Repository: crosslife/OpenBird Branch: master Commit: 9e0198a1a229 Files: 3587 Total size: 146.3 MB Directory structure: gitextract_sexonwb9/ ├── .gitignore ├── CMakeLists.txt ├── Classes/ │ ├── AdmobHelper.cpp │ ├── AdmobHelper.h │ ├── AppDelegate.cpp │ ├── AppDelegate.h │ └── LuaInterface/ │ ├── lua_tinker.cpp │ ├── lua_tinker.h │ └── luaconf.h ├── LICENSE ├── README.md ├── Resources/ │ ├── AudioEngine.lua │ ├── CCBReaderLoad.lua │ ├── CocoStudio.lua │ ├── Cocos2d.lua │ ├── Cocos2dConstants.lua │ ├── Deprecated.lua │ ├── DeprecatedClass.lua │ ├── DeprecatedEnum.lua │ ├── DeprecatedOpenglEnum.lua │ ├── DrawPrimitives.lua │ ├── GuiConstants.lua │ ├── Opengl.lua │ ├── OpenglConstants.lua │ ├── StudioConstants.lua │ ├── extern.lua │ ├── json.lua │ ├── luaj.lua │ ├── luaoc.lua │ ├── main.lua │ ├── mobdebug.lua │ ├── res/ │ │ ├── atlas.txt │ │ ├── sfx_die.ogg │ │ ├── sfx_hit.ogg │ │ ├── sfx_point.ogg │ │ ├── sfx_swooshing.ogg │ │ └── sfx_wing.ogg │ └── scripts/ │ ├── GameScene.lua │ ├── StartScene.lua │ ├── out.lua │ └── tools.lua ├── cocos2d/ │ ├── .gitattributes │ ├── .gitignore │ ├── .gitmodules │ ├── .travis.yml │ ├── AUTHORS │ ├── CHANGELOG │ ├── CMakeLists.txt │ ├── README.md │ ├── build/ │ │ ├── BuildHelpers.CMakeLists.txt │ │ ├── android-build.py │ │ ├── build-mingw32-gcc-make.sh │ │ ├── cocos2d-win32.vc2012.sln │ │ ├── cocos2d_libs.xcodeproj/ │ │ │ └── project.pbxproj │ │ ├── cocos2d_samples.xcodeproj/ │ │ │ └── project.pbxproj │ │ ├── install-deps-linux.sh │ │ ├── win32-msvc-2012-x86.cmd │ │ └── win32-msvc-2013-x86.cmd │ ├── cocos/ │ │ ├── 2d/ │ │ │ ├── Android.mk │ │ │ ├── CCAction.cpp │ │ │ ├── CCAction.h │ │ │ ├── CCActionCamera.cpp │ │ │ ├── CCActionCamera.h │ │ │ ├── CCActionCatmullRom.cpp │ │ │ ├── CCActionCatmullRom.h │ │ │ ├── CCActionEase.cpp │ │ │ ├── CCActionEase.h │ │ │ ├── CCActionGrid.cpp │ │ │ ├── CCActionGrid.h │ │ │ ├── CCActionGrid3D.cpp │ │ │ ├── CCActionGrid3D.h │ │ │ ├── CCActionInstant.cpp │ │ │ ├── CCActionInstant.h │ │ │ ├── CCActionInterval.cpp │ │ │ ├── CCActionInterval.h │ │ │ ├── CCActionManager.cpp │ │ │ ├── CCActionManager.h │ │ │ ├── CCActionPageTurn3D.cpp │ │ │ ├── CCActionPageTurn3D.h │ │ │ ├── CCActionProgressTimer.cpp │ │ │ ├── CCActionProgressTimer.h │ │ │ ├── CCActionTiledGrid.cpp │ │ │ ├── CCActionTiledGrid.h │ │ │ ├── CCActionTween.cpp │ │ │ ├── CCActionTween.h │ │ │ ├── CCAnimation.cpp │ │ │ ├── CCAnimation.h │ │ │ ├── CCAnimationCache.cpp │ │ │ ├── CCAnimationCache.h │ │ │ ├── CCAtlasNode.cpp │ │ │ ├── CCAtlasNode.h │ │ │ ├── CCClippingNode.cpp │ │ │ ├── CCClippingNode.h │ │ │ ├── CCComponent.cpp │ │ │ ├── CCComponent.h │ │ │ ├── CCComponentContainer.cpp │ │ │ ├── CCComponentContainer.h │ │ │ ├── CCConfiguration.cpp │ │ │ ├── CCConfiguration.h │ │ │ ├── CCDeprecated.cpp │ │ │ ├── CCDeprecated.h │ │ │ ├── CCDirector.cpp │ │ │ ├── CCDirector.h │ │ │ ├── CCDrawNode.cpp │ │ │ ├── CCDrawNode.h │ │ │ ├── CCDrawingPrimitives.cpp │ │ │ ├── CCDrawingPrimitives.h │ │ │ ├── CCEvent.cpp │ │ │ ├── CCEvent.h │ │ │ ├── CCEventAcceleration.cpp │ │ │ ├── CCEventAcceleration.h │ │ │ ├── CCEventCustom.cpp │ │ │ ├── CCEventCustom.h │ │ │ ├── CCEventDispatcher.cpp │ │ │ ├── CCEventDispatcher.h │ │ │ ├── CCEventKeyboard.cpp │ │ │ ├── CCEventKeyboard.h │ │ │ ├── CCEventListener.cpp │ │ │ ├── CCEventListener.h │ │ │ ├── CCEventListenerAcceleration.cpp │ │ │ ├── CCEventListenerAcceleration.h │ │ │ ├── CCEventListenerCustom.cpp │ │ │ ├── CCEventListenerCustom.h │ │ │ ├── CCEventListenerKeyboard.cpp │ │ │ ├── CCEventListenerKeyboard.h │ │ │ ├── CCEventListenerMouse.cpp │ │ │ ├── CCEventListenerMouse.h │ │ │ ├── CCEventListenerTouch.cpp │ │ │ ├── CCEventListenerTouch.h │ │ │ ├── CCEventMouse.cpp │ │ │ ├── CCEventMouse.h │ │ │ ├── CCEventTouch.cpp │ │ │ ├── CCEventTouch.h │ │ │ ├── CCEventType.h │ │ │ ├── CCFont.cpp │ │ │ ├── CCFont.h │ │ │ ├── CCFontAtlas.cpp │ │ │ ├── CCFontAtlas.h │ │ │ ├── CCFontAtlasCache.cpp │ │ │ ├── CCFontAtlasCache.h │ │ │ ├── CCFontCharMap.cpp │ │ │ ├── CCFontCharMap.h │ │ │ ├── CCFontFNT.cpp │ │ │ ├── CCFontFNT.h │ │ │ ├── CCFontFreeType.cpp │ │ │ ├── CCFontFreeType.h │ │ │ ├── CCGLBufferedNode.cpp │ │ │ ├── CCGLBufferedNode.h │ │ │ ├── CCGLProgram.cpp │ │ │ ├── CCGLProgram.h │ │ │ ├── CCGrabber.cpp │ │ │ ├── CCGrabber.h │ │ │ ├── CCGrid.cpp │ │ │ ├── CCGrid.h │ │ │ ├── CCIMEDelegate.h │ │ │ ├── CCIMEDispatcher.cpp │ │ │ ├── CCIMEDispatcher.h │ │ │ ├── CCLabel.cpp │ │ │ ├── CCLabel.h │ │ │ ├── CCLabelAtlas.cpp │ │ │ ├── CCLabelAtlas.h │ │ │ ├── CCLabelBMFont.cpp │ │ │ ├── CCLabelBMFont.h │ │ │ ├── CCLabelTTF.cpp │ │ │ ├── CCLabelTTF.h │ │ │ ├── CCLabelTextFormatter.cpp │ │ │ ├── CCLabelTextFormatter.h │ │ │ ├── CCLayer.cpp │ │ │ ├── CCLayer.h │ │ │ ├── CCMenu.cpp │ │ │ ├── CCMenu.h │ │ │ ├── CCMenuItem.cpp │ │ │ ├── CCMenuItem.h │ │ │ ├── CCMotionStreak.cpp │ │ │ ├── CCMotionStreak.h │ │ │ ├── CCNode.cpp │ │ │ ├── CCNode.h │ │ │ ├── CCNodeGrid.cpp │ │ │ ├── CCNodeGrid.h │ │ │ ├── CCNotificationCenter.cpp │ │ │ ├── CCNotificationCenter.h │ │ │ ├── CCParallaxNode.cpp │ │ │ ├── CCParallaxNode.h │ │ │ ├── CCParticleBatchNode.cpp │ │ │ ├── CCParticleBatchNode.h │ │ │ ├── CCParticleExamples.cpp │ │ │ ├── CCParticleExamples.h │ │ │ ├── CCParticleSystem.cpp │ │ │ ├── CCParticleSystem.h │ │ │ ├── CCParticleSystemQuad.cpp │ │ │ ├── CCParticleSystemQuad.h │ │ │ ├── CCProfiling.cpp │ │ │ ├── CCProfiling.h │ │ │ ├── CCProgressTimer.cpp │ │ │ ├── CCProgressTimer.h │ │ │ ├── CCProtocols.h │ │ │ ├── CCRenderTexture.cpp │ │ │ ├── CCRenderTexture.h │ │ │ ├── CCScene.cpp │ │ │ ├── CCScene.h │ │ │ ├── CCScheduler.cpp │ │ │ ├── CCScheduler.h │ │ │ ├── CCScriptSupport.cpp │ │ │ ├── CCScriptSupport.h │ │ │ ├── CCShaderCache.cpp │ │ │ ├── CCShaderCache.h │ │ │ ├── CCSprite.cpp │ │ │ ├── CCSprite.h │ │ │ ├── CCSpriteBatchNode.cpp │ │ │ ├── CCSpriteBatchNode.h │ │ │ ├── CCSpriteFrame.cpp │ │ │ ├── CCSpriteFrame.h │ │ │ ├── CCSpriteFrameCache.cpp │ │ │ ├── CCSpriteFrameCache.h │ │ │ ├── CCTMXLayer.cpp │ │ │ ├── CCTMXLayer.h │ │ │ ├── CCTMXObjectGroup.cpp │ │ │ ├── CCTMXObjectGroup.h │ │ │ ├── CCTMXTiledMap.cpp │ │ │ ├── CCTMXTiledMap.h │ │ │ ├── CCTMXXMLParser.cpp │ │ │ ├── CCTMXXMLParser.h │ │ │ ├── CCTextFieldTTF.cpp │ │ │ ├── CCTextFieldTTF.h │ │ │ ├── CCTexture2D.cpp │ │ │ ├── CCTexture2D.h │ │ │ ├── CCTextureAtlas.cpp │ │ │ ├── CCTextureAtlas.h │ │ │ ├── CCTextureCache.cpp │ │ │ ├── CCTextureCache.h │ │ │ ├── CCTileMapAtlas.cpp │ │ │ ├── CCTileMapAtlas.h │ │ │ ├── CCTouch.cpp │ │ │ ├── CCTouch.h │ │ │ ├── CCTransition.cpp │ │ │ ├── CCTransition.h │ │ │ ├── CCTransitionPageTurn.cpp │ │ │ ├── CCTransitionPageTurn.h │ │ │ ├── CCTransitionProgress.cpp │ │ │ ├── CCTransitionProgress.h │ │ │ ├── CCUserDefault.cpp │ │ │ ├── CCUserDefault.h │ │ │ ├── CCUserDefault.mm │ │ │ ├── CCUserDefaultAndroid.cpp │ │ │ ├── CCVertex.cpp │ │ │ ├── CCVertex.h │ │ │ ├── CMakeLists.txt │ │ │ ├── TGAlib.cpp │ │ │ ├── TGAlib.h │ │ │ ├── TransformUtils.cpp │ │ │ ├── TransformUtils.h │ │ │ ├── ZipUtils.cpp │ │ │ ├── ZipUtils.h │ │ │ ├── base64.cpp │ │ │ ├── base64.h │ │ │ ├── ccCArray.cpp │ │ │ ├── ccCArray.h │ │ │ ├── ccConfig.h │ │ │ ├── ccFPSImages.c │ │ │ ├── ccFPSImages.h │ │ │ ├── ccGLStateCache.cpp │ │ │ ├── ccGLStateCache.h │ │ │ ├── ccMacros.h │ │ │ ├── ccShaderEx_SwitchMask_frag.h │ │ │ ├── ccShader_Label_frag.h │ │ │ ├── ccShader_Label_frag_glow.h │ │ │ ├── ccShader_Label_frag_outline.h │ │ │ ├── ccShader_Label_frag_shadow.h │ │ │ ├── ccShader_Label_vert.h │ │ │ ├── ccShader_PositionColorLengthTexture_frag.h │ │ │ ├── ccShader_PositionColorLengthTexture_vert.h │ │ │ ├── ccShader_PositionColor_frag.h │ │ │ ├── ccShader_PositionColor_vert.h │ │ │ ├── ccShader_PositionTextureA8Color_frag.h │ │ │ ├── ccShader_PositionTextureA8Color_vert.h │ │ │ ├── ccShader_PositionTextureColorAlphaTest_frag.h │ │ │ ├── ccShader_PositionTextureColor_frag.h │ │ │ ├── ccShader_PositionTextureColor_noMVP_frag.h │ │ │ ├── ccShader_PositionTextureColor_noMVP_vert.h │ │ │ ├── ccShader_PositionTextureColor_vert.h │ │ │ ├── ccShader_PositionTexture_frag.h │ │ │ ├── ccShader_PositionTexture_uColor_frag.h │ │ │ ├── ccShader_PositionTexture_uColor_vert.h │ │ │ ├── ccShader_PositionTexture_vert.h │ │ │ ├── ccShader_Position_uColor_frag.h │ │ │ ├── ccShader_Position_uColor_vert.h │ │ │ ├── ccShaders.cpp │ │ │ ├── ccShaders.h │ │ │ ├── ccTypes.cpp │ │ │ ├── ccTypes.h │ │ │ ├── ccUTF8.cpp │ │ │ ├── ccUTF8.h │ │ │ ├── ccUtils.cpp │ │ │ ├── ccUtils.h │ │ │ ├── cocos2d.cpp │ │ │ ├── cocos2d.h │ │ │ ├── cocos2d.vcxproj │ │ │ ├── cocos2d.vcxproj.filters │ │ │ ├── cocos2d_headers.props │ │ │ ├── cocos2dx-Prefix.pch │ │ │ ├── cocos2dx.props │ │ │ ├── firePngData.h │ │ │ ├── platform/ │ │ │ │ ├── CCApplicationProtocol.h │ │ │ │ ├── CCCommon.h │ │ │ │ ├── CCDevice.h │ │ │ │ ├── CCEGLViewProtocol.cpp │ │ │ │ ├── CCEGLViewProtocol.h │ │ │ │ ├── CCFileUtils.cpp │ │ │ │ ├── CCFileUtils.h │ │ │ │ ├── CCImage.h │ │ │ │ ├── CCImageCommon_cpp.h │ │ │ │ ├── CCSAXParser.cpp │ │ │ │ ├── CCSAXParser.h │ │ │ │ ├── CCThread.cpp │ │ │ │ ├── CCThread.h │ │ │ │ ├── android/ │ │ │ │ │ ├── Android.mk │ │ │ │ │ ├── CCApplication.cpp │ │ │ │ │ ├── CCApplication.h │ │ │ │ │ ├── CCCommon.cpp │ │ │ │ │ ├── CCDevice.cpp │ │ │ │ │ ├── CCEGLView.cpp │ │ │ │ │ ├── CCEGLView.h │ │ │ │ │ ├── CCFileUtilsAndroid.cpp │ │ │ │ │ ├── CCFileUtilsAndroid.h │ │ │ │ │ ├── CCGL.h │ │ │ │ │ ├── CCImage.cpp │ │ │ │ │ ├── CCPlatformDefine.h │ │ │ │ │ ├── CCStdC.h │ │ │ │ │ ├── java/ │ │ │ │ │ │ ├── .classpath │ │ │ │ │ │ ├── .project │ │ │ │ │ │ ├── .settings/ │ │ │ │ │ │ │ └── org.eclipse.jdt.core.prefs │ │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ │ ├── ant.properties │ │ │ │ │ │ ├── build.xml │ │ │ │ │ │ ├── proguard-project.txt │ │ │ │ │ │ ├── project.properties │ │ │ │ │ │ ├── res/ │ │ │ │ │ │ │ └── .gitignore │ │ │ │ │ │ └── src/ │ │ │ │ │ │ └── org/ │ │ │ │ │ │ └── cocos2dx/ │ │ │ │ │ │ └── lib/ │ │ │ │ │ │ ├── Cocos2dxBitmap.java │ │ │ │ │ │ ├── Cocos2dxEditBoxDialog.java │ │ │ │ │ │ ├── Cocos2dxEditText.java │ │ │ │ │ │ ├── Cocos2dxHelper.java │ │ │ │ │ │ ├── Cocos2dxLocalStorage.java │ │ │ │ │ │ ├── Cocos2dxLuaJavaBridge.java │ │ │ │ │ │ ├── Cocos2dxMusic.java │ │ │ │ │ │ ├── Cocos2dxSound.java │ │ │ │ │ │ └── Cocos2dxTypefaces.java │ │ │ │ │ ├── jni/ │ │ │ │ │ │ ├── DPIJni.cpp │ │ │ │ │ │ ├── DPIJni.h │ │ │ │ │ │ ├── IMEJni.cpp │ │ │ │ │ │ ├── IMEJni.h │ │ │ │ │ │ ├── Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp │ │ │ │ │ │ ├── Java_org_cocos2dx_lib_Cocos2dxBitmap.h │ │ │ │ │ │ ├── Java_org_cocos2dx_lib_Cocos2dxHelper.cpp │ │ │ │ │ │ ├── Java_org_cocos2dx_lib_Cocos2dxHelper.h │ │ │ │ │ │ ├── JniHelper.cpp │ │ │ │ │ │ └── JniHelper.h │ │ │ │ │ ├── nativeactivity.cpp │ │ │ │ │ └── nativeactivity.h │ │ │ │ ├── apple/ │ │ │ │ │ ├── CCFileUtilsApple.h │ │ │ │ │ ├── CCFileUtilsApple.mm │ │ │ │ │ ├── CCLock.cpp │ │ │ │ │ ├── CCLock.h │ │ │ │ │ └── CCThread.mm │ │ │ │ ├── desktop/ │ │ │ │ │ ├── CCEGLView.cpp │ │ │ │ │ └── CCEGLView.h │ │ │ │ ├── ios/ │ │ │ │ │ ├── CCApplication.h │ │ │ │ │ ├── CCApplication.mm │ │ │ │ │ ├── CCCommon.mm │ │ │ │ │ ├── CCDevice.mm │ │ │ │ │ ├── CCDirectorCaller.h │ │ │ │ │ ├── CCDirectorCaller.mm │ │ │ │ │ ├── CCEGLView.h │ │ │ │ │ ├── CCEGLView.mm │ │ │ │ │ ├── CCES2Renderer.h │ │ │ │ │ ├── CCES2Renderer.m │ │ │ │ │ ├── CCESRenderer.h │ │ │ │ │ ├── CCGL.h │ │ │ │ │ ├── CCImage.mm │ │ │ │ │ ├── CCPlatformDefine.h │ │ │ │ │ ├── CCStdC.h │ │ │ │ │ ├── EAGLView.h │ │ │ │ │ ├── EAGLView.mm │ │ │ │ │ ├── OpenGL_Internal.h │ │ │ │ │ └── Simulation/ │ │ │ │ │ ├── AccelerometerSimulation.h │ │ │ │ │ └── AccelerometerSimulation.m │ │ │ │ ├── linux/ │ │ │ │ │ ├── CCApplication.cpp │ │ │ │ │ ├── CCApplication.h │ │ │ │ │ ├── CCCommon.cpp │ │ │ │ │ ├── CCDevice.cpp │ │ │ │ │ ├── CCFileUtilsLinux.cpp │ │ │ │ │ ├── CCFileUtilsLinux.h │ │ │ │ │ ├── CCGL.h │ │ │ │ │ ├── CCImage.cpp │ │ │ │ │ ├── CCPlatformDefine.h │ │ │ │ │ ├── CCStdC.cpp │ │ │ │ │ └── CCStdC.h │ │ │ │ ├── mac/ │ │ │ │ │ ├── CCApplication.h │ │ │ │ │ ├── CCApplication.mm │ │ │ │ │ ├── CCCommon.mm │ │ │ │ │ ├── CCDevice.cpp │ │ │ │ │ ├── CCDirectorCaller.h │ │ │ │ │ ├── CCDirectorCaller.mm │ │ │ │ │ ├── CCGL.h │ │ │ │ │ ├── CCImage.mm │ │ │ │ │ ├── CCPlatformDefine.h │ │ │ │ │ └── CCStdC.h │ │ │ │ └── win32/ │ │ │ │ ├── CCApplication.cpp │ │ │ │ ├── CCApplication.h │ │ │ │ ├── CCCommon.cpp │ │ │ │ ├── CCDevice.cpp │ │ │ │ ├── CCFileUtilsWin32.cpp │ │ │ │ ├── CCFileUtilsWin32.h │ │ │ │ ├── CCGL.h │ │ │ │ ├── CCImage.cpp │ │ │ │ ├── CCPlatformDefine.h │ │ │ │ ├── CCStdC.cpp │ │ │ │ ├── CCStdC.h │ │ │ │ └── compat/ │ │ │ │ └── stdint.h │ │ │ ├── renderer/ │ │ │ │ ├── CCBatchCommand.cpp │ │ │ │ ├── CCBatchCommand.h │ │ │ │ ├── CCCustomCommand.cpp │ │ │ │ ├── CCCustomCommand.h │ │ │ │ ├── CCFrustum.cpp │ │ │ │ ├── CCFrustum.h │ │ │ │ ├── CCGroupCommand.cpp │ │ │ │ ├── CCGroupCommand.h │ │ │ │ ├── CCMaterialManager.cpp │ │ │ │ ├── CCMaterialManager.h │ │ │ │ ├── CCQuadCommand.cpp │ │ │ │ ├── CCQuadCommand.h │ │ │ │ ├── CCRenderCommand.cpp │ │ │ │ ├── CCRenderCommand.h │ │ │ │ ├── CCRenderCommandPool.h │ │ │ │ ├── CCRenderMaterial.cpp │ │ │ │ ├── CCRenderMaterial.h │ │ │ │ ├── CCRenderer.cpp │ │ │ │ └── CCRenderer.h │ │ │ ├── uthash.h │ │ │ └── utlist.h │ │ ├── audio/ │ │ │ ├── CMakeLists.txt │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── ccdandroidUtils.cpp │ │ │ │ ├── ccdandroidUtils.h │ │ │ │ ├── cddSimpleAudioEngine.cpp │ │ │ │ ├── jni/ │ │ │ │ │ ├── cddandroidAndroidJavaEngine.cpp │ │ │ │ │ └── cddandroidAndroidJavaEngine.h │ │ │ │ └── opensl/ │ │ │ │ ├── OpenSLEngine.cpp │ │ │ │ ├── OpenSLEngine.h │ │ │ │ ├── SimpleAudioEngineOpenSL.cpp │ │ │ │ ├── SimpleAudioEngineOpenSL.h │ │ │ │ ├── cddandroidOpenSLEngine.cpp │ │ │ │ └── cddandroidOpenSLEngine.h │ │ │ ├── include/ │ │ │ │ ├── Export.h │ │ │ │ └── SimpleAudioEngine.h │ │ │ ├── ios/ │ │ │ │ ├── CDAudioManager.h │ │ │ │ ├── CDAudioManager.m │ │ │ │ ├── CDConfig.h │ │ │ │ ├── CDOpenALSupport.h │ │ │ │ ├── CDOpenALSupport.m │ │ │ │ ├── CocosDenshion.h │ │ │ │ ├── CocosDenshion.m │ │ │ │ ├── SimpleAudioEngine.mm │ │ │ │ ├── SimpleAudioEngine_objc.h │ │ │ │ └── SimpleAudioEngine_objc.m │ │ │ ├── linux/ │ │ │ │ ├── AudioPlayer.h │ │ │ │ ├── FmodAudioPlayer.cpp │ │ │ │ ├── FmodAudioPlayer.h │ │ │ │ └── SimpleAudioEngineFMOD.cpp │ │ │ ├── mac/ │ │ │ │ ├── CDAudioManager.h │ │ │ │ ├── CDAudioManager.m │ │ │ │ ├── CDConfig.h │ │ │ │ ├── CDOpenALSupport.h │ │ │ │ ├── CDOpenALSupport.m │ │ │ │ ├── CDXMacOSXSupport.h │ │ │ │ ├── CDXMacOSXSupport.mm │ │ │ │ ├── CocosDenshion.h │ │ │ │ ├── CocosDenshion.m │ │ │ │ ├── SimpleAudioEngine.mm │ │ │ │ ├── SimpleAudioEngine_objc.h │ │ │ │ └── SimpleAudioEngine_objc.m │ │ │ ├── openal/ │ │ │ │ ├── OpenALDecoder.cpp │ │ │ │ ├── OpenALDecoder.h │ │ │ │ └── SimpleAudioEngineOpenAL.cpp │ │ │ ├── proj.win32/ │ │ │ │ ├── CocosDenshion.vcxproj │ │ │ │ └── CocosDenshion.vcxproj.filters │ │ │ └── win32/ │ │ │ ├── MciPlayer.cpp │ │ │ ├── MciPlayer.h │ │ │ └── SimpleAudioEngine.cpp │ │ ├── base/ │ │ │ ├── CCAffineTransform.cpp │ │ │ ├── CCAffineTransform.h │ │ │ ├── CCArray.cpp │ │ │ ├── CCArray.h │ │ │ ├── CCAutoreleasePool.cpp │ │ │ ├── CCAutoreleasePool.h │ │ │ ├── CCBool.h │ │ │ ├── CCConsole.cpp │ │ │ ├── CCConsole.h │ │ │ ├── CCData.cpp │ │ │ ├── CCData.h │ │ │ ├── CCDataVisitor.cpp │ │ │ ├── CCDataVisitor.h │ │ │ ├── CCDictionary.cpp │ │ │ ├── CCDictionary.h │ │ │ ├── CCDouble.h │ │ │ ├── CCFloat.h │ │ │ ├── CCGeometry.cpp │ │ │ ├── CCGeometry.h │ │ │ ├── CCInteger.h │ │ │ ├── CCMap.h │ │ │ ├── CCNS.cpp │ │ │ ├── CCNS.h │ │ │ ├── CCObject.cpp │ │ │ ├── CCObject.h │ │ │ ├── CCPlatformConfig.h │ │ │ ├── CCPlatformMacros.h │ │ │ ├── CCSet.cpp │ │ │ ├── CCSet.h │ │ │ ├── CCString.cpp │ │ │ ├── CCString.h │ │ │ ├── CCValue.cpp │ │ │ ├── CCValue.h │ │ │ ├── CCVector.h │ │ │ ├── CMakeLists.txt │ │ │ ├── atitc.cpp │ │ │ ├── atitc.h │ │ │ ├── etc1.cpp │ │ │ ├── etc1.h │ │ │ ├── s3tc.cpp │ │ │ └── s3tc.h │ │ ├── editor-support/ │ │ │ ├── cocosbuilder/ │ │ │ │ ├── Android.mk │ │ │ │ ├── CCBAnimationManager.cpp │ │ │ │ ├── CCBAnimationManager.h │ │ │ │ ├── CCBFileLoader.cpp │ │ │ │ ├── CCBFileLoader.h │ │ │ │ ├── CCBKeyframe.cpp │ │ │ │ ├── CCBKeyframe.h │ │ │ │ ├── CCBMemberVariableAssigner.h │ │ │ │ ├── CCBReader.cpp │ │ │ │ ├── CCBReader.h │ │ │ │ ├── CCBSelectorResolver.h │ │ │ │ ├── CCBSequence.cpp │ │ │ │ ├── CCBSequence.h │ │ │ │ ├── CCBSequenceProperty.cpp │ │ │ │ ├── CCBSequenceProperty.h │ │ │ │ ├── CCControlButtonLoader.cpp │ │ │ │ ├── CCControlButtonLoader.h │ │ │ │ ├── CCControlLoader.cpp │ │ │ │ ├── CCControlLoader.h │ │ │ │ ├── CCLabelBMFontLoader.cpp │ │ │ │ ├── CCLabelBMFontLoader.h │ │ │ │ ├── CCLabelTTFLoader.cpp │ │ │ │ ├── CCLabelTTFLoader.h │ │ │ │ ├── CCLayerColorLoader.cpp │ │ │ │ ├── CCLayerColorLoader.h │ │ │ │ ├── CCLayerGradientLoader.cpp │ │ │ │ ├── CCLayerGradientLoader.h │ │ │ │ ├── CCLayerLoader.cpp │ │ │ │ ├── CCLayerLoader.h │ │ │ │ ├── CCMenuItemImageLoader.cpp │ │ │ │ ├── CCMenuItemImageLoader.h │ │ │ │ ├── CCMenuItemLoader.cpp │ │ │ │ ├── CCMenuItemLoader.h │ │ │ │ ├── CCMenuLoader.h │ │ │ │ ├── CCNode+CCBRelativePositioning.cpp │ │ │ │ ├── CCNode+CCBRelativePositioning.h │ │ │ │ ├── CCNodeLoader.cpp │ │ │ │ ├── CCNodeLoader.h │ │ │ │ ├── CCNodeLoaderLibrary.cpp │ │ │ │ ├── CCNodeLoaderLibrary.h │ │ │ │ ├── CCNodeLoaderListener.h │ │ │ │ ├── CCParticleSystemQuadLoader.cpp │ │ │ │ ├── CCParticleSystemQuadLoader.h │ │ │ │ ├── CCScale9SpriteLoader.cpp │ │ │ │ ├── CCScale9SpriteLoader.h │ │ │ │ ├── CCScrollViewLoader.cpp │ │ │ │ ├── CCScrollViewLoader.h │ │ │ │ ├── CCSpriteLoader.cpp │ │ │ │ ├── CCSpriteLoader.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── CocosBuilder.h │ │ │ │ └── proj.win32/ │ │ │ │ ├── libCocosBuilder.vcxproj │ │ │ │ └── libCocosBuilder.vcxproj.filters │ │ │ ├── cocostudio/ │ │ │ │ ├── Android.mk │ │ │ │ ├── CCActionEaseEx.cpp │ │ │ │ ├── CCActionEaseEx.h │ │ │ │ ├── CCActionFrame.cpp │ │ │ │ ├── CCActionFrame.h │ │ │ │ ├── CCActionFrameEasing.cpp │ │ │ │ ├── CCActionFrameEasing.h │ │ │ │ ├── CCActionManagerEx.cpp │ │ │ │ ├── CCActionManagerEx.h │ │ │ │ ├── CCActionNode.cpp │ │ │ │ ├── CCActionNode.h │ │ │ │ ├── CCActionObject.cpp │ │ │ │ ├── CCActionObject.h │ │ │ │ ├── CCArmature.cpp │ │ │ │ ├── CCArmature.h │ │ │ │ ├── CCArmatureAnimation.cpp │ │ │ │ ├── CCArmatureAnimation.h │ │ │ │ ├── CCArmatureDataManager.cpp │ │ │ │ ├── CCArmatureDataManager.h │ │ │ │ ├── CCArmatureDefine.cpp │ │ │ │ ├── CCArmatureDefine.h │ │ │ │ ├── CCBatchNode.cpp │ │ │ │ ├── CCBatchNode.h │ │ │ │ ├── CCBone.cpp │ │ │ │ ├── CCBone.h │ │ │ │ ├── CCColliderDetector.cpp │ │ │ │ ├── CCColliderDetector.h │ │ │ │ ├── CCComAttribute.cpp │ │ │ │ ├── CCComAttribute.h │ │ │ │ ├── CCComAudio.cpp │ │ │ │ ├── CCComAudio.h │ │ │ │ ├── CCComBase.h │ │ │ │ ├── CCComController.cpp │ │ │ │ ├── CCComController.h │ │ │ │ ├── CCComRender.cpp │ │ │ │ ├── CCComRender.h │ │ │ │ ├── CCDataReaderHelper.cpp │ │ │ │ ├── CCDataReaderHelper.h │ │ │ │ ├── CCDatas.cpp │ │ │ │ ├── CCDatas.h │ │ │ │ ├── CCDecorativeDisplay.cpp │ │ │ │ ├── CCDecorativeDisplay.h │ │ │ │ ├── CCDisplayFactory.cpp │ │ │ │ ├── CCDisplayFactory.h │ │ │ │ ├── CCDisplayManager.cpp │ │ │ │ ├── CCDisplayManager.h │ │ │ │ ├── CCInputDelegate.cpp │ │ │ │ ├── CCInputDelegate.h │ │ │ │ ├── CCProcessBase.cpp │ │ │ │ ├── CCProcessBase.h │ │ │ │ ├── CCSGUIReader.cpp │ │ │ │ ├── CCSGUIReader.h │ │ │ │ ├── CCSSceneReader.cpp │ │ │ │ ├── CCSSceneReader.h │ │ │ │ ├── CCSkin.cpp │ │ │ │ ├── CCSkin.h │ │ │ │ ├── CCSpriteFrameCacheHelper.cpp │ │ │ │ ├── CCSpriteFrameCacheHelper.h │ │ │ │ ├── CCTransformHelp.cpp │ │ │ │ ├── CCTransformHelp.h │ │ │ │ ├── CCTween.cpp │ │ │ │ ├── CCTween.h │ │ │ │ ├── CCTweenFunction.cpp │ │ │ │ ├── CCTweenFunction.h │ │ │ │ ├── CCUtilMath.cpp │ │ │ │ ├── CCUtilMath.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── CocoStudio.h │ │ │ │ ├── DictionaryHelper.cpp │ │ │ │ ├── DictionaryHelper.h │ │ │ │ ├── ObjectFactory.cpp │ │ │ │ ├── ObjectFactory.h │ │ │ │ ├── TriggerBase.cpp │ │ │ │ ├── TriggerBase.h │ │ │ │ ├── TriggerMng.cpp │ │ │ │ ├── TriggerMng.h │ │ │ │ ├── TriggerObj.cpp │ │ │ │ ├── TriggerObj.h │ │ │ │ └── proj.win32/ │ │ │ │ ├── libCocosStudio.vcxproj │ │ │ │ └── libCocosStudio.vcxproj.filters │ │ │ └── spine/ │ │ │ ├── Android.mk │ │ │ ├── Animation.cpp │ │ │ ├── Animation.h │ │ │ ├── AnimationState.cpp │ │ │ ├── AnimationState.h │ │ │ ├── AnimationStateData.cpp │ │ │ ├── AnimationStateData.h │ │ │ ├── Atlas.cpp │ │ │ ├── Atlas.h │ │ │ ├── AtlasAttachmentLoader.cpp │ │ │ ├── AtlasAttachmentLoader.h │ │ │ ├── Attachment.cpp │ │ │ ├── Attachment.h │ │ │ ├── AttachmentLoader.cpp │ │ │ ├── AttachmentLoader.h │ │ │ ├── Bone.cpp │ │ │ ├── Bone.h │ │ │ ├── BoneData.cpp │ │ │ ├── BoneData.h │ │ │ ├── BoundingBoxAttachment.cpp │ │ │ ├── BoundingBoxAttachment.h │ │ │ ├── CCSkeleton.cpp │ │ │ ├── CCSkeleton.h │ │ │ ├── CCSkeletonAnimation.cpp │ │ │ ├── CCSkeletonAnimation.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Event.cpp │ │ │ ├── Event.h │ │ │ ├── EventData.cpp │ │ │ ├── EventData.h │ │ │ ├── Json.cpp │ │ │ ├── Json.h │ │ │ ├── RegionAttachment.cpp │ │ │ ├── RegionAttachment.h │ │ │ ├── Skeleton.cpp │ │ │ ├── Skeleton.h │ │ │ ├── SkeletonBounds.cpp │ │ │ ├── SkeletonBounds.h │ │ │ ├── SkeletonData.cpp │ │ │ ├── SkeletonData.h │ │ │ ├── SkeletonJson.cpp │ │ │ ├── SkeletonJson.h │ │ │ ├── Skin.cpp │ │ │ ├── Skin.h │ │ │ ├── Slot.cpp │ │ │ ├── Slot.h │ │ │ ├── SlotData.cpp │ │ │ ├── SlotData.h │ │ │ ├── extension.cpp │ │ │ ├── extension.h │ │ │ ├── proj.win32/ │ │ │ │ ├── libSpine.vcxproj │ │ │ │ └── libSpine.vcxproj.filters │ │ │ ├── spine-cocos2dx.cpp │ │ │ ├── spine-cocos2dx.h │ │ │ └── spine.h │ │ ├── gui/ │ │ │ ├── Android.mk │ │ │ ├── CMakeLists.txt │ │ │ ├── CocosGUI.cpp │ │ │ ├── CocosGUI.h │ │ │ ├── UIButton.cpp │ │ │ ├── UIButton.h │ │ │ ├── UICheckBox.cpp │ │ │ ├── UICheckBox.h │ │ │ ├── UIHelper.cpp │ │ │ ├── UIHelper.h │ │ │ ├── UIImageView.cpp │ │ │ ├── UIImageView.h │ │ │ ├── UILayout.cpp │ │ │ ├── UILayout.h │ │ │ ├── UILayoutDefine.cpp │ │ │ ├── UILayoutDefine.h │ │ │ ├── UILayoutParameter.cpp │ │ │ ├── UILayoutParameter.h │ │ │ ├── UIListView.cpp │ │ │ ├── UIListView.h │ │ │ ├── UILoadingBar.cpp │ │ │ ├── UILoadingBar.h │ │ │ ├── UIPageView.cpp │ │ │ ├── UIPageView.h │ │ │ ├── UIScrollInterface.h │ │ │ ├── UIScrollView.cpp │ │ │ ├── UIScrollView.h │ │ │ ├── UISlider.cpp │ │ │ ├── UISlider.h │ │ │ ├── UIText.cpp │ │ │ ├── UIText.h │ │ │ ├── UITextAtlas.cpp │ │ │ ├── UITextAtlas.h │ │ │ ├── UITextBMFont.cpp │ │ │ ├── UITextBMFont.h │ │ │ ├── UITextField.cpp │ │ │ ├── UITextField.h │ │ │ ├── UIWidget.cpp │ │ │ ├── UIWidget.h │ │ │ └── proj.win32/ │ │ │ ├── libGUI.vcxproj │ │ │ └── libGUI.vcxproj.filters │ │ ├── math/ │ │ │ └── kazmath/ │ │ │ ├── CMakeLists.txt │ │ │ ├── include/ │ │ │ │ └── kazmath/ │ │ │ │ ├── GL/ │ │ │ │ │ ├── mat4stack.h │ │ │ │ │ └── matrix.h │ │ │ │ ├── aabb.h │ │ │ │ ├── kazmath.h │ │ │ │ ├── mat3.h │ │ │ │ ├── mat4.h │ │ │ │ ├── neon_matrix_impl.h │ │ │ │ ├── plane.h │ │ │ │ ├── quaternion.h │ │ │ │ ├── ray2.h │ │ │ │ ├── utility.h │ │ │ │ ├── vec2.h │ │ │ │ ├── vec3.h │ │ │ │ └── vec4.h │ │ │ └── src/ │ │ │ ├── CMakeLists.txt │ │ │ ├── ChangeLog │ │ │ ├── GL/ │ │ │ │ ├── mat4stack.c │ │ │ │ └── matrix.c │ │ │ ├── aabb.c │ │ │ ├── mat3.c │ │ │ ├── mat4.c │ │ │ ├── neon_matrix_impl.c │ │ │ ├── plane.c │ │ │ ├── quaternion.c │ │ │ ├── ray2.c │ │ │ ├── utility.c │ │ │ ├── vec2.c │ │ │ ├── vec3.c │ │ │ └── vec4.c │ │ ├── network/ │ │ │ ├── Android.mk │ │ │ ├── CMakeLists.txt │ │ │ ├── HttpClient.cpp │ │ │ ├── HttpClient.h │ │ │ ├── HttpRequest.h │ │ │ ├── HttpResponse.h │ │ │ ├── SocketIO.cpp │ │ │ ├── SocketIO.h │ │ │ ├── WebSocket.cpp │ │ │ ├── WebSocket.h │ │ │ └── proj.win32/ │ │ │ ├── libNetwork.vcxproj │ │ │ └── libNetwork.vcxproj.filters │ │ ├── physics/ │ │ │ ├── CCPhysicsBody.cpp │ │ │ ├── CCPhysicsBody.h │ │ │ ├── CCPhysicsContact.cpp │ │ │ ├── CCPhysicsContact.h │ │ │ ├── CCPhysicsJoint.cpp │ │ │ ├── CCPhysicsJoint.h │ │ │ ├── CCPhysicsShape.cpp │ │ │ ├── CCPhysicsShape.h │ │ │ ├── CCPhysicsWorld.cpp │ │ │ ├── CCPhysicsWorld.h │ │ │ ├── CMakeLists.txt │ │ │ └── chipmunk/ │ │ │ ├── CCPhysicsBodyInfo_chipmunk.cpp │ │ │ ├── CCPhysicsBodyInfo_chipmunk.h │ │ │ ├── CCPhysicsContactInfo_chipmunk.cpp │ │ │ ├── CCPhysicsContactInfo_chipmunk.h │ │ │ ├── CCPhysicsHelper_chipmunk.h │ │ │ ├── CCPhysicsJointInfo_chipmunk.cpp │ │ │ ├── CCPhysicsJointInfo_chipmunk.h │ │ │ ├── CCPhysicsShapeInfo_chipmunk.cpp │ │ │ ├── CCPhysicsShapeInfo_chipmunk.h │ │ │ ├── CCPhysicsWorldInfo_chipmunk.cpp │ │ │ └── CCPhysicsWorldInfo_chipmunk.h │ │ ├── scripting/ │ │ │ ├── CMakeLists.txt │ │ │ ├── auto-generated/ │ │ │ │ ├── README.md │ │ │ │ ├── js-bindings/ │ │ │ │ │ ├── jsb_cocos2dx_auto.cpp │ │ │ │ │ ├── jsb_cocos2dx_auto.hpp │ │ │ │ │ ├── jsb_cocos2dx_auto_api.js │ │ │ │ │ ├── jsb_cocos2dx_builder_auto.cpp │ │ │ │ │ ├── jsb_cocos2dx_builder_auto.hpp │ │ │ │ │ ├── jsb_cocos2dx_builder_auto_api.js │ │ │ │ │ ├── jsb_cocos2dx_extension_auto.cpp │ │ │ │ │ ├── jsb_cocos2dx_extension_auto.hpp │ │ │ │ │ ├── jsb_cocos2dx_extension_auto_api.js │ │ │ │ │ ├── jsb_cocos2dx_gui_auto.cpp │ │ │ │ │ ├── jsb_cocos2dx_gui_auto.hpp │ │ │ │ │ ├── jsb_cocos2dx_gui_auto_api.js │ │ │ │ │ ├── jsb_cocos2dx_spine_auto.cpp │ │ │ │ │ ├── jsb_cocos2dx_spine_auto.hpp │ │ │ │ │ ├── jsb_cocos2dx_spine_auto_api.js │ │ │ │ │ ├── jsb_cocos2dx_studio_auto.cpp │ │ │ │ │ ├── jsb_cocos2dx_studio_auto.hpp │ │ │ │ │ └── jsb_cocos2dx_studio_auto_api.js │ │ │ │ └── lua-bindings/ │ │ │ │ ├── lua_cocos2dx_auto.cpp │ │ │ │ ├── lua_cocos2dx_auto.hpp │ │ │ │ ├── lua_cocos2dx_auto_api.js │ │ │ │ ├── lua_cocos2dx_extension_auto.cpp │ │ │ │ ├── lua_cocos2dx_extension_auto.hpp │ │ │ │ ├── lua_cocos2dx_extension_auto_api.js │ │ │ │ ├── lua_cocos2dx_gui_auto.cpp │ │ │ │ ├── lua_cocos2dx_gui_auto.hpp │ │ │ │ ├── lua_cocos2dx_gui_auto_api.js │ │ │ │ ├── lua_cocos2dx_physics_auto.cpp │ │ │ │ ├── lua_cocos2dx_physics_auto.hpp │ │ │ │ ├── lua_cocos2dx_physics_auto_api.js │ │ │ │ ├── lua_cocos2dx_spine_auto.cpp │ │ │ │ ├── lua_cocos2dx_spine_auto.hpp │ │ │ │ ├── lua_cocos2dx_spine_auto_api.js │ │ │ │ ├── lua_cocos2dx_studio_auto.cpp │ │ │ │ ├── lua_cocos2dx_studio_auto.hpp │ │ │ │ └── lua_cocos2dx_studio_auto_api.js │ │ │ ├── javascript/ │ │ │ │ ├── bindings/ │ │ │ │ │ ├── Android.mk │ │ │ │ │ ├── ScriptingCore.cpp │ │ │ │ │ ├── ScriptingCore.h │ │ │ │ │ ├── chipmunk/ │ │ │ │ │ │ ├── Android.mk │ │ │ │ │ │ ├── js_bindings_chipmunk_auto_classes.cpp │ │ │ │ │ │ ├── js_bindings_chipmunk_auto_classes.h │ │ │ │ │ │ ├── js_bindings_chipmunk_auto_classes_registration.h │ │ │ │ │ │ ├── js_bindings_chipmunk_functions.cpp │ │ │ │ │ │ ├── js_bindings_chipmunk_functions.h │ │ │ │ │ │ ├── js_bindings_chipmunk_functions_registration.h │ │ │ │ │ │ ├── js_bindings_chipmunk_manual.cpp │ │ │ │ │ │ ├── js_bindings_chipmunk_manual.h │ │ │ │ │ │ ├── js_bindings_chipmunk_registration.cpp │ │ │ │ │ │ ├── js_bindings_chipmunk_registration.h │ │ │ │ │ │ ├── libJSBindingForChipmunk.vcxproj │ │ │ │ │ │ └── libJSBindingForChipmunk.vcxproj.filters │ │ │ │ │ ├── cocos2d_specifics.cpp │ │ │ │ │ ├── cocos2d_specifics.hpp │ │ │ │ │ ├── cocosbuilder/ │ │ │ │ │ │ ├── Android.mk │ │ │ │ │ │ ├── cocosbuilder_specifics.hpp │ │ │ │ │ │ ├── js_bindings_ccbreader.cpp │ │ │ │ │ │ ├── js_bindings_ccbreader.h │ │ │ │ │ │ ├── libJSBindingForBuilder.vcxproj │ │ │ │ │ │ └── libJSBindingForBuilder.vcxproj.filters │ │ │ │ │ ├── cocostudio/ │ │ │ │ │ │ ├── Android.mk │ │ │ │ │ │ ├── jsb_cocos2dx_studio_manual.cpp │ │ │ │ │ │ ├── jsb_cocos2dx_studio_manual.h │ │ │ │ │ │ ├── libJSBindingForStudio.vcxproj │ │ │ │ │ │ └── libJSBindingForStudio.vcxproj.filters │ │ │ │ │ ├── extension/ │ │ │ │ │ │ ├── Android.mk │ │ │ │ │ │ ├── jsb_cocos2dx_extension_manual.cpp │ │ │ │ │ │ ├── jsb_cocos2dx_extension_manual.h │ │ │ │ │ │ ├── libJSBindingForExtension.vcxproj │ │ │ │ │ │ └── libJSBindingForExtension.vcxproj.filters │ │ │ │ │ ├── gui/ │ │ │ │ │ │ ├── Android.mk │ │ │ │ │ │ ├── jsb_cocos2dx_gui_manual.cpp │ │ │ │ │ │ ├── jsb_cocos2dx_gui_manual.h │ │ │ │ │ │ ├── libJSBindingForGui.vcxproj │ │ │ │ │ │ └── libJSBindingForGui.vcxproj.filters │ │ │ │ │ ├── js_bindings_config.h │ │ │ │ │ ├── js_bindings_core.cpp │ │ │ │ │ ├── js_bindings_core.h │ │ │ │ │ ├── js_bindings_opengl.cpp │ │ │ │ │ ├── js_bindings_opengl.h │ │ │ │ │ ├── js_manual_conversions.cpp │ │ │ │ │ ├── js_manual_conversions.h │ │ │ │ │ ├── jsb_helper.h │ │ │ │ │ ├── jsb_opengl_functions.cpp │ │ │ │ │ ├── jsb_opengl_functions.h │ │ │ │ │ ├── jsb_opengl_manual.cpp │ │ │ │ │ ├── jsb_opengl_manual.h │ │ │ │ │ ├── jsb_opengl_registration.cpp │ │ │ │ │ ├── jsb_opengl_registration.h │ │ │ │ │ ├── localstorage/ │ │ │ │ │ │ ├── Android.mk │ │ │ │ │ │ ├── js_bindings_system_functions.cpp │ │ │ │ │ │ ├── js_bindings_system_functions.h │ │ │ │ │ │ ├── js_bindings_system_functions_registration.h │ │ │ │ │ │ ├── js_bindings_system_registration.cpp │ │ │ │ │ │ ├── js_bindings_system_registration.h │ │ │ │ │ │ ├── libJSBindingForLocalStorage.vcxproj │ │ │ │ │ │ └── libJSBindingForLocalStorage.vcxproj.filters │ │ │ │ │ ├── network/ │ │ │ │ │ │ ├── Android.mk │ │ │ │ │ │ ├── XMLHTTPRequest.cpp │ │ │ │ │ │ ├── XMLHTTPRequest.h │ │ │ │ │ │ ├── jsb_websocket.cpp │ │ │ │ │ │ ├── jsb_websocket.h │ │ │ │ │ │ ├── libJSBindingForNetwork.vcxproj │ │ │ │ │ │ └── libJSBindingForNetwork.vcxproj.filters │ │ │ │ │ ├── proj.win32/ │ │ │ │ │ │ ├── libJSBinding.vcxproj │ │ │ │ │ │ └── libJSBinding.vcxproj.filters │ │ │ │ │ ├── spidermonkey_specifics.h │ │ │ │ │ └── spine/ │ │ │ │ │ ├── Android.mk │ │ │ │ │ ├── libJSBindingForSpine.vcxproj │ │ │ │ │ └── libJSBindingForSpine.vcxproj.filters │ │ │ │ └── script/ │ │ │ │ ├── debugger/ │ │ │ │ │ ├── DevToolsUtils.js │ │ │ │ │ ├── README.md │ │ │ │ │ ├── actors/ │ │ │ │ │ │ ├── root.js │ │ │ │ │ │ └── script.js │ │ │ │ │ ├── core/ │ │ │ │ │ │ └── promise.js │ │ │ │ │ ├── main.js │ │ │ │ │ └── transport.js │ │ │ │ ├── jsb.js │ │ │ │ ├── jsb_chipmunk.js │ │ │ │ ├── jsb_chipmunk_constants.js │ │ │ │ ├── jsb_cocos2d.js │ │ │ │ ├── jsb_cocos2d_constants.js │ │ │ │ ├── jsb_cocos2d_extension.js │ │ │ │ ├── jsb_cocos2d_gui.js │ │ │ │ ├── jsb_cocos2d_studio.js │ │ │ │ ├── jsb_cocosbuilder.js │ │ │ │ ├── jsb_debugger.js │ │ │ │ ├── jsb_deprecated.js │ │ │ │ ├── jsb_opengl.js │ │ │ │ ├── jsb_opengl_constants.js │ │ │ │ └── jsb_sys.js │ │ │ └── lua/ │ │ │ ├── bindings/ │ │ │ │ ├── .cproject │ │ │ │ ├── .project │ │ │ │ ├── Android.mk │ │ │ │ ├── CCBProxy.cpp │ │ │ │ ├── CCBProxy.h │ │ │ │ ├── CCLuaBridge.cpp │ │ │ │ ├── CCLuaBridge.h │ │ │ │ ├── CCLuaEngine.cpp │ │ │ │ ├── CCLuaEngine.h │ │ │ │ ├── CCLuaStack.cpp │ │ │ │ ├── CCLuaStack.h │ │ │ │ ├── CCLuaValue.cpp │ │ │ │ ├── CCLuaValue.h │ │ │ │ ├── Cocos2dxLuaLoader.cpp │ │ │ │ ├── Cocos2dxLuaLoader.h │ │ │ │ ├── LuaBasicConversions.cpp │ │ │ │ ├── LuaBasicConversions.h │ │ │ │ ├── LuaOpengl.cpp │ │ │ │ ├── LuaOpengl.h │ │ │ │ ├── LuaScriptHandlerMgr.cpp │ │ │ │ ├── LuaScriptHandlerMgr.h │ │ │ │ ├── LuaSkeletonAnimation.cpp │ │ │ │ ├── LuaSkeletonAnimation.h │ │ │ │ ├── Lua_web_socket.cpp │ │ │ │ ├── Lua_web_socket.h │ │ │ │ ├── liblua.vcxproj │ │ │ │ ├── liblua.vcxproj.filters │ │ │ │ ├── lua_cocos2dx_coco_studio_manual.cpp │ │ │ │ ├── lua_cocos2dx_coco_studio_manual.hpp │ │ │ │ ├── lua_cocos2dx_deprecated.cpp │ │ │ │ ├── lua_cocos2dx_deprecated.h │ │ │ │ ├── lua_cocos2dx_extension_manual.cpp │ │ │ │ ├── lua_cocos2dx_extension_manual.h │ │ │ │ ├── lua_cocos2dx_gui_manual.cpp │ │ │ │ ├── lua_cocos2dx_gui_manual.hpp │ │ │ │ ├── lua_cocos2dx_manual.cpp │ │ │ │ ├── lua_cocos2dx_manual.hpp │ │ │ │ ├── lua_cocos2dx_physics_manual.cpp │ │ │ │ ├── lua_cocos2dx_physics_manual.hpp │ │ │ │ ├── lua_cocos2dx_spine_manual.cpp │ │ │ │ ├── lua_cocos2dx_spine_manual.hpp │ │ │ │ ├── lua_extensions.c │ │ │ │ ├── lua_extensions.h │ │ │ │ ├── lua_xml_http_request.cpp │ │ │ │ ├── lua_xml_http_request.h │ │ │ │ ├── platform/ │ │ │ │ │ ├── android/ │ │ │ │ │ │ ├── CCLuaJavaBridge.cpp │ │ │ │ │ │ ├── CCLuaJavaBridge.h │ │ │ │ │ │ └── jni/ │ │ │ │ │ │ ├── Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge.cpp │ │ │ │ │ │ └── Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge.h │ │ │ │ │ └── ios/ │ │ │ │ │ ├── CCLuaObjcBridge.h │ │ │ │ │ └── CCLuaObjcBridge.mm │ │ │ │ ├── socket/ │ │ │ │ │ ├── auxiliar.c │ │ │ │ │ ├── auxiliar.h │ │ │ │ │ ├── except.c │ │ │ │ │ ├── except.h │ │ │ │ │ ├── inet.c │ │ │ │ │ ├── inet.h │ │ │ │ │ ├── luasocket.c │ │ │ │ │ ├── luasocket.h │ │ │ │ │ ├── luasocket_buffer.c │ │ │ │ │ ├── luasocket_buffer.h │ │ │ │ │ ├── luasocket_io.c │ │ │ │ │ ├── luasocket_io.h │ │ │ │ │ ├── mime.c │ │ │ │ │ ├── mime.h │ │ │ │ │ ├── options.c │ │ │ │ │ ├── options.h │ │ │ │ │ ├── select.c │ │ │ │ │ ├── select.h │ │ │ │ │ ├── serial.c │ │ │ │ │ ├── socket.h │ │ │ │ │ ├── socket_scripts.c │ │ │ │ │ ├── socket_scripts.h │ │ │ │ │ ├── tcp.c │ │ │ │ │ ├── tcp.h │ │ │ │ │ ├── timeout.c │ │ │ │ │ ├── timeout.h │ │ │ │ │ ├── udp.c │ │ │ │ │ ├── udp.h │ │ │ │ │ ├── unix.c │ │ │ │ │ ├── unix.h │ │ │ │ │ ├── usocket.c │ │ │ │ │ ├── usocket.h │ │ │ │ │ ├── wsocket.c │ │ │ │ │ └── wsocket.h │ │ │ │ ├── tolua_fix.c │ │ │ │ └── tolua_fix.h │ │ │ └── script/ │ │ │ ├── AudioEngine.lua │ │ │ ├── CCBReaderLoad.lua │ │ │ ├── CocoStudio.lua │ │ │ ├── Cocos2d.lua │ │ │ ├── Cocos2dConstants.lua │ │ │ ├── Deprecated.lua │ │ │ ├── DeprecatedClass.lua │ │ │ ├── DeprecatedEnum.lua │ │ │ ├── DeprecatedOpenglEnum.lua │ │ │ ├── DrawPrimitives.lua │ │ │ ├── GuiConstants.lua │ │ │ ├── Opengl.lua │ │ │ ├── OpenglConstants.lua │ │ │ ├── StudioConstants.lua │ │ │ ├── extern.lua │ │ │ ├── json.lua │ │ │ ├── luaj.lua │ │ │ └── luaoc.lua │ │ └── storage/ │ │ └── local-storage/ │ │ ├── Android.mk │ │ ├── LocalStorage.cpp │ │ ├── LocalStorage.h │ │ ├── LocalStorageAndroid.cpp │ │ └── proj.win32/ │ │ ├── libLocalStorage.vcxproj │ │ └── libLocalStorage.vcxproj.filters │ ├── docs/ │ │ ├── .gitignore │ │ ├── CODING_STYLE.md │ │ ├── Groups.h │ │ ├── MainPage.h │ │ ├── RELEASE_NOTES.md │ │ └── doxygen.config │ ├── extensions/ │ │ ├── Android.mk │ │ ├── CMakeLists.txt │ │ ├── ExtensionMacros.h │ │ ├── GUI/ │ │ │ ├── CCControlExtension/ │ │ │ │ ├── CCControl.cpp │ │ │ │ ├── CCControl.h │ │ │ │ ├── CCControlButton.cpp │ │ │ │ ├── CCControlButton.h │ │ │ │ ├── CCControlColourPicker.cpp │ │ │ │ ├── CCControlColourPicker.h │ │ │ │ ├── CCControlExtensions.h │ │ │ │ ├── CCControlHuePicker.cpp │ │ │ │ ├── CCControlHuePicker.h │ │ │ │ ├── CCControlPotentiometer.cpp │ │ │ │ ├── CCControlPotentiometer.h │ │ │ │ ├── CCControlSaturationBrightnessPicker.cpp │ │ │ │ ├── CCControlSaturationBrightnessPicker.h │ │ │ │ ├── CCControlSlider.cpp │ │ │ │ ├── CCControlSlider.h │ │ │ │ ├── CCControlStepper.cpp │ │ │ │ ├── CCControlStepper.h │ │ │ │ ├── CCControlSwitch.cpp │ │ │ │ ├── CCControlSwitch.h │ │ │ │ ├── CCControlUtils.cpp │ │ │ │ ├── CCControlUtils.h │ │ │ │ ├── CCInvocation.cpp │ │ │ │ ├── CCInvocation.h │ │ │ │ ├── CCScale9Sprite.cpp │ │ │ │ └── CCScale9Sprite.h │ │ │ ├── CCEditBox/ │ │ │ │ ├── CCEditBox.cpp │ │ │ │ ├── CCEditBox.h │ │ │ │ ├── CCEditBoxImpl.h │ │ │ │ ├── CCEditBoxImplAndroid.cpp │ │ │ │ ├── CCEditBoxImplAndroid.h │ │ │ │ ├── CCEditBoxImplIOS.h │ │ │ │ ├── CCEditBoxImplIOS.mm │ │ │ │ ├── CCEditBoxImplMac.h │ │ │ │ ├── CCEditBoxImplMac.mm │ │ │ │ ├── CCEditBoxImplNone.cpp │ │ │ │ ├── CCEditBoxImplTizen.cpp │ │ │ │ ├── CCEditBoxImplTizen.h │ │ │ │ ├── CCEditBoxImplWin.cpp │ │ │ │ └── CCEditBoxImplWin.h │ │ │ └── CCScrollView/ │ │ │ ├── CCScrollView.cpp │ │ │ ├── CCScrollView.h │ │ │ ├── CCTableView.cpp │ │ │ ├── CCTableView.h │ │ │ ├── CCTableViewCell.cpp │ │ │ └── CCTableViewCell.h │ │ ├── assets-manager/ │ │ │ ├── AssetsManager.cpp │ │ │ └── AssetsManager.h │ │ ├── cocos-ext.h │ │ ├── physics-nodes/ │ │ │ ├── CCPhysicsDebugNode.cpp │ │ │ ├── CCPhysicsDebugNode.h │ │ │ ├── CCPhysicsSprite.cpp │ │ │ └── CCPhysicsSprite.h │ │ └── proj.win32/ │ │ ├── Win32InputBox.cpp │ │ ├── Win32InputBox.h │ │ ├── libExtensions.vcxproj │ │ └── libExtensions.vcxproj.filters │ ├── external/ │ │ ├── Box2D/ │ │ │ ├── Android.mk │ │ │ ├── Box2D.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Collision/ │ │ │ │ ├── Shapes/ │ │ │ │ │ ├── b2ChainShape.cpp │ │ │ │ │ ├── b2ChainShape.h │ │ │ │ │ ├── b2CircleShape.cpp │ │ │ │ │ ├── b2CircleShape.h │ │ │ │ │ ├── b2EdgeShape.cpp │ │ │ │ │ ├── b2EdgeShape.h │ │ │ │ │ ├── b2PolygonShape.cpp │ │ │ │ │ ├── b2PolygonShape.h │ │ │ │ │ └── b2Shape.h │ │ │ │ ├── b2BroadPhase.cpp │ │ │ │ ├── b2BroadPhase.h │ │ │ │ ├── b2CollideCircle.cpp │ │ │ │ ├── b2CollideEdge.cpp │ │ │ │ ├── b2CollidePolygon.cpp │ │ │ │ ├── b2Collision.cpp │ │ │ │ ├── b2Collision.h │ │ │ │ ├── b2Distance.cpp │ │ │ │ ├── b2Distance.h │ │ │ │ ├── b2DynamicTree.cpp │ │ │ │ ├── b2DynamicTree.h │ │ │ │ ├── b2TimeOfImpact.cpp │ │ │ │ └── b2TimeOfImpact.h │ │ │ ├── Common/ │ │ │ │ ├── b2BlockAllocator.cpp │ │ │ │ ├── b2BlockAllocator.h │ │ │ │ ├── b2Draw.cpp │ │ │ │ ├── b2Draw.h │ │ │ │ ├── b2GrowableStack.h │ │ │ │ ├── b2Math.cpp │ │ │ │ ├── b2Math.h │ │ │ │ ├── b2Settings.cpp │ │ │ │ ├── b2Settings.h │ │ │ │ ├── b2StackAllocator.cpp │ │ │ │ ├── b2StackAllocator.h │ │ │ │ ├── b2Timer.cpp │ │ │ │ └── b2Timer.h │ │ │ ├── Dynamics/ │ │ │ │ ├── Contacts/ │ │ │ │ │ ├── b2ChainAndCircleContact.cpp │ │ │ │ │ ├── b2ChainAndCircleContact.h │ │ │ │ │ ├── b2ChainAndPolygonContact.cpp │ │ │ │ │ ├── b2ChainAndPolygonContact.h │ │ │ │ │ ├── b2CircleContact.cpp │ │ │ │ │ ├── b2CircleContact.h │ │ │ │ │ ├── b2Contact.cpp │ │ │ │ │ ├── b2Contact.h │ │ │ │ │ ├── b2ContactSolver.cpp │ │ │ │ │ ├── b2ContactSolver.h │ │ │ │ │ ├── b2EdgeAndCircleContact.cpp │ │ │ │ │ ├── b2EdgeAndCircleContact.h │ │ │ │ │ ├── b2EdgeAndPolygonContact.cpp │ │ │ │ │ ├── b2EdgeAndPolygonContact.h │ │ │ │ │ ├── b2PolygonAndCircleContact.cpp │ │ │ │ │ ├── b2PolygonAndCircleContact.h │ │ │ │ │ ├── b2PolygonContact.cpp │ │ │ │ │ └── b2PolygonContact.h │ │ │ │ ├── Joints/ │ │ │ │ │ ├── b2DistanceJoint.cpp │ │ │ │ │ ├── b2DistanceJoint.h │ │ │ │ │ ├── b2FrictionJoint.cpp │ │ │ │ │ ├── b2FrictionJoint.h │ │ │ │ │ ├── b2GearJoint.cpp │ │ │ │ │ ├── b2GearJoint.h │ │ │ │ │ ├── b2Joint.cpp │ │ │ │ │ ├── b2Joint.h │ │ │ │ │ ├── b2MotorJoint.cpp │ │ │ │ │ ├── b2MotorJoint.h │ │ │ │ │ ├── b2MouseJoint.cpp │ │ │ │ │ ├── b2MouseJoint.h │ │ │ │ │ ├── b2PrismaticJoint.cpp │ │ │ │ │ ├── b2PrismaticJoint.h │ │ │ │ │ ├── b2PulleyJoint.cpp │ │ │ │ │ ├── b2PulleyJoint.h │ │ │ │ │ ├── b2RevoluteJoint.cpp │ │ │ │ │ ├── b2RevoluteJoint.h │ │ │ │ │ ├── b2RopeJoint.cpp │ │ │ │ │ ├── b2RopeJoint.h │ │ │ │ │ ├── b2WeldJoint.cpp │ │ │ │ │ ├── b2WeldJoint.h │ │ │ │ │ ├── b2WheelJoint.cpp │ │ │ │ │ └── b2WheelJoint.h │ │ │ │ ├── b2Body.cpp │ │ │ │ ├── b2Body.h │ │ │ │ ├── b2ContactManager.cpp │ │ │ │ ├── b2ContactManager.h │ │ │ │ ├── b2Fixture.cpp │ │ │ │ ├── b2Fixture.h │ │ │ │ ├── b2Island.cpp │ │ │ │ ├── b2Island.h │ │ │ │ ├── b2TimeStep.h │ │ │ │ ├── b2World.cpp │ │ │ │ ├── b2World.h │ │ │ │ ├── b2WorldCallbacks.cpp │ │ │ │ └── b2WorldCallbacks.h │ │ │ ├── Rope/ │ │ │ │ ├── b2Rope.cpp │ │ │ │ └── b2Rope.h │ │ │ └── proj.win32/ │ │ │ ├── Box2D.vcxproj │ │ │ └── Box2D.vcxproj.filters │ │ ├── chipmunk/ │ │ │ ├── .gitignore │ │ │ ├── Android.mk │ │ │ ├── LICENSE.txt │ │ │ ├── README.txt │ │ │ ├── chipmunk-docs.html │ │ │ ├── include/ │ │ │ │ └── chipmunk/ │ │ │ │ ├── chipmunk.h │ │ │ │ ├── chipmunk_ffi.h │ │ │ │ ├── chipmunk_private.h │ │ │ │ ├── chipmunk_types.h │ │ │ │ ├── chipmunk_unsafe.h │ │ │ │ ├── constraints/ │ │ │ │ │ ├── cpConstraint.h │ │ │ │ │ ├── cpDampedRotarySpring.h │ │ │ │ │ ├── cpDampedSpring.h │ │ │ │ │ ├── cpGearJoint.h │ │ │ │ │ ├── cpGrooveJoint.h │ │ │ │ │ ├── cpPinJoint.h │ │ │ │ │ ├── cpPivotJoint.h │ │ │ │ │ ├── cpRatchetJoint.h │ │ │ │ │ ├── cpRotaryLimitJoint.h │ │ │ │ │ ├── cpSimpleMotor.h │ │ │ │ │ ├── cpSlideJoint.h │ │ │ │ │ └── util.h │ │ │ │ ├── cpArbiter.h │ │ │ │ ├── cpBB.h │ │ │ │ ├── cpBody.h │ │ │ │ ├── cpPolyShape.h │ │ │ │ ├── cpShape.h │ │ │ │ ├── cpSpace.h │ │ │ │ ├── cpSpatialIndex.h │ │ │ │ └── cpVect.h │ │ │ ├── proj.win32/ │ │ │ │ ├── chipmunk.vcxproj │ │ │ │ └── chipmunk.vcxproj.filters │ │ │ └── src/ │ │ │ ├── CMakeLists.txt │ │ │ ├── chipmunk.c │ │ │ ├── constraints/ │ │ │ │ ├── cpConstraint.c │ │ │ │ ├── cpDampedRotarySpring.c │ │ │ │ ├── cpDampedSpring.c │ │ │ │ ├── cpGearJoint.c │ │ │ │ ├── cpGrooveJoint.c │ │ │ │ ├── cpPinJoint.c │ │ │ │ ├── cpPivotJoint.c │ │ │ │ ├── cpRatchetJoint.c │ │ │ │ ├── cpRotaryLimitJoint.c │ │ │ │ ├── cpSimpleMotor.c │ │ │ │ └── cpSlideJoint.c │ │ │ ├── cpArbiter.c │ │ │ ├── cpArray.c │ │ │ ├── cpBB.c │ │ │ ├── cpBBTree.c │ │ │ ├── cpBody.c │ │ │ ├── cpCollision.c │ │ │ ├── cpHashSet.c │ │ │ ├── cpPolyShape.c │ │ │ ├── cpShape.c │ │ │ ├── cpSpace.c │ │ │ ├── cpSpaceComponent.c │ │ │ ├── cpSpaceHash.c │ │ │ ├── cpSpaceQuery.c │ │ │ ├── cpSpaceStep.c │ │ │ ├── cpSpatialIndex.c │ │ │ ├── cpSweep1D.c │ │ │ ├── cpVect.c │ │ │ └── prime.h │ │ ├── curl/ │ │ │ ├── include/ │ │ │ │ ├── android/ │ │ │ │ │ └── curl/ │ │ │ │ │ ├── curl.h │ │ │ │ │ ├── curlbuild.h │ │ │ │ │ ├── curlrules.h │ │ │ │ │ ├── curlver.h │ │ │ │ │ ├── easy.h │ │ │ │ │ ├── mprintf.h │ │ │ │ │ ├── multi.h │ │ │ │ │ ├── stdcheaders.h │ │ │ │ │ ├── typecheck-gcc.h │ │ │ │ │ └── types.h │ │ │ │ ├── ios/ │ │ │ │ │ └── curl/ │ │ │ │ │ ├── curl.h │ │ │ │ │ ├── curlbuild.h │ │ │ │ │ ├── curlrules.h │ │ │ │ │ ├── curlver.h │ │ │ │ │ ├── easy.h │ │ │ │ │ ├── mprintf.h │ │ │ │ │ ├── multi.h │ │ │ │ │ ├── stdcheaders.h │ │ │ │ │ └── typecheck-gcc.h │ │ │ │ └── win32/ │ │ │ │ └── curl/ │ │ │ │ ├── curl.h │ │ │ │ ├── curlbuild.h │ │ │ │ ├── curlrules.h │ │ │ │ ├── curlver.h │ │ │ │ ├── easy.h │ │ │ │ ├── mprintf.h │ │ │ │ ├── multi.h │ │ │ │ ├── stdcheaders.h │ │ │ │ └── typecheck-gcc.h │ │ │ └── prebuilt/ │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── armeabi/ │ │ │ │ │ └── libcurl.a │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ └── libcurl.a │ │ │ │ └── x86/ │ │ │ │ └── libcurl.a │ │ │ ├── ios/ │ │ │ │ └── libcurl.a │ │ │ └── win32/ │ │ │ └── libcurl_imp.lib │ │ ├── edtaa3func/ │ │ │ ├── edtaa3func.cpp │ │ │ └── edtaa3func.h │ │ ├── freetype2/ │ │ │ ├── include/ │ │ │ │ ├── android/ │ │ │ │ │ ├── freetype2/ │ │ │ │ │ │ └── freetype/ │ │ │ │ │ │ ├── config/ │ │ │ │ │ │ │ ├── ftconfig.h │ │ │ │ │ │ │ ├── ftheader.h │ │ │ │ │ │ │ ├── ftmodule.h │ │ │ │ │ │ │ ├── ftoption.h │ │ │ │ │ │ │ └── ftstdlib.h │ │ │ │ │ │ ├── freetype.h │ │ │ │ │ │ ├── ftadvanc.h │ │ │ │ │ │ ├── ftautoh.h │ │ │ │ │ │ ├── ftbbox.h │ │ │ │ │ │ ├── ftbdf.h │ │ │ │ │ │ ├── ftbitmap.h │ │ │ │ │ │ ├── ftbzip2.h │ │ │ │ │ │ ├── ftcache.h │ │ │ │ │ │ ├── ftcffdrv.h │ │ │ │ │ │ ├── ftchapters.h │ │ │ │ │ │ ├── ftcid.h │ │ │ │ │ │ ├── fterrdef.h │ │ │ │ │ │ ├── fterrors.h │ │ │ │ │ │ ├── ftgasp.h │ │ │ │ │ │ ├── ftglyph.h │ │ │ │ │ │ ├── ftgxval.h │ │ │ │ │ │ ├── ftgzip.h │ │ │ │ │ │ ├── ftimage.h │ │ │ │ │ │ ├── ftincrem.h │ │ │ │ │ │ ├── ftlcdfil.h │ │ │ │ │ │ ├── ftlist.h │ │ │ │ │ │ ├── ftlzw.h │ │ │ │ │ │ ├── ftmac.h │ │ │ │ │ │ ├── ftmm.h │ │ │ │ │ │ ├── ftmodapi.h │ │ │ │ │ │ ├── ftmoderr.h │ │ │ │ │ │ ├── ftotval.h │ │ │ │ │ │ ├── ftoutln.h │ │ │ │ │ │ ├── ftpfr.h │ │ │ │ │ │ ├── ftrender.h │ │ │ │ │ │ ├── ftsizes.h │ │ │ │ │ │ ├── ftsnames.h │ │ │ │ │ │ ├── ftstroke.h │ │ │ │ │ │ ├── ftsynth.h │ │ │ │ │ │ ├── ftsystem.h │ │ │ │ │ │ ├── fttrigon.h │ │ │ │ │ │ ├── ftttdrv.h │ │ │ │ │ │ ├── fttypes.h │ │ │ │ │ │ ├── ftwinfnt.h │ │ │ │ │ │ ├── ftxf86.h │ │ │ │ │ │ ├── t1tables.h │ │ │ │ │ │ ├── ttnameid.h │ │ │ │ │ │ ├── tttables.h │ │ │ │ │ │ ├── tttags.h │ │ │ │ │ │ └── ttunpat.h │ │ │ │ │ └── ft2build.h │ │ │ │ ├── ios/ │ │ │ │ │ ├── freetype/ │ │ │ │ │ │ ├── config/ │ │ │ │ │ │ │ ├── ftconfig.h │ │ │ │ │ │ │ ├── ftheader.h │ │ │ │ │ │ │ ├── ftmodule.h │ │ │ │ │ │ │ ├── ftoption.h │ │ │ │ │ │ │ └── ftstdlib.h │ │ │ │ │ │ ├── freetype.h │ │ │ │ │ │ ├── ftadvanc.h │ │ │ │ │ │ ├── ftautoh.h │ │ │ │ │ │ ├── ftbbox.h │ │ │ │ │ │ ├── ftbdf.h │ │ │ │ │ │ ├── ftbitmap.h │ │ │ │ │ │ ├── ftbzip2.h │ │ │ │ │ │ ├── ftcache.h │ │ │ │ │ │ ├── ftcffdrv.h │ │ │ │ │ │ ├── ftchapters.h │ │ │ │ │ │ ├── ftcid.h │ │ │ │ │ │ ├── fterrdef.h │ │ │ │ │ │ ├── fterrors.h │ │ │ │ │ │ ├── ftgasp.h │ │ │ │ │ │ ├── ftglyph.h │ │ │ │ │ │ ├── ftgxval.h │ │ │ │ │ │ ├── ftgzip.h │ │ │ │ │ │ ├── ftimage.h │ │ │ │ │ │ ├── ftincrem.h │ │ │ │ │ │ ├── ftlcdfil.h │ │ │ │ │ │ ├── ftlist.h │ │ │ │ │ │ ├── ftlzw.h │ │ │ │ │ │ ├── ftmac.h │ │ │ │ │ │ ├── ftmm.h │ │ │ │ │ │ ├── ftmodapi.h │ │ │ │ │ │ ├── ftmoderr.h │ │ │ │ │ │ ├── ftotval.h │ │ │ │ │ │ ├── ftoutln.h │ │ │ │ │ │ ├── ftpfr.h │ │ │ │ │ │ ├── ftrender.h │ │ │ │ │ │ ├── ftsizes.h │ │ │ │ │ │ ├── ftsnames.h │ │ │ │ │ │ ├── ftstroke.h │ │ │ │ │ │ ├── ftsynth.h │ │ │ │ │ │ ├── ftsystem.h │ │ │ │ │ │ ├── fttrigon.h │ │ │ │ │ │ ├── ftttdrv.h │ │ │ │ │ │ ├── fttypes.h │ │ │ │ │ │ ├── ftwinfnt.h │ │ │ │ │ │ ├── ftxf86.h │ │ │ │ │ │ ├── internal/ │ │ │ │ │ │ │ ├── autohint.h │ │ │ │ │ │ │ ├── ftcalc.h │ │ │ │ │ │ │ ├── ftdebug.h │ │ │ │ │ │ │ ├── ftdriver.h │ │ │ │ │ │ │ ├── ftgloadr.h │ │ │ │ │ │ │ ├── ftmemory.h │ │ │ │ │ │ │ ├── ftobjs.h │ │ │ │ │ │ │ ├── ftpic.h │ │ │ │ │ │ │ ├── ftrfork.h │ │ │ │ │ │ │ ├── ftserv.h │ │ │ │ │ │ │ ├── ftstream.h │ │ │ │ │ │ │ ├── fttrace.h │ │ │ │ │ │ │ ├── ftvalid.h │ │ │ │ │ │ │ ├── internal.h │ │ │ │ │ │ │ ├── psaux.h │ │ │ │ │ │ │ ├── pshints.h │ │ │ │ │ │ │ ├── services/ │ │ │ │ │ │ │ │ ├── svbdf.h │ │ │ │ │ │ │ │ ├── svcid.h │ │ │ │ │ │ │ │ ├── svgldict.h │ │ │ │ │ │ │ │ ├── svgxval.h │ │ │ │ │ │ │ │ ├── svkern.h │ │ │ │ │ │ │ │ ├── svmm.h │ │ │ │ │ │ │ │ ├── svotval.h │ │ │ │ │ │ │ │ ├── svpfr.h │ │ │ │ │ │ │ │ ├── svpostnm.h │ │ │ │ │ │ │ │ ├── svprop.h │ │ │ │ │ │ │ │ ├── svpscmap.h │ │ │ │ │ │ │ │ ├── svpsinfo.h │ │ │ │ │ │ │ │ ├── svsfnt.h │ │ │ │ │ │ │ │ ├── svttcmap.h │ │ │ │ │ │ │ │ ├── svtteng.h │ │ │ │ │ │ │ │ ├── svttglyf.h │ │ │ │ │ │ │ │ ├── svwinfnt.h │ │ │ │ │ │ │ │ └── svxf86nm.h │ │ │ │ │ │ │ ├── sfnt.h │ │ │ │ │ │ │ ├── t1types.h │ │ │ │ │ │ │ └── tttypes.h │ │ │ │ │ │ ├── t1tables.h │ │ │ │ │ │ ├── ttnameid.h │ │ │ │ │ │ ├── tttables.h │ │ │ │ │ │ ├── tttags.h │ │ │ │ │ │ └── ttunpat.h │ │ │ │ │ └── ft2build.h │ │ │ │ ├── linux/ │ │ │ │ │ ├── freetype/ │ │ │ │ │ │ ├── config/ │ │ │ │ │ │ │ ├── ftconfig.h │ │ │ │ │ │ │ ├── ftheader.h │ │ │ │ │ │ │ ├── ftmodule.h │ │ │ │ │ │ │ ├── ftoption.h │ │ │ │ │ │ │ └── ftstdlib.h │ │ │ │ │ │ ├── freetype.h │ │ │ │ │ │ ├── ftadvanc.h │ │ │ │ │ │ ├── ftbbox.h │ │ │ │ │ │ ├── ftbdf.h │ │ │ │ │ │ ├── ftbitmap.h │ │ │ │ │ │ ├── ftbzip2.h │ │ │ │ │ │ ├── ftcache.h │ │ │ │ │ │ ├── ftchapters.h │ │ │ │ │ │ ├── ftcid.h │ │ │ │ │ │ ├── fterrdef.h │ │ │ │ │ │ ├── fterrors.h │ │ │ │ │ │ ├── ftgasp.h │ │ │ │ │ │ ├── ftglyph.h │ │ │ │ │ │ ├── ftgxval.h │ │ │ │ │ │ ├── ftgzip.h │ │ │ │ │ │ ├── ftimage.h │ │ │ │ │ │ ├── ftincrem.h │ │ │ │ │ │ ├── ftlcdfil.h │ │ │ │ │ │ ├── ftlist.h │ │ │ │ │ │ ├── ftlzw.h │ │ │ │ │ │ ├── ftmac.h │ │ │ │ │ │ ├── ftmm.h │ │ │ │ │ │ ├── ftmodapi.h │ │ │ │ │ │ ├── ftmoderr.h │ │ │ │ │ │ ├── ftotval.h │ │ │ │ │ │ ├── ftoutln.h │ │ │ │ │ │ ├── ftpfr.h │ │ │ │ │ │ ├── ftrender.h │ │ │ │ │ │ ├── ftsizes.h │ │ │ │ │ │ ├── ftsnames.h │ │ │ │ │ │ ├── ftstroke.h │ │ │ │ │ │ ├── ftsynth.h │ │ │ │ │ │ ├── ftsystem.h │ │ │ │ │ │ ├── fttrigon.h │ │ │ │ │ │ ├── fttypes.h │ │ │ │ │ │ ├── ftwinfnt.h │ │ │ │ │ │ ├── ftxf86.h │ │ │ │ │ │ ├── internal/ │ │ │ │ │ │ │ ├── autohint.h │ │ │ │ │ │ │ ├── ftcalc.h │ │ │ │ │ │ │ ├── ftdebug.h │ │ │ │ │ │ │ ├── ftdriver.h │ │ │ │ │ │ │ ├── ftgloadr.h │ │ │ │ │ │ │ ├── ftmemory.h │ │ │ │ │ │ │ ├── ftobjs.h │ │ │ │ │ │ │ ├── ftpic.h │ │ │ │ │ │ │ ├── ftrfork.h │ │ │ │ │ │ │ ├── ftserv.h │ │ │ │ │ │ │ ├── ftstream.h │ │ │ │ │ │ │ ├── fttrace.h │ │ │ │ │ │ │ ├── ftvalid.h │ │ │ │ │ │ │ ├── internal.h │ │ │ │ │ │ │ ├── psaux.h │ │ │ │ │ │ │ ├── pshints.h │ │ │ │ │ │ │ ├── services/ │ │ │ │ │ │ │ │ ├── svbdf.h │ │ │ │ │ │ │ │ ├── svcid.h │ │ │ │ │ │ │ │ ├── svgldict.h │ │ │ │ │ │ │ │ ├── svgxval.h │ │ │ │ │ │ │ │ ├── svkern.h │ │ │ │ │ │ │ │ ├── svmm.h │ │ │ │ │ │ │ │ ├── svotval.h │ │ │ │ │ │ │ │ ├── svpfr.h │ │ │ │ │ │ │ │ ├── svpostnm.h │ │ │ │ │ │ │ │ ├── svpscmap.h │ │ │ │ │ │ │ │ ├── svpsinfo.h │ │ │ │ │ │ │ │ ├── svsfnt.h │ │ │ │ │ │ │ │ ├── svttcmap.h │ │ │ │ │ │ │ │ ├── svtteng.h │ │ │ │ │ │ │ │ ├── svttglyf.h │ │ │ │ │ │ │ │ ├── svwinfnt.h │ │ │ │ │ │ │ │ └── svxf86nm.h │ │ │ │ │ │ │ ├── sfnt.h │ │ │ │ │ │ │ ├── t1types.h │ │ │ │ │ │ │ └── tttypes.h │ │ │ │ │ │ ├── t1tables.h │ │ │ │ │ │ ├── ttnameid.h │ │ │ │ │ │ ├── tttables.h │ │ │ │ │ │ ├── tttags.h │ │ │ │ │ │ └── ttunpat.h │ │ │ │ │ └── ft2build.h │ │ │ │ ├── mac/ │ │ │ │ │ ├── freetype/ │ │ │ │ │ │ ├── config/ │ │ │ │ │ │ │ ├── ftconfig.h │ │ │ │ │ │ │ ├── ftheader.h │ │ │ │ │ │ │ ├── ftmodule.h │ │ │ │ │ │ │ ├── ftoption.h │ │ │ │ │ │ │ └── ftstdlib.h │ │ │ │ │ │ ├── freetype.h │ │ │ │ │ │ ├── ftadvanc.h │ │ │ │ │ │ ├── ftautoh.h │ │ │ │ │ │ ├── ftbbox.h │ │ │ │ │ │ ├── ftbdf.h │ │ │ │ │ │ ├── ftbitmap.h │ │ │ │ │ │ ├── ftbzip2.h │ │ │ │ │ │ ├── ftcache.h │ │ │ │ │ │ ├── ftcffdrv.h │ │ │ │ │ │ ├── ftchapters.h │ │ │ │ │ │ ├── ftcid.h │ │ │ │ │ │ ├── fterrdef.h │ │ │ │ │ │ ├── fterrors.h │ │ │ │ │ │ ├── ftgasp.h │ │ │ │ │ │ ├── ftglyph.h │ │ │ │ │ │ ├── ftgxval.h │ │ │ │ │ │ ├── ftgzip.h │ │ │ │ │ │ ├── ftimage.h │ │ │ │ │ │ ├── ftincrem.h │ │ │ │ │ │ ├── ftlcdfil.h │ │ │ │ │ │ ├── ftlist.h │ │ │ │ │ │ ├── ftlzw.h │ │ │ │ │ │ ├── ftmac.h │ │ │ │ │ │ ├── ftmm.h │ │ │ │ │ │ ├── ftmodapi.h │ │ │ │ │ │ ├── ftmoderr.h │ │ │ │ │ │ ├── ftotval.h │ │ │ │ │ │ ├── ftoutln.h │ │ │ │ │ │ ├── ftpfr.h │ │ │ │ │ │ ├── ftrender.h │ │ │ │ │ │ ├── ftsizes.h │ │ │ │ │ │ ├── ftsnames.h │ │ │ │ │ │ ├── ftstroke.h │ │ │ │ │ │ ├── ftsynth.h │ │ │ │ │ │ ├── ftsystem.h │ │ │ │ │ │ ├── fttrigon.h │ │ │ │ │ │ ├── ftttdrv.h │ │ │ │ │ │ ├── fttypes.h │ │ │ │ │ │ ├── ftwinfnt.h │ │ │ │ │ │ ├── ftxf86.h │ │ │ │ │ │ ├── internal/ │ │ │ │ │ │ │ ├── autohint.h │ │ │ │ │ │ │ ├── ftcalc.h │ │ │ │ │ │ │ ├── ftdebug.h │ │ │ │ │ │ │ ├── ftdriver.h │ │ │ │ │ │ │ ├── ftgloadr.h │ │ │ │ │ │ │ ├── ftmemory.h │ │ │ │ │ │ │ ├── ftobjs.h │ │ │ │ │ │ │ ├── ftpic.h │ │ │ │ │ │ │ ├── ftrfork.h │ │ │ │ │ │ │ ├── ftserv.h │ │ │ │ │ │ │ ├── ftstream.h │ │ │ │ │ │ │ ├── fttrace.h │ │ │ │ │ │ │ ├── ftvalid.h │ │ │ │ │ │ │ ├── internal.h │ │ │ │ │ │ │ ├── psaux.h │ │ │ │ │ │ │ ├── pshints.h │ │ │ │ │ │ │ ├── services/ │ │ │ │ │ │ │ │ ├── svbdf.h │ │ │ │ │ │ │ │ ├── svcid.h │ │ │ │ │ │ │ │ ├── svgldict.h │ │ │ │ │ │ │ │ ├── svgxval.h │ │ │ │ │ │ │ │ ├── svkern.h │ │ │ │ │ │ │ │ ├── svmm.h │ │ │ │ │ │ │ │ ├── svotval.h │ │ │ │ │ │ │ │ ├── svpfr.h │ │ │ │ │ │ │ │ ├── svpostnm.h │ │ │ │ │ │ │ │ ├── svprop.h │ │ │ │ │ │ │ │ ├── svpscmap.h │ │ │ │ │ │ │ │ ├── svpsinfo.h │ │ │ │ │ │ │ │ ├── svsfnt.h │ │ │ │ │ │ │ │ ├── svttcmap.h │ │ │ │ │ │ │ │ ├── svtteng.h │ │ │ │ │ │ │ │ ├── svttglyf.h │ │ │ │ │ │ │ │ ├── svwinfnt.h │ │ │ │ │ │ │ │ └── svxf86nm.h │ │ │ │ │ │ │ ├── sfnt.h │ │ │ │ │ │ │ ├── t1types.h │ │ │ │ │ │ │ └── tttypes.h │ │ │ │ │ │ ├── t1tables.h │ │ │ │ │ │ ├── ttnameid.h │ │ │ │ │ │ ├── tttables.h │ │ │ │ │ │ ├── tttags.h │ │ │ │ │ │ └── ttunpat.h │ │ │ │ │ └── ft2build.h │ │ │ │ └── win32/ │ │ │ │ ├── freetype/ │ │ │ │ │ ├── config/ │ │ │ │ │ │ ├── ftconfig.h │ │ │ │ │ │ ├── ftheader.h │ │ │ │ │ │ ├── ftmodule.h │ │ │ │ │ │ ├── ftoption.h │ │ │ │ │ │ └── ftstdlib.h │ │ │ │ │ ├── freetype.h │ │ │ │ │ ├── ftadvanc.h │ │ │ │ │ ├── ftautoh.h │ │ │ │ │ ├── ftbbox.h │ │ │ │ │ ├── ftbdf.h │ │ │ │ │ ├── ftbitmap.h │ │ │ │ │ ├── ftbzip2.h │ │ │ │ │ ├── ftcache.h │ │ │ │ │ ├── ftcffdrv.h │ │ │ │ │ ├── ftchapters.h │ │ │ │ │ ├── ftcid.h │ │ │ │ │ ├── fterrdef.h │ │ │ │ │ ├── fterrors.h │ │ │ │ │ ├── ftgasp.h │ │ │ │ │ ├── ftglyph.h │ │ │ │ │ ├── ftgxval.h │ │ │ │ │ ├── ftgzip.h │ │ │ │ │ ├── ftimage.h │ │ │ │ │ ├── ftincrem.h │ │ │ │ │ ├── ftlcdfil.h │ │ │ │ │ ├── ftlist.h │ │ │ │ │ ├── ftlzw.h │ │ │ │ │ ├── ftmac.h │ │ │ │ │ ├── ftmm.h │ │ │ │ │ ├── ftmodapi.h │ │ │ │ │ ├── ftmoderr.h │ │ │ │ │ ├── ftotval.h │ │ │ │ │ ├── ftoutln.h │ │ │ │ │ ├── ftpfr.h │ │ │ │ │ ├── ftrender.h │ │ │ │ │ ├── ftsizes.h │ │ │ │ │ ├── ftsnames.h │ │ │ │ │ ├── ftstroke.h │ │ │ │ │ ├── ftsynth.h │ │ │ │ │ ├── ftsystem.h │ │ │ │ │ ├── fttrigon.h │ │ │ │ │ ├── ftttdrv.h │ │ │ │ │ ├── fttypes.h │ │ │ │ │ ├── ftwinfnt.h │ │ │ │ │ ├── ftxf86.h │ │ │ │ │ ├── internal/ │ │ │ │ │ │ ├── autohint.h │ │ │ │ │ │ ├── ftcalc.h │ │ │ │ │ │ ├── ftdebug.h │ │ │ │ │ │ ├── ftdriver.h │ │ │ │ │ │ ├── ftgloadr.h │ │ │ │ │ │ ├── ftmemory.h │ │ │ │ │ │ ├── ftobjs.h │ │ │ │ │ │ ├── ftpic.h │ │ │ │ │ │ ├── ftrfork.h │ │ │ │ │ │ ├── ftserv.h │ │ │ │ │ │ ├── ftstream.h │ │ │ │ │ │ ├── fttrace.h │ │ │ │ │ │ ├── ftvalid.h │ │ │ │ │ │ ├── internal.h │ │ │ │ │ │ ├── psaux.h │ │ │ │ │ │ ├── pshints.h │ │ │ │ │ │ ├── services/ │ │ │ │ │ │ │ ├── svbdf.h │ │ │ │ │ │ │ ├── svcid.h │ │ │ │ │ │ │ ├── svgldict.h │ │ │ │ │ │ │ ├── svgxval.h │ │ │ │ │ │ │ ├── svkern.h │ │ │ │ │ │ │ ├── svmm.h │ │ │ │ │ │ │ ├── svotval.h │ │ │ │ │ │ │ ├── svpfr.h │ │ │ │ │ │ │ ├── svpostnm.h │ │ │ │ │ │ │ ├── svprop.h │ │ │ │ │ │ │ ├── svpscmap.h │ │ │ │ │ │ │ ├── svpsinfo.h │ │ │ │ │ │ │ ├── svsfnt.h │ │ │ │ │ │ │ ├── svttcmap.h │ │ │ │ │ │ │ ├── svtteng.h │ │ │ │ │ │ │ ├── svttglyf.h │ │ │ │ │ │ │ ├── svwinfnt.h │ │ │ │ │ │ │ └── svxf86nm.h │ │ │ │ │ │ ├── sfnt.h │ │ │ │ │ │ ├── t1types.h │ │ │ │ │ │ └── tttypes.h │ │ │ │ │ ├── t1tables.h │ │ │ │ │ ├── ttnameid.h │ │ │ │ │ ├── tttables.h │ │ │ │ │ ├── tttags.h │ │ │ │ │ └── ttunpat.h │ │ │ │ └── ft2build.h │ │ │ └── prebuilt/ │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── armeabi/ │ │ │ │ │ └── libfreetype.a │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ └── libfreetype.a │ │ │ │ └── x86/ │ │ │ │ └── libfreetype.a │ │ │ ├── ios/ │ │ │ │ └── libfreetype.a │ │ │ ├── linux/ │ │ │ │ ├── 32-bit/ │ │ │ │ │ └── libfreetype.a │ │ │ │ └── 64-bit/ │ │ │ │ └── libfreetype.a │ │ │ ├── mac/ │ │ │ │ └── libfreetype.a │ │ │ └── win32/ │ │ │ └── freetype250.lib │ │ ├── glfw3/ │ │ │ ├── include/ │ │ │ │ ├── mac/ │ │ │ │ │ ├── glfw3.h │ │ │ │ │ └── glfw3native.h │ │ │ │ └── win32/ │ │ │ │ ├── glfw3.h │ │ │ │ └── glfw3native.h │ │ │ └── prebuilt/ │ │ │ ├── mac/ │ │ │ │ └── libglfw3.a │ │ │ └── win32/ │ │ │ └── glfw3.lib │ │ ├── jpeg/ │ │ │ ├── include/ │ │ │ │ ├── android/ │ │ │ │ │ ├── jconfig.h │ │ │ │ │ ├── jerror.h │ │ │ │ │ ├── jmorecfg.h │ │ │ │ │ └── jpeglib.h │ │ │ │ ├── ios/ │ │ │ │ │ ├── jconfig.h │ │ │ │ │ ├── jmorecfg.h │ │ │ │ │ └── jpeglib.h │ │ │ │ ├── linux/ │ │ │ │ │ ├── jconfig.h │ │ │ │ │ ├── jmorecfg.h │ │ │ │ │ └── jpeglib.h │ │ │ │ ├── mac/ │ │ │ │ │ ├── jconfig.h │ │ │ │ │ ├── jmorecfg.h │ │ │ │ │ └── jpeglib.h │ │ │ │ └── win32/ │ │ │ │ ├── jconfig.h │ │ │ │ ├── jmorecfg.h │ │ │ │ └── jpeglib.h │ │ │ └── prebuilt/ │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── armeabi/ │ │ │ │ │ └── libjpeg.a │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ └── libjpeg.a │ │ │ │ └── x86/ │ │ │ │ └── libjpeg.a │ │ │ ├── ios/ │ │ │ │ └── libjpeg.a │ │ │ ├── linux/ │ │ │ │ ├── 32-bit/ │ │ │ │ │ └── libjpeg.a │ │ │ │ └── 64-bit/ │ │ │ │ └── libjpeg.a │ │ │ ├── mac/ │ │ │ │ └── libjpeg.a │ │ │ └── win32/ │ │ │ └── libjpeg.lib │ │ ├── json/ │ │ │ ├── document.h │ │ │ ├── filestream.h │ │ │ ├── internal/ │ │ │ │ ├── pow10.h │ │ │ │ ├── stack.h │ │ │ │ └── strfunc.h │ │ │ ├── prettywriter.h │ │ │ ├── rapidjson.h │ │ │ ├── reader.h │ │ │ ├── stringbuffer.h │ │ │ └── writer.h │ │ ├── linux-specific/ │ │ │ └── fmod/ │ │ │ └── include/ │ │ │ ├── 32-bit/ │ │ │ │ ├── fmod.h │ │ │ │ ├── fmod.hpp │ │ │ │ ├── fmod_codec.h │ │ │ │ ├── fmod_dsp.h │ │ │ │ ├── fmod_errors.h │ │ │ │ ├── fmod_memoryinfo.h │ │ │ │ ├── fmod_output.h │ │ │ │ └── fmodlinux.h │ │ │ └── 64-bit/ │ │ │ ├── fmod.h │ │ │ ├── fmod.hpp │ │ │ ├── fmod_codec.h │ │ │ ├── fmod_dsp.h │ │ │ ├── fmod_errors.h │ │ │ ├── fmod_memoryinfo.h │ │ │ ├── fmod_output.h │ │ │ └── fmodlinux.h │ │ ├── lua/ │ │ │ ├── lua/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── lapi.c │ │ │ │ ├── lapi.h │ │ │ │ ├── lauxlib.c │ │ │ │ ├── lauxlib.h │ │ │ │ ├── lbaselib.c │ │ │ │ ├── lcode.c │ │ │ │ ├── lcode.h │ │ │ │ ├── ldblib.c │ │ │ │ ├── ldebug.c │ │ │ │ ├── ldebug.h │ │ │ │ ├── ldo.c │ │ │ │ ├── ldo.h │ │ │ │ ├── ldump.c │ │ │ │ ├── lfunc.c │ │ │ │ ├── lfunc.h │ │ │ │ ├── lgc.c │ │ │ │ ├── lgc.h │ │ │ │ ├── linit.c │ │ │ │ ├── liolib.c │ │ │ │ ├── llex.c │ │ │ │ ├── llex.h │ │ │ │ ├── llimits.h │ │ │ │ ├── lmathlib.c │ │ │ │ ├── lmem.c │ │ │ │ ├── lmem.h │ │ │ │ ├── loadlib.c │ │ │ │ ├── lobject.c │ │ │ │ ├── lobject.h │ │ │ │ ├── lopcodes.c │ │ │ │ ├── lopcodes.h │ │ │ │ ├── loslib.c │ │ │ │ ├── lparser.c │ │ │ │ ├── lparser.h │ │ │ │ ├── lstate.c │ │ │ │ ├── lstate.h │ │ │ │ ├── lstring.c │ │ │ │ ├── lstring.h │ │ │ │ ├── lstrlib.c │ │ │ │ ├── ltable.c │ │ │ │ ├── ltable.h │ │ │ │ ├── ltablib.c │ │ │ │ ├── ltm.c │ │ │ │ ├── ltm.h │ │ │ │ ├── lua.c │ │ │ │ ├── lua.h │ │ │ │ ├── luaconf.h │ │ │ │ ├── lualib.h │ │ │ │ ├── lundump.c │ │ │ │ ├── lundump.h │ │ │ │ ├── lvm.c │ │ │ │ ├── lvm.h │ │ │ │ ├── lzio.c │ │ │ │ ├── lzio.h │ │ │ │ └── print.c │ │ │ ├── luajit/ │ │ │ │ ├── build_android.sh │ │ │ │ ├── build_ios.sh │ │ │ │ ├── build_mac.sh │ │ │ │ ├── include/ │ │ │ │ │ ├── lauxlib.h │ │ │ │ │ ├── lua.h │ │ │ │ │ ├── luaconf.h │ │ │ │ │ └── lualib.h │ │ │ │ ├── prebuilt/ │ │ │ │ │ ├── android/ │ │ │ │ │ │ ├── Android.mk │ │ │ │ │ │ ├── armeabi/ │ │ │ │ │ │ │ └── libluajit.a │ │ │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ │ │ └── libluajit.a │ │ │ │ │ │ └── x86/ │ │ │ │ │ │ └── libluajit.a │ │ │ │ │ ├── ios/ │ │ │ │ │ │ └── libluajit.a │ │ │ │ │ ├── mac/ │ │ │ │ │ │ └── libluajit.a │ │ │ │ │ └── win32/ │ │ │ │ │ └── lua51.lib │ │ │ │ └── src/ │ │ │ │ ├── COPYRIGHT │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ ├── doc/ │ │ │ │ │ ├── bluequad-print.css │ │ │ │ │ ├── bluequad.css │ │ │ │ │ ├── changes.html │ │ │ │ │ ├── contact.html │ │ │ │ │ ├── ext_c_api.html │ │ │ │ │ ├── ext_ffi.html │ │ │ │ │ ├── ext_ffi_api.html │ │ │ │ │ ├── ext_ffi_semantics.html │ │ │ │ │ ├── ext_ffi_tutorial.html │ │ │ │ │ ├── ext_jit.html │ │ │ │ │ ├── extensions.html │ │ │ │ │ ├── faq.html │ │ │ │ │ ├── install.html │ │ │ │ │ ├── luajit.html │ │ │ │ │ ├── running.html │ │ │ │ │ └── status.html │ │ │ │ ├── dynasm/ │ │ │ │ │ ├── dasm_arm.h │ │ │ │ │ ├── dasm_arm.lua │ │ │ │ │ ├── dasm_mips.h │ │ │ │ │ ├── dasm_mips.lua │ │ │ │ │ ├── dasm_ppc.h │ │ │ │ │ ├── dasm_ppc.lua │ │ │ │ │ ├── dasm_proto.h │ │ │ │ │ ├── dasm_x64.lua │ │ │ │ │ ├── dasm_x86.h │ │ │ │ │ ├── dasm_x86.lua │ │ │ │ │ └── dynasm.lua │ │ │ │ ├── etc/ │ │ │ │ │ ├── luajit.1 │ │ │ │ │ └── luajit.pc │ │ │ │ ├── src/ │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── Makefile.dep │ │ │ │ │ ├── host/ │ │ │ │ │ │ ├── README │ │ │ │ │ │ ├── buildvm.c │ │ │ │ │ │ ├── buildvm.h │ │ │ │ │ │ ├── buildvm_asm.c │ │ │ │ │ │ ├── buildvm_fold.c │ │ │ │ │ │ ├── buildvm_lib.c │ │ │ │ │ │ ├── buildvm_peobj.c │ │ │ │ │ │ ├── genminilua.lua │ │ │ │ │ │ └── minilua.c │ │ │ │ │ ├── jit/ │ │ │ │ │ │ ├── bc.lua │ │ │ │ │ │ ├── bcsave.lua │ │ │ │ │ │ ├── dis_arm.lua │ │ │ │ │ │ ├── dis_mips.lua │ │ │ │ │ │ ├── dis_mipsel.lua │ │ │ │ │ │ ├── dis_ppc.lua │ │ │ │ │ │ ├── dis_x64.lua │ │ │ │ │ │ ├── dis_x86.lua │ │ │ │ │ │ ├── dump.lua │ │ │ │ │ │ └── v.lua │ │ │ │ │ ├── lauxlib.h │ │ │ │ │ ├── lib_aux.c │ │ │ │ │ ├── lib_base.c │ │ │ │ │ ├── lib_bit.c │ │ │ │ │ ├── lib_debug.c │ │ │ │ │ ├── lib_ffi.c │ │ │ │ │ ├── lib_init.c │ │ │ │ │ ├── lib_io.c │ │ │ │ │ ├── lib_jit.c │ │ │ │ │ ├── lib_math.c │ │ │ │ │ ├── lib_os.c │ │ │ │ │ ├── lib_package.c │ │ │ │ │ ├── lib_string.c │ │ │ │ │ ├── lib_table.c │ │ │ │ │ ├── lj.supp │ │ │ │ │ ├── lj_alloc.c │ │ │ │ │ ├── lj_alloc.h │ │ │ │ │ ├── lj_api.c │ │ │ │ │ ├── lj_arch.h │ │ │ │ │ ├── lj_asm.c │ │ │ │ │ ├── lj_asm.h │ │ │ │ │ ├── lj_asm_arm.h │ │ │ │ │ ├── lj_asm_mips.h │ │ │ │ │ ├── lj_asm_ppc.h │ │ │ │ │ ├── lj_asm_x86.h │ │ │ │ │ ├── lj_bc.c │ │ │ │ │ ├── lj_bc.h │ │ │ │ │ ├── lj_bcdump.h │ │ │ │ │ ├── lj_bcread.c │ │ │ │ │ ├── lj_bcwrite.c │ │ │ │ │ ├── lj_carith.c │ │ │ │ │ ├── lj_carith.h │ │ │ │ │ ├── lj_ccall.c │ │ │ │ │ ├── lj_ccall.h │ │ │ │ │ ├── lj_ccallback.c │ │ │ │ │ ├── lj_ccallback.h │ │ │ │ │ ├── lj_cconv.c │ │ │ │ │ ├── lj_cconv.h │ │ │ │ │ ├── lj_cdata.c │ │ │ │ │ ├── lj_cdata.h │ │ │ │ │ ├── lj_char.c │ │ │ │ │ ├── lj_char.h │ │ │ │ │ ├── lj_clib.c │ │ │ │ │ ├── lj_clib.h │ │ │ │ │ ├── lj_cparse.c │ │ │ │ │ ├── lj_cparse.h │ │ │ │ │ ├── lj_crecord.c │ │ │ │ │ ├── lj_crecord.h │ │ │ │ │ ├── lj_ctype.c │ │ │ │ │ ├── lj_ctype.h │ │ │ │ │ ├── lj_debug.c │ │ │ │ │ ├── lj_debug.h │ │ │ │ │ ├── lj_def.h │ │ │ │ │ ├── lj_dispatch.c │ │ │ │ │ ├── lj_dispatch.h │ │ │ │ │ ├── lj_emit_arm.h │ │ │ │ │ ├── lj_emit_mips.h │ │ │ │ │ ├── lj_emit_ppc.h │ │ │ │ │ ├── lj_emit_x86.h │ │ │ │ │ ├── lj_err.c │ │ │ │ │ ├── lj_err.h │ │ │ │ │ ├── lj_errmsg.h │ │ │ │ │ ├── lj_ff.h │ │ │ │ │ ├── lj_ffrecord.c │ │ │ │ │ ├── lj_ffrecord.h │ │ │ │ │ ├── lj_frame.h │ │ │ │ │ ├── lj_func.c │ │ │ │ │ ├── lj_func.h │ │ │ │ │ ├── lj_gc.c │ │ │ │ │ ├── lj_gc.h │ │ │ │ │ ├── lj_gdbjit.c │ │ │ │ │ ├── lj_gdbjit.h │ │ │ │ │ ├── lj_ir.c │ │ │ │ │ ├── lj_ir.h │ │ │ │ │ ├── lj_ircall.h │ │ │ │ │ ├── lj_iropt.h │ │ │ │ │ ├── lj_jit.h │ │ │ │ │ ├── lj_lex.c │ │ │ │ │ ├── lj_lex.h │ │ │ │ │ ├── lj_lib.c │ │ │ │ │ ├── lj_lib.h │ │ │ │ │ ├── lj_load.c │ │ │ │ │ ├── lj_mcode.c │ │ │ │ │ ├── lj_mcode.h │ │ │ │ │ ├── lj_meta.c │ │ │ │ │ ├── lj_meta.h │ │ │ │ │ ├── lj_obj.c │ │ │ │ │ ├── lj_obj.h │ │ │ │ │ ├── lj_opt_dce.c │ │ │ │ │ ├── lj_opt_fold.c │ │ │ │ │ ├── lj_opt_loop.c │ │ │ │ │ ├── lj_opt_mem.c │ │ │ │ │ ├── lj_opt_narrow.c │ │ │ │ │ ├── lj_opt_sink.c │ │ │ │ │ ├── lj_opt_split.c │ │ │ │ │ ├── lj_parse.c │ │ │ │ │ ├── lj_parse.h │ │ │ │ │ ├── lj_record.c │ │ │ │ │ ├── lj_record.h │ │ │ │ │ ├── lj_snap.c │ │ │ │ │ ├── lj_snap.h │ │ │ │ │ ├── lj_state.c │ │ │ │ │ ├── lj_state.h │ │ │ │ │ ├── lj_str.c │ │ │ │ │ ├── lj_str.h │ │ │ │ │ ├── lj_strscan.c │ │ │ │ │ ├── lj_strscan.h │ │ │ │ │ ├── lj_tab.c │ │ │ │ │ ├── lj_tab.h │ │ │ │ │ ├── lj_target.h │ │ │ │ │ ├── lj_target_arm.h │ │ │ │ │ ├── lj_target_mips.h │ │ │ │ │ ├── lj_target_ppc.h │ │ │ │ │ ├── lj_target_x86.h │ │ │ │ │ ├── lj_trace.c │ │ │ │ │ ├── lj_trace.h │ │ │ │ │ ├── lj_traceerr.h │ │ │ │ │ ├── lj_udata.c │ │ │ │ │ ├── lj_udata.h │ │ │ │ │ ├── lj_vm.h │ │ │ │ │ ├── lj_vmevent.c │ │ │ │ │ ├── lj_vmevent.h │ │ │ │ │ ├── lj_vmmath.c │ │ │ │ │ ├── ljamalg.c │ │ │ │ │ ├── lua.h │ │ │ │ │ ├── lua.hpp │ │ │ │ │ ├── luaconf.h │ │ │ │ │ ├── luajit.c │ │ │ │ │ ├── luajit.h │ │ │ │ │ ├── lualib.h │ │ │ │ │ ├── msvcbuild.bat │ │ │ │ │ ├── vm_arm.dasc │ │ │ │ │ ├── vm_mips.dasc │ │ │ │ │ ├── vm_ppc.dasc │ │ │ │ │ ├── vm_ppcspe.dasc │ │ │ │ │ ├── vm_x86.dasc │ │ │ │ │ └── xedkbuild.bat │ │ │ │ └── v2.0.1_hotfix1.patch │ │ │ └── tolua/ │ │ │ ├── CMakeLists.txt │ │ │ ├── tolua++.h │ │ │ ├── tolua_event.c │ │ │ ├── tolua_event.h │ │ │ ├── tolua_is.c │ │ │ ├── tolua_map.c │ │ │ ├── tolua_push.c │ │ │ └── tolua_to.c │ │ ├── png/ │ │ │ ├── include/ │ │ │ │ ├── android/ │ │ │ │ │ ├── png.h │ │ │ │ │ ├── pngconf.h │ │ │ │ │ └── pnglibconf.h │ │ │ │ ├── ios/ │ │ │ │ │ ├── png.h │ │ │ │ │ ├── pngconf.h │ │ │ │ │ └── pnglibconf.h │ │ │ │ ├── mac/ │ │ │ │ │ ├── png.h │ │ │ │ │ ├── pngconf.h │ │ │ │ │ └── pnglibconf.h │ │ │ │ └── win32/ │ │ │ │ ├── png.h │ │ │ │ ├── pngconf.h │ │ │ │ └── pnglibconf.h │ │ │ └── prebuilt/ │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── armeabi/ │ │ │ │ │ └── libpng.a │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ └── libpng.a │ │ │ │ └── x86/ │ │ │ │ └── libpng.a │ │ │ ├── ios/ │ │ │ │ └── libpng.a │ │ │ ├── mac/ │ │ │ │ └── libpng.a │ │ │ └── win32/ │ │ │ └── libpng.lib │ │ ├── spidermonkey/ │ │ │ ├── include/ │ │ │ │ ├── android/ │ │ │ │ │ ├── js/ │ │ │ │ │ │ ├── Anchor.h │ │ │ │ │ │ ├── CallArgs.h │ │ │ │ │ │ ├── CharacterEncoding.h │ │ │ │ │ │ ├── Date.h │ │ │ │ │ │ ├── GCAPI.h │ │ │ │ │ │ ├── HashTable.h │ │ │ │ │ │ ├── HeapAPI.h │ │ │ │ │ │ ├── LegacyIntTypes.h │ │ │ │ │ │ ├── MemoryMetrics.h │ │ │ │ │ │ ├── PropertyKey.h │ │ │ │ │ │ ├── RequiredDefines.h │ │ │ │ │ │ ├── RootingAPI.h │ │ │ │ │ │ ├── Utility.h │ │ │ │ │ │ ├── Value.h │ │ │ │ │ │ └── Vector.h │ │ │ │ │ ├── js-config.h │ │ │ │ │ ├── js.msg │ │ │ │ │ ├── jsalloc.h │ │ │ │ │ ├── jsapi.h │ │ │ │ │ ├── jsclass.h │ │ │ │ │ ├── jsclist.h │ │ │ │ │ ├── jscpucfg.h │ │ │ │ │ ├── jsdbgapi.h │ │ │ │ │ ├── jsfriendapi.h │ │ │ │ │ ├── jslock.h │ │ │ │ │ ├── jsperf.h │ │ │ │ │ ├── jsprf.h │ │ │ │ │ ├── jsprototypes.h │ │ │ │ │ ├── jsproxy.h │ │ │ │ │ ├── jsprvtd.h │ │ │ │ │ ├── jspubtd.h │ │ │ │ │ ├── jstypes.h │ │ │ │ │ ├── jsutil.h │ │ │ │ │ ├── jsversion.h │ │ │ │ │ ├── jswrapper.h │ │ │ │ │ └── mozilla/ │ │ │ │ │ ├── AllocPolicy.h │ │ │ │ │ ├── Array.h │ │ │ │ │ ├── Assertions.h │ │ │ │ │ ├── Atomics.h │ │ │ │ │ ├── Attributes.h │ │ │ │ │ ├── BloomFilter.h │ │ │ │ │ ├── Casting.h │ │ │ │ │ ├── Char16.h │ │ │ │ │ ├── CheckedInt.h │ │ │ │ │ ├── Compiler.h │ │ │ │ │ ├── Constants.h │ │ │ │ │ ├── DebugOnly.h │ │ │ │ │ ├── Decimal.h │ │ │ │ │ ├── Endian.h │ │ │ │ │ ├── EnumSet.h │ │ │ │ │ ├── FloatingPoint.h │ │ │ │ │ ├── GuardObjects.h │ │ │ │ │ ├── HashFunctions.h │ │ │ │ │ ├── Likely.h │ │ │ │ │ ├── LinkedList.h │ │ │ │ │ ├── MathAlgorithms.h │ │ │ │ │ ├── MemoryChecking.h │ │ │ │ │ ├── MemoryReporting.h │ │ │ │ │ ├── Move.h │ │ │ │ │ ├── NullPtr.h │ │ │ │ │ ├── PodOperations.h │ │ │ │ │ ├── Poison.h │ │ │ │ │ ├── Range.h │ │ │ │ │ ├── RangedPtr.h │ │ │ │ │ ├── ReentrancyGuard.h │ │ │ │ │ ├── RefPtr.h │ │ │ │ │ ├── SHA1.h │ │ │ │ │ ├── Scoped.h │ │ │ │ │ ├── SplayTree.h │ │ │ │ │ ├── TemplateLib.h │ │ │ │ │ ├── ThreadLocal.h │ │ │ │ │ ├── TypeTraits.h │ │ │ │ │ ├── TypedEnum.h │ │ │ │ │ ├── Types.h │ │ │ │ │ ├── Util.h │ │ │ │ │ ├── Vector.h │ │ │ │ │ └── WeakPtr.h │ │ │ │ ├── ios/ │ │ │ │ │ ├── js/ │ │ │ │ │ │ ├── Anchor.h │ │ │ │ │ │ ├── CallArgs.h │ │ │ │ │ │ ├── CharacterEncoding.h │ │ │ │ │ │ ├── Date.h │ │ │ │ │ │ ├── GCAPI.h │ │ │ │ │ │ ├── HashTable.h │ │ │ │ │ │ ├── HeapAPI.h │ │ │ │ │ │ ├── LegacyIntTypes.h │ │ │ │ │ │ ├── MemoryMetrics.h │ │ │ │ │ │ ├── PropertyKey.h │ │ │ │ │ │ ├── RequiredDefines.h │ │ │ │ │ │ ├── RootingAPI.h │ │ │ │ │ │ ├── Utility.h │ │ │ │ │ │ ├── Value.h │ │ │ │ │ │ └── Vector.h │ │ │ │ │ ├── js-config.h │ │ │ │ │ ├── js.msg │ │ │ │ │ ├── jsalloc.h │ │ │ │ │ ├── jsapi.h │ │ │ │ │ ├── jsclass.h │ │ │ │ │ ├── jsclist.h │ │ │ │ │ ├── jscpucfg.h │ │ │ │ │ ├── jsdbgapi.h │ │ │ │ │ ├── jsfriendapi.h │ │ │ │ │ ├── jslock.h │ │ │ │ │ ├── jsperf.h │ │ │ │ │ ├── jsprf.h │ │ │ │ │ ├── jsprototypes.h │ │ │ │ │ ├── jsproxy.h │ │ │ │ │ ├── jsprvtd.h │ │ │ │ │ ├── jspubtd.h │ │ │ │ │ ├── jstypes.h │ │ │ │ │ ├── jsutil.h │ │ │ │ │ ├── jsversion.h │ │ │ │ │ ├── jswrapper.h │ │ │ │ │ └── mozilla/ │ │ │ │ │ ├── AllocPolicy.h │ │ │ │ │ ├── Array.h │ │ │ │ │ ├── Assertions.h │ │ │ │ │ ├── Atomics.h │ │ │ │ │ ├── Attributes.h │ │ │ │ │ ├── BloomFilter.h │ │ │ │ │ ├── Casting.h │ │ │ │ │ ├── Char16.h │ │ │ │ │ ├── CheckedInt.h │ │ │ │ │ ├── Compiler.h │ │ │ │ │ ├── Constants.h │ │ │ │ │ ├── DebugOnly.h │ │ │ │ │ ├── Decimal.h │ │ │ │ │ ├── Endian.h │ │ │ │ │ ├── EnumSet.h │ │ │ │ │ ├── FloatingPoint.h │ │ │ │ │ ├── GuardObjects.h │ │ │ │ │ ├── HashFunctions.h │ │ │ │ │ ├── Likely.h │ │ │ │ │ ├── LinkedList.h │ │ │ │ │ ├── MathAlgorithms.h │ │ │ │ │ ├── MemoryChecking.h │ │ │ │ │ ├── MemoryReporting.h │ │ │ │ │ ├── Move.h │ │ │ │ │ ├── NullPtr.h │ │ │ │ │ ├── PodOperations.h │ │ │ │ │ ├── Poison.h │ │ │ │ │ ├── Range.h │ │ │ │ │ ├── RangedPtr.h │ │ │ │ │ ├── ReentrancyGuard.h │ │ │ │ │ ├── RefPtr.h │ │ │ │ │ ├── SHA1.h │ │ │ │ │ ├── Scoped.h │ │ │ │ │ ├── SplayTree.h │ │ │ │ │ ├── TemplateLib.h │ │ │ │ │ ├── ThreadLocal.h │ │ │ │ │ ├── TypeTraits.h │ │ │ │ │ ├── TypedEnum.h │ │ │ │ │ ├── Types.h │ │ │ │ │ ├── Util.h │ │ │ │ │ ├── Vector.h │ │ │ │ │ └── WeakPtr.h │ │ │ │ ├── mac/ │ │ │ │ │ ├── js/ │ │ │ │ │ │ ├── Anchor.h │ │ │ │ │ │ ├── CallArgs.h │ │ │ │ │ │ ├── CharacterEncoding.h │ │ │ │ │ │ ├── Date.h │ │ │ │ │ │ ├── GCAPI.h │ │ │ │ │ │ ├── HashTable.h │ │ │ │ │ │ ├── HeapAPI.h │ │ │ │ │ │ ├── LegacyIntTypes.h │ │ │ │ │ │ ├── MemoryMetrics.h │ │ │ │ │ │ ├── PropertyKey.h │ │ │ │ │ │ ├── RequiredDefines.h │ │ │ │ │ │ ├── RootingAPI.h │ │ │ │ │ │ ├── Utility.h │ │ │ │ │ │ ├── Value.h │ │ │ │ │ │ └── Vector.h │ │ │ │ │ ├── js-config.h │ │ │ │ │ ├── js.msg │ │ │ │ │ ├── jsalloc.h │ │ │ │ │ ├── jsapi.h │ │ │ │ │ ├── jsclass.h │ │ │ │ │ ├── jsclist.h │ │ │ │ │ ├── jscpucfg.h │ │ │ │ │ ├── jsdbgapi.h │ │ │ │ │ ├── jsfriendapi.h │ │ │ │ │ ├── jslock.h │ │ │ │ │ ├── jsperf.h │ │ │ │ │ ├── jsprf.h │ │ │ │ │ ├── jsprototypes.h │ │ │ │ │ ├── jsproxy.h │ │ │ │ │ ├── jsprvtd.h │ │ │ │ │ ├── jspubtd.h │ │ │ │ │ ├── jstypes.h │ │ │ │ │ ├── jsutil.h │ │ │ │ │ ├── jsversion.h │ │ │ │ │ ├── jswrapper.h │ │ │ │ │ └── mozilla/ │ │ │ │ │ ├── AllocPolicy.h │ │ │ │ │ ├── Array.h │ │ │ │ │ ├── Assertions.h │ │ │ │ │ ├── Atomics.h │ │ │ │ │ ├── Attributes.h │ │ │ │ │ ├── BloomFilter.h │ │ │ │ │ ├── Casting.h │ │ │ │ │ ├── Char16.h │ │ │ │ │ ├── CheckedInt.h │ │ │ │ │ ├── Compiler.h │ │ │ │ │ ├── Constants.h │ │ │ │ │ ├── DebugOnly.h │ │ │ │ │ ├── Decimal.h │ │ │ │ │ ├── Endian.h │ │ │ │ │ ├── EnumSet.h │ │ │ │ │ ├── FloatingPoint.h │ │ │ │ │ ├── GuardObjects.h │ │ │ │ │ ├── HashFunctions.h │ │ │ │ │ ├── Likely.h │ │ │ │ │ ├── LinkedList.h │ │ │ │ │ ├── MathAlgorithms.h │ │ │ │ │ ├── MemoryChecking.h │ │ │ │ │ ├── MemoryReporting.h │ │ │ │ │ ├── Move.h │ │ │ │ │ ├── NullPtr.h │ │ │ │ │ ├── PodOperations.h │ │ │ │ │ ├── Poison.h │ │ │ │ │ ├── Range.h │ │ │ │ │ ├── RangedPtr.h │ │ │ │ │ ├── ReentrancyGuard.h │ │ │ │ │ ├── RefPtr.h │ │ │ │ │ ├── SHA1.h │ │ │ │ │ ├── Scoped.h │ │ │ │ │ ├── SplayTree.h │ │ │ │ │ ├── TemplateLib.h │ │ │ │ │ ├── ThreadLocal.h │ │ │ │ │ ├── TypeTraits.h │ │ │ │ │ ├── TypedEnum.h │ │ │ │ │ ├── Types.h │ │ │ │ │ ├── Util.h │ │ │ │ │ ├── Vector.h │ │ │ │ │ └── WeakPtr.h │ │ │ │ └── win32/ │ │ │ │ ├── js/ │ │ │ │ │ ├── Anchor.h │ │ │ │ │ ├── CallArgs.h │ │ │ │ │ ├── CharacterEncoding.h │ │ │ │ │ ├── Date.h │ │ │ │ │ ├── GCAPI.h │ │ │ │ │ ├── HashTable.h │ │ │ │ │ ├── HeapAPI.h │ │ │ │ │ ├── LegacyIntTypes.h │ │ │ │ │ ├── MemoryMetrics.h │ │ │ │ │ ├── PropertyKey.h │ │ │ │ │ ├── RequiredDefines.h │ │ │ │ │ ├── RootingAPI.h │ │ │ │ │ ├── Utility.h │ │ │ │ │ ├── Value.h │ │ │ │ │ └── Vector.h │ │ │ │ ├── js-config.h │ │ │ │ ├── js.msg │ │ │ │ ├── jsalloc.h │ │ │ │ ├── jsapi.h │ │ │ │ ├── jsclass.h │ │ │ │ ├── jsclist.h │ │ │ │ ├── jscpucfg.h │ │ │ │ ├── jsdbgapi.h │ │ │ │ ├── jsfriendapi.h │ │ │ │ ├── jslock.h │ │ │ │ ├── jsperf.h │ │ │ │ ├── jsprf.h │ │ │ │ ├── jsprototypes.h │ │ │ │ ├── jsproxy.h │ │ │ │ ├── jsprvtd.h │ │ │ │ ├── jspubtd.h │ │ │ │ ├── jstypes.h │ │ │ │ ├── jsutil.h │ │ │ │ ├── jsversion.h │ │ │ │ ├── jswrapper.h │ │ │ │ └── mozilla/ │ │ │ │ ├── AllocPolicy.h │ │ │ │ ├── Array.h │ │ │ │ ├── Assertions.h │ │ │ │ ├── Atomics.h │ │ │ │ ├── Attributes.h │ │ │ │ ├── BloomFilter.h │ │ │ │ ├── Casting.h │ │ │ │ ├── Char16.h │ │ │ │ ├── CheckedInt.h │ │ │ │ ├── Compiler.h │ │ │ │ ├── Constants.h │ │ │ │ ├── DebugOnly.h │ │ │ │ ├── Decimal.h │ │ │ │ ├── Endian.h │ │ │ │ ├── EnumSet.h │ │ │ │ ├── FloatingPoint.h │ │ │ │ ├── GuardObjects.h │ │ │ │ ├── HashFunctions.h │ │ │ │ ├── Likely.h │ │ │ │ ├── LinkedList.h │ │ │ │ ├── MathAlgorithms.h │ │ │ │ ├── MemoryChecking.h │ │ │ │ ├── MemoryReporting.h │ │ │ │ ├── Move.h │ │ │ │ ├── NullPtr.h │ │ │ │ ├── PodOperations.h │ │ │ │ ├── Poison.h │ │ │ │ ├── Range.h │ │ │ │ ├── RangedPtr.h │ │ │ │ ├── ReentrancyGuard.h │ │ │ │ ├── RefPtr.h │ │ │ │ ├── SHA1.h │ │ │ │ ├── Scoped.h │ │ │ │ ├── SplayTree.h │ │ │ │ ├── TemplateLib.h │ │ │ │ ├── ThreadLocal.h │ │ │ │ ├── TypeTraits.h │ │ │ │ ├── TypedEnum.h │ │ │ │ ├── Types.h │ │ │ │ ├── Util.h │ │ │ │ ├── Vector.h │ │ │ │ └── WeakPtr.h │ │ │ └── prebuilt/ │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── armeabi/ │ │ │ │ │ └── libjs_static.a │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ └── libjs_static.a │ │ │ │ └── x86/ │ │ │ │ └── libjs_static.a │ │ │ ├── ios/ │ │ │ │ └── libjs_static.a │ │ │ ├── mac/ │ │ │ │ └── libjs_static.a │ │ │ └── win32/ │ │ │ └── mozjs-25.0.lib │ │ ├── sqlite3/ │ │ │ ├── Android.mk │ │ │ ├── include/ │ │ │ │ ├── sqlite3.h │ │ │ │ └── sqlite3ext.h │ │ │ └── libraries/ │ │ │ └── win32/ │ │ │ └── sqlite3.lib │ │ ├── tiff/ │ │ │ ├── include/ │ │ │ │ ├── android/ │ │ │ │ │ ├── tiff.h │ │ │ │ │ ├── tiffconf.h │ │ │ │ │ ├── tiffio.h │ │ │ │ │ └── tiffvers.h │ │ │ │ ├── ios/ │ │ │ │ │ ├── tiff.h │ │ │ │ │ ├── tiffconf.h │ │ │ │ │ ├── tiffio.h │ │ │ │ │ └── tiffvers.h │ │ │ │ ├── linux/ │ │ │ │ │ ├── tiff.h │ │ │ │ │ ├── tiffconf.h │ │ │ │ │ ├── tiffio.h │ │ │ │ │ └── tiffvers.h │ │ │ │ ├── mac/ │ │ │ │ │ ├── tiff.h │ │ │ │ │ ├── tiffconf.h │ │ │ │ │ ├── tiffio.h │ │ │ │ │ └── tiffvers.h │ │ │ │ └── win32/ │ │ │ │ ├── tiff.h │ │ │ │ ├── tiffconf.h │ │ │ │ ├── tiffio.h │ │ │ │ └── tiffvers.h │ │ │ └── prebuilt/ │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── armeabi/ │ │ │ │ │ └── libtiff.a │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ └── libtiff.a │ │ │ │ └── x86/ │ │ │ │ └── libtiff.a │ │ │ ├── ios/ │ │ │ │ └── libtiff.a │ │ │ ├── linux/ │ │ │ │ ├── 32-bit/ │ │ │ │ │ └── libtiff.a │ │ │ │ └── 64-bit/ │ │ │ │ └── libtiff.a │ │ │ ├── mac/ │ │ │ │ └── libtiff.a │ │ │ └── win32/ │ │ │ └── libtiff.lib │ │ ├── tinyxml2/ │ │ │ ├── CMakeLists.txt │ │ │ ├── tinyxml2.cpp │ │ │ └── tinyxml2.h │ │ ├── unzip/ │ │ │ ├── CMakeLists.txt │ │ │ ├── ioapi.cpp │ │ │ ├── ioapi.h │ │ │ ├── unzip.cpp │ │ │ └── unzip.h │ │ ├── webp/ │ │ │ ├── include/ │ │ │ │ ├── android/ │ │ │ │ │ ├── decode.h │ │ │ │ │ ├── encode.h │ │ │ │ │ └── types.h │ │ │ │ ├── ios/ │ │ │ │ │ ├── decode.h │ │ │ │ │ ├── encode.h │ │ │ │ │ └── types.h │ │ │ │ ├── linux/ │ │ │ │ │ ├── decode.h │ │ │ │ │ ├── encode.h │ │ │ │ │ └── types.h │ │ │ │ ├── mac/ │ │ │ │ │ ├── decode.h │ │ │ │ │ ├── encode.h │ │ │ │ │ └── types.h │ │ │ │ └── win32/ │ │ │ │ ├── decode.h │ │ │ │ ├── encode.h │ │ │ │ └── types.h │ │ │ └── prebuilt/ │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── armeabi/ │ │ │ │ │ └── libwebp.a │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ └── libwebp.a │ │ │ │ └── x86/ │ │ │ │ └── libwebp.a │ │ │ ├── ios/ │ │ │ │ └── libwebp.a │ │ │ ├── linux/ │ │ │ │ ├── 32-bit/ │ │ │ │ │ └── libwebp.a │ │ │ │ └── 64-bit/ │ │ │ │ └── libwebp.a │ │ │ ├── mac/ │ │ │ │ └── libwebp.a │ │ │ └── win32/ │ │ │ └── libwebp.lib │ │ ├── websockets/ │ │ │ ├── include/ │ │ │ │ ├── android/ │ │ │ │ │ └── libwebsockets.h │ │ │ │ ├── ios/ │ │ │ │ │ └── libwebsockets.h │ │ │ │ ├── mac/ │ │ │ │ │ └── libwebsockets.h │ │ │ │ └── win32/ │ │ │ │ ├── libwebsockets.h │ │ │ │ └── win32helpers/ │ │ │ │ ├── gettimeofday.h │ │ │ │ └── websock-w32.h │ │ │ └── prebuilt/ │ │ │ ├── android/ │ │ │ │ ├── Android.mk │ │ │ │ ├── armeabi/ │ │ │ │ │ └── libwebsockets.a │ │ │ │ ├── armeabi-v7a/ │ │ │ │ │ └── libwebsockets.a │ │ │ │ └── x86/ │ │ │ │ └── libwebsockets.a │ │ │ ├── ios/ │ │ │ │ └── libwebsockets.a │ │ │ ├── mac/ │ │ │ │ └── libwebsockets.a │ │ │ └── win32/ │ │ │ └── websockets.lib │ │ └── win32-specific/ │ │ ├── gles/ │ │ │ ├── include/ │ │ │ │ └── OGLES/ │ │ │ │ └── GL/ │ │ │ │ ├── glew.h │ │ │ │ ├── glxew.h │ │ │ │ └── wglew.h │ │ │ └── prebuilt/ │ │ │ └── glew32.lib │ │ ├── icon/ │ │ │ ├── include/ │ │ │ │ └── iconv.h │ │ │ └── prebuilt/ │ │ │ └── libiconv.lib │ │ └── zlib/ │ │ ├── include/ │ │ │ ├── zconf.h │ │ │ └── zlib.h │ │ └── prebuilt/ │ │ └── libzlib.lib │ ├── licenses/ │ │ ├── LICENSE_CCBReader.txt │ │ ├── LICENSE_CCControlExtension.txt │ │ ├── LICENSE_JSON4Lua.txt │ │ ├── LICENSE_Kazmath.txt │ │ ├── LICENSE_SpiderMonkey.txt │ │ ├── LICENSE_artwork.txt │ │ ├── LICENSE_box2d.txt │ │ ├── LICENSE_chipmunk.txt │ │ ├── LICENSE_cocos2d-iphone.txt │ │ ├── LICENSE_cocos2d-x.txt │ │ ├── LICENSE_cocosdenshion.txt │ │ ├── LICENSE_curl.txt │ │ ├── LICENSE_js.txt │ │ ├── LICENSE_jsoncpp.txt │ │ ├── LICENSE_libjpeg.txt │ │ ├── LICENSE_libpng.txt │ │ ├── LICENSE_libtiff.txt │ │ ├── LICENSE_libwebsockets.txt │ │ ├── LICENSE_libxml2.txt │ │ ├── LICENSE_lua.txt │ │ ├── LICENSE_ogg_vorbis.txt │ │ ├── LICENSE_tolua++.txt │ │ └── LICENSE_zlib.txt │ ├── plugin/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── jsbindings/ │ │ │ ├── auto/ │ │ │ │ ├── jsb_pluginx_protocols_auto.cpp │ │ │ │ ├── jsb_pluginx_protocols_auto.hpp │ │ │ │ └── jsb_pluginx_protocols_auto_api.js │ │ │ ├── js/ │ │ │ │ └── jsb_pluginx.js │ │ │ └── manual/ │ │ │ ├── jsb_pluginx_basic_conversions.cpp │ │ │ ├── jsb_pluginx_basic_conversions.h │ │ │ ├── jsb_pluginx_extension_registration.cpp │ │ │ ├── jsb_pluginx_extension_registration.h │ │ │ ├── jsb_pluginx_manual_callback.cpp │ │ │ ├── jsb_pluginx_manual_callback.h │ │ │ ├── jsb_pluginx_manual_protocols.cpp │ │ │ ├── jsb_pluginx_manual_protocols.h │ │ │ ├── jsb_pluginx_spidermonkey_specifics.cpp │ │ │ ├── jsb_pluginx_spidermonkey_specifics.h │ │ │ ├── pluginxUTF8.cpp │ │ │ ├── pluginxUTF8.h │ │ │ └── uthash.h │ │ ├── plugins/ │ │ │ ├── admob/ │ │ │ │ ├── proj.android/ │ │ │ │ │ ├── .classpath │ │ │ │ │ ├── .project │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── ForManifest.xml │ │ │ │ │ ├── build.xml │ │ │ │ │ ├── project.properties │ │ │ │ │ ├── res/ │ │ │ │ │ │ └── .gitignore │ │ │ │ │ ├── sdk/ │ │ │ │ │ │ └── GoogleAdMobAdsSdk.jar │ │ │ │ │ └── src/ │ │ │ │ │ └── org/ │ │ │ │ │ └── cocos2dx/ │ │ │ │ │ └── plugin/ │ │ │ │ │ └── AdsAdmob.java │ │ │ │ └── proj.ios/ │ │ │ │ ├── Admob/ │ │ │ │ │ ├── GADAdMobExtras.h │ │ │ │ │ ├── GADAdNetworkExtras.h │ │ │ │ │ ├── GADAdSize.h │ │ │ │ │ ├── GADBannerView.h │ │ │ │ │ ├── GADBannerViewDelegate.h │ │ │ │ │ ├── GADInterstitial.h │ │ │ │ │ ├── GADInterstitialDelegate.h │ │ │ │ │ ├── GADRequest.h │ │ │ │ │ ├── GADRequestError.h │ │ │ │ │ └── libGoogleAdMobAds.a │ │ │ │ ├── AdsAdmob.h │ │ │ │ ├── AdsAdmob.m │ │ │ │ └── PluginAdmob.xcodeproj/ │ │ │ │ └── project.pbxproj │ │ │ ├── alipay/ │ │ │ │ └── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── ForAssets/ │ │ │ │ │ └── alipay_plugin.apk │ │ │ │ ├── ForManifest.xml │ │ │ │ ├── build.xml │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ └── .gitignore │ │ │ │ ├── sdk/ │ │ │ │ │ └── alipay_plugin.jar │ │ │ │ └── src/ │ │ │ │ └── org/ │ │ │ │ └── cocos2dx/ │ │ │ │ └── plugin/ │ │ │ │ ├── AlixId.java │ │ │ │ ├── Base64.java │ │ │ │ ├── BaseHelper.java │ │ │ │ ├── IAPAlipay.java │ │ │ │ ├── MobileSecurePayHelper.java │ │ │ │ ├── MobileSecurePayer.java │ │ │ │ ├── NetworkManager.java │ │ │ │ ├── PartnerConfig.java │ │ │ │ ├── ResultChecker.java │ │ │ │ └── Rsa.java │ │ │ ├── flurry/ │ │ │ │ ├── proj.android/ │ │ │ │ │ ├── .classpath │ │ │ │ │ ├── .project │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── ForManifest.xml │ │ │ │ │ ├── build.xml │ │ │ │ │ ├── project.properties │ │ │ │ │ ├── res/ │ │ │ │ │ │ └── .gitignore │ │ │ │ │ ├── sdk/ │ │ │ │ │ │ └── FlurryAgent.jar │ │ │ │ │ └── src/ │ │ │ │ │ └── org/ │ │ │ │ │ └── cocos2dx/ │ │ │ │ │ └── plugin/ │ │ │ │ │ ├── AdsFlurry.java │ │ │ │ │ └── AnalyticsFlurry.java │ │ │ │ └── proj.ios/ │ │ │ │ ├── AdsFlurry.h │ │ │ │ ├── AdsFlurry.m │ │ │ │ ├── AnalyticsFlurry.h │ │ │ │ ├── AnalyticsFlurry.m │ │ │ │ ├── Flurry.h │ │ │ │ ├── FlurryAds/ │ │ │ │ │ ├── FlurryAdDelegate.h │ │ │ │ │ ├── FlurryAds.h │ │ │ │ │ └── libFlurryAds.a │ │ │ │ ├── PluginFlurry.xcodeproj/ │ │ │ │ │ └── project.pbxproj │ │ │ │ └── libFlurry.a │ │ │ ├── nd91/ │ │ │ │ └── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── DependProject/ │ │ │ │ │ ├── .classpath │ │ │ │ │ ├── .project │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── project.properties │ │ │ │ │ ├── res/ │ │ │ │ │ │ ├── anim/ │ │ │ │ │ │ │ ├── nd_flipin.xml │ │ │ │ │ │ │ ├── nd_flipin_reverse.xml │ │ │ │ │ │ │ ├── nd_flipout.xml │ │ │ │ │ │ │ └── nd_flipout_reverse.xml │ │ │ │ │ │ ├── drawable/ │ │ │ │ │ │ │ ├── nd3_background_xml.xml │ │ │ │ │ │ │ ├── nd3_button.xml │ │ │ │ │ │ │ ├── nd3_button_02.xml │ │ │ │ │ │ │ ├── nd3_button_action.xml │ │ │ │ │ │ │ ├── nd3_button_logout.xml │ │ │ │ │ │ │ ├── nd3_button_old.xml │ │ │ │ │ │ │ ├── nd3_button_x.xml │ │ │ │ │ │ │ ├── nd3_checkbox_button.xml │ │ │ │ │ │ │ ├── nd3_friend_del_button.xml │ │ │ │ │ │ │ ├── nd3_image_48_bg.xml │ │ │ │ │ │ │ ├── nd3_input_gray.xml │ │ │ │ │ │ │ ├── nd3_message_item_1_bg.xml │ │ │ │ │ │ │ ├── nd3_message_item_2_bg.xml │ │ │ │ │ │ │ ├── nd3_pay_checkbox_button.xml │ │ │ │ │ │ │ ├── nd3_progress_large.xml │ │ │ │ │ │ │ ├── nd3_rank_choice_left_btn_bg.xml │ │ │ │ │ │ │ ├── nd3_rank_choice_middle_btn_bg.xml │ │ │ │ │ │ │ ├── nd3_rank_choice_right_btn_bg.xml │ │ │ │ │ │ │ ├── nd3_regist_checked.xml │ │ │ │ │ │ │ ├── nd3_round_bg.xml │ │ │ │ │ │ │ ├── nd3_square_checkbox_button.xml │ │ │ │ │ │ │ ├── nd3_title_bar_action_btn_xml.xml │ │ │ │ │ │ │ ├── nd3_title_bar_return_btn_xml.xml │ │ │ │ │ │ │ ├── nd3_user_item_bg.xml │ │ │ │ │ │ │ ├── nd_blue.xml │ │ │ │ │ │ │ ├── nd_button_action_add.xml │ │ │ │ │ │ │ ├── nd_button_action_buy.xml │ │ │ │ │ │ │ ├── nd_button_action_reduce.xml │ │ │ │ │ │ │ ├── nd_c_blur.xml │ │ │ │ │ │ │ ├── nd_download.xml │ │ │ │ │ │ │ ├── nd_green.xml │ │ │ │ │ │ │ ├── nd_leaderboard_left_btn_bg.xml │ │ │ │ │ │ │ ├── nd_leaderboard_right_btn_bg.xml │ │ │ │ │ │ │ ├── nd_list_btn_delete_selector.xml │ │ │ │ │ │ │ ├── nd_login_btn_land_selector.xml │ │ │ │ │ │ │ ├── nd_login_btn_portrait_selector.xml │ │ │ │ │ │ │ ├── nd_register_btn_portrait_selector.xml │ │ │ │ │ │ │ ├── nd_slider_handle_h.xml │ │ │ │ │ │ │ ├── nd_slider_handle_h_expand.xml │ │ │ │ │ │ │ ├── nd_slider_handle_v.xml │ │ │ │ │ │ │ ├── nd_slider_handle_v_expand.xml │ │ │ │ │ │ │ └── nd_white_btn.xml │ │ │ │ │ │ ├── layout/ │ │ │ │ │ │ │ ├── nd3_account_bind_bind.xml │ │ │ │ │ │ │ ├── nd3_account_bind_register.xml │ │ │ │ │ │ │ ├── nd3_account_email_item.xml │ │ │ │ │ │ │ ├── nd3_account_login.xml │ │ │ │ │ │ │ ├── nd3_account_login_item.xml │ │ │ │ │ │ │ ├── nd3_account_login_land.xml │ │ │ │ │ │ │ ├── nd3_account_login_other_item.xml │ │ │ │ │ │ │ ├── nd3_account_login_portrait.xml │ │ │ │ │ │ │ ├── nd3_account_oauth_bind.xml │ │ │ │ │ │ │ ├── nd3_account_official.xml │ │ │ │ │ │ │ ├── nd3_account_official_landscape.xml │ │ │ │ │ │ │ ├── nd3_account_official_portrait.xml │ │ │ │ │ │ │ ├── nd3_account_other_login.xml │ │ │ │ │ │ │ ├── nd3_account_register.xml │ │ │ │ │ │ │ ├── nd3_account_register_agreement.xml │ │ │ │ │ │ │ ├── nd3_account_register_phone.xml │ │ │ │ │ │ │ ├── nd3_account_register_quick.xml │ │ │ │ │ │ │ ├── nd3_account_secret_find.xml │ │ │ │ │ │ │ ├── nd3_account_secret_set.xml │ │ │ │ │ │ │ ├── nd3_account_sina.xml │ │ │ │ │ │ │ ├── nd3_achieve_detail.xml │ │ │ │ │ │ │ ├── nd3_activity_action_template.xml │ │ │ │ │ │ │ ├── nd3_activity_content_reg_template_1.xml │ │ │ │ │ │ │ ├── nd3_activity_content_reg_template_2.xml │ │ │ │ │ │ │ ├── nd3_activity_content_reg_template_2_ext.xml │ │ │ │ │ │ │ ├── nd3_activity_content_reg_template_3.xml │ │ │ │ │ │ │ ├── nd3_activity_content_reg_template_4.xml │ │ │ │ │ │ │ ├── nd3_activity_detail.xml │ │ │ │ │ │ │ ├── nd3_activity_detail_plus_image.xml │ │ │ │ │ │ │ ├── nd3_activity_detail_plus_list.xml │ │ │ │ │ │ │ ├── nd3_activity_detail_plus_list_ext.xml │ │ │ │ │ │ │ ├── nd3_activity_head_reg.xml │ │ │ │ │ │ │ ├── nd3_activity_no_action_template.xml │ │ │ │ │ │ │ ├── nd3_app_feedback.xml │ │ │ │ │ │ │ ├── nd3_app_item.xml │ │ │ │ │ │ │ ├── nd3_app_property.xml │ │ │ │ │ │ │ ├── nd3_banner_layout.xml │ │ │ │ │ │ │ ├── nd3_blank_listview.xml │ │ │ │ │ │ │ ├── nd3_bottom_bar.xml │ │ │ │ │ │ │ ├── nd3_category_item.xml │ │ │ │ │ │ │ ├── nd3_category_plus_image_item.xml │ │ │ │ │ │ │ ├── nd3_control_center.xml │ │ │ │ │ │ │ ├── nd3_dispatch_search_friend.xml │ │ │ │ │ │ │ ├── nd3_empty_listview.xml │ │ │ │ │ │ │ ├── nd3_frame.xml │ │ │ │ │ │ │ ├── nd3_friend_home.xml │ │ │ │ │ │ │ ├── nd3_friend_remark_setting.xml │ │ │ │ │ │ │ ├── nd3_friend_section.xml │ │ │ │ │ │ │ ├── nd3_friend_section_list_item.xml │ │ │ │ │ │ │ ├── nd3_friend_section_panel.xml │ │ │ │ │ │ │ ├── nd3_game_content.xml │ │ │ │ │ │ │ ├── nd3_game_main.xml │ │ │ │ │ │ │ ├── nd3_home.xml │ │ │ │ │ │ │ ├── nd3_home_land.xml │ │ │ │ │ │ │ ├── nd3_home_personal.xml │ │ │ │ │ │ │ ├── nd3_home_portrait.xml │ │ │ │ │ │ │ ├── nd3_invite_friend.xml │ │ │ │ │ │ │ ├── nd3_invite_friend_choice.xml │ │ │ │ │ │ │ ├── nd3_invite_friend_item.xml │ │ │ │ │ │ │ ├── nd3_leaderboard_category.xml │ │ │ │ │ │ │ ├── nd3_leaderboard_list_item.xml │ │ │ │ │ │ │ ├── nd3_listview_footer.xml │ │ │ │ │ │ │ ├── nd3_listview_footer_ext.xml │ │ │ │ │ │ │ ├── nd3_listview_template.xml │ │ │ │ │ │ │ ├── nd3_listview_template_no_divider.xml │ │ │ │ │ │ │ ├── nd3_mesg_main.xml │ │ │ │ │ │ │ ├── nd3_message_friendmsge_list.xml │ │ │ │ │ │ │ ├── nd3_message_main.xml │ │ │ │ │ │ │ ├── nd3_message_receive_item.xml │ │ │ │ │ │ │ ├── nd3_message_record_item.xml │ │ │ │ │ │ │ ├── nd3_message_send.xml │ │ │ │ │ │ │ ├── nd3_message_send_item.xml │ │ │ │ │ │ │ ├── nd3_more_about.xml │ │ │ │ │ │ │ ├── nd3_more_account.xml │ │ │ │ │ │ │ ├── nd3_more_bean_recharge.xml │ │ │ │ │ │ │ ├── nd3_more_consume_detail.xml │ │ │ │ │ │ │ ├── nd3_more_consumes.xml │ │ │ │ │ │ │ ├── nd3_more_info.xml │ │ │ │ │ │ │ ├── nd3_more_info_edit_head_dialog.xml │ │ │ │ │ │ │ ├── nd3_more_more.xml │ │ │ │ │ │ │ ├── nd3_more_no_password.xml │ │ │ │ │ │ │ ├── nd3_more_password.xml │ │ │ │ │ │ │ ├── nd3_more_permission.xml │ │ │ │ │ │ │ ├── nd3_more_recharge_detail.xml │ │ │ │ │ │ │ ├── nd3_more_recharges.xml │ │ │ │ │ │ │ ├── nd3_more_records.xml │ │ │ │ │ │ │ ├── nd3_more_records_item.xml │ │ │ │ │ │ │ ├── nd3_myfriend.xml │ │ │ │ │ │ │ ├── nd3_network_error.xml │ │ │ │ │ │ │ ├── nd3_normal_search.xml │ │ │ │ │ │ │ ├── nd3_pay_friend_item.xml │ │ │ │ │ │ │ ├── nd3_pay_pass.xml │ │ │ │ │ │ │ ├── nd3_pay_password_check.xml │ │ │ │ │ │ │ ├── nd3_pay_products_item.xml │ │ │ │ │ │ │ ├── nd3_pay_select_friend.xml │ │ │ │ │ │ │ ├── nd3_pay_template.xml │ │ │ │ │ │ │ ├── nd3_person_info_detail.xml │ │ │ │ │ │ │ ├── nd3_personinfo.xml │ │ │ │ │ │ │ ├── nd3_progressbar.xml │ │ │ │ │ │ │ ├── nd3_recharge_record.xml │ │ │ │ │ │ │ ├── nd3_searchfriend_condition.xml │ │ │ │ │ │ │ ├── nd3_share_bind_account_item.xml │ │ │ │ │ │ │ ├── nd3_share_sina.xml │ │ │ │ │ │ │ ├── nd3_share_unbind_account_item.xml │ │ │ │ │ │ │ ├── nd3_stranger_home.xml │ │ │ │ │ │ │ ├── nd3_sysmessage_detail_action.xml │ │ │ │ │ │ │ ├── nd3_sysmessage_detail_app.xml │ │ │ │ │ │ │ ├── nd3_sysmessage_detail_no_action.xml │ │ │ │ │ │ │ ├── nd3_sysmessage_head_reg.xml │ │ │ │ │ │ │ ├── nd3_thirdplatform_item.xml │ │ │ │ │ │ │ ├── nd3_title_bar.xml │ │ │ │ │ │ │ ├── nd3_user_fangle.xml │ │ │ │ │ │ │ ├── nd3_user_fangle_ext.xml │ │ │ │ │ │ │ ├── nd3_user_item.xml │ │ │ │ │ │ │ ├── nd3_user_item_divider.xml │ │ │ │ │ │ │ ├── nd3_user_message.xml │ │ │ │ │ │ │ ├── nd3_user_message_switcher.xml │ │ │ │ │ │ │ ├── nd3_version_update.xml │ │ │ │ │ │ │ ├── nd3_write_message.xml │ │ │ │ │ │ │ ├── nd_account_list_item.xml │ │ │ │ │ │ │ ├── nd_account_manage.xml │ │ │ │ │ │ │ ├── nd_bind_phone_lottery.xml │ │ │ │ │ │ │ ├── nd_bind_phone_number.xml │ │ │ │ │ │ │ ├── nd_bind_phone_number_result.xml │ │ │ │ │ │ │ ├── nd_bind_phone_number_tip.xml │ │ │ │ │ │ │ ├── nd_bind_phone_number_unactivity_tip.xml │ │ │ │ │ │ │ ├── nd_check_version.xml │ │ │ │ │ │ │ ├── nd_feedback_faq.xml │ │ │ │ │ │ │ ├── nd_feedback_faq_list.xml │ │ │ │ │ │ │ ├── nd_feedback_fb.xml │ │ │ │ │ │ │ ├── nd_feedback_menu.xml │ │ │ │ │ │ │ ├── nd_feedback_menu_item.xml │ │ │ │ │ │ │ ├── nd_feedback_my_fb_item.xml │ │ │ │ │ │ │ ├── nd_feedback_my_fb_list.xml │ │ │ │ │ │ │ ├── nd_feedback_pj_landscape.xml │ │ │ │ │ │ │ ├── nd_feedback_pj_portrait.xml │ │ │ │ │ │ │ ├── nd_feedback_reply.xml │ │ │ │ │ │ │ ├── nd_feedback_reply_bottom.xml │ │ │ │ │ │ │ ├── nd_feedback_reply_item_left.xml │ │ │ │ │ │ │ ├── nd_feedback_reply_item_right.xml │ │ │ │ │ │ │ ├── nd_find_password.xml │ │ │ │ │ │ │ ├── nd_gcsdk_custom_toast.xml │ │ │ │ │ │ │ ├── nd_gcsdk_exitpage.xml │ │ │ │ │ │ │ ├── nd_gcsdk_pausepage.xml │ │ │ │ │ │ │ ├── nd_gcsdk_project_view_type_1.xml │ │ │ │ │ │ │ ├── nd_gcsdk_project_view_type_2.xml │ │ │ │ │ │ │ ├── nd_gcsdk_project_view_type_3.xml │ │ │ │ │ │ │ ├── nd_goods_detail.xml │ │ │ │ │ │ │ ├── nd_goods_list.xml │ │ │ │ │ │ │ ├── nd_goods_list_item.xml │ │ │ │ │ │ │ ├── nd_leaderboard.xml │ │ │ │ │ │ │ ├── nd_leaderboard_list_header.xml │ │ │ │ │ │ │ ├── nd_leaderboard_switcher_landscape_1.xml │ │ │ │ │ │ │ ├── nd_leaderboard_switcher_portrait_1.xml │ │ │ │ │ │ │ ├── nd_login_director.xml │ │ │ │ │ │ │ ├── nd_set_password.xml │ │ │ │ │ │ │ ├── nd_softpromotion_flipitem.xml │ │ │ │ │ │ │ ├── nd_softpromotion_listitem.xml │ │ │ │ │ │ │ ├── nd_softpromotion_slider_h.xml │ │ │ │ │ │ │ ├── nd_softpromotion_slider_item.xml │ │ │ │ │ │ │ ├── nd_softpromotion_slider_v.xml │ │ │ │ │ │ │ ├── nd_softwarepromotion.xml │ │ │ │ │ │ │ └── nd_unbind_phone_number.xml │ │ │ │ │ │ └── values/ │ │ │ │ │ │ ├── nd3_misc.xml │ │ │ │ │ │ ├── nd3_sdk_error_strings.xml │ │ │ │ │ │ ├── nd3_strings.xml │ │ │ │ │ │ ├── nd_gcsdk_colors.xml │ │ │ │ │ │ ├── nd_gcsdk_misc.xml │ │ │ │ │ │ ├── nd_gcsdk_strings.xml │ │ │ │ │ │ └── nd_gcsdk_styles.xml │ │ │ │ │ └── src/ │ │ │ │ │ └── .gitignore │ │ │ │ ├── ForManifest.xml │ │ │ │ ├── build.xml │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ └── .gitignore │ │ │ │ ├── sdk/ │ │ │ │ │ └── NdComPlatform.jar │ │ │ │ └── src/ │ │ │ │ └── org/ │ │ │ │ └── cocos2dx/ │ │ │ │ └── plugin/ │ │ │ │ ├── IAPNd91.java │ │ │ │ ├── IAPOnlineNd91.java │ │ │ │ ├── Nd91Wrapper.java │ │ │ │ ├── SocialNd91.java │ │ │ │ └── UserNd91.java │ │ │ ├── qh360/ │ │ │ │ └── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── ForAssets/ │ │ │ │ │ ├── alipay_plugin.apk │ │ │ │ │ ├── pro.jar │ │ │ │ │ └── upomp_bypay_config.xml │ │ │ │ ├── ForManifest.xml │ │ │ │ ├── ForRes/ │ │ │ │ │ ├── anim/ │ │ │ │ │ │ └── zsht_loading.xml │ │ │ │ │ ├── drawable/ │ │ │ │ │ │ ├── upomp_bypay_btn1.xml │ │ │ │ │ │ ├── upomp_bypay_btn2.xml │ │ │ │ │ │ ├── upomp_bypay_btn3.xml │ │ │ │ │ │ ├── upomp_bypay_btn4.xml │ │ │ │ │ │ ├── upomp_bypay_btn5.xml │ │ │ │ │ │ ├── upomp_bypay_btn6.xml │ │ │ │ │ │ ├── upomp_bypay_btn_card.xml │ │ │ │ │ │ ├── upomp_bypay_btn_enter1.xml │ │ │ │ │ │ ├── upomp_bypay_btn_enter2.xml │ │ │ │ │ │ ├── upomp_bypay_btn_esc1.xml │ │ │ │ │ │ ├── upomp_bypay_btn_esc2.xml │ │ │ │ │ │ ├── upomp_bypay_btn_letter.xml │ │ │ │ │ │ ├── upomp_bypay_btn_member1.xml │ │ │ │ │ │ ├── upomp_bypay_btn_member2.xml │ │ │ │ │ │ ├── upomp_bypay_btn_month.xml │ │ │ │ │ │ ├── upomp_bypay_btn_newweb.xml │ │ │ │ │ │ ├── upomp_bypay_btn_number.xml │ │ │ │ │ │ ├── upomp_bypay_btn_set.xml │ │ │ │ │ │ ├── upomp_bypay_btn_symbol.xml │ │ │ │ │ │ ├── upomp_bypay_btn_title_esc.xml │ │ │ │ │ │ ├── upomp_bypay_btn_year.xml │ │ │ │ │ │ ├── upomp_bypay_checkbox.xml │ │ │ │ │ │ ├── upomp_bypay_input_btn2.xml │ │ │ │ │ │ ├── upomp_bypay_input_btn4.xml │ │ │ │ │ │ ├── upomp_bypay_keyboard_btn_clear.xml │ │ │ │ │ │ ├── upomp_bypay_keyboard_btn_enter.xml │ │ │ │ │ │ ├── upomp_bypay_keyboard_btn_l_clear.xml │ │ │ │ │ │ ├── upomp_bypay_open_btn_enter.xml │ │ │ │ │ │ ├── upomp_bypay_progress.xml │ │ │ │ │ │ ├── upomp_bypay_progress_init.xml │ │ │ │ │ │ ├── zsht_authcode_style.xml │ │ │ │ │ │ ├── zsht_back_style.xml │ │ │ │ │ │ ├── zsht_button_style.xml │ │ │ │ │ │ └── zsht_input_style.xml │ │ │ │ │ ├── layout/ │ │ │ │ │ │ ├── upomp_bypay_about.xml │ │ │ │ │ │ ├── upomp_bypay_about_btn.xml │ │ │ │ │ │ ├── upomp_bypay_activity_dialog.xml │ │ │ │ │ │ ├── upomp_bypay_auth_bind_card.xml │ │ │ │ │ │ ├── upomp_bypay_bindcard_credit.xml │ │ │ │ │ │ ├── upomp_bypay_bindcard_debit.xml │ │ │ │ │ │ ├── upomp_bypay_bindcard_pan.xml │ │ │ │ │ │ ├── upomp_bypay_bindcard_result.xml │ │ │ │ │ │ ├── upomp_bypay_cardlist_content.xml │ │ │ │ │ │ ├── upomp_bypay_get_pass.xml │ │ │ │ │ │ ├── upomp_bypay_image_cvn2.xml │ │ │ │ │ │ ├── upomp_bypay_keyboard_dialog.xml │ │ │ │ │ │ ├── upomp_bypay_keyboard_letter.xml │ │ │ │ │ │ ├── upomp_bypay_keyboard_num.xml │ │ │ │ │ │ ├── upomp_bypay_keyboard_symbol.xml │ │ │ │ │ │ ├── upomp_bypay_onuser_cardmanage.xml │ │ │ │ │ │ ├── upomp_bypay_onuser_change_psw.xml │ │ │ │ │ │ ├── upomp_bypay_onuser_change_tel.xml │ │ │ │ │ │ ├── upomp_bypay_onuser_tel.xml │ │ │ │ │ │ ├── upomp_bypay_onuser_usermanage.xml │ │ │ │ │ │ ├── upomp_bypay_pay_main.xml │ │ │ │ │ │ ├── upomp_bypay_pay_result.xml │ │ │ │ │ │ ├── upomp_bypay_pay_result_lose.xml │ │ │ │ │ │ ├── upomp_bypay_register.xml │ │ │ │ │ │ ├── upomp_bypay_register2.xml │ │ │ │ │ │ ├── upomp_bypay_register_result.xml │ │ │ │ │ │ ├── upomp_bypay_splash.xml │ │ │ │ │ │ ├── upomp_bypay_support_card.xml │ │ │ │ │ │ ├── upomp_bypay_support_card_list.xml │ │ │ │ │ │ ├── upomp_bypay_user_credit.xml │ │ │ │ │ │ ├── upomp_bypay_user_debit.xml │ │ │ │ │ │ ├── upomp_bypay_userprotocal.xml │ │ │ │ │ │ ├── zsht_bankcard_agreement.xml │ │ │ │ │ │ ├── zsht_bankcard_pay.xml │ │ │ │ │ │ ├── zsht_griditems.xml │ │ │ │ │ │ ├── zsht_loading_process_dialog_anim.xml │ │ │ │ │ │ ├── zsht_success_page.xml │ │ │ │ │ │ └── zsht_user_message.xml │ │ │ │ │ ├── raw/ │ │ │ │ │ │ └── upomp_bypay_click.ogg │ │ │ │ │ └── values/ │ │ │ │ │ ├── upomp_strings.xml │ │ │ │ │ ├── upomp_styles.xml │ │ │ │ │ ├── zsht_strings.xml │ │ │ │ │ └── zsht_styles.xml │ │ │ │ ├── build.xml │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ └── .gitignore │ │ │ │ ├── sdk/ │ │ │ │ │ ├── 360SDK.jar │ │ │ │ │ ├── annotations.jar │ │ │ │ │ ├── upomp_bypay_lib.jar │ │ │ │ │ └── zsht_app_360game.jar │ │ │ │ └── src/ │ │ │ │ └── org/ │ │ │ │ └── cocos2dx/ │ │ │ │ └── plugin/ │ │ │ │ ├── IAPOnlineQH360.java │ │ │ │ ├── QH360Wrapper.java │ │ │ │ └── UserQH360.java │ │ │ ├── twitter/ │ │ │ │ ├── proj.android/ │ │ │ │ │ ├── .classpath │ │ │ │ │ ├── .project │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── ForManifest.xml │ │ │ │ │ ├── build.xml │ │ │ │ │ ├── project.properties │ │ │ │ │ ├── res/ │ │ │ │ │ │ └── .gitignore │ │ │ │ │ ├── sdk/ │ │ │ │ │ │ ├── signpost-commonshttp4-1.2.1.1.jar │ │ │ │ │ │ ├── signpost-core-1.2.1.1.jar │ │ │ │ │ │ ├── signpost-jetty6-1.2.1.1.jar │ │ │ │ │ │ └── twitter4j-core-android-3.0.1.jar │ │ │ │ │ └── src/ │ │ │ │ │ └── org/ │ │ │ │ │ └── cocos2dx/ │ │ │ │ │ └── plugin/ │ │ │ │ │ ├── Consts.java │ │ │ │ │ ├── ShareTwitter.java │ │ │ │ │ ├── TwitterApp.java │ │ │ │ │ ├── TwitterDialog.java │ │ │ │ │ └── TwitterSession.java │ │ │ │ └── proj.ios/ │ │ │ │ ├── FHSTwitterEngine/ │ │ │ │ │ ├── FHSTwitterEngine.h │ │ │ │ │ ├── FHSTwitterEngine.m │ │ │ │ │ └── OAuthConsumer/ │ │ │ │ │ ├── Categories/ │ │ │ │ │ │ ├── NSString+URLEncoding.h │ │ │ │ │ │ └── NSString+URLEncoding.m │ │ │ │ │ ├── Crytpo/ │ │ │ │ │ │ ├── Base64TranscoderFHS.c │ │ │ │ │ │ └── Base64TranscoderFHS.h │ │ │ │ │ ├── OAConsumer.h │ │ │ │ │ ├── OAConsumer.m │ │ │ │ │ ├── OAHMAC_SHA1SignatureProvider.h │ │ │ │ │ ├── OAHMAC_SHA1SignatureProvider.m │ │ │ │ │ ├── OAMutableURLRequest.h │ │ │ │ │ ├── OAMutableURLRequest.m │ │ │ │ │ ├── OARequestParameter.h │ │ │ │ │ ├── OARequestParameter.m │ │ │ │ │ ├── OAServiceTicket.h │ │ │ │ │ ├── OAServiceTicket.m │ │ │ │ │ ├── OAToken.h │ │ │ │ │ ├── OAToken.m │ │ │ │ │ └── OAuthConsumer.h │ │ │ │ ├── PluginTwitter.xcodeproj/ │ │ │ │ │ └── project.pbxproj │ │ │ │ ├── ShareTwitter.h │ │ │ │ └── ShareTwitter.m │ │ │ ├── uc/ │ │ │ │ └── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── ForManifest.xml │ │ │ │ ├── build.xml │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ └── .gitignore │ │ │ │ ├── sdk/ │ │ │ │ │ ├── UCGameSDK.jar │ │ │ │ │ └── alipay_plugin.jar │ │ │ │ └── src/ │ │ │ │ └── org/ │ │ │ │ └── cocos2dx/ │ │ │ │ └── plugin/ │ │ │ │ ├── IAPOnlineUC.java │ │ │ │ ├── UCWrapper.java │ │ │ │ └── UserUC.java │ │ │ ├── umeng/ │ │ │ │ ├── proj.android/ │ │ │ │ │ ├── .classpath │ │ │ │ │ ├── .project │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── ForManifest.xml │ │ │ │ │ ├── build.xml │ │ │ │ │ ├── project.properties │ │ │ │ │ ├── res/ │ │ │ │ │ │ └── .gitignore │ │ │ │ │ ├── sdk/ │ │ │ │ │ │ └── umeng_sdk.jar │ │ │ │ │ └── src/ │ │ │ │ │ └── org/ │ │ │ │ │ └── cocos2dx/ │ │ │ │ │ └── plugin/ │ │ │ │ │ └── AnalyticsUmeng.java │ │ │ │ └── proj.ios/ │ │ │ │ ├── AnalyticsUmeng.h │ │ │ │ ├── AnalyticsUmeng.m │ │ │ │ ├── MobClick.h │ │ │ │ ├── PluginUmeng.xcodeproj/ │ │ │ │ │ └── project.pbxproj │ │ │ │ └── libMobClickLibrary.a │ │ │ └── weibo/ │ │ │ ├── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── ForManifest.xml │ │ │ │ ├── build.xml │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ └── .gitignore │ │ │ │ ├── sdk/ │ │ │ │ │ └── weibosdk.jar │ │ │ │ └── src/ │ │ │ │ └── org/ │ │ │ │ └── cocos2dx/ │ │ │ │ └── plugin/ │ │ │ │ ├── AccessTokenKeeper.java │ │ │ │ └── ShareWeibo.java │ │ │ └── proj.ios/ │ │ │ ├── JSONKit/ │ │ │ │ ├── JSONKit.h │ │ │ │ └── JSONKit.m │ │ │ ├── PluginWeibo.xcodeproj/ │ │ │ │ └── project.pbxproj │ │ │ ├── ShareWeibo.h │ │ │ ├── ShareWeibo.m │ │ │ └── SinaWeibo/ │ │ │ ├── SinaWeibo.h │ │ │ ├── SinaWeibo.m │ │ │ ├── SinaWeiboAuthorizeView.h │ │ │ ├── SinaWeiboAuthorizeView.m │ │ │ ├── SinaWeiboConstants.h │ │ │ ├── SinaWeiboRequest.h │ │ │ └── SinaWeiboRequest.m │ │ ├── protocols/ │ │ │ ├── PluginManager.cpp │ │ │ ├── PluginParam.cpp │ │ │ ├── include/ │ │ │ │ ├── PluginFactory.h │ │ │ │ ├── PluginManager.h │ │ │ │ ├── PluginParam.h │ │ │ │ ├── PluginProtocol.h │ │ │ │ ├── ProtocolAds.h │ │ │ │ ├── ProtocolAnalytics.h │ │ │ │ ├── ProtocolIAP.h │ │ │ │ ├── ProtocolShare.h │ │ │ │ ├── ProtocolSocial.h │ │ │ │ └── ProtocolUser.h │ │ │ ├── jsb_protocols.ini │ │ │ ├── platform/ │ │ │ │ ├── android/ │ │ │ │ │ ├── PluginFactory.cpp │ │ │ │ │ ├── PluginJavaData.h │ │ │ │ │ ├── PluginJniHelper.cpp │ │ │ │ │ ├── PluginJniHelper.h │ │ │ │ │ ├── PluginJniMacros.h │ │ │ │ │ ├── PluginProtocol.cpp │ │ │ │ │ ├── PluginUtils.cpp │ │ │ │ │ ├── PluginUtils.h │ │ │ │ │ ├── ProtocolAds.cpp │ │ │ │ │ ├── ProtocolAnalytics.cpp │ │ │ │ │ ├── ProtocolIAP.cpp │ │ │ │ │ ├── ProtocolShare.cpp │ │ │ │ │ ├── ProtocolSocial.cpp │ │ │ │ │ └── ProtocolUser.cpp │ │ │ │ └── ios/ │ │ │ │ ├── AdsWrapper.h │ │ │ │ ├── AdsWrapper.mm │ │ │ │ ├── InterfaceAds.h │ │ │ │ ├── InterfaceAnalytics.h │ │ │ │ ├── InterfaceIAP.h │ │ │ │ ├── InterfaceShare.h │ │ │ │ ├── InterfaceSocial.h │ │ │ │ ├── InterfaceUser.h │ │ │ │ ├── PluginFactory.mm │ │ │ │ ├── PluginOCMacros.h │ │ │ │ ├── PluginProtocol.mm │ │ │ │ ├── PluginUtilsIOS.h │ │ │ │ ├── PluginUtilsIOS.mm │ │ │ │ ├── ProtocolAds.mm │ │ │ │ ├── ProtocolAnalytics.mm │ │ │ │ ├── ProtocolIAP.mm │ │ │ │ ├── ProtocolShare.mm │ │ │ │ ├── ProtocolSocial.mm │ │ │ │ ├── ProtocolUser.mm │ │ │ │ ├── ShareWrapper.h │ │ │ │ ├── ShareWrapper.mm │ │ │ │ ├── SocialWrapper.h │ │ │ │ ├── SocialWrapper.mm │ │ │ │ ├── UserWrapper.h │ │ │ │ └── UserWrapper.mm │ │ │ ├── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── build.xml │ │ │ │ ├── build_native.sh │ │ │ │ ├── jni/ │ │ │ │ │ ├── Android.mk │ │ │ │ │ └── Application.mk │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ └── .gitignore │ │ │ │ └── src/ │ │ │ │ └── org/ │ │ │ │ └── cocos2dx/ │ │ │ │ └── plugin/ │ │ │ │ ├── AdsWrapper.java │ │ │ │ ├── IAPWrapper.java │ │ │ │ ├── InterfaceAds.java │ │ │ │ ├── InterfaceAnalytics.java │ │ │ │ ├── InterfaceIAP.java │ │ │ │ ├── InterfaceShare.java │ │ │ │ ├── InterfaceSocial.java │ │ │ │ ├── InterfaceUser.java │ │ │ │ ├── PluginWrapper.java │ │ │ │ ├── ShareWrapper.java │ │ │ │ ├── SocialWrapper.java │ │ │ │ └── UserWrapper.java │ │ │ └── proj.ios/ │ │ │ └── PluginProtocol.xcodeproj/ │ │ │ └── project.pbxproj │ │ ├── samples/ │ │ │ ├── HelloAnalytics-JS/ │ │ │ │ ├── Classes/ │ │ │ │ │ ├── AppDelegate.cpp │ │ │ │ │ └── AppDelegate.h │ │ │ │ ├── Resources/ │ │ │ │ │ ├── main.js │ │ │ │ │ └── src/ │ │ │ │ │ ├── myApp.js │ │ │ │ │ └── resource.js │ │ │ │ └── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── ant.properties │ │ │ │ ├── build.xml │ │ │ │ ├── jni/ │ │ │ │ │ ├── Android.mk │ │ │ │ │ ├── Application.mk │ │ │ │ │ └── hellocpp/ │ │ │ │ │ └── main.cpp │ │ │ │ ├── ndkgdb.sh │ │ │ │ ├── proguard-project.txt │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ └── values/ │ │ │ │ │ └── strings.xml │ │ │ │ └── src/ │ │ │ │ └── nojava.txt │ │ │ ├── HelloIAP-JS/ │ │ │ │ ├── Classes/ │ │ │ │ │ ├── AppDelegate.cpp │ │ │ │ │ └── AppDelegate.h │ │ │ │ ├── Resources/ │ │ │ │ │ ├── alipay_plugin.apk │ │ │ │ │ ├── main.js │ │ │ │ │ └── src/ │ │ │ │ │ ├── myApp.js │ │ │ │ │ └── resource.js │ │ │ │ └── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── ant.properties │ │ │ │ ├── build.xml │ │ │ │ ├── jni/ │ │ │ │ │ ├── Android.mk │ │ │ │ │ ├── Application.mk │ │ │ │ │ └── hellocpp/ │ │ │ │ │ └── main.cpp │ │ │ │ ├── proguard-project.txt │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ ├── raw/ │ │ │ │ │ │ └── opening_sound.mid │ │ │ │ │ └── values/ │ │ │ │ │ ├── g_strings.xml │ │ │ │ │ └── strings.xml │ │ │ │ └── src/ │ │ │ │ └── nojava.txt │ │ │ └── HelloPlugins/ │ │ │ ├── Classes/ │ │ │ │ ├── AppDelegate.cpp │ │ │ │ ├── AppDelegate.h │ │ │ │ ├── AppMacros.h │ │ │ │ ├── Configs.h │ │ │ │ ├── HelloWorldScene.cpp │ │ │ │ ├── HelloWorldScene.h │ │ │ │ ├── TestAds/ │ │ │ │ │ ├── TestAdsScene.cpp │ │ │ │ │ └── TestAdsScene.h │ │ │ │ ├── TestAnalytics/ │ │ │ │ │ ├── TestAnalyticsScene.cpp │ │ │ │ │ └── TestAnalyticsScene.h │ │ │ │ ├── TestIAP/ │ │ │ │ │ ├── MyPurchase.cpp │ │ │ │ │ ├── MyPurchase.h │ │ │ │ │ ├── TestIAPScene.cpp │ │ │ │ │ └── TestIAPScene.h │ │ │ │ ├── TestIAPOnline/ │ │ │ │ │ ├── MyIAPOLManager.cpp │ │ │ │ │ ├── MyIAPOLManager.h │ │ │ │ │ ├── TestIAPOnlineScene.cpp │ │ │ │ │ └── TestIAPOnlineScene.h │ │ │ │ ├── TestShare/ │ │ │ │ │ ├── MyShareManager.cpp │ │ │ │ │ ├── MyShareManager.h │ │ │ │ │ ├── TestShareScene.cpp │ │ │ │ │ └── TestShareScene.h │ │ │ │ ├── TestSocial/ │ │ │ │ │ ├── MySocialManager.cpp │ │ │ │ │ ├── MySocialManager.h │ │ │ │ │ ├── TestSocialScene.cpp │ │ │ │ │ └── TestSocialScene.h │ │ │ │ └── TestUser/ │ │ │ │ ├── MyUserManager.cpp │ │ │ │ ├── MyUserManager.h │ │ │ │ ├── TestUserScene.cpp │ │ │ │ └── TestUserScene.h │ │ │ ├── proj.android/ │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── README.md │ │ │ │ ├── ant.properties │ │ │ │ ├── build.xml │ │ │ │ ├── jni/ │ │ │ │ │ ├── Android.mk │ │ │ │ │ ├── Application.mk │ │ │ │ │ └── hellocpp/ │ │ │ │ │ └── main.cpp │ │ │ │ ├── proguard-project.txt │ │ │ │ ├── project.properties │ │ │ │ ├── res/ │ │ │ │ │ └── values/ │ │ │ │ │ └── strings.xml │ │ │ │ └── src/ │ │ │ │ └── nojava.txt │ │ │ └── proj.ios/ │ │ │ ├── AppController.h │ │ │ ├── AppController.mm │ │ │ ├── HelloPlugins.xcodeproj/ │ │ │ │ └── project.pbxproj │ │ │ ├── Info.plist │ │ │ ├── RootViewController.h │ │ │ ├── RootViewController.mm │ │ │ └── main.m │ │ └── tools/ │ │ ├── android/ │ │ │ └── build_common.xml │ │ ├── android-build.py │ │ ├── config.sh │ │ ├── gameDevGuide.sh │ │ ├── publish.sh │ │ ├── tojs/ │ │ │ ├── .gitignore │ │ │ ├── conversions.yaml │ │ │ ├── genbindings-all.sh │ │ │ ├── genbindings.sh │ │ │ └── modify_include.sed │ │ ├── toolsForGame/ │ │ │ ├── addPluginForGame.sh │ │ │ ├── main.py │ │ │ ├── modifyAppMK.sh │ │ │ ├── modifyClassPath.py │ │ │ ├── modifyMK.sh │ │ │ ├── modifyManifest.py │ │ │ ├── modifyProject.py │ │ │ ├── modifyRes.sh │ │ │ └── steps.py │ │ └── toolsForPublish/ │ │ ├── checkEnvironment.sh │ │ ├── genPrebuildMK.sh │ │ └── publishPlugin.sh │ └── tools/ │ ├── __init__.py │ ├── android-emulator-README.md │ ├── android-mk-generator/ │ │ ├── android_mk_generator.py │ │ └── config.py │ ├── bindings-generator/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── backup/ │ │ │ └── clang-llvm-3.3-pybinding/ │ │ │ ├── __init__.py │ │ │ ├── cindex.py │ │ │ └── enumerations.py │ │ ├── clang/ │ │ │ ├── __init__.py │ │ │ ├── cindex.py │ │ │ └── enumerations.py │ │ ├── generator │ │ ├── generator.py │ │ ├── libclang/ │ │ │ └── VERSION.txt │ │ ├── targets/ │ │ │ ├── lua/ │ │ │ │ ├── conversions.yaml │ │ │ │ └── templates/ │ │ │ │ ├── apidoc_classfoot.js │ │ │ │ ├── apidoc_classhead.js │ │ │ │ ├── apidoc_function.js │ │ │ │ ├── apidoc_ns.js │ │ │ │ ├── function.h │ │ │ │ ├── ifunction.c │ │ │ │ ├── ifunction_overloaded.c │ │ │ │ ├── lambda.c │ │ │ │ ├── layout_foot.c │ │ │ │ ├── layout_foot.h │ │ │ │ ├── layout_head.c │ │ │ │ ├── layout_head.h │ │ │ │ ├── prelude.c │ │ │ │ ├── prelude.h │ │ │ │ ├── register.c │ │ │ │ ├── sfunction.c │ │ │ │ └── sfunction_overloaded.c │ │ │ └── spidermonkey/ │ │ │ ├── common/ │ │ │ │ ├── Android.mk.example │ │ │ │ ├── Debugger.md │ │ │ │ ├── ScriptingCore.cpp.example │ │ │ │ ├── ScriptingCore.h.example │ │ │ │ ├── debugger.js.example │ │ │ │ ├── helper.js.example │ │ │ │ ├── js_bindings_config.h.example │ │ │ │ ├── js_manual_conversions.cpp.example │ │ │ │ ├── js_manual_conversions.h.example │ │ │ │ ├── sample.js │ │ │ │ ├── spidermonkey_specifics.h.example │ │ │ │ └── uthash.h │ │ │ ├── conversions.yaml │ │ │ └── templates/ │ │ │ ├── apidoc_classfoot.js │ │ │ ├── apidoc_classhead.js │ │ │ ├── apidoc_function.js │ │ │ ├── apidoc_ns.js │ │ │ ├── function.h │ │ │ ├── ifunction.c │ │ │ ├── ifunction_overloaded.c │ │ │ ├── lambda.c │ │ │ ├── layout_foot.c │ │ │ ├── layout_foot.h │ │ │ ├── layout_head.c │ │ │ ├── layout_head.h │ │ │ ├── prelude.c │ │ │ ├── prelude.h │ │ │ ├── register.c │ │ │ ├── sfunction.c │ │ │ └── sfunction_overloaded.c │ │ └── test/ │ │ ├── simple_test/ │ │ │ ├── simple_class.cpp │ │ │ └── simple_class.h │ │ ├── test.bat │ │ ├── test.ini │ │ ├── test.sh │ │ ├── user.cfg.sample │ │ └── userconf.ini.sample │ ├── closure-compiler/ │ │ ├── compiler.jar │ │ ├── obfuscate.py │ │ └── template.xml │ ├── cocos2d-console/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── console/ │ │ │ ├── cocos2d.ini │ │ │ ├── cocos2d.py │ │ │ ├── cocos2d_jscompile.py │ │ │ ├── cocos2d_new.py │ │ │ └── cocos2d_version.py │ │ └── src/ │ │ └── jsbcc_source/ │ │ ├── README │ │ ├── jsbcc-vc2012.sln │ │ ├── jsbcc-vc2012.vcxproj │ │ ├── jsbcc-vc2012.vcxproj.filters │ │ ├── jsbcc.xcodeproj/ │ │ │ └── project.pbxproj │ │ ├── spidermonkey-ios/ │ │ │ ├── include/ │ │ │ │ ├── js/ │ │ │ │ │ ├── Anchor.h │ │ │ │ │ ├── CallArgs.h │ │ │ │ │ ├── CharacterEncoding.h │ │ │ │ │ ├── Date.h │ │ │ │ │ ├── GCAPI.h │ │ │ │ │ ├── HashTable.h │ │ │ │ │ ├── HeapAPI.h │ │ │ │ │ ├── LegacyIntTypes.h │ │ │ │ │ ├── MemoryMetrics.h │ │ │ │ │ ├── PropertyKey.h │ │ │ │ │ ├── RequiredDefines.h │ │ │ │ │ ├── RootingAPI.h │ │ │ │ │ ├── Utility.h │ │ │ │ │ ├── Value.h │ │ │ │ │ └── Vector.h │ │ │ │ ├── js-config.h │ │ │ │ ├── js.msg │ │ │ │ ├── jsalloc.h │ │ │ │ ├── jsapi.h │ │ │ │ ├── jsclass.h │ │ │ │ ├── jsclist.h │ │ │ │ ├── jscpucfg.h │ │ │ │ ├── jsdbgapi.h │ │ │ │ ├── jsfriendapi.h │ │ │ │ ├── jslock.h │ │ │ │ ├── jsperf.h │ │ │ │ ├── jsprf.h │ │ │ │ ├── jsprototypes.h │ │ │ │ ├── jsproxy.h │ │ │ │ ├── jsprvtd.h │ │ │ │ ├── jspubtd.h │ │ │ │ ├── jstypes.h │ │ │ │ ├── jsutil.h │ │ │ │ ├── jsversion.h │ │ │ │ ├── jswrapper.h │ │ │ │ └── mozilla/ │ │ │ │ ├── AllocPolicy.h │ │ │ │ ├── Array.h │ │ │ │ ├── Assertions.h │ │ │ │ ├── Atomics.h │ │ │ │ ├── Attributes.h │ │ │ │ ├── BloomFilter.h │ │ │ │ ├── Casting.h │ │ │ │ ├── Char16.h │ │ │ │ ├── CheckedInt.h │ │ │ │ ├── Compiler.h │ │ │ │ ├── Constants.h │ │ │ │ ├── DebugOnly.h │ │ │ │ ├── Decimal.h │ │ │ │ ├── Endian.h │ │ │ │ ├── EnumSet.h │ │ │ │ ├── FloatingPoint.h │ │ │ │ ├── GuardObjects.h │ │ │ │ ├── HashFunctions.h │ │ │ │ ├── Likely.h │ │ │ │ ├── LinkedList.h │ │ │ │ ├── MathAlgorithms.h │ │ │ │ ├── MemoryChecking.h │ │ │ │ ├── MemoryReporting.h │ │ │ │ ├── Move.h │ │ │ │ ├── NullPtr.h │ │ │ │ ├── PodOperations.h │ │ │ │ ├── Poison.h │ │ │ │ ├── Range.h │ │ │ │ ├── RangedPtr.h │ │ │ │ ├── ReentrancyGuard.h │ │ │ │ ├── RefPtr.h │ │ │ │ ├── SHA1.h │ │ │ │ ├── Scoped.h │ │ │ │ ├── SplayTree.h │ │ │ │ ├── TemplateLib.h │ │ │ │ ├── ThreadLocal.h │ │ │ │ ├── TypeTraits.h │ │ │ │ ├── TypedEnum.h │ │ │ │ ├── Types.h │ │ │ │ ├── Util.h │ │ │ │ ├── Vector.h │ │ │ │ └── WeakPtr.h │ │ │ └── lib/ │ │ │ └── libjs_static.a │ │ ├── spidermonkey-win32/ │ │ │ ├── include/ │ │ │ │ ├── js/ │ │ │ │ │ ├── Anchor.h │ │ │ │ │ ├── CallArgs.h │ │ │ │ │ ├── CharacterEncoding.h │ │ │ │ │ ├── Date.h │ │ │ │ │ ├── GCAPI.h │ │ │ │ │ ├── HashTable.h │ │ │ │ │ ├── HeapAPI.h │ │ │ │ │ ├── LegacyIntTypes.h │ │ │ │ │ ├── MemoryMetrics.h │ │ │ │ │ ├── PropertyKey.h │ │ │ │ │ ├── RequiredDefines.h │ │ │ │ │ ├── RootingAPI.h │ │ │ │ │ ├── Utility.h │ │ │ │ │ ├── Value.h │ │ │ │ │ └── Vector.h │ │ │ │ ├── js-config.h │ │ │ │ ├── js.msg │ │ │ │ ├── jsalloc.h │ │ │ │ ├── jsapi.h │ │ │ │ ├── jsclass.h │ │ │ │ ├── jsclist.h │ │ │ │ ├── jscpucfg.h │ │ │ │ ├── jsdbgapi.h │ │ │ │ ├── jsfriendapi.h │ │ │ │ ├── jslock.h │ │ │ │ ├── jsperf.h │ │ │ │ ├── jsprf.h │ │ │ │ ├── jsprototypes.h │ │ │ │ ├── jsproxy.h │ │ │ │ ├── jsprvtd.h │ │ │ │ ├── jspubtd.h │ │ │ │ ├── jstypes.h │ │ │ │ ├── jsutil.h │ │ │ │ ├── jsversion.h │ │ │ │ ├── jswrapper.h │ │ │ │ └── mozilla/ │ │ │ │ ├── AllocPolicy.h │ │ │ │ ├── Array.h │ │ │ │ ├── Assertions.h │ │ │ │ ├── Atomics.h │ │ │ │ ├── Attributes.h │ │ │ │ ├── BloomFilter.h │ │ │ │ ├── Casting.h │ │ │ │ ├── Char16.h │ │ │ │ ├── CheckedInt.h │ │ │ │ ├── Compiler.h │ │ │ │ ├── Constants.h │ │ │ │ ├── DebugOnly.h │ │ │ │ ├── Decimal.h │ │ │ │ ├── Endian.h │ │ │ │ ├── EnumSet.h │ │ │ │ ├── FloatingPoint.h │ │ │ │ ├── GuardObjects.h │ │ │ │ ├── HashFunctions.h │ │ │ │ ├── Likely.h │ │ │ │ ├── LinkedList.h │ │ │ │ ├── MathAlgorithms.h │ │ │ │ ├── MemoryChecking.h │ │ │ │ ├── MemoryReporting.h │ │ │ │ ├── Move.h │ │ │ │ ├── NullPtr.h │ │ │ │ ├── PodOperations.h │ │ │ │ ├── Poison.h │ │ │ │ ├── Range.h │ │ │ │ ├── RangedPtr.h │ │ │ │ ├── ReentrancyGuard.h │ │ │ │ ├── RefPtr.h │ │ │ │ ├── SHA1.h │ │ │ │ ├── Scoped.h │ │ │ │ ├── SplayTree.h │ │ │ │ ├── TemplateLib.h │ │ │ │ ├── ThreadLocal.h │ │ │ │ ├── TypeTraits.h │ │ │ │ ├── TypedEnum.h │ │ │ │ ├── Types.h │ │ │ │ ├── Util.h │ │ │ │ ├── Vector.h │ │ │ │ └── WeakPtr.h │ │ │ └── lib/ │ │ │ └── mozjs-25.0.lib │ │ └── src/ │ │ └── main.cpp │ ├── cpp-best-practise-formatter/ │ │ ├── cpp-best-practise-formatter.py │ │ └── test/ │ │ ├── CCDirector.h │ │ └── dir_skip/ │ │ └── test.h │ ├── jenkins-scripts/ │ │ ├── create-job.py │ │ ├── gen_jsb.sh │ │ ├── job-trigger.py │ │ └── pull-request-builder.py │ ├── localvartoauto/ │ │ └── LocalVarToAuto.py │ ├── make-package/ │ │ ├── Makefile │ │ ├── README.markdown │ │ └── git-archive-all │ ├── project-creator/ │ │ ├── README.md │ │ ├── config-create/ │ │ │ ├── config.gitingore │ │ │ └── create_config.py │ │ ├── create_project.py │ │ └── module/ │ │ ├── __init__.py │ │ ├── android.json │ │ ├── cocos_files.json │ │ ├── core.py │ │ ├── ios_mac.json │ │ ├── linux.json │ │ ├── ui.py │ │ └── win32.json │ ├── pylib/ │ │ ├── PathUtils.py │ │ └── __init__.py │ ├── tojs/ │ │ ├── README.mdown │ │ ├── cocos2dx.ini │ │ ├── cocos2dx_builder.ini │ │ ├── cocos2dx_extension.ini │ │ ├── cocos2dx_gui.ini │ │ ├── cocos2dx_spine.ini │ │ ├── cocos2dx_studio.ini │ │ ├── genbindings-win32.bat │ │ └── genbindings.sh │ ├── tolua/ │ │ ├── README.mdown │ │ ├── cocos2dx.ini │ │ ├── cocos2dx_extension.ini │ │ ├── cocos2dx_gui.ini │ │ ├── cocos2dx_physics.ini │ │ ├── cocos2dx_spine.ini │ │ ├── cocos2dx_studio.ini │ │ ├── genbindings-win32.bat │ │ └── genbindings.sh │ └── travis-scripts/ │ ├── before-install.sh │ ├── generate-jsbindings.sh │ ├── install_glfw.sh │ ├── run-script.sh │ └── travis_mac.yml ├── proj.android/ │ ├── .classpath │ ├── .project │ ├── AndroidManifest.xml │ ├── ant.properties │ ├── build.xml │ ├── build_native.py │ ├── google-play-services_lib/ │ │ ├── .classpath │ │ ├── .project │ │ ├── .settings/ │ │ │ └── org.eclipse.jdt.core.prefs │ │ ├── AndroidManifest.xml │ │ ├── README.txt │ │ ├── build.xml │ │ ├── libs/ │ │ │ ├── google-play-services.jar │ │ │ └── google-play-services.jar.properties │ │ ├── local.properties │ │ ├── proguard-project.txt │ │ ├── proguard.txt │ │ ├── project.properties │ │ ├── res/ │ │ │ ├── color/ │ │ │ │ ├── common_signin_btn_text_dark.xml │ │ │ │ └── common_signin_btn_text_light.xml │ │ │ ├── drawable/ │ │ │ │ ├── common_signin_btn_icon_dark.xml │ │ │ │ ├── common_signin_btn_icon_light.xml │ │ │ │ ├── common_signin_btn_text_dark.xml │ │ │ │ └── common_signin_btn_text_light.xml │ │ │ ├── values/ │ │ │ │ ├── ads_attrs.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── maps_attrs.xml │ │ │ │ ├── strings.xml │ │ │ │ └── version.xml │ │ │ ├── values-af/ │ │ │ │ └── strings.xml │ │ │ ├── values-am/ │ │ │ │ └── strings.xml │ │ │ ├── values-ar/ │ │ │ │ └── strings.xml │ │ │ ├── values-bg/ │ │ │ │ └── strings.xml │ │ │ ├── values-ca/ │ │ │ │ └── strings.xml │ │ │ ├── values-cs/ │ │ │ │ └── strings.xml │ │ │ ├── values-da/ │ │ │ │ └── strings.xml │ │ │ ├── values-de/ │ │ │ │ └── strings.xml │ │ │ ├── values-el/ │ │ │ │ └── strings.xml │ │ │ ├── values-en-rGB/ │ │ │ │ └── strings.xml │ │ │ ├── values-en-rIN/ │ │ │ │ └── strings.xml │ │ │ ├── values-es/ │ │ │ │ └── strings.xml │ │ │ ├── values-es-rUS/ │ │ │ │ └── strings.xml │ │ │ ├── values-et-rEE/ │ │ │ │ └── strings.xml │ │ │ ├── values-fa/ │ │ │ │ └── strings.xml │ │ │ ├── values-fi/ │ │ │ │ └── strings.xml │ │ │ ├── values-fr/ │ │ │ │ └── strings.xml │ │ │ ├── values-fr-rCA/ │ │ │ │ └── strings.xml │ │ │ ├── values-hi/ │ │ │ │ └── strings.xml │ │ │ ├── values-hr/ │ │ │ │ └── strings.xml │ │ │ ├── values-hu/ │ │ │ │ └── strings.xml │ │ │ ├── values-hy-rAM/ │ │ │ │ └── strings.xml │ │ │ ├── values-in/ │ │ │ │ └── strings.xml │ │ │ ├── values-it/ │ │ │ │ └── strings.xml │ │ │ ├── values-iw/ │ │ │ │ └── strings.xml │ │ │ ├── values-ja/ │ │ │ │ └── strings.xml │ │ │ ├── values-ka-rGE/ │ │ │ │ └── strings.xml │ │ │ ├── values-km-rKH/ │ │ │ │ └── strings.xml │ │ │ ├── values-ko/ │ │ │ │ └── strings.xml │ │ │ ├── values-lo-rLA/ │ │ │ │ └── strings.xml │ │ │ ├── values-lt/ │ │ │ │ └── strings.xml │ │ │ ├── values-lv/ │ │ │ │ └── strings.xml │ │ │ ├── values-mn-rMN/ │ │ │ │ └── strings.xml │ │ │ ├── values-ms-rMY/ │ │ │ │ └── strings.xml │ │ │ ├── values-nb/ │ │ │ │ └── strings.xml │ │ │ ├── values-nl/ │ │ │ │ └── strings.xml │ │ │ ├── values-pl/ │ │ │ │ └── strings.xml │ │ │ ├── values-pt/ │ │ │ │ └── strings.xml │ │ │ ├── values-pt-rBR/ │ │ │ │ └── strings.xml │ │ │ ├── values-pt-rPT/ │ │ │ │ └── strings.xml │ │ │ ├── values-ro/ │ │ │ │ └── strings.xml │ │ │ ├── values-ru/ │ │ │ │ └── strings.xml │ │ │ ├── values-sk/ │ │ │ │ └── strings.xml │ │ │ ├── values-sl/ │ │ │ │ └── strings.xml │ │ │ ├── values-sr/ │ │ │ │ └── strings.xml │ │ │ ├── values-sv/ │ │ │ │ └── strings.xml │ │ │ ├── values-sw/ │ │ │ │ └── strings.xml │ │ │ ├── values-th/ │ │ │ │ └── strings.xml │ │ │ ├── values-tl/ │ │ │ │ └── strings.xml │ │ │ ├── values-tr/ │ │ │ │ └── strings.xml │ │ │ ├── values-uk/ │ │ │ │ └── strings.xml │ │ │ ├── values-vi/ │ │ │ │ └── strings.xml │ │ │ ├── values-zh-rCN/ │ │ │ │ └── strings.xml │ │ │ ├── values-zh-rHK/ │ │ │ │ └── strings.xml │ │ │ ├── values-zh-rTW/ │ │ │ │ └── strings.xml │ │ │ └── values-zu/ │ │ │ └── strings.xml │ │ └── src/ │ │ └── android/ │ │ └── UnusedStub.java │ ├── jni/ │ │ ├── Android.mk │ │ ├── Application.mk │ │ └── hellolua/ │ │ └── main.cpp │ ├── local.properties │ ├── proguard-project.txt │ ├── project.properties │ ├── res/ │ │ ├── layout/ │ │ │ └── main.xml │ │ └── values/ │ │ ├── attrs.xml │ │ └── strings.xml │ └── src/ │ └── org/ │ └── cocos2dx/ │ └── lua/ │ └── Cocos2dxActivity.java ├── proj.ios_mac/ │ ├── FlappyBird.xcodeproj/ │ │ └── project.pbxproj │ ├── ios/ │ │ ├── AppController.h │ │ ├── AppController.mm │ │ ├── Info.plist │ │ ├── RootViewController.h │ │ ├── RootViewController.mm │ │ └── main.m │ └── mac/ │ ├── Icon.icns │ ├── Info.plist │ └── main.cpp ├── proj.linux/ │ └── main.cpp └── proj.win32/ ├── FlappyBird.sln ├── FlappyBird.vcxproj ├── FlappyBird.vcxproj.filters ├── game.rc ├── main.cpp ├── main.h └── resource.h ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ proj.win32/Debug.win32/ proj.win32/FlappyBird.opensdf proj.win32/FlappyBird.sdf proj.android/assets/ proj.android/bin/ proj.android/obj/ proj.android/gen/ proj.android/libs/ proj.android/.settings/ proj.android/google-play-services_lib/bin/ proj.android/google-play-services_lib/gen/ ================================================ FILE: CMakeLists.txt ================================================ cmake_minimum_required(VERSION 2.6) set(APP_NAME FlappyBird) project (${APP_NAME}) include(cocos2d/build/BuildHelpers.CMakeLists.txt) option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) option(DEBUG_MODE "Debug or release?" ON) if(DEBUG_MODE) set(CMAKE_BUILD_TYPE DEBUG) else(DEBUG_MODE) set(CMAKE_BUILD_TYPE RELEASE) endif(DEBUG_MODE) set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99") set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") if(USE_CHIPMUNK) message("Using chipmunk ...") add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1) elseif(USE_BOX2D) message("Using box2d ...") add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1) else(USE_CHIPMUNK) message(FATAL_ERROR "Must choose a physics library.") endif(USE_CHIPMUNK) # architecture if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) set(ARCH_DIR "64-bit") else() set(ARCH_DIR "32-bit") endif() set(GAME_SRC proj.linux/main.cpp Classes/AppDelegate.cpp ) set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d) include_directories( /usr/local/include/GLFW Classes ${COCOS2D_ROOT}/cocos/scripting/lua/bindings ${COCOS2D_ROOT}/external/lua/lua ${COCOS2D_ROOT}/external/lua/tolua ${COCOS2D_ROOT} ${COCOS2D_ROOT}/cocos ${COCOS2D_ROOT}/cocos/audio/include ${COCOS2D_ROOT}/cocos/2d ${COCOS2D_ROOT}/cocos/2d/renderer ${COCOS2D_ROOT}/cocos/2d/platform ${COCOS2D_ROOT}/cocos/2d/platform/desktop ${COCOS2D_ROOT}/cocos/2d/platform/linux ${COCOS2D_ROOT}/cocos/base ${COCOS2D_ROOT}/cocos/physics ${COCOS2D_ROOT}/cocos/editor-support ${COCOS2D_ROOT}/cocos/math/kazmath/include ${COCOS2D_ROOT}/extensions ${COCOS2D_ROOT}/external ${COCOS2D_ROOT}/external/edtaa3func ${COCOS2D_ROOT}/external/jpeg/include/linux ${COCOS2D_ROOT}/external/tiff/include/linux ${COCOS2D_ROOT}/external/webp/include/linux ${COCOS2D_ROOT}/external/tinyxml2 ${COCOS2D_ROOT}/external/unzip ${COCOS2D_ROOT}/external/chipmunk/include/chipmunk ${COCOS2D_ROOT}/external/freetype2/include/linux ${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR} ) link_directories( /usr/local/lib ${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR} ${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR} ${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR} ${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR} ${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} ) # kazmath add_subdirectory(${COCOS2D_ROOT}/cocos/math/kazmath) # chipmunk library add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src) # box2d library add_subdirectory(${COCOS2D_ROOT}/external/Box2D) # unzip library add_subdirectory(${COCOS2D_ROOT}/external/unzip) # tinyxml2 library add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2) # audio add_subdirectory(${COCOS2D_ROOT}/cocos/audio) # cocos base library add_subdirectory(${COCOS2D_ROOT}/cocos/base) # cocos 2d library add_subdirectory(${COCOS2D_ROOT}/cocos/2d) # gui add_subdirectory(${COCOS2D_ROOT}/cocos/gui) # network add_subdirectory(${COCOS2D_ROOT}/cocos/network) # extensions add_subdirectory(${COCOS2D_ROOT}/extensions) ## Editor Support # spine add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/spine) # cocosbuilder add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocosbuilder) # cocostudio add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocostudio) ## Scripting # lua add_subdirectory(${COCOS2D_ROOT}/external/lua/lua) # tolua add_subdirectory(${COCOS2D_ROOT}/external/lua/tolua) # luabinding add_subdirectory(${COCOS2D_ROOT}/cocos/scripting) # add the executable add_executable(${APP_NAME} ${GAME_SRC} ) if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) set(FMOD_LIB "fmodex64") else() set(FMOD_LIB "fmodex") endif() target_link_libraries(${APP_NAME} luabinding gui network spine cocostudio cocosbuilder extensions audio cocos2d ) set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin") set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") pre_build(${APP_NAME} COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua/script ${APP_BIN_DIR}/Resources ) ================================================ FILE: Classes/AdmobHelper.cpp ================================================ #include #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #include "AdmobHelper.h" #include "platform/android/jni/JniHelper.h" #include #include const char* NativeActivityClassName = "org/cocos2dx/lua/Cocos2dxActivity"; void AdmobHelper::showAds(){ cocos2d::JniMethodInfo t; if (cocos2d::JniHelper::getStaticMethodInfo(t , NativeActivityClassName , "showAdPopup" , "()V")) { t.env->CallStaticVoidMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); } } #endif ================================================ FILE: Classes/AdmobHelper.h ================================================ #ifndef __Admob_Helper_H_ #define __Admob_Helper_H_ class AdmobHelper { public: static void showAds(); }; #endif //__INTERFACE_FACEBOOK_H_ ================================================ FILE: Classes/AppDelegate.cpp ================================================ #include "AppDelegate.h" #include "CCLuaEngine.h" #include "SimpleAudioEngine.h" #include "LuaInterface/lua_tinker.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "AdmobHelper.h" void showAds() { AdmobHelper::showAds(); } #endif using namespace CocosDenshion; USING_NS_CC; AppDelegate::AppDelegate() { } AppDelegate::~AppDelegate() { SimpleAudioEngine::end(); } bool AppDelegate::applicationDidFinishLaunching() { // initialize director auto director = Director::getInstance(); director->setOpenGLView(EGLView::getInstance()); EGLView::getInstance()->setDesignResolutionSize(288, 512, ResolutionPolicy::EXACT_FIT); // turn on display FPS director->setDisplayStats(false); // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); // register lua engine auto engine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); //The call was commented because it will lead to ZeroBrane Studio can't find correct context when debugging //engine->executeScriptFile("hello.lua"); engine->executeString("require 'main.lua'"); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) //AdmobHelper::showAds(); //bind func to lua lua_State * L = LuaEngine::getInstance()->getLuaStack()->getLuaState(); lua_tinker::def(L, "showAds", showAds); #endif 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::getInstance()->stopAnimation(); SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { Director::getInstance()->startAnimation(); SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); } ================================================ FILE: Classes/AppDelegate.h ================================================ #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__ ================================================ FILE: Classes/LuaInterface/lua_tinker.cpp ================================================ // lua_tinker.cpp // // LuaTinker - Simple and light C++ wrapper for Lua. // // Copyright (c) 2005-2007 Kwon-il Lee (zupet@hitel.net) // // please check Licence.txt file for licence and legal issues. #include extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" }; #include "lua_tinker.h" /*---------------------------------------------------------------------------*/ /* init */ /*---------------------------------------------------------------------------*/ void lua_tinker::init(lua_State *L) { init_s64(L); init_u64(L); } /*---------------------------------------------------------------------------*/ /* __s64 */ /*---------------------------------------------------------------------------*/ static int tostring_s64(lua_State *L) { char temp[64]; sprintf(temp, "%I64d", *(long long*)lua_topointer(L, 1)); lua_pushstring(L, temp); return 1; } /*---------------------------------------------------------------------------*/ static int eq_s64(lua_State *L) { lua_pushboolean(L, memcmp(lua_topointer(L, 1), lua_topointer(L, 2), sizeof(long long)) == 0); return 1; } /*---------------------------------------------------------------------------*/ static int lt_s64(lua_State *L) { lua_pushboolean(L, memcmp(lua_topointer(L, 1), lua_topointer(L, 2), sizeof(long long)) < 0); return 1; } /*---------------------------------------------------------------------------*/ static int le_s64(lua_State *L) { lua_pushboolean(L, memcmp(lua_topointer(L, 1), lua_topointer(L, 2), sizeof(long long)) <= 0); return 1; } /*---------------------------------------------------------------------------*/ void lua_tinker::init_s64(lua_State *L) { const char* name = "__s64"; lua_pushstring(L, name); lua_newtable(L); lua_pushstring(L, "__name"); lua_pushstring(L, name); lua_rawset(L, -3); lua_pushstring(L, "__tostring"); lua_pushcclosure(L, tostring_s64, 0); lua_rawset(L, -3); lua_pushstring(L, "__eq"); lua_pushcclosure(L, eq_s64, 0); lua_rawset(L, -3); lua_pushstring(L, "__lt"); lua_pushcclosure(L, lt_s64, 0); lua_rawset(L, -3); lua_pushstring(L, "__le"); lua_pushcclosure(L, le_s64, 0); lua_rawset(L, -3); lua_settable(L, LUA_GLOBALSINDEX); } /*---------------------------------------------------------------------------*/ /* __u64 */ /*---------------------------------------------------------------------------*/ static int tostring_u64(lua_State *L) { char temp[64]; sprintf(temp, "%I64u", *(unsigned long long*)lua_topointer(L, 1)); lua_pushstring(L, temp); return 1; } /*---------------------------------------------------------------------------*/ static int eq_u64(lua_State *L) { lua_pushboolean(L, memcmp(lua_topointer(L, 1), lua_topointer(L, 2), sizeof(unsigned long long)) == 0); return 1; } /*---------------------------------------------------------------------------*/ static int lt_u64(lua_State *L) { lua_pushboolean(L, memcmp(lua_topointer(L, 1), lua_topointer(L, 2), sizeof(unsigned long long)) < 0); return 1; } /*---------------------------------------------------------------------------*/ static int le_u64(lua_State *L) { lua_pushboolean(L, memcmp(lua_topointer(L, 1), lua_topointer(L, 2), sizeof(unsigned long long)) <= 0); return 1; } /*---------------------------------------------------------------------------*/ void lua_tinker::init_u64(lua_State *L) { const char* name = "__u64"; lua_pushstring(L, name); lua_newtable(L); lua_pushstring(L, "__name"); lua_pushstring(L, name); lua_rawset(L, -3); lua_pushstring(L, "__tostring"); lua_pushcclosure(L, tostring_u64, 0); lua_rawset(L, -3); lua_pushstring(L, "__eq"); lua_pushcclosure(L, eq_u64, 0); lua_rawset(L, -3); lua_pushstring(L, "__lt"); lua_pushcclosure(L, lt_u64, 0); lua_rawset(L, -3); lua_pushstring(L, "__le"); lua_pushcclosure(L, le_u64, 0); lua_rawset(L, -3); lua_settable(L, LUA_GLOBALSINDEX); } /*---------------------------------------------------------------------------*/ /* excution */ /*---------------------------------------------------------------------------*/ void lua_tinker::dofile(lua_State *L, const char *filename) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); if(luaL_loadfile(L, filename) == 0) { lua_pcall(L, 0, 1, errfunc); } else { print_error(L, "%s", lua_tostring(L, -1)); } lua_remove(L, errfunc); lua_pop(L, 1); } /*---------------------------------------------------------------------------*/ void lua_tinker::dostring(lua_State *L, const char* buff) { lua_tinker::dobuffer(L, buff, strlen(buff)); } /*---------------------------------------------------------------------------*/ void lua_tinker::dobuffer(lua_State *L, const char* buff, size_t len) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); if(luaL_loadbuffer(L, buff, len, "lua_tinker::dobuffer()") == 0) { lua_pcall(L, 0, 1, errfunc); } else { print_error(L, "%s", lua_tostring(L, -1)); } lua_remove(L, errfunc); lua_pop(L, 1); } /*---------------------------------------------------------------------------*/ /* debug helpers */ /*---------------------------------------------------------------------------*/ static void call_stack(lua_State* L, int n) { lua_Debug ar; if(lua_getstack(L, n, &ar) == 1) { lua_getinfo(L, "nSlu", &ar); const char* indent; if(n == 0) { indent = "->\t"; lua_tinker::print_error(L, "\t"); } else { indent = "\t"; } if(ar.name) lua_tinker::print_error(L, "%s%s() : line %d [%s : line %d]", indent, ar.name, ar.currentline, ar.source, ar.linedefined); else lua_tinker::print_error(L, "%sunknown : line %d [%s : line %d]", indent, ar.currentline, ar.source, ar.linedefined); call_stack(L, n+1); } } /*---------------------------------------------------------------------------*/ int lua_tinker::on_error(lua_State *L) { print_error(L, "%s", lua_tostring(L, -1)); call_stack(L, 0); return 0; } /*---------------------------------------------------------------------------*/ void lua_tinker::print_error(lua_State *L, const char* fmt, ...) { char text[4096]; va_list args; va_start(args, fmt); vsprintf(text, fmt, args); va_end(args); lua_pushstring(L, "_ALERT"); lua_gettable(L, LUA_GLOBALSINDEX); if(lua_isfunction(L, -1)) { lua_pushstring(L, text); lua_call(L, 1, 0); } else { printf("%s\n", text); lua_pop(L, 1); } } /*---------------------------------------------------------------------------*/ void lua_tinker::enum_stack(lua_State *L) { int top = lua_gettop(L); print_error(L, "Type:%d", top); for(int i=1; i<=lua_gettop(L); ++i) { switch(lua_type(L, i)) { case LUA_TNIL: print_error(L, "\t%s", lua_typename(L, lua_type(L, i))); break; case LUA_TBOOLEAN: print_error(L, "\t%s %s", lua_typename(L, lua_type(L, i)), lua_toboolean(L, i)?"true":"false"); break; case LUA_TLIGHTUSERDATA: print_error(L, "\t%s 0x%08p", lua_typename(L, lua_type(L, i)), lua_topointer(L, i)); break; case LUA_TNUMBER: print_error(L, "\t%s %f", lua_typename(L, lua_type(L, i)), lua_tonumber(L, i)); break; case LUA_TSTRING: print_error(L, "\t%s %s", lua_typename(L, lua_type(L, i)), lua_tostring(L, i)); break; case LUA_TTABLE: print_error(L, "\t%s 0x%08p", lua_typename(L, lua_type(L, i)), lua_topointer(L, i)); break; case LUA_TFUNCTION: print_error(L, "\t%s() 0x%08p", lua_typename(L, lua_type(L, i)), lua_topointer(L, i)); break; case LUA_TUSERDATA: print_error(L, "\t%s 0x%08p", lua_typename(L, lua_type(L, i)), lua_topointer(L, i)); break; case LUA_TTHREAD: print_error(L, "\t%s", lua_typename(L, lua_type(L, i))); break; } } } /*---------------------------------------------------------------------------*/ /* read */ /*---------------------------------------------------------------------------*/ template<> char* lua_tinker::read(lua_State *L, int index) { return (char*)lua_tostring(L, index); } template<> const char* lua_tinker::read(lua_State *L, int index) { return (const char*)lua_tostring(L, index); } template<> char lua_tinker::read(lua_State *L, int index) { return (char)lua_tonumber(L, index); } template<> unsigned char lua_tinker::read(lua_State *L, int index) { return (unsigned char)lua_tonumber(L, index); } template<> short lua_tinker::read(lua_State *L, int index) { return (short)lua_tonumber(L, index); } template<> unsigned short lua_tinker::read(lua_State *L, int index) { return (unsigned short)lua_tonumber(L, index); } template<> long lua_tinker::read(lua_State *L, int index) { return (long)lua_tonumber(L, index); } template<> unsigned long lua_tinker::read(lua_State *L, int index) { return (unsigned long)lua_tonumber(L, index); } template<> int lua_tinker::read(lua_State *L, int index) { return (int)lua_tonumber(L, index); } template<> unsigned int lua_tinker::read(lua_State *L, int index) { return (unsigned int)lua_tonumber(L, index); } template<> float lua_tinker::read(lua_State *L, int index) { return (float)lua_tonumber(L, index); } template<> double lua_tinker::read(lua_State *L, int index) { return (double)lua_tonumber(L, index); } template<> bool lua_tinker::read(lua_State *L, int index) { if(lua_isboolean(L, index)) return lua_toboolean(L, index) != 0; else return lua_tonumber(L, index) != 0; } template<> void lua_tinker::read(lua_State *L, int index) { return; } template<> long long lua_tinker::read(lua_State *L, int index) { if(lua_isnumber(L,index)) return (long long)lua_tonumber(L, index); else return *(long long*)lua_touserdata(L, index); } template<> unsigned long long lua_tinker::read(lua_State *L, int index) { if(lua_isnumber(L,index)) return (unsigned long long)lua_tonumber(L, index); else return *(unsigned long long*)lua_touserdata(L, index); } template<> lua_tinker::table lua_tinker::read(lua_State *L, int index) { return table(L, index); } /*---------------------------------------------------------------------------*/ /* push */ /*---------------------------------------------------------------------------*/ template<> void lua_tinker::push(lua_State *L, char ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, unsigned char ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, short ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, unsigned short ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, long ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, unsigned long ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, int ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, unsigned int ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, float ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, double ret) { lua_pushnumber(L, ret); } template<> void lua_tinker::push(lua_State *L, char* ret) { lua_pushstring(L, ret); } template<> void lua_tinker::push(lua_State *L, const char* ret) { lua_pushstring(L, ret); } template<> void lua_tinker::push(lua_State *L, bool ret) { lua_pushboolean(L, ret); } template<> void lua_tinker::push(lua_State *L, lua_value* ret) { if(ret) ret->to_lua(L); else lua_pushnil(L); } template<> void lua_tinker::push(lua_State *L, long long ret) { *(long long*)lua_newuserdata(L, sizeof(long long)) = ret; lua_pushstring(L, "__s64"); lua_gettable(L, LUA_GLOBALSINDEX); lua_setmetatable(L, -2); } template<> void lua_tinker::push(lua_State *L, unsigned long long ret) { *(unsigned long long*)lua_newuserdata(L, sizeof(unsigned long long)) = ret; lua_pushstring(L, "__u64"); lua_gettable(L, LUA_GLOBALSINDEX); lua_setmetatable(L, -2); } template<> void lua_tinker::push(lua_State *L, lua_tinker::table ret) { lua_pushvalue(L, ret.m_obj->m_index); } /*---------------------------------------------------------------------------*/ /* pop */ /*---------------------------------------------------------------------------*/ template<> void lua_tinker::pop(lua_State *L) { lua_pop(L, 1); } template<> lua_tinker::table lua_tinker::pop(lua_State *L) { return table(L, lua_gettop(L)); } /*---------------------------------------------------------------------------*/ /* Tinker Class Helper */ /*---------------------------------------------------------------------------*/ static void invoke_parent(lua_State *L) { lua_pushstring(L, "__parent"); lua_rawget(L, -2); if(lua_istable(L,-1)) { lua_pushvalue(L,2); lua_rawget(L, -2); if(!lua_isnil(L,-1)) { lua_remove(L,-2); } else { lua_remove(L, -1); invoke_parent(L); lua_remove(L,-2); } } } /*---------------------------------------------------------------------------*/ int lua_tinker::meta_get(lua_State *L) { lua_getmetatable(L,1); lua_pushvalue(L,2); lua_rawget(L,-2); if(lua_isuserdata(L,-1)) { user2type::invoke(L,-1)->get(L); lua_remove(L, -2); } else if(lua_isnil(L,-1)) { lua_remove(L,-1); invoke_parent(L); if(lua_isnil(L,-1)) { lua_pushfstring(L, "can't find '%s' class variable. (forgot registering class variable ?)", lua_tostring(L, 2)); lua_error(L); } } lua_remove(L,-2); return 1; } /*---------------------------------------------------------------------------*/ int lua_tinker::meta_set(lua_State *L) { lua_getmetatable(L,1); lua_pushvalue(L,2); lua_rawget(L,-2); if(lua_isuserdata(L,-1)) { user2type::invoke(L,-1)->set(L); } else if(lua_isnil(L, -1)) { lua_pushvalue(L,2); lua_pushvalue(L,3); lua_rawset(L, -4); } lua_settop(L, 3); return 0; } /*---------------------------------------------------------------------------*/ void lua_tinker::push_meta(lua_State *L, const char* name) { lua_pushstring(L, name); lua_gettable(L, LUA_GLOBALSINDEX); } /*---------------------------------------------------------------------------*/ /* table object on stack */ /*---------------------------------------------------------------------------*/ lua_tinker::table_obj::table_obj(lua_State* L, int index) :m_L(L) ,m_index(index) ,m_ref(0) { if(lua_isnil(m_L, m_index)) { m_pointer = NULL; lua_remove(m_L, m_index); } else { m_pointer = lua_topointer(m_L, m_index); } } lua_tinker::table_obj::~table_obj() { if(validate()) { lua_remove(m_L, m_index); } } void lua_tinker::table_obj::inc_ref() { ++m_ref; } void lua_tinker::table_obj::dec_ref() { if(--m_ref == 0) delete this; } bool lua_tinker::table_obj::validate() { if(m_pointer != NULL) { if(m_pointer == lua_topointer(m_L, m_index)) { return true; } else { int top = lua_gettop(m_L); for(int i=1; i<=top; ++i) { if(m_pointer == lua_topointer(m_L, i)) { m_index = i; return true; } } m_pointer = NULL; return false; } } else { return false; } } /*---------------------------------------------------------------------------*/ /* Table Object Holder */ /*---------------------------------------------------------------------------*/ lua_tinker::table::table(lua_State* L) { lua_newtable(L); m_obj = new table_obj(L, lua_gettop(L)); m_obj->inc_ref(); } lua_tinker::table::table(lua_State* L, const char* name) { lua_pushstring(L, name); lua_gettable(L, LUA_GLOBALSINDEX); if(lua_istable(L, -1) == 0) { lua_pop(L, 1); lua_newtable(L); lua_pushstring(L, name); lua_pushvalue(L, -2); lua_settable(L, LUA_GLOBALSINDEX); } m_obj = new table_obj(L, lua_gettop(L)); } lua_tinker::table::table(lua_State* L, int index) { if(index < 0) { index = lua_gettop(L) + index + 1; } m_obj = new table_obj(L, index); m_obj->inc_ref(); } lua_tinker::table::table(const table& input) { m_obj = input.m_obj; m_obj->inc_ref(); } lua_tinker::table::~table() { m_obj->dec_ref(); } /*---------------------------------------------------------------------------*/ ================================================ FILE: Classes/LuaInterface/lua_tinker.h ================================================ // lua_tinker.h // // LuaTinker - Simple and light C++ wrapper for Lua. // // Copyright (c) 2005-2007 Kwon-il Lee (zupet@hitel.net) // // please check Licence.txt file for licence and legal issues. #if !defined(_LUA_TINKER_H_) #define _LUA_TINKER_H_ #include #include namespace lua_tinker { // init LuaTinker void init(lua_State *L); void init_s64(lua_State *L); void init_u64(lua_State *L); // string-buffer excution void dofile(lua_State *L, const char *filename); void dostring(lua_State *L, const char* buff); void dobuffer(lua_State *L, const char* buff, size_t sz); // debug helpers void enum_stack(lua_State *L); int on_error(lua_State *L); void print_error(lua_State *L, const char* fmt, ...); // dynamic type extention struct lua_value { virtual void to_lua(lua_State *L) = 0; }; // type trait template struct class_name; struct table; template struct if_ {}; template struct if_ { typedef A type; }; template struct if_ { typedef B type; }; template struct is_ptr { static const bool value = false; }; template struct is_ptr { static const bool value = true; }; template struct is_ref { static const bool value = false; }; template struct is_ref { static const bool value = true; }; template struct remove_const { typedef A type; }; template struct remove_const { typedef A type; }; template struct base_type { typedef A type; }; template struct base_type { typedef A type; }; template struct base_type { typedef A type; }; template struct class_type { typedef typename remove_const::type>::type type; }; template struct is_obj { static const bool value = true; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; template<> struct is_obj { static const bool value = false; }; ///////////////////////////////// enum { no = 1, yes = 2 }; typedef char (& no_type )[no]; typedef char (& yes_type)[yes]; struct int_conv_type { int_conv_type(int); }; no_type int_conv_tester (...); yes_type int_conv_tester (int_conv_type); no_type vfnd_ptr_tester (const volatile char *); no_type vfnd_ptr_tester (const volatile short *); no_type vfnd_ptr_tester (const volatile int *); no_type vfnd_ptr_tester (const volatile long *); no_type vfnd_ptr_tester (const volatile double *); no_type vfnd_ptr_tester (const volatile float *); no_type vfnd_ptr_tester (const volatile bool *); yes_type vfnd_ptr_tester (const volatile void *); template T* add_ptr(T&); template struct bool_to_yesno { typedef no_type type; }; template <> struct bool_to_yesno { typedef yes_type type; }; template struct is_enum { static T arg; static const bool value = ( (sizeof(int_conv_tester(arg)) == sizeof(yes_type)) && (sizeof(vfnd_ptr_tester(add_ptr(arg))) == sizeof(yes_type)) ); }; ///////////////////////////////// // from lua template struct void2val { static T invoke(void* input){ return *(T*)input; } }; template struct void2ptr { static T* invoke(void* input){ return (T*)input; } }; template struct void2ref { static T& invoke(void* input){ return *(T*)input; } }; template struct void2type { static T invoke(void* ptr) { return if_::value ,void2ptr::type> ,typename if_::value ,void2ref::type> ,void2val::type> >::type >::type::invoke(ptr); } }; struct user { user(void* p) : m_p(p) {} virtual ~user() {} void* m_p; }; template struct user2type { static T invoke(lua_State *L, int index) { return void2type::invoke(lua_touserdata(L, index)); } }; template struct lua2enum { static T invoke(lua_State *L, int index) { return (T)(int)lua_tonumber(L, index); } }; template struct lua2object { static T invoke(lua_State *L, int index) { if(!lua_isuserdata(L,index)) { lua_pushstring(L, "no class at first argument. (forgot ':' expression ?)"); lua_error(L); } return void2type::invoke(user2type::invoke(L,index)->m_p); } }; template T lua2type(lua_State *L, int index) { return if_::value ,lua2enum ,lua2object >::type::invoke(L, index); } template struct val2user : user { val2user() : user(new T) {} template val2user(T1 t1) : user(new T(t1)) {} template val2user(T1 t1, T2 t2) : user(new T(t1, t2)) {} template val2user(T1 t1, T2 t2, T3 t3) : user(new T(t1, t2, t3)) {} template val2user(T1 t1, T2 t2, T3 t3, T4 t4) : user(new T(t1, t2, t3,t4)) {} template val2user(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) : user(new T(t1, t2, t3,t4,t5)) {} ~val2user() { delete ((T*)m_p); } }; template struct ptr2user : user { ptr2user(T* t) : user((void*)t) {} }; template struct ref2user : user { ref2user(T& t) : user(&t) {} }; // to lua template struct val2lua { static void invoke(lua_State *L, T& input){ new(lua_newuserdata(L, sizeof(val2user))) val2user(input); } }; template struct ptr2lua { static void invoke(lua_State *L, T* input){ if(input) new(lua_newuserdata(L, sizeof(ptr2user))) ptr2user(input); else lua_pushnil(L); } }; template struct ref2lua { static void invoke(lua_State *L, T& input){ new(lua_newuserdata(L, sizeof(ref2user))) ref2user(input); } }; template struct enum2lua { static void invoke(lua_State *L, T val) { lua_pushnumber(L, (int)val); } }; template struct object2lua { static void invoke(lua_State *L, T val) { if_::value ,ptr2lua::type> ,typename if_::value ,ref2lua::type> ,val2lua::type> >::type >::type::invoke(L, val); push_meta(L, class_name::type>::name()); lua_setmetatable(L, -2); } }; template void type2lua(lua_State *L, T val) { if_::value ,enum2lua ,object2lua >::type::invoke(L, val); } // get value from cclosure template T upvalue_(lua_State *L) { return user2type::invoke(L, lua_upvalueindex(1)); } // read a value from lua stack template T read(lua_State *L, int index) { return lua2type(L, index); } template<> char* read(lua_State *L, int index); template<> const char* read(lua_State *L, int index); template<> char read(lua_State *L, int index); template<> unsigned char read(lua_State *L, int index); template<> short read(lua_State *L, int index); template<> unsigned short read(lua_State *L, int index); template<> long read(lua_State *L, int index); template<> unsigned long read(lua_State *L, int index); template<> int read(lua_State *L, int index); template<> unsigned int read(lua_State *L, int index); template<> float read(lua_State *L, int index); template<> double read(lua_State *L, int index); template<> bool read(lua_State *L, int index); template<> void read(lua_State *L, int index); template<> long long read(lua_State *L, int index); template<> unsigned long long read(lua_State *L, int index); template<> table read(lua_State *L, int index); // push a value to lua stack template void push(lua_State *L, T ret) { type2lua(L, ret); } template<> void push(lua_State *L, char ret); template<> void push(lua_State *L, unsigned char ret); template<> void push(lua_State *L, short ret); template<> void push(lua_State *L, unsigned short ret); template<> void push(lua_State *L, long ret); template<> void push(lua_State *L, unsigned long ret); template<> void push(lua_State *L, int ret); template<> void push(lua_State *L, unsigned int ret); template<> void push(lua_State *L, float ret); template<> void push(lua_State *L, double ret); template<> void push(lua_State *L, char* ret); template<> void push(lua_State *L, const char* ret); template<> void push(lua_State *L, bool ret); template<> void push(lua_State *L, lua_value* ret); template<> void push(lua_State *L, long long ret); template<> void push(lua_State *L, unsigned long long ret); template<> void push(lua_State *L, table ret); // pop a value from lua stack template T pop(lua_State *L) { T t = read(L, -1); lua_pop(L, 1); return t; } template<> void pop(lua_State *L); template<> table pop(lua_State *L); // functor (with return value) template struct functor { static int invoke(lua_State *L) { push(L,upvalue_(L)(read(L,1),read(L,2),read(L,3),read(L,4),read(L,5))); return 1; } }; template struct functor { static int invoke(lua_State *L) { push(L,upvalue_(L)(read(L,1),read(L,2),read(L,3),read(L,4))); return 1; } }; template struct functor { static int invoke(lua_State *L) { push(L,upvalue_(L)(read(L,1),read(L,2),read(L,3))); return 1; } }; template struct functor { static int invoke(lua_State *L) { push(L,upvalue_(L)(read(L,1),read(L,2))); return 1; } }; template struct functor { static int invoke(lua_State *L) { push(L,upvalue_(L)(read(L,1))); return 1; } }; template struct functor { static int invoke(lua_State *L) { push(L,upvalue_(L)()); return 1; } }; // functor (without return value) template struct functor { static int invoke(lua_State *L) { upvalue_(L)(read(L,1),read(L,2),read(L,3),read(L,4),read(L,5)); return 0; } }; template struct functor { static int invoke(lua_State *L) { upvalue_(L)(read(L,1),read(L,2),read(L,3),read(L,4)); return 0; } }; template struct functor { static int invoke(lua_State *L) { upvalue_(L)(read(L,1),read(L,2),read(L,3)); return 0; } }; template struct functor { static int invoke(lua_State *L) { upvalue_(L)(read(L,1),read(L,2)); return 0; } }; template struct functor { static int invoke(lua_State *L) { upvalue_(L)(read(L,1)); return 0; } }; template<> struct functor { static int invoke(lua_State *L) { upvalue_(L)(); return 0; } }; // functor (non-managed) template struct functor { static int invoke(lua_State *L) { return upvalue_(L)(L,read(L,1)); } }; template<> struct functor { static int invoke(lua_State *L) { return upvalue_(L)(L); } }; // push_functor template void push_functor(lua_State *L, RVal (*func)()) { lua_pushcclosure(L, functor::invoke, 1); } template void push_functor(lua_State *L, RVal (*func)(T1)) { lua_pushcclosure(L, functor::invoke, 1); } template void push_functor(lua_State *L, RVal (*func)(T1,T2)) { lua_pushcclosure(L, functor::invoke, 1); } template void push_functor(lua_State *L, RVal (*func)(T1,T2,T3)) { lua_pushcclosure(L, functor::invoke, 1); } template void push_functor(lua_State *L, RVal (*func)(T1,T2,T3,T4)) { lua_pushcclosure(L, functor::invoke, 1); } template void push_functor(lua_State *L, RVal (*func)(T1,T2,T3,T4,T5)) { lua_pushcclosure(L, functor::invoke, 1); } // member variable struct var_base { virtual void get(lua_State *L) = 0; virtual void set(lua_State *L) = 0; }; template struct mem_var : var_base { V T::*_var; mem_var(V T::*val) : _var(val) {} void get(lua_State *L) { push::value,V&,V>::type>(L, read(L,1)->*(_var)); } void set(lua_State *L) { read(L,1)->*(_var) = read(L, 3); } }; // class member functor (with return value) template struct mem_functor { static int invoke(lua_State *L) { push(L,(read(L,1)->*upvalue_(L))(read(L,2),read(L,3),read(L,4),read(L,5),read(L,6)));; return 1; } }; template struct mem_functor { static int invoke(lua_State *L) { push(L,(read(L,1)->*upvalue_(L))(read(L,2),read(L,3),read(L,4),read(L,5))); return 1; } }; template struct mem_functor { static int invoke(lua_State *L) { push(L,(read(L,1)->*upvalue_(L))(read(L,2),read(L,3),read(L,4))); return 1; } }; template struct mem_functor { static int invoke(lua_State *L) { push(L,(read(L,1)->*upvalue_(L))(read(L,2),read(L,3))); return 1; } }; template struct mem_functor { static int invoke(lua_State *L) { push(L,(read(L,1)->*upvalue_(L))(read(L,2))); return 1; } }; template struct mem_functor { static int invoke(lua_State *L) { push(L,(read(L,1)->*upvalue_(L))()); return 1; } }; // class member functor (without return value) template struct mem_functor { static int invoke(lua_State *L) { (read(L,1)->*upvalue_(L))(read(L,2),read(L,3),read(L,4),read(L,5),read(L,6)); return 0; } }; template struct mem_functor { static int invoke(lua_State *L) { (read(L,1)->*upvalue_(L))(read(L,2),read(L,3),read(L,4),read(L,5)); return 0; } }; template struct mem_functor { static int invoke(lua_State *L) { (read(L,1)->*upvalue_(L))(read(L,2),read(L,3),read(L,4)); return 0; } }; template struct mem_functor { static int invoke(lua_State *L) { (read(L,1)->*upvalue_(L))(read(L,2),read(L,3)); return 0; } }; template struct mem_functor { static int invoke(lua_State *L) { (read(L,1)->*upvalue_(L))(read(L,2)); return 0; } }; template struct mem_functor { static int invoke(lua_State *L) { (read(L,1)->*upvalue_(L))(); return 0; } }; // class member functor (non-managed) template struct mem_functor { static int invoke(lua_State *L) { return (read(L,1)->*upvalue_(L))(L, read(L,2)); } }; template struct mem_functor { static int invoke(lua_State *L) { return (read(L,1)->*upvalue_(L))(L); } }; // push_functor template void push_functor(lua_State *L, RVal (T::*func)()) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)() const) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1)) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1) const) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1,T2)) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1,T2) const) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1,T2,T3)) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1,T2,T3) const) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1,T2,T3,T4)) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1,T2,T3,T4) const) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1,T2,T3,T4,T5)) { lua_pushcclosure(L, mem_functor::invoke, 1); } template void push_functor(lua_State *L, RVal (T::*func)(T1,T2,T3,T4,T5) const) { lua_pushcclosure(L, mem_functor::invoke, 1); } // constructor template int constructor(lua_State *L) { new(lua_newuserdata(L, sizeof(val2user))) val2user(read(L,2),read(L,3),read(L,4),read(L,5),read(L,6)); push_meta(L, class_name::type>::name()); lua_setmetatable(L, -2); return 1; } template int constructor(lua_State *L) { new(lua_newuserdata(L, sizeof(val2user))) val2user(read(L,2),read(L,3),read(L,4),read(L,5)); push_meta(L, class_name::type>::name()); lua_setmetatable(L, -2); return 1; } template int constructor(lua_State *L) { new(lua_newuserdata(L, sizeof(val2user))) val2user(read(L,2),read(L,3),read(L,4)); push_meta(L, class_name::type>::name()); lua_setmetatable(L, -2); return 1; } template int constructor(lua_State *L) { new(lua_newuserdata(L, sizeof(val2user))) val2user(read(L,2),read(L,3)); push_meta(L, class_name::type>::name()); lua_setmetatable(L, -2); return 1; } template int constructor(lua_State *L) { new(lua_newuserdata(L, sizeof(val2user))) val2user(read(L,2)); push_meta(L, class_name::type>::name()); lua_setmetatable(L, -2); return 1; } template int constructor(lua_State *L) { new(lua_newuserdata(L, sizeof(val2user))) val2user(); push_meta(L, class_name::type>::name()); lua_setmetatable(L, -2); return 1; } // destroyer template int destroyer(lua_State *L) { ((user*)lua_touserdata(L, 1))->~user(); return 0; } // global function template void def(lua_State* L, const char* name, F func) { lua_pushstring(L, name); lua_pushlightuserdata(L, (void*)func); push_functor(L, func); lua_settable(L, LUA_GLOBALSINDEX); } // global variable template void set(lua_State* L, const char* name, T object) { lua_pushstring(L, name); push(L, object); lua_settable(L, LUA_GLOBALSINDEX); } template T get(lua_State* L, const char* name) { lua_pushstring(L, name); lua_gettable(L, LUA_GLOBALSINDEX); return pop(L); } template void decl(lua_State* L, const char* name, T object) { set(L, name, object); } // call template RVal call(lua_State* L, const char* name) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_pushstring(L, name); lua_gettable(L, LUA_GLOBALSINDEX); if(lua_isfunction(L,-1)) { lua_pcall(L, 0, 1, errfunc); } else { print_error(L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, errfunc); return pop(L); } template RVal call(lua_State* L, const char* name, T1 arg) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_pushstring(L, name); lua_gettable(L, LUA_GLOBALSINDEX); if(lua_isfunction(L,-1)) { push(L, arg); lua_pcall(L, 1, 1, errfunc); } else { print_error(L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, errfunc); return pop(L); } template RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_pushstring(L, name); lua_gettable(L, LUA_GLOBALSINDEX); if(lua_isfunction(L,-1)) { push(L, arg1); push(L, arg2); lua_pcall(L, 2, 1, errfunc); } else { print_error(L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, errfunc); return pop(L); } template RVal call(lua_State* L, const char* name, T1 arg1, T2 arg2, T3 arg3) { lua_pushcclosure(L, on_error, 0); int errfunc = lua_gettop(L); lua_pushstring(L, name); lua_gettable(L, LUA_GLOBALSINDEX); if(lua_isfunction(L,-1)) { push(L, arg1); push(L, arg2); push(L, arg3); lua_pcall(L, 3, 1, errfunc); } else { print_error(L, "lua_tinker::call() attempt to call global `%s' (not a function)", name); } lua_remove(L, errfunc); return pop(L); } // class helper int meta_get(lua_State *L); int meta_set(lua_State *L); void push_meta(lua_State *L, const char* name); // class init template void class_add(lua_State* L, const char* name) { class_name::name(name); lua_pushstring(L, name); lua_newtable(L); lua_pushstring(L, "__name"); lua_pushstring(L, name); lua_rawset(L, -3); lua_pushstring(L, "__index"); lua_pushcclosure(L, meta_get, 0); lua_rawset(L, -3); lua_pushstring(L, "__newindex"); lua_pushcclosure(L, meta_set, 0); lua_rawset(L, -3); lua_pushstring(L, "__gc"); lua_pushcclosure(L, destroyer, 0); lua_rawset(L, -3); lua_settable(L, LUA_GLOBALSINDEX); } // Tinker Class Inheritence template void class_inh(lua_State* L) { push_meta(L, class_name::name()); if(lua_istable(L, -1)) { lua_pushstring(L, "__parent"); push_meta(L, class_name

::name()); lua_rawset(L, -3); } lua_pop(L, 1); } // Tinker Class Constructor template void class_con(lua_State* L,F func) { push_meta(L, class_name::name()); if(lua_istable(L, -1)) { lua_newtable(L); lua_pushstring(L, "__call"); lua_pushcclosure(L, func, 0); lua_rawset(L, -3); lua_setmetatable(L, -2); } lua_pop(L, 1); } // Tinker Class Functions template void class_def(lua_State* L, const char* name, F func) { push_meta(L, class_name::name()); if(lua_istable(L, -1)) { lua_pushstring(L, name); new(lua_newuserdata(L,sizeof(F))) F(func); push_functor(L, func); lua_rawset(L, -3); } lua_pop(L, 1); } // Tinker Class Variables template void class_mem(lua_State* L, const char* name, VAR BASE::*val) { push_meta(L, class_name::name()); if(lua_istable(L, -1)) { lua_pushstring(L, name); new(lua_newuserdata(L,sizeof(mem_var))) mem_var(val); lua_rawset(L, -3); } lua_pop(L, 1); } template struct class_name { // global name static const char* name(const char* name = NULL) { static char temp[256] = ""; if(name) strcpy(temp, name); return temp; } }; // Table Object on Stack struct table_obj { table_obj(lua_State* L, int index); ~table_obj(); void inc_ref(); void dec_ref(); bool validate(); template void set(const char* name, T object) { if(validate()) { lua_pushstring(m_L, name); push(m_L, object); lua_settable(m_L, m_index); } } template void set(int index, T object) { if(validate()) { lua_pushnumber(m_L, index); push(m_L, object); lua_settable(m_L, m_index); } } template T get(const char* name) { if(validate()) { lua_pushstring(m_L, name); lua_gettable(m_L, m_index); } else { lua_pushnil(m_L); } return pop(m_L); } template T get(int index) { if(validate()) { lua_pushnumber(m_L, index); lua_gettable(m_L, m_index); } else { lua_pushnil(m_L); } return pop(m_L); } lua_State* m_L; int m_index; const void* m_pointer; int m_ref; }; // Table Object Holder struct table { table(lua_State* L); table(lua_State* L, int index); table(lua_State* L, const char* name); table(const table& input); ~table(); template void set(const char* name, T object) { m_obj->set(name, object); } template void set(int index, T object) { m_obj->set(index, object); } template T get(const char* name) { return m_obj->get(name); } template T get(int index) { return m_obj->get(index); } table_obj* m_obj; }; } // namespace lua_tinker #endif //_LUA_TINKER_H_ ================================================ FILE: Classes/LuaInterface/luaconf.h ================================================ /* ** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ #ifndef lconfig_h #define lconfig_h #include #include /* ** ================================================================== ** Search for "@@" to find all configurable definitions. ** =================================================================== */ /* @@ LUA_ANSI controls the use of non-ansi features. ** CHANGE it (define it) if you want Lua to avoid the use of any ** non-ansi feature or library. */ #if defined(__STRICT_ANSI__) #define LUA_ANSI #endif #if !defined(LUA_ANSI) && defined(_WIN32) #define LUA_WIN #endif #if defined(LUA_USE_LINUX) #define LUA_USE_POSIX #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ #define LUA_USE_READLINE /* needs some extra libraries */ #endif #if defined(LUA_USE_MACOSX) #define LUA_USE_POSIX #define LUA_DL_DYLD /* does not need extra library */ #endif /* @@ LUA_USE_POSIX includes all functionallity listed as X/Open System @* Interfaces Extension (XSI). ** CHANGE it (define it) if your system is XSI compatible. */ #if defined(LUA_USE_POSIX) #define LUA_USE_MKSTEMP #define LUA_USE_ISATTY #define LUA_USE_POPEN #define LUA_USE_ULONGJMP #endif /* @@ LUA_PATH and LUA_CPATH are the names of the environment variables that @* Lua check to set its paths. @@ LUA_INIT is the name of the environment variable that Lua @* checks for initialization code. ** CHANGE them if you want different names. */ #define LUA_PATH "LUA_PATH" #define LUA_CPATH "LUA_CPATH" #define LUA_INIT "LUA_INIT" /* @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for @* Lua libraries. @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for @* C libraries. ** CHANGE them if your machine has a non-conventional directory ** hierarchy or if you want to install your libraries in ** non-conventional directories. */ #if defined(_WIN32) /* ** In Windows, any exclamation mark ('!') in the path is replaced by the ** path of the directory of the executable file of the current process. */ #define LUA_LDIR "!\\lua\\" #define LUA_CDIR "!\\" #define LUA_PATH_DEFAULT \ ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" #define LUA_CPATH_DEFAULT \ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" #else #define LUA_ROOT "/usr/local/" #define LUA_LDIR LUA_ROOT "share/lua/5.1/" #define LUA_CDIR LUA_ROOT "lib/lua/5.1/" #define LUA_PATH_DEFAULT \ "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" #define LUA_CPATH_DEFAULT \ "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" #endif /* @@ LUA_DIRSEP is the directory separator (for submodules). ** CHANGE it if your machine does not use "/" as the directory separator ** and is not Windows. (On Windows Lua automatically uses "\".) */ #if defined(_WIN32) #define LUA_DIRSEP "\\" #else #define LUA_DIRSEP "/" #endif /* @@ LUA_PATHSEP is the character that separates templates in a path. @@ LUA_PATH_MARK is the string that marks the substitution points in a @* template. @@ LUA_EXECDIR in a Windows path is replaced by the executable's @* directory. @@ LUA_IGMARK is a mark to ignore all before it when bulding the @* luaopen_ function name. ** CHANGE them if for some reason your system cannot use those ** characters. (E.g., if one of those characters is a common character ** in file/directory names.) Probably you do not need to change them. */ #define LUA_PATHSEP ";" #define LUA_PATH_MARK "?" #define LUA_EXECDIR "!" #define LUA_IGMARK "-" /* @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most ** machines, ptrdiff_t gives a good choice between int or long.) */ #define LUA_INTEGER ptrdiff_t /* @@ LUA_API is a mark for all core API functions. @@ LUALIB_API is a mark for all standard library functions. ** CHANGE them if you need to define those functions in some special way. ** For instance, if you want to create one Windows DLL with the core and ** the libraries, you may want to use the following definition (define ** LUA_BUILD_AS_DLL to get it). */ #if defined(LUA_BUILD_AS_DLL) #if defined(LUA_CORE) || defined(LUA_LIB) #define LUA_API __declspec(dllexport) #else #define LUA_API __declspec(dllimport) #endif #else #define LUA_API extern #endif /* more often than not the libs go together with the core */ #define LUALIB_API LUA_API /* @@ LUAI_FUNC is a mark for all extern functions that are not to be @* exported to outside modules. @@ LUAI_DATA is a mark for all extern (const) variables that are not to @* be exported to outside modules. ** CHANGE them if you need to mark them in some special way. Elf/gcc ** (versions 3.2 and later) mark them as "hidden" to optimize access ** when Lua is compiled as a shared library. */ #if defined(luaall_c) #define LUAI_FUNC static #define LUAI_DATA /* empty */ #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ defined(__ELF__) #define LUAI_FUNC __attribute__((visibility("hidden"))) extern #define LUAI_DATA LUAI_FUNC #else #define LUAI_FUNC extern #define LUAI_DATA extern #endif /* @@ LUA_QL describes how error messages quote program elements. ** CHANGE it if you want a different appearance. */ #define LUA_QL(x) "'" x "'" #define LUA_QS LUA_QL("%s") /* @@ LUA_IDSIZE gives the maximum size for the description of the source @* of a function in debug information. ** CHANGE it if you want a different size. */ #define LUA_IDSIZE 60 /* ** {================================================================== ** Stand-alone configuration ** =================================================================== */ #if defined(lua_c) || defined(luaall_c) /* @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that @* is, whether we're running lua interactively). ** CHANGE it if you have a better definition for non-POSIX/non-Windows ** systems. */ #if defined(LUA_USE_ISATTY) #include #define lua_stdin_is_tty() isatty(0) #elif defined(LUA_WIN) #include #include #define lua_stdin_is_tty() _isatty(_fileno(stdin)) #else #define lua_stdin_is_tty() 1 /* assume stdin is a tty */ #endif /* @@ LUA_PROMPT is the default prompt used by stand-alone Lua. @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. ** CHANGE them if you want different prompts. (You can also change the ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) */ #define LUA_PROMPT "> " #define LUA_PROMPT2 ">> " /* @@ LUA_PROGNAME is the default name for the stand-alone Lua program. ** CHANGE it if your stand-alone interpreter has a different name and ** your system is not able to detect that name automatically. */ #define LUA_PROGNAME "lua" /* @@ LUA_MAXINPUT is the maximum length for an input line in the @* stand-alone interpreter. ** CHANGE it if you need longer lines. */ #define LUA_MAXINPUT 512 /* @@ lua_readline defines how to show a prompt and then read a line from @* the standard input. @@ lua_saveline defines how to "save" a read line in a "history". @@ lua_freeline defines how to free a line read by lua_readline. ** CHANGE them if you want to improve this functionality (e.g., by using ** GNU readline and history facilities). */ #if defined(LUA_USE_READLINE) #include #include #include #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) #define lua_saveline(L,idx) \ if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ add_history(lua_tostring(L, idx)); /* add it to history */ #define lua_freeline(L,b) ((void)L, free(b)) #else #define lua_readline(L,b,p) \ ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ #define lua_saveline(L,idx) { (void)L; (void)idx; } #define lua_freeline(L,b) { (void)L; (void)b; } #endif #endif /* }================================================================== */ /* @@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles @* as a percentage. ** CHANGE it if you want the GC to run faster or slower (higher values ** mean larger pauses which mean slower collection.) You can also change ** this value dynamically. */ #define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ /* @@ LUAI_GCMUL defines the default speed of garbage collection relative to @* memory allocation as a percentage. ** CHANGE it if you want to change the granularity of the garbage ** collection. (Higher values mean coarser collections. 0 represents ** infinity, where each step performs a full collection.) You can also ** change this value dynamically. */ #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ /* @@ LUA_COMPAT_GETN controls compatibility with old getn behavior. ** CHANGE it (define it) if you want exact compatibility with the ** behavior of setn/getn in Lua 5.0. */ #undef LUA_COMPAT_GETN /* @@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. ** CHANGE it to undefined as soon as you do not need a global 'loadlib' ** function (the function is still available as 'package.loadlib'). */ #undef LUA_COMPAT_LOADLIB /* @@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. ** CHANGE it to undefined as soon as your programs use only '...' to ** access vararg parameters (instead of the old 'arg' table). */ #define LUA_COMPAT_VARARG /* @@ LUA_COMPAT_MOD controls compatibility with old math.mod function. ** CHANGE it to undefined as soon as your programs use 'math.fmod' or ** the new '%' operator instead of 'math.mod'. */ #define LUA_COMPAT_MOD /* @@ LUA_COMPAT_LSTR controls compatibility with old long string nesting @* facility. ** CHANGE it to 2 if you want the old behaviour, or undefine it to turn ** off the advisory error when nesting [[...]]. */ #define LUA_COMPAT_LSTR 1 /* @@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. ** CHANGE it to undefined as soon as you rename 'string.gfind' to ** 'string.gmatch'. */ #define LUA_COMPAT_GFIND /* @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' @* behavior. ** CHANGE it to undefined as soon as you replace to 'luaL_register' ** your uses of 'luaL_openlib' */ #define LUA_COMPAT_OPENLIB /* @@ luai_apicheck is the assert macro used by the Lua-C API. ** CHANGE luai_apicheck if you want Lua to perform some checks in the ** parameters it gets from API calls. This may slow down the interpreter ** a bit, but may be quite useful when debugging C code that interfaces ** with Lua. A useful redefinition is to use assert.h. */ #if defined(LUA_USE_APICHECK) #include #define luai_apicheck(L,o) { (void)L; assert(o); } #else #define luai_apicheck(L,o) { (void)L; } #endif /* @@ LUAI_BITSINT defines the number of bits in an int. ** CHANGE here if Lua cannot automatically detect the number of bits of ** your machine. Probably you do not need to change this. */ /* avoid overflows in comparison */ #if INT_MAX-20 < 32760 #define LUAI_BITSINT 16 #elif INT_MAX > 2147483640L /* int has at least 32 bits */ #define LUAI_BITSINT 32 #else #error "you must define LUA_BITSINT with number of bits in an integer" #endif /* @@ LUAI_UINT32 is an unsigned integer with at least 32 bits. @@ LUAI_INT32 is an signed integer with at least 32 bits. @@ LUAI_UMEM is an unsigned integer big enough to count the total @* memory used by Lua. @@ LUAI_MEM is a signed integer big enough to count the total memory @* used by Lua. ** CHANGE here if for some weird reason the default definitions are not ** good enough for your machine. (The definitions in the 'else' ** part always works, but may waste space on machines with 64-bit ** longs.) Probably you do not need to change this. */ #if LUAI_BITSINT >= 32 #define LUAI_UINT32 unsigned int #define LUAI_INT32 int #define LUAI_MAXINT32 INT_MAX #define LUAI_UMEM size_t #define LUAI_MEM ptrdiff_t #else /* 16-bit ints */ #define LUAI_UINT32 unsigned long #define LUAI_INT32 long #define LUAI_MAXINT32 LONG_MAX #define LUAI_UMEM unsigned long #define LUAI_MEM long #endif /* @@ LUAI_MAXCALLS limits the number of nested calls. ** CHANGE it if you need really deep recursive calls. This limit is ** arbitrary; its only purpose is to stop infinite recursion before ** exhausting memory. */ #define LUAI_MAXCALLS 20000 /* @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function @* can use. ** CHANGE it if you need lots of (Lua) stack space for your C ** functions. This limit is arbitrary; its only purpose is to stop C ** functions to consume unlimited stack space. (must be smaller than ** -LUA_REGISTRYINDEX) */ #define LUAI_MAXCSTACK 8000 /* ** {================================================================== ** CHANGE (to smaller values) the following definitions if your system ** has a small C stack. (Or you may want to change them to larger ** values if your system has a large C stack and these limits are ** too rigid for you.) Some of these constants control the size of ** stack-allocated arrays used by the compiler or the interpreter, while ** others limit the maximum number of recursive calls that the compiler ** or the interpreter can perform. Values too large may cause a C stack ** overflow for some forms of deep constructs. ** =================================================================== */ /* @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and @* syntactical nested non-terminals in a program. */ #define LUAI_MAXCCALLS 200 /* @@ LUAI_MAXVARS is the maximum number of local variables per function @* (must be smaller than 250). */ #define LUAI_MAXVARS 200 /* @@ LUAI_MAXUPVALUES is the maximum number of upvalues per function @* (must be smaller than 250). */ #define LUAI_MAXUPVALUES 60 /* @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. */ #define LUAL_BUFFERSIZE BUFSIZ /* }================================================================== */ /* ** {================================================================== @@ LUA_NUMBER is the type of numbers in Lua. ** CHANGE the following definitions only if you want to build Lua ** with a number type different from double. You may also need to ** change lua_number2int & lua_number2integer. ** =================================================================== */ #define LUA_NUMBER_DOUBLE #define LUA_NUMBER double /* @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' @* over a number. */ #define LUAI_UACNUMBER double /* @@ LUA_NUMBER_SCAN is the format for reading numbers. @@ LUA_NUMBER_FMT is the format for writing numbers. @@ lua_number2str converts a number to a string. @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. @@ lua_str2number converts a string to a number. */ #define LUA_NUMBER_SCAN "%lf" #define LUA_NUMBER_FMT "%.14g" #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ #define lua_str2number(s,p) strtod((s), (p)) /* @@ The luai_num* macros define the primitive operations over numbers. */ #if defined(LUA_CORE) #include #define luai_numadd(a,b) ((a)+(b)) #define luai_numsub(a,b) ((a)-(b)) #define luai_nummul(a,b) ((a)*(b)) #define luai_numdiv(a,b) ((a)/(b)) #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) #define luai_numpow(a,b) (pow(a,b)) #define luai_numunm(a) (-(a)) #define luai_numeq(a,b) ((a)==(b)) #define luai_numlt(a,b) ((a)<(b)) #define luai_numle(a,b) ((a)<=(b)) #define luai_numisnan(a) (!luai_numeq((a), (a))) #endif /* @@ lua_number2int is a macro to convert lua_Number to int. @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. ** CHANGE them if you know a faster way to convert a lua_Number to ** int (with any rounding method and without throwing errors) in your ** system. In Pentium machines, a naive typecast from double to int ** in C is extremely slow, so any alternative is worth trying. */ /* On a Pentium, resort to a trick */ #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ (defined(__i386) || defined (_M_IX86) || defined(__i386__)) /* On a Microsoft compiler, use assembler */ #if defined(_MSC_VER) #define lua_number2int(i,d) __asm fld d __asm fistp i #define lua_number2integer(i,n) lua_number2int(i, n) /* the next trick should work on any Pentium, but sometimes clashes with a DirectX idiosyncrasy */ #else union luai_Cast { double l_d; long l_l; }; #define lua_number2int(i,d) \ { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } #define lua_number2integer(i,n) lua_number2int(i, n) #endif /* this option always works, but may be slow */ #else #define lua_number2int(i,d) ((i)=(int)(d)) #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) #endif /* }================================================================== */ /* @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. ** CHANGE it if your system requires alignments larger than double. (For ** instance, if your system supports long doubles and they must be ** aligned in 16-byte boundaries, then you should add long double in the ** union.) Probably you do not need to change this. */ #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } /* @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. ** CHANGE them if you prefer to use longjmp/setjmp even with C++ ** or if want/don't to use _longjmp/_setjmp instead of regular ** longjmp/setjmp. By default, Lua handles errors with exceptions when ** compiling as C++ code, with _longjmp/_setjmp when asked to use them, ** and with longjmp/setjmp otherwise. */ #if defined(__cplusplus) /* C++ exceptions */ #define LUAI_THROW(L,c) throw(c) #define LUAI_TRY(L,c,a) try { a } catch(...) \ { if ((c)->status == 0) (c)->status = -1; } #define luai_jmpbuf int /* dummy variable */ #elif defined(LUA_USE_ULONGJMP) /* in Unix, try _longjmp/_setjmp (more efficient) */ #define LUAI_THROW(L,c) _longjmp((c)->b, 1) #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } #define luai_jmpbuf jmp_buf #else /* default handling with long jumps */ #define LUAI_THROW(L,c) longjmp((c)->b, 1) #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } #define luai_jmpbuf jmp_buf #endif /* @@ LUA_MAXCAPTURES is the maximum number of captures that a pattern @* can do during pattern-matching. ** CHANGE it if you need more captures. This limit is arbitrary. */ #define LUA_MAXCAPTURES 32 /* @@ lua_tmpnam is the function that the OS library uses to create a @* temporary name. @@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. ** CHANGE them if you have an alternative to tmpnam (which is considered ** insecure) or if you want the original tmpnam anyway. By default, Lua ** uses tmpnam except when POSIX is available, where it uses mkstemp. */ #if defined(loslib_c) || defined(luaall_c) #if defined(LUA_USE_MKSTEMP) #include #define LUA_TMPNAMBUFSIZE 32 #define lua_tmpnam(b,e) { \ strcpy(b, "/tmp/lua_XXXXXX"); \ e = mkstemp(b); \ if (e != -1) close(e); \ e = (e == -1); } #else #define LUA_TMPNAMBUFSIZE L_tmpnam #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } #endif #endif /* @@ lua_popen spawns a new process connected to the current one through @* the file streams. ** CHANGE it if you have a way to implement it in your system. */ #if defined(LUA_USE_POPEN) #define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) #define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) #elif defined(LUA_WIN) #define lua_popen(L,c,m) ((void)L, _popen(c,m)) #define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) #else #define lua_popen(L,c,m) ((void)((void)c, m), \ luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) #define lua_pclose(L,file) ((void)((void)L, file), 0) #endif /* @@ LUA_DL_* define which dynamic-library system Lua should use. ** CHANGE here if Lua has problems choosing the appropriate ** dynamic-library system for your platform (either Windows' DLL, Mac's ** dyld, or Unix's dlopen). If your system is some kind of Unix, there ** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for ** it. To use dlopen you also need to adapt the src/Makefile (probably ** adding -ldl to the linker options), so Lua does not select it ** automatically. (When you change the makefile to add -ldl, you must ** also add -DLUA_USE_DLOPEN.) ** If you do not want any kind of dynamic library, undefine all these ** options. ** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. */ #if defined(LUA_USE_DLOPEN) #define LUA_DL_DLOPEN #endif #if defined(LUA_WIN) #define LUA_DL_DLL #endif /* @@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State @* (the data goes just *before* the lua_State pointer). ** CHANGE (define) this if you really need that. This value must be ** a multiple of the maximum alignment required for your machine. */ #define LUAI_EXTRASPACE 0 /* @@ luai_userstate* allow user-specific actions on threads. ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something ** extra when a thread is created/deleted/resumed/yielded. */ #define luai_userstateopen(L) ((void)L) #define luai_userstateclose(L) ((void)L) #define luai_userstatethread(L,L1) ((void)L) #define luai_userstatefree(L) ((void)L) #define luai_userstateresume(L,n) ((void)L) #define luai_userstateyield(L,n) ((void)L) /* @@ LUA_INTFRMLEN is the length modifier for integer conversions @* in 'string.format'. @@ LUA_INTFRM_T is the integer type correspoding to the previous length @* modifier. ** CHANGE them if your system supports long long or does not support long. */ #if defined(LUA_USELONGLONG) #define LUA_INTFRMLEN "ll" #define LUA_INTFRM_T long long #else #define LUA_INTFRMLEN "l" #define LUA_INTFRM_T long #endif /* =================================================================== */ /* ** Local configuration. You can use this space to add your redefinitions ** without modifying the main part of the file. */ #endif ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2014 Ge Ziyang 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. ================================================ FILE: README.md ================================================ OpenBird ======== Flappy Bird made with cocos2dx Latest Gif ================================================ FILE: Resources/AudioEngine.lua ================================================ --Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects. local M = {} local audioEngineInstance = cc.SimpleAudioEngine:getInstance() function M.stopAllEffects() audioEngineInstance:stopAllEffects() end function M.getMusicVolume() return audioEngineInstance:getMusicVolume() end function M.isMusicPlaying() return audioEngineInstance:isMusicPlaying() end function M.getEffectsVolume() return audioEngineInstance:getEffectsVolume() end function M.setMusicVolume(volume) audioEngineInstance:setMusicVolume(volume) end function M.stopEffect(handle) audioEngineInstance:stopEffect(handle) end function M.stopMusic(isReleaseData) local releaseDataValue = false if nil ~= isReleaseData then releaseDataValue = isReleaseData end audioEngineInstance:stopMusic(releaseDataValue) end function M.playMusic(filename, isLoop) local loopValue = false if nil ~= isLoop then loopValue = isLoop end audioEngineInstance:playMusic(filename, loopValue) end function M.pauseAllEffects() audioEngineInstance:pauseAllEffects() end function M.preloadMusic(filename) audioEngineInstance:preloadMusic(filename) end function M.resumeMusic() audioEngineInstance:resumeMusic() end function M.playEffect(filename, isLoop) local loopValue = false if nil ~= isLoop then loopValue = isLoop end return audioEngineInstance:playEffect(filename, loopValue) end function M.rewindMusic() audioEngineInstance:rewindMusic() end function M.willPlayMusic() return audioEngineInstance:willPlayMusic() end function M.unloadEffect(filename) audioEngineInstance:unloadEffect(filename) end function M.preloadEffect(filename) audioEngineInstance:preloadEffect(filename) end function M.setEffectsVolume(volume) audioEngineInstance:setEffectsVolume(volume) end function M.pauseEffect(handle) audioEngineInstance:pauseEffect(handle) end function M.resumeAllEffects(handle) audioEngineInstance:resumeAllEffects() end function M.pauseMusic() audioEngineInstance:pauseMusic() end function M.resumeEffect(handle) audioEngineInstance:resumeEffect(handle) end local modename = "AudioEngine" local proxy = {} local mt = { __index = M, __newindex = function (t ,k ,v) print("attemp to update a read-only table") end } setmetatable(proxy,mt) _G[modename] = proxy package.loaded[modename] = proxy ================================================ FILE: Resources/CCBReaderLoad.lua ================================================ ccb = ccb or {} function CCBReaderLoad(strFilePath,proxy,owner) if nil == proxy then return nil end local ccbReader = proxy:createCCBReader() local node = ccbReader:load(strFilePath) local rootName = "" --owner set in readCCBFromFile is proxy if nil ~= owner then --Callbacks local ownerCallbackNames = ccbReader:getOwnerCallbackNames() local ownerCallbackNodes = ccbReader:getOwnerCallbackNodes() local ownerCallbackControlEvents = ccbReader:getOwnerCallbackControlEvents() local i = 1 for i = 1,table.getn(ownerCallbackNames) do local callbackName = ownerCallbackNames[i] local callbackNode = tolua.cast(ownerCallbackNodes[i],"cc.Node") if "function" == type(owner[callbackName]) then proxy:setCallback(callbackNode, owner[callbackName], ownerCallbackControlEvents[i]) else print("Warning: Cannot find owner's lua function:" .. ":" .. callbackName .. " for ownerVar selector") end end --Variables local ownerOutletNames = ccbReader:getOwnerOutletNames() local ownerOutletNodes = ccbReader:getOwnerOutletNodes() for i = 1, table.getn(ownerOutletNames) do local outletName = ownerOutletNames[i] local outletNode = tolua.cast(ownerOutletNodes[i],"cc.Node") owner[outletName] = outletNode end end local nodesWithAnimationManagers = ccbReader:getNodesWithAnimationManagers() local animationManagersForNodes = ccbReader:getAnimationManagersForNodes() for i = 1 , table.getn(nodesWithAnimationManagers) do local innerNode = tolua.cast(nodesWithAnimationManagers[i], "cc.Node") local animationManager = tolua.cast(animationManagersForNodes[i], "cc.CCBAnimationManager") local documentControllerName = animationManager:getDocumentControllerName() if "" == documentControllerName then end if nil ~= ccb[documentControllerName] then ccb[documentControllerName]["mAnimationManager"] = animationManager end --Callbacks local documentCallbackNames = animationManager:getDocumentCallbackNames() local documentCallbackNodes = animationManager:getDocumentCallbackNodes() local documentCallbackControlEvents = animationManager:getDocumentCallbackControlEvents() for i = 1,table.getn(documentCallbackNames) do local callbackName = documentCallbackNames[i] local callbackNode = tolua.cast(documentCallbackNodes[i],"cc.Node") if "" ~= documentControllerName and nil ~= ccb[documentControllerName] then if "function" == type(ccb[documentControllerName][callbackName]) then proxy:setCallback(callbackNode, ccb[documentControllerName][callbackName], documentCallbackControlEvents[i]) else print("Warning: Cannot found lua function [" .. documentControllerName .. ":" .. callbackName .. "] for docRoot selector") end end end --Variables local documentOutletNames = animationManager:getDocumentOutletNames() local documentOutletNodes = animationManager:getDocumentOutletNodes() for i = 1, table.getn(documentOutletNames) do local outletName = documentOutletNames[i] local outletNode = tolua.cast(documentOutletNodes[i],"cc.Node") if nil ~= ccb[documentControllerName] then ccb[documentControllerName][outletName] = tolua.cast(outletNode, proxy:getNodeTypeName(outletNode)) end end --[[ if (typeof(controller.onDidLoadFromCCB) == "function") controller.onDidLoadFromCCB(); ]]-- --Setup timeline callbacks local keyframeCallbacks = animationManager:getKeyframeCallbacks() for i = 1 , table.getn(keyframeCallbacks) do local callbackCombine = keyframeCallbacks[i] local beignIndex,endIndex = string.find(callbackCombine,":") local callbackType = tonumber(string.sub(callbackCombine,1,beignIndex - 1)) local callbackName = string.sub(callbackCombine,endIndex + 1, -1) --Document callback if 1 == callbackType and nil ~= ccb[documentControllerName] then local callfunc = cc.CallFunc:create(ccb[documentControllerName][callbackName]) animationManager:setCallFuncForLuaCallbackNamed(callfunc, callbackCombine); elseif 2 == callbackType and nil ~= owner then --Owner callback local callfunc = cc.CallFunc:create(owner[callbackName])--need check animationManager:setCallFuncForLuaCallbackNamed(callfunc, callbackCombine) end end --start animation local autoPlaySeqId = animationManager:getAutoPlaySequenceId() if -1 ~= autoPlaySeqId then animationManager:runAnimationsForSequenceIdTweenDuration(autoPlaySeqId, 0) end end return node end local function CCBuilderReaderLoad(strFilePath,proxy,owner) print("\n********** \n".."CCBuilderReaderLoad(strFilePath,proxy,owner)".." was deprecated please use ".. "CCBReaderLoad(strFilePath,proxy,owner)" .. " instead.\n**********") return CCBReaderLoad(strFilePath,proxy,owner) end rawset(_G,"CCBuilderReaderLoad",CCBuilderReaderLoad) ================================================ FILE: Resources/CocoStudio.lua ================================================ require "json" require "extern" ccs = ccs or {} function ccs.sendTriggerEvent(event) local triggerObjArr = ccs.TriggerMng.getInstance():get(event) if nil == triggerObjArr then return end for i = 1, table.getn(triggerObjArr) do local triObj = triggerObjArr[i] if nil ~= triObj and triObj.detect then triObj:done() end end end function ccs.registerTriggerClass(className, createFunc) ccs.TInfo.new(className,createFunc) end ccs.TInfo = class("TInfo") ccs.TInfo._className = "" ccs.TInfo._fun = nil function ccs.TInfo:ctor(c,f) -- @param {String|ccs.TInfo}c -- @param {Function}f if nil ~= f then self._className = c self._fun = f else self._className = c._className self._fun = c._fun end ccs.ObjectFactory.getInstance():registerType(self) end ccs.ObjectFactory = class("ObjectFactory") ccs.ObjectFactory._typeMap = nil ccs.ObjectFactory._instance = nil function ccs.ObjectFactory:ctor() self._typeMap = {} end function ccs.ObjectFactory.getInstance() if nil == ccs.ObjectFactory._instance then ccs.ObjectFactory._instance = ccs.ObjectFactory.new() end return ccs.ObjectFactory._instance end function ccs.ObjectFactory.destroyInstance() ccs.ObjectFactory._instance = nil end function ccs.ObjectFactory:createObject(classname) local obj = nil local t = self._typeMap[classname] if nil ~= t then obj = t._fun() end return obj end function ccs.ObjectFactory:registerType(t) self._typeMap[t._className] = t end ccs.TriggerObj = class("TriggerObj") ccs.TriggerObj._cons = {} ccs.TriggerObj._acts = {} ccs.TriggerObj._enable = false ccs.TriggerObj._id = 0 ccs.TriggerObj._vInt = {} function ccs.TriggerObj.extend(target) local t = tolua.getpeer(target) if not t then t = {} tolua.setpeer(target, t) end setmetatable(t, TriggerObj) return target end function ccs.TriggerObj:ctor() self:init() end function ccs.TriggerObj:init() self._id = 0 self._enable = true self._cons = {} self._acts = {} self._vInt = {} end function ccs.TriggerObj:detect() if (not self._enable) or (table.getn(self._cons) == 0) then return true end local ret = true local obj = nil for i = 1 , table.getn(self._cons) do obj = self._cons[i] if nil ~= obj and obj.detect then ret = ret and obj:detect() end end return ret end function ccs.TriggerObj:done() if (not self._enable) or (table.getn(self._acts) == 0) then return end local obj = nil for i = 1, table.getn(self._acts) do obj = self._acts[i] if nil ~= obj and obj.done then obj:done() end end end function ccs.TriggerObj:removeAll() local obj = nil for i=1, table.getn(self._cons) do obj = self._cons[i] if nil ~= obj then obj:removeAll() end end self._cons = {} for i=1, table.getn(self._acts) do obj = self._acts[i] if nil ~= obj then obj:removeAll() end end self._acts = {} end function ccs.TriggerObj:serialize(jsonValue) self._id = jsonValue["id"] local count = 0 --condition local cons = jsonValue["conditions"] if nil ~= cons then count = table.getn(cons) for i = 1, count do local subDict = cons[i] local className = subDict["classname"] if nil ~= className then local obj = ObjectFactory.getInstance():createObject(className) assert(nil ~= obj, string.format("class named %s can not implement!",className)) obj:serialize(subDict) obj:init() table.insert(self._cons, obj) end end end local actions = jsonValue["actions"] if nil ~= actions then count = table.getn(actions) for i = 1,count do local subAction = actions[i] local className = subAction["classname"] if nil ~= className then local act = ccs.ObjectFactory.getInstance():createObject(className) assert(nil ~= act ,string.format("class named %s can not implement!",className)) act:serialize(subAction) act:init() table.insert(self._acts,act) end end end local events = jsonValue["events"] if nil ~= events then count = table.getn(events) for i = 1, count do local subEveent = events[i] local eventID = subEveent["id"] if eventID >= 0 then table.insert(self._vInt,eventID) end end end end function ccs.TriggerObj:getId() return self._id end function ccs.TriggerObj:setEnable(enable) self._enable = enable end function ccs.TriggerObj:getEvents() return self._vInt end ccs.TriggerMng = class("TriggerMng") ccs.TriggerMng._eventTriggers = nil ccs.TriggerMng._triggerObjs = nil ccs.TriggerMng._movementDispatches = nil ccs.TriggerMng._instance = nil function ccs.TriggerMng:ctor() self._triggerObjs = {} self._movementDispatches = {} self._eventTriggers = {} end function ccs.TriggerMng.getInstance() if ccs.TriggerMng._instance == nil then ccs.TriggerMng._instance = ccs.TriggerMng.new() end return ccs.TriggerMng._instance end function ccs.TriggerMng.destroyInstance() if ccs.TriggerMng._instance ~= nil then ccs.TriggerMng._instance:removeAll() ccs.TriggerMng._instance = nil end end function ccs.TriggerMng:triggerMngVersion() return "1.0.0.0" end function ccs.TriggerMng:parse(jsonStr) local parseTable = json.decode(jsonStr,1) if nil == parseTable then return end local count = table.getn(parseTable) for i = 1, count do local subDict = parseTable[i] local triggerObj = ccs.TriggerObj.new() triggerObj:serialize(subDict) local events = triggerObj:getEvents() for j = 1, table.getn(events) do local event = events[j] self:add(event, triggerObj) end self._triggerObjs[triggerObj:getId()] = triggerObj end end function ccs.TriggerMng:get(event) return self._eventTriggers[event] end function ccs.TriggerMng:getTriggerObj(id) return self._triggerObjs[id] end function ccs.TriggerMng:add(event,triggerObj) local eventTriggers = self._eventTriggers[event] if nil == eventTriggers then eventTriggers = {} end local exist = false for i = 1, table.getn(eventTriggers) do if eventTriggers[i] == triggers then exist = true break end end if not exist then table.insert(eventTriggers,triggerObj) self._eventTriggers[event] = eventTriggers end end function ccs.TriggerMng:removeAll( ) for k in pairs(self._eventTriggers) do local triObjArr = self._eventTriggers[k] for j = 1, table.getn(triObjArr) do local obj = triObjArr[j] obj:removeAll() end end self._eventTriggers = {} end function ccs.TriggerMng:remove(event, obj) if nil ~= obj then return self:removeObjByEvent(event, obj) end assert(event >= 0,"event must be larger than 0") if nil == self._eventTriggers then return false end local triObjects = self._eventTriggers[event] if nil == triObjects then return false end for i = 1, table.getn(triObjects) do local triObject = triggers[i] if nil ~= triObject then triObject:remvoeAll() end end self._eventTriggers[event] = nil return true end function ccs.TriggerMng:removeObjByEvent(event, obj) assert(event >= 0,"event must be larger than 0") if nil == self._eventTriggers then return false end local triObjects = self._eventTriggers[event] if nil == triObjects then return false end for i = 1,table.getn(triObjects) do local triObject = triObjects[i] if nil ~= triObject and triObject == obj then triObject:remvoeAll() table.remove(triObjects, i) return true end end end function ccs.TriggerMng:removeTriggerObj(id) local obj = self.getTriggerObj(id) if nil == obj then return false end local events = obj:getEvents() for i = 1, table.getn(events) do self:remove(events[i],obj) end return true end function ccs.TriggerMng:isEmpty() return (not (nil == self._eventTriggers)) or table.getn(self._eventTriggers) <= 0 end ================================================ FILE: Resources/Cocos2d.lua ================================================ require "CocoStudio" cc = cc or {} cc.DIRECTOR_PROJECTION_2D = 0 cc.DIRECTOR_PROJECTION_3D = 1 function cc.clampf(value, min_inclusive, max_inclusive) -- body local temp = 0 if min_inclusive > max_inclusive then temp = min_inclusive min_inclusive = max_inclusive max_inclusive = temp end if value < min_inclusive then return min_inclusive elseif value < max_inclusive then return value else return max_inclusive end end --Point function cc.p(_x,_y) if nil == _y then return { x = _x.x, y = _x.y } else return { x = _x, y = _y } end end function cc.pAdd(pt1,pt2) return {x = pt1.x + pt2.x , y = pt1.y + pt2.y } end function cc.pSub(pt1,pt2) return {x = pt1.x - pt2.x , y = pt1.y - pt2.y } end function cc.pMul(pt1,factor) return { x = pt1.x * factor , y = pt1.y * factor } end function cc.pMidpoint(pt1,pt2) return { x = (pt1.x + pt2.x) / 2.0 , y = ( pt1.y + pt2.y) / 2.0 } end function cc.pForAngle(a) return { x = math.cos(a), y = math.sin(a) } end function cc.pGetLength(pt) return math.sqrt( pt.x * pt.x + pt.y * pt.y ) end function cc.pNormalize(pt) local length = cc.pGetLength(pt) if 0 == length then return { x = 1.0,y = 0.0 } end return { x = pt.x / length, y = pt.y / length } end function cc.pCross(self,other) return self.x * other.y - self.y * other.x end function cc.pDot(self,other) return self.x * other.x + self.y * other.y end function cc.pToAngleSelf(self) return math.atan2(self.y, self.x) end function cc.pGetAngle(self,other) local a2 = cc.pNormalize(self) local b2 = cc.pNormalize(other) local angle = math.atan2(cc.pCross(a2, b2), cc.pDot(a2, b2) ) if angle < 1.192092896e-7 then return 0.0 end return angle end function cc.pGetDistance(startP,endP) return cc.pGetLength(cc.pSub(startP,endP)) end function cc.pIsLineIntersect(A, B, C, D, s, t) if ((A.x == B.x) and (A.y == B.y)) or ((C.x == D.x) and (C.y == D.y))then return false, s, t end local BAx = B.x - A.x local BAy = B.y - A.y local DCx = D.x - C.x local DCy = D.y - C.y local ACx = A.x - C.x local ACy = A.y - C.y local denom = DCy * BAx - DCx * BAy s = DCx * ACy - DCy * ACx t = BAx * ACy - BAy * ACx if (denom == 0) then if (s == 0 or t == 0) then return true, s , t end return false, s, t end s = s / denom t = t / denom return true,s,t end function cc.pPerp(pt) return { x = -pt.y, y = pt.x } end function cc.RPerp(pt) return { x = pt.y, y = -pt.x } end function cc.pProject(pt1, pt2) return { x = pt2.x * (cc.pDot(pt1,pt2) / cc.pDot(pt2,pt2)) , y = pt2.y * (cc.pDot(pt1,pt2) / cc.pDot(pt2,pt2)) } end function cc.pRotate(pt1, pt2) return { x = pt1.x * pt2.x - pt1.y * pt2.y, y = pt1.x * pt2.y + pt1.y * pt2.x } end function cc.pUnrotate(pt1, pt2) return { x = pt1.x * pt2.x + pt1.y * pt2.y, pt1.y * pt2.x - pt1.x * pt2.y } end --Calculates the square length of pt function cc.pLengthSQ(pt) return cc.pDot(pt,pt) end --Calculates the square distance between pt1 and pt2 function cc.pDistanceSQ(pt1,pt2) return cc.pLengthSQ(cc.pSub(pt1,pt2)) end function cc.pGetClampPoint(pt1,pt2,pt3) return { x = cc.clampf(pt1.x, pt2.x, pt3.x), y = cc.clampf(pt1.y, pt2.y, pt3.y) } end function cc.pFromSize(sz) return { x = sz.width, y = sz.height } end function cc.pLerp(pt1,pt2,alpha) return cc.pAdd(cc.pMul(pt1, 1.0 - alpha), cc.pMul(pt2,alpha) ) end function cc.pFuzzyEqual(pt1,pt2,variance) if (pt1.x - variance <= pt2.x) and (pt2.x <= pt1.x + variance) and (pt1.y - variance <= pt2.y) and (pt2.y <= pt1.y + variance) then return true else return false end end function cc.pRotateByAngle(pt1, pt2, angle) return cc.pAdd(pt2, cc.pRotate( cc.pSub(pt1, pt2),cc.pForAngle(angle))) end function cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4) local s,t,ret = 0,0,false ret,s,t =cc.pIsLineIntersect(pt1, pt2, pt3, pt4,s,t) if ret and s >= 0.0 and s <= 1.0 and t >= 0.0 and t <= 0.0 then return true; end return false end function cc.pGetIntersectPoint(pt1,pt2,pt3,pt4) local s,t, ret = 0,0,false ret,s,t = cc.pIsLineIntersect(pt1,pt2,pt3,pt4,s,t) if ret then return cc.p(pt1.x + s * (pt2.x - pt1.x), pt1.y + s * (pt2.y - pt1.y)) else return cc.p(0,0) end end --Size function cc.size( _width,_height ) return { width = _width, height = _height } end --Rect function cc.rect(_x,_y,_width,_height) return { x = _x, y = _y, width = _width, height = _height } end function cc.rectEqualToRect(rect1,rect2) if ((rect1.x >= rect2.x) or (rect1.y >= rect2.y) or ( rect1.x + rect1.width <= rect2.x + rect2.width) or ( rect1.y + rect1.height <= rect2.y + rect2.height)) then return false end return true end function cc.rectGetMaxX(rect) return rect.x + rect.width end function cc.rectGetMidX(rect) return rect.x + rect.width / 2.0 end function cc.rectGetMinX(rect) return rect.x end function cc.rectGetMaxY(rect) return rect.y + rect.height end function cc.rectGetMidY(rect) return rect.y + rect.height / 2.0 end function cc.rectGetMinY(rect) return rect.y end function cc.rectContainsPoint( rect, point ) local ret = false if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and (point.y >= rect.y) and (point.y <= rect.y + rect.height) then ret = true end return ret end function cc.rectIntersectsRect( rect1, rect2 ) local intersect = not ( rect1.x > rect2.x + rect2.width or rect1.x + rect1.width < rect2.x or rect1.y > rect2.y + rect2.height or rect1.y + rect1.height < rect2.y ) return intersect end function cc.rectUnion( rect1, rect2 ) local rect = cc.rect(0, 0, 0, 0) rect.x = math.min(rect1.x, rect2.x) rect.y = math.min(rect1.y, rect2.y) rect.width = math.max(rect1.x + rect1.width, rect2.x + rect2.width) - rect.x rect.height = math.max(rect1.y + rect1.height, rect2.y + rect2.height) - rect.y return rect end function cc.rectIntersection( rect1, rect2 ) local intersection = cc.rect( math.max(rect1.x, rect2.x), math.max(rect1.y, rect2.y), 0, 0) intersection.width = math.min(rect1.x + rect1.width, rect2.x + rect2.width) - intersection.x intersection.height = math.min(rect1.y + rect1.height, rect2.y + rect2.height) - intersection.y return intersection end --Color3B function cc.c3b( _r,_g,_b ) return { r = _r, g = _g, b = _b } end --Color4B function cc.c4b( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end --Color4F function cc.c4f( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end --Vertex2F function cc.vertex2F(_x,_y) return { x = _x, y = _y } end --Vertex3F function cc.Vertex3F(_x,_y,_z) return { x = _x, y = _y, z = _z } end --Tex2F function cc.tex2F(_u,_v) return { u = _u, v = _v } end --PointSprite function cc.PointSprite(_pos,_color,_size) return { pos = _pos, color = _color, size = _size } end --Quad2 function cc.Quad2(_tl,_tr,_bl,_br) return { tl = _tl, tr = _tr, bl = _bl, br = _br } end --Quad3 function cc.Quad3(_tl, _tr, _bl, _br) return { tl = _tl, tr = _tr, bl = _bl, br = _br } end --V2F_C4B_T2F function cc.V2F_C4B_T2F(_vertices, _colors, _texCoords) return { vertices = _vertices, colors = _colors, texCoords = _texCoords } end --V2F_C4F_T2F function cc.V2F_C4F_T2F(_vertices, _colors, _texCoords) return { vertices = _vertices, colors = _colors, texCoords = _texCoords } end --V3F_C4B_T2F function cc.V3F_C4B_T2F(_vertices, _colors, _texCoords) return { vertices = _vertices, colors = _colors, texCoords = _texCoords } end --V2F_C4B_T2F_Quad function cc.V2F_C4B_T2F_Quad(_bl, _br, _tl, _tr) return { bl = _bl, br = _br, tl = _tl, tr = _tr } end --V3F_C4B_T2F_Quad function cc.V3F_C4B_T2F_Quad(_tl, _bl, _tr, _br) return { tl = _tl, bl = _bl, tr = _tr, br = _br } end --V2F_C4F_T2F_Quad function cc.V2F_C4F_T2F_Quad(_bl, _br, _tl, _tr) return { bl = _bl, br = _br, tl = _tl, tr = _tr } end --T2F_Quad function cc.T2F_Quad(_bl, _br, _tl, _tr) return { bl = _bl, br = _br, tl = _tl, tr = _tr } end --AnimationFrameData function cc.AnimationFrameData( _texCoords, _delay, _size) return { texCoords = _texCoords, delay = _delay, size = _size } end --PhysicsMaterial function cc.PhysicsMaterial(_density, _restitution, _friction) return { density = _density, restitution = _restitution, friction = _friction } end local ConfigType = { NONE = 0, COCOSTUDIO = 1, } function __onParseConfig(configType,jasonStr) if configType == ConfigType.COCOSTUDIO then ccs.TriggerMng.getInstance():parse(jasonStr) end end ================================================ FILE: Resources/Cocos2dConstants.lua ================================================ cc = cc or {} cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff cc.TMX_ORIENTATION_HEX = 0x1 cc.TMX_ORIENTATION_ISO = 0x2 cc.TMX_ORIENTATION_ORTHO = 0x0 cc.Z_COMPRESSION_BZIP2 = 0x1 cc.Z_COMPRESSION_GZIP = 0x2 cc.Z_COMPRESSION_NONE = 0x3 cc.Z_COMPRESSION_ZLIB = 0x0 cc.BLEND_DST = 0x303 cc.BLEND_SRC = 0x1 cc.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0 cc.DIRECTOR_MAC_THREAD = 0x0 cc.DIRECTOR_STATS_INTERVAL = 0.1 cc.ENABLE_BOX2_D_INTEGRATION = 0x0 cc.ENABLE_DEPRECATED = 0x1 cc.ENABLE_GL_STATE_CACHE = 0x1 cc.ENABLE_PROFILERS = 0x0 cc.ENABLE_STACKABLE_ACTIONS = 0x1 cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0 cc.GL_ALL = 0x0 cc.LABELATLAS_DEBUG_DRAW = 0x0 cc.LABELBMFONT_DEBUG_DRAW = 0x0 cc.MAC_USE_DISPLAY_LINK_THREAD = 0x0 cc.MAC_USE_MAIN_THREAD = 0x2 cc.MAC_USE_OWN_THREAD = 0x1 cc.NODE_RENDER_SUBPIXEL = 0x1 cc.PVRMIPMAP_MAX = 0x10 cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1 cc.SPRITE_DEBUG_DRAW = 0x0 cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0 cc.TEXTURE_ATLAS_USE_VAO = 0x1 cc.USE_L_A88_LABELS = 0x1 cc.ACTION_TAG_INVALID = -1 cc.DEVICE_MAC = 0x6 cc.DEVICE_MAC_RETINA_DISPLAY = 0x7 cc.DEVICEI_PAD = 0x4 cc.DEVICEI_PAD_RETINA_DISPLAY = 0x5 cc.DEVICEI_PHONE = 0x0 cc.DEVICEI_PHONE5 = 0x2 cc.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3 cc.DEVICEI_PHONE_RETINA_DISPLAY = 0x1 cc.DIRECTOR_PROJECTION2_D = 0x0 cc.DIRECTOR_PROJECTION3_D = 0x1 cc.DIRECTOR_PROJECTION_CUSTOM = 0x2 cc.DIRECTOR_PROJECTION_DEFAULT = 0x1 cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1 cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0 cc.FLIPED_ALL = 0xe0000000 cc.FLIPPED_MASK = 0x1fffffff cc.IMAGE_FORMAT_JPEG = 0x0 cc.IMAGE_FORMAT_PNG = 0x1 cc.ITEM_SIZE = 0x20 cc.LABEL_AUTOMATIC_WIDTH = -1 cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1 cc.LINE_BREAK_MODE_CLIP = 0x2 cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3 cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5 cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4 cc.LINE_BREAK_MODE_WORD_WRAP = 0x0 cc.MAC_VERSION_10_6 = 0xa060000 cc.MAC_VERSION_10_7 = 0xa070000 cc.MAC_VERSION_10_8 = 0xa080000 cc.MENU_HANDLER_PRIORITY = -128 cc.MENU_STATE_TRACKING_TOUCH = 0x1 cc.MENU_STATE_WAITING = 0x0 cc.NODE_TAG_INVALID = -1 cc.PARTICLE_DURATION_INFINITY = -1 cc.PARTICLE_MODE_GRAVITY = 0x0 cc.PARTICLE_MODE_RADIUS = 0x1 cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1 cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1 cc.POSITION_TYPE_FREE = 0x0 cc.POSITION_TYPE_GROUPED = 0x2 cc.POSITION_TYPE_RELATIVE = 0x1 cc.PRIORITY_NON_SYSTEM_MIN = -2147483647 cc.PRIORITY_SYSTEM = -2147483648 cc.PROGRESS_TIMER_TYPE_BAR = 0x1 cc.PROGRESS_TIMER_TYPE_RADIAL = 0x0 cc.REPEAT_FOREVER = 0xfffffffe cc.RESOLUTION_MAC = 0x1 cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2 cc.RESOLUTION_UNKNOWN = 0x0 cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000 cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000 cc.TMX_TILE_VERTICAL_FLAG = 0x40000000 cc.TEXT_ALIGNMENT_CENTER = 0x1 cc.TEXT_ALIGNMENT_LEFT = 0x0 cc.TEXT_ALIGNMENT_RIGHT = 0x2 cc.TEXTURE2_D_PIXEL_FORMAT_AUTO = 0x0 cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888 = 0x1 cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x2 cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x3 cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x4 cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x5 cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x6 cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x7 cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x8 cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x9 cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0xa cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4A = 0xb cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0xc cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2A = 0xd cc.TEXTURE2_D_PIXEL_FORMAT_ETC = 0xe cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT1 = 0xf cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT3 = 0x10 cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT5 = 0x11 cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 cc.TOUCHES_ALL_AT_ONCE = 0x0 cc.TOUCHES_ONE_BY_ONE = 0x1 cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1 cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0 cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1 cc.TRANSITION_ORIENTATION_UP_OVER = 0x0 cc.UNIFORM_COS_TIME = 0x5 cc.UNIFORM_MV_MATRIX = 0x1 cc.UNIFORM_MVP_MATRIX = 0x2 cc.UNIFORM_P_MATRIX = 0x0 cc.UNIFORM_RANDOM01 = 0x6 cc.UNIFORM_SAMPLER = 0x7 cc.UNIFORM_SIN_TIME = 0x4 cc.UNIFORM_TIME = 0x3 cc.UNIFORM_MAX = 0x8 cc.VERTEX_ATTRIB_FLAG_COLOR = 0x2 cc.VERTEX_ATTRIB_FLAG_NONE = 0x0 cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7 cc.VERTEX_ATTRIB_FLAG_POSITION = 0x1 cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4 cc.VERTEX_ATTRIB_COLOR = 0x1 cc.VERTEX_ATTRIB_MAX = 0x3 cc.VERTEX_ATTRIB_POSITION = 0x0 cc.VERTEX_ATTRIB_TEX_COORDS = 0x2 cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2 cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1 cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0 cc.OS_VERSION_4_0 = 0x4000000 cc.OS_VERSION_4_0_1 = 0x4000100 cc.OS_VERSION_4_1 = 0x4010000 cc.OS_VERSION_4_2 = 0x4020000 cc.OS_VERSION_4_2_1 = 0x4020100 cc.OS_VERSION_4_3 = 0x4030000 cc.OS_VERSION_4_3_1 = 0x4030100 cc.OS_VERSION_4_3_2 = 0x4030200 cc.OS_VERSION_4_3_3 = 0x4030300 cc.OS_VERSION_4_3_4 = 0x4030400 cc.OS_VERSION_4_3_5 = 0x4030500 cc.OS_VERSION_5_0 = 0x5000000 cc.OS_VERSION_5_0_1 = 0x5000100 cc.OS_VERSION_5_1_0 = 0x5010000 cc.OS_VERSION_6_0_0 = 0x6000000 cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification' cc.CHIPMUNK_IMPORT = 'chipmunk.h' cc.ATTRIBUTE_NAME_COLOR = 'a_color' cc.ATTRIBUTE_NAME_POSITION = 'a_position' cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord' cc.SHADER_POSITION_COLOR = 'ShaderPositionColor' cc.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor' cc.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture' cc.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color' cc.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor' cc.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest' cc.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor' cc.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor' cc.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue' cc.UNIFORM_COS_TIME_S = 'CC_CosTime' cc.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix' cc.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix' cc.UNIFORM_P_MATRIX_S = 'CC_PMatrix' cc.UNIFORM_RANDOM01_S = 'CC_Random01' cc.UNIFORM_SAMPLER_S = 'CC_Texture0' cc.UNIFORM_SIN_TIME_S = 'CC_SinTime' cc.UNIFORM_TIME_S = 'CC_Time' cc.PLATFORM_OS_WINDOWS = 0 cc.PLATFORM_OS_LINUX = 1 cc.PLATFORM_OS_MAC = 2 cc.PLATFORM_OS_ANDROID = 3 cc.PLATFORM_OS_IPHONE = 4 cc.PLATFORM_OS_IPAD = 5 cc.PLATFORM_OS_BLACKBERRY = 6 cc.PLATFORM_OS_NACL = 7 cc.PLATFORM_OS_EMSCRIPTEN = 8 cc.PLATFORM_OS_TIZEN = 9 cc.SCROLLVIEW_SCRIPT_SCROLL = 0 cc.SCROLLVIEW_SCRIPT_ZOOM = 1 cc.TABLECELL_TOUCHED = 2 cc.TABLECELL_HIGH_LIGHT = 3 cc.TABLECELL_UNHIGH_LIGHT = 4 cc.TABLECELL_WILL_RECYCLE = 5 cc.TABLECELL_SIZE_FOR_INDEX = 6 cc.TABLECELL_SIZE_AT_INDEX = 7 cc.NUMBER_OF_CELLS_IN_TABLEVIEW = 8 cc.SCROLLVIEW_DIRECTION_NONE = -1 cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0 cc.SCROLLVIEW_DIRECTION_VERTICAL = 1 cc.SCROLLVIEW_DIRECTION_BOTH = 2 cc.CONTROL_EVENTTYPE_TOUCH_DOWN = 1 cc.CONTROL_EVENTTYPE_DRAG_INSIDE = 2 cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE = 4 cc.CONTROL_EVENTTYPE_DRAG_ENTER = 8 cc.CONTROL_EVENTTYPE_DRAG_EXIT = 16 cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE = 32 cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE = 64 cc.CONTROL_EVENTTYPE_TOUCH_CANCEL = 128 cc.CONTROL_EVENTTYPE_VALUE_CHANGED = 256 cc.CONTROL_STATE_NORMAL = 1 cc.CONTROL_STATE_HIGH_LIGHTED = 2 cc.CONTROL_STATE_DISABLED = 4 cc.CONTROL_STATE_SELECTED = 8 cc.KEYBOARD_RETURNTYPE_DEFAULT = 0 cc.KEYBOARD_RETURNTYPE_DONE = 1 cc.KEYBOARD_RETURNTYPE_SEND = 2 cc.KEYBOARD_RETURNTYPE_SEARCH = 3 cc.KEYBOARD_RETURNTYPE_GO = 4 cc.EDITBOX_INPUT_MODE_ANY = 0 cc.EDITBOX_INPUT_MODE_EMAILADDR = 1 cc.EDITBOX_INPUT_MODE_NUMERIC = 2 cc.EDITBOX_INPUT_MODE_PHONENUMBER = 3 cc.EDITBOX_INPUT_MODE_URL = 4 cc.EDITBOX_INPUT_MODE_DECIMAL = 5 cc.EDITBOX_INPUT_MODE_SINGLELINE = 6 cc.EDITBOX_INPUT_FLAG_PASSWORD = 0 cc.EDITBOX_INPUT_FLAG_SENSITIVE = 1 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4 cc.LANGUAGE_ENGLISH = 0 cc.LANGUAGE_CHINESE = 1 cc.LANGUAGE_FRENCH = 2 cc.LANGUAGE_ITALIAN = 3 cc.LANGUAGE_GERMAN = 4 cc.LANGUAGE_SPANISH = 5 cc.LANGUAGE_RUSSIAN = 6 cc.LANGUAGE_KOREAN = 7 cc.LANGUAGE_JAPANESE = 8 cc.LANGUAGE_HUNGARIAN = 9 cc.LANGUAGE_PORTUGUESE = 10 cc.LANGUAGE_ARABIC = 11 cc.NODE_ON_ENTER = 0 cc.NODE_ON_EXIT = 1 cc.NODE_ON_ENTER_TRANSITION_DID_FINISH = 2 cc.NODE_ON_EXIT_TRANSITION_DID_START = 3 cc.NODE_ON_CLEAN_UP = 4 cc.CONTROL_STEPPER_PART_MINUS = 0 cc.CONTROL_STEPPER_PART_PLUS = 1 cc.CONTROL_STEPPER_PART_NONE = 2 cc.TABLEVIEW_FILL_TOPDOWN = 0 cc.TABLEVIEW_FILL_BOTTOMUP = 1 cc.WEBSOCKET_OPEN = 0 cc.WEBSOCKET_MESSAGE = 1 cc.WEBSOCKET_CLOSE = 2 cc.WEBSOCKET_ERROR = 3 cc.WEBSOCKET_STATE_CONNECTING = 0 cc.WEBSOCKET_STATE_OPEN = 1 cc.WEBSOCKET_STATE_CLOSING = 2 cc.WEBSOCKET_STATE_CLOSED = 3 cc.XMLHTTPREQUEST_RESPONSE_STRING = 0 cc.XMLHTTPREQUEST_RESPONSE_ARRAY_BUFFER = 1 cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2 cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3 cc.XMLHTTPREQUEST_RESPONSE_JSON = 4 cc.ASSETSMANAGER_CREATE_FILE = 0 cc.ASSETSMANAGER_NETWORK = 1 cc.ASSETSMANAGER_NO_NEW_VERSION = 2 cc.ASSETSMANAGER_UNCOMPRESS = 3 cc.ASSETSMANAGER_PROTOCOL_PROGRESS = 0 cc.ASSETSMANAGER_PROTOCOL_SUCCESS = 1 cc.ASSETSMANAGER_PROTOCOL_ERROR = 2 cc.Handler = cc.Handler or {} cc.Handler.NODE = 0 cc.Handler.MENU_CLICKED = 1 cc.Handler.CALLFUNC = 2 cc.Handler.SCHEDULE = 3 cc.Handler.TOUCHES = 4 cc.Handler.KEYPAD = 5 cc.Handler.ACCELEROMETER = 6 cc.Handler.CONTROL_TOUCH_DOWN = 7 cc.Handler.CONTROL_TOUCH_DRAG_INSIDE = 8 cc.Handler.CONTROL_TOUCH_DRAG_OUTSIDE = 9 cc.Handler.CONTROL_TOUCH_DRAG_ENTER = 10 cc.Handler.CONTROL_TOUCH_DRAG_EXIT = 11 cc.Handler.CONTROL_TOUCH_UP_INSIDE = 12 cc.Handler.CONTROL_TOUCH_UP_OUTSIDE = 13 cc.Handler.CONTROL_TOUCH_UP_CANCEL = 14 cc.Handler.CONTROL_VALUE_CHANGED = 15 cc.Handler.WEBSOCKET_OPEN = 16 cc.Handler.WEBSOCKET_MESSAGE = 17 cc.Handler.WEBSOCKET_CLOSE = 18 cc.Handler.WEBSOCKET_ERROR = 19 cc.Handler.GL_NODE_DRAW = 20 cc.Handler.SCROLLVIEW_SCROLL = 21 cc.Handler.SCROLLVIEW_ZOOM = 22 cc.Handler.TABLECELL_TOUCHED = 23 cc.Handler.TABLECELL_HIGHLIGHT = 24 cc.Handler.TABLECELL_UNHIGHLIGHT = 25 cc.Handler.TABLECELL_WILL_RECYCLE = 26 cc.Handler.TABLECELL_SIZE_FOR_INDEX = 27 cc.Handler.TABLECELL_AT_INDEX = 28 cc.Handler.TABLEVIEW_NUMS_OF_CELLS = 29 cc.Handler.HTTPREQUEST_STATE_CHANGE = 30 cc.Handler.ASSETSMANAGER_PROGRESS = 31 cc.Handler.ASSETSMANAGER_SUCCESS = 32 cc.Handler.ASSETSMANAGER_ERROR = 33 cc.Handler.STUDIO_EVENT_LISTENER = 34 cc.Handler.ARMATURE_EVENT = 35 cc.Handler.EVENT_ACC = 36 cc.Handler.EVENT_CUSTIOM = 37 cc.Handler.EVENT_KEYBOARD_PRESSED = 38 cc.Handler.EVENT_KEYBOARD_RELEASED = 39 cc.Handler.EVENT_TOUCH_BEGAN = 40 cc.Handler.EVENT_TOUCH_MOVED = 41 cc.Handler.EVENT_TOUCH_ENDED = 42 cc.Handler.EVENT_TOUCH_CANCELLED = 43 cc.Handler.EVENT_TOUCHES_BEGAN = 44 cc.Handler.EVENT_TOUCHES_MOVED = 45 cc.Handler.EVENT_TOUCHES_ENDED = 46 cc.Handler.EVENT_TOUCHES_CANCELLED = 47 cc.Handler.EVENT_MOUSE_DOWN = 48 cc.Handler.EVENT_MOUSE_UP = 49 cc.Handler.EVENT_MOUSE_MOVE = 50 cc.Handler.EVENT_MOUSE_SCROLL = 51 cc.Handler.EVENT_SPINE = 52 cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN = 53 cc.Handler.EVENT_PHYSICS_CONTACT_PRESOLVE = 54 cc.Handler.EVENT_PHYSICS_CONTACT_POSTSOLVE = 55 cc.Handler.EVENT_PHYSICS_CONTACT_SEPERATE = 56 cc.EVENT_UNKNOWN = 0 cc.EVENT_TOUCH_ONE_BY_ONE = 1 cc.EVENT_TOUCH_ALL_AT_ONCE = 2 cc.EVENT_KEYBOARD = 3 cc.EVENT_MOUSE = 4 cc.EVENT_ACCELERATION = 5 cc.EVENT_CUSTOM = 6 cc.PHYSICSSHAPE_MATERIAL_DEFAULT = {density = 0.0, restitution = 0.5, friction = 0.5} cc.PHYSICSBODY_MATERIAL_DEFAULT = {density = 0.1, restitution = 0.5, friction = 0.5} cc.GLYPHCOLLECTION_DYNAMIC = 0 cc.GLYPHCOLLECTION_NEHE = 1 cc.GLYPHCOLLECTION_ASCII = 2 cc.GLYPHCOLLECTION_CUSTOM = 3 cc.LabelEffect = { NORMAL = 0, OUTLINE = 1, SHADOW = 2, GLOW = 3, } cc.KeyCode = { KEY_NONE = 0, KEY_PAUSE = 0x0013, KEY_SCROLL_LOCK = 0x1014, KEY_PRINT = 0x1061, KEY_SYSREQ = 0x106A, KEY_BREAK = 0x106B, KEY_ESCAPE = 0x001B, KEY_BACKSPACE = 0x0008, KEY_TAB = 0x0009, KEY_BACK_TAB = 0x0089, KEY_RETURN = 0x000D, KEY_CAPS_LOCK = 0x00E5, KEY_SHIFT = 0x00E1, KEY_CTRL = 0x00E3, KEY_ALT = 0x00E9, KEY_MENU = 0x1067, KEY_HYPER = 0x10ED, KEY_INSERT = 0x1063, KEY_HOME = 0x1050, KEY_PG_UP = 0x1055, KEY_DELETE = 0x10FF, KEY_END = 0x1057, KEY_PG_DOWN = 0x1056, KEY_LEFT_ARROW = 0x1051, KEY_RIGHT_ARROW = 0x1053, KEY_UP_ARROW = 0x1052, KEY_DOWN_ARROW = 0x1054, KEY_NUM_LOCK = 0x107F, KEY_KP_PLUS = 0x10AB, KEY_KP_MINUS = 0x10AD, KEY_KP_MULTIPLY = 0x10AA, KEY_KP_DIVIDE = 0x10AF, KEY_KP_ENTER = 0x108D, KEY_KP_HOME = 0x10B7, KEY_KP_UP = 0x10B8, KEY_KP_PG_UP = 0x10B9, KEY_KP_LEFT = 0x10B4, KEY_KP_FIVE = 0x10B5, KEY_KP_RIGHT = 0x10B6, KEY_KP_END = 0x10B1, KEY_KP_DOWN = 0x10B2, KEY_KP_PG_DOWN = 0x10B3, KEY_KP_INSERT = 0x10B0, KEY_KP_DELETE = 0x10AE, KEY_F1 = 0x00BE, KEY_F2 = 0x00BF, KEY_F3 = 0x00C0, KEY_F4 = 0x00C1, KEY_F5 = 0x00C2, KEY_F6 = 0x00C3, KEY_F7 = 0x00C4, KEY_F8 = 0x00C5, KEY_F9 = 0x00C6, KEY_F10 = 0x00C7, KEY_F11 = 0x00C8, KEY_F12 = 0x00C9, KEY_SPACE = ' ', KEY_EXCLAM = '!', KEY_QUOTE = '"', KEY_NUMBER = '#', KEY_DOLLAR = '$', KEY_PERCENT = '%', KEY_CIRCUMFLEX = '^', KEY_AMPERSAND = '&', KEY_APOSTROPHE = '\'', KEY_LEFT_PARENTHESIS = '(', KEY_RIGHT_PARENTHESIS = ')', KEY_ASTERISK = '*', KEY_PLUS = '+', KEY_COMMA = ',', KEY_MINUS = '-', KEY_PERIOD = '.', KEY_SLASH = '/', KEY_0 = '0', KEY_1 = '1', KEY_2 = '2', KEY_3 = '3', KEY_4 = '4', KEY_5 = '5', KEY_6 = '6', KEY_7 = '7', KEY_8 = '8', KEY_9 = '9', KEY_COLON = ':', KEY_SEMICOLON = ';', KEY_LESS_THAN = '<', KEY_EQUAL = '=', KEY_GREATER_THAN = '>', KEY_QUESTION = '?', KEY_AT = '@', KEY_CAPITAL_A = 'A', KEY_CAPITAL_B = 'B', KEY_CAPITAL_C = 'C', KEY_CAPITAL_D = 'D', KEY_CAPITAL_E = 'E', KEY_CAPITAL_F = 'F', KEY_CAPITAL_G = 'G', KEY_CAPITAL_H = 'H', KEY_CAPITAL_I = 'I', KEY_CAPITAL_J = 'J', KEY_CAPITAL_K = 'K', KEY_CAPITAL_L = 'L', KEY_CAPITAL_M = 'M', KEY_CAPITAL_N = 'N', KEY_CAPITAL_O = 'O', KEY_CAPITAL_P = 'P', KEY_CAPITAL_Q = 'Q', KEY_CAPITAL_R = 'R', KEY_CAPITAL_S = 'S', KEY_CAPITAL_T = 'T', KEY_CAPITAL_U = 'U', KEY_CAPITAL_V = 'V', KEY_CAPITAL_W = 'W', KEY_CAPITAL_X = 'X', KEY_CAPITAL_Y = 'Y', KEY_CAPITAL_Z = 'Z', KEY_LEFT_BRACKET = '[', KEY_BACK_SLASH = '\\', KEY_RIGHT_BRACKET = ']', KEY_UNDERSCORE = '_', KEY_GRAVE = '`', KEY_A = 'a', KEY_B = 'b', KEY_C = 'c', KEY_D = 'd', KEY_E = 'e', KEY_F = 'f', KEY_G = 'g', KEY_H = 'h', KEY_I = 'i', KEY_J = 'j', KEY_K = 'k', KEY_L = 'l', KEY_M = 'm', KEY_N = 'n', KEY_O = 'o', KEY_P = 'p', KEY_Q = 'q', KEY_R = 'r', KEY_S = 's', KEY_T = 't', KEY_U = 'u', KEY_V = 'v', KEY_W = 'w', KEY_X = 'x', KEY_Y = 'y', KEY_Z = 'z', KEY_LEFT_BRACE = '{', KEY_BAR = '|', KEY_RIGHT_BRACE = '}', KEY_TILDE = '~', KEY_EURO = 0x20AC, KEY_POUND = 0x00A3, KEY_YEN = 0x00A5, KEY_MIDDLE_DOT = 0x0095, KEY_SEARCH = 0xFFAA, }; ================================================ FILE: Resources/Deprecated.lua ================================================ require "Cocos2d.lua" --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") end --functions of CCDirector will be deprecated,begin local CCDirectorDeprecated = { } function CCDirectorDeprecated.sharedDirector() deprecatedTip("CCDirector:sharedDirector","cc.Director:getInstance") return cc.Director:getInstance() end rawset(CCDirector,"sharedDirector",CCDirectorDeprecated.sharedDirector) --functions of CCDirector will be deprecated,end --functions of CCTextureCache will be deprecated begin local TextureCacheDeprecated = {} function TextureCacheDeprecated.getInstance(self) deprecatedTip("cc.TextureCache:getInstance","cc.Director:getInstance():getTextureCache") return cc.Director:getInstance():getTextureCache() end rawset(cc.TextureCache,"getInstance",TextureCacheDeprecated.getInstance) function TextureCacheDeprecated.destroyInstance(self) deprecatedTip("cc.TextureCache:destroyInstance","cc.Director:getInstance():destroyTextureCache") return cc.Director:getInstance():destroyTextureCache() end rawset(cc.TextureCache,"destroyInstance",TextureCacheDeprecated.destroyInstance) function TextureCacheDeprecated.dumpCachedTextureInfo(self) deprecatedTip("self:dumpCachedTextureInfo","self:getCachedTextureInfo") return print(self:getCachedTextureInfo()) end rawset(cc.TextureCache,"dumpCachedTextureInfo",TextureCacheDeprecated.dumpCachedTextureInfo) local CCTextureCacheDeprecated = { } function CCTextureCacheDeprecated.sharedTextureCache() deprecatedTip("CCTextureCache:sharedTextureCache","CCTextureCache:getInstance") return cc.TextureCache:getInstance() end rawset(CCTextureCache,"sharedTextureCache",CCTextureCacheDeprecated.sharedTextureCache) function CCTextureCacheDeprecated.purgeSharedTextureCache() deprecatedTip("CCTextureCache:purgeSharedTextureCache","CCTextureCache:destroyInstance") return cc.TextureCache:destroyInstance() end rawset(CCTextureCache,"purgeSharedTextureCache",CCTextureCacheDeprecated.purgeSharedTextureCache) function CCTextureCacheDeprecated.addUIImage(self, image, key) deprecatedTip("CCTextureCache:addUIImage","CCTextureCache:addImage") return self:addImage(image,key) end rawset(CCTextureCache,"addUIImage",CCTextureCacheDeprecated.addUIImage) --functions of CCTextureCache will be deprecated end --functions of CCAnimation will be deprecated begin local CCAnimationDeprecated = {} function CCAnimationDeprecated.addSpriteFrameWithFileName(self,...) deprecatedTip("CCAnimationDeprecated:addSpriteFrameWithFileName","cc.Animation:addSpriteFrameWithFile") return self:addSpriteFrameWithFile(...) end rawset(CCAnimation,"addSpriteFrameWithFileName",CCAnimationDeprecated.addSpriteFrameWithFileName) --functions of CCAnimation will be deprecated end --functions of CCAnimationCache will be deprecated begin local CCAnimationCacheDeprecated = { } function CCAnimationCacheDeprecated.sharedAnimationCache() deprecatedTip("CCAnimationCache:sharedAnimationCache","CCAnimationCache:getInstance") return CCAnimationCache:getInstance() end rawset(CCAnimationCache,"sharedAnimationCache",CCAnimationCacheDeprecated.sharedAnimationCache) function CCAnimationCacheDeprecated.purgeSharedAnimationCache() deprecatedTip("CCAnimationCache:purgeSharedAnimationCache","CCAnimationCache:destroyInstance") return CCAnimationCache:destroyInstance() end rawset(CCAnimationCache,"purgeSharedAnimationCache",CCAnimationCacheDeprecated.purgeSharedAnimationCache) function CCAnimationCacheDeprecated.addAnimationsWithFile(self,...) deprecatedTip("CCAnimationCache:addAnimationsWithFile","cc.AnimationCache:addAnimations") return self:addAnimations(...) end rawset(CCAnimationCache,"addAnimationsWithFile",CCAnimationCacheDeprecated.addAnimationsWithFile) function CCAnimationCacheDeprecated.animationByName(self,...) deprecatedTip("CCAnimationCache:animationByName","cc.AnimationCache:getAnimation") return self:getAnimation(...) end rawset(CCAnimationCache,"animationByName",CCAnimationCacheDeprecated.animationByName) function CCAnimationCacheDeprecated.removeAnimationByName(self) deprecatedTip("CCAnimationCache:removeAnimationByName","cc.AnimationCache:removeAnimation") return self:removeAnimation() end rawset(CCAnimationCache,"removeAnimationByName",CCAnimationCacheDeprecated.removeAnimationByName) --functions of CCAnimationCache will be deprecated end --functions of CCFileUtils will be deprecated end local CCFileUtilsDeprecated = { } function CCFileUtilsDeprecated.sharedFileUtils() deprecatedTip("CCFileUtils:sharedFileUtils","CCFileUtils:getInstance") return cc.FileUtils:getInstance() end rawset(CCFileUtils,"sharedFileUtils",CCFileUtilsDeprecated.sharedFileUtils) function CCFileUtilsDeprecated.purgeFileUtils() deprecatedTip("CCFileUtils:purgeFileUtils","CCFileUtils:destroyInstance") return cc.FileUtils:destroyInstance() end rawset(CCFileUtils,"purgeFileUtils",CCFileUtilsDeprecated.purgeFileUtils) --functions of CCFileUtils will be deprecated end --functions of SimpleAudioEngine will be deprecated begin local SimpleAudioEngineDeprecated = { } function SimpleAudioEngineDeprecated.sharedEngine() deprecatedTip("SimpleAudioEngine:sharedEngine","SimpleAudioEngine:getInstance") return cc.SimpleAudioEngine:getInstance() end rawset(SimpleAudioEngine,"sharedEngine",SimpleAudioEngineDeprecated.sharedEngine) function SimpleAudioEngineDeprecated.playBackgroundMusic(self,...) deprecatedTip("SimpleAudioEngine:playBackgroundMusic","SimpleAudioEngine:playMusic") return self:playMusic(...) end rawset(SimpleAudioEngine,"playBackgroundMusic",SimpleAudioEngineDeprecated.playBackgroundMusic) --functions of SimpleAudioEngine will be deprecated end --functions of CCMenu will be deprecated begin local CCMenuDeprecated = { } function CCMenuDeprecated.createWithItem(self,...) deprecatedTip("CCMenuDeprecated:createWithItem","cc.Menu:createWithItem") return self:create(...) end rawset(CCMenu,"createWithItem",CCMenuDeprecated.createWithItem) function CCMenuDeprecated.setHandlerPriority(self) print("\n********** \n".."setHandlerPriority was deprecated in 3.0. \n**********") end rawset(CCMenu,"setHandlerPriority",CCMenuDeprecated.setHandlerPriority) --functions of CCMenu will be deprecated end --functions of CCNode will be deprecated begin local CCNodeDeprecated = { } function CCNodeDeprecated.boundingBox(self) deprecatedTip("CCNode:boundingBox","cc.Node:getBoundingBox") return self:getBoundingBox() end rawset(CCNode,"boundingBox",CCNodeDeprecated.boundingBox) function CCNodeDeprecated.numberOfRunningActions(self) deprecatedTip("CCNode:numberOfRunningActions","cc.Node:getNumberOfRunningActions") return self:getNumberOfRunningActions() end rawset(CCNode,"numberOfRunningActions",CCNodeDeprecated.numberOfRunningActions) function CCNodeDeprecated.removeFromParentAndCleanup(self,...) deprecatedTip("CCNode:removeFromParentAndCleanup","cc.Node:removeFromParent") return self:removeFromParent(...) end rawset(CCNode,"removeFromParentAndCleanup",CCNodeDeprecated.removeFromParentAndCleanup) --functions of CCNode will be deprecated end --CCDrawPrimitives will be deprecated begin local function CCDrawPrimitivesClassDeprecated() deprecatedTip("CCDrawPrimitives","cc.DrawPrimitives") return cc.DrawPrimitives end _G["CCDrawPrimitives"] = CCDrawPrimitivesClassDeprecated() --functions of CCDrawPrimitives will be deprecated begin local CCDrawPrimitivesDeprecated = { } function CCDrawPrimitivesDeprecated.ccDrawPoint(pt) deprecatedTip("ccDrawPoint","cc.DrawPrimitives.drawPoint") return cc.DrawPrimitives.drawPoint(pt) end rawset(_G, "ccDrawPoint", CCDrawPrimitivesDeprecated.ccDrawPoint) function CCDrawPrimitivesDeprecated.ccDrawLine(origin,destination) deprecatedTip("ccDrawLine","cc.DrawPrimitives.drawLine") return cc.DrawPrimitives.drawLine(origin,destination) end rawset(_G, "ccDrawLine", CCDrawPrimitivesDeprecated.ccDrawLine) function CCDrawPrimitivesDeprecated.ccDrawRect(origin,destination) deprecatedTip("ccDrawRect","cc.DrawPrimitives.drawRect") return cc.DrawPrimitives.drawRect(origin,destination) end rawset(_G, "ccDrawRect", CCDrawPrimitivesDeprecated.ccDrawRect) function CCDrawPrimitivesDeprecated.ccDrawSolidRect(origin,destination,color) deprecatedTip("ccDrawSolidRect","cc.DrawPrimitives.drawSolidRect") return cc.DrawPrimitives.drawSolidRect(origin,destination,color) end rawset(_G, "ccDrawSolidRect", CCDrawPrimitivesDeprecated.ccDrawSolidRect) -- params:... may represent two param(xScale,yScale) or nil function CCDrawPrimitivesDeprecated.ccDrawCircle(center,radius,angle,segments,drawLineToCenter,...) deprecatedTip("ccDrawCircle","cc.DrawPrimitives.drawCircle") return cc.DrawPrimitives.drawCircle(center,radius,angle,segments,drawLineToCenter,...) end rawset(_G, "ccDrawCircle", CCDrawPrimitivesDeprecated.ccDrawCircle) -- params:... may represent two param(xScale,yScale) or nil function CCDrawPrimitivesDeprecated.ccDrawSolidCircle(center,radius,angle,segments,...) deprecatedTip("ccDrawSolidCircle","cc.DrawPrimitives.drawSolidCircle") return cc.DrawPrimitives.drawSolidCircle(center,radius,angle,segments,...) end rawset(_G, "ccDrawSolidCircle", CCDrawPrimitivesDeprecated.ccDrawSolidCircle) function CCDrawPrimitivesDeprecated.ccDrawQuadBezier(origin,control,destination,segments) deprecatedTip("ccDrawQuadBezier","cc.DrawPrimitives.drawQuadBezier") return cc.DrawPrimitives.drawQuadBezier(origin,control,destination,segments) end rawset(_G, "ccDrawQuadBezier", CCDrawPrimitivesDeprecated.ccDrawQuadBezier) function CCDrawPrimitivesDeprecated.ccDrawCubicBezier(origin,control1,control2,destination,segments) deprecatedTip("ccDrawCubicBezier","cc.DrawPrimitives.drawCubicBezier") return cc.DrawPrimitives.drawCubicBezier(origin,control1,control2,destination,segments) end rawset(_G, "ccDrawCubicBezier", CCDrawPrimitivesDeprecated.ccDrawCubicBezier) function CCDrawPrimitivesDeprecated.ccDrawCatmullRom(arrayOfControlPoints,segments) deprecatedTip("ccDrawCatmullRom","cc.DrawPrimitives.drawCatmullRom") return cc.DrawPrimitives.drawCatmullRom(arrayOfControlPoints,segments) end rawset(_G, "ccDrawCatmullRom", CCDrawPrimitivesDeprecated.ccDrawCatmullRom) function CCDrawPrimitivesDeprecated.ccDrawCardinalSpline(config,tension,segments) deprecatedTip("ccDrawCardinalSpline","cc.DrawPrimitives.drawCardinalSpline") return cc.DrawPrimitives.drawCardinalSpline(config,tension,segments) end rawset(_G, "ccDrawCardinalSpline", CCDrawPrimitivesDeprecated.ccDrawCardinalSpline) function CCDrawPrimitivesDeprecated.ccDrawColor4B(r,g,b,a) deprecatedTip("ccDrawColor4B","cc.DrawPrimitives.drawColor4B") return cc.DrawPrimitives.drawColor4B(r,g,b,a) end rawset(_G, "ccDrawColor4B", CCDrawPrimitivesDeprecated.ccDrawColor4B) function CCDrawPrimitivesDeprecated.ccDrawColor4F(r,g,b,a) deprecatedTip("ccDrawColor4F","cc.DrawPrimitives.drawColor4F") return cc.DrawPrimitives.drawColor4F(r,g,b,a) end rawset(_G, "ccDrawColor4F", CCDrawPrimitivesDeprecated.ccDrawColor4F) function CCDrawPrimitivesDeprecated.ccPointSize(pointSize) deprecatedTip("ccPointSize","cc.DrawPrimitives.setPointSize") return cc.DrawPrimitives.setPointSize(pointSize) end rawset(_G, "ccPointSize", CCDrawPrimitivesDeprecated.ccPointSize) --functions of CCDrawPrimitives will be deprecated end --CCDrawPrimitives will be deprecated end local CCProgressTimerDeprecated = {} function CCProgressTimerDeprecated.setReverseProgress(self,...) deprecatedTip("CCProgressTimer","CCProgressTimer:setReverseDirection") return self:setReverseDirection(...) end rawset(CCProgressTimer,"setReverseProgress",CCProgressTimerDeprecated.setReverseProgress) --functions of CCSpriteFrameCache will be deprecated begin local CCSpriteFrameCacheDeprecated = { } function CCSpriteFrameCacheDeprecated.spriteFrameByName(self,szName) deprecatedTip("CCSpriteFrameCache:spriteFrameByName","CCSpriteFrameCache:getSpriteFrameByName") return self:getSpriteFrameByName(szName) end rawset(CCSpriteFrameCache,"spriteFrameByName",CCSpriteFrameCacheDeprecated.spriteFrameByName) function CCSpriteFrameCacheDeprecated.sharedSpriteFrameCache() deprecatedTip("CCSpriteFrameCache:sharedSpriteFrameCache","CCSpriteFrameCache:getInstance") return CCSpriteFrameCache:getInstance() end rawset(CCSpriteFrameCache,"sharedSpriteFrameCache",CCSpriteFrameCacheDeprecated.sharedSpriteFrameCache) function CCSpriteFrameCacheDeprecated.purgeSharedSpriteFrameCache() deprecatedTip("CCSpriteFrameCache:purgeSharedSpriteFrameCache","CCSpriteFrameCache:destroyInstance") return CCSpriteFrameCache:destroyInstance() end rawset(CCSpriteFrameCache,"purgeSharedSpriteFrameCache",CCSpriteFrameCacheDeprecated.purgeSharedSpriteFrameCache) function CCSpriteFrameCacheDeprecated.addSpriteFramesWithFile(self,...) deprecatedTip("CCSpriteFrameCache:addSpriteFramesWithFile","CCSpriteFrameCache:addSpriteFrames") return self:addSpriteFrames(...) end rawset(CCSpriteFrameCache,"addSpriteFramesWithFile",CCSpriteFrameCacheDeprecated.addSpriteFramesWithFile) function CCSpriteFrameCacheDeprecated.getSpriteFrameByName(self,...) deprecatedTip("CCSpriteFrameCache:getSpriteFrameByName","CCSpriteFrameCache:getSpriteFrame") return self:getSpriteFrame(...) end rawset(CCSpriteFrameCache,"getSpriteFrameByName",CCSpriteFrameCacheDeprecated.getSpriteFrameByName) --functions of CCSpriteFrameCache will be deprecated end --functions of CCLabelAtlas will be deprecated begin local CCLabelAtlasDeprecated = {} function CCLabelAtlasDeprecated.create(self,...) deprecatedTip("CCLabelAtlas:create","CCLabelAtlas:_create") return self:_create(...) end rawset(CCLabelAtlas,"create",CCLabelAtlasDeprecated.create) --functions of CCLabelAtlas will be deprecated end --------------------------- --global functions wil be deprecated, begin local function CCRectMake(x,y,width,height) deprecatedTip("CCRectMake(x,y,width,height)","cc.rect(x,y,width,height) in lua") return cc.rect(x,y,width,height) end rawset(_G,"CCRectMake",CCRectMake) local function ccc3(r,g,b) deprecatedTip("ccc3(r,g,b)","cc.c3b(r,g,b)") return cc.c3b(r,g,b) end rawset(_G,"ccc3",ccc3) local function ccp(x,y) deprecatedTip("ccp(x,y)","cc.p(x,y)") return cc.p(x,y) end rawset(_G,"ccp",ccp) local function CCSizeMake(width,height) deprecatedTip("CCSizeMake(width,height)","cc.size(width,height)") return cc.size(width,height) end rawset(_G,"CCSizeMake",CCSizeMake) local function ccc4(r,g,b,a) deprecatedTip("ccc4(r,g,b,a)","cc.c4b(r,g,b,a)") return cc.c4b(r,g,b,a) end rawset(_G,"ccc4",ccc4) local function ccc4FFromccc3B(color3B) deprecatedTip("ccc4FFromccc3B(color3B)","cc.c4f(color3B.r / 255.0,color3B.g / 255.0,color3B.b / 255.0,1.0)") return cc.c4f(color3B.r/255.0, color3B.g/255.0, color3B.b/255.0, 1.0) end rawset(_G,"ccc4FFromccc3B",ccc4FFromccc3B) local function ccc4f(r,g,b,a) deprecatedTip("ccc4f(r,g,b,a)","cc.c4f(r,g,b,a)") return cc.c4f(r,g,b,a) end rawset(_G,"ccc4f",ccc4f) local function ccc4FFromccc4B(color4B) deprecatedTip("ccc4FFromccc4B(color4B)","cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0)") return cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0) end rawset(_G,"ccc4FFromccc4B",ccc4FFromccc4B) local function ccc4FEqual(a,b) deprecatedTip("ccc4FEqual(a,b)","a:equals(b)") return a:equals(b) end rawset(_G,"ccc4FEqual",ccc4FEqual) --global functions wil be deprecated, end --functions of _G will be deprecated begin local function ccpLineIntersect(a,b,c,d,s,t) deprecatedTip("ccpLineIntersect","cc.pIsLineIntersect") return cc.pIsLineIntersect(a,b,c,d,s,t) end rawset(_G,"ccpLineIntersect",ccpLineIntersect) local function CCPointMake(x,y) deprecatedTip("CCPointMake(x,y)","cc.p(x,y)") return cc.p(x,y) end rawset(_G,"CCPointMake",CCPointMake) local function ccpNeg(pt) deprecatedTip("ccpNeg","cc.pSub") return cc.pSub({x = 0,y = 0}, pt) end rawset(_G,"ccpNeg",ccpNeg) local function ccpAdd(pt1,pt2) deprecatedTip("ccpAdd","cc.pAdd") return cc.pAdd(pt1,pt2) end rawset(_G,"ccpAdd",ccpAdd) local function ccpSub(pt1,pt2) deprecatedTip("ccpSub","cc.pSub") return cc.pSub(pt1,pt2) end rawset(_G,"ccpSub",ccpSub) local function ccpMult(pt,factor) deprecatedTip("ccpMult","cc.pMul") return cc.pMul(pt,factor) end rawset(_G,"ccpMult",ccpMult) local function ccpMidpoint(pt1,pt2) deprecatedTip("ccpMidpoint","cc.pMidpoint") return cc.pMidpoint(pt1,pt2) end rawset(_G,"ccpMidpoint",ccpMidpoint) local function ccpDot(pt1,pt2) deprecatedTip("ccpDot","cc.pDot") return cc.pDot(pt1,pt2) end rawset(_G,"ccpDot",ccpDot) local function ccpCross(pt1,pt2) deprecatedTip("ccpCross","cc.pCross") return cc.pCross(pt1, pt2) end rawset(_G,"ccpCross",ccpCross) local function ccpPerp(pt) deprecatedTip("ccpPerp","cc.pPerp") return cc.pPerp(pt) end rawset(_G,"ccpPerp",ccpPerp) local function ccpRPerp(pt) deprecatedTip("ccpRPerp","cc.RPerp") return cc.RPerp(pt) end rawset(_G,"ccpRPerp",ccpRPerp) local function ccpProject(pt1,pt2) deprecatedTip("ccpProject","cc.pProject") return cc.pProject(pt1,pt2) end rawset(_G,"ccpProject",ccpProject) local function ccpRotate(pt1,pt2) deprecatedTip("ccpRotate","cc.pRotate") return cc.pRotate(pt1,pt2) end rawset(_G,"ccpRotate",ccpRotate) local function ccpUnrotate(pt1,pt2) deprecatedTip("ccpUnrotate","cc.pUnrotate") return cc.pUnrotate(pt1,pt2) end rawset(_G,"ccpUnrotate",ccpUnrotate) local function ccpLengthSQ(pt) deprecatedTip("ccpLengthSQ","cc.pLengthSQ") return cc.pLengthSQ(pt) end rawset(_G,"ccpLengthSQ",ccpLengthSQ) local function ccpDistanceSQ(pt1,pt2) deprecatedTip("ccpDistanceSQ","cc.pDistanceSQ") return cc.pDistanceSQ(pt1,pt2) end rawset(_G,"ccpDistanceSQ",ccpDistanceSQ) local function ccpLength(pt) deprecatedTip("ccpLength","cc.pGetLength") return cc.pGetLength(pt) end rawset(_G,"ccpLength",ccpLength) local function ccpDistance(pt1,pt2) deprecatedTip("ccpDistance","cc.pGetDistance") return cc.pGetDistance(pt1, pt2) end rawset(_G,"ccpDistance",ccpDistance) local function ccpNormalize(pt) deprecatedTip("ccpNormalize","cc.pNormalize") return cc.pNormalize(pt) end rawset(_G,"ccpNormalize",ccpNormalize) local function ccpForAngle(angle) deprecatedTip("ccpForAngle","cc.pForAngle") return cc.pForAngle(angle) end rawset(_G,"ccpForAngle",ccpForAngle) local function ccpToAngle(pt) deprecatedTip("ccpToAngle","cc.pToAngleSelf") return cc.pToAngleSelf(pt) end rawset(_G,"ccpToAngle",ccpToAngle) local function ccpClamp(pt1,pt2,pt3) deprecatedTip("ccpClamp","cc.pGetClampPoint") return cc.pGetClampPoint(pt1,pt2,pt3) end rawset(_G,"ccpClamp",ccpClamp) local function ccpFromSize(sz) deprecatedTip("ccpFromSize(sz)","cc.pFromSize") return cc.pFromSize(sz) end rawset(_G,"ccpFromSize",ccpFromSize) local function ccpLerp(pt1,pt2,alpha) deprecatedTip("ccpLerp","cc.pLerp") return cc.pLerp(pt1,pt2,alpha) end rawset(_G,"ccpLerp",ccpLerp) local function ccpFuzzyEqual(pt1,pt2,variance) deprecatedTip("ccpFuzzyEqual","cc.pFuzzyEqual") return cc.pFuzzyEqual(pt1,pt2,variance) end rawset(_G,"ccpFuzzyEqual",ccpFuzzyEqual) local function ccpCompMult(pt1,pt2) deprecatedTip("ccpCompMult","cc.p") return cc.p(pt1.x * pt2.x , pt1.y * pt2.y) end rawset(_G,"ccpCompMult",ccpCompMult) local function ccpAngleSigned(pt1,pt2) deprecatedTip("ccpAngleSigned","cc.pGetAngle") return cc.pGetAngle(pt1, pt2) end rawset(_G,"ccpAngleSigned",ccpAngleSigned) local function ccpAngle(pt1,pt2) deprecatedTip("ccpAngle","cc.pGetAngle") return cc.pGetAngle(pt1,ptw) end rawset(_G,"ccpAngle",ccpAngle) local function ccpRotateByAngle(pt1,pt2,angle) deprecatedTip("ccpRotateByAngle","cc.pRotateByAngle") return cc.pRotateByAngle(pt1, pt2, angle) end rawset(_G,"ccpRotateByAngle",ccpRotateByAngle) local function ccpSegmentIntersect(pt1,pt2,pt3,pt4) deprecatedTip("ccpSegmentIntersect","cc.pIsSegmentIntersect") return cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4) end rawset(_G,"ccpSegmentIntersect",ccpSegmentIntersect) local function ccpIntersectPoint(pt1,pt2,pt3,pt4) deprecatedTip("ccpIntersectPoint","cc.pGetIntersectPoint") return cc.pGetIntersectPoint(pt1,pt2,pt3,pt4) end rawset(_G,"ccpIntersectPoint",ccpIntersectPoint) local function vertex2(x,y) deprecatedTip("vertex2(x,y)","cc.vertex2F(x,y)") return cc.vertex2F(x,y) end rawset(_G,"vertex2",vertex2) local function vertex3(x,y,z) deprecatedTip("vertex3(x,y,z)","cc.Vertex3F(x,y,z)") return cc.Vertex3F(x,y,z) end rawset(_G,"vertex3",vertex3) local function tex2(u,v) deprecatedTip("tex2(u,v)","cc.tex2f(u,v)") return cc.tex2f(u,v) end rawset(_G,"tex2",tex2) local function ccc4BFromccc4F(color4F) deprecatedTip("ccc4BFromccc4F(color4F)","Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0)") return Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0) end rawset(_G,"ccc4BFromccc4F",ccc4BFromccc4F) local function ccColor3BDeprecated() deprecatedTip("ccColor3B","cc.c3b(0,0,0)") return cc.c3b(0,0,0) end _G["ccColor3B"] = ccColor3BDeprecated local function ccColor4BDeprecated() deprecatedTip("ccColor4B","cc.c4b(0,0,0,0)") return cc.c4b(0,0,0,0) end _G["ccColor4B"] = ccColor4BDeprecated local function ccColor4FDeprecated() deprecatedTip("ccColor4F","cc.c4f(0.0,0.0,0.0,0.0)") return cc.c4f(0.0,0.0,0.0,0.0) end _G["ccColor4F"] = ccColor4FDeprecated local function ccVertex2FDeprecated() deprecatedTip("ccVertex2F","cc.vertex2F(0.0,0.0)") return cc.vertex2F(0.0,0.0) end _G["ccVertex2F"] = ccVertex2FDeprecated local function ccVertex3FDeprecated() deprecatedTip("ccVertex3F","cc.Vertex3F(0.0, 0.0, 0.0)") return cc.Vertex3F(0.0, 0.0, 0.0) end _G["ccVertex3F"] = ccVertex3FDeprecated local function ccTex2FDeprecated() deprecatedTip("ccTex2F","cc.tex2F(0.0, 0.0)") return cc.tex2F(0.0, 0.0) end _G["ccTex2F"] = ccTex2FDeprecated local function ccPointSpriteDeprecated() deprecatedTip("ccPointSprite","cc.PointSprite(cc.vertex2F(0.0, 0.0),cc.c4b(0.0, 0.0, 0.0),0)") return cc.PointSprite(cc.vertex2F(0.0, 0.0),cc.c4b(0.0, 0.0, 0.0),0) end _G["ccPointSprite"] = ccPointSpriteDeprecated local function ccQuad2Deprecated() deprecatedTip("ccQuad2","cc.Quad2(cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0))") return cc.Quad2(cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0)) end _G["ccQuad2"] = ccQuad2Deprecated local function ccQuad3Deprecated() deprecatedTip("ccQuad3","cc.Quad3(cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0))") return cc.Quad3(cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0)) end _G["ccQuad3"] = ccQuad3Deprecated local function ccV2FC4BT2FDeprecated() deprecatedTip("ccV2F_C4B_T2F","cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))") return cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)) end _G["ccV2F_C4B_T2F"] = ccV2FC4BT2FDeprecated local function ccV2FC4FT2FDeprecated() deprecatedTip("ccV2F_C4F_T2F","cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0 , 0.0 , 0.0 ), cc.tex2F(0.0, 0.0))") return cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0 , 0.0 , 0.0), cc.tex2F(0.0, 0.0)) end _G["ccV2F_C4F_T2F"] = ccV2FC4FT2FDeprecated local function ccV3FC4BT2FDeprecated() deprecatedTip("ccV3F_C4B_T2F","cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0 , 0, 0 ), cc.tex2F(0.0, 0.0))") return cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0 , 0, 0 ), cc.tex2F(0.0, 0.0)) end _G["ccV3F_C4B_T2F"] = ccV3FC4BT2FDeprecated local function ccV2FC4BT2FQuadDeprecated() deprecatedTip("ccV2F_C4B_T2F_Quad","cc.V2F_C4B_T2F_Quad(cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)))") return cc.V2F_C4B_T2F_Quad(cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))) end _G["ccV2F_C4B_T2F_Quad"] = ccV2FC4BT2FQuadDeprecated local function ccV3FC4BT2FQuadDeprecated() deprecatedTip("ccV3F_C4B_T2F_Quad","cc.V3F_C4B_T2F_Quad(_tl, _bl, _tr, _br)") return cc.V3F_C4B_T2F_Quad(cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))) end _G["ccV3F_C4B_T2F_Quad"] = ccV3FC4BT2FQuadDeprecated local function ccV2FC4FT2FQuadDeprecated() deprecatedTip("ccV2F_C4F_T2F_Quad","cc.V2F_C4F_T2F_Quad(_bl, _br, _tl, _tr)") return cc.V2F_C4F_T2F_Quad(cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0))) end _G["ccV2F_C4F_T2F_Quad"] = ccV2FC4FT2FQuadDeprecated local function ccT2FQuadDeprecated() deprecatedTip("ccT2F_Quad","cc.T2F_Quad(_bl, _br, _tl, _tr)") return cc.T2F_Quad(cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0)) end _G["ccT2F_Quad"] = ccT2FQuadDeprecated local function ccAnimationFrameDataDeprecated() deprecatedTip("ccAnimationFrameData","cc.AnimationFrameData( _texCoords, _delay, _size)") return cc.AnimationFrameData(cc.T2F_Quad(cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0)), 0, cc.size(0,0)) end _G["ccAnimationFrameData"] = ccAnimationFrameDataDeprecated local function tex2(u,v) deprecatedTip("tex2(u,v)","cc.tex2f(u,v)") return cc.tex2f(u,v) end rawset(_G,"tex2",tex2) --functions of CCControl will be deprecated end local CCControlDeprecated = { } function CCControlDeprecated.addHandleOfControlEvent(self,func,controlEvent) deprecatedTip("addHandleOfControlEvent","registerControlEventHandler") print("come in addHandleOfControlEvent") self:registerControlEventHandler(func,controlEvent) end rawset(CCControl,"addHandleOfControlEvent",CCControlDeprecated.addHandleOfControlEvent) --functions of CCControl will be deprecated end --functions of CCEGLView will be deprecated end local CCEGLViewDeprecated = { } function CCEGLViewDeprecated.sharedOpenGLView() deprecatedTip("CCEGLView:sharedOpenGLView","CCEGLView:getInstance") return CCEGLView:getInstance() end rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) --functions of CCFileUtils will be deprecated end --Enums of CCTableView will be deprecated begin rawset(CCTableView, "kTableViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) rawset(CCTableView,"kTableViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) rawset(CCTableView,"kTableCellTouched",cc.TABLECELL_TOUCHED) rawset(CCTableView,"kTableCellSizeForIndex",cc.TABLECELL_SIZE_FOR_INDEX) rawset(CCTableView,"kTableCellSizeAtIndex",cc.TABLECELL_SIZE_AT_INDEX) rawset(CCTableView,"kNumberOfCellsInTableView",cc.NUMBER_OF_CELLS_IN_TABLEVIEW) --Enums of CCTableView will be deprecated end --Enums of CCScrollView will be deprecated begin rawset(CCScrollView, "kScrollViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) rawset(CCScrollView,"kScrollViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) --Enums of CCScrollView will be deprecated end --functions of CCApplication will be deprecated end local CCApplicationDeprecated = { } function CCApplicationDeprecated.sharedApplication() deprecatedTip("CCApplication:sharedApplication","CCApplication:getInstance") return CCApplication:getInstance() end rawset(CCApplication,"sharedApplication",CCApplicationDeprecated.sharedApplication) --functions of CCApplication will be deprecated end --functions of CCDirector will be deprecated end local CCDirectorDeprecated = { } function CCDirectorDeprecated.sharedDirector() deprecatedTip("CCDirector:sharedDirector","CCDirector:getInstance") return CCDirector:getInstance() end rawset(CCDirector,"sharedDirector",CCDirectorDeprecated.sharedDirector) --functions of CCDirector will be deprecated end --functions of CCUserDefault will be deprecated end local CCUserDefaultDeprecated = { } function CCUserDefaultDeprecated.sharedUserDefault() deprecatedTip("CCUserDefault:sharedUserDefault","CCUserDefault:getInstance") return CCUserDefault:getInstance() end rawset(CCUserDefault,"sharedUserDefault",CCUserDefaultDeprecated.sharedUserDefault) function CCUserDefaultDeprecated.purgeSharedUserDefault() deprecatedTip("CCUserDefault:purgeSharedUserDefault","CCUserDefault:destroyInstance") return CCUserDefault:destroyInstance() end rawset(CCUserDefault,"purgeSharedUserDefault",CCUserDefaultDeprecated.purgeSharedUserDefault) --functions of CCUserDefault will be deprecated end --functions of CCGrid3DAction will be deprecated begin local CCGrid3DActionDeprecated = { } function CCGrid3DActionDeprecated.vertex(self,pt) deprecatedTip("vertex","CCGrid3DAction:getVertex") return self:getVertex(pt) end rawset(CCGrid3DAction,"vertex",CCGrid3DActionDeprecated.vertex) function CCGrid3DActionDeprecated.originalVertex(self,pt) deprecatedTip("originalVertex","CCGrid3DAction:getOriginalVertex") return self:getOriginalVertex(pt) end rawset(CCGrid3DAction,"originalVertex",CCGrid3DActionDeprecated.originalVertex) --functions of CCGrid3DAction will be deprecated end --functions of CCTiledGrid3DAction will be deprecated begin local CCTiledGrid3DActionDeprecated = { } function CCTiledGrid3DActionDeprecated.tile(self,pt) deprecatedTip("tile","CCTiledGrid3DAction:getTile") return self:getTile(pt) end rawset(CCTiledGrid3DAction,"tile",CCTiledGrid3DActionDeprecated.tile) function CCTiledGrid3DActionDeprecated.originalTile(self,pt) deprecatedTip("originalTile","CCTiledGrid3DAction:getOriginalTile") return self:getOriginalTile(pt) end rawset(CCTiledGrid3DAction,"originalTile",CCTiledGrid3DActionDeprecated.originalTile) --functions of CCTiledGrid3DAction will be deprecated end --functions of CCTexture2D will be deprecated begin local CCTexture2DDeprecated = { } function CCTexture2DDeprecated.stringForFormat(self) deprecatedTip("Texture2D:stringForFormat","Texture2D:getStringForFormat") return self:getStringForFormat() end rawset(CCTexture2D,"stringForFormat",CCTexture2DDeprecated.stringForFormat) function CCTexture2DDeprecated.bitsPerPixelForFormat(self) deprecatedTip("Texture2D:bitsPerPixelForFormat","Texture2D:getBitsPerPixelForFormat") return self:getBitsPerPixelForFormat() end rawset(CCTexture2D,"bitsPerPixelForFormat",CCTexture2DDeprecated.bitsPerPixelForFormat) function CCTexture2DDeprecated.bitsPerPixelForFormat(self,pixelFormat) deprecatedTip("Texture2D:bitsPerPixelForFormat","Texture2D:getBitsPerPixelForFormat") return self:getBitsPerPixelForFormat(pixelFormat) end rawset(CCTexture2D,"bitsPerPixelForFormat",CCTexture2DDeprecated.bitsPerPixelForFormat) function CCTexture2DDeprecated.defaultAlphaPixelFormat(self) deprecatedTip("Texture2D:defaultAlphaPixelFormat","Texture2D:getDefaultAlphaPixelFormat") return self:getDefaultAlphaPixelFormat() end rawset(CCTexture2D,"defaultAlphaPixelFormat",CCTexture2DDeprecated.defaultAlphaPixelFormat) --functions of CCTexture2D will be deprecated end --functions of CCTimer will be deprecated begin local CCTimerDeprecated = { } function CCTimerDeprecated.timerWithScriptHandler(handler,seconds) deprecatedTip("CCTimer:timerWithScriptHandler","CCTimer:createWithScriptHandler") return CCTimer:createWithScriptHandler(handler,seconds) end rawset(CCTimer,"timerWithScriptHandler",CCTimerDeprecated.timerWithScriptHandler) function CCTimerDeprecated.numberOfRunningActionsInTarget(self,target) deprecatedTip("CCActionManager:numberOfRunningActionsInTarget","CCActionManager:getNumberOfRunningActionsInTarget") return self:getNumberOfRunningActionsInTarget(target) end rawset(CCTimer,"numberOfRunningActionsInTarget",CCTimerDeprecated.numberOfRunningActionsInTarget) --functions of CCTimer will be deprecated end --functions of CCMenuItemFont will be deprecated begin local CCMenuItemFontDeprecated = { } function CCMenuItemFontDeprecated.fontSize() deprecatedTip("CCMenuItemFont:fontSize","CCMenuItemFont:getFontSize") return CCMenuItemFont:getFontSize() end rawset(CCMenuItemFont,"fontSize",CCMenuItemFontDeprecated.fontSize) function CCMenuItemFontDeprecated.fontName() deprecatedTip("CCMenuItemFont:fontName","CCMenuItemFont:getFontName") return CCMenuItemFont:getFontName() end rawset(CCMenuItemFont,"fontName",CCMenuItemFontDeprecated.fontName) function CCMenuItemFontDeprecated.fontSizeObj(self) deprecatedTip("CCMenuItemFont:fontSizeObj","CCMenuItemFont:getFontSizeObj") return self:getFontSizeObj() end rawset(CCMenuItemFont,"fontSizeObj",CCMenuItemFontDeprecated.fontSizeObj) function CCMenuItemFontDeprecated.fontNameObj(self) deprecatedTip("CCMenuItemFont:fontNameObj","CCMenuItemFont:getFontNameObj") return self:getFontNameObj() end rawset(CCMenuItemFont,"fontNameObj",CCMenuItemFontDeprecated.fontNameObj) --functions of CCMenuItemFont will be deprecated end --functions of CCMenuItemToggle will be deprecated begin local CCMenuItemToggleDeprecated = { } function CCMenuItemToggleDeprecated.selectedItem(self) deprecatedTip("CCMenuItemToggle:selectedItem","CCMenuItemToggle:getSelectedItem") return self:getSelectedItem() end rawset(CCMenuItemToggle,"selectedItem",CCMenuItemToggleDeprecated.selectedItem) --functions of CCMenuItemToggle will be deprecated end --functions of CCTileMapAtlas will be deprecated begin local CCTileMapAtlasDeprecated = { } function CCTileMapAtlasDeprecated.tileAt(self,pos) deprecatedTip("CCTileMapAtlas:tileAt","CCTileMapAtlas:getTileAt") return self:getTileAt(pos) end rawset(CCTileMapAtlas,"tileAt",CCTileMapAtlasDeprecated.tileAt) --functions of CCTileMapAtlas will be deprecated end --functions of CCTMXLayer will be deprecated begin local CCTMXLayerDeprecated = { } function CCTMXLayerDeprecated.tileAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:tileAt","CCTMXLayer:getTileAt") return self:getTileAt(tileCoordinate) end rawset(CCTMXLayer,"tileAt",CCTMXLayerDeprecated.tileAt) function CCTMXLayerDeprecated.tileGIDAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:tileGIDAt","CCTMXLayer:getTileGIDAt") return self:getTileGIDAt(tileCoordinate) end rawset(CCTMXLayer,"tileGIDAt",CCTMXLayerDeprecated.tileGIDAt) function CCTMXLayerDeprecated.positionAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:positionAt","CCTMXLayer:getPositionAt") return self:getPositionAt(tileCoordinate) end rawset(CCTMXLayer,"positionAt",CCTMXLayerDeprecated.positionAt) function CCTMXLayerDeprecated.propertyNamed(self,propertyName) deprecatedTip("CCTMXLayer:propertyNamed","CCTMXLayer:getProperty") return self:getProperty(propertyName) end rawset(CCTMXLayer,"propertyNamed",CCTMXLayerDeprecated.propertyNamed) --functions of CCTMXLayer will be deprecated end --functions of CCTMXTiledMap will be deprecated begin local CCTMXTiledMapDeprecated = { } function CCTMXTiledMapDeprecated.layerNamed(self,layerName) deprecatedTip("CCTMXTiledMap:layerNamed","CCTMXTiledMap:getLayer") return self:getLayer(layerName) end rawset(CCTMXTiledMap,"layerNamed", CCTMXTiledMapDeprecated.layerNamed) function CCTMXTiledMapDeprecated.propertyNamed(self,propertyName) deprecatedTip("CCTMXTiledMap:propertyNamed","CCTMXTiledMap:getProperty") return self:getProperty(propertyName) end rawset(CCTMXTiledMap,"propertyNamed", CCTMXTiledMapDeprecated.propertyNamed ) function CCTMXTiledMapDeprecated.propertiesForGID(self,GID) deprecatedTip("CCTMXTiledMap:propertiesForGID","CCTMXTiledMap:getPropertiesForGID") return self:getPropertiesForGID(GID) end rawset(CCTMXTiledMap,"propertiesForGID", CCTMXTiledMapDeprecated.propertiesForGID) function CCTMXTiledMapDeprecated.objectGroupNamed(self,groupName) deprecatedTip("CCTMXTiledMap:objectGroupNamed","CCTMXTiledMap:getObjectGroup") return self:getObjectGroup(groupName) end rawset(CCTMXTiledMap,"objectGroupNamed", CCTMXTiledMapDeprecated.objectGroupNamed) --functions of CCTMXTiledMap will be deprecated end --functions of CCTMXMapInfo will be deprecated begin local CCTMXMapInfoDeprecated = { } function CCTMXMapInfoDeprecated.getStoringCharacters(self) deprecatedTip("CCTMXMapInfo:getStoringCharacters","CCTMXMapInfo:isStoringCharacters") return self:isStoringCharacters() end rawset(CCTMXMapInfo,"getStoringCharacters", CCTMXMapInfoDeprecated.getStoringCharacters) function CCTMXMapInfoDeprecated.formatWithTMXFile(infoTable,tmxFile) deprecatedTip("CCTMXMapInfo:formatWithTMXFile","CCTMXMapInfo:create") return CCTMXMapInfo:create(tmxFile) end rawset(CCTMXMapInfo,"formatWithTMXFile", CCTMXMapInfoDeprecated.formatWithTMXFile) function CCTMXMapInfoDeprecated.formatWithXML(infoTable,tmxString,resourcePath) deprecatedTip("CCTMXMapInfo:formatWithXML","TMXMapInfo:createWithXML") return CCTMXMapInfo:createWithXML(tmxString,resourcePath) end rawset(CCTMXMapInfo,"formatWithXML", CCTMXMapInfoDeprecated.formatWithXML) --functions of CCTMXMapInfo will be deprecated end --functions of CCTMXObject will be deprecated begin local CCTMXObjectGroupDeprecated = { } function CCTMXObjectGroupDeprecated.propertyNamed(self,propertyName) deprecatedTip("CCTMXObjectGroup:propertyNamed","CCTMXObjectGroup:getProperty") return self:getProperty(propertyName) end rawset(CCTMXObjectGroup,"propertyNamed", CCTMXObjectGroupDeprecated.propertyNamed) function CCTMXObjectGroupDeprecated.objectNamed(self, objectName) deprecatedTip("CCTMXObjectGroup:objectNamed","CCTMXObjectGroup:getObject") return self:getObject(objectName) end rawset(CCTMXObjectGroup,"objectNamed", CCTMXObjectGroupDeprecated.objectNamed) --functions of CCTMXObject will be deprecated end --functions of WebSocket will be deprecated begin local targetPlatform = CCApplication:getInstance():getTargetPlatform() if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) then local WebSocketDeprecated = { } function WebSocketDeprecated.sendTextMsg(self, string) deprecatedTip("WebSocket:sendTextMsg","WebSocket:sendString") return self:sendString(string) end rawset(WebSocket,"sendTextMsg", WebSocketDeprecated.sendTextMsg) function WebSocketDeprecated.sendBinaryMsg(self, table,tablesize) deprecatedTip("WebSocket:sendBinaryMsg","WebSocket:sendString") string.char(unpack(table)) return self:sendString(string.char(unpack(table))) end rawset(WebSocket,"sendBinaryMsg", WebSocketDeprecated.sendBinaryMsg) end --functions of WebSocket will be deprecated end --functions of CCRenderTexture will be deprecated begin local CCRenderTextureDeprecated = { } function CCRenderTextureDeprecated.newCCImage(self) deprecatedTip("CCRenderTexture:newCCImage","CCRenderTexture:newImage") return self:newImage() end rawset(CCRenderTexture, "newCCImage", CCRenderTextureDeprecated.newCCImage) --functions of CCRenderTexture will be deprecated end --functions of Sprite will be deprecated begin local CCSpriteDeprecated = { } function CCSpriteDeprecated.setFlipX(self,flag) deprecatedTip("CCSpriteDeprecated:setFlipX","CCSpriteDeprecated:setFlippedX") return self:setFlippedX(flag) end rawset(cc.Sprite, "setFlipX", CCSpriteDeprecated.setFlipX) function CCSpriteDeprecated.setFlipY(self,flag) deprecatedTip("CCSpriteDeprecated:setFlipY","CCSpriteDeprecated:setFlippedY") return self:setFlippedY(flag) end rawset(cc.Sprite, "setFlipY", CCSpriteDeprecated.setFlipY) --functions of Sprite will be deprecated end --functions of Layer will be deprecated begin local CCLayerDeprecated = {} function CCLayerDeprecated.setKeypadEnabled( self, enabled) return self:setKeyboardEnabled(enabled) end rawset(cc.Layer, "setKeypadEnabled", CCLayerDeprecated.setKeypadEnabled ) function CCLayerDeprecated.isKeypadEnabled(self) return self:isKeyboardEnabled() end rawset(cc.Layer, "isKeypadEnabled", CCLayerDeprecated.isKeypadEnabled ) --functions of Layer will be deprecated end --functions of ccs.GUIReader will be deprecated begin local CCSGUIReaderDeprecated = { } function CCSGUIReaderDeprecated.purgeGUIReader() deprecatedTip("ccs.GUIReader:purgeGUIReader","ccs.GUIReader:destroyInstance") return ccs.GUIReader:destroyInstance() end rawset(ccs.GUIReader,"purgeGUIReader",CCSGUIReaderDeprecated.purgeGUIReader) --functions of ccs.GUIReader will be deprecated end --functions of ccs.ActionManagerEx will be deprecated begin local CCSActionManagerExDeprecated = { } function CCSActionManagerExDeprecated.destroyActionManager() deprecatedTip("ccs.ActionManagerEx:destroyActionManager","ccs.ActionManagerEx:destroyInstance") return ccs.ActionManagerEx:destroyInstance() end rawset(ccs.ActionManagerEx,"destroyActionManager",CCSActionManagerExDeprecated.destroyActionManager) --functions of ccs.ActionManagerEx will be deprecated end --functions of ccs.SceneReader will be deprecated begin local CCSSceneReaderDeprecated = { } function CCSSceneReaderDeprecated.destroySceneReader(self) deprecatedTip("ccs.SceneReader:destroySceneReader","ccs.SceneReader:destroyInstance") return self:destroyInstance() end rawset(ccs.SceneReader,"destroySceneReader",CCSSceneReaderDeprecated.destroySceneReader) --functions of ccs.SceneReader will be deprecated end --functions of CCArmatureDataManager will be deprecated begin local CCArmatureDataManagerDeprecated = { } function CCArmatureDataManagerDeprecated.sharedArmatureDataManager() deprecatedTip("CCArmatureDataManager:sharedArmatureDataManager","ccs.ArmatureDataManager:getInstance") return ccs.ArmatureDataManager:getInstance() end rawset(CCArmatureDataManager,"sharedArmatureDataManager",CCArmatureDataManagerDeprecated.sharedArmatureDataManager) function CCArmatureDataManagerDeprecated.purge() deprecatedTip("CCArmatureDataManager:purge","ccs.ArmatureDataManager:destoryInstance") return ccs.ArmatureDataManager:destoryInstance() end rawset(CCArmatureDataManager,"purge",CCArmatureDataManagerDeprecated.purge) --functions of CCArmatureDataManager will be deprecated end --functions of GUIReader will be deprecated begin local GUIReaderDeprecated = { } function GUIReaderDeprecated.shareReader() deprecatedTip("GUIReader:shareReader","ccs.GUIReader:getInstance") return ccs.GUIReader:getInstance() end rawset(GUIReader,"shareReader",GUIReaderDeprecated.shareReader) function GUIReaderDeprecated.purgeGUIReader() deprecatedTip("GUIReader:purgeGUIReader","ccs.GUIReader:destroyInstance") return ccs.GUIReader:destroyInstance() end rawset(GUIReader,"purgeGUIReader",GUIReaderDeprecated.purgeGUIReader) --functions of GUIReader will be deprecated end --functions of SceneReader will be deprecated begin local SceneReaderDeprecated = { } function SceneReaderDeprecated.sharedSceneReader() deprecatedTip("SceneReader:sharedSceneReader","ccs.SceneReader:getInstance") return ccs.SceneReader:getInstance() end rawset(SceneReader,"sharedSceneReader",SceneReaderDeprecated.sharedSceneReader) function SceneReaderDeprecated.purgeSceneReader(self) deprecatedTip("SceneReader:purgeSceneReader","ccs.SceneReader:destroyInstance") return self:destroyInstance() end rawset(SceneReader,"purgeSceneReader",SceneReaderDeprecated.purgeSceneReader) --functions of SceneReader will be deprecated end --functions of CCEGLView will be deprecated begin local CCEGLViewDeprecated = { } function CCEGLViewDeprecated.sharedOpenGLView() deprecatedTip("CCEGLView:sharedOpenGLView","cc.EGLView:getInstance") return cc.EGLView:getInstance() end rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) --functions of CCEGLView will be deprecated end --functions of cc.Node will be deprecated begin local NodeDeprecated = { } function NodeDeprecated.setZOrder(self,zOrder) deprecatedTip("cc.Node:setZOrder","cc.Node:setLocalZOrder") return self:setLocalZOrder(zOrder) end rawset(cc.Node,"setZOrder",NodeDeprecated.setZOrder) function NodeDeprecated.getZOrder(self) deprecatedTip("cc.Node:getZOrder","cc.Node:getLocalZOrder") return self:getLocalZOrder() end rawset(cc.Node,"getZOrder",NodeDeprecated.getZOrder) --functions of cc.Node will be deprecated end ================================================ FILE: Resources/DeprecatedClass.lua ================================================ -- This is the DeprecatedClass DeprecatedClass = {} or DeprecatedClass --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") end --CCProgressTo class will be Deprecated,begin function DeprecatedClass.CCProgressTo() deprecatedTip("CCProgressTo","cc.ProgressTo") return cc.ProgressTo end _G["CCProgressTo"] = DeprecatedClass.CCProgressTo() --CCProgressTo class will be Deprecated,end --CCHide class will be Deprecated,begin function DeprecatedClass.CCHide() deprecatedTip("CCHide","cc.Hide") return cc.Hide end _G["CCHide"] = DeprecatedClass.CCHide() --CCHide class will be Deprecated,end --CCTransitionMoveInB class will be Deprecated,begin function DeprecatedClass.CCTransitionMoveInB() deprecatedTip("CCTransitionMoveInB","cc.TransitionMoveInB") return cc.TransitionMoveInB end _G["CCTransitionMoveInB"] = DeprecatedClass.CCTransitionMoveInB() --CCTransitionMoveInB class will be Deprecated,end --CCEaseSineIn class will be Deprecated,begin function DeprecatedClass.CCEaseSineIn() deprecatedTip("CCEaseSineIn","cc.EaseSineIn") return cc.EaseSineIn end _G["CCEaseSineIn"] = DeprecatedClass.CCEaseSineIn() --CCEaseSineIn class will be Deprecated,end --CCTransitionMoveInL class will be Deprecated,begin function DeprecatedClass.CCTransitionMoveInL() deprecatedTip("CCTransitionMoveInL","cc.TransitionMoveInL") return cc.TransitionMoveInL end _G["CCTransitionMoveInL"] = DeprecatedClass.CCTransitionMoveInL() --CCTransitionMoveInL class will be Deprecated,end --CCEaseInOut class will be Deprecated,begin function DeprecatedClass.CCEaseInOut() deprecatedTip("CCEaseInOut","cc.EaseInOut") return cc.EaseInOut end _G["CCEaseInOut"] = DeprecatedClass.CCEaseInOut() --CCEaseInOut class will be Deprecated,end --SimpleAudioEngine class will be Deprecated,begin function DeprecatedClass.SimpleAudioEngine() deprecatedTip("SimpleAudioEngine","cc.SimpleAudioEngine") return cc.SimpleAudioEngine end _G["SimpleAudioEngine"] = DeprecatedClass.SimpleAudioEngine() --SimpleAudioEngine class will be Deprecated,end --CCTransitionMoveInT class will be Deprecated,begin function DeprecatedClass.CCTransitionMoveInT() deprecatedTip("CCTransitionMoveInT","cc.TransitionMoveInT") return cc.TransitionMoveInT end _G["CCTransitionMoveInT"] = DeprecatedClass.CCTransitionMoveInT() --CCTransitionMoveInT class will be Deprecated,end --CCTransitionMoveInR class will be Deprecated,begin function DeprecatedClass.CCTransitionMoveInR() deprecatedTip("CCTransitionMoveInR","cc.TransitionMoveInR") return cc.TransitionMoveInR end _G["CCTransitionMoveInR"] = DeprecatedClass.CCTransitionMoveInR() --CCTransitionMoveInR class will be Deprecated,end --CCControlHuePicker class will be Deprecated,begin function DeprecatedClass.CCControlHuePicker() deprecatedTip("CCControlHuePicker","cc.ControlHuePicker") return cc.ControlHuePicker end _G["CCControlHuePicker"] = DeprecatedClass.CCControlHuePicker() --CCControlHuePicker class will be Deprecated,end --CCParticleSnow class will be Deprecated,begin function DeprecatedClass.CCParticleSnow() deprecatedTip("CCParticleSnow","cc.ParticleSnow") return cc.ParticleSnow end _G["CCParticleSnow"] = DeprecatedClass.CCParticleSnow() --CCParticleSnow class will be Deprecated,end --CCActionCamera class will be Deprecated,begin function DeprecatedClass.CCActionCamera() deprecatedTip("CCActionCamera","cc.ActionCamera") return cc.ActionCamera end _G["CCActionCamera"] = DeprecatedClass.CCActionCamera() --CCActionCamera class will be Deprecated,end --CCProgressFromTo class will be Deprecated,begin function DeprecatedClass.CCProgressFromTo() deprecatedTip("CCProgressFromTo","cc.ProgressFromTo") return cc.ProgressFromTo end _G["CCProgressFromTo"] = DeprecatedClass.CCProgressFromTo() --CCProgressFromTo class will be Deprecated,end --CCMoveTo class will be Deprecated,begin function DeprecatedClass.CCMoveTo() deprecatedTip("CCMoveTo","cc.MoveTo") return cc.MoveTo end _G["CCMoveTo"] = DeprecatedClass.CCMoveTo() --CCMoveTo class will be Deprecated,end --CCJumpBy class will be Deprecated,begin function DeprecatedClass.CCJumpBy() deprecatedTip("CCJumpBy","cc.JumpBy") return cc.JumpBy end _G["CCJumpBy"] = DeprecatedClass.CCJumpBy() --CCJumpBy class will be Deprecated,end --CCObject class will be Deprecated,begin function DeprecatedClass.CCObject() deprecatedTip("CCObject","cc.Object") return cc.Object end _G["CCObject"] = DeprecatedClass.CCObject() --CCObject class will be Deprecated,end --CCTransitionRotoZoom class will be Deprecated,begin function DeprecatedClass.CCTransitionRotoZoom() deprecatedTip("CCTransitionRotoZoom","cc.TransitionRotoZoom") return cc.TransitionRotoZoom end _G["CCTransitionRotoZoom"] = DeprecatedClass.CCTransitionRotoZoom() --CCTransitionRotoZoom class will be Deprecated,end --CCControlColourPicker class will be Deprecated,begin function DeprecatedClass.CCControlColourPicker() deprecatedTip("CCControlColourPicker","cc.ControlColourPicker") return cc.ControlColourPicker end _G["CCControlColourPicker"] = DeprecatedClass.CCControlColourPicker() --CCControlColourPicker class will be Deprecated,end --CCDirector class will be Deprecated,begin function DeprecatedClass.CCDirector() deprecatedTip("CCDirector","cc.Director") return cc.Director end _G["CCDirector"] = DeprecatedClass.CCDirector() --CCDirector class will be Deprecated,end --CCScheduler class will be Deprecated,begin function DeprecatedClass.CCScheduler() deprecatedTip("CCScheduler","cc.Scheduler") return cc.Scheduler end _G["CCScheduler"] = DeprecatedClass.CCScheduler() --CCScheduler class will be Deprecated,end --CCEaseElasticOut class will be Deprecated,begin function DeprecatedClass.CCEaseElasticOut() deprecatedTip("CCEaseElasticOut","cc.EaseElasticOut") return cc.EaseElasticOut end _G["CCEaseElasticOut"] = DeprecatedClass.CCEaseElasticOut() --CCEaseElasticOut class will be Deprecated,end --CCTableViewCell class will be Deprecated,begin function DeprecatedClass.CCTableViewCell() deprecatedTip("CCTableViewCell","cc.TableViewCell") return cc.TableViewCell end _G["CCTableViewCell"] = DeprecatedClass.CCTableViewCell() --CCTableViewCell class will be Deprecated,end --CCEaseBackOut class will be Deprecated,begin function DeprecatedClass.CCEaseBackOut() deprecatedTip("CCEaseBackOut","cc.EaseBackOut") return cc.EaseBackOut end _G["CCEaseBackOut"] = DeprecatedClass.CCEaseBackOut() --CCEaseBackOut class will be Deprecated,end --CCParticleSystemQuad class will be Deprecated,begin function DeprecatedClass.CCParticleSystemQuad() deprecatedTip("CCParticleSystemQuad","cc.ParticleSystemQuad") return cc.ParticleSystemQuad end _G["CCParticleSystemQuad"] = DeprecatedClass.CCParticleSystemQuad() --CCParticleSystemQuad class will be Deprecated,end --CCMenuItemToggle class will be Deprecated,begin function DeprecatedClass.CCMenuItemToggle() deprecatedTip("CCMenuItemToggle","cc.MenuItemToggle") return cc.MenuItemToggle end _G["CCMenuItemToggle"] = DeprecatedClass.CCMenuItemToggle() --CCMenuItemToggle class will be Deprecated,end --CCStopGrid class will be Deprecated,begin function DeprecatedClass.CCStopGrid() deprecatedTip("CCStopGrid","cc.StopGrid") return cc.StopGrid end _G["CCStopGrid"] = DeprecatedClass.CCStopGrid() --CCStopGrid class will be Deprecated,end --CCTransitionScene class will be Deprecated,begin function DeprecatedClass.CCTransitionScene() deprecatedTip("CCTransitionScene","cc.TransitionScene") return cc.TransitionScene end _G["CCTransitionScene"] = DeprecatedClass.CCTransitionScene() --CCTransitionScene class will be Deprecated,end --CCSkewBy class will be Deprecated,begin function DeprecatedClass.CCSkewBy() deprecatedTip("CCSkewBy","cc.SkewBy") return cc.SkewBy end _G["CCSkewBy"] = DeprecatedClass.CCSkewBy() --CCSkewBy class will be Deprecated,end --CCLayer class will be Deprecated,begin function DeprecatedClass.CCLayer() deprecatedTip("CCLayer","cc.Layer") return cc.Layer end _G["CCLayer"] = DeprecatedClass.CCLayer() --CCLayer class will be Deprecated,end --CCEaseElastic class will be Deprecated,begin function DeprecatedClass.CCEaseElastic() deprecatedTip("CCEaseElastic","cc.EaseElastic") return cc.EaseElastic end _G["CCEaseElastic"] = DeprecatedClass.CCEaseElastic() --CCEaseElastic class will be Deprecated,end --CCTMXTiledMap class will be Deprecated,begin function DeprecatedClass.CCTMXTiledMap() deprecatedTip("CCTMXTiledMap","cc.TMXTiledMap") return cc.TMXTiledMap end _G["CCTMXTiledMap"] = DeprecatedClass.CCTMXTiledMap() --CCTMXTiledMap class will be Deprecated,end --CCGrid3DAction class will be Deprecated,begin function DeprecatedClass.CCGrid3DAction() deprecatedTip("CCGrid3DAction","cc.Grid3DAction") return cc.Grid3DAction end _G["CCGrid3DAction"] = DeprecatedClass.CCGrid3DAction() --CCGrid3DAction class will be Deprecated,end --CCFadeIn class will be Deprecated,begin function DeprecatedClass.CCFadeIn() deprecatedTip("CCFadeIn","cc.FadeIn") return cc.FadeIn end _G["CCFadeIn"] = DeprecatedClass.CCFadeIn() --CCFadeIn class will be Deprecated,end --CCNodeRGBA class will be Deprecated,begin function DeprecatedClass.CCNodeRGBA() deprecatedTip("CCNodeRGBA","cc.Node") return cc.Node end _G["CCNodeRGBA"] = DeprecatedClass.CCNodeRGBA() --CCNodeRGBA class will be Deprecated,end --NodeRGBA class will be Deprecated,begin function DeprecatedClass.NodeRGBA() deprecatedTip("cc.NodeRGBA","cc.Node") return cc.Node end _G["cc"]["NodeRGBA"] = DeprecatedClass.NodeRGBA() --NodeRGBA class will be Deprecated,end --CCAnimationCache class will be Deprecated,begin function DeprecatedClass.CCAnimationCache() deprecatedTip("CCAnimationCache","cc.AnimationCache") return cc.AnimationCache end _G["CCAnimationCache"] = DeprecatedClass.CCAnimationCache() --CCAnimationCache class will be Deprecated,end --CCFlipY3D class will be Deprecated,begin function DeprecatedClass.CCFlipY3D() deprecatedTip("CCFlipY3D","cc.FlipY3D") return cc.FlipY3D end _G["CCFlipY3D"] = DeprecatedClass.CCFlipY3D() --CCFlipY3D class will be Deprecated,end --CCEaseSineInOut class will be Deprecated,begin function DeprecatedClass.CCEaseSineInOut() deprecatedTip("CCEaseSineInOut","cc.EaseSineInOut") return cc.EaseSineInOut end _G["CCEaseSineInOut"] = DeprecatedClass.CCEaseSineInOut() --CCEaseSineInOut class will be Deprecated,end --CCTransitionFlipAngular class will be Deprecated,begin function DeprecatedClass.CCTransitionFlipAngular() deprecatedTip("CCTransitionFlipAngular","cc.TransitionFlipAngular") return cc.TransitionFlipAngular end _G["CCTransitionFlipAngular"] = DeprecatedClass.CCTransitionFlipAngular() --CCTransitionFlipAngular class will be Deprecated,end --CCControl class will be Deprecated,begin function DeprecatedClass.CCControl() deprecatedTip("CCControl","cc.Control") return cc.Control end _G["CCControl"] = DeprecatedClass.CCControl() --CCControl class will be Deprecated,end --CCEaseElasticInOut class will be Deprecated,begin function DeprecatedClass.CCEaseElasticInOut() deprecatedTip("CCEaseElasticInOut","cc.EaseElasticInOut") return cc.EaseElasticInOut end _G["CCEaseElasticInOut"] = DeprecatedClass.CCEaseElasticInOut() --CCEaseElasticInOut class will be Deprecated,end --CCEaseBounce class will be Deprecated,begin function DeprecatedClass.CCEaseBounce() deprecatedTip("CCEaseBounce","cc.EaseBounce") return cc.EaseBounce end _G["CCEaseBounce"] = DeprecatedClass.CCEaseBounce() --CCEaseBounce class will be Deprecated,end --CCShow class will be Deprecated,begin function DeprecatedClass.CCShow() deprecatedTip("CCShow","cc.Show") return cc.Show end _G["CCShow"] = DeprecatedClass.CCShow() --CCShow class will be Deprecated,end --CCEditBox class will be Deprecated,begin function DeprecatedClass.CCEditBox() deprecatedTip("CCEditBox","cc.EditBox") return cc.EditBox end _G["CCEditBox"] = DeprecatedClass.CCEditBox() --CCEditBox class will be Deprecated,end --CCFadeOut class will be Deprecated,begin function DeprecatedClass.CCFadeOut() deprecatedTip("CCFadeOut","cc.FadeOut") return cc.FadeOut end _G["CCFadeOut"] = DeprecatedClass.CCFadeOut() --CCFadeOut class will be Deprecated,end --CCCallFunc class will be Deprecated,begin function DeprecatedClass.CCCallFunc() deprecatedTip("CCCallFunc","cc.CallFunc") return cc.CallFunc end _G["CCCallFunc"] = DeprecatedClass.CCCallFunc() --CCCallFunc class will be Deprecated,end --CCWaves3D class will be Deprecated,begin function DeprecatedClass.CCWaves3D() deprecatedTip("CCWaves3D","cc.Waves3D") return cc.Waves3D end _G["CCWaves3D"] = DeprecatedClass.CCWaves3D() --CCWaves3D class will be Deprecated,end --CCFlipX3D class will be Deprecated,begin function DeprecatedClass.CCFlipX3D() deprecatedTip("CCFlipX3D","cc.FlipX3D") return cc.FlipX3D end _G["CCFlipX3D"] = DeprecatedClass.CCFlipX3D() --CCFlipX3D class will be Deprecated,end --CCParticleFireworks class will be Deprecated,begin function DeprecatedClass.CCParticleFireworks() deprecatedTip("CCParticleFireworks","cc.ParticleFireworks") return cc.ParticleFireworks end _G["CCParticleFireworks"] = DeprecatedClass.CCParticleFireworks() --CCParticleFireworks class will be Deprecated,end --CCMenuItemImage class will be Deprecated,begin function DeprecatedClass.CCMenuItemImage() deprecatedTip("CCMenuItemImage","cc.MenuItemImage") return cc.MenuItemImage end _G["CCMenuItemImage"] = DeprecatedClass.CCMenuItemImage() --CCMenuItemImage class will be Deprecated,end --CCParticleFire class will be Deprecated,begin function DeprecatedClass.CCParticleFire() deprecatedTip("CCParticleFire","cc.ParticleFire") return cc.ParticleFire end _G["CCParticleFire"] = DeprecatedClass.CCParticleFire() --CCParticleFire class will be Deprecated,end --CCMenuItem class will be Deprecated,begin function DeprecatedClass.CCMenuItem() deprecatedTip("CCMenuItem","cc.MenuItem") return cc.MenuItem end _G["CCMenuItem"] = DeprecatedClass.CCMenuItem() --CCMenuItem class will be Deprecated,end --CCActionEase class will be Deprecated,begin function DeprecatedClass.CCActionEase() deprecatedTip("CCActionEase","cc.ActionEase") return cc.ActionEase end _G["CCActionEase"] = DeprecatedClass.CCActionEase() --CCActionEase class will be Deprecated,end --CCTransitionSceneOriented class will be Deprecated,begin function DeprecatedClass.CCTransitionSceneOriented() deprecatedTip("CCTransitionSceneOriented","cc.TransitionSceneOriented") return cc.TransitionSceneOriented end _G["CCTransitionSceneOriented"] = DeprecatedClass.CCTransitionSceneOriented() --CCTransitionSceneOriented class will be Deprecated,end --CCTransitionZoomFlipAngular class will be Deprecated,begin function DeprecatedClass.CCTransitionZoomFlipAngular() deprecatedTip("CCTransitionZoomFlipAngular","cc.TransitionZoomFlipAngular") return cc.TransitionZoomFlipAngular end _G["CCTransitionZoomFlipAngular"] = DeprecatedClass.CCTransitionZoomFlipAngular() --CCTransitionZoomFlipAngular class will be Deprecated,end --CCEaseIn class will be Deprecated,begin function DeprecatedClass.CCEaseIn() deprecatedTip("CCEaseIn","cc.EaseIn") return cc.EaseIn end _G["CCEaseIn"] = DeprecatedClass.CCEaseIn() --CCEaseIn class will be Deprecated,end --CCEaseExponentialInOut class will be Deprecated,begin function DeprecatedClass.CCEaseExponentialInOut() deprecatedTip("CCEaseExponentialInOut","cc.EaseExponentialInOut") return cc.EaseExponentialInOut end _G["CCEaseExponentialInOut"] = DeprecatedClass.CCEaseExponentialInOut() --CCEaseExponentialInOut class will be Deprecated,end --CCTransitionFlipX class will be Deprecated,begin function DeprecatedClass.CCTransitionFlipX() deprecatedTip("CCTransitionFlipX","cc.TransitionFlipX") return cc.TransitionFlipX end _G["CCTransitionFlipX"] = DeprecatedClass.CCTransitionFlipX() --CCTransitionFlipX class will be Deprecated,end --CCEaseExponentialOut class will be Deprecated,begin function DeprecatedClass.CCEaseExponentialOut() deprecatedTip("CCEaseExponentialOut","cc.EaseExponentialOut") return cc.EaseExponentialOut end _G["CCEaseExponentialOut"] = DeprecatedClass.CCEaseExponentialOut() --CCEaseExponentialOut class will be Deprecated,end --CCLabel class will be Deprecated,begin function DeprecatedClass.CCLabel() deprecatedTip("CCLabel","cc.Label") return cc.Label end _G["CCLabel"] = DeprecatedClass.CCLabel() --CCLabel class will be Deprecated,end --CCApplication class will be Deprecated,begin function DeprecatedClass.CCApplication() deprecatedTip("CCApplication","cc.Application") return cc.Application end _G["CCApplication"] = DeprecatedClass.CCApplication() --CCApplication class will be Deprecated,end --CCControlSlider class will be Deprecated,begin function DeprecatedClass.CCControlSlider() deprecatedTip("CCControlSlider","cc.ControlSlider") return cc.ControlSlider end _G["CCControlSlider"] = DeprecatedClass.CCControlSlider() --CCControlSlider class will be Deprecated,end --CCDelayTime class will be Deprecated,begin function DeprecatedClass.CCDelayTime() deprecatedTip("CCDelayTime","cc.DelayTime") return cc.DelayTime end _G["CCDelayTime"] = DeprecatedClass.CCDelayTime() --CCDelayTime class will be Deprecated,end --CCLabelAtlas class will be Deprecated,begin function DeprecatedClass.CCLabelAtlas() deprecatedTip("CCLabelAtlas","cc.LabelAtlas") return cc.LabelAtlas end _G["CCLabelAtlas"] = DeprecatedClass.CCLabelAtlas() --CCLabelAtlas class will be Deprecated,end --CCLabelBMFont class will be Deprecated,begin function DeprecatedClass.CCLabelBMFont() deprecatedTip("CCLabelBMFont","cc.LabelBMFont") return cc.LabelBMFont end _G["CCLabelBMFont"] = DeprecatedClass.CCLabelBMFont() --CCLabelBMFont class will be Deprecated,end --CCScale9Sprite class will be Deprecated,begin function DeprecatedClass.CCScale9Sprite() deprecatedTip("CCScale9Sprite","cc.Scale9Sprite") return cc.Scale9Sprite end _G["CCScale9Sprite"] = DeprecatedClass.CCScale9Sprite() --CCScale9Sprite class will be Deprecated,end --CCFadeOutTRTiles class will be Deprecated,begin function DeprecatedClass.CCFadeOutTRTiles() deprecatedTip("CCFadeOutTRTiles","cc.FadeOutTRTiles") return cc.FadeOutTRTiles end _G["CCFadeOutTRTiles"] = DeprecatedClass.CCFadeOutTRTiles() --CCFadeOutTRTiles class will be Deprecated,end --CCEaseElasticIn class will be Deprecated,begin function DeprecatedClass.CCEaseElasticIn() deprecatedTip("CCEaseElasticIn","cc.EaseElasticIn") return cc.EaseElasticIn end _G["CCEaseElasticIn"] = DeprecatedClass.CCEaseElasticIn() --CCEaseElasticIn class will be Deprecated,end --CCParticleSpiral class will be Deprecated,begin function DeprecatedClass.CCParticleSpiral() deprecatedTip("CCParticleSpiral","cc.ParticleSpiral") return cc.ParticleSpiral end _G["CCParticleSpiral"] = DeprecatedClass.CCParticleSpiral() --CCParticleSpiral class will be Deprecated,end --CCBReader class will be Deprecated,begin function DeprecatedClass.CCBReader() deprecatedTip("CCBReader","cc.BReader") return cc.BReader end _G["CCBReader"] = DeprecatedClass.CCBReader() --CCBReader class will be Deprecated,end --CCFiniteTimeAction class will be Deprecated,begin function DeprecatedClass.CCFiniteTimeAction() deprecatedTip("CCFiniteTimeAction","cc.FiniteTimeAction") return cc.FiniteTimeAction end _G["CCFiniteTimeAction"] = DeprecatedClass.CCFiniteTimeAction() --CCFiniteTimeAction class will be Deprecated,end --CCFadeOutDownTiles class will be Deprecated,begin function DeprecatedClass.CCFadeOutDownTiles() deprecatedTip("CCFadeOutDownTiles","cc.FadeOutDownTiles") return cc.FadeOutDownTiles end _G["CCFadeOutDownTiles"] = DeprecatedClass.CCFadeOutDownTiles() --CCFadeOutDownTiles class will be Deprecated,end --CCJumpTiles3D class will be Deprecated,begin function DeprecatedClass.CCJumpTiles3D() deprecatedTip("CCJumpTiles3D","cc.JumpTiles3D") return cc.JumpTiles3D end _G["CCJumpTiles3D"] = DeprecatedClass.CCJumpTiles3D() --CCJumpTiles3D class will be Deprecated,end --CCEaseBackIn class will be Deprecated,begin function DeprecatedClass.CCEaseBackIn() deprecatedTip("CCEaseBackIn","cc.EaseBackIn") return cc.EaseBackIn end _G["CCEaseBackIn"] = DeprecatedClass.CCEaseBackIn() --CCEaseBackIn class will be Deprecated,end --CCSpriteBatchNode class will be Deprecated,begin function DeprecatedClass.CCSpriteBatchNode() deprecatedTip("CCSpriteBatchNode","cc.SpriteBatchNode") return cc.SpriteBatchNode end _G["CCSpriteBatchNode"] = DeprecatedClass.CCSpriteBatchNode() --CCSpriteBatchNode class will be Deprecated,end --CCParticleSystem class will be Deprecated,begin function DeprecatedClass.CCParticleSystem() deprecatedTip("CCParticleSystem","cc.ParticleSystem") return cc.ParticleSystem end _G["CCParticleSystem"] = DeprecatedClass.CCParticleSystem() --CCParticleSystem class will be Deprecated,end --CCActionTween class will be Deprecated,begin function DeprecatedClass.CCActionTween() deprecatedTip("CCActionTween","cc.ActionTween") return cc.ActionTween end _G["CCActionTween"] = DeprecatedClass.CCActionTween() --CCActionTween class will be Deprecated,end --CCTransitionFadeDown class will be Deprecated,begin function DeprecatedClass.CCTransitionFadeDown() deprecatedTip("CCTransitionFadeDown","cc.TransitionFadeDown") return cc.TransitionFadeDown end _G["CCTransitionFadeDown"] = DeprecatedClass.CCTransitionFadeDown() --CCTransitionFadeDown class will be Deprecated,end --CCParticleSun class will be Deprecated,begin function DeprecatedClass.CCParticleSun() deprecatedTip("CCParticleSun","cc.ParticleSun") return cc.ParticleSun end _G["CCParticleSun"] = DeprecatedClass.CCParticleSun() --CCParticleSun class will be Deprecated,end --CCTransitionProgressHorizontal class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressHorizontal() deprecatedTip("CCTransitionProgressHorizontal","cc.TransitionProgressHorizontal") return cc.TransitionProgressHorizontal end _G["CCTransitionProgressHorizontal"] = DeprecatedClass.CCTransitionProgressHorizontal() --CCTransitionProgressHorizontal class will be Deprecated,end --CCRipple3D class will be Deprecated,begin function DeprecatedClass.CCRipple3D() deprecatedTip("CCRipple3D","cc.Ripple3D") return cc.Ripple3D end _G["CCRipple3D"] = DeprecatedClass.CCRipple3D() --CCRipple3D class will be Deprecated,end --CCTMXLayer class will be Deprecated,begin function DeprecatedClass.CCTMXLayer() deprecatedTip("CCTMXLayer","cc.TMXLayer") return cc.TMXLayer end _G["CCTMXLayer"] = DeprecatedClass.CCTMXLayer() --CCTMXLayer class will be Deprecated,end --CCFlipX class will be Deprecated,begin function DeprecatedClass.CCFlipX() deprecatedTip("CCFlipX","cc.FlipX") return cc.FlipX end _G["CCFlipX"] = DeprecatedClass.CCFlipX() --CCFlipX class will be Deprecated,end --CCFlipY class will be Deprecated,begin function DeprecatedClass.CCFlipY() deprecatedTip("CCFlipY","cc.FlipY") return cc.FlipY end _G["CCFlipY"] = DeprecatedClass.CCFlipY() --CCFlipY class will be Deprecated,end --CCTransitionSplitCols class will be Deprecated,begin function DeprecatedClass.CCTransitionSplitCols() deprecatedTip("CCTransitionSplitCols","cc.TransitionSplitCols") return cc.TransitionSplitCols end _G["CCTransitionSplitCols"] = DeprecatedClass.CCTransitionSplitCols() --CCTransitionSplitCols class will be Deprecated,end --CCTimer class will be Deprecated,begin function DeprecatedClass.CCTimer() deprecatedTip("CCTimer","cc.Timer") return cc.Timer end _G["CCTimer"] = DeprecatedClass.CCTimer() --CCTimer class will be Deprecated,end --CCFadeTo class will be Deprecated,begin function DeprecatedClass.CCFadeTo() deprecatedTip("CCFadeTo","cc.FadeTo") return cc.FadeTo end _G["CCFadeTo"] = DeprecatedClass.CCFadeTo() --CCFadeTo class will be Deprecated,end --CCBAnimationManager class will be Deprecated,begin function DeprecatedClass.CCBAnimationManager() deprecatedTip("CCBAnimationManager","cc.BAnimationManager") return cc.BAnimationManager end _G["CCBAnimationManager"] = DeprecatedClass.CCBAnimationManager() --CCBAnimationManager class will be Deprecated,end --CCRepeatForever class will be Deprecated,begin function DeprecatedClass.CCRepeatForever() deprecatedTip("CCRepeatForever","cc.RepeatForever") return cc.RepeatForever end _G["CCRepeatForever"] = DeprecatedClass.CCRepeatForever() --CCRepeatForever class will be Deprecated,end --CCPlace class will be Deprecated,begin function DeprecatedClass.CCPlace() deprecatedTip("CCPlace","cc.Place") return cc.Place end _G["CCPlace"] = DeprecatedClass.CCPlace() --CCPlace class will be Deprecated,end --CCScrollView class will be Deprecated,begin function DeprecatedClass.CCScrollView() deprecatedTip("CCScrollView","cc.ScrollView") return cc.ScrollView end _G["CCScrollView"] = DeprecatedClass.CCScrollView() --CCScrollView class will be Deprecated,end --CCGLProgram class will be Deprecated,begin function DeprecatedClass.CCGLProgram() deprecatedTip("CCGLProgram","cc.GLProgram") return cc.GLProgram end _G["CCGLProgram"] = DeprecatedClass.CCGLProgram() --CCGLProgram class will be Deprecated,end --CCEaseBounceOut class will be Deprecated,begin function DeprecatedClass.CCEaseBounceOut() deprecatedTip("CCEaseBounceOut","cc.EaseBounceOut") return cc.EaseBounceOut end _G["CCEaseBounceOut"] = DeprecatedClass.CCEaseBounceOut() --CCEaseBounceOut class will be Deprecated,end --CCCardinalSplineBy class will be Deprecated,begin function DeprecatedClass.CCCardinalSplineBy() deprecatedTip("CCCardinalSplineBy","cc.CardinalSplineBy") return cc.CardinalSplineBy end _G["CCCardinalSplineBy"] = DeprecatedClass.CCCardinalSplineBy() --CCCardinalSplineBy class will be Deprecated,end --CCSpriteFrameCache class will be Deprecated,begin function DeprecatedClass.CCSpriteFrameCache() deprecatedTip("CCSpriteFrameCache","cc.SpriteFrameCache") return cc.SpriteFrameCache end _G["CCSpriteFrameCache"] = DeprecatedClass.CCSpriteFrameCache() --CCSpriteFrameCache class will be Deprecated,end --CCTransitionShrinkGrow class will be Deprecated,begin function DeprecatedClass.CCTransitionShrinkGrow() deprecatedTip("CCTransitionShrinkGrow","cc.TransitionShrinkGrow") return cc.TransitionShrinkGrow end _G["CCTransitionShrinkGrow"] = DeprecatedClass.CCTransitionShrinkGrow() --CCTransitionShrinkGrow class will be Deprecated,end --CCSplitCols class will be Deprecated,begin function DeprecatedClass.CCSplitCols() deprecatedTip("CCSplitCols","cc.SplitCols") return cc.SplitCols end _G["CCSplitCols"] = DeprecatedClass.CCSplitCols() --CCSplitCols class will be Deprecated,end --CCClippingNode class will be Deprecated,begin function DeprecatedClass.CCClippingNode() deprecatedTip("CCClippingNode","cc.ClippingNode") return cc.ClippingNode end _G["CCClippingNode"] = DeprecatedClass.CCClippingNode() --CCClippingNode class will be Deprecated,end --CCEaseBounceInOut class will be Deprecated,begin function DeprecatedClass.CCEaseBounceInOut() deprecatedTip("CCEaseBounceInOut","cc.EaseBounceInOut") return cc.EaseBounceInOut end _G["CCEaseBounceInOut"] = DeprecatedClass.CCEaseBounceInOut() --CCEaseBounceInOut class will be Deprecated,end --CCLiquid class will be Deprecated,begin function DeprecatedClass.CCLiquid() deprecatedTip("CCLiquid","cc.Liquid") return cc.Liquid end _G["CCLiquid"] = DeprecatedClass.CCLiquid() --CCLiquid class will be Deprecated,end --CCParticleFlower class will be Deprecated,begin function DeprecatedClass.CCParticleFlower() deprecatedTip("CCParticleFlower","cc.ParticleFlower") return cc.ParticleFlower end _G["CCParticleFlower"] = DeprecatedClass.CCParticleFlower() --CCParticleFlower class will be Deprecated,end --CCTableView class will be Deprecated,begin function DeprecatedClass.CCTableView() deprecatedTip("CCTableView","cc.TableView") return cc.TableView end _G["CCTableView"] = DeprecatedClass.CCTableView() --CCTableView class will be Deprecated,end --CCParticleSmoke class will be Deprecated,begin function DeprecatedClass.CCParticleSmoke() deprecatedTip("CCParticleSmoke","cc.ParticleSmoke") return cc.ParticleSmoke end _G["CCParticleSmoke"] = DeprecatedClass.CCParticleSmoke() --CCParticleSmoke class will be Deprecated,end --CCImage class will be Deprecated,begin function DeprecatedClass.CCImage() deprecatedTip("CCImage","cc.Image") return cc.Image end _G["CCImage"] = DeprecatedClass.CCImage() --CCImage class will be Deprecated,end --CCTurnOffTiles class will be Deprecated,begin function DeprecatedClass.CCTurnOffTiles() deprecatedTip("CCTurnOffTiles","cc.TurnOffTiles") return cc.TurnOffTiles end _G["CCTurnOffTiles"] = DeprecatedClass.CCTurnOffTiles() --CCTurnOffTiles class will be Deprecated,end --CCBlink class will be Deprecated,begin function DeprecatedClass.CCBlink() deprecatedTip("CCBlink","cc.Blink") return cc.Blink end _G["CCBlink"] = DeprecatedClass.CCBlink() --CCBlink class will be Deprecated,end --CCShaderCache class will be Deprecated,begin function DeprecatedClass.CCShaderCache() deprecatedTip("CCShaderCache","cc.ShaderCache") return cc.ShaderCache end _G["CCShaderCache"] = DeprecatedClass.CCShaderCache() --CCShaderCache class will be Deprecated,end --CCJumpTo class will be Deprecated,begin function DeprecatedClass.CCJumpTo() deprecatedTip("CCJumpTo","cc.JumpTo") return cc.JumpTo end _G["CCJumpTo"] = DeprecatedClass.CCJumpTo() --CCJumpTo class will be Deprecated,end --CCAtlasNode class will be Deprecated,begin function DeprecatedClass.CCAtlasNode() deprecatedTip("CCAtlasNode","cc.AtlasNode") return cc.AtlasNode end _G["CCAtlasNode"] = DeprecatedClass.CCAtlasNode() --CCAtlasNode class will be Deprecated,end --CCTransitionJumpZoom class will be Deprecated,begin function DeprecatedClass.CCTransitionJumpZoom() deprecatedTip("CCTransitionJumpZoom","cc.TransitionJumpZoom") return cc.TransitionJumpZoom end _G["CCTransitionJumpZoom"] = DeprecatedClass.CCTransitionJumpZoom() --CCTransitionJumpZoom class will be Deprecated,end --CCTransitionProgressVertical class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressVertical() deprecatedTip("CCTransitionProgressVertical","cc.TransitionProgressVertical") return cc.TransitionProgressVertical end _G["CCTransitionProgressVertical"] = DeprecatedClass.CCTransitionProgressVertical() --CCTransitionProgressVertical class will be Deprecated,end --CCAnimationFrame class will be Deprecated,begin function DeprecatedClass.CCAnimationFrame() deprecatedTip("CCAnimationFrame","cc.AnimationFrame") return cc.AnimationFrame end _G["CCAnimationFrame"] = DeprecatedClass.CCAnimationFrame() --CCAnimationFrame class will be Deprecated,end --CCTintTo class will be Deprecated,begin function DeprecatedClass.CCTintTo() deprecatedTip("CCTintTo","cc.TintTo") return cc.TintTo end _G["CCTintTo"] = DeprecatedClass.CCTintTo() --CCTintTo class will be Deprecated,end --CCTiledGrid3DAction class will be Deprecated,begin function DeprecatedClass.CCTiledGrid3DAction() deprecatedTip("CCTiledGrid3DAction","cc.TiledGrid3DAction") return cc.TiledGrid3DAction end _G["CCTiledGrid3DAction"] = DeprecatedClass.CCTiledGrid3DAction() --CCTiledGrid3DAction class will be Deprecated,end --CCTMXTilesetInfo class will be Deprecated,begin function DeprecatedClass.CCTMXTilesetInfo() deprecatedTip("CCTMXTilesetInfo","cc.TMXTilesetInfo") return cc.TMXTilesetInfo end _G["CCTMXTilesetInfo"] = DeprecatedClass.CCTMXTilesetInfo() --CCTMXTilesetInfo class will be Deprecated,end --CCTMXObjectGroup class will be Deprecated,begin function DeprecatedClass.CCTMXObjectGroup() deprecatedTip("CCTMXObjectGroup","cc.TMXObjectGroup") return cc.TMXObjectGroup end _G["CCTMXObjectGroup"] = DeprecatedClass.CCTMXObjectGroup() --CCTMXObjectGroup class will be Deprecated,end --CCParticleGalaxy class will be Deprecated,begin function DeprecatedClass.CCParticleGalaxy() deprecatedTip("CCParticleGalaxy","cc.ParticleGalaxy") return cc.ParticleGalaxy end _G["CCParticleGalaxy"] = DeprecatedClass.CCParticleGalaxy() --CCParticleGalaxy class will be Deprecated,end --CCTwirl class will be Deprecated,begin function DeprecatedClass.CCTwirl() deprecatedTip("CCTwirl","cc.Twirl") return cc.Twirl end _G["CCTwirl"] = DeprecatedClass.CCTwirl() --CCTwirl class will be Deprecated,end --CCMenuItemLabel class will be Deprecated,begin function DeprecatedClass.CCMenuItemLabel() deprecatedTip("CCMenuItemLabel","cc.MenuItemLabel") return cc.MenuItemLabel end _G["CCMenuItemLabel"] = DeprecatedClass.CCMenuItemLabel() --CCMenuItemLabel class will be Deprecated,end --CCLayerColor class will be Deprecated,begin function DeprecatedClass.CCLayerColor() deprecatedTip("CCLayerColor","cc.LayerColor") return cc.LayerColor end _G["CCLayerColor"] = DeprecatedClass.CCLayerColor() --CCLayerColor class will be Deprecated,end --CCFadeOutBLTiles class will be Deprecated,begin function DeprecatedClass.CCFadeOutBLTiles() deprecatedTip("CCFadeOutBLTiles","cc.FadeOutBLTiles") return cc.FadeOutBLTiles end _G["CCFadeOutBLTiles"] = DeprecatedClass.CCFadeOutBLTiles() --CCFadeOutBLTiles class will be Deprecated,end --CCTransitionProgress class will be Deprecated,begin function DeprecatedClass.CCTransitionProgress() deprecatedTip("CCTransitionProgress","cc.TransitionProgress") return cc.TransitionProgress end _G["CCTransitionProgress"] = DeprecatedClass.CCTransitionProgress() --CCTransitionProgress class will be Deprecated,end --CCEaseRateAction class will be Deprecated,begin function DeprecatedClass.CCEaseRateAction() deprecatedTip("CCEaseRateAction","cc.EaseRateAction") return cc.EaseRateAction end _G["CCEaseRateAction"] = DeprecatedClass.CCEaseRateAction() --CCEaseRateAction class will be Deprecated,end --CCLayerGradient class will be Deprecated,begin function DeprecatedClass.CCLayerGradient() deprecatedTip("CCLayerGradient","cc.LayerGradient") return cc.LayerGradient end _G["CCLayerGradient"] = DeprecatedClass.CCLayerGradient() --CCLayerGradient class will be Deprecated,end --CCMenuItemSprite class will be Deprecated,begin function DeprecatedClass.CCMenuItemSprite() deprecatedTip("CCMenuItemSprite","cc.MenuItemSprite") return cc.MenuItemSprite end _G["CCMenuItemSprite"] = DeprecatedClass.CCMenuItemSprite() --CCMenuItemSprite class will be Deprecated,end --CCNode class will be Deprecated,begin function DeprecatedClass.CCNode() deprecatedTip("CCNode","cc.Node") return cc.Node end _G["CCNode"] = DeprecatedClass.CCNode() --CCNode class will be Deprecated,end --CCToggleVisibility class will be Deprecated,begin function DeprecatedClass.CCToggleVisibility() deprecatedTip("CCToggleVisibility","cc.ToggleVisibility") return cc.ToggleVisibility end _G["CCToggleVisibility"] = DeprecatedClass.CCToggleVisibility() --CCToggleVisibility class will be Deprecated,end --CCRepeat class will be Deprecated,begin function DeprecatedClass.CCRepeat() deprecatedTip("CCRepeat","cc.Repeat") return cc.Repeat end _G["CCRepeat"] = DeprecatedClass.CCRepeat() --CCRepeat class will be Deprecated,end --CCRenderTexture class will be Deprecated,begin function DeprecatedClass.CCRenderTexture() deprecatedTip("CCRenderTexture","cc.RenderTexture") return cc.RenderTexture end _G["CCRenderTexture"] = DeprecatedClass.CCRenderTexture() --CCRenderTexture class will be Deprecated,end --CCTransitionFlipY class will be Deprecated,begin function DeprecatedClass.CCTransitionFlipY() deprecatedTip("CCTransitionFlipY","cc.TransitionFlipY") return cc.TransitionFlipY end _G["CCTransitionFlipY"] = DeprecatedClass.CCTransitionFlipY() --CCTransitionFlipY class will be Deprecated,end --CCLayerMultiplex class will be Deprecated,begin function DeprecatedClass.CCLayerMultiplex() deprecatedTip("CCLayerMultiplex","cc.LayerMultiplex") return cc.LayerMultiplex end _G["CCLayerMultiplex"] = DeprecatedClass.CCLayerMultiplex() --CCLayerMultiplex class will be Deprecated,end --CCTMXLayerInfo class will be Deprecated,begin function DeprecatedClass.CCTMXLayerInfo() deprecatedTip("CCTMXLayerInfo","cc.TMXLayerInfo") return cc.TMXLayerInfo end _G["CCTMXLayerInfo"] = DeprecatedClass.CCTMXLayerInfo() --CCTMXLayerInfo class will be Deprecated,end --CCEaseBackInOut class will be Deprecated,begin function DeprecatedClass.CCEaseBackInOut() deprecatedTip("CCEaseBackInOut","cc.EaseBackInOut") return cc.EaseBackInOut end _G["CCEaseBackInOut"] = DeprecatedClass.CCEaseBackInOut() --CCEaseBackInOut class will be Deprecated,end --CCActionInstant class will be Deprecated,begin function DeprecatedClass.CCActionInstant() deprecatedTip("CCActionInstant","cc.ActionInstant") return cc.ActionInstant end _G["CCActionInstant"] = DeprecatedClass.CCActionInstant() --CCActionInstant class will be Deprecated,end --CCTargetedAction class will be Deprecated,begin function DeprecatedClass.CCTargetedAction() deprecatedTip("CCTargetedAction","cc.TargetedAction") return cc.TargetedAction end _G["CCTargetedAction"] = DeprecatedClass.CCTargetedAction() --CCTargetedAction class will be Deprecated,end --CCDrawNode class will be Deprecated,begin function DeprecatedClass.CCDrawNode() deprecatedTip("CCDrawNode","cc.DrawNode") return cc.DrawNode end _G["CCDrawNode"] = DeprecatedClass.CCDrawNode() --CCDrawNode class will be Deprecated,end --CCTransitionTurnOffTiles class will be Deprecated,begin function DeprecatedClass.CCTransitionTurnOffTiles() deprecatedTip("CCTransitionTurnOffTiles","cc.TransitionTurnOffTiles") return cc.TransitionTurnOffTiles end _G["CCTransitionTurnOffTiles"] = DeprecatedClass.CCTransitionTurnOffTiles() --CCTransitionTurnOffTiles class will be Deprecated,end --CCRotateTo class will be Deprecated,begin function DeprecatedClass.CCRotateTo() deprecatedTip("CCRotateTo","cc.RotateTo") return cc.RotateTo end _G["CCRotateTo"] = DeprecatedClass.CCRotateTo() --CCRotateTo class will be Deprecated,end --CCTransitionSplitRows class will be Deprecated,begin function DeprecatedClass.CCTransitionSplitRows() deprecatedTip("CCTransitionSplitRows","cc.TransitionSplitRows") return cc.TransitionSplitRows end _G["CCTransitionSplitRows"] = DeprecatedClass.CCTransitionSplitRows() --CCTransitionSplitRows class will be Deprecated,end --CCTransitionProgressRadialCCW class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressRadialCCW() deprecatedTip("CCTransitionProgressRadialCCW","cc.TransitionProgressRadialCCW") return cc.TransitionProgressRadialCCW end _G["CCTransitionProgressRadialCCW"] = DeprecatedClass.CCTransitionProgressRadialCCW() --CCTransitionProgressRadialCCW class will be Deprecated,end --CCScaleTo class will be Deprecated,begin function DeprecatedClass.CCScaleTo() deprecatedTip("CCScaleTo","cc.ScaleTo") return cc.ScaleTo end _G["CCScaleTo"] = DeprecatedClass.CCScaleTo() --CCScaleTo class will be Deprecated,end --CCTransitionPageTurn class will be Deprecated,begin function DeprecatedClass.CCTransitionPageTurn() deprecatedTip("CCTransitionPageTurn","cc.TransitionPageTurn") return cc.TransitionPageTurn end _G["CCTransitionPageTurn"] = DeprecatedClass.CCTransitionPageTurn() --CCTransitionPageTurn class will be Deprecated,end --CCParticleExplosion class will be Deprecated,begin function DeprecatedClass.CCParticleExplosion() deprecatedTip("CCParticleExplosion","cc.ParticleExplosion") return cc.ParticleExplosion end _G["CCParticleExplosion"] = DeprecatedClass.CCParticleExplosion() --CCParticleExplosion class will be Deprecated,end --CCMenu class will be Deprecated,begin function DeprecatedClass.CCMenu() deprecatedTip("CCMenu","cc.Menu") return cc.Menu end _G["CCMenu"] = DeprecatedClass.CCMenu() --CCMenu class will be Deprecated,end --CCTexture2D class will be Deprecated,begin function DeprecatedClass.CCTexture2D() deprecatedTip("CCTexture2D","cc.Texture2D") return cc.Texture2D end _G["CCTexture2D"] = DeprecatedClass.CCTexture2D() --CCTexture2D class will be Deprecated,end --CCActionManager class will be Deprecated,begin function DeprecatedClass.CCActionManager() deprecatedTip("CCActionManager","cc.ActionManager") return cc.ActionManager end _G["CCActionManager"] = DeprecatedClass.CCActionManager() --CCActionManager class will be Deprecated,end --CCParticleBatchNode class will be Deprecated,begin function DeprecatedClass.CCParticleBatchNode() deprecatedTip("CCParticleBatchNode","cc.ParticleBatchNode") return cc.ParticleBatchNode end _G["CCParticleBatchNode"] = DeprecatedClass.CCParticleBatchNode() --CCParticleBatchNode class will be Deprecated,end --CCTransitionZoomFlipX class will be Deprecated,begin function DeprecatedClass.CCTransitionZoomFlipX() deprecatedTip("CCTransitionZoomFlipX","cc.TransitionZoomFlipX") return cc.TransitionZoomFlipX end _G["CCTransitionZoomFlipX"] = DeprecatedClass.CCTransitionZoomFlipX() --CCTransitionZoomFlipX class will be Deprecated,end --CCControlPotentiometer class will be Deprecated,begin function DeprecatedClass.CCControlPotentiometer() deprecatedTip("CCControlPotentiometer","cc.ControlPotentiometer") return cc.ControlPotentiometer end _G["CCControlPotentiometer"] = DeprecatedClass.CCControlPotentiometer() --CCControlPotentiometer class will be Deprecated,end --CCScaleBy class will be Deprecated,begin function DeprecatedClass.CCScaleBy() deprecatedTip("CCScaleBy","cc.ScaleBy") return cc.ScaleBy end _G["CCScaleBy"] = DeprecatedClass.CCScaleBy() --CCScaleBy class will be Deprecated,end --CCTileMapAtlas class will be Deprecated,begin function DeprecatedClass.CCTileMapAtlas() deprecatedTip("CCTileMapAtlas","cc.TileMapAtlas") return cc.TileMapAtlas end _G["CCTileMapAtlas"] = DeprecatedClass.CCTileMapAtlas() --CCTileMapAtlas class will be Deprecated,end --CCAction class will be Deprecated,begin function DeprecatedClass.CCAction() deprecatedTip("CCAction","cc.Action") return cc.Action end _G["CCAction"] = DeprecatedClass.CCAction() --CCAction class will be Deprecated,end --CCLens3D class will be Deprecated,begin function DeprecatedClass.CCLens3D() deprecatedTip("CCLens3D","cc.Lens3D") return cc.Lens3D end _G["CCLens3D"] = DeprecatedClass.CCLens3D() --CCLens3D class will be Deprecated,end --CCAnimation class will be Deprecated,begin function DeprecatedClass.CCAnimation() deprecatedTip("CCAnimation","cc.Animation") return cc.Animation end _G["CCAnimation"] = DeprecatedClass.CCAnimation() --CCAnimation class will be Deprecated,end --CCTransitionSlideInT class will be Deprecated,begin function DeprecatedClass.CCTransitionSlideInT() deprecatedTip("CCTransitionSlideInT","cc.TransitionSlideInT") return cc.TransitionSlideInT end _G["CCTransitionSlideInT"] = DeprecatedClass.CCTransitionSlideInT() --CCTransitionSlideInT class will be Deprecated,end --CCSpawn class will be Deprecated,begin function DeprecatedClass.CCSpawn() deprecatedTip("CCSpawn","cc.Spawn") return cc.Spawn end _G["CCSpawn"] = DeprecatedClass.CCSpawn() --CCSpawn class will be Deprecated,end --CCSet class will be Deprecated,begin function DeprecatedClass.CCSet() deprecatedTip("CCSet","cc.Set") return cc.Set end _G["CCSet"] = DeprecatedClass.CCSet() --CCSet class will be Deprecated,end --CCShakyTiles3D class will be Deprecated,begin function DeprecatedClass.CCShakyTiles3D() deprecatedTip("CCShakyTiles3D","cc.ShakyTiles3D") return cc.ShakyTiles3D end _G["CCShakyTiles3D"] = DeprecatedClass.CCShakyTiles3D() --CCShakyTiles3D class will be Deprecated,end --CCPageTurn3D class will be Deprecated,begin function DeprecatedClass.CCPageTurn3D() deprecatedTip("CCPageTurn3D","cc.PageTurn3D") return cc.PageTurn3D end _G["CCPageTurn3D"] = DeprecatedClass.CCPageTurn3D() --CCPageTurn3D class will be Deprecated,end --CCGrid3D class will be Deprecated,begin function DeprecatedClass.CCGrid3D() deprecatedTip("CCGrid3D","cc.Grid3D") return cc.Grid3D end _G["CCGrid3D"] = DeprecatedClass.CCGrid3D() --CCGrid3D class will be Deprecated,end --CCTransitionProgressInOut class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressInOut() deprecatedTip("CCTransitionProgressInOut","cc.TransitionProgressInOut") return cc.TransitionProgressInOut end _G["CCTransitionProgressInOut"] = DeprecatedClass.CCTransitionProgressInOut() --CCTransitionProgressInOut class will be Deprecated,end --CCTransitionFadeBL class will be Deprecated,begin function DeprecatedClass.CCTransitionFadeBL() deprecatedTip("CCTransitionFadeBL","cc.TransitionFadeBL") return cc.TransitionFadeBL end _G["CCTransitionFadeBL"] = DeprecatedClass.CCTransitionFadeBL() --CCTransitionFadeBL class will be Deprecated,end --CCCamera class will be Deprecated,begin function DeprecatedClass.CCCamera() deprecatedTip("CCCamera","cc.Camera") return cc.Camera end _G["CCCamera"] = DeprecatedClass.CCCamera() --CCCamera class will be Deprecated,end --CCLayerRGBA class will be Deprecated,begin function DeprecatedClass.CCLayerRGBA() deprecatedTip("CCLayerRGBA","cc.Layer") return cc.Layer end _G["CCLayerRGBA"] = DeprecatedClass.CCLayerRGBA() --CCLayerRGBA class will be Deprecated,end --LayerRGBA class will be Deprecated,begin function DeprecatedClass.LayerRGBA() deprecatedTip("cc.LayerRGBA","cc.Layer") return cc.Layer end _G["cc"]["LayerRGBA"] = DeprecatedClass.LayerRGBA() --LayerRGBA class will be Deprecated,end --CCBezierTo class will be Deprecated,begin function DeprecatedClass.CCBezierTo() deprecatedTip("CCBezierTo","cc.BezierTo") return cc.BezierTo end _G["CCBezierTo"] = DeprecatedClass.CCBezierTo() --CCBezierTo class will be Deprecated,end --CCControlButton class will be Deprecated,begin function DeprecatedClass.CCControlButton() deprecatedTip("CCControlButton","cc.ControlButton") return cc.ControlButton end _G["CCControlButton"] = DeprecatedClass.CCControlButton() --CCControlButton class will be Deprecated,end --CCFollow class will be Deprecated,begin function DeprecatedClass.CCFollow() deprecatedTip("CCFollow","cc.Follow") return cc.Follow end _G["CCFollow"] = DeprecatedClass.CCFollow() --CCFollow class will be Deprecated,end --CCTintBy class will be Deprecated,begin function DeprecatedClass.CCTintBy() deprecatedTip("CCTintBy","cc.TintBy") return cc.TintBy end _G["CCTintBy"] = DeprecatedClass.CCTintBy() --CCTintBy class will be Deprecated,end --CCActionInterval class will be Deprecated,begin function DeprecatedClass.CCActionInterval() deprecatedTip("CCActionInterval","cc.ActionInterval") return cc.ActionInterval end _G["CCActionInterval"] = DeprecatedClass.CCActionInterval() --CCActionInterval class will be Deprecated,end --CCAnimate class will be Deprecated,begin function DeprecatedClass.CCAnimate() deprecatedTip("CCAnimate","cc.Animate") return cc.Animate end _G["CCAnimate"] = DeprecatedClass.CCAnimate() --CCAnimate class will be Deprecated,end --CCProgressTimer class will be Deprecated,begin function DeprecatedClass.CCProgressTimer() deprecatedTip("CCProgressTimer","cc.ProgressTimer") return cc.ProgressTimer end _G["CCProgressTimer"] = DeprecatedClass.CCProgressTimer() --CCProgressTimer class will be Deprecated,end --CCParticleMeteor class will be Deprecated,begin function DeprecatedClass.CCParticleMeteor() deprecatedTip("CCParticleMeteor","cc.ParticleMeteor") return cc.ParticleMeteor end _G["CCParticleMeteor"] = DeprecatedClass.CCParticleMeteor() --CCParticleMeteor class will be Deprecated,end --CCTransitionFadeTR class will be Deprecated,begin function DeprecatedClass.CCTransitionFadeTR() deprecatedTip("CCTransitionFadeTR","cc.TransitionFadeTR") return cc.TransitionFadeTR end _G["CCTransitionFadeTR"] = DeprecatedClass.CCTransitionFadeTR() --CCTransitionFadeTR class will be Deprecated,end --CCCatmullRomTo class will be Deprecated,begin function DeprecatedClass.CCCatmullRomTo() deprecatedTip("CCCatmullRomTo","cc.CatmullRomTo") return cc.CatmullRomTo end _G["CCCatmullRomTo"] = DeprecatedClass.CCCatmullRomTo() --CCCatmullRomTo class will be Deprecated,end --CCTransitionZoomFlipY class will be Deprecated,begin function DeprecatedClass.CCTransitionZoomFlipY() deprecatedTip("CCTransitionZoomFlipY","cc.TransitionZoomFlipY") return cc.TransitionZoomFlipY end _G["CCTransitionZoomFlipY"] = DeprecatedClass.CCTransitionZoomFlipY() --CCTransitionZoomFlipY class will be Deprecated,end --CCTransitionCrossFade class will be Deprecated,begin function DeprecatedClass.CCTransitionCrossFade() deprecatedTip("CCTransitionCrossFade","cc.TransitionCrossFade") return cc.TransitionCrossFade end _G["CCTransitionCrossFade"] = DeprecatedClass.CCTransitionCrossFade() --CCTransitionCrossFade class will be Deprecated,end --CCGridBase class will be Deprecated,begin function DeprecatedClass.CCGridBase() deprecatedTip("CCGridBase","cc.GridBase") return cc.GridBase end _G["CCGridBase"] = DeprecatedClass.CCGridBase() --CCGridBase class will be Deprecated,end --CCSkewTo class will be Deprecated,begin function DeprecatedClass.CCSkewTo() deprecatedTip("CCSkewTo","cc.SkewTo") return cc.SkewTo end _G["CCSkewTo"] = DeprecatedClass.CCSkewTo() --CCSkewTo class will be Deprecated,end --CCCardinalSplineTo class will be Deprecated,begin function DeprecatedClass.CCCardinalSplineTo() deprecatedTip("CCCardinalSplineTo","cc.CardinalSplineTo") return cc.CardinalSplineTo end _G["CCCardinalSplineTo"] = DeprecatedClass.CCCardinalSplineTo() --CCCardinalSplineTo class will be Deprecated,end --CCTMXMapInfo class will be Deprecated,begin function DeprecatedClass.CCTMXMapInfo() deprecatedTip("CCTMXMapInfo","cc.TMXMapInfo") return cc.TMXMapInfo end _G["CCTMXMapInfo"] = DeprecatedClass.CCTMXMapInfo() --CCTMXMapInfo class will be Deprecated,end --CCEaseExponentialIn class will be Deprecated,begin function DeprecatedClass.CCEaseExponentialIn() deprecatedTip("CCEaseExponentialIn","cc.EaseExponentialIn") return cc.EaseExponentialIn end _G["CCEaseExponentialIn"] = DeprecatedClass.CCEaseExponentialIn() --CCEaseExponentialIn class will be Deprecated,end --CCReuseGrid class will be Deprecated,begin function DeprecatedClass.CCReuseGrid() deprecatedTip("CCReuseGrid","cc.ReuseGrid") return cc.ReuseGrid end _G["CCReuseGrid"] = DeprecatedClass.CCReuseGrid() --CCReuseGrid class will be Deprecated,end --CCMenuItemAtlasFont class will be Deprecated,begin function DeprecatedClass.CCMenuItemAtlasFont() deprecatedTip("CCMenuItemAtlasFont","cc.MenuItemAtlasFont") return cc.MenuItemAtlasFont end _G["CCMenuItemAtlasFont"] = DeprecatedClass.CCMenuItemAtlasFont() --CCMenuItemAtlasFont class will be Deprecated,end --CCSpriteFrame class will be Deprecated,begin function DeprecatedClass.CCSpriteFrame() deprecatedTip("CCSpriteFrame","cc.SpriteFrame") return cc.SpriteFrame end _G["CCSpriteFrame"] = DeprecatedClass.CCSpriteFrame() --CCSpriteFrame class will be Deprecated,end --CCSplitRows class will be Deprecated,begin function DeprecatedClass.CCSplitRows() deprecatedTip("CCSplitRows","cc.SplitRows") return cc.SplitRows end _G["CCSplitRows"] = DeprecatedClass.CCSplitRows() --CCSplitRows class will be Deprecated,end --CCControlStepper class will be Deprecated,begin function DeprecatedClass.CCControlStepper() deprecatedTip("CCControlStepper","cc.ControlStepper") return cc.ControlStepper end _G["CCControlStepper"] = DeprecatedClass.CCControlStepper() --CCControlStepper class will be Deprecated,end --CCSprite class will be Deprecated,begin function DeprecatedClass.CCSprite() deprecatedTip("CCSprite","cc.Sprite") return cc.Sprite end _G["CCSprite"] = DeprecatedClass.CCSprite() --CCSprite class will be Deprecated,end --CCOrbitCamera class will be Deprecated,begin function DeprecatedClass.CCOrbitCamera() deprecatedTip("CCOrbitCamera","cc.OrbitCamera") return cc.OrbitCamera end _G["CCOrbitCamera"] = DeprecatedClass.CCOrbitCamera() --CCOrbitCamera class will be Deprecated,end --CCUserDefault class will be Deprecated,begin function DeprecatedClass.CCUserDefault() deprecatedTip("CCUserDefault","cc.UserDefault") return cc.UserDefault end _G["CCUserDefault"] = DeprecatedClass.CCUserDefault() --CCUserDefault class will be Deprecated,end --CCFadeOutUpTiles class will be Deprecated,begin function DeprecatedClass.CCFadeOutUpTiles() deprecatedTip("CCFadeOutUpTiles","cc.FadeOutUpTiles") return cc.FadeOutUpTiles end _G["CCFadeOutUpTiles"] = DeprecatedClass.CCFadeOutUpTiles() --CCFadeOutUpTiles class will be Deprecated,end --CCParticleRain class will be Deprecated,begin function DeprecatedClass.CCParticleRain() deprecatedTip("CCParticleRain","cc.ParticleRain") return cc.ParticleRain end _G["CCParticleRain"] = DeprecatedClass.CCParticleRain() --CCParticleRain class will be Deprecated,end --CCWaves class will be Deprecated,begin function DeprecatedClass.CCWaves() deprecatedTip("CCWaves","cc.Waves") return cc.Waves end _G["CCWaves"] = DeprecatedClass.CCWaves() --CCWaves class will be Deprecated,end --CCEaseOut class will be Deprecated,begin function DeprecatedClass.CCEaseOut() deprecatedTip("CCEaseOut","cc.EaseOut") return cc.EaseOut end _G["CCEaseOut"] = DeprecatedClass.CCEaseOut() --CCEaseOut class will be Deprecated,end --CCEaseBounceIn class will be Deprecated,begin function DeprecatedClass.CCEaseBounceIn() deprecatedTip("CCEaseBounceIn","cc.EaseBounceIn") return cc.EaseBounceIn end _G["CCEaseBounceIn"] = DeprecatedClass.CCEaseBounceIn() --CCEaseBounceIn class will be Deprecated,end --CCMenuItemFont class will be Deprecated,begin function DeprecatedClass.CCMenuItemFont() deprecatedTip("CCMenuItemFont","cc.MenuItemFont") return cc.MenuItemFont end _G["CCMenuItemFont"] = DeprecatedClass.CCMenuItemFont() --CCMenuItemFont class will be Deprecated,end --CCEaseSineOut class will be Deprecated,begin function DeprecatedClass.CCEaseSineOut() deprecatedTip("CCEaseSineOut","cc.EaseSineOut") return cc.EaseSineOut end _G["CCEaseSineOut"] = DeprecatedClass.CCEaseSineOut() --CCEaseSineOut class will be Deprecated,end --CCTextureCache class will be Deprecated,begin function DeprecatedClass.CCTextureCache() deprecatedTip("CCTextureCache","cc.TextureCache") return cc.TextureCache end _G["CCTextureCache"] = DeprecatedClass.CCTextureCache() --CCTextureCache class will be Deprecated,end --CCTiledGrid3D class will be Deprecated,begin function DeprecatedClass.CCTiledGrid3D() deprecatedTip("CCTiledGrid3D","cc.TiledGrid3D") return cc.TiledGrid3D end _G["CCTiledGrid3D"] = DeprecatedClass.CCTiledGrid3D() --CCTiledGrid3D class will be Deprecated,end --CCRemoveSelf class will be Deprecated,begin function DeprecatedClass.CCRemoveSelf() deprecatedTip("CCRemoveSelf","cc.RemoveSelf") return cc.RemoveSelf end _G["CCRemoveSelf"] = DeprecatedClass.CCRemoveSelf() --CCRemoveSelf class will be Deprecated,end --CCControlSaturationBrightnessPicker class will be Deprecated,begin function DeprecatedClass.CCControlSaturationBrightnessPicker() deprecatedTip("CCControlSaturationBrightnessPicker","cc.ControlSaturationBrightnessPicker") return cc.ControlSaturationBrightnessPicker end _G["CCControlSaturationBrightnessPicker"] = DeprecatedClass.CCControlSaturationBrightnessPicker() --CCControlSaturationBrightnessPicker class will be Deprecated,end --CCLabelTTF class will be Deprecated,begin function DeprecatedClass.CCLabelTTF() deprecatedTip("CCLabelTTF","cc.LabelTTF") return cc.LabelTTF end _G["CCLabelTTF"] = DeprecatedClass.CCLabelTTF() --CCLabelTTF class will be Deprecated,end --CCTouch class will be Deprecated,begin function DeprecatedClass.CCTouch() deprecatedTip("CCTouch","cc.Touch") return cc.Touch end _G["CCTouch"] = DeprecatedClass.CCTouch() --CCTouch class will be Deprecated,end --CCMoveBy class will be Deprecated,begin function DeprecatedClass.CCMoveBy() deprecatedTip("CCMoveBy","cc.MoveBy") return cc.MoveBy end _G["CCMoveBy"] = DeprecatedClass.CCMoveBy() --CCMoveBy class will be Deprecated,end --CCMotionStreak class will be Deprecated,begin function DeprecatedClass.CCMotionStreak() deprecatedTip("CCMotionStreak","cc.MotionStreak") return cc.MotionStreak end _G["CCMotionStreak"] = DeprecatedClass.CCMotionStreak() --CCMotionStreak class will be Deprecated,end --CCRotateBy class will be Deprecated,begin function DeprecatedClass.CCRotateBy() deprecatedTip("CCRotateBy","cc.RotateBy") return cc.RotateBy end _G["CCRotateBy"] = DeprecatedClass.CCRotateBy() --CCRotateBy class will be Deprecated,end --CCFileUtils class will be Deprecated,begin function DeprecatedClass.CCFileUtils() deprecatedTip("CCFileUtils","cc.FileUtils") return cc.FileUtils end _G["CCFileUtils"] = DeprecatedClass.CCFileUtils() --CCFileUtils class will be Deprecated,end --CCBezierBy class will be Deprecated,begin function DeprecatedClass.CCBezierBy() deprecatedTip("CCBezierBy","cc.BezierBy") return cc.BezierBy end _G["CCBezierBy"] = DeprecatedClass.CCBezierBy() --CCBezierBy class will be Deprecated,end --CCTransitionFade class will be Deprecated,begin function DeprecatedClass.CCTransitionFade() deprecatedTip("CCTransitionFade","cc.TransitionFade") return cc.TransitionFade end _G["CCTransitionFade"] = DeprecatedClass.CCTransitionFade() --CCTransitionFade class will be Deprecated,end --CCTransitionProgressOutIn class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressOutIn() deprecatedTip("CCTransitionProgressOutIn","cc.TransitionProgressOutIn") return cc.TransitionProgressOutIn end _G["CCTransitionProgressOutIn"] = DeprecatedClass.CCTransitionProgressOutIn() --CCTransitionProgressOutIn class will be Deprecated,end --CCCatmullRomBy class will be Deprecated,begin function DeprecatedClass.CCCatmullRomBy() deprecatedTip("CCCatmullRomBy","cc.CatmullRomBy") return cc.CatmullRomBy end _G["CCCatmullRomBy"] = DeprecatedClass.CCCatmullRomBy() --CCCatmullRomBy class will be Deprecated,end --CCGridAction class will be Deprecated,begin function DeprecatedClass.CCGridAction() deprecatedTip("CCGridAction","cc.GridAction") return cc.GridAction end _G["CCGridAction"] = DeprecatedClass.CCGridAction() --CCGridAction class will be Deprecated,end --CCShaky3D class will be Deprecated,begin function DeprecatedClass.CCShaky3D() deprecatedTip("CCShaky3D","cc.Shaky3D") return cc.Shaky3D end _G["CCShaky3D"] = DeprecatedClass.CCShaky3D() --CCShaky3D class will be Deprecated,end --CCTransitionEaseScene class will be Deprecated,begin function DeprecatedClass.CCTransitionEaseScene() deprecatedTip("CCTransitionEaseScene","cc.TransitionEaseScene") return cc.TransitionEaseScene end _G["CCTransitionEaseScene"] = DeprecatedClass.CCTransitionEaseScene() --CCTransitionEaseScene class will be Deprecated,end --CCSequence class will be Deprecated,begin function DeprecatedClass.CCSequence() deprecatedTip("CCSequence","cc.Sequence") return cc.Sequence end _G["CCSequence"] = DeprecatedClass.CCSequence() --CCSequence class will be Deprecated,end --CCTransitionFadeUp class will be Deprecated,begin function DeprecatedClass.CCTransitionFadeUp() deprecatedTip("CCTransitionFadeUp","cc.TransitionFadeUp") return cc.TransitionFadeUp end _G["CCTransitionFadeUp"] = DeprecatedClass.CCTransitionFadeUp() --CCTransitionFadeUp class will be Deprecated,end --CCTransitionProgressRadialCW class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressRadialCW() deprecatedTip("CCTransitionProgressRadialCW","cc.TransitionProgressRadialCW") return cc.TransitionProgressRadialCW end _G["CCTransitionProgressRadialCW"] = DeprecatedClass.CCTransitionProgressRadialCW() --CCTransitionProgressRadialCW class will be Deprecated,end --CCShuffleTiles class will be Deprecated,begin function DeprecatedClass.CCShuffleTiles() deprecatedTip("CCShuffleTiles","cc.ShuffleTiles") return cc.ShuffleTiles end _G["CCShuffleTiles"] = DeprecatedClass.CCShuffleTiles() --CCShuffleTiles class will be Deprecated,end --CCTransitionSlideInR class will be Deprecated,begin function DeprecatedClass.CCTransitionSlideInR() deprecatedTip("CCTransitionSlideInR","cc.TransitionSlideInR") return cc.TransitionSlideInR end _G["CCTransitionSlideInR"] = DeprecatedClass.CCTransitionSlideInR() --CCTransitionSlideInR class will be Deprecated,end --CCScene class will be Deprecated,begin function DeprecatedClass.CCScene() deprecatedTip("CCScene","cc.Scene") return cc.Scene end _G["CCScene"] = DeprecatedClass.CCScene() --CCScene class will be Deprecated,end --CCParallaxNode class will be Deprecated,begin function DeprecatedClass.CCParallaxNode() deprecatedTip("CCParallaxNode","cc.ParallaxNode") return cc.ParallaxNode end _G["CCParallaxNode"] = DeprecatedClass.CCParallaxNode() --CCParallaxNode class will be Deprecated,end --CCTransitionSlideInL class will be Deprecated,begin function DeprecatedClass.CCTransitionSlideInL() deprecatedTip("CCTransitionSlideInL","cc.TransitionSlideInL") return cc.TransitionSlideInL end _G["CCTransitionSlideInL"] = DeprecatedClass.CCTransitionSlideInL() --CCTransitionSlideInL class will be Deprecated,end --CCControlSwitch class will be Deprecated,begin function DeprecatedClass.CCControlSwitch() deprecatedTip("CCControlSwitch","cc.ControlSwitch") return cc.ControlSwitch end _G["CCControlSwitch"] = DeprecatedClass.CCControlSwitch() --CCControlSwitch class will be Deprecated,end --CCWavesTiles3D class will be Deprecated,begin function DeprecatedClass.CCWavesTiles3D() deprecatedTip("CCWavesTiles3D","cc.WavesTiles3D") return cc.WavesTiles3D end _G["CCWavesTiles3D"] = DeprecatedClass.CCWavesTiles3D() --CCWavesTiles3D class will be Deprecated,end --CCTransitionSlideInB class will be Deprecated,begin function DeprecatedClass.CCTransitionSlideInB() deprecatedTip("CCTransitionSlideInB","cc.TransitionSlideInB") return cc.TransitionSlideInB end _G["CCTransitionSlideInB"] = DeprecatedClass.CCTransitionSlideInB() --CCTransitionSlideInB class will be Deprecated,end --CCSpeed class will be Deprecated,begin function DeprecatedClass.CCSpeed() deprecatedTip("CCSpeed","cc.Speed") return cc.Speed end _G["CCSpeed"] = DeprecatedClass.CCSpeed() --CCSpeed class will be Deprecated,end --CCShatteredTiles3D class will be Deprecated,begin function DeprecatedClass.CCShatteredTiles3D() deprecatedTip("CCShatteredTiles3D","cc.ShatteredTiles3D") return cc.ShatteredTiles3D end _G["CCShatteredTiles3D"] = DeprecatedClass.CCShatteredTiles3D() --CCShatteredTiles3D class will be Deprecated,end --CCCallFuncN class will be Deprecated,begin function DeprecatedClass.CCCallFuncN() deprecatedTip("CCCallFuncN","cc.CallFunc") return cc.CallFunc end _G["CCCallFuncN"] = DeprecatedClass.CCCallFuncN() --CCCallFuncN class will be Deprecated,end --CCArmature class will be Deprecated,begin function DeprecatedClass.CCArmature() deprecatedTip("CCArmature","ccs.Armature") return ccs.Armature end _G["CCArmature"] = DeprecatedClass.CCArmature() --CCArmature class will be Deprecated,end --CCArmatureAnimation class will be Deprecated,begin function DeprecatedClass.CCArmatureAnimation() deprecatedTip("CCArmatureAnimation","ccs.ArmatureAnimation") return ccs.ArmatureAnimation end _G["CCArmatureAnimation"] = DeprecatedClass.CCArmatureAnimation() --CCArmatureAnimation class will be Deprecated,end --CCSkin class will be Deprecated,begin function DeprecatedClass.CCSkin() deprecatedTip("CCSkin","ccs.Skin") return ccs.Skin end _G["CCSkin"] = DeprecatedClass.CCSkin() --CCSkin class will be Deprecated,end --CCBone class will be Deprecated,begin function DeprecatedClass.CCBone() deprecatedTip("CCBone","ccs.Bone") return ccs.Bone end _G["CCBone"] = DeprecatedClass.CCBone() --CCBone class will be Deprecated,end --CCArmatureDataManager class will be Deprecated,begin function DeprecatedClass.CCArmatureDataManager() deprecatedTip("CCArmatureDataManager","ccs.ArmatureDataManager") return ccs.ArmatureDataManager end _G["CCArmatureDataManager"] = DeprecatedClass.CCArmatureDataManager() --CCArmatureDataManager class will be Deprecated,end --CCBatchNode class will be Deprecated,begin function DeprecatedClass.CCBatchNode() deprecatedTip("CCBatchNode","ccs.BatchNode") return ccs.BatchNode end _G["CCBatchNode"] = DeprecatedClass.CCBatchNode() --CCBatchNode class will be Deprecated,end --CCTween class will be Deprecated,begin function DeprecatedClass.CCTween() deprecatedTip("CCTween","ccs.Tween") return ccs.Tween end _G["CCTween"] = DeprecatedClass.CCTween() --CCTween class will be Deprecated,end --CCBaseData class will be Deprecated,begin function DeprecatedClass.CCBaseData() deprecatedTip("CCBaseData","ccs.BaseData") return ccs.BaseData end _G["CCBaseData"] = DeprecatedClass.CCBaseData() --CCBaseData class will be Deprecated,end --CCDisplayManager class will be Deprecated,begin function DeprecatedClass.CCDisplayManager() deprecatedTip("CCDisplayManager","ccs.DisplayManager") return ccs.DisplayManager end _G["CCDisplayManager"] = DeprecatedClass.CCDisplayManager() --CCDisplayManager class will be Deprecated,end --UIHelper class will be Deprecated,begin function DeprecatedClass.UIHelper() deprecatedTip("UIHelper","ccs.UIHelper") return ccs.UIHelper end _G["UIHelper"] = DeprecatedClass.UIHelper() --UIHelper class will be Deprecated,end --UILayout class will be Deprecated,begin function DeprecatedClass.UILayout() deprecatedTip("UILayout","ccs.UILayout") return ccs.UILayout end _G["UILayout"] = DeprecatedClass.UILayout() --UILayout class will be Deprecated,end --UIWidget class will be Deprecated,begin function DeprecatedClass.UIWidget() deprecatedTip("UIWidget","ccs.UIWidget") return ccs.UIWidget end _G["UIWidget"] = DeprecatedClass.UIWidget() --UIWidget class will be Deprecated,end --UILayer class will be Deprecated,begin function DeprecatedClass.UILayer() deprecatedTip("UILayer","ccs.UILayer") return ccs.UILayer end _G["UILayer"] = DeprecatedClass.UILayer() --UILayer class will be Deprecated,end --UIButton class will be Deprecated,begin function DeprecatedClass.UIButton() deprecatedTip("UIButton","ccs.UIButton") return ccs.UIButton end _G["UIButton"] = DeprecatedClass.UIButton() --UIButton class will be Deprecated,end --UICheckBox class will be Deprecated,begin function DeprecatedClass.UICheckBox() deprecatedTip("UICheckBox","ccs.UICheckBox") return ccs.UICheckBox end _G["UICheckBox"] = DeprecatedClass.UICheckBox() --UICheckBox class will be Deprecated,end --UIImageView class will be Deprecated,begin function DeprecatedClass.UIImageView() deprecatedTip("UIImageView","ccs.UIImageView") return ccs.UIImageView end _G["UIImageView"] = DeprecatedClass.UIImageView() --UIImageView class will be Deprecated,end --UILabel class will be Deprecated,begin function DeprecatedClass.UILabel() deprecatedTip("UILabel","ccs.UILabel") return ccs.UILabel end _G["UILabel"] = DeprecatedClass.UILabel() --UILabel class will be Deprecated,end --UILabelAtlas class will be Deprecated,begin function DeprecatedClass.UILabelAtlas() deprecatedTip("UILabelAtlas","ccs.UILabelAtlas") return ccs.UILabelAtlas end _G["UILabelAtlas"] = DeprecatedClass.UILabelAtlas() --UILabelAtlas class will be Deprecated,end --UILabelBMFont class will be Deprecated,begin function DeprecatedClass.UILabelBMFont() deprecatedTip("UILabelBMFont","ccs.UILabelBMFont") return ccs.UILabelBMFont end _G["UILabelBMFont"] = DeprecatedClass.UILabelBMFont() --UILabelBMFont class will be Deprecated,end --UILoadingBar class will be Deprecated,begin function DeprecatedClass.UILoadingBar() deprecatedTip("UILoadingBar","ccs.UILoadingBar") return ccs.UILoadingBar end _G["UILoadingBar"] = DeprecatedClass.UILoadingBar() --UILoadingBar class will be Deprecated,end --UISlider class will be Deprecated,begin function DeprecatedClass.UISlider() deprecatedTip("UISlider","ccs.UISlider") return ccs.UISlider end _G["UISlider"] = DeprecatedClass.UISlider() --UISlider class will be Deprecated,end --UITextField class will be Deprecated,begin function DeprecatedClass.UITextField() deprecatedTip("UITextField","ccs.UITextField") return ccs.UITextField end _G["UITextField"] = DeprecatedClass.UITextField() --UITextField class will be Deprecated,end --UIScrollView class will be Deprecated,begin function DeprecatedClass.UIScrollView() deprecatedTip("UIScrollView","ccs.UIScrollView") return ccs.UIScrollView end _G["UIScrollView"] = DeprecatedClass.UIScrollView() --UIScrollView class will be Deprecated,end --UIPageView class will be Deprecated,begin function DeprecatedClass.UIPageView() deprecatedTip("UIPageView","ccs.UIPageView") return ccs.UIPageView end _G["UIPageView"] = DeprecatedClass.UIPageView() --UIPageView class will be Deprecated,end --UIListView class will be Deprecated,begin function DeprecatedClass.UIListView() deprecatedTip("UIListView","ccs.UIListView") return ccs.UIListView end _G["UIListView"] = DeprecatedClass.UIListView() --UIListView class will be Deprecated,end --UILayoutParameter class will be Deprecated,begin function DeprecatedClass.UILayoutParameter() deprecatedTip("UILayoutParameter","ccs.UILayoutParameter") return ccs.UILayoutParameter end _G["UILayoutParameter"] = DeprecatedClass.UILayoutParameter() --UILayoutParameter class will be Deprecated,end --UILinearLayoutParameter class will be Deprecated,begin function DeprecatedClass.UILinearLayoutParameter() deprecatedTip("UILinearLayoutParameter","ccs.UILinearLayoutParameter") return ccs.UILinearLayoutParameter end _G["UILinearLayoutParameter"] = DeprecatedClass.UILinearLayoutParameter() --UILinearLayoutParameter class will be Deprecated,end --UIRelativeLayoutParameter class will be Deprecated,begin function DeprecatedClass.UIRelativeLayoutParameter() deprecatedTip("UIRelativeLayoutParameter","ccs.UIRelativeLayoutParameter") return ccs.UIRelativeLayoutParameter end _G["UIRelativeLayoutParameter"] = DeprecatedClass.UIRelativeLayoutParameter() --UIRelativeLayoutParameter class will be Deprecated,end --CCComController class will be Deprecated,begin function DeprecatedClass.CCComController() deprecatedTip("CCComController","ccs.ComController") return ccs.CCComController end _G["CCComController"] = DeprecatedClass.CCComController() --CCComController class will be Deprecated,end --CCComAudio class will be Deprecated,begin function DeprecatedClass.CCComAudio() deprecatedTip("CCComAudio","ccs.ComAudio") return ccs.ComAudio end _G["CCComAudio"] = DeprecatedClass.CCComAudio() --CCComAudio class will be Deprecated,end --CCComAttribute class will be Deprecated,begin function DeprecatedClass.CCComAttribute() deprecatedTip("CCComAttribute","ccs.ComAttribute") return ccs.ComAttribute end _G["CCComAttribute"] = DeprecatedClass.CCComAttribute() --CCComAttribute class will be Deprecated,end --CCComRender class will be Deprecated,begin function DeprecatedClass.CCComRender() deprecatedTip("CCComRender","ccs.ComRender") return ccs.ComRender end _G["CCComRender"] = DeprecatedClass.CCComRender() --CCComRender class will be Deprecated,end --ActionManager class will be Deprecated,begin function DeprecatedClass.ActionManager() deprecatedTip("ActionManager","ccs.ActionManagerEx") return ccs.ActionManagerEx end _G["ActionManager"] = DeprecatedClass.ActionManager() --CCComRender class will be Deprecated,end --SceneReader class will be Deprecated,begin function DeprecatedClass.SceneReader() deprecatedTip("SceneReader","ccs.SceneReader") return ccs.SceneReader end _G["SceneReader"] = DeprecatedClass.SceneReader() --SceneReader class will be Deprecated,end --GUIReader class will be Deprecated,begin function DeprecatedClass.GUIReader() deprecatedTip("GUIReader","ccs.GUIReader") return ccs.GUIReader end _G["GUIReader"] = DeprecatedClass.GUIReader() --GUIReader class will be Deprecated,end --UIRootWidget class will be Deprecated,begin function DeprecatedClass.UIRootWidget() deprecatedTip("UIRootWidget","ccs.UIRootWidget") return ccs.UIRootWidget end _G["UIRootWidget"] = DeprecatedClass.UIRootWidget() --UIRootWidget class will be Deprecated,end --ActionObject class will be Deprecated,begin function DeprecatedClass.ActionObject() deprecatedTip("ActionObject","ccs.ActionObject") return ccs.ActionObject end _G["ActionObject"] = DeprecatedClass.ActionObject() --ActionObject class will be Deprecated,end --CCEGLViewProtocol class will be Deprecated,begin function DeprecatedClass.CCEGLViewProtocol() deprecatedTip("CCEGLViewProtocol","cc.EGLViewProtocol") return cc.EGLViewProtocol end _G["CCEGLViewProtocol"] = DeprecatedClass.CCEGLViewProtocol() --CCEGLViewProtocol class will be Deprecated,end --CCEGLView class will be Deprecated,begin function DeprecatedClass.CCEGLView() deprecatedTip("CCEGLView","cc.EGLView") return cc.EGLView end _G["CCEGLView"] = DeprecatedClass.CCEGLView() --CCEGLView class will be Deprecated,end --CCBProxy class will be Deprecated,begin function DeprecatedClass.CCBProxy() deprecatedTip("CCBProxy","cc.CCBProxy") return cc.CCBProxy end _G["CCBProxy"] = DeprecatedClass.CCBProxy() --CCBProxy class will be Deprecated,end --WebSocket class will be Deprecated,begin function DeprecatedClass.WebSocket() deprecatedTip("WebSocket","cc.WebSocket") return cc.WebSocket end _G["WebSocket"] = DeprecatedClass.WebSocket() --WebSocket class will be Deprecated,end --XMLHttpRequest class will be Deprecated,begin function DeprecatedClass.XMLHttpRequest() deprecatedTip("XMLHttpRequest","cc.XMLHttpRequest") return cc.XMLHttpRequest end _G["XMLHttpRequest"] = DeprecatedClass.XMLHttpRequest() --XMLHttpRequest class will be Deprecated,end ================================================ FILE: Resources/DeprecatedEnum.lua ================================================ require "Cocos2dConstants.lua" require "OpenglConstants.lua" require "StudioConstants.lua" --Enums will be deprecated,begin _G.kCCTextAlignmentLeft = cc.TEXT_ALIGNMENT_LEFT _G.kCCTextAlignmentRight = cc.TEXT_ALIGNMENT_RIGHT _G.kCCTextAlignmentCenter = cc.TEXT_ALIGNMENT_CENTER _G.kCCVerticalTextAlignmentTop = cc.VERTICAL_TEXT_ALIGNMENT_TOP _G.kCCVerticalTextAlignmentCenter = cc.VERTICAL_TEXT_ALIGNMENT_CENTER _G.kCCVerticalTextAlignmentBottom = cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM _G.kCCDirectorProjection3D = cc.DIRECTOR_PROJECTION3_D _G.kCCDirectorProjection2D = cc.DIRECTOR_PROJECTION2_D _G.kCCDirectorProjectionCustom = cc.DIRECTOR_PROJECTION_CUSTOM _G.kCCDirectorProjectionDefault = cc.DIRECTOR_PROJECTION_DEFAULT _G.kCCNodeTagInvalid = cc.NODE_TAG_INVALID _G.kCCNodeOnEnter = cc.NODE_ON_ENTER _G.kCCNodeOnExit = cc.NODE_ON_EXIT _G.kCCTexture2DPixelFormat_RGBA8888 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 _G.kCCTexture2DPixelFormat_RGB888 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 _G.kCCTexture2DPixelFormat_RGB565 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 _G.kCCTexture2DPixelFormat_A8 = cc.TEXTURE2_D_PIXEL_FORMAT_A8 _G.kCCTexture2DPixelFormat_I8 = cc.TEXTURE2_D_PIXEL_FORMAT_I8 _G.kCCTexture2DPixelFormat_AI88 = cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 _G.kCCTexture2DPixelFormat_RGBA4444 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 _G.kCCTexture2DPixelFormat_RGB5A1 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 _G.kCCTexture2DPixelFormat_PVRTC4 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 _G.kCCTexture2DPixelFormat_PVRTC2 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 _G.kCCTexture2DPixelFormat_Default = cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT _G.kCCImageFormatPNG = cc.IMAGE_FORMAT_PNG _G.kCCImageFormatJPEG = cc.IMAGE_FORMAT_JPEG _G.kCCTouchesOneByOne = cc.TOUCHES_ONE_BY_ONE _G.kCCTouchesAllAtOnce = cc.TOUCHES_ALL_AT_ONCE _G.kCCTransitionOrientationLeftOver = cc.TRANSITION_ORIENTATION_LEFT_OVER _G.kCCTransitionOrientationRightOver = cc.TRANSITION_ORIENTATION_RIGHT_OVER _G.kCCTransitionOrientationUpOver = cc.TRANSITION_ORIENTATION_UP_OVER _G.kCCTransitionOrientationDownOver = cc.TRANSITION_ORIENTATION_DOWN_OVER _G.kCCActionTagInvalid = cc.ACTION_TAG_INVALID _G.kCCLabelAutomaticWidth = cc.LABEL_AUTOMATIC_WIDTH _G.kCCMenuStateWaiting = cc.MENU_STATE_WAITING _G.kCCMenuStateTrackingTouch = cc.MENU_STATE_TRACKING_TOUCH _G.kCCMenuHandlerPriority = cc.MENU_HANDLER_PRIORITY _G.kCCParticleDurationInfinity = cc.PARTICLE_DURATION_INFINITY _G.kCCParticleStartSizeEqualToEndSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE _G.kCCParticleStartRadiusEqualToEndRadius = cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS _G.kCCParticleModeGravity = cc.PARTICLE_MODE_GRAVITY _G.kCCParticleModeRadius = cc.PARTICLE_MODE_RADIUS _G.kCCPositionTypeFree = cc.POSITION_TYPE_FREE _G.kCCPositionTypeRelative = cc.POSITION_TYPE_RELATIVE _G.kCCPositionTypeGrouped = cc.POSITION_TYPE_GROUPED _G.kCCProgressTimerTypeRadial = cc.PROGRESS_TIMER_TYPE_RADIAL _G.kCCProgressTimerTypeBar = cc.PROGRESS_TIMER_TYPE_BAR _G.kCCTMXTileHorizontalFlag = cc.TMX_TILE_HORIZONTAL_FLAG _G.kCCTMXTileVerticalFlag = cc.TMX_TILE_VERTICAL_FLAG _G.kCCTMXTileDiagonalFlag = cc.TMX_TILE_DIAGONAL_FLAG _G.kCCFlipedAll = cc.FLIPED_ALL _G.kCCFlippedMask = cc.FLIPPED_MASK _G.kCCControlStepperPartMinus = cc.CONTROL_STEPPER_PART_MINUS _G.kCCControlStepperPartPlus = cc.CONTROL_STEPPER_PART_PLUS _G.kCCControlStepperPartNone = cc.CONTROL_STEPPER_PART_NONE _G.kLanguageEnglish = cc.LANGUAGE_ENGLISH _G.kLanguageChinese = cc.LANGUAGE_CHINESE _G.kLanguageFrench = cc.LANGUAGE_FRENCH _G.kLanguageItalian = cc.LANGUAGE_ITALIAN _G.kLanguageGerman = cc.LANGUAGE_GERMAN _G.kLanguageSpanish = cc.LANGUAGE_SPANISH _G.kLanguageRussian = cc.LANGUAGE_RUSSIAN _G.kLanguageKorean = cc.LANGUAGE_KOREAN _G.kLanguageJapanese = cc.LANGUAGE_JAPANESE _G.kLanguageHungarian = cc.LANGUAGE_HUNGARIAN _G.kLanguagePortuguese = cc.LANGUAGE_PORTUGUESE _G.kLanguageArabic = cc.LANGUAGE_ARABIC _G.kTargetWindows = cc.PLATFORM_OS_WINDOWS _G.kTargetLinux = cc.PLATFORM_OS_LINUX _G.kTargetMacOS = cc.PLATFORM_OS_MAC _G.kTargetAndroid = cc.PLATFORM_OS_ANDROID _G.kTargetIphone = cc.PLATFORM_OS_IPHONE _G.kTargetIpad = cc.PLATFORM_OS_IPAD _G.kTargetBlackBerry = cc.PLATFORM_OS_BLACKBERRY _G.GL_ZERO = gl.ZERO _G.GL_ONE = gl.ONE _G.GL_SRC_COLOR = gl.SRC_COLOR _G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR _G.GL_SRC_ALPHA = gl.SRC_ALPHA _G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA _G.GL_DST_ALPHA = gl.DST_ALPHA _G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA _G.GL_DST_COLOR = gl.DST_COLOR _G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR _G.GL_RENDERBUFFER_INTERNAL_FORMAT = gl.RENDERBUFFER_INTERNAL_FORMAT _G.GL_LINE_WIDTH = gl.LINE_WIDTH _G.GL_CONSTANT_ALPHA = gl.CONSTANT_ALPHA _G.GL_BLEND_SRC_ALPHA = gl.BLEND_SRC_ALPHA _G.GL_GREEN_BITS = gl.GREEN_BITS _G.GL_STENCIL_REF = gl.STENCIL_REF _G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA _G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE _G.GL_CCW = gl.CCW _G.GL_MAX_TEXTURE_IMAGE_UNITS = gl.MAX_TEXTURE_IMAGE_UNITS _G.GL_BACK = gl.BACK _G.GL_ACTIVE_ATTRIBUTES = gl.ACTIVE_ATTRIBUTES _G.GL_TEXTURE_CUBE_MAP_POSITIVE_X = gl.TEXTURE_CUBE_MAP_POSITIVE_X _G.GL_STENCIL_BACK_VALUE_MASK = gl.STENCIL_BACK_VALUE_MASK _G.GL_TEXTURE_CUBE_MAP_POSITIVE_Z = gl.TEXTURE_CUBE_MAP_POSITIVE_Z _G.GL_ONE = gl.ONE _G.GL_TRUE = gl.TRUE _G.GL_TEXTURE12 = gl.TEXTURE12 _G.GL_LINK_STATUS = gl.LINK_STATUS _G.GL_BLEND = gl.BLEND _G.GL_LESS = gl.LESS _G.GL_TEXTURE16 = gl.TEXTURE16 _G.GL_BOOL_VEC2 = gl.BOOL_VEC2 _G.GL_KEEP = gl.KEEP _G.GL_DST_COLOR = gl.DST_COLOR _G.GL_VERTEX_ATTRIB_ARRAY_ENABLED = gl.VERTEX_ATTRIB_ARRAY_ENABLED _G.GL_EXTENSIONS = gl.EXTENSIONS _G.GL_FRONT = gl.FRONT _G.GL_DST_ALPHA = gl.DST_ALPHA _G.GL_ATTACHED_SHADERS = gl.ATTACHED_SHADERS _G.GL_STENCIL_BACK_FUNC = gl.STENCIL_BACK_FUNC _G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR _G.GL_BLEND_EQUATION = gl.BLEND_EQUATION _G.GL_RENDERBUFFER_DEPTH_SIZE = gl.RENDERBUFFER_DEPTH_SIZE _G.GL_PACK_ALIGNMENT = gl.PACK_ALIGNMENT _G.GL_VENDOR = gl.VENDOR _G.GL_NEAREST_MIPMAP_LINEAR = gl.NEAREST_MIPMAP_LINEAR _G.GL_TEXTURE_CUBE_MAP_POSITIVE_Y = gl.TEXTURE_CUBE_MAP_POSITIVE_Y _G.GL_NEAREST = gl.NEAREST _G.GL_RENDERBUFFER_WIDTH = gl.RENDERBUFFER_WIDTH _G.GL_ARRAY_BUFFER_BINDING = gl.ARRAY_BUFFER_BINDING _G.GL_ARRAY_BUFFER = gl.ARRAY_BUFFER _G.GL_LEQUAL = gl.LEQUAL _G.GL_VERSION = gl.VERSION _G.GL_COLOR_CLEAR_VALUE = gl.COLOR_CLEAR_VALUE _G.GL_RENDERER = gl.RENDERER _G.GL_STENCIL_BACK_PASS_DEPTH_PASS = gl.STENCIL_BACK_PASS_DEPTH_PASS _G.GL_STENCIL_BACK_PASS_DEPTH_FAIL = gl.STENCIL_BACK_PASS_DEPTH_FAIL _G.GL_STENCIL_BACK_WRITEMASK = gl.STENCIL_BACK_WRITEMASK _G.GL_BOOL = gl.BOOL _G.GL_VIEWPORT = gl.VIEWPORT _G.GL_FRAGMENT_SHADER = gl.FRAGMENT_SHADER _G.GL_LUMINANCE = gl.LUMINANCE _G.GL_DECR_WRAP = gl.DECR_WRAP _G.GL_FUNC_ADD = gl.FUNC_ADD _G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA _G.GL_OUT_OF_MEMORY = gl.OUT_OF_MEMORY _G.GL_BOOL_VEC4 = gl.BOOL_VEC4 _G.GL_POLYGON_OFFSET_FACTOR = gl.POLYGON_OFFSET_FACTOR _G.GL_STATIC_DRAW = gl.STATIC_DRAW _G.GL_DITHER = gl.DITHER _G.GL_TEXTURE31 = gl.TEXTURE31 _G.GL_TEXTURE30 = gl.TEXTURE30 _G.GL_UNSIGNED_BYTE = gl.UNSIGNED_BYTE _G.GL_DEPTH_COMPONENT16 = gl.DEPTH_COMPONENT16 _G.GL_TEXTURE23 = gl.TEXTURE23 _G.GL_DEPTH_TEST = gl.DEPTH_TEST _G.GL_STENCIL_PASS_DEPTH_FAIL = gl.STENCIL_PASS_DEPTH_FAIL _G.GL_BOOL_VEC3 = gl.BOOL_VEC3 _G.GL_POLYGON_OFFSET_UNITS = gl.POLYGON_OFFSET_UNITS _G.GL_TEXTURE_BINDING_2D = gl.TEXTURE_BINDING_2D _G.GL_TEXTURE21 = gl.TEXTURE21 _G.GL_UNPACK_ALIGNMENT = gl.UNPACK_ALIGNMENT _G.GL_DONT_CARE = gl.DONT_CARE _G.GL_BUFFER_SIZE = gl.BUFFER_SIZE _G.GL_FLOAT_MAT3 = gl.FLOAT_MAT3 _G.GL_UNSIGNED_SHORT_5_6_5 = gl.UNSIGNED_SHORT_5_6_5 _G.GL_INT_VEC2 = gl.INT_VEC2 _G.GL_UNSIGNED_SHORT_4_4_4_4 = gl.UNSIGNED_SHORT_4_4_4_4 _G.GL_NONE = gl.NONE _G.GL_BLEND_DST_ALPHA = gl.BLEND_DST_ALPHA _G.GL_VERTEX_ATTRIB_ARRAY_SIZE = gl.VERTEX_ATTRIB_ARRAY_SIZE _G.GL_SRC_COLOR = gl.SRC_COLOR _G.GL_COMPRESSED_TEXTURE_FORMATS = gl.COMPRESSED_TEXTURE_FORMATS _G.GL_STENCIL_ATTACHMENT = gl.STENCIL_ATTACHMENT _G.GL_MAX_VERTEX_ATTRIBS = gl.MAX_VERTEX_ATTRIBS _G.GL_NUM_COMPRESSED_TEXTURE_FORMATS = gl.NUM_COMPRESSED_TEXTURE_FORMATS _G.GL_BLEND_EQUATION_RGB = gl.BLEND_EQUATION_RGB _G.GL_TEXTURE = gl.TEXTURE _G.GL_LINEAR_MIPMAP_LINEAR = gl.LINEAR_MIPMAP_LINEAR _G.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING _G.GL_CURRENT_PROGRAM = gl.CURRENT_PROGRAM _G.GL_COLOR_BUFFER_BIT = gl.COLOR_BUFFER_BIT _G.GL_TEXTURE20 = gl.TEXTURE20 _G.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = gl.ACTIVE_ATTRIBUTE_MAX_LENGTH _G.GL_TEXTURE28 = gl.TEXTURE28 _G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE _G.GL_TEXTURE22 = gl.TEXTURE22 _G.GL_ELEMENT_ARRAY_BUFFER_BINDING = gl.ELEMENT_ARRAY_BUFFER_BINDING _G.GL_STREAM_DRAW = gl.STREAM_DRAW _G.GL_SCISSOR_BOX = gl.SCISSOR_BOX _G.GL_TEXTURE26 = gl.TEXTURE26 _G.GL_TEXTURE27 = gl.TEXTURE27 _G.GL_TEXTURE24 = gl.TEXTURE24 _G.GL_TEXTURE25 = gl.TEXTURE25 _G.GL_NO_ERROR = gl.NO_ERROR _G.GL_TEXTURE29 = gl.TEXTURE29 _G.GL_FLOAT_MAT4 = gl.FLOAT_MAT4 _G.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = gl.VERTEX_ATTRIB_ARRAY_NORMALIZED _G.GL_SAMPLE_COVERAGE_INVERT = gl.SAMPLE_COVERAGE_INVERT _G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL _G.GL_FLOAT_VEC3 = gl.FLOAT_VEC3 _G.GL_STENCIL_CLEAR_VALUE = gl.STENCIL_CLEAR_VALUE _G.GL_UNSIGNED_SHORT_5_5_5_1 = gl.UNSIGNED_SHORT_5_5_5_1 _G.GL_ACTIVE_UNIFORMS = gl.ACTIVE_UNIFORMS _G.GL_INVALID_OPERATION = gl.INVALID_OPERATION _G.GL_DEPTH_ATTACHMENT = gl.DEPTH_ATTACHMENT _G.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS _G.GL_FRAMEBUFFER_COMPLETE = gl.FRAMEBUFFER_COMPLETE _G.GL_ONE_MINUS_CONSTANT_COLOR = gl.ONE_MINUS_CONSTANT_COLOR _G.GL_TEXTURE2 = gl.TEXTURE2 _G.GL_TEXTURE1 = gl.TEXTURE1 _G.GL_GEQUAL = gl.GEQUAL _G.GL_TEXTURE7 = gl.TEXTURE7 _G.GL_TEXTURE6 = gl.TEXTURE6 _G.GL_TEXTURE5 = gl.TEXTURE5 _G.GL_TEXTURE4 = gl.TEXTURE4 _G.GL_GENERATE_MIPMAP_HINT = gl.GENERATE_MIPMAP_HINT _G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR _G.GL_TEXTURE9 = gl.TEXTURE9 _G.GL_STENCIL_TEST = gl.STENCIL_TEST _G.GL_COLOR_WRITEMASK = gl.COLOR_WRITEMASK _G.GL_DEPTH_COMPONENT = gl.DEPTH_COMPONENT _G.GL_STENCIL_INDEX8 = gl.STENCIL_INDEX8 _G.GL_VERTEX_ATTRIB_ARRAY_TYPE = gl.VERTEX_ATTRIB_ARRAY_TYPE _G.GL_FLOAT_VEC2 = gl.FLOAT_VEC2 _G.GL_BLUE_BITS = gl.BLUE_BITS _G.GL_VERTEX_SHADER = gl.VERTEX_SHADER _G.GL_SUBPIXEL_BITS = gl.SUBPIXEL_BITS _G.GL_STENCIL_WRITEMASK = gl.STENCIL_WRITEMASK _G.GL_FLOAT_VEC4 = gl.FLOAT_VEC4 _G.GL_TEXTURE17 = gl.TEXTURE17 _G.GL_ONE_MINUS_CONSTANT_ALPHA = gl.ONE_MINUS_CONSTANT_ALPHA _G.GL_TEXTURE15 = gl.TEXTURE15 _G.GL_TEXTURE14 = gl.TEXTURE14 _G.GL_TEXTURE13 = gl.TEXTURE13 _G.GL_SAMPLES = gl.SAMPLES _G.GL_TEXTURE11 = gl.TEXTURE11 _G.GL_TEXTURE10 = gl.TEXTURE10 _G.GL_FUNC_SUBTRACT = gl.FUNC_SUBTRACT _G.GL_STENCIL_BUFFER_BIT = gl.STENCIL_BUFFER_BIT _G.GL_TEXTURE19 = gl.TEXTURE19 _G.GL_TEXTURE18 = gl.TEXTURE18 _G.GL_NEAREST_MIPMAP_NEAREST = gl.NEAREST_MIPMAP_NEAREST _G.GL_SHORT = gl.SHORT _G.GL_RENDERBUFFER_BINDING = gl.RENDERBUFFER_BINDING _G.GL_REPEAT = gl.REPEAT _G.GL_TEXTURE_MIN_FILTER = gl.TEXTURE_MIN_FILTER _G.GL_RED_BITS = gl.RED_BITS _G.GL_FRONT_FACE = gl.FRONT_FACE _G.GL_BLEND_COLOR = gl.BLEND_COLOR _G.GL_MIRRORED_REPEAT = gl.MIRRORED_REPEAT _G.GL_INT_VEC4 = gl.INT_VEC4 _G.GL_MAX_CUBE_MAP_TEXTURE_SIZE = gl.MAX_CUBE_MAP_TEXTURE_SIZE _G.GL_RENDERBUFFER_BLUE_SIZE = gl.RENDERBUFFER_BLUE_SIZE _G.GL_SAMPLE_COVERAGE = gl.SAMPLE_COVERAGE _G.GL_SRC_ALPHA = gl.SRC_ALPHA _G.GL_FUNC_REVERSE_SUBTRACT = gl.FUNC_REVERSE_SUBTRACT _G.GL_DEPTH_WRITEMASK = gl.DEPTH_WRITEMASK _G.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT _G.GL_POLYGON_OFFSET_FILL = gl.POLYGON_OFFSET_FILL _G.GL_STENCIL_FUNC = gl.STENCIL_FUNC _G.GL_REPLACE = gl.REPLACE _G.GL_LUMINANCE_ALPHA = gl.LUMINANCE_ALPHA _G.GL_DEPTH_RANGE = gl.DEPTH_RANGE _G.GL_FASTEST = gl.FASTEST _G.GL_STENCIL_FAIL = gl.STENCIL_FAIL _G.GL_UNSIGNED_SHORT = gl.UNSIGNED_SHORT _G.GL_RENDERBUFFER_HEIGHT = gl.RENDERBUFFER_HEIGHT _G.GL_STENCIL_BACK_FAIL = gl.STENCIL_BACK_FAIL _G.GL_BLEND_SRC_RGB = gl.BLEND_SRC_RGB _G.GL_TEXTURE3 = gl.TEXTURE3 _G.GL_RENDERBUFFER = gl.RENDERBUFFER _G.GL_RGB5_A1 = gl.RGB5_A1 _G.GL_RENDERBUFFER_ALPHA_SIZE = gl.RENDERBUFFER_ALPHA_SIZE _G.GL_RENDERBUFFER_STENCIL_SIZE = gl.RENDERBUFFER_STENCIL_SIZE _G.GL_NOTEQUAL = gl.NOTEQUAL _G.GL_BLEND_DST_RGB = gl.BLEND_DST_RGB _G.GL_FRONT_AND_BACK = gl.FRONT_AND_BACK _G.GL_TEXTURE_BINDING_CUBE_MAP = gl.TEXTURE_BINDING_CUBE_MAP _G.GL_MAX_RENDERBUFFER_SIZE = gl.MAX_RENDERBUFFER_SIZE _G.GL_ZERO = gl.ZERO _G.GL_TEXTURE0 = gl.TEXTURE0 _G.GL_SAMPLE_ALPHA_TO_COVERAGE = gl.SAMPLE_ALPHA_TO_COVERAGE _G.GL_BUFFER_USAGE = gl.BUFFER_USAGE _G.GL_ACTIVE_TEXTURE = gl.ACTIVE_TEXTURE _G.GL_BYTE = gl.BYTE _G.GL_CW = gl.CW _G.GL_DYNAMIC_DRAW = gl.DYNAMIC_DRAW _G.GL_RENDERBUFFER_RED_SIZE = gl.RENDERBUFFER_RED_SIZE _G.GL_FALSE = gl.FALSE _G.GL_GREATER = gl.GREATER _G.GL_RGBA4 = gl.RGBA4 _G.GL_VALIDATE_STATUS = gl.VALIDATE_STATUS _G.GL_STENCIL_BITS = gl.STENCIL_BITS _G.GL_RGB = gl.RGB _G.GL_INT = gl.INT _G.GL_DEPTH_FUNC = gl.DEPTH_FUNC _G.GL_SAMPLER_2D = gl.SAMPLER_2D _G.GL_NICEST = gl.NICEST _G.GL_MAX_VIEWPORT_DIMS = gl.MAX_VIEWPORT_DIMS _G.GL_CULL_FACE = gl.CULL_FACE _G.GL_INT_VEC3 = gl.INT_VEC3 _G.GL_ALIASED_POINT_SIZE_RANGE = gl.ALIASED_POINT_SIZE_RANGE _G.GL_INVALID_ENUM = gl.INVALID_ENUM _G.GL_INVERT = gl.INVERT _G.GL_CULL_FACE_MODE = gl.CULL_FACE_MODE _G.GL_TEXTURE8 = gl.TEXTURE8 _G.GL_VERTEX_ATTRIB_ARRAY_POINTER = gl.VERTEX_ATTRIB_ARRAY_POINTER _G.GL_TEXTURE_WRAP_S = gl.TEXTURE_WRAP_S _G.GL_VERTEX_ATTRIB_ARRAY_STRIDE = gl.VERTEX_ATTRIB_ARRAY_STRIDE _G.GL_LINES = gl.LINES _G.GL_EQUAL = gl.EQUAL _G.GL_LINE_LOOP = gl.LINE_LOOP _G.GL_TEXTURE_WRAP_T = gl.TEXTURE_WRAP_T _G.GL_DEPTH_BUFFER_BIT = gl.DEPTH_BUFFER_BIT _G.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS _G.GL_SHADER_TYPE = gl.SHADER_TYPE _G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_X = gl.TEXTURE_CUBE_MAP_NEGATIVE_X _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = gl.TEXTURE_CUBE_MAP_NEGATIVE_Y _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = gl.TEXTURE_CUBE_MAP_NEGATIVE_Z _G.GL_DECR = gl.DECR _G.GL_DELETE_STATUS = gl.DELETE_STATUS _G.GL_DEPTH_BITS = gl.DEPTH_BITS _G.GL_INCR = gl.INCR _G.GL_SAMPLE_COVERAGE_VALUE = gl.SAMPLE_COVERAGE_VALUE _G.GL_ALPHA_BITS = gl.ALPHA_BITS _G.GL_FLOAT_MAT2 = gl.FLOAT_MAT2 _G.GL_LINE_STRIP = gl.LINE_STRIP _G.GL_SHADER_SOURCE_LENGTH = gl.SHADER_SOURCE_LENGTH _G.GL_INVALID_VALUE = gl.INVALID_VALUE _G.GL_NEVER = gl.NEVER _G.GL_INCR_WRAP = gl.INCR_WRAP _G.GL_BLEND_EQUATION_ALPHA = gl.BLEND_EQUATION_ALPHA _G.GL_TEXTURE_MAG_FILTER = gl.TEXTURE_MAG_FILTER _G.GL_POINTS = gl.POINTS _G.GL_COLOR_ATTACHMENT0 = gl.COLOR_ATTACHMENT0 _G.GL_RGBA = gl.RGBA _G.GL_SRC_ALPHA_SATURATE = gl.SRC_ALPHA_SATURATE _G.GL_SAMPLER_CUBE = gl.SAMPLER_CUBE _G.GL_FRAMEBUFFER = gl.FRAMEBUFFER _G.GL_TEXTURE_CUBE_MAP = gl.TEXTURE_CUBE_MAP _G.GL_SAMPLE_BUFFERS = gl.SAMPLE_BUFFERS _G.GL_LINEAR = gl.LINEAR _G.GL_LINEAR_MIPMAP_NEAREST = gl.LINEAR_MIPMAP_NEAREST _G.GL_ACTIVE_UNIFORM_MAX_LENGTH = gl.ACTIVE_UNIFORM_MAX_LENGTH _G.GL_STENCIL_BACK_REF = gl.STENCIL_BACK_REF _G.GL_ELEMENT_ARRAY_BUFFER = gl.ELEMENT_ARRAY_BUFFER _G.GL_CLAMP_TO_EDGE = gl.CLAMP_TO_EDGE _G.GL_TRIANGLE_STRIP = gl.TRIANGLE_STRIP _G.GL_CONSTANT_COLOR = gl.CONSTANT_COLOR _G.GL_COMPILE_STATUS = gl.COMPILE_STATUS _G.GL_RENDERBUFFER_GREEN_SIZE = gl.RENDERBUFFER_GREEN_SIZE _G.GL_UNSIGNED_INT = gl.UNSIGNED_INT _G.GL_DEPTH_CLEAR_VALUE = gl.DEPTH_CLEAR_VALUE _G.GL_ALIASED_LINE_WIDTH_RANGE = gl.ALIASED_LINE_WIDTH_RANGE _G.GL_SHADING_LANGUAGE_VERSION = gl.SHADING_LANGUAGE_VERSION _G.GL_FRAMEBUFFER_UNSUPPORTED = gl.FRAMEBUFFER_UNSUPPORTED _G.GL_INFO_LOG_LENGTH = gl.INFO_LOG_LENGTH _G.GL_STENCIL_PASS_DEPTH_PASS = gl.STENCIL_PASS_DEPTH_PASS _G.GL_STENCIL_VALUE_MASK = gl.STENCIL_VALUE_MASK _G.GL_ALWAYS = gl.ALWAYS _G.GL_MAX_TEXTURE_SIZE = gl.MAX_TEXTURE_SIZE _G.GL_FLOAT = gl.FLOAT _G.GL_FRAMEBUFFER_BINDING = gl.FRAMEBUFFER_BINDING _G.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT _G.GL_TRIANGLE_FAN = gl.TRIANGLE_FAN _G.GL_INVALID_FRAMEBUFFER_OPERATION = gl.INVALID_FRAMEBUFFER_OPERATION _G.GL_TEXTURE_2D = gl.TEXTURE_2D _G.GL_ALPHA = gl.ALPHA _G.GL_CURRENT_VERTEX_ATTRIB = gl.CURRENT_VERTEX_ATTRIB _G.GL_SCISSOR_TEST = gl.SCISSOR_TEST _G.GL_TRIANGLES = gl.TRIANGLES _G.CCControlEventTouchDown = cc.CONTROL_EVENTTYPE_TOUCH_DOWN _G.CCControlEventTouchDragInside = cc.CONTROL_EVENTTYPE_DRAG_INSIDE _G.CCControlEventTouchDragOutside = cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE _G.CCControlEventTouchDragEnter = cc.CONTROL_EVENTTYPE_DRAG_ENTER _G.CCControlEventTouchDragExit = cc.CONTROL_EVENTTYPE_DRAG_EXIT _G.CCControlEventTouchUpInside = cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE _G.CCControlEventTouchUpOutside = cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE _G.CCControlEventTouchCancel = cc.CONTROL_EVENTTYPE_TOUCH_CANCEL _G.CCControlEventValueChanged = cc.CONTROL_EVENTTYPE_VALUE_CHANGED _G.CCControlStateNormal = cc.CONTROL_STATE_NORMAL _G.CCControlStateHighlighted = cc.CONTROL_STATE_HIGH_LIGHTED _G.CCControlStateDisabled = cc.CONTROL_STATE_DISABLED _G.CCControlStateSelected = cc.CONTROL_STATE_SELECTED _G.kWebSocketScriptHandlerOpen = cc.WEBSOCKET_OPEN _G.kWebSocketScriptHandlerMessage = cc.WEBSOCKET_MESSAGE _G.kWebSocketScriptHandlerClose = cc.WEBSOCKET_CLOSE _G.kWebSocketScriptHandlerError = cc.WEBSOCKET_ERROR _G.kStateConnecting = cc.WEBSOCKET_STATE_CONNECTING _G.kStateOpen = cc.WEBSOCKET_STATE_OPEN _G.kStateClosing = cc.WEBSOCKET_STATE_CLOSING _G.kStateClosed = cc.WEBSOCKET_STATE_CLOSED _G.LAYOUT_COLOR_NONE = ccs.LayoutBackGroundColorType.none _G.LAYOUT_COLOR_SOLID = ccs.LayoutBackGroundColorType.solid _G.LAYOUT_COLOR_GRADIENT = ccs.LayoutBackGroundColorType.gradient _G.LAYOUT_ABSOLUTE = ccs.LayoutType.absolute _G.LAYOUT_LINEAR_VERTICAL = ccs.LayoutType.linearVertical _G.LAYOUT_LINEAR_HORIZONTAL = ccs.LayoutType.linearHorizontal _G.LAYOUT_RELATIVE = ccs.LayoutType.relative _G.BRIGHT_NONE = ccs.BrightStyle.none _G.BRIGHT_NORMAL = ccs.BrightStyle.normal _G.BRIGHT_HIGHLIGHT = ccs.BrightStyle.highlight _G.WidgetTypeWidget = ccs.WidgetType.widget _G.WidgetTypeContainer = ccs.WidgetType.container _G.UI_TEX_TYPE_LOCAL = ccs.TextureResType.UI_TEX_TYPE_LOCAL _G.UI_TEX_TYPE_PLIST = ccs.TextureResType.UI_TEX_TYPE_PLIST _G.TOUCH_EVENT_BEGAN = ccs.TouchEventType.began _G.TOUCH_EVENT_MOVED = ccs.TouchEventType.moved _G.TOUCH_EVENT_ENDED = ccs.TouchEventType.ended _G.TOUCH_EVENT_CANCELED = ccs.TouchEventType.canceled _G.SIZE_ABSOLUTE = ccs.SizeType.absolute _G.SIZE_PERCENT = ccs.SizeType.percent _G.POSITION_ABSOLUTE = ccs.PositionType.absolute _G.POSITION_PERCENT = ccs.PositionType.percent _G.CHECKBOX_STATE_EVENT_SELECTED = ccs.CheckBoxEventType.selected _G.CHECKBOX_STATE_EVENT_UNSELECTED = ccs.CheckBoxEventType.unselected _G.CHECKBOX_STATE_EVENT_SELECTED = ccs.CheckBoxEventType.selected _G.CHECKBOX_STATE_EVENT_UNSELECTED = ccs.CheckBoxEventType.unselected _G.LoadingBarTypeLeft = ccs.LoadingBarType.left _G.LoadingBarTypeRight = ccs.LoadingBarType.right _G.LoadingBarTypeRight = ccs.SliderEventType.percent_changed _G.TEXTFIELD_EVENT_ATTACH_WITH_IME = ccs.TextFiledEventType.attach_with_ime _G.TEXTFIELD_EVENT_DETACH_WITH_IME = ccs.TextFiledEventType.detach_with_ime _G.TEXTFIELD_EVENT_INSERT_TEXT = ccs.TextFiledEventType.insert_text _G.TEXTFIELD_EVENT_DELETE_BACKWARD = ccs.TextFiledEventType.delete_backward _G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccs.SCROLLVIEW_DIR.none _G.SCROLLVIEW_DIR_VERTICAL = ccs.SCROLLVIEW_DIR.vertical _G.SCROLLVIEW_DIR_HORIZONTAL = ccs.SCROLLVIEW_DIR.horizontal _G.SCROLLVIEW_DIR_BOTH = ccs.SCROLLVIEW_DIR.both _G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccs.ScrollviewEventType.SCROLL_TO_TOP _G.SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccs.ScrollviewEventType.SCROLL_TO_BOTTOM _G.SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccs.ScrollviewEventType.SCROLL_TO_LEFT _G.SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccs.ScrollviewEventType.SCROLL_TO_RIGHT _G.SCROLLVIEW_EVENT_SCROLLING = ccs.ScrollviewEventType.SCROLLING _G.SCROLLVIEW_EVENT_BOUNCE_TOP = ccs.ScrollviewEventType.BOUNCE_TOP _G.SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccs.ScrollviewEventType.BOUNCE_BOTTOM _G.SCROLLVIEW_EVENT_BOUNCE_LEFT = ccs.ScrollviewEventType.BOUNCE_LEFT _G.SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccs.ScrollviewEventType.BOUNCE_RIGHT _G.PAGEVIEW_EVENT_TURNING = ccs.PageViewEventType.turning _G.PAGEVIEW_TOUCHLEFT = ccs.PVTouchDir.touch_left _G.PAGEVIEW_TOUCHRIGHT = ccs.PVTouchDir.touch_right _G.LISTVIEW_DIR_NONE = ccs.ListViewDirection.none _G.LISTVIEW_DIR_VERTICAL = ccs.ListViewDirection.vertical _G.LISTVIEW_DIR_HORIZONTAL = ccs.ListViewDirection.horizontal _G.LISTVIEW_MOVE_DIR_NONE = ccs.ListViewMoveDirection.none _G.LISTVIEW_MOVE_DIR_UP = ccs.ListViewMoveDirection.up _G.LISTVIEW_MOVE_DIR_DOWN = ccs.ListViewMoveDirection.down _G.LISTVIEW_MOVE_DIR_LEFT = ccs.ListViewMoveDirection.left _G.LISTVIEW_MOVE_DIR_RIGHT = ccs.ListViewMoveDirection.right _G.LISTVIEW_EVENT_INIT_CHILD = ccs.ListViewEventType.init_child _G.LISTVIEW_EVENT_UPDATE_CHILD = ccs.ListViewEventType.update_child _G.LAYOUT_PARAMETER_NONE = ccs.UILayoutParameterType.none _G.LAYOUT_PARAMETER_LINEAR = ccs.UILayoutParameterType.linear _G.LAYOUT_PARAMETER_RELATIVE = ccs.UILayoutParameterType.relative _G.kCCScrollViewDirectionHorizontal = cc.SCROLLVIEW_DIRECTION_HORIZONTAL _G.kCCScrollViewDirectionVertical = cc.SCROLLVIEW_DIRECTION_VERTICAL _G.kCCTableViewFillTopDown = cc.TABLEVIEW_FILL_TOPDOWN _G.kCCTableViewFillBottomUp = cc.TABLEVIEW_FILL_BOTTOMUP ================================================ FILE: Resources/DeprecatedOpenglEnum.lua ================================================ -- This is the DeprecatedEnum DeprecatedClass = {} or DeprecatedClass _G.GL_RENDERBUFFER_INTERNAL_FORMAT = gl.RENDERBUFFER_INTERNAL_FORMAT _G.GL_LINE_WIDTH = gl.LINE_WIDTH _G.GL_CONSTANT_ALPHA = gl.CONSTANT_ALPHA _G.GL_BLEND_SRC_ALPHA = gl.BLEND_SRC_ALPHA _G.GL_GREEN_BITS = gl.GREEN_BITS _G.GL_STENCIL_REF = gl.STENCIL_REF _G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA _G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE _G.GL_CCW = gl.CCW _G.GL_MAX_TEXTURE_IMAGE_UNITS = gl.MAX_TEXTURE_IMAGE_UNITS _G.GL_BACK = gl.BACK _G.GL_ACTIVE_ATTRIBUTES = gl.ACTIVE_ATTRIBUTES _G.GL_TEXTURE_CUBE_MAP_POSITIVE_X = gl.TEXTURE_CUBE_MAP_POSITIVE_X _G.GL_STENCIL_BACK_VALUE_MASK = gl.STENCIL_BACK_VALUE_MASK _G.GL_TEXTURE_CUBE_MAP_POSITIVE_Z = gl.TEXTURE_CUBE_MAP_POSITIVE_Z _G.GL_ONE = gl.ONE _G.GL_TRUE = gl.TRUE _G.GL_TEXTURE12 = gl.TEXTURE12 _G.GL_LINK_STATUS = gl.LINK_STATUS _G.GL_BLEND = gl.BLEND _G.GL_LESS = gl.LESS _G.GL_TEXTURE16 = gl.TEXTURE16 _G.GL_BOOL_VEC2 = gl.BOOL_VEC2 _G.GL_KEEP = gl.KEEP _G.GL_DST_COLOR = gl.DST_COLOR _G.GL_VERTEX_ATTRIB_ARRAY_ENABLED = gl.VERTEX_ATTRIB_ARRAY_ENABLED _G.GL_EXTENSIONS = gl.EXTENSIONS _G.GL_FRONT = gl.FRONT _G.GL_DST_ALPHA = gl.DST_ALPHA _G.GL_ATTACHED_SHADERS = gl.ATTACHED_SHADERS _G.GL_STENCIL_BACK_FUNC = gl.STENCIL_BACK_FUNC _G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR _G.GL_BLEND_EQUATION = gl.BLEND_EQUATION _G.GL_RENDERBUFFER_DEPTH_SIZE = gl.RENDERBUFFER_DEPTH_SIZE _G.GL_PACK_ALIGNMENT = gl.PACK_ALIGNMENT _G.GL_VENDOR = gl.VENDOR _G.GL_NEAREST_MIPMAP_LINEAR = gl.NEAREST_MIPMAP_LINEAR _G.GL_TEXTURE_CUBE_MAP_POSITIVE_Y = gl.TEXTURE_CUBE_MAP_POSITIVE_Y _G.GL_NEAREST = gl.NEAREST _G.GL_RENDERBUFFER_WIDTH = gl.RENDERBUFFER_WIDTH _G.GL_ARRAY_BUFFER_BINDING = gl.ARRAY_BUFFER_BINDING _G.GL_ARRAY_BUFFER = gl.ARRAY_BUFFER _G.GL_LEQUAL = gl.LEQUAL _G.GL_VERSION = gl.VERSION _G.GL_COLOR_CLEAR_VALUE = gl.COLOR_CLEAR_VALUE _G.GL_RENDERER = gl.RENDERER _G.GL_STENCIL_BACK_PASS_DEPTH_PASS = gl.STENCIL_BACK_PASS_DEPTH_PASS _G.GL_STENCIL_BACK_PASS_DEPTH_FAIL = gl.STENCIL_BACK_PASS_DEPTH_FAIL _G.GL_STENCIL_BACK_WRITEMASK = gl.STENCIL_BACK_WRITEMASK _G.GL_BOOL = gl.BOOL _G.GL_VIEWPORT = gl.VIEWPORT _G.GL_FRAGMENT_SHADER = gl.FRAGMENT_SHADER _G.GL_LUMINANCE = gl.LUMINANCE _G.GL_DECR_WRAP = gl.DECR_WRAP _G.GL_FUNC_ADD = gl.FUNC_ADD _G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA _G.GL_OUT_OF_MEMORY = gl.OUT_OF_MEMORY _G.GL_BOOL_VEC4 = gl.BOOL_VEC4 _G.GL_POLYGON_OFFSET_FACTOR = gl.POLYGON_OFFSET_FACTOR _G.GL_STATIC_DRAW = gl.STATIC_DRAW _G.GL_DITHER = gl.DITHER _G.GL_TEXTURE31 = gl.TEXTURE31 _G.GL_TEXTURE30 = gl.TEXTURE30 _G.GL_UNSIGNED_BYTE = gl.UNSIGNED_BYTE _G.GL_DEPTH_COMPONENT16 = gl.DEPTH_COMPONENT16 _G.GL_TEXTURE23 = gl.TEXTURE23 _G.GL_DEPTH_TEST = gl.DEPTH_TEST _G.GL_STENCIL_PASS_DEPTH_FAIL = gl.STENCIL_PASS_DEPTH_FAIL _G.GL_BOOL_VEC3 = gl.BOOL_VEC3 _G.GL_POLYGON_OFFSET_UNITS = gl.POLYGON_OFFSET_UNITS _G.GL_TEXTURE_BINDING_2D = gl.TEXTURE_BINDING_2D _G.GL_TEXTURE21 = gl.TEXTURE21 _G.GL_UNPACK_ALIGNMENT = gl.UNPACK_ALIGNMENT _G.GL_DONT_CARE = gl.DONT_CARE _G.GL_BUFFER_SIZE = gl.BUFFER_SIZE _G.GL_FLOAT_MAT3 = gl.FLOAT_MAT3 _G.GL_UNSIGNED_SHORT_5_6_5 = gl.UNSIGNED_SHORT_5_6_5 _G.GL_INT_VEC2 = gl.INT_VEC2 _G.GL_UNSIGNED_SHORT_4_4_4_4 = gl.UNSIGNED_SHORT_4_4_4_4 _G.GL_NONE = gl.NONE _G.GL_BLEND_DST_ALPHA = gl.BLEND_DST_ALPHA _G.GL_VERTEX_ATTRIB_ARRAY_SIZE = gl.VERTEX_ATTRIB_ARRAY_SIZE _G.GL_SRC_COLOR = gl.SRC_COLOR _G.GL_COMPRESSED_TEXTURE_FORMATS = gl.COMPRESSED_TEXTURE_FORMATS _G.GL_STENCIL_ATTACHMENT = gl.STENCIL_ATTACHMENT _G.GL_MAX_VERTEX_ATTRIBS = gl.MAX_VERTEX_ATTRIBS _G.GL_NUM_COMPRESSED_TEXTURE_FORMATS = gl.NUM_COMPRESSED_TEXTURE_FORMATS _G.GL_BLEND_EQUATION_RGB = gl.BLEND_EQUATION_RGB _G.GL_TEXTURE = gl.TEXTURE _G.GL_LINEAR_MIPMAP_LINEAR = gl.LINEAR_MIPMAP_LINEAR _G.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING _G.GL_CURRENT_PROGRAM = gl.CURRENT_PROGRAM _G.GL_COLOR_BUFFER_BIT = gl.COLOR_BUFFER_BIT _G.GL_TEXTURE20 = gl.TEXTURE20 _G.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = gl.ACTIVE_ATTRIBUTE_MAX_LENGTH _G.GL_TEXTURE28 = gl.TEXTURE28 _G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE _G.GL_TEXTURE22 = gl.TEXTURE22 _G.GL_ELEMENT_ARRAY_BUFFER_BINDING = gl.ELEMENT_ARRAY_BUFFER_BINDING _G.GL_STREAM_DRAW = gl.STREAM_DRAW _G.GL_SCISSOR_BOX = gl.SCISSOR_BOX _G.GL_TEXTURE26 = gl.TEXTURE26 _G.GL_TEXTURE27 = gl.TEXTURE27 _G.GL_TEXTURE24 = gl.TEXTURE24 _G.GL_TEXTURE25 = gl.TEXTURE25 _G.GL_NO_ERROR = gl.NO_ERROR _G.GL_TEXTURE29 = gl.TEXTURE29 _G.GL_FLOAT_MAT4 = gl.FLOAT_MAT4 _G.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = gl.VERTEX_ATTRIB_ARRAY_NORMALIZED _G.GL_SAMPLE_COVERAGE_INVERT = gl.SAMPLE_COVERAGE_INVERT _G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL _G.GL_FLOAT_VEC3 = gl.FLOAT_VEC3 _G.GL_STENCIL_CLEAR_VALUE = gl.STENCIL_CLEAR_VALUE _G.GL_UNSIGNED_SHORT_5_5_5_1 = gl.UNSIGNED_SHORT_5_5_5_1 _G.GL_ACTIVE_UNIFORMS = gl.ACTIVE_UNIFORMS _G.GL_INVALID_OPERATION = gl.INVALID_OPERATION _G.GL_DEPTH_ATTACHMENT = gl.DEPTH_ATTACHMENT _G.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS _G.GL_FRAMEBUFFER_COMPLETE = gl.FRAMEBUFFER_COMPLETE _G.GL_ONE_MINUS_CONSTANT_COLOR = gl.ONE_MINUS_CONSTANT_COLOR _G.GL_TEXTURE2 = gl.TEXTURE2 _G.GL_TEXTURE1 = gl.TEXTURE1 _G.GL_GEQUAL = gl.GEQUAL _G.GL_TEXTURE7 = gl.TEXTURE7 _G.GL_TEXTURE6 = gl.TEXTURE6 _G.GL_TEXTURE5 = gl.TEXTURE5 _G.GL_TEXTURE4 = gl.TEXTURE4 _G.GL_GENERATE_MIPMAP_HINT = gl.GENERATE_MIPMAP_HINT _G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR _G.GL_TEXTURE9 = gl.TEXTURE9 _G.GL_STENCIL_TEST = gl.STENCIL_TEST _G.GL_COLOR_WRITEMASK = gl.COLOR_WRITEMASK _G.GL_DEPTH_COMPONENT = gl.DEPTH_COMPONENT _G.GL_STENCIL_INDEX8 = gl.STENCIL_INDEX8 _G.GL_VERTEX_ATTRIB_ARRAY_TYPE = gl.VERTEX_ATTRIB_ARRAY_TYPE _G.GL_FLOAT_VEC2 = gl.FLOAT_VEC2 _G.GL_BLUE_BITS = gl.BLUE_BITS _G.GL_VERTEX_SHADER = gl.VERTEX_SHADER _G.GL_SUBPIXEL_BITS = gl.SUBPIXEL_BITS _G.GL_STENCIL_WRITEMASK = gl.STENCIL_WRITEMASK _G.GL_FLOAT_VEC4 = gl.FLOAT_VEC4 _G.GL_TEXTURE17 = gl.TEXTURE17 _G.GL_ONE_MINUS_CONSTANT_ALPHA = gl.ONE_MINUS_CONSTANT_ALPHA _G.GL_TEXTURE15 = gl.TEXTURE15 _G.GL_TEXTURE14 = gl.TEXTURE14 _G.GL_TEXTURE13 = gl.TEXTURE13 _G.GL_SAMPLES = gl.SAMPLES _G.GL_TEXTURE11 = gl.TEXTURE11 _G.GL_TEXTURE10 = gl.TEXTURE10 _G.GL_FUNC_SUBTRACT = gl.FUNC_SUBTRACT _G.GL_STENCIL_BUFFER_BIT = gl.STENCIL_BUFFER_BIT _G.GL_TEXTURE19 = gl.TEXTURE19 _G.GL_TEXTURE18 = gl.TEXTURE18 _G.GL_NEAREST_MIPMAP_NEAREST = gl.NEAREST_MIPMAP_NEAREST _G.GL_SHORT = gl.SHORT _G.GL_RENDERBUFFER_BINDING = gl.RENDERBUFFER_BINDING _G.GL_REPEAT = gl.REPEAT _G.GL_TEXTURE_MIN_FILTER = gl.TEXTURE_MIN_FILTER _G.GL_RED_BITS = gl.RED_BITS _G.GL_FRONT_FACE = gl.FRONT_FACE _G.GL_BLEND_COLOR = gl.BLEND_COLOR _G.GL_MIRRORED_REPEAT = gl.MIRRORED_REPEAT _G.GL_INT_VEC4 = gl.INT_VEC4 _G.GL_MAX_CUBE_MAP_TEXTURE_SIZE = gl.MAX_CUBE_MAP_TEXTURE_SIZE _G.GL_RENDERBUFFER_BLUE_SIZE = gl.RENDERBUFFER_BLUE_SIZE _G.GL_SAMPLE_COVERAGE = gl.SAMPLE_COVERAGE _G.GL_SRC_ALPHA = gl.SRC_ALPHA _G.GL_FUNC_REVERSE_SUBTRACT = gl.FUNC_REVERSE_SUBTRACT _G.GL_DEPTH_WRITEMASK = gl.DEPTH_WRITEMASK _G.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT _G.GL_POLYGON_OFFSET_FILL = gl.POLYGON_OFFSET_FILL _G.GL_STENCIL_FUNC = gl.STENCIL_FUNC _G.GL_REPLACE = gl.REPLACE _G.GL_LUMINANCE_ALPHA = gl.LUMINANCE_ALPHA _G.GL_DEPTH_RANGE = gl.DEPTH_RANGE _G.GL_FASTEST = gl.FASTEST _G.GL_STENCIL_FAIL = gl.STENCIL_FAIL _G.GL_UNSIGNED_SHORT = gl.UNSIGNED_SHORT _G.GL_RENDERBUFFER_HEIGHT = gl.RENDERBUFFER_HEIGHT _G.GL_STENCIL_BACK_FAIL = gl.STENCIL_BACK_FAIL _G.GL_BLEND_SRC_RGB = gl.BLEND_SRC_RGB _G.GL_TEXTURE3 = gl.TEXTURE3 _G.GL_RENDERBUFFER = gl.RENDERBUFFER _G.GL_RGB5_A1 = gl.RGB5_A1 _G.GL_RENDERBUFFER_ALPHA_SIZE = gl.RENDERBUFFER_ALPHA_SIZE _G.GL_RENDERBUFFER_STENCIL_SIZE = gl.RENDERBUFFER_STENCIL_SIZE _G.GL_NOTEQUAL = gl.NOTEQUAL _G.GL_BLEND_DST_RGB = gl.BLEND_DST_RGB _G.GL_FRONT_AND_BACK = gl.FRONT_AND_BACK _G.GL_TEXTURE_BINDING_CUBE_MAP = gl.TEXTURE_BINDING_CUBE_MAP _G.GL_MAX_RENDERBUFFER_SIZE = gl.MAX_RENDERBUFFER_SIZE _G.GL_ZERO = gl.ZERO _G.GL_TEXTURE0 = gl.TEXTURE0 _G.GL_SAMPLE_ALPHA_TO_COVERAGE = gl.SAMPLE_ALPHA_TO_COVERAGE _G.GL_BUFFER_USAGE = gl.BUFFER_USAGE _G.GL_ACTIVE_TEXTURE = gl.ACTIVE_TEXTURE _G.GL_BYTE = gl.BYTE _G.GL_CW = gl.CW _G.GL_DYNAMIC_DRAW = gl.DYNAMIC_DRAW _G.GL_RENDERBUFFER_RED_SIZE = gl.RENDERBUFFER_RED_SIZE _G.GL_FALSE = gl.FALSE _G.GL_GREATER = gl.GREATER _G.GL_RGBA4 = gl.RGBA4 _G.GL_VALIDATE_STATUS = gl.VALIDATE_STATUS _G.GL_STENCIL_BITS = gl.STENCIL_BITS _G.GL_RGB = gl.RGB _G.GL_INT = gl.INT _G.GL_DEPTH_FUNC = gl.DEPTH_FUNC _G.GL_SAMPLER_2D = gl.SAMPLER_2D _G.GL_NICEST = gl.NICEST _G.GL_MAX_VIEWPORT_DIMS = gl.MAX_VIEWPORT_DIMS _G.GL_CULL_FACE = gl.CULL_FACE _G.GL_INT_VEC3 = gl.INT_VEC3 _G.GL_ALIASED_POINT_SIZE_RANGE = gl.ALIASED_POINT_SIZE_RANGE _G.GL_INVALID_ENUM = gl.INVALID_ENUM _G.GL_INVERT = gl.INVERT _G.GL_CULL_FACE_MODE = gl.CULL_FACE_MODE _G.GL_TEXTURE8 = gl.TEXTURE8 _G.GL_VERTEX_ATTRIB_ARRAY_POINTER = gl.VERTEX_ATTRIB_ARRAY_POINTER _G.GL_TEXTURE_WRAP_S = gl.TEXTURE_WRAP_S _G.GL_VERTEX_ATTRIB_ARRAY_STRIDE = gl.VERTEX_ATTRIB_ARRAY_STRIDE _G.GL_LINES = gl.LINES _G.GL_EQUAL = gl.EQUAL _G.GL_LINE_LOOP = gl.LINE_LOOP _G.GL_TEXTURE_WRAP_T = gl.TEXTURE_WRAP_T _G.GL_DEPTH_BUFFER_BIT = gl.DEPTH_BUFFER_BIT _G.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS _G.GL_SHADER_TYPE = gl.SHADER_TYPE _G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_X = gl.TEXTURE_CUBE_MAP_NEGATIVE_X _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = gl.TEXTURE_CUBE_MAP_NEGATIVE_Y _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = gl.TEXTURE_CUBE_MAP_NEGATIVE_Z _G.GL_DECR = gl.DECR _G.GL_DELETE_STATUS = gl.DELETE_STATUS _G.GL_DEPTH_BITS = gl.DEPTH_BITS _G.GL_INCR = gl.INCR _G.GL_SAMPLE_COVERAGE_VALUE = gl.SAMPLE_COVERAGE_VALUE _G.GL_ALPHA_BITS = gl.ALPHA_BITS _G.GL_FLOAT_MAT2 = gl.FLOAT_MAT2 _G.GL_LINE_STRIP = gl.LINE_STRIP _G.GL_SHADER_SOURCE_LENGTH = gl.SHADER_SOURCE_LENGTH _G.GL_INVALID_VALUE = gl.INVALID_VALUE _G.GL_NEVER = gl.NEVER _G.GL_INCR_WRAP = gl.INCR_WRAP _G.GL_BLEND_EQUATION_ALPHA = gl.BLEND_EQUATION_ALPHA _G.GL_TEXTURE_MAG_FILTER = gl.TEXTURE_MAG_FILTER _G.GL_POINTS = gl.POINTS _G.GL_COLOR_ATTACHMENT0 = gl.COLOR_ATTACHMENT0 _G.GL_RGBA = gl.RGBA _G.GL_SRC_ALPHA_SATURATE = gl.SRC_ALPHA_SATURATE _G.GL_SAMPLER_CUBE = gl.SAMPLER_CUBE _G.GL_FRAMEBUFFER = gl.FRAMEBUFFER _G.GL_TEXTURE_CUBE_MAP = gl.TEXTURE_CUBE_MAP _G.GL_SAMPLE_BUFFERS = gl.SAMPLE_BUFFERS _G.GL_LINEAR = gl.LINEAR _G.GL_LINEAR_MIPMAP_NEAREST = gl.LINEAR_MIPMAP_NEAREST _G.GL_ACTIVE_UNIFORM_MAX_LENGTH = gl.ACTIVE_UNIFORM_MAX_LENGTH _G.GL_STENCIL_BACK_REF = gl.STENCIL_BACK_REF _G.GL_ELEMENT_ARRAY_BUFFER = gl.ELEMENT_ARRAY_BUFFER _G.GL_CLAMP_TO_EDGE = gl.CLAMP_TO_EDGE _G.GL_TRIANGLE_STRIP = gl.TRIANGLE_STRIP _G.GL_CONSTANT_COLOR = gl.CONSTANT_COLOR _G.GL_COMPILE_STATUS = gl.COMPILE_STATUS _G.GL_RENDERBUFFER_GREEN_SIZE = gl.RENDERBUFFER_GREEN_SIZE _G.GL_UNSIGNED_INT = gl.UNSIGNED_INT _G.GL_DEPTH_CLEAR_VALUE = gl.DEPTH_CLEAR_VALUE _G.GL_ALIASED_LINE_WIDTH_RANGE = gl.ALIASED_LINE_WIDTH_RANGE _G.GL_SHADING_LANGUAGE_VERSION = gl.SHADING_LANGUAGE_VERSION _G.GL_FRAMEBUFFER_UNSUPPORTED = gl.FRAMEBUFFER_UNSUPPORTED _G.GL_INFO_LOG_LENGTH = gl.INFO_LOG_LENGTH _G.GL_STENCIL_PASS_DEPTH_PASS = gl.STENCIL_PASS_DEPTH_PASS _G.GL_STENCIL_VALUE_MASK = gl.STENCIL_VALUE_MASK _G.GL_ALWAYS = gl.ALWAYS _G.GL_MAX_TEXTURE_SIZE = gl.MAX_TEXTURE_SIZE _G.GL_FLOAT = gl.FLOAT _G.GL_FRAMEBUFFER_BINDING = gl.FRAMEBUFFER_BINDING _G.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT _G.GL_TRIANGLE_FAN = gl.TRIANGLE_FAN _G.GL_INVALID_FRAMEBUFFER_OPERATION = gl.INVALID_FRAMEBUFFER_OPERATION _G.GL_TEXTURE_2D = gl.TEXTURE_2D _G.GL_ALPHA = gl.ALPHA _G.GL_CURRENT_VERTEX_ATTRIB = gl.CURRENT_VERTEX_ATTRIB _G.GL_SCISSOR_TEST = gl.SCISSOR_TEST _G.GL_TRIANGLES = gl.TRIANGLES ================================================ FILE: Resources/DrawPrimitives.lua ================================================ local dp_initialized = false local dp_shader = nil local dp_colorLocation = -1 local dp_color = { 1.0, 1.0, 1.0, 1.0 } local dp_pointSizeLocation = -1 local dp_pointSize = 1.0 local SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor" local targetPlatform = CCApplication:getInstance():getTargetPlatform() local function lazy_init() if not dp_initialized then dp_shader = CCShaderCache:getInstance():getProgram(SHADER_NAME_POSITION_U_COLOR) --dp_shader:retain() if nil ~= dp_shader then dp_colorLocation = gl.getUniformLocation( dp_shader:getProgram(), "u_color") dp_pointSizeLocation = gl.getUniformLocation( dp_shader:getProgram(), "u_pointSize") dp_Initialized = true end end if nil == dp_shader then print("Error:dp_shader is nil!") return false end return true end local function setDrawProperty() gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION ) dp_shader:use() dp_shader:setUniformsForBuiltins() dp_shader:setUniformLocationWith4fv(dp_colorLocation, dp_color, 1) end function ccDrawInit() lazy_init() end function ccDrawFree() dp_initialized = false end function ccDrawColor4f(r,g,b,a) dp_color[1] = r dp_color[2] = g dp_color[3] = b dp_color[4] = a end function ccPointSize(pointSize) dp_pointSize = pointSize * CCDirector:getInstance():getContentScaleFactor() end function ccDrawColor4B(r,g,b,a) dp_color[1] = r / 255.0 dp_color[2] = g / 255.0 dp_color[3] = b / 255.0 dp_color[4] = a / 255.0 end function ccDrawPoint(point) if not lazy_init() then return end local vertexBuffer = { } local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) local vertices = { point.x,point.y} gl.bufferData(gl.ARRAY_BUFFER,2,vertices,gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() dp_shader:setUniformLocationWith1f(dp_pointSizeLocation, dp_pointSize) gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.POINTS,0,1) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawPoints(points,numOfPoint) if not lazy_init() then return end local vertexBuffer = {} local i = 1 local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) local vertices = {} for i = 1, numOfPoint do vertices[2 * i - 1] = points[i].x vertices[2 * i] = points[i].y end gl.bufferData(gl.ARRAY_BUFFER, numOfPoint * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() dp_shader:setUniformLocationWith1f(dp_pointSizeLocation, dp_pointSize) gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.POINTS,0,numOfPoint) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawLine(origin,destination) if not lazy_init() then return end local vertexBuffer = {} local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) local vertices = { origin.x, origin.y, destination.x, destination.y} gl.bufferData(gl.ARRAY_BUFFER,4,vertices,gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.LINES ,0,2) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawPoly(points,numOfPoints,closePolygon) if not lazy_init() then return end local vertexBuffer = {} local i = 1 local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) local vertices = {} for i = 1, numOfPoints do vertices[2 * i - 1] = points[i].x vertices[2 * i] = points[i].y end gl.bufferData(gl.ARRAY_BUFFER, numOfPoints * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) if closePolygon then gl.drawArrays(gl.LINE_LOOP , 0, numOfPoints) else gl.drawArrays(gl.LINE_STRIP, 0, numOfPoints) end gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawSolidPoly(points,numOfPoints,color) if not lazy_init() then return end local vertexBuffer = {} local i = 1 local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) local vertices = {} for i = 1, numOfPoints do vertices[2 * i - 1] = points[i].x vertices[2 * i] = points[i].y end gl.bufferData(gl.ARRAY_BUFFER, numOfPoints * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION ) dp_shader:use() dp_shader:setUniformsForBuiltins() dp_shader:setUniformLocationWith4fv(dp_colorLocation, color, 1) gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_FAN , 0, numOfPoints) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawRect(origin,destination) ccDrawLine(CCPoint:__call(origin.x, origin.y), CCPoint:__call(destination.x, origin.y)) ccDrawLine(CCPoint:__call(destination.x, origin.y), CCPoint:__call(destination.x, destination.y)) ccDrawLine(CCPoint:__call(destination.x, destination.y), CCPoint:__call(origin.x, destination.y)) ccDrawLine(CCPoint:__call(origin.x, destination.y), CCPoint:__call(origin.x, origin.y)) end function ccDrawSolidRect( origin,destination,color ) local vertices = { origin, CCPoint:__call(destination.x, origin.y) , destination, CCPoint:__call(origin.x, destination.y) } ccDrawSolidPoly(vertices,4,color) end function ccDrawCircleScale( center, radius, angle, segments,drawLineToCenter,scaleX,scaleY) if not lazy_init() then return end local additionalSegment = 1 if drawLineToCenter then additionalSegment = additionalSegment + 1 end local vertexBuffer = { } local function initBuffer() local coef = 2.0 * math.pi / segments local i = 1 local vertices = {} vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) for i = 1, segments + 1 do local rads = (i - 1) * coef local j = radius * math.cos(rads + angle) * scaleX + center.x local k = radius * math.sin(rads + angle) * scaleY + center.y vertices[i * 2 - 1] = j vertices[i * 2] = k end vertices[(segments + 2) * 2 - 1] = center.x vertices[(segments + 2) * 2] = center.y gl.bufferData(gl.ARRAY_BUFFER, (segments + 2) * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.LINE_STRIP , 0, segments + additionalSegment) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawCircle(center, radius, angle, segments, drawLineToCenter) ccDrawCircleScale(center, radius, angle, segments, drawLineToCenter, 1.0, 1.0) end function ccDrawSolidCircle(center, radius, angle, segments,scaleX,scaleY) if not lazy_init() then return end local vertexBuffer = { } local function initBuffer() local coef = 2.0 * math.pi / segments local i = 1 local vertices = {} vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) for i = 1, segments + 1 do local rads = (i - 1) * coef local j = radius * math.cos(rads + angle) * scaleX + center.x local k = radius * math.sin(rads + angle) * scaleY + center.y vertices[i * 2 - 1] = j vertices[i * 2] = k end vertices[(segments + 2) * 2 - 1] = center.x vertices[(segments + 2) * 2] = center.y gl.bufferData(gl.ARRAY_BUFFER, (segments + 2) * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_FAN , 0, segments + 1) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawQuadBezier(origin, control, destination, segments) if not lazy_init() then return end local vertexBuffer = { } local function initBuffer() local vertices = { } local i = 1 local t = 0.0 for i = 1, segments do vertices[2 * i - 1] = math.pow(1 - t,2) * origin.x + 2.0 * (1 - t) * t * control.x + t * t * destination.x vertices[2 * i] = math.pow(1 - t,2) * origin.y + 2.0 * (1 - t) * t * control.y + t * t * destination.y t = t + 1.0 / segments end vertices[2 * (segments + 1) - 1] = destination.x vertices[2 * (segments + 1)] = destination.y vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) gl.bufferData(gl.ARRAY_BUFFER, (segments + 1) * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.LINE_STRIP , 0, segments + 1) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawCubicBezier(origin, control1, control2, destination, segments) if not lazy_init then return end local vertexBuffer = { } local function initBuffer() local vertices = { } local t = 0 local i = 1 for i = 1, segments do vertices[2 * i - 1] = math.pow(1 - t,3) * origin.x + 3.0 * math.pow(1 - t, 2) * t * control1.x + 3.0 * (1 - t) * t * t * control2.x + t * t * t * destination.x vertices[2 * i] = math.pow(1 - t,3) * origin.y + 3.0 * math.pow(1 - t, 2) * t * control1.y + 3.0 * (1 - t) * t * t * control2.y + t * t * t * destination.y t = t + 1.0 / segments end vertices[2 * (segments + 1) - 1] = destination.x vertices[2 * (segments + 1)] = destination.y vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) gl.bufferData(gl.ARRAY_BUFFER, (segments + 1) * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.LINE_STRIP , 0, segments + 1) gl.bindBuffer(gl.ARRAY_BUFFER,0) end ================================================ FILE: Resources/GuiConstants.lua ================================================ ccui = ccui or {} ccui.BrightStyle = { none = -1, normal = 0, highlight = 1, } ccui.WidgetType = { widget = 0, --control container = 1, --container } ccui.TextureResType = { localType = 0, plistType = 1, } ccui.TouchEventType = { began = 0, moved = 1, ended = 2, canceled = 3, } ccui.SizeType = { absolute = 0, percent = 1, } ccui.PositionType = { absolute = 0, percent = 1, } ccui.CheckBoxEventType = { selected = 0, unselected = 1, } ccui.TextFiledEventType = { attach_with_ime = 0, detach_with_ime = 1, insert_text = 2, delete_backward = 3, } ccui.LayoutBackGroundColorType = { none = 0, solid = 1, gradient = 2, } ccui.LayoutType = { absolute = 0, linearVertical = 1, linearHorizontal = 2, relative = 3, } ccui.LayoutParameterType = { none = 0, linear = 1, relative = 2, } ccui.LinearGravity = { none = 0, left = 1, top = 2, right = 3, bottom = 4, centerVertical = 5, centerHorizontal = 6, } ccui.RelativeAlign = { alignNone = 0, alignParentTopLeft = 1, alignParentTopCenterHorizontal = 2, alignParentTopRight = 3, alignParentLeftCenterVertical = 4, centerInParent = 5, alignParentRightCenterVertical = 6, alignParentLeftBottom = 7, alignParentBottomCenterHorizontal = 8, alignParentRightBottom = 9, locationAboveLeftAlign = 10, locationAboveCenter = 11, locationAboveRightAlign = 12, locationLeftOfTopAlign = 13, locationLeftOfCenter = 14, locationLeftOfBottomAlign = 15, locationRightOfTopAlign = 16, locationRightOfCenter = 17, locationRightOfBottomAlign = 18, locationBelowLeftAlign = 19, locationBelowCenter = 20, locationBelowRightAlign = 21, } ccui.SliderEventType = {percentChanged = 0} ccui.LoadingBarType = { left = 0, right = 1} ccui.ScrollViewDir = { none = 0, vertical = 1, horizontal = 2, both = 3, } ccui.ScrollViewMoveDir = { none = 0, up = 1, down = 2, left = 3, right = 4, } ccui.ScrollviewEventType = { scrollToTop = 0, scrollToBottom = 1, scrollToLeft = 2, scrollToRight = 3, scrolling = 4, bounceTop = 5, bounceBottom = 6, bounceLeft = 7, bounceRight = 8, } ccui.ListViewDirection = { none = 0, vertical = 1, horizontal = 2, } ccui.ListViewMoveDirection = { none = 0, up = 1, down = 2, left = 3, right = 4, } ccui.ListViewEventType = { onsSelectedItem = 0, } ccui.PageViewEventType = { turning = 0, } ccui.PVTouchDir = { touchLeft = 0, touchRight = 1, } ccui.ListViewGravity = { left = 0, right = 1, centerHorizontal = 2, top = 3, bottom = 4 , centerVertical = 5, } ================================================ FILE: Resources/Opengl.lua ================================================ require "OpenglConstants" gl = gl or {} --Create functions function gl.createTexture() local retTable = {} retTable.texture_id = gl._createTexture() return retTable end function gl.createBuffer() local retTable = {} retTable.buffer_id = gl._createBuffer() return retTable end function gl.createRenderbuffer() local retTable = {} retTable.renderbuffer_id = gl._createRenderuffer() return retTable end function gl.createFramebuffer( ) local retTable = {} retTable.framebuffer_id = gl._createFramebuffer() return retTable end function gl.createProgram() local retTable = {} retTable.program_id = gl._createProgram() return retTable end function gl.createShader(shaderType) local retTable = {} retTable.shader_id = gl._createShader(shaderType) return retTable end --Delete Fun function gl.deleteTexture(texture) local texture_id = 0 if "number" == type(texture) then texture_id = texture elseif "table" == type(texture) then texture_id = texture.texture_id end gl._deleteTexture(texture_id) end function gl.deleteBuffer(buffer) local buffer_id = 0 if "number" == type(buffer) then buffer_id = buffer elseif "table" == type(buffer) then buffer_id = buffer.buffer_id end gl._deleteBuffer(buffer_id) end function gl.deleteRenderbuffer(buffer) local renderbuffer_id = 0 if "number" == type(buffer) then renderbuffer_id = buffer elseif "table" == type(buffer) then renderbuffer_id = buffer.renderbuffer_id end gl._deleteRenderbuffer(renderbuffer_id) end function gl.deleteFramebuffer(buffer) local framebuffer_id = 0 if "number" == type(buffer) then framebuffer_id = buffer elseif "table" == type(buffer) then framebuffer_id = buffer.framebuffer_id end gl._deleteFramebuffer(framebuffer_id) end function gl.deleteProgram( program ) local program_id = 0 if "number" == type(buffer) then program_id = program elseif "table" == type(program) then program_id = program.program_id end gl._deleteProgram(program_id) end function gl.deleteShader(shader) local shader_id = 0 if "number" == type(shader) then shader_id = shader elseif "table" == type(shader) then shader_id = shader.shader_id end gl._deleteShader(shader_id) end --Bind Related function gl.bindTexture(target, texture) local texture_id = 0 if "number" == type(texture) then texture_id = texture elseif "table" == type(texture) then texture_id = texture.texture_id end gl._bindTexture(target,texture_id) end function gl.bindBuffer( target,buffer ) local buffer_id = 0 if "number" == type(buffer) then buffer_id = buffer elseif "table" == type(buffer) then buffer_id = buffer.buffer_id end gl._bindBuffer(target, buffer_id) end function gl.bindRenderBuffer(target, buffer) local buffer_id = 0 if "number" == type(buffer) then buffer_id = buffer; elseif "table" == type(buffer) then buffer_id = buffer.buffer_id end gl._bindRenderbuffer(target, buffer_id) end function gl.bindFramebuffer(target, buffer) local buffer_id = 0 if "number" == type(buffer) then buffer_id = buffer elseif "table" == type(buffer) then buffer_id = buffer.buffer_id end gl._bindFramebuffer(target, buffer_id) end --Uniform related function gl.getUniform(program, location) local program_id = 0 local location_id = 0 if "number" == type(program) then program_id = program else program_id = program.program_id end if "number" == type(location) then location_id = location else location_id = location.location_id end return gl._getUniform(program_id, location_id) end --shader related function gl.compileShader(shader) gl._compileShader( shader.shader_id) end function gl.shaderSource(shader, source) gl._shaderSource(shader.shader_id, source) end function gl.getShaderParameter(shader, e) return gl._getShaderParameter(shader.shader_id,e) end function gl.getShaderInfoLog( shader ) return gl._getShaderInfoLog(shader.shader_id) end --program related function gl.attachShader( program, shader ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end gl._attachShader(program_id, shader.shader_id) end function gl.linkProgram( program ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end gl._linkProgram(program_id) end function gl.getProgramParameter(program, e) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getProgramParameter(program_id, e) end function gl.useProgram(program) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end gl._useProgram (program_id) end function gl.getAttribLocation(program, name ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getAttribLocation(program_id, name) end function gl.getUniformLocation( program, name ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getUniformLocation(program_id,name) end function gl.getActiveAttrib( program, index ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getActiveAttrib(program_id, index); end function gl.getActiveUniform( program, index ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getActiveUniform(program_id, index) end function gl.getAttachedShaders(program) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getAttachedShaders(program_id) end function gl.glNodeCreate() return cc.GLNode:create() end ================================================ FILE: Resources/OpenglConstants.lua ================================================ --Encapsulate opengl constants. gl = gl or {} gl.GCCSO_SHADER_BINARY_FJ = 0x9260 gl._3DC_XY_AMD = 0x87fa gl._3DC_X_AMD = 0x87f9 gl.ACTIVE_ATTRIBUTES = 0x8b89 gl.ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8b8a gl.ACTIVE_PROGRAM_EXT = 0x8259 gl.ACTIVE_TEXTURE = 0x84e0 gl.ACTIVE_UNIFORMS = 0x8b86 gl.ACTIVE_UNIFORM_MAX_LENGTH = 0x8b87 gl.ALIASED_LINE_WIDTH_RANGE = 0x846e gl.ALIASED_POINT_SIZE_RANGE = 0x846d gl.ALL_COMPLETED_NV = 0x84f2 gl.ALL_SHADER_BITS_EXT = 0xffffffff gl.ALPHA = 0x1906 gl.ALPHA16F_EXT = 0x881c gl.ALPHA32F_EXT = 0x8816 gl.ALPHA8_EXT = 0x803c gl.ALPHA8_OES = 0x803c gl.ALPHA_BITS = 0xd55 gl.ALPHA_TEST_FUNC_QCOM = 0xbc1 gl.ALPHA_TEST_QCOM = 0xbc0 gl.ALPHA_TEST_REF_QCOM = 0xbc2 gl.ALREADY_SIGNALED_APPLE = 0x911a gl.ALWAYS = 0x207 gl.AMD_compressed_3DC_texture = 0x1 gl.AMD_compressed_ATC_texture = 0x1 gl.AMD_performance_monitor = 0x1 gl.AMD_program_binary_Z400 = 0x1 gl.ANGLE_depth_texture = 0x1 gl.ANGLE_framebuffer_blit = 0x1 gl.ANGLE_framebuffer_multisample = 0x1 gl.ANGLE_instanced_arrays = 0x1 gl.ANGLE_pack_reverse_row_order = 0x1 gl.ANGLE_program_binary = 0x1 gl.ANGLE_texture_compression_dxt3 = 0x1 gl.ANGLE_texture_compression_dxt5 = 0x1 gl.ANGLE_texture_usage = 0x1 gl.ANGLE_translated_shader_source = 0x1 gl.ANY_SAMPLES_PASSED_CONSERVATIVE_EXT = 0x8d6a gl.ANY_SAMPLES_PASSED_EXT = 0x8c2f gl.APPLE_copy_texture_levels = 0x1 gl.APPLE_framebuffer_multisample = 0x1 gl.APPLE_rgb_422 = 0x1 gl.APPLE_sync = 0x1 gl.APPLE_texture_format_BGRA8888 = 0x1 gl.APPLE_texture_max_level = 0x1 gl.ARM_mali_program_binary = 0x1 gl.ARM_mali_shader_binary = 0x1 gl.ARM_rgba8 = 0x1 gl.ARRAY_BUFFER = 0x8892 gl.ARRAY_BUFFER_BINDING = 0x8894 gl.ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8c93 gl.ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87ee gl.ATC_RGB_AMD = 0x8c92 gl.ATTACHED_SHADERS = 0x8b85 gl.BACK = 0x405 gl.BGRA8_EXT = 0x93a1 gl.BGRA_EXT = 0x80e1 gl.BGRA_IMG = 0x80e1 gl.BINNING_CONTROL_HINT_QCOM = 0x8fb0 gl.BLEND = 0xbe2 gl.BLEND_COLOR = 0x8005 gl.BLEND_DST_ALPHA = 0x80ca gl.BLEND_DST_RGB = 0x80c8 gl.BLEND_EQUATION = 0x8009 gl.BLEND_EQUATION_ALPHA = 0x883d gl.BLEND_EQUATION_RGB = 0x8009 gl.BLEND_SRC_ALPHA = 0x80cb gl.BLEND_SRC_RGB = 0x80c9 gl.BLUE_BITS = 0xd54 gl.BOOL = 0x8b56 gl.BOOL_VEC2 = 0x8b57 gl.BOOL_VEC3 = 0x8b58 gl.BOOL_VEC4 = 0x8b59 gl.BUFFER = 0x82e0 gl.BUFFER_ACCESS_OES = 0x88bb gl.BUFFER_MAPPED_OES = 0x88bc gl.BUFFER_MAP_POINTER_OES = 0x88bd gl.BUFFER_OBJECT_EXT = 0x9151 gl.BUFFER_SIZE = 0x8764 gl.BUFFER_USAGE = 0x8765 gl.BYTE = 0x1400 gl.CCW = 0x901 gl.CLAMP_TO_BORDER_NV = 0x812d gl.CLAMP_TO_EDGE = 0x812f gl.COLOR_ATTACHMENT0 = 0x8ce0 gl.COLOR_ATTACHMENT0_NV = 0x8ce0 gl.COLOR_ATTACHMENT10_NV = 0x8cea gl.COLOR_ATTACHMENT11_NV = 0x8ceb gl.COLOR_ATTACHMENT12_NV = 0x8cec gl.COLOR_ATTACHMENT13_NV = 0x8ced gl.COLOR_ATTACHMENT14_NV = 0x8cee gl.COLOR_ATTACHMENT15_NV = 0x8cef gl.COLOR_ATTACHMENT1_NV = 0x8ce1 gl.COLOR_ATTACHMENT2_NV = 0x8ce2 gl.COLOR_ATTACHMENT3_NV = 0x8ce3 gl.COLOR_ATTACHMENT4_NV = 0x8ce4 gl.COLOR_ATTACHMENT5_NV = 0x8ce5 gl.COLOR_ATTACHMENT6_NV = 0x8ce6 gl.COLOR_ATTACHMENT7_NV = 0x8ce7 gl.COLOR_ATTACHMENT8_NV = 0x8ce8 gl.COLOR_ATTACHMENT9_NV = 0x8ce9 gl.COLOR_ATTACHMENT_EXT = 0x90f0 gl.COLOR_BUFFER_BIT = 0x4000 gl.COLOR_BUFFER_BIT0_QCOM = 0x1 gl.COLOR_BUFFER_BIT1_QCOM = 0x2 gl.COLOR_BUFFER_BIT2_QCOM = 0x4 gl.COLOR_BUFFER_BIT3_QCOM = 0x8 gl.COLOR_BUFFER_BIT4_QCOM = 0x10 gl.COLOR_BUFFER_BIT5_QCOM = 0x20 gl.COLOR_BUFFER_BIT6_QCOM = 0x40 gl.COLOR_BUFFER_BIT7_QCOM = 0x80 gl.COLOR_CLEAR_VALUE = 0xc22 gl.COLOR_EXT = 0x1800 gl.COLOR_WRITEMASK = 0xc23 gl.COMPARE_REF_TO_TEXTURE_EXT = 0x884e gl.COMPILE_STATUS = 0x8b81 gl.COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93bb gl.COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93b8 gl.COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93b9 gl.COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93ba gl.COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93bc gl.COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93bd gl.COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93b0 gl.COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93b1 gl.COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93b2 gl.COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93b3 gl.COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93b4 gl.COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93b5 gl.COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93b6 gl.COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93b7 gl.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8c03 gl.COMPRESSED_RGBA_PVRTC_2BPPV2_IMG = 0x9137 gl.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8c02 gl.COMPRESSED_RGBA_PVRTC_4BPPV2_IMG = 0x9138 gl.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83f1 gl.COMPRESSED_RGBA_S3TC_DXT3_ANGLE = 0x83f2 gl.COMPRESSED_RGBA_S3TC_DXT5_ANGLE = 0x83f3 gl.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8c01 gl.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8c00 gl.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83f0 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93db gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93d8 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93d9 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93da gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93dc gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93dd gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93d0 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93d1 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93d2 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93d3 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93d4 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93d5 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93d6 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93d7 gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV = 0x8c4d gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV = 0x8c4e gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV = 0x8c4f gl.COMPRESSED_SRGB_S3TC_DXT1_NV = 0x8c4c gl.COMPRESSED_TEXTURE_FORMATS = 0x86a3 gl.CONDITION_SATISFIED_APPLE = 0x911c gl.CONSTANT_ALPHA = 0x8003 gl.CONSTANT_COLOR = 0x8001 gl.CONTEXT_FLAG_DEBUG_BIT = 0x2 gl.CONTEXT_ROBUST_ACCESS_EXT = 0x90f3 gl.COUNTER_RANGE_AMD = 0x8bc1 gl.COUNTER_TYPE_AMD = 0x8bc0 gl.COVERAGE_ALL_FRAGMENTS_NV = 0x8ed5 gl.COVERAGE_ATTACHMENT_NV = 0x8ed2 gl.COVERAGE_AUTOMATIC_NV = 0x8ed7 gl.COVERAGE_BUFFERS_NV = 0x8ed3 gl.COVERAGE_BUFFER_BIT_NV = 0x8000 gl.COVERAGE_COMPONENT4_NV = 0x8ed1 gl.COVERAGE_COMPONENT_NV = 0x8ed0 gl.COVERAGE_EDGE_FRAGMENTS_NV = 0x8ed6 gl.COVERAGE_SAMPLES_NV = 0x8ed4 gl.CPU_OPTIMIZED_QCOM = 0x8fb1 gl.CULL_FACE = 0xb44 gl.CULL_FACE_MODE = 0xb45 gl.CURRENT_PROGRAM = 0x8b8d gl.CURRENT_QUERY_EXT = 0x8865 gl.CURRENT_VERTEX_ATTRIB = 0x8626 gl.CW = 0x900 gl.DEBUG_CALLBACK_FUNCTION = 0x8244 gl.DEBUG_CALLBACK_USER_PARAM = 0x8245 gl.DEBUG_GROUP_STACK_DEPTH = 0x826d gl.DEBUG_LOGGED_MESSAGES = 0x9145 gl.DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243 gl.DEBUG_OUTPUT = 0x92e0 gl.DEBUG_OUTPUT_SYNCHRONOUS = 0x8242 gl.DEBUG_SEVERITY_HIGH = 0x9146 gl.DEBUG_SEVERITY_LOW = 0x9148 gl.DEBUG_SEVERITY_MEDIUM = 0x9147 gl.DEBUG_SEVERITY_NOTIFICATION = 0x826b gl.DEBUG_SOURCE_API = 0x8246 gl.DEBUG_SOURCE_APPLICATION = 0x824a gl.DEBUG_SOURCE_OTHER = 0x824b gl.DEBUG_SOURCE_SHADER_COMPILER = 0x8248 gl.DEBUG_SOURCE_THIRD_PARTY = 0x8249 gl.DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247 gl.DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824d gl.DEBUG_TYPE_ERROR = 0x824c gl.DEBUG_TYPE_MARKER = 0x8268 gl.DEBUG_TYPE_OTHER = 0x8251 gl.DEBUG_TYPE_PERFORMANCE = 0x8250 gl.DEBUG_TYPE_POP_GROUP = 0x826a gl.DEBUG_TYPE_PORTABILITY = 0x824f gl.DEBUG_TYPE_PUSH_GROUP = 0x8269 gl.DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824e gl.DECR = 0x1e03 gl.DECR_WRAP = 0x8508 gl.DELETE_STATUS = 0x8b80 gl.DEPTH24_STENCIL8_OES = 0x88f0 gl.DEPTH_ATTACHMENT = 0x8d00 gl.DEPTH_BITS = 0xd56 gl.DEPTH_BUFFER_BIT = 0x100 gl.DEPTH_BUFFER_BIT0_QCOM = 0x100 gl.DEPTH_BUFFER_BIT1_QCOM = 0x200 gl.DEPTH_BUFFER_BIT2_QCOM = 0x400 gl.DEPTH_BUFFER_BIT3_QCOM = 0x800 gl.DEPTH_BUFFER_BIT4_QCOM = 0x1000 gl.DEPTH_BUFFER_BIT5_QCOM = 0x2000 gl.DEPTH_BUFFER_BIT6_QCOM = 0x4000 gl.DEPTH_BUFFER_BIT7_QCOM = 0x8000 gl.DEPTH_CLEAR_VALUE = 0xb73 gl.DEPTH_COMPONENT = 0x1902 gl.DEPTH_COMPONENT16 = 0x81a5 gl.DEPTH_COMPONENT16_NONLINEAR_NV = 0x8e2c gl.DEPTH_COMPONENT16_OES = 0x81a5 gl.DEPTH_COMPONENT24_OES = 0x81a6 gl.DEPTH_COMPONENT32_OES = 0x81a7 gl.DEPTH_EXT = 0x1801 gl.DEPTH_FUNC = 0xb74 gl.DEPTH_RANGE = 0xb70 gl.DEPTH_STENCIL_OES = 0x84f9 gl.DEPTH_TEST = 0xb71 gl.DEPTH_WRITEMASK = 0xb72 gl.DITHER = 0xbd0 gl.DMP_shader_binary = 0x1 gl.DONT_CARE = 0x1100 gl.DRAW_BUFFER0_NV = 0x8825 gl.DRAW_BUFFER10_NV = 0x882f gl.DRAW_BUFFER11_NV = 0x8830 gl.DRAW_BUFFER12_NV = 0x8831 gl.DRAW_BUFFER13_NV = 0x8832 gl.DRAW_BUFFER14_NV = 0x8833 gl.DRAW_BUFFER15_NV = 0x8834 gl.DRAW_BUFFER1_NV = 0x8826 gl.DRAW_BUFFER2_NV = 0x8827 gl.DRAW_BUFFER3_NV = 0x8828 gl.DRAW_BUFFER4_NV = 0x8829 gl.DRAW_BUFFER5_NV = 0x882a gl.DRAW_BUFFER6_NV = 0x882b gl.DRAW_BUFFER7_NV = 0x882c gl.DRAW_BUFFER8_NV = 0x882d gl.DRAW_BUFFER9_NV = 0x882e gl.DRAW_BUFFER_EXT = 0xc01 gl.DRAW_FRAMEBUFFER_ANGLE = 0x8ca9 gl.DRAW_FRAMEBUFFER_APPLE = 0x8ca9 gl.DRAW_FRAMEBUFFER_BINDING_ANGLE = 0x8ca6 gl.DRAW_FRAMEBUFFER_BINDING_APPLE = 0x8ca6 gl.DRAW_FRAMEBUFFER_BINDING_NV = 0x8ca6 gl.DRAW_FRAMEBUFFER_NV = 0x8ca9 gl.DST_ALPHA = 0x304 gl.DST_COLOR = 0x306 gl.DYNAMIC_DRAW = 0x88e8 gl.ELEMENT_ARRAY_BUFFER = 0x8893 gl.ELEMENT_ARRAY_BUFFER_BINDING = 0x8895 gl.EQUAL = 0x202 gl.ES_VERSION_2_0 = 0x1 gl.ETC1_RGB8_OES = 0x8d64 gl.ETC1_SRGB8_NV = 0x88ee gl.EXTENSIONS = 0x1f03 gl.EXT_blend_minmax = 0x1 gl.EXT_color_buffer_half_float = 0x1 gl.EXT_debug_label = 0x1 gl.EXT_debug_marker = 0x1 gl.EXT_discard_framebuffer = 0x1 gl.EXT_map_buffer_range = 0x1 gl.EXT_multi_draw_arrays = 0x1 gl.EXT_multisampled_render_to_texture = 0x1 gl.EXT_multiview_draw_buffers = 0x1 gl.EXT_occlusion_query_boolean = 0x1 gl.EXT_read_format_bgra = 0x1 gl.EXT_robustness = 0x1 gl.EXT_sRGB = 0x1 gl.EXT_separate_shader_objects = 0x1 gl.EXT_shader_framebuffer_fetch = 0x1 gl.EXT_shader_texture_lod = 0x1 gl.EXT_shadow_samplers = 0x1 gl.EXT_texture_compression_dxt1 = 0x1 gl.EXT_texture_filter_anisotropic = 0x1 gl.EXT_texture_format_BGRA8888 = 0x1 gl.EXT_texture_rg = 0x1 gl.EXT_texture_storage = 0x1 gl.EXT_texture_type_2_10_10_10_REV = 0x1 gl.EXT_unpack_subimage = 0x1 gl.FALSE = 0x0 gl.FASTEST = 0x1101 gl.FENCE_CONDITION_NV = 0x84f4 gl.FENCE_STATUS_NV = 0x84f3 gl.FIXED = 0x140c gl.FJ_shader_binary_GCCSO = 0x1 gl.FLOAT = 0x1406 gl.FLOAT_MAT2 = 0x8b5a gl.FLOAT_MAT3 = 0x8b5b gl.FLOAT_MAT4 = 0x8b5c gl.FLOAT_VEC2 = 0x8b50 gl.FLOAT_VEC3 = 0x8b51 gl.FLOAT_VEC4 = 0x8b52 gl.FRAGMENT_SHADER = 0x8b30 gl.FRAGMENT_SHADER_BIT_EXT = 0x2 gl.FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8b8b gl.FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT = 0x8a52 gl.FRAMEBUFFER = 0x8d40 gl.FRAMEBUFFER_ATTACHMENT_ANGLE = 0x93a3 gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT = 0x8210 gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT = 0x8211 gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8cd1 gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8cd0 gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES = 0x8cd4 gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8cd3 gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8cd2 gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT = 0x8d6c gl.FRAMEBUFFER_BINDING = 0x8ca6 gl.FRAMEBUFFER_COMPLETE = 0x8cd5 gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8cd6 gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8cd9 gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8cd7 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE = 0x8d56 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE = 0x8d56 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT = 0x8d56 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG = 0x9134 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV = 0x8d56 gl.FRAMEBUFFER_UNDEFINED_OES = 0x8219 gl.FRAMEBUFFER_UNSUPPORTED = 0x8cdd gl.FRONT = 0x404 gl.FRONT_AND_BACK = 0x408 gl.FRONT_FACE = 0xb46 gl.FUNC_ADD = 0x8006 gl.FUNC_REVERSE_SUBTRACT = 0x800b gl.FUNC_SUBTRACT = 0x800a gl.GENERATE_MIPMAP_HINT = 0x8192 gl.GEQUAL = 0x206 gl.GPU_OPTIMIZED_QCOM = 0x8fb2 gl.GREATER = 0x204 gl.GREEN_BITS = 0xd53 gl.GUILTY_CONTEXT_RESET_EXT = 0x8253 gl.HALF_FLOAT_OES = 0x8d61 gl.HIGH_FLOAT = 0x8df2 gl.HIGH_INT = 0x8df5 gl.IMG_multisampled_render_to_texture = 0x1 gl.IMG_program_binary = 0x1 gl.IMG_read_format = 0x1 gl.IMG_shader_binary = 0x1 gl.IMG_texture_compression_pvrtc = 0x1 gl.IMG_texture_compression_pvrtc2 = 0x1 gl.IMPLEMENTATION_COLOR_READ_FORMAT = 0x8b9b gl.IMPLEMENTATION_COLOR_READ_TYPE = 0x8b9a gl.INCR = 0x1e02 gl.INCR_WRAP = 0x8507 gl.INFO_LOG_LENGTH = 0x8b84 gl.INNOCENT_CONTEXT_RESET_EXT = 0x8254 gl.INT = 0x1404 gl.INT_10_10_10_2_OES = 0x8df7 gl.INT_VEC2 = 0x8b53 gl.INT_VEC3 = 0x8b54 gl.INT_VEC4 = 0x8b55 gl.INVALID_ENUM = 0x500 gl.INVALID_FRAMEBUFFER_OPERATION = 0x506 gl.INVALID_OPERATION = 0x502 gl.INVALID_VALUE = 0x501 gl.INVERT = 0x150a gl.KEEP = 0x1e00 gl.KHR_debug = 0x1 gl.KHR_texture_compression_astc_ldr = 0x1 gl.LEQUAL = 0x203 gl.LESS = 0x201 gl.LINEAR = 0x2601 gl.LINEAR_MIPMAP_LINEAR = 0x2703 gl.LINEAR_MIPMAP_NEAREST = 0x2701 gl.LINES = 0x1 gl.LINE_LOOP = 0x2 gl.LINE_STRIP = 0x3 gl.LINE_WIDTH = 0xb21 gl.LINK_STATUS = 0x8b82 gl.LOSE_CONTEXT_ON_RESET_EXT = 0x8252 gl.LOW_FLOAT = 0x8df0 gl.LOW_INT = 0x8df3 gl.LUMINANCE = 0x1909 gl.LUMINANCE16F_EXT = 0x881e gl.LUMINANCE32F_EXT = 0x8818 gl.LUMINANCE4_ALPHA4_OES = 0x8043 gl.LUMINANCE8_ALPHA8_EXT = 0x8045 gl.LUMINANCE8_ALPHA8_OES = 0x8045 gl.LUMINANCE8_EXT = 0x8040 gl.LUMINANCE8_OES = 0x8040 gl.LUMINANCE_ALPHA = 0x190a gl.LUMINANCE_ALPHA16F_EXT = 0x881f gl.LUMINANCE_ALPHA32F_EXT = 0x8819 gl.MALI_PROGRAM_BINARY_ARM = 0x8f61 gl.MALI_SHADER_BINARY_ARM = 0x8f60 gl.MAP_FLUSH_EXPLICIT_BIT_EXT = 0x10 gl.MAP_INVALIDATE_BUFFER_BIT_EXT = 0x8 gl.MAP_INVALIDATE_RANGE_BIT_EXT = 0x4 gl.MAP_READ_BIT_EXT = 0x1 gl.MAP_UNSYNCHRONIZED_BIT_EXT = 0x20 gl.MAP_WRITE_BIT_EXT = 0x2 gl.MAX_3D_TEXTURE_SIZE_OES = 0x8073 gl.MAX_COLOR_ATTACHMENTS_NV = 0x8cdf gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8b4d gl.MAX_CUBE_MAP_TEXTURE_SIZE = 0x851c gl.MAX_DEBUG_GROUP_STACK_DEPTH = 0x826c gl.MAX_DEBUG_LOGGED_MESSAGES = 0x9144 gl.MAX_DEBUG_MESSAGE_LENGTH = 0x9143 gl.MAX_DRAW_BUFFERS_NV = 0x8824 gl.MAX_EXT = 0x8008 gl.MAX_FRAGMENT_UNIFORM_VECTORS = 0x8dfd gl.MAX_LABEL_LENGTH = 0x82e8 gl.MAX_MULTIVIEW_BUFFERS_EXT = 0x90f2 gl.MAX_RENDERBUFFER_SIZE = 0x84e8 gl.MAX_SAMPLES_ANGLE = 0x8d57 gl.MAX_SAMPLES_APPLE = 0x8d57 gl.MAX_SAMPLES_EXT = 0x8d57 gl.MAX_SAMPLES_IMG = 0x9135 gl.MAX_SAMPLES_NV = 0x8d57 gl.MAX_SERVER_WAIT_TIMEOUT_APPLE = 0x9111 gl.MAX_TEXTURE_IMAGE_UNITS = 0x8872 gl.MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84ff gl.MAX_TEXTURE_SIZE = 0xd33 gl.MAX_VARYING_VECTORS = 0x8dfc gl.MAX_VERTEX_ATTRIBS = 0x8869 gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8b4c gl.MAX_VERTEX_UNIFORM_VECTORS = 0x8dfb gl.MAX_VIEWPORT_DIMS = 0xd3a gl.MEDIUM_FLOAT = 0x8df1 gl.MEDIUM_INT = 0x8df4 gl.MIN_EXT = 0x8007 gl.MIRRORED_REPEAT = 0x8370 gl.MULTISAMPLE_BUFFER_BIT0_QCOM = 0x1000000 gl.MULTISAMPLE_BUFFER_BIT1_QCOM = 0x2000000 gl.MULTISAMPLE_BUFFER_BIT2_QCOM = 0x4000000 gl.MULTISAMPLE_BUFFER_BIT3_QCOM = 0x8000000 gl.MULTISAMPLE_BUFFER_BIT4_QCOM = 0x10000000 gl.MULTISAMPLE_BUFFER_BIT5_QCOM = 0x20000000 gl.MULTISAMPLE_BUFFER_BIT6_QCOM = 0x40000000 gl.MULTISAMPLE_BUFFER_BIT7_QCOM = 0x80000000 gl.MULTIVIEW_EXT = 0x90f1 gl.NEAREST = 0x2600 gl.NEAREST_MIPMAP_LINEAR = 0x2702 gl.NEAREST_MIPMAP_NEAREST = 0x2700 gl.NEVER = 0x200 gl.NICEST = 0x1102 gl.NONE = 0x0 gl.NOTEQUAL = 0x205 gl.NO_ERROR = 0x0 gl.NO_RESET_NOTIFICATION_EXT = 0x8261 gl.NUM_COMPRESSED_TEXTURE_FORMATS = 0x86a2 gl.NUM_PROGRAM_BINARY_FORMATS_OES = 0x87fe gl.NUM_SHADER_BINARY_FORMATS = 0x8df9 gl.NV_coverage_sample = 0x1 gl.NV_depth_nonlinear = 0x1 gl.NV_draw_buffers = 0x1 gl.NV_draw_instanced = 0x1 gl.NV_fbo_color_attachments = 0x1 gl.NV_fence = 0x1 gl.NV_framebuffer_blit = 0x1 gl.NV_framebuffer_multisample = 0x1 gl.NV_generate_mipmap_sRGB = 0x1 gl.NV_instanced_arrays = 0x1 gl.NV_read_buffer = 0x1 gl.NV_read_buffer_front = 0x1 gl.NV_read_depth = 0x1 gl.NV_read_depth_stencil = 0x1 gl.NV_read_stencil = 0x1 gl.NV_sRGB_formats = 0x1 gl.NV_shadow_samplers_array = 0x1 gl.NV_shadow_samplers_cube = 0x1 gl.NV_texture_border_clamp = 0x1 gl.NV_texture_compression_s3tc_update = 0x1 gl.NV_texture_npot_2D_mipmap = 0x1 gl.OBJECT_TYPE_APPLE = 0x9112 gl.OES_EGL_image = 0x1 gl.OES_EGL_image_external = 0x1 gl.OES_compressed_ETC1_RGB8_texture = 0x1 gl.OES_compressed_paletted_texture = 0x1 gl.OES_depth24 = 0x1 gl.OES_depth32 = 0x1 gl.OES_depth_texture = 0x1 gl.OES_element_index_uint = 0x1 gl.OES_fbo_render_mipmap = 0x1 gl.OES_fragment_precision_high = 0x1 gl.OES_get_program_binary = 0x1 gl.OES_mapbuffer = 0x1 gl.OES_packed_depth_stencil = 0x1 gl.OES_required_internalformat = 0x1 gl.OES_rgb8_rgba8 = 0x1 gl.OES_standard_derivatives = 0x1 gl.OES_stencil1 = 0x1 gl.OES_stencil4 = 0x1 gl.OES_surfaceless_context = 0x1 gl.OES_texture_3D = 0x1 gl.OES_texture_float = 0x1 gl.OES_texture_float_linear = 0x1 gl.OES_texture_half_float = 0x1 gl.OES_texture_half_float_linear = 0x1 gl.OES_texture_npot = 0x1 gl.OES_vertex_array_object = 0x1 gl.OES_vertex_half_float = 0x1 gl.OES_vertex_type_10_10_10_2 = 0x1 gl.ONE = 0x1 gl.ONE_MINUS_CONSTANT_ALPHA = 0x8004 gl.ONE_MINUS_CONSTANT_COLOR = 0x8002 gl.ONE_MINUS_DST_ALPHA = 0x305 gl.ONE_MINUS_DST_COLOR = 0x307 gl.ONE_MINUS_SRC_ALPHA = 0x303 gl.ONE_MINUS_SRC_COLOR = 0x301 gl.OUT_OF_MEMORY = 0x505 gl.PACK_ALIGNMENT = 0xd05 gl.PACK_REVERSE_ROW_ORDER_ANGLE = 0x93a4 gl.PALETTE4_R5_G6_B5_OES = 0x8b92 gl.PALETTE4_RGB5_A1_OES = 0x8b94 gl.PALETTE4_RGB8_OES = 0x8b90 gl.PALETTE4_RGBA4_OES = 0x8b93 gl.PALETTE4_RGBA8_OES = 0x8b91 gl.PALETTE8_R5_G6_B5_OES = 0x8b97 gl.PALETTE8_RGB5_A1_OES = 0x8b99 gl.PALETTE8_RGB8_OES = 0x8b95 gl.PALETTE8_RGBA4_OES = 0x8b98 gl.PALETTE8_RGBA8_OES = 0x8b96 gl.PERCENTAGE_AMD = 0x8bc3 gl.PERFMON_GLOBAL_MODE_QCOM = 0x8fa0 gl.PERFMON_RESULT_AMD = 0x8bc6 gl.PERFMON_RESULT_AVAILABLE_AMD = 0x8bc4 gl.PERFMON_RESULT_SIZE_AMD = 0x8bc5 gl.POINTS = 0x0 gl.POLYGON_OFFSET_FACTOR = 0x8038 gl.POLYGON_OFFSET_FILL = 0x8037 gl.POLYGON_OFFSET_UNITS = 0x2a00 gl.PROGRAM = 0x82e2 gl.PROGRAM_BINARY_ANGLE = 0x93a6 gl.PROGRAM_BINARY_FORMATS_OES = 0x87ff gl.PROGRAM_BINARY_LENGTH_OES = 0x8741 gl.PROGRAM_OBJECT_EXT = 0x8b40 gl.PROGRAM_PIPELINE_BINDING_EXT = 0x825a gl.PROGRAM_PIPELINE_OBJECT_EXT = 0x8a4f gl.PROGRAM_SEPARABLE_EXT = 0x8258 gl.QCOM_alpha_test = 0x1 gl.QCOM_binning_control = 0x1 gl.QCOM_driver_control = 0x1 gl.QCOM_extended_get = 0x1 gl.QCOM_extended_get2 = 0x1 gl.QCOM_perfmon_global_mode = 0x1 gl.QCOM_tiled_rendering = 0x1 gl.QCOM_writeonly_rendering = 0x1 gl.QUERY = 0x82e3 gl.QUERY_OBJECT_EXT = 0x9153 gl.QUERY_RESULT_AVAILABLE_EXT = 0x8867 gl.QUERY_RESULT_EXT = 0x8866 gl.R16F_EXT = 0x822d gl.R32F_EXT = 0x822e gl.R8_EXT = 0x8229 gl.READ_BUFFER_EXT = 0xc02 gl.READ_BUFFER_NV = 0xc02 gl.READ_FRAMEBUFFER_ANGLE = 0x8ca8 gl.READ_FRAMEBUFFER_APPLE = 0x8ca8 gl.READ_FRAMEBUFFER_BINDING_ANGLE = 0x8caa gl.READ_FRAMEBUFFER_BINDING_APPLE = 0x8caa gl.READ_FRAMEBUFFER_BINDING_NV = 0x8caa gl.READ_FRAMEBUFFER_NV = 0x8ca8 gl.RED_BITS = 0xd52 gl.RED_EXT = 0x1903 gl.RENDERBUFFER = 0x8d41 gl.RENDERBUFFER_ALPHA_SIZE = 0x8d53 gl.RENDERBUFFER_BINDING = 0x8ca7 gl.RENDERBUFFER_BLUE_SIZE = 0x8d52 gl.RENDERBUFFER_DEPTH_SIZE = 0x8d54 gl.RENDERBUFFER_GREEN_SIZE = 0x8d51 gl.RENDERBUFFER_HEIGHT = 0x8d43 gl.RENDERBUFFER_INTERNAL_FORMAT = 0x8d44 gl.RENDERBUFFER_RED_SIZE = 0x8d50 gl.RENDERBUFFER_SAMPLES_ANGLE = 0x8cab gl.RENDERBUFFER_SAMPLES_APPLE = 0x8cab gl.RENDERBUFFER_SAMPLES_EXT = 0x8cab gl.RENDERBUFFER_SAMPLES_IMG = 0x9133 gl.RENDERBUFFER_SAMPLES_NV = 0x8cab gl.RENDERBUFFER_STENCIL_SIZE = 0x8d55 gl.RENDERBUFFER_WIDTH = 0x8d42 gl.RENDERER = 0x1f01 gl.RENDER_DIRECT_TO_FRAMEBUFFER_QCOM = 0x8fb3 gl.REPEAT = 0x2901 gl.REPLACE = 0x1e01 gl.REQUIRED_TEXTURE_IMAGE_UNITS_OES = 0x8d68 gl.RESET_NOTIFICATION_STRATEGY_EXT = 0x8256 gl.RG16F_EXT = 0x822f gl.RG32F_EXT = 0x8230 gl.RG8_EXT = 0x822b gl.RGB = 0x1907 gl.RGB10_A2_EXT = 0x8059 gl.RGB10_EXT = 0x8052 gl.RGB16F_EXT = 0x881b gl.RGB32F_EXT = 0x8815 gl.RGB565 = 0x8d62 gl.RGB565_OES = 0x8d62 gl.RGB5_A1 = 0x8057 gl.RGB5_A1_OES = 0x8057 gl.RGB8_OES = 0x8051 gl.RGBA = 0x1908 gl.RGBA16F_EXT = 0x881a gl.RGBA32F_EXT = 0x8814 gl.RGBA4 = 0x8056 gl.RGBA4_OES = 0x8056 gl.RGBA8_OES = 0x8058 gl.RGB_422_APPLE = 0x8a1f gl.RG_EXT = 0x8227 gl.SAMPLER = 0x82e6 gl.SAMPLER_2D = 0x8b5e gl.SAMPLER_2D_ARRAY_SHADOW_NV = 0x8dc4 gl.SAMPLER_2D_SHADOW_EXT = 0x8b62 gl.SAMPLER_3D_OES = 0x8b5f gl.SAMPLER_CUBE = 0x8b60 gl.SAMPLER_CUBE_SHADOW_NV = 0x8dc5 gl.SAMPLER_EXTERNAL_OES = 0x8d66 gl.SAMPLES = 0x80a9 gl.SAMPLE_ALPHA_TO_COVERAGE = 0x809e gl.SAMPLE_BUFFERS = 0x80a8 gl.SAMPLE_COVERAGE = 0x80a0 gl.SAMPLE_COVERAGE_INVERT = 0x80ab gl.SAMPLE_COVERAGE_VALUE = 0x80aa gl.SCISSOR_BOX = 0xc10 gl.SCISSOR_TEST = 0xc11 gl.SGX_BINARY_IMG = 0x8c0a gl.SGX_PROGRAM_BINARY_IMG = 0x9130 gl.SHADER = 0x82e1 gl.SHADER_BINARY_DMP = 0x9250 gl.SHADER_BINARY_FORMATS = 0x8df8 gl.SHADER_BINARY_VIV = 0x8fc4 gl.SHADER_COMPILER = 0x8dfa gl.SHADER_OBJECT_EXT = 0x8b48 gl.SHADER_SOURCE_LENGTH = 0x8b88 gl.SHADER_TYPE = 0x8b4f gl.SHADING_LANGUAGE_VERSION = 0x8b8c gl.SHORT = 0x1402 gl.SIGNALED_APPLE = 0x9119 gl.SLUMINANCE8_ALPHA8_NV = 0x8c45 gl.SLUMINANCE8_NV = 0x8c47 gl.SLUMINANCE_ALPHA_NV = 0x8c44 gl.SLUMINANCE_NV = 0x8c46 gl.SRC_ALPHA = 0x302 gl.SRC_ALPHA_SATURATE = 0x308 gl.SRC_COLOR = 0x300 gl.SRGB8_ALPHA8_EXT = 0x8c43 gl.SRGB8_NV = 0x8c41 gl.SRGB_ALPHA_EXT = 0x8c42 gl.SRGB_EXT = 0x8c40 gl.STACK_OVERFLOW = 0x503 gl.STACK_UNDERFLOW = 0x504 gl.STATE_RESTORE = 0x8bdc gl.STATIC_DRAW = 0x88e4 gl.STENCIL_ATTACHMENT = 0x8d20 gl.STENCIL_BACK_FAIL = 0x8801 gl.STENCIL_BACK_FUNC = 0x8800 gl.STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802 gl.STENCIL_BACK_PASS_DEPTH_PASS = 0x8803 gl.STENCIL_BACK_REF = 0x8ca3 gl.STENCIL_BACK_VALUE_MASK = 0x8ca4 gl.STENCIL_BACK_WRITEMASK = 0x8ca5 gl.STENCIL_BITS = 0xd57 gl.STENCIL_BUFFER_BIT = 0x400 gl.STENCIL_BUFFER_BIT0_QCOM = 0x10000 gl.STENCIL_BUFFER_BIT1_QCOM = 0x20000 gl.STENCIL_BUFFER_BIT2_QCOM = 0x40000 gl.STENCIL_BUFFER_BIT3_QCOM = 0x80000 gl.STENCIL_BUFFER_BIT4_QCOM = 0x100000 gl.STENCIL_BUFFER_BIT5_QCOM = 0x200000 gl.STENCIL_BUFFER_BIT6_QCOM = 0x400000 gl.STENCIL_BUFFER_BIT7_QCOM = 0x800000 gl.STENCIL_CLEAR_VALUE = 0xb91 gl.STENCIL_EXT = 0x1802 gl.STENCIL_FAIL = 0xb94 gl.STENCIL_FUNC = 0xb92 gl.STENCIL_INDEX1_OES = 0x8d46 gl.STENCIL_INDEX4_OES = 0x8d47 gl.STENCIL_INDEX8 = 0x8d48 gl.STENCIL_PASS_DEPTH_FAIL = 0xb95 gl.STENCIL_PASS_DEPTH_PASS = 0xb96 gl.STENCIL_REF = 0xb97 gl.STENCIL_TEST = 0xb90 gl.STENCIL_VALUE_MASK = 0xb93 gl.STENCIL_WRITEMASK = 0xb98 gl.STREAM_DRAW = 0x88e0 gl.SUBPIXEL_BITS = 0xd50 gl.SYNC_CONDITION_APPLE = 0x9113 gl.SYNC_FENCE_APPLE = 0x9116 gl.SYNC_FLAGS_APPLE = 0x9115 gl.SYNC_FLUSH_COMMANDS_BIT_APPLE = 0x1 gl.SYNC_GPU_COMMANDS_COMPLETE_APPLE = 0x9117 gl.SYNC_OBJECT_APPLE = 0x8a53 gl.SYNC_STATUS_APPLE = 0x9114 gl.TEXTURE = 0x1702 gl.TEXTURE0 = 0x84c0 gl.TEXTURE1 = 0x84c1 gl.TEXTURE10 = 0x84ca gl.TEXTURE11 = 0x84cb gl.TEXTURE12 = 0x84cc gl.TEXTURE13 = 0x84cd gl.TEXTURE14 = 0x84ce gl.TEXTURE15 = 0x84cf gl.TEXTURE16 = 0x84d0 gl.TEXTURE17 = 0x84d1 gl.TEXTURE18 = 0x84d2 gl.TEXTURE19 = 0x84d3 gl.TEXTURE2 = 0x84c2 gl.TEXTURE20 = 0x84d4 gl.TEXTURE21 = 0x84d5 gl.TEXTURE22 = 0x84d6 gl.TEXTURE23 = 0x84d7 gl.TEXTURE24 = 0x84d8 gl.TEXTURE25 = 0x84d9 gl.TEXTURE26 = 0x84da gl.TEXTURE27 = 0x84db gl.TEXTURE28 = 0x84dc gl.TEXTURE29 = 0x84dd gl.TEXTURE3 = 0x84c3 gl.TEXTURE30 = 0x84de gl.TEXTURE31 = 0x84df gl.TEXTURE4 = 0x84c4 gl.TEXTURE5 = 0x84c5 gl.TEXTURE6 = 0x84c6 gl.TEXTURE7 = 0x84c7 gl.TEXTURE8 = 0x84c8 gl.TEXTURE9 = 0x84c9 gl.TEXTURE_2D = 0xde1 gl.TEXTURE_3D_OES = 0x806f gl.TEXTURE_BINDING_2D = 0x8069 gl.TEXTURE_BINDING_3D_OES = 0x806a gl.TEXTURE_BINDING_CUBE_MAP = 0x8514 gl.TEXTURE_BINDING_EXTERNAL_OES = 0x8d67 gl.TEXTURE_BORDER_COLOR_NV = 0x1004 gl.TEXTURE_COMPARE_FUNC_EXT = 0x884d gl.TEXTURE_COMPARE_MODE_EXT = 0x884c gl.TEXTURE_CUBE_MAP = 0x8513 gl.TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516 gl.TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518 gl.TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851a gl.TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515 gl.TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517 gl.TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519 gl.TEXTURE_DEPTH_QCOM = 0x8bd4 gl.TEXTURE_EXTERNAL_OES = 0x8d65 gl.TEXTURE_FORMAT_QCOM = 0x8bd6 gl.TEXTURE_HEIGHT_QCOM = 0x8bd3 gl.TEXTURE_IMAGE_VALID_QCOM = 0x8bd8 gl.TEXTURE_IMMUTABLE_FORMAT_EXT = 0x912f gl.TEXTURE_INTERNAL_FORMAT_QCOM = 0x8bd5 gl.TEXTURE_MAG_FILTER = 0x2800 gl.TEXTURE_MAX_ANISOTROPY_EXT = 0x84fe gl.TEXTURE_MAX_LEVEL_APPLE = 0x813d gl.TEXTURE_MIN_FILTER = 0x2801 gl.TEXTURE_NUM_LEVELS_QCOM = 0x8bd9 gl.TEXTURE_OBJECT_VALID_QCOM = 0x8bdb gl.TEXTURE_SAMPLES_IMG = 0x9136 gl.TEXTURE_TARGET_QCOM = 0x8bda gl.TEXTURE_TYPE_QCOM = 0x8bd7 gl.TEXTURE_USAGE_ANGLE = 0x93a2 gl.TEXTURE_WIDTH_QCOM = 0x8bd2 gl.TEXTURE_WRAP_R_OES = 0x8072 gl.TEXTURE_WRAP_S = 0x2802 gl.TEXTURE_WRAP_T = 0x2803 gl.TIMEOUT_EXPIRED_APPLE = 0x911b gl.TIMEOUT_IGNORED_APPLE = 0xffffffffffffffff gl.TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93a0 gl.TRIANGLES = 0x4 gl.TRIANGLE_FAN = 0x6 gl.TRIANGLE_STRIP = 0x5 gl.TRUE = 0x1 gl.UNKNOWN_CONTEXT_RESET_EXT = 0x8255 gl.UNPACK_ALIGNMENT = 0xcf5 gl.UNPACK_ROW_LENGTH = 0xcf2 gl.UNPACK_SKIP_PIXELS = 0xcf4 gl.UNPACK_SKIP_ROWS = 0xcf3 gl.UNSIGNALED_APPLE = 0x9118 gl.UNSIGNED_BYTE = 0x1401 gl.UNSIGNED_INT = 0x1405 gl.UNSIGNED_INT64_AMD = 0x8bc2 gl.UNSIGNED_INT_10_10_10_2_OES = 0x8df6 gl.UNSIGNED_INT_24_8_OES = 0x84fa gl.UNSIGNED_INT_2_10_10_10_REV_EXT = 0x8368 gl.UNSIGNED_NORMALIZED_EXT = 0x8c17 gl.UNSIGNED_SHORT = 0x1403 gl.UNSIGNED_SHORT_1_5_5_5_REV_EXT = 0x8366 gl.UNSIGNED_SHORT_4_4_4_4 = 0x8033 gl.UNSIGNED_SHORT_4_4_4_4_REV_EXT = 0x8365 gl.UNSIGNED_SHORT_4_4_4_4_REV_IMG = 0x8365 gl.UNSIGNED_SHORT_5_5_5_1 = 0x8034 gl.UNSIGNED_SHORT_5_6_5 = 0x8363 gl.UNSIGNED_SHORT_8_8_APPLE = 0x85ba gl.UNSIGNED_SHORT_8_8_REV_APPLE = 0x85bb gl.VALIDATE_STATUS = 0x8b83 gl.VENDOR = 0x1f00 gl.VERSION = 0x1f02 gl.VERTEX_ARRAY_BINDING_OES = 0x85b5 gl.VERTEX_ARRAY_OBJECT_EXT = 0x9154 gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889f gl.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88fe gl.VERTEX_ATTRIB_ARRAY_DIVISOR_NV = 0x88fe gl.VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622 gl.VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886a gl.VERTEX_ATTRIB_ARRAY_POINTER = 0x8645 gl.VERTEX_ATTRIB_ARRAY_SIZE = 0x8623 gl.VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624 gl.VERTEX_ATTRIB_ARRAY_TYPE = 0x8625 gl.VERTEX_SHADER = 0x8b31 gl.VERTEX_SHADER_BIT_EXT = 0x1 gl.VIEWPORT = 0xba2 gl.VIV_shader_binary = 0x1 gl.WAIT_FAILED_APPLE = 0x911d gl.WRITEONLY_RENDERING_QCOM = 0x8823 gl.WRITE_ONLY_OES = 0x88b9 gl.Z400_BINARY_AMD = 0x8740 gl.ZERO = 0x0 ================================================ FILE: Resources/StudioConstants.lua ================================================ ccs = ccs or {} ccs.MovementEventType = { start = 0, complete = 1, loopComplete = 2, } ================================================ FILE: Resources/extern.lua ================================================ function clone(object) local lookup_table = {} local function _copy(object) if type(object) ~= "table" then return object elseif lookup_table[object] then return lookup_table[object] end local new_table = {} lookup_table[object] = new_table for key, value in pairs(object) do new_table[_copy(key)] = _copy(value) end return setmetatable(new_table, getmetatable(object)) end return _copy(object) end --Create an class. function class(classname, super) local superType = type(super) local cls if superType ~= "function" and superType ~= "table" then superType = nil super = nil end if superType == "function" or (super and super.__ctype == 1) then -- inherited from native C++ Object cls = {} if superType == "table" then -- copy fields from super for k,v in pairs(super) do cls[k] = v end cls.__create = super.__create cls.super = super else cls.__create = super end cls.ctor = function() end cls.__cname = classname cls.__ctype = 1 function cls.new(...) local instance = cls.__create(...) -- copy fields from class to native object for k,v in pairs(cls) do instance[k] = v end instance.class = cls instance:ctor(...) return instance end else -- inherited from Lua Object if super then cls = clone(super) cls.super = super else cls = {ctor = function() end} end cls.__cname = classname cls.__ctype = 2 -- lua cls.__index = cls function cls.new(...) local instance = setmetatable({}, cls) instance.class = cls instance:ctor(...) return instance end end return cls end function schedule(node, callback, delay) local delay = cc.DelayTime:create(delay) local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback)) local action = cc.RepeatForever:create(sequence) node:runAction(action) return action end function performWithDelay(node, callback, delay) local delay = cc.DelayTime:create(delay) local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback)) node:runAction(sequence) return sequence end ================================================ FILE: Resources/json.lua ================================================ ----------------------------------------------------------------------------- -- JSON4Lua: JSON encoding / decoding support for the Lua language. -- json Module. -- Author: Craig Mason-Jones -- Homepage: http://json.luaforge.net/ -- Version: 0.9.40 -- This module is released under the MIT License (MIT). -- Please see LICENCE.txt for details. -- -- USAGE: -- This module exposes two functions: -- encode(o) -- Returns the table / string / boolean / number / nil / json.null value as a JSON-encoded string. -- decode(json_string) -- Returns a Lua object populated with the data encoded in the JSON string json_string. -- -- REQUIREMENTS: -- compat-5.1 if using Lua 5.0 -- -- CHANGELOG -- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix). -- Fixed Lua 5.1 compatibility issues. -- Introduced json.null to have null values in associative arrays. -- encode() performance improvement (more than 50%) through table.concat rather than .. -- Introduced decode ability to ignore /**/ comments in the JSON string. -- 0.9.10 Fix to array encoding / decoding to correctly manage nil/null values in arrays. ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- -- Imports and dependencies ----------------------------------------------------------------------------- local math = require('math') local string = require("string") local table = require("table") local base = _G ----------------------------------------------------------------------------- -- Module declaration ----------------------------------------------------------------------------- module("json") -- Public functions -- Private functions local decode_scanArray local decode_scanComment local decode_scanConstant local decode_scanNumber local decode_scanObject local decode_scanString local decode_scanWhitespace local encodeString local isArray local isEncodable ----------------------------------------------------------------------------- -- PUBLIC FUNCTIONS ----------------------------------------------------------------------------- --- Encodes an arbitrary Lua object / variable. -- @param v The Lua object / variable to be JSON encoded. -- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) function encode (v) -- Handle nil values if v==nil then return "null" end local vtype = base.type(v) -- Handle strings if vtype=='string' then return '"' .. encodeString(v) .. '"' -- Need to handle encoding in string end -- Handle booleans if vtype=='number' or vtype=='boolean' then return base.tostring(v) end -- Handle tables if vtype=='table' then local rval = {} -- Consider arrays separately local bArray, maxCount = isArray(v) if bArray then for i = 1,maxCount do table.insert(rval, encode(v[i])) end else -- An object, not an array for i,j in base.pairs(v) do if isEncodable(i) and isEncodable(j) then table.insert(rval, '"' .. encodeString(i) .. '":' .. encode(j)) end end end if bArray then return '[' .. table.concat(rval,',') ..']' else return '{' .. table.concat(rval,',') .. '}' end end -- Handle null values if vtype=='function' and v==null then return 'null' end base.assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. base.tostring(v)) end --- Decodes a JSON string and returns the decoded value as a Lua data structure / value. -- @param s The string to scan. -- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. -- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil, -- and the position of the first character after -- the scanned JSON object. function decode(s, startPos) startPos = startPos and startPos or 1 startPos = decode_scanWhitespace(s,startPos) base.assert(startPos<=string.len(s), 'Unterminated JSON encoded object found at position in [' .. s .. ']') local curChar = string.sub(s,startPos,startPos) -- Object if curChar=='{' then return decode_scanObject(s,startPos) end -- Array if curChar=='[' then return decode_scanArray(s,startPos) end -- Number if string.find("+-0123456789.e", curChar, 1, true) then return decode_scanNumber(s,startPos) end -- String if curChar==[["]] or curChar==[[']] then return decode_scanString(s,startPos) end if string.sub(s,startPos,startPos+1)=='/*' then return decode(s, decode_scanComment(s,startPos)) end -- Otherwise, it must be a constant return decode_scanConstant(s,startPos) end --- The null function allows one to specify a null value in an associative array (which is otherwise -- discarded if you set the value with 'nil' in Lua. Simply set t = { first=json.null } function null() return null -- so json.null() will also return null ;-) end ----------------------------------------------------------------------------- -- Internal, PRIVATE functions. -- Following a Python-like convention, I have prefixed all these 'PRIVATE' -- functions with an underscore. ----------------------------------------------------------------------------- --- Scans an array from JSON into a Lua object -- startPos begins at the start of the array. -- Returns the array and the next starting position -- @param s The string being scanned. -- @param startPos The starting position for the scan. -- @return table, int The scanned array as a table, and the position of the next character to scan. function decode_scanArray(s,startPos) local array = {} -- The return value local stringLen = string.len(s) base.assert(string.sub(s,startPos,startPos)=='[','decode_scanArray called but array does not start at position ' .. startPos .. ' in string:\n'..s ) startPos = startPos + 1 -- Infinite loop for array elements repeat startPos = decode_scanWhitespace(s,startPos) base.assert(startPos<=stringLen,'JSON String ended unexpectedly scanning array.') local curChar = string.sub(s,startPos,startPos) if (curChar==']') then return array, startPos+1 end if (curChar==',') then startPos = decode_scanWhitespace(s,startPos+1) end base.assert(startPos<=stringLen, 'JSON String ended unexpectedly scanning array.') object, startPos = decode(s,startPos) table.insert(array,object) until false end --- Scans a comment and discards the comment. -- Returns the position of the next character following the comment. -- @param string s The JSON string to scan. -- @param int startPos The starting position of the comment function decode_scanComment(s, startPos) base.assert( string.sub(s,startPos,startPos+1)=='/*', "decode_scanComment called but comment does not start at position " .. startPos) local endPos = string.find(s,'*/',startPos+2) base.assert(endPos~=nil, "Unterminated comment in string at " .. startPos) return endPos+2 end --- Scans for given constants: true, false or null -- Returns the appropriate Lua type, and the position of the next character to read. -- @param s The string being scanned. -- @param startPos The position in the string at which to start scanning. -- @return object, int The object (true, false or nil) and the position at which the next character should be -- scanned. function decode_scanConstant(s, startPos) local consts = { ["true"] = true, ["false"] = false, ["null"] = nil } local constNames = {"true","false","null"} for i,k in base.pairs(constNames) do --print ("[" .. string.sub(s,startPos, startPos + string.len(k) -1) .."]", k) if string.sub(s,startPos, startPos + string.len(k) -1 )==k then return consts[k], startPos + string.len(k) end end base.assert(nil, 'Failed to scan constant from string ' .. s .. ' at starting position ' .. startPos) end --- Scans a number from the JSON encoded string. -- (in fact, also is able to scan numeric +- eqns, which is not -- in the JSON spec.) -- Returns the number, and the position of the next character -- after the number. -- @param s The string being scanned. -- @param startPos The position at which to start scanning. -- @return number, int The extracted number and the position of the next character to scan. function decode_scanNumber(s,startPos) local endPos = startPos+1 local stringLen = string.len(s) local acceptableChars = "+-0123456789.e" while (string.find(acceptableChars, string.sub(s,endPos,endPos), 1, true) and endPos<=stringLen ) do endPos = endPos + 1 end local stringValue = 'return ' .. string.sub(s,startPos, endPos-1) local stringEval = base.loadstring(stringValue) base.assert(stringEval, 'Failed to scan number [ ' .. stringValue .. '] in JSON string at position ' .. startPos .. ' : ' .. endPos) return stringEval(), endPos end --- Scans a JSON object into a Lua object. -- startPos begins at the start of the object. -- Returns the object and the next starting position. -- @param s The string being scanned. -- @param startPos The starting position of the scan. -- @return table, int The scanned object as a table and the position of the next character to scan. function decode_scanObject(s,startPos) local object = {} local stringLen = string.len(s) local key, value base.assert(string.sub(s,startPos,startPos)=='{','decode_scanObject called but object does not start at position ' .. startPos .. ' in string:\n' .. s) startPos = startPos + 1 repeat startPos = decode_scanWhitespace(s,startPos) base.assert(startPos<=stringLen, 'JSON string ended unexpectedly while scanning object.') local curChar = string.sub(s,startPos,startPos) if (curChar=='}') then return object,startPos+1 end if (curChar==',') then startPos = decode_scanWhitespace(s,startPos+1) end base.assert(startPos<=stringLen, 'JSON string ended unexpectedly scanning object.') -- Scan the key key, startPos = decode(s,startPos) base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) startPos = decode_scanWhitespace(s,startPos) base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) base.assert(string.sub(s,startPos,startPos)==':','JSON object key-value assignment mal-formed at ' .. startPos) startPos = decode_scanWhitespace(s,startPos+1) base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) value, startPos = decode(s,startPos) object[key]=value until false -- infinite loop while key-value pairs are found end --- Scans a JSON string from the opening inverted comma or single quote to the -- end of the string. -- Returns the string extracted as a Lua string, -- and the position of the next non-string character -- (after the closing inverted comma or single quote). -- @param s The string being scanned. -- @param startPos The starting position of the scan. -- @return string, int The extracted string as a Lua string, and the next character to parse. function decode_scanString(s,startPos) base.assert(startPos, 'decode_scanString(..) called without start position') local startChar = string.sub(s,startPos,startPos) base.assert(startChar==[[']] or startChar==[["]],'decode_scanString called for a non-string') local escaped = false local endPos = startPos + 1 local bEnded = false local stringLen = string.len(s) repeat local curChar = string.sub(s,endPos,endPos) if not escaped then if curChar==[[\]] then escaped = true else bEnded = curChar==startChar end else -- If we're escaped, we accept the current character come what may escaped = false end endPos = endPos + 1 base.assert(endPos <= stringLen+1, "String decoding failed: unterminated string at position " .. endPos) until bEnded local stringValue = 'return ' .. string.sub(s, startPos, endPos-1) local stringEval = base.loadstring(stringValue) base.assert(stringEval, 'Failed to load string [ ' .. stringValue .. '] in JSON4Lua.decode_scanString at position ' .. startPos .. ' : ' .. endPos) return stringEval(), endPos end --- Scans a JSON string skipping all whitespace from the current start position. -- Returns the position of the first non-whitespace character, or nil if the whole end of string is reached. -- @param s The string being scanned -- @param startPos The starting position where we should begin removing whitespace. -- @return int The first position where non-whitespace was encountered, or string.len(s)+1 if the end of string -- was reached. function decode_scanWhitespace(s,startPos) local whitespace=" \n\r\t" local stringLen = string.len(s) while ( string.find(whitespace, string.sub(s,startPos,startPos), 1, true) and startPos <= stringLen) do startPos = startPos + 1 end return startPos end --- Encodes a string to be JSON-compatible. -- This just involves back-quoting inverted commas, back-quotes and newlines, I think ;-) -- @param s The string to return as a JSON encoded (i.e. backquoted string) -- @return The string appropriately escaped. function encodeString(s) s = string.gsub(s,'\\','\\\\') s = string.gsub(s,'"','\\"') s = string.gsub(s,"'","\\'") s = string.gsub(s,'\n','\\n') s = string.gsub(s,'\t','\\t') return s end -- Determines whether the given Lua type is an array or a table / dictionary. -- We consider any table an array if it has indexes 1..n for its n items, and no -- other data in the table. -- I think this method is currently a little 'flaky', but can't think of a good way around it yet... -- @param t The table to evaluate as an array -- @return boolean, number True if the table can be represented as an array, false otherwise. If true, -- the second returned value is the maximum -- number of indexed elements in the array. function isArray(t) -- Next we count all the elements, ensuring that any non-indexed elements are not-encodable -- (with the possible exception of 'n') local maxIndex = 0 for k,v in base.pairs(t) do if (base.type(k)=='number' and math.floor(k)==k and 1<=k) then -- k,v is an indexed pair if (not isEncodable(v)) then return false end -- All array elements must be encodable maxIndex = math.max(maxIndex,k) else if (k=='n') then if v ~= table.getn(t) then return false end -- False if n does not hold the number of elements else -- Else of (k=='n') if isEncodable(v) then return false end end -- End of (k~='n') end -- End of k,v not an indexed pair end -- End of loop across all pairs return true, maxIndex end --- Determines whether the given Lua object / table / variable can be JSON encoded. The only -- types that are JSON encodable are: string, boolean, number, nil, table and json.null. -- In this implementation, all other types are ignored. -- @param o The object to examine. -- @return boolean True if the object should be JSON encoded, false if it should be ignored. function isEncodable(o) local t = base.type(o) return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null) end ================================================ FILE: Resources/luaj.lua ================================================ local luaj = {} local callJavaStaticMethod = LuaJavaBridge.callStaticMethod local function checkArguments(args, sig) if type(args) ~= "table" then args = {} end if sig then return args, sig end sig = {"("} for i, v in ipairs(args) do local t = type(v) if t == "number" then sig[#sig + 1] = "F" elseif t == "boolean" then sig[#sig + 1] = "Z" elseif t == "function" then sig[#sig + 1] = "I" else sig[#sig + 1] = "Ljava/lang/String;" end end sig[#sig + 1] = ")V" return args, table.concat(sig) end function luaj.callStaticMethod(className, methodName, args, sig) local args, sig = checkArguments(args, sig) --echoInfo("luaj.callStaticMethod(\"%s\",\n\t\"%s\",\n\targs,\n\t\"%s\"", className, methodName, sig) return callJavaStaticMethod(className, methodName, args, sig) end return luaj ================================================ FILE: Resources/luaoc.lua ================================================ local luaoc = {} local callStaticMethod = LuaObjcBridge.callStaticMethod function luaoc.callStaticMethod(className, methodName, args) local ok, ret = callStaticMethod(className, methodName, args) if not ok then local msg = string.format("luaoc.callStaticMethod(\"%s\", \"%s\", \"%s\") - error: [%s] ", className, methodName, tostring(args), tostring(ret)) if ret == -1 then print(msg .. "INVALID PARAMETERS") elseif ret == -2 then print(msg .. "CLASS NOT FOUND") elseif ret == -3 then print(msg .. "METHOD NOT FOUND") elseif ret == -4 then print(msg .. "EXCEPTION OCCURRED") elseif ret == -5 then print(msg .. "INVALID METHOD SIGNATURE") else print(msg .. "UNKNOWN") end end return ok, ret end return luaoc ================================================ FILE: Resources/main.lua ================================================ require "Cocos2d" require "scripts.out" require "scripts.tools" -- cclog cclog = function(...) print(string.format(...)) end -- for CCLuaEngine traceback function __G__TRACKBACK__(msg) cclog("----------------------------------------") cclog("LUA ERROR: " .. tostring(msg) .. "\n") cclog(debug.traceback()) cclog("----------------------------------------") end local function main() -- avoid memory leak collectgarbage("setpause", 100) collectgarbage("setstepmul", 5000) local startScene = require("scripts.StartScene") cc.Director:getInstance():runWithScene(startScene) end xpcall(main, __G__TRACKBACK__) ================================================ FILE: Resources/mobdebug.lua ================================================ -- -- MobDebug 0.542 -- Copyright 2011-13 Paul Kulchenko -- Based on RemDebug 1.0 Copyright Kepler Project 2005 -- local mobdebug = { _NAME = "mobdebug", _VERSION = 0.542, _COPYRIGHT = "Paul Kulchenko", _DESCRIPTION = "Mobile Remote Debugger for the Lua programming language", port = os and os.getenv and os.getenv("MOBDEBUG_PORT") or 8172, checkcount = 200, yieldtimeout = 0.02, } local coroutine = coroutine local error = error local getfenv = getfenv local setfenv = setfenv local loadstring = loadstring or load -- "load" replaced "loadstring" in Lua 5.2 local io = io local os = os local pairs = pairs local require = require local setmetatable = setmetatable local string = string local tonumber = tonumber local unpack = table.unpack or unpack local rawget = rawget -- if strict.lua is used, then need to avoid referencing some global -- variables, as they can be undefined; -- use rawget to to avoid complaints from strict.lua at run-time. -- it's safe to do the initialization here as all these variables -- should get defined values (of any) before the debugging starts. -- there is also global 'wx' variable, which is checked as part of -- the debug loop as 'wx' can be loaded at any time during debugging. local genv = _G or _ENV local jit = rawget(genv, "jit") local MOAICoroutine = rawget(genv, "MOAICoroutine") if not setfenv then -- Lua 5.2 -- based on http://lua-users.org/lists/lua-l/2010-06/msg00314.html -- this assumes f is a function local function findenv(f) local level = 1 repeat local name, value = debug.getupvalue(f, level) if name == '_ENV' then return level, value end level = level + 1 until name == nil return nil end getfenv = function (f) return(select(2, findenv(f)) or _G) end setfenv = function (f, t) local level = findenv(f) if level then debug.setupvalue(f, level, t) end return f end end -- check for OS and convert file names to lower case on windows -- (its file system is case insensitive, but case preserving), as setting a -- breakpoint on x:\Foo.lua will not work if the file was loaded as X:\foo.lua. -- OSX and Windows behave the same way (case insensitive, but case preserving) local iscasepreserving = os and os.getenv and (os.getenv('WINDIR') or (os.getenv('OS') or ''):match('[Ww]indows') or os.getenv('DYLD_LIBRARY_PATH')) or not io.open("/proc") -- turn jit off based on Mike Pall's comment in this discussion: -- http://www.freelists.org/post/luajit/Debug-hooks-and-JIT,2 -- "You need to turn it off at the start if you plan to receive -- reliable hook calls at any later point in time." if jit and jit.off then jit.off() end local socket = require "socket" local debug = require "debug" local coro_debugger local coro_debugee local coroutines = {}; setmetatable(coroutines, {__mode = "k"}) -- "weak" keys local events = { BREAK = 1, WATCH = 2, RESTART = 3, STACK = 4 } local breakpoints = {} local watches = {} local lastsource local lastfile local watchescnt = 0 local abort -- default value is nil; this is used in start/loop distinction local seen_hook = false local checkcount = 0 local step_into = false local step_over = false local step_level = 0 local stack_level = 0 local server local buf local outputs = {} local iobase = {print = print} local basedir = "" local deferror = "execution aborted at default debugee" local debugee = function () local a = 1 for _ = 1, 10 do a = a + 1 end error(deferror) end local function q(s) return s:gsub('([%(%)%.%%%+%-%*%?%[%^%$%]])','%%%1') end local serpent = (function() ---- include Serpent module for serialization local n, v = "serpent", 0.25 -- (C) 2012-13 Paul Kulchenko; MIT License local c, d = "Paul Kulchenko", "Lua serializer and pretty printer" local snum = {[tostring(1/0)]='1/0 --[[math.huge]]',[tostring(-1/0)]='-1/0 --[[-math.huge]]',[tostring(0/0)]='0/0'} local badtype = {thread = true, userdata = true, cdata = true} local keyword, globals, G = {}, {}, (_G or _ENV) for _,k in ipairs({'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'goto', 'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while'}) do keyword[k] = true end for k,v in pairs(G) do globals[v] = k end -- build func to name mapping for _,g in ipairs({'coroutine', 'debug', 'io', 'math', 'string', 'table', 'os'}) do for k,v in pairs(G[g]) do globals[v] = g..'.'..k end end local function s(t, opts) local name, indent, fatal, maxnum = opts.name, opts.indent, opts.fatal, opts.maxnum local sparse, custom, huge = opts.sparse, opts.custom, not opts.nohuge local space, maxl = (opts.compact and '' or ' '), (opts.maxlevel or math.huge) local iname, comm = '_'..(name or ''), opts.comment and (tonumber(opts.comment) or math.huge) local seen, sref, syms, symn = {}, {'local '..iname..'={}'}, {}, 0 local function gensym(val) return '_'..(tostring(tostring(val)):gsub("[^%w]",""):gsub("(%d%w+)", -- tostring(val) is needed because __tostring may return a non-string value function(s) if not syms[s] then symn = symn+1; syms[s] = symn end return syms[s] end)) end local function safestr(s) return type(s) == "number" and (huge and snum[tostring(s)] or s) or type(s) ~= "string" and tostring(s) -- escape NEWLINE/010 and EOF/026 or ("%q"):format(s):gsub("\010","n"):gsub("\026","\\026") end local function comment(s,l) return comm and (l or 0) < comm and ' --[['..tostring(s)..']]' or '' end local function globerr(s,l) return globals[s] and globals[s]..comment(s,l) or not fatal and safestr(select(2, pcall(tostring, s))) or error("Can't serialize "..tostring(s)) end local function safename(path, name) -- generates foo.bar, foo[3], or foo['b a r'] local n = name == nil and '' or name local plain = type(n) == "string" and n:match("^[%l%u_][%w_]*$") and not keyword[n] local safe = plain and n or '['..safestr(n)..']' return (path or '')..(plain and path and '.' or '')..safe, safe end local alphanumsort = type(opts.sortkeys) == 'function' and opts.sortkeys or function(k, o, n) -- k=keys, o=originaltable, n=padding local maxn, to = tonumber(n) or 12, {number = 'a', string = 'b'} local function padnum(d) return ("%0"..maxn.."d"):format(d) end table.sort(k, function(a,b) -- sort numeric keys first: k[key] is non-nil for numeric keys return (k[a] and 0 or to[type(a)] or 'z')..(tostring(a):gsub("%d+",padnum)) < (k[b] and 0 or to[type(b)] or 'z')..(tostring(b):gsub("%d+",padnum)) end) end local function val2str(t, name, indent, insref, path, plainindex, level) local ttype, level, mt = type(t), (level or 0), getmetatable(t) local spath, sname = safename(path, name) local tag = plainindex and ((type(name) == "number") and '' or name..space..'='..space) or (name ~= nil and sname..space..'='..space or '') if seen[t] then -- already seen this element sref[#sref+1] = spath..space..'='..space..seen[t] return tag..'nil'..comment('ref', level) end if type(mt) == 'table' and (mt.__serialize or mt.__tostring) then -- knows how to serialize itself seen[t] = insref or spath if mt.__serialize then t = mt.__serialize(t) else t = tostring(t) end ttype = type(t) end -- new value falls through to be serialized if ttype == "table" then if level >= maxl then return tag..'{}'..comment('max', level) end seen[t] = insref or spath if next(t) == nil then return tag..'{}'..comment(t, level) end -- table empty local maxn, o, out = math.min(#t, maxnum or #t), {}, {} for key = 1, maxn do o[key] = key end if not maxnum or #o < maxnum then local n = #o -- n = n + 1; o[n] is much faster than o[#o+1] on large tables for key in pairs(t) do if o[key] ~= key then n = n + 1; o[n] = key end end end if maxnum and #o > maxnum then o[maxnum+1] = nil end if opts.sortkeys and #o > maxn then alphanumsort(o, t, opts.sortkeys) end local sparse = sparse and #o > maxn -- disable sparsness if only numeric keys (shorter output) for n, key in ipairs(o) do local value, ktype, plainindex = t[key], type(key), n <= maxn and not sparse if opts.valignore and opts.valignore[value] -- skip ignored values; do nothing or opts.keyallow and not opts.keyallow[key] or opts.valtypeignore and opts.valtypeignore[type(value)] -- skipping ignored value types or sparse and value == nil then -- skipping nils; do nothing elseif ktype == 'table' or ktype == 'function' or badtype[ktype] then if not seen[key] and not globals[key] then sref[#sref+1] = 'placeholder' local sname = safename(iname, gensym(key)) -- iname is table for local variables sref[#sref] = val2str(key,sname,indent,sname,iname,true) end sref[#sref+1] = 'placeholder' local path = seen[t]..'['..(seen[key] or globals[key] or gensym(key))..']' sref[#sref] = path..space..'='..space..(seen[value] or val2str(value,nil,indent,path)) else out[#out+1] = val2str(value,key,indent,insref,seen[t],plainindex,level+1) end end local prefix = string.rep(indent or '', level) local head = indent and '{\n'..prefix..indent or '{' local body = table.concat(out, ','..(indent and '\n'..prefix..indent or space)) local tail = indent and "\n"..prefix..'}' or '}' return (custom and custom(tag,head,body,tail) or tag..head..body..tail)..comment(t, level) elseif badtype[ttype] then seen[t] = insref or spath return tag..globerr(t, level) elseif ttype == 'function' then seen[t] = insref or spath local ok, res = pcall(string.dump, t) local func = ok and ((opts.nocode and "function() --[[..skipped..]] end" or "loadstring("..safestr(res)..",'@serialized')")..comment(t, level)) return tag..(func or globerr(t, level)) else return tag..safestr(t) end -- handle all other types end local sepr = indent and "\n" or ";"..space local body = val2str(t, name, indent) -- this call also populates sref local tail = #sref>1 and table.concat(sref, sepr)..sepr or '' local warn = opts.comment and #sref>1 and space.."--[[incomplete output with shared/self-references skipped]]" or '' return not name and body..warn or "do local "..body..sepr..tail.."return "..name..sepr.."end" end local function merge(a, b) if b then for k,v in pairs(b) do a[k] = v end end; return a; end return { _NAME = n, _COPYRIGHT = c, _DESCRIPTION = d, _VERSION = v, serialize = s, dump = function(a, opts) return s(a, merge({name = '_', compact = true, sparse = true}, opts)) end, line = function(a, opts) return s(a, merge({sortkeys = true, comment = true}, opts)) end, block = function(a, opts) return s(a, merge({indent = ' ', sortkeys = true, comment = true}, opts)) end } end)() ---- end of Serpent module local function removebasedir(path, basedir) if iscasepreserving then -- check if the lowercased path matches the basedir -- if so, return substring of the original path (to not lowercase it) return path:lower():find('^'..q(basedir:lower())) and path:sub(#basedir+1) or path else return string.gsub(path, '^'..q(basedir), '') end end local function stack(start) local function vars(f) local func = debug.getinfo(f, "f").func local i = 1 local locals = {} while true do local name, value = debug.getlocal(f, i) if not name then break end if string.sub(name, 1, 1) ~= '(' then locals[name] = {value, tostring(value)} end i = i + 1 end i = 1 local ups = {} while func and true do -- check for func as it may be nil for tail calls local name, value = debug.getupvalue(func, i) if not name then break end ups[name] = {value, tostring(value)} i = i + 1 end return locals, ups end local stack = {} for i = (start or 0), 100 do local source = debug.getinfo(i, "Snl") if not source then break end local src = source.source if src:find("@") == 1 then src = src:sub(2):gsub("\\", "/") if src:find("%./") == 1 then src = src:sub(3) end end table.insert(stack, { -- remove basedir from source {source.name, removebasedir(src, basedir), source.linedefined, source.currentline, source.what, source.namewhat, source.short_src}, vars(i+1)}) if source.what == 'main' then break end end return stack end local function set_breakpoint(file, line) if file == '-' and lastfile then file = lastfile elseif iscasepreserving then file = string.lower(file) end if not breakpoints[line] then breakpoints[line] = {} end breakpoints[line][file] = true end local function remove_breakpoint(file, line) if file == '-' and lastfile then file = lastfile elseif iscasepreserving then file = string.lower(file) end if breakpoints[line] then breakpoints[line][file] = nil end end local function has_breakpoint(file, line) return breakpoints[line] and breakpoints[line][iscasepreserving and string.lower(file) or file] end local function restore_vars(vars) if type(vars) ~= 'table' then return end -- locals need to be processed in the reverse order, starting from -- the inner block out, to make sure that the localized variables -- are correctly updated with only the closest variable with -- the same name being changed -- first loop find how many local variables there is, while -- the second loop processes them from i to 1 local i = 1 while true do local name = debug.getlocal(3, i) if not name then break end i = i + 1 end i = i - 1 local written_vars = {} while i > 0 do local name = debug.getlocal(3, i) if not written_vars[name] then if string.sub(name, 1, 1) ~= '(' then debug.setlocal(3, i, rawget(vars, name)) end written_vars[name] = true end i = i - 1 end i = 1 local func = debug.getinfo(3, "f").func while true do local name = debug.getupvalue(func, i) if not name then break end if not written_vars[name] then if string.sub(name, 1, 1) ~= '(' then debug.setupvalue(func, i, rawget(vars, name)) end written_vars[name] = true end i = i + 1 end end local function capture_vars(level) local vars = {} local func = debug.getinfo(level or 3, "f").func local i = 1 while true do local name, value = debug.getupvalue(func, i) if not name then break end if string.sub(name, 1, 1) ~= '(' then vars[name] = value end i = i + 1 end i = 1 while true do local name, value = debug.getlocal(level or 3, i) if not name then break end if string.sub(name, 1, 1) ~= '(' then vars[name] = value end i = i + 1 end -- returned 'vars' table plays a dual role: (1) it captures local values -- and upvalues to be restored later (in case they are modified in "eval"), -- and (2) it provides an environment for evaluated chunks. -- getfenv(func) is needed to provide proper environment for functions, -- including access to globals, but this causes vars[name] to fail in -- restore_vars on local variables or upvalues with `nil` values when -- 'strict' is in effect. To avoid this `rawget` is used in restore_vars. setmetatable(vars, { __index = getfenv(func), __newindex = getfenv(func) }) return vars end local function stack_depth(start_depth) for i = start_depth, 0, -1 do if debug.getinfo(i, "l") then return i+1 end end return start_depth end local function is_safe(stack_level) -- the stack grows up: 0 is getinfo, 1 is is_safe, 2 is debug_hook, 3 is user function if stack_level == 3 then return true end for i = 3, stack_level do -- return if it is not safe to abort local info = debug.getinfo(i, "S") if not info then return true end if info.what == "C" then return false end end return true end local function in_debugger() local this = debug.getinfo(1, "S").source -- only need to check few frames as mobdebug frames should be close for i = 3, 7 do local info = debug.getinfo(i, "S") if not info then return false end if info.source == this then return true end end return false end local function is_pending(peer) -- if there is something already in the buffer, skip check if not buf and checkcount >= mobdebug.checkcount then peer:settimeout(0) -- non-blocking buf = peer:receive(1) peer:settimeout() -- back to blocking checkcount = 0 end return buf end local function debug_hook(event, line) -- (1) LuaJIT needs special treatment. Because debug_hook is set for -- *all* coroutines, and not just the one being debugged as in regular Lua -- (http://lua-users.org/lists/lua-l/2011-06/msg00513.html), -- need to avoid debugging mobdebug's own code as LuaJIT doesn't -- always correctly generate call/return hook events (there are more -- calls than returns, which breaks stack depth calculation and -- 'step' and 'step over' commands stop working; possibly because -- 'tail return' events are not generated by LuaJIT). -- the next line checks if the debugger is run under LuaJIT and if -- one of debugger methods is present in the stack, it simply returns. if jit then -- when luajit is compiled with LUAJIT_ENABLE_LUA52COMPAT, -- coroutine.running() returns non-nil for the main thread. local coro, main = coroutine.running() if not coro or main then coro = 'main' end local disabled = coroutines[coro] == false or coroutines[coro] == nil and coro ~= (coro_debugee or 'main') if coro_debugee and disabled or not coro_debugee and (disabled or in_debugger()) then return end end -- (2) check if abort has been requested and it's safe to abort if abort and is_safe(stack_level) then error(abort) end -- (3) also check if this debug hook has not been visited for any reason. -- this check is needed to avoid stepping in too early -- (for example, when coroutine.resume() is executed inside start()). if not seen_hook and in_debugger() then return end if event == "call" then stack_level = stack_level + 1 elseif event == "return" or event == "tail return" then stack_level = stack_level - 1 elseif event == "line" then -- may need to fall through because of the following: -- (1) step_into -- (2) step_over and stack_level <= step_level (need stack_level) -- (3) breakpoint; check for line first as it's known; then for file -- (4) socket call (only do every Xth check) -- (5) at least one watch is registered if not ( step_into or step_over or breakpoints[line] or watchescnt > 0 or is_pending(server) ) then checkcount = checkcount + 1; return end checkcount = mobdebug.checkcount -- force check on the next command -- this is needed to check if the stack got shorter or longer. -- unfortunately counting call/return calls is not reliable. -- the discrepancy may happen when "pcall(load, '')" call is made -- or when "error()" is called in a function. -- in either case there are more "call" than "return" events reported. -- this validation is done for every "line" event, but should be "cheap" -- as it checks for the stack to get shorter (or longer by one call). -- start from one level higher just in case we need to grow the stack. -- this may happen after coroutine.resume call to a function that doesn't -- have any other instructions to execute. it triggers three returns: -- "return, tail return, return", which needs to be accounted for. stack_level = stack_depth(stack_level+1) local caller = debug.getinfo(2, "S") -- grab the filename and fix it if needed local file = lastfile if (lastsource ~= caller.source) then file, lastsource = caller.source, caller.source -- technically, users can supply names that may not use '@', -- for example when they call loadstring('...', 'filename.lua'). -- Unfortunately, there is no reliable/quick way to figure out -- what is the filename and what is the source code. -- The following will work if the supplied filename uses Unix path. if file:find("^@") then file = file:gsub("^@", ""):gsub("\\", "/") -- need this conversion to be applied to relative and absolute -- file names as you may write "require 'Foo'" to -- load "foo.lua" (on a case insensitive file system) and breakpoints -- set on foo.lua will not work if not converted to the same case. if iscasepreserving then file = string.lower(file) end if file:find("%./") == 1 then file = file:sub(3) else file = file:gsub('^'..q(basedir), '') end -- some file systems allow newlines in file names; remove these. file = file:gsub("\n", ' ') else -- this is either a file name coming from loadstring("chunk", "file"), -- or the actual source code that needs to be serialized (as it may -- include newlines); assume it's a file name if it's all on one line. file = file:find("[\r\n]") and serpent.line(file) or file end -- set to true if we got here; this only needs to be done once per -- session, so do it here to at least avoid setting it for every line. seen_hook = true lastfile = file end local vars, status, res if (watchescnt > 0) then vars = capture_vars() for index, value in pairs(watches) do setfenv(value, vars) local ok, fired = pcall(value) if ok and fired then status, res = coroutine.resume(coro_debugger, events.WATCH, vars, file, line, index) break -- any one watch is enough; don't check multiple times end end end -- need to get into the "regular" debug handler, but only if there was -- no watch that was fired. If there was a watch, handle its result. local getin = (status == nil) and (step_into or (step_over and stack_level <= step_level) or has_breakpoint(file, line) or is_pending(server)) if getin then vars = vars or capture_vars() step_into = false step_over = false status, res = coroutine.resume(coro_debugger, events.BREAK, vars, file, line) end -- handle 'stack' command that provides stack() information to the debugger if status and res == 'stack' then while status and res == 'stack' do -- resume with the stack trace and variables if vars then restore_vars(vars) end -- restore vars so they are reflected in stack values -- this may fail if __tostring method fails at run-time local ok, snapshot = pcall(stack, 4) status, res = coroutine.resume(coro_debugger, ok and events.STACK or events.BREAK, snapshot, file, line) end end -- need to recheck once more as resume after 'stack' command may -- return something else (for example, 'exit'), which needs to be handled if status and res and res ~= 'stack' then if abort == nil and res == "exit" then os.exit(1); return end abort = res -- only abort if safe; if not, there is another (earlier) check inside -- debug_hook, which will abort execution at the first safe opportunity if is_safe(stack_level) then error(abort) end elseif not status and res then error(res, 2) -- report any other (internal) errors back to the application end if vars then restore_vars(vars) end end end local function stringify_results(status, ...) if not status then return status, ... end -- on error report as it local t = {...} for i,v in pairs(t) do -- stringify each of the returned values local ok, res = pcall(serpent.line, v, {nocode = true, comment = 1}) t[i] = ok and res or ("%q"):format(res):gsub("\010","n"):gsub("\026","\\026") end -- stringify table with all returned values -- this is done to allow each returned value to be used (serialized or not) -- intependently and to preserve "original" comments return pcall(serpent.dump, t, {sparse = false}) end local function debugger_loop(sev, svars, sfile, sline) local command local app, osname local eval_env = svars or {} local function emptyWatch () return false end local loaded = {} for k in pairs(package.loaded) do loaded[k] = true end while true do local line, err local wx = rawget(genv, "wx") -- use rawread to make strict.lua happy if (wx or mobdebug.yield) and server.settimeout then server:settimeout(mobdebug.yieldtimeout) end while true do line, err = server:receive() if not line and err == "timeout" then -- yield for wx GUI applications if possible to avoid "busyness" app = app or (wx and wx.wxGetApp and wx.wxGetApp()) if app then local win = app:GetTopWindow() local inloop = app:IsMainLoopRunning() osname = osname or wx.wxPlatformInfo.Get():GetOperatingSystemFamilyName() if win and not inloop then -- process messages in a regular way -- and exit as soon as the event loop is idle if osname == 'Unix' then wx.wxTimer(app):Start(10, true) end local exitLoop = function() win:Disconnect(wx.wxID_ANY, wx.wxID_ANY, wx.wxEVT_IDLE) win:Disconnect(wx.wxID_ANY, wx.wxID_ANY, wx.wxEVT_TIMER) app:ExitMainLoop() end win:Connect(wx.wxEVT_IDLE, exitLoop) win:Connect(wx.wxEVT_TIMER, exitLoop) app:MainLoop() end elseif mobdebug.yield then mobdebug.yield() end elseif not line and err == "closed" then error("Debugger connection unexpectedly closed", 0) else -- if there is something in the pending buffer, prepend it to the line if buf then line = buf .. line; buf = nil end break end end if server.settimeout then server:settimeout() end -- back to blocking command = string.sub(line, string.find(line, "^[A-Z]+")) if command == "SETB" then local _, _, _, file, line = string.find(line, "^([A-Z]+)%s+(.-)%s+(%d+)%s*$") if file and line then set_breakpoint(file, tonumber(line)) server:send("200 OK\n") else server:send("400 Bad Request\n") end elseif command == "DELB" then local _, _, _, file, line = string.find(line, "^([A-Z]+)%s+(.-)%s+(%d+)%s*$") if file and line then remove_breakpoint(file, tonumber(line)) server:send("200 OK\n") else server:send("400 Bad Request\n") end elseif command == "EXEC" then local _, _, chunk = string.find(line, "^[A-Z]+%s+(.+)$") if chunk then local func, res = loadstring(chunk) local status if func then setfenv(func, eval_env) status, res = stringify_results(pcall(func)) end if status then server:send("200 OK " .. #res .. "\n") server:send(res) else server:send("401 Error in Expression " .. #res .. "\n") server:send(res) end else server:send("400 Bad Request\n") end elseif command == "LOAD" then local _, _, size, name = string.find(line, "^[A-Z]+%s+(%d+)%s+(%S.-)%s*$") size = tonumber(size) if abort == nil then -- no LOAD/RELOAD allowed inside start() if size > 0 then server:receive(size) end if sfile and sline then server:send("201 Started " .. sfile .. " " .. sline .. "\n") else server:send("200 OK 0\n") end else -- reset environment to allow required modules to load again -- remove those packages that weren't loaded when debugger started for k in pairs(package.loaded) do if not loaded[k] then package.loaded[k] = nil end end if size == 0 and name == '-' then -- RELOAD the current script being debugged server:send("200 OK 0\n") coroutine.yield("load") else -- receiving 0 bytes blocks (at least in luasocket 2.0.2), so skip reading local chunk = size == 0 and "" or server:receive(size) if chunk then -- LOAD a new script for debugging local func, res = loadstring(chunk, "@"..name) if func then server:send("200 OK 0\n") debugee = func coroutine.yield("load") else server:send("401 Error in Expression " .. #res .. "\n") server:send(res) end else server:send("400 Bad Request\n") end end end elseif command == "SETW" then local _, _, exp = string.find(line, "^[A-Z]+%s+(.+)%s*$") if exp then local func, res = loadstring("return(" .. exp .. ")") if func then watchescnt = watchescnt + 1 local newidx = #watches + 1 watches[newidx] = func server:send("200 OK " .. newidx .. "\n") else server:send("401 Error in Expression " .. #res .. "\n") server:send(res) end else server:send("400 Bad Request\n") end elseif command == "DELW" then local _, _, index = string.find(line, "^[A-Z]+%s+(%d+)%s*$") index = tonumber(index) if index > 0 and index <= #watches then watchescnt = watchescnt - (watches[index] ~= emptyWatch and 1 or 0) watches[index] = emptyWatch server:send("200 OK\n") else server:send("400 Bad Request\n") end elseif command == "RUN" then server:send("200 OK\n") local ev, vars, file, line, idx_watch = coroutine.yield() eval_env = vars if ev == events.BREAK then server:send("202 Paused " .. file .. " " .. line .. "\n") elseif ev == events.WATCH then server:send("203 Paused " .. file .. " " .. line .. " " .. idx_watch .. "\n") elseif ev == events.RESTART then -- nothing to do else server:send("401 Error in Execution " .. #file .. "\n") server:send(file) end elseif command == "STEP" then server:send("200 OK\n") step_into = true local ev, vars, file, line, idx_watch = coroutine.yield() eval_env = vars if ev == events.BREAK then server:send("202 Paused " .. file .. " " .. line .. "\n") elseif ev == events.WATCH then server:send("203 Paused " .. file .. " " .. line .. " " .. idx_watch .. "\n") elseif ev == events.RESTART then -- nothing to do else server:send("401 Error in Execution " .. #file .. "\n") server:send(file) end elseif command == "OVER" or command == "OUT" then server:send("200 OK\n") step_over = true -- OVER and OUT are very similar except for -- the stack level value at which to stop if command == "OUT" then step_level = stack_level - 1 else step_level = stack_level end local ev, vars, file, line, idx_watch = coroutine.yield() eval_env = vars if ev == events.BREAK then server:send("202 Paused " .. file .. " " .. line .. "\n") elseif ev == events.WATCH then server:send("203 Paused " .. file .. " " .. line .. " " .. idx_watch .. "\n") elseif ev == events.RESTART then -- nothing to do else server:send("401 Error in Execution " .. #file .. "\n") server:send(file) end elseif command == "BASEDIR" then local _, _, dir = string.find(line, "^[A-Z]+%s+(.+)%s*$") if dir then basedir = iscasepreserving and string.lower(dir) or dir -- reset cached source as it may change with basedir lastsource = nil server:send("200 OK\n") else server:send("400 Bad Request\n") end elseif command == "SUSPEND" then -- do nothing; it already fulfilled its role elseif command == "STACK" then -- first check if we can execute the stack command -- as it requires yielding back to debug_hook it cannot be executed -- if we have not seen the hook yet as happens after start(). -- in this case we simply return an empty result local vars, ev = {} if seen_hook then ev, vars = coroutine.yield("stack") end if ev and ev ~= events.STACK then server:send("401 Error in Execution " .. #vars .. "\n") server:send(vars) else local ok, res = pcall(serpent.dump, vars, {nocode = true, sparse = false}) if ok then server:send("200 OK " .. res .. "\n") else server:send("401 Error in Execution " .. #res .. "\n") server:send(res) end end elseif command == "OUTPUT" then local _, _, stream, mode = string.find(line, "^[A-Z]+%s+(%w+)%s+([dcr])%s*$") if stream and mode and stream == "stdout" then -- assign "print" in the global environment genv.print = mode == 'd' and iobase.print or coroutine.wrap(function(...) -- wrapping into coroutine.wrap protects this function from -- being stepped through in the debugger local tbl = {...} while true do if mode == 'c' then iobase.print(unpack(tbl)) end for n = 1, #tbl do tbl[n] = select(2, pcall(serpent.line, tbl[n], {nocode = true, comment = false})) end local file = table.concat(tbl, "\t").."\n" server:send("204 Output " .. stream .. " " .. #file .. "\n" .. file) tbl = {coroutine.yield()} end end) server:send("200 OK\n") else server:send("400 Bad Request\n") end elseif command == "EXIT" then server:send("200 OK\n") coroutine.yield("exit") else server:send("400 Bad Request\n") end end end local function connect(controller_host, controller_port) return (socket.connect4 or socket.connect)(controller_host, controller_port) end local function isrunning() return coro_debugger and coroutine.status(coro_debugger) == 'suspended' end local lasthost, lastport -- Starts a debug session by connecting to a controller local function start(controller_host, controller_port) -- only one debugging session can be run (as there is only one debug hook) if isrunning() then return end lasthost = controller_host or lasthost lastport = controller_port or lastport controller_host = lasthost or "localhost" controller_port = lastport or mobdebug.port local err server, err = (socket.connect4 or socket.connect)(controller_host, controller_port) if server then -- correct stack depth which already has some calls on it -- so it doesn't go into negative when those calls return -- as this breaks subsequence checks in stack_depth(). -- start from 16th frame, which is sufficiently large for this check. stack_level = stack_depth(16) -- provide our own traceback function to report the error remotely do local dtraceback = debug.traceback debug.traceback = function (...) if select('#', ...) >= 1 then local err, lvl = ... if err and type(err) ~= 'thread' then local trace = dtraceback(err, (lvl or 2)+1) if genv.print == iobase.print then -- no remote redirect return trace else genv.print(trace) -- report the error remotely return -- don't report locally to avoid double reporting end end end -- direct call to debug.traceback: return the original. -- debug.traceback(nil, level) doesn't work in Lua 5.1 -- (http://lua-users.org/lists/lua-l/2011-06/msg00574.html), so -- simply remove first frame from the stack trace return (dtraceback(...):gsub("(stack traceback:\n)[^\n]*\n", "%1")) end end coro_debugger = coroutine.create(debugger_loop) debug.sethook(debug_hook, "lcr") seen_hook = nil -- reset in case the last start() call was refused step_into = true -- start with step command return true else print(("Could not connect to %s:%s: %s") :format(controller_host, controller_port, err or "unknown error")) end end local function controller(controller_host, controller_port, scratchpad) -- only one debugging session can be run (as there is only one debug hook) if isrunning() then return end lasthost = controller_host or lasthost lastport = controller_port or lastport controller_host = lasthost or "localhost" controller_port = lastport or mobdebug.port local exitonerror = not scratchpad local err server, err = (socket.connect4 or socket.connect)(controller_host, controller_port) if server then local function report(trace, err) local msg = err .. "\n" .. trace server:send("401 Error in Execution " .. #msg .. "\n") server:send(msg) return err end seen_hook = true -- allow to accept all commands coro_debugger = coroutine.create(debugger_loop) while true do step_into = true -- start with step command abort = false -- reset abort flag from the previous loop if scratchpad then checkcount = mobdebug.checkcount end -- force suspend right away coro_debugee = coroutine.create(debugee) debug.sethook(coro_debugee, debug_hook, "lcr") local status, err = coroutine.resume(coro_debugee) -- was there an error or is the script done? -- 'abort' state is allowed here; ignore it if abort then if tostring(abort) == 'exit' then break end else if status then -- normal execution is done break elseif err and not tostring(err):find(deferror) then -- report the error back -- err is not necessarily a string, so convert to string to report report(debug.traceback(coro_debugee), tostring(err)) if exitonerror then break end -- resume once more to clear the response the debugger wants to send -- need to use capture_vars(2) as three would be the level of -- the caller for controller(), but because of the tail call, -- the caller may not exist; -- This is not entirely safe as the user may see the local -- variable from console, but they will be reset anyway. -- This functionality is used when scratchpad is paused to -- gain access to remote console to modify global variables. local status, err = coroutine.resume(coro_debugger, events.RESTART, capture_vars(2)) if not status or status and err == "exit" then break end end end end else print(("Could not connect to %s:%s: %s") :format(controller_host, controller_port, err or "unknown error")) return false end return true end local function scratchpad(controller_host, controller_port) return controller(controller_host, controller_port, true) end local function loop(controller_host, controller_port) return controller(controller_host, controller_port, false) end local function on() if not (isrunning() and server) then return end -- main is set to true under Lua5.2 for the "main" chunk. -- Lua5.1 returns co as `nil` in that case. local co, main = coroutine.running() if main then co = nil end if co then coroutines[co] = true debug.sethook(co, debug_hook, "lcr") else if jit then coroutines.main = true end debug.sethook(debug_hook, "lcr") end end local function off() if not (isrunning() and server) then return end -- main is set to true under Lua5.2 for the "main" chunk. -- Lua5.1 returns co as `nil` in that case. local co, main = coroutine.running() if main then co = nil end -- don't remove coroutine hook under LuaJIT as there is only one (global) hook if co then coroutines[co] = false if not jit then debug.sethook(co) end else if jit then coroutines.main = false end if not jit then debug.sethook() end end -- check if there is any thread that is still being debugged under LuaJIT; -- if not, turn the debugging off if jit then local remove = true for co, debugged in pairs(coroutines) do if debugged then remove = false; break end end if remove then debug.sethook() end end end -- Handles server debugging commands local function handle(params, client, options) local _, _, command = string.find(params, "^([a-z]+)") local file, line, watch_idx if command == "run" or command == "step" or command == "out" or command == "over" or command == "exit" then client:send(string.upper(command) .. "\n") client:receive() -- this should consume the first '200 OK' response while true do local done = true local breakpoint = client:receive() if not breakpoint then print("Program finished") os.exit() return -- use return here for those cases where os.exit() is not wanted end local _, _, status = string.find(breakpoint, "^(%d+)") if status == "200" then -- don't need to do anything elseif status == "202" then _, _, file, line = string.find(breakpoint, "^202 Paused%s+(.-)%s+(%d+)%s*$") if file and line then print("Paused at file " .. file .. " line " .. line) end elseif status == "203" then _, _, file, line, watch_idx = string.find(breakpoint, "^203 Paused%s+(.-)%s+(%d+)%s+(%d+)%s*$") if file and line and watch_idx then print("Paused at file " .. file .. " line " .. line .. " (watch expression " .. watch_idx .. ": [" .. watches[watch_idx] .. "])") end elseif status == "204" then local _, _, stream, size = string.find(breakpoint, "^204 Output (%w+) (%d+)$") if stream and size then local msg = client:receive(tonumber(size)) print(msg) if outputs[stream] then outputs[stream](msg) end -- this was just the output, so go back reading the response done = false end elseif status == "401" then local _, _, size = string.find(breakpoint, "^401 Error in Execution (%d+)$") if size then local msg = client:receive(tonumber(size)) print("Error in remote application: " .. msg) os.exit(1) return nil, nil, msg -- use return here for those cases where os.exit() is not wanted end else print("Unknown error") os.exit(1) -- use return here for those cases where os.exit() is not wanted return nil, nil, "Debugger error: unexpected response '" .. breakpoint .. "'" end if done then break end end elseif command == "setb" then _, _, _, file, line = string.find(params, "^([a-z]+)%s+(.-)%s+(%d+)%s*$") if file and line then -- if this is a file name, and not a file source if not file:find('^".*"$') then file = string.gsub(file, "\\", "/") -- convert slash file = removebasedir(file, basedir) end client:send("SETB " .. file .. " " .. line .. "\n") if client:receive() == "200 OK" then set_breakpoint(file, line) else print("Error: breakpoint not inserted") end else print("Invalid command") end elseif command == "setw" then local _, _, exp = string.find(params, "^[a-z]+%s+(.+)$") if exp then client:send("SETW " .. exp .. "\n") local answer = client:receive() local _, _, watch_idx = string.find(answer, "^200 OK (%d+)%s*$") if watch_idx then watches[watch_idx] = exp print("Inserted watch exp no. " .. watch_idx) else local _, _, size = string.find(answer, "^401 Error in Expression (%d+)$") if size then local err = client:receive(tonumber(size)):gsub(".-:%d+:%s*","") print("Error: watch expression not set: " .. err) else print("Error: watch expression not set") end end else print("Invalid command") end elseif command == "delb" then _, _, _, file, line = string.find(params, "^([a-z]+)%s+(.-)%s+(%d+)%s*$") if file and line then -- if this is a file name, and not a file source if not file:find('^".*"$') then file = string.gsub(file, "\\", "/") -- convert slash file = removebasedir(file, basedir) end client:send("DELB " .. file .. " " .. line .. "\n") if client:receive() == "200 OK" then remove_breakpoint(file, line) else print("Error: breakpoint not removed") end else print("Invalid command") end elseif command == "delallb" then for line, breaks in pairs(breakpoints) do for file, _ in pairs(breaks) do client:send("DELB " .. file .. " " .. line .. "\n") if client:receive() == "200 OK" then remove_breakpoint(file, line) else print("Error: breakpoint at file " .. file .. " line " .. line .. " not removed") end end end elseif command == "delw" then local _, _, index = string.find(params, "^[a-z]+%s+(%d+)%s*$") if index then client:send("DELW " .. index .. "\n") if client:receive() == "200 OK" then watches[index] = nil else print("Error: watch expression not removed") end else print("Invalid command") end elseif command == "delallw" then for index, exp in pairs(watches) do client:send("DELW " .. index .. "\n") if client:receive() == "200 OK" then watches[index] = nil else print("Error: watch expression at index " .. index .. " [" .. exp .. "] not removed") end end elseif command == "eval" or command == "exec" or command == "load" or command == "loadstring" or command == "reload" then local _, _, exp = string.find(params, "^[a-z]+%s+(.+)$") if exp or (command == "reload") then if command == "eval" or command == "exec" then exp = (exp:gsub("%-%-%[(=*)%[.-%]%1%]", "") -- remove comments :gsub("%-%-.-\n", " ") -- remove line comments :gsub("\n", " ")) -- convert new lines if command == "eval" then exp = "return " .. exp end client:send("EXEC " .. exp .. "\n") elseif command == "reload" then client:send("LOAD 0 -\n") elseif command == "loadstring" then local _, _, _, file, lines = string.find(exp, "^([\"'])(.-)%1%s+(.+)") if not file then _, _, file, lines = string.find(exp, "^(%S+)%s+(.+)") end client:send("LOAD " .. #lines .. " " .. file .. "\n") client:send(lines) else local file = io.open(exp, "r") if not file and pcall(require, "winapi") then -- if file is not open and winapi is there, try with a short path; -- this may be needed for unicode paths on windows winapi.set_encoding(winapi.CP_UTF8) file = io.open(winapi.short_path(exp), "r") end if not file then error("Cannot open file " .. exp) end -- read the file and remove the shebang line as it causes a compilation error local lines = file:read("*all"):gsub("^#!.-\n", "\n") file:close() local file = string.gsub(exp, "\\", "/") -- convert slash file = removebasedir(file, basedir) client:send("LOAD " .. #lines .. " " .. file .. "\n") if #lines > 0 then client:send(lines) end end while true do local params, err = client:receive() if not params then return nil, nil, "Debugger connection " .. (err or "error") end local done = true local _, _, status, len = string.find(params, "^(%d+).-%s+(%d+)%s*$") if status == "200" then len = tonumber(len) if len > 0 then local status, res local str = client:receive(len) -- handle serialized table with results local func, err = loadstring(str) if func then status, res = pcall(func) if not status then err = res elseif type(res) ~= "table" then err = "received "..type(res).." instead of expected 'table'" end end if err then print("Error in processing results: " .. err) return nil, nil, "Error in processing results: " .. err end print(unpack(res)) return res[1], res end elseif status == "201" then _, _, file, line = string.find(params, "^201 Started%s+(.-)%s+(%d+)%s*$") elseif status == "202" or params == "200 OK" then -- do nothing; this only happens when RE/LOAD command gets the response -- that was for the original command that was aborted elseif status == "204" then local _, _, stream, size = string.find(params, "^204 Output (%w+) (%d+)$") if stream and size then local msg = client:receive(tonumber(size)) print(msg) if outputs[stream] then outputs[stream](msg) end -- this was just the output, so go back reading the response done = false end elseif status == "401" then len = tonumber(len) local res = client:receive(len) print("Error in expression: " .. res) return nil, nil, res else print("Unknown error") return nil, nil, "Debugger error: unexpected response after EXEC/LOAD '" .. params .. "'" end if done then break end end else print("Invalid command") end elseif command == "listb" then for l, v in pairs(breakpoints) do for f in pairs(v) do print(f .. ": " .. l) end end elseif command == "listw" then for i, v in pairs(watches) do print("Watch exp. " .. i .. ": " .. v) end elseif command == "suspend" then client:send("SUSPEND\n") elseif command == "stack" then client:send("STACK\n") local resp = client:receive() local _, _, status, res = string.find(resp, "^(%d+)%s+%w+%s+(.+)%s*$") if status == "200" then local func, err = loadstring(res) if func == nil then print("Error in stack information: " .. err) return nil, nil, err end local ok, stack = pcall(func) if not ok then print("Error in stack information: " .. stack) return nil, nil, stack end for _,frame in ipairs(stack) do print(serpent.line(frame[1], {comment = false})) end return stack elseif status == "401" then local _, _, len = string.find(resp, "%s+(%d+)%s*$") len = tonumber(len) local res = len > 0 and client:receive(len) or "Invalid stack information." print("Error in expression: " .. res) return nil, nil, res else print("Unknown error") return nil, nil, "Debugger error: unexpected response after STACK" end elseif command == "output" then local _, _, stream, mode = string.find(params, "^[a-z]+%s+(%w+)%s+([dcr])%s*$") if stream and mode then client:send("OUTPUT "..stream.." "..mode.."\n") local resp = client:receive() local _, _, status = string.find(resp, "^(%d+)%s+%w+%s*$") if status == "200" then print("Stream "..stream.." redirected") outputs[stream] = type(options) == 'table' and options.handler or nil else print("Unknown error") return nil, nil, "Debugger error: can't redirect "..stream end else print("Invalid command") end elseif command == "basedir" then local _, _, dir = string.find(params, "^[a-z]+%s+(.+)$") if dir then dir = string.gsub(dir, "\\", "/") -- convert slash if not string.find(dir, "/$") then dir = dir .. "/" end local remdir = dir:match("\t(.+)") if remdir then dir = dir:gsub("/?\t.+", "/") end basedir = dir client:send("BASEDIR "..(remdir or dir).."\n") local resp = client:receive() local _, _, status = string.find(resp, "^(%d+)%s+%w+%s*$") if status == "200" then print("New base directory is " .. basedir) else print("Unknown error") return nil, nil, "Debugger error: unexpected response after BASEDIR" end else print(basedir) end elseif command == "help" then print("setb -- sets a breakpoint") print("delb -- removes a breakpoint") print("delallb -- removes all breakpoints") print("setw -- adds a new watch expression") print("delw -- removes the watch expression at index") print("delallw -- removes all watch expressions") print("run -- runs until next breakpoint") print("step -- runs until next line, stepping into function calls") print("over -- runs until next line, stepping over function calls") print("out -- runs until line after returning from current function") print("listb -- lists breakpoints") print("listw -- lists watch expressions") print("eval -- evaluates expression on the current context and returns its value") print("exec -- executes statement on the current context") print("load -- loads a local file for debugging") print("reload -- restarts the current debugging session") print("stack -- reports stack trace") print("output stdout -- capture and redirect io stream (default|copy|redirect)") print("basedir [] -- sets the base path of the remote application, or shows the current one") print("exit -- exits debugger") else local _, _, spaces = string.find(params, "^(%s*)$") if not spaces then print("Invalid command") return nil, nil, "Invalid command" end end return file, line end -- Starts debugging server local function listen(host, port) host = host or "*" port = port or mobdebug.port local socket = require "socket" print("Lua Remote Debugger") print("Run the program you wish to debug") local server = socket.bind(host, port) local client = server:accept() client:send("STEP\n") client:receive() local breakpoint = client:receive() local _, _, file, line = string.find(breakpoint, "^202 Paused%s+(.-)%s+(%d+)%s*$") if file and line then print("Paused at file " .. file ) print("Type 'help' for commands") else local _, _, size = string.find(breakpoint, "^401 Error in Execution (%d+)%s*$") if size then print("Error in remote application: ") print(client:receive(size)) end end while true do io.write("> ") local line = io.read("*line") handle(line, client) end end local cocreate local function coro() if cocreate then return end -- only set once cocreate = cocreate or coroutine.create coroutine.create = function(f, ...) return cocreate(function(...) require("mobdebug").on() return f(...) end, ...) end end local moconew local function moai() if moconew then return end -- only set once moconew = moconew or (MOAICoroutine and MOAICoroutine.new) if not moconew then return end MOAICoroutine.new = function(...) local thread = moconew(...) -- need to support both thread.run and getmetatable(thread).run, which -- was used in earlier MOAI versions local mt = thread.run and thread or getmetatable(thread) local patched = mt.run mt.run = function(self, f, ...) return patched(self, function(...) require("mobdebug").on() return f(...) end, ...) end return thread end end -- this is a function that removes all hooks and closes the socket to -- report back to the controller that the debugging is done. -- the script that called `done` can still continue. local function done() if not (isrunning() and server) then return end if not jit then for co, debugged in pairs(coroutines) do if debugged then debug.sethook(co) end end end debug.sethook() server:close() coro_debugger = nil -- to make sure isrunning() returns `false` seen_hook = nil -- to make sure that the next start() call works abort = nil -- to make sure that callback calls use proper "abort" value end -- make public functions available mobdebug.listen = listen mobdebug.loop = loop mobdebug.scratchpad = scratchpad mobdebug.handle = handle mobdebug.connect = connect mobdebug.start = start mobdebug.on = on mobdebug.off = off mobdebug.moai = moai mobdebug.coro = coro mobdebug.done = done mobdebug.line = serpent.line mobdebug.dump = serpent.dump mobdebug.yield = nil -- callback -- this is needed to make "require 'modebug'" to work when mobdebug -- module is loaded manually package.loaded.mobdebug = mobdebug return mobdebug ================================================ FILE: Resources/res/atlas.txt ================================================ bg_day 288 512 0.0 0.0 0.28125 0.5 bg_night 288 512 0.28515625 0.0 0.28125 0.5 bird0_0 48 48 0.0 0.9472656 0.046875 0.046875 bird0_1 48 48 0.0546875 0.9472656 0.046875 0.046875 bird0_2 48 48 0.109375 0.9472656 0.046875 0.046875 bird1_0 48 48 0.1640625 0.9472656 0.046875 0.046875 bird1_1 48 48 0.21875 0.6308594 0.046875 0.046875 bird1_2 48 48 0.21875 0.6816406 0.046875 0.046875 bird2_0 48 48 0.21875 0.7324219 0.046875 0.046875 bird2_1 48 48 0.21875 0.7832031 0.046875 0.046875 bird2_2 48 48 0.21875 0.8339844 0.046875 0.046875 black 32 32 0.5703125 0.40234375 0.03125 0.03125 blink_00 10 10 0.26953125 0.6660156 0.009765625 0.009765625 blink_01 10 10 0.26953125 0.7167969 0.009765625 0.009765625 blink_02 10 10 0.26953125 0.7675781 0.009765625 0.009765625 brand_copyright 126 14 0.86328125 0.17773438 0.123046875 0.013671875 button_menu 80 28 0.90234375 0.05078125 0.078125 0.02734375 button_ok 80 28 0.90234375 0.08203125 0.078125 0.02734375 button_pause 26 28 0.23632812 0.59765625 0.025390625 0.02734375 button_play 116 70 0.6855469 0.22851562 0.11328125 0.068359375 button_rate 74 48 0.90234375 0.0 0.072265625 0.046875 button_resume 26 28 0.65234375 0.27734375 0.025390625 0.02734375 button_score 116 70 0.8027344 0.22851562 0.11328125 0.068359375 button_share 80 28 0.5703125 0.27734375 0.078125 0.02734375 font_048 24 44 0.96875 0.11328125 0.0234375 0.04296875 font_049 16 44 0.265625 0.8847656 0.015625 0.04296875 font_050 24 44 0.5703125 0.30859375 0.0234375 0.04296875 font_051 24 44 0.59765625 0.30859375 0.0234375 0.04296875 font_052 24 44 0.625 0.30859375 0.0234375 0.04296875 font_053 24 44 0.65234375 0.30859375 0.0234375 0.04296875 font_054 24 44 0.5703125 0.35546875 0.0234375 0.04296875 font_055 24 44 0.59765625 0.35546875 0.0234375 0.04296875 font_056 24 44 0.625 0.35546875 0.0234375 0.04296875 font_057 24 44 0.65234375 0.35546875 0.0234375 0.04296875 land 336 112 0.5703125 0.0 0.328125 0.109375 medals_0 44 44 0.23632812 0.50390625 0.04296875 0.04296875 medals_1 44 44 0.23632812 0.55078125 0.04296875 0.04296875 medals_2 44 44 0.21875 0.8847656 0.04296875 0.04296875 medals_3 44 44 0.21875 0.9316406 0.04296875 0.04296875 new 32 14 0.21875 0.9785156 0.03125 0.013671875 number_context_00 12 14 0.26953125 0.6308594 0.01171875 0.013671875 number_context_01 12 14 0.26953125 0.6484375 0.01171875 0.013671875 number_context_02 12 14 0.26953125 0.6816406 0.01171875 0.013671875 number_context_03 12 14 0.26953125 0.69921875 0.01171875 0.013671875 number_context_04 12 14 0.26953125 0.7324219 0.01171875 0.013671875 number_context_05 12 14 0.26953125 0.75 0.01171875 0.013671875 number_context_06 12 14 0.26953125 0.7832031 0.01171875 0.013671875 number_context_07 12 14 0.26953125 0.80078125 0.01171875 0.013671875 number_context_08 12 14 0.26953125 0.8339844 0.01171875 0.013671875 number_context_09 12 14 0.26953125 0.8515625 0.01171875 0.013671875 number_context_10 12 14 0.96875 0.16015625 0.01171875 0.013671875 number_score_00 16 20 0.265625 0.59765625 0.015625 0.01953125 number_score_01 16 20 0.265625 0.9316406 0.015625 0.01953125 number_score_02 16 20 0.265625 0.9550781 0.015625 0.01953125 number_score_03 16 20 0.25390625 0.9785156 0.015625 0.01953125 number_score_04 16 20 0.9785156 0.0 0.015625 0.01953125 number_score_05 16 20 0.9785156 0.0234375 0.015625 0.01953125 number_score_06 16 20 0.984375 0.05078125 0.015625 0.01953125 number_score_07 16 20 0.984375 0.08203125 0.015625 0.01953125 number_score_08 16 20 0.5703125 0.47265625 0.015625 0.01953125 number_score_09 16 20 0.60546875 0.40234375 0.015625 0.01953125 pipe2_down 52 320 0.0 0.6308594 0.05078125 0.3125 pipe2_up 52 320 0.0546875 0.6308594 0.05078125 0.3125 pipe_down 52 320 0.109375 0.6308594 0.05078125 0.3125 pipe_up 52 320 0.1640625 0.6308594 0.05078125 0.3125 score_panel 238 126 0.0 0.50390625 0.23242188 0.123046875 text_game_over 204 54 0.765625 0.11328125 0.19921875 0.052734375 text_ready 196 62 0.5703125 0.11328125 0.19140625 0.060546875 title 178 48 0.6855469 0.17773438 0.17382812 0.046875 tutorial 114 98 0.5703125 0.17773438 0.111328125 0.095703125 white 32 32 0.5703125 0.4375 0.03125 0.03125 ================================================ FILE: Resources/scripts/GameScene.lua ================================================ -- -- Author: GeZiyang -- Date: 2014-02-10 -- local midX = visibleSize.width / 2 local midY = visibleSize.height / 2 --config local birdX = 90 local birdSize = 15 local pipeCount = 5 local pipeHeight = 320 local pipeDistance = 100 local landHeight = 112 local tapV = 260 local systemGravity = -900 --config end -- vars local PIPE_NEW = 0 local PIPE_PASS = 1 g_initFlag = false local gameOver = false local sceneGame = nil local scoreNode = nil local pipes = {} -- for score calcs 0 for local pipeState = {} local totalScore = 0 local checkFunc = 0 local createPipeFunc = 0 local birdRotateFunc = 0 local gameLayerListener = nil local overLayerListener = nil -- functions local function showGameOverLayer() local overLayer = cc.Layer:create() local actionNode = cc.Node:create() overLayer:addChild(actionNode) local gameOverLogo = createAtlasSprite("text_game_over") local scorePanel = createAtlasSprite("score_panel") local nowScoreNode = cc.Node:create() local bestScoreNode = cc.Node:create() local newInfoSprite = createAtlasSprite("new") local playButton = createAtlasSprite("button_play") local rankButton = createAtlasSprite("button_score") local function initOverItems() -- game over gameOverLogo:setPosition(cc.p(midX, midY + 100)) gameOverLogo:setVisible(false) overLayer:addChild(gameOverLogo) -- score panel scorePanel:setPosition(cc.p(midX, midY)) scorePanel:setVisible(false) -- score node nowScoreNode:setPosition(cc.p(200, 80)) scorePanel:addChild(nowScoreNode) bestScoreNode:setPosition(cc.p(200, 40)) scorePanel:addChild(bestScoreNode) -- new info newInfoSprite:setPosition(cc.p(155, 60)) newInfoSprite:setVisible(false) scorePanel:addChild(newInfoSprite) overLayer:addChild(scorePanel) --bottom buttons -- play button playButton:setPosition(cc.p(midX / 2, midY - 120)) playButton:setVisible(false) overLayer:addChild(playButton, 1000) g_playButton = playButton -- rank button rankButton:setPosition(cc.p(visibleSize.width * 3 / 4, midY - 120)) rankButton:setVisible(false) overLayer:addChild(rankButton, 1000) g_rankButton = rankButton end local function showOverItems() local function showGameOverLogo() cc.SimpleAudioEngine:getInstance():playEffect(uiPath) scoreNode:setVisible(false) gameOverLogo:setVisible(true) local place = cc.Place:create(cc.p(midX, midY + 120)) local move1 = cc.MoveTo:create(0.2, cc.p(midX, midY + 96)) local move2 = cc.MoveTo:create(0.2, cc.p(midX, midY + 100)) gameOverLogo:runAction(cc.Sequence:create(place, move1, move2)) end local function showScorePanel() cc.SimpleAudioEngine:getInstance():playEffect(uiPath) scorePanel:setVisible(true) local place = cc.Place:create(cc.p(midX, -100)) local move1 = cc.MoveTo:create(0.1, cc.p(midX, midY)) scorePanel:runAction(cc.Sequence:create(place, move1)) end local function showNewRecordInfo() newInfoSprite:setVisible(true) end local function showMedal() if totalScore < 10 then return end local medalStr = "medals_"..(math.max(4 - math.floor(totalScore / 10), 0)) local medalSprite = createAtlasSprite(medalStr) medalSprite:setPosition(cc.p(55, 60)) scorePanel:addChild(medalSprite) end local function showScoreNumber() --CreateSpriteScore(nowScoreNode, totalScore, 2, 2) local savedBestScore = cc.UserDefault:getInstance():getIntegerForKey("bestScore", 0) if totalScore > savedBestScore then savedBestScore = totalScore -- show new showNewRecordInfo() -- save score cc.UserDefault:getInstance():setIntegerForKey("bestScore", totalScore) end CreateSpriteScore(bestScoreNode, savedBestScore, 2, 2) CreateSpriteScore(nowScoreNode, 0, 2, 2) local tmpScore = 0 local showSingleNumberFunc = 0 local function showSingleNumber() CreateSpriteScore(nowScoreNode, tmpScore, 2, 2) tmpScore = tmpScore + 1 if tmpScore > totalScore then cc.Director:getInstance():getScheduler():unscheduleScriptEntry(showSingleNumberFunc) end end showSingleNumberFunc = cc.Director:getInstance():getScheduler():scheduleScriptFunc(showSingleNumber, 0.5 / totalScore, false) end local function showBottomButton() playButton:setVisible(true) rankButton:setVisible(true) end local delay1 = cc.DelayTime:create(1) local showOverLogoFunc = cc.CallFunc:create(showGameOverLogo) local showScorePanelFunc = cc.CallFunc:create(showScorePanel) local showMedalFunc = cc.CallFunc:create(showMedal) local showScoreNumberFunc = cc.CallFunc:create(showScoreNumber) local showBottomButtonFunc = cc.CallFunc:create(showBottomButton) local action = cc.Sequence:create(delay1, showOverLogoFunc, delay1, showScorePanelFunc, showMedalFunc, showScoreNumberFunc, delay1, showBottomButtonFunc) actionNode:runAction(action) end initOverItems() showOverItems() -- listener g_rateButton = nil overLayerListener = cc.EventListenerTouchOneByOne:create() overLayerListener:registerScriptHandler(onCommonMenuLayerTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN ) overLayerListener:registerScriptHandler(onCommonMenuLayerTouchEnded,cc.Handler.EVENT_TOUCH_ENDED ) overLayer:getEventDispatcher():addEventListenerWithSceneGraphPriority(overLayerListener, overLayer) sceneGame:addChild(overLayer) end local function createPipes(layer) local function initPipe() for i = 1, pipeCount do local downPipe = createAtlasSprite("pipe_down") local upPipe = createAtlasSprite("pipe_up") downPipe:setPosition(cc.p(0, pipeHeight + pipeDistance)) local singlePipe = cc.Node:create() singlePipe:addChild(downPipe) singlePipe:addChild(upPipe) singlePipe:setPosition(cc.p(- visibleSize.width * 2, 0)) layer:addChild(singlePipe, 10) pipes[i] = singlePipe pipeState[i] = PIPE_PASS end end local function createPipe() for i = 1, pipeCount do print(i) if pipes[i]:getPositionX() < -100 then local pipeNode = pipes[i] pipeState[i] = PIPE_NEW pipeNode:stopAllActions() local randomHeight = math.random(0,3) pipeNode:setPosition(cc.p(visibleSize.width * 2, 50 * randomHeight)) pipeNode:setTag(randomHeight) local move = cc.MoveTo:create(8, cc.p(- visibleSize.width * 2, 50 * randomHeight)) pipeNode:runAction(move) break end end end initPipe() createPipeFunc = cc.Director:getInstance():getScheduler():scheduleScriptFunc(createPipe, 1.3, false) end local function createLayerBg() local layerBg, land_1, land_2 = createCommonBackLayer() local groudNode = cc.Node:create() groudNode:setPhysicsBody(cc.PhysicsBody:createEdgeSegment(cc.p(0, landHeight), cc.p(288, landHeight))) layerBg:addChild(groudNode) -- add bird local spriteBird = createBird() spriteBird:setPosition(birdX, visibleSize.height / 2 + 10) spriteBird:setPhysicsBody(cc.PhysicsBody:createCircle(birdSize)) spriteBird:getPhysicsBody():setEnable(false) spriteBird:runAction(createFlyAction(cc.p(spriteBird:getPosition()))) layerBg:addChild(spriteBird, 1000) -- add blink white local whiteBlinkSprite = createAtlasSprite("white") whiteBlinkSprite:setScale(100) whiteBlinkSprite:setOpacity(0) layerBg:addChild(whiteBlinkSprite, 2000) -- init ready info local rNode = nil local rTextSprite = nil local rImage = nil local function initReady() local readyTextSprite = createAtlasSprite("text_ready") readyTextSprite:setPosition(cc.p(0, 100)) local readyImage = createAtlasSprite("tutorial") local readyNode = cc.Node:create() readyNode:addChild(readyTextSprite) readyNode:addChild(readyImage) readyNode:setPosition(cc.p(visibleSize.width / 2, visibleSize.height / 2)) rNode = readyNode rTextSprite = readyTextSprite rImage = readyImage layerBg:addChild(readyNode) end local function hideReady() spriteBird:stopActionByTag(g_flyTag) rTextSprite:runAction(cc.FadeOut:create(0.2)) rImage:runAction(cc.FadeOut:create(0.2)) end initReady() -- score scoreNode = cc.Node:create() local function initScore() scoreNode:setPosition(cc.p(visibleSize.width / 2, visibleSize.height * 4 / 5 + 10)) layerBg:addChild(scoreNode, 10000) end local function refreshScore() CreateSpriteScore(scoreNode, totalScore, 1, 1) end initScore() refreshScore() local function blinkWhite() local fadeIn = cc.FadeIn:create(0.1) local fadeOut = cc.FadeOut:create(0.1) whiteBlinkSprite:runAction(cc.Sequence:create(fadeIn, fadeOut)) end local function GameOver() gameOver = true cc.SimpleAudioEngine:getInstance():playEffect(hitPath) for i = 1, pipeCount do pipes[i]:stopAllActions() end land_1:stopAllActions() land_2:stopAllActions() spriteBird:getPhysicsBody():setVelocity(cc.p(0, 0)) cc.Director:getInstance():getScheduler():unscheduleScriptEntry(createPipeFunc) cc.Director:getInstance():getScheduler():unscheduleScriptEntry(checkFunc) blinkWhite() layerBg:getEventDispatcher():removeEventListener(gameLayerListener) showGameOverLayer() end -- check hit and calc score local function rotateBird() local v = spriteBird:getPhysicsBody():getVelocity() spriteBird:setRotation(math.min(math.max(-90, v.y * 0.2 + 60), 30)) end local function checkHit() -- check hit if spriteBird:getPositionY() < landHeight + birdSize then GameOver() return end -- calc score for i=1, pipeCount do -- check hit if math.abs(pipes[i]:getPositionX() - birdX) < (birdSize + 26) then -- check down if spriteBird:getPositionY() < pipes[i]:getPositionY() + pipeHeight / 2 + birdSize then cc.SimpleAudioEngine:getInstance():playEffect(fallPath) GameOver() return end -- check up if spriteBird:getPositionY() > pipes[i]:getPositionY() + pipeHeight / 2 + pipeDistance - birdSize then cc.SimpleAudioEngine:getInstance():playEffect(fallPath) GameOver() return end end if pipeState[i] == PIPE_NEW and pipes[i]:getPositionX() < birdX then pipeState[i] = PIPE_PASS totalScore = totalScore + 1 cc.SimpleAudioEngine:getInstance():playEffect(scorePath) refreshScore() return end end end -- listener local touchBeginPoint = nil local ready = false local function onTouchBegan(touch, event) local location = touch:getLocation() -- cclog("onTouchBegan: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = {x = location.x, y = location.y} if not ready then ready = true hideReady() createPipes(layerBg) spriteBird:getPhysicsBody():setEnable(true) spriteBird:getPhysicsBody():setVelocity(cc.p(0, tapV)) checkFunc = cc.Director:getInstance():getScheduler():scheduleScriptFunc(checkHit, 0, false) birdRotateFunc = cc.Director:getInstance():getScheduler():scheduleScriptFunc(rotateBird, 0, false) else -- spriteBird:setPosition(cc.p(birdX, spriteBird:getPositionY() + 10)) spriteBird:getPhysicsBody():setVelocity(cc.p(0, tapV)) -- spriteBird:getPhysicsBody():applyImpulse(cc.p(0, 20000)) print(spriteBird:getPhysicsBody():getVelocity().y) end cc.SimpleAudioEngine:getInstance():playEffect(wingPath) -- CCTOUCHBEGAN event must return true return true end gameLayerListener = cc.EventListenerTouchOneByOne:create() gameLayerListener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN ) layerBg:getEventDispatcher():addEventListenerWithSceneGraphPriority(gameLayerListener, layerBg) local function onContactBegin(event, contact) cclog("onContactBegin") if not gameOver then gameOver = true GameOver() end spriteBird:getPhysicsBody():setEnable(false) spriteBird:stopAllActions() spriteBird:setRotation(-90) cc.Director:getInstance():getScheduler():unscheduleScriptEntry(birdRotateFunc) birdRotateFunc = 0 end local contactListener = cc.EventListenerPhysicsContactWithBodies:create(groudNode:getPhysicsBody(), spriteBird:getPhysicsBody()) contactListener:registerScriptHandler(onContactBegin, cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN) layerBg:getEventDispatcher():addEventListenerWithSceneGraphPriority(contactListener, layerBg) return layerBg end local function resetGameSceneValue() totalScore = 0 gameOver = false if birdRotateFunc ~= 0 then cc.Director:getInstance():getScheduler():unscheduleScriptEntry(birdRotateFunc) birdRotateFunc = 0 end end -- run function createGameScene() resetGameSceneValue() local scene = cc.Scene:createWithPhysics() -- scene:getPhysicsWorld():setDebugDrawMask(cc.PhysicsWorld.DEBUGDRAW_ALL) scene:getPhysicsWorld():setGravity(cc.p(0, systemGravity)) local gravity = scene:getPhysicsWorld():getGravity() print("gravity : "..gravity.x.." "..gravity.y) local layerBg = createLayerBg() scene:addChild(layerBg) sceneGame = scene return scene end return createGameScene() ================================================ FILE: Resources/scripts/StartScene.lua ================================================ -- -- Author: GeZiyang -- Date: 2014-02-10 -- -- config local sceneStart = nil local function createStartBackLayer() local backLayer = createCommonBackLayer() -- logo local spriteLogo = createAtlasSprite("title") spriteLogo:setPosition(cc.p(visibleSize.width / 2, visibleSize.height * 2 / 3)) backLayer:addChild(spriteLogo) -- flappy bird local spriteBird = createBird() spriteBird:setPosition(cc.p(visibleSize.width / 2, visibleSize.height / 2 + 25)) spriteBird:runAction(createFlyAction(cc.p(spriteBird:getPosition()))) backLayer:addChild(spriteBird) -- rate button local rateButton = createAtlasSprite("button_rate") rateButton:setPosition(cc.p(visibleSize.width / 2, visibleSize.height / 2 - 35)) backLayer:addChild(rateButton) -- play button local playButton = createAtlasSprite("button_play") playButton:setPosition(cc.p(visibleSize.width / 4, visibleSize.height / 2 - 120)) backLayer:addChild(playButton, 1000) -- rank button local rankButton = createAtlasSprite("button_score") rankButton:setPosition(cc.p(visibleSize.width * 3 / 4, visibleSize.height / 2 - 120)) backLayer:addChild(rankButton, 1000) -- copy right local spriteCopyright = createAtlasSprite("brand_copyright") spriteCopyright:setPosition(cc.p(visibleSize.width / 2, visibleSize.height / 2 - 170)) backLayer:addChild(spriteCopyright, 1000) -- for common listener g_rateButton = rateButton g_playButton = playButton g_rankButton = rankButton local listener = cc.EventListenerTouchOneByOne:create() listener:registerScriptHandler(onCommonMenuLayerTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN ) listener:registerScriptHandler(onCommonMenuLayerTouchEnded,cc.Handler.EVENT_TOUCH_ENDED ) local eventDispatcher = backLayer:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(listener, backLayer) return backLayer end -- run if sceneStart == nil then sceneStart = cc.Scene:create() local backLayer = createStartBackLayer() sceneStart:addChild(backLayer) end return sceneStart ================================================ FILE: Resources/scripts/out.lua ================================================ a = {} a["bg_day"]={width=288, height=512, x=0, y=0} a["bg_night"]={width=288, height=512, x=292, y=0} a["bird0_0"]={width=48, height=48, x=0, y=970} a["bird0_1"]={width=48, height=48, x=56, y=970} a["bird0_2"]={width=48, height=48, x=112, y=970} a["bird1_0"]={width=48, height=48, x=168, y=970} a["bird1_1"]={width=48, height=48, x=224, y=646} a["bird1_2"]={width=48, height=48, x=224, y=698} a["bird2_0"]={width=48, height=48, x=224, y=750} a["bird2_1"]={width=48, height=48, x=224, y=802} a["bird2_2"]={width=48, height=48, x=224, y=854} a["black"]={width=32, height=32, x=584, y=412} a["blink_00"]={width=10, height=10, x=276, y=682} a["blink_01"]={width=10, height=10, x=276, y=734} a["blink_02"]={width=10, height=10, x=276, y=786} a["brand_copyright"]={width=126, height=14, x=884, y=182} a["button_menu"]={width=80, height=28, x=924, y=52} a["button_ok"]={width=80, height=28, x=924, y=84} a["button_pause"]={width=26, height=28, x=242, y=612} a["button_play"]={width=116, height=70, x=702, y=234} a["button_rate"]={width=74, height=48, x=924, y=0} a["button_resume"]={width=26, height=28, x=668, y=284} a["button_score"]={width=116, height=70, x=822, y=234} a["button_share"]={width=80, height=28, x=584, y=284} a["font_048"]={width=24, height=44, x=992, y=116} a["font_049"]={width=16, height=44, x=272, y=906} a["font_050"]={width=24, height=44, x=584, y=316} a["font_051"]={width=24, height=44, x=612, y=316} a["font_052"]={width=24, height=44, x=640, y=316} a["font_053"]={width=24, height=44, x=668, y=316} a["font_054"]={width=24, height=44, x=584, y=364} a["font_055"]={width=24, height=44, x=612, y=364} a["font_056"]={width=24, height=44, x=640, y=364} a["font_057"]={width=24, height=44, x=668, y=364} a["land"]={width=336, height=112, x=584, y=0} a["medals_0"]={width=44, height=44, x=242, y=516} a["medals_1"]={width=44, height=44, x=242, y=564} a["medals_2"]={width=44, height=44, x=224, y=906} a["medals_3"]={width=44, height=44, x=224, y=954} a["new"]={width=32, height=14, x=224, y=1002} a["number_context_00"]={width=12, height=14, x=276, y=646} a["number_context_01"]={width=12, height=14, x=276, y=664} a["number_context_02"]={width=12, height=14, x=276, y=698} a["number_context_03"]={width=12, height=14, x=276, y=716} a["number_context_04"]={width=12, height=14, x=276, y=750} a["number_context_05"]={width=12, height=14, x=276, y=768} a["number_context_06"]={width=12, height=14, x=276, y=802} a["number_context_07"]={width=12, height=14, x=276, y=820} a["number_context_08"]={width=12, height=14, x=276, y=854} a["number_context_09"]={width=12, height=14, x=276, y=872} a["number_context_10"]={width=12, height=14, x=992, y=164} a["number_score_00"]={width=16, height=20, x=272, y=612} a["number_score_01"]={width=16, height=20, x=272, y=954} a["number_score_02"]={width=16, height=20, x=272, y=978} a["number_score_03"]={width=16, height=20, x=260, y=1002} a["number_score_04"]={width=16, height=20, x=1002, y=0} a["number_score_05"]={width=16, height=20, x=1002, y=24} a["number_score_06"]={width=16, height=20, x=1008, y=52} a["number_score_07"]={width=16, height=20, x=1008, y=84} a["number_score_08"]={width=16, height=20, x=584, y=484} a["number_score_09"]={width=16, height=20, x=620, y=412} a["pipe2_down"]={width=52, height=320, x=0, y=646} a["pipe2_up"]={width=52, height=320, x=56, y=646} a["pipe_down"]={width=52, height=320, x=112, y=646} a["pipe_up"]={width=52, height=320, x=168, y=646} a["score_panel"]={width=238, height=126, x=0, y=516} a["text_game_over"]={width=204, height=54, x=784, y=116} a["text_ready"]={width=196, height=62, x=584, y=116} a["title"]={width=178, height=48, x=702, y=182} a["tutorial"]={width=114, height=98, x=584, y=182} a["white"]={width=32, height=32, x=584, y=448} ================================================ FILE: Resources/scripts/tools.lua ================================================ -- -- Author: GeZiyang -- Date: 2014-02-10 -- -- config local flySpeed = 2.5 local flyOffset = 5 -- vars g_flyTag = 1000 g_rateButton = nil g_playButton = nil g_rankButton = nil cc.FileUtils:getInstance():addSearchPath("res/") local textureAtlas = cc.Director:getInstance():getTextureCache():addImage("atlas.png") wingPath = cc.FileUtils:getInstance():fullPathForFilename("sfx_wing.wav") hitPath = cc.FileUtils:getInstance():fullPathForFilename("sfx_hit.wav") scorePath = cc.FileUtils:getInstance():fullPathForFilename("sfx_point.wav") fallPath = cc.FileUtils:getInstance():fullPathForFilename("sfx_die.wav") uiPath = cc.FileUtils:getInstance():fullPathForFilename("sfx_swooshing.wav") cc.SimpleAudioEngine:getInstance():preloadEffect(wingPath) cc.SimpleAudioEngine:getInstance():preloadEffect(hitPath) cc.SimpleAudioEngine:getInstance():preloadEffect(scorePath) cc.SimpleAudioEngine:getInstance():preloadEffect(fallPath) cc.SimpleAudioEngine:getInstance():preloadEffect(uiPath) visibleSize = cc.Director:getInstance():getVisibleSize() print("visibleSize :"..visibleSize.width.." "..visibleSize.height) local function generateSpriteLuaFile() -- body local atlasFile = io.open("atlas.txt", "r") local outFile = io.open("out.lua","w") outFile:write("a = {}\n") local line, tmpSprite for line in atlasFile:lines() do tmpSprite = {} for i in string.gmatch(line, "%S+") do tmpSprite[#tmpSprite + 1] = i cclog(i) end local name = tmpSprite[1] local width = tmpSprite[2] local height = tmpSprite[3] local x = math.floor(1024 * (tonumber(tmpSprite[4])) + 0.1) local y = math.floor(1024 * (tonumber(tmpSprite[5])) + 0.1) outFile:write(string.format("a[\"%s\"]={width=%s, height=%s, x=%s, y=%s}\n", name, width, height, x, y)) end outFile.close() end function createAtlasSprite(name) local tmpTable = a[name] local rectX = tmpTable.x local rectY = tmpTable.y local rectWidth = tmpTable.width local rectHeight = tmpTable.height -- fix 1px edge bug if name == "land" then rectX = rectX + 1 end local rect = cc.rect(rectX, rectY, rectWidth, rectHeight) local frame = cc.SpriteFrame:createWithTexture(textureAtlas, rect) local atlasSprite = cc.Sprite:createWithSpriteFrame(frame) return atlasSprite end function getSpriteSize(name) return cc.size(a[name].width, a[name].height) end function createBird() local randomIndex = math.random(0, 2) local birdFrames = {} for i=1,3 do local tmpTable = a["bird"..randomIndex.."_"..(i-1)] local rect = cc.rect(tmpTable.x, tmpTable.y, tmpTable.width, tmpTable.height) local frame = cc.SpriteFrame:createWithTexture(textureAtlas, rect) birdFrames[#birdFrames + 1] = frame end local spriteBird = cc.Sprite:createWithSpriteFrame(birdFrames[1]) local animation = cc.Animation:createWithSpriteFrames(birdFrames, 0.1) local animate = cc.Animate:create(animation); spriteBird:runAction(cc.RepeatForever:create(animate)) return spriteBird end function createCommonBackLayer() local layerBg = cc.Layer:create() local randomBgIndex = math.random(1, 2) local bgName = "bg_day" if randomBgIndex == 2 then bgName = "bg_night" end local bg = createAtlasSprite(bgName) bg:setPosition(cc.p(visibleSize.width / 2, visibleSize.height / 2)) layerBg:addChild(bg) local landHeight = getSpriteSize("land").height -- first moving land local land_1 = createAtlasSprite("land") land_1:setPosition(visibleSize.width / 2, landHeight / 2) layerBg:addChild(land_1, 100) local move1 = cc.MoveTo:create(2, cc.p(- visibleSize.width / 2, landHeight / 2)) local reset1 = cc.Place:create(cc.p(visibleSize.width / 2, landHeight / 2)) land_1:runAction(cc.RepeatForever:create(cc.Sequence:create(move1, reset1))) -- second moving land local land_2 = createAtlasSprite("land") land_2:setPosition(visibleSize.width * 3 / 2, landHeight / 2) layerBg:addChild(land_2, 100) local move2 = cc.MoveTo:create(2, cc.p(visibleSize.width / 2, landHeight / 2)) local reset2 = cc.Place:create(cc.p(visibleSize.width * 3 / 2, landHeight / 2)) land_2:runAction(cc.RepeatForever:create(cc.Sequence:create(move2, reset2))) return layerBg, land_1, land_2 end function createFlyAction(position) local moveUp = cc.MoveTo:create(1.0 / flySpeed, cc.p(position.x, position.y + flyOffset)) local moveDown = cc.MoveTo:create(1.0 / flySpeed, cc.p(position.x, position.y - flyOffset)) local flyAction = cc.RepeatForever:create(cc.Sequence:create(moveUp, moveDown)) flyAction:setTag(g_flyTag) return flyAction end local clickedButton = nil local function checkMenuButton(button, name, point) cclog("checkMenuButton : "..name) local buttonSize = getSpriteSize(name) local buttonX = button:getPositionX() local buttonY = button:getPositionY() if math.abs(point.x - buttonX) < buttonSize.width / 2 and math.abs(point.y - buttonY) < buttonSize.height / 2 then clickedButton = button return true end return false end -- listener local touchBeginPoint = nil function onCommonMenuLayerTouchBegan(touch, event) local location = touch:getLocation() cclog("onCommonMenuLayerTouchBegan: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = {x = location.x, y = location.y} if g_rateButton ~= nil then checkMenuButton(g_rateButton, "button_rate", touchBeginPoint) end if g_playButton ~= nil then checkMenuButton(g_playButton, "button_play", touchBeginPoint) end if g_rankButton ~= nil then checkMenuButton(g_rankButton, "button_score", touchBeginPoint) end if clickedButton ~= nil then clickedButton:setPosition(cc.p(clickedButton:getPositionX(), clickedButton:getPositionY() - 3)) end -- CCTOUCHBEGAN event must return true return true end function onCommonMenuLayerTouchEnded(touch, event) local location = touch:getLocation() cclog("onCommonMenuLayerTouchEnded: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = nil if clickedButton ~= nil then clickedButton:setPosition(cc.p(clickedButton:getPositionX(), clickedButton:getPositionY() + 3)) if clickedButton == g_rateButton then elseif clickedButton == g_playButton then local gameScene = nil if g_initFlag == nil then gameScene = require("scripts.GameScene") else gameScene = createGameScene() end local trans = cc.TransitionFade:create(0.5, gameScene, cc.c3b(0,0,0)) cc.Director:getInstance():replaceScene(trans) cc.SimpleAudioEngine:getInstance():playEffect(uiPath) elseif clickedButton == g_rankButton then showAds() end clickedButton = nil end end --size : 1.big 2.small --alignType : 1. mid 2. right function CreateSpriteScore(rootNode, score, size, alignType) local function createScoreDigit(digit) if size == 1 then return createAtlasSprite("font_0"..(48 + digit)) end return createAtlasSprite("number_score_0"..digit) end rootNode:removeAllChildren() local distance = 20 if size == 2 then distance = 15 end local digits = {} local tmpScore = score local dig = math.fmod(tmpScore, 10) digits[#digits + 1] = dig while math.floor(tmpScore / 10) ~= 0 do tmpScore = math.floor(tmpScore / 10) dig = math.fmod(tmpScore, 10) digits[#digits + 1] = dig end local nowOffset = (#digits - 1) * distance / 2 if alignType == 2 then nowOffset = 0 end for i=1, #digits do local digitSprite = createScoreDigit(digits[i]) digitSprite:setPosition(cc.p(nowOffset, 0)) rootNode:addChild(digitSprite) nowOffset = nowOffset - distance end end ================================================ FILE: cocos2d/.gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto # Custom for Visual Studio *.cs diff=csharp *.sln merge=union *.csproj merge=union *.vbproj merge=union *.fsproj merge=union *.dbproj merge=union # Standard to msysgit *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain *.dot diff=astextplain *.DOT diff=astextplain *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain ================================================ FILE: cocos2d/.gitignore ================================================ # Ignore thumbnails created by windows Thumbs.db # Ignore files build by Visual Studio *.obj *.exe *.pdb *.aps *.vcproj.*.user *.vspscc *_i.c *.i *.icf *_p.c *.ncb *.suo *.tlb *.tlh *.bak *.cache *.ilk *.log [Bb]in [Dd]ebug/ [Dd]ebug.win32/ *.sbr *.sdf obj/ [Rr]elease/ [Rr]elease.win32/ _ReSharper*/ [Tt]est[Rr]esult* ipch/ *.opensdf # Ignore files build by ndk and eclipse libs/ bin/ obj/ gen/ assets/ local.properties # Ignore files built by NaCl samples/Cpp/HelloCpp/proj.nacl/Resources/ samples/Cpp/TestCpp/proj.nacl/Resources/ samples/Cpp/TestCpp/proj.nacl/out/ samples/Cpp/SimpleGame/proj.nacl/Resources/ samples/Lua/HelloLua/proj.nacl/Resources/ samples/Lua/TestLua/proj.nacl/Resources/ # Ignore python compiled files *.pyc # Ignore files build by airplay and marmalade build_*_xcode/ build_*_vc10/ # Ignore files build by xcode *.mode*v* *.pbxuser *.xcbkptlist *.xcscheme *.xcworkspacedata *.xcuserstate *.xccheckout xcschememanagement.plist .DS_Store ._.* xcuserdata/ DerivedData/ # Ignore files built by AppCode .idea/ # Ignore files built by bada .Simulator-Debug/ .Target-Debug/ .Target-Release/ # Ignore files built by blackberry Simulator/ Device-Debug/ Device-Release/ # Ignore vim swaps *.swp *.swo # Ignore files created by create_project.py projects/ # Ignore config files in javascript bindings generator tools/tojs/user.cfg # ... userconf.ini generated if running from tools/tojs tools/tojs/userconf.ini tools/tolua/userconf.ini # ... userconf.ini generated if running from tools/jenkins_scripts/mac/android/ tools/jenkins_scripts/mac/android/userconf.ini # CTags tags # ignore files, created with make-all-linux-project script /lib /build/linux-build ================================================ FILE: cocos2d/.gitmodules ================================================ [submodule "tools/bindings-generator"] path = tools/bindings-generator url = git://github.com/cocos2d/bindings-generator.git [submodule "cocos/scripting/auto-generated"] path = cocos/scripting/auto-generated url = git://github.com/cocos2d-x/bindings-auto-generated.git [submodule "samples/Javascript/Shared"] path = samples/Javascript/Shared url = git://github.com/cocos2d/cocos2d-js-tests.git [submodule "tools/cocos2d-console"] path = tools/cocos2d-console url = git://github.com/cocos2d/cocos2d-console.git [submodule "plugin"] path = plugin url = https://github.com/cocos2d-x/plugin-x.git ================================================ FILE: cocos2d/.travis.yml ================================================ language: cpp env: matrix: - GEN_JSB=YES - PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++ - PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++ # Since switching to C++11 only the ARM version of the nactive client # port currently builds. TODO(sbc): Re-enable all architectures. # Disabled travis-ci build for native client port since it doesn't support std::thread, std::mutex. # - PLATFORM=nacl DEBUG=1 NACL_ARCH=arm - PLATFORM=android # - PLATFORM=emscripten DEBUG=1 global: - secure: |- cHXOjAda+t2tmBVuVAiQfvhDN+unToO6hX1rc3dJeGDOk4rlQnylJacjA7o/ enkWeHagbW2Ja4h7BxQz4h7dada8zEbIbEMK4VEHx6AWwQM+GIEqkJPv5g8k 4P20MLpX4XyUwm/16btpnqgXlyd8Q3Zjh3Vui/5/VzwPnxUQEho= - secure: |- U/JsyiSR9q+8wX1arfciy3BdbMQaKmgt48/9tiU7P2RQJ/FR2AHGq85sNGI/ ZUxN4JPLGALEvkFMo4NYyJDUcsdRHZX3vbp5xbSSRaBigqJIj3HDxtlPVf2m /W2GzcfNNX1ACO18hSWH0d2yFlF263ZmvudzQIfqTESfjGQBzwA= - secure: |- Wsngwo3jlZtvuPfr3RNhqrz/liNIhKYnlw4KYJO90gMQ9ZQKRTlMv2BMiPw/ 9lV+vgJQDRcFe7dKwtC86vk10EU7Ym2bhVmhMxi/AlmJXgavjmPVdizRT7rh X2Ry/Nb6hGRkH3WS0T3D/KG1+e7lP/TMB9bvo6/locLJ2A6Z1YI= script: - export CC=$CC_COMPILER - export CXX=$CXX_COMPILER - tools/travis-scripts/run-script.sh before_install: - tools/travis-scripts/before-install.sh # whitelist branches: only: - master - develop ================================================ FILE: cocos2d/AUTHORS ================================================ cocos2d-x authors & contributors (ordered by the join in time) Core Developers: Ricardo Quesada XiaoMing Zhang (Minggo) JianHua Chen (James) Zhe Wang (Walzer) Qingkui Hu (samuele3hu) Huabing Xu (dabingnn) Bo Yu (boyu0) Wenhai Lin(Dhilan007) 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 simpliplant Hardware keyboard support liuyq CCTextureAtlas::updateQuad modify for the memcpy hot spot. frranck adding norwegian language varlucian fix the bug that OnEnterTransitionDidFinish was called twice when a node is added in onEnter. carlomorgantinizynga CCLabelTTF supports for shadow and stroke Adding CCLabelTTF::createWithFontDefinition. New label support. James Gregory (j4m3z0r, Zynga) Maintainer of Emscripten port. Initial Emscripten port. Use browser font rendering instead of FreeType. Add destructor to CCGLBufferedNode. Asynchronous Image loading for Emscripten DarraghCoy Fix a potential crash SimpleAudioEngineOpenSL::playEffect Fix some bugs with Set class Add ccDrawSolidCircle Add Rect::unionWithRect Fix a memory leak in Set::removeAllObjects. silverscania Pass correct parameter to glPixelStorei when creating a texture FlagellumDei Center the window correctly on windows ggggamer fixed memory leak of preloadEffect on windows CodeSnooker Added Method to create a CCMenuItemToggle from a CCArray with a target selector wagaf-d Move ccpX functions to CCPoint methods and operators sergey-shambir Added CC_DISABLE_COPY macro Added __attribute__(__format__()) for CCLog and CCString Refactoring network extension and fixing unlikely memory leaks. Adding PUT/DELETE methods for CCHttpRequest. Adding project part for QtCreator. Implemented pitch, pan and gain. Using SDL backend instead of glfw for Linux. savdalion Added example for russian language in TestCpp Added const modifier for classes CCArray, CCObject Deprecated method fixes rodrigogolive Fix broke linux build kdejongh Fix for spaces at the beginning of wrapped lines on Android martell use tinyxml2 to replace libxml2 Added Mingw-crt Support without breaking VS SDK CMake support for windows. Added support for x64 target of windows. mchinen fix emulator issue for OpenGL ES 2.0 on Android Fix missing protocol method warning for iOS 6.0 addition DenizPiri use CCLOG to implement print() function in LUA nickveri nickkwalee added some missing function for setting integer shader uniforms in CCGLProgram biteforest fix cc scale9 sprite bug Jimmy Sambuo fix the bug that SimpleAudioEngine::playEffect() and playBackgroundMusic() play twice on linux DarraghCoy fix for loading custom fonts on iOS when referenced from a CCB file Fix CCUserDefault.cpp compiling on Android. Fixing CCFileUtils 'createXXXXWithContentsOfFile' path lookup issue. Add CCDirector::popToSceneStackLevel(int level). Fixing a bug that custom font can't be loaded correctly if using full path of filename on android. Waiter fix an error that OpenSLEngine can't load resources from SD card add CCRemoveSelf action Fixing a bug that CCLabelTTF setString crash on android. billy1380 make CCLens3d support concave effect. Adding 64bit target for Mac project. benjamesward add Portuguese and Arabic language support Fixed linebreaks on Mac OSX Victor K(fnz) fix memory leak of CCTextureCache::addImageAsync() on iOS tks2shimizu add CCFloat, CCDouble and CCBool Add append function for String class Adding String::componentsSeparatedByString function for splitting string. chenium fix a bug that CCRenderTexture can not work when coming to foreground on Android 9re(Taro Kobayashi) add Japanese language support mingulov improve the speed of accessing to files from apk sburavtsov fix for correct unscheduling and instance destruction of extensions/network/HttpClient.cpp wenbin wang add error handler when read image data using libjpeg add korean language support fix getDeviceModel bug in android CocosDenshion Horcruxes fix the bug that CCArray::createWithContentsOfFile() may not read file data on iOS Hu Kaiou contribute the new version of libcurl to support both armv7 & armv7s on iOS fix some memory leak ByungChoi modify linux makefiles to fix compiling errors edbartley update MSVS and MAC projects to use project-relative path CCControl* should not respond to touches if the control is not visible Some improvements for CCScrollView and CCTableView. Touch priority can't be set to the value specified by a call to CCMenu::setTouchPriority(int). CCTableView crashes if a CCTableViewDelegate is not provided. Fixing a bug that _realOpacity isn't assigned in CCLayerColor::initWithColor. CCScrollView TouchPriority Fix Add encrypted PVR.CCZ support to ZipUtils + Tests Fix for broken of ccArrayGetIndexOfObject after merging this commit(076f38c). Weeds (Andre Rudlaff) Used fontconfig to enhance font rendering on linux. Fixed a bug about missing horizontal alignment for Custom TTF fonts on linux. Fixed a bug that the truetype fonts from resource directory can't be found on linux. Fixed the size calculations for true type fonts (especially for italic fonts). Added a very simple greedy line break algorithmfor true type labels. Fixed font rendering crash for certain fonts on linux. Fixed potential crash in CCScheduler::removeHashElement. Fixed potential crash in CCSaxParser. Added kResolutionFixedHeight and kResolutionFixedWidth resolution policy. Use pthread mutex and condition variable instead of pthred semaphore to load image asynchronizely. Fixed crash in HttpClient request on 64Bit. Nat Weiss (iphonegamekit.com) author of Mac port add TMX polygon parsing Properly resets the tile's Y flipping XiaoLong Zhang (Chukong Inc) Mike McGary (Zynga) Di Wu (Zynga China) CCBReader and cpp reflection mechanic Angus Comrie contributes cocos2d-x port of CCControlExtension. Yannick Loriot author of CCControlExtension in cocos2d-iphone. Surith Thekkiam (folecr, Zynga) contribute for Android module building Simpler, correct handling of spritesheet sources for CCScale9Sprite. Clean up linked libraries for android. JavaScript debugger improved and bugfixed. Fix flags for debugger server socket. Fix flags for debugger server socket. When user has built with JS Debugger support ScriptingCore will handle necessary runtime changes. Nicolas Gramlich (nicolasgramlich, Zynga) fixed CCDirector to use CCLabelBMFont instead of CCLabelTTF added CCBReader (CCBI format) Added cleanup and reset methods to ScriptingCore. Fixed a bug in ScriptingCore::evalString not setting the outval. Updated .classpath of Android project to latest ADT 22 build tool compatibility. Rohan Kuruvilla (rohankuruvilla, Zynga) Improvements to JS Bindings. Synchronizing CCBReader to version 5. Adding OpenGL Bindings to Javascript. Fixing a bug that nested ccb-files are not positioned correctly. Fixing a bug that crash when loading valid project. Jianfeng Zou (NetDragon Inc) contributes CCListView and CCTextureWatcher. dducharme author of blackberry port ImperialPenguin Added TTF support for blackberry port. HuaXu Cai (Kongzhong Corporation) author of linux port ciaranj add a build file that correctly generates LuaCocos2d.cpp add a lua template add particle systems to lua bindings use ant to generate LuaCocos2d.cpp and lua projects Marat Yakupov (moadib) Adds ability of simulating android enter/resume background on win32 Adds ability of simulating android back/menu key on win32 Adds support for multiple background music sources to CocosDenshion for Blackberry Eli Yukelzon (reflog) add a helper method to draw filled polygons improvements to CCUserDefaults ZhuoShi Shun contribute the lua binding of CocosDenshion Jirka Fajfr Chris Calm authors of CCTexturePVR RuiXiang Zhou (NetDragon) XiDi Peng (NetDragon) AiYu Ye (NetDragon) authors of lua binding Max Aksenov author and maintainer of Airplay port Giovanni Zito Francis Styck authors of Marmalade port Mat Hopwood( Marmalade official engineer ) Marmalade support for gles20 branch Carlos Sessa implement the accelerometer module for Android port James Chen(dumganhar) author of Bada port Erawppa implement CCNotificationCenter YuLei Liao(dualface) contribute the factor of lua binding jreitman fix the bug of asynchronous loading resources for iOS Nat Weiss minor enhancements to the Cocos2D-X codebase and Android build scripts Qingyun Huang (greathqy) implement CCHttpRequest donaldalanmorrison fix some warnings and memory leaks Yinghui Peng(mustime) use OpenSL ES to play effects add TestLua sample Dongyang Cai(John-cdy) add automatically test tools Sergey Vikhirev(BorMor) Remove retina specific methods and logic. johnangel OpenGL framebuffer access violation fix. Enable Windows XP support in Visual Studio 2012 Update 1. Peter Farkas (fape) contributes Marmalade port for gles20 branch add Hungarian language support fixed compilation errors after adding support of webp image format. Tomoaki Shimizu (tks2shimizu) Adding randomObject to CCDictionary. Igor Zavorotkin (ivzave) Adding lua support for linux platform. Jozef Prídavok (jpridavok) Adding CCEditBox implementation for Mac OSX. tiantian20007 Fixing a crash for call runAnimation() in CCBAnimationManagerDelegate::completedAnimationSequenceNamed. Fixing a bug that CCControl's touch priority is not set correctly; m_nDefaultTouchPriority is never used. Fixing a syntax error for RENDER_IN_SUBPIXEL macro. Implement CCDictionary::writeToFile(). Fixing a bug that unused spriteframes also need to be removed when purgeCachedData. Adding a method to get duration of timeline for CCBAnimationManager class, it's easy for getting duration of animation in JSB. xyhl515 Fixed a bug that CCControlSwitch::setOn(isOn,false) doesn't work. Adds VS2012 Express template installing support. Fixing a logical error in CCDrawNode::drawPolygon. Fixing a bug that Jsb function getCPBody return type is not right. DarraghCoy Fix for unaligned memory access crash in CCBReader::readFloat(). Sergej Tatarincev (SevInf) Making ScriptingCore.cpp compiled fine with C++11 on iOS. Using shared NodeLoaderLibrary in CCBReader bindings. CCEditBox iOS enchantments/bugfixes. Support variable cell sizes in CCTableView. ThePickleMan Adding 'rotationIsDir' property to ParticleSystem. DrawNode supports to draw triangle, quad bezier, cubic bezier. Jianghua (jxhgzs) Adding an additional transform for CCNode. giginet Fix CCRepeat#create is recieved bad argument on Lua binding. neokim Adds 'setFont' and 'setAnchorPoint' to CCEditBox. Workaround for some problems due to UITextField of CCEditBoxImplIOS is attached as a view above OpenGL view. Sam Clegg (sbc100) Author of Native Client port. Refactor linux build system and fix many warnings. Fixing a bug where missing packages would cause the script to exit on linux. Adding 'make run' target for linux projects. Stripping newlines from log message and fixing linux library location. Fixing a bug that CCPhysicsSprite was overriding only some of the getPosition methods. Adding a macro USE_BOX2D to check whether to enable Box2D for linux and nacl port. Adding Travis build support for linux and NaCl. Logging assert messages to the console. Renaming CCScriptSupport::executeAssert to CCScriptSupport::handleAssert. Adding Native Client support for develop branch (cocos2d-x 3.0) and some warnings fixes. Cleanup travis build scripts. Refactoring emscripten building script. Peter Young (young40) 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. fixed a bug when button's parent is hided, the button still can responce to clicked event. Asad ur Rehman (AsadR) Adding CCNotificationCenter::removeAllObservers(CCObject *target). jedy Fix of CCNode.h's document with doxygen 1.8.3 can't be generated. whitegfx Implementation of kEditBoxInputFlagSensitive setting for CCEditBoxImplIOS. Zecken (gelldur) Fixing a profiling compilation error in CCParticleBatchNode. Fixing linking errors for TestCPP with libcurl on linux. Fixing a bug that crash was triggered if there is not `textureFileName`section in particle plist file. flamingo (flaming0) Null pointer check in order to prevent crashes. Updating spine-runtime to EsotericSoftware/spine-runtimes@5f90386. rtissera (Romain TISSERAND) Adding missing JNIEXPORT / JNICALL declarations. Fix iOS 4.3 JPEG loading issue. Yodesoft Improving font rendering performance for linux platform. Reducing function call in nativeInitBitmapDC to improve performance. Refactoring writable path to "/.config/" for linux platform. sjchao Fixing a display bug when a scrollView nested in another scrollView. Éloi Rivard (azmeuk) Linux OpenAL support. Added some guards to prevent Eclipse to compile twice the same class. Linux Eclipse projects updates Refactored emscripten-build.sh, it's no longer need to be edited to make emscripten work. Creation of CCDeprecated-ext.h Use of a single emscripten HTML template file. Added some guards in fileutils. Fixed a bug in emscripten file utils. Added emscripten keyboard support Clang support for Linux Multiple emscripten template support. Emscripten multiple resolutions support. Toplevel Makefile refactoring elmiro Correction of passed buffer size to readlink and verification of result return by readlink. harikrishnar (Hari Krishna) Wrong logic in CCArray::initWithObjects. Fixing a bug that button should not get respond if its parent is invisable. rogerzanoni Fixing a linking error that libpthread and libGL libraries need to be linked on linux. Fixing a compiling error of [-Werror=array-bounds] when compiling Box2dTestBed. zhanghaojie Fixing a bug that anchorPoint property of CCScale9Sprite doesn't work in CCBReader. MarkEHenderson (Mark Henderson) Fixing of variable initialization in SpriteBatchNode. akira-cn Adding response for back and menu keypad event for Android. lgb (Oleg) Fixing a compilation error for BlackBerry PlayBook. Comparing float number by using epsilon and absolute difference. jotel (Jaroslaw Lewandowski) Fixing a bug that wrong type of argument signature is used in setAccelerometerIntervalJNI function. Fix for broken of ccArrayGetIndexOfObject after merging this commit(076f38c). Explicitly initialising CCAcceleration structure. Add support to save/retrieve CCData into/from CCUserDefault. Text Shadows fix Solving 'black screen' on android. MarcelBloemendaal Adding secureTextEntry property to CCTextFieldTTF. brawsome Adding new macro CCB_MEMBERVARIABLEASSIGNER_GLUE_WEAK to CCBMemberVariableAssigner.h. Adding CCLOG before original path is returned in CCFileUtils::fullPathForFileName to aid in debugging. Optmization to ccArrayGetIndexOfObject. sunzhuoshi Adding support for javascript bytecode. Fixing bad js constant names. ptekchand (Pranav Tekchand) Supporting negative node scales for CCScrollView. coolengineer (Hojin Choi) Refactoring callback selector for HttpResponse. djh- Fixing a bug that displayed color of CCDrawNode is incorrect when VAO is disabled. acai (beingstudio) Fix of null pointer access in CCBAnimationManager::getRunningSequenceName. metalgit92 Adding const qualification to some CCNode's getters Clarinexus Fixing a bug that setColor and setOpacity of CCControlButton and CCScale9Sprite are broken. Xander84 Fixing a bug in CCBValue::getByteValue. smshuja Fixing a bug that pointQueryFirst returns invalid Shape when a shape is not found in JSB. Fixing a bug that New PivotJoint can't access 4 parameters like in html5 version. Fixing a bug that Pivotjoint constructor and pointQueryFirst in Space class will return false instead of invalid shape object. Carsten Sandtner (casarock) Adding XMLHttpRequest support for JSB. Lee, Jae-Hong (pyrasis) Maintainer of tizen port. localStorageGetItem crashes when column text is NULL. fix image bug on Android lumendes Updating spine-runtime to EsotericSoftware/spine-runtimes@5f90386. sunxiaoyu Refactoring CCEditBox to add UITextField only when keyboard was opened, remove it when keyboard was closed. edwardzhou (Edward Zhou) Correcting the type detecting order for Lua CCBProxy::getNodeTypeName. Casting variables to their own type, and print warning info if no corresponding lua callback function instead of crash. fix of WebSocket url parse error for 'ws://domain.com/websocket' pattern. Fixed a bug that Websocket doesn't support send/receive data which larger than 4096 bytes. musikov Fixing a bug that missing precision when getting strokeColor and fontFillColor hawkwood (Justin Hawkwood) Fixing a bug that EditBox doesn't show any text if it's initialized with text. wtyqm (zhang peng) Fixing a bug that ccbRootPath wasn't passed to sub ccb nodes. smilingpoplar (YangLe) Fixing a bug that CCScale9Sprite doesn't support rotated spriteframe in atlas. xxuejie Add namespace prefix to selector macros hannon235 (Chris) Fixing a bug that the submenu of ExtensionTest in TestCpp can't scroll. Implements a socket.io client extension and adds a test case. pktangyue Fixing a bug that CCScale9Sprite::setInsetLeft/XXX can't work for rotated sprite frame. Fixing a bug that Color and Opacity of Scale9Sprite will not be changed when it's added to NodeRGBA and run with FadeIn/Out actions. Adding *.xccheckout to gitignore. jllust Fixing a bug that CCLabelBMFont crashes in glDrawElements of CCTextureAtlas::drawNumberOfQuads sometimes. Sam Gross (colesbury) Ignoring formatting specifiers in JavaScript log messages. Make bindings-generator supports to bind std::function argument. James Munro (jdmunro) Added JSB support for ccpDistanceSQ. Rafael (rafaelx) A warning fix of AL_INVALID_NAME and AL_INVALID_OPERATION in SimpleAudioEngineOpenAL.cpp. metalbass Fixing an issue that sigslot::_connection_base# (from 0 to 8) don't have virtual destructors. thp Port Cocos2D-X to Qt 5 Nako Sung (nakosung) Fixing a bug that wrong logic when pass an empty std::vector to WebSocket::init. Exposing cc.RemoveSelf to JS. exposed AssetsManager to javascript and added multiple-assetsManager support dotsquid Fixed the crash caused by improper deletion of VBOs and VAO in ParticleSystemQuad. maciekczwa Fixing a bug that stroke color with channel color values other than 255 doesn't take effect on android. zcgit a potential bug fix in Layer::init. gkosciolek Fixing a bug that observers with the same target and name but different sender are the same observer in NotificationCenter. xbruce Fixing a bug that crash appears when extending cc.ScrollView in JS. Fixing a bug that cc.registerTargettedDelegate doesn't support pure js object as its target. elwinarens (Elwin Arens) Minor spelling changes in description of CCScene.h signmotion (Andrey Syrokomsky) Fixed some compiling-warnings (MSVC2012). michaelcontento [Android] use onWindowFocusChanged(bool) instead of onResume()/onPause() Prevent nullptr access in AssetsManager [Android] re-introduce Cocos2dxHelper.runOnGLThread(Runnable) [Android] added EGL_RENDERABLE_TYPE to OpenGL attributes Android: add xlargeScreens="true" to supports-screens Trigger onKeyReleased only after the key has been released. Makes Colors are now comparable and explicit convertible bmanGH Use gl caching functions in TexturePVR::createGLTexture() Configuration of VAO in runtime Add setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv mothed into GLProgram class metadao make create_project.py more pythonic and fix some typoes timothyqiu Project creator: use absolute path for json config files Documentation fixes A better way to locate project creator rablwupei Fixed a memory leak in ScriptingCore::runScript() Fixed a memory leak in Spine. Added support of passing array to cc.Sequence.create and cc.Spawn.create. Fixed a bug that sys.localStorage.getItem() does not support non-ascii string. Fixed a memory leak in XMLHttpRequest. Fixed a bug that wrong convention to jsval in cccolor4f_to_jsval and cccolor3b_to_jsval. Keita Obo (ktaobo) Avoid unnecessary object duplication for Scale9Sprite. jimmystar Fixed a bug that cc.Scheduler.schedule(target, func) without repeat argument couldn't repeat schedule forever on device. XiaoLongHan (kpkhxlgy0) Fixed a bug that outside of keyboard can't be responded to close keyboard when using EditBox. lettas A fix for multi-platform template. HoGarfield (garfield_ho) Fixed a bug that CCBReader can't play sequence automatically in JSB. Could not set next animation in CCBAnimationCompleted callback. Fixed missing to add JSAutoCompartment when invoking JS functions from C++. CCBReader: To set anchor point to 0,0 when created by loader lite3 Fixed a bug that Node's anchor point was changed after being added to ScrollView. superrad Clear NoSuchMethodError Exception when JniHelper fails to find methodID Nite Luo (darkdukey) Added Mouse Support For Desktop Platforms. ledyba Fixed a bug that EventListeners can't be removed sometimes. Fixed a bug that the data size has to be specified when parsing XML using TinyXML. Closed X display after getting DPI on Linux. Luis Parravicini (luisparravicini) Fixed typos in create_project.py. xhcnb Device::setAccelerometerEnabled needs to be invoked before adding ACC listener. Fixed a bug that it will get wrong custom properties when use different count custom properties in CocosBuilder. bopohaa Fixed a bug that Webp test crashes. lajos FontTest isn't rendered correctly with custom TTF font on Mac platform. hulefei Added gui namespace before SEL_TouchEvent. zhiqiangxu Fixed a logic error in ControlUtils::RectUnion. Fixed an issue that there is an useless conversion in ScrollView::onTouchBegan. yinkaile (2youyouo2) Maintainer of Armature Bone Animation. dmurtagh Fixed a bug that UserDefault::getDoubleForKey() doesn't pass default value to Java. seobyeongky Updates spine runtime. Fixed a potential bug in Data's copy constructor. luocker Fix a bug that string itself is also modified in `String::componentsSeparatedByString`. omersaeed Fix a bug that game will crash if connection breaks during download using AssetManager. SBKarr AngelCode binary file format support for LabelBMFont. zarelaky OpenAL context isn't destroyed correctly on mac and ios. kicktheken (Kenneth Chan) Fixed a bug that the setBlendFunc method of some classes wasn't exposed to LUA. andyque Fixed a bug that missing to check self assignment of Vector, Map, Value and String. Fixed a bug that move assignment operator doesn't clear previous content bug. Fixed the compile error of Map's getRandomObject. daltomi Fixed a typo in Director class. Removed an unnecessary boolean flag in CCFontAtlasCache.cpp. v1ctor ControlSlider supports to set selected thumb sprite. ControlButton supports to set scale ratio of touchdown state akof1314 TestCpp works by using CMake and mingw on Windows. Pisces000221 Corrected a few mistakes in the README file of project-creator. Corrected a mistake in README. hbbalfred Fixed a bug that crash if file doesn't exist when using FileUtils::getStringFromFile. liang8305 Use multiple processes according the number of cores to build android project pandamicro Exposed SAXParser to JS, it is used for parsing XML in JS. hanjukim Fixed a bug that color and opacity settings were not applied when invoking Label::alignText. Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, Designer of CCApplication/CCEGLView/platform structure. He's working together with 2dx core team but leading FishingJoy game Bin Zhang core-team member but put himself in FishingJoy game since 2012. RongHong Huang (flyingpaper) Author of cocos2d-xna and spent all his time on wp7. Cocos2d-x can not grow so fast without the active community. Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups! Special thanks to Ricardo Quesada for giving us lots of guidances & suggestions. ================================================ FILE: cocos2d/CHANGELOG ================================================ cocos2d-x-3.0beta2 Jan.24 2014 [All] [NEW] Full screen support for desktop platforms. [NEW] Adds performance test for EventDispatcher. [NEW] Adds performance test for Containers(Vector<>, Array, Map, Dictionary). [NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier. [NEW] Console: added the 'textures', 'fileutils dump' and 'config' commands [NEW] GLCache: glActiveTexture() is cached with GL::activeTexture(). All code MUST call the cached version in order to work correctly [NEW] Label: Uses a struct of TTF configuration for Label::createWithTTF to reduce parameters and make this interface more easily to use. [NEW] Label: Integrates LabelAtlas into new Label. [NEW] Node: Added `setGlobalZOrder()`. Useful to change the Node's render order. Node::setZOrder() -> Node::setLocalZOrder() [NEW] Renderer: Added BatchCommand. This command is not "batchable" with other commands, but improves performance in about 10% [FIX] event->stopPropagation can't work for EventListenerTouchAllAtOnce. [FIX] Uses unified `desktop/CCEGLView.h/cpp` for desktop platforms (windows, mac, linux). [FIX] Bindings-generator supports Windows again and remove dependency of LLVM since we only need binary(libclang.so/dll). [FIX] Removes unused files for MAC platform after using glfw3 to create opengl context. [FIX] Wrong arithmetic of child's position in ParallaxNode::addChild() [FIX] CocoStudio: TestColliderDetector in ArmatureTest can't work. [FIX] CocoStudio: The order of transform calculation in Skin::getNodeToWorldTransform() is incorrect. [FIX] Crash if file doesn't exist when using FileUtils::getStringFromFile. [FIX] If setting a shorter string than before while using LabelAtlas, the effect will be wrong. [FIX] Label: Memory leak in FontFreeType::createFontAtlas(). [FIX] Label: Crash when using unknown characters. [FIX] Label: Missing line breaks and wrong alignment. [FIX] Label: Corrupt looking characters and incorrect spacing between characters [FIX] Label: Label:color and opacity settings are invalid afeter these these properties changed: 1)text content changed 2)align style changed 3)max line width limited [FIX] Label: Crash when using unknown characters [FIX] Console: log(format, va_args) is private to prevent possible resolution errors [FIX] Configuration: dumpInfo() -> getInfo() [FIX] ControlSlider doesn't support to set selected thumb sprite. [FIX] ControlButton doesn't support to set scale ratio of touchdown state. [FIX] Particles: Crash was triggered if there is not `textureFileName`section in particle plist file. [FIX] Renderer: Uses a float as key with only the depth. Viewport, opaque are not needed now [FIX] Renderer Performance Fix: QuadCommand::init() does not copy the Quads, it only store a reference making the code faster [FIX] Renderer Performance Fix: Sprite and SpriteBatchNode (and subclasses) has much better performance [FIX] Renderer Performance Fix: When note using VAO, call glBufferData() instead of glBufferSubData(). [FIX] Renderer Performance Fix: Doesn't sort z=0 elements. It also uses sort() instead of stable_sort() for z!=0. [FIX] Sprite: removed _hasChildren optimization. It uses !_children.empty() now which is super fast as well [FIX] Tests: Sprites Performance Test has 4 new tests [FIX] TextureCache: getTextureForKey and removeTextureForKey work as expected [FIX] TextureCache: dumpCachedTextureInfo() -> getCachedTextureInfo() [FIX] Websocket doesn't support send/receive data which larger than 4096 bytes. [FIX] Object: Remove _retainCount [FIX] ParallaxNode: Coordinate of Sprite may be wrong after being added into ParallaxNode [FIX] Crash if there is not `textureFileName`section in particle plist file [FIX] Websocket cannot send/receive more than 4096 bytes data [FIX] TextureCache::addImageAsync can't load first image [FIX] ControlSlider: Can not set "selected thumb sprite" [FIX] ControlSlider: Can not set "scale ratio" [FIX] Crash when loading tga format image [FIX] Keyboard pressed events are being repeatedly fired before keyboard is released [Android] [FIX] Background music can't be resumed when back from foreground [FIX] ANR (Application Not Responding) appears on android 2.3 when pressing hardware button. [lua binding] [NEW] Can bind classes that have the same class names but different namesapces [FIX] Use EventDispatcher to update some test cases [FIX] sp.SkeletonAnimation:registerScriptHandler should not override cc.Node:registerScriptHandler [javascript binding] [NEW] Bind SAXParser [FIX] Pure JS class that wants to inherite from cc.Class will trigger an irrelevant log [FIX] Mac and iOS Simulator should also use SpiderMonkey which was built in RELEASE mode [FIX] Crash when running JSB projects on iOS device in DEBUG mode [FIX] Crash when Firefox connects to JSB application on Mac platform. [Desktop] [NEW] Support fullscreen [Linux] [FIX] "Testing empty labels" in LabelTest crashes. [Mac] [FIX] Removes unused files after using glfw3 to create opengl context [Win32] [FIX] Compiling error when using x64 target [FIX] Tests: TestCpp works with CMake [FIX] Bindings-generator supports Windows again and remove dependency of LLVM since it only needs binary of libclang cocos2d-x-3.0beta Jan.7 2014 [All] [NEW] New label: shadow, outline, glow support [NEW] AngelCode binary file format support for LabelBMFont [NEW] New spine runtime support [NEW] Add templated containers, such as `cocos2d::Map<>` and `cocos2d::Vector<>` [NEW] TextureCache::addImageAsync() uses std::function<> as call back [NEW] Namespace changed: network -> cocos2d::network, gui -> cocos2d::gui [NEW] Added more CocoStudioSceneTest samples. [NEW] Added UnitTest for Vector, Map, Value. [NEW] AngelCode binary file format support for LabelBMFont. [NEW] New renderer: Scene graph and Renderer are decoupled now. [NEW] Upgrated Box2D to 2.3.0 [NEW] SChedule::performFunctionInCocosThread() [NEW] Added tga format support again. [NEW] Adds UnitTest for Template container and Value class [FIX] A Logic error in ControlUtils::RectUnion. [FIX] Bug fixes for Armature, use Vector, Map instead of Array, Dictionary. [FIX] Used c++11 range loop(highest performance) instead of other types of loop. [FIX] Removed most hungarian notations. [FIX] Merged NodeRGBA to Node. [FIX] Potential hash collision fix. [FIX] Updates spine runtime to the latest version. [FIX] Uses `const std::string&` instead of `const char*`. [FIX] LabelBMFont string can't be shown integrally. [FIX] Deprecates FileUtils::getFileData, adds FileUtils::getStringFromFile/getDataFromFile. [FIX] GUI refactoring: Removes UI prefix, Widget is inherited from Node, uses new containers(Vector, Map). [FIX] String itself is also modified in `String::componentsSeparatedByString`. [FIX] Sprites with PhysicsBody move to a wrong position when game resume from background. [FIX] Crash if connection breaks during download using AssetManager. [FIX] OpenAL context isn't destroyed correctly on mac and ios. [FIX] Useless conversion in ScrollView::onTouchBegan. [FIX] Two memory leak fixes in EventDispatcher::removeEventListener(s). [FIX] CCTMXMap doesn't support TMX files reference external TSX files [FIX] Logical error in `CallFuncN::clone()` [FIX] Child's opacity will not be changed when its parent's cascadeOpacityEnabled was set to true and opacity was changed [FIX] Disallow copy and assign for Scene Graph + Actions objects [FIX] XMLHttpRequest receives wrong binary array [FIX] XMLHttpRequest.status needs to be assigned even when connection fails [FIX] TextureCache::addImageAsync may load a image even it is loaded in GL thread [FIX] EventCustom shouldn't use std::hash to generate unique ID, because the result is not unique [FIX] CC_USE_PHYSICS is actually impossible to turn it off [FIX] Crash if connection breaks during download using AssetManager [FIX] Project_creator supports creating project at any folder and supports UI [Android] [NEW] build/android-build.sh: add supporting to generate .apk file [NEW] Bindings-generator supports to bind 'unsigned long'. [FIX] XMLHttpRequest receives wrong binary array. [FIX] 'Test Frame Event' of TestJavascript/CocoStudioArmatureTest Crashes. [FIX] UserDefault::getDoubleForKey() doesn't pass default value to Java. [iOS] [FIX] Infinite loop in UserDefault's destructor [Windows] [NEW] CMake support for windows. [Bindings] [NEW] Support CocoStudio v1.2 [NEW] Adds spine JS binding support. [FIX] Don't bind override functions for JSB and LuaBining since they aren't needed at all. [FIX] The order of onEnter and onExit is wrong. [FIX] The setBlendFunc method of some classes wasn't exposed to LUA. [FIX] Bindings-generator doesn't support 'unsigned long' [FIX] Potential hash collision by using typeid(T).hash_code() in JSB and LuaBinding [Lua binding] [NEW] New label support [NEW] Physcis integrated support [NEW] EventDispatcher support [FIX] CallFuncND + auto remove lua test case have no effect [FIX] Lua gc will cause correcsponding c++ object been released [FIX] Some lua manual binding functions don't remove unneeded element in the lua stack [FIX] The setBlendFunc method of some classes wasn't exposed to LUA [Javascript binding] [FIX] `onEnter` event is triggered after children's `onEnter` event cocos2d-x-3.0alpha1 Nov.19 2013 [all platforms] [DOC] Added RELEASE_NOTES and CODING_STYLE.md files [FIX] Texture: use CCLOG to log when a texture is being decoded in software [FIX] Spine: fix memory leaks [FIX] fixed a memory leak in XMLHTTPRequest.cpp [FIX] removeSpriteFramesFromFile() crashes if file doesn't exist. [FIX] Avoid unnecessary object duplication for Scale9Sprite. [FIX] create_project.py does not rename/replace template projects completely. [FIX] Could not set next animation in CCBAnimationCompleted callback. [FIX] The Node's anchor point was changed after being added to ScrollView. [FIX] Refactored and improved EventDispatcher. [FIX] EventListeners can't be removed sometimes. [FIX] When parsing XML using TinyXML, the data size has to be specified. [FIX] Parameter type: const char* -> const string& [FIX] Armature: many bug fixed, add more samples, add function to skip some frames when playing animation [FIX] Configuration of VAO in runtime [FIX] Webp Test Crashes. [FIX] TransitionScenePageTurn: z fighting [FIX] AssetsManager: Adding test whether the file directory exists when uncompressing file entry,if does not exist then create directory [FIX] CCBReader: To set anchor point to 0,0 when loading Scale9Sprite [FIX] OpenGL Error 502 in Hole Demo [FIX] AssetsManager: downloading progress is not synchronized with actual download [FIX] SpriteFrameCache: memory leak when loading a plist file [FIX] removeSpriteFramesFromFile() crashes if file doesn't exist [FIX] EditBox: can't click the area that outside of keyboard to close keyboard [FIX] CCBReader: can not set next animation in AnimationCompleted callback [FIX] Node's anchor point was changed after being added to ScrollView [FIX] EventDispather: refactor method and fix some bugs [FIX] EventListner: cann't be removed sometimes [FIX] UserDefault: didn't set data size when parsing XML using TinyXML [FIX] Webp test crashed [FIX] CCHttpClient: The subthread of CCHttpClient interrupts main thread if timeout signal comes. [NEW] Arm64 support. [NEW] Added Mouse Support For Desktop Platforms. [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. [NEW] Sprite: Override setScale(float scaleX, float scaleY) [NEW] External: added | operator for Control::EventType [NEW] Android & iOS screen size change support [NEW] GLProgram: setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv [NEW] Color[3|4][B|F]: comparable and explicit convertible [NEW] Contorl::EventType add | operation [NEW] Performance Test: Sprite drawing [NEW] Adjusted folder structure [NEW] Added tools to simplify upgrading game codes from v2.x to v3.x [FIX] Added virtual destructors on Interfaces [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. [FIX] Clear NoSuchMethodError Exception when JniHelper fails to find method id [FIX] Fixed crash when backging from background [FIX] LabelTTF: crashed when setting dimension input height value less than the height of the font and the input width value is 0 [FIX] Changed data type of 'char' to signed as default [NEW] Added xlargeScreens="true" to supports-screens [NEW] Added build/android-build.py to build all Android samples, and remove all build_native.sh/cmd [NEW] Added build_native.py to build template projects, and remove build_native.sh/cmd [NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again [NEW] Added support for orientation changed [NEW] Disabled CDT Builder on Eclipse [Mac] [FIX] Removed unused CCLOG() from GL initialization [FIX] HttpClientTest: crash [iOS] [FIX] Can't click the area that outside of keyboard to close keyboard when using EditBox. [NEW] Added support for orientation changed [Linux] [NEW] Used CMake to build linux projects. [FIX] Closed X display after getting DPI on Linux. [Win32] [FIX] Last test case of OpenglTest crashed [Desktop] [FIX] Trigger onKeyReleased only after the key has been released. [NEW] Added mouse support [Javascript binding] [FIX] Fixed a memory leak in ScriptingCore::runScript() [FIX] sys.localStorage.getItem() does not support non-ascii string. [FIX] cc.Scheduler.schedule(target, func) without repeat argument couldn't repeat schedule forever on device. [FIX] CCBReader can't play sequence automatically in JSB. [FIX] Wrong convention to jsval in cccolor4f_to_jsval and cccolor3b_to_jsval [FIX] sys.localStorage: doesn't support non-ascii string [FIX] BuilderReader: can't play sequence automatically [FIX] Wrong conversion to javal in cccolor4f_to_jsval and cccolor3b_to_jsval [NEW] main.js -> cocos2d-jsb.js [NEW] Remote debugging using Firefox, "step into" can not work [NEW] Added binding for Node::setScale(float, float) [NEW] Impvoved armature binding [NEW] Added CocoStudio releated binding codes: gui, scene parser, and add corresponding samples [Lua Binding] [NEW] Added Armature lua binding and added test samples. [NEW] Added LuaObjectBridge & LuaJavaBridge to simplify invoking objective-c codes and java codes from lua [NEW] Added CocoStudio releated binding codes: gui, scene parser, and add corresponding samples [NEW] Added AssetsManager binding and corresponding sample [NEW] Added XMLHttpRequest lua binding and corresponding sample cocos2d-x-3.0alpha0 @Sep.19 2013 [all platforms] [FIX] TargetAction::reverse() works as expected [FIX] Fixed crash in OpenGLTest [FIX] Fixed logic when passing an empty std::vector to WebSocket::init() [FIX] Fixed crash in ParticleSystemQuad due to improper deletion of VBO and VAO [FIX] Point::isSegmentIntersect() returns correct value [FIX] Improved UTF8 response code in XmlHttpRequest [FIX] Observers with the same target and name but different sender are the same observer in NotificationCenter [NEW] Added ATITC format support [NEW] Better integration with physics engine [NEW] New Event Dispatcher: supports Keybaord, Touches, Accelerometer, Custom events. Added Tests as well [NEW] New Label code: Faster and more efficient than previous code [NEW] Added S3TC support [NEW] Added a method to get duration of timeline for CCBAnimationManager class [NEW] Array is compatible with STL containers. [3RD] Upgraded SpiderMonkey to Firefox v23 [Android] [FIX] Fixed When lock screen or entering background and resume the application textures from pvr.ccz file become black [FIX] Fixed Stroke font color [NEW] Uses Native Activity [iOS] [FIX] Status bar can be hidden on iOS 7 [FIX] Added iOS7 icons to templates and tests [Mac OS X] [NEW] iOS and Mac tempaltes were merged into one single Xcode project file. [NEW] Added Lua template [JavaScript bindings] [FIX] CCBReader is able to set properties to owner if 'owner var' is setted [FIX] Fixed crash when extending cc.ScrollView in JS [FIX] cc.registerTargettedDelegate supports pure js object as its target [FIX] Fixed memory leak in the binding glue code of cc.FileUtils.getStringFromFile(getByteArrayFromFile) [NEW] Added bindigns for Sprite::getDisplayFrame(), ControlButton callback and RemoveSelf [Lua bindings] [NEW] Bind Sprite::getDisplayFrame() cocos2d-x-3.0alpha0-pre @Jul.30 2013 [all platforms] [FIX] #2124: Image::initWithImageFileThreadSafe is not thread safe [FIX] #2230: Node::onEnterTransitionDidFinish was called twice when a node is added in Node::onEnter [FIX] #2237: calculation offset in font rendering [FIX] #2303: missing precision when getting strokeColor and fontFillColor [FIX] #2312: WebSocket can not parse url like "ws://domain.com/websocket" [FIX] #2327: implement Node::isScheduled [FIX] #2338: ccbRootPath is not passed to sub ccb nodes [FIX] #2346: OpenGL error 0x0502 in TextureAtlas::drawNumberOfQuads [FIX] #2359: Sprite will become white block when using ControlSwitch [FIX] #2361: some bug fixed of the Set class [FIX] #2366: text shadow [FIX] #2367: ClippingNode works differently on different platforms [FIX] #2370: Pivotjoint constructor and pointQueryFirst in Space class will return false instead of invalid shape object [FIX] #2381: ControlSwitch wasn't displayed correctly when adding more than one switch [FIX] #2384: The submenu of ExtensionTest in TestCpp can't scroll [FIX] #2386: ClippingNode works wrongly when being set as a child [FIX] #2396: Scale9Sprite::setInsetLeft/XXX can't work for rotated sprite frame [FIX] #2401: LabelBMFont crashes in glDrawElements of CCTextureAtlas::drawNumberOfQuads randombly [FIX] #2410: Black screen appears on android randomly [FIX] #2411: Opacity option for shadow in CCLabelTTF is not working [FIX] #2406: Color and Opacity of Scale9Sprite will not be changed when it's added to NodeRGBA and run with FadeIn/Out actions [FIX] #2415: Warning of AL_INVALID_NAME and AL_INVALID_OPERATION in SimpleAudioEngineOpenAL.cpp [FIX] #2418: Unused spriteframes also need to be removed when purgeCachedData [FIX] #2431: Potential crash when loading js files [FIX] #2229: Explicitly initialising CCAcceleration structure [FIX] #2234: Add destructor to CCGLBufferedNode [Feature] #2232: adding Norwegian language support [Feature] #2235: Ability to save/retrieve CCData into/from CCUserDefault [Feature] #2250: add support for std::function<> in CCMemuItem and CCCallFunc [Feature] #2273: Hardware keyboard support [Feature] #2278: Adds CALLBACK_0, CALLBACK_1 and CALLBACK_2 macros for MenuItems [Feature] #2279: Updates chipmunk2d to v6.1.5 [Feature] #2283: Adds Polish language support [Feature] #2289: Uses clone() pattern for actions [Feature] #2332: Adding project for QtCreator [Feature] #2364: Adds DrawPrimitives::DrawSolidCircle [Feature] #2365: Adds Rect::unionWithRect [Feature] #2385: Implemented pitch, pan and gain for SimpleAudioEngine [Feature] #2389: Adding cookie support for HttpClient [Feature] #2392: Adds append() function for String class [Feature] #2395: Adds Scale9SpriteTest for TestCpp [Feature] #2399: Adds SocketIO support [Feature] #2408: Adds String::componentsSeparatedByString function for splitting string [Feature] #2414: Bindings-generator could bind std::function<> argument [Refactor] #2129: Removes Hungarian notation from ivars. Removes CC and cc prefixes from name classes and free functions. [Refactor] #2242: Enables c++11 [Refactor] #2300: Using clone() pattern instead of 'copyWithZone' pattern [Refactor] #2305: Use std::thread instead of pthread [Refactor] #2328: ETC support for all platforms [Refactor] #2373: Change some member functions to const [Refactor] #2378: Remove the usage of CC_PROPERTY_XXX in engine code [Refactor] #2388: Creating a default texture for CCSprite if setTexture(nullptr) is invoked [Refactor] #2397: Singleton refactor, sharedXXX --> getInstance, purgeXXX --> destroyInstance [Refactor] #2404: Move all deprecated global functions and variables into CCDeprecated.h [Refactor] #2430: Uses strongly typed enums (enum class) instead of simple enums [iOS] [FIX] #2274: compile and run for iOS7 and Xcode5 [Refactor] #2371: use one single Xcode project for iOS and Mac projects [Android] [FIX] #2306: CCLabelTTF::setString crash [Refactor] #2329: use Android "asset manager" to improve file system read performance [Refactor] #2400: use onWindowFocusChanged(bool) instead of onResume()/onPause() [OS X] [FIX] #2275: LabelTTF vertical alignment [FIX] #2398: Add support for initializing Image with raw data [windows] [FIX] #2322: link error becasue of using multiply inheritance [JavaScript bindings] [FIX] #2307: PhysicsSprite::getCPBody return wrong type [FIX] #2313: bind cc.ClippingNode [FIX] #2315: iterating through cc.Node children crash [Feature] #2285: bind MontionStreak [Feature] #2340: Updates SpiderMonekey to Firefox v22 (JS Bindings) [Feature] #2427: bind FileUtils.getInstance().createDictionaryWithContentsOfFile [Lua bindings] [Feature] #2276: Add CCScrollView Lua binding and corresponding test sample [Feature] #2277: Add OpenGL Lua binding and corresponding test sample [Feature] #2324: Add OpenGL Lua module [Feature] #2343: Redesign the mechanism of invoking Lua func from c++ [Feature] #2344: make some execute functions into one function in ScriptEngineProtocol [Feature] #2426: Add DrawPrimitives test sample [Feature] #2429: LuaWebSocket supports sending binary string [plugin-x] [FIX] #2348: event will not be sent to server when paramMap argument of logEvent function is nil [Emscript] [Feature] #2289: Asynchronous Image loading 2.1rc0-x-2.1.4 @Jnue.12 2013 [all platforms] Bug #2098: fix TouchPriority issue of CCScrollView Bug #2107: fix crash in HttpClient request on 64Bit Bug #2115: fix linking errors for TestCPP with libcurl Bug #2128: remove setting ignoreAnchorPoint for child CCB files and fix crash while trying to load sprite frame when the file is missing Bug #2140: fix a bug that the displayed color of CCDrawNode is incorrect when VAO is disabled Bug #2142: adding CCDataVisitor and implementing CCPrettyPrinter Bug #2143: fix a crash caused by ScrollView.setDelegate(tmp function) Bug #2146: unpack texture data correctly Bug #2147: fix null pointer access in CCBAnimationManager::getRunningSequenceName() Bug #2150: fix a bug that setColor and setOpacity of CCControlButton and CCScale9Sprite are broken Bug #2251: fix a logical error in CCDrawNode::drawPolygon() Bug #2271: fix memory leak as possible Feature #1859: make AssetsManager download resources in a new thread Feature #2086: make CCLabelTTF supports shadows and stroke Feature #2100: add CCDirector::popToSceneStackLevel(int level) Feature #2105: add Travis build support Feature #2108: add example for russian language in TestCpp Feature #2111: add CC_DISABLE_COPY macro Feature #2114: add __attribute__(__format__()) for CCLog and CCString Feature #2116: support negative node scales for CCScrollView Feature #2117: implement CCDictionary::writeToFile() Feature #2122: add method to create a CCMenuItemToggle from a CCArray with a target selector Feature #2132: add encrypted PVR.CCZ support to ZipUtils + Tests Feature #2157: add Mingw-crt Support without breaking VS SDK Feature #2265: add CCLabelTTF::createWithFontDefinition() Feature #2270: add Armature(CocoStudio runtime) support Refactor #2109: add const modifier for classes CCArray, CCObject Refactor #2118: move ccpX functions to CCPoint methods and operators Refactor #2119: use httpresponse_selector instead of callfuncND_selector for the callback function of CCHttpRequest Refactor #2123: refactor network extension, fixing unlikely memory leaks, adding PUT/DELETE methods Refactor #2127: add CCLOG before original path is returned in CCFileUtils::fullPathForFileName to aid in debugging Refactor #2149: add const qualification to some CCNode's getters Refactor #2189: CCLabelTTF::enableShadow() const update Refactor #2215: refactor CCConfiguration Refactor #2217: use CCLabelAtlas instead of CCLabelTTF to show FPS Refactor #2231: implement a format of CCConfiguration Refactor #2233: add support for "CCString" types for boolean and integers in CCConfiguration Refactor #2236: fix memory hot spot of CCTextureAtlas::updateQuad() [android] Bug #1284: fix a bug that SimpleAudioEngine may cause crash on i9100 Bug #2151: fix custom font loading on Android for resource mapped font files Bug #2190: updat .classpath of Android project to latest ADT 22 build tool compatibility Bug #2266: fix a bug that CCFileUtils::getFileData() may not get file data correctly on Android Feature #2161: add ETC1 image format [iOS] Bug #2102: fix missing protocol method warning for iOS 6.0 addition Bug #2104: fix a bug that JPEG picture not displayed correctly on iOS 4.3 Bug #2260: fix a bug that CCDirectory::createWithContentsOfFile() returns a valid pointer though the file is missing on iOS Refactor #2101: update cocos2dx Xcode project to detect more warnings Refactor #2253: add UITextField only when keyboard was opened, removing it when keyboard was closed [mac] Bug #2249: fix linebreaks on Mac OSX [win32] Bug #2131: fix memory leak of SimpleAudioEngine::preloadEffect() Bug #2145: center the window correctly on windows [emscripten] Feature #2120: compile c++ to js Bug #2159: use browser font rendering instead of FreeType Refactor #2133: compile for Emscripten in asm.js mode Document #2121: write a document to describe the usage of emscriptenate port [tizen] Feature #2185: add support for Tizen [JavaScript bindings] Bug #2099: fix a bug in ScriptingCore::evalString() not setting the outval Bug #2179: fix a bug that pointQueryFirst returns invalid Shape when a shape is not found Bug #2186: fix a bug that new PivotJoint can't access 4 parameters like in html5 version Bug #2187: JavaScript debugger improved and bug fixed Bug #2243: fix a bug that XMLHttpRequest dones't support non-ascii characters Bug #2244: fix a bug that cc.Camera.getEyeXYZ, cc.Camera.getCenterXYZ, cc.Camera.getUpXYZ return bad values Feature #1647: Bind websocket to JavaScript Feature #2092: add XMLHttpRequest and bind it to JSB Feature #2106: add support for JavaScript byte code Feature #2162: add command line tool for generating JavaScript bytecode Feature #2214: upgrade Spidermonkey to Firefox v21 Refactor #2152: log assert messages to the console and renaming CCScriptSupport::executeAssert to CCScriptSupport::handleAssert Refactor #2247: use functions instead of macros to speeding up building for JSB project [Lua bindings] Feature #2103: implement most test cases cocos2d-2.1rc0-x-2.1.3 @May.01 2013 [all platforms] Bug #1853: use SHELLOPTS instead of "-o igncr" for Android Eclipse project Bug #1860: fix a bug that onNodeLoaded will be called twice if ccb was added as a CCBFile Bug #1862: fix a bug that CCScrollView::setContainer may cause dangling pointer when NULL is passed into Bug #1876: fix a bug that CCScale9Sprite::setColor() & setOpacity() are broken Bug #1935: fix a bug that use "==" for float comparison of CCPoint and CCSize Bug #1937: fix a bug that CCControl's touch priority is not set correctly, m_nDefaultTouchPriority is never used Bug #1943: added some missing function for setting integer shader uniforms in CCGLProgram Bug #1999: allowing to set fontName and fontSize separately for CCEditBox Bug #2003: fix a potential crash in CCScheduler::removeHashElement() Bug #2030: fix a bug that scissor rectangle in nested CCScrollView is wrong Bug #2031: make CCFileUtils::createXXXXWithContentsOfFile() support relative path Bug #2035: fix a potential crash in CCSaxParser Bug #2037: fix a wrong logic in CCArray::initWithObjects() Bug #2040: get scale property from sub-ccb node may trigger an assert Bug #2054: fix a bug that anchorPoint property of CCScale9Sprite doesn't work in CCBReader Bug #2055: enable easy switching between Box2D and chipmunk Bug #2058: properly resets the tile's Y flipping Bug #2061: fix a bug that wrong type of argument signature is used in setAccelerometerIntervalJNI function Bug #2073: fix a memory leak in CCUserDefault Bug #2080: fix a bug that _realOpacity isn't assigned in CCLayerColor::initWithColor Feature #2001: add CCRemoveSelf Action Feature #2048: support variable cell sizes in CCTableView Feature #2065: adding kResolutionFixedHeight and kResolutionFixedWidth resolution policy Feature #2068: adding a secureTextEntry property to CCTextFieldTTF Feature #2069: adding new macro CCB_MEMBERVARIABLEASSIGNER_GLUE_WEAK to CCBMemberVariableAssigner.h Feature #2075: support spine editor Feature #2076: adding a method CCBReader::setResolutionScale for setting resolution scale manually Refactor #1592: updating UTHASH to v1.9.8 Refactor #2042: remove libxml2 Refactor #2097: use pthread mutex and condition variable instead of pthread semaphore to load image asynchronizely [android] Bug #1996: adding missing JNIEXPORT / JNICALL declarations Bug #2028: fix a bug taht application can not run correctly on Android simulator Bug #2045: some small fixes to CocosPlayer Bug #2062: fix for spaces at the beginning of wrapped lines Bug #2083: fix a bug that Bytecode of LuaJIT can't work on android Refactor #1613: not reload resources when coming from background on Android Refactor #1861: CocosPlayer Android update Refactor #1904: strip libcurl.a on x86 architecture Refactor #2027: reduce function call in nativeInitBitmapDC to improve performance Refactor #2047: clean up linked libraries for android [iOS] Bug #1863: fix a bug that CCUserDefault on iOS may not save immediately Feature #2096: adding Cocosplayer for iOS and bug fixes [linux] Bug #1932: fix a bug that font rendering crashed for certain fonts Bug #2036: correct passed buffer size to readlink Bug #2044: link libpthread and libGL Bug #2046: strip newlines from log message and fixing linux library location Bug #2052: fix a bug that [-Werror=array-bounds] error appears when compiling Box2dTestBed Feature #2032: Linux OpenAL support Refactor #2000: improve font rendering performance for linux platform Refactor #2053: set writable path to "/.config/" [mac] Bug #2051: fix a bug that TestCpp/ExtensionsTest/CocosbuilderTest crashes under x86_64 target Feature #1856: adding 64bit target for Mac project [JavaScript bindings] Bug #1855: fix a bug that std_string_to_jsval generates messy js string when passed a non-ascii UTF8 std::string Bug #2057: adding response for back and menu keypad event for Android Bug #2059: fix a bug that cc.FileUtils.getInstance().getStringFromFile(filename) doesn't return a whole string Bug #2071: fix a bug that cc.TMXLayer.getTiles() can't work Feature #1841: find a way to obfuscate JavaScript code on the top of JSB Feature #1936: adding OpenGL Bindings to Javascript Feature #2043: upgrading SpiderMonkey to Firefox20.0 Feature #2060: support for cc.FileUtils.getInstance().getByteArrayFromFile(filename) Feature #2064: exposing cc.Node.nodeTo***Transform to JS Refactor #1944: subclass of cc.Sprite,cc.Layer... doesn't need cc.associateWithNative anymore [Lua bindings] Feature #1814: add menutest Feature #1941: add TileMapTest Feature #1942: add LayerTest Feature #1945: use CCLOG to implement print() function Feature #1993: add ParallaxTest Feature #1994: add ActionManagerTest Feature #1997: add IntervalTest Feature #1998: add SceneTest Feature #2002: add Texture2dTest, RenderTexture, ZwoptexTest, FontTest, CocosDenshionTest and EffectsAdvancedTest Feature #2004: add UserDefaultTest Feature #2005: add CurrentLanguageTest Refactor #1847: use luajit Refactor #2084: unify the method of loading Lua files on all platforms cocos2d-2.1rc0-x-2.1.2 @Mar.20 2013 [all platforms] Bug #1529: use NSUserDefaults on iOS and SharedPreferences on Android implement CCUserDefault Bug #1672: fix a bug that CCTableView is too sensitive on some devices with high density display Bug #1689: support horizontal alignment for Custom TTF fonts Bug #1691: fix a bug that CCControlSwitch::setOn(isOn,false) doesn't work Bug #1692: add TMX polygon parsing Bug #1697: fix a logical error in CCRenderTexture::initWithWidthAndHeight() Bug #1710: add simpler,correct handling of spritesheet sources for CCScale9Sprite Bug #1711: fix a bug that clipping rectangle of CCScrollView is wrong when the scale of its ancestors isn't equal to 1 Bug #1731: change declaration of CCSize, CCPoint and CCRect in pkg file Bug #1751: fix a bug that clicking outside of CCTableViewCell will also get response when container size is smaller than view size Bug #1754: fix a bug that offset of the container is wrong in CCTableView Bug #1821: fix a bug that the display result is wrong when invoking CCControlButton::setHighlighted() Feature #1686: synchronize to cocos2d-iphone v2.1rc0 Feature #1708: adding Portuguese and Arabic language support Feature #1712: add an interface to get DPI Feature #1741: CCLens3d can be concave Feature #1742: add 'rotationIsDir' property to ParticleSystem Feature #1761: implement setVisible() for CCEditBox Feature #1807: add getStartLocationInView() and getStartLocation() methods in CCTouch Feature #1822: add CCNotificationCenter::removeAllObservers(CCObject *target) Feature #1838: synchronize CCBReader to the lastest version Feature #1489: add AssetsManager Refactor #1687: refactor CCFileUtils and CCImage Refactor #1700: add webp image format support Refactor #1702: change return value of CCFileUtils::getWritablePath() Refactor #1703: replace libxml2 with tinyxml2 Refactor #1749: add 'setFont' and 'setAnchorPoint' to CCEditBox [android] Bug #1752: fix a bug that libcurl.a causes link error after being stripped Bug #1760: fix a bug that cpufeatures module is redefined Bug #1775: fix a bug that OpenSLEngine can not load resources from SD card Bug #1812: fix a warning of getStringWithEllipsisJni() function when compiling it with clang Feature #1827: support building android project, including native codes, in Eclipse [iOS] Bug #1750: fix a bug that CCEditBox's position is incorrect when it's added to a non-fullscreen CCNode Bug #1804: fix for loading custom fonts on iOS when referenced from a CCB file Feature #1842: support kEditBoxInputFlagSensitive setting for CCEditBox on iOS Refactor #1755: add CocosDenshion xcode project Refactor #1825: use CCLabelTTF to show text for CCEditBox [JavaScript bindings] Bug #1707: fix a crash caused by unaligned memory access in CCBReader::readFloat() Bug #1726: fix crash of JSB application on android device with armv6 architecture Bug #1729: fix compiling error of ScriptingCore.cpp with C++11 on iOS Bug #1747: fix a crash when passing null to cc.AnimationFrame.initWithSpriteFrame() Bug #1823: use shared NodeLoaderLibrary in CCBReader bindings Feature #1724: add HelloJS sample Feature #1730: bind CCScrollView and CCTableView to js Feature #1748: separate chipmunk and sqlite from js_binding_core.cpp Feature #1753: upgrade SpiderMonkey to Firefox19. Feature #1808: make cxx_generator support parsing functions that have default parameters Feature #1811: add a method to get file data for JSB Feature #1824: bind CCEditBox to JS Refactor #1682: add ScriptingCore::getGlobalObject() function Refactor #1740: add cleanup and reset methods to ScriptingCore Refactor #1830: use JS::CompileOptions::setUTF8(true) to compile script Refactor #1836: make js target of "cc.Scheduler().scheduleCallbackForTarget()" accept a object that not depend on CCNode or its subclass Refactor #1837: refactor schedule binding codes [Lua bindings] Bug #1745: fix a bug that CCRepeat:create() receives error argument Feature #1425: fix errors in Lua test cases and add more test cases Feature #1698: add CCLuaObjcBridge Feature #1802: add TouchesTest for Lua binding Refactor #1818: cleanup the tolua++ bindings build system [win32] Feature #1634: CCEditBox support Feature #1746: add VS2012 Express template installing support [linux] Bug #1688: fix a bug that truetype fonts from resource directory can't be found Bug #1810: fix a bug that SimpleAudioEngine::playEffect() and playBackgroundMusic() play twice on linux Bug #1819: fix a bug that building script exits when missing packages Bug #1834: fix the size calculations for true type fonts (especially for italic fonts) Refactor #1806: refactor linux build system Refactor #1820: add 'make run' target for linux projects [mac os] Bug #1637: fix a bug that CCLabelTTF & CCMenuItemLabel cannot display on Mac Retina [black berry] Refactor #1709: add support for multiple background music sources [chrome native client] Feature #1762: add Native Client support cocos2d-2.1beta3-x-2.1.1 @Jan.29 2013 [ all platforms] Bug #1547: fix a bug that when CCMenuItem is removed before touch ended, application will crash if keeping moving Bug #1553: fix a memory leak in CCControllButton Bug #1604: fix a bug that the enum values in ccPVR3TexturePixelFormat are truncated to 32bit Bug #1605: fix a crash that when adding just one action to CCSequence Bug #1639: fix a bug that CCBReader miss parsing some properties Bug #1659: fix a bug that invoking runAnimation() in CCBAnimationManagerDelegate::completedAnimationSequenceNamed will cause crash Bug #1662: fix a bug that returns wrong full path if texture name in the plist doesn't contain relative path Bug #1664: fix a logical error in CCAtlasNode::setOpacityModifyRGB Bug #1670: fix a memory leak in CCBReader Bug #1674: fix a logical error in CCScale9Sprite constructor Bug #1680: fix a bug that can't set touch priority by invoking CCMenu::setTouchPriority() Bug #1681: fix a bug that CCTableView crashes if CCTableViewDelegate is not provided Feature #1598: add japanese language support Feature #1625: add stackable action support and exchange the order of parameters for 3d relative actions Feature #1667: add file name lookup support Refactor #1593: remove all deprecated methods Refactor #1599: do some improvements of CCScrollView and CCTableView Refactor #1602: add randomObject to CCDictionary Refactor #1603: adjust samples directory structure Refactor #1606: return CCSequence pointer for CCSequence::create Refactor #1648: make CCPoint, CCRect and CCSize not inherit from CCObject Refactor #1649: change return type to const reference for member variable accessing Refactor #1654: report function and line number for CCAssert Refactor #1683: refactor CCFileUtils to make it be compatible with the resource searching strategy of cocos2d-iphone Document #1650: add detailed comments for CCDictionary Document #1678: add detailed doxygen comments for CCNode [android] Bug #1544: fix a bug that CCRenderTexture works wrong after coming back to foreground Bug #1580: fix a bug that application may lost focus after popping up keyboard Bug #1607: fix a bug that the path CCUserDefault saves in may cause issue Bug #1610: fix a bug that CCLabelTTF will lost a character at the end of a line Bug #1623: fix a bug that SimpleAudioEngine::playBackgroundMusic() may not take effect Bug #1679: upload unstripped prebuilt libraries for armeabi-v7a architectures Refactor #1673: add to AndroidManifest.xml [iOS] Bug #1600: fix a bug that application created by xCode template will crash after coming to foreground Bug #1612: fix some compilation errors when using c++11 compiler Bug #1657: fix a memory leak in CCTextureCache::addImageAsync() Refactor #1636: refactor CCEditBox [win32] Refactor #1627: add VS version check in project file [marmalade] Bug #1631: make SimpleGame force landscape Refactor #1629: add marmalade third party cleanup Refactor #1630: add TestLua post-build script Refactor #1632: remove grskia dependency and add in freetype support to the builds. [linux] Feature #1611: add Lua support Refactor #1621: add linux 64bit target for eclipse project Refactor #1676: refactor makefile and eclipse project configuration [JavaScript bindings] Bug #1550: fix some memory leaks in JSBinding Bug #1614: fix a crash caused by DrawNodeTest Bug #1622: fix a crash when cc.Node.getChildren is invoked if it has no children Bug #1641: fix a bug that the coins in WatermelonWithMe don't animate Bug #1644: fix a crash caused by passing NULL parameter to ccdictionary_to_jsval Bug #1645: fix a bug that JS Project created by xXode template doesn't work correctly Bug #1653: handle correctly when parsing int value in JSB Feature #1620: add sys.localStorage support for JSB Feature #1642: add tools for generating js-binding codes on windows Feature #1646: update SpiderMonkey to v18.0 Feature #1660: add js-debugger for js-binding Feature #1661: add jsb sample game CrystalCraze Refactor #1530: do some improvements to JS Bindings Refactor #1633: implement sys.capabilities for JSB [Lua bindings] Refactor #1608: add CCNode::scheduleUpdateWithPriorityLua() for LuaBinding Refactor #1626: add CCDirector::setDisplayStats() for luabinding cocos2d-2.1beta3-x-2.1.0 @Dec.5 2012 [all platforms] Bug #1556: set a default texture for CCParticleFire, CCParticleFireworks, etc Feature #1555: update to cocos2d-iphone v2.1 beta3 Feature #1564: update tests to cocos2d-iphone v2.1beta3 Feature #1572: add sample game WatermelonWithMe Feature #1573: add sample game CocosDragonJS Refactor #1545: remove the usage of NODE_FUNC and CREATE_FUNC Refactor #1565: remove VS2008 support Refactor #1576: update CCBReader to latest version of CocosBuilder Refactor #1589: add CCBReader::setCCBRootPath() [iOS] Bug #1548: update libcurl header files to 7.26.0 on iOS [android] Bug #1551: add error handler when reading image data using libjpeg Refactor #1558: improve the speed of accessing to files from apk [marmalade] Bug #1559: fix a bug that if a file in resource directory doesn't exist, it will not search from root directory Bug #1571: add box2d rope to marmalade project Bug #1590: JPEG and File fixes for marmalade Feature #1557: Marmalade support Refactor #1574: update marmalade languages Refactor #1575: update samples/TestCpp to compatible with marmalade Refactor #1578: create cocos2dx-ext marmalade project Refactor #1591: add TestLua marmalade project [JavaScript bindings] Bug #1577: fix a bug that touch events lost on Win32 when using JSBinding Bug #1586: fix a crash in WatermelonWithMe Bug #1588: rescheduleCallback support for JSBinding Refactor #1570: improve the debugger for JSBinding [Lua bindings] Bug #1587: remove Lua script handler in CCCallFunc's destructor cocos2d-2.0-x-2.0.4 @Nov.2 2012 [all platforms] Bug #1473: fix a bug that CCScale9Sprite does not support rotated spriteframe in atlas Bug #1494: fix a bug that missing removing auto-release object from AutoReleasePool if it invokes 'autorelease' method more than one time Bug #1495: fix a bug that CCScrollView display area and touch area are wrong if its parent's postion isn't at CCPointZero in world Bug #1508: fix a bug that potential observer array modification while it's traversed in CCNotificationCenter Bug #1510: fix a bug that application will freeze when 'numberOfCellsInTableView' returns zero Bug #1516: fix a bug that the font size of labels for displaying FPS,SPF,DrawCount is incorrect in different design resolutions Bug #1536: CCControl* should not respond to touches if the control is not visible Bug #1538: fix a logic error in CCControlHuePicker::checkSliderPosition() Bug #1543: fix a bug that CCLayerGradient background of CocosBuilderTest can't be shown Feature #1515: add a zoom function for debugging large resolution (e.g.new ipad) app on desktop Refactor #1312: upgrade libcurl to 7.26.0 Refactor #1486: apply multi-resolution mechanic on iOS, especially for iphone5 Refactor #1520: add comments to describe the usage of multiresolution in HelloCpp Refactor #1521: use relative coordinates in TestCpp Document #1532: write a document describes how to debug games for ipad3 on low-resolution PC Document #1493: add doxygen comments in CCNotificationCenter.h [android] Bug #1466: reload shader for test case "ShaderTest" after it comes from background Bug #1500: fix a bug that CCRenderTexture cannot render properly on some Qualcomm Adreno GPUs Bug #1507: fix a bug that can not play effect for the first time without pre-load effect [iOS] Bug #1527: fix a bug that MoonWarriors can not run on iOS simulator sometimes Refactor #1491: remove dependency of FontLabel lib [JavaScript bindings] Bug #1526: fix a bug that JavaScript binding related samples will crash on iOS devices Feature #1469: add MoonWarriors as a sample game Refactor #1487: use shared JavaScript test cases with cocos2d-html5 and cocos2d-iphone Refactor #1517: upgrade SpiderMonkey to FF 17.0 beta3 [Lua bindings] Bug #1506: fix a compilation error of TestLua if the path of cocos2d-x contains spaces [win32] Bug #1496: fix an error of comparing font's face name in CCImage of win32 port Bug #1511: fix openGL framebuffer access violation Bug #1540: fix win32 CCLuaLog memory leaks and invalid console UTF8 output Feature #1513: add Multi-Touch support for win7/8 tablet or ultrabook Refactor #1512: change writable directory to "C:\Documents and Settings\username\Local Settings\Application Data\your app name" if the app be built in release mode cocos2d-2.0-x-2.0.3 @Sep.26 2012 [all platforms] Bug #1452: change CCRGBAProtocol to public in order for actions like CCTintTo to have an affect on the CCScale9Sprite Bug #1454: make JavaScript binding work together with Lua binding and c++ codes Bug #1464: fix a crash caused by CCLabelBMFont Bug #1478: fix a bug that TMX parser causes tileset images not to be loaded Bug #1479: fix a bug that CCNotificationCenter does not check whether the object is valid before post notification Bug #1485: fix potential memory leak in CCNotificationObserver Feature #1458: add CCTableView Feature #1460: min/max allowed value for CCControlSlider Feature #1470: update CCBReader to cocosbuilder v2.1 beta Feature #1483: synchronize CCControlExtension to newest version Refactor #1477: abstracts Lua and JS binding protocol, some bugs fixes in lua-binding, adding custom menu on win32 and mac for switching resolutions [iOS] Bug #1482: fix a bug that orientation is wrong on iOS 6 SDK Bug #1453: fix a bug that CCGL.h includes wrong path of a header file Bug #1484: fix a minor memory-logic error in EditBoxImplIOS.mm Feature #1455: add Xcode template for cocos2dx-js [android] Refactor #1481: refactor android Java+JNI [mac os] Bug #1456: remove code signing from MAC TestCpp project [linux] [win32] Feature #1457: Add vs2012 sln Feature #1474: popup a warning dialog instead of crash directly when OpenGL version is too old to run 2dx [js-bindings] Feature #1451: merge new js-binding codes Refactor #1476: update location of spidermonkey-android makefile [lua] Refactor #1480: Update lua-binding for overloaded functions [tools] Feature #1404: add scripts for jenkins-ci cocos2d-2.0-x-2.0.2 @Aug.30 2012 [all platforms] Bug #1298: fix a logical error of CCSequence Bug #1371: fix a particle crashes if setAutoRemoveOnFinish(true) Bug #1379: fix a typo error of comment in CCNode.cpp Bug #1381: fix a bug that CCLayerColor::setContentSize() declared differently with CCNode::setContentSize() Bug #1382: fix a crash of CCBReader caused by null pointer Bug #1384: fix an error when loading CCControlButton from ccbi Bug #1385: fix a logic error in BitmapFontMultiLineAlignment Bug #1386: fix a crash of PauseResumeActionsTest Bug #1395: fix a bug that CCTextureCache::addImage ignores error in CCTexture2D::initWithImage() Bug #1400: re-assign texture rect of CCControlSlider to consider SpriteFrame orientation Bug #1403: fix a bug that do not support png8 format Bug #1408: fix a bug that CCMenuItemImage is not loaded when the target and selector are empty in CCBReader Bug #1409: fix a bug that loading CCControlButton from ccbi failed Bug #1427: fix a bug that CCArray::randomObject() may use index that out of range Bug #1430: fix a bug that can not compute correct label's width or height when its value is 0 Bug #1440: fix a bug that CCSprite::displayFrame() uses wrong offset to create a sprite frame Feature #1416: add object-oriented API of CCGeometry Feature #1405: implement multi-resolution adaption solution Feature #1424: add a simple wrapper of http access Feature #1429: add CCEditBox which wraps system edit control Feature #1439: synchronize to cocos2d-iphone 2.0 stable version Refactor #1399: adjust directory structure Refactor #1402: improve static creator function names to avoid confusion Refactor #1413: improve CCTouch::getLocation(), getDelta() which returns OpenGL coordinates directly Refactor #1437: change the return type of CCApplication::sharedApplication() and CCEGLView::sharedOpenGLView() to a pointer Refactor #1441: put hd and iPad resources of TestCpp into separate directories Refactor #1442: use CREATE_FUNC to replace LAYER_CREATE_FUNC and SCENE_CREATE_FUNC [iOS] Bug #1389: fix a Xcode 4.5-specific compiling errors that can not convert -1 to unsigned int Bug #1432: fix a bug that "MutiTouchTest" crashes on IOS if putting more than 5 fingers on the screen Refactor #1383: change the file path that CCUserDefault saves xml file in Refactor #1433: remove fpsxxx.png in template Refactor #1443: Fix some warnings [android] Bug #1284: use OpenSL ES to play effects when the device is i9100 Bug #1372: fix a typo error in platform/android/CCEGLView.h Bug #1377: fix TMX Tile cracks in the Test App Refactor #1407: cleaner build script Refactor #1438: make android template use its own source files [mac os] Bug #1417: fix a compiling error when building TestCpp for mac port using command line Feature #1401: add mac port [win32] Bug #1390: fix a win32 error says "The application failed to initialize properly" [linux] Bug #1445: fix compiling errors on linux Feature #1419: add linux port [blackberry] Feature #1420: add blackberry port cocos2d-2.0-rc2-x-2.0.1 @Jun.28 2012 [all platforms] Bug #1257: synchronize CCGrabber.cpp Bug #1280: fix a bug that BitmapFontMultiLineAlignment test doesn't work correctly Bug #1286: fix the declaration of tgaLoadRLEImageData() Bug #1293: fix a bug that CCDirector::getFrames() returns wrong value Bug #1296: fix a logical error in CCTMXTiledMap::tilesetForLayer() Bug #1300: fix a typo of CC_ENABLE_CACHE_TEXTTURE_DATA Bug #1301: apply scissor with points in CCEGLView::sharedOpenGLView().setScissorInPoints() Bug #1302: change the parameter type of CCMenu::setHandlerPriority to signed int Bug #1308: fix a logical bug in CCTouchDispatcher Bug #1326: fix a bug that the compilation of HelloLua and testjs project was broken after synchronizing to rc2 Bug #1330: fix bugs of CCBIReader Bug #1335: fix memory leaks in cocos2dx and CCBReader Bug #1368: implement a test case(Effect4) in EffectsAdvancedTest Feature #1202: remove CCFileData Feature #1310: synchronize to rc2 Feature #1323: support CCBIReader Feature #1324: add create() for static member functions that new an autorelease object Feature #1332: add macro COCOS2D_VERSION in cocos2d.h Feature #1333: support CCScrollView Feature #1334: add ScrollViewTest to CocosBuilderTest Refactor #1181: refactor CCRenderTexture Refactor #1283: use relative path in cocos2d.h Refactor #1288: enhances CCTransitionScene to work even if there is no running scene Refactor #1289: update CCControlButton: add zoomOnTouchDown property and setPreferredSize Refactor #1292: modify some function names to make them more readable Refactor #1336: use CC_DEPRECATED_ATTRIBUTE macro to mark deprecated interfaces Refactor #1367: change some function names that start with "createWith" to "create" [iOS] Bug #1290: fix a bug that a project generated by template can not find Shaders folder Bug #1297: fix a bug that the effect is wrong when using projection 2d and enabling retina Bug #1299: fix a bug that SimpleAudioEngine::resumeEffect and SimpleAudioEngine::resumeAllEffects will play effects that are played previously Bug #1315: fix wrong effect of TileMapTest when enabling retina Bug #1338: fix a crash of CocosdenshionTest when playing effect then clicking HOME menu Bug #1343: fix a bug of Xcode template Bug #1364: fix a bug that can not resume background music after pausing it Refactor #1269: generate project for cocos2dx, then HelloWorld, tests, HelloLua and testjs can refer it [android] Bug #1239: fix a bug that can not stop effect if play effect with loop mode twice Bug #1278: fix a bug that CocosDenshion::unloadEffect() can not stop playing effect Bug #1322: make CCLabelTTF support vertical alignment Refactor #1287: make android template's build_native.sh automatically copy new icons Refactor #1329: move all java files part of engine into a certain directory, then all projects refer them [win32] Bug #1282: fix a crash that if the display card is ATI Bug #1344: fix a bug of win32 template Bug #1365: fix a bug that some files of Resources folder which is copied by build_native.sh will lost authority in cygwin Bug #1366: fix a crash of tests [lua] Bug #1369: fix a crash when invoking CCLabelTTF:setPosition(x,y) Feature #1327: export 'create' method for Lua bindings cocos2d-2.0-rc0a-x-2.0 @May.31 2012 [all platforms] Bug #1094: fix a bug that nothing will be shown when using CCParticleBatchNode Bug #1115: fix a bug that CCFileUtils::fullPathFromRelativePath() with resolution parameter return error value with empty string Bug #1137: fix a memory leak in CCLabelBMFont and sync the implementation of CCLabelBMFont to gles20 branch Bug #1138: fix a memory leak in CCTextureCache::addPVRImage. Bug #1155: revert CCDirector singleton to original implementation Bug #1157: fix a bug that nothing is shown in TMX Orthogonal Test Bug #1158: fix a bug in CCParticleSystemQuad Bug #1159: update "CallFuncND + auto remove" test demo Bug #1160: rename 'CGFloat' to 'CCFloat' Bug #1164: add the render mode which uses VBO without VAO in CCParticleSystemQuad Bug #1165: merge pull request #842 Bug #1187: fix a bug that spanish(Buen día) cannot be shown completely in CCLabelBMFont unicode test Bug #1189: CCLabelBMFont updateLabel() optimizations and fixes Bug #1212: fix a bug that TMXBug787Test crash. Bug #1217: fix a bug that EaseActions reverse broken Bug #1232: fix a bug that CCLayerGradient::updateColor() assign wrong value to m_pSquareColors Bug #1244: fix memory leak in CCParticleSystem::initWithDictionary() Bug #1273: fix a bug that app will crash after clicking closed button in TextureCacheTest Bug #1275: fix memory leaks in tests project Bug #1277: implement CCToggleVisibility::copyWithZone() Feature #1114: integrate CCControlExtension and implement corresponding tests Feature #1180: synchronize CCConfiguration Feature #1194: merge texturewatcher contributed by NetGragon Feature #1205: add ccbreader and test case for CocosBuilder Feature #1240: support TIFF format picture Feature #1258: merge Rolando's testjs into gles20 branch Refactor #1156: synchronize CCDirector Refactor #1166: improve CCString and CCArray, optimize CCDictionary Refactor #1176: change linebreak symbol to UNIX format ('\n'), replace 'tab' with four spaces Refactor #1177: refactor platform Refactor #1178: use macro NS_CC_BEGIN instead of "namespace cocos2d {", NS_CC_END instead of "}" Refactor #1188: refactor directory structure Refactor #1191: update templates for all platforms Refactor #1198: optimize CCTextureCache::removeUnusedTextures() Refactor #1203: remove CCFileUtils::setResource(const char* pszZipFileName) and SimpleAudioEngine::setResource Refactor #1204: refactor AppDelegate::initInstance() Refactor #1206: remove some unused files, only supports iOS, win32 and android Refactor #1211: translate Chinese comments to English for CCTextureWatcher and CCListView Refactor #1246: fix CCDirector using CCLabelBMFont instead of CCLabelTTF Refactor #1252: add CCEGLViewProtocol::getFrameSize() method for getting the real screen size of device Refactor #1253: add static method "purgeConfiguration" for CCConfiguration to avoid memory leak [iOS] Bug #1109: add parentheses to remove Xcode warnings Bug #1230: fix a bug that Calculation of string width may be wrong on iOS Bug #1266: fix a bug that CCTextureCahce::addImageAsync() don't work correctly on iOS Feature #1095: IOS screen resolution support [android] Bug #1139: fix a bug that screen becomes black when backing from background Bug #1140: fix a bug that ParticleTest crashed Bug #1141: fix a bug that NodeTest crashed in StressTest1 and StressTest2 Bug #1142: fix a bug that TouchesTest crashed Bug #1143: fix a bug that MenuTest crashed Bug #1144: fix a bug that ParallaxTest crashed Bug #1145: fix a bug that TileMap crashed Bug #1146: fix a bug that IntervalTest crashed Bug #1147: fix a bug that ChipmunkAccelTouchTest crashed Bug #1148: fix a bug that LabelTest crashed Bug #1149: fix a bug that SpriteTest crashed when go to second test case Bug #1150: fix a bug that RenderTextureTest crashed at second test case Bug #1151: fix a bug that Box2DTest crashed Bug #1152: fix a bug that PerformanceTest crashed at 1, 2, 5 test cases Bug #1185: fix a bug that when backing to foreground, will lost texture if it uses sprite batch node Bug #1216: fix JNI memory leaks Bug #1229: fix a bug that android port can not be compiled on ndk android-8 level Bug #1236: fix a bug that JniHelper::jstring2string may crash when parameter is null Bug #1237: fix a bug that line number message printed by CCAssert is wrong Bug #1279: fix a bug that NodeNonOpaqueTest can't be shown correctly Feature #1247: add profiler support for android Feature #1265: build dynamic library of SpiderMonkey for Android, and implement testjs for android Refactor #1179: popup a message box when invoking CCAssert() on Android Refactor #1201: simplify the usage of writing Android.mk [windows] Bug #1215: fix a bug that Win32 retina cannot work Bug #1251: add CocosBuilderTest to the test project for VS2008 Bug #1264: fix wrong string alignment when using utf-8 encoded text with CCLabelTTF Bug #1268: fix a bug that Testjs will crash after clicking the close button on win32 Bug #1270: fix some warning on win32 Feature #1186: add console window for Win32 application, all debug message output to this console window Feature #1263: build dynamic library of SpiderMonkey for win32, and add testjs project to solution Refactor #1170: remove win32 template of wophone [lua] Refactor #1190: update Lua binding to 2.0 Refactor #1220: using CCString::stringWithContentsOfFile to get string from Lua script files cocos2d-1.0.1-x-0.12.0 @ Mar.5 2012 [all platforms] Bug #925: rename HelloWorld/Resource to HelloWorld/Resources Bug #948: fix a bug that CCMutableArray::getIndexOfObject returns 0 on both "index 0" and "not existing" Bug #951: remove definition of NSMutableSet Bug #961: fix mad behaviour in second stage of CCEaseBackInOut Bug #965: remove some dynamic_cast calling since selector_protocol.h was removed Bug #967: fix a bug that PVR Textures cannot be reloaded after GL context lost Bug #986: add init() funciton in CCMenu class Feature #952: make CCLabelBMFont supports other languages, include Chinese, Korean, Janpanese and so on. Feature #972: add Support for CCNotificationCenter Refactor #933: refactor CCUserDefault Refactor #958: move the implement of SelectorProtocol to CCObject Document #975: add comment for CCTMXTiledMap::getMapSize and more methods [iOS] Bug #946: fix a bug that can not load HD image for both Retina and Normal correctly Bug #762: fix a bug that CCLabelTTF is in different position (higher) than in previous version on iphone Refactor #985: remove template for xcode3 [android] Bug #947: fix a bug that long chinese string causes closed loop on android Bug #950: fix a crash when touching the screen because of RTTI Bug #954: fix a bug that accelerometer axes inverted on android tablet when setting orientation to portrait Bug #957: fix a bug that when running textInputTest, application enters background after input character and click back key on android devices Bug #959: fix a bug that get wrong multitouch id Bug #964: fix a bug that can not show whole charactor Bug #971: fix dynamic_cast error on android Feature #982: make android template supports box2d, chipmunk and lua Refactor #970: use modules in the Android NDK build Bug #1008: fix a bug that missing "return" in SimpleAudioEngine::getEffectsVolume() method on android platform [bada] Bug #984: use static library for cocos2dx project on bada and qnx platform [blackberry] Bug #960: detect when the application goes and return from background in QNX (Black Berry Playbook) Bug #962: fix some bugs on qnx port Bug #963: fix a bug that applicationWillEnterForeground will be invoked twice when application is launched Bug #968: fix a bug about "Out of bound" in CCFileUtils::getWriteablePath() for BlackBerry Feature #994: add support for bbndk2.0 [marmalade] Bug #995: modify project configure for marmalade port after adding extension support and refactor resource folder [win32] Feature #969: implement Accelerometer Simulation for Win32. [lua] Bug #942: fix a crash when invoking CCScheduler:sharedScheduler():scheduleScriptFunc in lua Bug #953: add tolua++ for Mac Refactor #973: refactor Lua support cocos2d-1.0.1-x-0.11.0 @ Jan.13 2012 [blackberry] Feature #907: support blackberry playbook [all platforms] Bug #752: fix a bug that enable and disable touch more times in touch handler callback function may cause memory leak Bug #911: fix a bug that TextureCache::addUIImage() cannot create texture when key is null Bug #920: export export functions in CCAffineTransform with CC_DLL Bug #922: make CCTexture2D::setPVRImagesHavePremultipliedAlpha() to be a static function Bug #926: fix a crash caused by RTTI when running TouchesTest Bug #936: fix a bug that touch menu item may crash when selector is null Feature #892: use RTTI to simplify the codes Feature #903: add touch index for CCTouch Refactor #934: add 'isEqual' function for CCString, make CCObject::isEqual to a virtual function Refactor #940: use new icons and new background pictures with new logo of cocos2d-x [android] Bug #923: fix a bug that CCTextureCache::addImageAsync() crashes when a game enters foreground from background Bug #906: remove unneeded codes in CCImage_android.cpp Bug #910: fix a bug that create-android-project.bat may erase exist folder with appointed name Bug #884: fix a crash error caused by CocosDenshion on android simulator Bug #921: fix a bug that accelerometer axes inverted in Motorola Xoom tablet Bug #928: fix a bug that 16-bit texture is changed to 32-bit after application enter foreground Bug #935: fix a bug that terminateProcessJNI() invoke wrong jni function Bug #937: fix a compiling error on android x86 Bug #941: fix a bug that volume of background music may not in [0, 1.0] Feature #887: define GL_GLEXT_PROTOTYPES = 1 automatically when compile on ndk r7 Feature #919: improve build_native.sh and create-android-project.sh Refactor #924: make loading music resources thread safe Document #837: Write a document describes how to use jni Document #914: update document to fit android r5~r7 [iOS] Bug #917: implement CCFileUtils::getFileDataFromZip() Feature #893: remove cached data when receiving memory warning on iOS [bada] Bug #918: fix a compiling error after renaming airplay to marmalade Bug #927: fix a crash caused by invoking unloadEffect after invoking stopEffect Bug #938: fix a bug that glGenFramebuffersOES isn't supported on wave m device Bug #943: fix a bug that box2d can't be compiled successfully on bada sdk 1.2.1 Refactor #904: Recreate bada 2.0 projects [win32] Bug #915: fix a bug that msvc template uses old version of .cpp files [linux] Bug #888: fix compiling error with eclipse Bug #930: fix a crash caused by load jpg format files [marmalade] Refactor #908: merge marmalade to latest cocos2d-x source cocos2d-1.0.1-x-0.10.0 @ Dec.2 2011 [bada] Feature #223 integrate cocos2d-bada branch to master Bug #852 fix a bug that CCSpriteBatchNode cannot be drawn correctly [all platforms] Feature #854 integrate pthread and write a test case on all platforms Feature #465 implement CCTextureCache::addImageAsync() Feature #850 upgrade box2d from 2.1.2 to last 2.2.1 Feature #781 add functions for effects Feature #760 add methods to get/set CCDirector::m_pNotificationNode Bug #883 fix the crash of SpriteTest Refactor #879 use CCAssert() instead of assert() Document #882 Write a document describes some cautions about using pthread [android] Feature #838 support android x86 platform Bug #758 fix a bug that custom TTF fonts causing low memory Bug #848 fix a bug that accelerometer values are wrong if the content is scaled Bug #885 fix a bug that SimpleAudioEngine::setEffectVolume() don't take effect immediately Document #864 write a describe how to build on sdk 4.0 & ndk-r7 Document #878 write a document describe how to build project for x86 android Document #881 write a document describes building android ndk project with ndk-r7 [linux] Bug #780 fix build error on ubuntu 11.0 Bug #776 fix a bug in the audio player cocos2d-1.0.1-x-0.9.2 @ Oct.20,2011 [linux] Feature #728 Linux port is born! http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_run_HelloWorld_and_tests_on_linux [all platforms] Feature #672 Implements copyWithZone() for CCShow & CCHide Feature #676 add more languages into CCApplication::getCurrentLanguage() Feature #678 add private constructor for CCArray Feature #684 add test case for CCApplication::getCurrentLanguage() Feature #685 add test case in LabelTest to display Chinese charactors Bug #675 Fix memory leak in CCLayer when using accelerometer Bug #686 CCTMXLayer::appendTileForGID() not setting Z index tag causes the first screen of tiles to be re-created Bug #689 CCRect should assert the width and height is positive Bug #698 CCSprite::init() is excited twice in all CCSprite's static methods Bug #700 CC_SWAP32 marco has a typo with leads to error swap result Bug #701 CCZHeader.version should be unsigned short Bug #715 CCFadeOut causes a crash when applied to CCMenuItem and m_pSelectedImage is NULL Bug #718 fix a typo in method CCMenu::alignItemsInRows Bug #749 CCSpriteTest crashes at the test case SpriteNilTexture Bug #750 CCTextureCache::textureForKey() can't find textures added by function addUIImage() Refactor #677 Pass arguments by reference instead of pointer if possible Refactor #703 Refactor Accelerometer. Because it only sends data to one delegate, so it needs only one setDelegate() Document #692 Describe the usage of view orientation http://www.cocos2d-x.org/projects/cocos2d-x/wiki/About_device_orientation [android] Feature #670 Pause & resume effect playing when activity is paused & resumed Feature #687 Implement preloadBackgroundMusic to android Feature #688 Support reading resources not only from apk Feature #726 use external storage on android Feature #746 add a helper method to draw filled polygons Bug #683 getPackagenameJNI() and getCurrentLanguageJNI() mustn't return invalid pointer Bug #696 Some android devices may crash at CCRenderTexture::end(bool) Bug #719 CocosDenshionTest crashes when start the test case on android Bug #714 CCLabelTTF has different visual result between Android & Windows Bug #727 Memory leak of NewStringUTF Bug #736 Remove android:installLocation in AndroidManifest.xml Bug #743 nativeInit is called with wrong screen size when running on device with software android buttons Bug #744 CCUserDefault crashes in v0.9.1 Bug #755 Multi-touch causes crash on sum sung devices [ios] Bug #660 CCLabelBMFont image error in retina display Bug #693 CCLabelTTF can not break line by '\n' on iOS Bug #716 subbing & adding volume of sound effects don't change volume little by little on iOS Bug #738 Passing CCSize(width,0) to CCLabelTTF causes the label invisible Bug #753 visual orientation is wrong on ios5 simulator Bug #754 Missing png file for CCLabelAtlas cause crashes on iOS 4.3.3 & 5.0 [win32] Feature #731 add ability of simulating android back/menu key on win32 Feature #735 add ability of simulating android enter/resume background on win32. Shift+F1=android Back, Shift+F2 =android Menu Feature #745 export CCTime to all Bug #747 Win32 templates should put all resources into "Resources" folder Bug #748 build error in win32 release version [wophone] Bug #702 tests crash at the start on wophone devices [lua] Feature #704 Print error descriptions ad pop error code in CCLuaScriptModule::executeString & CCLuaScriptModule::executeScriptFile Feature #707 Support 'require' for Lua on android Feature #732 Add particle systems to Lua bindings Feature #733 Use ant to generate a Lua project, refer to http://www.cocos2d-x.org/boards/11/topics/3957 Feature #734 Use ant to generate LuaCocos2d.cpp cocos2d-1.0.1-x-0.9.1 @ Aug.17,2011 [all platforms] Feature #347 Support custom TTF fonts Feature #536 Support PVR Texture Feature #645 update to cocos2d-iphone v1.0.1 Feature #633 allow SimpleAudioEngine::playEffect repeatly Feature #630 implement CCRenderTexture::saveBuffer method Feature #613 Call executeCallFuncN instead of executeCallFunc in CCMenuItem::active() Feature #620 add Texture2d test case Feature #638 Add support for per ccz format Feature #641 users can CCRenderTexture::saveBuffer to any path Feature #643 swap Accelerometer input x/y according to the orientation Feature #665 add test case for CCRenderTexture::saveBuffer Bug #513 CCProgressTimer doesn't work with CCspriteFrameCache Bug #609 Retain & Release CCObject in CCSet Bug #628 CCMutableArray::arrayWithObjects should autorelease array object Bug #629 pass eImgFmt to initWithImageData in initWithImageFile Bug #636 CCTextureCache::textureForKey() can't find the right texture Bug #639 m_PositionInPixels isn't correctly initialized Bug #640 the image read from render texture is upseted Bug #644 CCSpriteBatchNode::removeAllChildrenWithCleanup() not work as expected Bug #680 CCtouchDispatcher::rearrangeHandlers() crash Refactor #623 refactor Cocos2dJni.cpp Refactor #652 refactor char* JniHelper::jstringtochar() Document #622 comment CCUserDefault in doxygen format Document #651 add CCFileUtils to oxygen api document [lua] Feature #679 bind Lua to CocosDenshion Feature #647 add a method to set search path of Lua script Feature #611 Add some methods in CCMenuItemLabel & CCMenuItemToggle for lua Feature #612 Export CCNode::getContentSizeInPixels & setContentSizeInPixels to lua Feature #653 add CCScheduler::unscheduleScriptFunc Bug #615 CCLOG may crash in LuaEngineImpl [android] Feature #610 Remove the support of ndk-r4 crystax.net version Bug #608 CCRenderTexture cannot show textures after sleep and wake-up Bug #618 HelloWorld & Tests crash when X is clicked Bug #619 CCFadeTo may crash on android Bug #624 CCLabelTTF::setString("\n\n\n") crashes on android Bug #625 test_image_rgba4444.pvr.gz can not packed into app Bug #631 TextInputTest crash when input nothing Bug #637 Create resources folder instead of resource in create-android-project.sh Bug #648 CCRenderTexture::saveBuffer may crash on some devices like Moto Defy Bug #655 CCLabelTTF doesn't draw all characters, it may lost the last char Refactor #656 refactor CCFileUtils, make it support reading data from directory other than assets [ios] Feature #642 CCImage_ios.mm should be modified for saving image Feature #658 xcode3 template should create AppDelegate.cpp/.h instead of ${PROJECT_NAME}AppDelegate.cpp/.h Feature #661 fix TMXTiledMap for iPhone Retina mode Bug #667 AppDelegate::applicationDidEnterBackground isn't invoked on iOS Bug #668 CCLabelBMFont display 4 characters in a square per character block in retina mode [win32] Feature #620 change Lua library to static lib Feature #632 Update visual studio template for Lua support cocos2d-1.0.0-x-0.9.0 @ Jul.14,2011 [all platforms] Feature #584 sync with cocos2d-iphone v1.0.0 Feature #601 use Chipmunk v5.3.5 Feature #581 change return types of xxxAction::reverse() to its own type Bug #522 CCSpriteFrameCache::addSpriteFramesWithFile(const char* pszPlist) crashed if the param have no '/' Bug #522 CCTextureCache::removeTextureForKey(const char*) cache the image path incorrectly Bug #573 CCLayerColor does not init its m_tColor, which will result to a random color Bug #576 some CCMutableDictionary methods must return _KeyT instead of std::string Bug #577 CCReverseTime may crash Bug #578 Debian & LavaFlow of ParticleTest have not picture, the effect of ParticleFire is wrong Bug #580 ShuffleTilesTest of EffectText may crash [ios] Bug #546 CCLabelTTF::labelWithString() works incorrectly when height = 0 Bug #604 test.xcodeproject miss Summary & Info in xcode4 since v0.8.5 [android] Feature #547 deal with line wrap of CCLabelTTF::initWithString(...) [win32] Bug #659 ChipmunkTest Sensors crashes in a few seconds Bug #583 SimpleAudioEngine::playBackgroundMusic(const char*, true) have no sound on win32 Bug #605 export C methods in CCNS.h to dll interfaces Bug #548 export CCConfiguration to dll interfaces [marmalade/airplay] Bug #600 incorrect memory allocation in marmalade port Refactor #582 use libpng instead of CIwImage in CCImage_airplay.cpp [wophone] Bug #545 fix the wrong effect of ChipmunkTest Bug #606 PageTransitionForward in TransitionsTest has wrong visual effect cocos2d-0.99.5-x-0.8.5 @ Jun.28,2011 [all platforms] Feature #577 Lua Support! We export all the cocos2d-x classes & methods to lua! Please compile and run HelloLua, and read HelloLua/Resource/hello.Lua for more details. And the Lua new project template/wizard is ready on xcode3, xcode4 and VisualStudio2008 & 2010 Feature #398 Xcode4 templates! Run install-template-xcode.sh to do the magic Feature #323 Internationalization support! Add CCApplication::getCurrentLanguage() method on all platforms Feature #529 add static node() method to CCLayerColor & CCLayerGradient Bug #534 don't raise compile error if ios project includes CCImage.cpp & CCFileUtils.cpp Bug #429 Effect is wrong when the value of defaultAlphaPixelFormet=kCCTexture2DPixelFormat_A8 in CCTexture2D Bug #491 Unsafe cycle in CCScheduler::unscheduleAllSelectors Bug #502 Refactor the singleton mode of CCConfiguration Bug #512,#525 fix warnings in /Wall flag Bug #516 Undefined behavious in ccCArray.h (signed / unsigned conversion) Bug #518 CCScheduler::unscheduleAllSelectors() uses tHashSelectorEntry in wrong way Bug #521 the effect of PageTurn3D is curious Bug #523 CCParticleSystemQuad::particleWithFile() can't work correctly Bug #524 CCFileUtils::dictionaryWithContentsOfFile() can't parse special plist format Bug #526 glScissior can't work correctly when use autoscale function Bug #543 EffectTest renders x4 scale when use auto-scale on android/win32/wophone Bug #544 some test cases of TransitionTest renders x4 scale when use auto-scale on android/win32/wophone [android] Bug #490 TextInputTest show words on soft keyboard detach instead of each key pressed Bug #507 RenderTextureTest failed on some android devices Bug #532 GLSurface has no response when tap screen frequently for a long time Bug #542 SimpleAudioEngine::setBackgroundMusicVolume() not work when background music changed Refactor #535 remove skia dependence when drawing strings, which cause bug #507 [ios] Feature #540 Add RootViewController into xcode3/xcode4 templates. Games can use ios rotation mechanism [win32] Feature #537 Update PVRFrame lib to version 2.8 for ATI graphic card new driver [wophone] Bug #539 games on wophone wva devices probably failed on reading resource from zip package cocos2d-0.99.5-x-0.8.4 @ May.26,2011 [android] Feature #496 SUPPORT ANDROID 3.0! We test it on both Motorola XOOM & Samsung Galaxy Tab 10.1 (Highlight!!!!!) Bug #494 typo fixed, Cocos2dxActivity::setPackgeName() to setPackageName() Bug #495 Memory leak of CCFileUtils::getWriteablePath() Bug #497 soft keyboard stays shown on some devices while the project includes CCTextFieldTTF Bug #501 projects creaed by android template have the same package name Bug #510 Tests progress is killed at the power down phase [all platforms] Feature #503 upgrade chipmunk from 5.1 to 5.3.4, keep sync with cocos2d-iphone (Highlight!) Feature #509 For integrting IME, we had to rotate UI to landscape by default Bug #499 CCRGBAProtocol isn't inherited and implemented in CCMenuItemSprite [ios] Bug #493 the return value of CCFileUtils::getWriteablePath() is not end with '/' Bug #508 Problem in running Tests in Retina resolution since 0.8.2 [win32] Bug #492 CCFileUtils::fullPathFromRelativeFile forget to consider the path separated by '\' Feature #489 Use GetCurrentDirectory instead of GetModuleFileName in CCFileUtils_win32.cpp cocos2d-0.99.5-x-0.8.3 @ May.12,2011 [all platforms] Feature #317 wrap input box for game dev, CCTextFieldTTF. (Highlight!) Feature #455 implement CCUserDefault for data persistence (Highlight!) Feature #456 integrate libcurl for network access (Highlight!) Feature #468 implement CCProfiler & CCProfilingTimer Feature #450 can set default pixel format other than RGBA888 Feature #449 Remove the sources for mac platform. We plan to focus on mobile platforms & reduce the complexity Refactor #451 Remove the event dispatcher and refactor CCLayer & CCMenu & CCParticleSystemPoint. Refactor #452 Refactor CCDirector CCGrid CCNode, reduce the complexity Refactor #472 Refactor duplicated modules under cocos2dx/platform, reduce the complexity Bug #341 CCTMXFiledMap crashed when a child is not the obj of CCTMXLayer Bug #371 A layer can't registered as a StandardTouchDelegate when touch event is handling Bug #428 Function addChild low efficiency Bug #448 CCCallFuncO crashes Bug #467 CCLayer:m_eTouchDelegateType = ccTouchDeletateAllBit all the time Bug #471 invoke CCFileUtils::setResourcePath may cause loading texture for ParticleSystem failed Bug #484 CCTextureAtlas::initWithTexture() may cause memory leak Bug #486 transition test FlipX, FlipY, FlipAngular, ZoomFlipXxx flickers on ios simulator & device [ios] Bug #447 really exit application when "x" button is clicked Bug #460 cocos2dx + box2d template cannot find libxml2.dylib [android] Feature #393 use full version of libxml2, with xmlXPath.. serial methods Feature #477 Set compilation default ndk version to r5 Bug #374 replace the method for EGL rendering context lost Bug #453 Android Cocosdenshion can't replace background music Bug #462 no applicationDidEnterBackground / applicationWillEnterBackground on Android Bug #470 use GAME_ROOT or other words instead of HELLOWORLD_ROOT in anroid new projects Bug #475 CCImage::initWithString return true even if the bitmap hasn't been initialized [win32] Feature #454 Modify the including path of Box2D genereated by win32 template Bug #459 the project create by template for vs use the RuntimeLibrary MTd, different with other project [wophone] Feature #482 Modify the resource data path for the new WoPhone SDK Feature #487 Implement the function CCFiltUtils::getWriteablePath() on wophone Refactor #466 Refactor CCFileUtils for the new packing approach on wophone Bug #481 After power down & up, backlight will turn off automaticlly if there's no operation Bug #485 reduce the CPU occupation, modify the approach of FPS control on wophone [airplay] Feature #480 add template for airplay cocos2d-0.99.5-x-0.8.2 @ Apr.7,2011 [all platforms] 390 Feature Implement performance test 411 Feature support .plist format outputed by the last version of Zwoptex 415 Feature Make all xxxFromFile methods can accept relative path 439 Feature all file reading must pass though CCFileUtils::getFileData 441 Feature Initialize pointers in construction & detect them in destruction 427 Refactor refactor CCTMXXMLParser with multi-platform CCSAXParser design 434 Refactor refactor class CCFileUtils 396 Refactor remove ccxScopedPtr & ccxScopedArray, use STL instead 350 Bug TransitionFade flickers 391 Bug CCSpriteFrameCache doesn't support .plist files which format isn't equal to 0 420 Bug CCSprite::spriteWithFile() returns a valid object when the image file isn't present 440 Bug Can't show MessageBox when imageFromFile can't find the image [ios] 349 Bug deal with plist files in binary format 435 Bug CocosDenshion crashes at foreground/background switching 438 Bug MotionStreak Test crashes on device [android] 421 Feature Add a template & new project script for android 443 Feature implement CCKeypadDelegate on android 367 Bug Android.mk of HelloWorld and Tests depends on alphabet order 422 Bug the 2nd point in multi-touch isn't located to the correct coordinate 430 Bug replace glColor4ub with glColor4f to avoid "called unimplement OpenGL ES API" on some android devices 431 Bug ParticleFlower on G3 can't show the particles correctly [win32] 417 Bug No touchEnd when the mouse move out from the window 424 Bug open vs2010.sln says cannot open CCamera.cpp [airplay] 379 Feature integrate airplay sdk port 442 feature implement CocosDenshion on airplay port cocos2d-0.99.5-x-0.8.1 @ Mar.21,2011 [all platforms] 400 Bug typo, rename CCamera.cpp to CCCamera 403 Feature rename cocos2d::UIEvent to cocos2d::CCEvent, to avoid class name conflict on ios 405 Bug CCConfiguration::checkForGLExtension(const string&) sometimes may crashes 407 Bug replace "CCGL.h" with "CCGL.h" in CCCamera.cpp, for case-sensitive systems 408 Bug memory leak in CCImage::_initWithPngData 409 Feature rename cocos2d::NSArray to cocos2d::CCArray, to avoid the conflict on ios 418 Feature add copyright of cocos2d-iphone original authors to each file 423 Bug fix compilation warnings when COCOS2D_DEBUG == 2 [ios] 404 Bug HiResTest isnot prerfect on HVGA/Retina yet 410 Bug xcode3 template, cannot find libxml from header searh paths in release build 419 Bug test case TMXIsoVertexZ in TileMapTst has wrong effect on ios [android] 399 Bug HelloWorld crashes when the screen is touched 405 Bug CocosDenshion test, BGM isn't paused after HOME key tapped [win32] 395 Bug make AppDelegate.cpp created by VS wizard portable without any modification 401 Bug VisualStudio template for 2010 OutputDir errors cocos2d-0.99.5-x-0.8.0 @ Mar.15,2011 [all platforms] 316 Feature Resolution auto adjustment, auto scale HVGA resource to WVGA or any other resolutions 336 Refactor refactor platform porting layer 253 Bug xml parser sometimes crashes 375 Feature Rename NS,CG,UI prefix classes/definitions to CC prefix, avoid the crash at ios dev 332 Feature upgrade tests from 0.99.4 to 0.99.5 [ios] 363 Bug CCLabelTTF can't treat line breaks and wrapping correctly. 351 Feature CCLabelTTF cannot automatic line break on iphone 352 Bug ccRemoveHDSuffixFromFile & CCFileUtils::getDoubleResolutionImage isnot work 392 Bug border of sprite debug draw isn't scaled if enableRetinaDisplay(true) 385 Feature implement ccos2d::CCLog 388 Feature update the template for iOS [android] 247 Feature support multitouch 242 Feature support accelerometer on android 353 Feature support jpg on android 344 Feature add APP_ABI := armeabi armeabi-v7a to improve the performance on some devices 356 Bug CCLabelTTF::initWithString crashed [wophone] 386 Bug resolve the compile conflict on wophone sdk 383 Bug The approach which handle left soft-key clicked is not work 377 Feature Replace the word "uphone" with "wophone" 357 Bug CCLabelTTF doesn't support words contain line breaks. 348 Bug CCLabelTTF blur if color = white and fontSize < 24 [win32] 373 Feature Disable PVRFrame window when cocos2d running 355 Bug CCLabelTTF doesn't support line breaks and wrapping words 300 Feature wizard for Visual C++ 2008 Express & VS2010 Express/Professional cocos2d-0.99.5-x-0.7.2 @ Jan.26,2011 [all platforms] - upgrade engine logic internal & interfaces to 0.99.5 - the list of menu items in tests is showing how to scroll now - lots of bugs fixed [iphone] - add new project templates for Xcode - add the c++ wrapper for CocosDenshion::SimpleAudioEngine - support UTF8 charactors in text renderring, such as CCLabelTTF, CCMenuItemFont [android] - add CocosDenshion::SimpleAudioEngine implement on android - the engine can adjust the apk filename automatically - the engine will not crash at surface recreate, especially at background-to-foreground switching [wophone] - switch the game to background, then press power key will not cause the background music play again - remove the methods of using resouce map in cocos2d-wophone & SimpleAudioEngine. Only zip resource is recommended and suppported. - can auto find the installed path of your game, and load zip resource file from the current folder. No absolute path in code any more. Do this to support installing games to micro-SD card cocos2d-0.99.4-x-0.7.1 @ Dec.20,2010 [all platforms] - add CCKeypadDelegate class, which enable CCLayer to respond "back" key in wophone & android - Add namespace for CocosDenshion - fix compile errors when enable CC_XXX_DEBUG_DRAW switchs in ccConfig.h - fix memory leaks on each platform - more details: http://www.cocos2d-x.org/versions/show/5 [android] - Run through all the test cases of cocos2d, support ndk r4,r5, sdk higher than 2.0. Tested on HTC G2,G3,G6,G7 - HelloWorld integrate all platforms in one directory now - WANRNING: this version isn't ready for android games porting yet. The CocosDenshion isn't ported to android, and this version will crashes when screen orientation changes or the game gack to foreground look more on this bug http://www.cocos2d-x.org/boards/10/topics/202 [iphone] - Add support of loading textureImageData from the ParticleDesign plist file - Fix more then 3000 complie warnings - You can try to use this version to develop your iOS game now. It's much more stable than the previous version [wophone] - Games can easily read resources from zip file now. This will drastically reduce the memory usage - Add power management: pause the message loop when cocos2d-x game is switched to background or backlight down - Multi-touch support [win32] - SimpleAudioEngine can play background musci with repeating now cocos2d-0.99.4-x-0.7.0 @ Nov.29,2010 * cocos2d-iphone-cpp port ready! include accelerometer & multi-touch * refactor the directory structure of HelloWorld & tests * cocos2d-wophone supports accelerometer * add cocos2d-x wizard for cocos2d-win32 & cocos2d-wophone for VisualStudio2008 * jump out a message box when load texture failed (win32 & wophone) * more details: http://www.cocos2d-x.org/versions/show/4 cocos2d-0.99.4-wophone-win32-stable-rc1 http://www.cocos2d-x.org/versions/show/1 http://www.cocos2d-x.org/versions/show/2 http://www.cocos2d-x.org/versions/show/3 ================================================ FILE: cocos2d/CMakeLists.txt ================================================ #/**************************************************************************** # Copyright (c) 2013 cocos2d-x.org # Copyright (c) 2012-2013 martell malone # # 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. # ****************************************************************************/ cmake_minimum_required(VERSION 2.8) project (Cocos2dx) # The version number set(Cocos2dxSamples_VERSION_MAJOR 3) set(Cocos2dxSamples_VERSION_MINOR 0) include(build/BuildHelpers.CMakeLists.txt) if(WIN32 OR APPLE) option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) option(DEBUG_MODE "Debug or release?" ON) option(BUILD_LIBS_LUA "Build lua libraries" OFF) option(BUILD_GUI "Build GUI library" ON) option(BUILD_NETWORK "Build network library" ON) option(BUILD_EXTENSIONS "Build extension library" ON) option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) option(BUILD_HelloCpp "Only build HelloCpp sample" ON) option(BUILD_TestCpp "Only build TestCpp sample" ON) option(BUILD_HelloLua "Only build HelloLua sample" OFF) option(BUILD_TestLua "Only build TestLua sample" OFF) else()#temp option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) option(DEBUG_MODE "Debug or release?" ON) option(BUILD_LIBS_LUA "Build lua libraries" ON) option(BUILD_GUI "Build GUI library" ON) option(BUILD_NETWORK "Build network library" ON) option(BUILD_EXTENSIONS "Build extension library" ON) option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) option(BUILD_HelloCpp "Only build HelloCpp sample" ON) option(BUILD_TestCpp "Only build TestCpp sample" ON) option(BUILD_HelloLua "Only build HelloLua sample" ON) option(BUILD_TestLua "Only build TestLua sample" ON) endif()#temp if(DEBUG_MODE) set(CMAKE_BUILD_TYPE DEBUG) else(DEBUG_MODE) set(CMAKE_BUILD_TYPE RELEASE) endif(DEBUG_MODE) set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) if(WIN32) ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32) if(MSVC) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710 -wd4514 -wd4056 -wd4996 -wd4099) else(MSVC)#MINGW endif(MSVC) elseif(APPLE) else()#Linux ADD_DEFINITIONS(-DLINUX) endif() if(NOT MSVC)# all gcc set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99") set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") endif() if(MINGW) add_definitions(-DGLEW_STATIC) endif() if(USE_CHIPMUNK) message("Using chipmunk ...") add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1) elseif(USE_BOX2D) message("Using box2d ...") add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=1) else(USE_CHIPMUNK) message(FATAL_ERROR "Must choose a physics library.") endif(USE_CHIPMUNK) # architecture if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) set(ARCH_DIR "64-bit") else() set(ARCH_DIR "32-bit") endif() if(WIN32) # Win32 set(PLATFORM_FOLDER win32) elseif(APPLE)# osx or ios set(PLATFORM_FOLDER mac) else() # Assume Linux set(PLATFORM_FOLDER linux) endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cocos ${CMAKE_CURRENT_SOURCE_DIR}/cocos/audio/include ${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d ${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/renderer ${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform ${CMAKE_CURRENT_SOURCE_DIR}/cocos/base ${CMAKE_CURRENT_SOURCE_DIR}/cocos/physics ${CMAKE_CURRENT_SOURCE_DIR}/cocos/editor-support ${CMAKE_CURRENT_SOURCE_DIR}/cocos/math/kazmath/include ${CMAKE_CURRENT_SOURCE_DIR}/extensions ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2 ${CMAKE_CURRENT_SOURCE_DIR}/external/unzip ${CMAKE_CURRENT_SOURCE_DIR}/external/edtaa3func ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include/chipmunk ${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform/desktop ${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/include/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/include/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/include/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER} ) if(WIN32) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/include/OGLES ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/include ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/include external/curl/include/${PLATFORM_FOLDER} ) elseif(APPLE) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER} ) else() include_directories( /usr/include /usr/local/include/GLFW ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/include/${ARCH_DIR} ) endif() if(WIN32) if(NOT MINGW) link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt ) endif() elseif(APPLE) else() link_directories( /usr/local/lib ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR} ) endif() # kazmath add_subdirectory(cocos/math/kazmath) # chipmunk library add_subdirectory(external/chipmunk/src) # box2d library add_subdirectory(external/Box2D) # unzip library add_subdirectory(external/unzip) # tinyxml2 library add_subdirectory(external/tinyxml2) # audio add_subdirectory(cocos/audio) # cocos base library add_subdirectory(cocos/base) # cocos 2d library add_subdirectory(cocos/2d) if(BUILD_GUI) # gui add_subdirectory(cocos/gui) endif(BUILD_GUI) if(BUILD_NETWORK) # network add_subdirectory(cocos/network) endif(BUILD_NETWORK) if(BUILD_EXTENSIONS) # extensions add_subdirectory(extensions) endif(BUILD_EXTENSIONS) ## Editor Support if(BUILD_EDITOR_SPINE) # spine add_subdirectory(cocos/editor-support/spine) endif(BUILD_EDITOR_SPINE) if(BUILD_EDITOR_COCOSBUILDER) # cocosbuilder add_subdirectory(cocos/editor-support/cocosbuilder) endif(BUILD_EDITOR_COCOSBUILDER) if(BUILD_EDITOR_COCOSTUDIO) # cocostudio add_subdirectory(cocos/editor-support/cocostudio) endif(BUILD_EDITOR_COCOSTUDIO) if(BUILD_LIBS_LUA) ## Scripting # lua add_subdirectory(external/lua/lua) # tolua add_subdirectory(external/lua/tolua) # luabinding add_subdirectory(cocos/scripting) endif(BUILD_LIBS_LUA) # build samples if(BUILD_HelloCpp) add_subdirectory(samples/Cpp/HelloCpp) endif(BUILD_HelloCpp) if(BUILD_TestCpp) add_subdirectory(samples/Cpp/TestCpp) endif(BUILD_TestCpp) if(BUILD_HelloLua) add_subdirectory(samples/Lua/HelloLua) endif(BUILD_HelloLua) if(BUILD_TestLua) add_subdirectory(samples/Lua/TestLua) endif(BUILD_TestLua) ================================================ FILE: cocos2d/README.md ================================================ cocos2d-x ========= [![Build Status](https://travis-ci.org/cocos2d/cocos2d-x.png?branch=master)](https://travis-ci.org/cocos2d/cocos2d-x) [cocos2d-x][1] is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications. It is based on [cocos2d-iphone][2], but instead of using Objective-C, it uses C++. It works on iOS, Android, OS X, Windows, Linux, Emscripten, Google Native Client, BlackBerry and Tizen. cocos2d-x is: * Fast * Free * Easy to use * Community Supported How to start a new game ----------------------- 1. Download the code from [cocos2d download site][4] 2. Enter `tools/project-creator` 3. Run the `create_project.py` script Example: $ cd cocos2d-x/tools/project-creator $ ./create_project.py -n mygame -k com.your_company.mygame -l cpp -p /home/mygame $ cd /home/mygame ### Build new project for android ### $ cd proj.android $ ./build_native.py ### Build new project for ios & osx ### * Enter *proj.ios_mac* folder, open *mygame.xcodeproj* * Select ios or osx targets in scheme toolbar ### Build new project for linux ### if you never run cocos2d-x on linux, you need to install all dependences by the script in **cocos2d/build/install-deps-linux.sh** $ cd cocos2d/build $ ./install-deps-linux.sh $ ../.. Then $ mkdir build $ cd build $ cmake .. $ make -j4 Run $ bin/mygame ### Build new project for win32 ### * Enter *proj.win32*, open *mygame.sln* by vs2012 Main features ------------- * Scene management (workflow) * Transitions between scenes * Sprites and Sprite Sheets * Effects: Lens, Ripple, Waves, Liquid, etc. * Actions (behaviours): * Trasformation Actions: Move, Rotate, Scale, Fade, Tint, etc. * Composable actions: Sequence, Spawn, Repeat, Reverse * Ease Actions: Exp, Sin, Cubic, Elastic, etc. * Misc actions: CallFunc, OrbitCamera, Follow, Tween * Basic menus and buttons * Integrated with physics engines: [Box2d][5] and [Chipmunk][6] * Particle system * Skeleton Animations: [Spine][7] and Armature support * Fonts: * Fast font rendering using Fixed and Variable width fonts * Support for .ttf fonts * Tile Map support: Orthogonal, Isometric and Hexagonal * Parallax scrolling * Motion Streak * Render To Texture * Touch/Accelerometer on mobile devices * Touch/Mouse/Keyboard on desktop * Sound Engine support (CocosDenshion library) based on OpenAL * Integrated Slow motion/Fast forward * Fast and compressed textures: PVR compressed and uncompressed textures, ETC1 compressed textures, and more * Resolution Independence * Language: C++, with Lua and JavaScript bindings * Open Source Commercial Friendly: Compatible with open and closed source projects * OpenGL ES 2.0 (mobile) / OpenGL 2.1 (desktop) based Build Requirements ------------------ * Mac OS X 10.7+, Xcode 4.6+ * or Ubuntu 12.10+, CMake 2.6+ * or Windows 7+, VS 2012+ Runtime Requirements -------------------- * iOS 5.0+ for iPhone / iPad games * Android 2.3+ for Android games * OS X v10.6+ for Mac games * Windows 7+ for Win games Running Tests -------------------- Select the test you want from Xcode Scheme chooser. * For OS X / iOS ``` $ cd cocos2d-x/build $ open samples.xcodeproj ``` * For Linux ``` $ cd cocos2d-x/build $ ./install-deps-linux.sh $ cmake .. $ make ``` Run Samples ``` $ bin/hellocpp/hellocpp or $ bin/testlua/testlua ``` You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, you should make it to direct to a correct one. `install-deps-linux.sh` only has to be run once. * For Windows Open the `cocos2d-x/build/cocos2d-win32.vc2012.sln` * For Android ``` $ cd cocos2d-x/build $ python ./android-build.py hellocpp ``` Import HelloCpp Android project using Eclipse(released with Android SDK). The path to be imported is `cocos2d-x/samples/Cpp/HelloCpp/proj.android`. Contributing to the Project -------------------------------- Did you find a bug? Do you have feature request? Do you want to merge a feature? * [contributing to cocos2d-x][8] Contact us ---------- * Forum: [http://forum.cocos2d-x.org][9] * Twitter: [http://www.twitter.com/cocos2dx][10] * Weibo: [http://t.sina.com.cn/cocos2dx][11] * IRC: [https://webchat.freenode.net/][12] (#cocos2d and #cocos2d-x channels) [1]: http://www.cocos2d-x.org "cocos2d-x" [2]: http://www.cocos2d-iphone.org "cocos2d for iPhone" [3]: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Download [4]: http://www.cocos2d-x.org/download/version#Cocos2d-x [5]: http://www.box2d.org "Box2D" [6]: http://www.chipmunk-physics.net "Chipmunk2D" [7]: http://esotericsoftware.com/ "http://esotericsoftware.com/" [8]: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Contribution [9]: http://forum.cocos2d-x.org "http://forum.cocos2d-x.org" [10]: http://www.twitter.com/cocos2dx "http://www.twitter.com/cocos2dx" [11]: http://t.sina.com.cn/cocos2dx "http://t.sina.com.cn/cocos2dx" [12]: https://webchat.freenode.net/ "https://webchat.freenode.net/" ================================================ FILE: cocos2d/build/BuildHelpers.CMakeLists.txt ================================================ macro(pre_build TARGET_NAME) add_custom_target( ${TARGET_NAME}_PRE_BUILD ALL ) add_custom_command( TARGET ${TARGET_NAME}_PRE_BUILD ${ARGN} PRE_BUILD COMMENT "${TARGET_NAME}_PRE_BUILD ..." ) add_custom_target( ${TARGET_NAME}_CORE_PRE_BUILD ) add_dependencies( ${TARGET_NAME}_PRE_BUILD ${TARGET_NAME}_CORE_PRE_BUILD ) endmacro() ================================================ FILE: cocos2d/build/android-build.py ================================================ #!/usr/bin/python # android-build.py # Build android samples import sys import os, os.path import shutil from optparse import OptionParser CPP_SAMPLES = ['hellocpp', 'testcpp', 'simplegame', 'assetsmanager'] LUA_SAMPLES = ['hellolua', 'testlua'] JSB_SAMPLES = ['cocosdragon', 'crystalcraze', 'moonwarriors', 'testjavascript', 'watermelonwithme'] ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES def get_num_of_cpu(): ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. ''' try: platform = sys.platform if platform == 'win32': if 'NUMBER_OF_PROCESSORS' in os.environ: return int(os.environ['NUMBER_OF_PROCESSORS']) else: return 1 else: from numpy.distutils import cpuinfo return cpuinfo.cpu._getNCPUs() except Exception: print "Can't know cpuinfo, use default 1 cpu" return 1 def check_environment_variables(): ''' Checking the environment NDK_ROOT, which will be used for building ''' try: NDK_ROOT = os.environ['NDK_ROOT'] except Exception: print "NDK_ROOT not defined. Please define NDK_ROOT in your environment" sys.exit(1) return NDK_ROOT def check_environment_variables_sdk(): ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building ''' try: SDK_ROOT = os.environ['ANDROID_SDK_ROOT'] except Exception: print "ANDROID_SDK_ROOT not defined. Please define ANDROID_SDK_ROOT in your environment" sys.exit(1) return SDK_ROOT def select_toolchain_version(): '''Because ndk-r8e uses gcc4.6 as default. gcc4.6 doesn't support c++11. So we should select gcc4.7 when using ndk-r8e. But gcc4.7 is removed in ndk-r9, so we should determine whether gcc4.7 exist. Conclution: ndk-r8e -> use gcc4.7 ndk-r9 -> use gcc4.8 ''' ndk_root = check_environment_variables() if os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.8")): os.environ['NDK_TOOLCHAIN_VERSION'] = '4.8' print "The Selected NDK toolchain version was 4.8 !" elif os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.7")): os.environ['NDK_TOOLCHAIN_VERSION'] = '4.7' print "The Selected NDK toolchain version was 4.7 !" else: print "Couldn't find the gcc toolchain." exit(1) def caculate_built_samples(args): ''' Compute the sampels to be built 'cpp' for short of all cpp samples 'lua' for short of all lua smpleas 'jsb' for short of all javascript samples ''' if 'all' in args: return ALL_SAMPLES targets = [] if 'cpp' in args: targets += CPP_SAMPLES args.remove('cpp') if 'lua' in args: targets += LUA_SAMPLES args.remove('lua') if 'jsb' in args: targets += JSB_SAMPLES args.remove('jsb') targets += args # remove duplicate elements, for example # python android-build.py cpp hellocpp targets = set(targets) return list(targets) def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,android_platform,build_mode): ndk_path = os.path.join(ndk_root, "ndk-build") # windows should use ";" to seperate module paths platform = sys.platform if platform == 'win32': ndk_module_path = 'NDK_MODULE_PATH=%s;%s/external;%s/cocos' % (cocos_root, cocos_root, cocos_root) else: ndk_module_path = 'NDK_MODULE_PATH=%s:%s/external:%s/cocos' % (cocos_root, cocos_root, cocos_root) num_of_cpu = get_num_of_cpu() if ndk_build_param == None: command = '%s -j%d -C %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_module_path) else: command = '%s -j%d -C %s %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_build_param, ndk_module_path) print command if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") elif android_platform is not None: sdk_tool_path = os.path.join(sdk_root, "tools/android") cocoslib_path = os.path.join(cocos_root, "cocos/2d/platform/android/java") command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) if os.system(command) != 0: raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root) if os.system(command) != 0: raise Exception("update project [ " + app_android_root + " ] fails!") buildfile_path = os.path.join(app_android_root, "build.xml") command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root) os.system(command) def copy_files(src, dst): for item in os.listdir(src): path = os.path.join(src, item) # Android can not package the file that ends with ".gz" if not item.startswith('.') and not item.endswith('.gz') and os.path.isfile(path): shutil.copy(path, dst) if os.path.isdir(path): new_dst = os.path.join(dst, item) os.mkdir(new_dst) copy_files(path, new_dst) def copy_resources(target, app_android_root): # remove app_android_root/assets if it exists assets_dir = os.path.join(app_android_root, "assets") if os.path.isdir(assets_dir): shutil.rmtree(assets_dir) # copy resources(cpp samples and lua samples) os.mkdir(assets_dir) resources_dir = os.path.join(app_android_root, "../Resources") if os.path.isdir(resources_dir): copy_files(resources_dir, assets_dir) # jsb samples should copy javascript files and resources(shared with cocos2d-html5) if target in JSB_SAMPLES: resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/javascript/script") copy_files(resources_dir, assets_dir) if target == "cocosdragon": resources_dir = os.path.join(app_android_root, "../../Shared/games/CocosDragonJS/Published files Android") if target == "crystalcraze": resources_dir = os.path.join(app_android_root, "../../Shared/games/CrystalCraze/Published-Android") if target == "testjavascript": resources_dir = os.path.join(app_android_root, "../../Shared/tests/") if target == "watermelonwithme": resources_dir = os.path.join(app_android_root, "../../Shared/games/WatermelonWithMe") if target != "moonwarriors": copy_files(resources_dir, assets_dir) else: resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/res") dst_dir = os.path.join(assets_dir, "res") os.mkdir(dst_dir) copy_files(resources_dir, dst_dir) resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/src") dst_dir = os.path.join(assets_dir, "src") os.mkdir(dst_dir) copy_files(resources_dir, dst_dir) resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors") for item in os.listdir(resources_dir): path = os.path.join(resources_dir, item) if item.endswith('.js') and os.path.isfile(path): shutil.copy(path, assets_dir) # AssetsManager test should also copy javascript files if target == "assetsmanager": resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/javascript/script") copy_files(resources_dir, assets_dir) # lua samples should copy lua script if target in LUA_SAMPLES: resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/lua/script") copy_files(resources_dir, assets_dir) # TestLua shared resources with TestCpp if target == "testlua": resources_dir = os.path.join(app_android_root, "../../../Cpp/TestCpp/Resources") copy_files(resources_dir, assets_dir) def build_samples(target,ndk_build_param,android_platform,build_mode): ndk_root = check_environment_variables() sdk_root = None select_toolchain_version() build_targets = caculate_built_samples(target) current_dir = os.path.dirname(os.path.realpath(__file__)) cocos_root = os.path.join(current_dir, "..") if android_platform is not None: sdk_root = check_environment_variables_sdk() if android_platform.isdigit(): android_platform = 'android-'+android_platform else: print 'please use vaild android platform' exit(1) if build_mode is None: build_mode = 'debug' elif build_mode != 'release': build_mode = 'debug' app_android_root = '' for target in build_targets: if target == 'hellocpp': app_android_root = os.path.join(cocos_root, 'samples/Cpp/HelloCpp/proj.android') elif target == 'testcpp': app_android_root = os.path.join(cocos_root, 'samples/Cpp/TestCpp/proj.android') elif target == 'simplegame': app_android_root = os.path.join(cocos_root, 'samples/Cpp/SimpleGame/proj.android') elif target == 'assetsmanager': app_android_root = os.path.join(cocos_root, 'samples/Cpp/AssetsManagerTest/proj.android') elif target == 'hellolua': app_android_root = os.path.join(cocos_root, 'samples/Lua/HelloLua/proj.android') elif target == 'testlua': app_android_root = os.path.join(cocos_root, 'samples/Lua/TestLua/proj.android') elif target == 'cocosdragon': app_android_root = os.path.join(cocos_root, 'samples/Javascript/CocosDragonJS/proj.android') elif target == 'crystalcraze': app_android_root = os.path.join(cocos_root, 'samples/Javascript/CrystalCraze/proj.android') elif target == 'moonwarriors': app_android_root = os.path.join(cocos_root, 'samples/Javascript/MoonWarriors/proj.android') elif target == 'testjavascript': app_android_root = os.path.join(cocos_root, 'samples/Javascript/TestJavascript/proj.android') elif target == 'watermelonwithme': app_android_root = os.path.join(cocos_root, 'samples/Javascript/WatermelonWithMe/proj.android') else: print 'unknown target: %s' % target continue copy_resources(target, app_android_root) do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,android_platform,build_mode) # -------------- main -------------- if __name__ == '__main__': #parse the params usage = """ This script is mainy used for building samples built-in with cocos2d-x. Usage: %prog [options] target Valid targets are: [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon|crystalcraze|moonwarriors|testjavascript|watermelonwithme]. You can combine them arbitrarily with a whitespace among two valid targets. You can use [all|cpp|lua|jsb], to build all the samples, or all the c++ samples, or all the lua samples, or all the jsb samples respectevely. cpp = ['hellocpp', 'testcpp', 'simplegame', 'assetsmanager'] lua = ['hellolua', 'testlua'] jsb = ['cocosdragon', 'crystalcraze', 'moonwarriors', 'testjavascript', 'watermelonwithme'] all = cpp + lua + jsb // be careful with the all target, it may took a very long time to compile all the projects, do it under your own risk. If you are new to cocos2d-x, I recommend you start with hellocpp,hellolua or testjavascript. You can combine these targets like this: //1. to build simplegame and assetsmanager python android-build.py -p 10 simplegame assetsmanager //2. to build hellolua and all the jsb samples python android-build.py -p 19 hellolua jsb Note: You should install ant to generate apk while building the andriod samples. But it is optional. You can generate apk with eclipse. """ parser = OptionParser(usage=usage) parser.add_option("-n", "--ndk", dest="ndk_build_param", help='Parameter for ndk-build') parser.add_option("-p", "--platform", dest="android_platform", help='Parameter for android-update. Without the parameter,the script just build dynamic library for the projects. Valid android-platform are:[10|11|12|13|14|15|16|17|18|19]') parser.add_option("-b", "--build", dest="build_mode", help='The build mode for java project,debug[default] or release. Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html') (opts, args) = parser.parse_args() if len(args) == 0: parser.print_help() else: try: build_samples(args, opts.ndk_build_param,opts.android_platform,opts.build_mode) except Exception as e: print e sys.exit(1) ================================================ FILE: cocos2d/build/build-mingw32-gcc-make.sh ================================================ #!/bin/bash # msys2 Pacman Manager for cocos2d-x #/**************************************************************************** # Copyright (c) 2012-2013 Martell Malone # # # 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. # ****************************************************************************/ set -e THISDIR="$(dirname $0)" test "$THISDIR" = "." && THISDIR=${PWD} OSTYPE=${OSTYPE//[0-9.]/} HOST_ARCH=$(uname -m) if [ "${HOST_ARCH}" = "i686" ]; then BITS=32 elif [ "${HOST_ARCH}" = "x86_64" ]; then BITS=64 fi if [ "${OSTYPE}" = "msys" ]; then CC=${HOST_ARCH}-w64-mingw32-gcc CXX=${HOST_ARCH}-w64-mingw32-g++ PP=mingw-w64-${HOST_ARCH} MINGW_PACKAGES=(glfw glew libwebp libjpeg-turbo libpng freetype libiconv zlib curl make gcc binutils headers cmake libxml2) MINGW_PACKAGES=(${MINGW_PACKAGES[@]/#/${PP}-}) pacman -S --force --noconfirm --needed ${MINGW_PACKAGES[@]} mkdir -p mingw${BITS} && cd mingw${BITS} export PATH=/mingw${BITS}/bin:${PATH} cmake -G"MinGW Makefiles" -DCMAKE_MAKE_PROGRAM="mingw32-make" \ -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" ../.. mingw32-make fi ================================================ FILE: cocos2d/build/cocos2d-win32.vc2012.sln ================================================  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "..\samples\Cpp\HelloCpp\proj.win32\HelloCpp.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "..\external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "..\samples\Cpp\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\cocos\editor-support\cocosbuilder\proj.win32\libCocosBuilder.vcxproj", "{811C0DAB-7B96-4BD3-A154-B7572B58E4AB}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosStudio", "..\cocos\editor-support\cocostudio\proj.win32\libCocosStudio.vcxproj", "{B57CF53F-2E49-4031-9822-047CC0E6BDE2}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGUI", "..\cocos\gui\proj.win32\libGUI.vcxproj", "{7E06E92C-537A-442B-9E4A-4761C84F8A1A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libNetwork", "..\cocos\network\proj.win32\libNetwork.vcxproj", "{DF2638C0-8128-4847-867C-6EAFE3DEE7B5}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetsManagerTest", "..\samples\Cpp\AssetsManagerTest\proj.win32\AssetsManagerTest.vcxproj", "{6D37505F-A890-441D-BD3F-A61E2C0469CE}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\cocos\scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "..\samples\Javascript\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\cocos\storage\local-storage\proj.win32\libLocalStorage.vcxproj", "{632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CocosDragonJS", "..\samples\Javascript\CocosDragonJS\proj.win32\CocosDragonJS.vcxproj", "{68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalCraze", "..\samples\Javascript\CrystalCraze\proj.win32\CrystalCraze.vcxproj", "{9A17D9A4-4B11-4E32-94F6-895FF4909EC5}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MoonWarriors", "..\samples\Javascript\MoonWarriors\proj.win32\MoonWarriors.vcxproj", "{1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WatermelonWithMe", "..\samples\Javascript\WatermelonWithMe\proj.win32\WatermelonWithMe.vcxproj", "{BE092D9E-95AE-4F86-84CE-F4519E4F3F15}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "..\cocos\scripting\lua\bindings\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "..\samples\Lua\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "..\samples\Lua\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleGame", "..\samples\Cpp\SimpleGame\proj.win32\SimpleGame.vcxproj", "{E0E282F4-8487-452C-BFAB-CB960EB4D22F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForBuilder", "..\cocos\scripting\javascript\bindings\cocosbuilder\libJSBindingForBuilder.vcxproj", "{F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForStudio", "..\cocos\scripting\javascript\bindings\cocostudio\libJSBindingForStudio.vcxproj", "{79D34511-E54E-410A-8BBA-EF175AD6C695}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForNetwork", "..\cocos\scripting\javascript\bindings\network\libJSBindingForNetwork.vcxproj", "{3BEC13F5-E227-4D80-BC77-1C857F83BCFC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForExtension", "..\cocos\scripting\javascript\bindings\extension\libJSBindingForExtension.vcxproj", "{625F7391-9A91-48A1-8CFC-79508C822637}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libJSBinding", "libJSBinding", "{10F98A57-B9A1-47DA-9FBA-12D328E72ED1}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForChipmunk", "..\cocos\scripting\javascript\bindings\chipmunk\libJSBindingForChipmunk.vcxproj", "{21070E58-EEC6-4E16-8B4F-6D083DF55790}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForLocalStorage", "..\cocos\scripting\javascript\bindings\localstorage\libJSBindingForLocalStorage.vcxproj", "{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForGui", "..\cocos\scripting\javascript\bindings\gui\libJSBindingForGui.vcxproj", "{9A844C88-97E8-4E2D-B09A-E138C67D338B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForSpine", "..\cocos\scripting\javascript\bindings\spine\libJSBindingForSpine.vcxproj", "{E78CDC6B-F37D-48D2-AD91-1DB549497E32}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32 {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32 {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32 {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Debug|Win32.ActiveCfg = Debug|Win32 {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Debug|Win32.Build.0 = Debug|Win32 {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Release|Win32.ActiveCfg = Release|Win32 {811C0DAB-7B96-4BD3-A154-B7572B58E4AB}.Release|Win32.Build.0 = Release|Win32 {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Debug|Win32.ActiveCfg = Debug|Win32 {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Debug|Win32.Build.0 = Debug|Win32 {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Release|Win32.ActiveCfg = Release|Win32 {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Release|Win32.Build.0 = Release|Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Debug|Win32.ActiveCfg = Debug|Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Debug|Win32.Build.0 = Debug|Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.ActiveCfg = Release|Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.Build.0 = Release|Win32 {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Debug|Win32.ActiveCfg = Debug|Win32 {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Debug|Win32.Build.0 = Debug|Win32 {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Release|Win32.ActiveCfg = Release|Win32 {DF2638C0-8128-4847-867C-6EAFE3DEE7B5}.Release|Win32.Build.0 = Release|Win32 {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.ActiveCfg = Debug|Win32 {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.Build.0 = Debug|Win32 {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.ActiveCfg = Release|Win32 {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.Build.0 = Release|Win32 {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Debug|Win32.ActiveCfg = Debug|Win32 {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Debug|Win32.Build.0 = Debug|Win32 {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Release|Win32.ActiveCfg = Release|Win32 {6D37505F-A890-441D-BD3F-A61E2C0469CE}.Release|Win32.Build.0 = Release|Win32 {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.ActiveCfg = Debug|Win32 {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.Build.0 = Debug|Win32 {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.ActiveCfg = Release|Win32 {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.Build.0 = Release|Win32 {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32 {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32 {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32 {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32 {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Debug|Win32.ActiveCfg = Debug|Win32 {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Debug|Win32.Build.0 = Debug|Win32 {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Release|Win32.ActiveCfg = Release|Win32 {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}.Release|Win32.Build.0 = Release|Win32 {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Debug|Win32.ActiveCfg = Debug|Win32 {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Debug|Win32.Build.0 = Debug|Win32 {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Release|Win32.ActiveCfg = Release|Win32 {68ED0B4E-2BCA-45D2-9648-CEABEBD3B9D7}.Release|Win32.Build.0 = Release|Win32 {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Debug|Win32.ActiveCfg = Debug|Win32 {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Debug|Win32.Build.0 = Debug|Win32 {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Release|Win32.ActiveCfg = Release|Win32 {9A17D9A4-4B11-4E32-94F6-895FF4909EC5}.Release|Win32.Build.0 = Release|Win32 {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Debug|Win32.ActiveCfg = Debug|Win32 {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Debug|Win32.Build.0 = Debug|Win32 {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Release|Win32.ActiveCfg = Release|Win32 {1DB7C0FC-46FF-4A1B-82E0-C6244EEEC4C2}.Release|Win32.Build.0 = Release|Win32 {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Debug|Win32.ActiveCfg = Debug|Win32 {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Debug|Win32.Build.0 = Debug|Win32 {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Release|Win32.ActiveCfg = Release|Win32 {BE092D9E-95AE-4F86-84CE-F4519E4F3F15}.Release|Win32.Build.0 = Release|Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.ActiveCfg = Debug|Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.Build.0 = Debug|Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.ActiveCfg = Release|Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.Build.0 = Release|Win32 {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32 {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32 {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32 {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32 {4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32 {E0E282F4-8487-452C-BFAB-CB960EB4D22F}.Debug|Win32.ActiveCfg = Debug|Win32 {E0E282F4-8487-452C-BFAB-CB960EB4D22F}.Debug|Win32.Build.0 = Debug|Win32 {E0E282F4-8487-452C-BFAB-CB960EB4D22F}.Release|Win32.ActiveCfg = Release|Win32 {E0E282F4-8487-452C-BFAB-CB960EB4D22F}.Release|Win32.Build.0 = Release|Win32 {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}.Debug|Win32.ActiveCfg = Debug|Win32 {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}.Debug|Win32.Build.0 = Debug|Win32 {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}.Release|Win32.ActiveCfg = Release|Win32 {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD}.Release|Win32.Build.0 = Release|Win32 {79D34511-E54E-410A-8BBA-EF175AD6C695}.Debug|Win32.ActiveCfg = Debug|Win32 {79D34511-E54E-410A-8BBA-EF175AD6C695}.Debug|Win32.Build.0 = Debug|Win32 {79D34511-E54E-410A-8BBA-EF175AD6C695}.Release|Win32.ActiveCfg = Release|Win32 {79D34511-E54E-410A-8BBA-EF175AD6C695}.Release|Win32.Build.0 = Release|Win32 {3BEC13F5-E227-4D80-BC77-1C857F83BCFC}.Debug|Win32.ActiveCfg = Debug|Win32 {3BEC13F5-E227-4D80-BC77-1C857F83BCFC}.Debug|Win32.Build.0 = Debug|Win32 {3BEC13F5-E227-4D80-BC77-1C857F83BCFC}.Release|Win32.ActiveCfg = Release|Win32 {3BEC13F5-E227-4D80-BC77-1C857F83BCFC}.Release|Win32.Build.0 = Release|Win32 {625F7391-9A91-48A1-8CFC-79508C822637}.Debug|Win32.ActiveCfg = Debug|Win32 {625F7391-9A91-48A1-8CFC-79508C822637}.Debug|Win32.Build.0 = Debug|Win32 {625F7391-9A91-48A1-8CFC-79508C822637}.Release|Win32.ActiveCfg = Release|Win32 {625F7391-9A91-48A1-8CFC-79508C822637}.Release|Win32.Build.0 = Release|Win32 {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Debug|Win32.ActiveCfg = Debug|Win32 {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Debug|Win32.Build.0 = Debug|Win32 {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Release|Win32.ActiveCfg = Release|Win32 {21070E58-EEC6-4E16-8B4F-6D083DF55790}.Release|Win32.Build.0 = Release|Win32 {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Debug|Win32.ActiveCfg = Debug|Win32 {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Debug|Win32.Build.0 = Debug|Win32 {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.ActiveCfg = Release|Win32 {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.Build.0 = Release|Win32 {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Debug|Win32.ActiveCfg = Debug|Win32 {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Debug|Win32.Build.0 = Debug|Win32 {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Release|Win32.ActiveCfg = Release|Win32 {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Release|Win32.Build.0 = Release|Win32 {E78CDC6B-F37D-48D2-AD91-1DB549497E32}.Debug|Win32.ActiveCfg = Debug|Win32 {E78CDC6B-F37D-48D2-AD91-1DB549497E32}.Debug|Win32.Build.0 = Debug|Win32 {E78CDC6B-F37D-48D2-AD91-1DB549497E32}.Release|Win32.ActiveCfg = Release|Win32 {E78CDC6B-F37D-48D2-AD91-1DB549497E32}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {79D34511-E54E-410A-8BBA-EF175AD6C695} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {3BEC13F5-E227-4D80-BC77-1C857F83BCFC} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {625F7391-9A91-48A1-8CFC-79508C822637} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {39379840-825A-45A0-B363-C09FFEF864BD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {21070E58-EEC6-4E16-8B4F-6D083DF55790} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {9A844C88-97E8-4E2D-B09A-E138C67D338B} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {E78CDC6B-F37D-48D2-AD91-1DB549497E32} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} EndGlobalSection EndGlobal ================================================ FILE: cocos2d/build/cocos2d_libs.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXAggregateTarget section */ A03F2E8E178141C1006731B9 /* build-all-libs Mac */ = { isa = PBXAggregateTarget; buildConfigurationList = A03F2E8F178141C1006731B9 /* Build configuration list for PBXAggregateTarget "build-all-libs Mac" */; buildPhases = ( ); dependencies = ( 1A6FB7E71785683A00CDF010 /* PBXTargetDependency */, A03F31FF178147CB006731B9 /* PBXTargetDependency */, A03F3201178147CB006731B9 /* PBXTargetDependency */, A03F2FC01781458C006731B9 /* PBXTargetDependency */, A03F2E93178141D1006731B9 /* PBXTargetDependency */, A03F2E95178141D1006731B9 /* PBXTargetDependency */, A03F2E97178141D1006731B9 /* PBXTargetDependency */, ); name = "build-all-libs Mac"; productName = "build-all"; }; A07A4E0B178386390073F6A7 /* build-all-libs iOS */ = { isa = PBXAggregateTarget; buildConfigurationList = A07A4E0C178386390073F6A7 /* Build configuration list for PBXAggregateTarget "build-all-libs iOS" */; buildPhases = ( ); dependencies = ( A07A4E10178386520073F6A7 /* PBXTargetDependency */, A07A5047178389710073F6A7 /* PBXTargetDependency */, A07A5049178389710073F6A7 /* PBXTargetDependency */, A07A504B178389710073F6A7 /* PBXTargetDependency */, A07A504D178389710073F6A7 /* PBXTargetDependency */, A07A504F178389710073F6A7 /* PBXTargetDependency */, 1A6FB4FF17854AD600CDF010 /* PBXTargetDependency */, ); name = "build-all-libs iOS"; productName = "build-all-libs iOS"; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 06C0F2EF186AD822003594D5 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */; }; 06C0F2F0186AD824003594D5 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */; }; 06CAAAC2186AD7D70012A414 /* CCActionEaseEx.h in Headers */ = {isa = PBXBuildFile; fileRef = 37936A401869B7B200E974DD /* CCActionEaseEx.h */; }; 06CAAAC3186AD7D80012A414 /* CCActionEaseEx.h in Headers */ = {isa = PBXBuildFile; fileRef = 37936A401869B7B200E974DD /* CCActionEaseEx.h */; }; 06CAAAC4186AD7DF0012A414 /* CCActionEaseEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3774879E1869BA8C00EDF837 /* CCActionEaseEx.cpp */; }; 06CAAAC5186AD7E50012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; }; 06CAAAC6186AD7E60012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; }; 06CAAAC7186AD7E90012A414 /* TriggerObj.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAAC0186AD63B0012A414 /* TriggerObj.cpp */; }; 06CAAAC8186AD7EB0012A414 /* TriggerObj.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAAC0186AD63B0012A414 /* TriggerObj.cpp */; }; 06CAAAC9186AD7EE0012A414 /* TriggerMng.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABF186AD63B0012A414 /* TriggerMng.h */; }; 06CAAACA186AD7EF0012A414 /* TriggerMng.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABF186AD63B0012A414 /* TriggerMng.h */; }; 06CAAACB186AD7F20012A414 /* TriggerMng.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABE186AD63B0012A414 /* TriggerMng.cpp */; }; 06CAAACC186AD7F50012A414 /* TriggerMng.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABE186AD63B0012A414 /* TriggerMng.cpp */; }; 06CAAACD186AD7F90012A414 /* TriggerBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABD186AD63B0012A414 /* TriggerBase.h */; }; 06CAAACE186AD7FA0012A414 /* TriggerBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABD186AD63B0012A414 /* TriggerBase.h */; }; 06CAAACF186AD7FC0012A414 /* TriggerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */; }; 06CAAAD0186AD7FE0012A414 /* TriggerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */; }; 06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABB186AD63B0012A414 /* ObjectFactory.h */; }; 06CAAAD2186AD8030012A414 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABB186AD63B0012A414 /* ObjectFactory.h */; }; 1585AB5B1828D74F00000FB5 /* lua_cocos2dx_studio_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1585AB591828D74F00000FB5 /* lua_cocos2dx_studio_auto.cpp */; }; 1585AB5C1828D74F00000FB5 /* lua_cocos2dx_studio_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1585AB591828D74F00000FB5 /* lua_cocos2dx_studio_auto.cpp */; }; 1585AB5D1828D74F00000FB5 /* lua_cocos2dx_studio_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1585AB5A1828D74F00000FB5 /* lua_cocos2dx_studio_auto.hpp */; }; 1585AB5E1828D74F00000FB5 /* lua_cocos2dx_studio_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1585AB5A1828D74F00000FB5 /* lua_cocos2dx_studio_auto.hpp */; }; 158E06DE181F6796008E01F6 /* lua_xml_http_request.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 158E06DC181F6796008E01F6 /* lua_xml_http_request.cpp */; }; 158E06DF181F6796008E01F6 /* lua_xml_http_request.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 158E06DC181F6796008E01F6 /* lua_xml_http_request.cpp */; }; 158E06E0181F6796008E01F6 /* lua_xml_http_request.h in Headers */ = {isa = PBXBuildFile; fileRef = 158E06DD181F6796008E01F6 /* lua_xml_http_request.h */; }; 158E06E1181F6796008E01F6 /* lua_xml_http_request.h in Headers */ = {isa = PBXBuildFile; fileRef = 158E06DD181F6796008E01F6 /* lua_xml_http_request.h */; }; 1599607B1811329600C7D42C /* libluajit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1599607A1811329600C7D42C /* libluajit.a */; }; 15996080181132DE00C7D42C /* libluajit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1599607F181132DE00C7D42C /* libluajit.a */; }; 15A71D5E18921E6900F30AC0 /* auxiliar.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D3C18921E6900F30AC0 /* auxiliar.c */; }; 15A71D5F18921E6900F30AC0 /* auxiliar.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D3C18921E6900F30AC0 /* auxiliar.c */; }; 15A71D6018921E6900F30AC0 /* auxiliar.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D3D18921E6900F30AC0 /* auxiliar.h */; }; 15A71D6118921E6900F30AC0 /* auxiliar.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D3D18921E6900F30AC0 /* auxiliar.h */; }; 15A71D6218921E6900F30AC0 /* except.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D3E18921E6900F30AC0 /* except.c */; }; 15A71D6318921E6900F30AC0 /* except.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D3E18921E6900F30AC0 /* except.c */; }; 15A71D6418921E6900F30AC0 /* except.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D3F18921E6900F30AC0 /* except.h */; }; 15A71D6518921E6900F30AC0 /* except.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D3F18921E6900F30AC0 /* except.h */; }; 15A71D6618921E6900F30AC0 /* inet.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4018921E6900F30AC0 /* inet.c */; }; 15A71D6718921E6900F30AC0 /* inet.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4018921E6900F30AC0 /* inet.c */; }; 15A71D6818921E6900F30AC0 /* inet.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4118921E6900F30AC0 /* inet.h */; }; 15A71D6918921E6900F30AC0 /* inet.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4118921E6900F30AC0 /* inet.h */; }; 15A71D6A18921E6900F30AC0 /* luasocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4218921E6900F30AC0 /* luasocket.c */; }; 15A71D6B18921E6900F30AC0 /* luasocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4218921E6900F30AC0 /* luasocket.c */; }; 15A71D6C18921E6900F30AC0 /* luasocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4318921E6900F30AC0 /* luasocket.h */; }; 15A71D6D18921E6900F30AC0 /* luasocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4318921E6900F30AC0 /* luasocket.h */; }; 15A71D6E18921E6900F30AC0 /* luasocket_buffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4418921E6900F30AC0 /* luasocket_buffer.c */; }; 15A71D6F18921E6900F30AC0 /* luasocket_buffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4418921E6900F30AC0 /* luasocket_buffer.c */; }; 15A71D7018921E6900F30AC0 /* luasocket_buffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4518921E6900F30AC0 /* luasocket_buffer.h */; }; 15A71D7118921E6900F30AC0 /* luasocket_buffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4518921E6900F30AC0 /* luasocket_buffer.h */; }; 15A71D7218921E6900F30AC0 /* luasocket_io.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4618921E6900F30AC0 /* luasocket_io.c */; }; 15A71D7318921E6900F30AC0 /* luasocket_io.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4618921E6900F30AC0 /* luasocket_io.c */; }; 15A71D7418921E6900F30AC0 /* luasocket_io.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4718921E6900F30AC0 /* luasocket_io.h */; }; 15A71D7518921E6900F30AC0 /* luasocket_io.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4718921E6900F30AC0 /* luasocket_io.h */; }; 15A71D7618921E6900F30AC0 /* mime.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4818921E6900F30AC0 /* mime.c */; }; 15A71D7718921E6900F30AC0 /* mime.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4818921E6900F30AC0 /* mime.c */; }; 15A71D7818921E6900F30AC0 /* mime.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4918921E6900F30AC0 /* mime.h */; }; 15A71D7918921E6900F30AC0 /* mime.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4918921E6900F30AC0 /* mime.h */; }; 15A71D7A18921E6900F30AC0 /* options.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4A18921E6900F30AC0 /* options.c */; }; 15A71D7B18921E6900F30AC0 /* options.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4A18921E6900F30AC0 /* options.c */; }; 15A71D7C18921E6900F30AC0 /* options.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4B18921E6900F30AC0 /* options.h */; }; 15A71D7D18921E6900F30AC0 /* options.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4B18921E6900F30AC0 /* options.h */; }; 15A71D7E18921E6900F30AC0 /* select.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4C18921E6900F30AC0 /* select.c */; }; 15A71D7F18921E6900F30AC0 /* select.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4C18921E6900F30AC0 /* select.c */; }; 15A71D8018921E6900F30AC0 /* select.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4D18921E6900F30AC0 /* select.h */; }; 15A71D8118921E6900F30AC0 /* select.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4D18921E6900F30AC0 /* select.h */; }; 15A71D8218921E6900F30AC0 /* serial.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4E18921E6900F30AC0 /* serial.c */; }; 15A71D8318921E6900F30AC0 /* serial.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D4E18921E6900F30AC0 /* serial.c */; }; 15A71D8418921E6900F30AC0 /* socket.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4F18921E6900F30AC0 /* socket.h */; }; 15A71D8518921E6900F30AC0 /* socket.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D4F18921E6900F30AC0 /* socket.h */; }; 15A71D8618921E6900F30AC0 /* socket_scripts.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5018921E6900F30AC0 /* socket_scripts.c */; }; 15A71D8718921E6900F30AC0 /* socket_scripts.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5018921E6900F30AC0 /* socket_scripts.c */; }; 15A71D8818921E6900F30AC0 /* socket_scripts.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5118921E6900F30AC0 /* socket_scripts.h */; }; 15A71D8918921E6900F30AC0 /* socket_scripts.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5118921E6900F30AC0 /* socket_scripts.h */; }; 15A71D8A18921E6900F30AC0 /* tcp.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5218921E6900F30AC0 /* tcp.c */; }; 15A71D8B18921E6900F30AC0 /* tcp.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5218921E6900F30AC0 /* tcp.c */; }; 15A71D8C18921E6900F30AC0 /* tcp.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5318921E6900F30AC0 /* tcp.h */; }; 15A71D8D18921E6900F30AC0 /* tcp.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5318921E6900F30AC0 /* tcp.h */; }; 15A71D8E18921E6900F30AC0 /* timeout.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5418921E6900F30AC0 /* timeout.c */; }; 15A71D8F18921E6900F30AC0 /* timeout.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5418921E6900F30AC0 /* timeout.c */; }; 15A71D9018921E6900F30AC0 /* timeout.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5518921E6900F30AC0 /* timeout.h */; }; 15A71D9118921E6900F30AC0 /* timeout.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5518921E6900F30AC0 /* timeout.h */; }; 15A71D9218921E6900F30AC0 /* udp.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5618921E6900F30AC0 /* udp.c */; }; 15A71D9318921E6900F30AC0 /* udp.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5618921E6900F30AC0 /* udp.c */; }; 15A71D9418921E6900F30AC0 /* udp.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5718921E6900F30AC0 /* udp.h */; }; 15A71D9518921E6900F30AC0 /* udp.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5718921E6900F30AC0 /* udp.h */; }; 15A71D9618921E6900F30AC0 /* unix.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5818921E6900F30AC0 /* unix.c */; }; 15A71D9718921E6900F30AC0 /* unix.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5818921E6900F30AC0 /* unix.c */; }; 15A71D9818921E6900F30AC0 /* unix.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5918921E6900F30AC0 /* unix.h */; }; 15A71D9918921E6900F30AC0 /* unix.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5918921E6900F30AC0 /* unix.h */; }; 15A71D9A18921E6900F30AC0 /* usocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5A18921E6900F30AC0 /* usocket.c */; }; 15A71D9B18921E6900F30AC0 /* usocket.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71D5A18921E6900F30AC0 /* usocket.c */; }; 15A71D9C18921E6900F30AC0 /* usocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5B18921E6900F30AC0 /* usocket.h */; }; 15A71D9D18921E6900F30AC0 /* usocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5B18921E6900F30AC0 /* usocket.h */; }; 15A71DA018921E6900F30AC0 /* wsocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5D18921E6900F30AC0 /* wsocket.h */; }; 15A71DA118921E6900F30AC0 /* wsocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71D5D18921E6900F30AC0 /* wsocket.h */; }; 15A71DA41892291500F30AC0 /* lua_extensions.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71DA21892291500F30AC0 /* lua_extensions.c */; }; 15A71DA51892291500F30AC0 /* lua_extensions.c in Sources */ = {isa = PBXBuildFile; fileRef = 15A71DA21892291500F30AC0 /* lua_extensions.c */; }; 15A71DA61892291500F30AC0 /* lua_extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71DA31892291500F30AC0 /* lua_extensions.h */; }; 15A71DA71892291500F30AC0 /* lua_extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A71DA31892291500F30AC0 /* lua_extensions.h */; }; 15CA8D0D18697A56000032AB /* lua_cocos2dx_spine_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CA8D0B18697A56000032AB /* lua_cocos2dx_spine_manual.cpp */; }; 15CA8D0E18697A56000032AB /* lua_cocos2dx_spine_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CA8D0B18697A56000032AB /* lua_cocos2dx_spine_manual.cpp */; }; 15CA8D0F18697A56000032AB /* lua_cocos2dx_spine_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15CA8D0C18697A56000032AB /* lua_cocos2dx_spine_manual.hpp */; }; 15CA8D1018697A56000032AB /* lua_cocos2dx_spine_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15CA8D0C18697A56000032AB /* lua_cocos2dx_spine_manual.hpp */; }; 15CA8D1318697AE1000032AB /* lua_cocos2dx_spine_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CA8D1118697AE1000032AB /* lua_cocos2dx_spine_auto.cpp */; }; 15CA8D1418697AE1000032AB /* lua_cocos2dx_spine_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CA8D1118697AE1000032AB /* lua_cocos2dx_spine_auto.cpp */; }; 15CA8D1518697AE1000032AB /* lua_cocos2dx_spine_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15CA8D1218697AE1000032AB /* lua_cocos2dx_spine_auto.hpp */; }; 15CA8D1618697AE1000032AB /* lua_cocos2dx_spine_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15CA8D1218697AE1000032AB /* lua_cocos2dx_spine_auto.hpp */; }; 15CA8D1918697BE5000032AB /* LuaSkeletonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CA8D1718697BE5000032AB /* LuaSkeletonAnimation.cpp */; }; 15CA8D1A18697BE5000032AB /* LuaSkeletonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15CA8D1718697BE5000032AB /* LuaSkeletonAnimation.cpp */; }; 15CA8D1B18697BE5000032AB /* LuaSkeletonAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CA8D1818697BE5000032AB /* LuaSkeletonAnimation.h */; }; 15CA8D1C18697BE5000032AB /* LuaSkeletonAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CA8D1818697BE5000032AB /* LuaSkeletonAnimation.h */; }; 15D6E845182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15D6E843182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.cpp */; }; 15D6E846182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15D6E843182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.cpp */; }; 15D6E847182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15D6E844182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.hpp */; }; 15D6E848182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15D6E844182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.hpp */; }; 15F4C8821875637D0082884F /* lua_cocos2dx_gui_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15F4C8801875637D0082884F /* lua_cocos2dx_gui_auto.cpp */; }; 15F4C8831875637D0082884F /* lua_cocos2dx_gui_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15F4C8801875637D0082884F /* lua_cocos2dx_gui_auto.cpp */; }; 15F4C8841875637D0082884F /* lua_cocos2dx_gui_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15F4C8811875637D0082884F /* lua_cocos2dx_gui_auto.hpp */; }; 15F4C8851875637D0082884F /* lua_cocos2dx_gui_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15F4C8811875637D0082884F /* lua_cocos2dx_gui_auto.hpp */; }; 15F4CA1F1875885A0082884F /* lua_cocos2dx_gui_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15F4CA1D1875885A0082884F /* lua_cocos2dx_gui_manual.cpp */; }; 15F4CA201875885A0082884F /* lua_cocos2dx_gui_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15F4CA1D1875885A0082884F /* lua_cocos2dx_gui_manual.cpp */; }; 15F4CA211875885A0082884F /* lua_cocos2dx_gui_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15F4CA1E1875885A0082884F /* lua_cocos2dx_gui_manual.hpp */; }; 15F4CA221875885A0082884F /* lua_cocos2dx_gui_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15F4CA1E1875885A0082884F /* lua_cocos2dx_gui_manual.hpp */; }; 1A087AE81860400400196EF5 /* edtaa3func.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A087AE61860400400196EF5 /* edtaa3func.cpp */; }; 1A087AE91860400400196EF5 /* edtaa3func.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A087AE61860400400196EF5 /* edtaa3func.cpp */; }; 1A087AEA1860400400196EF5 /* edtaa3func.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A087AE71860400400196EF5 /* edtaa3func.h */; }; 1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A087AE71860400400196EF5 /* edtaa3func.h */; }; 1A0DB7321823827C0025743D /* CCGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0DB7301823827C0025743D /* CCGL.h */; }; 1A0DB7331823827C0025743D /* EAGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0DB7311823827C0025743D /* EAGLView.h */; }; 1A0DB7381823828F0025743D /* CCGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0DB7351823828F0025743D /* CCGL.h */; }; 1A2C7872181A11EC004E5527 /* jsb_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C785E181A11EC004E5527 /* jsb_cocos2dx_auto.cpp */; }; 1A2C7874181A11EC004E5527 /* jsb_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C785E181A11EC004E5527 /* jsb_cocos2dx_auto.cpp */; }; 1A2C7876181A11EC004E5527 /* jsb_cocos2dx_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C785F181A11EC004E5527 /* jsb_cocos2dx_auto.hpp */; }; 1A2C7878181A11EC004E5527 /* jsb_cocos2dx_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C785F181A11EC004E5527 /* jsb_cocos2dx_auto.hpp */; }; 1A2C787E181A11EC004E5527 /* jsb_cocos2dx_builder_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C7861181A11EC004E5527 /* jsb_cocos2dx_builder_auto.cpp */; }; 1A2C7880181A11EC004E5527 /* jsb_cocos2dx_builder_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C7861181A11EC004E5527 /* jsb_cocos2dx_builder_auto.cpp */; }; 1A2C7882181A11EC004E5527 /* jsb_cocos2dx_builder_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7862181A11EC004E5527 /* jsb_cocos2dx_builder_auto.hpp */; }; 1A2C7884181A11EC004E5527 /* jsb_cocos2dx_builder_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7862181A11EC004E5527 /* jsb_cocos2dx_builder_auto.hpp */; }; 1A2C788A181A11EC004E5527 /* jsb_cocos2dx_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C7864181A11EC004E5527 /* jsb_cocos2dx_extension_auto.cpp */; }; 1A2C788C181A11EC004E5527 /* jsb_cocos2dx_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C7864181A11EC004E5527 /* jsb_cocos2dx_extension_auto.cpp */; }; 1A2C788E181A11EC004E5527 /* jsb_cocos2dx_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7865181A11EC004E5527 /* jsb_cocos2dx_extension_auto.hpp */; }; 1A2C7890181A11EC004E5527 /* jsb_cocos2dx_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7865181A11EC004E5527 /* jsb_cocos2dx_extension_auto.hpp */; }; 1A2C7896181A11EC004E5527 /* jsb_cocos2dx_studio_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C7867181A11EC004E5527 /* jsb_cocos2dx_studio_auto.cpp */; }; 1A2C7898181A11EC004E5527 /* jsb_cocos2dx_studio_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C7867181A11EC004E5527 /* jsb_cocos2dx_studio_auto.cpp */; }; 1A2C789A181A11EC004E5527 /* jsb_cocos2dx_studio_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7868181A11EC004E5527 /* jsb_cocos2dx_studio_auto.hpp */; }; 1A2C789C181A11EC004E5527 /* jsb_cocos2dx_studio_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7868181A11EC004E5527 /* jsb_cocos2dx_studio_auto.hpp */; }; 1A2C78A3181A11EC004E5527 /* lua_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C786B181A11EC004E5527 /* lua_cocos2dx_auto.cpp */; }; 1A2C78A5181A11EC004E5527 /* lua_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C786B181A11EC004E5527 /* lua_cocos2dx_auto.cpp */; }; 1A2C78A7181A11EC004E5527 /* lua_cocos2dx_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C786C181A11EC004E5527 /* lua_cocos2dx_auto.hpp */; }; 1A2C78A9181A11EC004E5527 /* lua_cocos2dx_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C786C181A11EC004E5527 /* lua_cocos2dx_auto.hpp */; }; 1A2C78AF181A11EC004E5527 /* lua_cocos2dx_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C786E181A11EC004E5527 /* lua_cocos2dx_extension_auto.cpp */; }; 1A2C78B1181A11EC004E5527 /* lua_cocos2dx_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C786E181A11EC004E5527 /* lua_cocos2dx_extension_auto.cpp */; }; 1A2C78B3181A11EC004E5527 /* lua_cocos2dx_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C786F181A11EC004E5527 /* lua_cocos2dx_extension_auto.hpp */; }; 1A2C78B5181A11EC004E5527 /* lua_cocos2dx_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C786F181A11EC004E5527 /* lua_cocos2dx_extension_auto.hpp */; }; 1A2C790D181A1257004E5527 /* js_bindings_chipmunk_auto_classes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78BE181A1257004E5527 /* js_bindings_chipmunk_auto_classes.cpp */; }; 1A2C790E181A1257004E5527 /* js_bindings_chipmunk_auto_classes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78BE181A1257004E5527 /* js_bindings_chipmunk_auto_classes.cpp */; }; 1A2C790F181A1257004E5527 /* js_bindings_chipmunk_auto_classes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78BF181A1257004E5527 /* js_bindings_chipmunk_auto_classes.h */; }; 1A2C7910181A1257004E5527 /* js_bindings_chipmunk_auto_classes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78BF181A1257004E5527 /* js_bindings_chipmunk_auto_classes.h */; }; 1A2C7911181A1257004E5527 /* js_bindings_chipmunk_auto_classes_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C0181A1257004E5527 /* js_bindings_chipmunk_auto_classes_registration.h */; }; 1A2C7912181A1257004E5527 /* js_bindings_chipmunk_auto_classes_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C0181A1257004E5527 /* js_bindings_chipmunk_auto_classes_registration.h */; }; 1A2C7913181A1257004E5527 /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78C1181A1257004E5527 /* js_bindings_chipmunk_functions.cpp */; }; 1A2C7914181A1257004E5527 /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78C1181A1257004E5527 /* js_bindings_chipmunk_functions.cpp */; }; 1A2C7915181A1257004E5527 /* js_bindings_chipmunk_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C2181A1257004E5527 /* js_bindings_chipmunk_functions.h */; }; 1A2C7916181A1257004E5527 /* js_bindings_chipmunk_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C2181A1257004E5527 /* js_bindings_chipmunk_functions.h */; }; 1A2C7917181A1257004E5527 /* js_bindings_chipmunk_functions_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C3181A1257004E5527 /* js_bindings_chipmunk_functions_registration.h */; }; 1A2C7918181A1257004E5527 /* js_bindings_chipmunk_functions_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C3181A1257004E5527 /* js_bindings_chipmunk_functions_registration.h */; }; 1A2C7919181A1257004E5527 /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78C4181A1257004E5527 /* js_bindings_chipmunk_manual.cpp */; }; 1A2C791A181A1257004E5527 /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78C4181A1257004E5527 /* js_bindings_chipmunk_manual.cpp */; }; 1A2C791B181A1257004E5527 /* js_bindings_chipmunk_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C5181A1257004E5527 /* js_bindings_chipmunk_manual.h */; }; 1A2C791C181A1257004E5527 /* js_bindings_chipmunk_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C5181A1257004E5527 /* js_bindings_chipmunk_manual.h */; }; 1A2C791D181A1257004E5527 /* js_bindings_chipmunk_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78C6181A1257004E5527 /* js_bindings_chipmunk_registration.cpp */; }; 1A2C791E181A1257004E5527 /* js_bindings_chipmunk_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78C6181A1257004E5527 /* js_bindings_chipmunk_registration.cpp */; }; 1A2C791F181A1257004E5527 /* js_bindings_chipmunk_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C7181A1257004E5527 /* js_bindings_chipmunk_registration.h */; }; 1A2C7920181A1257004E5527 /* js_bindings_chipmunk_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78C7181A1257004E5527 /* js_bindings_chipmunk_registration.h */; }; 1A2C7921181A1257004E5527 /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78CB181A1257004E5527 /* cocos2d_specifics.cpp */; }; 1A2C7922181A1257004E5527 /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78CB181A1257004E5527 /* cocos2d_specifics.cpp */; }; 1A2C7923181A1257004E5527 /* cocos2d_specifics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78CC181A1257004E5527 /* cocos2d_specifics.hpp */; }; 1A2C7924181A1257004E5527 /* cocos2d_specifics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78CC181A1257004E5527 /* cocos2d_specifics.hpp */; }; 1A2C7925181A1257004E5527 /* cocosbuilder_specifics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78CF181A1257004E5527 /* cocosbuilder_specifics.hpp */; }; 1A2C7926181A1257004E5527 /* cocosbuilder_specifics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78CF181A1257004E5527 /* cocosbuilder_specifics.hpp */; }; 1A2C7927181A1257004E5527 /* js_bindings_ccbreader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78D0181A1257004E5527 /* js_bindings_ccbreader.cpp */; }; 1A2C7928181A1257004E5527 /* js_bindings_ccbreader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78D0181A1257004E5527 /* js_bindings_ccbreader.cpp */; }; 1A2C7929181A1257004E5527 /* js_bindings_ccbreader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78D1181A1257004E5527 /* js_bindings_ccbreader.h */; }; 1A2C792A181A1257004E5527 /* js_bindings_ccbreader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78D1181A1257004E5527 /* js_bindings_ccbreader.h */; }; 1A2C792F181A1257004E5527 /* jsb_cocos2dx_studio_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78D9181A1257004E5527 /* jsb_cocos2dx_studio_manual.cpp */; }; 1A2C7930181A1257004E5527 /* jsb_cocos2dx_studio_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78D9181A1257004E5527 /* jsb_cocos2dx_studio_manual.cpp */; }; 1A2C7931181A1257004E5527 /* jsb_cocos2dx_studio_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78DA181A1257004E5527 /* jsb_cocos2dx_studio_manual.h */; }; 1A2C7932181A1257004E5527 /* jsb_cocos2dx_studio_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78DA181A1257004E5527 /* jsb_cocos2dx_studio_manual.h */; }; 1A2C7933181A1257004E5527 /* jsb_cocos2dx_extension_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78E0181A1257004E5527 /* jsb_cocos2dx_extension_manual.cpp */; }; 1A2C7934181A1257004E5527 /* jsb_cocos2dx_extension_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78E0181A1257004E5527 /* jsb_cocos2dx_extension_manual.cpp */; }; 1A2C7935181A1257004E5527 /* jsb_cocos2dx_extension_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78E1181A1257004E5527 /* jsb_cocos2dx_extension_manual.h */; }; 1A2C7936181A1257004E5527 /* jsb_cocos2dx_extension_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78E1181A1257004E5527 /* jsb_cocos2dx_extension_manual.h */; }; 1A2C7937181A1257004E5527 /* js_bindings_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78E5181A1257004E5527 /* js_bindings_config.h */; }; 1A2C7938181A1257004E5527 /* js_bindings_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78E5181A1257004E5527 /* js_bindings_config.h */; }; 1A2C7939181A1257004E5527 /* js_bindings_core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78E6181A1257004E5527 /* js_bindings_core.cpp */; }; 1A2C793A181A1257004E5527 /* js_bindings_core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78E6181A1257004E5527 /* js_bindings_core.cpp */; }; 1A2C793B181A1257004E5527 /* js_bindings_core.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78E7181A1257004E5527 /* js_bindings_core.h */; }; 1A2C793C181A1257004E5527 /* js_bindings_core.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78E7181A1257004E5527 /* js_bindings_core.h */; }; 1A2C793D181A1257004E5527 /* js_bindings_opengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78E8181A1257004E5527 /* js_bindings_opengl.cpp */; }; 1A2C793E181A1257004E5527 /* js_bindings_opengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78E8181A1257004E5527 /* js_bindings_opengl.cpp */; }; 1A2C793F181A1257004E5527 /* js_bindings_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78E9181A1257004E5527 /* js_bindings_opengl.h */; }; 1A2C7940181A1257004E5527 /* js_bindings_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78E9181A1257004E5527 /* js_bindings_opengl.h */; }; 1A2C7941181A1257004E5527 /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78EA181A1257004E5527 /* js_manual_conversions.cpp */; }; 1A2C7942181A1257004E5527 /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78EA181A1257004E5527 /* js_manual_conversions.cpp */; }; 1A2C7943181A1257004E5527 /* js_manual_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78EB181A1257004E5527 /* js_manual_conversions.h */; }; 1A2C7944181A1257004E5527 /* js_manual_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78EB181A1257004E5527 /* js_manual_conversions.h */; }; 1A2C7945181A1257004E5527 /* jsb_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78EC181A1257004E5527 /* jsb_helper.h */; }; 1A2C7946181A1257004E5527 /* jsb_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78EC181A1257004E5527 /* jsb_helper.h */; }; 1A2C7947181A1257004E5527 /* jsb_opengl_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78ED181A1257004E5527 /* jsb_opengl_functions.cpp */; }; 1A2C7948181A1257004E5527 /* jsb_opengl_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78ED181A1257004E5527 /* jsb_opengl_functions.cpp */; }; 1A2C7949181A1257004E5527 /* jsb_opengl_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78EE181A1257004E5527 /* jsb_opengl_functions.h */; }; 1A2C794A181A1257004E5527 /* jsb_opengl_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78EE181A1257004E5527 /* jsb_opengl_functions.h */; }; 1A2C794B181A1257004E5527 /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78EF181A1257004E5527 /* jsb_opengl_manual.cpp */; }; 1A2C794C181A1257004E5527 /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78EF181A1257004E5527 /* jsb_opengl_manual.cpp */; }; 1A2C794D181A1257004E5527 /* jsb_opengl_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F0181A1257004E5527 /* jsb_opengl_manual.h */; }; 1A2C794E181A1257004E5527 /* jsb_opengl_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F0181A1257004E5527 /* jsb_opengl_manual.h */; }; 1A2C794F181A1257004E5527 /* jsb_opengl_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78F1181A1257004E5527 /* jsb_opengl_registration.cpp */; }; 1A2C7950181A1257004E5527 /* jsb_opengl_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78F1181A1257004E5527 /* jsb_opengl_registration.cpp */; }; 1A2C7951181A1257004E5527 /* jsb_opengl_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F2181A1257004E5527 /* jsb_opengl_registration.h */; }; 1A2C7952181A1257004E5527 /* jsb_opengl_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F2181A1257004E5527 /* jsb_opengl_registration.h */; }; 1A2C7953181A1257004E5527 /* js_bindings_system_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78F5181A1257004E5527 /* js_bindings_system_functions.cpp */; }; 1A2C7954181A1257004E5527 /* js_bindings_system_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78F5181A1257004E5527 /* js_bindings_system_functions.cpp */; }; 1A2C7955181A1257004E5527 /* js_bindings_system_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F6181A1257004E5527 /* js_bindings_system_functions.h */; }; 1A2C7956181A1257004E5527 /* js_bindings_system_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F6181A1257004E5527 /* js_bindings_system_functions.h */; }; 1A2C7957181A1257004E5527 /* js_bindings_system_functions_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F7181A1257004E5527 /* js_bindings_system_functions_registration.h */; }; 1A2C7958181A1257004E5527 /* js_bindings_system_functions_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F7181A1257004E5527 /* js_bindings_system_functions_registration.h */; }; 1A2C7959181A1257004E5527 /* js_bindings_system_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78F8181A1257004E5527 /* js_bindings_system_registration.cpp */; }; 1A2C795A181A1257004E5527 /* js_bindings_system_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78F8181A1257004E5527 /* js_bindings_system_registration.cpp */; }; 1A2C795B181A1257004E5527 /* js_bindings_system_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F9181A1257004E5527 /* js_bindings_system_registration.h */; }; 1A2C795C181A1257004E5527 /* js_bindings_system_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C78F9181A1257004E5527 /* js_bindings_system_registration.h */; }; 1A2C795D181A1257004E5527 /* jsb_websocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78FF181A1257004E5527 /* jsb_websocket.cpp */; }; 1A2C795E181A1257004E5527 /* jsb_websocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C78FF181A1257004E5527 /* jsb_websocket.cpp */; }; 1A2C795F181A1257004E5527 /* jsb_websocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7900181A1257004E5527 /* jsb_websocket.h */; }; 1A2C7960181A1257004E5527 /* jsb_websocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7900181A1257004E5527 /* jsb_websocket.h */; }; 1A2C7961181A1257004E5527 /* XMLHTTPRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C7904181A1257004E5527 /* XMLHTTPRequest.cpp */; }; 1A2C7962181A1257004E5527 /* XMLHTTPRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C7904181A1257004E5527 /* XMLHTTPRequest.cpp */; }; 1A2C7963181A1257004E5527 /* XMLHTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7905181A1257004E5527 /* XMLHTTPRequest.h */; }; 1A2C7964181A1257004E5527 /* XMLHTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C7905181A1257004E5527 /* XMLHTTPRequest.h */; }; 1A2C7965181A1257004E5527 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C790A181A1257004E5527 /* ScriptingCore.cpp */; }; 1A2C7966181A1257004E5527 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C790A181A1257004E5527 /* ScriptingCore.cpp */; }; 1A2C7967181A1257004E5527 /* ScriptingCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C790B181A1257004E5527 /* ScriptingCore.h */; }; 1A2C7968181A1257004E5527 /* ScriptingCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C790B181A1257004E5527 /* ScriptingCore.h */; }; 1A2C7969181A1257004E5527 /* spidermonkey_specifics.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C790C181A1257004E5527 /* spidermonkey_specifics.h */; }; 1A2C796A181A1257004E5527 /* spidermonkey_specifics.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2C790C181A1257004E5527 /* spidermonkey_specifics.h */; }; 1A3B1F78180E88C300497A22 /* CCBProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F4E180E88C200497A22 /* CCBProxy.cpp */; }; 1A3B1F79180E88C300497A22 /* CCBProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F4E180E88C200497A22 /* CCBProxy.cpp */; }; 1A3B1F7A180E88C300497A22 /* CCBProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F4F180E88C200497A22 /* CCBProxy.h */; }; 1A3B1F7B180E88C300497A22 /* CCBProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F4F180E88C200497A22 /* CCBProxy.h */; }; 1A3B1F7C180E88C300497A22 /* CCLuaBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F50180E88C200497A22 /* CCLuaBridge.cpp */; }; 1A3B1F7D180E88C300497A22 /* CCLuaBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F50180E88C200497A22 /* CCLuaBridge.cpp */; }; 1A3B1F7E180E88C300497A22 /* CCLuaBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F51180E88C200497A22 /* CCLuaBridge.h */; }; 1A3B1F7F180E88C300497A22 /* CCLuaBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F51180E88C200497A22 /* CCLuaBridge.h */; }; 1A3B1F80180E88C300497A22 /* CCLuaEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F52180E88C200497A22 /* CCLuaEngine.cpp */; }; 1A3B1F81180E88C300497A22 /* CCLuaEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F52180E88C200497A22 /* CCLuaEngine.cpp */; }; 1A3B1F82180E88C300497A22 /* CCLuaEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F53180E88C200497A22 /* CCLuaEngine.h */; }; 1A3B1F83180E88C300497A22 /* CCLuaEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F53180E88C200497A22 /* CCLuaEngine.h */; }; 1A3B1F84180E88C300497A22 /* CCLuaStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F54180E88C200497A22 /* CCLuaStack.cpp */; }; 1A3B1F85180E88C300497A22 /* CCLuaStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F54180E88C200497A22 /* CCLuaStack.cpp */; }; 1A3B1F86180E88C300497A22 /* CCLuaStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F55180E88C200497A22 /* CCLuaStack.h */; }; 1A3B1F87180E88C300497A22 /* CCLuaStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F55180E88C200497A22 /* CCLuaStack.h */; }; 1A3B1F88180E88C300497A22 /* CCLuaValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F56180E88C300497A22 /* CCLuaValue.cpp */; }; 1A3B1F89180E88C300497A22 /* CCLuaValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F56180E88C300497A22 /* CCLuaValue.cpp */; }; 1A3B1F8A180E88C300497A22 /* CCLuaValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F57180E88C300497A22 /* CCLuaValue.h */; }; 1A3B1F8B180E88C300497A22 /* CCLuaValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F57180E88C300497A22 /* CCLuaValue.h */; }; 1A3B1F8C180E88C300497A22 /* Cocos2dxLuaLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F58180E88C300497A22 /* Cocos2dxLuaLoader.cpp */; }; 1A3B1F8D180E88C300497A22 /* Cocos2dxLuaLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F58180E88C300497A22 /* Cocos2dxLuaLoader.cpp */; }; 1A3B1F8E180E88C300497A22 /* Cocos2dxLuaLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F59180E88C300497A22 /* Cocos2dxLuaLoader.h */; }; 1A3B1F8F180E88C300497A22 /* Cocos2dxLuaLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F59180E88C300497A22 /* Cocos2dxLuaLoader.h */; }; 1A3B1F90180E88C300497A22 /* lua_cocos2dx_deprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F5D180E88C300497A22 /* lua_cocos2dx_deprecated.cpp */; }; 1A3B1F91180E88C300497A22 /* lua_cocos2dx_deprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F5D180E88C300497A22 /* lua_cocos2dx_deprecated.cpp */; }; 1A3B1F92180E88C300497A22 /* lua_cocos2dx_deprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F5E180E88C300497A22 /* lua_cocos2dx_deprecated.h */; }; 1A3B1F93180E88C300497A22 /* lua_cocos2dx_deprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F5E180E88C300497A22 /* lua_cocos2dx_deprecated.h */; }; 1A3B1F94180E88C300497A22 /* lua_cocos2dx_extension_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F5F180E88C300497A22 /* lua_cocos2dx_extension_manual.cpp */; }; 1A3B1F95180E88C300497A22 /* lua_cocos2dx_extension_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F5F180E88C300497A22 /* lua_cocos2dx_extension_manual.cpp */; }; 1A3B1F96180E88C300497A22 /* lua_cocos2dx_extension_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F60180E88C300497A22 /* lua_cocos2dx_extension_manual.h */; }; 1A3B1F97180E88C300497A22 /* lua_cocos2dx_extension_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F60180E88C300497A22 /* lua_cocos2dx_extension_manual.h */; }; 1A3B1F98180E88C300497A22 /* lua_cocos2dx_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F61180E88C300497A22 /* lua_cocos2dx_manual.cpp */; }; 1A3B1F99180E88C300497A22 /* lua_cocos2dx_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F61180E88C300497A22 /* lua_cocos2dx_manual.cpp */; }; 1A3B1F9A180E88C300497A22 /* lua_cocos2dx_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F62180E88C300497A22 /* lua_cocos2dx_manual.hpp */; }; 1A3B1F9B180E88C300497A22 /* lua_cocos2dx_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F62180E88C300497A22 /* lua_cocos2dx_manual.hpp */; }; 1A3B1F9C180E88C300497A22 /* Lua_web_socket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F63180E88C300497A22 /* Lua_web_socket.cpp */; }; 1A3B1F9D180E88C300497A22 /* Lua_web_socket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F63180E88C300497A22 /* Lua_web_socket.cpp */; }; 1A3B1F9E180E88C300497A22 /* Lua_web_socket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F64180E88C300497A22 /* Lua_web_socket.h */; }; 1A3B1F9F180E88C300497A22 /* Lua_web_socket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F64180E88C300497A22 /* Lua_web_socket.h */; }; 1A3B1FA0180E88C300497A22 /* LuaBasicConversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F65180E88C300497A22 /* LuaBasicConversions.cpp */; }; 1A3B1FA1180E88C300497A22 /* LuaBasicConversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F65180E88C300497A22 /* LuaBasicConversions.cpp */; }; 1A3B1FA2180E88C300497A22 /* LuaBasicConversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F66180E88C300497A22 /* LuaBasicConversions.h */; }; 1A3B1FA3180E88C300497A22 /* LuaBasicConversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F66180E88C300497A22 /* LuaBasicConversions.h */; }; 1A3B1FA4180E88C300497A22 /* LuaOpengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F67180E88C300497A22 /* LuaOpengl.cpp */; }; 1A3B1FA5180E88C300497A22 /* LuaOpengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F67180E88C300497A22 /* LuaOpengl.cpp */; }; 1A3B1FA6180E88C300497A22 /* LuaOpengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F68180E88C300497A22 /* LuaOpengl.h */; }; 1A3B1FA7180E88C300497A22 /* LuaOpengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F68180E88C300497A22 /* LuaOpengl.h */; }; 1A3B1FA8180E88C300497A22 /* LuaScriptHandlerMgr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F69180E88C300497A22 /* LuaScriptHandlerMgr.cpp */; }; 1A3B1FA9180E88C300497A22 /* LuaScriptHandlerMgr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F69180E88C300497A22 /* LuaScriptHandlerMgr.cpp */; }; 1A3B1FAA180E88C300497A22 /* LuaScriptHandlerMgr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F6A180E88C300497A22 /* LuaScriptHandlerMgr.h */; }; 1A3B1FAB180E88C300497A22 /* LuaScriptHandlerMgr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F6A180E88C300497A22 /* LuaScriptHandlerMgr.h */; }; 1A3B1FB6180E88C300497A22 /* CCLuaObjcBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F74180E88C300497A22 /* CCLuaObjcBridge.h */; }; 1A3B1FB7180E88C300497A22 /* CCLuaObjcBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F74180E88C300497A22 /* CCLuaObjcBridge.h */; }; 1A3B1FB8180E88C300497A22 /* CCLuaObjcBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F75180E88C300497A22 /* CCLuaObjcBridge.mm */; }; 1A3B1FB9180E88C300497A22 /* CCLuaObjcBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F75180E88C300497A22 /* CCLuaObjcBridge.mm */; }; 1A3B1FBA180E88C300497A22 /* tolua_fix.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F76180E88C300497A22 /* tolua_fix.c */; }; 1A3B1FBB180E88C300497A22 /* tolua_fix.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F76180E88C300497A22 /* tolua_fix.c */; }; 1A3B1FBC180E88C300497A22 /* tolua_fix.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F77180E88C300497A22 /* tolua_fix.h */; }; 1A3B1FBD180E88C300497A22 /* tolua_fix.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3B1F77180E88C300497A22 /* tolua_fix.h */; }; 1A570061180BC5A10088DEC7 /* CCAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570047180BC5A10088DEC7 /* CCAction.cpp */; }; 1A570062180BC5A10088DEC7 /* CCAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570047180BC5A10088DEC7 /* CCAction.cpp */; }; 1A570063180BC5A10088DEC7 /* CCAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570048180BC5A10088DEC7 /* CCAction.h */; }; 1A570064180BC5A10088DEC7 /* CCAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570048180BC5A10088DEC7 /* CCAction.h */; }; 1A570065180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570049180BC5A10088DEC7 /* CCActionCamera.cpp */; }; 1A570066180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570049180BC5A10088DEC7 /* CCActionCamera.cpp */; }; 1A570067180BC5A10088DEC7 /* CCActionCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57004A180BC5A10088DEC7 /* CCActionCamera.h */; }; 1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57004A180BC5A10088DEC7 /* CCActionCamera.h */; }; 1A570069180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57004B180BC5A10088DEC7 /* CCActionCatmullRom.cpp */; }; 1A57006A180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57004B180BC5A10088DEC7 /* CCActionCatmullRom.cpp */; }; 1A57006B180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57004C180BC5A10088DEC7 /* CCActionCatmullRom.h */; }; 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57004C180BC5A10088DEC7 /* CCActionCatmullRom.h */; }; 1A57006D180BC5A10088DEC7 /* CCActionEase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57004D180BC5A10088DEC7 /* CCActionEase.cpp */; }; 1A57006E180BC5A10088DEC7 /* CCActionEase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57004D180BC5A10088DEC7 /* CCActionEase.cpp */; }; 1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57004E180BC5A10088DEC7 /* CCActionEase.h */; }; 1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57004E180BC5A10088DEC7 /* CCActionEase.h */; }; 1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57004F180BC5A10088DEC7 /* CCActionGrid.cpp */; }; 1A570072180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57004F180BC5A10088DEC7 /* CCActionGrid.cpp */; }; 1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570050180BC5A10088DEC7 /* CCActionGrid.h */; }; 1A570074180BC5A10088DEC7 /* CCActionGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570050180BC5A10088DEC7 /* CCActionGrid.h */; }; 1A570075180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570051180BC5A10088DEC7 /* CCActionGrid3D.cpp */; }; 1A570076180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570051180BC5A10088DEC7 /* CCActionGrid3D.cpp */; }; 1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570052180BC5A10088DEC7 /* CCActionGrid3D.h */; }; 1A570078180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570052180BC5A10088DEC7 /* CCActionGrid3D.h */; }; 1A570079180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570053180BC5A10088DEC7 /* CCActionInstant.cpp */; }; 1A57007A180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570053180BC5A10088DEC7 /* CCActionInstant.cpp */; }; 1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570054180BC5A10088DEC7 /* CCActionInstant.h */; }; 1A57007C180BC5A10088DEC7 /* CCActionInstant.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570054180BC5A10088DEC7 /* CCActionInstant.h */; }; 1A57007D180BC5A10088DEC7 /* CCActionInterval.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570055180BC5A10088DEC7 /* CCActionInterval.cpp */; }; 1A57007E180BC5A10088DEC7 /* CCActionInterval.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570055180BC5A10088DEC7 /* CCActionInterval.cpp */; }; 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570056180BC5A10088DEC7 /* CCActionInterval.h */; }; 1A570080180BC5A10088DEC7 /* CCActionInterval.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570056180BC5A10088DEC7 /* CCActionInterval.h */; }; 1A570081180BC5A10088DEC7 /* CCActionManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570057180BC5A10088DEC7 /* CCActionManager.cpp */; }; 1A570082180BC5A10088DEC7 /* CCActionManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570057180BC5A10088DEC7 /* CCActionManager.cpp */; }; 1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570058180BC5A10088DEC7 /* CCActionManager.h */; }; 1A570084180BC5A10088DEC7 /* CCActionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570058180BC5A10088DEC7 /* CCActionManager.h */; }; 1A570085180BC5A10088DEC7 /* CCActionPageTurn3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570059180BC5A10088DEC7 /* CCActionPageTurn3D.cpp */; }; 1A570086180BC5A10088DEC7 /* CCActionPageTurn3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570059180BC5A10088DEC7 /* CCActionPageTurn3D.cpp */; }; 1A570087180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57005A180BC5A10088DEC7 /* CCActionPageTurn3D.h */; }; 1A570088180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57005A180BC5A10088DEC7 /* CCActionPageTurn3D.h */; }; 1A570089180BC5A10088DEC7 /* CCActionProgressTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57005B180BC5A10088DEC7 /* CCActionProgressTimer.cpp */; }; 1A57008A180BC5A10088DEC7 /* CCActionProgressTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57005B180BC5A10088DEC7 /* CCActionProgressTimer.cpp */; }; 1A57008B180BC5A10088DEC7 /* CCActionProgressTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57005C180BC5A10088DEC7 /* CCActionProgressTimer.h */; }; 1A57008C180BC5A10088DEC7 /* CCActionProgressTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57005C180BC5A10088DEC7 /* CCActionProgressTimer.h */; }; 1A57008D180BC5A10088DEC7 /* CCActionTiledGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57005D180BC5A10088DEC7 /* CCActionTiledGrid.cpp */; }; 1A57008E180BC5A10088DEC7 /* CCActionTiledGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57005D180BC5A10088DEC7 /* CCActionTiledGrid.cpp */; }; 1A57008F180BC5A10088DEC7 /* CCActionTiledGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57005E180BC5A10088DEC7 /* CCActionTiledGrid.h */; }; 1A570090180BC5A10088DEC7 /* CCActionTiledGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57005E180BC5A10088DEC7 /* CCActionTiledGrid.h */; }; 1A570091180BC5A10088DEC7 /* CCActionTween.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57005F180BC5A10088DEC7 /* CCActionTween.cpp */; }; 1A570092180BC5A10088DEC7 /* CCActionTween.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57005F180BC5A10088DEC7 /* CCActionTween.cpp */; }; 1A570093180BC5A10088DEC7 /* CCActionTween.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570060180BC5A10088DEC7 /* CCActionTween.h */; }; 1A570094180BC5A10088DEC7 /* CCActionTween.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570060180BC5A10088DEC7 /* CCActionTween.h */; }; 1A570098180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570096180BC5C10088DEC7 /* CCAtlasNode.cpp */; }; 1A570099180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570096180BC5C10088DEC7 /* CCAtlasNode.cpp */; }; 1A57009A180BC5C10088DEC7 /* CCAtlasNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570097180BC5C10088DEC7 /* CCAtlasNode.h */; }; 1A57009B180BC5C10088DEC7 /* CCAtlasNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570097180BC5C10088DEC7 /* CCAtlasNode.h */; }; 1A57009E180BC5D20088DEC7 /* CCNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57009C180BC5D20088DEC7 /* CCNode.cpp */; }; 1A57009F180BC5D20088DEC7 /* CCNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57009C180BC5D20088DEC7 /* CCNode.cpp */; }; 1A5700A0180BC5D20088DEC7 /* CCNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57009D180BC5D20088DEC7 /* CCNode.h */; }; 1A5700A1180BC5D20088DEC7 /* CCNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57009D180BC5D20088DEC7 /* CCNode.h */; }; 1A5700C5180BC6060088DEC7 /* atitc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700A3180BC6060088DEC7 /* atitc.cpp */; }; 1A5700C6180BC6060088DEC7 /* atitc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700A3180BC6060088DEC7 /* atitc.cpp */; }; 1A5700C7180BC6060088DEC7 /* atitc.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700A4180BC6060088DEC7 /* atitc.h */; }; 1A5700C8180BC6060088DEC7 /* atitc.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700A4180BC6060088DEC7 /* atitc.h */; }; 1A5700C9180BC6060088DEC7 /* CCAffineTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700A5180BC6060088DEC7 /* CCAffineTransform.cpp */; }; 1A5700CA180BC6060088DEC7 /* CCAffineTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700A5180BC6060088DEC7 /* CCAffineTransform.cpp */; }; 1A5700CB180BC6060088DEC7 /* CCAffineTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700A6180BC6060088DEC7 /* CCAffineTransform.h */; }; 1A5700CC180BC6060088DEC7 /* CCAffineTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700A6180BC6060088DEC7 /* CCAffineTransform.h */; }; 1A5700CD180BC6060088DEC7 /* CCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700A7180BC6060088DEC7 /* CCArray.cpp */; }; 1A5700CE180BC6060088DEC7 /* CCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700A7180BC6060088DEC7 /* CCArray.cpp */; }; 1A5700CF180BC6060088DEC7 /* CCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700A8180BC6060088DEC7 /* CCArray.h */; }; 1A5700D0180BC6060088DEC7 /* CCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700A8180BC6060088DEC7 /* CCArray.h */; }; 1A5700D1180BC6060088DEC7 /* CCAutoreleasePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700A9180BC6060088DEC7 /* CCAutoreleasePool.cpp */; }; 1A5700D2180BC6060088DEC7 /* CCAutoreleasePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700A9180BC6060088DEC7 /* CCAutoreleasePool.cpp */; }; 1A5700D3180BC6060088DEC7 /* CCAutoreleasePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700AA180BC6060088DEC7 /* CCAutoreleasePool.h */; }; 1A5700D4180BC6060088DEC7 /* CCAutoreleasePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700AA180BC6060088DEC7 /* CCAutoreleasePool.h */; }; 1A5700D5180BC6060088DEC7 /* CCBool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700AB180BC6060088DEC7 /* CCBool.h */; }; 1A5700D6180BC6060088DEC7 /* CCBool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700AB180BC6060088DEC7 /* CCBool.h */; }; 1A5700D7180BC6060088DEC7 /* CCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700AC180BC6060088DEC7 /* CCData.cpp */; }; 1A5700D8180BC6060088DEC7 /* CCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700AC180BC6060088DEC7 /* CCData.cpp */; }; 1A5700D9180BC6060088DEC7 /* CCData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700AD180BC6060088DEC7 /* CCData.h */; }; 1A5700DA180BC6060088DEC7 /* CCData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700AD180BC6060088DEC7 /* CCData.h */; }; 1A5700DB180BC6060088DEC7 /* CCDataVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700AE180BC6060088DEC7 /* CCDataVisitor.cpp */; }; 1A5700DC180BC6060088DEC7 /* CCDataVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700AE180BC6060088DEC7 /* CCDataVisitor.cpp */; }; 1A5700DD180BC6060088DEC7 /* CCDataVisitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700AF180BC6060088DEC7 /* CCDataVisitor.h */; }; 1A5700DE180BC6060088DEC7 /* CCDataVisitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700AF180BC6060088DEC7 /* CCDataVisitor.h */; }; 1A5700DF180BC6060088DEC7 /* CCDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700B0180BC6060088DEC7 /* CCDictionary.cpp */; }; 1A5700E0180BC6060088DEC7 /* CCDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700B0180BC6060088DEC7 /* CCDictionary.cpp */; }; 1A5700E1180BC6060088DEC7 /* CCDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B1180BC6060088DEC7 /* CCDictionary.h */; }; 1A5700E2180BC6060088DEC7 /* CCDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B1180BC6060088DEC7 /* CCDictionary.h */; }; 1A5700E3180BC6060088DEC7 /* CCDouble.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B2180BC6060088DEC7 /* CCDouble.h */; }; 1A5700E4180BC6060088DEC7 /* CCDouble.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B2180BC6060088DEC7 /* CCDouble.h */; }; 1A5700E5180BC6060088DEC7 /* CCFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B3180BC6060088DEC7 /* CCFloat.h */; }; 1A5700E6180BC6060088DEC7 /* CCFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B3180BC6060088DEC7 /* CCFloat.h */; }; 1A5700E7180BC6060088DEC7 /* CCGeometry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700B4180BC6060088DEC7 /* CCGeometry.cpp */; }; 1A5700E8180BC6060088DEC7 /* CCGeometry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700B4180BC6060088DEC7 /* CCGeometry.cpp */; }; 1A5700E9180BC6060088DEC7 /* CCGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B5180BC6060088DEC7 /* CCGeometry.h */; }; 1A5700EA180BC6060088DEC7 /* CCGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B5180BC6060088DEC7 /* CCGeometry.h */; }; 1A5700EB180BC6060088DEC7 /* CCInteger.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B6180BC6060088DEC7 /* CCInteger.h */; }; 1A5700EC180BC6060088DEC7 /* CCInteger.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B6180BC6060088DEC7 /* CCInteger.h */; }; 1A5700ED180BC6060088DEC7 /* CCNS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700B7180BC6060088DEC7 /* CCNS.cpp */; }; 1A5700EE180BC6060088DEC7 /* CCNS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700B7180BC6060088DEC7 /* CCNS.cpp */; }; 1A5700EF180BC6060088DEC7 /* CCNS.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B8180BC6060088DEC7 /* CCNS.h */; }; 1A5700F0180BC6060088DEC7 /* CCNS.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700B8180BC6060088DEC7 /* CCNS.h */; }; 1A5700F1180BC6060088DEC7 /* CCObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700B9180BC6060088DEC7 /* CCObject.cpp */; }; 1A5700F2180BC6060088DEC7 /* CCObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700B9180BC6060088DEC7 /* CCObject.cpp */; }; 1A5700F3180BC6060088DEC7 /* CCObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700BA180BC6060088DEC7 /* CCObject.h */; }; 1A5700F4180BC6060088DEC7 /* CCObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700BA180BC6060088DEC7 /* CCObject.h */; }; 1A5700F5180BC6060088DEC7 /* CCPlatformConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700BB180BC6060088DEC7 /* CCPlatformConfig.h */; }; 1A5700F6180BC6060088DEC7 /* CCPlatformConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700BB180BC6060088DEC7 /* CCPlatformConfig.h */; }; 1A5700F7180BC6060088DEC7 /* CCPlatformMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700BC180BC6060088DEC7 /* CCPlatformMacros.h */; }; 1A5700F8180BC6060088DEC7 /* CCPlatformMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700BC180BC6060088DEC7 /* CCPlatformMacros.h */; }; 1A5700F9180BC6060088DEC7 /* CCSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700BD180BC6060088DEC7 /* CCSet.cpp */; }; 1A5700FA180BC6060088DEC7 /* CCSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700BD180BC6060088DEC7 /* CCSet.cpp */; }; 1A5700FB180BC6060088DEC7 /* CCSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700BE180BC6060088DEC7 /* CCSet.h */; }; 1A5700FC180BC6060088DEC7 /* CCSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700BE180BC6060088DEC7 /* CCSet.h */; }; 1A5700FD180BC6060088DEC7 /* CCString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700BF180BC6060088DEC7 /* CCString.cpp */; }; 1A5700FE180BC6060088DEC7 /* CCString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700BF180BC6060088DEC7 /* CCString.cpp */; }; 1A5700FF180BC6060088DEC7 /* CCString.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700C0180BC6060088DEC7 /* CCString.h */; }; 1A570100180BC6060088DEC7 /* CCString.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700C0180BC6060088DEC7 /* CCString.h */; }; 1A570101180BC6060088DEC7 /* etc1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700C1180BC6060088DEC7 /* etc1.cpp */; }; 1A570102180BC6060088DEC7 /* etc1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700C1180BC6060088DEC7 /* etc1.cpp */; }; 1A570103180BC6060088DEC7 /* etc1.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700C2180BC6060088DEC7 /* etc1.h */; }; 1A570104180BC6060088DEC7 /* etc1.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700C2180BC6060088DEC7 /* etc1.h */; }; 1A570105180BC6060088DEC7 /* s3tc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700C3180BC6060088DEC7 /* s3tc.cpp */; }; 1A570106180BC6060088DEC7 /* s3tc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5700C3180BC6060088DEC7 /* s3tc.cpp */; }; 1A570107180BC6060088DEC7 /* s3tc.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700C4180BC6060088DEC7 /* s3tc.h */; }; 1A570108180BC6060088DEC7 /* s3tc.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5700C4180BC6060088DEC7 /* s3tc.h */; }; 1A57010E180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57010A180BC8ED0088DEC7 /* CCDrawingPrimitives.cpp */; }; 1A57010F180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57010A180BC8ED0088DEC7 /* CCDrawingPrimitives.cpp */; }; 1A570110180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57010B180BC8EE0088DEC7 /* CCDrawingPrimitives.h */; }; 1A570111180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57010B180BC8EE0088DEC7 /* CCDrawingPrimitives.h */; }; 1A570112180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57010C180BC8EE0088DEC7 /* CCDrawNode.cpp */; }; 1A570113180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57010C180BC8EE0088DEC7 /* CCDrawNode.cpp */; }; 1A570114180BC8EE0088DEC7 /* CCDrawNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57010D180BC8EE0088DEC7 /* CCDrawNode.h */; }; 1A570115180BC8EE0088DEC7 /* CCDrawNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57010D180BC8EE0088DEC7 /* CCDrawNode.h */; }; 1A57011B180BC90D0088DEC7 /* CCGrabber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570117180BC90D0088DEC7 /* CCGrabber.cpp */; }; 1A57011C180BC90D0088DEC7 /* CCGrabber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570117180BC90D0088DEC7 /* CCGrabber.cpp */; }; 1A57011D180BC90D0088DEC7 /* CCGrabber.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570118180BC90D0088DEC7 /* CCGrabber.h */; }; 1A57011E180BC90D0088DEC7 /* CCGrabber.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570118180BC90D0088DEC7 /* CCGrabber.h */; }; 1A57011F180BC90D0088DEC7 /* CCGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570119180BC90D0088DEC7 /* CCGrid.cpp */; }; 1A570120180BC90D0088DEC7 /* CCGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570119180BC90D0088DEC7 /* CCGrid.cpp */; }; 1A570121180BC90D0088DEC7 /* CCGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57011A180BC90D0088DEC7 /* CCGrid.h */; }; 1A570122180BC90D0088DEC7 /* CCGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57011A180BC90D0088DEC7 /* CCGrid.h */; }; 1A57013A180BC9460088DEC7 /* CCEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570124180BC9460088DEC7 /* CCEvent.cpp */; }; 1A57013B180BC9460088DEC7 /* CCEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570124180BC9460088DEC7 /* CCEvent.cpp */; }; 1A57013C180BC9460088DEC7 /* CCEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570125180BC9460088DEC7 /* CCEvent.h */; }; 1A57013D180BC9460088DEC7 /* CCEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570125180BC9460088DEC7 /* CCEvent.h */; }; 1A57013E180BC9460088DEC7 /* CCEventAcceleration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570126180BC9460088DEC7 /* CCEventAcceleration.cpp */; }; 1A57013F180BC9460088DEC7 /* CCEventAcceleration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570126180BC9460088DEC7 /* CCEventAcceleration.cpp */; }; 1A570140180BC9460088DEC7 /* CCEventAcceleration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570127180BC9460088DEC7 /* CCEventAcceleration.h */; }; 1A570141180BC9460088DEC7 /* CCEventAcceleration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570127180BC9460088DEC7 /* CCEventAcceleration.h */; }; 1A570142180BC9460088DEC7 /* CCEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570128180BC9460088DEC7 /* CCEventCustom.cpp */; }; 1A570143180BC9460088DEC7 /* CCEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570128180BC9460088DEC7 /* CCEventCustom.cpp */; }; 1A570144180BC9460088DEC7 /* CCEventCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570129180BC9460088DEC7 /* CCEventCustom.h */; }; 1A570145180BC9460088DEC7 /* CCEventCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570129180BC9460088DEC7 /* CCEventCustom.h */; }; 1A570146180BC9460088DEC7 /* CCEventDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57012A180BC9460088DEC7 /* CCEventDispatcher.cpp */; }; 1A570147180BC9460088DEC7 /* CCEventDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57012A180BC9460088DEC7 /* CCEventDispatcher.cpp */; }; 1A570148180BC9460088DEC7 /* CCEventDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57012B180BC9460088DEC7 /* CCEventDispatcher.h */; }; 1A570149180BC9460088DEC7 /* CCEventDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57012B180BC9460088DEC7 /* CCEventDispatcher.h */; }; 1A57014A180BC9460088DEC7 /* CCEventKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57012C180BC9460088DEC7 /* CCEventKeyboard.cpp */; }; 1A57014B180BC9460088DEC7 /* CCEventKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57012C180BC9460088DEC7 /* CCEventKeyboard.cpp */; }; 1A57014C180BC9460088DEC7 /* CCEventKeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57012D180BC9460088DEC7 /* CCEventKeyboard.h */; }; 1A57014D180BC9460088DEC7 /* CCEventKeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57012D180BC9460088DEC7 /* CCEventKeyboard.h */; }; 1A57014E180BC9460088DEC7 /* CCEventListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57012E180BC9460088DEC7 /* CCEventListener.cpp */; }; 1A57014F180BC9460088DEC7 /* CCEventListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57012E180BC9460088DEC7 /* CCEventListener.cpp */; }; 1A570150180BC9460088DEC7 /* CCEventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57012F180BC9460088DEC7 /* CCEventListener.h */; }; 1A570151180BC9460088DEC7 /* CCEventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57012F180BC9460088DEC7 /* CCEventListener.h */; }; 1A570152180BC9460088DEC7 /* CCEventListenerAcceleration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570130180BC9460088DEC7 /* CCEventListenerAcceleration.cpp */; }; 1A570153180BC9460088DEC7 /* CCEventListenerAcceleration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570130180BC9460088DEC7 /* CCEventListenerAcceleration.cpp */; }; 1A570154180BC9460088DEC7 /* CCEventListenerAcceleration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570131180BC9460088DEC7 /* CCEventListenerAcceleration.h */; }; 1A570155180BC9460088DEC7 /* CCEventListenerAcceleration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570131180BC9460088DEC7 /* CCEventListenerAcceleration.h */; }; 1A570156180BC9460088DEC7 /* CCEventListenerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570132180BC9460088DEC7 /* CCEventListenerCustom.cpp */; }; 1A570157180BC9460088DEC7 /* CCEventListenerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570132180BC9460088DEC7 /* CCEventListenerCustom.cpp */; }; 1A570158180BC9460088DEC7 /* CCEventListenerCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570133180BC9460088DEC7 /* CCEventListenerCustom.h */; }; 1A570159180BC9460088DEC7 /* CCEventListenerCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570133180BC9460088DEC7 /* CCEventListenerCustom.h */; }; 1A57015A180BC9460088DEC7 /* CCEventListenerKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570134180BC9460088DEC7 /* CCEventListenerKeyboard.cpp */; }; 1A57015B180BC9460088DEC7 /* CCEventListenerKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570134180BC9460088DEC7 /* CCEventListenerKeyboard.cpp */; }; 1A57015C180BC9460088DEC7 /* CCEventListenerKeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570135180BC9460088DEC7 /* CCEventListenerKeyboard.h */; }; 1A57015D180BC9460088DEC7 /* CCEventListenerKeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570135180BC9460088DEC7 /* CCEventListenerKeyboard.h */; }; 1A57015E180BC9460088DEC7 /* CCEventListenerTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570136180BC9460088DEC7 /* CCEventListenerTouch.cpp */; }; 1A57015F180BC9460088DEC7 /* CCEventListenerTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570136180BC9460088DEC7 /* CCEventListenerTouch.cpp */; }; 1A570160180BC9460088DEC7 /* CCEventListenerTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570137180BC9460088DEC7 /* CCEventListenerTouch.h */; }; 1A570161180BC9460088DEC7 /* CCEventListenerTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570137180BC9460088DEC7 /* CCEventListenerTouch.h */; }; 1A570162180BC9460088DEC7 /* CCEventTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570138180BC9460088DEC7 /* CCEventTouch.cpp */; }; 1A570163180BC9460088DEC7 /* CCEventTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570138180BC9460088DEC7 /* CCEventTouch.cpp */; }; 1A570164180BC9460088DEC7 /* CCEventTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570139180BC9460088DEC7 /* CCEventTouch.h */; }; 1A570165180BC9460088DEC7 /* CCEventTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570139180BC9460088DEC7 /* CCEventTouch.h */; }; 1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570182180BCB590088DEC7 /* CCFont.cpp */; }; 1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570182180BCB590088DEC7 /* CCFont.cpp */; }; 1A57019F180BCB590088DEC7 /* CCFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570183180BCB590088DEC7 /* CCFont.h */; }; 1A5701A0180BCB590088DEC7 /* CCFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570183180BCB590088DEC7 /* CCFont.h */; }; 1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570184180BCB590088DEC7 /* CCFontAtlas.cpp */; }; 1A5701A2180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570184180BCB590088DEC7 /* CCFontAtlas.cpp */; }; 1A5701A3180BCB590088DEC7 /* CCFontAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570185180BCB590088DEC7 /* CCFontAtlas.h */; }; 1A5701A4180BCB590088DEC7 /* CCFontAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570185180BCB590088DEC7 /* CCFontAtlas.h */; }; 1A5701A5180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570186180BCB590088DEC7 /* CCFontAtlasCache.cpp */; }; 1A5701A6180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570186180BCB590088DEC7 /* CCFontAtlasCache.cpp */; }; 1A5701A7180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570187180BCB590088DEC7 /* CCFontAtlasCache.h */; }; 1A5701A8180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570187180BCB590088DEC7 /* CCFontAtlasCache.h */; }; 1A5701B1180BCB590088DEC7 /* CCFontFNT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57018C180BCB590088DEC7 /* CCFontFNT.cpp */; }; 1A5701B2180BCB590088DEC7 /* CCFontFNT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57018C180BCB590088DEC7 /* CCFontFNT.cpp */; }; 1A5701B3180BCB590088DEC7 /* CCFontFNT.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57018D180BCB590088DEC7 /* CCFontFNT.h */; }; 1A5701B4180BCB590088DEC7 /* CCFontFNT.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57018D180BCB590088DEC7 /* CCFontFNT.h */; }; 1A5701B5180BCB590088DEC7 /* CCFontFreeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57018E180BCB590088DEC7 /* CCFontFreeType.cpp */; }; 1A5701B6180BCB590088DEC7 /* CCFontFreeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57018E180BCB590088DEC7 /* CCFontFreeType.cpp */; }; 1A5701B7180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57018F180BCB590088DEC7 /* CCFontFreeType.h */; }; 1A5701B8180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57018F180BCB590088DEC7 /* CCFontFreeType.h */; }; 1A5701B9180BCB5A0088DEC7 /* CCLabel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570190180BCB590088DEC7 /* CCLabel.cpp */; }; 1A5701BA180BCB5A0088DEC7 /* CCLabel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570190180BCB590088DEC7 /* CCLabel.cpp */; }; 1A5701BB180BCB5A0088DEC7 /* CCLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570191180BCB590088DEC7 /* CCLabel.h */; }; 1A5701BC180BCB5A0088DEC7 /* CCLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570191180BCB590088DEC7 /* CCLabel.h */; }; 1A5701BD180BCB5A0088DEC7 /* CCLabelAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570192180BCB590088DEC7 /* CCLabelAtlas.cpp */; }; 1A5701BE180BCB5A0088DEC7 /* CCLabelAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570192180BCB590088DEC7 /* CCLabelAtlas.cpp */; }; 1A5701BF180BCB5A0088DEC7 /* CCLabelAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570193180BCB590088DEC7 /* CCLabelAtlas.h */; }; 1A5701C0180BCB5A0088DEC7 /* CCLabelAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570193180BCB590088DEC7 /* CCLabelAtlas.h */; }; 1A5701C1180BCB5A0088DEC7 /* CCLabelBMFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570194180BCB590088DEC7 /* CCLabelBMFont.cpp */; }; 1A5701C2180BCB5A0088DEC7 /* CCLabelBMFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570194180BCB590088DEC7 /* CCLabelBMFont.cpp */; }; 1A5701C3180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570195180BCB590088DEC7 /* CCLabelBMFont.h */; }; 1A5701C4180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570195180BCB590088DEC7 /* CCLabelBMFont.h */; }; 1A5701C7180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570197180BCB590088DEC7 /* CCLabelTextFormatter.cpp */; }; 1A5701C8180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570197180BCB590088DEC7 /* CCLabelTextFormatter.cpp */; }; 1A5701C9180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570198180BCB590088DEC7 /* CCLabelTextFormatter.h */; }; 1A5701CA180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570198180BCB590088DEC7 /* CCLabelTextFormatter.h */; }; 1A5701CB180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570199180BCB590088DEC7 /* CCLabelTTF.cpp */; }; 1A5701CC180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570199180BCB590088DEC7 /* CCLabelTTF.cpp */; }; 1A5701CD180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57019A180BCB590088DEC7 /* CCLabelTTF.h */; }; 1A5701CE180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57019A180BCB590088DEC7 /* CCLabelTTF.h */; }; 1A5701DE180BCB8C0088DEC7 /* CCLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701D4180BCB8C0088DEC7 /* CCLayer.cpp */; }; 1A5701DF180BCB8C0088DEC7 /* CCLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701D4180BCB8C0088DEC7 /* CCLayer.cpp */; }; 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701D5180BCB8C0088DEC7 /* CCLayer.h */; }; 1A5701E1180BCB8C0088DEC7 /* CCLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701D5180BCB8C0088DEC7 /* CCLayer.h */; }; 1A5701E2180BCB8C0088DEC7 /* CCScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701D6180BCB8C0088DEC7 /* CCScene.cpp */; }; 1A5701E3180BCB8C0088DEC7 /* CCScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701D6180BCB8C0088DEC7 /* CCScene.cpp */; }; 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701D7180BCB8C0088DEC7 /* CCScene.h */; }; 1A5701E5180BCB8C0088DEC7 /* CCScene.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701D7180BCB8C0088DEC7 /* CCScene.h */; }; 1A5701E6180BCB8C0088DEC7 /* CCTransition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701D8180BCB8C0088DEC7 /* CCTransition.cpp */; }; 1A5701E7180BCB8C0088DEC7 /* CCTransition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701D8180BCB8C0088DEC7 /* CCTransition.cpp */; }; 1A5701E8180BCB8C0088DEC7 /* CCTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701D9180BCB8C0088DEC7 /* CCTransition.h */; }; 1A5701E9180BCB8C0088DEC7 /* CCTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701D9180BCB8C0088DEC7 /* CCTransition.h */; }; 1A5701EA180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701DA180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp */; }; 1A5701EB180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701DA180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp */; }; 1A5701EC180BCB8C0088DEC7 /* CCTransitionPageTurn.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701DB180BCB8C0088DEC7 /* CCTransitionPageTurn.h */; }; 1A5701ED180BCB8C0088DEC7 /* CCTransitionPageTurn.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701DB180BCB8C0088DEC7 /* CCTransitionPageTurn.h */; }; 1A5701EE180BCB8C0088DEC7 /* CCTransitionProgress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701DC180BCB8C0088DEC7 /* CCTransitionProgress.cpp */; }; 1A5701EF180BCB8C0088DEC7 /* CCTransitionProgress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701DC180BCB8C0088DEC7 /* CCTransitionProgress.cpp */; }; 1A5701F0180BCB8C0088DEC7 /* CCTransitionProgress.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701DD180BCB8C0088DEC7 /* CCTransitionProgress.h */; }; 1A5701F1180BCB8C0088DEC7 /* CCTransitionProgress.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701DD180BCB8C0088DEC7 /* CCTransitionProgress.h */; }; 1A5701F7180BCBAD0088DEC7 /* CCMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701F3180BCBAD0088DEC7 /* CCMenu.cpp */; }; 1A5701F8180BCBAD0088DEC7 /* CCMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701F3180BCBAD0088DEC7 /* CCMenu.cpp */; }; 1A5701F9180BCBAD0088DEC7 /* CCMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701F4180BCBAD0088DEC7 /* CCMenu.h */; }; 1A5701FA180BCBAD0088DEC7 /* CCMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701F4180BCBAD0088DEC7 /* CCMenu.h */; }; 1A5701FB180BCBAD0088DEC7 /* CCMenuItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701F5180BCBAD0088DEC7 /* CCMenuItem.cpp */; }; 1A5701FC180BCBAD0088DEC7 /* CCMenuItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5701F5180BCBAD0088DEC7 /* CCMenuItem.cpp */; }; 1A5701FD180BCBAD0088DEC7 /* CCMenuItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701F6180BCBAD0088DEC7 /* CCMenuItem.h */; }; 1A5701FE180BCBAD0088DEC7 /* CCMenuItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5701F6180BCBAD0088DEC7 /* CCMenuItem.h */; }; 1A570202180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570200180BCBD40088DEC7 /* CCClippingNode.cpp */; }; 1A570203180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570200180BCBD40088DEC7 /* CCClippingNode.cpp */; }; 1A570204180BCBD40088DEC7 /* CCClippingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570201180BCBD40088DEC7 /* CCClippingNode.h */; }; 1A570205180BCBD40088DEC7 /* CCClippingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570201180BCBD40088DEC7 /* CCClippingNode.h */; }; 1A570208180BCBDF0088DEC7 /* CCMotionStreak.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570206180BCBDF0088DEC7 /* CCMotionStreak.cpp */; }; 1A570209180BCBDF0088DEC7 /* CCMotionStreak.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570206180BCBDF0088DEC7 /* CCMotionStreak.cpp */; }; 1A57020A180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570207180BCBDF0088DEC7 /* CCMotionStreak.h */; }; 1A57020B180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570207180BCBDF0088DEC7 /* CCMotionStreak.h */; }; 1A570210180BCBF40088DEC7 /* CCProgressTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57020C180BCBF40088DEC7 /* CCProgressTimer.cpp */; }; 1A570211180BCBF40088DEC7 /* CCProgressTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57020C180BCBF40088DEC7 /* CCProgressTimer.cpp */; }; 1A570212180BCBF40088DEC7 /* CCProgressTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57020D180BCBF40088DEC7 /* CCProgressTimer.h */; }; 1A570213180BCBF40088DEC7 /* CCProgressTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57020D180BCBF40088DEC7 /* CCProgressTimer.h */; }; 1A570214180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57020E180BCBF40088DEC7 /* CCRenderTexture.cpp */; }; 1A570215180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57020E180BCBF40088DEC7 /* CCRenderTexture.cpp */; }; 1A570216180BCBF40088DEC7 /* CCRenderTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57020F180BCBF40088DEC7 /* CCRenderTexture.h */; }; 1A570217180BCBF40088DEC7 /* CCRenderTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57020F180BCBF40088DEC7 /* CCRenderTexture.h */; }; 1A570221180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570219180BCC1A0088DEC7 /* CCParticleBatchNode.cpp */; }; 1A570222180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570219180BCC1A0088DEC7 /* CCParticleBatchNode.cpp */; }; 1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57021A180BCC1A0088DEC7 /* CCParticleBatchNode.h */; }; 1A570224180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57021A180BCC1A0088DEC7 /* CCParticleBatchNode.h */; }; 1A570225180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57021B180BCC1A0088DEC7 /* CCParticleExamples.cpp */; }; 1A570226180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57021B180BCC1A0088DEC7 /* CCParticleExamples.cpp */; }; 1A570227180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57021C180BCC1A0088DEC7 /* CCParticleExamples.h */; }; 1A570228180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57021C180BCC1A0088DEC7 /* CCParticleExamples.h */; }; 1A570229180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57021D180BCC1A0088DEC7 /* CCParticleSystem.cpp */; }; 1A57022A180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57021D180BCC1A0088DEC7 /* CCParticleSystem.cpp */; }; 1A57022B180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57021E180BCC1A0088DEC7 /* CCParticleSystem.h */; }; 1A57022C180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57021E180BCC1A0088DEC7 /* CCParticleSystem.h */; }; 1A57022D180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57021F180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp */; }; 1A57022E180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57021F180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp */; }; 1A57022F180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570220180BCC1A0088DEC7 /* CCParticleSystemQuad.h */; }; 1A570230180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570220180BCC1A0088DEC7 /* CCParticleSystemQuad.h */; }; 1A570234180BCC4D0088DEC7 /* CCScriptSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570232180BCC4D0088DEC7 /* CCScriptSupport.cpp */; }; 1A570235180BCC4D0088DEC7 /* CCScriptSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570232180BCC4D0088DEC7 /* CCScriptSupport.cpp */; }; 1A570236180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */; }; 1A570237180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */; }; 1A57024D180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */; }; 1A57024E180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */; }; 1A57024F180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */; }; 1A570250180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */; }; 1A570251180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */; }; 1A570252180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */; }; 1A570253180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */; }; 1A570254180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */; }; 1A570255180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */; }; 1A570256180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */; }; 1A570257180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */; }; 1A570258180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */; }; 1A570259180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */; }; 1A57025A180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */; }; 1A57025B180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */; }; 1A57025C180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */; }; 1A57025D180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */; }; 1A57025E180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */; }; 1A57025F180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */; }; 1A570260180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */; }; 1A570261180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */; }; 1A570262180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */; }; 1A570263180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */; }; 1A570264180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */; }; 1A570265180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */; }; 1A570266180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */; }; 1A570267180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */; }; 1A570268180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */; }; 1A570269180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; 1A57026A180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; 1A57026B180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */; }; 1A57026C180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */; }; 1A57026D180BCC6F0088DEC7 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */; }; 1A57026E180BCC6F0088DEC7 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */; }; 1A57026F180BCC6F0088DEC7 /* ccShaderEx_SwitchMask_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57024A180BCC6F0088DEC7 /* ccShaderEx_SwitchMask_frag.h */; }; 1A570270180BCC6F0088DEC7 /* ccShaderEx_SwitchMask_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57024A180BCC6F0088DEC7 /* ccShaderEx_SwitchMask_frag.h */; }; 1A570271180BCC6F0088DEC7 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */; }; 1A570272180BCC6F0088DEC7 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */; }; 1A570273180BCC6F0088DEC7 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57024C180BCC6F0088DEC7 /* ccShaders.h */; }; 1A570274180BCC6F0088DEC7 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57024C180BCC6F0088DEC7 /* ccShaders.h */; }; 1A57027E180BCC900088DEC7 /* CCSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570276180BCC900088DEC7 /* CCSprite.cpp */; }; 1A57027F180BCC900088DEC7 /* CCSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570276180BCC900088DEC7 /* CCSprite.cpp */; }; 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570277180BCC900088DEC7 /* CCSprite.h */; }; 1A570281180BCC900088DEC7 /* CCSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570277180BCC900088DEC7 /* CCSprite.h */; }; 1A570282180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570278180BCC900088DEC7 /* CCSpriteBatchNode.cpp */; }; 1A570283180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570278180BCC900088DEC7 /* CCSpriteBatchNode.cpp */; }; 1A570284180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570279180BCC900088DEC7 /* CCSpriteBatchNode.h */; }; 1A570285180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570279180BCC900088DEC7 /* CCSpriteBatchNode.h */; }; 1A570286180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57027A180BCC900088DEC7 /* CCSpriteFrame.cpp */; }; 1A570287180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57027A180BCC900088DEC7 /* CCSpriteFrame.cpp */; }; 1A570288180BCC900088DEC7 /* CCSpriteFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57027B180BCC900088DEC7 /* CCSpriteFrame.h */; }; 1A570289180BCC900088DEC7 /* CCSpriteFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57027B180BCC900088DEC7 /* CCSpriteFrame.h */; }; 1A57028A180BCC900088DEC7 /* CCSpriteFrameCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57027C180BCC900088DEC7 /* CCSpriteFrameCache.cpp */; }; 1A57028B180BCC900088DEC7 /* CCSpriteFrameCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57027C180BCC900088DEC7 /* CCSpriteFrameCache.cpp */; }; 1A57028C180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57027D180BCC900088DEC7 /* CCSpriteFrameCache.h */; }; 1A57028D180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57027D180BCC900088DEC7 /* CCSpriteFrameCache.h */; }; 1A570292180BCCAB0088DEC7 /* CCAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57028E180BCCAB0088DEC7 /* CCAnimation.cpp */; }; 1A570293180BCCAB0088DEC7 /* CCAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57028E180BCCAB0088DEC7 /* CCAnimation.cpp */; }; 1A570294180BCCAB0088DEC7 /* CCAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57028F180BCCAB0088DEC7 /* CCAnimation.h */; }; 1A570295180BCCAB0088DEC7 /* CCAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57028F180BCCAB0088DEC7 /* CCAnimation.h */; }; 1A570296180BCCAB0088DEC7 /* CCAnimationCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570290180BCCAB0088DEC7 /* CCAnimationCache.cpp */; }; 1A570297180BCCAB0088DEC7 /* CCAnimationCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570290180BCCAB0088DEC7 /* CCAnimationCache.cpp */; }; 1A570298180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570291180BCCAB0088DEC7 /* CCAnimationCache.h */; }; 1A570299180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570291180BCCAB0088DEC7 /* CCAnimationCache.h */; }; 1A57029D180BCD890088DEC7 /* base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57029B180BCD890088DEC7 /* base64.cpp */; }; 1A57029E180BCD890088DEC7 /* base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57029B180BCD890088DEC7 /* base64.cpp */; }; 1A57029F180BCD890088DEC7 /* base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57029C180BCD890088DEC7 /* base64.h */; }; 1A5702A0180BCD890088DEC7 /* base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57029C180BCD890088DEC7 /* base64.h */; }; 1A5702A3180BCD980088DEC7 /* CCNotificationCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702A1180BCD980088DEC7 /* CCNotificationCenter.cpp */; }; 1A5702A4180BCD980088DEC7 /* CCNotificationCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702A1180BCD980088DEC7 /* CCNotificationCenter.cpp */; }; 1A5702A5180BCD980088DEC7 /* CCNotificationCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702A2180BCD980088DEC7 /* CCNotificationCenter.h */; }; 1A5702A6180BCD980088DEC7 /* CCNotificationCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702A2180BCD980088DEC7 /* CCNotificationCenter.h */; }; 1A5702A9180BCDAA0088DEC7 /* CCProfiling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702A7180BCDAA0088DEC7 /* CCProfiling.cpp */; }; 1A5702AA180BCDAA0088DEC7 /* CCProfiling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702A7180BCDAA0088DEC7 /* CCProfiling.cpp */; }; 1A5702AB180BCDAA0088DEC7 /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702A8180BCDAA0088DEC7 /* CCProfiling.h */; }; 1A5702AC180BCDAA0088DEC7 /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702A8180BCDAA0088DEC7 /* CCProfiling.h */; }; 1A5702AF180BCDBC0088DEC7 /* ccUTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702AD180BCDBC0088DEC7 /* ccUTF8.cpp */; }; 1A5702B0180BCDBC0088DEC7 /* ccUTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702AD180BCDBC0088DEC7 /* ccUTF8.cpp */; }; 1A5702B1180BCDBC0088DEC7 /* ccUTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702AE180BCDBC0088DEC7 /* ccUTF8.h */; }; 1A5702B2180BCDBC0088DEC7 /* ccUTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702AE180BCDBC0088DEC7 /* ccUTF8.h */; }; 1A5702B5180BCDF40088DEC7 /* CCVertex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702B3180BCDF40088DEC7 /* CCVertex.cpp */; }; 1A5702B6180BCDF40088DEC7 /* CCVertex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702B3180BCDF40088DEC7 /* CCVertex.cpp */; }; 1A5702B7180BCDF40088DEC7 /* CCVertex.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702B4180BCDF40088DEC7 /* CCVertex.h */; }; 1A5702B8180BCDF40088DEC7 /* CCVertex.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702B4180BCDF40088DEC7 /* CCVertex.h */; }; 1A5702BA180BCDFC0088DEC7 /* ccUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702B9180BCDFC0088DEC7 /* ccUtils.h */; }; 1A5702BB180BCDFC0088DEC7 /* ccUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702B9180BCDFC0088DEC7 /* ccUtils.h */; }; 1A5702C0180BCE2A0088DEC7 /* CCIMEDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702BD180BCE2A0088DEC7 /* CCIMEDelegate.h */; }; 1A5702C1180BCE2A0088DEC7 /* CCIMEDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702BD180BCE2A0088DEC7 /* CCIMEDelegate.h */; }; 1A5702C2180BCE2A0088DEC7 /* CCIMEDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702BE180BCE2A0088DEC7 /* CCIMEDispatcher.cpp */; }; 1A5702C3180BCE2A0088DEC7 /* CCIMEDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702BE180BCE2A0088DEC7 /* CCIMEDispatcher.cpp */; }; 1A5702C4180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702BF180BCE2A0088DEC7 /* CCIMEDispatcher.h */; }; 1A5702C5180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702BF180BCE2A0088DEC7 /* CCIMEDispatcher.h */; }; 1A5702C8180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702C6180BCE370088DEC7 /* CCTextFieldTTF.cpp */; }; 1A5702C9180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702C6180BCE370088DEC7 /* CCTextFieldTTF.cpp */; }; 1A5702CA180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702C7180BCE370088DEC7 /* CCTextFieldTTF.h */; }; 1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702C7180BCE370088DEC7 /* CCTextFieldTTF.h */; }; 1A5702D3180BCE570088DEC7 /* CCTexture2D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702CD180BCE560088DEC7 /* CCTexture2D.cpp */; }; 1A5702D4180BCE570088DEC7 /* CCTexture2D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702CD180BCE560088DEC7 /* CCTexture2D.cpp */; }; 1A5702D5180BCE570088DEC7 /* CCTexture2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702CE180BCE570088DEC7 /* CCTexture2D.h */; }; 1A5702D6180BCE570088DEC7 /* CCTexture2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702CE180BCE570088DEC7 /* CCTexture2D.h */; }; 1A5702D7180BCE570088DEC7 /* CCTextureAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702CF180BCE570088DEC7 /* CCTextureAtlas.cpp */; }; 1A5702D8180BCE570088DEC7 /* CCTextureAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702CF180BCE570088DEC7 /* CCTextureAtlas.cpp */; }; 1A5702D9180BCE570088DEC7 /* CCTextureAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702D0180BCE570088DEC7 /* CCTextureAtlas.h */; }; 1A5702DA180BCE570088DEC7 /* CCTextureAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702D0180BCE570088DEC7 /* CCTextureAtlas.h */; }; 1A5702DB180BCE570088DEC7 /* CCTextureCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702D1180BCE570088DEC7 /* CCTextureCache.cpp */; }; 1A5702DC180BCE570088DEC7 /* CCTextureCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702D1180BCE570088DEC7 /* CCTextureCache.cpp */; }; 1A5702DD180BCE570088DEC7 /* CCTextureCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702D2180BCE570088DEC7 /* CCTextureCache.h */; }; 1A5702DE180BCE570088DEC7 /* CCTextureCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702D2180BCE570088DEC7 /* CCTextureCache.h */; }; 1A5702EA180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E0180BCE750088DEC7 /* CCTileMapAtlas.cpp */; }; 1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E0180BCE750088DEC7 /* CCTileMapAtlas.cpp */; }; 1A5702EC180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E1180BCE750088DEC7 /* CCTileMapAtlas.h */; }; 1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E1180BCE750088DEC7 /* CCTileMapAtlas.h */; }; 1A5702EE180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E2180BCE750088DEC7 /* CCTMXLayer.cpp */; }; 1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E2180BCE750088DEC7 /* CCTMXLayer.cpp */; }; 1A5702F0180BCE750088DEC7 /* CCTMXLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E3180BCE750088DEC7 /* CCTMXLayer.h */; }; 1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E3180BCE750088DEC7 /* CCTMXLayer.h */; }; 1A5702F2180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E4180BCE750088DEC7 /* CCTMXObjectGroup.cpp */; }; 1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E4180BCE750088DEC7 /* CCTMXObjectGroup.cpp */; }; 1A5702F4180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E5180BCE750088DEC7 /* CCTMXObjectGroup.h */; }; 1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E5180BCE750088DEC7 /* CCTMXObjectGroup.h */; }; 1A5702F6180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E6180BCE750088DEC7 /* CCTMXTiledMap.cpp */; }; 1A5702F7180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E6180BCE750088DEC7 /* CCTMXTiledMap.cpp */; }; 1A5702F8180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E7180BCE750088DEC7 /* CCTMXTiledMap.h */; }; 1A5702F9180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E7180BCE750088DEC7 /* CCTMXTiledMap.h */; }; 1A5702FA180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E8180BCE750088DEC7 /* CCTMXXMLParser.cpp */; }; 1A5702FB180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702E8180BCE750088DEC7 /* CCTMXXMLParser.cpp */; }; 1A5702FC180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E9180BCE750088DEC7 /* CCTMXXMLParser.h */; }; 1A5702FD180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702E9180BCE750088DEC7 /* CCTMXXMLParser.h */; }; 1A570300180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702FE180BCE890088DEC7 /* CCParallaxNode.cpp */; }; 1A570301180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5702FE180BCE890088DEC7 /* CCParallaxNode.cpp */; }; 1A570302180BCE890088DEC7 /* CCParallaxNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702FF180BCE890088DEC7 /* CCParallaxNode.h */; }; 1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5702FF180BCE890088DEC7 /* CCParallaxNode.h */; }; 1A570305180BCED90088DEC7 /* ccUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570304180BCED90088DEC7 /* ccUtils.cpp */; }; 1A570306180BCED90088DEC7 /* ccUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570304180BCED90088DEC7 /* ccUtils.cpp */; }; 1A57030C180BCF190088DEC7 /* CCComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570308180BCF190088DEC7 /* CCComponent.cpp */; }; 1A57030D180BCF190088DEC7 /* CCComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570308180BCF190088DEC7 /* CCComponent.cpp */; }; 1A57030E180BCF190088DEC7 /* CCComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570309180BCF190088DEC7 /* CCComponent.h */; }; 1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570309180BCF190088DEC7 /* CCComponent.h */; }; 1A570310180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57030A180BCF190088DEC7 /* CCComponentContainer.cpp */; }; 1A570311180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57030A180BCF190088DEC7 /* CCComponentContainer.cpp */; }; 1A570312180BCF190088DEC7 /* CCComponentContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57030B180BCF190088DEC7 /* CCComponentContainer.h */; }; 1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57030B180BCF190088DEC7 /* CCComponentContainer.h */; }; 1A570319180BCF430088DEC7 /* ccCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570315180BCF430088DEC7 /* ccCArray.cpp */; }; 1A57031A180BCF430088DEC7 /* ccCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570315180BCF430088DEC7 /* ccCArray.cpp */; }; 1A57031B180BCF430088DEC7 /* ccCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570316180BCF430088DEC7 /* ccCArray.h */; }; 1A57031C180BCF430088DEC7 /* ccCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570316180BCF430088DEC7 /* ccCArray.h */; }; 1A57031D180BCF430088DEC7 /* uthash.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570317180BCF430088DEC7 /* uthash.h */; }; 1A57031E180BCF430088DEC7 /* uthash.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570317180BCF430088DEC7 /* uthash.h */; }; 1A57031F180BCF430088DEC7 /* utlist.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570318180BCF430088DEC7 /* utlist.h */; }; 1A570320180BCF430088DEC7 /* utlist.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570318180BCF430088DEC7 /* utlist.h */; }; 1A570324180BCF660088DEC7 /* TGAlib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570322180BCF660088DEC7 /* TGAlib.cpp */; }; 1A570325180BCF660088DEC7 /* TGAlib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570322180BCF660088DEC7 /* TGAlib.cpp */; }; 1A570326180BCF660088DEC7 /* TGAlib.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570323180BCF660088DEC7 /* TGAlib.h */; }; 1A570327180BCF660088DEC7 /* TGAlib.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570323180BCF660088DEC7 /* TGAlib.h */; }; 1A57032F180BCFD50088DEC7 /* CCUserDefault.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57032B180BCFD50088DEC7 /* CCUserDefault.cpp */; }; 1A570330180BCFD50088DEC7 /* CCUserDefault.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57032B180BCFD50088DEC7 /* CCUserDefault.cpp */; }; 1A570331180BCFD50088DEC7 /* CCUserDefault.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57032C180BCFD50088DEC7 /* CCUserDefault.h */; }; 1A570332180BCFD50088DEC7 /* CCUserDefault.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57032C180BCFD50088DEC7 /* CCUserDefault.h */; }; 1A570333180BCFD50088DEC7 /* CCUserDefault.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A57032D180BCFD50088DEC7 /* CCUserDefault.mm */; }; 1A570334180BCFD50088DEC7 /* CCUserDefault.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A57032D180BCFD50088DEC7 /* CCUserDefault.mm */; }; 1A570335180BCFD50088DEC7 /* CCUserDefaultAndroid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57032E180BCFD50088DEC7 /* CCUserDefaultAndroid.cpp */; }; 1A570336180BCFD50088DEC7 /* CCUserDefaultAndroid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57032E180BCFD50088DEC7 /* CCUserDefaultAndroid.cpp */; }; 1A57033A180BCFFA0088DEC7 /* ZipUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570338180BCFFA0088DEC7 /* ZipUtils.cpp */; }; 1A57033B180BCFFA0088DEC7 /* ZipUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570338180BCFFA0088DEC7 /* ZipUtils.cpp */; }; 1A57033C180BCFFA0088DEC7 /* ZipUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570339180BCFFA0088DEC7 /* ZipUtils.h */; }; 1A57033D180BCFFA0088DEC7 /* ZipUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570339180BCFFA0088DEC7 /* ZipUtils.h */; }; 1A570347180BD0850088DEC7 /* libglfw3.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A570346180BD0850088DEC7 /* libglfw3.a */; }; 1A57034B180BD09B0088DEC7 /* tinyxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570349180BD09B0088DEC7 /* tinyxml2.cpp */; }; 1A57034C180BD09B0088DEC7 /* tinyxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570349180BD09B0088DEC7 /* tinyxml2.cpp */; }; 1A57034D180BD09B0088DEC7 /* tinyxml2.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57034A180BD09B0088DEC7 /* tinyxml2.h */; }; 1A57034E180BD09B0088DEC7 /* tinyxml2.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57034A180BD09B0088DEC7 /* tinyxml2.h */; }; 1A570354180BD0B00088DEC7 /* ioapi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570350180BD0B00088DEC7 /* ioapi.cpp */; }; 1A570355180BD0B00088DEC7 /* ioapi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570350180BD0B00088DEC7 /* ioapi.cpp */; }; 1A570356180BD0B00088DEC7 /* ioapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570351180BD0B00088DEC7 /* ioapi.h */; }; 1A570357180BD0B00088DEC7 /* ioapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570351180BD0B00088DEC7 /* ioapi.h */; }; 1A570358180BD0B00088DEC7 /* unzip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570352180BD0B00088DEC7 /* unzip.cpp */; }; 1A570359180BD0B00088DEC7 /* unzip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570352180BD0B00088DEC7 /* unzip.cpp */; }; 1A57035A180BD0B00088DEC7 /* unzip.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570353180BD0B00088DEC7 /* unzip.h */; }; 1A57035B180BD0B00088DEC7 /* unzip.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570353180BD0B00088DEC7 /* unzip.h */; }; 1A570361180BD1080088DEC7 /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A570360180BD1080088DEC7 /* libpng.a */; }; 1A570364180BD1120088DEC7 /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A570363180BD1120088DEC7 /* libpng.a */; }; 1A570378180BD1B40088DEC7 /* libjpeg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A570377180BD1B40088DEC7 /* libjpeg.a */; }; 1A57037B180BD1C90088DEC7 /* libjpeg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A57037A180BD1C90088DEC7 /* libjpeg.a */; }; 1A5703A1180BD22C0088DEC7 /* libtiff.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5703A0180BD22C0088DEC7 /* libtiff.a */; }; 1A5703A4180BD2350088DEC7 /* libtiff.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5703A3180BD2350088DEC7 /* libtiff.a */; }; 1A5703B8180BD2780088DEC7 /* libwebp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5703B7180BD2780088DEC7 /* libwebp.a */; }; 1A5703BB180BD2800088DEC7 /* libwebp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5703BA180BD2800088DEC7 /* libwebp.a */; }; 1A57052B180BD31F0088DEC7 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A57052A180BD31F0088DEC7 /* libfreetype.a */; }; 1A57052E180BD3280088DEC7 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A57052D180BD3280088DEC7 /* libfreetype.a */; }; 1A570533180BD9500088DEC7 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */; }; 1A570534180BD9500088DEC7 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */; }; 1A570535180BD9500088DEC7 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570530180BD9500088DEC7 /* CCGLProgram.h */; }; 1A570536180BD9500088DEC7 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570530180BD9500088DEC7 /* CCGLProgram.h */; }; 1A570537180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */; }; 1A570538180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */; }; 1A570539180BD9500088DEC7 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570532180BD9500088DEC7 /* ccGLStateCache.h */; }; 1A57053A180BD9500088DEC7 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570532180BD9500088DEC7 /* ccGLStateCache.h */; }; 1A570546180BD9C40088DEC7 /* CCTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570544180BD9C40088DEC7 /* CCTouch.cpp */; }; 1A570547180BD9C40088DEC7 /* CCTouch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570544180BD9C40088DEC7 /* CCTouch.cpp */; }; 1A570548180BD9C40088DEC7 /* CCTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570545180BD9C40088DEC7 /* CCTouch.h */; }; 1A570549180BD9C40088DEC7 /* CCTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570545180BD9C40088DEC7 /* CCTouch.h */; }; 1A85BA0D1845F31700260FC0 /* CCVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A85BA0C1845F31700260FC0 /* CCVector.h */; }; 1A85BA0E1845F31700260FC0 /* CCVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A85BA0C1845F31700260FC0 /* CCVector.h */; }; 1A8C5646180E8D0D00EF57C3 /* tolua++.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C563F180E8D0D00EF57C3 /* tolua++.h */; }; 1A8C5647180E8D0D00EF57C3 /* tolua++.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C563F180E8D0D00EF57C3 /* tolua++.h */; }; 1A8C5648180E8D0D00EF57C3 /* tolua_event.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5640180E8D0D00EF57C3 /* tolua_event.c */; }; 1A8C5649180E8D0D00EF57C3 /* tolua_event.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5640180E8D0D00EF57C3 /* tolua_event.c */; }; 1A8C564A180E8D0D00EF57C3 /* tolua_event.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5641180E8D0D00EF57C3 /* tolua_event.h */; }; 1A8C564B180E8D0D00EF57C3 /* tolua_event.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5641180E8D0D00EF57C3 /* tolua_event.h */; }; 1A8C564C180E8D0D00EF57C3 /* tolua_is.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5642180E8D0D00EF57C3 /* tolua_is.c */; }; 1A8C564D180E8D0D00EF57C3 /* tolua_is.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5642180E8D0D00EF57C3 /* tolua_is.c */; }; 1A8C564E180E8D0D00EF57C3 /* tolua_map.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5643180E8D0D00EF57C3 /* tolua_map.c */; }; 1A8C564F180E8D0D00EF57C3 /* tolua_map.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5643180E8D0D00EF57C3 /* tolua_map.c */; }; 1A8C5650180E8D0D00EF57C3 /* tolua_push.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5644180E8D0D00EF57C3 /* tolua_push.c */; }; 1A8C5651180E8D0D00EF57C3 /* tolua_push.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5644180E8D0D00EF57C3 /* tolua_push.c */; }; 1A8C5652180E8D0D00EF57C3 /* tolua_to.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5645180E8D0D00EF57C3 /* tolua_to.c */; }; 1A8C5653180E8D0D00EF57C3 /* tolua_to.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5645180E8D0D00EF57C3 /* tolua_to.c */; }; 1A8C58EC180E92CC00EF57C3 /* CocosGUI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58BF180E92CC00EF57C3 /* CocosGUI.cpp */; }; 1A8C58ED180E92CC00EF57C3 /* CocosGUI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58BF180E92CC00EF57C3 /* CocosGUI.cpp */; }; 1A8C58EE180E92CC00EF57C3 /* CocosGUI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C0180E92CC00EF57C3 /* CocosGUI.h */; }; 1A8C58EF180E92CC00EF57C3 /* CocosGUI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C0180E92CC00EF57C3 /* CocosGUI.h */; }; 1A8C58F0180E92CC00EF57C3 /* UILayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58C1180E92CC00EF57C3 /* UILayout.cpp */; }; 1A8C58F1180E92CC00EF57C3 /* UILayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58C1180E92CC00EF57C3 /* UILayout.cpp */; }; 1A8C58F2180E92CC00EF57C3 /* UILayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C2180E92CC00EF57C3 /* UILayout.h */; }; 1A8C58F3180E92CC00EF57C3 /* UILayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C2180E92CC00EF57C3 /* UILayout.h */; }; 1A8C58F4180E92CC00EF57C3 /* UILayoutParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58C3180E92CC00EF57C3 /* UILayoutParameter.cpp */; }; 1A8C58F5180E92CC00EF57C3 /* UILayoutParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58C3180E92CC00EF57C3 /* UILayoutParameter.cpp */; }; 1A8C58F6180E92CC00EF57C3 /* UILayoutParameter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C4180E92CC00EF57C3 /* UILayoutParameter.h */; }; 1A8C58F7180E92CC00EF57C3 /* UILayoutParameter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C4180E92CC00EF57C3 /* UILayoutParameter.h */; }; 1A8C58F8180E92CC00EF57C3 /* UIButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58C5180E92CC00EF57C3 /* UIButton.cpp */; }; 1A8C58F9180E92CC00EF57C3 /* UIButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58C5180E92CC00EF57C3 /* UIButton.cpp */; }; 1A8C58FA180E92CC00EF57C3 /* UIButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C6180E92CC00EF57C3 /* UIButton.h */; }; 1A8C58FB180E92CC00EF57C3 /* UIButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C6180E92CC00EF57C3 /* UIButton.h */; }; 1A8C58FC180E92CC00EF57C3 /* UICheckBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58C7180E92CC00EF57C3 /* UICheckBox.cpp */; }; 1A8C58FD180E92CC00EF57C3 /* UICheckBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58C7180E92CC00EF57C3 /* UICheckBox.cpp */; }; 1A8C58FE180E92CC00EF57C3 /* UICheckBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C8180E92CC00EF57C3 /* UICheckBox.h */; }; 1A8C58FF180E92CC00EF57C3 /* UICheckBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58C8180E92CC00EF57C3 /* UICheckBox.h */; }; 1A8C5904180E92CC00EF57C3 /* UIHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58CB180E92CC00EF57C3 /* UIHelper.cpp */; }; 1A8C5905180E92CC00EF57C3 /* UIHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58CB180E92CC00EF57C3 /* UIHelper.cpp */; }; 1A8C5906180E92CC00EF57C3 /* UIHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58CC180E92CC00EF57C3 /* UIHelper.h */; }; 1A8C5907180E92CC00EF57C3 /* UIHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58CC180E92CC00EF57C3 /* UIHelper.h */; }; 1A8C5908180E92CC00EF57C3 /* UIImageView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58CD180E92CC00EF57C3 /* UIImageView.cpp */; }; 1A8C5909180E92CC00EF57C3 /* UIImageView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58CD180E92CC00EF57C3 /* UIImageView.cpp */; }; 1A8C590A180E92CC00EF57C3 /* UIImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58CE180E92CC00EF57C3 /* UIImageView.h */; }; 1A8C590B180E92CC00EF57C3 /* UIImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58CE180E92CC00EF57C3 /* UIImageView.h */; }; 1A8C5910180E92CC00EF57C3 /* UIText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58D1180E92CC00EF57C3 /* UIText.cpp */; }; 1A8C5911180E92CC00EF57C3 /* UIText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58D1180E92CC00EF57C3 /* UIText.cpp */; }; 1A8C5912180E92CC00EF57C3 /* UIText.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58D2180E92CC00EF57C3 /* UIText.h */; }; 1A8C5913180E92CC00EF57C3 /* UIText.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58D2180E92CC00EF57C3 /* UIText.h */; }; 1A8C5914180E92CC00EF57C3 /* UITextAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58D3180E92CC00EF57C3 /* UITextAtlas.cpp */; }; 1A8C5915180E92CC00EF57C3 /* UITextAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58D3180E92CC00EF57C3 /* UITextAtlas.cpp */; }; 1A8C5916180E92CC00EF57C3 /* UITextAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58D4180E92CC00EF57C3 /* UITextAtlas.h */; }; 1A8C5917180E92CC00EF57C3 /* UITextAtlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58D4180E92CC00EF57C3 /* UITextAtlas.h */; }; 1A8C5918180E92CC00EF57C3 /* UITextBMFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58D5180E92CC00EF57C3 /* UITextBMFont.cpp */; }; 1A8C5919180E92CC00EF57C3 /* UITextBMFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58D5180E92CC00EF57C3 /* UITextBMFont.cpp */; }; 1A8C591A180E92CC00EF57C3 /* UITextBMFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58D6180E92CC00EF57C3 /* UITextBMFont.h */; }; 1A8C591B180E92CC00EF57C3 /* UITextBMFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58D6180E92CC00EF57C3 /* UITextBMFont.h */; }; 1A8C5920180E92CC00EF57C3 /* UILayoutDefine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58D9180E92CC00EF57C3 /* UILayoutDefine.cpp */; }; 1A8C5921180E92CC00EF57C3 /* UILayoutDefine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58D9180E92CC00EF57C3 /* UILayoutDefine.cpp */; }; 1A8C5922180E92CC00EF57C3 /* UILayoutDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58DA180E92CC00EF57C3 /* UILayoutDefine.h */; }; 1A8C5923180E92CC00EF57C3 /* UILayoutDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58DA180E92CC00EF57C3 /* UILayoutDefine.h */; }; 1A8C5928180E92CC00EF57C3 /* UILoadingBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58DD180E92CC00EF57C3 /* UILoadingBar.cpp */; }; 1A8C5929180E92CC00EF57C3 /* UILoadingBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58DD180E92CC00EF57C3 /* UILoadingBar.cpp */; }; 1A8C592A180E92CC00EF57C3 /* UILoadingBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58DE180E92CC00EF57C3 /* UILoadingBar.h */; }; 1A8C592B180E92CC00EF57C3 /* UILoadingBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58DE180E92CC00EF57C3 /* UILoadingBar.h */; }; 1A8C592C180E92CC00EF57C3 /* UIPageView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58DF180E92CC00EF57C3 /* UIPageView.cpp */; }; 1A8C592D180E92CC00EF57C3 /* UIPageView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58DF180E92CC00EF57C3 /* UIPageView.cpp */; }; 1A8C592E180E92CC00EF57C3 /* UIPageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E0180E92CC00EF57C3 /* UIPageView.h */; }; 1A8C592F180E92CC00EF57C3 /* UIPageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E0180E92CC00EF57C3 /* UIPageView.h */; }; 1A8C5934180E92CC00EF57C3 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E3180E92CC00EF57C3 /* UIScrollInterface.h */; }; 1A8C5935180E92CC00EF57C3 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E3180E92CC00EF57C3 /* UIScrollInterface.h */; }; 1A8C5936180E92CC00EF57C3 /* UIScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58E4180E92CC00EF57C3 /* UIScrollView.cpp */; }; 1A8C5937180E92CC00EF57C3 /* UIScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58E4180E92CC00EF57C3 /* UIScrollView.cpp */; }; 1A8C5938180E92CC00EF57C3 /* UIScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E5180E92CC00EF57C3 /* UIScrollView.h */; }; 1A8C5939180E92CC00EF57C3 /* UIScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E5180E92CC00EF57C3 /* UIScrollView.h */; }; 1A8C593A180E92CC00EF57C3 /* UISlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58E6180E92CC00EF57C3 /* UISlider.cpp */; }; 1A8C593B180E92CC00EF57C3 /* UISlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58E6180E92CC00EF57C3 /* UISlider.cpp */; }; 1A8C593C180E92CC00EF57C3 /* UISlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E7180E92CC00EF57C3 /* UISlider.h */; }; 1A8C593D180E92CC00EF57C3 /* UISlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E7180E92CC00EF57C3 /* UISlider.h */; }; 1A8C593E180E92CC00EF57C3 /* UITextField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58E8180E92CC00EF57C3 /* UITextField.cpp */; }; 1A8C593F180E92CC00EF57C3 /* UITextField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58E8180E92CC00EF57C3 /* UITextField.cpp */; }; 1A8C5940180E92CC00EF57C3 /* UITextField.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E9180E92CC00EF57C3 /* UITextField.h */; }; 1A8C5941180E92CC00EF57C3 /* UITextField.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58E9180E92CC00EF57C3 /* UITextField.h */; }; 1A8C5942180E92CC00EF57C3 /* UIWidget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58EA180E92CC00EF57C3 /* UIWidget.cpp */; }; 1A8C5943180E92CC00EF57C3 /* UIWidget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C58EA180E92CC00EF57C3 /* UIWidget.cpp */; }; 1A8C5944180E92CC00EF57C3 /* UIWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58EB180E92CC00EF57C3 /* UIWidget.h */; }; 1A8C5945180E92CC00EF57C3 /* UIWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C58EB180E92CC00EF57C3 /* UIWidget.h */; }; 1A8C598B180E930E00EF57C3 /* CCActionFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */; }; 1A8C598C180E930E00EF57C3 /* CCActionFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */; }; 1A8C598D180E930E00EF57C3 /* CCActionFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5949180E930E00EF57C3 /* CCActionFrame.h */; }; 1A8C598E180E930E00EF57C3 /* CCActionFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5949180E930E00EF57C3 /* CCActionFrame.h */; }; 1A8C598F180E930E00EF57C3 /* CCActionFrameEasing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C594A180E930E00EF57C3 /* CCActionFrameEasing.cpp */; }; 1A8C5990180E930E00EF57C3 /* CCActionFrameEasing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C594A180E930E00EF57C3 /* CCActionFrameEasing.cpp */; }; 1A8C5991180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C594B180E930E00EF57C3 /* CCActionFrameEasing.h */; }; 1A8C5992180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C594B180E930E00EF57C3 /* CCActionFrameEasing.h */; }; 1A8C5993180E930E00EF57C3 /* CCActionManagerEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C594C180E930E00EF57C3 /* CCActionManagerEx.cpp */; }; 1A8C5994180E930E00EF57C3 /* CCActionManagerEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C594C180E930E00EF57C3 /* CCActionManagerEx.cpp */; }; 1A8C5995180E930E00EF57C3 /* CCActionManagerEx.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C594D180E930E00EF57C3 /* CCActionManagerEx.h */; }; 1A8C5996180E930E00EF57C3 /* CCActionManagerEx.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C594D180E930E00EF57C3 /* CCActionManagerEx.h */; }; 1A8C5997180E930E00EF57C3 /* CCActionNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C594E180E930E00EF57C3 /* CCActionNode.cpp */; }; 1A8C5998180E930E00EF57C3 /* CCActionNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C594E180E930E00EF57C3 /* CCActionNode.cpp */; }; 1A8C5999180E930E00EF57C3 /* CCActionNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C594F180E930E00EF57C3 /* CCActionNode.h */; }; 1A8C599A180E930E00EF57C3 /* CCActionNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C594F180E930E00EF57C3 /* CCActionNode.h */; }; 1A8C599B180E930E00EF57C3 /* CCActionObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5950180E930E00EF57C3 /* CCActionObject.cpp */; }; 1A8C599C180E930E00EF57C3 /* CCActionObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5950180E930E00EF57C3 /* CCActionObject.cpp */; }; 1A8C599D180E930E00EF57C3 /* CCActionObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5951180E930E00EF57C3 /* CCActionObject.h */; }; 1A8C599E180E930E00EF57C3 /* CCActionObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5951180E930E00EF57C3 /* CCActionObject.h */; }; 1A8C599F180E930E00EF57C3 /* CCArmature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5952180E930E00EF57C3 /* CCArmature.cpp */; }; 1A8C59A0180E930E00EF57C3 /* CCArmature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5952180E930E00EF57C3 /* CCArmature.cpp */; }; 1A8C59A1180E930E00EF57C3 /* CCArmature.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5953180E930E00EF57C3 /* CCArmature.h */; }; 1A8C59A2180E930E00EF57C3 /* CCArmature.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5953180E930E00EF57C3 /* CCArmature.h */; }; 1A8C59A3180E930E00EF57C3 /* CCArmatureAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5954180E930E00EF57C3 /* CCArmatureAnimation.cpp */; }; 1A8C59A4180E930E00EF57C3 /* CCArmatureAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5954180E930E00EF57C3 /* CCArmatureAnimation.cpp */; }; 1A8C59A5180E930E00EF57C3 /* CCArmatureAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5955180E930E00EF57C3 /* CCArmatureAnimation.h */; }; 1A8C59A6180E930E00EF57C3 /* CCArmatureAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5955180E930E00EF57C3 /* CCArmatureAnimation.h */; }; 1A8C59A7180E930E00EF57C3 /* CCArmatureDataManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5956180E930E00EF57C3 /* CCArmatureDataManager.cpp */; }; 1A8C59A8180E930E00EF57C3 /* CCArmatureDataManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5956180E930E00EF57C3 /* CCArmatureDataManager.cpp */; }; 1A8C59A9180E930E00EF57C3 /* CCArmatureDataManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5957180E930E00EF57C3 /* CCArmatureDataManager.h */; }; 1A8C59AA180E930E00EF57C3 /* CCArmatureDataManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5957180E930E00EF57C3 /* CCArmatureDataManager.h */; }; 1A8C59AB180E930E00EF57C3 /* CCArmatureDefine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5958180E930E00EF57C3 /* CCArmatureDefine.cpp */; }; 1A8C59AC180E930E00EF57C3 /* CCArmatureDefine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5958180E930E00EF57C3 /* CCArmatureDefine.cpp */; }; 1A8C59AD180E930E00EF57C3 /* CCArmatureDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5959180E930E00EF57C3 /* CCArmatureDefine.h */; }; 1A8C59AE180E930E00EF57C3 /* CCArmatureDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5959180E930E00EF57C3 /* CCArmatureDefine.h */; }; 1A8C59AF180E930E00EF57C3 /* CCBatchNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C595A180E930E00EF57C3 /* CCBatchNode.cpp */; }; 1A8C59B0180E930E00EF57C3 /* CCBatchNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C595A180E930E00EF57C3 /* CCBatchNode.cpp */; }; 1A8C59B1180E930E00EF57C3 /* CCBatchNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C595B180E930E00EF57C3 /* CCBatchNode.h */; }; 1A8C59B2180E930E00EF57C3 /* CCBatchNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C595B180E930E00EF57C3 /* CCBatchNode.h */; }; 1A8C59B3180E930E00EF57C3 /* CCBone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C595C180E930E00EF57C3 /* CCBone.cpp */; }; 1A8C59B4180E930E00EF57C3 /* CCBone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C595C180E930E00EF57C3 /* CCBone.cpp */; }; 1A8C59B5180E930E00EF57C3 /* CCBone.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C595D180E930E00EF57C3 /* CCBone.h */; }; 1A8C59B6180E930E00EF57C3 /* CCBone.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C595D180E930E00EF57C3 /* CCBone.h */; }; 1A8C59B7180E930E00EF57C3 /* CCColliderDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C595E180E930E00EF57C3 /* CCColliderDetector.cpp */; }; 1A8C59B8180E930E00EF57C3 /* CCColliderDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C595E180E930E00EF57C3 /* CCColliderDetector.cpp */; }; 1A8C59B9180E930E00EF57C3 /* CCColliderDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C595F180E930E00EF57C3 /* CCColliderDetector.h */; }; 1A8C59BA180E930E00EF57C3 /* CCColliderDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C595F180E930E00EF57C3 /* CCColliderDetector.h */; }; 1A8C59BB180E930E00EF57C3 /* CCComAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5960180E930E00EF57C3 /* CCComAttribute.cpp */; }; 1A8C59BC180E930E00EF57C3 /* CCComAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5960180E930E00EF57C3 /* CCComAttribute.cpp */; }; 1A8C59BD180E930E00EF57C3 /* CCComAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5961180E930E00EF57C3 /* CCComAttribute.h */; }; 1A8C59BE180E930E00EF57C3 /* CCComAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5961180E930E00EF57C3 /* CCComAttribute.h */; }; 1A8C59BF180E930E00EF57C3 /* CCComAudio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5962180E930E00EF57C3 /* CCComAudio.cpp */; }; 1A8C59C0180E930E00EF57C3 /* CCComAudio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5962180E930E00EF57C3 /* CCComAudio.cpp */; }; 1A8C59C1180E930E00EF57C3 /* CCComAudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5963180E930E00EF57C3 /* CCComAudio.h */; }; 1A8C59C2180E930E00EF57C3 /* CCComAudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5963180E930E00EF57C3 /* CCComAudio.h */; }; 1A8C59C3180E930E00EF57C3 /* CCComController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5964180E930E00EF57C3 /* CCComController.cpp */; }; 1A8C59C4180E930E00EF57C3 /* CCComController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5964180E930E00EF57C3 /* CCComController.cpp */; }; 1A8C59C5180E930E00EF57C3 /* CCComController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5965180E930E00EF57C3 /* CCComController.h */; }; 1A8C59C6180E930E00EF57C3 /* CCComController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5965180E930E00EF57C3 /* CCComController.h */; }; 1A8C59C7180E930E00EF57C3 /* CCComRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5966180E930E00EF57C3 /* CCComRender.cpp */; }; 1A8C59C8180E930E00EF57C3 /* CCComRender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5966180E930E00EF57C3 /* CCComRender.cpp */; }; 1A8C59C9180E930E00EF57C3 /* CCComRender.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5967180E930E00EF57C3 /* CCComRender.h */; }; 1A8C59CA180E930E00EF57C3 /* CCComRender.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5967180E930E00EF57C3 /* CCComRender.h */; }; 1A8C59CB180E930E00EF57C3 /* CCDataReaderHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5968180E930E00EF57C3 /* CCDataReaderHelper.cpp */; }; 1A8C59CC180E930E00EF57C3 /* CCDataReaderHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5968180E930E00EF57C3 /* CCDataReaderHelper.cpp */; }; 1A8C59CD180E930E00EF57C3 /* CCDataReaderHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5969180E930E00EF57C3 /* CCDataReaderHelper.h */; }; 1A8C59CE180E930E00EF57C3 /* CCDataReaderHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5969180E930E00EF57C3 /* CCDataReaderHelper.h */; }; 1A8C59CF180E930E00EF57C3 /* CCDatas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C596A180E930E00EF57C3 /* CCDatas.cpp */; }; 1A8C59D0180E930E00EF57C3 /* CCDatas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C596A180E930E00EF57C3 /* CCDatas.cpp */; }; 1A8C59D1180E930E00EF57C3 /* CCDatas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C596B180E930E00EF57C3 /* CCDatas.h */; }; 1A8C59D2180E930E00EF57C3 /* CCDatas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C596B180E930E00EF57C3 /* CCDatas.h */; }; 1A8C59D3180E930E00EF57C3 /* CCDecorativeDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C596C180E930E00EF57C3 /* CCDecorativeDisplay.cpp */; }; 1A8C59D4180E930E00EF57C3 /* CCDecorativeDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C596C180E930E00EF57C3 /* CCDecorativeDisplay.cpp */; }; 1A8C59D5180E930E00EF57C3 /* CCDecorativeDisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C596D180E930E00EF57C3 /* CCDecorativeDisplay.h */; }; 1A8C59D6180E930E00EF57C3 /* CCDecorativeDisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C596D180E930E00EF57C3 /* CCDecorativeDisplay.h */; }; 1A8C59D7180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C596E180E930E00EF57C3 /* CCDisplayFactory.cpp */; }; 1A8C59D8180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C596E180E930E00EF57C3 /* CCDisplayFactory.cpp */; }; 1A8C59D9180E930E00EF57C3 /* CCDisplayFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C596F180E930E00EF57C3 /* CCDisplayFactory.h */; }; 1A8C59DA180E930E00EF57C3 /* CCDisplayFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C596F180E930E00EF57C3 /* CCDisplayFactory.h */; }; 1A8C59DB180E930E00EF57C3 /* CCDisplayManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5970180E930E00EF57C3 /* CCDisplayManager.cpp */; }; 1A8C59DC180E930E00EF57C3 /* CCDisplayManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5970180E930E00EF57C3 /* CCDisplayManager.cpp */; }; 1A8C59DD180E930E00EF57C3 /* CCDisplayManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5971180E930E00EF57C3 /* CCDisplayManager.h */; }; 1A8C59DE180E930E00EF57C3 /* CCDisplayManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5971180E930E00EF57C3 /* CCDisplayManager.h */; }; 1A8C59DF180E930E00EF57C3 /* CCInputDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5972180E930E00EF57C3 /* CCInputDelegate.cpp */; }; 1A8C59E0180E930E00EF57C3 /* CCInputDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5972180E930E00EF57C3 /* CCInputDelegate.cpp */; }; 1A8C59E1180E930E00EF57C3 /* CCInputDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5973180E930E00EF57C3 /* CCInputDelegate.h */; }; 1A8C59E2180E930E00EF57C3 /* CCInputDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5973180E930E00EF57C3 /* CCInputDelegate.h */; }; 1A8C59E3180E930E00EF57C3 /* CCProcessBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5974180E930E00EF57C3 /* CCProcessBase.cpp */; }; 1A8C59E4180E930E00EF57C3 /* CCProcessBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5974180E930E00EF57C3 /* CCProcessBase.cpp */; }; 1A8C59E5180E930E00EF57C3 /* CCProcessBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5975180E930E00EF57C3 /* CCProcessBase.h */; }; 1A8C59E6180E930E00EF57C3 /* CCProcessBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5975180E930E00EF57C3 /* CCProcessBase.h */; }; 1A8C59E7180E930E00EF57C3 /* CCSGUIReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5976180E930E00EF57C3 /* CCSGUIReader.cpp */; }; 1A8C59E8180E930E00EF57C3 /* CCSGUIReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5976180E930E00EF57C3 /* CCSGUIReader.cpp */; }; 1A8C59E9180E930E00EF57C3 /* CCSGUIReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5977180E930E00EF57C3 /* CCSGUIReader.h */; }; 1A8C59EA180E930E00EF57C3 /* CCSGUIReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5977180E930E00EF57C3 /* CCSGUIReader.h */; }; 1A8C59EB180E930E00EF57C3 /* CCSkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5978180E930E00EF57C3 /* CCSkin.cpp */; }; 1A8C59EC180E930E00EF57C3 /* CCSkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5978180E930E00EF57C3 /* CCSkin.cpp */; }; 1A8C59ED180E930E00EF57C3 /* CCSkin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5979180E930E00EF57C3 /* CCSkin.h */; }; 1A8C59EE180E930E00EF57C3 /* CCSkin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5979180E930E00EF57C3 /* CCSkin.h */; }; 1A8C59EF180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C597A180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp */; }; 1A8C59F0180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C597A180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp */; }; 1A8C59F1180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C597B180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h */; }; 1A8C59F2180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C597B180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h */; }; 1A8C59F3180E930E00EF57C3 /* CCSSceneReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C597C180E930E00EF57C3 /* CCSSceneReader.cpp */; }; 1A8C59F4180E930E00EF57C3 /* CCSSceneReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C597C180E930E00EF57C3 /* CCSSceneReader.cpp */; }; 1A8C59F5180E930E00EF57C3 /* CCSSceneReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C597D180E930E00EF57C3 /* CCSSceneReader.h */; }; 1A8C59F6180E930E00EF57C3 /* CCSSceneReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C597D180E930E00EF57C3 /* CCSSceneReader.h */; }; 1A8C59F7180E930E00EF57C3 /* CCTransformHelp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C597E180E930E00EF57C3 /* CCTransformHelp.cpp */; }; 1A8C59F8180E930E00EF57C3 /* CCTransformHelp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C597E180E930E00EF57C3 /* CCTransformHelp.cpp */; }; 1A8C59F9180E930E00EF57C3 /* CCTransformHelp.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C597F180E930E00EF57C3 /* CCTransformHelp.h */; }; 1A8C59FA180E930E00EF57C3 /* CCTransformHelp.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C597F180E930E00EF57C3 /* CCTransformHelp.h */; }; 1A8C59FB180E930E00EF57C3 /* CCTween.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5980180E930E00EF57C3 /* CCTween.cpp */; }; 1A8C59FC180E930E00EF57C3 /* CCTween.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5980180E930E00EF57C3 /* CCTween.cpp */; }; 1A8C59FD180E930E00EF57C3 /* CCTween.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5981180E930E00EF57C3 /* CCTween.h */; }; 1A8C59FE180E930E00EF57C3 /* CCTween.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5981180E930E00EF57C3 /* CCTween.h */; }; 1A8C59FF180E930E00EF57C3 /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5982180E930E00EF57C3 /* CCTweenFunction.cpp */; }; 1A8C5A00180E930E00EF57C3 /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5982180E930E00EF57C3 /* CCTweenFunction.cpp */; }; 1A8C5A01180E930E00EF57C3 /* CCTweenFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5983180E930E00EF57C3 /* CCTweenFunction.h */; }; 1A8C5A02180E930E00EF57C3 /* CCTweenFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5983180E930E00EF57C3 /* CCTweenFunction.h */; }; 1A8C5A03180E930E00EF57C3 /* CCUtilMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5984180E930E00EF57C3 /* CCUtilMath.cpp */; }; 1A8C5A04180E930E00EF57C3 /* CCUtilMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5984180E930E00EF57C3 /* CCUtilMath.cpp */; }; 1A8C5A05180E930E00EF57C3 /* CCUtilMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5985180E930E00EF57C3 /* CCUtilMath.h */; }; 1A8C5A06180E930E00EF57C3 /* CCUtilMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5985180E930E00EF57C3 /* CCUtilMath.h */; }; 1A8C5A07180E930E00EF57C3 /* CocoStudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5986180E930E00EF57C3 /* CocoStudio.h */; }; 1A8C5A08180E930E00EF57C3 /* CocoStudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5986180E930E00EF57C3 /* CocoStudio.h */; }; 1A8C5A0D180E930E00EF57C3 /* DictionaryHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5989180E930E00EF57C3 /* DictionaryHelper.cpp */; }; 1A8C5A0E180E930E00EF57C3 /* DictionaryHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5989180E930E00EF57C3 /* DictionaryHelper.cpp */; }; 1A8C5A0F180E930E00EF57C3 /* DictionaryHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C598A180E930E00EF57C3 /* DictionaryHelper.h */; }; 1A8C5A10180E930E00EF57C3 /* DictionaryHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C598A180E930E00EF57C3 /* DictionaryHelper.h */; }; 1A94D35116C2072800D79D09 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; }; 1A9DCA13180E6955007A3AD4 /* ccConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DC9F8180E6955007A3AD4 /* ccConfig.h */; }; 1A9DCA14180E6955007A3AD4 /* ccConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DC9F8180E6955007A3AD4 /* ccConfig.h */; }; 1A9DCA15180E6955007A3AD4 /* CCConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC9F9180E6955007A3AD4 /* CCConfiguration.cpp */; }; 1A9DCA16180E6955007A3AD4 /* CCConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC9F9180E6955007A3AD4 /* CCConfiguration.cpp */; }; 1A9DCA17180E6955007A3AD4 /* CCConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DC9FA180E6955007A3AD4 /* CCConfiguration.h */; }; 1A9DCA18180E6955007A3AD4 /* CCConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DC9FA180E6955007A3AD4 /* CCConfiguration.h */; }; 1A9DCA1D180E6955007A3AD4 /* CCDirector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC9FD180E6955007A3AD4 /* CCDirector.cpp */; }; 1A9DCA1E180E6955007A3AD4 /* CCDirector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC9FD180E6955007A3AD4 /* CCDirector.cpp */; }; 1A9DCA1F180E6955007A3AD4 /* CCDirector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DC9FE180E6955007A3AD4 /* CCDirector.h */; }; 1A9DCA20180E6955007A3AD4 /* CCDirector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DC9FE180E6955007A3AD4 /* CCDirector.h */; }; 1A9DCA21180E6955007A3AD4 /* CCEventType.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DC9FF180E6955007A3AD4 /* CCEventType.h */; }; 1A9DCA22180E6955007A3AD4 /* CCEventType.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DC9FF180E6955007A3AD4 /* CCEventType.h */; }; 1A9DCA23180E6955007A3AD4 /* ccFPSImages.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA00180E6955007A3AD4 /* ccFPSImages.c */; }; 1A9DCA24180E6955007A3AD4 /* ccFPSImages.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA00180E6955007A3AD4 /* ccFPSImages.c */; }; 1A9DCA25180E6955007A3AD4 /* ccFPSImages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA01180E6955007A3AD4 /* ccFPSImages.h */; }; 1A9DCA26180E6955007A3AD4 /* ccFPSImages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA01180E6955007A3AD4 /* ccFPSImages.h */; }; 1A9DCA27180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA02180E6955007A3AD4 /* CCGLBufferedNode.cpp */; }; 1A9DCA28180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA02180E6955007A3AD4 /* CCGLBufferedNode.cpp */; }; 1A9DCA29180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA03180E6955007A3AD4 /* CCGLBufferedNode.h */; }; 1A9DCA2A180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA03180E6955007A3AD4 /* CCGLBufferedNode.h */; }; 1A9DCA2B180E6955007A3AD4 /* ccMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA04180E6955007A3AD4 /* ccMacros.h */; }; 1A9DCA2C180E6955007A3AD4 /* ccMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA04180E6955007A3AD4 /* ccMacros.h */; }; 1A9DCA2D180E6955007A3AD4 /* CCProtocols.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA05180E6955007A3AD4 /* CCProtocols.h */; }; 1A9DCA2E180E6955007A3AD4 /* CCProtocols.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA05180E6955007A3AD4 /* CCProtocols.h */; }; 1A9DCA2F180E6955007A3AD4 /* CCScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA06180E6955007A3AD4 /* CCScheduler.cpp */; }; 1A9DCA30180E6955007A3AD4 /* CCScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA06180E6955007A3AD4 /* CCScheduler.cpp */; }; 1A9DCA31180E6955007A3AD4 /* CCScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA07180E6955007A3AD4 /* CCScheduler.h */; }; 1A9DCA32180E6955007A3AD4 /* CCScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA07180E6955007A3AD4 /* CCScheduler.h */; }; 1A9DCA37180E6955007A3AD4 /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA0A180E6955007A3AD4 /* cocos2d.cpp */; }; 1A9DCA38180E6955007A3AD4 /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA0A180E6955007A3AD4 /* cocos2d.cpp */; }; 1A9DCA39180E6955007A3AD4 /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0B180E6955007A3AD4 /* cocos2d.h */; }; 1A9DCA3A180E6955007A3AD4 /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0B180E6955007A3AD4 /* cocos2d.h */; }; 1A9DCA3B180E6955007A3AD4 /* firePngData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0C180E6955007A3AD4 /* firePngData.h */; }; 1A9DCA3C180E6955007A3AD4 /* firePngData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0C180E6955007A3AD4 /* firePngData.h */; }; 1A9DCA3D180E6955007A3AD4 /* TransformUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA0D180E6955007A3AD4 /* TransformUtils.cpp */; }; 1A9DCA3E180E6955007A3AD4 /* TransformUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA0D180E6955007A3AD4 /* TransformUtils.cpp */; }; 1A9DCA3F180E6955007A3AD4 /* TransformUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0E180E6955007A3AD4 /* TransformUtils.h */; }; 1A9DCA40180E6955007A3AD4 /* TransformUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0E180E6955007A3AD4 /* TransformUtils.h */; }; 1A9DCA43180E6D90007A3AD4 /* CCDeprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA41180E6D90007A3AD4 /* CCDeprecated.cpp */; }; 1A9DCA44180E6D90007A3AD4 /* CCDeprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA41180E6D90007A3AD4 /* CCDeprecated.cpp */; }; 1A9DCA45180E6D90007A3AD4 /* CCDeprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA42180E6D90007A3AD4 /* CCDeprecated.h */; }; 1A9DCA46180E6D90007A3AD4 /* CCDeprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA42180E6D90007A3AD4 /* CCDeprecated.h */; }; 1A9DCA49180E6DE3007A3AD4 /* ccTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA47180E6DE3007A3AD4 /* ccTypes.cpp */; }; 1A9DCA4A180E6DE3007A3AD4 /* ccTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DCA47180E6DE3007A3AD4 /* ccTypes.cpp */; }; 1A9DCA4B180E6DE3007A3AD4 /* ccTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA48180E6DE3007A3AD4 /* ccTypes.h */; }; 1A9DCA4C180E6DE3007A3AD4 /* ccTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA48180E6DE3007A3AD4 /* ccTypes.h */; }; 1A9DCA4D180E6E3C007A3AD4 /* libjs_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AAF5421180E4047000584C8 /* libjs_static.a */; }; 1A9DCA4E180E6E42007A3AD4 /* libjs_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AAF5424180E405B000584C8 /* libjs_static.a */; }; 1AA2063F1848437900053418 /* CCMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA2063E1848437900053418 /* CCMap.h */; }; 1AA206401848437A00053418 /* CCMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA2063E1848437900053418 /* CCMap.h */; }; 1AAF528B180E2ECC000584C8 /* b2BroadPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B61807AF9C005B8026 /* b2BroadPhase.cpp */; }; 1AAF528C180E2ECC000584C8 /* b2BroadPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168B71807AF9C005B8026 /* b2BroadPhase.h */; }; 1AAF528D180E2ECC000584C8 /* b2CollideCircle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B81807AF9C005B8026 /* b2CollideCircle.cpp */; }; 1AAF528E180E2ECC000584C8 /* b2CollideEdge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B91807AF9C005B8026 /* b2CollideEdge.cpp */; }; 1AAF528F180E2ECC000584C8 /* b2CollidePolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168BA1807AF9C005B8026 /* b2CollidePolygon.cpp */; }; 1AAF5290180E2ECC000584C8 /* b2Collision.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168BB1807AF9C005B8026 /* b2Collision.cpp */; }; 1AAF5291180E2ECC000584C8 /* b2Collision.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168BC1807AF9C005B8026 /* b2Collision.h */; }; 1AAF5292180E2ECC000584C8 /* b2Distance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168BD1807AF9C005B8026 /* b2Distance.cpp */; }; 1AAF5293180E2ECC000584C8 /* b2Distance.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168BE1807AF9C005B8026 /* b2Distance.h */; }; 1AAF5294180E2ECC000584C8 /* b2DynamicTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168BF1807AF9C005B8026 /* b2DynamicTree.cpp */; }; 1AAF5295180E2ECC000584C8 /* b2DynamicTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C01807AF9C005B8026 /* b2DynamicTree.h */; }; 1AAF5296180E2ECC000584C8 /* b2TimeOfImpact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168C11807AF9C005B8026 /* b2TimeOfImpact.cpp */; }; 1AAF5297180E2ECC000584C8 /* b2TimeOfImpact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C21807AF9C005B8026 /* b2TimeOfImpact.h */; }; 1AAF5298180E2ED2000584C8 /* Box2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168B41807AF9C005B8026 /* Box2D.h */; }; 1AAF5299180E2EE1000584C8 /* Box2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168B41807AF9C005B8026 /* Box2D.h */; }; 1AAF529A180E2EE4000584C8 /* b2BroadPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B61807AF9C005B8026 /* b2BroadPhase.cpp */; }; 1AAF529B180E2EE4000584C8 /* b2BroadPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168B71807AF9C005B8026 /* b2BroadPhase.h */; }; 1AAF529C180E2EE4000584C8 /* b2CollideCircle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B81807AF9C005B8026 /* b2CollideCircle.cpp */; }; 1AAF529D180E2EE4000584C8 /* b2CollideEdge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B91807AF9C005B8026 /* b2CollideEdge.cpp */; }; 1AAF529E180E2EE4000584C8 /* b2CollidePolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168BA1807AF9C005B8026 /* b2CollidePolygon.cpp */; }; 1AAF529F180E2EE4000584C8 /* b2Collision.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168BB1807AF9C005B8026 /* b2Collision.cpp */; }; 1AAF52A0180E2EE4000584C8 /* b2Collision.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168BC1807AF9C005B8026 /* b2Collision.h */; }; 1AAF52A1180E2EE4000584C8 /* b2Distance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168BD1807AF9C005B8026 /* b2Distance.cpp */; }; 1AAF52A2180E2EE4000584C8 /* b2Distance.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168BE1807AF9C005B8026 /* b2Distance.h */; }; 1AAF52A3180E2EE4000584C8 /* b2DynamicTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168BF1807AF9C005B8026 /* b2DynamicTree.cpp */; }; 1AAF52A4180E2EE4000584C8 /* b2DynamicTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C01807AF9C005B8026 /* b2DynamicTree.h */; }; 1AAF52A5180E2EE4000584C8 /* b2TimeOfImpact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168C11807AF9C005B8026 /* b2TimeOfImpact.cpp */; }; 1AAF52A6180E2EE4000584C8 /* b2TimeOfImpact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C21807AF9C005B8026 /* b2TimeOfImpact.h */; }; 1AAF52A7180E2EE8000584C8 /* b2ChainShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168C41807AF9C005B8026 /* b2ChainShape.cpp */; }; 1AAF52A8180E2EE8000584C8 /* b2ChainShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C51807AF9C005B8026 /* b2ChainShape.h */; }; 1AAF52A9180E2EE8000584C8 /* b2CircleShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168C61807AF9C005B8026 /* b2CircleShape.cpp */; }; 1AAF52AA180E2EE8000584C8 /* b2CircleShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C71807AF9C005B8026 /* b2CircleShape.h */; }; 1AAF52AB180E2EE8000584C8 /* b2EdgeShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168C81807AF9C005B8026 /* b2EdgeShape.cpp */; }; 1AAF52AC180E2EE8000584C8 /* b2EdgeShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C91807AF9C005B8026 /* b2EdgeShape.h */; }; 1AAF52AD180E2EE8000584C8 /* b2PolygonShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168CA1807AF9C005B8026 /* b2PolygonShape.cpp */; }; 1AAF52AE180E2EE8000584C8 /* b2PolygonShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168CB1807AF9C005B8026 /* b2PolygonShape.h */; }; 1AAF52AF180E2EE8000584C8 /* b2Shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168CC1807AF9C005B8026 /* b2Shape.h */; }; 1AAF52B0180E2EE9000584C8 /* b2ChainShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168C41807AF9C005B8026 /* b2ChainShape.cpp */; }; 1AAF52B1180E2EE9000584C8 /* b2ChainShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C51807AF9C005B8026 /* b2ChainShape.h */; }; 1AAF52B2180E2EE9000584C8 /* b2CircleShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168C61807AF9C005B8026 /* b2CircleShape.cpp */; }; 1AAF52B3180E2EE9000584C8 /* b2CircleShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C71807AF9C005B8026 /* b2CircleShape.h */; }; 1AAF52B4180E2EE9000584C8 /* b2EdgeShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168C81807AF9C005B8026 /* b2EdgeShape.cpp */; }; 1AAF52B5180E2EE9000584C8 /* b2EdgeShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168C91807AF9C005B8026 /* b2EdgeShape.h */; }; 1AAF52B6180E2EE9000584C8 /* b2PolygonShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168CA1807AF9C005B8026 /* b2PolygonShape.cpp */; }; 1AAF52B7180E2EE9000584C8 /* b2PolygonShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168CB1807AF9C005B8026 /* b2PolygonShape.h */; }; 1AAF52B8180E2EE9000584C8 /* b2Shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168CC1807AF9C005B8026 /* b2Shape.h */; }; 1AAF52B9180E2EEE000584C8 /* b2BlockAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168CE1807AF9C005B8026 /* b2BlockAllocator.cpp */; }; 1AAF52BA180E2EEE000584C8 /* b2BlockAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168CF1807AF9C005B8026 /* b2BlockAllocator.h */; }; 1AAF52BB180E2EEE000584C8 /* b2Draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D01807AF9C005B8026 /* b2Draw.cpp */; }; 1AAF52BC180E2EEE000584C8 /* b2Draw.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D11807AF9C005B8026 /* b2Draw.h */; }; 1AAF52BD180E2EEE000584C8 /* b2GrowableStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D21807AF9C005B8026 /* b2GrowableStack.h */; }; 1AAF52BE180E2EEE000584C8 /* b2Math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D31807AF9C005B8026 /* b2Math.cpp */; }; 1AAF52BF180E2EEE000584C8 /* b2Math.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D41807AF9C005B8026 /* b2Math.h */; }; 1AAF52C0180E2EEE000584C8 /* b2Settings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D51807AF9C005B8026 /* b2Settings.cpp */; }; 1AAF52C1180E2EEE000584C8 /* b2Settings.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D61807AF9C005B8026 /* b2Settings.h */; }; 1AAF52C2180E2EEE000584C8 /* b2StackAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D71807AF9C005B8026 /* b2StackAllocator.cpp */; }; 1AAF52C3180E2EEE000584C8 /* b2StackAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D81807AF9C005B8026 /* b2StackAllocator.h */; }; 1AAF52C4180E2EEE000584C8 /* b2Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D91807AF9C005B8026 /* b2Timer.cpp */; }; 1AAF52C5180E2EEE000584C8 /* b2Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168DA1807AF9C005B8026 /* b2Timer.h */; }; 1AAF52C6180E2EEF000584C8 /* b2BlockAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168CE1807AF9C005B8026 /* b2BlockAllocator.cpp */; }; 1AAF52C7180E2EEF000584C8 /* b2BlockAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168CF1807AF9C005B8026 /* b2BlockAllocator.h */; }; 1AAF52C8180E2EEF000584C8 /* b2Draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D01807AF9C005B8026 /* b2Draw.cpp */; }; 1AAF52C9180E2EEF000584C8 /* b2Draw.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D11807AF9C005B8026 /* b2Draw.h */; }; 1AAF52CA180E2EEF000584C8 /* b2GrowableStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D21807AF9C005B8026 /* b2GrowableStack.h */; }; 1AAF52CB180E2EEF000584C8 /* b2Math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D31807AF9C005B8026 /* b2Math.cpp */; }; 1AAF52CC180E2EEF000584C8 /* b2Math.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D41807AF9C005B8026 /* b2Math.h */; }; 1AAF52CD180E2EEF000584C8 /* b2Settings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D51807AF9C005B8026 /* b2Settings.cpp */; }; 1AAF52CE180E2EEF000584C8 /* b2Settings.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D61807AF9C005B8026 /* b2Settings.h */; }; 1AAF52CF180E2EEF000584C8 /* b2StackAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D71807AF9C005B8026 /* b2StackAllocator.cpp */; }; 1AAF52D0180E2EEF000584C8 /* b2StackAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168D81807AF9C005B8026 /* b2StackAllocator.h */; }; 1AAF52D1180E2EEF000584C8 /* b2Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168D91807AF9C005B8026 /* b2Timer.cpp */; }; 1AAF52D2180E2EEF000584C8 /* b2Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168DA1807AF9C005B8026 /* b2Timer.h */; }; 1AAF52D3180E2EF5000584C8 /* b2Body.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168DC1807AF9C005B8026 /* b2Body.cpp */; }; 1AAF52D4180E2EF5000584C8 /* b2Body.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168DD1807AF9C005B8026 /* b2Body.h */; }; 1AAF52D5180E2EF5000584C8 /* b2ContactManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168DE1807AF9C005B8026 /* b2ContactManager.cpp */; }; 1AAF52D6180E2EF5000584C8 /* b2ContactManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168DF1807AF9C005B8026 /* b2ContactManager.h */; }; 1AAF52D7180E2EF5000584C8 /* b2Fixture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168E01807AF9C005B8026 /* b2Fixture.cpp */; }; 1AAF52D8180E2EF5000584C8 /* b2Fixture.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E11807AF9C005B8026 /* b2Fixture.h */; }; 1AAF52D9180E2EF5000584C8 /* b2Island.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168E21807AF9C005B8026 /* b2Island.cpp */; }; 1AAF52DA180E2EF5000584C8 /* b2Island.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E31807AF9C005B8026 /* b2Island.h */; }; 1AAF52DB180E2EF5000584C8 /* b2TimeStep.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E41807AF9C005B8026 /* b2TimeStep.h */; }; 1AAF52DC180E2EF5000584C8 /* b2World.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168E51807AF9C005B8026 /* b2World.cpp */; }; 1AAF52DD180E2EF5000584C8 /* b2World.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E61807AF9C005B8026 /* b2World.h */; }; 1AAF52DE180E2EF5000584C8 /* b2WorldCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168E71807AF9C005B8026 /* b2WorldCallbacks.cpp */; }; 1AAF52DF180E2EF5000584C8 /* b2WorldCallbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E81807AF9C005B8026 /* b2WorldCallbacks.h */; }; 1AAF52E0180E2EF6000584C8 /* b2Body.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168DC1807AF9C005B8026 /* b2Body.cpp */; }; 1AAF52E1180E2EF6000584C8 /* b2Body.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168DD1807AF9C005B8026 /* b2Body.h */; }; 1AAF52E2180E2EF6000584C8 /* b2ContactManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168DE1807AF9C005B8026 /* b2ContactManager.cpp */; }; 1AAF52E3180E2EF6000584C8 /* b2ContactManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168DF1807AF9C005B8026 /* b2ContactManager.h */; }; 1AAF52E4180E2EF6000584C8 /* b2Fixture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168E01807AF9C005B8026 /* b2Fixture.cpp */; }; 1AAF52E5180E2EF6000584C8 /* b2Fixture.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E11807AF9C005B8026 /* b2Fixture.h */; }; 1AAF52E6180E2EF6000584C8 /* b2Island.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168E21807AF9C005B8026 /* b2Island.cpp */; }; 1AAF52E7180E2EF6000584C8 /* b2Island.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E31807AF9C005B8026 /* b2Island.h */; }; 1AAF52E8180E2EF6000584C8 /* b2TimeStep.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E41807AF9C005B8026 /* b2TimeStep.h */; }; 1AAF52E9180E2EF6000584C8 /* b2World.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168E51807AF9C005B8026 /* b2World.cpp */; }; 1AAF52EA180E2EF6000584C8 /* b2World.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E61807AF9C005B8026 /* b2World.h */; }; 1AAF52EB180E2EF6000584C8 /* b2WorldCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168E71807AF9C005B8026 /* b2WorldCallbacks.cpp */; }; 1AAF52EC180E2EF6000584C8 /* b2WorldCallbacks.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168E81807AF9C005B8026 /* b2WorldCallbacks.h */; }; 1AAF52ED180E2EFC000584C8 /* b2ChainAndCircleContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168EA1807AF9C005B8026 /* b2ChainAndCircleContact.cpp */; }; 1AAF52EE180E2EFC000584C8 /* b2ChainAndCircleContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168EB1807AF9C005B8026 /* b2ChainAndCircleContact.h */; }; 1AAF52EF180E2EFC000584C8 /* b2ChainAndPolygonContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168EC1807AF9C005B8026 /* b2ChainAndPolygonContact.cpp */; }; 1AAF52F0180E2EFC000584C8 /* b2ChainAndPolygonContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168ED1807AF9C005B8026 /* b2ChainAndPolygonContact.h */; }; 1AAF52F1180E2EFC000584C8 /* b2CircleContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168EE1807AF9C005B8026 /* b2CircleContact.cpp */; }; 1AAF52F2180E2EFC000584C8 /* b2CircleContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168EF1807AF9C005B8026 /* b2CircleContact.h */; }; 1AAF52F3180E2EFC000584C8 /* b2Contact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F01807AF9C005B8026 /* b2Contact.cpp */; }; 1AAF52F4180E2EFC000584C8 /* b2Contact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F11807AF9C005B8026 /* b2Contact.h */; }; 1AAF52F5180E2EFC000584C8 /* b2ContactSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F21807AF9C005B8026 /* b2ContactSolver.cpp */; }; 1AAF52F6180E2EFC000584C8 /* b2ContactSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F31807AF9C005B8026 /* b2ContactSolver.h */; }; 1AAF52F7180E2EFC000584C8 /* b2EdgeAndCircleContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F41807AF9C005B8026 /* b2EdgeAndCircleContact.cpp */; }; 1AAF52F8180E2EFC000584C8 /* b2EdgeAndCircleContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F51807AF9C005B8026 /* b2EdgeAndCircleContact.h */; }; 1AAF52F9180E2EFC000584C8 /* b2EdgeAndPolygonContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F61807AF9C005B8026 /* b2EdgeAndPolygonContact.cpp */; }; 1AAF52FA180E2EFC000584C8 /* b2EdgeAndPolygonContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F71807AF9C005B8026 /* b2EdgeAndPolygonContact.h */; }; 1AAF52FB180E2EFC000584C8 /* b2PolygonAndCircleContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F81807AF9C005B8026 /* b2PolygonAndCircleContact.cpp */; }; 1AAF52FC180E2EFC000584C8 /* b2PolygonAndCircleContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F91807AF9C005B8026 /* b2PolygonAndCircleContact.h */; }; 1AAF52FD180E2EFC000584C8 /* b2PolygonContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168FA1807AF9C005B8026 /* b2PolygonContact.cpp */; }; 1AAF52FE180E2EFC000584C8 /* b2PolygonContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168FB1807AF9C005B8026 /* b2PolygonContact.h */; }; 1AAF52FF180E2EFE000584C8 /* b2ChainAndCircleContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168EA1807AF9C005B8026 /* b2ChainAndCircleContact.cpp */; }; 1AAF5300180E2EFE000584C8 /* b2ChainAndCircleContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168EB1807AF9C005B8026 /* b2ChainAndCircleContact.h */; }; 1AAF5301180E2EFE000584C8 /* b2ChainAndPolygonContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168EC1807AF9C005B8026 /* b2ChainAndPolygonContact.cpp */; }; 1AAF5302180E2EFE000584C8 /* b2ChainAndPolygonContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168ED1807AF9C005B8026 /* b2ChainAndPolygonContact.h */; }; 1AAF5303180E2EFE000584C8 /* b2CircleContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168EE1807AF9C005B8026 /* b2CircleContact.cpp */; }; 1AAF5304180E2EFE000584C8 /* b2CircleContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168EF1807AF9C005B8026 /* b2CircleContact.h */; }; 1AAF5305180E2EFE000584C8 /* b2Contact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F01807AF9C005B8026 /* b2Contact.cpp */; }; 1AAF5306180E2EFE000584C8 /* b2Contact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F11807AF9C005B8026 /* b2Contact.h */; }; 1AAF5307180E2EFE000584C8 /* b2ContactSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F21807AF9C005B8026 /* b2ContactSolver.cpp */; }; 1AAF5308180E2EFE000584C8 /* b2ContactSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F31807AF9C005B8026 /* b2ContactSolver.h */; }; 1AAF5309180E2EFE000584C8 /* b2EdgeAndCircleContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F41807AF9C005B8026 /* b2EdgeAndCircleContact.cpp */; }; 1AAF530A180E2EFE000584C8 /* b2EdgeAndCircleContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F51807AF9C005B8026 /* b2EdgeAndCircleContact.h */; }; 1AAF530B180E2EFE000584C8 /* b2EdgeAndPolygonContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F61807AF9C005B8026 /* b2EdgeAndPolygonContact.cpp */; }; 1AAF530C180E2EFE000584C8 /* b2EdgeAndPolygonContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F71807AF9C005B8026 /* b2EdgeAndPolygonContact.h */; }; 1AAF530D180E2EFE000584C8 /* b2PolygonAndCircleContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168F81807AF9C005B8026 /* b2PolygonAndCircleContact.cpp */; }; 1AAF530E180E2EFE000584C8 /* b2PolygonAndCircleContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168F91807AF9C005B8026 /* b2PolygonAndCircleContact.h */; }; 1AAF530F180E2EFE000584C8 /* b2PolygonContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168FA1807AF9C005B8026 /* b2PolygonContact.cpp */; }; 1AAF5310180E2EFE000584C8 /* b2PolygonContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168FB1807AF9C005B8026 /* b2PolygonContact.h */; }; 1AAF5311180E2F04000584C8 /* b2DistanceJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168FD1807AF9C005B8026 /* b2DistanceJoint.cpp */; }; 1AAF5312180E2F04000584C8 /* b2DistanceJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168FE1807AF9C005B8026 /* b2DistanceJoint.h */; }; 1AAF5313180E2F04000584C8 /* b2FrictionJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168FF1807AF9C005B8026 /* b2FrictionJoint.cpp */; }; 1AAF5314180E2F04000584C8 /* b2FrictionJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169001807AF9C005B8026 /* b2FrictionJoint.h */; }; 1AAF5315180E2F04000584C8 /* b2GearJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169011807AF9C005B8026 /* b2GearJoint.cpp */; }; 1AAF5316180E2F04000584C8 /* b2GearJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169021807AF9C005B8026 /* b2GearJoint.h */; }; 1AAF5317180E2F04000584C8 /* b2Joint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169031807AF9C005B8026 /* b2Joint.cpp */; }; 1AAF5318180E2F04000584C8 /* b2Joint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169041807AF9C005B8026 /* b2Joint.h */; }; 1AAF5319180E2F04000584C8 /* b2MouseJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169051807AF9C005B8026 /* b2MouseJoint.cpp */; }; 1AAF531A180E2F04000584C8 /* b2MouseJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169061807AF9C005B8026 /* b2MouseJoint.h */; }; 1AAF531B180E2F04000584C8 /* b2PrismaticJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169071807AF9C005B8026 /* b2PrismaticJoint.cpp */; }; 1AAF531C180E2F04000584C8 /* b2PrismaticJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169081807AF9C005B8026 /* b2PrismaticJoint.h */; }; 1AAF531D180E2F04000584C8 /* b2PulleyJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169091807AF9C005B8026 /* b2PulleyJoint.cpp */; }; 1AAF531E180E2F04000584C8 /* b2PulleyJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1690A1807AF9C005B8026 /* b2PulleyJoint.h */; }; 1AAF531F180E2F04000584C8 /* b2RevoluteJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1690B1807AF9C005B8026 /* b2RevoluteJoint.cpp */; }; 1AAF5320180E2F04000584C8 /* b2RevoluteJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1690C1807AF9C005B8026 /* b2RevoluteJoint.h */; }; 1AAF5321180E2F04000584C8 /* b2RopeJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1690D1807AF9C005B8026 /* b2RopeJoint.cpp */; }; 1AAF5322180E2F04000584C8 /* b2RopeJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1690E1807AF9C005B8026 /* b2RopeJoint.h */; }; 1AAF5323180E2F04000584C8 /* b2WeldJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1690F1807AF9C005B8026 /* b2WeldJoint.cpp */; }; 1AAF5324180E2F04000584C8 /* b2WeldJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169101807AF9C005B8026 /* b2WeldJoint.h */; }; 1AAF5325180E2F04000584C8 /* b2WheelJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169111807AF9C005B8026 /* b2WheelJoint.cpp */; }; 1AAF5326180E2F04000584C8 /* b2WheelJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169121807AF9C005B8026 /* b2WheelJoint.h */; }; 1AAF5327180E2F04000584C8 /* b2DistanceJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168FD1807AF9C005B8026 /* b2DistanceJoint.cpp */; }; 1AAF5328180E2F04000584C8 /* b2DistanceJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168FE1807AF9C005B8026 /* b2DistanceJoint.h */; }; 1AAF5329180E2F04000584C8 /* b2FrictionJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168FF1807AF9C005B8026 /* b2FrictionJoint.cpp */; }; 1AAF532A180E2F04000584C8 /* b2FrictionJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169001807AF9C005B8026 /* b2FrictionJoint.h */; }; 1AAF532B180E2F04000584C8 /* b2GearJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169011807AF9C005B8026 /* b2GearJoint.cpp */; }; 1AAF532C180E2F04000584C8 /* b2GearJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169021807AF9C005B8026 /* b2GearJoint.h */; }; 1AAF532D180E2F04000584C8 /* b2Joint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169031807AF9C005B8026 /* b2Joint.cpp */; }; 1AAF532E180E2F04000584C8 /* b2Joint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169041807AF9C005B8026 /* b2Joint.h */; }; 1AAF532F180E2F04000584C8 /* b2MouseJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169051807AF9C005B8026 /* b2MouseJoint.cpp */; }; 1AAF5330180E2F04000584C8 /* b2MouseJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169061807AF9C005B8026 /* b2MouseJoint.h */; }; 1AAF5331180E2F04000584C8 /* b2PrismaticJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169071807AF9C005B8026 /* b2PrismaticJoint.cpp */; }; 1AAF5332180E2F04000584C8 /* b2PrismaticJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169081807AF9C005B8026 /* b2PrismaticJoint.h */; }; 1AAF5333180E2F04000584C8 /* b2PulleyJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169091807AF9C005B8026 /* b2PulleyJoint.cpp */; }; 1AAF5334180E2F04000584C8 /* b2PulleyJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1690A1807AF9C005B8026 /* b2PulleyJoint.h */; }; 1AAF5335180E2F04000584C8 /* b2RevoluteJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1690B1807AF9C005B8026 /* b2RevoluteJoint.cpp */; }; 1AAF5336180E2F04000584C8 /* b2RevoluteJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1690C1807AF9C005B8026 /* b2RevoluteJoint.h */; }; 1AAF5337180E2F04000584C8 /* b2RopeJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1690D1807AF9C005B8026 /* b2RopeJoint.cpp */; }; 1AAF5338180E2F04000584C8 /* b2RopeJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1690E1807AF9C005B8026 /* b2RopeJoint.h */; }; 1AAF5339180E2F04000584C8 /* b2WeldJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1690F1807AF9C005B8026 /* b2WeldJoint.cpp */; }; 1AAF533A180E2F04000584C8 /* b2WeldJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169101807AF9C005B8026 /* b2WeldJoint.h */; }; 1AAF533B180E2F04000584C8 /* b2WheelJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169111807AF9C005B8026 /* b2WheelJoint.cpp */; }; 1AAF533C180E2F04000584C8 /* b2WheelJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169121807AF9C005B8026 /* b2WheelJoint.h */; }; 1AAF533D180E2F10000584C8 /* b2Rope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169321807AF9C005B8026 /* b2Rope.cpp */; }; 1AAF533E180E2F10000584C8 /* b2Rope.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169331807AF9C005B8026 /* b2Rope.h */; }; 1AAF533F180E2F11000584C8 /* b2Rope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A169321807AF9C005B8026 /* b2Rope.cpp */; }; 1AAF5340180E2F11000584C8 /* b2Rope.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169331807AF9C005B8026 /* b2Rope.h */; }; 1AAF5353180E3060000584C8 /* AssetsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5351180E3060000584C8 /* AssetsManager.cpp */; }; 1AAF5354180E3060000584C8 /* AssetsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5351180E3060000584C8 /* AssetsManager.cpp */; }; 1AAF5355180E3060000584C8 /* AssetsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5352180E3060000584C8 /* AssetsManager.h */; }; 1AAF5356180E3060000584C8 /* AssetsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5352180E3060000584C8 /* AssetsManager.h */; }; 1AAF536A180E3374000584C8 /* HttpClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5362180E3374000584C8 /* HttpClient.cpp */; }; 1AAF536B180E3374000584C8 /* HttpClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5362180E3374000584C8 /* HttpClient.cpp */; }; 1AAF536C180E3374000584C8 /* HttpClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5363180E3374000584C8 /* HttpClient.h */; }; 1AAF536D180E3374000584C8 /* HttpClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5363180E3374000584C8 /* HttpClient.h */; }; 1AAF536E180E3374000584C8 /* HttpRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5364180E3374000584C8 /* HttpRequest.h */; }; 1AAF536F180E3374000584C8 /* HttpRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5364180E3374000584C8 /* HttpRequest.h */; }; 1AAF5370180E3374000584C8 /* HttpResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5365180E3374000584C8 /* HttpResponse.h */; }; 1AAF5371180E3374000584C8 /* HttpResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5365180E3374000584C8 /* HttpResponse.h */; }; 1AAF5372180E3374000584C8 /* SocketIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5366180E3374000584C8 /* SocketIO.cpp */; }; 1AAF5373180E3374000584C8 /* SocketIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5366180E3374000584C8 /* SocketIO.cpp */; }; 1AAF5374180E3374000584C8 /* SocketIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5367180E3374000584C8 /* SocketIO.h */; }; 1AAF5375180E3374000584C8 /* SocketIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5367180E3374000584C8 /* SocketIO.h */; }; 1AAF5376180E3374000584C8 /* WebSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5368180E3374000584C8 /* WebSocket.cpp */; }; 1AAF5377180E3374000584C8 /* WebSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5368180E3374000584C8 /* WebSocket.cpp */; }; 1AAF5378180E3374000584C8 /* WebSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5369180E3374000584C8 /* WebSocket.h */; }; 1AAF5379180E3374000584C8 /* WebSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF5369180E3374000584C8 /* WebSocket.h */; }; 1AAF5385180E35A3000584C8 /* libwebsockets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AAF5384180E35A3000584C8 /* libwebsockets.a */; }; 1AAF5388180E35AC000584C8 /* libwebsockets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AAF5387180E35AC000584C8 /* libwebsockets.a */; }; 1AAF541D180E3B6A000584C8 /* libcurl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AAF541C180E3B6A000584C8 /* libcurl.a */; }; 1AAF584F180E40B9000584C8 /* LocalStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF584C180E40B9000584C8 /* LocalStorage.cpp */; }; 1AAF5850180E40B9000584C8 /* LocalStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF584C180E40B9000584C8 /* LocalStorage.cpp */; }; 1AAF5851180E40B9000584C8 /* LocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF584D180E40B9000584C8 /* LocalStorage.h */; }; 1AAF5852180E40B9000584C8 /* LocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAF584D180E40B9000584C8 /* LocalStorage.h */; }; 1AAF5853180E40B9000584C8 /* LocalStorageAndroid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF584E180E40B9000584C8 /* LocalStorageAndroid.cpp */; }; 1AAF5854180E40B9000584C8 /* LocalStorageAndroid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF584E180E40B9000584C8 /* LocalStorageAndroid.cpp */; }; 1ABA68AE1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ABA68AC1888D700007D1BB4 /* CCFontCharMap.cpp */; }; 1ABA68AF1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ABA68AC1888D700007D1BB4 /* CCFontCharMap.cpp */; }; 1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABA68AD1888D700007D1BB4 /* CCFontCharMap.h */; }; 1ABA68B11888D700007D1BB4 /* CCFontCharMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABA68AD1888D700007D1BB4 /* CCFontCharMap.h */; }; 1AD71DA9180E26E600808F54 /* CCBAnimationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71CFA180E26E600808F54 /* CCBAnimationManager.cpp */; }; 1AD71DAA180E26E600808F54 /* CCBAnimationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71CFA180E26E600808F54 /* CCBAnimationManager.cpp */; }; 1AD71DAB180E26E600808F54 /* CCBAnimationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71CFB180E26E600808F54 /* CCBAnimationManager.h */; }; 1AD71DAC180E26E600808F54 /* CCBAnimationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71CFB180E26E600808F54 /* CCBAnimationManager.h */; }; 1AD71DAD180E26E600808F54 /* CCBFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71CFC180E26E600808F54 /* CCBFileLoader.cpp */; }; 1AD71DAE180E26E600808F54 /* CCBFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71CFC180E26E600808F54 /* CCBFileLoader.cpp */; }; 1AD71DAF180E26E600808F54 /* CCBFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71CFD180E26E600808F54 /* CCBFileLoader.h */; }; 1AD71DB0180E26E600808F54 /* CCBFileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71CFD180E26E600808F54 /* CCBFileLoader.h */; }; 1AD71DB1180E26E600808F54 /* CCBKeyframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71CFE180E26E600808F54 /* CCBKeyframe.cpp */; }; 1AD71DB2180E26E600808F54 /* CCBKeyframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71CFE180E26E600808F54 /* CCBKeyframe.cpp */; }; 1AD71DB3180E26E600808F54 /* CCBKeyframe.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71CFF180E26E600808F54 /* CCBKeyframe.h */; }; 1AD71DB4180E26E600808F54 /* CCBKeyframe.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71CFF180E26E600808F54 /* CCBKeyframe.h */; }; 1AD71DB5180E26E600808F54 /* CCBMemberVariableAssigner.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D00180E26E600808F54 /* CCBMemberVariableAssigner.h */; }; 1AD71DB6180E26E600808F54 /* CCBMemberVariableAssigner.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D00180E26E600808F54 /* CCBMemberVariableAssigner.h */; }; 1AD71DB7180E26E600808F54 /* CCBReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D01180E26E600808F54 /* CCBReader.cpp */; }; 1AD71DB8180E26E600808F54 /* CCBReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D01180E26E600808F54 /* CCBReader.cpp */; }; 1AD71DB9180E26E600808F54 /* CCBReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D02180E26E600808F54 /* CCBReader.h */; }; 1AD71DBA180E26E600808F54 /* CCBReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D02180E26E600808F54 /* CCBReader.h */; }; 1AD71DBB180E26E600808F54 /* CCBSelectorResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D03180E26E600808F54 /* CCBSelectorResolver.h */; }; 1AD71DBC180E26E600808F54 /* CCBSelectorResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D03180E26E600808F54 /* CCBSelectorResolver.h */; }; 1AD71DBD180E26E600808F54 /* CCBSequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D04180E26E600808F54 /* CCBSequence.cpp */; }; 1AD71DBE180E26E600808F54 /* CCBSequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D04180E26E600808F54 /* CCBSequence.cpp */; }; 1AD71DBF180E26E600808F54 /* CCBSequence.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D05180E26E600808F54 /* CCBSequence.h */; }; 1AD71DC0180E26E600808F54 /* CCBSequence.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D05180E26E600808F54 /* CCBSequence.h */; }; 1AD71DC1180E26E600808F54 /* CCBSequenceProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D06180E26E600808F54 /* CCBSequenceProperty.cpp */; }; 1AD71DC2180E26E600808F54 /* CCBSequenceProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D06180E26E600808F54 /* CCBSequenceProperty.cpp */; }; 1AD71DC3180E26E600808F54 /* CCBSequenceProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D07180E26E600808F54 /* CCBSequenceProperty.h */; }; 1AD71DC4180E26E600808F54 /* CCBSequenceProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D07180E26E600808F54 /* CCBSequenceProperty.h */; }; 1AD71DC9180E26E600808F54 /* CCControlButtonLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D0A180E26E600808F54 /* CCControlButtonLoader.cpp */; }; 1AD71DCA180E26E600808F54 /* CCControlButtonLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D0A180E26E600808F54 /* CCControlButtonLoader.cpp */; }; 1AD71DCB180E26E600808F54 /* CCControlButtonLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D0B180E26E600808F54 /* CCControlButtonLoader.h */; }; 1AD71DCC180E26E600808F54 /* CCControlButtonLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D0B180E26E600808F54 /* CCControlButtonLoader.h */; }; 1AD71DCD180E26E600808F54 /* CCControlLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D0C180E26E600808F54 /* CCControlLoader.cpp */; }; 1AD71DCE180E26E600808F54 /* CCControlLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D0C180E26E600808F54 /* CCControlLoader.cpp */; }; 1AD71DCF180E26E600808F54 /* CCControlLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D0D180E26E600808F54 /* CCControlLoader.h */; }; 1AD71DD0180E26E600808F54 /* CCControlLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D0D180E26E600808F54 /* CCControlLoader.h */; }; 1AD71DD1180E26E600808F54 /* CCLabelBMFontLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D0E180E26E600808F54 /* CCLabelBMFontLoader.cpp */; }; 1AD71DD2180E26E600808F54 /* CCLabelBMFontLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D0E180E26E600808F54 /* CCLabelBMFontLoader.cpp */; }; 1AD71DD3180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D0F180E26E600808F54 /* CCLabelBMFontLoader.h */; }; 1AD71DD4180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D0F180E26E600808F54 /* CCLabelBMFontLoader.h */; }; 1AD71DD5180E26E600808F54 /* CCLabelTTFLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D10180E26E600808F54 /* CCLabelTTFLoader.cpp */; }; 1AD71DD6180E26E600808F54 /* CCLabelTTFLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D10180E26E600808F54 /* CCLabelTTFLoader.cpp */; }; 1AD71DD7180E26E600808F54 /* CCLabelTTFLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D11180E26E600808F54 /* CCLabelTTFLoader.h */; }; 1AD71DD8180E26E600808F54 /* CCLabelTTFLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D11180E26E600808F54 /* CCLabelTTFLoader.h */; }; 1AD71DD9180E26E600808F54 /* CCLayerColorLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D12180E26E600808F54 /* CCLayerColorLoader.cpp */; }; 1AD71DDA180E26E600808F54 /* CCLayerColorLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D12180E26E600808F54 /* CCLayerColorLoader.cpp */; }; 1AD71DDB180E26E600808F54 /* CCLayerColorLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D13180E26E600808F54 /* CCLayerColorLoader.h */; }; 1AD71DDC180E26E600808F54 /* CCLayerColorLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D13180E26E600808F54 /* CCLayerColorLoader.h */; }; 1AD71DDD180E26E600808F54 /* CCLayerGradientLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D14180E26E600808F54 /* CCLayerGradientLoader.cpp */; }; 1AD71DDE180E26E600808F54 /* CCLayerGradientLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D14180E26E600808F54 /* CCLayerGradientLoader.cpp */; }; 1AD71DDF180E26E600808F54 /* CCLayerGradientLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D15180E26E600808F54 /* CCLayerGradientLoader.h */; }; 1AD71DE0180E26E600808F54 /* CCLayerGradientLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D15180E26E600808F54 /* CCLayerGradientLoader.h */; }; 1AD71DE1180E26E600808F54 /* CCLayerLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D16180E26E600808F54 /* CCLayerLoader.cpp */; }; 1AD71DE2180E26E600808F54 /* CCLayerLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D16180E26E600808F54 /* CCLayerLoader.cpp */; }; 1AD71DE3180E26E600808F54 /* CCLayerLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D17180E26E600808F54 /* CCLayerLoader.h */; }; 1AD71DE4180E26E600808F54 /* CCLayerLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D17180E26E600808F54 /* CCLayerLoader.h */; }; 1AD71DE5180E26E600808F54 /* CCMenuItemImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D18180E26E600808F54 /* CCMenuItemImageLoader.cpp */; }; 1AD71DE6180E26E600808F54 /* CCMenuItemImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D18180E26E600808F54 /* CCMenuItemImageLoader.cpp */; }; 1AD71DE7180E26E600808F54 /* CCMenuItemImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D19180E26E600808F54 /* CCMenuItemImageLoader.h */; }; 1AD71DE8180E26E600808F54 /* CCMenuItemImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D19180E26E600808F54 /* CCMenuItemImageLoader.h */; }; 1AD71DE9180E26E600808F54 /* CCMenuItemLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D1A180E26E600808F54 /* CCMenuItemLoader.cpp */; }; 1AD71DEA180E26E600808F54 /* CCMenuItemLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D1A180E26E600808F54 /* CCMenuItemLoader.cpp */; }; 1AD71DEB180E26E600808F54 /* CCMenuItemLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D1B180E26E600808F54 /* CCMenuItemLoader.h */; }; 1AD71DEC180E26E600808F54 /* CCMenuItemLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D1B180E26E600808F54 /* CCMenuItemLoader.h */; }; 1AD71DED180E26E600808F54 /* CCMenuLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D1C180E26E600808F54 /* CCMenuLoader.h */; }; 1AD71DEE180E26E600808F54 /* CCMenuLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D1C180E26E600808F54 /* CCMenuLoader.h */; }; 1AD71DEF180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D1D180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp */; }; 1AD71DF0180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D1D180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp */; }; 1AD71DF1180E26E600808F54 /* CCNode+CCBRelativePositioning.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D1E180E26E600808F54 /* CCNode+CCBRelativePositioning.h */; }; 1AD71DF2180E26E600808F54 /* CCNode+CCBRelativePositioning.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D1E180E26E600808F54 /* CCNode+CCBRelativePositioning.h */; }; 1AD71DF3180E26E600808F54 /* CCNodeLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D1F180E26E600808F54 /* CCNodeLoader.cpp */; }; 1AD71DF4180E26E600808F54 /* CCNodeLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D1F180E26E600808F54 /* CCNodeLoader.cpp */; }; 1AD71DF5180E26E600808F54 /* CCNodeLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D20180E26E600808F54 /* CCNodeLoader.h */; }; 1AD71DF6180E26E600808F54 /* CCNodeLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D20180E26E600808F54 /* CCNodeLoader.h */; }; 1AD71DF7180E26E600808F54 /* CCNodeLoaderLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D21180E26E600808F54 /* CCNodeLoaderLibrary.cpp */; }; 1AD71DF8180E26E600808F54 /* CCNodeLoaderLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D21180E26E600808F54 /* CCNodeLoaderLibrary.cpp */; }; 1AD71DF9180E26E600808F54 /* CCNodeLoaderLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D22180E26E600808F54 /* CCNodeLoaderLibrary.h */; }; 1AD71DFA180E26E600808F54 /* CCNodeLoaderLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D22180E26E600808F54 /* CCNodeLoaderLibrary.h */; }; 1AD71DFB180E26E600808F54 /* CCNodeLoaderListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D23180E26E600808F54 /* CCNodeLoaderListener.h */; }; 1AD71DFC180E26E600808F54 /* CCNodeLoaderListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D23180E26E600808F54 /* CCNodeLoaderListener.h */; }; 1AD71DFD180E26E600808F54 /* CCParticleSystemQuadLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D24180E26E600808F54 /* CCParticleSystemQuadLoader.cpp */; }; 1AD71DFE180E26E600808F54 /* CCParticleSystemQuadLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D24180E26E600808F54 /* CCParticleSystemQuadLoader.cpp */; }; 1AD71DFF180E26E600808F54 /* CCParticleSystemQuadLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D25180E26E600808F54 /* CCParticleSystemQuadLoader.h */; }; 1AD71E00180E26E600808F54 /* CCParticleSystemQuadLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D25180E26E600808F54 /* CCParticleSystemQuadLoader.h */; }; 1AD71E01180E26E600808F54 /* CCScale9SpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D26180E26E600808F54 /* CCScale9SpriteLoader.cpp */; }; 1AD71E02180E26E600808F54 /* CCScale9SpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D26180E26E600808F54 /* CCScale9SpriteLoader.cpp */; }; 1AD71E03180E26E600808F54 /* CCScale9SpriteLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D27180E26E600808F54 /* CCScale9SpriteLoader.h */; }; 1AD71E04180E26E600808F54 /* CCScale9SpriteLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D27180E26E600808F54 /* CCScale9SpriteLoader.h */; }; 1AD71E05180E26E600808F54 /* CCScrollViewLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D28180E26E600808F54 /* CCScrollViewLoader.cpp */; }; 1AD71E06180E26E600808F54 /* CCScrollViewLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D28180E26E600808F54 /* CCScrollViewLoader.cpp */; }; 1AD71E07180E26E600808F54 /* CCScrollViewLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D29180E26E600808F54 /* CCScrollViewLoader.h */; }; 1AD71E08180E26E600808F54 /* CCScrollViewLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D29180E26E600808F54 /* CCScrollViewLoader.h */; }; 1AD71E09180E26E600808F54 /* CCSpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D2A180E26E600808F54 /* CCSpriteLoader.cpp */; }; 1AD71E0A180E26E600808F54 /* CCSpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D2A180E26E600808F54 /* CCSpriteLoader.cpp */; }; 1AD71E0B180E26E600808F54 /* CCSpriteLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D2B180E26E600808F54 /* CCSpriteLoader.h */; }; 1AD71E0C180E26E600808F54 /* CCSpriteLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D2B180E26E600808F54 /* CCSpriteLoader.h */; }; 1AD71E0D180E26E600808F54 /* CocosBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D2C180E26E600808F54 /* CocosBuilder.h */; }; 1AD71E0E180E26E600808F54 /* CocosBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D2C180E26E600808F54 /* CocosBuilder.h */; }; 1AD71E95180E26E600808F54 /* Animation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D7E180E26E600808F54 /* Animation.cpp */; }; 1AD71E96180E26E600808F54 /* Animation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D7E180E26E600808F54 /* Animation.cpp */; }; 1AD71E97180E26E600808F54 /* Animation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D7F180E26E600808F54 /* Animation.h */; }; 1AD71E98180E26E600808F54 /* Animation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D7F180E26E600808F54 /* Animation.h */; }; 1AD71E99180E26E600808F54 /* AnimationState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D80180E26E600808F54 /* AnimationState.cpp */; }; 1AD71E9A180E26E600808F54 /* AnimationState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D80180E26E600808F54 /* AnimationState.cpp */; }; 1AD71E9B180E26E600808F54 /* AnimationState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D81180E26E600808F54 /* AnimationState.h */; }; 1AD71E9C180E26E600808F54 /* AnimationState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D81180E26E600808F54 /* AnimationState.h */; }; 1AD71E9D180E26E600808F54 /* AnimationStateData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D82180E26E600808F54 /* AnimationStateData.cpp */; }; 1AD71E9E180E26E600808F54 /* AnimationStateData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D82180E26E600808F54 /* AnimationStateData.cpp */; }; 1AD71E9F180E26E600808F54 /* AnimationStateData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D83180E26E600808F54 /* AnimationStateData.h */; }; 1AD71EA0180E26E600808F54 /* AnimationStateData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D83180E26E600808F54 /* AnimationStateData.h */; }; 1AD71EA1180E26E600808F54 /* Atlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D84180E26E600808F54 /* Atlas.cpp */; }; 1AD71EA2180E26E600808F54 /* Atlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D84180E26E600808F54 /* Atlas.cpp */; }; 1AD71EA3180E26E600808F54 /* Atlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D85180E26E600808F54 /* Atlas.h */; }; 1AD71EA4180E26E600808F54 /* Atlas.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D85180E26E600808F54 /* Atlas.h */; }; 1AD71EA5180E26E600808F54 /* AtlasAttachmentLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D86180E26E600808F54 /* AtlasAttachmentLoader.cpp */; }; 1AD71EA6180E26E600808F54 /* AtlasAttachmentLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D86180E26E600808F54 /* AtlasAttachmentLoader.cpp */; }; 1AD71EA7180E26E600808F54 /* AtlasAttachmentLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D87180E26E600808F54 /* AtlasAttachmentLoader.h */; }; 1AD71EA8180E26E600808F54 /* AtlasAttachmentLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D87180E26E600808F54 /* AtlasAttachmentLoader.h */; }; 1AD71EA9180E26E600808F54 /* Attachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D88180E26E600808F54 /* Attachment.cpp */; }; 1AD71EAA180E26E600808F54 /* Attachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D88180E26E600808F54 /* Attachment.cpp */; }; 1AD71EAB180E26E600808F54 /* Attachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D89180E26E600808F54 /* Attachment.h */; }; 1AD71EAC180E26E600808F54 /* Attachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D89180E26E600808F54 /* Attachment.h */; }; 1AD71EAD180E26E600808F54 /* AttachmentLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D8A180E26E600808F54 /* AttachmentLoader.cpp */; }; 1AD71EAE180E26E600808F54 /* AttachmentLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D8A180E26E600808F54 /* AttachmentLoader.cpp */; }; 1AD71EAF180E26E600808F54 /* AttachmentLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D8B180E26E600808F54 /* AttachmentLoader.h */; }; 1AD71EB0180E26E600808F54 /* AttachmentLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D8B180E26E600808F54 /* AttachmentLoader.h */; }; 1AD71EB1180E26E600808F54 /* Bone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D8C180E26E600808F54 /* Bone.cpp */; }; 1AD71EB2180E26E600808F54 /* Bone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D8C180E26E600808F54 /* Bone.cpp */; }; 1AD71EB3180E26E600808F54 /* Bone.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D8D180E26E600808F54 /* Bone.h */; }; 1AD71EB4180E26E600808F54 /* Bone.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D8D180E26E600808F54 /* Bone.h */; }; 1AD71EB5180E26E600808F54 /* BoneData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D8E180E26E600808F54 /* BoneData.cpp */; }; 1AD71EB6180E26E600808F54 /* BoneData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D8E180E26E600808F54 /* BoneData.cpp */; }; 1AD71EB7180E26E600808F54 /* BoneData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D8F180E26E600808F54 /* BoneData.h */; }; 1AD71EB8180E26E600808F54 /* BoneData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D8F180E26E600808F54 /* BoneData.h */; }; 1AD71EB9180E26E600808F54 /* CCSkeleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D90180E26E600808F54 /* CCSkeleton.cpp */; }; 1AD71EBA180E26E600808F54 /* CCSkeleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D90180E26E600808F54 /* CCSkeleton.cpp */; }; 1AD71EBB180E26E600808F54 /* CCSkeleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D91180E26E600808F54 /* CCSkeleton.h */; }; 1AD71EBC180E26E600808F54 /* CCSkeleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D91180E26E600808F54 /* CCSkeleton.h */; }; 1AD71EBD180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D92180E26E600808F54 /* CCSkeletonAnimation.cpp */; }; 1AD71EBE180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D92180E26E600808F54 /* CCSkeletonAnimation.cpp */; }; 1AD71EBF180E26E600808F54 /* CCSkeletonAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D93180E26E600808F54 /* CCSkeletonAnimation.h */; }; 1AD71EC0180E26E600808F54 /* CCSkeletonAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D93180E26E600808F54 /* CCSkeletonAnimation.h */; }; 1AD71EC1180E26E600808F54 /* extension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D94180E26E600808F54 /* extension.cpp */; }; 1AD71EC2180E26E600808F54 /* extension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D94180E26E600808F54 /* extension.cpp */; }; 1AD71EC3180E26E600808F54 /* extension.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D95180E26E600808F54 /* extension.h */; }; 1AD71EC4180E26E600808F54 /* extension.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D95180E26E600808F54 /* extension.h */; }; 1AD71EC5180E26E600808F54 /* Json.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D96180E26E600808F54 /* Json.cpp */; }; 1AD71EC6180E26E600808F54 /* Json.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D96180E26E600808F54 /* Json.cpp */; }; 1AD71EC7180E26E600808F54 /* Json.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D97180E26E600808F54 /* Json.h */; }; 1AD71EC8180E26E600808F54 /* Json.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D97180E26E600808F54 /* Json.h */; }; 1AD71EC9180E26E600808F54 /* RegionAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D98180E26E600808F54 /* RegionAttachment.cpp */; }; 1AD71ECA180E26E600808F54 /* RegionAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D98180E26E600808F54 /* RegionAttachment.cpp */; }; 1AD71ECB180E26E600808F54 /* RegionAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D99180E26E600808F54 /* RegionAttachment.h */; }; 1AD71ECC180E26E600808F54 /* RegionAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D99180E26E600808F54 /* RegionAttachment.h */; }; 1AD71ECD180E26E600808F54 /* Skeleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D9A180E26E600808F54 /* Skeleton.cpp */; }; 1AD71ECE180E26E600808F54 /* Skeleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D9A180E26E600808F54 /* Skeleton.cpp */; }; 1AD71ECF180E26E600808F54 /* Skeleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D9B180E26E600808F54 /* Skeleton.h */; }; 1AD71ED0180E26E600808F54 /* Skeleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D9B180E26E600808F54 /* Skeleton.h */; }; 1AD71ED1180E26E600808F54 /* SkeletonData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D9C180E26E600808F54 /* SkeletonData.cpp */; }; 1AD71ED2180E26E600808F54 /* SkeletonData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D9C180E26E600808F54 /* SkeletonData.cpp */; }; 1AD71ED3180E26E600808F54 /* SkeletonData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D9D180E26E600808F54 /* SkeletonData.h */; }; 1AD71ED4180E26E600808F54 /* SkeletonData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D9D180E26E600808F54 /* SkeletonData.h */; }; 1AD71ED5180E26E600808F54 /* SkeletonJson.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D9E180E26E600808F54 /* SkeletonJson.cpp */; }; 1AD71ED6180E26E600808F54 /* SkeletonJson.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71D9E180E26E600808F54 /* SkeletonJson.cpp */; }; 1AD71ED7180E26E600808F54 /* SkeletonJson.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D9F180E26E600808F54 /* SkeletonJson.h */; }; 1AD71ED8180E26E600808F54 /* SkeletonJson.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71D9F180E26E600808F54 /* SkeletonJson.h */; }; 1AD71ED9180E26E600808F54 /* Skin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71DA0180E26E600808F54 /* Skin.cpp */; }; 1AD71EDA180E26E600808F54 /* Skin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71DA0180E26E600808F54 /* Skin.cpp */; }; 1AD71EDB180E26E600808F54 /* Skin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA1180E26E600808F54 /* Skin.h */; }; 1AD71EDC180E26E600808F54 /* Skin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA1180E26E600808F54 /* Skin.h */; }; 1AD71EDD180E26E600808F54 /* Slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71DA2180E26E600808F54 /* Slot.cpp */; }; 1AD71EDE180E26E600808F54 /* Slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71DA2180E26E600808F54 /* Slot.cpp */; }; 1AD71EDF180E26E600808F54 /* Slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA3180E26E600808F54 /* Slot.h */; }; 1AD71EE0180E26E600808F54 /* Slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA3180E26E600808F54 /* Slot.h */; }; 1AD71EE1180E26E600808F54 /* SlotData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71DA4180E26E600808F54 /* SlotData.cpp */; }; 1AD71EE2180E26E600808F54 /* SlotData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71DA4180E26E600808F54 /* SlotData.cpp */; }; 1AD71EE3180E26E600808F54 /* SlotData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA5180E26E600808F54 /* SlotData.h */; }; 1AD71EE4180E26E600808F54 /* SlotData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA5180E26E600808F54 /* SlotData.h */; }; 1AD71EE5180E26E600808F54 /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71DA6180E26E600808F54 /* spine-cocos2dx.cpp */; }; 1AD71EE6180E26E600808F54 /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71DA6180E26E600808F54 /* spine-cocos2dx.cpp */; }; 1AD71EE7180E26E600808F54 /* spine-cocos2dx.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA7180E26E600808F54 /* spine-cocos2dx.h */; }; 1AD71EE8180E26E600808F54 /* spine-cocos2dx.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA7180E26E600808F54 /* spine-cocos2dx.h */; }; 1AD71EE9180E26E600808F54 /* spine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA8180E26E600808F54 /* spine.h */; }; 1AD71EEA180E26E600808F54 /* spine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71DA8180E26E600808F54 /* spine.h */; }; 1AD71EF0180E27CF00808F54 /* CCPhysicsDebugNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71EEC180E27CF00808F54 /* CCPhysicsDebugNode.cpp */; }; 1AD71EF1180E27CF00808F54 /* CCPhysicsDebugNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71EEC180E27CF00808F54 /* CCPhysicsDebugNode.cpp */; }; 1AD71EF2180E27CF00808F54 /* CCPhysicsDebugNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EED180E27CF00808F54 /* CCPhysicsDebugNode.h */; }; 1AD71EF3180E27CF00808F54 /* CCPhysicsDebugNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EED180E27CF00808F54 /* CCPhysicsDebugNode.h */; }; 1AD71EF4180E27CF00808F54 /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71EEE180E27CF00808F54 /* CCPhysicsSprite.cpp */; }; 1AD71EF5180E27CF00808F54 /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71EEE180E27CF00808F54 /* CCPhysicsSprite.cpp */; }; 1AD71EF6180E27CF00808F54 /* CCPhysicsSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */; }; 1AD71EF7180E27CF00808F54 /* CCPhysicsSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */; }; 1AE3C844184F14F700CF29B5 /* CCValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE3C842184F14F700CF29B5 /* CCValue.cpp */; }; 1AE3C845184F14F700CF29B5 /* CCValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE3C842184F14F700CF29B5 /* CCValue.cpp */; }; 1AE3C846184F14F700CF29B5 /* CCValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE3C843184F14F700CF29B5 /* CCValue.h */; }; 1AE3C847184F14F700CF29B5 /* CCValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE3C843184F14F700CF29B5 /* CCValue.h */; }; 2AC795DB1862870F005EC8E1 /* SkeletonBounds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D918628689005EC8E1 /* SkeletonBounds.cpp */; }; 2AC795DC1862870F005EC8E1 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D51862867D005EC8E1 /* Event.cpp */; }; 2AC795DD1862870F005EC8E1 /* EventData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D71862867D005EC8E1 /* EventData.cpp */; }; 2AC795DE1862870F005EC8E1 /* BoundingBoxAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D318628672005EC8E1 /* BoundingBoxAttachment.cpp */; }; 2AC795DF18628723005EC8E1 /* SkeletonBounds.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AC795DA18628689005EC8E1 /* SkeletonBounds.h */; }; 2AC795E018628723005EC8E1 /* Event.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AC795D61862867D005EC8E1 /* Event.h */; }; 2AC795E118628723005EC8E1 /* EventData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AC795D81862867D005EC8E1 /* EventData.h */; }; 2AC795E218628723005EC8E1 /* BoundingBoxAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AC795D418628672005EC8E1 /* BoundingBoxAttachment.h */; }; 2AC795E318628746005EC8E1 /* SkeletonBounds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D918628689005EC8E1 /* SkeletonBounds.cpp */; }; 2AC795E418628746005EC8E1 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D51862867D005EC8E1 /* Event.cpp */; }; 2AC795E518628746005EC8E1 /* EventData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D71862867D005EC8E1 /* EventData.cpp */; }; 2AC795E618628746005EC8E1 /* BoundingBoxAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D318628672005EC8E1 /* BoundingBoxAttachment.cpp */; }; 2AC795E71862875D005EC8E1 /* SkeletonBounds.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AC795DA18628689005EC8E1 /* SkeletonBounds.h */; }; 2AC795E81862875D005EC8E1 /* Event.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AC795D61862867D005EC8E1 /* Event.h */; }; 2AC795E91862875D005EC8E1 /* EventData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AC795D81862867D005EC8E1 /* EventData.h */; }; 2AC795EA1862875D005EC8E1 /* BoundingBoxAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AC795D418628672005EC8E1 /* BoundingBoxAttachment.h */; }; 2AFCB8211863D67F00EB4B5C /* jsb_cocos2dx_spine_auto.cpp in Headers */ = {isa = PBXBuildFile; fileRef = 2AFCB81F1863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.cpp */; }; 2AFCB8221863D68B00EB4B5C /* jsb_cocos2dx_spine_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2AFCB8201863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.hpp */; }; 2AFCB8231863D6B200EB4B5C /* jsb_cocos2dx_spine_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AFCB81F1863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.cpp */; }; 2AFCB8241863D6F600EB4B5C /* jsb_cocos2dx_spine_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AFCB81F1863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.cpp */; }; 2AFCB8251863D70300EB4B5C /* jsb_cocos2dx_spine_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2AFCB8201863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.hpp */; }; 373B9129187891F400198F86 /* CCComBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 373B910718787C0B00198F86 /* CCComBase.h */; }; 373B912A187891FB00198F86 /* CCComBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 373B910718787C0B00198F86 /* CCComBase.h */; }; 3774879F1869BA8C00EDF837 /* CCActionEaseEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3774879E1869BA8C00EDF837 /* CCActionEaseEx.cpp */; }; 3EEF8BD31839FFAF005E8A6C /* jsb_cocos2dx_gui_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EEF8BCB1839F390005E8A6C /* jsb_cocos2dx_gui_auto.cpp */; }; 3EEF8BD41839FFAF005E8A6C /* jsb_cocos2dx_gui_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EEF8BD11839F5C5005E8A6C /* jsb_cocos2dx_gui_manual.cpp */; }; 3EEF8BD5183A001B005E8A6C /* jsb_cocos2dx_gui_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EEF8BCB1839F390005E8A6C /* jsb_cocos2dx_gui_auto.cpp */; }; 3EEF8BD6183A001B005E8A6C /* jsb_cocos2dx_gui_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EEF8BD11839F5C5005E8A6C /* jsb_cocos2dx_gui_manual.cpp */; }; 460E44EF1807DED6000CDD6D /* mat4stack.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1709D1807CE87005B8026 /* mat4stack.c */; }; 460E44F01807DED6000CDD6D /* matrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1709E1807CE87005B8026 /* matrix.c */; }; 460E44F11807DED7000CDD6D /* mat4stack.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1709D1807CE87005B8026 /* mat4stack.c */; }; 460E44F21807DED8000CDD6D /* matrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1709E1807CE87005B8026 /* matrix.c */; }; 460E468118080832000CDD6D /* cocos-ext.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A167D21807AF4D005B8026 /* cocos-ext.h */; }; 460E468218080836000CDD6D /* cocos-ext.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A167D21807AF4D005B8026 /* cocos-ext.h */; }; 460E477B180808F5000CDD6D /* ExtensionMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168321807AF4E005B8026 /* ExtensionMacros.h */; }; 460E477C180808F7000CDD6D /* ExtensionMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168321807AF4E005B8026 /* ExtensionMacros.h */; }; 460E477D18080902000CDD6D /* CCControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168351807AF4E005B8026 /* CCControl.cpp */; }; 460E477E18080902000CDD6D /* CCControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168361807AF4E005B8026 /* CCControl.h */; }; 460E477F18080902000CDD6D /* CCControlButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168371807AF4E005B8026 /* CCControlButton.cpp */; }; 460E478018080902000CDD6D /* CCControlButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168381807AF4E005B8026 /* CCControlButton.h */; }; 460E478118080902000CDD6D /* CCControlColourPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168391807AF4E005B8026 /* CCControlColourPicker.cpp */; }; 460E478218080902000CDD6D /* CCControlColourPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683A1807AF4E005B8026 /* CCControlColourPicker.h */; }; 460E478318080902000CDD6D /* CCControlExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683B1807AF4E005B8026 /* CCControlExtensions.h */; }; 460E478418080902000CDD6D /* CCControlHuePicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1683C1807AF4E005B8026 /* CCControlHuePicker.cpp */; }; 460E478518080902000CDD6D /* CCControlHuePicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683D1807AF4E005B8026 /* CCControlHuePicker.h */; }; 460E478618080902000CDD6D /* CCControlPotentiometer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1683E1807AF4E005B8026 /* CCControlPotentiometer.cpp */; }; 460E478718080902000CDD6D /* CCControlPotentiometer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683F1807AF4E005B8026 /* CCControlPotentiometer.h */; }; 460E478818080902000CDD6D /* CCControlSaturationBrightnessPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168401807AF4E005B8026 /* CCControlSaturationBrightnessPicker.cpp */; }; 460E478918080902000CDD6D /* CCControlSaturationBrightnessPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168411807AF4E005B8026 /* CCControlSaturationBrightnessPicker.h */; }; 460E478A18080902000CDD6D /* CCControlSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168421807AF4E005B8026 /* CCControlSlider.cpp */; }; 460E478B18080902000CDD6D /* CCControlSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168431807AF4E005B8026 /* CCControlSlider.h */; }; 460E478C18080902000CDD6D /* CCControlStepper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168441807AF4E005B8026 /* CCControlStepper.cpp */; }; 460E478D18080902000CDD6D /* CCControlStepper.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168451807AF4E005B8026 /* CCControlStepper.h */; }; 460E478E18080902000CDD6D /* CCControlSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168461807AF4E005B8026 /* CCControlSwitch.cpp */; }; 460E478F18080902000CDD6D /* CCControlSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168471807AF4E005B8026 /* CCControlSwitch.h */; }; 460E479018080902000CDD6D /* CCControlUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168481807AF4E005B8026 /* CCControlUtils.cpp */; }; 460E479118080902000CDD6D /* CCControlUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168491807AF4E005B8026 /* CCControlUtils.h */; }; 460E479218080902000CDD6D /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */; }; 460E479318080902000CDD6D /* CCInvocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684B1807AF4E005B8026 /* CCInvocation.h */; }; 460E479418080902000CDD6D /* CCScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684C1807AF4E005B8026 /* CCScale9Sprite.cpp */; }; 460E479518080902000CDD6D /* CCScale9Sprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684D1807AF4E005B8026 /* CCScale9Sprite.h */; }; 460E479618080904000CDD6D /* CCControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168351807AF4E005B8026 /* CCControl.cpp */; }; 460E479718080904000CDD6D /* CCControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168361807AF4E005B8026 /* CCControl.h */; }; 460E479818080904000CDD6D /* CCControlButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168371807AF4E005B8026 /* CCControlButton.cpp */; }; 460E479918080904000CDD6D /* CCControlButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168381807AF4E005B8026 /* CCControlButton.h */; }; 460E479A18080904000CDD6D /* CCControlColourPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168391807AF4E005B8026 /* CCControlColourPicker.cpp */; }; 460E479B18080904000CDD6D /* CCControlColourPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683A1807AF4E005B8026 /* CCControlColourPicker.h */; }; 460E479C18080904000CDD6D /* CCControlExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683B1807AF4E005B8026 /* CCControlExtensions.h */; }; 460E479D18080904000CDD6D /* CCControlHuePicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1683C1807AF4E005B8026 /* CCControlHuePicker.cpp */; }; 460E479E18080904000CDD6D /* CCControlHuePicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683D1807AF4E005B8026 /* CCControlHuePicker.h */; }; 460E479F18080904000CDD6D /* CCControlPotentiometer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1683E1807AF4E005B8026 /* CCControlPotentiometer.cpp */; }; 460E47A018080904000CDD6D /* CCControlPotentiometer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683F1807AF4E005B8026 /* CCControlPotentiometer.h */; }; 460E47A118080904000CDD6D /* CCControlSaturationBrightnessPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168401807AF4E005B8026 /* CCControlSaturationBrightnessPicker.cpp */; }; 460E47A218080904000CDD6D /* CCControlSaturationBrightnessPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168411807AF4E005B8026 /* CCControlSaturationBrightnessPicker.h */; }; 460E47A318080904000CDD6D /* CCControlSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168421807AF4E005B8026 /* CCControlSlider.cpp */; }; 460E47A418080904000CDD6D /* CCControlSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168431807AF4E005B8026 /* CCControlSlider.h */; }; 460E47A518080904000CDD6D /* CCControlStepper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168441807AF4E005B8026 /* CCControlStepper.cpp */; }; 460E47A618080904000CDD6D /* CCControlStepper.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168451807AF4E005B8026 /* CCControlStepper.h */; }; 460E47A718080904000CDD6D /* CCControlSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168461807AF4E005B8026 /* CCControlSwitch.cpp */; }; 460E47A818080904000CDD6D /* CCControlSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168471807AF4E005B8026 /* CCControlSwitch.h */; }; 460E47A918080904000CDD6D /* CCControlUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168481807AF4E005B8026 /* CCControlUtils.cpp */; }; 460E47AA18080904000CDD6D /* CCControlUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168491807AF4E005B8026 /* CCControlUtils.h */; }; 460E47AB18080904000CDD6D /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */; }; 460E47AC18080904000CDD6D /* CCInvocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684B1807AF4E005B8026 /* CCInvocation.h */; }; 460E47AD18080904000CDD6D /* CCScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684C1807AF4E005B8026 /* CCScale9Sprite.cpp */; }; 460E47AE18080904000CDD6D /* CCScale9Sprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684D1807AF4E005B8026 /* CCScale9Sprite.h */; }; 460E47AF1808090B000CDD6D /* CCEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684F1807AF4E005B8026 /* CCEditBox.cpp */; }; 460E47B01808090B000CDD6D /* CCEditBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168501807AF4E005B8026 /* CCEditBox.h */; }; 460E47B11808090B000CDD6D /* CCEditBoxImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168511807AF4E005B8026 /* CCEditBoxImpl.h */; }; 460E47B21808090B000CDD6D /* CCEditBoxImplAndroid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168521807AF4E005B8026 /* CCEditBoxImplAndroid.cpp */; }; 460E47B31808090B000CDD6D /* CCEditBoxImplAndroid.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168531807AF4E005B8026 /* CCEditBoxImplAndroid.h */; }; 460E47B41808090B000CDD6D /* CCEditBoxImplIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168541807AF4E005B8026 /* CCEditBoxImplIOS.h */; }; 460E47B51808090B000CDD6D /* CCEditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A168551807AF4E005B8026 /* CCEditBoxImplIOS.mm */; }; 460E47B61808090B000CDD6D /* CCEditBoxImplMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168561807AF4E005B8026 /* CCEditBoxImplMac.h */; }; 460E47B71808090B000CDD6D /* CCEditBoxImplMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A168571807AF4E005B8026 /* CCEditBoxImplMac.mm */; }; 460E47B81808090B000CDD6D /* CCEditBoxImplNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168581807AF4E005B8026 /* CCEditBoxImplNone.cpp */; }; 460E47B91808090B000CDD6D /* CCEditBoxImplTizen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168591807AF4E005B8026 /* CCEditBoxImplTizen.cpp */; }; 460E47BA1808090B000CDD6D /* CCEditBoxImplTizen.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685A1807AF4E005B8026 /* CCEditBoxImplTizen.h */; }; 460E47BB1808090B000CDD6D /* CCEditBoxImplWin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1685B1807AF4E005B8026 /* CCEditBoxImplWin.cpp */; }; 460E47BC1808090B000CDD6D /* CCEditBoxImplWin.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685C1807AF4E005B8026 /* CCEditBoxImplWin.h */; }; 460E47BD1808090D000CDD6D /* CCEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684F1807AF4E005B8026 /* CCEditBox.cpp */; }; 460E47BE1808090D000CDD6D /* CCEditBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168501807AF4E005B8026 /* CCEditBox.h */; }; 460E47BF1808090D000CDD6D /* CCEditBoxImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168511807AF4E005B8026 /* CCEditBoxImpl.h */; }; 460E47C01808090D000CDD6D /* CCEditBoxImplAndroid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168521807AF4E005B8026 /* CCEditBoxImplAndroid.cpp */; }; 460E47C11808090D000CDD6D /* CCEditBoxImplAndroid.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168531807AF4E005B8026 /* CCEditBoxImplAndroid.h */; }; 460E47C21808090D000CDD6D /* CCEditBoxImplIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168541807AF4E005B8026 /* CCEditBoxImplIOS.h */; }; 460E47C31808090D000CDD6D /* CCEditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A168551807AF4E005B8026 /* CCEditBoxImplIOS.mm */; }; 460E47C41808090D000CDD6D /* CCEditBoxImplMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168561807AF4E005B8026 /* CCEditBoxImplMac.h */; }; 460E47C51808090D000CDD6D /* CCEditBoxImplMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A168571807AF4E005B8026 /* CCEditBoxImplMac.mm */; }; 460E47C61808090D000CDD6D /* CCEditBoxImplNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168581807AF4E005B8026 /* CCEditBoxImplNone.cpp */; }; 460E47C71808090D000CDD6D /* CCEditBoxImplTizen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168591807AF4E005B8026 /* CCEditBoxImplTizen.cpp */; }; 460E47C81808090D000CDD6D /* CCEditBoxImplTizen.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685A1807AF4E005B8026 /* CCEditBoxImplTizen.h */; }; 460E47C91808090D000CDD6D /* CCEditBoxImplWin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1685B1807AF4E005B8026 /* CCEditBoxImplWin.cpp */; }; 460E47CA1808090D000CDD6D /* CCEditBoxImplWin.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685C1807AF4E005B8026 /* CCEditBoxImplWin.h */; }; 460E47CB18080913000CDD6D /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */; }; 460E47CC18080913000CDD6D /* CCScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685F1807AF4E005B8026 /* CCScrollView.h */; }; 460E47CF18080913000CDD6D /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168621807AF4E005B8026 /* CCTableView.cpp */; }; 460E47D018080913000CDD6D /* CCTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168631807AF4E005B8026 /* CCTableView.h */; }; 460E47D118080913000CDD6D /* CCTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168641807AF4E005B8026 /* CCTableViewCell.cpp */; }; 460E47D218080913000CDD6D /* CCTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168651807AF4E005B8026 /* CCTableViewCell.h */; }; 460E47D318080914000CDD6D /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */; }; 460E47D418080914000CDD6D /* CCScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685F1807AF4E005B8026 /* CCScrollView.h */; }; 460E47D718080914000CDD6D /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168621807AF4E005B8026 /* CCTableView.cpp */; }; 460E47D818080914000CDD6D /* CCTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168631807AF4E005B8026 /* CCTableView.h */; }; 460E47D918080914000CDD6D /* CCTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168641807AF4E005B8026 /* CCTableViewCell.cpp */; }; 460E47DA18080914000CDD6D /* CCTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168651807AF4E005B8026 /* CCTableViewCell.h */; }; 46A160421807A5D4005B8026 /* Export.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE11807A56F005B8026 /* Export.h */; }; 46A160431807A5D4005B8026 /* SimpleAudioEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE21807A56F005B8026 /* SimpleAudioEngine.h */; }; 46A160441807A5D4005B8026 /* CDAudioManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FF41807A56F005B8026 /* CDAudioManager.h */; }; 46A160451807A5D4005B8026 /* CDAudioManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FF51807A56F005B8026 /* CDAudioManager.m */; }; 46A160461807A5D4005B8026 /* CDConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FF61807A56F005B8026 /* CDConfig.h */; }; 46A160471807A5D4005B8026 /* CDOpenALSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FF71807A56F005B8026 /* CDOpenALSupport.h */; }; 46A160481807A5D4005B8026 /* CDOpenALSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FF81807A56F005B8026 /* CDOpenALSupport.m */; }; 46A160491807A5D4005B8026 /* CDXMacOSXSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FF91807A56F005B8026 /* CDXMacOSXSupport.h */; }; 46A1604A1807A5D4005B8026 /* CDXMacOSXSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FFA1807A56F005B8026 /* CDXMacOSXSupport.mm */; }; 46A1604B1807A5D4005B8026 /* CocosDenshion.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FFB1807A56F005B8026 /* CocosDenshion.h */; }; 46A1604C1807A5D4005B8026 /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FFC1807A56F005B8026 /* CocosDenshion.m */; }; 46A1604D1807A5D4005B8026 /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FFD1807A56F005B8026 /* SimpleAudioEngine.mm */; }; 46A1604E1807A5D4005B8026 /* SimpleAudioEngine_objc.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FFE1807A56F005B8026 /* SimpleAudioEngine_objc.h */; }; 46A1604F1807A5D4005B8026 /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FFF1807A56F005B8026 /* SimpleAudioEngine_objc.m */; }; 46A160501807A5EB005B8026 /* Export.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE11807A56F005B8026 /* Export.h */; }; 46A160511807A5EB005B8026 /* SimpleAudioEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE21807A56F005B8026 /* SimpleAudioEngine.h */; }; 46A160521807A5EB005B8026 /* CDAudioManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE41807A56F005B8026 /* CDAudioManager.h */; }; 46A160531807A5EB005B8026 /* CDAudioManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FE51807A56F005B8026 /* CDAudioManager.m */; }; 46A160541807A5EB005B8026 /* CDConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE61807A56F005B8026 /* CDConfig.h */; }; 46A160551807A5EB005B8026 /* CDOpenALSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE71807A56F005B8026 /* CDOpenALSupport.h */; }; 46A160561807A5EB005B8026 /* CDOpenALSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FE81807A56F005B8026 /* CDOpenALSupport.m */; }; 46A160571807A5EB005B8026 /* CocosDenshion.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE91807A56F005B8026 /* CocosDenshion.h */; }; 46A160581807A5EB005B8026 /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FEA1807A56F005B8026 /* CocosDenshion.m */; }; 46A160591807A5EB005B8026 /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FEB1807A56F005B8026 /* SimpleAudioEngine.mm */; }; 46A1605A1807A5EB005B8026 /* SimpleAudioEngine_objc.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FEC1807A56F005B8026 /* SimpleAudioEngine_objc.h */; }; 46A1605B1807A5EB005B8026 /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A15FED1807A56F005B8026 /* SimpleAudioEngine_objc.m */; }; 46A170131807CBFC005B8026 /* CCFileUtilsApple.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A8F1807B038005B8026 /* CCFileUtilsApple.h */; }; 46A170141807CBFC005B8026 /* CCFileUtilsApple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A901807B038005B8026 /* CCFileUtilsApple.mm */; }; 46A170151807CBFC005B8026 /* CCLock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A911807B038005B8026 /* CCLock.cpp */; }; 46A170161807CBFC005B8026 /* CCLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A921807B038005B8026 /* CCLock.h */; }; 46A170171807CBFC005B8026 /* CCThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A931807B038005B8026 /* CCThread.mm */; }; 46A170181807CBFC005B8026 /* CCApplicationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A941807B038005B8026 /* CCApplicationProtocol.h */; }; 46A170191807CBFC005B8026 /* CCCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A951807B038005B8026 /* CCCommon.h */; }; 46A1701A1807CBFC005B8026 /* CCDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A961807B038005B8026 /* CCDevice.h */; }; 46A1701B1807CBFC005B8026 /* CCEGLViewProtocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A971807B038005B8026 /* CCEGLViewProtocol.cpp */; }; 46A1701C1807CBFC005B8026 /* CCEGLViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A981807B038005B8026 /* CCEGLViewProtocol.h */; }; 46A1701D1807CBFC005B8026 /* CCFileUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A991807B038005B8026 /* CCFileUtils.cpp */; }; 46A1701E1807CBFC005B8026 /* CCFileUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A9A1807B038005B8026 /* CCFileUtils.h */; }; 46A1701F1807CBFC005B8026 /* CCImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A9B1807B038005B8026 /* CCImage.h */; }; 46A170231807CBFC005B8026 /* CCSAXParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A9F1807B038005B8026 /* CCSAXParser.cpp */; }; 46A170241807CBFC005B8026 /* CCSAXParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AA01807B038005B8026 /* CCSAXParser.h */; }; 46A170251807CBFC005B8026 /* CCThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AA11807B038005B8026 /* CCThread.cpp */; }; 46A170261807CBFC005B8026 /* CCThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AA21807B038005B8026 /* CCThread.h */; }; 46A170271807CBFE005B8026 /* CCFileUtilsApple.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A8F1807B038005B8026 /* CCFileUtilsApple.h */; }; 46A170281807CBFE005B8026 /* CCFileUtilsApple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A901807B038005B8026 /* CCFileUtilsApple.mm */; }; 46A170291807CBFE005B8026 /* CCLock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A911807B038005B8026 /* CCLock.cpp */; }; 46A1702A1807CBFE005B8026 /* CCLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A921807B038005B8026 /* CCLock.h */; }; 46A1702B1807CBFE005B8026 /* CCThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A931807B038005B8026 /* CCThread.mm */; }; 46A1702C1807CBFE005B8026 /* CCApplicationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A941807B038005B8026 /* CCApplicationProtocol.h */; }; 46A1702D1807CBFE005B8026 /* CCCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A951807B038005B8026 /* CCCommon.h */; }; 46A1702E1807CBFE005B8026 /* CCDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A961807B038005B8026 /* CCDevice.h */; }; 46A1702F1807CBFE005B8026 /* CCEGLViewProtocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A971807B038005B8026 /* CCEGLViewProtocol.cpp */; }; 46A170301807CBFE005B8026 /* CCEGLViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A981807B038005B8026 /* CCEGLViewProtocol.h */; }; 46A170311807CBFE005B8026 /* CCFileUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A991807B038005B8026 /* CCFileUtils.cpp */; }; 46A170321807CBFE005B8026 /* CCFileUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A9A1807B038005B8026 /* CCFileUtils.h */; }; 46A170331807CBFE005B8026 /* CCImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16A9B1807B038005B8026 /* CCImage.h */; }; 46A170371807CBFE005B8026 /* CCSAXParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16A9F1807B038005B8026 /* CCSAXParser.cpp */; }; 46A170381807CBFE005B8026 /* CCSAXParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AA01807B038005B8026 /* CCSAXParser.h */; }; 46A170391807CBFE005B8026 /* CCThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AA11807B038005B8026 /* CCThread.cpp */; }; 46A1703A1807CBFE005B8026 /* CCThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AA21807B038005B8026 /* CCThread.h */; }; 46A1703B1807CC07005B8026 /* CCApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AA41807B038005B8026 /* CCApplication.h */; }; 46A1703C1807CC07005B8026 /* CCApplication.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AA51807B038005B8026 /* CCApplication.mm */; }; 46A1703D1807CC07005B8026 /* CCCommon.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AA61807B038005B8026 /* CCCommon.mm */; }; 46A1703E1807CC07005B8026 /* CCDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AA71807B038005B8026 /* CCDevice.mm */; }; 46A1703F1807CC07005B8026 /* CCDirectorCaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AA81807B038005B8026 /* CCDirectorCaller.h */; }; 46A170401807CC07005B8026 /* CCDirectorCaller.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AA91807B038005B8026 /* CCDirectorCaller.mm */; }; 46A170411807CC07005B8026 /* CCEGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AAA1807B038005B8026 /* CCEGLView.h */; }; 46A170421807CC07005B8026 /* CCEGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AAB1807B038005B8026 /* CCEGLView.mm */; }; 46A170431807CC07005B8026 /* CCES2Renderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AAC1807B038005B8026 /* CCES2Renderer.h */; }; 46A170441807CC07005B8026 /* CCES2Renderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AAD1807B038005B8026 /* CCES2Renderer.m */; }; 46A170451807CC07005B8026 /* CCESRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AAE1807B038005B8026 /* CCESRenderer.h */; }; 46A170471807CC07005B8026 /* CCImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AB01807B038005B8026 /* CCImage.mm */; }; 46A170481807CC07005B8026 /* CCPlatformDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AB11807B038005B8026 /* CCPlatformDefine.h */; }; 46A170491807CC07005B8026 /* CCStdC.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AB21807B038005B8026 /* CCStdC.h */; }; 46A1704B1807CC07005B8026 /* EAGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AB41807B038005B8026 /* EAGLView.mm */; }; 46A1704C1807CC07005B8026 /* OpenGL_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AB51807B038005B8026 /* OpenGL_Internal.h */; }; 46A1704D1807CC11005B8026 /* AccelerometerSimulation.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AB71807B038005B8026 /* AccelerometerSimulation.h */; }; 46A1704E1807CC11005B8026 /* AccelerometerSimulation.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AB81807B038005B8026 /* AccelerometerSimulation.m */; }; 46A1704F1807CC1C005B8026 /* CCApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AC81807B038005B8026 /* CCApplication.h */; }; 46A170501807CC1C005B8026 /* CCApplication.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AC91807B038005B8026 /* CCApplication.mm */; }; 46A170511807CC1C005B8026 /* CCCommon.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16ACA1807B038005B8026 /* CCCommon.mm */; }; 46A170521807CC1C005B8026 /* CCDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A16ACB1807B038005B8026 /* CCDevice.cpp */; }; 46A170531807CC1C005B8026 /* CCDirectorCaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16ACC1807B038005B8026 /* CCDirectorCaller.h */; }; 46A170541807CC1C005B8026 /* CCDirectorCaller.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16ACD1807B038005B8026 /* CCDirectorCaller.mm */; }; 46A1705A1807CC1C005B8026 /* CCImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A16AD31807B038005B8026 /* CCImage.mm */; }; 46A1705B1807CC1C005B8026 /* CCPlatformDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AD41807B038005B8026 /* CCPlatformDefine.h */; }; 46A1705C1807CC1C005B8026 /* CCStdC.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A16AD51807B038005B8026 /* CCStdC.h */; }; 46A170A91807CE9D005B8026 /* aabb.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170891807CE87005B8026 /* aabb.h */; }; 46A170AA1807CE9E005B8026 /* aabb.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170891807CE87005B8026 /* aabb.h */; }; 46A170AB1807CEA3005B8026 /* mat4stack.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708B1807CE87005B8026 /* mat4stack.h */; }; 46A170AC1807CEA3005B8026 /* matrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708C1807CE87005B8026 /* matrix.h */; }; 46A170AD1807CEA3005B8026 /* kazmath.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708D1807CE87005B8026 /* kazmath.h */; }; 46A170AE1807CEA3005B8026 /* mat3.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708E1807CE87005B8026 /* mat3.h */; }; 46A170AF1807CEA3005B8026 /* mat4.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708F1807CE87005B8026 /* mat4.h */; }; 46A170B01807CEA3005B8026 /* neon_matrix_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170901807CE87005B8026 /* neon_matrix_impl.h */; }; 46A170B11807CEA3005B8026 /* plane.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170911807CE87005B8026 /* plane.h */; }; 46A170B21807CEA3005B8026 /* quaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170921807CE87005B8026 /* quaternion.h */; }; 46A170B31807CEA3005B8026 /* ray2.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170931807CE87005B8026 /* ray2.h */; }; 46A170B41807CEA3005B8026 /* utility.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170941807CE87005B8026 /* utility.h */; }; 46A170B51807CEA3005B8026 /* vec2.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170951807CE87005B8026 /* vec2.h */; }; 46A170B61807CEA3005B8026 /* vec3.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170961807CE87005B8026 /* vec3.h */; }; 46A170B71807CEA3005B8026 /* vec4.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170971807CE87005B8026 /* vec4.h */; }; 46A170B81807CEA4005B8026 /* mat4stack.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708B1807CE87005B8026 /* mat4stack.h */; }; 46A170B91807CEA4005B8026 /* matrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708C1807CE87005B8026 /* matrix.h */; }; 46A170BA1807CEA4005B8026 /* kazmath.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708D1807CE87005B8026 /* kazmath.h */; }; 46A170BB1807CEA4005B8026 /* mat3.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708E1807CE87005B8026 /* mat3.h */; }; 46A170BC1807CEA4005B8026 /* mat4.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1708F1807CE87005B8026 /* mat4.h */; }; 46A170BD1807CEA4005B8026 /* neon_matrix_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170901807CE87005B8026 /* neon_matrix_impl.h */; }; 46A170BE1807CEA4005B8026 /* plane.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170911807CE87005B8026 /* plane.h */; }; 46A170BF1807CEA4005B8026 /* quaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170921807CE87005B8026 /* quaternion.h */; }; 46A170C01807CEA4005B8026 /* ray2.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170931807CE87005B8026 /* ray2.h */; }; 46A170C11807CEA4005B8026 /* utility.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170941807CE87005B8026 /* utility.h */; }; 46A170C21807CEA4005B8026 /* vec2.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170951807CE87005B8026 /* vec2.h */; }; 46A170C31807CEA4005B8026 /* vec3.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170961807CE87005B8026 /* vec3.h */; }; 46A170C41807CEA4005B8026 /* vec4.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170971807CE87005B8026 /* vec4.h */; }; 46A170C51807CEB0005B8026 /* aabb.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170991807CE87005B8026 /* aabb.c */; }; 46A170C61807CEB2005B8026 /* aabb.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170991807CE87005B8026 /* aabb.c */; }; 46A170C71807CEBB005B8026 /* mat3.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1709F1807CE87005B8026 /* mat3.c */; }; 46A170C81807CEBB005B8026 /* mat4.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A01807CE87005B8026 /* mat4.c */; }; 46A170C91807CEBB005B8026 /* neon_matrix_impl.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A11807CE87005B8026 /* neon_matrix_impl.c */; }; 46A170CA1807CEBB005B8026 /* plane.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A21807CE87005B8026 /* plane.c */; }; 46A170CB1807CEBB005B8026 /* quaternion.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A31807CE87005B8026 /* quaternion.c */; }; 46A170CC1807CEBB005B8026 /* ray2.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A41807CE87005B8026 /* ray2.c */; }; 46A170CD1807CEBB005B8026 /* utility.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A51807CE87005B8026 /* utility.c */; }; 46A170CE1807CEBB005B8026 /* vec2.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A61807CE87005B8026 /* vec2.c */; }; 46A170CF1807CEBB005B8026 /* vec3.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A71807CE87005B8026 /* vec3.c */; }; 46A170D01807CEBB005B8026 /* vec4.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A81807CE87005B8026 /* vec4.c */; }; 46A170D11807CEBC005B8026 /* mat3.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1709F1807CE87005B8026 /* mat3.c */; }; 46A170D21807CEBC005B8026 /* mat4.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A01807CE87005B8026 /* mat4.c */; }; 46A170D31807CEBC005B8026 /* neon_matrix_impl.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A11807CE87005B8026 /* neon_matrix_impl.c */; }; 46A170D41807CEBC005B8026 /* plane.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A21807CE87005B8026 /* plane.c */; }; 46A170D51807CEBC005B8026 /* quaternion.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A31807CE87005B8026 /* quaternion.c */; }; 46A170D61807CEBC005B8026 /* ray2.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A41807CE87005B8026 /* ray2.c */; }; 46A170D71807CEBC005B8026 /* utility.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A51807CE87005B8026 /* utility.c */; }; 46A170D81807CEBC005B8026 /* vec2.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A61807CE87005B8026 /* vec2.c */; }; 46A170D91807CEBC005B8026 /* vec3.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A71807CE87005B8026 /* vec3.c */; }; 46A170DA1807CEBC005B8026 /* vec4.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A170A81807CE87005B8026 /* vec4.c */; }; 46A170E61807CECA005B8026 /* CCPhysicsBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1706E1807CE7A005B8026 /* CCPhysicsBody.cpp */; }; 46A170E71807CECA005B8026 /* CCPhysicsBody.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1706F1807CE7A005B8026 /* CCPhysicsBody.h */; }; 46A170E81807CECA005B8026 /* CCPhysicsContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170701807CE7A005B8026 /* CCPhysicsContact.cpp */; }; 46A170E91807CECA005B8026 /* CCPhysicsContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170711807CE7A005B8026 /* CCPhysicsContact.h */; }; 46A170EA1807CECA005B8026 /* CCPhysicsJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170721807CE7A005B8026 /* CCPhysicsJoint.cpp */; }; 46A170EB1807CECA005B8026 /* CCPhysicsJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170731807CE7A005B8026 /* CCPhysicsJoint.h */; }; 46A170ED1807CECA005B8026 /* CCPhysicsShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170751807CE7A005B8026 /* CCPhysicsShape.cpp */; }; 46A170EE1807CECA005B8026 /* CCPhysicsShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170761807CE7A005B8026 /* CCPhysicsShape.h */; }; 46A170EF1807CECA005B8026 /* CCPhysicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170771807CE7A005B8026 /* CCPhysicsWorld.cpp */; }; 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170781807CE7A005B8026 /* CCPhysicsWorld.h */; }; 46A170FC1807CECB005B8026 /* CCPhysicsBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1706E1807CE7A005B8026 /* CCPhysicsBody.cpp */; }; 46A170FD1807CECB005B8026 /* CCPhysicsBody.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1706F1807CE7A005B8026 /* CCPhysicsBody.h */; }; 46A170FE1807CECB005B8026 /* CCPhysicsContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170701807CE7A005B8026 /* CCPhysicsContact.cpp */; }; 46A170FF1807CECB005B8026 /* CCPhysicsContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170711807CE7A005B8026 /* CCPhysicsContact.h */; }; 46A171001807CECB005B8026 /* CCPhysicsJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170721807CE7A005B8026 /* CCPhysicsJoint.cpp */; }; 46A171011807CECB005B8026 /* CCPhysicsJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170731807CE7A005B8026 /* CCPhysicsJoint.h */; }; 46A171031807CECB005B8026 /* CCPhysicsShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170751807CE7A005B8026 /* CCPhysicsShape.cpp */; }; 46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170761807CE7A005B8026 /* CCPhysicsShape.h */; }; 46A171051807CECB005B8026 /* CCPhysicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170771807CE7A005B8026 /* CCPhysicsWorld.cpp */; }; 46A171061807CECB005B8026 /* CCPhysicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A170781807CE7A005B8026 /* CCPhysicsWorld.h */; }; 46A173D41807D358005B8026 /* chipmunk.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1697B1807AFD6005B8026 /* chipmunk.c */; }; 46A173D51807D35A005B8026 /* chipmunk.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1697B1807AFD6005B8026 /* chipmunk.c */; }; 46A173D61807D363005B8026 /* cpConstraint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1697E1807AFD6005B8026 /* cpConstraint.c */; }; 46A173D71807D363005B8026 /* cpDampedRotarySpring.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1697F1807AFD6005B8026 /* cpDampedRotarySpring.c */; }; 46A173D81807D363005B8026 /* cpDampedSpring.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169801807AFD6005B8026 /* cpDampedSpring.c */; }; 46A173D91807D363005B8026 /* cpGearJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169811807AFD6005B8026 /* cpGearJoint.c */; }; 46A173DA1807D363005B8026 /* cpGrooveJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169821807AFD6005B8026 /* cpGrooveJoint.c */; }; 46A173DB1807D363005B8026 /* cpPinJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169831807AFD6005B8026 /* cpPinJoint.c */; }; 46A173DC1807D363005B8026 /* cpPivotJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169841807AFD6005B8026 /* cpPivotJoint.c */; }; 46A173DD1807D363005B8026 /* cpRatchetJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169851807AFD6005B8026 /* cpRatchetJoint.c */; }; 46A173DE1807D363005B8026 /* cpRotaryLimitJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169861807AFD6005B8026 /* cpRotaryLimitJoint.c */; }; 46A173DF1807D363005B8026 /* cpSimpleMotor.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169871807AFD6005B8026 /* cpSimpleMotor.c */; }; 46A173E01807D363005B8026 /* cpSlideJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169881807AFD6005B8026 /* cpSlideJoint.c */; }; 46A173E11807D363005B8026 /* cpArbiter.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169891807AFD6005B8026 /* cpArbiter.c */; }; 46A173E21807D363005B8026 /* cpArray.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698A1807AFD6005B8026 /* cpArray.c */; }; 46A173E31807D363005B8026 /* cpBB.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698B1807AFD6005B8026 /* cpBB.c */; }; 46A173E41807D363005B8026 /* cpBBTree.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698C1807AFD6005B8026 /* cpBBTree.c */; }; 46A173E51807D363005B8026 /* cpBody.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698D1807AFD6005B8026 /* cpBody.c */; }; 46A173E61807D363005B8026 /* cpCollision.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698E1807AFD6005B8026 /* cpCollision.c */; }; 46A173E71807D363005B8026 /* cpHashSet.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698F1807AFD6005B8026 /* cpHashSet.c */; }; 46A173E81807D363005B8026 /* cpPolyShape.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169901807AFD6005B8026 /* cpPolyShape.c */; }; 46A173E91807D363005B8026 /* cpShape.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169911807AFD6005B8026 /* cpShape.c */; }; 46A173EA1807D363005B8026 /* cpSpace.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169921807AFD6005B8026 /* cpSpace.c */; }; 46A173EB1807D363005B8026 /* cpSpaceComponent.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169931807AFD6005B8026 /* cpSpaceComponent.c */; }; 46A173EC1807D363005B8026 /* cpSpaceHash.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169941807AFD6005B8026 /* cpSpaceHash.c */; }; 46A173ED1807D363005B8026 /* cpSpaceQuery.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169951807AFD6005B8026 /* cpSpaceQuery.c */; }; 46A173EE1807D363005B8026 /* cpSpaceStep.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169961807AFD6005B8026 /* cpSpaceStep.c */; }; 46A173EF1807D363005B8026 /* cpSpatialIndex.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169971807AFD6005B8026 /* cpSpatialIndex.c */; }; 46A173F01807D363005B8026 /* cpSweep1D.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169981807AFD6005B8026 /* cpSweep1D.c */; }; 46A173F11807D363005B8026 /* cpVect.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169991807AFD6005B8026 /* cpVect.c */; }; 46A173F21807D363005B8026 /* prime.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1699A1807AFD6005B8026 /* prime.h */; }; 46A173F31807D365005B8026 /* cpConstraint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1697E1807AFD6005B8026 /* cpConstraint.c */; }; 46A173F41807D365005B8026 /* cpDampedRotarySpring.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1697F1807AFD6005B8026 /* cpDampedRotarySpring.c */; }; 46A173F51807D365005B8026 /* cpDampedSpring.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169801807AFD6005B8026 /* cpDampedSpring.c */; }; 46A173F61807D365005B8026 /* cpGearJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169811807AFD6005B8026 /* cpGearJoint.c */; }; 46A173F71807D365005B8026 /* cpGrooveJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169821807AFD6005B8026 /* cpGrooveJoint.c */; }; 46A173F81807D365005B8026 /* cpPinJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169831807AFD6005B8026 /* cpPinJoint.c */; }; 46A173F91807D365005B8026 /* cpPivotJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169841807AFD6005B8026 /* cpPivotJoint.c */; }; 46A173FA1807D365005B8026 /* cpRatchetJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169851807AFD6005B8026 /* cpRatchetJoint.c */; }; 46A173FB1807D365005B8026 /* cpRotaryLimitJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169861807AFD6005B8026 /* cpRotaryLimitJoint.c */; }; 46A173FC1807D365005B8026 /* cpSimpleMotor.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169871807AFD6005B8026 /* cpSimpleMotor.c */; }; 46A173FD1807D365005B8026 /* cpSlideJoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169881807AFD6005B8026 /* cpSlideJoint.c */; }; 46A173FE1807D365005B8026 /* cpArbiter.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169891807AFD6005B8026 /* cpArbiter.c */; }; 46A173FF1807D365005B8026 /* cpArray.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698A1807AFD6005B8026 /* cpArray.c */; }; 46A174001807D365005B8026 /* cpBB.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698B1807AFD6005B8026 /* cpBB.c */; }; 46A174011807D365005B8026 /* cpBBTree.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698C1807AFD6005B8026 /* cpBBTree.c */; }; 46A174021807D365005B8026 /* cpBody.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698D1807AFD6005B8026 /* cpBody.c */; }; 46A174031807D365005B8026 /* cpCollision.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698E1807AFD6005B8026 /* cpCollision.c */; }; 46A174041807D365005B8026 /* cpHashSet.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A1698F1807AFD6005B8026 /* cpHashSet.c */; }; 46A174051807D365005B8026 /* cpPolyShape.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169901807AFD6005B8026 /* cpPolyShape.c */; }; 46A174061807D365005B8026 /* cpShape.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169911807AFD6005B8026 /* cpShape.c */; }; 46A174071807D365005B8026 /* cpSpace.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169921807AFD6005B8026 /* cpSpace.c */; }; 46A174081807D365005B8026 /* cpSpaceComponent.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169931807AFD6005B8026 /* cpSpaceComponent.c */; }; 46A174091807D365005B8026 /* cpSpaceHash.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169941807AFD6005B8026 /* cpSpaceHash.c */; }; 46A1740A1807D365005B8026 /* cpSpaceQuery.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169951807AFD6005B8026 /* cpSpaceQuery.c */; }; 46A1740B1807D365005B8026 /* cpSpaceStep.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169961807AFD6005B8026 /* cpSpaceStep.c */; }; 46A1740C1807D365005B8026 /* cpSpatialIndex.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169971807AFD6005B8026 /* cpSpatialIndex.c */; }; 46A1740D1807D365005B8026 /* cpSweep1D.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169981807AFD6005B8026 /* cpSweep1D.c */; }; 46A1740E1807D365005B8026 /* cpVect.c in Sources */ = {isa = PBXBuildFile; fileRef = 46A169991807AFD6005B8026 /* cpVect.c */; }; 46A1740F1807D365005B8026 /* prime.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1699A1807AFD6005B8026 /* prime.h */; }; 46A174101807D372005B8026 /* chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169401807AFD6005B8026 /* chipmunk.h */; }; 46A174111807D372005B8026 /* chipmunk_ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169411807AFD6005B8026 /* chipmunk_ffi.h */; }; 46A174121807D372005B8026 /* chipmunk_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169421807AFD6005B8026 /* chipmunk_private.h */; }; 46A174131807D372005B8026 /* chipmunk_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169431807AFD6005B8026 /* chipmunk_types.h */; }; 46A174141807D372005B8026 /* chipmunk_unsafe.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169441807AFD6005B8026 /* chipmunk_unsafe.h */; }; 46A174151807D374005B8026 /* chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169401807AFD6005B8026 /* chipmunk.h */; }; 46A174161807D374005B8026 /* chipmunk_ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169411807AFD6005B8026 /* chipmunk_ffi.h */; }; 46A174171807D374005B8026 /* chipmunk_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169421807AFD6005B8026 /* chipmunk_private.h */; }; 46A174181807D374005B8026 /* chipmunk_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169431807AFD6005B8026 /* chipmunk_types.h */; }; 46A174191807D374005B8026 /* chipmunk_unsafe.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169441807AFD6005B8026 /* chipmunk_unsafe.h */; }; 46A1741A1807D379005B8026 /* cpConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169461807AFD6005B8026 /* cpConstraint.h */; }; 46A1741B1807D379005B8026 /* cpDampedRotarySpring.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169471807AFD6005B8026 /* cpDampedRotarySpring.h */; }; 46A1741C1807D379005B8026 /* cpDampedSpring.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169481807AFD6005B8026 /* cpDampedSpring.h */; }; 46A1741D1807D379005B8026 /* cpGearJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169491807AFD6005B8026 /* cpGearJoint.h */; }; 46A1741E1807D379005B8026 /* cpGrooveJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694A1807AFD6005B8026 /* cpGrooveJoint.h */; }; 46A1741F1807D379005B8026 /* cpPinJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694B1807AFD6005B8026 /* cpPinJoint.h */; }; 46A174201807D379005B8026 /* cpPivotJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694C1807AFD6005B8026 /* cpPivotJoint.h */; }; 46A174211807D379005B8026 /* cpRatchetJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694D1807AFD6005B8026 /* cpRatchetJoint.h */; }; 46A174221807D379005B8026 /* cpRotaryLimitJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694E1807AFD6005B8026 /* cpRotaryLimitJoint.h */; }; 46A174231807D379005B8026 /* cpSimpleMotor.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694F1807AFD6005B8026 /* cpSimpleMotor.h */; }; 46A174241807D379005B8026 /* cpSlideJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169501807AFD6005B8026 /* cpSlideJoint.h */; }; 46A174251807D379005B8026 /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169511807AFD6005B8026 /* util.h */; }; 46A174261807D379005B8026 /* cpArbiter.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169521807AFD6005B8026 /* cpArbiter.h */; }; 46A174271807D379005B8026 /* cpBB.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169531807AFD6005B8026 /* cpBB.h */; }; 46A174281807D379005B8026 /* cpBody.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169541807AFD6005B8026 /* cpBody.h */; }; 46A174291807D379005B8026 /* cpPolyShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169551807AFD6005B8026 /* cpPolyShape.h */; }; 46A1742A1807D379005B8026 /* cpShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169561807AFD6005B8026 /* cpShape.h */; }; 46A1742B1807D379005B8026 /* cpSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169571807AFD6005B8026 /* cpSpace.h */; }; 46A1742C1807D379005B8026 /* cpSpatialIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169581807AFD6005B8026 /* cpSpatialIndex.h */; }; 46A1742D1807D379005B8026 /* cpVect.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169591807AFD6005B8026 /* cpVect.h */; }; 46A1742E1807D37B005B8026 /* cpConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169461807AFD6005B8026 /* cpConstraint.h */; }; 46A1742F1807D37B005B8026 /* cpDampedRotarySpring.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169471807AFD6005B8026 /* cpDampedRotarySpring.h */; }; 46A174301807D37B005B8026 /* cpDampedSpring.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169481807AFD6005B8026 /* cpDampedSpring.h */; }; 46A174311807D37B005B8026 /* cpGearJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169491807AFD6005B8026 /* cpGearJoint.h */; }; 46A174321807D37B005B8026 /* cpGrooveJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694A1807AFD6005B8026 /* cpGrooveJoint.h */; }; 46A174331807D37B005B8026 /* cpPinJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694B1807AFD6005B8026 /* cpPinJoint.h */; }; 46A174341807D37B005B8026 /* cpPivotJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694C1807AFD6005B8026 /* cpPivotJoint.h */; }; 46A174351807D37B005B8026 /* cpRatchetJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694D1807AFD6005B8026 /* cpRatchetJoint.h */; }; 46A174361807D37B005B8026 /* cpRotaryLimitJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694E1807AFD6005B8026 /* cpRotaryLimitJoint.h */; }; 46A174371807D37B005B8026 /* cpSimpleMotor.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1694F1807AFD6005B8026 /* cpSimpleMotor.h */; }; 46A174381807D37B005B8026 /* cpSlideJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169501807AFD6005B8026 /* cpSlideJoint.h */; }; 46A174391807D37B005B8026 /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169511807AFD6005B8026 /* util.h */; }; 46A1743A1807D37B005B8026 /* cpArbiter.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169521807AFD6005B8026 /* cpArbiter.h */; }; 46A1743B1807D37B005B8026 /* cpBB.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169531807AFD6005B8026 /* cpBB.h */; }; 46A1743C1807D37B005B8026 /* cpBody.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169541807AFD6005B8026 /* cpBody.h */; }; 46A1743D1807D37B005B8026 /* cpPolyShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169551807AFD6005B8026 /* cpPolyShape.h */; }; 46A1743E1807D37B005B8026 /* cpShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169561807AFD6005B8026 /* cpShape.h */; }; 46A1743F1807D37B005B8026 /* cpSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169571807AFD6005B8026 /* cpSpace.h */; }; 46A174401807D37B005B8026 /* cpSpatialIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169581807AFD6005B8026 /* cpSpatialIndex.h */; }; 46A174411807D37B005B8026 /* cpVect.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A169591807AFD6005B8026 /* cpVect.h */; }; 5069133E185016C1009BBDD7 /* CCConsole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5069133C185016C1009BBDD7 /* CCConsole.cpp */; }; 5069133F185016C1009BBDD7 /* CCConsole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5069133C185016C1009BBDD7 /* CCConsole.cpp */; }; 50691340185016C1009BBDD7 /* CCConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = 5069133D185016C1009BBDD7 /* CCConsole.h */; }; 50691341185016C1009BBDD7 /* CCConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = 5069133D185016C1009BBDD7 /* CCConsole.h */; }; 50A1FF1818290ED4001840C4 /* UIListView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50A1FF1618290ED4001840C4 /* UIListView.cpp */; }; 50A1FF1918290ED4001840C4 /* UIListView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50A1FF1618290ED4001840C4 /* UIListView.cpp */; }; 50A1FF1A18290ED4001840C4 /* UIListView.h in Headers */ = {isa = PBXBuildFile; fileRef = 50A1FF1718290ED4001840C4 /* UIListView.h */; }; 50A1FF1B18290ED4001840C4 /* UIListView.h in Headers */ = {isa = PBXBuildFile; fileRef = 50A1FF1718290ED4001840C4 /* UIListView.h */; }; 50AE5EA3188749250007CFE3 /* CCBatchCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50AE5EA1188749250007CFE3 /* CCBatchCommand.cpp */; }; 50AE5EA4188749250007CFE3 /* CCBatchCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50AE5EA1188749250007CFE3 /* CCBatchCommand.cpp */; }; 50AE5EA5188749250007CFE3 /* CCBatchCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 50AE5EA2188749250007CFE3 /* CCBatchCommand.h */; }; 50AE5EA6188749250007CFE3 /* CCBatchCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 50AE5EA2188749250007CFE3 /* CCBatchCommand.h */; }; 593BDCF2184D0A6E00C21E48 /* CCCustomCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 593BDCD8184D0A6E00C21E48 /* CCCustomCommand.cpp */; }; 593BDCF3184D0A6E00C21E48 /* CCCustomCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 593BDCD8184D0A6E00C21E48 /* CCCustomCommand.cpp */; }; 593BDCF4184D0A6E00C21E48 /* CCCustomCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 593BDCD9184D0A6E00C21E48 /* CCCustomCommand.h */; }; 593BDCF5184D0A6E00C21E48 /* CCCustomCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 593BDCD9184D0A6E00C21E48 /* CCCustomCommand.h */; }; 593BDCF6184D0A6E00C21E48 /* CCGroupCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 593BDCDA184D0A6E00C21E48 /* CCGroupCommand.cpp */; }; 593BDCF7184D0A6E00C21E48 /* CCGroupCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 593BDCDA184D0A6E00C21E48 /* CCGroupCommand.cpp */; }; 593BDCF8184D0A6E00C21E48 /* CCGroupCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 593BDCDB184D0A6E00C21E48 /* CCGroupCommand.h */; }; 593BDCF9184D0A6E00C21E48 /* CCGroupCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 593BDCDB184D0A6E00C21E48 /* CCGroupCommand.h */; }; 59A79D511821E26E00F19697 /* CCEventListenerMouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A79D4D1821E26E00F19697 /* CCEventListenerMouse.cpp */; }; 59A79D521821E26E00F19697 /* CCEventListenerMouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A79D4D1821E26E00F19697 /* CCEventListenerMouse.cpp */; }; 59A79D531821E26E00F19697 /* CCEventListenerMouse.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A79D4E1821E26E00F19697 /* CCEventListenerMouse.h */; }; 59A79D541821E26E00F19697 /* CCEventListenerMouse.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A79D4E1821E26E00F19697 /* CCEventListenerMouse.h */; }; 59A79D551821E26E00F19697 /* CCEventMouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A79D4F1821E26E00F19697 /* CCEventMouse.cpp */; }; 59A79D561821E26E00F19697 /* CCEventMouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A79D4F1821E26E00F19697 /* CCEventMouse.cpp */; }; 59A79D571821E26E00F19697 /* CCEventMouse.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A79D501821E26E00F19697 /* CCEventMouse.h */; }; 59A79D581821E26E00F19697 /* CCEventMouse.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A79D501821E26E00F19697 /* CCEventMouse.h */; }; 74AC80E553789C6DE3EC737A /* CCRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC8EB8FE47EED9B30B7106 /* CCRenderer.cpp */; }; 74AC819B780D9EB49CC421AB /* CCRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC8DF0EA49A124E1B11681 /* CCRenderer.h */; }; 74AC81CAB5F3883FCC2A4A5B /* CCQuadCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC8C4AE1EB0FCB287E7396 /* CCQuadCommand.h */; }; 74AC826A592CAE6AACD35DC5 /* CCMaterialManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC853F6B597094730AFB36 /* CCMaterialManager.cpp */; }; 74AC82C9892F007745926C93 /* CCFrustum.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC840F2F17ED6D0163669F /* CCFrustum.h */; }; 74AC83D0193BC28994D683E8 /* CCMaterialManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC853F6B597094730AFB36 /* CCMaterialManager.cpp */; }; 74AC846799FE6F299B410289 /* CCQuadCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC8D28EF93BFF332D3C456 /* CCQuadCommand.cpp */; }; 74AC84A100AF9E826288CE2C /* CCRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC80F6E92FC29EA536D7F8 /* CCRenderCommand.cpp */; }; 74AC84A2F1052B49CA60C2D1 /* CCRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC8DF0EA49A124E1B11681 /* CCRenderer.h */; }; 74AC8573F4F84201C08E5523 /* CCRenderCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC8F4F7D9E52FCB522B647 /* CCRenderCommand.h */; }; 74AC858052DDF289AF7D6309 /* CCFrustum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC80EEB031D67E86B45096 /* CCFrustum.cpp */; }; 74AC8589A38C358F1E472BBD /* CCRenderMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC8CC6504014E3A59C55B2 /* CCRenderMaterial.h */; }; 74AC85BC90D7CF01D652E8C3 /* CCRenderMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC82DE19B10586E1C39974 /* CCRenderMaterial.cpp */; }; 74AC8796ABB6761790CF8CC2 /* CCRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC8EB8FE47EED9B30B7106 /* CCRenderer.cpp */; }; 74AC87A5A3B3AD5055CCA3B9 /* CCRenderMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC8CC6504014E3A59C55B2 /* CCRenderMaterial.h */; }; 74AC8813CEE4FC652A0951FB /* CCRenderMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC82DE19B10586E1C39974 /* CCRenderMaterial.cpp */; }; 74AC897DFAB8043D3873A8F3 /* CCRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC80F6E92FC29EA536D7F8 /* CCRenderCommand.cpp */; }; 74AC8A10DE9DE8E14D8B3735 /* CCMaterialManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC800F4905C8827A44EED3 /* CCMaterialManager.h */; }; 74AC8AE45B093F2F76A5B1C2 /* CCQuadCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC8C4AE1EB0FCB287E7396 /* CCQuadCommand.h */; }; 74AC8C8DDFD05322513C8C72 /* CCFrustum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC80EEB031D67E86B45096 /* CCFrustum.cpp */; }; 74AC8CF1E05EA89BC441EEBC /* CCQuadCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 74AC8D28EF93BFF332D3C456 /* CCQuadCommand.cpp */; }; 74AC8E2CDB69E1FDBFCFBD78 /* CCRenderCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC8F4F7D9E52FCB522B647 /* CCRenderCommand.h */; }; 74AC8E3E7D85FB595242AAEC /* CCMaterialManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC800F4905C8827A44EED3 /* CCMaterialManager.h */; }; 74AC8EE0C2AAB82783F47089 /* CCFrustum.h in Headers */ = {isa = PBXBuildFile; fileRef = 74AC840F2F17ED6D0163669F /* CCFrustum.h */; }; A023FA34185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; A023FA35185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; A023FA36185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; A023FA37185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; A04583F2189053B500E32FE8 /* CCEGLView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A04583F0189053B500E32FE8 /* CCEGLView.cpp */; }; A04583F3189053B500E32FE8 /* CCEGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = A04583F1189053B500E32FE8 /* CCEGLView.h */; }; A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; }; A0E6B28018613EA5009C5D17 /* CCRenderCommandPool.h in Headers */ = {isa = PBXBuildFile; fileRef = A0E6B27F18613EA5009C5D17 /* CCRenderCommandPool.h */; }; A0E6B28118613EA5009C5D17 /* CCRenderCommandPool.h in Headers */ = {isa = PBXBuildFile; fileRef = A0E6B27F18613EA5009C5D17 /* CCRenderCommandPool.h */; }; B362C3AE1872BAB700F0BDF4 /* lua_cocos2dx_physics_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B362C3A21872B37200F0BDF4 /* lua_cocos2dx_physics_auto.cpp */; }; B362C3AF1872BAB700F0BDF4 /* lua_cocos2dx_physics_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = B362C3A31872B37200F0BDF4 /* lua_cocos2dx_physics_auto.hpp */; }; B362C3B01872BABC00F0BDF4 /* lua_cocos2dx_physics_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B362C3A21872B37200F0BDF4 /* lua_cocos2dx_physics_auto.cpp */; }; B362C3B11872BABC00F0BDF4 /* lua_cocos2dx_physics_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = B362C3A31872B37200F0BDF4 /* lua_cocos2dx_physics_auto.hpp */; }; B362C3B21872BADC00F0BDF4 /* lua_cocos2dx_physics_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B362C3A41872B4E900F0BDF4 /* lua_cocos2dx_physics_manual.cpp */; }; B362C3B31872BADC00F0BDF4 /* lua_cocos2dx_physics_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = B362C3A51872B4E900F0BDF4 /* lua_cocos2dx_physics_manual.hpp */; }; B362C3B41872BADF00F0BDF4 /* lua_cocos2dx_physics_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B362C3A41872B4E900F0BDF4 /* lua_cocos2dx_physics_manual.cpp */; }; B362C3B51872BADF00F0BDF4 /* lua_cocos2dx_physics_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = B362C3A51872B4E900F0BDF4 /* lua_cocos2dx_physics_manual.hpp */; }; B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */; }; B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */; }; B37510731823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */; }; B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */; }; B37510751823AC9F00B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */; }; B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */; }; B37510771823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */; }; B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */; }; B37510791823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */; }; B375107A1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */; }; B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */; }; B375107C1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */; }; B375107D1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */; }; B375107E1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */; }; B375107F1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */; }; B37510801823ACA100B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */; }; B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */; }; B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */; }; B37510831823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */; }; B37510841823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */; }; B37510851823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */; }; B37510861823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */; }; B3AF01A01842FBA400A98B85 /* b2MotorJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B3AF019E1842FBA400A98B85 /* b2MotorJoint.cpp */; }; B3AF01A11842FBA400A98B85 /* b2MotorJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B3AF019E1842FBA400A98B85 /* b2MotorJoint.cpp */; }; B3AF01A21842FBA400A98B85 /* b2MotorJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */; }; B3AF01A31842FBA400A98B85 /* b2MotorJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */; }; B3B12A5A17E7F44000026B4A /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A03F2CB81780BD04006731B9 /* libchipmunk Mac.a */; }; B3B12A5B17E7F45C00026B4A /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A4F3B178387670073F6A7 /* libchipmunk iOS.a */; }; ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; }; ED9C6A9718599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 1A6FB4FE17854AD600CDF010 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = 1A119716178526AA00D62A44; remoteInfo = "luabindings iOS"; }; 1A6FB7E61785683A00CDF010 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = 1A6FB50417854BC200CDF010; remoteInfo = "luabindings Mac"; }; 460E44F31807E241000CDD6D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 46A173D21807D330005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; A03F2E92178141D1006731B9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = cocos2dx; }; A03F2E94178141D1006731B9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = chipmunk; }; A03F2E96178141D1006731B9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A03F2D5D1780BDF7006731B9; remoteInfo = box2d; }; A03F2FBF1781458C006731B9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = CocosDenshion; }; A03F31FE178147CB006731B9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions"; }; A03F3200178147CB006731B9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A03F31E81781479B006731B9; remoteInfo = jsbindings; }; A07A4E0F178386520073F6A7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; A07A5046178389710073F6A7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; A07A5048178389710073F6A7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; A07A504A178389710073F6A7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A07A4F3C1783876B0073F6A7; remoteInfo = "box2d iOS"; }; A07A504C178389710073F6A7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; A07A504E178389710073F6A7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1551A336158F2AB200E66CFE /* Project object */; proxyType = 1; remoteGlobalIDString = A07A4FB5178387750073F6A7; remoteInfo = "jsbindings iOS"; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFactory.cpp; sourceTree = ""; }; 06CAAABB186AD63B0012A414 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectFactory.h; sourceTree = ""; }; 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerBase.cpp; sourceTree = ""; }; 06CAAABD186AD63B0012A414 /* TriggerBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerBase.h; sourceTree = ""; }; 06CAAABE186AD63B0012A414 /* TriggerMng.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerMng.cpp; sourceTree = ""; }; 06CAAABF186AD63B0012A414 /* TriggerMng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerMng.h; sourceTree = ""; }; 06CAAAC0186AD63B0012A414 /* TriggerObj.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerObj.cpp; sourceTree = ""; }; 06CAAAC1186AD63B0012A414 /* TriggerObj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerObj.h; sourceTree = ""; }; 1551A33F158F2AB200E66CFE /* libcocos2dx Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2dx Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 1551A342158F2AB200E66CFE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 1585AB591828D74F00000FB5 /* lua_cocos2dx_studio_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_studio_auto.cpp; sourceTree = ""; }; 1585AB5A1828D74F00000FB5 /* lua_cocos2dx_studio_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_studio_auto.hpp; sourceTree = ""; }; 158E06DC181F6796008E01F6 /* lua_xml_http_request.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_xml_http_request.cpp; sourceTree = ""; }; 158E06DD181F6796008E01F6 /* lua_xml_http_request.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_xml_http_request.h; sourceTree = ""; }; 1599607A1811329600C7D42C /* libluajit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libluajit.a; path = ../external/lua/luajit/prebuilt/mac/libluajit.a; sourceTree = ""; }; 1599607F181132DE00C7D42C /* libluajit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libluajit.a; path = ../external/lua/luajit/prebuilt/ios/libluajit.a; sourceTree = ""; }; 15A71D3C18921E6900F30AC0 /* auxiliar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = auxiliar.c; sourceTree = ""; }; 15A71D3D18921E6900F30AC0 /* auxiliar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = auxiliar.h; sourceTree = ""; }; 15A71D3E18921E6900F30AC0 /* except.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = except.c; sourceTree = ""; }; 15A71D3F18921E6900F30AC0 /* except.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = except.h; sourceTree = ""; }; 15A71D4018921E6900F30AC0 /* inet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = inet.c; sourceTree = ""; }; 15A71D4118921E6900F30AC0 /* inet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inet.h; sourceTree = ""; }; 15A71D4218921E6900F30AC0 /* luasocket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = luasocket.c; sourceTree = ""; }; 15A71D4318921E6900F30AC0 /* luasocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = luasocket.h; sourceTree = ""; }; 15A71D4418921E6900F30AC0 /* luasocket_buffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = luasocket_buffer.c; sourceTree = ""; }; 15A71D4518921E6900F30AC0 /* luasocket_buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = luasocket_buffer.h; sourceTree = ""; }; 15A71D4618921E6900F30AC0 /* luasocket_io.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = luasocket_io.c; sourceTree = ""; }; 15A71D4718921E6900F30AC0 /* luasocket_io.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = luasocket_io.h; sourceTree = ""; }; 15A71D4818921E6900F30AC0 /* mime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mime.c; sourceTree = ""; }; 15A71D4918921E6900F30AC0 /* mime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mime.h; sourceTree = ""; }; 15A71D4A18921E6900F30AC0 /* options.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = options.c; sourceTree = ""; }; 15A71D4B18921E6900F30AC0 /* options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = options.h; sourceTree = ""; }; 15A71D4C18921E6900F30AC0 /* select.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = select.c; sourceTree = ""; }; 15A71D4D18921E6900F30AC0 /* select.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = select.h; sourceTree = ""; }; 15A71D4E18921E6900F30AC0 /* serial.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = serial.c; sourceTree = ""; }; 15A71D4F18921E6900F30AC0 /* socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = socket.h; sourceTree = ""; }; 15A71D5018921E6900F30AC0 /* socket_scripts.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = socket_scripts.c; sourceTree = ""; }; 15A71D5118921E6900F30AC0 /* socket_scripts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = socket_scripts.h; sourceTree = ""; }; 15A71D5218921E6900F30AC0 /* tcp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tcp.c; sourceTree = ""; }; 15A71D5318921E6900F30AC0 /* tcp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tcp.h; sourceTree = ""; }; 15A71D5418921E6900F30AC0 /* timeout.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = timeout.c; sourceTree = ""; }; 15A71D5518921E6900F30AC0 /* timeout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = timeout.h; sourceTree = ""; }; 15A71D5618921E6900F30AC0 /* udp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = udp.c; sourceTree = ""; }; 15A71D5718921E6900F30AC0 /* udp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = udp.h; sourceTree = ""; }; 15A71D5818921E6900F30AC0 /* unix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = unix.c; sourceTree = ""; }; 15A71D5918921E6900F30AC0 /* unix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unix.h; sourceTree = ""; }; 15A71D5A18921E6900F30AC0 /* usocket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = usocket.c; sourceTree = ""; }; 15A71D5B18921E6900F30AC0 /* usocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = usocket.h; sourceTree = ""; }; 15A71D5D18921E6900F30AC0 /* wsocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wsocket.h; sourceTree = ""; }; 15A71DA21892291500F30AC0 /* lua_extensions.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lua_extensions.c; sourceTree = ""; }; 15A71DA31892291500F30AC0 /* lua_extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_extensions.h; sourceTree = ""; }; 15CA8D0B18697A56000032AB /* lua_cocos2dx_spine_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_spine_manual.cpp; sourceTree = ""; }; 15CA8D0C18697A56000032AB /* lua_cocos2dx_spine_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_spine_manual.hpp; sourceTree = ""; }; 15CA8D1118697AE1000032AB /* lua_cocos2dx_spine_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_spine_auto.cpp; sourceTree = ""; }; 15CA8D1218697AE1000032AB /* lua_cocos2dx_spine_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_spine_auto.hpp; sourceTree = ""; }; 15CA8D1718697BE5000032AB /* LuaSkeletonAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaSkeletonAnimation.cpp; sourceTree = ""; }; 15CA8D1818697BE5000032AB /* LuaSkeletonAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaSkeletonAnimation.h; sourceTree = ""; }; 15D6E843182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_coco_studio_manual.cpp; sourceTree = ""; }; 15D6E844182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_coco_studio_manual.hpp; sourceTree = ""; }; 15F4C8801875637D0082884F /* lua_cocos2dx_gui_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_gui_auto.cpp; sourceTree = ""; }; 15F4C8811875637D0082884F /* lua_cocos2dx_gui_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_gui_auto.hpp; sourceTree = ""; }; 15F4CA1D1875885A0082884F /* lua_cocos2dx_gui_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_gui_manual.cpp; sourceTree = ""; }; 15F4CA1E1875885A0082884F /* lua_cocos2dx_gui_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_gui_manual.hpp; sourceTree = ""; }; 1A087AE61860400400196EF5 /* edtaa3func.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = edtaa3func.cpp; sourceTree = ""; }; 1A087AE71860400400196EF5 /* edtaa3func.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = edtaa3func.h; sourceTree = ""; }; 1A0DB7301823827C0025743D /* CCGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGL.h; sourceTree = ""; }; 1A0DB7311823827C0025743D /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = ""; }; 1A0DB7351823828F0025743D /* CCGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGL.h; sourceTree = ""; }; 1A119791178526AA00D62A44 /* libluabindings iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libluabindings iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 1A2C785E181A11EC004E5527 /* jsb_cocos2dx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_auto.cpp; sourceTree = ""; }; 1A2C785F181A11EC004E5527 /* jsb_cocos2dx_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_auto.hpp; sourceTree = ""; }; 1A2C7861181A11EC004E5527 /* jsb_cocos2dx_builder_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_builder_auto.cpp; sourceTree = ""; }; 1A2C7862181A11EC004E5527 /* jsb_cocos2dx_builder_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_builder_auto.hpp; sourceTree = ""; }; 1A2C7864181A11EC004E5527 /* jsb_cocos2dx_extension_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_extension_auto.cpp; sourceTree = ""; }; 1A2C7865181A11EC004E5527 /* jsb_cocos2dx_extension_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_extension_auto.hpp; sourceTree = ""; }; 1A2C7867181A11EC004E5527 /* jsb_cocos2dx_studio_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_studio_auto.cpp; sourceTree = ""; }; 1A2C7868181A11EC004E5527 /* jsb_cocos2dx_studio_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_studio_auto.hpp; sourceTree = ""; }; 1A2C786B181A11EC004E5527 /* lua_cocos2dx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_auto.cpp; sourceTree = ""; }; 1A2C786C181A11EC004E5527 /* lua_cocos2dx_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_auto.hpp; sourceTree = ""; }; 1A2C786E181A11EC004E5527 /* lua_cocos2dx_extension_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_extension_auto.cpp; sourceTree = ""; }; 1A2C786F181A11EC004E5527 /* lua_cocos2dx_extension_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_extension_auto.hpp; sourceTree = ""; }; 1A2C7871181A11EC004E5527 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = ""; }; 1A2C78BE181A1257004E5527 /* js_bindings_chipmunk_auto_classes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_auto_classes.cpp; sourceTree = ""; }; 1A2C78BF181A1257004E5527 /* js_bindings_chipmunk_auto_classes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_auto_classes.h; sourceTree = ""; }; 1A2C78C0181A1257004E5527 /* js_bindings_chipmunk_auto_classes_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_auto_classes_registration.h; sourceTree = ""; }; 1A2C78C1181A1257004E5527 /* js_bindings_chipmunk_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_functions.cpp; sourceTree = ""; }; 1A2C78C2181A1257004E5527 /* js_bindings_chipmunk_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_functions.h; sourceTree = ""; }; 1A2C78C3181A1257004E5527 /* js_bindings_chipmunk_functions_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_functions_registration.h; sourceTree = ""; }; 1A2C78C4181A1257004E5527 /* js_bindings_chipmunk_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_manual.cpp; sourceTree = ""; }; 1A2C78C5181A1257004E5527 /* js_bindings_chipmunk_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_manual.h; sourceTree = ""; }; 1A2C78C6181A1257004E5527 /* js_bindings_chipmunk_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_registration.cpp; sourceTree = ""; }; 1A2C78C7181A1257004E5527 /* js_bindings_chipmunk_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_registration.h; sourceTree = ""; }; 1A2C78CB181A1257004E5527 /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_specifics.cpp; sourceTree = ""; }; 1A2C78CC181A1257004E5527 /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_specifics.hpp; sourceTree = ""; }; 1A2C78CF181A1257004E5527 /* cocosbuilder_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocosbuilder_specifics.hpp; sourceTree = ""; }; 1A2C78D0181A1257004E5527 /* js_bindings_ccbreader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_ccbreader.cpp; sourceTree = ""; }; 1A2C78D1181A1257004E5527 /* js_bindings_ccbreader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_ccbreader.h; sourceTree = ""; }; 1A2C78D9181A1257004E5527 /* jsb_cocos2dx_studio_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_studio_manual.cpp; sourceTree = ""; }; 1A2C78DA181A1257004E5527 /* jsb_cocos2dx_studio_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_studio_manual.h; sourceTree = ""; }; 1A2C78E0181A1257004E5527 /* jsb_cocos2dx_extension_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_extension_manual.cpp; sourceTree = ""; }; 1A2C78E1181A1257004E5527 /* jsb_cocos2dx_extension_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_extension_manual.h; sourceTree = ""; }; 1A2C78E5181A1257004E5527 /* js_bindings_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_config.h; sourceTree = ""; }; 1A2C78E6181A1257004E5527 /* js_bindings_core.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_core.cpp; sourceTree = ""; }; 1A2C78E7181A1257004E5527 /* js_bindings_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_core.h; sourceTree = ""; }; 1A2C78E8181A1257004E5527 /* js_bindings_opengl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_opengl.cpp; sourceTree = ""; }; 1A2C78E9181A1257004E5527 /* js_bindings_opengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_opengl.h; sourceTree = ""; }; 1A2C78EA181A1257004E5527 /* js_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_manual_conversions.cpp; sourceTree = ""; }; 1A2C78EB181A1257004E5527 /* js_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_manual_conversions.h; sourceTree = ""; }; 1A2C78EC181A1257004E5527 /* jsb_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_helper.h; sourceTree = ""; }; 1A2C78ED181A1257004E5527 /* jsb_opengl_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_functions.cpp; sourceTree = ""; }; 1A2C78EE181A1257004E5527 /* jsb_opengl_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_opengl_functions.h; sourceTree = ""; }; 1A2C78EF181A1257004E5527 /* jsb_opengl_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_manual.cpp; sourceTree = ""; }; 1A2C78F0181A1257004E5527 /* jsb_opengl_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_opengl_manual.h; sourceTree = ""; }; 1A2C78F1181A1257004E5527 /* jsb_opengl_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_registration.cpp; sourceTree = ""; }; 1A2C78F2181A1257004E5527 /* jsb_opengl_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_opengl_registration.h; sourceTree = ""; }; 1A2C78F5181A1257004E5527 /* js_bindings_system_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_system_functions.cpp; sourceTree = ""; }; 1A2C78F6181A1257004E5527 /* js_bindings_system_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_system_functions.h; sourceTree = ""; }; 1A2C78F7181A1257004E5527 /* js_bindings_system_functions_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_system_functions_registration.h; sourceTree = ""; }; 1A2C78F8181A1257004E5527 /* js_bindings_system_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_system_registration.cpp; sourceTree = ""; }; 1A2C78F9181A1257004E5527 /* js_bindings_system_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_system_registration.h; sourceTree = ""; }; 1A2C78FF181A1257004E5527 /* jsb_websocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_websocket.cpp; sourceTree = ""; }; 1A2C7900181A1257004E5527 /* jsb_websocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_websocket.h; sourceTree = ""; }; 1A2C7904181A1257004E5527 /* XMLHTTPRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHTTPRequest.cpp; sourceTree = ""; }; 1A2C7905181A1257004E5527 /* XMLHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHTTPRequest.h; sourceTree = ""; }; 1A2C790A181A1257004E5527 /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptingCore.cpp; sourceTree = ""; }; 1A2C790B181A1257004E5527 /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptingCore.h; sourceTree = ""; }; 1A2C790C181A1257004E5527 /* spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spidermonkey_specifics.h; sourceTree = ""; }; 1A3B1F4E180E88C200497A22 /* CCBProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBProxy.cpp; sourceTree = ""; }; 1A3B1F4F180E88C200497A22 /* CCBProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBProxy.h; sourceTree = ""; }; 1A3B1F50180E88C200497A22 /* CCLuaBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLuaBridge.cpp; sourceTree = ""; }; 1A3B1F51180E88C200497A22 /* CCLuaBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLuaBridge.h; sourceTree = ""; }; 1A3B1F52180E88C200497A22 /* CCLuaEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLuaEngine.cpp; sourceTree = ""; }; 1A3B1F53180E88C200497A22 /* CCLuaEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLuaEngine.h; sourceTree = ""; }; 1A3B1F54180E88C200497A22 /* CCLuaStack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLuaStack.cpp; sourceTree = ""; }; 1A3B1F55180E88C200497A22 /* CCLuaStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLuaStack.h; sourceTree = ""; }; 1A3B1F56180E88C300497A22 /* CCLuaValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLuaValue.cpp; sourceTree = ""; }; 1A3B1F57180E88C300497A22 /* CCLuaValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLuaValue.h; sourceTree = ""; }; 1A3B1F58180E88C300497A22 /* Cocos2dxLuaLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cocos2dxLuaLoader.cpp; sourceTree = ""; }; 1A3B1F59180E88C300497A22 /* Cocos2dxLuaLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cocos2dxLuaLoader.h; sourceTree = ""; }; 1A3B1F5D180E88C300497A22 /* lua_cocos2dx_deprecated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_deprecated.cpp; sourceTree = ""; }; 1A3B1F5E180E88C300497A22 /* lua_cocos2dx_deprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_cocos2dx_deprecated.h; sourceTree = ""; }; 1A3B1F5F180E88C300497A22 /* lua_cocos2dx_extension_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_extension_manual.cpp; sourceTree = ""; }; 1A3B1F60180E88C300497A22 /* lua_cocos2dx_extension_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_cocos2dx_extension_manual.h; sourceTree = ""; }; 1A3B1F61180E88C300497A22 /* lua_cocos2dx_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_manual.cpp; sourceTree = ""; }; 1A3B1F62180E88C300497A22 /* lua_cocos2dx_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_manual.hpp; sourceTree = ""; }; 1A3B1F63180E88C300497A22 /* Lua_web_socket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lua_web_socket.cpp; sourceTree = ""; }; 1A3B1F64180E88C300497A22 /* Lua_web_socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lua_web_socket.h; sourceTree = ""; }; 1A3B1F65180E88C300497A22 /* LuaBasicConversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaBasicConversions.cpp; sourceTree = ""; }; 1A3B1F66180E88C300497A22 /* LuaBasicConversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaBasicConversions.h; sourceTree = ""; }; 1A3B1F67180E88C300497A22 /* LuaOpengl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaOpengl.cpp; sourceTree = ""; }; 1A3B1F68180E88C300497A22 /* LuaOpengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaOpengl.h; sourceTree = ""; }; 1A3B1F69180E88C300497A22 /* LuaScriptHandlerMgr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaScriptHandlerMgr.cpp; sourceTree = ""; }; 1A3B1F6A180E88C300497A22 /* LuaScriptHandlerMgr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaScriptHandlerMgr.h; sourceTree = ""; }; 1A3B1F74180E88C300497A22 /* CCLuaObjcBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLuaObjcBridge.h; sourceTree = ""; }; 1A3B1F75180E88C300497A22 /* CCLuaObjcBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCLuaObjcBridge.mm; sourceTree = ""; }; 1A3B1F76180E88C300497A22 /* tolua_fix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_fix.c; sourceTree = ""; }; 1A3B1F77180E88C300497A22 /* tolua_fix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tolua_fix.h; sourceTree = ""; }; 1A570047180BC5A10088DEC7 /* CCAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAction.cpp; sourceTree = ""; }; 1A570048180BC5A10088DEC7 /* CCAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAction.h; sourceTree = ""; }; 1A570049180BC5A10088DEC7 /* CCActionCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionCamera.cpp; sourceTree = ""; }; 1A57004A180BC5A10088DEC7 /* CCActionCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionCamera.h; sourceTree = ""; }; 1A57004B180BC5A10088DEC7 /* CCActionCatmullRom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionCatmullRom.cpp; sourceTree = ""; }; 1A57004C180BC5A10088DEC7 /* CCActionCatmullRom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionCatmullRom.h; sourceTree = ""; }; 1A57004D180BC5A10088DEC7 /* CCActionEase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionEase.cpp; sourceTree = ""; }; 1A57004E180BC5A10088DEC7 /* CCActionEase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionEase.h; sourceTree = ""; }; 1A57004F180BC5A10088DEC7 /* CCActionGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionGrid.cpp; sourceTree = ""; }; 1A570050180BC5A10088DEC7 /* CCActionGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionGrid.h; sourceTree = ""; }; 1A570051180BC5A10088DEC7 /* CCActionGrid3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionGrid3D.cpp; sourceTree = ""; }; 1A570052180BC5A10088DEC7 /* CCActionGrid3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionGrid3D.h; sourceTree = ""; }; 1A570053180BC5A10088DEC7 /* CCActionInstant.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionInstant.cpp; sourceTree = ""; }; 1A570054180BC5A10088DEC7 /* CCActionInstant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionInstant.h; sourceTree = ""; }; 1A570055180BC5A10088DEC7 /* CCActionInterval.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionInterval.cpp; sourceTree = ""; }; 1A570056180BC5A10088DEC7 /* CCActionInterval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionInterval.h; sourceTree = ""; }; 1A570057180BC5A10088DEC7 /* CCActionManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionManager.cpp; sourceTree = ""; }; 1A570058180BC5A10088DEC7 /* CCActionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionManager.h; sourceTree = ""; }; 1A570059180BC5A10088DEC7 /* CCActionPageTurn3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionPageTurn3D.cpp; sourceTree = ""; }; 1A57005A180BC5A10088DEC7 /* CCActionPageTurn3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionPageTurn3D.h; sourceTree = ""; }; 1A57005B180BC5A10088DEC7 /* CCActionProgressTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionProgressTimer.cpp; sourceTree = ""; }; 1A57005C180BC5A10088DEC7 /* CCActionProgressTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionProgressTimer.h; sourceTree = ""; }; 1A57005D180BC5A10088DEC7 /* CCActionTiledGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTiledGrid.cpp; sourceTree = ""; }; 1A57005E180BC5A10088DEC7 /* CCActionTiledGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTiledGrid.h; sourceTree = ""; }; 1A57005F180BC5A10088DEC7 /* CCActionTween.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTween.cpp; sourceTree = ""; }; 1A570060180BC5A10088DEC7 /* CCActionTween.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTween.h; sourceTree = ""; }; 1A570096180BC5C10088DEC7 /* CCAtlasNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAtlasNode.cpp; sourceTree = ""; }; 1A570097180BC5C10088DEC7 /* CCAtlasNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAtlasNode.h; sourceTree = ""; }; 1A57009C180BC5D20088DEC7 /* CCNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNode.cpp; sourceTree = ""; }; 1A57009D180BC5D20088DEC7 /* CCNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNode.h; sourceTree = ""; }; 1A5700A3180BC6060088DEC7 /* atitc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = atitc.cpp; path = ../base/atitc.cpp; sourceTree = ""; }; 1A5700A4180BC6060088DEC7 /* atitc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atitc.h; path = ../base/atitc.h; sourceTree = ""; }; 1A5700A5180BC6060088DEC7 /* CCAffineTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCAffineTransform.cpp; path = ../base/CCAffineTransform.cpp; sourceTree = ""; }; 1A5700A6180BC6060088DEC7 /* CCAffineTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCAffineTransform.h; path = ../base/CCAffineTransform.h; sourceTree = ""; }; 1A5700A7180BC6060088DEC7 /* CCArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCArray.cpp; path = ../base/CCArray.cpp; sourceTree = ""; }; 1A5700A8180BC6060088DEC7 /* CCArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCArray.h; path = ../base/CCArray.h; sourceTree = ""; }; 1A5700A9180BC6060088DEC7 /* CCAutoreleasePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCAutoreleasePool.cpp; path = ../base/CCAutoreleasePool.cpp; sourceTree = ""; }; 1A5700AA180BC6060088DEC7 /* CCAutoreleasePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCAutoreleasePool.h; path = ../base/CCAutoreleasePool.h; sourceTree = ""; }; 1A5700AB180BC6060088DEC7 /* CCBool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCBool.h; path = ../base/CCBool.h; sourceTree = ""; }; 1A5700AC180BC6060088DEC7 /* CCData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCData.cpp; path = ../base/CCData.cpp; sourceTree = ""; }; 1A5700AD180BC6060088DEC7 /* CCData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCData.h; path = ../base/CCData.h; sourceTree = ""; }; 1A5700AE180BC6060088DEC7 /* CCDataVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCDataVisitor.cpp; path = ../base/CCDataVisitor.cpp; sourceTree = ""; }; 1A5700AF180BC6060088DEC7 /* CCDataVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCDataVisitor.h; path = ../base/CCDataVisitor.h; sourceTree = ""; }; 1A5700B0180BC6060088DEC7 /* CCDictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCDictionary.cpp; path = ../base/CCDictionary.cpp; sourceTree = ""; }; 1A5700B1180BC6060088DEC7 /* CCDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCDictionary.h; path = ../base/CCDictionary.h; sourceTree = ""; }; 1A5700B2180BC6060088DEC7 /* CCDouble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCDouble.h; path = ../base/CCDouble.h; sourceTree = ""; }; 1A5700B3180BC6060088DEC7 /* CCFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCFloat.h; path = ../base/CCFloat.h; sourceTree = ""; }; 1A5700B4180BC6060088DEC7 /* CCGeometry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCGeometry.cpp; path = ../base/CCGeometry.cpp; sourceTree = ""; }; 1A5700B5180BC6060088DEC7 /* CCGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGeometry.h; path = ../base/CCGeometry.h; sourceTree = ""; }; 1A5700B6180BC6060088DEC7 /* CCInteger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCInteger.h; path = ../base/CCInteger.h; sourceTree = ""; }; 1A5700B7180BC6060088DEC7 /* CCNS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCNS.cpp; path = ../base/CCNS.cpp; sourceTree = ""; }; 1A5700B8180BC6060088DEC7 /* CCNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCNS.h; path = ../base/CCNS.h; sourceTree = ""; }; 1A5700B9180BC6060088DEC7 /* CCObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCObject.cpp; path = ../base/CCObject.cpp; sourceTree = ""; }; 1A5700BA180BC6060088DEC7 /* CCObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCObject.h; path = ../base/CCObject.h; sourceTree = ""; }; 1A5700BB180BC6060088DEC7 /* CCPlatformConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPlatformConfig.h; path = ../base/CCPlatformConfig.h; sourceTree = ""; }; 1A5700BC180BC6060088DEC7 /* CCPlatformMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPlatformMacros.h; path = ../base/CCPlatformMacros.h; sourceTree = ""; }; 1A5700BD180BC6060088DEC7 /* CCSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCSet.cpp; path = ../base/CCSet.cpp; sourceTree = ""; }; 1A5700BE180BC6060088DEC7 /* CCSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCSet.h; path = ../base/CCSet.h; sourceTree = ""; }; 1A5700BF180BC6060088DEC7 /* CCString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCString.cpp; path = ../base/CCString.cpp; sourceTree = ""; }; 1A5700C0180BC6060088DEC7 /* CCString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCString.h; path = ../base/CCString.h; sourceTree = ""; }; 1A5700C1180BC6060088DEC7 /* etc1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = etc1.cpp; path = ../base/etc1.cpp; sourceTree = ""; }; 1A5700C2180BC6060088DEC7 /* etc1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = etc1.h; path = ../base/etc1.h; sourceTree = ""; }; 1A5700C3180BC6060088DEC7 /* s3tc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = s3tc.cpp; path = ../base/s3tc.cpp; sourceTree = ""; }; 1A5700C4180BC6060088DEC7 /* s3tc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = s3tc.h; path = ../base/s3tc.h; sourceTree = ""; }; 1A57010A180BC8ED0088DEC7 /* CCDrawingPrimitives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDrawingPrimitives.cpp; sourceTree = ""; }; 1A57010B180BC8EE0088DEC7 /* CCDrawingPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDrawingPrimitives.h; sourceTree = ""; }; 1A57010C180BC8EE0088DEC7 /* CCDrawNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCDrawNode.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A57010D180BC8EE0088DEC7 /* CCDrawNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDrawNode.h; sourceTree = ""; }; 1A570117180BC90D0088DEC7 /* CCGrabber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGrabber.cpp; sourceTree = ""; }; 1A570118180BC90D0088DEC7 /* CCGrabber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGrabber.h; sourceTree = ""; }; 1A570119180BC90D0088DEC7 /* CCGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGrid.cpp; sourceTree = ""; }; 1A57011A180BC90D0088DEC7 /* CCGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGrid.h; sourceTree = ""; }; 1A570124180BC9460088DEC7 /* CCEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEvent.cpp; sourceTree = ""; }; 1A570125180BC9460088DEC7 /* CCEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEvent.h; sourceTree = ""; }; 1A570126180BC9460088DEC7 /* CCEventAcceleration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventAcceleration.cpp; sourceTree = ""; }; 1A570127180BC9460088DEC7 /* CCEventAcceleration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventAcceleration.h; sourceTree = ""; }; 1A570128180BC9460088DEC7 /* CCEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventCustom.cpp; sourceTree = ""; }; 1A570129180BC9460088DEC7 /* CCEventCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventCustom.h; sourceTree = ""; }; 1A57012A180BC9460088DEC7 /* CCEventDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventDispatcher.cpp; sourceTree = ""; }; 1A57012B180BC9460088DEC7 /* CCEventDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventDispatcher.h; sourceTree = ""; }; 1A57012C180BC9460088DEC7 /* CCEventKeyboard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventKeyboard.cpp; sourceTree = ""; }; 1A57012D180BC9460088DEC7 /* CCEventKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventKeyboard.h; sourceTree = ""; }; 1A57012E180BC9460088DEC7 /* CCEventListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventListener.cpp; sourceTree = ""; }; 1A57012F180BC9460088DEC7 /* CCEventListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventListener.h; sourceTree = ""; }; 1A570130180BC9460088DEC7 /* CCEventListenerAcceleration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventListenerAcceleration.cpp; sourceTree = ""; }; 1A570131180BC9460088DEC7 /* CCEventListenerAcceleration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventListenerAcceleration.h; sourceTree = ""; }; 1A570132180BC9460088DEC7 /* CCEventListenerCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventListenerCustom.cpp; sourceTree = ""; }; 1A570133180BC9460088DEC7 /* CCEventListenerCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventListenerCustom.h; sourceTree = ""; }; 1A570134180BC9460088DEC7 /* CCEventListenerKeyboard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventListenerKeyboard.cpp; sourceTree = ""; }; 1A570135180BC9460088DEC7 /* CCEventListenerKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventListenerKeyboard.h; sourceTree = ""; }; 1A570136180BC9460088DEC7 /* CCEventListenerTouch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventListenerTouch.cpp; sourceTree = ""; }; 1A570137180BC9460088DEC7 /* CCEventListenerTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventListenerTouch.h; sourceTree = ""; }; 1A570138180BC9460088DEC7 /* CCEventTouch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventTouch.cpp; sourceTree = ""; }; 1A570139180BC9460088DEC7 /* CCEventTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventTouch.h; sourceTree = ""; }; 1A570182180BCB590088DEC7 /* CCFont.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFont.cpp; sourceTree = ""; }; 1A570183180BCB590088DEC7 /* CCFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFont.h; sourceTree = ""; }; 1A570184180BCB590088DEC7 /* CCFontAtlas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFontAtlas.cpp; sourceTree = ""; }; 1A570185180BCB590088DEC7 /* CCFontAtlas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFontAtlas.h; sourceTree = ""; }; 1A570186180BCB590088DEC7 /* CCFontAtlasCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFontAtlasCache.cpp; sourceTree = ""; }; 1A570187180BCB590088DEC7 /* CCFontAtlasCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFontAtlasCache.h; sourceTree = ""; }; 1A57018C180BCB590088DEC7 /* CCFontFNT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFontFNT.cpp; sourceTree = ""; }; 1A57018D180BCB590088DEC7 /* CCFontFNT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFontFNT.h; sourceTree = ""; }; 1A57018E180BCB590088DEC7 /* CCFontFreeType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFontFreeType.cpp; sourceTree = ""; }; 1A57018F180BCB590088DEC7 /* CCFontFreeType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFontFreeType.h; sourceTree = ""; }; 1A570190180BCB590088DEC7 /* CCLabel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCLabel.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570191180BCB590088DEC7 /* CCLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabel.h; sourceTree = ""; }; 1A570192180BCB590088DEC7 /* CCLabelAtlas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelAtlas.cpp; sourceTree = ""; }; 1A570193180BCB590088DEC7 /* CCLabelAtlas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelAtlas.h; sourceTree = ""; }; 1A570194180BCB590088DEC7 /* CCLabelBMFont.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelBMFont.cpp; sourceTree = ""; }; 1A570195180BCB590088DEC7 /* CCLabelBMFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelBMFont.h; sourceTree = ""; }; 1A570197180BCB590088DEC7 /* CCLabelTextFormatter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelTextFormatter.cpp; sourceTree = ""; }; 1A570198180BCB590088DEC7 /* CCLabelTextFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelTextFormatter.h; sourceTree = ""; }; 1A570199180BCB590088DEC7 /* CCLabelTTF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelTTF.cpp; sourceTree = ""; }; 1A57019A180BCB590088DEC7 /* CCLabelTTF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelTTF.h; sourceTree = ""; }; 1A5701D4180BCB8C0088DEC7 /* CCLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCLayer.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A5701D5180BCB8C0088DEC7 /* CCLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayer.h; sourceTree = ""; }; 1A5701D6180BCB8C0088DEC7 /* CCScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScene.cpp; sourceTree = ""; }; 1A5701D7180BCB8C0088DEC7 /* CCScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScene.h; sourceTree = ""; }; 1A5701D8180BCB8C0088DEC7 /* CCTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTransition.cpp; sourceTree = ""; }; 1A5701D9180BCB8C0088DEC7 /* CCTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTransition.h; sourceTree = ""; }; 1A5701DA180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCTransitionPageTurn.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A5701DB180BCB8C0088DEC7 /* CCTransitionPageTurn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTransitionPageTurn.h; sourceTree = ""; }; 1A5701DC180BCB8C0088DEC7 /* CCTransitionProgress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTransitionProgress.cpp; sourceTree = ""; }; 1A5701DD180BCB8C0088DEC7 /* CCTransitionProgress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTransitionProgress.h; sourceTree = ""; }; 1A5701F3180BCBAD0088DEC7 /* CCMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenu.cpp; sourceTree = ""; }; 1A5701F4180BCBAD0088DEC7 /* CCMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenu.h; sourceTree = ""; }; 1A5701F5180BCBAD0088DEC7 /* CCMenuItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItem.cpp; sourceTree = ""; }; 1A5701F6180BCBAD0088DEC7 /* CCMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItem.h; sourceTree = ""; }; 1A570200180BCBD40088DEC7 /* CCClippingNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCClippingNode.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570201180BCBD40088DEC7 /* CCClippingNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCClippingNode.h; sourceTree = ""; }; 1A570206180BCBDF0088DEC7 /* CCMotionStreak.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCMotionStreak.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570207180BCBDF0088DEC7 /* CCMotionStreak.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMotionStreak.h; sourceTree = ""; }; 1A57020C180BCBF40088DEC7 /* CCProgressTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCProgressTimer.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A57020D180BCBF40088DEC7 /* CCProgressTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProgressTimer.h; sourceTree = ""; }; 1A57020E180BCBF40088DEC7 /* CCRenderTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCRenderTexture.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A57020F180BCBF40088DEC7 /* CCRenderTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRenderTexture.h; sourceTree = ""; }; 1A570219180BCC1A0088DEC7 /* CCParticleBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleBatchNode.cpp; sourceTree = ""; }; 1A57021A180BCC1A0088DEC7 /* CCParticleBatchNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleBatchNode.h; sourceTree = ""; }; 1A57021B180BCC1A0088DEC7 /* CCParticleExamples.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleExamples.cpp; sourceTree = ""; }; 1A57021C180BCC1A0088DEC7 /* CCParticleExamples.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleExamples.h; sourceTree = ""; }; 1A57021D180BCC1A0088DEC7 /* CCParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleSystem.cpp; sourceTree = ""; }; 1A57021E180BCC1A0088DEC7 /* CCParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleSystem.h; sourceTree = ""; }; 1A57021F180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCParticleSystemQuad.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570220180BCC1A0088DEC7 /* CCParticleSystemQuad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleSystemQuad.h; sourceTree = ""; }; 1A570232180BCC4D0088DEC7 /* CCScriptSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScriptSupport.cpp; sourceTree = ""; }; 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScriptSupport.h; sourceTree = ""; }; 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_frag.h; sourceTree = ""; }; 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_vert.h; sourceTree = ""; }; 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_frag.h; sourceTree = ""; }; 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_vert.h; sourceTree = ""; }; 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_frag.h; sourceTree = ""; }; 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_vert.h; sourceTree = ""; }; 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_frag.h; sourceTree = ""; }; 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_frag.h; sourceTree = ""; }; 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_vert.h; sourceTree = ""; }; 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_vert.h; sourceTree = ""; }; 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_frag.h; sourceTree = ""; }; 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_vert.h; sourceTree = ""; }; 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_frag.h; sourceTree = ""; }; 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_vert.h; sourceTree = ""; }; 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColorAlphaTest_frag.h; sourceTree = ""; }; 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderCache.cpp; sourceTree = ""; }; 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShaderCache.h; sourceTree = ""; }; 1A57024A180BCC6F0088DEC7 /* ccShaderEx_SwitchMask_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShaderEx_SwitchMask_frag.h; sourceTree = ""; }; 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccShaders.cpp; sourceTree = ""; }; 1A57024C180BCC6F0088DEC7 /* ccShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShaders.h; sourceTree = ""; }; 1A570276180BCC900088DEC7 /* CCSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCSprite.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570277180BCC900088DEC7 /* CCSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSprite.h; sourceTree = ""; }; 1A570278180BCC900088DEC7 /* CCSpriteBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteBatchNode.cpp; sourceTree = ""; }; 1A570279180BCC900088DEC7 /* CCSpriteBatchNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteBatchNode.h; sourceTree = ""; }; 1A57027A180BCC900088DEC7 /* CCSpriteFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteFrame.cpp; sourceTree = ""; }; 1A57027B180BCC900088DEC7 /* CCSpriteFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteFrame.h; sourceTree = ""; }; 1A57027C180BCC900088DEC7 /* CCSpriteFrameCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteFrameCache.cpp; sourceTree = ""; }; 1A57027D180BCC900088DEC7 /* CCSpriteFrameCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteFrameCache.h; sourceTree = ""; }; 1A57028E180BCCAB0088DEC7 /* CCAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAnimation.cpp; sourceTree = ""; }; 1A57028F180BCCAB0088DEC7 /* CCAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAnimation.h; sourceTree = ""; }; 1A570290180BCCAB0088DEC7 /* CCAnimationCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAnimationCache.cpp; sourceTree = ""; }; 1A570291180BCCAB0088DEC7 /* CCAnimationCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAnimationCache.h; sourceTree = ""; }; 1A57029B180BCD890088DEC7 /* base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = base64.cpp; sourceTree = ""; }; 1A57029C180BCD890088DEC7 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base64.h; sourceTree = ""; }; 1A5702A1180BCD980088DEC7 /* CCNotificationCenter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNotificationCenter.cpp; sourceTree = ""; }; 1A5702A2180BCD980088DEC7 /* CCNotificationCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNotificationCenter.h; sourceTree = ""; }; 1A5702A7180BCDAA0088DEC7 /* CCProfiling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProfiling.cpp; sourceTree = ""; }; 1A5702A8180BCDAA0088DEC7 /* CCProfiling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProfiling.h; sourceTree = ""; }; 1A5702AD180BCDBC0088DEC7 /* ccUTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccUTF8.cpp; sourceTree = ""; }; 1A5702AE180BCDBC0088DEC7 /* ccUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccUTF8.h; sourceTree = ""; }; 1A5702B3180BCDF40088DEC7 /* CCVertex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVertex.cpp; sourceTree = ""; }; 1A5702B4180BCDF40088DEC7 /* CCVertex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVertex.h; sourceTree = ""; }; 1A5702B9180BCDFC0088DEC7 /* ccUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccUtils.h; sourceTree = ""; }; 1A5702BD180BCE2A0088DEC7 /* CCIMEDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCIMEDelegate.h; sourceTree = ""; }; 1A5702BE180BCE2A0088DEC7 /* CCIMEDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCIMEDispatcher.cpp; sourceTree = ""; }; 1A5702BF180BCE2A0088DEC7 /* CCIMEDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCIMEDispatcher.h; sourceTree = ""; }; 1A5702C6180BCE370088DEC7 /* CCTextFieldTTF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTextFieldTTF.cpp; sourceTree = ""; }; 1A5702C7180BCE370088DEC7 /* CCTextFieldTTF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTextFieldTTF.h; sourceTree = ""; }; 1A5702CD180BCE560088DEC7 /* CCTexture2D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTexture2D.cpp; sourceTree = ""; }; 1A5702CE180BCE570088DEC7 /* CCTexture2D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTexture2D.h; sourceTree = ""; }; 1A5702CF180BCE570088DEC7 /* CCTextureAtlas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTextureAtlas.cpp; sourceTree = ""; }; 1A5702D0180BCE570088DEC7 /* CCTextureAtlas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTextureAtlas.h; sourceTree = ""; }; 1A5702D1180BCE570088DEC7 /* CCTextureCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTextureCache.cpp; sourceTree = ""; }; 1A5702D2180BCE570088DEC7 /* CCTextureCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTextureCache.h; sourceTree = ""; }; 1A5702E0180BCE750088DEC7 /* CCTileMapAtlas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTileMapAtlas.cpp; sourceTree = ""; }; 1A5702E1180BCE750088DEC7 /* CCTileMapAtlas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTileMapAtlas.h; sourceTree = ""; }; 1A5702E2180BCE750088DEC7 /* CCTMXLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTMXLayer.cpp; sourceTree = ""; }; 1A5702E3180BCE750088DEC7 /* CCTMXLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTMXLayer.h; sourceTree = ""; }; 1A5702E4180BCE750088DEC7 /* CCTMXObjectGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTMXObjectGroup.cpp; sourceTree = ""; }; 1A5702E5180BCE750088DEC7 /* CCTMXObjectGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTMXObjectGroup.h; sourceTree = ""; }; 1A5702E6180BCE750088DEC7 /* CCTMXTiledMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTMXTiledMap.cpp; sourceTree = ""; }; 1A5702E7180BCE750088DEC7 /* CCTMXTiledMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTMXTiledMap.h; sourceTree = ""; }; 1A5702E8180BCE750088DEC7 /* CCTMXXMLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTMXXMLParser.cpp; sourceTree = ""; }; 1A5702E9180BCE750088DEC7 /* CCTMXXMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTMXXMLParser.h; sourceTree = ""; }; 1A5702FE180BCE890088DEC7 /* CCParallaxNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParallaxNode.cpp; sourceTree = ""; }; 1A5702FF180BCE890088DEC7 /* CCParallaxNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParallaxNode.h; sourceTree = ""; }; 1A570304180BCED90088DEC7 /* ccUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccUtils.cpp; sourceTree = ""; }; 1A570308180BCF190088DEC7 /* CCComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComponent.cpp; sourceTree = ""; }; 1A570309180BCF190088DEC7 /* CCComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComponent.h; sourceTree = ""; }; 1A57030A180BCF190088DEC7 /* CCComponentContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComponentContainer.cpp; sourceTree = ""; }; 1A57030B180BCF190088DEC7 /* CCComponentContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComponentContainer.h; sourceTree = ""; }; 1A570315180BCF430088DEC7 /* ccCArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccCArray.cpp; sourceTree = ""; }; 1A570316180BCF430088DEC7 /* ccCArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccCArray.h; sourceTree = ""; }; 1A570317180BCF430088DEC7 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; 1A570318180BCF430088DEC7 /* utlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utlist.h; sourceTree = ""; }; 1A570322180BCF660088DEC7 /* TGAlib.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TGAlib.cpp; sourceTree = ""; }; 1A570323180BCF660088DEC7 /* TGAlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGAlib.h; sourceTree = ""; }; 1A57032B180BCFD50088DEC7 /* CCUserDefault.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCUserDefault.cpp; sourceTree = ""; }; 1A57032C180BCFD50088DEC7 /* CCUserDefault.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCUserDefault.h; sourceTree = ""; }; 1A57032D180BCFD50088DEC7 /* CCUserDefault.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCUserDefault.mm; sourceTree = ""; }; 1A57032E180BCFD50088DEC7 /* CCUserDefaultAndroid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCUserDefaultAndroid.cpp; sourceTree = ""; }; 1A570338180BCFFA0088DEC7 /* ZipUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZipUtils.cpp; sourceTree = ""; }; 1A570339180BCFFA0088DEC7 /* ZipUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZipUtils.h; sourceTree = ""; }; 1A570346180BD0850088DEC7 /* libglfw3.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libglfw3.a; path = ../external/glfw3/prebuilt/mac/libglfw3.a; sourceTree = ""; }; 1A570349180BD09B0088DEC7 /* tinyxml2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxml2.cpp; sourceTree = ""; }; 1A57034A180BD09B0088DEC7 /* tinyxml2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tinyxml2.h; sourceTree = ""; }; 1A570350180BD0B00088DEC7 /* ioapi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ioapi.cpp; sourceTree = ""; }; 1A570351180BD0B00088DEC7 /* ioapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi.h; sourceTree = ""; }; 1A570352180BD0B00088DEC7 /* unzip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unzip.cpp; sourceTree = ""; }; 1A570353180BD0B00088DEC7 /* unzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unzip.h; sourceTree = ""; }; 1A570360180BD1080088DEC7 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libpng.a; sourceTree = ""; }; 1A570363180BD1120088DEC7 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libpng.a; sourceTree = ""; }; 1A570377180BD1B40088DEC7 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libjpeg.a; sourceTree = ""; }; 1A57037A180BD1C90088DEC7 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libjpeg.a; sourceTree = ""; }; 1A5703A0180BD22C0088DEC7 /* libtiff.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libtiff.a; sourceTree = ""; }; 1A5703A3180BD2350088DEC7 /* libtiff.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libtiff.a; sourceTree = ""; }; 1A5703B7180BD2780088DEC7 /* libwebp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebp.a; sourceTree = ""; }; 1A5703BA180BD2800088DEC7 /* libwebp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebp.a; sourceTree = ""; }; 1A57052A180BD31F0088DEC7 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfreetype.a; sourceTree = ""; }; 1A57052D180BD3280088DEC7 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfreetype.a; sourceTree = ""; }; 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgram.cpp; sourceTree = ""; }; 1A570530180BD9500088DEC7 /* CCGLProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgram.h; sourceTree = ""; }; 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccGLStateCache.cpp; sourceTree = ""; }; 1A570532180BD9500088DEC7 /* ccGLStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccGLStateCache.h; sourceTree = ""; }; 1A570544180BD9C40088DEC7 /* CCTouch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTouch.cpp; sourceTree = ""; }; 1A570545180BD9C40088DEC7 /* CCTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTouch.h; sourceTree = ""; }; 1A57FFF7180BC5160088DEC7 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CHANGELOG; path = ../CHANGELOG; sourceTree = ""; }; 1A6FB53017854BC300CDF010 /* libluabindings Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libluabindings Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 1A85BA0C1845F31700260FC0 /* CCVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCVector.h; path = ../base/CCVector.h; sourceTree = ""; }; 1A8C563F180E8D0D00EF57C3 /* tolua++.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "tolua++.h"; sourceTree = ""; }; 1A8C5640180E8D0D00EF57C3 /* tolua_event.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_event.c; sourceTree = ""; }; 1A8C5641180E8D0D00EF57C3 /* tolua_event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tolua_event.h; sourceTree = ""; }; 1A8C5642180E8D0D00EF57C3 /* tolua_is.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_is.c; sourceTree = ""; }; 1A8C5643180E8D0D00EF57C3 /* tolua_map.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_map.c; sourceTree = ""; }; 1A8C5644180E8D0D00EF57C3 /* tolua_push.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_push.c; sourceTree = ""; }; 1A8C5645180E8D0D00EF57C3 /* tolua_to.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_to.c; sourceTree = ""; }; 1A8C58BF180E92CC00EF57C3 /* CocosGUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosGUI.cpp; sourceTree = ""; }; 1A8C58C0180E92CC00EF57C3 /* CocosGUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosGUI.h; sourceTree = ""; }; 1A8C58C1180E92CC00EF57C3 /* UILayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = UILayout.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A8C58C2180E92CC00EF57C3 /* UILayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayout.h; sourceTree = ""; }; 1A8C58C3180E92CC00EF57C3 /* UILayoutParameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutParameter.cpp; sourceTree = ""; }; 1A8C58C4180E92CC00EF57C3 /* UILayoutParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutParameter.h; sourceTree = ""; }; 1A8C58C5180E92CC00EF57C3 /* UIButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIButton.cpp; sourceTree = ""; }; 1A8C58C6180E92CC00EF57C3 /* UIButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIButton.h; sourceTree = ""; }; 1A8C58C7180E92CC00EF57C3 /* UICheckBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UICheckBox.cpp; sourceTree = ""; }; 1A8C58C8180E92CC00EF57C3 /* UICheckBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICheckBox.h; sourceTree = ""; }; 1A8C58CB180E92CC00EF57C3 /* UIHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIHelper.cpp; sourceTree = ""; }; 1A8C58CC180E92CC00EF57C3 /* UIHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIHelper.h; sourceTree = ""; }; 1A8C58CD180E92CC00EF57C3 /* UIImageView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIImageView.cpp; sourceTree = ""; }; 1A8C58CE180E92CC00EF57C3 /* UIImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIImageView.h; sourceTree = ""; }; 1A8C58D1180E92CC00EF57C3 /* UIText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIText.cpp; sourceTree = ""; }; 1A8C58D2180E92CC00EF57C3 /* UIText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIText.h; sourceTree = ""; }; 1A8C58D3180E92CC00EF57C3 /* UITextAtlas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UITextAtlas.cpp; sourceTree = ""; }; 1A8C58D4180E92CC00EF57C3 /* UITextAtlas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UITextAtlas.h; sourceTree = ""; }; 1A8C58D5180E92CC00EF57C3 /* UITextBMFont.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UITextBMFont.cpp; sourceTree = ""; }; 1A8C58D6180E92CC00EF57C3 /* UITextBMFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UITextBMFont.h; sourceTree = ""; }; 1A8C58D9180E92CC00EF57C3 /* UILayoutDefine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutDefine.cpp; sourceTree = ""; }; 1A8C58DA180E92CC00EF57C3 /* UILayoutDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutDefine.h; sourceTree = ""; }; 1A8C58DD180E92CC00EF57C3 /* UILoadingBar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILoadingBar.cpp; sourceTree = ""; }; 1A8C58DE180E92CC00EF57C3 /* UILoadingBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILoadingBar.h; sourceTree = ""; }; 1A8C58DF180E92CC00EF57C3 /* UIPageView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIPageView.cpp; sourceTree = ""; }; 1A8C58E0180E92CC00EF57C3 /* UIPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIPageView.h; sourceTree = ""; }; 1A8C58E3180E92CC00EF57C3 /* UIScrollInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollInterface.h; sourceTree = ""; }; 1A8C58E4180E92CC00EF57C3 /* UIScrollView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScrollView.cpp; sourceTree = ""; }; 1A8C58E5180E92CC00EF57C3 /* UIScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollView.h; sourceTree = ""; }; 1A8C58E6180E92CC00EF57C3 /* UISlider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UISlider.cpp; sourceTree = ""; }; 1A8C58E7180E92CC00EF57C3 /* UISlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UISlider.h; sourceTree = ""; }; 1A8C58E8180E92CC00EF57C3 /* UITextField.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UITextField.cpp; sourceTree = ""; }; 1A8C58E9180E92CC00EF57C3 /* UITextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UITextField.h; sourceTree = ""; }; 1A8C58EA180E92CC00EF57C3 /* UIWidget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIWidget.cpp; sourceTree = ""; }; 1A8C58EB180E92CC00EF57C3 /* UIWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidget.h; sourceTree = ""; }; 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionFrame.cpp; sourceTree = ""; }; 1A8C5949180E930E00EF57C3 /* CCActionFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionFrame.h; sourceTree = ""; }; 1A8C594A180E930E00EF57C3 /* CCActionFrameEasing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionFrameEasing.cpp; sourceTree = ""; }; 1A8C594B180E930E00EF57C3 /* CCActionFrameEasing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionFrameEasing.h; sourceTree = ""; }; 1A8C594C180E930E00EF57C3 /* CCActionManagerEx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionManagerEx.cpp; sourceTree = ""; }; 1A8C594D180E930E00EF57C3 /* CCActionManagerEx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionManagerEx.h; sourceTree = ""; }; 1A8C594E180E930E00EF57C3 /* CCActionNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionNode.cpp; sourceTree = ""; }; 1A8C594F180E930E00EF57C3 /* CCActionNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionNode.h; sourceTree = ""; }; 1A8C5950180E930E00EF57C3 /* CCActionObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionObject.cpp; sourceTree = ""; }; 1A8C5951180E930E00EF57C3 /* CCActionObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionObject.h; sourceTree = ""; }; 1A8C5952180E930E00EF57C3 /* CCArmature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmature.cpp; sourceTree = ""; }; 1A8C5953180E930E00EF57C3 /* CCArmature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmature.h; sourceTree = ""; }; 1A8C5954180E930E00EF57C3 /* CCArmatureAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmatureAnimation.cpp; sourceTree = ""; }; 1A8C5955180E930E00EF57C3 /* CCArmatureAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmatureAnimation.h; sourceTree = ""; }; 1A8C5956180E930E00EF57C3 /* CCArmatureDataManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmatureDataManager.cpp; sourceTree = ""; }; 1A8C5957180E930E00EF57C3 /* CCArmatureDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmatureDataManager.h; sourceTree = ""; }; 1A8C5958180E930E00EF57C3 /* CCArmatureDefine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmatureDefine.cpp; sourceTree = ""; }; 1A8C5959180E930E00EF57C3 /* CCArmatureDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmatureDefine.h; sourceTree = ""; }; 1A8C595A180E930E00EF57C3 /* CCBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCBatchNode.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A8C595B180E930E00EF57C3 /* CCBatchNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBatchNode.h; sourceTree = ""; }; 1A8C595C180E930E00EF57C3 /* CCBone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBone.cpp; sourceTree = ""; }; 1A8C595D180E930E00EF57C3 /* CCBone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBone.h; sourceTree = ""; }; 1A8C595E180E930E00EF57C3 /* CCColliderDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCColliderDetector.cpp; sourceTree = ""; }; 1A8C595F180E930E00EF57C3 /* CCColliderDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCColliderDetector.h; sourceTree = ""; }; 1A8C5960180E930E00EF57C3 /* CCComAttribute.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComAttribute.cpp; sourceTree = ""; }; 1A8C5961180E930E00EF57C3 /* CCComAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComAttribute.h; sourceTree = ""; }; 1A8C5962180E930E00EF57C3 /* CCComAudio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComAudio.cpp; sourceTree = ""; }; 1A8C5963180E930E00EF57C3 /* CCComAudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComAudio.h; sourceTree = ""; }; 1A8C5964180E930E00EF57C3 /* CCComController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComController.cpp; sourceTree = ""; }; 1A8C5965180E930E00EF57C3 /* CCComController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComController.h; sourceTree = ""; }; 1A8C5966180E930E00EF57C3 /* CCComRender.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComRender.cpp; sourceTree = ""; }; 1A8C5967180E930E00EF57C3 /* CCComRender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComRender.h; sourceTree = ""; }; 1A8C5968180E930E00EF57C3 /* CCDataReaderHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDataReaderHelper.cpp; sourceTree = ""; }; 1A8C5969180E930E00EF57C3 /* CCDataReaderHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDataReaderHelper.h; sourceTree = ""; }; 1A8C596A180E930E00EF57C3 /* CCDatas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDatas.cpp; sourceTree = ""; }; 1A8C596B180E930E00EF57C3 /* CCDatas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDatas.h; sourceTree = ""; }; 1A8C596C180E930E00EF57C3 /* CCDecorativeDisplay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDecorativeDisplay.cpp; sourceTree = ""; }; 1A8C596D180E930E00EF57C3 /* CCDecorativeDisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDecorativeDisplay.h; sourceTree = ""; }; 1A8C596E180E930E00EF57C3 /* CCDisplayFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDisplayFactory.cpp; sourceTree = ""; }; 1A8C596F180E930E00EF57C3 /* CCDisplayFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDisplayFactory.h; sourceTree = ""; }; 1A8C5970180E930E00EF57C3 /* CCDisplayManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDisplayManager.cpp; sourceTree = ""; }; 1A8C5971180E930E00EF57C3 /* CCDisplayManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDisplayManager.h; sourceTree = ""; }; 1A8C5972180E930E00EF57C3 /* CCInputDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCInputDelegate.cpp; sourceTree = ""; }; 1A8C5973180E930E00EF57C3 /* CCInputDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCInputDelegate.h; sourceTree = ""; }; 1A8C5974180E930E00EF57C3 /* CCProcessBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProcessBase.cpp; sourceTree = ""; }; 1A8C5975180E930E00EF57C3 /* CCProcessBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProcessBase.h; sourceTree = ""; }; 1A8C5976180E930E00EF57C3 /* CCSGUIReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSGUIReader.cpp; sourceTree = ""; }; 1A8C5977180E930E00EF57C3 /* CCSGUIReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSGUIReader.h; sourceTree = ""; }; 1A8C5978180E930E00EF57C3 /* CCSkin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCSkin.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A8C5979180E930E00EF57C3 /* CCSkin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSkin.h; sourceTree = ""; }; 1A8C597A180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteFrameCacheHelper.cpp; sourceTree = ""; }; 1A8C597B180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteFrameCacheHelper.h; sourceTree = ""; }; 1A8C597C180E930E00EF57C3 /* CCSSceneReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSSceneReader.cpp; sourceTree = ""; }; 1A8C597D180E930E00EF57C3 /* CCSSceneReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSSceneReader.h; sourceTree = ""; }; 1A8C597E180E930E00EF57C3 /* CCTransformHelp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTransformHelp.cpp; sourceTree = ""; }; 1A8C597F180E930E00EF57C3 /* CCTransformHelp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTransformHelp.h; sourceTree = ""; }; 1A8C5980180E930E00EF57C3 /* CCTween.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTween.cpp; sourceTree = ""; }; 1A8C5981180E930E00EF57C3 /* CCTween.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTween.h; sourceTree = ""; }; 1A8C5982180E930E00EF57C3 /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = ""; }; 1A8C5983180E930E00EF57C3 /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = ""; }; 1A8C5984180E930E00EF57C3 /* CCUtilMath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCUtilMath.cpp; sourceTree = ""; }; 1A8C5985180E930E00EF57C3 /* CCUtilMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCUtilMath.h; sourceTree = ""; }; 1A8C5986180E930E00EF57C3 /* CocoStudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoStudio.h; sourceTree = ""; }; 1A8C5989180E930E00EF57C3 /* DictionaryHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DictionaryHelper.cpp; sourceTree = ""; }; 1A8C598A180E930E00EF57C3 /* DictionaryHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryHelper.h; sourceTree = ""; }; 1A9DC9F8180E6955007A3AD4 /* ccConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccConfig.h; sourceTree = ""; }; 1A9DC9F9180E6955007A3AD4 /* CCConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCConfiguration.cpp; sourceTree = ""; }; 1A9DC9FA180E6955007A3AD4 /* CCConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCConfiguration.h; sourceTree = ""; }; 1A9DC9FD180E6955007A3AD4 /* CCDirector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDirector.cpp; sourceTree = ""; }; 1A9DC9FE180E6955007A3AD4 /* CCDirector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDirector.h; sourceTree = ""; }; 1A9DC9FF180E6955007A3AD4 /* CCEventType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventType.h; sourceTree = ""; }; 1A9DCA00180E6955007A3AD4 /* ccFPSImages.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccFPSImages.c; sourceTree = ""; }; 1A9DCA01180E6955007A3AD4 /* ccFPSImages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccFPSImages.h; sourceTree = ""; }; 1A9DCA02180E6955007A3AD4 /* CCGLBufferedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLBufferedNode.cpp; sourceTree = ""; }; 1A9DCA03180E6955007A3AD4 /* CCGLBufferedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLBufferedNode.h; sourceTree = ""; }; 1A9DCA04180E6955007A3AD4 /* ccMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccMacros.h; sourceTree = ""; }; 1A9DCA05180E6955007A3AD4 /* CCProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtocols.h; sourceTree = ""; }; 1A9DCA06180E6955007A3AD4 /* CCScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScheduler.cpp; sourceTree = ""; }; 1A9DCA07180E6955007A3AD4 /* CCScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScheduler.h; sourceTree = ""; }; 1A9DCA0A180E6955007A3AD4 /* cocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d.cpp; sourceTree = ""; }; 1A9DCA0B180E6955007A3AD4 /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cocos2d.h; sourceTree = ""; }; 1A9DCA0C180E6955007A3AD4 /* firePngData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = firePngData.h; sourceTree = ""; }; 1A9DCA0D180E6955007A3AD4 /* TransformUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformUtils.cpp; sourceTree = ""; }; 1A9DCA0E180E6955007A3AD4 /* TransformUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformUtils.h; sourceTree = ""; }; 1A9DCA41180E6D90007A3AD4 /* CCDeprecated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDeprecated.cpp; sourceTree = ""; }; 1A9DCA42180E6D90007A3AD4 /* CCDeprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDeprecated.h; sourceTree = ""; }; 1A9DCA47180E6DE3007A3AD4 /* ccTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccTypes.cpp; sourceTree = ""; }; 1A9DCA48180E6DE3007A3AD4 /* ccTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccTypes.h; sourceTree = ""; }; 1AA2063E1848437900053418 /* CCMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCMap.h; path = ../base/CCMap.h; sourceTree = ""; }; 1AAF5351180E3060000584C8 /* AssetsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AssetsManager.cpp; sourceTree = ""; }; 1AAF5352180E3060000584C8 /* AssetsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AssetsManager.h; sourceTree = ""; }; 1AAF5362180E3374000584C8 /* HttpClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HttpClient.cpp; sourceTree = ""; }; 1AAF5363180E3374000584C8 /* HttpClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpClient.h; sourceTree = ""; }; 1AAF5364180E3374000584C8 /* HttpRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpRequest.h; sourceTree = ""; }; 1AAF5365180E3374000584C8 /* HttpResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpResponse.h; sourceTree = ""; }; 1AAF5366180E3374000584C8 /* SocketIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketIO.cpp; sourceTree = ""; }; 1AAF5367180E3374000584C8 /* SocketIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketIO.h; sourceTree = ""; }; 1AAF5368180E3374000584C8 /* WebSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocket.cpp; sourceTree = ""; }; 1AAF5369180E3374000584C8 /* WebSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocket.h; sourceTree = ""; }; 1AAF5384180E35A3000584C8 /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebsockets.a; sourceTree = ""; }; 1AAF5387180E35AC000584C8 /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebsockets.a; sourceTree = ""; }; 1AAF541C180E3B6A000584C8 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libcurl.a; sourceTree = ""; }; 1AAF5421180E4047000584C8 /* libjs_static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libjs_static.a; sourceTree = ""; }; 1AAF5424180E405B000584C8 /* libjs_static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libjs_static.a; sourceTree = ""; }; 1AAF584B180E40B9000584C8 /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; 1AAF584C180E40B9000584C8 /* LocalStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalStorage.cpp; sourceTree = ""; }; 1AAF584D180E40B9000584C8 /* LocalStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalStorage.h; sourceTree = ""; }; 1AAF584E180E40B9000584C8 /* LocalStorageAndroid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalStorageAndroid.cpp; sourceTree = ""; }; 1ABA68AC1888D700007D1BB4 /* CCFontCharMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFontCharMap.cpp; sourceTree = ""; }; 1ABA68AD1888D700007D1BB4 /* CCFontCharMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFontCharMap.h; sourceTree = ""; }; 1AD71CFA180E26E600808F54 /* CCBAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBAnimationManager.cpp; sourceTree = ""; }; 1AD71CFB180E26E600808F54 /* CCBAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBAnimationManager.h; sourceTree = ""; }; 1AD71CFC180E26E600808F54 /* CCBFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBFileLoader.cpp; sourceTree = ""; }; 1AD71CFD180E26E600808F54 /* CCBFileLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBFileLoader.h; sourceTree = ""; }; 1AD71CFE180E26E600808F54 /* CCBKeyframe.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBKeyframe.cpp; sourceTree = ""; }; 1AD71CFF180E26E600808F54 /* CCBKeyframe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBKeyframe.h; sourceTree = ""; }; 1AD71D00180E26E600808F54 /* CCBMemberVariableAssigner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBMemberVariableAssigner.h; sourceTree = ""; }; 1AD71D01180E26E600808F54 /* CCBReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBReader.cpp; sourceTree = ""; }; 1AD71D02180E26E600808F54 /* CCBReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBReader.h; sourceTree = ""; }; 1AD71D03180E26E600808F54 /* CCBSelectorResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSelectorResolver.h; sourceTree = ""; }; 1AD71D04180E26E600808F54 /* CCBSequence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBSequence.cpp; sourceTree = ""; }; 1AD71D05180E26E600808F54 /* CCBSequence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSequence.h; sourceTree = ""; }; 1AD71D06180E26E600808F54 /* CCBSequenceProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBSequenceProperty.cpp; sourceTree = ""; }; 1AD71D07180E26E600808F54 /* CCBSequenceProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBSequenceProperty.h; sourceTree = ""; }; 1AD71D0A180E26E600808F54 /* CCControlButtonLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButtonLoader.cpp; sourceTree = ""; }; 1AD71D0B180E26E600808F54 /* CCControlButtonLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlButtonLoader.h; sourceTree = ""; }; 1AD71D0C180E26E600808F54 /* CCControlLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlLoader.cpp; sourceTree = ""; }; 1AD71D0D180E26E600808F54 /* CCControlLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlLoader.h; sourceTree = ""; }; 1AD71D0E180E26E600808F54 /* CCLabelBMFontLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelBMFontLoader.cpp; sourceTree = ""; }; 1AD71D0F180E26E600808F54 /* CCLabelBMFontLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelBMFontLoader.h; sourceTree = ""; }; 1AD71D10180E26E600808F54 /* CCLabelTTFLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLabelTTFLoader.cpp; sourceTree = ""; }; 1AD71D11180E26E600808F54 /* CCLabelTTFLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelTTFLoader.h; sourceTree = ""; }; 1AD71D12180E26E600808F54 /* CCLayerColorLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerColorLoader.cpp; sourceTree = ""; }; 1AD71D13180E26E600808F54 /* CCLayerColorLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerColorLoader.h; sourceTree = ""; }; 1AD71D14180E26E600808F54 /* CCLayerGradientLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerGradientLoader.cpp; sourceTree = ""; }; 1AD71D15180E26E600808F54 /* CCLayerGradientLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerGradientLoader.h; sourceTree = ""; }; 1AD71D16180E26E600808F54 /* CCLayerLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLayerLoader.cpp; sourceTree = ""; }; 1AD71D17180E26E600808F54 /* CCLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLayerLoader.h; sourceTree = ""; }; 1AD71D18180E26E600808F54 /* CCMenuItemImageLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItemImageLoader.cpp; sourceTree = ""; }; 1AD71D19180E26E600808F54 /* CCMenuItemImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItemImageLoader.h; sourceTree = ""; }; 1AD71D1A180E26E600808F54 /* CCMenuItemLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMenuItemLoader.cpp; sourceTree = ""; }; 1AD71D1B180E26E600808F54 /* CCMenuItemLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuItemLoader.h; sourceTree = ""; }; 1AD71D1C180E26E600808F54 /* CCMenuLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuLoader.h; sourceTree = ""; }; 1AD71D1D180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "CCNode+CCBRelativePositioning.cpp"; sourceTree = ""; }; 1AD71D1E180E26E600808F54 /* CCNode+CCBRelativePositioning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCNode+CCBRelativePositioning.h"; sourceTree = ""; }; 1AD71D1F180E26E600808F54 /* CCNodeLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeLoader.cpp; sourceTree = ""; }; 1AD71D20180E26E600808F54 /* CCNodeLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoader.h; sourceTree = ""; }; 1AD71D21180E26E600808F54 /* CCNodeLoaderLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeLoaderLibrary.cpp; sourceTree = ""; }; 1AD71D22180E26E600808F54 /* CCNodeLoaderLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoaderLibrary.h; sourceTree = ""; }; 1AD71D23180E26E600808F54 /* CCNodeLoaderListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeLoaderListener.h; sourceTree = ""; }; 1AD71D24180E26E600808F54 /* CCParticleSystemQuadLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleSystemQuadLoader.cpp; sourceTree = ""; }; 1AD71D25180E26E600808F54 /* CCParticleSystemQuadLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleSystemQuadLoader.h; sourceTree = ""; }; 1AD71D26180E26E600808F54 /* CCScale9SpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9SpriteLoader.cpp; sourceTree = ""; }; 1AD71D27180E26E600808F54 /* CCScale9SpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScale9SpriteLoader.h; sourceTree = ""; }; 1AD71D28180E26E600808F54 /* CCScrollViewLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScrollViewLoader.cpp; sourceTree = ""; }; 1AD71D29180E26E600808F54 /* CCScrollViewLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScrollViewLoader.h; sourceTree = ""; }; 1AD71D2A180E26E600808F54 /* CCSpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteLoader.cpp; sourceTree = ""; }; 1AD71D2B180E26E600808F54 /* CCSpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteLoader.h; sourceTree = ""; }; 1AD71D2C180E26E600808F54 /* CocosBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosBuilder.h; sourceTree = ""; }; 1AD71D7E180E26E600808F54 /* Animation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Animation.cpp; sourceTree = ""; }; 1AD71D7F180E26E600808F54 /* Animation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Animation.h; sourceTree = ""; }; 1AD71D80180E26E600808F54 /* AnimationState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimationState.cpp; sourceTree = ""; }; 1AD71D81180E26E600808F54 /* AnimationState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationState.h; sourceTree = ""; }; 1AD71D82180E26E600808F54 /* AnimationStateData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimationStateData.cpp; sourceTree = ""; }; 1AD71D83180E26E600808F54 /* AnimationStateData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationStateData.h; sourceTree = ""; }; 1AD71D84180E26E600808F54 /* Atlas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Atlas.cpp; sourceTree = ""; }; 1AD71D85180E26E600808F54 /* Atlas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Atlas.h; sourceTree = ""; }; 1AD71D86180E26E600808F54 /* AtlasAttachmentLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AtlasAttachmentLoader.cpp; sourceTree = ""; }; 1AD71D87180E26E600808F54 /* AtlasAttachmentLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AtlasAttachmentLoader.h; sourceTree = ""; }; 1AD71D88180E26E600808F54 /* Attachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Attachment.cpp; sourceTree = ""; }; 1AD71D89180E26E600808F54 /* Attachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Attachment.h; sourceTree = ""; }; 1AD71D8A180E26E600808F54 /* AttachmentLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AttachmentLoader.cpp; sourceTree = ""; }; 1AD71D8B180E26E600808F54 /* AttachmentLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttachmentLoader.h; sourceTree = ""; }; 1AD71D8C180E26E600808F54 /* Bone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Bone.cpp; sourceTree = ""; }; 1AD71D8D180E26E600808F54 /* Bone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bone.h; sourceTree = ""; }; 1AD71D8E180E26E600808F54 /* BoneData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoneData.cpp; sourceTree = ""; }; 1AD71D8F180E26E600808F54 /* BoneData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoneData.h; sourceTree = ""; }; 1AD71D90180E26E600808F54 /* CCSkeleton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCSkeleton.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AD71D91180E26E600808F54 /* CCSkeleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSkeleton.h; sourceTree = ""; }; 1AD71D92180E26E600808F54 /* CCSkeletonAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSkeletonAnimation.cpp; sourceTree = ""; }; 1AD71D93180E26E600808F54 /* CCSkeletonAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSkeletonAnimation.h; sourceTree = ""; }; 1AD71D94180E26E600808F54 /* extension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extension.cpp; sourceTree = ""; }; 1AD71D95180E26E600808F54 /* extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = extension.h; sourceTree = ""; }; 1AD71D96180E26E600808F54 /* Json.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Json.cpp; sourceTree = ""; }; 1AD71D97180E26E600808F54 /* Json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Json.h; sourceTree = ""; }; 1AD71D98180E26E600808F54 /* RegionAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegionAttachment.cpp; sourceTree = ""; }; 1AD71D99180E26E600808F54 /* RegionAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegionAttachment.h; sourceTree = ""; }; 1AD71D9A180E26E600808F54 /* Skeleton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Skeleton.cpp; sourceTree = ""; }; 1AD71D9B180E26E600808F54 /* Skeleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Skeleton.h; sourceTree = ""; }; 1AD71D9C180E26E600808F54 /* SkeletonData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonData.cpp; sourceTree = ""; }; 1AD71D9D180E26E600808F54 /* SkeletonData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkeletonData.h; sourceTree = ""; }; 1AD71D9E180E26E600808F54 /* SkeletonJson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonJson.cpp; sourceTree = ""; }; 1AD71D9F180E26E600808F54 /* SkeletonJson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkeletonJson.h; sourceTree = ""; }; 1AD71DA0180E26E600808F54 /* Skin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Skin.cpp; sourceTree = ""; }; 1AD71DA1180E26E600808F54 /* Skin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Skin.h; sourceTree = ""; }; 1AD71DA2180E26E600808F54 /* Slot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Slot.cpp; sourceTree = ""; }; 1AD71DA3180E26E600808F54 /* Slot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Slot.h; sourceTree = ""; }; 1AD71DA4180E26E600808F54 /* SlotData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SlotData.cpp; sourceTree = ""; }; 1AD71DA5180E26E600808F54 /* SlotData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlotData.h; sourceTree = ""; }; 1AD71DA6180E26E600808F54 /* spine-cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "spine-cocos2dx.cpp"; sourceTree = ""; }; 1AD71DA7180E26E600808F54 /* spine-cocos2dx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "spine-cocos2dx.h"; sourceTree = ""; }; 1AD71DA8180E26E600808F54 /* spine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spine.h; sourceTree = ""; }; 1AD71EEC180E27CF00808F54 /* CCPhysicsDebugNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsDebugNode.cpp; sourceTree = ""; }; 1AD71EED180E27CF00808F54 /* CCPhysicsDebugNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsDebugNode.h; sourceTree = ""; }; 1AD71EEE180E27CF00808F54 /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsSprite.cpp; sourceTree = ""; }; 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsSprite.h; sourceTree = ""; }; 1AE3C842184F14F700CF29B5 /* CCValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCValue.cpp; path = ../base/CCValue.cpp; sourceTree = ""; }; 1AE3C843184F14F700CF29B5 /* CCValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCValue.h; path = ../base/CCValue.h; sourceTree = ""; }; 2AC795D318628672005EC8E1 /* BoundingBoxAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoundingBoxAttachment.cpp; sourceTree = ""; }; 2AC795D418628672005EC8E1 /* BoundingBoxAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoundingBoxAttachment.h; sourceTree = ""; }; 2AC795D51862867D005EC8E1 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = ""; }; 2AC795D61862867D005EC8E1 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Event.h; sourceTree = ""; }; 2AC795D71862867D005EC8E1 /* EventData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventData.cpp; sourceTree = ""; }; 2AC795D81862867D005EC8E1 /* EventData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventData.h; sourceTree = ""; }; 2AC795D918628689005EC8E1 /* SkeletonBounds.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonBounds.cpp; sourceTree = ""; }; 2AC795DA18628689005EC8E1 /* SkeletonBounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkeletonBounds.h; sourceTree = ""; }; 2AFCB81F1863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_spine_auto.cpp; sourceTree = ""; }; 2AFCB8201863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_spine_auto.hpp; sourceTree = ""; }; 373B910718787C0B00198F86 /* CCComBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComBase.h; sourceTree = ""; }; 3774879E1869BA8C00EDF837 /* CCActionEaseEx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionEaseEx.cpp; sourceTree = ""; }; 37936A341869B76800E974DD /* document.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = document.h; sourceTree = ""; }; 37936A351869B76800E974DD /* filestream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filestream.h; sourceTree = ""; }; 37936A371869B76800E974DD /* pow10.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pow10.h; sourceTree = ""; }; 37936A381869B76800E974DD /* stack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stack.h; sourceTree = ""; }; 37936A391869B76800E974DD /* strfunc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strfunc.h; sourceTree = ""; }; 37936A3A1869B76800E974DD /* prettywriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prettywriter.h; sourceTree = ""; }; 37936A3B1869B76800E974DD /* rapidjson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rapidjson.h; sourceTree = ""; }; 37936A3C1869B76800E974DD /* reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reader.h; sourceTree = ""; }; 37936A3D1869B76800E974DD /* stringbuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stringbuffer.h; sourceTree = ""; }; 37936A3E1869B76800E974DD /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = ""; }; 37936A401869B7B200E974DD /* CCActionEaseEx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionEaseEx.h; sourceTree = ""; }; 3EEF8BCB1839F390005E8A6C /* jsb_cocos2dx_gui_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_gui_auto.cpp; sourceTree = ""; }; 3EEF8BCC1839F390005E8A6C /* jsb_cocos2dx_gui_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_gui_auto.hpp; sourceTree = ""; }; 3EEF8BD11839F5C5005E8A6C /* jsb_cocos2dx_gui_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_cocos2dx_gui_manual.cpp; path = gui/jsb_cocos2dx_gui_manual.cpp; sourceTree = ""; }; 3EEF8BD21839F5C5005E8A6C /* jsb_cocos2dx_gui_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_cocos2dx_gui_manual.h; path = gui/jsb_cocos2dx_gui_manual.h; sourceTree = ""; }; 46A15FCC1807A544005B8026 /* AUTHORS */ = {isa = PBXFileReference; lastKnownFileType = text; name = AUTHORS; path = ../AUTHORS; sourceTree = ""; }; 46A15FCE1807A544005B8026 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = ""; }; 46A15FE11807A56F005B8026 /* Export.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; 46A15FE21807A56F005B8026 /* SimpleAudioEngine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine.h; sourceTree = ""; }; 46A15FE41807A56F005B8026 /* CDAudioManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDAudioManager.h; sourceTree = ""; }; 46A15FE51807A56F005B8026 /* CDAudioManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CDAudioManager.m; sourceTree = ""; }; 46A15FE61807A56F005B8026 /* CDConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDConfig.h; sourceTree = ""; }; 46A15FE71807A56F005B8026 /* CDOpenALSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDOpenALSupport.h; sourceTree = ""; }; 46A15FE81807A56F005B8026 /* CDOpenALSupport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CDOpenALSupport.m; sourceTree = ""; }; 46A15FE91807A56F005B8026 /* CocosDenshion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CocosDenshion.h; sourceTree = ""; }; 46A15FEA1807A56F005B8026 /* CocosDenshion.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CocosDenshion.m; sourceTree = ""; }; 46A15FEB1807A56F005B8026 /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = ""; }; 46A15FEC1807A56F005B8026 /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = ""; }; 46A15FED1807A56F005B8026 /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = ""; }; 46A15FF41807A56F005B8026 /* CDAudioManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDAudioManager.h; sourceTree = ""; }; 46A15FF51807A56F005B8026 /* CDAudioManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CDAudioManager.m; sourceTree = ""; }; 46A15FF61807A56F005B8026 /* CDConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDConfig.h; sourceTree = ""; }; 46A15FF71807A56F005B8026 /* CDOpenALSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDOpenALSupport.h; sourceTree = ""; }; 46A15FF81807A56F005B8026 /* CDOpenALSupport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CDOpenALSupport.m; sourceTree = ""; }; 46A15FF91807A56F005B8026 /* CDXMacOSXSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDXMacOSXSupport.h; sourceTree = ""; }; 46A15FFA1807A56F005B8026 /* CDXMacOSXSupport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CDXMacOSXSupport.mm; sourceTree = ""; }; 46A15FFB1807A56F005B8026 /* CocosDenshion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CocosDenshion.h; sourceTree = ""; }; 46A15FFC1807A56F005B8026 /* CocosDenshion.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CocosDenshion.m; sourceTree = ""; }; 46A15FFD1807A56F005B8026 /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = ""; }; 46A15FFE1807A56F005B8026 /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = ""; }; 46A15FFF1807A56F005B8026 /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = ""; }; 46A167D21807AF4D005B8026 /* cocos-ext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "cocos-ext.h"; sourceTree = ""; }; 46A168321807AF4E005B8026 /* ExtensionMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtensionMacros.h; sourceTree = ""; }; 46A168351807AF4E005B8026 /* CCControl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControl.cpp; sourceTree = ""; }; 46A168361807AF4E005B8026 /* CCControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControl.h; sourceTree = ""; }; 46A168371807AF4E005B8026 /* CCControlButton.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButton.cpp; sourceTree = ""; }; 46A168381807AF4E005B8026 /* CCControlButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlButton.h; sourceTree = ""; }; 46A168391807AF4E005B8026 /* CCControlColourPicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlColourPicker.cpp; sourceTree = ""; }; 46A1683A1807AF4E005B8026 /* CCControlColourPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlColourPicker.h; sourceTree = ""; }; 46A1683B1807AF4E005B8026 /* CCControlExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlExtensions.h; sourceTree = ""; }; 46A1683C1807AF4E005B8026 /* CCControlHuePicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlHuePicker.cpp; sourceTree = ""; }; 46A1683D1807AF4E005B8026 /* CCControlHuePicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlHuePicker.h; sourceTree = ""; }; 46A1683E1807AF4E005B8026 /* CCControlPotentiometer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlPotentiometer.cpp; sourceTree = ""; }; 46A1683F1807AF4E005B8026 /* CCControlPotentiometer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlPotentiometer.h; sourceTree = ""; }; 46A168401807AF4E005B8026 /* CCControlSaturationBrightnessPicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSaturationBrightnessPicker.cpp; sourceTree = ""; }; 46A168411807AF4E005B8026 /* CCControlSaturationBrightnessPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlSaturationBrightnessPicker.h; sourceTree = ""; }; 46A168421807AF4E005B8026 /* CCControlSlider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSlider.cpp; sourceTree = ""; }; 46A168431807AF4E005B8026 /* CCControlSlider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlSlider.h; sourceTree = ""; }; 46A168441807AF4E005B8026 /* CCControlStepper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlStepper.cpp; sourceTree = ""; }; 46A168451807AF4E005B8026 /* CCControlStepper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlStepper.h; sourceTree = ""; }; 46A168461807AF4E005B8026 /* CCControlSwitch.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSwitch.cpp; sourceTree = ""; }; 46A168471807AF4E005B8026 /* CCControlSwitch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlSwitch.h; sourceTree = ""; }; 46A168481807AF4E005B8026 /* CCControlUtils.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlUtils.cpp; sourceTree = ""; }; 46A168491807AF4E005B8026 /* CCControlUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlUtils.h; sourceTree = ""; }; 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCInvocation.cpp; sourceTree = ""; }; 46A1684B1807AF4E005B8026 /* CCInvocation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCInvocation.h; sourceTree = ""; }; 46A1684C1807AF4E005B8026 /* CCScale9Sprite.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9Sprite.cpp; sourceTree = ""; }; 46A1684D1807AF4E005B8026 /* CCScale9Sprite.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCScale9Sprite.h; sourceTree = ""; }; 46A1684F1807AF4E005B8026 /* CCEditBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBox.cpp; sourceTree = ""; }; 46A168501807AF4E005B8026 /* CCEditBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBox.h; sourceTree = ""; }; 46A168511807AF4E005B8026 /* CCEditBoxImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImpl.h; sourceTree = ""; }; 46A168521807AF4E005B8026 /* CCEditBoxImplAndroid.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBoxImplAndroid.cpp; sourceTree = ""; }; 46A168531807AF4E005B8026 /* CCEditBoxImplAndroid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplAndroid.h; sourceTree = ""; }; 46A168541807AF4E005B8026 /* CCEditBoxImplIOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplIOS.h; sourceTree = ""; }; 46A168551807AF4E005B8026 /* CCEditBoxImplIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplIOS.mm; sourceTree = ""; }; 46A168561807AF4E005B8026 /* CCEditBoxImplMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplMac.h; sourceTree = ""; }; 46A168571807AF4E005B8026 /* CCEditBoxImplMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplMac.mm; sourceTree = ""; }; 46A168581807AF4E005B8026 /* CCEditBoxImplNone.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBoxImplNone.cpp; sourceTree = ""; }; 46A168591807AF4E005B8026 /* CCEditBoxImplTizen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBoxImplTizen.cpp; sourceTree = ""; }; 46A1685A1807AF4E005B8026 /* CCEditBoxImplTizen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplTizen.h; sourceTree = ""; }; 46A1685B1807AF4E005B8026 /* CCEditBoxImplWin.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBoxImplWin.cpp; sourceTree = ""; }; 46A1685C1807AF4E005B8026 /* CCEditBoxImplWin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplWin.h; sourceTree = ""; }; 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCScrollView.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 46A1685F1807AF4E005B8026 /* CCScrollView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCScrollView.h; sourceTree = ""; }; 46A168621807AF4E005B8026 /* CCTableView.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableView.cpp; sourceTree = ""; }; 46A168631807AF4E005B8026 /* CCTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCTableView.h; sourceTree = ""; }; 46A168641807AF4E005B8026 /* CCTableViewCell.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableViewCell.cpp; sourceTree = ""; }; 46A168651807AF4E005B8026 /* CCTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCTableViewCell.h; sourceTree = ""; }; 46A168B31807AF9C005B8026 /* Android.mk */ = {isa = PBXFileReference; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; 46A168B41807AF9C005B8026 /* Box2D.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Box2D.h; sourceTree = ""; }; 46A168B61807AF9C005B8026 /* b2BroadPhase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2BroadPhase.cpp; sourceTree = ""; }; 46A168B71807AF9C005B8026 /* b2BroadPhase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2BroadPhase.h; sourceTree = ""; }; 46A168B81807AF9C005B8026 /* b2CollideCircle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2CollideCircle.cpp; sourceTree = ""; }; 46A168B91807AF9C005B8026 /* b2CollideEdge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2CollideEdge.cpp; sourceTree = ""; }; 46A168BA1807AF9C005B8026 /* b2CollidePolygon.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2CollidePolygon.cpp; sourceTree = ""; }; 46A168BB1807AF9C005B8026 /* b2Collision.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Collision.cpp; sourceTree = ""; }; 46A168BC1807AF9C005B8026 /* b2Collision.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Collision.h; sourceTree = ""; }; 46A168BD1807AF9C005B8026 /* b2Distance.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Distance.cpp; sourceTree = ""; }; 46A168BE1807AF9C005B8026 /* b2Distance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Distance.h; sourceTree = ""; }; 46A168BF1807AF9C005B8026 /* b2DynamicTree.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2DynamicTree.cpp; sourceTree = ""; }; 46A168C01807AF9C005B8026 /* b2DynamicTree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2DynamicTree.h; sourceTree = ""; }; 46A168C11807AF9C005B8026 /* b2TimeOfImpact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2TimeOfImpact.cpp; sourceTree = ""; }; 46A168C21807AF9C005B8026 /* b2TimeOfImpact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2TimeOfImpact.h; sourceTree = ""; }; 46A168C41807AF9C005B8026 /* b2ChainShape.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2ChainShape.cpp; sourceTree = ""; }; 46A168C51807AF9C005B8026 /* b2ChainShape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2ChainShape.h; sourceTree = ""; }; 46A168C61807AF9C005B8026 /* b2CircleShape.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2CircleShape.cpp; sourceTree = ""; }; 46A168C71807AF9C005B8026 /* b2CircleShape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2CircleShape.h; sourceTree = ""; }; 46A168C81807AF9C005B8026 /* b2EdgeShape.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2EdgeShape.cpp; sourceTree = ""; }; 46A168C91807AF9C005B8026 /* b2EdgeShape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2EdgeShape.h; sourceTree = ""; }; 46A168CA1807AF9C005B8026 /* b2PolygonShape.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2PolygonShape.cpp; sourceTree = ""; }; 46A168CB1807AF9C005B8026 /* b2PolygonShape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2PolygonShape.h; sourceTree = ""; }; 46A168CC1807AF9C005B8026 /* b2Shape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Shape.h; sourceTree = ""; }; 46A168CE1807AF9C005B8026 /* b2BlockAllocator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2BlockAllocator.cpp; sourceTree = ""; }; 46A168CF1807AF9C005B8026 /* b2BlockAllocator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2BlockAllocator.h; sourceTree = ""; }; 46A168D01807AF9C005B8026 /* b2Draw.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Draw.cpp; sourceTree = ""; }; 46A168D11807AF9C005B8026 /* b2Draw.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Draw.h; sourceTree = ""; }; 46A168D21807AF9C005B8026 /* b2GrowableStack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2GrowableStack.h; sourceTree = ""; }; 46A168D31807AF9C005B8026 /* b2Math.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Math.cpp; sourceTree = ""; }; 46A168D41807AF9C005B8026 /* b2Math.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Math.h; sourceTree = ""; }; 46A168D51807AF9C005B8026 /* b2Settings.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Settings.cpp; sourceTree = ""; }; 46A168D61807AF9C005B8026 /* b2Settings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Settings.h; sourceTree = ""; }; 46A168D71807AF9C005B8026 /* b2StackAllocator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2StackAllocator.cpp; sourceTree = ""; }; 46A168D81807AF9C005B8026 /* b2StackAllocator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2StackAllocator.h; sourceTree = ""; }; 46A168D91807AF9C005B8026 /* b2Timer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Timer.cpp; sourceTree = ""; }; 46A168DA1807AF9C005B8026 /* b2Timer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Timer.h; sourceTree = ""; }; 46A168DC1807AF9C005B8026 /* b2Body.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Body.cpp; sourceTree = ""; }; 46A168DD1807AF9C005B8026 /* b2Body.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Body.h; sourceTree = ""; }; 46A168DE1807AF9C005B8026 /* b2ContactManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2ContactManager.cpp; sourceTree = ""; }; 46A168DF1807AF9C005B8026 /* b2ContactManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2ContactManager.h; sourceTree = ""; }; 46A168E01807AF9C005B8026 /* b2Fixture.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Fixture.cpp; sourceTree = ""; }; 46A168E11807AF9C005B8026 /* b2Fixture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Fixture.h; sourceTree = ""; }; 46A168E21807AF9C005B8026 /* b2Island.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Island.cpp; sourceTree = ""; }; 46A168E31807AF9C005B8026 /* b2Island.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Island.h; sourceTree = ""; }; 46A168E41807AF9C005B8026 /* b2TimeStep.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2TimeStep.h; sourceTree = ""; }; 46A168E51807AF9C005B8026 /* b2World.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2World.cpp; sourceTree = ""; }; 46A168E61807AF9C005B8026 /* b2World.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2World.h; sourceTree = ""; }; 46A168E71807AF9C005B8026 /* b2WorldCallbacks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2WorldCallbacks.cpp; sourceTree = ""; }; 46A168E81807AF9C005B8026 /* b2WorldCallbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2WorldCallbacks.h; sourceTree = ""; }; 46A168EA1807AF9C005B8026 /* b2ChainAndCircleContact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2ChainAndCircleContact.cpp; sourceTree = ""; }; 46A168EB1807AF9C005B8026 /* b2ChainAndCircleContact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2ChainAndCircleContact.h; sourceTree = ""; }; 46A168EC1807AF9C005B8026 /* b2ChainAndPolygonContact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2ChainAndPolygonContact.cpp; sourceTree = ""; }; 46A168ED1807AF9C005B8026 /* b2ChainAndPolygonContact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2ChainAndPolygonContact.h; sourceTree = ""; }; 46A168EE1807AF9C005B8026 /* b2CircleContact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2CircleContact.cpp; sourceTree = ""; }; 46A168EF1807AF9C005B8026 /* b2CircleContact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2CircleContact.h; sourceTree = ""; }; 46A168F01807AF9C005B8026 /* b2Contact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Contact.cpp; sourceTree = ""; }; 46A168F11807AF9C005B8026 /* b2Contact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Contact.h; sourceTree = ""; }; 46A168F21807AF9C005B8026 /* b2ContactSolver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2ContactSolver.cpp; sourceTree = ""; }; 46A168F31807AF9C005B8026 /* b2ContactSolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2ContactSolver.h; sourceTree = ""; }; 46A168F41807AF9C005B8026 /* b2EdgeAndCircleContact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2EdgeAndCircleContact.cpp; sourceTree = ""; }; 46A168F51807AF9C005B8026 /* b2EdgeAndCircleContact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2EdgeAndCircleContact.h; sourceTree = ""; }; 46A168F61807AF9C005B8026 /* b2EdgeAndPolygonContact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2EdgeAndPolygonContact.cpp; sourceTree = ""; }; 46A168F71807AF9C005B8026 /* b2EdgeAndPolygonContact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2EdgeAndPolygonContact.h; sourceTree = ""; }; 46A168F81807AF9C005B8026 /* b2PolygonAndCircleContact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2PolygonAndCircleContact.cpp; sourceTree = ""; }; 46A168F91807AF9C005B8026 /* b2PolygonAndCircleContact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2PolygonAndCircleContact.h; sourceTree = ""; }; 46A168FA1807AF9C005B8026 /* b2PolygonContact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2PolygonContact.cpp; sourceTree = ""; }; 46A168FB1807AF9C005B8026 /* b2PolygonContact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2PolygonContact.h; sourceTree = ""; }; 46A168FD1807AF9C005B8026 /* b2DistanceJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2DistanceJoint.cpp; sourceTree = ""; }; 46A168FE1807AF9C005B8026 /* b2DistanceJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2DistanceJoint.h; sourceTree = ""; }; 46A168FF1807AF9C005B8026 /* b2FrictionJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2FrictionJoint.cpp; sourceTree = ""; }; 46A169001807AF9C005B8026 /* b2FrictionJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2FrictionJoint.h; sourceTree = ""; }; 46A169011807AF9C005B8026 /* b2GearJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2GearJoint.cpp; sourceTree = ""; }; 46A169021807AF9C005B8026 /* b2GearJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2GearJoint.h; sourceTree = ""; }; 46A169031807AF9C005B8026 /* b2Joint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Joint.cpp; sourceTree = ""; }; 46A169041807AF9C005B8026 /* b2Joint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Joint.h; sourceTree = ""; }; 46A169051807AF9C005B8026 /* b2MouseJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2MouseJoint.cpp; sourceTree = ""; }; 46A169061807AF9C005B8026 /* b2MouseJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2MouseJoint.h; sourceTree = ""; }; 46A169071807AF9C005B8026 /* b2PrismaticJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2PrismaticJoint.cpp; sourceTree = ""; }; 46A169081807AF9C005B8026 /* b2PrismaticJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2PrismaticJoint.h; sourceTree = ""; }; 46A169091807AF9C005B8026 /* b2PulleyJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2PulleyJoint.cpp; sourceTree = ""; }; 46A1690A1807AF9C005B8026 /* b2PulleyJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2PulleyJoint.h; sourceTree = ""; }; 46A1690B1807AF9C005B8026 /* b2RevoluteJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2RevoluteJoint.cpp; sourceTree = ""; }; 46A1690C1807AF9C005B8026 /* b2RevoluteJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2RevoluteJoint.h; sourceTree = ""; }; 46A1690D1807AF9C005B8026 /* b2RopeJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2RopeJoint.cpp; sourceTree = ""; }; 46A1690E1807AF9C005B8026 /* b2RopeJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2RopeJoint.h; sourceTree = ""; }; 46A1690F1807AF9C005B8026 /* b2WeldJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2WeldJoint.cpp; sourceTree = ""; }; 46A169101807AF9C005B8026 /* b2WeldJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2WeldJoint.h; sourceTree = ""; }; 46A169111807AF9C005B8026 /* b2WheelJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2WheelJoint.cpp; sourceTree = ""; }; 46A169121807AF9C005B8026 /* b2WheelJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2WheelJoint.h; sourceTree = ""; }; 46A169321807AF9C005B8026 /* b2Rope.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2Rope.cpp; sourceTree = ""; }; 46A169331807AF9C005B8026 /* b2Rope.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Rope.h; sourceTree = ""; }; 46A169401807AFD6005B8026 /* chipmunk.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = chipmunk.h; sourceTree = ""; }; 46A169411807AFD6005B8026 /* chipmunk_ffi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = chipmunk_ffi.h; sourceTree = ""; }; 46A169421807AFD6005B8026 /* chipmunk_private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = chipmunk_private.h; sourceTree = ""; }; 46A169431807AFD6005B8026 /* chipmunk_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = chipmunk_types.h; sourceTree = ""; }; 46A169441807AFD6005B8026 /* chipmunk_unsafe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = chipmunk_unsafe.h; sourceTree = ""; }; 46A169461807AFD6005B8026 /* cpConstraint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpConstraint.h; sourceTree = ""; }; 46A169471807AFD6005B8026 /* cpDampedRotarySpring.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpDampedRotarySpring.h; sourceTree = ""; }; 46A169481807AFD6005B8026 /* cpDampedSpring.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpDampedSpring.h; sourceTree = ""; }; 46A169491807AFD6005B8026 /* cpGearJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpGearJoint.h; sourceTree = ""; }; 46A1694A1807AFD6005B8026 /* cpGrooveJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpGrooveJoint.h; sourceTree = ""; }; 46A1694B1807AFD6005B8026 /* cpPinJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpPinJoint.h; sourceTree = ""; }; 46A1694C1807AFD6005B8026 /* cpPivotJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpPivotJoint.h; sourceTree = ""; }; 46A1694D1807AFD6005B8026 /* cpRatchetJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpRatchetJoint.h; sourceTree = ""; }; 46A1694E1807AFD6005B8026 /* cpRotaryLimitJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpRotaryLimitJoint.h; sourceTree = ""; }; 46A1694F1807AFD6005B8026 /* cpSimpleMotor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpSimpleMotor.h; sourceTree = ""; }; 46A169501807AFD6005B8026 /* cpSlideJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpSlideJoint.h; sourceTree = ""; }; 46A169511807AFD6005B8026 /* util.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = ""; }; 46A169521807AFD6005B8026 /* cpArbiter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpArbiter.h; sourceTree = ""; }; 46A169531807AFD6005B8026 /* cpBB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpBB.h; sourceTree = ""; }; 46A169541807AFD6005B8026 /* cpBody.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpBody.h; sourceTree = ""; }; 46A169551807AFD6005B8026 /* cpPolyShape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpPolyShape.h; sourceTree = ""; }; 46A169561807AFD6005B8026 /* cpShape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpShape.h; sourceTree = ""; }; 46A169571807AFD6005B8026 /* cpSpace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpSpace.h; sourceTree = ""; }; 46A169581807AFD6005B8026 /* cpSpatialIndex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpSpatialIndex.h; sourceTree = ""; }; 46A169591807AFD6005B8026 /* cpVect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cpVect.h; sourceTree = ""; }; 46A1697B1807AFD6005B8026 /* chipmunk.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = chipmunk.c; sourceTree = ""; }; 46A1697C1807AFD6005B8026 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 46A1697E1807AFD6005B8026 /* cpConstraint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpConstraint.c; sourceTree = ""; }; 46A1697F1807AFD6005B8026 /* cpDampedRotarySpring.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpDampedRotarySpring.c; sourceTree = ""; }; 46A169801807AFD6005B8026 /* cpDampedSpring.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpDampedSpring.c; sourceTree = ""; }; 46A169811807AFD6005B8026 /* cpGearJoint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpGearJoint.c; sourceTree = ""; }; 46A169821807AFD6005B8026 /* cpGrooveJoint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpGrooveJoint.c; sourceTree = ""; }; 46A169831807AFD6005B8026 /* cpPinJoint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpPinJoint.c; sourceTree = ""; }; 46A169841807AFD6005B8026 /* cpPivotJoint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpPivotJoint.c; sourceTree = ""; }; 46A169851807AFD6005B8026 /* cpRatchetJoint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpRatchetJoint.c; sourceTree = ""; }; 46A169861807AFD6005B8026 /* cpRotaryLimitJoint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpRotaryLimitJoint.c; sourceTree = ""; }; 46A169871807AFD6005B8026 /* cpSimpleMotor.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSimpleMotor.c; sourceTree = ""; }; 46A169881807AFD6005B8026 /* cpSlideJoint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSlideJoint.c; sourceTree = ""; }; 46A169891807AFD6005B8026 /* cpArbiter.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpArbiter.c; sourceTree = ""; }; 46A1698A1807AFD6005B8026 /* cpArray.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpArray.c; sourceTree = ""; }; 46A1698B1807AFD6005B8026 /* cpBB.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpBB.c; sourceTree = ""; }; 46A1698C1807AFD6005B8026 /* cpBBTree.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpBBTree.c; sourceTree = ""; }; 46A1698D1807AFD6005B8026 /* cpBody.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpBody.c; sourceTree = ""; }; 46A1698E1807AFD6005B8026 /* cpCollision.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpCollision.c; sourceTree = ""; }; 46A1698F1807AFD6005B8026 /* cpHashSet.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpHashSet.c; sourceTree = ""; }; 46A169901807AFD6005B8026 /* cpPolyShape.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpPolyShape.c; sourceTree = ""; }; 46A169911807AFD6005B8026 /* cpShape.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpShape.c; sourceTree = ""; }; 46A169921807AFD6005B8026 /* cpSpace.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSpace.c; sourceTree = ""; }; 46A169931807AFD6005B8026 /* cpSpaceComponent.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSpaceComponent.c; sourceTree = ""; }; 46A169941807AFD6005B8026 /* cpSpaceHash.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSpaceHash.c; sourceTree = ""; }; 46A169951807AFD6005B8026 /* cpSpaceQuery.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSpaceQuery.c; sourceTree = ""; }; 46A169961807AFD6005B8026 /* cpSpaceStep.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSpaceStep.c; sourceTree = ""; }; 46A169971807AFD6005B8026 /* cpSpatialIndex.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSpatialIndex.c; sourceTree = ""; }; 46A169981807AFD6005B8026 /* cpSweep1D.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpSweep1D.c; sourceTree = ""; }; 46A169991807AFD6005B8026 /* cpVect.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cpVect.c; sourceTree = ""; }; 46A1699A1807AFD6005B8026 /* prime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = prime.h; sourceTree = ""; }; 46A16A8F1807B038005B8026 /* CCFileUtilsApple.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCFileUtilsApple.h; sourceTree = ""; }; 46A16A901807B038005B8026 /* CCFileUtilsApple.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCFileUtilsApple.mm; sourceTree = ""; }; 46A16A911807B038005B8026 /* CCLock.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCLock.cpp; sourceTree = ""; }; 46A16A921807B038005B8026 /* CCLock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCLock.h; sourceTree = ""; }; 46A16A931807B038005B8026 /* CCThread.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCThread.mm; sourceTree = ""; }; 46A16A941807B038005B8026 /* CCApplicationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCApplicationProtocol.h; sourceTree = ""; }; 46A16A951807B038005B8026 /* CCCommon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCCommon.h; sourceTree = ""; }; 46A16A961807B038005B8026 /* CCDevice.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCDevice.h; sourceTree = ""; }; 46A16A971807B038005B8026 /* CCEGLViewProtocol.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEGLViewProtocol.cpp; sourceTree = ""; }; 46A16A981807B038005B8026 /* CCEGLViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEGLViewProtocol.h; sourceTree = ""; }; 46A16A991807B038005B8026 /* CCFileUtils.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCFileUtils.cpp; sourceTree = ""; }; 46A16A9A1807B038005B8026 /* CCFileUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCFileUtils.h; sourceTree = ""; }; 46A16A9B1807B038005B8026 /* CCImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCImage.h; sourceTree = ""; }; 46A16A9F1807B038005B8026 /* CCSAXParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCSAXParser.cpp; sourceTree = ""; }; 46A16AA01807B038005B8026 /* CCSAXParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCSAXParser.h; sourceTree = ""; }; 46A16AA11807B038005B8026 /* CCThread.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCThread.cpp; sourceTree = ""; }; 46A16AA21807B038005B8026 /* CCThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCThread.h; sourceTree = ""; }; 46A16AA41807B038005B8026 /* CCApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCApplication.h; sourceTree = ""; }; 46A16AA51807B038005B8026 /* CCApplication.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCApplication.mm; sourceTree = ""; }; 46A16AA61807B038005B8026 /* CCCommon.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCCommon.mm; sourceTree = ""; }; 46A16AA71807B038005B8026 /* CCDevice.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCDevice.mm; sourceTree = ""; }; 46A16AA81807B038005B8026 /* CCDirectorCaller.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCDirectorCaller.h; sourceTree = ""; }; 46A16AA91807B038005B8026 /* CCDirectorCaller.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCDirectorCaller.mm; sourceTree = ""; }; 46A16AAA1807B038005B8026 /* CCEGLView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEGLView.h; sourceTree = ""; }; 46A16AAB1807B038005B8026 /* CCEGLView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEGLView.mm; sourceTree = ""; }; 46A16AAC1807B038005B8026 /* CCES2Renderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCES2Renderer.h; sourceTree = ""; }; 46A16AAD1807B038005B8026 /* CCES2Renderer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CCES2Renderer.m; sourceTree = ""; }; 46A16AAE1807B038005B8026 /* CCESRenderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCESRenderer.h; sourceTree = ""; }; 46A16AB01807B038005B8026 /* CCImage.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCImage.mm; sourceTree = ""; }; 46A16AB11807B038005B8026 /* CCPlatformDefine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPlatformDefine.h; sourceTree = ""; }; 46A16AB21807B038005B8026 /* CCStdC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCStdC.h; sourceTree = ""; }; 46A16AB41807B038005B8026 /* EAGLView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = EAGLView.mm; sourceTree = ""; }; 46A16AB51807B038005B8026 /* OpenGL_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OpenGL_Internal.h; sourceTree = ""; }; 46A16AB71807B038005B8026 /* AccelerometerSimulation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccelerometerSimulation.h; sourceTree = ""; }; 46A16AB81807B038005B8026 /* AccelerometerSimulation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccelerometerSimulation.m; sourceTree = ""; }; 46A16AC81807B038005B8026 /* CCApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCApplication.h; sourceTree = ""; }; 46A16AC91807B038005B8026 /* CCApplication.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCApplication.mm; sourceTree = ""; }; 46A16ACA1807B038005B8026 /* CCCommon.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCCommon.mm; sourceTree = ""; }; 46A16ACB1807B038005B8026 /* CCDevice.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCDevice.cpp; sourceTree = ""; }; 46A16ACC1807B038005B8026 /* CCDirectorCaller.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCDirectorCaller.h; sourceTree = ""; }; 46A16ACD1807B038005B8026 /* CCDirectorCaller.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCDirectorCaller.mm; sourceTree = ""; }; 46A16AD31807B038005B8026 /* CCImage.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCImage.mm; sourceTree = ""; }; 46A16AD41807B038005B8026 /* CCPlatformDefine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPlatformDefine.h; sourceTree = ""; }; 46A16AD51807B038005B8026 /* CCStdC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCStdC.h; sourceTree = ""; }; 46A16E1B1807C948005B8026 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../cocos/2d/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; 46A16E1C1807C948005B8026 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = ../cocos/2d/platform/third_party/ios/libraries/libfreetype.a; sourceTree = ""; }; 46A16E1D1807C948005B8026 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjpeg.a; path = ../cocos/2d/platform/third_party/ios/libraries/libjpeg.a; sourceTree = ""; }; 46A16E1E1807C948005B8026 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = ../cocos/2d/platform/third_party/ios/libraries/libpng.a; sourceTree = ""; }; 46A16E1F1807C948005B8026 /* libtiff.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtiff.a; path = ../cocos/2d/platform/third_party/ios/libraries/libtiff.a; sourceTree = ""; }; 46A16E201807C948005B8026 /* libwebp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libwebp.a; path = ../cocos/2d/platform/third_party/ios/libraries/libwebp.a; sourceTree = ""; }; 46A16E211807C95C005B8026 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = ../cocos/2d/platform/third_party/mac/libraries/libfreetype.a; sourceTree = ""; }; 46A16E221807C95C005B8026 /* libglfw3.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libglfw3.a; path = ../cocos/2d/platform/third_party/mac/libraries/libglfw3.a; sourceTree = ""; }; 46A16E231807C95C005B8026 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjpeg.a; path = ../cocos/2d/platform/third_party/mac/libraries/libjpeg.a; sourceTree = ""; }; 46A16E241807C95C005B8026 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = ../cocos/2d/platform/third_party/mac/libraries/libpng.a; sourceTree = ""; }; 46A16E251807C95C005B8026 /* libtiff.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtiff.a; path = ../cocos/2d/platform/third_party/mac/libraries/libtiff.a; sourceTree = ""; }; 46A16E261807C95C005B8026 /* libwebp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libwebp.a; path = ../cocos/2d/platform/third_party/mac/libraries/libwebp.a; sourceTree = ""; }; 46A16E271807C992005B8026 /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libwebsockets.a; path = ../external/libwebsockets/ios/lib/libwebsockets.a; sourceTree = ""; }; 46A16E281807C99F005B8026 /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libwebsockets.a; path = ../external/libwebsockets/mac/lib/libwebsockets.a; sourceTree = ""; }; 46A1706E1807CE7A005B8026 /* CCPhysicsBody.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsBody.cpp; sourceTree = ""; }; 46A1706F1807CE7A005B8026 /* CCPhysicsBody.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPhysicsBody.h; sourceTree = ""; }; 46A170701807CE7A005B8026 /* CCPhysicsContact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsContact.cpp; sourceTree = ""; }; 46A170711807CE7A005B8026 /* CCPhysicsContact.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPhysicsContact.h; sourceTree = ""; }; 46A170721807CE7A005B8026 /* CCPhysicsJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsJoint.cpp; sourceTree = ""; }; 46A170731807CE7A005B8026 /* CCPhysicsJoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPhysicsJoint.h; sourceTree = ""; }; 46A170751807CE7A005B8026 /* CCPhysicsShape.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsShape.cpp; sourceTree = ""; }; 46A170761807CE7A005B8026 /* CCPhysicsShape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPhysicsShape.h; sourceTree = ""; }; 46A170771807CE7A005B8026 /* CCPhysicsWorld.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsWorld.cpp; sourceTree = ""; }; 46A170781807CE7A005B8026 /* CCPhysicsWorld.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPhysicsWorld.h; sourceTree = ""; }; 46A170891807CE87005B8026 /* aabb.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = aabb.h; sourceTree = ""; }; 46A1708B1807CE87005B8026 /* mat4stack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mat4stack.h; sourceTree = ""; }; 46A1708C1807CE87005B8026 /* matrix.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = matrix.h; sourceTree = ""; }; 46A1708D1807CE87005B8026 /* kazmath.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = kazmath.h; sourceTree = ""; }; 46A1708E1807CE87005B8026 /* mat3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mat3.h; sourceTree = ""; }; 46A1708F1807CE87005B8026 /* mat4.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mat4.h; sourceTree = ""; }; 46A170901807CE87005B8026 /* neon_matrix_impl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = neon_matrix_impl.h; sourceTree = ""; }; 46A170911807CE87005B8026 /* plane.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = plane.h; sourceTree = ""; }; 46A170921807CE87005B8026 /* quaternion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = quaternion.h; sourceTree = ""; }; 46A170931807CE87005B8026 /* ray2.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ray2.h; sourceTree = ""; }; 46A170941807CE87005B8026 /* utility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = utility.h; sourceTree = ""; }; 46A170951807CE87005B8026 /* vec2.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vec2.h; sourceTree = ""; }; 46A170961807CE87005B8026 /* vec3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vec3.h; sourceTree = ""; }; 46A170971807CE87005B8026 /* vec4.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = vec4.h; sourceTree = ""; }; 46A170991807CE87005B8026 /* aabb.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = aabb.c; sourceTree = ""; }; 46A1709A1807CE87005B8026 /* ChangeLog */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChangeLog; sourceTree = ""; }; 46A1709B1807CE87005B8026 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 46A1709D1807CE87005B8026 /* mat4stack.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mat4stack.c; sourceTree = ""; }; 46A1709E1807CE87005B8026 /* matrix.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = matrix.c; sourceTree = ""; }; 46A1709F1807CE87005B8026 /* mat3.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mat3.c; sourceTree = ""; }; 46A170A01807CE87005B8026 /* mat4.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mat4.c; sourceTree = ""; }; 46A170A11807CE87005B8026 /* neon_matrix_impl.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = neon_matrix_impl.c; sourceTree = ""; }; 46A170A21807CE87005B8026 /* plane.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = plane.c; sourceTree = ""; }; 46A170A31807CE87005B8026 /* quaternion.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = quaternion.c; sourceTree = ""; }; 46A170A41807CE87005B8026 /* ray2.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ray2.c; sourceTree = ""; }; 46A170A51807CE87005B8026 /* utility.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = utility.c; sourceTree = ""; }; 46A170A61807CE87005B8026 /* vec2.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = vec2.c; sourceTree = ""; }; 46A170A71807CE87005B8026 /* vec3.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = vec3.c; sourceTree = ""; }; 46A170A81807CE87005B8026 /* vec4.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = vec4.c; sourceTree = ""; }; 5069133C185016C1009BBDD7 /* CCConsole.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCConsole.cpp; path = ../base/CCConsole.cpp; sourceTree = ""; }; 5069133D185016C1009BBDD7 /* CCConsole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCConsole.h; path = ../base/CCConsole.h; sourceTree = ""; }; 50A1FF1618290ED4001840C4 /* UIListView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIListView.cpp; sourceTree = ""; }; 50A1FF1718290ED4001840C4 /* UIListView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIListView.h; sourceTree = ""; }; 50AE5EA1188749250007CFE3 /* CCBatchCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBatchCommand.cpp; sourceTree = ""; }; 50AE5EA2188749250007CFE3 /* CCBatchCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBatchCommand.h; sourceTree = ""; }; 50DC5180187B817900A9C23F /* RELEASE_NOTES.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = RELEASE_NOTES.md; path = ../docs/RELEASE_NOTES.md; sourceTree = ""; }; 593BDCD8184D0A6E00C21E48 /* CCCustomCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCCustomCommand.cpp; sourceTree = ""; }; 593BDCD9184D0A6E00C21E48 /* CCCustomCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCCustomCommand.h; sourceTree = ""; }; 593BDCDA184D0A6E00C21E48 /* CCGroupCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGroupCommand.cpp; sourceTree = ""; }; 593BDCDB184D0A6E00C21E48 /* CCGroupCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGroupCommand.h; sourceTree = ""; }; 59A79D4D1821E26E00F19697 /* CCEventListenerMouse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventListenerMouse.cpp; sourceTree = ""; }; 59A79D4E1821E26E00F19697 /* CCEventListenerMouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventListenerMouse.h; sourceTree = ""; }; 59A79D4F1821E26E00F19697 /* CCEventMouse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEventMouse.cpp; sourceTree = ""; }; 59A79D501821E26E00F19697 /* CCEventMouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEventMouse.h; sourceTree = ""; }; 74AC800F4905C8827A44EED3 /* CCMaterialManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMaterialManager.h; sourceTree = ""; }; 74AC80EEB031D67E86B45096 /* CCFrustum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFrustum.cpp; sourceTree = ""; }; 74AC80F6E92FC29EA536D7F8 /* CCRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCRenderCommand.cpp; sourceTree = ""; }; 74AC82DE19B10586E1C39974 /* CCRenderMaterial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCRenderMaterial.cpp; sourceTree = ""; }; 74AC840F2F17ED6D0163669F /* CCFrustum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFrustum.h; sourceTree = ""; }; 74AC853F6B597094730AFB36 /* CCMaterialManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMaterialManager.cpp; sourceTree = ""; }; 74AC8C4AE1EB0FCB287E7396 /* CCQuadCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCQuadCommand.h; sourceTree = ""; }; 74AC8CC6504014E3A59C55B2 /* CCRenderMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRenderMaterial.h; sourceTree = ""; }; 74AC8D28EF93BFF332D3C456 /* CCQuadCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCQuadCommand.cpp; sourceTree = ""; }; 74AC8DF0EA49A124E1B11681 /* CCRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRenderer.h; sourceTree = ""; }; 74AC8EB8FE47EED9B30B7106 /* CCRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCRenderer.cpp; sourceTree = ""; }; 74AC8F4F7D9E52FCB522B647 /* CCRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRenderCommand.h; sourceTree = ""; }; A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_frag.h; sourceTree = ""; }; A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_vert.h; sourceTree = ""; }; A03F2CB81780BD04006731B9 /* libchipmunk Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libchipmunk Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2D9B1780BDF7006731B9 /* libbox2d Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libbox2d Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2ED617814268006731B9 /* libCocosDenshion Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libCocosDenshion Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2FD617814595006731B9 /* libcocos2dx-extensions Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2dx-extensions Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F31FD1781479B006731B9 /* libjsbindings Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libjsbindings Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A04583F0189053B500E32FE8 /* CCEGLView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCEGLView.cpp; sourceTree = ""; }; A04583F1189053B500E32FE8 /* CCEGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEGLView.h; sourceTree = ""; }; A07A4D641783777C0073F6A7 /* libcocos2dx iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2dx iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A4EFC1783867C0073F6A7 /* libcocos2dx-extensions iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2dx-extensions iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A4F3B178387670073F6A7 /* libchipmunk iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libchipmunk iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A4F9E1783876B0073F6A7 /* libbox2d iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libbox2d iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A4FB4178387730073F6A7 /* libCocosDenshion iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libCocosDenshion iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A5030178387750073F6A7 /* libjsbindings iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libjsbindings iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A0E6B27F18613EA5009C5D17 /* CCRenderCommandPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRenderCommandPool.h; sourceTree = ""; }; B362C3A21872B37200F0BDF4 /* lua_cocos2dx_physics_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_physics_auto.cpp; sourceTree = ""; }; B362C3A31872B37200F0BDF4 /* lua_cocos2dx_physics_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_physics_auto.hpp; sourceTree = ""; }; B362C3A41872B4E900F0BDF4 /* lua_cocos2dx_physics_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_physics_manual.cpp; sourceTree = ""; }; B362C3A51872B4E900F0BDF4 /* lua_cocos2dx_physics_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_physics_manual.hpp; sourceTree = ""; }; B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsBodyInfo_chipmunk.cpp; sourceTree = ""; }; B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsBodyInfo_chipmunk.h; sourceTree = ""; }; B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsContactInfo_chipmunk.cpp; sourceTree = ""; }; B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsContactInfo_chipmunk.h; sourceTree = ""; }; B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsHelper_chipmunk.h; sourceTree = ""; }; B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsJointInfo_chipmunk.cpp; sourceTree = ""; }; B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsJointInfo_chipmunk.h; sourceTree = ""; }; B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsShapeInfo_chipmunk.cpp; sourceTree = ""; }; B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsShapeInfo_chipmunk.h; sourceTree = ""; }; B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsWorldInfo_chipmunk.cpp; sourceTree = ""; }; B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsWorldInfo_chipmunk.h; sourceTree = ""; }; B3AF019E1842FBA400A98B85 /* b2MotorJoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = b2MotorJoint.cpp; sourceTree = ""; }; B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = ""; }; ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCNodeGrid.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeGrid.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 1551A33C158F2AB200E66CFE /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( B3B12A5A17E7F44000026B4A /* libchipmunk Mac.a in Frameworks */, 1A94D35116C2072800D79D09 /* Foundation.framework in Frameworks */, 1A570347180BD0850088DEC7 /* libglfw3.a in Frameworks */, 1A570361180BD1080088DEC7 /* libpng.a in Frameworks */, 1A57037B180BD1C90088DEC7 /* libjpeg.a in Frameworks */, 1A5703A1180BD22C0088DEC7 /* libtiff.a in Frameworks */, 1A5703B8180BD2780088DEC7 /* libwebp.a in Frameworks */, 1A57052B180BD31F0088DEC7 /* libfreetype.a in Frameworks */, 1AAF5385180E35A3000584C8 /* libwebsockets.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A11972D178526AA00D62A44 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 15996080181132DE00C7D42C /* libluajit.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB51817854BC200CDF010 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1599607B1811329600C7D42C /* libluajit.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2C011780BD04006731B9 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; A03F2D7C1780BDF7006731B9 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; A03F2EB717814268006731B9 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; A03F2FC917814595006731B9 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; A03F31F01781479B006731B9 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A9DCA4D180E6E3C007A3AD4 /* libjs_static.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4CAD1783777C0073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( B3B12A5B17E7F45C00026B4A /* libchipmunk iOS.a in Frameworks */, A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */, 1A570364180BD1120088DEC7 /* libpng.a in Frameworks */, 1A570378180BD1B40088DEC7 /* libjpeg.a in Frameworks */, 1A5703A4180BD2350088DEC7 /* libtiff.a in Frameworks */, 1A5703BB180BD2800088DEC7 /* libwebp.a in Frameworks */, 1A57052E180BD3280088DEC7 /* libfreetype.a in Frameworks */, 1AAF5388180E35AC000584C8 /* libwebsockets.a in Frameworks */, 1AAF541D180E3B6A000584C8 /* libcurl.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4E7B1783867C0073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; A07A4F1C178387670073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; A07A4F6B1783876B0073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; A07A4FA7178387730073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; A07A4FCC178387750073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A9DCA4E180E6E42007A3AD4 /* libjs_static.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 1551A334158F2AB200E66CFE = { isa = PBXGroup; children = ( 46A15FCC1807A544005B8026 /* AUTHORS */, 1A57FFF7180BC5160088DEC7 /* CHANGELOG */, 46A15FCE1807A544005B8026 /* README.md */, 50DC5180187B817900A9C23F /* RELEASE_NOTES.md */, 46A169A11807B037005B8026 /* 2d */, 46A15FD01807A56F005B8026 /* audio */, 1A5700A2180BC5E60088DEC7 /* base */, 1AD71CF7180E26E600808F54 /* editor-support */, 46A167981807AF4D005B8026 /* extensions */, 1A57033E180BD0490088DEC7 /* external */, 1551A341158F2AB200E66CFE /* Frameworks */, 1A8C58BD180E92CC00EF57C3 /* gui */, 46A170851807CE87005B8026 /* math */, 1AAF5360180E3374000584C8 /* network */, 46A170611807CE7A005B8026 /* physics */, 1551A340158F2AB200E66CFE /* Products */, 1AAF5426180E409E000584C8 /* scripting */, 1AAF5849180E40B8000584C8 /* storage */, ); sourceTree = ""; }; 1551A340158F2AB200E66CFE /* Products */ = { isa = PBXGroup; children = ( 1551A33F158F2AB200E66CFE /* libcocos2dx Mac.a */, A03F2CB81780BD04006731B9 /* libchipmunk Mac.a */, A03F2D9B1780BDF7006731B9 /* libbox2d Mac.a */, A03F2ED617814268006731B9 /* libCocosDenshion Mac.a */, A03F2FD617814595006731B9 /* libcocos2dx-extensions Mac.a */, A03F31FD1781479B006731B9 /* libjsbindings Mac.a */, A07A4D641783777C0073F6A7 /* libcocos2dx iOS.a */, A07A4EFC1783867C0073F6A7 /* libcocos2dx-extensions iOS.a */, A07A4F3B178387670073F6A7 /* libchipmunk iOS.a */, A07A4F9E1783876B0073F6A7 /* libbox2d iOS.a */, A07A4FB4178387730073F6A7 /* libCocosDenshion iOS.a */, A07A5030178387750073F6A7 /* libjsbindings iOS.a */, 1A119791178526AA00D62A44 /* libluabindings iOS.a */, 1A6FB53017854BC300CDF010 /* libluabindings Mac.a */, ); name = Products; sourceTree = ""; }; 1551A341158F2AB200E66CFE /* Frameworks */ = { isa = PBXGroup; children = ( B3D8D44B179921D50039C204 /* ios */, B3D8D4471799219B0039C204 /* mac */, 1551A342158F2AB200E66CFE /* Foundation.framework */, ); name = Frameworks; sourceTree = ""; }; 15A71D3B18921E6900F30AC0 /* socket */ = { isa = PBXGroup; children = ( 15A71D3C18921E6900F30AC0 /* auxiliar.c */, 15A71D3D18921E6900F30AC0 /* auxiliar.h */, 15A71D3E18921E6900F30AC0 /* except.c */, 15A71D3F18921E6900F30AC0 /* except.h */, 15A71D4018921E6900F30AC0 /* inet.c */, 15A71D4118921E6900F30AC0 /* inet.h */, 15A71D4218921E6900F30AC0 /* luasocket.c */, 15A71D4318921E6900F30AC0 /* luasocket.h */, 15A71D4418921E6900F30AC0 /* luasocket_buffer.c */, 15A71D4518921E6900F30AC0 /* luasocket_buffer.h */, 15A71D4618921E6900F30AC0 /* luasocket_io.c */, 15A71D4718921E6900F30AC0 /* luasocket_io.h */, 15A71D4818921E6900F30AC0 /* mime.c */, 15A71D4918921E6900F30AC0 /* mime.h */, 15A71D4A18921E6900F30AC0 /* options.c */, 15A71D4B18921E6900F30AC0 /* options.h */, 15A71D4C18921E6900F30AC0 /* select.c */, 15A71D4D18921E6900F30AC0 /* select.h */, 15A71D4E18921E6900F30AC0 /* serial.c */, 15A71D4F18921E6900F30AC0 /* socket.h */, 15A71D5018921E6900F30AC0 /* socket_scripts.c */, 15A71D5118921E6900F30AC0 /* socket_scripts.h */, 15A71D5218921E6900F30AC0 /* tcp.c */, 15A71D5318921E6900F30AC0 /* tcp.h */, 15A71D5418921E6900F30AC0 /* timeout.c */, 15A71D5518921E6900F30AC0 /* timeout.h */, 15A71D5618921E6900F30AC0 /* udp.c */, 15A71D5718921E6900F30AC0 /* udp.h */, 15A71D5818921E6900F30AC0 /* unix.c */, 15A71D5918921E6900F30AC0 /* unix.h */, 15A71D5A18921E6900F30AC0 /* usocket.c */, 15A71D5B18921E6900F30AC0 /* usocket.h */, 15A71D5D18921E6900F30AC0 /* wsocket.h */, ); path = socket; sourceTree = ""; }; 1A087AE51860400400196EF5 /* edtaa3func */ = { isa = PBXGroup; children = ( 1A087AE61860400400196EF5 /* edtaa3func.cpp */, 1A087AE71860400400196EF5 /* edtaa3func.h */, ); name = edtaa3func; path = ../external/edtaa3func; sourceTree = ""; }; 1A2C785C181A11EC004E5527 /* auto-generated */ = { isa = PBXGroup; children = ( 1A2C785D181A11EC004E5527 /* js-bindings */, 1A2C786A181A11EC004E5527 /* lua-bindings */, 1A2C7871181A11EC004E5527 /* README.md */, ); path = "auto-generated"; sourceTree = ""; }; 1A2C785D181A11EC004E5527 /* js-bindings */ = { isa = PBXGroup; children = ( 3EEF8BCB1839F390005E8A6C /* jsb_cocos2dx_gui_auto.cpp */, 3EEF8BCC1839F390005E8A6C /* jsb_cocos2dx_gui_auto.hpp */, 1A2C785E181A11EC004E5527 /* jsb_cocos2dx_auto.cpp */, 1A2C785F181A11EC004E5527 /* jsb_cocos2dx_auto.hpp */, 1A2C7861181A11EC004E5527 /* jsb_cocos2dx_builder_auto.cpp */, 1A2C7862181A11EC004E5527 /* jsb_cocos2dx_builder_auto.hpp */, 1A2C7864181A11EC004E5527 /* jsb_cocos2dx_extension_auto.cpp */, 1A2C7865181A11EC004E5527 /* jsb_cocos2dx_extension_auto.hpp */, 1A2C7867181A11EC004E5527 /* jsb_cocos2dx_studio_auto.cpp */, 1A2C7868181A11EC004E5527 /* jsb_cocos2dx_studio_auto.hpp */, 2AFCB81F1863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.cpp */, 2AFCB8201863D65D00EB4B5C /* jsb_cocos2dx_spine_auto.hpp */, ); path = "js-bindings"; sourceTree = ""; }; 1A2C786A181A11EC004E5527 /* lua-bindings */ = { isa = PBXGroup; children = ( B362C3A21872B37200F0BDF4 /* lua_cocos2dx_physics_auto.cpp */, B362C3A31872B37200F0BDF4 /* lua_cocos2dx_physics_auto.hpp */, 15F4C8801875637D0082884F /* lua_cocos2dx_gui_auto.cpp */, 15F4C8811875637D0082884F /* lua_cocos2dx_gui_auto.hpp */, 15CA8D1118697AE1000032AB /* lua_cocos2dx_spine_auto.cpp */, 15CA8D1218697AE1000032AB /* lua_cocos2dx_spine_auto.hpp */, 1585AB591828D74F00000FB5 /* lua_cocos2dx_studio_auto.cpp */, 1585AB5A1828D74F00000FB5 /* lua_cocos2dx_studio_auto.hpp */, 1A2C786B181A11EC004E5527 /* lua_cocos2dx_auto.cpp */, 1A2C786C181A11EC004E5527 /* lua_cocos2dx_auto.hpp */, 1A2C786E181A11EC004E5527 /* lua_cocos2dx_extension_auto.cpp */, 1A2C786F181A11EC004E5527 /* lua_cocos2dx_extension_auto.hpp */, ); path = "lua-bindings"; sourceTree = ""; }; 1A2C78BA181A1257004E5527 /* bindings */ = { isa = PBXGroup; children = ( 3EEF8BD01839F5A7005E8A6C /* gui */, 1A2C78BC181A1257004E5527 /* chipmunk */, 1A2C78CB181A1257004E5527 /* cocos2d_specifics.cpp */, 1A2C78CC181A1257004E5527 /* cocos2d_specifics.hpp */, 1A2C78CD181A1257004E5527 /* cocosbuilder */, 1A2C78D7181A1257004E5527 /* cocostudio */, 1A2C78DE181A1257004E5527 /* extension */, 1A2C78E5181A1257004E5527 /* js_bindings_config.h */, 1A2C78E6181A1257004E5527 /* js_bindings_core.cpp */, 1A2C78E7181A1257004E5527 /* js_bindings_core.h */, 1A2C78E8181A1257004E5527 /* js_bindings_opengl.cpp */, 1A2C78E9181A1257004E5527 /* js_bindings_opengl.h */, 1A2C78EA181A1257004E5527 /* js_manual_conversions.cpp */, 1A2C78EB181A1257004E5527 /* js_manual_conversions.h */, 1A2C78EC181A1257004E5527 /* jsb_helper.h */, 1A2C78ED181A1257004E5527 /* jsb_opengl_functions.cpp */, 1A2C78EE181A1257004E5527 /* jsb_opengl_functions.h */, 1A2C78EF181A1257004E5527 /* jsb_opengl_manual.cpp */, 1A2C78F0181A1257004E5527 /* jsb_opengl_manual.h */, 1A2C78F1181A1257004E5527 /* jsb_opengl_registration.cpp */, 1A2C78F2181A1257004E5527 /* jsb_opengl_registration.h */, 1A2C78F3181A1257004E5527 /* localstorage */, 1A2C78FD181A1257004E5527 /* network */, 1A2C790A181A1257004E5527 /* ScriptingCore.cpp */, 1A2C790B181A1257004E5527 /* ScriptingCore.h */, 1A2C790C181A1257004E5527 /* spidermonkey_specifics.h */, ); path = bindings; sourceTree = ""; }; 1A2C78BC181A1257004E5527 /* chipmunk */ = { isa = PBXGroup; children = ( 1A2C78BE181A1257004E5527 /* js_bindings_chipmunk_auto_classes.cpp */, 1A2C78BF181A1257004E5527 /* js_bindings_chipmunk_auto_classes.h */, 1A2C78C0181A1257004E5527 /* js_bindings_chipmunk_auto_classes_registration.h */, 1A2C78C1181A1257004E5527 /* js_bindings_chipmunk_functions.cpp */, 1A2C78C2181A1257004E5527 /* js_bindings_chipmunk_functions.h */, 1A2C78C3181A1257004E5527 /* js_bindings_chipmunk_functions_registration.h */, 1A2C78C4181A1257004E5527 /* js_bindings_chipmunk_manual.cpp */, 1A2C78C5181A1257004E5527 /* js_bindings_chipmunk_manual.h */, 1A2C78C6181A1257004E5527 /* js_bindings_chipmunk_registration.cpp */, 1A2C78C7181A1257004E5527 /* js_bindings_chipmunk_registration.h */, ); path = chipmunk; sourceTree = ""; }; 1A2C78CD181A1257004E5527 /* cocosbuilder */ = { isa = PBXGroup; children = ( 1A2C78CF181A1257004E5527 /* cocosbuilder_specifics.hpp */, 1A2C78D0181A1257004E5527 /* js_bindings_ccbreader.cpp */, 1A2C78D1181A1257004E5527 /* js_bindings_ccbreader.h */, ); path = cocosbuilder; sourceTree = ""; }; 1A2C78D7181A1257004E5527 /* cocostudio */ = { isa = PBXGroup; children = ( 1A2C78D9181A1257004E5527 /* jsb_cocos2dx_studio_manual.cpp */, 1A2C78DA181A1257004E5527 /* jsb_cocos2dx_studio_manual.h */, ); path = cocostudio; sourceTree = ""; }; 1A2C78DE181A1257004E5527 /* extension */ = { isa = PBXGroup; children = ( 1A2C78E0181A1257004E5527 /* jsb_cocos2dx_extension_manual.cpp */, 1A2C78E1181A1257004E5527 /* jsb_cocos2dx_extension_manual.h */, ); path = extension; sourceTree = ""; }; 1A2C78F3181A1257004E5527 /* localstorage */ = { isa = PBXGroup; children = ( 1A2C78F5181A1257004E5527 /* js_bindings_system_functions.cpp */, 1A2C78F6181A1257004E5527 /* js_bindings_system_functions.h */, 1A2C78F7181A1257004E5527 /* js_bindings_system_functions_registration.h */, 1A2C78F8181A1257004E5527 /* js_bindings_system_registration.cpp */, 1A2C78F9181A1257004E5527 /* js_bindings_system_registration.h */, ); path = localstorage; sourceTree = ""; }; 1A2C78FD181A1257004E5527 /* network */ = { isa = PBXGroup; children = ( 1A2C78FF181A1257004E5527 /* jsb_websocket.cpp */, 1A2C7900181A1257004E5527 /* jsb_websocket.h */, 1A2C7904181A1257004E5527 /* XMLHTTPRequest.cpp */, 1A2C7905181A1257004E5527 /* XMLHTTPRequest.h */, ); path = network; sourceTree = ""; }; 1A3B1F49180E887E00497A22 /* lua */ = { isa = PBXGroup; children = ( 1A3B1F4A180E88C200497A22 /* bindings */, ); name = lua; sourceTree = ""; }; 1A3B1F4A180E88C200497A22 /* bindings */ = { isa = PBXGroup; children = ( 15A71DA21892291500F30AC0 /* lua_extensions.c */, 15A71DA31892291500F30AC0 /* lua_extensions.h */, 15A71D3B18921E6900F30AC0 /* socket */, B362C3A41872B4E900F0BDF4 /* lua_cocos2dx_physics_manual.cpp */, B362C3A51872B4E900F0BDF4 /* lua_cocos2dx_physics_manual.hpp */, 15F4CA1D1875885A0082884F /* lua_cocos2dx_gui_manual.cpp */, 15F4CA1E1875885A0082884F /* lua_cocos2dx_gui_manual.hpp */, 15CA8D1718697BE5000032AB /* LuaSkeletonAnimation.cpp */, 15CA8D1818697BE5000032AB /* LuaSkeletonAnimation.h */, 15CA8D0B18697A56000032AB /* lua_cocos2dx_spine_manual.cpp */, 15CA8D0C18697A56000032AB /* lua_cocos2dx_spine_manual.hpp */, 15D6E843182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.cpp */, 15D6E844182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.hpp */, 158E06DC181F6796008E01F6 /* lua_xml_http_request.cpp */, 158E06DD181F6796008E01F6 /* lua_xml_http_request.h */, 1A3B1F4E180E88C200497A22 /* CCBProxy.cpp */, 1A3B1F4F180E88C200497A22 /* CCBProxy.h */, 1A3B1F50180E88C200497A22 /* CCLuaBridge.cpp */, 1A3B1F51180E88C200497A22 /* CCLuaBridge.h */, 1A3B1F52180E88C200497A22 /* CCLuaEngine.cpp */, 1A3B1F53180E88C200497A22 /* CCLuaEngine.h */, 1A3B1F54180E88C200497A22 /* CCLuaStack.cpp */, 1A3B1F55180E88C200497A22 /* CCLuaStack.h */, 1A3B1F56180E88C300497A22 /* CCLuaValue.cpp */, 1A3B1F57180E88C300497A22 /* CCLuaValue.h */, 1A3B1F58180E88C300497A22 /* Cocos2dxLuaLoader.cpp */, 1A3B1F59180E88C300497A22 /* Cocos2dxLuaLoader.h */, 1A3B1F5D180E88C300497A22 /* lua_cocos2dx_deprecated.cpp */, 1A3B1F5E180E88C300497A22 /* lua_cocos2dx_deprecated.h */, 1A3B1F5F180E88C300497A22 /* lua_cocos2dx_extension_manual.cpp */, 1A3B1F60180E88C300497A22 /* lua_cocos2dx_extension_manual.h */, 1A3B1F61180E88C300497A22 /* lua_cocos2dx_manual.cpp */, 1A3B1F62180E88C300497A22 /* lua_cocos2dx_manual.hpp */, 1A3B1F63180E88C300497A22 /* Lua_web_socket.cpp */, 1A3B1F64180E88C300497A22 /* Lua_web_socket.h */, 1A3B1F65180E88C300497A22 /* LuaBasicConversions.cpp */, 1A3B1F66180E88C300497A22 /* LuaBasicConversions.h */, 1A3B1F67180E88C300497A22 /* LuaOpengl.cpp */, 1A3B1F68180E88C300497A22 /* LuaOpengl.h */, 1A3B1F69180E88C300497A22 /* LuaScriptHandlerMgr.cpp */, 1A3B1F6A180E88C300497A22 /* LuaScriptHandlerMgr.h */, 1A3B1F6C180E88C300497A22 /* platform */, 1A3B1F76180E88C300497A22 /* tolua_fix.c */, 1A3B1F77180E88C300497A22 /* tolua_fix.h */, ); name = bindings; path = lua/bindings; sourceTree = ""; }; 1A3B1F6C180E88C300497A22 /* platform */ = { isa = PBXGroup; children = ( 1A3B1F73180E88C300497A22 /* ios */, ); path = platform; sourceTree = ""; }; 1A3B1F73180E88C300497A22 /* ios */ = { isa = PBXGroup; children = ( 1A3B1F74180E88C300497A22 /* CCLuaObjcBridge.h */, 1A3B1F75180E88C300497A22 /* CCLuaObjcBridge.mm */, ); path = ios; sourceTree = ""; }; 1A570046180BC59A0088DEC7 /* actions */ = { isa = PBXGroup; children = ( 1A570047180BC5A10088DEC7 /* CCAction.cpp */, 1A570048180BC5A10088DEC7 /* CCAction.h */, 1A570049180BC5A10088DEC7 /* CCActionCamera.cpp */, 1A57004A180BC5A10088DEC7 /* CCActionCamera.h */, 1A57004B180BC5A10088DEC7 /* CCActionCatmullRom.cpp */, 1A57004C180BC5A10088DEC7 /* CCActionCatmullRom.h */, 1A57004D180BC5A10088DEC7 /* CCActionEase.cpp */, 1A57004E180BC5A10088DEC7 /* CCActionEase.h */, 1A57004F180BC5A10088DEC7 /* CCActionGrid.cpp */, 1A570050180BC5A10088DEC7 /* CCActionGrid.h */, 1A570051180BC5A10088DEC7 /* CCActionGrid3D.cpp */, 1A570052180BC5A10088DEC7 /* CCActionGrid3D.h */, 1A570053180BC5A10088DEC7 /* CCActionInstant.cpp */, 1A570054180BC5A10088DEC7 /* CCActionInstant.h */, 1A570055180BC5A10088DEC7 /* CCActionInterval.cpp */, 1A570056180BC5A10088DEC7 /* CCActionInterval.h */, 1A570057180BC5A10088DEC7 /* CCActionManager.cpp */, 1A570058180BC5A10088DEC7 /* CCActionManager.h */, 1A570059180BC5A10088DEC7 /* CCActionPageTurn3D.cpp */, 1A57005A180BC5A10088DEC7 /* CCActionPageTurn3D.h */, 1A57005B180BC5A10088DEC7 /* CCActionProgressTimer.cpp */, 1A57005C180BC5A10088DEC7 /* CCActionProgressTimer.h */, 1A57005D180BC5A10088DEC7 /* CCActionTiledGrid.cpp */, 1A57005E180BC5A10088DEC7 /* CCActionTiledGrid.h */, 1A57005F180BC5A10088DEC7 /* CCActionTween.cpp */, 1A570060180BC5A10088DEC7 /* CCActionTween.h */, ); name = actions; sourceTree = ""; }; 1A570095180BC5B00088DEC7 /* base-nodes */ = { isa = PBXGroup; children = ( 1A57009C180BC5D20088DEC7 /* CCNode.cpp */, 1A57009D180BC5D20088DEC7 /* CCNode.h */, 1A570096180BC5C10088DEC7 /* CCAtlasNode.cpp */, 1A570097180BC5C10088DEC7 /* CCAtlasNode.h */, ); name = "base-nodes"; sourceTree = ""; }; 1A5700A2180BC5E60088DEC7 /* base */ = { isa = PBXGroup; children = ( 1A5700A3180BC6060088DEC7 /* atitc.cpp */, 1A5700A4180BC6060088DEC7 /* atitc.h */, 1A5700A5180BC6060088DEC7 /* CCAffineTransform.cpp */, 1A5700A6180BC6060088DEC7 /* CCAffineTransform.h */, 1A5700A7180BC6060088DEC7 /* CCArray.cpp */, 1A5700A8180BC6060088DEC7 /* CCArray.h */, 1A5700A9180BC6060088DEC7 /* CCAutoreleasePool.cpp */, 1A5700AA180BC6060088DEC7 /* CCAutoreleasePool.h */, 1A5700AB180BC6060088DEC7 /* CCBool.h */, 5069133C185016C1009BBDD7 /* CCConsole.cpp */, 5069133D185016C1009BBDD7 /* CCConsole.h */, 1A5700AC180BC6060088DEC7 /* CCData.cpp */, 1A5700AD180BC6060088DEC7 /* CCData.h */, 1A5700AE180BC6060088DEC7 /* CCDataVisitor.cpp */, 1A5700AF180BC6060088DEC7 /* CCDataVisitor.h */, 1A5700B0180BC6060088DEC7 /* CCDictionary.cpp */, 1A5700B1180BC6060088DEC7 /* CCDictionary.h */, 1A5700B2180BC6060088DEC7 /* CCDouble.h */, 1A5700B3180BC6060088DEC7 /* CCFloat.h */, 1A5700B4180BC6060088DEC7 /* CCGeometry.cpp */, 1A5700B5180BC6060088DEC7 /* CCGeometry.h */, 1A5700B6180BC6060088DEC7 /* CCInteger.h */, 1AA2063E1848437900053418 /* CCMap.h */, 1A5700B7180BC6060088DEC7 /* CCNS.cpp */, 1A5700B8180BC6060088DEC7 /* CCNS.h */, 1A5700B9180BC6060088DEC7 /* CCObject.cpp */, 1A5700BA180BC6060088DEC7 /* CCObject.h */, 1A5700BB180BC6060088DEC7 /* CCPlatformConfig.h */, 1A5700BC180BC6060088DEC7 /* CCPlatformMacros.h */, 1A5700BD180BC6060088DEC7 /* CCSet.cpp */, 1A5700BE180BC6060088DEC7 /* CCSet.h */, 1A5700BF180BC6060088DEC7 /* CCString.cpp */, 1A5700C0180BC6060088DEC7 /* CCString.h */, 1AE3C842184F14F700CF29B5 /* CCValue.cpp */, 1AE3C843184F14F700CF29B5 /* CCValue.h */, 1A85BA0C1845F31700260FC0 /* CCVector.h */, 1A5700C1180BC6060088DEC7 /* etc1.cpp */, 1A5700C2180BC6060088DEC7 /* etc1.h */, 1A5700C3180BC6060088DEC7 /* s3tc.cpp */, 1A5700C4180BC6060088DEC7 /* s3tc.h */, ); name = base; path = ../cocos/2d; sourceTree = ""; }; 1A570109180BC8DC0088DEC7 /* draw-nodes */ = { isa = PBXGroup; children = ( 1A57010A180BC8ED0088DEC7 /* CCDrawingPrimitives.cpp */, 1A57010B180BC8EE0088DEC7 /* CCDrawingPrimitives.h */, 1A57010C180BC8EE0088DEC7 /* CCDrawNode.cpp */, 1A57010D180BC8EE0088DEC7 /* CCDrawNode.h */, ); name = "draw-nodes"; sourceTree = ""; }; 1A570116180BC8FE0088DEC7 /* effects */ = { isa = PBXGroup; children = ( 1A570117180BC90D0088DEC7 /* CCGrabber.cpp */, 1A570118180BC90D0088DEC7 /* CCGrabber.h */, 1A570119180BC90D0088DEC7 /* CCGrid.cpp */, 1A57011A180BC90D0088DEC7 /* CCGrid.h */, ); name = effects; sourceTree = ""; }; 1A570123180BC9270088DEC7 /* event-dispatcher */ = { isa = PBXGroup; children = ( 59A79D4D1821E26E00F19697 /* CCEventListenerMouse.cpp */, 59A79D4E1821E26E00F19697 /* CCEventListenerMouse.h */, 59A79D4F1821E26E00F19697 /* CCEventMouse.cpp */, 59A79D501821E26E00F19697 /* CCEventMouse.h */, 1A570124180BC9460088DEC7 /* CCEvent.cpp */, 1A570125180BC9460088DEC7 /* CCEvent.h */, 1A570126180BC9460088DEC7 /* CCEventAcceleration.cpp */, 1A570127180BC9460088DEC7 /* CCEventAcceleration.h */, 1A570128180BC9460088DEC7 /* CCEventCustom.cpp */, 1A570129180BC9460088DEC7 /* CCEventCustom.h */, 1A57012A180BC9460088DEC7 /* CCEventDispatcher.cpp */, 1A57012B180BC9460088DEC7 /* CCEventDispatcher.h */, 1A57012C180BC9460088DEC7 /* CCEventKeyboard.cpp */, 1A57012D180BC9460088DEC7 /* CCEventKeyboard.h */, 1A57012E180BC9460088DEC7 /* CCEventListener.cpp */, 1A57012F180BC9460088DEC7 /* CCEventListener.h */, 1A570130180BC9460088DEC7 /* CCEventListenerAcceleration.cpp */, 1A570131180BC9460088DEC7 /* CCEventListenerAcceleration.h */, 1A570132180BC9460088DEC7 /* CCEventListenerCustom.cpp */, 1A570133180BC9460088DEC7 /* CCEventListenerCustom.h */, 1A570134180BC9460088DEC7 /* CCEventListenerKeyboard.cpp */, 1A570135180BC9460088DEC7 /* CCEventListenerKeyboard.h */, 1A570136180BC9460088DEC7 /* CCEventListenerTouch.cpp */, 1A570137180BC9460088DEC7 /* CCEventListenerTouch.h */, 1A570138180BC9460088DEC7 /* CCEventTouch.cpp */, 1A570139180BC9460088DEC7 /* CCEventTouch.h */, 1A570544180BD9C40088DEC7 /* CCTouch.cpp */, 1A570545180BD9C40088DEC7 /* CCTouch.h */, ); name = "event-dispatcher"; sourceTree = ""; }; 1A570181180BCB170088DEC7 /* label-nodes */ = { isa = PBXGroup; children = ( 1A570182180BCB590088DEC7 /* CCFont.cpp */, 1A570183180BCB590088DEC7 /* CCFont.h */, 1A570184180BCB590088DEC7 /* CCFontAtlas.cpp */, 1A570185180BCB590088DEC7 /* CCFontAtlas.h */, 1A570186180BCB590088DEC7 /* CCFontAtlasCache.cpp */, 1A570187180BCB590088DEC7 /* CCFontAtlasCache.h */, 1ABA68AC1888D700007D1BB4 /* CCFontCharMap.cpp */, 1ABA68AD1888D700007D1BB4 /* CCFontCharMap.h */, 1A57018C180BCB590088DEC7 /* CCFontFNT.cpp */, 1A57018D180BCB590088DEC7 /* CCFontFNT.h */, 1A57018E180BCB590088DEC7 /* CCFontFreeType.cpp */, 1A57018F180BCB590088DEC7 /* CCFontFreeType.h */, 1A570190180BCB590088DEC7 /* CCLabel.cpp */, 1A570191180BCB590088DEC7 /* CCLabel.h */, 1A570192180BCB590088DEC7 /* CCLabelAtlas.cpp */, 1A570193180BCB590088DEC7 /* CCLabelAtlas.h */, 1A570194180BCB590088DEC7 /* CCLabelBMFont.cpp */, 1A570195180BCB590088DEC7 /* CCLabelBMFont.h */, 1A570197180BCB590088DEC7 /* CCLabelTextFormatter.cpp */, 1A570198180BCB590088DEC7 /* CCLabelTextFormatter.h */, 1A570199180BCB590088DEC7 /* CCLabelTTF.cpp */, 1A57019A180BCB590088DEC7 /* CCLabelTTF.h */, ); name = "label-nodes"; sourceTree = ""; }; 1A5701D3180BCB670088DEC7 /* layers-scenes-transitions-nodes */ = { isa = PBXGroup; children = ( 1A5701D4180BCB8C0088DEC7 /* CCLayer.cpp */, 1A5701D5180BCB8C0088DEC7 /* CCLayer.h */, 1A5701D6180BCB8C0088DEC7 /* CCScene.cpp */, 1A5701D7180BCB8C0088DEC7 /* CCScene.h */, 1A5701D8180BCB8C0088DEC7 /* CCTransition.cpp */, 1A5701D9180BCB8C0088DEC7 /* CCTransition.h */, 1A5701DA180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp */, 1A5701DB180BCB8C0088DEC7 /* CCTransitionPageTurn.h */, 1A5701DC180BCB8C0088DEC7 /* CCTransitionProgress.cpp */, 1A5701DD180BCB8C0088DEC7 /* CCTransitionProgress.h */, ); name = "layers-scenes-transitions-nodes"; sourceTree = ""; }; 1A5701F2180BCB970088DEC7 /* menu-nodes */ = { isa = PBXGroup; children = ( 1A5701F3180BCBAD0088DEC7 /* CCMenu.cpp */, 1A5701F4180BCBAD0088DEC7 /* CCMenu.h */, 1A5701F5180BCBAD0088DEC7 /* CCMenuItem.cpp */, 1A5701F6180BCBAD0088DEC7 /* CCMenuItem.h */, ); name = "menu-nodes"; sourceTree = ""; }; 1A5701FF180BCBBD0088DEC7 /* misc-nodes */ = { isa = PBXGroup; children = ( ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */, ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */, 1A57020C180BCBF40088DEC7 /* CCProgressTimer.cpp */, 1A57020D180BCBF40088DEC7 /* CCProgressTimer.h */, 1A57020E180BCBF40088DEC7 /* CCRenderTexture.cpp */, 1A57020F180BCBF40088DEC7 /* CCRenderTexture.h */, 1A570206180BCBDF0088DEC7 /* CCMotionStreak.cpp */, 1A570207180BCBDF0088DEC7 /* CCMotionStreak.h */, 1A570200180BCBD40088DEC7 /* CCClippingNode.cpp */, 1A570201180BCBD40088DEC7 /* CCClippingNode.h */, ); name = "misc-nodes"; sourceTree = ""; }; 1A570218180BCC000088DEC7 /* particle-nodes */ = { isa = PBXGroup; children = ( 1A570219180BCC1A0088DEC7 /* CCParticleBatchNode.cpp */, 1A57021A180BCC1A0088DEC7 /* CCParticleBatchNode.h */, 1A57021B180BCC1A0088DEC7 /* CCParticleExamples.cpp */, 1A57021C180BCC1A0088DEC7 /* CCParticleExamples.h */, 1A57021D180BCC1A0088DEC7 /* CCParticleSystem.cpp */, 1A57021E180BCC1A0088DEC7 /* CCParticleSystem.h */, 1A57021F180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp */, 1A570220180BCC1A0088DEC7 /* CCParticleSystemQuad.h */, ); name = "particle-nodes"; sourceTree = ""; }; 1A570231180BCC380088DEC7 /* script-support */ = { isa = PBXGroup; children = ( 1A570232180BCC4D0088DEC7 /* CCScriptSupport.cpp */, 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */, ); name = "script-support"; sourceTree = ""; }; 1A570238180BCC580088DEC7 /* shaders */ = { isa = PBXGroup; children = ( 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */, 1A570530180BD9500088DEC7 /* CCGLProgram.h */, 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */, 1A570532180BD9500088DEC7 /* ccGLStateCache.h */, 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */, 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */, 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */, 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */, 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */, 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */, 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */, 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */, 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */, 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */, 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */, 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */, 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */, 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */, A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */, A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */, 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */, 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */, 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */, 1A57024A180BCC6F0088DEC7 /* ccShaderEx_SwitchMask_frag.h */, 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */, 1A57024C180BCC6F0088DEC7 /* ccShaders.h */, ); name = shaders; sourceTree = ""; }; 1A570275180BCC840088DEC7 /* sprite-nodes */ = { isa = PBXGroup; children = ( 1A57028E180BCCAB0088DEC7 /* CCAnimation.cpp */, 1A57028F180BCCAB0088DEC7 /* CCAnimation.h */, 1A570290180BCCAB0088DEC7 /* CCAnimationCache.cpp */, 1A570291180BCCAB0088DEC7 /* CCAnimationCache.h */, 1A570276180BCC900088DEC7 /* CCSprite.cpp */, 1A570277180BCC900088DEC7 /* CCSprite.h */, 1A570278180BCC900088DEC7 /* CCSpriteBatchNode.cpp */, 1A570279180BCC900088DEC7 /* CCSpriteBatchNode.h */, 1A57027A180BCC900088DEC7 /* CCSpriteFrame.cpp */, 1A57027B180BCC900088DEC7 /* CCSpriteFrame.h */, 1A57027C180BCC900088DEC7 /* CCSpriteFrameCache.cpp */, 1A57027D180BCC900088DEC7 /* CCSpriteFrameCache.h */, ); name = "sprite-nodes"; sourceTree = ""; }; 1A57029A180BCD4F0088DEC7 /* support */ = { isa = PBXGroup; children = ( 1A570337180BCFED0088DEC7 /* zip-support */, 1A57032A180BCFBC0088DEC7 /* user-default */, 1A570321180BCF580088DEC7 /* image-support */, 1A570314180BCF1C0088DEC7 /* data-support */, 1A570307180BCEFB0088DEC7 /* component */, 1A57029B180BCD890088DEC7 /* base64.cpp */, 1A57029C180BCD890088DEC7 /* base64.h */, 1A5702A1180BCD980088DEC7 /* CCNotificationCenter.cpp */, 1A5702A2180BCD980088DEC7 /* CCNotificationCenter.h */, 1A5702A7180BCDAA0088DEC7 /* CCProfiling.cpp */, 1A5702A8180BCDAA0088DEC7 /* CCProfiling.h */, 1A5702AD180BCDBC0088DEC7 /* ccUTF8.cpp */, 1A5702AE180BCDBC0088DEC7 /* ccUTF8.h */, 1A570304180BCED90088DEC7 /* ccUtils.cpp */, 1A5702B9180BCDFC0088DEC7 /* ccUtils.h */, 1A5702B3180BCDF40088DEC7 /* CCVertex.cpp */, 1A5702B4180BCDF40088DEC7 /* CCVertex.h */, ); name = support; sourceTree = ""; }; 1A5702BC180BCE0A0088DEC7 /* text-input-node */ = { isa = PBXGroup; children = ( 1A5702C6180BCE370088DEC7 /* CCTextFieldTTF.cpp */, 1A5702C7180BCE370088DEC7 /* CCTextFieldTTF.h */, 1A5702BD180BCE2A0088DEC7 /* CCIMEDelegate.h */, 1A5702BE180BCE2A0088DEC7 /* CCIMEDispatcher.cpp */, 1A5702BF180BCE2A0088DEC7 /* CCIMEDispatcher.h */, ); name = "text-input-node"; sourceTree = ""; }; 1A5702CC180BCE410088DEC7 /* textures */ = { isa = PBXGroup; children = ( 1A5702CD180BCE560088DEC7 /* CCTexture2D.cpp */, 1A5702CE180BCE570088DEC7 /* CCTexture2D.h */, 1A5702CF180BCE570088DEC7 /* CCTextureAtlas.cpp */, 1A5702D0180BCE570088DEC7 /* CCTextureAtlas.h */, 1A5702D1180BCE570088DEC7 /* CCTextureCache.cpp */, 1A5702D2180BCE570088DEC7 /* CCTextureCache.h */, ); name = textures; sourceTree = ""; }; 1A5702DF180BCE610088DEC7 /* tilemap-parallax-nodes */ = { isa = PBXGroup; children = ( 1A5702FE180BCE890088DEC7 /* CCParallaxNode.cpp */, 1A5702FF180BCE890088DEC7 /* CCParallaxNode.h */, 1A5702E0180BCE750088DEC7 /* CCTileMapAtlas.cpp */, 1A5702E1180BCE750088DEC7 /* CCTileMapAtlas.h */, 1A5702E2180BCE750088DEC7 /* CCTMXLayer.cpp */, 1A5702E3180BCE750088DEC7 /* CCTMXLayer.h */, 1A5702E4180BCE750088DEC7 /* CCTMXObjectGroup.cpp */, 1A5702E5180BCE750088DEC7 /* CCTMXObjectGroup.h */, 1A5702E6180BCE750088DEC7 /* CCTMXTiledMap.cpp */, 1A5702E7180BCE750088DEC7 /* CCTMXTiledMap.h */, 1A5702E8180BCE750088DEC7 /* CCTMXXMLParser.cpp */, 1A5702E9180BCE750088DEC7 /* CCTMXXMLParser.h */, ); name = "tilemap-parallax-nodes"; sourceTree = ""; }; 1A570307180BCEFB0088DEC7 /* component */ = { isa = PBXGroup; children = ( 1A570308180BCF190088DEC7 /* CCComponent.cpp */, 1A570309180BCF190088DEC7 /* CCComponent.h */, 1A57030A180BCF190088DEC7 /* CCComponentContainer.cpp */, 1A57030B180BCF190088DEC7 /* CCComponentContainer.h */, ); name = component; sourceTree = ""; }; 1A570314180BCF1C0088DEC7 /* data-support */ = { isa = PBXGroup; children = ( 1A570315180BCF430088DEC7 /* ccCArray.cpp */, 1A570316180BCF430088DEC7 /* ccCArray.h */, 1A570317180BCF430088DEC7 /* uthash.h */, 1A570318180BCF430088DEC7 /* utlist.h */, ); name = "data-support"; sourceTree = ""; }; 1A570321180BCF580088DEC7 /* image-support */ = { isa = PBXGroup; children = ( 1A570322180BCF660088DEC7 /* TGAlib.cpp */, 1A570323180BCF660088DEC7 /* TGAlib.h */, ); name = "image-support"; sourceTree = ""; }; 1A57032A180BCFBC0088DEC7 /* user-default */ = { isa = PBXGroup; children = ( 1A57032B180BCFD50088DEC7 /* CCUserDefault.cpp */, 1A57032C180BCFD50088DEC7 /* CCUserDefault.h */, 1A57032D180BCFD50088DEC7 /* CCUserDefault.mm */, 1A57032E180BCFD50088DEC7 /* CCUserDefaultAndroid.cpp */, ); name = "user-default"; sourceTree = ""; }; 1A570337180BCFED0088DEC7 /* zip-support */ = { isa = PBXGroup; children = ( 1A570338180BCFFA0088DEC7 /* ZipUtils.cpp */, 1A570339180BCFFA0088DEC7 /* ZipUtils.h */, ); name = "zip-support"; sourceTree = ""; }; 1A57033E180BD0490088DEC7 /* external */ = { isa = PBXGroup; children = ( 46A168B21807AF9C005B8026 /* Box2D */, 46A1693A1807AFD6005B8026 /* chipmunk */, 1AAF5403180E3B2D000584C8 /* curl */, 1A087AE51860400400196EF5 /* edtaa3func */, 1A5703BC180BD2940088DEC7 /* freetype2 */, 1A57033F180BD0540088DEC7 /* glfw3 */, 1A570373180BD1790088DEC7 /* jpeg */, 1AD71EF8180E28C400808F54 /* json */, 1A8C55C9180E8C5700EF57C3 /* lua */, 1A57035C180BD0D90088DEC7 /* png */, 1AAF541E180E4013000584C8 /* spidermonkey */, 1A57038A180BD1EF0088DEC7 /* tiff */, 1A570348180BD09B0088DEC7 /* tinyxml2 */, 1A57034F180BD0B00088DEC7 /* unzip */, 1A5703A5180BD2410088DEC7 /* webp */, 1AAF537A180E354D000584C8 /* websockets */, ); name = external; sourceTree = ""; }; 1A57033F180BD0540088DEC7 /* glfw3 */ = { isa = PBXGroup; children = ( 1A570345180BD07B0088DEC7 /* lib */, ); name = glfw3; sourceTree = ""; }; 1A570345180BD07B0088DEC7 /* lib */ = { isa = PBXGroup; children = ( 1A570346180BD0850088DEC7 /* libglfw3.a */, ); name = lib; sourceTree = ""; }; 1A570348180BD09B0088DEC7 /* tinyxml2 */ = { isa = PBXGroup; children = ( 1A570349180BD09B0088DEC7 /* tinyxml2.cpp */, 1A57034A180BD09B0088DEC7 /* tinyxml2.h */, ); name = tinyxml2; path = ../external/tinyxml2; sourceTree = ""; }; 1A57034F180BD0B00088DEC7 /* unzip */ = { isa = PBXGroup; children = ( 1A570350180BD0B00088DEC7 /* ioapi.cpp */, 1A570351180BD0B00088DEC7 /* ioapi.h */, 1A570352180BD0B00088DEC7 /* unzip.cpp */, 1A570353180BD0B00088DEC7 /* unzip.h */, ); name = unzip; path = ../external/unzip; sourceTree = ""; }; 1A57035C180BD0D90088DEC7 /* png */ = { isa = PBXGroup; children = ( 1A57035E180BD0EF0088DEC7 /* prebuilt */, ); name = png; sourceTree = ""; }; 1A57035E180BD0EF0088DEC7 /* prebuilt */ = { isa = PBXGroup; children = ( 1A570362180BD1120088DEC7 /* ios */, 1A57035F180BD1080088DEC7 /* mac */, ); name = prebuilt; sourceTree = ""; }; 1A57035F180BD1080088DEC7 /* mac */ = { isa = PBXGroup; children = ( 1A570360180BD1080088DEC7 /* libpng.a */, ); name = mac; path = ../external/png/prebuilt/mac; sourceTree = ""; }; 1A570362180BD1120088DEC7 /* ios */ = { isa = PBXGroup; children = ( 1A570363180BD1120088DEC7 /* libpng.a */, ); name = ios; path = ../external/png/prebuilt/ios; sourceTree = ""; }; 1A570373180BD1790088DEC7 /* jpeg */ = { isa = PBXGroup; children = ( 1A570375180BD1840088DEC7 /* prebuilt */, ); name = jpeg; sourceTree = ""; }; 1A570375180BD1840088DEC7 /* prebuilt */ = { isa = PBXGroup; children = ( 1A570376180BD1B40088DEC7 /* ios */, 1A570379180BD1C90088DEC7 /* mac */, ); name = prebuilt; sourceTree = ""; }; 1A570376180BD1B40088DEC7 /* ios */ = { isa = PBXGroup; children = ( 1A570377180BD1B40088DEC7 /* libjpeg.a */, ); name = ios; path = ../external/jpeg/prebuilt/ios; sourceTree = ""; }; 1A570379180BD1C90088DEC7 /* mac */ = { isa = PBXGroup; children = ( 1A57037A180BD1C90088DEC7 /* libjpeg.a */, ); name = mac; path = ../external/jpeg/prebuilt/mac; sourceTree = ""; }; 1A57038A180BD1EF0088DEC7 /* tiff */ = { isa = PBXGroup; children = ( 1A57038C180BD2040088DEC7 /* prebuilt */, ); name = tiff; sourceTree = ""; }; 1A57038C180BD2040088DEC7 /* prebuilt */ = { isa = PBXGroup; children = ( 1A5703A2180BD2350088DEC7 /* ios */, 1A57039F180BD22C0088DEC7 /* mac */, ); name = prebuilt; sourceTree = ""; }; 1A57039F180BD22C0088DEC7 /* mac */ = { isa = PBXGroup; children = ( 1A5703A0180BD22C0088DEC7 /* libtiff.a */, ); name = mac; path = ../external/tiff/prebuilt/mac; sourceTree = ""; }; 1A5703A2180BD2350088DEC7 /* ios */ = { isa = PBXGroup; children = ( 1A5703A3180BD2350088DEC7 /* libtiff.a */, ); name = ios; path = ../external/tiff/prebuilt/ios; sourceTree = ""; }; 1A5703A5180BD2410088DEC7 /* webp */ = { isa = PBXGroup; children = ( 1A5703A6180BD2530088DEC7 /* prebuilt */, ); name = webp; sourceTree = ""; }; 1A5703A6180BD2530088DEC7 /* prebuilt */ = { isa = PBXGroup; children = ( 1A5703B9180BD2800088DEC7 /* ios */, 1A5703B6180BD2780088DEC7 /* mac */, ); name = prebuilt; sourceTree = ""; }; 1A5703B6180BD2780088DEC7 /* mac */ = { isa = PBXGroup; children = ( 1A5703B7180BD2780088DEC7 /* libwebp.a */, ); name = mac; path = ../external/webp/prebuilt/mac; sourceTree = ""; }; 1A5703B9180BD2800088DEC7 /* ios */ = { isa = PBXGroup; children = ( 1A5703BA180BD2800088DEC7 /* libwebp.a */, ); name = ios; path = ../external/webp/prebuilt/ios; sourceTree = ""; }; 1A5703BC180BD2940088DEC7 /* freetype2 */ = { isa = PBXGroup; children = ( 1A5703BE180BD29C0088DEC7 /* prebuilt */, ); name = freetype2; sourceTree = ""; }; 1A5703BE180BD29C0088DEC7 /* prebuilt */ = { isa = PBXGroup; children = ( 1A57052C180BD3280088DEC7 /* ios */, 1A570529180BD31F0088DEC7 /* mac */, ); name = prebuilt; sourceTree = ""; }; 1A570529180BD31F0088DEC7 /* mac */ = { isa = PBXGroup; children = ( 1A57052A180BD31F0088DEC7 /* libfreetype.a */, ); name = mac; path = ../external/freetype2/prebuilt/mac; sourceTree = ""; }; 1A57052C180BD3280088DEC7 /* ios */ = { isa = PBXGroup; children = ( 1A57052D180BD3280088DEC7 /* libfreetype.a */, ); name = ios; path = ../external/freetype2/prebuilt/ios; sourceTree = ""; }; 1A8C55C9180E8C5700EF57C3 /* lua */ = { isa = PBXGroup; children = ( 1A8C5637180E8C7800EF57C3 /* luajit */, 1A8C563E180E8D0D00EF57C3 /* tolua */, ); name = lua; sourceTree = ""; }; 1A8C5637180E8C7800EF57C3 /* luajit */ = { isa = PBXGroup; children = ( 1A8C563B180E8CA700EF57C3 /* mac */, 1A8C5638180E8C8700EF57C3 /* ios */, ); name = luajit; sourceTree = ""; }; 1A8C5638180E8C8700EF57C3 /* ios */ = { isa = PBXGroup; children = ( 1599607F181132DE00C7D42C /* libluajit.a */, ); name = ios; sourceTree = ""; }; 1A8C563B180E8CA700EF57C3 /* mac */ = { isa = PBXGroup; children = ( 1599607A1811329600C7D42C /* libluajit.a */, ); name = mac; sourceTree = ""; }; 1A8C563E180E8D0D00EF57C3 /* tolua */ = { isa = PBXGroup; children = ( 1A8C563F180E8D0D00EF57C3 /* tolua++.h */, 1A8C5640180E8D0D00EF57C3 /* tolua_event.c */, 1A8C5641180E8D0D00EF57C3 /* tolua_event.h */, 1A8C5642180E8D0D00EF57C3 /* tolua_is.c */, 1A8C5643180E8D0D00EF57C3 /* tolua_map.c */, 1A8C5644180E8D0D00EF57C3 /* tolua_push.c */, 1A8C5645180E8D0D00EF57C3 /* tolua_to.c */, ); name = tolua; path = ../external/lua/tolua; sourceTree = ""; }; 1A8C58BD180E92CC00EF57C3 /* gui */ = { isa = PBXGroup; children = ( 1A8C58BF180E92CC00EF57C3 /* CocosGUI.cpp */, 1A8C58C0180E92CC00EF57C3 /* CocosGUI.h */, 1A8C58C1180E92CC00EF57C3 /* UILayout.cpp */, 1A8C58C2180E92CC00EF57C3 /* UILayout.h */, 1A8C58C3180E92CC00EF57C3 /* UILayoutParameter.cpp */, 1A8C58C4180E92CC00EF57C3 /* UILayoutParameter.h */, 1A8C58C5180E92CC00EF57C3 /* UIButton.cpp */, 1A8C58C6180E92CC00EF57C3 /* UIButton.h */, 1A8C58C7180E92CC00EF57C3 /* UICheckBox.cpp */, 1A8C58C8180E92CC00EF57C3 /* UICheckBox.h */, 1A8C58CB180E92CC00EF57C3 /* UIHelper.cpp */, 1A8C58CC180E92CC00EF57C3 /* UIHelper.h */, 1A8C58CD180E92CC00EF57C3 /* UIImageView.cpp */, 1A8C58CE180E92CC00EF57C3 /* UIImageView.h */, 1A8C58D1180E92CC00EF57C3 /* UIText.cpp */, 1A8C58D2180E92CC00EF57C3 /* UIText.h */, 1A8C58D3180E92CC00EF57C3 /* UITextAtlas.cpp */, 1A8C58D4180E92CC00EF57C3 /* UITextAtlas.h */, 1A8C58D5180E92CC00EF57C3 /* UITextBMFont.cpp */, 1A8C58D6180E92CC00EF57C3 /* UITextBMFont.h */, 1A8C58D9180E92CC00EF57C3 /* UILayoutDefine.cpp */, 1A8C58DA180E92CC00EF57C3 /* UILayoutDefine.h */, 1A8C58DD180E92CC00EF57C3 /* UILoadingBar.cpp */, 1A8C58DE180E92CC00EF57C3 /* UILoadingBar.h */, 1A8C58DF180E92CC00EF57C3 /* UIPageView.cpp */, 1A8C58E0180E92CC00EF57C3 /* UIPageView.h */, 1A8C58E3180E92CC00EF57C3 /* UIScrollInterface.h */, 1A8C58E4180E92CC00EF57C3 /* UIScrollView.cpp */, 1A8C58E5180E92CC00EF57C3 /* UIScrollView.h */, 50A1FF1618290ED4001840C4 /* UIListView.cpp */, 50A1FF1718290ED4001840C4 /* UIListView.h */, 1A8C58E6180E92CC00EF57C3 /* UISlider.cpp */, 1A8C58E7180E92CC00EF57C3 /* UISlider.h */, 1A8C58E8180E92CC00EF57C3 /* UITextField.cpp */, 1A8C58E9180E92CC00EF57C3 /* UITextField.h */, 1A8C58EA180E92CC00EF57C3 /* UIWidget.cpp */, 1A8C58EB180E92CC00EF57C3 /* UIWidget.h */, ); name = gui; path = ../cocos/gui; sourceTree = ""; }; 1A8C5946180E930E00EF57C3 /* cocostudio */ = { isa = PBXGroup; children = ( 06CAAAC1186AD63B0012A414 /* TriggerObj.h */, 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */, 06CAAABB186AD63B0012A414 /* ObjectFactory.h */, 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */, 06CAAABD186AD63B0012A414 /* TriggerBase.h */, 06CAAABE186AD63B0012A414 /* TriggerMng.cpp */, 06CAAABF186AD63B0012A414 /* TriggerMng.h */, 06CAAAC0186AD63B0012A414 /* TriggerObj.cpp */, 3774879E1869BA8C00EDF837 /* CCActionEaseEx.cpp */, 37936A401869B7B200E974DD /* CCActionEaseEx.h */, 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */, 1A8C5949180E930E00EF57C3 /* CCActionFrame.h */, 1A8C594A180E930E00EF57C3 /* CCActionFrameEasing.cpp */, 1A8C594B180E930E00EF57C3 /* CCActionFrameEasing.h */, 1A8C594C180E930E00EF57C3 /* CCActionManagerEx.cpp */, 1A8C594D180E930E00EF57C3 /* CCActionManagerEx.h */, 1A8C594E180E930E00EF57C3 /* CCActionNode.cpp */, 1A8C594F180E930E00EF57C3 /* CCActionNode.h */, 1A8C5950180E930E00EF57C3 /* CCActionObject.cpp */, 1A8C5951180E930E00EF57C3 /* CCActionObject.h */, 1A8C5952180E930E00EF57C3 /* CCArmature.cpp */, 1A8C5953180E930E00EF57C3 /* CCArmature.h */, 1A8C5954180E930E00EF57C3 /* CCArmatureAnimation.cpp */, 1A8C5955180E930E00EF57C3 /* CCArmatureAnimation.h */, 1A8C5956180E930E00EF57C3 /* CCArmatureDataManager.cpp */, 1A8C5957180E930E00EF57C3 /* CCArmatureDataManager.h */, 1A8C5958180E930E00EF57C3 /* CCArmatureDefine.cpp */, 1A8C5959180E930E00EF57C3 /* CCArmatureDefine.h */, 1A8C595A180E930E00EF57C3 /* CCBatchNode.cpp */, 1A8C595B180E930E00EF57C3 /* CCBatchNode.h */, 1A8C595C180E930E00EF57C3 /* CCBone.cpp */, 1A8C595D180E930E00EF57C3 /* CCBone.h */, 1A8C595E180E930E00EF57C3 /* CCColliderDetector.cpp */, 1A8C595F180E930E00EF57C3 /* CCColliderDetector.h */, 373B910718787C0B00198F86 /* CCComBase.h */, 1A8C5960180E930E00EF57C3 /* CCComAttribute.cpp */, 1A8C5961180E930E00EF57C3 /* CCComAttribute.h */, 1A8C5962180E930E00EF57C3 /* CCComAudio.cpp */, 1A8C5963180E930E00EF57C3 /* CCComAudio.h */, 1A8C5964180E930E00EF57C3 /* CCComController.cpp */, 1A8C5965180E930E00EF57C3 /* CCComController.h */, 1A8C5966180E930E00EF57C3 /* CCComRender.cpp */, 1A8C5967180E930E00EF57C3 /* CCComRender.h */, 1A8C5968180E930E00EF57C3 /* CCDataReaderHelper.cpp */, 1A8C5969180E930E00EF57C3 /* CCDataReaderHelper.h */, 1A8C596A180E930E00EF57C3 /* CCDatas.cpp */, 1A8C596B180E930E00EF57C3 /* CCDatas.h */, 1A8C596C180E930E00EF57C3 /* CCDecorativeDisplay.cpp */, 1A8C596D180E930E00EF57C3 /* CCDecorativeDisplay.h */, 1A8C596E180E930E00EF57C3 /* CCDisplayFactory.cpp */, 1A8C596F180E930E00EF57C3 /* CCDisplayFactory.h */, 1A8C5970180E930E00EF57C3 /* CCDisplayManager.cpp */, 1A8C5971180E930E00EF57C3 /* CCDisplayManager.h */, 1A8C5972180E930E00EF57C3 /* CCInputDelegate.cpp */, 1A8C5973180E930E00EF57C3 /* CCInputDelegate.h */, 1A8C5974180E930E00EF57C3 /* CCProcessBase.cpp */, 1A8C5975180E930E00EF57C3 /* CCProcessBase.h */, 1A8C5976180E930E00EF57C3 /* CCSGUIReader.cpp */, 1A8C5977180E930E00EF57C3 /* CCSGUIReader.h */, 1A8C5978180E930E00EF57C3 /* CCSkin.cpp */, 1A8C5979180E930E00EF57C3 /* CCSkin.h */, 1A8C597A180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp */, 1A8C597B180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h */, 1A8C597C180E930E00EF57C3 /* CCSSceneReader.cpp */, 1A8C597D180E930E00EF57C3 /* CCSSceneReader.h */, 1A8C597E180E930E00EF57C3 /* CCTransformHelp.cpp */, 1A8C597F180E930E00EF57C3 /* CCTransformHelp.h */, 1A8C5980180E930E00EF57C3 /* CCTween.cpp */, 1A8C5981180E930E00EF57C3 /* CCTween.h */, 1A8C5982180E930E00EF57C3 /* CCTweenFunction.cpp */, 1A8C5983180E930E00EF57C3 /* CCTweenFunction.h */, 1A8C5984180E930E00EF57C3 /* CCUtilMath.cpp */, 1A8C5985180E930E00EF57C3 /* CCUtilMath.h */, 1A8C5986180E930E00EF57C3 /* CocoStudio.h */, 1A8C5989180E930E00EF57C3 /* DictionaryHelper.cpp */, 1A8C598A180E930E00EF57C3 /* DictionaryHelper.h */, ); path = cocostudio; sourceTree = ""; }; 1AAF5350180E305F000584C8 /* assets-manager */ = { isa = PBXGroup; children = ( 1AAF5351180E3060000584C8 /* AssetsManager.cpp */, 1AAF5352180E3060000584C8 /* AssetsManager.h */, ); path = "assets-manager"; sourceTree = ""; }; 1AAF5360180E3374000584C8 /* network */ = { isa = PBXGroup; children = ( 1AAF5362180E3374000584C8 /* HttpClient.cpp */, 1AAF5363180E3374000584C8 /* HttpClient.h */, 1AAF5364180E3374000584C8 /* HttpRequest.h */, 1AAF5365180E3374000584C8 /* HttpResponse.h */, 1AAF5366180E3374000584C8 /* SocketIO.cpp */, 1AAF5367180E3374000584C8 /* SocketIO.h */, 1AAF5368180E3374000584C8 /* WebSocket.cpp */, 1AAF5369180E3374000584C8 /* WebSocket.h */, ); name = network; path = ../cocos/network; sourceTree = ""; }; 1AAF537A180E354D000584C8 /* websockets */ = { isa = PBXGroup; children = ( 1AAF537B180E3560000584C8 /* prebuilt */, ); name = websockets; sourceTree = ""; }; 1AAF537B180E3560000584C8 /* prebuilt */ = { isa = PBXGroup; children = ( 1AAF5386180E35AC000584C8 /* ios */, 1AAF5383180E35A3000584C8 /* mac */, ); name = prebuilt; sourceTree = ""; }; 1AAF5383180E35A3000584C8 /* mac */ = { isa = PBXGroup; children = ( 1AAF5384180E35A3000584C8 /* libwebsockets.a */, ); name = mac; path = ../external/websockets/prebuilt/mac; sourceTree = ""; }; 1AAF5386180E35AC000584C8 /* ios */ = { isa = PBXGroup; children = ( 1AAF5387180E35AC000584C8 /* libwebsockets.a */, ); name = ios; path = ../external/websockets/prebuilt/ios; sourceTree = ""; }; 1AAF5403180E3B2D000584C8 /* curl */ = { isa = PBXGroup; children = ( 1AAF5405180E3B38000584C8 /* prebuilt */, ); name = curl; sourceTree = ""; }; 1AAF5405180E3B38000584C8 /* prebuilt */ = { isa = PBXGroup; children = ( 1AAF541B180E3B6A000584C8 /* ios */, ); name = prebuilt; sourceTree = ""; }; 1AAF541B180E3B6A000584C8 /* ios */ = { isa = PBXGroup; children = ( 1AAF541C180E3B6A000584C8 /* libcurl.a */, ); name = ios; path = ../external/curl/prebuilt/ios; sourceTree = ""; }; 1AAF541E180E4013000584C8 /* spidermonkey */ = { isa = PBXGroup; children = ( 1AAF541F180E4023000584C8 /* prebuilt */, ); name = spidermonkey; sourceTree = ""; }; 1AAF541F180E4023000584C8 /* prebuilt */ = { isa = PBXGroup; children = ( 1AAF5423180E405B000584C8 /* ios */, 1AAF5420180E4047000584C8 /* mac */, ); name = prebuilt; sourceTree = ""; }; 1AAF5420180E4047000584C8 /* mac */ = { isa = PBXGroup; children = ( 1AAF5421180E4047000584C8 /* libjs_static.a */, ); name = mac; path = ../external/spidermonkey/prebuilt/mac; sourceTree = ""; }; 1AAF5423180E405B000584C8 /* ios */ = { isa = PBXGroup; children = ( 1AAF5424180E405B000584C8 /* libjs_static.a */, ); name = ios; path = ../external/spidermonkey/prebuilt/ios; sourceTree = ""; }; 1AAF5426180E409E000584C8 /* scripting */ = { isa = PBXGroup; children = ( 1A2C785C181A11EC004E5527 /* auto-generated */, 1AAF5428180E409E000584C8 /* javascript */, 1A3B1F49180E887E00497A22 /* lua */, ); name = scripting; path = ../cocos/scripting; sourceTree = ""; }; 1AAF5428180E409E000584C8 /* javascript */ = { isa = PBXGroup; children = ( 1A2C78BA181A1257004E5527 /* bindings */, ); path = javascript; sourceTree = ""; }; 1AAF5849180E40B8000584C8 /* storage */ = { isa = PBXGroup; children = ( 1AAF584A180E40B9000584C8 /* local-storage */, ); name = storage; path = ../cocos/storage; sourceTree = ""; }; 1AAF584A180E40B9000584C8 /* local-storage */ = { isa = PBXGroup; children = ( 1AAF584B180E40B9000584C8 /* Android.mk */, 1AAF584C180E40B9000584C8 /* LocalStorage.cpp */, 1AAF584D180E40B9000584C8 /* LocalStorage.h */, 1AAF584E180E40B9000584C8 /* LocalStorageAndroid.cpp */, ); path = "local-storage"; sourceTree = ""; }; 1AD71CF7180E26E600808F54 /* editor-support */ = { isa = PBXGroup; children = ( 1AD71CF8180E26E600808F54 /* cocosbuilder */, 1A8C5946180E930E00EF57C3 /* cocostudio */, 1AD71D7C180E26E600808F54 /* spine */, ); name = "editor-support"; path = "../cocos/editor-support"; sourceTree = ""; }; 1AD71CF8180E26E600808F54 /* cocosbuilder */ = { isa = PBXGroup; children = ( 1AD71CFA180E26E600808F54 /* CCBAnimationManager.cpp */, 1AD71CFB180E26E600808F54 /* CCBAnimationManager.h */, 1AD71CFC180E26E600808F54 /* CCBFileLoader.cpp */, 1AD71CFD180E26E600808F54 /* CCBFileLoader.h */, 1AD71CFE180E26E600808F54 /* CCBKeyframe.cpp */, 1AD71CFF180E26E600808F54 /* CCBKeyframe.h */, 1AD71D00180E26E600808F54 /* CCBMemberVariableAssigner.h */, 1AD71D01180E26E600808F54 /* CCBReader.cpp */, 1AD71D02180E26E600808F54 /* CCBReader.h */, 1AD71D03180E26E600808F54 /* CCBSelectorResolver.h */, 1AD71D04180E26E600808F54 /* CCBSequence.cpp */, 1AD71D05180E26E600808F54 /* CCBSequence.h */, 1AD71D06180E26E600808F54 /* CCBSequenceProperty.cpp */, 1AD71D07180E26E600808F54 /* CCBSequenceProperty.h */, 1AD71D0A180E26E600808F54 /* CCControlButtonLoader.cpp */, 1AD71D0B180E26E600808F54 /* CCControlButtonLoader.h */, 1AD71D0C180E26E600808F54 /* CCControlLoader.cpp */, 1AD71D0D180E26E600808F54 /* CCControlLoader.h */, 1AD71D0E180E26E600808F54 /* CCLabelBMFontLoader.cpp */, 1AD71D0F180E26E600808F54 /* CCLabelBMFontLoader.h */, 1AD71D10180E26E600808F54 /* CCLabelTTFLoader.cpp */, 1AD71D11180E26E600808F54 /* CCLabelTTFLoader.h */, 1AD71D12180E26E600808F54 /* CCLayerColorLoader.cpp */, 1AD71D13180E26E600808F54 /* CCLayerColorLoader.h */, 1AD71D14180E26E600808F54 /* CCLayerGradientLoader.cpp */, 1AD71D15180E26E600808F54 /* CCLayerGradientLoader.h */, 1AD71D16180E26E600808F54 /* CCLayerLoader.cpp */, 1AD71D17180E26E600808F54 /* CCLayerLoader.h */, 1AD71D18180E26E600808F54 /* CCMenuItemImageLoader.cpp */, 1AD71D19180E26E600808F54 /* CCMenuItemImageLoader.h */, 1AD71D1A180E26E600808F54 /* CCMenuItemLoader.cpp */, 1AD71D1B180E26E600808F54 /* CCMenuItemLoader.h */, 1AD71D1C180E26E600808F54 /* CCMenuLoader.h */, 1AD71D1D180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp */, 1AD71D1E180E26E600808F54 /* CCNode+CCBRelativePositioning.h */, 1AD71D1F180E26E600808F54 /* CCNodeLoader.cpp */, 1AD71D20180E26E600808F54 /* CCNodeLoader.h */, 1AD71D21180E26E600808F54 /* CCNodeLoaderLibrary.cpp */, 1AD71D22180E26E600808F54 /* CCNodeLoaderLibrary.h */, 1AD71D23180E26E600808F54 /* CCNodeLoaderListener.h */, 1AD71D24180E26E600808F54 /* CCParticleSystemQuadLoader.cpp */, 1AD71D25180E26E600808F54 /* CCParticleSystemQuadLoader.h */, 1AD71D26180E26E600808F54 /* CCScale9SpriteLoader.cpp */, 1AD71D27180E26E600808F54 /* CCScale9SpriteLoader.h */, 1AD71D28180E26E600808F54 /* CCScrollViewLoader.cpp */, 1AD71D29180E26E600808F54 /* CCScrollViewLoader.h */, 1AD71D2A180E26E600808F54 /* CCSpriteLoader.cpp */, 1AD71D2B180E26E600808F54 /* CCSpriteLoader.h */, 1AD71D2C180E26E600808F54 /* CocosBuilder.h */, ); path = cocosbuilder; sourceTree = ""; }; 1AD71D7C180E26E600808F54 /* spine */ = { isa = PBXGroup; children = ( 2AC795D918628689005EC8E1 /* SkeletonBounds.cpp */, 2AC795DA18628689005EC8E1 /* SkeletonBounds.h */, 2AC795D51862867D005EC8E1 /* Event.cpp */, 2AC795D61862867D005EC8E1 /* Event.h */, 2AC795D71862867D005EC8E1 /* EventData.cpp */, 2AC795D81862867D005EC8E1 /* EventData.h */, 2AC795D318628672005EC8E1 /* BoundingBoxAttachment.cpp */, 2AC795D418628672005EC8E1 /* BoundingBoxAttachment.h */, 1AD71D7E180E26E600808F54 /* Animation.cpp */, 1AD71D7F180E26E600808F54 /* Animation.h */, 1AD71D80180E26E600808F54 /* AnimationState.cpp */, 1AD71D81180E26E600808F54 /* AnimationState.h */, 1AD71D82180E26E600808F54 /* AnimationStateData.cpp */, 1AD71D83180E26E600808F54 /* AnimationStateData.h */, 1AD71D84180E26E600808F54 /* Atlas.cpp */, 1AD71D85180E26E600808F54 /* Atlas.h */, 1AD71D86180E26E600808F54 /* AtlasAttachmentLoader.cpp */, 1AD71D87180E26E600808F54 /* AtlasAttachmentLoader.h */, 1AD71D88180E26E600808F54 /* Attachment.cpp */, 1AD71D89180E26E600808F54 /* Attachment.h */, 1AD71D8A180E26E600808F54 /* AttachmentLoader.cpp */, 1AD71D8B180E26E600808F54 /* AttachmentLoader.h */, 1AD71D8C180E26E600808F54 /* Bone.cpp */, 1AD71D8D180E26E600808F54 /* Bone.h */, 1AD71D8E180E26E600808F54 /* BoneData.cpp */, 1AD71D8F180E26E600808F54 /* BoneData.h */, 1AD71D90180E26E600808F54 /* CCSkeleton.cpp */, 1AD71D91180E26E600808F54 /* CCSkeleton.h */, 1AD71D92180E26E600808F54 /* CCSkeletonAnimation.cpp */, 1AD71D93180E26E600808F54 /* CCSkeletonAnimation.h */, 1AD71D94180E26E600808F54 /* extension.cpp */, 1AD71D95180E26E600808F54 /* extension.h */, 1AD71D96180E26E600808F54 /* Json.cpp */, 1AD71D97180E26E600808F54 /* Json.h */, 1AD71D98180E26E600808F54 /* RegionAttachment.cpp */, 1AD71D99180E26E600808F54 /* RegionAttachment.h */, 1AD71D9A180E26E600808F54 /* Skeleton.cpp */, 1AD71D9B180E26E600808F54 /* Skeleton.h */, 1AD71D9C180E26E600808F54 /* SkeletonData.cpp */, 1AD71D9D180E26E600808F54 /* SkeletonData.h */, 1AD71D9E180E26E600808F54 /* SkeletonJson.cpp */, 1AD71D9F180E26E600808F54 /* SkeletonJson.h */, 1AD71DA0180E26E600808F54 /* Skin.cpp */, 1AD71DA1180E26E600808F54 /* Skin.h */, 1AD71DA2180E26E600808F54 /* Slot.cpp */, 1AD71DA3180E26E600808F54 /* Slot.h */, 1AD71DA4180E26E600808F54 /* SlotData.cpp */, 1AD71DA5180E26E600808F54 /* SlotData.h */, 1AD71DA6180E26E600808F54 /* spine-cocos2dx.cpp */, 1AD71DA7180E26E600808F54 /* spine-cocos2dx.h */, 1AD71DA8180E26E600808F54 /* spine.h */, ); path = spine; sourceTree = ""; }; 1AD71EEB180E27CF00808F54 /* physics-nodes */ = { isa = PBXGroup; children = ( 1AD71EEC180E27CF00808F54 /* CCPhysicsDebugNode.cpp */, 1AD71EED180E27CF00808F54 /* CCPhysicsDebugNode.h */, 1AD71EEE180E27CF00808F54 /* CCPhysicsSprite.cpp */, 1AD71EEF180E27CF00808F54 /* CCPhysicsSprite.h */, ); path = "physics-nodes"; sourceTree = ""; }; 1AD71EF8180E28C400808F54 /* json */ = { isa = PBXGroup; children = ( 37936A341869B76800E974DD /* document.h */, 37936A351869B76800E974DD /* filestream.h */, 37936A361869B76800E974DD /* internal */, 37936A3A1869B76800E974DD /* prettywriter.h */, 37936A3B1869B76800E974DD /* rapidjson.h */, 37936A3C1869B76800E974DD /* reader.h */, 37936A3D1869B76800E974DD /* stringbuffer.h */, 37936A3E1869B76800E974DD /* writer.h */, ); name = json; path = ../external/json; sourceTree = ""; }; 37936A361869B76800E974DD /* internal */ = { isa = PBXGroup; children = ( 37936A371869B76800E974DD /* pow10.h */, 37936A381869B76800E974DD /* stack.h */, 37936A391869B76800E974DD /* strfunc.h */, ); path = internal; sourceTree = ""; }; 3EEF8BD01839F5A7005E8A6C /* gui */ = { isa = PBXGroup; children = ( 3EEF8BD11839F5C5005E8A6C /* jsb_cocos2dx_gui_manual.cpp */, 3EEF8BD21839F5C5005E8A6C /* jsb_cocos2dx_gui_manual.h */, ); name = gui; sourceTree = ""; }; 46A15FD01807A56F005B8026 /* audio */ = { isa = PBXGroup; children = ( 46A15FE01807A56F005B8026 /* include */, 46A15FE31807A56F005B8026 /* ios */, 46A15FF31807A56F005B8026 /* mac */, ); name = audio; path = ../cocos/audio; sourceTree = ""; }; 46A15FE01807A56F005B8026 /* include */ = { isa = PBXGroup; children = ( 46A15FE11807A56F005B8026 /* Export.h */, 46A15FE21807A56F005B8026 /* SimpleAudioEngine.h */, ); path = include; sourceTree = ""; }; 46A15FE31807A56F005B8026 /* ios */ = { isa = PBXGroup; children = ( 46A15FE41807A56F005B8026 /* CDAudioManager.h */, 46A15FE51807A56F005B8026 /* CDAudioManager.m */, 46A15FE61807A56F005B8026 /* CDConfig.h */, 46A15FE71807A56F005B8026 /* CDOpenALSupport.h */, 46A15FE81807A56F005B8026 /* CDOpenALSupport.m */, 46A15FE91807A56F005B8026 /* CocosDenshion.h */, 46A15FEA1807A56F005B8026 /* CocosDenshion.m */, 46A15FEB1807A56F005B8026 /* SimpleAudioEngine.mm */, 46A15FEC1807A56F005B8026 /* SimpleAudioEngine_objc.h */, 46A15FED1807A56F005B8026 /* SimpleAudioEngine_objc.m */, ); path = ios; sourceTree = ""; }; 46A15FF31807A56F005B8026 /* mac */ = { isa = PBXGroup; children = ( 46A15FF41807A56F005B8026 /* CDAudioManager.h */, 46A15FF51807A56F005B8026 /* CDAudioManager.m */, 46A15FF61807A56F005B8026 /* CDConfig.h */, 46A15FF71807A56F005B8026 /* CDOpenALSupport.h */, 46A15FF81807A56F005B8026 /* CDOpenALSupport.m */, 46A15FF91807A56F005B8026 /* CDXMacOSXSupport.h */, 46A15FFA1807A56F005B8026 /* CDXMacOSXSupport.mm */, 46A15FFB1807A56F005B8026 /* CocosDenshion.h */, 46A15FFC1807A56F005B8026 /* CocosDenshion.m */, 46A15FFD1807A56F005B8026 /* SimpleAudioEngine.mm */, 46A15FFE1807A56F005B8026 /* SimpleAudioEngine_objc.h */, 46A15FFF1807A56F005B8026 /* SimpleAudioEngine_objc.m */, ); path = mac; sourceTree = ""; }; 46A167981807AF4D005B8026 /* extensions */ = { isa = PBXGroup; children = ( 46A167D21807AF4D005B8026 /* cocos-ext.h */, 46A168321807AF4E005B8026 /* ExtensionMacros.h */, 1AAF5350180E305F000584C8 /* assets-manager */, 46A168331807AF4E005B8026 /* GUI */, 1AD71EEB180E27CF00808F54 /* physics-nodes */, ); name = extensions; path = ../extensions; sourceTree = ""; }; 46A168331807AF4E005B8026 /* GUI */ = { isa = PBXGroup; children = ( 46A168341807AF4E005B8026 /* CCControlExtension */, 46A1684E1807AF4E005B8026 /* CCEditBox */, 46A1685D1807AF4E005B8026 /* CCScrollView */, ); path = GUI; sourceTree = ""; }; 46A168341807AF4E005B8026 /* CCControlExtension */ = { isa = PBXGroup; children = ( 46A168351807AF4E005B8026 /* CCControl.cpp */, 46A168361807AF4E005B8026 /* CCControl.h */, 46A168371807AF4E005B8026 /* CCControlButton.cpp */, 46A168381807AF4E005B8026 /* CCControlButton.h */, 46A168391807AF4E005B8026 /* CCControlColourPicker.cpp */, 46A1683A1807AF4E005B8026 /* CCControlColourPicker.h */, 46A1683B1807AF4E005B8026 /* CCControlExtensions.h */, 46A1683C1807AF4E005B8026 /* CCControlHuePicker.cpp */, 46A1683D1807AF4E005B8026 /* CCControlHuePicker.h */, 46A1683E1807AF4E005B8026 /* CCControlPotentiometer.cpp */, 46A1683F1807AF4E005B8026 /* CCControlPotentiometer.h */, 46A168401807AF4E005B8026 /* CCControlSaturationBrightnessPicker.cpp */, 46A168411807AF4E005B8026 /* CCControlSaturationBrightnessPicker.h */, 46A168421807AF4E005B8026 /* CCControlSlider.cpp */, 46A168431807AF4E005B8026 /* CCControlSlider.h */, 46A168441807AF4E005B8026 /* CCControlStepper.cpp */, 46A168451807AF4E005B8026 /* CCControlStepper.h */, 46A168461807AF4E005B8026 /* CCControlSwitch.cpp */, 46A168471807AF4E005B8026 /* CCControlSwitch.h */, 46A168481807AF4E005B8026 /* CCControlUtils.cpp */, 46A168491807AF4E005B8026 /* CCControlUtils.h */, 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */, 46A1684B1807AF4E005B8026 /* CCInvocation.h */, 46A1684C1807AF4E005B8026 /* CCScale9Sprite.cpp */, 46A1684D1807AF4E005B8026 /* CCScale9Sprite.h */, ); path = CCControlExtension; sourceTree = ""; }; 46A1684E1807AF4E005B8026 /* CCEditBox */ = { isa = PBXGroup; children = ( 46A1684F1807AF4E005B8026 /* CCEditBox.cpp */, 46A168501807AF4E005B8026 /* CCEditBox.h */, 46A168511807AF4E005B8026 /* CCEditBoxImpl.h */, 46A168521807AF4E005B8026 /* CCEditBoxImplAndroid.cpp */, 46A168531807AF4E005B8026 /* CCEditBoxImplAndroid.h */, 46A168541807AF4E005B8026 /* CCEditBoxImplIOS.h */, 46A168551807AF4E005B8026 /* CCEditBoxImplIOS.mm */, 46A168561807AF4E005B8026 /* CCEditBoxImplMac.h */, 46A168571807AF4E005B8026 /* CCEditBoxImplMac.mm */, 46A168581807AF4E005B8026 /* CCEditBoxImplNone.cpp */, 46A168591807AF4E005B8026 /* CCEditBoxImplTizen.cpp */, 46A1685A1807AF4E005B8026 /* CCEditBoxImplTizen.h */, 46A1685B1807AF4E005B8026 /* CCEditBoxImplWin.cpp */, 46A1685C1807AF4E005B8026 /* CCEditBoxImplWin.h */, ); path = CCEditBox; sourceTree = ""; }; 46A1685D1807AF4E005B8026 /* CCScrollView */ = { isa = PBXGroup; children = ( 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */, 46A1685F1807AF4E005B8026 /* CCScrollView.h */, 46A168621807AF4E005B8026 /* CCTableView.cpp */, 46A168631807AF4E005B8026 /* CCTableView.h */, 46A168641807AF4E005B8026 /* CCTableViewCell.cpp */, 46A168651807AF4E005B8026 /* CCTableViewCell.h */, ); path = CCScrollView; sourceTree = ""; }; 46A168B21807AF9C005B8026 /* Box2D */ = { isa = PBXGroup; children = ( 46A168B31807AF9C005B8026 /* Android.mk */, 46A168B41807AF9C005B8026 /* Box2D.h */, 46A168B51807AF9C005B8026 /* Collision */, 46A168CD1807AF9C005B8026 /* Common */, 46A168DB1807AF9C005B8026 /* Dynamics */, 46A169311807AF9C005B8026 /* Rope */, ); name = Box2D; path = ../external/Box2D; sourceTree = ""; }; 46A168B51807AF9C005B8026 /* Collision */ = { isa = PBXGroup; children = ( 46A168B61807AF9C005B8026 /* b2BroadPhase.cpp */, 46A168B71807AF9C005B8026 /* b2BroadPhase.h */, 46A168B81807AF9C005B8026 /* b2CollideCircle.cpp */, 46A168B91807AF9C005B8026 /* b2CollideEdge.cpp */, 46A168BA1807AF9C005B8026 /* b2CollidePolygon.cpp */, 46A168BB1807AF9C005B8026 /* b2Collision.cpp */, 46A168BC1807AF9C005B8026 /* b2Collision.h */, 46A168BD1807AF9C005B8026 /* b2Distance.cpp */, 46A168BE1807AF9C005B8026 /* b2Distance.h */, 46A168BF1807AF9C005B8026 /* b2DynamicTree.cpp */, 46A168C01807AF9C005B8026 /* b2DynamicTree.h */, 46A168C11807AF9C005B8026 /* b2TimeOfImpact.cpp */, 46A168C21807AF9C005B8026 /* b2TimeOfImpact.h */, 46A168C31807AF9C005B8026 /* Shapes */, ); path = Collision; sourceTree = ""; }; 46A168C31807AF9C005B8026 /* Shapes */ = { isa = PBXGroup; children = ( 46A168C41807AF9C005B8026 /* b2ChainShape.cpp */, 46A168C51807AF9C005B8026 /* b2ChainShape.h */, 46A168C61807AF9C005B8026 /* b2CircleShape.cpp */, 46A168C71807AF9C005B8026 /* b2CircleShape.h */, 46A168C81807AF9C005B8026 /* b2EdgeShape.cpp */, 46A168C91807AF9C005B8026 /* b2EdgeShape.h */, 46A168CA1807AF9C005B8026 /* b2PolygonShape.cpp */, 46A168CB1807AF9C005B8026 /* b2PolygonShape.h */, 46A168CC1807AF9C005B8026 /* b2Shape.h */, ); path = Shapes; sourceTree = ""; }; 46A168CD1807AF9C005B8026 /* Common */ = { isa = PBXGroup; children = ( 46A168CE1807AF9C005B8026 /* b2BlockAllocator.cpp */, 46A168CF1807AF9C005B8026 /* b2BlockAllocator.h */, 46A168D01807AF9C005B8026 /* b2Draw.cpp */, 46A168D11807AF9C005B8026 /* b2Draw.h */, 46A168D21807AF9C005B8026 /* b2GrowableStack.h */, 46A168D31807AF9C005B8026 /* b2Math.cpp */, 46A168D41807AF9C005B8026 /* b2Math.h */, 46A168D51807AF9C005B8026 /* b2Settings.cpp */, 46A168D61807AF9C005B8026 /* b2Settings.h */, 46A168D71807AF9C005B8026 /* b2StackAllocator.cpp */, 46A168D81807AF9C005B8026 /* b2StackAllocator.h */, 46A168D91807AF9C005B8026 /* b2Timer.cpp */, 46A168DA1807AF9C005B8026 /* b2Timer.h */, ); path = Common; sourceTree = ""; }; 46A168DB1807AF9C005B8026 /* Dynamics */ = { isa = PBXGroup; children = ( 46A168DC1807AF9C005B8026 /* b2Body.cpp */, 46A168DD1807AF9C005B8026 /* b2Body.h */, 46A168DE1807AF9C005B8026 /* b2ContactManager.cpp */, 46A168DF1807AF9C005B8026 /* b2ContactManager.h */, 46A168E01807AF9C005B8026 /* b2Fixture.cpp */, 46A168E11807AF9C005B8026 /* b2Fixture.h */, 46A168E21807AF9C005B8026 /* b2Island.cpp */, 46A168E31807AF9C005B8026 /* b2Island.h */, 46A168E41807AF9C005B8026 /* b2TimeStep.h */, 46A168E51807AF9C005B8026 /* b2World.cpp */, 46A168E61807AF9C005B8026 /* b2World.h */, 46A168E71807AF9C005B8026 /* b2WorldCallbacks.cpp */, 46A168E81807AF9C005B8026 /* b2WorldCallbacks.h */, 46A168E91807AF9C005B8026 /* Contacts */, 46A168FC1807AF9C005B8026 /* Joints */, ); path = Dynamics; sourceTree = ""; }; 46A168E91807AF9C005B8026 /* Contacts */ = { isa = PBXGroup; children = ( 46A168EA1807AF9C005B8026 /* b2ChainAndCircleContact.cpp */, 46A168EB1807AF9C005B8026 /* b2ChainAndCircleContact.h */, 46A168EC1807AF9C005B8026 /* b2ChainAndPolygonContact.cpp */, 46A168ED1807AF9C005B8026 /* b2ChainAndPolygonContact.h */, 46A168EE1807AF9C005B8026 /* b2CircleContact.cpp */, 46A168EF1807AF9C005B8026 /* b2CircleContact.h */, 46A168F01807AF9C005B8026 /* b2Contact.cpp */, 46A168F11807AF9C005B8026 /* b2Contact.h */, 46A168F21807AF9C005B8026 /* b2ContactSolver.cpp */, 46A168F31807AF9C005B8026 /* b2ContactSolver.h */, 46A168F41807AF9C005B8026 /* b2EdgeAndCircleContact.cpp */, 46A168F51807AF9C005B8026 /* b2EdgeAndCircleContact.h */, 46A168F61807AF9C005B8026 /* b2EdgeAndPolygonContact.cpp */, 46A168F71807AF9C005B8026 /* b2EdgeAndPolygonContact.h */, 46A168F81807AF9C005B8026 /* b2PolygonAndCircleContact.cpp */, 46A168F91807AF9C005B8026 /* b2PolygonAndCircleContact.h */, 46A168FA1807AF9C005B8026 /* b2PolygonContact.cpp */, 46A168FB1807AF9C005B8026 /* b2PolygonContact.h */, ); path = Contacts; sourceTree = ""; }; 46A168FC1807AF9C005B8026 /* Joints */ = { isa = PBXGroup; children = ( B3AF019E1842FBA400A98B85 /* b2MotorJoint.cpp */, B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */, 46A168FD1807AF9C005B8026 /* b2DistanceJoint.cpp */, 46A168FE1807AF9C005B8026 /* b2DistanceJoint.h */, 46A168FF1807AF9C005B8026 /* b2FrictionJoint.cpp */, 46A169001807AF9C005B8026 /* b2FrictionJoint.h */, 46A169011807AF9C005B8026 /* b2GearJoint.cpp */, 46A169021807AF9C005B8026 /* b2GearJoint.h */, 46A169031807AF9C005B8026 /* b2Joint.cpp */, 46A169041807AF9C005B8026 /* b2Joint.h */, 46A169051807AF9C005B8026 /* b2MouseJoint.cpp */, 46A169061807AF9C005B8026 /* b2MouseJoint.h */, 46A169071807AF9C005B8026 /* b2PrismaticJoint.cpp */, 46A169081807AF9C005B8026 /* b2PrismaticJoint.h */, 46A169091807AF9C005B8026 /* b2PulleyJoint.cpp */, 46A1690A1807AF9C005B8026 /* b2PulleyJoint.h */, 46A1690B1807AF9C005B8026 /* b2RevoluteJoint.cpp */, 46A1690C1807AF9C005B8026 /* b2RevoluteJoint.h */, 46A1690D1807AF9C005B8026 /* b2RopeJoint.cpp */, 46A1690E1807AF9C005B8026 /* b2RopeJoint.h */, 46A1690F1807AF9C005B8026 /* b2WeldJoint.cpp */, 46A169101807AF9C005B8026 /* b2WeldJoint.h */, 46A169111807AF9C005B8026 /* b2WheelJoint.cpp */, 46A169121807AF9C005B8026 /* b2WheelJoint.h */, ); path = Joints; sourceTree = ""; }; 46A169311807AF9C005B8026 /* Rope */ = { isa = PBXGroup; children = ( 46A169321807AF9C005B8026 /* b2Rope.cpp */, 46A169331807AF9C005B8026 /* b2Rope.h */, ); path = Rope; sourceTree = ""; }; 46A1693A1807AFD6005B8026 /* chipmunk */ = { isa = PBXGroup; children = ( 46A1693E1807AFD6005B8026 /* include */, 46A1697A1807AFD6005B8026 /* src */, ); name = chipmunk; path = ../external/chipmunk; sourceTree = ""; }; 46A1693E1807AFD6005B8026 /* include */ = { isa = PBXGroup; children = ( 46A1693F1807AFD6005B8026 /* chipmunk */, ); path = include; sourceTree = ""; }; 46A1693F1807AFD6005B8026 /* chipmunk */ = { isa = PBXGroup; children = ( 46A169401807AFD6005B8026 /* chipmunk.h */, 46A169411807AFD6005B8026 /* chipmunk_ffi.h */, 46A169421807AFD6005B8026 /* chipmunk_private.h */, 46A169431807AFD6005B8026 /* chipmunk_types.h */, 46A169441807AFD6005B8026 /* chipmunk_unsafe.h */, 46A169451807AFD6005B8026 /* constraints */, 46A169521807AFD6005B8026 /* cpArbiter.h */, 46A169531807AFD6005B8026 /* cpBB.h */, 46A169541807AFD6005B8026 /* cpBody.h */, 46A169551807AFD6005B8026 /* cpPolyShape.h */, 46A169561807AFD6005B8026 /* cpShape.h */, 46A169571807AFD6005B8026 /* cpSpace.h */, 46A169581807AFD6005B8026 /* cpSpatialIndex.h */, 46A169591807AFD6005B8026 /* cpVect.h */, ); path = chipmunk; sourceTree = ""; }; 46A169451807AFD6005B8026 /* constraints */ = { isa = PBXGroup; children = ( 46A169461807AFD6005B8026 /* cpConstraint.h */, 46A169471807AFD6005B8026 /* cpDampedRotarySpring.h */, 46A169481807AFD6005B8026 /* cpDampedSpring.h */, 46A169491807AFD6005B8026 /* cpGearJoint.h */, 46A1694A1807AFD6005B8026 /* cpGrooveJoint.h */, 46A1694B1807AFD6005B8026 /* cpPinJoint.h */, 46A1694C1807AFD6005B8026 /* cpPivotJoint.h */, 46A1694D1807AFD6005B8026 /* cpRatchetJoint.h */, 46A1694E1807AFD6005B8026 /* cpRotaryLimitJoint.h */, 46A1694F1807AFD6005B8026 /* cpSimpleMotor.h */, 46A169501807AFD6005B8026 /* cpSlideJoint.h */, 46A169511807AFD6005B8026 /* util.h */, ); path = constraints; sourceTree = ""; }; 46A1697A1807AFD6005B8026 /* src */ = { isa = PBXGroup; children = ( 46A1697B1807AFD6005B8026 /* chipmunk.c */, 46A1697C1807AFD6005B8026 /* CMakeLists.txt */, 46A1697D1807AFD6005B8026 /* constraints */, 46A169891807AFD6005B8026 /* cpArbiter.c */, 46A1698A1807AFD6005B8026 /* cpArray.c */, 46A1698B1807AFD6005B8026 /* cpBB.c */, 46A1698C1807AFD6005B8026 /* cpBBTree.c */, 46A1698D1807AFD6005B8026 /* cpBody.c */, 46A1698E1807AFD6005B8026 /* cpCollision.c */, 46A1698F1807AFD6005B8026 /* cpHashSet.c */, 46A169901807AFD6005B8026 /* cpPolyShape.c */, 46A169911807AFD6005B8026 /* cpShape.c */, 46A169921807AFD6005B8026 /* cpSpace.c */, 46A169931807AFD6005B8026 /* cpSpaceComponent.c */, 46A169941807AFD6005B8026 /* cpSpaceHash.c */, 46A169951807AFD6005B8026 /* cpSpaceQuery.c */, 46A169961807AFD6005B8026 /* cpSpaceStep.c */, 46A169971807AFD6005B8026 /* cpSpatialIndex.c */, 46A169981807AFD6005B8026 /* cpSweep1D.c */, 46A169991807AFD6005B8026 /* cpVect.c */, 46A1699A1807AFD6005B8026 /* prime.h */, ); path = src; sourceTree = ""; }; 46A1697D1807AFD6005B8026 /* constraints */ = { isa = PBXGroup; children = ( 46A1697E1807AFD6005B8026 /* cpConstraint.c */, 46A1697F1807AFD6005B8026 /* cpDampedRotarySpring.c */, 46A169801807AFD6005B8026 /* cpDampedSpring.c */, 46A169811807AFD6005B8026 /* cpGearJoint.c */, 46A169821807AFD6005B8026 /* cpGrooveJoint.c */, 46A169831807AFD6005B8026 /* cpPinJoint.c */, 46A169841807AFD6005B8026 /* cpPivotJoint.c */, 46A169851807AFD6005B8026 /* cpRatchetJoint.c */, 46A169861807AFD6005B8026 /* cpRotaryLimitJoint.c */, 46A169871807AFD6005B8026 /* cpSimpleMotor.c */, 46A169881807AFD6005B8026 /* cpSlideJoint.c */, ); path = constraints; sourceTree = ""; }; 46A169A11807B037005B8026 /* 2d */ = { isa = PBXGroup; children = ( 1A9DCA47180E6DE3007A3AD4 /* ccTypes.cpp */, 1A9DCA48180E6DE3007A3AD4 /* ccTypes.h */, 1A9DCA41180E6D90007A3AD4 /* CCDeprecated.cpp */, 1A9DCA42180E6D90007A3AD4 /* CCDeprecated.h */, 1A9DC9F8180E6955007A3AD4 /* ccConfig.h */, 1A9DC9F9180E6955007A3AD4 /* CCConfiguration.cpp */, 1A9DC9FA180E6955007A3AD4 /* CCConfiguration.h */, 1A9DC9FD180E6955007A3AD4 /* CCDirector.cpp */, 1A9DC9FE180E6955007A3AD4 /* CCDirector.h */, 1A9DC9FF180E6955007A3AD4 /* CCEventType.h */, 1A9DCA00180E6955007A3AD4 /* ccFPSImages.c */, 1A9DCA01180E6955007A3AD4 /* ccFPSImages.h */, 1A9DCA02180E6955007A3AD4 /* CCGLBufferedNode.cpp */, 1A9DCA03180E6955007A3AD4 /* CCGLBufferedNode.h */, 1A9DCA04180E6955007A3AD4 /* ccMacros.h */, 1A9DCA05180E6955007A3AD4 /* CCProtocols.h */, 1A9DCA06180E6955007A3AD4 /* CCScheduler.cpp */, 1A9DCA07180E6955007A3AD4 /* CCScheduler.h */, 1A9DCA0A180E6955007A3AD4 /* cocos2d.cpp */, 1A9DCA0B180E6955007A3AD4 /* cocos2d.h */, 1A9DCA0C180E6955007A3AD4 /* firePngData.h */, 1A9DCA0D180E6955007A3AD4 /* TransformUtils.cpp */, 1A9DCA0E180E6955007A3AD4 /* TransformUtils.h */, 1A570046180BC59A0088DEC7 /* actions */, 1A570095180BC5B00088DEC7 /* base-nodes */, 1A570109180BC8DC0088DEC7 /* draw-nodes */, 1A570116180BC8FE0088DEC7 /* effects */, 1A570123180BC9270088DEC7 /* event-dispatcher */, 1A570181180BCB170088DEC7 /* label-nodes */, 1A5701D3180BCB670088DEC7 /* layers-scenes-transitions-nodes */, 1A5701F2180BCB970088DEC7 /* menu-nodes */, 1A5701FF180BCBBD0088DEC7 /* misc-nodes */, 1A570218180BCC000088DEC7 /* particle-nodes */, 46A16A5A1807B038005B8026 /* platform */, 1A570231180BCC380088DEC7 /* script-support */, 1A570238180BCC580088DEC7 /* shaders */, 1A570275180BCC840088DEC7 /* sprite-nodes */, 1A57029A180BCD4F0088DEC7 /* support */, 1A5702BC180BCE0A0088DEC7 /* text-input-node */, 1A5702CC180BCE410088DEC7 /* textures */, 1A5702DF180BCE610088DEC7 /* tilemap-parallax-nodes */, 74AC83D91006ABC123943F35 /* renderer */, ); name = 2d; path = ../cocos/2d; sourceTree = ""; }; 46A16A5A1807B038005B8026 /* platform */ = { isa = PBXGroup; children = ( 46A16AA31807B038005B8026 /* ios */, 46A16AC71807B038005B8026 /* mac */, A04583EF189053B500E32FE8 /* desktop */, 46A16A8E1807B038005B8026 /* apple */, 46A16A941807B038005B8026 /* CCApplicationProtocol.h */, 46A16A951807B038005B8026 /* CCCommon.h */, 46A16A961807B038005B8026 /* CCDevice.h */, 46A16A971807B038005B8026 /* CCEGLViewProtocol.cpp */, 46A16A981807B038005B8026 /* CCEGLViewProtocol.h */, 46A16A991807B038005B8026 /* CCFileUtils.cpp */, 46A16A9A1807B038005B8026 /* CCFileUtils.h */, 46A16A9B1807B038005B8026 /* CCImage.h */, 46A16A9F1807B038005B8026 /* CCSAXParser.cpp */, 46A16AA01807B038005B8026 /* CCSAXParser.h */, 46A16AA11807B038005B8026 /* CCThread.cpp */, 46A16AA21807B038005B8026 /* CCThread.h */, ); path = platform; sourceTree = ""; }; 46A16A8E1807B038005B8026 /* apple */ = { isa = PBXGroup; children = ( 46A16A8F1807B038005B8026 /* CCFileUtilsApple.h */, 46A16A901807B038005B8026 /* CCFileUtilsApple.mm */, 46A16A911807B038005B8026 /* CCLock.cpp */, 46A16A921807B038005B8026 /* CCLock.h */, 46A16A931807B038005B8026 /* CCThread.mm */, ); path = apple; sourceTree = ""; }; 46A16AA31807B038005B8026 /* ios */ = { isa = PBXGroup; children = ( 46A16AA41807B038005B8026 /* CCApplication.h */, 46A16AA51807B038005B8026 /* CCApplication.mm */, 46A16AA61807B038005B8026 /* CCCommon.mm */, 46A16AA71807B038005B8026 /* CCDevice.mm */, 46A16AA81807B038005B8026 /* CCDirectorCaller.h */, 46A16AA91807B038005B8026 /* CCDirectorCaller.mm */, 46A16AAA1807B038005B8026 /* CCEGLView.h */, 46A16AAB1807B038005B8026 /* CCEGLView.mm */, 46A16AAC1807B038005B8026 /* CCES2Renderer.h */, 46A16AAD1807B038005B8026 /* CCES2Renderer.m */, 46A16AAE1807B038005B8026 /* CCESRenderer.h */, 1A0DB7301823827C0025743D /* CCGL.h */, 46A16AB01807B038005B8026 /* CCImage.mm */, 46A16AB11807B038005B8026 /* CCPlatformDefine.h */, 46A16AB21807B038005B8026 /* CCStdC.h */, 1A0DB7311823827C0025743D /* EAGLView.h */, 46A16AB41807B038005B8026 /* EAGLView.mm */, 46A16AB51807B038005B8026 /* OpenGL_Internal.h */, 46A16AB61807B038005B8026 /* Simulation */, ); path = ios; sourceTree = ""; }; 46A16AB61807B038005B8026 /* Simulation */ = { isa = PBXGroup; children = ( 46A16AB71807B038005B8026 /* AccelerometerSimulation.h */, 46A16AB81807B038005B8026 /* AccelerometerSimulation.m */, ); path = Simulation; sourceTree = ""; }; 46A16AC71807B038005B8026 /* mac */ = { isa = PBXGroup; children = ( 46A16AC81807B038005B8026 /* CCApplication.h */, 46A16AC91807B038005B8026 /* CCApplication.mm */, 46A16ACA1807B038005B8026 /* CCCommon.mm */, 46A16ACB1807B038005B8026 /* CCDevice.cpp */, 46A16ACC1807B038005B8026 /* CCDirectorCaller.h */, 46A16ACD1807B038005B8026 /* CCDirectorCaller.mm */, 1A0DB7351823828F0025743D /* CCGL.h */, 46A16AD31807B038005B8026 /* CCImage.mm */, 46A16AD41807B038005B8026 /* CCPlatformDefine.h */, 46A16AD51807B038005B8026 /* CCStdC.h */, ); path = mac; sourceTree = ""; }; 46A170611807CE7A005B8026 /* physics */ = { isa = PBXGroup; children = ( 46A170791807CE7A005B8026 /* chipmunk */, 46A1706E1807CE7A005B8026 /* CCPhysicsBody.cpp */, 46A1706F1807CE7A005B8026 /* CCPhysicsBody.h */, 46A170701807CE7A005B8026 /* CCPhysicsContact.cpp */, 46A170711807CE7A005B8026 /* CCPhysicsContact.h */, 46A170721807CE7A005B8026 /* CCPhysicsJoint.cpp */, 46A170731807CE7A005B8026 /* CCPhysicsJoint.h */, 46A170751807CE7A005B8026 /* CCPhysicsShape.cpp */, 46A170761807CE7A005B8026 /* CCPhysicsShape.h */, 46A170771807CE7A005B8026 /* CCPhysicsWorld.cpp */, 46A170781807CE7A005B8026 /* CCPhysicsWorld.h */, ); name = physics; path = ../cocos/physics; sourceTree = ""; }; 46A170791807CE7A005B8026 /* chipmunk */ = { isa = PBXGroup; children = ( B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */, B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */, B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */, B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */, B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */, B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */, B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */, B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */, B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */, B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */, B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */, ); path = chipmunk; sourceTree = ""; }; 46A170851807CE87005B8026 /* math */ = { isa = PBXGroup; children = ( 46A170861807CE87005B8026 /* kazmath */, ); name = math; path = ../cocos/math; sourceTree = ""; }; 46A170861807CE87005B8026 /* kazmath */ = { isa = PBXGroup; children = ( 46A170871807CE87005B8026 /* include */, 46A170981807CE87005B8026 /* src */, ); path = kazmath; sourceTree = ""; }; 46A170871807CE87005B8026 /* include */ = { isa = PBXGroup; children = ( 46A170881807CE87005B8026 /* kazmath */, ); path = include; sourceTree = ""; }; 46A170881807CE87005B8026 /* kazmath */ = { isa = PBXGroup; children = ( 46A170891807CE87005B8026 /* aabb.h */, 46A1708A1807CE87005B8026 /* GL */, 46A1708D1807CE87005B8026 /* kazmath.h */, 46A1708E1807CE87005B8026 /* mat3.h */, 46A1708F1807CE87005B8026 /* mat4.h */, 46A170901807CE87005B8026 /* neon_matrix_impl.h */, 46A170911807CE87005B8026 /* plane.h */, 46A170921807CE87005B8026 /* quaternion.h */, 46A170931807CE87005B8026 /* ray2.h */, 46A170941807CE87005B8026 /* utility.h */, 46A170951807CE87005B8026 /* vec2.h */, 46A170961807CE87005B8026 /* vec3.h */, 46A170971807CE87005B8026 /* vec4.h */, ); path = kazmath; sourceTree = ""; }; 46A1708A1807CE87005B8026 /* GL */ = { isa = PBXGroup; children = ( 46A1708B1807CE87005B8026 /* mat4stack.h */, 46A1708C1807CE87005B8026 /* matrix.h */, ); path = GL; sourceTree = ""; }; 46A170981807CE87005B8026 /* src */ = { isa = PBXGroup; children = ( 46A170991807CE87005B8026 /* aabb.c */, 46A1709A1807CE87005B8026 /* ChangeLog */, 46A1709B1807CE87005B8026 /* CMakeLists.txt */, 46A1709C1807CE87005B8026 /* GL */, 46A1709F1807CE87005B8026 /* mat3.c */, 46A170A01807CE87005B8026 /* mat4.c */, 46A170A11807CE87005B8026 /* neon_matrix_impl.c */, 46A170A21807CE87005B8026 /* plane.c */, 46A170A31807CE87005B8026 /* quaternion.c */, 46A170A41807CE87005B8026 /* ray2.c */, 46A170A51807CE87005B8026 /* utility.c */, 46A170A61807CE87005B8026 /* vec2.c */, 46A170A71807CE87005B8026 /* vec3.c */, 46A170A81807CE87005B8026 /* vec4.c */, ); path = src; sourceTree = ""; }; 46A1709C1807CE87005B8026 /* GL */ = { isa = PBXGroup; children = ( 46A1709D1807CE87005B8026 /* mat4stack.c */, 46A1709E1807CE87005B8026 /* matrix.c */, ); path = GL; sourceTree = ""; }; 74AC83D91006ABC123943F35 /* renderer */ = { isa = PBXGroup; children = ( 50AE5EA1188749250007CFE3 /* CCBatchCommand.cpp */, 50AE5EA2188749250007CFE3 /* CCBatchCommand.h */, A0E6B27F18613EA5009C5D17 /* CCRenderCommandPool.h */, 593BDCD8184D0A6E00C21E48 /* CCCustomCommand.cpp */, 593BDCD9184D0A6E00C21E48 /* CCCustomCommand.h */, 74AC80EEB031D67E86B45096 /* CCFrustum.cpp */, 74AC840F2F17ED6D0163669F /* CCFrustum.h */, 593BDCDA184D0A6E00C21E48 /* CCGroupCommand.cpp */, 593BDCDB184D0A6E00C21E48 /* CCGroupCommand.h */, 74AC853F6B597094730AFB36 /* CCMaterialManager.cpp */, 74AC800F4905C8827A44EED3 /* CCMaterialManager.h */, 74AC8D28EF93BFF332D3C456 /* CCQuadCommand.cpp */, 74AC8C4AE1EB0FCB287E7396 /* CCQuadCommand.h */, 74AC80F6E92FC29EA536D7F8 /* CCRenderCommand.cpp */, 74AC8F4F7D9E52FCB522B647 /* CCRenderCommand.h */, 74AC8EB8FE47EED9B30B7106 /* CCRenderer.cpp */, 74AC8DF0EA49A124E1B11681 /* CCRenderer.h */, 74AC82DE19B10586E1C39974 /* CCRenderMaterial.cpp */, 74AC8CC6504014E3A59C55B2 /* CCRenderMaterial.h */, ); path = renderer; sourceTree = ""; }; A04583EF189053B500E32FE8 /* desktop */ = { isa = PBXGroup; children = ( A04583F0189053B500E32FE8 /* CCEGLView.cpp */, A04583F1189053B500E32FE8 /* CCEGLView.h */, ); path = desktop; sourceTree = ""; }; B3D8D4471799219B0039C204 /* mac */ = { isa = PBXGroup; children = ( 46A16E281807C99F005B8026 /* libwebsockets.a */, 46A16E211807C95C005B8026 /* libfreetype.a */, 46A16E221807C95C005B8026 /* libglfw3.a */, 46A16E231807C95C005B8026 /* libjpeg.a */, 46A16E241807C95C005B8026 /* libpng.a */, 46A16E251807C95C005B8026 /* libtiff.a */, 46A16E261807C95C005B8026 /* libwebp.a */, ); name = mac; sourceTree = ""; }; B3D8D44B179921D50039C204 /* ios */ = { isa = PBXGroup; children = ( 46A16E271807C992005B8026 /* libwebsockets.a */, 46A16E1B1807C948005B8026 /* libcurl.a */, 46A16E1C1807C948005B8026 /* libfreetype.a */, 46A16E1D1807C948005B8026 /* libjpeg.a */, 46A16E1E1807C948005B8026 /* libpng.a */, 46A16E1F1807C948005B8026 /* libtiff.a */, 46A16E201807C948005B8026 /* libwebp.a */, ); name = ios; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ 1551A33D158F2AB200E66CFE /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 2AC795DF18628723005EC8E1 /* SkeletonBounds.h in Headers */, 2AC795E018628723005EC8E1 /* Event.h in Headers */, 2AC795E118628723005EC8E1 /* EventData.h in Headers */, 2AC795E218628723005EC8E1 /* BoundingBoxAttachment.h in Headers */, 06CAAAC9186AD7EE0012A414 /* TriggerMng.h in Headers */, 46A170B01807CEA3005B8026 /* neon_matrix_impl.h in Headers */, 1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */, 1AA2063F1848437900053418 /* CCMap.h in Headers */, 46A170191807CBFC005B8026 /* CCCommon.h in Headers */, 46A170E71807CECA005B8026 /* CCPhysicsBody.h in Headers */, 46A170EB1807CECA005B8026 /* CCPhysicsJoint.h in Headers */, 46A170531807CC1C005B8026 /* CCDirectorCaller.h in Headers */, 46A170B71807CEA3005B8026 /* vec4.h in Headers */, 46A170B61807CEA3005B8026 /* vec3.h in Headers */, 50AE5EA5188749250007CFE3 /* CCBatchCommand.h in Headers */, 46A170241807CBFC005B8026 /* CCSAXParser.h in Headers */, 46A1701A1807CBFC005B8026 /* CCDevice.h in Headers */, 46A170161807CBFC005B8026 /* CCLock.h in Headers */, 46A170B31807CEA3005B8026 /* ray2.h in Headers */, 46A170B51807CEA3005B8026 /* vec2.h in Headers */, 46A170B21807CEA3005B8026 /* quaternion.h in Headers */, 46A1701C1807CBFC005B8026 /* CCEGLViewProtocol.h in Headers */, 46A1701E1807CBFC005B8026 /* CCFileUtils.h in Headers */, 46A170B11807CEA3005B8026 /* plane.h in Headers */, B37510771823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */, 46A1705B1807CC1C005B8026 /* CCPlatformDefine.h in Headers */, 46A170EE1807CECA005B8026 /* CCPhysicsShape.h in Headers */, 46A170AD1807CEA3005B8026 /* kazmath.h in Headers */, 46A170261807CBFC005B8026 /* CCThread.h in Headers */, 46A170AE1807CEA3005B8026 /* mat3.h in Headers */, 46A170AF1807CEA3005B8026 /* mat4.h in Headers */, 46A170AB1807CEA3005B8026 /* mat4stack.h in Headers */, 46A170E91807CECA005B8026 /* CCPhysicsContact.h in Headers */, 46A170B41807CEA3005B8026 /* utility.h in Headers */, B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 46A170A91807CE9D005B8026 /* aabb.h in Headers */, 46A1705C1807CC1C005B8026 /* CCStdC.h in Headers */, 46A1704F1807CC1C005B8026 /* CCApplication.h in Headers */, 46A170131807CBFC005B8026 /* CCFileUtilsApple.h in Headers */, 46A1701F1807CBFC005B8026 /* CCImage.h in Headers */, 46A170AC1807CEA3005B8026 /* matrix.h in Headers */, 46A170181807CBFC005B8026 /* CCApplicationProtocol.h in Headers */, 1A570063180BC5A10088DEC7 /* CCAction.h in Headers */, 1A570067180BC5A10088DEC7 /* CCActionCamera.h in Headers */, 1A57006B180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, 1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */, 06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */, A023FA34185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */, 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, A023FA36185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 593BDCF8184D0A6E00C21E48 /* CCGroupCommand.h in Headers */, 1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */, 1A570087180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */, ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */, 1A57008B180BC5A10088DEC7 /* CCActionProgressTimer.h in Headers */, 1A0DB7381823828F0025743D /* CCGL.h in Headers */, 1A57008F180BC5A10088DEC7 /* CCActionTiledGrid.h in Headers */, 1A570093180BC5A10088DEC7 /* CCActionTween.h in Headers */, 1A57009A180BC5C10088DEC7 /* CCAtlasNode.h in Headers */, 1A5700A0180BC5D20088DEC7 /* CCNode.h in Headers */, 59A79D531821E26E00F19697 /* CCEventListenerMouse.h in Headers */, 1A5700C7180BC6060088DEC7 /* atitc.h in Headers */, 1A5700CB180BC6060088DEC7 /* CCAffineTransform.h in Headers */, 1A5700CF180BC6060088DEC7 /* CCArray.h in Headers */, 06CAAAC6186AD7E60012A414 /* TriggerObj.h in Headers */, 1A5700D3180BC6060088DEC7 /* CCAutoreleasePool.h in Headers */, 1A5700D5180BC6060088DEC7 /* CCBool.h in Headers */, 1A5700D9180BC6060088DEC7 /* CCData.h in Headers */, 1A5700DD180BC6060088DEC7 /* CCDataVisitor.h in Headers */, 1A5700E1180BC6060088DEC7 /* CCDictionary.h in Headers */, 1A5700E3180BC6060088DEC7 /* CCDouble.h in Headers */, 1A5700E5180BC6060088DEC7 /* CCFloat.h in Headers */, 1A5700E9180BC6060088DEC7 /* CCGeometry.h in Headers */, 1A5700EB180BC6060088DEC7 /* CCInteger.h in Headers */, 1A5700EF180BC6060088DEC7 /* CCNS.h in Headers */, 1A5700F3180BC6060088DEC7 /* CCObject.h in Headers */, 1A5700F5180BC6060088DEC7 /* CCPlatformConfig.h in Headers */, 1A5700F7180BC6060088DEC7 /* CCPlatformMacros.h in Headers */, 1A5700FB180BC6060088DEC7 /* CCSet.h in Headers */, A04583F3189053B500E32FE8 /* CCEGLView.h in Headers */, 1A5700FF180BC6060088DEC7 /* CCString.h in Headers */, 1A570103180BC6060088DEC7 /* etc1.h in Headers */, 1A570107180BC6060088DEC7 /* s3tc.h in Headers */, 1A570110180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */, B37510791823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */, 1A570114180BC8EE0088DEC7 /* CCDrawNode.h in Headers */, 1A57011D180BC90D0088DEC7 /* CCGrabber.h in Headers */, 1A570121180BC90D0088DEC7 /* CCGrid.h in Headers */, 1A57013C180BC9460088DEC7 /* CCEvent.h in Headers */, 1A570140180BC9460088DEC7 /* CCEventAcceleration.h in Headers */, 1A570144180BC9460088DEC7 /* CCEventCustom.h in Headers */, 1A570148180BC9460088DEC7 /* CCEventDispatcher.h in Headers */, 1A57014C180BC9460088DEC7 /* CCEventKeyboard.h in Headers */, 1A570150180BC9460088DEC7 /* CCEventListener.h in Headers */, 1A570154180BC9460088DEC7 /* CCEventListenerAcceleration.h in Headers */, 1A570158180BC9460088DEC7 /* CCEventListenerCustom.h in Headers */, 1AE3C846184F14F700CF29B5 /* CCValue.h in Headers */, 1A57015C180BC9460088DEC7 /* CCEventListenerKeyboard.h in Headers */, 1A570160180BC9460088DEC7 /* CCEventListenerTouch.h in Headers */, 1A570164180BC9460088DEC7 /* CCEventTouch.h in Headers */, 1A57019F180BCB590088DEC7 /* CCFont.h in Headers */, 1A5701A3180BCB590088DEC7 /* CCFontAtlas.h in Headers */, 1A5701A7180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, 1A5701B3180BCB590088DEC7 /* CCFontFNT.h in Headers */, 1A5701B7180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */, 1A5701BB180BCB5A0088DEC7 /* CCLabel.h in Headers */, 1A5701BF180BCB5A0088DEC7 /* CCLabelAtlas.h in Headers */, 1A5701C3180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, 1A5701C9180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, 1A5701CD180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */, 1A087AEA1860400400196EF5 /* edtaa3func.h in Headers */, 1A5701E8180BCB8C0088DEC7 /* CCTransition.h in Headers */, 1A5701EC180BCB8C0088DEC7 /* CCTransitionPageTurn.h in Headers */, 1A5701F0180BCB8C0088DEC7 /* CCTransitionProgress.h in Headers */, 1A5701F9180BCBAD0088DEC7 /* CCMenu.h in Headers */, 1A5701FD180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, 1A570204180BCBD40088DEC7 /* CCClippingNode.h in Headers */, 1A57020A180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */, 1A570212180BCBF40088DEC7 /* CCProgressTimer.h in Headers */, 1A570216180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, 1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, 1A570227180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, 1A57022B180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, 1A57022F180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, 50A1FF1A18290ED4001840C4 /* UIListView.h in Headers */, 1A570236180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */, 1A57024D180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */, 1A57024F180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */, 1A570251180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */, 1A570253180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */, 1A570255180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, 1A570257180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, 50691340185016C1009BBDD7 /* CCConsole.h in Headers */, 1A570259180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */, 1A57025B180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */, 1A57025D180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */, 1A57025F180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */, 593BDCF4184D0A6E00C21E48 /* CCCustomCommand.h in Headers */, 1A570261180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 1A570263180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */, 1A570265180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */, 1A570267180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */, 1A570269180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, 1A57026D180BCC6F0088DEC7 /* CCShaderCache.h in Headers */, 1A57026F180BCC6F0088DEC7 /* ccShaderEx_SwitchMask_frag.h in Headers */, 1A570273180BCC6F0088DEC7 /* ccShaders.h in Headers */, 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570284180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, 1A570288180BCC900088DEC7 /* CCSpriteFrame.h in Headers */, 1A57028C180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */, 1A570294180BCCAB0088DEC7 /* CCAnimation.h in Headers */, 1A570298180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */, 1A57029F180BCD890088DEC7 /* base64.h in Headers */, 1A5702A5180BCD980088DEC7 /* CCNotificationCenter.h in Headers */, 1A5702AB180BCDAA0088DEC7 /* CCProfiling.h in Headers */, 1A5702B1180BCDBC0088DEC7 /* ccUTF8.h in Headers */, 1A5702B7180BCDF40088DEC7 /* CCVertex.h in Headers */, 1A5702BA180BCDFC0088DEC7 /* ccUtils.h in Headers */, 1A5702C0180BCE2A0088DEC7 /* CCIMEDelegate.h in Headers */, 1A5702C4180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */, 1A5702CA180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 1A5702D5180BCE570088DEC7 /* CCTexture2D.h in Headers */, 1A5702D9180BCE570088DEC7 /* CCTextureAtlas.h in Headers */, 1A5702DD180BCE570088DEC7 /* CCTextureCache.h in Headers */, 1A5702EC180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, 1A5702F0180BCE750088DEC7 /* CCTMXLayer.h in Headers */, 1A5702F4180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F8180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, 1A5702FC180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */, 1A570302180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 1A57030E180BCF190088DEC7 /* CCComponent.h in Headers */, 1A570312180BCF190088DEC7 /* CCComponentContainer.h in Headers */, B37510751823AC9F00B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */, 1A57031B180BCF430088DEC7 /* ccCArray.h in Headers */, 1A57031D180BCF430088DEC7 /* uthash.h in Headers */, 1A57031F180BCF430088DEC7 /* utlist.h in Headers */, 1A570326180BCF660088DEC7 /* TGAlib.h in Headers */, 1A570331180BCFD50088DEC7 /* CCUserDefault.h in Headers */, 1A57033C180BCFFA0088DEC7 /* ZipUtils.h in Headers */, 1A57034D180BD09B0088DEC7 /* tinyxml2.h in Headers */, 1A570356180BD0B00088DEC7 /* ioapi.h in Headers */, 1A57035A180BD0B00088DEC7 /* unzip.h in Headers */, 1A570535180BD9500088DEC7 /* CCGLProgram.h in Headers */, 1A570539180BD9500088DEC7 /* ccGLStateCache.h in Headers */, 1A570548180BD9C40088DEC7 /* CCTouch.h in Headers */, 1AD71DAB180E26E600808F54 /* CCBAnimationManager.h in Headers */, 1AD71DAF180E26E600808F54 /* CCBFileLoader.h in Headers */, B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */, 1AD71DB3180E26E600808F54 /* CCBKeyframe.h in Headers */, 06CAAAC3186AD7D80012A414 /* CCActionEaseEx.h in Headers */, 1AD71DB5180E26E600808F54 /* CCBMemberVariableAssigner.h in Headers */, 1AD71DB9180E26E600808F54 /* CCBReader.h in Headers */, 1AD71DBB180E26E600808F54 /* CCBSelectorResolver.h in Headers */, 1AD71DBF180E26E600808F54 /* CCBSequence.h in Headers */, 1AD71DC3180E26E600808F54 /* CCBSequenceProperty.h in Headers */, 1AD71DCB180E26E600808F54 /* CCControlButtonLoader.h in Headers */, 1AD71DCF180E26E600808F54 /* CCControlLoader.h in Headers */, 1AD71DD3180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */, 1AD71DD7180E26E600808F54 /* CCLabelTTFLoader.h in Headers */, 1AD71DDB180E26E600808F54 /* CCLayerColorLoader.h in Headers */, 1AD71DDF180E26E600808F54 /* CCLayerGradientLoader.h in Headers */, 1AD71DE3180E26E600808F54 /* CCLayerLoader.h in Headers */, 1AD71DE7180E26E600808F54 /* CCMenuItemImageLoader.h in Headers */, 1AD71DEB180E26E600808F54 /* CCMenuItemLoader.h in Headers */, 1AD71DED180E26E600808F54 /* CCMenuLoader.h in Headers */, 1AD71DF1180E26E600808F54 /* CCNode+CCBRelativePositioning.h in Headers */, 1AD71DF5180E26E600808F54 /* CCNodeLoader.h in Headers */, 1AD71DF9180E26E600808F54 /* CCNodeLoaderLibrary.h in Headers */, 1AD71DFB180E26E600808F54 /* CCNodeLoaderListener.h in Headers */, 1AD71DFF180E26E600808F54 /* CCParticleSystemQuadLoader.h in Headers */, 1AD71E03180E26E600808F54 /* CCScale9SpriteLoader.h in Headers */, 1AD71E07180E26E600808F54 /* CCScrollViewLoader.h in Headers */, 1AD71E0B180E26E600808F54 /* CCSpriteLoader.h in Headers */, 1AD71E0D180E26E600808F54 /* CocosBuilder.h in Headers */, 1AD71E97180E26E600808F54 /* Animation.h in Headers */, 1AD71E9B180E26E600808F54 /* AnimationState.h in Headers */, 1AD71E9F180E26E600808F54 /* AnimationStateData.h in Headers */, 1AD71EA3180E26E600808F54 /* Atlas.h in Headers */, 1AD71EA7180E26E600808F54 /* AtlasAttachmentLoader.h in Headers */, 1AD71EAB180E26E600808F54 /* Attachment.h in Headers */, 1AD71EAF180E26E600808F54 /* AttachmentLoader.h in Headers */, 1AD71EB3180E26E600808F54 /* Bone.h in Headers */, 1AD71EB7180E26E600808F54 /* BoneData.h in Headers */, 1AD71EBB180E26E600808F54 /* CCSkeleton.h in Headers */, 1AD71EBF180E26E600808F54 /* CCSkeletonAnimation.h in Headers */, 1AD71EC3180E26E600808F54 /* extension.h in Headers */, 1AD71EC7180E26E600808F54 /* Json.h in Headers */, 06CAAACD186AD7F90012A414 /* TriggerBase.h in Headers */, 1AD71ECB180E26E600808F54 /* RegionAttachment.h in Headers */, 1AD71ECF180E26E600808F54 /* Skeleton.h in Headers */, 1AD71ED3180E26E600808F54 /* SkeletonData.h in Headers */, 1AD71ED7180E26E600808F54 /* SkeletonJson.h in Headers */, 1AD71EDB180E26E600808F54 /* Skin.h in Headers */, 1AD71EDF180E26E600808F54 /* Slot.h in Headers */, 1AD71EE3180E26E600808F54 /* SlotData.h in Headers */, 1AD71EE7180E26E600808F54 /* spine-cocos2dx.h in Headers */, 1AD71EE9180E26E600808F54 /* spine.h in Headers */, 1A85BA0D1845F31700260FC0 /* CCVector.h in Headers */, 1AAF536C180E3374000584C8 /* HttpClient.h in Headers */, 1AAF536E180E3374000584C8 /* HttpRequest.h in Headers */, 1AAF5370180E3374000584C8 /* HttpResponse.h in Headers */, 1AAF5374180E3374000584C8 /* SocketIO.h in Headers */, 373B9129187891F400198F86 /* CCComBase.h in Headers */, 1AAF5378180E3374000584C8 /* WebSocket.h in Headers */, 1AAF5851180E40B9000584C8 /* LocalStorage.h in Headers */, 1A9DCA13180E6955007A3AD4 /* ccConfig.h in Headers */, 1A9DCA17180E6955007A3AD4 /* CCConfiguration.h in Headers */, 1A9DCA1F180E6955007A3AD4 /* CCDirector.h in Headers */, 1A9DCA21180E6955007A3AD4 /* CCEventType.h in Headers */, 1A9DCA25180E6955007A3AD4 /* ccFPSImages.h in Headers */, 1A9DCA29180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */, 1A9DCA2B180E6955007A3AD4 /* ccMacros.h in Headers */, 1A9DCA2D180E6955007A3AD4 /* CCProtocols.h in Headers */, 1A9DCA31180E6955007A3AD4 /* CCScheduler.h in Headers */, 1A9DCA39180E6955007A3AD4 /* cocos2d.h in Headers */, 1A9DCA3B180E6955007A3AD4 /* firePngData.h in Headers */, 1A9DCA3F180E6955007A3AD4 /* TransformUtils.h in Headers */, B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */, 1A9DCA45180E6D90007A3AD4 /* CCDeprecated.h in Headers */, 1A9DCA4B180E6DE3007A3AD4 /* ccTypes.h in Headers */, 1A8C58EE180E92CC00EF57C3 /* CocosGUI.h in Headers */, 1A8C58F2180E92CC00EF57C3 /* UILayout.h in Headers */, 1A8C58F6180E92CC00EF57C3 /* UILayoutParameter.h in Headers */, 1A8C58FA180E92CC00EF57C3 /* UIButton.h in Headers */, 1A8C58FE180E92CC00EF57C3 /* UICheckBox.h in Headers */, 1A8C5906180E92CC00EF57C3 /* UIHelper.h in Headers */, 1A8C590A180E92CC00EF57C3 /* UIImageView.h in Headers */, 1A8C5912180E92CC00EF57C3 /* UIText.h in Headers */, 1A8C5916180E92CC00EF57C3 /* UITextAtlas.h in Headers */, 1A8C591A180E92CC00EF57C3 /* UITextBMFont.h in Headers */, 1A8C5922180E92CC00EF57C3 /* UILayoutDefine.h in Headers */, 1A8C592A180E92CC00EF57C3 /* UILoadingBar.h in Headers */, 1A8C592E180E92CC00EF57C3 /* UIPageView.h in Headers */, 1A8C5934180E92CC00EF57C3 /* UIScrollInterface.h in Headers */, 1A8C5938180E92CC00EF57C3 /* UIScrollView.h in Headers */, 1A8C593C180E92CC00EF57C3 /* UISlider.h in Headers */, 1A8C5940180E92CC00EF57C3 /* UITextField.h in Headers */, 1A8C5944180E92CC00EF57C3 /* UIWidget.h in Headers */, 1A8C598D180E930E00EF57C3 /* CCActionFrame.h in Headers */, 1A8C5991180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */, 1A8C5995180E930E00EF57C3 /* CCActionManagerEx.h in Headers */, 1A8C5999180E930E00EF57C3 /* CCActionNode.h in Headers */, 1A8C599D180E930E00EF57C3 /* CCActionObject.h in Headers */, 1A8C59A1180E930E00EF57C3 /* CCArmature.h in Headers */, 1A8C59A5180E930E00EF57C3 /* CCArmatureAnimation.h in Headers */, 1A8C59A9180E930E00EF57C3 /* CCArmatureDataManager.h in Headers */, 1A8C59AD180E930E00EF57C3 /* CCArmatureDefine.h in Headers */, 1A8C59B1180E930E00EF57C3 /* CCBatchNode.h in Headers */, 1A8C59B5180E930E00EF57C3 /* CCBone.h in Headers */, 1A8C59B9180E930E00EF57C3 /* CCColliderDetector.h in Headers */, 1A8C59BD180E930E00EF57C3 /* CCComAttribute.h in Headers */, 1A8C59C1180E930E00EF57C3 /* CCComAudio.h in Headers */, 1A8C59C5180E930E00EF57C3 /* CCComController.h in Headers */, 1A8C59C9180E930E00EF57C3 /* CCComRender.h in Headers */, 1A8C59CD180E930E00EF57C3 /* CCDataReaderHelper.h in Headers */, 1A8C59D1180E930E00EF57C3 /* CCDatas.h in Headers */, 1A8C59D5180E930E00EF57C3 /* CCDecorativeDisplay.h in Headers */, 1A8C59D9180E930E00EF57C3 /* CCDisplayFactory.h in Headers */, 1A8C59DD180E930E00EF57C3 /* CCDisplayManager.h in Headers */, 1A8C59E1180E930E00EF57C3 /* CCInputDelegate.h in Headers */, 1A8C59E5180E930E00EF57C3 /* CCProcessBase.h in Headers */, 1A8C59E9180E930E00EF57C3 /* CCSGUIReader.h in Headers */, 1A8C59ED180E930E00EF57C3 /* CCSkin.h in Headers */, 1A8C59F1180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */, 1A8C59F5180E930E00EF57C3 /* CCSSceneReader.h in Headers */, 1A8C59F9180E930E00EF57C3 /* CCTransformHelp.h in Headers */, 1A8C59FD180E930E00EF57C3 /* CCTween.h in Headers */, 1A8C5A01180E930E00EF57C3 /* CCTweenFunction.h in Headers */, 1A8C5A05180E930E00EF57C3 /* CCUtilMath.h in Headers */, 1A8C5A07180E930E00EF57C3 /* CocoStudio.h in Headers */, 59A79D571821E26E00F19697 /* CCEventMouse.h in Headers */, 1A8C5A0F180E930E00EF57C3 /* DictionaryHelper.h in Headers */, 74AC82C9892F007745926C93 /* CCFrustum.h in Headers */, 74AC819B780D9EB49CC421AB /* CCRenderer.h in Headers */, 74AC81CAB5F3883FCC2A4A5B /* CCQuadCommand.h in Headers */, 74AC8E2CDB69E1FDBFCFBD78 /* CCRenderCommand.h in Headers */, 74AC8589A38C358F1E472BBD /* CCRenderMaterial.h in Headers */, 74AC8E3E7D85FB595242AAEC /* CCMaterialManager.h in Headers */, A0E6B28018613EA5009C5D17 /* CCRenderCommandPool.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A11972F178526AA00D62A44 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1F7B180E88C300497A22 /* CCBProxy.h in Headers */, 15A71D6118921E6900F30AC0 /* auxiliar.h in Headers */, 15A71DA71892291500F30AC0 /* lua_extensions.h in Headers */, 1A3B1F7F180E88C300497A22 /* CCLuaBridge.h in Headers */, 15A71D9518921E6900F30AC0 /* udp.h in Headers */, 15A71D8518921E6900F30AC0 /* socket.h in Headers */, 1A3B1F83180E88C300497A22 /* CCLuaEngine.h in Headers */, 15A71D9D18921E6900F30AC0 /* usocket.h in Headers */, 15CA8D1018697A56000032AB /* lua_cocos2dx_spine_manual.hpp in Headers */, 1A3B1F87180E88C300497A22 /* CCLuaStack.h in Headers */, 15A71D7D18921E6900F30AC0 /* options.h in Headers */, 15A71D9118921E6900F30AC0 /* timeout.h in Headers */, 1A3B1F8B180E88C300497A22 /* CCLuaValue.h in Headers */, 1A3B1F8F180E88C300497A22 /* Cocos2dxLuaLoader.h in Headers */, 15A71D7918921E6900F30AC0 /* mime.h in Headers */, 15A71D8D18921E6900F30AC0 /* tcp.h in Headers */, 1A3B1F93180E88C300497A22 /* lua_cocos2dx_deprecated.h in Headers */, 1A3B1F97180E88C300497A22 /* lua_cocos2dx_extension_manual.h in Headers */, 15A71D9918921E6900F30AC0 /* unix.h in Headers */, 1A3B1F9B180E88C300497A22 /* lua_cocos2dx_manual.hpp in Headers */, 1A3B1F9F180E88C300497A22 /* Lua_web_socket.h in Headers */, 15A71D6918921E6900F30AC0 /* inet.h in Headers */, 1A3B1FA3180E88C300497A22 /* LuaBasicConversions.h in Headers */, 15A71D7518921E6900F30AC0 /* luasocket_io.h in Headers */, 1A3B1FA7180E88C300497A22 /* LuaOpengl.h in Headers */, 1A2C78A9181A11EC004E5527 /* lua_cocos2dx_auto.hpp in Headers */, 1A3B1FAB180E88C300497A22 /* LuaScriptHandlerMgr.h in Headers */, 1A3B1FB7180E88C300497A22 /* CCLuaObjcBridge.h in Headers */, 15A71DA118921E6900F30AC0 /* wsocket.h in Headers */, 15A71D8918921E6900F30AC0 /* socket_scripts.h in Headers */, 15CA8D1C18697BE5000032AB /* LuaSkeletonAnimation.h in Headers */, 1A3B1FBD180E88C300497A22 /* tolua_fix.h in Headers */, 15A71D6518921E6900F30AC0 /* except.h in Headers */, 1A8C5647180E8D0D00EF57C3 /* tolua++.h in Headers */, 158E06E1181F6796008E01F6 /* lua_xml_http_request.h in Headers */, 1A2C78B5181A11EC004E5527 /* lua_cocos2dx_extension_auto.hpp in Headers */, 15A71D7118921E6900F30AC0 /* luasocket_buffer.h in Headers */, B362C3B51872BADF00F0BDF4 /* lua_cocos2dx_physics_manual.hpp in Headers */, 15A71D6D18921E6900F30AC0 /* luasocket.h in Headers */, 15A71D8118921E6900F30AC0 /* select.h in Headers */, 1A8C564B180E8D0D00EF57C3 /* tolua_event.h in Headers */, 15CA8D1618697AE1000032AB /* lua_cocos2dx_spine_auto.hpp in Headers */, B362C3AF1872BAB700F0BDF4 /* lua_cocos2dx_physics_auto.hpp in Headers */, 1585AB5E1828D74F00000FB5 /* lua_cocos2dx_studio_auto.hpp in Headers */, 15D6E848182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.hpp in Headers */, 15F4C8851875637D0082884F /* lua_cocos2dx_gui_auto.hpp in Headers */, 15F4CA221875885A0082884F /* lua_cocos2dx_gui_manual.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB51B17854BC200CDF010 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1F7A180E88C300497A22 /* CCBProxy.h in Headers */, 15A71D6018921E6900F30AC0 /* auxiliar.h in Headers */, 15A71DA61892291500F30AC0 /* lua_extensions.h in Headers */, 1A3B1F7E180E88C300497A22 /* CCLuaBridge.h in Headers */, 15A71D9418921E6900F30AC0 /* udp.h in Headers */, 15A71D8418921E6900F30AC0 /* socket.h in Headers */, 1A3B1F82180E88C300497A22 /* CCLuaEngine.h in Headers */, 15A71D9C18921E6900F30AC0 /* usocket.h in Headers */, 15CA8D0F18697A56000032AB /* lua_cocos2dx_spine_manual.hpp in Headers */, 1A3B1F86180E88C300497A22 /* CCLuaStack.h in Headers */, 15A71D7C18921E6900F30AC0 /* options.h in Headers */, 15A71D9018921E6900F30AC0 /* timeout.h in Headers */, 1A3B1F8A180E88C300497A22 /* CCLuaValue.h in Headers */, 1A3B1F8E180E88C300497A22 /* Cocos2dxLuaLoader.h in Headers */, 15A71D7818921E6900F30AC0 /* mime.h in Headers */, 15A71D8C18921E6900F30AC0 /* tcp.h in Headers */, 1A3B1F92180E88C300497A22 /* lua_cocos2dx_deprecated.h in Headers */, 1A3B1F96180E88C300497A22 /* lua_cocos2dx_extension_manual.h in Headers */, 15A71D9818921E6900F30AC0 /* unix.h in Headers */, 1A3B1F9A180E88C300497A22 /* lua_cocos2dx_manual.hpp in Headers */, 1A3B1F9E180E88C300497A22 /* Lua_web_socket.h in Headers */, 15A71D6818921E6900F30AC0 /* inet.h in Headers */, 1A3B1FA2180E88C300497A22 /* LuaBasicConversions.h in Headers */, 15A71D7418921E6900F30AC0 /* luasocket_io.h in Headers */, 1A3B1FA6180E88C300497A22 /* LuaOpengl.h in Headers */, 1A2C78A7181A11EC004E5527 /* lua_cocos2dx_auto.hpp in Headers */, 1A3B1FAA180E88C300497A22 /* LuaScriptHandlerMgr.h in Headers */, 1A3B1FB6180E88C300497A22 /* CCLuaObjcBridge.h in Headers */, 15A71DA018921E6900F30AC0 /* wsocket.h in Headers */, 15A71D8818921E6900F30AC0 /* socket_scripts.h in Headers */, 15CA8D1B18697BE5000032AB /* LuaSkeletonAnimation.h in Headers */, 1A3B1FBC180E88C300497A22 /* tolua_fix.h in Headers */, 15A71D6418921E6900F30AC0 /* except.h in Headers */, 1A8C5646180E8D0D00EF57C3 /* tolua++.h in Headers */, 158E06E0181F6796008E01F6 /* lua_xml_http_request.h in Headers */, 1A2C78B3181A11EC004E5527 /* lua_cocos2dx_extension_auto.hpp in Headers */, 15A71D7018921E6900F30AC0 /* luasocket_buffer.h in Headers */, B362C3B31872BADC00F0BDF4 /* lua_cocos2dx_physics_manual.hpp in Headers */, 15A71D6C18921E6900F30AC0 /* luasocket.h in Headers */, 15A71D8018921E6900F30AC0 /* select.h in Headers */, 1A8C564A180E8D0D00EF57C3 /* tolua_event.h in Headers */, 15CA8D1518697AE1000032AB /* lua_cocos2dx_spine_auto.hpp in Headers */, B362C3B11872BABC00F0BDF4 /* lua_cocos2dx_physics_auto.hpp in Headers */, 1585AB5D1828D74F00000FB5 /* lua_cocos2dx_studio_auto.hpp in Headers */, 15D6E847182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.hpp in Headers */, 15F4C8841875637D0082884F /* lua_cocos2dx_gui_auto.hpp in Headers */, 15F4CA211875885A0082884F /* lua_cocos2dx_gui_manual.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2C051780BD04006731B9 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 46A174251807D379005B8026 /* util.h in Headers */, 46A1742D1807D379005B8026 /* cpVect.h in Headers */, 46A1740F1807D365005B8026 /* prime.h in Headers */, 46A174141807D372005B8026 /* chipmunk_unsafe.h in Headers */, 46A174121807D372005B8026 /* chipmunk_private.h in Headers */, 46A174231807D379005B8026 /* cpSimpleMotor.h in Headers */, 46A1741D1807D379005B8026 /* cpGearJoint.h in Headers */, 46A1742B1807D379005B8026 /* cpSpace.h in Headers */, 46A174261807D379005B8026 /* cpArbiter.h in Headers */, 46A174211807D379005B8026 /* cpRatchetJoint.h in Headers */, 46A174111807D372005B8026 /* chipmunk_ffi.h in Headers */, 46A174241807D379005B8026 /* cpSlideJoint.h in Headers */, 46A174221807D379005B8026 /* cpRotaryLimitJoint.h in Headers */, 46A174101807D372005B8026 /* chipmunk.h in Headers */, 46A174131807D372005B8026 /* chipmunk_types.h in Headers */, 46A1741C1807D379005B8026 /* cpDampedSpring.h in Headers */, 46A1741F1807D379005B8026 /* cpPinJoint.h in Headers */, 46A1742A1807D379005B8026 /* cpShape.h in Headers */, 46A174271807D379005B8026 /* cpBB.h in Headers */, 46A1741B1807D379005B8026 /* cpDampedRotarySpring.h in Headers */, 46A1742C1807D379005B8026 /* cpSpatialIndex.h in Headers */, 46A174201807D379005B8026 /* cpPivotJoint.h in Headers */, 46A174281807D379005B8026 /* cpBody.h in Headers */, 46A174291807D379005B8026 /* cpPolyShape.h in Headers */, 46A1741E1807D379005B8026 /* cpGrooveJoint.h in Headers */, 46A1741A1807D379005B8026 /* cpConstraint.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2D7D1780BDF7006731B9 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 1AAF528C180E2ECC000584C8 /* b2BroadPhase.h in Headers */, 1AAF5291180E2ECC000584C8 /* b2Collision.h in Headers */, 1AAF5293180E2ECC000584C8 /* b2Distance.h in Headers */, 1AAF5295180E2ECC000584C8 /* b2DynamicTree.h in Headers */, 1AAF5297180E2ECC000584C8 /* b2TimeOfImpact.h in Headers */, 1AAF5298180E2ED2000584C8 /* Box2D.h in Headers */, 1AAF52B1180E2EE9000584C8 /* b2ChainShape.h in Headers */, 1AAF52B3180E2EE9000584C8 /* b2CircleShape.h in Headers */, 1AAF52B5180E2EE9000584C8 /* b2EdgeShape.h in Headers */, 1AAF52B7180E2EE9000584C8 /* b2PolygonShape.h in Headers */, 1AAF52B8180E2EE9000584C8 /* b2Shape.h in Headers */, 1AAF52C7180E2EEF000584C8 /* b2BlockAllocator.h in Headers */, 1AAF52C9180E2EEF000584C8 /* b2Draw.h in Headers */, 1AAF52CA180E2EEF000584C8 /* b2GrowableStack.h in Headers */, 1AAF52CC180E2EEF000584C8 /* b2Math.h in Headers */, 1AAF52CE180E2EEF000584C8 /* b2Settings.h in Headers */, B3AF01A21842FBA400A98B85 /* b2MotorJoint.h in Headers */, 1AAF52D0180E2EEF000584C8 /* b2StackAllocator.h in Headers */, 1AAF52D2180E2EEF000584C8 /* b2Timer.h in Headers */, 1AAF52D4180E2EF5000584C8 /* b2Body.h in Headers */, 1AAF52D6180E2EF5000584C8 /* b2ContactManager.h in Headers */, 1AAF52D8180E2EF5000584C8 /* b2Fixture.h in Headers */, 1AAF52DA180E2EF5000584C8 /* b2Island.h in Headers */, 1AAF52DB180E2EF5000584C8 /* b2TimeStep.h in Headers */, 1AAF52DD180E2EF5000584C8 /* b2World.h in Headers */, 1AAF52DF180E2EF5000584C8 /* b2WorldCallbacks.h in Headers */, 1AAF5300180E2EFE000584C8 /* b2ChainAndCircleContact.h in Headers */, 1AAF5302180E2EFE000584C8 /* b2ChainAndPolygonContact.h in Headers */, 1AAF5304180E2EFE000584C8 /* b2CircleContact.h in Headers */, 1AAF5306180E2EFE000584C8 /* b2Contact.h in Headers */, 1AAF5308180E2EFE000584C8 /* b2ContactSolver.h in Headers */, 1AAF530A180E2EFE000584C8 /* b2EdgeAndCircleContact.h in Headers */, 1AAF530C180E2EFE000584C8 /* b2EdgeAndPolygonContact.h in Headers */, 1AAF530E180E2EFE000584C8 /* b2PolygonAndCircleContact.h in Headers */, 1AAF5310180E2EFE000584C8 /* b2PolygonContact.h in Headers */, 1AAF5312180E2F04000584C8 /* b2DistanceJoint.h in Headers */, 1AAF5314180E2F04000584C8 /* b2FrictionJoint.h in Headers */, 1AAF5316180E2F04000584C8 /* b2GearJoint.h in Headers */, 1AAF5318180E2F04000584C8 /* b2Joint.h in Headers */, 1AAF531A180E2F04000584C8 /* b2MouseJoint.h in Headers */, 1AAF531C180E2F04000584C8 /* b2PrismaticJoint.h in Headers */, 1AAF531E180E2F04000584C8 /* b2PulleyJoint.h in Headers */, 1AAF5320180E2F04000584C8 /* b2RevoluteJoint.h in Headers */, 1AAF5322180E2F04000584C8 /* b2RopeJoint.h in Headers */, 1AAF5324180E2F04000584C8 /* b2WeldJoint.h in Headers */, 1AAF5326180E2F04000584C8 /* b2WheelJoint.h in Headers */, 1AAF533E180E2F10000584C8 /* b2Rope.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2EB817814268006731B9 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 46A160421807A5D4005B8026 /* Export.h in Headers */, 46A160471807A5D4005B8026 /* CDOpenALSupport.h in Headers */, 46A160461807A5D4005B8026 /* CDConfig.h in Headers */, 46A160491807A5D4005B8026 /* CDXMacOSXSupport.h in Headers */, 46A160441807A5D4005B8026 /* CDAudioManager.h in Headers */, 46A1604E1807A5D4005B8026 /* SimpleAudioEngine_objc.h in Headers */, 46A160431807A5D4005B8026 /* SimpleAudioEngine.h in Headers */, 46A1604B1807A5D4005B8026 /* CocosDenshion.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2FCA17814595006731B9 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 460E478318080902000CDD6D /* CCControlExtensions.h in Headers */, 460E477E18080902000CDD6D /* CCControl.h in Headers */, 460E47B11808090B000CDD6D /* CCEditBoxImpl.h in Headers */, 460E47BA1808090B000CDD6D /* CCEditBoxImplTizen.h in Headers */, 460E47B31808090B000CDD6D /* CCEditBoxImplAndroid.h in Headers */, 460E47B61808090B000CDD6D /* CCEditBoxImplMac.h in Headers */, 460E477B180808F5000CDD6D /* ExtensionMacros.h in Headers */, 460E479118080902000CDD6D /* CCControlUtils.h in Headers */, 460E468118080832000CDD6D /* cocos-ext.h in Headers */, 460E47B41808090B000CDD6D /* CCEditBoxImplIOS.h in Headers */, 460E47CC18080913000CDD6D /* CCScrollView.h in Headers */, 460E47B01808090B000CDD6D /* CCEditBox.h in Headers */, 460E478918080902000CDD6D /* CCControlSaturationBrightnessPicker.h in Headers */, 460E47D018080913000CDD6D /* CCTableView.h in Headers */, 460E478F18080902000CDD6D /* CCControlSwitch.h in Headers */, 460E479518080902000CDD6D /* CCScale9Sprite.h in Headers */, 460E478718080902000CDD6D /* CCControlPotentiometer.h in Headers */, 460E47BC1808090B000CDD6D /* CCEditBoxImplWin.h in Headers */, 460E478B18080902000CDD6D /* CCControlSlider.h in Headers */, 460E478218080902000CDD6D /* CCControlColourPicker.h in Headers */, 460E478518080902000CDD6D /* CCControlHuePicker.h in Headers */, 460E479318080902000CDD6D /* CCInvocation.h in Headers */, 460E478018080902000CDD6D /* CCControlButton.h in Headers */, 460E478D18080902000CDD6D /* CCControlStepper.h in Headers */, 460E47D218080913000CDD6D /* CCTableViewCell.h in Headers */, 1AD71EF2180E27CF00808F54 /* CCPhysicsDebugNode.h in Headers */, 1AD71EF6180E27CF00808F54 /* CCPhysicsSprite.h in Headers */, 1AAF5355180E3060000584C8 /* AssetsManager.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F31F11781479B006731B9 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 2AFCB8211863D67F00EB4B5C /* jsb_cocos2dx_spine_auto.cpp in Headers */, 1A2C7937181A1257004E5527 /* js_bindings_config.h in Headers */, 1A2C790F181A1257004E5527 /* js_bindings_chipmunk_auto_classes.h in Headers */, 1A2C7935181A1257004E5527 /* jsb_cocos2dx_extension_manual.h in Headers */, 1A2C791F181A1257004E5527 /* js_bindings_chipmunk_registration.h in Headers */, 1A2C7955181A1257004E5527 /* js_bindings_system_functions.h in Headers */, 1A2C7911181A1257004E5527 /* js_bindings_chipmunk_auto_classes_registration.h in Headers */, 1A2C7963181A1257004E5527 /* XMLHTTPRequest.h in Headers */, 1A2C795F181A1257004E5527 /* jsb_websocket.h in Headers */, 1A2C7969181A1257004E5527 /* spidermonkey_specifics.h in Headers */, 1A2C788E181A11EC004E5527 /* jsb_cocos2dx_extension_auto.hpp in Headers */, 1A2C7923181A1257004E5527 /* cocos2d_specifics.hpp in Headers */, 1A2C7931181A1257004E5527 /* jsb_cocos2dx_studio_manual.h in Headers */, 1A2C789A181A11EC004E5527 /* jsb_cocos2dx_studio_auto.hpp in Headers */, 1A2C794D181A1257004E5527 /* jsb_opengl_manual.h in Headers */, 1A2C7967181A1257004E5527 /* ScriptingCore.h in Headers */, 1A2C795B181A1257004E5527 /* js_bindings_system_registration.h in Headers */, 1A2C7949181A1257004E5527 /* jsb_opengl_functions.h in Headers */, 1A2C7925181A1257004E5527 /* cocosbuilder_specifics.hpp in Headers */, 1A2C7915181A1257004E5527 /* js_bindings_chipmunk_functions.h in Headers */, 1A2C7917181A1257004E5527 /* js_bindings_chipmunk_functions_registration.h in Headers */, 1A2C793B181A1257004E5527 /* js_bindings_core.h in Headers */, 1A2C793F181A1257004E5527 /* js_bindings_opengl.h in Headers */, 1A2C7945181A1257004E5527 /* jsb_helper.h in Headers */, 1A2C7957181A1257004E5527 /* js_bindings_system_functions_registration.h in Headers */, 1A2C7943181A1257004E5527 /* js_manual_conversions.h in Headers */, 1A2C7929181A1257004E5527 /* js_bindings_ccbreader.h in Headers */, 1A2C7951181A1257004E5527 /* jsb_opengl_registration.h in Headers */, 1A2C7876181A11EC004E5527 /* jsb_cocos2dx_auto.hpp in Headers */, 1A2C7882181A11EC004E5527 /* jsb_cocos2dx_builder_auto.hpp in Headers */, 1A2C791B181A1257004E5527 /* js_bindings_chipmunk_manual.h in Headers */, 2AFCB8221863D68B00EB4B5C /* jsb_cocos2dx_spine_auto.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4CB11783777C0073F6A7 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 2AC795E71862875D005EC8E1 /* SkeletonBounds.h in Headers */, 2AC795E81862875D005EC8E1 /* Event.h in Headers */, 2AC795E91862875D005EC8E1 /* EventData.h in Headers */, 2AC795EA1862875D005EC8E1 /* BoundingBoxAttachment.h in Headers */, 46A1702D1807CBFE005B8026 /* CCCommon.h in Headers */, 46A170FF1807CECB005B8026 /* CCPhysicsContact.h in Headers */, 593BDCF9184D0A6E00C21E48 /* CCGroupCommand.h in Headers */, 46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */, 46A1703F1807CC07005B8026 /* CCDirectorCaller.h in Headers */, 46A170B81807CEA4005B8026 /* mat4stack.h in Headers */, 46A170BF1807CEA4005B8026 /* quaternion.h in Headers */, 46A170381807CBFE005B8026 /* CCSAXParser.h in Headers */, 46A170BA1807CEA4005B8026 /* kazmath.h in Headers */, 46A170BD1807CEA4005B8026 /* neon_matrix_impl.h in Headers */, 46A1702E1807CBFE005B8026 /* CCDevice.h in Headers */, 46A1702A1807CBFE005B8026 /* CCLock.h in Headers */, 46A170451807CC07005B8026 /* CCESRenderer.h in Headers */, 46A170C41807CEA4005B8026 /* vec4.h in Headers */, 46A171011807CECB005B8026 /* CCPhysicsJoint.h in Headers */, 50AE5EA6188749250007CFE3 /* CCBatchCommand.h in Headers */, 46A170C01807CEA4005B8026 /* ray2.h in Headers */, 46A170BC1807CEA4005B8026 /* mat4.h in Headers */, 50A1FF1B18290ED4001840C4 /* UIListView.h in Headers */, 46A170411807CC07005B8026 /* CCEGLView.h in Headers */, A023FA37185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 46A170C21807CEA4005B8026 /* vec2.h in Headers */, 46A170301807CBFE005B8026 /* CCEGLViewProtocol.h in Headers */, 46A170321807CBFE005B8026 /* CCFileUtils.h in Headers */, 46A170BB1807CEA4005B8026 /* mat3.h in Headers */, 46A1703A1807CBFE005B8026 /* CCThread.h in Headers */, 46A170C11807CEA4005B8026 /* utility.h in Headers */, 46A170AA1807CE9E005B8026 /* aabb.h in Headers */, 46A170FD1807CECB005B8026 /* CCPhysicsBody.h in Headers */, 46A171061807CECB005B8026 /* CCPhysicsWorld.h in Headers */, 46A170491807CC07005B8026 /* CCStdC.h in Headers */, 46A1703B1807CC07005B8026 /* CCApplication.h in Headers */, 46A170271807CBFE005B8026 /* CCFileUtilsApple.h in Headers */, 46A170431807CC07005B8026 /* CCES2Renderer.h in Headers */, 46A170331807CBFE005B8026 /* CCImage.h in Headers */, 46A170BE1807CEA4005B8026 /* plane.h in Headers */, 46A170B91807CEA4005B8026 /* matrix.h in Headers */, 46A170481807CC07005B8026 /* CCPlatformDefine.h in Headers */, 46A1704D1807CC11005B8026 /* AccelerometerSimulation.h in Headers */, 46A170C31807CEA4005B8026 /* vec3.h in Headers */, 46A1704C1807CC07005B8026 /* OpenGL_Internal.h in Headers */, 46A1702C1807CBFE005B8026 /* CCApplicationProtocol.h in Headers */, 1A570064180BC5A10088DEC7 /* CCAction.h in Headers */, 06CAAACE186AD7FA0012A414 /* TriggerBase.h in Headers */, 1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */, 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, 1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570074180BC5A10088DEC7 /* CCActionGrid.h in Headers */, B37510841823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */, 1A570078180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A57007C180BC5A10088DEC7 /* CCActionInstant.h in Headers */, B37510861823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */, 1A570080180BC5A10088DEC7 /* CCActionInterval.h in Headers */, 1A570084180BC5A10088DEC7 /* CCActionManager.h in Headers */, 1A570088180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */, 1A57008C180BC5A10088DEC7 /* CCActionProgressTimer.h in Headers */, 1A570090180BC5A10088DEC7 /* CCActionTiledGrid.h in Headers */, 1A570094180BC5A10088DEC7 /* CCActionTween.h in Headers */, 1A0DB7331823827C0025743D /* EAGLView.h in Headers */, 1A57009B180BC5C10088DEC7 /* CCAtlasNode.h in Headers */, 1A5700A1180BC5D20088DEC7 /* CCNode.h in Headers */, 1A5700C8180BC6060088DEC7 /* atitc.h in Headers */, 1A5700CC180BC6060088DEC7 /* CCAffineTransform.h in Headers */, 1A5700D0180BC6060088DEC7 /* CCArray.h in Headers */, 1A5700D4180BC6060088DEC7 /* CCAutoreleasePool.h in Headers */, 1A5700D6180BC6060088DEC7 /* CCBool.h in Headers */, 1A5700DA180BC6060088DEC7 /* CCData.h in Headers */, 1A5700DE180BC6060088DEC7 /* CCDataVisitor.h in Headers */, 1A5700E2180BC6060088DEC7 /* CCDictionary.h in Headers */, 1A5700E4180BC6060088DEC7 /* CCDouble.h in Headers */, 1A5700E6180BC6060088DEC7 /* CCFloat.h in Headers */, 1A5700EA180BC6060088DEC7 /* CCGeometry.h in Headers */, 1A5700EC180BC6060088DEC7 /* CCInteger.h in Headers */, 1A5700F0180BC6060088DEC7 /* CCNS.h in Headers */, 1A5700F4180BC6060088DEC7 /* CCObject.h in Headers */, 1A5700F6180BC6060088DEC7 /* CCPlatformConfig.h in Headers */, 1A5700F8180BC6060088DEC7 /* CCPlatformMacros.h in Headers */, 1AA206401848437A00053418 /* CCMap.h in Headers */, 1A5700FC180BC6060088DEC7 /* CCSet.h in Headers */, 1A570100180BC6060088DEC7 /* CCString.h in Headers */, 1A570104180BC6060088DEC7 /* etc1.h in Headers */, 1A570108180BC6060088DEC7 /* s3tc.h in Headers */, 1A570111180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */, 1A570115180BC8EE0088DEC7 /* CCDrawNode.h in Headers */, 06CAAAC5186AD7E50012A414 /* TriggerObj.h in Headers */, 1A57011E180BC90D0088DEC7 /* CCGrabber.h in Headers */, 1A570122180BC90D0088DEC7 /* CCGrid.h in Headers */, 1A57013D180BC9460088DEC7 /* CCEvent.h in Headers */, 1A570141180BC9460088DEC7 /* CCEventAcceleration.h in Headers */, 1A570145180BC9460088DEC7 /* CCEventCustom.h in Headers */, 1A570149180BC9460088DEC7 /* CCEventDispatcher.h in Headers */, 1A57014D180BC9460088DEC7 /* CCEventKeyboard.h in Headers */, 1A570151180BC9460088DEC7 /* CCEventListener.h in Headers */, 1A570155180BC9460088DEC7 /* CCEventListenerAcceleration.h in Headers */, 1A570159180BC9460088DEC7 /* CCEventListenerCustom.h in Headers */, 1A57015D180BC9460088DEC7 /* CCEventListenerKeyboard.h in Headers */, 1A570161180BC9460088DEC7 /* CCEventListenerTouch.h in Headers */, 1A570165180BC9460088DEC7 /* CCEventTouch.h in Headers */, 1A5701A0180BCB590088DEC7 /* CCFont.h in Headers */, 1A5701A4180BCB590088DEC7 /* CCFontAtlas.h in Headers */, 1A5701A8180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, 1A5701B4180BCB590088DEC7 /* CCFontFNT.h in Headers */, 593BDCF5184D0A6E00C21E48 /* CCCustomCommand.h in Headers */, 1A5701B8180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */, 1A5701BC180BCB5A0088DEC7 /* CCLabel.h in Headers */, 1A5701C0180BCB5A0088DEC7 /* CCLabelAtlas.h in Headers */, 1A5701C4180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, 1A5701CA180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, 1A5701CE180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 1A5701E1180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E5180BCB8C0088DEC7 /* CCScene.h in Headers */, 1A5701E9180BCB8C0088DEC7 /* CCTransition.h in Headers */, 1A5701ED180BCB8C0088DEC7 /* CCTransitionPageTurn.h in Headers */, 1A5701F1180BCB8C0088DEC7 /* CCTransitionProgress.h in Headers */, 1A5701FA180BCBAD0088DEC7 /* CCMenu.h in Headers */, 1A5701FE180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, 1A570205180BCBD40088DEC7 /* CCClippingNode.h in Headers */, 1A57020B180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */, 1A570213180BCBF40088DEC7 /* CCProgressTimer.h in Headers */, B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */, 1A570217180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, 1A570224180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, 373B912A187891FB00198F86 /* CCComBase.h in Headers */, 1A570228180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, 1A57022C180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, 1A570230180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, 1A570237180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */, 1A57024E180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */, 1A570250180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */, 1A570252180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */, 1A570254180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */, 1A570256180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, 1A570258180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, 1A57025A180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */, 1A57025C180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */, 1A57025E180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */, 1A570260180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */, 1A570262180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 1A570264180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */, 1A570266180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */, 1A570268180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */, 1A57026A180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, 1A57026E180BCC6F0088DEC7 /* CCShaderCache.h in Headers */, 1A570270180BCC6F0088DEC7 /* ccShaderEx_SwitchMask_frag.h in Headers */, 1A570274180BCC6F0088DEC7 /* ccShaders.h in Headers */, 1A570281180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570285180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, 1A570289180BCC900088DEC7 /* CCSpriteFrame.h in Headers */, 1A57028D180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */, 1A570295180BCCAB0088DEC7 /* CCAnimation.h in Headers */, 1A570299180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */, 1A5702A0180BCD890088DEC7 /* base64.h in Headers */, 1A5702A6180BCD980088DEC7 /* CCNotificationCenter.h in Headers */, 1A5702AC180BCDAA0088DEC7 /* CCProfiling.h in Headers */, 1A5702B2180BCDBC0088DEC7 /* ccUTF8.h in Headers */, 1A5702B8180BCDF40088DEC7 /* CCVertex.h in Headers */, 06CAAAD2186AD8030012A414 /* ObjectFactory.h in Headers */, 1A5702BB180BCDFC0088DEC7 /* ccUtils.h in Headers */, 1A5702C1180BCE2A0088DEC7 /* CCIMEDelegate.h in Headers */, 1A5702C5180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */, 1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 1A5702D6180BCE570088DEC7 /* CCTexture2D.h in Headers */, 50691341185016C1009BBDD7 /* CCConsole.h in Headers */, 1A5702DA180BCE570088DEC7 /* CCTextureAtlas.h in Headers */, 1A5702DE180BCE570088DEC7 /* CCTextureCache.h in Headers */, 1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, 1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */, 1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F9180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, 1A5702FD180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */, 1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */, 1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */, 1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */, 1A57031C180BCF430088DEC7 /* ccCArray.h in Headers */, 1A57031E180BCF430088DEC7 /* uthash.h in Headers */, 1A570320180BCF430088DEC7 /* utlist.h in Headers */, B375107F1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */, 1A570327180BCF660088DEC7 /* TGAlib.h in Headers */, 1A570332180BCFD50088DEC7 /* CCUserDefault.h in Headers */, 1A57033D180BCFFA0088DEC7 /* ZipUtils.h in Headers */, 1A57034E180BD09B0088DEC7 /* tinyxml2.h in Headers */, 1A570357180BD0B00088DEC7 /* ioapi.h in Headers */, 1A57035B180BD0B00088DEC7 /* unzip.h in Headers */, 1A570536180BD9500088DEC7 /* CCGLProgram.h in Headers */, 1A57053A180BD9500088DEC7 /* ccGLStateCache.h in Headers */, 1A570549180BD9C40088DEC7 /* CCTouch.h in Headers */, 1AD71DAC180E26E600808F54 /* CCBAnimationManager.h in Headers */, 1AD71DB0180E26E600808F54 /* CCBFileLoader.h in Headers */, 1AD71DB4180E26E600808F54 /* CCBKeyframe.h in Headers */, 1AD71DB6180E26E600808F54 /* CCBMemberVariableAssigner.h in Headers */, 1AD71DBA180E26E600808F54 /* CCBReader.h in Headers */, 1AD71DBC180E26E600808F54 /* CCBSelectorResolver.h in Headers */, 1AD71DC0180E26E600808F54 /* CCBSequence.h in Headers */, 1AD71DC4180E26E600808F54 /* CCBSequenceProperty.h in Headers */, 1AD71DCC180E26E600808F54 /* CCControlButtonLoader.h in Headers */, 1AD71DD0180E26E600808F54 /* CCControlLoader.h in Headers */, 1AD71DD4180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */, 1AD71DD8180E26E600808F54 /* CCLabelTTFLoader.h in Headers */, 1AD71DDC180E26E600808F54 /* CCLayerColorLoader.h in Headers */, 1AD71DE0180E26E600808F54 /* CCLayerGradientLoader.h in Headers */, 1AD71DE4180E26E600808F54 /* CCLayerLoader.h in Headers */, 1AD71DE8180E26E600808F54 /* CCMenuItemImageLoader.h in Headers */, 1AD71DEC180E26E600808F54 /* CCMenuItemLoader.h in Headers */, 1AD71DEE180E26E600808F54 /* CCMenuLoader.h in Headers */, 1AD71DF2180E26E600808F54 /* CCNode+CCBRelativePositioning.h in Headers */, 1AD71DF6180E26E600808F54 /* CCNodeLoader.h in Headers */, 1AD71DFA180E26E600808F54 /* CCNodeLoaderLibrary.h in Headers */, 1AD71DFC180E26E600808F54 /* CCNodeLoaderListener.h in Headers */, 1AD71E00180E26E600808F54 /* CCParticleSystemQuadLoader.h in Headers */, 1AD71E04180E26E600808F54 /* CCScale9SpriteLoader.h in Headers */, 1AD71E08180E26E600808F54 /* CCScrollViewLoader.h in Headers */, 1AD71E0C180E26E600808F54 /* CCSpriteLoader.h in Headers */, 1AD71E0E180E26E600808F54 /* CocosBuilder.h in Headers */, 1AD71E98180E26E600808F54 /* Animation.h in Headers */, 59A79D541821E26E00F19697 /* CCEventListenerMouse.h in Headers */, 1AD71E9C180E26E600808F54 /* AnimationState.h in Headers */, 1AD71EA0180E26E600808F54 /* AnimationStateData.h in Headers */, 1AD71EA4180E26E600808F54 /* Atlas.h in Headers */, 1AD71EA8180E26E600808F54 /* AtlasAttachmentLoader.h in Headers */, 1ABA68B11888D700007D1BB4 /* CCFontCharMap.h in Headers */, 1AD71EAC180E26E600808F54 /* Attachment.h in Headers */, 1AD71EB0180E26E600808F54 /* AttachmentLoader.h in Headers */, 1AD71EB4180E26E600808F54 /* Bone.h in Headers */, 1AD71EB8180E26E600808F54 /* BoneData.h in Headers */, 06CAAACA186AD7EF0012A414 /* TriggerMng.h in Headers */, 1AD71EBC180E26E600808F54 /* CCSkeleton.h in Headers */, 1AD71EC0180E26E600808F54 /* CCSkeletonAnimation.h in Headers */, 1AD71EC4180E26E600808F54 /* extension.h in Headers */, 1AD71EC8180E26E600808F54 /* Json.h in Headers */, 1AD71ECC180E26E600808F54 /* RegionAttachment.h in Headers */, 1AD71ED0180E26E600808F54 /* Skeleton.h in Headers */, 1AD71ED4180E26E600808F54 /* SkeletonData.h in Headers */, 1AD71ED8180E26E600808F54 /* SkeletonJson.h in Headers */, 1AD71EDC180E26E600808F54 /* Skin.h in Headers */, 1A85BA0E1845F31700260FC0 /* CCVector.h in Headers */, 1AD71EE0180E26E600808F54 /* Slot.h in Headers */, 1AD71EE4180E26E600808F54 /* SlotData.h in Headers */, 06CAAAC2186AD7D70012A414 /* CCActionEaseEx.h in Headers */, 1AD71EE8180E26E600808F54 /* spine-cocos2dx.h in Headers */, 1AD71EEA180E26E600808F54 /* spine.h in Headers */, 1AAF536D180E3374000584C8 /* HttpClient.h in Headers */, A0E6B28118613EA5009C5D17 /* CCRenderCommandPool.h in Headers */, 1AAF536F180E3374000584C8 /* HttpRequest.h in Headers */, 59A79D581821E26E00F19697 /* CCEventMouse.h in Headers */, 1AAF5371180E3374000584C8 /* HttpResponse.h in Headers */, 1AAF5375180E3374000584C8 /* SocketIO.h in Headers */, 1AAF5379180E3374000584C8 /* WebSocket.h in Headers */, 1AAF5852180E40B9000584C8 /* LocalStorage.h in Headers */, 1A9DCA14180E6955007A3AD4 /* ccConfig.h in Headers */, 1A9DCA18180E6955007A3AD4 /* CCConfiguration.h in Headers */, 1A9DCA20180E6955007A3AD4 /* CCDirector.h in Headers */, 1A9DCA22180E6955007A3AD4 /* CCEventType.h in Headers */, 1A9DCA26180E6955007A3AD4 /* ccFPSImages.h in Headers */, 1A9DCA2A180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */, 1A9DCA2C180E6955007A3AD4 /* ccMacros.h in Headers */, 1A0DB7321823827C0025743D /* CCGL.h in Headers */, 1A9DCA2E180E6955007A3AD4 /* CCProtocols.h in Headers */, 1A9DCA32180E6955007A3AD4 /* CCScheduler.h in Headers */, 1A9DCA3A180E6955007A3AD4 /* cocos2d.h in Headers */, 1A9DCA3C180E6955007A3AD4 /* firePngData.h in Headers */, 1A9DCA40180E6955007A3AD4 /* TransformUtils.h in Headers */, 1A9DCA46180E6D90007A3AD4 /* CCDeprecated.h in Headers */, 1A9DCA4C180E6DE3007A3AD4 /* ccTypes.h in Headers */, 1A8C58EF180E92CC00EF57C3 /* CocosGUI.h in Headers */, 1A8C58F3180E92CC00EF57C3 /* UILayout.h in Headers */, 1A8C58F7180E92CC00EF57C3 /* UILayoutParameter.h in Headers */, 1A8C58FB180E92CC00EF57C3 /* UIButton.h in Headers */, 1A8C58FF180E92CC00EF57C3 /* UICheckBox.h in Headers */, 1A8C5907180E92CC00EF57C3 /* UIHelper.h in Headers */, 1A8C590B180E92CC00EF57C3 /* UIImageView.h in Headers */, 1A8C5913180E92CC00EF57C3 /* UIText.h in Headers */, 1A8C5917180E92CC00EF57C3 /* UITextAtlas.h in Headers */, 1A8C591B180E92CC00EF57C3 /* UITextBMFont.h in Headers */, 1A8C5923180E92CC00EF57C3 /* UILayoutDefine.h in Headers */, 1A8C592B180E92CC00EF57C3 /* UILoadingBar.h in Headers */, 1A8C592F180E92CC00EF57C3 /* UIPageView.h in Headers */, 1A8C5935180E92CC00EF57C3 /* UIScrollInterface.h in Headers */, 1A8C5939180E92CC00EF57C3 /* UIScrollView.h in Headers */, 1A8C593D180E92CC00EF57C3 /* UISlider.h in Headers */, 1A8C5941180E92CC00EF57C3 /* UITextField.h in Headers */, 1A8C5945180E92CC00EF57C3 /* UIWidget.h in Headers */, 1A8C598E180E930E00EF57C3 /* CCActionFrame.h in Headers */, 1A8C5992180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */, 1A8C5996180E930E00EF57C3 /* CCActionManagerEx.h in Headers */, 1A8C599A180E930E00EF57C3 /* CCActionNode.h in Headers */, 1A8C599E180E930E00EF57C3 /* CCActionObject.h in Headers */, 1A8C59A2180E930E00EF57C3 /* CCArmature.h in Headers */, 1A8C59A6180E930E00EF57C3 /* CCArmatureAnimation.h in Headers */, 1A8C59AA180E930E00EF57C3 /* CCArmatureDataManager.h in Headers */, 1A8C59AE180E930E00EF57C3 /* CCArmatureDefine.h in Headers */, 1A8C59B2180E930E00EF57C3 /* CCBatchNode.h in Headers */, 1A8C59B6180E930E00EF57C3 /* CCBone.h in Headers */, 1A8C59BA180E930E00EF57C3 /* CCColliderDetector.h in Headers */, 1A8C59BE180E930E00EF57C3 /* CCComAttribute.h in Headers */, 1A8C59C2180E930E00EF57C3 /* CCComAudio.h in Headers */, 1A8C59C6180E930E00EF57C3 /* CCComController.h in Headers */, 1A8C59CA180E930E00EF57C3 /* CCComRender.h in Headers */, 1A8C59CE180E930E00EF57C3 /* CCDataReaderHelper.h in Headers */, 1A8C59D2180E930E00EF57C3 /* CCDatas.h in Headers */, ED9C6A9718599AD8000A5232 /* CCNodeGrid.h in Headers */, 1A8C59D6180E930E00EF57C3 /* CCDecorativeDisplay.h in Headers */, 1A8C59DA180E930E00EF57C3 /* CCDisplayFactory.h in Headers */, 1A8C59DE180E930E00EF57C3 /* CCDisplayManager.h in Headers */, 1A8C59E2180E930E00EF57C3 /* CCInputDelegate.h in Headers */, 1A8C59E6180E930E00EF57C3 /* CCProcessBase.h in Headers */, B375107D1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */, 1A8C59EA180E930E00EF57C3 /* CCSGUIReader.h in Headers */, 1A8C59EE180E930E00EF57C3 /* CCSkin.h in Headers */, B37510801823ACA100B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */, A023FA35185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 1A8C59F2180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */, 1A8C59F6180E930E00EF57C3 /* CCSSceneReader.h in Headers */, 1A8C59FA180E930E00EF57C3 /* CCTransformHelp.h in Headers */, 1A8C59FE180E930E00EF57C3 /* CCTween.h in Headers */, 1A8C5A02180E930E00EF57C3 /* CCTweenFunction.h in Headers */, 1AE3C847184F14F700CF29B5 /* CCValue.h in Headers */, 1A8C5A06180E930E00EF57C3 /* CCUtilMath.h in Headers */, 1A8C5A08180E930E00EF57C3 /* CocoStudio.h in Headers */, 1A8C5A10180E930E00EF57C3 /* DictionaryHelper.h in Headers */, 74AC8EE0C2AAB82783F47089 /* CCFrustum.h in Headers */, 74AC84A2F1052B49CA60C2D1 /* CCRenderer.h in Headers */, 74AC8AE45B093F2F76A5B1C2 /* CCQuadCommand.h in Headers */, 74AC8573F4F84201C08E5523 /* CCRenderCommand.h in Headers */, 74AC87A5A3B3AD5055CCA3B9 /* CCRenderMaterial.h in Headers */, 74AC8A10DE9DE8E14D8B3735 /* CCMaterialManager.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4E7D1783867C0073F6A7 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 460E47A618080904000CDD6D /* CCControlStepper.h in Headers */, 460E47D418080914000CDD6D /* CCScrollView.h in Headers */, 460E479918080904000CDD6D /* CCControlButton.h in Headers */, 460E47A418080904000CDD6D /* CCControlSlider.h in Headers */, 460E479E18080904000CDD6D /* CCControlHuePicker.h in Headers */, 460E468218080836000CDD6D /* cocos-ext.h in Headers */, 460E47C41808090D000CDD6D /* CCEditBoxImplMac.h in Headers */, 460E47BF1808090D000CDD6D /* CCEditBoxImpl.h in Headers */, 460E47AE18080904000CDD6D /* CCScale9Sprite.h in Headers */, 460E477C180808F7000CDD6D /* ExtensionMacros.h in Headers */, 460E47A218080904000CDD6D /* CCControlSaturationBrightnessPicker.h in Headers */, 460E479B18080904000CDD6D /* CCControlColourPicker.h in Headers */, 460E47C11808090D000CDD6D /* CCEditBoxImplAndroid.h in Headers */, 460E47CA1808090D000CDD6D /* CCEditBoxImplWin.h in Headers */, 460E47AA18080904000CDD6D /* CCControlUtils.h in Headers */, 460E47C81808090D000CDD6D /* CCEditBoxImplTizen.h in Headers */, 460E47A818080904000CDD6D /* CCControlSwitch.h in Headers */, 460E47D818080914000CDD6D /* CCTableView.h in Headers */, 460E479718080904000CDD6D /* CCControl.h in Headers */, 460E479C18080904000CDD6D /* CCControlExtensions.h in Headers */, 460E47DA18080914000CDD6D /* CCTableViewCell.h in Headers */, 460E47AC18080904000CDD6D /* CCInvocation.h in Headers */, 460E47A018080904000CDD6D /* CCControlPotentiometer.h in Headers */, 460E47BE1808090D000CDD6D /* CCEditBox.h in Headers */, 460E47C21808090D000CDD6D /* CCEditBoxImplIOS.h in Headers */, 1AD71EF3180E27CF00808F54 /* CCPhysicsDebugNode.h in Headers */, 1AD71EF7180E27CF00808F54 /* CCPhysicsSprite.h in Headers */, 1AAF5356180E3060000584C8 /* AssetsManager.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4F1D178387670073F6A7 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 46A174391807D37B005B8026 /* util.h in Headers */, 46A174411807D37B005B8026 /* cpVect.h in Headers */, 46A173F21807D363005B8026 /* prime.h in Headers */, 46A174191807D374005B8026 /* chipmunk_unsafe.h in Headers */, 46A174171807D374005B8026 /* chipmunk_private.h in Headers */, 46A174371807D37B005B8026 /* cpSimpleMotor.h in Headers */, 46A174311807D37B005B8026 /* cpGearJoint.h in Headers */, 46A1743F1807D37B005B8026 /* cpSpace.h in Headers */, 46A1743A1807D37B005B8026 /* cpArbiter.h in Headers */, 46A174351807D37B005B8026 /* cpRatchetJoint.h in Headers */, 46A174161807D374005B8026 /* chipmunk_ffi.h in Headers */, 46A174381807D37B005B8026 /* cpSlideJoint.h in Headers */, 46A174361807D37B005B8026 /* cpRotaryLimitJoint.h in Headers */, 46A174151807D374005B8026 /* chipmunk.h in Headers */, 46A174181807D374005B8026 /* chipmunk_types.h in Headers */, 46A174301807D37B005B8026 /* cpDampedSpring.h in Headers */, 46A174331807D37B005B8026 /* cpPinJoint.h in Headers */, 46A1743E1807D37B005B8026 /* cpShape.h in Headers */, 46A1743B1807D37B005B8026 /* cpBB.h in Headers */, 46A1742F1807D37B005B8026 /* cpDampedRotarySpring.h in Headers */, 46A174401807D37B005B8026 /* cpSpatialIndex.h in Headers */, 46A174341807D37B005B8026 /* cpPivotJoint.h in Headers */, 46A1743C1807D37B005B8026 /* cpBody.h in Headers */, 46A1743D1807D37B005B8026 /* cpPolyShape.h in Headers */, 46A174321807D37B005B8026 /* cpGrooveJoint.h in Headers */, 46A1742E1807D37B005B8026 /* cpConstraint.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4F6C1783876B0073F6A7 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 1AAF5299180E2EE1000584C8 /* Box2D.h in Headers */, 1AAF529B180E2EE4000584C8 /* b2BroadPhase.h in Headers */, 1AAF52A0180E2EE4000584C8 /* b2Collision.h in Headers */, 1AAF52A2180E2EE4000584C8 /* b2Distance.h in Headers */, 1AAF52A4180E2EE4000584C8 /* b2DynamicTree.h in Headers */, 1AAF52A6180E2EE4000584C8 /* b2TimeOfImpact.h in Headers */, 1AAF52A8180E2EE8000584C8 /* b2ChainShape.h in Headers */, 1AAF52AA180E2EE8000584C8 /* b2CircleShape.h in Headers */, 1AAF52AC180E2EE8000584C8 /* b2EdgeShape.h in Headers */, 1AAF52AE180E2EE8000584C8 /* b2PolygonShape.h in Headers */, 1AAF52AF180E2EE8000584C8 /* b2Shape.h in Headers */, 1AAF52BA180E2EEE000584C8 /* b2BlockAllocator.h in Headers */, 1AAF52BC180E2EEE000584C8 /* b2Draw.h in Headers */, 1AAF52BD180E2EEE000584C8 /* b2GrowableStack.h in Headers */, 1AAF52BF180E2EEE000584C8 /* b2Math.h in Headers */, 1AAF52C1180E2EEE000584C8 /* b2Settings.h in Headers */, B3AF01A31842FBA400A98B85 /* b2MotorJoint.h in Headers */, 1AAF52C3180E2EEE000584C8 /* b2StackAllocator.h in Headers */, 1AAF52C5180E2EEE000584C8 /* b2Timer.h in Headers */, 1AAF52E1180E2EF6000584C8 /* b2Body.h in Headers */, 1AAF52E3180E2EF6000584C8 /* b2ContactManager.h in Headers */, 1AAF52E5180E2EF6000584C8 /* b2Fixture.h in Headers */, 1AAF52E7180E2EF6000584C8 /* b2Island.h in Headers */, 1AAF52E8180E2EF6000584C8 /* b2TimeStep.h in Headers */, 1AAF52EA180E2EF6000584C8 /* b2World.h in Headers */, 1AAF52EC180E2EF6000584C8 /* b2WorldCallbacks.h in Headers */, 1AAF52EE180E2EFC000584C8 /* b2ChainAndCircleContact.h in Headers */, 1AAF52F0180E2EFC000584C8 /* b2ChainAndPolygonContact.h in Headers */, 1AAF52F2180E2EFC000584C8 /* b2CircleContact.h in Headers */, 1AAF52F4180E2EFC000584C8 /* b2Contact.h in Headers */, 1AAF52F6180E2EFC000584C8 /* b2ContactSolver.h in Headers */, 1AAF52F8180E2EFC000584C8 /* b2EdgeAndCircleContact.h in Headers */, 1AAF52FA180E2EFC000584C8 /* b2EdgeAndPolygonContact.h in Headers */, 1AAF52FC180E2EFC000584C8 /* b2PolygonAndCircleContact.h in Headers */, 1AAF52FE180E2EFC000584C8 /* b2PolygonContact.h in Headers */, 1AAF5328180E2F04000584C8 /* b2DistanceJoint.h in Headers */, 1AAF532A180E2F04000584C8 /* b2FrictionJoint.h in Headers */, 1AAF532C180E2F04000584C8 /* b2GearJoint.h in Headers */, 1AAF532E180E2F04000584C8 /* b2Joint.h in Headers */, 1AAF5330180E2F04000584C8 /* b2MouseJoint.h in Headers */, 1AAF5332180E2F04000584C8 /* b2PrismaticJoint.h in Headers */, 1AAF5334180E2F04000584C8 /* b2PulleyJoint.h in Headers */, 1AAF5336180E2F04000584C8 /* b2RevoluteJoint.h in Headers */, 1AAF5338180E2F04000584C8 /* b2RopeJoint.h in Headers */, 1AAF533A180E2F04000584C8 /* b2WeldJoint.h in Headers */, 1AAF533C180E2F04000584C8 /* b2WheelJoint.h in Headers */, 1AAF5340180E2F11000584C8 /* b2Rope.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4FA8178387730073F6A7 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 46A160501807A5EB005B8026 /* Export.h in Headers */, 46A1605A1807A5EB005B8026 /* SimpleAudioEngine_objc.h in Headers */, 46A160551807A5EB005B8026 /* CDOpenALSupport.h in Headers */, 46A160541807A5EB005B8026 /* CDConfig.h in Headers */, 46A160521807A5EB005B8026 /* CDAudioManager.h in Headers */, 46A160571807A5EB005B8026 /* CocosDenshion.h in Headers */, 46A160511807A5EB005B8026 /* SimpleAudioEngine.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4FCE178387750073F6A7 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( 1A2C7938181A1257004E5527 /* js_bindings_config.h in Headers */, 1A2C7910181A1257004E5527 /* js_bindings_chipmunk_auto_classes.h in Headers */, 1A2C7936181A1257004E5527 /* jsb_cocos2dx_extension_manual.h in Headers */, 1A2C7920181A1257004E5527 /* js_bindings_chipmunk_registration.h in Headers */, 1A2C7956181A1257004E5527 /* js_bindings_system_functions.h in Headers */, 1A2C7912181A1257004E5527 /* js_bindings_chipmunk_auto_classes_registration.h in Headers */, 1A2C7964181A1257004E5527 /* XMLHTTPRequest.h in Headers */, 1A2C7960181A1257004E5527 /* jsb_websocket.h in Headers */, 1A2C796A181A1257004E5527 /* spidermonkey_specifics.h in Headers */, 1A2C7890181A11EC004E5527 /* jsb_cocos2dx_extension_auto.hpp in Headers */, 1A2C7924181A1257004E5527 /* cocos2d_specifics.hpp in Headers */, 1A2C7932181A1257004E5527 /* jsb_cocos2dx_studio_manual.h in Headers */, 1A2C789C181A11EC004E5527 /* jsb_cocos2dx_studio_auto.hpp in Headers */, 1A2C794E181A1257004E5527 /* jsb_opengl_manual.h in Headers */, 1A2C7968181A1257004E5527 /* ScriptingCore.h in Headers */, 1A2C795C181A1257004E5527 /* js_bindings_system_registration.h in Headers */, 1A2C794A181A1257004E5527 /* jsb_opengl_functions.h in Headers */, 1A2C7926181A1257004E5527 /* cocosbuilder_specifics.hpp in Headers */, 1A2C7916181A1257004E5527 /* js_bindings_chipmunk_functions.h in Headers */, 1A2C7918181A1257004E5527 /* js_bindings_chipmunk_functions_registration.h in Headers */, 1A2C793C181A1257004E5527 /* js_bindings_core.h in Headers */, 1A2C7940181A1257004E5527 /* js_bindings_opengl.h in Headers */, 1A2C7946181A1257004E5527 /* jsb_helper.h in Headers */, 1A2C7958181A1257004E5527 /* js_bindings_system_functions_registration.h in Headers */, 1A2C7944181A1257004E5527 /* js_manual_conversions.h in Headers */, 1A2C792A181A1257004E5527 /* js_bindings_ccbreader.h in Headers */, 1A2C7952181A1257004E5527 /* jsb_opengl_registration.h in Headers */, 1A2C7878181A11EC004E5527 /* jsb_cocos2dx_auto.hpp in Headers */, 1A2C7884181A11EC004E5527 /* jsb_cocos2dx_builder_auto.hpp in Headers */, 1A2C791C181A1257004E5527 /* js_bindings_chipmunk_manual.h in Headers */, 2AFCB8251863D70300EB4B5C /* jsb_cocos2dx_spine_auto.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 1551A33E158F2AB200E66CFE /* cocos2dx Mac */ = { isa = PBXNativeTarget; buildConfigurationList = 1551A34C158F2AB200E66CFE /* Build configuration list for PBXNativeTarget "cocos2dx Mac" */; buildPhases = ( 1551A33B158F2AB200E66CFE /* Sources */, 1551A33C158F2AB200E66CFE /* Frameworks */, 1551A33D158F2AB200E66CFE /* Headers */, ); buildRules = ( ); dependencies = ( 460E44F41807E241000CDD6D /* PBXTargetDependency */, ); name = "cocos2dx Mac"; productName = cocos2dx; productReference = 1551A33F158F2AB200E66CFE /* libcocos2dx Mac.a */; productType = "com.apple.product-type.library.static"; }; 1A119716178526AA00D62A44 /* luabindings iOS */ = { isa = PBXNativeTarget; buildConfigurationList = 1A11978E178526AA00D62A44 /* Build configuration list for PBXNativeTarget "luabindings iOS" */; buildPhases = ( 1A119717178526AA00D62A44 /* Sources */, 1A11972D178526AA00D62A44 /* Frameworks */, 1A11972F178526AA00D62A44 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "luabindings iOS"; productName = cocos2dx; productReference = 1A119791178526AA00D62A44 /* libluabindings iOS.a */; productType = "com.apple.product-type.library.static"; }; 1A6FB50417854BC200CDF010 /* luabindings Mac */ = { isa = PBXNativeTarget; buildConfigurationList = 1A6FB52D17854BC200CDF010 /* Build configuration list for PBXNativeTarget "luabindings Mac" */; buildPhases = ( 1A6FB50517854BC200CDF010 /* Sources */, 1A6FB51817854BC200CDF010 /* Frameworks */, 1A6FB51B17854BC200CDF010 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "luabindings Mac"; productName = cocos2dx; productReference = 1A6FB53017854BC300CDF010 /* libluabindings Mac.a */; productType = "com.apple.product-type.library.static"; }; A03F2B781780BD04006731B9 /* chipmunk Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A03F2CB51780BD04006731B9 /* Build configuration list for PBXNativeTarget "chipmunk Mac" */; buildPhases = ( A03F2B791780BD04006731B9 /* Sources */, A03F2C011780BD04006731B9 /* Frameworks */, A03F2C051780BD04006731B9 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "chipmunk Mac"; productName = cocos2dx; productReference = A03F2CB81780BD04006731B9 /* libchipmunk Mac.a */; productType = "com.apple.product-type.library.static"; }; A03F2D5D1780BDF7006731B9 /* box2d Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A03F2D981780BDF7006731B9 /* Build configuration list for PBXNativeTarget "box2d Mac" */; buildPhases = ( A03F2D5E1780BDF7006731B9 /* Sources */, A03F2D7C1780BDF7006731B9 /* Frameworks */, A03F2D7D1780BDF7006731B9 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "box2d Mac"; productName = cocos2dx; productReference = A03F2D9B1780BDF7006731B9 /* libbox2d Mac.a */; productType = "com.apple.product-type.library.static"; }; A03F2E9817814268006731B9 /* CocosDenshion Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A03F2ED317814268006731B9 /* Build configuration list for PBXNativeTarget "CocosDenshion Mac" */; buildPhases = ( A03F2E9917814268006731B9 /* Sources */, A03F2EB717814268006731B9 /* Frameworks */, A03F2EB817814268006731B9 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "CocosDenshion Mac"; productName = cocos2dx; productReference = A03F2ED617814268006731B9 /* libCocosDenshion Mac.a */; productType = "com.apple.product-type.library.static"; }; A03F2FC117814595006731B9 /* cocos2dx-extensions Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A03F2FD317814595006731B9 /* Build configuration list for PBXNativeTarget "cocos2dx-extensions Mac" */; buildPhases = ( A03F2FC217814595006731B9 /* Sources */, A03F2FC917814595006731B9 /* Frameworks */, A03F2FCA17814595006731B9 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "cocos2dx-extensions Mac"; productName = cocos2dx; productReference = A03F2FD617814595006731B9 /* libcocos2dx-extensions Mac.a */; productType = "com.apple.product-type.library.static"; }; A03F31E81781479B006731B9 /* jsbindings Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A03F31FA1781479B006731B9 /* Build configuration list for PBXNativeTarget "jsbindings Mac" */; buildPhases = ( A03F31E91781479B006731B9 /* Sources */, A03F31F01781479B006731B9 /* Frameworks */, A03F31F11781479B006731B9 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "jsbindings Mac"; productName = cocos2dx; productReference = A03F31FD1781479B006731B9 /* libjsbindings Mac.a */; productType = "com.apple.product-type.library.static"; }; A07A4C241783777C0073F6A7 /* cocos2dx iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A4D611783777C0073F6A7 /* Build configuration list for PBXNativeTarget "cocos2dx iOS" */; buildPhases = ( A07A4C251783777C0073F6A7 /* Sources */, A07A4CAD1783777C0073F6A7 /* Frameworks */, A07A4CB11783777C0073F6A7 /* Headers */, ); buildRules = ( ); dependencies = ( 46A173D31807D330005B8026 /* PBXTargetDependency */, ); name = "cocos2dx iOS"; productName = cocos2dx; productReference = A07A4D641783777C0073F6A7 /* libcocos2dx iOS.a */; productType = "com.apple.product-type.library.static"; }; A07A4E111783867C0073F6A7 /* cocos2dx-extensions iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A4EF91783867C0073F6A7 /* Build configuration list for PBXNativeTarget "cocos2dx-extensions iOS" */; buildPhases = ( A07A4E121783867C0073F6A7 /* Sources */, A07A4E7B1783867C0073F6A7 /* Frameworks */, A07A4E7D1783867C0073F6A7 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "cocos2dx-extensions iOS"; productName = cocos2dx; productReference = A07A4EFC1783867C0073F6A7 /* libcocos2dx-extensions iOS.a */; productType = "com.apple.product-type.library.static"; }; A07A4EFD178387670073F6A7 /* chipmunk iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A4F38178387670073F6A7 /* Build configuration list for PBXNativeTarget "chipmunk iOS" */; buildPhases = ( A07A4EFE178387670073F6A7 /* Sources */, A07A4F1C178387670073F6A7 /* Frameworks */, A07A4F1D178387670073F6A7 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "chipmunk iOS"; productName = cocos2dx; productReference = A07A4F3B178387670073F6A7 /* libchipmunk iOS.a */; productType = "com.apple.product-type.library.static"; }; A07A4F3C1783876B0073F6A7 /* box2d iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A4F9B1783876B0073F6A7 /* Build configuration list for PBXNativeTarget "box2d iOS" */; buildPhases = ( A07A4F3D1783876B0073F6A7 /* Sources */, A07A4F6B1783876B0073F6A7 /* Frameworks */, A07A4F6C1783876B0073F6A7 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "box2d iOS"; productName = cocos2dx; productReference = A07A4F9E1783876B0073F6A7 /* libbox2d iOS.a */; productType = "com.apple.product-type.library.static"; }; A07A4F9F178387730073F6A7 /* CocosDenshion iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A4FB1178387730073F6A7 /* Build configuration list for PBXNativeTarget "CocosDenshion iOS" */; buildPhases = ( A07A4FA0178387730073F6A7 /* Sources */, A07A4FA7178387730073F6A7 /* Frameworks */, A07A4FA8178387730073F6A7 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "CocosDenshion iOS"; productName = cocos2dx; productReference = A07A4FB4178387730073F6A7 /* libCocosDenshion iOS.a */; productType = "com.apple.product-type.library.static"; }; A07A4FB5178387750073F6A7 /* jsbindings iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A502D178387750073F6A7 /* Build configuration list for PBXNativeTarget "jsbindings iOS" */; buildPhases = ( A07A4FB6178387750073F6A7 /* Sources */, A07A4FCC178387750073F6A7 /* Frameworks */, A07A4FCE178387750073F6A7 /* Headers */, ); buildRules = ( ); dependencies = ( ); name = "jsbindings iOS"; productName = cocos2dx; productReference = A07A5030178387750073F6A7 /* libjsbindings iOS.a */; productType = "com.apple.product-type.library.static"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 1551A336158F2AB200E66CFE /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0500; ORGANIZATIONNAME = ""; }; buildConfigurationList = 1551A339158F2AB200E66CFE /* Build configuration list for PBXProject "cocos2d_libs" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); mainGroup = 1551A334158F2AB200E66CFE; productRefGroup = 1551A340158F2AB200E66CFE /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( A03F2E8E178141C1006731B9 /* build-all-libs Mac */, 1551A33E158F2AB200E66CFE /* cocos2dx Mac */, A03F2FC117814595006731B9 /* cocos2dx-extensions Mac */, A03F2B781780BD04006731B9 /* chipmunk Mac */, A03F2D5D1780BDF7006731B9 /* box2d Mac */, A03F2E9817814268006731B9 /* CocosDenshion Mac */, A03F31E81781479B006731B9 /* jsbindings Mac */, 1A6FB50417854BC200CDF010 /* luabindings Mac */, A07A4E0B178386390073F6A7 /* build-all-libs iOS */, A07A4C241783777C0073F6A7 /* cocos2dx iOS */, A07A4E111783867C0073F6A7 /* cocos2dx-extensions iOS */, A07A4EFD178387670073F6A7 /* chipmunk iOS */, A07A4F3C1783876B0073F6A7 /* box2d iOS */, A07A4F9F178387730073F6A7 /* CocosDenshion iOS */, A07A4FB5178387750073F6A7 /* jsbindings iOS */, 1A119716178526AA00D62A44 /* luabindings iOS */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ 1551A33B158F2AB200E66CFE /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 2AC795DB1862870F005EC8E1 /* SkeletonBounds.cpp in Sources */, 2AC795DC1862870F005EC8E1 /* Event.cpp in Sources */, 2AC795DD1862870F005EC8E1 /* EventData.cpp in Sources */, 2AC795DE1862870F005EC8E1 /* BoundingBoxAttachment.cpp in Sources */, 46A170501807CC1C005B8026 /* CCApplication.mm in Sources */, 46A1705A1807CC1C005B8026 /* CCImage.mm in Sources */, 46A170CC1807CEBB005B8026 /* ray2.c in Sources */, 460E44EF1807DED6000CDD6D /* mat4stack.c in Sources */, 46A170CA1807CEBB005B8026 /* plane.c in Sources */, 46A170EA1807CECA005B8026 /* CCPhysicsJoint.cpp in Sources */, 46A170141807CBFC005B8026 /* CCFileUtilsApple.mm in Sources */, 46A1701D1807CBFC005B8026 /* CCFileUtils.cpp in Sources */, 46A170EF1807CECA005B8026 /* CCPhysicsWorld.cpp in Sources */, 46A170C71807CEBB005B8026 /* mat3.c in Sources */, 46A170521807CC1C005B8026 /* CCDevice.cpp in Sources */, 46A170231807CBFC005B8026 /* CCSAXParser.cpp in Sources */, 46A170ED1807CECA005B8026 /* CCPhysicsShape.cpp in Sources */, 46A170C51807CEB0005B8026 /* aabb.c in Sources */, 46A170171807CBFC005B8026 /* CCThread.mm in Sources */, 46A170C81807CEBB005B8026 /* mat4.c in Sources */, 46A170CB1807CEBB005B8026 /* quaternion.c in Sources */, 46A170D01807CEBB005B8026 /* vec4.c in Sources */, ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */, 46A170CE1807CEBB005B8026 /* vec2.c in Sources */, 46A170541807CC1C005B8026 /* CCDirectorCaller.mm in Sources */, 460E44F01807DED6000CDD6D /* matrix.c in Sources */, 06CAAACB186AD7F20012A414 /* TriggerMng.cpp in Sources */, 46A170511807CC1C005B8026 /* CCCommon.mm in Sources */, 46A1701B1807CBFC005B8026 /* CCEGLViewProtocol.cpp in Sources */, 46A170E61807CECA005B8026 /* CCPhysicsBody.cpp in Sources */, 46A170151807CBFC005B8026 /* CCLock.cpp in Sources */, A04583F2189053B500E32FE8 /* CCEGLView.cpp in Sources */, 46A170C91807CEBB005B8026 /* neon_matrix_impl.c in Sources */, 46A170CF1807CEBB005B8026 /* vec3.c in Sources */, 46A170E81807CECA005B8026 /* CCPhysicsContact.cpp in Sources */, 46A170CD1807CEBB005B8026 /* utility.c in Sources */, 46A170251807CBFC005B8026 /* CCThread.cpp in Sources */, 1A570061180BC5A10088DEC7 /* CCAction.cpp in Sources */, 1A570065180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */, 1A570069180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */, 1A57006D180BC5A10088DEC7 /* CCActionEase.cpp in Sources */, 1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */, 593BDCF6184D0A6E00C21E48 /* CCGroupCommand.cpp in Sources */, B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */, 1A570075180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, B375107A1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */, 1A570079180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */, 1A57007D180BC5A10088DEC7 /* CCActionInterval.cpp in Sources */, 1A570081180BC5A10088DEC7 /* CCActionManager.cpp in Sources */, 1A570085180BC5A10088DEC7 /* CCActionPageTurn3D.cpp in Sources */, 1A570089180BC5A10088DEC7 /* CCActionProgressTimer.cpp in Sources */, 1A57008D180BC5A10088DEC7 /* CCActionTiledGrid.cpp in Sources */, 1A570091180BC5A10088DEC7 /* CCActionTween.cpp in Sources */, 1A570098180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */, 1A57009E180BC5D20088DEC7 /* CCNode.cpp in Sources */, 1A5700C5180BC6060088DEC7 /* atitc.cpp in Sources */, B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */, 1A5700C9180BC6060088DEC7 /* CCAffineTransform.cpp in Sources */, 1A5700CD180BC6060088DEC7 /* CCArray.cpp in Sources */, 1A5700D1180BC6060088DEC7 /* CCAutoreleasePool.cpp in Sources */, 1A5700D7180BC6060088DEC7 /* CCData.cpp in Sources */, 1A5700DB180BC6060088DEC7 /* CCDataVisitor.cpp in Sources */, 1A5700DF180BC6060088DEC7 /* CCDictionary.cpp in Sources */, 1A5700E7180BC6060088DEC7 /* CCGeometry.cpp in Sources */, 1A5700ED180BC6060088DEC7 /* CCNS.cpp in Sources */, 1A5700F1180BC6060088DEC7 /* CCObject.cpp in Sources */, 1A5700F9180BC6060088DEC7 /* CCSet.cpp in Sources */, 1A5700FD180BC6060088DEC7 /* CCString.cpp in Sources */, 1A570101180BC6060088DEC7 /* etc1.cpp in Sources */, 1A570105180BC6060088DEC7 /* s3tc.cpp in Sources */, 1A57010E180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */, 1A570112180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */, 1A57011B180BC90D0088DEC7 /* CCGrabber.cpp in Sources */, 1A57011F180BC90D0088DEC7 /* CCGrid.cpp in Sources */, 1A57013A180BC9460088DEC7 /* CCEvent.cpp in Sources */, 1A57013E180BC9460088DEC7 /* CCEventAcceleration.cpp in Sources */, 1A570142180BC9460088DEC7 /* CCEventCustom.cpp in Sources */, 1A570146180BC9460088DEC7 /* CCEventDispatcher.cpp in Sources */, 1A57014A180BC9460088DEC7 /* CCEventKeyboard.cpp in Sources */, 1A57014E180BC9460088DEC7 /* CCEventListener.cpp in Sources */, 1A570152180BC9460088DEC7 /* CCEventListenerAcceleration.cpp in Sources */, 1A570156180BC9460088DEC7 /* CCEventListenerCustom.cpp in Sources */, 06C0F2EF186AD822003594D5 /* ObjectFactory.cpp in Sources */, 1A57015A180BC9460088DEC7 /* CCEventListenerKeyboard.cpp in Sources */, 1A57015E180BC9460088DEC7 /* CCEventListenerTouch.cpp in Sources */, 1A570162180BC9460088DEC7 /* CCEventTouch.cpp in Sources */, 1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */, 1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, 1A5701A5180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, 1A5701B1180BCB590088DEC7 /* CCFontFNT.cpp in Sources */, 1A5701B5180BCB590088DEC7 /* CCFontFreeType.cpp in Sources */, 1A5701B9180BCB5A0088DEC7 /* CCLabel.cpp in Sources */, 1A5701BD180BCB5A0088DEC7 /* CCLabelAtlas.cpp in Sources */, 1A5701C1180BCB5A0088DEC7 /* CCLabelBMFont.cpp in Sources */, 1A087AE81860400400196EF5 /* edtaa3func.cpp in Sources */, B37510731823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */, 1A5701C7180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */, 1A5701CB180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */, 1A5701DE180BCB8C0088DEC7 /* CCLayer.cpp in Sources */, 1A5701E2180BCB8C0088DEC7 /* CCScene.cpp in Sources */, 1A5701E6180BCB8C0088DEC7 /* CCTransition.cpp in Sources */, 1A5701EA180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */, 1A5701EE180BCB8C0088DEC7 /* CCTransitionProgress.cpp in Sources */, 1A5701F7180BCBAD0088DEC7 /* CCMenu.cpp in Sources */, 1A5701FB180BCBAD0088DEC7 /* CCMenuItem.cpp in Sources */, 1A570202180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */, 06CAAACF186AD7FC0012A414 /* TriggerBase.cpp in Sources */, 1A570208180BCBDF0088DEC7 /* CCMotionStreak.cpp in Sources */, 1A570210180BCBF40088DEC7 /* CCProgressTimer.cpp in Sources */, 1A570214180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */, 1A570221180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */, 1A570225180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */, 1A570229180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */, 1A57022D180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */, 1A570234180BCC4D0088DEC7 /* CCScriptSupport.cpp in Sources */, 1A57026B180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */, 1A570271180BCC6F0088DEC7 /* ccShaders.cpp in Sources */, 1A57027E180BCC900088DEC7 /* CCSprite.cpp in Sources */, 1A570282180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, 1A570286180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */, 1A57028A180BCC900088DEC7 /* CCSpriteFrameCache.cpp in Sources */, 1A570292180BCCAB0088DEC7 /* CCAnimation.cpp in Sources */, 1A570296180BCCAB0088DEC7 /* CCAnimationCache.cpp in Sources */, 1A57029D180BCD890088DEC7 /* base64.cpp in Sources */, 1A5702A3180BCD980088DEC7 /* CCNotificationCenter.cpp in Sources */, 1A5702A9180BCDAA0088DEC7 /* CCProfiling.cpp in Sources */, 3774879F1869BA8C00EDF837 /* CCActionEaseEx.cpp in Sources */, 59A79D551821E26E00F19697 /* CCEventMouse.cpp in Sources */, 1A5702AF180BCDBC0088DEC7 /* ccUTF8.cpp in Sources */, 1A5702B5180BCDF40088DEC7 /* CCVertex.cpp in Sources */, 1A5702C2180BCE2A0088DEC7 /* CCIMEDispatcher.cpp in Sources */, 1A5702C8180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */, 1A5702D3180BCE570088DEC7 /* CCTexture2D.cpp in Sources */, 1A5702D7180BCE570088DEC7 /* CCTextureAtlas.cpp in Sources */, 50AE5EA3188749250007CFE3 /* CCBatchCommand.cpp in Sources */, 1A5702DB180BCE570088DEC7 /* CCTextureCache.cpp in Sources */, 1A5702EA180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, 1A5702EE180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, 1A5702F2180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, 1A5702F6180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */, 1A5702FA180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */, 1A570300180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */, 1A570305180BCED90088DEC7 /* ccUtils.cpp in Sources */, 1A57030C180BCF190088DEC7 /* CCComponent.cpp in Sources */, 1A570310180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */, 1A570319180BCF430088DEC7 /* ccCArray.cpp in Sources */, B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */, 1A570324180BCF660088DEC7 /* TGAlib.cpp in Sources */, 1A57032F180BCFD50088DEC7 /* CCUserDefault.cpp in Sources */, 1A570333180BCFD50088DEC7 /* CCUserDefault.mm in Sources */, 1A570335180BCFD50088DEC7 /* CCUserDefaultAndroid.cpp in Sources */, 1A57033A180BCFFA0088DEC7 /* ZipUtils.cpp in Sources */, 1A57034B180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, 1A570354180BD0B00088DEC7 /* ioapi.cpp in Sources */, 1A570358180BD0B00088DEC7 /* unzip.cpp in Sources */, 1A570533180BD9500088DEC7 /* CCGLProgram.cpp in Sources */, 1A570537180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */, 1A570546180BD9C40088DEC7 /* CCTouch.cpp in Sources */, 1AD71DA9180E26E600808F54 /* CCBAnimationManager.cpp in Sources */, 1AD71DAD180E26E600808F54 /* CCBFileLoader.cpp in Sources */, 1AD71DB1180E26E600808F54 /* CCBKeyframe.cpp in Sources */, 1AD71DB7180E26E600808F54 /* CCBReader.cpp in Sources */, 1AD71DBD180E26E600808F54 /* CCBSequence.cpp in Sources */, 1AD71DC1180E26E600808F54 /* CCBSequenceProperty.cpp in Sources */, 1AD71DC9180E26E600808F54 /* CCControlButtonLoader.cpp in Sources */, 1AD71DCD180E26E600808F54 /* CCControlLoader.cpp in Sources */, 1AE3C844184F14F700CF29B5 /* CCValue.cpp in Sources */, 1AD71DD1180E26E600808F54 /* CCLabelBMFontLoader.cpp in Sources */, 1AD71DD5180E26E600808F54 /* CCLabelTTFLoader.cpp in Sources */, 1AD71DD9180E26E600808F54 /* CCLayerColorLoader.cpp in Sources */, 1AD71DDD180E26E600808F54 /* CCLayerGradientLoader.cpp in Sources */, 1AD71DE1180E26E600808F54 /* CCLayerLoader.cpp in Sources */, 1AD71DE5180E26E600808F54 /* CCMenuItemImageLoader.cpp in Sources */, 1AD71DE9180E26E600808F54 /* CCMenuItemLoader.cpp in Sources */, 593BDCF2184D0A6E00C21E48 /* CCCustomCommand.cpp in Sources */, 06CAAAC7186AD7E90012A414 /* TriggerObj.cpp in Sources */, 1AD71DEF180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp in Sources */, 1AD71DF3180E26E600808F54 /* CCNodeLoader.cpp in Sources */, 1AD71DF7180E26E600808F54 /* CCNodeLoaderLibrary.cpp in Sources */, 1AD71DFD180E26E600808F54 /* CCParticleSystemQuadLoader.cpp in Sources */, 1AD71E01180E26E600808F54 /* CCScale9SpriteLoader.cpp in Sources */, 1AD71E05180E26E600808F54 /* CCScrollViewLoader.cpp in Sources */, 1AD71E09180E26E600808F54 /* CCSpriteLoader.cpp in Sources */, 1AD71E95180E26E600808F54 /* Animation.cpp in Sources */, 1AD71E99180E26E600808F54 /* AnimationState.cpp in Sources */, 1AD71E9D180E26E600808F54 /* AnimationStateData.cpp in Sources */, 1AD71EA1180E26E600808F54 /* Atlas.cpp in Sources */, 1AD71EA5180E26E600808F54 /* AtlasAttachmentLoader.cpp in Sources */, 1AD71EA9180E26E600808F54 /* Attachment.cpp in Sources */, 1AD71EAD180E26E600808F54 /* AttachmentLoader.cpp in Sources */, 1AD71EB1180E26E600808F54 /* Bone.cpp in Sources */, 1AD71EB5180E26E600808F54 /* BoneData.cpp in Sources */, 1AD71EB9180E26E600808F54 /* CCSkeleton.cpp in Sources */, 1AD71EBD180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */, 1AD71EC1180E26E600808F54 /* extension.cpp in Sources */, 1AD71EC5180E26E600808F54 /* Json.cpp in Sources */, 1AD71EC9180E26E600808F54 /* RegionAttachment.cpp in Sources */, 1AD71ECD180E26E600808F54 /* Skeleton.cpp in Sources */, 1AD71ED1180E26E600808F54 /* SkeletonData.cpp in Sources */, 1AD71ED5180E26E600808F54 /* SkeletonJson.cpp in Sources */, 1AD71ED9180E26E600808F54 /* Skin.cpp in Sources */, 1AD71EDD180E26E600808F54 /* Slot.cpp in Sources */, 1AD71EE1180E26E600808F54 /* SlotData.cpp in Sources */, 1AD71EE5180E26E600808F54 /* spine-cocos2dx.cpp in Sources */, 1AAF536A180E3374000584C8 /* HttpClient.cpp in Sources */, 1AAF5372180E3374000584C8 /* SocketIO.cpp in Sources */, 1AAF5376180E3374000584C8 /* WebSocket.cpp in Sources */, 1AAF584F180E40B9000584C8 /* LocalStorage.cpp in Sources */, 1AAF5853180E40B9000584C8 /* LocalStorageAndroid.cpp in Sources */, 5069133E185016C1009BBDD7 /* CCConsole.cpp in Sources */, 1A9DCA15180E6955007A3AD4 /* CCConfiguration.cpp in Sources */, 1A9DCA1D180E6955007A3AD4 /* CCDirector.cpp in Sources */, 1A9DCA23180E6955007A3AD4 /* ccFPSImages.c in Sources */, 1A9DCA27180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */, 1A9DCA2F180E6955007A3AD4 /* CCScheduler.cpp in Sources */, 1A9DCA37180E6955007A3AD4 /* cocos2d.cpp in Sources */, 1A9DCA3D180E6955007A3AD4 /* TransformUtils.cpp in Sources */, 1A9DCA43180E6D90007A3AD4 /* CCDeprecated.cpp in Sources */, 1A9DCA49180E6DE3007A3AD4 /* ccTypes.cpp in Sources */, 1A8C58EC180E92CC00EF57C3 /* CocosGUI.cpp in Sources */, 1A8C58F0180E92CC00EF57C3 /* UILayout.cpp in Sources */, 1A8C58F4180E92CC00EF57C3 /* UILayoutParameter.cpp in Sources */, 1A8C58F8180E92CC00EF57C3 /* UIButton.cpp in Sources */, 1A8C58FC180E92CC00EF57C3 /* UICheckBox.cpp in Sources */, 1A8C5904180E92CC00EF57C3 /* UIHelper.cpp in Sources */, 1A8C5908180E92CC00EF57C3 /* UIImageView.cpp in Sources */, 1A8C5910180E92CC00EF57C3 /* UIText.cpp in Sources */, 1A8C5914180E92CC00EF57C3 /* UITextAtlas.cpp in Sources */, 1A8C5918180E92CC00EF57C3 /* UITextBMFont.cpp in Sources */, 59A79D511821E26E00F19697 /* CCEventListenerMouse.cpp in Sources */, 1A8C5920180E92CC00EF57C3 /* UILayoutDefine.cpp in Sources */, 1A8C5928180E92CC00EF57C3 /* UILoadingBar.cpp in Sources */, 1A8C592C180E92CC00EF57C3 /* UIPageView.cpp in Sources */, 1A8C5936180E92CC00EF57C3 /* UIScrollView.cpp in Sources */, 1A8C593A180E92CC00EF57C3 /* UISlider.cpp in Sources */, 1A8C593E180E92CC00EF57C3 /* UITextField.cpp in Sources */, 1A8C5942180E92CC00EF57C3 /* UIWidget.cpp in Sources */, 1A8C598B180E930E00EF57C3 /* CCActionFrame.cpp in Sources */, 1A8C598F180E930E00EF57C3 /* CCActionFrameEasing.cpp in Sources */, 1A8C5993180E930E00EF57C3 /* CCActionManagerEx.cpp in Sources */, 1A8C5997180E930E00EF57C3 /* CCActionNode.cpp in Sources */, 1A8C599B180E930E00EF57C3 /* CCActionObject.cpp in Sources */, 1A8C599F180E930E00EF57C3 /* CCArmature.cpp in Sources */, 1A8C59A3180E930E00EF57C3 /* CCArmatureAnimation.cpp in Sources */, 1A8C59A7180E930E00EF57C3 /* CCArmatureDataManager.cpp in Sources */, 1A8C59AB180E930E00EF57C3 /* CCArmatureDefine.cpp in Sources */, 1A8C59AF180E930E00EF57C3 /* CCBatchNode.cpp in Sources */, 1A8C59B3180E930E00EF57C3 /* CCBone.cpp in Sources */, 50A1FF1818290ED4001840C4 /* UIListView.cpp in Sources */, 1A8C59B7180E930E00EF57C3 /* CCColliderDetector.cpp in Sources */, 1A8C59BB180E930E00EF57C3 /* CCComAttribute.cpp in Sources */, 1A8C59BF180E930E00EF57C3 /* CCComAudio.cpp in Sources */, 1A8C59C3180E930E00EF57C3 /* CCComController.cpp in Sources */, 1A8C59C7180E930E00EF57C3 /* CCComRender.cpp in Sources */, 1A8C59CB180E930E00EF57C3 /* CCDataReaderHelper.cpp in Sources */, 1A8C59CF180E930E00EF57C3 /* CCDatas.cpp in Sources */, 1A8C59D3180E930E00EF57C3 /* CCDecorativeDisplay.cpp in Sources */, 1A8C59D7180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */, 1A8C59DB180E930E00EF57C3 /* CCDisplayManager.cpp in Sources */, 1A8C59DF180E930E00EF57C3 /* CCInputDelegate.cpp in Sources */, 1A8C59E3180E930E00EF57C3 /* CCProcessBase.cpp in Sources */, 1A8C59E7180E930E00EF57C3 /* CCSGUIReader.cpp in Sources */, 1A8C59EB180E930E00EF57C3 /* CCSkin.cpp in Sources */, 1A8C59EF180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp in Sources */, 1A8C59F3180E930E00EF57C3 /* CCSSceneReader.cpp in Sources */, 1A8C59F7180E930E00EF57C3 /* CCTransformHelp.cpp in Sources */, 1A8C59FB180E930E00EF57C3 /* CCTween.cpp in Sources */, 1A8C59FF180E930E00EF57C3 /* CCTweenFunction.cpp in Sources */, 1A8C5A03180E930E00EF57C3 /* CCUtilMath.cpp in Sources */, 1A8C5A0D180E930E00EF57C3 /* DictionaryHelper.cpp in Sources */, 74AC8C8DDFD05322513C8C72 /* CCFrustum.cpp in Sources */, 74AC8796ABB6761790CF8CC2 /* CCRenderer.cpp in Sources */, 1ABA68AE1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */, 74AC8CF1E05EA89BC441EEBC /* CCQuadCommand.cpp in Sources */, 74AC897DFAB8043D3873A8F3 /* CCRenderCommand.cpp in Sources */, 74AC85BC90D7CF01D652E8C3 /* CCRenderMaterial.cpp in Sources */, 74AC83D0193BC28994D683E8 /* CCMaterialManager.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A119717178526AA00D62A44 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1F79180E88C300497A22 /* CCBProxy.cpp in Sources */, 1A3B1F7D180E88C300497A22 /* CCLuaBridge.cpp in Sources */, 1A3B1F81180E88C300497A22 /* CCLuaEngine.cpp in Sources */, 15A71D9318921E6900F30AC0 /* udp.c in Sources */, 15A71DA51892291500F30AC0 /* lua_extensions.c in Sources */, 15A71D8318921E6900F30AC0 /* serial.c in Sources */, B362C3B41872BADF00F0BDF4 /* lua_cocos2dx_physics_manual.cpp in Sources */, 1A3B1F85180E88C300497A22 /* CCLuaStack.cpp in Sources */, 158E06DF181F6796008E01F6 /* lua_xml_http_request.cpp in Sources */, 15A71D7F18921E6900F30AC0 /* select.c in Sources */, 15A71D7B18921E6900F30AC0 /* options.c in Sources */, 1A3B1F89180E88C300497A22 /* CCLuaValue.cpp in Sources */, 1A3B1F8D180E88C300497A22 /* Cocos2dxLuaLoader.cpp in Sources */, 15A71D8718921E6900F30AC0 /* socket_scripts.c in Sources */, 1A3B1F91180E88C300497A22 /* lua_cocos2dx_deprecated.cpp in Sources */, 15CA8D1A18697BE5000032AB /* LuaSkeletonAnimation.cpp in Sources */, 1A3B1F95180E88C300497A22 /* lua_cocos2dx_extension_manual.cpp in Sources */, 1A3B1F99180E88C300497A22 /* lua_cocos2dx_manual.cpp in Sources */, 15A71D6318921E6900F30AC0 /* except.c in Sources */, 15A71D7718921E6900F30AC0 /* mime.c in Sources */, 1585AB5C1828D74F00000FB5 /* lua_cocos2dx_studio_auto.cpp in Sources */, 1A3B1F9D180E88C300497A22 /* Lua_web_socket.cpp in Sources */, B362C3AE1872BAB700F0BDF4 /* lua_cocos2dx_physics_auto.cpp in Sources */, 1A3B1FA1180E88C300497A22 /* LuaBasicConversions.cpp in Sources */, 1A3B1FA5180E88C300497A22 /* LuaOpengl.cpp in Sources */, 15A71D9B18921E6900F30AC0 /* usocket.c in Sources */, 1A3B1FA9180E88C300497A22 /* LuaScriptHandlerMgr.cpp in Sources */, 15A71D6B18921E6900F30AC0 /* luasocket.c in Sources */, 15CA8D0E18697A56000032AB /* lua_cocos2dx_spine_manual.cpp in Sources */, 15A71D6718921E6900F30AC0 /* inet.c in Sources */, 1A2C78A5181A11EC004E5527 /* lua_cocos2dx_auto.cpp in Sources */, 1A3B1FB9180E88C300497A22 /* CCLuaObjcBridge.mm in Sources */, 1A2C78B1181A11EC004E5527 /* lua_cocos2dx_extension_auto.cpp in Sources */, 15A71D7318921E6900F30AC0 /* luasocket_io.c in Sources */, 1A3B1FBB180E88C300497A22 /* tolua_fix.c in Sources */, 1A8C5649180E8D0D00EF57C3 /* tolua_event.c in Sources */, 15A71D8B18921E6900F30AC0 /* tcp.c in Sources */, 15CA8D1418697AE1000032AB /* lua_cocos2dx_spine_auto.cpp in Sources */, 15A71D8F18921E6900F30AC0 /* timeout.c in Sources */, 1A8C564D180E8D0D00EF57C3 /* tolua_is.c in Sources */, 1A8C564F180E8D0D00EF57C3 /* tolua_map.c in Sources */, 1A8C5651180E8D0D00EF57C3 /* tolua_push.c in Sources */, 1A8C5653180E8D0D00EF57C3 /* tolua_to.c in Sources */, 15D6E846182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.cpp in Sources */, 15A71D5F18921E6900F30AC0 /* auxiliar.c in Sources */, 15A71D6F18921E6900F30AC0 /* luasocket_buffer.c in Sources */, 15F4C8831875637D0082884F /* lua_cocos2dx_gui_auto.cpp in Sources */, 15A71D9718921E6900F30AC0 /* unix.c in Sources */, 15F4CA201875885A0082884F /* lua_cocos2dx_gui_manual.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB50517854BC200CDF010 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1F78180E88C300497A22 /* CCBProxy.cpp in Sources */, 1A3B1F7C180E88C300497A22 /* CCLuaBridge.cpp in Sources */, 1A3B1F80180E88C300497A22 /* CCLuaEngine.cpp in Sources */, 15A71D9218921E6900F30AC0 /* udp.c in Sources */, 15A71DA41892291500F30AC0 /* lua_extensions.c in Sources */, 15A71D8218921E6900F30AC0 /* serial.c in Sources */, B362C3B21872BADC00F0BDF4 /* lua_cocos2dx_physics_manual.cpp in Sources */, 1A3B1F84180E88C300497A22 /* CCLuaStack.cpp in Sources */, 158E06DE181F6796008E01F6 /* lua_xml_http_request.cpp in Sources */, 15A71D7E18921E6900F30AC0 /* select.c in Sources */, 15A71D7A18921E6900F30AC0 /* options.c in Sources */, 1A3B1F88180E88C300497A22 /* CCLuaValue.cpp in Sources */, 1A3B1F8C180E88C300497A22 /* Cocos2dxLuaLoader.cpp in Sources */, 15A71D8618921E6900F30AC0 /* socket_scripts.c in Sources */, 1A3B1F90180E88C300497A22 /* lua_cocos2dx_deprecated.cpp in Sources */, 15CA8D1918697BE5000032AB /* LuaSkeletonAnimation.cpp in Sources */, 1A3B1F94180E88C300497A22 /* lua_cocos2dx_extension_manual.cpp in Sources */, 1A3B1F98180E88C300497A22 /* lua_cocos2dx_manual.cpp in Sources */, 15A71D6218921E6900F30AC0 /* except.c in Sources */, 15A71D7618921E6900F30AC0 /* mime.c in Sources */, 1585AB5B1828D74F00000FB5 /* lua_cocos2dx_studio_auto.cpp in Sources */, 1A3B1F9C180E88C300497A22 /* Lua_web_socket.cpp in Sources */, B362C3B01872BABC00F0BDF4 /* lua_cocos2dx_physics_auto.cpp in Sources */, 1A3B1FA0180E88C300497A22 /* LuaBasicConversions.cpp in Sources */, 1A3B1FA4180E88C300497A22 /* LuaOpengl.cpp in Sources */, 15A71D9A18921E6900F30AC0 /* usocket.c in Sources */, 1A3B1FA8180E88C300497A22 /* LuaScriptHandlerMgr.cpp in Sources */, 15A71D6A18921E6900F30AC0 /* luasocket.c in Sources */, 15CA8D0D18697A56000032AB /* lua_cocos2dx_spine_manual.cpp in Sources */, 15A71D6618921E6900F30AC0 /* inet.c in Sources */, 1A2C78A3181A11EC004E5527 /* lua_cocos2dx_auto.cpp in Sources */, 1A3B1FB8180E88C300497A22 /* CCLuaObjcBridge.mm in Sources */, 1A2C78AF181A11EC004E5527 /* lua_cocos2dx_extension_auto.cpp in Sources */, 15A71D7218921E6900F30AC0 /* luasocket_io.c in Sources */, 1A3B1FBA180E88C300497A22 /* tolua_fix.c in Sources */, 1A8C5648180E8D0D00EF57C3 /* tolua_event.c in Sources */, 15A71D8A18921E6900F30AC0 /* tcp.c in Sources */, 15CA8D1318697AE1000032AB /* lua_cocos2dx_spine_auto.cpp in Sources */, 15A71D8E18921E6900F30AC0 /* timeout.c in Sources */, 1A8C564C180E8D0D00EF57C3 /* tolua_is.c in Sources */, 1A8C564E180E8D0D00EF57C3 /* tolua_map.c in Sources */, 1A8C5650180E8D0D00EF57C3 /* tolua_push.c in Sources */, 1A8C5652180E8D0D00EF57C3 /* tolua_to.c in Sources */, 15D6E845182B81710003C5B1 /* lua_cocos2dx_coco_studio_manual.cpp in Sources */, 15A71D5E18921E6900F30AC0 /* auxiliar.c in Sources */, 15A71D6E18921E6900F30AC0 /* luasocket_buffer.c in Sources */, 15F4C8821875637D0082884F /* lua_cocos2dx_gui_auto.cpp in Sources */, 15A71D9618921E6900F30AC0 /* unix.c in Sources */, 15F4CA1F1875885A0082884F /* lua_cocos2dx_gui_manual.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2B791780BD04006731B9 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 46A1740A1807D365005B8026 /* cpSpaceQuery.c in Sources */, 46A174061807D365005B8026 /* cpShape.c in Sources */, 46A174001807D365005B8026 /* cpBB.c in Sources */, 46A173F91807D365005B8026 /* cpPivotJoint.c in Sources */, 46A174011807D365005B8026 /* cpBBTree.c in Sources */, 46A173D51807D35A005B8026 /* chipmunk.c in Sources */, 46A174021807D365005B8026 /* cpBody.c in Sources */, 46A173FC1807D365005B8026 /* cpSimpleMotor.c in Sources */, 46A173F31807D365005B8026 /* cpConstraint.c in Sources */, 46A174081807D365005B8026 /* cpSpaceComponent.c in Sources */, 46A174091807D365005B8026 /* cpSpaceHash.c in Sources */, 46A173F81807D365005B8026 /* cpPinJoint.c in Sources */, 46A1740D1807D365005B8026 /* cpSweep1D.c in Sources */, 46A173F51807D365005B8026 /* cpDampedSpring.c in Sources */, 46A1740B1807D365005B8026 /* cpSpaceStep.c in Sources */, 46A173F71807D365005B8026 /* cpGrooveJoint.c in Sources */, 46A174051807D365005B8026 /* cpPolyShape.c in Sources */, 46A1740E1807D365005B8026 /* cpVect.c in Sources */, 46A173FD1807D365005B8026 /* cpSlideJoint.c in Sources */, 46A173FB1807D365005B8026 /* cpRotaryLimitJoint.c in Sources */, 46A174041807D365005B8026 /* cpHashSet.c in Sources */, 46A173FE1807D365005B8026 /* cpArbiter.c in Sources */, 46A173FF1807D365005B8026 /* cpArray.c in Sources */, 46A173F61807D365005B8026 /* cpGearJoint.c in Sources */, 46A174031807D365005B8026 /* cpCollision.c in Sources */, 46A174071807D365005B8026 /* cpSpace.c in Sources */, 46A173FA1807D365005B8026 /* cpRatchetJoint.c in Sources */, 46A173F41807D365005B8026 /* cpDampedRotarySpring.c in Sources */, 46A1740C1807D365005B8026 /* cpSpatialIndex.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2D5E1780BDF7006731B9 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1AAF528B180E2ECC000584C8 /* b2BroadPhase.cpp in Sources */, 1AAF528D180E2ECC000584C8 /* b2CollideCircle.cpp in Sources */, 1AAF528E180E2ECC000584C8 /* b2CollideEdge.cpp in Sources */, 1AAF528F180E2ECC000584C8 /* b2CollidePolygon.cpp in Sources */, 1AAF5290180E2ECC000584C8 /* b2Collision.cpp in Sources */, 1AAF5292180E2ECC000584C8 /* b2Distance.cpp in Sources */, 1AAF5294180E2ECC000584C8 /* b2DynamicTree.cpp in Sources */, 1AAF5296180E2ECC000584C8 /* b2TimeOfImpact.cpp in Sources */, 1AAF52B0180E2EE9000584C8 /* b2ChainShape.cpp in Sources */, 1AAF52B2180E2EE9000584C8 /* b2CircleShape.cpp in Sources */, 1AAF52B4180E2EE9000584C8 /* b2EdgeShape.cpp in Sources */, 1AAF52B6180E2EE9000584C8 /* b2PolygonShape.cpp in Sources */, 1AAF52C6180E2EEF000584C8 /* b2BlockAllocator.cpp in Sources */, 1AAF52C8180E2EEF000584C8 /* b2Draw.cpp in Sources */, 1AAF52CB180E2EEF000584C8 /* b2Math.cpp in Sources */, 1AAF52CD180E2EEF000584C8 /* b2Settings.cpp in Sources */, 1AAF52CF180E2EEF000584C8 /* b2StackAllocator.cpp in Sources */, 1AAF52D1180E2EEF000584C8 /* b2Timer.cpp in Sources */, 1AAF52D3180E2EF5000584C8 /* b2Body.cpp in Sources */, 1AAF52D5180E2EF5000584C8 /* b2ContactManager.cpp in Sources */, 1AAF52D7180E2EF5000584C8 /* b2Fixture.cpp in Sources */, 1AAF52D9180E2EF5000584C8 /* b2Island.cpp in Sources */, 1AAF52DC180E2EF5000584C8 /* b2World.cpp in Sources */, 1AAF52DE180E2EF5000584C8 /* b2WorldCallbacks.cpp in Sources */, 1AAF52FF180E2EFE000584C8 /* b2ChainAndCircleContact.cpp in Sources */, 1AAF5301180E2EFE000584C8 /* b2ChainAndPolygonContact.cpp in Sources */, 1AAF5303180E2EFE000584C8 /* b2CircleContact.cpp in Sources */, 1AAF5305180E2EFE000584C8 /* b2Contact.cpp in Sources */, 1AAF5307180E2EFE000584C8 /* b2ContactSolver.cpp in Sources */, 1AAF5309180E2EFE000584C8 /* b2EdgeAndCircleContact.cpp in Sources */, B3AF01A01842FBA400A98B85 /* b2MotorJoint.cpp in Sources */, 1AAF530B180E2EFE000584C8 /* b2EdgeAndPolygonContact.cpp in Sources */, 1AAF530D180E2EFE000584C8 /* b2PolygonAndCircleContact.cpp in Sources */, 1AAF530F180E2EFE000584C8 /* b2PolygonContact.cpp in Sources */, 1AAF5311180E2F04000584C8 /* b2DistanceJoint.cpp in Sources */, 1AAF5313180E2F04000584C8 /* b2FrictionJoint.cpp in Sources */, 1AAF5315180E2F04000584C8 /* b2GearJoint.cpp in Sources */, 1AAF5317180E2F04000584C8 /* b2Joint.cpp in Sources */, 1AAF5319180E2F04000584C8 /* b2MouseJoint.cpp in Sources */, 1AAF531B180E2F04000584C8 /* b2PrismaticJoint.cpp in Sources */, 1AAF531D180E2F04000584C8 /* b2PulleyJoint.cpp in Sources */, 1AAF531F180E2F04000584C8 /* b2RevoluteJoint.cpp in Sources */, 1AAF5321180E2F04000584C8 /* b2RopeJoint.cpp in Sources */, 1AAF5323180E2F04000584C8 /* b2WeldJoint.cpp in Sources */, 1AAF5325180E2F04000584C8 /* b2WheelJoint.cpp in Sources */, 1AAF533D180E2F10000584C8 /* b2Rope.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2E9917814268006731B9 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 46A1604F1807A5D4005B8026 /* SimpleAudioEngine_objc.m in Sources */, 46A1604A1807A5D4005B8026 /* CDXMacOSXSupport.mm in Sources */, 46A1604D1807A5D4005B8026 /* SimpleAudioEngine.mm in Sources */, 46A1604C1807A5D4005B8026 /* CocosDenshion.m in Sources */, 46A160451807A5D4005B8026 /* CDAudioManager.m in Sources */, 46A160481807A5D4005B8026 /* CDOpenALSupport.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F2FC217814595006731B9 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 460E477D18080902000CDD6D /* CCControl.cpp in Sources */, 460E47CB18080913000CDD6D /* CCScrollView.cpp in Sources */, 460E47D118080913000CDD6D /* CCTableViewCell.cpp in Sources */, 460E47CF18080913000CDD6D /* CCTableView.cpp in Sources */, 460E478618080902000CDD6D /* CCControlPotentiometer.cpp in Sources */, 460E478C18080902000CDD6D /* CCControlStepper.cpp in Sources */, 460E47BB1808090B000CDD6D /* CCEditBoxImplWin.cpp in Sources */, 460E47B21808090B000CDD6D /* CCEditBoxImplAndroid.cpp in Sources */, 460E47B81808090B000CDD6D /* CCEditBoxImplNone.cpp in Sources */, 460E478418080902000CDD6D /* CCControlHuePicker.cpp in Sources */, 460E478A18080902000CDD6D /* CCControlSlider.cpp in Sources */, 460E478818080902000CDD6D /* CCControlSaturationBrightnessPicker.cpp in Sources */, 460E47B91808090B000CDD6D /* CCEditBoxImplTizen.cpp in Sources */, 460E47B51808090B000CDD6D /* CCEditBoxImplIOS.mm in Sources */, 460E478E18080902000CDD6D /* CCControlSwitch.cpp in Sources */, 460E479218080902000CDD6D /* CCInvocation.cpp in Sources */, 460E477F18080902000CDD6D /* CCControlButton.cpp in Sources */, 460E47B71808090B000CDD6D /* CCEditBoxImplMac.mm in Sources */, 460E47AF1808090B000CDD6D /* CCEditBox.cpp in Sources */, 460E479418080902000CDD6D /* CCScale9Sprite.cpp in Sources */, 460E478118080902000CDD6D /* CCControlColourPicker.cpp in Sources */, 460E479018080902000CDD6D /* CCControlUtils.cpp in Sources */, 1AD71EF0180E27CF00808F54 /* CCPhysicsDebugNode.cpp in Sources */, 1AD71EF4180E27CF00808F54 /* CCPhysicsSprite.cpp in Sources */, 1AAF5353180E3060000584C8 /* AssetsManager.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A03F31E91781479B006731B9 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 3EEF8BD5183A001B005E8A6C /* jsb_cocos2dx_gui_auto.cpp in Sources */, 3EEF8BD6183A001B005E8A6C /* jsb_cocos2dx_gui_manual.cpp in Sources */, 1A2C791D181A1257004E5527 /* js_bindings_chipmunk_registration.cpp in Sources */, 1A2C793D181A1257004E5527 /* js_bindings_opengl.cpp in Sources */, 1A2C794F181A1257004E5527 /* jsb_opengl_registration.cpp in Sources */, 1A2C7959181A1257004E5527 /* js_bindings_system_registration.cpp in Sources */, 1A2C7919181A1257004E5527 /* js_bindings_chipmunk_manual.cpp in Sources */, 1A2C792F181A1257004E5527 /* jsb_cocos2dx_studio_manual.cpp in Sources */, 1A2C7965181A1257004E5527 /* ScriptingCore.cpp in Sources */, 1A2C790D181A1257004E5527 /* js_bindings_chipmunk_auto_classes.cpp in Sources */, 1A2C7913181A1257004E5527 /* js_bindings_chipmunk_functions.cpp in Sources */, 1A2C7933181A1257004E5527 /* jsb_cocos2dx_extension_manual.cpp in Sources */, 1A2C7947181A1257004E5527 /* jsb_opengl_functions.cpp in Sources */, 1A2C7927181A1257004E5527 /* js_bindings_ccbreader.cpp in Sources */, 1A2C7872181A11EC004E5527 /* jsb_cocos2dx_auto.cpp in Sources */, 1A2C7939181A1257004E5527 /* js_bindings_core.cpp in Sources */, 1A2C794B181A1257004E5527 /* jsb_opengl_manual.cpp in Sources */, 1A2C787E181A11EC004E5527 /* jsb_cocos2dx_builder_auto.cpp in Sources */, 1A2C7941181A1257004E5527 /* js_manual_conversions.cpp in Sources */, 1A2C7921181A1257004E5527 /* cocos2d_specifics.cpp in Sources */, 1A2C788A181A11EC004E5527 /* jsb_cocos2dx_extension_auto.cpp in Sources */, 1A2C7953181A1257004E5527 /* js_bindings_system_functions.cpp in Sources */, 1A2C7896181A11EC004E5527 /* jsb_cocos2dx_studio_auto.cpp in Sources */, 1A2C795D181A1257004E5527 /* jsb_websocket.cpp in Sources */, 1A2C7961181A1257004E5527 /* XMLHTTPRequest.cpp in Sources */, 2AFCB8231863D6B200EB4B5C /* jsb_cocos2dx_spine_auto.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4C251783777C0073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 2AC795E318628746005EC8E1 /* SkeletonBounds.cpp in Sources */, 2AC795E418628746005EC8E1 /* Event.cpp in Sources */, 2AC795E518628746005EC8E1 /* EventData.cpp in Sources */, 2AC795E618628746005EC8E1 /* BoundingBoxAttachment.cpp in Sources */, 46A1703C1807CC07005B8026 /* CCApplication.mm in Sources */, 46A170471807CC07005B8026 /* CCImage.mm in Sources */, 46A170D61807CEBC005B8026 /* ray2.c in Sources */, 460E44F11807DED7000CDD6D /* mat4stack.c in Sources */, 46A170D41807CEBC005B8026 /* plane.c in Sources */, 46A1704B1807CC07005B8026 /* EAGLView.mm in Sources */, 46A171001807CECB005B8026 /* CCPhysicsJoint.cpp in Sources */, 46A170441807CC07005B8026 /* CCES2Renderer.m in Sources */, 46A170281807CBFE005B8026 /* CCFileUtilsApple.mm in Sources */, 46A170311807CBFE005B8026 /* CCFileUtils.cpp in Sources */, 46A171051807CECB005B8026 /* CCPhysicsWorld.cpp in Sources */, 46A170D11807CEBC005B8026 /* mat3.c in Sources */, 46A1704E1807CC11005B8026 /* AccelerometerSimulation.m in Sources */, 46A1703E1807CC07005B8026 /* CCDevice.mm in Sources */, 46A171031807CECB005B8026 /* CCPhysicsShape.cpp in Sources */, 46A170371807CBFE005B8026 /* CCSAXParser.cpp in Sources */, 46A170C61807CEB2005B8026 /* aabb.c in Sources */, 46A1702B1807CBFE005B8026 /* CCThread.mm in Sources */, 46A170D21807CEBC005B8026 /* mat4.c in Sources */, 46A170D51807CEBC005B8026 /* quaternion.c in Sources */, ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */, 46A170DA1807CEBC005B8026 /* vec4.c in Sources */, 46A170D81807CEBC005B8026 /* vec2.c in Sources */, 46A170401807CC07005B8026 /* CCDirectorCaller.mm in Sources */, 460E44F21807DED8000CDD6D /* matrix.c in Sources */, 06CAAACC186AD7F50012A414 /* TriggerMng.cpp in Sources */, 46A1703D1807CC07005B8026 /* CCCommon.mm in Sources */, 46A1702F1807CBFE005B8026 /* CCEGLViewProtocol.cpp in Sources */, 46A170FC1807CECB005B8026 /* CCPhysicsBody.cpp in Sources */, 46A170291807CBFE005B8026 /* CCLock.cpp in Sources */, 46A170D31807CEBC005B8026 /* neon_matrix_impl.c in Sources */, 46A170D91807CEBC005B8026 /* vec3.c in Sources */, 46A170FE1807CECB005B8026 /* CCPhysicsContact.cpp in Sources */, 46A170D71807CEBC005B8026 /* utility.c in Sources */, 46A170391807CBFE005B8026 /* CCThread.cpp in Sources */, 46A170421807CC07005B8026 /* CCEGLView.mm in Sources */, 1A570062180BC5A10088DEC7 /* CCAction.cpp in Sources */, 1A570066180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */, 1A57006A180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */, 1A57006E180BC5A10088DEC7 /* CCActionEase.cpp in Sources */, 1A570072180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */, 593BDCF7184D0A6E00C21E48 /* CCGroupCommand.cpp in Sources */, B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */, 1A570076180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, B37510851823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */, 1A57007A180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */, 1A57007E180BC5A10088DEC7 /* CCActionInterval.cpp in Sources */, 1A570082180BC5A10088DEC7 /* CCActionManager.cpp in Sources */, 1A570086180BC5A10088DEC7 /* CCActionPageTurn3D.cpp in Sources */, 1A57008A180BC5A10088DEC7 /* CCActionProgressTimer.cpp in Sources */, 1A57008E180BC5A10088DEC7 /* CCActionTiledGrid.cpp in Sources */, 1A570092180BC5A10088DEC7 /* CCActionTween.cpp in Sources */, 1A570099180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */, 1A57009F180BC5D20088DEC7 /* CCNode.cpp in Sources */, 1A5700C6180BC6060088DEC7 /* atitc.cpp in Sources */, B37510831823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */, 1A5700CA180BC6060088DEC7 /* CCAffineTransform.cpp in Sources */, 1A5700CE180BC6060088DEC7 /* CCArray.cpp in Sources */, 1A5700D2180BC6060088DEC7 /* CCAutoreleasePool.cpp in Sources */, 1A5700D8180BC6060088DEC7 /* CCData.cpp in Sources */, 1A5700DC180BC6060088DEC7 /* CCDataVisitor.cpp in Sources */, 1A5700E0180BC6060088DEC7 /* CCDictionary.cpp in Sources */, 1A5700E8180BC6060088DEC7 /* CCGeometry.cpp in Sources */, 1A5700EE180BC6060088DEC7 /* CCNS.cpp in Sources */, 1A5700F2180BC6060088DEC7 /* CCObject.cpp in Sources */, 1A5700FA180BC6060088DEC7 /* CCSet.cpp in Sources */, 1A5700FE180BC6060088DEC7 /* CCString.cpp in Sources */, 1A570102180BC6060088DEC7 /* etc1.cpp in Sources */, 1A570106180BC6060088DEC7 /* s3tc.cpp in Sources */, 1A57010F180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */, 1A570113180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */, 1A57011C180BC90D0088DEC7 /* CCGrabber.cpp in Sources */, 1A570120180BC90D0088DEC7 /* CCGrid.cpp in Sources */, 1A57013B180BC9460088DEC7 /* CCEvent.cpp in Sources */, 1A57013F180BC9460088DEC7 /* CCEventAcceleration.cpp in Sources */, 1A570143180BC9460088DEC7 /* CCEventCustom.cpp in Sources */, 1A570147180BC9460088DEC7 /* CCEventDispatcher.cpp in Sources */, 1A57014B180BC9460088DEC7 /* CCEventKeyboard.cpp in Sources */, 1A57014F180BC9460088DEC7 /* CCEventListener.cpp in Sources */, 1A570153180BC9460088DEC7 /* CCEventListenerAcceleration.cpp in Sources */, 1A570157180BC9460088DEC7 /* CCEventListenerCustom.cpp in Sources */, 06C0F2F0186AD824003594D5 /* ObjectFactory.cpp in Sources */, 1A57015B180BC9460088DEC7 /* CCEventListenerKeyboard.cpp in Sources */, 1A57015F180BC9460088DEC7 /* CCEventListenerTouch.cpp in Sources */, 1A570163180BC9460088DEC7 /* CCEventTouch.cpp in Sources */, 1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */, 1A5701A2180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, 1A5701A6180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, 1A5701B2180BCB590088DEC7 /* CCFontFNT.cpp in Sources */, 1A5701B6180BCB590088DEC7 /* CCFontFreeType.cpp in Sources */, 1A5701BA180BCB5A0088DEC7 /* CCLabel.cpp in Sources */, 1A5701BE180BCB5A0088DEC7 /* CCLabelAtlas.cpp in Sources */, 1A5701C2180BCB5A0088DEC7 /* CCLabelBMFont.cpp in Sources */, 1A087AE91860400400196EF5 /* edtaa3func.cpp in Sources */, 06CAAAC4186AD7DF0012A414 /* CCActionEaseEx.cpp in Sources */, B375107E1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */, 1A5701C8180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */, 1A5701CC180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */, 1A5701DF180BCB8C0088DEC7 /* CCLayer.cpp in Sources */, 1A5701E3180BCB8C0088DEC7 /* CCScene.cpp in Sources */, 1A5701E7180BCB8C0088DEC7 /* CCTransition.cpp in Sources */, 1A5701EB180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */, 1A5701EF180BCB8C0088DEC7 /* CCTransitionProgress.cpp in Sources */, 1A5701F8180BCBAD0088DEC7 /* CCMenu.cpp in Sources */, 1A5701FC180BCBAD0088DEC7 /* CCMenuItem.cpp in Sources */, 06CAAAD0186AD7FE0012A414 /* TriggerBase.cpp in Sources */, 1A570203180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */, 1A570209180BCBDF0088DEC7 /* CCMotionStreak.cpp in Sources */, 1A570211180BCBF40088DEC7 /* CCProgressTimer.cpp in Sources */, 1A570215180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */, 1A570222180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */, 1A570226180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */, 1A57022A180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */, 1A57022E180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */, 1A570235180BCC4D0088DEC7 /* CCScriptSupport.cpp in Sources */, 1A57026C180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */, 1A570272180BCC6F0088DEC7 /* ccShaders.cpp in Sources */, 1A57027F180BCC900088DEC7 /* CCSprite.cpp in Sources */, 1A570283180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, 1A570287180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */, 1A57028B180BCC900088DEC7 /* CCSpriteFrameCache.cpp in Sources */, 1A570293180BCCAB0088DEC7 /* CCAnimation.cpp in Sources */, 1A570297180BCCAB0088DEC7 /* CCAnimationCache.cpp in Sources */, 1A57029E180BCD890088DEC7 /* base64.cpp in Sources */, 1A5702A4180BCD980088DEC7 /* CCNotificationCenter.cpp in Sources */, 1A5702AA180BCDAA0088DEC7 /* CCProfiling.cpp in Sources */, 59A79D561821E26E00F19697 /* CCEventMouse.cpp in Sources */, 1A5702B0180BCDBC0088DEC7 /* ccUTF8.cpp in Sources */, 1A5702B6180BCDF40088DEC7 /* CCVertex.cpp in Sources */, 1A5702C3180BCE2A0088DEC7 /* CCIMEDispatcher.cpp in Sources */, 1A5702C9180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */, 1A5702D4180BCE570088DEC7 /* CCTexture2D.cpp in Sources */, 1A5702D8180BCE570088DEC7 /* CCTextureAtlas.cpp in Sources */, 50AE5EA4188749250007CFE3 /* CCBatchCommand.cpp in Sources */, 1A5702DC180BCE570088DEC7 /* CCTextureCache.cpp in Sources */, 1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, 1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, 1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, 1A5702F7180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */, 1A5702FB180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */, 1A570301180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */, 1A570306180BCED90088DEC7 /* ccUtils.cpp in Sources */, 1A57030D180BCF190088DEC7 /* CCComponent.cpp in Sources */, 1A570311180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */, 1A57031A180BCF430088DEC7 /* ccCArray.cpp in Sources */, B375107C1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */, 1A570325180BCF660088DEC7 /* TGAlib.cpp in Sources */, 1A570330180BCFD50088DEC7 /* CCUserDefault.cpp in Sources */, 1A570334180BCFD50088DEC7 /* CCUserDefault.mm in Sources */, 1A570336180BCFD50088DEC7 /* CCUserDefaultAndroid.cpp in Sources */, 1A57033B180BCFFA0088DEC7 /* ZipUtils.cpp in Sources */, 1A57034C180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, 1A570355180BD0B00088DEC7 /* ioapi.cpp in Sources */, 1A570359180BD0B00088DEC7 /* unzip.cpp in Sources */, 1A570534180BD9500088DEC7 /* CCGLProgram.cpp in Sources */, 1A570538180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */, 1A570547180BD9C40088DEC7 /* CCTouch.cpp in Sources */, 1AD71DAA180E26E600808F54 /* CCBAnimationManager.cpp in Sources */, 1AD71DAE180E26E600808F54 /* CCBFileLoader.cpp in Sources */, 1AD71DB2180E26E600808F54 /* CCBKeyframe.cpp in Sources */, 1AD71DB8180E26E600808F54 /* CCBReader.cpp in Sources */, 1AD71DBE180E26E600808F54 /* CCBSequence.cpp in Sources */, 1AD71DC2180E26E600808F54 /* CCBSequenceProperty.cpp in Sources */, 1AD71DCA180E26E600808F54 /* CCControlButtonLoader.cpp in Sources */, 1AD71DCE180E26E600808F54 /* CCControlLoader.cpp in Sources */, 1AE3C845184F14F700CF29B5 /* CCValue.cpp in Sources */, 1AD71DD2180E26E600808F54 /* CCLabelBMFontLoader.cpp in Sources */, 1AD71DD6180E26E600808F54 /* CCLabelTTFLoader.cpp in Sources */, 1AD71DDA180E26E600808F54 /* CCLayerColorLoader.cpp in Sources */, 1AD71DDE180E26E600808F54 /* CCLayerGradientLoader.cpp in Sources */, 1AD71DE2180E26E600808F54 /* CCLayerLoader.cpp in Sources */, 1AD71DE6180E26E600808F54 /* CCMenuItemImageLoader.cpp in Sources */, 1AD71DEA180E26E600808F54 /* CCMenuItemLoader.cpp in Sources */, 593BDCF3184D0A6E00C21E48 /* CCCustomCommand.cpp in Sources */, 06CAAAC8186AD7EB0012A414 /* TriggerObj.cpp in Sources */, 1AD71DF0180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp in Sources */, 1AD71DF4180E26E600808F54 /* CCNodeLoader.cpp in Sources */, 1AD71DF8180E26E600808F54 /* CCNodeLoaderLibrary.cpp in Sources */, 1AD71DFE180E26E600808F54 /* CCParticleSystemQuadLoader.cpp in Sources */, 1AD71E02180E26E600808F54 /* CCScale9SpriteLoader.cpp in Sources */, 1AD71E06180E26E600808F54 /* CCScrollViewLoader.cpp in Sources */, 1AD71E0A180E26E600808F54 /* CCSpriteLoader.cpp in Sources */, 1AD71E96180E26E600808F54 /* Animation.cpp in Sources */, 1AD71E9A180E26E600808F54 /* AnimationState.cpp in Sources */, 1AD71E9E180E26E600808F54 /* AnimationStateData.cpp in Sources */, 1AD71EA2180E26E600808F54 /* Atlas.cpp in Sources */, 1AD71EA6180E26E600808F54 /* AtlasAttachmentLoader.cpp in Sources */, 1AD71EAA180E26E600808F54 /* Attachment.cpp in Sources */, 1AD71EAE180E26E600808F54 /* AttachmentLoader.cpp in Sources */, 1AD71EB2180E26E600808F54 /* Bone.cpp in Sources */, 1AD71EB6180E26E600808F54 /* BoneData.cpp in Sources */, 1AD71EBA180E26E600808F54 /* CCSkeleton.cpp in Sources */, 1AD71EBE180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */, 1AD71EC2180E26E600808F54 /* extension.cpp in Sources */, 1AD71EC6180E26E600808F54 /* Json.cpp in Sources */, 1AD71ECA180E26E600808F54 /* RegionAttachment.cpp in Sources */, 1AD71ECE180E26E600808F54 /* Skeleton.cpp in Sources */, 1AD71ED2180E26E600808F54 /* SkeletonData.cpp in Sources */, 1AD71ED6180E26E600808F54 /* SkeletonJson.cpp in Sources */, 1AD71EDA180E26E600808F54 /* Skin.cpp in Sources */, 1AD71EDE180E26E600808F54 /* Slot.cpp in Sources */, 1AD71EE2180E26E600808F54 /* SlotData.cpp in Sources */, 1AD71EE6180E26E600808F54 /* spine-cocos2dx.cpp in Sources */, 1AAF536B180E3374000584C8 /* HttpClient.cpp in Sources */, 1AAF5373180E3374000584C8 /* SocketIO.cpp in Sources */, 1AAF5377180E3374000584C8 /* WebSocket.cpp in Sources */, 1AAF5850180E40B9000584C8 /* LocalStorage.cpp in Sources */, 1AAF5854180E40B9000584C8 /* LocalStorageAndroid.cpp in Sources */, 5069133F185016C1009BBDD7 /* CCConsole.cpp in Sources */, 1A9DCA16180E6955007A3AD4 /* CCConfiguration.cpp in Sources */, 1A9DCA1E180E6955007A3AD4 /* CCDirector.cpp in Sources */, 1A9DCA24180E6955007A3AD4 /* ccFPSImages.c in Sources */, 1A9DCA28180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */, 1A9DCA30180E6955007A3AD4 /* CCScheduler.cpp in Sources */, 1A9DCA38180E6955007A3AD4 /* cocos2d.cpp in Sources */, 1A9DCA3E180E6955007A3AD4 /* TransformUtils.cpp in Sources */, 1A9DCA44180E6D90007A3AD4 /* CCDeprecated.cpp in Sources */, 1A9DCA4A180E6DE3007A3AD4 /* ccTypes.cpp in Sources */, 1A8C58ED180E92CC00EF57C3 /* CocosGUI.cpp in Sources */, 1A8C58F1180E92CC00EF57C3 /* UILayout.cpp in Sources */, 1A8C58F5180E92CC00EF57C3 /* UILayoutParameter.cpp in Sources */, 1A8C58F9180E92CC00EF57C3 /* UIButton.cpp in Sources */, 1A8C58FD180E92CC00EF57C3 /* UICheckBox.cpp in Sources */, 1A8C5905180E92CC00EF57C3 /* UIHelper.cpp in Sources */, 1A8C5909180E92CC00EF57C3 /* UIImageView.cpp in Sources */, 1A8C5911180E92CC00EF57C3 /* UIText.cpp in Sources */, 1A8C5915180E92CC00EF57C3 /* UITextAtlas.cpp in Sources */, 1A8C5919180E92CC00EF57C3 /* UITextBMFont.cpp in Sources */, 59A79D521821E26E00F19697 /* CCEventListenerMouse.cpp in Sources */, 1A8C5921180E92CC00EF57C3 /* UILayoutDefine.cpp in Sources */, 1A8C5929180E92CC00EF57C3 /* UILoadingBar.cpp in Sources */, 1A8C592D180E92CC00EF57C3 /* UIPageView.cpp in Sources */, 1A8C5937180E92CC00EF57C3 /* UIScrollView.cpp in Sources */, 1A8C593B180E92CC00EF57C3 /* UISlider.cpp in Sources */, 1A8C593F180E92CC00EF57C3 /* UITextField.cpp in Sources */, 1A8C5943180E92CC00EF57C3 /* UIWidget.cpp in Sources */, 1A8C598C180E930E00EF57C3 /* CCActionFrame.cpp in Sources */, 1A8C5990180E930E00EF57C3 /* CCActionFrameEasing.cpp in Sources */, 1A8C5994180E930E00EF57C3 /* CCActionManagerEx.cpp in Sources */, 1A8C5998180E930E00EF57C3 /* CCActionNode.cpp in Sources */, 1A8C599C180E930E00EF57C3 /* CCActionObject.cpp in Sources */, 1A8C59A0180E930E00EF57C3 /* CCArmature.cpp in Sources */, 1A8C59A4180E930E00EF57C3 /* CCArmatureAnimation.cpp in Sources */, 1A8C59A8180E930E00EF57C3 /* CCArmatureDataManager.cpp in Sources */, 1A8C59AC180E930E00EF57C3 /* CCArmatureDefine.cpp in Sources */, 1A8C59B0180E930E00EF57C3 /* CCBatchNode.cpp in Sources */, 1A8C59B4180E930E00EF57C3 /* CCBone.cpp in Sources */, 50A1FF1918290ED4001840C4 /* UIListView.cpp in Sources */, 1A8C59B8180E930E00EF57C3 /* CCColliderDetector.cpp in Sources */, 1A8C59BC180E930E00EF57C3 /* CCComAttribute.cpp in Sources */, 1A8C59C0180E930E00EF57C3 /* CCComAudio.cpp in Sources */, 1A8C59C4180E930E00EF57C3 /* CCComController.cpp in Sources */, 1A8C59C8180E930E00EF57C3 /* CCComRender.cpp in Sources */, 1A8C59CC180E930E00EF57C3 /* CCDataReaderHelper.cpp in Sources */, 1A8C59D0180E930E00EF57C3 /* CCDatas.cpp in Sources */, 1A8C59D4180E930E00EF57C3 /* CCDecorativeDisplay.cpp in Sources */, 1A8C59D8180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */, 1A8C59DC180E930E00EF57C3 /* CCDisplayManager.cpp in Sources */, 1A8C59E0180E930E00EF57C3 /* CCInputDelegate.cpp in Sources */, 1A8C59E4180E930E00EF57C3 /* CCProcessBase.cpp in Sources */, 1A8C59E8180E930E00EF57C3 /* CCSGUIReader.cpp in Sources */, 1A8C59EC180E930E00EF57C3 /* CCSkin.cpp in Sources */, 1A8C59F0180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp in Sources */, 1A8C59F4180E930E00EF57C3 /* CCSSceneReader.cpp in Sources */, 1A8C59F8180E930E00EF57C3 /* CCTransformHelp.cpp in Sources */, 1A8C59FC180E930E00EF57C3 /* CCTween.cpp in Sources */, 1A8C5A00180E930E00EF57C3 /* CCTweenFunction.cpp in Sources */, 1A8C5A04180E930E00EF57C3 /* CCUtilMath.cpp in Sources */, 1A8C5A0E180E930E00EF57C3 /* DictionaryHelper.cpp in Sources */, 74AC858052DDF289AF7D6309 /* CCFrustum.cpp in Sources */, 74AC80E553789C6DE3EC737A /* CCRenderer.cpp in Sources */, 1ABA68AF1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */, 74AC846799FE6F299B410289 /* CCQuadCommand.cpp in Sources */, 74AC84A100AF9E826288CE2C /* CCRenderCommand.cpp in Sources */, 74AC8813CEE4FC652A0951FB /* CCRenderMaterial.cpp in Sources */, 74AC826A592CAE6AACD35DC5 /* CCMaterialManager.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4E121783867C0073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 460E47D918080914000CDD6D /* CCTableViewCell.cpp in Sources */, 460E47C01808090D000CDD6D /* CCEditBoxImplAndroid.cpp in Sources */, 460E47A118080904000CDD6D /* CCControlSaturationBrightnessPicker.cpp in Sources */, 460E47BD1808090D000CDD6D /* CCEditBox.cpp in Sources */, 460E47C71808090D000CDD6D /* CCEditBoxImplTizen.cpp in Sources */, 460E47C61808090D000CDD6D /* CCEditBoxImplNone.cpp in Sources */, 460E47D318080914000CDD6D /* CCScrollView.cpp in Sources */, 460E47C91808090D000CDD6D /* CCEditBoxImplWin.cpp in Sources */, 460E47A918080904000CDD6D /* CCControlUtils.cpp in Sources */, 460E47D718080914000CDD6D /* CCTableView.cpp in Sources */, 460E479F18080904000CDD6D /* CCControlPotentiometer.cpp in Sources */, 460E479818080904000CDD6D /* CCControlButton.cpp in Sources */, 460E47C51808090D000CDD6D /* CCEditBoxImplMac.mm in Sources */, 460E479D18080904000CDD6D /* CCControlHuePicker.cpp in Sources */, 460E47A318080904000CDD6D /* CCControlSlider.cpp in Sources */, 460E47AB18080904000CDD6D /* CCInvocation.cpp in Sources */, 460E47AD18080904000CDD6D /* CCScale9Sprite.cpp in Sources */, 460E47C31808090D000CDD6D /* CCEditBoxImplIOS.mm in Sources */, 460E47A718080904000CDD6D /* CCControlSwitch.cpp in Sources */, 460E479618080904000CDD6D /* CCControl.cpp in Sources */, 460E47A518080904000CDD6D /* CCControlStepper.cpp in Sources */, 460E479A18080904000CDD6D /* CCControlColourPicker.cpp in Sources */, 1AD71EF1180E27CF00808F54 /* CCPhysicsDebugNode.cpp in Sources */, 1AD71EF5180E27CF00808F54 /* CCPhysicsSprite.cpp in Sources */, 1AAF5354180E3060000584C8 /* AssetsManager.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4EFE178387670073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 46A173ED1807D363005B8026 /* cpSpaceQuery.c in Sources */, 46A173E91807D363005B8026 /* cpShape.c in Sources */, 46A173E31807D363005B8026 /* cpBB.c in Sources */, 46A173DC1807D363005B8026 /* cpPivotJoint.c in Sources */, 46A173E41807D363005B8026 /* cpBBTree.c in Sources */, 46A173D41807D358005B8026 /* chipmunk.c in Sources */, 46A173E51807D363005B8026 /* cpBody.c in Sources */, 46A173DF1807D363005B8026 /* cpSimpleMotor.c in Sources */, 46A173D61807D363005B8026 /* cpConstraint.c in Sources */, 46A173EB1807D363005B8026 /* cpSpaceComponent.c in Sources */, 46A173EC1807D363005B8026 /* cpSpaceHash.c in Sources */, 46A173DB1807D363005B8026 /* cpPinJoint.c in Sources */, 46A173F01807D363005B8026 /* cpSweep1D.c in Sources */, 46A173D81807D363005B8026 /* cpDampedSpring.c in Sources */, 46A173EE1807D363005B8026 /* cpSpaceStep.c in Sources */, 46A173DA1807D363005B8026 /* cpGrooveJoint.c in Sources */, 46A173E81807D363005B8026 /* cpPolyShape.c in Sources */, 46A173F11807D363005B8026 /* cpVect.c in Sources */, 46A173E01807D363005B8026 /* cpSlideJoint.c in Sources */, 46A173DE1807D363005B8026 /* cpRotaryLimitJoint.c in Sources */, 46A173E71807D363005B8026 /* cpHashSet.c in Sources */, 46A173E11807D363005B8026 /* cpArbiter.c in Sources */, 46A173E21807D363005B8026 /* cpArray.c in Sources */, 46A173D91807D363005B8026 /* cpGearJoint.c in Sources */, 46A173E61807D363005B8026 /* cpCollision.c in Sources */, 46A173EA1807D363005B8026 /* cpSpace.c in Sources */, 46A173DD1807D363005B8026 /* cpRatchetJoint.c in Sources */, 46A173D71807D363005B8026 /* cpDampedRotarySpring.c in Sources */, 46A173EF1807D363005B8026 /* cpSpatialIndex.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4F3D1783876B0073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1AAF529A180E2EE4000584C8 /* b2BroadPhase.cpp in Sources */, 1AAF529C180E2EE4000584C8 /* b2CollideCircle.cpp in Sources */, 1AAF529D180E2EE4000584C8 /* b2CollideEdge.cpp in Sources */, 1AAF529E180E2EE4000584C8 /* b2CollidePolygon.cpp in Sources */, 1AAF529F180E2EE4000584C8 /* b2Collision.cpp in Sources */, 1AAF52A1180E2EE4000584C8 /* b2Distance.cpp in Sources */, 1AAF52A3180E2EE4000584C8 /* b2DynamicTree.cpp in Sources */, 1AAF52A5180E2EE4000584C8 /* b2TimeOfImpact.cpp in Sources */, 1AAF52A7180E2EE8000584C8 /* b2ChainShape.cpp in Sources */, 1AAF52A9180E2EE8000584C8 /* b2CircleShape.cpp in Sources */, 1AAF52AB180E2EE8000584C8 /* b2EdgeShape.cpp in Sources */, 1AAF52AD180E2EE8000584C8 /* b2PolygonShape.cpp in Sources */, 1AAF52B9180E2EEE000584C8 /* b2BlockAllocator.cpp in Sources */, 1AAF52BB180E2EEE000584C8 /* b2Draw.cpp in Sources */, 1AAF52BE180E2EEE000584C8 /* b2Math.cpp in Sources */, 1AAF52C0180E2EEE000584C8 /* b2Settings.cpp in Sources */, 1AAF52C2180E2EEE000584C8 /* b2StackAllocator.cpp in Sources */, 1AAF52C4180E2EEE000584C8 /* b2Timer.cpp in Sources */, 1AAF52E0180E2EF6000584C8 /* b2Body.cpp in Sources */, 1AAF52E2180E2EF6000584C8 /* b2ContactManager.cpp in Sources */, 1AAF52E4180E2EF6000584C8 /* b2Fixture.cpp in Sources */, 1AAF52E6180E2EF6000584C8 /* b2Island.cpp in Sources */, 1AAF52E9180E2EF6000584C8 /* b2World.cpp in Sources */, 1AAF52EB180E2EF6000584C8 /* b2WorldCallbacks.cpp in Sources */, 1AAF52ED180E2EFC000584C8 /* b2ChainAndCircleContact.cpp in Sources */, 1AAF52EF180E2EFC000584C8 /* b2ChainAndPolygonContact.cpp in Sources */, 1AAF52F1180E2EFC000584C8 /* b2CircleContact.cpp in Sources */, 1AAF52F3180E2EFC000584C8 /* b2Contact.cpp in Sources */, 1AAF52F5180E2EFC000584C8 /* b2ContactSolver.cpp in Sources */, 1AAF52F7180E2EFC000584C8 /* b2EdgeAndCircleContact.cpp in Sources */, B3AF01A11842FBA400A98B85 /* b2MotorJoint.cpp in Sources */, 1AAF52F9180E2EFC000584C8 /* b2EdgeAndPolygonContact.cpp in Sources */, 1AAF52FB180E2EFC000584C8 /* b2PolygonAndCircleContact.cpp in Sources */, 1AAF52FD180E2EFC000584C8 /* b2PolygonContact.cpp in Sources */, 1AAF5327180E2F04000584C8 /* b2DistanceJoint.cpp in Sources */, 1AAF5329180E2F04000584C8 /* b2FrictionJoint.cpp in Sources */, 1AAF532B180E2F04000584C8 /* b2GearJoint.cpp in Sources */, 1AAF532D180E2F04000584C8 /* b2Joint.cpp in Sources */, 1AAF532F180E2F04000584C8 /* b2MouseJoint.cpp in Sources */, 1AAF5331180E2F04000584C8 /* b2PrismaticJoint.cpp in Sources */, 1AAF5333180E2F04000584C8 /* b2PulleyJoint.cpp in Sources */, 1AAF5335180E2F04000584C8 /* b2RevoluteJoint.cpp in Sources */, 1AAF5337180E2F04000584C8 /* b2RopeJoint.cpp in Sources */, 1AAF5339180E2F04000584C8 /* b2WeldJoint.cpp in Sources */, 1AAF533B180E2F04000584C8 /* b2WheelJoint.cpp in Sources */, 1AAF533F180E2F11000584C8 /* b2Rope.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4FA0178387730073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 46A160531807A5EB005B8026 /* CDAudioManager.m in Sources */, 46A160581807A5EB005B8026 /* CocosDenshion.m in Sources */, 46A160591807A5EB005B8026 /* SimpleAudioEngine.mm in Sources */, 46A1605B1807A5EB005B8026 /* SimpleAudioEngine_objc.m in Sources */, 46A160561807A5EB005B8026 /* CDOpenALSupport.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A4FB6178387750073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 3EEF8BD31839FFAF005E8A6C /* jsb_cocos2dx_gui_auto.cpp in Sources */, 3EEF8BD41839FFAF005E8A6C /* jsb_cocos2dx_gui_manual.cpp in Sources */, 1A2C791E181A1257004E5527 /* js_bindings_chipmunk_registration.cpp in Sources */, 1A2C793E181A1257004E5527 /* js_bindings_opengl.cpp in Sources */, 1A2C7950181A1257004E5527 /* jsb_opengl_registration.cpp in Sources */, 1A2C795A181A1257004E5527 /* js_bindings_system_registration.cpp in Sources */, 1A2C791A181A1257004E5527 /* js_bindings_chipmunk_manual.cpp in Sources */, 1A2C7930181A1257004E5527 /* jsb_cocos2dx_studio_manual.cpp in Sources */, 1A2C7966181A1257004E5527 /* ScriptingCore.cpp in Sources */, 1A2C790E181A1257004E5527 /* js_bindings_chipmunk_auto_classes.cpp in Sources */, 1A2C7914181A1257004E5527 /* js_bindings_chipmunk_functions.cpp in Sources */, 1A2C7934181A1257004E5527 /* jsb_cocos2dx_extension_manual.cpp in Sources */, 1A2C7948181A1257004E5527 /* jsb_opengl_functions.cpp in Sources */, 1A2C7928181A1257004E5527 /* js_bindings_ccbreader.cpp in Sources */, 1A2C7874181A11EC004E5527 /* jsb_cocos2dx_auto.cpp in Sources */, 1A2C793A181A1257004E5527 /* js_bindings_core.cpp in Sources */, 1A2C794C181A1257004E5527 /* jsb_opengl_manual.cpp in Sources */, 1A2C7880181A11EC004E5527 /* jsb_cocos2dx_builder_auto.cpp in Sources */, 1A2C7942181A1257004E5527 /* js_manual_conversions.cpp in Sources */, 1A2C7922181A1257004E5527 /* cocos2d_specifics.cpp in Sources */, 1A2C788C181A11EC004E5527 /* jsb_cocos2dx_extension_auto.cpp in Sources */, 1A2C7954181A1257004E5527 /* js_bindings_system_functions.cpp in Sources */, 1A2C7898181A11EC004E5527 /* jsb_cocos2dx_studio_auto.cpp in Sources */, 1A2C795E181A1257004E5527 /* jsb_websocket.cpp in Sources */, 1A2C7962181A1257004E5527 /* XMLHTTPRequest.cpp in Sources */, 2AFCB8241863D6F600EB4B5C /* jsb_cocos2dx_spine_auto.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 1A6FB4FF17854AD600CDF010 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1A119716178526AA00D62A44 /* luabindings iOS */; targetProxy = 1A6FB4FE17854AD600CDF010 /* PBXContainerItemProxy */; }; 1A6FB7E71785683A00CDF010 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1A6FB50417854BC200CDF010 /* luabindings Mac */; targetProxy = 1A6FB7E61785683A00CDF010 /* PBXContainerItemProxy */; }; 460E44F41807E241000CDD6D /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A03F2B781780BD04006731B9 /* chipmunk Mac */; targetProxy = 460E44F31807E241000CDD6D /* PBXContainerItemProxy */; }; 46A173D31807D330005B8026 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A4EFD178387670073F6A7 /* chipmunk iOS */; targetProxy = 46A173D21807D330005B8026 /* PBXContainerItemProxy */; }; A03F2E93178141D1006731B9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1551A33E158F2AB200E66CFE /* cocos2dx Mac */; targetProxy = A03F2E92178141D1006731B9 /* PBXContainerItemProxy */; }; A03F2E95178141D1006731B9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A03F2B781780BD04006731B9 /* chipmunk Mac */; targetProxy = A03F2E94178141D1006731B9 /* PBXContainerItemProxy */; }; A03F2E97178141D1006731B9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A03F2D5D1780BDF7006731B9 /* box2d Mac */; targetProxy = A03F2E96178141D1006731B9 /* PBXContainerItemProxy */; }; A03F2FC01781458C006731B9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A03F2E9817814268006731B9 /* CocosDenshion Mac */; targetProxy = A03F2FBF1781458C006731B9 /* PBXContainerItemProxy */; }; A03F31FF178147CB006731B9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A03F2FC117814595006731B9 /* cocos2dx-extensions Mac */; targetProxy = A03F31FE178147CB006731B9 /* PBXContainerItemProxy */; }; A03F3201178147CB006731B9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A03F31E81781479B006731B9 /* jsbindings Mac */; targetProxy = A03F3200178147CB006731B9 /* PBXContainerItemProxy */; }; A07A4E10178386520073F6A7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A4C241783777C0073F6A7 /* cocos2dx iOS */; targetProxy = A07A4E0F178386520073F6A7 /* PBXContainerItemProxy */; }; A07A5047178389710073F6A7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A4E111783867C0073F6A7 /* cocos2dx-extensions iOS */; targetProxy = A07A5046178389710073F6A7 /* PBXContainerItemProxy */; }; A07A5049178389710073F6A7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A4EFD178387670073F6A7 /* chipmunk iOS */; targetProxy = A07A5048178389710073F6A7 /* PBXContainerItemProxy */; }; A07A504B178389710073F6A7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A4F3C1783876B0073F6A7 /* box2d iOS */; targetProxy = A07A504A178389710073F6A7 /* PBXContainerItemProxy */; }; A07A504D178389710073F6A7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A4F9F178387730073F6A7 /* CocosDenshion iOS */; targetProxy = A07A504C178389710073F6A7 /* PBXContainerItemProxy */; }; A07A504F178389710073F6A7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A4FB5178387750073F6A7 /* jsbindings iOS */; targetProxy = A07A504E178389710073F6A7 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ 1551A34A158F2AB200E66CFE /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = c99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_SHADOW = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; MACOSX_DEPLOYMENT_TARGET = 10.7; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SKIP_INSTALL = YES; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath/include $(SRCROOT)/../cocos/2d/platform $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../cocos/gui $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external $(SRCROOT)/../cocos/storage"; }; name = Debug; }; 1551A34B158F2AB200E66CFE /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; GCC_C_LANGUAGE_STANDARD = c99; GCC_PREPROCESSOR_DEFINITIONS = ( "CC_ENABLE_CHIPMUNK_INTEGRATION=1", NDEBUG, USE_FILE32API, ); GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_SHADOW = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; MACOSX_DEPLOYMENT_TARGET = 10.7; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SKIP_INSTALL = YES; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath/include $(SRCROOT)/../cocos/2d/platform $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../cocos/gui $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external $(SRCROOT)/../cocos/storage"; VALIDATE_PRODUCT = YES; }; name = Release; }; 1551A34D158F2AB200E66CFE /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/2d/cocos2dx-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../external/glfw3/prebuilt/mac\"", "\"$(SRCROOT)/../external/png/prebuilt/mac\"", "\"$(SRCROOT)/../external/jpeg/prebuilt/mac\"", "\"$(SRCROOT)/../external/tiff/prebuilt/mac\"", "\"$(SRCROOT)/../external/webp/prebuilt/mac\"", "\"$(SRCROOT)/../external/freetype2/prebuilt/mac\"", "\"$(SRCROOT)/../external/websockets/prebuilt/mac\"", ); USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/png/include/mac $(SRCROOT)/../external/tiff/include/mac $(SRCROOT)/../external/webp/include/mac $(SRCROOT)/../external/jpeg/include/mac $(SRCROOT)/../external/freetype2/include/mac $(SRCROOT)/../external/websockets/include/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/2d/platform/desktop"; }; name = Debug; }; 1551A34E158F2AB200E66CFE /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/2d/cocos2dx-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_KEYBOARD_SUPPORT, CC_TARGET_OS_MAC, ); HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../external/glfw3/prebuilt/mac\"", "\"$(SRCROOT)/../external/png/prebuilt/mac\"", "\"$(SRCROOT)/../external/jpeg/prebuilt/mac\"", "\"$(SRCROOT)/../external/tiff/prebuilt/mac\"", "\"$(SRCROOT)/../external/webp/prebuilt/mac\"", "\"$(SRCROOT)/../external/freetype2/prebuilt/mac\"", "\"$(SRCROOT)/../external/websockets/prebuilt/mac\"", ); USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/png/include/mac $(SRCROOT)/../external/tiff/include/mac $(SRCROOT)/../external/webp/include/mac $(SRCROOT)/../external/jpeg/include/mac $(SRCROOT)/../external/freetype2/include/mac $(SRCROOT)/../external/websockets/include/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/2d/platform/desktop"; }; name = Release; }; 1A11978F178526AA00D62A44 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/2d/cocos2dx-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../external/lua/luajit/prebuilt/ios", ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; }; name = Debug; }; 1A119790178526AA00D62A44 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/2d/cocos2dx-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../external/lua/luajit/prebuilt/ios", ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; }; name = Release; }; 1A6FB52E17854BC200CDF010 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/2d/cocos2dx-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../external/lua/luajit/prebuilt/mac", ); TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; }; name = Debug; }; 1A6FB52F17854BC200CDF010 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/2d/cocos2dx-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../external/lua/luajit/prebuilt/mac", ); TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; }; name = Release; }; A03F2CB61780BD04006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/chipmunk/include/chipmunk/"; }; name = Debug; }; A03F2CB71780BD04006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/chipmunk/include/chipmunk/"; }; name = Release; }; A03F2D991780BDF7006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_WARN_UNUSED_VALUE = NO; GCC_WARN_UNUSED_VARIABLE = NO; HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/"; USER_HEADER_SEARCH_PATHS = ""; }; name = Debug; }; A03F2D9A1780BDF7006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { GCC_WARN_UNUSED_VALUE = NO; GCC_WARN_UNUSED_VARIABLE = NO; HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/"; USER_HEADER_SEARCH_PATHS = ""; }; name = Release; }; A03F2E90178141C1006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_BOX2D_INTEGRATION=1", ); HEADER_SEARCH_PATHS = ( "$(inherited)", "/Applications/Xcode\\ 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", ); USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath/include $(SRCROOT)/../cocos/2d/platform $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../cocos/gui $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external/Box2D $(SRCROOT)/../external $(SRCROOT)/../cocos/storage"; }; name = Debug; }; A03F2E91178141C1006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { HEADER_SEARCH_PATHS = ( "$(inherited)", "/Applications/Xcode\\ 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", ); USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath/include $(SRCROOT)/../cocos/2d/platform $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../cocos/gui $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../external/Box2D $(SRCROOT)/../external $(SRCROOT)/../cocos/storage"; }; name = Release; }; A03F2ED417814268006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac"; }; name = Debug; }; A03F2ED517814268006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac"; }; name = Release; }; A03F2FD417814595006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = "$(inherited)"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A03F2FD517814595006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = "$(inherited)"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Release; }; A03F31FB1781479B006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../external/spidermonkey/prebuilt/mac\"", ); USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A03F31FC1781479B006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../external/spidermonkey/prebuilt/mac\"", ); USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Release; }; A07A4D621783777C0073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/2d/cocos2dx-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; LIBRARY_SEARCH_PATHS = ( "\"$(SRCROOT)/../external/png/prebuilt/ios\"", "\"$(SRCROOT)/../external/jpeg/prebuilt/ios\"", "\"$(SRCROOT)/../external/tiff/prebuilt/ios\"", "\"$(SRCROOT)/../external/webp/prebuilt/ios\"", "\"$(SRCROOT)/../external/freetype2/prebuilt/ios\"", "\"$(SRCROOT)/../external/websockets/prebuilt/ios\"", "\"$(SRCROOT)/../external/curl/prebuilt/ios\"", ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external/websockets/include/ios $(SRCROOT)/../external/freetype2/include/ios $(SRCROOT)/../external/curl/include/ios $(SRCROOT)/../external/webp/include/ios $(SRCROOT)/../external/tiff/include/ios $(SRCROOT)/../external/jpeg/include/ios $(SRCROOT)/../external/png/include/ios"; }; name = Debug; }; A07A4D631783777C0073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/2d/cocos2dx-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; LIBRARY_SEARCH_PATHS = ( "\"$(SRCROOT)/../external/png/prebuilt/ios\"", "\"$(SRCROOT)/../external/jpeg/prebuilt/ios\"", "\"$(SRCROOT)/../external/tiff/prebuilt/ios\"", "\"$(SRCROOT)/../external/webp/prebuilt/ios\"", "\"$(SRCROOT)/../external/freetype2/prebuilt/ios\"", "\"$(SRCROOT)/../external/websockets/prebuilt/ios\"", "\"$(SRCROOT)/../external/curl/prebuilt/ios\"", ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external/websockets/include/ios $(SRCROOT)/../external/freetype2/include/ios $(SRCROOT)/../external/curl/include/ios $(SRCROOT)/../external/webp/include/ios $(SRCROOT)/../external/tiff/include/ios $(SRCROOT)/../external/jpeg/include/ios $(SRCROOT)/../external/png/include/ios"; }; name = Release; }; A07A4E0D178386390073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; A07A4E0E178386390073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; A07A4EFA1783867C0073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; LIBRARY_SEARCH_PATHS = "$(inherited)"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external/curl/include/ios"; }; name = Debug; }; A07A4EFB1783867C0073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; LIBRARY_SEARCH_PATHS = "$(inherited)"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external/curl/include/ios"; }; name = Release; }; A07A4F39178387670073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/chipmunk/include/chipmunk/"; }; name = Debug; }; A07A4F3A178387670073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/chipmunk/include/chipmunk/"; }; name = Release; }; A07A4F9C1783876B0073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; GCC_WARN_UNUSED_VALUE = NO; GCC_WARN_UNUSED_VARIABLE = NO; HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = ""; }; name = Debug; }; A07A4F9D1783876B0073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; GCC_WARN_UNUSED_VALUE = NO; GCC_WARN_UNUSED_VARIABLE = NO; HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = ""; }; name = Release; }; A07A4FB2178387730073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios"; }; name = Debug; }; A07A4FB3178387730073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios"; }; name = Release; }; A07A502E178387750073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../external/spidermonkey/prebuilt/ios\"", ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/spidermonkey/include/ios $(SRCROOT)/../cocos/2d/platform/ios"; }; name = Debug; }; A07A502F178387750073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_IPHONE, ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../external/spidermonkey/prebuilt/ios\"", ); SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/spidermonkey/include/ios $(SRCROOT)/../cocos/2d/platform/ios"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 1551A339158F2AB200E66CFE /* Build configuration list for PBXProject "cocos2d_libs" */ = { isa = XCConfigurationList; buildConfigurations = ( 1551A34A158F2AB200E66CFE /* Debug */, 1551A34B158F2AB200E66CFE /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 1551A34C158F2AB200E66CFE /* Build configuration list for PBXNativeTarget "cocos2dx Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( 1551A34D158F2AB200E66CFE /* Debug */, 1551A34E158F2AB200E66CFE /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 1A11978E178526AA00D62A44 /* Build configuration list for PBXNativeTarget "luabindings iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 1A11978F178526AA00D62A44 /* Debug */, 1A119790178526AA00D62A44 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 1A6FB52D17854BC200CDF010 /* Build configuration list for PBXNativeTarget "luabindings Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( 1A6FB52E17854BC200CDF010 /* Debug */, 1A6FB52F17854BC200CDF010 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A03F2CB51780BD04006731B9 /* Build configuration list for PBXNativeTarget "chipmunk Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A03F2CB61780BD04006731B9 /* Debug */, A03F2CB71780BD04006731B9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A03F2D981780BDF7006731B9 /* Build configuration list for PBXNativeTarget "box2d Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A03F2D991780BDF7006731B9 /* Debug */, A03F2D9A1780BDF7006731B9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A03F2E8F178141C1006731B9 /* Build configuration list for PBXAggregateTarget "build-all-libs Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A03F2E90178141C1006731B9 /* Debug */, A03F2E91178141C1006731B9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A03F2ED317814268006731B9 /* Build configuration list for PBXNativeTarget "CocosDenshion Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A03F2ED417814268006731B9 /* Debug */, A03F2ED517814268006731B9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A03F2FD317814595006731B9 /* Build configuration list for PBXNativeTarget "cocos2dx-extensions Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A03F2FD417814595006731B9 /* Debug */, A03F2FD517814595006731B9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A03F31FA1781479B006731B9 /* Build configuration list for PBXNativeTarget "jsbindings Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A03F31FB1781479B006731B9 /* Debug */, A03F31FC1781479B006731B9 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A07A4D611783777C0073F6A7 /* Build configuration list for PBXNativeTarget "cocos2dx iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A4D621783777C0073F6A7 /* Debug */, A07A4D631783777C0073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A07A4E0C178386390073F6A7 /* Build configuration list for PBXAggregateTarget "build-all-libs iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A4E0D178386390073F6A7 /* Debug */, A07A4E0E178386390073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A07A4EF91783867C0073F6A7 /* Build configuration list for PBXNativeTarget "cocos2dx-extensions iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A4EFA1783867C0073F6A7 /* Debug */, A07A4EFB1783867C0073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A07A4F38178387670073F6A7 /* Build configuration list for PBXNativeTarget "chipmunk iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A4F39178387670073F6A7 /* Debug */, A07A4F3A178387670073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A07A4F9B1783876B0073F6A7 /* Build configuration list for PBXNativeTarget "box2d iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A4F9C1783876B0073F6A7 /* Debug */, A07A4F9D1783876B0073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A07A4FB1178387730073F6A7 /* Build configuration list for PBXNativeTarget "CocosDenshion iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A4FB2178387730073F6A7 /* Debug */, A07A4FB3178387730073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; A07A502D178387750073F6A7 /* Build configuration list for PBXNativeTarget "jsbindings iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A502E178387750073F6A7 /* Debug */, A07A502F178387750073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 1551A336158F2AB200E66CFE /* Project object */; } ================================================ FILE: cocos2d/build/cocos2d_samples.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXAggregateTarget section */ A035ACBB1782469700987F6C /* build-all-samples Mac */ = { isa = PBXAggregateTarget; buildConfigurationList = A035ACBC1782469800987F6C /* Build configuration list for PBXAggregateTarget "build-all-samples Mac" */; buildPhases = ( ); dependencies = ( 1A6FB7E31785682700CDF010 /* PBXTargetDependency */, 1A6FB7E51785682700CDF010 /* PBXTargetDependency */, A035AF731782569500987F6C /* PBXTargetDependency */, A035AF751782569500987F6C /* PBXTargetDependency */, A035ACC0178246BD00987F6C /* PBXTargetDependency */, A035ACC2178246BD00987F6C /* PBXTargetDependency */, A035ACC4178246BD00987F6C /* PBXTargetDependency */, A035ACC6178246BD00987F6C /* PBXTargetDependency */, A035ACC8178246BD00987F6C /* PBXTargetDependency */, A035ACCA178246BD00987F6C /* PBXTargetDependency */, ); name = "build-all-samples Mac"; productName = "build-all-samples"; }; A07A517B1783A1CC0073F6A7 /* build-all-samples iOS */ = { isa = PBXAggregateTarget; buildConfigurationList = A07A517C1783A1CC0073F6A7 /* Build configuration list for PBXAggregateTarget "build-all-samples iOS" */; buildPhases = ( ); dependencies = ( 1A6FB50117854AEA00CDF010 /* PBXTargetDependency */, 1A6FB50317854AEA00CDF010 /* PBXTargetDependency */, A01E19971784C8DD00B0CA4A /* PBXTargetDependency */, A01E19991784C8DD00B0CA4A /* PBXTargetDependency */, A01E199B1784C8DD00B0CA4A /* PBXTargetDependency */, A01E199D1784C8DD00B0CA4A /* PBXTargetDependency */, A01E17E21784C3EB00B0CA4A /* PBXTargetDependency */, A01E17E41784C3EB00B0CA4A /* PBXTargetDependency */, A01E17E61784C3EB00B0CA4A /* PBXTargetDependency */, A07A526D1783AB980073F6A7 /* PBXTargetDependency */, ); name = "build-all-samples iOS"; productName = "build-all-samples iOS"; }; /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ 15394DF3182E8F5D000A418D /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15394DF2182E8F5D000A418D /* StudioConstants.lua */; }; 15394DF5182E8F5D000A418D /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15394DF2182E8F5D000A418D /* StudioConstants.lua */; }; 1585AAC81821F8D900000FB5 /* LuaObjectCBridgeTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1585AAC71821F8D900000FB5 /* LuaObjectCBridgeTest.mm */; }; 1585AB111821FA1A00000FB5 /* luaoc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1585AB101821FA1A00000FB5 /* luaoc.lua */; }; 1585AB131821FA1A00000FB5 /* luaoc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1585AB101821FA1A00000FB5 /* luaoc.lua */; }; 1585AB181821FF4C00000FB5 /* LuaObjectCBridgeTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1585AB171821FF4C00000FB5 /* LuaObjectCBridgeTest.mm */; }; 1585AB35182299FA00000FB5 /* json.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1585AB34182299FA00000FB5 /* json.lua */; }; 1585AB37182299FA00000FB5 /* json.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1585AB34182299FA00000FB5 /* json.lua */; }; 1585AB4B1823A55400000FB5 /* lua_assetsmanager_test_sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1585AB491823A55400000FB5 /* lua_assetsmanager_test_sample.cpp */; }; 1585AB4C1823A55400000FB5 /* lua_assetsmanager_test_sample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1585AB491823A55400000FB5 /* lua_assetsmanager_test_sample.cpp */; }; 15982CE2187656CD00625972 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15982CE1187656CD00625972 /* GuiConstants.lua */; }; 15982CE4187656CD00625972 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15982CE1187656CD00625972 /* GuiConstants.lua */; }; 15A71DB71894AE6200F30AC0 /* mobdebug.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A71DB61894AE6200F30AC0 /* mobdebug.lua */; }; 15A71DB81894AE6200F30AC0 /* mobdebug.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A71DB61894AE6200F30AC0 /* mobdebug.lua */; }; 15C64825165F3934007D4F18 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; 15C64827165F394E007D4F18 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; 15C64829165F396B007D4F18 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; 15C6482B165F3979007D4F18 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; 15C6482D165F3988007D4F18 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; 15C6482F165F399D007D4F18 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; 15C64833165F3AFD007D4F18 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; 15F4C82918751B590082884F /* extern.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15F4C82818751B590082884F /* extern.lua */; }; 15F4C82B18751B590082884F /* extern.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15F4C82818751B590082884F /* extern.lua */; }; 15F4C847187551340082884F /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15F4C846187551340082884F /* CocoStudio.lua */; }; 15F4C849187551340082884F /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15F4C846187551340082884F /* CocoStudio.lua */; }; 1A0800BE18780B2A00E62F93 /* cocosbuilderRes in Resources */ = {isa = PBXBuildFile; fileRef = 1A0800BC18780B2A00E62F93 /* cocosbuilderRes */; }; 1A0800BF18780B2A00E62F93 /* cocosbuilderRes in Resources */ = {isa = PBXBuildFile; fileRef = 1A0800BC18780B2A00E62F93 /* cocosbuilderRes */; }; 1A0800C018780B2A00E62F93 /* luaScript in Resources */ = {isa = PBXBuildFile; fileRef = 1A0800BD18780B2A00E62F93 /* luaScript */; }; 1A0800C118780B2A00E62F93 /* luaScript in Resources */ = {isa = PBXBuildFile; fileRef = 1A0800BD18780B2A00E62F93 /* luaScript */; }; 1A0800C418780B5E00E62F93 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15982CE1187656CD00625972 /* GuiConstants.lua */; }; 1A0800C518780B5E00E62F93 /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15F4C846187551340082884F /* CocoStudio.lua */; }; 1A0800C618780B5E00E62F93 /* extern.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15F4C82818751B590082884F /* extern.lua */; }; 1A0800C718780B5E00E62F93 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15394DF2182E8F5D000A418D /* StudioConstants.lua */; }; 1A0800C818780B5E00E62F93 /* json.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1585AB34182299FA00000FB5 /* json.lua */; }; 1A0800C918780B5E00E62F93 /* luaoc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1585AB101821FA1A00000FB5 /* luaoc.lua */; }; 1A0800CA18780B5E00E62F93 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5596180E8B8400EF57C3 /* AudioEngine.lua */; }; 1A0800CB18780B5E00E62F93 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5597180E8B8400EF57C3 /* CCBReaderLoad.lua */; }; 1A0800CC18780B5E00E62F93 /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5598180E8B8400EF57C3 /* Cocos2d.lua */; }; 1A0800CD18780B5E00E62F93 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5599180E8B8400EF57C3 /* Cocos2dConstants.lua */; }; 1A0800CE18780B5E00E62F93 /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559A180E8B8400EF57C3 /* Deprecated.lua */; }; 1A0800CF18780B5E00E62F93 /* DeprecatedClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559B180E8B8400EF57C3 /* DeprecatedClass.lua */; }; 1A0800D018780B5E00E62F93 /* DeprecatedEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559C180E8B8400EF57C3 /* DeprecatedEnum.lua */; }; 1A0800D118780B5E00E62F93 /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559D180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua */; }; 1A0800D218780B5E00E62F93 /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559E180E8B8400EF57C3 /* DrawPrimitives.lua */; }; 1A0800D318780B5E00E62F93 /* luaj.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559F180E8B8400EF57C3 /* luaj.lua */; }; 1A0800D418780B5E00E62F93 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C55A0180E8B8400EF57C3 /* Opengl.lua */; }; 1A0800D518780B5E00E62F93 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C55A1180E8B8400EF57C3 /* OpenglConstants.lua */; }; 1A0800D618780B6100E62F93 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15982CE1187656CD00625972 /* GuiConstants.lua */; }; 1A0800D718780B6100E62F93 /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15F4C846187551340082884F /* CocoStudio.lua */; }; 1A0800D818780B6100E62F93 /* extern.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15F4C82818751B590082884F /* extern.lua */; }; 1A0800D918780B6100E62F93 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15394DF2182E8F5D000A418D /* StudioConstants.lua */; }; 1A0800DA18780B6100E62F93 /* json.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1585AB34182299FA00000FB5 /* json.lua */; }; 1A0800DB18780B6100E62F93 /* luaoc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1585AB101821FA1A00000FB5 /* luaoc.lua */; }; 1A0800DC18780B6100E62F93 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5596180E8B8400EF57C3 /* AudioEngine.lua */; }; 1A0800DD18780B6100E62F93 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5597180E8B8400EF57C3 /* CCBReaderLoad.lua */; }; 1A0800DE18780B6100E62F93 /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5598180E8B8400EF57C3 /* Cocos2d.lua */; }; 1A0800DF18780B6100E62F93 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5599180E8B8400EF57C3 /* Cocos2dConstants.lua */; }; 1A0800E018780B6100E62F93 /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559A180E8B8400EF57C3 /* Deprecated.lua */; }; 1A0800E118780B6100E62F93 /* DeprecatedClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559B180E8B8400EF57C3 /* DeprecatedClass.lua */; }; 1A0800E218780B6100E62F93 /* DeprecatedEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559C180E8B8400EF57C3 /* DeprecatedEnum.lua */; }; 1A0800E318780B6100E62F93 /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559D180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua */; }; 1A0800E418780B6100E62F93 /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559E180E8B8400EF57C3 /* DrawPrimitives.lua */; }; 1A0800E518780B6100E62F93 /* luaj.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559F180E8B8400EF57C3 /* luaj.lua */; }; 1A0800E618780B6100E62F93 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C55A0180E8B8400EF57C3 /* Opengl.lua */; }; 1A0800E718780B6100E62F93 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C55A1180E8B8400EF57C3 /* OpenglConstants.lua */; }; 1A0800E818780BD400E62F93 /* animations in Resources */ = {isa = PBXBuildFile; fileRef = 37C819601875DF2A00930C57 /* animations */; }; 1A0800E918780BD400E62F93 /* armature in Resources */ = {isa = PBXBuildFile; fileRef = 37C819611875DF2A00930C57 /* armature */; }; 1A0800EA18780BD400E62F93 /* ccb in Resources */ = {isa = PBXBuildFile; fileRef = 37C819651875DF2A00930C57 /* ccb */; }; 1A0800EB18780BD400E62F93 /* cocosgui in Resources */ = {isa = PBXBuildFile; fileRef = 37C819681875DF2A00930C57 /* cocosgui */; }; 1A0800EC18780BD400E62F93 /* components in Resources */ = {isa = PBXBuildFile; fileRef = 37C819691875DF2A00930C57 /* components */; }; 1A0800ED18780BD400E62F93 /* configs in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196A1875DF2A00930C57 /* configs */; }; 1A0800EE18780BD400E62F93 /* extensions in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196E1875DF2A00930C57 /* extensions */; }; 1A0800EF18780BD400E62F93 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 37C819701875DF2A00930C57 /* fonts */; }; 1A0800F018780BD400E62F93 /* hd in Resources */ = {isa = PBXBuildFile; fileRef = 37C819721875DF2A00930C57 /* hd */; }; 1A0800F118780BD400E62F93 /* Images in Resources */ = {isa = PBXBuildFile; fileRef = 37C819741875DF2B00930C57 /* Images */; }; 1A0800F218780BD400E62F93 /* ipad in Resources */ = {isa = PBXBuildFile; fileRef = 37C819751875DF2B00930C57 /* ipad */; }; 1A0800F318780BD400E62F93 /* ipadhd in Resources */ = {isa = PBXBuildFile; fileRef = 37C819761875DF2B00930C57 /* ipadhd */; }; 1A0800F418780BD400E62F93 /* Misc in Resources */ = {isa = PBXBuildFile; fileRef = 37C819771875DF2B00930C57 /* Misc */; }; 1A0800F518780BD400E62F93 /* Particles in Resources */ = {isa = PBXBuildFile; fileRef = 37C819791875DF2B00930C57 /* Particles */; }; 1A0800F618780BD400E62F93 /* scenetest in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197B1875DF2B00930C57 /* scenetest */; }; 1A0800F718780BD400E62F93 /* Shaders in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197C1875DF2B00930C57 /* Shaders */; }; 1A0800F818780BD400E62F93 /* spine in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197D1875DF2B00930C57 /* spine */; }; 1A0800F918780BD400E62F93 /* TileMaps in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197E1875DF2B00930C57 /* TileMaps */; }; 1A0800FA18780BD400E62F93 /* zwoptex in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197F1875DF2B00930C57 /* zwoptex */; }; 1A08010E18780BD600E62F93 /* animations in Resources */ = {isa = PBXBuildFile; fileRef = 37C819601875DF2A00930C57 /* animations */; }; 1A08010F18780BD600E62F93 /* armature in Resources */ = {isa = PBXBuildFile; fileRef = 37C819611875DF2A00930C57 /* armature */; }; 1A08011018780BD600E62F93 /* ccb in Resources */ = {isa = PBXBuildFile; fileRef = 37C819651875DF2A00930C57 /* ccb */; }; 1A08011118780BD600E62F93 /* cocosgui in Resources */ = {isa = PBXBuildFile; fileRef = 37C819681875DF2A00930C57 /* cocosgui */; }; 1A08011218780BD600E62F93 /* components in Resources */ = {isa = PBXBuildFile; fileRef = 37C819691875DF2A00930C57 /* components */; }; 1A08011318780BD600E62F93 /* configs in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196A1875DF2A00930C57 /* configs */; }; 1A08011418780BD600E62F93 /* extensions in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196E1875DF2A00930C57 /* extensions */; }; 1A08011518780BD600E62F93 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 37C819701875DF2A00930C57 /* fonts */; }; 1A08011618780BD600E62F93 /* hd in Resources */ = {isa = PBXBuildFile; fileRef = 37C819721875DF2A00930C57 /* hd */; }; 1A08011718780BD600E62F93 /* Images in Resources */ = {isa = PBXBuildFile; fileRef = 37C819741875DF2B00930C57 /* Images */; }; 1A08011818780BD600E62F93 /* ipad in Resources */ = {isa = PBXBuildFile; fileRef = 37C819751875DF2B00930C57 /* ipad */; }; 1A08011918780BD600E62F93 /* ipadhd in Resources */ = {isa = PBXBuildFile; fileRef = 37C819761875DF2B00930C57 /* ipadhd */; }; 1A08011A18780BD600E62F93 /* Misc in Resources */ = {isa = PBXBuildFile; fileRef = 37C819771875DF2B00930C57 /* Misc */; }; 1A08011B18780BD600E62F93 /* Particles in Resources */ = {isa = PBXBuildFile; fileRef = 37C819791875DF2B00930C57 /* Particles */; }; 1A08011C18780BD600E62F93 /* scenetest in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197B1875DF2B00930C57 /* scenetest */; }; 1A08011D18780BD600E62F93 /* Shaders in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197C1875DF2B00930C57 /* Shaders */; }; 1A08011E18780BD600E62F93 /* spine in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197D1875DF2B00930C57 /* spine */; }; 1A08011F18780BD600E62F93 /* TileMaps in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197E1875DF2B00930C57 /* TileMaps */; }; 1A08012018780BD600E62F93 /* zwoptex in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197F1875DF2B00930C57 /* zwoptex */; }; 1A08013418780C0700E62F93 /* background-music-aac.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C819621875DF2A00930C57 /* background-music-aac.wav */; }; 1A08013518780C0700E62F93 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 37C819631875DF2A00930C57 /* background.mp3 */; }; 1A08013618780C0700E62F93 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 37C819641875DF2A00930C57 /* background.ogg */; }; 1A08013718780C0B00E62F93 /* background-music-aac.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C819621875DF2A00930C57 /* background-music-aac.wav */; }; 1A08013818780C0B00E62F93 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 37C819631875DF2A00930C57 /* background.mp3 */; }; 1A08013918780C0B00E62F93 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 37C819641875DF2A00930C57 /* background.ogg */; }; 1A08013A18780C1B00E62F93 /* effect1.raw in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196B1875DF2A00930C57 /* effect1.raw */; }; 1A08013B18780C1B00E62F93 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196C1875DF2A00930C57 /* effect1.wav */; }; 1A08013C18780C1B00E62F93 /* effect2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196D1875DF2A00930C57 /* effect2.ogg */; }; 1A08013D18780C1B00E62F93 /* fileLookup.plist in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196F1875DF2A00930C57 /* fileLookup.plist */; }; 1A08013E18780C1B00E62F93 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 37C819711875DF2A00930C57 /* fps_images.png */; }; 1A08013F18780C1B00E62F93 /* Hello.png in Resources */ = {isa = PBXBuildFile; fileRef = 37C819731875DF2A00930C57 /* Hello.png */; }; 1A08014018780C1B00E62F93 /* music.mid in Resources */ = {isa = PBXBuildFile; fileRef = 37C819781875DF2B00930C57 /* music.mid */; }; 1A08014118780C1B00E62F93 /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197A1875DF2B00930C57 /* pew-pew-lei.wav */; }; 1A08014218780C1D00E62F93 /* effect1.raw in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196B1875DF2A00930C57 /* effect1.raw */; }; 1A08014318780C1D00E62F93 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196C1875DF2A00930C57 /* effect1.wav */; }; 1A08014418780C1D00E62F93 /* effect2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196D1875DF2A00930C57 /* effect2.ogg */; }; 1A08014518780C1D00E62F93 /* fileLookup.plist in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196F1875DF2A00930C57 /* fileLookup.plist */; }; 1A08014618780C1D00E62F93 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 37C819711875DF2A00930C57 /* fps_images.png */; }; 1A08014718780C1D00E62F93 /* Hello.png in Resources */ = {isa = PBXBuildFile; fileRef = 37C819731875DF2A00930C57 /* Hello.png */; }; 1A08014818780C1D00E62F93 /* music.mid in Resources */ = {isa = PBXBuildFile; fileRef = 37C819781875DF2B00930C57 /* music.mid */; }; 1A08014918780C1D00E62F93 /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197A1875DF2B00930C57 /* pew-pew-lei.wav */; }; 1A087AEE1860418300196EF5 /* PerformanceLabelTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A087AEC1860418300196EF5 /* PerformanceLabelTest.cpp */; }; 1A087AEF1860418300196EF5 /* PerformanceLabelTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A087AEC1860418300196EF5 /* PerformanceLabelTest.cpp */; }; 1A1197CB1785363400D62A44 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; 1A1197CC1785363400D62A44 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; 1A1197CD1785363400D62A44 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; 1A1197CE1785363400D62A44 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; 1A1197CF1785363400D62A44 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; 1A1197D01785363400D62A44 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; 1A1197D11785363400D62A44 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; 1A1197D21785363400D62A44 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; 1A1197D31785363400D62A44 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; 1A119864178538E400D62A44 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; 1A119865178538E400D62A44 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; 1A119866178538E400D62A44 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; 1A119867178538E400D62A44 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; 1A119868178538E400D62A44 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; 1A119869178538E400D62A44 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; 1A11986A178538E400D62A44 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; 1A11986B178538E400D62A44 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; 1A11986C178538E400D62A44 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; 1A2F51B01877DA5900B48BFE /* tests in Resources */ = {isa = PBXBuildFile; fileRef = 1A2F51AF1877DA5900B48BFE /* tests */; }; 1A2F51B11877DA5900B48BFE /* tests in Resources */ = {isa = PBXBuildFile; fileRef = 1A2F51AF1877DA5900B48BFE /* tests */; }; 1A3B1DB3180E7C4700497A22 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1DB1180E7C4700497A22 /* AppDelegate.cpp */; }; 1A3B1DB4180E7C4700497A22 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1DB1180E7C4700497A22 /* AppDelegate.cpp */; }; 1A3B1DCA180E7C5100497A22 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1DB7180E7C5100497A22 /* AppController.mm */; }; 1A3B1DCB180E7C5100497A22 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DB8180E7C5100497A22 /* Default-568h@2x.png */; }; 1A3B1DCC180E7C5100497A22 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DB9180E7C5100497A22 /* Default.png */; }; 1A3B1DCD180E7C5100497A22 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DBA180E7C5100497A22 /* Default@2x.png */; }; 1A3B1DCE180E7C5100497A22 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DBB180E7C5100497A22 /* Icon-120.png */; }; 1A3B1DCF180E7C5100497A22 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DBC180E7C5100497A22 /* Icon-144.png */; }; 1A3B1DD0180E7C5100497A22 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DBD180E7C5100497A22 /* Icon-152.png */; }; 1A3B1DD1180E7C5100497A22 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DBE180E7C5100497A22 /* Icon-72.png */; }; 1A3B1DD2180E7C5100497A22 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DBF180E7C5100497A22 /* Icon-76.png */; }; 1A3B1DD3180E7C5100497A22 /* Icon-Small-50.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DC0180E7C5100497A22 /* Icon-Small-50.png */; }; 1A3B1DD4180E7C5100497A22 /* Icon-Small.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DC1180E7C5100497A22 /* Icon-Small.png */; }; 1A3B1DD5180E7C5100497A22 /* Icon-Small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DC2180E7C5100497A22 /* Icon-Small@2x.png */; }; 1A3B1DD6180E7C5100497A22 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DC3180E7C5100497A22 /* Icon.png */; }; 1A3B1DD7180E7C5100497A22 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DC4180E7C5100497A22 /* Icon@2x.png */; }; 1A3B1DD9180E7C5100497A22 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1DC6180E7C5100497A22 /* main.m */; }; 1A3B1DDA180E7C5100497A22 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1DC9180E7C5100497A22 /* RootViewController.mm */; }; 1A3B1DE3180E7C5C00497A22 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DDC180E7C5C00497A22 /* InfoPlist.strings */; }; 1A3B1DE4180E7C5C00497A22 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DDE180E7C5C00497A22 /* MainMenu.xib */; }; 1A3B1DE5180E7C5C00497A22 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DE0180E7C5C00497A22 /* Icon.icns */; }; 1A3B1DE6180E7C5C00497A22 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DE1180E7C5C00497A22 /* Info.plist */; }; 1A3B1DE7180E7C5C00497A22 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1DE2180E7C5C00497A22 /* main.cpp */; }; 1A3B1DF2180E7CAF00497A22 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; }; 1A3B1DF3180E7CAF00497A22 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 1A3B1DF4180E7CAF00497A22 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */; }; 1A3B1DF5180E7CAF00497A22 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 1A3B1DF6180E7CAF00497A22 /* libjsbindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBA1807A4F9005B8026 /* libjsbindings Mac.a */; }; 1A3B1DFD180E7D2200497A22 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DF9180E7D2200497A22 /* res */; }; 1A3B1DFE180E7D2200497A22 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DF9180E7D2200497A22 /* res */; }; 1A3B1DFF180E7D2200497A22 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DFA180E7D2200497A22 /* src */; }; 1A3B1E00180E7D2200497A22 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DFA180E7D2200497A22 /* src */; }; 1A3B1E01180E7D3900497A22 /* MoonWarriors-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DF8180E7D2200497A22 /* MoonWarriors-jsb.js */; }; 1A3B1E02180E7D4B00497A22 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A3B1E03180E7D4B00497A22 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A3B1E04180E7D4C00497A22 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A3B1E05180E7D4C00497A22 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A3B1E06180E7D5000497A22 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A3B1E07180E7D5100497A22 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A3B1E08180E7D5100497A22 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A3B1E09180E7D5200497A22 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A3B1E14180E7E2700497A22 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */; }; 1A3B1E15180E7E2700497A22 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 1A3B1E16180E7E2700497A22 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */; }; 1A3B1E17180E7E2700497A22 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 1A3B1E18180E7E2700497A22 /* libjsbindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC81807A4F9005B8026 /* libjsbindings iOS.a */; }; 1A3B1E19180E7E4E00497A22 /* MoonWarriors-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1DF8180E7D2200497A22 /* MoonWarriors-jsb.js */; }; 1A3B1E26180E7EFA00497A22 /* boot-html5.js in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1C180E7EFA00497A22 /* boot-html5.js */; }; 1A3B1E28180E7EFA00497A22 /* boot-jsb.js in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1D180E7EFA00497A22 /* boot-jsb.js */; }; 1A3B1E2A180E7EFA00497A22 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1E180E7EFA00497A22 /* index.html */; }; 1A3B1E2B180E7EFA00497A22 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1E180E7EFA00497A22 /* index.html */; }; 1A3B1E2C180E7EFA00497A22 /* levels.js in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1F180E7EFA00497A22 /* levels.js */; }; 1A3B1E2E180E7EFA00497A22 /* main.js in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E20180E7EFA00497A22 /* main.js */; }; 1A3B1E30180E7EFA00497A22 /* Platform in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E21180E7EFA00497A22 /* Platform */; }; 1A3B1E31180E7EFA00497A22 /* Platform in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E21180E7EFA00497A22 /* Platform */; }; 1A3B1E32180E7EFA00497A22 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E22180E7EFA00497A22 /* res */; }; 1A3B1E33180E7EFA00497A22 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E22180E7EFA00497A22 /* res */; }; 1A3B1E34180E7EFA00497A22 /* resources-html5.js in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E23180E7EFA00497A22 /* resources-html5.js */; }; 1A3B1E36180E7EFA00497A22 /* resources-jsb.js in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E24180E7EFA00497A22 /* resources-jsb.js */; }; 1A3B1E38180E7EFA00497A22 /* watermelon_with_me.js in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E25180E7EFA00497A22 /* watermelon_with_me.js */; }; 1A3B1E40180E7F1500497A22 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E3E180E7F1500497A22 /* AppDelegate.cpp */; }; 1A3B1E41180E7F1500497A22 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E3E180E7F1500497A22 /* AppDelegate.cpp */; }; 1A3B1E54180E7F1E00497A22 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E44180E7F1E00497A22 /* AppController.mm */; }; 1A3B1E55180E7F1E00497A22 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E45180E7F1E00497A22 /* Default-568h@2x.png */; }; 1A3B1E56180E7F1E00497A22 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E46180E7F1E00497A22 /* Default.png */; }; 1A3B1E57180E7F1E00497A22 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E47180E7F1E00497A22 /* Default@2x.png */; }; 1A3B1E58180E7F1E00497A22 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E48180E7F1E00497A22 /* Icon-114.png */; }; 1A3B1E59180E7F1E00497A22 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E49180E7F1E00497A22 /* Icon-120.png */; }; 1A3B1E5A180E7F1E00497A22 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E4A180E7F1E00497A22 /* Icon-144.png */; }; 1A3B1E5B180E7F1E00497A22 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E4B180E7F1E00497A22 /* Icon-152.png */; }; 1A3B1E5C180E7F1E00497A22 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E4C180E7F1E00497A22 /* Icon-57.png */; }; 1A3B1E5D180E7F1E00497A22 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E4D180E7F1E00497A22 /* Icon-72.png */; }; 1A3B1E5E180E7F1E00497A22 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E4E180E7F1E00497A22 /* Icon-76.png */; }; 1A3B1E60180E7F1E00497A22 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E50180E7F1E00497A22 /* main.m */; }; 1A3B1E61180E7F1E00497A22 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E53180E7F1E00497A22 /* RootViewController.mm */; }; 1A3B1E6A180E7F2400497A22 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E63180E7F2400497A22 /* InfoPlist.strings */; }; 1A3B1E6B180E7F2400497A22 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E65180E7F2400497A22 /* MainMenu.xib */; }; 1A3B1E6C180E7F2400497A22 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E67180E7F2400497A22 /* Icon.icns */; }; 1A3B1E6E180E7F2400497A22 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E69180E7F2400497A22 /* main.cpp */; }; 1A3B1E79180E7F6B00497A22 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; }; 1A3B1E7A180E7F6B00497A22 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 1A3B1E7B180E7F6B00497A22 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */; }; 1A3B1E7C180E7F6B00497A22 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 1A3B1E7D180E7F6B00497A22 /* libjsbindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBA1807A4F9005B8026 /* libjsbindings Mac.a */; }; 1A3B1E7E180E7FBB00497A22 /* boot-html5.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1C180E7EFA00497A22 /* boot-html5.js */; }; 1A3B1E7F180E7FBB00497A22 /* boot-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1D180E7EFA00497A22 /* boot-jsb.js */; }; 1A3B1E80180E7FBB00497A22 /* levels.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1F180E7EFA00497A22 /* levels.js */; }; 1A3B1E81180E7FBB00497A22 /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E20180E7EFA00497A22 /* main.js */; }; 1A3B1E82180E7FBB00497A22 /* resources-html5.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E23180E7EFA00497A22 /* resources-html5.js */; }; 1A3B1E83180E7FBB00497A22 /* resources-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E24180E7EFA00497A22 /* resources-jsb.js */; }; 1A3B1E84180E7FBB00497A22 /* watermelon_with_me.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E25180E7EFA00497A22 /* watermelon_with_me.js */; }; 1A3B1E8F180E804F00497A22 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */; }; 1A3B1E90180E804F00497A22 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 1A3B1E91180E804F00497A22 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */; }; 1A3B1E92180E804F00497A22 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 1A3B1E93180E804F00497A22 /* libjsbindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC81807A4F9005B8026 /* libjsbindings iOS.a */; }; 1A3B1E94180E807600497A22 /* boot-html5.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1C180E7EFA00497A22 /* boot-html5.js */; }; 1A3B1E95180E807600497A22 /* boot-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1D180E7EFA00497A22 /* boot-jsb.js */; }; 1A3B1E96180E807600497A22 /* levels.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E1F180E7EFA00497A22 /* levels.js */; }; 1A3B1E97180E807600497A22 /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E20180E7EFA00497A22 /* main.js */; }; 1A3B1E98180E807600497A22 /* resources-html5.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E23180E7EFA00497A22 /* resources-html5.js */; }; 1A3B1E99180E807600497A22 /* resources-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E24180E7EFA00497A22 /* resources-jsb.js */; }; 1A3B1E9A180E807600497A22 /* watermelon_with_me.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1E25180E7EFA00497A22 /* watermelon_with_me.js */; }; 1A3B1E9F180E80B600497A22 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E9D180E80B600497A22 /* AppDelegate.cpp */; }; 1A3B1EA0180E80B600497A22 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1E9D180E80B600497A22 /* AppDelegate.cpp */; }; 1A3B1EB3180E80BD00497A22 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1EA3180E80BD00497A22 /* AppController.mm */; }; 1A3B1EB4180E80BD00497A22 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EA4180E80BD00497A22 /* Default-568h@2x.png */; }; 1A3B1EB5180E80BD00497A22 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EA5180E80BD00497A22 /* Default.png */; }; 1A3B1EB6180E80BD00497A22 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EA6180E80BD00497A22 /* Default@2x.png */; }; 1A3B1EB7180E80BD00497A22 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EA7180E80BD00497A22 /* Icon-114.png */; }; 1A3B1EB8180E80BD00497A22 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EA8180E80BD00497A22 /* Icon-120.png */; }; 1A3B1EB9180E80BD00497A22 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EA9180E80BD00497A22 /* Icon-144.png */; }; 1A3B1EBA180E80BD00497A22 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EAA180E80BD00497A22 /* Icon-152.png */; }; 1A3B1EBB180E80BD00497A22 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EAB180E80BD00497A22 /* Icon-57.png */; }; 1A3B1EBC180E80BD00497A22 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EAC180E80BD00497A22 /* Icon-72.png */; }; 1A3B1EBD180E80BD00497A22 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EAD180E80BD00497A22 /* Icon-76.png */; }; 1A3B1EBF180E80BD00497A22 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1EAF180E80BD00497A22 /* main.m */; }; 1A3B1EC0180E80BD00497A22 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1EB2180E80BD00497A22 /* RootViewController.mm */; }; 1A3B1EC9180E80C700497A22 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EC2180E80C700497A22 /* InfoPlist.strings */; }; 1A3B1ECA180E80C700497A22 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EC4180E80C700497A22 /* MainMenu.xib */; }; 1A3B1ECB180E80C700497A22 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EC6180E80C700497A22 /* Icon.icns */; }; 1A3B1ECD180E80C700497A22 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1EC8180E80C700497A22 /* main.cpp */; }; 1A3B1ED0180E80E200497A22 /* Published files iOS in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1ECF180E80E200497A22 /* Published files iOS */; }; 1A3B1ED1180E80E200497A22 /* Published files iOS in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1ECF180E80E200497A22 /* Published files iOS */; }; 1A3B1EDC180E811D00497A22 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; }; 1A3B1EDD180E811D00497A22 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 1A3B1EDE180E811D00497A22 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */; }; 1A3B1EDF180E811D00497A22 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 1A3B1EE0180E811D00497A22 /* libjsbindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBA1807A4F9005B8026 /* libjsbindings Mac.a */; }; 1A3B1EEB180E81B500497A22 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */; }; 1A3B1EEC180E81B500497A22 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 1A3B1EED180E81B500497A22 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */; }; 1A3B1EEE180E81B500497A22 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 1A3B1EEF180E81B500497A22 /* libjsbindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC81807A4F9005B8026 /* libjsbindings iOS.a */; }; 1A3B1EF3180E826E00497A22 /* Published-iOS in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EF2180E826E00497A22 /* Published-iOS */; }; 1A3B1EF4180E826E00497A22 /* Published-iOS in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1EF2180E826E00497A22 /* Published-iOS */; }; 1A3B1EFB180E828300497A22 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1EF9180E828300497A22 /* AppDelegate.cpp */; }; 1A3B1EFC180E828300497A22 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1EF9180E828300497A22 /* AppDelegate.cpp */; }; 1A3B1F0F180E828E00497A22 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1EFF180E828E00497A22 /* AppController.mm */; }; 1A3B1F10180E828E00497A22 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F00180E828E00497A22 /* Default-568h@2x.png */; }; 1A3B1F11180E828E00497A22 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F01180E828E00497A22 /* Default.png */; }; 1A3B1F12180E828E00497A22 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F02180E828E00497A22 /* Default@2x.png */; }; 1A3B1F13180E828E00497A22 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F03180E828E00497A22 /* Icon-114.png */; }; 1A3B1F14180E828E00497A22 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F04180E828E00497A22 /* Icon-120.png */; }; 1A3B1F15180E828E00497A22 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F05180E828E00497A22 /* Icon-144.png */; }; 1A3B1F16180E828E00497A22 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F06180E828E00497A22 /* Icon-152.png */; }; 1A3B1F17180E828E00497A22 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F07180E828E00497A22 /* Icon-57.png */; }; 1A3B1F18180E828E00497A22 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F08180E828E00497A22 /* Icon-72.png */; }; 1A3B1F19180E828E00497A22 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F09180E828E00497A22 /* Icon-76.png */; }; 1A3B1F1B180E828E00497A22 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F0B180E828E00497A22 /* main.m */; }; 1A3B1F1C180E828E00497A22 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F0E180E828E00497A22 /* RootViewController.mm */; }; 1A3B1F25180E829600497A22 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F1E180E829600497A22 /* InfoPlist.strings */; }; 1A3B1F26180E829600497A22 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F20180E829600497A22 /* MainMenu.xib */; }; 1A3B1F27180E829600497A22 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1A3B1F22180E829600497A22 /* Icon.icns */; }; 1A3B1F29180E829600497A22 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3B1F24180E829600497A22 /* main.cpp */; }; 1A3B1F34180E82C800497A22 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; }; 1A3B1F35180E82C800497A22 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 1A3B1F36180E82C800497A22 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */; }; 1A3B1F37180E82C800497A22 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 1A3B1F38180E82C800497A22 /* libjsbindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBA1807A4F9005B8026 /* libjsbindings Mac.a */; }; 1A3B1F43180E82DC00497A22 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */; }; 1A3B1F44180E82DC00497A22 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 1A3B1F45180E82DC00497A22 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */; }; 1A3B1F46180E82DC00497A22 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 1A3B1F47180E82DC00497A22 /* libjsbindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC81807A4F9005B8026 /* libjsbindings iOS.a */; }; 1A514AFE180FB6470053B876 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 46A174CC1807D934005B8026 /* Icon.icns */; }; 1A514B01180FB66F0053B876 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174AE1807D934005B8026 /* Default.png */; }; 1A514B02180FB6730053B876 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174AF1807D934005B8026 /* Default@2x.png */; }; 1A514B03180FB6780053B876 /* Icon-100.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174B21807D934005B8026 /* Icon-100.png */; }; 1A514B04180FB67C0053B876 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174B31807D934005B8026 /* Icon-114.png */; }; 1A514B05180FB67C0053B876 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174B41807D934005B8026 /* Icon-120.png */; }; 1A514B06180FB67C0053B876 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174B51807D934005B8026 /* Icon-144.png */; }; 1A514B07180FB67C0053B876 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174B61807D934005B8026 /* Icon-152.png */; }; 1A514B08180FB67C0053B876 /* Icon-40.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174B71807D934005B8026 /* Icon-40.png */; }; 1A514B09180FB67C0053B876 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174B81807D934005B8026 /* Icon-57.png */; }; 1A514B0A180FB67C0053B876 /* Icon-58.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174B91807D934005B8026 /* Icon-58.png */; }; 1A514B0B180FB67C0053B876 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174BA1807D934005B8026 /* Icon-72.png */; }; 1A514B0C180FB67C0053B876 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174BB1807D934005B8026 /* Icon-76.png */; }; 1A514B0D180FB67C0053B876 /* Icon-80.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174BC1807D934005B8026 /* Icon-80.png */; }; 1A514B0E180FB6A30053B876 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45301807E712000CDD6D /* Default.png */; }; 1A514B0F180FB6A30053B876 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45311807E712000CDD6D /* Default@2x.png */; }; 1A514B10180FB6A30053B876 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45321807E712000CDD6D /* Icon-114.png */; }; 1A514B11180FB6A30053B876 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45331807E712000CDD6D /* Icon-120.png */; }; 1A514B12180FB6A30053B876 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45341807E712000CDD6D /* Icon-144.png */; }; 1A514B13180FB6A30053B876 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45351807E712000CDD6D /* Icon-152.png */; }; 1A514B14180FB6A30053B876 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45361807E712000CDD6D /* Icon-57.png */; }; 1A514B15180FB6A30053B876 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45371807E712000CDD6D /* Icon-72.png */; }; 1A514B16180FB6A30053B876 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E45381807E712000CDD6D /* Icon-76.png */; }; 1A6A41E5180BE41100565AC2 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6A41DF180BE41100565AC2 /* AppDelegate.cpp */; }; 1A6A41E6180BE41100565AC2 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6A41DF180BE41100565AC2 /* AppDelegate.cpp */; }; 1A6A41E7180BE41100565AC2 /* GameOverScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6A41E1180BE41100565AC2 /* GameOverScene.cpp */; }; 1A6A41E8180BE41100565AC2 /* GameOverScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6A41E1180BE41100565AC2 /* GameOverScene.cpp */; }; 1A6A41E9180BE41100565AC2 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6A41E3180BE41100565AC2 /* HelloWorldScene.cpp */; }; 1A6A41EA180BE41100565AC2 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6A41E3180BE41100565AC2 /* HelloWorldScene.cpp */; }; 1A6FB5951785523D00CDF010 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; 1A6FB5961785524600CDF010 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; 1A6FB5971785524D00CDF010 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; 1A6FB5981785525300CDF010 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; 1A6FB5991785526500CDF010 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; 1A6FB59A1785526C00CDF010 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; 1A6FB59B1785527300CDF010 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; 1A6FB59C1785528700CDF010 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; 1A6FB59D1785528E00CDF010 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; 1A6FB7A71785614200CDF010 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; 1A6FB7A81785614200CDF010 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; 1A6FB7A91785614200CDF010 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; 1A6FB7AA1785614200CDF010 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; 1A6FB7AB1785614200CDF010 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; 1A6FB7AC1785614200CDF010 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; 1A6FB7AD1785614200CDF010 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; 1A6FB7AE1785614200CDF010 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; 1A6FB7AF1785614200CDF010 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; 1A80519718768FD300C117B5 /* UnitTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A80519518768FD300C117B5 /* UnitTest.cpp */; }; 1A80519818768FD300C117B5 /* UnitTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A80519518768FD300C117B5 /* UnitTest.cpp */; }; 1A8C5532180E8B1C00EF57C3 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5530180E8B1C00EF57C3 /* AppDelegate.cpp */; }; 1A8C5533180E8B1C00EF57C3 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5530180E8B1C00EF57C3 /* AppDelegate.cpp */; }; 1A8C554A180E8B3D00EF57C3 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C553A180E8B3D00EF57C3 /* AppController.mm */; }; 1A8C554B180E8B3D00EF57C3 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C553B180E8B3D00EF57C3 /* Default-568h@2x.png */; }; 1A8C554C180E8B3D00EF57C3 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C553C180E8B3D00EF57C3 /* Default.png */; }; 1A8C554D180E8B3D00EF57C3 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C553D180E8B3D00EF57C3 /* Default@2x.png */; }; 1A8C554E180E8B3D00EF57C3 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C553F180E8B3D00EF57C3 /* Icon-114.png */; }; 1A8C554F180E8B3D00EF57C3 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5540180E8B3D00EF57C3 /* Icon-120.png */; }; 1A8C5550180E8B3D00EF57C3 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5541180E8B3D00EF57C3 /* Icon-144.png */; }; 1A8C5551180E8B3D00EF57C3 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5542180E8B3D00EF57C3 /* Icon-152.png */; }; 1A8C5552180E8B3D00EF57C3 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5543180E8B3D00EF57C3 /* Icon-57.png */; }; 1A8C5553180E8B3D00EF57C3 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5544180E8B3D00EF57C3 /* Icon-72.png */; }; 1A8C5554180E8B3D00EF57C3 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5545180E8B3D00EF57C3 /* Icon-76.png */; }; 1A8C5556180E8B3D00EF57C3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5547180E8B3D00EF57C3 /* main.m */; }; 1A8C5557180E8B3D00EF57C3 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5549180E8B3D00EF57C3 /* RootViewController.mm */; }; 1A8C5561180E8B4500EF57C3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5559180E8B4500EF57C3 /* InfoPlist.strings */; }; 1A8C5562180E8B4500EF57C3 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C555B180E8B4500EF57C3 /* MainMenu.xib */; }; 1A8C5563180E8B4500EF57C3 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C555E180E8B4500EF57C3 /* Icon.icns */; }; 1A8C5565180E8B4500EF57C3 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5560180E8B4500EF57C3 /* main.cpp */; }; 1A8C557B180E8B5100EF57C3 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5569180E8B5100EF57C3 /* background.mp3 */; }; 1A8C557C180E8B5100EF57C3 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5569180E8B5100EF57C3 /* background.mp3 */; }; 1A8C557D180E8B5100EF57C3 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556A180E8B5100EF57C3 /* background.ogg */; }; 1A8C557E180E8B5100EF57C3 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556A180E8B5100EF57C3 /* background.ogg */; }; 1A8C557F180E8B5100EF57C3 /* crop.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556B180E8B5100EF57C3 /* crop.png */; }; 1A8C5580180E8B5100EF57C3 /* crop.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556B180E8B5100EF57C3 /* crop.png */; }; 1A8C5583180E8B5100EF57C3 /* dog.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556D180E8B5100EF57C3 /* dog.png */; }; 1A8C5584180E8B5100EF57C3 /* dog.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556D180E8B5100EF57C3 /* dog.png */; }; 1A8C5585180E8B5100EF57C3 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556E180E8B5100EF57C3 /* effect1.wav */; }; 1A8C5586180E8B5100EF57C3 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556E180E8B5100EF57C3 /* effect1.wav */; }; 1A8C5587180E8B5100EF57C3 /* farm.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556F180E8B5100EF57C3 /* farm.jpg */; }; 1A8C5588180E8B5100EF57C3 /* farm.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C556F180E8B5100EF57C3 /* farm.jpg */; }; 1A8C5589180E8B5100EF57C3 /* Marker Felt.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5571180E8B5100EF57C3 /* Marker Felt.ttf */; }; 1A8C558A180E8B5100EF57C3 /* Marker Felt.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5571180E8B5100EF57C3 /* Marker Felt.ttf */; }; 1A8C558B180E8B5100EF57C3 /* hello.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5572180E8B5100EF57C3 /* hello.lua */; }; 1A8C558C180E8B5100EF57C3 /* hello.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5572180E8B5100EF57C3 /* hello.lua */; }; 1A8C558D180E8B5100EF57C3 /* hello2.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5573180E8B5100EF57C3 /* hello2.lua */; }; 1A8C558E180E8B5100EF57C3 /* hello2.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5573180E8B5100EF57C3 /* hello2.lua */; }; 1A8C558F180E8B5100EF57C3 /* land.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5574180E8B5100EF57C3 /* land.png */; }; 1A8C5590180E8B5100EF57C3 /* land.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5574180E8B5100EF57C3 /* land.png */; }; 1A8C5591180E8B5100EF57C3 /* menu1.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5575180E8B5100EF57C3 /* menu1.png */; }; 1A8C5592180E8B5100EF57C3 /* menu1.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5575180E8B5100EF57C3 /* menu1.png */; }; 1A8C5593180E8B5100EF57C3 /* menu2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5576180E8B5100EF57C3 /* menu2.png */; }; 1A8C5594180E8B5100EF57C3 /* menu2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5576180E8B5100EF57C3 /* menu2.png */; }; 1A8C55A2180E8B8400EF57C3 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5596180E8B8400EF57C3 /* AudioEngine.lua */; }; 1A8C55A3180E8B8400EF57C3 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5596180E8B8400EF57C3 /* AudioEngine.lua */; }; 1A8C55A4180E8B8400EF57C3 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5597180E8B8400EF57C3 /* CCBReaderLoad.lua */; }; 1A8C55A5180E8B8400EF57C3 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5597180E8B8400EF57C3 /* CCBReaderLoad.lua */; }; 1A8C55A6180E8B8400EF57C3 /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5598180E8B8400EF57C3 /* Cocos2d.lua */; }; 1A8C55A7180E8B8400EF57C3 /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5598180E8B8400EF57C3 /* Cocos2d.lua */; }; 1A8C55A8180E8B8400EF57C3 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5599180E8B8400EF57C3 /* Cocos2dConstants.lua */; }; 1A8C55A9180E8B8400EF57C3 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C5599180E8B8400EF57C3 /* Cocos2dConstants.lua */; }; 1A8C55AA180E8B8400EF57C3 /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559A180E8B8400EF57C3 /* Deprecated.lua */; }; 1A8C55AB180E8B8400EF57C3 /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559A180E8B8400EF57C3 /* Deprecated.lua */; }; 1A8C55AC180E8B8400EF57C3 /* DeprecatedClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559B180E8B8400EF57C3 /* DeprecatedClass.lua */; }; 1A8C55AD180E8B8400EF57C3 /* DeprecatedClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559B180E8B8400EF57C3 /* DeprecatedClass.lua */; }; 1A8C55AE180E8B8400EF57C3 /* DeprecatedEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559C180E8B8400EF57C3 /* DeprecatedEnum.lua */; }; 1A8C55AF180E8B8400EF57C3 /* DeprecatedEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559C180E8B8400EF57C3 /* DeprecatedEnum.lua */; }; 1A8C55B0180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559D180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua */; }; 1A8C55B1180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559D180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua */; }; 1A8C55B2180E8B8400EF57C3 /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559E180E8B8400EF57C3 /* DrawPrimitives.lua */; }; 1A8C55B3180E8B8400EF57C3 /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559E180E8B8400EF57C3 /* DrawPrimitives.lua */; }; 1A8C55B4180E8B8400EF57C3 /* luaj.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559F180E8B8400EF57C3 /* luaj.lua */; }; 1A8C55B5180E8B8400EF57C3 /* luaj.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C559F180E8B8400EF57C3 /* luaj.lua */; }; 1A8C55B6180E8B8400EF57C3 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C55A0180E8B8400EF57C3 /* Opengl.lua */; }; 1A8C55B7180E8B8400EF57C3 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C55A0180E8B8400EF57C3 /* Opengl.lua */; }; 1A8C55B8180E8B8400EF57C3 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C55A1180E8B8400EF57C3 /* OpenglConstants.lua */; }; 1A8C55B9180E8B8400EF57C3 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A8C55A1180E8B8400EF57C3 /* OpenglConstants.lua */; }; 1A8C55C4180E8BBB00EF57C3 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; }; 1A8C55C5180E8BBB00EF57C3 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 1A8C55C6180E8BBB00EF57C3 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */; }; 1A8C55C7180E8BBB00EF57C3 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 1A8C55C8180E8BBB00EF57C3 /* libluabindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBC1807A4F9005B8026 /* libluabindings Mac.a */; }; 1A8C5666180E8E0700EF57C3 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */; }; 1A8C5667180E8E0700EF57C3 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 1A8C5668180E8E0700EF57C3 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */; }; 1A8C5669180E8E0700EF57C3 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 1A8C566A180E8E0700EF57C3 /* libluabindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FCA1807A4F9005B8026 /* libluabindings iOS.a */; }; 1A8C566F180E8E9600EF57C3 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C566D180E8E9600EF57C3 /* AppDelegate.cpp */; }; 1A8C5670180E8E9600EF57C3 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C566D180E8E9600EF57C3 /* AppDelegate.cpp */; }; 1A8C5864180E8F0100EF57C3 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5854180E8F0100EF57C3 /* AppController.mm */; }; 1A8C5870180E8F0100EF57C3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5860180E8F0100EF57C3 /* main.m */; }; 1A8C5871180E8F0100EF57C3 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5862180E8F0100EF57C3 /* RootViewController.mm */; }; 1A8C587F180E8F0C00EF57C3 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5879180E8F0C00EF57C3 /* main.cpp */; }; 1A8C588A180E8F7600EF57C3 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; }; 1A8C588B180E8F7600EF57C3 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 1A8C588C180E8F7600EF57C3 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */; }; 1A8C588D180E8F7600EF57C3 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 1A8C588E180E8F7600EF57C3 /* libluabindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBC1807A4F9005B8026 /* libluabindings Mac.a */; }; 1A8C5899180E8F8F00EF57C3 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */; }; 1A8C589A180E8F8F00EF57C3 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 1A8C589B180E8F8F00EF57C3 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */; }; 1A8C589C180E8F8F00EF57C3 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 1A8C589D180E8F8F00EF57C3 /* libluabindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FCA1807A4F9005B8026 /* libluabindings iOS.a */; }; 1A9141A1180BEB6A00CFC31F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A91419A180BEB6A00CFC31F /* InfoPlist.strings */; }; 1A9141A2180BEB6A00CFC31F /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A91419C180BEB6A00CFC31F /* MainMenu.xib */; }; 1A9141A3180BEB6A00CFC31F /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1A91419E180BEB6A00CFC31F /* Icon.icns */; }; 1A9141A4180BEB6A00CFC31F /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A91419F180BEB6A00CFC31F /* main.cpp */; }; 1A9DC2A3180E65D4007A3AD4 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC2A1180E65D4007A3AD4 /* AppDelegate.cpp */; }; 1A9DC2A4180E65D4007A3AD4 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC2A1180E65D4007A3AD4 /* AppDelegate.cpp */; }; 1A9DC2B3180E6681007A3AD4 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC2AC180E6681007A3AD4 /* main.cpp */; }; 1A9DC2C8180E668B007A3AD4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC2B7180E668B007A3AD4 /* AppController.mm */; }; 1A9DC2D5180E668B007A3AD4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC2C4180E668B007A3AD4 /* main.m */; }; 1A9DC2D6180E668B007A3AD4 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9DC2C7180E668B007A3AD4 /* RootViewController.mm */; }; 1A9DC9E5180E6742007A3AD4 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A9DC9E6180E6742007A3AD4 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 1A9DC9E4180E6742007A3AD4 /* script */; }; 1A9DC9F1180E68D8007A3AD4 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; }; 1A9DC9F2180E68D8007A3AD4 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 1A9DC9F3180E68D8007A3AD4 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */; }; 1A9DC9F4180E68D8007A3AD4 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 1A9DC9F5180E68D8007A3AD4 /* libjsbindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBA1807A4F9005B8026 /* libjsbindings Mac.a */; }; 1A9DCA60180E7453007A3AD4 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */; }; 1A9DCA61180E7453007A3AD4 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 1A9DCA62180E7453007A3AD4 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */; }; 1A9DCA63180E7453007A3AD4 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 1A9DCA64180E7453007A3AD4 /* libjsbindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC81807A4F9005B8026 /* libjsbindings iOS.a */; }; 1A9F808D177E98A600D9A1CB /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; 1AAF514A180E2C1A000584C8 /* AccelerometerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FA7180E2C17000584C8 /* AccelerometerTest.cpp */; }; 1AAF514B180E2C1A000584C8 /* AccelerometerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FA7180E2C17000584C8 /* AccelerometerTest.cpp */; }; 1AAF514C180E2C1A000584C8 /* ActionManagerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FAA180E2C17000584C8 /* ActionManagerTest.cpp */; }; 1AAF514D180E2C1A000584C8 /* ActionManagerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FAA180E2C17000584C8 /* ActionManagerTest.cpp */; }; 1AAF514E180E2C1A000584C8 /* ActionsEaseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FAD180E2C17000584C8 /* ActionsEaseTest.cpp */; }; 1AAF514F180E2C1A000584C8 /* ActionsEaseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FAD180E2C17000584C8 /* ActionsEaseTest.cpp */; }; 1AAF5150180E2C1A000584C8 /* ActionsProgressTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FB0180E2C17000584C8 /* ActionsProgressTest.cpp */; }; 1AAF5151180E2C1A000584C8 /* ActionsProgressTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FB0180E2C17000584C8 /* ActionsProgressTest.cpp */; }; 1AAF5152180E2C1A000584C8 /* ActionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FB3180E2C17000584C8 /* ActionsTest.cpp */; }; 1AAF5153180E2C1A000584C8 /* ActionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FB3180E2C17000584C8 /* ActionsTest.cpp */; }; 1AAF5154180E2C1A000584C8 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FB5180E2C17000584C8 /* AppDelegate.cpp */; }; 1AAF5155180E2C1A000584C8 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FB5180E2C17000584C8 /* AppDelegate.cpp */; }; 1AAF5156180E2C1A000584C8 /* BaseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FB7180E2C17000584C8 /* BaseTest.cpp */; }; 1AAF5157180E2C1A000584C8 /* BaseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FB7180E2C17000584C8 /* BaseTest.cpp */; }; 1AAF5158180E2C1A000584C8 /* Box2dTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FBA180E2C17000584C8 /* Box2dTest.cpp */; }; 1AAF5159180E2C1A000584C8 /* Box2dTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FBA180E2C17000584C8 /* Box2dTest.cpp */; }; 1AAF515A180E2C1A000584C8 /* Box2dView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FBD180E2C17000584C8 /* Box2dView.cpp */; }; 1AAF515B180E2C1A000584C8 /* Box2dView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FBD180E2C17000584C8 /* Box2dView.cpp */; }; 1AAF515C180E2C1A000584C8 /* GLES-Render.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FBF180E2C17000584C8 /* GLES-Render.cpp */; }; 1AAF515D180E2C1A000584C8 /* GLES-Render.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FBF180E2C17000584C8 /* GLES-Render.cpp */; }; 1AAF515E180E2C1A000584C8 /* Test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FC1180E2C17000584C8 /* Test.cpp */; }; 1AAF515F180E2C1A000584C8 /* Test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FC1180E2C17000584C8 /* Test.cpp */; }; 1AAF5160180E2C1A000584C8 /* TestEntries.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FC3180E2C17000584C8 /* TestEntries.cpp */; }; 1AAF5161180E2C1A000584C8 /* TestEntries.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FC3180E2C17000584C8 /* TestEntries.cpp */; }; 1AAF5162180E2C1A000584C8 /* Bug-1159.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FF3180E2C17000584C8 /* Bug-1159.cpp */; }; 1AAF5163180E2C1A000584C8 /* Bug-1159.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FF3180E2C17000584C8 /* Bug-1159.cpp */; }; 1AAF5164180E2C1A000584C8 /* Bug-1174.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FF5180E2C17000584C8 /* Bug-1174.cpp */; }; 1AAF5165180E2C1A000584C8 /* Bug-1174.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FF5180E2C17000584C8 /* Bug-1174.cpp */; }; 1AAF5166180E2C1A000584C8 /* Bug-350.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FF7180E2C17000584C8 /* Bug-350.cpp */; }; 1AAF5167180E2C1A000584C8 /* Bug-350.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FF7180E2C17000584C8 /* Bug-350.cpp */; }; 1AAF5168180E2C1A000584C8 /* Bug-422.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FF9180E2C17000584C8 /* Bug-422.cpp */; }; 1AAF5169180E2C1A000584C8 /* Bug-422.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FF9180E2C17000584C8 /* Bug-422.cpp */; }; 1AAF516A180E2C1A000584C8 /* Bug-458.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FFC180E2C17000584C8 /* Bug-458.cpp */; }; 1AAF516B180E2C1A000584C8 /* Bug-458.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FFC180E2C17000584C8 /* Bug-458.cpp */; }; 1AAF516C180E2C1A000584C8 /* QuestionContainerSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FFE180E2C17000584C8 /* QuestionContainerSprite.cpp */; }; 1AAF516D180E2C1A000584C8 /* QuestionContainerSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF4FFE180E2C17000584C8 /* QuestionContainerSprite.cpp */; }; 1AAF516E180E2C1A000584C8 /* Bug-624.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5000180E2C17000584C8 /* Bug-624.cpp */; }; 1AAF516F180E2C1A000584C8 /* Bug-624.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5000180E2C17000584C8 /* Bug-624.cpp */; }; 1AAF5170180E2C1A000584C8 /* Bug-886.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5002180E2C17000584C8 /* Bug-886.cpp */; }; 1AAF5171180E2C1A000584C8 /* Bug-886.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5002180E2C17000584C8 /* Bug-886.cpp */; }; 1AAF5172180E2C1A000584C8 /* Bug-899.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5004180E2C17000584C8 /* Bug-899.cpp */; }; 1AAF5173180E2C1A000584C8 /* Bug-899.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5004180E2C17000584C8 /* Bug-899.cpp */; }; 1AAF5174180E2C1A000584C8 /* Bug-914.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5006180E2C17000584C8 /* Bug-914.cpp */; }; 1AAF5175180E2C1A000584C8 /* Bug-914.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5006180E2C17000584C8 /* Bug-914.cpp */; }; 1AAF5176180E2C1A000584C8 /* BugsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5008180E2C17000584C8 /* BugsTest.cpp */; }; 1AAF5177180E2C1A000584C8 /* BugsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5008180E2C17000584C8 /* BugsTest.cpp */; }; 1AAF5178180E2C1A000584C8 /* ChipmunkTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF500B180E2C18000584C8 /* ChipmunkTest.cpp */; }; 1AAF5179180E2C1A000584C8 /* ChipmunkTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF500B180E2C18000584C8 /* ChipmunkTest.cpp */; }; 1AAF517A180E2C1A000584C8 /* ClickAndMoveTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF500E180E2C18000584C8 /* ClickAndMoveTest.cpp */; }; 1AAF517B180E2C1A000584C8 /* ClickAndMoveTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF500E180E2C18000584C8 /* ClickAndMoveTest.cpp */; }; 1AAF517C180E2C1A000584C8 /* ClippingNodeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5011180E2C18000584C8 /* ClippingNodeTest.cpp */; }; 1AAF517D180E2C1A000584C8 /* ClippingNodeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5011180E2C18000584C8 /* ClippingNodeTest.cpp */; }; 1AAF517E180E2C1A000584C8 /* CocosDenshionTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5014180E2C18000584C8 /* CocosDenshionTest.cpp */; }; 1AAF517F180E2C1A000584C8 /* CocosDenshionTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5014180E2C18000584C8 /* CocosDenshionTest.cpp */; }; 1AAF5180180E2C1A000584C8 /* ConfigurationTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5017180E2C18000584C8 /* ConfigurationTest.cpp */; }; 1AAF5181180E2C1A000584C8 /* ConfigurationTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5017180E2C18000584C8 /* ConfigurationTest.cpp */; }; 1AAF5182180E2C1A000584C8 /* controller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5019180E2C18000584C8 /* controller.cpp */; }; 1AAF5183180E2C1A000584C8 /* controller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5019180E2C18000584C8 /* controller.cpp */; }; 1AAF5184180E2C1A000584C8 /* CurlTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF501C180E2C18000584C8 /* CurlTest.cpp */; }; 1AAF5185180E2C1A000584C8 /* CurlTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF501C180E2C18000584C8 /* CurlTest.cpp */; }; 1AAF5186180E2C1A000584C8 /* CurrentLanguageTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF501F180E2C18000584C8 /* CurrentLanguageTest.cpp */; }; 1AAF5187180E2C1A000584C8 /* CurrentLanguageTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF501F180E2C18000584C8 /* CurrentLanguageTest.cpp */; }; 1AAF5188180E2C1A000584C8 /* DataVisitorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5022180E2C18000584C8 /* DataVisitorTest.cpp */; }; 1AAF5189180E2C1A000584C8 /* DataVisitorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5022180E2C18000584C8 /* DataVisitorTest.cpp */; }; 1AAF518A180E2C1A000584C8 /* DrawPrimitivesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5025180E2C18000584C8 /* DrawPrimitivesTest.cpp */; }; 1AAF518B180E2C1A000584C8 /* DrawPrimitivesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5025180E2C18000584C8 /* DrawPrimitivesTest.cpp */; }; 1AAF518C180E2C1A000584C8 /* EffectsAdvancedTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5028180E2C18000584C8 /* EffectsAdvancedTest.cpp */; }; 1AAF518D180E2C1A000584C8 /* EffectsAdvancedTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5028180E2C18000584C8 /* EffectsAdvancedTest.cpp */; }; 1AAF518E180E2C1A000584C8 /* EffectsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF502B180E2C18000584C8 /* EffectsTest.cpp */; }; 1AAF518F180E2C1A000584C8 /* EffectsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF502B180E2C18000584C8 /* EffectsTest.cpp */; }; 1AAF5190180E2C1A000584C8 /* AnimationsTestLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5031180E2C18000584C8 /* AnimationsTestLayer.cpp */; }; 1AAF5191180E2C1A000584C8 /* AnimationsTestLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5031180E2C18000584C8 /* AnimationsTestLayer.cpp */; }; 1AAF5192180E2C1A000584C8 /* ButtonTestLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5034180E2C18000584C8 /* ButtonTestLayer.cpp */; }; 1AAF5193180E2C1A000584C8 /* ButtonTestLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5034180E2C18000584C8 /* ButtonTestLayer.cpp */; }; 1AAF5194180E2C1A000584C8 /* CocosBuilderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5037180E2C18000584C8 /* CocosBuilderTest.cpp */; }; 1AAF5195180E2C1A000584C8 /* CocosBuilderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5037180E2C18000584C8 /* CocosBuilderTest.cpp */; }; 1AAF5196180E2C1A000584C8 /* HelloCocosBuilderLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF503A180E2C18000584C8 /* HelloCocosBuilderLayer.cpp */; }; 1AAF5197180E2C1A000584C8 /* HelloCocosBuilderLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF503A180E2C18000584C8 /* HelloCocosBuilderLayer.cpp */; }; 1AAF5198180E2C1A000584C8 /* MenuTestLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5041180E2C18000584C8 /* MenuTestLayer.cpp */; }; 1AAF5199180E2C1A000584C8 /* MenuTestLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5041180E2C18000584C8 /* MenuTestLayer.cpp */; }; 1AAF519A180E2C1A000584C8 /* TestHeaderLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF504E180E2C18000584C8 /* TestHeaderLayer.cpp */; }; 1AAF519B180E2C1A000584C8 /* TestHeaderLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF504E180E2C18000584C8 /* TestHeaderLayer.cpp */; }; 1AAF519C180E2C1A000584C8 /* TimelineCallbackTestLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5053180E2C18000584C8 /* TimelineCallbackTestLayer.cpp */; }; 1AAF519D180E2C1A000584C8 /* TimelineCallbackTestLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5053180E2C18000584C8 /* TimelineCallbackTestLayer.cpp */; }; 1AAF519E180E2C1A000584C8 /* ArmatureScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5056180E2C18000584C8 /* ArmatureScene.cpp */; }; 1AAF519F180E2C1A000584C8 /* ArmatureScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5056180E2C18000584C8 /* ArmatureScene.cpp */; }; 1AAF51A0180E2C1A000584C8 /* ComponentsTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5059180E2C18000584C8 /* ComponentsTestScene.cpp */; }; 1AAF51A1180E2C1A000584C8 /* ComponentsTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5059180E2C18000584C8 /* ComponentsTestScene.cpp */; }; 1AAF51A2180E2C1A000584C8 /* EnemyController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF505B180E2C18000584C8 /* EnemyController.cpp */; }; 1AAF51A3180E2C1A000584C8 /* EnemyController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF505B180E2C18000584C8 /* EnemyController.cpp */; }; 1AAF51A4180E2C1A000584C8 /* GameOverScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF505D180E2C18000584C8 /* GameOverScene.cpp */; }; 1AAF51A5180E2C1A000584C8 /* GameOverScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF505D180E2C18000584C8 /* GameOverScene.cpp */; }; 1AAF51A6180E2C1A000584C8 /* PlayerController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF505F180E2C18000584C8 /* PlayerController.cpp */; }; 1AAF51A7180E2C1A000584C8 /* PlayerController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF505F180E2C18000584C8 /* PlayerController.cpp */; }; 1AAF51A8180E2C1A000584C8 /* ProjectileController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5061180E2C18000584C8 /* ProjectileController.cpp */; }; 1AAF51A9180E2C1A000584C8 /* ProjectileController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5061180E2C18000584C8 /* ProjectileController.cpp */; }; 1AAF51AA180E2C1A000584C8 /* SceneController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5063180E2C18000584C8 /* SceneController.cpp */; }; 1AAF51AB180E2C1A000584C8 /* SceneController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5063180E2C18000584C8 /* SceneController.cpp */; }; 1AAF51D4180E2C1A000584C8 /* SceneEditorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50A0180E2C19000584C8 /* SceneEditorTest.cpp */; }; 1AAF51D5180E2C1A000584C8 /* SceneEditorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50A0180E2C19000584C8 /* SceneEditorTest.cpp */; }; 1AAF51D6180E2C1A000584C8 /* CCControlButtonTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50A4180E2C19000584C8 /* CCControlButtonTest.cpp */; }; 1AAF51D7180E2C1A000584C8 /* CCControlButtonTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50A4180E2C19000584C8 /* CCControlButtonTest.cpp */; }; 1AAF51D8180E2C1A000584C8 /* CCControlColourPickerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50A7180E2C19000584C8 /* CCControlColourPickerTest.cpp */; }; 1AAF51D9180E2C1A000584C8 /* CCControlColourPickerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50A7180E2C19000584C8 /* CCControlColourPickerTest.cpp */; }; 1AAF51DA180E2C1A000584C8 /* CCControlPotentiometerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50AA180E2C19000584C8 /* CCControlPotentiometerTest.cpp */; }; 1AAF51DB180E2C1A000584C8 /* CCControlPotentiometerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50AA180E2C19000584C8 /* CCControlPotentiometerTest.cpp */; }; 1AAF51DC180E2C1A000584C8 /* CCControlScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50AC180E2C19000584C8 /* CCControlScene.cpp */; }; 1AAF51DD180E2C1A000584C8 /* CCControlScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50AC180E2C19000584C8 /* CCControlScene.cpp */; }; 1AAF51DE180E2C1A000584C8 /* CCControlSceneManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50AE180E2C19000584C8 /* CCControlSceneManager.cpp */; }; 1AAF51DF180E2C1A000584C8 /* CCControlSceneManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50AE180E2C19000584C8 /* CCControlSceneManager.cpp */; }; 1AAF51E0180E2C1A000584C8 /* CCControlSliderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50B1180E2C19000584C8 /* CCControlSliderTest.cpp */; }; 1AAF51E1180E2C1A000584C8 /* CCControlSliderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50B1180E2C19000584C8 /* CCControlSliderTest.cpp */; }; 1AAF51E2180E2C1A000584C8 /* CCControlStepperTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50B4180E2C19000584C8 /* CCControlStepperTest.cpp */; }; 1AAF51E3180E2C1A000584C8 /* CCControlStepperTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50B4180E2C19000584C8 /* CCControlStepperTest.cpp */; }; 1AAF51E4180E2C1A000584C8 /* CCControlSwitchTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50B7180E2C19000584C8 /* CCControlSwitchTest.cpp */; }; 1AAF51E5180E2C1A000584C8 /* CCControlSwitchTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50B7180E2C19000584C8 /* CCControlSwitchTest.cpp */; }; 1AAF51E6180E2C1A000584C8 /* EditBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50BA180E2C19000584C8 /* EditBoxTest.cpp */; }; 1AAF51E7180E2C1A000584C8 /* EditBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50BA180E2C19000584C8 /* EditBoxTest.cpp */; }; 1AAF51E8180E2C1A000584C8 /* ExtensionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50BC180E2C19000584C8 /* ExtensionsTest.cpp */; }; 1AAF51E9180E2C1A000584C8 /* ExtensionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50BC180E2C19000584C8 /* ExtensionsTest.cpp */; }; 1AAF51EA180E2C1A000584C8 /* HttpClientTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50BF180E2C19000584C8 /* HttpClientTest.cpp */; }; 1AAF51EB180E2C1A000584C8 /* HttpClientTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50BF180E2C19000584C8 /* HttpClientTest.cpp */; }; 1AAF51EC180E2C1A000584C8 /* SocketIOTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50C1180E2C19000584C8 /* SocketIOTest.cpp */; }; 1AAF51ED180E2C1A000584C8 /* SocketIOTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50C1180E2C19000584C8 /* SocketIOTest.cpp */; }; 1AAF51EE180E2C1A000584C8 /* WebSocketTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50C3180E2C19000584C8 /* WebSocketTest.cpp */; }; 1AAF51EF180E2C1A000584C8 /* WebSocketTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50C3180E2C19000584C8 /* WebSocketTest.cpp */; }; 1AAF51F0180E2C1A000584C8 /* NotificationCenterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50C6180E2C19000584C8 /* NotificationCenterTest.cpp */; }; 1AAF51F1180E2C1A000584C8 /* NotificationCenterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50C6180E2C19000584C8 /* NotificationCenterTest.cpp */; }; 1AAF51F2180E2C1A000584C8 /* Scale9SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50C9180E2C19000584C8 /* Scale9SpriteTest.cpp */; }; 1AAF51F3180E2C1A000584C8 /* Scale9SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50C9180E2C19000584C8 /* Scale9SpriteTest.cpp */; }; 1AAF51F4180E2C1A000584C8 /* CustomTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50CC180E2C19000584C8 /* CustomTableViewCell.cpp */; }; 1AAF51F5180E2C1A000584C8 /* CustomTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50CC180E2C19000584C8 /* CustomTableViewCell.cpp */; }; 1AAF51F6180E2C1A000584C8 /* TableViewTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50CE180E2C19000584C8 /* TableViewTestScene.cpp */; }; 1AAF51F7180E2C1A000584C8 /* TableViewTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50CE180E2C19000584C8 /* TableViewTestScene.cpp */; }; 1AAF51F8180E2C1A000584C8 /* FileUtilsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50D1180E2C19000584C8 /* FileUtilsTest.cpp */; }; 1AAF51F9180E2C1A000584C8 /* FileUtilsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50D1180E2C19000584C8 /* FileUtilsTest.cpp */; }; 1AAF51FA180E2C1A000584C8 /* FontTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50D4180E2C19000584C8 /* FontTest.cpp */; }; 1AAF51FB180E2C1A000584C8 /* FontTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50D4180E2C19000584C8 /* FontTest.cpp */; }; 1AAF51FC180E2C1A000584C8 /* IntervalTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50D7180E2C19000584C8 /* IntervalTest.cpp */; }; 1AAF51FD180E2C1A000584C8 /* IntervalTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50D7180E2C19000584C8 /* IntervalTest.cpp */; }; 1AAF51FE180E2C1A000584C8 /* KeyboardTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50DA180E2C19000584C8 /* KeyboardTest.cpp */; }; 1AAF51FF180E2C1A000584C8 /* KeyboardTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50DA180E2C19000584C8 /* KeyboardTest.cpp */; }; 1AAF5200180E2C1A000584C8 /* KeypadTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50DD180E2C19000584C8 /* KeypadTest.cpp */; }; 1AAF5201180E2C1A000584C8 /* KeypadTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50DD180E2C19000584C8 /* KeypadTest.cpp */; }; 1AAF5202180E2C1A000584C8 /* LabelTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50E0180E2C19000584C8 /* LabelTest.cpp */; }; 1AAF5203180E2C1A000584C8 /* LabelTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50E0180E2C19000584C8 /* LabelTest.cpp */; }; 1AAF5204180E2C1A000584C8 /* LabelTestNew.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50E2180E2C19000584C8 /* LabelTestNew.cpp */; }; 1AAF5205180E2C1A000584C8 /* LabelTestNew.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50E2180E2C19000584C8 /* LabelTestNew.cpp */; }; 1AAF5206180E2C1A000584C8 /* LayerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50E5180E2C19000584C8 /* LayerTest.cpp */; }; 1AAF5207180E2C1A000584C8 /* LayerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50E5180E2C19000584C8 /* LayerTest.cpp */; }; 1AAF5208180E2C1A000584C8 /* MenuTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50E8180E2C19000584C8 /* MenuTest.cpp */; }; 1AAF5209180E2C1A000584C8 /* MenuTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50E8180E2C19000584C8 /* MenuTest.cpp */; }; 1AAF520A180E2C1A000584C8 /* MotionStreakTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50EB180E2C19000584C8 /* MotionStreakTest.cpp */; }; 1AAF520B180E2C1A000584C8 /* MotionStreakTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50EB180E2C19000584C8 /* MotionStreakTest.cpp */; }; 1AAF520C180E2C1A000584C8 /* MutiTouchTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50EE180E2C19000584C8 /* MutiTouchTest.cpp */; }; 1AAF520D180E2C1A000584C8 /* MutiTouchTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50EE180E2C19000584C8 /* MutiTouchTest.cpp */; }; 1AAF520E180E2C1A000584C8 /* NewEventDispatcherTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50F1180E2C19000584C8 /* NewEventDispatcherTest.cpp */; }; 1AAF520F180E2C1A000584C8 /* NewEventDispatcherTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50F1180E2C19000584C8 /* NewEventDispatcherTest.cpp */; }; 1AAF5210180E2C1A000584C8 /* NodeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50F4180E2C19000584C8 /* NodeTest.cpp */; }; 1AAF5211180E2C1A000584C8 /* NodeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50F4180E2C19000584C8 /* NodeTest.cpp */; }; 1AAF5212180E2C1A000584C8 /* ParallaxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50F7180E2C1A000584C8 /* ParallaxTest.cpp */; }; 1AAF5213180E2C1A000584C8 /* ParallaxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50F7180E2C1A000584C8 /* ParallaxTest.cpp */; }; 1AAF5214180E2C1A000584C8 /* ParticleTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50FA180E2C1A000584C8 /* ParticleTest.cpp */; }; 1AAF5215180E2C1A000584C8 /* ParticleTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50FA180E2C1A000584C8 /* ParticleTest.cpp */; }; 1AAF5216180E2C1A000584C8 /* PerformanceAllocTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50FD180E2C1A000584C8 /* PerformanceAllocTest.cpp */; }; 1AAF5217180E2C1A000584C8 /* PerformanceAllocTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50FD180E2C1A000584C8 /* PerformanceAllocTest.cpp */; }; 1AAF5218180E2C1A000584C8 /* PerformanceNodeChildrenTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50FF180E2C1A000584C8 /* PerformanceNodeChildrenTest.cpp */; }; 1AAF5219180E2C1A000584C8 /* PerformanceNodeChildrenTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF50FF180E2C1A000584C8 /* PerformanceNodeChildrenTest.cpp */; }; 1AAF521A180E2C1A000584C8 /* PerformanceParticleTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5101180E2C1A000584C8 /* PerformanceParticleTest.cpp */; }; 1AAF521B180E2C1A000584C8 /* PerformanceParticleTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5101180E2C1A000584C8 /* PerformanceParticleTest.cpp */; }; 1AAF521C180E2C1A000584C8 /* PerformanceSpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5103180E2C1A000584C8 /* PerformanceSpriteTest.cpp */; }; 1AAF521D180E2C1A000584C8 /* PerformanceSpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5103180E2C1A000584C8 /* PerformanceSpriteTest.cpp */; }; 1AAF521E180E2C1A000584C8 /* PerformanceTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5105180E2C1A000584C8 /* PerformanceTest.cpp */; }; 1AAF521F180E2C1A000584C8 /* PerformanceTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5105180E2C1A000584C8 /* PerformanceTest.cpp */; }; 1AAF5220180E2C1A000584C8 /* PerformanceTextureTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5107180E2C1A000584C8 /* PerformanceTextureTest.cpp */; }; 1AAF5221180E2C1A000584C8 /* PerformanceTextureTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5107180E2C1A000584C8 /* PerformanceTextureTest.cpp */; }; 1AAF5222180E2C1A000584C8 /* PerformanceTouchesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5109180E2C1A000584C8 /* PerformanceTouchesTest.cpp */; }; 1AAF5223180E2C1A000584C8 /* PerformanceTouchesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5109180E2C1A000584C8 /* PerformanceTouchesTest.cpp */; }; 1AAF5224180E2C1A000584C8 /* PhysicsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF510C180E2C1A000584C8 /* PhysicsTest.cpp */; }; 1AAF5225180E2C1A000584C8 /* PhysicsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF510C180E2C1A000584C8 /* PhysicsTest.cpp */; }; 1AAF5226180E2C1A000584C8 /* RenderTextureTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF510F180E2C1A000584C8 /* RenderTextureTest.cpp */; }; 1AAF5227180E2C1A000584C8 /* RenderTextureTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF510F180E2C1A000584C8 /* RenderTextureTest.cpp */; }; 1AAF5228180E2C1A000584C8 /* RotateWorldTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5112180E2C1A000584C8 /* RotateWorldTest.cpp */; }; 1AAF5229180E2C1A000584C8 /* RotateWorldTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5112180E2C1A000584C8 /* RotateWorldTest.cpp */; }; 1AAF522A180E2C1A000584C8 /* SceneTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5115180E2C1A000584C8 /* SceneTest.cpp */; }; 1AAF522B180E2C1A000584C8 /* SceneTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5115180E2C1A000584C8 /* SceneTest.cpp */; }; 1AAF522C180E2C1A000584C8 /* SchedulerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5118180E2C1A000584C8 /* SchedulerTest.cpp */; }; 1AAF522D180E2C1A000584C8 /* SchedulerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5118180E2C1A000584C8 /* SchedulerTest.cpp */; }; 1AAF522E180E2C1A000584C8 /* ShaderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF511B180E2C1A000584C8 /* ShaderTest.cpp */; }; 1AAF522F180E2C1A000584C8 /* ShaderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF511B180E2C1A000584C8 /* ShaderTest.cpp */; }; 1AAF5230180E2C1A000584C8 /* ShaderTest2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF511D180E2C1A000584C8 /* ShaderTest2.cpp */; }; 1AAF5231180E2C1A000584C8 /* ShaderTest2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF511D180E2C1A000584C8 /* ShaderTest2.cpp */; }; 1AAF5232180E2C1A000584C8 /* SpineTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5120180E2C1A000584C8 /* SpineTest.cpp */; }; 1AAF5233180E2C1A000584C8 /* SpineTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5120180E2C1A000584C8 /* SpineTest.cpp */; }; 1AAF5234180E2C1A000584C8 /* SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5123180E2C1A000584C8 /* SpriteTest.cpp */; }; 1AAF5235180E2C1A000584C8 /* SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5123180E2C1A000584C8 /* SpriteTest.cpp */; }; 1AAF5236180E2C1A000584C8 /* testBasic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5125180E2C1A000584C8 /* testBasic.cpp */; }; 1AAF5237180E2C1A000584C8 /* testBasic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5125180E2C1A000584C8 /* testBasic.cpp */; }; 1AAF5238180E2C1A000584C8 /* TextInputTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF512A180E2C1A000584C8 /* TextInputTest.cpp */; }; 1AAF5239180E2C1A000584C8 /* TextInputTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF512A180E2C1A000584C8 /* TextInputTest.cpp */; }; 1AAF523A180E2C1A000584C8 /* Texture2dTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF512D180E2C1A000584C8 /* Texture2dTest.cpp */; }; 1AAF523B180E2C1A000584C8 /* Texture2dTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF512D180E2C1A000584C8 /* Texture2dTest.cpp */; }; 1AAF523C180E2C1A000584C8 /* TextureCacheTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5130180E2C1A000584C8 /* TextureCacheTest.cpp */; }; 1AAF523D180E2C1A000584C8 /* TextureCacheTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5130180E2C1A000584C8 /* TextureCacheTest.cpp */; }; 1AAF523E180E2C1A000584C8 /* TextureAtlasEncryptionTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5133180E2C1A000584C8 /* TextureAtlasEncryptionTest.cpp */; }; 1AAF523F180E2C1A000584C8 /* TextureAtlasEncryptionTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5133180E2C1A000584C8 /* TextureAtlasEncryptionTest.cpp */; }; 1AAF5240180E2C1A000584C8 /* TileMapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5136180E2C1A000584C8 /* TileMapTest.cpp */; }; 1AAF5241180E2C1A000584C8 /* TileMapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5136180E2C1A000584C8 /* TileMapTest.cpp */; }; 1AAF5242180E2C1A000584C8 /* Ball.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5139180E2C1A000584C8 /* Ball.cpp */; }; 1AAF5243180E2C1A000584C8 /* Ball.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5139180E2C1A000584C8 /* Ball.cpp */; }; 1AAF5244180E2C1A000584C8 /* Paddle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF513B180E2C1A000584C8 /* Paddle.cpp */; }; 1AAF5245180E2C1A000584C8 /* Paddle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF513B180E2C1A000584C8 /* Paddle.cpp */; }; 1AAF5246180E2C1A000584C8 /* TouchesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF513D180E2C1A000584C8 /* TouchesTest.cpp */; }; 1AAF5247180E2C1A000584C8 /* TouchesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF513D180E2C1A000584C8 /* TouchesTest.cpp */; }; 1AAF5248180E2C1A000584C8 /* TransitionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5140180E2C1A000584C8 /* TransitionsTest.cpp */; }; 1AAF5249180E2C1A000584C8 /* TransitionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5140180E2C1A000584C8 /* TransitionsTest.cpp */; }; 1AAF524A180E2C1A000584C8 /* UserDefaultTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5143180E2C1A000584C8 /* UserDefaultTest.cpp */; }; 1AAF524B180E2C1A000584C8 /* UserDefaultTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5143180E2C1A000584C8 /* UserDefaultTest.cpp */; }; 1AAF524C180E2C1A000584C8 /* VisibleRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5145180E2C1A000584C8 /* VisibleRect.cpp */; }; 1AAF524D180E2C1A000584C8 /* VisibleRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5145180E2C1A000584C8 /* VisibleRect.cpp */; }; 1AAF524E180E2C1A000584C8 /* ZwoptexTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5148180E2C1A000584C8 /* ZwoptexTest.cpp */; }; 1AAF524F180E2C1A000584C8 /* ZwoptexTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5148180E2C1A000584C8 /* ZwoptexTest.cpp */; }; 1AAF5269180E2C26000584C8 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5253180E2C26000584C8 /* RootViewController.mm */; }; 1AAF526A180E2C26000584C8 /* testsAppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5255180E2C26000584C8 /* testsAppDelegate.mm */; }; 1AAF526B180E2C26000584C8 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5256180E2C26000584C8 /* Default-568h@2x.png */; }; 1AAF526C180E2C26000584C8 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5257180E2C26000584C8 /* Default.png */; }; 1AAF526D180E2C26000584C8 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5258180E2C26000584C8 /* Default@2x.png */; }; 1AAF526E180E2C26000584C8 /* Icon-100.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5259180E2C26000584C8 /* Icon-100.png */; }; 1AAF526F180E2C26000584C8 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF525A180E2C26000584C8 /* Icon-114.png */; }; 1AAF5270180E2C26000584C8 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF525B180E2C26000584C8 /* Icon-120.png */; }; 1AAF5271180E2C26000584C8 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF525C180E2C26000584C8 /* Icon-144.png */; }; 1AAF5272180E2C26000584C8 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF525D180E2C26000584C8 /* Icon-152.png */; }; 1AAF5273180E2C26000584C8 /* Icon-29.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF525E180E2C26000584C8 /* Icon-29.png */; }; 1AAF5274180E2C26000584C8 /* Icon-40.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF525F180E2C26000584C8 /* Icon-40.png */; }; 1AAF5275180E2C26000584C8 /* Icon-50.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5260180E2C26000584C8 /* Icon-50.png */; }; 1AAF5276180E2C26000584C8 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5261180E2C26000584C8 /* Icon-57.png */; }; 1AAF5277180E2C26000584C8 /* Icon-58.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5262180E2C26000584C8 /* Icon-58.png */; }; 1AAF5278180E2C26000584C8 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5263180E2C26000584C8 /* Icon-72.png */; }; 1AAF5279180E2C26000584C8 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5264180E2C26000584C8 /* Icon-76.png */; }; 1AAF527A180E2C26000584C8 /* Icon-80.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5265180E2C26000584C8 /* Icon-80.png */; }; 1AAF527B180E2C26000584C8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5267180E2C26000584C8 /* main.m */; }; 1AAF527C180E2C26000584C8 /* Test-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5268180E2C26000584C8 /* Test-Info.plist */; }; 1AAF5286180E2C31000584C8 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF527E180E2C31000584C8 /* InfoPlist.strings */; }; 1AAF5287180E2C31000584C8 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5280180E2C31000584C8 /* MainMenu.xib */; }; 1AAF5288180E2C31000584C8 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1AAF5282180E2C31000584C8 /* Icon.icns */; }; 1AAF5289180E2C31000584C8 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF5283180E2C31000584C8 /* main.cpp */; }; 1AAF534B180E2F4E000584C8 /* libbox2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB61807A4F9005B8026 /* libbox2d Mac.a */; }; 1AAF534C180E2F4E000584C8 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; }; 1AAF534D180E2F4E000584C8 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 1AAF534E180E2F4E000584C8 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */; }; 1AAF534F180E2F4E000584C8 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 1AAF53FE180E39D4000584C8 /* libbox2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC41807A4F9005B8026 /* libbox2d iOS.a */; }; 1AAF53FF180E39D4000584C8 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */; }; 1AAF5400180E39D4000584C8 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 1AAF5401180E39D4000584C8 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */; }; 1AAF5402180E39D4000584C8 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 1ADCE790186BCAB9001B78A4 /* CocosGUIScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360CA186819DB00828878 /* CocosGUIScene.cpp */; }; 1ADCE793186BCAFB001B78A4 /* UIScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360EA186819DB00828878 /* UIScene.cpp */; }; 1ADCE794186BCAFB001B78A4 /* UISceneManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360EC186819DB00828878 /* UISceneManager.cpp */; }; 1ADCE795186BCB20001B78A4 /* UIButtonTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360CD186819DB00828878 /* UIButtonTest.cpp */; }; 1ADCE796186BCB20001B78A4 /* UICheckBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360D0186819DB00828878 /* UICheckBoxTest.cpp */; }; 1ADCE797186BCB21001B78A4 /* UIImageViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360D3186819DB00828878 /* UIImageViewTest.cpp */; }; 1ADCE798186BCB21001B78A4 /* UILabelAtlasTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360D6186819DB00828878 /* UILabelAtlasTest.cpp */; }; 1ADCE799186BCB21001B78A4 /* UILabelBMFontTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360D9186819DB00828878 /* UILabelBMFontTest.cpp */; }; 1ADCE79A186BCB21001B78A4 /* UILabelTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360DC186819DB00828878 /* UILabelTest.cpp */; }; 1ADCE79B186BCB21001B78A4 /* UILayoutTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360DF186819DB00828878 /* UILayoutTest.cpp */; }; 1ADCE79C186BCB21001B78A4 /* UIListViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360E2186819DB00828878 /* UIListViewTest.cpp */; }; 1ADCE79D186BCB21001B78A4 /* UILoadingBarTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360E5186819DB00828878 /* UILoadingBarTest.cpp */; }; 1ADCE79E186BCB21001B78A4 /* UIPageViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360E8186819DB00828878 /* UIPageViewTest.cpp */; }; 1ADCE79F186BCF19001B78A4 /* UIScrollViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360EF186819DB00828878 /* UIScrollViewTest.cpp */; }; 1ADCE7A0186BCF19001B78A4 /* UISliderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360F2186819DB00828878 /* UISliderTest.cpp */; }; 1ADCE7A1186BCF19001B78A4 /* UITextFieldTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360F5186819DB00828878 /* UITextFieldTest.cpp */; }; 1ADCE7A2186BCF19001B78A4 /* UIWidgetAddNodeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360F8186819DB00828878 /* UIWidgetAddNodeTest.cpp */; }; 1ADD146D188D25270034D5EF /* PerformanceEventDispatcherTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ADD146B188D25270034D5EF /* PerformanceEventDispatcherTest.cpp */; }; 1ADD146E188D25270034D5EF /* PerformanceEventDispatcherTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ADD146B188D25270034D5EF /* PerformanceEventDispatcherTest.cpp */; }; 1AFB0DE31885357A003B2FF3 /* PerformanceContainerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB0DE11885357A003B2FF3 /* PerformanceContainerTest.cpp */; }; 1AFB0DE41885357A003B2FF3 /* PerformanceContainerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB0DE11885357A003B2FF3 /* PerformanceContainerTest.cpp */; }; 37A61460186B21F6007A4638 /* acts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37A6145B186B21F6007A4638 /* acts.cpp */; }; 37A61461186B21F6007A4638 /* acts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37A6145B186B21F6007A4638 /* acts.cpp */; }; 37A61462186B21F6007A4638 /* cons.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37A6145D186B21F6007A4638 /* cons.cpp */; }; 37A61463186B21F6007A4638 /* cons.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37A6145D186B21F6007A4638 /* cons.cpp */; }; 37C819801875DF2B00930C57 /* animations in Resources */ = {isa = PBXBuildFile; fileRef = 37C819601875DF2A00930C57 /* animations */; }; 37C819831875DF2B00930C57 /* animations in Resources */ = {isa = PBXBuildFile; fileRef = 37C819601875DF2A00930C57 /* animations */; }; 37C819861875DF2B00930C57 /* armature in Resources */ = {isa = PBXBuildFile; fileRef = 37C819611875DF2A00930C57 /* armature */; }; 37C819891875DF2B00930C57 /* armature in Resources */ = {isa = PBXBuildFile; fileRef = 37C819611875DF2A00930C57 /* armature */; }; 37C8198C1875DF2B00930C57 /* background-music-aac.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C819621875DF2A00930C57 /* background-music-aac.wav */; }; 37C8198F1875DF2B00930C57 /* background-music-aac.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C819621875DF2A00930C57 /* background-music-aac.wav */; }; 37C819921875DF2B00930C57 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 37C819631875DF2A00930C57 /* background.mp3 */; }; 37C819951875DF2B00930C57 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 37C819631875DF2A00930C57 /* background.mp3 */; }; 37C819981875DF2B00930C57 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 37C819641875DF2A00930C57 /* background.ogg */; }; 37C8199B1875DF2B00930C57 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 37C819641875DF2A00930C57 /* background.ogg */; }; 37C8199E1875DF2B00930C57 /* ccb in Resources */ = {isa = PBXBuildFile; fileRef = 37C819651875DF2A00930C57 /* ccb */; }; 37C819A11875DF2B00930C57 /* ccb in Resources */ = {isa = PBXBuildFile; fileRef = 37C819651875DF2A00930C57 /* ccb */; }; 37C819A41875DF2B00930C57 /* CocosBuilderExample.ccbproj in Resources */ = {isa = PBXBuildFile; fileRef = 37C819661875DF2A00930C57 /* CocosBuilderExample.ccbproj */; }; 37C819A71875DF2B00930C57 /* CocosBuilderExample.ccbproj in Resources */ = {isa = PBXBuildFile; fileRef = 37C819661875DF2A00930C57 /* CocosBuilderExample.ccbproj */; }; 37C819AA1875DF2B00930C57 /* CocosBuilderExample.ccbresourcelog in Resources */ = {isa = PBXBuildFile; fileRef = 37C819671875DF2A00930C57 /* CocosBuilderExample.ccbresourcelog */; }; 37C819AD1875DF2B00930C57 /* CocosBuilderExample.ccbresourcelog in Resources */ = {isa = PBXBuildFile; fileRef = 37C819671875DF2A00930C57 /* CocosBuilderExample.ccbresourcelog */; }; 37C819B01875DF2B00930C57 /* cocosgui in Resources */ = {isa = PBXBuildFile; fileRef = 37C819681875DF2A00930C57 /* cocosgui */; }; 37C819B31875DF2B00930C57 /* cocosgui in Resources */ = {isa = PBXBuildFile; fileRef = 37C819681875DF2A00930C57 /* cocosgui */; }; 37C819B61875DF2B00930C57 /* components in Resources */ = {isa = PBXBuildFile; fileRef = 37C819691875DF2A00930C57 /* components */; }; 37C819B91875DF2B00930C57 /* components in Resources */ = {isa = PBXBuildFile; fileRef = 37C819691875DF2A00930C57 /* components */; }; 37C819BC1875DF2B00930C57 /* configs in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196A1875DF2A00930C57 /* configs */; }; 37C819BF1875DF2B00930C57 /* configs in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196A1875DF2A00930C57 /* configs */; }; 37C819C21875DF2B00930C57 /* effect1.raw in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196B1875DF2A00930C57 /* effect1.raw */; }; 37C819C51875DF2B00930C57 /* effect1.raw in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196B1875DF2A00930C57 /* effect1.raw */; }; 37C819C81875DF2B00930C57 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196C1875DF2A00930C57 /* effect1.wav */; }; 37C819CB1875DF2B00930C57 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196C1875DF2A00930C57 /* effect1.wav */; }; 37C819CE1875DF2B00930C57 /* effect2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196D1875DF2A00930C57 /* effect2.ogg */; }; 37C819D11875DF2B00930C57 /* effect2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196D1875DF2A00930C57 /* effect2.ogg */; }; 37C819D41875DF2B00930C57 /* extensions in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196E1875DF2A00930C57 /* extensions */; }; 37C819D71875DF2B00930C57 /* extensions in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196E1875DF2A00930C57 /* extensions */; }; 37C819DA1875DF2B00930C57 /* fileLookup.plist in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196F1875DF2A00930C57 /* fileLookup.plist */; }; 37C819DD1875DF2B00930C57 /* fileLookup.plist in Resources */ = {isa = PBXBuildFile; fileRef = 37C8196F1875DF2A00930C57 /* fileLookup.plist */; }; 37C819E01875DF2B00930C57 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 37C819701875DF2A00930C57 /* fonts */; }; 37C819E31875DF2B00930C57 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 37C819701875DF2A00930C57 /* fonts */; }; 37C819E61875DF2B00930C57 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 37C819711875DF2A00930C57 /* fps_images.png */; }; 37C819E91875DF2B00930C57 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 37C819711875DF2A00930C57 /* fps_images.png */; }; 37C819EC1875DF2B00930C57 /* hd in Resources */ = {isa = PBXBuildFile; fileRef = 37C819721875DF2A00930C57 /* hd */; }; 37C819EF1875DF2B00930C57 /* hd in Resources */ = {isa = PBXBuildFile; fileRef = 37C819721875DF2A00930C57 /* hd */; }; 37C819F21875DF2B00930C57 /* Hello.png in Resources */ = {isa = PBXBuildFile; fileRef = 37C819731875DF2A00930C57 /* Hello.png */; }; 37C819F51875DF2B00930C57 /* Hello.png in Resources */ = {isa = PBXBuildFile; fileRef = 37C819731875DF2A00930C57 /* Hello.png */; }; 37C819F81875DF2B00930C57 /* Images in Resources */ = {isa = PBXBuildFile; fileRef = 37C819741875DF2B00930C57 /* Images */; }; 37C819FB1875DF2B00930C57 /* Images in Resources */ = {isa = PBXBuildFile; fileRef = 37C819741875DF2B00930C57 /* Images */; }; 37C819FE1875DF2B00930C57 /* ipad in Resources */ = {isa = PBXBuildFile; fileRef = 37C819751875DF2B00930C57 /* ipad */; }; 37C81A011875DF2B00930C57 /* ipad in Resources */ = {isa = PBXBuildFile; fileRef = 37C819751875DF2B00930C57 /* ipad */; }; 37C81A041875DF2B00930C57 /* ipadhd in Resources */ = {isa = PBXBuildFile; fileRef = 37C819761875DF2B00930C57 /* ipadhd */; }; 37C81A071875DF2B00930C57 /* ipadhd in Resources */ = {isa = PBXBuildFile; fileRef = 37C819761875DF2B00930C57 /* ipadhd */; }; 37C81A0A1875DF2B00930C57 /* Misc in Resources */ = {isa = PBXBuildFile; fileRef = 37C819771875DF2B00930C57 /* Misc */; }; 37C81A0D1875DF2B00930C57 /* Misc in Resources */ = {isa = PBXBuildFile; fileRef = 37C819771875DF2B00930C57 /* Misc */; }; 37C81A101875DF2B00930C57 /* music.mid in Resources */ = {isa = PBXBuildFile; fileRef = 37C819781875DF2B00930C57 /* music.mid */; }; 37C81A131875DF2B00930C57 /* music.mid in Resources */ = {isa = PBXBuildFile; fileRef = 37C819781875DF2B00930C57 /* music.mid */; }; 37C81A161875DF2B00930C57 /* Particles in Resources */ = {isa = PBXBuildFile; fileRef = 37C819791875DF2B00930C57 /* Particles */; }; 37C81A191875DF2B00930C57 /* Particles in Resources */ = {isa = PBXBuildFile; fileRef = 37C819791875DF2B00930C57 /* Particles */; }; 37C81A1C1875DF2B00930C57 /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197A1875DF2B00930C57 /* pew-pew-lei.wav */; }; 37C81A1F1875DF2B00930C57 /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197A1875DF2B00930C57 /* pew-pew-lei.wav */; }; 37C81A221875DF2B00930C57 /* scenetest in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197B1875DF2B00930C57 /* scenetest */; }; 37C81A251875DF2B00930C57 /* scenetest in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197B1875DF2B00930C57 /* scenetest */; }; 37C81A281875DF2B00930C57 /* Shaders in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197C1875DF2B00930C57 /* Shaders */; }; 37C81A2B1875DF2B00930C57 /* Shaders in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197C1875DF2B00930C57 /* Shaders */; }; 37C81A2E1875DF2B00930C57 /* spine in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197D1875DF2B00930C57 /* spine */; }; 37C81A311875DF2B00930C57 /* spine in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197D1875DF2B00930C57 /* spine */; }; 37C81A341875DF2B00930C57 /* TileMaps in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197E1875DF2B00930C57 /* TileMaps */; }; 37C81A371875DF2B00930C57 /* TileMaps in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197E1875DF2B00930C57 /* TileMaps */; }; 37C81A3A1875DF2B00930C57 /* zwoptex in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197F1875DF2B00930C57 /* zwoptex */; }; 37C81A3D1875DF2B00930C57 /* zwoptex in Resources */ = {isa = PBXBuildFile; fileRef = 37C8197F1875DF2B00930C57 /* zwoptex */; }; 460E44BB1807DDC2000CDD6D /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 460E44FD1807E413000CDD6D /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 460E45691807E767000CDD6D /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 460E452E1807E712000CDD6D /* AppController.mm */; }; 460E456A1807E767000CDD6D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 460E453B1807E712000CDD6D /* RootViewController.mm */; }; 460E45861807FDC3000CDD6D /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; }; 460E45871807FDC3000CDD6D /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; }; 460E45B9180801A4000CDD6D /* background-music-aac.wav in Resources */ = {isa = PBXBuildFile; fileRef = 460E45A1180801A4000CDD6D /* background-music-aac.wav */; }; 460E45BA180801A4000CDD6D /* background-music-aac.wav in Resources */ = {isa = PBXBuildFile; fileRef = 460E45A1180801A4000CDD6D /* background-music-aac.wav */; }; 460E45BD180801A4000CDD6D /* Marker Felt.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 460E45A4180801A4000CDD6D /* Marker Felt.ttf */; }; 460E45BE180801A4000CDD6D /* Marker Felt.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 460E45A4180801A4000CDD6D /* Marker Felt.ttf */; }; 460E45C9180801A4000CDD6D /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 460E45AB180801A4000CDD6D /* pew-pew-lei.wav */; }; 460E45CA180801A4000CDD6D /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 460E45AB180801A4000CDD6D /* pew-pew-lei.wav */; }; 460E45D8180801C1000CDD6D /* hd in Resources */ = {isa = PBXBuildFile; fileRef = 460E45D7180801C1000CDD6D /* hd */; }; 460E45D9180801C1000CDD6D /* hd in Resources */ = {isa = PBXBuildFile; fileRef = 460E45D7180801C1000CDD6D /* hd */; }; 460E45DB180801C9000CDD6D /* sd in Resources */ = {isa = PBXBuildFile; fileRef = 460E45DA180801C9000CDD6D /* sd */; }; 460E45DC180801C9000CDD6D /* sd in Resources */ = {isa = PBXBuildFile; fileRef = 460E45DA180801C9000CDD6D /* sd */; }; 460E45DF18080238000CDD6D /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */; }; 460E45E018080238000CDD6D /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */; }; 4662EB5F188E426300B02E8F /* ReleasePoolTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4662EB5D188E426300B02E8F /* ReleasePoolTest.cpp */; }; 4662EB60188E426300B02E8F /* ReleasePoolTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4662EB5D188E426300B02E8F /* ReleasePoolTest.cpp */; }; 468588DA180805F100AC387D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 460E45391807E712000CDD6D /* main.m */; }; 46A174E71807D95B005B8026 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A174851807D934005B8026 /* AppDelegate.cpp */; }; 46A174E81807D96A005B8026 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A174881807D934005B8026 /* HelloWorldScene.cpp */; }; 46A174E91807D976005B8026 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A174851807D934005B8026 /* AppDelegate.cpp */; }; 46A174EA1807D976005B8026 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A174881807D934005B8026 /* HelloWorldScene.cpp */; }; 46A174F41807D9C4005B8026 /* bang.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174EC1807D9C4005B8026 /* bang.png */; }; 46A174F51807D9C4005B8026 /* bang.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174EC1807D9C4005B8026 /* bang.png */; }; 46A174F81807D9C4005B8026 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 46A174EE1807D9C4005B8026 /* fonts */; }; 46A174F91807D9C4005B8026 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 46A174EE1807D9C4005B8026 /* fonts */; }; 46A174FA1807D9C4005B8026 /* ipad in Resources */ = {isa = PBXBuildFile; fileRef = 46A174EF1807D9C4005B8026 /* ipad */; }; 46A174FB1807D9C4005B8026 /* ipad in Resources */ = {isa = PBXBuildFile; fileRef = 46A174EF1807D9C4005B8026 /* ipad */; }; 46A174FC1807D9C4005B8026 /* ipadhd in Resources */ = {isa = PBXBuildFile; fileRef = 46A174F01807D9C4005B8026 /* ipadhd */; }; 46A174FD1807D9C4005B8026 /* ipadhd in Resources */ = {isa = PBXBuildFile; fileRef = 46A174F01807D9C4005B8026 /* ipadhd */; }; 46A174FE1807D9C4005B8026 /* iphone in Resources */ = {isa = PBXBuildFile; fileRef = 46A174F11807D9C4005B8026 /* iphone */; }; 46A174FF1807D9C4005B8026 /* iphone in Resources */ = {isa = PBXBuildFile; fileRef = 46A174F11807D9C4005B8026 /* iphone */; }; 46A175001807D9CB005B8026 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A174CD1807D934005B8026 /* main.cpp */; }; 46A175011807D9E2005B8026 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A174AC1807D934005B8026 /* AppController.mm */; }; 46A175021807D9E2005B8026 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 46A174BD1807D934005B8026 /* main.m */; }; 46A175031807D9E2005B8026 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A174BF1807D934005B8026 /* RootViewController.mm */; }; 5010FC91180F0F8300B8E2AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 46A174AD1807D934005B8026 /* Default-568h@2x.png */; }; 5010FC92180F105C00B8E2AE /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 460E452F1807E712000CDD6D /* Default-568h@2x.png */; }; 50691336184EB453009BBDD7 /* ConsoleTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50691334184EB453009BBDD7 /* ConsoleTest.cpp */; }; 50691337184EB453009BBDD7 /* ConsoleTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50691334184EB453009BBDD7 /* ConsoleTest.cpp */; }; 50D360FA186819DB00828878 /* CocosGUIScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360CA186819DB00828878 /* CocosGUIScene.cpp */; }; 50D360FB186819DB00828878 /* UIButtonTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360CD186819DB00828878 /* UIButtonTest.cpp */; }; 50D360FC186819DB00828878 /* UICheckBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360D0186819DB00828878 /* UICheckBoxTest.cpp */; }; 50D360FD186819DB00828878 /* UIImageViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360D3186819DB00828878 /* UIImageViewTest.cpp */; }; 50D360FE186819DB00828878 /* UILabelAtlasTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360D6186819DB00828878 /* UILabelAtlasTest.cpp */; }; 50D360FF186819DB00828878 /* UILabelBMFontTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360D9186819DB00828878 /* UILabelBMFontTest.cpp */; }; 50D36100186819DB00828878 /* UILabelTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360DC186819DB00828878 /* UILabelTest.cpp */; }; 50D36101186819DB00828878 /* UILayoutTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360DF186819DB00828878 /* UILayoutTest.cpp */; }; 50D36102186819DB00828878 /* UIListViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360E2186819DB00828878 /* UIListViewTest.cpp */; }; 50D36103186819DB00828878 /* UILoadingBarTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360E5186819DB00828878 /* UILoadingBarTest.cpp */; }; 50D36104186819DB00828878 /* UIPageViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360E8186819DB00828878 /* UIPageViewTest.cpp */; }; 50D36105186819DB00828878 /* UIScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360EA186819DB00828878 /* UIScene.cpp */; }; 50D36106186819DB00828878 /* UISceneManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360EC186819DB00828878 /* UISceneManager.cpp */; }; 50D36107186819DB00828878 /* UIScrollViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360EF186819DB00828878 /* UIScrollViewTest.cpp */; }; 50D36108186819DB00828878 /* UISliderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360F2186819DB00828878 /* UISliderTest.cpp */; }; 50D36109186819DB00828878 /* UITextFieldTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360F5186819DB00828878 /* UITextFieldTest.cpp */; }; 50D3610A186819DB00828878 /* UIWidgetAddNodeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D360F8186819DB00828878 /* UIWidgetAddNodeTest.cpp */; }; 599121E6182C74AC00CE785B /* NewRendererTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 599121E4182C74AC00CE785B /* NewRendererTest.cpp */; }; 599121E7182C74AC00CE785B /* NewRendererTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 599121E4182C74AC00CE785B /* NewRendererTest.cpp */; }; 59A79D5D1821E95C00F19697 /* MouseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A79D5B1821E95C00F19697 /* MouseTest.cpp */; }; 59A79D5E1821E95C00F19697 /* MouseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59A79D5B1821E95C00F19697 /* MouseTest.cpp */; }; A01E16881784BDA100B0CA4A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A01E16891784BDA100B0CA4A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A01E168A1784BDA100B0CA4A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A01E168D1784BDA100B0CA4A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A01E169B1784BE2400B0CA4A /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; A01E169C1784BE2800B0CA4A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; A01E169D1784BE2C00B0CA4A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; A01E169E1784BE3200B0CA4A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; A01E169F1784BE3A00B0CA4A /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A01E17661784C06E00B0CA4A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A01E17671784C06E00B0CA4A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A01E17681784C06E00B0CA4A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A01E17691784C06E00B0CA4A /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A01E176A1784C06E00B0CA4A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A01E176B1784C06E00B0CA4A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; A01E176C1784C06E00B0CA4A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; A01E176D1784C06E00B0CA4A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; A01E176E1784C06E00B0CA4A /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; A01E184B1784C45400B0CA4A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A01E184C1784C45400B0CA4A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A01E184D1784C45400B0CA4A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A01E184E1784C45400B0CA4A /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A01E184F1784C45400B0CA4A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A01E18501784C45400B0CA4A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; A01E18511784C45400B0CA4A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; A01E18521784C45400B0CA4A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; A01E18531784C45400B0CA4A /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; A01E18801784C4D600B0CA4A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A01E18811784C4D600B0CA4A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A01E18821784C4D600B0CA4A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A01E18831784C4D600B0CA4A /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A01E18841784C4D600B0CA4A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A01E18851784C4D600B0CA4A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; A01E18861784C4D600B0CA4A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; A01E18871784C4D600B0CA4A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; A01E18881784C4D600B0CA4A /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; A01E18B51784C4DC00B0CA4A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A01E18B61784C4DC00B0CA4A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A01E18B71784C4DC00B0CA4A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A01E18B81784C4DC00B0CA4A /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A01E18B91784C4DC00B0CA4A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A01E18BA1784C4DC00B0CA4A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; A01E18BB1784C4DC00B0CA4A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; A01E18BC1784C4DC00B0CA4A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; A01E18BD1784C4DC00B0CA4A /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; A01E18EA1784C4E000B0CA4A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A01E18EB1784C4E000B0CA4A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A01E18EC1784C4E000B0CA4A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A01E18ED1784C4E000B0CA4A /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A01E18EE1784C4E000B0CA4A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A01E18EF1784C4E000B0CA4A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; A01E18F01784C4E000B0CA4A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; A01E18F11784C4E000B0CA4A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; A01E18F21784C4E000B0CA4A /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; A01E18F81784C59400B0CA4A /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A01E18F91784C59400B0CA4A /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A01E18FA1784C59400B0CA4A /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A01E18FB1784C59500B0CA4A /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A01E18FC1784C59500B0CA4A /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A035A5E01782290400987F6C /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; A035A5E11782290400987F6C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A035A5E21782290400987F6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A035A5E31782290400987F6C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A035A5E41782290400987F6C /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; A035A5E51782290400987F6C /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A035A5E61782290400987F6C /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A035A5E71782290400987F6C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; A035A5E81782290400987F6C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A035A71217822E9E00987F6C /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A035A7701782301C00987F6C /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A035A7711782301C00987F6C /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; A035A7721782301C00987F6C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A035A7731782301C00987F6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A035A7741782301C00987F6C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A035A7751782301C00987F6C /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; A035A7761782301C00987F6C /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A035A7771782301C00987F6C /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A035A7781782301C00987F6C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; A035A7791782301C00987F6C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A035A9EA17823FE100987F6C /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A035A9EB17823FE100987F6C /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; A035A9EC17823FE100987F6C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A035A9ED17823FE100987F6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A035A9EE17823FE100987F6C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A035A9EF17823FE100987F6C /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; A035A9F017823FE100987F6C /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A035A9F117823FE100987F6C /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A035A9F217823FE100987F6C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; A035A9F317823FE100987F6C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A035AAB81782422400987F6C /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A035AAB91782422400987F6C /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; A035AABA1782422400987F6C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A035AABB1782422400987F6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A035AABC1782422400987F6C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A035AABD1782422400987F6C /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; A035AABE1782422400987F6C /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A035AABF1782422400987F6C /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A035AAC01782422400987F6C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; A035AAC11782422400987F6C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A035AC2A1782453000987F6C /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; A035AC2B1782453000987F6C /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; A035AC2C1782453000987F6C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A035AC2D1782453000987F6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A035AC2E1782453000987F6C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A035AC2F1782453000987F6C /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; A035AC301782453000987F6C /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A035AC311782453000987F6C /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A035AC321782453000987F6C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; A035AC331782453000987F6C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A035AD6A178254A300987F6C /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; A035AD6B178254A300987F6C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A035AD6C178254A300987F6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A035AD6D178254A300987F6C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A035AD6E178254A300987F6C /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; A035AD6F178254A300987F6C /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A035AD70178254A300987F6C /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A035AD71178254A300987F6C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; A035AD72178254A300987F6C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A035AE7C178255DC00987F6C /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; A035AE7D178255DC00987F6C /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A035AE7E178255DC00987F6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A035AE7F178255DC00987F6C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A035AE80178255DC00987F6C /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482A165F3979007D4F18 /* ApplicationServices.framework */; }; A035AE81178255DC00987F6C /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A035AE82178255DC00987F6C /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A035AE83178255DC00987F6C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; A035AE84178255DC00987F6C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A05FCACA177C124500BE600E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A07A521E1783A1D20073F6A7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A07A521F1783A1D20073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A07A52201783A1D20073F6A7 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A07A52221783A1D20073F6A7 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A07A52231783A1D20073F6A7 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A07A52BE1783AF1E0073F6A7 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; A07A52BF1783AF210073F6A7 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; A07A52C01783AF250073F6A7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; A07A52C31783B02C0073F6A7 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; A07A53751784AC9B0073F6A7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A07A53761784AC9B0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; A07A53771784AC9B0073F6A7 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482C165F3988007D4F18 /* AudioToolbox.framework */; }; A07A53781784AC9B0073F6A7 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; A07A53791784AC9B0073F6A7 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; A07A537A1784AC9B0073F6A7 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */; }; A07A537B1784AC9B0073F6A7 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B91783AE900073F6A7 /* OpenGLES.framework */; }; A07A537C1784AC9B0073F6A7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; A07A537D1784AC9B0073F6A7 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; D60AE43417F7FFE100757E4B /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D60AE43717F9142200757E4B /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D60AE43817F9143D00757E4B /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D6408CA8180650F200FB5B4C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D6408CAB1806510600FB5B4C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D6408CAC1806511F00FB5B4C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D6408CAD1806512D00FB5B4C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D6408CAE1806513A00FB5B4C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D6408CAF1806514400FB5B4C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; D6408CB01806515200FB5B4C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; ED3674B9187FA7020038ECFC /* PerformanceRendererTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED3674B8187FA7020038ECFC /* PerformanceRendererTest.cpp */; }; ED3674BA187FA7020038ECFC /* PerformanceRendererTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED3674B8187FA7020038ECFC /* PerformanceRendererTest.cpp */; }; ED743D1517D098AF0004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; ED743D1617D098B60004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; ED743D1717D099F10004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; ED743D1917D09A390004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; ED743D1A17D09A730004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; ED743D1B17D09AAE0004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; ED743D1C17D09C990004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; ED743D1D17D09CD40004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; ED743D1E17D09D070004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; EDCC747F17C455FD007B692C /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 1A3B1DE8180E7C9C00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 1A3B1DEA180E7C9C00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 1A3B1DEC180E7C9C00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 1A3B1DEE180E7C9C00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 1A3B1DF0180E7C9C00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F31E81781479B006731B9; remoteInfo = "jsbindings Mac"; }; 1A3B1E0A180E7E1D00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 1A3B1E0C180E7E1D00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 1A3B1E0E180E7E1D00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 1A3B1E10180E7E1D00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 1A3B1E12180E7E1D00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4FB5178387750073F6A7; remoteInfo = "jsbindings iOS"; }; 1A3B1E6F180E7F3E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 1A3B1E71180E7F3E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 1A3B1E73180E7F3E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 1A3B1E75180E7F3E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 1A3B1E77180E7F3E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F31E81781479B006731B9; remoteInfo = "jsbindings Mac"; }; 1A3B1E85180E804400497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 1A3B1E87180E804400497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 1A3B1E89180E804400497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 1A3B1E8B180E804400497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 1A3B1E8D180E804400497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4FB5178387750073F6A7; remoteInfo = "jsbindings iOS"; }; 1A3B1ED2180E810E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 1A3B1ED4180E810E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 1A3B1ED6180E810E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 1A3B1ED8180E810E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 1A3B1EDA180E810E00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F31E81781479B006731B9; remoteInfo = "jsbindings Mac"; }; 1A3B1EE1180E81AA00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 1A3B1EE3180E81AA00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 1A3B1EE5180E81AA00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 1A3B1EE7180E81AA00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 1A3B1EE9180E81AA00497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4FB5178387750073F6A7; remoteInfo = "jsbindings iOS"; }; 1A3B1F2A180E82B800497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 1A3B1F2C180E82B800497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 1A3B1F2E180E82B800497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 1A3B1F30180E82B800497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 1A3B1F32180E82B800497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F31E81781479B006731B9; remoteInfo = "jsbindings Mac"; }; 1A3B1F39180E82D200497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 1A3B1F3B180E82D200497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 1A3B1F3D180E82D200497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 1A3B1F3F180E82D200497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 1A3B1F41180E82D200497A22 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4FB5178387750073F6A7; remoteInfo = "jsbindings iOS"; }; 1A6FB50017854AEA00CDF010 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = 1A1197B31785363400D62A44; remoteInfo = "Hello lua iOS"; }; 1A6FB50217854AEA00CDF010 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = 1A11982D178538E400D62A44; remoteInfo = "Test lua iOS"; }; 1A6FB7E21785682700CDF010 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = 1A6FB53517854FE400CDF010; remoteInfo = "Hello lua Mac"; }; 1A6FB7E41785682700CDF010 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = 1A6FB7821785614200CDF010; remoteInfo = "Test lua Mac"; }; 1A8C55BA180E8BA400EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 1A8C55BC180E8BA400EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 1A8C55BE180E8BA400EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 1A8C55C0180E8BA400EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 1A8C55C2180E8BA400EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1A6FB50417854BC200CDF010; remoteInfo = "luabindings Mac"; }; 1A8C565C180E8DFB00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 1A8C565E180E8DFB00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 1A8C5660180E8DFB00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 1A8C5662180E8DFB00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 1A8C5664180E8DFB00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1A119716178526AA00D62A44; remoteInfo = "luabindings iOS"; }; 1A8C5880180E8F5F00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 1A8C5882180E8F5F00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 1A8C5884180E8F5F00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 1A8C5886180E8F5F00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 1A8C5888180E8F5F00EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1A6FB50417854BC200CDF010; remoteInfo = "luabindings Mac"; }; 1A8C588F180E8F8000EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 1A8C5891180E8F8000EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 1A8C5893180E8F8000EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 1A8C5895180E8F8000EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 1A8C5897180E8F8000EF57C3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1A119716178526AA00D62A44; remoteInfo = "luabindings iOS"; }; 1A9DC9E7180E68CE007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 1A9DC9E9180E68CE007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 1A9DC9EB180E68CE007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 1A9DC9ED180E68CE007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 1A9DC9EF180E68CE007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F31E81781479B006731B9; remoteInfo = "jsbindings Mac"; }; 1A9DCA56180E743F007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 1A9DCA58180E743F007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 1A9DCA5A180E743F007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 1A9DCA5C180E743F007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 1A9DCA5E180E743F007A3AD4 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4FB5178387750073F6A7; remoteInfo = "jsbindings iOS"; }; 1AAF5341180E2F41000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 1AAF5343180E2F41000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2FC117814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 1AAF5345180E2F41000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2B781780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 1AAF5347180E2F41000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2D5D1780BDF7006731B9; remoteInfo = "box2d Mac"; }; 1AAF5349180E2F41000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 1AAF53F4180E39C6000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 1AAF53F6180E39C6000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4E111783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 1AAF53F8180E39C6000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4EFD178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 1AAF53FA180E39C6000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F3C1783876B0073F6A7; remoteInfo = "box2d iOS"; }; 1AAF53FC180E39C6000584C8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 460E44B91807DCCC000CDD6D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 460E44FB1807E408000CDD6D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 460E44FE1807E656000CDD6D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4C241783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 460E45821807FDB0000CDD6D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = 1551A33E158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 460E45841807FDB0000CDD6D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A03F2E9817814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 460E45DD18080218000CDD6D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 1; remoteGlobalIDString = A07A4F9F178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 46A15FAF1807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = 1551A33F158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; 46A15FB11807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F2FD617814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; 46A15FB31807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F2CB81780BD04006731B9; remoteInfo = "chipmunk Mac"; }; 46A15FB51807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F2D9B1780BDF7006731B9; remoteInfo = "box2d Mac"; }; 46A15FB71807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F2ED617814268006731B9; remoteInfo = "CocosDenshion Mac"; }; 46A15FB91807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F31FD1781479B006731B9; remoteInfo = "jsbindings Mac"; }; 46A15FBB1807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = 1A6FB53017854BC300CDF010; remoteInfo = "luabindings Mac"; }; 46A15FBD1807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4D641783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; 46A15FBF1807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4EFC1783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; 46A15FC11807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4F3B178387670073F6A7; remoteInfo = "chipmunk iOS"; }; 46A15FC31807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4F9E1783876B0073F6A7; remoteInfo = "box2d iOS"; }; 46A15FC51807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4FB4178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; 46A15FC71807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A5030178387750073F6A7; remoteInfo = "jsbindings iOS"; }; 46A15FC91807A4F9005B8026 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = 1A119791178526AA00D62A44; remoteInfo = "luabindings iOS"; }; A01E17E11784C3EB00B0CA4A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A07A52CF1784AC9B0073F6A7; remoteInfo = "Hello cpp iOS"; }; A01E17E31784C3EB00B0CA4A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A01E16631784BDA100B0CA4A; remoteInfo = "Simple Game iOS"; }; A01E17E51784C3EB00B0CA4A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A01E16C01784C06E00B0CA4A; remoteInfo = "Test JavaScript iOS"; }; A01E19961784C8DD00B0CA4A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A01E17E71784C45400B0CA4A; remoteInfo = "JS Watermelon With Me iOS"; }; A01E19981784C8DD00B0CA4A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A01E18591784C4D600B0CA4A; remoteInfo = "JS Moon Warriors iOS"; }; A01E199A1784C8DD00B0CA4A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A01E188E1784C4DC00B0CA4A; remoteInfo = "JS Crystal Craze iOS"; }; A01E199C1784C8DD00B0CA4A /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A01E18C31784C4E000B0CA4A; remoteInfo = "JS CocosDragon iOS"; }; A035ACBF178246BD00987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = 1D6058900D05DD3D006BFB54; remoteInfo = "Test cpp"; }; A035ACC1178246BD00987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A035A5441782290400987F6C; remoteInfo = "Test JavaScript"; }; A035ACC3178246BD00987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A035A7131782301C00987F6C; remoteInfo = "JS Watermelon With Me"; }; A035ACC5178246BD00987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A035A9BA17823FE100987F6C; remoteInfo = "JS Moon Warriors"; }; A035ACC7178246BD00987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A035AA8D1782422400987F6C; remoteInfo = "JS Crystal Craze"; }; A035ACC9178246BD00987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A035AC021782453000987F6C; remoteInfo = "JS CocosDragon"; }; A035AF721782569500987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A035AE58178255DC00987F6C; remoteInfo = "Hello cpp"; }; A035AF741782569500987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A035ACCE178254A300987F6C; remoteInfo = "Simple Game"; }; A07A526C1783AB980073F6A7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; remoteGlobalIDString = A07A517F1783A1D20073F6A7; remoteInfo = "Test cpp iOS"; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 15394DF2182E8F5D000A418D /* StudioConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = StudioConstants.lua; path = ../cocos/scripting/lua/script/StudioConstants.lua; sourceTree = ""; }; 1585AAC61821F8D900000FB5 /* LuaObjectCBridgeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaObjectCBridgeTest.h; sourceTree = ""; }; 1585AAC71821F8D900000FB5 /* LuaObjectCBridgeTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LuaObjectCBridgeTest.mm; sourceTree = ""; }; 1585AB101821FA1A00000FB5 /* luaoc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaoc.lua; path = ../cocos/scripting/lua/script/luaoc.lua; sourceTree = ""; }; 1585AB161821FF4C00000FB5 /* LuaObjectCBridgeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaObjectCBridgeTest.h; sourceTree = ""; }; 1585AB171821FF4C00000FB5 /* LuaObjectCBridgeTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LuaObjectCBridgeTest.mm; sourceTree = ""; }; 1585AB34182299FA00000FB5 /* json.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = json.lua; path = ../cocos/scripting/lua/script/json.lua; sourceTree = ""; }; 1585AB491823A55400000FB5 /* lua_assetsmanager_test_sample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_assetsmanager_test_sample.cpp; sourceTree = ""; }; 1585AB4A1823A55400000FB5 /* lua_assetsmanager_test_sample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_assetsmanager_test_sample.h; sourceTree = ""; }; 15982CE1187656CD00625972 /* GuiConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = GuiConstants.lua; path = ../cocos/scripting/lua/script/GuiConstants.lua; sourceTree = ""; }; 15A71DB61894AE6200F30AC0 /* mobdebug.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mobdebug.lua; sourceTree = ""; }; 15C64822165F391E007D4F18 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; 15C64824165F3934007D4F18 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework; sourceTree = DEVELOPER_DIR; }; 15C64826165F394E007D4F18 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; }; 15C64828165F396B007D4F18 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenAL.framework; sourceTree = DEVELOPER_DIR; }; 15C6482A165F3979007D4F18 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/ApplicationServices.framework; sourceTree = DEVELOPER_DIR; }; 15C6482C165F3988007D4F18 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AudioToolbox.framework; sourceTree = DEVELOPER_DIR; }; 15C6482E165F399D007D4F18 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; }; 15C64832165F3AFD007D4F18 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; 15F4C82818751B590082884F /* extern.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = extern.lua; path = ../cocos/scripting/lua/script/extern.lua; sourceTree = ""; }; 15F4C846187551340082884F /* CocoStudio.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CocoStudio.lua; path = ../cocos/scripting/lua/script/CocoStudio.lua; sourceTree = ""; }; 1A0800BC18780B2A00E62F93 /* cocosbuilderRes */ = {isa = PBXFileReference; lastKnownFileType = folder; path = cocosbuilderRes; sourceTree = ""; }; 1A0800BD18780B2A00E62F93 /* luaScript */ = {isa = PBXFileReference; lastKnownFileType = folder; path = luaScript; sourceTree = ""; }; 1A087AEC1860418300196EF5 /* PerformanceLabelTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceLabelTest.cpp; sourceTree = ""; }; 1A087AED1860418300196EF5 /* PerformanceLabelTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceLabelTest.h; sourceTree = ""; }; 1A1197D71785363400D62A44 /* Hello lua iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Hello lua iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1A119870178538E400D62A44 /* Test lua iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Test lua iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1A2F51AF1877DA5900B48BFE /* tests */ = {isa = PBXFileReference; lastKnownFileType = folder; name = tests; path = ../samples/Javascript/Shared/tests; sourceTree = ""; }; 1A3B1DB1180E7C4700497A22 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1A3B1DB2180E7C4700497A22 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1A3B1DB6180E7C5100497A22 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 1A3B1DB7180E7C5100497A22 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 1A3B1DB8180E7C5100497A22 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 1A3B1DB9180E7C5100497A22 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 1A3B1DBA180E7C5100497A22 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 1A3B1DBB180E7C5100497A22 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 1A3B1DBC180E7C5100497A22 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 1A3B1DBD180E7C5100497A22 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 1A3B1DBE180E7C5100497A22 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 1A3B1DBF180E7C5100497A22 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 1A3B1DC0180E7C5100497A22 /* Icon-Small-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small-50.png"; sourceTree = ""; }; 1A3B1DC1180E7C5100497A22 /* Icon-Small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small.png"; sourceTree = ""; }; 1A3B1DC2180E7C5100497A22 /* Icon-Small@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small@2x.png"; sourceTree = ""; }; 1A3B1DC3180E7C5100497A22 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; 1A3B1DC4180E7C5100497A22 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; }; 1A3B1DC5180E7C5100497A22 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A3B1DC6180E7C5100497A22 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 1A3B1DC7180E7C5100497A22 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 1A3B1DC8180E7C5100497A22 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 1A3B1DC9180E7C5100497A22 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 1A3B1DDD180E7C5C00497A22 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 1A3B1DDF180E7C5C00497A22 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 1A3B1DE0180E7C5C00497A22 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1A3B1DE1180E7C5C00497A22 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A3B1DE2180E7C5C00497A22 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1A3B1DF8180E7D2200497A22 /* MoonWarriors-jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "MoonWarriors-jsb.js"; path = "../samples/Javascript/Shared/games/MoonWarriors/MoonWarriors-jsb.js"; sourceTree = ""; }; 1A3B1DF9180E7D2200497A22 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = res; path = ../samples/Javascript/Shared/games/MoonWarriors/res; sourceTree = ""; }; 1A3B1DFA180E7D2200497A22 /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = ../samples/Javascript/Shared/games/MoonWarriors/src; sourceTree = ""; }; 1A3B1E1C180E7EFA00497A22 /* boot-html5.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "boot-html5.js"; path = "../samples/Javascript/Shared/games/WatermelonWithMe/boot-html5.js"; sourceTree = ""; }; 1A3B1E1D180E7EFA00497A22 /* boot-jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "boot-jsb.js"; path = "../samples/Javascript/Shared/games/WatermelonWithMe/boot-jsb.js"; sourceTree = ""; }; 1A3B1E1E180E7EFA00497A22 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = index.html; path = ../samples/Javascript/Shared/games/WatermelonWithMe/index.html; sourceTree = ""; }; 1A3B1E1F180E7EFA00497A22 /* levels.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = levels.js; path = ../samples/Javascript/Shared/games/WatermelonWithMe/levels.js; sourceTree = ""; }; 1A3B1E20180E7EFA00497A22 /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = ../samples/Javascript/Shared/games/WatermelonWithMe/main.js; sourceTree = ""; }; 1A3B1E21180E7EFA00497A22 /* Platform */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Platform; path = ../samples/Javascript/Shared/games/WatermelonWithMe/Platform; sourceTree = ""; }; 1A3B1E22180E7EFA00497A22 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = res; path = ../samples/Javascript/Shared/games/WatermelonWithMe/res; sourceTree = ""; }; 1A3B1E23180E7EFA00497A22 /* resources-html5.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "resources-html5.js"; path = "../samples/Javascript/Shared/games/WatermelonWithMe/resources-html5.js"; sourceTree = ""; }; 1A3B1E24180E7EFA00497A22 /* resources-jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "resources-jsb.js"; path = "../samples/Javascript/Shared/games/WatermelonWithMe/resources-jsb.js"; sourceTree = ""; }; 1A3B1E25180E7EFA00497A22 /* watermelon_with_me.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = watermelon_with_me.js; path = ../samples/Javascript/Shared/games/WatermelonWithMe/watermelon_with_me.js; sourceTree = ""; }; 1A3B1E3E180E7F1500497A22 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1A3B1E3F180E7F1500497A22 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1A3B1E43180E7F1E00497A22 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 1A3B1E44180E7F1E00497A22 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 1A3B1E45180E7F1E00497A22 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 1A3B1E46180E7F1E00497A22 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 1A3B1E47180E7F1E00497A22 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 1A3B1E48180E7F1E00497A22 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 1A3B1E49180E7F1E00497A22 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 1A3B1E4A180E7F1E00497A22 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 1A3B1E4B180E7F1E00497A22 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 1A3B1E4C180E7F1E00497A22 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 1A3B1E4D180E7F1E00497A22 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 1A3B1E4E180E7F1E00497A22 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 1A3B1E4F180E7F1E00497A22 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A3B1E50180E7F1E00497A22 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 1A3B1E51180E7F1E00497A22 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 1A3B1E52180E7F1E00497A22 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 1A3B1E53180E7F1E00497A22 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 1A3B1E64180E7F2400497A22 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 1A3B1E66180E7F2400497A22 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 1A3B1E67180E7F2400497A22 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1A3B1E68180E7F2400497A22 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A3B1E69180E7F2400497A22 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1A3B1E9D180E80B600497A22 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1A3B1E9E180E80B600497A22 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1A3B1EA2180E80BD00497A22 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 1A3B1EA3180E80BD00497A22 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 1A3B1EA4180E80BD00497A22 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 1A3B1EA5180E80BD00497A22 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 1A3B1EA6180E80BD00497A22 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 1A3B1EA7180E80BD00497A22 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 1A3B1EA8180E80BD00497A22 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 1A3B1EA9180E80BD00497A22 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 1A3B1EAA180E80BD00497A22 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 1A3B1EAB180E80BD00497A22 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 1A3B1EAC180E80BD00497A22 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 1A3B1EAD180E80BD00497A22 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 1A3B1EAE180E80BD00497A22 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A3B1EAF180E80BD00497A22 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 1A3B1EB0180E80BD00497A22 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 1A3B1EB1180E80BD00497A22 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 1A3B1EB2180E80BD00497A22 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 1A3B1EC3180E80C700497A22 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 1A3B1EC5180E80C700497A22 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 1A3B1EC6180E80C700497A22 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1A3B1EC7180E80C700497A22 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A3B1EC8180E80C700497A22 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1A3B1ECF180E80E200497A22 /* Published files iOS */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Published files iOS"; path = "../samples/Javascript/Shared/games/CocosDragonJS/Published files iOS"; sourceTree = ""; }; 1A3B1EF2180E826E00497A22 /* Published-iOS */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Published-iOS"; path = "../samples/Javascript/Shared/games/CrystalCraze/Published-iOS"; sourceTree = ""; }; 1A3B1EF9180E828300497A22 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1A3B1EFA180E828300497A22 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1A3B1EFE180E828E00497A22 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 1A3B1EFF180E828E00497A22 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 1A3B1F00180E828E00497A22 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 1A3B1F01180E828E00497A22 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 1A3B1F02180E828E00497A22 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 1A3B1F03180E828E00497A22 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 1A3B1F04180E828E00497A22 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 1A3B1F05180E828E00497A22 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 1A3B1F06180E828E00497A22 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 1A3B1F07180E828E00497A22 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 1A3B1F08180E828E00497A22 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 1A3B1F09180E828E00497A22 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 1A3B1F0A180E828E00497A22 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A3B1F0B180E828E00497A22 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 1A3B1F0C180E828E00497A22 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 1A3B1F0D180E828E00497A22 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 1A3B1F0E180E828E00497A22 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 1A3B1F1F180E829600497A22 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 1A3B1F21180E829600497A22 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 1A3B1F22180E829600497A22 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1A3B1F23180E829600497A22 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A3B1F24180E829600497A22 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1A6A41DF180BE41100565AC2 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1A6A41E0180BE41100565AC2 /* AppDelegate.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = AppDelegate.h; sourceTree = ""; }; 1A6A41E1180BE41100565AC2 /* GameOverScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GameOverScene.cpp; sourceTree = ""; }; 1A6A41E2180BE41100565AC2 /* GameOverScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameOverScene.h; sourceTree = ""; }; 1A6A41E3180BE41100565AC2 /* HelloWorldScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HelloWorldScene.cpp; sourceTree = ""; }; 1A6A41E4180BE41100565AC2 /* HelloWorldScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloWorldScene.h; sourceTree = ""; }; 1A6FB56B17854FE400CDF010 /* Hello lua Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Hello lua Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1A6FB7B31785614200CDF010 /* Test lua Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Test lua Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1A80519518768FD300C117B5 /* UnitTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnitTest.cpp; path = UnitTest/UnitTest.cpp; sourceTree = ""; }; 1A80519618768FD300C117B5 /* UnitTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnitTest.h; path = UnitTest/UnitTest.h; sourceTree = ""; }; 1A8C5530180E8B1C00EF57C3 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1A8C5531180E8B1C00EF57C3 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1A8C5539180E8B3D00EF57C3 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 1A8C553A180E8B3D00EF57C3 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 1A8C553B180E8B3D00EF57C3 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 1A8C553C180E8B3D00EF57C3 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 1A8C553D180E8B3D00EF57C3 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 1A8C553E180E8B3D00EF57C3 /* HelloLua_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloLua_Prefix.pch; sourceTree = ""; }; 1A8C553F180E8B3D00EF57C3 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 1A8C5540180E8B3D00EF57C3 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 1A8C5541180E8B3D00EF57C3 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 1A8C5542180E8B3D00EF57C3 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 1A8C5543180E8B3D00EF57C3 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 1A8C5544180E8B3D00EF57C3 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 1A8C5545180E8B3D00EF57C3 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 1A8C5546180E8B3D00EF57C3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A8C5547180E8B3D00EF57C3 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 1A8C5548180E8B3D00EF57C3 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 1A8C5549180E8B3D00EF57C3 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 1A8C555A180E8B4500EF57C3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 1A8C555C180E8B4500EF57C3 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 1A8C555D180E8B4500EF57C3 /* HelloLua_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloLua_Prefix.pch; sourceTree = ""; }; 1A8C555E180E8B4500EF57C3 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1A8C555F180E8B4500EF57C3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A8C5560180E8B4500EF57C3 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1A8C5567180E8B5100EF57C3 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 1A8C5569180E8B5100EF57C3 /* background.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = background.mp3; sourceTree = ""; }; 1A8C556A180E8B5100EF57C3 /* background.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = background.ogg; sourceTree = ""; }; 1A8C556B180E8B5100EF57C3 /* crop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = crop.png; sourceTree = ""; }; 1A8C556D180E8B5100EF57C3 /* dog.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dog.png; sourceTree = ""; }; 1A8C556E180E8B5100EF57C3 /* effect1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = effect1.wav; sourceTree = ""; }; 1A8C556F180E8B5100EF57C3 /* farm.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = farm.jpg; sourceTree = ""; }; 1A8C5571180E8B5100EF57C3 /* Marker Felt.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Marker Felt.ttf"; sourceTree = ""; }; 1A8C5572180E8B5100EF57C3 /* hello.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = hello.lua; sourceTree = ""; }; 1A8C5573180E8B5100EF57C3 /* hello2.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = hello2.lua; sourceTree = ""; }; 1A8C5574180E8B5100EF57C3 /* land.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = land.png; sourceTree = ""; }; 1A8C5575180E8B5100EF57C3 /* menu1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu1.png; sourceTree = ""; }; 1A8C5576180E8B5100EF57C3 /* menu2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu2.png; sourceTree = ""; }; 1A8C5596180E8B8400EF57C3 /* AudioEngine.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AudioEngine.lua; path = ../cocos/scripting/lua/script/AudioEngine.lua; sourceTree = ""; }; 1A8C5597180E8B8400EF57C3 /* CCBReaderLoad.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CCBReaderLoad.lua; path = ../cocos/scripting/lua/script/CCBReaderLoad.lua; sourceTree = ""; }; 1A8C5598180E8B8400EF57C3 /* Cocos2d.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2d.lua; path = ../cocos/scripting/lua/script/Cocos2d.lua; sourceTree = ""; }; 1A8C5599180E8B8400EF57C3 /* Cocos2dConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2dConstants.lua; path = ../cocos/scripting/lua/script/Cocos2dConstants.lua; sourceTree = ""; }; 1A8C559A180E8B8400EF57C3 /* Deprecated.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Deprecated.lua; path = ../cocos/scripting/lua/script/Deprecated.lua; sourceTree = ""; }; 1A8C559B180E8B8400EF57C3 /* DeprecatedClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedClass.lua; path = ../cocos/scripting/lua/script/DeprecatedClass.lua; sourceTree = ""; }; 1A8C559C180E8B8400EF57C3 /* DeprecatedEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedEnum.lua; path = ../cocos/scripting/lua/script/DeprecatedEnum.lua; sourceTree = ""; }; 1A8C559D180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedOpenglEnum.lua; path = ../cocos/scripting/lua/script/DeprecatedOpenglEnum.lua; sourceTree = ""; }; 1A8C559E180E8B8400EF57C3 /* DrawPrimitives.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DrawPrimitives.lua; path = ../cocos/scripting/lua/script/DrawPrimitives.lua; sourceTree = ""; }; 1A8C559F180E8B8400EF57C3 /* luaj.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaj.lua; path = ../cocos/scripting/lua/script/luaj.lua; sourceTree = ""; }; 1A8C55A0180E8B8400EF57C3 /* Opengl.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Opengl.lua; path = ../cocos/scripting/lua/script/Opengl.lua; sourceTree = ""; }; 1A8C55A1180E8B8400EF57C3 /* OpenglConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OpenglConstants.lua; path = ../cocos/scripting/lua/script/OpenglConstants.lua; sourceTree = ""; }; 1A8C566D180E8E9600EF57C3 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1A8C566E180E8E9600EF57C3 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1A8C5853180E8F0100EF57C3 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 1A8C5854180E8F0100EF57C3 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 1A8C5855180E8F0100EF57C3 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 1A8C5856180E8F0100EF57C3 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 1A8C5857180E8F0100EF57C3 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 1A8C5858180E8F0100EF57C3 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 1A8C5859180E8F0100EF57C3 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 1A8C585A180E8F0100EF57C3 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 1A8C585B180E8F0100EF57C3 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 1A8C585C180E8F0100EF57C3 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 1A8C585D180E8F0100EF57C3 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 1A8C585E180E8F0100EF57C3 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 1A8C585F180E8F0100EF57C3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A8C5860180E8F0100EF57C3 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 1A8C5861180E8F0100EF57C3 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 1A8C5862180E8F0100EF57C3 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 1A8C5863180E8F0100EF57C3 /* TestLua_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestLua_Prefix.pch; sourceTree = ""; }; 1A8C5874180E8F0C00EF57C3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 1A8C5876180E8F0C00EF57C3 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 1A8C5877180E8F0C00EF57C3 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1A8C5878180E8F0C00EF57C3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A8C5879180E8F0C00EF57C3 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1A8C587A180E8F0C00EF57C3 /* TestLua_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestLua_Prefix.pch; sourceTree = ""; }; 1A91419B180BEB6A00CFC31F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = InfoPlist.strings; sourceTree = ""; }; 1A91419D180BEB6A00CFC31F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = MainMenu.xib; sourceTree = ""; }; 1A91419E180BEB6A00CFC31F /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = Icon.icns; path = proj.mac/Icon.icns; sourceTree = ""; }; 1A91419F180BEB6A00CFC31F /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = proj.mac/main.cpp; sourceTree = ""; }; 1A9141A0180BEB6A00CFC31F /* SampleGame_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SampleGame_Prefix.pch; path = proj.mac/SampleGame_Prefix.pch; sourceTree = ""; }; 1A9DC2A1180E65D4007A3AD4 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1A9DC2A2180E65D4007A3AD4 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1A9DC2A7180E6681007A3AD4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 1A9DC2A9180E6681007A3AD4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 1A9DC2AA180E6681007A3AD4 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1A9DC2AB180E6681007A3AD4 /* Info-obfuscated.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-obfuscated.plist"; sourceTree = ""; }; 1A9DC2AC180E6681007A3AD4 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1A9DC2AD180E6681007A3AD4 /* Test_Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Test_Info.plist; sourceTree = ""; }; 1A9DC2AE180E6681007A3AD4 /* Test_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test_Prefix.pch; sourceTree = ""; }; 1A9DC2B6180E668B007A3AD4 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 1A9DC2B7180E668B007A3AD4 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 1A9DC2B8180E668B007A3AD4 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 1A9DC2B9180E668B007A3AD4 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 1A9DC2BA180E668B007A3AD4 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 1A9DC2BB180E668B007A3AD4 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 1A9DC2BC180E668B007A3AD4 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 1A9DC2BD180E668B007A3AD4 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 1A9DC2BE180E668B007A3AD4 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 1A9DC2BF180E668B007A3AD4 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 1A9DC2C0180E668B007A3AD4 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 1A9DC2C1180E668B007A3AD4 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 1A9DC2C2180E668B007A3AD4 /* Info-obfuscated.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-obfuscated.plist"; sourceTree = ""; }; 1A9DC2C3180E668B007A3AD4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1A9DC2C4180E668B007A3AD4 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 1A9DC2C5180E668B007A3AD4 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 1A9DC2C6180E668B007A3AD4 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 1A9DC2C7180E668B007A3AD4 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 1A9DC9E4180E6742007A3AD4 /* script */ = {isa = PBXFileReference; lastKnownFileType = folder; name = script; path = ../cocos/scripting/javascript/script; sourceTree = ""; }; 1A9F808C177E98A600D9A1CB /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; 1AAF4FA7180E2C17000584C8 /* AccelerometerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccelerometerTest.cpp; sourceTree = ""; }; 1AAF4FA8180E2C17000584C8 /* AccelerometerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccelerometerTest.h; sourceTree = ""; }; 1AAF4FAA180E2C17000584C8 /* ActionManagerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActionManagerTest.cpp; sourceTree = ""; }; 1AAF4FAB180E2C17000584C8 /* ActionManagerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionManagerTest.h; sourceTree = ""; }; 1AAF4FAD180E2C17000584C8 /* ActionsEaseTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActionsEaseTest.cpp; sourceTree = ""; }; 1AAF4FAE180E2C17000584C8 /* ActionsEaseTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionsEaseTest.h; sourceTree = ""; }; 1AAF4FB0180E2C17000584C8 /* ActionsProgressTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActionsProgressTest.cpp; sourceTree = ""; }; 1AAF4FB1180E2C17000584C8 /* ActionsProgressTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionsProgressTest.h; sourceTree = ""; }; 1AAF4FB3180E2C17000584C8 /* ActionsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ActionsTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF4FB4180E2C17000584C8 /* ActionsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionsTest.h; sourceTree = ""; }; 1AAF4FB5180E2C17000584C8 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 1AAF4FB6180E2C17000584C8 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 1AAF4FB7180E2C17000584C8 /* BaseTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseTest.cpp; sourceTree = ""; }; 1AAF4FB8180E2C17000584C8 /* BaseTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseTest.h; sourceTree = ""; }; 1AAF4FBA180E2C17000584C8 /* Box2dTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Box2dTest.cpp; sourceTree = ""; }; 1AAF4FBB180E2C17000584C8 /* Box2dTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Box2dTest.h; sourceTree = ""; }; 1AAF4FBD180E2C17000584C8 /* Box2dView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = Box2dView.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF4FBE180E2C17000584C8 /* Box2dView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Box2dView.h; sourceTree = ""; }; 1AAF4FBF180E2C17000584C8 /* GLES-Render.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "GLES-Render.cpp"; sourceTree = ""; }; 1AAF4FC0180E2C17000584C8 /* GLES-Render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GLES-Render.h"; sourceTree = ""; }; 1AAF4FC1180E2C17000584C8 /* Test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Test.cpp; sourceTree = ""; }; 1AAF4FC2180E2C17000584C8 /* Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test.h; sourceTree = ""; }; 1AAF4FC3180E2C17000584C8 /* TestEntries.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestEntries.cpp; sourceTree = ""; }; 1AAF4FC5180E2C17000584C8 /* AddPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddPair.h; sourceTree = ""; }; 1AAF4FC6180E2C17000584C8 /* ApplyForce.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyForce.h; sourceTree = ""; }; 1AAF4FC7180E2C17000584C8 /* BodyTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BodyTypes.h; sourceTree = ""; }; 1AAF4FC8180E2C17000584C8 /* Breakable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakable.h; sourceTree = ""; }; 1AAF4FC9180E2C17000584C8 /* Bridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bridge.h; sourceTree = ""; }; 1AAF4FCA180E2C17000584C8 /* BulletTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BulletTest.h; sourceTree = ""; }; 1AAF4FCB180E2C17000584C8 /* Cantilever.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cantilever.h; sourceTree = ""; }; 1AAF4FCC180E2C17000584C8 /* Car.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Car.h; sourceTree = ""; }; 1AAF4FCD180E2C17000584C8 /* Chain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Chain.h; sourceTree = ""; }; 1AAF4FCE180E2C17000584C8 /* CharacterCollision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CharacterCollision.h; sourceTree = ""; }; 1AAF4FCF180E2C17000584C8 /* CollisionFiltering.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollisionFiltering.h; sourceTree = ""; }; 1AAF4FD0180E2C17000584C8 /* CollisionProcessing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollisionProcessing.h; sourceTree = ""; }; 1AAF4FD1180E2C17000584C8 /* CompoundShapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompoundShapes.h; sourceTree = ""; }; 1AAF4FD2180E2C17000584C8 /* Confined.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Confined.h; sourceTree = ""; }; 1AAF4FD3180E2C17000584C8 /* ContinuousTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContinuousTest.h; sourceTree = ""; }; 1AAF4FD4180E2C17000584C8 /* DistanceTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DistanceTest.h; sourceTree = ""; }; 1AAF4FD5180E2C17000584C8 /* Dominos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dominos.h; sourceTree = ""; }; 1AAF4FD6180E2C17000584C8 /* DumpShell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpShell.h; sourceTree = ""; }; 1AAF4FD7180E2C17000584C8 /* DynamicTreeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicTreeTest.h; sourceTree = ""; }; 1AAF4FD8180E2C17000584C8 /* EdgeShapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EdgeShapes.h; sourceTree = ""; }; 1AAF4FD9180E2C17000584C8 /* EdgeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EdgeTest.h; sourceTree = ""; }; 1AAF4FDA180E2C17000584C8 /* Gears.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gears.h; sourceTree = ""; }; 1AAF4FDB180E2C17000584C8 /* OneSidedPlatform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OneSidedPlatform.h; sourceTree = ""; }; 1AAF4FDC180E2C17000584C8 /* Pinball.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pinball.h; sourceTree = ""; }; 1AAF4FDD180E2C17000584C8 /* PolyCollision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyCollision.h; sourceTree = ""; }; 1AAF4FDE180E2C17000584C8 /* PolyShapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolyShapes.h; sourceTree = ""; }; 1AAF4FDF180E2C17000584C8 /* Prismatic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prismatic.h; sourceTree = ""; }; 1AAF4FE0180E2C17000584C8 /* Pulleys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pulleys.h; sourceTree = ""; }; 1AAF4FE1180E2C17000584C8 /* Pyramid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pyramid.h; sourceTree = ""; }; 1AAF4FE2180E2C17000584C8 /* RayCast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RayCast.h; sourceTree = ""; }; 1AAF4FE3180E2C17000584C8 /* Revolute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Revolute.h; sourceTree = ""; }; 1AAF4FE4180E2C17000584C8 /* Rope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Rope.h; sourceTree = ""; }; 1AAF4FE5180E2C17000584C8 /* RopeJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RopeJoint.h; sourceTree = ""; }; 1AAF4FE6180E2C17000584C8 /* SensorTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SensorTest.h; sourceTree = ""; }; 1AAF4FE7180E2C17000584C8 /* ShapeEditing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeEditing.h; sourceTree = ""; }; 1AAF4FE8180E2C17000584C8 /* SliderCrank.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderCrank.h; sourceTree = ""; }; 1AAF4FE9180E2C17000584C8 /* SphereStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SphereStack.h; sourceTree = ""; }; 1AAF4FEA180E2C17000584C8 /* TheoJansen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TheoJansen.h; sourceTree = ""; }; 1AAF4FEB180E2C17000584C8 /* Tiles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tiles.h; sourceTree = ""; }; 1AAF4FEC180E2C17000584C8 /* TimeOfImpact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeOfImpact.h; sourceTree = ""; }; 1AAF4FED180E2C17000584C8 /* Tumbler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tumbler.h; sourceTree = ""; }; 1AAF4FEE180E2C17000584C8 /* VaryingFriction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VaryingFriction.h; sourceTree = ""; }; 1AAF4FEF180E2C17000584C8 /* VaryingRestitution.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VaryingRestitution.h; sourceTree = ""; }; 1AAF4FF0180E2C17000584C8 /* VerticalStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VerticalStack.h; sourceTree = ""; }; 1AAF4FF1180E2C17000584C8 /* Web.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Web.h; sourceTree = ""; }; 1AAF4FF3180E2C17000584C8 /* Bug-1159.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-1159.cpp"; sourceTree = ""; }; 1AAF4FF4180E2C17000584C8 /* Bug-1159.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-1159.h"; sourceTree = ""; }; 1AAF4FF5180E2C17000584C8 /* Bug-1174.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-1174.cpp"; sourceTree = ""; }; 1AAF4FF6180E2C17000584C8 /* Bug-1174.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-1174.h"; sourceTree = ""; }; 1AAF4FF7180E2C17000584C8 /* Bug-350.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-350.cpp"; sourceTree = ""; }; 1AAF4FF8180E2C17000584C8 /* Bug-350.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-350.h"; sourceTree = ""; }; 1AAF4FF9180E2C17000584C8 /* Bug-422.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-422.cpp"; sourceTree = ""; }; 1AAF4FFA180E2C17000584C8 /* Bug-422.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-422.h"; sourceTree = ""; }; 1AAF4FFC180E2C17000584C8 /* Bug-458.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-458.cpp"; sourceTree = ""; }; 1AAF4FFD180E2C17000584C8 /* Bug-458.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-458.h"; sourceTree = ""; }; 1AAF4FFE180E2C17000584C8 /* QuestionContainerSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QuestionContainerSprite.cpp; sourceTree = ""; }; 1AAF4FFF180E2C17000584C8 /* QuestionContainerSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuestionContainerSprite.h; sourceTree = ""; }; 1AAF5000180E2C17000584C8 /* Bug-624.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-624.cpp"; sourceTree = ""; }; 1AAF5001180E2C17000584C8 /* Bug-624.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-624.h"; sourceTree = ""; }; 1AAF5002180E2C17000584C8 /* Bug-886.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-886.cpp"; sourceTree = ""; }; 1AAF5003180E2C17000584C8 /* Bug-886.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-886.h"; sourceTree = ""; }; 1AAF5004180E2C17000584C8 /* Bug-899.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-899.cpp"; sourceTree = ""; }; 1AAF5005180E2C17000584C8 /* Bug-899.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-899.h"; sourceTree = ""; }; 1AAF5006180E2C17000584C8 /* Bug-914.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-914.cpp"; sourceTree = ""; }; 1AAF5007180E2C17000584C8 /* Bug-914.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-914.h"; sourceTree = ""; }; 1AAF5008180E2C17000584C8 /* BugsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BugsTest.cpp; sourceTree = ""; }; 1AAF5009180E2C17000584C8 /* BugsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BugsTest.h; sourceTree = ""; }; 1AAF500B180E2C18000584C8 /* ChipmunkTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChipmunkTest.cpp; sourceTree = ""; }; 1AAF500C180E2C18000584C8 /* ChipmunkTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChipmunkTest.h; sourceTree = ""; }; 1AAF500E180E2C18000584C8 /* ClickAndMoveTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClickAndMoveTest.cpp; sourceTree = ""; }; 1AAF500F180E2C18000584C8 /* ClickAndMoveTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClickAndMoveTest.h; sourceTree = ""; }; 1AAF5011180E2C18000584C8 /* ClippingNodeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ClippingNodeTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF5012180E2C18000584C8 /* ClippingNodeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClippingNodeTest.h; sourceTree = ""; }; 1AAF5014180E2C18000584C8 /* CocosDenshionTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosDenshionTest.cpp; sourceTree = ""; }; 1AAF5015180E2C18000584C8 /* CocosDenshionTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosDenshionTest.h; sourceTree = ""; }; 1AAF5017180E2C18000584C8 /* ConfigurationTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConfigurationTest.cpp; sourceTree = ""; }; 1AAF5018180E2C18000584C8 /* ConfigurationTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConfigurationTest.h; sourceTree = ""; }; 1AAF5019180E2C18000584C8 /* controller.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = controller.cpp; sourceTree = ""; }; 1AAF501A180E2C18000584C8 /* controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = controller.h; sourceTree = ""; }; 1AAF501C180E2C18000584C8 /* CurlTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CurlTest.cpp; sourceTree = ""; }; 1AAF501D180E2C18000584C8 /* CurlTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CurlTest.h; sourceTree = ""; }; 1AAF501F180E2C18000584C8 /* CurrentLanguageTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CurrentLanguageTest.cpp; sourceTree = ""; }; 1AAF5020180E2C18000584C8 /* CurrentLanguageTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CurrentLanguageTest.h; sourceTree = ""; }; 1AAF5022180E2C18000584C8 /* DataVisitorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataVisitorTest.cpp; sourceTree = ""; }; 1AAF5023180E2C18000584C8 /* DataVisitorTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataVisitorTest.h; sourceTree = ""; }; 1AAF5025180E2C18000584C8 /* DrawPrimitivesTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = DrawPrimitivesTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF5026180E2C18000584C8 /* DrawPrimitivesTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawPrimitivesTest.h; sourceTree = ""; }; 1AAF5028180E2C18000584C8 /* EffectsAdvancedTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EffectsAdvancedTest.cpp; sourceTree = ""; }; 1AAF5029180E2C18000584C8 /* EffectsAdvancedTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EffectsAdvancedTest.h; sourceTree = ""; }; 1AAF502B180E2C18000584C8 /* EffectsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EffectsTest.cpp; sourceTree = ""; }; 1AAF502C180E2C18000584C8 /* EffectsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EffectsTest.h; sourceTree = ""; }; 1AAF5030180E2C18000584C8 /* AnimationsLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationsLayerLoader.h; sourceTree = ""; }; 1AAF5031180E2C18000584C8 /* AnimationsTestLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimationsTestLayer.cpp; sourceTree = ""; }; 1AAF5032180E2C18000584C8 /* AnimationsTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationsTestLayer.h; sourceTree = ""; }; 1AAF5034180E2C18000584C8 /* ButtonTestLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ButtonTestLayer.cpp; sourceTree = ""; }; 1AAF5035180E2C18000584C8 /* ButtonTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonTestLayer.h; sourceTree = ""; }; 1AAF5036180E2C18000584C8 /* ButtonTestLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonTestLayerLoader.h; sourceTree = ""; }; 1AAF5037180E2C18000584C8 /* CocosBuilderTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosBuilderTest.cpp; sourceTree = ""; }; 1AAF5038180E2C18000584C8 /* CocosBuilderTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosBuilderTest.h; sourceTree = ""; }; 1AAF503A180E2C18000584C8 /* HelloCocosBuilderLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HelloCocosBuilderLayer.cpp; sourceTree = ""; }; 1AAF503B180E2C18000584C8 /* HelloCocosBuilderLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloCocosBuilderLayer.h; sourceTree = ""; }; 1AAF503C180E2C18000584C8 /* HelloCocosBuilderLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloCocosBuilderLayerLoader.h; sourceTree = ""; }; 1AAF503E180E2C18000584C8 /* LabelTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelTestLayer.h; sourceTree = ""; }; 1AAF503F180E2C18000584C8 /* LabelTestLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelTestLayerLoader.h; sourceTree = ""; }; 1AAF5041180E2C18000584C8 /* MenuTestLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MenuTestLayer.cpp; sourceTree = ""; }; 1AAF5042180E2C18000584C8 /* MenuTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuTestLayer.h; sourceTree = ""; }; 1AAF5043180E2C18000584C8 /* MenuTestLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuTestLayerLoader.h; sourceTree = ""; }; 1AAF5045180E2C18000584C8 /* ParticleSystemTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleSystemTestLayer.h; sourceTree = ""; }; 1AAF5046180E2C18000584C8 /* ParticleSystemTestLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleSystemTestLayerLoader.h; sourceTree = ""; }; 1AAF5048180E2C18000584C8 /* ScrollViewTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollViewTestLayer.h; sourceTree = ""; }; 1AAF5049180E2C18000584C8 /* ScrollViewTestLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollViewTestLayerLoader.h; sourceTree = ""; }; 1AAF504B180E2C18000584C8 /* SpriteTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteTestLayer.h; sourceTree = ""; }; 1AAF504C180E2C18000584C8 /* SpriteTestLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteTestLayerLoader.h; sourceTree = ""; }; 1AAF504E180E2C18000584C8 /* TestHeaderLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestHeaderLayer.cpp; sourceTree = ""; }; 1AAF504F180E2C18000584C8 /* TestHeaderLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestHeaderLayer.h; sourceTree = ""; }; 1AAF5050180E2C18000584C8 /* TestHeaderLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestHeaderLayerLoader.h; sourceTree = ""; }; 1AAF5052180E2C18000584C8 /* TimelineCallbackLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimelineCallbackLayerLoader.h; sourceTree = ""; }; 1AAF5053180E2C18000584C8 /* TimelineCallbackTestLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimelineCallbackTestLayer.cpp; sourceTree = ""; }; 1AAF5054180E2C18000584C8 /* TimelineCallbackTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimelineCallbackTestLayer.h; sourceTree = ""; }; 1AAF5056180E2C18000584C8 /* ArmatureScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ArmatureScene.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF5057180E2C18000584C8 /* ArmatureScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArmatureScene.h; sourceTree = ""; }; 1AAF5059180E2C18000584C8 /* ComponentsTestScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComponentsTestScene.cpp; sourceTree = ""; }; 1AAF505A180E2C18000584C8 /* ComponentsTestScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComponentsTestScene.h; sourceTree = ""; }; 1AAF505B180E2C18000584C8 /* EnemyController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnemyController.cpp; sourceTree = ""; }; 1AAF505C180E2C18000584C8 /* EnemyController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnemyController.h; sourceTree = ""; }; 1AAF505D180E2C18000584C8 /* GameOverScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GameOverScene.cpp; sourceTree = ""; }; 1AAF505E180E2C18000584C8 /* GameOverScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameOverScene.h; sourceTree = ""; }; 1AAF505F180E2C18000584C8 /* PlayerController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlayerController.cpp; sourceTree = ""; }; 1AAF5060180E2C18000584C8 /* PlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerController.h; sourceTree = ""; }; 1AAF5061180E2C18000584C8 /* ProjectileController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProjectileController.cpp; sourceTree = ""; }; 1AAF5062180E2C18000584C8 /* ProjectileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectileController.h; sourceTree = ""; }; 1AAF5063180E2C18000584C8 /* SceneController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SceneController.cpp; sourceTree = ""; }; 1AAF5064180E2C18000584C8 /* SceneController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneController.h; sourceTree = ""; }; 1AAF50A0180E2C19000584C8 /* SceneEditorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SceneEditorTest.cpp; sourceTree = ""; }; 1AAF50A1180E2C19000584C8 /* SceneEditorTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneEditorTest.h; sourceTree = ""; }; 1AAF50A4180E2C19000584C8 /* CCControlButtonTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButtonTest.cpp; sourceTree = ""; }; 1AAF50A5180E2C19000584C8 /* CCControlButtonTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlButtonTest.h; sourceTree = ""; }; 1AAF50A7180E2C19000584C8 /* CCControlColourPickerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlColourPickerTest.cpp; sourceTree = ""; }; 1AAF50A8180E2C19000584C8 /* CCControlColourPickerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlColourPickerTest.h; sourceTree = ""; }; 1AAF50AA180E2C19000584C8 /* CCControlPotentiometerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlPotentiometerTest.cpp; sourceTree = ""; }; 1AAF50AB180E2C19000584C8 /* CCControlPotentiometerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlPotentiometerTest.h; sourceTree = ""; }; 1AAF50AC180E2C19000584C8 /* CCControlScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlScene.cpp; sourceTree = ""; }; 1AAF50AD180E2C19000584C8 /* CCControlScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlScene.h; sourceTree = ""; }; 1AAF50AE180E2C19000584C8 /* CCControlSceneManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSceneManager.cpp; sourceTree = ""; }; 1AAF50AF180E2C19000584C8 /* CCControlSceneManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSceneManager.h; sourceTree = ""; }; 1AAF50B1180E2C19000584C8 /* CCControlSliderTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSliderTest.cpp; sourceTree = ""; }; 1AAF50B2180E2C19000584C8 /* CCControlSliderTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSliderTest.h; sourceTree = ""; }; 1AAF50B4180E2C19000584C8 /* CCControlStepperTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlStepperTest.cpp; sourceTree = ""; }; 1AAF50B5180E2C19000584C8 /* CCControlStepperTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlStepperTest.h; sourceTree = ""; }; 1AAF50B7180E2C19000584C8 /* CCControlSwitchTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSwitchTest.cpp; sourceTree = ""; }; 1AAF50B8180E2C19000584C8 /* CCControlSwitchTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSwitchTest.h; sourceTree = ""; }; 1AAF50BA180E2C19000584C8 /* EditBoxTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditBoxTest.cpp; sourceTree = ""; }; 1AAF50BB180E2C19000584C8 /* EditBoxTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditBoxTest.h; sourceTree = ""; }; 1AAF50BC180E2C19000584C8 /* ExtensionsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtensionsTest.cpp; sourceTree = ""; }; 1AAF50BD180E2C19000584C8 /* ExtensionsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionsTest.h; sourceTree = ""; }; 1AAF50BF180E2C19000584C8 /* HttpClientTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HttpClientTest.cpp; sourceTree = ""; }; 1AAF50C0180E2C19000584C8 /* HttpClientTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpClientTest.h; sourceTree = ""; }; 1AAF50C1180E2C19000584C8 /* SocketIOTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketIOTest.cpp; sourceTree = ""; }; 1AAF50C2180E2C19000584C8 /* SocketIOTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketIOTest.h; sourceTree = ""; }; 1AAF50C3180E2C19000584C8 /* WebSocketTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketTest.cpp; sourceTree = ""; }; 1AAF50C4180E2C19000584C8 /* WebSocketTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketTest.h; sourceTree = ""; }; 1AAF50C6180E2C19000584C8 /* NotificationCenterTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotificationCenterTest.cpp; sourceTree = ""; }; 1AAF50C7180E2C19000584C8 /* NotificationCenterTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationCenterTest.h; sourceTree = ""; }; 1AAF50C9180E2C19000584C8 /* Scale9SpriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Scale9SpriteTest.cpp; sourceTree = ""; }; 1AAF50CA180E2C19000584C8 /* Scale9SpriteTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scale9SpriteTest.h; sourceTree = ""; }; 1AAF50CC180E2C19000584C8 /* CustomTableViewCell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomTableViewCell.cpp; sourceTree = ""; }; 1AAF50CD180E2C19000584C8 /* CustomTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomTableViewCell.h; sourceTree = ""; }; 1AAF50CE180E2C19000584C8 /* TableViewTestScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TableViewTestScene.cpp; sourceTree = ""; }; 1AAF50CF180E2C19000584C8 /* TableViewTestScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewTestScene.h; sourceTree = ""; }; 1AAF50D1180E2C19000584C8 /* FileUtilsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileUtilsTest.cpp; sourceTree = ""; }; 1AAF50D2180E2C19000584C8 /* FileUtilsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileUtilsTest.h; sourceTree = ""; }; 1AAF50D4180E2C19000584C8 /* FontTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontTest.cpp; sourceTree = ""; }; 1AAF50D5180E2C19000584C8 /* FontTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontTest.h; sourceTree = ""; }; 1AAF50D7180E2C19000584C8 /* IntervalTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntervalTest.cpp; sourceTree = ""; }; 1AAF50D8180E2C19000584C8 /* IntervalTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntervalTest.h; sourceTree = ""; }; 1AAF50DA180E2C19000584C8 /* KeyboardTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyboardTest.cpp; sourceTree = ""; }; 1AAF50DB180E2C19000584C8 /* KeyboardTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyboardTest.h; sourceTree = ""; }; 1AAF50DD180E2C19000584C8 /* KeypadTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeypadTest.cpp; sourceTree = ""; }; 1AAF50DE180E2C19000584C8 /* KeypadTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeypadTest.h; sourceTree = ""; }; 1AAF50E0180E2C19000584C8 /* LabelTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = LabelTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF50E1180E2C19000584C8 /* LabelTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelTest.h; sourceTree = ""; }; 1AAF50E2180E2C19000584C8 /* LabelTestNew.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = LabelTestNew.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF50E3180E2C19000584C8 /* LabelTestNew.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelTestNew.h; sourceTree = ""; }; 1AAF50E5180E2C19000584C8 /* LayerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayerTest.cpp; sourceTree = ""; }; 1AAF50E6180E2C19000584C8 /* LayerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerTest.h; sourceTree = ""; }; 1AAF50E8180E2C19000584C8 /* MenuTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MenuTest.cpp; sourceTree = ""; }; 1AAF50E9180E2C19000584C8 /* MenuTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuTest.h; sourceTree = ""; }; 1AAF50EB180E2C19000584C8 /* MotionStreakTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MotionStreakTest.cpp; sourceTree = ""; }; 1AAF50EC180E2C19000584C8 /* MotionStreakTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MotionStreakTest.h; sourceTree = ""; }; 1AAF50EE180E2C19000584C8 /* MutiTouchTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MutiTouchTest.cpp; sourceTree = ""; }; 1AAF50EF180E2C19000584C8 /* MutiTouchTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MutiTouchTest.h; sourceTree = ""; }; 1AAF50F1180E2C19000584C8 /* NewEventDispatcherTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewEventDispatcherTest.cpp; sourceTree = ""; }; 1AAF50F2180E2C19000584C8 /* NewEventDispatcherTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewEventDispatcherTest.h; sourceTree = ""; }; 1AAF50F4180E2C19000584C8 /* NodeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = NodeTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF50F5180E2C1A000584C8 /* NodeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeTest.h; sourceTree = ""; }; 1AAF50F7180E2C1A000584C8 /* ParallaxTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParallaxTest.cpp; sourceTree = ""; }; 1AAF50F8180E2C1A000584C8 /* ParallaxTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParallaxTest.h; sourceTree = ""; }; 1AAF50FA180E2C1A000584C8 /* ParticleTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleTest.cpp; sourceTree = ""; }; 1AAF50FB180E2C1A000584C8 /* ParticleTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleTest.h; sourceTree = ""; }; 1AAF50FD180E2C1A000584C8 /* PerformanceAllocTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceAllocTest.cpp; sourceTree = ""; }; 1AAF50FE180E2C1A000584C8 /* PerformanceAllocTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceAllocTest.h; sourceTree = ""; }; 1AAF50FF180E2C1A000584C8 /* PerformanceNodeChildrenTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceNodeChildrenTest.cpp; sourceTree = ""; }; 1AAF5100180E2C1A000584C8 /* PerformanceNodeChildrenTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceNodeChildrenTest.h; sourceTree = ""; }; 1AAF5101180E2C1A000584C8 /* PerformanceParticleTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceParticleTest.cpp; sourceTree = ""; }; 1AAF5102180E2C1A000584C8 /* PerformanceParticleTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceParticleTest.h; sourceTree = ""; }; 1AAF5103180E2C1A000584C8 /* PerformanceSpriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceSpriteTest.cpp; sourceTree = ""; }; 1AAF5104180E2C1A000584C8 /* PerformanceSpriteTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceSpriteTest.h; sourceTree = ""; }; 1AAF5105180E2C1A000584C8 /* PerformanceTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceTest.cpp; sourceTree = ""; }; 1AAF5106180E2C1A000584C8 /* PerformanceTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceTest.h; sourceTree = ""; }; 1AAF5107180E2C1A000584C8 /* PerformanceTextureTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceTextureTest.cpp; sourceTree = ""; }; 1AAF5108180E2C1A000584C8 /* PerformanceTextureTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceTextureTest.h; sourceTree = ""; }; 1AAF5109180E2C1A000584C8 /* PerformanceTouchesTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceTouchesTest.cpp; sourceTree = ""; }; 1AAF510A180E2C1A000584C8 /* PerformanceTouchesTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceTouchesTest.h; sourceTree = ""; }; 1AAF510C180E2C1A000584C8 /* PhysicsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PhysicsTest.cpp; sourceTree = ""; }; 1AAF510D180E2C1A000584C8 /* PhysicsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhysicsTest.h; sourceTree = ""; }; 1AAF510F180E2C1A000584C8 /* RenderTextureTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = RenderTextureTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF5110180E2C1A000584C8 /* RenderTextureTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextureTest.h; sourceTree = ""; }; 1AAF5112180E2C1A000584C8 /* RotateWorldTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RotateWorldTest.cpp; sourceTree = ""; }; 1AAF5113180E2C1A000584C8 /* RotateWorldTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RotateWorldTest.h; sourceTree = ""; }; 1AAF5115180E2C1A000584C8 /* SceneTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SceneTest.cpp; sourceTree = ""; }; 1AAF5116180E2C1A000584C8 /* SceneTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneTest.h; sourceTree = ""; }; 1AAF5118180E2C1A000584C8 /* SchedulerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchedulerTest.cpp; sourceTree = ""; }; 1AAF5119180E2C1A000584C8 /* SchedulerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SchedulerTest.h; sourceTree = ""; }; 1AAF511B180E2C1A000584C8 /* ShaderTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ShaderTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF511C180E2C1A000584C8 /* ShaderTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderTest.h; sourceTree = ""; }; 1AAF511D180E2C1A000584C8 /* ShaderTest2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ShaderTest2.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF511E180E2C1A000584C8 /* ShaderTest2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderTest2.h; sourceTree = ""; }; 1AAF5120180E2C1A000584C8 /* SpineTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpineTest.cpp; sourceTree = ""; }; 1AAF5121180E2C1A000584C8 /* SpineTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpineTest.h; sourceTree = ""; }; 1AAF5123180E2C1A000584C8 /* SpriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpriteTest.cpp; sourceTree = ""; }; 1AAF5124180E2C1A000584C8 /* SpriteTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteTest.h; sourceTree = ""; }; 1AAF5125180E2C1A000584C8 /* testBasic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = testBasic.cpp; sourceTree = ""; }; 1AAF5126180E2C1A000584C8 /* testBasic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testBasic.h; sourceTree = ""; }; 1AAF5127180E2C1A000584C8 /* testResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testResource.h; sourceTree = ""; }; 1AAF5128180E2C1A000584C8 /* tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tests.h; sourceTree = ""; }; 1AAF512A180E2C1A000584C8 /* TextInputTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextInputTest.cpp; sourceTree = ""; }; 1AAF512B180E2C1A000584C8 /* TextInputTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputTest.h; sourceTree = ""; }; 1AAF512D180E2C1A000584C8 /* Texture2dTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = Texture2dTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF512E180E2C1A000584C8 /* Texture2dTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Texture2dTest.h; sourceTree = ""; }; 1AAF5130180E2C1A000584C8 /* TextureCacheTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureCacheTest.cpp; sourceTree = ""; }; 1AAF5131180E2C1A000584C8 /* TextureCacheTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCacheTest.h; sourceTree = ""; }; 1AAF5133180E2C1A000584C8 /* TextureAtlasEncryptionTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureAtlasEncryptionTest.cpp; sourceTree = ""; }; 1AAF5134180E2C1A000584C8 /* TextureAtlasEncryptionTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureAtlasEncryptionTest.h; sourceTree = ""; }; 1AAF5136180E2C1A000584C8 /* TileMapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = TileMapTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AAF5137180E2C1A000584C8 /* TileMapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileMapTest.h; sourceTree = ""; }; 1AAF5139180E2C1A000584C8 /* Ball.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Ball.cpp; sourceTree = ""; }; 1AAF513A180E2C1A000584C8 /* Ball.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Ball.h; sourceTree = ""; }; 1AAF513B180E2C1A000584C8 /* Paddle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Paddle.cpp; sourceTree = ""; }; 1AAF513C180E2C1A000584C8 /* Paddle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Paddle.h; sourceTree = ""; }; 1AAF513D180E2C1A000584C8 /* TouchesTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TouchesTest.cpp; sourceTree = ""; }; 1AAF513E180E2C1A000584C8 /* TouchesTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TouchesTest.h; sourceTree = ""; }; 1AAF5140180E2C1A000584C8 /* TransitionsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransitionsTest.cpp; sourceTree = ""; }; 1AAF5141180E2C1A000584C8 /* TransitionsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransitionsTest.h; sourceTree = ""; }; 1AAF5143180E2C1A000584C8 /* UserDefaultTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserDefaultTest.cpp; sourceTree = ""; }; 1AAF5144180E2C1A000584C8 /* UserDefaultTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserDefaultTest.h; sourceTree = ""; }; 1AAF5145180E2C1A000584C8 /* VisibleRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisibleRect.cpp; sourceTree = ""; }; 1AAF5146180E2C1A000584C8 /* VisibleRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisibleRect.h; sourceTree = ""; }; 1AAF5148180E2C1A000584C8 /* ZwoptexTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZwoptexTest.cpp; sourceTree = ""; }; 1AAF5149180E2C1A000584C8 /* ZwoptexTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZwoptexTest.h; sourceTree = ""; }; 1AAF5252180E2C26000584C8 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 1AAF5253180E2C26000584C8 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 1AAF5254180E2C26000584C8 /* testsAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testsAppDelegate.h; sourceTree = ""; }; 1AAF5255180E2C26000584C8 /* testsAppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = testsAppDelegate.mm; sourceTree = ""; }; 1AAF5256180E2C26000584C8 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 1AAF5257180E2C26000584C8 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 1AAF5258180E2C26000584C8 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 1AAF5259180E2C26000584C8 /* Icon-100.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-100.png"; sourceTree = ""; }; 1AAF525A180E2C26000584C8 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 1AAF525B180E2C26000584C8 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 1AAF525C180E2C26000584C8 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 1AAF525D180E2C26000584C8 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 1AAF525E180E2C26000584C8 /* Icon-29.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-29.png"; sourceTree = ""; }; 1AAF525F180E2C26000584C8 /* Icon-40.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-40.png"; sourceTree = ""; }; 1AAF5260180E2C26000584C8 /* Icon-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-50.png"; sourceTree = ""; }; 1AAF5261180E2C26000584C8 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 1AAF5262180E2C26000584C8 /* Icon-58.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-58.png"; sourceTree = ""; }; 1AAF5263180E2C26000584C8 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 1AAF5264180E2C26000584C8 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 1AAF5265180E2C26000584C8 /* Icon-80.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-80.png"; sourceTree = ""; }; 1AAF5266180E2C26000584C8 /* iphone_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iphone_Prefix.pch; sourceTree = ""; }; 1AAF5267180E2C26000584C8 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 1AAF5268180E2C26000584C8 /* Test-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Test-Info.plist"; sourceTree = ""; }; 1AAF527F180E2C31000584C8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 1AAF5281180E2C31000584C8 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 1AAF5282180E2C31000584C8 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1AAF5283180E2C31000584C8 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 1AAF5284180E2C31000584C8 /* Test_Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Test_Info.plist; sourceTree = ""; }; 1AAF5285180E2C31000584C8 /* Test_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test_Prefix.pch; sourceTree = ""; }; 1ADD146B188D25270034D5EF /* PerformanceEventDispatcherTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceEventDispatcherTest.cpp; sourceTree = ""; }; 1ADD146C188D25270034D5EF /* PerformanceEventDispatcherTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceEventDispatcherTest.h; sourceTree = ""; }; 1AFB0DE11885357A003B2FF3 /* PerformanceContainerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceContainerTest.cpp; sourceTree = ""; }; 1AFB0DE21885357A003B2FF3 /* PerformanceContainerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceContainerTest.h; sourceTree = ""; }; 1D6058910D05DD3D006BFB54 /* Test cpp Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Test cpp Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 37A6145B186B21F6007A4638 /* acts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = acts.cpp; sourceTree = ""; }; 37A6145C186B21F6007A4638 /* acts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = acts.h; sourceTree = ""; }; 37A6145D186B21F6007A4638 /* cons.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cons.cpp; sourceTree = ""; }; 37A6145E186B21F6007A4638 /* cons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cons.h; sourceTree = ""; }; 37A6145F186B21F6007A4638 /* EventDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventDef.h; sourceTree = ""; }; 37C819601875DF2A00930C57 /* animations */ = {isa = PBXFileReference; lastKnownFileType = folder; name = animations; path = ../samples/Cpp/TestCpp/Resources/animations; sourceTree = ""; }; 37C819611875DF2A00930C57 /* armature */ = {isa = PBXFileReference; lastKnownFileType = folder; name = armature; path = ../samples/Cpp/TestCpp/Resources/armature; sourceTree = ""; }; 37C819621875DF2A00930C57 /* background-music-aac.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = "background-music-aac.wav"; path = "../samples/Cpp/TestCpp/Resources/background-music-aac.wav"; sourceTree = ""; }; 37C819631875DF2A00930C57 /* background.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = background.mp3; path = ../samples/Cpp/TestCpp/Resources/background.mp3; sourceTree = ""; }; 37C819641875DF2A00930C57 /* background.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; name = background.ogg; path = ../samples/Cpp/TestCpp/Resources/background.ogg; sourceTree = ""; }; 37C819651875DF2A00930C57 /* ccb */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ccb; path = ../samples/Cpp/TestCpp/Resources/ccb; sourceTree = ""; }; 37C819661875DF2A00930C57 /* CocosBuilderExample.ccbproj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = CocosBuilderExample.ccbproj; path = ../samples/Cpp/TestCpp/Resources/CocosBuilderExample.ccbproj; sourceTree = ""; }; 37C819671875DF2A00930C57 /* CocosBuilderExample.ccbresourcelog */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CocosBuilderExample.ccbresourcelog; path = ../samples/Cpp/TestCpp/Resources/CocosBuilderExample.ccbresourcelog; sourceTree = ""; }; 37C819681875DF2A00930C57 /* cocosgui */ = {isa = PBXFileReference; lastKnownFileType = folder; name = cocosgui; path = ../samples/Cpp/TestCpp/Resources/cocosgui; sourceTree = ""; }; 37C819691875DF2A00930C57 /* components */ = {isa = PBXFileReference; lastKnownFileType = folder; name = components; path = ../samples/Cpp/TestCpp/Resources/components; sourceTree = ""; }; 37C8196A1875DF2A00930C57 /* configs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = configs; path = ../samples/Cpp/TestCpp/Resources/configs; sourceTree = ""; }; 37C8196B1875DF2A00930C57 /* effect1.raw */ = {isa = PBXFileReference; lastKnownFileType = file; name = effect1.raw; path = ../samples/Cpp/TestCpp/Resources/effect1.raw; sourceTree = ""; }; 37C8196C1875DF2A00930C57 /* effect1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = effect1.wav; path = ../samples/Cpp/TestCpp/Resources/effect1.wav; sourceTree = ""; }; 37C8196D1875DF2A00930C57 /* effect2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; name = effect2.ogg; path = ../samples/Cpp/TestCpp/Resources/effect2.ogg; sourceTree = ""; }; 37C8196E1875DF2A00930C57 /* extensions */ = {isa = PBXFileReference; lastKnownFileType = folder; name = extensions; path = ../samples/Cpp/TestCpp/Resources/extensions; sourceTree = ""; }; 37C8196F1875DF2A00930C57 /* fileLookup.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = fileLookup.plist; path = ../samples/Cpp/TestCpp/Resources/fileLookup.plist; sourceTree = ""; }; 37C819701875DF2A00930C57 /* fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = fonts; path = ../samples/Cpp/TestCpp/Resources/fonts; sourceTree = ""; }; 37C819711875DF2A00930C57 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = fps_images.png; path = ../samples/Cpp/TestCpp/Resources/fps_images.png; sourceTree = ""; }; 37C819721875DF2A00930C57 /* hd */ = {isa = PBXFileReference; lastKnownFileType = folder; name = hd; path = ../samples/Cpp/TestCpp/Resources/hd; sourceTree = ""; }; 37C819731875DF2A00930C57 /* Hello.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Hello.png; path = ../samples/Cpp/TestCpp/Resources/Hello.png; sourceTree = ""; }; 37C819741875DF2B00930C57 /* Images */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Images; path = ../samples/Cpp/TestCpp/Resources/Images; sourceTree = ""; }; 37C819751875DF2B00930C57 /* ipad */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ipad; path = ../samples/Cpp/TestCpp/Resources/ipad; sourceTree = ""; }; 37C819761875DF2B00930C57 /* ipadhd */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ipadhd; path = ../samples/Cpp/TestCpp/Resources/ipadhd; sourceTree = ""; }; 37C819771875DF2B00930C57 /* Misc */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Misc; path = ../samples/Cpp/TestCpp/Resources/Misc; sourceTree = ""; }; 37C819781875DF2B00930C57 /* music.mid */ = {isa = PBXFileReference; lastKnownFileType = audio.midi; name = music.mid; path = ../samples/Cpp/TestCpp/Resources/music.mid; sourceTree = ""; }; 37C819791875DF2B00930C57 /* Particles */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Particles; path = ../samples/Cpp/TestCpp/Resources/Particles; sourceTree = ""; }; 37C8197A1875DF2B00930C57 /* pew-pew-lei.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = "pew-pew-lei.wav"; path = "../samples/Cpp/TestCpp/Resources/pew-pew-lei.wav"; sourceTree = ""; }; 37C8197B1875DF2B00930C57 /* scenetest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = scenetest; path = ../samples/Cpp/TestCpp/Resources/scenetest; sourceTree = ""; }; 37C8197C1875DF2B00930C57 /* Shaders */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Shaders; path = ../samples/Cpp/TestCpp/Resources/Shaders; sourceTree = ""; }; 37C8197D1875DF2B00930C57 /* spine */ = {isa = PBXFileReference; lastKnownFileType = folder; name = spine; path = ../samples/Cpp/TestCpp/Resources/spine; sourceTree = ""; }; 37C8197E1875DF2B00930C57 /* TileMaps */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TileMaps; path = ../samples/Cpp/TestCpp/Resources/TileMaps; sourceTree = ""; }; 37C8197F1875DF2B00930C57 /* zwoptex */ = {isa = PBXFileReference; lastKnownFileType = folder; name = zwoptex; path = ../samples/Cpp/TestCpp/Resources/zwoptex; sourceTree = ""; }; 460E452D1807E712000CDD6D /* AppController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 460E452E1807E712000CDD6D /* AppController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 460E452F1807E712000CDD6D /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 460E45301807E712000CDD6D /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 460E45311807E712000CDD6D /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 460E45321807E712000CDD6D /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 460E45331807E712000CDD6D /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 460E45341807E712000CDD6D /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 460E45351807E712000CDD6D /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 460E45361807E712000CDD6D /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 460E45371807E712000CDD6D /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 460E45381807E712000CDD6D /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 460E45391807E712000CDD6D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 460E453A1807E712000CDD6D /* RootViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 460E453B1807E712000CDD6D /* RootViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 460E453C1807E712000CDD6D /* SimpleGame-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SimpleGame-Info.plist"; sourceTree = ""; }; 460E453D1807E712000CDD6D /* SimpleGame_Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimpleGame_Prefix.pch; sourceTree = ""; }; 460E459E180801A4000CDD6D /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 460E459F180801A4000CDD6D /* app.config.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = app.config.txt; sourceTree = ""; }; 460E45A0180801A4000CDD6D /* app.icf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = app.icf; sourceTree = ""; }; 460E45A1180801A4000CDD6D /* background-music-aac.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "background-music-aac.wav"; sourceTree = ""; }; 460E45A2180801A4000CDD6D /* development.icf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = development.icf; sourceTree = ""; }; 460E45A4180801A4000CDD6D /* Marker Felt.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Marker Felt.ttf"; sourceTree = ""; }; 460E45AB180801A4000CDD6D /* pew-pew-lei.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "pew-pew-lei.wav"; sourceTree = ""; }; 460E45D7180801C1000CDD6D /* hd */ = {isa = PBXFileReference; lastKnownFileType = folder; path = hd; sourceTree = ""; }; 460E45DA180801C9000CDD6D /* sd */ = {isa = PBXFileReference; lastKnownFileType = folder; path = sd; sourceTree = ""; }; 4662EB5D188E426300B02E8F /* ReleasePoolTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReleasePoolTest.cpp; sourceTree = ""; }; 4662EB63188E472A00B02E8F /* ReleasePoolTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReleasePoolTest.h; sourceTree = ""; }; 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = cocos2d_libs.xcodeproj; sourceTree = ""; }; 46A174851807D934005B8026 /* AppDelegate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 46A174861807D934005B8026 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 46A174871807D934005B8026 /* AppMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppMacros.h; sourceTree = ""; }; 46A174881807D934005B8026 /* HelloWorldScene.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HelloWorldScene.cpp; sourceTree = ""; }; 46A174891807D934005B8026 /* HelloWorldScene.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HelloWorldScene.h; sourceTree = ""; }; 46A174AB1807D934005B8026 /* AppController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 46A174AC1807D934005B8026 /* AppController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; 46A174AD1807D934005B8026 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 46A174AE1807D934005B8026 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 46A174AF1807D934005B8026 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 46A174B01807D934005B8026 /* HelloCpp-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HelloCpp-Info.plist"; sourceTree = ""; }; 46A174B11807D934005B8026 /* HelloCpp_Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HelloCpp_Prefix.pch; sourceTree = ""; }; 46A174B21807D934005B8026 /* Icon-100.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-100.png"; sourceTree = ""; }; 46A174B31807D934005B8026 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; 46A174B41807D934005B8026 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; 46A174B51807D934005B8026 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; 46A174B61807D934005B8026 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; 46A174B71807D934005B8026 /* Icon-40.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-40.png"; sourceTree = ""; }; 46A174B81807D934005B8026 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; 46A174B91807D934005B8026 /* Icon-58.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-58.png"; sourceTree = ""; }; 46A174BA1807D934005B8026 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 46A174BB1807D934005B8026 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; 46A174BC1807D934005B8026 /* Icon-80.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-80.png"; sourceTree = ""; }; 46A174BD1807D934005B8026 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 46A174BE1807D934005B8026 /* RootViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 46A174BF1807D934005B8026 /* RootViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; 46A174C71807D934005B8026 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 46A174C91807D934005B8026 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 46A174CA1807D934005B8026 /* HelloCpp_Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = HelloCpp_Info.plist; sourceTree = ""; }; 46A174CB1807D934005B8026 /* HelloCpp_Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HelloCpp_Prefix.pch; sourceTree = ""; }; 46A174CC1807D934005B8026 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 46A174CD1807D934005B8026 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 46A174EC1807D9C4005B8026 /* bang.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bang.png; sourceTree = ""; }; 46A174EE1807D9C4005B8026 /* fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = fonts; sourceTree = ""; }; 46A174EF1807D9C4005B8026 /* ipad */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ipad; sourceTree = ""; }; 46A174F01807D9C4005B8026 /* ipadhd */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ipadhd; sourceTree = ""; }; 46A174F11807D9C4005B8026 /* iphone */ = {isa = PBXFileReference; lastKnownFileType = folder; path = iphone; sourceTree = ""; }; 50691334184EB453009BBDD7 /* ConsoleTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleTest.cpp; sourceTree = ""; }; 50691335184EB453009BBDD7 /* ConsoleTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleTest.h; sourceTree = ""; }; 50D360CA186819DB00828878 /* CocosGUIScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosGUIScene.cpp; sourceTree = ""; }; 50D360CB186819DB00828878 /* CocosGUIScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosGUIScene.h; sourceTree = ""; }; 50D360CD186819DB00828878 /* UIButtonTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIButtonTest.cpp; sourceTree = ""; }; 50D360CE186819DB00828878 /* UIButtonTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIButtonTest.h; sourceTree = ""; }; 50D360D0186819DB00828878 /* UICheckBoxTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UICheckBoxTest.cpp; sourceTree = ""; }; 50D360D1186819DB00828878 /* UICheckBoxTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICheckBoxTest.h; sourceTree = ""; }; 50D360D3186819DB00828878 /* UIImageViewTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIImageViewTest.cpp; sourceTree = ""; }; 50D360D4186819DB00828878 /* UIImageViewTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIImageViewTest.h; sourceTree = ""; }; 50D360D6186819DB00828878 /* UILabelAtlasTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILabelAtlasTest.cpp; sourceTree = ""; }; 50D360D7186819DB00828878 /* UILabelAtlasTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILabelAtlasTest.h; sourceTree = ""; }; 50D360D9186819DB00828878 /* UILabelBMFontTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILabelBMFontTest.cpp; sourceTree = ""; }; 50D360DA186819DB00828878 /* UILabelBMFontTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILabelBMFontTest.h; sourceTree = ""; }; 50D360DC186819DB00828878 /* UILabelTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILabelTest.cpp; sourceTree = ""; }; 50D360DD186819DB00828878 /* UILabelTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILabelTest.h; sourceTree = ""; }; 50D360DF186819DB00828878 /* UILayoutTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutTest.cpp; sourceTree = ""; }; 50D360E0186819DB00828878 /* UILayoutTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutTest.h; sourceTree = ""; }; 50D360E2186819DB00828878 /* UIListViewTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIListViewTest.cpp; sourceTree = ""; }; 50D360E3186819DB00828878 /* UIListViewTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIListViewTest.h; sourceTree = ""; }; 50D360E5186819DB00828878 /* UILoadingBarTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILoadingBarTest.cpp; sourceTree = ""; }; 50D360E6186819DB00828878 /* UILoadingBarTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILoadingBarTest.h; sourceTree = ""; }; 50D360E8186819DB00828878 /* UIPageViewTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIPageViewTest.cpp; sourceTree = ""; }; 50D360E9186819DB00828878 /* UIPageViewTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIPageViewTest.h; sourceTree = ""; }; 50D360EA186819DB00828878 /* UIScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScene.cpp; sourceTree = ""; }; 50D360EB186819DB00828878 /* UIScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScene.h; sourceTree = ""; }; 50D360EC186819DB00828878 /* UISceneManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UISceneManager.cpp; sourceTree = ""; }; 50D360ED186819DB00828878 /* UISceneManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UISceneManager.h; sourceTree = ""; }; 50D360EF186819DB00828878 /* UIScrollViewTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScrollViewTest.cpp; sourceTree = ""; }; 50D360F0186819DB00828878 /* UIScrollViewTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollViewTest.h; sourceTree = ""; }; 50D360F2186819DB00828878 /* UISliderTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UISliderTest.cpp; sourceTree = ""; }; 50D360F3186819DB00828878 /* UISliderTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UISliderTest.h; sourceTree = ""; }; 50D360F5186819DB00828878 /* UITextFieldTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UITextFieldTest.cpp; sourceTree = ""; }; 50D360F6186819DB00828878 /* UITextFieldTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UITextFieldTest.h; sourceTree = ""; }; 50D360F8186819DB00828878 /* UIWidgetAddNodeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIWidgetAddNodeTest.cpp; sourceTree = ""; }; 50D360F9186819DB00828878 /* UIWidgetAddNodeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidgetAddNodeTest.h; sourceTree = ""; }; 599121E4182C74AC00CE785B /* NewRendererTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewRendererTest.cpp; sourceTree = ""; }; 599121E5182C74AC00CE785B /* NewRendererTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewRendererTest.h; sourceTree = ""; }; 59A79D5B1821E95C00F19697 /* MouseTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseTest.cpp; sourceTree = ""; }; 59A79D5C1821E95C00F19697 /* MouseTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MouseTest.h; sourceTree = ""; }; A01E16931784BDA100B0CA4A /* Simple Game iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Simple Game iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A01E17721784C06E00B0CA4A /* Test JavaScript iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Test JavaScript iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A01E18571784C45500B0CA4A /* JS Watermelon With Me iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JS Watermelon With Me iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A01E188C1784C4D600B0CA4A /* JS Moon Warriors iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JS Moon Warriors iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A01E18C11784C4DC00B0CA4A /* JS Crystal Craze iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JS Crystal Craze iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A01E18F61784C4E000B0CA4A /* JS CocosDragon iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JS CocosDragon iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A035A5EC1782290400987F6C /* Test JavaScript Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Test JavaScript Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A035A71117822E9E00987F6C /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; A035A77D1782301C00987F6C /* JS Watermelon With Me Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JS Watermelon With Me Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A035A9F717823FE100987F6C /* JS Moon Warriors Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JS Moon Warriors Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A035AAC51782422400987F6C /* JS Crystal Craze Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JS Crystal Craze Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A035AC371782453000987F6C /* JS CocosDragon Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JS CocosDragon Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A035AD76178254A300987F6C /* Simple Game Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Simple Game Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A035AE88178255DC00987F6C /* Hello cpp Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Hello cpp Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A52291783A1D20073F6A7 /* Test cpp iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Test cpp iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A52B71783AE6D0073F6A7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; A07A52B91783AE900073F6A7 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/OpenGLES.framework; sourceTree = DEVELOPER_DIR; }; A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; A07A52C11783B01F0073F6A7 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; }; A07A53811784AC9B0073F6A7 /* Hello cpp iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Hello cpp iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; B3AF01A8184313DE00A98B85 /* ConvexHull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConvexHull.h; sourceTree = ""; }; B3AF01A9184313DE00A98B85 /* ConveyorBelt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConveyorBelt.h; sourceTree = ""; }; B3AF01AA184313DE00A98B85 /* Mobile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Mobile.h; sourceTree = ""; }; B3AF01AB184313DE00A98B85 /* MobileBalanced.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MobileBalanced.h; sourceTree = ""; }; B3AF01AC184313DE00A98B85 /* MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MotorJoint.h; sourceTree = ""; }; D60AE43317F7FFE100757E4B /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; }; ED3674B3187FA6BF0038ECFC /* PerformanceRendererTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceRendererTest.h; sourceTree = ""; }; ED3674B8187FA7020038ECFC /* PerformanceRendererTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceRendererTest.cpp; sourceTree = ""; }; EDCC747E17C455FD007B692C /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 1A1197C91785363400D62A44 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A8C5666180E8E0700EF57C3 /* libchipmunk iOS.a in Frameworks */, 1A8C5667180E8E0700EF57C3 /* libcocos2dx iOS.a in Frameworks */, 1A8C5668180E8E0700EF57C3 /* libcocos2dx-extensions iOS.a in Frameworks */, 1A8C5669180E8E0700EF57C3 /* libCocosDenshion iOS.a in Frameworks */, 1A8C566A180E8E0700EF57C3 /* libluabindings iOS.a in Frameworks */, D6408CB01806515200FB5B4C /* CoreMotion.framework in Frameworks */, 1A1197CB1785363400D62A44 /* libz.dylib in Frameworks */, 1A1197CC1785363400D62A44 /* OpenGLES.framework in Frameworks */, 1A1197CD1785363400D62A44 /* Foundation.framework in Frameworks */, 1A1197CE1785363400D62A44 /* AudioToolbox.framework in Frameworks */, 1A1197CF1785363400D62A44 /* OpenAL.framework in Frameworks */, 1A1197D01785363400D62A44 /* QuartzCore.framework in Frameworks */, 1A1197D11785363400D62A44 /* CoreGraphics.framework in Frameworks */, 1A1197D21785363400D62A44 /* UIKit.framework in Frameworks */, 1A1197D31785363400D62A44 /* AVFoundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A11985F178538E400D62A44 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A8C5899180E8F8F00EF57C3 /* libchipmunk iOS.a in Frameworks */, 1A8C589A180E8F8F00EF57C3 /* libcocos2dx iOS.a in Frameworks */, 1A8C589B180E8F8F00EF57C3 /* libcocos2dx-extensions iOS.a in Frameworks */, 1A8C589C180E8F8F00EF57C3 /* libCocosDenshion iOS.a in Frameworks */, 1A8C589D180E8F8F00EF57C3 /* libluabindings iOS.a in Frameworks */, D60AE43717F9142200757E4B /* CoreMotion.framework in Frameworks */, 1A119864178538E400D62A44 /* libz.dylib in Frameworks */, 1A119865178538E400D62A44 /* OpenGLES.framework in Frameworks */, 1A119866178538E400D62A44 /* Foundation.framework in Frameworks */, 1A119867178538E400D62A44 /* AudioToolbox.framework in Frameworks */, 1A119868178538E400D62A44 /* OpenAL.framework in Frameworks */, 1A119869178538E400D62A44 /* QuartzCore.framework in Frameworks */, 1A11986A178538E400D62A44 /* CoreGraphics.framework in Frameworks */, 1A11986B178538E400D62A44 /* UIKit.framework in Frameworks */, 1A11986C178538E400D62A44 /* AVFoundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB55A17854FE400CDF010 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A8C55C4180E8BBB00EF57C3 /* libchipmunk Mac.a in Frameworks */, 1A8C55C5180E8BBB00EF57C3 /* libcocos2dx Mac.a in Frameworks */, 1A8C55C6180E8BBB00EF57C3 /* libcocos2dx-extensions Mac.a in Frameworks */, 1A8C55C7180E8BBB00EF57C3 /* libCocosDenshion Mac.a in Frameworks */, 1A8C55C8180E8BBB00EF57C3 /* libluabindings Mac.a in Frameworks */, 1A6FB59D1785528E00CDF010 /* libz.dylib in Frameworks */, 1A6FB59C1785528700CDF010 /* libcurl.dylib in Frameworks */, 1A6FB59B1785527300CDF010 /* ApplicationServices.framework in Frameworks */, 1A6FB59A1785526C00CDF010 /* AudioToolbox.framework in Frameworks */, 1A6FB5991785526500CDF010 /* Foundation.framework in Frameworks */, 1A6FB5981785525300CDF010 /* Cocoa.framework in Frameworks */, 1A6FB5971785524D00CDF010 /* OpenGL.framework in Frameworks */, 1A6FB5961785524600CDF010 /* QuartzCore.framework in Frameworks */, 1A6FB5951785523D00CDF010 /* OpenAL.framework in Frameworks */, ED743D1D17D09CD40004076B /* IOKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB7A21785614200CDF010 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A8C588A180E8F7600EF57C3 /* libchipmunk Mac.a in Frameworks */, 1A8C588B180E8F7600EF57C3 /* libcocos2dx Mac.a in Frameworks */, 1A8C588C180E8F7600EF57C3 /* libcocos2dx-extensions Mac.a in Frameworks */, 1A8C588D180E8F7600EF57C3 /* libCocosDenshion Mac.a in Frameworks */, 1A8C588E180E8F7600EF57C3 /* libluabindings Mac.a in Frameworks */, 1A6FB7A71785614200CDF010 /* libz.dylib in Frameworks */, 1A6FB7A81785614200CDF010 /* libcurl.dylib in Frameworks */, 1A6FB7A91785614200CDF010 /* ApplicationServices.framework in Frameworks */, 1A6FB7AA1785614200CDF010 /* AudioToolbox.framework in Frameworks */, 1A6FB7AB1785614200CDF010 /* Foundation.framework in Frameworks */, 1A6FB7AC1785614200CDF010 /* Cocoa.framework in Frameworks */, 1A6FB7AD1785614200CDF010 /* OpenGL.framework in Frameworks */, 1A6FB7AE1785614200CDF010 /* QuartzCore.framework in Frameworks */, 1A6FB7AF1785614200CDF010 /* OpenAL.framework in Frameworks */, ED743D1E17D09D070004076B /* IOKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1AAF534B180E2F4E000584C8 /* libbox2d Mac.a in Frameworks */, 1AAF534C180E2F4E000584C8 /* libchipmunk Mac.a in Frameworks */, 1AAF534D180E2F4E000584C8 /* libcocos2dx Mac.a in Frameworks */, 1AAF534E180E2F4E000584C8 /* libcocos2dx-extensions Mac.a in Frameworks */, 1AAF534F180E2F4E000584C8 /* libCocosDenshion Mac.a in Frameworks */, EDCC747F17C455FD007B692C /* IOKit.framework in Frameworks */, 1A9F808D177E98A600D9A1CB /* libcurl.dylib in Frameworks */, 15C6482F165F399D007D4F18 /* libz.dylib in Frameworks */, 15C64833165F3AFD007D4F18 /* Foundation.framework in Frameworks */, 15C6482D165F3988007D4F18 /* AudioToolbox.framework in Frameworks */, 15C6482B165F3979007D4F18 /* ApplicationServices.framework in Frameworks */, 15C64829165F396B007D4F18 /* OpenAL.framework in Frameworks */, 15C64827165F394E007D4F18 /* QuartzCore.framework in Frameworks */, 15C64825165F3934007D4F18 /* OpenGL.framework in Frameworks */, A05FCACA177C124500BE600E /* Cocoa.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E16841784BDA100B0CA4A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 460E45DF18080238000CDD6D /* libcocos2dx iOS.a in Frameworks */, 460E45E018080238000CDD6D /* libCocosDenshion iOS.a in Frameworks */, D6408CAB1806510600FB5B4C /* CoreMotion.framework in Frameworks */, A01E16881784BDA100B0CA4A /* libz.dylib in Frameworks */, A01E16891784BDA100B0CA4A /* Foundation.framework in Frameworks */, A01E168A1784BDA100B0CA4A /* AudioToolbox.framework in Frameworks */, A01E168D1784BDA100B0CA4A /* QuartzCore.framework in Frameworks */, A01E169B1784BE2400B0CA4A /* AVFoundation.framework in Frameworks */, A01E169C1784BE2800B0CA4A /* CoreGraphics.framework in Frameworks */, A01E169D1784BE2C00B0CA4A /* OpenGLES.framework in Frameworks */, A01E169E1784BE3200B0CA4A /* UIKit.framework in Frameworks */, A01E169F1784BE3A00B0CA4A /* OpenAL.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E17601784C06E00B0CA4A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A9DCA60180E7453007A3AD4 /* libchipmunk iOS.a in Frameworks */, 1A9DCA61180E7453007A3AD4 /* libcocos2dx iOS.a in Frameworks */, 1A9DCA62180E7453007A3AD4 /* libcocos2dx-extensions iOS.a in Frameworks */, 1A9DCA63180E7453007A3AD4 /* libCocosDenshion iOS.a in Frameworks */, 1A9DCA64180E7453007A3AD4 /* libjsbindings iOS.a in Frameworks */, D60AE43817F9143D00757E4B /* CoreMotion.framework in Frameworks */, A01E17661784C06E00B0CA4A /* libz.dylib in Frameworks */, A01E17671784C06E00B0CA4A /* Foundation.framework in Frameworks */, A01E17681784C06E00B0CA4A /* AudioToolbox.framework in Frameworks */, A01E17691784C06E00B0CA4A /* OpenAL.framework in Frameworks */, A01E176A1784C06E00B0CA4A /* QuartzCore.framework in Frameworks */, A01E176B1784C06E00B0CA4A /* CoreGraphics.framework in Frameworks */, A01E176C1784C06E00B0CA4A /* OpenGLES.framework in Frameworks */, A01E176D1784C06E00B0CA4A /* UIKit.framework in Frameworks */, A01E176E1784C06E00B0CA4A /* AVFoundation.framework in Frameworks */, A01E18F81784C59400B0CA4A /* libsqlite3.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18431784C45400B0CA4A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E8F180E804F00497A22 /* libchipmunk iOS.a in Frameworks */, 1A3B1E90180E804F00497A22 /* libcocos2dx iOS.a in Frameworks */, 1A3B1E91180E804F00497A22 /* libcocos2dx-extensions iOS.a in Frameworks */, 1A3B1E92180E804F00497A22 /* libCocosDenshion iOS.a in Frameworks */, 1A3B1E93180E804F00497A22 /* libjsbindings iOS.a in Frameworks */, D6408CAC1806511F00FB5B4C /* CoreMotion.framework in Frameworks */, A01E184B1784C45400B0CA4A /* libz.dylib in Frameworks */, A01E18F91784C59400B0CA4A /* libsqlite3.dylib in Frameworks */, A01E184C1784C45400B0CA4A /* Foundation.framework in Frameworks */, A01E184D1784C45400B0CA4A /* AudioToolbox.framework in Frameworks */, A01E184E1784C45400B0CA4A /* OpenAL.framework in Frameworks */, A01E184F1784C45400B0CA4A /* QuartzCore.framework in Frameworks */, A01E18501784C45400B0CA4A /* CoreGraphics.framework in Frameworks */, A01E18511784C45400B0CA4A /* OpenGLES.framework in Frameworks */, A01E18521784C45400B0CA4A /* UIKit.framework in Frameworks */, A01E18531784C45400B0CA4A /* AVFoundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18781784C4D600B0CA4A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E14180E7E2700497A22 /* libchipmunk iOS.a in Frameworks */, 1A3B1E15180E7E2700497A22 /* libcocos2dx iOS.a in Frameworks */, 1A3B1E16180E7E2700497A22 /* libcocos2dx-extensions iOS.a in Frameworks */, 1A3B1E17180E7E2700497A22 /* libCocosDenshion iOS.a in Frameworks */, 1A3B1E18180E7E2700497A22 /* libjsbindings iOS.a in Frameworks */, D6408CAD1806512D00FB5B4C /* CoreMotion.framework in Frameworks */, A01E18801784C4D600B0CA4A /* libz.dylib in Frameworks */, A01E18811784C4D600B0CA4A /* Foundation.framework in Frameworks */, A01E18821784C4D600B0CA4A /* AudioToolbox.framework in Frameworks */, A01E18831784C4D600B0CA4A /* OpenAL.framework in Frameworks */, A01E18841784C4D600B0CA4A /* QuartzCore.framework in Frameworks */, A01E18851784C4D600B0CA4A /* CoreGraphics.framework in Frameworks */, A01E18861784C4D600B0CA4A /* OpenGLES.framework in Frameworks */, A01E18871784C4D600B0CA4A /* UIKit.framework in Frameworks */, A01E18881784C4D600B0CA4A /* AVFoundation.framework in Frameworks */, A01E18FA1784C59400B0CA4A /* libsqlite3.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18AD1784C4DC00B0CA4A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1F43180E82DC00497A22 /* libchipmunk iOS.a in Frameworks */, 1A3B1F44180E82DC00497A22 /* libcocos2dx iOS.a in Frameworks */, 1A3B1F45180E82DC00497A22 /* libcocos2dx-extensions iOS.a in Frameworks */, 1A3B1F46180E82DC00497A22 /* libCocosDenshion iOS.a in Frameworks */, 1A3B1F47180E82DC00497A22 /* libjsbindings iOS.a in Frameworks */, D6408CAE1806513A00FB5B4C /* CoreMotion.framework in Frameworks */, A01E18B51784C4DC00B0CA4A /* libz.dylib in Frameworks */, A01E18B61784C4DC00B0CA4A /* Foundation.framework in Frameworks */, A01E18B71784C4DC00B0CA4A /* AudioToolbox.framework in Frameworks */, A01E18B81784C4DC00B0CA4A /* OpenAL.framework in Frameworks */, A01E18B91784C4DC00B0CA4A /* QuartzCore.framework in Frameworks */, A01E18BA1784C4DC00B0CA4A /* CoreGraphics.framework in Frameworks */, A01E18BB1784C4DC00B0CA4A /* OpenGLES.framework in Frameworks */, A01E18BC1784C4DC00B0CA4A /* UIKit.framework in Frameworks */, A01E18BD1784C4DC00B0CA4A /* AVFoundation.framework in Frameworks */, A01E18FB1784C59500B0CA4A /* libsqlite3.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18E21784C4E000B0CA4A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1EEB180E81B500497A22 /* libchipmunk iOS.a in Frameworks */, 1A3B1EEC180E81B500497A22 /* libcocos2dx iOS.a in Frameworks */, 1A3B1EED180E81B500497A22 /* libcocos2dx-extensions iOS.a in Frameworks */, 1A3B1EEE180E81B500497A22 /* libCocosDenshion iOS.a in Frameworks */, 1A3B1EEF180E81B500497A22 /* libjsbindings iOS.a in Frameworks */, D6408CAF1806514400FB5B4C /* CoreMotion.framework in Frameworks */, A01E18EA1784C4E000B0CA4A /* libz.dylib in Frameworks */, A01E18EB1784C4E000B0CA4A /* Foundation.framework in Frameworks */, A01E18EC1784C4E000B0CA4A /* AudioToolbox.framework in Frameworks */, A01E18ED1784C4E000B0CA4A /* OpenAL.framework in Frameworks */, A01E18EE1784C4E000B0CA4A /* QuartzCore.framework in Frameworks */, A01E18EF1784C4E000B0CA4A /* CoreGraphics.framework in Frameworks */, A01E18F01784C4E000B0CA4A /* OpenGLES.framework in Frameworks */, A01E18F11784C4E000B0CA4A /* UIKit.framework in Frameworks */, A01E18F21784C4E000B0CA4A /* AVFoundation.framework in Frameworks */, A01E18FC1784C59500B0CA4A /* libsqlite3.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A5DA1782290400987F6C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A9DC9F1180E68D8007A3AD4 /* libchipmunk Mac.a in Frameworks */, 1A9DC9F2180E68D8007A3AD4 /* libcocos2dx Mac.a in Frameworks */, 1A9DC9F3180E68D8007A3AD4 /* libcocos2dx-extensions Mac.a in Frameworks */, 1A9DC9F4180E68D8007A3AD4 /* libCocosDenshion Mac.a in Frameworks */, 1A9DC9F5180E68D8007A3AD4 /* libjsbindings Mac.a in Frameworks */, A035A71217822E9E00987F6C /* libsqlite3.dylib in Frameworks */, A035A5E01782290400987F6C /* libcurl.dylib in Frameworks */, A035A5E11782290400987F6C /* libz.dylib in Frameworks */, A035A5E21782290400987F6C /* Foundation.framework in Frameworks */, A035A5E31782290400987F6C /* AudioToolbox.framework in Frameworks */, A035A5E41782290400987F6C /* ApplicationServices.framework in Frameworks */, A035A5E51782290400987F6C /* OpenAL.framework in Frameworks */, A035A5E61782290400987F6C /* QuartzCore.framework in Frameworks */, A035A5E71782290400987F6C /* OpenGL.framework in Frameworks */, ED743D1717D099F10004076B /* IOKit.framework in Frameworks */, A035A5E81782290400987F6C /* Cocoa.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A76A1782301C00987F6C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E79180E7F6B00497A22 /* libchipmunk Mac.a in Frameworks */, 1A3B1E7A180E7F6B00497A22 /* libcocos2dx Mac.a in Frameworks */, 1A3B1E7B180E7F6B00497A22 /* libcocos2dx-extensions Mac.a in Frameworks */, 1A3B1E7C180E7F6B00497A22 /* libCocosDenshion Mac.a in Frameworks */, 1A3B1E7D180E7F6B00497A22 /* libjsbindings Mac.a in Frameworks */, ED743D1917D09A390004076B /* IOKit.framework in Frameworks */, A035A7701782301C00987F6C /* libsqlite3.dylib in Frameworks */, A035A7711782301C00987F6C /* libcurl.dylib in Frameworks */, A035A7721782301C00987F6C /* libz.dylib in Frameworks */, A035A7731782301C00987F6C /* Foundation.framework in Frameworks */, A035A7741782301C00987F6C /* AudioToolbox.framework in Frameworks */, A035A7751782301C00987F6C /* ApplicationServices.framework in Frameworks */, A035A7761782301C00987F6C /* OpenAL.framework in Frameworks */, A035A7771782301C00987F6C /* QuartzCore.framework in Frameworks */, A035A7781782301C00987F6C /* OpenGL.framework in Frameworks */, A035A7791782301C00987F6C /* Cocoa.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A9E417823FE100987F6C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1DF2180E7CAF00497A22 /* libchipmunk Mac.a in Frameworks */, 1A3B1DF3180E7CAF00497A22 /* libcocos2dx Mac.a in Frameworks */, 1A3B1DF4180E7CAF00497A22 /* libcocos2dx-extensions Mac.a in Frameworks */, 1A3B1DF5180E7CAF00497A22 /* libCocosDenshion Mac.a in Frameworks */, 1A3B1DF6180E7CAF00497A22 /* libjsbindings Mac.a in Frameworks */, A035A9EA17823FE100987F6C /* libsqlite3.dylib in Frameworks */, A035A9EB17823FE100987F6C /* libcurl.dylib in Frameworks */, A035A9EC17823FE100987F6C /* libz.dylib in Frameworks */, A035A9ED17823FE100987F6C /* Foundation.framework in Frameworks */, A035A9EE17823FE100987F6C /* AudioToolbox.framework in Frameworks */, A035A9EF17823FE100987F6C /* ApplicationServices.framework in Frameworks */, A035A9F017823FE100987F6C /* OpenAL.framework in Frameworks */, A035A9F117823FE100987F6C /* QuartzCore.framework in Frameworks */, A035A9F217823FE100987F6C /* OpenGL.framework in Frameworks */, A035A9F317823FE100987F6C /* Cocoa.framework in Frameworks */, ED743D1A17D09A730004076B /* IOKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AAB21782422400987F6C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1F34180E82C800497A22 /* libchipmunk Mac.a in Frameworks */, 1A3B1F35180E82C800497A22 /* libcocos2dx Mac.a in Frameworks */, 1A3B1F36180E82C800497A22 /* libcocos2dx-extensions Mac.a in Frameworks */, 1A3B1F37180E82C800497A22 /* libCocosDenshion Mac.a in Frameworks */, 1A3B1F38180E82C800497A22 /* libjsbindings Mac.a in Frameworks */, A035AAB81782422400987F6C /* libsqlite3.dylib in Frameworks */, A035AAB91782422400987F6C /* libcurl.dylib in Frameworks */, A035AABA1782422400987F6C /* libz.dylib in Frameworks */, A035AABB1782422400987F6C /* Foundation.framework in Frameworks */, A035AABC1782422400987F6C /* AudioToolbox.framework in Frameworks */, A035AABD1782422400987F6C /* ApplicationServices.framework in Frameworks */, A035AABE1782422400987F6C /* OpenAL.framework in Frameworks */, A035AABF1782422400987F6C /* QuartzCore.framework in Frameworks */, A035AAC01782422400987F6C /* OpenGL.framework in Frameworks */, A035AAC11782422400987F6C /* Cocoa.framework in Frameworks */, ED743D1B17D09AAE0004076B /* IOKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AC241782453000987F6C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1EDC180E811D00497A22 /* libchipmunk Mac.a in Frameworks */, 1A3B1EDD180E811D00497A22 /* libcocos2dx Mac.a in Frameworks */, 1A3B1EDE180E811D00497A22 /* libcocos2dx-extensions Mac.a in Frameworks */, 1A3B1EDF180E811D00497A22 /* libCocosDenshion Mac.a in Frameworks */, 1A3B1EE0180E811D00497A22 /* libjsbindings Mac.a in Frameworks */, A035AC2A1782453000987F6C /* libsqlite3.dylib in Frameworks */, A035AC2B1782453000987F6C /* libcurl.dylib in Frameworks */, A035AC2C1782453000987F6C /* libz.dylib in Frameworks */, ED743D1C17D09C990004076B /* IOKit.framework in Frameworks */, A035AC2D1782453000987F6C /* Foundation.framework in Frameworks */, A035AC2E1782453000987F6C /* AudioToolbox.framework in Frameworks */, A035AC2F1782453000987F6C /* ApplicationServices.framework in Frameworks */, A035AC301782453000987F6C /* OpenAL.framework in Frameworks */, A035AC311782453000987F6C /* QuartzCore.framework in Frameworks */, A035AC321782453000987F6C /* OpenGL.framework in Frameworks */, A035AC331782453000987F6C /* Cocoa.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AD64178254A300987F6C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 460E45861807FDC3000CDD6D /* libcocos2dx Mac.a in Frameworks */, 460E45871807FDC3000CDD6D /* libCocosDenshion Mac.a in Frameworks */, A035AD6A178254A300987F6C /* libcurl.dylib in Frameworks */, A035AD6B178254A300987F6C /* libz.dylib in Frameworks */, A035AD6C178254A300987F6C /* Foundation.framework in Frameworks */, A035AD6D178254A300987F6C /* AudioToolbox.framework in Frameworks */, A035AD6E178254A300987F6C /* ApplicationServices.framework in Frameworks */, A035AD6F178254A300987F6C /* OpenAL.framework in Frameworks */, A035AD70178254A300987F6C /* QuartzCore.framework in Frameworks */, A035AD71178254A300987F6C /* OpenGL.framework in Frameworks */, A035AD72178254A300987F6C /* Cocoa.framework in Frameworks */, ED743D1617D098B60004076B /* IOKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AE79178255DC00987F6C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 460E44FD1807E413000CDD6D /* libcocos2dx Mac.a in Frameworks */, A035AE7C178255DC00987F6C /* libcurl.dylib in Frameworks */, A035AE7D178255DC00987F6C /* libz.dylib in Frameworks */, A035AE7E178255DC00987F6C /* Foundation.framework in Frameworks */, A035AE7F178255DC00987F6C /* AudioToolbox.framework in Frameworks */, A035AE80178255DC00987F6C /* ApplicationServices.framework in Frameworks */, A035AE81178255DC00987F6C /* OpenAL.framework in Frameworks */, A035AE82178255DC00987F6C /* QuartzCore.framework in Frameworks */, A035AE83178255DC00987F6C /* OpenGL.framework in Frameworks */, A035AE84178255DC00987F6C /* Cocoa.framework in Frameworks */, ED743D1517D098AF0004076B /* IOKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A52171783A1D20073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 1AAF53FE180E39D4000584C8 /* libbox2d iOS.a in Frameworks */, 1AAF53FF180E39D4000584C8 /* libchipmunk iOS.a in Frameworks */, 1AAF5400180E39D4000584C8 /* libcocos2dx iOS.a in Frameworks */, 1AAF5401180E39D4000584C8 /* libcocos2dx-extensions iOS.a in Frameworks */, 1AAF5402180E39D4000584C8 /* libCocosDenshion iOS.a in Frameworks */, D60AE43417F7FFE100757E4B /* CoreMotion.framework in Frameworks */, A07A521E1783A1D20073F6A7 /* libz.dylib in Frameworks */, A07A521F1783A1D20073F6A7 /* Foundation.framework in Frameworks */, A07A52201783A1D20073F6A7 /* AudioToolbox.framework in Frameworks */, A07A52221783A1D20073F6A7 /* OpenAL.framework in Frameworks */, A07A52231783A1D20073F6A7 /* QuartzCore.framework in Frameworks */, A07A52BE1783AF1E0073F6A7 /* CoreGraphics.framework in Frameworks */, A07A52BF1783AF210073F6A7 /* OpenGLES.framework in Frameworks */, A07A52C01783AF250073F6A7 /* UIKit.framework in Frameworks */, A07A52C31783B02C0073F6A7 /* AVFoundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A536F1784AC9B0073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 460E44BB1807DDC2000CDD6D /* libcocos2dx iOS.a in Frameworks */, D6408CA8180650F200FB5B4C /* CoreMotion.framework in Frameworks */, A07A53751784AC9B0073F6A7 /* libz.dylib in Frameworks */, A07A537B1784AC9B0073F6A7 /* OpenGLES.framework in Frameworks */, A07A53761784AC9B0073F6A7 /* Foundation.framework in Frameworks */, A07A53771784AC9B0073F6A7 /* AudioToolbox.framework in Frameworks */, A07A53781784AC9B0073F6A7 /* OpenAL.framework in Frameworks */, A07A53791784AC9B0073F6A7 /* QuartzCore.framework in Frameworks */, A07A537A1784AC9B0073F6A7 /* CoreGraphics.framework in Frameworks */, A07A537C1784AC9B0073F6A7 /* UIKit.framework in Frameworks */, A07A537D1784AC9B0073F6A7 /* AVFoundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 19C28FACFE9D520D11CA2CBB /* Products */ = { isa = PBXGroup; children = ( 1D6058910D05DD3D006BFB54 /* Test cpp Mac.app */, A035A5EC1782290400987F6C /* Test JavaScript Mac.app */, A035A77D1782301C00987F6C /* JS Watermelon With Me Mac.app */, A035A9F717823FE100987F6C /* JS Moon Warriors Mac.app */, A035AAC51782422400987F6C /* JS Crystal Craze Mac.app */, A035AC371782453000987F6C /* JS CocosDragon Mac.app */, A035AD76178254A300987F6C /* Simple Game Mac.app */, A035AE88178255DC00987F6C /* Hello cpp Mac.app */, A07A52291783A1D20073F6A7 /* Test cpp iOS.app */, A07A53811784AC9B0073F6A7 /* Hello cpp iOS.app */, A01E16931784BDA100B0CA4A /* Simple Game iOS.app */, A01E17721784C06E00B0CA4A /* Test JavaScript iOS.app */, A01E18571784C45500B0CA4A /* JS Watermelon With Me iOS.app */, A01E188C1784C4D600B0CA4A /* JS Moon Warriors iOS.app */, A01E18C11784C4DC00B0CA4A /* JS Crystal Craze iOS.app */, A01E18F61784C4E000B0CA4A /* JS CocosDragon iOS.app */, 1A1197D71785363400D62A44 /* Hello lua iOS.app */, 1A119870178538E400D62A44 /* Test lua iOS.app */, 1A6FB56B17854FE400CDF010 /* Hello lua Mac.app */, 1A6FB7B31785614200CDF010 /* Test lua Mac.app */, ); name = Products; sourceTree = ""; }; 1A3B1DAF180E7C3400497A22 /* MoonWarriors */ = { isa = PBXGroup; children = ( 1A3B1DB0180E7C4700497A22 /* Classes */, 1A3B1DB5180E7C5100497A22 /* proj.ios */, 1A3B1DDB180E7C5C00497A22 /* proj.mac */, 1A3B1DF7180E7CF700497A22 /* Resources */, ); name = MoonWarriors; sourceTree = ""; }; 1A3B1DB0180E7C4700497A22 /* Classes */ = { isa = PBXGroup; children = ( 1A3B1DB1180E7C4700497A22 /* AppDelegate.cpp */, 1A3B1DB2180E7C4700497A22 /* AppDelegate.h */, ); name = Classes; path = ../samples/Javascript/MoonWarriors/Classes; sourceTree = ""; }; 1A3B1DB5180E7C5100497A22 /* proj.ios */ = { isa = PBXGroup; children = ( 1A3B1DB6180E7C5100497A22 /* AppController.h */, 1A3B1DB7180E7C5100497A22 /* AppController.mm */, 1A3B1DB8180E7C5100497A22 /* Default-568h@2x.png */, 1A3B1DB9180E7C5100497A22 /* Default.png */, 1A3B1DBA180E7C5100497A22 /* Default@2x.png */, 1A3B1DBB180E7C5100497A22 /* Icon-120.png */, 1A3B1DBC180E7C5100497A22 /* Icon-144.png */, 1A3B1DBD180E7C5100497A22 /* Icon-152.png */, 1A3B1DBE180E7C5100497A22 /* Icon-72.png */, 1A3B1DBF180E7C5100497A22 /* Icon-76.png */, 1A3B1DC0180E7C5100497A22 /* Icon-Small-50.png */, 1A3B1DC1180E7C5100497A22 /* Icon-Small.png */, 1A3B1DC2180E7C5100497A22 /* Icon-Small@2x.png */, 1A3B1DC3180E7C5100497A22 /* Icon.png */, 1A3B1DC4180E7C5100497A22 /* Icon@2x.png */, 1A3B1DC5180E7C5100497A22 /* Info.plist */, 1A3B1DC6180E7C5100497A22 /* main.m */, 1A3B1DC7180E7C5100497A22 /* Prefix.pch */, 1A3B1DC8180E7C5100497A22 /* RootViewController.h */, 1A3B1DC9180E7C5100497A22 /* RootViewController.mm */, ); name = proj.ios; path = ../samples/Javascript/MoonWarriors/proj.ios; sourceTree = ""; }; 1A3B1DDB180E7C5C00497A22 /* proj.mac */ = { isa = PBXGroup; children = ( 1A3B1DDC180E7C5C00497A22 /* InfoPlist.strings */, 1A3B1DDE180E7C5C00497A22 /* MainMenu.xib */, 1A3B1DE0180E7C5C00497A22 /* Icon.icns */, 1A3B1DE1180E7C5C00497A22 /* Info.plist */, 1A3B1DE2180E7C5C00497A22 /* main.cpp */, ); name = proj.mac; path = ../samples/Javascript/MoonWarriors/proj.mac; sourceTree = ""; }; 1A3B1DF7180E7CF700497A22 /* Resources */ = { isa = PBXGroup; children = ( 1A3B1DF8180E7D2200497A22 /* MoonWarriors-jsb.js */, 1A3B1DF9180E7D2200497A22 /* res */, 1A3B1DFA180E7D2200497A22 /* src */, ); name = Resources; sourceTree = ""; }; 1A3B1E1A180E7ED800497A22 /* WatermelonWithMe */ = { isa = PBXGroup; children = ( 1A3B1E3D180E7F1500497A22 /* Classes */, 1A3B1E42180E7F1E00497A22 /* proj.ios */, 1A3B1E62180E7F2400497A22 /* proj.mac */, 1A3B1E1B180E7EE400497A22 /* Resources */, ); name = WatermelonWithMe; sourceTree = ""; }; 1A3B1E1B180E7EE400497A22 /* Resources */ = { isa = PBXGroup; children = ( 1A3B1E1C180E7EFA00497A22 /* boot-html5.js */, 1A3B1E1D180E7EFA00497A22 /* boot-jsb.js */, 1A3B1E1E180E7EFA00497A22 /* index.html */, 1A3B1E1F180E7EFA00497A22 /* levels.js */, 1A3B1E20180E7EFA00497A22 /* main.js */, 1A3B1E21180E7EFA00497A22 /* Platform */, 1A3B1E22180E7EFA00497A22 /* res */, 1A3B1E23180E7EFA00497A22 /* resources-html5.js */, 1A3B1E24180E7EFA00497A22 /* resources-jsb.js */, 1A3B1E25180E7EFA00497A22 /* watermelon_with_me.js */, ); name = Resources; sourceTree = ""; }; 1A3B1E3D180E7F1500497A22 /* Classes */ = { isa = PBXGroup; children = ( 1A3B1E3E180E7F1500497A22 /* AppDelegate.cpp */, 1A3B1E3F180E7F1500497A22 /* AppDelegate.h */, ); name = Classes; path = ../samples/Javascript/WatermelonWithMe/Classes; sourceTree = ""; }; 1A3B1E42180E7F1E00497A22 /* proj.ios */ = { isa = PBXGroup; children = ( 1A3B1E43180E7F1E00497A22 /* AppController.h */, 1A3B1E44180E7F1E00497A22 /* AppController.mm */, 1A3B1E45180E7F1E00497A22 /* Default-568h@2x.png */, 1A3B1E46180E7F1E00497A22 /* Default.png */, 1A3B1E47180E7F1E00497A22 /* Default@2x.png */, 1A3B1E48180E7F1E00497A22 /* Icon-114.png */, 1A3B1E49180E7F1E00497A22 /* Icon-120.png */, 1A3B1E4A180E7F1E00497A22 /* Icon-144.png */, 1A3B1E4B180E7F1E00497A22 /* Icon-152.png */, 1A3B1E4C180E7F1E00497A22 /* Icon-57.png */, 1A3B1E4D180E7F1E00497A22 /* Icon-72.png */, 1A3B1E4E180E7F1E00497A22 /* Icon-76.png */, 1A3B1E4F180E7F1E00497A22 /* Info.plist */, 1A3B1E50180E7F1E00497A22 /* main.m */, 1A3B1E51180E7F1E00497A22 /* Prefix.pch */, 1A3B1E52180E7F1E00497A22 /* RootViewController.h */, 1A3B1E53180E7F1E00497A22 /* RootViewController.mm */, ); name = proj.ios; path = ../samples/Javascript/WatermelonWithMe/proj.ios; sourceTree = ""; }; 1A3B1E62180E7F2400497A22 /* proj.mac */ = { isa = PBXGroup; children = ( 1A3B1E63180E7F2400497A22 /* InfoPlist.strings */, 1A3B1E65180E7F2400497A22 /* MainMenu.xib */, 1A3B1E67180E7F2400497A22 /* Icon.icns */, 1A3B1E68180E7F2400497A22 /* Info.plist */, 1A3B1E69180E7F2400497A22 /* main.cpp */, ); name = proj.mac; path = ../samples/Javascript/WatermelonWithMe/proj.mac; sourceTree = ""; }; 1A3B1E9B180E809F00497A22 /* CocosDragonJS */ = { isa = PBXGroup; children = ( 1A3B1E9C180E80B600497A22 /* Classes */, 1A3B1EA1180E80BD00497A22 /* proj.ios */, 1A3B1EC1180E80C700497A22 /* proj.mac */, 1A3B1ECE180E80CE00497A22 /* Resources */, ); name = CocosDragonJS; sourceTree = ""; }; 1A3B1E9C180E80B600497A22 /* Classes */ = { isa = PBXGroup; children = ( 1A3B1E9D180E80B600497A22 /* AppDelegate.cpp */, 1A3B1E9E180E80B600497A22 /* AppDelegate.h */, ); name = Classes; path = ../samples/Javascript/CocosDragonJS/Classes; sourceTree = ""; }; 1A3B1EA1180E80BD00497A22 /* proj.ios */ = { isa = PBXGroup; children = ( 1A3B1EA2180E80BD00497A22 /* AppController.h */, 1A3B1EA3180E80BD00497A22 /* AppController.mm */, 1A3B1EA4180E80BD00497A22 /* Default-568h@2x.png */, 1A3B1EA5180E80BD00497A22 /* Default.png */, 1A3B1EA6180E80BD00497A22 /* Default@2x.png */, 1A3B1EA7180E80BD00497A22 /* Icon-114.png */, 1A3B1EA8180E80BD00497A22 /* Icon-120.png */, 1A3B1EA9180E80BD00497A22 /* Icon-144.png */, 1A3B1EAA180E80BD00497A22 /* Icon-152.png */, 1A3B1EAB180E80BD00497A22 /* Icon-57.png */, 1A3B1EAC180E80BD00497A22 /* Icon-72.png */, 1A3B1EAD180E80BD00497A22 /* Icon-76.png */, 1A3B1EAE180E80BD00497A22 /* Info.plist */, 1A3B1EAF180E80BD00497A22 /* main.m */, 1A3B1EB0180E80BD00497A22 /* Prefix.pch */, 1A3B1EB1180E80BD00497A22 /* RootViewController.h */, 1A3B1EB2180E80BD00497A22 /* RootViewController.mm */, ); name = proj.ios; path = ../samples/Javascript/CocosDragonJS/proj.ios; sourceTree = ""; }; 1A3B1EC1180E80C700497A22 /* proj.mac */ = { isa = PBXGroup; children = ( 1A3B1EC2180E80C700497A22 /* InfoPlist.strings */, 1A3B1EC4180E80C700497A22 /* MainMenu.xib */, 1A3B1EC6180E80C700497A22 /* Icon.icns */, 1A3B1EC7180E80C700497A22 /* Info.plist */, 1A3B1EC8180E80C700497A22 /* main.cpp */, ); name = proj.mac; path = ../samples/Javascript/CocosDragonJS/proj.mac; sourceTree = ""; }; 1A3B1ECE180E80CE00497A22 /* Resources */ = { isa = PBXGroup; children = ( 1A3B1ECF180E80E200497A22 /* Published files iOS */, ); name = Resources; sourceTree = ""; }; 1A3B1EF0180E822B00497A22 /* CrystalCraze */ = { isa = PBXGroup; children = ( 1A3B1EF8180E828300497A22 /* Classes */, 1A3B1EFD180E828E00497A22 /* proj.ios */, 1A3B1F1D180E829600497A22 /* proj.mac */, 1A3B1EF1180E823500497A22 /* Resources */, ); name = CrystalCraze; sourceTree = ""; }; 1A3B1EF1180E823500497A22 /* Resources */ = { isa = PBXGroup; children = ( 1A3B1EF2180E826E00497A22 /* Published-iOS */, ); name = Resources; sourceTree = ""; }; 1A3B1EF8180E828300497A22 /* Classes */ = { isa = PBXGroup; children = ( 1A3B1EF9180E828300497A22 /* AppDelegate.cpp */, 1A3B1EFA180E828300497A22 /* AppDelegate.h */, ); name = Classes; path = ../samples/Javascript/CrystalCraze/Classes; sourceTree = ""; }; 1A3B1EFD180E828E00497A22 /* proj.ios */ = { isa = PBXGroup; children = ( 1A3B1EFE180E828E00497A22 /* AppController.h */, 1A3B1EFF180E828E00497A22 /* AppController.mm */, 1A3B1F00180E828E00497A22 /* Default-568h@2x.png */, 1A3B1F01180E828E00497A22 /* Default.png */, 1A3B1F02180E828E00497A22 /* Default@2x.png */, 1A3B1F03180E828E00497A22 /* Icon-114.png */, 1A3B1F04180E828E00497A22 /* Icon-120.png */, 1A3B1F05180E828E00497A22 /* Icon-144.png */, 1A3B1F06180E828E00497A22 /* Icon-152.png */, 1A3B1F07180E828E00497A22 /* Icon-57.png */, 1A3B1F08180E828E00497A22 /* Icon-72.png */, 1A3B1F09180E828E00497A22 /* Icon-76.png */, 1A3B1F0A180E828E00497A22 /* Info.plist */, 1A3B1F0B180E828E00497A22 /* main.m */, 1A3B1F0C180E828E00497A22 /* Prefix.pch */, 1A3B1F0D180E828E00497A22 /* RootViewController.h */, 1A3B1F0E180E828E00497A22 /* RootViewController.mm */, ); name = proj.ios; path = ../samples/Javascript/CrystalCraze/proj.ios; sourceTree = ""; }; 1A3B1F1D180E829600497A22 /* proj.mac */ = { isa = PBXGroup; children = ( 1A3B1F1E180E829600497A22 /* InfoPlist.strings */, 1A3B1F20180E829600497A22 /* MainMenu.xib */, 1A3B1F22180E829600497A22 /* Icon.icns */, 1A3B1F23180E829600497A22 /* Info.plist */, 1A3B1F24180E829600497A22 /* main.cpp */, ); name = proj.mac; path = ../samples/Javascript/CrystalCraze/proj.mac; sourceTree = ""; }; 1A3B1F48180E85E100497A22 /* HelloLua */ = { isa = PBXGroup; children = ( 1A8C552F180E8B1C00EF57C3 /* Classes */, 1A8C5538180E8B3D00EF57C3 /* proj.ios */, 1A8C5558180E8B4500EF57C3 /* proj.mac */, 1A8C5566180E8B5100EF57C3 /* Resources */, ); name = HelloLua; sourceTree = ""; }; 1A6A41DE180BE41100565AC2 /* Classes */ = { isa = PBXGroup; children = ( 1A6A41E0180BE41100565AC2 /* AppDelegate.h */, 1A6A41DF180BE41100565AC2 /* AppDelegate.cpp */, 1A6A41E1180BE41100565AC2 /* GameOverScene.cpp */, 1A6A41E2180BE41100565AC2 /* GameOverScene.h */, 1A6A41E3180BE41100565AC2 /* HelloWorldScene.cpp */, 1A6A41E4180BE41100565AC2 /* HelloWorldScene.h */, ); path = Classes; sourceTree = ""; }; 1A804EB61876890200C117B5 /* UnitTest */ = { isa = PBXGroup; children = ( 1A80519518768FD300C117B5 /* UnitTest.cpp */, 1A80519618768FD300C117B5 /* UnitTest.h */, ); name = UnitTest; sourceTree = ""; }; 1A8C552F180E8B1C00EF57C3 /* Classes */ = { isa = PBXGroup; children = ( 1A8C5530180E8B1C00EF57C3 /* AppDelegate.cpp */, 1A8C5531180E8B1C00EF57C3 /* AppDelegate.h */, ); name = Classes; path = ../samples/Lua/HelloLua/Classes; sourceTree = ""; }; 1A8C5538180E8B3D00EF57C3 /* proj.ios */ = { isa = PBXGroup; children = ( 1A8C5539180E8B3D00EF57C3 /* AppController.h */, 1A8C553A180E8B3D00EF57C3 /* AppController.mm */, 1A8C553B180E8B3D00EF57C3 /* Default-568h@2x.png */, 1A8C553C180E8B3D00EF57C3 /* Default.png */, 1A8C553D180E8B3D00EF57C3 /* Default@2x.png */, 1A8C553E180E8B3D00EF57C3 /* HelloLua_Prefix.pch */, 1A8C553F180E8B3D00EF57C3 /* Icon-114.png */, 1A8C5540180E8B3D00EF57C3 /* Icon-120.png */, 1A8C5541180E8B3D00EF57C3 /* Icon-144.png */, 1A8C5542180E8B3D00EF57C3 /* Icon-152.png */, 1A8C5543180E8B3D00EF57C3 /* Icon-57.png */, 1A8C5544180E8B3D00EF57C3 /* Icon-72.png */, 1A8C5545180E8B3D00EF57C3 /* Icon-76.png */, 1A8C5546180E8B3D00EF57C3 /* Info.plist */, 1A8C5547180E8B3D00EF57C3 /* main.m */, 1A8C5548180E8B3D00EF57C3 /* RootViewController.h */, 1A8C5549180E8B3D00EF57C3 /* RootViewController.mm */, ); name = proj.ios; path = ../samples/Lua/HelloLua/proj.ios; sourceTree = ""; }; 1A8C5558180E8B4500EF57C3 /* proj.mac */ = { isa = PBXGroup; children = ( 1A8C5559180E8B4500EF57C3 /* InfoPlist.strings */, 1A8C555B180E8B4500EF57C3 /* MainMenu.xib */, 1A8C555D180E8B4500EF57C3 /* HelloLua_Prefix.pch */, 1A8C555E180E8B4500EF57C3 /* Icon.icns */, 1A8C555F180E8B4500EF57C3 /* Info.plist */, 1A8C5560180E8B4500EF57C3 /* main.cpp */, ); name = proj.mac; path = ../samples/Lua/HelloLua/proj.mac; sourceTree = ""; }; 1A8C5566180E8B5100EF57C3 /* Resources */ = { isa = PBXGroup; children = ( 15A71DB61894AE6200F30AC0 /* mobdebug.lua */, 1A8C5567180E8B5100EF57C3 /* .gitignore */, 1A8C5569180E8B5100EF57C3 /* background.mp3 */, 1A8C556A180E8B5100EF57C3 /* background.ogg */, 1A8C556B180E8B5100EF57C3 /* crop.png */, 1A8C556D180E8B5100EF57C3 /* dog.png */, 1A8C556E180E8B5100EF57C3 /* effect1.wav */, 1A8C556F180E8B5100EF57C3 /* farm.jpg */, 1A8C5570180E8B5100EF57C3 /* fonts */, 1A8C5572180E8B5100EF57C3 /* hello.lua */, 1A8C5573180E8B5100EF57C3 /* hello2.lua */, 1A8C5574180E8B5100EF57C3 /* land.png */, 1A8C5575180E8B5100EF57C3 /* menu1.png */, 1A8C5576180E8B5100EF57C3 /* menu2.png */, ); name = Resources; path = ../samples/Lua/HelloLua/Resources; sourceTree = ""; }; 1A8C5570180E8B5100EF57C3 /* fonts */ = { isa = PBXGroup; children = ( 1A8C5571180E8B5100EF57C3 /* Marker Felt.ttf */, ); path = fonts; sourceTree = ""; }; 1A8C5595180E8B6500EF57C3 /* Lua Common */ = { isa = PBXGroup; children = ( 15982CE1187656CD00625972 /* GuiConstants.lua */, 15F4C846187551340082884F /* CocoStudio.lua */, 15F4C82818751B590082884F /* extern.lua */, 15394DF2182E8F5D000A418D /* StudioConstants.lua */, 1585AB34182299FA00000FB5 /* json.lua */, 1585AB101821FA1A00000FB5 /* luaoc.lua */, 1A8C5596180E8B8400EF57C3 /* AudioEngine.lua */, 1A8C5597180E8B8400EF57C3 /* CCBReaderLoad.lua */, 1A8C5598180E8B8400EF57C3 /* Cocos2d.lua */, 1A8C5599180E8B8400EF57C3 /* Cocos2dConstants.lua */, 1A8C559A180E8B8400EF57C3 /* Deprecated.lua */, 1A8C559B180E8B8400EF57C3 /* DeprecatedClass.lua */, 1A8C559C180E8B8400EF57C3 /* DeprecatedEnum.lua */, 1A8C559D180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua */, 1A8C559E180E8B8400EF57C3 /* DrawPrimitives.lua */, 1A8C559F180E8B8400EF57C3 /* luaj.lua */, 1A8C55A0180E8B8400EF57C3 /* Opengl.lua */, 1A8C55A1180E8B8400EF57C3 /* OpenglConstants.lua */, ); name = "Lua Common"; sourceTree = ""; }; 1A8C566B180E8E7F00EF57C3 /* TestLua */ = { isa = PBXGroup; children = ( 1A8C566C180E8E9600EF57C3 /* Classes */, 1A8C5852180E8F0100EF57C3 /* proj.ios */, 1A8C5872180E8F0C00EF57C3 /* proj.mac */, 1A8C5671180E8EA400EF57C3 /* Resources */, ); name = TestLua; sourceTree = ""; }; 1A8C566C180E8E9600EF57C3 /* Classes */ = { isa = PBXGroup; children = ( 1585AB491823A55400000FB5 /* lua_assetsmanager_test_sample.cpp */, 1585AB4A1823A55400000FB5 /* lua_assetsmanager_test_sample.h */, 1A8C566D180E8E9600EF57C3 /* AppDelegate.cpp */, 1A8C566E180E8E9600EF57C3 /* AppDelegate.h */, ); name = Classes; path = ../samples/Lua/TestLua/Classes; sourceTree = ""; }; 1A8C5671180E8EA400EF57C3 /* Resources */ = { isa = PBXGroup; children = ( 1A0800BC18780B2A00E62F93 /* cocosbuilderRes */, 1A0800BD18780B2A00E62F93 /* luaScript */, ); name = Resources; path = ../samples/Lua/TestLua/Resources; sourceTree = ""; }; 1A8C5852180E8F0100EF57C3 /* proj.ios */ = { isa = PBXGroup; children = ( 1585AAC61821F8D900000FB5 /* LuaObjectCBridgeTest.h */, 1585AAC71821F8D900000FB5 /* LuaObjectCBridgeTest.mm */, 1A8C5853180E8F0100EF57C3 /* AppController.h */, 1A8C5854180E8F0100EF57C3 /* AppController.mm */, 1A8C5855180E8F0100EF57C3 /* Default-568h@2x.png */, 1A8C5856180E8F0100EF57C3 /* Default.png */, 1A8C5857180E8F0100EF57C3 /* Default@2x.png */, 1A8C5858180E8F0100EF57C3 /* Icon-114.png */, 1A8C5859180E8F0100EF57C3 /* Icon-120.png */, 1A8C585A180E8F0100EF57C3 /* Icon-144.png */, 1A8C585B180E8F0100EF57C3 /* Icon-152.png */, 1A8C585C180E8F0100EF57C3 /* Icon-57.png */, 1A8C585D180E8F0100EF57C3 /* Icon-72.png */, 1A8C585E180E8F0100EF57C3 /* Icon-76.png */, 1A8C585F180E8F0100EF57C3 /* Info.plist */, 1A8C5860180E8F0100EF57C3 /* main.m */, 1A8C5861180E8F0100EF57C3 /* RootViewController.h */, 1A8C5862180E8F0100EF57C3 /* RootViewController.mm */, 1A8C5863180E8F0100EF57C3 /* TestLua_Prefix.pch */, ); name = proj.ios; path = ../samples/Lua/TestLua/proj.ios; sourceTree = ""; }; 1A8C5872180E8F0C00EF57C3 /* proj.mac */ = { isa = PBXGroup; children = ( 1585AB161821FF4C00000FB5 /* LuaObjectCBridgeTest.h */, 1585AB171821FF4C00000FB5 /* LuaObjectCBridgeTest.mm */, 1A8C5873180E8F0C00EF57C3 /* InfoPlist.strings */, 1A8C5875180E8F0C00EF57C3 /* MainMenu.xib */, 1A8C5877180E8F0C00EF57C3 /* Icon.icns */, 1A8C5878180E8F0C00EF57C3 /* Info.plist */, 1A8C5879180E8F0C00EF57C3 /* main.cpp */, 1A8C587A180E8F0C00EF57C3 /* TestLua_Prefix.pch */, ); name = proj.mac; path = ../samples/Lua/TestLua/proj.mac; sourceTree = ""; }; 1A914198180BEB4B00CFC31F /* proj.mac */ = { isa = PBXGroup; children = ( 1A914199180BEB6A00CFC31F /* en.lproj */, 1A91419E180BEB6A00CFC31F /* Icon.icns */, 1A91419F180BEB6A00CFC31F /* main.cpp */, 1A9141A0180BEB6A00CFC31F /* SampleGame_Prefix.pch */, ); name = proj.mac; sourceTree = ""; }; 1A914199180BEB6A00CFC31F /* en.lproj */ = { isa = PBXGroup; children = ( 1A91419A180BEB6A00CFC31F /* InfoPlist.strings */, 1A91419C180BEB6A00CFC31F /* MainMenu.xib */, ); name = en.lproj; path = proj.mac/en.lproj; sourceTree = ""; }; 1A9DC29F180E65A1007A3AD4 /* TestJavascript */ = { isa = PBXGroup; children = ( 1A9DC2A0180E65D4007A3AD4 /* Classes */, 1A9DC2D7180E66BB007A3AD4 /* JS Tests */, 1A9DC2B5180E668B007A3AD4 /* proj.ios */, 1A9DC2A5180E6681007A3AD4 /* proj.mac */, ); name = TestJavascript; sourceTree = ""; }; 1A9DC2A0180E65D4007A3AD4 /* Classes */ = { isa = PBXGroup; children = ( 1A9DC2A1180E65D4007A3AD4 /* AppDelegate.cpp */, 1A9DC2A2180E65D4007A3AD4 /* AppDelegate.h */, ); name = Classes; path = ../samples/Javascript/TestJavascript/Classes; sourceTree = ""; }; 1A9DC2A5180E6681007A3AD4 /* proj.mac */ = { isa = PBXGroup; children = ( 1A9DC2A6180E6681007A3AD4 /* InfoPlist.strings */, 1A9DC2A8180E6681007A3AD4 /* MainMenu.xib */, 1A9DC2AA180E6681007A3AD4 /* Icon.icns */, 1A9DC2AB180E6681007A3AD4 /* Info-obfuscated.plist */, 1A9DC2AC180E6681007A3AD4 /* main.cpp */, 1A9DC2AD180E6681007A3AD4 /* Test_Info.plist */, 1A9DC2AE180E6681007A3AD4 /* Test_Prefix.pch */, ); name = proj.mac; path = ../samples/Javascript/TestJavascript/proj.mac; sourceTree = ""; }; 1A9DC2B5180E668B007A3AD4 /* proj.ios */ = { isa = PBXGroup; children = ( 1A9DC2B6180E668B007A3AD4 /* AppController.h */, 1A9DC2B7180E668B007A3AD4 /* AppController.mm */, 1A9DC2B8180E668B007A3AD4 /* Default-568h@2x.png */, 1A9DC2B9180E668B007A3AD4 /* Default.png */, 1A9DC2BA180E668B007A3AD4 /* Default@2x.png */, 1A9DC2BB180E668B007A3AD4 /* Icon-114.png */, 1A9DC2BC180E668B007A3AD4 /* Icon-120.png */, 1A9DC2BD180E668B007A3AD4 /* Icon-144.png */, 1A9DC2BE180E668B007A3AD4 /* Icon-152.png */, 1A9DC2BF180E668B007A3AD4 /* Icon-57.png */, 1A9DC2C0180E668B007A3AD4 /* Icon-72.png */, 1A9DC2C1180E668B007A3AD4 /* Icon-76.png */, 1A9DC2C2180E668B007A3AD4 /* Info-obfuscated.plist */, 1A9DC2C3180E668B007A3AD4 /* Info.plist */, 1A9DC2C4180E668B007A3AD4 /* main.m */, 1A9DC2C5180E668B007A3AD4 /* Prefix.pch */, 1A9DC2C6180E668B007A3AD4 /* RootViewController.h */, 1A9DC2C7180E668B007A3AD4 /* RootViewController.mm */, ); name = proj.ios; path = ../samples/Javascript/TestJavascript/proj.ios; sourceTree = ""; }; 1A9DC2D7180E66BB007A3AD4 /* JS Tests */ = { isa = PBXGroup; children = ( 1A2F51AF1877DA5900B48BFE /* tests */, ); name = "JS Tests"; sourceTree = ""; }; 1A9DC9E3180E6736007A3AD4 /* JS Common */ = { isa = PBXGroup; children = ( 1A9DC9E4180E6742007A3AD4 /* script */, ); name = "JS Common"; sourceTree = ""; }; 1AAF4F98180E2C00000584C8 /* TestCpp */ = { isa = PBXGroup; children = ( 1AAF4FA5180E2C17000584C8 /* Classes */, 1AAF5250180E2C26000584C8 /* proj.ios */, 1AAF527D180E2C31000584C8 /* proj.mac */, 1AAF538C180E3628000584C8 /* Resources */, ); name = TestCpp; sourceTree = ""; }; 1AAF4FA5180E2C17000584C8 /* Classes */ = { isa = PBXGroup; children = ( 1AAF4FA6180E2C17000584C8 /* AccelerometerTest */, 1AAF4FA9180E2C17000584C8 /* ActionManagerTest */, 1AAF4FAC180E2C17000584C8 /* ActionsEaseTest */, 1AAF4FAF180E2C17000584C8 /* ActionsProgressTest */, 1AAF4FB2180E2C17000584C8 /* ActionsTest */, 1AAF4FB5180E2C17000584C8 /* AppDelegate.cpp */, 1AAF4FB6180E2C17000584C8 /* AppDelegate.h */, 1AAF4FB7180E2C17000584C8 /* BaseTest.cpp */, 1AAF4FB8180E2C17000584C8 /* BaseTest.h */, 1AAF4FB9180E2C17000584C8 /* Box2DTest */, 1AAF4FBC180E2C17000584C8 /* Box2DTestBed */, 1AAF4FF2180E2C17000584C8 /* BugsTest */, 1AAF500A180E2C18000584C8 /* ChipmunkTest */, 1AAF500D180E2C18000584C8 /* ClickAndMoveTest */, 1AAF5010180E2C18000584C8 /* ClippingNodeTest */, 1AAF5013180E2C18000584C8 /* CocosDenshionTest */, 1AAF5016180E2C18000584C8 /* ConfigurationTest */, 50691333184EB453009BBDD7 /* ConsoleTest */, 1AAF5019180E2C18000584C8 /* controller.cpp */, 1AAF501A180E2C18000584C8 /* controller.h */, 1AAF501B180E2C18000584C8 /* CurlTest */, 1AAF501E180E2C18000584C8 /* CurrentLanguageTest */, 1AAF5021180E2C18000584C8 /* DataVisitorTest */, 1AAF5024180E2C18000584C8 /* DrawPrimitivesTest */, 1AAF5027180E2C18000584C8 /* EffectsAdvancedTest */, 1AAF502A180E2C18000584C8 /* EffectsTest */, 1AAF502D180E2C18000584C8 /* ExtensionsTest */, 1AAF50D0180E2C19000584C8 /* FileUtilsTest */, 1AAF50D3180E2C19000584C8 /* FontTest */, 59A79D5A1821E95C00F19697 /* InputTest */, 1AAF50D6180E2C19000584C8 /* IntervalTest */, 1AAF50D9180E2C19000584C8 /* KeyboardTest */, 1AAF50DC180E2C19000584C8 /* KeypadTest */, 1AAF50DF180E2C19000584C8 /* LabelTest */, 1AAF50E4180E2C19000584C8 /* LayerTest */, 1AAF50E7180E2C19000584C8 /* MenuTest */, 1AAF50EA180E2C19000584C8 /* MotionStreakTest */, 1AAF50ED180E2C19000584C8 /* MutiTouchTest */, 1AAF50F0180E2C19000584C8 /* NewEventDispatcherTest */, 599121E3182C74AC00CE785B /* NewRendererTest */, 1AAF50F3180E2C19000584C8 /* NodeTest */, 1AAF50F6180E2C1A000584C8 /* ParallaxTest */, 1AAF50F9180E2C1A000584C8 /* ParticleTest */, 1AAF50FC180E2C1A000584C8 /* PerformanceTest */, 1AAF510B180E2C1A000584C8 /* PhysicsTest */, 4662EB5C188E426300B02E8F /* ReleasePoolTest */, 1AAF510E180E2C1A000584C8 /* RenderTextureTest */, 1AAF5111180E2C1A000584C8 /* RotateWorldTest */, 1AAF5114180E2C1A000584C8 /* SceneTest */, 1AAF5117180E2C1A000584C8 /* SchedulerTest */, 1AAF511A180E2C1A000584C8 /* ShaderTest */, 1AAF511F180E2C1A000584C8 /* SpineTest */, 1AAF5122180E2C1A000584C8 /* SpriteTest */, 1AAF5125180E2C1A000584C8 /* testBasic.cpp */, 1AAF5126180E2C1A000584C8 /* testBasic.h */, 1AAF5127180E2C1A000584C8 /* testResource.h */, 1AAF5128180E2C1A000584C8 /* tests.h */, 1AAF5129180E2C1A000584C8 /* TextInputTest */, 1AAF512C180E2C1A000584C8 /* Texture2dTest */, 1AAF512F180E2C1A000584C8 /* TextureCacheTest */, 1AAF5132180E2C1A000584C8 /* TexturePackerEncryptionTest */, 1AAF5135180E2C1A000584C8 /* TileMapTest */, 1AAF5138180E2C1A000584C8 /* TouchesTest */, 1AAF513F180E2C1A000584C8 /* TransitionsTest */, 1A804EB61876890200C117B5 /* UnitTest */, 1AAF5142180E2C1A000584C8 /* UserDefaultTest */, 1AAF5145180E2C1A000584C8 /* VisibleRect.cpp */, 1AAF5146180E2C1A000584C8 /* VisibleRect.h */, 1AAF5147180E2C1A000584C8 /* ZwoptexTest */, ); name = Classes; path = ../samples/Cpp/TestCpp/Classes; sourceTree = ""; }; 1AAF4FA6180E2C17000584C8 /* AccelerometerTest */ = { isa = PBXGroup; children = ( 1AAF4FA7180E2C17000584C8 /* AccelerometerTest.cpp */, 1AAF4FA8180E2C17000584C8 /* AccelerometerTest.h */, ); path = AccelerometerTest; sourceTree = ""; }; 1AAF4FA9180E2C17000584C8 /* ActionManagerTest */ = { isa = PBXGroup; children = ( 1AAF4FAA180E2C17000584C8 /* ActionManagerTest.cpp */, 1AAF4FAB180E2C17000584C8 /* ActionManagerTest.h */, ); path = ActionManagerTest; sourceTree = ""; }; 1AAF4FAC180E2C17000584C8 /* ActionsEaseTest */ = { isa = PBXGroup; children = ( 1AAF4FAD180E2C17000584C8 /* ActionsEaseTest.cpp */, 1AAF4FAE180E2C17000584C8 /* ActionsEaseTest.h */, ); path = ActionsEaseTest; sourceTree = ""; }; 1AAF4FAF180E2C17000584C8 /* ActionsProgressTest */ = { isa = PBXGroup; children = ( 1AAF4FB0180E2C17000584C8 /* ActionsProgressTest.cpp */, 1AAF4FB1180E2C17000584C8 /* ActionsProgressTest.h */, ); path = ActionsProgressTest; sourceTree = ""; }; 1AAF4FB2180E2C17000584C8 /* ActionsTest */ = { isa = PBXGroup; children = ( 1AAF4FB3180E2C17000584C8 /* ActionsTest.cpp */, 1AAF4FB4180E2C17000584C8 /* ActionsTest.h */, ); path = ActionsTest; sourceTree = ""; }; 1AAF4FB9180E2C17000584C8 /* Box2DTest */ = { isa = PBXGroup; children = ( 1AAF4FBA180E2C17000584C8 /* Box2dTest.cpp */, 1AAF4FBB180E2C17000584C8 /* Box2dTest.h */, ); path = Box2DTest; sourceTree = ""; }; 1AAF4FBC180E2C17000584C8 /* Box2DTestBed */ = { isa = PBXGroup; children = ( 1AAF4FBD180E2C17000584C8 /* Box2dView.cpp */, 1AAF4FBE180E2C17000584C8 /* Box2dView.h */, 1AAF4FBF180E2C17000584C8 /* GLES-Render.cpp */, 1AAF4FC0180E2C17000584C8 /* GLES-Render.h */, 1AAF4FC1180E2C17000584C8 /* Test.cpp */, 1AAF4FC2180E2C17000584C8 /* Test.h */, 1AAF4FC3180E2C17000584C8 /* TestEntries.cpp */, 1AAF4FC4180E2C17000584C8 /* Tests */, ); path = Box2DTestBed; sourceTree = ""; }; 1AAF4FC4180E2C17000584C8 /* Tests */ = { isa = PBXGroup; children = ( B3AF01A8184313DE00A98B85 /* ConvexHull.h */, B3AF01A9184313DE00A98B85 /* ConveyorBelt.h */, B3AF01AA184313DE00A98B85 /* Mobile.h */, B3AF01AB184313DE00A98B85 /* MobileBalanced.h */, B3AF01AC184313DE00A98B85 /* MotorJoint.h */, 1AAF4FC5180E2C17000584C8 /* AddPair.h */, 1AAF4FC6180E2C17000584C8 /* ApplyForce.h */, 1AAF4FC7180E2C17000584C8 /* BodyTypes.h */, 1AAF4FC8180E2C17000584C8 /* Breakable.h */, 1AAF4FC9180E2C17000584C8 /* Bridge.h */, 1AAF4FCA180E2C17000584C8 /* BulletTest.h */, 1AAF4FCB180E2C17000584C8 /* Cantilever.h */, 1AAF4FCC180E2C17000584C8 /* Car.h */, 1AAF4FCD180E2C17000584C8 /* Chain.h */, 1AAF4FCE180E2C17000584C8 /* CharacterCollision.h */, 1AAF4FCF180E2C17000584C8 /* CollisionFiltering.h */, 1AAF4FD0180E2C17000584C8 /* CollisionProcessing.h */, 1AAF4FD1180E2C17000584C8 /* CompoundShapes.h */, 1AAF4FD2180E2C17000584C8 /* Confined.h */, 1AAF4FD3180E2C17000584C8 /* ContinuousTest.h */, 1AAF4FD4180E2C17000584C8 /* DistanceTest.h */, 1AAF4FD5180E2C17000584C8 /* Dominos.h */, 1AAF4FD6180E2C17000584C8 /* DumpShell.h */, 1AAF4FD7180E2C17000584C8 /* DynamicTreeTest.h */, 1AAF4FD8180E2C17000584C8 /* EdgeShapes.h */, 1AAF4FD9180E2C17000584C8 /* EdgeTest.h */, 1AAF4FDA180E2C17000584C8 /* Gears.h */, 1AAF4FDB180E2C17000584C8 /* OneSidedPlatform.h */, 1AAF4FDC180E2C17000584C8 /* Pinball.h */, 1AAF4FDD180E2C17000584C8 /* PolyCollision.h */, 1AAF4FDE180E2C17000584C8 /* PolyShapes.h */, 1AAF4FDF180E2C17000584C8 /* Prismatic.h */, 1AAF4FE0180E2C17000584C8 /* Pulleys.h */, 1AAF4FE1180E2C17000584C8 /* Pyramid.h */, 1AAF4FE2180E2C17000584C8 /* RayCast.h */, 1AAF4FE3180E2C17000584C8 /* Revolute.h */, 1AAF4FE4180E2C17000584C8 /* Rope.h */, 1AAF4FE5180E2C17000584C8 /* RopeJoint.h */, 1AAF4FE6180E2C17000584C8 /* SensorTest.h */, 1AAF4FE7180E2C17000584C8 /* ShapeEditing.h */, 1AAF4FE8180E2C17000584C8 /* SliderCrank.h */, 1AAF4FE9180E2C17000584C8 /* SphereStack.h */, 1AAF4FEA180E2C17000584C8 /* TheoJansen.h */, 1AAF4FEB180E2C17000584C8 /* Tiles.h */, 1AAF4FEC180E2C17000584C8 /* TimeOfImpact.h */, 1AAF4FED180E2C17000584C8 /* Tumbler.h */, 1AAF4FEE180E2C17000584C8 /* VaryingFriction.h */, 1AAF4FEF180E2C17000584C8 /* VaryingRestitution.h */, 1AAF4FF0180E2C17000584C8 /* VerticalStack.h */, 1AAF4FF1180E2C17000584C8 /* Web.h */, ); path = Tests; sourceTree = ""; }; 1AAF4FF2180E2C17000584C8 /* BugsTest */ = { isa = PBXGroup; children = ( 1AAF4FF3180E2C17000584C8 /* Bug-1159.cpp */, 1AAF4FF4180E2C17000584C8 /* Bug-1159.h */, 1AAF4FF5180E2C17000584C8 /* Bug-1174.cpp */, 1AAF4FF6180E2C17000584C8 /* Bug-1174.h */, 1AAF4FF7180E2C17000584C8 /* Bug-350.cpp */, 1AAF4FF8180E2C17000584C8 /* Bug-350.h */, 1AAF4FF9180E2C17000584C8 /* Bug-422.cpp */, 1AAF4FFA180E2C17000584C8 /* Bug-422.h */, 1AAF4FFB180E2C17000584C8 /* Bug-458 */, 1AAF5000180E2C17000584C8 /* Bug-624.cpp */, 1AAF5001180E2C17000584C8 /* Bug-624.h */, 1AAF5002180E2C17000584C8 /* Bug-886.cpp */, 1AAF5003180E2C17000584C8 /* Bug-886.h */, 1AAF5004180E2C17000584C8 /* Bug-899.cpp */, 1AAF5005180E2C17000584C8 /* Bug-899.h */, 1AAF5006180E2C17000584C8 /* Bug-914.cpp */, 1AAF5007180E2C17000584C8 /* Bug-914.h */, 1AAF5008180E2C17000584C8 /* BugsTest.cpp */, 1AAF5009180E2C17000584C8 /* BugsTest.h */, ); path = BugsTest; sourceTree = ""; }; 1AAF4FFB180E2C17000584C8 /* Bug-458 */ = { isa = PBXGroup; children = ( 1AAF4FFC180E2C17000584C8 /* Bug-458.cpp */, 1AAF4FFD180E2C17000584C8 /* Bug-458.h */, 1AAF4FFE180E2C17000584C8 /* QuestionContainerSprite.cpp */, 1AAF4FFF180E2C17000584C8 /* QuestionContainerSprite.h */, ); path = "Bug-458"; sourceTree = ""; }; 1AAF500A180E2C18000584C8 /* ChipmunkTest */ = { isa = PBXGroup; children = ( 1AAF500B180E2C18000584C8 /* ChipmunkTest.cpp */, 1AAF500C180E2C18000584C8 /* ChipmunkTest.h */, ); path = ChipmunkTest; sourceTree = ""; }; 1AAF500D180E2C18000584C8 /* ClickAndMoveTest */ = { isa = PBXGroup; children = ( 1AAF500E180E2C18000584C8 /* ClickAndMoveTest.cpp */, 1AAF500F180E2C18000584C8 /* ClickAndMoveTest.h */, ); path = ClickAndMoveTest; sourceTree = ""; }; 1AAF5010180E2C18000584C8 /* ClippingNodeTest */ = { isa = PBXGroup; children = ( 1AAF5011180E2C18000584C8 /* ClippingNodeTest.cpp */, 1AAF5012180E2C18000584C8 /* ClippingNodeTest.h */, ); path = ClippingNodeTest; sourceTree = ""; }; 1AAF5013180E2C18000584C8 /* CocosDenshionTest */ = { isa = PBXGroup; children = ( 1AAF5014180E2C18000584C8 /* CocosDenshionTest.cpp */, 1AAF5015180E2C18000584C8 /* CocosDenshionTest.h */, ); path = CocosDenshionTest; sourceTree = ""; }; 1AAF5016180E2C18000584C8 /* ConfigurationTest */ = { isa = PBXGroup; children = ( 1AAF5017180E2C18000584C8 /* ConfigurationTest.cpp */, 1AAF5018180E2C18000584C8 /* ConfigurationTest.h */, ); path = ConfigurationTest; sourceTree = ""; }; 1AAF501B180E2C18000584C8 /* CurlTest */ = { isa = PBXGroup; children = ( 1AAF501C180E2C18000584C8 /* CurlTest.cpp */, 1AAF501D180E2C18000584C8 /* CurlTest.h */, ); path = CurlTest; sourceTree = ""; }; 1AAF501E180E2C18000584C8 /* CurrentLanguageTest */ = { isa = PBXGroup; children = ( 1AAF501F180E2C18000584C8 /* CurrentLanguageTest.cpp */, 1AAF5020180E2C18000584C8 /* CurrentLanguageTest.h */, ); path = CurrentLanguageTest; sourceTree = ""; }; 1AAF5021180E2C18000584C8 /* DataVisitorTest */ = { isa = PBXGroup; children = ( 1AAF5022180E2C18000584C8 /* DataVisitorTest.cpp */, 1AAF5023180E2C18000584C8 /* DataVisitorTest.h */, ); path = DataVisitorTest; sourceTree = ""; }; 1AAF5024180E2C18000584C8 /* DrawPrimitivesTest */ = { isa = PBXGroup; children = ( 1AAF5025180E2C18000584C8 /* DrawPrimitivesTest.cpp */, 1AAF5026180E2C18000584C8 /* DrawPrimitivesTest.h */, ); path = DrawPrimitivesTest; sourceTree = ""; }; 1AAF5027180E2C18000584C8 /* EffectsAdvancedTest */ = { isa = PBXGroup; children = ( 1AAF5028180E2C18000584C8 /* EffectsAdvancedTest.cpp */, 1AAF5029180E2C18000584C8 /* EffectsAdvancedTest.h */, ); path = EffectsAdvancedTest; sourceTree = ""; }; 1AAF502A180E2C18000584C8 /* EffectsTest */ = { isa = PBXGroup; children = ( 1AAF502B180E2C18000584C8 /* EffectsTest.cpp */, 1AAF502C180E2C18000584C8 /* EffectsTest.h */, ); path = EffectsTest; sourceTree = ""; }; 1AAF502D180E2C18000584C8 /* ExtensionsTest */ = { isa = PBXGroup; children = ( 1AAF502E180E2C18000584C8 /* CocosBuilderTest */, 1AAF5055180E2C18000584C8 /* CocoStudioArmatureTest */, 1AAF5058180E2C18000584C8 /* CocoStudioComponentsTest */, 1AAF5065180E2C18000584C8 /* CocoStudioGUITest */, 1AAF509F180E2C19000584C8 /* CocoStudioSceneTest */, 1AAF50A2180E2C19000584C8 /* ControlExtensionTest */, 1AAF50B9180E2C19000584C8 /* EditBoxTest */, 1AAF50BC180E2C19000584C8 /* ExtensionsTest.cpp */, 1AAF50BD180E2C19000584C8 /* ExtensionsTest.h */, 1AAF50BE180E2C19000584C8 /* NetworkTest */, 1AAF50C5180E2C19000584C8 /* NotificationCenterTest */, 1AAF50C8180E2C19000584C8 /* Scale9SpriteTest */, 1AAF50CB180E2C19000584C8 /* TableViewTest */, ); path = ExtensionsTest; sourceTree = ""; }; 1AAF502E180E2C18000584C8 /* CocosBuilderTest */ = { isa = PBXGroup; children = ( 1AAF502F180E2C18000584C8 /* AnimationsTest */, 1AAF5033180E2C18000584C8 /* ButtonTest */, 1AAF5037180E2C18000584C8 /* CocosBuilderTest.cpp */, 1AAF5038180E2C18000584C8 /* CocosBuilderTest.h */, 1AAF5039180E2C18000584C8 /* HelloCocosBuilder */, 1AAF503D180E2C18000584C8 /* LabelTest */, 1AAF5040180E2C18000584C8 /* MenuTest */, 1AAF5044180E2C18000584C8 /* ParticleSystemTest */, 1AAF5047180E2C18000584C8 /* ScrollViewTest */, 1AAF504A180E2C18000584C8 /* SpriteTest */, 1AAF504D180E2C18000584C8 /* TestHeader */, 1AAF5051180E2C18000584C8 /* TimelineCallbackTest */, ); path = CocosBuilderTest; sourceTree = ""; }; 1AAF502F180E2C18000584C8 /* AnimationsTest */ = { isa = PBXGroup; children = ( 1AAF5030180E2C18000584C8 /* AnimationsLayerLoader.h */, 1AAF5031180E2C18000584C8 /* AnimationsTestLayer.cpp */, 1AAF5032180E2C18000584C8 /* AnimationsTestLayer.h */, ); path = AnimationsTest; sourceTree = ""; }; 1AAF5033180E2C18000584C8 /* ButtonTest */ = { isa = PBXGroup; children = ( 1AAF5034180E2C18000584C8 /* ButtonTestLayer.cpp */, 1AAF5035180E2C18000584C8 /* ButtonTestLayer.h */, 1AAF5036180E2C18000584C8 /* ButtonTestLayerLoader.h */, ); path = ButtonTest; sourceTree = ""; }; 1AAF5039180E2C18000584C8 /* HelloCocosBuilder */ = { isa = PBXGroup; children = ( 1AAF503A180E2C18000584C8 /* HelloCocosBuilderLayer.cpp */, 1AAF503B180E2C18000584C8 /* HelloCocosBuilderLayer.h */, 1AAF503C180E2C18000584C8 /* HelloCocosBuilderLayerLoader.h */, ); path = HelloCocosBuilder; sourceTree = ""; }; 1AAF503D180E2C18000584C8 /* LabelTest */ = { isa = PBXGroup; children = ( 1AAF503E180E2C18000584C8 /* LabelTestLayer.h */, 1AAF503F180E2C18000584C8 /* LabelTestLayerLoader.h */, ); path = LabelTest; sourceTree = ""; }; 1AAF5040180E2C18000584C8 /* MenuTest */ = { isa = PBXGroup; children = ( 1AAF5041180E2C18000584C8 /* MenuTestLayer.cpp */, 1AAF5042180E2C18000584C8 /* MenuTestLayer.h */, 1AAF5043180E2C18000584C8 /* MenuTestLayerLoader.h */, ); path = MenuTest; sourceTree = ""; }; 1AAF5044180E2C18000584C8 /* ParticleSystemTest */ = { isa = PBXGroup; children = ( 1AAF5045180E2C18000584C8 /* ParticleSystemTestLayer.h */, 1AAF5046180E2C18000584C8 /* ParticleSystemTestLayerLoader.h */, ); path = ParticleSystemTest; sourceTree = ""; }; 1AAF5047180E2C18000584C8 /* ScrollViewTest */ = { isa = PBXGroup; children = ( 1AAF5048180E2C18000584C8 /* ScrollViewTestLayer.h */, 1AAF5049180E2C18000584C8 /* ScrollViewTestLayerLoader.h */, ); path = ScrollViewTest; sourceTree = ""; }; 1AAF504A180E2C18000584C8 /* SpriteTest */ = { isa = PBXGroup; children = ( 1AAF504B180E2C18000584C8 /* SpriteTestLayer.h */, 1AAF504C180E2C18000584C8 /* SpriteTestLayerLoader.h */, ); path = SpriteTest; sourceTree = ""; }; 1AAF504D180E2C18000584C8 /* TestHeader */ = { isa = PBXGroup; children = ( 1AAF504E180E2C18000584C8 /* TestHeaderLayer.cpp */, 1AAF504F180E2C18000584C8 /* TestHeaderLayer.h */, 1AAF5050180E2C18000584C8 /* TestHeaderLayerLoader.h */, ); path = TestHeader; sourceTree = ""; }; 1AAF5051180E2C18000584C8 /* TimelineCallbackTest */ = { isa = PBXGroup; children = ( 1AAF5052180E2C18000584C8 /* TimelineCallbackLayerLoader.h */, 1AAF5053180E2C18000584C8 /* TimelineCallbackTestLayer.cpp */, 1AAF5054180E2C18000584C8 /* TimelineCallbackTestLayer.h */, ); path = TimelineCallbackTest; sourceTree = ""; }; 1AAF5055180E2C18000584C8 /* CocoStudioArmatureTest */ = { isa = PBXGroup; children = ( 1AAF5056180E2C18000584C8 /* ArmatureScene.cpp */, 1AAF5057180E2C18000584C8 /* ArmatureScene.h */, ); path = CocoStudioArmatureTest; sourceTree = ""; }; 1AAF5058180E2C18000584C8 /* CocoStudioComponentsTest */ = { isa = PBXGroup; children = ( 1AAF5059180E2C18000584C8 /* ComponentsTestScene.cpp */, 1AAF505A180E2C18000584C8 /* ComponentsTestScene.h */, 1AAF505B180E2C18000584C8 /* EnemyController.cpp */, 1AAF505C180E2C18000584C8 /* EnemyController.h */, 1AAF505D180E2C18000584C8 /* GameOverScene.cpp */, 1AAF505E180E2C18000584C8 /* GameOverScene.h */, 1AAF505F180E2C18000584C8 /* PlayerController.cpp */, 1AAF5060180E2C18000584C8 /* PlayerController.h */, 1AAF5061180E2C18000584C8 /* ProjectileController.cpp */, 1AAF5062180E2C18000584C8 /* ProjectileController.h */, 1AAF5063180E2C18000584C8 /* SceneController.cpp */, 1AAF5064180E2C18000584C8 /* SceneController.h */, ); path = CocoStudioComponentsTest; sourceTree = ""; }; 1AAF5065180E2C18000584C8 /* CocoStudioGUITest */ = { isa = PBXGroup; children = ( 50D360CA186819DB00828878 /* CocosGUIScene.cpp */, 50D360CB186819DB00828878 /* CocosGUIScene.h */, 50D360CC186819DB00828878 /* UIButtonTest */, 50D360CF186819DB00828878 /* UICheckBoxTest */, 50D360D2186819DB00828878 /* UIImageViewTest */, 50D360D5186819DB00828878 /* UILabelAtlasTest */, 50D360D8186819DB00828878 /* UILabelBMFontTest */, 50D360DB186819DB00828878 /* UILabelTest */, 50D360DE186819DB00828878 /* UILayoutTest */, 50D360E1186819DB00828878 /* UIListViewTest */, 50D360E4186819DB00828878 /* UILoadingBarTest */, 50D360E7186819DB00828878 /* UIPageViewTest */, 50D360EA186819DB00828878 /* UIScene.cpp */, 50D360EB186819DB00828878 /* UIScene.h */, 50D360EC186819DB00828878 /* UISceneManager.cpp */, 50D360ED186819DB00828878 /* UISceneManager.h */, 50D360EE186819DB00828878 /* UIScrollViewTest */, 50D360F1186819DB00828878 /* UISliderTest */, 50D360F4186819DB00828878 /* UITextFieldTest */, 50D360F7186819DB00828878 /* UIWidgetAddNodeTest */, ); path = CocoStudioGUITest; sourceTree = ""; }; 1AAF509F180E2C19000584C8 /* CocoStudioSceneTest */ = { isa = PBXGroup; children = ( 37A6145A186B21F6007A4638 /* TriggerCode */, 1AAF50A0180E2C19000584C8 /* SceneEditorTest.cpp */, 1AAF50A1180E2C19000584C8 /* SceneEditorTest.h */, ); path = CocoStudioSceneTest; sourceTree = ""; }; 1AAF50A2180E2C19000584C8 /* ControlExtensionTest */ = { isa = PBXGroup; children = ( 1AAF50A3180E2C19000584C8 /* CCControlButtonTest */, 1AAF50A6180E2C19000584C8 /* CCControlColourPicker */, 1AAF50A9180E2C19000584C8 /* CCControlPotentiometerTest */, 1AAF50AC180E2C19000584C8 /* CCControlScene.cpp */, 1AAF50AD180E2C19000584C8 /* CCControlScene.h */, 1AAF50AE180E2C19000584C8 /* CCControlSceneManager.cpp */, 1AAF50AF180E2C19000584C8 /* CCControlSceneManager.h */, 1AAF50B0180E2C19000584C8 /* CCControlSliderTest */, 1AAF50B3180E2C19000584C8 /* CCControlStepperTest */, 1AAF50B6180E2C19000584C8 /* CCControlSwitchTest */, ); path = ControlExtensionTest; sourceTree = ""; }; 1AAF50A3180E2C19000584C8 /* CCControlButtonTest */ = { isa = PBXGroup; children = ( 1AAF50A4180E2C19000584C8 /* CCControlButtonTest.cpp */, 1AAF50A5180E2C19000584C8 /* CCControlButtonTest.h */, ); path = CCControlButtonTest; sourceTree = ""; }; 1AAF50A6180E2C19000584C8 /* CCControlColourPicker */ = { isa = PBXGroup; children = ( 1AAF50A7180E2C19000584C8 /* CCControlColourPickerTest.cpp */, 1AAF50A8180E2C19000584C8 /* CCControlColourPickerTest.h */, ); path = CCControlColourPicker; sourceTree = ""; }; 1AAF50A9180E2C19000584C8 /* CCControlPotentiometerTest */ = { isa = PBXGroup; children = ( 1AAF50AA180E2C19000584C8 /* CCControlPotentiometerTest.cpp */, 1AAF50AB180E2C19000584C8 /* CCControlPotentiometerTest.h */, ); path = CCControlPotentiometerTest; sourceTree = ""; }; 1AAF50B0180E2C19000584C8 /* CCControlSliderTest */ = { isa = PBXGroup; children = ( 1AAF50B1180E2C19000584C8 /* CCControlSliderTest.cpp */, 1AAF50B2180E2C19000584C8 /* CCControlSliderTest.h */, ); path = CCControlSliderTest; sourceTree = ""; }; 1AAF50B3180E2C19000584C8 /* CCControlStepperTest */ = { isa = PBXGroup; children = ( 1AAF50B4180E2C19000584C8 /* CCControlStepperTest.cpp */, 1AAF50B5180E2C19000584C8 /* CCControlStepperTest.h */, ); path = CCControlStepperTest; sourceTree = ""; }; 1AAF50B6180E2C19000584C8 /* CCControlSwitchTest */ = { isa = PBXGroup; children = ( 1AAF50B7180E2C19000584C8 /* CCControlSwitchTest.cpp */, 1AAF50B8180E2C19000584C8 /* CCControlSwitchTest.h */, ); path = CCControlSwitchTest; sourceTree = ""; }; 1AAF50B9180E2C19000584C8 /* EditBoxTest */ = { isa = PBXGroup; children = ( 1AAF50BA180E2C19000584C8 /* EditBoxTest.cpp */, 1AAF50BB180E2C19000584C8 /* EditBoxTest.h */, ); path = EditBoxTest; sourceTree = ""; }; 1AAF50BE180E2C19000584C8 /* NetworkTest */ = { isa = PBXGroup; children = ( 1AAF50BF180E2C19000584C8 /* HttpClientTest.cpp */, 1AAF50C0180E2C19000584C8 /* HttpClientTest.h */, 1AAF50C1180E2C19000584C8 /* SocketIOTest.cpp */, 1AAF50C2180E2C19000584C8 /* SocketIOTest.h */, 1AAF50C3180E2C19000584C8 /* WebSocketTest.cpp */, 1AAF50C4180E2C19000584C8 /* WebSocketTest.h */, ); path = NetworkTest; sourceTree = ""; }; 1AAF50C5180E2C19000584C8 /* NotificationCenterTest */ = { isa = PBXGroup; children = ( 1AAF50C6180E2C19000584C8 /* NotificationCenterTest.cpp */, 1AAF50C7180E2C19000584C8 /* NotificationCenterTest.h */, ); path = NotificationCenterTest; sourceTree = ""; }; 1AAF50C8180E2C19000584C8 /* Scale9SpriteTest */ = { isa = PBXGroup; children = ( 1AAF50C9180E2C19000584C8 /* Scale9SpriteTest.cpp */, 1AAF50CA180E2C19000584C8 /* Scale9SpriteTest.h */, ); path = Scale9SpriteTest; sourceTree = ""; }; 1AAF50CB180E2C19000584C8 /* TableViewTest */ = { isa = PBXGroup; children = ( 1AAF50CC180E2C19000584C8 /* CustomTableViewCell.cpp */, 1AAF50CD180E2C19000584C8 /* CustomTableViewCell.h */, 1AAF50CE180E2C19000584C8 /* TableViewTestScene.cpp */, 1AAF50CF180E2C19000584C8 /* TableViewTestScene.h */, ); path = TableViewTest; sourceTree = ""; }; 1AAF50D0180E2C19000584C8 /* FileUtilsTest */ = { isa = PBXGroup; children = ( 1AAF50D1180E2C19000584C8 /* FileUtilsTest.cpp */, 1AAF50D2180E2C19000584C8 /* FileUtilsTest.h */, ); path = FileUtilsTest; sourceTree = ""; }; 1AAF50D3180E2C19000584C8 /* FontTest */ = { isa = PBXGroup; children = ( 1AAF50D4180E2C19000584C8 /* FontTest.cpp */, 1AAF50D5180E2C19000584C8 /* FontTest.h */, ); path = FontTest; sourceTree = ""; }; 1AAF50D6180E2C19000584C8 /* IntervalTest */ = { isa = PBXGroup; children = ( 1AAF50D7180E2C19000584C8 /* IntervalTest.cpp */, 1AAF50D8180E2C19000584C8 /* IntervalTest.h */, ); path = IntervalTest; sourceTree = ""; }; 1AAF50D9180E2C19000584C8 /* KeyboardTest */ = { isa = PBXGroup; children = ( 1AAF50DA180E2C19000584C8 /* KeyboardTest.cpp */, 1AAF50DB180E2C19000584C8 /* KeyboardTest.h */, ); path = KeyboardTest; sourceTree = ""; }; 1AAF50DC180E2C19000584C8 /* KeypadTest */ = { isa = PBXGroup; children = ( 1AAF50DD180E2C19000584C8 /* KeypadTest.cpp */, 1AAF50DE180E2C19000584C8 /* KeypadTest.h */, ); path = KeypadTest; sourceTree = ""; }; 1AAF50DF180E2C19000584C8 /* LabelTest */ = { isa = PBXGroup; children = ( 1AAF50E0180E2C19000584C8 /* LabelTest.cpp */, 1AAF50E1180E2C19000584C8 /* LabelTest.h */, 1AAF50E2180E2C19000584C8 /* LabelTestNew.cpp */, 1AAF50E3180E2C19000584C8 /* LabelTestNew.h */, ); path = LabelTest; sourceTree = ""; }; 1AAF50E4180E2C19000584C8 /* LayerTest */ = { isa = PBXGroup; children = ( 1AAF50E5180E2C19000584C8 /* LayerTest.cpp */, 1AAF50E6180E2C19000584C8 /* LayerTest.h */, ); path = LayerTest; sourceTree = ""; }; 1AAF50E7180E2C19000584C8 /* MenuTest */ = { isa = PBXGroup; children = ( 1AAF50E8180E2C19000584C8 /* MenuTest.cpp */, 1AAF50E9180E2C19000584C8 /* MenuTest.h */, ); path = MenuTest; sourceTree = ""; }; 1AAF50EA180E2C19000584C8 /* MotionStreakTest */ = { isa = PBXGroup; children = ( 1AAF50EB180E2C19000584C8 /* MotionStreakTest.cpp */, 1AAF50EC180E2C19000584C8 /* MotionStreakTest.h */, ); path = MotionStreakTest; sourceTree = ""; }; 1AAF50ED180E2C19000584C8 /* MutiTouchTest */ = { isa = PBXGroup; children = ( 1AAF50EE180E2C19000584C8 /* MutiTouchTest.cpp */, 1AAF50EF180E2C19000584C8 /* MutiTouchTest.h */, ); path = MutiTouchTest; sourceTree = ""; }; 1AAF50F0180E2C19000584C8 /* NewEventDispatcherTest */ = { isa = PBXGroup; children = ( 1AAF50F1180E2C19000584C8 /* NewEventDispatcherTest.cpp */, 1AAF50F2180E2C19000584C8 /* NewEventDispatcherTest.h */, ); path = NewEventDispatcherTest; sourceTree = ""; }; 1AAF50F3180E2C19000584C8 /* NodeTest */ = { isa = PBXGroup; children = ( 1AAF50F4180E2C19000584C8 /* NodeTest.cpp */, 1AAF50F5180E2C1A000584C8 /* NodeTest.h */, ); path = NodeTest; sourceTree = ""; }; 1AAF50F6180E2C1A000584C8 /* ParallaxTest */ = { isa = PBXGroup; children = ( 1AAF50F7180E2C1A000584C8 /* ParallaxTest.cpp */, 1AAF50F8180E2C1A000584C8 /* ParallaxTest.h */, ); path = ParallaxTest; sourceTree = ""; }; 1AAF50F9180E2C1A000584C8 /* ParticleTest */ = { isa = PBXGroup; children = ( 1AAF50FA180E2C1A000584C8 /* ParticleTest.cpp */, 1AAF50FB180E2C1A000584C8 /* ParticleTest.h */, ); path = ParticleTest; sourceTree = ""; }; 1AAF50FC180E2C1A000584C8 /* PerformanceTest */ = { isa = PBXGroup; children = ( 1AAF50FD180E2C1A000584C8 /* PerformanceAllocTest.cpp */, 1AAF50FE180E2C1A000584C8 /* PerformanceAllocTest.h */, 1AFB0DE11885357A003B2FF3 /* PerformanceContainerTest.cpp */, 1AFB0DE21885357A003B2FF3 /* PerformanceContainerTest.h */, 1ADD146B188D25270034D5EF /* PerformanceEventDispatcherTest.cpp */, 1ADD146C188D25270034D5EF /* PerformanceEventDispatcherTest.h */, 1A087AEC1860418300196EF5 /* PerformanceLabelTest.cpp */, 1A087AED1860418300196EF5 /* PerformanceLabelTest.h */, 1AAF50FF180E2C1A000584C8 /* PerformanceNodeChildrenTest.cpp */, 1AAF5100180E2C1A000584C8 /* PerformanceNodeChildrenTest.h */, 1AAF5101180E2C1A000584C8 /* PerformanceParticleTest.cpp */, 1AAF5102180E2C1A000584C8 /* PerformanceParticleTest.h */, ED3674B8187FA7020038ECFC /* PerformanceRendererTest.cpp */, ED3674B3187FA6BF0038ECFC /* PerformanceRendererTest.h */, 1AAF5103180E2C1A000584C8 /* PerformanceSpriteTest.cpp */, 1AAF5104180E2C1A000584C8 /* PerformanceSpriteTest.h */, 1AAF5105180E2C1A000584C8 /* PerformanceTest.cpp */, 1AAF5106180E2C1A000584C8 /* PerformanceTest.h */, 1AAF5107180E2C1A000584C8 /* PerformanceTextureTest.cpp */, 1AAF5108180E2C1A000584C8 /* PerformanceTextureTest.h */, 1AAF5109180E2C1A000584C8 /* PerformanceTouchesTest.cpp */, 1AAF510A180E2C1A000584C8 /* PerformanceTouchesTest.h */, ); path = PerformanceTest; sourceTree = ""; }; 1AAF510B180E2C1A000584C8 /* PhysicsTest */ = { isa = PBXGroup; children = ( 1AAF510C180E2C1A000584C8 /* PhysicsTest.cpp */, 1AAF510D180E2C1A000584C8 /* PhysicsTest.h */, ); path = PhysicsTest; sourceTree = ""; }; 1AAF510E180E2C1A000584C8 /* RenderTextureTest */ = { isa = PBXGroup; children = ( 1AAF510F180E2C1A000584C8 /* RenderTextureTest.cpp */, 1AAF5110180E2C1A000584C8 /* RenderTextureTest.h */, ); path = RenderTextureTest; sourceTree = ""; }; 1AAF5111180E2C1A000584C8 /* RotateWorldTest */ = { isa = PBXGroup; children = ( 1AAF5112180E2C1A000584C8 /* RotateWorldTest.cpp */, 1AAF5113180E2C1A000584C8 /* RotateWorldTest.h */, ); path = RotateWorldTest; sourceTree = ""; }; 1AAF5114180E2C1A000584C8 /* SceneTest */ = { isa = PBXGroup; children = ( 1AAF5115180E2C1A000584C8 /* SceneTest.cpp */, 1AAF5116180E2C1A000584C8 /* SceneTest.h */, ); path = SceneTest; sourceTree = ""; }; 1AAF5117180E2C1A000584C8 /* SchedulerTest */ = { isa = PBXGroup; children = ( 1AAF5118180E2C1A000584C8 /* SchedulerTest.cpp */, 1AAF5119180E2C1A000584C8 /* SchedulerTest.h */, ); path = SchedulerTest; sourceTree = ""; }; 1AAF511A180E2C1A000584C8 /* ShaderTest */ = { isa = PBXGroup; children = ( 1AAF511B180E2C1A000584C8 /* ShaderTest.cpp */, 1AAF511C180E2C1A000584C8 /* ShaderTest.h */, 1AAF511D180E2C1A000584C8 /* ShaderTest2.cpp */, 1AAF511E180E2C1A000584C8 /* ShaderTest2.h */, ); path = ShaderTest; sourceTree = ""; }; 1AAF511F180E2C1A000584C8 /* SpineTest */ = { isa = PBXGroup; children = ( 1AAF5120180E2C1A000584C8 /* SpineTest.cpp */, 1AAF5121180E2C1A000584C8 /* SpineTest.h */, ); path = SpineTest; sourceTree = ""; }; 1AAF5122180E2C1A000584C8 /* SpriteTest */ = { isa = PBXGroup; children = ( 1AAF5123180E2C1A000584C8 /* SpriteTest.cpp */, 1AAF5124180E2C1A000584C8 /* SpriteTest.h */, ); path = SpriteTest; sourceTree = ""; }; 1AAF5129180E2C1A000584C8 /* TextInputTest */ = { isa = PBXGroup; children = ( 1AAF512A180E2C1A000584C8 /* TextInputTest.cpp */, 1AAF512B180E2C1A000584C8 /* TextInputTest.h */, ); path = TextInputTest; sourceTree = ""; }; 1AAF512C180E2C1A000584C8 /* Texture2dTest */ = { isa = PBXGroup; children = ( 1AAF512D180E2C1A000584C8 /* Texture2dTest.cpp */, 1AAF512E180E2C1A000584C8 /* Texture2dTest.h */, ); path = Texture2dTest; sourceTree = ""; }; 1AAF512F180E2C1A000584C8 /* TextureCacheTest */ = { isa = PBXGroup; children = ( 1AAF5130180E2C1A000584C8 /* TextureCacheTest.cpp */, 1AAF5131180E2C1A000584C8 /* TextureCacheTest.h */, ); path = TextureCacheTest; sourceTree = ""; }; 1AAF5132180E2C1A000584C8 /* TexturePackerEncryptionTest */ = { isa = PBXGroup; children = ( 1AAF5133180E2C1A000584C8 /* TextureAtlasEncryptionTest.cpp */, 1AAF5134180E2C1A000584C8 /* TextureAtlasEncryptionTest.h */, ); path = TexturePackerEncryptionTest; sourceTree = ""; }; 1AAF5135180E2C1A000584C8 /* TileMapTest */ = { isa = PBXGroup; children = ( 1AAF5136180E2C1A000584C8 /* TileMapTest.cpp */, 1AAF5137180E2C1A000584C8 /* TileMapTest.h */, ); path = TileMapTest; sourceTree = ""; }; 1AAF5138180E2C1A000584C8 /* TouchesTest */ = { isa = PBXGroup; children = ( 1AAF5139180E2C1A000584C8 /* Ball.cpp */, 1AAF513A180E2C1A000584C8 /* Ball.h */, 1AAF513B180E2C1A000584C8 /* Paddle.cpp */, 1AAF513C180E2C1A000584C8 /* Paddle.h */, 1AAF513D180E2C1A000584C8 /* TouchesTest.cpp */, 1AAF513E180E2C1A000584C8 /* TouchesTest.h */, ); path = TouchesTest; sourceTree = ""; }; 1AAF513F180E2C1A000584C8 /* TransitionsTest */ = { isa = PBXGroup; children = ( 1AAF5140180E2C1A000584C8 /* TransitionsTest.cpp */, 1AAF5141180E2C1A000584C8 /* TransitionsTest.h */, ); path = TransitionsTest; sourceTree = ""; }; 1AAF5142180E2C1A000584C8 /* UserDefaultTest */ = { isa = PBXGroup; children = ( 1AAF5143180E2C1A000584C8 /* UserDefaultTest.cpp */, 1AAF5144180E2C1A000584C8 /* UserDefaultTest.h */, ); path = UserDefaultTest; sourceTree = ""; }; 1AAF5147180E2C1A000584C8 /* ZwoptexTest */ = { isa = PBXGroup; children = ( 1AAF5148180E2C1A000584C8 /* ZwoptexTest.cpp */, 1AAF5149180E2C1A000584C8 /* ZwoptexTest.h */, ); path = ZwoptexTest; sourceTree = ""; }; 1AAF5250180E2C26000584C8 /* proj.ios */ = { isa = PBXGroup; children = ( 1AAF5251180E2C26000584C8 /* Classes */, 1AAF5256180E2C26000584C8 /* Default-568h@2x.png */, 1AAF5257180E2C26000584C8 /* Default.png */, 1AAF5258180E2C26000584C8 /* Default@2x.png */, 1AAF5259180E2C26000584C8 /* Icon-100.png */, 1AAF525A180E2C26000584C8 /* Icon-114.png */, 1AAF525B180E2C26000584C8 /* Icon-120.png */, 1AAF525C180E2C26000584C8 /* Icon-144.png */, 1AAF525D180E2C26000584C8 /* Icon-152.png */, 1AAF525E180E2C26000584C8 /* Icon-29.png */, 1AAF525F180E2C26000584C8 /* Icon-40.png */, 1AAF5260180E2C26000584C8 /* Icon-50.png */, 1AAF5261180E2C26000584C8 /* Icon-57.png */, 1AAF5262180E2C26000584C8 /* Icon-58.png */, 1AAF5263180E2C26000584C8 /* Icon-72.png */, 1AAF5264180E2C26000584C8 /* Icon-76.png */, 1AAF5265180E2C26000584C8 /* Icon-80.png */, 1AAF5266180E2C26000584C8 /* iphone_Prefix.pch */, 1AAF5267180E2C26000584C8 /* main.m */, 1AAF5268180E2C26000584C8 /* Test-Info.plist */, ); name = proj.ios; path = ../samples/Cpp/TestCpp/proj.ios; sourceTree = ""; }; 1AAF5251180E2C26000584C8 /* Classes */ = { isa = PBXGroup; children = ( 1AAF5252180E2C26000584C8 /* RootViewController.h */, 1AAF5253180E2C26000584C8 /* RootViewController.mm */, 1AAF5254180E2C26000584C8 /* testsAppDelegate.h */, 1AAF5255180E2C26000584C8 /* testsAppDelegate.mm */, ); path = Classes; sourceTree = ""; }; 1AAF527D180E2C31000584C8 /* proj.mac */ = { isa = PBXGroup; children = ( 1AAF527E180E2C31000584C8 /* InfoPlist.strings */, 1AAF5280180E2C31000584C8 /* MainMenu.xib */, 1AAF5282180E2C31000584C8 /* Icon.icns */, 1AAF5283180E2C31000584C8 /* main.cpp */, 1AAF5284180E2C31000584C8 /* Test_Info.plist */, 1AAF5285180E2C31000584C8 /* Test_Prefix.pch */, ); name = proj.mac; path = ../samples/Cpp/TestCpp/proj.mac; sourceTree = ""; }; 1AAF538C180E3628000584C8 /* Resources */ = { isa = PBXGroup; children = ( 37C819601875DF2A00930C57 /* animations */, 37C819611875DF2A00930C57 /* armature */, 37C819621875DF2A00930C57 /* background-music-aac.wav */, 37C819631875DF2A00930C57 /* background.mp3 */, 37C819641875DF2A00930C57 /* background.ogg */, 37C819651875DF2A00930C57 /* ccb */, 37C819661875DF2A00930C57 /* CocosBuilderExample.ccbproj */, 37C819671875DF2A00930C57 /* CocosBuilderExample.ccbresourcelog */, 37C819681875DF2A00930C57 /* cocosgui */, 37C819691875DF2A00930C57 /* components */, 37C8196A1875DF2A00930C57 /* configs */, 37C8196B1875DF2A00930C57 /* effect1.raw */, 37C8196C1875DF2A00930C57 /* effect1.wav */, 37C8196D1875DF2A00930C57 /* effect2.ogg */, 37C8196E1875DF2A00930C57 /* extensions */, 37C8196F1875DF2A00930C57 /* fileLookup.plist */, 37C819701875DF2A00930C57 /* fonts */, 37C819711875DF2A00930C57 /* fps_images.png */, 37C819721875DF2A00930C57 /* hd */, 37C819731875DF2A00930C57 /* Hello.png */, 37C819741875DF2B00930C57 /* Images */, 37C819751875DF2B00930C57 /* ipad */, 37C819761875DF2B00930C57 /* ipadhd */, 37C819771875DF2B00930C57 /* Misc */, 37C819781875DF2B00930C57 /* music.mid */, 37C819791875DF2B00930C57 /* Particles */, 37C8197A1875DF2B00930C57 /* pew-pew-lei.wav */, 37C8197B1875DF2B00930C57 /* scenetest */, 37C8197C1875DF2B00930C57 /* Shaders */, 37C8197D1875DF2B00930C57 /* spine */, 37C8197E1875DF2B00930C57 /* TileMaps */, 37C8197F1875DF2B00930C57 /* zwoptex */, ); name = Resources; sourceTree = ""; }; 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */, 1A3B1E9B180E809F00497A22 /* CocosDragonJS */, 1A3B1EF0180E822B00497A22 /* CrystalCraze */, 29B97323FDCFA39411CA2CEA /* Frameworks */, 46A174831807D934005B8026 /* HelloCpp */, 1A3B1F48180E85E100497A22 /* HelloLua */, 1A9DC9E3180E6736007A3AD4 /* JS Common */, 1A8C5595180E8B6500EF57C3 /* Lua Common */, 1A3B1DAF180E7C3400497A22 /* MoonWarriors */, 19C28FACFE9D520D11CA2CBB /* Products */, 460E45011807E711000CDD6D /* SimpleGame */, 1AAF4F98180E2C00000584C8 /* TestCpp */, 1A9DC29F180E65A1007A3AD4 /* TestJavascript */, 1A8C566B180E8E7F00EF57C3 /* TestLua */, 1A3B1E1A180E7ED800497A22 /* WatermelonWithMe */, ); name = CustomTemplate; sourceTree = ""; }; 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( D60AE43317F7FFE100757E4B /* CoreMotion.framework */, A035A71117822E9E00987F6C /* libsqlite3.dylib */, 1A9F808C177E98A600D9A1CB /* libcurl.dylib */, 15C6482E165F399D007D4F18 /* libz.dylib */, EDCC747E17C455FD007B692C /* IOKit.framework */, A07A52C11783B01F0073F6A7 /* AVFoundation.framework */, A07A52BB1783AEB80073F6A7 /* CoreGraphics.framework */, A07A52B91783AE900073F6A7 /* OpenGLES.framework */, A07A52B71783AE6D0073F6A7 /* UIKit.framework */, 15C6482C165F3988007D4F18 /* AudioToolbox.framework */, 15C6482A165F3979007D4F18 /* ApplicationServices.framework */, 15C64828165F396B007D4F18 /* OpenAL.framework */, 15C64826165F394E007D4F18 /* QuartzCore.framework */, 15C64824165F3934007D4F18 /* OpenGL.framework */, 15C64822165F391E007D4F18 /* Cocoa.framework */, 15C64832165F3AFD007D4F18 /* Foundation.framework */, ); name = Frameworks; sourceTree = ""; }; 37A6145A186B21F6007A4638 /* TriggerCode */ = { isa = PBXGroup; children = ( 37A6145B186B21F6007A4638 /* acts.cpp */, 37A6145C186B21F6007A4638 /* acts.h */, 37A6145D186B21F6007A4638 /* cons.cpp */, 37A6145E186B21F6007A4638 /* cons.h */, 37A6145F186B21F6007A4638 /* EventDef.h */, ); path = TriggerCode; sourceTree = ""; }; 460E45011807E711000CDD6D /* SimpleGame */ = { isa = PBXGroup; children = ( 1A6A41DE180BE41100565AC2 /* Classes */, 460E452C1807E712000CDD6D /* proj.ios */, 1A914198180BEB4B00CFC31F /* proj.mac */, 460E459D180801A4000CDD6D /* Resources */, ); name = SimpleGame; path = ../samples/Cpp/SimpleGame; sourceTree = ""; }; 460E452C1807E712000CDD6D /* proj.ios */ = { isa = PBXGroup; children = ( 460E452D1807E712000CDD6D /* AppController.h */, 460E452E1807E712000CDD6D /* AppController.mm */, 460E452F1807E712000CDD6D /* Default-568h@2x.png */, 460E45301807E712000CDD6D /* Default.png */, 460E45311807E712000CDD6D /* Default@2x.png */, 460E45321807E712000CDD6D /* Icon-114.png */, 460E45331807E712000CDD6D /* Icon-120.png */, 460E45341807E712000CDD6D /* Icon-144.png */, 460E45351807E712000CDD6D /* Icon-152.png */, 460E45361807E712000CDD6D /* Icon-57.png */, 460E45371807E712000CDD6D /* Icon-72.png */, 460E45381807E712000CDD6D /* Icon-76.png */, 460E45391807E712000CDD6D /* main.m */, 460E453A1807E712000CDD6D /* RootViewController.h */, 460E453B1807E712000CDD6D /* RootViewController.mm */, 460E453C1807E712000CDD6D /* SimpleGame-Info.plist */, 460E453D1807E712000CDD6D /* SimpleGame_Prefix.pch */, ); path = proj.ios; sourceTree = ""; }; 460E459D180801A4000CDD6D /* Resources */ = { isa = PBXGroup; children = ( 460E45DA180801C9000CDD6D /* sd */, 460E45D7180801C1000CDD6D /* hd */, 460E459E180801A4000CDD6D /* .gitignore */, 460E459F180801A4000CDD6D /* app.config.txt */, 460E45A0180801A4000CDD6D /* app.icf */, 460E45A1180801A4000CDD6D /* background-music-aac.wav */, 460E45A2180801A4000CDD6D /* development.icf */, 460E45A3180801A4000CDD6D /* fonts */, 460E45AB180801A4000CDD6D /* pew-pew-lei.wav */, ); path = Resources; sourceTree = ""; }; 460E45A3180801A4000CDD6D /* fonts */ = { isa = PBXGroup; children = ( 460E45A4180801A4000CDD6D /* Marker Felt.ttf */, ); path = fonts; sourceTree = ""; }; 4662EB5C188E426300B02E8F /* ReleasePoolTest */ = { isa = PBXGroup; children = ( 4662EB63188E472A00B02E8F /* ReleasePoolTest.h */, 4662EB5D188E426300B02E8F /* ReleasePoolTest.cpp */, ); path = ReleasePoolTest; sourceTree = ""; }; 46A15F9D1807A4F8005B8026 /* Products */ = { isa = PBXGroup; children = ( 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */, 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */, 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */, 46A15FB61807A4F9005B8026 /* libbox2d Mac.a */, 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */, 46A15FBA1807A4F9005B8026 /* libjsbindings Mac.a */, 46A15FBC1807A4F9005B8026 /* libluabindings Mac.a */, 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */, 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */, 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */, 46A15FC41807A4F9005B8026 /* libbox2d iOS.a */, 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */, 46A15FC81807A4F9005B8026 /* libjsbindings iOS.a */, 46A15FCA1807A4F9005B8026 /* libluabindings iOS.a */, ); name = Products; sourceTree = ""; }; 46A174831807D934005B8026 /* HelloCpp */ = { isa = PBXGroup; children = ( 46A174841807D934005B8026 /* Classes */, 46A174AA1807D934005B8026 /* proj.ios */, 46A174C51807D934005B8026 /* proj.mac */, 46A174D41807D934005B8026 /* Resources */, ); name = HelloCpp; path = ../samples/Cpp/HelloCpp; sourceTree = ""; }; 46A174841807D934005B8026 /* Classes */ = { isa = PBXGroup; children = ( 46A174851807D934005B8026 /* AppDelegate.cpp */, 46A174861807D934005B8026 /* AppDelegate.h */, 46A174871807D934005B8026 /* AppMacros.h */, 46A174881807D934005B8026 /* HelloWorldScene.cpp */, 46A174891807D934005B8026 /* HelloWorldScene.h */, ); path = Classes; sourceTree = ""; }; 46A174AA1807D934005B8026 /* proj.ios */ = { isa = PBXGroup; children = ( 46A174AB1807D934005B8026 /* AppController.h */, 46A174AC1807D934005B8026 /* AppController.mm */, 46A174AD1807D934005B8026 /* Default-568h@2x.png */, 46A174AE1807D934005B8026 /* Default.png */, 46A174AF1807D934005B8026 /* Default@2x.png */, 46A174B01807D934005B8026 /* HelloCpp-Info.plist */, 46A174B11807D934005B8026 /* HelloCpp_Prefix.pch */, 46A174B21807D934005B8026 /* Icon-100.png */, 46A174B31807D934005B8026 /* Icon-114.png */, 46A174B41807D934005B8026 /* Icon-120.png */, 46A174B51807D934005B8026 /* Icon-144.png */, 46A174B61807D934005B8026 /* Icon-152.png */, 46A174B71807D934005B8026 /* Icon-40.png */, 46A174B81807D934005B8026 /* Icon-57.png */, 46A174B91807D934005B8026 /* Icon-58.png */, 46A174BA1807D934005B8026 /* Icon-72.png */, 46A174BB1807D934005B8026 /* Icon-76.png */, 46A174BC1807D934005B8026 /* Icon-80.png */, 46A174BD1807D934005B8026 /* main.m */, 46A174BE1807D934005B8026 /* RootViewController.h */, 46A174BF1807D934005B8026 /* RootViewController.mm */, ); path = proj.ios; sourceTree = ""; }; 46A174C51807D934005B8026 /* proj.mac */ = { isa = PBXGroup; children = ( 46A174C61807D934005B8026 /* InfoPlist.strings */, 46A174C81807D934005B8026 /* MainMenu.xib */, 46A174CA1807D934005B8026 /* HelloCpp_Info.plist */, 46A174CB1807D934005B8026 /* HelloCpp_Prefix.pch */, 46A174CC1807D934005B8026 /* Icon.icns */, 46A174CD1807D934005B8026 /* main.cpp */, ); path = proj.mac; sourceTree = ""; }; 46A174D41807D934005B8026 /* Resources */ = { isa = PBXGroup; children = ( 46A174EC1807D9C4005B8026 /* bang.png */, 46A174EE1807D9C4005B8026 /* fonts */, 46A174EF1807D9C4005B8026 /* ipad */, 46A174F01807D9C4005B8026 /* ipadhd */, 46A174F11807D9C4005B8026 /* iphone */, ); path = Resources; sourceTree = ""; }; 50691333184EB453009BBDD7 /* ConsoleTest */ = { isa = PBXGroup; children = ( 50691334184EB453009BBDD7 /* ConsoleTest.cpp */, 50691335184EB453009BBDD7 /* ConsoleTest.h */, ); path = ConsoleTest; sourceTree = ""; }; 50D360CC186819DB00828878 /* UIButtonTest */ = { isa = PBXGroup; children = ( 50D360CD186819DB00828878 /* UIButtonTest.cpp */, 50D360CE186819DB00828878 /* UIButtonTest.h */, ); path = UIButtonTest; sourceTree = ""; }; 50D360CF186819DB00828878 /* UICheckBoxTest */ = { isa = PBXGroup; children = ( 50D360D0186819DB00828878 /* UICheckBoxTest.cpp */, 50D360D1186819DB00828878 /* UICheckBoxTest.h */, ); path = UICheckBoxTest; sourceTree = ""; }; 50D360D2186819DB00828878 /* UIImageViewTest */ = { isa = PBXGroup; children = ( 50D360D3186819DB00828878 /* UIImageViewTest.cpp */, 50D360D4186819DB00828878 /* UIImageViewTest.h */, ); path = UIImageViewTest; sourceTree = ""; }; 50D360D5186819DB00828878 /* UILabelAtlasTest */ = { isa = PBXGroup; children = ( 50D360D6186819DB00828878 /* UILabelAtlasTest.cpp */, 50D360D7186819DB00828878 /* UILabelAtlasTest.h */, ); path = UILabelAtlasTest; sourceTree = ""; }; 50D360D8186819DB00828878 /* UILabelBMFontTest */ = { isa = PBXGroup; children = ( 50D360D9186819DB00828878 /* UILabelBMFontTest.cpp */, 50D360DA186819DB00828878 /* UILabelBMFontTest.h */, ); path = UILabelBMFontTest; sourceTree = ""; }; 50D360DB186819DB00828878 /* UILabelTest */ = { isa = PBXGroup; children = ( 50D360DC186819DB00828878 /* UILabelTest.cpp */, 50D360DD186819DB00828878 /* UILabelTest.h */, ); path = UILabelTest; sourceTree = ""; }; 50D360DE186819DB00828878 /* UILayoutTest */ = { isa = PBXGroup; children = ( 50D360DF186819DB00828878 /* UILayoutTest.cpp */, 50D360E0186819DB00828878 /* UILayoutTest.h */, ); path = UILayoutTest; sourceTree = ""; }; 50D360E1186819DB00828878 /* UIListViewTest */ = { isa = PBXGroup; children = ( 50D360E2186819DB00828878 /* UIListViewTest.cpp */, 50D360E3186819DB00828878 /* UIListViewTest.h */, ); path = UIListViewTest; sourceTree = ""; }; 50D360E4186819DB00828878 /* UILoadingBarTest */ = { isa = PBXGroup; children = ( 50D360E5186819DB00828878 /* UILoadingBarTest.cpp */, 50D360E6186819DB00828878 /* UILoadingBarTest.h */, ); path = UILoadingBarTest; sourceTree = ""; }; 50D360E7186819DB00828878 /* UIPageViewTest */ = { isa = PBXGroup; children = ( 50D360E8186819DB00828878 /* UIPageViewTest.cpp */, 50D360E9186819DB00828878 /* UIPageViewTest.h */, ); path = UIPageViewTest; sourceTree = ""; }; 50D360EE186819DB00828878 /* UIScrollViewTest */ = { isa = PBXGroup; children = ( 50D360EF186819DB00828878 /* UIScrollViewTest.cpp */, 50D360F0186819DB00828878 /* UIScrollViewTest.h */, ); path = UIScrollViewTest; sourceTree = ""; }; 50D360F1186819DB00828878 /* UISliderTest */ = { isa = PBXGroup; children = ( 50D360F2186819DB00828878 /* UISliderTest.cpp */, 50D360F3186819DB00828878 /* UISliderTest.h */, ); path = UISliderTest; sourceTree = ""; }; 50D360F4186819DB00828878 /* UITextFieldTest */ = { isa = PBXGroup; children = ( 50D360F5186819DB00828878 /* UITextFieldTest.cpp */, 50D360F6186819DB00828878 /* UITextFieldTest.h */, ); path = UITextFieldTest; sourceTree = ""; }; 50D360F7186819DB00828878 /* UIWidgetAddNodeTest */ = { isa = PBXGroup; children = ( 50D360F8186819DB00828878 /* UIWidgetAddNodeTest.cpp */, 50D360F9186819DB00828878 /* UIWidgetAddNodeTest.h */, ); path = UIWidgetAddNodeTest; sourceTree = ""; }; 599121E3182C74AC00CE785B /* NewRendererTest */ = { isa = PBXGroup; children = ( 599121E4182C74AC00CE785B /* NewRendererTest.cpp */, 599121E5182C74AC00CE785B /* NewRendererTest.h */, ); path = NewRendererTest; sourceTree = ""; }; 59A79D5A1821E95C00F19697 /* InputTest */ = { isa = PBXGroup; children = ( 59A79D5B1821E95C00F19697 /* MouseTest.cpp */, 59A79D5C1821E95C00F19697 /* MouseTest.h */, ); path = InputTest; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 1A1197B31785363400D62A44 /* Hello lua iOS */ = { isa = PBXNativeTarget; buildConfigurationList = 1A1197D41785363400D62A44 /* Build configuration list for PBXNativeTarget "Hello lua iOS" */; buildPhases = ( 1A1197B61785363400D62A44 /* Resources */, 1A1197C31785363400D62A44 /* Sources */, 1A1197C91785363400D62A44 /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A8C565D180E8DFB00EF57C3 /* PBXTargetDependency */, 1A8C565F180E8DFB00EF57C3 /* PBXTargetDependency */, 1A8C5661180E8DFB00EF57C3 /* PBXTargetDependency */, 1A8C5663180E8DFB00EF57C3 /* PBXTargetDependency */, 1A8C5665180E8DFB00EF57C3 /* PBXTargetDependency */, ); name = "Hello lua iOS"; productName = iphone; productReference = 1A1197D71785363400D62A44 /* Hello lua iOS.app */; productType = "com.apple.product-type.application"; }; 1A11982D178538E400D62A44 /* Test lua iOS */ = { isa = PBXNativeTarget; buildConfigurationList = 1A11986D178538E400D62A44 /* Build configuration list for PBXNativeTarget "Test lua iOS" */; buildPhases = ( 1A119836178538E400D62A44 /* Resources */, 1A11985A178538E400D62A44 /* Sources */, 1A11985F178538E400D62A44 /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A8C5890180E8F8000EF57C3 /* PBXTargetDependency */, 1A8C5892180E8F8000EF57C3 /* PBXTargetDependency */, 1A8C5894180E8F8000EF57C3 /* PBXTargetDependency */, 1A8C5896180E8F8000EF57C3 /* PBXTargetDependency */, 1A8C5898180E8F8000EF57C3 /* PBXTargetDependency */, ); name = "Test lua iOS"; productName = iphone; productReference = 1A119870178538E400D62A44 /* Test lua iOS.app */; productType = "com.apple.product-type.application"; }; 1A6FB53517854FE400CDF010 /* Hello lua Mac */ = { isa = PBXNativeTarget; buildConfigurationList = 1A6FB56817854FE400CDF010 /* Build configuration list for PBXNativeTarget "Hello lua Mac" */; buildPhases = ( 1A6FB53E17854FE400CDF010 /* Resources */, 1A6FB55517854FE400CDF010 /* Sources */, 1A6FB55A17854FE400CDF010 /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A8C55BB180E8BA400EF57C3 /* PBXTargetDependency */, 1A8C55BD180E8BA400EF57C3 /* PBXTargetDependency */, 1A8C55BF180E8BA400EF57C3 /* PBXTargetDependency */, 1A8C55C1180E8BA400EF57C3 /* PBXTargetDependency */, 1A8C55C3180E8BA400EF57C3 /* PBXTargetDependency */, ); name = "Hello lua Mac"; productName = iphone; productReference = 1A6FB56B17854FE400CDF010 /* Hello lua Mac.app */; productType = "com.apple.product-type.application"; }; 1A6FB7821785614200CDF010 /* Test lua Mac */ = { isa = PBXNativeTarget; buildConfigurationList = 1A6FB7B01785614200CDF010 /* Build configuration list for PBXNativeTarget "Test lua Mac" */; buildPhases = ( 1A6FB78B1785614200CDF010 /* Resources */, 1A6FB79E1785614200CDF010 /* Sources */, 1A6FB7A21785614200CDF010 /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A8C5881180E8F5F00EF57C3 /* PBXTargetDependency */, 1A8C5883180E8F5F00EF57C3 /* PBXTargetDependency */, 1A8C5885180E8F5F00EF57C3 /* PBXTargetDependency */, 1A8C5887180E8F5F00EF57C3 /* PBXTargetDependency */, 1A8C5889180E8F5F00EF57C3 /* PBXTargetDependency */, ); name = "Test lua Mac"; productName = iphone; productReference = 1A6FB7B31785614200CDF010 /* Test lua Mac.app */; productType = "com.apple.product-type.application"; }; 1D6058900D05DD3D006BFB54 /* Test cpp Mac */ = { isa = PBXNativeTarget; buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Test cpp Mac" */; buildPhases = ( 1D60588D0D05DD3D006BFB54 /* Resources */, 1D60588E0D05DD3D006BFB54 /* Sources */, 1D60588F0D05DD3D006BFB54 /* Frameworks */, ); buildRules = ( ); dependencies = ( 1AAF5342180E2F41000584C8 /* PBXTargetDependency */, 1AAF5344180E2F41000584C8 /* PBXTargetDependency */, 1AAF5346180E2F41000584C8 /* PBXTargetDependency */, 1AAF5348180E2F41000584C8 /* PBXTargetDependency */, 1AAF534A180E2F41000584C8 /* PBXTargetDependency */, ); name = "Test cpp Mac"; productName = iphone; productReference = 1D6058910D05DD3D006BFB54 /* Test cpp Mac.app */; productType = "com.apple.product-type.application"; }; A01E16631784BDA100B0CA4A /* Simple Game iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A01E16901784BDA100B0CA4A /* Build configuration list for PBXNativeTarget "Simple Game iOS" */; buildPhases = ( A01E16681784BDA100B0CA4A /* Resources */, A01E167E1784BDA100B0CA4A /* Sources */, A01E16841784BDA100B0CA4A /* Frameworks */, ); buildRules = ( ); dependencies = ( 460E45DE18080218000CDD6D /* PBXTargetDependency */, 460E44FF1807E656000CDD6D /* PBXTargetDependency */, ); name = "Simple Game iOS"; productName = iphone; productReference = A01E16931784BDA100B0CA4A /* Simple Game iOS.app */; productType = "com.apple.product-type.application"; }; A01E16C01784C06E00B0CA4A /* Test JavaScript iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A01E176F1784C06E00B0CA4A /* Build configuration list for PBXNativeTarget "Test JavaScript iOS" */; buildPhases = ( A01E16CB1784C06E00B0CA4A /* Resources */, A01E16F51784C06E00B0CA4A /* Sources */, A01E17601784C06E00B0CA4A /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A9DCA57180E743F007A3AD4 /* PBXTargetDependency */, 1A9DCA59180E743F007A3AD4 /* PBXTargetDependency */, 1A9DCA5B180E743F007A3AD4 /* PBXTargetDependency */, 1A9DCA5D180E743F007A3AD4 /* PBXTargetDependency */, 1A9DCA5F180E743F007A3AD4 /* PBXTargetDependency */, ); name = "Test JavaScript iOS"; productName = iphone; productReference = A01E17721784C06E00B0CA4A /* Test JavaScript iOS.app */; productType = "com.apple.product-type.application"; }; A01E17E71784C45400B0CA4A /* JS Watermelon With Me iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A01E18541784C45400B0CA4A /* Build configuration list for PBXNativeTarget "JS Watermelon With Me iOS" */; buildPhases = ( A01E17F41784C45400B0CA4A /* Resources */, A01E183E1784C45400B0CA4A /* Sources */, A01E18431784C45400B0CA4A /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A3B1E86180E804400497A22 /* PBXTargetDependency */, 1A3B1E88180E804400497A22 /* PBXTargetDependency */, 1A3B1E8A180E804400497A22 /* PBXTargetDependency */, 1A3B1E8C180E804400497A22 /* PBXTargetDependency */, 1A3B1E8E180E804400497A22 /* PBXTargetDependency */, ); name = "JS Watermelon With Me iOS"; productName = iphone; productReference = A01E18571784C45500B0CA4A /* JS Watermelon With Me iOS.app */; productType = "com.apple.product-type.application"; }; A01E18591784C4D600B0CA4A /* JS Moon Warriors iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A01E18891784C4D600B0CA4A /* Build configuration list for PBXNativeTarget "JS Moon Warriors iOS" */; buildPhases = ( A01E18661784C4D600B0CA4A /* Resources */, A01E18731784C4D600B0CA4A /* Sources */, A01E18781784C4D600B0CA4A /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A3B1E0B180E7E1D00497A22 /* PBXTargetDependency */, 1A3B1E0D180E7E1D00497A22 /* PBXTargetDependency */, 1A3B1E0F180E7E1D00497A22 /* PBXTargetDependency */, 1A3B1E11180E7E1D00497A22 /* PBXTargetDependency */, 1A3B1E13180E7E1D00497A22 /* PBXTargetDependency */, ); name = "JS Moon Warriors iOS"; productName = iphone; productReference = A01E188C1784C4D600B0CA4A /* JS Moon Warriors iOS.app */; productType = "com.apple.product-type.application"; }; A01E188E1784C4DC00B0CA4A /* JS Crystal Craze iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A01E18BE1784C4DC00B0CA4A /* Build configuration list for PBXNativeTarget "JS Crystal Craze iOS" */; buildPhases = ( A01E189B1784C4DC00B0CA4A /* Resources */, A01E18A81784C4DC00B0CA4A /* Sources */, A01E18AD1784C4DC00B0CA4A /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A3B1F3A180E82D200497A22 /* PBXTargetDependency */, 1A3B1F3C180E82D200497A22 /* PBXTargetDependency */, 1A3B1F3E180E82D200497A22 /* PBXTargetDependency */, 1A3B1F40180E82D200497A22 /* PBXTargetDependency */, 1A3B1F42180E82D200497A22 /* PBXTargetDependency */, ); name = "JS Crystal Craze iOS"; productName = iphone; productReference = A01E18C11784C4DC00B0CA4A /* JS Crystal Craze iOS.app */; productType = "com.apple.product-type.application"; }; A01E18C31784C4E000B0CA4A /* JS CocosDragon iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A01E18F31784C4E000B0CA4A /* Build configuration list for PBXNativeTarget "JS CocosDragon iOS" */; buildPhases = ( A01E18D01784C4E000B0CA4A /* Resources */, A01E18DD1784C4E000B0CA4A /* Sources */, A01E18E21784C4E000B0CA4A /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A3B1EE2180E81AA00497A22 /* PBXTargetDependency */, 1A3B1EE4180E81AA00497A22 /* PBXTargetDependency */, 1A3B1EE6180E81AA00497A22 /* PBXTargetDependency */, 1A3B1EE8180E81AA00497A22 /* PBXTargetDependency */, 1A3B1EEA180E81AA00497A22 /* PBXTargetDependency */, ); name = "JS CocosDragon iOS"; productName = iphone; productReference = A01E18F61784C4E000B0CA4A /* JS CocosDragon iOS.app */; productType = "com.apple.product-type.application"; }; A035A5441782290400987F6C /* Test JavaScript Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A035A5E91782290400987F6C /* Build configuration list for PBXNativeTarget "Test JavaScript Mac" */; buildPhases = ( A035A54F1782290400987F6C /* Resources */, A035A5701782290400987F6C /* Sources */, A035A5DA1782290400987F6C /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A9DC9E8180E68CE007A3AD4 /* PBXTargetDependency */, 1A9DC9EA180E68CE007A3AD4 /* PBXTargetDependency */, 1A9DC9EC180E68CE007A3AD4 /* PBXTargetDependency */, 1A9DC9EE180E68CE007A3AD4 /* PBXTargetDependency */, 1A9DC9F0180E68CE007A3AD4 /* PBXTargetDependency */, ); name = "Test JavaScript Mac"; productName = iphone; productReference = A035A5EC1782290400987F6C /* Test JavaScript Mac.app */; productType = "com.apple.product-type.application"; }; A035A7131782301C00987F6C /* JS Watermelon With Me Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A035A77A1782301C00987F6C /* Build configuration list for PBXNativeTarget "JS Watermelon With Me Mac" */; buildPhases = ( A035A7201782301C00987F6C /* Resources */, A035A7661782301C00987F6C /* Sources */, A035A76A1782301C00987F6C /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A3B1E70180E7F3E00497A22 /* PBXTargetDependency */, 1A3B1E72180E7F3E00497A22 /* PBXTargetDependency */, 1A3B1E74180E7F3E00497A22 /* PBXTargetDependency */, 1A3B1E76180E7F3E00497A22 /* PBXTargetDependency */, 1A3B1E78180E7F3E00497A22 /* PBXTargetDependency */, ); name = "JS Watermelon With Me Mac"; productName = iphone; productReference = A035A77D1782301C00987F6C /* JS Watermelon With Me Mac.app */; productType = "com.apple.product-type.application"; }; A035A9BA17823FE100987F6C /* JS Moon Warriors Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A035A9F417823FE100987F6C /* Build configuration list for PBXNativeTarget "JS Moon Warriors Mac" */; buildPhases = ( A035A9C717823FE100987F6C /* Resources */, A035A9E017823FE100987F6C /* Sources */, A035A9E417823FE100987F6C /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A3B1DE9180E7C9C00497A22 /* PBXTargetDependency */, 1A3B1DEB180E7C9C00497A22 /* PBXTargetDependency */, 1A3B1DED180E7C9C00497A22 /* PBXTargetDependency */, 1A3B1DEF180E7C9C00497A22 /* PBXTargetDependency */, 1A3B1DF1180E7C9C00497A22 /* PBXTargetDependency */, ); name = "JS Moon Warriors Mac"; productName = iphone; productReference = A035A9F717823FE100987F6C /* JS Moon Warriors Mac.app */; productType = "com.apple.product-type.application"; }; A035AA8D1782422400987F6C /* JS Crystal Craze Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A035AAC21782422400987F6C /* Build configuration list for PBXNativeTarget "JS Crystal Craze Mac" */; buildPhases = ( A035AA9A1782422400987F6C /* Resources */, A035AAAE1782422400987F6C /* Sources */, A035AAB21782422400987F6C /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A3B1F2B180E82B800497A22 /* PBXTargetDependency */, 1A3B1F2D180E82B800497A22 /* PBXTargetDependency */, 1A3B1F2F180E82B800497A22 /* PBXTargetDependency */, 1A3B1F31180E82B800497A22 /* PBXTargetDependency */, 1A3B1F33180E82B800497A22 /* PBXTargetDependency */, ); name = "JS Crystal Craze Mac"; productName = iphone; productReference = A035AAC51782422400987F6C /* JS Crystal Craze Mac.app */; productType = "com.apple.product-type.application"; }; A035AC021782453000987F6C /* JS CocosDragon Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A035AC341782453000987F6C /* Build configuration list for PBXNativeTarget "JS CocosDragon Mac" */; buildPhases = ( A035AC0F1782453000987F6C /* Resources */, A035AC201782453000987F6C /* Sources */, A035AC241782453000987F6C /* Frameworks */, ); buildRules = ( ); dependencies = ( 1A3B1ED3180E810E00497A22 /* PBXTargetDependency */, 1A3B1ED5180E810E00497A22 /* PBXTargetDependency */, 1A3B1ED7180E810E00497A22 /* PBXTargetDependency */, 1A3B1ED9180E810E00497A22 /* PBXTargetDependency */, 1A3B1EDB180E810E00497A22 /* PBXTargetDependency */, ); name = "JS CocosDragon Mac"; productName = iphone; productReference = A035AC371782453000987F6C /* JS CocosDragon Mac.app */; productType = "com.apple.product-type.application"; }; A035ACCE178254A300987F6C /* Simple Game Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A035AD73178254A300987F6C /* Build configuration list for PBXNativeTarget "Simple Game Mac" */; buildPhases = ( A035ACD9178254A300987F6C /* Resources */, A035ACFA178254A300987F6C /* Sources */, A035AD64178254A300987F6C /* Frameworks */, ); buildRules = ( ); dependencies = ( 460E45831807FDB0000CDD6D /* PBXTargetDependency */, 460E45851807FDB0000CDD6D /* PBXTargetDependency */, ); name = "Simple Game Mac"; productName = iphone; productReference = A035AD76178254A300987F6C /* Simple Game Mac.app */; productType = "com.apple.product-type.application"; }; A035AE58178255DC00987F6C /* Hello cpp Mac */ = { isa = PBXNativeTarget; buildConfigurationList = A035AE85178255DC00987F6C /* Build configuration list for PBXNativeTarget "Hello cpp Mac" */; buildPhases = ( A035AE5D178255DC00987F6C /* Resources */, A035AE73178255DC00987F6C /* Sources */, A035AE79178255DC00987F6C /* Frameworks */, ); buildRules = ( ); dependencies = ( 460E44FC1807E408000CDD6D /* PBXTargetDependency */, ); name = "Hello cpp Mac"; productName = iphone; productReference = A035AE88178255DC00987F6C /* Hello cpp Mac.app */; productType = "com.apple.product-type.application"; }; A07A517F1783A1D20073F6A7 /* Test cpp iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A52261783A1D20073F6A7 /* Build configuration list for PBXNativeTarget "Test cpp iOS" */; buildPhases = ( A07A518A1783A1D20073F6A7 /* Resources */, A07A51AD1783A1D20073F6A7 /* Sources */, A07A52171783A1D20073F6A7 /* Frameworks */, ); buildRules = ( ); dependencies = ( 1AAF53F5180E39C6000584C8 /* PBXTargetDependency */, 1AAF53F7180E39C6000584C8 /* PBXTargetDependency */, 1AAF53F9180E39C6000584C8 /* PBXTargetDependency */, 1AAF53FB180E39C6000584C8 /* PBXTargetDependency */, 1AAF53FD180E39C6000584C8 /* PBXTargetDependency */, ); name = "Test cpp iOS"; productName = iphone; productReference = A07A52291783A1D20073F6A7 /* Test cpp iOS.app */; productType = "com.apple.product-type.application"; }; A07A52CF1784AC9B0073F6A7 /* Hello cpp iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A537E1784AC9B0073F6A7 /* Build configuration list for PBXNativeTarget "Hello cpp iOS" */; buildPhases = ( A07A52DA1784AC9B0073F6A7 /* Resources */, A07A53041784AC9B0073F6A7 /* Sources */, A07A536F1784AC9B0073F6A7 /* Frameworks */, ); buildRules = ( ); dependencies = ( 460E44BA1807DCCC000CDD6D /* PBXTargetDependency */, ); name = "Hello cpp iOS"; productName = iphone; productReference = A07A53811784AC9B0073F6A7 /* Hello cpp iOS.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0500; }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "cocos2d_samples" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, Japanese, French, German, en, ); mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; projectDirPath = ""; projectReferences = ( { ProductGroup = 46A15F9D1807A4F8005B8026 /* Products */; ProjectRef = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; }, ); projectRoot = ""; targets = ( A035ACBB1782469700987F6C /* build-all-samples Mac */, A035AE58178255DC00987F6C /* Hello cpp Mac */, A035ACCE178254A300987F6C /* Simple Game Mac */, 1D6058900D05DD3D006BFB54 /* Test cpp Mac */, A035A5441782290400987F6C /* Test JavaScript Mac */, A035A7131782301C00987F6C /* JS Watermelon With Me Mac */, A035A9BA17823FE100987F6C /* JS Moon Warriors Mac */, A035AA8D1782422400987F6C /* JS Crystal Craze Mac */, A035AC021782453000987F6C /* JS CocosDragon Mac */, 1A6FB53517854FE400CDF010 /* Hello lua Mac */, 1A6FB7821785614200CDF010 /* Test lua Mac */, A07A517B1783A1CC0073F6A7 /* build-all-samples iOS */, A07A52CF1784AC9B0073F6A7 /* Hello cpp iOS */, A07A517F1783A1D20073F6A7 /* Test cpp iOS */, A01E16631784BDA100B0CA4A /* Simple Game iOS */, A01E16C01784C06E00B0CA4A /* Test JavaScript iOS */, A01E17E71784C45400B0CA4A /* JS Watermelon With Me iOS */, A01E18591784C4D600B0CA4A /* JS Moon Warriors iOS */, A01E188E1784C4DC00B0CA4A /* JS Crystal Craze iOS */, A01E18C31784C4E000B0CA4A /* JS CocosDragon iOS */, 1A1197B31785363400D62A44 /* Hello lua iOS */, 1A11982D178538E400D62A44 /* Test lua iOS */, ); }; /* End PBXProject section */ /* Begin PBXReferenceProxy section */ 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libcocos2dx Mac.a"; remoteRef = 46A15FAF1807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FB21807A4F9005B8026 /* libcocos2dx-extensions Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libcocos2dx-extensions Mac.a"; remoteRef = 46A15FB11807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libchipmunk Mac.a"; remoteRef = 46A15FB31807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FB61807A4F9005B8026 /* libbox2d Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libbox2d Mac.a"; remoteRef = 46A15FB51807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libCocosDenshion Mac.a"; remoteRef = 46A15FB71807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FBA1807A4F9005B8026 /* libjsbindings Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libjsbindings Mac.a"; remoteRef = 46A15FB91807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FBC1807A4F9005B8026 /* libluabindings Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libluabindings Mac.a"; remoteRef = 46A15FBB1807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FBE1807A4F9005B8026 /* libcocos2dx iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libcocos2dx iOS.a"; remoteRef = 46A15FBD1807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FC01807A4F9005B8026 /* libcocos2dx-extensions iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libcocos2dx-extensions iOS.a"; remoteRef = 46A15FBF1807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FC21807A4F9005B8026 /* libchipmunk iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libchipmunk iOS.a"; remoteRef = 46A15FC11807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FC41807A4F9005B8026 /* libbox2d iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libbox2d iOS.a"; remoteRef = 46A15FC31807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FC61807A4F9005B8026 /* libCocosDenshion iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libCocosDenshion iOS.a"; remoteRef = 46A15FC51807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FC81807A4F9005B8026 /* libjsbindings iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libjsbindings iOS.a"; remoteRef = 46A15FC71807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 46A15FCA1807A4F9005B8026 /* libluabindings iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libluabindings iOS.a"; remoteRef = 46A15FC91807A4F9005B8026 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ 1A1197B61785363400D62A44 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A8C554B180E8B3D00EF57C3 /* Default-568h@2x.png in Resources */, 15A71DB81894AE6200F30AC0 /* mobdebug.lua in Resources */, 1A8C554C180E8B3D00EF57C3 /* Default.png in Resources */, 1A8C554D180E8B3D00EF57C3 /* Default@2x.png in Resources */, 1A8C554E180E8B3D00EF57C3 /* Icon-114.png in Resources */, 1A8C554F180E8B3D00EF57C3 /* Icon-120.png in Resources */, 1A8C5550180E8B3D00EF57C3 /* Icon-144.png in Resources */, 1A8C5551180E8B3D00EF57C3 /* Icon-152.png in Resources */, 1A8C5552180E8B3D00EF57C3 /* Icon-57.png in Resources */, 1A8C5553180E8B3D00EF57C3 /* Icon-72.png in Resources */, 1585AB131821FA1A00000FB5 /* luaoc.lua in Resources */, 1A8C5554180E8B3D00EF57C3 /* Icon-76.png in Resources */, 15394DF5182E8F5D000A418D /* StudioConstants.lua in Resources */, 1A8C557C180E8B5100EF57C3 /* background.mp3 in Resources */, 1A8C557E180E8B5100EF57C3 /* background.ogg in Resources */, 1A8C5580180E8B5100EF57C3 /* crop.png in Resources */, 1A8C5584180E8B5100EF57C3 /* dog.png in Resources */, 1A8C5586180E8B5100EF57C3 /* effect1.wav in Resources */, 1A8C5588180E8B5100EF57C3 /* farm.jpg in Resources */, 1A8C558A180E8B5100EF57C3 /* Marker Felt.ttf in Resources */, 1A8C558C180E8B5100EF57C3 /* hello.lua in Resources */, 1A8C558E180E8B5100EF57C3 /* hello2.lua in Resources */, 1A8C5590180E8B5100EF57C3 /* land.png in Resources */, 1A8C5592180E8B5100EF57C3 /* menu1.png in Resources */, 1A8C5594180E8B5100EF57C3 /* menu2.png in Resources */, 1A8C55A3180E8B8400EF57C3 /* AudioEngine.lua in Resources */, 1A8C55A5180E8B8400EF57C3 /* CCBReaderLoad.lua in Resources */, 1A8C55A7180E8B8400EF57C3 /* Cocos2d.lua in Resources */, 1A8C55A9180E8B8400EF57C3 /* Cocos2dConstants.lua in Resources */, 1A8C55AB180E8B8400EF57C3 /* Deprecated.lua in Resources */, 1A8C55AD180E8B8400EF57C3 /* DeprecatedClass.lua in Resources */, 1A8C55AF180E8B8400EF57C3 /* DeprecatedEnum.lua in Resources */, 1A8C55B1180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua in Resources */, 1A8C55B3180E8B8400EF57C3 /* DrawPrimitives.lua in Resources */, 1A8C55B5180E8B8400EF57C3 /* luaj.lua in Resources */, 1A8C55B7180E8B8400EF57C3 /* Opengl.lua in Resources */, 1585AB37182299FA00000FB5 /* json.lua in Resources */, 1A8C55B9180E8B8400EF57C3 /* OpenglConstants.lua in Resources */, 15F4C82B18751B590082884F /* extern.lua in Resources */, 15F4C849187551340082884F /* CocoStudio.lua in Resources */, 15982CE4187656CD00625972 /* GuiConstants.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A119836178538E400D62A44 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A08014718780C1D00E62F93 /* Hello.png in Resources */, 1A08010E18780BD600E62F93 /* animations in Resources */, 1A08011618780BD600E62F93 /* hd in Resources */, 1A0800E218780B6100E62F93 /* DeprecatedEnum.lua in Resources */, 1A0800D918780B6100E62F93 /* StudioConstants.lua in Resources */, 1A08011518780BD600E62F93 /* fonts in Resources */, 1A08011E18780BD600E62F93 /* spine in Resources */, 1A0800C118780B2A00E62F93 /* luaScript in Resources */, 1A08011118780BD600E62F93 /* cocosgui in Resources */, 1A08014518780C1D00E62F93 /* fileLookup.plist in Resources */, 1A08014218780C1D00E62F93 /* effect1.raw in Resources */, 1A0800E318780B6100E62F93 /* DeprecatedOpenglEnum.lua in Resources */, 1A0800DF18780B6100E62F93 /* Cocos2dConstants.lua in Resources */, 1A08011D18780BD600E62F93 /* Shaders in Resources */, 1A08014618780C1D00E62F93 /* fps_images.png in Resources */, 1A08011018780BD600E62F93 /* ccb in Resources */, 1A08013718780C0B00E62F93 /* background-music-aac.wav in Resources */, 1A08011718780BD600E62F93 /* Images in Resources */, 1A08011F18780BD600E62F93 /* TileMaps in Resources */, 1A0800D818780B6100E62F93 /* extern.lua in Resources */, 1A08011B18780BD600E62F93 /* Particles in Resources */, 1A08011A18780BD600E62F93 /* Misc in Resources */, 1A08011218780BD600E62F93 /* components in Resources */, 1A08014418780C1D00E62F93 /* effect2.ogg in Resources */, 1A0800DA18780B6100E62F93 /* json.lua in Resources */, 1A08011418780BD600E62F93 /* extensions in Resources */, 1A0800BF18780B2A00E62F93 /* cocosbuilderRes in Resources */, 1A08014918780C1D00E62F93 /* pew-pew-lei.wav in Resources */, 1A08011918780BD600E62F93 /* ipadhd in Resources */, 1A0800E618780B6100E62F93 /* Opengl.lua in Resources */, 1A0800E118780B6100E62F93 /* DeprecatedClass.lua in Resources */, 1A0800DC18780B6100E62F93 /* AudioEngine.lua in Resources */, 1A0800DB18780B6100E62F93 /* luaoc.lua in Resources */, 1A0800DE18780B6100E62F93 /* Cocos2d.lua in Resources */, 1A0800E018780B6100E62F93 /* Deprecated.lua in Resources */, 1A08010F18780BD600E62F93 /* armature in Resources */, 1A0800E418780B6100E62F93 /* DrawPrimitives.lua in Resources */, 1A08013918780C0B00E62F93 /* background.ogg in Resources */, 1A0800D718780B6100E62F93 /* CocoStudio.lua in Resources */, 1A0800DD18780B6100E62F93 /* CCBReaderLoad.lua in Resources */, 1A08013818780C0B00E62F93 /* background.mp3 in Resources */, 1A08014818780C1D00E62F93 /* music.mid in Resources */, 1A08011C18780BD600E62F93 /* scenetest in Resources */, 1A08014318780C1D00E62F93 /* effect1.wav in Resources */, 1A08012018780BD600E62F93 /* zwoptex in Resources */, 1A08011318780BD600E62F93 /* configs in Resources */, 1A0800E718780B6100E62F93 /* OpenglConstants.lua in Resources */, 1A0800E518780B6100E62F93 /* luaj.lua in Resources */, 1A08011818780BD600E62F93 /* ipad in Resources */, 1A0800D618780B6100E62F93 /* GuiConstants.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB53E17854FE400CDF010 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A8C5561180E8B4500EF57C3 /* InfoPlist.strings in Resources */, 1A8C5562180E8B4500EF57C3 /* MainMenu.xib in Resources */, 1A8C5563180E8B4500EF57C3 /* Icon.icns in Resources */, 1A8C557B180E8B5100EF57C3 /* background.mp3 in Resources */, 1A8C557D180E8B5100EF57C3 /* background.ogg in Resources */, 1A8C557F180E8B5100EF57C3 /* crop.png in Resources */, 1A8C5583180E8B5100EF57C3 /* dog.png in Resources */, 1A8C5585180E8B5100EF57C3 /* effect1.wav in Resources */, 1A8C5587180E8B5100EF57C3 /* farm.jpg in Resources */, 1585AB35182299FA00000FB5 /* json.lua in Resources */, 1A8C5589180E8B5100EF57C3 /* Marker Felt.ttf in Resources */, 1A8C558B180E8B5100EF57C3 /* hello.lua in Resources */, 1A8C558D180E8B5100EF57C3 /* hello2.lua in Resources */, 1A8C558F180E8B5100EF57C3 /* land.png in Resources */, 1585AB111821FA1A00000FB5 /* luaoc.lua in Resources */, 15394DF3182E8F5D000A418D /* StudioConstants.lua in Resources */, 1A8C5591180E8B5100EF57C3 /* menu1.png in Resources */, 1A8C5593180E8B5100EF57C3 /* menu2.png in Resources */, 1A8C55A2180E8B8400EF57C3 /* AudioEngine.lua in Resources */, 1A8C55A4180E8B8400EF57C3 /* CCBReaderLoad.lua in Resources */, 1A8C55A6180E8B8400EF57C3 /* Cocos2d.lua in Resources */, 1A8C55A8180E8B8400EF57C3 /* Cocos2dConstants.lua in Resources */, 1A8C55AA180E8B8400EF57C3 /* Deprecated.lua in Resources */, 1A8C55AC180E8B8400EF57C3 /* DeprecatedClass.lua in Resources */, 1A8C55AE180E8B8400EF57C3 /* DeprecatedEnum.lua in Resources */, 1A8C55B0180E8B8400EF57C3 /* DeprecatedOpenglEnum.lua in Resources */, 1A8C55B2180E8B8400EF57C3 /* DrawPrimitives.lua in Resources */, 1A8C55B4180E8B8400EF57C3 /* luaj.lua in Resources */, 1A8C55B6180E8B8400EF57C3 /* Opengl.lua in Resources */, 15A71DB71894AE6200F30AC0 /* mobdebug.lua in Resources */, 1A8C55B8180E8B8400EF57C3 /* OpenglConstants.lua in Resources */, 15F4C82918751B590082884F /* extern.lua in Resources */, 15F4C847187551340082884F /* CocoStudio.lua in Resources */, 15982CE2187656CD00625972 /* GuiConstants.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB78B1785614200CDF010 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A08013F18780C1B00E62F93 /* Hello.png in Resources */, 1A0800E818780BD400E62F93 /* animations in Resources */, 1A0800F018780BD400E62F93 /* hd in Resources */, 1A0800D018780B5E00E62F93 /* DeprecatedEnum.lua in Resources */, 1A0800C718780B5E00E62F93 /* StudioConstants.lua in Resources */, 1A0800EF18780BD400E62F93 /* fonts in Resources */, 1A0800F818780BD400E62F93 /* spine in Resources */, 1A0800C018780B2A00E62F93 /* luaScript in Resources */, 1A0800EB18780BD400E62F93 /* cocosgui in Resources */, 1A08013D18780C1B00E62F93 /* fileLookup.plist in Resources */, 1A08013A18780C1B00E62F93 /* effect1.raw in Resources */, 1A0800D118780B5E00E62F93 /* DeprecatedOpenglEnum.lua in Resources */, 1A0800CD18780B5E00E62F93 /* Cocos2dConstants.lua in Resources */, 1A0800F718780BD400E62F93 /* Shaders in Resources */, 1A08013E18780C1B00E62F93 /* fps_images.png in Resources */, 1A0800EA18780BD400E62F93 /* ccb in Resources */, 1A08013418780C0700E62F93 /* background-music-aac.wav in Resources */, 1A0800F118780BD400E62F93 /* Images in Resources */, 1A0800F918780BD400E62F93 /* TileMaps in Resources */, 1A0800C618780B5E00E62F93 /* extern.lua in Resources */, 1A0800F518780BD400E62F93 /* Particles in Resources */, 1A0800F418780BD400E62F93 /* Misc in Resources */, 1A0800EC18780BD400E62F93 /* components in Resources */, 1A08013C18780C1B00E62F93 /* effect2.ogg in Resources */, 1A0800C818780B5E00E62F93 /* json.lua in Resources */, 1A0800EE18780BD400E62F93 /* extensions in Resources */, 1A0800BE18780B2A00E62F93 /* cocosbuilderRes in Resources */, 1A08014118780C1B00E62F93 /* pew-pew-lei.wav in Resources */, 1A0800F318780BD400E62F93 /* ipadhd in Resources */, 1A0800D418780B5E00E62F93 /* Opengl.lua in Resources */, 1A0800CF18780B5E00E62F93 /* DeprecatedClass.lua in Resources */, 1A0800CA18780B5E00E62F93 /* AudioEngine.lua in Resources */, 1A0800C918780B5E00E62F93 /* luaoc.lua in Resources */, 1A0800CC18780B5E00E62F93 /* Cocos2d.lua in Resources */, 1A0800CE18780B5E00E62F93 /* Deprecated.lua in Resources */, 1A0800E918780BD400E62F93 /* armature in Resources */, 1A0800D218780B5E00E62F93 /* DrawPrimitives.lua in Resources */, 1A08013618780C0700E62F93 /* background.ogg in Resources */, 1A0800C518780B5E00E62F93 /* CocoStudio.lua in Resources */, 1A0800CB18780B5E00E62F93 /* CCBReaderLoad.lua in Resources */, 1A08013518780C0700E62F93 /* background.mp3 in Resources */, 1A08014018780C1B00E62F93 /* music.mid in Resources */, 1A0800F618780BD400E62F93 /* scenetest in Resources */, 1A08013B18780C1B00E62F93 /* effect1.wav in Resources */, 1A0800FA18780BD400E62F93 /* zwoptex in Resources */, 1A0800ED18780BD400E62F93 /* configs in Resources */, 1A0800D518780B5E00E62F93 /* OpenglConstants.lua in Resources */, 1A0800D318780B5E00E62F93 /* luaj.lua in Resources */, 1A0800F218780BD400E62F93 /* ipad in Resources */, 1A0800C418780B5E00E62F93 /* GuiConstants.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1D60588D0D05DD3D006BFB54 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 37C81A2E1875DF2B00930C57 /* spine in Resources */, 37C81A3A1875DF2B00930C57 /* zwoptex in Resources */, 37C81A0A1875DF2B00930C57 /* Misc in Resources */, 37C81A041875DF2B00930C57 /* ipadhd in Resources */, 37C81A341875DF2B00930C57 /* TileMaps in Resources */, 37C819A41875DF2B00930C57 /* CocosBuilderExample.ccbproj in Resources */, 37C8199E1875DF2B00930C57 /* ccb in Resources */, 37C819D41875DF2B00930C57 /* extensions in Resources */, 1AAF5286180E2C31000584C8 /* InfoPlist.strings in Resources */, 37C81A161875DF2B00930C57 /* Particles in Resources */, 37C819F81875DF2B00930C57 /* Images in Resources */, 37C819981875DF2B00930C57 /* background.ogg in Resources */, 37C819E61875DF2B00930C57 /* fps_images.png in Resources */, 37C819B01875DF2B00930C57 /* cocosgui in Resources */, 37C819C81875DF2B00930C57 /* effect1.wav in Resources */, 37C819FE1875DF2B00930C57 /* ipad in Resources */, 37C819C21875DF2B00930C57 /* effect1.raw in Resources */, 37C819CE1875DF2B00930C57 /* effect2.ogg in Resources */, 37C819801875DF2B00930C57 /* animations in Resources */, 37C819AA1875DF2B00930C57 /* CocosBuilderExample.ccbresourcelog in Resources */, 37C81A281875DF2B00930C57 /* Shaders in Resources */, 37C81A1C1875DF2B00930C57 /* pew-pew-lei.wav in Resources */, 37C81A221875DF2B00930C57 /* scenetest in Resources */, 37C819EC1875DF2B00930C57 /* hd in Resources */, 37C819E01875DF2B00930C57 /* fonts in Resources */, 37C819B61875DF2B00930C57 /* components in Resources */, 37C8198C1875DF2B00930C57 /* background-music-aac.wav in Resources */, 37C819F21875DF2B00930C57 /* Hello.png in Resources */, 37C819DA1875DF2B00930C57 /* fileLookup.plist in Resources */, 1AAF5287180E2C31000584C8 /* MainMenu.xib in Resources */, 37C819861875DF2B00930C57 /* armature in Resources */, 37C819921875DF2B00930C57 /* background.mp3 in Resources */, 37C819BC1875DF2B00930C57 /* configs in Resources */, 37C81A101875DF2B00930C57 /* music.mid in Resources */, 1AAF5288180E2C31000584C8 /* Icon.icns in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E16681784BDA100B0CA4A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 460E45BA180801A4000CDD6D /* background-music-aac.wav in Resources */, 460E45BE180801A4000CDD6D /* Marker Felt.ttf in Resources */, 460E45D9180801C1000CDD6D /* hd in Resources */, 460E45DC180801C9000CDD6D /* sd in Resources */, 460E45CA180801A4000CDD6D /* pew-pew-lei.wav in Resources */, 5010FC92180F105C00B8E2AE /* Default-568h@2x.png in Resources */, 1A514B0E180FB6A30053B876 /* Default.png in Resources */, 1A514B0F180FB6A30053B876 /* Default@2x.png in Resources */, 1A514B10180FB6A30053B876 /* Icon-114.png in Resources */, 1A514B11180FB6A30053B876 /* Icon-120.png in Resources */, 1A514B12180FB6A30053B876 /* Icon-144.png in Resources */, 1A514B13180FB6A30053B876 /* Icon-152.png in Resources */, 1A514B14180FB6A30053B876 /* Icon-57.png in Resources */, 1A514B15180FB6A30053B876 /* Icon-72.png in Resources */, 1A514B16180FB6A30053B876 /* Icon-76.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E16CB1784C06E00B0CA4A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A2F51B11877DA5900B48BFE /* tests in Resources */, 1A9DC9E6180E6742007A3AD4 /* script in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E17F41784C45400B0CA4A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E94180E807600497A22 /* boot-html5.js in Resources */, 1A3B1E95180E807600497A22 /* boot-jsb.js in Resources */, 1A3B1E96180E807600497A22 /* levels.js in Resources */, 1A3B1E97180E807600497A22 /* main.js in Resources */, 1A3B1E98180E807600497A22 /* resources-html5.js in Resources */, 1A3B1E99180E807600497A22 /* resources-jsb.js in Resources */, 1A3B1E9A180E807600497A22 /* watermelon_with_me.js in Resources */, 1A3B1E06180E7D5000497A22 /* script in Resources */, 1A3B1E2B180E7EFA00497A22 /* index.html in Resources */, 1A3B1E31180E7EFA00497A22 /* Platform in Resources */, 1A3B1E33180E7EFA00497A22 /* res in Resources */, 1A3B1E55180E7F1E00497A22 /* Default-568h@2x.png in Resources */, 1A3B1E56180E7F1E00497A22 /* Default.png in Resources */, 1A3B1E57180E7F1E00497A22 /* Default@2x.png in Resources */, 1A3B1E58180E7F1E00497A22 /* Icon-114.png in Resources */, 1A3B1E59180E7F1E00497A22 /* Icon-120.png in Resources */, 1A3B1E5A180E7F1E00497A22 /* Icon-144.png in Resources */, 1A3B1E5B180E7F1E00497A22 /* Icon-152.png in Resources */, 1A3B1E5C180E7F1E00497A22 /* Icon-57.png in Resources */, 1A3B1E5D180E7F1E00497A22 /* Icon-72.png in Resources */, 1A3B1E5E180E7F1E00497A22 /* Icon-76.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18661784C4D600B0CA4A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E19180E7E4E00497A22 /* MoonWarriors-jsb.js in Resources */, 1A3B1DCB180E7C5100497A22 /* Default-568h@2x.png in Resources */, 1A3B1DCC180E7C5100497A22 /* Default.png in Resources */, 1A3B1DCD180E7C5100497A22 /* Default@2x.png in Resources */, 1A3B1DCE180E7C5100497A22 /* Icon-120.png in Resources */, 1A3B1DCF180E7C5100497A22 /* Icon-144.png in Resources */, 1A3B1DD0180E7C5100497A22 /* Icon-152.png in Resources */, 1A3B1DD1180E7C5100497A22 /* Icon-72.png in Resources */, 1A3B1DD2180E7C5100497A22 /* Icon-76.png in Resources */, 1A3B1DD3180E7C5100497A22 /* Icon-Small-50.png in Resources */, 1A3B1DD4180E7C5100497A22 /* Icon-Small.png in Resources */, 1A3B1DD5180E7C5100497A22 /* Icon-Small@2x.png in Resources */, 1A3B1DD6180E7C5100497A22 /* Icon.png in Resources */, 1A3B1DD7180E7C5100497A22 /* Icon@2x.png in Resources */, 1A3B1DFE180E7D2200497A22 /* res in Resources */, 1A3B1E00180E7D2200497A22 /* src in Resources */, 1A3B1E07180E7D5100497A22 /* script in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E189B1784C4DC00B0CA4A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E08180E7D5100497A22 /* script in Resources */, 1A3B1EF4180E826E00497A22 /* Published-iOS in Resources */, 1A3B1F10180E828E00497A22 /* Default-568h@2x.png in Resources */, 1A3B1F11180E828E00497A22 /* Default.png in Resources */, 1A3B1F12180E828E00497A22 /* Default@2x.png in Resources */, 1A3B1F13180E828E00497A22 /* Icon-114.png in Resources */, 1A3B1F14180E828E00497A22 /* Icon-120.png in Resources */, 1A3B1F15180E828E00497A22 /* Icon-144.png in Resources */, 1A3B1F16180E828E00497A22 /* Icon-152.png in Resources */, 1A3B1F17180E828E00497A22 /* Icon-57.png in Resources */, 1A3B1F18180E828E00497A22 /* Icon-72.png in Resources */, 1A3B1F19180E828E00497A22 /* Icon-76.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18D01784C4E000B0CA4A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E09180E7D5200497A22 /* script in Resources */, 1A3B1EB4180E80BD00497A22 /* Default-568h@2x.png in Resources */, 1A3B1EB5180E80BD00497A22 /* Default.png in Resources */, 1A3B1EB6180E80BD00497A22 /* Default@2x.png in Resources */, 1A3B1EB7180E80BD00497A22 /* Icon-114.png in Resources */, 1A3B1EB8180E80BD00497A22 /* Icon-120.png in Resources */, 1A3B1EB9180E80BD00497A22 /* Icon-144.png in Resources */, 1A3B1EBA180E80BD00497A22 /* Icon-152.png in Resources */, 1A3B1EBB180E80BD00497A22 /* Icon-57.png in Resources */, 1A3B1EBC180E80BD00497A22 /* Icon-72.png in Resources */, 1A3B1EBD180E80BD00497A22 /* Icon-76.png in Resources */, 1A3B1ED1180E80E200497A22 /* Published files iOS in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A54F1782290400987F6C /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A2F51B01877DA5900B48BFE /* tests in Resources */, 1A9DC9E5180E6742007A3AD4 /* script in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A7201782301C00987F6C /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E7E180E7FBB00497A22 /* boot-html5.js in Resources */, 1A3B1E7F180E7FBB00497A22 /* boot-jsb.js in Resources */, 1A3B1E80180E7FBB00497A22 /* levels.js in Resources */, 1A3B1E81180E7FBB00497A22 /* main.js in Resources */, 1A3B1E82180E7FBB00497A22 /* resources-html5.js in Resources */, 1A3B1E83180E7FBB00497A22 /* resources-jsb.js in Resources */, 1A3B1E84180E7FBB00497A22 /* watermelon_with_me.js in Resources */, 1A3B1E02180E7D4B00497A22 /* script in Resources */, 1A3B1E2A180E7EFA00497A22 /* index.html in Resources */, 1A3B1E30180E7EFA00497A22 /* Platform in Resources */, 1A3B1E32180E7EFA00497A22 /* res in Resources */, 1A3B1E6A180E7F2400497A22 /* InfoPlist.strings in Resources */, 1A3B1E6B180E7F2400497A22 /* MainMenu.xib in Resources */, 1A3B1E6C180E7F2400497A22 /* Icon.icns in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A9C717823FE100987F6C /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E01180E7D3900497A22 /* MoonWarriors-jsb.js in Resources */, 1A3B1DE3180E7C5C00497A22 /* InfoPlist.strings in Resources */, 1A3B1DE4180E7C5C00497A22 /* MainMenu.xib in Resources */, 1A3B1DE5180E7C5C00497A22 /* Icon.icns in Resources */, 1A3B1DE6180E7C5C00497A22 /* Info.plist in Resources */, 1A3B1DFD180E7D2200497A22 /* res in Resources */, 1A3B1DFF180E7D2200497A22 /* src in Resources */, 1A3B1E03180E7D4B00497A22 /* script in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AA9A1782422400987F6C /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E04180E7D4C00497A22 /* script in Resources */, 1A3B1EF3180E826E00497A22 /* Published-iOS in Resources */, 1A3B1F25180E829600497A22 /* InfoPlist.strings in Resources */, 1A3B1F26180E829600497A22 /* MainMenu.xib in Resources */, 1A3B1F27180E829600497A22 /* Icon.icns in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AC0F1782453000987F6C /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E05180E7D4C00497A22 /* script in Resources */, 1A3B1EC9180E80C700497A22 /* InfoPlist.strings in Resources */, 1A3B1ECA180E80C700497A22 /* MainMenu.xib in Resources */, 1A3B1ECB180E80C700497A22 /* Icon.icns in Resources */, 1A3B1ED0180E80E200497A22 /* Published files iOS in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035ACD9178254A300987F6C /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 460E45D8180801C1000CDD6D /* hd in Resources */, 460E45C9180801A4000CDD6D /* pew-pew-lei.wav in Resources */, 460E45BD180801A4000CDD6D /* Marker Felt.ttf in Resources */, 460E45DB180801C9000CDD6D /* sd in Resources */, 460E45B9180801A4000CDD6D /* background-music-aac.wav in Resources */, 1A9141A1180BEB6A00CFC31F /* InfoPlist.strings in Resources */, 1A9141A2180BEB6A00CFC31F /* MainMenu.xib in Resources */, 1A9141A3180BEB6A00CFC31F /* Icon.icns in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AE5D178255DC00987F6C /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 46A174FC1807D9C4005B8026 /* ipadhd in Resources */, 46A174F41807D9C4005B8026 /* bang.png in Resources */, 46A174FE1807D9C4005B8026 /* iphone in Resources */, 46A174F81807D9C4005B8026 /* fonts in Resources */, 46A174FA1807D9C4005B8026 /* ipad in Resources */, 1A514AFE180FB6470053B876 /* Icon.icns in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A518A1783A1D20073F6A7 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 37C81A071875DF2B00930C57 /* ipadhd in Resources */, 1AAF526B180E2C26000584C8 /* Default-568h@2x.png in Resources */, 1AAF526C180E2C26000584C8 /* Default.png in Resources */, 37C819EF1875DF2B00930C57 /* hd in Resources */, 1AAF526D180E2C26000584C8 /* Default@2x.png in Resources */, 37C819FB1875DF2B00930C57 /* Images in Resources */, 37C819D11875DF2B00930C57 /* effect2.ogg in Resources */, 1AAF526E180E2C26000584C8 /* Icon-100.png in Resources */, 1AAF526F180E2C26000584C8 /* Icon-114.png in Resources */, 1AAF5270180E2C26000584C8 /* Icon-120.png in Resources */, 37C819A11875DF2B00930C57 /* ccb in Resources */, 1AAF5271180E2C26000584C8 /* Icon-144.png in Resources */, 37C819C51875DF2B00930C57 /* effect1.raw in Resources */, 1AAF5272180E2C26000584C8 /* Icon-152.png in Resources */, 37C819E31875DF2B00930C57 /* fonts in Resources */, 37C81A1F1875DF2B00930C57 /* pew-pew-lei.wav in Resources */, 37C81A0D1875DF2B00930C57 /* Misc in Resources */, 1AAF5273180E2C26000584C8 /* Icon-29.png in Resources */, 37C819CB1875DF2B00930C57 /* effect1.wav in Resources */, 37C81A251875DF2B00930C57 /* scenetest in Resources */, 37C8199B1875DF2B00930C57 /* background.ogg in Resources */, 37C819831875DF2B00930C57 /* animations in Resources */, 37C81A3D1875DF2B00930C57 /* zwoptex in Resources */, 37C819DD1875DF2B00930C57 /* fileLookup.plist in Resources */, 37C819BF1875DF2B00930C57 /* configs in Resources */, 1AAF5274180E2C26000584C8 /* Icon-40.png in Resources */, 37C819E91875DF2B00930C57 /* fps_images.png in Resources */, 1AAF5275180E2C26000584C8 /* Icon-50.png in Resources */, 37C819B31875DF2B00930C57 /* cocosgui in Resources */, 37C81A131875DF2B00930C57 /* music.mid in Resources */, 37C8198F1875DF2B00930C57 /* background-music-aac.wav in Resources */, 1AAF5276180E2C26000584C8 /* Icon-57.png in Resources */, 1AAF5277180E2C26000584C8 /* Icon-58.png in Resources */, 37C81A191875DF2B00930C57 /* Particles in Resources */, 37C81A2B1875DF2B00930C57 /* Shaders in Resources */, 1AAF5278180E2C26000584C8 /* Icon-72.png in Resources */, 1AAF5279180E2C26000584C8 /* Icon-76.png in Resources */, 1AAF527A180E2C26000584C8 /* Icon-80.png in Resources */, 37C81A311875DF2B00930C57 /* spine in Resources */, 37C819891875DF2B00930C57 /* armature in Resources */, 37C81A371875DF2B00930C57 /* TileMaps in Resources */, 37C819D71875DF2B00930C57 /* extensions in Resources */, 37C819B91875DF2B00930C57 /* components in Resources */, 37C819951875DF2B00930C57 /* background.mp3 in Resources */, 37C819AD1875DF2B00930C57 /* CocosBuilderExample.ccbresourcelog in Resources */, 37C81A011875DF2B00930C57 /* ipad in Resources */, 37C819F51875DF2B00930C57 /* Hello.png in Resources */, 37C819A71875DF2B00930C57 /* CocosBuilderExample.ccbproj in Resources */, 1AAF527C180E2C26000584C8 /* Test-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A52DA1784AC9B0073F6A7 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 46A174FD1807D9C4005B8026 /* ipadhd in Resources */, 46A174F51807D9C4005B8026 /* bang.png in Resources */, 46A174FF1807D9C4005B8026 /* iphone in Resources */, 5010FC91180F0F8300B8E2AE /* Default-568h@2x.png in Resources */, 46A174F91807D9C4005B8026 /* fonts in Resources */, 46A174FB1807D9C4005B8026 /* ipad in Resources */, 1A514B01180FB66F0053B876 /* Default.png in Resources */, 1A514B02180FB6730053B876 /* Default@2x.png in Resources */, 1A514B03180FB6780053B876 /* Icon-100.png in Resources */, 1A514B04180FB67C0053B876 /* Icon-114.png in Resources */, 1A514B05180FB67C0053B876 /* Icon-120.png in Resources */, 1A514B06180FB67C0053B876 /* Icon-144.png in Resources */, 1A514B07180FB67C0053B876 /* Icon-152.png in Resources */, 1A514B08180FB67C0053B876 /* Icon-40.png in Resources */, 1A514B09180FB67C0053B876 /* Icon-57.png in Resources */, 1A514B0A180FB67C0053B876 /* Icon-58.png in Resources */, 1A514B0B180FB67C0053B876 /* Icon-72.png in Resources */, 1A514B0C180FB67C0053B876 /* Icon-76.png in Resources */, 1A514B0D180FB67C0053B876 /* Icon-80.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 1A1197C31785363400D62A44 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A8C5533180E8B1C00EF57C3 /* AppDelegate.cpp in Sources */, 1A8C554A180E8B3D00EF57C3 /* AppController.mm in Sources */, 1A8C5556180E8B3D00EF57C3 /* main.m in Sources */, 1A8C5557180E8B3D00EF57C3 /* RootViewController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A11985A178538E400D62A44 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A8C5670180E8E9600EF57C3 /* AppDelegate.cpp in Sources */, 1A8C5864180E8F0100EF57C3 /* AppController.mm in Sources */, 1A8C5870180E8F0100EF57C3 /* main.m in Sources */, 1A8C5871180E8F0100EF57C3 /* RootViewController.mm in Sources */, 1585AAC81821F8D900000FB5 /* LuaObjectCBridgeTest.mm in Sources */, 1585AB4C1823A55400000FB5 /* lua_assetsmanager_test_sample.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB55517854FE400CDF010 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A8C5532180E8B1C00EF57C3 /* AppDelegate.cpp in Sources */, 1A8C5565180E8B4500EF57C3 /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1A6FB79E1785614200CDF010 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A8C566F180E8E9600EF57C3 /* AppDelegate.cpp in Sources */, 1585AB181821FF4C00000FB5 /* LuaObjectCBridgeTest.mm in Sources */, 1A8C587F180E8F0C00EF57C3 /* main.cpp in Sources */, 1585AB4B1823A55400000FB5 /* lua_assetsmanager_test_sample.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 1D60588E0D05DD3D006BFB54 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1AAF514A180E2C1A000584C8 /* AccelerometerTest.cpp in Sources */, 1AAF514C180E2C1A000584C8 /* ActionManagerTest.cpp in Sources */, 1AAF514E180E2C1A000584C8 /* ActionsEaseTest.cpp in Sources */, 1AAF5150180E2C1A000584C8 /* ActionsProgressTest.cpp in Sources */, 1AAF5152180E2C1A000584C8 /* ActionsTest.cpp in Sources */, 1AAF5154180E2C1A000584C8 /* AppDelegate.cpp in Sources */, 1AAF5156180E2C1A000584C8 /* BaseTest.cpp in Sources */, 1AAF5158180E2C1A000584C8 /* Box2dTest.cpp in Sources */, 1AAF515A180E2C1A000584C8 /* Box2dView.cpp in Sources */, 1AAF515C180E2C1A000584C8 /* GLES-Render.cpp in Sources */, 1AAF515E180E2C1A000584C8 /* Test.cpp in Sources */, 1AAF5160180E2C1A000584C8 /* TestEntries.cpp in Sources */, 1AAF5162180E2C1A000584C8 /* Bug-1159.cpp in Sources */, 1AAF5164180E2C1A000584C8 /* Bug-1174.cpp in Sources */, 1AAF5166180E2C1A000584C8 /* Bug-350.cpp in Sources */, 1ADCE79B186BCB21001B78A4 /* UILayoutTest.cpp in Sources */, 1AAF5168180E2C1A000584C8 /* Bug-422.cpp in Sources */, 1AAF516A180E2C1A000584C8 /* Bug-458.cpp in Sources */, 50691336184EB453009BBDD7 /* ConsoleTest.cpp in Sources */, 1ADCE79F186BCF19001B78A4 /* UIScrollViewTest.cpp in Sources */, 1ADD146D188D25270034D5EF /* PerformanceEventDispatcherTest.cpp in Sources */, 1ADCE79C186BCB21001B78A4 /* UIListViewTest.cpp in Sources */, 1AAF516C180E2C1A000584C8 /* QuestionContainerSprite.cpp in Sources */, 1AAF516E180E2C1A000584C8 /* Bug-624.cpp in Sources */, 1ADCE79D186BCB21001B78A4 /* UILoadingBarTest.cpp in Sources */, 1AAF5170180E2C1A000584C8 /* Bug-886.cpp in Sources */, 1AAF5172180E2C1A000584C8 /* Bug-899.cpp in Sources */, 1AAF5174180E2C1A000584C8 /* Bug-914.cpp in Sources */, 1AAF5176180E2C1A000584C8 /* BugsTest.cpp in Sources */, 1AAF5178180E2C1A000584C8 /* ChipmunkTest.cpp in Sources */, 1AAF517A180E2C1A000584C8 /* ClickAndMoveTest.cpp in Sources */, 1AAF517C180E2C1A000584C8 /* ClippingNodeTest.cpp in Sources */, 1AAF517E180E2C1A000584C8 /* CocosDenshionTest.cpp in Sources */, 1AAF5180180E2C1A000584C8 /* ConfigurationTest.cpp in Sources */, 1ADCE79E186BCB21001B78A4 /* UIPageViewTest.cpp in Sources */, 1AAF5182180E2C1A000584C8 /* controller.cpp in Sources */, 1AAF5184180E2C1A000584C8 /* CurlTest.cpp in Sources */, 1AAF5186180E2C1A000584C8 /* CurrentLanguageTest.cpp in Sources */, 1AAF5188180E2C1A000584C8 /* DataVisitorTest.cpp in Sources */, 1AAF518A180E2C1A000584C8 /* DrawPrimitivesTest.cpp in Sources */, 1AAF518C180E2C1A000584C8 /* EffectsAdvancedTest.cpp in Sources */, 1AAF518E180E2C1A000584C8 /* EffectsTest.cpp in Sources */, 1AAF5190180E2C1A000584C8 /* AnimationsTestLayer.cpp in Sources */, 37A61460186B21F6007A4638 /* acts.cpp in Sources */, 1AAF5192180E2C1A000584C8 /* ButtonTestLayer.cpp in Sources */, 1AAF5194180E2C1A000584C8 /* CocosBuilderTest.cpp in Sources */, 1AAF5196180E2C1A000584C8 /* HelloCocosBuilderLayer.cpp in Sources */, 4662EB5F188E426300B02E8F /* ReleasePoolTest.cpp in Sources */, 1AAF5198180E2C1A000584C8 /* MenuTestLayer.cpp in Sources */, 1AAF519A180E2C1A000584C8 /* TestHeaderLayer.cpp in Sources */, 1AAF519C180E2C1A000584C8 /* TimelineCallbackTestLayer.cpp in Sources */, 1AAF519E180E2C1A000584C8 /* ArmatureScene.cpp in Sources */, 1AAF51A0180E2C1A000584C8 /* ComponentsTestScene.cpp in Sources */, 1AAF51A2180E2C1A000584C8 /* EnemyController.cpp in Sources */, 1ADCE799186BCB21001B78A4 /* UILabelBMFontTest.cpp in Sources */, 1AAF51A4180E2C1A000584C8 /* GameOverScene.cpp in Sources */, 1AFB0DE31885357A003B2FF3 /* PerformanceContainerTest.cpp in Sources */, 59A79D5D1821E95C00F19697 /* MouseTest.cpp in Sources */, 1AAF51A6180E2C1A000584C8 /* PlayerController.cpp in Sources */, 1ADCE796186BCB20001B78A4 /* UICheckBoxTest.cpp in Sources */, 1AAF51A8180E2C1A000584C8 /* ProjectileController.cpp in Sources */, 1AAF51AA180E2C1A000584C8 /* SceneController.cpp in Sources */, 1ADCE795186BCB20001B78A4 /* UIButtonTest.cpp in Sources */, 1AAF51D4180E2C1A000584C8 /* SceneEditorTest.cpp in Sources */, 1AAF51D6180E2C1A000584C8 /* CCControlButtonTest.cpp in Sources */, 1AAF51D8180E2C1A000584C8 /* CCControlColourPickerTest.cpp in Sources */, 1AAF51DA180E2C1A000584C8 /* CCControlPotentiometerTest.cpp in Sources */, 1AAF51DC180E2C1A000584C8 /* CCControlScene.cpp in Sources */, 1AAF51DE180E2C1A000584C8 /* CCControlSceneManager.cpp in Sources */, 1AAF51E0180E2C1A000584C8 /* CCControlSliderTest.cpp in Sources */, 1AAF51E2180E2C1A000584C8 /* CCControlStepperTest.cpp in Sources */, 1AAF51E4180E2C1A000584C8 /* CCControlSwitchTest.cpp in Sources */, 1ADCE790186BCAB9001B78A4 /* CocosGUIScene.cpp in Sources */, 1AAF51E6180E2C1A000584C8 /* EditBoxTest.cpp in Sources */, 1AAF51E8180E2C1A000584C8 /* ExtensionsTest.cpp in Sources */, 1AAF51EA180E2C1A000584C8 /* HttpClientTest.cpp in Sources */, 1AAF51EC180E2C1A000584C8 /* SocketIOTest.cpp in Sources */, 1AAF51EE180E2C1A000584C8 /* WebSocketTest.cpp in Sources */, 1AAF51F0180E2C1A000584C8 /* NotificationCenterTest.cpp in Sources */, ED3674B9187FA7020038ECFC /* PerformanceRendererTest.cpp in Sources */, 1AAF51F2180E2C1A000584C8 /* Scale9SpriteTest.cpp in Sources */, 1ADCE793186BCAFB001B78A4 /* UIScene.cpp in Sources */, 1AAF51F4180E2C1A000584C8 /* CustomTableViewCell.cpp in Sources */, 1ADCE797186BCB21001B78A4 /* UIImageViewTest.cpp in Sources */, 1AAF51F6180E2C1A000584C8 /* TableViewTestScene.cpp in Sources */, 1AAF51F8180E2C1A000584C8 /* FileUtilsTest.cpp in Sources */, 1AAF51FA180E2C1A000584C8 /* FontTest.cpp in Sources */, 1A087AEE1860418300196EF5 /* PerformanceLabelTest.cpp in Sources */, 1AAF51FC180E2C1A000584C8 /* IntervalTest.cpp in Sources */, 1AAF51FE180E2C1A000584C8 /* KeyboardTest.cpp in Sources */, 1AAF5200180E2C1A000584C8 /* KeypadTest.cpp in Sources */, 1AAF5202180E2C1A000584C8 /* LabelTest.cpp in Sources */, 1AAF5204180E2C1A000584C8 /* LabelTestNew.cpp in Sources */, 1AAF5206180E2C1A000584C8 /* LayerTest.cpp in Sources */, 1AAF5208180E2C1A000584C8 /* MenuTest.cpp in Sources */, 1AAF520A180E2C1A000584C8 /* MotionStreakTest.cpp in Sources */, 1AAF520C180E2C1A000584C8 /* MutiTouchTest.cpp in Sources */, 1A80519718768FD300C117B5 /* UnitTest.cpp in Sources */, 1AAF520E180E2C1A000584C8 /* NewEventDispatcherTest.cpp in Sources */, 1ADCE794186BCAFB001B78A4 /* UISceneManager.cpp in Sources */, 1AAF5210180E2C1A000584C8 /* NodeTest.cpp in Sources */, 1AAF5212180E2C1A000584C8 /* ParallaxTest.cpp in Sources */, 1AAF5214180E2C1A000584C8 /* ParticleTest.cpp in Sources */, 1AAF5216180E2C1A000584C8 /* PerformanceAllocTest.cpp in Sources */, 1AAF5218180E2C1A000584C8 /* PerformanceNodeChildrenTest.cpp in Sources */, 1AAF521A180E2C1A000584C8 /* PerformanceParticleTest.cpp in Sources */, 1AAF521C180E2C1A000584C8 /* PerformanceSpriteTest.cpp in Sources */, 1AAF521E180E2C1A000584C8 /* PerformanceTest.cpp in Sources */, 1AAF5220180E2C1A000584C8 /* PerformanceTextureTest.cpp in Sources */, 1AAF5222180E2C1A000584C8 /* PerformanceTouchesTest.cpp in Sources */, 1AAF5224180E2C1A000584C8 /* PhysicsTest.cpp in Sources */, 599121E6182C74AC00CE785B /* NewRendererTest.cpp in Sources */, 1AAF5226180E2C1A000584C8 /* RenderTextureTest.cpp in Sources */, 1AAF5228180E2C1A000584C8 /* RotateWorldTest.cpp in Sources */, 1AAF522A180E2C1A000584C8 /* SceneTest.cpp in Sources */, 1AAF522C180E2C1A000584C8 /* SchedulerTest.cpp in Sources */, 1ADCE7A0186BCF19001B78A4 /* UISliderTest.cpp in Sources */, 1AAF522E180E2C1A000584C8 /* ShaderTest.cpp in Sources */, 1AAF5230180E2C1A000584C8 /* ShaderTest2.cpp in Sources */, 1ADCE79A186BCB21001B78A4 /* UILabelTest.cpp in Sources */, 1AAF5232180E2C1A000584C8 /* SpineTest.cpp in Sources */, 37A61462186B21F6007A4638 /* cons.cpp in Sources */, 1ADCE7A1186BCF19001B78A4 /* UITextFieldTest.cpp in Sources */, 1AAF5234180E2C1A000584C8 /* SpriteTest.cpp in Sources */, 1AAF5236180E2C1A000584C8 /* testBasic.cpp in Sources */, 1AAF5238180E2C1A000584C8 /* TextInputTest.cpp in Sources */, 1AAF523A180E2C1A000584C8 /* Texture2dTest.cpp in Sources */, 1AAF523C180E2C1A000584C8 /* TextureCacheTest.cpp in Sources */, 1AAF523E180E2C1A000584C8 /* TextureAtlasEncryptionTest.cpp in Sources */, 1AAF5240180E2C1A000584C8 /* TileMapTest.cpp in Sources */, 1AAF5242180E2C1A000584C8 /* Ball.cpp in Sources */, 1AAF5244180E2C1A000584C8 /* Paddle.cpp in Sources */, 1ADCE798186BCB21001B78A4 /* UILabelAtlasTest.cpp in Sources */, 1AAF5246180E2C1A000584C8 /* TouchesTest.cpp in Sources */, 1AAF5248180E2C1A000584C8 /* TransitionsTest.cpp in Sources */, 1AAF524A180E2C1A000584C8 /* UserDefaultTest.cpp in Sources */, 1ADCE7A2186BCF19001B78A4 /* UIWidgetAddNodeTest.cpp in Sources */, 1AAF524C180E2C1A000584C8 /* VisibleRect.cpp in Sources */, 1AAF524E180E2C1A000584C8 /* ZwoptexTest.cpp in Sources */, 1AAF5289180E2C31000584C8 /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E167E1784BDA100B0CA4A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 460E456A1807E767000CDD6D /* RootViewController.mm in Sources */, 460E45691807E767000CDD6D /* AppController.mm in Sources */, 468588DA180805F100AC387D /* main.m in Sources */, 1A6A41E6180BE41100565AC2 /* AppDelegate.cpp in Sources */, 1A6A41E8180BE41100565AC2 /* GameOverScene.cpp in Sources */, 1A6A41EA180BE41100565AC2 /* HelloWorldScene.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E16F51784C06E00B0CA4A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A9DC2A4180E65D4007A3AD4 /* AppDelegate.cpp in Sources */, 1A9DC2C8180E668B007A3AD4 /* AppController.mm in Sources */, 1A9DC2D5180E668B007A3AD4 /* main.m in Sources */, 1A9DC2D6180E668B007A3AD4 /* RootViewController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E183E1784C45400B0CA4A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E41180E7F1500497A22 /* AppDelegate.cpp in Sources */, 1A3B1E54180E7F1E00497A22 /* AppController.mm in Sources */, 1A3B1E60180E7F1E00497A22 /* main.m in Sources */, 1A3B1E61180E7F1E00497A22 /* RootViewController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18731784C4D600B0CA4A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1DB4180E7C4700497A22 /* AppDelegate.cpp in Sources */, 1A3B1DCA180E7C5100497A22 /* AppController.mm in Sources */, 1A3B1DD9180E7C5100497A22 /* main.m in Sources */, 1A3B1DDA180E7C5100497A22 /* RootViewController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18A81784C4DC00B0CA4A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1EFC180E828300497A22 /* AppDelegate.cpp in Sources */, 1A3B1F0F180E828E00497A22 /* AppController.mm in Sources */, 1A3B1F1B180E828E00497A22 /* main.m in Sources */, 1A3B1F1C180E828E00497A22 /* RootViewController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A01E18DD1784C4E000B0CA4A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1EA0180E80B600497A22 /* AppDelegate.cpp in Sources */, 1A3B1EB3180E80BD00497A22 /* AppController.mm in Sources */, 1A3B1EBF180E80BD00497A22 /* main.m in Sources */, 1A3B1EC0180E80BD00497A22 /* RootViewController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A5701782290400987F6C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A9DC2A3180E65D4007A3AD4 /* AppDelegate.cpp in Sources */, 1A9DC2B3180E6681007A3AD4 /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A7661782301C00987F6C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E26180E7EFA00497A22 /* boot-html5.js in Sources */, 1A3B1E28180E7EFA00497A22 /* boot-jsb.js in Sources */, 1A3B1E2C180E7EFA00497A22 /* levels.js in Sources */, 1A3B1E2E180E7EFA00497A22 /* main.js in Sources */, 1A3B1E34180E7EFA00497A22 /* resources-html5.js in Sources */, 1A3B1E36180E7EFA00497A22 /* resources-jsb.js in Sources */, 1A3B1E38180E7EFA00497A22 /* watermelon_with_me.js in Sources */, 1A3B1E40180E7F1500497A22 /* AppDelegate.cpp in Sources */, 1A3B1E6E180E7F2400497A22 /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035A9E017823FE100987F6C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1DB3180E7C4700497A22 /* AppDelegate.cpp in Sources */, 1A3B1DE7180E7C5C00497A22 /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AAAE1782422400987F6C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1EFB180E828300497A22 /* AppDelegate.cpp in Sources */, 1A3B1F29180E829600497A22 /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AC201782453000987F6C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A3B1E9F180E80B600497A22 /* AppDelegate.cpp in Sources */, 1A3B1ECD180E80C700497A22 /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035ACFA178254A300987F6C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1A6A41E7180BE41100565AC2 /* GameOverScene.cpp in Sources */, 1A6A41E9180BE41100565AC2 /* HelloWorldScene.cpp in Sources */, 1A6A41E5180BE41100565AC2 /* AppDelegate.cpp in Sources */, 1A9141A4180BEB6A00CFC31F /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A035AE73178255DC00987F6C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 46A174E81807D96A005B8026 /* HelloWorldScene.cpp in Sources */, 46A174E71807D95B005B8026 /* AppDelegate.cpp in Sources */, 46A175001807D9CB005B8026 /* main.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A51AD1783A1D20073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 1AAF514B180E2C1A000584C8 /* AccelerometerTest.cpp in Sources */, 1AAF514D180E2C1A000584C8 /* ActionManagerTest.cpp in Sources */, 4662EB60188E426300B02E8F /* ReleasePoolTest.cpp in Sources */, 1AAF514F180E2C1A000584C8 /* ActionsEaseTest.cpp in Sources */, 1AAF5151180E2C1A000584C8 /* ActionsProgressTest.cpp in Sources */, 1AAF5153180E2C1A000584C8 /* ActionsTest.cpp in Sources */, 1AAF5155180E2C1A000584C8 /* AppDelegate.cpp in Sources */, 1AAF5157180E2C1A000584C8 /* BaseTest.cpp in Sources */, 1AAF5159180E2C1A000584C8 /* Box2dTest.cpp in Sources */, 1AAF515B180E2C1A000584C8 /* Box2dView.cpp in Sources */, 1AAF515D180E2C1A000584C8 /* GLES-Render.cpp in Sources */, 1A087AEF1860418300196EF5 /* PerformanceLabelTest.cpp in Sources */, 1AAF515F180E2C1A000584C8 /* Test.cpp in Sources */, 50D36105186819DB00828878 /* UIScene.cpp in Sources */, 1AAF5161180E2C1A000584C8 /* TestEntries.cpp in Sources */, 1AAF5163180E2C1A000584C8 /* Bug-1159.cpp in Sources */, 1AAF5165180E2C1A000584C8 /* Bug-1174.cpp in Sources */, 50D36101186819DB00828878 /* UILayoutTest.cpp in Sources */, 1AAF5167180E2C1A000584C8 /* Bug-350.cpp in Sources */, 1AAF5169180E2C1A000584C8 /* Bug-422.cpp in Sources */, 1AAF516B180E2C1A000584C8 /* Bug-458.cpp in Sources */, ED3674BA187FA7020038ECFC /* PerformanceRendererTest.cpp in Sources */, 50D36102186819DB00828878 /* UIListViewTest.cpp in Sources */, 1AAF516D180E2C1A000584C8 /* QuestionContainerSprite.cpp in Sources */, 1AAF516F180E2C1A000584C8 /* Bug-624.cpp in Sources */, 1ADD146E188D25270034D5EF /* PerformanceEventDispatcherTest.cpp in Sources */, 50D36103186819DB00828878 /* UILoadingBarTest.cpp in Sources */, 1AAF5171180E2C1A000584C8 /* Bug-886.cpp in Sources */, 1AAF5173180E2C1A000584C8 /* Bug-899.cpp in Sources */, 1AAF5175180E2C1A000584C8 /* Bug-914.cpp in Sources */, 1AAF5177180E2C1A000584C8 /* BugsTest.cpp in Sources */, 1AAF5179180E2C1A000584C8 /* ChipmunkTest.cpp in Sources */, 1AAF517B180E2C1A000584C8 /* ClickAndMoveTest.cpp in Sources */, 1AAF517D180E2C1A000584C8 /* ClippingNodeTest.cpp in Sources */, 1AAF517F180E2C1A000584C8 /* CocosDenshionTest.cpp in Sources */, 1AAF5181180E2C1A000584C8 /* ConfigurationTest.cpp in Sources */, 50D36104186819DB00828878 /* UIPageViewTest.cpp in Sources */, 1AAF5183180E2C1A000584C8 /* controller.cpp in Sources */, 1AAF5185180E2C1A000584C8 /* CurlTest.cpp in Sources */, 1AAF5187180E2C1A000584C8 /* CurrentLanguageTest.cpp in Sources */, 50D36109186819DB00828878 /* UITextFieldTest.cpp in Sources */, 1AAF5189180E2C1A000584C8 /* DataVisitorTest.cpp in Sources */, 1AAF518B180E2C1A000584C8 /* DrawPrimitivesTest.cpp in Sources */, 1AAF518D180E2C1A000584C8 /* EffectsAdvancedTest.cpp in Sources */, 1AAF518F180E2C1A000584C8 /* EffectsTest.cpp in Sources */, 1AAF5191180E2C1A000584C8 /* AnimationsTestLayer.cpp in Sources */, 37A61461186B21F6007A4638 /* acts.cpp in Sources */, 1AAF5193180E2C1A000584C8 /* ButtonTestLayer.cpp in Sources */, 1AAF5195180E2C1A000584C8 /* CocosBuilderTest.cpp in Sources */, 1AAF5197180E2C1A000584C8 /* HelloCocosBuilderLayer.cpp in Sources */, 1AAF5199180E2C1A000584C8 /* MenuTestLayer.cpp in Sources */, 1AAF519B180E2C1A000584C8 /* TestHeaderLayer.cpp in Sources */, 1AAF519D180E2C1A000584C8 /* TimelineCallbackTestLayer.cpp in Sources */, 50D36108186819DB00828878 /* UISliderTest.cpp in Sources */, 1AAF519F180E2C1A000584C8 /* ArmatureScene.cpp in Sources */, 1AAF51A1180E2C1A000584C8 /* ComponentsTestScene.cpp in Sources */, 1AAF51A3180E2C1A000584C8 /* EnemyController.cpp in Sources */, 50D360FF186819DB00828878 /* UILabelBMFontTest.cpp in Sources */, 1AAF51A5180E2C1A000584C8 /* GameOverScene.cpp in Sources */, 1AAF51A7180E2C1A000584C8 /* PlayerController.cpp in Sources */, 1AAF51A9180E2C1A000584C8 /* ProjectileController.cpp in Sources */, 50D360FC186819DB00828878 /* UICheckBoxTest.cpp in Sources */, 1AAF51AB180E2C1A000584C8 /* SceneController.cpp in Sources */, 50D36107186819DB00828878 /* UIScrollViewTest.cpp in Sources */, 50D360FA186819DB00828878 /* CocosGUIScene.cpp in Sources */, 50D3610A186819DB00828878 /* UIWidgetAddNodeTest.cpp in Sources */, 50D360FB186819DB00828878 /* UIButtonTest.cpp in Sources */, 1AAF51D5180E2C1A000584C8 /* SceneEditorTest.cpp in Sources */, 1AAF51D7180E2C1A000584C8 /* CCControlButtonTest.cpp in Sources */, 1AAF51D9180E2C1A000584C8 /* CCControlColourPickerTest.cpp in Sources */, 1AAF51DB180E2C1A000584C8 /* CCControlPotentiometerTest.cpp in Sources */, 1AAF51DD180E2C1A000584C8 /* CCControlScene.cpp in Sources */, 1AAF51DF180E2C1A000584C8 /* CCControlSceneManager.cpp in Sources */, 1AAF51E1180E2C1A000584C8 /* CCControlSliderTest.cpp in Sources */, 1AAF51E3180E2C1A000584C8 /* CCControlStepperTest.cpp in Sources */, 1AAF51E5180E2C1A000584C8 /* CCControlSwitchTest.cpp in Sources */, 1AAF51E7180E2C1A000584C8 /* EditBoxTest.cpp in Sources */, 1AAF51E9180E2C1A000584C8 /* ExtensionsTest.cpp in Sources */, 1AAF51EB180E2C1A000584C8 /* HttpClientTest.cpp in Sources */, 1AAF51ED180E2C1A000584C8 /* SocketIOTest.cpp in Sources */, 1AAF51EF180E2C1A000584C8 /* WebSocketTest.cpp in Sources */, 1AAF51F1180E2C1A000584C8 /* NotificationCenterTest.cpp in Sources */, 1AAF51F3180E2C1A000584C8 /* Scale9SpriteTest.cpp in Sources */, 50D36106186819DB00828878 /* UISceneManager.cpp in Sources */, 599121E7182C74AC00CE785B /* NewRendererTest.cpp in Sources */, 1AAF51F5180E2C1A000584C8 /* CustomTableViewCell.cpp in Sources */, 1AAF51F7180E2C1A000584C8 /* TableViewTestScene.cpp in Sources */, 50D360FD186819DB00828878 /* UIImageViewTest.cpp in Sources */, 1A80519818768FD300C117B5 /* UnitTest.cpp in Sources */, 1AAF51F9180E2C1A000584C8 /* FileUtilsTest.cpp in Sources */, 1AFB0DE41885357A003B2FF3 /* PerformanceContainerTest.cpp in Sources */, 1AAF51FB180E2C1A000584C8 /* FontTest.cpp in Sources */, 1AAF51FD180E2C1A000584C8 /* IntervalTest.cpp in Sources */, 1AAF51FF180E2C1A000584C8 /* KeyboardTest.cpp in Sources */, 1AAF5201180E2C1A000584C8 /* KeypadTest.cpp in Sources */, 1AAF5203180E2C1A000584C8 /* LabelTest.cpp in Sources */, 1AAF5205180E2C1A000584C8 /* LabelTestNew.cpp in Sources */, 1AAF5207180E2C1A000584C8 /* LayerTest.cpp in Sources */, 1AAF5209180E2C1A000584C8 /* MenuTest.cpp in Sources */, 1AAF520B180E2C1A000584C8 /* MotionStreakTest.cpp in Sources */, 1AAF520D180E2C1A000584C8 /* MutiTouchTest.cpp in Sources */, 1AAF520F180E2C1A000584C8 /* NewEventDispatcherTest.cpp in Sources */, 1AAF5211180E2C1A000584C8 /* NodeTest.cpp in Sources */, 1AAF5213180E2C1A000584C8 /* ParallaxTest.cpp in Sources */, 1AAF5215180E2C1A000584C8 /* ParticleTest.cpp in Sources */, 1AAF5217180E2C1A000584C8 /* PerformanceAllocTest.cpp in Sources */, 1AAF5219180E2C1A000584C8 /* PerformanceNodeChildrenTest.cpp in Sources */, 1AAF521B180E2C1A000584C8 /* PerformanceParticleTest.cpp in Sources */, 37A61463186B21F6007A4638 /* cons.cpp in Sources */, 1AAF521D180E2C1A000584C8 /* PerformanceSpriteTest.cpp in Sources */, 59A79D5E1821E95C00F19697 /* MouseTest.cpp in Sources */, 50691337184EB453009BBDD7 /* ConsoleTest.cpp in Sources */, 1AAF521F180E2C1A000584C8 /* PerformanceTest.cpp in Sources */, 1AAF5221180E2C1A000584C8 /* PerformanceTextureTest.cpp in Sources */, 1AAF5223180E2C1A000584C8 /* PerformanceTouchesTest.cpp in Sources */, 1AAF5225180E2C1A000584C8 /* PhysicsTest.cpp in Sources */, 1AAF5227180E2C1A000584C8 /* RenderTextureTest.cpp in Sources */, 1AAF5229180E2C1A000584C8 /* RotateWorldTest.cpp in Sources */, 1AAF522B180E2C1A000584C8 /* SceneTest.cpp in Sources */, 1AAF522D180E2C1A000584C8 /* SchedulerTest.cpp in Sources */, 1AAF522F180E2C1A000584C8 /* ShaderTest.cpp in Sources */, 1AAF5231180E2C1A000584C8 /* ShaderTest2.cpp in Sources */, 1AAF5233180E2C1A000584C8 /* SpineTest.cpp in Sources */, 1AAF5235180E2C1A000584C8 /* SpriteTest.cpp in Sources */, 50D36100186819DB00828878 /* UILabelTest.cpp in Sources */, 1AAF5237180E2C1A000584C8 /* testBasic.cpp in Sources */, 1AAF5239180E2C1A000584C8 /* TextInputTest.cpp in Sources */, 1AAF523B180E2C1A000584C8 /* Texture2dTest.cpp in Sources */, 1AAF523D180E2C1A000584C8 /* TextureCacheTest.cpp in Sources */, 1AAF523F180E2C1A000584C8 /* TextureAtlasEncryptionTest.cpp in Sources */, 1AAF5241180E2C1A000584C8 /* TileMapTest.cpp in Sources */, 1AAF5243180E2C1A000584C8 /* Ball.cpp in Sources */, 1AAF5245180E2C1A000584C8 /* Paddle.cpp in Sources */, 1AAF5247180E2C1A000584C8 /* TouchesTest.cpp in Sources */, 1AAF5249180E2C1A000584C8 /* TransitionsTest.cpp in Sources */, 50D360FE186819DB00828878 /* UILabelAtlasTest.cpp in Sources */, 1AAF524B180E2C1A000584C8 /* UserDefaultTest.cpp in Sources */, 1AAF524D180E2C1A000584C8 /* VisibleRect.cpp in Sources */, 1AAF524F180E2C1A000584C8 /* ZwoptexTest.cpp in Sources */, 1AAF5269180E2C26000584C8 /* RootViewController.mm in Sources */, 1AAF526A180E2C26000584C8 /* testsAppDelegate.mm in Sources */, 1AAF527B180E2C26000584C8 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; A07A53041784AC9B0073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 46A175011807D9E2005B8026 /* AppController.mm in Sources */, 46A175031807D9E2005B8026 /* RootViewController.mm in Sources */, 46A174EA1807D976005B8026 /* HelloWorldScene.cpp in Sources */, 46A175021807D9E2005B8026 /* main.m in Sources */, 46A174E91807D976005B8026 /* AppDelegate.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 1A3B1DE9180E7C9C00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 1A3B1DE8180E7C9C00497A22 /* PBXContainerItemProxy */; }; 1A3B1DEB180E7C9C00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions Mac"; targetProxy = 1A3B1DEA180E7C9C00497A22 /* PBXContainerItemProxy */; }; 1A3B1DED180E7C9C00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk Mac"; targetProxy = 1A3B1DEC180E7C9C00497A22 /* PBXContainerItemProxy */; }; 1A3B1DEF180E7C9C00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 1A3B1DEE180E7C9C00497A22 /* PBXContainerItemProxy */; }; 1A3B1DF1180E7C9C00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings Mac"; targetProxy = 1A3B1DF0180E7C9C00497A22 /* PBXContainerItemProxy */; }; 1A3B1E0B180E7E1D00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 1A3B1E0A180E7E1D00497A22 /* PBXContainerItemProxy */; }; 1A3B1E0D180E7E1D00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions iOS"; targetProxy = 1A3B1E0C180E7E1D00497A22 /* PBXContainerItemProxy */; }; 1A3B1E0F180E7E1D00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk iOS"; targetProxy = 1A3B1E0E180E7E1D00497A22 /* PBXContainerItemProxy */; }; 1A3B1E11180E7E1D00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 1A3B1E10180E7E1D00497A22 /* PBXContainerItemProxy */; }; 1A3B1E13180E7E1D00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings iOS"; targetProxy = 1A3B1E12180E7E1D00497A22 /* PBXContainerItemProxy */; }; 1A3B1E70180E7F3E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 1A3B1E6F180E7F3E00497A22 /* PBXContainerItemProxy */; }; 1A3B1E72180E7F3E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions Mac"; targetProxy = 1A3B1E71180E7F3E00497A22 /* PBXContainerItemProxy */; }; 1A3B1E74180E7F3E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk Mac"; targetProxy = 1A3B1E73180E7F3E00497A22 /* PBXContainerItemProxy */; }; 1A3B1E76180E7F3E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 1A3B1E75180E7F3E00497A22 /* PBXContainerItemProxy */; }; 1A3B1E78180E7F3E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings Mac"; targetProxy = 1A3B1E77180E7F3E00497A22 /* PBXContainerItemProxy */; }; 1A3B1E86180E804400497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 1A3B1E85180E804400497A22 /* PBXContainerItemProxy */; }; 1A3B1E88180E804400497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions iOS"; targetProxy = 1A3B1E87180E804400497A22 /* PBXContainerItemProxy */; }; 1A3B1E8A180E804400497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk iOS"; targetProxy = 1A3B1E89180E804400497A22 /* PBXContainerItemProxy */; }; 1A3B1E8C180E804400497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 1A3B1E8B180E804400497A22 /* PBXContainerItemProxy */; }; 1A3B1E8E180E804400497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings iOS"; targetProxy = 1A3B1E8D180E804400497A22 /* PBXContainerItemProxy */; }; 1A3B1ED3180E810E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 1A3B1ED2180E810E00497A22 /* PBXContainerItemProxy */; }; 1A3B1ED5180E810E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions Mac"; targetProxy = 1A3B1ED4180E810E00497A22 /* PBXContainerItemProxy */; }; 1A3B1ED7180E810E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk Mac"; targetProxy = 1A3B1ED6180E810E00497A22 /* PBXContainerItemProxy */; }; 1A3B1ED9180E810E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 1A3B1ED8180E810E00497A22 /* PBXContainerItemProxy */; }; 1A3B1EDB180E810E00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings Mac"; targetProxy = 1A3B1EDA180E810E00497A22 /* PBXContainerItemProxy */; }; 1A3B1EE2180E81AA00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 1A3B1EE1180E81AA00497A22 /* PBXContainerItemProxy */; }; 1A3B1EE4180E81AA00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions iOS"; targetProxy = 1A3B1EE3180E81AA00497A22 /* PBXContainerItemProxy */; }; 1A3B1EE6180E81AA00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk iOS"; targetProxy = 1A3B1EE5180E81AA00497A22 /* PBXContainerItemProxy */; }; 1A3B1EE8180E81AA00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 1A3B1EE7180E81AA00497A22 /* PBXContainerItemProxy */; }; 1A3B1EEA180E81AA00497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings iOS"; targetProxy = 1A3B1EE9180E81AA00497A22 /* PBXContainerItemProxy */; }; 1A3B1F2B180E82B800497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 1A3B1F2A180E82B800497A22 /* PBXContainerItemProxy */; }; 1A3B1F2D180E82B800497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions Mac"; targetProxy = 1A3B1F2C180E82B800497A22 /* PBXContainerItemProxy */; }; 1A3B1F2F180E82B800497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk Mac"; targetProxy = 1A3B1F2E180E82B800497A22 /* PBXContainerItemProxy */; }; 1A3B1F31180E82B800497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 1A3B1F30180E82B800497A22 /* PBXContainerItemProxy */; }; 1A3B1F33180E82B800497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings Mac"; targetProxy = 1A3B1F32180E82B800497A22 /* PBXContainerItemProxy */; }; 1A3B1F3A180E82D200497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 1A3B1F39180E82D200497A22 /* PBXContainerItemProxy */; }; 1A3B1F3C180E82D200497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions iOS"; targetProxy = 1A3B1F3B180E82D200497A22 /* PBXContainerItemProxy */; }; 1A3B1F3E180E82D200497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk iOS"; targetProxy = 1A3B1F3D180E82D200497A22 /* PBXContainerItemProxy */; }; 1A3B1F40180E82D200497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 1A3B1F3F180E82D200497A22 /* PBXContainerItemProxy */; }; 1A3B1F42180E82D200497A22 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings iOS"; targetProxy = 1A3B1F41180E82D200497A22 /* PBXContainerItemProxy */; }; 1A6FB50117854AEA00CDF010 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1A1197B31785363400D62A44 /* Hello lua iOS */; targetProxy = 1A6FB50017854AEA00CDF010 /* PBXContainerItemProxy */; }; 1A6FB50317854AEA00CDF010 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1A11982D178538E400D62A44 /* Test lua iOS */; targetProxy = 1A6FB50217854AEA00CDF010 /* PBXContainerItemProxy */; }; 1A6FB7E31785682700CDF010 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1A6FB53517854FE400CDF010 /* Hello lua Mac */; targetProxy = 1A6FB7E21785682700CDF010 /* PBXContainerItemProxy */; }; 1A6FB7E51785682700CDF010 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1A6FB7821785614200CDF010 /* Test lua Mac */; targetProxy = 1A6FB7E41785682700CDF010 /* PBXContainerItemProxy */; }; 1A8C55BB180E8BA400EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 1A8C55BA180E8BA400EF57C3 /* PBXContainerItemProxy */; }; 1A8C55BD180E8BA400EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions Mac"; targetProxy = 1A8C55BC180E8BA400EF57C3 /* PBXContainerItemProxy */; }; 1A8C55BF180E8BA400EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk Mac"; targetProxy = 1A8C55BE180E8BA400EF57C3 /* PBXContainerItemProxy */; }; 1A8C55C1180E8BA400EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 1A8C55C0180E8BA400EF57C3 /* PBXContainerItemProxy */; }; 1A8C55C3180E8BA400EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "luabindings Mac"; targetProxy = 1A8C55C2180E8BA400EF57C3 /* PBXContainerItemProxy */; }; 1A8C565D180E8DFB00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 1A8C565C180E8DFB00EF57C3 /* PBXContainerItemProxy */; }; 1A8C565F180E8DFB00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions iOS"; targetProxy = 1A8C565E180E8DFB00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5661180E8DFB00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk iOS"; targetProxy = 1A8C5660180E8DFB00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5663180E8DFB00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 1A8C5662180E8DFB00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5665180E8DFB00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "luabindings iOS"; targetProxy = 1A8C5664180E8DFB00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5881180E8F5F00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 1A8C5880180E8F5F00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5883180E8F5F00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions Mac"; targetProxy = 1A8C5882180E8F5F00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5885180E8F5F00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk Mac"; targetProxy = 1A8C5884180E8F5F00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5887180E8F5F00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 1A8C5886180E8F5F00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5889180E8F5F00EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "luabindings Mac"; targetProxy = 1A8C5888180E8F5F00EF57C3 /* PBXContainerItemProxy */; }; 1A8C5890180E8F8000EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 1A8C588F180E8F8000EF57C3 /* PBXContainerItemProxy */; }; 1A8C5892180E8F8000EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions iOS"; targetProxy = 1A8C5891180E8F8000EF57C3 /* PBXContainerItemProxy */; }; 1A8C5894180E8F8000EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk iOS"; targetProxy = 1A8C5893180E8F8000EF57C3 /* PBXContainerItemProxy */; }; 1A8C5896180E8F8000EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 1A8C5895180E8F8000EF57C3 /* PBXContainerItemProxy */; }; 1A8C5898180E8F8000EF57C3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "luabindings iOS"; targetProxy = 1A8C5897180E8F8000EF57C3 /* PBXContainerItemProxy */; }; 1A9DC9E8180E68CE007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 1A9DC9E7180E68CE007A3AD4 /* PBXContainerItemProxy */; }; 1A9DC9EA180E68CE007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions Mac"; targetProxy = 1A9DC9E9180E68CE007A3AD4 /* PBXContainerItemProxy */; }; 1A9DC9EC180E68CE007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk Mac"; targetProxy = 1A9DC9EB180E68CE007A3AD4 /* PBXContainerItemProxy */; }; 1A9DC9EE180E68CE007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 1A9DC9ED180E68CE007A3AD4 /* PBXContainerItemProxy */; }; 1A9DC9F0180E68CE007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings Mac"; targetProxy = 1A9DC9EF180E68CE007A3AD4 /* PBXContainerItemProxy */; }; 1A9DCA57180E743F007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 1A9DCA56180E743F007A3AD4 /* PBXContainerItemProxy */; }; 1A9DCA59180E743F007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions iOS"; targetProxy = 1A9DCA58180E743F007A3AD4 /* PBXContainerItemProxy */; }; 1A9DCA5B180E743F007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk iOS"; targetProxy = 1A9DCA5A180E743F007A3AD4 /* PBXContainerItemProxy */; }; 1A9DCA5D180E743F007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 1A9DCA5C180E743F007A3AD4 /* PBXContainerItemProxy */; }; 1A9DCA5F180E743F007A3AD4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "jsbindings iOS"; targetProxy = 1A9DCA5E180E743F007A3AD4 /* PBXContainerItemProxy */; }; 1AAF5342180E2F41000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 1AAF5341180E2F41000584C8 /* PBXContainerItemProxy */; }; 1AAF5344180E2F41000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions Mac"; targetProxy = 1AAF5343180E2F41000584C8 /* PBXContainerItemProxy */; }; 1AAF5346180E2F41000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk Mac"; targetProxy = 1AAF5345180E2F41000584C8 /* PBXContainerItemProxy */; }; 1AAF5348180E2F41000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "box2d Mac"; targetProxy = 1AAF5347180E2F41000584C8 /* PBXContainerItemProxy */; }; 1AAF534A180E2F41000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 1AAF5349180E2F41000584C8 /* PBXContainerItemProxy */; }; 1AAF53F5180E39C6000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 1AAF53F4180E39C6000584C8 /* PBXContainerItemProxy */; }; 1AAF53F7180E39C6000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx-extensions iOS"; targetProxy = 1AAF53F6180E39C6000584C8 /* PBXContainerItemProxy */; }; 1AAF53F9180E39C6000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "chipmunk iOS"; targetProxy = 1AAF53F8180E39C6000584C8 /* PBXContainerItemProxy */; }; 1AAF53FB180E39C6000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "box2d iOS"; targetProxy = 1AAF53FA180E39C6000584C8 /* PBXContainerItemProxy */; }; 1AAF53FD180E39C6000584C8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 1AAF53FC180E39C6000584C8 /* PBXContainerItemProxy */; }; 460E44BA1807DCCC000CDD6D /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 460E44B91807DCCC000CDD6D /* PBXContainerItemProxy */; }; 460E44FC1807E408000CDD6D /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 460E44FB1807E408000CDD6D /* PBXContainerItemProxy */; }; 460E44FF1807E656000CDD6D /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx iOS"; targetProxy = 460E44FE1807E656000CDD6D /* PBXContainerItemProxy */; }; 460E45831807FDB0000CDD6D /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "cocos2dx Mac"; targetProxy = 460E45821807FDB0000CDD6D /* PBXContainerItemProxy */; }; 460E45851807FDB0000CDD6D /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion Mac"; targetProxy = 460E45841807FDB0000CDD6D /* PBXContainerItemProxy */; }; 460E45DE18080218000CDD6D /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "CocosDenshion iOS"; targetProxy = 460E45DD18080218000CDD6D /* PBXContainerItemProxy */; }; A01E17E21784C3EB00B0CA4A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A52CF1784AC9B0073F6A7 /* Hello cpp iOS */; targetProxy = A01E17E11784C3EB00B0CA4A /* PBXContainerItemProxy */; }; A01E17E41784C3EB00B0CA4A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A01E16631784BDA100B0CA4A /* Simple Game iOS */; targetProxy = A01E17E31784C3EB00B0CA4A /* PBXContainerItemProxy */; }; A01E17E61784C3EB00B0CA4A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A01E16C01784C06E00B0CA4A /* Test JavaScript iOS */; targetProxy = A01E17E51784C3EB00B0CA4A /* PBXContainerItemProxy */; }; A01E19971784C8DD00B0CA4A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A01E17E71784C45400B0CA4A /* JS Watermelon With Me iOS */; targetProxy = A01E19961784C8DD00B0CA4A /* PBXContainerItemProxy */; }; A01E19991784C8DD00B0CA4A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A01E18591784C4D600B0CA4A /* JS Moon Warriors iOS */; targetProxy = A01E19981784C8DD00B0CA4A /* PBXContainerItemProxy */; }; A01E199B1784C8DD00B0CA4A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A01E188E1784C4DC00B0CA4A /* JS Crystal Craze iOS */; targetProxy = A01E199A1784C8DD00B0CA4A /* PBXContainerItemProxy */; }; A01E199D1784C8DD00B0CA4A /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A01E18C31784C4E000B0CA4A /* JS CocosDragon iOS */; targetProxy = A01E199C1784C8DD00B0CA4A /* PBXContainerItemProxy */; }; A035ACC0178246BD00987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1D6058900D05DD3D006BFB54 /* Test cpp Mac */; targetProxy = A035ACBF178246BD00987F6C /* PBXContainerItemProxy */; }; A035ACC2178246BD00987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A035A5441782290400987F6C /* Test JavaScript Mac */; targetProxy = A035ACC1178246BD00987F6C /* PBXContainerItemProxy */; }; A035ACC4178246BD00987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A035A7131782301C00987F6C /* JS Watermelon With Me Mac */; targetProxy = A035ACC3178246BD00987F6C /* PBXContainerItemProxy */; }; A035ACC6178246BD00987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A035A9BA17823FE100987F6C /* JS Moon Warriors Mac */; targetProxy = A035ACC5178246BD00987F6C /* PBXContainerItemProxy */; }; A035ACC8178246BD00987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A035AA8D1782422400987F6C /* JS Crystal Craze Mac */; targetProxy = A035ACC7178246BD00987F6C /* PBXContainerItemProxy */; }; A035ACCA178246BD00987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A035AC021782453000987F6C /* JS CocosDragon Mac */; targetProxy = A035ACC9178246BD00987F6C /* PBXContainerItemProxy */; }; A035AF731782569500987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A035AE58178255DC00987F6C /* Hello cpp Mac */; targetProxy = A035AF721782569500987F6C /* PBXContainerItemProxy */; }; A035AF751782569500987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A035ACCE178254A300987F6C /* Simple Game Mac */; targetProxy = A035AF741782569500987F6C /* PBXContainerItemProxy */; }; A07A526D1783AB980073F6A7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = A07A517F1783A1D20073F6A7 /* Test cpp iOS */; targetProxy = A07A526C1783AB980073F6A7 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 1A3B1DDC180E7C5C00497A22 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1A3B1DDD180E7C5C00497A22 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1A3B1DDE180E7C5C00497A22 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1A3B1DDF180E7C5C00497A22 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 1A3B1E63180E7F2400497A22 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1A3B1E64180E7F2400497A22 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1A3B1E65180E7F2400497A22 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1A3B1E66180E7F2400497A22 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 1A3B1EC2180E80C700497A22 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1A3B1EC3180E80C700497A22 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1A3B1EC4180E80C700497A22 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1A3B1EC5180E80C700497A22 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 1A3B1F1E180E829600497A22 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1A3B1F1F180E829600497A22 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1A3B1F20180E829600497A22 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1A3B1F21180E829600497A22 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 1A8C5559180E8B4500EF57C3 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1A8C555A180E8B4500EF57C3 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1A8C555B180E8B4500EF57C3 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1A8C555C180E8B4500EF57C3 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 1A8C5873180E8F0C00EF57C3 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1A8C5874180E8F0C00EF57C3 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1A8C5875180E8F0C00EF57C3 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1A8C5876180E8F0C00EF57C3 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 1A91419A180BEB6A00CFC31F /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1A91419B180BEB6A00CFC31F /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1A91419C180BEB6A00CFC31F /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1A91419D180BEB6A00CFC31F /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 1A9DC2A6180E6681007A3AD4 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1A9DC2A7180E6681007A3AD4 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1A9DC2A8180E6681007A3AD4 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1A9DC2A9180E6681007A3AD4 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 1AAF527E180E2C31000584C8 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 1AAF527F180E2C31000584C8 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 1AAF5280180E2C31000584C8 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 1AAF5281180E2C31000584C8 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; 46A174C61807D934005B8026 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( 46A174C71807D934005B8026 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; 46A174C81807D934005B8026 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( 46A174C91807D934005B8026 /* en */, ); name = MainMenu.xib; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 1A1197D51785363400D62A44 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Lua/HelloLua/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/lua/bindings $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; }; name = Debug; }; 1A1197D61785363400D62A44 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Lua/HelloLua/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/lua/bindings $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; VALIDATE_PRODUCT = YES; }; name = Release; }; 1A11986E178538E400D62A44 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Lua/TestLua/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/lua/bindings $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; }; name = Debug; }; 1A11986F178538E400D62A44 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Lua/TestLua/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/lua/bindings $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; VALIDATE_PRODUCT = YES; }; name = Release; }; 1A6FB56917854FE400CDF010 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Lua/HelloLua/proj.mac/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = ""; "OTHER_LDFLAGS[arch=x86_64]" = ( "-pagezero_size", 10000, "-image_base", 100000000, ); SDKROOT = macosx; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/lua/bindings $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; }; name = Debug; }; 1A6FB56A17854FE400CDF010 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Lua/HelloLua/proj.mac/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = ""; "OTHER_LDFLAGS[arch=x86_64]" = ( "-pagezero_size", 10000, "-image_base", 100000000, ); SDKROOT = macosx; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/lua/bindings $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; VALIDATE_PRODUCT = YES; }; name = Release; }; 1A6FB7B11785614200CDF010 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Lua/TestLua/proj.mac/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = ""; "OTHER_LDFLAGS[arch=x86_64]" = ( "-pagezero_size", 10000, "-image_base", 100000000, ); SDKROOT = macosx; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/lua/bindings $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; }; name = Debug; }; 1A6FB7B21785614200CDF010 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Lua/TestLua/proj.mac/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = ""; "OTHER_LDFLAGS[arch=x86_64]" = ( "-pagezero_size", 10000, "-image_base", 100000000, ); SDKROOT = macosx; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/lua/bindings $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua"; VALIDATE_PRODUCT = YES; }; name = Release; }; 1D6058940D05DD3E006BFB54 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Cpp/TestCpp/proj.mac/Test_Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; 1D6058950D05DD3E006BFB54 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Cpp/TestCpp/proj.mac/Test_Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; VALIDATE_PRODUCT = YES; }; name = Release; }; A01E16911784BDA100B0CA4A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = "../samples/Cpp/SimpleGame/proj.ios/SimpleGame-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios"; }; name = Debug; }; A01E16921784BDA100B0CA4A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = "../samples/Cpp/SimpleGame/proj.ios/SimpleGame-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios"; VALIDATE_PRODUCT = YES; }; name = Release; }; A01E17701784C06E00B0CA4A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/TestJavascript/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; }; name = Debug; }; A01E17711784C06E00B0CA4A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/TestJavascript/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; VALIDATE_PRODUCT = YES; }; name = Release; }; A01E18551784C45400B0CA4A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/WatermelonWithMe/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; }; name = Debug; }; A01E18561784C45400B0CA4A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/WatermelonWithMe/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; VALIDATE_PRODUCT = YES; }; name = Release; }; A01E188A1784C4D600B0CA4A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/MoonWarriors/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; }; name = Debug; }; A01E188B1784C4D600B0CA4A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/MoonWarriors/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; VALIDATE_PRODUCT = YES; }; name = Release; }; A01E18BF1784C4DC00B0CA4A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/CrystalCraze/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; }; name = Debug; }; A01E18C01784C4DC00B0CA4A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/CrystalCraze/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; VALIDATE_PRODUCT = YES; }; name = Release; }; A01E18F41784C4E000B0CA4A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/CocosDragonJS/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; }; name = Debug; }; A01E18F51784C4E000B0CA4A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, COCOS2D_JAVASCRIPT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/CocosDragonJS/proj.ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/ios"; VALIDATE_PRODUCT = YES; }; name = Release; }; A035A5EA1782290400987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/TestJavascript/proj.mac/Test_Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A035A5EB1782290400987F6C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/TestJavascript/proj.mac/Test_Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; VALIDATE_PRODUCT = YES; }; name = Release; }; A035A77B1782301C00987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/WatermelonWithMe/proj.mac/Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A035A77C1782301C00987F6C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/WatermelonWithMe/proj.mac/Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; VALIDATE_PRODUCT = YES; }; name = Release; }; A035A9F517823FE100987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/MoonWarriors/proj.mac/Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A035A9F617823FE100987F6C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/MoonWarriors/proj.mac/Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; VALIDATE_PRODUCT = YES; }; name = Release; }; A035AAC31782422400987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/CrystalCraze/proj.mac/Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A035AAC41782422400987F6C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/CrystalCraze/proj.mac/Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; VALIDATE_PRODUCT = YES; }; name = Release; }; A035AC351782453000987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/CocosDragonJS/proj.mac/Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A035AC361782453000987F6C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", COCOS2D_JAVASCRIPT, CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Javascript/CocosDragonJS/proj.mac/Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../cocos/scripting/javascript/bindings $(SRCROOT)/../cocos/scripting/auto-generated/js-bindings $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/../external/glfw3/include/mac"; VALIDATE_PRODUCT = YES; }; name = Release; }; A035ACBD1782469800987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { HEADER_SEARCH_PATHS = ""; }; name = Debug; }; A035ACBE1782469800987F6C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { HEADER_SEARCH_PATHS = ""; }; name = Release; }; A035AD74178254A300987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Cpp/SimpleGame/proj.mac/SampleGame_Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A035AD75178254A300987F6C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Cpp/SimpleGame/proj.mac/SampleGame_Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; VALIDATE_PRODUCT = YES; }; name = Release; }; A035AE86178255DC00987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Cpp/HelloCpp/proj.mac/HelloCpp_Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; }; name = Debug; }; A035AE87178255DC00987F6C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ../samples/Cpp/HelloCpp/proj.mac/HelloCpp_Info.plist; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac"; VALIDATE_PRODUCT = YES; }; name = Release; }; A07A517D1783A1CC0073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; COMPRESS_PNG_FILES = NO; SDKROOT = iphoneos; }; name = Debug; }; A07A517E1783A1CC0073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; COMPRESS_PNG_FILES = NO; SDKROOT = iphoneos; }; name = Release; }; A07A52271783A1D20073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = "../samples/Cpp/TestCpp/proj.ios/Test-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; LIBRARY_SEARCH_PATHS = "$(inherited)"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/2d/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios"; }; name = Debug; }; A07A52281783A1D20073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = "../samples/Cpp/TestCpp/proj.ios/Test-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; LIBRARY_SEARCH_PATHS = "$(inherited)"; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/2d/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios"; VALIDATE_PRODUCT = YES; }; name = Release; }; A07A537F1784AC9B0073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = "../samples/Cpp/HelloCpp/proj.ios/HelloCpp-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios"; }; name = Debug; }; A07A53801784AC9B0073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", CC_TARGET_OS_IPHONE, ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = "../samples/Cpp/HelloCpp/proj.ios/HelloCpp-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios"; VALIDATE_PRODUCT = YES; }; name = Release; }; C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = c99; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", ); GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath/include $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk"; }; name = Debug; }; C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = c99; GCC_PREPROCESSOR_DEFINITIONS = ( NDEBUG, USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", ); GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath/include $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 1A1197D41785363400D62A44 /* Build configuration list for PBXNativeTarget "Hello lua iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 1A1197D51785363400D62A44 /* Debug */, 1A1197D61785363400D62A44 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; 1A11986D178538E400D62A44 /* Build configuration list for PBXNativeTarget "Test lua iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 1A11986E178538E400D62A44 /* Debug */, 1A11986F178538E400D62A44 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; 1A6FB56817854FE400CDF010 /* Build configuration list for PBXNativeTarget "Hello lua Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( 1A6FB56917854FE400CDF010 /* Debug */, 1A6FB56A17854FE400CDF010 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; 1A6FB7B01785614200CDF010 /* Build configuration list for PBXNativeTarget "Test lua Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( 1A6FB7B11785614200CDF010 /* Debug */, 1A6FB7B21785614200CDF010 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Test cpp Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( 1D6058940D05DD3E006BFB54 /* Debug */, 1D6058950D05DD3E006BFB54 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A01E16901784BDA100B0CA4A /* Build configuration list for PBXNativeTarget "Simple Game iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A01E16911784BDA100B0CA4A /* Debug */, A01E16921784BDA100B0CA4A /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A01E176F1784C06E00B0CA4A /* Build configuration list for PBXNativeTarget "Test JavaScript iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A01E17701784C06E00B0CA4A /* Debug */, A01E17711784C06E00B0CA4A /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A01E18541784C45400B0CA4A /* Build configuration list for PBXNativeTarget "JS Watermelon With Me iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A01E18551784C45400B0CA4A /* Debug */, A01E18561784C45400B0CA4A /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A01E18891784C4D600B0CA4A /* Build configuration list for PBXNativeTarget "JS Moon Warriors iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A01E188A1784C4D600B0CA4A /* Debug */, A01E188B1784C4D600B0CA4A /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A01E18BE1784C4DC00B0CA4A /* Build configuration list for PBXNativeTarget "JS Crystal Craze iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A01E18BF1784C4DC00B0CA4A /* Debug */, A01E18C01784C4DC00B0CA4A /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A01E18F31784C4E000B0CA4A /* Build configuration list for PBXNativeTarget "JS CocosDragon iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A01E18F41784C4E000B0CA4A /* Debug */, A01E18F51784C4E000B0CA4A /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A035A5E91782290400987F6C /* Build configuration list for PBXNativeTarget "Test JavaScript Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A035A5EA1782290400987F6C /* Debug */, A035A5EB1782290400987F6C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A035A77A1782301C00987F6C /* Build configuration list for PBXNativeTarget "JS Watermelon With Me Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A035A77B1782301C00987F6C /* Debug */, A035A77C1782301C00987F6C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A035A9F417823FE100987F6C /* Build configuration list for PBXNativeTarget "JS Moon Warriors Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A035A9F517823FE100987F6C /* Debug */, A035A9F617823FE100987F6C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A035AAC21782422400987F6C /* Build configuration list for PBXNativeTarget "JS Crystal Craze Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A035AAC31782422400987F6C /* Debug */, A035AAC41782422400987F6C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A035AC341782453000987F6C /* Build configuration list for PBXNativeTarget "JS CocosDragon Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A035AC351782453000987F6C /* Debug */, A035AC361782453000987F6C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A035ACBC1782469800987F6C /* Build configuration list for PBXAggregateTarget "build-all-samples Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A035ACBD1782469800987F6C /* Debug */, A035ACBE1782469800987F6C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A035AD73178254A300987F6C /* Build configuration list for PBXNativeTarget "Simple Game Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A035AD74178254A300987F6C /* Debug */, A035AD75178254A300987F6C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A035AE85178255DC00987F6C /* Build configuration list for PBXNativeTarget "Hello cpp Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( A035AE86178255DC00987F6C /* Debug */, A035AE87178255DC00987F6C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A07A517C1783A1CC0073F6A7 /* Build configuration list for PBXAggregateTarget "build-all-samples iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A517D1783A1CC0073F6A7 /* Debug */, A07A517E1783A1CC0073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A07A52261783A1D20073F6A7 /* Build configuration list for PBXNativeTarget "Test cpp iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A52271783A1D20073F6A7 /* Debug */, A07A52281783A1D20073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; A07A537E1784AC9B0073F6A7 /* Build configuration list for PBXNativeTarget "Hello cpp iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( A07A537F1784AC9B0073F6A7 /* Debug */, A07A53801784AC9B0073F6A7 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; C01FCF4E08A954540054247B /* Build configuration list for PBXProject "cocos2d_samples" */ = { isa = XCConfigurationList; buildConfigurations = ( C01FCF4F08A954540054247B /* Debug */, C01FCF5008A954540054247B /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; /* End XCConfigurationList section */ }; rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; } ================================================ FILE: cocos2d/build/install-deps-linux.sh ================================================ #!/bin/bash # Change directory to the location of this script cd $(dirname ${BASH_SOURCE[0]}) DEPENDS='libx11-dev' DEPENDS+=' libxmu-dev' DEPENDS+=' libglu1-mesa-dev' DEPENDS+=' libgl2ps-dev' DEPENDS+=' libxi-dev' DEPENDS+=' g++' DEPENDS+=' libzip-dev' DEPENDS+=' libpng12-dev' DEPENDS+=' libcurl4-gnutls-dev' DEPENDS+=' libfontconfig1-dev' DEPENDS+=' libsqlite3-dev' DEPENDS+=' libglew*-dev' MISSING= echo "Checking for missing packages ..." for i in $DEPENDS; do if ! dpkg-query -W --showformat='${Status}\n' $i | grep "install ok installed" > /dev/null; then MISSING+="$i " fi done if [ -n "$MISSING" ]; then TXTCOLOR_DEFAULT="\033[0;m" TXTCOLOR_GREEN="\033[0;32m" echo -e $TXTCOLOR_GREEN"Missing packages: $MISSING.\nYou may be asked for your password for package installation."$TXTCOLOR_DEFAULT sudo apt-get --force-yes --yes install $MISSING fi # install glfw ../tools/travis-scripts/install_glfw.sh ================================================ FILE: cocos2d/build/win32-msvc-2012-x86.cmd ================================================ @echo off SETLOCAL :start mkdir win32-msvc-vs2012-x86 cd win32-msvc-vs2012-x86 cmake -G "Visual Studio 11" ../.. pause ================================================ FILE: cocos2d/build/win32-msvc-2013-x86.cmd ================================================ @echo off SETLOCAL :start mkdir win32-msvc-vs2013-x86 cd win32-msvc-vs2013-x86 cmake -G "Visual Studio 12" ../.. pause ================================================ FILE: cocos2d/cocos/2d/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos2dx_static LOCAL_MODULE_FILENAME := libcocos2d LOCAL_SRC_FILES := \ base64.cpp \ CCAction.cpp \ CCActionCamera.cpp \ CCActionCatmullRom.cpp \ CCActionEase.cpp \ CCActionGrid.cpp \ CCActionGrid3D.cpp \ CCActionInstant.cpp \ CCActionInterval.cpp \ CCActionManager.cpp \ CCActionPageTurn3D.cpp \ CCActionProgressTimer.cpp \ CCActionTiledGrid.cpp \ CCActionTween.cpp \ CCAnimation.cpp \ CCAnimationCache.cpp \ CCAtlasNode.cpp \ ccCArray.cpp \ CCClippingNode.cpp \ CCComponent.cpp \ CCComponentContainer.cpp \ CCConfiguration.cpp \ CCDeprecated.cpp \ CCDirector.cpp \ CCDrawingPrimitives.cpp \ CCDrawNode.cpp \ CCEvent.cpp \ CCEventAcceleration.cpp \ CCEventCustom.cpp \ CCEventDispatcher.cpp \ CCEventKeyboard.cpp \ CCEventListener.cpp \ CCEventListenerAcceleration.cpp \ CCEventListenerCustom.cpp \ CCEventListenerKeyboard.cpp \ CCEventListenerMouse.cpp \ CCEventListenerTouch.cpp \ CCEventMouse.cpp \ CCEventTouch.cpp \ CCFont.cpp \ CCFontCharMap.cpp \ CCFontAtlas.cpp \ CCFontAtlasCache.cpp \ CCFontFNT.cpp \ CCFontFreeType.cpp \ ccFPSImages.c \ CCGLBufferedNode.cpp \ CCGLProgram.cpp \ ccGLStateCache.cpp \ CCGrabber.cpp \ CCGrid.cpp \ CCNodeGrid.cpp \ CCIMEDispatcher.cpp \ CCLabel.cpp \ CCLabelAtlas.cpp \ CCLabelBMFont.cpp \ CCLabelTextFormatter.cpp \ CCLabelTTF.cpp \ CCLayer.cpp \ CCMenu.cpp \ CCMenuItem.cpp \ CCMotionStreak.cpp \ CCNode.cpp \ CCNotificationCenter.cpp \ CCParallaxNode.cpp \ CCParticleBatchNode.cpp \ CCParticleExamples.cpp \ CCParticleSystem.cpp \ CCParticleSystemQuad.cpp \ CCProfiling.cpp \ CCProgressTimer.cpp \ CCRenderTexture.cpp \ CCScene.cpp \ CCScheduler.cpp \ CCScriptSupport.cpp \ CCShaderCache.cpp \ ccShaders.cpp \ CCSprite.cpp \ CCSpriteBatchNode.cpp \ CCSpriteFrame.cpp \ CCSpriteFrameCache.cpp \ CCTextFieldTTF.cpp \ CCTexture2D.cpp \ CCTextureAtlas.cpp \ CCTextureCache.cpp \ CCTileMapAtlas.cpp \ CCTMXLayer.cpp \ CCTMXObjectGroup.cpp \ CCTMXTiledMap.cpp \ CCTMXXMLParser.cpp \ CCTouch.cpp \ CCTransition.cpp \ CCTransitionPageTurn.cpp \ CCTransitionProgress.cpp \ ccTypes.cpp \ CCUserDefault.cpp \ CCUserDefaultAndroid.cpp \ ccUTF8.cpp \ ccUtils.cpp \ CCVertex.cpp \ cocos2d.cpp \ TGAlib.cpp \ TransformUtils.cpp \ ZipUtils.cpp \ platform/CCEGLViewProtocol.cpp \ platform/CCFileUtils.cpp \ platform/CCSAXParser.cpp \ platform/CCThread.cpp \ renderer/CCCustomCommand.cpp \ renderer/CCFrustum.cpp \ renderer/CCGroupCommand.cpp \ renderer/CCMaterialManager.cpp \ renderer/CCQuadCommand.cpp \ renderer/CCBatchCommand.cpp \ renderer/CCRenderCommand.cpp \ renderer/CCRenderer.cpp \ renderer/CCRenderMaterial.cpp \ ../base/atitc.cpp \ ../base/CCAffineTransform.cpp \ ../base/CCArray.cpp \ ../base/CCAutoreleasePool.cpp \ ../base/CCConsole.cpp \ ../base/CCData.cpp \ ../base/CCDataVisitor.cpp \ ../base/CCDictionary.cpp \ ../base/CCGeometry.cpp \ ../base/CCNS.cpp \ ../base/CCObject.cpp \ ../base/CCSet.cpp \ ../base/CCString.cpp \ ../base/CCValue.cpp \ ../base/etc1.cpp \ ../base/s3tc.cpp \ ../math/kazmath/src/aabb.c \ ../math/kazmath/src/mat3.c \ ../math/kazmath/src/mat4.c \ ../math/kazmath/src/neon_matrix_impl.c \ ../math/kazmath/src/plane.c \ ../math/kazmath/src/quaternion.c \ ../math/kazmath/src/ray2.c \ ../math/kazmath/src/utility.c \ ../math/kazmath/src/vec2.c \ ../math/kazmath/src/vec3.c \ ../math/kazmath/src/vec4.c \ ../math/kazmath/src/GL/mat4stack.c \ ../math/kazmath/src/GL/matrix.c \ ../physics/CCPhysicsBody.cpp \ ../physics/CCPhysicsContact.cpp \ ../physics/CCPhysicsJoint.cpp \ ../physics/CCPhysicsShape.cpp \ ../physics/CCPhysicsWorld.cpp \ ../physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp \ ../physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp \ ../physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp \ ../physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp \ ../physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp \ ../../external/tinyxml2/tinyxml2.cpp \ ../../external/unzip/ioapi.cpp \ ../../external/unzip/unzip.cpp \ ../../external/edtaa3func/edtaa3func.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/renderer \ $(LOCAL_PATH)/../math/kazmath/include \ platform/android \ $(LOCAL_PATH)/../physics \ $(LOCAL_PATH)/../base \ $(LOCAL_PATH)/../../external/tinyxml2 \ $(LOCAL_PATH)/../../external/unzip \ $(LOCAL_PATH)/../../external/chipmunk/include/chipmunk LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/renderer \ $(LOCAL_PATH)/../math/kazmath/include \ $(LOCAL_PATH)/platform/android \ $(LOCAL_PATH)/../physics \ $(LOCAL_PATH)/../base \ $(LOCAL_PATH)/../../external/tinyxml2 \ $(LOCAL_PATH)/../../external/unzip \ $(LOCAL_PATH)/../../external/chipmunk/include/chipmunk \ $(LOCAL_PATH)/../../external/edtaa3func LOCAL_LDLIBS := -lGLESv2 \ -llog \ -lz \ -landroid LOCAL_EXPORT_LDLIBS := -lGLESv2 \ -llog \ -lz \ -landroid LOCAL_WHOLE_STATIC_LIBRARIES := cocos_freetype2_static LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static # define the macro to compile through support/zip_support/ioapi.c LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API LOCAL_CPPFLAGS := -Wno-literal-suffix -Wno-deprecated-declarations LOCAL_EXPORT_CFLAGS := -Wno-psabi -DUSE_FILE32API LOCAL_EXPORT_CPPFLAGS := -Wno-literal-suffix -Wno-deprecated-declarations include $(BUILD_STATIC_LIBRARY) $(call import-module,freetype2/prebuilt/android) $(call import-module,chipmunk) $(call import-module,2d/platform/android) ================================================ FILE: cocos2d/cocos/2d/CCAction.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAction.h" #include "CCActionInterval.h" #include "CCNode.h" #include "CCDirector.h" #include "CCString.h" NS_CC_BEGIN // // Action Base Class // Action::Action() :_originalTarget(nullptr) ,_target(nullptr) ,_tag(Action::INVALID_TAG) { } Action::~Action() { CCLOGINFO("deallocing Action: %p - tag: %i", this, _tag); } std::string Action::description() const { return StringUtils::format("initWithAction(action, speed)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool Speed::initWithAction(ActionInterval *action, float speed) { CCASSERT(action != nullptr, ""); action->retain(); _innerAction = action; _speed = speed; return true; } Speed *Speed::clone() const { // no copy constructor auto a = new Speed(); a->initWithAction(_innerAction->clone(), _speed); a->autorelease(); return a; } void Speed::startWithTarget(Node* target) { Action::startWithTarget(target); _innerAction->startWithTarget(target); } void Speed::stop() { _innerAction->stop(); Action::stop(); } void Speed::step(float dt) { _innerAction->step(dt * _speed); } bool Speed::isDone() const { return _innerAction->isDone(); } Speed *Speed::reverse() const { return Speed::create(_innerAction->reverse(), _speed); } void Speed::setInnerAction(ActionInterval *action) { if (_innerAction != action) { CC_SAFE_RELEASE(_innerAction); _innerAction = action; CC_SAFE_RETAIN(_innerAction); } } // // Follow // Follow::~Follow() { CC_SAFE_RELEASE(_followedNode); } Follow* Follow::create(Node *followedNode, const Rect& rect/* = Rect::ZERO*/) { Follow *follow = new Follow(); if (follow && follow->initWithTarget(followedNode, rect)) { follow->autorelease(); return follow; } CC_SAFE_DELETE(follow); return nullptr; } Follow* Follow::clone() const { // no copy constructor auto a = new Follow(); a->initWithTarget(_followedNode, _worldRect); a->autorelease(); return a; } Follow* Follow::reverse() const { return clone(); } bool Follow::initWithTarget(Node *followedNode, const Rect& rect/* = Rect::ZERO*/) { CCASSERT(followedNode != nullptr, ""); followedNode->retain(); _followedNode = followedNode; _worldRect = rect; if (rect.equals(Rect::ZERO)) { _boundarySet = false; } else { _boundarySet = true; } _boundaryFullyCovered = false; Size winSize = Director::getInstance()->getWinSize(); _fullScreenSize = Point(winSize.width, winSize.height); _halfScreenSize = _fullScreenSize * 0.5f; if (_boundarySet) { _leftBoundary = -((rect.origin.x+rect.size.width) - _fullScreenSize.x); _rightBoundary = -rect.origin.x ; _topBoundary = -rect.origin.y; _bottomBoundary = -((rect.origin.y+rect.size.height) - _fullScreenSize.y); if(_rightBoundary < _leftBoundary) { // screen width is larger than world's boundary width //set both in the middle of the world _rightBoundary = _leftBoundary = (_leftBoundary + _rightBoundary) / 2; } if(_topBoundary < _bottomBoundary) { // screen width is larger than world's boundary width //set both in the middle of the world _topBoundary = _bottomBoundary = (_topBoundary + _bottomBoundary) / 2; } if( (_topBoundary == _bottomBoundary) && (_leftBoundary == _rightBoundary) ) { _boundaryFullyCovered = true; } } return true; } void Follow::step(float dt) { CC_UNUSED_PARAM(dt); if(_boundarySet) { // whole map fits inside a single screen, no need to modify the position - unless map boundaries are increased if(_boundaryFullyCovered) return; Point tempPos = _halfScreenSize - _followedNode->getPosition(); _target->setPosition(Point(clampf(tempPos.x, _leftBoundary, _rightBoundary), clampf(tempPos.y, _bottomBoundary, _topBoundary))); } else { _target->setPosition(_halfScreenSize - _followedNode->getPosition()); } } bool Follow::isDone() const { return ( !_followedNode->isRunning() ); } void Follow::stop() { _target = nullptr; Action::stop(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCAction.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTIONS_CCACTION_H__ #define __ACTIONS_CCACTION_H__ #include "CCObject.h" #include "CCGeometry.h" #include "CCPlatformMacros.h" NS_CC_BEGIN /** * @addtogroup actions * @{ */ /** @brief Base class for Action objects. */ class CC_DLL Action : public Object, public Clonable { public: /// Default tag used for all the actions static const int INVALID_TAG = -1; /** * @js NA * @lua NA */ virtual std::string description() const; /** returns a clone of action */ virtual Action* clone() const = 0; /** returns a new action that performs the exactly the reverse action */ virtual Action* reverse() const = 0; //! return true if the action has finished virtual bool isDone() const; //! called before the action start. It will also set the target. virtual void startWithTarget(Node *target); /** called after the action has finished. It will set the 'target' to nil. IMPORTANT: You should never call "[action stop]" manually. Instead, use: "target->stopAction(action);" */ virtual void stop(); //! called every frame with it's delta time. DON'T override unless you know what you are doing. virtual void step(float dt); /** called once per frame. time a value between 0 and 1 For example: - 0 means that the action just started - 0.5 means that the action is in the middle - 1 means that the action is over */ virtual void update(float time); inline Node* getTarget() const { return _target; } /** The action will modify the target properties. */ inline void setTarget(Node *target) { _target = target; } inline Node* getOriginalTarget() const { return _originalTarget; } /** Set the original target, since target can be nil. Is the target that were used to run the action. Unless you are doing something complex, like ActionManager, you should NOT call this method. The target is 'assigned', it is not 'retained'. @since v0.8.2 */ inline void setOriginalTarget(Node *originalTarget) { _originalTarget = originalTarget; } inline int getTag() const { return _tag; } inline void setTag(int tag) { _tag = tag; } protected: Action(); virtual ~Action(); Node *_originalTarget; /** The "target". The target will be set with the 'startWithTarget' method. When the 'stop' method is called, target will be set to nil. The target is 'assigned', it is not 'retained'. */ Node *_target; /** The action tag. An identifier of the action */ int _tag; private: CC_DISALLOW_COPY_AND_ASSIGN(Action); }; /** @brief Base class actions that do have a finite time duration. Possible actions: - An action with a duration of 0 seconds - An action with a duration of 35.5 seconds Infinite time actions are valid */ class CC_DLL FiniteTimeAction : public Action { public: //! get duration in seconds of the action inline float getDuration() const { return _duration; } //! set duration in seconds of the action inline void setDuration(float duration) { _duration = duration; } // // Overrides // virtual FiniteTimeAction* reverse() const override = 0; virtual FiniteTimeAction* clone() const override = 0; protected: FiniteTimeAction() : _duration(0) {} virtual ~FiniteTimeAction(){} //! duration in seconds float _duration; private: CC_DISALLOW_COPY_AND_ASSIGN(FiniteTimeAction); }; class ActionInterval; class RepeatForever; /** @brief Changes the speed of an action, making it take longer (speed>1) or less (speed<1) time. Useful to simulate 'slow motion' or 'fast forward' effect. @warning This action can't be Sequenceable because it is not an IntervalAction */ class CC_DLL Speed : public Action { public: /** create the action */ static Speed* create(ActionInterval* action, float speed); inline float getSpeed(void) const { return _speed; } /** alter the speed of the inner function in runtime */ inline void setSpeed(float speed) { _speed = speed; } void setInnerAction(ActionInterval *action); inline ActionInterval* getInnerAction() const { return _innerAction; } // // Override // virtual Speed* clone() const override; virtual Speed* reverse() const override; virtual void startWithTarget(Node* target) override; virtual void stop() override; virtual void step(float dt) override; virtual bool isDone() const override; protected: Speed(); virtual ~Speed(void); /** initializes the action */ bool initWithAction(ActionInterval *action, float speed); float _speed; ActionInterval *_innerAction; private: CC_DISALLOW_COPY_AND_ASSIGN(Speed); }; /** @brief Follow is an action that "follows" a node. Eg: @code layer->runAction(Follow::actionWithTarget(hero)); @endcode Instead of using Camera as a "follower", use this action instead. @since v0.99.2 */ class CC_DLL Follow : public Action { public: /** * Creates the action with a set boundary or with no boundary. * * @param followedNode The node to be followed. * @param rect The boundary. If \p rect is equal to Rect::ZERO, it'll work * with no boundary. */ static Follow* create(Node *followedNode, const Rect& rect = Rect::ZERO); inline bool isBoundarySet() const { return _boundarySet; } /** alter behavior - turn on/off boundary */ inline void setBoudarySet(bool value) { _boundarySet = value; } // // Override // virtual Follow* clone() const override; virtual Follow* reverse() const override; virtual void step(float dt) override; virtual bool isDone() const override; virtual void stop() override; protected: /** * @js ctor */ Follow() : _followedNode(nullptr) , _boundarySet(false) , _boundaryFullyCovered(false) , _leftBoundary(0.0) , _rightBoundary(0.0) , _topBoundary(0.0) , _bottomBoundary(0.0) , _worldRect(Rect::ZERO) {} /** * @js NA * @lua NA */ virtual ~Follow(); /** * Initializes the action with a set boundary or with no boundary. * * @param followedNode The node to be followed. * @param rect The boundary. If \p rect is equal to Rect::ZERO, it'll work * with no boundary. */ bool initWithTarget(Node *followedNode, const Rect& rect = Rect::ZERO); // node to follow Node *_followedNode; // whether camera should be limited to certain area bool _boundarySet; // if screen size is bigger than the boundary - update not needed bool _boundaryFullyCovered; // fast access to the screen dimensions Point _halfScreenSize; Point _fullScreenSize; // world boundaries float _leftBoundary; float _rightBoundary; float _topBoundary; float _bottomBoundary; Rect _worldRect; private: CC_DISALLOW_COPY_AND_ASSIGN(Follow); }; // end of actions group /// @} NS_CC_END #endif // __ACTIONS_CCACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionCamera.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionCamera.h" #include "CCNode.h" #include "CCStdC.h" NS_CC_BEGIN // // CameraAction // ActionCamera::ActionCamera() { kmVec3Fill(&_center, 0, 0, 0); kmVec3Fill(&_eye, 0, 0, FLT_EPSILON); kmVec3Fill(&_up, 0, 1, 0); } void ActionCamera::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); } ActionCamera* ActionCamera::clone() const { // no copy constructor auto a = new ActionCamera(); a->autorelease(); return a; } ActionCamera * ActionCamera::reverse() const { // FIXME: This conversion isn't safe. return (ActionCamera*)ReverseTime::create(const_cast(this)); } void ActionCamera::restore() { kmVec3Fill(&_center, 0, 0, 0); kmVec3Fill(&_eye, 0, 0, FLT_EPSILON); kmVec3Fill(&_up, 0, 1, 0); } void ActionCamera::setEye(const kmVec3& eye) { _eye = eye; updateTransform(); } void ActionCamera::setEye(float x, float y, float z) { kmVec3Fill(&_eye, x, y, z); updateTransform(); } void ActionCamera::setCenter(const kmVec3& center) { _center = center; updateTransform(); } void ActionCamera::setUp(const kmVec3& up) { _up = up; updateTransform(); } void ActionCamera::updateTransform() { kmMat4 lookupMatrix; kmMat4LookAt(&lookupMatrix, &_eye, &_center, &_up); Point anchorPoint = _target->getAnchorPointInPoints(); bool needsTranslation = !anchorPoint.equals(Point::ZERO); kmMat4 mv; kmMat4Identity(&mv); if(needsTranslation) { kmMat4 t; kmMat4Translation(&t, anchorPoint.x, anchorPoint.y, 0); kmMat4Multiply(&mv, &mv, &t); } kmMat4Multiply(&mv, &mv, &lookupMatrix); if(needsTranslation) { kmMat4 t; kmMat4Translation(&t, -anchorPoint.x, -anchorPoint.y, 0); kmMat4Multiply(&mv, &mv, &t); } // XXX FIXME TODO // Using the AdditionalTransform is a complete hack. // This should be done by multipliying the lookup-Matrix with the Node's MV matrix // And then setting the result as the new MV matrix // But that operation needs to be done after all the 'updates'. // So the Director should emit an 'director_after_update' event. // And this object should listen to it _target->setAdditionalTransform(mv); } // // OrbitCamera // OrbitCamera * OrbitCamera::create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) { OrbitCamera * obitCamera = new OrbitCamera(); if(obitCamera->initWithDuration(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX)) { obitCamera->autorelease(); return obitCamera; } CC_SAFE_DELETE(obitCamera); return nullptr; } OrbitCamera* OrbitCamera::clone() const { // no copy constructor auto a = new OrbitCamera(); a->initWithDuration(_duration, _radius, _deltaRadius, _angleZ, _deltaAngleZ, _angleX, _deltaAngleX); a->autorelease(); return a; } bool OrbitCamera::initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) { if ( ActionInterval::initWithDuration(t) ) { _radius = radius; _deltaRadius = deltaRadius; _angleZ = angleZ; _deltaAngleZ = deltaAngleZ; _angleX = angleX; _deltaAngleX = deltaAngleX; _radDeltaZ = (float)CC_DEGREES_TO_RADIANS(deltaAngleZ); _radDeltaX = (float)CC_DEGREES_TO_RADIANS(deltaAngleX); return true; } return false; } void OrbitCamera::startWithTarget(Node *target) { ActionCamera::startWithTarget(target); float r, zenith, azimuth; this->sphericalRadius(&r, &zenith, &azimuth); if( isnan(_radius) ) _radius = r; if( isnan(_angleZ) ) _angleZ = (float)CC_RADIANS_TO_DEGREES(zenith); if( isnan(_angleX) ) _angleX = (float)CC_RADIANS_TO_DEGREES(azimuth); _radZ = (float)CC_DEGREES_TO_RADIANS(_angleZ); _radX = (float)CC_DEGREES_TO_RADIANS(_angleX); } void OrbitCamera::update(float dt) { float r = (_radius + _deltaRadius * dt) * FLT_EPSILON; float za = _radZ + _radDeltaZ * dt; float xa = _radX + _radDeltaX * dt; float i = sinf(za) * cosf(xa) * r + _center.x; float j = sinf(za) * sinf(xa) * r + _center.y; float k = cosf(za) * r + _center.z; setEye(i,j,k); } void OrbitCamera::sphericalRadius(float *newRadius, float *zenith, float *azimuth) { float r; // radius float s; float x = _eye.x - _center.x; float y = _eye.y - _center.y; float z = _eye.z - _center.z; r = sqrtf( powf(x,2) + powf(y,2) + powf(z,2)); s = sqrtf( powf(x,2) + powf(y,2)); if( s == 0.0f ) s = FLT_EPSILON; if(r==0.0f) r = FLT_EPSILON; *zenith = acosf( z/r); if( x < 0 ) *azimuth= (float)M_PI - asinf(y/s); else *azimuth = asinf(y/s); *newRadius = r / FLT_EPSILON; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionCamera.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCCAMERA_ACTION_H__ #define __CCCAMERA_ACTION_H__ #include "CCActionInterval.h" #include "kazmath/kazmath.h" NS_CC_BEGIN class Camera; /** * @addtogroup actions * @{ */ /** @brief Base class for Camera actions @ingroup Actions */ class CC_DLL ActionCamera : public ActionInterval // { public: /** * @js ctor */ ActionCamera(); /** * @js NA * @lua NA */ virtual ~ActionCamera(){} // Overrides virtual void startWithTarget(Node *target) override; virtual ActionCamera * reverse() const override; virtual ActionCamera *clone() const override; /* sets the Eye value of the Camera */ void setEye(const kmVec3 &eye); void setEye(float x, float y, float z); /* returns the Eye value of the Camera */ const kmVec3& getEye() const { return _eye; } /* sets the Center value of the Camera */ void setCenter(const kmVec3 ¢er); /* returns the Center value of the Camera */ const kmVec3& getCenter() const { return _center; } /* sets the Up value of the Camera */ void setUp(const kmVec3 &up); /* Returns the Up value of the Camera */ const kmVec3& getUp() const { return _up; } protected: void restore(); void updateTransform(); kmVec3 _center; kmVec3 _eye; kmVec3 _up; }; /** @brief OrbitCamera action Orbits the camera around the center of the screen using spherical coordinates @ingroup Actions */ class CC_DLL OrbitCamera : public ActionCamera // { public: /** creates a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ static OrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); /** * @js ctor */ OrbitCamera() : _radius(0.0) , _deltaRadius(0.0) , _angleZ(0.0) , _deltaAngleZ(0.0) , _angleX(0.0) , _deltaAngleX(0.0) , _radZ(0.0) , _radDeltaZ(0.0) , _radX(0.0) , _radDeltaX(0.0) {} /** * @js NA * @lua NA */ virtual ~OrbitCamera(){} /** initializes a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ bool initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); /** positions the camera according to spherical coordinates */ void sphericalRadius(float *r, float *zenith, float *azimuth); // Overrides OrbitCamera *clone() const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: float _radius; float _deltaRadius; float _angleZ; float _deltaAngleZ; float _angleX; float _deltaAngleX; float _radZ; float _radDeltaZ; float _radX; float _radDeltaX; }; // end of actions group /// @} NS_CC_END #endif //__CCCAMERA_ACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionCatmullRom.cpp ================================================ /* * Copyright (c) 2008 Radu Gruian * Copyright (c) 2011 Vit Valentin * Copyright (c) 2012 cocos2d-x.org * Copyright (c) 2013-2014 Chukong Technologies Inc. * * 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. * * * Original code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So * * Adapted to cocos2d-x by Vit Valentin * * Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada */ #include "ccMacros.h" #include "CCActionCatmullRom.h" using namespace std; NS_CC_BEGIN; /* * Implementation of PointArray */ PointArray* PointArray::create(ssize_t capacity) { PointArray* pointArray = new PointArray(); if (pointArray) { if (pointArray->initWithCapacity(capacity)) { pointArray->autorelease(); } else { delete pointArray; pointArray = nullptr; } } return pointArray; } bool PointArray::initWithCapacity(ssize_t capacity) { _controlPoints = new vector(); return true; } PointArray* PointArray::clone() const { vector *newArray = new vector(); vector::iterator iter; for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) { newArray->push_back(new Point((*iter)->x, (*iter)->y)); } PointArray *points = new PointArray(); points->initWithCapacity(10); points->setControlPoints(newArray); points->autorelease(); return points; } PointArray::~PointArray() { CCLOGINFO("deallocing PointArray: %p", this); vector::iterator iter; for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) { delete *iter; } delete _controlPoints; } PointArray::PointArray() :_controlPoints(nullptr){} const std::vector* PointArray::getControlPoints() const { return _controlPoints; } void PointArray::setControlPoints(vector *controlPoints) { CCASSERT(controlPoints != nullptr, "control points should not be nullptr"); // delete old points vector::iterator iter; for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter) { delete *iter; } delete _controlPoints; _controlPoints = controlPoints; } void PointArray::addControlPoint(Point controlPoint) { _controlPoints->push_back(new Point(controlPoint.x, controlPoint.y)); } void PointArray::insertControlPoint(Point &controlPoint, ssize_t index) { Point *temp = new Point(controlPoint.x, controlPoint.y); _controlPoints->insert(_controlPoints->begin() + index, temp); } Point PointArray::getControlPointAtIndex(ssize_t index) { index = MIN(_controlPoints->size()-1, MAX(index, 0)); return *(_controlPoints->at(index)); } void PointArray::replaceControlPoint(cocos2d::Point &controlPoint, ssize_t index) { Point *temp = _controlPoints->at(index); temp->x = controlPoint.x; temp->y = controlPoint.y; } void PointArray::removeControlPointAtIndex(ssize_t index) { vector::iterator iter = _controlPoints->begin() + index; Point* removedPoint = *iter; _controlPoints->erase(iter); delete removedPoint; } ssize_t PointArray::count() const { return _controlPoints->size(); } PointArray* PointArray::reverse() const { vector *newArray = new vector(); vector::reverse_iterator iter; Point *point = nullptr; for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter) { point = *iter; newArray->push_back(new Point(point->x, point->y)); } PointArray *config = PointArray::create(0); config->setControlPoints(newArray); return config; } void PointArray::reverseInline() { size_t l = _controlPoints->size(); Point *p1 = nullptr; Point *p2 = nullptr; float x, y; for (size_t i = 0; i < l/2; ++i) { p1 = _controlPoints->at(i); p2 = _controlPoints->at(l-i-1); x = p1->x; y = p1->y; p1->x = p2->x; p1->y = p2->y; p2->x = x; p2->y = y; } } // CatmullRom Spline formula: Point ccCardinalSplineAt(Point &p0, Point &p1, Point &p2, Point &p3, float tension, float t) { float t2 = t * t; float t3 = t2 * t; /* * Formula: s(-ttt + 2tt - t)P1 + s(-ttt + tt)P2 + (2ttt - 3tt + 1)P2 + s(ttt - 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt - tt)P4 */ float s = (1 - tension) / 2; float b1 = s * ((-t3 + (2 * t2)) - t); // s(-t3 + 2 t2 - t)P1 float b2 = s * (-t3 + t2) + (2 * t3 - 3 * t2 + 1); // s(-t3 + t2)P2 + (2 t3 - 3 t2 + 1)P2 float b3 = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2); // s(t3 - 2 t2 + t)P3 + (-2 t3 + 3 t2)P3 float b4 = s * (t3 - t2); // s(t3 - t2)P4 float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4); float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4); return Point(x,y); } /* Implementation of CardinalSplineTo */ CardinalSplineTo* CardinalSplineTo::create(float duration, cocos2d::PointArray *points, float tension) { CardinalSplineTo *ret = new CardinalSplineTo(); if (ret) { if (ret->initWithDuration(duration, points, tension)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } bool CardinalSplineTo::initWithDuration(float duration, cocos2d::PointArray *points, float tension) { CCASSERT(points->count() > 0, "Invalid configuration. It must at least have one control point"); if (ActionInterval::initWithDuration(duration)) { this->setPoints(points); this->_tension = tension; return true; } return false; } CardinalSplineTo::~CardinalSplineTo() { CC_SAFE_RELEASE_NULL(_points); } CardinalSplineTo::CardinalSplineTo() : _points(nullptr) , _deltaT(0.f) , _tension(0.f) { } void CardinalSplineTo::startWithTarget(cocos2d::Node *target) { ActionInterval::startWithTarget(target); // _deltaT = (float) 1 / _points->count(); // Issue #1441 _deltaT = (float) 1 / (_points->count() - 1); _previousPosition = target->getPosition(); _accumulatedDiff = Point::ZERO; } CardinalSplineTo* CardinalSplineTo::clone() const { // no copy constructor auto a = new CardinalSplineTo(); a->initWithDuration(this->_duration, this->_points->clone(), this->_tension); a->autorelease(); return a; } void CardinalSplineTo::update(float time) { ssize_t p; float lt; // eg. // p..p..p..p..p..p..p // 1..2..3..4..5..6..7 // want p to be 1, 2, 3, 4, 5, 6 if (time == 1) { p = _points->count() - 1; lt = 1; } else { p = time / _deltaT; lt = (time - _deltaT * (float)p) / _deltaT; } // Interpolate Point pp0 = _points->getControlPointAtIndex(p-1); Point pp1 = _points->getControlPointAtIndex(p+0); Point pp2 = _points->getControlPointAtIndex(p+1); Point pp3 = _points->getControlPointAtIndex(p+2); Point newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt); #if CC_ENABLE_STACKABLE_ACTIONS // Support for stacked actions Node *node = _target; Point diff = node->getPosition() - _previousPosition; if( diff.x !=0 || diff.y != 0 ) { _accumulatedDiff = _accumulatedDiff + diff; newPos = newPos + _accumulatedDiff; } #endif this->updatePosition(newPos); } void CardinalSplineTo::updatePosition(cocos2d::Point &newPos) { _target->setPosition(newPos); _previousPosition = newPos; } CardinalSplineTo* CardinalSplineTo::reverse() const { PointArray *pReverse = _points->reverse(); return CardinalSplineTo::create(_duration, pReverse, _tension); } /* CardinalSplineBy */ CardinalSplineBy* CardinalSplineBy::create(float duration, cocos2d::PointArray *points, float tension) { CardinalSplineBy *ret = new CardinalSplineBy(); if (ret) { if (ret->initWithDuration(duration, points, tension)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } CardinalSplineBy::CardinalSplineBy() : _startPosition(0,0) { } void CardinalSplineBy::updatePosition(cocos2d::Point &newPos) { Point p = newPos + _startPosition; _target->setPosition(p); _previousPosition = p; } CardinalSplineBy* CardinalSplineBy::reverse() const { PointArray *copyConfig = _points->clone(); // // convert "absolutes" to "diffs" // Point p = copyConfig->getControlPointAtIndex(0); for (ssize_t i = 1; i < copyConfig->count(); ++i) { Point current = copyConfig->getControlPointAtIndex(i); Point diff = current - p; copyConfig->replaceControlPoint(diff, i); p = current; } // convert to "diffs" to "reverse absolute" PointArray *pReverse = copyConfig->reverse(); // 1st element (which should be 0,0) should be here too p = pReverse->getControlPointAtIndex(pReverse->count()-1); pReverse->removeControlPointAtIndex(pReverse->count()-1); p = -p; pReverse->insertControlPoint(p, 0); for (ssize_t i = 1; i < pReverse->count(); ++i) { Point current = pReverse->getControlPointAtIndex(i); current = -current; Point abs = current + p; pReverse->replaceControlPoint(abs, i); p = abs; } return CardinalSplineBy::create(_duration, pReverse, _tension); } void CardinalSplineBy::startWithTarget(cocos2d::Node *target) { CardinalSplineTo::startWithTarget(target); _startPosition = target->getPosition(); } CardinalSplineBy* CardinalSplineBy::clone() const { // no copy constructor auto a = new CardinalSplineBy(); a->initWithDuration(this->_duration, this->_points->clone(), this->_tension); a->autorelease(); return a; } /* CatmullRomTo */ CatmullRomTo* CatmullRomTo::create(float dt, cocos2d::PointArray *points) { CatmullRomTo *ret = new CatmullRomTo(); if (ret) { if (ret->initWithDuration(dt, points)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } bool CatmullRomTo::initWithDuration(float dt, cocos2d::PointArray *points) { if (CardinalSplineTo::initWithDuration(dt, points, 0.5f)) { return true; } return false; } CatmullRomTo* CatmullRomTo::clone() const { // no copy constructor auto a = new CatmullRomTo(); a->initWithDuration(this->_duration, this->_points->clone()); a->autorelease(); return a; } CatmullRomTo* CatmullRomTo::reverse() const { PointArray *reverse = _points->reverse(); return CatmullRomTo::create(_duration, reverse); } /* CatmullRomBy */ CatmullRomBy* CatmullRomBy::create(float dt, cocos2d::PointArray *points) { CatmullRomBy *ret = new CatmullRomBy(); if (ret) { if (ret->initWithDuration(dt, points)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } bool CatmullRomBy::initWithDuration(float dt, cocos2d::PointArray *points) { if (CardinalSplineTo::initWithDuration(dt, points, 0.5f)) { return true; } return false; } CatmullRomBy* CatmullRomBy::clone() const { // no copy constructor auto a = new CatmullRomBy(); a->initWithDuration(this->_duration, this->_points->clone()); a->autorelease(); return a; } CatmullRomBy* CatmullRomBy::reverse() const { PointArray *copyConfig = _points->clone(); // // convert "absolutes" to "diffs" // Point p = copyConfig->getControlPointAtIndex(0); for (ssize_t i = 1; i < copyConfig->count(); ++i) { Point current = copyConfig->getControlPointAtIndex(i); Point diff = current - p; copyConfig->replaceControlPoint(diff, i); p = current; } // convert to "diffs" to "reverse absolute" PointArray *reverse = copyConfig->reverse(); // 1st element (which should be 0,0) should be here too p = reverse->getControlPointAtIndex(reverse->count()-1); reverse->removeControlPointAtIndex(reverse->count()-1); p = -p; reverse->insertControlPoint(p, 0); for (ssize_t i = 1; i < reverse->count(); ++i) { Point current = reverse->getControlPointAtIndex(i); current = -current; Point abs = current + p; reverse->replaceControlPoint(abs, i); p = abs; } return CatmullRomBy::create(_duration, reverse); } NS_CC_END; ================================================ FILE: cocos2d/cocos/2d/CCActionCatmullRom.h ================================================ /* * Copyright (c) 2008 Radu Gruian * Copyright (c) 2011 Vit Valentin * Copyright (c) 2012 cocos2d-x.org * Copyright (c) 2013-2014 Chukong Technologies Inc. * * * 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. * * * Original code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So * * Adapted to cocos2d-x by Vit Valentin * * Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada */ #ifndef __CCACTION_CATMULLROM_H__ #define __CCACTION_CATMULLROM_H__ #include #include "CCActionInterval.h" #include "CCNode.h" #include "CCGeometry.h" NS_CC_BEGIN; /** * @addtogroup actions * @{ */ /** An Array that contain control points. Used by CardinalSplineTo and (By) and CatmullRomTo (and By) actions. @ingroup Actions */ class CC_DLL PointArray : public Object, public Clonable { public: /** creates and initializes a Points array with capacity * @js NA */ static PointArray* create(ssize_t capacity); /** * @js NA * @lua NA */ virtual ~PointArray(); /** * @js NA * @lua NA */ PointArray(); /** initializes a Catmull Rom config with a capacity hint * @js NA */ bool initWithCapacity(ssize_t capacity); /** appends a control point * @js NA */ void addControlPoint(Point controlPoint); /** inserts a controlPoint at index * @js NA */ void insertControlPoint(Point &controlPoint, ssize_t index); /** replaces an existing controlPoint at index * @js NA */ void replaceControlPoint(Point &controlPoint, ssize_t index); /** get the value of a controlPoint at a given index * @js NA */ Point getControlPointAtIndex(ssize_t index); /** deletes a control point at a given index * @js NA */ void removeControlPointAtIndex(ssize_t index); /** returns the number of objects of the control point array * @js NA */ ssize_t count() const; /** returns a new copy of the array reversed. User is responsible for releasing this copy * @js NA */ PointArray* reverse() const; /** reverse the current control point array inline, without generating a new one * @js NA */ void reverseInline(); /** * @js NA * @lua NA */ virtual PointArray* clone() const; /** * @js NA */ const std::vector* getControlPoints() const; /** * @js NA */ void setControlPoints(std::vector *controlPoints); private: /** Array that contains the control points */ std::vector *_controlPoints; }; /** Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline @ingroup Actions */ class CC_DLL CardinalSplineTo : public ActionInterval { public: /** creates an action with a Cardinal Spline array of points and tension * @code * when this function bound to js or lua,the input params are changed * in js: var create(var t,var table) * in lua: lcaol create(local t, local table) * @endcode */ static CardinalSplineTo* create(float duration, PointArray* points, float tension); /** * @js NA * @lua NA */ virtual ~CardinalSplineTo(); /** * @js NA * @lua NA */ CardinalSplineTo(); /** initializes the action with a duration and an array of points */ bool initWithDuration(float duration, PointArray* points, float tension); virtual void updatePosition(Point &newPos); inline PointArray* getPoints() { return _points; } /** * @js NA * @lua NA */ inline void setPoints(PointArray* points) { CC_SAFE_RETAIN(points); CC_SAFE_RELEASE(_points); _points = points; } // Overrides virtual CardinalSplineTo *clone() const override; virtual CardinalSplineTo* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: /** Array of control points */ PointArray *_points; float _deltaT; float _tension; Point _previousPosition; Point _accumulatedDiff; }; /** Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline @ingroup Actions */ class CC_DLL CardinalSplineBy : public CardinalSplineTo { public: /** creates an action with a Cardinal Spline array of points and tension * @code * when this function bound to js or lua,the input params are changed * in js: var create(var t,var table) * in lua: lcaol create(local t, local table) * @endcode */ static CardinalSplineBy* create(float duration, PointArray* points, float tension); CardinalSplineBy(); // Overrides virtual void startWithTarget(Node *target) override; virtual void updatePosition(Point &newPos) override; virtual CardinalSplineBy *clone() const override; virtual CardinalSplineBy* reverse() const override; protected: Point _startPosition; }; /** An action that moves the target with a CatmullRom curve to a destination point. A Catmull Rom is a Cardinal Spline with a tension of 0.5. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline @ingroup Actions */ class CC_DLL CatmullRomTo : public CardinalSplineTo { public: /** creates an action with a Cardinal Spline array of points and tension * @code * when this function bound to js or lua,the input params are changed * in js: var create(var dt,var table) * in lua: lcaol create(local dt, local table) * @endcode */ static CatmullRomTo* create(float dt, PointArray* points); /** initializes the action with a duration and an array of points */ bool initWithDuration(float dt, PointArray* points); // Override virtual CatmullRomTo *clone() const override; virtual CatmullRomTo *reverse() const override; }; /** An action that moves the target with a CatmullRom curve by a certain distance. A Catmull Rom is a Cardinal Spline with a tension of 0.5. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline @ingroup Actions */ class CC_DLL CatmullRomBy : public CardinalSplineBy { public: /** creates an action with a Cardinal Spline array of points and tension * @code * when this function bound to js or lua,the input params are changed * in js: var create(var dt,var table) * in lua: lcaol create(local dt, local table) * @endcode */ static CatmullRomBy* create(float dt, PointArray* points); /** initializes the action with a duration and an array of points */ bool initWithDuration(float dt, PointArray* points); // Override virtual CatmullRomBy *clone() const override; virtual CatmullRomBy *reverse() const override; }; /** Returns the Cardinal Spline position for a given set of control points, tension and time */ extern CC_DLL Point ccCardinalSplineAt(Point &p0, Point &p1, Point &p2, Point &p3, float tension, float t); // end of actions group /// @} NS_CC_END; #endif // __CCACTION_CATMULLROM_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionEase.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2009 Jason Booth Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ /* * Elastic, Back and Bounce actions based on code from: * http://github.com/NikhilK/silverlightfx/ * * by http://github.com/NikhilK */ #include "CCActionEase.h" NS_CC_BEGIN #ifndef M_PI_X_2 #define M_PI_X_2 (float)M_PI * 2.0f #endif // // EaseAction // bool ActionEase::initWithAction(ActionInterval *action) { CCASSERT(action != nullptr, ""); if (ActionInterval::initWithDuration(action->getDuration())) { _inner = action; action->retain(); return true; } return false; } ActionEase::~ActionEase(void) { CC_SAFE_RELEASE(_inner); } void ActionEase::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _inner->startWithTarget(_target); } void ActionEase::stop(void) { _inner->stop(); ActionInterval::stop(); } void ActionEase::update(float time) { _inner->update(time); } ActionInterval* ActionEase::getInnerAction() { return _inner; } // // EaseRateAction // bool EaseRateAction::initWithAction(ActionInterval *action, float rate) { if (ActionEase::initWithAction(action)) { _rate = rate; return true; } return false; } EaseRateAction::~EaseRateAction() { } // // EeseIn // EaseIn* EaseIn::create(ActionInterval *action, float rate) { EaseIn *easeIn = new EaseIn(); if (easeIn) { if (easeIn->initWithAction(action, rate)) { easeIn->autorelease(); } else { CC_SAFE_RELEASE_NULL(easeIn); } } return easeIn; } EaseIn* EaseIn::clone() const { // no copy constructor auto a = new EaseIn(); a->initWithAction(_inner->clone(), _rate); a->autorelease(); return a; } void EaseIn::update(float time) { _inner->update(powf(time, _rate)); } EaseIn* EaseIn::reverse() const { return EaseIn::create(_inner->reverse(), 1 / _rate); } // // EaseOut // EaseOut* EaseOut::create(ActionInterval *action, float rate) { EaseOut *easeOut = new EaseOut(); if (easeOut) { if (easeOut->initWithAction(action, rate)) { easeOut->autorelease(); } else { CC_SAFE_RELEASE_NULL(easeOut); } } return easeOut; } EaseOut* EaseOut::clone() const { // no copy constructor auto a = new EaseOut(); a->initWithAction(_inner->clone(), _rate); a->autorelease(); return a; } void EaseOut::update(float time) { _inner->update(powf(time, 1 / _rate)); } EaseOut* EaseOut::reverse() const { return EaseOut::create(_inner->reverse(), 1 / _rate); } // // EaseInOut // EaseInOut* EaseInOut::create(ActionInterval *action, float rate) { EaseInOut *easeInOut = new EaseInOut(); if (easeInOut) { if (easeInOut->initWithAction(action, rate)) { easeInOut->autorelease(); } else { CC_SAFE_RELEASE_NULL(easeInOut); } } return easeInOut; } EaseInOut* EaseInOut::clone() const { // no copy constructor auto a = new EaseInOut(); a->initWithAction(_inner->clone(), _rate); a->autorelease(); return a; } void EaseInOut::update(float time) { time *= 2; if (time < 1) { _inner->update(0.5f * powf(time, _rate)); } else { _inner->update(1.0f - 0.5f * powf(2-time, _rate)); } } // InOut and OutIn are symmetrical EaseInOut* EaseInOut::reverse() const { return EaseInOut::create(_inner->reverse(), _rate); } // // EaseExponentialIn // EaseExponentialIn* EaseExponentialIn::create(ActionInterval* action) { EaseExponentialIn *ret = new EaseExponentialIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseExponentialIn* EaseExponentialIn::clone() const { // no copy constructor auto a = new EaseExponentialIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseExponentialIn::update(float time) { _inner->update(time == 0 ? 0 : powf(2, 10 * (time/1 - 1)) - 1 * 0.001f); } ActionEase * EaseExponentialIn::reverse() const { return EaseExponentialOut::create(_inner->reverse()); } // // EaseExponentialOut // EaseExponentialOut* EaseExponentialOut::create(ActionInterval* action) { EaseExponentialOut *ret = new EaseExponentialOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseExponentialOut* EaseExponentialOut::clone() const { // no copy constructor auto a = new EaseExponentialOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseExponentialOut::update(float time) { _inner->update(time == 1 ? 1 : (-powf(2, -10 * time / 1) + 1)); } ActionEase* EaseExponentialOut::reverse() const { return EaseExponentialIn::create(_inner->reverse()); } // // EaseExponentialInOut // EaseExponentialInOut* EaseExponentialInOut::create(ActionInterval *action) { EaseExponentialInOut *ret = new EaseExponentialInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseExponentialInOut* EaseExponentialInOut::clone() const { // no copy constructor auto a = new EaseExponentialInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseExponentialInOut::update(float time) { time /= 0.5f; if (time < 1) { time = 0.5f * powf(2, 10 * (time - 1)); } else { time = 0.5f * (-powf(2, -10 * (time - 1)) + 2); } _inner->update(time); } EaseExponentialInOut* EaseExponentialInOut::reverse() const { return EaseExponentialInOut::create(_inner->reverse()); } // // EaseSineIn // EaseSineIn* EaseSineIn::create(ActionInterval* action) { EaseSineIn *ret = new EaseSineIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseSineIn* EaseSineIn::clone() const { // no copy constructor auto a = new EaseSineIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseSineIn::update(float time) { _inner->update(-1 * cosf(time * (float)M_PI_2) + 1); } ActionEase* EaseSineIn::reverse() const { return EaseSineOut::create(_inner->reverse()); } // // EaseSineOut // EaseSineOut* EaseSineOut::create(ActionInterval* action) { EaseSineOut *ret = new EaseSineOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseSineOut* EaseSineOut::clone() const { // no copy constructor auto a = new EaseSineOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseSineOut::update(float time) { _inner->update(sinf(time * (float)M_PI_2)); } ActionEase* EaseSineOut::reverse(void) const { return EaseSineIn::create(_inner->reverse()); } // // EaseSineInOut // EaseSineInOut* EaseSineInOut::create(ActionInterval* action) { EaseSineInOut *ret = new EaseSineInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseSineInOut* EaseSineInOut::clone() const { // no copy constructor auto a = new EaseSineInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseSineInOut::update(float time) { _inner->update(-0.5f * (cosf((float)M_PI * time) - 1)); } EaseSineInOut* EaseSineInOut::reverse() const { return EaseSineInOut::create(_inner->reverse()); } // // EaseElastic // bool EaseElastic::initWithAction(ActionInterval *action, float period/* = 0.3f*/) { if (ActionEase::initWithAction(action)) { _period = period; return true; } return false; } // // EaseElasticIn // EaseElasticIn* EaseElasticIn::create(ActionInterval *action) { return EaseElasticIn::create(action, 0.3f); } EaseElasticIn* EaseElasticIn::create(ActionInterval *action, float period/* = 0.3f*/) { EaseElasticIn *ret = new EaseElasticIn(); if (ret) { if (ret->initWithAction(action, period)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseElasticIn* EaseElasticIn::clone() const { // no copy constructor auto a = new EaseElasticIn(); a->initWithAction(_inner->clone(), _period); a->autorelease(); return a; } void EaseElasticIn::update(float time) { float newT = 0; if (time == 0 || time == 1) { newT = time; } else { float s = _period / 4; time = time - 1; newT = -powf(2, 10 * time) * sinf((time - s) * M_PI_X_2 / _period); } _inner->update(newT); } EaseElastic* EaseElasticIn::reverse() const { return EaseElasticOut::create(_inner->reverse(), _period); } // // EaseElasticOut // EaseElasticOut* EaseElasticOut::create(ActionInterval *action) { return EaseElasticOut::create(action, 0.3f); } EaseElasticOut* EaseElasticOut::create(ActionInterval *action, float period/* = 0.3f*/) { EaseElasticOut *ret = new EaseElasticOut(); if (ret) { if (ret->initWithAction(action, period)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseElasticOut* EaseElasticOut::clone() const { // no copy constructor auto a = new EaseElasticOut(); a->initWithAction(_inner->clone(), _period); a->autorelease(); return a; } void EaseElasticOut::update(float time) { float newT = 0; if (time == 0 || time == 1) { newT = time; } else { float s = _period / 4; newT = powf(2, -10 * time) * sinf((time - s) * M_PI_X_2 / _period) + 1; } _inner->update(newT); } EaseElastic* EaseElasticOut::reverse() const { return EaseElasticIn::create(_inner->reverse(), _period); } // // EaseElasticInOut // EaseElasticInOut* EaseElasticInOut::create(ActionInterval *action) { return EaseElasticInOut::create(action, 0.3f); } EaseElasticInOut* EaseElasticInOut::create(ActionInterval *action, float period/* = 0.3f*/) { EaseElasticInOut *ret = new EaseElasticInOut(); if (ret) { if (ret->initWithAction(action, period)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseElasticInOut* EaseElasticInOut::clone() const { // no copy constructor auto a = new EaseElasticInOut(); a->initWithAction(_inner->clone(), _period); a->autorelease(); return a; } void EaseElasticInOut::update(float time) { float newT = 0; if (time == 0 || time == 1) { newT = time; } else { time = time * 2; if ( _period == 0) { _period = 0.3f * 1.5f; } float s = _period / 4; time = time - 1; if (time < 0) { newT = -0.5f * powf(2, 10 * time) * sinf((time -s) * M_PI_X_2 / _period); } else { newT = powf(2, -10 * time) * sinf((time - s) * M_PI_X_2 / _period) * 0.5f + 1; } } _inner->update(newT); } EaseElasticInOut* EaseElasticInOut::reverse() const { return EaseElasticInOut::create(_inner->reverse(), _period); } // // EaseBounce // float EaseBounce::bounceTime(float time) { if (time < 1 / 2.75) { return 7.5625f * time * time; } else if (time < 2 / 2.75) { time -= 1.5f / 2.75f; return 7.5625f * time * time + 0.75f; } else if(time < 2.5 / 2.75) { time -= 2.25f / 2.75f; return 7.5625f * time * time + 0.9375f; } time -= 2.625f / 2.75f; return 7.5625f * time * time + 0.984375f; } // // EaseBounceIn // EaseBounceIn* EaseBounceIn::create(ActionInterval* action) { EaseBounceIn *ret = new EaseBounceIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseBounceIn* EaseBounceIn::clone() const { // no copy constructor auto a = new EaseBounceIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseBounceIn::update(float time) { float newT = 1 - bounceTime(1 - time); _inner->update(newT); } EaseBounce* EaseBounceIn::reverse() const { return EaseBounceOut::create(_inner->reverse()); } // // EaseBounceOut // EaseBounceOut* EaseBounceOut::create(ActionInterval* action) { EaseBounceOut *ret = new EaseBounceOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseBounceOut* EaseBounceOut::clone() const { // no copy constructor auto a = new EaseBounceOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseBounceOut::update(float time) { float newT = bounceTime(time); _inner->update(newT); } EaseBounce* EaseBounceOut::reverse() const { return EaseBounceIn::create(_inner->reverse()); } // // EaseBounceInOut // EaseBounceInOut* EaseBounceInOut::create(ActionInterval* action) { EaseBounceInOut *ret = new EaseBounceInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseBounceInOut* EaseBounceInOut::clone() const { // no copy constructor auto a = new EaseBounceInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseBounceInOut::update(float time) { float newT = 0; if (time < 0.5f) { time = time * 2; newT = (1 - bounceTime(1 - time)) * 0.5f; } else { newT = bounceTime(time * 2 - 1) * 0.5f + 0.5f; } _inner->update(newT); } EaseBounceInOut* EaseBounceInOut::reverse() const { return EaseBounceInOut::create(_inner->reverse()); } // // EaseBackIn // EaseBackIn* EaseBackIn::create(ActionInterval *action) { EaseBackIn *ret = new EaseBackIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseBackIn* EaseBackIn::clone() const { // no copy constructor auto a = new EaseBackIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseBackIn::update(float time) { float overshoot = 1.70158f; _inner->update(time * time * ((overshoot + 1) * time - overshoot)); } ActionEase* EaseBackIn::reverse() const { return EaseBackOut::create(_inner->reverse()); } // // EaseBackOut // EaseBackOut* EaseBackOut::create(ActionInterval* action) { EaseBackOut *ret = new EaseBackOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseBackOut* EaseBackOut::clone() const { // no copy constructor auto a = new EaseBackOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseBackOut::update(float time) { float overshoot = 1.70158f; time = time - 1; _inner->update(time * time * ((overshoot + 1) * time + overshoot) + 1); } ActionEase* EaseBackOut::reverse() const { return EaseBackIn::create(_inner->reverse()); } // // EaseBackInOut // EaseBackInOut* EaseBackInOut::create(ActionInterval* action) { EaseBackInOut *ret = new EaseBackInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseBackInOut* EaseBackInOut::clone() const { // no copy constructor auto a = new EaseBackInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseBackInOut::update(float time) { float overshoot = 1.70158f * 1.525f; time = time * 2; if (time < 1) { _inner->update((time * time * ((overshoot + 1) * time - overshoot)) / 2); } else { time = time - 2; _inner->update((time * time * ((overshoot + 1) * time + overshoot)) / 2 + 1); } } EaseBackInOut* EaseBackInOut::reverse() const { return EaseBackInOut::create(_inner->reverse()); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionEase.h ================================================ /**************************************************************************** Copyright (c) 2008-2009 Jason Booth Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTION_CCEASE_ACTION_H__ #define __ACTION_CCEASE_ACTION_H__ #include "CCActionInterval.h" NS_CC_BEGIN class Object; /** * @addtogroup actions * @{ */ /** @brief Base class for Easing actions @ingroup Actions */ class CC_DLL ActionEase : public ActionInterval { public: virtual ActionInterval* getInnerAction(); // // Overrides // virtual ActionEase* clone() const override = 0; virtual ActionEase* reverse() const override = 0; virtual void startWithTarget(Node *target) override; virtual void stop() override; virtual void update(float time) override; protected: ActionEase() {} virtual ~ActionEase(); /** initializes the action */ bool initWithAction(ActionInterval *action); /** The inner action */ ActionInterval *_inner; private: CC_DISALLOW_COPY_AND_ASSIGN(ActionEase); }; /** @brief Base class for Easing actions with rate parameters @ingroup Actions */ class CC_DLL EaseRateAction : public ActionEase { public: /** set rate value for the actions */ inline void setRate(float rate) { _rate = rate; } /** get rate value for the actions */ inline float getRate() const { return _rate; } // // Overrides // virtual EaseRateAction* clone() const override = 0; virtual EaseRateAction* reverse() const override = 0; protected: EaseRateAction() {} virtual ~EaseRateAction(); /** Initializes the action with the inner action and the rate parameter */ bool initWithAction(ActionInterval *pAction, float fRate); float _rate; private: CC_DISALLOW_COPY_AND_ASSIGN(EaseRateAction); }; /** @brief EaseIn action with a rate @ingroup Actions */ class CC_DLL EaseIn : public EaseRateAction { public: /** Creates the action with the inner action and the rate parameter */ static EaseIn* create(ActionInterval* action, float rate); // Overrides virtual void update(float time) override; virtual EaseIn* clone() const override; virtual EaseIn* reverse() const override; protected: EaseIn() {} virtual ~EaseIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseIn); }; /** @brief EaseOut action with a rate @ingroup Actions */ class CC_DLL EaseOut : public EaseRateAction { public: /** Creates the action with the inner action and the rate parameter */ static EaseOut* create(ActionInterval* action, float rate); // Overrides virtual void update(float time) override; virtual EaseOut* clone() const override; virtual EaseOut* reverse() const override; protected: EaseOut() {} virtual ~EaseOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseOut); }; /** @brief EaseInOut action with a rate @ingroup Actions */ class CC_DLL EaseInOut : public EaseRateAction { public: /** Creates the action with the inner action and the rate parameter */ static EaseInOut* create(ActionInterval* action, float rate); // Overrides virtual void update(float time) override; virtual EaseInOut* clone() const override; virtual EaseInOut* reverse() const override; protected: EaseInOut() {} virtual ~EaseInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseInOut); }; /** @brief Ease Exponential In @ingroup Actions */ class CC_DLL EaseExponentialIn : public ActionEase { public: /** creates the action */ static EaseExponentialIn* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseExponentialIn* clone() const override; virtual ActionEase* reverse() const override; protected: EaseExponentialIn() {} virtual ~EaseExponentialIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseExponentialIn); }; /** @brief Ease Exponential Out @ingroup Actions */ class CC_DLL EaseExponentialOut : public ActionEase { public: /** creates the action */ static EaseExponentialOut* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseExponentialOut* clone() const override; virtual ActionEase* reverse() const override; protected: EaseExponentialOut() {} virtual ~EaseExponentialOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseExponentialOut); }; /** @brief Ease Exponential InOut @ingroup Actions */ class CC_DLL EaseExponentialInOut : public ActionEase { public: /** creates the action */ static EaseExponentialInOut* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseExponentialInOut* clone() const override; virtual EaseExponentialInOut* reverse() const override; protected: EaseExponentialInOut() {} virtual ~EaseExponentialInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseExponentialInOut); }; /** @brief Ease Sine In @ingroup Actions */ class CC_DLL EaseSineIn : public ActionEase { public: /** creates the action */ static EaseSineIn* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseSineIn* clone() const override; virtual ActionEase* reverse() const override; protected: EaseSineIn() {} virtual ~EaseSineIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseSineIn); }; /** @brief Ease Sine Out @ingroup Actions */ class CC_DLL EaseSineOut : public ActionEase { public: /** creates the action */ static EaseSineOut* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseSineOut* clone() const override; virtual ActionEase* reverse() const override; protected: EaseSineOut() {} virtual ~EaseSineOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseSineOut); }; /** @brief Ease Sine InOut @ingroup Actions */ class CC_DLL EaseSineInOut : public ActionEase { public: /** creates the action */ static EaseSineInOut* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseSineInOut* clone() const override; virtual EaseSineInOut* reverse() const override; protected: EaseSineInOut() {} virtual ~EaseSineInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseSineInOut); }; /** @brief Ease Elastic abstract class @since v0.8.2 @ingroup Actions */ class CC_DLL EaseElastic : public ActionEase { public: /** get period of the wave in radians. default is 0.3 */ inline float getPeriod() const { return _period; } /** set period of the wave in radians. */ inline void setPeriod(float fPeriod) { _period = fPeriod; } // // Overrides // virtual EaseElastic* clone() const override = 0; virtual EaseElastic* reverse() const override = 0; protected: EaseElastic() {} virtual ~EaseElastic() {} /** Initializes the action with the inner action and the period in radians (default is 0.3) */ bool initWithAction(ActionInterval *action, float period = 0.3f); float _period; private: CC_DISALLOW_COPY_AND_ASSIGN(EaseElastic); }; /** @brief Ease Elastic In action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseElasticIn : public EaseElastic { public: /** Creates the action with the inner action and the period in radians (default is 0.3) */ static EaseElasticIn* create(ActionInterval *action, float period); static EaseElasticIn* create(ActionInterval *action); // Overrides virtual void update(float time) override; virtual EaseElasticIn* clone() const override; virtual EaseElastic* reverse() const override; protected: EaseElasticIn() {} virtual ~EaseElasticIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseElasticIn); }; /** @brief Ease Elastic Out action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseElasticOut : public EaseElastic { public: /** Creates the action with the inner action and the period in radians (default is 0.3) */ static EaseElasticOut* create(ActionInterval *action, float period); static EaseElasticOut* create(ActionInterval *action); // Overrides virtual void update(float time) override; virtual EaseElasticOut* clone() const override; virtual EaseElastic* reverse() const override; protected: EaseElasticOut() {} virtual ~EaseElasticOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseElasticOut); }; /** @brief Ease Elastic InOut action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseElasticInOut : public EaseElastic { public: /** Creates the action with the inner action and the period in radians (default is 0.3) */ static EaseElasticInOut* create(ActionInterval *action, float period); static EaseElasticInOut* create(ActionInterval *action); // Overrides virtual void update(float time) override; virtual EaseElasticInOut* clone() const override; virtual EaseElasticInOut* reverse() const override; protected: EaseElasticInOut() {} virtual ~EaseElasticInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseElasticInOut); }; /** @brief EaseBounce abstract class. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseBounce : public ActionEase { public: float bounceTime(float time); // Overrides virtual EaseBounce* clone() const override = 0; virtual EaseBounce* reverse() const override = 0; protected: EaseBounce() {} virtual ~EaseBounce() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseBounce); }; /** @brief EaseBounceIn action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseBounceIn : public EaseBounce { public: /** creates the action */ static EaseBounceIn* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseBounceIn* clone() const override; virtual EaseBounce* reverse() const override; protected: EaseBounceIn() {} virtual ~EaseBounceIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseBounceIn); }; /** @brief EaseBounceOut action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseBounceOut : public EaseBounce { public: /** creates the action */ static EaseBounceOut* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseBounceOut* clone() const override; virtual EaseBounce* reverse() const override; protected: EaseBounceOut() {} virtual ~EaseBounceOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseBounceOut); }; /** @brief EaseBounceInOut action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseBounceInOut : public EaseBounce { public: /** creates the action */ static EaseBounceInOut* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseBounceInOut* clone() const override; virtual EaseBounceInOut* reverse() const override; protected: EaseBounceInOut() {} virtual ~EaseBounceInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseBounceInOut); }; /** @brief EaseBackIn action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseBackIn : public ActionEase { public: /** creates the action */ static EaseBackIn* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseBackIn* clone() const override; virtual ActionEase* reverse() const override; protected: EaseBackIn() {} virtual ~EaseBackIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseBackIn); }; /** @brief EaseBackOut action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseBackOut : public ActionEase { public: /** creates the action */ static EaseBackOut* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseBackOut* clone() const override; virtual ActionEase* reverse() const override; protected: EaseBackOut() {} virtual ~EaseBackOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseBackOut); }; /** @brief EaseBackInOut action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 @ingroup Actions */ class CC_DLL EaseBackInOut : public ActionEase { public: /** creates the action */ static EaseBackInOut* create(ActionInterval* action); // Overrides virtual void update(float time) override; virtual EaseBackInOut* clone() const override; virtual EaseBackInOut* reverse() const override; protected: EaseBackInOut() {} virtual ~EaseBackInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseBackInOut); }; // end of actions group /// @} NS_CC_END #endif // __ACTION_CCEASE_ACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionGrid.cpp ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionGrid.h" #include "CCDirector.h" #include "CCGrid.h" #include "CCNodeGrid.h" NS_CC_BEGIN // implementation of GridAction bool GridAction::initWithDuration(float duration, const Size& gridSize) { if (ActionInterval::initWithDuration(duration)) { _gridSize = gridSize; return true; } return false; } void GridAction::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); cacheTargetAsGridNode(); GridBase *newgrid = this->getGrid(); GridBase *targetGrid = _gridNodeTarget->getGrid(); if (targetGrid && targetGrid->getReuseGrid() > 0) { if (targetGrid->isActive() && targetGrid->getGridSize().width == _gridSize.width && targetGrid->getGridSize().height == _gridSize.height /*&& dynamic_cast(targetGrid) != nullptr*/) { targetGrid->reuse(); } else { CCASSERT(0, ""); } } else { if (targetGrid && targetGrid->isActive()) { targetGrid->setActive(false); } _gridNodeTarget->setGrid(newgrid); _gridNodeTarget->getGrid()->setActive(true); } } void GridAction::cacheTargetAsGridNode() { _gridNodeTarget = dynamic_cast (_target); CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid"); } GridAction* GridAction::reverse() const { // FIXME: This conversion isn't safe. return (GridAction*)ReverseTime::create( this->clone() ); } GridBase* GridAction::getGrid() { // Abstract class needs implementation CCASSERT(0, ""); return nullptr; } // implementation of Grid3DAction GridBase* Grid3DAction::getGrid() { return Grid3D::create(_gridSize); } Vertex3F Grid3DAction::getVertex(const Point& position) const { Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); return g->getVertex(position); } Vertex3F Grid3DAction::getOriginalVertex(const Point& position) const { Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); return g->getOriginalVertex(position); } void Grid3DAction::setVertex(const Point& position, const Vertex3F& vertex) { Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); g->setVertex(position, vertex); } // implementation of TiledGrid3DAction GridBase* TiledGrid3DAction::getGrid(void) { return TiledGrid3D::create(_gridSize); } Quad3 TiledGrid3DAction::getTile(const Point& pos) const { TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->getTile(pos); } Quad3 TiledGrid3DAction::getOriginalTile(const Point& pos) const { TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->getOriginalTile(pos); } void TiledGrid3DAction::setTile(const Point& pos, const Quad3& coords) { TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->setTile(pos, coords); } // implementation AccelDeccelAmplitude AccelDeccelAmplitude* AccelDeccelAmplitude::create(Action *action, float duration) { AccelDeccelAmplitude *ret = new AccelDeccelAmplitude(); if (ret) { if (ret->initWithAction(action, duration)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool AccelDeccelAmplitude::initWithAction(Action *action, float duration) { if (ActionInterval::initWithDuration(duration)) { _rate = 1.0f; _other = (ActionInterval*)(action); action->retain(); return true; } return false; } AccelDeccelAmplitude* AccelDeccelAmplitude::clone() const { // no copy constructor auto a = new AccelDeccelAmplitude(); a->initWithAction(_other->clone(), _rate); a->autorelease(); return a; } AccelDeccelAmplitude::~AccelDeccelAmplitude() { CC_SAFE_RELEASE(_other); } void AccelDeccelAmplitude::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _other->startWithTarget(target); } void AccelDeccelAmplitude::update(float time) { float f = time * 2; if (f > 1) { f -= 1; f = 1 - f; } ((AccelDeccelAmplitude*)(_other))->setAmplitudeRate(powf(f, _rate)); } AccelDeccelAmplitude* AccelDeccelAmplitude::reverse() const { return AccelDeccelAmplitude::create(_other->reverse(), _duration); } // implementation of AccelAmplitude AccelAmplitude* AccelAmplitude::create(Action *action, float duration) { AccelAmplitude *ret = new AccelAmplitude(); if (ret) { if (ret->initWithAction(action, duration)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool AccelAmplitude::initWithAction(Action *action, float duration) { if (ActionInterval::initWithDuration(duration)) { _rate = 1.0f; _other = (ActionInterval*)(action); action->retain(); return true; } return false; } AccelAmplitude* AccelAmplitude::clone() const { // no copy constructor auto a = new AccelAmplitude(); a->initWithAction(_other->clone(), _duration); a->autorelease(); return a; } AccelAmplitude::~AccelAmplitude(void) { CC_SAFE_DELETE(_other); } void AccelAmplitude::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _other->startWithTarget(target); } void AccelAmplitude::update(float time) { ((AccelAmplitude*)(_other))->setAmplitudeRate(powf(time, _rate)); _other->update(time); } AccelAmplitude* AccelAmplitude::reverse() const { return AccelAmplitude::create(_other->reverse(), _duration); } // DeccelAmplitude DeccelAmplitude* DeccelAmplitude::create(Action *action, float duration) { DeccelAmplitude *ret = new DeccelAmplitude(); if (ret) { if (ret->initWithAction(action, duration)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool DeccelAmplitude::initWithAction(Action *action, float duration) { if (ActionInterval::initWithDuration(duration)) { _rate = 1.0f; _other = (ActionInterval*)(action); action->retain(); return true; } return false; } DeccelAmplitude::~DeccelAmplitude() { CC_SAFE_RELEASE(_other); } void DeccelAmplitude::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _other->startWithTarget(target); } void DeccelAmplitude::update(float time) { ((DeccelAmplitude*)(_other))->setAmplitudeRate(powf((1 - time), _rate)); _other->update(time); } DeccelAmplitude* DeccelAmplitude::clone() const { // no copy constructor auto a = new DeccelAmplitude(); a->initWithAction(_other->clone(), _duration); a->autorelease(); return a; } DeccelAmplitude* DeccelAmplitude::reverse() const { return DeccelAmplitude::create(_other->reverse(), _duration); } // implementation of StopGrid void StopGrid::startWithTarget(Node *target) { ActionInstant::startWithTarget(target); cacheTargetAsGridNode(); GridBase *grid = _gridNodeTarget->getGrid(); if (grid && grid->isActive()) { grid->setActive(false); } } void StopGrid::cacheTargetAsGridNode() { _gridNodeTarget = dynamic_cast (_target); CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid"); } StopGrid* StopGrid::create() { StopGrid* pAction = new StopGrid(); pAction->autorelease(); return pAction; } StopGrid* StopGrid::clone() const { return StopGrid::create(); } StopGrid* StopGrid::reverse() const { // no reverse, just clone it return this->clone(); } // implementation of ReuseGrid ReuseGrid* ReuseGrid::create(int times) { ReuseGrid *action = new ReuseGrid(); if (action) { if (action->initWithTimes(times)) { action->autorelease(); } else { CC_SAFE_DELETE(action); } } return action; } bool ReuseGrid::initWithTimes(int times) { _times = times; return true; } void ReuseGrid::startWithTarget(Node *target) { ActionInstant::startWithTarget(target); cacheTargetAsGridNode(); if (_gridNodeTarget->getGrid() && _gridNodeTarget->getGrid()->isActive()) { _gridNodeTarget->getGrid()->setReuseGrid(_gridNodeTarget->getGrid()->getReuseGrid() + _times); } } void ReuseGrid::cacheTargetAsGridNode() { _gridNodeTarget = dynamic_cast (_target); CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid"); } ReuseGrid* ReuseGrid::clone() const { return ReuseGrid::create(_times); } ReuseGrid* ReuseGrid::reverse() const { // no reverse, just clone it return this->clone(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionGrid.h ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTION_CCGRID_ACTION_H__ #define __ACTION_CCGRID_ACTION_H__ #include "CCActionInterval.h" #include "CCActionInstant.h" NS_CC_BEGIN class GridBase; class NodeGrid; /** * @addtogroup actions * @{ */ /** @brief Base class for Grid actions */ class CC_DLL GridAction : public ActionInterval { public: /** returns the grid */ virtual GridBase* getGrid(); // overrides virtual GridAction * clone() const override = 0; virtual GridAction* reverse() const override; virtual void startWithTarget(Node *target) override; protected: GridAction() {} virtual ~GridAction() {} /** initializes the action with size and duration */ bool initWithDuration(float duration, const Size& gridSize); Size _gridSize; NodeGrid* _gridNodeTarget; void cacheTargetAsGridNode(); private: CC_DISALLOW_COPY_AND_ASSIGN(GridAction); }; /** @brief Base class for Grid3D actions. Grid3D actions can modify a non-tiled grid. */ class CC_DLL Grid3DAction : public GridAction { public: /** returns the grid */ virtual GridBase* getGrid(); /** returns the vertex than belongs to certain position in the grid * @js NA * @lua NA */ Vertex3F getVertex(const Point& position) const; /** @deprecated Use getVertex() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE inline Vertex3F vertex(const Point& position) { return getVertex(position); } /** returns the non-transformed vertex than belongs to certain position in the grid * @js NA * @lua NA */ Vertex3F getOriginalVertex(const Point& position) const; /** @deprecated Use getOriginalVertex() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE inline Vertex3F originalVertex(const Point& position) { return getOriginalVertex(position); } /** sets a new vertex to a certain position of the grid * @js NA * @lua NA */ void setVertex(const Point& position, const Vertex3F& vertex); // Overrides virtual Grid3DAction * clone() const override = 0; }; /** @brief Base class for TiledGrid3D actions */ class CC_DLL TiledGrid3DAction : public GridAction { public: /** creates the action with size and duration * @js NA * @lua NA */ static TiledGrid3DAction* create(float duration, const Size& gridSize); /** returns the tile that belongs to a certain position of the grid * @js NA * @lua NA */ Quad3 getTile(const Point& position) const; /** @deprecated Use getTile() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& position) { return getTile(position); } /** returns the non-transformed tile that belongs to a certain position of the grid * @js NA * @lua NA */ Quad3 getOriginalTile(const Point& position) const; /** @deprecated Use getOriginalTile() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& position) { return getOriginalTile(position); } /** sets a new tile to a certain position of the grid * @js NA * @lua NA */ void setTile(const Point& position, const Quad3& coords); /** returns the grid */ virtual GridBase* getGrid(); // Override virtual TiledGrid3DAction * clone() const override = 0; }; /** @brief AccelDeccelAmplitude action */ class CC_DLL AccelDeccelAmplitude : public ActionInterval { public: /** creates the action with an inner action that has the amplitude property, and a duration time */ static AccelDeccelAmplitude* create(Action *action, float duration); /** get amplitude rate */ inline float getRate(void) const { return _rate; } /** set amplitude rate */ inline void setRate(float fRate) { _rate = fRate; } // Overrides virtual void startWithTarget(Node *target) override; virtual void update(float time) override; virtual AccelDeccelAmplitude* clone() const override; virtual AccelDeccelAmplitude* reverse() const override; protected: AccelDeccelAmplitude() {} virtual ~AccelDeccelAmplitude(); /** initializes the action with an inner action that has the amplitude property, and a duration time */ bool initWithAction(Action *pAction, float duration); float _rate; ActionInterval *_other; private: CC_DISALLOW_COPY_AND_ASSIGN(AccelDeccelAmplitude); }; /** @brief AccelAmplitude action */ class CC_DLL AccelAmplitude : public ActionInterval { public: /** creates the action with an inner action that has the amplitude property, and a duration time */ static AccelAmplitude* create(Action *action, float duration); /** get amplitude rate */ inline float getRate() const { return _rate; } /** set amplitude rate */ inline void setRate(float rate) { _rate = rate; } // Overrides virtual void startWithTarget(Node *target) override; virtual void update(float time) override; virtual AccelAmplitude* clone() const override; virtual AccelAmplitude* reverse() const override; protected: AccelAmplitude() {} virtual ~AccelAmplitude(); bool initWithAction(Action *action, float duration); float _rate; ActionInterval *_other; private: CC_DISALLOW_COPY_AND_ASSIGN(AccelAmplitude); }; /** @brief DeccelAmplitude action */ class CC_DLL DeccelAmplitude : public ActionInterval { public: /** creates the action with an inner action that has the amplitude property, and a duration time */ static DeccelAmplitude* create(Action *action, float duration); /** get amplitude rate */ inline float getRate(void) const { return _rate; } /** set amplitude rate */ inline void setRate(float rate) { _rate = rate; } // overrides virtual void startWithTarget(Node *target) override; virtual void update(float time) override; virtual DeccelAmplitude* clone() const override; virtual DeccelAmplitude* reverse() const override; protected: DeccelAmplitude() {} virtual ~DeccelAmplitude(); /** initializes the action with an inner action that has the amplitude property, and a duration time */ bool initWithAction(Action *action, float duration); float _rate; ActionInterval *_other; private: CC_DISALLOW_COPY_AND_ASSIGN(DeccelAmplitude); }; /** @brief StopGrid action. @warning Don't call this action if another grid action is active. Call if you want to remove the the grid effect. Example: Sequence::actions(Lens::action(...), StopGrid::action(...), nullptr); */ class CC_DLL StopGrid : public ActionInstant { public: /** Allocates and initializes the action */ static StopGrid* create(); // Overrides virtual void startWithTarget(Node *target) override; virtual StopGrid* clone() const override; virtual StopGrid* reverse() const override; protected: StopGrid() {} virtual ~StopGrid() {} NodeGrid* _gridNodeTarget; void cacheTargetAsGridNode(); private: CC_DISALLOW_COPY_AND_ASSIGN(StopGrid); }; /** @brief ReuseGrid action */ class CC_DLL ReuseGrid : public ActionInstant { public: /** creates an action with the number of times that the current grid will be reused */ static ReuseGrid* create(int times); // Override virtual void startWithTarget(Node *target) override; virtual ReuseGrid* clone() const override; virtual ReuseGrid* reverse() const override; protected: ReuseGrid() {} virtual ~ReuseGrid() {} /** initializes an action with the number of times that the current grid will be reused */ bool initWithTimes(int times); NodeGrid* _gridNodeTarget; void cacheTargetAsGridNode(); int _times; private: CC_DISALLOW_COPY_AND_ASSIGN(ReuseGrid); }; // end of actions group /// @} NS_CC_END #endif // __ACTION_CCGRID_ACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionGrid3D.cpp ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionGrid3D.h" #include "CCDirector.h" #include NS_CC_BEGIN // implementation of Waves3D Waves3D* Waves3D::create(float duration, const Size& gridSize, unsigned int waves, float amplitude) { Waves3D *pAction = new Waves3D(); if (pAction) { if (pAction->initWithDuration(duration, gridSize, waves, amplitude)) { pAction->autorelease(); } else { CC_SAFE_RELEASE_NULL(pAction); } } return pAction; } bool Waves3D::initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude) { if (Grid3DAction::initWithDuration(duration, gridSize)) { _waves = waves; _amplitude = amplitude; _amplitudeRate = 1.0f; return true; } return false; } Waves3D* Waves3D::clone() const { // no copy constructor auto a = new Waves3D(); a->initWithDuration(_duration, _gridSize, _waves, _amplitude); a->autorelease(); return a; } void Waves3D::update(float time) { int i, j; for (i = 0; i < _gridSize.width + 1; ++i) { for (j = 0; j < _gridSize.height + 1; ++j) { Vertex3F v = getOriginalVertex(Point(i ,j)); v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate); //CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate)); setVertex(Point(i, j), v); } } } // implementation of FlipX3D FlipX3D* FlipX3D::create(float duration) { FlipX3D *action = new FlipX3D(); if (action) { if (action->initWithDuration(duration)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool FlipX3D::initWithDuration(float duration) { return Grid3DAction::initWithDuration(duration, Size(1, 1)); } bool FlipX3D::initWithSize(const Size& gridSize, float duration) { if (gridSize.width != 1 || gridSize.height != 1) { // Grid size must be (1,1) CCASSERT(0, "Grid size must be (1,1)"); return false; } return Grid3DAction::initWithDuration(duration, gridSize); } FlipX3D* FlipX3D::clone() const { // no copy constructor auto a = new FlipX3D(); a->initWithSize(_gridSize, _duration); a->autorelease(); return a; } void FlipX3D::update(float time) { float angle = (float)M_PI * time; // 180 degrees float mz = sinf(angle); angle = angle / 2.0f; // x calculates degrees from 0 to 90 float mx = cosf(angle); Vertex3F v0, v1, v, diff; v0 = getOriginalVertex(Point(1, 1)); v1 = getOriginalVertex(Point(0, 0)); float x0 = v0.x; float x1 = v1.x; float x; Point a, b, c, d; if ( x0 > x1 ) { // Normal Grid a = Point(0,0); b = Point(0,1); c = Point(1,0); d = Point(1,1); x = x0; } else { // Reversed Grid c = Point(0,0); d = Point(0,1); a = Point(1,0); b = Point(1,1); x = x1; } diff.x = ( x - x * mx ); diff.z = fabsf( floorf( (x * mz) / 4.0f ) ); // bottom-left v = getOriginalVertex(a); v.x = diff.x; v.z += diff.z; setVertex(a, v); // upper-left v = getOriginalVertex(b); v.x = diff.x; v.z += diff.z; setVertex(b, v); // bottom-right v = getOriginalVertex(c); v.x -= diff.x; v.z -= diff.z; setVertex(c, v); // upper-right v = getOriginalVertex(d); v.x -= diff.x; v.z -= diff.z; setVertex(d, v); } // implementation of FlipY3D FlipY3D* FlipY3D::clone() const { // no copy constructor auto a = new FlipY3D(); a->initWithSize(_gridSize, _duration); a->autorelease(); return a; } FlipY3D* FlipY3D::create(float duration) { FlipY3D *action = new FlipY3D(); if (action) { if (action->initWithDuration(duration)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } void FlipY3D::update(float time) { float angle = (float)M_PI * time; // 180 degrees float mz = sinf( angle ); angle = angle / 2.0f; // x calculates degrees from 0 to 90 float my = cosf(angle); Vertex3F v0, v1, v, diff; v0 = getOriginalVertex(Point(1, 1)); v1 = getOriginalVertex(Point(0, 0)); float y0 = v0.y; float y1 = v1.y; float y; Point a, b, c, d; if (y0 > y1) { // Normal Grid a = Point(0,0); b = Point(0,1); c = Point(1,0); d = Point(1,1); y = y0; } else { // Reversed Grid b = Point(0,0); a = Point(0,1); d = Point(1,0); c = Point(1,1); y = y1; } diff.y = y - y * my; diff.z = fabsf(floorf((y * mz) / 4.0f)); // bottom-left v = getOriginalVertex(a); v.y = diff.y; v.z += diff.z; setVertex(a, v); // upper-left v = getOriginalVertex(b); v.y -= diff.y; v.z -= diff.z; setVertex(b, v); // bottom-right v = getOriginalVertex(c); v.y = diff.y; v.z += diff.z; setVertex(c, v); // upper-right v = getOriginalVertex(d); v.y -= diff.y; v.z -= diff.z; setVertex(d, v); } // implementation of Lens3D Lens3D* Lens3D::create(float duration, const Size& gridSize, const Point& position, float radius) { Lens3D *action = new Lens3D(); if (action) { if (action->initWithDuration(duration, gridSize, position, radius)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Point& position, float radius) { if (Grid3DAction::initWithDuration(duration, gridSize)) { _position = Point(-1, -1); setPosition(position); _radius = radius; _lensEffect = 0.7f; _concave = false; _dirty = true; return true; } return false; } Lens3D* Lens3D::clone() const { // no copy constructor auto a = new Lens3D(); a->initWithDuration(_duration, _gridSize, _position, _radius); a->autorelease(); return a; } void Lens3D::setPosition(const Point& pos) { if( !pos.equals(_position)) { _position = pos; _dirty = true; } } void Lens3D::update(float time) { CC_UNUSED_PARAM(time); if (_dirty) { int i, j; for (i = 0; i < _gridSize.width + 1; ++i) { for (j = 0; j < _gridSize.height + 1; ++j) { Vertex3F v = getOriginalVertex(Point(i, j)); Point vect = _position - Point(v.x, v.y); float r = vect.getLength(); if (r < _radius) { r = _radius - r; float pre_log = r / _radius; if ( pre_log == 0 ) { pre_log = 0.001f; } float l = logf(pre_log) * _lensEffect; float new_r = expf( l ) * _radius; if (vect.getLength() > 0) { vect = vect.normalize(); Point new_vect = vect * new_r; v.z += (_concave ? -1.0f : 1.0f) * new_vect.getLength() * _lensEffect; } } setVertex(Point(i, j), v); } } _dirty = false; } } // implementation of Ripple3D Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude) { Ripple3D *action = new Ripple3D(); if (action) { if (action->initWithDuration(duration, gridSize, position, radius, waves, amplitude)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude) { if (Grid3DAction::initWithDuration(duration, gridSize)) { setPosition(position); _radius = radius; _waves = waves; _amplitude = amplitude; _amplitudeRate = 1.0f; return true; } return false; } void Ripple3D::setPosition(const Point& position) { _position = position; } Ripple3D* Ripple3D::clone() const { // no copy constructor auto a = new Ripple3D(); a->initWithDuration(_duration, _gridSize, _position, _radius, _waves, _amplitude); a->autorelease(); return a; } void Ripple3D::update(float time) { int i, j; for (i = 0; i < (_gridSize.width+1); ++i) { for (j = 0; j < (_gridSize.height+1); ++j) { Vertex3F v = getOriginalVertex(Point(i, j)); Point vect = _position - Point(v.x,v.y); float r = vect.getLength(); if (r < _radius) { r = _radius - r; float rate = powf(r / _radius, 2); v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate); } setVertex(Point(i, j), v); } } } // implementation of Shaky3D Shaky3D* Shaky3D::create(float duration, const Size& gridSize, int range, bool shakeZ) { Shaky3D *action = new Shaky3D(); if (action) { if (action->initWithDuration(duration, gridSize, range, shakeZ)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool Shaky3D::initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ) { if (Grid3DAction::initWithDuration(duration, gridSize)) { _randrange = range; _shakeZ = shakeZ; return true; } return false; } Shaky3D* Shaky3D::clone() const { // no copy constructor auto a = new Shaky3D(); a->initWithDuration(_duration, _gridSize, _randrange, _shakeZ); a->autorelease(); return a; } void Shaky3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; for (i = 0; i < (_gridSize.width+1); ++i) { for (j = 0; j < (_gridSize.height+1); ++j) { Vertex3F v = getOriginalVertex(Point(i ,j)); v.x += (rand() % (_randrange*2)) - _randrange; v.y += (rand() % (_randrange*2)) - _randrange; if (_shakeZ) { v.z += (rand() % (_randrange*2)) - _randrange; } setVertex(Point(i, j), v); } } } // implementation of Liquid Liquid* Liquid::create(float duration, const Size& gridSize, unsigned int waves, float amplitude) { Liquid *action = new Liquid(); if (action) { if (action->initWithDuration(duration, gridSize, waves, amplitude)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool Liquid::initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude) { if (Grid3DAction::initWithDuration(duration, gridSize)) { _waves = waves; _amplitude = amplitude; _amplitudeRate = 1.0f; return true; } return false; } Liquid* Liquid::clone() const { // no copy constructor auto a = new Liquid(); a->initWithDuration(_duration, _gridSize, _waves, _amplitude); a->autorelease(); return a; } void Liquid::update(float time) { int i, j; for (i = 1; i < _gridSize.width; ++i) { for (j = 1; j < _gridSize.height; ++j) { Vertex3F v = getOriginalVertex(Point(i, j)); v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate)); v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate)); setVertex(Point(i, j), v); } } } // implementation of Waves Waves* Waves::create(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical) { Waves *action = new Waves(); if (action) { if (action->initWithDuration(duration, gridSize, waves, amplitude, horizontal, vertical)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool Waves::initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical) { if (Grid3DAction::initWithDuration(duration, gridSize)) { _waves = waves; _amplitude = amplitude; _amplitudeRate = 1.0f; _horizontal = horizontal; _vertical = vertical; return true; } return false; } Waves* Waves::clone() const { // no copy constructor auto a = new Waves(); a->initWithDuration(_duration, _gridSize, _waves, _amplitude, _horizontal, _vertical); a->autorelease(); return a; } void Waves::update(float time) { int i, j; for (i = 0; i < _gridSize.width + 1; ++i) { for (j = 0; j < _gridSize.height + 1; ++j) { Vertex3F v = getOriginalVertex(Point(i, j)); if (_vertical) { v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate)); } if (_horizontal) { v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate)); } setVertex(Point(i, j), v); } } } // implementation of Twirl Twirl* Twirl::create(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude) { Twirl *action = new Twirl(); if (action) { if (action->initWithDuration(duration, gridSize, position, twirls, amplitude)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool Twirl::initWithDuration(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude) { if (Grid3DAction::initWithDuration(duration, gridSize)) { setPosition(position); _twirls = twirls; _amplitude = amplitude; _amplitudeRate = 1.0f; return true; } return false; } void Twirl::setPosition(const Point& position) { _position = position; } Twirl *Twirl::clone() const { // no copy constructor auto a = new Twirl(); a->initWithDuration(_duration, _gridSize, _position, _twirls, _amplitude); a->autorelease(); return a; } void Twirl::update(float time) { int i, j; Point c = _position; for (i = 0; i < (_gridSize.width+1); ++i) { for (j = 0; j < (_gridSize.height+1); ++j) { Vertex3F v = getOriginalVertex(Point(i ,j)); Point avg = Point(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f)); float r = avg.getLength(); float amp = 0.1f * _amplitude * _amplitudeRate; float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * _twirls * 2 ) * amp; Point d = Point( sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x), cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x)); v.x = c.x + d.x; v.y = c.y + d.y; setVertex(Point(i ,j), v); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionGrid3D.h ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTION_CCGRID3D_ACTION_H__ #define __ACTION_CCGRID3D_ACTION_H__ #include "CCActionGrid.h" NS_CC_BEGIN /** * @addtogroup actions * @{ */ /** @brief Waves3D action */ class CC_DLL Waves3D : public Grid3DAction { public: /** creates an action with duration, grid size, waves and amplitude */ static Waves3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude); /** returns the amplitude of the effect */ inline float getAmplitude() const { return _amplitude; } /** sets the amplitude to the effect */ inline void setAmplitude(float amplitude) { _amplitude = amplitude; } /** returns the amplitude rate */ inline float getAmplitudeRate() const { return _amplitudeRate; } /** sets the ampliture rate */ inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; } // Overrides virtual Waves3D* clone() const override; virtual void update(float time) override; protected: Waves3D() {} virtual ~Waves3D() {} /** initializes an action with duration, grid size, waves and amplitude */ bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude); unsigned int _waves; float _amplitude; float _amplitudeRate; private: CC_DISALLOW_COPY_AND_ASSIGN(Waves3D); }; /** @brief FlipX3D action */ class CC_DLL FlipX3D : public Grid3DAction { public: /** creates the action with duration */ static FlipX3D* create(float duration); // Override virtual FlipX3D* clone() const override; virtual void update(float time) override; protected: FlipX3D() {} virtual ~FlipX3D() {} /** initializes the action with duration */ bool initWithDuration(float duration); virtual bool initWithSize(const Size& gridSize, float duration); private: CC_DISALLOW_COPY_AND_ASSIGN(FlipX3D); }; /** @brief FlipY3D action */ class CC_DLL FlipY3D : public FlipX3D { public: FlipY3D() {} virtual ~FlipY3D() {} /** creates the action with duration */ static FlipY3D* create(float duration); // Overrides virtual void update(float time) override; virtual FlipY3D* clone() const override; private: CC_DISALLOW_COPY_AND_ASSIGN(FlipY3D); }; /** @brief Lens3D action */ class CC_DLL Lens3D : public Grid3DAction { public: /** creates the action with center position, radius, a grid size and duration */ static Lens3D* create(float duration, const Size& gridSize, const Point& position, float radius); /** Get lens center position */ inline float getLensEffect() const { return _lensEffect; } /** Set lens center position */ inline void setLensEffect(float lensEffect) { _lensEffect = lensEffect; } /** Set whether lens is concave */ inline void setConcave(bool concave) { _concave = concave; } inline const Point& getPosition() const { return _position; } void setPosition(const Point& position); // Overrides virtual Lens3D* clone() const override; virtual void update(float time) override; protected: Lens3D() {} virtual ~Lens3D() {} /** initializes the action with center position, radius, a grid size and duration */ bool initWithDuration(float duration, const Size& gridSize, const Point& position, float radius); /* lens center position */ Point _position; float _radius; /** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */ float _lensEffect; /** lens is concave. (true = concave, false = convex) default is convex i.e. false */ bool _concave; bool _dirty; private: CC_DISALLOW_COPY_AND_ASSIGN(Lens3D); }; /** @brief Ripple3D action */ class CC_DLL Ripple3D : public Grid3DAction { public: /** creates the action with radius, number of waves, amplitude, a grid size and duration */ static Ripple3D* create(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude); /** get center position */ inline const Point& getPosition() const { return _position; } /** set center position */ void setPosition(const Point& position); inline float getAmplitude() const { return _amplitude; } inline void setAmplitude(float fAmplitude) { _amplitude = fAmplitude; } inline float getAmplitudeRate() const { return _amplitudeRate; } inline void setAmplitudeRate(float fAmplitudeRate) { _amplitudeRate = fAmplitudeRate; } // Override virtual Ripple3D* clone() const override; virtual void update(float time) override; protected: Ripple3D() {} virtual ~Ripple3D() {} /** initializes the action with radius, number of waves, amplitude, a grid size and duration */ bool initWithDuration(float duration, const Size& gridSize, const Point& position, float radius, unsigned int waves, float amplitude); /* center position */ Point _position; float _radius; unsigned int _waves; float _amplitude; float _amplitudeRate; private: CC_DISALLOW_COPY_AND_ASSIGN(Ripple3D); }; /** @brief Shaky3D action */ class CC_DLL Shaky3D : public Grid3DAction { public: Shaky3D() {} virtual ~Shaky3D() {} /** creates the action with a range, shake Z vertices, a grid and duration */ static Shaky3D* create(float duration, const Size& gridSize, int range, bool shakeZ); // Overrides virtual Shaky3D* clone() const override; virtual void update(float time) override; protected: /** initializes the action with a range, shake Z vertices, a grid and duration */ bool initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ); int _randrange; bool _shakeZ; private: CC_DISALLOW_COPY_AND_ASSIGN(Shaky3D); }; /** @brief Liquid action */ class CC_DLL Liquid : public Grid3DAction { public: Liquid() {} virtual ~Liquid() {} /** creates the action with amplitude, a grid and duration */ static Liquid* create(float duration, const Size& gridSize, unsigned int waves, float amplitude); inline float getAmplitude() const { return _amplitude; } inline void setAmplitude(float amplitude) { _amplitude = amplitude; } inline float getAmplitudeRate() const { return _amplitudeRate; } inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; } // Overrides virtual Liquid* clone() const override; virtual void update(float time) override; protected: /** initializes the action with amplitude, a grid and duration */ bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude); unsigned int _waves; float _amplitude; float _amplitudeRate; private: CC_DISALLOW_COPY_AND_ASSIGN(Liquid); }; /** @brief Waves action */ class CC_DLL Waves : public Grid3DAction { public: Waves() {} virtual ~Waves() {} /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ static Waves* create(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical); inline float getAmplitude() const { return _amplitude; } inline void setAmplitude(float amplitude) { _amplitude = amplitude; } inline float getAmplitudeRate() const { return _amplitudeRate; } inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; } // Overrides virtual Waves* clone() const override; virtual void update(float time) override; protected: /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical); unsigned int _waves; float _amplitude; float _amplitudeRate; bool _vertical; bool _horizontal; private: CC_DISALLOW_COPY_AND_ASSIGN(Waves); }; /** @brief Twirl action */ class CC_DLL Twirl : public Grid3DAction { public: Twirl() {} virtual ~Twirl() {} /** creates the action with center position, number of twirls, amplitude, a grid size and duration */ static Twirl* create(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude); /** get twirl center */ inline const Point& getPosition() const { return _position; } /** set twirl center */ void setPosition(const Point& position); inline float getAmplitude() const { return _amplitude; } inline void setAmplitude(float amplitude) { _amplitude = amplitude; } inline float getAmplitudeRate() const { return _amplitudeRate; } inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; } // Overrides virtual Twirl* clone() const override; virtual void update(float time) override; protected: /** initializes the action with center position, number of twirls, amplitude, a grid size and duration */ bool initWithDuration(float duration, const Size& gridSize, Point position, unsigned int twirls, float amplitude); /* twirl center */ Point _position; unsigned int _twirls; float _amplitude; float _amplitudeRate; private: CC_DISALLOW_COPY_AND_ASSIGN(Twirl); }; // end of actions group /// @} NS_CC_END #endif // __ACTION_CCGRID3D_ACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionInstant.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionInstant.h" #include "CCNode.h" #include "CCSprite.h" #include "CCScriptSupport.h" #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (push) #pragma warning (disable: 4996) #endif NS_CC_BEGIN // // InstantAction // bool ActionInstant::isDone() const { return true; } void ActionInstant::step(float dt) { CC_UNUSED_PARAM(dt); update(1); } void ActionInstant::update(float time) { CC_UNUSED_PARAM(time); // nothing } // // Show // Show* Show::create() { Show* ret = new Show(); if (ret) { ret->autorelease(); } return ret; } void Show::update(float time) { CC_UNUSED_PARAM(time); _target->setVisible(true); } ActionInstant* Show::reverse() const { return Hide::create(); } Show * Show::clone() const { // no copy constructor auto a = new Show(); a->autorelease(); return a; } // // Hide // Hide * Hide::create() { Hide *ret = new Hide(); if (ret) { ret->autorelease(); } return ret; } void Hide::update(float time) { CC_UNUSED_PARAM(time); _target->setVisible(false); } ActionInstant *Hide::reverse() const { return Show::create(); } Hide * Hide::clone() const { // no copy constructor auto a = new Hide(); a->autorelease(); return a; } // // ToggleVisibility // ToggleVisibility * ToggleVisibility::create() { ToggleVisibility *ret = new ToggleVisibility(); if (ret) { ret->autorelease(); } return ret; } void ToggleVisibility::update(float time) { CC_UNUSED_PARAM(time); _target->setVisible(!_target->isVisible()); } ToggleVisibility * ToggleVisibility::reverse() const { return ToggleVisibility::create(); } ToggleVisibility * ToggleVisibility::clone() const { // no copy constructor auto a = new ToggleVisibility(); a->autorelease(); return a; } // // Remove Self // RemoveSelf * RemoveSelf::create(bool isNeedCleanUp /*= true*/) { RemoveSelf *ret = new RemoveSelf(); if (ret && ret->init(isNeedCleanUp)) { ret->autorelease(); } return ret; } bool RemoveSelf::init(bool isNeedCleanUp) { _isNeedCleanUp = isNeedCleanUp; return true; } void RemoveSelf::update(float time) { CC_UNUSED_PARAM(time); _target->removeFromParentAndCleanup(_isNeedCleanUp); } RemoveSelf *RemoveSelf::reverse() const { return RemoveSelf::create(_isNeedCleanUp); } RemoveSelf * RemoveSelf::clone() const { // no copy constructor auto a = new RemoveSelf(); a->init(_isNeedCleanUp); a->autorelease(); return a; } // // FlipX // FlipX *FlipX::create(bool x) { FlipX *ret = new FlipX(); if (ret && ret->initWithFlipX(x)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool FlipX::initWithFlipX(bool x) { _flipX = x; return true; } void FlipX::update(float time) { CC_UNUSED_PARAM(time); static_cast(_target)->setFlippedX(_flipX); } FlipX* FlipX::reverse() const { return FlipX::create(!_flipX); } FlipX * FlipX::clone() const { // no copy constructor auto a = new FlipX(); a->initWithFlipX(_flipX); a->autorelease(); return a; } // // FlipY // FlipY * FlipY::create(bool y) { FlipY *ret = new FlipY(); if (ret && ret->initWithFlipY(y)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool FlipY::initWithFlipY(bool y) { _flipY = y; return true; } void FlipY::update(float time) { CC_UNUSED_PARAM(time); static_cast(_target)->setFlippedY(_flipY); } FlipY* FlipY::reverse() const { return FlipY::create(!_flipY); } FlipY * FlipY::clone() const { // no copy constructor auto a = new FlipY(); a->initWithFlipY(_flipY); a->autorelease(); return a; } // // Place // Place* Place::create(const Point& pos) { Place *ret = new Place(); if (ret && ret->initWithPosition(pos)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool Place::initWithPosition(const Point& pos) { _position = pos; return true; } Place * Place::clone() const { // no copy constructor auto a = new Place(); a->initWithPosition(_position); a->autorelease(); return a; } Place * Place::reverse() const { // no reverse, just clone return this->clone(); } void Place::update(float time) { CC_UNUSED_PARAM(time); _target->setPosition(_position); } // // CallFunc // CallFunc * CallFunc::create(const std::function &func) { CallFunc *ret = new CallFunc(); if (ret && ret->initWithFunction(func) ) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } CallFunc * CallFunc::create(Object* selectorTarget, SEL_CallFunc selector) { CallFunc *ret = new CallFunc(); if (ret && ret->initWithTarget(selectorTarget)) { ret->_callFunc = selector; ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool CallFunc::initWithFunction(const std::function &func) { _function = func; return true; } bool CallFunc::initWithTarget(Object* target) { if (target) { target->retain(); } if (_selectorTarget) { _selectorTarget->release(); } _selectorTarget = target; return true; } CallFunc::~CallFunc() { CC_SAFE_RELEASE(_selectorTarget); } CallFunc * CallFunc::clone() const { // no copy constructor auto a = new CallFunc(); if( _selectorTarget) { a->initWithTarget(_selectorTarget); a->_callFunc = _callFunc; } else if( _function ){ a->initWithFunction(_function); } a->autorelease(); return a; } CallFunc * CallFunc::reverse() const { // no reverse here, just return a clone return this->clone(); } void CallFunc::update(float time) { CC_UNUSED_PARAM(time); this->execute(); } void CallFunc::execute() { if (_callFunc) { (_selectorTarget->*_callFunc)(); } else if( _function ){ _function(); } } // // CallFuncN // CallFuncN * CallFuncN::create(const std::function &func) { auto ret = new CallFuncN(); if (ret && ret->initWithFunction(func) ) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } // XXX deprecated CallFuncN * CallFuncN::create(Object* selectorTarget, SEL_CallFuncN selector) { CallFuncN *ret = new CallFuncN(); if (ret && ret->initWithTarget(selectorTarget, selector)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } void CallFuncN::execute() { if (_callFuncN) { (_selectorTarget->*_callFuncN)(_target); } else if (_functionN) { _functionN(_target); } } bool CallFuncN::initWithFunction(const std::function &func) { _functionN = func; return true; } bool CallFuncN::initWithTarget(Object* selectorTarget, SEL_CallFuncN selector) { if (CallFunc::initWithTarget(selectorTarget)) { _callFuncN = selector; return true; } return false; } CallFuncN * CallFuncN::clone() const { // no copy constructor auto a = new CallFuncN(); if( _selectorTarget) { a->initWithTarget(_selectorTarget, _callFuncN); } else if( _functionN ){ a->initWithFunction(_functionN); } a->autorelease(); return a; } // // CallFuncND // __CCCallFuncND * __CCCallFuncND::create(Object* selectorTarget, SEL_CallFuncND selector, void* d) { __CCCallFuncND* ret = new __CCCallFuncND(); if (ret && ret->initWithTarget(selectorTarget, selector, d)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool __CCCallFuncND::initWithTarget(Object* selectorTarget, SEL_CallFuncND selector, void* d) { if (CallFunc::initWithTarget(selectorTarget)) { _data = d; _callFuncND = selector; return true; } return false; } void __CCCallFuncND::execute() { if (_callFuncND) { (_selectorTarget->*_callFuncND)(_target, _data); } } __CCCallFuncND * __CCCallFuncND::clone() const { // no copy constructor auto a = new __CCCallFuncND(); if( _selectorTarget) { a->initWithTarget(_selectorTarget, _callFuncND, _data); } a->autorelease(); return a; } // // CallFuncO // __CCCallFuncO::__CCCallFuncO() : _object(nullptr) { } __CCCallFuncO::~__CCCallFuncO() { CC_SAFE_RELEASE(_object); } void __CCCallFuncO::execute() { if (_callFuncO) { (_selectorTarget->*_callFuncO)(_object); } } __CCCallFuncO * __CCCallFuncO::create(Object* selectorTarget, SEL_CallFuncO selector, Object* object) { __CCCallFuncO *ret = new __CCCallFuncO(); if (ret && ret->initWithTarget(selectorTarget, selector, object)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool __CCCallFuncO::initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, Object* object) { if (CallFunc::initWithTarget(selectorTarget)) { _object = object; CC_SAFE_RETAIN(_object); _callFuncO = selector; return true; } return false; } __CCCallFuncO * __CCCallFuncO::clone() const { // no copy constructor auto a = new __CCCallFuncO(); if( _selectorTarget) { a->initWithTarget(_selectorTarget, _callFuncO, _object); } a->autorelease(); return a; } Object* __CCCallFuncO::getObject() const { return _object; } void __CCCallFuncO::setObject(Object* obj) { if (obj != _object) { CC_SAFE_RELEASE(_object); _object = obj; CC_SAFE_RETAIN(_object); } } NS_CC_END #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic warning "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (pop) #endif ================================================ FILE: cocos2d/cocos/2d/CCActionInstant.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCINSTANT_ACTION_H__ #define __CCINSTANT_ACTION_H__ #include #include #include "CCStdC.h" #include "CCAction.h" NS_CC_BEGIN /** * @addtogroup actions * @{ */ /** @brief Instant actions are immediate actions. They don't have a duration like the IntervalAction actions. */ class CC_DLL ActionInstant : public FiniteTimeAction // { public: // // Overrides // virtual ActionInstant* clone() const override = 0; virtual ActionInstant * reverse() const override = 0; virtual bool isDone() const override; virtual void step(float dt) override; virtual void update(float time) override; }; /** @brief Show the node */ class CC_DLL Show : public ActionInstant { public: /** Allocates and initializes the action */ static Show * create(); // // Overrides // virtual void update(float time) override; virtual ActionInstant* reverse() const override; virtual Show* clone() const override; protected: Show(){} virtual ~Show(){} private: CC_DISALLOW_COPY_AND_ASSIGN(Show); }; /** @brief Hide the node */ class CC_DLL Hide : public ActionInstant { public: /** Allocates and initializes the action */ static Hide * create(); // // Overrides // virtual void update(float time) override; virtual ActionInstant* reverse() const override; virtual Hide* clone() const override; protected: Hide(){} virtual ~Hide(){} private: CC_DISALLOW_COPY_AND_ASSIGN(Hide); }; /** @brief Toggles the visibility of a node */ class CC_DLL ToggleVisibility : public ActionInstant { public: /** Allocates and initializes the action */ static ToggleVisibility * create(); // // Overrides // virtual void update(float time) override; virtual ToggleVisibility* reverse() const override; virtual ToggleVisibility* clone() const override; protected: ToggleVisibility(){} virtual ~ToggleVisibility(){} private: CC_DISALLOW_COPY_AND_ASSIGN(ToggleVisibility); }; /** @brief Remove the node */ class CC_DLL RemoveSelf : public ActionInstant { public: /** create the action */ static RemoveSelf * create(bool isNeedCleanUp = true); // // Override // virtual void update(float time) override; virtual RemoveSelf* clone() const override; virtual RemoveSelf* reverse() const override; protected: RemoveSelf() : _isNeedCleanUp(true){} virtual ~RemoveSelf(){} /** init the action */ bool init(bool isNeedCleanUp); bool _isNeedCleanUp; private: CC_DISALLOW_COPY_AND_ASSIGN(RemoveSelf); }; /** @brief Flips the sprite horizontally @since v0.99.0 */ class CC_DLL FlipX : public ActionInstant { public: /** create the action */ static FlipX * create(bool x); // // Overrides // virtual void update(float time) override; virtual FlipX* reverse() const override; virtual FlipX* clone() const override; protected: FlipX() :_flipX(false) {} virtual ~FlipX() {} /** init the action */ bool initWithFlipX(bool x); bool _flipX; private: CC_DISALLOW_COPY_AND_ASSIGN(FlipX); }; /** @brief Flips the sprite vertically @since v0.99.0 */ class CC_DLL FlipY : public ActionInstant { public: /** create the action */ static FlipY * create(bool y); // // Overrides // virtual void update(float time) override; virtual FlipY* reverse() const override; virtual FlipY* clone() const override; protected: FlipY() :_flipY(false) {} virtual ~FlipY() {} /** init the action */ bool initWithFlipY(bool y); bool _flipY; private: CC_DISALLOW_COPY_AND_ASSIGN(FlipY); }; /** @brief Places the node in a certain position */ class CC_DLL Place : public ActionInstant // { public: /** creates a Place action with a position */ static Place * create(const Point& pos); // // Overrides // virtual void update(float time) override; virtual Place* reverse() const override; virtual Place* clone() const override; protected: Place(){} virtual ~Place(){} /** Initializes a Place action with a position */ bool initWithPosition(const Point& pos); Point _position; private: CC_DISALLOW_COPY_AND_ASSIGN(Place); }; /** @brief Calls a 'callback' */ class CC_DLL CallFunc : public ActionInstant // { public: /** creates the action with the callback of type std::function. This is the preferred way to create the callback. * When this funtion bound in js or lua ,the input param will be changed * In js: var create(var func, var this, var [data]) or var create(var func) * In lua:local create(local funcID) */ static CallFunc * create(const std::function& func); /** creates the action with the callback typedef void (Object::*SEL_CallFunc)(); @deprecated Use the std::function API instead. * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Object* target, SEL_CallFunc selector); public: /** executes the callback */ virtual void execute(); inline Object* getTargetCallback() { return _selectorTarget; } inline void setTargetCallback(Object* sel) { if (sel != _selectorTarget) { CC_SAFE_RETAIN(sel); CC_SAFE_RELEASE(_selectorTarget); _selectorTarget = sel; } } // // Overrides // virtual void update(float time) override; virtual CallFunc* reverse() const override; virtual CallFunc* clone() const override; protected: CallFunc() : _selectorTarget(nullptr) , _callFunc(nullptr) , _function(nullptr) { } virtual ~CallFunc(); /** initializes the action with the callback typedef void (Object::*SEL_CallFunc)(); @deprecated Use the std::function API instead. */ CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* target); /** initializes the action with the std::function * @js NA * @lua NA */ bool initWithFunction(const std::function& func); /** Target that will be called */ Object* _selectorTarget; union { SEL_CallFunc _callFunc; SEL_CallFuncN _callFuncN; }; /** function that will be called */ std::function _function; private: CC_DISALLOW_COPY_AND_ASSIGN(CallFunc); }; /** @brief Calls a 'callback' with the node as the first argument N means Node */ class CC_DLL CallFuncN : public CallFunc { public: /** creates the action with the callback of type std::function. This is the preferred way to create the callback. */ static CallFuncN * create(const std::function& func); /** creates the action with the callback typedef void (Object::*SEL_CallFuncN)(Node*); @deprecated Use the std::function API instead. */ CC_DEPRECATED_ATTRIBUTE static CallFuncN * create(Object* target, SEL_CallFuncN selector); // // Overrides // virtual CallFuncN* clone() const override; virtual void execute() override; protected: CallFuncN():_functionN(nullptr){} virtual ~CallFuncN(){} /** initializes the action with the std::function */ bool initWithFunction(const std::function& func); /** initializes the action with the callback typedef void (Object::*SEL_CallFuncN)(Node*); @deprecated Use the std::function API instead. */ CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* target, SEL_CallFuncN selector); /** function that will be called with the "sender" as the 1st argument */ std::function _functionN; private: CC_DISALLOW_COPY_AND_ASSIGN(CallFuncN); }; /** @deprecated Please use CallFuncN instead. @brief Calls a 'callback' with the node as the first argument and the 2nd argument is data * ND means: Node and Data. Data is void *, so it could be anything. */ class CC_DLL __CCCallFuncND : public CallFunc { public: /** creates the action with the callback and the data to pass as an argument */ CC_DEPRECATED_ATTRIBUTE static __CCCallFuncND * create(Object* target, SEL_CallFuncND selector, void* d); // // Overrides // virtual __CCCallFuncND* clone() const override; virtual void execute() override; protected: __CCCallFuncND() {} virtual ~__CCCallFuncND() {} /** initializes the action with the callback and the data to pass as an argument */ bool initWithTarget(Object* target, SEL_CallFuncND selector, void* d); SEL_CallFuncND _callFuncND; void* _data; private: CC_DISALLOW_COPY_AND_ASSIGN(__CCCallFuncND); }; /** @deprecated Please use CallFuncN instead. @brief Calls a 'callback' with an object as the first argument. O means Object. @since v0.99.5 */ class CC_DLL __CCCallFuncO : public CallFunc { public: /** creates the action with the callback typedef void (Object::*SEL_CallFuncO)(Object*); */ CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Object* target, SEL_CallFuncO selector, Object* object); // // Overrides // virtual __CCCallFuncO* clone() const override; virtual void execute() override; Object* getObject() const; void setObject(Object* obj); protected: __CCCallFuncO(); virtual ~__CCCallFuncO(); /** initializes the action with the callback typedef void (Object::*SEL_CallFuncO)(Object*); */ bool initWithTarget(Object* target, SEL_CallFuncO selector, Object* object); /** object to be passed as argument */ Object* _object; SEL_CallFuncO _callFuncO; private: CC_DISALLOW_COPY_AND_ASSIGN(__CCCallFuncO); }; // end of actions group /// @} NS_CC_END #endif //__CCINSTANT_ACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionInterval.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionInterval.h" #include "CCSprite.h" #include "CCNode.h" #include "CCStdC.h" #include "CCActionInstant.h" #include NS_CC_BEGIN // Extra action for making a Sequence or Spawn when only adding one action to it. class ExtraAction : public FiniteTimeAction { public: static ExtraAction* create(); virtual ExtraAction* clone() const; virtual ExtraAction* reverse(void) const; virtual void update(float time); virtual void step(float dt); }; ExtraAction* ExtraAction::create() { ExtraAction* ret = new ExtraAction(); if (ret) { ret->autorelease(); } return ret; } ExtraAction* ExtraAction::clone(void) const { // no copy constructor auto a = new ExtraAction(); a->autorelease(); return a; } ExtraAction* ExtraAction::reverse(void) const { return ExtraAction::create(); } void ExtraAction::update(float time) { CC_UNUSED_PARAM(time); } void ExtraAction::step(float dt) { CC_UNUSED_PARAM(dt); } // // IntervalAction // bool ActionInterval::initWithDuration(float d) { _duration = d; // prevent division by 0 // This comparison could be in step:, but it might decrease the performance // by 3% in heavy based action games. if (_duration == 0) { _duration = FLT_EPSILON; } _elapsed = 0; _firstTick = true; return true; } bool ActionInterval::isDone(void) const { return _elapsed >= _duration; } void ActionInterval::step(float dt) { if (_firstTick) { _firstTick = false; _elapsed = 0; } else { _elapsed += dt; } this->update(MAX (0, // needed for rewind. elapsed could be negative MIN(1, _elapsed / MAX(_duration, FLT_EPSILON) // division by 0 ) ) ); } void ActionInterval::setAmplitudeRate(float amp) { CC_UNUSED_PARAM(amp); // Abstract class needs implementation CCASSERT(0, ""); } float ActionInterval::getAmplitudeRate(void) { // Abstract class needs implementation CCASSERT(0, ""); return 0; } void ActionInterval::startWithTarget(Node *target) { FiniteTimeAction::startWithTarget(target); _elapsed = 0.0f; _firstTick = true; } // // Sequence // Sequence* Sequence::createWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo) { Sequence *sequence = new Sequence(); sequence->initWithTwoActions(actionOne, actionTwo); sequence->autorelease(); return sequence; } Sequence* Sequence::create(FiniteTimeAction *action1, ...) { va_list params; va_start(params, action1); Sequence *ret = Sequence::createWithVariableList(action1, params); va_end(params); return ret; } Sequence* Sequence::createWithVariableList(FiniteTimeAction *action1, va_list args) { FiniteTimeAction *now; FiniteTimeAction *prev = action1; bool bOneAction = true; while (action1) { now = va_arg(args, FiniteTimeAction*); if (now) { prev = createWithTwoActions(prev, now); bOneAction = false; } else { // If only one action is added to Sequence, make up a Sequence by adding a simplest finite time action. if (bOneAction) { prev = createWithTwoActions(prev, ExtraAction::create()); } break; } } return ((Sequence*)prev); } Sequence* Sequence::create(const Vector& arrayOfActions) { Sequence* ret = nullptr; do { auto count = arrayOfActions.size(); CC_BREAK_IF(count == 0); auto prev = arrayOfActions.at(0); if (count > 1) { for (int i = 1; i < count; ++i) { prev = createWithTwoActions(prev, arrayOfActions.at(i)); } } else { // If only one action is added to Sequence, make up a Sequence by adding a simplest finite time action. prev = createWithTwoActions(prev, ExtraAction::create()); } ret = static_cast(prev); }while (0); return ret; } bool Sequence::initWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo) { CCASSERT(actionOne != nullptr, ""); CCASSERT(actionTwo != nullptr, ""); float d = actionOne->getDuration() + actionTwo->getDuration(); ActionInterval::initWithDuration(d); _actions[0] = actionOne; actionOne->retain(); _actions[1] = actionTwo; actionTwo->retain(); return true; } Sequence* Sequence::clone(void) const { // no copy constructor auto a = new Sequence(); a->initWithTwoActions(_actions[0]->clone(), _actions[1]->clone() ); a->autorelease(); return a; } Sequence::~Sequence(void) { CC_SAFE_RELEASE(_actions[0]); CC_SAFE_RELEASE(_actions[1]); } void Sequence::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _split = _actions[0]->getDuration() / _duration; _last = -1; } void Sequence::stop(void) { // Issue #1305 if( _last != - 1) { _actions[_last]->stop(); } ActionInterval::stop(); } void Sequence::update(float t) { int found = 0; float new_t = 0.0f; if( t < _split ) { // action[0] found = 0; if( _split != 0 ) new_t = t / _split; else new_t = 1; } else { // action[1] found = 1; if ( _split == 1 ) new_t = 1; else new_t = (t-_split) / (1 - _split ); } if ( found==1 ) { if( _last == -1 ) { // action[0] was skipped, execute it. _actions[0]->startWithTarget(_target); _actions[0]->update(1.0f); _actions[0]->stop(); } else if( _last == 0 ) { // switching to action 1. stop action 0. _actions[0]->update(1.0f); _actions[0]->stop(); } } else if(found==0 && _last==1 ) { // Reverse mode ? // XXX: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode" // since it will require a hack to know if an action is on reverse mode or not. // "step" should be overriden, and the "reverseMode" value propagated to inner Sequences. _actions[1]->update(0); _actions[1]->stop(); } // Last action found and it is done. if( found == _last && _actions[found]->isDone() ) { return; } // Last action found and it is done if( found != _last ) { _actions[found]->startWithTarget(_target); } _actions[found]->update(new_t); _last = found; } Sequence* Sequence::reverse() const { return Sequence::createWithTwoActions(_actions[1]->reverse(), _actions[0]->reverse()); } // // Repeat // Repeat* Repeat::create(FiniteTimeAction *action, unsigned int times) { Repeat* repeat = new Repeat(); repeat->initWithAction(action, times); repeat->autorelease(); return repeat; } bool Repeat::initWithAction(FiniteTimeAction *action, unsigned int times) { float d = action->getDuration() * times; if (ActionInterval::initWithDuration(d)) { _times = times; _innerAction = action; action->retain(); _actionInstant = dynamic_cast(action) ? true : false; //an instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action if (_actionInstant) { _times -=1; } _total = 0; return true; } return false; } Repeat* Repeat::clone(void) const { // no copy constructor auto a = new Repeat(); a->initWithAction( _innerAction->clone(), _times ); a->autorelease(); return a; } Repeat::~Repeat(void) { CC_SAFE_RELEASE(_innerAction); } void Repeat::startWithTarget(Node *target) { _total = 0; _nextDt = _innerAction->getDuration()/_duration; ActionInterval::startWithTarget(target); _innerAction->startWithTarget(target); } void Repeat::stop(void) { _innerAction->stop(); ActionInterval::stop(); } // issue #80. Instead of hooking step:, hook update: since it can be called by any // container action like Repeat, Sequence, Ease, etc.. void Repeat::update(float dt) { if (dt >= _nextDt) { while (dt > _nextDt && _total < _times) { _innerAction->update(1.0f); _total++; _innerAction->stop(); _innerAction->startWithTarget(_target); _nextDt += _innerAction->getDuration()/_duration; } // fix for issue #1288, incorrect end value of repeat if(dt >= 1.0f && _total < _times) { _total++; } // don't set an instant action back or update it, it has no use because it has no duration if (!_actionInstant) { if (_total == _times) { _innerAction->update(1); _innerAction->stop(); } else { // issue #390 prevent jerk, use right update _innerAction->update(dt - (_nextDt - _innerAction->getDuration()/_duration)); } } } else { _innerAction->update(fmodf(dt * _times,1.0f)); } } bool Repeat::isDone(void) const { return _total == _times; } Repeat* Repeat::reverse() const { return Repeat::create(_innerAction->reverse(), _times); } // // RepeatForever // RepeatForever::~RepeatForever() { CC_SAFE_RELEASE(_innerAction); } RepeatForever *RepeatForever::create(ActionInterval *action) { RepeatForever *ret = new RepeatForever(); if (ret && ret->initWithAction(action)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool RepeatForever::initWithAction(ActionInterval *action) { CCASSERT(action != nullptr, ""); action->retain(); _innerAction = action; return true; } RepeatForever *RepeatForever::clone(void) const { // no copy constructor auto a = new RepeatForever(); a->initWithAction(_innerAction->clone()); a->autorelease(); return a; } void RepeatForever::startWithTarget(Node* target) { ActionInterval::startWithTarget(target); _innerAction->startWithTarget(target); } void RepeatForever::step(float dt) { _innerAction->step(dt); if (_innerAction->isDone()) { float diff = _innerAction->getElapsed() - _innerAction->getDuration(); _innerAction->startWithTarget(_target); // to prevent jerk. issue #390, 1247 _innerAction->step(0.0f); _innerAction->step(diff); } } bool RepeatForever::isDone() const { return false; } RepeatForever *RepeatForever::reverse() const { return RepeatForever::create(_innerAction->reverse()); } // // Spawn // Spawn* Spawn::create(FiniteTimeAction *action1, ...) { va_list params; va_start(params, action1); Spawn *ret = Spawn::createWithVariableList(action1, params); va_end(params); return ret; } Spawn* Spawn::createWithVariableList(FiniteTimeAction *action1, va_list args) { FiniteTimeAction *now; FiniteTimeAction *prev = action1; bool oneAction = true; while (action1) { now = va_arg(args, FiniteTimeAction*); if (now) { prev = createWithTwoActions(prev, now); oneAction = false; } else { // If only one action is added to Spawn, make up a Spawn by adding a simplest finite time action. if (oneAction) { prev = createWithTwoActions(prev, ExtraAction::create()); } break; } } return ((Spawn*)prev); } Spawn* Spawn::create(const Vector& arrayOfActions) { Spawn* ret = nullptr; do { auto count = arrayOfActions.size(); CC_BREAK_IF(count == 0); auto prev = arrayOfActions.at(0); if (count > 1) { for (int i = 1; i < arrayOfActions.size(); ++i) { prev = createWithTwoActions(prev, arrayOfActions.at(i)); } } else { // If only one action is added to Spawn, make up a Spawn by adding a simplest finite time action. prev = createWithTwoActions(prev, ExtraAction::create()); } ret = static_cast(prev); }while (0); return ret; } Spawn* Spawn::createWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2) { Spawn *spawn = new Spawn(); spawn->initWithTwoActions(action1, action2); spawn->autorelease(); return spawn; } bool Spawn::initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2) { CCASSERT(action1 != nullptr, ""); CCASSERT(action2 != nullptr, ""); bool ret = false; float d1 = action1->getDuration(); float d2 = action2->getDuration(); if (ActionInterval::initWithDuration(MAX(d1, d2))) { _one = action1; _two = action2; if (d1 > d2) { _two = Sequence::createWithTwoActions(action2, DelayTime::create(d1 - d2)); } else if (d1 < d2) { _one = Sequence::createWithTwoActions(action1, DelayTime::create(d2 - d1)); } _one->retain(); _two->retain(); ret = true; } return ret; } Spawn* Spawn::clone(void) const { // no copy constructor auto a = new Spawn(); a->initWithTwoActions(_one->clone(), _two->clone()); a->autorelease(); return a; } Spawn::~Spawn(void) { CC_SAFE_RELEASE(_one); CC_SAFE_RELEASE(_two); } void Spawn::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _one->startWithTarget(target); _two->startWithTarget(target); } void Spawn::stop(void) { _one->stop(); _two->stop(); ActionInterval::stop(); } void Spawn::update(float time) { if (_one) { _one->update(time); } if (_two) { _two->update(time); } } Spawn* Spawn::reverse() const { return Spawn::createWithTwoActions(_one->reverse(), _two->reverse()); } // // RotateTo // RotateTo* RotateTo::create(float duration, float deltaAngle) { RotateTo* rotateTo = new RotateTo(); rotateTo->initWithDuration(duration, deltaAngle); rotateTo->autorelease(); return rotateTo; } bool RotateTo::initWithDuration(float duration, float deltaAngle) { if (ActionInterval::initWithDuration(duration)) { _dstAngleX = _dstAngleY = deltaAngle; return true; } return false; } RotateTo* RotateTo::create(float duration, float deltaAngleX, float deltaAngleY) { RotateTo* rotateTo = new RotateTo(); rotateTo->initWithDuration(duration, deltaAngleX, deltaAngleY); rotateTo->autorelease(); return rotateTo; } bool RotateTo::initWithDuration(float duration, float deltaAngleX, float deltaAngleY) { if (ActionInterval::initWithDuration(duration)) { _dstAngleX = deltaAngleX; _dstAngleY = deltaAngleY; return true; } return false; } RotateTo* RotateTo::clone(void) const { // no copy constructor auto a = new RotateTo(); a->initWithDuration(_duration, _dstAngleX, _dstAngleY); a->autorelease(); return a; } void RotateTo::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); // Calculate X _startAngleX = target->getRotationX(); if (_startAngleX > 0) { _startAngleX = fmodf(_startAngleX, 360.0f); } else { _startAngleX = fmodf(_startAngleX, -360.0f); } _diffAngleX = _dstAngleX - _startAngleX; if (_diffAngleX > 180) { _diffAngleX -= 360; } if (_diffAngleX < -180) { _diffAngleX += 360; } //Calculate Y: It's duplicated from calculating X since the rotation wrap should be the same _startAngleY = _target->getRotationY(); if (_startAngleY > 0) { _startAngleY = fmodf(_startAngleY, 360.0f); } else { _startAngleY = fmodf(_startAngleY, -360.0f); } _diffAngleY = _dstAngleY - _startAngleY; if (_diffAngleY > 180) { _diffAngleY -= 360; } if (_diffAngleY < -180) { _diffAngleY += 360; } } void RotateTo::update(float time) { if (_target) { _target->setRotationX(_startAngleX + _diffAngleX * time); _target->setRotationY(_startAngleY + _diffAngleY * time); } } RotateTo *RotateTo::reverse() const { CCASSERT(false, "RotateTo doesn't support the 'reverse' method"); return nullptr; } // // RotateBy // RotateBy* RotateBy::create(float duration, float deltaAngle) { RotateBy *rotateBy = new RotateBy(); rotateBy->initWithDuration(duration, deltaAngle); rotateBy->autorelease(); return rotateBy; } bool RotateBy::initWithDuration(float duration, float deltaAngle) { if (ActionInterval::initWithDuration(duration)) { _angleX = _angleY = deltaAngle; return true; } return false; } RotateBy* RotateBy::create(float duration, float deltaAngleX, float deltaAngleY) { RotateBy *rotateBy = new RotateBy(); rotateBy->initWithDuration(duration, deltaAngleX, deltaAngleY); rotateBy->autorelease(); return rotateBy; } bool RotateBy::initWithDuration(float duration, float deltaAngleX, float deltaAngleY) { if (ActionInterval::initWithDuration(duration)) { _angleX = deltaAngleX; _angleY = deltaAngleY; return true; } return false; } RotateBy* RotateBy::clone(void) const { // no copy constructor auto a = new RotateBy(); a->initWithDuration(_duration, _angleX, _angleY); a->autorelease(); return a; } void RotateBy::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _startAngleX = target->getRotationX(); _startAngleY = target->getRotationY(); } void RotateBy::update(float time) { // XXX: shall I add % 360 if (_target) { _target->setRotationX(_startAngleX + _angleX * time); _target->setRotationY(_startAngleY + _angleY * time); } } RotateBy* RotateBy::reverse() const { return RotateBy::create(_duration, -_angleX, -_angleY); } // // MoveBy // MoveBy* MoveBy::create(float duration, const Point& deltaPosition) { MoveBy *ret = new MoveBy(); ret->initWithDuration(duration, deltaPosition); ret->autorelease(); return ret; } bool MoveBy::initWithDuration(float duration, const Point& deltaPosition) { if (ActionInterval::initWithDuration(duration)) { _positionDelta = deltaPosition; return true; } return false; } MoveBy* MoveBy::clone(void) const { // no copy constructor auto a = new MoveBy(); a->initWithDuration(_duration, _positionDelta); a->autorelease(); return a; } void MoveBy::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _previousPosition = _startPosition = target->getPosition(); } MoveBy* MoveBy::reverse() const { return MoveBy::create(_duration, Point( -_positionDelta.x, -_positionDelta.y)); } void MoveBy::update(float t) { if (_target) { #if CC_ENABLE_STACKABLE_ACTIONS Point currentPos = _target->getPosition(); Point diff = currentPos - _previousPosition; _startPosition = _startPosition + diff; Point newPos = _startPosition + (_positionDelta * t); _target->setPosition(newPos); _previousPosition = newPos; #else _target->setPosition(ccpAdd( _startPosition, ccpMult(_positionDelta, t))); #endif // CC_ENABLE_STACKABLE_ACTIONS } } // // MoveTo // MoveTo* MoveTo::create(float duration, const Point& position) { MoveTo *ret = new MoveTo(); ret->initWithDuration(duration, position); ret->autorelease(); return ret; } bool MoveTo::initWithDuration(float duration, const Point& position) { if (ActionInterval::initWithDuration(duration)) { _endPosition = position; return true; } return false; } MoveTo* MoveTo::clone(void) const { // no copy constructor auto a = new MoveTo(); a->initWithDuration(_duration, _endPosition); a->autorelease(); return a; } void MoveTo::startWithTarget(Node *target) { MoveBy::startWithTarget(target); _positionDelta = _endPosition - target->getPosition(); } // // SkewTo // SkewTo* SkewTo::create(float t, float sx, float sy) { SkewTo *skewTo = new SkewTo(); if (skewTo) { if (skewTo->initWithDuration(t, sx, sy)) { skewTo->autorelease(); } else { CC_SAFE_DELETE(skewTo); } } return skewTo; } bool SkewTo::initWithDuration(float t, float sx, float sy) { bool bRet = false; if (ActionInterval::initWithDuration(t)) { _endSkewX = sx; _endSkewY = sy; bRet = true; } return bRet; } SkewTo* SkewTo::clone(void) const { // no copy constructor auto a = new SkewTo(); a->initWithDuration(_duration, _endSkewX, _endSkewY); a->autorelease(); return a; } SkewTo* SkewTo::reverse() const { CCASSERT(false, "reverse() not supported in SkewTo"); return nullptr; } void SkewTo::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _startSkewX = target->getSkewX(); if (_startSkewX > 0) { _startSkewX = fmodf(_startSkewX, 180.f); } else { _startSkewX = fmodf(_startSkewX, -180.f); } _deltaX = _endSkewX - _startSkewX; if (_deltaX > 180) { _deltaX -= 360; } if (_deltaX < -180) { _deltaX += 360; } _startSkewY = target->getSkewY(); if (_startSkewY > 0) { _startSkewY = fmodf(_startSkewY, 360.f); } else { _startSkewY = fmodf(_startSkewY, -360.f); } _deltaY = _endSkewY - _startSkewY; if (_deltaY > 180) { _deltaY -= 360; } if (_deltaY < -180) { _deltaY += 360; } } void SkewTo::update(float t) { _target->setSkewX(_startSkewX + _deltaX * t); _target->setSkewY(_startSkewY + _deltaY * t); } SkewTo::SkewTo() : _skewX(0.0) , _skewY(0.0) , _startSkewX(0.0) , _startSkewY(0.0) , _endSkewX(0.0) , _endSkewY(0.0) , _deltaX(0.0) , _deltaY(0.0) { } // // SkewBy // SkewBy* SkewBy::create(float t, float sx, float sy) { SkewBy *skewBy = new SkewBy(); if (skewBy) { if (skewBy->initWithDuration(t, sx, sy)) { skewBy->autorelease(); } else { CC_SAFE_DELETE(skewBy); } } return skewBy; } SkewBy * SkewBy::clone() const { // no copy constructor auto a = new SkewBy(); a->initWithDuration(_duration, _skewX, _skewY); a->autorelease(); return a; } bool SkewBy::initWithDuration(float t, float deltaSkewX, float deltaSkewY) { bool ret = false; if (SkewTo::initWithDuration(t, deltaSkewX, deltaSkewY)) { _skewX = deltaSkewX; _skewY = deltaSkewY; ret = true; } return ret; } void SkewBy::startWithTarget(Node *target) { SkewTo::startWithTarget(target); _deltaX = _skewX; _deltaY = _skewY; _endSkewX = _startSkewX + _deltaX; _endSkewY = _startSkewY + _deltaY; } SkewBy* SkewBy::reverse() const { return SkewBy::create(_duration, -_skewX, -_skewY); } // // JumpBy // JumpBy* JumpBy::create(float duration, const Point& position, float height, int jumps) { JumpBy *jumpBy = new JumpBy(); jumpBy->initWithDuration(duration, position, height, jumps); jumpBy->autorelease(); return jumpBy; } bool JumpBy::initWithDuration(float duration, const Point& position, float height, int jumps) { CCASSERT(jumps>=0, "Number of jumps must be >= 0"); if (ActionInterval::initWithDuration(duration) && jumps>=0) { _delta = position; _height = height; _jumps = jumps; return true; } return false; } JumpBy* JumpBy::clone(void) const { // no copy constructor auto a = new JumpBy(); a->initWithDuration(_duration, _delta, _height, _jumps); a->autorelease(); return a; } void JumpBy::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _previousPos = _startPosition = target->getPosition(); } void JumpBy::update(float t) { // parabolic jump (since v0.8.2) if (_target) { float frac = fmodf( t * _jumps, 1.0f ); float y = _height * 4 * frac * (1 - frac); y += _delta.y * t; float x = _delta.x * t; #if CC_ENABLE_STACKABLE_ACTIONS Point currentPos = _target->getPosition(); Point diff = currentPos - _previousPos; _startPosition = diff + _startPosition; Point newPos = _startPosition + Point(x,y); _target->setPosition(newPos); _previousPos = newPos; #else _target->setPosition(ccpAdd( _startPosition, Point(x,y))); #endif // !CC_ENABLE_STACKABLE_ACTIONS } } JumpBy* JumpBy::reverse() const { return JumpBy::create(_duration, Point(-_delta.x, -_delta.y), _height, _jumps); } // // JumpTo // JumpTo* JumpTo::create(float duration, const Point& position, float height, int jumps) { JumpTo *jumpTo = new JumpTo(); jumpTo->initWithDuration(duration, position, height, jumps); jumpTo->autorelease(); return jumpTo; } JumpTo* JumpTo::clone(void) const { // no copy constructor auto a = new JumpTo(); a->initWithDuration(_duration, _delta, _height, _jumps); a->autorelease(); return a; } JumpTo* JumpTo::reverse() const { CCASSERT(false, "reverse() not supported in JumpTo"); return nullptr; } void JumpTo::startWithTarget(Node *target) { JumpBy::startWithTarget(target); _delta = Point(_delta.x - _startPosition.x, _delta.y - _startPosition.y); } // Bezier cubic formula: // ((1 - t) + t)3 = 1 // Expands to ... // (1 - t)3 + 3t(1-t)2 + 3t2(1 - t) + t3 = 1 static inline float bezierat( float a, float b, float c, float d, float t ) { return (powf(1-t,3) * a + 3*t*(powf(1-t,2))*b + 3*powf(t,2)*(1-t)*c + powf(t,3)*d ); } // // BezierBy // BezierBy* BezierBy::create(float t, const ccBezierConfig& c) { BezierBy *bezierBy = new BezierBy(); bezierBy->initWithDuration(t, c); bezierBy->autorelease(); return bezierBy; } bool BezierBy::initWithDuration(float t, const ccBezierConfig& c) { if (ActionInterval::initWithDuration(t)) { _config = c; return true; } return false; } void BezierBy::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _previousPosition = _startPosition = target->getPosition(); } BezierBy* BezierBy::clone(void) const { // no copy constructor auto a = new BezierBy(); a->initWithDuration(_duration, _config); a->autorelease(); return a; } void BezierBy::update(float time) { if (_target) { float xa = 0; float xb = _config.controlPoint_1.x; float xc = _config.controlPoint_2.x; float xd = _config.endPosition.x; float ya = 0; float yb = _config.controlPoint_1.y; float yc = _config.controlPoint_2.y; float yd = _config.endPosition.y; float x = bezierat(xa, xb, xc, xd, time); float y = bezierat(ya, yb, yc, yd, time); #if CC_ENABLE_STACKABLE_ACTIONS Point currentPos = _target->getPosition(); Point diff = currentPos - _previousPosition; _startPosition = _startPosition + diff; Point newPos = _startPosition + Point(x,y); _target->setPosition(newPos); _previousPosition = newPos; #else _target->setPosition(ccpAdd( _startPosition, Point(x,y))); #endif // !CC_ENABLE_STACKABLE_ACTIONS } } BezierBy* BezierBy::reverse(void) const { ccBezierConfig r; r.endPosition = -_config.endPosition; r.controlPoint_1 = _config.controlPoint_2 + (-_config.endPosition); r.controlPoint_2 = _config.controlPoint_1 + (-_config.endPosition); BezierBy *action = BezierBy::create(_duration, r); return action; } // // BezierTo // BezierTo* BezierTo::create(float t, const ccBezierConfig& c) { BezierTo *bezierTo = new BezierTo(); bezierTo->initWithDuration(t, c); bezierTo->autorelease(); return bezierTo; } bool BezierTo::initWithDuration(float t, const ccBezierConfig &c) { if (ActionInterval::initWithDuration(t)) { _toConfig = c; return true; } return false; } BezierTo* BezierTo::clone(void) const { // no copy constructor auto a = new BezierTo(); a->initWithDuration(_duration, _toConfig); a->autorelease(); return a; } void BezierTo::startWithTarget(Node *target) { BezierBy::startWithTarget(target); _config.controlPoint_1 = _toConfig.controlPoint_1 - _startPosition; _config.controlPoint_2 = _toConfig.controlPoint_2 - _startPosition; _config.endPosition = _toConfig.endPosition - _startPosition; } BezierTo* BezierTo::reverse() const { CCASSERT(false, "CCBezierTo doesn't support the 'reverse' method"); return nullptr; } // // ScaleTo // ScaleTo* ScaleTo::create(float duration, float s) { ScaleTo *scaleTo = new ScaleTo(); scaleTo->initWithDuration(duration, s); scaleTo->autorelease(); return scaleTo; } ScaleTo* ScaleTo::create(float duration, float sx, float sy) { ScaleTo *scaleTo = new ScaleTo(); scaleTo->initWithDuration(duration, sx, sy); scaleTo->autorelease(); return scaleTo; } bool ScaleTo::initWithDuration(float duration, float s) { if (ActionInterval::initWithDuration(duration)) { _endScaleX = s; _endScaleY = s; return true; } return false; } bool ScaleTo::initWithDuration(float duration, float sx, float sy) { if (ActionInterval::initWithDuration(duration)) { _endScaleX = sx; _endScaleY = sy; return true; } return false; } ScaleTo* ScaleTo::clone(void) const { // no copy constructor auto a = new ScaleTo(); a->initWithDuration(_duration, _endScaleX, _endScaleY); a->autorelease(); return a; } ScaleTo* ScaleTo::reverse() const { CCASSERT(false, "reverse() not supported in ScaleTo"); return nullptr; } void ScaleTo::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _startScaleX = target->getScaleX(); _startScaleY = target->getScaleY(); _deltaX = _endScaleX - _startScaleX; _deltaY = _endScaleY - _startScaleY; } void ScaleTo::update(float time) { if (_target) { _target->setScaleX(_startScaleX + _deltaX * time); _target->setScaleY(_startScaleY + _deltaY * time); } } // // ScaleBy // ScaleBy* ScaleBy::create(float duration, float s) { ScaleBy *scaleBy = new ScaleBy(); scaleBy->initWithDuration(duration, s); scaleBy->autorelease(); return scaleBy; } ScaleBy* ScaleBy::create(float duration, float sx, float sy) { ScaleBy *scaleBy = new ScaleBy(); scaleBy->initWithDuration(duration, sx, sy); scaleBy->autorelease(); return scaleBy; } ScaleBy* ScaleBy::clone(void) const { // no copy constructor auto a = new ScaleBy(); a->initWithDuration(_duration, _endScaleX, _endScaleY); a->autorelease(); return a; } void ScaleBy::startWithTarget(Node *target) { ScaleTo::startWithTarget(target); _deltaX = _startScaleX * _endScaleX - _startScaleX; _deltaY = _startScaleY * _endScaleY - _startScaleY; } ScaleBy* ScaleBy::reverse() const { return ScaleBy::create(_duration, 1 / _endScaleX, 1 / _endScaleY); } // // Blink // Blink* Blink::create(float duration, int blinks) { Blink *blink = new Blink(); blink->initWithDuration(duration, blinks); blink->autorelease(); return blink; } bool Blink::initWithDuration(float duration, int blinks) { CCASSERT(blinks>=0, "blinks should be >= 0"); if (ActionInterval::initWithDuration(duration) && blinks>=0) { _times = blinks; return true; } return false; } void Blink::stop() { _target->setVisible(_originalState); ActionInterval::stop(); } void Blink::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _originalState = target->isVisible(); } Blink* Blink::clone(void) const { // no copy constructor auto a = new Blink(); a->initWithDuration(_duration, _times); a->autorelease(); return a; } void Blink::update(float time) { if (_target && ! isDone()) { float slice = 1.0f / _times; float m = fmodf(time, slice); _target->setVisible(m > slice / 2 ? true : false); } } Blink* Blink::reverse() const { return Blink::create(_duration, _times); } // // FadeIn // FadeIn* FadeIn::create(float d) { FadeIn* action = new FadeIn(); action->initWithDuration(d); action->autorelease(); return action; } FadeIn* FadeIn::clone() const { // no copy constructor auto a = new FadeIn(); a->initWithDuration(_duration); a->autorelease(); return a; } void FadeIn::update(float time) { if (_target) { _target->setOpacity((GLubyte)(255 * time)); } /*_target->setOpacity((GLubyte)(255 * time));*/ } ActionInterval* FadeIn::reverse() const { return FadeOut::create(_duration); } // // FadeOut // FadeOut* FadeOut::create(float d) { FadeOut* action = new FadeOut(); action->initWithDuration(d); action->autorelease(); return action; } FadeOut* FadeOut::clone() const { // no copy constructor auto a = new FadeOut(); a->initWithDuration(_duration); a->autorelease(); return a; } void FadeOut::update(float time) { if (_target) { _target->setOpacity(GLubyte(255 * (1 - time))); } /*_target->setOpacity(GLubyte(255 * (1 - time)));*/ } ActionInterval* FadeOut::reverse() const { return FadeIn::create(_duration); } // // FadeTo // FadeTo* FadeTo::create(float duration, GLubyte opacity) { FadeTo *fadeTo = new FadeTo(); fadeTo->initWithDuration(duration, opacity); fadeTo->autorelease(); return fadeTo; } bool FadeTo::initWithDuration(float duration, GLubyte opacity) { if (ActionInterval::initWithDuration(duration)) { _toOpacity = opacity; return true; } return false; } FadeTo* FadeTo::clone() const { // no copy constructor auto a = new FadeTo(); a->initWithDuration(_duration, _toOpacity); a->autorelease(); return a; } FadeTo* FadeTo::reverse() const { CCASSERT(false, "reverse() not supported in FadeTo"); return nullptr; } void FadeTo::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); if (target) { _fromOpacity = target->getOpacity(); } /*_fromOpacity = target->getOpacity();*/ } void FadeTo::update(float time) { if (_target) { _target->setOpacity((GLubyte)(_fromOpacity + (_toOpacity - _fromOpacity) * time)); } /*_target->setOpacity((GLubyte)(_fromOpacity + (_toOpacity - _fromOpacity) * time));*/ } // // TintTo // TintTo* TintTo::create(float duration, GLubyte red, GLubyte green, GLubyte blue) { TintTo *tintTo = new TintTo(); tintTo->initWithDuration(duration, red, green, blue); tintTo->autorelease(); return tintTo; } bool TintTo::initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) { if (ActionInterval::initWithDuration(duration)) { _to = Color3B(red, green, blue); return true; } return false; } TintTo* TintTo::clone() const { // no copy constructor auto a = new TintTo(); a->initWithDuration(_duration, _to.r, _to.g, _to.b); a->autorelease(); return a; } TintTo* TintTo::reverse() const { CCASSERT(false, "reverse() not supported in TintTo"); return nullptr; } void TintTo::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); if (_target) { _from = _target->getColor(); } /*_from = target->getColor();*/ } void TintTo::update(float time) { if (_target) { _target->setColor(Color3B(GLubyte(_from.r + (_to.r - _from.r) * time), (GLubyte)(_from.g + (_to.g - _from.g) * time), (GLubyte)(_from.b + (_to.b - _from.b) * time))); } } // // TintBy // TintBy* TintBy::create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) { TintBy *tintBy = new TintBy(); tintBy->initWithDuration(duration, deltaRed, deltaGreen, deltaBlue); tintBy->autorelease(); return tintBy; } bool TintBy::initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) { if (ActionInterval::initWithDuration(duration)) { _deltaR = deltaRed; _deltaG = deltaGreen; _deltaB = deltaBlue; return true; } return false; } TintBy* TintBy::clone() const { // no copy constructor auto a = new TintBy(); a->initWithDuration(_duration, (GLubyte)_deltaR, (GLubyte)_deltaG, (GLubyte)_deltaB); a->autorelease(); return a; } void TintBy::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); if (target) { Color3B color = target->getColor(); _fromR = color.r; _fromG = color.g; _fromB = color.b; } } void TintBy::update(float time) { if (_target) { _target->setColor(Color3B((GLubyte)(_fromR + _deltaR * time), (GLubyte)(_fromG + _deltaG * time), (GLubyte)(_fromB + _deltaB * time))); } } TintBy* TintBy::reverse() const { return TintBy::create(_duration, -_deltaR, -_deltaG, -_deltaB); } // // DelayTime // DelayTime* DelayTime::create(float d) { DelayTime* action = new DelayTime(); action->initWithDuration(d); action->autorelease(); return action; } DelayTime* DelayTime::clone() const { // no copy constructor auto a = new DelayTime(); a->initWithDuration(_duration); a->autorelease(); return a; } void DelayTime::update(float time) { CC_UNUSED_PARAM(time); return; } DelayTime* DelayTime::reverse() const { return DelayTime::create(_duration); } // // ReverseTime // ReverseTime* ReverseTime::create(FiniteTimeAction *action) { // casting to prevent warnings ReverseTime *reverseTime = new ReverseTime(); reverseTime->initWithAction( action->clone() ); reverseTime->autorelease(); return reverseTime; } bool ReverseTime::initWithAction(FiniteTimeAction *action) { CCASSERT(action != nullptr, ""); CCASSERT(action != _other, ""); if (ActionInterval::initWithDuration(action->getDuration())) { // Don't leak if action is reused CC_SAFE_RELEASE(_other); _other = action; action->retain(); return true; } return false; } ReverseTime* ReverseTime::clone() const { // no copy constructor auto a = new ReverseTime(); a->initWithAction( _other->clone() ); a->autorelease(); return a; } ReverseTime::ReverseTime() : _other(nullptr) { } ReverseTime::~ReverseTime(void) { CC_SAFE_RELEASE(_other); } void ReverseTime::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _other->startWithTarget(target); } void ReverseTime::stop(void) { _other->stop(); ActionInterval::stop(); } void ReverseTime::update(float time) { if (_other) { _other->update(1 - time); } } ReverseTime* ReverseTime::reverse() const { // XXX: This looks like a bug return (ReverseTime*)_other->clone(); } // // Animate // Animate* Animate::create(Animation *animation) { Animate *animate = new Animate(); animate->initWithAnimation(animation); animate->autorelease(); return animate; } Animate::Animate() : _splitTimes(new std::vector) , _nextFrame(0) , _origFrame(nullptr) , _executedLoops(0) , _animation(nullptr) { } Animate::~Animate() { CC_SAFE_RELEASE(_animation); CC_SAFE_RELEASE(_origFrame); CC_SAFE_DELETE(_splitTimes); } bool Animate::initWithAnimation(Animation* animation) { CCASSERT( animation!=nullptr, "Animate: argument Animation must be non-nullptr"); float singleDuration = animation->getDuration(); if ( ActionInterval::initWithDuration(singleDuration * animation->getLoops() ) ) { _nextFrame = 0; setAnimation(animation); _origFrame = nullptr; _executedLoops = 0; _splitTimes->reserve(animation->getFrames().size()); float accumUnitsOfTime = 0; float newUnitOfTimeValue = singleDuration / animation->getTotalDelayUnits(); auto frames = animation->getFrames(); for (auto& frame : frames) { float value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration; accumUnitsOfTime += frame->getDelayUnits(); _splitTimes->push_back(value); } return true; } return false; } void Animate::setAnimation(cocos2d::Animation *animation) { if (_animation != animation) { CC_SAFE_RETAIN(animation); CC_SAFE_RELEASE(_animation); _animation = animation; } } Animate* Animate::clone() const { // no copy constructor auto a = new Animate(); a->initWithAnimation(_animation->clone()); a->autorelease(); return a; } void Animate::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); Sprite *sprite = static_cast(target); CC_SAFE_RELEASE(_origFrame); if (_animation->getRestoreOriginalFrame()) { _origFrame = sprite->getSpriteFrame(); _origFrame->retain(); } _nextFrame = 0; _executedLoops = 0; } void Animate::stop(void) { if (_animation->getRestoreOriginalFrame() && _target) { static_cast(_target)->setSpriteFrame(_origFrame); } ActionInterval::stop(); } void Animate::update(float t) { // if t==1, ignore. Animation should finish with t==1 if( t < 1.0f ) { t *= _animation->getLoops(); // new loop? If so, reset frame counter unsigned int loopNumber = (unsigned int)t; if( loopNumber > _executedLoops ) { _nextFrame = 0; _executedLoops++; } // new t for animations t = fmodf(t, 1.0f); } auto frames = _animation->getFrames(); auto numberOfFrames = frames.size(); SpriteFrame *frameToDisplay = nullptr; for( int i=_nextFrame; i < numberOfFrames; i++ ) { float splitTime = _splitTimes->at(i); if( splitTime <= t ) { AnimationFrame* frame = frames.at(i); frameToDisplay = frame->getSpriteFrame(); static_cast(_target)->setSpriteFrame(frameToDisplay); const ValueMap& dict = frame->getUserInfo(); if ( !dict.empty() ) { //TODO: [[NSNotificationCenter defaultCenter] postNotificationName:AnimationFrameDisplayedNotification object:target_ userInfo:dict]; } _nextFrame = i+1; } // Issue 1438. Could be more than one frame per tick, due to low frame rate or frame delta < 1/FPS else { break; } } } Animate* Animate::reverse() const { auto oldArray = _animation->getFrames(); Vector newArray(oldArray.size()); if (oldArray.size() > 0) { for (auto iter = oldArray.crbegin(); iter != oldArray.crend(); ++iter) { AnimationFrame* animFrame = *iter; if (!animFrame) { break; } newArray.pushBack(animFrame->clone()); } } Animation *newAnim = Animation::create(newArray, _animation->getDelayPerUnit(), _animation->getLoops()); newAnim->setRestoreOriginalFrame(_animation->getRestoreOriginalFrame()); return Animate::create(newAnim); } // TargetedAction TargetedAction::TargetedAction() : _action(nullptr) , _forcedTarget(nullptr) { } TargetedAction::~TargetedAction() { CC_SAFE_RELEASE(_forcedTarget); CC_SAFE_RELEASE(_action); } TargetedAction* TargetedAction::create(Node* target, FiniteTimeAction* action) { TargetedAction* p = new TargetedAction(); p->initWithTarget(target, action); p->autorelease(); return p; } bool TargetedAction::initWithTarget(Node* target, FiniteTimeAction* action) { if(ActionInterval::initWithDuration(action->getDuration())) { CC_SAFE_RETAIN(target); _forcedTarget = target; CC_SAFE_RETAIN(action); _action = action; return true; } return false; } TargetedAction* TargetedAction::clone() const { // no copy constructor auto a = new TargetedAction(); // win32 : use the _other's copy object. a->initWithTarget(_forcedTarget, _action->clone()); a->autorelease(); return a; } TargetedAction* TargetedAction::reverse(void) const { // just reverse the internal action auto a = new TargetedAction(); a->initWithTarget(_forcedTarget, _action->reverse()); a->autorelease(); return a; } void TargetedAction::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _action->startWithTarget(_forcedTarget); } void TargetedAction::stop(void) { _action->stop(); } void TargetedAction::update(float time) { _action->update(time); } void TargetedAction::setForcedTarget(Node* forcedTarget) { if( _forcedTarget != forcedTarget ) { CC_SAFE_RETAIN(forcedTarget); CC_SAFE_RELEASE(_forcedTarget); _forcedTarget = forcedTarget; } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionInterval.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTION_CCINTERVAL_ACTION_H__ #define __ACTION_CCINTERVAL_ACTION_H__ #include "CCNode.h" #include "CCAction.h" #include "CCProtocols.h" #include "CCSpriteFrame.h" #include "CCAnimation.h" #include "CCVector.h" #include NS_CC_BEGIN /** * @addtogroup actions * @{ */ /** @brief An interval action is an action that takes place within a certain period of time. It has an start time, and a finish time. The finish time is the parameter duration plus the start time. These ActionInterval actions have some interesting properties, like: - They can run normally (default) - They can run reversed with the reverse method - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. For example, you can simulate a Ping Pong effect running the action normally and then running it again in Reverse mode. Example: Action *pingPongAction = Sequence::actions(action, action->reverse(), nullptr); */ class CC_DLL ActionInterval : public FiniteTimeAction { public: /** how many seconds had elapsed since the actions started to run. */ inline float getElapsed(void) { return _elapsed; } //extension in GridAction void setAmplitudeRate(float amp); float getAmplitudeRate(void); // // Overrides // virtual bool isDone(void) const override; virtual void step(float dt) override; virtual void startWithTarget(Node *target) override; virtual ActionInterval* reverse() const override = 0; virtual ActionInterval *clone() const override = 0; protected: /** initializes the action */ bool initWithDuration(float d); float _elapsed; bool _firstTick; }; /** @brief Runs actions sequentially, one after another */ class CC_DLL Sequence : public ActionInterval { public: /** helper constructor to create an array of sequenceable actions */ static Sequence* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION; /** helper constructor to create an array of sequenceable actions given an array * @code * When this funtion bound to the js or lua,the input params changed * in js :var create(var object1,var object2, ...) * in lua :local create(local object1,local object2, ...) * @endcode */ static Sequence* create(const Vector& arrayOfActions); /** helper constructor to create an array of sequence-able actions */ static Sequence* createWithVariableList(FiniteTimeAction *action1, va_list args); /** creates the action */ static Sequence* createWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction *actionTwo); // // Overrides // virtual Sequence* clone() const override; virtual Sequence* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void stop(void) override; virtual void update(float t) override; protected: Sequence() {} virtual ~Sequence(void); /** initializes the action */ bool initWithTwoActions(FiniteTimeAction *pActionOne, FiniteTimeAction *pActionTwo); FiniteTimeAction *_actions[2]; float _split; int _last; private: CC_DISALLOW_COPY_AND_ASSIGN(Sequence); }; /** @brief Repeats an action a number of times. * To repeat an action forever use the RepeatForever action. */ class CC_DLL Repeat : public ActionInterval { public: /** creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */ static Repeat* create(FiniteTimeAction *action, unsigned int times); inline void setInnerAction(FiniteTimeAction *action) { if (_innerAction != action) { CC_SAFE_RETAIN(action); CC_SAFE_RELEASE(_innerAction); _innerAction = action; } } inline FiniteTimeAction* getInnerAction() { return _innerAction; } // // Overrides // virtual Repeat* clone() const override; virtual Repeat* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void stop(void) override; virtual void update(float dt) override; virtual bool isDone(void) const override; protected: Repeat() {} virtual ~Repeat(); /** initializes a Repeat action. Times is an unsigned integer between 1 and pow(2,30) */ bool initWithAction(FiniteTimeAction *pAction, unsigned int times); unsigned int _times; unsigned int _total; float _nextDt; bool _actionInstant; /** Inner action */ FiniteTimeAction *_innerAction; private: CC_DISALLOW_COPY_AND_ASSIGN(Repeat); }; /** @brief Repeats an action for ever. To repeat the an action for a limited number of times use the Repeat action. @warning This action can't be Sequenceable because it is not an IntervalAction */ class CC_DLL RepeatForever : public ActionInterval { public: /** creates the action */ static RepeatForever* create(ActionInterval *action); inline void setInnerAction(ActionInterval *action) { if (_innerAction != action) { CC_SAFE_RELEASE(_innerAction); _innerAction = action; CC_SAFE_RETAIN(_innerAction); } } inline ActionInterval* getInnerAction() { return _innerAction; } // // Overrides // virtual RepeatForever* clone() const override; virtual RepeatForever* reverse(void) const override; virtual void startWithTarget(Node* target) override; virtual void step(float dt) override; virtual bool isDone(void) const override; protected: RepeatForever() : _innerAction(nullptr) {} virtual ~RepeatForever(); /** initializes the action */ bool initWithAction(ActionInterval *action); /** Inner action */ ActionInterval *_innerAction; private: CC_DISALLOW_COPY_AND_ASSIGN(RepeatForever); }; /** @brief Spawn a new action immediately */ class CC_DLL Spawn : public ActionInterval { public: /** helper constructor to create an array of spawned actions * @code * When this funtion bound to the js or lua,the input params changed * in js :var create(var object1,var object2, ...) * in lua :local create(local object1,local object2, ...) * @endcode */ static Spawn* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION; /** helper constructor to create an array of spawned actions */ static Spawn* createWithVariableList(FiniteTimeAction *action1, va_list args); /** helper constructor to create an array of spawned actions given an array */ static Spawn* create(const Vector& arrayOfActions); /** creates the Spawn action */ static Spawn* createWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2); // // Overrides // virtual Spawn* clone() const override; virtual Spawn* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void stop(void) override; virtual void update(float time) override; protected: Spawn() {} virtual ~Spawn(); /** initializes the Spawn action with the 2 actions to spawn */ bool initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *action2); FiniteTimeAction *_one; FiniteTimeAction *_two; private: CC_DISALLOW_COPY_AND_ASSIGN(Spawn); }; /** @brief Rotates a Node object to a certain angle by modifying it's rotation attribute. The direction will be decided by the shortest angle. */ class CC_DLL RotateTo : public ActionInterval { public: /** creates the action with separate rotation angles */ static RotateTo* create(float duration, float deltaAngleX, float deltaAngleY); /** creates the action */ static RotateTo* create(float duration, float deltaAngle); // // Overrides // virtual RotateTo* clone() const override; virtual RotateTo* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: RotateTo() {} virtual ~RotateTo() {} /** initializes the action */ bool initWithDuration(float duration, float deltaAngle); bool initWithDuration(float duration, float deltaAngleX, float deltaAngleY); float _dstAngleX; float _startAngleX; float _diffAngleX; float _dstAngleY; float _startAngleY; float _diffAngleY; private: CC_DISALLOW_COPY_AND_ASSIGN(RotateTo); }; /** @brief Rotates a Node object clockwise a number of degrees by modifying it's rotation attribute. */ class CC_DLL RotateBy : public ActionInterval { public: /** creates the action */ static RotateBy* create(float duration, float deltaAngle); static RotateBy* create(float duration, float deltaAngleX, float deltaAngleY); // // Override // virtual RotateBy* clone() const override; virtual RotateBy* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: RotateBy() {} virtual ~RotateBy() {} /** initializes the action */ bool initWithDuration(float duration, float deltaAngle); bool initWithDuration(float duration, float deltaAngleX, float deltaAngleY); float _angleX; float _startAngleX; float _angleY; float _startAngleY; private: CC_DISALLOW_COPY_AND_ASSIGN(RotateBy); }; /** Moves a Node object x,y pixels by modifying it's position attribute. x and y are relative to the position of the object. Several MoveBy actions can be concurrently called, and the resulting movement will be the sum of individual movements. @since v2.1beta2-custom */ class CC_DLL MoveBy : public ActionInterval { public: /** creates the action */ static MoveBy* create(float duration, const Point& deltaPosition); // // Overrides // virtual MoveBy* clone() const override; virtual MoveBy* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: MoveBy() {} virtual ~MoveBy() {} /** initializes the action */ bool initWithDuration(float duration, const Point& deltaPosition); Point _positionDelta; Point _startPosition; Point _previousPosition; private: CC_DISALLOW_COPY_AND_ASSIGN(MoveBy); }; /** Moves a Node object to the position x,y. x and y are absolute coordinates by modifying it's position attribute. Several MoveTo actions can be concurrently called, and the resulting movement will be the sum of individual movements. @since v2.1beta2-custom */ class CC_DLL MoveTo : public MoveBy { public: /** creates the action */ static MoveTo* create(float duration, const Point& position); // // Overrides // virtual MoveTo* clone() const override; virtual void startWithTarget(Node *target) override; protected: MoveTo() {} virtual ~MoveTo() {} /** initializes the action */ bool initWithDuration(float duration, const Point& position); Point _endPosition; private: CC_DISALLOW_COPY_AND_ASSIGN(MoveTo); }; /** Skews a Node object to given angles by modifying it's skewX and skewY attributes @since v1.0 */ class CC_DLL SkewTo : public ActionInterval { public: /** creates the action */ static SkewTo* create(float t, float sx, float sy); // // Overrides // virtual SkewTo* clone() const override; virtual SkewTo* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: SkewTo(); virtual ~SkewTo() {} bool initWithDuration(float t, float sx, float sy); float _skewX; float _skewY; float _startSkewX; float _startSkewY; float _endSkewX; float _endSkewY; float _deltaX; float _deltaY; private: CC_DISALLOW_COPY_AND_ASSIGN(SkewTo); }; /** Skews a Node object by skewX and skewY degrees @since v1.0 */ class CC_DLL SkewBy : public SkewTo { public: /** creates the action */ static SkewBy* create(float t, float deltaSkewX, float deltaSkewY); // // Overrides // virtual void startWithTarget(Node *target) override; virtual SkewBy* clone() const override; virtual SkewBy* reverse(void) const override; protected: SkewBy() {} virtual ~SkewBy() {} bool initWithDuration(float t, float sx, float sy); private: CC_DISALLOW_COPY_AND_ASSIGN(SkewBy); }; /** @brief Moves a Node object simulating a parabolic jump movement by modifying it's position attribute. */ class CC_DLL JumpBy : public ActionInterval { public: /** creates the action */ static JumpBy* create(float duration, const Point& position, float height, int jumps); // // Overrides // virtual JumpBy* clone() const override; virtual JumpBy* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: JumpBy() {} virtual ~JumpBy() {} /** initializes the action */ bool initWithDuration(float duration, const Point& position, float height, int jumps); Point _startPosition; Point _delta; float _height; int _jumps; Point _previousPos; private: CC_DISALLOW_COPY_AND_ASSIGN(JumpBy); }; /** @brief Moves a Node object to a parabolic position simulating a jump movement by modifying it's position attribute. */ class CC_DLL JumpTo : public JumpBy { public: /** creates the action */ static JumpTo* create(float duration, const Point& position, float height, int jumps); // // Override // virtual void startWithTarget(Node *target) override; virtual JumpTo* clone() const override; virtual JumpTo* reverse(void) const override; private: JumpTo() {} virtual ~JumpTo() {} CC_DISALLOW_COPY_AND_ASSIGN(JumpTo); }; /** Bezier configuration structure */ typedef struct _ccBezierConfig { //! end position of the bezier Point endPosition; //! Bezier control point 1 Point controlPoint_1; //! Bezier control point 2 Point controlPoint_2; } ccBezierConfig; /** @brief An action that moves the target with a cubic Bezier curve by a certain distance. */ class CC_DLL BezierBy : public ActionInterval { public: /** creates the action with a duration and a bezier configuration * @code * when this function bound to js or lua,the input params are changed * in js: var create(var t,var table) * in lua: lcaol create(local t, local table) * @endcode */ static BezierBy* create(float t, const ccBezierConfig& c); // // Overrides // virtual BezierBy* clone() const override; virtual BezierBy* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: BezierBy() {} virtual ~BezierBy() {} /** initializes the action with a duration and a bezier configuration */ bool initWithDuration(float t, const ccBezierConfig& c); ccBezierConfig _config; Point _startPosition; Point _previousPosition; private: CC_DISALLOW_COPY_AND_ASSIGN(BezierBy); }; /** @brief An action that moves the target with a cubic Bezier curve to a destination point. @since v0.8.2 */ class CC_DLL BezierTo : public BezierBy { public: /** creates the action with a duration and a bezier configuration * @code * when this function bound to js or lua,the input params are changed * in js: var create(var t,var table) * in lua: lcaol create(local t, local table) * @endcode */ static BezierTo* create(float t, const ccBezierConfig& c); // // Overrides // virtual void startWithTarget(Node *target) override; virtual BezierTo* clone() const override; virtual BezierTo* reverse(void) const override; protected: BezierTo() {} virtual ~BezierTo() {} bool initWithDuration(float t, const ccBezierConfig &c); ccBezierConfig _toConfig; private: CC_DISALLOW_COPY_AND_ASSIGN(BezierTo); }; /** @brief Scales a Node object to a zoom factor by modifying it's scale attribute. @warning This action doesn't support "reverse" */ class CC_DLL ScaleTo : public ActionInterval { public: /** creates the action with the same scale factor for X and Y */ static ScaleTo* create(float duration, float s); /** creates the action with and X factor and a Y factor */ static ScaleTo* create(float duration, float sx, float sy); // // Overrides // virtual ScaleTo* clone() const override; virtual ScaleTo* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: ScaleTo() {} virtual ~ScaleTo() {} /** initializes the action with the same scale factor for X and Y */ bool initWithDuration(float duration, float s); /** initializes the action with and X factor and a Y factor */ bool initWithDuration(float duration, float sx, float sy); float _scaleX; float _scaleY; float _startScaleX; float _startScaleY; float _endScaleX; float _endScaleY; float _deltaX; float _deltaY; private: CC_DISALLOW_COPY_AND_ASSIGN(ScaleTo); }; /** @brief Scales a Node object a zoom factor by modifying it's scale attribute. */ class CC_DLL ScaleBy : public ScaleTo { public: /** creates the action with the same scale factor for X and Y */ static ScaleBy* create(float duration, float s); /** creates the action with and X factor and a Y factor */ static ScaleBy* create(float duration, float sx, float sy); // // Overrides // virtual void startWithTarget(Node *target) override; virtual ScaleBy* clone() const override; virtual ScaleBy* reverse(void) const override; protected: ScaleBy() {} virtual ~ScaleBy() {} private: CC_DISALLOW_COPY_AND_ASSIGN(ScaleBy); }; /** @brief Blinks a Node object by modifying it's visible attribute */ class CC_DLL Blink : public ActionInterval { public: /** creates the action */ static Blink* create(float duration, int blinks); // // Overrides // virtual Blink* clone() const override; virtual Blink* reverse(void) const override; virtual void update(float time) override; virtual void startWithTarget(Node *target) override; virtual void stop() override; protected: Blink() {} virtual ~Blink() {} /** initializes the action */ bool initWithDuration(float duration, int blinks); int _times; bool _originalState; private: CC_DISALLOW_COPY_AND_ASSIGN(Blink); }; /** @brief Fades In an object that implements the RGBAProtocol protocol. It modifies the opacity from 0 to 255. The "reverse" of this action is FadeOut */ class CC_DLL FadeIn : public ActionInterval { public: /** creates the action */ static FadeIn* create(float d); // // Overrides // virtual void update(float time) override; virtual FadeIn* clone() const override; virtual ActionInterval* reverse(void) const override; protected: FadeIn() {} virtual ~FadeIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(FadeIn); }; /** @brief Fades Out an object that implements the RGBAProtocol protocol. It modifies the opacity from 255 to 0. The "reverse" of this action is FadeIn */ class CC_DLL FadeOut : public ActionInterval { public: /** creates the action */ static FadeOut* create(float d); // // Overrides // virtual void update(float time) override; virtual FadeOut* clone() const override; virtual ActionInterval* reverse(void) const override; protected: FadeOut() {} virtual ~FadeOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(FadeOut); }; /** @brief Fades an object that implements the RGBAProtocol protocol. It modifies the opacity from the current value to a custom one. @warning This action doesn't support "reverse" */ class CC_DLL FadeTo : public ActionInterval { public: /** creates an action with duration and opacity */ static FadeTo* create(float duration, GLubyte opacity); // // Overrides // virtual FadeTo* clone() const override; virtual FadeTo* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: FadeTo() {} virtual ~FadeTo() {} /** initializes the action with duration and opacity */ bool initWithDuration(float duration, GLubyte opacity); GLubyte _toOpacity; GLubyte _fromOpacity; private: CC_DISALLOW_COPY_AND_ASSIGN(FadeTo); }; /** @brief Tints a Node that implements the NodeRGB protocol from current tint to a custom one. @warning This action doesn't support "reverse" @since v0.7.2 */ class CC_DLL TintTo : public ActionInterval { public: /** creates an action with duration and color */ static TintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue); // // Overrides // virtual TintTo* clone() const override; virtual TintTo* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: TintTo() {} virtual ~TintTo() {} /** initializes the action with duration and color */ bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); Color3B _to; Color3B _from; private: CC_DISALLOW_COPY_AND_ASSIGN(TintTo); }; /** @brief Tints a Node that implements the NodeRGB protocol from current tint to a custom one. @since v0.7.2 */ class CC_DLL TintBy : public ActionInterval { public: /** creates an action with duration and color */ static TintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); // // Overrides // virtual TintBy* clone() const override; virtual TintBy* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: TintBy() {} virtual ~TintBy() {} /** initializes the action with duration and color */ bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); GLshort _deltaR; GLshort _deltaG; GLshort _deltaB; GLshort _fromR; GLshort _fromG; GLshort _fromB; private: CC_DISALLOW_COPY_AND_ASSIGN(TintBy); }; /** @brief Delays the action a certain amount of seconds */ class CC_DLL DelayTime : public ActionInterval { public: /** creates the action */ static DelayTime* create(float d); // // Overrides // virtual void update(float time) override; virtual DelayTime* reverse() const override; virtual DelayTime* clone() const override; protected: DelayTime() {} virtual ~DelayTime() {} private: CC_DISALLOW_COPY_AND_ASSIGN(DelayTime); }; /** @brief Executes an action in reverse order, from time=duration to time=0 @warning Use this action carefully. This action is not sequenceable. Use it as the default "reversed" method of your own actions, but using it outside the "reversed" scope is not recommended. */ class CC_DLL ReverseTime : public ActionInterval { public: /** creates the action */ static ReverseTime* create(FiniteTimeAction *action); // // Overrides // virtual ReverseTime* reverse() const override; virtual ReverseTime* clone() const override; virtual void startWithTarget(Node *target) override; virtual void stop(void) override; virtual void update(float time) override; protected: ReverseTime(); virtual ~ReverseTime(void); /** initializes the action */ bool initWithAction(FiniteTimeAction *action); FiniteTimeAction *_other; private: CC_DISALLOW_COPY_AND_ASSIGN(ReverseTime); }; class Texture2D; /** @brief Animates a sprite given the name of an Animation */ class CC_DLL Animate : public ActionInterval { public: /** creates the action with an Animation and will restore the original frame when the animation is over */ static Animate* create(Animation *animation); /** sets the Animation object to be animated */ void setAnimation( Animation* animation ); /** returns the Animation object that is being animated */ Animation* getAnimation() { return _animation; } const Animation* getAnimation() const { return _animation; } // // Overrides // virtual Animate* clone() const override; virtual Animate* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void stop(void) override; virtual void update(float t) override; protected: Animate(); virtual ~Animate(); /** initializes the action with an Animation and will restore the original frame when the animation is over */ bool initWithAnimation(Animation *animation); std::vector* _splitTimes; int _nextFrame; SpriteFrame* _origFrame; unsigned int _executedLoops; Animation* _animation; private: CC_DISALLOW_COPY_AND_ASSIGN(Animate); }; /** Overrides the target of an action so that it always runs on the target * specified at action creation rather than the one specified by runAction. */ class CC_DLL TargetedAction : public ActionInterval { public: /** Create an action with the specified action and forced target */ static TargetedAction* create(Node* target, FiniteTimeAction* action); /** Sets the target that the action will be forced to run with */ void setForcedTarget(Node* forcedTarget); /** returns the target that the action is forced to run with */ Node* getForcedTarget() { return _forcedTarget; } const Node* getForcedTarget() const { return _forcedTarget; } // // Overrides // virtual TargetedAction* clone() const override; virtual TargetedAction* reverse() const override; virtual void startWithTarget(Node *target) override; virtual void stop(void) override; virtual void update(float time) override; protected: TargetedAction(); virtual ~TargetedAction(); /** Init an action with the specified action and forced target */ bool initWithTarget(Node* target, FiniteTimeAction* action); FiniteTimeAction* _action; Node* _forcedTarget; private: CC_DISALLOW_COPY_AND_ASSIGN(TargetedAction); }; // end of actions group /// @} NS_CC_END #endif //__ACTION_CCINTERVAL_ACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionManager.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionManager.h" #include "CCNode.h" #include "CCScheduler.h" #include "ccMacros.h" #include "ccCArray.h" #include "uthash.h" #include "CCSet.h" NS_CC_BEGIN // // singleton stuff // typedef struct _hashElement { struct _ccArray *actions; Node *target; int actionIndex; Action *currentAction; bool currentActionSalvaged; bool paused; UT_hash_handle hh; } tHashElement; ActionManager::ActionManager(void) : _targets(nullptr), _currentTarget(nullptr), _currentTargetSalvaged(false) { } ActionManager::~ActionManager(void) { CCLOGINFO("deallocing ActionManager: %p", this); removeAllActions(); } // private void ActionManager::deleteHashElement(tHashElement *element) { ccArrayFree(element->actions); HASH_DEL(_targets, element); element->target->release(); free(element); } void ActionManager::actionAllocWithHashElement(tHashElement *element) { // 4 actions per Node by default if (element->actions == nullptr) { element->actions = ccArrayNew(4); }else if (element->actions->num == element->actions->max) { ccArrayDoubleCapacity(element->actions); } } void ActionManager::removeActionAtIndex(ssize_t index, tHashElement *element) { Action *action = (Action*)element->actions->arr[index]; if (action == element->currentAction && (! element->currentActionSalvaged)) { element->currentAction->retain(); element->currentActionSalvaged = true; } ccArrayRemoveObjectAtIndex(element->actions, index, true); // update actionIndex in case we are in tick. looping over the actions if (element->actionIndex >= index) { element->actionIndex--; } if (element->actions->num == 0) { if (_currentTarget == element) { _currentTargetSalvaged = true; } else { deleteHashElement(element); } } } // pause / resume void ActionManager::pauseTarget(Node *target) { tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); if (element) { element->paused = true; } } void ActionManager::resumeTarget(Node *target) { tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); if (element) { element->paused = false; } } Vector ActionManager::pauseAllRunningActions() { Vector idsWithActions; for (tHashElement *element=_targets; element != nullptr; element = (tHashElement *)element->hh.next) { if (! element->paused) { element->paused = true; idsWithActions.pushBack(element->target); } } return idsWithActions; } void ActionManager::resumeTargets(const Vector& targetsToResume) { for(const auto &node : targetsToResume) { this->resumeTarget(node); } } // run void ActionManager::addAction(Action *action, Node *target, bool paused) { CCASSERT(action != nullptr, ""); CCASSERT(target != nullptr, ""); tHashElement *element = nullptr; // we should convert it to Object*, because we save it as Object* Object *tmp = target; HASH_FIND_PTR(_targets, &tmp, element); if (! element) { element = (tHashElement*)calloc(sizeof(*element), 1); element->paused = paused; target->retain(); element->target = target; HASH_ADD_PTR(_targets, target, element); } actionAllocWithHashElement(element); CCASSERT(! ccArrayContainsObject(element->actions, action), ""); ccArrayAppendObject(element->actions, action); action->startWithTarget(target); } // remove void ActionManager::removeAllActions() { for (tHashElement *element = _targets; element != nullptr; ) { auto target = element->target; element = (tHashElement*)element->hh.next; removeAllActionsFromTarget(target); } } void ActionManager::removeAllActionsFromTarget(Node *target) { // explicit null handling if (target == nullptr) { return; } tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); if (element) { if (ccArrayContainsObject(element->actions, element->currentAction) && (! element->currentActionSalvaged)) { element->currentAction->retain(); element->currentActionSalvaged = true; } ccArrayRemoveAllObjects(element->actions); if (_currentTarget == element) { _currentTargetSalvaged = true; } else { deleteHashElement(element); } } else { // CCLOG("cocos2d: removeAllActionsFromTarget: Target not found"); } } void ActionManager::removeAction(Action *action) { // explicit null handling if (action == nullptr) { return; } tHashElement *element = nullptr; Object *target = action->getOriginalTarget(); HASH_FIND_PTR(_targets, &target, element); if (element) { auto i = ccArrayGetIndexOfObject(element->actions, action); if (i != CC_INVALID_INDEX) { removeActionAtIndex(i, element); } } else { CCLOG("cocos2d: removeAction: Target not found"); } } void ActionManager::removeActionByTag(int tag, Node *target) { CCASSERT(tag != Action::INVALID_TAG, ""); CCASSERT(target != nullptr, ""); tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); if (element) { auto limit = element->actions->num; for (int i = 0; i < limit; ++i) { Action *action = (Action*)element->actions->arr[i]; if (action->getTag() == (int)tag && action->getOriginalTarget() == target) { removeActionAtIndex(i, element); break; } } } } // get // XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer // and, it is not possible to get the address of a reference Action* ActionManager::getActionByTag(int tag, const Node *target) const { CCASSERT(tag != Action::INVALID_TAG, ""); tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); if (element) { if (element->actions != nullptr) { auto limit = element->actions->num; for (int i = 0; i < limit; ++i) { Action *action = (Action*)element->actions->arr[i]; if (action->getTag() == (int)tag) { return action; } } } CCLOG("cocos2d : getActionByTag(tag = %d): Action not found", tag); } else { // CCLOG("cocos2d : getActionByTag: Target not found"); } return nullptr; } // XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer // and, it is not possible to get the address of a reference ssize_t ActionManager::getNumberOfRunningActionsInTarget(const Node *target) const { tHashElement *element = nullptr; HASH_FIND_PTR(_targets, &target, element); if (element) { return element->actions ? element->actions->num : 0; } return 0; } // main loop void ActionManager::update(float dt) { for (tHashElement *elt = _targets; elt != nullptr; ) { _currentTarget = elt; _currentTargetSalvaged = false; if (! _currentTarget->paused) { // The 'actions' MutableArray may change while inside this loop. for (_currentTarget->actionIndex = 0; _currentTarget->actionIndex < _currentTarget->actions->num; _currentTarget->actionIndex++) { _currentTarget->currentAction = (Action*)_currentTarget->actions->arr[_currentTarget->actionIndex]; if (_currentTarget->currentAction == nullptr) { continue; } _currentTarget->currentActionSalvaged = false; _currentTarget->currentAction->step(dt); if (_currentTarget->currentActionSalvaged) { // The currentAction told the node to remove it. To prevent the action from // accidentally deallocating itself before finishing its step, we retained // it. Now that step is done, it's safe to release it. _currentTarget->currentAction->release(); } else if (_currentTarget->currentAction->isDone()) { _currentTarget->currentAction->stop(); Action *action = _currentTarget->currentAction; // Make currentAction nil to prevent removeAction from salvaging it. _currentTarget->currentAction = nullptr; removeAction(action); } _currentTarget->currentAction = nullptr; } } // elt, at this moment, is still valid // so it is safe to ask this here (issue #490) elt = (tHashElement*)(elt->hh.next); // only delete currentTarget if no actions were scheduled during the cycle (issue #481) if (_currentTargetSalvaged && _currentTarget->actions->num == 0) { deleteHashElement(_currentTarget); } } // issue #635 _currentTarget = nullptr; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionManager.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTION_CCACTION_MANAGER_H__ #define __ACTION_CCACTION_MANAGER_H__ #include "CCAction.h" #include "CCVector.h" #include "CCObject.h" NS_CC_BEGIN struct _hashElement; /** * @addtogroup actions * @{ */ /** @brief ActionManager is a singleton that manages all the actions. Normally you won't need to use this singleton directly. 99% of the cases you will use the Node interface, which uses this singleton. But there are some cases where you might need to use this singleton. Examples: - When you want to run an action where the target is different from a Node. - When you want to pause / resume the actions @since v0.8 */ class CC_DLL ActionManager : public Object { public: /** * @js ctor */ ActionManager(void); /** * @js NA * @lua NA */ ~ActionManager(void); // actions /** Adds an action with a target. If the target is already present, then the action will be added to the existing target. If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target. When the target is paused, the queued actions won't be 'ticked'. */ void addAction(Action *action, Node *target, bool paused); /** Removes all actions from all the targets. */ void removeAllActions(); /** Removes all actions from a certain target. All the actions that belongs to the target will be removed. */ void removeAllActionsFromTarget(Node *target); /** Removes an action given an action reference. */ void removeAction(Action *action); /** Removes an action given its tag and the target */ void removeActionByTag(int tag, Node *target); /** Gets an action given its tag an a target @return the Action the with the given tag */ Action* getActionByTag(int tag, const Node *target) const; /** Returns the numbers of actions that are running in a certain target. * Composable actions are counted as 1 action. Example: * - If you are running 1 Sequence of 7 actions, it will return 1. * - If you are running 7 Sequences of 2 actions, it will return 7. */ ssize_t getNumberOfRunningActionsInTarget(const Node *target) const; /** @deprecated use getNumberOfRunningActionsInTarget() instead */ CC_DEPRECATED_ATTRIBUTE inline ssize_t numberOfRunningActionsInTarget(Node *target) const { return getNumberOfRunningActionsInTarget(target); } /** Pauses the target: all running actions and newly added actions will be paused. */ void pauseTarget(Node *target); /** Resumes the target. All queued actions will be resumed. */ void resumeTarget(Node *target); /** Pauses all running actions, returning a list of targets whose actions were paused. */ Vector pauseAllRunningActions(); /** Resume a set of targets (convenience function to reverse a pauseAllRunningActions call) */ void resumeTargets(const Vector& targetsToResume); protected: // declared in ActionManager.m void removeActionAtIndex(ssize_t index, struct _hashElement *element); void deleteHashElement(struct _hashElement *element); void actionAllocWithHashElement(struct _hashElement *element); void update(float dt); protected: struct _hashElement *_targets; struct _hashElement *_currentTarget; bool _currentTargetSalvaged; }; // end of actions group /// @} NS_CC_END #endif // __ACTION_CCACTION_MANAGER_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionPageTurn3D.cpp ================================================ /**************************************************************************** Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionPageTurn3D.h" NS_CC_BEGIN PageTurn3D* PageTurn3D::create(float duration, const Size& gridSize) { PageTurn3D *action = new PageTurn3D(); if (action) { if (action->initWithDuration(duration, gridSize)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } PageTurn3D *PageTurn3D::clone() const { // no copy constructor auto a = new PageTurn3D(); a->initWithDuration(_duration, _gridSize); a->autorelease(); return a; } /* * Update each tick * Time is the percentage of the way through the duration */ void PageTurn3D::update(float time) { float tt = MAX(0, time - 0.25f); float deltaAy = (tt * tt * 500); float ay = -100 - deltaAy; float deltaTheta = - (float) M_PI_2 * sqrtf( time) ; float theta = /*0.01f */ + (float) M_PI_2 +deltaTheta; float sinTheta = sinf(theta); float cosTheta = cosf(theta); for (int i = 0; i <= _gridSize.width; ++i) { for (int j = 0; j <= _gridSize.height; ++j) { // Get original vertex Vertex3F p = getOriginalVertex(Point(i ,j)); float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay))); float r = R * sinTheta; float alpha = asinf( p.x / R ); float beta = alpha / sinTheta; float cosBeta = cosf( beta ); // If beta > PI then we've wrapped around the cone // Reduce the radius to stop these points interfering with others if (beta <= M_PI) { p.x = ( r * sinf(beta)); } else { // Force X = 0 to stop wrapped // points p.x = 0; } p.y = ( R + ay - ( r * (1 - cosBeta) * sinTheta)); // We scale z here to avoid the animation being // too much bigger than the screen due to perspective transform p.z = (r * ( 1 - cosBeta ) * cosTheta) / 7;// "100" didn't work for // Stop z coord from dropping beneath underlying page in a transition // issue #751 if( p.z < 0.5f ) { p.z = 0.5f; } // Set new coords setVertex(Point(i, j), p); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionPageTurn3D.h ================================================ /**************************************************************************** Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTION_CCPAGETURN3D_ACTION_H__ #define __ACTION_CCPAGETURN3D_ACTION_H__ #include "CCActionGrid3D.h" NS_CC_BEGIN /** * @addtogroup actions * @{ */ /** @brief This action simulates a page turn from the bottom right hand corner of the screen. It's not much use by itself but is used by the PageTurnTransition. Based on an original paper by L Hong et al. http://www.parc.com/publication/1638/turning-pages-of-3d-electronic-books.html @since v0.8.2 */ class CC_DLL PageTurn3D : public Grid3DAction { public: /** create the action */ static PageTurn3D* create(float duration, const Size& gridSize); // Overrides virtual PageTurn3D* clone() const override; virtual void update(float time) override; }; // end of actions group /// @} NS_CC_END #endif // __ACTION_CCPAGETURN3D_ACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionProgressTimer.cpp ================================================ /**************************************************************************** Copyright (C) 2010 Lam Pham Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionProgressTimer.h" #include "CCProgressTimer.h" NS_CC_BEGIN #define kProgressTimerCast ProgressTimer* // implementation of ProgressTo ProgressTo* ProgressTo::create(float duration, float percent) { ProgressTo *progressTo = new ProgressTo(); progressTo->initWithDuration(duration, percent); progressTo->autorelease(); return progressTo; } bool ProgressTo::initWithDuration(float duration, float percent) { if (ActionInterval::initWithDuration(duration)) { _to = percent; return true; } return false; } ProgressTo* ProgressTo::clone() const { // no copy constructor auto a = new ProgressTo(); a->initWithDuration(_duration, _to); a->autorelease(); return a; } ProgressTo* ProgressTo::reverse() const { CCASSERT(false, "reverse() not supported in ProgressTo"); return nullptr; } void ProgressTo::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); _from = ((kProgressTimerCast)(target))->getPercentage(); // XXX: Is this correct ? // Adding it to support Repeat if (_from == 100) { _from = 0; } } void ProgressTo::update(float time) { ((kProgressTimerCast)(_target))->setPercentage(_from + (_to - _from) * time); } // implementation of ProgressFromTo ProgressFromTo* ProgressFromTo::create(float duration, float fromPercentage, float toPercentage) { ProgressFromTo *progressFromTo = new ProgressFromTo(); progressFromTo->initWithDuration(duration, fromPercentage, toPercentage); progressFromTo->autorelease(); return progressFromTo; } bool ProgressFromTo::initWithDuration(float duration, float fromPercentage, float toPercentage) { if (ActionInterval::initWithDuration(duration)) { _to = toPercentage; _from = fromPercentage; return true; } return false; } ProgressFromTo* ProgressFromTo::clone() const { // no copy constructor auto a = new ProgressFromTo(); a->initWithDuration(_duration, _from, _to); a->autorelease(); return a; } ProgressFromTo* ProgressFromTo::reverse(void) const { return ProgressFromTo::create(_duration, _to, _from); } void ProgressFromTo::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); } void ProgressFromTo::update(float time) { ((kProgressTimerCast)(_target))->setPercentage(_from + (_to - _from) * time); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionProgressTimer.h ================================================ /**************************************************************************** Copyright (C) 2010 Lam Pham Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTION_CCPROGRESS_TIMER_H__ #define __ACTION_CCPROGRESS_TIMER_H__ #include "CCActionInterval.h" NS_CC_BEGIN /** * @addtogroup actions * @{ */ /** @brief Progress to percentage @since v0.99.1 */ class CC_DLL ProgressTo : public ActionInterval { public: /** Creates and initializes with a duration and a percent */ static ProgressTo* create(float duration, float percent); // // Overrides // virtual ProgressTo* clone() const override; virtual ProgressTo* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: ProgressTo() {} virtual ~ProgressTo() {} /** Initializes with a duration and a percent */ bool initWithDuration(float duration, float percent); float _to; float _from; private: CC_DISALLOW_COPY_AND_ASSIGN(ProgressTo); }; /** @brief Progress from a percentage to another percentage @since v0.99.1 */ class CC_DLL ProgressFromTo : public ActionInterval { public: /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */ static ProgressFromTo* create(float duration, float fromPercentage, float toPercentage); // // Overrides // virtual ProgressFromTo* clone() const override; virtual ProgressFromTo* reverse(void) const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: ProgressFromTo() {} virtual ~ProgressFromTo() {} /** Initializes the action with a duration, a "from" percentage and a "to" percentage */ bool initWithDuration(float duration, float fromPercentage, float toPercentage); float _to; float _from; private: CC_DISALLOW_COPY_AND_ASSIGN(ProgressFromTo); }; // end of actions group /// @} NS_CC_END #endif // __ACTION_CCPROGRESS_TIMER_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionTiledGrid.cpp ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionTiledGrid.h" #include "CCDirector.h" #include "ccMacros.h" #include "CCGrid.h" #include "CCNodeGrid.h" #include NS_CC_BEGIN struct Tile { Point position; Point startPosition; Size delta; }; // implementation of ShakyTiles3D ShakyTiles3D* ShakyTiles3D::create(float duration, const Size& gridSize, int range, bool shakeZ) { ShakyTiles3D *action = new ShakyTiles3D(); if (action) { if (action->initWithDuration(duration, gridSize, range, shakeZ)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool ShakyTiles3D::initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ) { if (TiledGrid3DAction::initWithDuration(duration, gridSize)) { _randrange = range; _shakeZ = shakeZ; return true; } return false; } ShakyTiles3D* ShakyTiles3D::clone() const { // no copy constructor auto a = new ShakyTiles3D(); a->initWithDuration(_duration, _gridSize, _randrange, _shakeZ); a->autorelease(); return a; } void ShakyTiles3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; for (i = 0; i < _gridSize.width; ++i) { for (j = 0; j < _gridSize.height; ++j) { Quad3 coords = getOriginalTile(Point(i, j)); // X coords.bl.x += ( rand() % (_randrange*2) ) - _randrange; coords.br.x += ( rand() % (_randrange*2) ) - _randrange; coords.tl.x += ( rand() % (_randrange*2) ) - _randrange; coords.tr.x += ( rand() % (_randrange*2) ) - _randrange; // Y coords.bl.y += ( rand() % (_randrange*2) ) - _randrange; coords.br.y += ( rand() % (_randrange*2) ) - _randrange; coords.tl.y += ( rand() % (_randrange*2) ) - _randrange; coords.tr.y += ( rand() % (_randrange*2) ) - _randrange; if (_shakeZ) { coords.bl.z += ( rand() % (_randrange*2) ) - _randrange; coords.br.z += ( rand() % (_randrange*2) ) - _randrange; coords.tl.z += ( rand() % (_randrange*2) ) - _randrange; coords.tr.z += ( rand() % (_randrange*2) ) - _randrange; } setTile(Point(i, j), coords); } } } // implementation of ShatteredTiles3D ShatteredTiles3D* ShatteredTiles3D::create(float duration, const Size& gridSize, int range, bool shatterZ) { ShatteredTiles3D *action = new ShatteredTiles3D(); if (action) { if (action->initWithDuration(duration, gridSize, range, shatterZ)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool ShatteredTiles3D::initWithDuration(float duration, const Size& gridSize, int range, bool shatterZ) { if (TiledGrid3DAction::initWithDuration(duration, gridSize)) { _once = false; _randrange = range; _shatterZ = shatterZ; return true; } return false; } ShatteredTiles3D* ShatteredTiles3D::clone() const { // no copy constructor auto a = new ShatteredTiles3D(); a->initWithDuration(_duration, _gridSize, _randrange, _shatterZ); a->autorelease(); return a; } void ShatteredTiles3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; if (_once == false) { for (i = 0; i < _gridSize.width; ++i) { for (j = 0; j < _gridSize.height; ++j) { Quad3 coords = getOriginalTile(Point(i ,j)); // X coords.bl.x += ( rand() % (_randrange*2) ) - _randrange; coords.br.x += ( rand() % (_randrange*2) ) - _randrange; coords.tl.x += ( rand() % (_randrange*2) ) - _randrange; coords.tr.x += ( rand() % (_randrange*2) ) - _randrange; // Y coords.bl.y += ( rand() % (_randrange*2) ) - _randrange; coords.br.y += ( rand() % (_randrange*2) ) - _randrange; coords.tl.y += ( rand() % (_randrange*2) ) - _randrange; coords.tr.y += ( rand() % (_randrange*2) ) - _randrange; if (_shatterZ) { coords.bl.z += ( rand() % (_randrange*2) ) - _randrange; coords.br.z += ( rand() % (_randrange*2) ) - _randrange; coords.tl.z += ( rand() % (_randrange*2) ) - _randrange; coords.tr.z += ( rand() % (_randrange*2) ) - _randrange; } setTile(Point(i, j), coords); } } _once = true; } } // implementation of ShuffleTiles ShuffleTiles* ShuffleTiles::create(float duration, const Size& gridSize, unsigned int seed) { ShuffleTiles *action = new ShuffleTiles(); if (action) { if (action->initWithDuration(duration, gridSize, seed)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool ShuffleTiles::initWithDuration(float duration, const Size& gridSize, unsigned int seed) { if (TiledGrid3DAction::initWithDuration(duration, gridSize)) { _seed = seed; _tilesOrder = nullptr; _tiles = nullptr; return true; } return false; } ShuffleTiles* ShuffleTiles::clone() const { // no copy constructor auto a = new ShuffleTiles(); a->initWithDuration(_duration, _gridSize, _seed); a->autorelease(); return a; } ShuffleTiles::~ShuffleTiles(void) { CC_SAFE_DELETE_ARRAY(_tilesOrder); CC_SAFE_DELETE_ARRAY(_tiles); } void ShuffleTiles::shuffle(unsigned int *array, unsigned int len) { int i; for( i = len - 1; i >= 0; i-- ) { unsigned int j = rand() % (i+1); unsigned int v = array[i]; array[i] = array[j]; array[j] = v; } } Size ShuffleTiles::getDelta(const Size& pos) const { Point pos2; unsigned int idx = pos.width * _gridSize.height + pos.height; pos2.x = (float)(_tilesOrder[idx] / (int)_gridSize.height); pos2.y = (float)(_tilesOrder[idx] % (int)_gridSize.height); return Size((int)(pos2.x - pos.width), (int)(pos2.y - pos.height)); } void ShuffleTiles::placeTile(const Point& pos, Tile *t) { Quad3 coords = getOriginalTile(pos); Point step = _gridNodeTarget->getGrid()->getStep(); coords.bl.x += (int)(t->position.x * step.x); coords.bl.y += (int)(t->position.y * step.y); coords.br.x += (int)(t->position.x * step.x); coords.br.y += (int)(t->position.y * step.y); coords.tl.x += (int)(t->position.x * step.x); coords.tl.y += (int)(t->position.y * step.y); coords.tr.x += (int)(t->position.x * step.x); coords.tr.y += (int)(t->position.y * step.y); setTile(pos, coords); } void ShuffleTiles::startWithTarget(Node *target) { TiledGrid3DAction::startWithTarget(target); if (_seed != (unsigned int)-1) { srand(_seed); } _tilesCount = _gridSize.width * _gridSize.height; _tilesOrder = new unsigned int[_tilesCount]; int i, j; unsigned int k; /** * Use k to loop. Because _tilesCount is unsigned int, * and i is used later for int. */ for (k = 0; k < _tilesCount; ++k) { _tilesOrder[k] = k; } shuffle(_tilesOrder, _tilesCount); _tiles = (struct Tile *)new Tile[_tilesCount]; Tile *tileArray = (Tile*) _tiles; for (i = 0; i < _gridSize.width; ++i) { for (j = 0; j < _gridSize.height; ++j) { tileArray->position = Point((float)i, (float)j); tileArray->startPosition = Point((float)i, (float)j); tileArray->delta = getDelta(Size(i, j)); ++tileArray; } } } void ShuffleTiles::update(float time) { int i, j; Tile *tileArray = (Tile*)_tiles; for (i = 0; i < _gridSize.width; ++i) { for (j = 0; j < _gridSize.height; ++j) { tileArray->position = Point((float)tileArray->delta.width, (float)tileArray->delta.height) * time; placeTile(Point(i, j), tileArray); ++tileArray; } } } // implementation of FadeOutTRTiles FadeOutTRTiles* FadeOutTRTiles::create(float duration, const Size& gridSize) { FadeOutTRTiles *action = new FadeOutTRTiles(); if (action) { if (action->initWithDuration(duration, gridSize)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } FadeOutTRTiles* FadeOutTRTiles::clone() const { // no copy constructor auto a = new FadeOutTRTiles(); a->initWithDuration(_duration, _gridSize); a->autorelease(); return a; } float FadeOutTRTiles::testFunc(const Size& pos, float time) { Point n = Point((float)_gridSize.width, (float)_gridSize.height) * time; if ((n.x + n.y) == 0.0f) { return 1.0f; } return powf((pos.width + pos.height) / (n.x + n.y), 6); } void FadeOutTRTiles::turnOnTile(const Point& pos) { setTile(pos, getOriginalTile(pos)); } void FadeOutTRTiles::turnOffTile(const Point& pos) { Quad3 coords; memset(&coords, 0, sizeof(Quad3)); setTile(pos, coords); } void FadeOutTRTiles::transformTile(const Point& pos, float distance) { Quad3 coords = getOriginalTile(pos); Point step = _gridNodeTarget->getGrid()->getStep(); coords.bl.x += (step.x / 2) * (1.0f - distance); coords.bl.y += (step.y / 2) * (1.0f - distance); coords.br.x -= (step.x / 2) * (1.0f - distance); coords.br.y += (step.y / 2) * (1.0f - distance); coords.tl.x += (step.x / 2) * (1.0f - distance); coords.tl.y -= (step.y / 2) * (1.0f - distance); coords.tr.x -= (step.x / 2) * (1.0f - distance); coords.tr.y -= (step.y / 2) * (1.0f - distance); setTile(pos, coords); } void FadeOutTRTiles::update(float time) { int i, j; for (i = 0; i < _gridSize.width; ++i) { for (j = 0; j < _gridSize.height; ++j) { float distance = testFunc(Size(i, j), time); if ( distance == 0 ) { turnOffTile(Point(i, j)); } else if (distance < 1) { transformTile(Point(i, j), distance); } else { turnOnTile(Point(i, j)); } } } } // implementation of FadeOutBLTiles FadeOutBLTiles* FadeOutBLTiles::create(float duration, const Size& gridSize) { FadeOutBLTiles *action = new FadeOutBLTiles(); if (action) { if (action->initWithDuration(duration, gridSize)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } FadeOutBLTiles* FadeOutBLTiles::clone() const { // no copy constructor auto a = new FadeOutBLTiles(); a->initWithDuration(_duration, _gridSize); a->autorelease(); return a; } float FadeOutBLTiles::testFunc(const Size& pos, float time) { Point n = Point((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time); if ((pos.width + pos.height) == 0) { return 1.0f; } return powf((n.x + n.y) / (pos.width + pos.height), 6); } // implementation of FadeOutUpTiles FadeOutUpTiles* FadeOutUpTiles::create(float duration, const Size& gridSize) { FadeOutUpTiles *action = new FadeOutUpTiles(); if (action) { if (action->initWithDuration(duration, gridSize)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } FadeOutUpTiles* FadeOutUpTiles::clone() const { // no copy constructor auto a = new FadeOutUpTiles(); a->initWithDuration(_duration, _gridSize); a->autorelease(); return a; } float FadeOutUpTiles::testFunc(const Size& pos, float time) { Point n = Point((float)_gridSize.width, (float)_gridSize.height) * time; if (n.y == 0.0f) { return 1.0f; } return powf(pos.height / n.y, 6); } void FadeOutUpTiles::transformTile(const Point& pos, float distance) { Quad3 coords = getOriginalTile(pos); Point step = _gridNodeTarget->getGrid()->getStep(); coords.bl.y += (step.y / 2) * (1.0f - distance); coords.br.y += (step.y / 2) * (1.0f - distance); coords.tl.y -= (step.y / 2) * (1.0f - distance); coords.tr.y -= (step.y / 2) * (1.0f - distance); setTile(pos, coords); } // implementation of FadeOutDownTiles FadeOutDownTiles* FadeOutDownTiles::create(float duration, const Size& gridSize) { FadeOutDownTiles *action = new FadeOutDownTiles(); if (action) { if (action->initWithDuration(duration, gridSize)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } FadeOutDownTiles* FadeOutDownTiles::clone() const { // no copy constructor auto a = new FadeOutDownTiles(); a->initWithDuration(_duration, _gridSize); a->autorelease(); return a; } float FadeOutDownTiles::testFunc(const Size& pos, float time) { Point n = Point((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time); if (pos.height == 0) { return 1.0f; } return powf(n.y / pos.height, 6); } // implementation of TurnOffTiles TurnOffTiles* TurnOffTiles::create(float duration, const Size& gridSize) { TurnOffTiles* pAction = new TurnOffTiles(); if (pAction->initWithDuration(duration, gridSize, 0)) { pAction->autorelease(); } else { CC_SAFE_RELEASE_NULL(pAction); } return pAction; } TurnOffTiles* TurnOffTiles::create(float duration, const Size& gridSize, unsigned int seed) { TurnOffTiles *action = new TurnOffTiles(); if (action) { if (action->initWithDuration(duration, gridSize, seed)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool TurnOffTiles::initWithDuration(float duration, const Size& gridSize, unsigned int seed) { if (TiledGrid3DAction::initWithDuration(duration, gridSize)) { _seed = seed; _tilesOrder = nullptr; return true; } return false; } TurnOffTiles* TurnOffTiles::clone() const { // no copy constructor auto a = new TurnOffTiles(); a->initWithDuration(_duration, _gridSize, _seed ); a->autorelease(); return a; } TurnOffTiles::~TurnOffTiles(void) { CC_SAFE_DELETE_ARRAY(_tilesOrder); } void TurnOffTiles::shuffle(unsigned int *array, unsigned int len) { int i; for (i = len - 1; i >= 0; i--) { unsigned int j = rand() % (i+1); unsigned int v = array[i]; array[i] = array[j]; array[j] = v; } } void TurnOffTiles::turnOnTile(const Point& pos) { setTile(pos, getOriginalTile(pos)); } void TurnOffTiles::turnOffTile(const Point& pos) { Quad3 coords; memset(&coords, 0, sizeof(Quad3)); setTile(pos, coords); } void TurnOffTiles::startWithTarget(Node *target) { unsigned int i; TiledGrid3DAction::startWithTarget(target); if (_seed != (unsigned int)-1) { srand(_seed); } _tilesCount = _gridSize.width * _gridSize.height; _tilesOrder = new unsigned int[_tilesCount]; for (i = 0; i < _tilesCount; ++i) { _tilesOrder[i] = i; } shuffle(_tilesOrder, _tilesCount); } void TurnOffTiles::update(float time) { unsigned int i, l, t; l = (unsigned int)(time * (float)_tilesCount); for( i = 0; i < _tilesCount; i++ ) { t = _tilesOrder[i]; Point tilePos = Point( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height ); if ( i < l ) { turnOffTile(tilePos); } else { turnOnTile(tilePos); } } } // implementation of WavesTiles3D WavesTiles3D* WavesTiles3D::create(float duration, const Size& gridSize, unsigned int waves, float amplitude) { WavesTiles3D *action = new WavesTiles3D(); if (action) { if (action->initWithDuration(duration, gridSize, waves, amplitude)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool WavesTiles3D::initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude) { if (TiledGrid3DAction::initWithDuration(duration, gridSize)) { _waves = waves; _amplitude = amplitude; _amplitudeRate = 1.0f; return true; } return false; } WavesTiles3D* WavesTiles3D::clone() const { // no copy constructor auto a = new WavesTiles3D(); a->initWithDuration(_duration, _gridSize, _waves, _amplitude); a->autorelease(); return a; } void WavesTiles3D::update(float time) { int i, j; for( i = 0; i < _gridSize.width; i++ ) { for( j = 0; j < _gridSize.height; j++ ) { Quad3 coords = getOriginalTile(Point(i, j)); coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 + (coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate ); coords.br.z = coords.bl.z; coords.tl.z = coords.bl.z; coords.tr.z = coords.bl.z; setTile(Point(i, j), coords); } } } // implementation of JumpTiles3D JumpTiles3D* JumpTiles3D::create(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude) { JumpTiles3D *action = new JumpTiles3D(); if (action) { if (action->initWithDuration(duration, gridSize, numberOfJumps, amplitude)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool JumpTiles3D::initWithDuration(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude) { if (TiledGrid3DAction::initWithDuration(duration, gridSize)) { _jumps = numberOfJumps; _amplitude = amplitude; _amplitudeRate = 1.0f; return true; } return false; } JumpTiles3D* JumpTiles3D::clone() const { // no copy constructor auto a = new JumpTiles3D(); a->initWithDuration(_duration, _gridSize, _jumps, _amplitude); a->autorelease(); return a; } void JumpTiles3D::update(float time) { int i, j; float sinz = (sinf((float)M_PI * time * _jumps * 2) * _amplitude * _amplitudeRate ); float sinz2 = (sinf((float)M_PI * (time * _jumps * 2 + 1)) * _amplitude * _amplitudeRate ); for( i = 0; i < _gridSize.width; i++ ) { for( j = 0; j < _gridSize.height; j++ ) { Quad3 coords = getOriginalTile(Point(i, j)); if ( ((i+j) % 2) == 0 ) { coords.bl.z += sinz; coords.br.z += sinz; coords.tl.z += sinz; coords.tr.z += sinz; } else { coords.bl.z += sinz2; coords.br.z += sinz2; coords.tl.z += sinz2; coords.tr.z += sinz2; } setTile(Point(i, j), coords); } } } // implementation of SplitRows SplitRows* SplitRows::create(float duration, unsigned int nRows) { SplitRows *action = new SplitRows(); if (action) { if (action->initWithDuration(duration, nRows)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool SplitRows::initWithDuration(float duration, unsigned int rows) { _rows = rows; return TiledGrid3DAction::initWithDuration(duration, Size(1, rows)); } SplitRows* SplitRows::clone() const { // no copy constructor auto a = new SplitRows(); a->initWithDuration(_duration, _rows); a->autorelease(); return a; } void SplitRows::startWithTarget(Node *target) { TiledGrid3DAction::startWithTarget(target); _winSize = Director::getInstance()->getWinSizeInPixels(); } void SplitRows::update(float time) { unsigned int j; for (j = 0; j < _gridSize.height; ++j) { Quad3 coords = getOriginalTile(Point(0, j)); float direction = 1; if ( (j % 2 ) == 0 ) { direction = -1; } coords.bl.x += direction * _winSize.width * time; coords.br.x += direction * _winSize.width * time; coords.tl.x += direction * _winSize.width * time; coords.tr.x += direction * _winSize.width * time; setTile(Point(0, j), coords); } } // implementation of SplitCols SplitCols* SplitCols::create(float duration, unsigned int cols) { SplitCols *action = new SplitCols(); if (action) { if (action->initWithDuration(duration, cols)) { action->autorelease(); } else { CC_SAFE_RELEASE_NULL(action); } } return action; } bool SplitCols::initWithDuration(float duration, unsigned int cols) { _cols = cols; return TiledGrid3DAction::initWithDuration(duration, Size(cols, 1)); } SplitCols* SplitCols::clone() const { // no copy constructor auto a = new SplitCols(); a->initWithDuration(_duration, _cols); a->autorelease(); return a; } void SplitCols::startWithTarget(Node *target) { TiledGrid3DAction::startWithTarget(target); _winSize = Director::getInstance()->getWinSizeInPixels(); } void SplitCols::update(float time) { unsigned int i; for (i = 0; i < _gridSize.width; ++i) { Quad3 coords = getOriginalTile(Point(i, 0)); float direction = 1; if ( (i % 2 ) == 0 ) { direction = -1; } coords.bl.y += direction * _winSize.height * time; coords.br.y += direction * _winSize.height * time; coords.tl.y += direction * _winSize.height * time; coords.tr.y += direction * _winSize.height * time; setTile(Point(i, 0), coords); } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionTiledGrid.h ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ACTION_CCTILEDGRID_ACTION_H__ #define __ACTION_CCTILEDGRID_ACTION_H__ #include "CCActionGrid.h" NS_CC_BEGIN /** * @addtogroup actions * @{ */ /** @brief ShakyTiles3D action */ class CC_DLL ShakyTiles3D : public TiledGrid3DAction { public: /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration */ static ShakyTiles3D* create(float duration, const Size& gridSize, int range, bool shakeZ); // Override virtual ShakyTiles3D* clone() const override; virtual void update(float time) override; protected: ShakyTiles3D() {} virtual ~ShakyTiles3D() {} /** initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration */ bool initWithDuration(float duration, const Size& gridSize, int range, bool shakeZ); int _randrange; bool _shakeZ; private: CC_DISALLOW_COPY_AND_ASSIGN(ShakyTiles3D); }; /** @brief ShatteredTiles3D action */ class CC_DLL ShatteredTiles3D : public TiledGrid3DAction { public: /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */ static ShatteredTiles3D* create(float duration, const Size& gridSize, int range, bool shatterZ); // Override virtual ShatteredTiles3D* clone() const override; virtual void update(float time) override; protected: ShatteredTiles3D() {} virtual ~ShatteredTiles3D() {} /** initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration */ bool initWithDuration(float duration, const Size& gridSize, int range, bool shatterZ); int _randrange; bool _once; bool _shatterZ; private: CC_DISALLOW_COPY_AND_ASSIGN(ShatteredTiles3D); }; struct Tile; /** @brief ShuffleTiles action Shuffle the tiles in random order */ class CC_DLL ShuffleTiles : public TiledGrid3DAction { public: /** creates the action with a random seed, the grid size and the duration */ static ShuffleTiles* create(float duration, const Size& gridSize, unsigned int seed); void shuffle(unsigned int *array, unsigned int len); Size getDelta(const Size& pos) const; void placeTile(const Point& pos, Tile *t); // Overrides virtual void startWithTarget(Node *target) override; virtual void update(float time) override; virtual ShuffleTiles* clone() const override; protected: ShuffleTiles() {} virtual ~ShuffleTiles(); /** initializes the action with a random seed, the grid size and the duration */ bool initWithDuration(float duration, const Size& gridSize, unsigned int seed); unsigned int _seed; unsigned int _tilesCount; unsigned int* _tilesOrder; Tile* _tiles; private: CC_DISALLOW_COPY_AND_ASSIGN(ShuffleTiles); }; /** @brief FadeOutTRTiles action Fades out the tiles in a Top-Right direction */ class CC_DLL FadeOutTRTiles : public TiledGrid3DAction { public: /** creates the action with the grid size and the duration */ static FadeOutTRTiles* create(float duration, const Size& gridSize); virtual float testFunc(const Size& pos, float time); void turnOnTile(const Point& pos); void turnOffTile(const Point& pos); virtual void transformTile(const Point& pos, float distance); // Overrides virtual void update(float time) override; virtual FadeOutTRTiles* clone() const override; protected: FadeOutTRTiles() {} virtual ~FadeOutTRTiles() {} private: CC_DISALLOW_COPY_AND_ASSIGN(FadeOutTRTiles); }; /** @brief FadeOutBLTiles action. Fades out the tiles in a Bottom-Left direction */ class CC_DLL FadeOutBLTiles : public FadeOutTRTiles { public: /** creates the action with the grid size and the duration */ static FadeOutBLTiles* create(float duration, const Size& gridSize); // Overrides virtual float testFunc(const Size& pos, float time) override; virtual FadeOutBLTiles* clone() const override; protected: FadeOutBLTiles() {} virtual ~FadeOutBLTiles() {} private: CC_DISALLOW_COPY_AND_ASSIGN(FadeOutBLTiles); }; /** @brief FadeOutUpTiles action. Fades out the tiles in upwards direction */ class CC_DLL FadeOutUpTiles : public FadeOutTRTiles { public: /** creates the action with the grid size and the duration */ static FadeOutUpTiles* create(float duration, const Size& gridSize); virtual void transformTile(const Point& pos, float distance); // Overrides virtual FadeOutUpTiles* clone() const override; virtual float testFunc(const Size& pos, float time) override; protected: FadeOutUpTiles() {} virtual ~FadeOutUpTiles() {} private: CC_DISALLOW_COPY_AND_ASSIGN(FadeOutUpTiles); }; /** @brief FadeOutDownTiles action. Fades out the tiles in downwards direction */ class CC_DLL FadeOutDownTiles : public FadeOutUpTiles { public: /** creates the action with the grid size and the duration */ static FadeOutDownTiles* create(float duration, const Size& gridSize); // Overrides virtual FadeOutDownTiles* clone() const override; virtual float testFunc(const Size& pos, float time) override; protected: FadeOutDownTiles() {} virtual ~FadeOutDownTiles() {} private: CC_DISALLOW_COPY_AND_ASSIGN(FadeOutDownTiles); }; /** @brief TurnOffTiles action. Turn off the files in random order */ class CC_DLL TurnOffTiles : public TiledGrid3DAction { public: /** creates the action with the grid size and the duration */ static TurnOffTiles* create(float duration, const Size& gridSize); /** creates the action with a random seed, the grid size and the duration */ static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed); void shuffle(unsigned int *array, unsigned int len); void turnOnTile(const Point& pos); void turnOffTile(const Point& pos); // Overrides virtual TurnOffTiles* clone() const override; virtual void startWithTarget(Node *target) override; virtual void update(float time) override; protected: TurnOffTiles() {} virtual ~TurnOffTiles(); /** initializes the action with a random seed, the grid size and the duration */ bool initWithDuration(float duration, const Size& gridSize, unsigned int seed); unsigned int _seed; unsigned int _tilesCount; unsigned int* _tilesOrder; private: CC_DISALLOW_COPY_AND_ASSIGN(TurnOffTiles); }; /** @brief WavesTiles3D action. */ class CC_DLL WavesTiles3D : public TiledGrid3DAction { public: /** creates the action with a number of waves, the waves amplitude, the grid size and the duration */ static WavesTiles3D* create(float duration, const Size& gridSize, unsigned int waves, float amplitude); /** waves amplitude */ inline float getAmplitude(void) const { return _amplitude; } inline void setAmplitude(float amplitude) { _amplitude = amplitude; } /** waves amplitude rate */ inline float getAmplitudeRate(void) const { return _amplitudeRate; } inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; } // Override virtual WavesTiles3D* clone() const override; virtual void update(float time) override; protected: WavesTiles3D() {} virtual ~WavesTiles3D() {} /** initializes the action with a number of waves, the waves amplitude, the grid size and the duration */ bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude); unsigned int _waves; float _amplitude; float _amplitudeRate; private: CC_DISALLOW_COPY_AND_ASSIGN(WavesTiles3D); }; /** @brief JumpTiles3D action. A sin function is executed to move the tiles across the Z axis */ class CC_DLL JumpTiles3D : public TiledGrid3DAction { public: /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */ static JumpTiles3D* create(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude); /** amplitude of the sin*/ inline float getAmplitude(void) const { return _amplitude; } inline void setAmplitude(float amplitude) { _amplitude = amplitude; } /** amplitude rate */ inline float getAmplitudeRate(void) const { return _amplitudeRate; } inline void setAmplitudeRate(float amplitudeRate) { _amplitudeRate = amplitudeRate; } // Override virtual JumpTiles3D* clone() const override; virtual void update(float time) override; protected: JumpTiles3D() {} virtual ~JumpTiles3D() {} /** initializes the action with the number of jumps, the sin amplitude, the grid size and the duration */ bool initWithDuration(float duration, const Size& gridSize, unsigned int numberOfJumps, float amplitude); unsigned int _jumps; float _amplitude; float _amplitudeRate; private: CC_DISALLOW_COPY_AND_ASSIGN(JumpTiles3D); }; /** @brief SplitRows action */ class CC_DLL SplitRows : public TiledGrid3DAction { public : /** creates the action with the number of rows to split and the duration */ static SplitRows* create(float duration, unsigned int rows); // Overrides virtual SplitRows* clone() const override; virtual void update(float time) override; virtual void startWithTarget(Node *target) override; protected: SplitRows() {} virtual ~SplitRows() {} /** initializes the action with the number of rows to split and the duration */ bool initWithDuration(float duration, unsigned int rows); unsigned int _rows; Size _winSize; private: CC_DISALLOW_COPY_AND_ASSIGN(SplitRows); }; /** @brief SplitCols action */ class CC_DLL SplitCols : public TiledGrid3DAction { public: /** creates the action with the number of columns to split and the duration */ static SplitCols* create(float duration, unsigned int cols); // Overrides virtual SplitCols* clone() const override; virtual void update(float time) override; virtual void startWithTarget(Node *target) override; protected: SplitCols() {} virtual ~SplitCols() {} /** initializes the action with the number of columns to split and the duration */ bool initWithDuration(float duration, unsigned int cols); unsigned int _cols; Size _winSize; private: CC_DISALLOW_COPY_AND_ASSIGN(SplitCols); }; // end of actions group /// @} NS_CC_END #endif // __ACTION_CCTILEDGRID_ACTION_H__ ================================================ FILE: cocos2d/cocos/2d/CCActionTween.cpp ================================================ /**************************************************************************** Copyright (c) 2009 lhunath (Maarten Billemont) Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionTween.h" NS_CC_BEGIN ActionTween* ActionTween::create(float aDuration, const std::string& key, float from, float to) { ActionTween* ret = new ActionTween(); if (ret && ret->initWithDuration(aDuration, key, from, to)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ActionTween::initWithDuration(float duration, const std::string& key, float from, float to) { if (ActionInterval::initWithDuration(duration)) { _key = key; _to = to; _from = from; return true; } return false; } ActionTween *ActionTween::clone() const { // no copy constructor auto a = new ActionTween(); a->initWithDuration(_duration, _key.c_str(), _from, _to); a->autorelease(); return a; } void ActionTween::startWithTarget(Node *target) { CCASSERT(dynamic_cast(target), "target must implement ActionTweenDelegate"); ActionInterval::startWithTarget(target); _delta = _to - _from; } void ActionTween::update(float dt) { dynamic_cast(_target)->updateTweenAction(_to - _delta * (1 - dt), _key.c_str()); } ActionTween* ActionTween::reverse() const { return ActionTween::create(_duration, _key.c_str(), _to, _from); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCActionTween.h ================================================ /**************************************************************************** Copyright (c) 2009 lhunath (Maarten Billemont) Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCACTIONTWEEN_H__ #define __CCACTIONTWEEN_H__ #include "CCActionInterval.h" NS_CC_BEGIN /** * @addtogroup actions * @{ */ class CC_DLL ActionTweenDelegate { public: /** * @js NA * @lua NA */ virtual ~ActionTweenDelegate() {} virtual void updateTweenAction(float value, const std::string& key) = 0; }; /** ActionTween ActionTween is an action that lets you update any property of an object. For example, if you want to modify the "width" property of a target from 200 to 300 in 2 seconds, then: @code auto modifyWidth = ActionTween::create(2, "width", 200, 300); target->runAction(modifyWidth); @endcode Another example: ScaleTo action could be rewritten using PropertyAction: @code // scaleA and scaleB are equivalents auto scaleA = ScaleTo::create(2, 3); // (duration, to) auto scaleB = ActionTween::create(2, "scale", 1, 3); // (duration, key, from, to) @endcode @since v0.99.2 */ class CC_DLL ActionTween : public ActionInterval { public: /** creates an initializes the action with the property name (key), and the from and to parameters. */ static ActionTween* create(float duration, const std::string& key, float from, float to); /** initializes the action with the property name (key), and the from and to parameters. */ bool initWithDuration(float duration, const std::string& key, float from, float to); // Overrides void startWithTarget(Node *target) override; void update(float dt) override; ActionTween* reverse() const override; ActionTween *clone() const override; protected: std::string _key; float _from, _to; float _delta; }; // end of actions group /// @} NS_CC_END #endif /* __CCACTIONTWEEN_H__ */ ================================================ FILE: cocos2d/cocos/2d/CCAnimation.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAnimation.h" #include "CCTextureCache.h" #include "CCTexture2D.h" #include "ccMacros.h" #include "CCSpriteFrame.h" #include "CCDirector.h" NS_CC_BEGIN AnimationFrame* AnimationFrame::create(SpriteFrame* spriteFrame, float delayUnits, const ValueMap& userInfo) { auto ret = new AnimationFrame(); if (ret && ret->initWithSpriteFrame(spriteFrame, delayUnits, userInfo)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } AnimationFrame::AnimationFrame() : _spriteFrame(nullptr) , _delayUnits(0.0f) { } bool AnimationFrame::initWithSpriteFrame(SpriteFrame* spriteFrame, float delayUnits, const ValueMap& userInfo) { setSpriteFrame(spriteFrame); setDelayUnits(delayUnits); setUserInfo(userInfo); return true; } AnimationFrame::~AnimationFrame() { CCLOGINFO( "deallocing AnimationFrame: %p", this); CC_SAFE_RELEASE(_spriteFrame); } AnimationFrame* AnimationFrame::clone() const { // no copy constructor auto frame = new AnimationFrame(); frame->initWithSpriteFrame(_spriteFrame->clone(), _delayUnits, _userInfo); frame->autorelease(); return frame; } // implementation of Animation Animation* Animation::create(void) { Animation *animation = new Animation(); animation->init(); animation->autorelease(); return animation; } Animation* Animation::createWithSpriteFrames(const Vector& frames, float delay/* = 0.0f*/) { Animation *animation = new Animation(); animation->initWithSpriteFrames(frames, delay); animation->autorelease(); return animation; } Animation* Animation::create(const Vector& arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops /* = 1 */) { Animation *animation = new Animation(); animation->initWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops); animation->autorelease(); return animation; } bool Animation::init() { _loops = 1; _delayPerUnit = 0.0f; return true; } bool Animation::initWithSpriteFrames(const Vector& frames, float delay/* = 0.0f*/) { _loops = 1; _delayPerUnit = delay; for (auto& spriteFrame : frames) { auto animFrame = AnimationFrame::create(spriteFrame, 1, ValueMap()); _frames.pushBack(animFrame); _totalDelayUnits++; } return true; } bool Animation::initWithAnimationFrames(const Vector& arrayOfAnimationFrames, float delayPerUnit, unsigned int loops) { _delayPerUnit = delayPerUnit; _loops = loops; setFrames(arrayOfAnimationFrames); for (auto& animFrame : _frames) { _totalDelayUnits += animFrame->getDelayUnits(); } return true; } Animation::Animation() : _totalDelayUnits(0.0f) , _delayPerUnit(0.0f) , _duration(0.0f) , _restoreOriginalFrame(false) , _loops(0) { } Animation::~Animation(void) { CCLOGINFO("deallocing Animation: %p", this); } void Animation::addSpriteFrame(SpriteFrame* spriteFrame) { AnimationFrame *animFrame = AnimationFrame::create(spriteFrame, 1.0f, ValueMap()); _frames.pushBack(animFrame); // update duration _totalDelayUnits++; } void Animation::addSpriteFrameWithFile(const std::string& filename) { Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); Rect rect = Rect::ZERO; rect.size = texture->getContentSize(); SpriteFrame *frame = SpriteFrame::createWithTexture(texture, rect); addSpriteFrame(frame); } void Animation::addSpriteFrameWithTexture(Texture2D *pobTexture, const Rect& rect) { SpriteFrame *frame = SpriteFrame::createWithTexture(pobTexture, rect); addSpriteFrame(frame); } float Animation::getDuration(void) const { return _totalDelayUnits * _delayPerUnit; } Animation* Animation::clone() const { // no copy constructor auto a = new Animation(); a->initWithAnimationFrames(_frames, _delayPerUnit, _loops); a->setRestoreOriginalFrame(_restoreOriginalFrame); a->autorelease(); return a; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCAnimation.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_ANIMATION_H__ #define __CC_ANIMATION_H__ #include "CCPlatformConfig.h" #include "CCObject.h" #include "CCArray.h" #include "CCValue.h" #include "CCGeometry.h" #include "CCSpriteFrame.h" #include "CCVector.h" #include NS_CC_BEGIN class Texture2D; class SpriteFrame; /** * @addtogroup sprite_nodes * @{ */ /** AnimationFrame A frame of the animation. It contains information like: - sprite frame name - # of delay units. - offset @since v2.0 */ class CC_DLL AnimationFrame : public Object, public Clonable { public: /** * Creates the animation frame with a spriteframe, number of delay units and a notification user info * @since 3.0 */ static AnimationFrame* create(SpriteFrame* spriteFrame, float delayUnits, const ValueMap& userInfo); SpriteFrame* getSpriteFrame() const { return _spriteFrame; }; void setSpriteFrame(SpriteFrame* frame) { CC_SAFE_RETAIN(frame); CC_SAFE_RELEASE(_spriteFrame); _spriteFrame = frame; } /** Gets the units of time the frame takes */ float getDelayUnits() const { return _delayUnits; }; /** Sets the units of time the frame takes */ void setDelayUnits(float delayUnits) { _delayUnits = delayUnits; }; /** @brief Gets user infomation A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast. */ const ValueMap& getUserInfo() const { return _userInfo; }; ValueMap& getUserInfo() { return _userInfo; }; /** Sets user infomation */ void setUserInfo(const ValueMap& userInfo) { _userInfo = userInfo; } // Overrides virtual AnimationFrame *clone() const override; protected: /** * @js ctor */ AnimationFrame(); /** * @js NA * @lua NA */ virtual ~AnimationFrame(); /** initializes the animation frame with a spriteframe, number of delay units and a notification user info */ bool initWithSpriteFrame(SpriteFrame* spriteFrame, float delayUnits, const ValueMap& userInfo); /** SpriteFrameName to be used */ SpriteFrame* _spriteFrame; /** how many units of time the frame takes */ float _delayUnits; /** A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast. */ ValueMap _userInfo; private: CC_DISALLOW_COPY_AND_ASSIGN(AnimationFrame); }; /** A Animation object is used to perform animations on the Sprite objects. The Animation object contains AnimationFrame objects, and a possible delay between the frames. You can animate a Animation object by using the Animate action. Example: @code sprite->runAction(Animate::create(animation)); @endcode */ class CC_DLL Animation : public Object, public Clonable { public: /** Creates an animation @since v0.99.5 */ static Animation* create(void); /* Creates an animation with an array of SpriteFrame and a delay between frames in seconds. The frames will be added with one "delay unit". @since v0.99.5 */ static Animation* createWithSpriteFrames(const Vector& arrayOfSpriteFrameNames, float delay = 0.0f); /* Creates an animation with an array of AnimationFrame, the delay per units in seconds and and how many times it should be executed. @since v2.0 * @js NA */ static Animation* create(const Vector& arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops = 1); /** Adds a SpriteFrame to a Animation. The frame will be added with one "delay unit". */ void addSpriteFrame(SpriteFrame *frame); /** Adds a frame with an image filename. Internally it will create a SpriteFrame and it will add it. The frame will be added with one "delay unit". Added to facilitate the migration from v0.8 to v0.9. */ void addSpriteFrameWithFile(const std::string& filename); /** @deprecated. Use addSpriteFrameWithFile() instead */ CC_DEPRECATED_ATTRIBUTE void addSpriteFrameWithFileName(const std::string& filename){ addSpriteFrameWithFile(filename);} /** Adds a frame with a texture and a rect. Internally it will create a SpriteFrame and it will add it. The frame will be added with one "delay unit". Added to facilitate the migration from v0.8 to v0.9. */ void addSpriteFrameWithTexture(Texture2D* pobTexture, const Rect& rect); /** Gets the total Delay units of the Animation. */ float getTotalDelayUnits() const { return _totalDelayUnits; }; /** Sets the delay in seconds of the "delay unit" */ void setDelayPerUnit(float delayPerUnit) { _delayPerUnit = delayPerUnit; }; /** Gets the delay in seconds of the "delay unit" */ float getDelayPerUnit() const { return _delayPerUnit; }; /** Gets the duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */ float getDuration() const; /** Gets the array of AnimationFrames */ const Vector& getFrames() const { return _frames; }; /** Sets the array of AnimationFrames */ void setFrames(const Vector& frames) { _frames = frames; } /** Checks whether to restore the original frame when animation finishes. */ bool getRestoreOriginalFrame() const { return _restoreOriginalFrame; }; /** Sets whether to restore the original frame when animation finishes */ void setRestoreOriginalFrame(bool restoreOriginalFrame) { _restoreOriginalFrame = restoreOriginalFrame; }; /** Gets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */ unsigned int getLoops() const { return _loops; }; /** Sets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */ void setLoops(unsigned int loops) { _loops = loops; }; // overrides virtual Animation *clone() const override; protected: Animation(); virtual ~Animation(void); /** Initializes a Animation */ bool init(); /** Initializes a Animation with frames and a delay between frames @since v0.99.5 */ bool initWithSpriteFrames(const Vector& arrayOfSpriteFrameNames, float delay = 0.0f); /** Initializes a Animation with AnimationFrame @since v2.0 */ bool initWithAnimationFrames(const Vector& arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); /** total Delay units of the Animation. */ float _totalDelayUnits; /** Delay in seconds of the "delay unit" */ float _delayPerUnit; /** duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */ float _duration; /** array of AnimationFrames */ Vector _frames; /** whether or not it shall restore the original frame when the animation finishes */ bool _restoreOriginalFrame; /** how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */ unsigned int _loops; private: CC_DISALLOW_COPY_AND_ASSIGN(Animation); }; // end of sprite_nodes group /// @} NS_CC_END #endif // __CC_ANIMATION_H__ ================================================ FILE: cocos2d/cocos/2d/CCAnimationCache.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAnimationCache.h" #include "ccMacros.h" #include "CCAnimation.h" #include "CCSpriteFrame.h" #include "CCSpriteFrameCache.h" #include "CCString.h" #include "platform/CCFileUtils.h" using namespace std; NS_CC_BEGIN AnimationCache* AnimationCache::s_sharedAnimationCache = nullptr; AnimationCache* AnimationCache::getInstance() { if (! s_sharedAnimationCache) { s_sharedAnimationCache = new AnimationCache(); s_sharedAnimationCache->init(); } return s_sharedAnimationCache; } void AnimationCache::destroyInstance() { CC_SAFE_RELEASE_NULL(s_sharedAnimationCache); } bool AnimationCache::init() { return true; } AnimationCache::AnimationCache() { } AnimationCache::~AnimationCache() { CCLOGINFO("deallocing AnimationCache: %p", this); } void AnimationCache::addAnimation(Animation *animation, const std::string& name) { _animations.insert(name, animation); } void AnimationCache::removeAnimation(const std::string& name) { if (name.size()==0) return; _animations.erase(name); } Animation* AnimationCache::getAnimation(const std::string& name) { return _animations.at(name); } void AnimationCache::parseVersion1(const ValueMap& animations) { SpriteFrameCache *frameCache = SpriteFrameCache::getInstance(); for (auto iter = animations.cbegin(); iter != animations.cend(); ++iter) { const ValueMap& animationDict = iter->second.asValueMap(); const ValueVector& frameNames = animationDict.at("frames").asValueVector(); float delay = animationDict.at("delay").asFloat(); Animation* animation = nullptr; if ( frameNames.empty() ) { CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", iter->first.c_str()); continue; } ssize_t frameNameSize = frameNames.size(); Vector frames(frameNameSize); for (auto& frameName : frameNames) { SpriteFrame* spriteFrame = frameCache->getSpriteFrameByName(frameName.asString()); if ( ! spriteFrame ) { CCLOG("cocos2d: AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the SpriteFrameCache. This frame will not be added to the animation.", iter->first.c_str(), frameName.asString().c_str()); continue; } AnimationFrame* animFrame = AnimationFrame::create(spriteFrame, 1, ValueMap()); frames.pushBack(animFrame); } if ( frames.empty() ) { CCLOG("cocos2d: AnimationCache: None of the frames for animation '%s' were found in the SpriteFrameCache. Animation is not being added to the Animation Cache.", iter->first.c_str()); continue; } else if ( frames.size() != frameNameSize ) { CCLOG("cocos2d: AnimationCache: An animation in your dictionary refers to a frame which is not in the SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", iter->first.c_str()); } animation = Animation::create(frames, delay, 1); AnimationCache::getInstance()->addAnimation(animation, iter->first.c_str()); } } void AnimationCache::parseVersion2(const ValueMap& animations) { SpriteFrameCache *frameCache = SpriteFrameCache::getInstance(); for (auto iter = animations.cbegin(); iter != animations.cend(); ++iter) { std::string name = iter->first; ValueMap& animationDict = const_cast(iter->second.asValueMap()); const Value& loops = animationDict["loops"]; bool restoreOriginalFrame = animationDict["restoreOriginalFrame"].asBool(); ValueVector& frameArray = animationDict["frames"].asValueVector(); if ( frameArray.empty() ) { CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", name.c_str()); continue; } // Array of AnimationFrames Vector array(static_cast(frameArray.size())); for (auto& obj : frameArray) { ValueMap& entry = obj.asValueMap(); std::string spriteFrameName = entry["spriteframe"].asString(); SpriteFrame *spriteFrame = frameCache->getSpriteFrameByName(spriteFrameName); if( ! spriteFrame ) { CCLOG("cocos2d: AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the SpriteFrameCache. This frame will not be added to the animation.", name.c_str(), spriteFrameName.c_str()); continue; } float delayUnits = entry["delayUnits"].asFloat(); Value& userInfo = entry["notification"]; AnimationFrame *animFrame = AnimationFrame::create(spriteFrame, delayUnits, userInfo.asValueMap()); array.pushBack(animFrame); } float delayPerUnit = animationDict["delayPerUnit"].asFloat(); Animation *animation = Animation::create(array, delayPerUnit, loops.getType() != Value::Type::NONE ? loops.asInt() : 1); animation->setRestoreOriginalFrame(restoreOriginalFrame); AnimationCache::getInstance()->addAnimation(animation, name); } } void AnimationCache::addAnimationsWithDictionary(const ValueMap& dictionary,const std::string& plist) { if ( dictionary.find("animations") == dictionary.end() ) { CCLOG("cocos2d: AnimationCache: No animations were found in provided dictionary."); return; } const Value& animations = dictionary.at("animations"); unsigned int version = 1; if( dictionary.find("properties") != dictionary.end() ) { const ValueMap& properties = dictionary.at("properties").asValueMap(); version = properties.at("format").asInt(); const ValueVector& spritesheets = properties.at("spritesheets").asValueVector(); for(const auto &value : spritesheets) { std::string path = FileUtils::getInstance()->fullPathFromRelativeFile(value.asString(),plist); SpriteFrameCache::getInstance()->addSpriteFramesWithFile(path); } } switch (version) { case 1: parseVersion1(animations.asValueMap()); break; case 2: parseVersion2(animations.asValueMap()); break; default: CCASSERT(false, "Invalid animation format"); } } /** Read an NSDictionary from a plist file and parse it automatically for animations */ void AnimationCache::addAnimationsWithFile(const std::string& plist) { CCASSERT( plist.size()>0, "Invalid texture file name"); std::string path = FileUtils::getInstance()->fullPathForFilename(plist); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(path); CCASSERT( !dict.empty(), "CCAnimationCache: File could not be found"); addAnimationsWithDictionary(dict,plist); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCAnimationCache.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_ANIMATION_CACHE_H__ #define __CC_ANIMATION_CACHE_H__ #include "CCObject.h" #include "CCMap.h" #include "CCValue.h" #include NS_CC_BEGIN class Animation; /** * @addtogroup sprite_nodes * @{ */ /** Singleton that manages the Animations. It saves in a cache the animations. You should use this class if you want to save your animations in a cache. Before v0.99.5, the recommend way was to save them on the Sprite. Since v0.99.5, you should use this class instead. @since v0.99.5 */ class CC_DLL AnimationCache : public Object { public: /** * @js ctor */ AnimationCache(); /** * @js NA * @lua NA */ ~AnimationCache(); /** Returns the shared instance of the Animation cache */ static AnimationCache* getInstance(); /** Purges the cache. It releases all the Animation objects and the shared instance. */ static void destroyInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static AnimationCache* sharedAnimationCache() { return AnimationCache::getInstance(); } /** @deprecated Use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedAnimationCache() { return AnimationCache::destroyInstance(); } bool init(void); /** Adds a Animation with a name. */ void addAnimation(Animation *animation, const std::string& name); /** Deletes a Animation from the cache. */ void removeAnimation(const std::string& name); /** @deprecated. Use removeAnimation() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE void removeAnimationByName(const std::string& name){ removeAnimation(name);} /** Returns a Animation that was previously added. If the name is not found it will return nil. You should retain the returned copy if you are going to use it. */ Animation* getAnimation(const std::string& name); /** @deprecated. Use getAnimation() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE Animation* animationByName(const std::string& name){ return getAnimation(name); } /** Adds an animation from an NSDictionary Make sure that the frames were previously loaded in the SpriteFrameCache. @param plist The path of the relative file,it use to find the plist path for load SpriteFrames. @since v1.1 */ void addAnimationsWithDictionary(const ValueMap& dictionary,const std::string& plist); /** Adds an animation from a plist file. Make sure that the frames were previously loaded in the SpriteFrameCache. @since v1.1 * @js addAnimations * @lua addAnimations */ void addAnimationsWithFile(const std::string& plist); private: void parseVersion1(const ValueMap& animations); void parseVersion2(const ValueMap& animations); private: Map _animations; static AnimationCache* s_sharedAnimationCache; }; // end of sprite_nodes group /// @} NS_CC_END #endif // __CC_ANIMATION_CACHE_H__ ================================================ FILE: cocos2d/cocos/2d/CCAtlasNode.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAtlasNode.h" #include "CCTextureAtlas.h" #include "CCTextureCache.h" #include "CCDirector.h" #include "CCGLProgram.h" #include "CCShaderCache.h" #include "ccGLStateCache.h" #include "CCDirector.h" #include "TransformUtils.h" #include "renderer/CCRenderer.h" #include "renderer/CCQuadCommand.h" // external #include "kazmath/GL/matrix.h" NS_CC_BEGIN // implementation AtlasNode // AtlasNode - Creation & Init AtlasNode::AtlasNode() : _itemsPerRow(0) , _itemsPerColumn(0) , _itemWidth(0) , _itemHeight(0) , _textureAtlas(nullptr) , _isOpacityModifyRGB(false) , _quadsToDraw(0) , _uniformColor(0) , _ignoreContentScaleFactor(false) { } AtlasNode::~AtlasNode() { CC_SAFE_RELEASE(_textureAtlas); } AtlasNode * AtlasNode::create(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender) { AtlasNode * ret = new AtlasNode(); if (ret->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool AtlasNode::initWithTileFile(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender) { CCASSERT(tile.size() > 0, "file size should not be empty"); Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(tile); return initWithTexture(texture, tileWidth, tileHeight, itemsToRender); } bool AtlasNode::initWithTexture(Texture2D* texture, int tileWidth, int tileHeight, int itemsToRender) { _itemWidth = tileWidth; _itemHeight = tileHeight; _colorUnmodified = Color3B::WHITE; _isOpacityModifyRGB = true; _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _textureAtlas = new TextureAtlas(); _textureAtlas->initWithTexture(texture, itemsToRender); if (! _textureAtlas) { CCLOG("cocos2d: Could not initialize AtlasNode. Invalid Texture."); return false; } this->updateBlendFunc(); this->updateOpacityModifyRGB(); this->calculateMaxItems(); _quadsToDraw = itemsToRender; // shader stuff setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR)); _uniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color"); return true; } // AtlasNode - Atlas generation void AtlasNode::calculateMaxItems() { Size s = _textureAtlas->getTexture()->getContentSize(); if (_ignoreContentScaleFactor) { s = _textureAtlas->getTexture()->getContentSizeInPixels(); } _itemsPerColumn = (int)(s.height / _itemHeight); _itemsPerRow = (int)(s.width / _itemWidth); } void AtlasNode::updateAtlasValues() { CCASSERT(false, "CCAtlasNode:Abstract updateAtlasValue not overridden"); } // AtlasNode - draw void AtlasNode::draw(void) { // CC_NODE_DRAW_SETUP(); // // GL::blendFunc( _blendFunc.src, _blendFunc.dst ); // // GLfloat colors[4] = {_displayedColor.r / 255.0f, _displayedColor.g / 255.0f, _displayedColor.b / 255.0f, _displayedOpacity / 255.0f}; // getShaderProgram()->setUniformLocationWith4fv(_uniformColor, colors, 1); // // _textureAtlas->drawNumberOfQuads(_quadsToDraw, 0); auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); _quadCommand.init( _globalZOrder, _textureAtlas->getTexture()->getName(), shader, _blendFunc, _textureAtlas->getQuads(), _quadsToDraw, _modelViewTransform); Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } // AtlasNode - RGBA protocol const Color3B& AtlasNode::getColor() const { if(_isOpacityModifyRGB) { return _colorUnmodified; } return Node::getColor(); } void AtlasNode::setColor(const Color3B& color3) { Color3B tmp = color3; _colorUnmodified = color3; if( _isOpacityModifyRGB ) { tmp.r = tmp.r * _displayedOpacity/255; tmp.g = tmp.g * _displayedOpacity/255; tmp.b = tmp.b * _displayedOpacity/255; } Node::setColor(tmp); } void AtlasNode::setOpacity(GLubyte opacity) { Node::setOpacity(opacity); // special opacity for premultiplied textures if( _isOpacityModifyRGB ) this->setColor(_colorUnmodified); } void AtlasNode::setOpacityModifyRGB(bool value) { Color3B oldColor = this->getColor(); _isOpacityModifyRGB = value; this->setColor(oldColor); } bool AtlasNode::isOpacityModifyRGB() const { return _isOpacityModifyRGB; } void AtlasNode::updateOpacityModifyRGB() { _isOpacityModifyRGB = _textureAtlas->getTexture()->hasPremultipliedAlpha(); } void AtlasNode::setIgnoreContentScaleFactor(bool ignoreContentScaleFactor) { _ignoreContentScaleFactor = ignoreContentScaleFactor; } // AtlasNode - CocosNodeTexture protocol const BlendFunc& AtlasNode::getBlendFunc() const { return _blendFunc; } void AtlasNode::setBlendFunc(const BlendFunc &blendFunc) { _blendFunc = blendFunc; } void AtlasNode::updateBlendFunc() { if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha() ) _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } void AtlasNode::setTexture(Texture2D *texture) { _textureAtlas->setTexture(texture); this->updateBlendFunc(); this->updateOpacityModifyRGB(); } Texture2D * AtlasNode::getTexture() const { return _textureAtlas->getTexture(); } void AtlasNode::setTextureAtlas(TextureAtlas* textureAtlas) { CC_SAFE_RETAIN(textureAtlas); CC_SAFE_RELEASE(_textureAtlas); _textureAtlas = textureAtlas; } TextureAtlas * AtlasNode::getTextureAtlas() const { return _textureAtlas; } ssize_t AtlasNode::getQuadsToDraw() const { return _quadsToDraw; } void AtlasNode::setQuadsToDraw(ssize_t quadsToDraw) { _quadsToDraw = quadsToDraw; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCAtlasNode.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCATLAS_NODE_H__ #define __CCATLAS_NODE_H__ #include "CCNode.h" #include "CCProtocols.h" #include "ccTypes.h" #include "renderer/CCQuadCommand.h" NS_CC_BEGIN /** * @addtogroup base_nodes * @{ */ class TextureAtlas; /** @brief AtlasNode is a subclass of Node that implements the RGBAProtocol and TextureProtocol protocol It knows how to render a TextureAtlas object. If you are going to render a TextureAtlas consider subclassing AtlasNode (or a subclass of AtlasNode) All features from Node are valid, plus the following features: - opacity and RGB colors */ class CC_DLL AtlasNode : public Node, public TextureProtocol { public: /** creates a AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/ static AtlasNode * create(const std::string& filename, int tileWidth, int tileHeight, int itemsToRender); /** updates the Atlas (indexed vertex array). * Shall be overridden in subclasses */ virtual void updateAtlasValues(); void setTextureAtlas(TextureAtlas* textureAtlas); TextureAtlas* getTextureAtlas() const; void setQuadsToDraw(ssize_t quadsToDraw); ssize_t getQuadsToDraw() const; // Overrides virtual void draw() override; virtual Texture2D* getTexture() const override; virtual void setTexture(Texture2D *texture) override; virtual bool isOpacityModifyRGB() const override; virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override; virtual const Color3B& getColor(void) const override; virtual void setColor(const Color3B& color) override; virtual void setOpacity(GLubyte opacity) override; /** * @code * When this function bound into js or lua,the parameter will be changed * In js: var setBlendFunc(var src, var dst) * @endcode * @lua NA */ virtual void setBlendFunc(const BlendFunc& blendFunc) override; /** * @js NA * @lua NA */ virtual const BlendFunc& getBlendFunc() const override; protected: AtlasNode(); virtual ~AtlasNode(); /** initializes an AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/ bool initWithTileFile(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender); /** initializes an AtlasNode with a texture the width and height of each item measured in points and the quantity of items to render*/ bool initWithTexture(Texture2D* texture, int tileWidth, int tileHeight, int itemsToRender); void calculateMaxItems(); void updateBlendFunc(); void updateOpacityModifyRGB(); friend class Director; void setIgnoreContentScaleFactor(bool bIgnoreContentScaleFactor); //! chars per row int _itemsPerRow; //! chars per column int _itemsPerColumn; //! width of each char int _itemWidth; //! height of each char int _itemHeight; Color3B _colorUnmodified; TextureAtlas* _textureAtlas; // protocol variables bool _isOpacityModifyRGB; BlendFunc _blendFunc; // quads to draw ssize_t _quadsToDraw; // color uniform GLint _uniformColor; // This varible is only used for LabelAtlas FPS display. So plz don't modify its value. bool _ignoreContentScaleFactor; // quad command QuadCommand _quadCommand; private: CC_DISALLOW_COPY_AND_ASSIGN(AtlasNode); }; // end of base_node group /// @} NS_CC_END #endif // __CCATLAS_NODE_H__ ================================================ FILE: cocos2d/cocos/2d/CCClippingNode.cpp ================================================ /* * Copyright (c) 2012 Pierre-David Bélanger * Copyright (c) 2012 cocos2d-x.org * Copyright (c) 2013-2014 Chukong Technologies Inc. * * cocos2d-x: 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 "CCClippingNode.h" #include "kazmath/GL/matrix.h" #include "CCGLProgram.h" #include "CCShaderCache.h" #include "CCDirector.h" #include "CCDrawingPrimitives.h" #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCCustomCommand.h" NS_CC_BEGIN static GLint g_sStencilBits = -1; // store the current stencil layer (position in the stencil buffer), // this will allow nesting up to n ClippingNode, // where n is the number of bits of the stencil buffer. static GLint s_layer = -1; static void setProgram(Node *n, GLProgram *p) { n->setShaderProgram(p); auto& children = n->getChildren(); for(const auto &child : children) { setProgram(child, p); } } ClippingNode::ClippingNode() : _stencil(nullptr) , _alphaThreshold(0.0f) , _inverted(false) , _currentStencilEnabled(GL_FALSE) , _currentStencilWriteMask(~0) , _currentStencilFunc(GL_ALWAYS) , _currentStencilRef(0) , _currentStencilValueMask(~0) , _currentStencilFail(GL_KEEP) , _currentStencilPassDepthFail(GL_KEEP) , _currentStencilPassDepthPass(GL_KEEP) , _currentDepthWriteMask(GL_TRUE) , _currentAlphaTestEnabled(GL_FALSE) , _currentAlphaTestFunc(GL_ALWAYS) , _currentAlphaTestRef(1) { } ClippingNode::~ClippingNode() { CC_SAFE_RELEASE(_stencil); } ClippingNode* ClippingNode::create() { ClippingNode *ret = new ClippingNode(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ClippingNode* ClippingNode::create(Node *pStencil) { ClippingNode *ret = new ClippingNode(); if (ret && ret->init(pStencil)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ClippingNode::init() { return init(nullptr); } bool ClippingNode::init(Node *stencil) { CC_SAFE_RELEASE(_stencil); _stencil = stencil; CC_SAFE_RETAIN(_stencil); _alphaThreshold = 1; _inverted = false; // get (only once) the number of bits of the stencil buffer static bool once = true; if (once) { glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits); if (g_sStencilBits <= 0) { CCLOG("Stencil buffer is not enabled."); } once = false; } return true; } void ClippingNode::onEnter() { Node::onEnter(); if (_stencil != nullptr) { _stencil->onEnter(); } else { CCLOG("ClippingNode warning: _stencil is nil."); } } void ClippingNode::onEnterTransitionDidFinish() { Node::onEnterTransitionDidFinish(); if (_stencil != nullptr) { _stencil->onEnterTransitionDidFinish(); } } void ClippingNode::onExitTransitionDidStart() { if (_stencil != nullptr) { _stencil->onExitTransitionDidStart(); } Node::onExitTransitionDidStart(); } void ClippingNode::onExit() { if (_stencil != nullptr) { _stencil->onExit(); } Node::onExit(); } void ClippingNode::drawFullScreenQuadClearStencil() { kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPushMatrix(); kmGLLoadIdentity(); kmGLMatrixMode(KM_GL_PROJECTION); kmGLPushMatrix(); kmGLLoadIdentity(); DrawPrimitives::drawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1)); kmGLMatrixMode(KM_GL_PROJECTION); kmGLPopMatrix(); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPopMatrix(); } void ClippingNode::visit() { if(!_visible) return; kmGLPushMatrix(); transform(); //Add group command Renderer* renderer = Director::getInstance()->getRenderer(); _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); _beforeVisitCmd.init(_globalZOrder); _beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this); renderer->addCommand(&_beforeVisitCmd); if (_alphaThreshold < 1) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) #else // since glAlphaTest do not exists in OES, use a shader that writes // pixel only if greater than an alpha threshold GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // set our alphaThreshold program->use(); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); // we need to recursively apply this shader to all the nodes in the stencil node // XXX: we should have a way to apply shader to all nodes without having to do this setProgram(_stencil, program); #endif } _stencil->visit(); _afterDrawStencilCmd.init(_globalZOrder); _afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this); renderer->addCommand(&_afterDrawStencilCmd); int i = 0; if(!_children.empty()) { sortAllChildren(); // draw children zOrder < 0 for( ; i < _children.size(); i++ ) { auto node = _children.at(i); if ( node && node->getLocalZOrder() < 0 ) node->visit(); else break; } // self draw this->draw(); for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) (*it)->visit(); } else { this->draw(); } _afterVisitCmd.init(_globalZOrder); _afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this); renderer->addCommand(&_afterVisitCmd); renderer->popGroup(); kmGLPopMatrix(); } Node* ClippingNode::getStencil() const { return _stencil; } void ClippingNode::setStencil(Node *stencil) { CC_SAFE_RELEASE(_stencil); _stencil = stencil; CC_SAFE_RETAIN(_stencil); } GLfloat ClippingNode::getAlphaThreshold() const { return _alphaThreshold; } void ClippingNode::setAlphaThreshold(GLfloat alphaThreshold) { _alphaThreshold = alphaThreshold; } bool ClippingNode::isInverted() const { return _inverted; } void ClippingNode::setInverted(bool inverted) { _inverted = inverted; } void ClippingNode::onBeforeVisit() { /////////////////////////////////// // INIT // increment the current layer s_layer++; // mask of the current layer (ie: for layer 3: 00000100) GLint mask_layer = 0x1 << s_layer; // mask of all layers less than the current (ie: for layer 3: 00000011) GLint mask_layer_l = mask_layer - 1; // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) _mask_layer_le = mask_layer | mask_layer_l; // manually save the stencil state _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); // enable stencil use glEnable(GL_STENCIL_TEST); // check for OpenGL error while enabling stencil test CHECK_GL_ERROR_DEBUG(); // all bits on the stencil buffer are readonly, except the current layer bit, // this means that operation like glClear or glStencilOp will be masked with this value glStencilMask(mask_layer); // manually save the depth test state glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); // disable depth test while drawing the stencil //glDisable(GL_DEPTH_TEST); // disable update to the depth buffer while drawing the stencil, // as the stencil is not meant to be rendered in the real scene, // it should never prevent something else to be drawn, // only disabling depth buffer update should do glDepthMask(GL_FALSE); /////////////////////////////////// // CLEAR STENCIL BUFFER // manually clear the stencil buffer by drawing a fullscreen rectangle on it // setup the stencil test func like this: // for each pixel in the fullscreen rectangle // never draw it into the frame buffer // if not in inverted mode: set the current layer value to 0 in the stencil buffer // if in inverted mode: set the current layer value to 1 in the stencil buffer glStencilFunc(GL_NEVER, mask_layer, mask_layer); glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); // draw a fullscreen solid rectangle to clear the stencil buffer //ccDrawSolidRect(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); drawFullScreenQuadClearStencil(); /////////////////////////////////// // DRAW CLIPPING STENCIL // setup the stencil test func like this: // for each pixel in the stencil node // never draw it into the frame buffer // if not in inverted mode: set the current layer value to 1 in the stencil buffer // if in inverted mode: set the current layer value to 0 in the stencil buffer glStencilFunc(GL_NEVER, mask_layer, mask_layer); glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP); // enable alpha test only if the alpha threshold < 1, // indeed if alpha threshold == 1, every pixel will be drawn anyways if (_alphaThreshold < 1) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) // manually save the alpha test state _currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&_currentAlphaTestFunc); glGetFloatv(GL_ALPHA_TEST_REF, &_currentAlphaTestRef); // enable alpha testing glEnable(GL_ALPHA_TEST); // check for OpenGL error while enabling alpha test CHECK_GL_ERROR_DEBUG(); // pixel will be drawn only if greater than an alpha threshold glAlphaFunc(GL_GREATER, _alphaThreshold); #else #endif } //Draw _stencil } void ClippingNode::onAfterDrawStencil() { // restore alpha test state if (_alphaThreshold < 1) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) // manually restore the alpha test state glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef); if (!_currentAlphaTestEnabled) { glDisable(GL_ALPHA_TEST); } #else // XXX: we need to find a way to restore the shaders of the stencil node and its childs #endif } // restore the depth test state glDepthMask(_currentDepthWriteMask); //if (currentDepthTestEnabled) { // glEnable(GL_DEPTH_TEST); //} /////////////////////////////////// // DRAW CONTENT // setup the stencil test func like this: // for each pixel of this node and its childs // if all layers less than or equals to the current are set to 1 in the stencil buffer // draw the pixel and keep the current layer in the stencil buffer // else // do not draw the pixel but keep the current layer in the stencil buffer glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // draw (according to the stencil test func) this node and its childs } void ClippingNode::onAfterVisit() { /////////////////////////////////// // CLEANUP // manually restore the stencil state glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); glStencilMask(_currentStencilWriteMask); if (!_currentStencilEnabled) { glDisable(GL_STENCIL_TEST); } // we are done using this layer, decrement s_layer--; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCClippingNode.h ================================================ /* * Copyright (c) 2012 Pierre-David Bélanger * Copyright (c) 2012 cocos2d-x.org * Copyright (c) 2013-2014 Chukong Technologies Inc. * * http://www.cocos2d-x.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #ifndef __MISCNODE_CCCLIPPING_NODE_H__ #define __MISCNODE_CCCLIPPING_NODE_H__ #include "CCNode.h" #include "CCGL.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCCustomCommand.h" NS_CC_BEGIN /** ClippingNode is a subclass of Node. It draws its content (childs) clipped using a stencil. The stencil is an other Node that will not be drawn. The clipping is done using the alpha part of the stencil (adjusted with an alphaThreshold). */ class CC_DLL ClippingNode : public Node { public: /** Creates and initializes a clipping node without a stencil. */ static ClippingNode* create(); /** Creates and initializes a clipping node with an other node as its stencil. The stencil node will be retained. */ static ClippingNode* create(Node *stencil); /** The Node to use as a stencil to do the clipping. The stencil node will be retained. This default to nil. */ Node* getStencil() const; void setStencil(Node *stencil); /** The alpha threshold. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. Should be a float between 0 and 1. This default to 1 (so alpha test is disabled). */ GLfloat getAlphaThreshold() const; void setAlphaThreshold(GLfloat alphaThreshold); /** Inverted. If this is set to true, the stencil is inverted, so the content is drawn where the stencil is NOT drawn. This default to false. */ bool isInverted() const; void setInverted(bool inverted); // Overrides /** * @js NA * @lua NA */ virtual void onEnter() override; /** * @js NA * @lua NA */ virtual void onEnterTransitionDidFinish() override; /** * @js NA * @lua NA */ virtual void onExitTransitionDidStart() override; /** * @js NA * @lua NA */ virtual void onExit() override; virtual void visit() override; protected: ClippingNode(); /** * @js NA * @lua NA */ virtual ~ClippingNode(); /** Initializes a clipping node without a stencil. */ virtual bool init(); /** Initializes a clipping node with an other node as its stencil. The stencil node will be retained, and its parent will be set to this clipping node. */ virtual bool init(Node *stencil); /**draw fullscreen quad to clear stencil bits */ void drawFullScreenQuadClearStencil(); Node* _stencil; GLfloat _alphaThreshold; bool _inverted; protected: //renderData and callback void onBeforeVisit(); void onAfterDrawStencil(); void onAfterVisit(); GLboolean _currentStencilEnabled; GLuint _currentStencilWriteMask; GLenum _currentStencilFunc; GLint _currentStencilRef; GLuint _currentStencilValueMask; GLenum _currentStencilFail; GLenum _currentStencilPassDepthFail; GLenum _currentStencilPassDepthPass; GLboolean _currentDepthWriteMask; GLboolean _currentAlphaTestEnabled; GLenum _currentAlphaTestFunc; GLclampf _currentAlphaTestRef; GLint _mask_layer_le; GroupCommand _groupCommand; CustomCommand _beforeVisitCmd; CustomCommand _afterDrawStencilCmd; CustomCommand _afterVisitCmd; private: CC_DISALLOW_COPY_AND_ASSIGN(ClippingNode); }; NS_CC_END #endif // __MISCNODE_CCCLIPPING_NODE_H__ ================================================ FILE: cocos2d/cocos/2d/CCComponent.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCComponent.h" NS_CC_BEGIN Component::Component(void) : _owner(nullptr) , _enabled(true) { } Component::~Component(void) { } bool Component::init() { return true; } void Component::onEnter() { } void Component::onExit() { } void Component::update(float delta) { } bool Component::serialize(void *ar) { return true; } Component* Component::create(void) { Component * ret = new Component(); if (ret != nullptr && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } const std::string& Component::getName() const { return _name; } void Component::setName(const std::string& name) { _name = name; } Node* Component::getOwner() const { return _owner; } void Component::setOwner(Node *owner) { _owner = owner; } bool Component::isEnabled() const { return _enabled; } void Component::setEnabled(bool b) { _enabled = b; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCComponent.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_FRAMEWORK_COMPONENT_H__ #define __CC_FRAMEWORK_COMPONENT_H__ #include "CCObject.h" #include NS_CC_BEGIN class CC_DLL Component : public Object { protected: /** * @js ctor */ Component(void); public: /** * @js NA * @lua NA */ virtual ~Component(void); virtual bool init(); /** * @js NA * @lua NA */ virtual void onEnter(); /** * @js NA * @lua NA */ virtual void onExit(); virtual void update(float delta); virtual bool serialize(void* r); virtual bool isEnabled() const; virtual void setEnabled(bool b); static Component* create(void); const std::string& getName() const; void setName(const std::string& name); void setOwner(Node *pOwner); Node* getOwner() const; protected: Node *_owner; std::string _name; bool _enabled; }; NS_CC_END #endif // __FUNDATION__CCCOMPONENT_H__ ================================================ FILE: cocos2d/cocos/2d/CCComponentContainer.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCComponentContainer.h" #include "CCComponent.h" #include "CCDirector.h" NS_CC_BEGIN ComponentContainer::ComponentContainer(Node *node) : _components(nullptr) , _owner(node) { } ComponentContainer::~ComponentContainer(void) { CC_SAFE_DELETE(_components); } Component* ComponentContainer::get(const std::string& name) const { Component* ret = nullptr; do { CC_BREAK_IF(nullptr == _components); ret = _components->at(name); } while (0); return ret; } bool ComponentContainer::add(Component *com) { bool ret = false; CCASSERT(com != nullptr, "Argument must be non-nil"); CCASSERT(com->getOwner() == nullptr, "Component already added. It can't be added again"); do { if (_components == nullptr) { _components = new Map(); _owner->scheduleUpdate(); } Component *component = _components->at(com->getName()); CCASSERT(component == nullptr, "Component already added. It can't be added again"); CC_BREAK_IF(component); com->setOwner(_owner); _components->insert(com->getName(), com); com->onEnter(); ret = true; } while(0); return ret; } bool ComponentContainer::remove(const std::string& name) { bool ret = false; do { CC_BREAK_IF(!_components); auto iter = _components->find(name); CC_BREAK_IF(iter == _components->end()); auto com = iter->second; com->onExit(); com->setOwner(nullptr); _components->erase(iter); ret = true; } while(0); return ret; } void ComponentContainer::removeAll() { if (_components != nullptr) { for (auto iter = _components->begin(); iter != _components->end(); ++iter) { iter->second->onExit(); iter->second->setOwner(nullptr); } _components->clear(); CC_SAFE_DELETE(_components); _owner->unscheduleUpdate(); } } void ComponentContainer::alloc(void) { _components = new Map(); } void ComponentContainer::visit(float delta) { if (_components != nullptr) { for (auto iter = _components->begin(); iter != _components->end(); ++iter) { iter->second->update(delta); } } } bool ComponentContainer::isEmpty() const { return (_components == nullptr || _components->empty()); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCComponentContainer.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_FRAMEWORK_COMCONTAINER_H__ #define __CC_FRAMEWORK_COMCONTAINER_H__ #include "CCMap.h" #include NS_CC_BEGIN class Component; class Node; class CC_DLL ComponentContainer { protected: /** * @js ctor */ ComponentContainer(Node *pNode); public: /** * @js NA * @lua NA */ virtual ~ComponentContainer(void); virtual Component* get(const std::string& name) const; virtual bool add(Component *com); virtual bool remove(const std::string& name); virtual void removeAll(); virtual void visit(float delta); public: bool isEmpty() const; private: void alloc(void); private: Map* _components; Node *_owner; friend class Node; }; NS_CC_END #endif // __FUNDATION__CCCOMPONENT_H__ ================================================ FILE: cocos2d/cocos/2d/CCConfiguration.cpp ================================================ /**************************************************************************** Copyright (c) 2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCConfiguration.h" #include #include "ccMacros.h" #include "ccConfig.h" #include "CCDictionary.h" #include "CCInteger.h" #include "CCBool.h" #include "platform/CCFileUtils.h" using namespace std; NS_CC_BEGIN extern const char* cocos2dVersion(); Configuration* Configuration::s_sharedConfiguration = nullptr; Configuration::Configuration() : _maxTextureSize(0) , _maxModelviewStackDepth(0) , _supportsPVRTC(false) , _supportsETC1(false) , _supportsS3TC(false) , _supportsATITC(false) , _supportsNPOT(false) , _supportsBGRA8888(false) , _supportsDiscardFramebuffer(false) , _supportsShareableVAO(false) , _maxSamplesAllowed(0) , _maxTextureUnits(0) , _glExtensions(nullptr) { } bool Configuration::init() { _valueDict["cocos2d.x.version"] = Value(cocos2dVersion()); #if CC_ENABLE_PROFILERS _valueDict["cocos2d.x.compiled_with_profiler"] = Value(true); #else _valueDict["cocos2d.x.compiled_with_profiler"] = Value(false); #endif #if CC_ENABLE_GL_STATE_CACHE == 0 _valueDict["cocos2d.x.compiled_with_gl_state_cache"] = Value(false); #else _valueDict["cocos2d.x.compiled_with_gl_state_cache"] = Value(true); #endif #if COCOS2D_DEBUG _valueDict["cocos2d.x.build_type"] = Value("DEBUG"); #else _valueDict["cocos2d.x.build_type"] = Value("RELEASE"); #endif return true; } Configuration::~Configuration() { } std::string Configuration::getInfo() const { // And Dump some warnings as well #if CC_ENABLE_PROFILERS CCLOG("cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.h)\n"); #endif #if CC_ENABLE_GL_STATE_CACHE == 0 CCLOG("cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it (from ccConfig.h)\n"); #endif // Dump Value forDump = Value(_valueDict); return forDump.getDescription(); } void Configuration::gatherGPUInfo() { _valueDict["gl.vendor"] = Value((const char*)glGetString(GL_VENDOR)); _valueDict["gl.renderer"] = Value((const char*)glGetString(GL_RENDERER)); _valueDict["gl.version"] = Value((const char*)glGetString(GL_VERSION)); _glExtensions = (char *)glGetString(GL_EXTENSIONS); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_maxTextureSize); _valueDict["gl.max_texture_size"] = Value((int)_maxTextureSize); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_maxTextureUnits); _valueDict["gl.max_texture_units"] = Value((int)_maxTextureUnits); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) glGetIntegerv(GL_MAX_SAMPLES_APPLE, &_maxSamplesAllowed); _valueDict["gl.max_samples_allowed"] = Value((int)_maxSamplesAllowed); #endif _supportsETC1 = checkForGLExtension("GL_OES_compressed_ETC1_RGB8_texture"); _valueDict["gl.supports_ETC1"] = Value(_supportsETC1); _supportsS3TC = checkForGLExtension("GL_EXT_texture_compression_s3tc"); _valueDict["gl.supports_S3TC"] = Value(_supportsS3TC); _supportsATITC = checkForGLExtension("GL_AMD_compressed_ATC_texture"); _valueDict["gl.supports_ATITC"] = Value(_supportsATITC); _supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc"); _valueDict["gl.supports_PVRTC"] = Value(_supportsPVRTC); _supportsNPOT = true; _valueDict["gl.supports_NPOT"] = Value(_supportsNPOT); _supportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888"); _valueDict["gl.supports_BGRA8888"] = Value(_supportsBGRA8888); _supportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer"); _valueDict["gl.supports_discard_framebuffer"] = Value(_supportsDiscardFramebuffer); _supportsShareableVAO = checkForGLExtension("vertex_array_object"); _valueDict["gl.supports_vertex_array_object"] = Value(_supportsShareableVAO); CHECK_GL_ERROR_DEBUG(); } Configuration* Configuration::getInstance() { if (! s_sharedConfiguration) { s_sharedConfiguration = new Configuration(); s_sharedConfiguration->init(); } return s_sharedConfiguration; } void Configuration::destroyInstance() { CC_SAFE_RELEASE_NULL(s_sharedConfiguration); } // XXX: deprecated Configuration* Configuration::sharedConfiguration() { return Configuration::getInstance(); } // XXX: deprecated void Configuration::purgeConfiguration() { Configuration::destroyInstance(); } bool Configuration::checkForGLExtension(const string &searchName) const { bool ret = false; const char *kSearchName = searchName.c_str(); if (_glExtensions && strstr(_glExtensions, kSearchName)) { ret = true; } return ret; } // // getters for specific variables. // Mantained for backward compatiblity reasons only. // int Configuration::getMaxTextureSize() const { return _maxTextureSize; } int Configuration::getMaxModelviewStackDepth() const { return _maxModelviewStackDepth; } int Configuration::getMaxTextureUnits() const { return _maxTextureUnits; } bool Configuration::supportsNPOT() const { return _supportsNPOT; } bool Configuration::supportsPVRTC() const { return _supportsPVRTC; } bool Configuration::supportsETC() const { //GL_ETC1_RGB8_OES is not defined in old opengl version #ifdef GL_ETC1_RGB8_OES return _supportsETC1; #else return false; #endif } bool Configuration::supportsS3TC() const { return _supportsS3TC; } bool Configuration::supportsATITC() const { return _supportsATITC; } bool Configuration::supportsBGRA8888() const { return _supportsBGRA8888; } bool Configuration::supportsDiscardFramebuffer() const { return _supportsDiscardFramebuffer; } bool Configuration::supportsShareableVAO() const { #if CC_TEXTURE_ATLAS_USE_VAO return _supportsShareableVAO; #else return false; #endif } // // generic getters for properties // const Value& Configuration::getValue(const std::string& key, const Value& defaultValue) const { auto iter = _valueDict.find(key); if (iter != _valueDict.end()) return _valueDict.at(key); return defaultValue; } void Configuration::setValue(const std::string& key, const Value& value) { _valueDict[key] = value; } // // load file // void Configuration::loadConfigFile(const std::string& filename) { ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(filename); CCASSERT(!dict.empty(), "cannot create dictionary"); // search for metadata bool validMetadata = false; auto metadataIter = dict.find("metadata"); if (metadataIter != dict.end() && metadataIter->second.getType() == Value::Type::MAP) { const auto& metadata = metadataIter->second.asValueMap(); auto formatIter = metadata.find("format"); if (formatIter != metadata.end()) { int format = formatIter->second.asInt(); // Support format: 1 if (format == 1) { validMetadata = true; } } } if (! validMetadata) { CCLOG("Invalid config format for file: %s", filename.c_str()); return; } auto dataIter = dict.find("data"); if (dataIter == dict.end() || dataIter->second.getType() != Value::Type::MAP) { CCLOG("Expected 'data' dict, but not found. Config file: %s", filename.c_str()); return; } // Add all keys in the existing dictionary const auto& dataMap = dataIter->second.asValueMap(); for (auto dataMapIter = dataMap.begin(); dataMapIter != dataMap.end(); ++dataMapIter) { if (_valueDict.find(dataMapIter->first) == _valueDict.end()) _valueDict[dataMapIter->first] = dataMapIter->second; else CCLOG("Key already present. Ignoring '%s'",dataMapIter->first.c_str()); } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCConfiguration.h ================================================ /**************************************************************************** Copyright (c) 2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCCONFIGURATION_H__ #define __CCCONFIGURATION_H__ #include "CCObject.h" #include "CCGL.h" #include "CCString.h" #include "CCValue.h" #include NS_CC_BEGIN /** * @addtogroup global * @{ */ /** @brief Configuration contains some openGL variables @since v0.99.0 */ class CC_DLL Configuration : public Object { public: /** returns a shared instance of Configuration */ static Configuration *getInstance(); /** purge the shared instance of Configuration */ static void destroyInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static Configuration *sharedConfiguration(); /** @deprecated Use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration(); public: /** * @js NA * @lua NA */ virtual ~Configuration(); /** OpenGL Max texture size. */ int getMaxTextureSize() const; /** OpenGL Max Modelview Stack Depth. */ int getMaxModelviewStackDepth() const; /** returns the maximum texture units @since v2.0.0 */ int getMaxTextureUnits() const; /** Whether or not the GPU supports NPOT (Non Power Of Two) textures. OpenGL ES 2.0 already supports NPOT (iOS). @since v0.99.2 */ bool supportsNPOT() const; /** Whether or not PVR Texture Compressed is supported */ bool supportsPVRTC() const; /** Whether or not ETC Texture Compressed is supported */ bool supportsETC() const; /** Whether or not S3TC Texture Compressed is supported */ bool supportsS3TC() const; /** Whether or not ATITC Texture Compressed is supported */ bool supportsATITC() const; /** Whether or not BGRA8888 textures are supported. @since v0.99.2 */ bool supportsBGRA8888() const; /** Whether or not glDiscardFramebufferEXT is supported @since v0.99.2 */ bool supportsDiscardFramebuffer() const; /** Whether or not shareable VAOs are supported. @since v2.0.0 */ bool supportsShareableVAO() const; /** returns whether or not an OpenGL is supported */ bool checkForGLExtension(const std::string &searchName) const; bool init(); /** returns the value of a given key as a double */ const Value& getValue(const std::string& key, const Value& defaultValue = Value::Null) const; /** sets a new key/value pair in the configuration dictionary */ void setValue(const std::string& key, const Value& value); /** returns the Configuration info */ std::string getInfo() const; /** gathers OpenGL / GPU information */ void gatherGPUInfo(); /** Loads a config file. If the keys are already present, then they are going to be replaced. Otherwise the new keys are added. */ void loadConfigFile(const std::string& filename); private: Configuration(void); static Configuration *s_sharedConfiguration; static std::string s_configfile; protected: GLint _maxTextureSize; GLint _maxModelviewStackDepth; bool _supportsPVRTC; bool _supportsETC1; bool _supportsS3TC; bool _supportsATITC; bool _supportsNPOT; bool _supportsBGRA8888; bool _supportsDiscardFramebuffer; bool _supportsShareableVAO; GLint _maxSamplesAllowed; GLint _maxTextureUnits; char * _glExtensions; ValueMap _valueDict; }; // end of global group /// @} NS_CC_END #endif // __CCCONFIGURATION_H__ ================================================ FILE: cocos2d/cocos/2d/CCDeprecated.cpp ================================================ /**************************************************************************** Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocos2d.h" NS_CC_BEGIN const Point CCPointZero = Point::ZERO; /* The "zero" size -- equivalent to Size(0, 0). */ const Size CCSizeZero = Size::ZERO; /* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */ const Rect CCRectZero = Rect::ZERO; const Color3B ccWHITE = Color3B::WHITE; const Color3B ccYELLOW = Color3B::YELLOW; const Color3B ccGREEN = Color3B::GREEN; const Color3B ccBLUE = Color3B::BLUE; const Color3B ccRED = Color3B::RED; const Color3B ccMAGENTA = Color3B::MAGENTA; const Color3B ccBLACK = Color3B::BLACK; const Color3B ccORANGE = Color3B::ORANGE; const Color3B ccGRAY = Color3B::GRAY; const BlendFunc kCCBlendFuncDisable = BlendFunc::DISABLE; const char* kCCShader_PositionTextureColor = GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR; const char* kCCShader_PositionTextureColorAlphaTest = GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST; const char* kCCShader_PositionColor = GLProgram::SHADER_NAME_POSITION_COLOR; const char* kCCShader_PositionTexture = GLProgram::SHADER_NAME_POSITION_TEXTURE; const char* kCCShader_PositionTexture_uColor = GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR; const char* kCCShader_PositionTextureA8Color = GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR; const char* kCCShader_Position_uColor = GLProgram::SHADER_NAME_POSITION_U_COLOR; const char* kCCShader_PositionLengthTexureColor = GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR; // uniform names const char* kCCUniformPMatrix_s = GLProgram::UNIFORM_NAME_P_MATRIX; const char* kCCUniformMVMatrix_s = GLProgram::UNIFORM_NAME_MV_MATRIX; const char* kCCUniformMVPMatrix_s = GLProgram::UNIFORM_NAME_MVP_MATRIX; const char* kCCUniformTime_s = GLProgram::UNIFORM_NAME_TIME; const char* kCCUniformSinTime_s = GLProgram::UNIFORM_NAME_SIN_TIME; const char* kCCUniformCosTime_s = GLProgram::UNIFORM_NAME_COS_TIME; const char* kCCUniformRandom01_s = GLProgram::UNIFORM_NAME_RANDOM01; const char* kCCUniformSampler_s = GLProgram::UNIFORM_NAME_SAMPLER; const char* kCCUniformAlphaTestValue = GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE; // Attribute names const char* kCCAttributeNameColor = GLProgram::ATTRIBUTE_NAME_COLOR; const char* kCCAttributeNamePosition = GLProgram::ATTRIBUTE_NAME_POSITION; const char* kCCAttributeNameTexCoord = GLProgram::ATTRIBUTE_NAME_TEX_COORD; void ccDrawInit() { DrawPrimitives::init(); } void ccDrawFree() { DrawPrimitives::free(); } void ccDrawPoint( const Point& point ) { DrawPrimitives::drawPoint(point); } void ccDrawPoints( const Point *points, unsigned int numberOfPoints ) { DrawPrimitives::drawPoints(points, numberOfPoints); } void ccDrawLine( const Point& origin, const Point& destination ) { DrawPrimitives::drawLine(origin, destination); } void ccDrawRect( Point origin, Point destination ) { DrawPrimitives::drawRect(origin, destination); } void ccDrawSolidRect( Point origin, Point destination, Color4F color ) { DrawPrimitives::drawSolidRect(origin, destination, color); } void ccDrawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon ) { DrawPrimitives::drawPoly(vertices, numOfVertices, closePolygon); } void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ) { DrawPrimitives::drawSolidPoly(poli, numberOfPoints, color); } void ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY) { DrawPrimitives::drawCircle(center, radius, angle, segments, drawLineToCenter, scaleX, scaleY); } void ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) { DrawPrimitives::drawCircle(center, radius, angle, segments, drawLineToCenter); } void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY) { DrawPrimitives::drawSolidCircle(center, radius, angle, segments, scaleX, scaleY); } void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments) { DrawPrimitives::drawSolidCircle(center, radius, angle, segments); } void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments) { DrawPrimitives::drawQuadBezier(origin, control, destination, segments); } void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments) { DrawPrimitives::drawCubicBezier(origin, control1, control2, destination, segments); } void ccDrawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ) { DrawPrimitives::drawCatmullRom(arrayOfControlPoints, segments); } void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segments ) { DrawPrimitives::drawCardinalSpline(config, tension, segments); } void ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) { DrawPrimitives::setDrawColor4B(r, g, b, a); } void ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) { DrawPrimitives::setDrawColor4F(r, g, b, a); } void ccPointSize( GLfloat pointSize ) { DrawPrimitives::setPointSize(pointSize); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCDeprecated.h ================================================ /**************************************************************************** Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ /** Add deprecated global functions and variables here */ #ifndef __COCOS2D_CCDEPRECATED_H__ #define __COCOS2D_CCDEPRECATED_H__ #include #include "CCGeometry.h" #include "ccTypes.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ /** Helper macro that creates a Point @return Point @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE inline Point ccp(float x, float y) { return Point(x, y); } /** Returns opposite of point. @return Point @since v0.7.2 @deprecated please use Point::-, for example: -v1 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpNeg(const Point& v) { return -v; } /** Calculates sum of two points. @return Point @since v0.7.2 @deprecated please use Point::+, for example: v1 + v2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpAdd(const Point& v1, const Point& v2) { return v1 + v2; } /** Calculates difference of two points. @return Point @since v0.7.2 @deprecated please use Point::-, for example: v1 - v2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpSub(const Point& v1, const Point& v2) { return v1 - v2; } /** Returns point multiplied by given factor. @return Point @since v0.7.2 @deprecated please use Point::*, for example: v1 * v2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpMult(const Point& v, const float s) { return v * s; } /** Calculates midpoint between two points. @return Point @since v0.7.2 @deprecated please use it like (v1 + v2) / 2.0f */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpMidpoint(const Point& v1, const Point& v2) { return v1.getMidpoint(v2); } /** Calculates dot product of two points. @return float @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpDot(const Point& v1, const Point& v2) { return v1.dot(v2); } /** Calculates cross product of two points. @return float @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpCross(const Point& v1, const Point& v2) { return v1.cross(v2); } /** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0 @return Point @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpPerp(const Point& v) { return v.getPerp(); } /** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0 @return Point @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpRPerp(const Point& v) { return v.getRPerp(); } /** Calculates the projection of v1 over v2. @return Point @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpProject(const Point& v1, const Point& v2) { return v1.project(v2); } /** Rotates two points. @return Point @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpRotate(const Point& v1, const Point& v2) { return v1.rotate(v2); } /** Unrotates two points. @return Point @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpUnrotate(const Point& v1, const Point& v2) { return v1.unrotate(v2); } /** Calculates the square length of a Point (not calling sqrt() ) @return float @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpLengthSQ(const Point& v) { return v.getLengthSq(); } /** Calculates the square distance between two points (not calling sqrt() ) @return float @since v1.1 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpDistanceSQ(const Point p1, const Point p2) { return (p1 - p2).getLengthSq(); } /** Calculates distance between point an origin @return float @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpLength(const Point& v) { return v.getLength(); } /** Calculates the distance between two points @return float @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpDistance(const Point& v1, const Point& v2) { return v1.getDistance(v2); } /** Returns point multiplied to a length of 1. @return Point @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpNormalize(const Point& v) { return v.normalize(); } /** Converts radians to a normalized vector. @return Point @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpForAngle(const float a) { return Point::forAngle(a); } /** Converts a vector to radians. @return float @since v0.7.2 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpToAngle(const Point& v) { return v.getAngle(); } /** Clamp a point between from and to. @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpClamp(const Point& p, const Point& from, const Point& to) { return p.getClampPoint(from, to); } /** Quickly convert Size to a Point @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpFromSize(const Size& s) { return Point(s); } /** Run a math operation function on each point component * absf, fllorf, ceilf, roundf * any function that has the signature: float func(float); * For example: let's try to take the floor of x,y * ccpCompOp(p,floorf); @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpCompOp(const Point& p, float (*opFunc)(float)) { return p.compOp(opFunc); } /** Linear Interpolation between two points a and b @returns alpha == 0 ? a alpha == 1 ? b otherwise a value between a..b @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpLerp(const Point& a, const Point& b, float alpha) { return a.lerp(b, alpha); } /** @returns if points have fuzzy equality which means equal with some degree of variance. @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline bool ccpFuzzyEqual(const Point& a, const Point& b, float variance) { return a.fuzzyEquals(b, variance); } /** Multiplies a and b components, a.x*b.x, a.y*b.y @returns a component-wise multiplication @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpCompMult(const Point& a, const Point& b) { return Point(a.x * b.x, a.y * b.y); } /** @returns the signed angle in radians between two vector directions @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpAngleSigned(const Point& a, const Point& b) { return a.getAngle(b); } /** @returns the angle in radians between two vector directions @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline float ccpAngle(const Point& a, const Point& b) { return a.getAngle(b); } /** Rotates a point counter clockwise by the angle around a pivot @param v is the point to rotate @param pivot is the pivot, naturally @param angle is the angle of rotation cw in radians @returns the rotated point @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpRotateByAngle(const Point& v, const Point& pivot, float angle) { return v.rotateByAngle(pivot, angle); } /** A general line-line intersection test @param p1 is the startpoint for the first line P1 = (p1 - p2) @param p2 is the endpoint for the first line P1 = (p1 - p2) @param p3 is the startpoint for the second line P2 = (p3 - p4) @param p4 is the endpoint for the second line P2 = (p3 - p4) @param s is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1)) @param t is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3)) @return bool indicating successful intersection of a line note that to truly test intersection for segments we have to make sure that s & t lie within [0..1] and for rays, make sure s & t > 0 the hit point is p3 + t * (p4 - p3); the hit point also is p1 + s * (p2 - p1); @since v0.99.1 */ CC_DEPRECATED_ATTRIBUTE static inline bool ccpLineIntersect(const Point& p1, const Point& p2, const Point& p3, const Point& p4, float *s, float *t) { return Point::isLineIntersect(p1, p2, p3, p4, s, t); } /* ccpSegmentIntersect returns true if Segment A-B intersects with segment C-D @since v1.0.0 */ CC_DEPRECATED_ATTRIBUTE static inline bool ccpSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D) { return Point::isSegmentIntersect(A, B, C, D); } /* ccpIntersectPoint returns the intersection point of line A-B, C-D @since v1.0.0 */ CC_DEPRECATED_ATTRIBUTE static inline Point ccpIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D) { return Point::getIntersectPoint(A, B, C, D); } CC_DEPRECATED_ATTRIBUTE inline Point CCPointMake(float x, float y) { return Point(x, y); } CC_DEPRECATED_ATTRIBUTE inline Size CCSizeMake(float width, float height) { return Size(width, height); } CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, float height) { return Rect(x, y, width, height); } CC_DEPRECATED_ATTRIBUTE extern const Point CCPointZero; /* The "zero" size -- equivalent to Size(0, 0). */ CC_DEPRECATED_ATTRIBUTE extern const Size CCSizeZero; /* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */ CC_DEPRECATED_ATTRIBUTE extern const Rect CCRectZero; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccWHITE; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccYELLOW; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGREEN; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLUE; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccRED; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccMAGENTA; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLACK; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccORANGE; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGRAY; CC_DEPRECATED_ATTRIBUTE extern const BlendFunc kCCBlendFuncDisable; CC_DEPRECATED_ATTRIBUTE static inline Color3B ccc3(GLubyte r, GLubyte g, GLubyte b) { return Color3B(r, g, b); } CC_DEPRECATED_ATTRIBUTE static inline bool ccc3BEqual(const Color3B &col1, const Color3B &col2) { return col1.r == col2.r && col1.g == col2.g && col1.b == col2.b; } CC_DEPRECATED_ATTRIBUTE static inline Color4B ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o) { return Color4B(r, g, b, o); } CC_DEPRECATED_ATTRIBUTE static inline Color4F ccc4FFromccc3B(Color3B c) { return Color4F(c.r/255.f, c.g/255.f, c.b/255.f, 1.f); } CC_DEPRECATED_ATTRIBUTE static inline Color4F ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a) { return Color4F(r, g, b, a); } CC_DEPRECATED_ATTRIBUTE static inline Color4F ccc4FFromccc4B(Color4B c) { return Color4F(c.r/255.f, c.g/255.f, c.b/255.f, c.a/255.f); } CC_DEPRECATED_ATTRIBUTE static inline Color4B ccc4BFromccc4F(Color4F c) { return Color4B((GLubyte)(c.r*255), (GLubyte)(c.g*255), (GLubyte)(c.b*255), (GLubyte)(c.a*255)); } CC_DEPRECATED_ATTRIBUTE static inline bool ccc4FEqual(Color4F a, Color4F b) { return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; } CC_DEPRECATED_ATTRIBUTE static inline Vertex2F vertex2(const float x, const float y) { Vertex2F c(x, y); return c; } CC_DEPRECATED_ATTRIBUTE static inline Vertex3F vertex3(const float x, const float y, const float z) { Vertex3F c(x, y, z); return c; } CC_DEPRECATED_ATTRIBUTE static inline Tex2F tex2(const float u, const float v) { Tex2F t(u , v); return t; } CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty) { return AffineTransformMake(a, b, c, d, tx, ty); } CC_DEPRECATED_ATTRIBUTE static inline Point CCPointApplyAffineTransform(const Point& point, const AffineTransform& t) { return PointApplyAffineTransform(point, t); } CC_DEPRECATED_ATTRIBUTE static inline Size CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t) { return SizeApplyAffineTransform(size, t); } CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMakeIdentity() { return AffineTransformMakeIdentity(); } CC_DEPRECATED_ATTRIBUTE static inline Rect CCRectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform) { return RectApplyAffineTransform(rect, anAffineTransform); } CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformTranslate(const AffineTransform& t, float tx, float ty) { return AffineTransformTranslate(t, tx, ty); } CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformRotate(const AffineTransform& aTransform, float anAngle) { return AffineTransformRotate(aTransform, anAngle); } CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformScale(const AffineTransform& t, float sx, float sy) { return AffineTransformScale(t, sx, sy); } CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2) { return AffineTransformConcat(t1, t2); } CC_DEPRECATED_ATTRIBUTE static inline bool CCAffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2) { return AffineTransformEqualToTransform(t1, t2); } CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformInvert(const AffineTransform& t) { return AffineTransformInvert(t); } CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformIdentity() { return AffineTransformMakeIdentity(); } // CC prefix compatibility CC_DEPRECATED_ATTRIBUTE typedef Object CCObject; CC_DEPRECATED_ATTRIBUTE typedef Event CCEvent; CC_DEPRECATED_ATTRIBUTE typedef DataVisitor CCDataVisitor; CC_DEPRECATED_ATTRIBUTE typedef PrettyPrinter CCPrettyPrinter; CC_DEPRECATED_ATTRIBUTE typedef Acceleration CCAcceleration; CC_DEPRECATED_ATTRIBUTE typedef TextureAtlas CCTextureAtlas; CC_DEPRECATED_ATTRIBUTE typedef Configuration CCConfiguration; CC_DEPRECATED_ATTRIBUTE typedef PointArray CCPointArray; CC_DEPRECATED_ATTRIBUTE typedef RemoveSelf CCRemoveSelf; CC_DEPRECATED_ATTRIBUTE typedef IMEDelegate CCIMEDelegate; CC_DEPRECATED_ATTRIBUTE typedef IMEKeyboardNotificationInfo CCIMEKeyboardNotificationInfo; CC_DEPRECATED_ATTRIBUTE typedef TextFieldDelegate CCTextFieldDelegate; CC_DEPRECATED_ATTRIBUTE typedef TextFieldTTF CCTextFieldTTF; CC_DEPRECATED_ATTRIBUTE typedef __NotificationCenter CCNotificationCenter; CC_DEPRECATED_ATTRIBUTE typedef __NotificationCenter NotificationCenter; //CC_DEPRECATED_ATTRIBUTE typedef TargetedTouchDelegate CCTargetedTouchDelegate; //CC_DEPRECATED_ATTRIBUTE typedef StandardTouchDelegate CCStandardTouchDelegate; //CC_DEPRECATED_ATTRIBUTE typedef TouchDelegate CCTouchDelegate; CC_DEPRECATED_ATTRIBUTE typedef Image CCImage; CC_DEPRECATED_ATTRIBUTE typedef UserDefault CCUserDefault; CC_DEPRECATED_ATTRIBUTE typedef Action CCAction; CC_DEPRECATED_ATTRIBUTE typedef FiniteTimeAction CCFiniteTimeAction; CC_DEPRECATED_ATTRIBUTE typedef Speed CCSpeed; CC_DEPRECATED_ATTRIBUTE typedef Follow CCFollow; CC_DEPRECATED_ATTRIBUTE typedef GLProgram CCGLProgram; CC_DEPRECATED_ATTRIBUTE typedef Touch CCTouch; CC_DEPRECATED_ATTRIBUTE typedef Texture2D CCTexture2D; CC_DEPRECATED_ATTRIBUTE typedef Node CCNode; CC_DEPRECATED_ATTRIBUTE typedef Node CCNodeRGBA; CC_DEPRECATED_ATTRIBUTE typedef Node CCRGBAProtocol; CC_DEPRECATED_ATTRIBUTE typedef SpriteFrame CCSpriteFrame; CC_DEPRECATED_ATTRIBUTE typedef AnimationFrame CCAnimationFrame; CC_DEPRECATED_ATTRIBUTE typedef Animation CCAnimation; CC_DEPRECATED_ATTRIBUTE typedef ActionInterval CCActionInterval; CC_DEPRECATED_ATTRIBUTE typedef Sequence CCSequence; CC_DEPRECATED_ATTRIBUTE typedef Repeat CCRepeat; CC_DEPRECATED_ATTRIBUTE typedef RepeatForever CCRepeatForever; CC_DEPRECATED_ATTRIBUTE typedef Spawn CCSpawn; CC_DEPRECATED_ATTRIBUTE typedef RotateTo CCRotateTo; CC_DEPRECATED_ATTRIBUTE typedef RotateBy CCRotateBy; CC_DEPRECATED_ATTRIBUTE typedef MoveBy CCMoveBy; CC_DEPRECATED_ATTRIBUTE typedef MoveTo CCMoveTo; CC_DEPRECATED_ATTRIBUTE typedef SkewTo CCSkewTo; CC_DEPRECATED_ATTRIBUTE typedef SkewBy CCSkewBy; CC_DEPRECATED_ATTRIBUTE typedef JumpBy CCJumpBy; CC_DEPRECATED_ATTRIBUTE typedef JumpTo CCJumpTo; CC_DEPRECATED_ATTRIBUTE typedef BezierBy CCBezierBy; CC_DEPRECATED_ATTRIBUTE typedef BezierTo CCBezierTo; CC_DEPRECATED_ATTRIBUTE typedef ScaleTo CCScaleTo; CC_DEPRECATED_ATTRIBUTE typedef ScaleBy CCScaleBy; CC_DEPRECATED_ATTRIBUTE typedef Blink CCBlink; CC_DEPRECATED_ATTRIBUTE typedef FadeIn CCFadeIn; CC_DEPRECATED_ATTRIBUTE typedef FadeOut CCFadeOut; CC_DEPRECATED_ATTRIBUTE typedef FadeTo CCFadeTo; CC_DEPRECATED_ATTRIBUTE typedef TintTo CCTintTo; CC_DEPRECATED_ATTRIBUTE typedef TintBy CCTintBy; CC_DEPRECATED_ATTRIBUTE typedef DelayTime CCDelayTime; CC_DEPRECATED_ATTRIBUTE typedef Animate CCAnimate; CC_DEPRECATED_ATTRIBUTE typedef TargetedAction CCTargetedAction; CC_DEPRECATED_ATTRIBUTE typedef ActionCamera CCActionCamera; CC_DEPRECATED_ATTRIBUTE typedef OrbitCamera CCOrbitCamera; CC_DEPRECATED_ATTRIBUTE typedef ActionManager CCActionManager; CC_DEPRECATED_ATTRIBUTE typedef ActionEase CCActionEase; CC_DEPRECATED_ATTRIBUTE typedef EaseRateAction CCEaseRateAction; CC_DEPRECATED_ATTRIBUTE typedef EaseIn CCEaseIn; CC_DEPRECATED_ATTRIBUTE typedef EaseOut CCEaseOut; CC_DEPRECATED_ATTRIBUTE typedef EaseInOut CCEaseInOut; CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialIn CCEaseExponentialIn; CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialOut CCEaseExponentialOut; CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialInOut CCEaseExponentialInOut; CC_DEPRECATED_ATTRIBUTE typedef EaseSineIn CCEaseSineIn; CC_DEPRECATED_ATTRIBUTE typedef EaseSineOut CCEaseSineOut; CC_DEPRECATED_ATTRIBUTE typedef EaseSineInOut CCEaseSineInOut; CC_DEPRECATED_ATTRIBUTE typedef EaseElastic CCEaseElastic; CC_DEPRECATED_ATTRIBUTE typedef EaseElasticIn CCEaseElasticIn; CC_DEPRECATED_ATTRIBUTE typedef EaseElasticOut CCEaseElasticOut; CC_DEPRECATED_ATTRIBUTE typedef EaseElasticInOut CCEaseElasticInOut; CC_DEPRECATED_ATTRIBUTE typedef EaseBounce CCEaseBounce; CC_DEPRECATED_ATTRIBUTE typedef EaseBounceIn CCEaseBounceIn; CC_DEPRECATED_ATTRIBUTE typedef EaseBounceOut CCEaseBounceOut; CC_DEPRECATED_ATTRIBUTE typedef EaseBounceInOut CCEaseBounceInOut; CC_DEPRECATED_ATTRIBUTE typedef EaseBackIn CCEaseBackIn; CC_DEPRECATED_ATTRIBUTE typedef EaseBackOut CCEaseBackOut; CC_DEPRECATED_ATTRIBUTE typedef EaseBackInOut CCEaseBackInOut; CC_DEPRECATED_ATTRIBUTE typedef ActionInstant CCActionInstant; CC_DEPRECATED_ATTRIBUTE typedef Show CCShow; CC_DEPRECATED_ATTRIBUTE typedef Hide CCHide; CC_DEPRECATED_ATTRIBUTE typedef ToggleVisibility CCToggleVisibility; CC_DEPRECATED_ATTRIBUTE typedef FlipX CCFlipX; CC_DEPRECATED_ATTRIBUTE typedef FlipY CCFlipY; CC_DEPRECATED_ATTRIBUTE typedef Place CCPlace; CC_DEPRECATED_ATTRIBUTE typedef CallFunc CCCallFunc; CC_DEPRECATED_ATTRIBUTE typedef CallFuncN CCCallFuncN; CC_DEPRECATED_ATTRIBUTE typedef __CCCallFuncND CCCallFuncND; CC_DEPRECATED_ATTRIBUTE typedef __CCCallFuncO CCCallFuncO; CC_DEPRECATED_ATTRIBUTE typedef GridAction CCGridAction; CC_DEPRECATED_ATTRIBUTE typedef Grid3DAction CCGrid3DAction; CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3DAction CCTiledGrid3DAction; CC_DEPRECATED_ATTRIBUTE typedef StopGrid CCStopGrid; CC_DEPRECATED_ATTRIBUTE typedef ReuseGrid CCReuseGrid; CC_DEPRECATED_ATTRIBUTE typedef Waves3D CCWaves3D; CC_DEPRECATED_ATTRIBUTE typedef FlipX3D CCFlipX3D; CC_DEPRECATED_ATTRIBUTE typedef FlipY3D CCFlipY3D; CC_DEPRECATED_ATTRIBUTE typedef Lens3D CCLens3D; CC_DEPRECATED_ATTRIBUTE typedef Ripple3D CCRipple3D; CC_DEPRECATED_ATTRIBUTE typedef Shaky3D CCShaky3D; CC_DEPRECATED_ATTRIBUTE typedef Liquid CCLiquid; CC_DEPRECATED_ATTRIBUTE typedef Waves CCWaves; CC_DEPRECATED_ATTRIBUTE typedef Twirl CCTwirl; CC_DEPRECATED_ATTRIBUTE typedef PageTurn3D CCPageTurn3D; CC_DEPRECATED_ATTRIBUTE typedef ProgressTo CCProgressTo; CC_DEPRECATED_ATTRIBUTE typedef ProgressFromTo CCProgressFromTo; CC_DEPRECATED_ATTRIBUTE typedef ShakyTiles3D CCShakyTiles3D; CC_DEPRECATED_ATTRIBUTE typedef ShatteredTiles3D CCShatteredTiles3D; CC_DEPRECATED_ATTRIBUTE typedef ShuffleTiles CCShuffleTiles; CC_DEPRECATED_ATTRIBUTE typedef FadeOutTRTiles CCFadeOutTRTiles; CC_DEPRECATED_ATTRIBUTE typedef FadeOutBLTiles CCFadeOutBLTiles; CC_DEPRECATED_ATTRIBUTE typedef FadeOutUpTiles CCFadeOutUpTiles; CC_DEPRECATED_ATTRIBUTE typedef FadeOutDownTiles CCFadeOutDownTiles; CC_DEPRECATED_ATTRIBUTE typedef TurnOffTiles CCTurnOffTiles; CC_DEPRECATED_ATTRIBUTE typedef WavesTiles3D CCWavesTiles3D; CC_DEPRECATED_ATTRIBUTE typedef JumpTiles3D CCJumpTiles3D; CC_DEPRECATED_ATTRIBUTE typedef SplitRows CCSplitRows; CC_DEPRECATED_ATTRIBUTE typedef SplitCols CCSplitCols; CC_DEPRECATED_ATTRIBUTE typedef ActionTween CCActionTween; CC_DEPRECATED_ATTRIBUTE typedef CardinalSplineTo CCCardinalSplineTo; CC_DEPRECATED_ATTRIBUTE typedef CardinalSplineBy CCCardinalSplineBy; CC_DEPRECATED_ATTRIBUTE typedef CatmullRomTo CCCatmullRomTo; CC_DEPRECATED_ATTRIBUTE typedef CatmullRomBy CCCatmullRomBy; CC_DEPRECATED_ATTRIBUTE typedef AtlasNode CCAtlasNode; CC_DEPRECATED_ATTRIBUTE typedef TextureProtocol CCTextureProtocol; CC_DEPRECATED_ATTRIBUTE typedef BlendProtocol CCBlendProtocol; CC_DEPRECATED_ATTRIBUTE typedef DrawNode CCDrawNode; CC_DEPRECATED_ATTRIBUTE typedef Camera CCCamera; CC_DEPRECATED_ATTRIBUTE typedef LabelAtlas CCLabelAtlas; CC_DEPRECATED_ATTRIBUTE typedef LabelProtocol CCLabelProtocol; CC_DEPRECATED_ATTRIBUTE typedef Director CCDirector; CC_DEPRECATED_ATTRIBUTE typedef GridBase CCGridBase; CC_DEPRECATED_ATTRIBUTE typedef Grid3D CCGrid3D; CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3D CCTiledGrid3D; CC_DEPRECATED_ATTRIBUTE typedef Sprite CCSprite; CC_DEPRECATED_ATTRIBUTE typedef LabelTTF CCLabelTTF; CC_DEPRECATED_ATTRIBUTE typedef SpriteBatchNode CCSpriteBatchNode; CC_DEPRECATED_ATTRIBUTE typedef LabelBMFont CCLabelBMFont; CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayer; //CC_DEPRECATED_ATTRIBUTE typedef KeypadDelegate CCKeypadDelegate; CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayerRGBA; CC_DEPRECATED_ATTRIBUTE typedef LayerColor CCLayerColor; CC_DEPRECATED_ATTRIBUTE typedef LayerGradient CCLayerGradient; CC_DEPRECATED_ATTRIBUTE typedef LayerMultiplex CCLayerMultiplex; CC_DEPRECATED_ATTRIBUTE typedef Scene CCScene; CC_DEPRECATED_ATTRIBUTE typedef TransitionEaseScene CCTransitionEaseScene; CC_DEPRECATED_ATTRIBUTE typedef TransitionScene CCTransitionScene; CC_DEPRECATED_ATTRIBUTE typedef TransitionSceneOriented CCTransitionSceneOriented; CC_DEPRECATED_ATTRIBUTE typedef TransitionRotoZoom CCTransitionRotoZoom; CC_DEPRECATED_ATTRIBUTE typedef TransitionJumpZoom CCTransitionJumpZoom; CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInL CCTransitionMoveInL; CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInR CCTransitionMoveInR; CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInT CCTransitionMoveInT; CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInB CCTransitionMoveInB; CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInL CCTransitionSlideInL; CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInR CCTransitionSlideInR; CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInB CCTransitionSlideInB; CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInT CCTransitionSlideInT; CC_DEPRECATED_ATTRIBUTE typedef TransitionShrinkGrow CCTransitionShrinkGrow; CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipX CCTransitionFlipX; CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipY CCTransitionFlipY; CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipAngular CCTransitionFlipAngular; CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipX CCTransitionZoomFlipX; CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipY CCTransitionZoomFlipY; CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipAngular CCTransitionZoomFlipAngular; CC_DEPRECATED_ATTRIBUTE typedef TransitionFade CCTransitionFade; CC_DEPRECATED_ATTRIBUTE typedef TransitionCrossFade CCTransitionCrossFade; CC_DEPRECATED_ATTRIBUTE typedef TransitionTurnOffTiles CCTransitionTurnOffTiles; CC_DEPRECATED_ATTRIBUTE typedef TransitionSplitCols CCTransitionSplitCols; CC_DEPRECATED_ATTRIBUTE typedef TransitionSplitRows CCTransitionSplitRows; CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeTR CCTransitionFadeTR; CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeBL CCTransitionFadeBL; CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeUp CCTransitionFadeUp; CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeDown CCTransitionFadeDown; CC_DEPRECATED_ATTRIBUTE typedef TransitionPageTurn CCTransitionPageTurn; CC_DEPRECATED_ATTRIBUTE typedef TransitionProgress CCTransitionProgress; CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressRadialCCW CCTransitionProgressRadialCCW; CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressRadialCW CCTransitionProgressRadialCW; CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressHorizontal CCTransitionProgressHorizontal; CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressVertical CCTransitionProgressVertical; CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressInOut CCTransitionProgressInOut; CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressOutIn CCTransitionProgressOutIn; CC_DEPRECATED_ATTRIBUTE typedef MenuItem CCMenuItem; CC_DEPRECATED_ATTRIBUTE typedef MenuItemLabel CCMenuItemLabel; CC_DEPRECATED_ATTRIBUTE typedef MenuItemAtlasFont CCMenuItemAtlasFont; CC_DEPRECATED_ATTRIBUTE typedef MenuItemFont CCMenuItemFont; CC_DEPRECATED_ATTRIBUTE typedef MenuItemSprite CCMenuItemSprite; CC_DEPRECATED_ATTRIBUTE typedef MenuItemImage CCMenuItemImage; CC_DEPRECATED_ATTRIBUTE typedef MenuItemToggle CCMenuItemToggle; CC_DEPRECATED_ATTRIBUTE typedef Menu CCMenu; CC_DEPRECATED_ATTRIBUTE typedef ClippingNode CCClippingNode; CC_DEPRECATED_ATTRIBUTE typedef MotionStreak CCMotionStreak; CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer CCProgressTimer; CC_DEPRECATED_ATTRIBUTE typedef RenderTexture CCRenderTexture; CC_DEPRECATED_ATTRIBUTE typedef ParticleBatchNode CCParticleBatchNode; CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem CCParticleSystem; CC_DEPRECATED_ATTRIBUTE typedef ParticleSystemQuad CCParticleSystemQuad; CC_DEPRECATED_ATTRIBUTE typedef ParticleFire CCParticleFire; CC_DEPRECATED_ATTRIBUTE typedef ParticleFireworks CCParticleFireworks; CC_DEPRECATED_ATTRIBUTE typedef ParticleSun CCParticleSun; CC_DEPRECATED_ATTRIBUTE typedef ParticleGalaxy CCParticleGalaxy; CC_DEPRECATED_ATTRIBUTE typedef ParticleFlower CCParticleFlower; CC_DEPRECATED_ATTRIBUTE typedef ParticleMeteor CCParticleMeteor; CC_DEPRECATED_ATTRIBUTE typedef ParticleSpiral CCParticleSpiral; CC_DEPRECATED_ATTRIBUTE typedef ParticleExplosion CCParticleExplosion; CC_DEPRECATED_ATTRIBUTE typedef ParticleSmoke CCParticleSmoke; CC_DEPRECATED_ATTRIBUTE typedef ParticleSnow CCParticleSnow; CC_DEPRECATED_ATTRIBUTE typedef ParticleRain CCParticleRain; CC_DEPRECATED_ATTRIBUTE typedef FileUtils CCFileUtils; CC_DEPRECATED_ATTRIBUTE typedef Application CCApplication; CC_DEPRECATED_ATTRIBUTE typedef ShaderCache CCShaderCache; CC_DEPRECATED_ATTRIBUTE typedef AnimationCache CCAnimationCache; CC_DEPRECATED_ATTRIBUTE typedef SpriteFrameCache CCSpriteFrameCache; CC_DEPRECATED_ATTRIBUTE typedef TextureCache CCTextureCache; CC_DEPRECATED_ATTRIBUTE typedef ParallaxNode CCParallaxNode; CC_DEPRECATED_ATTRIBUTE typedef TMXObjectGroup CCTMXObjectGroup; CC_DEPRECATED_ATTRIBUTE typedef TMXLayerInfo CCTMXLayerInfo; CC_DEPRECATED_ATTRIBUTE typedef TMXTilesetInfo CCTMXTilesetInfo; CC_DEPRECATED_ATTRIBUTE typedef TMXMapInfo CCTMXMapInfo; CC_DEPRECATED_ATTRIBUTE typedef TMXLayer CCTMXLayer; CC_DEPRECATED_ATTRIBUTE typedef TMXTiledMap CCTMXTiledMap; CC_DEPRECATED_ATTRIBUTE typedef TileMapAtlas CCTileMapAtlas; CC_DEPRECATED_ATTRIBUTE typedef Timer CCTimer; CC_DEPRECATED_ATTRIBUTE typedef Scheduler CCScheduler; CC_DEPRECATED_ATTRIBUTE typedef EGLView CCEGLView; CC_DEPRECATED_ATTRIBUTE typedef Component CCComponent; CC_DEPRECATED_ATTRIBUTE typedef AffineTransform CCAffineTransform; CC_DEPRECATED_ATTRIBUTE typedef Point CCPoint; CC_DEPRECATED_ATTRIBUTE typedef Size CCSize; CC_DEPRECATED_ATTRIBUTE typedef Rect CCRect; CC_DEPRECATED_ATTRIBUTE typedef Color3B ccColor3B; CC_DEPRECATED_ATTRIBUTE typedef Color4F ccColor4F; CC_DEPRECATED_ATTRIBUTE typedef Color4B ccColor4B; CC_DEPRECATED_ATTRIBUTE typedef Vertex2F ccVertex2F; CC_DEPRECATED_ATTRIBUTE typedef Vertex3F ccVertex3F; CC_DEPRECATED_ATTRIBUTE typedef Tex2F ccTex2F; CC_DEPRECATED_ATTRIBUTE typedef PointSprite ccPointSprite; CC_DEPRECATED_ATTRIBUTE typedef Quad2 ccQuad2; CC_DEPRECATED_ATTRIBUTE typedef Quad3 ccQuad3; CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F ccV2F_C4B_T2F; CC_DEPRECATED_ATTRIBUTE typedef V2F_C4F_T2F ccV2F_C4F_T2F; CC_DEPRECATED_ATTRIBUTE typedef V3F_C4B_T2F ccV3F_C4B_T2F; CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F_Triangle ccV2F_C4B_T2F_Triangle; CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F_Quad ccV2F_C4B_T2F_Quad; CC_DEPRECATED_ATTRIBUTE typedef V3F_C4B_T2F_Quad ccV3F_C4B_T2F_Quad; CC_DEPRECATED_ATTRIBUTE typedef V2F_C4F_T2F_Quad ccV2F_C4F_T2F_Quad; CC_DEPRECATED_ATTRIBUTE typedef BlendFunc ccBlendFunc; CC_DEPRECATED_ATTRIBUTE typedef T2F_Quad ccT2F_Quad; CC_DEPRECATED_ATTRIBUTE typedef AnimationFrameData ccAnimationFrameData; CC_DEPRECATED_ATTRIBUTE typedef FontShadow ccFontShadow; CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke; CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition; CC_DEPRECATED_ATTRIBUTE typedef TextVAlignment CCVerticalTextAlignment; CC_DEPRECATED_ATTRIBUTE typedef TextHAlignment CCTextAlignment; CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type CCProgressTimerType; CC_DEPRECATED_ATTRIBUTE typedef void* CCZone; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_Position = GLProgram::VERTEX_ATTRIB_POSITION; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_Color = GLProgram::VERTEX_ATTRIB_COLOR; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_TexCoords = GLProgram::VERTEX_ATTRIB_TEX_COORDS; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_MAX = GLProgram::VERTEX_ATTRIB_MAX; CC_DEPRECATED_ATTRIBUTE const int kCCUniformPMatrix = GLProgram::UNIFORM_P_MATRIX; CC_DEPRECATED_ATTRIBUTE const int kCCUniformMVMatrix = GLProgram::UNIFORM_MV_MATRIX; CC_DEPRECATED_ATTRIBUTE const int kCCUniformMVPMatrix = GLProgram::UNIFORM_MVP_MATRIX; CC_DEPRECATED_ATTRIBUTE const int kCCUniformTime = GLProgram::UNIFORM_TIME; CC_DEPRECATED_ATTRIBUTE const int kCCUniformSinTime = GLProgram::UNIFORM_SIN_TIME; CC_DEPRECATED_ATTRIBUTE const int kCCUniformCosTime = GLProgram::UNIFORM_COS_TIME; CC_DEPRECATED_ATTRIBUTE const int kCCUniformRandom01 = GLProgram::UNIFORM_RANDOM01; CC_DEPRECATED_ATTRIBUTE const int kCCUniformSampler = GLProgram::UNIFORM_SAMPLER; CC_DEPRECATED_ATTRIBUTE const int kCCUniform_MAX = GLProgram::UNIFORM_MAX; CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColor; CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColorAlphaTest; CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionColor; CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTexture; CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTexture_uColor; CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureA8Color; CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_Position_uColor; CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionLengthTexureColor; // uniform names CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformPMatrix_s; CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformMVMatrix_s; CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformMVPMatrix_s; CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformTime_s; CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformSinTime_s; CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformCosTime_s; CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformRandom01_s; CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformSampler_s; CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformAlphaTestValue; // Attribute names CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameColor; CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNamePosition; CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameTexCoord; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_None = GL::VERTEX_ATTRIB_FLAT_NONE; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_Position = GL::VERTEX_ATTRIB_FLAG_POSITION; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_Color = GL::VERTEX_ATTRIB_FLAG_COLOR; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_TexCoords = GL::VERTEX_ATTRIB_FLAG_TEX_COORDS; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_PosColorTex = GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX; CC_DEPRECATED_ATTRIBUTE const ProgressTimer::Type kCCProgressTimerTypeRadial = ProgressTimer::Type::RADIAL; CC_DEPRECATED_ATTRIBUTE const ProgressTimer::Type kCCProgressTimerTypeBar = ProgressTimer::Type::BAR; CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type ProgressTimerType; CC_DEPRECATED_ATTRIBUTE const Director::Projection kCCDirectorProjection2D = Director::Projection::_2D; CC_DEPRECATED_ATTRIBUTE const Director::Projection kCCDirectorProjection3D = Director::Projection::_3D; CC_DEPRECATED_ATTRIBUTE const Director::Projection kCCDirectorProjectionCustom = Director::Projection::CUSTOM; CC_DEPRECATED_ATTRIBUTE const Director::Projection kCCDirectorProjectionDefault = Director::Projection::DEFAULT; CC_DEPRECATED_ATTRIBUTE typedef Director::Projection ccDirectorProjection; CC_DEPRECATED_ATTRIBUTE const TextVAlignment kCCVerticalTextAlignmentTop = TextVAlignment::TOP; CC_DEPRECATED_ATTRIBUTE const TextVAlignment kCCVerticalTextAlignmentCenter = TextVAlignment::CENTER; CC_DEPRECATED_ATTRIBUTE const TextVAlignment kCCVerticalTextAlignmentBottom = TextVAlignment::BOTTOM; CC_DEPRECATED_ATTRIBUTE const TextHAlignment kCCTextAlignmentLeft = TextHAlignment::LEFT; CC_DEPRECATED_ATTRIBUTE const TextHAlignment kCCTextAlignmentCenter = TextHAlignment::CENTER; CC_DEPRECATED_ATTRIBUTE const TextHAlignment kCCTextAlignmentRight = TextHAlignment::RIGHT; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA8888 = Texture2D::PixelFormat::RGBA8888; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB888 = Texture2D::PixelFormat::RGB888; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB565 = Texture2D::PixelFormat::RGB565; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_A8 = Texture2D::PixelFormat::A8; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8 = Texture2D::PixelFormat::I8; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88 = Texture2D::PixelFormat::AI88; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444 = Texture2D::PixelFormat::RGBA4444; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1 = Texture2D::PixelFormat::RGB5A1; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PixelFormat::PVRTC4; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PixelFormat::PVRTC2; CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default = Texture2D::PixelFormat::DEFAULT; CC_DEPRECATED_ATTRIBUTE typedef Texture2D::PixelFormat CCTexture2DPixelFormat; CC_DEPRECATED_ATTRIBUTE const int kCCParticleDurationInfinity = ParticleSystem::DURATION_INFINITY; CC_DEPRECATED_ATTRIBUTE const int kCCParticleStartSizeEqualToEndSize = ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE; CC_DEPRECATED_ATTRIBUTE const int kCCParticleStartRadiusEqualToEndRadius = ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS; CC_DEPRECATED_ATTRIBUTE const int kParticleDurationInfinity = ParticleSystem::DURATION_INFINITY; CC_DEPRECATED_ATTRIBUTE const int kParticleStartSizeEqualToEndSize = ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE; CC_DEPRECATED_ATTRIBUTE const int kParticleStartRadiusEqualToEndRadius = ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS; CC_DEPRECATED_ATTRIBUTE const ParticleSystem::Mode kCCParticleModeGravity = ParticleSystem::Mode::GRAVITY; CC_DEPRECATED_ATTRIBUTE const ParticleSystem::Mode kCCParticleModeRadius = ParticleSystem::Mode::RADIUS; CC_DEPRECATED_ATTRIBUTE const int kCCParticleDefaultCapacity = kParticleDefaultCapacity; CC_DEPRECATED_ATTRIBUTE const ParticleSystem::PositionType kCCPositionTypeFree = ParticleSystem::PositionType::FREE; CC_DEPRECATED_ATTRIBUTE const ParticleSystem::PositionType kCCPositionTypeRelative = ParticleSystem::PositionType::RELATIVE; CC_DEPRECATED_ATTRIBUTE const ParticleSystem::PositionType kCCPositionTypeGrouped = ParticleSystem::PositionType::GROUPED; CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem::PositionType tPositionType; #define kCCLabelAutomaticWidth kLabelAutomaticWidth CC_DEPRECATED_ATTRIBUTE const Menu::State kCCMenuStateWaiting = Menu::State::WAITING; CC_DEPRECATED_ATTRIBUTE const Menu::State kCCMenuStateTrackingTouch = Menu::State::TRACKING_TOUCH; CC_DEPRECATED_ATTRIBUTE typedef Menu::State tMenuState; CC_DEPRECATED_ATTRIBUTE const Touch::DispatchMode kCCTouchesOneByOne = Touch::DispatchMode::ONE_BY_ONE; CC_DEPRECATED_ATTRIBUTE const Touch::DispatchMode kCCTouchesAllAtOnce = Touch::DispatchMode::ALL_AT_ONCE; CC_DEPRECATED_ATTRIBUTE typedef Touch::DispatchMode ccTouchesMode; CC_DEPRECATED_ATTRIBUTE const Image::Format kCCImageFormatPNG = Image::Format::PNG; CC_DEPRECATED_ATTRIBUTE const Image::Format kCCImageFormatJPEG = Image::Format::JPG; CC_DEPRECATED_ATTRIBUTE typedef Image::Format tImageFormat; CC_DEPRECATED_ATTRIBUTE const TransitionScene::Orientation kCCTransitionOrientationLeftOver = TransitionScene::Orientation::LEFT_OVER; CC_DEPRECATED_ATTRIBUTE const TransitionScene::Orientation kCCTransitionOrientationRightOver = TransitionScene::Orientation::RIGHT_OVER; CC_DEPRECATED_ATTRIBUTE const TransitionScene::Orientation kCCTransitionOrientationUpOver = TransitionScene::Orientation::UP_OVER; CC_DEPRECATED_ATTRIBUTE const TransitionScene::Orientation kCCTransitionOrientationDownOver = TransitionScene::Orientation::DOWN_OVER; CC_DEPRECATED_ATTRIBUTE typedef TransitionScene::Orientation tOrientation; CC_DEPRECATED_ATTRIBUTE const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM; CC_DEPRECATED_ATTRIBUTE const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN; CC_DEPRECATED_ATTRIBUTE const int kCCActionTagInvalid = Action::INVALID_TAG; CC_DEPRECATED_ATTRIBUTE const int kCCNodeTagInvalid = Node::INVALID_TAG; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnEnter = kNodeOnEnter; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnExit = kNodeOnExit; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnEnterTransitionDidFinish = kNodeOnEnterTransitionDidFinish; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnExitTransitionDidStart = kNodeOnExitTransitionDidStart; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnCleanup = kNodeOnCleanup; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageEnglish = LanguageType::ENGLISH; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageChinese = LanguageType::CHINESE; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageFrench = LanguageType::FRENCH; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageItalian = LanguageType::ITALIAN; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageGerman = LanguageType::GERMAN; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageSpanish = LanguageType::SPANISH; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageRussian = LanguageType::RUSSIAN; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageKorean = LanguageType::KOREAN; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageJapanese = LanguageType::JAPANESE; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageHungarian = LanguageType::HUNGARIAN; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguagePortuguese = LanguageType::PORTUGUESE; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageArabic = LanguageType::ARABIC; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageNorwegian = LanguageType::NORWEGIAN; CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguagePolish = LanguageType::POLISH; CC_DEPRECATED_ATTRIBUTE typedef LanguageType ccLanguageType; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetWindows = Application::Platform::OS_WINDOWS; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetLinux = Application::Platform::OS_LINUX; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetMacOS = Application::Platform::OS_MAC; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetAndroid = Application::Platform::OS_ANDROID; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetIphone = Application::Platform::OS_IPHONE; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetIpad = Application::Platform::OS_IPAD; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetBlackBerry = Application::Platform::OS_BLACKBERRY; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetNaCl = Application::Platform::OS_NACL; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetEmscripten = Application::Platform::OS_EMSCRIPTEN; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetTizen = Application::Platform::OS_TIZEN; CC_DEPRECATED_ATTRIBUTE typedef Application::Platform TargetPlatform; CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionExactFit = ResolutionPolicy::EXACT_FIT; CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionNoBorder = ResolutionPolicy::NO_BORDER; CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionShowAll = ResolutionPolicy::SHOW_ALL; CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionFixedHeight = ResolutionPolicy::FIXED_HEIGHT; CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionFixedWidth = ResolutionPolicy::FIXED_WIDTH; CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionUnKnown = ResolutionPolicy::UNKNOWN; #define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag #define kCCTMXTileVerticalFlag kTMXTileVerticalFlag #define kCCTMXTileDiagonalFlag kTMXTileDiagonalFlag #define kCCFlipedAll kFlipedAll #define kCCFlippedMask kFlippedMask /** use log() instead */ CC_DEPRECATED_ATTRIBUTE void CC_DLL CCLog(const char * pszFormat, ...) CC_FORMAT_PRINTF(1, 2); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawInit(); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawFree(); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoint( const Point& point ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoints( const Point *points, unsigned int numberOfPoints ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawLine( const Point& origin, const Point& destination ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawRect( Point origin, Point destination ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidRect( Point origin, Point destination, Color4F color ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segments ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ); CC_DEPRECATED_ATTRIBUTE void CC_DLL ccPointSize( GLfloat pointSize ); CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLInvalidateStateCache() { GL::invalidateStateCache(); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLUseProgram(GLuint program) { GL::useProgram(program); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteProgram(GLuint program){ GL::deleteProgram(program); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBlendFunc(GLenum sfactor, GLenum dfactor) { GL::blendFunc(sfactor, dfactor); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBlendResetToCache() { GL::blendResetToCache(); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccSetProjectionMatrixDirty() { GL::setProjectionMatrixDirty(); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLEnableVertexAttribs(unsigned int flags) { GL::enableVertexAttribs(flags); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindTexture2D(GLuint textureId) { GL::bindTexture2D(textureId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId) { GL::bindTexture2DN(textureUnit, textureId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteTexture(GLuint textureId) { GL::deleteTexture(textureId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId) { GL::deleteTextureN(textureUnit, textureId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindVAO(GLuint vaoId) { GL::bindVAO(vaoId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLEnable( int flags ) { /* ignore */ }; CC_DEPRECATED_ATTRIBUTE typedef int ccGLServerState; CC_DEPRECATED_ATTRIBUTE typedef Data CCData; CC_DEPRECATED_ATTRIBUTE typedef __Set CCSet; CC_DEPRECATED_ATTRIBUTE typedef __SetIterator CCSetIterator; CC_DEPRECATED_ATTRIBUTE typedef __Set Set; CC_DEPRECATED_ATTRIBUTE typedef __SetIterator SetIterator; CC_DEPRECATED_ATTRIBUTE typedef __Array CCArray; CC_DEPRECATED_ATTRIBUTE typedef __Array Array; CC_DEPRECATED_ATTRIBUTE typedef __Dictionary Dictionary; CC_DEPRECATED_ATTRIBUTE typedef __Dictionary CCDictionary; CC_DEPRECATED_ATTRIBUTE typedef __Double Double; CC_DEPRECATED_ATTRIBUTE typedef __Double CCDouble; CC_DEPRECATED_ATTRIBUTE typedef __Float Float; CC_DEPRECATED_ATTRIBUTE typedef __Float CCFloat; CC_DEPRECATED_ATTRIBUTE typedef __Integer Integer; CC_DEPRECATED_ATTRIBUTE typedef __Integer CCInteger; CC_DEPRECATED_ATTRIBUTE typedef __Bool Bool; CC_DEPRECATED_ATTRIBUTE typedef __Bool CCBool; CC_DEPRECATED_ATTRIBUTE typedef __String CCString; CC_DEPRECATED_ATTRIBUTE typedef __String String; CC_DEPRECATED_ATTRIBUTE typedef __RGBAProtocol RGBAProtocol; CC_DEPRECATED_ATTRIBUTE typedef __NodeRGBA NodeRGBA; CC_DEPRECATED_ATTRIBUTE typedef __LayerRGBA LayerRGBA; NS_CC_END #endif // __COCOS2D_CCDEPRECATED_H__ ================================================ FILE: cocos2d/cocos/2d/CCDirector.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ // cocos2d includes #include "CCDirector.h" // standard includes #include #include "ccFPSImages.h" #include "CCDrawingPrimitives.h" #include "CCNS.h" #include "CCScene.h" #include "CCArray.h" #include "CCScheduler.h" #include "ccMacros.h" #include "CCTransition.h" #include "CCTextureCache.h" #include "CCSpriteFrameCache.h" #include "CCAutoreleasePool.h" #include "platform/CCFileUtils.h" #include "CCApplication.h" #include "CCLabelBMFont.h" #include "CCActionManager.h" #include "CCAnimationCache.h" #include "CCTouch.h" #include "CCUserDefault.h" #include "ccGLStateCache.h" #include "CCShaderCache.h" #include "kazmath/kazmath.h" #include "kazmath/GL/matrix.h" #include "CCProfiling.h" #include "platform/CCImage.h" #include "CCEGLView.h" #include "CCConfiguration.h" #include "CCEventDispatcher.h" #include "CCEventCustom.h" #include "CCFontFreeType.h" #include "renderer/CCRenderer.h" #include "renderer/CCFrustum.h" #include "CCConsole.h" /** Position of the FPS Default: 0,0 (bottom-left corner) */ #ifndef CC_DIRECTOR_STATS_POSITION #define CC_DIRECTOR_STATS_POSITION Director::getInstance()->getVisibleOrigin() #endif using namespace std; unsigned int g_uNumberOfDraws = 0; NS_CC_BEGIN // XXX it should be a Director ivar. Move it there once support for multiple directors is added // singleton stuff static DisplayLinkDirector *s_SharedDirector = nullptr; #define kDefaultFPS 60 // 60 frames per second extern const char* cocos2dVersion(void); const char *Director::EVENT_PROJECTION_CHANGED = "director_projection_changed"; const char *Director::EVENT_AFTER_DRAW = "director_after_draw"; const char *Director::EVENT_AFTER_VISIT = "director_after_visit"; const char *Director::EVENT_AFTER_UPDATE = "director_after_udpate"; Director* Director::getInstance() { if (!s_SharedDirector) { s_SharedDirector = new DisplayLinkDirector(); s_SharedDirector->init(); } return s_SharedDirector; } Director::Director() { } bool Director::init(void) { setDefaultValues(); // scenes _runningScene = nullptr; _nextScene = nullptr; _notificationNode = nullptr; _scenesStack.reserve(15); // FPS _accumDt = 0.0f; _frameRate = 0.0f; _FPSLabel = nullptr; _SPFLabel = nullptr; _drawsLabel = nullptr; _totalFrames = _frames = 0; _FPS = new char[10]; _lastUpdate = new struct timeval; // paused ? _paused = false; // purge ? _purgeDirectorInNextLoop = false; _winSizeInPoints = Size::ZERO; _openGLView = nullptr; _cullingFrustum = new Frustum(); _contentScaleFactor = 1.0f; // scheduler _scheduler = new Scheduler(); // action manager _actionManager = new ActionManager(); _scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false); _eventDispatcher = new EventDispatcher(); _eventAfterDraw = new EventCustom(EVENT_AFTER_DRAW); _eventAfterDraw->setUserData(this); _eventAfterVisit = new EventCustom(EVENT_AFTER_VISIT); _eventAfterVisit->setUserData(this); _eventAfterUpdate = new EventCustom(EVENT_AFTER_UPDATE); _eventAfterUpdate->setUserData(this); _eventProjectionChanged = new EventCustom(EVENT_PROJECTION_CHANGED); _eventProjectionChanged->setUserData(this); //init TextureCache initTextureCache(); _renderer = new Renderer; _console = new Console; return true; } Director::~Director(void) { CCLOGINFO("deallocing Director: %p", this); CC_SAFE_RELEASE(_FPSLabel); CC_SAFE_RELEASE(_SPFLabel); CC_SAFE_RELEASE(_drawsLabel); CC_SAFE_RELEASE(_runningScene); CC_SAFE_RELEASE(_notificationNode); CC_SAFE_RELEASE(_scheduler); CC_SAFE_RELEASE(_actionManager); CC_SAFE_RELEASE(_eventDispatcher); delete _eventAfterUpdate; delete _eventAfterDraw; delete _eventAfterVisit; delete _eventProjectionChanged; delete _renderer; delete _console; // clean auto release pool PoolManager::destroyInstance(); // delete _lastUpdate CC_SAFE_DELETE(_lastUpdate); // delete fps string delete []_FPS; s_SharedDirector = nullptr; } void Director::setDefaultValues(void) { Configuration *conf = Configuration::getInstance(); // default FPS double fps = conf->getValue("cocos2d.x.fps", Value(kDefaultFPS)).asDouble(); _oldAnimationInterval = _animationInterval = 1.0 / fps; // Display FPS _displayStats = conf->getValue("cocos2d.x.display_fps", Value(false)).asBool(); // GL projection std::string projection = conf->getValue("cocos2d.x.gl.projection", Value("3d")).asString(); if (projection == "3d") _projection = Projection::_3D; else if (projection == "2d") _projection = Projection::_2D; else if (projection == "custom") _projection = Projection::CUSTOM; else CCASSERT(false, "Invalid projection value"); // Default pixel format for PNG images with alpha std::string pixel_format = conf->getValue("cocos2d.x.texture.pixel_format_for_png", Value("rgba8888")).asString(); if (pixel_format == "rgba8888") Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); else if(pixel_format == "rgba4444") Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); else if(pixel_format == "rgba5551") Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1); // PVR v2 has alpha premultiplied ? bool pvr_alpha_premultipled = conf->getValue("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", Value(false)).asBool(); Texture2D::PVRImagesHavePremultipliedAlpha(pvr_alpha_premultipled); } void Director::setGLDefaultValues() { // This method SHOULD be called only after openGLView_ was initialized CCASSERT(_openGLView, "opengl view should not be null"); setAlphaBlending(true); // XXX: Fix me, should enable/disable depth test according the depth format as cocos2d-iphone did // [self setDepthTest: view_.depthFormat]; setDepthTest(false); setProjection(_projection); // set other opengl default values glClearColor(0.0f, 0.0f, 0.0f, 1.0f); } // Draw the Scene void Director::drawScene() { // calculate "global" dt calculateDeltaTime(); if (_openGLView) { _openGLView->pollInputEvents(); } //tick before glClear: issue #533 if (! _paused) { _scheduler->update(_deltaTime); _eventDispatcher->dispatchEvent(_eventAfterUpdate); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* to avoid flickr, nextScene MUST be here: after tick and before draw. XXX: Which bug is this one. It seems that it can't be reproduced with v0.9 */ if (_nextScene) { setNextScene(); } kmGLPushMatrix(); //construct the frustum { kmMat4 view; kmMat4 projection; kmGLGetMatrix(KM_GL_PROJECTION, &projection); kmGLGetMatrix(KM_GL_MODELVIEW, &view); _cullingFrustum->setupFromMatrix(view, projection); } // draw the scene if (_runningScene) { _runningScene->visit(); _eventDispatcher->dispatchEvent(_eventAfterVisit); } // draw the notifications node if (_notificationNode) { _notificationNode->visit(); } if (_displayStats) { showStats(); } _renderer->render(); _eventDispatcher->dispatchEvent(_eventAfterDraw); kmGLPopMatrix(); _totalFrames++; // swap buffers if (_openGLView) { _openGLView->swapBuffers(); } if (_displayStats) { calculateMPF(); } } void Director::calculateDeltaTime() { struct timeval now; if (gettimeofday(&now, nullptr) != 0) { CCLOG("error in gettimeofday"); _deltaTime = 0; return; } // new delta time. Re-fixed issue #1277 if (_nextDeltaTimeZero) { _deltaTime = 0; _nextDeltaTimeZero = false; } else { _deltaTime = (now.tv_sec - _lastUpdate->tv_sec) + (now.tv_usec - _lastUpdate->tv_usec) / 1000000.0f; _deltaTime = MAX(0, _deltaTime); } #if COCOS2D_DEBUG // If we are debugging our code, prevent big delta time if (_deltaTime > 0.2f) { _deltaTime = 1 / 60.0f; } #endif *_lastUpdate = now; } float Director::getDeltaTime() const { return _deltaTime; } void Director::setOpenGLView(EGLView *openGLView) { CCASSERT(openGLView, "opengl view should not be null"); if (_openGLView != openGLView) { // Configuration. Gather GPU info Configuration *conf = Configuration::getInstance(); conf->gatherGPUInfo(); CCLOG("%s\n",conf->getInfo().c_str()); // EAGLView is not a Object delete _openGLView; // [openGLView_ release] _openGLView = openGLView; // set size _winSizeInPoints = _openGLView->getDesignResolutionSize(); createStatsLabel(); if (_openGLView) { setGLDefaultValues(); } _renderer->initGLView(); CHECK_GL_ERROR_DEBUG(); // _touchDispatcher->setDispatchEvents(true); } } TextureCache* Director::getTextureCache() const { return _textureCache; } void Director::initTextureCache() { #ifdef EMSCRIPTEN _textureCache = new TextureCacheEmscripten(); #else _textureCache = new TextureCache(); #endif // EMSCRIPTEN } void Director::destroyTextureCache() { if (_textureCache) { _textureCache->waitForQuit(); CC_SAFE_RELEASE_NULL(_textureCache); } } void Director::setViewport() { if (_openGLView) { _openGLView->setViewPortInPoints(0, 0, _winSizeInPoints.width, _winSizeInPoints.height); } } void Director::setNextDeltaTimeZero(bool bNextDeltaTimeZero) { _nextDeltaTimeZero = bNextDeltaTimeZero; } void Director::setProjection(Projection projection) { Size size = _winSizeInPoints; setViewport(); switch (projection) { case Projection::_2D: kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); kmMat4 orthoMatrix; kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1024, 1024); kmGLMultMatrix(&orthoMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); break; case Projection::_3D: { float zeye = this->getZEye(); kmMat4 matrixPerspective, matrixLookup; kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); // issue #1334 kmMat4PerspectiveProjection(&matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2); // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); kmGLMultMatrix(&matrixPerspective); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); kmVec3 eye, center, up; kmVec3Fill(&eye, size.width/2, size.height/2, zeye); kmVec3Fill(¢er, size.width/2, size.height/2, 0.0f); kmVec3Fill(&up, 0.0f, 1.0f, 0.0f); kmMat4LookAt(&matrixLookup, &eye, ¢er, &up); kmGLMultMatrix(&matrixLookup); break; } case Projection::CUSTOM: // Projection Delegate is no longer needed // since the event "PROJECTION CHANGED" is emitted break; default: CCLOG("cocos2d: Director: unrecognized projection"); break; } _projection = projection; GL::setProjectionMatrixDirty(); _eventDispatcher->dispatchEvent(_eventProjectionChanged); } void Director::purgeCachedData(void) { LabelBMFont::purgeCachedData(); if (s_SharedDirector->getOpenGLView()) { SpriteFrameCache::getInstance()->removeUnusedSpriteFrames(); _textureCache->removeUnusedTextures(); } FileUtils::getInstance()->purgeCachedEntries(); } float Director::getZEye(void) const { return (_winSizeInPoints.height / 1.1566f); } void Director::setAlphaBlending(bool on) { if (on) { GL::blendFunc(CC_BLEND_SRC, CC_BLEND_DST); } else { GL::blendFunc(GL_ONE, GL_ZERO); } CHECK_GL_ERROR_DEBUG(); } void Director::setDepthTest(bool on) { if (on) { glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } else { glDisable(GL_DEPTH_TEST); } CHECK_GL_ERROR_DEBUG(); } static void GLToClipTransform(kmMat4 *transformOut) { kmMat4 projection; kmGLGetMatrix(KM_GL_PROJECTION, &projection); kmMat4 modelview; kmGLGetMatrix(KM_GL_MODELVIEW, &modelview); kmMat4Multiply(transformOut, &projection, &modelview); } Point Director::convertToGL(const Point& uiPoint) { kmMat4 transform; GLToClipTransform(&transform); kmMat4 transformInv; kmMat4Inverse(&transformInv, &transform); // Calculate z=0 using -> transform*[0, 0, 0, 1]/w kmScalar zClip = transform.mat[14]/transform.mat[15]; Size glSize = _openGLView->getDesignResolutionSize(); kmVec3 clipCoord = {2.0f*uiPoint.x/glSize.width - 1.0f, 1.0f - 2.0f*uiPoint.y/glSize.height, zClip}; kmVec3 glCoord; kmVec3TransformCoord(&glCoord, &clipCoord, &transformInv); return Point(glCoord.x, glCoord.y); } Point Director::convertToUI(const Point& glPoint) { kmMat4 transform; GLToClipTransform(&transform); kmVec3 clipCoord; // Need to calculate the zero depth from the transform. kmVec3 glCoord = {glPoint.x, glPoint.y, 0.0}; kmVec3TransformCoord(&clipCoord, &glCoord, &transform); Size glSize = _openGLView->getDesignResolutionSize(); return Point(glSize.width*(clipCoord.x*0.5 + 0.5), glSize.height*(-clipCoord.y*0.5 + 0.5)); } const Size& Director::getWinSize(void) const { return _winSizeInPoints; } Size Director::getWinSizeInPixels() const { return Size(_winSizeInPoints.width * _contentScaleFactor, _winSizeInPoints.height * _contentScaleFactor); } Size Director::getVisibleSize() const { if (_openGLView) { return _openGLView->getVisibleSize(); } else { return Size::ZERO; } } Point Director::getVisibleOrigin() const { if (_openGLView) { return _openGLView->getVisibleOrigin(); } else { return Point::ZERO; } } // scene management void Director::runWithScene(Scene *scene) { CCASSERT(scene != nullptr, "This command can only be used to start the Director. There is already a scene present."); CCASSERT(_runningScene == nullptr, "_runningScene should be null"); pushScene(scene); startAnimation(); } void Director::replaceScene(Scene *scene) { CCASSERT(_runningScene, "Use runWithScene: instead to start the director"); CCASSERT(scene != nullptr, "the scene should not be null"); ssize_t index = _scenesStack.size(); _sendCleanupToScene = true; _scenesStack.replace(index - 1, scene); _nextScene = scene; } void Director::pushScene(Scene *scene) { CCASSERT(scene, "the scene should not null"); _sendCleanupToScene = false; _scenesStack.pushBack(scene); _nextScene = scene; } void Director::popScene(void) { CCASSERT(_runningScene != nullptr, "running scene should not null"); _scenesStack.popBack(); ssize_t c = _scenesStack.size(); if (c == 0) { end(); } else { _sendCleanupToScene = true; _nextScene = _scenesStack.at(c - 1); } } void Director::popToRootScene(void) { popToSceneStackLevel(1); } void Director::popToSceneStackLevel(int level) { CCASSERT(_runningScene != nullptr, "A running Scene is needed"); ssize_t c = _scenesStack.size(); // level 0? -> end if (level == 0) { end(); return; } // current level or lower -> nothing if (level >= c) return; // pop stack until reaching desired level while (c > level) { auto current = _scenesStack.back(); if (current->isRunning()) { current->onExitTransitionDidStart(); current->onExit(); } current->cleanup(); _scenesStack.popBack(); --c; } _nextScene = _scenesStack.back(); _sendCleanupToScene = false; } void Director::end() { _purgeDirectorInNextLoop = true; } void Director::purgeDirector() { // cleanup scheduler getScheduler()->unscheduleAll(); // don't release the event handlers // They are needed in case the director is run again // _touchDispatcher->removeAllDelegates(); if (_runningScene) { _runningScene->onExitTransitionDidStart(); _runningScene->onExit(); _runningScene->cleanup(); _runningScene->release(); } _runningScene = nullptr; _nextScene = nullptr; // remove all objects, but don't release it. // runWithScene might be executed after 'end'. _scenesStack.clear(); stopAnimation(); CC_SAFE_RELEASE_NULL(_FPSLabel); CC_SAFE_RELEASE_NULL(_SPFLabel); CC_SAFE_RELEASE_NULL(_drawsLabel); CC_SAFE_DELETE(_cullingFrustum); // purge bitmap cache LabelBMFont::purgeCachedData(); FontFreeType::shutdownFreeType(); // purge all managed caches DrawPrimitives::free(); AnimationCache::destroyInstance(); SpriteFrameCache::destroyInstance(); ShaderCache::destroyInstance(); FileUtils::destroyInstance(); Configuration::destroyInstance(); // cocos2d-x specific data structures UserDefault::destroyInstance(); GL::invalidateStateCache(); destroyTextureCache(); CHECK_GL_ERROR_DEBUG(); // OpenGL view if (_openGLView) { _openGLView->end(); _openGLView = nullptr; } // delete Director release(); } void Director::setNextScene() { bool runningIsTransition = dynamic_cast(_runningScene) != nullptr; bool newIsTransition = dynamic_cast(_nextScene) != nullptr; // If it is not a transition, call onExit/cleanup if (! newIsTransition) { if (_runningScene) { _runningScene->onExitTransitionDidStart(); _runningScene->onExit(); } // issue #709. the root node (scene) should receive the cleanup message too // otherwise it might be leaked. if (_sendCleanupToScene && _runningScene) { _runningScene->cleanup(); } } if (_runningScene) { _runningScene->release(); } _runningScene = _nextScene; _nextScene->retain(); _nextScene = nullptr; if ((! runningIsTransition) && _runningScene) { _runningScene->onEnter(); _runningScene->onEnterTransitionDidFinish(); } } void Director::pause() { if (_paused) { return; } _oldAnimationInterval = _animationInterval; // when paused, don't consume CPU setAnimationInterval(1 / 4.0); _paused = true; } void Director::resume() { if (! _paused) { return; } setAnimationInterval(_oldAnimationInterval); _paused = false; _deltaTime = 0; // fix issue #3509, skip one fps to avoid incorrect time calculation. setNextDeltaTimeZero(true); } // display the FPS using a LabelAtlas // updates the FPS every frame void Director::showStats() { ++_frames; _accumDt += _deltaTime; if (_displayStats) { if (_FPSLabel && _SPFLabel && _drawsLabel) { if (_accumDt > CC_DIRECTOR_STATS_INTERVAL) { sprintf(_FPS, "%.3f", _secondsPerFrame); _SPFLabel->setString(_FPS); _frameRate = _frames / _accumDt; _frames = 0; _accumDt = 0; sprintf(_FPS, "%.1f", _frameRate); _FPSLabel->setString(_FPS); sprintf(_FPS, "%4lu", (unsigned long)g_uNumberOfDraws); _drawsLabel->setString(_FPS); } _drawsLabel->visit(); _FPSLabel->visit(); _SPFLabel->visit(); } } g_uNumberOfDraws = 0; } void Director::calculateMPF() { struct timeval now; gettimeofday(&now, nullptr); _secondsPerFrame = (now.tv_sec - _lastUpdate->tv_sec) + (now.tv_usec - _lastUpdate->tv_usec) / 1000000.0f; } // returns the FPS image data pointer and len void Director::getFPSImageData(unsigned char** datapointer, ssize_t* length) { // XXX fixed me if it should be used *datapointer = cc_fps_images_png; *length = cc_fps_images_len(); } void Director::createStatsLabel() { Texture2D *texture = nullptr; if (_FPSLabel && _SPFLabel) { CC_SAFE_RELEASE_NULL(_FPSLabel); CC_SAFE_RELEASE_NULL(_SPFLabel); CC_SAFE_RELEASE_NULL(_drawsLabel); _textureCache->removeTextureForKey("/cc_fps_images"); FileUtils::getInstance()->purgeCachedEntries(); } Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); unsigned char *data = nullptr; ssize_t dataLength = 0; getFPSImageData(&data, &dataLength); Image* image = new Image(); bool isOK = image->initWithImageData(data, dataLength); if (! isOK) { CCLOGERROR("%s", "Fails: init fps_images"); return; } texture = _textureCache->addImage(image, "/cc_fps_images"); CC_SAFE_RELEASE(image); /* We want to use an image which is stored in the file named ccFPSImage.c for any design resolutions and all resource resolutions. To achieve this, Firstly, we need to ignore 'contentScaleFactor' in 'AtlasNode' and 'LabelAtlas'. So I added a new method called 'setIgnoreContentScaleFactor' for 'AtlasNode', this is not exposed to game developers, it's only used for displaying FPS now. Secondly, the size of this image is 480*320, to display the FPS label with correct size, a factor of design resolution ratio of 480x320 is also needed. */ float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f; _FPSLabel = LabelAtlas::create(); _FPSLabel->retain(); _FPSLabel->setIgnoreContentScaleFactor(true); _FPSLabel->initWithString("00.0", texture, 12, 32 , '.'); _FPSLabel->setScale(factor); _SPFLabel = LabelAtlas::create(); _SPFLabel->retain(); _SPFLabel->setIgnoreContentScaleFactor(true); _SPFLabel->initWithString("0.000", texture, 12, 32, '.'); _SPFLabel->setScale(factor); _drawsLabel = LabelAtlas::create(); _drawsLabel->retain(); _drawsLabel->setIgnoreContentScaleFactor(true); _drawsLabel->initWithString("000", texture, 12, 32, '.'); _drawsLabel->setScale(factor); Texture2D::setDefaultAlphaPixelFormat(currentFormat); _drawsLabel->setPosition(Point(0, 34*factor) + CC_DIRECTOR_STATS_POSITION); _SPFLabel->setPosition(Point(0, 17*factor) + CC_DIRECTOR_STATS_POSITION); _FPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION); } void Director::setContentScaleFactor(float scaleFactor) { if (scaleFactor != _contentScaleFactor) { _contentScaleFactor = scaleFactor; createStatsLabel(); } } void Director::setNotificationNode(Node *node) { CC_SAFE_RELEASE(_notificationNode); _notificationNode = node; CC_SAFE_RETAIN(_notificationNode); } void Director::setScheduler(Scheduler* scheduler) { if (_scheduler != scheduler) { CC_SAFE_RETAIN(scheduler); CC_SAFE_RELEASE(_scheduler); _scheduler = scheduler; } } void Director::setActionManager(ActionManager* actionManager) { if (_actionManager != actionManager) { CC_SAFE_RETAIN(actionManager); CC_SAFE_RELEASE(_actionManager); _actionManager = actionManager; } } void Director::setEventDispatcher(EventDispatcher* dispatcher) { if (_eventDispatcher != dispatcher) { CC_SAFE_RETAIN(dispatcher); CC_SAFE_RELEASE(_eventDispatcher); _eventDispatcher = dispatcher; } } /*************************************************** * implementation of DisplayLinkDirector **************************************************/ // should we implement 4 types of director ?? // I think DisplayLinkDirector is enough // so we now only support DisplayLinkDirector void DisplayLinkDirector::startAnimation() { if (gettimeofday(_lastUpdate, nullptr) != 0) { CCLOG("cocos2d: DisplayLinkDirector: Error on gettimeofday"); } _invalid = false; Application::getInstance()->setAnimationInterval(_animationInterval); } void DisplayLinkDirector::mainLoop() { if (_purgeDirectorInNextLoop) { _purgeDirectorInNextLoop = false; purgeDirector(); } else if (! _invalid) { drawScene(); // release the objects PoolManager::getInstance()->getCurrentPool()->clear(); } } void DisplayLinkDirector::stopAnimation() { _invalid = true; } void DisplayLinkDirector::setAnimationInterval(double interval) { _animationInterval = interval; if (! _invalid) { stopAnimation(); startAnimation(); } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCDirector.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDIRECTOR_H__ #define __CCDIRECTOR_H__ #include "CCPlatformMacros.h" #include "CCObject.h" #include "ccTypes.h" #include "CCGeometry.h" #include "CCVector.h" #include "CCGL.h" #include "kazmath/mat4.h" #include "CCLabelAtlas.h" NS_CC_BEGIN /** * @addtogroup base_nodes * @{ */ /* Forward declarations. */ class LabelAtlas; class Scene; class EGLView; class DirectorDelegate; class Node; class Scheduler; class ActionManager; class EventDispatcher; class EventCustom; class EventListenerCustom; class TextureCache; class Frustum; class Renderer; class Console; /** @brief Class that creates and handles the main Window and manages how and when to execute the Scenes. The Director is also responsible for: - initializing the OpenGL context - setting the OpenGL pixel format (default on is RGB565) - setting the OpenGL buffer depth (default one is 0-bit) - setting the projection (default one is 3D) - setting the orientation (default one is Portrait) Since the Director is a singleton, the standard way to use it is by calling: _ Director::getInstance()->methodName(); The Director also sets the default OpenGL context: - GL_TEXTURE_2D is enabled - GL_VERTEX_ARRAY is enabled - GL_COLOR_ARRAY is enabled - GL_TEXTURE_COORD_ARRAY is enabled */ class CC_DLL Director : public Object { public: static const char *EVENT_PROJECTION_CHANGED; static const char* EVENT_AFTER_UPDATE; static const char* EVENT_AFTER_VISIT; static const char* EVENT_AFTER_DRAW; /** @typedef ccDirectorProjection Possible OpenGL projections used by director */ enum class Projection { /// sets a 2D projection (orthogonal projection) _2D, /// sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500. _3D, /// it calls "updateProjection" on the projection delegate. CUSTOM, /// Default projection is 3D projection DEFAULT = _3D, }; /** returns a shared instance of the director */ static Director* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static Director* sharedDirector() { return Director::getInstance(); } /** * @js ctor */ Director(void); /** * @js NA * @lua NA */ virtual ~Director(void); virtual bool init(void); // attribute /** Get current running Scene. Director can only run one Scene at a time */ inline Scene* getRunningScene() { return _runningScene; } /** Get the FPS value */ inline double getAnimationInterval() { return _animationInterval; } /** Set the FPS value. */ virtual void setAnimationInterval(double interval) = 0; /** Whether or not to display the FPS on the bottom-left corner */ inline bool isDisplayStats() { return _displayStats; } /** Display the FPS on the bottom-left corner */ inline void setDisplayStats(bool displayStats) { _displayStats = displayStats; } /** seconds per frame */ inline float getSecondsPerFrame() { return _secondsPerFrame; } /** Get the EGLView, where everything is rendered * @js NA * @lua NA */ inline EGLView* getOpenGLView() { return _openGLView; } void setOpenGLView(EGLView *openGLView); TextureCache* getTextureCache() const; inline bool isNextDeltaTimeZero() { return _nextDeltaTimeZero; } void setNextDeltaTimeZero(bool nextDeltaTimeZero); /** Whether or not the Director is paused */ inline bool isPaused() { return _paused; } /** How many frames were called since the director started */ inline unsigned int getTotalFrames() { return _totalFrames; } /** Sets an OpenGL projection @since v0.8.2 * @js NA * @lua NA */ inline Projection getProjection() { return _projection; } void setProjection(Projection projection); /** Sets the glViewport*/ void setViewport(); /** How many frames were called since the director started */ /** Whether or not the replaced scene will receive the cleanup message. If the new scene is pushed, then the old scene won't receive the "cleanup" message. If the new scene replaces the old one, the it will receive the "cleanup" message. @since v0.99.0 */ inline bool isSendCleanupToScene() { return _sendCleanupToScene; } /** This object will be visited after the main scene is visited. This object MUST implement the "visit" selector. Useful to hook a notification object, like Notifications (http://github.com/manucorporat/CCNotifications) @since v0.99.5 */ Node* getNotificationNode() const { return _notificationNode; } void setNotificationNode(Node *node); // window size /** returns the size of the OpenGL view in points. */ const Size& getWinSize() const; /** returns the size of the OpenGL view in pixels. */ Size getWinSizeInPixels() const; /** returns visible size of the OpenGL view in points. * the value is equal to getWinSize if don't invoke * EGLView::setDesignResolutionSize() */ Size getVisibleSize() const; /** returns visible origin of the OpenGL view in points. */ Point getVisibleOrigin() const; /** converts a UIKit coordinate to an OpenGL coordinate Useful to convert (multi) touch coordinates to the current layout (portrait or landscape) */ Point convertToGL(const Point& point); /** converts an OpenGL coordinate to a UIKit coordinate Useful to convert node points to window points for calls such as glScissor */ Point convertToUI(const Point& point); /// XXX: missing description float getZEye() const; // Scene Management /** Enters the Director's main loop with the given Scene. * Call it to run only your FIRST scene. * Don't call it if there is already a running scene. * * It will call pushScene: and then it will call startAnimation */ void runWithScene(Scene *scene); /** Suspends the execution of the running scene, pushing it on the stack of suspended scenes. * The new scene will be executed. * Try to avoid big stacks of pushed scenes to reduce memory allocation. * ONLY call it if there is a running scene. */ void pushScene(Scene *scene); /** Pops out a scene from the stack. * This scene will replace the running one. * The running scene will be deleted. If there are no more scenes in the stack the execution is terminated. * ONLY call it if there is a running scene. */ void popScene(); /** Pops out all scenes from the stack until the root scene in the queue. * This scene will replace the running one. * Internally it will call `popToSceneStackLevel(1)` */ void popToRootScene(); /** Pops out all scenes from the stack until it reaches `level`. If level is 0, it will end the director. If level is 1, it will pop all scenes until it reaches to root scene. If level is <= than the current stack level, it won't do anything. */ void popToSceneStackLevel(int level); /** Replaces the running scene with a new one. The running scene is terminated. * ONLY call it if there is a running scene. */ void replaceScene(Scene *scene); /** Ends the execution, releases the running scene. It doesn't remove the OpenGL view from its parent. You have to do it manually. * @lua endToLua */ void end(); /** Pauses the running scene. The running scene will be _drawed_ but all scheduled timers will be paused While paused, the draw rate will be 4 FPS to reduce CPU consumption */ void pause(); /** Resumes the paused scene The scheduled timers will be activated again. The "delta time" will be 0 (as if the game wasn't paused) */ void resume(); /** Stops the animation. Nothing will be drawn. The main loop won't be triggered anymore. If you don't want to pause your animation call [pause] instead. */ virtual void stopAnimation() = 0; /** The main loop is triggered again. Call this function only if [stopAnimation] was called earlier @warning Don't call this function to start the main loop. To run the main loop call runWithScene */ virtual void startAnimation() = 0; /** Draw the scene. This method is called every frame. Don't call it manually. */ void drawScene(); // Memory Helper /** Removes all cocos2d cached data. It will purge the TextureCache, SpriteFrameCache, LabelBMFont cache @since v0.99.3 */ void purgeCachedData(); /** sets the default values based on the Configuration info */ void setDefaultValues(); // OpenGL Helper /** sets the OpenGL default values */ void setGLDefaultValues(); /** enables/disables OpenGL alpha blending */ void setAlphaBlending(bool on); /** enables/disables OpenGL depth test */ void setDepthTest(bool on); virtual void mainLoop() = 0; /** The size in pixels of the surface. It could be different than the screen size. High-res devices might have a higher surface size than the screen size. Only available when compiled using SDK >= 4.0. @since v0.99.4 */ void setContentScaleFactor(float scaleFactor); float getContentScaleFactor() const { return _contentScaleFactor; } /** Get the Culling Frustum */ Frustum* getFrustum() const { return _cullingFrustum; } /** Gets the Scheduler associated with this director @since v2.0 */ Scheduler* getScheduler() const { return _scheduler; } /** Sets the Scheduler associated with this director @since v2.0 */ void setScheduler(Scheduler* scheduler); /** Gets the ActionManager associated with this director @since v2.0 */ ActionManager* getActionManager() const { return _actionManager; } /** Sets the ActionManager associated with this director @since v2.0 */ void setActionManager(ActionManager* actionManager); /** Gets the EventDispatcher associated with this director @since v3.0 */ EventDispatcher* getEventDispatcher() const { return _eventDispatcher; } /** Sets the EventDispatcher associated with this director @since v3.0 */ void setEventDispatcher(EventDispatcher* dispatcher); /** Returns the Renderer @since v3.0 */ Renderer* getRenderer() const { return _renderer; } /** Returns the Console @since v3.0 */ Console* getConsole() const { return _console; } /* Gets delta time since last tick to main loop */ float getDeltaTime() const; /** * get Frame Rate */ float getFrameRate() const { return _frameRate; } protected: void purgeDirector(); bool _purgeDirectorInNextLoop; // this flag will be set to true in end() void setNextScene(); void showStats(); void createStatsLabel(); void calculateMPF(); void getFPSImageData(unsigned char** datapointer, ssize_t* length); /** calculates delta time since last time it was called */ void calculateDeltaTime(); //textureCache creation or release void initTextureCache(); void destroyTextureCache(); /** Scheduler associated with this director @since v2.0 */ Scheduler *_scheduler; /** ActionManager associated with this director @since v2.0 */ ActionManager *_actionManager; /** EventDispatcher associated with this director @since v3.0 */ EventDispatcher* _eventDispatcher; EventCustom *_eventProjectionChanged, *_eventAfterDraw, *_eventAfterVisit, *_eventAfterUpdate; /* delta time since last tick to main loop */ float _deltaTime; /* The EGLView, where everything is rendered */ EGLView *_openGLView; //texture cache belongs to this director TextureCache *_textureCache; double _animationInterval; double _oldAnimationInterval; /* landscape mode ? */ bool _landscape; bool _displayStats; float _accumDt; float _frameRate; LabelAtlas *_FPSLabel; LabelAtlas *_SPFLabel; LabelAtlas *_drawsLabel; /** Whether or not the Director is paused */ bool _paused; /* How many frames were called since the director started */ unsigned int _totalFrames; unsigned int _frames; float _secondsPerFrame; Frustum *_cullingFrustum; /* The running scene */ Scene *_runningScene; /* will be the next 'runningScene' in the next frame nextScene is a weak reference. */ Scene *_nextScene; /* If true, then "old" scene will receive the cleanup message */ bool _sendCleanupToScene; /* scheduled scenes */ Vector _scenesStack; /* last time the main loop was updated */ struct timeval *_lastUpdate; /* whether or not the next delta time will be zero */ bool _nextDeltaTimeZero; /* projection used */ Projection _projection; /* window size in points */ Size _winSizeInPoints; /* content scale factor */ float _contentScaleFactor; /* store the fps string */ char *_FPS; /* This object will be visited after the scene. Useful to hook a notification node */ Node *_notificationNode; /* Renderer for the Director */ Renderer *_renderer; /* Console for the director */ Console *_console; // EGLViewProtocol will recreate stats labels to fit visible rect friend class EGLViewProtocol; }; /** @brief DisplayLinkDirector is a Director that synchronizes timers with the refresh rate of the display. Features and Limitations: - Scheduled timers & drawing are synchronizes with the refresh rate of the display - Only supports animation intervals of 1/60 1/30 & 1/15 @since v0.8.2 */ class DisplayLinkDirector : public Director { public: DisplayLinkDirector() : _invalid(false) {} // // Overrides // virtual void mainLoop() override; virtual void setAnimationInterval(double value) override; virtual void startAnimation() override; virtual void stopAnimation() override; protected: bool _invalid; }; // end of base_node group /// @} NS_CC_END #endif // __CCDIRECTOR_H__ ================================================ FILE: cocos2d/cocos/2d/CCDrawNode.cpp ================================================ /* Copyright (c) 2012 Scott Lembcke and Howling Moon Software * Copyright (c) 2012 cocos2d-x.org * Copyright (c) 2013-2014 Chukong Technologies Inc. * * 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 "CCDrawNode.h" #include "CCShaderCache.h" #include "CCGL.h" #include "CCEventType.h" #include "CCConfiguration.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCRenderer.h" #include "CCDirector.h" #include "CCEventListenerCustom.h" #include "CCEventDispatcher.h" NS_CC_BEGIN // Vertex2F == CGPoint in 32-bits, but not in 64-bits (OS X) // that's why the "v2f" functions are needed static Vertex2F v2fzero(0.0f,0.0f); static inline Vertex2F v2f(float x, float y) { Vertex2F ret(x, y); return ret; } static inline Vertex2F v2fadd(const Vertex2F &v0, const Vertex2F &v1) { return v2f(v0.x+v1.x, v0.y+v1.y); } static inline Vertex2F v2fsub(const Vertex2F &v0, const Vertex2F &v1) { return v2f(v0.x-v1.x, v0.y-v1.y); } static inline Vertex2F v2fmult(const Vertex2F &v, float s) { return v2f(v.x * s, v.y * s); } static inline Vertex2F v2fperp(const Vertex2F &p0) { return v2f(-p0.y, p0.x); } static inline Vertex2F v2fneg(const Vertex2F &p0) { return v2f(-p0.x, - p0.y); } static inline float v2fdot(const Vertex2F &p0, const Vertex2F &p1) { return p0.x * p1.x + p0.y * p1.y; } static inline Vertex2F v2fforangle(float _a_) { return v2f(cosf(_a_), sinf(_a_)); } static inline Vertex2F v2fnormalize(const Vertex2F &p) { Point r = Point(p.x, p.y).normalize(); return v2f(r.x, r.y); } static inline Vertex2F __v2f(const Point &v) { //#ifdef __LP64__ return v2f(v.x, v.y); // #else // return * ((Vertex2F*) &v); // #endif } static inline Tex2F __t(const Vertex2F &v) { return *(Tex2F*)&v; } // implementation of DrawNode DrawNode::DrawNode() : _vao(0) , _vbo(0) , _bufferCapacity(0) , _bufferCount(0) , _buffer(nullptr) , _dirty(false) { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; } DrawNode::~DrawNode() { free(_buffer); _buffer = nullptr; glDeleteBuffers(1, &_vbo); _vbo = 0; if (Configuration::getInstance()->supportsShareableVAO()) { glDeleteVertexArrays(1, &_vao); GL::bindVAO(0); _vao = 0; } } DrawNode* DrawNode::create() { DrawNode* ret = new DrawNode(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } void DrawNode::ensureCapacity(int count) { CCASSERT(count>=0, "capacity must be >= 0"); if(_bufferCount + count > _bufferCapacity) { _bufferCapacity += MAX(_bufferCapacity, count); _buffer = (V2F_C4B_T2F*)realloc(_buffer, _bufferCapacity*sizeof(V2F_C4B_T2F)); } } bool DrawNode::init() { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR)); ensureCapacity(512); if (Configuration::getInstance()->supportsShareableVAO()) { glGenVertexArrays(1, &_vao); GL::bindVAO(_vao); } glGenBuffers(1, &_vbo); glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); glBindBuffer(GL_ARRAY_BUFFER, 0); if (Configuration::getInstance()->supportsShareableVAO()) { GL::bindVAO(0); } CHECK_GL_ERROR_DEBUG(); _dirty = true; #if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ /** listen the event that coming to foreground on Android */ this->init(); }); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); #endif return true; } void DrawNode::render() { if (_dirty) { glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW); _dirty = false; } if (Configuration::getInstance()->supportsShareableVAO()) { GL::bindVAO(_vao); } else { GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); glBindBuffer(GL_ARRAY_BUFFER, _vbo); // vertex glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); // color glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); // texcood glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); } glDrawArrays(GL_TRIANGLES, 0, _bufferCount); glBindBuffer(GL_ARRAY_BUFFER, 0); CC_INCREMENT_GL_DRAWS(1); CHECK_GL_ERROR_DEBUG(); } void DrawNode::draw() { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } void DrawNode::onDraw() { CC_NODE_DRAW_SETUP(); GL::blendFunc(_blendFunc.src, _blendFunc.dst); render(); } void DrawNode::drawDot(const Point &pos, float radius, const Color4F &color) { unsigned int vertex_count = 2*3; ensureCapacity(vertex_count); V2F_C4B_T2F a = {Vertex2F(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) }; V2F_C4B_T2F b = {Vertex2F(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) }; V2F_C4B_T2F c = {Vertex2F(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) }; V2F_C4B_T2F d = {Vertex2F(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) }; V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle triangle0 = {a, b, c}; V2F_C4B_T2F_Triangle triangle1 = {a, c, d}; triangles[0] = triangle0; triangles[1] = triangle1; _bufferCount += vertex_count; _dirty = true; } void DrawNode::drawSegment(const Point &from, const Point &to, float radius, const Color4F &color) { unsigned int vertex_count = 6*3; ensureCapacity(vertex_count); Vertex2F a = __v2f(from); Vertex2F b = __v2f(to); Vertex2F n = v2fnormalize(v2fperp(v2fsub(b, a))); Vertex2F t = v2fperp(n); Vertex2F nw = v2fmult(n, radius); Vertex2F tw = v2fmult(t, radius); Vertex2F v0 = v2fsub(b, v2fadd(nw, tw)); Vertex2F v1 = v2fadd(b, v2fsub(nw, tw)); Vertex2F v2 = v2fsub(b, nw); Vertex2F v3 = v2fadd(b, nw); Vertex2F v4 = v2fsub(a, nw); Vertex2F v5 = v2fadd(a, nw); Vertex2F v6 = v2fsub(a, v2fsub(nw, tw)); Vertex2F v7 = v2fadd(a, v2fadd(nw, tw)); V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle triangles0 = { {v0, Color4B(color), __t(v2fneg(v2fadd(n, t)))}, {v1, Color4B(color), __t(v2fsub(n, t))}, {v2, Color4B(color), __t(v2fneg(n))}, }; triangles[0] = triangles0; V2F_C4B_T2F_Triangle triangles1 = { {v3, Color4B(color), __t(n)}, {v1, Color4B(color), __t(v2fsub(n, t))}, {v2, Color4B(color), __t(v2fneg(n))}, }; triangles[1] = triangles1; V2F_C4B_T2F_Triangle triangles2 = { {v3, Color4B(color), __t(n)}, {v4, Color4B(color), __t(v2fneg(n))}, {v2, Color4B(color), __t(v2fneg(n))}, }; triangles[2] = triangles2; V2F_C4B_T2F_Triangle triangles3 = { {v3, Color4B(color), __t(n)}, {v4, Color4B(color), __t(v2fneg(n))}, {v5, Color4B(color), __t(n) }, }; triangles[3] = triangles3; V2F_C4B_T2F_Triangle triangles4 = { {v6, Color4B(color), __t(v2fsub(t, n))}, {v4, Color4B(color), __t(v2fneg(n)) }, {v5, Color4B(color), __t(n)}, }; triangles[4] = triangles4; V2F_C4B_T2F_Triangle triangles5 = { {v6, Color4B(color), __t(v2fsub(t, n))}, {v7, Color4B(color), __t(v2fadd(n, t))}, {v5, Color4B(color), __t(n)}, }; triangles[5] = triangles5; _bufferCount += vertex_count; _dirty = true; } void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor) { CCASSERT(count >= 0, "invalid count value"); struct ExtrudeVerts {Vertex2F offset, n;}; struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count); memset(extrude, 0, sizeof(struct ExtrudeVerts)*count); for (int i = 0; i < count; i++) { Vertex2F v0 = __v2f(verts[(i-1+count)%count]); Vertex2F v1 = __v2f(verts[i]); Vertex2F v2 = __v2f(verts[(i+1)%count]); Vertex2F n1 = v2fnormalize(v2fperp(v2fsub(v1, v0))); Vertex2F n2 = v2fnormalize(v2fperp(v2fsub(v2, v1))); Vertex2F offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0)); struct ExtrudeVerts tmp = {offset, n2}; extrude[i] = tmp; } bool outline = (borderColor.a > 0.0 && borderWidth > 0.0); auto triangle_count = 3*count - 2; auto vertex_count = 3*triangle_count; ensureCapacity(vertex_count); V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle *cursor = triangles; float inset = (outline == false ? 0.5 : 0.0); for (int i = 0; i < count-2; i++) { Vertex2F v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset)); Vertex2F v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset)); Vertex2F v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset)); V2F_C4B_T2F_Triangle tmp = { {v0, Color4B(fillColor), __t(v2fzero)}, {v1, Color4B(fillColor), __t(v2fzero)}, {v2, Color4B(fillColor), __t(v2fzero)}, }; *cursor++ = tmp; } for(int i = 0; i < count; i++) { int j = (i+1)%count; Vertex2F v0 = __v2f(verts[i]); Vertex2F v1 = __v2f(verts[j]); Vertex2F n0 = extrude[i].n; Vertex2F offset0 = extrude[i].offset; Vertex2F offset1 = extrude[j].offset; if(outline) { Vertex2F inner0 = v2fsub(v0, v2fmult(offset0, borderWidth)); Vertex2F inner1 = v2fsub(v1, v2fmult(offset1, borderWidth)); Vertex2F outer0 = v2fadd(v0, v2fmult(offset0, borderWidth)); Vertex2F outer1 = v2fadd(v1, v2fmult(offset1, borderWidth)); V2F_C4B_T2F_Triangle tmp1 = { {inner0, Color4B(borderColor), __t(v2fneg(n0))}, {inner1, Color4B(borderColor), __t(v2fneg(n0))}, {outer1, Color4B(borderColor), __t(n0)} }; *cursor++ = tmp1; V2F_C4B_T2F_Triangle tmp2 = { {inner0, Color4B(borderColor), __t(v2fneg(n0))}, {outer0, Color4B(borderColor), __t(n0)}, {outer1, Color4B(borderColor), __t(n0)} }; *cursor++ = tmp2; } else { Vertex2F inner0 = v2fsub(v0, v2fmult(offset0, 0.5)); Vertex2F inner1 = v2fsub(v1, v2fmult(offset1, 0.5)); Vertex2F outer0 = v2fadd(v0, v2fmult(offset0, 0.5)); Vertex2F outer1 = v2fadd(v1, v2fmult(offset1, 0.5)); V2F_C4B_T2F_Triangle tmp1 = { {inner0, Color4B(fillColor), __t(v2fzero)}, {inner1, Color4B(fillColor), __t(v2fzero)}, {outer1, Color4B(fillColor), __t(n0)} }; *cursor++ = tmp1; V2F_C4B_T2F_Triangle tmp2 = { {inner0, Color4B(fillColor), __t(v2fzero)}, {outer0, Color4B(fillColor), __t(n0)}, {outer1, Color4B(fillColor), __t(n0)} }; *cursor++ = tmp2; } } _bufferCount += vertex_count; _dirty = true; free(extrude); } void DrawNode::drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color) { unsigned int vertex_count = 2*3; ensureCapacity(vertex_count); Color4B col = Color4B(color); V2F_C4B_T2F a = {Vertex2F(p1.x, p1.y), col, Tex2F(0.0, 0.0) }; V2F_C4B_T2F b = {Vertex2F(p2.x, p2.y), col, Tex2F(0.0, 0.0) }; V2F_C4B_T2F c = {Vertex2F(p3.x, p3.y), col, Tex2F(0.0, 0.0) }; V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); V2F_C4B_T2F_Triangle triangle = {a, b, c}; triangles[0] = triangle; _bufferCount += vertex_count; _dirty = true; } void DrawNode::drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color) { unsigned int vertex_count = (segments + 1) * 3; ensureCapacity(vertex_count); Tex2F texCoord = Tex2F(0.0, 0.0); Color4B col = Color4B(color); Vertex2F vertex; Vertex2F firstVertex = Vertex2F(from.x, from.y); Vertex2F lastVertex = Vertex2F(to.x, to.y); float t = 0; for(unsigned int i = segments + 1; i > 0; i--) { float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x; float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y; vertex = Vertex2F(x, y); V2F_C4B_T2F a = {firstVertex, col, texCoord }; V2F_C4B_T2F b = {lastVertex, col, texCoord }; V2F_C4B_T2F c = {vertex, col, texCoord }; V2F_C4B_T2F_Triangle triangle = {a, b, c}; ((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle; lastVertex = vertex; t += 1.0f / segments; _bufferCount += 3; } _dirty = true; } void DrawNode::drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color) { unsigned int vertex_count = (segments + 1) * 3; ensureCapacity(vertex_count); Tex2F texCoord = Tex2F(0.0, 0.0); Color4B col = Color4B(color); Vertex2F vertex; Vertex2F firstVertex = Vertex2F(from.x, from.y); Vertex2F lastVertex = Vertex2F(to.x, to.y); float t = 0; for(unsigned int i = segments + 1; i > 0; i--) { float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x; float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y; vertex = Vertex2F(x, y); V2F_C4B_T2F a = {firstVertex, col, texCoord }; V2F_C4B_T2F b = {lastVertex, col, texCoord }; V2F_C4B_T2F c = {vertex, col, texCoord }; V2F_C4B_T2F_Triangle triangle = {a, b, c}; ((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle; lastVertex = vertex; t += 1.0f / segments; _bufferCount += 3; } _dirty = true; } void DrawNode::clear() { _bufferCount = 0; _dirty = true; } const BlendFunc& DrawNode::getBlendFunc() const { return _blendFunc; } void DrawNode::setBlendFunc(const BlendFunc &blendFunc) { _blendFunc = blendFunc; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCDrawNode.h ================================================ /* Copyright (c) 2012 Scott Lembcke and Howling Moon Software * Copyright (c) 2012 cocos2d-x.org * Copyright (c) 2013-2014 Chukong Technologies Inc. * * 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. */ /* * Code copied & pasted from SpacePatrol game https://github.com/slembcke/SpacePatrol * * Renamed and added some changes for cocos2d * */ #ifndef __CCDRAWNODES_CCDRAW_NODE_H__ #define __CCDRAWNODES_CCDRAW_NODE_H__ #include "CCNode.h" #include "ccTypes.h" #include "renderer/CCCustomCommand.h" NS_CC_BEGIN /** DrawNode Node that draws dots, segments and polygons. Faster than the "drawing primitives" since they it draws everything in one single batch. @since v2.1 */ class CC_DLL DrawNode : public Node { public: /** creates and initialize a DrawNode node */ static DrawNode* create(); /** draw a dot at a position, with a given radius and color */ void drawDot(const Point &pos, float radius, const Color4F &color); /** draw a segment with a radius and color */ void drawSegment(const Point &from, const Point &to, float radius, const Color4F &color); /** draw a polygon with a fill color and line color * @code * When this function bound into js or lua,the parameter will be changed * In js: var drawPolygon(var Arrayofpoints, var fillColor, var width, var borderColor) * In lua:local drawPolygon(local pointTable,local tableCount,local fillColor,local width,local borderColor) * @endcode */ void drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor); /** draw a triangle with color */ void drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color); /** draw a cubic bezier curve with color and number of segments */ void drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color); /** draw a quadratic bezier curve with color and number of segments */ void drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color); /** Clear the geometry in the node's buffer. */ void clear(); /** * @js NA * @lua NA */ const BlendFunc& getBlendFunc() const; /** * @code * When this function bound into js or lua,the parameter will be changed * In js: var setBlendFunc(var src, var dst) * @endcode * @lua NA */ void setBlendFunc(const BlendFunc &blendFunc); void onDraw(); // Overrides virtual void draw() override; protected: DrawNode(); virtual ~DrawNode(); virtual bool init(); void ensureCapacity(int count); void render(); GLuint _vao; GLuint _vbo; int _bufferCapacity; GLsizei _bufferCount; V2F_C4B_T2F *_buffer; BlendFunc _blendFunc; CustomCommand _customCommand; bool _dirty; private: CC_DISALLOW_COPY_AND_ASSIGN(DrawNode); }; NS_CC_END #endif // __CCDRAWNODES_CCDRAW_NODE_H__ ================================================ FILE: cocos2d/cocos/2d/CCDrawingPrimitives.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ /* * * IMPORTANT IMPORTANT IMPORTANT IMPORTANT * * * LEGACY FUNCTIONS * * USE DrawNode instead * */ #include "CCDrawingPrimitives.h" #include "ccTypes.h" #include "ccMacros.h" #include "CCGL.h" #include "CCDirector.h" #include "ccGLStateCache.h" #include "CCShaderCache.h" #include "CCGLProgram.h" #include "CCActionCatmullRom.h" #include #include NS_CC_BEGIN #ifndef M_PI #define M_PI 3.14159265358979323846 #endif namespace DrawPrimitives { static bool s_initialized = false; static GLProgram* s_shader = nullptr; static int s_colorLocation = -1; static Color4F s_color(1.0f,1.0f,1.0f,1.0f); static int s_pointSizeLocation = -1; static GLfloat s_pointSize = 1.0f; #ifdef EMSCRIPTEN static GLuint s_bufferObject = 0; static GLuint s_bufferSize = 0; static void setGLBufferData(void *buf, GLuint bufSize) { if(s_bufferSize < bufSize) { if(s_bufferObject) { glDeleteBuffers(1, &s_bufferObject); } glGenBuffers(1, &s_bufferObject); s_bufferSize = bufSize; glBindBuffer(GL_ARRAY_BUFFER, s_bufferObject); glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_DYNAMIC_DRAW); } else { glBindBuffer(GL_ARRAY_BUFFER, s_bufferObject); glBufferSubData(GL_ARRAY_BUFFER, 0, bufSize, buf); } } #endif // EMSCRIPTEN static void lazy_init( void ) { if( ! s_initialized ) { // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // s_shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); s_shader->retain(); s_colorLocation = glGetUniformLocation( s_shader->getProgram(), "u_color"); CHECK_GL_ERROR_DEBUG(); s_pointSizeLocation = glGetUniformLocation( s_shader->getProgram(), "u_pointSize"); CHECK_GL_ERROR_DEBUG(); s_initialized = true; } } // When switching from backround to foreground on android, we want the params to be initialized again void init() { lazy_init(); } void free() { CC_SAFE_RELEASE_NULL(s_shader); s_initialized = false; } void drawPoint( const Point& point ) { lazy_init(); Vertex2F p; p.x = point.x; p.y = point.y; GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); s_shader->use(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize); #ifdef EMSCRIPTEN setGLBufferData(&p, 8); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, &p); #endif // EMSCRIPTEN glDrawArrays(GL_POINTS, 0, 1); CC_INCREMENT_GL_DRAWS(1); } void drawPoints( const Point *points, unsigned int numberOfPoints ) { lazy_init(); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); s_shader->use(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize); // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed Vertex2F* newPoints = new Vertex2F[numberOfPoints]; // iPhone and 32-bit machines optimization if( sizeof(Point) == sizeof(Vertex2F) ) { #ifdef EMSCRIPTEN setGLBufferData((void*) points, numberOfPoints * sizeof(Point)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points); #endif // EMSCRIPTEN } else { // Mac on 64-bit for( unsigned int i=0; iuse(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, 16); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINES, 0, 2); CC_INCREMENT_GL_DRAWS(1); } void drawRect( Point origin, Point destination ) { drawLine(Point(origin.x, origin.y), Point(destination.x, origin.y)); drawLine(Point(destination.x, origin.y), Point(destination.x, destination.y)); drawLine(Point(destination.x, destination.y), Point(origin.x, destination.y)); drawLine(Point(origin.x, destination.y), Point(origin.x, origin.y)); } void drawSolidRect( Point origin, Point destination, Color4F color ) { Point vertices[] = { origin, Point(destination.x, origin.y), destination, Point(origin.x, destination.y) }; drawSolidPoly(vertices, 4, color ); } void drawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolygon ) { lazy_init(); s_shader->use(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); // iPhone and 32-bit machines optimization if( sizeof(Point) == sizeof(Vertex2F) ) { #ifdef EMSCRIPTEN setGLBufferData((void*) poli, numberOfPoints * sizeof(Point)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli); #endif // EMSCRIPTEN if( closePolygon ) glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints); else glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints); } else { // Mac on 64-bit // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed Vertex2F* newPoli = new Vertex2F[numberOfPoints]; for( unsigned int i=0; iuse(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &color.r, 1); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed Vertex2F* newPoli = new Vertex2F[numberOfPoints]; // iPhone and 32-bit machines optimization if( sizeof(Point) == sizeof(Vertex2F) ) { #ifdef EMSCRIPTEN setGLBufferData((void*) poli, numberOfPoints * sizeof(Point)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli); #endif // EMSCRIPTEN } else { // Mac on 64-bit for( unsigned int i=0; iuse(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments+additionalSegment); ::free( vertices ); CC_INCREMENT_GL_DRAWS(1); } void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) { drawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f); } void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY) { lazy_init(); const float coef = 2.0f * (float)M_PI/segments; GLfloat *vertices = (GLfloat*)calloc( sizeof(GLfloat)*2*(segments+2), 1); if( ! vertices ) return; for(unsigned int i = 0;i <= segments; i++) { float rads = i*coef; GLfloat j = radius * cosf(rads + angle) * scaleX + center.x; GLfloat k = radius * sinf(rads + angle) * scaleY + center.y; vertices[i*2] = j; vertices[i*2+1] = k; } vertices[(segments+1)*2] = center.x; vertices[(segments+1)*2+1] = center.y; s_shader->use(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) segments+1); ::free( vertices ); CC_INCREMENT_GL_DRAWS(1); } void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments) { drawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f); } void drawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments) { lazy_init(); Vertex2F* vertices = new Vertex2F[segments + 1]; float t = 0.0f; for(unsigned int i = 0; i < segments; i++) { vertices[i].x = powf(1 - t, 2) * origin.x + 2.0f * (1 - t) * t * control.x + t * t * destination.x; vertices[i].y = powf(1 - t, 2) * origin.y + 2.0f * (1 - t) * t * control.y + t * t * destination.y; t += 1.0f / segments; } vertices[segments].x = destination.x; vertices[segments].y = destination.y; s_shader->use(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); CC_SAFE_DELETE_ARRAY(vertices); CC_INCREMENT_GL_DRAWS(1); } void drawCatmullRom( PointArray *points, unsigned int segments ) { drawCardinalSpline( points, 0.5f, segments ); } void drawCardinalSpline( PointArray *config, float tension, unsigned int segments ) { lazy_init(); Vertex2F* vertices = new Vertex2F[segments + 1]; ssize_t p; float lt; float deltaT = 1.0f / config->count(); for( unsigned int i=0; i < segments+1;i++) { float dt = (float)i / segments; // border if( dt == 1 ) { p = config->count() - 1; lt = 1; } else { p = dt / deltaT; lt = (dt - deltaT * (float)p) / deltaT; } // Interpolate Point pp0 = config->getControlPointAtIndex(p-1); Point pp1 = config->getControlPointAtIndex(p+0); Point pp2 = config->getControlPointAtIndex(p+1); Point pp3 = config->getControlPointAtIndex(p+2); Point newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt); vertices[i].x = newPos.x; vertices[i].y = newPos.y; } s_shader->use(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*)&s_color.r, 1); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); CC_SAFE_DELETE_ARRAY(vertices); CC_INCREMENT_GL_DRAWS(1); } void drawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments) { lazy_init(); Vertex2F* vertices = new Vertex2F[segments + 1]; float t = 0; for(unsigned int i = 0; i < segments; i++) { vertices[i].x = powf(1 - t, 3) * origin.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x; vertices[i].y = powf(1 - t, 3) * origin.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y; t += 1.0f / segments; } vertices[segments].x = destination.x; vertices[segments].y = destination.y; s_shader->use(); s_shader->setUniformsForBuiltins(); s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); CC_SAFE_DELETE_ARRAY(vertices); CC_INCREMENT_GL_DRAWS(1); } void setDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) { s_color.r = r; s_color.g = g; s_color.b = b; s_color.a = a; } void setPointSize( GLfloat pointSize ) { s_pointSize = pointSize * CC_CONTENT_SCALE_FACTOR(); //TODO :glPointSize( pointSize ); } void setDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) { s_color.r = r/255.0f; s_color.g = g/255.0f; s_color.b = b/255.0f; s_color.a = a/255.0f; } } // DrawPrimitives namespace NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCDrawingPrimitives.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ /* * * IMPORTANT IMPORTANT IMPORTANT IMPORTANT * * * LEGACY FUNCTIONS * * USE DrawNode instead * */ #ifndef __CCDRAWING_PRIMITIVES__ #define __CCDRAWING_PRIMITIVES__ #include "ccTypes.h" #include "ccMacros.h" #include "CCGeometry.h" // for Point /** @file Drawing OpenGL ES primitives. - drawPoint, drawPoints - drawLine - drawRect, drawSolidRect - drawPoly, drawSolidPoly - drawCircle - drawQuadBezier - drawCubicBezier - drawCatmullRom - drawCardinalSpline You can change the color, point size, width by calling: - drawColor4B(), drawColor4F() - ccPointSize() - glLineWidth() @warning These functions draws the Line, Point, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. Instead you should use DrawNode */ NS_CC_BEGIN /** * @addtogroup global * @{ */ class PointArray; namespace DrawPrimitives { /** Initializes the drawing primitives */ void init(); /** Frees allocated resources by the drawing primitives */ void free(); /** draws a point given x and y coordinate measured in points */ void drawPoint( const Point& point ); /** draws an array of points. @since v0.7.2 */ void drawPoints( const Point *points, unsigned int numberOfPoints ); /** draws a line given the origin and destination point measured in points */ void drawLine( const Point& origin, const Point& destination ); /** draws a rectangle given the origin and destination point measured in points. */ void drawRect( Point origin, Point destination ); /** draws a solid rectangle given the origin and destination point measured in points. @since 1.1 */ void drawSolidRect( Point origin, Point destination, Color4F color ); /** draws a polygon given a pointer to Point coordinates and the number of vertices measured in points. The polygon can be closed or open */ void drawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon ); /** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color. */ void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ); /** draws a circle given the center, radius and number of segments. */ void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); /** draws a solid circle given the center, radius and number of segments. */ void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments); /** draws a quad bezier path @warning This function could be pretty slow. Use it only for debugging purposes. @since v0.8 */ void drawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments); /** draws a cubic bezier path @warning This function could be pretty slow. Use it only for debugging purposes. @since v0.8 */ void drawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments); /** draws a Catmull Rom path. @warning This function could be pretty slow. Use it only for debugging purposes. @since v2.0 */ void drawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ); /** draws a Cardinal Spline path. @warning This function could be pretty slow. Use it only for debugging purposes. @since v2.0 */ void drawCardinalSpline( PointArray *config, float tension, unsigned int segments ); /** set the drawing color with 4 unsigned bytes @since v2.0 */ void setDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ); /** set the drawing color with 4 floats @since v2.0 */ void setDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ); /** set the point size in points. Default 1. @since v2.0 */ void setPointSize( GLfloat pointSize ); }; // end of global group /// @} NS_CC_END #endif // __CCDRAWING_PRIMITIVES__ ================================================ FILE: cocos2d/cocos/2d/CCEvent.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEvent.h" NS_CC_BEGIN Event::Event(Type type) : _type(type) , _isStopped(false) , _currentTarget(nullptr) { } Event::~Event() { } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEvent.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCEVENT_H__ #define __CCEVENT_H__ #include #include #include "CCObject.h" #include "CCPlatformMacros.h" NS_CC_BEGIN class Node; /** * Base class of all kinds of events. */ class Event : public Object { public: enum class Type { TOUCH, KEYBOARD, ACCELERATION, MOUSE, CUSTOM }; protected: /** Constructor */ Event(Type type); public: /** Destructor */ virtual ~Event(); /** Gets the event type */ inline Type getType() const { return _type; }; /** Stops propagation for current event */ inline void stopPropagation() { _isStopped = true; }; /** Checks whether the event has been stopped */ inline bool isStopped() const { return _isStopped; }; /** @brief Gets current target of the event * @return The target with which the event associates. * @note It onlys be available when the event listener is associated with node. * It returns 0 when the listener is associated with fixed priority. */ inline Node* getCurrentTarget() { return _currentTarget; }; protected: /** Sets current target */ inline void setCurrentTarget(Node* target) { _currentTarget = target; }; Type _type; ///< Event type bool _isStopped; ///< whether the event has been stopped. Node* _currentTarget; ///< Current target friend class EventDispatcher; }; NS_CC_END #endif // __CCEVENT_H__ ================================================ FILE: cocos2d/cocos/2d/CCEventAcceleration.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventAcceleration.h" NS_CC_BEGIN EventAcceleration::EventAcceleration(Acceleration acc) : Event(Type::ACCELERATION) , _acc(acc) { } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventAcceleration.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__CCAccelerometerEvent__ #define __cocos2d_libs__CCAccelerometerEvent__ #include "CCEvent.h" #include "ccTypes.h" NS_CC_BEGIN class EventAcceleration : public Event { public: EventAcceleration(Acceleration acc); private: Acceleration _acc; friend class EventListenerAcceleration; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCAccelerometerEvent__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventCustom.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventCustom.h" #include "ccMacros.h" #include NS_CC_BEGIN EventCustom::EventCustom(const std::string& eventName) : Event(Type::CUSTOM) , _userData(nullptr) , _eventName(eventName) { } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventCustom.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__CCCustomEvent__ #define __cocos2d_libs__CCCustomEvent__ #include "CCEvent.h" NS_CC_BEGIN class EventCustom : public Event { public: /** Constructor */ EventCustom(const std::string& eventName); /** Sets user data */ inline void setUserData(void* data) { _userData = data; }; /** Gets user data */ inline void* getUserData() const { return _userData; }; /** Gets event name */ inline const std::string& getEventName() const { return _eventName; }; protected: void* _userData; ///< User data std::string _eventName; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCCustomEvent__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventDispatcher.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventDispatcher.h" #include "CCEvent.h" #include "CCEventTouch.h" #include "CCEventCustom.h" #include "CCEventListenerTouch.h" #include "CCEventListenerAcceleration.h" #include "CCEventListenerMouse.h" #include "CCEventListenerKeyboard.h" #include "CCEventListenerCustom.h" #include "CCNode.h" #include "CCDirector.h" #include #define DUMP_LISTENER_ITEM_PRIORITY_INFO 0 namespace { class DispatchGuard { public: DispatchGuard(int& count): _count(count) { ++_count; } ~DispatchGuard() { --_count; } private: int& _count; }; } NS_CC_BEGIN static EventListener::ListenerID __getListenerID(Event* event) { EventListener::ListenerID ret; switch (event->getType()) { case Event::Type::ACCELERATION: ret = EventListenerAcceleration::LISTENER_ID; break; case Event::Type::CUSTOM: { auto customEvent = static_cast(event); ret = customEvent->getEventName(); } break; case Event::Type::KEYBOARD: ret = EventListenerKeyboard::LISTENER_ID; break; case Event::Type::MOUSE: ret = EventListenerMouse::LISTENER_ID; break; case Event::Type::TOUCH: // Touch listener is very special, it contains two kinds of listeners, EventListenerTouchOneByOne and EventListenerTouchAllAtOnce. // return UNKNOWN instead. CCASSERT(false, "Don't call this method if the event is for touch."); break; default: CCASSERT(false, "Invalid type!"); break; } return ret; } EventDispatcher::EventListenerVector::EventListenerVector() : _fixedListeners(nullptr), _sceneGraphListeners(nullptr), _gt0Index(0) { } EventDispatcher::EventListenerVector::~EventListenerVector() { CC_SAFE_DELETE(_sceneGraphListeners); CC_SAFE_DELETE(_fixedListeners); } size_t EventDispatcher::EventListenerVector::size() const { size_t ret = 0; if (_sceneGraphListeners) ret += _sceneGraphListeners->size(); if (_fixedListeners) ret += _fixedListeners->size(); return ret; } bool EventDispatcher::EventListenerVector::empty() const { return (_sceneGraphListeners == nullptr || _sceneGraphListeners->empty()) && (_fixedListeners == nullptr || _fixedListeners->empty()); } void EventDispatcher::EventListenerVector::push_back(EventListener* listener) { if (listener->getFixedPriority() == 0) { if (_sceneGraphListeners == nullptr) { _sceneGraphListeners = new std::vector(); _sceneGraphListeners->reserve(100); } _sceneGraphListeners->push_back(listener); } else { if (_fixedListeners == nullptr) { _fixedListeners = new std::vector(); _fixedListeners->reserve(100); } _fixedListeners->push_back(listener); } } void EventDispatcher::EventListenerVector::clearSceneGraphListeners() { if (_sceneGraphListeners) { _sceneGraphListeners->clear(); delete _sceneGraphListeners; _sceneGraphListeners = nullptr; } } void EventDispatcher::EventListenerVector::clearFixedListeners() { if (_fixedListeners) { _fixedListeners->clear(); delete _fixedListeners; _fixedListeners = nullptr; } } void EventDispatcher::EventListenerVector::clear() { clearSceneGraphListeners(); clearFixedListeners(); } EventDispatcher::EventDispatcher() : _inDispatch(0) , _isEnabled(true) , _nodePriorityIndex(0) { _toAddedListeners.reserve(50); } EventDispatcher::~EventDispatcher() { removeAllEventListeners(); } void EventDispatcher::visitTarget(Node* node, bool isRootNode) { int i = 0; auto& children = node->getChildren(); auto childrenCount = children.size(); if(childrenCount > 0) { Node* child = nullptr; // visit children zOrder < 0 for( ; i < childrenCount; i++ ) { child = children.at(i); if ( child && child->getLocalZOrder() < 0 ) visitTarget(child, false); else break; } if (_nodeListenersMap.find(node) != _nodeListenersMap.end()) { _globalZOrderNodeMap[node->getGlobalZOrder()].push_back(node); } for( ; i < childrenCount; i++ ) { child = children.at(i); if (child) visitTarget(child, false); } } else { if (_nodeListenersMap.find(node) != _nodeListenersMap.end()) { _globalZOrderNodeMap[node->getGlobalZOrder()].push_back(node); } } if (isRootNode) { std::vector globalZOrders; globalZOrders.reserve(_globalZOrderNodeMap.size()); for (const auto& e : _globalZOrderNodeMap) { globalZOrders.push_back(e.first); } std::sort(globalZOrders.begin(), globalZOrders.end(), [](const float a, const float b){ return a < b; }); for (const auto& globalZ : globalZOrders) { for (const auto& n : _globalZOrderNodeMap[globalZ]) { _nodePriorityMap[n] = ++_nodePriorityIndex; } } _globalZOrderNodeMap.clear(); } } void EventDispatcher::pauseTarget(Node* node) { auto listenerIter = _nodeListenersMap.find(node); if (listenerIter != _nodeListenersMap.end()) { auto listeners = listenerIter->second; for (auto& l : *listeners) { l->setPaused(true); } } } void EventDispatcher::resumeTarget(Node* node) { auto listenerIter = _nodeListenersMap.find(node); if (listenerIter != _nodeListenersMap.end()) { auto listeners = listenerIter->second; for (auto& l : *listeners) { l->setPaused(false); } } setDirtyForNode(node); } void EventDispatcher::cleanTarget(Node* node) { auto listenerIter = _nodeListenersMap.find(node); if (listenerIter != _nodeListenersMap.end()) { auto listeners = listenerIter->second; auto listenersCopy = *listeners; for (auto& l : listenersCopy) { removeEventListener(l); } } } void EventDispatcher::associateNodeAndEventListener(Node* node, EventListener* listener) { std::vector* listeners = nullptr; auto found = _nodeListenersMap.find(node); if (found != _nodeListenersMap.end()) { listeners = found->second; } else { listeners = new std::vector(); _nodeListenersMap.insert(std::make_pair(node, listeners)); } listeners->push_back(listener); } void EventDispatcher::dissociateNodeAndEventListener(Node* node, EventListener* listener) { std::vector* listeners = nullptr; auto found = _nodeListenersMap.find(node); if (found != _nodeListenersMap.end()) { listeners = found->second; auto iter = std::find(listeners->begin(), listeners->end(), listener); if (iter != listeners->end()) { listeners->erase(iter); } if (listeners->empty()) { _nodeListenersMap.erase(found); delete listeners; } } } void EventDispatcher::addEventListener(EventListener* listener) { if (_inDispatch == 0) { forceAddEventListener(listener); } else { _toAddedListeners.push_back(listener); } listener->retain(); } void EventDispatcher::forceAddEventListener(EventListener* listener) { EventListenerVector* listeners = nullptr; EventListener::ListenerID listenerID = listener->getListenerID(); auto itr = _listeners.find(listenerID); if (itr == _listeners.end()) { listeners = new EventListenerVector(); _listeners.insert(std::make_pair(listenerID, listeners)); } else { listeners = itr->second; } listeners->push_back(listener); if (listener->getFixedPriority() == 0) { setDirty(listenerID, DirtyFlag::SCENE_GRAPH_PRIORITY); auto node = listener->getSceneGraphPriority(); CCASSERT(node != nullptr, "Invalid scene graph priority!"); associateNodeAndEventListener(node, listener); if (node->isRunning()) { resumeTarget(node); } } else { setDirty(listenerID, DirtyFlag::FIXED_PRIORITY); } } void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* listener, Node* node) { CCASSERT(listener && node, "Invalid parameters."); CCASSERT(!listener->isRegistered(), "The listener has been registered."); if (!listener->checkAvailable()) return; listener->setSceneGraphPriority(node); listener->setFixedPriority(0); listener->setRegistered(true); addEventListener(listener); } void EventDispatcher::addEventListenerWithFixedPriority(EventListener* listener, int fixedPriority) { CCASSERT(listener, "Invalid parameters."); CCASSERT(!listener->isRegistered(), "The listener has been registered."); CCASSERT(fixedPriority != 0, "0 priority is forbidden for fixed priority since it's used for scene graph based priority."); if (!listener->checkAvailable()) return; listener->setSceneGraphPriority(nullptr); listener->setFixedPriority(fixedPriority); listener->setRegistered(true); listener->setPaused(false); addEventListener(listener); } EventListenerCustom* EventDispatcher::addCustomEventListener(const std::string &eventName, std::function callback) { EventListenerCustom *listener = EventListenerCustom::create(eventName, callback); addEventListenerWithFixedPriority(listener, 1); return listener; } void EventDispatcher::removeEventListener(EventListener* listener) { if (listener == nullptr) return; bool isFound = false; auto removeListenerInVector = [&](std::vector* listeners){ if (listeners == nullptr) return; for (auto iter = listeners->begin(); iter != listeners->end(); ++iter) { auto l = *iter; if (l == listener) { CC_SAFE_RETAIN(l); l->setRegistered(false); if (l->getSceneGraphPriority() != nullptr) { dissociateNodeAndEventListener(l->getSceneGraphPriority(), l); } if (_inDispatch == 0) { listeners->erase(iter); CC_SAFE_RELEASE(l); } isFound = true; break; } } }; for (auto iter = _listeners.begin(); iter != _listeners.end();) { auto listeners = iter->second; auto fixedPriorityListeners = listeners->getFixedPriorityListeners(); auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners(); removeListenerInVector(sceneGraphPriorityListeners); if (!isFound) { removeListenerInVector(fixedPriorityListeners); } if (iter->second->empty()) { _priorityDirtyFlagMap.erase(listener->getListenerID()); auto list = iter->second; iter = _listeners.erase(iter); CC_SAFE_DELETE(list); } else { ++iter; } if (isFound) break; } if (isFound) { CC_SAFE_RELEASE(listener); } else { for(auto iter = _toAddedListeners.begin(); iter != _toAddedListeners.end(); ++iter) { if (*iter == listener) { listener->release(); _toAddedListeners.erase(iter); break; } } } } void EventDispatcher::setPriority(EventListener* listener, int fixedPriority) { if (listener == nullptr) return; for (auto iter = _listeners.begin(); iter != _listeners.end(); ++iter) { auto fixedPriorityListeners = iter->second->getFixedPriorityListeners(); if (fixedPriorityListeners) { auto found = std::find(fixedPriorityListeners->begin(), fixedPriorityListeners->end(), listener); if (found != fixedPriorityListeners->end()) { CCASSERT(listener->getSceneGraphPriority() == nullptr, "Can't set fixed priority with scene graph based listener."); if (listener->getFixedPriority() != fixedPriority) { listener->setFixedPriority(fixedPriority); setDirty(listener->getListenerID(), DirtyFlag::FIXED_PRIORITY); } return; } } } } void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, std::function onEvent) { bool shouldStopPropagation = false; auto fixedPriorityListeners = listeners->getFixedPriorityListeners(); auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners(); ssize_t i = 0; // priority < 0 if (fixedPriorityListeners) { bool isEmpty = fixedPriorityListeners->empty(); for (; !isEmpty && i < listeners->getGt0Index(); ++i) { auto l = fixedPriorityListeners->at(i); if (!l->isPaused() && l->isRegistered() && onEvent(l)) { shouldStopPropagation = true; break; } } } if (sceneGraphPriorityListeners) { if (!shouldStopPropagation) { // priority == 0, scene graph priority for (auto& l : *sceneGraphPriorityListeners) { if (!l->isPaused() && l->isRegistered() && onEvent(l)) { shouldStopPropagation = true; break; } } } } if (fixedPriorityListeners) { if (!shouldStopPropagation) { // priority > 0 ssize_t size = fixedPriorityListeners->size(); for (; i < size; ++i) { auto l = fixedPriorityListeners->at(i); if (!l->isPaused() && l->isRegistered() && onEvent(fixedPriorityListeners->at(i))) { shouldStopPropagation = true; break; } } } } } void EventDispatcher::dispatchEvent(Event* event) { if (!_isEnabled) return; updateDirtyFlagForSceneGraph(); DispatchGuard guard(_inDispatch); if (event->getType() == Event::Type::TOUCH) { dispatchTouchEvent(static_cast(event)); return; } auto listenerID = __getListenerID(event); sortEventListeners(listenerID); auto iter = _listeners.find(listenerID); if (iter != _listeners.end()) { auto listeners = iter->second; auto onEvent = [&event](EventListener* listener) -> bool{ event->setCurrentTarget(listener->getSceneGraphPriority()); listener->_onEvent(event); return event->isStopped(); }; dispatchEventToListeners(listeners, onEvent); } updateListeners(event); } void EventDispatcher::dispatchCustomEvent(const std::string &eventName, void *optionalUserData) { EventCustom ev(eventName); ev.setUserData(optionalUserData); dispatchEvent(&ev); } void EventDispatcher::dispatchTouchEvent(EventTouch* event) { sortEventListeners(EventListenerTouchOneByOne::LISTENER_ID); sortEventListeners(EventListenerTouchAllAtOnce::LISTENER_ID); auto oneByOnelisteners = getListeners(EventListenerTouchOneByOne::LISTENER_ID); auto allAtOncelisteners = getListeners(EventListenerTouchAllAtOnce::LISTENER_ID); // If there aren't any touch listeners, return directly. if (nullptr == oneByOnelisteners && nullptr == allAtOncelisteners) return; bool isNeedsMutableSet = (oneByOnelisteners && allAtOncelisteners); std::vector orignalTouches = event->getTouches(); std::vector mutableTouches(orignalTouches.size()); std::copy(orignalTouches.begin(), orignalTouches.end(), mutableTouches.begin()); // // process the target handlers 1st // if (oneByOnelisteners) { auto mutableTouchesIter = mutableTouches.begin(); auto touchesIter = orignalTouches.begin(); for (; touchesIter != orignalTouches.end(); ++touchesIter) { bool isSwallowed = false; auto onTouchEvent = [&](EventListener* l) -> bool { // Return true to break EventListenerTouchOneByOne* listener = static_cast(l); // Skip if the listener was removed. if (!listener->_isRegistered) return false; event->setCurrentTarget(listener->_node); bool isClaimed = false; std::vector::iterator removedIter; EventTouch::EventCode eventCode = event->getEventCode(); if (eventCode == EventTouch::EventCode::BEGAN) { if (listener->onTouchBegan) { isClaimed = listener->onTouchBegan(*touchesIter, event); if (isClaimed && listener->_isRegistered) { listener->_claimedTouches.push_back(*touchesIter); } } } else if (listener->_claimedTouches.size() > 0 && ((removedIter = std::find(listener->_claimedTouches.begin(), listener->_claimedTouches.end(), *touchesIter)) != listener->_claimedTouches.end())) { isClaimed = true; switch (eventCode) { case EventTouch::EventCode::MOVED: if (listener->onTouchMoved) { listener->onTouchMoved(*touchesIter, event); } break; case EventTouch::EventCode::ENDED: if (listener->onTouchEnded) { listener->onTouchEnded(*touchesIter, event); } if (listener->_isRegistered) { listener->_claimedTouches.erase(removedIter); } break; case EventTouch::EventCode::CANCELLED: if (listener->onTouchCancelled) { listener->onTouchCancelled(*touchesIter, event); } if (listener->_isRegistered) { listener->_claimedTouches.erase(removedIter); } break; default: CCASSERT(false, "The eventcode is invalid."); break; } } // If the event was stopped, return directly. if (event->isStopped()) { updateListeners(event); return true; } CCASSERT((*touchesIter)->getID() == (*mutableTouchesIter)->getID(), ""); if (isClaimed && listener->_isRegistered && listener->_needSwallow) { if (isNeedsMutableSet) { mutableTouchesIter = mutableTouches.erase(mutableTouchesIter); isSwallowed = true; } return true; } return false; }; // dispatchEventToListeners(oneByOnelisteners, onTouchEvent); if (event->isStopped()) { return; } if (!isSwallowed) ++mutableTouchesIter; } } // // process standard handlers 2nd // if (allAtOncelisteners && mutableTouches.size() > 0) { auto onTouchesEvent = [&](EventListener* l) -> bool{ EventListenerTouchAllAtOnce* listener = static_cast(l); // Skip if the listener was removed. if (!listener->_isRegistered) return false; event->setCurrentTarget(listener->_node); switch (event->getEventCode()) { case EventTouch::EventCode::BEGAN: if (listener->onTouchesBegan) { listener->onTouchesBegan(mutableTouches, event); } break; case EventTouch::EventCode::MOVED: if (listener->onTouchesMoved) { listener->onTouchesMoved(mutableTouches, event); } break; case EventTouch::EventCode::ENDED: if (listener->onTouchesEnded) { listener->onTouchesEnded(mutableTouches, event); } break; case EventTouch::EventCode::CANCELLED: if (listener->onTouchesCancelled) { listener->onTouchesCancelled(mutableTouches, event); } break; default: CCASSERT(false, "The eventcode is invalid."); break; } // If the event was stopped, return directly. if (event->isStopped()) { updateListeners(event); return true; } return false; }; dispatchEventToListeners(allAtOncelisteners, onTouchesEvent); if (event->isStopped()) { return; } } updateListeners(event); } void EventDispatcher::updateListeners(Event* event) { auto onUpdateListeners = [this](const EventListener::ListenerID& listenerID) { auto listenersIter = _listeners.find(listenerID); if (listenersIter == _listeners.end()) return; auto listeners = listenersIter->second; auto fixedPriorityListeners = listeners->getFixedPriorityListeners(); auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners(); if (sceneGraphPriorityListeners) { for (auto iter = sceneGraphPriorityListeners->begin(); iter != sceneGraphPriorityListeners->end();) { auto l = *iter; if (!l->isRegistered()) { iter = sceneGraphPriorityListeners->erase(iter); l->release(); } else { ++iter; } } } if (fixedPriorityListeners) { for (auto iter = fixedPriorityListeners->begin(); iter != fixedPriorityListeners->end();) { auto l = *iter; if (!l->isRegistered()) { iter = fixedPriorityListeners->erase(iter); l->release(); } else { ++iter; } } } if (sceneGraphPriorityListeners && sceneGraphPriorityListeners->empty()) { listeners->clearSceneGraphListeners(); } if (fixedPriorityListeners && fixedPriorityListeners->empty()) { listeners->clearFixedListeners(); } if (listenersIter->second->empty()) { _priorityDirtyFlagMap.erase(listenersIter->first); delete listenersIter->second; listenersIter = _listeners.erase(listenersIter); } else { ++listenersIter; } }; if (event->getType() == Event::Type::TOUCH) { onUpdateListeners(EventListenerTouchOneByOne::LISTENER_ID); onUpdateListeners(EventListenerTouchAllAtOnce::LISTENER_ID); } else { onUpdateListeners(__getListenerID(event)); } if (!_toAddedListeners.empty()) { for (auto& listener : _toAddedListeners) { forceAddEventListener(listener); } _toAddedListeners.clear(); } } void EventDispatcher::updateDirtyFlagForSceneGraph() { if (!_dirtyNodes.empty()) { for (auto& node : _dirtyNodes) { auto iter = _nodeListenersMap.find(node); if (iter != _nodeListenersMap.end()) { for (auto& l : *iter->second) { setDirty(l->getListenerID(), DirtyFlag::SCENE_GRAPH_PRIORITY); } } } _dirtyNodes.clear(); } } void EventDispatcher::sortEventListeners(const EventListener::ListenerID& listenerID) { DirtyFlag dirtyFlag = DirtyFlag::NONE; auto dirtyIter = _priorityDirtyFlagMap.find(listenerID); if (dirtyIter != _priorityDirtyFlagMap.end()) { dirtyFlag = dirtyIter->second; } if (dirtyFlag != DirtyFlag::NONE) { if ((int)dirtyFlag & (int)DirtyFlag::FIXED_PRIORITY) { sortEventListenersOfFixedPriority(listenerID); } if ((int)dirtyFlag & (int)DirtyFlag::SCENE_GRAPH_PRIORITY) { sortEventListenersOfSceneGraphPriority(listenerID); } dirtyIter->second = DirtyFlag::NONE; } } void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener::ListenerID& listenerID) { auto listeners = getListeners(listenerID); if (listeners == nullptr) return; Node* rootNode = (Node*)Director::getInstance()->getRunningScene(); // Reset priority index _nodePriorityIndex = 0; _nodePriorityMap.clear(); visitTarget(rootNode, true); // After sort: priority < 0, > 0 auto sceneGraphlisteners = listeners->getSceneGraphPriorityListeners(); std::sort(sceneGraphlisteners->begin(), sceneGraphlisteners->end(), [this](const EventListener* l1, const EventListener* l2) { return _nodePriorityMap[l1->getSceneGraphPriority()] > _nodePriorityMap[l2->getSceneGraphPriority()]; }); #if DUMP_LISTENER_ITEM_PRIORITY_INFO log("-----------------------------------"); for (auto& l : *sceneGraphlisteners) { log("listener priority: node ([%s]%p), priority (%d)", typeid(*l->_node).name(), l->_node, _nodePriorityMap[l->_node]); } #endif } void EventDispatcher::sortEventListenersOfFixedPriority(const EventListener::ListenerID& listenerID) { auto listeners = getListeners(listenerID); if (listeners == nullptr) return; // After sort: priority < 0, > 0 auto fixedlisteners = listeners->getFixedPriorityListeners(); std::sort(fixedlisteners->begin(), fixedlisteners->end(), [](const EventListener* l1, const EventListener* l2) { return l1->getFixedPriority() < l2->getFixedPriority(); }); // FIXME: Should use binary search int index = 0; for (auto& listener : *fixedlisteners) { if (listener->getFixedPriority() >= 0) break; ++index; } listeners->setGt0Index(index); #if DUMP_LISTENER_ITEM_PRIORITY_INFO log("-----------------------------------"); for (auto& l : *fixedlisteners) { log("listener priority: node (%p), fixed (%d)", l->_node, l->_fixedPriority); } #endif } EventDispatcher::EventListenerVector* EventDispatcher::getListeners(const EventListener::ListenerID& listenerID) { auto iter = _listeners.find(listenerID); if (iter != _listeners.end()) { return iter->second; } return nullptr; } void EventDispatcher::removeEventListenersForListenerID(const EventListener::ListenerID& listenerID) { auto listenerItemIter = _listeners.find(listenerID); if (listenerItemIter != _listeners.end()) { auto listeners = listenerItemIter->second; auto fixedPriorityListeners = listeners->getFixedPriorityListeners(); auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners(); auto removeAllListenersInVector = [&](std::vector* listenerVector){ if (listenerVector == nullptr) return; for (auto iter = listenerVector->begin(); iter != listenerVector->end();) { auto l = *iter; l->setRegistered(false); if (l->getSceneGraphPriority() != nullptr) { dissociateNodeAndEventListener(l->getSceneGraphPriority(), l); } if (_inDispatch == 0) { iter = listenerVector->erase(iter); CC_SAFE_RELEASE(l); } else { ++iter; } } }; removeAllListenersInVector(sceneGraphPriorityListeners); removeAllListenersInVector(fixedPriorityListeners); if (!_inDispatch) { listeners->clear(); delete listeners; _listeners.erase(listenerItemIter); _priorityDirtyFlagMap.erase(listenerID); } } for (auto iter = _toAddedListeners.begin(); iter != _toAddedListeners.end();) { if ((*iter)->getListenerID() == listenerID) { (*iter)->release(); iter = _toAddedListeners.erase(iter); } else { ++iter; } } } void EventDispatcher::removeEventListeners(EventListener::Type listenerType) { if (listenerType == EventListener::Type::TOUCH_ONE_BY_ONE) { removeEventListenersForListenerID(EventListenerTouchOneByOne::LISTENER_ID); } else if (listenerType == EventListener::Type::TOUCH_ALL_AT_ONCE) { removeEventListenersForListenerID(EventListenerTouchAllAtOnce::LISTENER_ID); } else if (listenerType == EventListener::Type::MOUSE) { removeEventListenersForListenerID(EventListenerMouse::LISTENER_ID); } else if (listenerType == EventListener::Type::ACCELERATION) { removeEventListenersForListenerID(EventListenerAcceleration::LISTENER_ID); } else if (listenerType == EventListener::Type::KEYBOARD) { removeEventListenersForListenerID(EventListenerKeyboard::LISTENER_ID); } else { CCASSERT(false, "Invalid listener type!"); } } void EventDispatcher::removeCustomEventListeners(const std::string& customEventName) { removeEventListenersForListenerID(customEventName); } void EventDispatcher::removeAllEventListeners() { std::vector types(_listeners.size()); for (const auto& e : _listeners) { types.push_back(e.first); } for (const auto& type : types) { removeEventListenersForListenerID(type); } if (!_inDispatch) { _listeners.clear(); } } void EventDispatcher::setEnabled(bool isEnabled) { _isEnabled = isEnabled; } bool EventDispatcher::isEnabled() const { return _isEnabled; } void EventDispatcher::setDirtyForNode(Node* node) { // Mark the node dirty only when there is an eventlistener associated with it. if (_nodeListenersMap.find(node) != _nodeListenersMap.end()) { _dirtyNodes.insert(node); } } void EventDispatcher::setDirty(const EventListener::ListenerID& listenerID, DirtyFlag flag) { auto iter = _priorityDirtyFlagMap.find(listenerID); if (iter == _priorityDirtyFlagMap.end()) { _priorityDirtyFlagMap.insert(std::make_pair(listenerID, flag)); } else { int ret = (int)flag | (int)iter->second; iter->second = (DirtyFlag) ret; } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventDispatcher.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EVENT_DISPATCHER_H__ #define __CC_EVENT_DISPATCHER_H__ #include "CCPlatformMacros.h" #include "CCEventListener.h" #include "CCEvent.h" #include #include #include #include #include NS_CC_BEGIN class Event; class EventTouch; class Node; class EventCustom; class EventListenerCustom; /** This class manages event listener subscriptions and event dispatching. The EventListener list is managed in such a way that event listeners can be added and removed even from within an EventListener, while events are being dispatched. */ class EventDispatcher : public Object { public: /** Adds a event listener for a specified event with the priority of scene graph. * @param listener The listener of a specified event. * @param node The priority of the listener is based on the draw order of this node. * @note The priority of scene graph will be fixed value 0. So the order of listener item * in the vector will be ' <0, scene graph (0 priority), >0'. */ void addEventListenerWithSceneGraphPriority(EventListener* listener, Node* node); /** Adds a event listener for a specified event with the fixed priority. * @param listener The listener of a specified event. * @param fixedPriority The fixed priority of the listener. * @note A lower priority will be called before the ones that have a higher value. * 0 priority is forbidden for fixed priority since it's used for scene graph based priority. */ void addEventListenerWithFixedPriority(EventListener* listener, int fixedPriority); /** Adds a Custom event listener. It will use a fixed priority of 1. @return the generated event. Needed in order to remove the event from the dispather */ EventListenerCustom* addCustomEventListener(const std::string &eventName, std::function callback); /** Remove a listener * @param listener The specified event listener which needs to be removed. */ void removeEventListener(EventListener* listener); /** Removes all listeners with the same event listener type */ void removeEventListeners(EventListener::Type listenerType); /** Removes all custom listeners with the same event name */ void removeCustomEventListeners(const std::string& customEventName); /** Removes all listeners */ void removeAllEventListeners(); /** Sets listener's priority with fixed value. */ void setPriority(EventListener* listener, int fixedPriority); /** Whether to enable dispatching events */ void setEnabled(bool isEnabled); /** Checks whether dispatching events is enabled */ bool isEnabled() const; /** Dispatches the event * Also removes all EventListeners marked for deletion from the * event dispatcher list. */ void dispatchEvent(Event* event); /** Dispatches a Custom Event with a event name an optional user data */ void dispatchCustomEvent(const std::string &eventName, void *optionalUserData); /** Constructor of EventDispatcher */ EventDispatcher(); /** Destructor of EventDispatcher */ ~EventDispatcher(); protected: friend class Node; /** Sets the dirty flag for a node. */ void setDirtyForNode(Node* node); /** Notifys event dispatcher that the node has been paused. */ void pauseTarget(Node* node); /** Notifys event dispatcher that the node has been resumed. */ void resumeTarget(Node* node); /** Notifys event dispatcher that the node has been deleted. */ void cleanTarget(Node* node); /** * The vector to store event listeners with scene graph based priority and fixed priority. */ class EventListenerVector { public: EventListenerVector(); ~EventListenerVector(); size_t size() const; bool empty() const; void push_back(EventListener* item); void clearSceneGraphListeners(); void clearFixedListeners(); void clear(); inline std::vector* getFixedPriorityListeners() const { return _fixedListeners; }; inline std::vector* getSceneGraphPriorityListeners() const { return _sceneGraphListeners; }; inline ssize_t getGt0Index() const { return _gt0Index; }; inline void setGt0Index(ssize_t index) { _gt0Index = index; }; private: std::vector* _fixedListeners; std::vector* _sceneGraphListeners; ssize_t _gt0Index; }; /** Adds an event listener with item * @note if it is dispatching event, the added operation will be delayed to the end of current dispatch * @see forceAddEventListener */ void addEventListener(EventListener* listener); /** Force adding an event listener * @note force add an event listener which will ignore whether it's in dispatching. * @see addEventListener */ void forceAddEventListener(EventListener* listener); /** Gets event the listener list for the event listener type. */ EventListenerVector* getListeners(const EventListener::ListenerID& listenerID); /** Update dirty flag */ void updateDirtyFlagForSceneGraph(); /** Removes all listeners with the same event listener ID */ void removeEventListenersForListenerID(const EventListener::ListenerID& listenerID); /** Sort event listener */ void sortEventListeners(const EventListener::ListenerID& listenerID); /** Sorts the listeners of specified type by scene graph priority */ void sortEventListenersOfSceneGraphPriority(const EventListener::ListenerID& listenerID); /** Sorts the listeners of specified type by fixed priority */ void sortEventListenersOfFixedPriority(const EventListener::ListenerID& listenerID); /** Updates all listeners * 1) Removes all listener items that have been marked as 'removed' when dispatching event. * 2) Adds all listener items that have been marked as 'added' when dispatching event. */ void updateListeners(Event* event); /** Touch event needs to be processed different with other events since it needs support ALL_AT_ONCE and ONE_BY_NONE mode. */ void dispatchTouchEvent(EventTouch* event); /** Associates node with event listener */ void associateNodeAndEventListener(Node* node, EventListener* listener); /** Dissociates node with event listener */ void dissociateNodeAndEventListener(Node* node, EventListener* listener); /** Dispatches event to listeners with a specified listener type */ void dispatchEventToListeners(EventListenerVector* listeners, std::function onEvent); /// Priority dirty flag enum class DirtyFlag { NONE = 0, FIXED_PRIORITY = 1 << 0, SCENE_GRAPH_PRIORITY = 1 << 1, ALL = FIXED_PRIORITY | SCENE_GRAPH_PRIORITY }; /** Sets the dirty flag for a specified listener ID */ void setDirty(const EventListener::ListenerID& listenerID, DirtyFlag flag); /** Walks though scene graph to get the draw order for each node, it's called before sorting event listener with scene graph priority */ void visitTarget(Node* node, bool isRootNode); /** Listeners map */ std::unordered_map _listeners; /** The map of dirty flag */ std::unordered_map _priorityDirtyFlagMap; /** The map of node and event listeners */ std::unordered_map*> _nodeListenersMap; /** The map of node and its event priority */ std::unordered_map _nodePriorityMap; /** key: Global Z Order, value: Sorted Nodes */ std::unordered_map> _globalZOrderNodeMap; /** The listeners to be added after dispatching event */ std::vector _toAddedListeners; /** The nodes were associated with scene graph based priority listeners */ std::set _dirtyNodes; /** Whether the dispatcher is dispatching event */ int _inDispatch; /** Whether to enable dispatching event */ bool _isEnabled; int _nodePriorityIndex; }; NS_CC_END #endif // __CC_EVENT_DISPATCHER_H__ ================================================ FILE: cocos2d/cocos/2d/CCEventKeyboard.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventKeyboard.h" NS_CC_BEGIN EventKeyboard::EventKeyboard(KeyCode keyCode, bool isPressed) : Event(Type::KEYBOARD) , _keyCode(keyCode) , _isPressed(isPressed) {} NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventKeyboard.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__CCKeyboardEvent__ #define __cocos2d_libs__CCKeyboardEvent__ #include "CCEvent.h" NS_CC_BEGIN class EventKeyboard : public Event { public: /** * The key (code). */ enum class KeyCode { KEY_NONE = 0, KEY_PAUSE = 0x0013, KEY_SCROLL_LOCK = 0x1014, KEY_PRINT = 0x1061, KEY_SYSREQ = 0x106A, KEY_BREAK = 0x106B, KEY_ESCAPE = 0x001B, KEY_BACKSPACE = 0x0008, KEY_TAB = 0x0009, KEY_BACK_TAB = 0x0089, KEY_RETURN = 0x000D, KEY_CAPS_LOCK = 0x00E5, KEY_SHIFT = 0x00E1, KEY_CTRL = 0x00E3, KEY_ALT = 0x00E9, KEY_MENU = 0x1067, KEY_HYPER = 0x10ED, KEY_INSERT = 0x1063, KEY_HOME = 0x1050, KEY_PG_UP = 0x1055, KEY_DELETE = 0x10FF, KEY_END = 0x1057, KEY_PG_DOWN = 0x1056, KEY_LEFT_ARROW = 0x1051, KEY_RIGHT_ARROW = 0x1053, KEY_UP_ARROW = 0x1052, KEY_DOWN_ARROW = 0x1054, KEY_NUM_LOCK = 0x107F, KEY_KP_PLUS = 0x10AB, KEY_KP_MINUS = 0x10AD, KEY_KP_MULTIPLY = 0x10AA, KEY_KP_DIVIDE = 0x10AF, KEY_KP_ENTER = 0x108D, KEY_KP_HOME = 0x10B7, KEY_KP_UP = 0x10B8, KEY_KP_PG_UP = 0x10B9, KEY_KP_LEFT = 0x10B4, KEY_KP_FIVE = 0x10B5, KEY_KP_RIGHT = 0x10B6, KEY_KP_END = 0x10B1, KEY_KP_DOWN = 0x10B2, KEY_KP_PG_DOWN = 0x10B3, KEY_KP_INSERT = 0x10B0, KEY_KP_DELETE = 0x10AE, KEY_F1 = 0x00BE, KEY_F2 = 0x00BF, KEY_F3 = 0x00C0, KEY_F4 = 0x00C1, KEY_F5 = 0x00C2, KEY_F6 = 0x00C3, KEY_F7 = 0x00C4, KEY_F8 = 0x00C5, KEY_F9 = 0x00C6, KEY_F10 = 0x00C7, KEY_F11 = 0x00C8, KEY_F12 = 0x00C9, KEY_SPACE = ' ', KEY_EXCLAM = '!', KEY_QUOTE = '"', KEY_NUMBER = '#', KEY_DOLLAR = '$', KEY_PERCENT = '%', KEY_CIRCUMFLEX = '^', KEY_AMPERSAND = '&', KEY_APOSTROPHE = '\'', KEY_LEFT_PARENTHESIS = '(', KEY_RIGHT_PARENTHESIS = ')', KEY_ASTERISK = '*', KEY_PLUS = '+', KEY_COMMA = ',', KEY_MINUS = '-', KEY_PERIOD = '.', KEY_SLASH = '/', KEY_0 = '0', KEY_1 = '1', KEY_2 = '2', KEY_3 = '3', KEY_4 = '4', KEY_5 = '5', KEY_6 = '6', KEY_7 = '7', KEY_8 = '8', KEY_9 = '9', KEY_COLON = ':', KEY_SEMICOLON = ';', KEY_LESS_THAN = '<', KEY_EQUAL = '=', KEY_GREATER_THAN = '>', KEY_QUESTION = '?', KEY_AT = '@', KEY_CAPITAL_A = 'A', KEY_CAPITAL_B = 'B', KEY_CAPITAL_C = 'C', KEY_CAPITAL_D = 'D', KEY_CAPITAL_E = 'E', KEY_CAPITAL_F = 'F', KEY_CAPITAL_G = 'G', KEY_CAPITAL_H = 'H', KEY_CAPITAL_I = 'I', KEY_CAPITAL_J = 'J', KEY_CAPITAL_K = 'K', KEY_CAPITAL_L = 'L', KEY_CAPITAL_M = 'M', KEY_CAPITAL_N = 'N', KEY_CAPITAL_O = 'O', KEY_CAPITAL_P = 'P', KEY_CAPITAL_Q = 'Q', KEY_CAPITAL_R = 'R', KEY_CAPITAL_S = 'S', KEY_CAPITAL_T = 'T', KEY_CAPITAL_U = 'U', KEY_CAPITAL_V = 'V', KEY_CAPITAL_W = 'W', KEY_CAPITAL_X = 'X', KEY_CAPITAL_Y = 'Y', KEY_CAPITAL_Z = 'Z', KEY_LEFT_BRACKET = '[', KEY_BACK_SLASH = '\\', KEY_RIGHT_BRACKET = ']', KEY_UNDERSCORE = '_', KEY_GRAVE = '`', KEY_A = 'a', KEY_B = 'b', KEY_C = 'c', KEY_D = 'd', KEY_E = 'e', KEY_F = 'f', KEY_G = 'g', KEY_H = 'h', KEY_I = 'i', KEY_J = 'j', KEY_K = 'k', KEY_L = 'l', KEY_M = 'm', KEY_N = 'n', KEY_O = 'o', KEY_P = 'p', KEY_Q = 'q', KEY_R = 'r', KEY_S = 's', KEY_T = 't', KEY_U = 'u', KEY_V = 'v', KEY_W = 'w', KEY_X = 'x', KEY_Y = 'y', KEY_Z = 'z', KEY_LEFT_BRACE = '{', KEY_BAR = '|', KEY_RIGHT_BRACE = '}', KEY_TILDE = '~', KEY_EURO = 0x20AC, KEY_POUND = 0x00A3, KEY_YEN = 0x00A5, KEY_MIDDLE_DOT = 0x0095, KEY_SEARCH = 0xFFAA }; EventKeyboard(KeyCode keyCode, bool isPressed); private: KeyCode _keyCode; bool _isPressed; friend class EventListenerKeyboard; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCKeyboardEvent__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventListener.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventListener.h" #include "platform/CCCommon.h" NS_CC_BEGIN EventListener::EventListener() {} EventListener::~EventListener() { CCLOGINFO("In the destructor of EventListener. %p", this); } bool EventListener::init(Type t, ListenerID listenerID, std::function callback) { _onEvent = callback; _type = t; _listenerID = listenerID; _isRegistered = false; _paused = true; return true; } bool EventListener::checkAvailable() { return (_onEvent != nullptr); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventListener.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef cocos2d_libs_EventListener_h #define cocos2d_libs_EventListener_h #include "CCPlatformMacros.h" #include "CCObject.h" #include #include #include #include NS_CC_BEGIN class Event; class Node; /** * The base class of event listener. * If you need custom listener which with different callback, you need to inherit this class. * For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard, EventListenerTouchOneByOne, EventListenerCustom. */ class EventListener : public Object { public: enum class Type { UNKNOWN, TOUCH_ONE_BY_ONE, TOUCH_ALL_AT_ONCE, KEYBOARD, MOUSE, ACCELERATION, CUSTOM }; typedef std::string ListenerID; protected: /** Constructor */ EventListener(); /** Initializes event with type and callback function */ bool init(Type t, ListenerID listenerID, std::functioncallback); public: /** Destructor */ virtual ~EventListener(); /** Checks whether the listener is available. */ virtual bool checkAvailable() = 0; /** Clones the listener, its subclasses have to override this method. */ virtual EventListener* clone() = 0; protected: inline void setPaused(bool paused) { _paused = paused; }; inline bool isPaused() const { return _paused; }; inline void setRegistered(bool registered) { _isRegistered = registered; }; inline bool isRegistered() const { return _isRegistered; }; inline Type getType() const { return _type; }; inline const ListenerID& getListenerID() const { return _listenerID; }; inline void setFixedPriority(int fixedPriority) { _fixedPriority = fixedPriority; }; inline int getFixedPriority() const { return _fixedPriority; }; inline void setSceneGraphPriority(Node* node) { _node = node; }; inline Node* getSceneGraphPriority() const { return _node; }; std::function _onEvent; /// Event callback function Type _type; /// Event listener type ListenerID _listenerID; /// Event listener ID bool _isRegistered; /// Whether the listener has been added to dispatcher. // The priority of event listener int _fixedPriority; // The higher the number, the higher the priority, 0 is for scene graph base priority. Node* _node; // scene graph based priority bool _paused; // Whether the listener is paused friend class EventDispatcher; }; NS_CC_END #endif ================================================ FILE: cocos2d/cocos/2d/CCEventListenerAcceleration.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventListenerAcceleration.h" #include "CCEventAcceleration.h" NS_CC_BEGIN const std::string EventListenerAcceleration::LISTENER_ID = "__cc_acceleration"; EventListenerAcceleration::EventListenerAcceleration() { } EventListenerAcceleration::~EventListenerAcceleration() { CCLOGINFO("In the destructor of AccelerationEventListener. %p", this); } EventListenerAcceleration* EventListenerAcceleration::create(std::function callback) { EventListenerAcceleration* ret = new EventListenerAcceleration(); if (ret && ret->init(callback)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool EventListenerAcceleration::init(std::function callback) { auto listener = [this](Event* event){ auto accEvent = static_cast(event); this->onAccelerationEvent(&accEvent->_acc, event); }; if (EventListener::init(Type::ACCELERATION, LISTENER_ID, listener)) { onAccelerationEvent = callback; return true; } return false; } EventListenerAcceleration* EventListenerAcceleration::clone() { auto ret = new EventListenerAcceleration(); if (ret && ret->init(onAccelerationEvent)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool EventListenerAcceleration::checkAvailable() { CCASSERT(onAccelerationEvent, ""); return true; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventListenerAcceleration.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__CCAccelerometerListener__ #define __cocos2d_libs__CCAccelerometerListener__ #include "CCEventListener.h" #include "ccTypes.h" NS_CC_BEGIN class EventListenerAcceleration : public EventListener { public: static const std::string LISTENER_ID; static EventListenerAcceleration* create(std::function callback); virtual ~EventListenerAcceleration(); /// Overrides virtual EventListenerAcceleration* clone() override; virtual bool checkAvailable() override; private: EventListenerAcceleration(); bool init(std::function callback); std::function onAccelerationEvent; friend class LuaEventListenerAcceleration; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCAccelerometerListener__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventListenerCustom.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventListenerCustom.h" #include "CCEventCustom.h" NS_CC_BEGIN EventListenerCustom::EventListenerCustom() : _onCustomEvent(nullptr) { } EventListenerCustom* EventListenerCustom::create(const std::string& eventName, std::function callback) { EventListenerCustom* ret = new EventListenerCustom(); if (ret && ret->init(eventName, callback)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool EventListenerCustom::init(ListenerID listenerId, std::functioncallback) { bool ret = false; _onCustomEvent = callback; auto listener = [this](Event* event){ if (_onCustomEvent != nullptr) { _onCustomEvent(static_cast(event)); } }; if (EventListener::init(EventListener::Type::CUSTOM, listenerId, listener)) { ret = true; } return ret; } EventListenerCustom* EventListenerCustom::clone() { EventListenerCustom* ret = new EventListenerCustom(); if (ret && ret->init(_listenerID, _onCustomEvent)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool EventListenerCustom::checkAvailable() { bool ret = false; if (EventListener::checkAvailable() && _onCustomEvent != nullptr) { ret = true; } return ret; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventListenerCustom.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__CCCustomEventListener__ #define __cocos2d_libs__CCCustomEventListener__ #include "CCEventListener.h" NS_CC_BEGIN class EventCustom; /** * Usage: * auto dispatcher = Director::getInstance()->getEventDispatcher(); * Adds a listener: * * auto callback = [](EventCustom* event){ do_some_thing(); }; * auto listener = EventListenerCustom::create(callback); * dispatcher->addEventListenerWithSceneGraphPriority(listener, one_node); * * Dispatchs a custom event: * * EventCustom event("your_event_type"); * dispatcher->dispatchEvent(&event); * * Removes a listener * * dispatcher->removeEventListener(listener); */ class EventListenerCustom : public EventListener { public: /** Creates an event listener with type and callback. * @param eventType The type of the event. * @param callback The callback function when the specified event was emitted. */ static EventListenerCustom* create(const std::string& eventName, std::function callback); /// Overrides virtual bool checkAvailable() override; virtual EventListenerCustom* clone() override; protected: /** Constructor */ EventListenerCustom(); /** Initializes event with type and callback function */ bool init(ListenerID listenerId, std::function callback); std::function _onCustomEvent; friend class LuaEventListenerCustom; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCCustomEventListener__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventListenerKeyboard.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventListenerKeyboard.h" #include "CCEventKeyboard.h" #include "ccMacros.h" NS_CC_BEGIN const std::string EventListenerKeyboard::LISTENER_ID = "__cc_keyboard"; bool EventListenerKeyboard::checkAvailable() { if (onKeyPressed == nullptr && onKeyReleased == nullptr) { CCASSERT(false, "Invalid EventListenerKeyboard!"); return false; } return true; } EventListenerKeyboard* EventListenerKeyboard::create() { auto ret = new EventListenerKeyboard(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } EventListenerKeyboard* EventListenerKeyboard::clone() { auto ret = new EventListenerKeyboard(); if (ret && ret->init()) { ret->autorelease(); ret->onKeyPressed = onKeyPressed; ret->onKeyReleased = onKeyReleased; } else { CC_SAFE_DELETE(ret); } return ret; } EventListenerKeyboard::EventListenerKeyboard() : onKeyPressed(nullptr) , onKeyReleased(nullptr) { } bool EventListenerKeyboard::init() { auto listener = [this](Event* event){ auto keyboardEvent = static_cast(event); if (keyboardEvent->_isPressed) { if (onKeyPressed != nullptr) onKeyPressed(keyboardEvent->_keyCode, event); } else { if (onKeyReleased != nullptr) onKeyReleased(keyboardEvent->_keyCode, event); } }; if (EventListener::init(Type::KEYBOARD, LISTENER_ID, listener)) { return true; } return false; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventListenerKeyboard.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__CCKeyboardEventListener__ #define __cocos2d_libs__CCKeyboardEventListener__ #include "CCEventListener.h" #include "CCEventKeyboard.h" NS_CC_BEGIN class Event; class EventListenerKeyboard : public EventListener { public: static const std::string LISTENER_ID; static EventListenerKeyboard* create(); /// Overrides virtual EventListenerKeyboard* clone() override; virtual bool checkAvailable() override; std::function onKeyPressed; std::function onKeyReleased; private: EventListenerKeyboard(); bool init(); }; NS_CC_END #endif /* defined(__cocos2d_libs__CCKeyboardEventListener__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventListenerMouse.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventListenerMouse.h" NS_CC_BEGIN const std::string EventListenerMouse::LISTENER_ID = "__cc_mouse"; bool EventListenerMouse::checkAvailable() { return true; } EventListenerMouse* EventListenerMouse::create() { auto ret = new EventListenerMouse(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } EventListenerMouse* EventListenerMouse::clone() { auto ret = new EventListenerMouse(); if (ret && ret->init()) { ret->autorelease(); ret->onMouseUp = onMouseUp; ret->onMouseDown = onMouseDown; ret->onMouseMove = onMouseMove; ret->onMouseScroll = onMouseScroll; } else { CC_SAFE_DELETE(ret); } return ret; } EventListenerMouse::EventListenerMouse() : onMouseDown(nullptr) , onMouseUp(nullptr) , onMouseMove(nullptr) , onMouseScroll(nullptr) { } bool EventListenerMouse::init() { auto listener = [this](Event* event){ auto mouseEvent = static_cast(event); switch (mouseEvent->_mouseEventType) { case EventMouse::MouseEventType::MOUSE_DOWN: if(onMouseDown != nullptr) onMouseDown(event); break; case EventMouse::MouseEventType::MOUSE_UP: if(onMouseUp != nullptr) onMouseUp(event); break; case EventMouse::MouseEventType::MOUSE_MOVE: if(onMouseMove != nullptr) onMouseMove(event); break; case EventMouse::MouseEventType::MOUSE_SCROLL: if(onMouseScroll != nullptr) onMouseScroll(event); break; default: break; } }; if (EventListener::init(Type::MOUSE, LISTENER_ID, listener)) { return true; } return false; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventListenerMouse.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventListener.h" #include "CCEventMouse.h" #ifndef __cocos2d_libs__CCMouseEventListener__ #define __cocos2d_libs__CCMouseEventListener__ NS_CC_BEGIN class Event; class EventListenerMouse : public EventListener { public: static const std::string LISTENER_ID; static EventListenerMouse* create(); /// Overrides virtual EventListenerMouse* clone() override; virtual bool checkAvailable() override; std::function onMouseDown; std::function onMouseUp; std::function onMouseMove; std::function onMouseScroll; private: EventListenerMouse(); bool init(); }; NS_CC_END #endif /* defined(__cocos2d_libs__CCMouseEventListener__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventListenerTouch.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventListenerTouch.h" #include "CCEventDispatcher.h" #include "CCEventTouch.h" #include NS_CC_BEGIN const std::string EventListenerTouchOneByOne::LISTENER_ID = "__cc_touch_one_by_one"; EventListenerTouchOneByOne::EventListenerTouchOneByOne() : onTouchBegan(nullptr) , onTouchMoved(nullptr) , onTouchEnded(nullptr) , onTouchCancelled(nullptr) , _needSwallow(false) { } EventListenerTouchOneByOne::~EventListenerTouchOneByOne() { CCLOGINFO("In the destructor of EventListenerTouchOneByOne, %p", this); } bool EventListenerTouchOneByOne::init() { if (EventListener::init(Type::TOUCH_ONE_BY_ONE, LISTENER_ID, nullptr)) { return true; } return false; } void EventListenerTouchOneByOne::setSwallowTouches(bool needSwallow) { _needSwallow = needSwallow; } EventListenerTouchOneByOne* EventListenerTouchOneByOne::create() { auto ret = new EventListenerTouchOneByOne(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool EventListenerTouchOneByOne::checkAvailable() { if (onTouchBegan == nullptr) { CCASSERT(false, "Invalid EventListenerTouchOneByOne!"); return false; } return true; } EventListenerTouchOneByOne* EventListenerTouchOneByOne::clone() { auto ret = new EventListenerTouchOneByOne(); if (ret && ret->init()) { ret->autorelease(); ret->onTouchBegan = onTouchBegan; ret->onTouchMoved = onTouchMoved; ret->onTouchEnded = onTouchEnded; ret->onTouchCancelled = onTouchCancelled; ret->_claimedTouches = _claimedTouches; ret->_needSwallow = _needSwallow; } else { CC_SAFE_DELETE(ret); } return ret; } ///////// const std::string EventListenerTouchAllAtOnce::LISTENER_ID = "__cc_touch_all_at_once"; EventListenerTouchAllAtOnce::EventListenerTouchAllAtOnce() : onTouchesBegan(nullptr) , onTouchesMoved(nullptr) , onTouchesEnded(nullptr) , onTouchesCancelled(nullptr) { } EventListenerTouchAllAtOnce::~EventListenerTouchAllAtOnce() { CCLOGINFO("In the destructor of EventListenerTouchAllAtOnce, %p", this); } bool EventListenerTouchAllAtOnce::init() { if (EventListener::init(Type::TOUCH_ALL_AT_ONCE, LISTENER_ID, nullptr)) { return true; } return false; } EventListenerTouchAllAtOnce* EventListenerTouchAllAtOnce::create() { auto ret = new EventListenerTouchAllAtOnce(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool EventListenerTouchAllAtOnce::checkAvailable() { if (onTouchesBegan == nullptr && onTouchesMoved == nullptr && onTouchesEnded == nullptr && onTouchesCancelled == nullptr) { CCASSERT(false, "Invalid EventListenerTouchAllAtOnce!"); return false; } return true; } EventListenerTouchAllAtOnce* EventListenerTouchAllAtOnce::clone() { auto ret = new EventListenerTouchAllAtOnce(); if (ret && ret->init()) { ret->autorelease(); ret->onTouchesBegan = onTouchesBegan; ret->onTouchesMoved = onTouchesMoved; ret->onTouchesEnded = onTouchesEnded; ret->onTouchesCancelled = onTouchesCancelled; } else { CC_SAFE_DELETE(ret); } return ret; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventListenerTouch.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__CCTouchEventListener__ #define __cocos2d_libs__CCTouchEventListener__ #include "CCEventListener.h" #include "CCTouch.h" #include NS_CC_BEGIN class EventListenerTouchOneByOne : public EventListener { public: static const std::string LISTENER_ID; static EventListenerTouchOneByOne* create(); virtual ~EventListenerTouchOneByOne(); void setSwallowTouches(bool needSwallow); /// Overrides virtual EventListenerTouchOneByOne* clone() override; virtual bool checkAvailable() override; // public: std::function onTouchBegan; std::function onTouchMoved; std::function onTouchEnded; std::function onTouchCancelled; private: EventListenerTouchOneByOne(); bool init(); std::vector _claimedTouches; bool _needSwallow; friend class EventDispatcher; }; class EventListenerTouchAllAtOnce : public EventListener { public: static const std::string LISTENER_ID; static EventListenerTouchAllAtOnce* create(); virtual ~EventListenerTouchAllAtOnce(); /// Overrides virtual EventListenerTouchAllAtOnce* clone() override; virtual bool checkAvailable() override; // public: std::function&, Event*)> onTouchesBegan; std::function&, Event*)> onTouchesMoved; std::function&, Event*)> onTouchesEnded; std::function&, Event*)> onTouchesCancelled; private: EventListenerTouchAllAtOnce(); bool init(); private: friend class EventDispatcher; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCTouchEventListener__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventMouse.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventMouse.h" NS_CC_BEGIN EventMouse::EventMouse(MouseEventType mouseEventCode) : Event(Type::MOUSE) , _mouseEventType(mouseEventCode) , _mouseButton(0) , _x(0.0f) , _y(0.0f) , _scrollX(0.0f) , _scrollY(0.0f) { }; NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventMouse.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__CCMouseEvent__ #define __cocos2d_libs__CCMouseEvent__ #include "CCEvent.h" #define MOUSE_BUTTON_LEFT 0 #define MOUSE_BUTTON_RIGHT 1 #define MOUSE_BUTTON_MIDDLE 2 #define MOUSE_BUTTON_4 3 #define MOUSE_BUTTON_5 4 #define MOUSE_BUTTON_6 5 #define MOUSE_BUTTON_7 6 #define MOUSE_BUTTON_8 7 NS_CC_BEGIN class EventMouse : public Event { public: /** * Different types of MouseEvent */ enum class MouseEventType { MOUSE_NONE, MOUSE_DOWN, MOUSE_UP, MOUSE_MOVE, MOUSE_SCROLL, }; EventMouse(MouseEventType mouseEventCode); /** Set mouse scroll data */ inline void setScrollData(float scrollX, float scrollY) { _scrollX = scrollX; _scrollY = scrollY; }; inline float getScrollX() { return _scrollX; }; inline float getScrollY() { return _scrollY; }; inline void setCursorPosition(float x, float y) { _x = x; _y = y; }; inline void setMouseButton(int button) { _mouseButton = button; }; inline int getMouseButton() { return _mouseButton; }; inline float getCursorX() { return _x; }; inline float getCursorY() { return _y; }; private: MouseEventType _mouseEventType; int _mouseButton; float _x; float _y; float _scrollX; float _scrollY; friend class EventListenerMouse; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCMouseEvent__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventTouch.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEventTouch.h" NS_CC_BEGIN EventTouch::EventTouch() : Event(Type::TOUCH) { _touches.reserve(MAX_TOUCHES); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCEventTouch.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __cocos2d_libs__TouchEvent__ #define __cocos2d_libs__TouchEvent__ #include "CCEvent.h" #include "CCTouch.h" #include NS_CC_BEGIN #define TOUCH_PERF_DEBUG 1 class EventTouch : public Event { public: static const int MAX_TOUCHES = 5; enum class EventCode { BEGAN, MOVED, ENDED, CANCELLED }; EventTouch(); EventCode getEventCode() { return _eventCode; }; std::vector getTouches() { return _touches; }; #if TOUCH_PERF_DEBUG void setEventCode(EventCode eventCode) { _eventCode = eventCode; }; void setTouches(const std::vector& touches) { _touches = touches; }; #endif private: EventCode _eventCode; std::vector _touches; friend class EGLViewProtocol; }; NS_CC_END #endif /* defined(__cocos2d_libs__TouchEvent__) */ ================================================ FILE: cocos2d/cocos/2d/CCEventType.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCEVENT_TYPE_H__ #define __CCEVENT_TYPE_H__ /** * This header is used for defining event types using in NotificationCenter */ // The application will come to foreground. // This message is used for reloading resources before come to foreground on Android. // This message is posted in main.cpp. #define EVENT_COME_TO_FOREGROUND "event_come_to_foreground" // The application will come to background. // This message is used for doing something before coming to background, such as save RenderTexture. // This message is posted in cocos2dx/platform/android/jni/MessageJni.cpp. #define EVENT_COME_TO_BACKGROUND "event_come_to_background" #endif // __CCEVENT_TYPE_H__ ================================================ FILE: cocos2d/cocos/2d/CCFont.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCFont.h" #include "ccUTF8.h" NS_CC_BEGIN const char * Font::_glyphASCII = "\"!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ "; const char * Font::_glyphNEHE = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ "; Font::Font() : _usedGlyphs(GlyphCollection::ASCII) , _customGlyphs(nullptr) { } const char * Font::getGlyphCollection(GlyphCollection glyphs) const { switch (glyphs) { case GlyphCollection::NEHE: return _glyphNEHE; break; case GlyphCollection::ASCII: return _glyphASCII; break; default: return 0; break; } } void Font::setCurrentGlyphCollection(GlyphCollection glyphs, const char *customGlyphs) { if (_customGlyphs) delete [] _customGlyphs; switch (glyphs) { case GlyphCollection::NEHE: _customGlyphs = 0; break; case GlyphCollection::ASCII: _customGlyphs = 0; break; default: if (customGlyphs) { size_t lenght = strlen(customGlyphs); _customGlyphs = new char [lenght + 2]; memcpy(_customGlyphs, customGlyphs, lenght); _customGlyphs[lenght] = 0; _customGlyphs[lenght+1] = 0; } break; } _usedGlyphs = glyphs; } const char * Font::getCurrentGlyphCollection() const { if (_customGlyphs) { return _customGlyphs; } else { return getGlyphCollection(_usedGlyphs); } } unsigned short* Font::getUTF16Text(const char *text, int &outNumLetters) const { unsigned short* utf16String = cc_utf8_to_utf16(text); if(!utf16String) return 0; outNumLetters = cc_wcslen(utf16String); return utf16String; } int Font::getUTF16TextLenght(unsigned short int *text) const { return cc_wcslen(text); } unsigned short * Font::trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const { if ( newBegin < 0 || newEnd <= 0 ) return 0; if ( newBegin >= newEnd ) return 0; if (newEnd >= cc_wcslen(text)) return 0; int newLenght = newEnd - newBegin + 2; unsigned short* trimmedString = new unsigned short[newLenght]; for(int c = 0; c < (newLenght - 1); ++c) { trimmedString[c] = text[newBegin + c]; } // last char trimmedString[newLenght-1] = 0x0000; // done return trimmedString; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCFont.h ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CCFont_h_ #define _CCFont_h_ #include #include "CCLabel.h" NS_CC_BEGIN // fwd class FontAtlas; class CC_DLL Font : public Object { public: virtual FontAtlas *createFontAtlas() = 0; virtual int* getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const = 0; virtual const char* getCurrentGlyphCollection() const; virtual unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const { return 0; } virtual int getFontMaxHeight() const { return 0; } virtual int getUTF16TextLenght(unsigned short int *text) const; virtual unsigned short * getUTF16Text(const char *text, int &outNumLetters) const; virtual unsigned short * trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const; protected: Font(); /** * @js NA * @lua NA */ virtual ~Font() {} void setCurrentGlyphCollection(GlyphCollection glyphs, const char *customGlyphs = 0); const char * getGlyphCollection(GlyphCollection glyphs) const; GlyphCollection _usedGlyphs; char * _customGlyphs; static const char * _glyphASCII; static const char * _glyphNEHE; }; NS_CC_END #endif ================================================ FILE: cocos2d/cocos/2d/CCFontAtlas.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCFontAtlas.h" #include "CCFontFreeType.h" #include "ccUTF8.h" #include "CCDirector.h" #define PAGE_WIDTH 1024 #define PAGE_HEIGHT 1024 NS_CC_BEGIN FontAtlas::FontAtlas(Font &theFont) : _font(&theFont), _currentPageData(nullptr) { _font->retain(); FontFreeType* fontTTf = dynamic_cast(_font); if (fontTTf) { _currentPageLineHeight = _font->getFontMaxHeight(); _commonLineHeight = _currentPageLineHeight * 0.8f; Texture2D * tex = new Texture2D; _currentPage = 0; _currentPageOrigX = 0; _currentPageOrigY = 0; _letterPadding = 0; _makeDistanceMap = fontTTf->isDistanceFieldEnabled(); if(_makeDistanceMap) { _commonLineHeight += 2 * FontFreeType::DistanceMapSpread; _letterPadding += 2 * FontFreeType::DistanceMapSpread; } _currentPageDataSize = (PAGE_WIDTH * PAGE_HEIGHT * 1); _currentPageData = new unsigned char[_currentPageDataSize]; memset(_currentPageData, 0, _currentPageDataSize); addTexture(*tex,0); tex->release(); } else { _makeDistanceMap = false; } } FontAtlas::~FontAtlas() { _font->release(); relaseTextures(); delete []_currentPageData; } void FontAtlas::relaseTextures() { for( auto &item: _atlasTextures) { item.second->release(); } } void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition) { _fontLetterDefinitions[letterDefinition.letteCharUTF16] = letterDefinition; } bool FontAtlas::getLetterDefinitionForChar(unsigned short letteCharUTF16, FontLetterDefinition &outDefinition) { auto outIterator = _fontLetterDefinitions.find(letteCharUTF16); if (outIterator != _fontLetterDefinitions.end()) { outDefinition = (*outIterator).second; return true; } else { outDefinition.validDefinition = false; return false; } } bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String) { if(_currentPageData == nullptr) return false; FontFreeType* fontTTf = (FontFreeType*)_font; std::unordered_map fontDefs; int length = cc_wcslen(utf16String); float offsetAdjust = _letterPadding / 2; //find out new letter for (int i = 0; i < length; ++i) { auto outIterator = _fontLetterDefinitions.find(utf16String[i]); if (outIterator == _fontLetterDefinitions.end()) { auto outIterator2 = fontDefs.find(utf16String[i]); if(outIterator2 != fontDefs.end()) continue; Rect tempRect; FontLetterDefinition tempDef; if (!fontTTf->getBBOXFotChar(utf16String[i], tempRect,tempDef.xAdvance)) { tempDef.validDefinition = false; tempDef.letteCharUTF16 = utf16String[i]; tempDef.width = 0; tempDef.height = 0; tempDef.U = 0; tempDef.V = 0; tempDef.offsetX = 0; tempDef.offsetY = 0; tempDef.textureID = 0; tempDef.xAdvance = 0; } else { tempDef.validDefinition = true; tempDef.letteCharUTF16 = utf16String[i]; tempDef.width = tempRect.size.width + _letterPadding; tempDef.height = tempRect.size.height + _letterPadding; tempDef.offsetX = tempRect.origin.x + offsetAdjust; tempDef.offsetY = _commonLineHeight + tempRect.origin.y - offsetAdjust; } fontDefs[utf16String[i]] = tempDef; } } Size _pageContentSize = Size(PAGE_WIDTH,PAGE_HEIGHT); float scaleFactor = CC_CONTENT_SCALE_FACTOR(); float glyphWidth; Texture2D::PixelFormat pixelFormat = Texture2D::PixelFormat::A8; for(auto it = fontDefs.begin(); it != fontDefs.end(); it++) { if(it->second.validDefinition) { glyphWidth = it->second.width; if (_currentPageOrigX + glyphWidth > PAGE_WIDTH) { _currentPageOrigY += _currentPageLineHeight; _currentPageOrigX = 0; if(_currentPageOrigY >= PAGE_HEIGHT) { _atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, PAGE_WIDTH, PAGE_HEIGHT, _pageContentSize ); _currentPageOrigY = 0; delete []_currentPageData; _currentPageData = new unsigned char[_currentPageDataSize]; if(_currentPageData == nullptr) return false; memset(_currentPageData, 0, _currentPageDataSize); _currentPage++; Texture2D* tex = new Texture2D; addTexture(*tex,_currentPage); tex->release(); } } fontTTf->renderCharAt(it->second.letteCharUTF16,_currentPageOrigX,_currentPageOrigY,_currentPageData,PAGE_WIDTH); it->second.U = _currentPageOrigX; it->second.V = _currentPageOrigY; it->second.textureID = _currentPage; // take from pixels to points it->second.width = it->second.width / scaleFactor; it->second.height = it->second.height / scaleFactor; it->second.U = it->second.U / scaleFactor; it->second.V = it->second.V / scaleFactor; } else glyphWidth = 0; _fontLetterDefinitions[it->second.letteCharUTF16] = it->second; _currentPageOrigX += glyphWidth + 1; } if(fontDefs.size() > 0) _atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, PAGE_WIDTH, PAGE_HEIGHT, _pageContentSize ); return true; } void FontAtlas::addTexture(Texture2D &texture, int slot) { texture.retain(); _atlasTextures[slot] = &texture; } Texture2D & FontAtlas::getTexture(int slot) { return *(_atlasTextures[slot]); } float FontAtlas::getCommonLineHeight() const { return _commonLineHeight; } void FontAtlas::setCommonLineHeight(float newHeight) { _commonLineHeight = newHeight; } const Font * FontAtlas::getFont() const { return _font; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCFontAtlas.h ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CCFontAtlas_h_ #define _CCFontAtlas_h_ #include #include "CCPlatformMacros.h" #include "CCObject.h" NS_CC_BEGIN //fwd class Font; class Texture2D; struct FontLetterDefinition { unsigned short letteCharUTF16; float U; float V; float width; float height; float offsetX; float offsetY; int textureID; bool validDefinition; int xAdvance; }; class CC_DLL FontAtlas : public Object { public: /** * @js ctor */ FontAtlas(Font &theFont); /** * @js NA * @lua NA */ virtual ~FontAtlas(); void addLetterDefinition(const FontLetterDefinition &letterDefinition); bool getLetterDefinitionForChar(unsigned short letteCharUTF16, FontLetterDefinition &outDefinition); bool prepareLetterDefinitions(unsigned short *utf16String); void addTexture(Texture2D &texture, int slot); float getCommonLineHeight() const; void setCommonLineHeight(float newHeight); Texture2D& getTexture(int slot); const Font* getFont() const; private: void relaseTextures(); std::unordered_map _atlasTextures; std::unordered_map _fontLetterDefinitions; float _commonLineHeight; Font * _font; // Dynamic GlyphCollection related stuff int _currentPage; unsigned char *_currentPageData; int _currentPageDataSize; float _currentPageOrigX; float _currentPageOrigY; float _currentPageLineHeight; float _letterPadding; bool _makeDistanceMap; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCFontAtlas__) */ ================================================ FILE: cocos2d/cocos/2d/CCFontAtlasCache.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include "CCFontAtlasCache.h" #include "CCFontFNT.h" #include "CCFontFreeType.h" #include "CCFontCharMap.h" NS_CC_BEGIN std::unordered_map FontAtlasCache::_atlasMap; FontAtlas * FontAtlasCache::getFontAtlasTTF(const std::string& fontFileName, int size, GlyphCollection glyphs, const char *customGlyphs, bool useDistanceField) { std::string atlasName = generateFontName(fontFileName, size, glyphs, useDistanceField); FontAtlas *tempAtlas = _atlasMap[atlasName]; if ( !tempAtlas ) { FontFreeType *font = FontFreeType::create(fontFileName, size, glyphs, customGlyphs); if (font) { font->setDistanceFieldEnabled(useDistanceField); tempAtlas = font->createFontAtlas(); if (tempAtlas) _atlasMap[atlasName] = tempAtlas; } else { return nullptr; } } else { tempAtlas->retain(); } return tempAtlas; } FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName) { std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false); FontAtlas *tempAtlas = _atlasMap[atlasName]; if ( !tempAtlas ) { Font *font = FontFNT::create(fontFileName); if(font) { tempAtlas = font->createFontAtlas(); if (tempAtlas) _atlasMap[atlasName] = tempAtlas; } else { return nullptr; } } else { tempAtlas->retain(); } return tempAtlas; } FontAtlas * FontAtlasCache::getFontAtlasCharMap(const std::string& plistFile) { std::string atlasName = generateFontName(plistFile, 0, GlyphCollection::CUSTOM,false); FontAtlas *tempAtlas = _atlasMap[atlasName]; if ( !tempAtlas ) { Font *font = FontCharMap::create(plistFile); if(font) { tempAtlas = font->createFontAtlas(); if (tempAtlas) _atlasMap[atlasName] = tempAtlas; } else { return nullptr; } } else { tempAtlas->retain(); } return tempAtlas; } FontAtlas * FontAtlasCache::getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap) { char tmp[30]; sprintf(tmp,"name:%u_%d_%d_%d",texture->getName(),itemWidth,itemHeight,startCharMap); std::string atlasName = generateFontName(tmp, 0, GlyphCollection::CUSTOM,false); FontAtlas *tempAtlas = _atlasMap[atlasName]; if ( !tempAtlas ) { Font *font = FontCharMap::create(texture,itemWidth,itemHeight,startCharMap); if(font) { tempAtlas = font->createFontAtlas(); if (tempAtlas) _atlasMap[atlasName] = tempAtlas; } else { return nullptr; } } else { tempAtlas->retain(); } return tempAtlas; } FontAtlas * FontAtlasCache::getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap) { std::string atlasName = generateFontName(charMapFile, 0, GlyphCollection::CUSTOM,false); FontAtlas *tempAtlas = _atlasMap[atlasName]; if ( !tempAtlas ) { Font *font = FontCharMap::create(charMapFile,itemWidth,itemHeight,startCharMap); if(font) { tempAtlas = font->createFontAtlas(); if (tempAtlas) _atlasMap[atlasName] = tempAtlas; } else { return nullptr; } } else { tempAtlas->retain(); } return tempAtlas; } std::string FontAtlasCache::generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField) { std::string tempName(fontFileName); switch (theGlyphs) { case GlyphCollection::DYNAMIC: tempName.append("_DYNAMIC_"); break; case GlyphCollection::NEHE: tempName.append("_NEHE_"); break; case GlyphCollection::ASCII: tempName.append("_ASCII_"); break; case GlyphCollection::CUSTOM: tempName.append("_CUSTOM_"); break; default: break; } if(useDistanceField) tempName.append("df"); // std::to_string is not supported on android, using std::stringstream instead. std::stringstream ss; ss << size; return tempName.append(ss.str()); } bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas) { if (nullptr != atlas) { for( auto &item: _atlasMap ) { if ( item.second == atlas ) { if (atlas->getReferenceCount() == 1) { _atlasMap.erase(item.first); } atlas->release(); return true; } } } return false; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCFontAtlasCache.h ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CCFontAtlasCache_h_ #define _CCFontAtlasCache_h_ #include #include #include "CCFontAtlas.h" #include "CCLabel.h" NS_CC_BEGIN class CC_DLL FontAtlasCache { public: static FontAtlas * getFontAtlasTTF(const std::string& fontFileName, int size, GlyphCollection glyphs, const char *customGlyphs = 0, bool useDistanceField = false); static FontAtlas * getFontAtlasFNT(const std::string& fontFileName); static FontAtlas * getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); static FontAtlas * getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap); static FontAtlas * getFontAtlasCharMap(const std::string& plistFile); static bool releaseFontAtlas(FontAtlas *atlas); private: static std::string generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField); static std::unordered_map _atlasMap; }; NS_CC_END #endif ================================================ FILE: cocos2d/cocos/2d/CCFontCharMap.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCFontCharMap.h" #include "CCFontAtlas.h" #include "platform/CCFileUtils.h" #include "CCDirector.h" #include "CCTextureCache.h" #include "ccUTF8.h" NS_CC_BEGIN FontCharMap * FontCharMap::create(const std::string& plistFile) { std::string pathStr = FileUtils::getInstance()->fullPathForFilename(plistFile); std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/"; ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(pathStr.c_str()); CCASSERT(dict["version"].asInt() == 1, "Unsupported version. Upgrade cocos2d version"); std::string textureFilename = relPathStr + dict["textureFilename"].asString(); unsigned int width = dict["itemWidth"].asInt() / CC_CONTENT_SCALE_FACTOR(); unsigned int height = dict["itemHeight"].asInt() / CC_CONTENT_SCALE_FACTOR(); unsigned int startChar = dict["firstChar"].asInt(); Texture2D *tempTexture = Director::getInstance()->getTextureCache()->addImage(textureFilename); if (!tempTexture) { return nullptr; } FontCharMap *tempFont = new FontCharMap(tempTexture,width,height,startChar); if (!tempFont) { return nullptr; } tempFont->autorelease(); return tempFont; } FontCharMap* FontCharMap::create(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap) { Texture2D *tempTexture = Director::getInstance()->getTextureCache()->addImage(charMapFile); if (!tempTexture) { return nullptr; } FontCharMap *tempFont = new FontCharMap(tempTexture,itemWidth,itemHeight,startCharMap); if (!tempFont) { return nullptr; } tempFont->autorelease(); return tempFont; } FontCharMap* FontCharMap::create(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap) { FontCharMap *tempFont = new FontCharMap(texture,itemWidth,itemHeight,startCharMap); if (!tempFont) { return nullptr; } tempFont->autorelease(); return tempFont; } FontCharMap::~FontCharMap() { } int * FontCharMap::getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const { if (!text) return 0; outNumLetters = cc_wcslen(text); if (!outNumLetters) return 0; int *sizes = new int[outNumLetters]; if (!sizes) return 0; for (int c = 0; c < outNumLetters; ++c) { sizes[c] = 0; } return sizes; } FontAtlas * FontCharMap::createFontAtlas() { FontAtlas *tempAtlas = new FontAtlas(*this); if (!tempAtlas) return nullptr; Size s = _texture->getContentSize(); int itemsPerColumn = (int)(s.height / _itemHeight); int itemsPerRow = (int)(s.width / _itemWidth); tempAtlas->setCommonLineHeight(_itemHeight); FontLetterDefinition tempDefinition; tempDefinition.textureID = 0; tempDefinition.offsetX = 0.0f; tempDefinition.offsetY = 0.0f; tempDefinition.validDefinition = true; tempDefinition.width = _itemWidth; tempDefinition.height = _itemHeight; tempDefinition.xAdvance = _itemWidth * CC_CONTENT_SCALE_FACTOR(); int charId = _mapStartChar; for (int row = 0; row < itemsPerColumn; ++row) { for (int col = 0; col < itemsPerRow; ++col) { tempDefinition.letteCharUTF16 = charId; tempDefinition.U = _itemWidth * col; tempDefinition.V = _itemHeight * row; tempAtlas->addLetterDefinition(tempDefinition); charId++; } } tempAtlas->addTexture(*_texture,0); return tempAtlas; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCFontCharMap.h ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CCFontCharMap_h_ #define _CCFontCharMap_h_ #include "CCFont.h" NS_CC_BEGIN class FontCharMap : public Font { public: static FontCharMap * create(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); static FontCharMap * create(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap); static FontCharMap * create(const std::string& plistFile); virtual int* getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const override; virtual FontAtlas *createFontAtlas() override; protected: FontCharMap(Texture2D* texture,int itemWidth, int itemHeight, int startCharMap) :_texture(texture) ,_mapStartChar(startCharMap) ,_itemWidth(itemWidth) ,_itemHeight(itemHeight) {} /** * @js NA * @lua NA */ virtual ~FontCharMap(); private: Texture2D* _texture; int _mapStartChar; int _itemWidth; int _itemHeight; }; NS_CC_END #endif /* defined(_CCFontCharMap_h_) */ ================================================ FILE: cocos2d/cocos/2d/CCFontFNT.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCFontFNT.h" #include "CCFontAtlas.h" #include "CCLabelBMFont.h" #include "CCDirector.h" #include "CCTextureCache.h" #include "ccUTF8.h" NS_CC_BEGIN FontFNT * FontFNT::create(const std::string& fntFilePath) { CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFilePath); if (!newConf) return nullptr; // add the texture Texture2D *tempTexture = Director::getInstance()->getTextureCache()->addImage(newConf->getAtlasName()); if (!tempTexture) { delete newConf; return nullptr; } FontFNT *tempFont = new FontFNT(newConf); if (!tempFont) { delete newConf; return nullptr; } tempFont->autorelease(); return tempFont; } FontFNT::~FontFNT() { } int * FontFNT::getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const { if (!text) return 0; outNumLetters = cc_wcslen(text); if (!outNumLetters) return 0; int *sizes = new int[outNumLetters]; if (!sizes) return 0; for (int c = 0; c < outNumLetters; ++c) { if (c < (outNumLetters-1)) sizes[c] = getHorizontalKerningForChars(text[c], text[c+1]); else sizes[c] = 0; } return sizes; } int FontFNT::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const { int ret = 0; unsigned int key = (firstChar << 16) | (secondChar & 0xffff); if (_configuration->_kerningDictionary) { tKerningHashElement *element = nullptr; HASH_FIND_INT(_configuration->_kerningDictionary, &key, element); if (element) ret = element->amount; } return ret; } FontAtlas * FontFNT::createFontAtlas() { FontAtlas *tempAtlas = new FontAtlas(*this); if (!tempAtlas) return nullptr; // check that everything is fine with the BMFontCofniguration if (!_configuration->_fontDefDictionary) return nullptr; size_t numGlyphs = _configuration->_characterSet->size(); if (!numGlyphs) return nullptr; if (_configuration->_commonHeight == 0) return nullptr; // commone height tempAtlas->setCommonLineHeight(_configuration->_commonHeight); ccBMFontDef fontDef; tFontDefHashElement *currentElement, *tmp; // Purge uniform hash HASH_ITER(hh, _configuration->_fontDefDictionary, currentElement, tmp) { FontLetterDefinition tempDefinition; fontDef = currentElement->fontDef; Rect tempRect; tempRect = fontDef.rect; tempRect = CC_RECT_PIXELS_TO_POINTS(tempRect); tempDefinition.letteCharUTF16 = fontDef.charID; tempDefinition.offsetX = fontDef.xOffset; tempDefinition.offsetY = fontDef.yOffset; tempDefinition.U = tempRect.origin.x; tempDefinition.V = tempRect.origin.y; tempDefinition.width = tempRect.size.width; tempDefinition.height = tempRect.size.height; //carloX: only one texture supported FOR NOW tempDefinition.textureID = 0; tempDefinition.validDefinition = true; tempDefinition.xAdvance = fontDef.xAdvance; // add the new definition tempAtlas->addLetterDefinition(tempDefinition); } // add the texture (only one texture for now) Texture2D *tempTexture = Director::getInstance()->getTextureCache()->addImage(_configuration->getAtlasName()); if (!tempTexture) return 0; // add the texture tempAtlas->addTexture(*tempTexture, 0); // done return tempAtlas; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCFontFNT.h ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CCFontFNT_h_ #define _CCFontFNT_h_ #include "CCFont.h" NS_CC_BEGIN class CCBMFontConfiguration; class FontFNT : public Font { public: static FontFNT * create(const std::string& fntFilePath); virtual int* getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const override; virtual FontAtlas *createFontAtlas() override; protected: FontFNT(CCBMFontConfiguration *theContfig) : _configuration(theContfig) {} /** * @js NA * @lua NA */ virtual ~FontFNT(); private: int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const; CCBMFontConfiguration * _configuration; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCFontFNT__) */ ================================================ FILE: cocos2d/cocos/2d/CCFontFreeType.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include #include "ccUTF8.h" #include "CCFontFreeType.h" #include "platform/CCFileUtils.h" #include "edtaa3func.h" NS_CC_BEGIN FT_Library FontFreeType::_FTlibrary; bool FontFreeType::_FTInitialized = false; const int FontFreeType::DistanceMapSpread = 3; FontFreeType * FontFreeType::create(const std::string &fontName, int fontSize, GlyphCollection glyphs, const char *customGlyphs) { FontFreeType *tempFont = new FontFreeType(); if (!tempFont) return nullptr; tempFont->setCurrentGlyphCollection(glyphs, customGlyphs); if (!tempFont->createFontObject(fontName, fontSize)) { delete tempFont; return nullptr; } return tempFont; } bool FontFreeType::initFreeType() { if (_FTInitialized == false) { // begin freetype if (FT_Init_FreeType( &_FTlibrary )) return false; _FTInitialized = true; } return _FTInitialized; } void FontFreeType::shutdownFreeType() { if (_FTInitialized == true) { FT_Done_FreeType(_FTlibrary); _FTInitialized = false; } } FT_Library FontFreeType::getFTLibrary() { initFreeType(); return _FTlibrary; } FontFreeType::FontFreeType() : _fontRef(nullptr) ,_distanceFieldEnabled(false) { } bool FontFreeType::createFontObject(const std::string &fontName, int fontSize) { FT_Face face; _ttfData = FileUtils::getInstance()->getDataFromFile(fontName); if (_ttfData.isNull()) return false; // create the face from the data if (FT_New_Memory_Face(getFTLibrary(), _ttfData.getBytes(), _ttfData.getSize(), 0, &face )) return false; //we want to use unicode if (FT_Select_Charmap(face, FT_ENCODING_UNICODE)) return false; // set the requested font size int dpi = 72; int fontSizePoints = (int)(64.f * fontSize); if (FT_Set_Char_Size(face, fontSizePoints, fontSizePoints, dpi, dpi)) return false; // store the face globally _fontRef = face; // save font name locally _fontName = fontName; // done and good return true; } FontFreeType::~FontFreeType() { if (_fontRef) { FT_Done_Face(_fontRef); } } FontAtlas * FontFreeType::createFontAtlas() { FontAtlas *atlas = new FontAtlas(*this); if (_usedGlyphs != GlyphCollection::DYNAMIC) { unsigned short* utf16 = cc_utf8_to_utf16(getCurrentGlyphCollection()); atlas->prepareLetterDefinitions(utf16); CC_SAFE_DELETE_ARRAY(utf16); } this->release(); return atlas; } bool FontFreeType::getBBOXFotChar(unsigned short theChar, Rect &outRect, int &xAdvance) const { if (!_fontRef) return false; // get the ID to the char we need int glyph_index = FT_Get_Char_Index(_fontRef, theChar); if (!glyph_index) return false; // load glyph infos if (FT_Load_Glyph(_fontRef, glyph_index, FT_LOAD_DEFAULT)) return false; // store result in the passed rectangle outRect.origin.x = _fontRef->glyph->metrics.horiBearingX >> 6; outRect.origin.y = - (_fontRef->glyph->metrics.horiBearingY >> 6); outRect.size.width = (_fontRef->glyph->metrics.width >> 6); outRect.size.height = (_fontRef->glyph->metrics.height >> 6); xAdvance = (static_cast(_fontRef->glyph->metrics.horiAdvance >> 6)); return true; } int * FontFreeType::getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const { if (!text) return 0; outNumLetters = cc_wcslen(text); if (!outNumLetters) return 0; int *sizes = new int[outNumLetters]; if (!sizes) return 0; for (int c = 0; c < outNumLetters; ++c) { if (c < (outNumLetters-1)) sizes[c] = getHorizontalKerningForChars(text[c], text[c+1]); else sizes[c] = 0; } return sizes; } int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const { if (!_fontRef) return 0; bool hasKerning = FT_HAS_KERNING( _fontRef ) != 0; if (!hasKerning) return 0; // get the ID to the char we need int glyphIndex1 = FT_Get_Char_Index(_fontRef, firstChar); if (!glyphIndex1) return 0; // get the ID to the char we need int glyphIndex2 = FT_Get_Char_Index(_fontRef, secondChar); if (!glyphIndex2) return 0; FT_Vector kerning; if (FT_Get_Kerning( _fontRef, glyphIndex1, glyphIndex2, FT_KERNING_DEFAULT, &kerning)) return 0; return (static_cast(kerning.x >> 6)); } int FontFreeType::getFontMaxHeight() const { return (static_cast(_fontRef->size->metrics.height >> 6)); } unsigned char * FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const { if (!_fontRef) return 0; if (_distanceFieldEnabled) { if (FT_Load_Char(_fontRef,theChar,FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT)) return 0; } else { if (FT_Load_Char(_fontRef,theChar,FT_LOAD_RENDER)) return 0; } outWidth = _fontRef->glyph->bitmap.width; outHeight = _fontRef->glyph->bitmap.rows; // return the pointer to the bitmap return _fontRef->glyph->bitmap.buffer; } unsigned char * makeDistanceMap( unsigned char *img, unsigned int width, unsigned int height) { unsigned int pixelAmount = (width + 2 * FontFreeType::DistanceMapSpread) * (height + 2 * FontFreeType::DistanceMapSpread); short * xdist = (short *) malloc( pixelAmount * sizeof(short) ); short * ydist = (short *) malloc( pixelAmount * sizeof(short) ); double * gx = (double *) calloc( pixelAmount, sizeof(double) ); double * gy = (double *) calloc( pixelAmount, sizeof(double) ); double * data = (double *) calloc( pixelAmount, sizeof(double) ); double * outside = (double *) calloc( pixelAmount, sizeof(double) ); double * inside = (double *) calloc( pixelAmount, sizeof(double) ); unsigned int i,j; // Convert img into double (data) rescale image levels between 0 and 1 unsigned int outWidth = width + 2 * FontFreeType::DistanceMapSpread; for (i = 0; i < width; ++i) { for (j = 0; j < height; ++j) { data[j * outWidth + FontFreeType::DistanceMapSpread + i] = img[j * width + i] / 255.0; } } width += 2 * FontFreeType::DistanceMapSpread; height += 2 * FontFreeType::DistanceMapSpread; // Transform background (outside contour, in areas of 0's) computegradient( data, width, height, gx, gy); edtaa3(data, gx, gy, width, height, xdist, ydist, outside); for( i=0; i< pixelAmount; i++) if( outside[i] < 0.0 ) outside[i] = 0.0; // Transform foreground (inside contour, in areas of 1's) for( i=0; i< pixelAmount; i++) data[i] = 1 - data[i]; computegradient( data, width, height, gx, gy); edtaa3(data, gx, gy, width, height, xdist, ydist, inside); for( i=0; i< pixelAmount; i++) if( inside[i] < 0.0 ) inside[i] = 0.0; // The bipolar distance field is now outside-inside double dist; /* Single channel 8-bit output (bad precision and range, but simple) */ unsigned char *out = (unsigned char *) malloc( pixelAmount * sizeof(unsigned char) ); for( i=0; i < pixelAmount; i++) { dist = outside[i] - inside[i]; dist = 128.0 - dist*16; if( dist < 0 ) dist = 0; if( dist > 255 ) dist = 255; out[i] = (unsigned char) dist; } /* Dual channel 16-bit output (more complicated, but good precision and range) */ /*unsigned char *out = (unsigned char *) malloc( pixelAmount * 3 * sizeof(unsigned char) ); for( i=0; i< pixelAmount; i++) { dist = outside[i] - inside[i]; dist = 128.0 - dist*16; if( dist < 0.0 ) dist = 0.0; if( dist >= 256.0 ) dist = 255.999; // R channel is a copy of the original grayscale image out[3*i] = img[i]; // G channel is fraction out[3*i + 1] = (unsigned char) ( 256 - (dist - floor(dist)* 256.0 )); // B channel is truncated integer part out[3*i + 2] = (unsigned char)dist; }*/ free( xdist ); free( ydist ); free( gx ); free( gy ); free( data ); free( outside ); free( inside ); return out; } void FontFreeType::setDistanceFieldEnabled(bool distanceFieldEnabled) { _distanceFieldEnabled = distanceFieldEnabled; } bool FontFreeType::renderCharAt(unsigned short int charToRender, int posX, int posY, unsigned char *destMemory, int destSize) { unsigned char *sourceBitmap = 0; int sourceWidth = 0; int sourceHeight = 0; sourceBitmap = getGlyphBitmap(charToRender, sourceWidth, sourceHeight); if (!sourceBitmap) return false; if (_distanceFieldEnabled) { unsigned char * out = makeDistanceMap(sourceBitmap,sourceWidth,sourceHeight); int iX = posX; int iY = posY; sourceWidth += 2 * DistanceMapSpread; sourceHeight += 2 * DistanceMapSpread; for (int y = 0; y < sourceHeight; ++y) { int bitmap_y = y * sourceWidth; for (int x = 0; x < sourceWidth; ++x) { /* Dual channel 16-bit output (more complicated, but good precision and range) */ /*int index = (iX + ( iY * destSize )) * 3; int index2 = (bitmap_y + x)*3; destMemory[index] = out[index2]; destMemory[index + 1] = out[index2 + 1]; destMemory[index + 2] = out[index2 + 2];*/ //Single channel 8-bit output destMemory[iX + ( iY * destSize )] = out[bitmap_y + x]; iX += 1; } iX = posX; iY += 1; } free(out); return true; } int iX = posX; int iY = posY; for (int y = 0; y < sourceHeight; ++y) { int bitmap_y = y * sourceWidth; for (int x = 0; x < sourceWidth; ++x) { unsigned char cTemp = sourceBitmap[bitmap_y + x]; // the final pixel destMemory[(iX + ( iY * destSize ) )] = cTemp; iX += 1; } iX = posX; iY += 1; } //everything good return true; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCFontFreeType.h ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _FontFreetype_h_ #define _FontFreetype_h_ #include "CCFont.h" #include "CCData.h" #include #include #include FT_FREETYPE_H NS_CC_BEGIN class CC_DLL FontFreeType : public Font { public: static const int DistanceMapSpread; static FontFreeType * create(const std::string &fontName, int fontSize, GlyphCollection glyphs, const char *customGlyphs); static void shutdownFreeType(); void setDistanceFieldEnabled(bool distanceFieldEnabled); bool isDistanceFieldEnabled() const { return _distanceFieldEnabled;} bool renderCharAt(unsigned short int charToRender, int posX, int posY, unsigned char *destMemory, int destSize); virtual FontAtlas * createFontAtlas() override; virtual int * getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const override; unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const override; virtual int getFontMaxHeight() const override; bool getBBOXFotChar(unsigned short theChar, Rect &outRect,int &xAdvance) const; protected: FontFreeType(); virtual ~FontFreeType(); bool createFontObject(const std::string &fontName, int fontSize); private: bool initFreeType(); FT_Library getFTLibrary(); int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const; static FT_Library _FTlibrary; static bool _FTInitialized; FT_Face _fontRef; std::string _fontName; Data _ttfData; bool _distanceFieldEnabled; }; NS_CC_END #endif ================================================ FILE: cocos2d/cocos/2d/CCGLBufferedNode.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCGLBufferedNode.h" GLBufferedNode::GLBufferedNode() { for(int i = 0; i < BUFFER_SLOTS; i++) { _bufferObject[i] = 0; _bufferSize[i] = 0; _indexBufferObject[i] = 0; _indexBufferSize[i] = 0; } } GLBufferedNode::~GLBufferedNode() { for(int i = 0; i < BUFFER_SLOTS; i++) { if(_bufferSize[i]) { glDeleteBuffers(1, &(_bufferObject[i])); } if(_indexBufferSize[i]) { glDeleteBuffers(1, &(_indexBufferObject[i])); } } } void GLBufferedNode::setGLBufferData(void *buf, GLuint bufSize, int slot) { // WebGL doesn't support client-side arrays, so generate a buffer and load the data first. if(_bufferSize[slot] < bufSize) { if(_bufferObject[slot]) { glDeleteBuffers(1, &(_bufferObject[slot])); } glGenBuffers(1, &(_bufferObject[slot])); _bufferSize[slot] = bufSize; glBindBuffer(GL_ARRAY_BUFFER, _bufferObject[slot]); glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_DYNAMIC_DRAW); } else { glBindBuffer(GL_ARRAY_BUFFER, _bufferObject[slot]); glBufferSubData(GL_ARRAY_BUFFER, 0, bufSize, buf); } } void GLBufferedNode::setGLIndexData(void *buf, GLuint bufSize, int slot) { // WebGL doesn't support client-side arrays, so generate a buffer and load the data first. if(_indexBufferSize[slot] < bufSize) { if(_indexBufferObject[slot]) { glDeleteBuffers(1, &(_indexBufferObject[slot])); } glGenBuffers(1, &(_indexBufferObject[slot])); _indexBufferSize[slot] = bufSize; glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBufferObject[slot]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, bufSize, buf, GL_DYNAMIC_DRAW); } else { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBufferObject[slot]); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, bufSize, buf); } } ================================================ FILE: cocos2d/cocos/2d/CCGLBufferedNode.h ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_GL_BUFFERED_NODE__ #define __CC_GL_BUFFERED_NODE__ #include "CCGL.h" class GLBufferedNode { public: /** * @js ctor */ GLBufferedNode(); /** * @js NA * @lua NA */ virtual ~GLBufferedNode(); /** * Load the given data into this Node's GL Buffer. Needed for WebGL, as it does not support client-side arrays. */ void setGLBufferData(void *buf, GLuint bufSize, int slot); void setGLIndexData(void *buf, GLuint bufSize, int slot); // We allocate 4 buffer objs per node, and index into them as slots. #define BUFFER_SLOTS 4 GLuint _bufferObject[BUFFER_SLOTS]; GLuint _bufferSize[BUFFER_SLOTS]; GLuint _indexBufferObject[BUFFER_SLOTS]; GLuint _indexBufferSize[BUFFER_SLOTS]; }; #endif // __CC_GL_BUFFERED_NODE__ ================================================ FILE: cocos2d/cocos/2d/CCGLProgram.cpp ================================================ /**************************************************************************** Copyright 2011 Jeff Lamarche Copyright 2012 Goffredo Marocchi Copyright 2012 Ricardo Quesada Copyright 2012 cocos2d-x.org Copyright 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN false 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 "CCDirector.h" #include "CCGLProgram.h" #include "ccGLStateCache.h" #include "ccMacros.h" #include "platform/CCFileUtils.h" #include "uthash.h" #include "CCString.h" // extern #include "kazmath/GL/matrix.h" #include "kazmath/kazmath.h" NS_CC_BEGIN typedef struct _hashUniformEntry { GLvoid* value; // value unsigned int location; // Key UT_hash_handle hh; // hash entry } tHashUniformEntry; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositionTextureColor_noMVP"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest"; const char* GLProgram::SHADER_NAME_POSITION_COLOR = "ShaderPositionColor"; const char* GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP = "ShaderPositionColor_noMVP"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR = "ShaderPositionTexture_uColor"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR = "ShaderPositionTextureA8Color"; const char* GLProgram::SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor"; const char* GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR = "ShaderPositionLengthTextureColor"; const char* GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL = "ShaderLabelNormol"; const char* GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW = "ShaderLabelGlow"; const char* GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_OUTLINE = "ShaderLabelOutline"; const char* GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_SHADOW = "ShaderLabelShadow"; // uniform names const char* GLProgram::UNIFORM_NAME_P_MATRIX = "CC_PMatrix"; const char* GLProgram::UNIFORM_NAME_MV_MATRIX = "CC_MVMatrix"; const char* GLProgram::UNIFORM_NAME_MVP_MATRIX = "CC_MVPMatrix"; const char* GLProgram::UNIFORM_NAME_TIME = "CC_Time"; const char* GLProgram::UNIFORM_NAME_SIN_TIME = "CC_SinTime"; const char* GLProgram::UNIFORM_NAME_COS_TIME = "CC_CosTime"; const char* GLProgram::UNIFORM_NAME_RANDOM01 = "CC_Random01"; const char* GLProgram::UNIFORM_NAME_SAMPLER = "CC_Texture0"; const char* GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE = "CC_alpha_value"; // Attribute names const char* GLProgram::ATTRIBUTE_NAME_COLOR = "a_color"; const char* GLProgram::ATTRIBUTE_NAME_POSITION = "a_position"; const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"; GLProgram::GLProgram() : _program(0) , _vertShader(0) , _fragShader(0) , _hashForUniforms(nullptr) , _flags() { memset(_uniforms, 0, sizeof(_uniforms)); } GLProgram::~GLProgram() { CCLOGINFO("%s %d deallocing GLProgram: %p", __FUNCTION__, __LINE__, this); // there is no need to delete the shaders. They should have been already deleted. CCASSERT(_vertShader == 0, "Vertex Shaders should have been already deleted"); CCASSERT(_fragShader == 0, "Fragment Shaders should have been already deleted"); if (_program) { GL::deleteProgram(_program); } tHashUniformEntry *current_element, *tmp; // Purge uniform hash HASH_ITER(hh, _hashForUniforms, current_element, tmp) { HASH_DEL(_hashForUniforms, current_element); free(current_element->value); free(current_element); } } bool GLProgram::initWithVertexShaderByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) { _program = glCreateProgram(); CHECK_GL_ERROR_DEBUG(); _vertShader = _fragShader = 0; if (vShaderByteArray) { if (!compileShader(&_vertShader, GL_VERTEX_SHADER, vShaderByteArray)) { CCLOG("cocos2d: ERROR: Failed to compile vertex shader"); } } // Create and compile fragment shader if (fShaderByteArray) { if (!compileShader(&_fragShader, GL_FRAGMENT_SHADER, fShaderByteArray)) { CCLOG("cocos2d: ERROR: Failed to compile fragment shader"); } } if (_vertShader) { glAttachShader(_program, _vertShader); } CHECK_GL_ERROR_DEBUG(); if (_fragShader) { glAttachShader(_program, _fragShader); } _hashForUniforms = nullptr; CHECK_GL_ERROR_DEBUG(); return true; } bool GLProgram::initWithVertexShaderFilename(const char* vShaderFilename, const char* fShaderFilename) { std::string vertexSource = FileUtils::getInstance()->getStringFromFile(FileUtils::getInstance()->fullPathForFilename(vShaderFilename).c_str()); std::string fragmentSource = FileUtils::getInstance()->getStringFromFile(FileUtils::getInstance()->fullPathForFilename(fShaderFilename).c_str()); return initWithVertexShaderByteArray(vertexSource.c_str(), fragmentSource.c_str()); } std::string GLProgram::getDescription() const { return StringUtils::format("", (size_t)this, _program, _vertShader, _fragShader); } bool GLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source) { GLint status; if (!source) { return false; } const GLchar *sources[] = { #if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_LINUX && CC_TARGET_PLATFORM != CC_PLATFORM_MAC) (type == GL_VERTEX_SHADER ? "precision highp float;\n" : "precision mediump float;\n"), #endif "uniform mat4 CC_PMatrix;\n" "uniform mat4 CC_MVMatrix;\n" "uniform mat4 CC_MVPMatrix;\n" "uniform vec4 CC_Time;\n" "uniform vec4 CC_SinTime;\n" "uniform vec4 CC_CosTime;\n" "uniform vec4 CC_Random01;\n" "//CC INCLUDES END\n\n", source, }; *shader = glCreateShader(type); glShaderSource(*shader, sizeof(sources)/sizeof(*sources), sources, nullptr); glCompileShader(*shader); glGetShaderiv(*shader, GL_COMPILE_STATUS, &status); if (! status) { GLsizei length; glGetShaderiv(*shader, GL_SHADER_SOURCE_LENGTH, &length); GLchar* src = (GLchar *)malloc(sizeof(GLchar) * length); glGetShaderSource(*shader, length, nullptr, src); CCLOG("cocos2d: ERROR: Failed to compile shader:\n%s", src); if (type == GL_VERTEX_SHADER) { CCLOG("cocos2d: %s", getVertexShaderLog().c_str()); } else { CCLOG("cocos2d: %s", getFragmentShaderLog().c_str()); } free(src); abort(); } return (status == GL_TRUE); } void GLProgram::addAttribute(const char* attributeName, GLuint index) { glBindAttribLocation(_program, index, attributeName); } void GLProgram::updateUniforms() { _uniforms[UNIFORM_P_MATRIX] = glGetUniformLocation(_program, UNIFORM_NAME_P_MATRIX); _uniforms[UNIFORM_MV_MATRIX] = glGetUniformLocation(_program, UNIFORM_NAME_MV_MATRIX); _uniforms[UNIFORM_MVP_MATRIX] = glGetUniformLocation(_program, UNIFORM_NAME_MVP_MATRIX); _uniforms[UNIFORM_TIME] = glGetUniformLocation(_program, UNIFORM_NAME_TIME); _uniforms[UNIFORM_SIN_TIME] = glGetUniformLocation(_program, UNIFORM_NAME_SIN_TIME); _uniforms[UNIFORM_COS_TIME] = glGetUniformLocation(_program, UNIFORM_NAME_COS_TIME); _uniforms[UNIFORM_RANDOM01] = glGetUniformLocation(_program, UNIFORM_NAME_RANDOM01); _uniforms[UNIFORM_SAMPLER] = glGetUniformLocation(_program, UNIFORM_NAME_SAMPLER); _flags.usesP = _uniforms[UNIFORM_P_MATRIX] != -1; _flags.usesMV = _uniforms[UNIFORM_MV_MATRIX] != -1; _flags.usesMVP = _uniforms[UNIFORM_MVP_MATRIX] != -1; _flags.usesTime = ( _uniforms[UNIFORM_TIME] != -1 || _uniforms[UNIFORM_SIN_TIME] != -1 || _uniforms[UNIFORM_COS_TIME] != -1 ); _flags.usesRandom = _uniforms[UNIFORM_RANDOM01] != -1; this->use(); // Since sample most probably won't change, set it to 0 now. this->setUniformLocationWith1i(_uniforms[UNIFORM_SAMPLER], 0); } bool GLProgram::link() { CCASSERT(_program != 0, "Cannot link invalid program"); GLint status = GL_TRUE; glLinkProgram(_program); if (_vertShader) { glDeleteShader(_vertShader); } if (_fragShader) { glDeleteShader(_fragShader); } _vertShader = _fragShader = 0; #if COCOS2D_DEBUG glGetProgramiv(_program, GL_LINK_STATUS, &status); if (status == GL_FALSE) { CCLOG("cocos2d: ERROR: Failed to link program: %i", _program); GL::deleteProgram(_program); _program = 0; } #endif return (status == GL_TRUE); } void GLProgram::use() { GL::useProgram(_program); } std::string GLProgram::logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const { std::string ret; GLint logLength = 0, charsWritten = 0; infoFunc(object, GL_INFO_LOG_LENGTH, &logLength); if (logLength < 1) return ""; char *logBytes = (char*)malloc(logLength); logFunc(object, logLength, &charsWritten, logBytes); ret = logBytes; free(logBytes); return ret; } std::string GLProgram::getVertexShaderLog() const { return this->logForOpenGLObject(_vertShader, (GLInfoFunction)&glGetShaderiv, (GLLogFunction)&glGetShaderInfoLog); } std::string GLProgram::getFragmentShaderLog() const { return this->logForOpenGLObject(_fragShader, (GLInfoFunction)&glGetShaderiv, (GLLogFunction)&glGetShaderInfoLog); } std::string GLProgram::getProgramLog() const { return this->logForOpenGLObject(_program, (GLInfoFunction)&glGetProgramiv, (GLLogFunction)&glGetProgramInfoLog); } // Uniform cache bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsigned int bytes) { if (location < 0) { return false; } bool updated = true; tHashUniformEntry *element = nullptr; HASH_FIND_INT(_hashForUniforms, &location, element); if (! element) { element = (tHashUniformEntry*)malloc( sizeof(*element) ); // key element->location = location; // value element->value = malloc( bytes ); memcpy(element->value, data, bytes ); HASH_ADD_INT(_hashForUniforms, location, element); } else { if (memcmp(element->value, data, bytes) == 0) { updated = false; } else { memcpy(element->value, data, bytes); } } return updated; } GLint GLProgram::getUniformLocationForName(const char* name) const { CCASSERT(name != nullptr, "Invalid uniform name" ); CCASSERT(_program != 0, "Invalid operation. Cannot get uniform location when program is not initialized"); return glGetUniformLocation(_program, name); } void GLProgram::setUniformLocationWith1i(GLint location, GLint i1) { bool updated = updateUniformLocation(location, &i1, sizeof(i1)*1); if( updated ) { glUniform1i( (GLint)location, i1); } } void GLProgram::setUniformLocationWith2i(GLint location, GLint i1, GLint i2) { GLint ints[2] = {i1,i2}; bool updated = updateUniformLocation(location, ints, sizeof(ints)); if( updated ) { glUniform2i( (GLint)location, i1, i2); } } void GLProgram::setUniformLocationWith3i(GLint location, GLint i1, GLint i2, GLint i3) { GLint ints[3] = {i1,i2,i3}; bool updated = updateUniformLocation(location, ints, sizeof(ints)); if( updated ) { glUniform3i( (GLint)location, i1, i2, i3); } } void GLProgram::setUniformLocationWith4i(GLint location, GLint i1, GLint i2, GLint i3, GLint i4) { GLint ints[4] = {i1,i2,i3,i4}; bool updated = updateUniformLocation(location, ints, sizeof(ints)); if( updated ) { glUniform4i( (GLint)location, i1, i2, i3, i4); } } void GLProgram::setUniformLocationWith2iv(GLint location, GLint* ints, unsigned int numberOfArrays) { bool updated = updateUniformLocation(location, ints, sizeof(int)*2*numberOfArrays); if( updated ) { glUniform2iv( (GLint)location, (GLsizei)numberOfArrays, ints ); } } void GLProgram::setUniformLocationWith3iv(GLint location, GLint* ints, unsigned int numberOfArrays) { bool updated = updateUniformLocation(location, ints, sizeof(int)*3*numberOfArrays); if( updated ) { glUniform3iv( (GLint)location, (GLsizei)numberOfArrays, ints ); } } void GLProgram::setUniformLocationWith4iv(GLint location, GLint* ints, unsigned int numberOfArrays) { bool updated = updateUniformLocation(location, ints, sizeof(int)*4*numberOfArrays); if( updated ) { glUniform4iv( (GLint)location, (GLsizei)numberOfArrays, ints ); } } void GLProgram::setUniformLocationWith1f(GLint location, GLfloat f1) { bool updated = updateUniformLocation(location, &f1, sizeof(f1)*1); if( updated ) { glUniform1f( (GLint)location, f1); } } void GLProgram::setUniformLocationWith2f(GLint location, GLfloat f1, GLfloat f2) { GLfloat floats[2] = {f1,f2}; bool updated = updateUniformLocation(location, floats, sizeof(floats)); if( updated ) { glUniform2f( (GLint)location, f1, f2); } } void GLProgram::setUniformLocationWith3f(GLint location, GLfloat f1, GLfloat f2, GLfloat f3) { GLfloat floats[3] = {f1,f2,f3}; bool updated = updateUniformLocation(location, floats, sizeof(floats)); if( updated ) { glUniform3f( (GLint)location, f1, f2, f3); } } void GLProgram::setUniformLocationWith4f(GLint location, GLfloat f1, GLfloat f2, GLfloat f3, GLfloat f4) { GLfloat floats[4] = {f1,f2,f3,f4}; bool updated = updateUniformLocation(location, floats, sizeof(floats)); if( updated ) { glUniform4f( (GLint)location, f1, f2, f3,f4); } } void GLProgram::setUniformLocationWith2fv(GLint location, const GLfloat* floats, unsigned int numberOfArrays) { bool updated = updateUniformLocation(location, floats, sizeof(float)*2*numberOfArrays); if( updated ) { glUniform2fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } } void GLProgram::setUniformLocationWith3fv(GLint location, const GLfloat* floats, unsigned int numberOfArrays) { bool updated = updateUniformLocation(location, floats, sizeof(float)*3*numberOfArrays); if( updated ) { glUniform3fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } } void GLProgram::setUniformLocationWith4fv(GLint location, const GLfloat* floats, unsigned int numberOfArrays) { bool updated = updateUniformLocation(location, floats, sizeof(float)*4*numberOfArrays); if( updated ) { glUniform4fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } } void GLProgram::setUniformLocationWithMatrix2fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices) { bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*4*numberOfMatrices); if( updated ) { glUniformMatrix2fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); } } void GLProgram::setUniformLocationWithMatrix3fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices) { bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*9*numberOfMatrices); if( updated ) { glUniformMatrix3fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); } } void GLProgram::setUniformLocationWithMatrix4fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices) { bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*16*numberOfMatrices); if( updated ) { glUniformMatrix4fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); } } void GLProgram::setUniformsForBuiltins() { kmMat4 matrixMV; kmGLGetMatrix(KM_GL_MODELVIEW, &matrixMV); setUniformsForBuiltins(matrixMV); } void GLProgram::setUniformsForBuiltins(const kmMat4 &matrixMV) { kmMat4 matrixP; kmGLGetMatrix(KM_GL_PROJECTION, &matrixP); if(_flags.usesP) setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_P_MATRIX], matrixP.mat, 1); if(_flags.usesMV) setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_MV_MATRIX], matrixMV.mat, 1); if(_flags.usesMVP) { kmMat4 matrixMVP; kmMat4Multiply(&matrixMVP, &matrixP, &matrixMV); setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_MVP_MATRIX], matrixMVP.mat, 1); } if(_flags.usesTime) { Director *director = Director::getInstance(); // This doesn't give the most accurate global time value. // Cocos2D doesn't store a high precision time value, so this will have to do. // Getting Mach time per frame per shader using time could be extremely expensive. float time = director->getTotalFrames() * director->getAnimationInterval(); setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_TIME], time/10.0, time, time*2, time*4); setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_SIN_TIME], time/8.0, time/4.0, time/2.0, sinf(time)); setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_COS_TIME], time/8.0, time/4.0, time/2.0, cosf(time)); } if(_flags.usesRandom) setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_RANDOM01], CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1()); } void GLProgram::reset() { _vertShader = _fragShader = 0; memset(_uniforms, 0, sizeof(_uniforms)); // it is already deallocated by android //GL::deleteProgram(_program); _program = 0; tHashUniformEntry *current_element, *tmp; // Purge uniform hash HASH_ITER(hh, _hashForUniforms, current_element, tmp) { HASH_DEL(_hashForUniforms, current_element); free(current_element->value); free(current_element); } _hashForUniforms = nullptr; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCGLProgram.h ================================================ /**************************************************************************** Copyright 2011 Jeff Lamarche Copyright 2012 Goffredo Marocchi Copyright 2012 Ricardo Quesada Copyright 2012 cocos2d-x.org Copyright 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCGLPROGRAM_H__ #define __CCGLPROGRAM_H__ #include "ccMacros.h" #include "CCObject.h" #include "CCGL.h" #include "kazmath/kazmath.h" NS_CC_BEGIN /** * @addtogroup shaders * @{ */ struct _hashUniformEntry; typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); /** GLProgram Class that implements a glProgram @since v2.0.0 */ class CC_DLL GLProgram : public Object { public: enum { VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_COLOR, VERTEX_ATTRIB_TEX_COORDS, VERTEX_ATTRIB_MAX, }; enum { UNIFORM_P_MATRIX, UNIFORM_MV_MATRIX, UNIFORM_MVP_MATRIX, UNIFORM_TIME, UNIFORM_SIN_TIME, UNIFORM_COS_TIME, UNIFORM_RANDOM01, UNIFORM_SAMPLER, UNIFORM_MAX, }; static const char* SHADER_NAME_POSITION_TEXTURE_COLOR; static const char* SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP; static const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST; static const char* SHADER_NAME_POSITION_COLOR; static const char* SHADER_NAME_POSITION_COLOR_NO_MVP; static const char* SHADER_NAME_POSITION_TEXTURE; static const char* SHADER_NAME_POSITION_TEXTURE_U_COLOR; static const char* SHADER_NAME_POSITION_TEXTURE_A8_COLOR; static const char* SHADER_NAME_POSITION_U_COLOR; static const char* SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR; static const char* SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL; static const char* SHADER_NAME_LABEL_DISTANCEFIELD_GLOW; static const char* SHADER_NAME_LABEL_DISTANCEFIELD_OUTLINE; static const char* SHADER_NAME_LABEL_DISTANCEFIELD_SHADOW; // uniform names static const char* UNIFORM_NAME_P_MATRIX; static const char* UNIFORM_NAME_MV_MATRIX; static const char* UNIFORM_NAME_MVP_MATRIX; static const char* UNIFORM_NAME_TIME; static const char* UNIFORM_NAME_SIN_TIME; static const char* UNIFORM_NAME_COS_TIME; static const char* UNIFORM_NAME_RANDOM01; static const char* UNIFORM_NAME_SAMPLER; static const char* UNIFORM_NAME_ALPHA_TEST_VALUE; // Attribute names static const char* ATTRIBUTE_NAME_COLOR; static const char* ATTRIBUTE_NAME_POSITION; static const char* ATTRIBUTE_NAME_TEX_COORD; /** * @js ctor */ GLProgram(); /** * @js NA * @lua NA */ virtual ~GLProgram(); /** Initializes the GLProgram with a vertex and fragment with bytes array * @js initWithString * @lua initWithString */ bool initWithVertexShaderByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); /** Initializes the GLProgram with a vertex and fragment with contents of filenames * @js init * @lua init */ bool initWithVertexShaderFilename(const char* vShaderFilename, const char* fShaderFilename); /** It will add a new attribute to the shader */ void addAttribute(const char* attributeName, GLuint index); /** links the glProgram */ bool link(); /** it will call glUseProgram() */ void use(); /** It will create 4 uniforms: - kUniformPMatrix - kUniformMVMatrix - kUniformMVPMatrix - GLProgram::UNIFORM_SAMPLER And it will bind "GLProgram::UNIFORM_SAMPLER" to 0 */ void updateUniforms(); /** calls retrieves the named uniform location for this shader program. */ GLint getUniformLocationForName(const char* name) const; /** calls glUniform1i only if the values are different than the previous call for this same shader program. * @js setUniformLocationI32 * @lua setUniformLocationI32 */ void setUniformLocationWith1i(GLint location, GLint i1); /** calls glUniform2i only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith2i(GLint location, GLint i1, GLint i2); /** calls glUniform3i only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith3i(GLint location, GLint i1, GLint i2, GLint i3); /** calls glUniform4i only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith4i(GLint location, GLint i1, GLint i2, GLint i3, GLint i4); /** calls glUniform2iv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith2iv(GLint location, GLint* ints, unsigned int numberOfArrays); /** calls glUniform3iv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith3iv(GLint location, GLint* ints, unsigned int numberOfArrays); /** calls glUniform4iv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith4iv(GLint location, GLint* ints, unsigned int numberOfArrays); /** calls glUniform1f only if the values are different than the previous call for this same shader program. * In js or lua,please use setUniformLocationF32 * @js NA */ void setUniformLocationWith1f(GLint location, GLfloat f1); /** calls glUniform2f only if the values are different than the previous call for this same shader program. * In js or lua,please use setUniformLocationF32 * @js NA */ void setUniformLocationWith2f(GLint location, GLfloat f1, GLfloat f2); /** calls glUniform3f only if the values are different than the previous call for this same shader program. * In js or lua,please use setUniformLocationF32 * @js NA */ void setUniformLocationWith3f(GLint location, GLfloat f1, GLfloat f2, GLfloat f3); /** calls glUniform4f only if the values are different than the previous call for this same shader program. * In js or lua,please use setUniformLocationF32 * @js NA */ void setUniformLocationWith4f(GLint location, GLfloat f1, GLfloat f2, GLfloat f3, GLfloat f4); /** calls glUniform2fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith2fv(GLint location, const GLfloat* floats, unsigned int numberOfArrays); /** calls glUniform3fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith3fv(GLint location, const GLfloat* floats, unsigned int numberOfArrays); /** calls glUniform4fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith4fv(GLint location, const GLfloat* floats, unsigned int numberOfArrays); /** calls glUniformMatrix2fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWithMatrix2fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices); /** calls glUniformMatrix3fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWithMatrix3fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices); /** calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWithMatrix4fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices); /** will update the builtin uniforms if they are different than the previous call for this same shader program. */ void setUniformsForBuiltins(); void setUniformsForBuiltins(const kmMat4 &modelView); /** returns the vertexShader error log */ std::string getVertexShaderLog() const; /** returns the fragmentShader error log */ std::string getFragmentShaderLog() const; /** returns the program error log */ std::string getProgramLog() const; // reload all shaders, this function is designed for android // when opengl context lost, so don't call it. void reset(); inline const GLuint getProgram() const { return _program; } private: bool updateUniformLocation(GLint location, const GLvoid* data, unsigned int bytes); virtual std::string getDescription() const; bool compileShader(GLuint * shader, GLenum type, const GLchar* source); std::string logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const; private: GLuint _program; GLuint _vertShader; GLuint _fragShader; GLint _uniforms[UNIFORM_MAX]; struct _hashUniformEntry* _hashForUniforms; struct flag_struct { unsigned int usesTime:1; unsigned int usesMVP:1; unsigned int usesMV:1; unsigned int usesP:1; unsigned int usesRandom:1; // handy way to initialize the bitfield flag_struct() { memset(this, 0, sizeof(*this)); } } _flags; }; // end of shaders group /// @} NS_CC_END #endif /* __CCGLPROGRAM_H__ */ ================================================ FILE: cocos2d/cocos/2d/CCGrabber.cpp ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCGrabber.h" #include "ccMacros.h" #include "CCTexture2D.h" NS_CC_BEGIN Grabber::Grabber(void) : _FBO(0) , _oldFBO(0) { memset(_oldClearColor, 0, sizeof(_oldClearColor)); // generate FBO glGenFramebuffers(1, &_FBO); } void Grabber::grab(Texture2D *texture) { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); // bind glBindFramebuffer(GL_FRAMEBUFFER, _FBO); // associate texture with FBO glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->getName(), 0); // check if it worked (probably worth doing :) ) GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { CCASSERT(0, "Frame Grabber: could not attach texture to framebuffer"); } glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); } void Grabber::beforeRender(Texture2D *texture) { CC_UNUSED_PARAM(texture); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); glBindFramebuffer(GL_FRAMEBUFFER, _FBO); // save clear color glGetFloatv(GL_COLOR_CLEAR_VALUE, _oldClearColor); // BUG XXX: doesn't work with RGB565. glClearColor(0, 0, 0, 0); // BUG #631: To fix #631, uncomment the lines with #631 // Warning: But it Grabber won't work with 2 effects at the same time // glClearColor(0.0f,0.0f,0.0f,1.0f); // #631 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // glColorMask(true, true, true, false); // #631 } void Grabber::afterRender(cocos2d::Texture2D *texture) { CC_UNUSED_PARAM(texture); glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); // glColorMask(true, true, true, true); // #631 // Restore clear color glClearColor(_oldClearColor[0], _oldClearColor[1], _oldClearColor[2], _oldClearColor[3]); } Grabber::~Grabber() { CCLOGINFO("deallocing Grabber: %p", this); glDeleteFramebuffers(1, &_FBO); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCGrabber.h ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __EFFECTS_CCGRABBER_H__ #define __EFFECTS_CCGRABBER_H__ #include "CCConfiguration.h" #include "CCObject.h" #include "CCGL.h" NS_CC_BEGIN class Texture2D; /** * @addtogroup effects * @{ */ /** FBO class that grabs the the contents of the screen */ class Grabber : public Object { public: /** * @js ctor */ Grabber(void); /** * @js NA * @lua NA */ ~Grabber(void); void grab(Texture2D *texture); void beforeRender(Texture2D *texture); void afterRender(Texture2D *texture); protected: GLuint _FBO; GLint _oldFBO; GLfloat _oldClearColor[4]; }; // end of effects group /// @} NS_CC_END #endif // __EFFECTS_CCGRABBER_H__ ================================================ FILE: cocos2d/cocos/2d/CCGrid.cpp ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ccMacros.h" #include "CCGrid.h" #include "CCDirector.h" #include "CCGrabber.h" #include "ccUtils.h" #include "CCGLProgram.h" #include "CCShaderCache.h" #include "ccGLStateCache.h" #include "CCGL.h" #include "TransformUtils.h" #include "kazmath/kazmath.h" #include "kazmath/GL/matrix.h" NS_CC_BEGIN // implementation of GridBase GridBase* GridBase::create(const Size& gridSize) { GridBase *pGridBase = new GridBase(); if (pGridBase) { if (pGridBase->initWithSize(gridSize)) { pGridBase->autorelease(); } else { CC_SAFE_RELEASE_NULL(pGridBase); } } return pGridBase; } GridBase* GridBase::create(const Size& gridSize, Texture2D *texture, bool flipped) { GridBase *pGridBase = new GridBase(); if (pGridBase) { if (pGridBase->initWithSize(gridSize, texture, flipped)) { pGridBase->autorelease(); } else { CC_SAFE_RELEASE_NULL(pGridBase); } } return pGridBase; } bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipped) { bool ret = true; _active = false; _reuseGrid = 0; _gridSize = gridSize; _texture = texture; CC_SAFE_RETAIN(_texture); _isTextureFlipped = flipped; Size texSize = _texture->getContentSize(); _step.x = texSize.width / _gridSize.width; _step.y = texSize.height / _gridSize.height; _grabber = new Grabber(); if (_grabber) { _grabber->grab(_texture); } else { ret = false; } _shaderProgram = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE); calculateVertexPoints(); return ret; } bool GridBase::initWithSize(const Size& gridSize) { Director *director = Director::getInstance(); Size s = director->getWinSizeInPixels(); auto POTWide = ccNextPOT((unsigned int)s.width); auto POTHigh = ccNextPOT((unsigned int)s.height); // we only use rgba8888 Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888; auto dataLen = POTWide * POTHigh * 4; void *data = calloc(dataLen, 1); if (! data) { CCLOG("cocos2d: Grid: not enough memory."); this->release(); return false; } Texture2D *texture = new Texture2D(); texture->initWithData(data, dataLen, format, POTWide, POTHigh, s); free(data); if (! texture) { CCLOG("cocos2d: Grid: error creating texture"); return false; } initWithSize(gridSize, texture, false); texture->release(); return true; } GridBase::~GridBase(void) { CCLOGINFO("deallocing GridBase: %p", this); //TODO: ? why 2.0 comments this line setActive(false); CC_SAFE_RELEASE(_texture); CC_SAFE_RELEASE(_grabber); } // properties void GridBase::setActive(bool active) { _active = active; if (! active) { Director *pDirector = Director::getInstance(); Director::Projection proj = pDirector->getProjection(); pDirector->setProjection(proj); } } void GridBase::setTextureFlipped(bool flipped) { if (_isTextureFlipped != flipped) { _isTextureFlipped = flipped; calculateVertexPoints(); } } void GridBase::set2DProjection() { Director *director = Director::getInstance(); Size size = director->getWinSizeInPixels(); glViewport(0, 0, (GLsizei)(size.width), (GLsizei)(size.height) ); kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); kmMat4 orthoMatrix; kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1, 1); kmGLMultMatrix( &orthoMatrix ); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); GL::setProjectionMatrixDirty(); } void GridBase::beforeDraw(void) { // save projection Director *director = Director::getInstance(); _directorProjection = director->getProjection(); // 2d projection // [director setProjection:Director::Projection::_2D]; set2DProjection(); _grabber->beforeRender(_texture); } void GridBase::afterDraw(cocos2d::Node *target) { _grabber->afterRender(_texture); // restore projection Director *director = Director::getInstance(); director->setProjection(_directorProjection); // if (target->getCamera()->isDirty()) // { // Point offset = target->getAnchorPointInPoints(); // // // // // XXX: Camera should be applied in the AnchorPoint // // // kmGLTranslatef(offset.x, offset.y, 0); // target->getCamera()->locate(); // kmGLTranslatef(-offset.x, -offset.y, 0); // } GL::bindTexture2D(_texture->getName()); // restore projection for default FBO .fixed bug #543 #544 //TODO: Director::getInstance()->setProjection(Director::getInstance()->getProjection()); //TODO: Director::getInstance()->applyOrientation(); blit(); } void GridBase::blit(void) { CCASSERT(0, ""); } void GridBase::reuse(void) { CCASSERT(0, ""); } void GridBase::calculateVertexPoints(void) { CCASSERT(0, ""); } // implementation of Grid3D Grid3D* Grid3D::create(const Size& gridSize, Texture2D *texture, bool flipped) { Grid3D *ret= new Grid3D(); if (ret) { if (ret->initWithSize(gridSize, texture, flipped)) { ret->autorelease(); } else { delete ret; ret = nullptr; } } return ret; } Grid3D* Grid3D::create(const Size& gridSize) { Grid3D *ret= new Grid3D(); if (ret) { if (ret->initWithSize(gridSize)) { ret->autorelease(); } else { delete ret; ret = nullptr; } } return ret; } Grid3D::Grid3D() : _texCoordinates(nullptr) , _vertices(nullptr) , _originalVertices(nullptr) , _indices(nullptr) { } Grid3D::~Grid3D(void) { CC_SAFE_FREE(_texCoordinates); CC_SAFE_FREE(_vertices); CC_SAFE_FREE(_indices); CC_SAFE_FREE(_originalVertices); } void Grid3D::blit(void) { int n = _gridSize.width * _gridSize.height; GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS ); _shaderProgram->use(); _shaderProgram->setUniformsForBuiltins();; // // Attributes // #ifdef EMSCRIPTEN // Size calculations from calculateVertexPoints(). unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); // position setGLBufferData(_vertices, numOfPoints * sizeof(Vertex3F), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); // texCoords setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vertex2F), 1); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLIndexData(_indices, n * 12, 0); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); #else // position glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices); // texCoords glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, _indices); #endif // EMSCRIPTEN CC_INCREMENT_GL_DRAWS(1); } void Grid3D::calculateVertexPoints(void) { float width = (float)_texture->getPixelsWide(); float height = (float)_texture->getPixelsHigh(); float imageH = _texture->getContentSizeInPixels().height; int x, y, i; CC_SAFE_FREE(_vertices); CC_SAFE_FREE(_originalVertices); CC_SAFE_FREE(_texCoordinates); CC_SAFE_FREE(_indices); unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1); _vertices = malloc(numOfPoints * sizeof(Vertex3F)); _originalVertices = malloc(numOfPoints * sizeof(Vertex3F)); _texCoordinates = malloc(numOfPoints * sizeof(Vertex2F)); _indices = (GLushort*)malloc(_gridSize.width * _gridSize.height * sizeof(GLushort) * 6); GLfloat *vertArray = (GLfloat*)_vertices; GLfloat *texArray = (GLfloat*)_texCoordinates; GLushort *idxArray = _indices; for (x = 0; x < _gridSize.width; ++x) { for (y = 0; y < _gridSize.height; ++y) { int idx = (y * _gridSize.width) + x; GLfloat x1 = x * _step.x; GLfloat x2 = x1 + _step.x; GLfloat y1 = y * _step.y; GLfloat y2= y1 + _step.y; GLushort a = (GLushort)(x * (_gridSize.height + 1) + y); GLushort b = (GLushort)((x + 1) * (_gridSize.height + 1) + y); GLushort c = (GLushort)((x + 1) * (_gridSize.height + 1) + (y + 1)); GLushort d = (GLushort)(x * (_gridSize.height + 1) + (y + 1)); GLushort tempidx[6] = {a, b, d, b, c, d}; memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort)); int l1[4] = {a*3, b*3, c*3, d*3}; Vertex3F e(x1, y1, 0); Vertex3F f(x2, y1, 0); Vertex3F g(x2, y2, 0); Vertex3F h(x1, y2, 0); Vertex3F l2[4] = {e, f, g, h}; int tex1[4] = {a*2, b*2, c*2, d*2}; Point Tex2F[4] = {Point(x1, y1), Point(x2, y1), Point(x2, y2), Point(x1, y2)}; for (i = 0; i < 4; ++i) { vertArray[l1[i]] = l2[i].x; vertArray[l1[i] + 1] = l2[i].y; vertArray[l1[i] + 2] = l2[i].z; texArray[tex1[i]] = Tex2F[i].x / width; if (_isTextureFlipped) { texArray[tex1[i] + 1] = (imageH - Tex2F[i].y) / height; } else { texArray[tex1[i] + 1] = Tex2F[i].y / height; } } } } memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vertex3F)); } Vertex3F Grid3D::getVertex(const Point& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int index = (pos.x * (_gridSize.height+1) + pos.y) * 3; float *vertArray = (float*)_vertices; Vertex3F vert(vertArray[index], vertArray[index+1], vertArray[index+2]); return vert; } Vertex3F Grid3D::getOriginalVertex(const Point& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int index = (pos.x * (_gridSize.height+1) + pos.y) * 3; float *vertArray = (float*)_originalVertices; Vertex3F vert(vertArray[index], vertArray[index+1], vertArray[index+2]); return vert; } void Grid3D::setVertex(const Point& pos, const Vertex3F& vertex) { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3; float *vertArray = (float*)_vertices; vertArray[index] = vertex.x; vertArray[index+1] = vertex.y; vertArray[index+2] = vertex.z; } void Grid3D::reuse(void) { if (_reuseGrid > 0) { memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vertex3F)); --_reuseGrid; } } // implementation of TiledGrid3D TiledGrid3D::TiledGrid3D() : _texCoordinates(nullptr) , _vertices(nullptr) , _originalVertices(nullptr) , _indices(nullptr) { } TiledGrid3D::~TiledGrid3D(void) { CC_SAFE_FREE(_texCoordinates); CC_SAFE_FREE(_vertices); CC_SAFE_FREE(_originalVertices); CC_SAFE_FREE(_indices); } TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *texture, bool flipped) { TiledGrid3D *ret= new TiledGrid3D(); if (ret) { if (ret->initWithSize(gridSize, texture, flipped)) { ret->autorelease(); } else { delete ret; ret = nullptr; } } return ret; } TiledGrid3D* TiledGrid3D::create(const Size& gridSize) { TiledGrid3D *ret= new TiledGrid3D(); if (ret) { if (ret->initWithSize(gridSize)) { ret->autorelease(); } else { delete ret; ret = nullptr; } } return ret; } void TiledGrid3D::blit(void) { int n = _gridSize.width * _gridSize.height; _shaderProgram->use(); _shaderProgram->setUniformsForBuiltins(); // // Attributes // GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS ); #ifdef EMSCRIPTEN int numQuads = _gridSize.width * _gridSize.height; // position setGLBufferData(_vertices, (numQuads*4*sizeof(Vertex3F)), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); // texCoords setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vertex2F)), 1); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLIndexData(_indices, n * 12, 0); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); #else // position glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices); // texCoords glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, _indices); #endif // EMSCRIPTEN CC_INCREMENT_GL_DRAWS(1); } void TiledGrid3D::calculateVertexPoints(void) { float width = (float)_texture->getPixelsWide(); float height = (float)_texture->getPixelsHigh(); float imageH = _texture->getContentSizeInPixels().height; int numQuads = _gridSize.width * _gridSize.height; CC_SAFE_FREE(_vertices); CC_SAFE_FREE(_originalVertices); CC_SAFE_FREE(_texCoordinates); CC_SAFE_FREE(_indices); _vertices = malloc(numQuads*4*sizeof(Vertex3F)); _originalVertices = malloc(numQuads*4*sizeof(Vertex3F)); _texCoordinates = malloc(numQuads*4*sizeof(Vertex2F)); _indices = (GLushort*)malloc(numQuads*6*sizeof(GLushort)); GLfloat *vertArray = (GLfloat*)_vertices; GLfloat *texArray = (GLfloat*)_texCoordinates; GLushort *idxArray = _indices; int x, y; for( x = 0; x < _gridSize.width; x++ ) { for( y = 0; y < _gridSize.height; y++ ) { float x1 = x * _step.x; float x2 = x1 + _step.x; float y1 = y * _step.y; float y2 = y1 + _step.y; *vertArray++ = x1; *vertArray++ = y1; *vertArray++ = 0; *vertArray++ = x2; *vertArray++ = y1; *vertArray++ = 0; *vertArray++ = x1; *vertArray++ = y2; *vertArray++ = 0; *vertArray++ = x2; *vertArray++ = y2; *vertArray++ = 0; float newY1 = y1; float newY2 = y2; if (_isTextureFlipped) { newY1 = imageH - y1; newY2 = imageH - y2; } *texArray++ = x1 / width; *texArray++ = newY1 / height; *texArray++ = x2 / width; *texArray++ = newY1 / height; *texArray++ = x1 / width; *texArray++ = newY2 / height; *texArray++ = x2 / width; *texArray++ = newY2 / height; } } for (x = 0; x < numQuads; x++) { idxArray[x*6+0] = (GLushort)(x * 4 + 0); idxArray[x*6+1] = (GLushort)(x * 4 + 1); idxArray[x*6+2] = (GLushort)(x * 4 + 2); idxArray[x*6+3] = (GLushort)(x * 4 + 1); idxArray[x*6+4] = (GLushort)(x * 4 + 2); idxArray[x*6+5] = (GLushort)(x * 4 + 3); } memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat)); } void TiledGrid3D::setTile(const Point& pos, const Quad3& coords) { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; float *vertArray = (float*)_vertices; memcpy(&vertArray[idx], &coords, sizeof(Quad3)); } Quad3 TiledGrid3D::getOriginalTile(const Point& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; float *vertArray = (float*)_originalVertices; Quad3 ret; memcpy(&ret, &vertArray[idx], sizeof(Quad3)); return ret; } Quad3 TiledGrid3D::getTile(const Point& pos) const { CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers"); int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3; float *vertArray = (float*)_vertices; Quad3 ret; memcpy(&ret, &vertArray[idx], sizeof(Quad3)); return ret; } void TiledGrid3D::reuse(void) { if (_reuseGrid > 0) { int numQuads = _gridSize.width * _gridSize.height; memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat)); --_reuseGrid; } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCGrid.h ================================================ /**************************************************************************** Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __EFFECTS_CCGRID_H__ #define __EFFECTS_CCGRID_H__ #include "CCObject.h" #include "CCNode.h" #include "ccTypes.h" #include "CCTexture2D.h" #include "CCDirector.h" #include "kazmath/mat4.h" #ifdef EMSCRIPTEN #include "CCGLBufferedNode.h" #endif // EMSCRIPTEN NS_CC_BEGIN class Texture2D; class Grabber; class GLProgram; /** * @addtogroup effects * @{ */ /** Base class for other */ class CC_DLL GridBase : public Object { public: /** create one Grid */ static GridBase* create(const Size& gridSize, Texture2D *texture, bool flipped); /** create one Grid */ static GridBase* create(const Size& gridSize); /** * @js NA * @lua NA */ virtual ~GridBase(void); bool initWithSize(const Size& gridSize, Texture2D *texture, bool flipped); bool initWithSize(const Size& gridSize); /** whether or not the grid is active */ inline bool isActive(void) const { return _active; } void setActive(bool active); /** number of times that the grid will be reused */ inline int getReuseGrid(void) const { return _reuseGrid; } inline void setReuseGrid(int reuseGrid) { _reuseGrid = reuseGrid; } /** size of the grid */ inline const Size& getGridSize(void) const { return _gridSize; } inline void setGridSize(const Size& gridSize) { _gridSize = gridSize; } /** pixels between the grids */ inline const Point& getStep(void) const { return _step; } inline void setStep(const Point& step) { _step = step; } /** is texture flipped */ inline bool isTextureFlipped(void) const { return _isTextureFlipped; } void setTextureFlipped(bool flipped); void beforeDraw(void); void afterDraw(Node *target); virtual void blit(void); virtual void reuse(void); virtual void calculateVertexPoints(void); void set2DProjection(void); protected: bool _active; int _reuseGrid; Size _gridSize; Texture2D *_texture; Point _step; Grabber *_grabber; bool _isTextureFlipped; GLProgram* _shaderProgram; Director::Projection _directorProjection; }; /** Grid3D is a 3D grid implementation. Each vertex has 3 dimensions: x,y,z */ class CC_DLL Grid3D : public GridBase #ifdef EMSCRIPTEN , public GLBufferedNode #endif // EMSCRIPTEN { public: /** create one Grid */ static Grid3D* create(const Size& gridSize, Texture2D *texture, bool flipped); /** create one Grid */ static Grid3D* create(const Size& gridSize); /** * @js ctor */ Grid3D(); /** * @js NA * @lua NA */ ~Grid3D(void); /** returns the vertex at a given position * @js NA * @lua NA */ Vertex3F getVertex(const Point& pos) const; /** @deprecated Use getVertex() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE Vertex3F vertex(const Point& pos) const { return getVertex(pos); } /** returns the original (non-transformed) vertex at a given position * @js NA * @lua NA */ Vertex3F getOriginalVertex(const Point& pos) const; /** @deprecated Use getOriginalVertex() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE Vertex3F originalVertex(const Point& pos) const { return getOriginalVertex(pos); } /** sets a new vertex at a given position * @js NA * @lua NA */ void setVertex(const Point& pos, const Vertex3F& vertex); // Overrides virtual void blit() override; virtual void reuse() override; virtual void calculateVertexPoints() override; protected: GLvoid *_texCoordinates; GLvoid *_vertices; GLvoid *_originalVertices; GLushort *_indices; }; /** TiledGrid3D is a 3D grid implementation. It differs from Grid3D in that the tiles can be separated from the grid. */ class CC_DLL TiledGrid3D : public GridBase #ifdef EMSCRIPTEN , public GLBufferedNode #endif // EMSCRIPTEN { public: /** create one Grid */ static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool flipped); /** create one Grid */ static TiledGrid3D* create(const Size& gridSize); /** * @js ctor */ TiledGrid3D(); /** * @js NA * @lua NA */ ~TiledGrid3D(); /** returns the tile at the given position * @js NA * @lua NA */ Quad3 getTile(const Point& pos) const; /** returns the tile at the given position * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& pos) const { return getTile(pos); } /** returns the original tile (untransformed) at the given position * @js NA * @lua NA */ Quad3 getOriginalTile(const Point& pos) const; /** returns the original tile (untransformed) at the given position * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& pos) const { return getOriginalTile(pos); } /** sets a new tile * @js NA * @lua NA */ void setTile(const Point& pos, const Quad3& coords); // Overrides virtual void blit() override; virtual void reuse() override; virtual void calculateVertexPoints() override; protected: GLvoid *_texCoordinates; GLvoid *_vertices; GLvoid *_originalVertices; GLushort *_indices; }; // end of effects group /// @} NS_CC_END #endif // __EFFECTS_CCGRID_H__ ================================================ FILE: cocos2d/cocos/2d/CCIMEDelegate.h ================================================ /**************************************************************************** Copyright (c) 2010 cocos2d-x.org Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_IME_DELEGATE_H__ #define __CC_IME_DELEGATE_H__ #include #include "CCGeometry.h" NS_CC_BEGIN extern const std::string STD_STRING_EMPTY; /** * @addtogroup input * @{ */ typedef struct { Rect begin; // the soft keyboard rectangle when animation begins Rect end; // the soft keyboard rectangle when animation ends float duration; // the soft keyboard animation duration } IMEKeyboardNotificationInfo; /** @brief Input method editor delegate. */ class CC_DLL IMEDelegate { public: /** * @js NA * @lua NA */ virtual ~IMEDelegate(); /** * @js NA * @lua NA */ virtual bool attachWithIME(); /** * @js NA * @lua NA */ virtual bool detachWithIME(); protected: friend class IMEDispatcher; /** @brief Decide if the delegate instance is ready to receive an IME message. Called by IMEDispatcher. * @js NA * @lua NA */ virtual bool canAttachWithIME() { return false; } /** @brief When the delegate detaches from the IME, this method is called by IMEDispatcher. * @js NA * @lua NA */ virtual void didAttachWithIME() {} /** @brief Decide if the delegate instance can stop receiving IME messages. * @js NA * @lua NA */ virtual bool canDetachWithIME() { return false; } /** @brief When the delegate detaches from the IME, this method is called by IMEDispatcher. * @js NA * @lua NA */ virtual void didDetachWithIME() {} /** @brief Called by IMEDispatcher when text input received from the IME. * @js NA * @lua NA */ virtual void insertText(const char * text, int len) {CC_UNUSED_PARAM(text);CC_UNUSED_PARAM(len);} /** @brief Called by IMEDispatcher after the user clicks the backward key. * @js NA * @lua NA */ virtual void deleteBackward() {} /** @brief Called by IMEDispatcher for text stored in delegate. * @js NA * @lua NA */ virtual const std::string& getContentText() { return STD_STRING_EMPTY; } ////////////////////////////////////////////////////////////////////////// // keyboard show/hide notification ////////////////////////////////////////////////////////////////////////// /** * @js NA * @lua NA */ virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);} /** * @js NA * @lua NA */ virtual void keyboardDidShow(IMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);} /** * @js NA * @lua NA */ virtual void keyboardWillHide(IMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);} /** * @js NA * @lua NA */ virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);} protected: /** * @js NA * @lua NA */ IMEDelegate(); }; // end of input group /// @} NS_CC_END #endif // __CC_IME_DELEGATE_H__ ================================================ FILE: cocos2d/cocos/2d/CCIMEDispatcher.cpp ================================================ /**************************************************************************** Copyright (c) 2010 cocos2d-x.org Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCIMEDispatcher.h" #include NS_CC_BEGIN ////////////////////////////////////////////////////////////////////////// // add/remove delegate in IMEDelegate Cons/Destructor ////////////////////////////////////////////////////////////////////////// IMEDelegate::IMEDelegate() { IMEDispatcher::sharedDispatcher()->addDelegate(this); } IMEDelegate::~IMEDelegate() { IMEDispatcher::sharedDispatcher()->removeDelegate(this); } bool IMEDelegate::attachWithIME() { return IMEDispatcher::sharedDispatcher()->attachDelegateWithIME(this); } bool IMEDelegate::detachWithIME() { return IMEDispatcher::sharedDispatcher()->detachDelegateWithIME(this); } ////////////////////////////////////////////////////////////////////////// typedef std::list< IMEDelegate * > DelegateList; typedef std::list< IMEDelegate * >::iterator DelegateIter; ////////////////////////////////////////////////////////////////////////// // Delegate List manage class ////////////////////////////////////////////////////////////////////////// class IMEDispatcher::Impl { public: Impl() { } ~Impl() { } void init() { _delegateWithIme = 0; } DelegateIter findDelegate(IMEDelegate* delegate) { DelegateIter end = _delegateList.end(); for (DelegateIter iter = _delegateList.begin(); iter != end; ++iter) { if (delegate == *iter) { return iter; } } return end; } DelegateList _delegateList; IMEDelegate* _delegateWithIme; }; ////////////////////////////////////////////////////////////////////////// // Cons/Destructor ////////////////////////////////////////////////////////////////////////// IMEDispatcher::IMEDispatcher() : _impl(new IMEDispatcher::Impl) { _impl->init(); } IMEDispatcher::~IMEDispatcher() { CC_SAFE_DELETE(_impl); } ////////////////////////////////////////////////////////////////////////// // Add/Attach/Remove IMEDelegate ////////////////////////////////////////////////////////////////////////// void IMEDispatcher::addDelegate(IMEDelegate* delegate) { if (! delegate || ! _impl) { return; } if (_impl->_delegateList.end() != _impl->findDelegate(delegate)) { // pDelegate already in list return; } _impl->_delegateList.push_front(delegate); } bool IMEDispatcher::attachDelegateWithIME(IMEDelegate * delegate) { bool ret = false; do { CC_BREAK_IF(! _impl || ! delegate); DelegateIter end = _impl->_delegateList.end(); DelegateIter iter = _impl->findDelegate(delegate); // if pDelegate is not in delegate list, return CC_BREAK_IF(end == iter); if (_impl->_delegateWithIme) { // if old delegate canDetachWithIME return false // or pDelegate canAttachWithIME return false, // do nothing. CC_BREAK_IF(! _impl->_delegateWithIme->canDetachWithIME() || ! delegate->canAttachWithIME()); // detach first IMEDelegate * oldDelegate = _impl->_delegateWithIme; _impl->_delegateWithIme = 0; oldDelegate->didDetachWithIME(); _impl->_delegateWithIme = *iter; delegate->didAttachWithIME(); ret = true; break; } // delegate hasn't attached to IME yet CC_BREAK_IF(! delegate->canAttachWithIME()); _impl->_delegateWithIme = *iter; delegate->didAttachWithIME(); ret = true; } while (0); return ret; } bool IMEDispatcher::detachDelegateWithIME(IMEDelegate * delegate) { bool ret = false; do { CC_BREAK_IF(! _impl || ! delegate); // if pDelegate is not the current delegate attached to IME, return CC_BREAK_IF(_impl->_delegateWithIme != delegate); CC_BREAK_IF(! delegate->canDetachWithIME()); _impl->_delegateWithIme = 0; delegate->didDetachWithIME(); ret = true; } while (0); return ret; } void IMEDispatcher::removeDelegate(IMEDelegate* delegate) { do { CC_BREAK_IF(! delegate || ! _impl); DelegateIter iter = _impl->findDelegate(delegate); DelegateIter end = _impl->_delegateList.end(); CC_BREAK_IF(end == iter); if (_impl->_delegateWithIme) if (*iter == _impl->_delegateWithIme) { _impl->_delegateWithIme = 0; } _impl->_delegateList.erase(iter); } while (0); } ////////////////////////////////////////////////////////////////////////// // dispatch text message ////////////////////////////////////////////////////////////////////////// void IMEDispatcher::dispatchInsertText(const char * text, int len) { do { CC_BREAK_IF(! _impl || ! text || len <= 0); // there is no delegate attached to IME CC_BREAK_IF(! _impl->_delegateWithIme); _impl->_delegateWithIme->insertText(text, len); } while (0); } void IMEDispatcher::dispatchDeleteBackward() { do { CC_BREAK_IF(! _impl); // there is no delegate attached to IME CC_BREAK_IF(! _impl->_delegateWithIme); _impl->_delegateWithIme->deleteBackward(); } while (0); } const std::string& IMEDispatcher::getContentText() { if (_impl && _impl->_delegateWithIme) { return _impl->_delegateWithIme->getContentText(); } return STD_STRING_EMPTY; } ////////////////////////////////////////////////////////////////////////// // dispatch keyboard message ////////////////////////////////////////////////////////////////////////// void IMEDispatcher::dispatchKeyboardWillShow(IMEKeyboardNotificationInfo& info) { if (_impl) { IMEDelegate * delegate = 0; DelegateIter last = _impl->_delegateList.end(); for (DelegateIter first = _impl->_delegateList.begin(); first != last; ++first) { delegate = *(first); if (delegate) { delegate->keyboardWillShow(info); } } } } void IMEDispatcher::dispatchKeyboardDidShow(IMEKeyboardNotificationInfo& info) { if (_impl) { IMEDelegate * delegate = 0; DelegateIter last = _impl->_delegateList.end(); for (DelegateIter first = _impl->_delegateList.begin(); first != last; ++first) { delegate = *(first); if (delegate) { delegate->keyboardDidShow(info); } } } } void IMEDispatcher::dispatchKeyboardWillHide(IMEKeyboardNotificationInfo& info) { if (_impl) { IMEDelegate * delegate = 0; DelegateIter last = _impl->_delegateList.end(); for (DelegateIter first = _impl->_delegateList.begin(); first != last; ++first) { delegate = *(first); if (delegate) { delegate->keyboardWillHide(info); } } } } void IMEDispatcher::dispatchKeyboardDidHide(IMEKeyboardNotificationInfo& info) { if (_impl) { IMEDelegate * delegate = 0; DelegateIter last = _impl->_delegateList.end(); for (DelegateIter first = _impl->_delegateList.begin(); first != last; ++first) { delegate = *(first); if (delegate) { delegate->keyboardDidHide(info); } } } } ////////////////////////////////////////////////////////////////////////// // protected member function ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // static member function ////////////////////////////////////////////////////////////////////////// IMEDispatcher* IMEDispatcher::sharedDispatcher() { static IMEDispatcher s_instance; return &s_instance; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCIMEDispatcher.h ================================================ /**************************************************************************** Copyright (c) 2010 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_IME_DISPATCHER_H__ #define __CC_IME_DISPATCHER_H__ #include "CCIMEDelegate.h" NS_CC_BEGIN /** * @addtogroup input * @{ */ /** @brief Input Method Edit Message Dispatcher. */ class CC_DLL IMEDispatcher { public: /** * @js NA * @lua NA */ ~IMEDispatcher(); /** @brief Returns the shared IMEDispatcher object for the system. * @js NA * @lua NA */ static IMEDispatcher* sharedDispatcher(); // /** // @brief Releases all IMEDelegates from the shared dispatcher. // */ // static void purgeSharedDispatcher(); /** @brief Dispatches the input text from IME. * @js NA * @lua NA */ void dispatchInsertText(const char * text, int len); /** @brief Dispatches the delete-backward operation. * @js NA * @lua NA */ void dispatchDeleteBackward(); /** @brief Get the content text from IMEDelegate, retrieved previously from IME. * @js NA * @lua NA */ const std::string& getContentText(); ////////////////////////////////////////////////////////////////////////// // dispatch keyboard notification ////////////////////////////////////////////////////////////////////////// /** * @js NA * @lua NA */ void dispatchKeyboardWillShow(IMEKeyboardNotificationInfo& info); /** * @js NA * @lua NA */ void dispatchKeyboardDidShow(IMEKeyboardNotificationInfo& info); /** * @js NA * @lua NA */ void dispatchKeyboardWillHide(IMEKeyboardNotificationInfo& info); /** * @js NA * @lua NA */ void dispatchKeyboardDidHide(IMEKeyboardNotificationInfo& info); protected: friend class IMEDelegate; /** @brief Add delegate to receive IME messages. */ void addDelegate(IMEDelegate * delegate); /** @brief Attach the pDelegate to the IME. @return If the old delegate can detach from the IME, and the new delegate can attach to the IME, return true, otherwise false. */ bool attachDelegateWithIME(IMEDelegate * delegate); bool detachDelegateWithIME(IMEDelegate * delegate); /** @brief Remove the delegate from the delegates which receive IME messages. */ void removeDelegate(IMEDelegate * delegate); private: IMEDispatcher(); class Impl; Impl * _impl; }; // end of input group /// @} NS_CC_END #endif // __CC_IME_DISPATCHER_H__ ================================================ FILE: cocos2d/cocos/2d/CCLabel.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCLabel.h" #include "CCFontAtlasCache.h" #include "CCLabelTextFormatter.h" #include "CCSprite.h" #include "CCShaderCache.h" #include "ccUTF8.h" #include "CCSpriteFrame.h" #include "CCDirector.h" #include "renderer/CCRenderer.h" #include "CCFont.h" #define DISTANCEFIELD_ATLAS_FONTSIZE 50 NS_CC_BEGIN Label* Label::create() { Label *ret = new Label(); if (!ret) return nullptr; ret->autorelease(); return ret; } Label* Label::createWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment alignment /* = TextHAlignment::CENTER */, int lineSize /* = 0 */) { Label *ret = new Label(nullptr,alignment); if (!ret) return nullptr; if (ret->setTTFConfig(ttfConfig)) { if(ttfConfig.distanceFieldEnabled) ret->setFontSize(ttfConfig.fontSize); ret->setWidth(lineSize); ret->setString(text); ret->autorelease(); return ret; } else { delete ret; return nullptr; } } Label* Label::createWithTTF(const std::string& text, const std::string& fontFilePath, int fontSize, int lineSize /* = 0 */, TextHAlignment alignment /* = TextHAlignment::CENTER */, GlyphCollection glyphs /* = GlyphCollection::NEHE */, const char *customGlyphs /* = 0 */, bool useDistanceField /* = false */) { TTFConfig ttfConfig(fontFilePath.c_str(),fontSize,glyphs,customGlyphs,useDistanceField); return createWithTTF(ttfConfig,text,alignment,lineSize); } Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::CENTER */, int lineSize /* = 0 */) { Label *ret = new Label(nullptr,alignment); if (!ret) return nullptr; if (ret->setBMFontFilePath(bmfontFilePath)) { ret->setWidth(lineSize); ret->setString(text); ret->autorelease(); return ret; } else { delete ret; return nullptr; } } Label* Label::createWithCharMap(const std::string& plistFile) { Label *ret = new Label(); if (!ret) return nullptr; if (ret->setCharMap(plistFile)) { ret->autorelease(); return ret; } else { delete ret; return nullptr; } } Label* Label::createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap) { Label *ret = new Label(); if (!ret) return nullptr; if (ret->setCharMap(texture,itemWidth,itemHeight,startCharMap)) { ret->autorelease(); return ret; } else { delete ret; return nullptr; } } Label* Label::createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap) { Label *ret = new Label(); if (!ret) return nullptr; if (ret->setCharMap(charMapFile,itemWidth,itemHeight,startCharMap)) { ret->autorelease(); return ret; } else { delete ret; return nullptr; } } bool Label::setCharMap(const std::string& plistFile) { FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(plistFile); if (!newAtlas) return false; return initWithFontAtlas(newAtlas); } bool Label::setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap) { FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(texture,itemWidth,itemHeight,startCharMap); if (!newAtlas) return false; return initWithFontAtlas(newAtlas); } bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap) { FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(charMapFile,itemWidth,itemHeight,startCharMap); if (!newAtlas) return false; return initWithFontAtlas(newAtlas); } Label::Label(FontAtlas *atlas, TextHAlignment alignment, bool useDistanceField,bool useA8Shader) : _reusedLetter(nullptr) , _commonLineHeight(0.0f) , _lineBreakWithoutSpaces(false) , _width(0.0f) , _alignment(alignment) , _currentUTF16String(nullptr) , _originalUTF16String(nullptr) , _horizontalKernings(nullptr) , _fontAtlas(atlas) , _isOpacityModifyRGB(false) , _useDistanceField(useDistanceField) , _useA8Shader(useA8Shader) , _fontSize(0) , _uniformEffectColor(0) { _cascadeColorEnabled = true; } Label::~Label() { delete [] _currentUTF16String; delete [] _originalUTF16String; delete [] _horizontalKernings; if (_fontAtlas) FontAtlasCache::releaseFontAtlas(_fontAtlas); _reusedLetter->release(); } bool Label::init() { bool ret = true; if(_fontAtlas) { if (_reusedLetter == nullptr) { _reusedLetter = Sprite::createWithTexture(&_fontAtlas->getTexture(0)); _reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB); _reusedLetter->retain(); _reusedLetter->setAnchorPoint(Point::ANCHOR_TOP_LEFT); } ret = SpriteBatchNode::initWithTexture(&_fontAtlas->getTexture(0), 30); } if (_useDistanceField) setLabelEffect(LabelEffect::NORMAL,Color3B::BLACK); else if(_useA8Shader) setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR)); else setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return ret; } bool Label::initWithFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false */, bool useA8Shader /* = false */) { FontAtlas *oldAtlas = _fontAtlas; bool oldDistanceFieldEnable = _useDistanceField; bool oldA8ShaderEnabel = _useA8Shader; _fontAtlas = atlas; _useDistanceField = distanceFieldEnabled; _useA8Shader = useA8Shader; bool ret = Label::init(); if (oldAtlas) { if (ret) { FontAtlasCache::releaseFontAtlas(oldAtlas); } else { _fontAtlas = oldAtlas; _useDistanceField = oldDistanceFieldEnable; _useA8Shader = oldA8ShaderEnabel; Label::init(); FontAtlasCache::releaseFontAtlas(atlas); } } if (_fontAtlas) { _commonLineHeight = _fontAtlas->getCommonLineHeight(); if(_currentUTF16String) { resetCurrentString(); alignText(); } } return ret; } bool Label::setTTFConfig(const TTFConfig& ttfConfig) { FontAtlas *newAtlas = nullptr; if(ttfConfig.distanceFieldEnabled) newAtlas = FontAtlasCache::getFontAtlasTTF(ttfConfig.fontFilePath, DISTANCEFIELD_ATLAS_FONTSIZE, ttfConfig.glyphs, ttfConfig.customGlyphs,true); else newAtlas = FontAtlasCache::getFontAtlasTTF(ttfConfig.fontFilePath, ttfConfig.fontSize, ttfConfig.glyphs, ttfConfig.customGlyphs,false); if (!newAtlas) return false; return initWithFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true); } bool Label::setBMFontFilePath(const std::string& bmfontFilePath) { FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath); if (!newAtlas) return false; return initWithFontAtlas(newAtlas); } void Label::setString(const std::string& text) { if (!_fontAtlas || _commonLineHeight <= 0) return ; unsigned short* utf16String = cc_utf8_to_utf16(text.c_str()); if(!utf16String) return ; _originalUTF8String = text; setCurrentString(utf16String); setOriginalString(utf16String); // align text alignText(); } void Label::setAlignment(TextHAlignment alignment) { // store the new alignment if (alignment != _alignment) { // store _alignment = alignment; if (_currentUTF16String) { // reset the string resetCurrentString(); // need to align text again alignText(); } } } void Label::setWidth(float width) { if (width != _width) { // store _width = width; if (_currentUTF16String) { // reset the string resetCurrentString(); // need to align text again alignText(); } } } void Label::setLineBreakWithoutSpace(bool breakWithoutSpace) { if (breakWithoutSpace != _lineBreakWithoutSpaces) { // store _lineBreakWithoutSpaces = breakWithoutSpace; // need to align text again if(_currentUTF16String) { resetCurrentString(); alignText(); } } } void Label::setScale(float scale) { if (_useDistanceField) { scale *= 1.0f * _fontSize / DISTANCEFIELD_ATLAS_FONTSIZE; } Node::setScale(scale); } void Label::setScaleX(float scaleX) { if (_useDistanceField) { scaleX *= 1.0f * _fontSize / DISTANCEFIELD_ATLAS_FONTSIZE; } Node::setScaleX(scaleX); } void Label::setScaleY(float scaleY) { if (_useDistanceField) { scaleY *= 1.0f * _fontSize / DISTANCEFIELD_ATLAS_FONTSIZE; } Node::setScaleY(scaleY); } float Label::getScaleY() const { if (_useDistanceField) { return _scaleY / (1.0f * _fontSize / DISTANCEFIELD_ATLAS_FONTSIZE); } else { return _scaleY; } } float Label::getScaleX() const { if (_useDistanceField) { return _scaleX / (1.0f * _fontSize / DISTANCEFIELD_ATLAS_FONTSIZE); } else { return _scaleX; } } void Label::alignText() { if(_textureAtlas) _textureAtlas->removeAllQuads(); _fontAtlas->prepareLetterDefinitions(_currentUTF16String); LabelTextFormatter::createStringSprites(this); if(_width > 0 && LabelTextFormatter::multilineText(this) ) LabelTextFormatter::createStringSprites(this); LabelTextFormatter::alignText(this); int strLen = cc_wcslen(_currentUTF16String); for(const auto &child : _children) { int tag = child->getTag(); if(tag < 0 || tag >= strLen) SpriteBatchNode::removeChild(child, true); } _reusedLetter->setBatchNode(nullptr); int vaildIndex = 0; Sprite* child = nullptr; Rect uvRect; for (int ctr = 0; ctr < strLen; ++ctr) { if (_lettersInfo[ctr].def.validDefinition) { child = static_cast( this->getChildByTag(ctr) ); if (child) { uvRect.size.height = _lettersInfo[ctr].def.height; uvRect.size.width = _lettersInfo[ctr].def.width; uvRect.origin.x = _lettersInfo[ctr].def.U; uvRect.origin.y = _lettersInfo[ctr].def.V; child->setTexture(&_fontAtlas->getTexture(_lettersInfo[ctr].def.textureID)); child->setTextureRect(uvRect); } updateSpriteWithLetterDefinition(_reusedLetter,_lettersInfo[ctr].def,&_fontAtlas->getTexture(_lettersInfo[ctr].def.textureID)); _reusedLetter->setPosition(_lettersInfo[ctr].position); insertQuadFromSprite(_reusedLetter,vaildIndex++); } } updateColor(); } bool Label::computeHorizontalKernings(unsigned short int *stringToRender) { if (_horizontalKernings) { delete [] _horizontalKernings; _horizontalKernings = 0; } int letterCount = 0; _horizontalKernings = _fontAtlas->getFont()->getHorizontalKerningForTextUTF16(stringToRender, letterCount); if(!_horizontalKernings) return false; else return true; } bool Label::setOriginalString(unsigned short *stringToSet) { if (_originalUTF16String) { delete [] _originalUTF16String; _originalUTF16String = 0; } int newStringLenght = cc_wcslen(stringToSet); _originalUTF16String = new unsigned short int [newStringLenght + 1]; memset(_originalUTF16String, 0, (newStringLenght + 1) * 2); memcpy(_originalUTF16String, stringToSet, (newStringLenght * 2)); _originalUTF16String[newStringLenght] = 0; return true; } bool Label::setCurrentString(unsigned short *stringToSet) { // set the new string if (_currentUTF16String) { delete [] _currentUTF16String; _currentUTF16String = 0; } // _currentUTF16String = stringToSet; // compute the advances return computeHorizontalKernings(stringToSet); } void Label::resetCurrentString() { if ((!_currentUTF16String) && (!_originalUTF16String)) return; // set the new string if (_currentUTF16String) { delete [] _currentUTF16String; _currentUTF16String = 0; } int stringLenght = cc_wcslen(_originalUTF16String); _currentUTF16String = new unsigned short int [stringLenght + 1]; memcpy(_currentUTF16String, _originalUTF16String, stringLenght * 2); _currentUTF16String[stringLenght] = 0; } Sprite * Label::updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const FontLetterDefinition &theDefinition, Texture2D *theTexture) { if (!spriteToUpdate) { return 0; } else { Rect uvRect; uvRect.size.height = theDefinition.height; uvRect.size.width = theDefinition.width; uvRect.origin.x = theDefinition.U; uvRect.origin.y = theDefinition.V; SpriteFrame *frame = SpriteFrame::createWithTexture(theTexture, uvRect); if (frame) { spriteToUpdate->setBatchNode(this); spriteToUpdate->setSpriteFrame(frame); } return spriteToUpdate; } } bool Label::recordLetterInfo(const cocos2d::Point& point,unsigned short int theChar, int spriteIndex) { if (static_cast(spriteIndex) >= _lettersInfo.size()) { LetterInfo tmpInfo; _lettersInfo.push_back(tmpInfo); } _fontAtlas->getLetterDefinitionForChar(theChar, _lettersInfo[spriteIndex].def); _lettersInfo[spriteIndex].position = point; _lettersInfo[spriteIndex].contentSize.width = _lettersInfo[spriteIndex].def.width; _lettersInfo[spriteIndex].contentSize.height = _lettersInfo[spriteIndex].def.height; return _lettersInfo[spriteIndex].def.validDefinition; } bool Label::recordPlaceholderInfo(int spriteIndex) { if (static_cast(spriteIndex) >= _lettersInfo.size()) { LetterInfo tmpInfo; _lettersInfo.push_back(tmpInfo); } _lettersInfo[spriteIndex].def.validDefinition = false; return false; } void Label::addChild(Node * child, int zOrder/* =0 */, int tag/* =0 */) { CCASSERT(0, "addChild: is not supported on Label."); } void Label::setLabelEffect(LabelEffect effect,const Color3B& effectColor) { if(_useDistanceField == false) return; _currLabelEffect = effect; _effectColor = effectColor; switch (_currLabelEffect) { case cocos2d::LabelEffect::NORMAL: setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL)); break; case cocos2d::LabelEffect::OUTLINE: setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_OUTLINE)); break; case cocos2d::LabelEffect::SHADOW: setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_SHADOW)); break; case cocos2d::LabelEffect::GLOW: setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW)); break; default: return; } _uniformEffectColor = glGetUniformLocation(_shaderProgram->getProgram(), "v_effectColor"); } void Label::setFontSize(int fontSize) { _fontSize = fontSize; Node::setScale(1.0f*_fontSize/DISTANCEFIELD_ATLAS_FONTSIZE); } void Label::onDraw() { CC_PROFILER_START("CCSpriteBatchNode - draw"); // Optimization: Fast Dispatch if( _textureAtlas->getTotalQuads() == 0 ) { return; } CC_NODE_DRAW_SETUP(); if (_useDistanceField && _currLabelEffect != LabelEffect::NORMAL) { _shaderProgram->setUniformLocationWith3f(_uniformEffectColor, _effectColor.r/255.0f,_effectColor.g/255.0f,_effectColor.b/255.0f); } for(const auto &child: _children) child->updateTransform(); GL::blendFunc( _blendFunc.src, _blendFunc.dst ); _textureAtlas->drawQuads(); CC_PROFILER_STOP("CCSpriteBatchNode - draw"); } void Label::draw() { _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Label::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } ///// PROTOCOL STUFF Sprite * Label::getLetter(int ID) { if (ID < getStringLenght()) { if(_lettersInfo[ID].def.validDefinition == false) return nullptr; Sprite* sp = static_cast(this->getChildByTag(ID)); if (!sp) { Rect uvRect; uvRect.size.height = _lettersInfo[ID].def.height; uvRect.size.width = _lettersInfo[ID].def.width; uvRect.origin.x = _lettersInfo[ID].def.U; uvRect.origin.y = _lettersInfo[ID].def.V; sp = Sprite::createWithTexture(&_fontAtlas->getTexture(_lettersInfo[ID].def.textureID),uvRect); sp->setBatchNode(this); sp->setAnchorPoint(Point::ANCHOR_MIDDLE); sp->setPosition(Point(_lettersInfo[ID].position.x+uvRect.size.width/2,_lettersInfo[ID].position.y-uvRect.size.height/2)); sp->setOpacity(_realOpacity); this->addSpriteWithoutQuad(sp, ID, ID); } return sp; } return nullptr; } int Label::getCommonLineHeight() const { return _commonLineHeight; } // string related stuff int Label::getStringNumLines() const { int quantityOfLines = 1; unsigned int stringLen = _currentUTF16String ? cc_wcslen(_currentUTF16String) : -1; if (stringLen < 1) return stringLen; if (stringLen == 0) return (-1); // count number of lines for (unsigned int i = 0; i < stringLen - 1; ++i) { unsigned short c = _currentUTF16String[i]; if (c == '\n') { quantityOfLines++; } } return quantityOfLines; } int Label::getStringLenght() const { return _currentUTF16String ? cc_wcslen(_currentUTF16String) : 0; } unsigned short * Label::getUTF16String() const { return _currentUTF16String; } void Label::assignNewUTF16String(unsigned short *newString) { setCurrentString(newString); } TextHAlignment Label::getTextAlignment() const { return _alignment; } // label related stuff float Label::getMaxLineWidth() const { return _width; } bool Label::breakLineWithoutSpace() const { return _lineBreakWithoutSpaces; } // RGBA protocol bool Label::isOpacityModifyRGB() const { return _isOpacityModifyRGB; } void Label::setOpacityModifyRGB(bool isOpacityModifyRGB) { _isOpacityModifyRGB = isOpacityModifyRGB; for(const auto& child: _children) { child->setOpacityModifyRGB(_isOpacityModifyRGB); } _reusedLetter->setOpacityModifyRGB(true); } void Label::setColor(const Color3B& color) { _reusedLetter->setColor(color); SpriteBatchNode::setColor(color); } void Label::updateColor() { V3F_C4B_T2F_Quad *quads = _textureAtlas->getQuads(); auto count = _textureAtlas->getTotalQuads(); Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); // special opacity for premultiplied textures if (_isOpacityModifyRGB) { color4.r *= _displayedOpacity/255.0f; color4.g *= _displayedOpacity/255.0f; color4.b *= _displayedOpacity/255.0f; } for (int index=0; indexupdateQuad(&quads[index], index); } } std::string Label::getDescription() const { return StringUtils::format("

", _tag); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCMenu.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCMENU_H_ #define __CCMENU_H_ #include "CCMenuItem.h" #include "CCLayer.h" #include "CCVector.h" #include "CCEventTouch.h" #include "CCValue.h" NS_CC_BEGIN /** * @addtogroup GUI * @{ * @addtogroup menu * @{ */ /** @brief A Menu * * Features and Limitation: * - You can add MenuItem objects in runtime using addChild: * - But the only accepted children are MenuItem objects */ class CC_DLL Menu : public Layer { public: enum class State { WAITING, TRACKING_TOUCH, }; /** creates an empty Menu */ static Menu* create(); /** creates a Menu with MenuItem objects */ static Menu* create(MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION; /** creates a Menu with a Array of MenuItem objects */ static Menu* createWithArray(const Vector& arrayOfItems); /** creates a Menu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. */ static Menu* createWithItem(MenuItem* item); /** creates a Menu with MenuItem objects */ static Menu* createWithItems(MenuItem *firstItem, va_list args); /** align items vertically */ void alignItemsVertically(); /** align items vertically with padding @since v0.7.2 */ void alignItemsVerticallyWithPadding(float padding); /** align items horizontally */ void alignItemsHorizontally(); /** align items horizontally with padding @since v0.7.2 */ void alignItemsHorizontallyWithPadding(float padding); /** align items in rows of columns */ void alignItemsInColumns(int columns, ...) CC_REQUIRES_NULL_TERMINATION; void alignItemsInColumns(int columns, va_list args); void alignItemsInColumnsWithArray(const ValueVector& rows); /** align items in columns of rows */ void alignItemsInRows(int rows, ...) CC_REQUIRES_NULL_TERMINATION; void alignItemsInRows(int rows, va_list args); void alignItemsInRowsWithArray(const ValueVector& columns); virtual bool isEnabled() const { return _enabled; } virtual void setEnabled(bool value) { _enabled = value; }; virtual bool onTouchBegan(Touch* touch, Event* event); virtual void onTouchEnded(Touch* touch, Event* event); virtual void onTouchCancelled(Touch* touch, Event* event); virtual void onTouchMoved(Touch* touch, Event* event); // overrides virtual void removeChild(Node* child, bool cleanup) override; virtual void addChild(Node * child) override; virtual void addChild(Node * child, int zOrder) override; virtual void addChild(Node * child, int zOrder, int tag) override; virtual void onEnter() override; virtual void onExit() override; virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);} virtual bool isOpacityModifyRGB(void) const override { return false;} virtual std::string getDescription() const override; protected: /** * @js ctor */ Menu() : _selectedItem(nullptr) {} virtual ~Menu(); /** initializes an empty Menu */ bool init(); /** initializes a Menu with a NSArray of MenuItem objects */ bool initWithArray(const Vector& arrayOfItems); /** whether or not the menu will receive events */ bool _enabled; MenuItem* getItemForTouch(Touch * touch); State _state; MenuItem *_selectedItem; private: CC_DISALLOW_COPY_AND_ASSIGN(Menu); }; // end of GUI group /// @} /// @} NS_CC_END #endif//__CCMENU_H_ ================================================ FILE: cocos2d/cocos/2d/CCMenuItem.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCMenuItem.h" #include "CCActionInterval.h" #include "CCSprite.h" #include "CCLabelAtlas.h" #include "CCLabelTTF.h" #include "CCScriptSupport.h" #include #include #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (push) #pragma warning (disable: 4996) #endif NS_CC_BEGIN static int _globalFontSize = kItemSize; static std::string _globalFontName = "Marker Felt"; static bool _globalFontNameRelease = false; const unsigned int kCurrentItem = 0xc0c05001; const unsigned int kZoomActionTag = 0xc0c05002; const unsigned int kNormalTag = 0x1; const unsigned int kSelectedTag = 0x2; const unsigned int kDisableTag = 0x3; // // MenuItem // MenuItem* MenuItem::create() { return MenuItem::create((const ccMenuCallback&)nullptr); } // XXX deprecated MenuItem* MenuItem::create(Object *target, SEL_MenuHandler selector) { MenuItem *ret = new MenuItem(); ret->initWithTarget(target, selector); ret->autorelease(); return ret; } MenuItem* MenuItem::create( const ccMenuCallback& callback) { MenuItem *ret = new MenuItem(); ret->initWithCallback(callback); ret->autorelease(); return ret; } // XXX deprecated bool MenuItem::initWithTarget(cocos2d::Object *target, SEL_MenuHandler selector ) { _target = target; CC_SAFE_RETAIN(_target); return initWithCallback( std::bind(selector,target, std::placeholders::_1) ); } bool MenuItem::initWithCallback(const ccMenuCallback& callback) { setAnchorPoint(Point(0.5f, 0.5f)); _callback = callback; _enabled = true; _selected = false; return true; } MenuItem::~MenuItem() { CC_SAFE_RELEASE(_target); } void MenuItem::selected() { _selected = true; } void MenuItem::unselected() { _selected = false; } void MenuItem::activate() { if (_enabled) { if( _callback ) { _callback(this); } if (kScriptTypeNone != _scriptType) { BasicScriptData data(this); ScriptEvent scriptEvent(kMenuClickedEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); } } } void MenuItem::setEnabled(bool enabled) { _enabled = enabled; } bool MenuItem::isEnabled() const { return _enabled; } Rect MenuItem::rect() const { return Rect( _position.x - _contentSize.width * _anchorPoint.x, _position.y - _contentSize.height * _anchorPoint.y, _contentSize.width, _contentSize.height); } bool MenuItem::isSelected() const { return _selected; } // XXX deprecated void MenuItem::setTarget(Object *target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); setCallback( std::bind( selector, target, std::placeholders::_1) ); } void MenuItem::setCallback(const ccMenuCallback& callback) { _callback = callback; } std::string MenuItem::getDescription() const { return StringUtils::format("", _tag); } // //CCMenuItemLabel // void MenuItemLabel::setLabel(Node* var) { if (var) { addChild(var); var->setAnchorPoint(Point(0, 0)); setContentSize(var->getContentSize()); } if (_label) { removeChild(_label, true); } _label = var; } // XXX: deprecated MenuItemLabel * MenuItemLabel::create(Node*label, Object* target, SEL_MenuHandler selector) { MenuItemLabel *ret = new MenuItemLabel(); ret->initWithLabel(label, target, selector); ret->autorelease(); return ret; } MenuItemLabel * MenuItemLabel::create(Node*label, const ccMenuCallback& callback) { MenuItemLabel *ret = new MenuItemLabel(); ret->initWithLabel(label, callback); ret->autorelease(); return ret; } MenuItemLabel* MenuItemLabel::create(Node *label) { MenuItemLabel *ret = new MenuItemLabel(); ret->initWithLabel(label, (const ccMenuCallback&) nullptr); ret->autorelease(); return ret; } // XXX: deprecated bool MenuItemLabel::initWithLabel(Node* label, Object* target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); return initWithLabel(label, std::bind(selector,target, std::placeholders::_1) ); } bool MenuItemLabel::initWithLabel(Node* label, const ccMenuCallback& callback) { MenuItem::initWithCallback(callback); _originalScale = 1.0f; _colorBackup = Color3B::WHITE; setDisabledColor(Color3B(126,126,126)); this->setLabel(label); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; } MenuItemLabel::~MenuItemLabel() { } void MenuItemLabel::setString(const std::string& label) { dynamic_cast(_label)->setString(label); this->setContentSize(_label->getContentSize()); } void MenuItemLabel::activate() { if(_enabled) { this->stopAllActions(); this->setScale( _originalScale ); MenuItem::activate(); } } void MenuItemLabel::selected() { // subclass to change the default action if(_enabled) { MenuItem::selected(); Action *action = getActionByTag(kZoomActionTag); if (action) { this->stopAction(action); } else { _originalScale = this->getScale(); } Action *zoomAction = ScaleTo::create(0.1f, _originalScale * 1.2f); zoomAction->setTag(kZoomActionTag); this->runAction(zoomAction); } } void MenuItemLabel::unselected() { // subclass to change the default action if(_enabled) { MenuItem::unselected(); this->stopActionByTag(kZoomActionTag); Action *zoomAction = ScaleTo::create(0.1f, _originalScale); zoomAction->setTag(kZoomActionTag); this->runAction(zoomAction); } } void MenuItemLabel::setEnabled(bool enabled) { if( _enabled != enabled ) { if(enabled == false) { _colorBackup = _label->getColor(); _label->setColor(_disabledColor); } else { _label->setColor(_colorBackup); } } MenuItem::setEnabled(enabled); } // //CCMenuItemAtlasFont // MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap) { return MenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, (const ccMenuCallback&)nullptr); } // XXX: deprecated MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector) { MenuItemAtlasFont *ret = new MenuItemAtlasFont(); ret->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector); ret->autorelease(); return ret; } MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback) { MenuItemAtlasFont *ret = new MenuItemAtlasFont(); ret->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, callback); ret->autorelease(); return ret; } // XXX: deprecated bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); return initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, std::bind(selector,target, std::placeholders::_1) ); } bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback) { CCASSERT( value.size() != 0, "value length must be greater than 0"); LabelAtlas *label = LabelAtlas::create(); label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap); if (MenuItemLabel::initWithLabel(label, callback)) { // do something ? } return true; } // //CCMenuItemFont // void MenuItemFont::setFontSize(int s) { _globalFontSize = s; } int MenuItemFont::getFontSize() { return _globalFontSize; } void MenuItemFont::setFontName(const std::string& name) { if (_globalFontNameRelease) { _globalFontName.clear(); } _globalFontName = name; _globalFontNameRelease = true; } const std::string& MenuItemFont::getFontName() { return _globalFontName; } // XXX: deprecated MenuItemFont * MenuItemFont::create(const std::string& value, Object* target, SEL_MenuHandler selector) { MenuItemFont *ret = new MenuItemFont(); ret->initWithString(value, target, selector); ret->autorelease(); return ret; } MenuItemFont * MenuItemFont::create(const std::string& value, const ccMenuCallback& callback) { MenuItemFont *ret = new MenuItemFont(); ret->initWithString(value, callback); ret->autorelease(); return ret; } MenuItemFont * MenuItemFont::create(const std::string& value) { MenuItemFont *ret = new MenuItemFont(); ret->initWithString(value, (const ccMenuCallback&)nullptr); ret->autorelease(); return ret; } MenuItemFont::MenuItemFont() : _fontSize(0), _fontName("") {} MenuItemFont::~MenuItemFont() { CCLOGINFO("In the destructor of MenuItemFont (%p).", this); } // XXX: deprecated bool MenuItemFont::initWithString(const std::string& value, Object* target, SEL_MenuHandler selector) { CCASSERT( !value.empty(), "Value length must be greater than 0"); _target = target; CC_SAFE_RETAIN(target); return initWithString(value, std::bind(selector,target, std::placeholders::_1) ); } bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback& callback) { CCASSERT( !value.empty(), "Value length must be greater than 0"); _fontName = _globalFontName; _fontSize = _globalFontSize; LabelTTF *label = LabelTTF::create(value, _fontName, (float)_fontSize); if (MenuItemLabel::initWithLabel(label, callback)) { // do something ? } return true; } void MenuItemFont::recreateLabel() { LabelTTF *label = LabelTTF::create(dynamic_cast(_label)->getString(), _fontName.c_str(), (float)_fontSize); this->setLabel(label); } void MenuItemFont::setFontSizeObj(int s) { _fontSize = s; recreateLabel(); } int MenuItemFont::getFontSizeObj() const { return _fontSize; } void MenuItemFont::setFontNameObj(const std::string& name) { _fontName = name; recreateLabel(); } const std::string& MenuItemFont::getFontNameObj() const { return _fontName; } // //CCMenuItemSprite // void MenuItemSprite::setNormalImage(Node* image) { if (image != _normalImage) { if (image) { addChild(image, 0, kNormalTag); image->setAnchorPoint(Point(0, 0)); } if (_normalImage) { removeChild(_normalImage, true); } _normalImage = image; this->setContentSize(_normalImage->getContentSize()); this->updateImagesVisibility(); } } void MenuItemSprite::setSelectedImage(Node* image) { if (image != _normalImage) { if (image) { addChild(image, 0, kSelectedTag); image->setAnchorPoint(Point(0, 0)); } if (_selectedImage) { removeChild(_selectedImage, true); } _selectedImage = image; this->updateImagesVisibility(); } } void MenuItemSprite::setDisabledImage(Node* image) { if (image != _normalImage) { if (image) { addChild(image, 0, kDisableTag); image->setAnchorPoint(Point(0, 0)); } if (_disabledImage) { removeChild(_disabledImage, true); } _disabledImage = image; this->updateImagesVisibility(); } } // //CCMenuItemSprite // MenuItemSprite * MenuItemSprite::create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite) { return MenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, (const ccMenuCallback&)nullptr); } // XXX deprecated MenuItemSprite * MenuItemSprite::create(Node* normalSprite, Node* selectedSprite, Object* target, SEL_MenuHandler selector) { return MenuItemSprite::create(normalSprite, selectedSprite, nullptr, target, selector); } MenuItemSprite * MenuItemSprite::create(Node* normalSprite, Node* selectedSprite, const ccMenuCallback& callback) { return MenuItemSprite::create(normalSprite, selectedSprite, nullptr, callback); } // XXX deprecated MenuItemSprite * MenuItemSprite::create(Node *normalSprite, Node *selectedSprite, Node *disabledSprite, Object *target, SEL_MenuHandler selector) { MenuItemSprite *ret = new MenuItemSprite(); ret->initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector); ret->autorelease(); return ret; } MenuItemSprite * MenuItemSprite::create(Node *normalSprite, Node *selectedSprite, Node *disabledSprite, const ccMenuCallback& callback) { MenuItemSprite *ret = new MenuItemSprite(); ret->initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, callback); ret->autorelease(); return ret; } // XXX deprecated bool MenuItemSprite::initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Object* target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); return initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, std::bind(selector,target, std::placeholders::_1) ); } bool MenuItemSprite::initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback) { MenuItem::initWithCallback(callback); setNormalImage(normalSprite); setSelectedImage(selectedSprite); setDisabledImage(disabledSprite); if(_normalImage) { this->setContentSize(_normalImage->getContentSize()); } setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; } /** @since v0.99.5 */ void MenuItemSprite::selected() { MenuItem::selected(); if (_normalImage) { if (_disabledImage) { _disabledImage->setVisible(false); } if (_selectedImage) { _normalImage->setVisible(false); _selectedImage->setVisible(true); } else { _normalImage->setVisible(true); } } } void MenuItemSprite::unselected() { MenuItem::unselected(); if (_normalImage) { _normalImage->setVisible(true); if (_selectedImage) { _selectedImage->setVisible(false); } if (_disabledImage) { _disabledImage->setVisible(false); } } } void MenuItemSprite::setEnabled(bool bEnabled) { if( _enabled != bEnabled ) { MenuItem::setEnabled(bEnabled); this->updateImagesVisibility(); } } // Helper void MenuItemSprite::updateImagesVisibility() { if (_enabled) { if (_normalImage) _normalImage->setVisible(true); if (_selectedImage) _selectedImage->setVisible(false); if (_disabledImage) _disabledImage->setVisible(false); } else { if (_disabledImage) { if (_normalImage) _normalImage->setVisible(false); if (_selectedImage) _selectedImage->setVisible(false); if (_disabledImage) _disabledImage->setVisible(true); } else { if (_normalImage) _normalImage->setVisible(true); if (_selectedImage) _selectedImage->setVisible(false); if (_disabledImage) _disabledImage->setVisible(false); } } } /// /// MenuItemImage /// MenuItemImage* MenuItemImage::create() { MenuItemImage *ret = new MenuItemImage(); if (ret && ret->init()) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool MenuItemImage::init(void) { return initWithNormalImage("", "", "", (const ccMenuCallback&)nullptr); } MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage) { return MenuItemImage::create(normalImage, selectedImage, "", (const ccMenuCallback&)nullptr); } // XXX deprecated MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, Object* target, SEL_MenuHandler selector) { return MenuItemImage::create(normalImage, selectedImage, "", target, selector); } MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, const ccMenuCallback& callback) { return MenuItemImage::create(normalImage, selectedImage, "", callback); } // XXX deprecated MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector) { MenuItemImage *ret = new MenuItemImage(); if (ret && ret->initWithNormalImage(normalImage, selectedImage, disabledImage, target, selector)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, const ccMenuCallback& callback) { MenuItemImage *ret = new MenuItemImage(); if (ret && ret->initWithNormalImage(normalImage, selectedImage, disabledImage, callback)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage) { MenuItemImage *ret = new MenuItemImage(); if (ret && ret->initWithNormalImage(normalImage, selectedImage, disabledImage, (const ccMenuCallback&)nullptr)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } // XXX: deprecated bool MenuItemImage::initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector) { _target = target; CC_SAFE_RETAIN(_target); return initWithNormalImage(normalImage, selectedImage, disabledImage, std::bind(selector,target, std::placeholders::_1) ); } bool MenuItemImage::initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, const ccMenuCallback& callback) { Node *normalSprite = nullptr; Node *selectedSprite = nullptr; Node *disabledSprite = nullptr; if (normalImage.size() >0) { normalSprite = Sprite::create(normalImage); } if (selectedImage.size() >0) { selectedSprite = Sprite::create(selectedImage); } if(disabledImage.size() >0) { disabledSprite = Sprite::create(disabledImage); } return initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, callback); } // // Setter of sprite frames // void MenuItemImage::setNormalSpriteFrame(SpriteFrame * frame) { setNormalImage(Sprite::createWithSpriteFrame(frame)); } void MenuItemImage::setSelectedSpriteFrame(SpriteFrame * frame) { setSelectedImage(Sprite::createWithSpriteFrame(frame)); } void MenuItemImage::setDisabledSpriteFrame(SpriteFrame * frame) { setDisabledImage(Sprite::createWithSpriteFrame(frame)); } // // MenuItemToggle // // XXX: deprecated MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, const Vector& menuItems) { MenuItemToggle *ret = new MenuItemToggle(); ret->MenuItem::initWithTarget(target, selector); ret->_subItems = menuItems; ret->_selectedIndex = UINT_MAX; ret->setSelectedIndex(0); return ret; } MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, const Vector& menuItems) { MenuItemToggle *ret = new MenuItemToggle(); ret->MenuItem::initWithCallback(callback); ret->_subItems = menuItems; ret->_selectedIndex = UINT_MAX; ret->setSelectedIndex(0); return ret; } // XXX: deprecated MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...) { va_list args; va_start(args, item); MenuItemToggle *ret = new MenuItemToggle(); ret->initWithTarget(target, selector, item, args); ret->autorelease(); va_end(args); return ret; } MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, MenuItem* item, ...) { va_list args; va_start(args, item); MenuItemToggle *ret = new MenuItemToggle(); ret->initWithCallback(callback, item, args); ret->autorelease(); va_end(args); return ret; } MenuItemToggle * MenuItemToggle::create() { MenuItemToggle *ret = new MenuItemToggle(); ret->initWithItem(nullptr); ret->autorelease(); return ret; } // XXX: deprecated bool MenuItemToggle::initWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, va_list args) { _target = target; CC_SAFE_RETAIN(_target); return initWithCallback(std::bind( selector, target, std::placeholders::_1), item, args); } bool MenuItemToggle::initWithCallback(const ccMenuCallback &callback, MenuItem *item, va_list args) { MenuItem::initWithCallback(callback); int z = 0; MenuItem *i = item; while(i) { z++; _subItems.pushBack(i); i = va_arg(args, MenuItem*); } _selectedIndex = UINT_MAX; this->setSelectedIndex(0); return true; } MenuItemToggle* MenuItemToggle::create(MenuItem *item) { MenuItemToggle *ret = new MenuItemToggle(); ret->initWithItem(item); ret->autorelease(); return ret; } bool MenuItemToggle::initWithItem(MenuItem *item) { MenuItem::initWithCallback((const ccMenuCallback&)nullptr); if (item) { _subItems.pushBack(item); } _selectedIndex = UINT_MAX; this->setSelectedIndex(0); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); return true; } void MenuItemToggle::addSubItem(MenuItem *item) { _subItems.pushBack(item); } MenuItemToggle::~MenuItemToggle() { for(const auto &item : _subItems) { item->cleanup(); } } void MenuItemToggle::setSelectedIndex(unsigned int index) { if( index != _selectedIndex && _subItems.size() > 0 ) { _selectedIndex = index; MenuItem *currentItem = (MenuItem*)getChildByTag(kCurrentItem); if( currentItem ) { currentItem->removeFromParentAndCleanup(false); } MenuItem* item = _subItems.at(_selectedIndex); this->addChild(item, 0, kCurrentItem); Size s = item->getContentSize(); this->setContentSize(s); item->setPosition( Point( s.width/2, s.height/2 ) ); } } void MenuItemToggle::selected() { MenuItem::selected(); _subItems.at(_selectedIndex)->selected(); } void MenuItemToggle::unselected() { MenuItem::unselected(); _subItems.at(_selectedIndex)->unselected(); } void MenuItemToggle::activate() { // update index if( _enabled ) { unsigned int newIndex = (_selectedIndex + 1) % _subItems.size(); this->setSelectedIndex(newIndex); } MenuItem::activate(); } void MenuItemToggle::setEnabled(bool enabled) { if (_enabled != enabled) { MenuItem::setEnabled(enabled); for(const auto &item : _subItems) { item->setEnabled(enabled); } } } MenuItem* MenuItemToggle::getSelectedItem() { return _subItems.at(_selectedIndex); } NS_CC_END #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic warning "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (pop) #endif ================================================ FILE: cocos2d/cocos/2d/CCMenuItem.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCMENU_ITEM_H__ #define __CCMENU_ITEM_H__ // C++ includes #include // cocos2d includes #include "CCNode.h" #include "CCProtocols.h" #include "CCArray.h" NS_CC_BEGIN typedef std::function ccMenuCallback; class LabelTTF; class LabelAtlas; class Sprite; class SpriteFrame; #define kItemSize 32 /** * @addtogroup GUI * @{ * @addtogroup menu * @{ */ /** @brief MenuItem base class * * Subclass MenuItem (or any subclass) to create your custom MenuItem objects. */ class CC_DLL MenuItem : public Node { public: /** Creates a MenuItem with no target/selector */ static MenuItem* create(); /** Creates a MenuItem with a target/selector */ CC_DEPRECATED_ATTRIBUTE static MenuItem* create(Object *rec, SEL_MenuHandler selector); /** Creates a MenuItem with a target/selector */ static MenuItem* create(const ccMenuCallback& callback); /** Returns the outside box */ Rect rect() const; /** Activate the item */ virtual void activate(); /** The item was selected (not activated), similar to "mouse-over" */ virtual void selected(); /** The item was unselected */ virtual void unselected(); /** returns whether or not the item is enabled */ virtual bool isEnabled() const; /** enables or disables the item */ virtual void setEnabled(bool value); /** returns whether or not the item is selected */ virtual bool isSelected() const; /** set the callback to the menu item * @code * In js,can contain two params,the second param is jsptr * @endcode * @lua NA */ void setCallback(const ccMenuCallback& callback); /** set the target/selector of the menu item * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE void setTarget(Object *rec, SEL_MenuHandler selector); virtual std::string getDescription() const override; protected: /** * @js ctor */ MenuItem() : _selected(false) , _enabled(false) , _callback(nullptr) , _target(nullptr) {} /** * @js NA * @lua NA */ virtual ~MenuItem(); /** Initializes a MenuItem with a target/selector * @js NA * @lua NA */ bool initWithCallback(const ccMenuCallback& callback); /** Initializes a MenuItem with a target/selector * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE bool initWithTarget( Object *rec, SEL_MenuHandler selector); bool _selected; bool _enabled; // callback ccMenuCallback _callback; // If using the old API, the _target needs to be retained / released Object *_target; private: CC_DISALLOW_COPY_AND_ASSIGN(MenuItem); }; /** @brief An abstract class for "label" MenuItemLabel items Any Node that supports the LabelProtocol protocol can be added. Supported nodes: - BitmapFontAtlas - LabelAtlas - LabelTTF */ class CC_DLL MenuItemLabel : public MenuItem { public: /** creates a MenuItemLabel with a Label, target and selector */ CC_DEPRECATED_ATTRIBUTE static MenuItemLabel * create(Node*label, Object* target, SEL_MenuHandler selector); /** creates a MenuItemLabel with a Label and a callback */ static MenuItemLabel * create(Node*label, const ccMenuCallback& callback); /** creates a MenuItemLabel with a Label. Target and selector will be nil */ static MenuItemLabel* create(Node *label); /** sets a new string to the inner label */ void setString(const std::string& label); /** Gets the color that will be used to disable the item */ inline const Color3B& getDisabledColor() const { return _disabledColor; }; /** Sets the color that will be used to disable the item */ inline void setDisabledColor(const Color3B& color) { _disabledColor = color; }; /** Gets the label that is rendered. */ inline Node* getLabel() const { return _label; }; /** Sets the label that is rendered. */ void setLabel(Node* node); // Overrides virtual void activate() override; virtual void selected() override; virtual void unselected() override; virtual void setEnabled(bool enabled) override; protected: /** * @js ctor */ MenuItemLabel() : _originalScale(0.0) , _label(nullptr) {} /** * @js NA * @lua NA */ virtual ~MenuItemLabel(); /** initializes a MenuItemLabel with a Label, target and selector */ bool initWithLabel(Node* label, const ccMenuCallback& callback); /** initializes a MenuItemLabel with a Label, target and selector */ CC_DEPRECATED_ATTRIBUTE bool initWithLabel(Node* label, Object* target, SEL_MenuHandler selector); Color3B _colorBackup; float _originalScale; /** the color that will be used to disable the item */ Color3B _disabledColor; /** Label that is rendered. It can be any Node that implements the LabelProtocol */ Node* _label; private: CC_DISALLOW_COPY_AND_ASSIGN(MenuItemLabel); }; /** @brief A MenuItemAtlasFont Helper class that creates a MenuItemLabel class with a LabelAtlas */ class CC_DLL MenuItemAtlasFont : public MenuItemLabel { public: /** creates a menu item from a string and atlas with a target/selector */ static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap); /** creates a menu item from a string and atlas. Use it with MenuItemToggle */ CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector); /** creates a menu item from a string and atlas. Use it with MenuItemToggle */ static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback); protected: /** * @js ctor */ MenuItemAtlasFont(){} /** * @js NA * @lua NA */ virtual ~MenuItemAtlasFont(){} /** initializes a menu item from a string and atlas with a target/selector */ CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector); /** initializes a menu item from a string and atlas with a target/selector */ bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback); private: CC_DISALLOW_COPY_AND_ASSIGN(MenuItemAtlasFont); }; /** @brief A MenuItemFont Helper class that creates a MenuItemLabel class with a Label */ class CC_DLL MenuItemFont : public MenuItemLabel { public: /** creates a menu item from a string without target/selector. To be used with MenuItemToggle */ static MenuItemFont * create(const std::string& value = ""); /** creates a menu item from a string with a target/selector */ CC_DEPRECATED_ATTRIBUTE static MenuItemFont * create(const std::string& value, Object* target, SEL_MenuHandler selector); /** creates a menu item from a string with a target/selector */ static MenuItemFont * create(const std::string& value, const ccMenuCallback& callback); /** set default font size */ static void setFontSize(int size); /** get default font size */ static int getFontSize(); CC_DEPRECATED_ATTRIBUTE static int fontSize() { return MenuItemFont::getFontSize(); }; /** set the default font name */ static void setFontName(const std::string& name); /** get the default font name */ static const std::string& getFontName(); CC_DEPRECATED_ATTRIBUTE static const std::string& fontName() { return MenuItemFont::getFontName(); }; /** set font size * c++ can not overload static and non-static member functions with the same parameter types * so change the name to setFontSizeObj * @js setFontSize */ void setFontSizeObj(int size); /** get font size * @js getFontSize */ int getFontSizeObj() const; CC_DEPRECATED_ATTRIBUTE int fontSizeObj() const { return getFontSizeObj(); }; /** set the font name * c++ can not overload static and non-static member functions with the same parameter types * so change the name to setFontNameObj * @js setFontName */ void setFontNameObj(const std::string& name); /** returns the name of the Font * @js getFontNameObj */ const std::string& getFontNameObj() const; /** deprecated Use getFontNameObj() instead */ CC_DEPRECATED_ATTRIBUTE const std::string& fontNameObj() const { return getFontNameObj(); } protected: /** * @js ctor */ MenuItemFont(); /** * @js NA * @lua NA */ virtual ~MenuItemFont(); /** initializes a menu item from a string with a target/selector */ CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, Object* target, SEL_MenuHandler selector); /** initializes a menu item from a string with a target/selector */ bool initWithString(const std::string& value, const ccMenuCallback& callback); void recreateLabel(); int _fontSize; std::string _fontName; private: CC_DISALLOW_COPY_AND_ASSIGN(MenuItemFont); }; /** @brief MenuItemSprite accepts Node objects as items. The images has 3 different states: - unselected image - selected image - disabled image @since v0.8.0 */ class CC_DLL MenuItemSprite : public MenuItem { public: /** creates a menu item with a normal, selected and disabled image*/ static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite = nullptr); /** creates a menu item with a normal and selected image with target/selector */ CC_DEPRECATED_ATTRIBUTE static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Object* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector */ CC_DEPRECATED_ATTRIBUTE static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Object* target, SEL_MenuHandler selector); /** creates a menu item with a normal and selected image with a callable object */ static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, const ccMenuCallback& callback); /** creates a menu item with a normal,selected and disabled image with target/selector */ static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback); /** Gets the image used when the item is not selected */ inline Node* getNormalImage() const { return _normalImage; }; /** Sets the image used when the item is not selected */ void setNormalImage(Node* image); /** Gets the image used when the item is selected */ inline Node* getSelectedImage() const { return _selectedImage; }; /** Sets the image used when the item is selected */ void setSelectedImage(Node* image); /** Gets the image used when the item is disabled */ inline Node* getDisabledImage() const { return _disabledImage; }; /** Sets the image used when the item is disabled */ void setDisabledImage(Node* image); /** @since v0.99.5 */ virtual void selected(); virtual void unselected(); virtual void setEnabled(bool bEnabled); protected: MenuItemSprite() :_normalImage(nullptr) ,_selectedImage(nullptr) ,_disabledImage(nullptr) {} /** initializes a menu item with a normal, selected and disabled image with target/selector */ CC_DEPRECATED_ATTRIBUTE bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Object* target, SEL_MenuHandler selector); /** initializes a menu item with a normal, selected and disabled image with a callable object */ bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback); virtual void updateImagesVisibility(); /** the image used when the item is not selected */ Node* _normalImage; /** the image used when the item is selected */ Node* _selectedImage; /** the image used when the item is disabled */ Node* _disabledImage; private: CC_DISALLOW_COPY_AND_ASSIGN(MenuItemSprite); }; /** @brief MenuItemImage accepts images as items. The images has 3 different states: - unselected image - selected image - disabled image For best results try that all images are of the same size */ class CC_DLL MenuItemImage : public MenuItemSprite { public: /** Creates an MenuItemImage. */ static MenuItemImage* create(); /** creates a menu item with a normal and selected image*/ static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage); /** creates a menu item with a normal,selected and disabled image*/ static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage); /** creates a menu item with a normal and selected image with target/selector */ CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, Object* target, SEL_MenuHandler selector); /** creates a menu item with a normal and selected image with a callable object */ static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const ccMenuCallback& callback); /** creates a menu item with a normal,selected and disabled image with target/selector */ CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with a callable object */ static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const std::string&disabledImage, const ccMenuCallback& callback); /** sets the sprite frame for the normal image */ void setNormalSpriteFrame(SpriteFrame* frame); /** sets the sprite frame for the selected image */ void setSelectedSpriteFrame(SpriteFrame* frame); /** sets the sprite frame for the disabled image */ void setDisabledSpriteFrame(SpriteFrame* frame); protected: /** * @js ctor */ MenuItemImage(){} /** * @js NA * @lua NA */ virtual ~MenuItemImage(){} bool init(); /** initializes a menu item with a normal, selected and disabled image with target/selector */ CC_DEPRECATED_ATTRIBUTE bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector); /** initializes a menu item with a normal, selected and disabled image with a callable object */ bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, const ccMenuCallback& callback); private: CC_DISALLOW_COPY_AND_ASSIGN(MenuItemImage); }; /** @brief A MenuItemToggle A simple container class that "toggles" it's inner items The inner items can be any MenuItem */ class CC_DLL MenuItemToggle : public MenuItem { public: /** creates a menu item from a Array with a target selector * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Object* target, SEL_MenuHandler selector, const Vector& menuItems); /** creates a menu item from a list of items with a target/selector * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...)CC_REQUIRES_NULL_TERMINATION; /** creates a menu item from a Array with a callable object */ static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, const Vector& menuItems); /** creates a menu item from a list of items with a callable object */ static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION; /** creates a menu item with no target/selector and no items */ static MenuItemToggle* create(); /** creates a menu item with a item */ static MenuItemToggle* create(MenuItem *item); /** add more menu item */ void addSubItem(MenuItem *item); /** return the selected item */ MenuItem* getSelectedItem(); /** @deprecated Use getSelectedItem() instead */ CC_DEPRECATED_ATTRIBUTE MenuItem* selectedItem() { return getSelectedItem(); } /** Gets the index of the selected item */ inline unsigned int getSelectedIndex() const { return _selectedIndex; }; /** Sets the index of the selected item */ void setSelectedIndex(unsigned int index); /** Gets the array that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one. @since v0.7.2 * @js NA * @lua NA */ inline const Vector& getSubItems() const { return _subItems; }; inline Vector& getSubItems() { return _subItems; }; /** Sets the array that contains the subitems. */ inline void setSubItems(const Vector& items) { _subItems = items; } // Overrides virtual void activate() override; virtual void selected() override; virtual void unselected() override; virtual void setEnabled(bool var) override; protected: /** * @js ctor */ MenuItemToggle() : _selectedIndex(0) {} /** * @js NA * @lua NA */ virtual ~MenuItemToggle(); /** initializes a menu item from a list of items with a target selector * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, va_list args); /** initializes a menu item from a list of items with a callable object */ bool initWithCallback(const ccMenuCallback& callback, MenuItem* item, va_list args); /** initializes a menu item with a item */ bool initWithItem(MenuItem *item); /** returns the selected item */ unsigned int _selectedIndex; /** Array that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one. @since v0.7.2 */ Vector _subItems; private: CC_DISALLOW_COPY_AND_ASSIGN(MenuItemToggle); }; // end of GUI group /// @} /// @} NS_CC_END #endif //__CCMENU_ITEM_H__ ================================================ FILE: cocos2d/cocos/2d/CCMotionStreak.cpp ================================================ /**************************************************************************** Copyright (c) 2011 ForzeField Studios S.L. Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN false 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 "CCMotionStreak.h" #include "CCTextureCache.h" #include "ccGLStateCache.h" #include "CCGLProgram.h" #include "CCShaderCache.h" #include "ccMacros.h" #include "CCDirector.h" #include "CCVertex.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCRenderer.h" NS_CC_BEGIN MotionStreak::MotionStreak() : _fastMode(false) , _startingPositionInitialized(false) , _texture(nullptr) , _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED) , _positionR(Point::ZERO) , _stroke(0.0f) , _fadeDelta(0.0f) , _minSeg(0.0f) , _maxPoints(0) , _nuPoints(0) , _previousNuPoints(0) , _pointVertexes(nullptr) , _pointState(nullptr) , _vertices(nullptr) , _colorPointer(nullptr) , _texCoords(nullptr) { } MotionStreak::~MotionStreak() { CC_SAFE_RELEASE(_texture); CC_SAFE_FREE(_pointState); CC_SAFE_FREE(_pointVertexes); CC_SAFE_FREE(_vertices); CC_SAFE_FREE(_colorPointer); CC_SAFE_FREE(_texCoords); } MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path) { MotionStreak *ret = new MotionStreak(); if (ret && ret->initWithFade(fade, minSeg, stroke, color, path)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture) { MotionStreak *ret = new MotionStreak(); if (ret && ret->initWithFade(fade, minSeg, stroke, color, texture)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path) { CCASSERT(!path.empty(), "Invalid filename"); Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(path); return initWithFade(fade, minSeg, stroke, color, texture); } bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture) { Node::setPosition(Point::ZERO); setAnchorPoint(Point::ZERO); ignoreAnchorPointForPosition(true); _startingPositionInitialized = false; _positionR = Point::ZERO; _fastMode = true; _minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg; _minSeg *= _minSeg; _stroke = stroke; _fadeDelta = 1.0f/fade; _maxPoints = (int)(fade*60.0f)+2; _nuPoints = 0; _pointState = (float *)malloc(sizeof(float) * _maxPoints); _pointVertexes = (Point*)malloc(sizeof(Point) * _maxPoints); _vertices = (Vertex2F*)malloc(sizeof(Vertex2F) * _maxPoints * 2); _texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2); _colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4); // Set blend mode _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; // shader program setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); setTexture(texture); setColor(color); scheduleUpdate(); return true; } void MotionStreak::setPosition(const Point& position) { _startingPositionInitialized = true; _positionR = position; } void MotionStreak::tintWithColor(const Color3B& colors) { setColor(colors); // Fast assignation for(unsigned int i = 0; i<_nuPoints*2; i++) { *((Color3B*) (_colorPointer+i*4)) = colors; } } Texture2D* MotionStreak::getTexture(void) const { return _texture; } void MotionStreak::setTexture(Texture2D *texture) { if (_texture != texture) { CC_SAFE_RETAIN(texture); CC_SAFE_RELEASE(_texture); _texture = texture; } } void MotionStreak::setBlendFunc(const BlendFunc &blendFunc) { _blendFunc = blendFunc; } const BlendFunc& MotionStreak::getBlendFunc(void) const { return _blendFunc; } void MotionStreak::setOpacity(GLubyte opacity) { CCASSERT(false, "Set opacity no supported"); } GLubyte MotionStreak::getOpacity(void) const { CCASSERT(false, "Opacity no supported"); return 0; } void MotionStreak::setOpacityModifyRGB(bool bValue) { CC_UNUSED_PARAM(bValue); } bool MotionStreak::isOpacityModifyRGB(void) const { return false; } void MotionStreak::update(float delta) { if (!_startingPositionInitialized) { return; } delta *= _fadeDelta; unsigned int newIdx, newIdx2, i, i2; unsigned int mov = 0; // Update current points for(i = 0; i<_nuPoints; i++) { _pointState[i]-=delta; if(_pointState[i] <= 0) mov++; else { newIdx = i-mov; if(mov>0) { // Move data _pointState[newIdx] = _pointState[i]; // Move point _pointVertexes[newIdx] = _pointVertexes[i]; // Move vertices i2 = i*2; newIdx2 = newIdx*2; _vertices[newIdx2] = _vertices[i2]; _vertices[newIdx2+1] = _vertices[i2+1]; // Move color i2 *= 4; newIdx2 *= 4; _colorPointer[newIdx2+0] = _colorPointer[i2+0]; _colorPointer[newIdx2+1] = _colorPointer[i2+1]; _colorPointer[newIdx2+2] = _colorPointer[i2+2]; _colorPointer[newIdx2+4] = _colorPointer[i2+4]; _colorPointer[newIdx2+5] = _colorPointer[i2+5]; _colorPointer[newIdx2+6] = _colorPointer[i2+6]; }else newIdx2 = newIdx*8; const GLubyte op = (GLubyte)(_pointState[newIdx] * 255.0f); _colorPointer[newIdx2+3] = op; _colorPointer[newIdx2+7] = op; } } _nuPoints-=mov; // Append new point bool appendNewPoint = true; if(_nuPoints >= _maxPoints) { appendNewPoint = false; } else if(_nuPoints>0) { bool a1 = _pointVertexes[_nuPoints-1].getDistanceSq(_positionR) < _minSeg; bool a2 = (_nuPoints == 1) ? false : (_pointVertexes[_nuPoints-2].getDistanceSq(_positionR)< (_minSeg * 2.0f)); if(a1 || a2) { appendNewPoint = false; } } if(appendNewPoint) { _pointVertexes[_nuPoints] = _positionR; _pointState[_nuPoints] = 1.0f; // Color assignment const unsigned int offset = _nuPoints*8; *((Color3B*)(_colorPointer + offset)) = _displayedColor; *((Color3B*)(_colorPointer + offset+4)) = _displayedColor; // Opacity _colorPointer[offset+3] = 255; _colorPointer[offset+7] = 255; // Generate polygon if(_nuPoints > 0 && _fastMode ) { if(_nuPoints > 1) { ccVertexLineToPolygon(_pointVertexes, _stroke, _vertices, _nuPoints, 1); } else { ccVertexLineToPolygon(_pointVertexes, _stroke, _vertices, 0, 2); } } _nuPoints ++; } if( ! _fastMode ) { ccVertexLineToPolygon(_pointVertexes, _stroke, _vertices, 0, _nuPoints); } // Updated Tex Coords only if they are different than previous step if( _nuPoints && _previousNuPoints != _nuPoints ) { float texDelta = 1.0f / _nuPoints; for( i=0; i < _nuPoints; i++ ) { _texCoords[i*2] = Tex2F(0, texDelta*i); _texCoords[i*2+1] = Tex2F(1, texDelta*i); } _previousNuPoints = _nuPoints; } } void MotionStreak::reset() { _nuPoints = 0; } void MotionStreak::onDraw() { getShaderProgram()->use(); getShaderProgram()->setUniformsForBuiltins(_cachedMV); GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); GL::blendFunc( _blendFunc.src, _blendFunc.dst ); GL::bindTexture2D( _texture->getName() ); #ifdef EMSCRIPTEN // Size calculations from ::initWithFade setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoords); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2); } void MotionStreak::draw() { if(_nuPoints <= 1) return; kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV); _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCMotionStreak.h ================================================ /**************************************************************************** Copyright (c) 2011 ForzeField Studios S.L. Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCMOTION_STREAK_H__ #define __CCMOTION_STREAK_H__ #include "CCProtocols.h" #include "CCTexture2D.h" #include "ccTypes.h" #include "CCNode.h" #include "renderer/CCCustomCommand.h" #ifdef EMSCRIPTEN #include "CCGLBufferedNode.h" #endif // EMSCRIPTEN NS_CC_BEGIN /** * @addtogroup misc_nodes * @{ */ /** MotionStreak. Creates a trailing path. */ class CC_DLL MotionStreak : public Node, public TextureProtocol #ifdef EMSCRIPTEN , public GLBufferedNode #endif // EMSCRIPTEN { public: /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */ static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path); /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */ static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture); /** color used for the tint */ void tintWithColor(const Color3B& colors); /** Remove all living segments of the ribbon */ void reset(); /** When fast mode is enabled, new points are added faster but with lower precision */ inline bool isFastMode() const { return _fastMode; } inline void setFastMode(bool bFastMode) { _fastMode = bFastMode; } inline bool isStartingPositionInitialized() const { return _startingPositionInitialized; } inline void setStartingPositionInitialized(bool bStartingPositionInitialized) { _startingPositionInitialized = bStartingPositionInitialized; } // Overrides virtual void setPosition(const Point& position) override; /** * @js NA * @lua NA */ virtual void draw() override; /** * @js NA * @lua NA */ virtual void update(float delta) override; virtual Texture2D* getTexture() const override; virtual void setTexture(Texture2D *texture) override; /** * @js NA * @lua NA */ virtual void setBlendFunc(const BlendFunc &blendFunc) override; /** * @js NA * @lua NA */ virtual const BlendFunc& getBlendFunc() const override; virtual GLubyte getOpacity() const override; virtual void setOpacity(GLubyte opacity) override; virtual void setOpacityModifyRGB(bool value) override; virtual bool isOpacityModifyRGB() const override; protected: kmMat4 _cachedMV; //renderer callback void onDraw(); protected: /** * @js ctor */ MotionStreak(); /** * @js NA * @lua NA */ virtual ~MotionStreak(); /** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */ bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path); /** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture */ bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture); bool _fastMode; bool _startingPositionInitialized; /** texture used for the motion streak */ Texture2D* _texture; BlendFunc _blendFunc; Point _positionR; float _stroke; float _fadeDelta; float _minSeg; unsigned int _maxPoints; unsigned int _nuPoints; unsigned int _previousNuPoints; /** Pointers */ Point* _pointVertexes; float* _pointState; // Opengl Vertex2F* _vertices; GLubyte* _colorPointer; Tex2F* _texCoords; CustomCommand _customCommand; private: CC_DISALLOW_COPY_AND_ASSIGN(MotionStreak); }; // end of misc_nodes group /// @} NS_CC_END #endif //__CCMOTION_STREAK_H__ ================================================ FILE: cocos2d/cocos/2d/CCNode.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCNode.h" #include #include "CCString.h" #include "ccCArray.h" #include "TransformUtils.h" #include "CCGrid.h" #include "CCDirector.h" #include "CCScheduler.h" #include "CCTouch.h" #include "CCActionManager.h" #include "CCScriptSupport.h" #include "CCGLProgram.h" #include "CCEventDispatcher.h" #include "CCEvent.h" #include "CCEventTouch.h" #include "CCScene.h" #if CC_USE_PHYSICS #include "CCPhysicsBody.h" #endif // externals #include "kazmath/GL/matrix.h" #include "CCComponent.h" #include "CCComponentContainer.h" #if CC_NODE_RENDER_SUBPIXEL #define RENDER_IN_SUBPIXEL #else #define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) #endif NS_CC_BEGIN bool nodeComparisonLess(Node* n1, Node* n2) { return( n1->getLocalZOrder() < n2->getLocalZOrder() || ( n1->getLocalZOrder() == n2->getLocalZOrder() && n1->getOrderOfArrival() < n2->getOrderOfArrival() ) ); } // XXX: Yes, nodes might have a sort problem once every 15 days if the game runs at 60 FPS and each frame sprites are reordered. static int s_globalOrderOfArrival = 1; Node::Node(void) : _rotationX(0.0f) , _rotationY(0.0f) , _scaleX(1.0f) , _scaleY(1.0f) , _vertexZ(0.0f) , _position(Point::ZERO) , _skewX(0.0f) , _skewY(0.0f) , _anchorPointInPoints(Point::ZERO) , _anchorPoint(Point::ZERO) , _contentSize(Size::ZERO) , _useAdditionalTransform(false) , _transformDirty(true) , _inverseDirty(true) // children (lazy allocs) // lazy alloc , _localZOrder(0) , _globalZOrder(0) , _parent(nullptr) // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true , _tag(Node::INVALID_TAG) // userData is always inited as nil , _userData(nullptr) , _userObject(nullptr) , _shaderProgram(nullptr) , _orderOfArrival(0) , _running(false) , _visible(true) , _ignoreAnchorPointForPosition(false) , _reorderChildDirty(false) , _isTransitionFinished(false) , _updateScriptHandler(0) , _componentContainer(nullptr) #if CC_USE_PHYSICS , _physicsBody(nullptr) #endif , _displayedOpacity(255) , _realOpacity(255) , _displayedColor(Color3B::WHITE) , _realColor(Color3B::WHITE) , _cascadeColorEnabled(false) , _cascadeOpacityEnabled(false) { // set default scheduler and actionManager Director *director = Director::getInstance(); _actionManager = director->getActionManager(); _actionManager->retain(); _scheduler = director->getScheduler(); _scheduler->retain(); _eventDispatcher = director->getEventDispatcher(); _eventDispatcher->retain(); ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone; kmMat4Identity(&_transform); kmMat4Identity(&_inverse); kmMat4Identity(&_additionalTransform); } Node::~Node() { CCLOGINFO( "deallocing Node: %p - tag: %i", this, _tag ); if (_updateScriptHandler) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(_updateScriptHandler); } CC_SAFE_RELEASE(_actionManager); CC_SAFE_RELEASE(_scheduler); _eventDispatcher->cleanTarget(this); CC_SAFE_RELEASE(_eventDispatcher); // attributes CC_SAFE_RELEASE(_shaderProgram); CC_SAFE_RELEASE(_userObject); for (auto& child : _children) { child->_parent = nullptr; } removeAllComponents(); CC_SAFE_DELETE(_componentContainer); #if CC_USE_PHYSICS CC_SAFE_RELEASE(_physicsBody); #endif } bool Node::init() { return true; } float Node::getSkewX() const { return _skewX; } void Node::setSkewX(float newSkewX) { _skewX = newSkewX; _transformDirty = _inverseDirty = true; } float Node::getSkewY() const { return _skewY; } void Node::setSkewY(float newSkewY) { _skewY = newSkewY; _transformDirty = _inverseDirty = true; } /// zOrder setter : private method /// used internally to alter the zOrder variable. DON'T call this method manually void Node::_setLocalZOrder(int z) { _localZOrder = z; } void Node::setLocalZOrder(int z) { _localZOrder = z; if (_parent) { _parent->reorderChild(this, z); } _eventDispatcher->setDirtyForNode(this); } void Node::setGlobalZOrder(float globalZOrder) { if (_globalZOrder != globalZOrder) { _globalZOrder = globalZOrder; _eventDispatcher->setDirtyForNode(this); } } /// vertexZ getter float Node::getVertexZ() const { return _vertexZ; } /// vertexZ setter void Node::setVertexZ(float zOrder) { _vertexZ = zOrder; setGlobalZOrder(zOrder); } /// rotation getter float Node::getRotation() const { CCASSERT(_rotationX == _rotationY, "CCNode#rotation. RotationX != RotationY. Don't know which one to return"); return _rotationX; } /// rotation setter void Node::setRotation(float newRotation) { _rotationX = _rotationY = newRotation; _transformDirty = _inverseDirty = true; #if CC_USE_PHYSICS if (_physicsBody) { _physicsBody->setRotation(newRotation); } #endif } float Node::getRotationX() const { return _rotationX; } void Node::setRotationX(float fRotationX) { _rotationX = fRotationX; _transformDirty = _inverseDirty = true; } float Node::getRotationY() const { return _rotationY; } void Node::setRotationY(float rotationY) { _rotationY = rotationY; _transformDirty = _inverseDirty = true; } /// scale getter float Node::getScale(void) const { CCASSERT( _scaleX == _scaleY, "CCNode#scale. ScaleX != ScaleY. Don't know which one to return"); return _scaleX; } /// scale setter void Node::setScale(float scale) { _scaleX = _scaleY = scale; _transformDirty = _inverseDirty = true; } /// scaleX getter float Node::getScaleX() const { return _scaleX; } /// scale setter void Node::setScale(float scaleX,float scaleY) { _scaleX = scaleX; _scaleY = scaleY; _transformDirty = _inverseDirty = true; } /// scaleX setter void Node::setScaleX(float newScaleX) { _scaleX = newScaleX; _transformDirty = _inverseDirty = true; } /// scaleY getter float Node::getScaleY() const { return _scaleY; } /// scaleY setter void Node::setScaleY(float newScaleY) { _scaleY = newScaleY; _transformDirty = _inverseDirty = true; } /// position getter const Point& Node::getPosition() const { return _position; } /// position setter void Node::setPosition(const Point& newPosition) { _position = newPosition; _transformDirty = _inverseDirty = true; #if CC_USE_PHYSICS if (_physicsBody) { _physicsBody->setPosition(newPosition); } #endif } void Node::getPosition(float* x, float* y) const { *x = _position.x; *y = _position.y; } void Node::setPosition(float x, float y) { setPosition(Point(x, y)); } float Node::getPositionX() const { return _position.x; } float Node::getPositionY() const { return _position.y; } void Node::setPositionX(float x) { setPosition(Point(x, _position.y)); } void Node::setPositionY(float y) { setPosition(Point(_position.x, y)); } ssize_t Node::getChildrenCount() const { return _children.size(); } /// isVisible getter bool Node::isVisible() const { return _visible; } /// isVisible setter void Node::setVisible(bool var) { _visible = var; } const Point& Node::getAnchorPointInPoints() const { return _anchorPointInPoints; } /// anchorPoint getter const Point& Node::getAnchorPoint() const { return _anchorPoint; } void Node::setAnchorPoint(const Point& point) { if( ! point.equals(_anchorPoint)) { _anchorPoint = point; _anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); _transformDirty = _inverseDirty = true; } } /// contentSize getter const Size& Node::getContentSize() const { return _contentSize; } void Node::setContentSize(const Size & size) { if ( ! size.equals(_contentSize)) { _contentSize = size; _anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); _transformDirty = _inverseDirty = true; } } // isRunning getter bool Node::isRunning() const { return _running; } /// parent setter void Node::setParent(Node * var) { _parent = var; } /// isRelativeAnchorPoint getter bool Node::isIgnoreAnchorPointForPosition() const { return _ignoreAnchorPointForPosition; } /// isRelativeAnchorPoint setter void Node::ignoreAnchorPointForPosition(bool newValue) { if (newValue != _ignoreAnchorPointForPosition) { _ignoreAnchorPointForPosition = newValue; _transformDirty = _inverseDirty = true; } } /// tag getter int Node::getTag() const { return _tag; } /// tag setter void Node::setTag(int var) { _tag = var; } /// userData setter void Node::setUserData(void *var) { _userData = var; } int Node::getOrderOfArrival() const { return _orderOfArrival; } void Node::setOrderOfArrival(int orderOfArrival) { CCASSERT(orderOfArrival >=0, "Invalid orderOfArrival"); _orderOfArrival = orderOfArrival; } void Node::setUserObject(Object *pUserObject) { CC_SAFE_RETAIN(pUserObject); CC_SAFE_RELEASE(_userObject); _userObject = pUserObject; } void Node::setShaderProgram(GLProgram *pShaderProgram) { CC_SAFE_RETAIN(pShaderProgram); CC_SAFE_RELEASE(_shaderProgram); _shaderProgram = pShaderProgram; } Scene* Node::getScene() { if(!_parent) return nullptr; return _parent->getScene(); } Rect Node::getBoundingBox() const { Rect rect = Rect(0, 0, _contentSize.width, _contentSize.height); return RectApplyAffineTransform(rect, getNodeToParentAffineTransform()); } Node * Node::create(void) { Node * ret = new Node(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } void Node::cleanup() { // actions this->stopAllActions(); this->unscheduleAllSelectors(); if ( _scriptType != kScriptTypeNone) { int action = kNodeOnCleanup; BasicScriptData data(this,(void*)&action); ScriptEvent scriptEvent(kNodeEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); } // timers for( const auto &child: _children) child->cleanup(); } std::string Node::getDescription() const { return StringUtils::format("_tag == tag) return child; } return nullptr; } /* "add" logic MUST only be on this method * If a class want's to extend the 'addChild' behavior it only needs * to override this method */ void Node::addChild(Node *child, int zOrder, int tag) { CCASSERT( child != nullptr, "Argument must be non-nil"); CCASSERT( child->_parent == nullptr, "child already added. It can't be added again"); if (_children.empty()) { this->childrenAlloc(); } this->insertChild(child, zOrder); #if CC_USE_PHYSICS for (Node* node = this->getParent(); node != nullptr; node = node->getParent()) { if (dynamic_cast(node) != nullptr) { (dynamic_cast(node))->addChildToPhysicsWorld(child); break; } } #endif child->_tag = tag; child->setParent(this); child->setOrderOfArrival(s_globalOrderOfArrival++); if( _running ) { child->onEnter(); // prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter if (_isTransitionFinished) { child->onEnterTransitionDidFinish(); } } if (_cascadeColorEnabled) { updateCascadeColor(); } if (_cascadeOpacityEnabled) { updateCascadeOpacity(); } } void Node::addChild(Node *child, int zOrder) { CCASSERT( child != nullptr, "Argument must be non-nil"); this->addChild(child, zOrder, child->_tag); } void Node::addChild(Node *child) { CCASSERT( child != nullptr, "Argument must be non-nil"); this->addChild(child, child->_localZOrder, child->_tag); } void Node::removeFromParent() { this->removeFromParentAndCleanup(true); } void Node::removeFromParentAndCleanup(bool cleanup) { if (_parent != nullptr) { _parent->removeChild(this,cleanup); } } /* "remove" logic MUST only be on this method * If a class want's to extend the 'removeChild' behavior it only needs * to override this method */ void Node::removeChild(Node* child, bool cleanup /* = true */) { // explicit nil handling if (_children.empty()) { return; } ssize_t index = _children.getIndex(child); if( index != CC_INVALID_INDEX ) this->detachChild( child, index, cleanup ); } void Node::removeChildByTag(int tag, bool cleanup/* = true */) { CCASSERT( tag != Node::INVALID_TAG, "Invalid tag"); Node *child = this->getChildByTag(tag); if (child == nullptr) { CCLOG("cocos2d: removeChildByTag(tag = %d): child not found!", tag); } else { this->removeChild(child, cleanup); } } void Node::removeAllChildren() { this->removeAllChildrenWithCleanup(true); } void Node::removeAllChildrenWithCleanup(bool cleanup) { // not using detachChild improves speed here for (auto& child : _children) { // IMPORTANT: // -1st do onExit // -2nd cleanup if(_running) { child->onExitTransitionDidStart(); child->onExit(); } if (cleanup) { child->cleanup(); } // set parent nil at the end child->setParent(nullptr); } _children.clear(); } void Node::detachChild(Node *child, ssize_t childIndex, bool doCleanup) { // IMPORTANT: // -1st do onExit // -2nd cleanup if (_running) { child->onExitTransitionDidStart(); child->onExit(); } #if CC_USE_PHYSICS if (child->_physicsBody != nullptr) { child->_physicsBody->removeFromWorld(); } #endif // If you don't do cleanup, the child's actions will not get removed and the // its scheduledSelectors_ dict will not get released! if (doCleanup) { child->cleanup(); } // set parent nil at the end child->setParent(nullptr); _children.erase(childIndex); } // helper used by reorderChild & add void Node::insertChild(Node* child, int z) { _reorderChildDirty = true; _children.pushBack(child); child->_setLocalZOrder(z); } void Node::reorderChild(Node *child, int zOrder) { CCASSERT( child != nullptr, "Child must be non-nil"); _reorderChildDirty = true; child->setOrderOfArrival(s_globalOrderOfArrival++); child->_setLocalZOrder(zOrder); } void Node::sortAllChildren() { if( _reorderChildDirty ) { std::sort( std::begin(_children), std::end(_children), nodeComparisonLess ); _reorderChildDirty = false; } } void Node::draw() { //CCASSERT(0); // override me // Only use- this function to draw your stuff. // DON'T draw your stuff outside this method } void Node::visit() { // quick return if not visible. children won't be drawn. if (!_visible) { return; } kmGLPushMatrix(); this->transform(); int i = 0; if(!_children.empty()) { sortAllChildren(); // draw children zOrder < 0 for( ; i < _children.size(); i++ ) { auto node = _children.at(i); if ( node && node->_localZOrder < 0 ) node->visit(); else break; } // self draw this->draw(); for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) (*it)->visit(); } else { this->draw(); } // reset for next frame _orderOfArrival = 0; kmGLPopMatrix(); } void Node::transformAncestors() { if( _parent != nullptr ) { _parent->transformAncestors(); _parent->transform(); } } void Node::transform() { #if CC_USE_PHYSICS updatePhysicsTransform(); #endif kmMat4 transfrom4x4 = this->getNodeToParentTransform(); kmGLMultMatrix( &transfrom4x4 ); // saves the MV matrix kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewTransform); } void Node::onEnter() { _isTransitionFinished = false; if (_scriptType != kScriptTypeNone) { int action = kNodeOnEnter; BasicScriptData data(this,(void*)&action); ScriptEvent scriptEvent(kNodeEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); } for( const auto &child: _children) child->onEnter(); this->resume(); _running = true; } void Node::onEnterTransitionDidFinish() { _isTransitionFinished = true; if (_scriptType != kScriptTypeNone) { int action = kNodeOnEnterTransitionDidFinish; BasicScriptData data(this,(void*)&action); ScriptEvent scriptEvent(kNodeEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); } for( const auto &child: _children) child->onEnterTransitionDidFinish(); } void Node::onExitTransitionDidStart() { for( const auto &child: _children) child->onExitTransitionDidStart(); if (_scriptType != kScriptTypeNone) { int action = kNodeOnExitTransitionDidStart; BasicScriptData data(this,(void*)&action); ScriptEvent scriptEvent(kNodeEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); } } void Node::onExit() { this->pause(); _running = false; for( const auto &child: _children) child->onExit(); if (_scriptType != kScriptTypeNone) { int action = kNodeOnExit; BasicScriptData data(this,(void*)&action); ScriptEvent scriptEvent(kNodeEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); } } void Node::setEventDispatcher(EventDispatcher* dispatcher) { if (dispatcher != _eventDispatcher) { _eventDispatcher->cleanTarget(this); CC_SAFE_RETAIN(dispatcher); CC_SAFE_RELEASE(_eventDispatcher); _eventDispatcher = dispatcher; } } void Node::setActionManager(ActionManager* actionManager) { if( actionManager != _actionManager ) { this->stopAllActions(); CC_SAFE_RETAIN(actionManager); CC_SAFE_RELEASE(_actionManager); _actionManager = actionManager; } } Action * Node::runAction(Action* action) { CCASSERT( action != nullptr, "Argument must be non-nil"); _actionManager->addAction(action, this, !_running); return action; } void Node::stopAllActions() { _actionManager->removeAllActionsFromTarget(this); } void Node::stopAction(Action* action) { _actionManager->removeAction(action); } void Node::stopActionByTag(int tag) { CCASSERT( tag != Action::INVALID_TAG, "Invalid tag"); _actionManager->removeActionByTag(tag, this); } Action * Node::getActionByTag(int tag) { CCASSERT( tag != Action::INVALID_TAG, "Invalid tag"); return _actionManager->getActionByTag(tag, this); } ssize_t Node::getNumberOfRunningActions() const { return _actionManager->getNumberOfRunningActionsInTarget(this); } // Node - Callbacks void Node::setScheduler(Scheduler* scheduler) { if( scheduler != _scheduler ) { this->unscheduleAllSelectors(); CC_SAFE_RETAIN(scheduler); CC_SAFE_RELEASE(_scheduler); _scheduler = scheduler; } } bool Node::isScheduled(SEL_SCHEDULE selector) { return _scheduler->isScheduledForTarget(selector, this); } void Node::scheduleUpdate() { scheduleUpdateWithPriority(0); } void Node::scheduleUpdateWithPriority(int priority) { _scheduler->scheduleUpdateForTarget(this, priority, !_running); } void Node::scheduleUpdateWithPriorityLua(int nHandler, int priority) { unscheduleUpdate(); _updateScriptHandler = nHandler; _scheduler->scheduleUpdateForTarget(this, priority, !_running); } void Node::unscheduleUpdate() { _scheduler->unscheduleUpdateForTarget(this); if (_updateScriptHandler) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(_updateScriptHandler); _updateScriptHandler = 0; } } void Node::schedule(SEL_SCHEDULE selector) { this->schedule(selector, 0.0f, kRepeatForever, 0.0f); } void Node::schedule(SEL_SCHEDULE selector, float interval) { this->schedule(selector, interval, kRepeatForever, 0.0f); } void Node::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay) { CCASSERT( selector, "Argument must be non-nil"); CCASSERT( interval >=0, "Argument must be positive"); _scheduler->scheduleSelector(selector, this, interval , repeat, delay, !_running); } void Node::scheduleOnce(SEL_SCHEDULE selector, float delay) { this->schedule(selector, 0.0f, 0, delay); } void Node::unschedule(SEL_SCHEDULE selector) { // explicit nil handling if (selector == 0) return; _scheduler->unscheduleSelector(selector, this); } void Node::unscheduleAllSelectors() { _scheduler->unscheduleAllForTarget(this); } void Node::resume() { _scheduler->resumeTarget(this); _actionManager->resumeTarget(this); _eventDispatcher->resumeTarget(this); } void Node::pause() { _scheduler->pauseTarget(this); _actionManager->pauseTarget(this); _eventDispatcher->pauseTarget(this); } void Node::resumeSchedulerAndActions() { resume(); } void Node::pauseSchedulerAndActions() { pause(); } // override me void Node::update(float fDelta) { if (0 != _updateScriptHandler) { //only lua use SchedulerScriptData data(_updateScriptHandler,fDelta); ScriptEvent event(kScheduleEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } if (_componentContainer && !_componentContainer->isEmpty()) { _componentContainer->visit(fDelta); } } AffineTransform Node::getNodeToParentAffineTransform() const { AffineTransform ret; kmMat4 ret4 = getNodeToParentTransform(); GLToCGAffine(ret4.mat, &ret); return ret; } const kmMat4& Node::getNodeToParentTransform() const { if (_transformDirty) { // Translate values float x = _position.x; float y = _position.y; if (_ignoreAnchorPointForPosition) { x += _anchorPointInPoints.x; y += _anchorPointInPoints.y; } // Rotation values // Change rotation code to handle X and Y // If we skew with the exact same value for both x and y then we're simply just rotating float cx = 1, sx = 0, cy = 1, sy = 0; if (_rotationX || _rotationY) { float radiansX = -CC_DEGREES_TO_RADIANS(_rotationX); float radiansY = -CC_DEGREES_TO_RADIANS(_rotationY); cx = cosf(radiansX); sx = sinf(radiansX); cy = cosf(radiansY); sy = sinf(radiansY); } bool needsSkewMatrix = ( _skewX || _skewY ); // optimization: // inline anchor point calculation if skew is not needed // Adjusted transform calculation for rotational skew if (! needsSkewMatrix && !_anchorPointInPoints.equals(Point::ZERO)) { x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY; y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY; } // Build Transform Matrix // Adjusted transform calculation for rotational skew kmScalar mat[] = { cy * _scaleX, sy * _scaleX, 0, 0, -sx * _scaleY, cx * _scaleY, 0, 0, 0, 0, 1, 0, x, y, 0, 1 }; kmMat4Fill(&_transform, mat); // XXX: Try to inline skew // If skew is needed, apply skew and then anchor point if (needsSkewMatrix) { kmMat4 skewMatrix = { 1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, (float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; kmMat4Multiply(&_transform, &_transform, &skewMatrix); // adjust anchor point if (!_anchorPointInPoints.equals(Point::ZERO)) { // XXX: Argh, kmMat needs a "translate" method. // XXX: Although this is faster than multiplying a vec4 * mat4 _transform.mat[12] += _transform.mat[0] * -_anchorPointInPoints.x + _transform.mat[4] * -_anchorPointInPoints.y; _transform.mat[13] += _transform.mat[1] * -_anchorPointInPoints.x + _transform.mat[5] * -_anchorPointInPoints.y; } } // vertex Z _transform.mat[14] = _vertexZ; if (_useAdditionalTransform) { kmMat4Multiply(&_transform, &_transform, &_additionalTransform); } _transformDirty = false; } return _transform; } void Node::setNodeToParentTransform(const kmMat4& transform) { _transform = transform; _transformDirty = false; } void Node::setAdditionalTransform(const AffineTransform& additionalTransform) { CGAffineToGL(additionalTransform, _additionalTransform.mat); _transformDirty = true; _useAdditionalTransform = true; } void Node::setAdditionalTransform(const kmMat4& additionalTransform) { _additionalTransform = additionalTransform; _transformDirty = true; _useAdditionalTransform = true; } AffineTransform Node::getParentToNodeAffineTransform() const { AffineTransform ret; kmMat4 ret4 = getParentToNodeTransform(); GLToCGAffine(ret4.mat,&ret); return ret; } const kmMat4& Node::getParentToNodeTransform() const { if ( _inverseDirty ) { kmMat4Inverse(&_inverse, &_transform); _inverseDirty = false; } return _inverse; } AffineTransform Node::getNodeToWorldAffineTransform() const { AffineTransform t = this->getNodeToParentAffineTransform(); for (Node *p = _parent; p != nullptr; p = p->getParent()) t = AffineTransformConcat(t, p->getNodeToParentAffineTransform()); return t; } kmMat4 Node::getNodeToWorldTransform() const { kmMat4 t = this->getNodeToParentTransform(); for (Node *p = _parent; p != nullptr; p = p->getParent()) kmMat4Multiply(&t, &p->getNodeToParentTransform(), &t); return t; } AffineTransform Node::getWorldToNodeAffineTransform() const { return AffineTransformInvert(this->getNodeToWorldAffineTransform()); } kmMat4 Node::getWorldToNodeTransform() const { kmMat4 tmp, tmp2; tmp2 = this->getNodeToWorldTransform(); kmMat4Inverse(&tmp, &tmp2); return tmp; } Point Node::convertToNodeSpace(const Point& worldPoint) const { kmMat4 tmp = getWorldToNodeTransform(); kmVec3 vec3 = {worldPoint.x, worldPoint.y, 0}; kmVec3 ret; kmVec3Transform(&ret, &vec3, &tmp); return Point(ret.x, ret.y); } Point Node::convertToWorldSpace(const Point& nodePoint) const { kmMat4 tmp = getNodeToWorldTransform(); kmVec3 vec3 = {nodePoint.x, nodePoint.y, 0}; kmVec3 ret; kmVec3Transform(&ret, &vec3, &tmp); return Point(ret.x, ret.y); } Point Node::convertToNodeSpaceAR(const Point& worldPoint) const { Point nodePoint = convertToNodeSpace(worldPoint); return nodePoint - _anchorPointInPoints; } Point Node::convertToWorldSpaceAR(const Point& nodePoint) const { Point pt = nodePoint + _anchorPointInPoints; return convertToWorldSpace(pt); } Point Node::convertToWindowSpace(const Point& nodePoint) const { Point worldPoint = this->convertToWorldSpace(nodePoint); return Director::getInstance()->convertToUI(worldPoint); } // convenience methods which take a Touch instead of Point Point Node::convertTouchToNodeSpace(Touch *touch) const { Point point = touch->getLocation(); return this->convertToNodeSpace(point); } Point Node::convertTouchToNodeSpaceAR(Touch *touch) const { Point point = touch->getLocation(); return this->convertToNodeSpaceAR(point); } #if CC_USE_PHYSICS bool Node::updatePhysicsTransform() { if (_physicsBody != nullptr && _physicsBody->getWorld() != nullptr && !_physicsBody->isResting()) { _position = _physicsBody->getPosition(); _rotationX = _rotationY = _physicsBody->getRotation(); _transformDirty = _inverseDirty = true; return true; } return false; } #endif void Node::updateTransform() { // Recursively iterate over children for( const auto &child: _children) child->updateTransform(); } Component* Node::getComponent(const std::string& pName) { if( _componentContainer ) return _componentContainer->get(pName); return nullptr; } bool Node::addComponent(Component *pComponent) { // lazy alloc if( !_componentContainer ) _componentContainer = new ComponentContainer(this); return _componentContainer->add(pComponent); } bool Node::removeComponent(const std::string& pName) { if( _componentContainer ) return _componentContainer->remove(pName); return false; } void Node::removeAllComponents() { if( _componentContainer ) _componentContainer->removeAll(); } #if CC_USE_PHYSICS void Node::setPhysicsBody(PhysicsBody* body) { if (_physicsBody != nullptr) { _physicsBody->_node = nullptr; _physicsBody->release(); } _physicsBody = body; _physicsBody->_node = this; _physicsBody->retain(); _physicsBody->setPosition(getPosition()); _physicsBody->setRotation(getRotation()); } PhysicsBody* Node::getPhysicsBody() const { return _physicsBody; } #endif //CC_USE_PHYSICS GLubyte Node::getOpacity(void) const { return _realOpacity; } GLubyte Node::getDisplayedOpacity(void) const { return _displayedOpacity; } void Node::setOpacity(GLubyte opacity) { _displayedOpacity = _realOpacity = opacity; updateCascadeOpacity(); } void Node::updateDisplayedOpacity(GLubyte parentOpacity) { _displayedOpacity = _realOpacity * parentOpacity/255.0; updateColor(); if (_cascadeOpacityEnabled) { for(auto child : _children){ child->updateDisplayedOpacity(_displayedOpacity); } } } bool Node::isCascadeOpacityEnabled(void) const { return _cascadeOpacityEnabled; } void Node::setCascadeOpacityEnabled(bool cascadeOpacityEnabled) { if (_cascadeOpacityEnabled == cascadeOpacityEnabled) { return; } _cascadeOpacityEnabled = cascadeOpacityEnabled; if (cascadeOpacityEnabled) { updateCascadeOpacity(); } else { disableCascadeOpacity(); } } void Node::updateCascadeOpacity() { GLubyte parentOpacity = 255; if (_parent != nullptr && _parent->isCascadeOpacityEnabled()) { parentOpacity = _parent->getDisplayedOpacity(); } updateDisplayedOpacity(parentOpacity); } void Node::disableCascadeOpacity() { _displayedOpacity = _realOpacity; for(auto child : _children){ child->updateDisplayedOpacity(255); } } const Color3B& Node::getColor(void) const { return _realColor; } const Color3B& Node::getDisplayedColor() const { return _displayedColor; } void Node::setColor(const Color3B& color) { _displayedColor = _realColor = color; updateCascadeColor(); } void Node::updateDisplayedColor(const Color3B& parentColor) { _displayedColor.r = _realColor.r * parentColor.r/255.0; _displayedColor.g = _realColor.g * parentColor.g/255.0; _displayedColor.b = _realColor.b * parentColor.b/255.0; updateColor(); if (_cascadeColorEnabled) { for(const auto &child : _children){ child->updateDisplayedColor(_displayedColor); } } } bool Node::isCascadeColorEnabled(void) const { return _cascadeColorEnabled; } void Node::setCascadeColorEnabled(bool cascadeColorEnabled) { if (_cascadeColorEnabled == cascadeColorEnabled) { return; } _cascadeColorEnabled = cascadeColorEnabled; if (_cascadeColorEnabled) { updateCascadeColor(); } else { disableCascadeColor(); } } void Node::updateCascadeColor() { Color3B parentColor = Color3B::WHITE; if (_parent && _parent->isCascadeColorEnabled()) { parentColor = _parent->getDisplayedColor(); } updateDisplayedColor(parentColor); } void Node::disableCascadeColor() { for(auto child : _children){ child->updateDisplayedColor(Color3B::WHITE); } } __NodeRGBA::__NodeRGBA() { CCLOG("NodeRGBA deprecated."); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCNode.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __PLATFORM_CCNODE_H__ #define __PLATFORM_CCNODE_H__ #include "ccMacros.h" #include "CCAffineTransform.h" #include "CCArray.h" #include "CCGL.h" #include "ccGLStateCache.h" #include "CCGLProgram.h" #include "kazmath/kazmath.h" #include "CCScriptSupport.h" #include "CCProtocols.h" #include "CCEventDispatcher.h" #include "CCVector.h" #include "kazmath/kazmath.h" NS_CC_BEGIN class GridBase; class Point; class Touch; class Action; class LabelProtocol; class Scheduler; class ActionManager; class Component; class ComponentContainer; class EventDispatcher; class Scene; #if CC_USE_PHYSICS class PhysicsBody; #endif /** * @addtogroup base_nodes * @{ */ enum { kNodeOnEnter, kNodeOnExit, kNodeOnEnterTransitionDidFinish, kNodeOnExitTransitionDidStart, kNodeOnCleanup }; bool nodeComparisonLess(Node* n1, Node* n2); class EventListener; /** @brief Node is the base element of the Scene Graph. Element of the Scene Graph must be Node objects or subclasses of it. The most common Node objects are: Scene, Layer, Sprite, Menu. The main features of a Node are: - They can contain other Node objects (`addChild`, `getChildByTag`, `removeChild`, etc) - They can schedule periodic callback (`schedule`, `unschedule`, etc) - They can execute actions (`runAction`, `stopAction`, etc) Some Node objects provide extra functionality for them or their children. Subclassing a Node usually means (one/all) of: - overriding init to initialize resources and schedule callbacks - create callbacks to handle the advancement of time - overriding draw to render the node Properties of Node: - position - scale (x, y) - rotation (in degrees, clockwise) - GridBase (to do mesh transformations) - anchor point - size - visible - z-order - openGL z position Default values: - rotation: 0 - position: (x=0,y=0) - scale: (x=1,y=1) - contentSize: (x=0,y=0) - anchorPoint: (x=0,y=0) Limitations: - A Node is a "invisible" object. If you want to draw something on the screen, you should use a Sprite instead. Or subclass Node and override `draw`. Order in transformations with grid disabled -# The node will be translated (position) -# The node will be rotated (rotation) -# The node will be scaled (scale) Order in transformations with grid enabled -# The node will be translated (position) -# The node will be rotated (rotation) -# The node will be scaled (scale) -# The grid will capture the screen -# The grid will render the captured screen */ class CC_DLL Node : public Object { public: /// Default tag used for all the nodes static const int INVALID_TAG = -1; /// @{ /// @name Constructor, Destructor and Initializers /** * Allocates and initializes a node. * @return A initialized node which is marked as "autorelease". */ static Node * create(void); /** * Gets the description string. It makes debugging easier. * @return A string * @js NA * @lua NA */ virtual std::string getDescription() const; /// @} end of initializers /// @{ /// @name Setters & Getters for Graphic Peroperties /** LocalZOrder is the 'key' used to sort the node relative to its siblings. The Node's parent will sort all its children based ont the LocalZOrder value. If two nodes have the same LocalZOrder, then the node that was added first to the children's array will be in front of the other node in the array. Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) And Nodes that have LocalZOder values < 0 are the "left" subtree While Nodes with LocalZOder >=0 are the "right" subtree. @see `setGlobalZOrder` @see `setVertexZ` */ virtual void setLocalZOrder(int localZOrder); CC_DEPRECATED_ATTRIBUTE virtual void setZOrder(int localZOrder) { setLocalZOrder(localZOrder); } /* Helper function used by `setLocalZOrder`. Don't use it unless you know what you are doing. */ virtual void _setLocalZOrder(int z); /** * Gets the local Z order of this node. * * @see `setLocalZOrder(int)` * * @return The local (relative to its siblings) Z order. */ virtual int getLocalZOrder() const { return _localZOrder; } CC_DEPRECATED_ATTRIBUTE virtual int getZOrder() const { return getLocalZOrder(); } /** Defines the oder in which the nodes are renderer. Nodes that have a Global Z Order lower, are renderer first. In case two or more nodes have the same Global Z Order, the oder is not guaranteed. The only exception if the Nodes have a Global Z Order == 0. In that case, the Scene Graph order is used. By default, all nodes have a Global Z Order = 0. That means that by default, the Scene Graph order is used to render the nodes. Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order. Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their acenstors. And if ClippingNode is one of the ancestors, then "global Z order" will be relative to the ClippingNode. @see `setLocalZOrder()` @see `setVertexZ()` @since v3.0 */ virtual void setGlobalZOrder(float globalZOrder); /** * Returns the Node's Global Z Order. * * @see `setGlobalZOrder(int)` * * @return The node's global Z order */ virtual float getGlobalZOrder() const { return _globalZOrder; } /** * Sets the 'z' value in the OpenGL Depth Buffer. * * The OpenGL depth buffer and depth testing are disabled by default. You need to turn them on * in order to use this property correctly. * * `setVertexZ()` also sets the `setGlobalZValue()` with the vertexZ value. * * @see `setGlobalZValue()` * * @param vertexZ OpenGL Z vertex of this node. */ virtual void setVertexZ(float vertexZ); /** * Gets OpenGL Z vertex of this node. * * @see setVertexZ(float) * * @return OpenGL Z vertex of this node */ virtual float getVertexZ() const; /** * Changes the scale factor on X axis of this node * * The deafult value is 1.0 if you haven't changed it before * * @param scaleX The scale factor on X axis. */ virtual void setScaleX(float scaleX); /** * Returns the scale factor on X axis of this node * * @see setScaleX(float) * * @return The scale factor on X axis. */ virtual float getScaleX() const; /** * Changes the scale factor on Y axis of this node * * The Default value is 1.0 if you haven't changed it before. * * @param scaleY The scale factor on Y axis. */ virtual void setScaleY(float scaleY); /** * Returns the scale factor on Y axis of this node * * @see `setScaleY(float)` * * @return The scale factor on Y axis. */ virtual float getScaleY() const; /** * Changes both X and Y scale factor of the node. * * 1.0 is the default scale factor. It modifies the X and Y scale at the same time. * * @param scale The scale factor for both X and Y axis. */ virtual void setScale(float scale); /** * Gets the scale factor of the node, when X and Y have the same scale factor. * * @warning Assert when `_scaleX != _scaleY` * @see setScale(float) * * @return The scale factor of the node. */ virtual float getScale() const; /** * Changes both X and Y scale factor of the node. * * 1.0 is the default scale factor. It modifies the X and Y scale at the same time. * * @param scaleX The scale factor on X axis. * @param scaleY The scale factor on Y axis. */ virtual void setScale(float scaleX,float scaleY); /** * Changes the position (x,y) of the node in OpenGL coordinates * * Usually we use `Point(x,y)` to compose Point object. * The original point (0,0) is at the left-bottom corner of screen. * For example, this codesnip sets the node in the center of screen. @code Size size = Director::getInstance()->getWinSize(); node->setPosition( Point(size.width/2, size.height/2) ) @endcode * * @param position The position (x,y) of the node in OpenGL coordinates */ virtual void setPosition(const Point &position); /** * Gets the position (x,y) of the node in OpenGL coordinates * * @see setPosition(const Point&) * * @return The position (x,y) of the node in OpenGL coordinates * @code * In js and lua return value is table which contains x,y * @endcode */ virtual const Point& getPosition() const; /** * Sets position in a more efficient way. * * Passing two numbers (x,y) is much efficient than passing Point object. * This method is binded to lua and javascript. * Passing a number is 10 times faster than passing a object from lua to c++ * @code // sample code in lua local pos = node::getPosition() -- returns Point object from C++ node:setPosition(x, y) -- pass x, y coordinate to C++ @endcode * * @param x X coordinate for position * @param y Y coordinate for position */ virtual void setPosition(float x, float y); /** * Gets position in a more efficient way, returns two number instead of a Point object * * @see `setPosition(float, float)` * In js,out value not return */ virtual void getPosition(float* x, float* y) const; /** * Gets/Sets x or y coordinate individually for position. * These methods are used in Lua and Javascript Bindings */ virtual void setPositionX(float x); virtual float getPositionX(void) const; virtual void setPositionY(float y); virtual float getPositionY(void) const; /** * Changes the X skew angle of the node in degrees. * * This angle describes the shear distortion in the X direction. * Thus, it is the angle between the Y axis and the left edge of the shape * The default skewX angle is 0. Positive values distort the node in a CW direction. * * @param fSkewX The X skew angle of the node in degrees. */ virtual void setSkewX(float fSkewX); /** * Returns the X skew angle of the node in degrees. * * @see `setSkewX(float)` * * @return The X skew angle of the node in degrees. */ virtual float getSkewX() const; /** * Changes the Y skew angle of the node in degrees. * * This angle describes the shear distortion in the Y direction. * Thus, it is the angle between the X axis and the bottom edge of the shape * The default skewY angle is 0. Positive values distort the node in a CCW direction. * * @param fSkewY The Y skew angle of the node in degrees. */ virtual void setSkewY(float fSkewY); /** * Returns the Y skew angle of the node in degrees. * * @see `setSkewY(float)` * * @return The Y skew angle of the node in degrees. */ virtual float getSkewY() const; /** * Sets the anchor point in percent. * * anchorPoint is the point around which all transformations and positioning manipulations take place. * It's like a pin in the node where it is "attached" to its parent. * The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. * But you can use values higher than (1,1) and lower than (0,0) too. * The default anchorPoint is (0.5,0.5), so it starts in the center of the node. * * @param anchorPoint The anchor point of node. */ virtual void setAnchorPoint(const Point& anchorPoint); /** * Returns the anchor point in percent. * * @see `setAnchorPoint(const Point&)` * * @return The anchor point of node. */ virtual const Point& getAnchorPoint() const; /** * Returns the anchorPoint in absolute pixels. * * @warning You can only read it. If you wish to modify it, use anchorPoint instead. * @see `getAnchorPoint()` * * @return The anchor point in absolute pixels. */ virtual const Point& getAnchorPointInPoints() const; /** * Sets the untransformed size of the node. * * The contentSize remains the same no matter the node is scaled or rotated. * All nodes has a size. Layer and Scene has the same size of the screen. * * @param contentSize The untransformed size of the node. */ virtual void setContentSize(const Size& contentSize); /** * Returns the untransformed size of the node. * * @see `setContentSize(const Size&)` * * @return The untransformed size of the node. */ virtual const Size& getContentSize() const; /** * Sets whether the node is visible * * The default value is true, a node is default to visible * * @param visible true if the node is visible, false if the node is hidden. */ virtual void setVisible(bool visible); /** * Determines if the node is visible * * @see `setVisible(bool)` * * @return true if the node is visible, false if the node is hidden. */ virtual bool isVisible() const; /** * Sets the rotation (angle) of the node in degrees. * * 0 is the default rotation angle. * Positive values rotate node clockwise, and negative values for anti-clockwise. * * @param rotation The rotation of the node in degrees. */ virtual void setRotation(float rotation); /** * Returns the rotation of the node in degrees. * * @see `setRotation(float)` * * @return The rotation of the node in degrees. */ virtual float getRotation() const; /** * Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew. * * 0 is the default rotation angle. * Positive values rotate node clockwise, and negative values for anti-clockwise. * * @param rotationX The X rotation in degrees which performs a horizontal rotational skew. */ virtual void setRotationX(float rotationX); /** * Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew. * * @see `setRotationX(float)` * * @return The X rotation in degrees. */ virtual float getRotationX() const; /** * Sets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. * * 0 is the default rotation angle. * Positive values rotate node clockwise, and negative values for anti-clockwise. * * @param rotationY The Y rotation in degrees. */ virtual void setRotationY(float rotationY); /** * Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. * * @see `setRotationY(float)` * * @return The Y rotation in degrees. */ virtual float getRotationY() const; /** * Sets the arrival order when this node has a same ZOrder with other children. * * A node which called addChild subsequently will take a larger arrival order, * If two children have the same Z order, the child with larger arrival order will be drawn later. * * @warning This method is used internally for localZOrder sorting, don't change this manually * * @param orderOfArrival The arrival order. */ void setOrderOfArrival(int orderOfArrival); /** * Returns the arrival order, indecates which children is added previously. * * @see `setOrderOfArrival(unsigned int)` * * @return The arrival order. */ int getOrderOfArrival() const; /** @deprecated No longer needed * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE void setGLServerState(int serverState) { /* ignore */ }; /** @deprecated No longer needed * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE int getGLServerState() const { return 0; } /** * Sets whether the anchor point will be (0,0) when you position this node. * * This is an internal method, only used by Layer and Scene. Don't call it outside framework. * The default value is false, while in Layer and Scene are true * * @param ignore true if anchor point will be (0,0) when you position this node * @todo This method shoud be renamed as setIgnoreAnchorPointForPosition(bool) or something with "set" */ virtual void ignoreAnchorPointForPosition(bool ignore); /** * Gets whether the anchor point will be (0,0) when you position this node. * * @see `ignoreAnchorPointForPosition(bool)` * * @return true if the anchor point will be (0,0) when you position this node. */ virtual bool isIgnoreAnchorPointForPosition() const; /// @} end of Setters & Getters for Graphic Peroperties /// @{ /// @name Children and Parent /** * Adds a child to the container with z-order as 0. * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node */ virtual void addChild(Node * child); /** * Adds a child to the container with a local z-order * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node * @param zOrder Z order for drawing priority. Please refer to `setLocalZOrder(int)` */ virtual void addChild(Node * child, int localZOrder); /** * Adds a child to the container with z order and tag * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) * @param tag A interger to identify the node easily. Please refer to setTag(int) */ virtual void addChild(Node* child, int localZOrder, int tag); /** * Gets a child from the container with its tag * * @param tag An identifier to find the child node. * * @return a Node object whose tag equals to the input parameter */ virtual Node * getChildByTag(int tag); /** * Return an array of children * * Composing a "tree" structure is a very important feature of Node * Here's a sample code of traversing children array: @code Node* node = nullptr; CCARRAY_FOREACH(parent->getChildren(), node) { node->setPosition(0,0); } @endcode * This sample code traverses all children nodes, and set their position to (0,0) * * @return An array of children */ virtual Vector& getChildren() { return _children; } virtual const Vector& getChildren() const { return _children; } /** * Get the amount of children. * * @return The amount of children. */ virtual ssize_t getChildrenCount() const; /** * Sets the parent node * * @param parent A pointer to the parent node */ virtual void setParent(Node* parent); /** * Returns a pointer to the parent node * * @see `setParent(Node*)` * * @returns A pointer to the parent node */ virtual Node* getParent() { return _parent; } virtual const Node* getParent() const { return _parent; } ////// REMOVES ////// /** * Removes this node itself from its parent node with a cleanup. * If the node orphan, then nothing happens. * @see `removeFromParentAndCleanup(bool)` */ virtual void removeFromParent(); /** * Removes this node itself from its parent node. * If the node orphan, then nothing happens. * @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. * @js removeFromParent * @lua removeFromParent */ virtual void removeFromParentAndCleanup(bool cleanup); /** * Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. * * @param child The child node which will be removed. * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ virtual void removeChild(Node* child, bool cleanup = true); /** * Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter * * @param tag An interger number that identifies a child node * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ virtual void removeChildByTag(int tag, bool cleanup = true); /** * Removes all children from the container with a cleanup. * * @see `removeAllChildrenWithCleanup(bool)` */ virtual void removeAllChildren(); /** * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. * * @param cleanup true if all running actions on all children nodes should be cleanup, false oterwise. * @js removeAllChildren * @lua removeAllChildren */ virtual void removeAllChildrenWithCleanup(bool cleanup); /** * Reorders a child according to a new z value. * * @param child An already added child node. It MUST be already added. * @param localZOrder Z order for drawing priority. Please refer to setLocalZOrder(int) */ virtual void reorderChild(Node * child, int localZOrder); /** * Sorts the children array once before drawing, instead of every time when a child is added or reordered. * This appraoch can improves the performance massively. * @note Don't call this manually unless a child added needs to be removed in the same frame */ virtual void sortAllChildren(); /// @} end of Children and Parent /// @{ /// @name Tag & User data /** * Returns a tag that is used to identify the node easily. * * You can set tags to node then identify them easily. @code #define TAG_PLAYER 1 #define TAG_MONSTER 2 #define TAG_BOSS 3 // set tags node1->setTag(TAG_PLAYER); node2->setTag(TAG_MONSTER); node3->setTag(TAG_BOSS); parent->addChild(node1); parent->addChild(node2); parent->addChild(node3); // identify by tags Node* node = nullptr; CCARRAY_FOREACH(parent->getChildren(), node) { switch(node->getTag()) { case TAG_PLAYER: break; case TAG_MONSTER: break; case TAG_BOSS: break; } } @endcode * * @return A interger that identifies the node. */ virtual int getTag() const; /** * Changes the tag that is used to identify the node easily. * * Please refer to getTag for the sample code. * * @param tag A interger that indentifies the node. */ virtual void setTag(int tag); /** * Returns a custom user data pointer * * You can set everything in UserData pointer, a data block, a structure or an object. * * @return A custom user data pointer * @js NA * @lua NA */ virtual void* getUserData() { return _userData; } /** * @js NA * @lua NA */ virtual const void* getUserData() const { return _userData; } /** * Sets a custom user data pointer * * You can set everything in UserData pointer, a data block, a structure or an object, etc. * @warning Don't forget to release the memory manually, * especially before you change this data pointer, and before this node is autoreleased. * * @param userData A custom user data pointer * @js NA * @lua NA */ virtual void setUserData(void *userData); /** * Returns a user assigned Object * * Similar to userData, but instead of holding a void* it holds an object * * @return A user assigned Object * @js NA * @lua NA */ virtual Object* getUserObject() { return _userObject; } /** * @js NA * @lua NA */ virtual const Object* getUserObject() const { return _userObject; } /** * Returns a user assigned Object * * Similar to UserData, but instead of holding a void* it holds an object. * The UserObject will be retained once in this method, * and the previous UserObject (if existed) will be relese. * The UserObject will be released in Node's destructure. * * @param userObject A user assigned Object */ virtual void setUserObject(Object *userObject); /// @} end of Tag & User Data /// @{ /// @name Shader Program /** * Return the shader program currently used for this node * * @return The shader program currelty used for this node */ virtual GLProgram* getShaderProgram() { return _shaderProgram; } virtual const GLProgram* getShaderProgram() const { return _shaderProgram; } /** * Sets the shader program for this node * * Since v2.0, each rendering node must set its shader program. * It should be set in initialize phase. @code node->setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); @endcode * * @param shaderProgram The shader program which fetchs from ShaderCache. */ virtual void setShaderProgram(GLProgram *shaderProgram); /// @} end of Shader Program /** * Returns whether or not the node accepts event callbacks. * * Running means the node accept event callbacks like onEnter(), onExit(), update() * * @return Whether or not the node is running. */ virtual bool isRunning() const; /** * Schedules for lua script. * @js NA */ void scheduleUpdateWithPriorityLua(int handler, int priority); /// @} end Script Bindings /// @{ /// @name Event Callbacks /** * Event callback that is invoked every time when Node enters the 'stage'. * If the Node enters the 'stage' with a transition, this event is called when the transition starts. * During onEnter you can't access a "sister/brother" node. * If you override onEnter, you shall call its parent's one, e.g., Node::onEnter(). * @js NA * @lua NA */ virtual void onEnter(); /** Event callback that is invoked when the Node enters in the 'stage'. * If the Node enters the 'stage' with a transition, this event is called when the transition finishes. * If you override onEnterTransitionDidFinish, you shall call its parent's one, e.g. Node::onEnterTransitionDidFinish() * @js NA * @lua NA */ virtual void onEnterTransitionDidFinish(); /** * Event callback that is invoked every time the Node leaves the 'stage'. * If the Node leaves the 'stage' with a transition, this event is called when the transition finishes. * During onExit you can't access a sibling node. * If you override onExit, you shall call its parent's one, e.g., Node::onExit(). * @js NA * @lua NA */ virtual void onExit(); /** * Event callback that is called every time the Node leaves the 'stage'. * If the Node leaves the 'stage' with a transition, this callback is called when the transition starts. * @js NA * @lua NA */ virtual void onExitTransitionDidStart(); /// @} end of event callbacks. /** * Stops all running actions and schedulers */ virtual void cleanup(); /** * Override this method to draw your own node. * The following GL states will be enabled by default: * - `glEnableClientState(GL_VERTEX_ARRAY);` * - `glEnableClientState(GL_COLOR_ARRAY);` * - `glEnableClientState(GL_TEXTURE_COORD_ARRAY);` * - `glEnable(GL_TEXTURE_2D);` * AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE * But if you enable any other GL state, you should disable it after drawing your node. */ virtual void draw(); /** * Visits this node's children and draw them recursively. */ virtual void visit(); /** Returns the Scene that contains the Node. It returns `nullptr` if the node doesn't belong to any Scene. This function recursively calls parent->getScene() until parent is a Scene object. The results are not cached. It is that the user caches the results in case this functions is being used inside a loop. */ virtual Scene* getScene(); /** * Returns a "local" axis aligned bounding box of the node. * The returned box is relative only to its parent. * * @note This method returns a temporaty variable, so it can't returns const Rect& * @todo Rename to `getBoundingBox()` in the future versions. * * @return A "local" axis aligned boudning box of the node. */ virtual Rect getBoundingBox() const; /** @deprecated Use getBoundingBox instead */ CC_DEPRECATED_ATTRIBUTE inline virtual Rect boundingBox() const { return getBoundingBox(); } virtual void setEventDispatcher(EventDispatcher* dispatcher); virtual EventDispatcher* getEventDispatcher() const { return _eventDispatcher; }; /// @{ /// @name Actions /** * Sets the ActionManager object that is used by all actions. * * @warning If you set a new ActionManager, then previously created actions will be removed. * * @param actionManager A ActionManager object that is used by all actions. */ virtual void setActionManager(ActionManager* actionManager); /** * Gets the ActionManager object that is used by all actions. * @see setActionManager(ActionManager*) * @return A ActionManager object. */ virtual ActionManager* getActionManager() { return _actionManager; } virtual const ActionManager* getActionManager() const { return _actionManager; } /** * Executes an action, and returns the action that is executed. * * This node becomes the action's target. Refer to Action::getTarget() * @warning Actions don't retain their target. * * @return An Action pointer */ Action* runAction(Action* action); /** * Stops and removes all actions from the running action list . */ void stopAllActions(); /** * Stops and removes an action from the running action list. * * @param action The action object to be removed. */ void stopAction(Action* action); /** * Removes an action from the running action list by its tag. * * @param tag A tag that indicates the action to be removed. */ void stopActionByTag(int tag); /** * Gets an action from the running action list by its tag. * * @see `setTag(int)`, `getTag()`. * * @return The action object with the given tag. */ Action* getActionByTag(int tag); /** * Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays). * * Composable actions are counted as 1 action. Example: * If you are running 1 Sequence of 7 actions, it will return 1. * If you are running 7 Sequences of 2 actions, it will return 7. * @todo Rename to getNumberOfRunningActions() * * @return The number of actions that are running plus the ones that are schedule to run */ ssize_t getNumberOfRunningActions() const; /** @deprecated Use getNumberOfRunningActions() instead */ CC_DEPRECATED_ATTRIBUTE ssize_t numberOfRunningActions() const { return getNumberOfRunningActions(); }; /// @} end of Actions /// @{ /// @name Scheduler and Timer /** * Sets a Scheduler object that is used to schedule all "updates" and timers. * * @warning If you set a new Scheduler, then previously created timers/update are going to be removed. * @param scheduler A Shdeduler object that is used to schedule all "update" and timers. */ virtual void setScheduler(Scheduler* scheduler); /** * Gets a Sheduler object. * * @see setScheduler(Scheduler*) * @return A Scheduler object. */ virtual Scheduler* getScheduler() { return _scheduler; } virtual const Scheduler* getScheduler() const { return _scheduler; } /** * Checks whether a selector is scheduled. * * @param selector A function selector * @return Whether the funcion selector is scheduled. * @js NA * @lua NA */ bool isScheduled(SEL_SCHEDULE selector); /** * Schedules the "update" method. * * It will use the order number 0. This method will be called every frame. * Scheduled methods with a lower order value will be called before the ones that have a higher order value. * Only one "update" method could be scheduled per node. * @js NA * @lua NA */ void scheduleUpdate(void); /** * Schedules the "update" method with a custom priority. * * This selector will be called every frame. * Scheduled methods with a lower priority will be called before the ones that have a higher value. * Only one "update" selector could be scheduled per node (You can't have 2 'update' selectors). * @js NA * @lua NA */ void scheduleUpdateWithPriority(int priority); /* * Unschedules the "update" method. * @see scheduleUpdate(); */ void unscheduleUpdate(void); /** * Schedules a custom selector. * * If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. @code // firstly, implement a schedule function void MyNode::TickMe(float dt); // wrap this function into a selector via schedule_selector marco. this->schedule(schedule_selector(MyNode::TickMe), 0, 0, 0); @endcode * * @param selector The SEL_SCHEDULE selector to be scheduled. * @param interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead. * @param repeat The selector will be excuted (repeat + 1) times, you can use kRepeatForever for tick infinitely. * @param delay The amount of time that the first tick will wait before execution. * @lua NA */ void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay); /** * Schedules a custom selector with an interval time in seconds. * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` * * @param selector The SEL_SCHEDULE selector to be scheduled. * @param interval Callback interval time in seconds. 0 means tick every frame, * @lua NA */ void schedule(SEL_SCHEDULE selector, float interval); /** * Schedules a selector that runs only once, with a delay of 0 or larger * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` * * @param selector The SEL_SCHEDULE selector to be scheduled. * @param delay The amount of time that the first tick will wait before execution. * @lua NA */ void scheduleOnce(SEL_SCHEDULE selector, float delay); /** * Schedules a custom selector, the scheduled selector will be ticked every frame * @see schedule(SEL_SCHEDULE, float, unsigned int, float) * * @param selector A function wrapped as a selector * @lua NA */ void schedule(SEL_SCHEDULE selector); /** * Unschedules a custom selector. * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` * * @param selector A function wrapped as a selector * @lua NA */ void unschedule(SEL_SCHEDULE selector); /** * Unschedule all scheduled selectors: custom selectors, and the 'update' selector. * Actions are not affected by this method. * @lua NA */ void unscheduleAllSelectors(void); /** * Resumes all scheduled selectors, actions and event listeners. * This method is called internally by onEnter */ void resume(void); /** * Pauses all scheduled selectors, actions and event listeners.. * This method is called internally by onExit */ void pause(void); /** * Resumes all scheduled selectors, actions and event listeners. * This method is called internally by onEnter */ CC_DEPRECATED_ATTRIBUTE void resumeSchedulerAndActions(void); /** * Pauses all scheduled selectors, actions and event listeners.. * This method is called internally by onExit */ CC_DEPRECATED_ATTRIBUTE void pauseSchedulerAndActions(void); /* * Update method will be called automatically every frame if "scheduleUpdate" is called, and the node is "live" */ virtual void update(float delta); /// @} end of Scheduler and Timer /// @{ /// @name Transformations /** * Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes. */ void transform(); /** * Performs OpenGL view-matrix transformation of it's ancestors. * Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO) * It's necessary to transform the ancestors again. */ void transformAncestors(); /** * Calls children's updateTransform() method recursively. * * This method is moved from Sprite, so it's no longer specific to Sprite. * As the result, you apply SpriteBatchNode's optimization on your customed Node. * e.g., `batchNode->addChild(myCustomNode)`, while you can only addChild(sprite) before. */ virtual void updateTransform(); /** * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates. * The matrix is in Pixels. */ virtual const kmMat4& getNodeToParentTransform() const; virtual AffineTransform getNodeToParentAffineTransform() const; /** * Sets the Transformation matrix manually. */ virtual void setNodeToParentTransform(const kmMat4& transform); /** @deprecated use getNodeToParentTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentAffineTransform(); } /** * Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates. * The matrix is in Pixels. */ virtual const kmMat4& getParentToNodeTransform() const; virtual AffineTransform getParentToNodeAffineTransform() const; /** @deprecated Use getParentToNodeTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform parentToNodeTransform() const { return getParentToNodeAffineTransform(); } /** * Returns the world affine transform matrix. The matrix is in Pixels. */ virtual kmMat4 getNodeToWorldTransform() const; virtual AffineTransform getNodeToWorldAffineTransform() const; /** @deprecated Use getNodeToWorldTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToWorldTransform() const { return getNodeToWorldAffineTransform(); } /** * Returns the inverse world affine transform matrix. The matrix is in Pixels. */ virtual kmMat4 getWorldToNodeTransform() const; virtual AffineTransform getWorldToNodeAffineTransform() const; /** @deprecated Use worldToNodeTransform() instead */ CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform worldToNodeTransform() const { return getWorldToNodeAffineTransform(); } /// @} end of Transformations /// @{ /// @name Coordinate Converters /** * Converts a Point to node (local) space coordinates. The result is in Points. */ Point convertToNodeSpace(const Point& worldPoint) const; /** * Converts a Point to world space coordinates. The result is in Points. */ Point convertToWorldSpace(const Point& nodePoint) const; /** * Converts a Point to node (local) space coordinates. The result is in Points. * treating the returned/received node point as anchor relative. */ Point convertToNodeSpaceAR(const Point& worldPoint) const; /** * Converts a local Point to world space coordinates.The result is in Points. * treating the returned/received node point as anchor relative. */ Point convertToWorldSpaceAR(const Point& nodePoint) const; /** * convenience methods which take a Touch instead of Point */ Point convertTouchToNodeSpace(Touch * touch) const; /** * converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). */ Point convertTouchToNodeSpaceAR(Touch * touch) const; /** * Sets an additional transform matrix to the node. * * In order to remove it, set the Identity Matrix to the additional transform. * * @note The additional transform will be concatenated at the end of getNodeToParentTransform. * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). @code // create a batchNode SpriteBatchNode* batch= SpriteBatchNode::create("Icon-114.png"); this->addChild(batch); // create two sprites, spriteA will be added to batchNode, they are using different textures. Sprite* spriteA = Sprite::createWithTexture(batch->getTexture()); Sprite* spriteB = Sprite::create("Icon-72.png"); batch->addChild(spriteA); // We can't make spriteB as spriteA's child since they use different textures. So just add it to layer. // But we want to simulate `parent-child` relationship for these two node. this->addChild(spriteB); //position spriteA->setPosition(Point(200, 200)); // Gets the spriteA's transform. auto t = spriteA->getNodeToParentTransform(); // Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA. spriteB->setAdditionalTransform(t); //scale spriteA->setScale(2); // Gets the spriteA's transform. t = spriteA->getNodeToParentTransform(); // Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA. spriteB->setAdditionalTransform(t); //rotation spriteA->setRotation(20); // Gets the spriteA's transform. t = spriteA->getNodeToParentTransform(); // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA. spriteB->setAdditionalTransform(t); @endcode */ void setAdditionalTransform(const AffineTransform& additionalTransform); void setAdditionalTransform(const kmMat4& additionalTransform); /// @} end of Coordinate Converters /// @{ /// @name component functions /** * gets a component by its name */ Component* getComponent(const std::string& pName); /** * adds a component */ virtual bool addComponent(Component *pComponent); /** * removes a component by its name */ virtual bool removeComponent(const std::string& pName); /** * removes all components */ virtual void removeAllComponents(); /// @} end of component functions #if CC_USE_PHYSICS /** * set the PhysicsBody that let the sprite effect with physics */ void setPhysicsBody(PhysicsBody* body); /** * get the PhysicsBody the sprite have */ PhysicsBody* getPhysicsBody() const; /** * update rotation and position from physics body */ virtual bool updatePhysicsTransform(); #endif // overrides virtual GLubyte getOpacity() const; virtual GLubyte getDisplayedOpacity() const; virtual void setOpacity(GLubyte opacity); virtual void updateDisplayedOpacity(GLubyte parentOpacity); virtual bool isCascadeOpacityEnabled() const; virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); virtual const Color3B& getColor(void) const; virtual const Color3B& getDisplayedColor() const; virtual void setColor(const Color3B& color); virtual void updateDisplayedColor(const Color3B& parentColor); virtual bool isCascadeColorEnabled() const; virtual void setCascadeColorEnabled(bool cascadeColorEnabled); virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool isOpacityModifyRGB() const { return false; }; protected: // Nodes should be created using create(); Node(); virtual ~Node(); virtual bool init(); /// lazy allocs void childrenAlloc(void); /// helper that reorder a child void insertChild(Node* child, int z); /// Removes a child, call child->onExit(), do cleanup, remove it from children array. void detachChild(Node *child, ssize_t index, bool doCleanup); /// Convert cocos2d coordinates to UI windows coordinate. Point convertToWindowSpace(const Point& nodePoint) const; virtual void updateCascadeOpacity(); virtual void disableCascadeOpacity(); virtual void updateCascadeColor(); virtual void disableCascadeColor(); virtual void updateColor() {} float _rotationX; ///< rotation angle on x-axis float _rotationY; ///< rotation angle on y-axis float _scaleX; ///< scaling factor on x-axis float _scaleY; ///< scaling factor on y-axis Point _position; ///< position of the node float _skewX; ///< skew angle on x-axis float _skewY; ///< skew angle on y-axis Point _anchorPointInPoints; ///< anchor point in points Point _anchorPoint; ///< anchor point normalized (NOT in points) Size _contentSize; ///< untransformed size of the node kmMat4 _modelViewTransform; ///< ModelView transform of the Node. // "cache" variables are allowed to be mutable mutable kmMat4 _additionalTransform; ///< transform mutable kmMat4 _transform; ///< transform mutable kmMat4 _inverse; ///< inverse transform bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty mutable bool _transformDirty; ///< transform dirty flag mutable bool _inverseDirty; ///< inverse transform dirty flag int _localZOrder; ///< Local order (relative to its siblings) used to sort the node float _globalZOrder; ///< Global order used to sort the node float _vertexZ; ///< OpenGL real Z vertex Vector _children; ///< array of children nodes Node *_parent; ///< weak reference to parent node int _tag; ///< a tag. Can be any number you assigned just to identify this node void *_userData; ///< A user assingned void pointer, Can be point to any cpp object Object *_userObject; ///< A user assigned Object GLProgram *_shaderProgram; ///< OpenGL shader int _orderOfArrival; ///< used to preserve sequence while sorting children with the same localZOrder Scheduler *_scheduler; ///< scheduler used to schedule timers and updates ActionManager *_actionManager; ///< a pointer to ActionManager singleton, which is used to handle all the actions EventDispatcher* _eventDispatcher; ///< event dispatcher used to dispatch all kinds of events bool _running; ///< is running bool _visible; ///< is this node visible bool _ignoreAnchorPointForPosition; ///< true if the Anchor Point will be (0,0) when you position the Node, false otherwise. ///< Used by Layer and Scene. bool _reorderChildDirty; ///< children order dirty flag bool _isTransitionFinished; ///< flag to indicate whether the transition was finished int _scriptHandler; ///< script handler for onEnter() & onExit(), used in Javascript binding and Lua binding. int _updateScriptHandler; ///< script handler for update() callback per frame, which is invoked from lua & javascript. ccScriptType _scriptType; ///< type of script binding, lua or javascript ComponentContainer *_componentContainer; ///< Dictionary of components #if CC_USE_PHYSICS PhysicsBody* _physicsBody; ///< the physicsBody the node have #endif // opacity controls GLubyte _displayedOpacity; GLubyte _realOpacity; Color3B _displayedColor; Color3B _realColor; bool _cascadeColorEnabled; bool _cascadeOpacityEnabled; private: CC_DISALLOW_COPY_AND_ASSIGN(Node); }; //#pragma mark - NodeRGBA /** NodeRGBA is a subclass of Node that implements the RGBAProtocol protocol. All features from Node are valid, plus the following new features: - opacity - RGB colors Opacity/Color propagates into children that conform to the RGBAProtocol if cascadeOpacity/cascadeColor is enabled. @since v2.1 */ class CC_DLL __NodeRGBA : public Node, public __RGBAProtocol { public: // overrides virtual GLubyte getOpacity() const override { return Node::getOpacity(); } virtual GLubyte getDisplayedOpacity() const override { return Node::getDisplayedOpacity(); } virtual void setOpacity(GLubyte opacity) override { return Node::setOpacity(opacity); } virtual void updateDisplayedOpacity(GLubyte parentOpacity) override { return Node::updateDisplayedOpacity(parentOpacity); } virtual bool isCascadeOpacityEnabled() const override { return Node::isCascadeOpacityEnabled(); } virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override { return Node::setCascadeOpacityEnabled(cascadeOpacityEnabled); } virtual const Color3B& getColor(void) const override { return Node::getColor(); } virtual const Color3B& getDisplayedColor() const override { return Node::getDisplayedColor(); } virtual void setColor(const Color3B& color) override { return Node::setColor(color); } virtual void updateDisplayedColor(const Color3B& parentColor) override { return Node::updateDisplayedColor(parentColor); } virtual bool isCascadeColorEnabled() const override { return Node::isCascadeColorEnabled(); } virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override { return Node::setCascadeColorEnabled(cascadeColorEnabled); } virtual void setOpacityModifyRGB(bool bValue) override { return Node::setOpacityModifyRGB(bValue); } virtual bool isOpacityModifyRGB() const override { return Node::isOpacityModifyRGB(); } protected: __NodeRGBA(); virtual ~__NodeRGBA() {} private: CC_DISALLOW_COPY_AND_ASSIGN(__NodeRGBA); }; // end of base_node group /// @} NS_CC_END #endif // __PLATFORM_CCNODE_H__ ================================================ FILE: cocos2d/cocos/2d/CCNodeGrid.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCNodeGrid.h" #include "CCGrid.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCRenderer.h" #include "renderer/CCCustomCommand.h" NS_CC_BEGIN NodeGrid* NodeGrid::create() { NodeGrid * ret = new NodeGrid(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } NodeGrid::NodeGrid() : _gridTarget(nullptr) , _nodeGrid(nullptr) { } void NodeGrid::setTarget(Node* target) { CC_SAFE_RELEASE(_gridTarget); CC_SAFE_RETAIN(target); _gridTarget = target; } NodeGrid::~NodeGrid() { CC_SAFE_RELEASE(_nodeGrid); CC_SAFE_RELEASE(_gridTarget); } void NodeGrid::onGridBeginDraw() { if (_nodeGrid && _nodeGrid->isActive()) { _nodeGrid->beforeDraw(); } } void NodeGrid::onGridEndDraw() { if(_nodeGrid && _nodeGrid->isActive()) { _nodeGrid->afterDraw(this); } } void NodeGrid::visit() { // quick return if not visible. children won't be drawn. if (!_visible) { return; } Renderer* renderer = Director::getInstance()->getRenderer(); _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); kmGLPushMatrix(); Director::Projection beforeProjectionType; if(_nodeGrid && _nodeGrid->isActive()) { beforeProjectionType = Director::getInstance()->getProjection(); _nodeGrid->set2DProjection(); } _gridBeginCommand.init(_globalZOrder); _gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this); renderer->addCommand(&_gridBeginCommand); this->transform(); if(_gridTarget) { _gridTarget->visit(); } int i = 0; if(!_children.empty()) { sortAllChildren(); // draw children zOrder < 0 for( ; i < _children.size(); i++ ) { auto node = _children.at(i); if ( node && node->getLocalZOrder() < 0 ) node->visit(); else break; } // self draw,currently we have nothing to draw on NodeGrid, so there is no need to add render command this->draw(); for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) { (*it)->visit(); } } else { this->draw(); } // reset for next frame _orderOfArrival = 0; if(_nodeGrid && _nodeGrid->isActive()) { // restore projection Director *director = Director::getInstance(); director->setProjection(beforeProjectionType); } _gridEndCommand.init(_globalZOrder); _gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this); renderer->addCommand(&_gridEndCommand); renderer->popGroup(); kmGLPopMatrix(); } void NodeGrid::setGrid(GridBase *grid) { CC_SAFE_RELEASE(_nodeGrid); CC_SAFE_RETAIN(grid); _nodeGrid = grid; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCNodeGrid.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __MISCNODE_CCGRID_NODE_H__ #define __MISCNODE_CCGRID_NODE_H__ #include "CCNode.h" #include "kazmath/GL/matrix.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCCustomCommand.h" NS_CC_BEGIN class GridBase; class NodeGrid : public Node { public: static NodeGrid* create(); GridBase* getGrid() { return _nodeGrid; } /** * @js NA */ const GridBase* getGrid() const { return _nodeGrid; } /** * Changes a grid object that is used when applying effects * * @param grid A Grid object that is used when applying effects */ void setGrid(GridBase *grid); void setTarget(Node *target); // overrides virtual void visit() override; protected: NodeGrid(); virtual ~NodeGrid(); void onGridBeginDraw(); void onGridEndDraw(); Node* _gridTarget; GridBase* _nodeGrid; GroupCommand _groupCommand; CustomCommand _gridBeginCommand; CustomCommand _gridEndCommand; private: CC_DISALLOW_COPY_AND_ASSIGN(NodeGrid); }; NS_CC_END #endif ================================================ FILE: cocos2d/cocos/2d/CCNotificationCenter.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Erawppa Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCNotificationCenter.h" #include "CCArray.h" #include "CCScriptSupport.h" #include using namespace std; NS_CC_BEGIN static __NotificationCenter *s_sharedNotifCenter = nullptr; __NotificationCenter::__NotificationCenter() : _scriptHandler(0) { _observers = __Array::createWithCapacity(3); _observers->retain(); } __NotificationCenter::~__NotificationCenter() { _observers->release(); } __NotificationCenter *__NotificationCenter::getInstance() { if (!s_sharedNotifCenter) { s_sharedNotifCenter = new __NotificationCenter; } return s_sharedNotifCenter; } void __NotificationCenter::destroyInstance() { CC_SAFE_RELEASE_NULL(s_sharedNotifCenter); } // XXX: deprecated __NotificationCenter *__NotificationCenter::sharedNotificationCenter(void) { return __NotificationCenter::getInstance(); } // XXX: deprecated void __NotificationCenter::purgeNotificationCenter(void) { __NotificationCenter::destroyInstance(); } // // internal functions // bool __NotificationCenter::observerExisted(Object *target, const std::string& name, Object *sender) { Object* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = (NotificationObserver*) obj; if (!observer) continue; if (observer->getName() == name && observer->getTarget() == target && observer->getSender() == sender) return true; } return false; } // // observer functions // void __NotificationCenter::addObserver(Object *target, SEL_CallFuncO selector, const std::string& name, Object *sender) { if (this->observerExisted(target, name, sender)) return; NotificationObserver *observer = new NotificationObserver(target, selector, name, sender); if (!observer) return; observer->autorelease(); _observers->addObject(observer); } void __NotificationCenter::removeObserver(Object *target, const std::string& name) { Object* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = static_cast(obj); if (!observer) continue; if (observer->getName() == name && observer->getTarget() == target) { _observers->removeObject(observer); return; } } } int __NotificationCenter::removeAllObservers(Object *target) { Object *obj = nullptr; __Array *toRemove = __Array::create(); CCARRAY_FOREACH(_observers, obj) { NotificationObserver *observer = static_cast(obj); if (!observer) continue; if (observer->getTarget() == target) { toRemove->addObject(observer); } } _observers->removeObjectsInArray(toRemove); return static_cast(toRemove->count()); } void __NotificationCenter::registerScriptObserver( Object *target, int handler,const std::string& name) { if (this->observerExisted(target, name, nullptr)) return; NotificationObserver *observer = new NotificationObserver(target, nullptr, name, nullptr); if (!observer) return; observer->setHandler(handler); observer->autorelease(); _observers->addObject(observer); } void __NotificationCenter::unregisterScriptObserver(Object *target,const std::string& name) { Object* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = static_cast(obj); if (!observer) continue; if ( observer->getName() == name && observer->getTarget() == target) { _observers->removeObject(observer); } } } void __NotificationCenter::postNotification(const std::string& name, Object *sender) { __Array* ObserversCopy = __Array::createWithCapacity(_observers->count()); ObserversCopy->addObjectsFromArray(_observers); Object* obj = nullptr; CCARRAY_FOREACH(ObserversCopy, obj) { NotificationObserver* observer = static_cast(obj); if (!observer) continue; if (observer->getName() == name && (observer->getSender() == sender || observer->getSender() == nullptr || sender == nullptr)) { if (0 == observer->getHandler()) { observer->performSelector(sender); } } } } void __NotificationCenter::postNotification(const std::string& name) { this->postNotification(name,nullptr); } int __NotificationCenter::getObserverHandlerByName(const std::string& name) { if (name.empty()) { return 0; } Object* obj = nullptr; CCARRAY_FOREACH(_observers, obj) { NotificationObserver* observer = static_cast(obj); if (nullptr == observer) continue; if ( observer->getName() == name ) { return observer->getHandler(); break; } } return 0; } //////////////////////////////////////////////////////////////////////////////// /// /// NotificationObserver /// //////////////////////////////////////////////////////////////////////////////// NotificationObserver::NotificationObserver(Object *target, SEL_CallFuncO selector, const std::string& name, Object *sender) { _target = target; _selector = selector; _sender = sender; _name = name; _handler = 0; } NotificationObserver::~NotificationObserver() { } void NotificationObserver::performSelector(Object *sender) { if (_target) { if (sender) { (_target->*_selector)(sender); } else { (_target->*_selector)(_sender); } } } Object *NotificationObserver::getTarget() const { return _target; } SEL_CallFuncO NotificationObserver::getSelector() const { return _selector; } const std::string& NotificationObserver::getName() const { return _name; } Object* NotificationObserver::getSender() const { return _sender; } int NotificationObserver::getHandler() const { return _handler; } void NotificationObserver::setHandler(int var) { _handler = var; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCNotificationCenter.h ================================================ /**************************************************************************** Copyright (c) 2011 Erawppa Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCNOTIFICATIONCENTER_H__ #define __CCNOTIFICATIONCENTER_H__ #include "CCObject.h" #include "CCArray.h" NS_CC_BEGIN class ScriptHandlerMgr; class CC_DLL __NotificationCenter : public Object { friend class ScriptHandlerMgr; public: /** __NotificationCenter constructor * @js ctor */ __NotificationCenter(); /** __NotificationCenter destructor * @js NA * @lua NA */ ~__NotificationCenter(); /** Gets the single instance of __NotificationCenter. */ static __NotificationCenter *getInstance(); /** Destroys the single instance of __NotificationCenter. */ static void destroyInstance(); /** @deprecated use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static __NotificationCenter *sharedNotificationCenter(void); /** @deprecated use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeNotificationCenter(void); /** @brief Adds an observer for the specified target. * @param target The target which wants to observe notification events. * @param selector The callback function which will be invoked when the specified notification event was posted. * @param name The name of this notification. * @param sender The object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. nullptr means that the sender is not used to decide whether to deliver the notification to target. */ void addObserver(Object *target, SEL_CallFuncO selector, const std::string& name, Object *sender); /** @brief Removes the observer by the specified target and name. * @param target The target of this notification. * @param name The name of this notification. */ void removeObserver(Object *target,const std::string& name); /** @brief Removes all notifications registered by this target * @param target The target of this notification. * @returns the number of observers removed */ int removeAllObservers(Object *target); /** @brief Registers one hander for script binding. * @note Only supports Lua Binding now. * @param handler The lua handler. */ void registerScriptObserver(Object *target,int handler,const std::string& name); /** Unregisters script observer */ void unregisterScriptObserver(Object *target,const std::string& name); /** @brief Posts one notification event by name. * @param name The name of this notification. */ void postNotification(const std::string& name); /** @brief Posts one notification event by name. * @param name The name of this notification. * @param sender The object posting the notification. Can be nullptr */ void postNotification(const std::string& name, Object *sender); /** @brief Gets script handler. * @note Only supports Lua Binding now. * @return The script handle. */ inline int getScriptHandler() const { return _scriptHandler; }; /** @brief Gets observer script handler. * @param name The name of this notification. * @return The observer script handle. */ int getObserverHandlerByName(const std::string& name); private: // internal functions // Check whether the observer exists by the specified target and name. bool observerExisted(Object *target,const std::string& name, Object *sender); // variables // __Array *_observers; int _scriptHandler; }; class CC_DLL NotificationObserver : public Object { public: /** @brief NotificationObserver constructor * @param target The target which wants to observer notification events. * @param selector The callback function which will be invoked when the specified notification event was posted. * @param name The name of this notification. * @param sender The object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. nullptr means that the sender is not used to decide whether to deliver the notification to target. * @js NA * @lua NA */ NotificationObserver(Object *target, SEL_CallFuncO selector, const std::string& name, Object *sender); /** NotificationObserver destructor function * @js NA * @lua NA */ ~NotificationObserver(); /** Invokes the callback function of this observer * @js NA * @lua NA */ void performSelector(Object *sender); // Getters / Setters /** * @js NA * @lua NA */ Object* getTarget() const; /** * @js NA * @lua NA */ SEL_CallFuncO getSelector() const; /** * @js NA * @lua NA */ const std::string& getName() const; /** * @js NA * @lua NA */ Object* getSender() const; /** * @js NA * @lua NA */ int getHandler() const; /** * @js NA * @lua NA */ void setHandler(int handler); private: Object* _target; SEL_CallFuncO _selector; std::string _name; Object* _sender; int _handler; }; NS_CC_END #endif//__CCNOTIFICATIONCENTER_H__ ================================================ FILE: cocos2d/cocos/2d/CCParallaxNode.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCParallaxNode.h" #include "ccCArray.h" NS_CC_BEGIN class PointObject : Object { public: static PointObject * create(Point ratio, Point offset) { PointObject *ret = new PointObject(); ret->initWithPoint(ratio, offset); ret->autorelease(); return ret; } bool initWithPoint(Point ratio, Point offset) { _ratio = ratio; _offset = offset; _child = nullptr; return true; } inline const Point& getRatio() const { return _ratio; }; inline void setRatio(const Point& ratio) { _ratio = ratio; }; inline const Point& getOffset() const { return _offset; }; inline void setOffset(const Point& offset) { _offset = offset; }; inline Node* getChild() const { return _child; }; inline void setChild(Node* child) { _child = child; }; private: Point _ratio; Point _offset; Node *_child; // weak ref }; ParallaxNode::ParallaxNode() { _parallaxArray = ccArrayNew(5); _lastPosition = Point(-100,-100); } ParallaxNode::~ParallaxNode() { if( _parallaxArray ) { ccArrayFree(_parallaxArray); _parallaxArray = nullptr; } } ParallaxNode * ParallaxNode::create() { ParallaxNode *ret = new ParallaxNode(); ret->autorelease(); return ret; } void ParallaxNode::addChild(Node * child, int zOrder, int tag) { CC_UNUSED_PARAM(zOrder); CC_UNUSED_PARAM(child); CC_UNUSED_PARAM(tag); CCASSERT(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead"); } void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& offset) { CCASSERT( child != nullptr, "Argument must be non-nil"); PointObject *obj = PointObject::create(ratio, offset); obj->setChild(child); ccArrayAppendObjectWithResize(_parallaxArray, (Object*)obj); Point pos = this->absolutePosition(); pos.x = -pos.x + pos.x * ratio.x + offset.x; pos.y = -pos.y + pos.y * ratio.y + offset.y; child->setPosition(pos); Node::addChild(child, z, child->getTag()); } void ParallaxNode::removeChild(Node* child, bool cleanup) { for( int i=0;i < _parallaxArray->num;i++) { PointObject *point = (PointObject*)_parallaxArray->arr[i]; if( point->getChild()->isEqual(child)) { ccArrayRemoveObjectAtIndex(_parallaxArray, i, true); break; } } Node::removeChild(child, cleanup); } void ParallaxNode::removeAllChildrenWithCleanup(bool cleanup) { ccArrayRemoveAllObjects(_parallaxArray); Node::removeAllChildrenWithCleanup(cleanup); } Point ParallaxNode::absolutePosition() { Point ret = _position; Node *cn = this; while (cn->getParent() != nullptr) { cn = cn->getParent(); ret = ret + cn->getPosition(); } return ret; } /* The positions are updated at visit because: - using a timer is not guaranteed that it will called after all the positions were updated - overriding "draw" will only precise if the children have a z > 0 */ void ParallaxNode::visit() { // Point pos = position_; // Point pos = [self convertToWorldSpace:Point::ZERO]; Point pos = this->absolutePosition(); if( ! pos.equals(_lastPosition) ) { for( int i=0; i < _parallaxArray->num; i++ ) { PointObject *point = (PointObject*)_parallaxArray->arr[i]; float x = -pos.x + pos.x * point->getRatio().x + point->getOffset().x; float y = -pos.y + pos.y * point->getRatio().y + point->getOffset().y; point->getChild()->setPosition(Point(x,y)); } _lastPosition = pos; } Node::visit(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCParallaxNode.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPARALLAX_NODE_H__ #define __CCPARALLAX_NODE_H__ #include "CCNode.h" /*#include "ccArray.h"*/ NS_CC_BEGIN struct _ccArray; /** * @addtogroup tilemap_parallax_nodes * @{ */ /** @brief ParallaxNode: A node that simulates a parallax scroller The children will be moved faster / slower than the parent according the the parallax ratio. */ class CC_DLL ParallaxNode : public Node { public: // Create a Parallax node static ParallaxNode * create(); // prevents compiler warning: "Included function hides overloaded virtual functions" using Node::addChild; void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset); /** Sets an array of layers for the Parallax node */ void setParallaxArray( struct _ccArray *parallaxArray) { _parallaxArray = parallaxArray; } /** Returns the array of layers of the Parallax node */ struct _ccArray* getParallaxArray() { return _parallaxArray; } const struct _ccArray* getParallaxArray() const { return _parallaxArray; } // // Overrides // virtual void addChild(Node * child, int zOrder, int tag) override; virtual void removeChild(Node* child, bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void visit(void) override; protected: /** Adds a child to the container with a z-order, a parallax ratio and a position offset It returns self, so you can chain several addChilds. @since v0.8 * @js ctor */ ParallaxNode(); /** * @js NA * @lua NA */ virtual ~ParallaxNode(); Point absolutePosition(); Point _lastPosition; struct _ccArray* _parallaxArray; private: CC_DISALLOW_COPY_AND_ASSIGN(ParallaxNode); }; // end of tilemap_parallax_nodes group /// @} NS_CC_END #endif //__CCPARALLAX_NODE_H__ ================================================ FILE: cocos2d/cocos/2d/CCParticleBatchNode.cpp ================================================ /* * Copyright (C) 2009 Matt Oswald * Copyright (c) 2009-2010 Ricardo Quesada * Copyright (c) 2010-2012 cocos2d-x.org * Copyright (c) 2011 Zynga Inc. * Copyright (c) 2011 Marco Tillemans * Copyright (c) 2013-2014 Chukong Technologies Inc. * * http://www.cocos2d-x.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #include "CCParticleBatchNode.h" #include "CCTextureCache.h" #include "CCTextureAtlas.h" #include "ccConfig.h" #include "ccMacros.h" #include "CCGrid.h" #include "CCParticleSystem.h" #include "CCShaderCache.h" #include "CCGLProgram.h" #include "ccGLStateCache.h" #include "base64.h" #include "ZipUtils.h" #include "platform/CCFileUtils.h" #include "kazmath/GL/matrix.h" #include "CCProfiling.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCRenderer.h" NS_CC_BEGIN ParticleBatchNode::ParticleBatchNode() : _textureAtlas(nullptr) { } ParticleBatchNode::~ParticleBatchNode() { CC_SAFE_RELEASE(_textureAtlas); } /* * creation with Texture2D */ ParticleBatchNode* ParticleBatchNode::createWithTexture(Texture2D *tex, int capacity/* = kParticleDefaultCapacity*/) { ParticleBatchNode * p = new ParticleBatchNode(); if( p && p->initWithTexture(tex, capacity)) { p->autorelease(); return p; } CC_SAFE_DELETE(p); return nullptr; } /* * creation with File Image */ ParticleBatchNode* ParticleBatchNode::create(const std::string& imageFile, int capacity/* = kParticleDefaultCapacity*/) { ParticleBatchNode * p = new ParticleBatchNode(); if( p && p->initWithFile(imageFile, capacity)) { p->autorelease(); return p; } CC_SAFE_DELETE(p); return nullptr; } /* * init with Texture2D */ bool ParticleBatchNode::initWithTexture(Texture2D *tex, int capacity) { _textureAtlas = new TextureAtlas(); _textureAtlas->initWithTexture(tex, capacity); _children.reserve(capacity); _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } /* * init with FileImage */ bool ParticleBatchNode::initWithFile(const std::string& fileImage, int capacity) { Texture2D *tex = Director::getInstance()->getTextureCache()->addImage(fileImage); return initWithTexture(tex, capacity); } // ParticleBatchNode - composition // override visit. // Don't call visit on it's children void ParticleBatchNode::visit() { // CAREFUL: // This visit is almost identical to Node#visit // with the exception that it doesn't call visit on it's children // // The alternative is to have a void Sprite#visit, but // although this is less maintainable, is faster // if (!_visible) { return; } kmGLPushMatrix(); transform(); draw(); kmGLPopMatrix(); } // override addChild: void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag) { CCASSERT( aChild != nullptr, "Argument must be non-nullptr"); CCASSERT( dynamic_cast(aChild) != nullptr, "CCParticleBatchNode only supports QuadParticleSystems as children"); ParticleSystem* child = static_cast(aChild); CCASSERT( child->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCParticleSystem is not using the same texture id"); // If this is the 1st children, then copy blending function if (_children.empty()) { setBlendFunc(child->getBlendFunc()); } CCASSERT( _blendFunc.src == child->getBlendFunc().src && _blendFunc.dst == child->getBlendFunc().dst, "Can't add a ParticleSystem that uses a different blending function"); //no lazy sorting, so don't call super addChild, call helper instead auto pos = addChildHelper(child,zOrder,tag); //get new atlasIndex int atlasIndex = 0; if (pos != 0) { ParticleSystem* p = static_cast(_children.at(pos-1)); atlasIndex = p->getAtlasIndex() + p->getTotalParticles(); } else { atlasIndex = 0; } insertChild(child, atlasIndex); // update quad info child->setBatchNode(this); } // don't use lazy sorting, reordering the particle systems quads afterwards would be too complex // XXX research whether lazy sorting + freeing current quads and calloc a new block with size of capacity would be faster // XXX or possibly using vertexZ for reordering, that would be fastest // this helper is almost equivalent to Node's addChild, but doesn't make use of the lazy sorting int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int aTag) { CCASSERT( child != nullptr, "Argument must be non-nil"); CCASSERT( child->getParent() == nullptr, "child already added. It can't be added again"); _children.reserve(4); //don't use a lazy insert auto pos = searchNewPositionInChildrenForZ(z); _children.insert(pos, child); child->setTag(aTag); child->_setLocalZOrder(z); child->setParent(this); if( _running ) { child->onEnter(); child->onEnterTransitionDidFinish(); } return pos; } // Reorder will be done in this function, no "lazy" reorder to particles void ParticleBatchNode::reorderChild(Node * aChild, int zOrder) { CCASSERT( aChild != nullptr, "Child must be non-nullptr"); CCASSERT( dynamic_cast(aChild) != nullptr, "CCParticleBatchNode only supports QuadParticleSystems as children"); CCASSERT( _children.contains(aChild), "Child doesn't belong to batch" ); ParticleSystem* child = static_cast(aChild); if( zOrder == child->getLocalZOrder() ) { return; } // no reordering if only 1 child if (!_children.empty()) { int newIndex = 0, oldIndex = 0; getCurrentIndex(&oldIndex, &newIndex, child, zOrder); if( oldIndex != newIndex ) { // reorder _children->array child->retain(); _children.erase(oldIndex); _children.insert(newIndex, child); child->release(); // save old altasIndex int oldAtlasIndex = child->getAtlasIndex(); // update atlas index updateAllAtlasIndexes(); // Find new AtlasIndex int newAtlasIndex = 0; for( int i=0;i < _children.size();i++) { ParticleSystem* node = static_cast(_children.at(i)); if( node == child ) { newAtlasIndex = child->getAtlasIndex(); break; } } // reorder textureAtlas quads _textureAtlas->moveQuadsFromIndex(oldAtlasIndex, child->getTotalParticles(), newAtlasIndex); child->updateWithNoTime(); } } child->_setLocalZOrder(zOrder); } void ParticleBatchNode::getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z) { bool foundCurrentIdx = false; bool foundNewIdx = false; int minusOne = 0; auto count = _children.size(); for( int i=0; i < count; i++ ) { Node* pNode = _children.at(i); // new index if( pNode->getLocalZOrder() > z && ! foundNewIdx ) { *newIndex = i; foundNewIdx = true; if( foundCurrentIdx && foundNewIdx ) { break; } } // current index if( child == pNode ) { *oldIndex = i; foundCurrentIdx = true; if( ! foundNewIdx ) { minusOne = -1; } if( foundCurrentIdx && foundNewIdx ) { break; } } } if( ! foundNewIdx ) { *newIndex = static_cast(count); } *newIndex += minusOne; } int ParticleBatchNode::searchNewPositionInChildrenForZ(int z) { auto count = _children.size(); for( int i=0; i < count; i++ ) { Node *child = _children.at(i); if (child->getLocalZOrder() > z) { return i; } } return static_cast(count); } // override removeChild: void ParticleBatchNode::removeChild(Node* aChild, bool cleanup) { // explicit nil handling if (aChild == nullptr) return; CCASSERT( dynamic_cast(aChild) != nullptr, "CCParticleBatchNode only supports QuadParticleSystems as children"); CCASSERT(_children.contains(aChild), "CCParticleBatchNode doesn't contain the sprite. Can't remove it"); ParticleSystem* child = static_cast(aChild); Node::removeChild(child, cleanup); // remove child helper _textureAtlas->removeQuadsAtIndex(child->getAtlasIndex(), child->getTotalParticles()); // after memmove of data, empty the quads at the end of array _textureAtlas->fillWithEmptyQuadsFromIndex(_textureAtlas->getTotalQuads(), child->getTotalParticles()); // particle could be reused for self rendering child->setBatchNode(nullptr); updateAllAtlasIndexes(); } void ParticleBatchNode::removeChildAtIndex(int index, bool doCleanup) { removeChild(_children.at(index), doCleanup); } void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup) { for(const auto &child : _children) static_cast(child)->setBatchNode(nullptr); Node::removeAllChildrenWithCleanup(doCleanup); _textureAtlas->removeAllQuads(); } void ParticleBatchNode::draw(void) { CC_PROFILER_START("CCParticleBatchNode - draw"); if( _textureAtlas->getTotalQuads() == 0 ) { return; } _batchCommand.init( _globalZOrder, _shaderProgram, _blendFunc, _textureAtlas, _modelViewTransform); Director::getInstance()->getRenderer()->addCommand(&_batchCommand); CC_PROFILER_STOP("CCParticleBatchNode - draw"); } void ParticleBatchNode::increaseAtlasCapacityTo(ssize_t quantity) { CCLOG("cocos2d: ParticleBatchNode: resizing TextureAtlas capacity from [%lu] to [%lu].", (long)_textureAtlas->getCapacity(), (long)quantity); if( ! _textureAtlas->resizeCapacity(quantity) ) { // serious problems CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas"); CCASSERT(false,"XXX: ParticleBatchNode #increaseAtlasCapacity SHALL handle this assert"); } } //sets a 0'd quad into the quads array void ParticleBatchNode::disableParticle(int particleIndex) { V3F_C4B_T2F_Quad* quad = &((_textureAtlas->getQuads())[particleIndex]); quad->br.vertices.x = quad->br.vertices.y = quad->tr.vertices.x = quad->tr.vertices.y = quad->tl.vertices.x = quad->tl.vertices.y = quad->bl.vertices.x = quad->bl.vertices.y = 0.0f; } // ParticleBatchNode - add / remove / reorder helper methods // add child helper void ParticleBatchNode::insertChild(ParticleSystem* system, int index) { system->setAtlasIndex(index); if(_textureAtlas->getTotalQuads() + system->getTotalParticles() > _textureAtlas->getCapacity()) { increaseAtlasCapacityTo(_textureAtlas->getTotalQuads() + system->getTotalParticles()); // after a realloc empty quads of textureAtlas can be filled with gibberish (realloc doesn't perform calloc), insert empty quads to prevent it _textureAtlas->fillWithEmptyQuadsFromIndex(_textureAtlas->getCapacity() - system->getTotalParticles(), system->getTotalParticles()); } // make room for quads, not necessary for last child if (system->getAtlasIndex() + system->getTotalParticles() != _textureAtlas->getTotalQuads()) { _textureAtlas->moveQuadsFromIndex(index, index+system->getTotalParticles()); } // increase totalParticles here for new particles, update method of particle-system will fill the quads _textureAtlas->increaseTotalQuadsWith(system->getTotalParticles()); updateAllAtlasIndexes(); } //rebuild atlas indexes void ParticleBatchNode::updateAllAtlasIndexes() { int index = 0; for(const auto &child : _children) { ParticleSystem* partiSys = static_cast(child); partiSys->setAtlasIndex(index); index += partiSys->getTotalParticles(); } } // ParticleBatchNode - CocosNodeTexture protocol void ParticleBatchNode::updateBlendFunc() { if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha()) _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } void ParticleBatchNode::setTexture(Texture2D* texture) { _textureAtlas->setTexture(texture); // If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it if( texture && ! texture->hasPremultipliedAlpha() && ( _blendFunc.src == CC_BLEND_SRC && _blendFunc.dst == CC_BLEND_DST ) ) { _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } } Texture2D* ParticleBatchNode::getTexture() const { return _textureAtlas->getTexture(); } void ParticleBatchNode::setBlendFunc(const BlendFunc &blendFunc) { _blendFunc = blendFunc; } // returns the blending function used for the texture const BlendFunc& ParticleBatchNode::getBlendFunc() const { return _blendFunc; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCParticleBatchNode.h ================================================ /* * Copyright (C) 2009 Matt Oswald * Copyright (c) 2009-2010 Ricardo Quesada * Copyright (c) 2010-2012 cocos2d-x.org * Copyright (c) 2011 Zynga Inc. * Copyright (c) 2011 Marco Tillemans * Copyright (c) 2013-2014 Chukong Technologies Inc. * * http://www.cocos2d-x.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #ifndef __CCPARTICLEBATCHNODE_H__ #define __CCPARTICLEBATCHNODE_H__ #include "CCNode.h" #include "CCProtocols.h" #include "renderer/CCBatchCommand.h" NS_CC_BEGIN class Texture2D; class TextureAtlas; class ParticleSystem; /** * @addtogroup particle_nodes * @{ */ #define kParticleDefaultCapacity 500 /** ParticleBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call * (often known as "batch draw"). * * A ParticleBatchNode can reference one and only one texture (one image file, one texture atlas). * Only the ParticleSystems that are contained in that texture can be added to the SpriteBatchNode. * All ParticleSystems added to a SpriteBatchNode are drawn in one OpenGL ES draw call. * If the ParticleSystems are not added to a ParticleBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient. * * * Limitations: * - At the moment only ParticleSystemQuad is supported * - All systems need to be drawn with the same parameters, blend function, aliasing, texture * * Most efficient usage * - Initialize the ParticleBatchNode with the texture and enough capacity for all the particle systems * - Initialize all particle systems and add them as child to the batch node * @since v1.1 */ class CC_DLL ParticleBatchNode : public Node, public TextureProtocol { public: /** initializes the particle system with Texture2D, a capacity of particles, which particle system to use */ static ParticleBatchNode* createWithTexture(Texture2D *tex, int capacity = kParticleDefaultCapacity); /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */ static ParticleBatchNode* create(const std::string& fileImage, int capacity = kParticleDefaultCapacity); /** * @js NA * @lua NA */ virtual ~ParticleBatchNode(); /** Inserts a child into the ParticleBatchNode */ void insertChild(ParticleSystem* system, int index); void removeChildAtIndex(int index, bool doCleanup); void removeAllChildrenWithCleanup(bool doCleanup); /** disables a particle by inserting a 0'd quad into the texture atlas */ void disableParticle(int particleIndex); /** Gets the texture atlas used for drawing the quads */ inline TextureAtlas* getTextureAtlas() const { return _textureAtlas; }; /** Sets the texture atlas used for drawing the quads */ inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; }; // Overrides void visit(); using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; virtual void removeChild(Node* child, bool cleanup) override; virtual void reorderChild(Node * child, int zOrder) override; virtual void draw(void) override; virtual Texture2D* getTexture(void) const override; virtual void setTexture(Texture2D *texture) override; /** * @code * When this function bound into js or lua,the parameter will be changed * In js: var setBlendFunc(var src, var dst) * @endcode * @lua NA */ virtual void setBlendFunc(const BlendFunc &blendFunc) override; /** * @js NA * @lua NA */ virtual const BlendFunc& getBlendFunc(void) const override; protected: /** * @js ctor */ ParticleBatchNode(); /** initializes the particle system with Texture2D, a capacity of particles */ bool initWithTexture(Texture2D *tex, int capacity); /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */ bool initWithFile(const std::string& fileImage, int capacity); private: void updateAllAtlasIndexes(); void increaseAtlasCapacityTo(ssize_t quantity); int searchNewPositionInChildrenForZ(int z); void getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z); int addChildHelper(ParticleSystem* child, int z, int aTag); void updateBlendFunc(void); /** the texture atlas used for drawing the quads */ TextureAtlas* _textureAtlas; private: /** the blend function used for drawing the quads */ BlendFunc _blendFunc; // quad command BatchCommand _batchCommand; }; // end of particle_nodes group /// @} NS_CC_END #endif /* __CCPARTICLEBATCHNODE_H__ */ ================================================ FILE: cocos2d/cocos/2d/CCParticleExamples.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCParticleExamples.h" #include "CCDirector.h" #include "CCTextureCache.h" #include "firePngData.h" #include "platform/CCImage.h" NS_CC_BEGIN // // ParticleFire // static Texture2D* getDefaultTexture() { Texture2D* texture = nullptr; Image* image = nullptr; do { bool ret = false; const std::string key = "/__firePngData"; texture = Director::getInstance()->getTextureCache()->getTextureForKey(key); CC_BREAK_IF(texture != nullptr); image = new Image(); CC_BREAK_IF(nullptr == image); ret = image->initWithImageData(__firePngData, sizeof(__firePngData)); CC_BREAK_IF(!ret); texture = Director::getInstance()->getTextureCache()->addImage(image, key); } while (0); CC_SAFE_RELEASE(image); return texture; } ParticleFire* ParticleFire::create() { ParticleFire* ret = new ParticleFire(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleFire* ParticleFire::createWithTotalParticles(int numberOfParticles) { ParticleFire* ret = new ParticleFire(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleFire::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // Gravity Mode this->_emitterMode = Mode::GRAVITY; // Gravity Mode: gravity this->modeA.gravity = Point(0,0); // Gravity Mode: radial acceleration this->modeA.radialAccel = 0; this->modeA.radialAccelVar = 0; // Gravity Mode: speed of particles this->modeA.speed = 60; this->modeA.speedVar = 20; // starting angle _angle = 90; _angleVar = 10; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, 60)); this->_posVar = Point(40, 20); // life of particles _life = 3; _lifeVar = 0.25f; // size, in pixels _startSize = 54.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per frame _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.76f; _startColor.g = 0.25f; _startColor.b = 0.12f; _startColor.a = 1.0f; _startColorVar.r = 0.0f; _startColorVar.g = 0.0f; _startColorVar.b = 0.0f; _startColorVar.a = 0.0f; _endColor.r = 0.0f; _endColor.g = 0.0f; _endColor.b = 0.0f; _endColor.a = 1.0f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(true); return true; } return false; } // // ParticleFireworks // ParticleFireworks* ParticleFireworks::create() { ParticleFireworks* ret = new ParticleFireworks(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleFireworks* ParticleFireworks::createWithTotalParticles(int numberOfParticles) { ParticleFireworks* ret = new ParticleFireworks(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleFireworks::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration= DURATION_INFINITY; // Gravity Mode this->_emitterMode = Mode::GRAVITY; // Gravity Mode: gravity this->modeA.gravity = Point(0,-90); // Gravity Mode: radial this->modeA.radialAccel = 0; this->modeA.radialAccelVar = 0; // Gravity Mode: speed of particles this->modeA.speed = 180; this->modeA.speedVar = 50; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height/2)); // angle this->_angle= 90; this->_angleVar = 20; // life of particles this->_life = 3.5f; this->_lifeVar = 1; // emits per frame this->_emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.5f; _startColor.g = 0.5f; _startColor.b = 0.5f; _startColor.a = 1.0f; _startColorVar.r = 0.5f; _startColorVar.g = 0.5f; _startColorVar.b = 0.5f; _startColorVar.a = 0.1f; _endColor.r = 0.1f; _endColor.g = 0.1f; _endColor.b = 0.1f; _endColor.a = 0.2f; _endColorVar.r = 0.1f; _endColorVar.g = 0.1f; _endColorVar.b = 0.1f; _endColorVar.a = 0.2f; // size, in pixels _startSize = 8.0f; _startSizeVar = 2.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; } // // ParticleSun // ParticleSun* ParticleSun::create() { ParticleSun* ret = new ParticleSun(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleSun* ParticleSun::createWithTotalParticles(int numberOfParticles) { ParticleSun* ret = new ParticleSun(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleSun::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // additive this->setBlendAdditive(true); // duration _duration = DURATION_INFINITY; // Gravity Mode setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); // Gravity mode: radial acceleration setRadialAccel(0); setRadialAccelVar(0); // Gravity mode: speed of particles setSpeed(20); setSpeedVar(5); // angle _angle = 90; _angleVar = 360; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height/2)); setPosVar(Point::ZERO); // life of particles _life = 1; _lifeVar = 0.5f; // size, in pixels _startSize = 30.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per seconds _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.76f; _startColor.g = 0.25f; _startColor.b = 0.12f; _startColor.a = 1.0f; _startColorVar.r = 0.0f; _startColorVar.g = 0.0f; _startColorVar.b = 0.0f; _startColorVar.a = 0.0f; _endColor.r = 0.0f; _endColor.g = 0.0f; _endColor.b = 0.0f; _endColor.a = 1.0f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } return true; } return false; } // // ParticleGalaxy // ParticleGalaxy* ParticleGalaxy::create() { ParticleGalaxy* ret = new ParticleGalaxy(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleGalaxy* ParticleGalaxy::createWithTotalParticles(int numberOfParticles) { ParticleGalaxy* ret = new ParticleGalaxy(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // Gravity Mode setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); // Gravity Mode: speed of particles setSpeed(60); setSpeedVar(10); // Gravity Mode: radial setRadialAccel(-80); setRadialAccelVar(0); // Gravity Mode: tangential setTangentialAccel(80); setTangentialAccelVar(0); // angle _angle = 90; _angleVar = 360; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height/2)); setPosVar(Point::ZERO); // life of particles _life = 4; _lifeVar = 1; // size, in pixels _startSize = 37.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.12f; _startColor.g = 0.25f; _startColor.b = 0.76f; _startColor.a = 1.0f; _startColorVar.r = 0.0f; _startColorVar.g = 0.0f; _startColorVar.b = 0.0f; _startColorVar.a = 0.0f; _endColor.r = 0.0f; _endColor.g = 0.0f; _endColor.b = 0.0f; _endColor.a = 1.0f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(true); return true; } return false; } // // ParticleFlower // ParticleFlower* ParticleFlower::create() { ParticleFlower* ret = new ParticleFlower(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleFlower* ParticleFlower::createWithTotalParticles(int numberOfParticles) { ParticleFlower* ret = new ParticleFlower(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleFlower::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // Gravity Mode setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); // Gravity Mode: speed of particles setSpeed(80); setSpeedVar(10); // Gravity Mode: radial setRadialAccel(-60); setRadialAccelVar(0); // Gravity Mode: tangential setTangentialAccel(15); setTangentialAccelVar(0); // angle _angle = 90; _angleVar = 360; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height/2)); setPosVar(Point::ZERO); // life of particles _life = 4; _lifeVar = 1; // size, in pixels _startSize = 30.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.50f; _startColor.g = 0.50f; _startColor.b = 0.50f; _startColor.a = 1.0f; _startColorVar.r = 0.5f; _startColorVar.g = 0.5f; _startColorVar.b = 0.5f; _startColorVar.a = 0.5f; _endColor.r = 0.0f; _endColor.g = 0.0f; _endColor.b = 0.0f; _endColor.a = 1.0f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(true); return true; } return false; } // // ParticleMeteor // ParticleMeteor * ParticleMeteor::create() { ParticleMeteor *ret = new ParticleMeteor(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleMeteor* ParticleMeteor::createWithTotalParticles(int numberOfParticles) { ParticleMeteor* ret = new ParticleMeteor(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleMeteor::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // Gravity Mode setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(-200,200)); // Gravity Mode: speed of particles setSpeed(15); setSpeedVar(5); // Gravity Mode: radial setRadialAccel(0); setRadialAccelVar(0); // Gravity Mode: tangential setTangentialAccel(0); setTangentialAccelVar(0); // angle _angle = 90; _angleVar = 360; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height/2)); setPosVar(Point::ZERO); // life of particles _life = 2; _lifeVar = 1; // size, in pixels _startSize = 60.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.2f; _startColor.g = 0.4f; _startColor.b = 0.7f; _startColor.a = 1.0f; _startColorVar.r = 0.0f; _startColorVar.g = 0.0f; _startColorVar.b = 0.2f; _startColorVar.a = 0.1f; _endColor.r = 0.0f; _endColor.g = 0.0f; _endColor.b = 0.0f; _endColor.a = 1.0f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(true); return true; } return false; } // // ParticleSpiral // ParticleSpiral* ParticleSpiral::create() { ParticleSpiral* ret = new ParticleSpiral(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleSpiral* ParticleSpiral::createWithTotalParticles(int numberOfParticles) { ParticleSpiral* ret = new ParticleSpiral(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleSpiral::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // Gravity Mode setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); // Gravity Mode: speed of particles setSpeed(150); setSpeedVar(0); // Gravity Mode: radial setRadialAccel(-380); setRadialAccelVar(0); // Gravity Mode: tangential setTangentialAccel(45); setTangentialAccelVar(0); // angle _angle = 90; _angleVar = 0; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height/2)); setPosVar(Point::ZERO); // life of particles _life = 12; _lifeVar = 0; // size, in pixels _startSize = 20.0f; _startSizeVar = 0.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.5f; _startColor.g = 0.5f; _startColor.b = 0.5f; _startColor.a = 1.0f; _startColorVar.r = 0.5f; _startColorVar.g = 0.5f; _startColorVar.b = 0.5f; _startColorVar.a = 0.0f; _endColor.r = 0.5f; _endColor.g = 0.5f; _endColor.b = 0.5f; _endColor.a = 1.0f; _endColorVar.r = 0.5f; _endColorVar.g = 0.5f; _endColorVar.b = 0.5f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; } // // ParticleExplosion // ParticleExplosion* ParticleExplosion::create() { ParticleExplosion* ret = new ParticleExplosion(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleExplosion* ParticleExplosion::createWithTotalParticles(int numberOfParticles) { ParticleExplosion* ret = new ParticleExplosion(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleExplosion::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = 0.1f; setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); // Gravity Mode: speed of particles setSpeed(70); setSpeedVar(40); // Gravity Mode: radial setRadialAccel(0); setRadialAccelVar(0); // Gravity Mode: tangential setTangentialAccel(0); setTangentialAccelVar(0); // angle _angle = 90; _angleVar = 360; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height/2)); setPosVar(Point::ZERO); // life of particles _life = 5.0f; _lifeVar = 2; // size, in pixels _startSize = 15.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_duration; // color of particles _startColor.r = 0.7f; _startColor.g = 0.1f; _startColor.b = 0.2f; _startColor.a = 1.0f; _startColorVar.r = 0.5f; _startColorVar.g = 0.5f; _startColorVar.b = 0.5f; _startColorVar.a = 0.0f; _endColor.r = 0.5f; _endColor.g = 0.5f; _endColor.b = 0.5f; _endColor.a = 0.0f; _endColorVar.r = 0.5f; _endColorVar.g = 0.5f; _endColorVar.b = 0.5f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; } // // ParticleSmoke // ParticleSmoke* ParticleSmoke::create() { ParticleSmoke* ret = new ParticleSmoke(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleSmoke* ParticleSmoke::createWithTotalParticles(int numberOfParticles) { ParticleSmoke* ret = new ParticleSmoke(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleSmoke::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // Emitter mode: Gravity Mode setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); // Gravity Mode: radial acceleration setRadialAccel(0); setRadialAccelVar(0); // Gravity Mode: speed of particles setSpeed(25); setSpeedVar(10); // angle _angle = 90; _angleVar = 5; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, 0)); setPosVar(Point(20, 0)); // life of particles _life = 4; _lifeVar = 1; // size, in pixels _startSize = 60.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per frame _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.8f; _startColor.g = 0.8f; _startColor.b = 0.8f; _startColor.a = 1.0f; _startColorVar.r = 0.02f; _startColorVar.g = 0.02f; _startColorVar.b = 0.02f; _startColorVar.a = 0.0f; _endColor.r = 0.0f; _endColor.g = 0.0f; _endColor.b = 0.0f; _endColor.a = 1.0f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; } // // ParticleSnow // ParticleSnow* ParticleSnow::create() { ParticleSnow* ret = new ParticleSnow(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleSnow* ParticleSnow::createWithTotalParticles(int numberOfParticles) { ParticleSnow* ret = new ParticleSnow(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleSnow::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // set gravity mode. setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,-1)); // Gravity Mode: speed of particles setSpeed(5); setSpeedVar(1); // Gravity Mode: radial setRadialAccel(0); setRadialAccelVar(1); // Gravity mode: tangential setTangentialAccel(0); setTangentialAccelVar(1); // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height + 10)); setPosVar(Point(winSize.width/2, 0)); // angle _angle = -90; _angleVar = 5; // life of particles _life = 45; _lifeVar = 15; // size, in pixels _startSize = 10.0f; _startSizeVar = 5.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = 10; // color of particles _startColor.r = 1.0f; _startColor.g = 1.0f; _startColor.b = 1.0f; _startColor.a = 1.0f; _startColorVar.r = 0.0f; _startColorVar.g = 0.0f; _startColorVar.b = 0.0f; _startColorVar.a = 0.0f; _endColor.r = 1.0f; _endColor.g = 1.0f; _endColor.b = 1.0f; _endColor.a = 0.0f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; } // // ParticleRain // ParticleRain* ParticleRain::create() { ParticleRain* ret = new ParticleRain(); if (ret && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ParticleRain* ParticleRain::createWithTotalParticles(int numberOfParticles) { ParticleRain* ret = new ParticleRain(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ParticleRain::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(10,-10)); // Gravity Mode: radial setRadialAccel(0); setRadialAccelVar(1); // Gravity Mode: tangential setTangentialAccel(0); setTangentialAccelVar(1); // Gravity Mode: speed of particles setSpeed(130); setSpeedVar(30); // angle _angle = -90; _angleVar = 5; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height)); setPosVar(Point(winSize.width/2, 0)); // life of particles _life = 4.5f; _lifeVar = 0; // size, in pixels _startSize = 4.0f; _startSizeVar = 2.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = 20; // color of particles _startColor.r = 0.7f; _startColor.g = 0.8f; _startColor.b = 1.0f; _startColor.a = 1.0f; _startColorVar.r = 0.0f; _startColorVar.g = 0.0f; _startColorVar.b = 0.0f; _startColorVar.a = 0.0f; _endColor.r = 0.7f; _endColor.g = 0.8f; _endColor.b = 1.0f; _endColor.a = 0.5f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCParticleExamples.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPARTICLE_EXAMPLE_H__ #define __CCPARTICLE_EXAMPLE_H__ #include "CCParticleSystemQuad.h" NS_CC_BEGIN /** * @addtogroup particle_nodes * @{ */ //! @brief A fire particle system class CC_DLL ParticleFire : public ParticleSystemQuad { public: static ParticleFire* create(); static ParticleFire* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleFire(){} /** * @js NA * @lua NA */ virtual ~ParticleFire(){} bool init(){ return initWithTotalParticles(250); } virtual bool initWithTotalParticles(int numberOfParticles) override; private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleFire); }; //! @brief A fireworks particle system class CC_DLL ParticleFireworks : public ParticleSystemQuad { public: static ParticleFireworks* create(); static ParticleFireworks* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleFireworks(){} /** * @js NA * @lua NA */ virtual ~ParticleFireworks(){} bool init(){ return initWithTotalParticles(1500); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleFireworks); }; //! @brief A sun particle system class CC_DLL ParticleSun : public ParticleSystemQuad { public: static ParticleSun* create(); static ParticleSun* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleSun(){} /** * @js NA * @lua NA */ virtual ~ParticleSun(){} bool init(){ return initWithTotalParticles(350); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleSun); }; //! @brief A galaxy particle system class CC_DLL ParticleGalaxy : public ParticleSystemQuad { public: static ParticleGalaxy* create(); static ParticleGalaxy* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleGalaxy(){} /** * @js NA * @lua NA */ virtual ~ParticleGalaxy(){} bool init(){ return initWithTotalParticles(200); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleGalaxy); }; //! @brief A flower particle system class CC_DLL ParticleFlower : public ParticleSystemQuad { public: static ParticleFlower* create(); static ParticleFlower* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleFlower(){} /** * @js NA * @lua NA */ virtual ~ParticleFlower(){} bool init(){ return initWithTotalParticles(250); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleFlower); }; //! @brief A meteor particle system class CC_DLL ParticleMeteor : public ParticleSystemQuad { public: static ParticleMeteor * create(); static ParticleMeteor* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleMeteor(){} /** * @js NA * @lua NA */ virtual ~ParticleMeteor(){} bool init(){ return initWithTotalParticles(150); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleMeteor); }; //! @brief An spiral particle system class CC_DLL ParticleSpiral : public ParticleSystemQuad { public: static ParticleSpiral* create(); static ParticleSpiral* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleSpiral(){} /** * @js NA * @lua NA */ virtual ~ParticleSpiral(){} bool init(){ return initWithTotalParticles(500); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleSpiral); }; //! @brief An explosion particle system class CC_DLL ParticleExplosion : public ParticleSystemQuad { public: static ParticleExplosion* create(); static ParticleExplosion* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleExplosion(){} /** * @js NA * @lua NA */ virtual ~ParticleExplosion(){} bool init(){ return initWithTotalParticles(700); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleExplosion); }; //! @brief An smoke particle system class CC_DLL ParticleSmoke : public ParticleSystemQuad { public: static ParticleSmoke* create(); static ParticleSmoke* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleSmoke(){} /** * @js NA * @lua NA */ virtual ~ParticleSmoke(){} bool init(){ return initWithTotalParticles(200); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleSmoke); }; //! @brief An snow particle system class CC_DLL ParticleSnow : public ParticleSystemQuad { public: static ParticleSnow* create(); static ParticleSnow* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleSnow(){} /** * @js NA * @lua NA */ virtual ~ParticleSnow(){} bool init(){ return initWithTotalParticles(700); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleSnow); }; //! @brief A rain particle system class CC_DLL ParticleRain : public ParticleSystemQuad { public: static ParticleRain* create(); static ParticleRain* createWithTotalParticles(int numberOfParticles); protected: /** * @js ctor */ ParticleRain(){} /** * @js NA * @lua NA */ virtual ~ParticleRain(){} bool init(){ return initWithTotalParticles(1000); } virtual bool initWithTotalParticles(int numberOfParticles); private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleRain); }; // end of particle_nodes group /// @} NS_CC_END #endif //__CCPARTICLE_EXAMPLE_H__ ================================================ FILE: cocos2d/cocos/2d/CCParticleSystem.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ // ideas taken from: // . The ocean spray in your face [Jeff Lander] // http://www.double.co.nz/dust/col0798.pdf // . Building an Advanced Particle System [John van der Burg] // http://www.gamasutra.com/features/20000623/vanderburg_01.htm // . LOVE game engine // http://love2d.org/ // // // Radius mode support, from 71 squared // http://particledesigner.71squared.com/ // // IMPORTANT: Particle Designer is supported by cocos2d, but // 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d, // cocos2d uses a another approach, but the results are almost identical. // #include "CCParticleSystem.h" #include #include "CCParticleBatchNode.h" #include "ccTypes.h" #include "CCTextureCache.h" #include "CCTextureAtlas.h" #include "base64.h" #include "platform/CCFileUtils.h" #include "platform/CCImage.h" #include "ZipUtils.h" #include "CCDirector.h" #include "CCProfiling.h" // opengl #include "CCGL.h" using namespace std; NS_CC_BEGIN // ideas taken from: // . The ocean spray in your face [Jeff Lander] // http://www.double.co.nz/dust/col0798.pdf // . Building an Advanced Particle System [John van der Burg] // http://www.gamasutra.com/features/20000623/vanderburg_01.htm // . LOVE game engine // http://love2d.org/ // // // Radius mode support, from 71 squared // http://particledesigner.71squared.com/ // // IMPORTANT: Particle Designer is supported by cocos2d, but // 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d, // cocos2d uses a another approach, but the results are almost identical. // ParticleSystem::ParticleSystem() : _isBlendAdditive(false) , _isAutoRemoveOnFinish(false) , _plistFile("") , _elapsed(0) , _particles(nullptr) , _configName("") , _emitCounter(0) , _particleIdx(0) , _batchNode(nullptr) , _atlasIndex(0) , _transformSystemDirty(false) , _allocatedParticles(0) , _isActive(true) , _particleCount(0) , _duration(0) , _sourcePosition(Point::ZERO) , _posVar(Point::ZERO) , _life(0) , _lifeVar(0) , _angle(0) , _angleVar(0) , _emitterMode(Mode::GRAVITY) , _startSize(0) , _startSizeVar(0) , _endSize(0) , _endSizeVar(0) , _startSpin(0) , _startSpinVar(0) , _endSpin(0) , _endSpinVar(0) , _emissionRate(0) , _totalParticles(0) , _texture(nullptr) , _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED) , _opacityModifyRGB(false) , _yCoordFlipped(0) , _positionType(PositionType::FREE) { modeA.gravity = Point::ZERO; modeA.speed = 0; modeA.speedVar = 0; modeA.tangentialAccel = 0; modeA.tangentialAccelVar = 0; modeA.radialAccel = 0; modeA.radialAccelVar = 0; modeA.rotationIsDir = false; modeB.startRadius = 0; modeB.startRadiusVar = 0; modeB.endRadius = 0; modeB.endRadiusVar = 0; modeB.rotatePerSecond = 0; modeB.rotatePerSecondVar = 0; } // implementation ParticleSystem ParticleSystem * ParticleSystem::create(const std::string& plistFile) { ParticleSystem *ret = new ParticleSystem(); if (ret && ret->initWithFile(plistFile)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return ret; } ParticleSystem* ParticleSystem::createWithTotalParticles(int numberOfParticles) { ParticleSystem *ret = new ParticleSystem(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return ret; } bool ParticleSystem::init() { return initWithTotalParticles(150); } bool ParticleSystem::initWithFile(const std::string& plistFile) { bool ret = false; _plistFile = FileUtils::getInstance()->fullPathForFilename(plistFile); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(_plistFile.c_str()); CCASSERT( !dict.empty(), "Particles: file not found"); // XXX compute path from a path, should define a function somewhere to do it string listFilePath = plistFile; if (listFilePath.find('/') != string::npos) { listFilePath = listFilePath.substr(0, listFilePath.rfind('/') + 1); ret = this->initWithDictionary(dict, listFilePath.c_str()); } else { ret = this->initWithDictionary(dict, ""); } return ret; } bool ParticleSystem::initWithDictionary(ValueMap& dictionary) { return initWithDictionary(dictionary, ""); } bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& dirname) { bool ret = false; unsigned char *buffer = nullptr; unsigned char *deflated = nullptr; Image *image = nullptr; do { int maxParticles = dictionary["maxParticles"].asInt(); // self, not super if(this->initWithTotalParticles(maxParticles)) { // Emitter name in particle designer 2.0 _configName = dictionary["configName"].asString(); // angle _angle = dictionary["angle"].asFloat(); _angleVar = dictionary["angleVariance"].asFloat(); // duration _duration = dictionary["duration"].asFloat(); // blend function if (_configName.length()>0) { _blendFunc.src = dictionary["blendFuncSource"].asFloat(); } else { _blendFunc.src = dictionary["blendFuncSource"].asInt(); } _blendFunc.dst = dictionary["blendFuncDestination"].asInt(); // color _startColor.r = dictionary["startColorRed"].asFloat(); _startColor.g = dictionary["startColorGreen"].asFloat(); _startColor.b = dictionary["startColorBlue"].asFloat(); _startColor.a = dictionary["startColorAlpha"].asFloat(); _startColorVar.r = dictionary["startColorVarianceRed"].asFloat(); _startColorVar.g = dictionary["startColorVarianceGreen"].asFloat(); _startColorVar.b = dictionary["startColorVarianceBlue"].asFloat(); _startColorVar.a = dictionary["startColorVarianceAlpha"].asFloat(); _endColor.r = dictionary["finishColorRed"].asFloat(); _endColor.g = dictionary["finishColorGreen"].asFloat(); _endColor.b = dictionary["finishColorBlue"].asFloat(); _endColor.a = dictionary["finishColorAlpha"].asFloat(); _endColorVar.r = dictionary["finishColorVarianceRed"].asFloat(); _endColorVar.g = dictionary["finishColorVarianceGreen"].asFloat(); _endColorVar.b = dictionary["finishColorVarianceBlue"].asFloat(); _endColorVar.a = dictionary["finishColorVarianceAlpha"].asFloat(); // particle size _startSize = dictionary["startParticleSize"].asFloat(); _startSizeVar = dictionary["startParticleSizeVariance"].asFloat(); _endSize = dictionary["finishParticleSize"].asFloat(); _endSizeVar = dictionary["finishParticleSizeVariance"].asFloat(); // position float x = dictionary["sourcePositionx"].asFloat(); float y = dictionary["sourcePositiony"].asFloat(); this->setPosition( Point(x,y) ); _posVar.x = dictionary["sourcePositionVariancex"].asFloat(); _posVar.y = dictionary["sourcePositionVariancey"].asFloat(); // Spinning _startSpin = dictionary["rotationStart"].asFloat(); _startSpinVar = dictionary["rotationStartVariance"].asFloat(); _endSpin= dictionary["rotationEnd"].asFloat(); _endSpinVar= dictionary["rotationEndVariance"].asFloat(); _emitterMode = (Mode) dictionary["emitterType"].asInt(); // Mode A: Gravity + tangential accel + radial accel if (_emitterMode == Mode::GRAVITY) { // gravity modeA.gravity.x = dictionary["gravityx"].asFloat(); modeA.gravity.y = dictionary["gravityy"].asFloat(); // speed modeA.speed = dictionary["speed"].asFloat(); modeA.speedVar = dictionary["speedVariance"].asFloat(); // radial acceleration modeA.radialAccel = dictionary["radialAcceleration"].asFloat(); modeA.radialAccelVar = dictionary["radialAccelVariance"].asFloat(); // tangential acceleration modeA.tangentialAccel = dictionary["tangentialAcceleration"].asFloat(); modeA.tangentialAccelVar = dictionary["tangentialAccelVariance"].asFloat(); // rotation is dir modeA.rotationIsDir = dictionary["rotationIsDir"].asBool(); } // or Mode B: radius movement else if (_emitterMode == Mode::RADIUS) { if (_configName.length()>0) { modeB.startRadius = dictionary["maxRadius"].asInt(); } else { modeB.startRadius = dictionary["maxRadius"].asFloat(); } modeB.startRadiusVar = dictionary["maxRadiusVariance"].asFloat(); if (_configName.length()>0) { modeB.endRadius = dictionary["minRadius"].asInt(); } else { modeB.endRadius = dictionary["minRadius"].asFloat(); } modeB.endRadiusVar = 0.0f; if (_configName.length()>0) { modeB.rotatePerSecond = dictionary["rotatePerSecond"].asInt(); } else { modeB.rotatePerSecond = dictionary["rotatePerSecond"].asFloat(); } modeB.rotatePerSecondVar = dictionary["rotatePerSecondVariance"].asFloat(); } else { CCASSERT( false, "Invalid emitterType in config file"); CC_BREAK_IF(true); } // life span _life = dictionary["particleLifespan"].asFloat(); _lifeVar = dictionary["particleLifespanVariance"].asFloat(); // emission Rate _emissionRate = _totalParticles / _life; //don't get the internal texture if a batchNode is used if (!_batchNode) { // Set a compatible default for the alpha transfer _opacityModifyRGB = false; // texture // Try to get the texture from the cache std::string textureName = dictionary["textureFileName"].asString(); size_t rPos = textureName.rfind('/'); if (rPos != string::npos) { string textureDir = textureName.substr(0, rPos + 1); if (!dirname.empty() && textureDir != dirname) { textureName = textureName.substr(rPos+1); textureName = dirname + textureName; } } else if (!dirname.empty() && !textureName.empty()) { textureName = dirname + textureName; } Texture2D *tex = nullptr; if (textureName.length() > 0) { // set not pop-up message box when load image failed bool notify = FileUtils::getInstance()->isPopupNotify(); FileUtils::getInstance()->setPopupNotify(false); tex = Director::getInstance()->getTextureCache()->addImage(textureName); // reset the value of UIImage notify FileUtils::getInstance()->setPopupNotify(notify); } if (tex) { setTexture(tex); } else { std::string textureData = dictionary["textureImageData"].asString(); CCASSERT(!textureData.empty(), ""); auto dataLen = textureData.size(); if (dataLen != 0) { // if it fails, try to get it from the base64-gzipped data int decodeLen = base64Decode((unsigned char*)textureData.c_str(), (unsigned int)dataLen, &buffer); CCASSERT( buffer != nullptr, "CCParticleSystem: error decoding textureImageData"); CC_BREAK_IF(!buffer); ssize_t deflatedLen = ZipUtils::inflateMemory(buffer, decodeLen, &deflated); CCASSERT( deflated != nullptr, "CCParticleSystem: error ungzipping textureImageData"); CC_BREAK_IF(!deflated); // For android, we should retain it in VolatileTexture::addImage which invoked in Director::getInstance()->getTextureCache()->addUIImage() image = new Image(); bool isOK = image->initWithImageData(deflated, deflatedLen); CCASSERT(isOK, "CCParticleSystem: error init image with Data"); CC_BREAK_IF(!isOK); setTexture(Director::getInstance()->getTextureCache()->addImage(image, textureName.c_str())); image->release(); } } if (!_configName.empty()) { _yCoordFlipped = dictionary["yCoordFlipped"].asInt(); } CCASSERT( this->_texture != nullptr, "CCParticleSystem: error loading the texture"); } ret = true; } } while (0); free(buffer); free(deflated); return ret; } bool ParticleSystem::initWithTotalParticles(int numberOfParticles) { _totalParticles = numberOfParticles; CC_SAFE_FREE(_particles); _particles = (tParticle*)calloc(_totalParticles, sizeof(tParticle)); if( ! _particles ) { CCLOG("Particle system: not enough memory"); this->release(); return false; } _allocatedParticles = numberOfParticles; if (_batchNode) { for (int i = 0; i < _totalParticles; i++) { _particles[i].atlasIndex=i; } } // default, active _isActive = true; // default blend function _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; // default movement type; _positionType = PositionType::FREE; // by default be in mode A: _emitterMode = Mode::GRAVITY; // default: modulate // XXX: not used // colorModulate = YES; _isAutoRemoveOnFinish = false; // Optimization: compile updateParticle method //updateParticleSel = @selector(updateQuadWithParticle:newPosition:); //updateParticleImp = (CC_UPDATE_PARTICLE_IMP) [self methodForSelector:updateParticleSel]; //for batchNode _transformSystemDirty = false; // update after action in run! this->scheduleUpdateWithPriority(1); return true; } ParticleSystem::~ParticleSystem() { // Since the scheduler retains the "target (in this case the ParticleSystem) // it is not needed to call "unscheduleUpdate" here. In fact, it will be called in "cleanup" //unscheduleUpdate(); CC_SAFE_FREE(_particles); CC_SAFE_RELEASE(_texture); } bool ParticleSystem::addParticle() { if (this->isFull()) { return false; } tParticle * particle = &_particles[ _particleCount ]; this->initParticle(particle); ++_particleCount; return true; } void ParticleSystem::initParticle(tParticle* particle) { // timeToLive // no negative life. prevent division by 0 particle->timeToLive = _life + _lifeVar * CCRANDOM_MINUS1_1(); particle->timeToLive = MAX(0, particle->timeToLive); // position particle->pos.x = _sourcePosition.x + _posVar.x * CCRANDOM_MINUS1_1(); particle->pos.y = _sourcePosition.y + _posVar.y * CCRANDOM_MINUS1_1(); // Color Color4F start; start.r = clampf(_startColor.r + _startColorVar.r * CCRANDOM_MINUS1_1(), 0, 1); start.g = clampf(_startColor.g + _startColorVar.g * CCRANDOM_MINUS1_1(), 0, 1); start.b = clampf(_startColor.b + _startColorVar.b * CCRANDOM_MINUS1_1(), 0, 1); start.a = clampf(_startColor.a + _startColorVar.a * CCRANDOM_MINUS1_1(), 0, 1); Color4F end; end.r = clampf(_endColor.r + _endColorVar.r * CCRANDOM_MINUS1_1(), 0, 1); end.g = clampf(_endColor.g + _endColorVar.g * CCRANDOM_MINUS1_1(), 0, 1); end.b = clampf(_endColor.b + _endColorVar.b * CCRANDOM_MINUS1_1(), 0, 1); end.a = clampf(_endColor.a + _endColorVar.a * CCRANDOM_MINUS1_1(), 0, 1); particle->color = start; particle->deltaColor.r = (end.r - start.r) / particle->timeToLive; particle->deltaColor.g = (end.g - start.g) / particle->timeToLive; particle->deltaColor.b = (end.b - start.b) / particle->timeToLive; particle->deltaColor.a = (end.a - start.a) / particle->timeToLive; // size float startS = _startSize + _startSizeVar * CCRANDOM_MINUS1_1(); startS = MAX(0, startS); // No negative value particle->size = startS; if (_endSize == START_SIZE_EQUAL_TO_END_SIZE) { particle->deltaSize = 0; } else { float endS = _endSize + _endSizeVar * CCRANDOM_MINUS1_1(); endS = MAX(0, endS); // No negative values particle->deltaSize = (endS - startS) / particle->timeToLive; } // rotation float startA = _startSpin + _startSpinVar * CCRANDOM_MINUS1_1(); float endA = _endSpin + _endSpinVar * CCRANDOM_MINUS1_1(); particle->rotation = startA; particle->deltaRotation = (endA - startA) / particle->timeToLive; // position if (_positionType == PositionType::FREE) { particle->startPos = this->convertToWorldSpace(Point::ZERO); } else if (_positionType == PositionType::RELATIVE) { particle->startPos = _position; } // direction float a = CC_DEGREES_TO_RADIANS( _angle + _angleVar * CCRANDOM_MINUS1_1() ); // Mode Gravity: A if (_emitterMode == Mode::GRAVITY) { Point v(cosf( a ), sinf( a )); float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1(); // direction particle->modeA.dir = v * s ; // radial accel particle->modeA.radialAccel = modeA.radialAccel + modeA.radialAccelVar * CCRANDOM_MINUS1_1(); // tangential accel particle->modeA.tangentialAccel = modeA.tangentialAccel + modeA.tangentialAccelVar * CCRANDOM_MINUS1_1(); // rotation is dir if(modeA.rotationIsDir) particle->rotation = -CC_RADIANS_TO_DEGREES(particle->modeA.dir.getAngle()); } // Mode Radius: B else { // Set the default diameter of the particle from the source position float startRadius = modeB.startRadius + modeB.startRadiusVar * CCRANDOM_MINUS1_1(); float endRadius = modeB.endRadius + modeB.endRadiusVar * CCRANDOM_MINUS1_1(); particle->modeB.radius = startRadius; if (modeB.endRadius == START_RADIUS_EQUAL_TO_END_RADIUS) { particle->modeB.deltaRadius = 0; } else { particle->modeB.deltaRadius = (endRadius - startRadius) / particle->timeToLive; } particle->modeB.angle = a; particle->modeB.degreesPerSecond = CC_DEGREES_TO_RADIANS(modeB.rotatePerSecond + modeB.rotatePerSecondVar * CCRANDOM_MINUS1_1()); } } void ParticleSystem::stopSystem() { _isActive = false; _elapsed = _duration; _emitCounter = 0; } void ParticleSystem::resetSystem() { _isActive = true; _elapsed = 0; for (_particleIdx = 0; _particleIdx < _particleCount; ++_particleIdx) { tParticle *p = &_particles[_particleIdx]; p->timeToLive = 0; } } bool ParticleSystem::isFull() { return (_particleCount == _totalParticles); } // ParticleSystem - MainLoop void ParticleSystem::update(float dt) { CC_PROFILER_START_CATEGORY(kProfilerCategoryParticles , "CCParticleSystem - update"); if (_isActive && _emissionRate) { float rate = 1.0f / _emissionRate; //issue #1201, prevent bursts of particles, due to too high emitCounter if (_particleCount < _totalParticles) { _emitCounter += dt; } while (_particleCount < _totalParticles && _emitCounter > rate) { this->addParticle(); _emitCounter -= rate; } _elapsed += dt; if (_duration != -1 && _duration < _elapsed) { this->stopSystem(); } } _particleIdx = 0; Point currentPosition = Point::ZERO; if (_positionType == PositionType::FREE) { currentPosition = this->convertToWorldSpace(Point::ZERO); } else if (_positionType == PositionType::RELATIVE) { currentPosition = _position; } if (_visible) { while (_particleIdx < _particleCount) { tParticle *p = &_particles[_particleIdx]; // life p->timeToLive -= dt; if (p->timeToLive > 0) { // Mode A: gravity, direction, tangential accel & radial accel if (_emitterMode == Mode::GRAVITY) { Point tmp, radial, tangential; radial = Point::ZERO; // radial acceleration if (p->pos.x || p->pos.y) { radial = p->pos.normalize(); } tangential = radial; radial = radial * p->modeA.radialAccel; // tangential acceleration float newy = tangential.x; tangential.x = -tangential.y; tangential.y = newy; tangential = tangential * p->modeA.tangentialAccel; // (gravity + radial + tangential) * dt tmp = radial + tangential + modeA.gravity; tmp = tmp * dt; p->modeA.dir = p->modeA.dir + tmp; if (_configName.length()>0) { if (_yCoordFlipped == -1) { tmp = p->modeA.dir * dt; } else { tmp = p->modeA.dir * -dt; } } else { tmp = p->modeA.dir * dt; } p->pos = p->pos + tmp; } // Mode B: radius movement else { // Update the angle and radius of the particle. p->modeB.angle += p->modeB.degreesPerSecond * dt; p->modeB.radius += p->modeB.deltaRadius * dt; p->pos.x = - cosf(p->modeB.angle) * p->modeB.radius; p->pos.y = - sinf(p->modeB.angle) * p->modeB.radius; if (_yCoordFlipped == 1) { p->pos.y = -p->pos.y; } } // color p->color.r += (p->deltaColor.r * dt); p->color.g += (p->deltaColor.g * dt); p->color.b += (p->deltaColor.b * dt); p->color.a += (p->deltaColor.a * dt); // size p->size += (p->deltaSize * dt); p->size = MAX( 0, p->size ); // angle p->rotation += (p->deltaRotation * dt); // // update values in quad // Point newPos; if (_positionType == PositionType::FREE || _positionType == PositionType::RELATIVE) { Point diff = currentPosition - p->startPos; newPos = p->pos - diff; } else { newPos = p->pos; } // translate newPos to correct position, since matrix transform isn't performed in batchnode // don't update the particle with the new position information, it will interfere with the radius and tangential calculations if (_batchNode) { newPos.x+=_position.x; newPos.y+=_position.y; } updateQuadWithParticle(p, newPos); //updateParticleImp(self, updateParticleSel, p, newPos); // update particle counter ++_particleIdx; } else { // life < 0 int currentIndex = p->atlasIndex; if( _particleIdx != _particleCount-1 ) { _particles[_particleIdx] = _particles[_particleCount-1]; } if (_batchNode) { //disable the switched particle _batchNode->disableParticle(_atlasIndex+currentIndex); //switch indexes _particles[_particleCount-1].atlasIndex = currentIndex; } --_particleCount; if( _particleCount == 0 && _isAutoRemoveOnFinish ) { this->unscheduleUpdate(); _parent->removeChild(this, true); return; } } } //while _transformSystemDirty = false; } if (! _batchNode) { postStep(); } CC_PROFILER_STOP_CATEGORY(kProfilerCategoryParticles , "CCParticleSystem - update"); } void ParticleSystem::updateWithNoTime(void) { this->update(0.0f); } void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Point& newPosition) { CC_UNUSED_PARAM(particle); CC_UNUSED_PARAM(newPosition); // should be overridden } void ParticleSystem::postStep() { // should be overridden } // ParticleSystem - Texture protocol void ParticleSystem::setTexture(Texture2D* var) { if (_texture != var) { CC_SAFE_RETAIN(var); CC_SAFE_RELEASE(_texture); _texture = var; updateBlendFunc(); } } void ParticleSystem::updateBlendFunc() { CCASSERT(! _batchNode, "Can't change blending functions when the particle is being batched"); if(_texture) { bool premultiplied = _texture->hasPremultipliedAlpha(); _opacityModifyRGB = false; if( _texture && ( _blendFunc.src == CC_BLEND_SRC && _blendFunc.dst == CC_BLEND_DST ) ) { if( premultiplied ) { _opacityModifyRGB = true; } else { _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } } } } Texture2D * ParticleSystem::getTexture() const { return _texture; } // ParticleSystem - Additive Blending void ParticleSystem::setBlendAdditive(bool additive) { if( additive ) { _blendFunc = BlendFunc::ADDITIVE; } else { if( _texture && ! _texture->hasPremultipliedAlpha() ) _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; else _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; } } bool ParticleSystem::isBlendAdditive() const { return( _blendFunc.src == GL_SRC_ALPHA && _blendFunc.dst == GL_ONE); } // ParticleSystem - Properties of Gravity Mode void ParticleSystem::setTangentialAccel(float t) { CCASSERT( _emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.tangentialAccel = t; } float ParticleSystem::getTangentialAccel() const { CCASSERT( _emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.tangentialAccel; } void ParticleSystem::setTangentialAccelVar(float t) { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.tangentialAccelVar = t; } float ParticleSystem::getTangentialAccelVar() const { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.tangentialAccelVar; } void ParticleSystem::setRadialAccel(float t) { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.radialAccel = t; } float ParticleSystem::getRadialAccel() const { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.radialAccel; } void ParticleSystem::setRadialAccelVar(float t) { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.radialAccelVar = t; } float ParticleSystem::getRadialAccelVar() const { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.radialAccelVar; } void ParticleSystem::setRotationIsDir(bool t) { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.rotationIsDir = t; } bool ParticleSystem::getRotationIsDir() const { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.rotationIsDir; } void ParticleSystem::setGravity(const Point& g) { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.gravity = g; } const Point& ParticleSystem::getGravity() { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.gravity; } void ParticleSystem::setSpeed(float speed) { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.speed = speed; } float ParticleSystem::getSpeed() const { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.speed; } void ParticleSystem::setSpeedVar(float speedVar) { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.speedVar = speedVar; } float ParticleSystem::getSpeedVar() const { CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.speedVar; } // ParticleSystem - Properties of Radius Mode void ParticleSystem::setStartRadius(float startRadius) { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.startRadius = startRadius; } float ParticleSystem::getStartRadius() const { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.startRadius; } void ParticleSystem::setStartRadiusVar(float startRadiusVar) { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.startRadiusVar = startRadiusVar; } float ParticleSystem::getStartRadiusVar() const { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.startRadiusVar; } void ParticleSystem::setEndRadius(float endRadius) { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.endRadius = endRadius; } float ParticleSystem::getEndRadius() const { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.endRadius; } void ParticleSystem::setEndRadiusVar(float endRadiusVar) { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.endRadiusVar = endRadiusVar; } float ParticleSystem::getEndRadiusVar() const { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.endRadiusVar; } void ParticleSystem::setRotatePerSecond(float degrees) { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.rotatePerSecond = degrees; } float ParticleSystem::getRotatePerSecond() const { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.rotatePerSecond; } void ParticleSystem::setRotatePerSecondVar(float degrees) { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.rotatePerSecondVar = degrees; } float ParticleSystem::getRotatePerSecondVar() const { CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.rotatePerSecondVar; } bool ParticleSystem::isActive() const { return _isActive; } int ParticleSystem::getTotalParticles() const { return _totalParticles; } void ParticleSystem::setTotalParticles(int var) { CCASSERT( var <= _allocatedParticles, "Particle: resizing particle array only supported for quads"); _totalParticles = var; } const BlendFunc& ParticleSystem::getBlendFunc() const { return _blendFunc; } void ParticleSystem::setBlendFunc(const BlendFunc &blendFunc) { if( _blendFunc.src != blendFunc.src || _blendFunc.dst != blendFunc.dst ) { _blendFunc = blendFunc; this->updateBlendFunc(); } } bool ParticleSystem::isAutoRemoveOnFinish() const { return _isAutoRemoveOnFinish; } void ParticleSystem::setAutoRemoveOnFinish(bool var) { _isAutoRemoveOnFinish = var; } // ParticleSystem - methods for batchNode rendering ParticleBatchNode* ParticleSystem::getBatchNode(void) const { return _batchNode; } void ParticleSystem::setBatchNode(ParticleBatchNode* batchNode) { if( _batchNode != batchNode ) { _batchNode = batchNode; // weak reference if( batchNode ) { //each particle needs a unique index for (int i = 0; i < _totalParticles; i++) { _particles[i].atlasIndex=i; } } } } //don't use a transform matrix, this is faster void ParticleSystem::setScale(float s) { _transformSystemDirty = true; Node::setScale(s); } void ParticleSystem::setRotation(float newRotation) { _transformSystemDirty = true; Node::setRotation(newRotation); } void ParticleSystem::setScaleX(float newScaleX) { _transformSystemDirty = true; Node::setScaleX(newScaleX); } void ParticleSystem::setScaleY(float newScaleY) { _transformSystemDirty = true; Node::setScaleY(newScaleY); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCParticleSystem.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPARTICLE_SYSTEM_H__ #define __CCPARTICLE_SYSTEM_H__ #include "CCProtocols.h" #include "CCNode.h" #include "CCValue.h" #include "CCString.h" NS_CC_BEGIN /** * @addtogroup particle_nodes * @{ */ class ParticleBatchNode; /** Structure that contains the values of each particle */ typedef struct sParticle { Point pos; Point startPos; Color4F color; Color4F deltaColor; float size; float deltaSize; float rotation; float deltaRotation; float timeToLive; unsigned int atlasIndex; //! Mode A: gravity, direction, radial accel, tangential accel struct { Point dir; float radialAccel; float tangentialAccel; } modeA; //! Mode B: radius mode struct { float angle; float degreesPerSecond; float radius; float deltaRadius; } modeB; }tParticle; //typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tParticle*, Point); class Texture2D; /** @brief Particle System base class. Attributes of a Particle System: - emission rate of the particles - Gravity Mode (Mode A): - gravity - direction - speed +- variance - tangential acceleration +- variance - radial acceleration +- variance - Radius Mode (Mode B): - startRadius +- variance - endRadius +- variance - rotate +- variance - Properties common to all modes: - life +- life variance - start spin +- variance - end spin +- variance - start size +- variance - end size +- variance - start color +- variance - end color +- variance - life +- variance - blending function - texture cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/). 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d, cocos2d uses a another approach, but the results are almost identical. cocos2d supports all the variables used by Particle Designer plus a bit more: - spinning particles (supported when using ParticleSystemQuad) - tangential acceleration (Gravity mode) - radial acceleration (Gravity mode) - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) It is possible to customize any of the above mentioned properties in runtime. Example: @code emitter.radialAccel = 15; emitter.startSpin = 0; @endcode */ class CC_DLL ParticleSystem : public Node, public TextureProtocol { public: enum class Mode { GRAVITY, RADIUS, }; /** @typedef PositionType possible types of particle positions */ enum class PositionType { /** Living particles are attached to the world and are unaffected by emitter repositioning. */ FREE, /** Living particles are attached to the world but will follow the emitter repositioning. Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite. */ RELATIVE, /** Living particles are attached to the emitter and are translated along with it. */ GROUPED, }; //* @enum enum { /** The Particle emitter lives forever */ DURATION_INFINITY = -1, /** The starting size of the particle is equal to the ending size */ START_SIZE_EQUAL_TO_END_SIZE = -1, /** The starting radius of the particle is equal to the ending radius */ START_RADIUS_EQUAL_TO_END_RADIUS = -1, }; /** creates an initializes a ParticleSystem from a plist file. This plist files can be created manually or with Particle Designer: http://particledesigner.71squared.com/ @since v2.0 */ static ParticleSystem * create(const std::string& plistFile); //! create a system with a fixed number of particles static ParticleSystem* createWithTotalParticles(int numberOfParticles); //! Add a particle to the emitter bool addParticle(); //! Initializes a particle void initParticle(tParticle* particle); //! stop emitting particles. Running particles will continue to run until they die void stopSystem(); //! Kill all living particles. void resetSystem(); //! whether or not the system is full bool isFull(); //! should be overridden by subclasses virtual void updateQuadWithParticle(tParticle* particle, const Point& newPosition); //! should be overridden by subclasses virtual void postStep(); virtual void updateWithNoTime(void); virtual bool isAutoRemoveOnFinish() const; virtual void setAutoRemoveOnFinish(bool var); // mode A virtual const Point& getGravity(); virtual void setGravity(const Point& g); virtual float getSpeed() const; virtual void setSpeed(float speed); virtual float getSpeedVar() const; virtual void setSpeedVar(float speed); virtual float getTangentialAccel() const; virtual void setTangentialAccel(float t); virtual float getTangentialAccelVar() const; virtual void setTangentialAccelVar(float t); virtual float getRadialAccel() const; virtual void setRadialAccel(float t); virtual float getRadialAccelVar() const; virtual void setRadialAccelVar(float t); virtual bool getRotationIsDir() const; virtual void setRotationIsDir(bool t); // mode B virtual float getStartRadius() const; virtual void setStartRadius(float startRadius); virtual float getStartRadiusVar() const; virtual void setStartRadiusVar(float startRadiusVar); virtual float getEndRadius() const; virtual void setEndRadius(float endRadius); virtual float getEndRadiusVar() const; virtual void setEndRadiusVar(float endRadiusVar); virtual float getRotatePerSecond() const; virtual void setRotatePerSecond(float degrees); virtual float getRotatePerSecondVar() const; virtual void setRotatePerSecondVar(float degrees); virtual void setScale(float s); virtual void setRotation(float newRotation); virtual void setScaleX(float newScaleX); virtual void setScaleY(float newScaleY); virtual bool isActive() const; virtual bool isBlendAdditive() const; virtual void setBlendAdditive(bool value); virtual ParticleBatchNode* getBatchNode() const; virtual void setBatchNode(ParticleBatchNode* batchNode); // index of system in batch node array inline int getAtlasIndex() const { return _atlasIndex; }; inline void setAtlasIndex(int index) { _atlasIndex = index; }; /** Quantity of particles that are being simulated at the moment */ inline unsigned int getParticleCount() const { return _particleCount; }; /** How many seconds the emitter will run. -1 means 'forever' */ inline float getDuration() const { return _duration; }; inline void setDuration(float duration) { _duration = duration; }; /** sourcePosition of the emitter */ inline const Point& getSourcePosition() const { return _sourcePosition; }; inline void setSourcePosition(const Point& pos) { _sourcePosition = pos; }; /** Position variance of the emitter */ inline const Point& getPosVar() const { return _posVar; }; inline void setPosVar(const Point& pos) { _posVar = pos; }; /** life, and life variation of each particle */ inline float getLife() const { return _life; }; inline void setLife(float life) { _life = life; }; /** life variance of each particle */ inline float getLifeVar() const { return _lifeVar; }; inline void setLifeVar(float lifeVar) { _lifeVar = lifeVar; }; /** angle and angle variation of each particle */ inline float getAngle() const { return _angle; }; inline void setAngle(float angle) { _angle = angle; }; /** angle variance of each particle */ inline float getAngleVar() const { return _angleVar; }; inline void setAngleVar(float angleVar) { _angleVar = angleVar; }; /** Switch between different kind of emitter modes: - kParticleModeGravity: uses gravity, speed, radial and tangential acceleration - kParticleModeRadius: uses radius movement + rotation */ inline Mode getEmitterMode() const { return _emitterMode; }; inline void setEmitterMode(Mode mode) { _emitterMode = mode; }; /** start size in pixels of each particle */ inline float getStartSize() const { return _startSize; }; inline void setStartSize(float startSize) { _startSize = startSize; }; /** size variance in pixels of each particle */ inline float getStartSizeVar() const { return _startSizeVar; }; inline void setStartSizeVar(float sizeVar) { _startSizeVar = sizeVar; }; /** end size in pixels of each particle */ inline float getEndSize() const { return _endSize; }; inline void setEndSize(float endSize) { _endSize = endSize; }; /** end size variance in pixels of each particle */ inline float getEndSizeVar() const { return _endSizeVar; }; inline void setEndSizeVar(float sizeVar) { _endSizeVar = sizeVar; }; /** start color of each particle */ inline const Color4F& getStartColor() const { return _startColor; }; inline void setStartColor(const Color4F& color) { _startColor = color; }; /** start color variance of each particle */ inline const Color4F& getStartColorVar() const { return _startColorVar; }; inline void setStartColorVar(const Color4F& color) { _startColorVar = color; }; /** end color and end color variation of each particle */ inline const Color4F& getEndColor() const { return _endColor; }; inline void setEndColor(const Color4F& color) { _endColor = color; }; /** end color variance of each particle */ inline const Color4F& getEndColorVar() const { return _endColorVar; }; inline void setEndColorVar(const Color4F& color) { _endColorVar = color; }; //* initial angle of each particle inline float getStartSpin() const { return _startSpin; }; inline void setStartSpin(float spin) { _startSpin = spin; }; //* initial angle of each particle inline float getStartSpinVar() const { return _startSpinVar; }; inline void setStartSpinVar(float pinVar) { _startSpinVar = pinVar; }; //* initial angle of each particle inline float getEndSpin() const { return _endSpin; }; inline void setEndSpin(float endSpin) { _endSpin = endSpin; }; //* initial angle of each particle inline float getEndSpinVar() const { return _endSpinVar; }; inline void setEndSpinVar(float endSpinVar) { _endSpinVar = endSpinVar; }; /** emission rate of the particles */ inline float getEmissionRate() const { return _emissionRate; }; inline void setEmissionRate(float rate) { _emissionRate = rate; }; /** maximum particles of the system */ virtual int getTotalParticles() const; virtual void setTotalParticles(int totalParticles); /** does the alpha value modify color */ inline void setOpacityModifyRGB(bool opacityModifyRGB) { _opacityModifyRGB = opacityModifyRGB; }; inline bool isOpacityModifyRGB() const { return _opacityModifyRGB; }; CC_DEPRECATED_ATTRIBUTE inline bool getOpacityModifyRGB() const { return isOpacityModifyRGB(); } /** particles movement type: Free or Grouped @since v0.8 */ inline PositionType getPositionType() const { return _positionType; }; inline void setPositionType(PositionType type) { _positionType = type; }; // Overrides virtual void update(float dt) override; virtual Texture2D* getTexture() const override; virtual void setTexture(Texture2D *texture) override; /** *@code *When this function bound into js or lua,the parameter will be changed *In js: var setBlendFunc(var src, var dst) *In lua: local setBlendFunc(local src, local dst) *@endcode */ virtual void setBlendFunc(const BlendFunc &blendFunc) override; /** * @js NA * @lua NA */ virtual const BlendFunc &getBlendFunc() const override; protected: /** * @js ctor */ ParticleSystem(); /** * @js NA * @lua NA */ virtual ~ParticleSystem(); /** initializes a ParticleSystem*/ bool init(); /** initializes a ParticleSystem from a plist file. This plist files can be created manually or with Particle Designer: http://particledesigner.71squared.com/ @since v0.99.3 */ bool initWithFile(const std::string& plistFile); /** initializes a QuadParticleSystem from a Dictionary. @since v0.99.3 */ bool initWithDictionary(ValueMap& dictionary); /** initializes a particle system from a NSDictionary and the path from where to load the png @since v2.1 */ bool initWithDictionary(ValueMap& dictionary, const std::string& dirname); //! Initializes a system with a fixed number of particles virtual bool initWithTotalParticles(int numberOfParticles); virtual void updateBlendFunc(); /** whether or not the particles are using blend additive. If enabled, the following blending function will be used. @code source blend function = GL_SRC_ALPHA; dest blend function = GL_ONE; @endcode */ bool _isBlendAdditive; /** whether or not the node will be auto-removed when it has no particles left. By default it is false. @since v0.8 */ bool _isAutoRemoveOnFinish; std::string _plistFile; //! time elapsed since the start of the system (in seconds) float _elapsed; // Different modes //! Mode A:Gravity + Tangential Accel + Radial Accel struct { /** Gravity value. Only available in 'Gravity' mode. */ Point gravity; /** speed of each particle. Only available in 'Gravity' mode. */ float speed; /** speed variance of each particle. Only available in 'Gravity' mode. */ float speedVar; /** tangential acceleration of each particle. Only available in 'Gravity' mode. */ float tangentialAccel; /** tangential acceleration variance of each particle. Only available in 'Gravity' mode. */ float tangentialAccelVar; /** radial acceleration of each particle. Only available in 'Gravity' mode. */ float radialAccel; /** radial acceleration variance of each particle. Only available in 'Gravity' mode. */ float radialAccelVar; /** set the rotation of each particle to its direction Only available in 'Gravity' mode. */ bool rotationIsDir; } modeA; //! Mode B: circular movement (gravity, radial accel and tangential accel don't are not used in this mode) struct { /** The starting radius of the particles. Only available in 'Radius' mode. */ float startRadius; /** The starting radius variance of the particles. Only available in 'Radius' mode. */ float startRadiusVar; /** The ending radius of the particles. Only available in 'Radius' mode. */ float endRadius; /** The ending radius variance of the particles. Only available in 'Radius' mode. */ float endRadiusVar; /** Number of degrees to rotate a particle around the source pos per second. Only available in 'Radius' mode. */ float rotatePerSecond; /** Variance in degrees for rotatePerSecond. Only available in 'Radius' mode. */ float rotatePerSecondVar; } modeB; //! Array of particles tParticle *_particles; //Emitter name std::string _configName; // color modulate // BOOL colorModulate; //! How many particles can be emitted per second float _emitCounter; //! particle idx int _particleIdx; // Optimization //CC_UPDATE_PARTICLE_IMP updateParticleImp; //SEL updateParticleSel; /** weak reference to the SpriteBatchNode that renders the Sprite */ ParticleBatchNode* _batchNode; // index of system in batch node array int _atlasIndex; //true if scaled or rotated bool _transformSystemDirty; // Number of allocated particles int _allocatedParticles; /** Is the emitter active */ bool _isActive; /** Quantity of particles that are being simulated at the moment */ int _particleCount; /** How many seconds the emitter will run. -1 means 'forever' */ float _duration; /** sourcePosition of the emitter */ Point _sourcePosition; /** Position variance of the emitter */ Point _posVar; /** life, and life variation of each particle */ float _life; /** life variance of each particle */ float _lifeVar; /** angle and angle variation of each particle */ float _angle; /** angle variance of each particle */ float _angleVar; /** Switch between different kind of emitter modes: - kParticleModeGravity: uses gravity, speed, radial and tangential acceleration - kParticleModeRadius: uses radius movement + rotation */ Mode _emitterMode; /** start size in pixels of each particle */ float _startSize; /** size variance in pixels of each particle */ float _startSizeVar; /** end size in pixels of each particle */ float _endSize; /** end size variance in pixels of each particle */ float _endSizeVar; /** start color of each particle */ Color4F _startColor; /** start color variance of each particle */ Color4F _startColorVar; /** end color and end color variation of each particle */ Color4F _endColor; /** end color variance of each particle */ Color4F _endColorVar; //* initial angle of each particle float _startSpin; //* initial angle of each particle float _startSpinVar; //* initial angle of each particle float _endSpin; //* initial angle of each particle float _endSpinVar; /** emission rate of the particles */ float _emissionRate; /** maximum particles of the system */ int _totalParticles; /** conforms to CocosNodeTexture protocol */ Texture2D* _texture; /** conforms to CocosNodeTexture protocol */ BlendFunc _blendFunc; /** does the alpha value modify color */ bool _opacityModifyRGB; /** does FlippedY variance of each particle */ int _yCoordFlipped; /** particles movement type: Free or Grouped @since v0.8 */ PositionType _positionType; private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleSystem); }; // end of particle_nodes group /// @} NS_CC_END #endif //__CCPARTICLE_SYSTEM_H__ ================================================ FILE: cocos2d/cocos/2d/CCParticleSystemQuad.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Leonardo Kasperavičius Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCGL.h" #include "CCParticleSystemQuad.h" #include "CCSpriteFrame.h" #include "CCDirector.h" #include "CCParticleBatchNode.h" #include "CCTextureAtlas.h" #include "CCShaderCache.h" #include "ccGLStateCache.h" #include "CCGLProgram.h" #include "TransformUtils.h" #include "CCEventType.h" #include "CCConfiguration.h" #include "renderer/CCRenderer.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCCustomCommand.h" // extern #include "kazmath/GL/matrix.h" #include "CCEventListenerCustom.h" #include "CCEventDispatcher.h" NS_CC_BEGIN //implementation ParticleSystemQuad // overriding the init method bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles) { // base initialization if( ParticleSystem::initWithTotalParticles(numberOfParticles) ) { // allocating data space if( ! this->allocMemory() ) { this->release(); return false; } initIndices(); if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); } else { setupVBO(); } setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); #if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(ParticleSystemQuad::listenBackToForeground, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); #endif return true; } return false; } ParticleSystemQuad::ParticleSystemQuad() :_quads(nullptr) ,_indices(nullptr) ,_VAOname(0) { memset(_buffersVBO, 0, sizeof(_buffersVBO)); } ParticleSystemQuad::~ParticleSystemQuad() { if (nullptr == _batchNode) { CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); glDeleteBuffers(2, &_buffersVBO[0]); if (Configuration::getInstance()->supportsShareableVAO()) { glDeleteVertexArrays(1, &_VAOname); GL::bindVAO(0); } } } // implementation ParticleSystemQuad ParticleSystemQuad * ParticleSystemQuad::create(const std::string& filename) { ParticleSystemQuad *ret = new ParticleSystemQuad(); if (ret && ret->initWithFile(filename)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return ret; } ParticleSystemQuad * ParticleSystemQuad::createWithTotalParticles(int numberOfParticles) { ParticleSystemQuad *ret = new ParticleSystemQuad(); if (ret && ret->initWithTotalParticles(numberOfParticles)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return ret; } // pointRect should be in Texture coordinates, not pixel coordinates void ParticleSystemQuad::initTexCoordsWithRect(const Rect& pointRect) { // convert to Tex coords Rect rect = Rect( pointRect.origin.x * CC_CONTENT_SCALE_FACTOR(), pointRect.origin.y * CC_CONTENT_SCALE_FACTOR(), pointRect.size.width * CC_CONTENT_SCALE_FACTOR(), pointRect.size.height * CC_CONTENT_SCALE_FACTOR()); GLfloat wide = (GLfloat) pointRect.size.width; GLfloat high = (GLfloat) pointRect.size.height; if (_texture) { wide = (GLfloat)_texture->getPixelsWide(); high = (GLfloat)_texture->getPixelsHigh(); } #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL GLfloat left = (rect.origin.x*2+1) / (wide*2); GLfloat bottom = (rect.origin.y*2+1) / (high*2); GLfloat right = left + (rect.size.width*2-2) / (wide*2); GLfloat top = bottom + (rect.size.height*2-2) / (high*2); #else GLfloat left = rect.origin.x / wide; GLfloat bottom = rect.origin.y / high; GLfloat right = left + rect.size.width / wide; GLfloat top = bottom + rect.size.height / high; #endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL // Important. Texture in cocos2d are inverted, so the Y component should be inverted CC_SWAP( top, bottom, float); V3F_C4B_T2F_Quad *quads = nullptr; unsigned int start = 0, end = 0; if (_batchNode) { quads = _batchNode->getTextureAtlas()->getQuads(); start = _atlasIndex; end = _atlasIndex + _totalParticles; } else { quads = _quads; start = 0; end = _totalParticles; } for(unsigned int i=start; igetName() != _texture->getName() ) { ParticleSystem::setTexture(texture); } this->initTexCoordsWithRect(rect); } void ParticleSystemQuad::setTexture(Texture2D* texture) { const Size& s = texture->getContentSize(); this->setTextureWithRect(texture, Rect(0, 0, s.width, s.height)); } void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame) { CCASSERT(spriteFrame->getOffsetInPixels().equals(Point::ZERO), "QuadParticle only supports SpriteFrames with no offsets"); // update texture before updating texture rect if ( !_texture || spriteFrame->getTexture()->getName() != _texture->getName()) { this->setTexture(spriteFrame->getTexture()); } } void ParticleSystemQuad::initIndices() { for(int i = 0; i < _totalParticles; ++i) { const unsigned int i6 = i*6; const unsigned int i4 = i*4; _indices[i6+0] = (GLushort) i4+0; _indices[i6+1] = (GLushort) i4+1; _indices[i6+2] = (GLushort) i4+2; _indices[i6+5] = (GLushort) i4+1; _indices[i6+4] = (GLushort) i4+2; _indices[i6+3] = (GLushort) i4+3; } } void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Point& newPosition) { V3F_C4B_T2F_Quad *quad; if (_batchNode) { V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads(); quad = &(batchQuads[_atlasIndex+particle->atlasIndex]); } else { quad = &(_quads[_particleIdx]); } Color4B color = (_opacityModifyRGB) ? Color4B( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255) : Color4B( particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255); quad->bl.colors = color; quad->br.colors = color; quad->tl.colors = color; quad->tr.colors = color; // vertices GLfloat size_2 = particle->size/2; if (particle->rotation) { GLfloat x1 = -size_2; GLfloat y1 = -size_2; GLfloat x2 = size_2; GLfloat y2 = size_2; GLfloat x = newPosition.x; GLfloat y = newPosition.y; GLfloat r = (GLfloat)-CC_DEGREES_TO_RADIANS(particle->rotation); GLfloat cr = cosf(r); GLfloat sr = sinf(r); GLfloat ax = x1 * cr - y1 * sr + x; GLfloat ay = x1 * sr + y1 * cr + y; GLfloat bx = x2 * cr - y1 * sr + x; GLfloat by = x2 * sr + y1 * cr + y; GLfloat cx = x2 * cr - y2 * sr + x; GLfloat cy = x2 * sr + y2 * cr + y; GLfloat dx = x1 * cr - y2 * sr + x; GLfloat dy = x1 * sr + y2 * cr + y; // bottom-left quad->bl.vertices.x = ax; quad->bl.vertices.y = ay; // bottom-right vertex: quad->br.vertices.x = bx; quad->br.vertices.y = by; // top-left vertex: quad->tl.vertices.x = dx; quad->tl.vertices.y = dy; // top-right vertex: quad->tr.vertices.x = cx; quad->tr.vertices.y = cy; } else { // bottom-left vertex: quad->bl.vertices.x = newPosition.x - size_2; quad->bl.vertices.y = newPosition.y - size_2; // bottom-right vertex: quad->br.vertices.x = newPosition.x + size_2; quad->br.vertices.y = newPosition.y - size_2; // top-left vertex: quad->tl.vertices.x = newPosition.x - size_2; quad->tl.vertices.y = newPosition.y + size_2; // top-right vertex: quad->tr.vertices.x = newPosition.x + size_2; quad->tr.vertices.y = newPosition.y + size_2; } } void ParticleSystemQuad::postStep() { glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); // Option 1: Sub Data glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(_quads[0])*_totalParticles, _quads); // Option 2: Data // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * particleCount, quads_, GL_DYNAMIC_DRAW); // Option 3: Orphaning + glMapBuffer // glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0])*_totalParticles, nullptr, GL_STREAM_DRAW); // void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); // memcpy(buf, _quads, sizeof(_quads[0])*_totalParticles); // glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); CHECK_GL_ERROR_DEBUG(); } // overriding draw method //void ParticleSystemQuad::draw() //{ // CCASSERT(!_batchNode,"draw should not be called when added to a particleBatchNode"); // // CC_NODE_DRAW_SETUP(); // // GL::bindTexture2D( _texture->getName() ); // GL::blendFunc( _blendFunc.src, _blendFunc.dst ); // // CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad"); // // if (Configuration::getInstance()->supportsShareableVAO()) // { // // // // Using VBO and VAO // // // GL::bindVAO(_VAOname); // //#if CC_REBIND_INDICES_BUFFER // glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); //#endif // // glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0); // //#if CC_REBIND_INDICES_BUFFER // glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); //#endif // } // else // { // // // // Using VBO without VAO // // // // #define kQuadSize sizeof(_quads[0].bl) // // GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); // // glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); // // vertices // glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // // colors // glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // // tex coords // glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); // // glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); // // glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0); // // glBindBuffer(GL_ARRAY_BUFFER, 0); // glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // } // // CC_INCREMENT_GL_DRAWS(1); // CHECK_GL_ERROR_DEBUG(); //} void ParticleSystemQuad::draw() { CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad"); //quad command if(_particleIdx > 0) { // //transform vertices // std::vector drawQuads(_particleIdx); // memcpy(&drawQuads[0], _quads, sizeof(V3F_C4B_T2F_Quad) * _particleIdx); // AffineTransform worldTM = getNodeToWorldTransform(); // for(int index = 0; index <_particleIdx; ++index) // { // V3F_C4B_T2F_Quad* quad = _quads + index; // // Point pt(0,0); // pt = PointApplyAffineTransform( Point(quad->bl.vertices.x, quad->bl.vertices.y), worldTM); // drawQuads[index].bl.vertices.x = pt.x; // drawQuads[index].bl.vertices.y = pt.y; // // pt = PointApplyAffineTransform( Point(quad->br.vertices.x, quad->br.vertices.y), worldTM); // drawQuads[index].br.vertices.x = pt.x; // drawQuads[index].br.vertices.y = pt.y; // // pt = PointApplyAffineTransform( Point(quad->tl.vertices.x, quad->tl.vertices.y), worldTM); // drawQuads[index].tl.vertices.x = pt.x; // drawQuads[index].tl.vertices.y = pt.y; // // pt = PointApplyAffineTransform( Point(quad->tr.vertices.x, quad->tr.vertices.y), worldTM); // drawQuads[index].tr.vertices.x = pt.x; // drawQuads[index].tr.vertices.y = pt.y; // // } auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); _quadCommand.init(_globalZOrder, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform); Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } } void ParticleSystemQuad::setTotalParticles(int tp) { // If we are setting the total number of particles to a number higher // than what is allocated, we need to allocate new arrays if( tp > _allocatedParticles ) { // Allocate new memory size_t particlesSize = tp * sizeof(tParticle); size_t quadsSize = sizeof(_quads[0]) * tp * 1; size_t indicesSize = sizeof(_indices[0]) * tp * 6 * 1; tParticle* particlesNew = (tParticle*)realloc(_particles, particlesSize); V3F_C4B_T2F_Quad* quadsNew = (V3F_C4B_T2F_Quad*)realloc(_quads, quadsSize); GLushort* indicesNew = (GLushort*)realloc(_indices, indicesSize); if (particlesNew && quadsNew && indicesNew) { // Assign pointers _particles = particlesNew; _quads = quadsNew; _indices = indicesNew; // Clear the memory // XXX: Bug? If the quads are cleared, then drawing doesn't work... WHY??? XXX memset(_particles, 0, particlesSize); memset(_quads, 0, quadsSize); memset(_indices, 0, indicesSize); _allocatedParticles = tp; } else { // Out of memory, failed to resize some array if (particlesNew) _particles = particlesNew; if (quadsNew) _quads = quadsNew; if (indicesNew) _indices = indicesNew; CCLOG("Particle system: out of memory"); return; } _totalParticles = tp; // Init particles if (_batchNode) { for (int i = 0; i < _totalParticles; i++) { _particles[i].atlasIndex=i; } } initIndices(); if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); } else { setupVBO(); } } else { _totalParticles = tp; } resetSystem(); } void ParticleSystemQuad::setupVBOandVAO() { // clean VAO glDeleteBuffers(2, &_buffersVBO[0]); glDeleteVertexArrays(1, &_VAOname); GL::bindVAO(0); glGenVertexArrays(1, &_VAOname); GL::bindVAO(_VAOname); #define kQuadSize sizeof(_quads[0].bl) glGenBuffers(2, &_buffersVBO[0]); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW); // vertices glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW); // Must unbind the VAO before changing the element buffer. GL::bindVAO(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); CHECK_GL_ERROR_DEBUG(); } void ParticleSystemQuad::setupVBO() { glDeleteBuffers(2, &_buffersVBO[0]); glGenBuffers(2, &_buffersVBO[0]); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); CHECK_GL_ERROR_DEBUG(); } void ParticleSystemQuad::listenBackToForeground(EventCustom* event) { if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); } else { setupVBO(); } } bool ParticleSystemQuad::allocMemory() { CCASSERT( ( !_quads && !_indices), "Memory already alloced"); CCASSERT( !_batchNode, "Memory should not be alloced when not using batchNode"); CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); _quads = (V3F_C4B_T2F_Quad*)malloc(_totalParticles * sizeof(V3F_C4B_T2F_Quad)); _indices = (GLushort*)malloc(_totalParticles * 6 * sizeof(GLushort)); if( !_quads || !_indices) { CCLOG("cocos2d: Particle system: not enough memory"); CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); return false; } memset(_quads, 0, _totalParticles * sizeof(V3F_C4B_T2F_Quad)); memset(_indices, 0, _totalParticles * 6 * sizeof(GLushort)); return true; } void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode) { if( _batchNode != batchNode ) { ParticleBatchNode* oldBatch = _batchNode; ParticleSystem::setBatchNode(batchNode); // NEW: is self render ? if( ! batchNode ) { allocMemory(); initIndices(); setTexture(oldBatch->getTexture()); if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); } else { setupVBO(); } } // OLD: was it self render ? cleanup else if( !oldBatch ) { // copy current state to batch V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads(); V3F_C4B_T2F_Quad *quad = &(batchQuads[_atlasIndex] ); memcpy( quad, _quads, _totalParticles * sizeof(_quads[0]) ); CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); glDeleteBuffers(2, &_buffersVBO[0]); memset(_buffersVBO, 0, sizeof(_buffersVBO)); if (Configuration::getInstance()->supportsShareableVAO()) { glDeleteVertexArrays(1, &_VAOname); GL::bindVAO(0); _VAOname = 0; } } } } ParticleSystemQuad * ParticleSystemQuad::create() { ParticleSystemQuad *particleSystemQuad = new ParticleSystemQuad(); if (particleSystemQuad && particleSystemQuad->init()) { particleSystemQuad->autorelease(); return particleSystemQuad; } CC_SAFE_DELETE(particleSystemQuad); return nullptr; } std::string ParticleSystemQuad::getDescription() const { return StringUtils::format("", _tag, _totalParticles); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCParticleSystemQuad.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Leonardo Kasperavičius Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_PARTICLE_SYSTEM_QUAD_H__ #define __CC_PARTICLE_SYSTEM_QUAD_H__ #include "CCParticleSystem.h" #include "renderer/CCQuadCommand.h" NS_CC_BEGIN class SpriteFrame; class EventCustom; /** * @addtogroup particle_nodes * @{ */ /** @brief ParticleSystemQuad is a subclass of ParticleSystem It includes all the features of ParticleSystem. Special features and Limitations: - Particle size can be any float number. - The system can be scaled - The particles can be rotated - It supports subrects - It supports batched rendering since 1.1 @since v0.8 */ class CC_DLL ParticleSystemQuad : public ParticleSystem { public: /** creates a Particle Emitter */ static ParticleSystemQuad * create(); /** creates a Particle Emitter with a number of particles */ static ParticleSystemQuad * createWithTotalParticles(int numberOfParticles); /** creates an initializes a ParticleSystemQuad from a plist file. This plist files can be created manually or with Particle Designer: */ static ParticleSystemQuad * create(const std::string& filename); /** Sets a new SpriteFrame as particle. WARNING: this method is experimental. Use setTextureWithRect instead. @since v0.99.4 */ void setDisplayFrame(SpriteFrame *spriteFrame); /** Sets a new texture with a rect. The rect is in Points. @since v0.99.4 * @js NA * @lua NA */ void setTextureWithRect(Texture2D *texture, const Rect& rect); /** listen the event that coming to foreground on Android * @js NA * @lua NA */ void listenBackToForeground(EventCustom* event); /** * @js NA * @lua NA */ virtual void setTexture(Texture2D* texture) override; /** * @js NA * @lua NA */ virtual void updateQuadWithParticle(tParticle* particle, const Point& newPosition) override; /** * @js NA * @lua NA */ virtual void postStep() override; /** * @js NA * @lua NA */ virtual void draw() override; /** * @js NA * @lua NA */ virtual void setBatchNode(ParticleBatchNode* batchNode) override; /** * @js NA * @lua NA */ virtual void setTotalParticles(int tp) override; virtual std::string getDescription() const override; protected: /** * @js ctor */ ParticleSystemQuad(); /** * @js NA * @lua NA */ virtual ~ParticleSystemQuad(); /** initializes the indices for the vertices*/ void initIndices(); /** initializes the texture with a rectangle measured Points */ void initTexCoordsWithRect(const Rect& rect); // Overrides /** * @js NA * @lua NA */ virtual bool initWithTotalParticles(int numberOfParticles) override; void setupVBOandVAO(); void setupVBO(); bool allocMemory(); V3F_C4B_T2F_Quad *_quads; // quads to be rendered GLushort *_indices; // indices GLuint _VAOname; GLuint _buffersVBO[2]; //0: vertex 1: indices kmMat4 _transformMatrix; QuadCommand _quadCommand; // quad command private: CC_DISALLOW_COPY_AND_ASSIGN(ParticleSystemQuad); }; // end of particle_nodes group /// @} NS_CC_END #endif //__CC_PARTICLE_SYSTEM_QUAD_H__ ================================================ FILE: cocos2d/cocos/2d/CCProfiling.cpp ================================================ /**************************************************************************** Copyright (c) 2010 Stuart Carnie Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCProfiling.h" #include using namespace std; NS_CC_BEGIN //#pragma mark - Profiling Categories /* set to false the categories that you don't want to profile */ bool kProfilerCategorySprite = false; bool kProfilerCategoryBatchSprite = false; bool kProfilerCategoryParticles = false; static Profiler* g_sSharedProfiler = nullptr; Profiler* Profiler::getInstance() { if (! g_sSharedProfiler) { g_sSharedProfiler = new Profiler(); g_sSharedProfiler->init(); } return g_sSharedProfiler; } // XXX: deprecated Profiler* Profiler::sharedProfiler(void) { return Profiler::getInstance(); } ProfilingTimer* Profiler::createAndAddTimerWithName(const char* timerName) { ProfilingTimer *t = new ProfilingTimer(); t->initWithName(timerName); _activeTimers.insert(timerName, t); t->release(); return t; } void Profiler::releaseTimer(const char* timerName) { _activeTimers.erase(timerName); } void Profiler::releaseAllTimers() { _activeTimers.clear(); } bool Profiler::init() { return true; } Profiler::~Profiler(void) { } void Profiler::displayTimers() { for (auto iter = _activeTimers.begin(); iter != _activeTimers.end(); ++iter) { ProfilingTimer* timer = iter->second; log("%s", timer->getDescription().c_str()); } } // implementation of ProfilingTimer ProfilingTimer::ProfilingTimer() : _averageTime1(0) , _averageTime2(0) , minTime(100000000) , maxTime(0) , totalTime(0) , numberOfCalls(0) { } bool ProfilingTimer::initWithName(const char* timerName) { _nameStr = timerName; return true; } ProfilingTimer::~ProfilingTimer(void) { } std::string ProfilingTimer::getDescription() const { static char s_desciption[512] = {0}; sprintf(s_desciption, "%s ::\tavg1: %ldµ,\tavg2: %ldµ,\tmin: %ldµ,\tmax: %ldµ,\ttotal: %.2fs,\tnr calls: %ld", _nameStr.c_str(), _averageTime1, _averageTime2, minTime, maxTime, totalTime/1000000., numberOfCalls); return s_desciption; } void ProfilingTimer::reset() { numberOfCalls = 0; _averageTime1 = 0; _averageTime2 = 0; totalTime = 0; minTime = 100000000; maxTime = 0; _startTime = chrono::high_resolution_clock::now(); } void ProfilingBeginTimingBlock(const char *timerName) { Profiler* p = Profiler::getInstance(); ProfilingTimer* timer = p->_activeTimers.at(timerName); if( ! timer ) { timer = p->createAndAddTimerWithName(timerName); } timer->numberOfCalls++; // should be the last instruction in order to be more reliable timer->_startTime = chrono::high_resolution_clock::now(); } void ProfilingEndTimingBlock(const char *timerName) { // should be the 1st instruction in order to be more reliable auto now = chrono::high_resolution_clock::now(); Profiler* p = Profiler::getInstance(); ProfilingTimer* timer = p->_activeTimers.at(timerName); CCASSERT(timer, "CCProfilingTimer not found"); long duration = static_cast(chrono::duration_cast(now - timer->_startTime).count()); timer->totalTime += duration; timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f; timer->_averageTime2 = timer->totalTime / timer->numberOfCalls; timer->maxTime = MAX( timer->maxTime, duration); timer->minTime = MIN( timer->minTime, duration); } void ProfilingResetTimingBlock(const char *timerName) { Profiler* p = Profiler::getInstance(); ProfilingTimer *timer = p->_activeTimers.at(timerName); CCASSERT(timer, "CCProfilingTimer not found"); timer->reset(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCProfiling.h ================================================ /**************************************************************************** Copyright (c) 2010 Stuart Carnie Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SUPPORT_CCPROFILING_H__ #define __SUPPORT_CCPROFILING_H__ #include #include #include "ccConfig.h" #include "CCObject.h" #include "CCMap.h" NS_CC_BEGIN /** * @addtogroup global * @{ */ class ProfilingTimer; /** Profiler cocos2d builtin profiler. To use it, enable set the CC_ENABLE_PROFILERS=1 in the ccConfig.h file */ class CC_DLL Profiler : public Object { public: /** * @js NA * @lua NA */ ~Profiler(void); /** display the timers * @js NA * @lua NA */ void displayTimers(void); /** * @js NA * @lua NA */ bool init(void); public: /** returns the singleton * @js NA * @lua NA */ static Profiler* getInstance(void); /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static Profiler* sharedProfiler(void); /** Creates and adds a new timer * @js NA * @lua NA */ ProfilingTimer* createAndAddTimerWithName(const char* timerName); /** releases a timer * @js NA * @lua NA */ void releaseTimer(const char* timerName); /** releases all timers * @js NA * @lua NA */ void releaseAllTimers(); Map _activeTimers; }; class ProfilingTimer : public Object { public: /** * @js NA * @lua NA */ ProfilingTimer(); /** * @js NA * @lua NA */ ~ProfilingTimer(void); /** * @js NA * @lua NA */ bool initWithName(const char* timerName); /** * @js NA * @lua NA */ virtual std::string getDescription() const; /** * @js NA * @lua NA */ inline const std::chrono::high_resolution_clock::time_point& getStartTime(void) { return _startTime; }; /** resets the timer properties * @js NA * @lua NA */ void reset(); std::string _nameStr; std::chrono::high_resolution_clock::time_point _startTime; long _averageTime1; long _averageTime2; long minTime; long maxTime; long totalTime; long numberOfCalls; }; extern void ProfilingBeginTimingBlock(const char *timerName); extern void ProfilingEndTimingBlock(const char *timerName); extern void ProfilingResetTimingBlock(const char *timerName); /* * cocos2d profiling categories * used to enable / disable profilers with granularity */ extern bool kProfilerCategorySprite; extern bool kProfilerCategoryBatchSprite; extern bool kProfilerCategoryParticles; // end of global group /// @} NS_CC_END #endif // __SUPPORT_CCPROFILING_H__ ================================================ FILE: cocos2d/cocos/2d/CCProgressTimer.cpp ================================================ /**************************************************************************** Copyright (c) 2010 Lam Pham Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCProgressTimer.h" #include "ccMacros.h" #include "CCTextureCache.h" #include "CCGLProgram.h" #include "CCShaderCache.h" #include "ccGLStateCache.h" #include "CCDirector.h" #include "TransformUtils.h" #include "CCDrawingPrimitives.h" #include "renderer/CCRenderer.h" #include "renderer/CCCustomCommand.h" // extern #include "kazmath/GL/matrix.h" #include NS_CC_BEGIN #define kProgressTextureCoordsCount 4 // kProgressTextureCoords holds points {0,1} {0,0} {1,0} {1,1} we can represent it as bits const char kProgressTextureCoords = 0x4b; ProgressTimer::ProgressTimer() :_type(Type::RADIAL) ,_midpoint(0,0) ,_barChangeRate(0,0) ,_percentage(0.0f) ,_sprite(nullptr) ,_vertexDataCount(0) ,_vertexData(nullptr) ,_reverseDirection(false) {} ProgressTimer* ProgressTimer::create(Sprite* sp) { ProgressTimer *progressTimer = new ProgressTimer(); if (progressTimer->initWithSprite(sp)) { progressTimer->autorelease(); } else { delete progressTimer; progressTimer = nullptr; } return progressTimer; } bool ProgressTimer::initWithSprite(Sprite* sp) { setPercentage(0.0f); _vertexData = nullptr; _vertexDataCount = 0; setAnchorPoint(Point(0.5f,0.5f)); _type = Type::RADIAL; _reverseDirection = false; setMidpoint(Point(0.5f, 0.5f)); setBarChangeRate(Point(1,1)); setSprite(sp); // shader program setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } ProgressTimer::~ProgressTimer(void) { CC_SAFE_FREE(_vertexData); CC_SAFE_RELEASE(_sprite); } void ProgressTimer::setPercentage(float percentage) { if (_percentage != percentage) { _percentage = clampf(percentage, 0, 100); updateProgress(); } } void ProgressTimer::setSprite(Sprite *sprite) { if (_sprite != sprite) { CC_SAFE_RETAIN(sprite); CC_SAFE_RELEASE(_sprite); _sprite = sprite; setContentSize(_sprite->getContentSize()); // Every time we set a new sprite, we free the current vertex data if (_vertexData) { CC_SAFE_FREE(_vertexData); _vertexDataCount = 0; } } } void ProgressTimer::setType(Type type) { if (type != _type) { // release all previous information if (_vertexData) { CC_SAFE_FREE(_vertexData); _vertexData = nullptr; _vertexDataCount = 0; } _type = type; } } void ProgressTimer::setReverseProgress(bool reverse) { if( _reverseDirection != reverse ) { _reverseDirection = reverse; // release all previous information CC_SAFE_FREE(_vertexData); _vertexDataCount = 0; } } // Interval /// // @returns the vertex position from the texture coordinate /// Tex2F ProgressTimer::textureCoordFromAlphaPoint(Point alpha) { Tex2F ret(0.0f, 0.0f); if (!_sprite) { return ret; } V3F_C4B_T2F_Quad quad = _sprite->getQuad(); Point min = Point(quad.bl.texCoords.u,quad.bl.texCoords.v); Point max = Point(quad.tr.texCoords.u,quad.tr.texCoords.v); // Fix bug #1303 so that progress timer handles sprite frame texture rotation if (_sprite->isTextureRectRotated()) { CC_SWAP(alpha.x, alpha.y, float); } return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y); } Vertex2F ProgressTimer::vertexFromAlphaPoint(Point alpha) { Vertex2F ret(0.0f, 0.0f); if (!_sprite) { return ret; } V3F_C4B_T2F_Quad quad = _sprite->getQuad(); Point min = Point(quad.bl.vertices.x,quad.bl.vertices.y); Point max = Point(quad.tr.vertices.x,quad.tr.vertices.y); ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x; ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y; return ret; } void ProgressTimer::updateColor(void) { if (!_sprite) { return; } if (_vertexData) { Color4B sc = _sprite->getQuad().tl.colors; for (int i = 0; i < _vertexDataCount; ++i) { _vertexData[i].colors = sc; } } } void ProgressTimer::updateProgress(void) { switch (_type) { case Type::RADIAL: updateRadial(); break; case Type::BAR: updateBar(); break; default: break; } } void ProgressTimer::setAnchorPoint(const Point& anchorPoint) { Node::setAnchorPoint(anchorPoint); } Point ProgressTimer::getMidpoint() const { return _midpoint; } void ProgressTimer::setColor(const Color3B &color) { _sprite->setColor(color); updateColor(); } const Color3B& ProgressTimer::getColor() const { return _sprite->getColor(); } void ProgressTimer::setOpacity(GLubyte opacity) { _sprite->setOpacity(opacity); updateColor(); } GLubyte ProgressTimer::getOpacity() const { return _sprite->getOpacity(); } void ProgressTimer::setMidpoint(const Point& midPoint) { _midpoint = midPoint.getClampPoint(Point::ZERO, Point(1, 1)); } /// // Update does the work of mapping the texture onto the triangles // It now doesn't occur the cost of free/alloc data every update cycle. // It also only changes the percentage point but no other points if they have not // been modified. // // It now deals with flipped texture. If you run into this problem, just use the // sprite property and enable the methods flipX, flipY. /// void ProgressTimer::updateRadial(void) { if (!_sprite) { return; } float alpha = _percentage / 100.f; float angle = 2.f*((float)M_PI) * ( _reverseDirection ? alpha : 1.0f - alpha); // We find the vector to do a hit detection based on the percentage // We know the first vector is the one @ 12 o'clock (top,mid) so we rotate // from that by the progress angle around the _midpoint pivot Point topMid = Point(_midpoint.x, 1.f); Point percentagePt = topMid.rotateByAngle(_midpoint, angle); int index = 0; Point hit = Point::ZERO; if (alpha == 0.f) { // More efficient since we don't always need to check intersection // If the alpha is zero then the hit point is top mid and the index is 0. hit = topMid; index = 0; } else if (alpha == 1.f) { // More efficient since we don't always need to check intersection // If the alpha is one then the hit point is top mid and the index is 4. hit = topMid; index = 4; } else { // We run a for loop checking the edges of the texture to find the // intersection point // We loop through five points since the top is split in half float min_t = FLT_MAX; for (int i = 0; i <= kProgressTextureCoordsCount; ++i) { int pIndex = (i + (kProgressTextureCoordsCount - 1))%kProgressTextureCoordsCount; Point edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount); Point edgePtB = boundaryTexCoord(pIndex); // Remember that the top edge is split in half for the 12 o'clock position // Let's deal with that here by finding the correct endpoints if(i == 0){ edgePtB = edgePtA.lerp(edgePtB, 1-_midpoint.x); } else if(i == 4){ edgePtA = edgePtA.lerp(edgePtB, 1-_midpoint.x); } // s and t are returned by ccpLineIntersect float s = 0, t = 0; if(Point::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t)) { // Since our hit test is on rays we have to deal with the top edge // being in split in half so we have to test as a segment if ((i == 0 || i == 4)) { // s represents the point between edgePtA--edgePtB if (!(0.f <= s && s <= 1.f)) { continue; } } // As long as our t isn't negative we are at least finding a // correct hitpoint from _midpoint to percentagePt. if (t >= 0.f) { // Because the percentage line and all the texture edges are // rays we should only account for the shortest intersection if (t < min_t) { min_t = t; index = i; } } } } // Now that we have the minimum magnitude we can use that to find our intersection hit = _midpoint+ ((percentagePt - _midpoint) * min_t); } // The size of the vertex data is the index from the hitpoint // the 3 is for the _midpoint, 12 o'clock point and hitpoint position. bool sameIndexCount = true; if(_vertexDataCount != index + 3){ sameIndexCount = false; CC_SAFE_FREE(_vertexData); _vertexDataCount = 0; } if(!_vertexData) { _vertexDataCount = index + 3; _vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F)); CCASSERT( _vertexData, "CCProgressTimer. Not enough memory"); } updateColor(); if (!sameIndexCount) { // First we populate the array with the _midpoint, then all // vertices/texcoords/colors of the 12 'o clock start and edges and the hitpoint _vertexData[0].texCoords = textureCoordFromAlphaPoint(_midpoint); _vertexData[0].vertices = vertexFromAlphaPoint(_midpoint); _vertexData[1].texCoords = textureCoordFromAlphaPoint(topMid); _vertexData[1].vertices = vertexFromAlphaPoint(topMid); for(int i = 0; i < index; ++i){ Point alphaPoint = boundaryTexCoord(i); _vertexData[i+2].texCoords = textureCoordFromAlphaPoint(alphaPoint); _vertexData[i+2].vertices = vertexFromAlphaPoint(alphaPoint); } } // hitpoint will go last _vertexData[_vertexDataCount - 1].texCoords = textureCoordFromAlphaPoint(hit); _vertexData[_vertexDataCount - 1].vertices = vertexFromAlphaPoint(hit); } /// // Update does the work of mapping the texture onto the triangles for the bar // It now doesn't occur the cost of free/alloc data every update cycle. // It also only changes the percentage point but no other points if they have not // been modified. // // It now deals with flipped texture. If you run into this problem, just use the // sprite property and enable the methods flipX, flipY. /// void ProgressTimer::updateBar(void) { if (!_sprite) { return; } float alpha = _percentage / 100.0f; Point alphaOffset = Point(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f; Point min = _midpoint - alphaOffset; Point max = _midpoint + alphaOffset; if (min.x < 0.f) { max.x += -min.x; min.x = 0.f; } if (max.x > 1.f) { min.x -= max.x - 1.f; max.x = 1.f; } if (min.y < 0.f) { max.y += -min.y; min.y = 0.f; } if (max.y > 1.f) { min.y -= max.y - 1.f; max.y = 1.f; } if (!_reverseDirection) { if(!_vertexData) { _vertexDataCount = 4; _vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F)); CCASSERT( _vertexData, "CCProgressTimer. Not enough memory"); } // TOPLEFT _vertexData[0].texCoords = textureCoordFromAlphaPoint(Point(min.x,max.y)); _vertexData[0].vertices = vertexFromAlphaPoint(Point(min.x,max.y)); // BOTLEFT _vertexData[1].texCoords = textureCoordFromAlphaPoint(Point(min.x,min.y)); _vertexData[1].vertices = vertexFromAlphaPoint(Point(min.x,min.y)); // TOPRIGHT _vertexData[2].texCoords = textureCoordFromAlphaPoint(Point(max.x,max.y)); _vertexData[2].vertices = vertexFromAlphaPoint(Point(max.x,max.y)); // BOTRIGHT _vertexData[3].texCoords = textureCoordFromAlphaPoint(Point(max.x,min.y)); _vertexData[3].vertices = vertexFromAlphaPoint(Point(max.x,min.y)); } else { if(!_vertexData) { _vertexDataCount = 8; _vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F)); CCASSERT( _vertexData, "CCProgressTimer. Not enough memory"); // TOPLEFT 1 _vertexData[0].texCoords = textureCoordFromAlphaPoint(Point(0,1)); _vertexData[0].vertices = vertexFromAlphaPoint(Point(0,1)); // BOTLEFT 1 _vertexData[1].texCoords = textureCoordFromAlphaPoint(Point(0,0)); _vertexData[1].vertices = vertexFromAlphaPoint(Point(0,0)); // TOPRIGHT 2 _vertexData[6].texCoords = textureCoordFromAlphaPoint(Point(1,1)); _vertexData[6].vertices = vertexFromAlphaPoint(Point(1,1)); // BOTRIGHT 2 _vertexData[7].texCoords = textureCoordFromAlphaPoint(Point(1,0)); _vertexData[7].vertices = vertexFromAlphaPoint(Point(1,0)); } // TOPRIGHT 1 _vertexData[2].texCoords = textureCoordFromAlphaPoint(Point(min.x,max.y)); _vertexData[2].vertices = vertexFromAlphaPoint(Point(min.x,max.y)); // BOTRIGHT 1 _vertexData[3].texCoords = textureCoordFromAlphaPoint(Point(min.x,min.y)); _vertexData[3].vertices = vertexFromAlphaPoint(Point(min.x,min.y)); // TOPLEFT 2 _vertexData[4].texCoords = textureCoordFromAlphaPoint(Point(max.x,max.y)); _vertexData[4].vertices = vertexFromAlphaPoint(Point(max.x,max.y)); // BOTLEFT 2 _vertexData[5].texCoords = textureCoordFromAlphaPoint(Point(max.x,min.y)); _vertexData[5].vertices = vertexFromAlphaPoint(Point(max.x,min.y)); } updateColor(); } Point ProgressTimer::boundaryTexCoord(char index) { if (index < kProgressTextureCoordsCount) { if (_reverseDirection) { return Point((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1); } else { return Point((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1); } } return Point::ZERO; } void ProgressTimer::onDraw() { CC_NODE_DRAW_SETUP(); GL::blendFunc( _sprite->getBlendFunc().src, _sprite->getBlendFunc().dst ); GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); GL::bindTexture2D( _sprite->getTexture()->getName() ); #ifdef EMSCRIPTEN setGLBufferData((void*) _vertexData, (_vertexDataCount * sizeof(V2F_C4B_T2F)), 0); int offset = 0; glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); offset += sizeof(Vertex2F); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); offset += sizeof(Color4B); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); #else glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors); #endif // EMSCRIPTEN if(_type == Type::RADIAL) { glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount); } else if (_type == Type::BAR) { if (!_reverseDirection) { glDrawArrays(GL_TRIANGLE_STRIP, 0, _vertexDataCount); } else { glDrawArrays(GL_TRIANGLE_STRIP, 0, _vertexDataCount/2); glDrawArrays(GL_TRIANGLE_STRIP, 4, _vertexDataCount/2); // 2 draw calls CC_INCREMENT_GL_DRAWS(1); } } CC_INCREMENT_GL_DRAWS(1); } void ProgressTimer::draw() { if( ! _vertexData || ! _sprite) return; _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCProgressTimer.h ================================================ /**************************************************************************** Copyright (c) 2010 Lam Pham Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __MISC_NODE_CCPROGRESS_TIMER_H__ #define __MISC_NODE_CCPROGRESS_TIMER_H__ #include "CCSprite.h" #include "renderer/CCCustomCommand.h" #ifdef EMSCRIPTEN #include "CCGLBufferedNode.h" #endif // EMSCRIPTEN NS_CC_BEGIN /** * @addtogroup misc_nodes * @{ */ /** @brief ProgressTimer is a subclass of Node. It renders the inner sprite according to the percentage. The progress can be Radial, Horizontal or vertical. @since v0.99.1 */ class CC_DLL ProgressTimer : public Node #ifdef EMSCRIPTEN , public GLBufferedNode #endif // EMSCRIPTEN { public: /** Types of progress @since v0.99.1 */ enum class Type { /// Radial Counter-Clockwise RADIAL, /// Bar BAR, }; /** Creates a progress timer with the sprite as the shape the timer goes through */ static ProgressTimer* create(Sprite* sp); /** Change the percentage to change progress. */ inline Type getType() const { return _type; } /** Percentages are from 0 to 100 */ inline float getPercentage() const {return _percentage; } /** The image to show the progress percentage, retain */ inline Sprite* getSprite() const { return _sprite; } void setPercentage(float percentage); void setSprite(Sprite *sprite); void setType(Type type); /** * @js setReverseDirection * @lua setReverseDirection */ void setReverseProgress(bool reverse); inline bool isReverseDirection() { return _reverseDirection; }; inline void setReverseDirection(bool value) { _reverseDirection = value; }; /** * Midpoint is used to modify the progress start position. * If you're using radials type then the midpoint changes the center point * If you're using bar type the the midpoint changes the bar growth * it expands from the center but clamps to the sprites edge so: * you want a left to right then set the midpoint all the way to Point(0,y) * you want a right to left then set the midpoint all the way to Point(1,y) * you want a bottom to top then set the midpoint all the way to Point(x,0) * you want a top to bottom then set the midpoint all the way to Point(x,1) */ void setMidpoint(const Point& point); /** Returns the Midpoint */ Point getMidpoint() const; /** * This allows the bar type to move the component at a specific rate * Set the component to 0 to make sure it stays at 100%. * For example you want a left to right bar but not have the height stay 100% * Set the rate to be Point(0,1); and set the midpoint to = Point(0,.5f); */ inline void setBarChangeRate(const Point& barChangeRate ) { _barChangeRate = barChangeRate; } /** Returns the BarChangeRate */ inline Point getBarChangeRate() const { return _barChangeRate; } // Overrides virtual void draw() override; virtual void setAnchorPoint(const Point& anchorPoint) override; virtual void setColor(const Color3B &color) override; virtual const Color3B& getColor() const override; virtual void setOpacity(GLubyte opacity) override; virtual GLubyte getOpacity() const override; protected: /** * @js ctor */ ProgressTimer(); /** * @js NA * @lua NA */ virtual ~ProgressTimer(); /** Initializes a progress timer with the sprite as the shape the timer goes through */ bool initWithSprite(Sprite* sp); void onDraw(); Tex2F textureCoordFromAlphaPoint(Point alpha); Vertex2F vertexFromAlphaPoint(Point alpha); void updateProgress(void); void updateBar(void); void updateRadial(void); virtual void updateColor(void) override; Point boundaryTexCoord(char index); Type _type; Point _midpoint; Point _barChangeRate; float _percentage; Sprite *_sprite; int _vertexDataCount; V2F_C4B_T2F *_vertexData; CustomCommand _customCommand; bool _reverseDirection; private: CC_DISALLOW_COPY_AND_ASSIGN(ProgressTimer); }; // end of misc_nodes group /// @} NS_CC_END #endif //__MISC_NODE_CCPROGRESS_TIMER_H__ ================================================ FILE: cocos2d/cocos/2d/CCProtocols.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPROTOCOLS_H__ #define __CCPROTOCOLS_H__ #include "ccTypes.h" #include "CCTexture2D.h" #include NS_CC_BEGIN /** * RGBA protocol that affects Node's color and opacity */ class CC_DLL __RGBAProtocol { public: virtual ~__RGBAProtocol() {} /** * Changes the color with R,G,B bytes * * @param color Example: Color3B(255,100,0) means R=255, G=100, B=0 * @js NA * @lua NA */ virtual void setColor(const Color3B& color) = 0; /** * Returns color that is currently used. * * @return The Color3B contains R,G,B bytes. * @js NA * @lua NA */ virtual const Color3B& getColor() const = 0; /** * Returns the displayed color. * * @return The Color3B contains R,G,B bytes. * @js NA * @lua NA */ virtual const Color3B& getDisplayedColor() const = 0; /** * Returns the displayed opacity. * * @return The opacity of sprite, from 0 ~ 255 * @js NA * @lua NA */ virtual GLubyte getDisplayedOpacity() const = 0; /** * Returns the opacity. * * The opacity which indicates how transparent or opaque this node is. * 0 indicates fully transparent and 255 is fully opaque. * * @return The opacity of sprite, from 0 ~ 255 * @js NA * @lua NA */ virtual GLubyte getOpacity() const = 0; /** * Changes the opacity. * * @param opacity Goes from 0 to 255, where 255 means fully opaque and 0 means fully transparent. * @js NA * @lua NA */ virtual void setOpacity(GLubyte opacity) = 0; // optional /** * Changes the OpacityModifyRGB property. * If thie property is set to true, then the rendered color will be affected by opacity. * Normally, r = r * opacity/255, g = g * opacity/255, b = b * opacity/255. * * @param value If true, then the opacity will be applied as: glColor(R,G,B,opacity); * If false, then the opacity will be applied as: glColor(opacity, opacity, opacity, opacity); * @js NA * @lua NA */ virtual void setOpacityModifyRGB(bool value) = 0; /** * Returns whether or not the opacity will be applied using glColor(R,G,B,opacity) * or glColor(opacity, opacity, opacity, opacity) * * @return Returns opacity modify flag. * @js NA * @lua NA */ virtual bool isOpacityModifyRGB() const = 0; /** * whether or not color should be propagated to its children. * @js NA * @lua NA */ virtual bool isCascadeColorEnabled() const = 0; /** * @js NA * @lua NA */ virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0; /** * recursive method that updates display color * @js NA * @lua NA */ virtual void updateDisplayedColor(const Color3B& color) = 0; /** * whether or not opacity should be propagated to its children. * @js NA * @lua NA */ virtual bool isCascadeOpacityEnabled() const = 0; /** * @js NA * @lua NA */ virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0; /** * recursive method that updates the displayed opacity. * @js NA * @lua NA */ virtual void updateDisplayedOpacity(GLubyte opacity) = 0; }; /** * Specify the blending function according glBlendFunc * Please refer to glBlendFunc in OpenGL ES Manual * http://www.khronos.org/opengles/sdk/docs/man/xhtml/glBlendFunc.xml for more details. */ class CC_DLL BlendProtocol { public: virtual ~BlendProtocol() {} /** * Sets the source blending function. * * @param blendFunc A structure with source and destination factor to specify pixel arithmetic, * e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}. * @js NA * @lua NA */ virtual void setBlendFunc(const BlendFunc &blendFunc) = 0; /** * Returns the blending function that is currently being used. * * @return A BlendFunc structure with source and destination factor which specified pixel arithmetic. * @js NA * @lua NA */ virtual const BlendFunc &getBlendFunc() const = 0; }; /** * Node objects that uses a Texture2D to render the images. * The texture can have a blending function. * If the texture has alpha premultiplied the default blending function is: * src=GL_ONE dst= GL_ONE_MINUS_SRC_ALPHA * else * src=GL_SRC_ALPHA dst= GL_ONE_MINUS_SRC_ALPHA * But you can change the blending function at any time. */ class CC_DLL TextureProtocol : public BlendProtocol { public: virtual ~TextureProtocol() {} /** * Returns the currently used texture * * @return The texture that is currenlty being used. * @js NA * @lua NA */ virtual Texture2D* getTexture() const = 0; /** * Sets a new texuture. It will be retained. * * @param texture A valid Texture2D object, which will be applied to this sprite object. * @js NA * @lua NA */ virtual void setTexture(Texture2D *texture) = 0; }; /** * Common interface for Labels */ class CC_DLL LabelProtocol { public: virtual ~LabelProtocol() {} /** * Sets a new label using a string * * @param label A null terminated string * @js NA * @lua NA */ virtual void setString(const std::string &label) = 0; /** * Returns the string that is currently being used in this label * * @return The string that is currently being used in this label * @js NA * @lua NA */ virtual const std::string& getString() const = 0; }; /** * OpenGL projection protocol */ class CC_DLL DirectorDelegate { public: virtual ~DirectorDelegate() {} /** * Will be called by Director when the projection is updated, and "custom" projection is used * @js NA * @lua NA */ virtual void updateProjection() = 0; }; NS_CC_END #endif // __CCPROTOCOLS_H__ ================================================ FILE: cocos2d/cocos/2d/CCRenderTexture.cpp ================================================ /**************************************************************************** Copyright (c) 2009 Jason Booth Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCConfiguration.h" #include "CCRenderTexture.h" #include "CCDirector.h" #include "platform/CCImage.h" #include "CCGLProgram.h" #include "ccGLStateCache.h" #include "CCConfiguration.h" #include "ccUtils.h" #include "CCTextureCache.h" #include "platform/CCFileUtils.h" #include "CCGL.h" #include "CCEventType.h" #include "CCGrid.h" #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCCustomCommand.h" // extern #include "kazmath/GL/matrix.h" #include "CCEventListenerCustom.h" #include "CCEventDispatcher.h" NS_CC_BEGIN // implementation RenderTexture RenderTexture::RenderTexture() : _FBO(0) , _depthRenderBufffer(0) , _oldFBO(0) , _texture(0) , _textureCopy(0) , _UITextureImage(nullptr) , _pixelFormat(Texture2D::PixelFormat::RGBA8888) , _clearFlags(0) , _clearColor(Color4F(0,0,0,0)) , _clearDepth(0.0f) , _clearStencil(0) , _autoDraw(false) , _sprite(nullptr) { #if CC_ENABLE_CACHE_TEXTURE_DATA // Listen this event to save render texture before come to background. // Then it can be restored after coming to foreground on Android. auto toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(RenderTexture::listenToBackground, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(toBackgroundListener, this); auto toForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(RenderTexture::listenToForeground, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(toForegroundListener, this); #endif } RenderTexture::~RenderTexture() { CC_SAFE_RELEASE(_sprite); CC_SAFE_RELEASE(_textureCopy); glDeleteFramebuffers(1, &_FBO); if (_depthRenderBufffer) { glDeleteRenderbuffers(1, &_depthRenderBufffer); } CC_SAFE_DELETE(_UITextureImage); } void RenderTexture::listenToBackground(EventCustom *event) { #if CC_ENABLE_CACHE_TEXTURE_DATA CC_SAFE_DELETE(_UITextureImage); // to get the rendered texture data _UITextureImage = newImage(false); if (_UITextureImage) { const Size& s = _texture->getContentSizeInPixels(); VolatileTextureMgr::addDataTexture(_texture, _UITextureImage->getData(), s.width * s.height * 4, Texture2D::PixelFormat::RGBA8888, s); if ( _textureCopy ) { VolatileTextureMgr::addDataTexture(_textureCopy, _UITextureImage->getData(), s.width * s.height * 4, Texture2D::PixelFormat::RGBA8888, s); } } else { CCLOG("Cache rendertexture failed!"); } glDeleteFramebuffers(1, &_FBO); _FBO = 0; #endif } void RenderTexture::listenToForeground(EventCustom *event) { #if CC_ENABLE_CACHE_TEXTURE_DATA // -- regenerate frame buffer object and attach the texture glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); glGenFramebuffers(1, &_FBO); glBindFramebuffer(GL_FRAMEBUFFER, _FBO); _texture->setAliasTexParameters(); if ( _textureCopy ) { _textureCopy->setAliasTexParameters(); } glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0); glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); #endif } RenderTexture * RenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat) { RenderTexture *ret = new RenderTexture(); if(ret && ret->initWithWidthAndHeight(w, h, eFormat)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } RenderTexture * RenderTexture::create(int w ,int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat) { RenderTexture *ret = new RenderTexture(); if(ret && ret->initWithWidthAndHeight(w, h, eFormat, uDepthStencilFormat)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } RenderTexture * RenderTexture::create(int w, int h) { RenderTexture *ret = new RenderTexture(); if(ret && ret->initWithWidthAndHeight(w, h, Texture2D::PixelFormat::RGBA8888, 0)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat) { return initWithWidthAndHeight(w, h, eFormat, 0); } bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat format, GLuint depthStencilFormat) { CCASSERT(format != Texture2D::PixelFormat::A8, "only RGB and RGBA formats are valid for a render texture"); bool ret = false; void *data = nullptr; do { w = (int)(w * CC_CONTENT_SCALE_FACTOR()); h = (int)(h * CC_CONTENT_SCALE_FACTOR()); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); // textures must be power of two squared int powW = 0; int powH = 0; if (Configuration::getInstance()->supportsNPOT()) { powW = w; powH = h; } else { powW = ccNextPOT(w); powH = ccNextPOT(h); } auto dataLen = powW * powH * 4; data = malloc(dataLen); CC_BREAK_IF(! data); memset(data, 0, dataLen); _pixelFormat = format; _texture = new Texture2D(); if (_texture) { _texture->initWithData(data, dataLen, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h)); } else { break; } GLint oldRBO; glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO); if (Configuration::getInstance()->checkForGLExtension("GL_QCOM")) { _textureCopy = new Texture2D(); if (_textureCopy) { _textureCopy->initWithData(data, dataLen, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h)); } else { break; } } // generate FBO glGenFramebuffers(1, &_FBO); glBindFramebuffer(GL_FRAMEBUFFER, _FBO); // associate texture with FBO glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0); if (depthStencilFormat != 0) { //create and attach depth buffer glGenRenderbuffers(1, &_depthRenderBufffer); glBindRenderbuffer(GL_RENDERBUFFER, _depthRenderBufffer); glRenderbufferStorage(GL_RENDERBUFFER, depthStencilFormat, (GLsizei)powW, (GLsizei)powH); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthRenderBufffer); // if depth format is the one with stencil part, bind same render buffer as stencil attachment if (depthStencilFormat == GL_DEPTH24_STENCIL8) { glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _depthRenderBufffer); } } // check if it worked (probably worth doing :) ) CCASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Could not attach texture to framebuffer"); _texture->setAliasTexParameters(); // retained setSprite(Sprite::createWithTexture(_texture)); _texture->release(); _sprite->setScaleY(-1); _sprite->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); glBindRenderbuffer(GL_RENDERBUFFER, oldRBO); glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); // Diabled by default. _autoDraw = false; // add sprite for backward compatibility addChild(_sprite); ret = true; } while (0); CC_SAFE_FREE(data); return ret; } void RenderTexture::beginWithClear(float r, float g, float b, float a) { beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT); } void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue) { beginWithClear(r, g, b, a, depthValue, 0, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); } void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue) { beginWithClear(r, g, b, a, depthValue, stencilValue, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); } void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) { setClearColor(Color4F(r, g, b, a)); setClearDepth(depthValue); setClearStencil(stencilValue); setClearFlags(flags); this->begin(); //clear screen _beginWithClearCommand.init(_globalZOrder); _beginWithClearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this); Director::getInstance()->getRenderer()->addCommand(&_beginWithClearCommand); } //TODO find a better way to clear the screen, there is no need to rebind render buffer there. void RenderTexture::clear(float r, float g, float b, float a) { this->beginWithClear(r, g, b, a); this->end(); } void RenderTexture::clearDepth(float depthValue) { setClearDepth(depthValue); this->begin(); _clearDepthCommand.init(_globalZOrder); _clearDepthCommand.func = CC_CALLBACK_0(RenderTexture::onClearDepth, this); Director::getInstance()->getRenderer()->addCommand(&_clearDepthCommand); this->end(); } void RenderTexture::clearStencil(int stencilValue) { // save old stencil value int stencilClearValue; glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue); glClearStencil(stencilValue); glClear(GL_STENCIL_BUFFER_BIT); // restore clear color glClearStencil(stencilClearValue); } void RenderTexture::visit() { // override visit. // Don't call visit on its children if (!_visible) { return; } kmGLPushMatrix(); transform(); _sprite->visit(); draw(); kmGLPopMatrix(); _orderOfArrival = 0; } bool RenderTexture::saveToFile(const std::string& filename) { bool ret = false; Image *image = newImage(true); if (image) { ret = image->saveToFile(filename); } CC_SAFE_DELETE(image); return ret; } bool RenderTexture::saveToFile(const std::string& fileName, Image::Format format) { bool ret = false; CCASSERT(format == Image::Format::JPG || format == Image::Format::PNG, "the image can only be saved as JPG or PNG format"); Image *image = newImage(true); if (image) { std::string fullpath = FileUtils::getInstance()->getWritablePath() + fileName; ret = image->saveToFile(fullpath.c_str(), true); } CC_SAFE_DELETE(image); return ret; } /* get buffer as Image */ Image* RenderTexture::newImage(bool fliimage) { CCASSERT(_pixelFormat == Texture2D::PixelFormat::RGBA8888, "only RGBA8888 can be saved as image"); if (nullptr == _texture) { return nullptr; } const Size& s = _texture->getContentSizeInPixels(); // to get the image size to save // if the saving image domain exceeds the buffer texture domain, // it should be cut int savedBufferWidth = (int)s.width; int savedBufferHeight = (int)s.height; GLubyte *buffer = nullptr; GLubyte *tempData = nullptr; Image *image = new Image(); do { CC_BREAK_IF(! (buffer = new GLubyte[savedBufferWidth * savedBufferHeight * 4])); if(! (tempData = new GLubyte[savedBufferWidth * savedBufferHeight * 4])) { delete[] buffer; buffer = nullptr; break; } this->begin(); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0,0,savedBufferWidth, savedBufferHeight,GL_RGBA,GL_UNSIGNED_BYTE, tempData); this->end(); if ( fliimage ) // -- flip is only required when saving image to file { // to get the actual texture data // #640 the image read from rendertexture is dirty for (int i = 0; i < savedBufferHeight; ++i) { memcpy(&buffer[i * savedBufferWidth * 4], &tempData[(savedBufferHeight - i - 1) * savedBufferWidth * 4], savedBufferWidth * 4); } image->initWithRawData(buffer, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8); } else { image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8); } } while (0); CC_SAFE_DELETE_ARRAY(buffer); CC_SAFE_DELETE_ARRAY(tempData); return image; } void RenderTexture::onBegin() { // kmGLGetMatrix(KM_GL_PROJECTION, &_oldProjMatrix); kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadMatrix(&_projectionMatrix); kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadMatrix(&_transformMatrix); Director *director = Director::getInstance(); director->setProjection(director->getProjection()); const Size& texSize = _texture->getContentSizeInPixels(); // Calculate the adjustment ratios based on the old and new projections Size size = director->getWinSizeInPixels(); float widthRatio = size.width / texSize.width; float heightRatio = size.height / texSize.height; // Adjust the orthographic projection and viewport glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height); kmMat4 orthoMatrix; kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); kmGLMultMatrix(&orthoMatrix); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); glBindFramebuffer(GL_FRAMEBUFFER, _FBO); //TODO move this to configration, so we don't check it every time /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers. */ if (Configuration::getInstance()->checkForGLExtension("GL_QCOM")) { // -- bind a temporary texture so we can clear the render buffer without losing our texture glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0); CHECK_GL_ERROR_DEBUG(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0); } } void RenderTexture::onEnd() { Director *director = Director::getInstance(); glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); // restore viewport director->setViewport(); // kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadMatrix(&_oldProjMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadMatrix(&_oldTransMatrix); } void RenderTexture::onClear() { // save clear color GLfloat oldClearColor[4] = {0.0f}; GLfloat oldDepthClearValue = 0.0f; GLint oldStencilClearValue = 0; // backup and set if (_clearFlags & GL_COLOR_BUFFER_BIT) { glGetFloatv(GL_COLOR_CLEAR_VALUE, oldClearColor); glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a); } if (_clearFlags & GL_DEPTH_BUFFER_BIT) { glGetFloatv(GL_DEPTH_CLEAR_VALUE, &oldDepthClearValue); glClearDepth(_clearDepth); } if (_clearFlags & GL_STENCIL_BUFFER_BIT) { glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &oldStencilClearValue); glClearStencil(_clearStencil); } // clear glClear(_clearFlags); // restore if (_clearFlags & GL_COLOR_BUFFER_BIT) { glClearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); } if (_clearFlags & GL_DEPTH_BUFFER_BIT) { glClearDepth(oldDepthClearValue); } if (_clearFlags & GL_STENCIL_BUFFER_BIT) { glClearStencil(oldStencilClearValue); } } void RenderTexture::onClearDepth() { //! save old depth value GLfloat depthClearValue; glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); glClearDepth(_clearDepth); glClear(GL_DEPTH_BUFFER_BIT); // restore clear color glClearDepth(depthClearValue); } void RenderTexture::draw() { if (_autoDraw) { //Begin will create a render group using new render target begin(); //clear screen _clearCommand.init(_globalZOrder); _clearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this); Director::getInstance()->getRenderer()->addCommand(&_clearCommand); //! make sure all children are drawn sortAllChildren(); for(const auto &child: _children) { if (child != _sprite) child->visit(); } //End will pop the current render group end(); } } void RenderTexture::begin() { kmGLMatrixMode(KM_GL_PROJECTION); kmGLPushMatrix(); kmGLGetMatrix(KM_GL_PROJECTION, &_projectionMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPushMatrix(); kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix); Director *director = Director::getInstance(); director->setProjection(director->getProjection()); const Size& texSize = _texture->getContentSizeInPixels(); // Calculate the adjustment ratios based on the old and new projections Size size = director->getWinSizeInPixels(); float widthRatio = size.width / texSize.width; float heightRatio = size.height / texSize.height; kmMat4 orthoMatrix; kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); kmGLMultMatrix(&orthoMatrix); _groupCommand.init(_globalZOrder); Renderer *renderer = Director::getInstance()->getRenderer(); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); _beginCommand.init(_globalZOrder); _beginCommand.func = CC_CALLBACK_0(RenderTexture::onBegin, this); Director::getInstance()->getRenderer()->addCommand(&_beginCommand); } void RenderTexture::end() { _endCommand.init(_globalZOrder); _endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this); Renderer *renderer = Director::getInstance()->getRenderer(); renderer->addCommand(&_endCommand); renderer->popGroup(); kmGLMatrixMode(KM_GL_PROJECTION); kmGLPopMatrix(); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPopMatrix(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCRenderTexture.h ================================================ /**************************************************************************** Copyright (c) 2009 Jason Booth Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCRENDER_TEXTURE_H__ #define __CCRENDER_TEXTURE_H__ #include "CCNode.h" #include "CCSprite.h" #include "kazmath/mat4.h" #include "platform/CCImage.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCCustomCommand.h" NS_CC_BEGIN class EventCustom; /** * @addtogroup textures * @{ */ /** @brief RenderTexture is a generic rendering target. To render things into it, simply construct a render target, call begin on it, call visit on any cocos scenes or objects to render them, and call end. For convenience, render texture adds a sprite as it's display child with the results, so you can simply add the render texture to your scene and treat it like any other CocosNode. There are also functions for saving the render texture to disk in PNG or JPG format. @since v0.8.1 */ class CC_DLL RenderTexture : public Node { public: /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ static RenderTexture * create(int w ,int h, Texture2D::PixelFormat format, GLuint depthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ static RenderTexture * create(int w, int h, Texture2D::PixelFormat format); /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 */ static RenderTexture * create(int w, int h); /** starts grabbing */ virtual void begin(); /** starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin */ virtual void beginWithClear(float r, float g, float b, float a); /** starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin */ virtual void beginWithClear(float r, float g, float b, float a, float depthValue); /** starts rendering to the texture while clearing the texture first. This is more efficient then calling -clear first and then -begin */ virtual void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue); /** end is key word of lua, use other name to export to lua. */ inline void endToLua(){ end();}; /** ends grabbing*/ virtual void end(); /** clears the texture with a color */ void clear(float r, float g, float b, float a); /** clears the texture with a specified depth value */ virtual void clearDepth(float depthValue); /** clears the texture with a specified stencil value */ virtual void clearStencil(int stencilValue); /* creates a new Image from with the texture's data. Caller is responsible for releasing it by calling delete. */ Image* newImage(bool flipImage = true); CC_DEPRECATED_ATTRIBUTE Image* newCCImage(bool flipImage = true) { return newImage(flipImage); }; /** saves the texture into a file using JPEG format. The file will be saved in the Documents folder. Returns true if the operation is successful. */ bool saveToFile(const std::string& filename); /** saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder. Returns true if the operation is successful. */ bool saveToFile(const std::string& filename, Image::Format format); /** Listen "come to background" message, and save render texture. It only has effect on Android. */ void listenToBackground(EventCustom *event); /** Listen "come to foreground" message and restore the frame buffer object It only has effect on Android. */ void listenToForeground(EventCustom *event); /** Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when "autoDraw" is true. */ inline unsigned int getClearFlags() const { return _clearFlags; }; inline void setClearFlags(unsigned int clearFlags) { _clearFlags = clearFlags; }; /** Clear color value. Valid only when "autoDraw" is true. */ inline const Color4F& getClearColor() const { return _clearColor; }; inline void setClearColor(const Color4F &clearColor) { _clearColor = clearColor; }; /** Value for clearDepth. Valid only when "autoDraw" is true. */ inline float getClearDepth() const { return _clearDepth; }; inline void setClearDepth(float clearDepth) { _clearDepth = clearDepth; }; /** Value for clear Stencil. Valid only when "autoDraw" is true */ inline int getClearStencil() const { return _clearStencil; }; inline void setClearStencil(int clearStencil) { _clearStencil = clearStencil; }; /** When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons. Will be enabled in the future. */ inline bool isAutoDraw() const { return _autoDraw; }; inline void setAutoDraw(bool isAutoDraw) { _autoDraw = isAutoDraw; }; /** Gets the Sprite being used. */ inline Sprite* getSprite() const { return _sprite; }; /** Sets the Sprite being used. */ inline void setSprite(Sprite* sprite) { CC_SAFE_RETAIN(sprite); CC_SAFE_RELEASE(_sprite); _sprite = sprite; }; // Overrides virtual void visit() override; virtual void draw() override; public: // XXX should be procted. // but due to a bug in PowerVR + Android, // the constructor is public again RenderTexture(); virtual ~RenderTexture(); /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat format); /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat format, GLuint depthStencilFormat); protected: virtual void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags); GLuint _FBO; GLuint _depthRenderBufffer; GLint _oldFBO; Texture2D* _texture; Texture2D* _textureCopy; // a copy of _texture Image* _UITextureImage; Texture2D::PixelFormat _pixelFormat; // code for "auto" update GLbitfield _clearFlags; Color4F _clearColor; GLclampf _clearDepth; GLint _clearStencil; bool _autoDraw; /** The Sprite being used. The sprite, by default, will use the following blending function: GL_ONE, GL_ONE_MINUS_SRC_ALPHA. The blending function can be changed in runtime by calling: - [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}]; */ Sprite* _sprite; GroupCommand _groupCommand; CustomCommand _beginWithClearCommand; CustomCommand _clearDepthCommand; CustomCommand _clearCommand; CustomCommand _beginCommand; CustomCommand _endCommand; protected: //renderer caches and callbacks void onBegin(); void onEnd(); void onClear(); void onClearDepth(); kmMat4 _oldTransMatrix, _oldProjMatrix; kmMat4 _transformMatrix, _projectionMatrix; private: CC_DISALLOW_COPY_AND_ASSIGN(RenderTexture); }; // end of textures group /// @} NS_CC_END #endif //__CCRENDER_TEXTURE_H__ ================================================ FILE: cocos2d/cocos/2d/CCScene.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCScene.h" #include "CCDirector.h" #include "CCLayer.h" #include "CCSprite.h" #include "CCSpriteBatchNode.h" #include "CCPhysicsWorld.h" NS_CC_BEGIN Scene::Scene() #if CC_USE_PHYSICS : _physicsWorld(nullptr) #endif { _ignoreAnchorPointForPosition = true; setAnchorPoint(Point(0.5f, 0.5f)); } Scene::~Scene() { #if CC_USE_PHYSICS CC_SAFE_DELETE(_physicsWorld); #endif } bool Scene::init() { bool ret = false; do { Director * director; CC_BREAK_IF( ! (director = Director::getInstance()) ); this->setContentSize(director->getWinSize()); // success ret = true; } while (0); return ret; } Scene *Scene::create() { Scene *ret = new Scene(); if (ret && ret->init()) { ret->autorelease(); return ret; } else { CC_SAFE_DELETE(ret); return nullptr; } } std::string Scene::getDescription() const { return StringUtils::format("", _tag); } Scene* Scene::getScene() { return this; } #if CC_USE_PHYSICS void Scene::addChild(Node* child, int zOrder, int tag) { Node::addChild(child, zOrder, tag); addChildToPhysicsWorld(child); } void Scene::update(float delta) { Node::update(delta); if (nullptr != _physicsWorld) { _physicsWorld->update(delta); } } Scene *Scene::createWithPhysics() { Scene *ret = new Scene(); if (ret && ret->initWithPhysics()) { ret->autorelease(); return ret; } else { CC_SAFE_DELETE(ret); return nullptr; } } bool Scene::initWithPhysics() { bool ret = false; do { Director * director; CC_BREAK_IF( ! (director = Director::getInstance()) ); this->setContentSize(director->getWinSize()); CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::construct(*this))); this->scheduleUpdate(); // success ret = true; } while (0); return ret; } void Scene::addChildToPhysicsWorld(Node* child) { if (_physicsWorld) { std::function addToPhysicsWorldFunc = nullptr; addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Node* node) -> void { if (node->getPhysicsBody()) { _physicsWorld->addBody(node->getPhysicsBody()); } auto& children = node->getChildren(); for( const auto &n : children) { addToPhysicsWorldFunc(n); } }; addToPhysicsWorldFunc(child); } } #endif NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCScene.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCSCENE_H__ #define __CCSCENE_H__ #include "CCNode.h" #include "CCPhysicsWorld.h" NS_CC_BEGIN /** * @addtogroup scene * @{ */ /** @brief Scene is a subclass of Node that is used only as an abstract concept. Scene and Node are almost identical with the difference that Scene has its anchor point (by default) at the center of the screen. For the moment Scene has no other logic than that, but in future releases it might have additional logic. It is a good practice to use a Scene as the parent of all your nodes. */ class CC_DLL Scene : public Node { public: /** creates a new Scene object */ static Scene *create(); // Overrides virtual Scene *getScene() override; using Node::addChild; virtual std::string getDescription() const override; protected: Scene(); virtual ~Scene(); bool init(); friend class Node; friend class SpriteBatchNode; private: CC_DISALLOW_COPY_AND_ASSIGN(Scene); #if CC_USE_PHYSICS public: virtual void addChild(Node* child, int zOrder, int tag) override; virtual void update(float delta) override; inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; } static Scene *createWithPhysics(); protected: bool initWithPhysics(); void addChildToPhysicsWorld(Node* child); PhysicsWorld* _physicsWorld; #endif // CC_USE_PHYSICS }; // end of scene group /// @} NS_CC_END #endif // __CCSCENE_H__ ================================================ FILE: cocos2d/cocos/2d/CCScheduler.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCScheduler.h" #include "ccMacros.h" #include "CCDirector.h" #include "utlist.h" #include "ccCArray.h" #include "CCArray.h" #include "CCScriptSupport.h" using namespace std; NS_CC_BEGIN // data structures // A list double-linked list used for "updates with priority" typedef struct _listEntry { struct _listEntry *prev, *next; Object *target; // not retained (retained by hashUpdateEntry) int priority; bool paused; bool markedForDeletion; // selector will no longer be called and entry will be removed at end of the next tick } tListEntry; typedef struct _hashUpdateEntry { tListEntry **list; // Which list does it belong to ? tListEntry *entry; // entry in the list Object *target; // hash key (retained) UT_hash_handle hh; } tHashUpdateEntry; // Hash Element used for "selectors with interval" typedef struct _hashSelectorEntry { ccArray *timers; Object *target; // hash key (retained) int timerIndex; Timer *currentTimer; bool currentTimerSalvaged; bool paused; UT_hash_handle hh; } tHashTimerEntry; // implementation Timer Timer::Timer() : _target(nullptr) , _elapsed(-1) , _runForever(false) , _useDelay(false) , _timesExecuted(0) , _repeat(0) , _delay(0.0f) , _interval(0.0f) , _selector(nullptr) , _scriptHandler(0) { } Timer* Timer::create(Object *target, SEL_SCHEDULE selector) { Timer *timer = new Timer(); timer->initWithTarget(target, selector, 0.0f, kRepeatForever, 0.0f); timer->autorelease(); return timer; } Timer* Timer::create(Object *target, SEL_SCHEDULE selector, float seconds) { Timer *timer = new Timer(); timer->initWithTarget(target, selector, seconds, kRepeatForever, 0.0f); timer->autorelease(); return timer; } Timer* Timer::createWithScriptHandler(int handler, float seconds) { Timer *timer = new Timer(); timer->initWithScriptHandler(handler, seconds); timer->autorelease(); return timer; } bool Timer::initWithScriptHandler(int handler, float seconds) { _scriptHandler = handler; _elapsed = -1; _interval = seconds; return true; } bool Timer::initWithTarget(Object *target, SEL_SCHEDULE selector) { return initWithTarget(target, selector, 0, kRepeatForever, 0.0f); } bool Timer::initWithTarget(Object *target, SEL_SCHEDULE selector, float seconds, unsigned int repeat, float delay) { _target = target; _selector = selector; _elapsed = -1; _interval = seconds; _delay = delay; _useDelay = (delay > 0.0f) ? true : false; _repeat = repeat; _runForever = (repeat == kRepeatForever) ? true : false; return true; } void Timer::update(float dt) { if (_elapsed == -1) { _elapsed = 0; _timesExecuted = 0; } else { if (_runForever && !_useDelay) {//standard timer usage _elapsed += dt; if (_elapsed >= _interval) { if (_target && _selector) { (_target->*_selector)(_elapsed); } if (0 != _scriptHandler) { SchedulerScriptData data(_scriptHandler,_elapsed); ScriptEvent event(kScheduleEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } _elapsed = 0; } } else {//advanced usage _elapsed += dt; if (_useDelay) { if( _elapsed >= _delay ) { if (_target && _selector) { (_target->*_selector)(_elapsed); } if (0 != _scriptHandler) { SchedulerScriptData data(_scriptHandler,_elapsed); ScriptEvent event(kScheduleEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } _elapsed = _elapsed - _delay; _timesExecuted += 1; _useDelay = false; } } else { if (_elapsed >= _interval) { if (_target && _selector) { (_target->*_selector)(_elapsed); } if (0 != _scriptHandler) { SchedulerScriptData data(_scriptHandler,_elapsed); ScriptEvent event(kScheduleEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } _elapsed = 0; _timesExecuted += 1; } } if (!_runForever && _timesExecuted > _repeat) { //unschedule timer Director::getInstance()->getScheduler()->unscheduleSelector(_selector, _target); } } } } float Timer::getInterval() const { return _interval; } void Timer::setInterval(float interval) { _interval = interval; } SEL_SCHEDULE Timer::getSelector() const { return _selector; } // implementation of Scheduler // Priority level reserved for system services. const int Scheduler::PRIORITY_SYSTEM = INT_MIN; // Minimum priority level for user scheduling. const int Scheduler::PRIORITY_NON_SYSTEM_MIN = PRIORITY_SYSTEM + 1; Scheduler::Scheduler(void) : _timeScale(1.0f) , _updatesNegList(nullptr) , _updates0List(nullptr) , _updatesPosList(nullptr) , _hashForUpdates(nullptr) , _hashForTimers(nullptr) , _currentTarget(nullptr) , _currentTargetSalvaged(false) , _updateHashLocked(false) , _scriptHandlerEntries(20) { // I don't expect to have more than 30 functions to all per frame _functionsToPerform.reserve(30); } Scheduler::~Scheduler(void) { unscheduleAll(); } void Scheduler::removeHashElement(_hashSelectorEntry *element) { cocos2d::Object *target = element->target; ccArrayFree(element->timers); HASH_DEL(_hashForTimers, element); free(element); // make sure the target is released after we have removed the hash element // otherwise we access invalid memory when the release call deletes the target // and the target calls removeAllSelectors() during its destructor target->release(); } void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, bool paused) { this->scheduleSelector(selector, target, interval, kRepeatForever, 0.0f, paused); } void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, unsigned int repeat, float delay, bool paused) { CCASSERT(selector, "Argument selector must be non-nullptr"); CCASSERT(target, "Argument target must be non-nullptr"); tHashTimerEntry *element = nullptr; HASH_FIND_PTR(_hashForTimers, &target, element); if (! element) { element = (tHashTimerEntry *)calloc(sizeof(*element), 1); element->target = target; if (target) { target->retain(); } HASH_ADD_PTR(_hashForTimers, target, element); // Is this the 1st element ? Then set the pause level to all the selectors of this target element->paused = paused; } else { CCASSERT(element->paused == paused, ""); } if (element->timers == nullptr) { element->timers = ccArrayNew(10); } else { for (int i = 0; i < element->timers->num; ++i) { Timer *timer = (Timer*)element->timers->arr[i]; if (selector == timer->getSelector()) { CCLOG("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer->getInterval(), interval); timer->setInterval(interval); return; } } ccArrayEnsureExtraCapacity(element->timers, 1); } Timer *pTimer = new Timer(); pTimer->initWithTarget(target, selector, interval, repeat, delay); ccArrayAppendObject(element->timers, pTimer); pTimer->release(); } void Scheduler::unscheduleSelector(SEL_SCHEDULE selector, Object *target) { // explicity handle nil arguments when removing an object if (target == 0 || selector == 0) { return; } //CCASSERT(target); //CCASSERT(selector); tHashTimerEntry *element = nullptr; HASH_FIND_PTR(_hashForTimers, &target, element); if (element) { for (int i = 0; i < element->timers->num; ++i) { Timer *timer = static_cast(element->timers->arr[i]); if (selector == timer->getSelector()) { if (timer == element->currentTimer && (! element->currentTimerSalvaged)) { element->currentTimer->retain(); element->currentTimerSalvaged = true; } ccArrayRemoveObjectAtIndex(element->timers, i, true); // update timerIndex in case we are in tick:, looping over the actions if (element->timerIndex >= i) { element->timerIndex--; } if (element->timers->num == 0) { if (_currentTarget == element) { _currentTargetSalvaged = true; } else { removeHashElement(element); } } return; } } } } void Scheduler::priorityIn(tListEntry **list, Object *target, int priority, bool paused) { tListEntry *listElement = (tListEntry *)malloc(sizeof(*listElement)); listElement->target = target; listElement->priority = priority; listElement->paused = paused; listElement->next = listElement->prev = nullptr; listElement->markedForDeletion = false; // empty list ? if (! *list) { DL_APPEND(*list, listElement); } else { bool added = false; for (tListEntry *element = *list; element; element = element->next) { if (priority < element->priority) { if (element == *list) { DL_PREPEND(*list, listElement); } else { listElement->next = element; listElement->prev = element->prev; element->prev->next = listElement; element->prev = listElement; } added = true; break; } } // Not added? priority has the higher value. Append it. if (! added) { DL_APPEND(*list, listElement); } } // update hash entry for quick access tHashUpdateEntry *hashElement = (tHashUpdateEntry *)calloc(sizeof(*hashElement), 1); hashElement->target = target; target->retain(); hashElement->list = list; hashElement->entry = listElement; HASH_ADD_PTR(_hashForUpdates, target, hashElement); } void Scheduler::appendIn(_listEntry **list, Object *target, bool paused) { tListEntry *listElement = (tListEntry *)malloc(sizeof(*listElement)); listElement->target = target; listElement->paused = paused; listElement->markedForDeletion = false; DL_APPEND(*list, listElement); // update hash entry for quicker access tHashUpdateEntry *hashElement = (tHashUpdateEntry *)calloc(sizeof(*hashElement), 1); hashElement->target = target; target->retain(); hashElement->list = list; hashElement->entry = listElement; HASH_ADD_PTR(_hashForUpdates, target, hashElement); } void Scheduler::scheduleUpdateForTarget(Object *target, int priority, bool paused) { tHashUpdateEntry *hashElement = nullptr; HASH_FIND_PTR(_hashForUpdates, &target, hashElement); if (hashElement) { #if COCOS2D_DEBUG >= 1 CCASSERT(hashElement->entry->markedForDeletion,""); #endif // TODO: check if priority has changed! hashElement->entry->markedForDeletion = false; return; } // most of the updates are going to be 0, that's way there // is an special list for updates with priority 0 if (priority == 0) { appendIn(&_updates0List, target, paused); } else if (priority < 0) { priorityIn(&_updatesNegList, target, priority, paused); } else { // priority > 0 priorityIn(&_updatesPosList, target, priority, paused); } } bool Scheduler::isScheduledForTarget(SEL_SCHEDULE selector, Object *target) { CCASSERT(selector, "Argument selector must be non-nullptr"); CCASSERT(target, "Argument target must be non-nullptr"); tHashTimerEntry *element = nullptr; HASH_FIND_PTR(_hashForTimers, &target, element); if (!element) { return false; } if (element->timers == nullptr) { return false; }else { for (int i = 0; i < element->timers->num; ++i) { Timer *timer = (Timer*)element->timers->arr[i]; if (selector == timer->getSelector()) { return true; } } return false; } return false; // should never get here } void Scheduler::removeUpdateFromHash(struct _listEntry *entry) { tHashUpdateEntry *element = nullptr; HASH_FIND_PTR(_hashForUpdates, &entry->target, element); if (element) { // list entry DL_DELETE(*element->list, element->entry); free(element->entry); // hash entry Object* target = element->target; HASH_DEL(_hashForUpdates, element); free(element); // target#release should be the last one to prevent // a possible double-free. eg: If the [target dealloc] might want to remove it itself from there target->release(); } } void Scheduler::unscheduleUpdateForTarget(const Object *target) { if (target == nullptr) { return; } tHashUpdateEntry *element = nullptr; HASH_FIND_PTR(_hashForUpdates, &target, element); if (element) { if (_updateHashLocked) { element->entry->markedForDeletion = true; } else { this->removeUpdateFromHash(element->entry); } } } void Scheduler::unscheduleAll(void) { unscheduleAllWithMinPriority(PRIORITY_SYSTEM); } void Scheduler::unscheduleAllWithMinPriority(int minPriority) { // Custom Selectors tHashTimerEntry *element = nullptr; tHashTimerEntry *nextElement = nullptr; for (element = _hashForTimers; element != nullptr;) { // element may be removed in unscheduleAllSelectorsForTarget nextElement = (tHashTimerEntry *)element->hh.next; unscheduleAllForTarget(element->target); element = nextElement; } // Updates selectors tListEntry *entry, *tmp; if(minPriority < 0) { DL_FOREACH_SAFE(_updatesNegList, entry, tmp) { if(entry->priority >= minPriority) { unscheduleUpdateForTarget(entry->target); } } } if(minPriority <= 0) { DL_FOREACH_SAFE(_updates0List, entry, tmp) { unscheduleUpdateForTarget(entry->target); } } DL_FOREACH_SAFE(_updatesPosList, entry, tmp) { if(entry->priority >= minPriority) { unscheduleUpdateForTarget(entry->target); } } _scriptHandlerEntries.clear(); } void Scheduler::unscheduleAllForTarget(Object *target) { // explicit nullptr handling if (target == nullptr) { return; } // Custom Selectors tHashTimerEntry *element = nullptr; HASH_FIND_PTR(_hashForTimers, &target, element); if (element) { if (ccArrayContainsObject(element->timers, element->currentTimer) && (! element->currentTimerSalvaged)) { element->currentTimer->retain(); element->currentTimerSalvaged = true; } ccArrayRemoveAllObjects(element->timers); if (_currentTarget == element) { _currentTargetSalvaged = true; } else { removeHashElement(element); } } // update selector unscheduleUpdateForTarget(target); } unsigned int Scheduler::scheduleScriptFunc(unsigned int handler, float interval, bool paused) { SchedulerScriptHandlerEntry* entry = SchedulerScriptHandlerEntry::create(handler, interval, paused); _scriptHandlerEntries.pushBack(entry); return entry->getEntryId(); } void Scheduler::unscheduleScriptEntry(unsigned int scheduleScriptEntryID) { for (ssize_t i = _scriptHandlerEntries.size() - 1; i >= 0; i--) { SchedulerScriptHandlerEntry* entry = _scriptHandlerEntries.at(i); if (entry->getEntryId() == (int)scheduleScriptEntryID) { entry->markedForDeletion(); break; } } } void Scheduler::resumeTarget(Object *target) { CCASSERT(target != nullptr, ""); // custom selectors tHashTimerEntry *element = nullptr; HASH_FIND_PTR(_hashForTimers, &target, element); if (element) { element->paused = false; } // update selector tHashUpdateEntry *elementUpdate = nullptr; HASH_FIND_PTR(_hashForUpdates, &target, elementUpdate); if (elementUpdate) { CCASSERT(elementUpdate->entry != nullptr, ""); elementUpdate->entry->paused = false; } } void Scheduler::pauseTarget(Object *target) { CCASSERT(target != nullptr, ""); // custom selectors tHashTimerEntry *element = nullptr; HASH_FIND_PTR(_hashForTimers, &target, element); if (element) { element->paused = true; } // update selector tHashUpdateEntry *elementUpdate = nullptr; HASH_FIND_PTR(_hashForUpdates, &target, elementUpdate); if (elementUpdate) { CCASSERT(elementUpdate->entry != nullptr, ""); elementUpdate->entry->paused = true; } } bool Scheduler::isTargetPaused(Object *target) { CCASSERT( target != nullptr, "target must be non nil" ); // Custom selectors tHashTimerEntry *element = nullptr; HASH_FIND_PTR(_hashForTimers, &target, element); if( element ) { return element->paused; } // We should check update selectors if target does not have custom selectors tHashUpdateEntry *elementUpdate = nullptr; HASH_FIND_PTR(_hashForUpdates, &target, elementUpdate); if ( elementUpdate ) { return elementUpdate->entry->paused; } return false; // should never get here } Vector Scheduler::pauseAllTargets() { return pauseAllTargetsWithMinPriority(PRIORITY_SYSTEM); } Vector Scheduler::pauseAllTargetsWithMinPriority(int minPriority) { Vector idsWithSelectors(50); // Custom Selectors for(tHashTimerEntry *element = _hashForTimers; element != nullptr; element = (tHashTimerEntry*)element->hh.next) { element->paused = true; idsWithSelectors.pushBack(element->target); } // Updates selectors tListEntry *entry, *tmp; if(minPriority < 0) { DL_FOREACH_SAFE( _updatesNegList, entry, tmp ) { if(entry->priority >= minPriority) { entry->paused = true; idsWithSelectors.pushBack(entry->target); } } } if(minPriority <= 0) { DL_FOREACH_SAFE( _updates0List, entry, tmp ) { entry->paused = true; idsWithSelectors.pushBack(entry->target); } } DL_FOREACH_SAFE( _updatesPosList, entry, tmp ) { if(entry->priority >= minPriority) { entry->paused = true; idsWithSelectors.pushBack(entry->target); } } return idsWithSelectors; } void Scheduler::resumeTargets(const Vector& targetsToResume) { for(const auto &obj : targetsToResume) { this->resumeTarget(obj); } } void Scheduler::performFunctionInCocosThread(const std::function &function) { _performMutex.lock(); _functionsToPerform.push_back(function); _performMutex.unlock(); } // main loop void Scheduler::update(float dt) { _updateHashLocked = true; if (_timeScale != 1.0f) { dt *= _timeScale; } // // Selector callbacks // // Iterate over all the Updates' selectors tListEntry *entry, *tmp; // updates with priority < 0 DL_FOREACH_SAFE(_updatesNegList, entry, tmp) { if ((! entry->paused) && (! entry->markedForDeletion)) { entry->target->update(dt); } } // updates with priority == 0 DL_FOREACH_SAFE(_updates0List, entry, tmp) { if ((! entry->paused) && (! entry->markedForDeletion)) { entry->target->update(dt); } } // updates with priority > 0 DL_FOREACH_SAFE(_updatesPosList, entry, tmp) { if ((! entry->paused) && (! entry->markedForDeletion)) { entry->target->update(dt); } } // Iterate over all the custom selectors for (tHashTimerEntry *elt = _hashForTimers; elt != nullptr; ) { _currentTarget = elt; _currentTargetSalvaged = false; if (! _currentTarget->paused) { // The 'timers' array may change while inside this loop for (elt->timerIndex = 0; elt->timerIndex < elt->timers->num; ++(elt->timerIndex)) { elt->currentTimer = (Timer*)(elt->timers->arr[elt->timerIndex]); elt->currentTimerSalvaged = false; elt->currentTimer->update(dt); if (elt->currentTimerSalvaged) { // The currentTimer told the remove itself. To prevent the timer from // accidentally deallocating itself before finishing its step, we retained // it. Now that step is done, it's safe to release it. elt->currentTimer->release(); } elt->currentTimer = nullptr; } } // elt, at this moment, is still valid // so it is safe to ask this here (issue #490) elt = (tHashTimerEntry *)elt->hh.next; // only delete currentTarget if no actions were scheduled during the cycle (issue #481) if (_currentTargetSalvaged && _currentTarget->timers->num == 0) { removeHashElement(_currentTarget); } } // delete all updates that are marked for deletion // updates with priority < 0 DL_FOREACH_SAFE(_updatesNegList, entry, tmp) { if (entry->markedForDeletion) { this->removeUpdateFromHash(entry); } } // updates with priority == 0 DL_FOREACH_SAFE(_updates0List, entry, tmp) { if (entry->markedForDeletion) { this->removeUpdateFromHash(entry); } } // updates with priority > 0 DL_FOREACH_SAFE(_updatesPosList, entry, tmp) { if (entry->markedForDeletion) { this->removeUpdateFromHash(entry); } } _updateHashLocked = false; _currentTarget = nullptr; // // Script callbacks // // Iterate over all the script callbacks if (!_scriptHandlerEntries.empty()) { for (auto i = _scriptHandlerEntries.size() - 1; i >= 0; i--) { SchedulerScriptHandlerEntry* eachEntry = _scriptHandlerEntries.at(i); if (eachEntry->isMarkedForDeletion()) { _scriptHandlerEntries.erase(i); } else if (!eachEntry->isPaused()) { eachEntry->getTimer()->update(dt); } } } // // Functions allocated from another thread // // Testing size is faster than locking / unlocking. // And almost never there will be functions scheduled to be called. if( !_functionsToPerform.empty() ) { _performMutex.lock(); for( const auto &function : _functionsToPerform ) { function(); } _functionsToPerform.clear(); _performMutex.unlock(); } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCScheduler.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCSCHEDULER_H__ #define __CCSCHEDULER_H__ #include "CCObject.h" #include "CCVector.h" #include "uthash.h" #include #include NS_CC_BEGIN /** * @addtogroup global * @{ */ // // Timer // /** @brief Light-weight timer */ // class CC_DLL Timer : public Object { public: /** Allocates a timer with a target and a selector. */ static Timer* create(Object *target, SEL_SCHEDULE selector); /** Allocates a timer with a target, a selector and an interval in seconds. */ static Timer* create(Object *target, SEL_SCHEDULE selector, float seconds); /** Allocates a timer with a script callback function and an interval in seconds. * @js NA * @lua NA */ static Timer* createWithScriptHandler(int handler, float seconds); CC_DEPRECATED_ATTRIBUTE static Timer* timerWithTarget(Object *target, SEL_SCHEDULE selector) { return Timer::create(target, selector); } CC_DEPRECATED_ATTRIBUTE static Timer* timerWithTarget(Object *target, SEL_SCHEDULE selector, float seconds) { return Timer::create(target, selector, seconds); } CC_DEPRECATED_ATTRIBUTE static Timer* timerWithScriptHandler(int handler, float seconds) { return Timer::createWithScriptHandler(handler, seconds); } Timer(void); /** Initializes a timer with a target and a selector. */ bool initWithTarget(Object *target, SEL_SCHEDULE selector); /** Initializes a timer with a target, a selector and an interval in seconds, repeat in number of times to repeat, delay in seconds. */ bool initWithTarget(Object *target, SEL_SCHEDULE selector, float seconds, unsigned int repeat, float delay); /** Initializes a timer with a script callback function and an interval in seconds. */ bool initWithScriptHandler(int handler, float seconds); /** get interval in seconds */ float getInterval() const; /** set interval in seconds */ void setInterval(float interval); /** * @js NA * @lua NA */ SEL_SCHEDULE getSelector() const; /** triggers the timer */ void update(float dt); inline int getScriptHandler() const { return _scriptHandler; }; protected: Object *_target; float _elapsed; bool _runForever; bool _useDelay; unsigned int _timesExecuted; unsigned int _repeat; //0 = once, 1 is 2 x executed float _delay; float _interval; SEL_SCHEDULE _selector; int _scriptHandler; }; // // Scheduler // struct _listEntry; struct _hashSelectorEntry; struct _hashUpdateEntry; class SchedulerScriptHandlerEntry; /** @brief Scheduler is responsible for triggering the scheduled callbacks. You should not use NSTimer. Instead use this class. There are 2 different types of callbacks (selectors): - update selector: the 'update' selector will be called every frame. You can customize the priority. - custom selector: A custom selector will be called every frame, or with a custom interval of time The 'custom selectors' should be avoided when possible. It is faster, and consumes less memory to use the 'update selector'. */ class CC_DLL Scheduler : public Object { public: // Priority level reserved for system services. static const int PRIORITY_SYSTEM; // Minimum priority level for user scheduling. static const int PRIORITY_NON_SYSTEM_MIN; /** * @js ctor */ Scheduler(); /** * @js NA * @lua NA */ ~Scheduler(void); inline float getTimeScale() { return _timeScale; } /** Modifies the time of all scheduled callbacks. You can use this property to create a 'slow motion' or 'fast forward' effect. Default is 1.0. To create a 'slow motion' effect, use values below 1.0. To create a 'fast forward' effect, use values higher than 1.0. @since v0.8 @warning It will affect EVERY scheduled selector / action. */ inline void setTimeScale(float timeScale) { _timeScale = timeScale; } /** 'update' the scheduler. You should NEVER call this method, unless you know what you are doing. * @js NA * @lua NA */ void update(float dt); /** The scheduled method will be called every 'interval' seconds. If paused is true, then it won't be called until it is resumed. If 'interval' is 0, it will be called every frame, but if so, it's recommended to use 'scheduleUpdateForTarget:' instead. If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again. repeat let the action be repeated repeat + 1 times, use kRepeatForever to let the action run continuously delay is the amount of time the action will wait before it'll start @since v0.99.3, repeat and delay added in v1.1 */ void scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, unsigned int repeat, float delay, bool paused); /** calls scheduleSelector with kRepeatForever and a 0 delay */ void scheduleSelector(SEL_SCHEDULE selector, Object *target, float interval, bool paused); /** Schedules the 'update' selector for a given target with a given priority. The 'update' selector will be called every frame. The lower the priority, the earlier it is called. @since v0.99.3 */ void scheduleUpdateForTarget(Object *target, int priority, bool paused); /** Checks whether a selector for a given taget is scheduled. @since v3.0.0 */ bool isScheduledForTarget(SEL_SCHEDULE selector, Object *target); /** Unschedule a selector for a given target. If you want to unschedule the "update", use unscheudleUpdateForTarget. @since v0.99.3 */ void unscheduleSelector(SEL_SCHEDULE selector, Object *target); /** Unschedules the update selector for a given target @since v0.99.3 */ void unscheduleUpdateForTarget(const Object *target); /** Unschedules all selectors for a given target. This also includes the "update" selector. @since v0.99.3 */ void unscheduleAllForTarget(Object *target); /** Unschedules all selectors from all targets. You should NEVER call this method, unless you know what you are doing. @since v0.99.3 */ void unscheduleAll(void); /** Unschedules all selectors from all targets with a minimum priority. You should only call this with kPriorityNonSystemMin or higher. @since v2.0.0 */ void unscheduleAllWithMinPriority(int minPriority); /** The scheduled script callback will be called every 'interval' seconds. If paused is true, then it won't be called until it is resumed. If 'interval' is 0, it will be called every frame. return schedule script entry ID, used for unscheduleScriptFunc(). */ unsigned int scheduleScriptFunc(unsigned int handler, float interval, bool paused); /** Unschedule a script entry. */ void unscheduleScriptEntry(unsigned int scheduleScriptEntryID); /** Pauses the target. All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed. If the target is not present, nothing happens. @since v0.99.3 */ void pauseTarget(Object *target); /** Resumes the target. The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again. If the target is not present, nothing happens. @since v0.99.3 */ void resumeTarget(Object *target); /** Returns whether or not the target is paused @since v1.0.0 * In js: var isTargetPaused(var jsObject) * @lua NA */ bool isTargetPaused(Object *target); /** Pause all selectors from all targets. You should NEVER call this method, unless you know what you are doing. @since v2.0.0 */ Vector pauseAllTargets(); /** Pause all selectors from all targets with a minimum priority. You should only call this with kPriorityNonSystemMin or higher. @since v2.0.0 */ Vector pauseAllTargetsWithMinPriority(int minPriority); /** Resume selectors on a set of targets. This can be useful for undoing a call to pauseAllSelectors. @since v2.0.0 */ void resumeTargets(const Vector& targetsToResume); /** calls a function on the cocos2d thread. Useful when you need to call a cocos2d function from another thread. This function is thread safe. @since v3.0 */ void performFunctionInCocosThread( const std::function &function); protected: void removeHashElement(struct _hashSelectorEntry *element); void removeUpdateFromHash(struct _listEntry *entry); // update specific void priorityIn(struct _listEntry **list, Object *target, int priority, bool paused); void appendIn(struct _listEntry **list, Object *target, bool paused); float _timeScale; // // "updates with priority" stuff // struct _listEntry *_updatesNegList; // list of priority < 0 struct _listEntry *_updates0List; // list priority == 0 struct _listEntry *_updatesPosList; // list priority > 0 struct _hashUpdateEntry *_hashForUpdates; // hash used to fetch quickly the list entries for pause,delete,etc // Used for "selectors with interval" struct _hashSelectorEntry *_hashForTimers; struct _hashSelectorEntry *_currentTarget; bool _currentTargetSalvaged; // If true unschedule will not remove anything from a hash. Elements will only be marked for deletion. bool _updateHashLocked; Vector _scriptHandlerEntries; // Used for "perform Function" std::vector> _functionsToPerform; std::mutex _performMutex; }; // end of global group /// @} NS_CC_END #endif // __CCSCHEDULER_H__ ================================================ FILE: cocos2d/cocos/2d/CCScriptSupport.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCScriptSupport.h" #include "CCScheduler.h" bool CC_DLL cc_assert_script_compatible(const char *msg) { cocos2d::ScriptEngineProtocol* engine = cocos2d::ScriptEngineManager::getInstance()->getScriptEngine(); if (engine && engine->handleAssert(msg)) { return true; } return false; } NS_CC_BEGIN // #pragma mark - // #pragma mark ScriptHandlerEntry ScriptHandlerEntry* ScriptHandlerEntry::create(int handler) { ScriptHandlerEntry* entry = new ScriptHandlerEntry(handler); entry->autorelease(); return entry; } ScriptHandlerEntry::~ScriptHandlerEntry(void) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(_handler); } // #pragma mark - // #pragma mark SchedulerScriptHandlerEntry SchedulerScriptHandlerEntry* SchedulerScriptHandlerEntry::create(int handler, float interval, bool paused) { SchedulerScriptHandlerEntry* entry = new SchedulerScriptHandlerEntry(handler); entry->init(interval, paused); entry->autorelease(); return entry; } bool SchedulerScriptHandlerEntry::init(float interval, bool paused) { _timer = new Timer(); _timer->initWithScriptHandler(_handler, interval); _timer->autorelease(); _timer->retain(); _paused = paused; LUALOG("[LUA] ADD script schedule: %d, entryID: %d", _handler, _entryId); return true; } SchedulerScriptHandlerEntry::~SchedulerScriptHandlerEntry(void) { _timer->release(); LUALOG("[LUA] DEL script schedule %d, entryID: %d", _handler, _entryId); } // #pragma mark - // #pragma mark TouchScriptHandlerEntry TouchScriptHandlerEntry* TouchScriptHandlerEntry::create(int handler, bool isMultiTouches, int priority, bool swallowsTouches) { TouchScriptHandlerEntry* entry = new TouchScriptHandlerEntry(handler); entry->init(isMultiTouches, priority, swallowsTouches); entry->autorelease(); return entry; } TouchScriptHandlerEntry::~TouchScriptHandlerEntry(void) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(_handler); LUALOG("[LUA] Remove touch event handler: %d", _handler); } bool TouchScriptHandlerEntry::init(bool isMultiTouches, int priority, bool swallowsTouches) { _isMultiTouches = isMultiTouches; _priority = priority; _swallowsTouches = swallowsTouches; return true; } // #pragma mark - // #pragma mark ScriptEngineManager static ScriptEngineManager* s_pSharedScriptEngineManager = nullptr; ScriptEngineManager::~ScriptEngineManager(void) { removeScriptEngine(); } void ScriptEngineManager::setScriptEngine(ScriptEngineProtocol *scriptEngine) { removeScriptEngine(); _scriptEngine = scriptEngine; } void ScriptEngineManager::removeScriptEngine(void) { if (_scriptEngine) { delete _scriptEngine; _scriptEngine = nullptr; } } ScriptEngineManager* ScriptEngineManager::getInstance() { if (!s_pSharedScriptEngineManager) { s_pSharedScriptEngineManager = new ScriptEngineManager(); } return s_pSharedScriptEngineManager; } void ScriptEngineManager::destroyInstance() { if (s_pSharedScriptEngineManager) { delete s_pSharedScriptEngineManager; s_pSharedScriptEngineManager = nullptr; } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCScriptSupport.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SCRIPT_SUPPORT_H__ #define __SCRIPT_SUPPORT_H__ #include "platform/CCCommon.h" #include "CCTouch.h" #include "CCEventTouch.h" #include "CCEventKeyboard.h" #include "CCSet.h" #include #include #include typedef struct lua_State lua_State; NS_CC_BEGIN class Timer; class Layer; class MenuItem; class CallFunc; class Acceleration; enum ccScriptType { kScriptTypeNone = 0, kScriptTypeLua, kScriptTypeJavascript }; class ScriptHandlerEntry : public Object { public: static ScriptHandlerEntry* create(int handler); /** * @js NA * @lua NA */ ~ScriptHandlerEntry(void); int getHandler(void) { return _handler; } int getEntryId(void) { return _entryId; } protected: ScriptHandlerEntry(int handler) : _handler(handler) { static int newEntryId = 0; newEntryId++; _entryId = newEntryId; } int _handler; int _entryId; }; /** * @addtogroup script_support * @{ */ class SchedulerScriptHandlerEntry : public ScriptHandlerEntry { public: // nHandler return by tolua_ref_function(), called from LuaCocos2d.cpp /** * @js NA * @lua NA */ static SchedulerScriptHandlerEntry* create(int handler, float interval, bool paused); /** * @js NA * @lua NA */ ~SchedulerScriptHandlerEntry(void); /** * @js NA * @lua NA */ cocos2d::Timer* getTimer(void) { return _timer; } /** * @js NA * @lua NA */ bool isPaused(void) { return _paused; } /** * @js NA * @lua NA */ void markedForDeletion(void) { _markedForDeletion = true; } /** * @js NA * @lua NA */ bool isMarkedForDeletion(void) { return _markedForDeletion; } private: SchedulerScriptHandlerEntry(int handler) : ScriptHandlerEntry(handler) , _timer(nullptr) , _paused(false) , _markedForDeletion(false) { } bool init(float interval, bool paused); cocos2d::Timer* _timer; bool _paused; bool _markedForDeletion; }; class TouchScriptHandlerEntry : public ScriptHandlerEntry { public: /** * @js NA * @lua NA */ static TouchScriptHandlerEntry* create(int handler, bool isMultiTouches, int priority, bool swallowsTouches); /** * @js NA * @lua NA */ ~TouchScriptHandlerEntry(void); /** * @js NA * @lua NA */ bool isMultiTouches(void) { return _isMultiTouches; } /** * @js NA * @lua NA */ int getPriority(void) { return _priority; } /** * @js NA * @lua NA */ bool getSwallowsTouches(void) { return _swallowsTouches; } private: TouchScriptHandlerEntry(int handler) : ScriptHandlerEntry(handler) , _isMultiTouches(false) , _priority(0) , _swallowsTouches(false) { } bool init(bool isMultiTouches, int priority, bool swallowsTouches); bool _isMultiTouches; int _priority; bool _swallowsTouches; }; enum ScriptEventType { kNodeEvent = 0, kMenuClickedEvent, kCallFuncEvent, kScheduleEvent, kTouchEvent, kTouchesEvent, kKeypadEvent, kAccelerometerEvent, kControlEvent, kCommonEvent, }; struct BasicScriptData { // nativeobject:to get handler for lua or to get jsobject for js void* nativeObject; // value: a pointer to a object that already defined void* value; // Constructor /** * @js NA * @lua NA */ BasicScriptData(void* inObject,void* inValue = nullptr) : nativeObject(inObject),value(inValue) { } }; struct SchedulerScriptData { // lua use int handler; float elapse; // js use void* node; // Constructor /** * @js NA * @lua NA */ SchedulerScriptData(int inHandler,float inElapse,void* inNode = nullptr) : handler(inHandler), elapse(inElapse), node(inNode) { } }; struct TouchesScriptData { EventTouch::EventCode actionType; void* nativeObject; const std::vector& touches; // Constructor /** * @js NA * @lua NA */ TouchesScriptData(EventTouch::EventCode inActionType, void* inNativeObject, const std::vector& inTouches) : actionType(inActionType), nativeObject(inNativeObject), touches(inTouches) { } }; struct TouchScriptData { EventTouch::EventCode actionType; void* nativeObject; Touch* touch; // Constructor /** * @js NA * @lua NA */ TouchScriptData(EventTouch::EventCode inActionType, void* inNativeObject, Touch* inTouch) : actionType(inActionType), nativeObject(inNativeObject), touch(inTouch) { } }; struct KeypadScriptData { EventKeyboard::KeyCode actionType; void* nativeObject; // Constructor /** * @js NA * @lua NA */ KeypadScriptData(EventKeyboard::KeyCode inActionType,void* inNativeObject) : actionType(inActionType),nativeObject(inNativeObject) { } }; struct CommonScriptData { // Now this struct is only used in LuaBinding. int handler; char eventName[64]; Object* eventSource; char eventSourceClassName[64]; // Constructor /** * @js NA * @lua NA */ CommonScriptData(int inHandler,const char* inName,Object* inSource = nullptr,const char* inClassName = nullptr) : handler(inHandler), eventSource(inSource) { strncpy(eventName, inName, 64); if (nullptr == inClassName) { memset(eventSourceClassName, 0, 64*sizeof(char)); } else { strncpy(eventSourceClassName, inClassName, 64); } } }; struct ScriptEvent { ScriptEventType type; void* data; // Constructor /** * @js NA * @lua NA */ ScriptEvent(ScriptEventType inType,void* inData) : type(inType), data(inData) { } }; // Don't make ScriptEngineProtocol inherits from Object since setScriptEngine is invoked only once in AppDelegate.cpp, // It will affect the lifecycle of ScriptCore instance, the autorelease pool will be destroyed before destructing ScriptCore. // So a crash will appear on Win32 if you click the close button. class CC_DLL ScriptEngineProtocol { public: /** * @js NA * @lua NA */ virtual ~ScriptEngineProtocol() {}; /** Get script type * @js NA * @lua NA */ virtual ccScriptType getScriptType() { return kScriptTypeNone; }; /** Remove script object. * @js NA * @lua NA */ virtual void removeScriptObjectByObject(Object* obj) = 0; /** Remove script function handler, only LuaEngine class need to implement this function. * @js NA * @lua NA */ virtual void removeScriptHandler(int handler) {}; /** Reallocate script function handler, only LuaEngine class need to implement this function. * @js NA * @lua NA */ virtual int reallocateScriptHandler(int handler) { return 0;} /** @brief Execute script code contained in the given string. @param codes holding the valid script code that should be executed. @return 0 if the string is executed correctly. @return other if the string is executed wrongly. * @js NA * @lua NA */ virtual int executeString(const char* codes) = 0; /** @brief Execute a script file. @param filename String object holding the filename of the script file that is to be executed * @js NA * @lua NA */ virtual int executeScriptFile(const char* filename) = 0; /** @brief Execute a scripted global function. @brief The function should not take any parameters and should return an integer. @param functionName String object holding the name of the function, in the global script environment, that is to be executed. @return The integer value returned from the script function. * @js NA * @lua NA */ virtual int executeGlobalFunction(const char* functionName) = 0; /**when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in lua * @js NA * @lua NA */ virtual int sendEvent(ScriptEvent* evt) = 0; /** called by CCAssert to allow scripting engine to handle failed assertions * @return true if the assert was handled by the script engine, false otherwise. * @js NA * @lua NA */ virtual bool handleAssert(const char *msg) = 0; enum class ConfigType { NONE, COCOSTUDIO }; /** Parse configuration file */ virtual bool parseConfig(ConfigType type, const std::string& str) = 0; }; /** ScriptEngineManager is a singleton which holds an object instance of ScriptEngineProtocl It helps cocos2d-x and the user code to find back LuaEngine object @since v0.99.5-x-0.8.5 */ class CC_DLL ScriptEngineManager { public: /** * @js NA * @lua NA */ ~ScriptEngineManager(void); /** * @js NA * @lua NA */ ScriptEngineProtocol* getScriptEngine(void) { return _scriptEngine; } /** * @js NA * @lua NA */ void setScriptEngine(ScriptEngineProtocol *scriptEngine); /** * @js NA * @lua NA */ void removeScriptEngine(void); /** * @js NA * @lua NA */ static ScriptEngineManager* getInstance(); /** * @js NA * @lua NA */ static void destroyInstance(); /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static ScriptEngineManager* sharedManager() { return ScriptEngineManager::getInstance(); }; /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedManager() { ScriptEngineManager::destroyInstance(); }; private: ScriptEngineManager(void) : _scriptEngine(nullptr) { } ScriptEngineProtocol *_scriptEngine; }; // end of script_support group /// @} NS_CC_END #endif // __SCRIPT_SUPPORT_H__ ================================================ FILE: cocos2d/cocos/2d/CCShaderCache.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCShaderCache.h" #include "CCGLProgram.h" #include "ccMacros.h" #include "ccShaders.h" NS_CC_BEGIN enum { kShaderType_PositionTextureColor, kShaderType_PositionTextureColor_noMVP, kShaderType_PositionTextureColorAlphaTest, kShaderType_PositionColor, kShaderType_PositionColor_noMVP, kShaderType_PositionTexture, kShaderType_PositionTexture_uColor, kShaderType_PositionTextureA8Color, kShaderType_Position_uColor, kShaderType_PositionLengthTexureColor, kShaderType_LabelDistanceFieldNormal, kShaderType_LabelDistanceFieldGlow, kShaderType_LabelDistanceFieldOutline, kShaderType_LabelDistanceFieldShadow, kShaderType_MAX, }; static ShaderCache *_sharedShaderCache = 0; ShaderCache* ShaderCache::getInstance() { if (!_sharedShaderCache) { _sharedShaderCache = new ShaderCache(); if (!_sharedShaderCache->init()) { CC_SAFE_DELETE(_sharedShaderCache); } } return _sharedShaderCache; } void ShaderCache::destroyInstance() { CC_SAFE_RELEASE_NULL(_sharedShaderCache); } // XXX: deprecated ShaderCache* ShaderCache::sharedShaderCache() { return ShaderCache::getInstance(); } // XXX: deprecated void ShaderCache::purgeSharedShaderCache() { ShaderCache::destroyInstance(); } ShaderCache::ShaderCache() : _programs() { } ShaderCache::~ShaderCache() { for( auto it = _programs.begin(); it != _programs.end(); ++it ) { (it->second)->release(); } CCLOGINFO("deallocing ShaderCache: %p", this); } bool ShaderCache::init() { loadDefaultShaders(); return true; } void ShaderCache::loadDefaultShaders() { // Position Texture Color shader GLProgram *p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureColor); _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR, p ) ); // Position Texture Color without MVP shader p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureColor_noMVP); _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, p ) ); // Position Texture Color alpha test p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST, p) ); // // Position, Color shader // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionColor); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR, p) ); // // Position, Color shader no MVP // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionColor_noMVP); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP, p) ); // // Position Texture shader // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTexture); _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE, p) ); // // Position, Texture attribs, 1 Color as uniform shader // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTexture_uColor); _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR, p) ); // // Position Texture A8 Color shader // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureA8Color); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR, p) ); // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // p = new GLProgram(); loadDefaultShader(p, kShaderType_Position_uColor); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_U_COLOR, p) ); // // Position, Legth(TexCoords, Color (used by Draw Node basically ) // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionLengthTexureColor); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR, p) ); p = new GLProgram(); loadDefaultShader(p, kShaderType_LabelDistanceFieldNormal); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL, p) ); p = new GLProgram(); loadDefaultShader(p, kShaderType_LabelDistanceFieldGlow); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW, p) ); p = new GLProgram(); loadDefaultShader(p, kShaderType_LabelDistanceFieldOutline); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_OUTLINE, p) ); p = new GLProgram(); loadDefaultShader(p, kShaderType_LabelDistanceFieldShadow); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_SHADOW, p) ); } void ShaderCache::reloadDefaultShaders() { // reset all programs and reload them // Position Texture Color shader GLProgram *p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionTextureColor); // Position Texture Color without MVP shader p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); p->reset(); loadDefaultShader(p, kShaderType_PositionTextureColor_noMVP); // Position Texture Color alpha test p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); p->reset(); loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); // // Position, Color shader // p = getProgram(GLProgram::SHADER_NAME_POSITION_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionColor); // // Position, Color shader no MVP // p = getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP); loadDefaultShader(p, kShaderType_PositionColor_noMVP); // // Position Texture shader // p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE); p->reset(); loadDefaultShader(p, kShaderType_PositionTexture); // // Position, Texture attribs, 1 Color as uniform shader // p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionTexture_uColor); // // Position Texture A8 Color shader // p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionTextureA8Color); // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // p = getProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); p->reset(); loadDefaultShader(p, kShaderType_Position_uColor); // // Position, Legth(TexCoords, Color (used by Draw Node basically ) // p = getProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionLengthTexureColor); p = getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL); p->reset(); loadDefaultShader(p, kShaderType_LabelDistanceFieldNormal); p = getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW); p->reset(); loadDefaultShader(p, kShaderType_LabelDistanceFieldGlow); p = getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_OUTLINE); p->reset(); loadDefaultShader(p, kShaderType_LabelDistanceFieldOutline); p = getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_SHADOW); p->reset(); loadDefaultShader(p, kShaderType_LabelDistanceFieldShadow); } void ShaderCache::loadDefaultShader(GLProgram *p, int type) { switch (type) { case kShaderType_PositionTextureColor: p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColor_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionTextureColor_noMVP: p->initWithVertexShaderByteArray(ccPositionTextureColor_noMVP_vert, ccPositionTextureColor_noMVP_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionTextureColorAlphaTest: p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionColor: p->initWithVertexShaderByteArray(ccPositionColor_vert ,ccPositionColor_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); break; case kShaderType_PositionColor_noMVP: p->initWithVertexShaderByteArray(ccPositionTextureColor_noMVP_vert ,ccPositionColor_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); break; case kShaderType_PositionTexture: p->initWithVertexShaderByteArray(ccPositionTexture_vert ,ccPositionTexture_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionTexture_uColor: p->initWithVertexShaderByteArray(ccPositionTexture_uColor_vert, ccPositionTexture_uColor_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionTextureA8Color: p->initWithVertexShaderByteArray(ccPositionTextureA8Color_vert, ccPositionTextureA8Color_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_Position_uColor: p->initWithVertexShaderByteArray(ccPosition_uColor_vert, ccPosition_uColor_frag); p->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION); break; case kShaderType_PositionLengthTexureColor: p->initWithVertexShaderByteArray(ccPositionColorLengthTexture_vert, ccPositionColorLengthTexture_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); break; case kShaderType_LabelDistanceFieldNormal: p->initWithVertexShaderByteArray(ccLabelDistanceFieldNormal_vert, ccLabelDistanceFieldNormal_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_LabelDistanceFieldGlow: p->initWithVertexShaderByteArray(ccLabelDistanceFieldGlow_vert, ccLabelDistanceFieldGlow_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_LabelDistanceFieldOutline: p->initWithVertexShaderByteArray(ccLabelDistanceFieldOutline_vert, ccLabelDistanceFieldOutline_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_LabelDistanceFieldShadow: p->initWithVertexShaderByteArray(ccLabelDistanceFieldShadow_vert, ccLabelDistanceFieldShadow_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; default: CCLOG("cocos2d: %s:%d, error shader type", __FUNCTION__, __LINE__); return; } p->link(); p->updateUniforms(); CHECK_GL_ERROR_DEBUG(); } GLProgram* ShaderCache::getProgram(const std::string &key) { auto it = _programs.find(key); if( it != _programs.end() ) return it->second; return nullptr; } void ShaderCache::addProgram(GLProgram* program, const std::string &key) { program->retain(); _programs.insert( std::make_pair( key, program) ); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCShaderCache.h ================================================ /**************************************************************************** Copyright (c) 2011 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCSHADERCACHE_H__ #define __CCSHADERCACHE_H__ #include #include #include "CCDictionary.h" NS_CC_BEGIN class GLProgram; /** * @addtogroup shaders * @{ */ /** ShaderCache Singleton that stores manages GL shaders @since v2.0 */ class CC_DLL ShaderCache : public Object { public: /** * @js ctor */ ShaderCache(); /** * @js NA * @lua NA */ virtual ~ShaderCache(); /** returns the shared instance */ static ShaderCache* getInstance(); /** purges the cache. It releases the retained instance. */ static void destroyInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static ShaderCache* sharedShaderCache(); /** @deprecated Use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedShaderCache(); /** loads the default shaders */ void loadDefaultShaders(); /** reload the default shaders */ void reloadDefaultShaders(); /** returns a GL program for a given key */ GLProgram * getProgram(const std::string &key); /** @deprecated Use getProgram() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE GLProgram * programForKey(const std::string &key){ return getProgram(key); } /** adds a GLProgram to the cache for a given name */ void addProgram(GLProgram* program, const std::string &key); private: bool init(); void loadDefaultShader(GLProgram *program, int type); // Dictionary* _programs; std::unordered_map _programs; }; // end of shaders group /// @} NS_CC_END #endif /* __CCSHADERCACHE_H__ */ ================================================ FILE: cocos2d/cocos/2d/CCSprite.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCSpriteBatchNode.h" #include #include #include "CCAnimation.h" #include "CCAnimationCache.h" #include "ccConfig.h" #include "CCSprite.h" #include "CCSpriteFrame.h" #include "CCSpriteFrameCache.h" #include "CCTextureCache.h" #include "CCDrawingPrimitives.h" #include "CCShaderCache.h" #include "ccGLStateCache.h" #include "CCGLProgram.h" #include "CCDirector.h" #include "CCGeometry.h" #include "CCTexture2D.h" #include "CCAffineTransform.h" #include "TransformUtils.h" #include "CCProfiling.h" #include "renderer/CCRenderer.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCFrustum.h" // external #include "kazmath/GL/matrix.h" using namespace std; NS_CC_BEGIN #if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL #define RENDER_IN_SUBPIXEL #else #define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) #endif Sprite* Sprite::createWithTexture(Texture2D *texture) { Sprite *sprite = new Sprite(); if (sprite && sprite->initWithTexture(texture)) { sprite->autorelease(); return sprite; } CC_SAFE_DELETE(sprite); return nullptr; } Sprite* Sprite::createWithTexture(Texture2D *texture, const Rect& rect, bool rotated) { Sprite *sprite = new Sprite(); if (sprite && sprite->initWithTexture(texture, rect, rotated)) { sprite->autorelease(); return sprite; } CC_SAFE_DELETE(sprite); return nullptr; } Sprite* Sprite::create(const std::string& filename) { Sprite *sprite = new Sprite(); if (sprite && sprite->initWithFile(filename)) { sprite->autorelease(); return sprite; } CC_SAFE_DELETE(sprite); return nullptr; } Sprite* Sprite::create(const std::string& filename, const Rect& rect) { Sprite *sprite = new Sprite(); if (sprite && sprite->initWithFile(filename, rect)) { sprite->autorelease(); return sprite; } CC_SAFE_DELETE(sprite); return nullptr; } Sprite* Sprite::createWithSpriteFrame(SpriteFrame *spriteFrame) { Sprite *sprite = new Sprite(); if (spriteFrame && sprite && sprite->initWithSpriteFrame(spriteFrame)) { sprite->autorelease(); return sprite; } CC_SAFE_DELETE(sprite); return nullptr; } Sprite* Sprite::createWithSpriteFrameName(const std::string& spriteFrameName) { SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); #if COCOS2D_DEBUG > 0 char msg[256] = {0}; sprintf(msg, "Invalid spriteFrameName: %s", spriteFrameName.c_str()); CCASSERT(frame != nullptr, msg); #endif return createWithSpriteFrame(frame); } Sprite* Sprite::create() { Sprite *sprite = new Sprite(); if (sprite && sprite->init()) { sprite->autorelease(); return sprite; } CC_SAFE_DELETE(sprite); return nullptr; } bool Sprite::init(void) { return initWithTexture(nullptr, Rect::ZERO ); } bool Sprite::initWithTexture(Texture2D *texture) { CCASSERT(texture != nullptr, "Invalid texture for sprite"); Rect rect = Rect::ZERO; rect.size = texture->getContentSize(); return initWithTexture(texture, rect); } bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect) { return initWithTexture(texture, rect, false); } bool Sprite::initWithFile(const std::string& filename) { CCASSERT(filename.size()>0, "Invalid filename for sprite"); Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); if (texture) { Rect rect = Rect::ZERO; rect.size = texture->getContentSize(); return initWithTexture(texture, rect); } // don't release here. // when load texture failed, it's better to get a "transparent" sprite then a crashed program // this->release(); return false; } bool Sprite::initWithFile(const std::string &filename, const Rect& rect) { CCASSERT(filename.size()>0, "Invalid filename"); Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); if (texture) { return initWithTexture(texture, rect); } // don't release here. // when load texture failed, it's better to get a "transparent" sprite then a crashed program // this->release(); return false; } bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName) { CCASSERT(spriteFrameName.size() > 0, "Invalid spriteFrameName"); SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); return initWithSpriteFrame(frame); } bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame) { CCASSERT(spriteFrame != nullptr, ""); bool bRet = initWithTexture(spriteFrame->getTexture(), spriteFrame->getRect()); setSpriteFrame(spriteFrame); return bRet; } // designated initializer bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) { bool result; if (Node::init()) { _batchNode = nullptr; _recursiveDirty = false; setDirty(false); _opacityModifyRGB = true; _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _flippedX = _flippedY = false; // default transform anchor: center setAnchorPoint(Point(0.5f, 0.5f)); // zwoptex default values _offsetPosition = Point::ZERO; // clean the Quad memset(&_quad, 0, sizeof(_quad)); // Atlas: Color _quad.bl.colors = Color4B::WHITE; _quad.br.colors = Color4B::WHITE; _quad.tl.colors = Color4B::WHITE; _quad.tr.colors = Color4B::WHITE; // shader program setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); // update texture (calls updateBlendFunc) setTexture(texture); setTextureRect(rect, rotated, rect.size); // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" setBatchNode(nullptr); result = true; } else { result = false; } _recursiveDirty = true; setDirty(true); return result; } Sprite::Sprite(void) : _shouldBeHidden(false) , _texture(nullptr) { } Sprite::~Sprite(void) { CC_SAFE_RELEASE(_texture); } /* * Texture methods */ /* * This array is the data of a white image with 2 by 2 dimension. * It's used for creating a default texture when sprite's texture is set to nullptr. * Supposing codes as follows: * * auto sp = new Sprite(); * sp->init(); // Texture was set to nullptr, in order to make opacity and color to work correctly, we need to create a 2x2 white texture. * * The test is in "TestCpp/SpriteTest/Sprite without texture". */ static unsigned char cc_2x2_white_image[] = { // RGBA8888 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; #define CC_2x2_WHITE_IMAGE_KEY "/cc_2x2_white_image" void Sprite::setTexture(const std::string &filename) { Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); setTexture(texture); Rect rect = Rect::ZERO; rect.size = texture->getContentSize(); setTextureRect(rect); } void Sprite::setTexture(Texture2D *texture) { // If batchnode, then texture id should be the same CCASSERT(! _batchNode || texture->getName() == _batchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode"); // accept texture==nil as argument CCASSERT( !texture || dynamic_cast(texture), "setTexture expects a Texture2D. Invalid argument"); if (texture == nullptr) { // Gets the texture by key firstly. texture = Director::getInstance()->getTextureCache()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY); // If texture wasn't in cache, create it from RAW data. if (texture == nullptr) { Image* image = new Image(); bool isOK = image->initWithRawData(cc_2x2_white_image, sizeof(cc_2x2_white_image), 2, 2, 8); CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully."); texture = Director::getInstance()->getTextureCache()->addImage(image, CC_2x2_WHITE_IMAGE_KEY); CC_SAFE_RELEASE(image); } } if (!_batchNode && _texture != texture) { CC_SAFE_RETAIN(texture); CC_SAFE_RELEASE(_texture); _texture = texture; updateBlendFunc(); } } Texture2D* Sprite::getTexture() const { return _texture; } void Sprite::setTextureRect(const Rect& rect) { setTextureRect(rect, false, rect.size); } void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize) { _rectRotated = rotated; setContentSize(untrimmedSize); setVertexRect(rect); setTextureCoords(rect); Point relativeOffset = _unflippedOffsetPositionFromCenter; // issue #732 if (_flippedX) { relativeOffset.x = -relativeOffset.x; } if (_flippedY) { relativeOffset.y = -relativeOffset.y; } _offsetPosition.x = relativeOffset.x + (_contentSize.width - _rect.size.width) / 2; _offsetPosition.y = relativeOffset.y + (_contentSize.height - _rect.size.height) / 2; // rendering using batch node if (_batchNode) { // update dirty_, don't update recursiveDirty_ setDirty(true); } else { // self rendering // Atlas: Vertex float x1 = 0 + _offsetPosition.x; float y1 = 0 + _offsetPosition.y; float x2 = x1 + _rect.size.width; float y2 = y1 + _rect.size.height; // Don't update Z. _quad.bl.vertices = Vertex3F(x1, y1, 0); _quad.br.vertices = Vertex3F(x2, y1, 0); _quad.tl.vertices = Vertex3F(x1, y2, 0); _quad.tr.vertices = Vertex3F(x2, y2, 0); } } // override this method to generate "double scale" sprites void Sprite::setVertexRect(const Rect& rect) { _rect = rect; } void Sprite::setTextureCoords(Rect rect) { rect = CC_RECT_POINTS_TO_PIXELS(rect); Texture2D *tex = _batchNode ? _textureAtlas->getTexture() : _texture; if (! tex) { return; } float atlasWidth = (float)tex->getPixelsWide(); float atlasHeight = (float)tex->getPixelsHigh(); float left, right, top, bottom; if (_rectRotated) { #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL left = (2*rect.origin.x+1)/(2*atlasWidth); right = left+(rect.size.height*2-2)/(2*atlasWidth); top = (2*rect.origin.y+1)/(2*atlasHeight); bottom = top+(rect.size.width*2-2)/(2*atlasHeight); #else left = rect.origin.x/atlasWidth; right = (rect.origin.x+rect.size.height) / atlasWidth; top = rect.origin.y/atlasHeight; bottom = (rect.origin.y+rect.size.width) / atlasHeight; #endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL if (_flippedX) { CC_SWAP(top, bottom, float); } if (_flippedY) { CC_SWAP(left, right, float); } _quad.bl.texCoords.u = left; _quad.bl.texCoords.v = top; _quad.br.texCoords.u = left; _quad.br.texCoords.v = bottom; _quad.tl.texCoords.u = right; _quad.tl.texCoords.v = top; _quad.tr.texCoords.u = right; _quad.tr.texCoords.v = bottom; } else { #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL left = (2*rect.origin.x+1)/(2*atlasWidth); right = left + (rect.size.width*2-2)/(2*atlasWidth); top = (2*rect.origin.y+1)/(2*atlasHeight); bottom = top + (rect.size.height*2-2)/(2*atlasHeight); #else left = rect.origin.x/atlasWidth; right = (rect.origin.x + rect.size.width) / atlasWidth; top = rect.origin.y/atlasHeight; bottom = (rect.origin.y + rect.size.height) / atlasHeight; #endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL if(_flippedX) { CC_SWAP(left,right,float); } if(_flippedY) { CC_SWAP(top,bottom,float); } _quad.bl.texCoords.u = left; _quad.bl.texCoords.v = bottom; _quad.br.texCoords.u = right; _quad.br.texCoords.v = bottom; _quad.tl.texCoords.u = left; _quad.tl.texCoords.v = top; _quad.tr.texCoords.u = right; _quad.tr.texCoords.v = top; } } void Sprite::updateTransform(void) { CCASSERT(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode"); #if CC_USE_PHYSICS if (updatePhysicsTransform()) { setDirty(true); }; #endif // recalculate matrix only if it is dirty if( isDirty() ) { // If it is not visible, or one of its ancestors is not visible, then do nothing: if( !_visible || ( _parent && _parent != _batchNode && static_cast(_parent)->_shouldBeHidden) ) { _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vertex3F(0,0,0); _shouldBeHidden = true; } else { _shouldBeHidden = false; if( ! _parent || _parent == _batchNode ) { _transformToBatch = getNodeToParentTransform(); } else { CCASSERT( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); kmMat4 nodeToParent = getNodeToParentTransform(); kmMat4 parentTransform = static_cast(_parent)->_transformToBatch; kmMat4Multiply(&_transformToBatch, &parentTransform, &nodeToParent); } // // calculate the Quad based on the Affine Matrix // Size size = _rect.size; float x1 = _offsetPosition.x; float y1 = _offsetPosition.y; float x2 = x1 + size.width; float y2 = y1 + size.height; float x = _transformToBatch.mat[12]; float y = _transformToBatch.mat[13]; float cr = _transformToBatch.mat[0]; float sr = _transformToBatch.mat[1]; float cr2 = _transformToBatch.mat[5]; float sr2 = -_transformToBatch.mat[4]; float ax = x1 * cr - y1 * sr2 + x; float ay = x1 * sr + y1 * cr2 + y; float bx = x2 * cr - y1 * sr2 + x; float by = x2 * sr + y1 * cr2 + y; float cx = x2 * cr - y2 * sr2 + x; float cy = x2 * sr + y2 * cr2 + y; float dx = x1 * cr - y2 * sr2 + x; float dy = x1 * sr + y2 * cr2 + y; _quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ ); _quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ ); _quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ ); _quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS if (_textureAtlas) { _textureAtlas->updateQuad(&_quad, _atlasIndex); } _recursiveDirty = false; setDirty(false); } // MARMALADE CHANGED // recursively iterate over children /* if( _hasChildren ) { // MARMALADE: CHANGED TO USE Node* // NOTE THAT WE HAVE ALSO DEFINED virtual Node::updateTransform() arrayMakeObjectsPerformSelector(_children, updateTransform, Sprite*); }*/ Node::updateTransform(); #if CC_SPRITE_DEBUG_DRAW // draw bounding box Point vertices[4] = { Point( _quad.bl.vertices.x, _quad.bl.vertices.y ), Point( _quad.br.vertices.x, _quad.br.vertices.y ), Point( _quad.tr.vertices.x, _quad.tr.vertices.y ), Point( _quad.tl.vertices.x, _quad.tl.vertices.y ), }; ccDrawPoly(vertices, 4, true); #endif // CC_SPRITE_DEBUG_DRAW } // draw //void Sprite::draw(void) //{ // CC_PROFILER_START_CATEGORY(kProfilerCategorySprite, "CCSprite - draw"); // // CCASSERT(!_batchNode, "If Sprite is being rendered by SpriteBatchNode, Sprite#draw SHOULD NOT be called"); // // CC_NODE_DRAW_SETUP(); // // GL::blendFunc( _blendFunc.src, _blendFunc.dst ); // // GL::bindTexture2D( _texture->getName() ); // GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); // //#define kQuadSize sizeof(_quad.bl) //#ifdef EMSCRIPTEN // long offset = 0; // setGLBufferData(&_quad, 4 * kQuadSize, 0); //#else // long offset = (long)&_quad; //#endif // EMSCRIPTEN // // // vertex // int diff = offsetof( V3F_C4B_T2F, vertices); // glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); // // // texCoods // diff = offsetof( V3F_C4B_T2F, texCoords); // glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); // // // color // diff = offsetof( V3F_C4B_T2F, colors); // glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); // // // glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // // CHECK_GL_ERROR_DEBUG(); // // //#if CC_SPRITE_DEBUG_DRAW == 1 // // draw bounding box // Point vertices[4]={ // Point(_quad.tl.vertices.x,_quad.tl.vertices.y), // Point(_quad.bl.vertices.x,_quad.bl.vertices.y), // Point(_quad.br.vertices.x,_quad.br.vertices.y), // Point(_quad.tr.vertices.x,_quad.tr.vertices.y), // }; // ccDrawPoly(vertices, 4, true); //#elif CC_SPRITE_DEBUG_DRAW == 2 // // draw texture box // Size s = this->getTextureRect().size; // Point offsetPix = this->getOffsetPosition(); // Point vertices[4] = { // Point(offsetPix.x,offsetPix.y), Point(offsetPix.x+s.width,offsetPix.y), // Point(offsetPix.x+s.width,offsetPix.y+s.height), Point(offsetPix.x,offsetPix.y+s.height) // }; // ccDrawPoly(vertices, 4, true); //#endif // CC_SPRITE_DEBUG_DRAW // // CC_INCREMENT_GL_DRAWS(1); // // CC_PROFILER_STOP_CATEGORY(kProfilerCategorySprite, "CCSprite - draw"); //} void Sprite::draw(void) { //TODO implement z order _quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform); // if(culling()) { Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } } bool Sprite::culling() const { Frustum* frustum = Director::getInstance()->getFrustum(); //TODO optimize this transformation, should use parent's transformation instead kmMat4 worldTM = getNodeToWorldTransform(); //generate aabb // // calculate the Quad based on the Affine Matrix // Rect newRect = RectApplyTransform(_rect, worldTM); kmVec3 point = {newRect.getMinX(), newRect.getMinY(), _vertexZ}; AABB aabb(point,point); kmVec3Fill(&point,newRect.getMaxX(), newRect.getMinY(), _vertexZ); aabb.expand(point); kmVec3Fill(&point,newRect.getMinX(), newRect.getMaxY(), _vertexZ); aabb.expand(point); kmVec3Fill(&point,newRect.getMaxX(), newRect.getMaxY(), _vertexZ); aabb.expand(point); return Frustum::IntersectResult::OUTSIDE !=frustum->intersectAABB(aabb); } void Sprite::updateQuadVertices() { #if CC_USE_PHYSICS updatePhysicsTransform(); setDirty(true); #endif //TODO optimize the performance cache affineTransformation // recalculate matrix only if it is dirty if(isDirty()) { // if( ! _parent || _parent == (Node*)_batchNode ) // { // _transformToBatch = getNodeToParentTransform(); // } // else // { // CCASSERT( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); // _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast(_parent)->_transformToBatch ); // } //TODO optimize this transformation, should use parent's transformation instead _transformToBatch = getNodeToWorldTransform(); // // calculate the Quad based on the Affine Matrix // Rect newRect = RectApplyTransform(_rect, _transformToBatch); _quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMinX()), RENDER_IN_SUBPIXEL(newRect.getMinY()), _vertexZ ); _quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMaxX()), RENDER_IN_SUBPIXEL(newRect.getMinY()), _vertexZ ); _quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMinX()), RENDER_IN_SUBPIXEL(newRect.getMaxY()), _vertexZ ); _quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMaxX()), RENDER_IN_SUBPIXEL(newRect.getMaxY()), _vertexZ ); _recursiveDirty = false; setDirty(false); } } // Node overrides void Sprite::addChild(Node *child, int zOrder, int tag) { CCASSERT(child != nullptr, "Argument must be non-nullptr"); if (_batchNode) { Sprite* childSprite = dynamic_cast(child); CCASSERT( childSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode"); CCASSERT(childSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), ""); //put it in descendants array of batch node _batchNode->appendChild(childSprite); if (!_reorderChildDirty) { setReorderChildDirtyRecursively(); } } //CCNode already sets isReorderChildDirty_ so this needs to be after batchNode check Node::addChild(child, zOrder, tag); } void Sprite::reorderChild(Node *child, int zOrder) { CCASSERT(child != nullptr, "child must be non null"); CCASSERT(_children.contains(child), "child does not belong to this"); if( _batchNode && ! _reorderChildDirty) { setReorderChildDirtyRecursively(); _batchNode->reorderBatch(true); } Node::reorderChild(child, zOrder); } void Sprite::removeChild(Node *child, bool cleanup) { if (_batchNode) { _batchNode->removeSpriteFromAtlas((Sprite*)(child)); } Node::removeChild(child, cleanup); } void Sprite::removeAllChildrenWithCleanup(bool cleanup) { if (_batchNode) { for(const auto &child : _children) { Sprite* sprite = dynamic_cast(child); if (sprite) { _batchNode->removeSpriteFromAtlas(sprite); } } } Node::removeAllChildrenWithCleanup(cleanup); } void Sprite::sortAllChildren() { if (_reorderChildDirty) { #if 0 int i = 0, j = 0, length = _children->count(); // insertion sort for(i=1; i( _children->getObjectAtIndex(i) ); auto tempJ = static_cast( _children->getObjectAtIndex(j) ); //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller while(j>=0 && ( tempI->getLocalZOrder() < tempJ->getLocalZOrder() || ( tempI->getLocalZOrder() == tempJ->getLocalZOrder() && tempI->getOrderOfArrival() < tempJ->getOrderOfArrival() ) ) ) { _children->fastSetObject( tempJ, j+1 ); j = j-1; if(j>=0) tempJ = static_cast( _children->getObjectAtIndex(j) ); } _children->fastSetObject(tempI, j+1); } #else std::sort(std::begin(_children), std::end(_children), nodeComparisonLess); #endif if ( _batchNode) { for(const auto &child : _children) child->sortAllChildren(); } _reorderChildDirty = false; } } // // Node property overloads // used only when parent is SpriteBatchNode // void Sprite::setReorderChildDirtyRecursively(void) { //only set parents flag the first time if ( ! _reorderChildDirty ) { _reorderChildDirty = true; Node* node = static_cast(_parent); while (node && node != _batchNode) { static_cast(node)->setReorderChildDirtyRecursively(); node=node->getParent(); } } } void Sprite::setDirtyRecursively(bool bValue) { _recursiveDirty = bValue; setDirty(bValue); for(const auto &child: _children) { Sprite* sp = dynamic_cast(child); if (sp) { sp->setDirtyRecursively(true); } } } // XXX HACK: optimization #define SET_DIRTY_RECURSIVELY() { \ if (! _recursiveDirty) { \ _recursiveDirty = true; \ setDirty(true); \ if (!_children.empty()) \ setDirtyRecursively(true); \ } \ } void Sprite::setPosition(const Point& pos) { Node::setPosition(pos); SET_DIRTY_RECURSIVELY(); } void Sprite::setPosition(float x, float y) { Node::setPosition(x, y); SET_DIRTY_RECURSIVELY(); } void Sprite::setRotation(float rotation) { Node::setRotation(rotation); SET_DIRTY_RECURSIVELY(); } void Sprite::setRotationX(float fRotationX) { Node::setRotationX(fRotationX); SET_DIRTY_RECURSIVELY(); } void Sprite::setRotationY(float fRotationY) { Node::setRotationY(fRotationY); SET_DIRTY_RECURSIVELY(); } void Sprite::setSkewX(float sx) { Node::setSkewX(sx); SET_DIRTY_RECURSIVELY(); } void Sprite::setSkewY(float sy) { Node::setSkewY(sy); SET_DIRTY_RECURSIVELY(); } void Sprite::setScaleX(float scaleX) { Node::setScaleX(scaleX); SET_DIRTY_RECURSIVELY(); } void Sprite::setScaleY(float scaleY) { Node::setScaleY(scaleY); SET_DIRTY_RECURSIVELY(); } void Sprite::setScale(float fScale) { Node::setScale(fScale); SET_DIRTY_RECURSIVELY(); } void Sprite::setScale(float scaleX, float scaleY) { Node::setScale(scaleX, scaleY); SET_DIRTY_RECURSIVELY(); } void Sprite::setVertexZ(float fVertexZ) { Node::setVertexZ(fVertexZ); SET_DIRTY_RECURSIVELY(); } void Sprite::setAnchorPoint(const Point& anchor) { Node::setAnchorPoint(anchor); SET_DIRTY_RECURSIVELY(); } void Sprite::ignoreAnchorPointForPosition(bool value) { CCASSERT(! _batchNode, "ignoreAnchorPointForPosition is invalid in Sprite"); Node::ignoreAnchorPointForPosition(value); } void Sprite::setVisible(bool bVisible) { Node::setVisible(bVisible); SET_DIRTY_RECURSIVELY(); } void Sprite::setFlippedX(bool flippedX) { if (_flippedX != flippedX) { _flippedX = flippedX; setTextureRect(_rect, _rectRotated, _contentSize); } } bool Sprite::isFlippedX(void) const { return _flippedX; } void Sprite::setFlippedY(bool flippedY) { if (_flippedY != flippedY) { _flippedY = flippedY; setTextureRect(_rect, _rectRotated, _contentSize); } } bool Sprite::isFlippedY(void) const { return _flippedY; } // // RGBA protocol // void Sprite::updateColor(void) { Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); // special opacity for premultiplied textures if (_opacityModifyRGB) { color4.r *= _displayedOpacity/255.0f; color4.g *= _displayedOpacity/255.0f; color4.b *= _displayedOpacity/255.0f; } _quad.bl.colors = color4; _quad.br.colors = color4; _quad.tl.colors = color4; _quad.tr.colors = color4; // renders using batch node if (_batchNode) { if (_atlasIndex != INDEX_NOT_INITIALIZED) { _textureAtlas->updateQuad(&_quad, _atlasIndex); } else { // no need to set it recursively // update dirty_, don't update recursiveDirty_ setDirty(true); } } // self render // do nothing } void Sprite::setOpacityModifyRGB(bool modify) { if (_opacityModifyRGB != modify) { _opacityModifyRGB = modify; updateColor(); } } bool Sprite::isOpacityModifyRGB(void) const { return _opacityModifyRGB; } // Frames void Sprite::setSpriteFrame(const std::string &spriteFrameName) { SpriteFrameCache *cache = SpriteFrameCache::getInstance(); SpriteFrame *spriteFrame = cache->getSpriteFrameByName(spriteFrameName); CCASSERT(spriteFrame, "Invalid spriteFrameName"); setSpriteFrame(spriteFrame); } void Sprite::setSpriteFrame(SpriteFrame *spriteFrame) { _unflippedOffsetPositionFromCenter = spriteFrame->getOffset(); Texture2D *texture = spriteFrame->getTexture(); // update texture before updating texture rect if (texture != _texture) { setTexture(texture); } // update rect _rectRotated = spriteFrame->isRotated(); setTextureRect(spriteFrame->getRect(), _rectRotated, spriteFrame->getOriginalSize()); } void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex) { CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be nullptr"); Animation *a = AnimationCache::getInstance()->getAnimation(animationName); CCASSERT(a, "CCSprite#setDisplayFrameWithAnimationName: Frame not found"); AnimationFrame* frame = a->getFrames().at(frameIndex); CCASSERT(frame, "CCSprite#setDisplayFrame. Invalid frame"); setSpriteFrame(frame->getSpriteFrame()); } bool Sprite::isFrameDisplayed(SpriteFrame *frame) const { Rect r = frame->getRect(); return (r.equals(_rect) && frame->getTexture()->getName() == _texture->getName() && frame->getOffset().equals(_unflippedOffsetPositionFromCenter)); } SpriteFrame* Sprite::getSpriteFrame() const { return SpriteFrame::createWithTexture(_texture, CC_RECT_POINTS_TO_PIXELS(_rect), _rectRotated, CC_POINT_POINTS_TO_PIXELS(_unflippedOffsetPositionFromCenter), CC_SIZE_POINTS_TO_PIXELS(_contentSize)); } SpriteBatchNode* Sprite::getBatchNode() { return _batchNode; } void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode) { _batchNode = spriteBatchNode; // weak reference // self render if( ! _batchNode ) { _atlasIndex = INDEX_NOT_INITIALIZED; setTextureAtlas(nullptr); _recursiveDirty = false; setDirty(false); float x1 = _offsetPosition.x; float y1 = _offsetPosition.y; float x2 = x1 + _rect.size.width; float y2 = y1 + _rect.size.height; _quad.bl.vertices = Vertex3F( x1, y1, 0 ); _quad.br.vertices = Vertex3F( x2, y1, 0 ); _quad.tl.vertices = Vertex3F( x1, y2, 0 ); _quad.tr.vertices = Vertex3F( x2, y2, 0 ); } else { // using batch kmMat4Identity(&_transformToBatch); setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref } } // Texture protocol void Sprite::updateBlendFunc(void) { CCASSERT(! _batchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a SpriteBatchNode"); // it is possible to have an untextured sprite if (! _texture || ! _texture->hasPremultipliedAlpha()) { _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; setOpacityModifyRGB(false); } else { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; setOpacityModifyRGB(true); } } std::string Sprite::getDescription() const { int texture_id = -1; if( _batchNode ) texture_id = _batchNode->getTextureAtlas()->getTexture()->getName(); else texture_id = _texture->getName(); return StringUtils::format("", _tag, texture_id ); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCSprite.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SPRITE_NODE_CCSPRITE_H__ #define __SPRITE_NODE_CCSPRITE_H__ #include "CCNode.h" #include "CCProtocols.h" #include "CCTextureAtlas.h" #include "ccTypes.h" #include "CCDictionary.h" #include #ifdef EMSCRIPTEN #include "CCGLBufferedNode.h" #endif // EMSCRIPTEN #include "CCPhysicsBody.h" #include "renderer/CCQuadCommand.h" #include "kazmath/kazmath.h" NS_CC_BEGIN class SpriteBatchNode; class SpriteFrame; class Animation; class Rect; class Point; class Size; class Texture2D; struct transformValues_; /** * @addtogroup sprite_nodes * @{ */ /** * Sprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) ) * * Sprite can be created with an image, or with a sub-rectangle of an image. * * If the parent or any of its ancestors is a SpriteBatchNode then the following features/limitations are valid * - Features when the parent is a BatchNode: * - MUCH faster rendering, specially if the SpriteBatchNode has many children. All the children will be drawn in a single batch. * * - Limitations * - Camera is not supported yet (eg: OrbitCamera action doesn't work) * - GridBase actions are not supported (eg: Lens, Ripple, Twirl) * - The Alias/Antialias property belongs to SpriteBatchNode, so you can't individually set the aliased property. * - The Blending function property belongs to SpriteBatchNode, so you can't individually set the blending function property. * - Parallax scroller is not supported, but can be simulated with a "proxy" sprite. * * If the parent is an standard Node, then Sprite behaves like any other Node: * - It supports blending functions * - It supports aliasing / antialiasing * - But the rendering will be slower: 1 draw per children. * * The default anchorPoint in Sprite is (0.5, 0.5). */ class CC_DLL Sprite : public Node, public TextureProtocol { public: static const int INDEX_NOT_INITIALIZED = -1; /// Sprite invalid index on the SpriteBatchNode /// @{ /// @name Creators /** * Creates an empty sprite without texture. You can call setTexture method subsequently. * * @return An empty sprite object that is marked as autoreleased. */ static Sprite* create(); /** * Creates a sprite with an image filename. * * After creation, the rect of sprite will be the size of the image, * and the offset will be (0,0). * * @param filename The string which indicates a path to image file, e.g., "scene1/monster.png". * @return A valid sprite object that is marked as autoreleased. */ static Sprite* create(const std::string& filename); /** * Creates a sprite with an image filename and a rect. * * @param filename The string wich indicates a path to image file, e.g., "scene1/monster.png" * @param rect Only the contents inside rect of filename's texture will be applied for this sprite. * @return A valid sprite object that is marked as autoreleased. */ static Sprite* create(const std::string& filename, const Rect& rect); /** * Creates a sprite with an exsiting texture contained in a Texture2D object * After creation, the rect will be the size of the texture, and the offset will be (0,0). * * @param texture A pointer to a Texture2D object. * @return A valid sprite object that is marked as autoreleased. */ static Sprite* createWithTexture(Texture2D *texture); /** * Creates a sprite with a texture and a rect. * * After creation, the offset will be (0,0). * * @param texture A pointer to an existing Texture2D object. * You can use a Texture2D object for many sprites. * @param rect Only the contents inside the rect of this texture will be applied for this sprite. * @param rotated Whether or not the rect is rotated * @return A valid sprite object that is marked as autoreleased. */ static Sprite* createWithTexture(Texture2D *texture, const Rect& rect, bool rotated=false); /** * Creates a sprite with an sprite frame. * * @param pSpriteFrame A sprite frame which involves a texture and a rect * @return A valid sprite object that is marked as autoreleased. */ static Sprite* createWithSpriteFrame(SpriteFrame *pSpriteFrame); /** * Creates a sprite with an sprite frame name. * * A SpriteFrame will be fetched from the SpriteFrameCache by spriteFrameName param. * If the SpriteFrame doesn't exist it will raise an exception. * * @param spriteFrameName A null terminated string which indicates the sprite frame name. * @return A valid sprite object that is marked as autoreleased. */ static Sprite* createWithSpriteFrameName(const std::string& spriteFrameName); /// @} end of creators group /// @{ /// @name BatchNode methods /** * Updates the quad according the rotation, position, scale values. */ virtual void updateTransform(void); /** * Returns the batch node object if this sprite is rendered by SpriteBatchNode * * @return The SpriteBatchNode object if this sprite is rendered by SpriteBatchNode, * nullptr if the sprite isn't used batch node. */ virtual SpriteBatchNode* getBatchNode(void); /** * Sets the batch node to sprite * @warning This method is not recommended for game developers. Sample code for using batch node * @code * SpriteBatchNode *batch = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 15); * Sprite *sprite = Sprite::createWithTexture(batch->getTexture(), Rect(0, 0, 57, 57)); * batch->addChild(sprite); * layer->addChild(batch); * @endcode */ virtual void setBatchNode(SpriteBatchNode *spriteBatchNode); /// @} end of BatchNode methods /// @{ /// @name Texture / Frame methods /** Sets a new texture (from a filename) to the sprite. It will call `setTextureRect()` with the texture's content size. TODO: The whole Sprite API needs to be reviewed. */ virtual void setTexture(const std::string &filename ); /** Sets a new texture to the sprite. The Texture's rect is not changed. */ virtual void setTexture(Texture2D *texture) override; /** returns the Texture2D object used by the sprite */ virtual Texture2D* getTexture() const override; /** * Updates the texture rect of the Sprite in points. * It will call setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize) with \p rotated = false, and \p utrimmedSize = rect.size. */ virtual void setTextureRect(const Rect& rect); /** * Sets the texture rect, rectRotated and untrimmed size of the Sprite in points. * It will update the texture coordinates and the vertex rectangle. */ virtual void setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize); /** * Sets the vertex rect. * It will be called internally by setTextureRect. * Useful if you want to create 2x images from SD images in Retina Display. * Do not call it manually. Use setTextureRect instead. */ virtual void setVertexRect(const Rect& rect); /** * Sets a new SpriteFrame to the Sprite. */ virtual void setSpriteFrame(const std::string &spriteFrameName); virtual void setSpriteFrame(SpriteFrame* newFrame); /** @deprecated Use `setSpriteFrame()` instead. */ CC_DEPRECATED_ATTRIBUTE virtual void setDisplayFrame(SpriteFrame *newFrame) { setSpriteFrame(newFrame); } /** * Returns whether or not a SpriteFrame is being displayed */ virtual bool isFrameDisplayed(SpriteFrame *pFrame) const; /** * Returns the current displayed frame. */ virtual SpriteFrame* getSpriteFrame() const; /** @deprecated Use `getSpriteFrame()` instead */ CC_DEPRECATED_ATTRIBUTE virtual SpriteFrame* getDisplayFrame() const { return getSpriteFrame(); } /** @deprecated Use `getSpriteFrame()` instead */ CC_DEPRECATED_ATTRIBUTE virtual SpriteFrame* displayFrame() const { return getSpriteFrame(); }; /// @} End of frames methods /// @{ /// @name Animation methods /** * Changes the display frame with animation name and index. * The animation name will be get from the AnimationCache */ virtual void setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex); /// @} /// @{ /// @name Sprite Properties' setter/getters /** * Whether or not the Sprite needs to be updated in the Atlas. * * @return true if the sprite needs to be updated in the Atlas, false otherwise. */ virtual bool isDirty(void) const { return _dirty; } /** * Makes the Sprite to be updated in the Atlas. */ virtual void setDirty(bool bDirty) { _dirty = bDirty; } /** * Returns the quad (tex coords, vertex coords and color) information. * @js NA * @lua NA */ inline V3F_C4B_T2F_Quad getQuad(void) const { return _quad; } /** * Returns whether or not the texture rectangle is rotated. */ inline bool isTextureRectRotated(void) const { return _rectRotated; } /** * Returns the index used on the TextureAtlas. */ inline ssize_t getAtlasIndex(void) const { return _atlasIndex; } /** * Sets the index used on the TextureAtlas. * @warning Don't modify this value unless you know what you are doing */ inline void setAtlasIndex(ssize_t atlasIndex) { _atlasIndex = atlasIndex; } /** * Returns the rect of the Sprite in points */ inline const Rect& getTextureRect(void) { return _rect; } /** * Gets the weak reference of the TextureAtlas when the sprite is rendered using via SpriteBatchNode */ inline TextureAtlas* getTextureAtlas(void) { return _textureAtlas; } /** * Sets the weak reference of the TextureAtlas when the sprite is rendered using via SpriteBatchNode */ inline void setTextureAtlas(TextureAtlas *pobTextureAtlas) { _textureAtlas = pobTextureAtlas; } /** * Gets the offset position of the sprite. Calculated automatically by editors like Zwoptex. */ inline const Point& getOffsetPosition(void) const { return _offsetPosition; } /** * Returns the flag which indicates whether the sprite is flipped horizontally or not. * * It only flips the texture of the sprite, and not the texture of the sprite's children. * Also, flipping the texture doesn't alter the anchorPoint. * If you want to flip the anchorPoint too, and/or to flip the children too use: * sprite->setScaleX(sprite->getScaleX() * -1); * * @return true if the sprite is flipped horizontally, false otherwise. */ bool isFlippedX(void) const; /** * Sets whether the sprite should be flipped horizontally or not. * * @param flippedX true if the sprite should be flipped horizontally, false otherwise. */ void setFlippedX(bool flippedX); /** @deprecated Use isFlippedX() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE bool isFlipX() { return isFlippedX(); }; /** @deprecated Use setFlippedX() instead */ CC_DEPRECATED_ATTRIBUTE void setFlipX(bool flippedX) { setFlippedX(flippedX); }; /** * Return the flag which indicates whether the sprite is flipped vertically or not. * * It only flips the texture of the sprite, and not the texture of the sprite's children. * Also, flipping the texture doesn't alter the anchorPoint. * If you want to flip the anchorPoint too, and/or to flip the children too use: * sprite->setScaleY(sprite->getScaleY() * -1); * * @return true if the sprite is flipped vertically, false otherwise. */ bool isFlippedY(void) const; /** * Sets whether the sprite should be flipped vertically or not. * * @param flippedY true if the sprite should be flipped vertically, false otherwise. */ void setFlippedY(bool flippedY); /// @} End of Sprite properties getter/setters /** @deprecated Use isFlippedY() instead */ CC_DEPRECATED_ATTRIBUTE bool isFlipY() { return isFlippedY(); }; /** @deprecated Use setFlippedY() instead */ CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flippedY) { setFlippedY(flippedY); }; // // Overrides // /// @{ /// @name Functions inherited from TextureProtocol /** *@code *When this function bound into js or lua,the parameter will be changed *In js: var setBlendFunc(var src, var dst) *In lua: local setBlendFunc(local src, local dst) *@endcode */ inline void setBlendFunc(const BlendFunc &blendFunc) override { _blendFunc = blendFunc; } /** * @js NA * @lua NA */ inline const BlendFunc& getBlendFunc() const override { return _blendFunc; } /// @} virtual std::string getDescription() const override; /// @{ /// @name Functions inherited from Node virtual void setScaleX(float scaleX) override; virtual void setScaleY(float scaleY) override; virtual void setScale(float scaleX, float scaleY) override; /** * @js NA * @lua NA */ virtual void setPosition(const Point& pos) override; virtual void setPosition(float x, float y) override; virtual void setRotation(float rotation) override; virtual void setRotationX(float rotationX) override; virtual void setRotationY(float rotationY) override; virtual void setSkewX(float sx) override; virtual void setSkewY(float sy) override; virtual void removeChild(Node* child, bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void reorderChild(Node *child, int zOrder) override; using Node::addChild; virtual void addChild(Node *child, int zOrder, int tag) override; virtual void sortAllChildren() override; virtual void setScale(float scale) override; virtual void setVertexZ(float vertexZ) override; virtual void setAnchorPoint(const Point& anchor) override; virtual void ignoreAnchorPointForPosition(bool value) override; virtual void setVisible(bool bVisible) override; virtual void updateQuadVertices(); virtual void draw(void) override; virtual void setOpacityModifyRGB(bool modify) override; virtual bool isOpacityModifyRGB(void) const override; /// @} protected: Sprite(void); virtual ~Sprite(void); /* Initializes an empty sprite with nothing init. */ virtual bool init(void); /** * Initializes a sprite with a texture. * * After initialization, the rect used will be the size of the texture, and the offset will be (0,0). * * @param texture A pointer to an existing Texture2D object. * You can use a Texture2D object for many sprites. * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithTexture(Texture2D *texture); /** * Initializes a sprite with a texture and a rect. * * After initialization, the offset will be (0,0). * * @param texture A pointer to an exisiting Texture2D object. * You can use a Texture2D object for many sprites. * @param rect Only the contents inside rect of this texture will be applied for this sprite. * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithTexture(Texture2D *texture, const Rect& rect); /** * Initializes a sprite with a texture and a rect in points, optionally rotated. * * After initialization, the offset will be (0,0). * @note This is the designated initializer. * * @param texture A Texture2D object whose texture will be applied to this sprite. * @param rect A rectangle assigned the contents of texture. * @param rotated Whether or not the texture rectangle is rotated. * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithTexture(Texture2D *texture, const Rect& rect, bool rotated); /** * Initializes a sprite with an SpriteFrame. The texture and rect in SpriteFrame will be applied on this sprite * * @param pSpriteFrame A SpriteFrame object. It should includes a valid texture and a rect * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithSpriteFrame(SpriteFrame *pSpriteFrame); /** * Initializes a sprite with an sprite frame name. * * A SpriteFrame will be fetched from the SpriteFrameCache by name. * If the SpriteFrame doesn't exist it will raise an exception. * * @param spriteFrameName A key string that can fected a volid SpriteFrame from SpriteFrameCache * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithSpriteFrameName(const std::string& spriteFrameName); /** * Initializes a sprite with an image filename. * * This method will find filename from local file system, load its content to Texture2D, * then use Texture2D to create a sprite. * After initialization, the rect used will be the size of the image. The offset will be (0,0). * * @param filename The path to an image file in local file system * @return true if the sprite is initialized properly, false otherwise. * @js init * @lua init */ virtual bool initWithFile(const std::string& filename); /** * Initializes a sprite with an image filename, and a rect. * * This method will find filename from local file system, load its content to Texture2D, * then use Texture2D to create a sprite. * After initialization, the offset will be (0,0). * * @param filename The path to an image file in local file system. * @param rect The rectangle assigned the content area from texture. * @return true if the sprite is initialized properly, false otherwise. * @js init * @lua init */ virtual bool initWithFile(const std::string& filename, const Rect& rect); void updateColor(void); virtual void setTextureCoords(Rect rect); virtual void updateBlendFunc(void); virtual void setReorderChildDirtyRecursively(void); virtual void setDirtyRecursively(bool bValue); bool culling() const; // // Data used when the sprite is rendered using a SpriteSheet // TextureAtlas* _textureAtlas; /// SpriteBatchNode texture atlas (weak reference) ssize_t _atlasIndex; /// Absolute (real) Index on the SpriteSheet SpriteBatchNode* _batchNode; /// Used batch node (weak reference) bool _dirty; /// Whether the sprite needs to be updated bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible kmMat4 _transformToBatch; // // Data used when the sprite is self-rendered // BlendFunc _blendFunc; /// It's required for TextureProtocol inheritance Texture2D* _texture; /// Texture2D object that is used to render the sprite QuadCommand _quadCommand; /// quad command // // Shared data // // texture Rect _rect; /// Retangle of Texture2D bool _rectRotated; /// Whether the texture is rotated // Offset Position (used by Zwoptex) Point _offsetPosition; Point _unflippedOffsetPositionFromCenter; // vertex coords, texture coords and color info V3F_C4B_T2F_Quad _quad; // opacity and RGB protocol bool _opacityModifyRGB; // image is flipped bool _flippedX; /// Whether the sprite is flipped horizontally or not bool _flippedY; /// Whether the sprite is flipped vertically or not private: CC_DISALLOW_COPY_AND_ASSIGN(Sprite); }; // end of sprite_nodes group /// @} NS_CC_END #endif // __SPRITE_NODE_CCSPRITE_H__ ================================================ FILE: cocos2d/cocos/2d/CCSpriteBatchNode.cpp ================================================ /**************************************************************************** Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2009 Matt Oswald Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCSpriteBatchNode.h" #include #include "ccConfig.h" #include "CCSprite.h" #include "CCGrid.h" #include "CCDrawingPrimitives.h" #include "CCTextureCache.h" #include "CCShaderCache.h" #include "CCGLProgram.h" #include "ccGLStateCache.h" #include "CCDirector.h" #include "TransformUtils.h" #include "CCProfiling.h" #include "CCLayer.h" #include "CCScene.h" #include "renderer/CCRenderer.h" #include "renderer/CCQuadCommand.h" // external #include "kazmath/GL/matrix.h" NS_CC_BEGIN /* * creation with Texture2D */ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, ssize_t capacity/* = DEFAULT_CAPACITY*/) { SpriteBatchNode *batchNode = new SpriteBatchNode(); batchNode->initWithTexture(tex, capacity); batchNode->autorelease(); return batchNode; } /* * creation with File Image */ SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/) { SpriteBatchNode *batchNode = new SpriteBatchNode(); batchNode->initWithFile(fileImage, capacity); batchNode->autorelease(); return batchNode; } /* * init with Texture2D */ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity) { CCASSERT(capacity>=0, "Capacity must be >= 0"); _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _textureAtlas = new TextureAtlas(); if (capacity == 0) { capacity = DEFAULT_CAPACITY; } _textureAtlas->initWithTexture(tex, capacity); updateBlendFunc(); _children.reserve(capacity); _descendants.reserve(capacity); setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } bool SpriteBatchNode::init() { Texture2D * texture = new Texture2D(); texture->autorelease(); return this->initWithTexture(texture, 0); } /* * init with FileImage */ bool SpriteBatchNode::initWithFile(const std::string& fileImage, ssize_t capacity) { Texture2D *texture2D = Director::getInstance()->getTextureCache()->addImage(fileImage); return initWithTexture(texture2D, capacity); } SpriteBatchNode::SpriteBatchNode() : _textureAtlas(nullptr) { } SpriteBatchNode::~SpriteBatchNode() { CC_SAFE_RELEASE(_textureAtlas); } // override visit // don't call visit on it's children void SpriteBatchNode::visit(void) { CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); // CAREFUL: // This visit is almost identical to CocosNode#visit // with the exception that it doesn't call visit on it's children // // The alternative is to have a void Sprite#visit, but // although this is less maintainable, is faster // if (! _visible) { return; } kmGLPushMatrix(); sortAllChildren(); transform(); draw(); kmGLPopMatrix(); setOrderOfArrival(0); CC_PROFILER_STOP_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); } void SpriteBatchNode::addChild(Node *child, int zOrder, int tag) { CCASSERT(child != nullptr, "child should not be null"); CCASSERT(dynamic_cast(child) != nullptr, "CCSpriteBatchNode only supports Sprites as children"); Sprite *sprite = static_cast(child); // check Sprite is using the same texture id CCASSERT(sprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCSprite is not using the same texture id"); Node::addChild(child, zOrder, tag); appendChild(sprite); } // override reorderChild void SpriteBatchNode::reorderChild(Node *child, int zOrder) { CCASSERT(child != nullptr, "the child should not be null"); CCASSERT(_children.contains(child), "Child doesn't belong to Sprite"); if (zOrder == child->getLocalZOrder()) { return; } //set the z-order and sort later Node::reorderChild(child, zOrder); } // override remove child void SpriteBatchNode::removeChild(Node *child, bool cleanup) { Sprite *sprite = static_cast(child); // explicit null handling if (sprite == nullptr) { return; } CCASSERT(_children.contains(sprite), "sprite batch node should contain the child"); // cleanup before removing removeSpriteFromAtlas(sprite); Node::removeChild(sprite, cleanup); } void SpriteBatchNode::removeChildAtIndex(ssize_t index, bool doCleanup) { CCASSERT(index>=0 && index < _children.size(), "Invalid index"); removeChild(_children.at(index), doCleanup); } void SpriteBatchNode::removeAllChildrenWithCleanup(bool doCleanup) { // Invalidate atlas index. issue #569 // useSelfRender should be performed on all descendants. issue #1216 for(const auto &sprite: _descendants) { sprite->setBatchNode(nullptr); } Node::removeAllChildrenWithCleanup(doCleanup); _descendants.clear(); _textureAtlas->removeAllQuads(); } //override sortAllChildren void SpriteBatchNode::sortAllChildren() { if (_reorderChildDirty) { std::sort(std::begin(_children), std::end(_children), nodeComparisonLess); //sorted now check all children if (!_children.empty()) { //first sort all children recursively based on zOrder for(const auto &child: _children) { child->sortAllChildren(); } ssize_t index=0; //fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact) // and at the same time reorder descendants and the quads to the right index for(const auto &child: _children) { Sprite* sp = static_cast(child); updateAtlasIndex(sp, &index); } } _reorderChildDirty=false; } } void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, ssize_t* curIndex) { auto& array = sprite->getChildren(); auto count = array.size(); ssize_t oldIndex = 0; if( count == 0 ) { oldIndex = sprite->getAtlasIndex(); sprite->setAtlasIndex(*curIndex); sprite->setOrderOfArrival(0); if (oldIndex != *curIndex){ swap(oldIndex, *curIndex); } (*curIndex)++; } else { bool needNewIndex=true; if (array.at(0)->getLocalZOrder() >= 0) { //all children are in front of the parent oldIndex = sprite->getAtlasIndex(); sprite->setAtlasIndex(*curIndex); sprite->setOrderOfArrival(0); if (oldIndex != *curIndex) { swap(oldIndex, *curIndex); } (*curIndex)++; needNewIndex = false; } for(const auto &child: array) { Sprite* sp = static_cast(child); if (needNewIndex && sp->getLocalZOrder() >= 0) { oldIndex = sprite->getAtlasIndex(); sprite->setAtlasIndex(*curIndex); sprite->setOrderOfArrival(0); if (oldIndex != *curIndex) { this->swap(oldIndex, *curIndex); } (*curIndex)++; needNewIndex = false; } updateAtlasIndex(sp, curIndex); } if (needNewIndex) {//all children have a zOrder < 0) oldIndex = sprite->getAtlasIndex(); sprite->setAtlasIndex(*curIndex); sprite->setOrderOfArrival(0); if (oldIndex != *curIndex) { swap(oldIndex, *curIndex); } (*curIndex)++; } } } void SpriteBatchNode::swap(ssize_t oldIndex, ssize_t newIndex) { CCASSERT(oldIndex>=0 && oldIndex < (int)_descendants.size() && newIndex >=0 && newIndex < (int)_descendants.size(), "Invalid index"); V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads(); std::swap( quads[oldIndex], quads[newIndex] ); //update the index of other swapped item auto oldIt = std::next( _descendants.begin(), oldIndex ); auto newIt = std::next( _descendants.begin(), newIndex ); (*newIt)->setAtlasIndex(oldIndex); // (*oldIt)->setAtlasIndex(newIndex); std::swap( *oldIt, *newIt ); } void SpriteBatchNode::reorderBatch(bool reorder) { _reorderChildDirty=reorder; } void SpriteBatchNode::draw() { // Optimization: Fast Dispatch if( _textureAtlas->getTotalQuads() == 0 ) { return; } for(const auto &child: _children) child->updateTransform(); _batchCommand.init( _globalZOrder, _shaderProgram, _blendFunc, _textureAtlas, _modelViewTransform); Director::getInstance()->getRenderer()->addCommand(&_batchCommand); } void SpriteBatchNode::increaseAtlasCapacity(void) { // if we're going beyond the current TextureAtlas's capacity, // all the previously initialized sprites will need to redo their texture coords // this is likely computationally expensive ssize_t quantity = (_textureAtlas->getCapacity() + 1) * 4 / 3; CCLOG("cocos2d: SpriteBatchNode: resizing TextureAtlas capacity from [%d] to [%d].", static_cast(_textureAtlas->getCapacity()), static_cast(quantity)); if (! _textureAtlas->resizeCapacity(quantity)) { // serious problems CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas"); CCASSERT(false, "Not enough memory to resize the atlas"); } } ssize_t SpriteBatchNode::rebuildIndexInOrder(Sprite *parent, ssize_t index) { CCASSERT(index>=0 && index < _children.size(), "Invalid index"); auto& children = parent->getChildren(); for(const auto &child: children) { Sprite* sp = static_cast(child); if (sp && (sp->getLocalZOrder() < 0)) { index = rebuildIndexInOrder(sp, index); } } // ignore self (batch node) if (! parent->isEqual(this)) { parent->setAtlasIndex(index); index++; } for(const auto &child: children) { Sprite* sp = static_cast(child); if (sp && (sp->getLocalZOrder() >= 0)) { index = rebuildIndexInOrder(sp, index); } } return index; } ssize_t SpriteBatchNode::highestAtlasIndexInChild(Sprite *sprite) { auto& children = sprite->getChildren(); if (children.size() == 0) { return sprite->getAtlasIndex(); } else { return highestAtlasIndexInChild( static_cast(children.back())); } } ssize_t SpriteBatchNode::lowestAtlasIndexInChild(Sprite *sprite) { auto& children = sprite->getChildren(); if (children.size() == 0) { return sprite->getAtlasIndex(); } else { return lowestAtlasIndexInChild(static_cast(children.at(0))); } } ssize_t SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ) { auto& siblings = sprite->getParent()->getChildren(); auto childIndex = siblings.getIndex(sprite); // ignore parent Z if parent is spriteSheet bool ignoreParent = (SpriteBatchNode*)(sprite->getParent()) == this; Sprite *prev = nullptr; if (childIndex > 0 && childIndex != -1) { prev = static_cast(siblings.at(childIndex - 1)); } // first child of the sprite sheet if (ignoreParent) { if (childIndex == 0) { return 0; } return highestAtlasIndexInChild(prev) + 1; } // parent is a Sprite, so, it must be taken into account // first child of an Sprite ? if (childIndex == 0) { Sprite *p = static_cast(sprite->getParent()); // less than parent and brothers if (nZ < 0) { return p->getAtlasIndex(); } else { return p->getAtlasIndex() + 1; } } else { // previous & sprite belong to the same branch if ((prev->getLocalZOrder() < 0 && nZ < 0) || (prev->getLocalZOrder() >= 0 && nZ >= 0)) { return highestAtlasIndexInChild(prev) + 1; } // else (previous < 0 and sprite >= 0 ) Sprite *p = static_cast(sprite->getParent()); return p->getAtlasIndex() + 1; } // Should not happen. Error calculating Z on SpriteSheet CCASSERT(0, "should not run here"); return 0; } // addChild helper, faster than insertChild void SpriteBatchNode::appendChild(Sprite* sprite) { _reorderChildDirty=true; sprite->setBatchNode(this); sprite->setDirty(true); if(_textureAtlas->getTotalQuads() == _textureAtlas->getCapacity()) { increaseAtlasCapacity(); } _descendants.push_back(sprite); int index = static_cast(_descendants.size()-1); sprite->setAtlasIndex(index); V3F_C4B_T2F_Quad quad = sprite->getQuad(); _textureAtlas->insertQuad(&quad, index); // add children recursively auto& children = sprite->getChildren(); for(const auto &child: children) { appendChild(static_cast(child)); } } void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) { // remove from TextureAtlas _textureAtlas->removeQuadAtIndex(sprite->getAtlasIndex()); // Cleanup sprite. It might be reused (issue #569) sprite->setBatchNode(nullptr); auto it = std::find(_descendants.begin(), _descendants.end(), sprite ); if( it != _descendants.end() ) { auto next = std::next(it); for(; next != _descendants.end(); ++next) { Sprite *spr = *next; spr->setAtlasIndex( spr->getAtlasIndex() - 1 ); } _descendants.erase(it); } // remove children recursively auto& children = sprite->getChildren(); for(const auto &obj: children) { Sprite* child = static_cast(obj); if (child) { removeSpriteFromAtlas(child); } } } void SpriteBatchNode::updateBlendFunc(void) { if (! _textureAtlas->getTexture()->hasPremultipliedAlpha()) _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } // CocosNodeTexture protocol void SpriteBatchNode::setBlendFunc(const BlendFunc &blendFunc) { _blendFunc = blendFunc; } const BlendFunc& SpriteBatchNode::getBlendFunc(void) const { return _blendFunc; } Texture2D* SpriteBatchNode::getTexture(void) const { return _textureAtlas->getTexture(); } void SpriteBatchNode::setTexture(Texture2D *texture) { _textureAtlas->setTexture(texture); updateBlendFunc(); } // SpriteSheet Extension //implementation SpriteSheet (TMXTiledMapExtension) void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, ssize_t index) { CCASSERT( sprite != nullptr, "Argument must be non-nullptr"); CCASSERT( dynamic_cast(sprite), "CCSpriteBatchNode only supports Sprites as children"); // make needed room while(index >= _textureAtlas->getCapacity() || _textureAtlas->getCapacity() == _textureAtlas->getTotalQuads()) { this->increaseAtlasCapacity(); } // // update the quad directly. Don't add the sprite to the scene graph // sprite->setBatchNode(this); sprite->setAtlasIndex(index); V3F_C4B_T2F_Quad quad = sprite->getQuad(); _textureAtlas->insertQuad(&quad, index); // XXX: updateTransform will update the textureAtlas too, using updateQuad. // XXX: so, it should be AFTER the insertQuad sprite->setDirty(true); sprite->updateTransform(); } void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, ssize_t index) { CCASSERT(sprite != nullptr, "Argument must be non-nil"); CCASSERT(dynamic_cast(sprite) != nullptr, "CCSpriteBatchNode only supports Sprites as children"); // make needed room while (index >= _textureAtlas->getCapacity() || _textureAtlas->getCapacity() == _textureAtlas->getTotalQuads()) { this->increaseAtlasCapacity(); } // // update the quad directly. Don't add the sprite to the scene graph // sprite->setBatchNode(this); sprite->setAtlasIndex(index); sprite->setDirty(true); // UpdateTransform updates the textureAtlas quad sprite->updateTransform(); } SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int aTag) { CCASSERT( child != nullptr, "Argument must be non-nullptr"); CCASSERT( dynamic_cast(child), "CCSpriteBatchNode only supports Sprites as children"); // quad index is Z child->setAtlasIndex(z); // XXX: optimize with a binary search auto it = std::begin(_descendants); for(const auto &sprite: _descendants) { if(sprite->getAtlasIndex() >= z) std::next(it); } _descendants.insert(it, child); // IMPORTANT: Call super, and not self. Avoid adding it to the texture atlas array Node::addChild(child, z, aTag); //#issue 1262 don't use lazy sorting, tiles are added as quads not as sprites, so sprites need to be added in order reorderBatch(false); return this; } std::string SpriteBatchNode::getDescription() const { return StringUtils::format("", _tag); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCSpriteBatchNode.h ================================================ /**************************************************************************** Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2009 Matt Oswald Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_SPRITE_BATCH_NODE_H__ #define __CC_SPRITE_BATCH_NODE_H__ #include #include "CCNode.h" #include "CCProtocols.h" #include "CCTextureAtlas.h" #include "ccMacros.h" #include "renderer/CCBatchCommand.h" NS_CC_BEGIN /** * @addtogroup sprite_nodes * @{ */ class Sprite; /** SpriteBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call * (often known as "batch draw"). * * A SpriteBatchNode can reference one and only one texture (one image file, one texture atlas). * Only the Sprites that are contained in that texture can be added to the SpriteBatchNode. * All Sprites added to a SpriteBatchNode are drawn in one OpenGL ES draw call. * If the Sprites are not added to a SpriteBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient. * * * Limitations: * - The only object that is accepted as child (or grandchild, grand-grandchild, etc...) is Sprite or any subclass of Sprite. eg: particles, labels and layer can't be added to a SpriteBatchNode. * - Either all its children are Aliased or Antialiased. It can't be a mix. This is because "alias" is a property of the texture, and all the sprites share the same texture. * * @since v0.7.1 */ class CC_DLL SpriteBatchNode : public Node, public TextureProtocol { static const int DEFAULT_CAPACITY = 29; public: /** creates a SpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. */ static SpriteBatchNode* createWithTexture(Texture2D* tex, ssize_t capacity = DEFAULT_CAPACITY); /** creates a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. The file will be loaded using the TextureMgr. */ static SpriteBatchNode* create(const std::string& fileImage, ssize_t capacity = DEFAULT_CAPACITY); /** * @js ctor */ SpriteBatchNode(); /** * @js NA * @lua NA */ virtual ~SpriteBatchNode(); /** initializes a SpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. */ bool initWithTexture(Texture2D *tex, ssize_t capacity); /** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children. The capacity will be increased in 33% in runtime if it run out of space. The file will be loaded using the TextureMgr. * @js init * @lua init */ bool initWithFile(const std::string& fileImage, ssize_t capacity); bool init(); /** returns the TextureAtlas object */ inline TextureAtlas* getTextureAtlas(void) { return _textureAtlas; } /** sets the TextureAtlas object */ inline void setTextureAtlas(TextureAtlas* textureAtlas) { if (textureAtlas != _textureAtlas) { CC_SAFE_RETAIN(textureAtlas); CC_SAFE_RELEASE(_textureAtlas); _textureAtlas = textureAtlas; } } /** returns an array with the descendants (children, gran children, etc.). This is specific to BatchNode. In order to use the children, use getChildren() instead */ inline const std::vector& getDescendants() const { return _descendants; } void increaseAtlasCapacity(); /** removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter. @warning Removing a child from a SpriteBatchNode is very slow */ void removeChildAtIndex(ssize_t index, bool doCleanup); void appendChild(Sprite* sprite); void removeSpriteFromAtlas(Sprite *sprite); ssize_t rebuildIndexInOrder(Sprite *parent, ssize_t index); ssize_t highestAtlasIndexInChild(Sprite *sprite); ssize_t lowestAtlasIndexInChild(Sprite *sprite); ssize_t atlasIndexForChild(Sprite *sprite, int z); /* Sprites use this to start sortChildren, don't call this manually */ void reorderBatch(bool reorder); // // Overrides // // TextureProtocol virtual Texture2D* getTexture() const override; virtual void setTexture(Texture2D *texture) override; /** *@code *When this function bound into js or lua,the parameter will be changed *In js: var setBlendFunc(var src, var dst) *@endcode * @lua NA */ virtual void setBlendFunc(const BlendFunc &blendFunc) override; /** * @js NA * @lua NA */ virtual const BlendFunc& getBlendFunc() const override; virtual void visit() override; using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; virtual void reorderChild(Node *child, int zOrder) override; virtual void removeChild(Node *child, bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void sortAllChildren() override; virtual void draw(void) override; virtual std::string getDescription() const override; protected: /** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array. This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated. For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont) */ void insertQuadFromSprite(Sprite *sprite, ssize_t index); /** Updates a quad at a certain index into the texture atlas. The Sprite won't be added into the children array. This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated. For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont) */ void updateQuadFromSprite(Sprite *sprite, ssize_t index); /* This is the opposite of "addQuadFromSprite. It add the sprite to the children and descendants array, but it doesn't update add it to the texture atlas */ SpriteBatchNode * addSpriteWithoutQuad(Sprite *child, int z, int aTag); void updateAtlasIndex(Sprite* sprite, ssize_t* curIndex); void swap(ssize_t oldIndex, ssize_t newIndex); void updateBlendFunc(); TextureAtlas *_textureAtlas; BlendFunc _blendFunc; BatchCommand _batchCommand; // render command // all descendants: children, grand children, etc... // There is not need to retain/release these objects, since they are already retained by _children // So, using std::vector is slightly faster than using cocos2d::Array for this particular case std::vector _descendants; }; // end of sprite_nodes group /// @} NS_CC_END #endif // __CC_SPRITE_BATCH_NODE_H__ ================================================ FILE: cocos2d/cocos/2d/CCSpriteFrame.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTextureCache.h" #include "CCSpriteFrame.h" #include "CCDirector.h" NS_CC_BEGIN // implementation of SpriteFrame SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect) { SpriteFrame *spriteFrame = new SpriteFrame(); spriteFrame->initWithTextureFilename(filename, rect); spriteFrame->autorelease(); return spriteFrame; } SpriteFrame* SpriteFrame::createWithTexture(Texture2D *texture, const Rect& rect) { SpriteFrame *spriteFrame = new SpriteFrame(); spriteFrame->initWithTexture(texture, rect); spriteFrame->autorelease(); return spriteFrame; } SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize) { SpriteFrame *spriteFrame = new SpriteFrame(); spriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize); spriteFrame->autorelease(); return spriteFrame; } SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize) { SpriteFrame *spriteFrame = new SpriteFrame(); spriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize); spriteFrame->autorelease(); return spriteFrame; } bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect) { Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect); return initWithTexture(texture, rectInPixels, false, Point::ZERO, rectInPixels.size); } bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect) { Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS( rect ); return initWithTextureFilename(filename, rectInPixels, false, Point::ZERO, rectInPixels.size); } bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize) { _texture = texture; if (texture) { texture->retain(); } _rectInPixels = rect; _rect = CC_RECT_PIXELS_TO_POINTS(rect); _offsetInPixels = offset; _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels ); _originalSizeInPixels = originalSize; _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels ); _rotated = rotated; return true; } bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize) { _texture = nullptr; _textureFilename = filename; _rectInPixels = rect; _rect = CC_RECT_PIXELS_TO_POINTS( rect ); _offsetInPixels = offset; _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels ); _originalSizeInPixels = originalSize; _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels ); _rotated = rotated; return true; } SpriteFrame::~SpriteFrame(void) { CCLOGINFO("deallocing SpriteFrame: %p", this); CC_SAFE_RELEASE(_texture); } SpriteFrame* SpriteFrame::clone() const { // no copy constructor SpriteFrame *copy = new SpriteFrame(); copy->initWithTextureFilename(_textureFilename.c_str(), _rectInPixels, _rotated, _offsetInPixels, _originalSizeInPixels); copy->setTexture(_texture); copy->autorelease(); return copy; } void SpriteFrame::setRect(const Rect& rect) { _rect = rect; _rectInPixels = CC_RECT_POINTS_TO_PIXELS(_rect); } void SpriteFrame::setRectInPixels(const Rect& rectInPixels) { _rectInPixels = rectInPixels; _rect = CC_RECT_PIXELS_TO_POINTS(rectInPixels); } const Point& SpriteFrame::getOffset() const { return _offset; } void SpriteFrame::setOffset(const Point& offsets) { _offset = offsets; _offsetInPixels = CC_POINT_POINTS_TO_PIXELS( _offset ); } const Point& SpriteFrame::getOffsetInPixels() const { return _offsetInPixels; } void SpriteFrame::setOffsetInPixels(const Point& offsetInPixels) { _offsetInPixels = offsetInPixels; _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels ); } void SpriteFrame::setTexture(Texture2D * texture) { if( _texture != texture ) { CC_SAFE_RELEASE(_texture); CC_SAFE_RETAIN(texture); _texture = texture; } } Texture2D* SpriteFrame::getTexture(void) { if( _texture ) { return _texture; } if( _textureFilename.length() > 0 ) { return Director::getInstance()->getTextureCache()->addImage(_textureFilename.c_str()); } // no texture or texture filename return nullptr; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCSpriteFrame.h ================================================ /**************************************************************************** Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SPRITE_CCSPRITE_FRAME_H__ #define __SPRITE_CCSPRITE_FRAME_H__ #include "CCNode.h" #include "CCProtocols.h" #include "CCObject.h" #include "CCGeometry.h" NS_CC_BEGIN class Texture2D; /** * @addtogroup sprite_nodes * @{ */ /** @brief A SpriteFrame has: - texture: A Texture2D that will be used by the Sprite - rectangle: A rectangle of the texture You can modify the frame of a Sprite by doing: SpriteFrame *frame = SpriteFrame::frameWithTexture(texture, rect, offset); sprite->setDisplayFrame(frame); */ class CC_DLL SpriteFrame : public Object, public Clonable { public: /** Create a SpriteFrame with a texture filename, rect in points. It is assumed that the frame was not trimmed. */ static SpriteFrame* create(const std::string& filename, const Rect& rect); /** Create a SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. */ static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize); /** Create a SpriteFrame with a texture, rect in points. It is assumed that the frame was not trimmed. */ static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect); /** Create a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. */ static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize); /** * @js NA * @lua NA */ virtual ~SpriteFrame(void); /** Initializes a SpriteFrame with a texture, rect in points. It is assumed that the frame was not trimmed. */ bool initWithTexture(Texture2D* pobTexture, const Rect& rect); /** Initializes a SpriteFrame with a texture filename, rect in points; It is assumed that the frame was not trimmed. */ bool initWithTextureFilename(const std::string& filename, const Rect& rect); /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. */ bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize); /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. @since v1.1 */ bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize); // attributes inline const Rect& getRectInPixels() const { return _rectInPixels; } void setRectInPixels(const Rect& rectInPixels); inline bool isRotated(void) const { return _rotated; } inline void setRotated(bool rotated) { _rotated = rotated; } /** get rect of the frame */ inline const Rect& getRect(void) const { return _rect; } /** set rect of the frame */ void setRect(const Rect& rect); /** get offset of the frame */ const Point& getOffsetInPixels(void) const; /** set offset of the frame */ void setOffsetInPixels(const Point& offsetInPixels); /** get original size of the trimmed image */ inline const Size& getOriginalSizeInPixels(void) const { return _originalSizeInPixels; } /** set original size of the trimmed image */ inline void setOriginalSizeInPixels(const Size& sizeInPixels) { _originalSizeInPixels = sizeInPixels; } /** get original size of the trimmed image */ inline const Size& getOriginalSize(void) const { return _originalSize; } /** set original size of the trimmed image */ inline void setOriginalSize(const Size& sizeInPixels) { _originalSize = sizeInPixels; } /** get texture of the frame */ Texture2D* getTexture(void); /** set texture of the frame, the texture is retained */ void setTexture(Texture2D* pobTexture); const Point& getOffset(void) const; void setOffset(const Point& offsets); // Overrides virtual SpriteFrame *clone() const override; protected: Point _offset; Size _originalSize; Rect _rectInPixels; bool _rotated; Rect _rect; Point _offsetInPixels; Size _originalSizeInPixels; Texture2D *_texture; std::string _textureFilename; }; // end of sprite_nodes group /// @} NS_CC_END #endif //__SPRITE_CCSPRITE_FRAME_H__ ================================================ FILE: cocos2d/cocos/2d/CCSpriteFrameCache.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Jason Booth Copyright (c) 2009 Robert J Payne Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCNS.h" #include "ccMacros.h" #include "CCTextureCache.h" #include "CCSpriteFrameCache.h" #include "CCSpriteFrame.h" #include "CCSprite.h" #include "TransformUtils.h" #include "platform/CCFileUtils.h" #include "CCString.h" #include "CCArray.h" #include "CCDictionary.h" #include "CCDirector.h" #include using namespace std; NS_CC_BEGIN static SpriteFrameCache *_sharedSpriteFrameCache = nullptr; SpriteFrameCache* SpriteFrameCache::getInstance() { if (! _sharedSpriteFrameCache) { _sharedSpriteFrameCache = new SpriteFrameCache(); _sharedSpriteFrameCache->init(); } return _sharedSpriteFrameCache; } void SpriteFrameCache::destroyInstance() { CC_SAFE_RELEASE_NULL(_sharedSpriteFrameCache); } bool SpriteFrameCache::init(void) { _spriteFrames.reserve(20); _spriteFramesAliases.reserve(20); _loadedFileNames = new std::set(); return true; } SpriteFrameCache::~SpriteFrameCache(void) { CC_SAFE_DELETE(_loadedFileNames); } void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Texture2D* texture) { /* Supported Zwoptex Formats: ZWTCoordinatesFormatOptionXMLLegacy = 0, // Flash Version ZWTCoordinatesFormatOptionXML1_0 = 1, // Desktop Version 0.0 - 0.4b ZWTCoordinatesFormatOptionXML1_1 = 2, // Desktop Version 1.0.0 - 1.0.1 ZWTCoordinatesFormatOptionXML1_2 = 3, // Desktop Version 1.0.2+ */ ValueMap& framesDict = dictionary["frames"].asValueMap(); int format = 0; // get the format if (dictionary.find("metadata") != dictionary.end()) { ValueMap& metadataDict = dictionary["metadata"].asValueMap(); format = metadataDict["format"].asInt(); } // check the format CCASSERT(format >=0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:"); for (auto iter = framesDict.begin(); iter != framesDict.end(); ++iter) { ValueMap& frameDict = iter->second.asValueMap(); std::string spriteFrameName = iter->first; SpriteFrame* spriteFrame = _spriteFrames.at(spriteFrameName); if (spriteFrame) { continue; } if(format == 0) { float x = frameDict["x"].asFloat(); float y = frameDict["y"].asFloat(); float w = frameDict["width"].asFloat(); float h = frameDict["height"].asFloat(); float ox = frameDict["offsetX"].asFloat(); float oy = frameDict["offsetY"].asFloat(); int ow = frameDict["originalWidth"].asInt(); int oh = frameDict["originalHeight"].asInt(); // check ow/oh if(!ow || !oh) { CCLOGWARN("cocos2d: WARNING: originalWidth/Height not found on the SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist"); } // abs ow/oh ow = abs(ow); oh = abs(oh); // create frame spriteFrame = new SpriteFrame(); spriteFrame->initWithTexture(texture, Rect(x, y, w, h), false, Point(ox, oy), Size((float)ow, (float)oh) ); } else if(format == 1 || format == 2) { Rect frame = RectFromString(frameDict["frame"].asString()); bool rotated = false; // rotation if (format == 2) { rotated = frameDict["rotated"].asBool(); } Point offset = PointFromString(frameDict["offset"].asString()); Size sourceSize = SizeFromString(frameDict["sourceSize"].asString()); // create frame spriteFrame = new SpriteFrame(); spriteFrame->initWithTexture(texture, frame, rotated, offset, sourceSize ); } else if (format == 3) { // get values Size spriteSize = SizeFromString(frameDict["spriteSize"].asString()); Point spriteOffset = PointFromString(frameDict["spriteOffset"].asString()); Size spriteSourceSize = SizeFromString(frameDict["spriteSourceSize"].asString()); Rect textureRect = RectFromString(frameDict["textureRect"].asString()); bool textureRotated = frameDict["textureRotated"].asBool(); // get aliases ValueVector& aliases = frameDict["aliases"].asValueVector(); for(const auto &value : aliases) { std::string oneAlias = value.asString(); if (_spriteFramesAliases.find(oneAlias) != _spriteFramesAliases.end()) { CCLOGWARN("cocos2d: WARNING: an alias with name %s already exists", oneAlias.c_str()); } _spriteFramesAliases[oneAlias] = Value(spriteFrameName); } // create frame spriteFrame = new SpriteFrame(); spriteFrame->initWithTexture(texture, Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height), textureRotated, spriteOffset, spriteSourceSize); } // add sprite frame _spriteFrames.insert(spriteFrameName, spriteFrame); spriteFrame->release(); } } void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist, Texture2D *pobTexture) { std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); addSpriteFramesWithDictionary(dict, pobTexture); } void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName) { CCASSERT(textureFileName.size()>0, "texture name should not be null"); Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(textureFileName); if (texture) { addSpriteFramesWithFile(plist, texture); } else { CCLOG("cocos2d: SpriteFrameCache: couldn't load texture file. File not found %s", textureFileName.c_str()); } } void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist) { CCASSERT(pszPlist.size()>0, "plist filename should not be nullptr"); if (_loadedFileNames->find(pszPlist) == _loadedFileNames->end()) { std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); string texturePath(""); if (dict.find("metadata") != dict.end()) { ValueMap& metadataDict = dict["metadata"].asValueMap(); // try to read texture file name from meta data texturePath = metadataDict["textureFileName"].asString(); } if (!texturePath.empty()) { // build texture path relative to plist file texturePath = FileUtils::getInstance()->fullPathFromRelativeFile(texturePath.c_str(), pszPlist); } else { // build texture path by replacing file extension texturePath = pszPlist; // remove .xxx size_t startPos = texturePath.find_last_of("."); texturePath = texturePath.erase(startPos); // append .png texturePath = texturePath.append(".png"); CCLOG("cocos2d: SpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); } Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(texturePath.c_str()); if (texture) { addSpriteFramesWithDictionary(dict, texture); _loadedFileNames->insert(pszPlist); } else { CCLOG("cocos2d: SpriteFrameCache: Couldn't load texture"); } } } void SpriteFrameCache::addSpriteFrame(SpriteFrame* frame, const std::string& frameName) { _spriteFrames.insert(frameName, frame); } void SpriteFrameCache::removeSpriteFrames() { _spriteFrames.clear(); _spriteFramesAliases.clear(); _loadedFileNames->clear(); } void SpriteFrameCache::removeUnusedSpriteFrames() { bool removed = false; std::vector toRemoveFrames; for (auto iter = _spriteFrames.begin(); iter != _spriteFrames.end(); ++iter) { SpriteFrame* spriteFrame = iter->second; if( spriteFrame->getReferenceCount() == 1 ) { toRemoveFrames.push_back(iter->first); CCLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", iter->first.c_str()); removed = true; } } _spriteFrames.erase(toRemoveFrames); // XXX. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache if( removed ) { _loadedFileNames->clear(); } } void SpriteFrameCache::removeSpriteFrameByName(const std::string& name) { // explicit nil handling if( !(name.size()>0) ) return; // Is this an alias ? std::string key = _spriteFramesAliases[name].asString(); if (!key.empty()) { _spriteFrames.erase(key); _spriteFramesAliases.erase(key); } else { _spriteFrames.erase(name); } // XXX. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache _loadedFileNames->clear(); } void SpriteFrameCache::removeSpriteFramesFromFile(const std::string& plist) { std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); if (dict.empty()) { CCLOG("cocos2d:SpriteFrameCache:removeSpriteFramesFromFile: create dict by %s fail.",plist.c_str()); return; } removeSpriteFramesFromDictionary(dict); // remove it from the cache set::iterator ret = _loadedFileNames->find(plist); if (ret != _loadedFileNames->end()) { _loadedFileNames->erase(ret); } } void SpriteFrameCache::removeSpriteFramesFromDictionary(ValueMap& dictionary) { ValueMap framesDict = dictionary["frames"].asValueMap(); std::vector keysToRemove; for (auto iter = framesDict.cbegin(); iter != framesDict.cend(); ++iter) { if (_spriteFrames.at(iter->first)) { keysToRemove.push_back(iter->first); } } _spriteFrames.erase(keysToRemove); } void SpriteFrameCache::removeSpriteFramesFromTexture(Texture2D* texture) { std::vector keysToRemove; for (auto iter = _spriteFrames.cbegin(); iter != _spriteFrames.cend(); ++iter) { std::string key = iter->first; SpriteFrame* frame = _spriteFrames.at(key); if (frame && (frame->getTexture() == texture)) { keysToRemove.push_back(key); } } _spriteFrames.erase(keysToRemove); } SpriteFrame* SpriteFrameCache::getSpriteFrameByName(const std::string& name) { SpriteFrame* frame = _spriteFrames.at(name); if (!frame) { // try alias dictionary std::string key = _spriteFramesAliases[name].asString(); if (!key.empty()) { frame = _spriteFrames.at(key); if (!frame) { CCLOG("cocos2d: SpriteFrameCache: Frame '%s' not found", name.c_str()); } } } return frame; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCSpriteFrameCache.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Jason Booth Copyright (c) 2009 Robert J Payne Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SPRITE_CCSPRITE_FRAME_CACHE_H__ #define __SPRITE_CCSPRITE_FRAME_CACHE_H__ /* * To create sprite frames and texture atlas, use this tool: * http://zwoptex.zwopple.com/ */ #include "CCSpriteFrame.h" #include "CCTexture2D.h" #include "CCObject.h" #include "CCValue.h" #include "CCMap.h" #include #include NS_CC_BEGIN class Sprite; /** * @addtogroup sprite_nodes * @{ */ /** @brief Singleton that handles the loading of the sprite frames. It saves in a cache the sprite frames. @since v0.9 */ class CC_DLL SpriteFrameCache : public Object { public: /** Returns the shared instance of the Sprite Frame cache */ static SpriteFrameCache* getInstance(void); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static SpriteFrameCache* sharedSpriteFrameCache() { return SpriteFrameCache::getInstance(); } /** Destroys the cache. It releases all the Sprite Frames and the retained instance. */ static void destroyInstance(); /** @deprecated Use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedSpriteFrameCache() { return SpriteFrameCache::destroyInstance(); } protected: // MARMALADE: Made this protected not private, as deriving from this class is pretty useful SpriteFrameCache(){} public: /** * @js NA * @lua NA */ virtual ~SpriteFrameCache(); bool init(void); public: /** Adds multiple Sprite Frames from a plist file. * A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png * If you want to use another texture, you should use the addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName) method. * @js addSpriteFrames * @lua addSpriteFrames */ void addSpriteFramesWithFile(const std::string& plist); /** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames. @since v0.99.5 * @js addSpriteFrames * @lua addSpriteFrames */ void addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName); /** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames. * @js addSpriteFrames * @lua addSpriteFrames */ void addSpriteFramesWithFile(const std::string&plist, Texture2D *texture); /** Adds an sprite frame with a given name. If the name already exists, then the contents of the old name will be replaced with the new one. */ void addSpriteFrame(SpriteFrame *frame, const std::string& frameName); /** Purges the dictionary of loaded sprite frames. * Call this method if you receive the "Memory Warning". * In the short term: it will free some resources preventing your app from being killed. * In the medium term: it will allocate more resources. * In the long term: it will be the same. */ void removeSpriteFrames(); /** Removes unused sprite frames. * Sprite Frames that have a retain count of 1 will be deleted. * It is convenient to call this method after when starting a new Scene. */ void removeUnusedSpriteFrames(); /** Deletes an sprite frame from the sprite frame cache. */ void removeSpriteFrameByName(const std::string& name); /** Removes multiple Sprite Frames from a plist file. * Sprite Frames stored in this file will be removed. * It is convenient to call this method when a specific texture needs to be removed. * @since v0.99.5 */ void removeSpriteFramesFromFile(const std::string& plist); /** Removes all Sprite Frames associated with the specified textures. * It is convenient to call this method when a specific texture needs to be removed. * @since v0.995. */ void removeSpriteFramesFromTexture(Texture2D* texture); /** Returns an Sprite Frame that was previously added. If the name is not found it will return nil. You should retain the returned copy if you are going to use it. * @js getSpriteFrame * @lua getSpriteFrame */ SpriteFrame* getSpriteFrameByName(const std::string& name); /** @deprecated use getSpriteFrameByName() instead */ CC_DEPRECATED_ATTRIBUTE SpriteFrame* spriteFrameByName(const std::string&name) { return getSpriteFrameByName(name); } private: /*Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames. */ void addSpriteFramesWithDictionary(ValueMap& dictionary, Texture2D *texture); /** Removes multiple Sprite Frames from Dictionary. * @since v0.99.5 */ void removeSpriteFramesFromDictionary(ValueMap& dictionary); protected: Map _spriteFrames; ValueMap _spriteFramesAliases; std::set* _loadedFileNames; }; // end of sprite_nodes group /// @} NS_CC_END #endif // __SPRITE_CCSPRITE_FRAME_CACHE_H__ ================================================ FILE: cocos2d/cocos/2d/CCTMXLayer.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTMXLayer.h" #include "CCTMXXMLParser.h" #include "CCTMXTiledMap.h" #include "CCSprite.h" #include "CCTextureCache.h" #include "CCShaderCache.h" #include "CCGLProgram.h" #include "ccCArray.h" #include "CCDirector.h" NS_CC_BEGIN // TMXLayer - init & alloc & dealloc TMXLayer * TMXLayer::create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { TMXLayer *ret = new TMXLayer(); if (ret->initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo)) { ret->autorelease(); return ret; } return nullptr; } bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { // XXX: is 35% a good estimate ? Size size = layerInfo->_layerSize; float totalNumberOfTiles = size.width * size.height; float capacity = totalNumberOfTiles * 0.35f + 1; // 35 percent is occupied ? Texture2D *texture = nullptr; if( tilesetInfo ) { texture = Director::getInstance()->getTextureCache()->addImage(tilesetInfo->_sourceImage.c_str()); } if (SpriteBatchNode::initWithTexture(texture, static_cast(capacity))) { // layerInfo _layerName = layerInfo->_name; _layerSize = size; _tiles = layerInfo->_tiles; _opacity = layerInfo->_opacity; setProperties(layerInfo->getProperties()); _contentScaleFactor = Director::getInstance()->getContentScaleFactor(); // tilesetInfo _tileSet = tilesetInfo; CC_SAFE_RETAIN(_tileSet); // mapInfo _mapTileSize = mapInfo->getTileSize(); _layerOrientation = mapInfo->getOrientation(); // offset (after layer orientation is set); Point offset = this->calculateLayerOffset(layerInfo->_offset); this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset)); _atlasIndexArray = ccCArrayNew(totalNumberOfTiles); this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height))); _useAutomaticVertexZ = false; _vertexZvalue = 0; return true; } return false; } TMXLayer::TMXLayer() :_layerName("") ,_opacity(0) ,_vertexZvalue(0) ,_useAutomaticVertexZ(false) ,_reusedTile(nullptr) ,_atlasIndexArray(nullptr) ,_contentScaleFactor(1.0f) ,_layerSize(Size::ZERO) ,_mapTileSize(Size::ZERO) ,_tiles(nullptr) ,_tileSet(nullptr) ,_layerOrientation(TMXOrientationOrtho) {} TMXLayer::~TMXLayer() { CC_SAFE_RELEASE(_tileSet); CC_SAFE_RELEASE(_reusedTile); if (_atlasIndexArray) { ccCArrayFree(_atlasIndexArray); _atlasIndexArray = nullptr; } CC_SAFE_DELETE_ARRAY(_tiles); } void TMXLayer::releaseMap() { if (_tiles) { delete [] _tiles; _tiles = nullptr; } if (_atlasIndexArray) { ccCArrayFree(_atlasIndexArray); _atlasIndexArray = nullptr; } } // TMXLayer - setup Tiles void TMXLayer::setupTiles() { // Optimization: quick hack that sets the image size on the tileset _tileSet->_imageSize = _textureAtlas->getTexture()->getContentSizeInPixels(); // By default all the tiles are aliased // pros: // - easier to render // cons: // - difficult to scale / rotate / etc. _textureAtlas->getTexture()->setAliasTexParameters(); //CFByteOrder o = CFByteOrderGetCurrent(); // Parse cocos2d properties this->parseInternalProperties(); for (int y=0; y < _layerSize.height; y++) { for (int x=0; x < _layerSize.width; x++) { int pos = static_cast(x + _layerSize.width * y); int gid = _tiles[ pos ]; // gid are stored in little endian. // if host is big endian, then swap //if( o == CFByteOrderBigEndian ) // gid = CFSwapInt32( gid ); /* We support little endian.*/ // XXX: gid == 0 --> empty tile if (gid != 0) { this->appendTileForGID(gid, Point(x, y)); } } } } // TMXLayer - Properties Value TMXLayer::getProperty(const std::string& propertyName) const { if (_properties.find(propertyName) != _properties.end()) return _properties.at(propertyName); return Value(); } void TMXLayer::parseInternalProperties() { // if cc_vertex=automatic, then tiles will be rendered using vertexz auto vertexz = getProperty("cc_vertexz"); if (!vertexz.isNull()) { std::string vertexZStr = vertexz.asString(); // If "automatic" is on, then parse the "cc_alpha_func" too if (vertexZStr == "automatic") { _useAutomaticVertexZ = true; auto alphaFuncVal = getProperty("cc_alpha_func"); float alphaFuncValue = alphaFuncVal.asFloat(); setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST)); GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison // use shader program to set uniform getShaderProgram()->use(); getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, alphaFuncValue); CHECK_GL_ERROR_DEBUG(); } else { _vertexZvalue = vertexz.asInt(); } } } void TMXLayer::setupTileSprite(Sprite* sprite, Point pos, int gid) { sprite->setPosition(getPositionAt(pos)); sprite->setVertexZ((float)getVertexZForPos(pos)); sprite->setAnchorPoint(Point::ZERO); sprite->setOpacity(_opacity); //issue 1264, flip can be undone as well sprite->setFlippedX(false); sprite->setFlippedY(false); sprite->setRotation(0.0f); sprite->setAnchorPoint(Point(0,0)); // Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles. if (gid & kTMXTileDiagonalFlag) { // put the anchor in the middle for ease of rotation. sprite->setAnchorPoint(Point(0.5f,0.5f)); sprite->setPosition(Point(getPositionAt(pos).x + sprite->getContentSize().height/2, getPositionAt(pos).y + sprite->getContentSize().width/2 ) ); int flag = gid & (kTMXTileHorizontalFlag | kTMXTileVerticalFlag ); // handle the 4 diagonally flipped states. if (flag == kTMXTileHorizontalFlag) { sprite->setRotation(90.0f); } else if (flag == kTMXTileVerticalFlag) { sprite->setRotation(270.0f); } else if (flag == (kTMXTileVerticalFlag | kTMXTileHorizontalFlag) ) { sprite->setRotation(90.0f); sprite->setFlippedX(true); } else { sprite->setRotation(270.0f); sprite->setFlippedX(true); } } else { if (gid & kTMXTileHorizontalFlag) { sprite->setFlippedX(true); } if (gid & kTMXTileVerticalFlag) { sprite->setFlippedY(true); } } } Sprite* TMXLayer::reusedTileWithRect(Rect rect) { if (! _reusedTile) { _reusedTile = Sprite::createWithTexture(_textureAtlas->getTexture(), rect); _reusedTile->setBatchNode(this); _reusedTile->retain(); } else { // XXX HACK: Needed because if "batch node" is nil, // then the Sprite'squad will be reset _reusedTile->setBatchNode(nullptr); // Re-init the sprite _reusedTile->setTextureRect(rect, false, rect.size); // restore the batch node _reusedTile->setBatchNode(this); } return _reusedTile; } // TMXLayer - obtaining tiles/gids Sprite * TMXLayer::getTileAt(const Point& pos) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); Sprite *tile = nullptr; int gid = this->getTileGIDAt(pos); // if GID == 0, then no tile is present if (gid) { int z = (int)(pos.x + pos.y * _layerSize.width); tile = static_cast(this->getChildByTag(z)); // tile not created yet. create it if (! tile) { Rect rect = _tileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); tile = Sprite::createWithTexture(this->getTexture(), rect); tile->setBatchNode(this); tile->setPosition(getPositionAt(pos)); tile->setVertexZ((float)getVertexZForPos(pos)); tile->setAnchorPoint(Point::ZERO); tile->setOpacity(_opacity); ssize_t indexForZ = atlasIndexForExistantZ(z); this->addSpriteWithoutQuad(tile, static_cast(indexForZ), z); } } return tile; } int TMXLayer::getTileGIDAt(const Point& pos, ccTMXTileFlags* flags/* = nullptr*/) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); int idx = static_cast((pos.x + pos.y * _layerSize.width)); // Bits on the far end of the 32-bit global tile ID are used for tile flags int tile = _tiles[idx]; // issue1264, flipped tiles can be changed dynamically if (flags) { *flags = (ccTMXTileFlags)(tile & kFlipedAll); } return (tile & kFlippedMask); } // TMXLayer - adding helper methods Sprite * TMXLayer::insertTileForGID(int gid, const Point& pos) { if (gid != 0 && (static_cast((gid & kFlippedMask)) - _tileSet->_firstGid) >= 0) { Rect rect = _tileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); intptr_t z = (intptr_t)(pos.x + pos.y * _layerSize.width); Sprite *tile = reusedTileWithRect(rect); setupTileSprite(tile, pos, gid); // get atlas index ssize_t indexForZ = atlasIndexForNewZ(static_cast(z)); // Optimization: add the quad without adding a child this->insertQuadFromSprite(tile, indexForZ); // insert it into the local atlasindex array ccCArrayInsertValueAtIndex(_atlasIndexArray, (void*)z, indexForZ); // update possible children for(const auto &child : _children) { Sprite* sp = static_cast(child); ssize_t ai = sp->getAtlasIndex(); if ( ai >= indexForZ ) { sp->setAtlasIndex(ai+1); } } _tiles[z] = gid; return tile; } return nullptr; } Sprite * TMXLayer::updateTileForGID(int gid, const Point& pos) { Rect rect = _tileSet->rectForGID(gid); rect = Rect(rect.origin.x / _contentScaleFactor, rect.origin.y / _contentScaleFactor, rect.size.width/ _contentScaleFactor, rect.size.height/ _contentScaleFactor); int z = (int)(pos.x + pos.y * _layerSize.width); Sprite *tile = reusedTileWithRect(rect); setupTileSprite(tile ,pos ,gid); // get atlas index ssize_t indexForZ = atlasIndexForExistantZ(z); tile->setAtlasIndex(indexForZ); tile->setDirty(true); tile->updateTransform(); _tiles[z] = gid; return tile; } // used only when parsing the map. useless after the map was parsed // since lot's of assumptions are no longer true Sprite * TMXLayer::appendTileForGID(int gid, const Point& pos) { if (gid != 0 && (static_cast((gid & kFlippedMask)) - _tileSet->_firstGid) >= 0) { Rect rect = _tileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); intptr_t z = (intptr_t)(pos.x + pos.y * _layerSize.width); Sprite *tile = reusedTileWithRect(rect); setupTileSprite(tile ,pos ,gid); // optimization: // The difference between appendTileForGID and insertTileforGID is that append is faster, since // it appends the tile at the end of the texture atlas ssize_t indexForZ = _atlasIndexArray->num; // don't add it using the "standard" way. insertQuadFromSprite(tile, indexForZ); // append should be after addQuadFromSprite since it modifies the quantity values ccCArrayInsertValueAtIndex(_atlasIndexArray, (void*)z, indexForZ); return tile; } return nullptr; } // TMXLayer - atlasIndex and Z static inline int compareInts(const void * a, const void * b) { return ((*(int*)a) - (*(int*)b)); } ssize_t TMXLayer::atlasIndexForExistantZ(int z) { int key=z; int *item = (int*)bsearch((void*)&key, (void*)&_atlasIndexArray->arr[0], _atlasIndexArray->num, sizeof(void*), compareInts); CCASSERT(item, "TMX atlas index not found. Shall not happen"); ssize_t index = ((size_t)item - (size_t)_atlasIndexArray->arr) / sizeof(void*); return index; } ssize_t TMXLayer::atlasIndexForNewZ(int z) { // XXX: This can be improved with a sort of binary search ssize_t i=0; for (i=0; i< _atlasIndexArray->num ; i++) { ssize_t val = (size_t) _atlasIndexArray->arr[i]; if (z < val) { break; } } return i; } // TMXLayer - adding / remove tiles void TMXLayer::setTileGID(int gid, const Point& pos) { setTileGID(gid, pos, (ccTMXTileFlags)0); } void TMXLayer::setTileGID(int gid, const Point& pos, ccTMXTileFlags flags) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); CCASSERT(gid == 0 || gid >= _tileSet->_firstGid, "TMXLayer: invalid gid" ); ccTMXTileFlags currentFlags; int currentGID = getTileGIDAt(pos, ¤tFlags); if (currentGID != gid || currentFlags != flags) { int gidAndFlags = gid | flags; // setting gid=0 is equal to remove the tile if (gid == 0) { removeTileAt(pos); } // empty tile. create a new one else if (currentGID == 0) { insertTileForGID(gidAndFlags, pos); } // modifying an existing tile with a non-empty tile else { int z = pos.x + pos.y * _layerSize.width; Sprite *sprite = static_cast(getChildByTag(z)); if (sprite) { Rect rect = _tileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); sprite->setTextureRect(rect, false, rect.size); if (flags) { setupTileSprite(sprite, sprite->getPosition(), gidAndFlags); } _tiles[z] = gidAndFlags; } else { updateTileForGID(gidAndFlags, pos); } } } } void TMXLayer::addChild(Node * child, int zOrder, int tag) { CC_UNUSED_PARAM(child); CC_UNUSED_PARAM(zOrder); CC_UNUSED_PARAM(tag); CCASSERT(0, "addChild: is not supported on TMXLayer. Instead use setTileGID:at:/tileAt:"); } void TMXLayer::removeChild(Node* node, bool cleanup) { Sprite *sprite = (Sprite*)node; // allows removing nil objects if (! sprite) { return; } CCASSERT(_children.contains(sprite), "Tile does not belong to TMXLayer"); ssize_t atlasIndex = sprite->getAtlasIndex(); ssize_t zz = (ssize_t)_atlasIndexArray->arr[atlasIndex]; _tiles[zz] = 0; ccCArrayRemoveValueAtIndex(_atlasIndexArray, atlasIndex); SpriteBatchNode::removeChild(sprite, cleanup); } void TMXLayer::removeTileAt(const Point& pos) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); int gid = getTileGIDAt(pos); if (gid) { int z = pos.x + pos.y * _layerSize.width; ssize_t atlasIndex = atlasIndexForExistantZ(z); // remove tile from GID map _tiles[z] = 0; // remove tile from atlas position array ccCArrayRemoveValueAtIndex(_atlasIndexArray, atlasIndex); // remove it from sprites and/or texture atlas Sprite *sprite = (Sprite*)getChildByTag(z); if (sprite) { SpriteBatchNode::removeChild(sprite, true); } else { _textureAtlas->removeQuadAtIndex(atlasIndex); // update possible children for(const auto &obj : _children) { Sprite* child = static_cast(obj); ssize_t ai = child->getAtlasIndex(); if ( ai >= atlasIndex ) { child->setAtlasIndex(ai-1); } } } } } //CCTMXLayer - obtaining positions, offset Point TMXLayer::calculateLayerOffset(const Point& pos) { Point ret = Point::ZERO; switch (_layerOrientation) { case TMXOrientationOrtho: ret = Point( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height); break; case TMXOrientationIso: ret = Point((_mapTileSize.width /2) * (pos.x - pos.y), (_mapTileSize.height /2 ) * (-pos.x - pos.y)); break; case TMXOrientationHex: CCASSERT(pos.equals(Point::ZERO), "offset for hexagonal map not implemented yet"); break; } return ret; } Point TMXLayer::getPositionAt(const Point& pos) { Point ret = Point::ZERO; switch (_layerOrientation) { case TMXOrientationOrtho: ret = getPositionForOrthoAt(pos); break; case TMXOrientationIso: ret = getPositionForIsoAt(pos); break; case TMXOrientationHex: ret = getPositionForHexAt(pos); break; } ret = CC_POINT_PIXELS_TO_POINTS( ret ); return ret; } Point TMXLayer::getPositionForOrthoAt(const Point& pos) { return Point(pos.x * _mapTileSize.width, (_layerSize.height - pos.y - 1) * _mapTileSize.height); } Point TMXLayer::getPositionForIsoAt(const Point& pos) { return Point(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1), _mapTileSize.height /2 * ((_layerSize.height * 2 - pos.x - pos.y) - 2)); } Point TMXLayer::getPositionForHexAt(const Point& pos) { float diffY = 0; if ((int)pos.x % 2 == 1) { diffY = -_mapTileSize.height/2 ; } Point xy = Point(pos.x * _mapTileSize.width*3/4, (_layerSize.height - pos.y - 1) * _mapTileSize.height + diffY); return xy; } int TMXLayer::getVertexZForPos(const Point& pos) { int ret = 0; int maxVal = 0; if (_useAutomaticVertexZ) { switch (_layerOrientation) { case TMXOrientationIso: maxVal = static_cast(_layerSize.width + _layerSize.height); ret = static_cast(-(maxVal - (pos.x + pos.y))); break; case TMXOrientationOrtho: ret = static_cast(-(_layerSize.height-pos.y)); break; case TMXOrientationHex: CCASSERT(0, "TMX Hexa zOrder not supported"); break; default: CCASSERT(0, "TMX invalid value"); break; } } else { ret = _vertexZvalue; } return ret; } std::string TMXLayer::getDescription() const { return StringUtils::format("", _tag, (int)_mapTileSize.width, (int)_mapTileSize.height); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTMXLayer.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTMX_LAYER_H__ #define __CCTMX_LAYER_H__ #include "CCTMXObjectGroup.h" #include "CCAtlasNode.h" #include "CCSpriteBatchNode.h" #include "CCTMXXMLParser.h" #include "ccCArray.h" NS_CC_BEGIN class TMXMapInfo; class TMXLayerInfo; class TMXTilesetInfo; struct _ccCArray; /** * @addtogroup tilemap_parallax_nodes * @{ */ /** @brief TMXLayer represents the TMX layer. It is a subclass of SpriteBatchNode. By default the tiles are rendered using a TextureAtlas. If you modify a tile on runtime, then, that tile will become a Sprite, otherwise no Sprite objects are created. The benefits of using Sprite objects as tiles are: - tiles (Sprite) can be rotated/scaled/moved with a nice API If the layer contains a property named "cc_vertexz" with an integer (in can be positive or negative), then all the tiles belonging to the layer will use that value as their OpenGL vertex Z for depth. On the other hand, if the "cc_vertexz" property has the "automatic" value, then the tiles will use an automatic vertex Z value. Also before drawing the tiles, GL_ALPHA_TEST will be enabled, and disabled after drawing them. The used alpha func will be: glAlphaFunc( GL_GREATER, value ) "value" by default is 0, but you can change it from Tiled by adding the "cc_alpha_func" property to the layer. The value 0 should work for most cases, but if you have tiles that are semi-transparent, then you might want to use a different value, like 0.5. For further information, please see the programming guide: http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps @since v0.8.1 Tiles can have tile flags for additional properties. At the moment only flip horizontal and flip vertical are used. These bit flags are defined in TMXXMLParser.h. @since 1.1 */ class CC_DLL TMXLayer : public SpriteBatchNode { public: /** creates a TMXLayer with an tileset info, a layer info and a map info */ static TMXLayer * create(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); /** * @js ctor */ TMXLayer(); /** * @js NA * @lua NA */ virtual ~TMXLayer(); /** initializes a TMXLayer with a tileset info, a layer info and a map info */ bool initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); /** dealloc the map that contains the tile position from memory. Unless you want to know at runtime the tiles positions, you can safely call this method. If you are going to call layer->tileGIDAt() then, don't release the map */ void releaseMap(); /** returns the tile (Sprite) at a given a tile coordinate. The returned Sprite will be already added to the TMXLayer. Don't add it again. The Sprite can be treated like any other Sprite: rotated, scaled, translated, opacity, color, etc. You can remove either by calling: - layer->removeChild(sprite, cleanup); - or layer->removeTileAt(Point(x,y)); */ Sprite* getTileAt(const Point& tileCoordinate); CC_DEPRECATED_ATTRIBUTE Sprite* tileAt(const Point& tileCoordinate) { return getTileAt(tileCoordinate); }; /** returns the tile gid at a given tile coordinate. It also returns the tile flags. This method requires the the tile map has not been previously released (eg. don't call [layer releaseMap]) */ int getTileGIDAt(const Point& tileCoordinate, ccTMXTileFlags* flags = nullptr); CC_DEPRECATED_ATTRIBUTE int tileGIDAt(const Point& tileCoordinate, ccTMXTileFlags* flags = nullptr){ return getTileGIDAt(tileCoordinate, flags); }; /** sets the tile gid (gid = tile global id) at a given tile coordinate. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. If a tile is already placed at that position, then it will be removed. */ void setTileGID(int gid, const Point& tileCoordinate); /** sets the tile gid (gid = tile global id) at a given tile coordinate. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. If a tile is already placed at that position, then it will be removed. Use withFlags if the tile flags need to be changed as well */ void setTileGID(int gid, const Point& tileCoordinate, ccTMXTileFlags flags); /** removes a tile at given tile coordinate */ void removeTileAt(const Point& tileCoordinate); /** returns the position in points of a given tile coordinate */ Point getPositionAt(const Point& tileCoordinate); CC_DEPRECATED_ATTRIBUTE Point positionAt(const Point& tileCoordinate) { return getPositionAt(tileCoordinate); }; /** return the value for the specific property name */ Value getProperty(const std::string& propertyName) const; CC_DEPRECATED_ATTRIBUTE Value propertyNamed(const std::string& propertyName) const { return getProperty(propertyName); }; /** Creates the tiles */ void setupTiles(); inline const std::string& getLayerName(){ return _layerName; } inline void setLayerName(const std::string& layerName){ _layerName = layerName; } /** size of the layer in tiles */ inline const Size& getLayerSize() const { return _layerSize; }; inline void setLayerSize(const Size& size) { _layerSize = size; }; /** size of the map's tile (could be different from the tile's size) */ inline const Size& getMapTileSize() const { return _mapTileSize; }; inline void setMapTileSize(const Size& size) { _mapTileSize = size; }; /** pointer to the map of tiles * @js NA * @lua NA */ inline int* getTiles() const { return _tiles; }; inline void setTiles(int* tiles) { _tiles = tiles; }; /** Tileset information for the layer */ inline TMXTilesetInfo* getTileSet() const { return _tileSet; }; inline void setTileSet(TMXTilesetInfo* info) { CC_SAFE_RETAIN(info); CC_SAFE_RELEASE(_tileSet); _tileSet = info; }; /** Layer orientation, which is the same as the map orientation */ inline int getLayerOrientation() const { return _layerOrientation; }; inline void setLayerOrientation(int orientation) { _layerOrientation = orientation; }; /** properties from the layer. They can be added using Tiled */ inline const ValueMap& getProperties() const { return _properties; }; inline ValueMap& getProperties() { return _properties; }; inline void setProperties(const ValueMap& properties) { _properties = properties; }; // // Override // /** TMXLayer doesn't support adding a Sprite manually. @warning addchild(z, tag); is not supported on TMXLayer. Instead of setTileGID. */ using SpriteBatchNode::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; // super method void removeChild(Node* child, bool cleanup) override; virtual std::string getDescription() const override; private: Point getPositionForIsoAt(const Point& pos); Point getPositionForOrthoAt(const Point& pos); Point getPositionForHexAt(const Point& pos); Point calculateLayerOffset(const Point& offset); /* optimization methods */ Sprite* appendTileForGID(int gid, const Point& pos); Sprite* insertTileForGID(int gid, const Point& pos); Sprite* updateTileForGID(int gid, const Point& pos); /* The layer recognizes some special properties, like cc_vertez */ void parseInternalProperties(); void setupTileSprite(Sprite* sprite, Point pos, int gid); Sprite* reusedTileWithRect(Rect rect); int getVertexZForPos(const Point& pos); // index ssize_t atlasIndexForExistantZ(int z); ssize_t atlasIndexForNewZ(int z); protected: //! name of the layer std::string _layerName; //! TMX Layer supports opacity unsigned char _opacity; //! Only used when vertexZ is used int _vertexZvalue; bool _useAutomaticVertexZ; //! used for optimization Sprite *_reusedTile; ccCArray *_atlasIndexArray; // used for retina display float _contentScaleFactor; /** size of the layer in tiles */ Size _layerSize; /** size of the map's tile (could be different from the tile's size) */ Size _mapTileSize; /** pointer to the map of tiles */ int* _tiles; /** Tileset information for the layer */ TMXTilesetInfo* _tileSet; /** Layer orientation, which is the same as the map orientation */ int _layerOrientation; /** properties from the layer. They can be added using Tiled */ ValueMap _properties; }; // end of tilemap_parallax_nodes group /// @} NS_CC_END #endif //__CCTMX_LAYER_H__ ================================================ FILE: cocos2d/cocos/2d/CCTMXObjectGroup.cpp ================================================ /**************************************************************************** Copyright (c) 2010 Neophit Copyright (c) 2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTMXObjectGroup.h" #include "ccMacros.h" NS_CC_BEGIN //implementation TMXObjectGroup TMXObjectGroup::TMXObjectGroup() : _groupName("") , _positionOffset(Point::ZERO) { } TMXObjectGroup::~TMXObjectGroup() { CCLOGINFO("deallocing TMXObjectGroup: %p", this); } ValueMap TMXObjectGroup::getObject(const std::string& objectName) const { if (!_objects.empty()) { for (const auto& v : _objects) { const ValueMap& dict = v.asValueMap(); if (dict.find("name") != dict.end()) { if (dict.at("name").asString() == objectName) return dict; } } } // object not found return ValueMap(); } Value TMXObjectGroup::getProperty(const std::string& propertyName) const { if (_properties.find(propertyName) != _properties.end()) return _properties.at(propertyName); return Value(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTMXObjectGroup.h ================================================ /**************************************************************************** Copyright (c) 2010 Neophit Copyright (c) 2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTMX_OBJECT_GROUP_H__ #define __CCTMX_OBJECT_GROUP_H__ #include "CCGeometry.h" #include "CCString.h" #include "CCArray.h" #include "CCValue.h" NS_CC_BEGIN /** * @addtogroup tilemap_parallax_nodes * @{ */ /** @brief TMXObjectGroup represents the TMX object group. @since v0.99.0 */ class CC_DLL TMXObjectGroup : public Object { public: /** * @js ctor */ TMXObjectGroup(); /** * @js NA * @lua NA */ virtual ~TMXObjectGroup(); inline const std::string& getGroupName(){ return _groupName; } inline void setGroupName(const std::string& groupName){ _groupName = groupName; } /** return the value for the specific property name */ Value getProperty(const std::string& propertyName) const; CC_DEPRECATED_ATTRIBUTE Value propertyNamed(const std::string& propertyName) const { return getProperty(propertyName); }; /** return the dictionary for the specific object name. It will return the 1st object found on the array for the given name. */ ValueMap getObject(const std::string& objectName) const; CC_DEPRECATED_ATTRIBUTE ValueMap objectNamed(const std::string& objectName) const { return getObject(objectName); }; /** Gets the offset position of child objects */ inline const Point& getPositionOffset() const { return _positionOffset; }; /** Sets the offset position of child objects */ inline void setPositionOffset(const Point& offset) { _positionOffset = offset; }; /** Gets the list of properties stored in a dictionary */ inline const ValueMap& getProperties() const { return _properties; }; inline ValueMap& getProperties() { return _properties; }; /** Sets the list of properties */ inline void setProperties(const ValueMap& properties) { _properties = properties; }; /** Gets the array of the objects */ inline const ValueVector& getObjects() const { return _objects; }; inline ValueVector& getObjects() { return _objects; }; /** Sets the array of the objects */ inline void setObjects(const ValueVector& objects) { _objects = objects; }; protected: /** name of the group */ std::string _groupName; /** offset position of child objects */ Point _positionOffset; /** list of properties stored in a dictionary */ ValueMap _properties; /** array of the objects */ ValueVector _objects; }; // end of tilemap_parallax_nodes group /// @} NS_CC_END #endif //__CCTMX_OBJECT_GROUP_H__ ================================================ FILE: cocos2d/cocos/2d/CCTMXTiledMap.cpp ================================================ /**************************************************************************** Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTMXTiledMap.h" #include "CCTMXXMLParser.h" #include "CCTMXLayer.h" #include "CCSprite.h" #include NS_CC_BEGIN // implementation TMXTiledMap TMXTiledMap * TMXTiledMap::create(const std::string& tmxFile) { TMXTiledMap *ret = new TMXTiledMap(); if (ret->initWithTMXFile(tmxFile)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } TMXTiledMap* TMXTiledMap::createWithXML(const std::string& tmxString, const std::string& resourcePath) { TMXTiledMap *ret = new TMXTiledMap(); if (ret->initWithXML(tmxString, resourcePath)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile) { CCASSERT(tmxFile.size()>0, "TMXTiledMap: tmx file should not be empty"); setContentSize(Size::ZERO); TMXMapInfo *mapInfo = TMXMapInfo::create(tmxFile); if (! mapInfo) { return false; } CCASSERT( !mapInfo->getTilesets().empty(), "TMXTiledMap: Map not found. Please check the filename."); buildWithMapInfo(mapInfo); return true; } bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath) { setContentSize(Size::ZERO); TMXMapInfo *mapInfo = TMXMapInfo::createWithXML(tmxString, resourcePath); CCASSERT( !mapInfo->getTilesets().empty(), "TMXTiledMap: Map not found. Please check the filename."); buildWithMapInfo(mapInfo); return true; } TMXTiledMap::TMXTiledMap() :_mapSize(Size::ZERO) ,_tileSize(Size::ZERO) { } TMXTiledMap::~TMXTiledMap() { } // private TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { TMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo); TMXLayer *layer = TMXLayer::create(tileset, layerInfo, mapInfo); // tell the layerinfo to release the ownership of the tiles map. layerInfo->_ownTiles = false; layer->setupTiles(); return layer; } TMXTilesetInfo * TMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo) { Size size = layerInfo->_layerSize; auto& tilesets = mapInfo->getTilesets(); if (tilesets.size()>0) { TMXTilesetInfo* tileset = nullptr; for (auto iter = tilesets.crbegin(); iter != tilesets.crend(); ++iter) { tileset = *iter; if (tileset) { for( int y=0; y < size.height; y++ ) { for( int x=0; x < size.width; x++ ) { int pos = static_cast(x + size.width * y); int gid = layerInfo->_tiles[ pos ]; // gid are stored in little endian. // if host is big endian, then swap //if( o == CFByteOrderBigEndian ) // gid = CFSwapInt32( gid ); /* We support little endian.*/ // XXX: gid == 0 --> empty tile if( gid != 0 ) { // Optimization: quick return // if the layer is invalid (more than 1 tileset per layer) an CCAssert will be thrown later if( (gid & kFlippedMask) >= tileset->_firstGid ) return tileset; } } } } } } // If all the tiles are 0, return empty tileset CCLOG("cocos2d: Warning: TMX Layer '%s' has no tiles", layerInfo->_name.c_str()); return nullptr; } void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) { _mapSize = mapInfo->getMapSize(); _tileSize = mapInfo->getTileSize(); _mapOrientation = mapInfo->getOrientation(); _objectGroups = mapInfo->getObjectGroups(); _properties = mapInfo->getProperties(); _tileProperties = mapInfo->getTileProperties(); int idx=0; auto& layers = mapInfo->getLayers(); for(const auto &layerInfo : layers) { if (layerInfo->_visible) { TMXLayer *child = parseLayer(layerInfo, mapInfo); addChild(child, idx, idx); // update content size with the max size const Size& childSize = child->getContentSize(); Size currentSize = this->getContentSize(); currentSize.width = std::max( currentSize.width, childSize.width ); currentSize.height = std::max( currentSize.height, childSize.height ); this->setContentSize(currentSize); idx++; } } } // public TMXLayer * TMXTiledMap::getLayer(const std::string& layerName) const { CCASSERT(layerName.size() > 0, "Invalid layer name!"); for (auto& child : _children) { TMXLayer* layer = dynamic_cast(child); if(layer) { if(layerName.compare( layer->getLayerName()) == 0) { return layer; } } } // layer not found return nullptr; } TMXObjectGroup * TMXTiledMap::getObjectGroup(const std::string& groupName) const { CCASSERT(groupName.size() > 0, "Invalid group name!"); if (_objectGroups.size()>0) { TMXObjectGroup* objectGroup = nullptr; for (auto iter = _objectGroups.cbegin(); iter != _objectGroups.cend(); ++iter) { objectGroup = *iter; if (objectGroup && objectGroup->getGroupName() == groupName) { return objectGroup; } } } // objectGroup not found return nullptr; } Value TMXTiledMap::getProperty(const std::string& propertyName) const { if (_properties.find(propertyName) != _properties.end()) return _properties.at(propertyName); return Value(); } Value TMXTiledMap::getPropertiesForGID(int GID) const { if (_tileProperties.find(GID) != _tileProperties.end()) return _tileProperties.at(GID); return Value(); } std::string TMXTiledMap::getDescription() const { return StringUtils::format("(_children.size())); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTMXTiledMap.h ================================================ /**************************************************************************** Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTMX_TILE_MAP_H__ #define __CCTMX_TILE_MAP_H__ #include "CCNode.h" #include "CCTMXObjectGroup.h" #include "CCValue.h" NS_CC_BEGIN class TMXObjectGroup; class TMXLayer; class TMXLayerInfo; class TMXTilesetInfo; class TMXMapInfo; /** * @addtogroup tilemap_parallax_nodes * @{ */ /** Possible orientations of the TMX map */ enum { /** Orthogonal orientation */ TMXOrientationOrtho, /** Hexagonal orientation */ TMXOrientationHex, /** Isometric orientation */ TMXOrientationIso, }; /** @brief TMXTiledMap knows how to parse and render a TMX map. It adds support for the TMX tiled map format used by http://www.mapeditor.org It supports isometric, hexagonal and orthogonal tiles. It also supports object groups, objects, and properties. Features: - Each tile will be treated as an Sprite - The sprites are created on demand. They will be created only when you call "layer->tileAt(position)" - Each tile can be rotated / moved / scaled / tinted / "opaqued", since each tile is a Sprite - Tiles can be added/removed in runtime - The z-order of the tiles can be modified in runtime - Each tile has an anchorPoint of (0,0) - The anchorPoint of the TMXTileMap is (0,0) - The TMX layers will be added as a child - The TMX layers will be aliased by default - The tileset image will be loaded using the TextureCache - Each tile will have a unique tag - Each tile will have a unique z value. top-left: z=1, bottom-right: z=max z - Each object group will be treated as an MutableArray - Object class which will contain all the properties in a dictionary - Properties can be assigned to the Map, Layer, Object Group, and Object Limitations: - It only supports one tileset per layer. - Embedded images are not supported - It only supports the XML format (the JSON format is not supported) Technical description: Each layer is created using an TMXLayer (subclass of SpriteBatchNode). If you have 5 layers, then 5 TMXLayer will be created, unless the layer visibility is off. In that case, the layer won't be created at all. You can obtain the layers (TMXLayer objects) at runtime by: - map->getChildByTag(tag_number); // 0=1st layer, 1=2nd layer, 2=3rd layer, etc... - map->getLayer(name_of_the_layer); Each object group is created using a TMXObjectGroup which is a subclass of MutableArray. You can obtain the object groups at runtime by: - map->getObjectGroup(name_of_the_object_group); Each object is a TMXObject. Each property is stored as a key-value pair in an MutableDictionary. You can obtain the properties at runtime by: map->getProperty(name_of_the_property); layer->getProperty(name_of_the_property); objectGroup->getProperty(name_of_the_property); object->getProperty(name_of_the_property); @since v0.8.1 */ class CC_DLL TMXTiledMap : public Node { public: /** creates a TMX Tiled Map with a TMX file.*/ static TMXTiledMap* create(const std::string& tmxFile); /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */ static TMXTiledMap* createWithXML(const std::string& tmxString, const std::string& resourcePath); /** return the TMXLayer for the specific layer */ TMXLayer* getLayer(const std::string& layerName) const; /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE TMXLayer* layerNamed(const std::string& layerName) const { return getLayer(layerName); }; /** return the TMXObjectGroup for the specific group */ TMXObjectGroup* getObjectGroup(const std::string& groupName) const; /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE TMXObjectGroup* objectGroupNamed(const std::string& groupName) const { return getObjectGroup(groupName); }; /** return the value for the specific property name */ Value getProperty(const std::string& propertyName) const; /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE Value propertyNamed(const char *propertyName) const { return getProperty(propertyName); }; /** return properties dictionary for tile GID */ Value getPropertiesForGID(int GID) const; CC_DEPRECATED_ATTRIBUTE Value propertiesForGID(int GID) const { return getPropertiesForGID(GID); }; /** the map's size property measured in tiles */ inline const Size& getMapSize() const { return _mapSize; }; inline void setMapSize(const Size& mapSize) { _mapSize = mapSize; }; /** the tiles's size property measured in pixels */ inline const Size& getTileSize() const { return _tileSize; }; inline void setTileSize(const Size& tileSize) { _tileSize = tileSize; }; /** map orientation */ inline int getMapOrientation() const { return _mapOrientation; }; inline void setMapOrientation(int mapOrientation) { _mapOrientation = mapOrientation; }; /** object groups */ inline const Vector& getObjectGroups() const { return _objectGroups; }; inline Vector& getObjectGroups() { return _objectGroups; }; inline void setObjectGroups(const Vector& groups) { _objectGroups = groups; }; /** properties */ inline ValueMap& getProperties() { return _properties; }; inline void setProperties(const ValueMap& properties) { _properties = properties; }; virtual std::string getDescription() const override; protected: /** * @js ctor */ TMXTiledMap(); /** * @js NA * @lua NA */ virtual ~TMXTiledMap(); /** initializes a TMX Tiled Map with a TMX file */ bool initWithTMXFile(const std::string& tmxFile); /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */ bool initWithXML(const std::string& tmxString, const std::string& resourcePath); TMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); TMXTilesetInfo * tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); void buildWithMapInfo(TMXMapInfo* mapInfo); /** the map's size property measured in tiles */ Size _mapSize; /** the tiles's size property measured in pixels */ Size _tileSize; /** map orientation */ int _mapOrientation; /** object groups */ Vector _objectGroups; /** properties */ ValueMap _properties; //! tile properties ValueMapIntKey _tileProperties; private: CC_DISALLOW_COPY_AND_ASSIGN(TMXTiledMap); }; // end of tilemap_parallax_nodes group /// @} NS_CC_END #endif //__CCTMX_TILE_MAP_H__ ================================================ FILE: cocos2d/cocos/2d/CCTMXXMLParser.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Максим Аксенов Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include #include "CCTMXXMLParser.h" #include "CCTMXTiledMap.h" #include "ccMacros.h" #include "platform/CCFileUtils.h" #include "ZipUtils.h" #include "base64.h" using namespace std; NS_CC_BEGIN // implementation TMXLayerInfo TMXLayerInfo::TMXLayerInfo() : _name("") , _tiles(nullptr) , _ownTiles(true) , _offset(Point::ZERO) { } TMXLayerInfo::~TMXLayerInfo() { CCLOGINFO("deallocing TMXLayerInfo: %p", this); if( _ownTiles && _tiles ) { free(_tiles); _tiles = nullptr; } } ValueMap& TMXLayerInfo::getProperties() { return _properties; } void TMXLayerInfo::setProperties(ValueMap var) { _properties = var; } // implementation TMXTilesetInfo TMXTilesetInfo::TMXTilesetInfo() :_firstGid(0) ,_tileSize(Size::ZERO) ,_spacing(0) ,_margin(0) ,_imageSize(Size::ZERO) { } TMXTilesetInfo::~TMXTilesetInfo() { CCLOGINFO("deallocing TMXTilesetInfo: %p", this); } Rect TMXTilesetInfo::rectForGID(int gid) { Rect rect; rect.size = _tileSize; gid &= kFlippedMask; gid = gid - _firstGid; int max_x = (int)((_imageSize.width - _margin*2 + _spacing) / (_tileSize.width + _spacing)); // int max_y = (imageSize.height - margin*2 + spacing) / (tileSize.height + spacing); rect.origin.x = (gid % max_x) * (_tileSize.width + _spacing) + _margin; rect.origin.y = (gid / max_x) * (_tileSize.height + _spacing) + _margin; return rect; } // implementation TMXMapInfo TMXMapInfo * TMXMapInfo::create(const std::string& tmxFile) { TMXMapInfo *ret = new TMXMapInfo(); if(ret->initWithTMXFile(tmxFile)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } TMXMapInfo * TMXMapInfo::createWithXML(const std::string& tmxString, const std::string& resourcePath) { TMXMapInfo *ret = new TMXMapInfo(); if(ret->initWithXML(tmxString, resourcePath)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } void TMXMapInfo::internalInit(const std::string& tmxFileName, const std::string& resourcePath) { if (tmxFileName.size() > 0) { _TMXFileName = FileUtils::getInstance()->fullPathForFilename(tmxFileName); } if (resourcePath.size() > 0) { _resources = resourcePath; } _objectGroups.reserve(4); // tmp vars _currentString = ""; _storingCharacters = false; _layerAttribs = TMXLayerAttribNone; _parentElement = TMXPropertyNone; _currentFirstGID = -1; } bool TMXMapInfo::initWithXML(const std::string& tmxString, const std::string& resourcePath) { internalInit("", resourcePath); return parseXMLString(tmxString); } bool TMXMapInfo::initWithTMXFile(const std::string& tmxFile) { internalInit(tmxFile, ""); return parseXMLFile(_TMXFileName.c_str()); } TMXMapInfo::TMXMapInfo() : _mapSize(Size::ZERO) , _tileSize(Size::ZERO) , _layerAttribs(0) , _storingCharacters(false) , _currentFirstGID(-1) , _recordFirstGID(true) { } TMXMapInfo::~TMXMapInfo() { CCLOGINFO("deallocing TMXMapInfo: %p", this); } bool TMXMapInfo::parseXMLString(const std::string& xmlString) { size_t len = xmlString.size(); if (len <= 0) return false; SAXParser parser; if (false == parser.init("UTF-8") ) { return false; } parser.setDelegator(this); return parser.parse(xmlString.c_str(), len); } bool TMXMapInfo::parseXMLFile(const std::string& xmlFilename) { SAXParser parser; if (false == parser.init("UTF-8") ) { return false; } parser.setDelegator(this); return parser.parse(FileUtils::getInstance()->fullPathForFilename(xmlFilename).c_str()); } // the XML parser calls here with all the elements void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { CC_UNUSED_PARAM(ctx); TMXMapInfo *tmxMapInfo = this; std::string elementName = (char*)name; ValueMap attributeDict; if (atts && atts[0]) { for(int i = 0; atts[i]; i += 2) { std::string key = (char*)atts[i]; std::string value = (char*)atts[i+1]; attributeDict.insert(std::make_pair(key, Value(value))); } } if (elementName == "map") { std::string version = attributeDict["version"].asString(); if ( version != "1.0") { CCLOG("cocos2d: TMXFormat: Unsupported TMX version: %s", version.c_str()); } std::string orientationStr = attributeDict["orientation"].asString(); if (orientationStr == "orthogonal") tmxMapInfo->setOrientation(TMXOrientationOrtho); else if (orientationStr == "isometric") tmxMapInfo->setOrientation(TMXOrientationIso); else if(orientationStr == "hexagonal") tmxMapInfo->setOrientation(TMXOrientationHex); else CCLOG("cocos2d: TMXFomat: Unsupported orientation: %d", tmxMapInfo->getOrientation()); Size s; s.width = attributeDict["width"].asFloat(); s.height = attributeDict["height"].asFloat(); tmxMapInfo->setMapSize(s); s.width = attributeDict["tilewidth"].asFloat(); s.height = attributeDict["tileheight"].asFloat(); tmxMapInfo->setTileSize(s); // The parent element is now "map" tmxMapInfo->setParentElement(TMXPropertyMap); } else if (elementName == "tileset") { // If this is an external tileset then start parsing that std::string externalTilesetFilename = attributeDict["source"].asString(); if (externalTilesetFilename != "") { // Tileset file will be relative to the map file. So we need to convert it to an absolute path if (_TMXFileName.find_last_of("/") != string::npos) { string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1); externalTilesetFilename = dir + externalTilesetFilename; } else { externalTilesetFilename = _resources + "/" + externalTilesetFilename; } externalTilesetFilename = FileUtils::getInstance()->fullPathForFilename(externalTilesetFilename.c_str()); _currentFirstGID = attributeDict["firstgid"].asInt(); if (_currentFirstGID < 0) { _currentFirstGID = 0; } _recordFirstGID = false; tmxMapInfo->parseXMLFile(externalTilesetFilename.c_str()); } else { TMXTilesetInfo *tileset = new TMXTilesetInfo(); tileset->_name = attributeDict["name"].asString(); if (_recordFirstGID) { // unset before, so this is tmx file. tileset->_firstGid = attributeDict["firstgid"].asInt(); if (tileset->_firstGid < 0) { tileset->_firstGid = 0; } } else { tileset->_firstGid = _currentFirstGID; _currentFirstGID = 0; } tileset->_spacing = attributeDict["spacing"].asInt(); tileset->_margin = attributeDict["margin"].asInt(); Size s; s.width = attributeDict["tilewidth"].asFloat(); s.height = attributeDict["tileheight"].asFloat(); tileset->_tileSize = s; tmxMapInfo->getTilesets().pushBack(tileset); tileset->release(); } } else if (elementName == "tile") { if (tmxMapInfo->getParentElement() == TMXPropertyLayer) { TMXLayerInfo* layer = tmxMapInfo->getLayers().back(); Size layerSize = layer->_layerSize; int gid = attributeDict["gid"].asInt(); int tilesAmount = layerSize.width*layerSize.height; do { if (tilesAmount > 1) { // Check the value is all set or not CC_BREAK_IF(layer->_tiles[tilesAmount - 2] != -1 && layer->_tiles[tilesAmount - 1] != -1); int currentTileIndex = tilesAmount - layer->_tiles[tilesAmount - 1] - 2; layer->_tiles[currentTileIndex] = gid; if (currentTileIndex != tilesAmount - 1) { --layer->_tiles[tilesAmount - 1]; } } else if(tilesAmount == 1) { if (layer->_tiles[0] == -1) { layer->_tiles[0] = gid; } } } while (0); } else { TMXTilesetInfo* info = tmxMapInfo->getTilesets().back(); tmxMapInfo->setParentGID(info->_firstGid + attributeDict["id"].asInt()); tmxMapInfo->getTileProperties()[tmxMapInfo->getParentGID()] = Value(ValueMap()); tmxMapInfo->setParentElement(TMXPropertyTile); } } else if (elementName == "layer") { TMXLayerInfo *layer = new TMXLayerInfo(); layer->_name = attributeDict["name"].asString(); Size s; s.width = attributeDict["width"].asFloat(); s.height = attributeDict["height"].asFloat(); layer->_layerSize = s; layer->_visible = attributeDict["visible"].asBool(); Value& opacityValue = attributeDict["opacity"]; if( !opacityValue.isNull() ) { layer->_opacity = (unsigned char)(255.0f * opacityValue.asFloat()); } else { layer->_opacity = 255; } float x = attributeDict["x"].asFloat(); float y = attributeDict["y"].asFloat(); layer->_offset = Point(x,y); tmxMapInfo->getLayers().pushBack(layer); layer->release(); // The parent element is now "layer" tmxMapInfo->setParentElement(TMXPropertyLayer); } else if (elementName == "objectgroup") { TMXObjectGroup *objectGroup = new TMXObjectGroup(); objectGroup->setGroupName(attributeDict["name"].asString()); Point positionOffset; positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width; positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height; objectGroup->setPositionOffset(positionOffset); tmxMapInfo->getObjectGroups().pushBack(objectGroup); objectGroup->release(); // The parent element is now "objectgroup" tmxMapInfo->setParentElement(TMXPropertyObjectGroup); } else if (elementName == "image") { TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back(); // build full path std::string imagename = attributeDict["source"].asString(); if (_TMXFileName.find_last_of("/") != string::npos) { string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1); tileset->_sourceImage = dir + imagename; } else { tileset->_sourceImage = _resources + (_resources.size() ? "/" : "") + imagename; } } else if (elementName == "data") { std::string encoding = attributeDict["encoding"].asString(); std::string compression = attributeDict["compression"].asString(); if (encoding == "") { tmxMapInfo->setLayerAttribs(tmxMapInfo->getLayerAttribs() | TMXLayerAttribNone); TMXLayerInfo* layer = tmxMapInfo->getLayers().back(); Size layerSize = layer->_layerSize; int tilesAmount = layerSize.width*layerSize.height; int *tiles = (int *) malloc(tilesAmount*sizeof(int)); // set all value to -1 memset(tiles, 0xFF, tilesAmount*sizeof(int)); /* Save the special index in tiles[tilesAmount - 1]; * When we load tiles, we can do this: * tiles[tilesAmount - tiles[tilesAmount - 1] - 1] = tileNum; * --tiles[tilesAmount - 1]; * We do this because we can easily contorl how much tiles we loaded without add a "curTilesAmount" into class member. */ if (tilesAmount > 1) { tiles[tilesAmount - 1] = tilesAmount - 2; } layer->_tiles = tiles; } else if (encoding == "base64") { int layerAttribs = tmxMapInfo->getLayerAttribs(); tmxMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribBase64); tmxMapInfo->setStoringCharacters(true); if( compression == "gzip" ) { layerAttribs = tmxMapInfo->getLayerAttribs(); tmxMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribGzip); } else if (compression == "zlib") { layerAttribs = tmxMapInfo->getLayerAttribs(); tmxMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribZlib); } CCASSERT( compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method" ); } } else if (elementName == "object") { TMXObjectGroup* objectGroup = tmxMapInfo->getObjectGroups().back(); // The value for "type" was blank or not a valid class name // Create an instance of TMXObjectInfo to store the object and its properties ValueMap dict; // Parse everything automatically const char* array[] = {"name", "type", "width", "height", "gid"}; for(size_t i = 0; i < sizeof(array)/sizeof(array[0]); ++i ) { const char* key = array[i]; Value value = attributeDict[key]; dict[key] = value; } // But X and Y since they need special treatment // X int x = attributeDict["x"].asInt() + (int)objectGroup->getPositionOffset().x; dict["x"] = Value(x); // Y int y = attributeDict["y"].asInt() + (int)objectGroup->getPositionOffset().y; // Correct y position. (Tiled uses Flipped, cocos2d uses Standard) y = (int)(_mapSize.height * _tileSize.height) - y - attributeDict["height"].asInt(); dict["y"] = Value(y); // Add the object to the objectGroup objectGroup->getObjects().push_back(Value(dict)); // The parent element is now "object" tmxMapInfo->setParentElement(TMXPropertyObject); } else if (elementName == "property") { if ( tmxMapInfo->getParentElement() == TMXPropertyNone ) { CCLOG( "TMX tile map: Parent element is unsupported. Cannot add property named '%s' with value '%s'", attributeDict["name"].asString().c_str(), attributeDict["value"].asString().c_str() ); } else if ( tmxMapInfo->getParentElement() == TMXPropertyMap ) { // The parent element is the map Value value = attributeDict["value"]; std::string key = attributeDict["name"].asString(); tmxMapInfo->getProperties().insert(std::make_pair(key, value)); } else if ( tmxMapInfo->getParentElement() == TMXPropertyLayer ) { // The parent element is the last layer TMXLayerInfo* layer = tmxMapInfo->getLayers().back(); Value value = attributeDict["value"]; std::string key = attributeDict["name"].asString(); // Add the property to the layer layer->getProperties().insert(std::make_pair(key, value)); } else if ( tmxMapInfo->getParentElement() == TMXPropertyObjectGroup ) { // The parent element is the last object group TMXObjectGroup* objectGroup = tmxMapInfo->getObjectGroups().back(); Value value = attributeDict["value"]; std::string key = attributeDict["name"].asString(); objectGroup->getProperties().insert(std::make_pair(key, value)); } else if ( tmxMapInfo->getParentElement() == TMXPropertyObject ) { // The parent element is the last object TMXObjectGroup* objectGroup = tmxMapInfo->getObjectGroups().back(); ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap(); std::string propertyName = attributeDict["name"].asString(); dict[propertyName] = attributeDict["value"]; } else if ( tmxMapInfo->getParentElement() == TMXPropertyTile ) { ValueMap& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asValueMap(); std::string propertyName = attributeDict["name"].asString(); dict[propertyName] = attributeDict["value"]; } } else if (elementName == "polygon") { // find parent object's dict and add polygon-points to it TMXObjectGroup* objectGroup = _objectGroups.back(); ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap(); // get points value string std::string value = attributeDict["points"].asString(); if (!value.empty()) { ValueVector pointsArray; pointsArray.reserve(10); // parse points string into a space-separated set of points stringstream pointsStream(value); string pointPair; while(std::getline(pointsStream, pointPair, ' ')) { // parse each point combo into a comma-separated x,y point stringstream pointStream(pointPair); string xStr,yStr; ValueMap pointDict; // set x if(std::getline(pointStream, xStr, ',')) { int x = atoi(xStr.c_str()) + (int)objectGroup->getPositionOffset().x; pointDict["x"] = Value(x); } // set y if(std::getline(pointStream, yStr, ',')) { int y = atoi(yStr.c_str()) + (int)objectGroup->getPositionOffset().y; pointDict["y"] = Value(y); } // add to points array pointsArray.push_back(Value(pointDict)); } dict["points"] = Value(pointsArray); } } else if (elementName == "polyline") { // find parent object's dict and add polyline-points to it TMXObjectGroup* objectGroup = _objectGroups.back(); ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap(); // get points value string std::string value = attributeDict["points"].asString(); if (!value.empty()) { ValueVector pointsArray; pointsArray.reserve(10); // parse points string into a space-separated set of points stringstream pointsStream(value); string pointPair; while(std::getline(pointsStream, pointPair, ' ')) { // parse each point combo into a comma-separated x,y point stringstream pointStream(pointPair); string xStr,yStr; ValueMap pointDict; // set x if(std::getline(pointStream, xStr, ',')) { int x = atoi(xStr.c_str()) + (int)objectGroup->getPositionOffset().x; pointDict["x"] = Value(x); } // set y if(std::getline(pointStream, yStr, ',')) { int y = atoi(yStr.c_str()) + (int)objectGroup->getPositionOffset().y; pointDict["y"] = Value(y); } // add to points array pointsArray.push_back(Value(pointDict)); } dict["polylinePoints"] = Value(pointsArray); } } } void TMXMapInfo::endElement(void *ctx, const char *name) { CC_UNUSED_PARAM(ctx); TMXMapInfo *tmxMapInfo = this; std::string elementName = (char*)name; int len = 0; if(elementName == "data") { if (tmxMapInfo->getLayerAttribs() & TMXLayerAttribBase64) { tmxMapInfo->setStoringCharacters(false); TMXLayerInfo* layer = tmxMapInfo->getLayers().back(); std::string currentString = tmxMapInfo->getCurrentString(); unsigned char *buffer; len = base64Decode((unsigned char*)currentString.c_str(), (unsigned int)currentString.length(), &buffer); if( ! buffer ) { CCLOG("cocos2d: TiledMap: decode data error"); return; } if( tmxMapInfo->getLayerAttribs() & (TMXLayerAttribGzip | TMXLayerAttribZlib) ) { unsigned char *deflated = nullptr; Size s = layer->_layerSize; // int sizeHint = s.width * s.height * sizeof(uint32_t); ssize_t sizeHint = s.width * s.height * sizeof(unsigned int); ssize_t CC_UNUSED inflatedLen = ZipUtils::inflateMemoryWithHint(buffer, len, &deflated, sizeHint); CCASSERT(inflatedLen == sizeHint, ""); free(buffer); buffer = nullptr; if( ! deflated ) { CCLOG("cocos2d: TiledMap: inflate data error"); return; } layer->_tiles = reinterpret_cast(deflated); } else { layer->_tiles = reinterpret_cast(buffer); } tmxMapInfo->setCurrentString(""); } else if (tmxMapInfo->getLayerAttribs() & TMXLayerAttribNone) { TMXLayerInfo* layer = tmxMapInfo->getLayers().back(); Size layerSize = layer->_layerSize; int tilesAmount = layerSize.width * layerSize.height; //set all the tiles unseted to 0 if (tilesAmount > 1 && layer->_tiles[tilesAmount - 2] == -1) { for (int i = tilesAmount - layer->_tiles[tilesAmount - 1] - 2; i < tilesAmount; ++i) { layer->_tiles[i] = 0; } } else if (layer->_tiles[tilesAmount - 1] == -1) { layer->_tiles[tilesAmount - 1] = 0; } } } else if (elementName == "map") { // The map element has ended tmxMapInfo->setParentElement(TMXPropertyNone); } else if (elementName == "layer") { // The layer element has ended tmxMapInfo->setParentElement(TMXPropertyNone); } else if (elementName == "objectgroup") { // The objectgroup element has ended tmxMapInfo->setParentElement(TMXPropertyNone); } else if (elementName == "object") { // The object element has ended tmxMapInfo->setParentElement(TMXPropertyNone); } else if (elementName == "tileset") { _recordFirstGID = true; } } void TMXMapInfo::textHandler(void *ctx, const char *ch, int len) { CC_UNUSED_PARAM(ctx); TMXMapInfo *tmxMapInfo = this; std::string text((char*)ch,0,len); if (tmxMapInfo->isStoringCharacters()) { std::string currentString = tmxMapInfo->getCurrentString(); currentString += text; tmxMapInfo->setCurrentString(currentString.c_str()); } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTMXXMLParser.h ================================================ /**************************************************************************** Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_TM_XML_PARSER__ #define __CC_TM_XML_PARSER__ #include "CCArray.h" #include "CCGeometry.h" #include "platform/CCSAXParser.h" #include "CCVector.h" #include "CCValue.h" #include NS_CC_BEGIN class TMXLayerInfo; class TMXObjectGroup; class TMXTilesetInfo; /** @file * Internal TMX parser * * IMPORTANT: These classed should not be documented using doxygen strings * since the user should not use them. * */ /** * @addtogroup tilemap_parallax_nodes * @{ */ enum { TMXLayerAttribNone = 1 << 0, TMXLayerAttribBase64 = 1 << 1, TMXLayerAttribGzip = 1 << 2, TMXLayerAttribZlib = 1 << 3, }; enum { TMXPropertyNone, TMXPropertyMap, TMXPropertyLayer, TMXPropertyObjectGroup, TMXPropertyObject, TMXPropertyTile }; typedef enum ccTMXTileFlags_ { kTMXTileHorizontalFlag = 0x80000000, kTMXTileVerticalFlag = 0x40000000, kTMXTileDiagonalFlag = 0x20000000, kFlipedAll = (kTMXTileHorizontalFlag|kTMXTileVerticalFlag|kTMXTileDiagonalFlag), kFlippedMask = ~(kFlipedAll) } ccTMXTileFlags; // Bits on the far end of the 32-bit global tile ID (GID's) are used for tile flags /** @brief TMXLayerInfo contains the information about the layers like: - Layer name - Layer size - Layer opacity at creation time (it can be modified at runtime) - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) This information is obtained from the TMX file. */ class CC_DLL TMXLayerInfo : public Object { public: /** * @js ctor */ TMXLayerInfo(); /** * @js NA * @lua NA */ virtual ~TMXLayerInfo(); void setProperties(ValueMap properties); ValueMap& getProperties(); ValueMap _properties; std::string _name; Size _layerSize; int *_tiles; bool _visible; unsigned char _opacity; bool _ownTiles; Point _offset; }; /** @brief TMXTilesetInfo contains the information about the tilesets like: - Tileset name - Tileset spacing - Tileset margin - size of the tiles - Image used for the tiles - Image size This information is obtained from the TMX file. */ class CC_DLL TMXTilesetInfo : public Object { public: std::string _name; int _firstGid; Size _tileSize; int _spacing; int _margin; //! filename containing the tiles (should be spritesheet / texture atlas) std::string _sourceImage; //! size in pixels of the image Size _imageSize; public: /** * @js ctor */ TMXTilesetInfo(); /** * @js NA * @lua NA */ virtual ~TMXTilesetInfo(); Rect rectForGID(int gid); }; /** @brief TMXMapInfo contains the information about the map like: - Map orientation (hexagonal, isometric or orthogonal) - Tile size - Map size And it also contains: - Layers (an array of TMXLayerInfo objects) - Tilesets (an array of TMXTilesetInfo objects) - ObjectGroups (an array of TMXObjectGroupInfo objects) This information is obtained from the TMX file. */ class CC_DLL TMXMapInfo : public Object, public SAXDelegator { public: /** creates a TMX Format with a tmx file */ static TMXMapInfo * create(const std::string& tmxFile); /** creates a TMX Format with an XML string and a TMX resource path */ static TMXMapInfo * createWithXML(const std::string& tmxString, const std::string& resourcePath); /** creates a TMX Format with a tmx file */ CC_DEPRECATED_ATTRIBUTE static TMXMapInfo * formatWithTMXFile(const char *tmxFile) { return TMXMapInfo::create(tmxFile); }; /** creates a TMX Format with an XML string and a TMX resource path */ CC_DEPRECATED_ATTRIBUTE static TMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath) { return TMXMapInfo::createWithXML(tmxString, resourcePath); }; /** * @js ctor */ TMXMapInfo(); /** * @js NA * @lua NA */ virtual ~TMXMapInfo(); /** initializes a TMX format with a tmx file */ bool initWithTMXFile(const std::string& tmxFile); /** initializes a TMX format with an XML string and a TMX resource path */ bool initWithXML(const std::string& tmxString, const std::string& resourcePath); /** initializes parsing of an XML file, either a tmx (Map) file or tsx (Tileset) file */ bool parseXMLFile(const std::string& xmlFilename); /* initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */ bool parseXMLString(const std::string& xmlString); ValueMapIntKey& getTileProperties() { return _tileProperties; }; void setTileProperties(const ValueMapIntKey& tileProperties) { _tileProperties = tileProperties; }; /// map orientation inline int getOrientation() const { return _orientation; }; inline void setOrientation(int orientation) { _orientation = orientation; }; /// map width & height inline const Size& getMapSize() const { return _mapSize; }; inline void setMapSize(const Size& mapSize) { _mapSize = mapSize; }; /// tiles width & height inline const Size& getTileSize() const { return _tileSize; }; inline void setTileSize(const Size& tileSize) { _tileSize = tileSize; }; /// Layers inline const Vector& getLayers() const { return _layers; }; inline Vector& getLayers() { return _layers; }; inline void setLayers(const Vector& layers) { _layers = layers; }; /// tilesets inline const Vector& getTilesets() const { return _tilesets; }; inline Vector& getTilesets() { return _tilesets; }; inline void setTilesets(const Vector& tilesets) { _tilesets = tilesets; }; /// ObjectGroups inline const Vector& getObjectGroups() const { return _objectGroups; }; inline Vector& getObjectGroups() { return _objectGroups; }; inline void setObjectGroups(const Vector& groups) { _objectGroups = groups; }; /// parent element inline int getParentElement() const { return _parentElement; }; inline void setParentElement(int element) { _parentElement = element; }; /// parent GID inline int getParentGID() const { return _parentGID; }; inline void setParentGID(int gid) { _parentGID = gid; }; /// layer attribs inline int getLayerAttribs() const { return _layerAttribs; }; inline void setLayerAttribs(int layerAttribs) { _layerAttribs = layerAttribs; }; /// is storing characters? inline bool isStoringCharacters() const { return _storingCharacters; }; CC_DEPRECATED_ATTRIBUTE inline bool getStoringCharacters() const { return isStoringCharacters(); }; inline void setStoringCharacters(bool storingCharacters) { _storingCharacters = storingCharacters; }; /// properties inline const ValueMap& getProperties() const { return _properties; } inline ValueMap& getProperties() { return _properties; } inline void setProperties(const ValueMap& properties) { _properties = properties; }; // implement pure virtual methods of SAXDelegator /** * @js NA * @lua NA */ void startElement(void *ctx, const char *name, const char **atts); /** * @js NA * @lua NA */ void endElement(void *ctx, const char *name); /** * @js NA * @lua NA */ void textHandler(void *ctx, const char *ch, int len); inline const std::string& getCurrentString() const { return _currentString; } inline void setCurrentString(const std::string& currentString){ _currentString = currentString; } inline const std::string& getTMXFileName() const { return _TMXFileName; } inline void setTMXFileName(const std::string& fileName){ _TMXFileName = fileName; } protected: void internalInit(const std::string& tmxFileName, const std::string& resourcePath); /// map orientation int _orientation; /// map width & height Size _mapSize; /// tiles width & height Size _tileSize; /// Layers Vector _layers; /// tilesets Vector _tilesets; /// ObjectGroups Vector _objectGroups; /// parent element int _parentElement; /// parent GID int _parentGID; /// layer attribs int _layerAttribs; /// is storing characters? bool _storingCharacters; /// properties ValueMap _properties; //! tmx filename std::string _TMXFileName; // tmx resource path std::string _resources; //! current string std::string _currentString; //! tile properties ValueMapIntKey _tileProperties; int _currentFirstGID; bool _recordFirstGID; }; // end of tilemap_parallax_nodes group /// @} NS_CC_END #endif ================================================ FILE: cocos2d/cocos/2d/CCTextFieldTTF.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTextFieldTTF.h" #include "CCDirector.h" #include "CCEGLView.h" NS_CC_BEGIN static int _calcCharCount(const char * text) { int n = 0; char ch = 0; while ((ch = *text)) { CC_BREAK_IF(! ch); if (0x80 != (0xC0 & ch)) { ++n; } ++text; } return n; } ////////////////////////////////////////////////////////////////////////// // constructor and destructor ////////////////////////////////////////////////////////////////////////// TextFieldTTF::TextFieldTTF() : _delegate(0) , _charCount(0) , _inputText("") , _placeHolder("") // prevent LabelTTF initWithString assertion , _secureTextEntry(false) { _colorSpaceHolder.r = _colorSpaceHolder.g = _colorSpaceHolder.b = 127; } TextFieldTTF::~TextFieldTTF() { } ////////////////////////////////////////////////////////////////////////// // static constructor ////////////////////////////////////////////////////////////////////////// TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize) { TextFieldTTF *ret = new TextFieldTTF(); if(ret && ret->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize)) { ret->autorelease(); if (placeholder.size()>0) { ret->setPlaceHolder(placeholder); } return ret; } CC_SAFE_DELETE(ret); return nullptr; } TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize) { TextFieldTTF *ret = new TextFieldTTF(); if(ret && ret->initWithString("", fontName, fontSize)) { ret->autorelease(); if (placeholder.size()>0) { ret->setPlaceHolder(placeholder); } return ret; } CC_SAFE_DELETE(ret); return nullptr; } ////////////////////////////////////////////////////////////////////////// // initialize ////////////////////////////////////////////////////////////////////////// bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize) { _placeHolder = placeholder; return LabelTTF::initWithString(_placeHolder, fontName, fontSize, dimensions, alignment); } bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize) { _placeHolder = std::string(placeholder); return LabelTTF::initWithString(_placeHolder, fontName, fontSize); } ////////////////////////////////////////////////////////////////////////// // IMEDelegate ////////////////////////////////////////////////////////////////////////// bool TextFieldTTF::attachWithIME() { bool ret = IMEDelegate::attachWithIME(); if (ret) { // open keyboard EGLView * pGlView = Director::getInstance()->getOpenGLView(); if (pGlView) { pGlView->setIMEKeyboardState(true); } } return ret; } bool TextFieldTTF::detachWithIME() { bool ret = IMEDelegate::detachWithIME(); if (ret) { // close keyboard EGLView * glView = Director::getInstance()->getOpenGLView(); if (glView) { glView->setIMEKeyboardState(false); } } return ret; } bool TextFieldTTF::canAttachWithIME() { return (_delegate) ? (! _delegate->onTextFieldAttachWithIME(this)) : true; } bool TextFieldTTF::canDetachWithIME() { return (_delegate) ? (! _delegate->onTextFieldDetachWithIME(this)) : true; } void TextFieldTTF::insertText(const char * text, int len) { std::string insert(text, len); // insert \n means input end int pos = static_cast(insert.find('\n')); if ((int)insert.npos != pos) { len = pos; insert.erase(pos); } if (len > 0) { if (_delegate && _delegate->onTextFieldInsertText(this, insert.c_str(), len)) { // delegate doesn't want to insert text return; } _charCount += _calcCharCount(insert.c_str()); std::string sText(_inputText); sText.append(insert); setString(sText); } if ((int)insert.npos == pos) { return; } // '\n' inserted, let delegate process first if (_delegate && _delegate->onTextFieldInsertText(this, "\n", 1)) { return; } // if delegate hasn't processed, detach from IME by default detachWithIME(); } void TextFieldTTF::deleteBackward() { size_t len = _inputText.length(); if (! len) { // there is no string return; } // get the delete byte number size_t deleteLen = 1; // default, erase 1 byte while(0x80 == (0xC0 & _inputText.at(len - deleteLen))) { ++deleteLen; } if (_delegate && _delegate->onTextFieldDeleteBackward(this, _inputText.c_str() + len - deleteLen, static_cast(deleteLen))) { // delegate doesn't wan't to delete backwards return; } // if all text deleted, show placeholder string if (len <= deleteLen) { _inputText = ""; _charCount = 0; LabelTTF::setString(_placeHolder); return; } // set new input text std::string text(_inputText.c_str(), len - deleteLen); setString(text); } const std::string& TextFieldTTF::getContentText() { return _inputText; } void TextFieldTTF::draw() { if (_delegate && _delegate->onDraw(this)) { return; } if (_inputText.length()) { LabelTTF::draw(); return; } // draw placeholder Color3B color = getColor(); setColor(_colorSpaceHolder); LabelTTF::draw(); setColor(color); } const Color3B& TextFieldTTF::getColorSpaceHolder() { return _colorSpaceHolder; } void TextFieldTTF::setColorSpaceHolder(const Color3B& color) { _colorSpaceHolder = color; } ////////////////////////////////////////////////////////////////////////// // properties ////////////////////////////////////////////////////////////////////////// // input text property void TextFieldTTF::setString(const std::string &text) { static char bulletString[] = {(char)0xe2, (char)0x80, (char)0xa2, (char)0x00}; std::string displayText; size_t length; if (text.length()>0) { _inputText = text; displayText = _inputText; if (_secureTextEntry) { displayText = ""; length = _inputText.length(); while (length) { displayText.append(bulletString); --length; } } } else { _inputText = ""; } // if there is no input text, display placeholder instead if (! _inputText.length()) { LabelTTF::setString(_placeHolder); } else { LabelTTF::setString(displayText); } _charCount = _calcCharCount(_inputText.c_str()); } const std::string& TextFieldTTF::getString() const { return _inputText; } // place holder text property void TextFieldTTF::setPlaceHolder(const std::string& text) { _placeHolder = text; if (! _inputText.length()) { LabelTTF::setString(_placeHolder); } } const std::string& TextFieldTTF::getPlaceHolder() const { return _placeHolder; } // secureTextEntry void TextFieldTTF::setSecureTextEntry(bool value) { if (_secureTextEntry != value) { _secureTextEntry = value; setString(getString()); } } bool TextFieldTTF::isSecureTextEntry() { return _secureTextEntry; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTextFieldTTF.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_TEXT_FIELD_H__ #define __CC_TEXT_FIELD_H__ #include "CCLabelTTF.h" #include "CCIMEDelegate.h" NS_CC_BEGIN class TextFieldTTF; /** * @addtogroup input * @{ */ class CC_DLL TextFieldDelegate { public: virtual ~TextFieldDelegate() {} /** @brief If the sender doesn't want to attach to the IME, return true; */ virtual bool onTextFieldAttachWithIME(TextFieldTTF * sender) { CC_UNUSED_PARAM(sender); return false; } /** @brief If the sender doesn't want to detach from the IME, return true; */ virtual bool onTextFieldDetachWithIME(TextFieldTTF * sender) { CC_UNUSED_PARAM(sender); return false; } /** @brief If the sender doesn't want to insert the text, return true; */ virtual bool onTextFieldInsertText(TextFieldTTF * sender, const char * text, int nLen) { CC_UNUSED_PARAM(sender); CC_UNUSED_PARAM(text); CC_UNUSED_PARAM(nLen); return false; } /** @brief If the sender doesn't want to delete the delText, return true; */ virtual bool onTextFieldDeleteBackward(TextFieldTTF * sender, const char * delText, int nLen) { CC_UNUSED_PARAM(sender); CC_UNUSED_PARAM(delText); CC_UNUSED_PARAM(nLen); return false; } /** @brief If the sender doesn't want to draw, return true. */ virtual bool onDraw(TextFieldTTF * sender) { CC_UNUSED_PARAM(sender); return false; } }; /** @brief A simple text input field with TTF font. */ class CC_DLL TextFieldTTF : public LabelTTF, public IMEDelegate { public: /** * @js ctor */ TextFieldTTF(); /** * @js NA * @lua NA */ virtual ~TextFieldTTF(); //char * description(); /** creates a TextFieldTTF from a fontname, alignment, dimension and font size */ static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize); /** creates a LabelTTF from a fontname and font size */ static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize); /** initializes the TextFieldTTF with a font name, alignment, dimension and font size */ bool initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize); /** initializes the TextFieldTTF with a font name and font size */ bool initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize); /** @brief Open keyboard and receive input text. */ virtual bool attachWithIME(); /** @brief End text input and close keyboard. */ virtual bool detachWithIME(); ////////////////////////////////////////////////////////////////////////// // properties ////////////////////////////////////////////////////////////////////////// /** * @js NA * @lua NA */ inline TextFieldDelegate* getDelegate() const { return _delegate; }; /** * @js NA * @lua NA */ inline void setDelegate(TextFieldDelegate* delegate) { _delegate = delegate; }; inline int getCharCount() const { return _charCount; }; virtual const Color3B& getColorSpaceHolder(); virtual void setColorSpaceHolder(const Color3B& color); // input text property public: virtual void setString(const std::string& text) override; virtual const std::string& getString() const override; protected: TextFieldDelegate * _delegate; int _charCount; std::string _inputText; // place holder text property // place holder text displayed when there is no text in the text field. public: virtual void setPlaceHolder(const std::string& text); virtual const std::string& getPlaceHolder(void) const; protected: std::string _placeHolder; Color3B _colorSpaceHolder; public: virtual void setSecureTextEntry(bool value); virtual bool isSecureTextEntry(); protected: bool _secureTextEntry; protected: virtual void draw(); ////////////////////////////////////////////////////////////////////////// // IMEDelegate interface ////////////////////////////////////////////////////////////////////////// virtual bool canAttachWithIME() override; virtual bool canDetachWithIME() override; virtual void insertText(const char * text, int len) override; virtual void deleteBackward() override; virtual const std::string& getContentText() override; private: class LengthStack; LengthStack * _lens; }; // end of input group /// @} NS_CC_END #endif // __CC_TEXT_FIELD_H__ ================================================ FILE: cocos2d/cocos/2d/CCTexture2D.cpp ================================================ /**************************************************************************** Copyright (c) 2008 Apple Inc. All Rights Reserved. Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ /* * Support for RGBA_4_4_4_4 and RGBA_5_5_5_1 was copied from: * https://devforums.apple.com/message/37855#37855 by a1studmuffin */ #include "CCTexture2D.h" #include "ccConfig.h" #include "ccMacros.h" #include "CCConfiguration.h" #include "platform/CCImage.h" #include "CCGL.h" #include "ccUtils.h" #include "CCPlatformMacros.h" #include "CCDirector.h" #include "CCGLProgram.h" #include "ccGLStateCache.h" #include "CCShaderCache.h" #if CC_ENABLE_CACHE_TEXTURE_DATA #include "CCTextureCache.h" #endif NS_CC_BEGIN namespace { typedef Texture2D::PixelFormatInfoMap::value_type PixelFormatInfoMapValue; static const PixelFormatInfoMapValue TexturePixelFormatInfoTablesValue[] = { PixelFormatInfoMapValue(Texture2D::PixelFormat::BGRA8888, Texture2D::PixelFormatInfo(GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, true)), PixelFormatInfoMapValue(Texture2D::PixelFormat::RGBA8888, Texture2D::PixelFormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, true)), PixelFormatInfoMapValue(Texture2D::PixelFormat::RGBA4444, Texture2D::PixelFormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, true)), PixelFormatInfoMapValue(Texture2D::PixelFormat::RGB5A1, Texture2D::PixelFormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, true)), PixelFormatInfoMapValue(Texture2D::PixelFormat::RGB565, Texture2D::PixelFormatInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, false)), PixelFormatInfoMapValue(Texture2D::PixelFormat::RGB888, Texture2D::PixelFormatInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, false)), PixelFormatInfoMapValue(Texture2D::PixelFormat::A8, Texture2D::PixelFormatInfo(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, false)), PixelFormatInfoMapValue(Texture2D::PixelFormat::I8, Texture2D::PixelFormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, false)), PixelFormatInfoMapValue(Texture2D::PixelFormat::AI88, Texture2D::PixelFormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, true)), #ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG PixelFormatInfoMapValue(Texture2D::PixelFormat::PVRTC2, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, false)), PixelFormatInfoMapValue(Texture2D::PixelFormat::PVRTC2A, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, true)), PixelFormatInfoMapValue(Texture2D::PixelFormat::PVRTC4, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false)), PixelFormatInfoMapValue(Texture2D::PixelFormat::PVRTC4A, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, true)), #endif #ifdef GL_ETC1_RGB8_OES PixelFormatInfoMapValue(Texture2D::PixelFormat::ETC, Texture2D::PixelFormatInfo(GL_ETC1_RGB8_OES, 0xFFFFFFFF, 0xFFFFFFFF, 24, true, false)), #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT PixelFormatInfoMapValue(Texture2D::PixelFormat::S3TC_DXT1, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false)), #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT PixelFormatInfoMapValue(Texture2D::PixelFormat::S3TC_DXT3, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)), #endif #ifdef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT PixelFormatInfoMapValue(Texture2D::PixelFormat::S3TC_DXT5, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)), #endif #ifdef GL_ATC_RGB_AMD PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_RGB, Texture2D::PixelFormatInfo(GL_ATC_RGB_AMD, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false)), #endif #ifdef GL_ATC_RGBA_EXPLICIT_ALPHA_AMD PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_EXPLICIT_ALPHA, Texture2D::PixelFormatInfo(GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)), #endif #ifdef GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_INTERPOLATED_ALPHA, Texture2D::PixelFormatInfo(GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)), #endif }; } //CLASS IMPLEMENTATIONS: //The PixpelFormat corresponding information const Texture2D::PixelFormatInfoMap Texture2D::_pixelFormatInfoTables(TexturePixelFormatInfoTablesValue, TexturePixelFormatInfoTablesValue + sizeof(TexturePixelFormatInfoTablesValue) / sizeof(TexturePixelFormatInfoTablesValue[0])); // If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit) // Default is: RGBA8888 (32-bit textures) static Texture2D::PixelFormat g_defaultAlphaPixelFormat = Texture2D::PixelFormat::DEFAULT; static bool _PVRHaveAlphaPremultiplied = false; ////////////////////////////////////////////////////////////////////////// //conventer function // IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBB void Texture2D::convertI8ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i=0; i < dataLen; ++i) { *outData++ = data[i]; //R *outData++ = data[i]; //G *outData++ = data[i]; //B } } // IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB void Texture2D::convertAI88ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) { *outData++ = data[i]; //R *outData++ = data[i]; //G *outData++ = data[i]; //B } } // IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBBAAAAAAAA void Texture2D::convertI8ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0; i < dataLen; ++i) { *outData++ = data[i]; //R *outData++ = data[i]; //G *outData++ = data[i]; //B *outData++ = 0xFF; //A } } // IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) { *outData++ = data[i]; //R *outData++ = data[i]; //G *outData++ = data[i]; //B *outData++ = data[i + 1]; //A } } // IIIIIIII -> RRRRRGGGGGGBBBBB void Texture2D::convertI8ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (int i = 0; i < dataLen; ++i) { *out16++ = (data[i] & 0x00F8) << 8 //R | (data[i] & 0x00FC) << 3 //G | (data[i] & 0x00F8) >> 3; //B } } // IIIIIIIIAAAAAAAA -> RRRRRGGGGGGBBBBB void Texture2D::convertAI88ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) { *out16++ = (data[i] & 0x00F8) << 8 //R | (data[i] & 0x00FC) << 3 //G | (data[i] & 0x00F8) >> 3; //B } } // IIIIIIII -> RRRRGGGGBBBBAAAA void Texture2D::convertI8ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0; i < dataLen; ++i) { *out16++ = (data[i] & 0x00F0) << 8 //R | (data[i] & 0x00F0) << 4 //G | (data[i] & 0x00F0) //B | 0x000F; //A } } // IIIIIIIIAAAAAAAA -> RRRRGGGGBBBBAAAA void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) { *out16++ = (data[i] & 0x00F0) << 8 //R | (data[i] & 0x00F0) << 4 //G | (data[i] & 0x00F0) //B | (data[i+1] & 0x00F0) >> 4; //A } } // IIIIIIII -> RRRRRGGGGGBBBBBA void Texture2D::convertI8ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (int i = 0; i < dataLen; ++i) { *out16++ = (data[i] & 0x00F8) << 8 //R | (data[i] & 0x00F8) << 3 //G | (data[i] & 0x00F8) >> 2 //B | 0x0001; //A } } // IIIIIIIIAAAAAAAA -> RRRRRGGGGGBBBBBA void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) { *out16++ = (data[i] & 0x00F8) << 8 //R | (data[i] & 0x00F8) << 3 //G | (data[i] & 0x00F8) >> 2 //B | (data[i + 1] & 0x0080) >> 7; //A } } // IIIIIIII -> IIIIIIIIAAAAAAAA void Texture2D::convertI8ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0; i < dataLen; ++i) { *out16++ = 0xFF00 //A | data[i]; //I } } // IIIIIIIIAAAAAAAA -> AAAAAAAA void Texture2D::convertAI88ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 1; i < dataLen; i += 2) { *outData++ = data[i]; //A } } // IIIIIIIIAAAAAAAA -> IIIIIIII void Texture2D::convertAI88ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) { *outData++ = data[i]; //R } } // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3) { *outData++ = data[i]; //R *outData++ = data[i + 1]; //G *outData++ = data[i + 2]; //B *outData++ = 0xFF; //A } } // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4) { *outData++ = data[i]; //R *outData++ = data[i + 1]; //G *outData++ = data[i + 2]; //B } } // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGGBBBBB void Texture2D::convertRGB888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3) { *out16++ = (data[i] & 0x00F8) << 8 //R | (data[i + 1] & 0x00FC) << 3 //G | (data[i + 2] & 0x00F8) >> 3; //B } } // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRGGGGGGBBBBB void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4) { *out16++ = (data[i] & 0x00F8) << 8 //R | (data[i + 1] & 0x00FC) << 3 //G | (data[i + 2] & 0x00F8) >> 3; //B } } // RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIII void Texture2D::convertRGB888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3) { *outData++ = (data[i] * 299 + data[i + 1] * 587 + data[i + 2] * 114 + 500) / 1000; //I = (R*299 + G*587 + B*114 + 500) / 1000 } } // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIII void Texture2D::convertRGBA8888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4) { *outData++ = (data[i] * 299 + data[i + 1] * 587 + data[i + 2] * 114 + 500) / 1000; //I = (R*299 + G*587 + B*114 + 500) / 1000 } } // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> AAAAAAAA void Texture2D::convertRGBA8888ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen -3; i < l; i += 4) { *outData++ = data[i + 3]; //A } } // RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIIIAAAAAAAA void Texture2D::convertRGB888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3) { *outData++ = (data[i] * 299 + data[i + 1] * 587 + data[i + 2] * 114 + 500) / 1000; //I = (R*299 + G*587 + B*114 + 500) / 1000 *outData++ = 0xFF; } } // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIIIAAAAAAAA void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4) { *outData++ = (data[i] * 299 + data[i + 1] * 587 + data[i + 2] * 114 + 500) / 1000; //I = (R*299 + G*587 + B*114 + 500) / 1000 *outData++ = data[i + 3]; } } // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRGGGGBBBBAAAA void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3) { *out16++ = ((data[i] & 0x00F0) << 8 //R | (data[i + 1] & 0x00F0) << 4 //G | (data[i + 2] & 0xF0) //B | 0x0F); //A } } // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRGGGGBBBBAAAA void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4) { *out16++ = (data[i] & 0x00F0) << 8 //R | (data[i + 1] & 0x00F0) << 4 //G | (data[i + 2] & 0xF0) //B | (data[i + 3] & 0xF0) >> 4; //A } } // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3) { *out16++ = (data[i] & 0x00F8) << 8 //R | (data[i + 1] & 0x00F8) << 3 //G | (data[i + 2] & 0x00F8) >> 2 //B | 0x01; //A } } // RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA void Texture2D::convertRGBA8888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData) { unsigned short* out16 = (unsigned short*)outData; for (ssize_t i = 0, l = dataLen - 2; i < l; i += 4) { *out16++ = (data[i] & 0x00F8) << 8 //R | (data[i + 1] & 0x00F8) << 3 //G | (data[i + 2] & 0x00F8) >> 2 //B | (data[i + 3] & 0x0080) >> 7; //A } } // conventer function end ////////////////////////////////////////////////////////////////////////// Texture2D::Texture2D() : _pixelFormat(Texture2D::PixelFormat::DEFAULT) , _pixelsWide(0) , _pixelsHigh(0) , _name(0) , _maxS(0.0) , _maxT(0.0) , _hasPremultipliedAlpha(false) , _hasMipmaps(false) , _shaderProgram(nullptr) { } Texture2D::~Texture2D() { #if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTextureMgr::removeTexture(this); #endif CCLOGINFO("deallocing Texture2D: %p - id=%u", this, _name); CC_SAFE_RELEASE(_shaderProgram); if(_name) { GL::deleteTexture(_name); } } Texture2D::PixelFormat Texture2D::getPixelFormat() const { return _pixelFormat; } int Texture2D::getPixelsWide() const { return _pixelsWide; } int Texture2D::getPixelsHigh() const { return _pixelsHigh; } GLuint Texture2D::getName() const { return _name; } Size Texture2D::getContentSize() const { Size ret; ret.width = _contentSize.width / CC_CONTENT_SCALE_FACTOR(); ret.height = _contentSize.height / CC_CONTENT_SCALE_FACTOR(); return ret; } const Size& Texture2D::getContentSizeInPixels() { return _contentSize; } GLfloat Texture2D::getMaxS() const { return _maxS; } void Texture2D::setMaxS(GLfloat maxS) { _maxS = maxS; } GLfloat Texture2D::getMaxT() const { return _maxT; } void Texture2D::setMaxT(GLfloat maxT) { _maxT = maxT; } GLProgram* Texture2D::getShaderProgram() const { return _shaderProgram; } void Texture2D::setShaderProgram(GLProgram* shaderProgram) { CC_SAFE_RETAIN(shaderProgram); CC_SAFE_RELEASE(_shaderProgram); _shaderProgram = shaderProgram; } void Texture2D::releaseData(void *data) { free(data); } void* Texture2D::keepData(void *data, unsigned int length) { CC_UNUSED_PARAM(length); //The texture data mustn't be saved because it isn't a mutable texture. return data; } bool Texture2D::hasPremultipliedAlpha() const { return _hasPremultipliedAlpha; } bool Texture2D::initWithData(const void *data, ssize_t dataLen, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size& contentSize) { CCASSERT(dataLen>0 && pixelsWide>0 && pixelsHigh>0, "Invalid size"); //if data has no mipmaps, we will consider it has only one mipmap MipmapInfo mipmap; mipmap.address = (unsigned char*)data; mipmap.len = static_cast(dataLen); return initWithMipmaps(&mipmap, 1, pixelFormat, pixelsWide, pixelsHigh); //update information _contentSize = contentSize; _maxS = contentSize.width / (float)(pixelsWide); _maxT = contentSize.height / (float)(pixelsHigh); } bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, int pixelsWide, int pixelsHigh) { //the pixelFormat must be a certain value CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!"); CCASSERT(pixelsWide>0 && pixelsHigh>0, "Invalid size"); if (mipmapsNum <= 0) { CCLOG("cocos2d: WARNING: mipmap number is less than 1"); return false; } if(_pixelFormatInfoTables.find(pixelFormat) == _pixelFormatInfoTables.end()) { CCLOG("cocos2d: WARNING: unsupported pixelformat: %lx", (unsigned long)pixelFormat ); return false; } const PixelFormatInfo& info = _pixelFormatInfoTables.at(pixelFormat); if (info.compressed && !Configuration::getInstance()->supportsPVRTC() && !Configuration::getInstance()->supportsETC() && !Configuration::getInstance()->supportsS3TC() && !Configuration::getInstance()->supportsATITC()) { CCLOG("cocos2d: WARNING: PVRTC/ETC images are not supported"); return false; } //Set the row align only when mipmapsNum == 1 and the data is uncompressed if (mipmapsNum == 1 && !info.compressed) { unsigned int bytesPerRow = pixelsWide * info.bpp / 8; if(bytesPerRow % 8 == 0) { glPixelStorei(GL_UNPACK_ALIGNMENT, 8); } else if(bytesPerRow % 4 == 0) { glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } else if(bytesPerRow % 2 == 0) { glPixelStorei(GL_UNPACK_ALIGNMENT, 2); } else { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } }else { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } glGenTextures(1, &_name); GL::bindTexture2D(_name); if (mipmapsNum == 1) { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); }else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); } glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); CHECK_GL_ERROR_DEBUG(); // clean possible GL error // Specify OpenGL texture image int width = pixelsWide; int height = pixelsHigh; for (int i = 0; i < mipmapsNum; ++i) { unsigned char *data = mipmaps[i].address; GLsizei datalen = mipmaps[i].len; if (info.compressed) { glCompressedTexImage2D(GL_TEXTURE_2D, i, info.internalFormat, (GLsizei)width, (GLsizei)height, 0, datalen, data); } else { glTexImage2D(GL_TEXTURE_2D, i, info.internalFormat, (GLsizei)width, (GLsizei)height, 0, info.format, info.type, data); } if (i > 0 && (width != height || ccNextPOT(width) != width )) { CCLOG("cocos2d: Texture2D. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%d != height=%d", i, width, height); } GLenum err = glGetError(); if (err != GL_NO_ERROR) { CCLOG("cocos2d: Texture2D: Error uploading compressed texture level: %u . glError: 0x%04X", i, err); return false; } width = MAX(width >> 1, 1); height = MAX(height >> 1, 1); } _contentSize = Size((float)pixelsWide, (float)pixelsHigh); _pixelsWide = pixelsWide; _pixelsHigh = pixelsHigh; _pixelFormat = pixelFormat; _maxS = 1; _maxT = 1; _hasPremultipliedAlpha = false; _hasMipmaps = mipmapsNum > 1; setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); return true; } std::string Texture2D::getDescription() const { return StringUtils::format("", _name, (long)_pixelsWide, (long)_pixelsHigh, _maxS, _maxT); } // implementation Texture2D (Image) bool Texture2D::initWithImage(Image *image) { return initWithImage(image, PixelFormat::NONE); } bool Texture2D::initWithImage(Image *image, PixelFormat format) { if (image == nullptr) { CCLOG("cocos2d: Texture2D. Can't create Texture. UIImage is nil"); return false; } int imageWidth = image->getWidth(); int imageHeight = image->getHeight(); Configuration *conf = Configuration::getInstance(); int maxTextureSize = conf->getMaxTextureSize(); if (imageWidth > maxTextureSize || imageHeight > maxTextureSize) { CCLOG("cocos2d: WARNING: Image (%u x %u) is bigger than the supported %u x %u", imageWidth, imageHeight, maxTextureSize, maxTextureSize); return false; } unsigned char* tempData = image->getData(); Size imageSize = Size((float)imageWidth, (float)imageHeight); PixelFormat pixelFormat = PixelFormat::NONE; PixelFormat renderFormat = image->getRenderFormat(); size_t tempDataLen = image->getDataLen(); if (image->getNumberOfMipmaps() > 1) { if (format != PixelFormat::NONE) { CCLOG("cocos2d: WARNING: This image has more than 1 mipmaps and we will not convert the data format"); } initWithMipmaps(image->getMipmaps(), image->getNumberOfMipmaps(), image->getRenderFormat(), imageWidth, imageHeight); return true; } else if (image->isCompressed()) { if (format != PixelFormat::NONE) { CCLOG("cocos2d: WARNING: This image is compressed and we cann't convert it for now"); } initWithData(tempData, tempDataLen, image->getRenderFormat(), imageWidth, imageHeight, imageSize); return true; } else { // compute pixel format if (format != PixelFormat::NONE) { pixelFormat = format; }else { pixelFormat = g_defaultAlphaPixelFormat; } unsigned char* outTempData = nullptr; ssize_t outTempDataLen = 0; pixelFormat = convertDataToFormat(tempData, tempDataLen, renderFormat, pixelFormat, &outTempData, &outTempDataLen); initWithData(outTempData, outTempDataLen, pixelFormat, imageWidth, imageHeight, imageSize); if (outTempData != nullptr && outTempData != tempData) { delete [] outTempData; } // set the premultiplied tag if (!image->hasPremultipliedAlpha()) { if (image->getFileType() == Image::Format::PVR) { _hasPremultipliedAlpha = _PVRHaveAlphaPremultiplied; }else { CCLOG("wanning: We cann't find the data is premultiplied or not, we will assume it's false."); _hasPremultipliedAlpha = false; } }else { _hasPremultipliedAlpha = image->isPremultipliedAlpha(); } return true; } } Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen) { switch (format) { case PixelFormat::RGBA8888: *outDataLen = dataLen*4; *outData = new unsigned char[*outDataLen]; convertI8ToRGBA8888(data, dataLen, *outData); break; case PixelFormat::RGB888: *outDataLen = dataLen*3; *outData = new unsigned char[*outDataLen]; convertI8ToRGB888(data, dataLen, *outData); break; case PixelFormat::RGB565: *outDataLen = dataLen*2; *outData = new unsigned char[*outDataLen]; convertI8ToRGB565(data, dataLen, *outData); break; case PixelFormat::AI88: *outDataLen = dataLen*2; *outData = new unsigned char[*outDataLen]; convertI8ToAI88(data, dataLen, *outData); break; case PixelFormat::RGBA4444: *outDataLen = dataLen*2; *outData = new unsigned char[*outDataLen]; convertI8ToRGBA4444(data, dataLen, *outData); break; case PixelFormat::RGB5A1: *outDataLen = dataLen*2; *outData = new unsigned char[*outDataLen]; convertI8ToRGB5A1(data, dataLen, *outData); break; default: // unsupport convertion or don't need to convert if (format != PixelFormat::AUTO && format != PixelFormat::I8) { CCLOG("Can not convert image format PixelFormat::I8 to format ID:%d, we will use it's origin format PixelFormat::I8", format); } *outData = (unsigned char*)data; *outDataLen = dataLen; return PixelFormat::I8; } return format; } Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen) { switch (format) { case PixelFormat::RGBA8888: *outDataLen = dataLen*2; *outData = new unsigned char[*outDataLen]; convertAI88ToRGBA8888(data, dataLen, *outData); break; case PixelFormat::RGB888: *outDataLen = dataLen/2*3; *outData = new unsigned char[*outDataLen]; convertAI88ToRGB888(data, dataLen, *outData); break; case PixelFormat::RGB565: *outDataLen = dataLen; *outData = new unsigned char[*outDataLen]; convertAI88ToRGB565(data, dataLen, *outData); break; case PixelFormat::A8: *outDataLen = dataLen/2; *outData = new unsigned char[*outDataLen]; convertAI88ToA8(data, dataLen, *outData); break; case PixelFormat::I8: *outDataLen = dataLen/2; *outData = new unsigned char[*outDataLen]; convertAI88ToI8(data, dataLen, *outData); break; case PixelFormat::RGBA4444: *outDataLen = dataLen; *outData = new unsigned char[*outDataLen]; convertAI88ToRGBA4444(data, dataLen, *outData); break; case PixelFormat::RGB5A1: *outDataLen = dataLen; *outData = new unsigned char[*outDataLen]; convertAI88ToRGB5A1(data, dataLen, *outData); break; default: // unsupport convertion or don't need to convert if (format != PixelFormat::AUTO && format != PixelFormat::AI88) { CCLOG("Can not convert image format PixelFormat::AI88 to format ID:%d, we will use it's origin format PixelFormat::AI88", format); } *outData = (unsigned char*)data; *outDataLen = dataLen; return PixelFormat::AI88; break; } return format; } Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen) { switch (format) { case PixelFormat::RGBA8888: *outDataLen = dataLen/3*4; *outData = new unsigned char[*outDataLen]; convertRGB888ToRGBA8888(data, dataLen, *outData); break; case PixelFormat::RGB565: *outDataLen = dataLen/3*2; *outData = new unsigned char[*outDataLen]; convertRGB888ToRGB565(data, dataLen, *outData); break; case PixelFormat::I8: *outDataLen = dataLen/3; *outData = new unsigned char[*outDataLen]; convertRGB888ToI8(data, dataLen, *outData); break; case PixelFormat::AI88: *outDataLen = dataLen/3*2; *outData = new unsigned char[*outDataLen]; convertRGB888ToAI88(data, dataLen, *outData); break; case PixelFormat::RGBA4444: *outDataLen = dataLen/3*2; *outData = new unsigned char[*outDataLen]; convertRGB888ToRGBA4444(data, dataLen, *outData); break; case PixelFormat::RGB5A1: *outDataLen = dataLen; *outData = new unsigned char[*outDataLen]; convertRGB888ToRGB5A1(data, dataLen, *outData); break; default: // unsupport convertion or don't need to convert if (format != PixelFormat::AUTO && format != PixelFormat::RGB888) { CCLOG("Can not convert image format PixelFormat::RGB888 to format ID:%d, we will use it's origin format PixelFormat::RGB888", format); } *outData = (unsigned char*)data; *outDataLen = dataLen; return PixelFormat::RGB888; } return format; } Texture2D::PixelFormat Texture2D::convertRGBA8888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen) { switch (format) { case PixelFormat::RGB888: *outDataLen = dataLen/4*3; *outData = new unsigned char[*outDataLen]; convertRGBA8888ToRGB888(data, dataLen, *outData); break; case PixelFormat::RGB565: *outDataLen = dataLen/2; *outData = new unsigned char[*outDataLen]; convertRGBA8888ToRGB565(data, dataLen, *outData); break; case PixelFormat::A8: *outDataLen = dataLen/4; *outData = new unsigned char[*outDataLen]; convertRGBA8888ToA8(data, dataLen, *outData); break; case PixelFormat::I8: *outDataLen = dataLen/4; *outData = new unsigned char[*outDataLen]; convertRGBA8888ToI8(data, dataLen, *outData); break; case PixelFormat::AI88: *outDataLen = dataLen/2; *outData = new unsigned char[*outDataLen]; convertRGBA8888ToAI88(data, dataLen, *outData); break; case PixelFormat::RGBA4444: *outDataLen = dataLen/2; *outData = new unsigned char[*outDataLen]; convertRGBA8888ToRGBA4444(data, dataLen, *outData); break; case PixelFormat::RGB5A1: *outDataLen = dataLen/2; *outData = new unsigned char[*outDataLen]; convertRGBA8888ToRGB5A1(data, dataLen, *outData); break; default: // unsupport convertion or don't need to convert if (format != PixelFormat::AUTO && format != PixelFormat::RGBA8888) { CCLOG("Can not convert image format PixelFormat::RGBA8888 to format ID:%d, we will use it's origin format PixelFormat::RGBA8888", format); } *outData = (unsigned char*)data; *outDataLen = dataLen; return PixelFormat::RGBA8888; } return format; } /* convert map: 1.PixelFormat::RGBA8888 2.PixelFormat::RGB888 3.PixelFormat::RGB565 4.PixelFormat::A8 5.PixelFormat::I8 6.PixelFormat::AI88 7.PixelFormat::RGBA4444 8.PixelFormat::RGB5A1 gray(5) -> 1235678 gray alpha(6) -> 12345678 rgb(2) -> 1235678 rgba(1) -> 12345678 */ Texture2D::PixelFormat Texture2D::convertDataToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, ssize_t* outDataLen) { switch (originFormat) { case PixelFormat::I8: return convertI8ToFormat(data, dataLen, format, outData, outDataLen); case PixelFormat::AI88: return convertAI88ToFormat(data, dataLen, format, outData, outDataLen); case PixelFormat::RGB888: return convertRGB888ToFormat(data, dataLen, format, outData, outDataLen); case PixelFormat::RGBA8888: return convertRGBA8888ToFormat(data, dataLen, format, outData, outDataLen); default: CCLOG("unsupport convert for format %d to format %d", originFormat, format); *outData = (unsigned char*)data; *outDataLen = dataLen; return originFormat; } } // implementation Texture2D (Text) bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, TextHAlignment hAlignment/* = TextHAlignment::CENTER */, TextVAlignment vAlignment/* = TextVAlignment::TOP */) { FontDefinition tempDef; tempDef._shadow._shadowEnabled = false; tempDef._stroke._strokeEnabled = false; tempDef._fontName = std::string(fontName); tempDef._fontSize = fontSize; tempDef._dimensions = dimensions; tempDef._alignment = hAlignment; tempDef._vertAlignment = vAlignment; tempDef._fontFillColor = Color3B::WHITE; return initWithString(text, tempDef); } bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition) { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data VolatileTextureMgr::addStringTexture(this, text, textDefinition); #endif bool ret = false; Image::TextAlign align; if (TextVAlignment::TOP == textDefinition._vertAlignment) { align = (TextHAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::TOP : (TextHAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::TOP_LEFT : Image::TextAlign::TOP_RIGHT; } else if (TextVAlignment::CENTER == textDefinition._vertAlignment) { align = (TextHAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::CENTER : (TextHAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::LEFT : Image::TextAlign::RIGHT; } else if (TextVAlignment::BOTTOM == textDefinition._vertAlignment) { align = (TextHAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::BOTTOM : (TextHAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::BOTTOM_LEFT : Image::TextAlign::BOTTOM_RIGHT; } else { CCASSERT(false, "Not supported alignment format!"); return false; } #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) // handle shadow parameters bool shadowEnabled = false; float shadowDX = 0.0f; float shadowDY = 0.0f; float shadowBlur = 0.0f; float shadowOpacity = 0.0f; if ( textDefinition._shadow._shadowEnabled ) { shadowEnabled = true; shadowDX = textDefinition._shadow._shadowOffset.width; shadowDY = textDefinition._shadow._shadowOffset.height; shadowBlur = textDefinition._shadow._shadowBlur; shadowOpacity = textDefinition._shadow._shadowOpacity; } // handle stroke parameters bool strokeEnabled = false; float strokeColorR = 0.0f; float strokeColorG = 0.0f; float strokeColorB = 0.0f; float strokeSize = 0.0f; if ( textDefinition._stroke._strokeEnabled ) { strokeEnabled = true; strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f; strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f; strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f; strokeSize = textDefinition._stroke._strokeSize; } Image* image = new Image(); do { CC_BREAK_IF(nullptr == image); ret = image->initWithStringShadowStroke(text, (int)textDefinition._dimensions.width, (int)textDefinition._dimensions.height, align, textDefinition._fontName.c_str(), textDefinition._fontSize, textDefinition._fontFillColor.r / 255.0f, textDefinition._fontFillColor.g / 255.0f, textDefinition._fontFillColor.b / 255.0f, shadowEnabled, shadowDX, shadowDY, shadowOpacity, shadowBlur, strokeEnabled, strokeColorR, strokeColorG, strokeColorB, strokeSize); CC_BREAK_IF(!ret); ret = initWithImage(image); } while (0); CC_SAFE_RELEASE(image); return ret; #else bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled; CCASSERT(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!"); Image* image = new Image(); do { CC_BREAK_IF(nullptr == image); ret = image->initWithString(text, (int)textDefinition._dimensions.width, (int)textDefinition._dimensions.height, align, textDefinition._fontName.c_str(), (int)textDefinition._fontSize); CC_BREAK_IF(!ret); ret = initWithImage(image); } while (0); CC_SAFE_RELEASE(image); return ret; #endif } // implementation Texture2D (Drawing) void Texture2D::drawAtPoint(const Point& point) { GLfloat coordinates[] = { 0.0f, _maxT, _maxS,_maxT, 0.0f, 0.0f, _maxS,0.0f }; GLfloat width = (GLfloat)_pixelsWide * _maxS, height = (GLfloat)_pixelsHigh * _maxT; GLfloat vertices[] = { point.x, point.y, width + point.x, point.y, point.x, height + point.y, width + point.x, height + point.y }; GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS ); _shaderProgram->use(); _shaderProgram->setUniformsForBuiltins(); GL::bindTexture2D( _name ); #ifdef EMSCRIPTEN setGLBufferData(vertices, 8 * sizeof(GLfloat), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } void Texture2D::drawInRect(const Rect& rect) { GLfloat coordinates[] = { 0.0f, _maxT, _maxS,_maxT, 0.0f, 0.0f, _maxS,0.0f }; GLfloat vertices[] = { rect.origin.x, rect.origin.y, /*0.0f,*/ rect.origin.x + rect.size.width, rect.origin.y, /*0.0f,*/ rect.origin.x, rect.origin.y + rect.size.height, /*0.0f,*/ rect.origin.x + rect.size.width, rect.origin.y + rect.size.height, /*0.0f*/ }; GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS ); _shaderProgram->use(); _shaderProgram->setUniformsForBuiltins(); GL::bindTexture2D( _name ); #ifdef EMSCRIPTEN setGLBufferData(vertices, 8 * sizeof(GLfloat), 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } void Texture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied) { _PVRHaveAlphaPremultiplied = haveAlphaPremultiplied; } // // Use to apply MIN/MAG filter // // implementation Texture2D (GLFilter) void Texture2D::generateMipmap() { CCASSERT(_pixelsWide == ccNextPOT(_pixelsWide) && _pixelsHigh == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures"); GL::bindTexture2D( _name ); glGenerateMipmap(GL_TEXTURE_2D); _hasMipmaps = true; } bool Texture2D::hasMipmaps() const { return _hasMipmaps; } void Texture2D::setTexParameters(const TexParams &texParams) { CCASSERT((_pixelsWide == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) && (_pixelsHigh == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE), "GL_CLAMP_TO_EDGE should be used in NPOT dimensions"); GL::bindTexture2D( _name ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParams.minFilter ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams.magFilter ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texParams.wrapS ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texParams.wrapT ); #if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTextureMgr::setTexParameters(this, texParams); #endif } void Texture2D::setAliasTexParameters() { GL::bindTexture2D( _name ); if( ! _hasMipmaps ) { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); } else { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); } glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); #if CC_ENABLE_CACHE_TEXTURE_DATA TexParams texParams = {(GLuint)(_hasMipmaps?GL_NEAREST_MIPMAP_NEAREST:GL_NEAREST),GL_NEAREST,GL_NONE,GL_NONE}; VolatileTextureMgr::setTexParameters(this, texParams); #endif } void Texture2D::setAntiAliasTexParameters() { GL::bindTexture2D( _name ); if( ! _hasMipmaps ) { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); } else { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); } glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); #if CC_ENABLE_CACHE_TEXTURE_DATA TexParams texParams = {(GLuint)(_hasMipmaps?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR),GL_LINEAR,GL_NONE,GL_NONE}; VolatileTextureMgr::setTexParameters(this, texParams); #endif } const char* Texture2D::getStringForFormat() const { switch (_pixelFormat) { case Texture2D::PixelFormat::RGBA8888: return "RGBA8888"; case Texture2D::PixelFormat::RGB888: return "RGB888"; case Texture2D::PixelFormat::RGB565: return "RGB565"; case Texture2D::PixelFormat::RGBA4444: return "RGBA4444"; case Texture2D::PixelFormat::RGB5A1: return "RGB5A1"; case Texture2D::PixelFormat::AI88: return "AI88"; case Texture2D::PixelFormat::A8: return "A8"; case Texture2D::PixelFormat::I8: return "I8"; case Texture2D::PixelFormat::PVRTC4: return "PVRTC4"; case Texture2D::PixelFormat::PVRTC2: return "PVRTC2"; default: CCASSERT(false , "unrecognized pixel format"); CCLOG("stringForFormat: %ld, cannot give useful result", (long)_pixelFormat); break; } return nullptr; } // // Texture options for images that contains alpha // // implementation Texture2D (PixelFormat) void Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat format) { g_defaultAlphaPixelFormat = format; } Texture2D::PixelFormat Texture2D::getDefaultAlphaPixelFormat() { return g_defaultAlphaPixelFormat; } unsigned int Texture2D::getBitsPerPixelForFormat(Texture2D::PixelFormat format) const { if (format == PixelFormat::NONE) { return 0; } return _pixelFormatInfoTables.at(format).bpp; } unsigned int Texture2D::getBitsPerPixelForFormat() const { return this->getBitsPerPixelForFormat(_pixelFormat); } const Texture2D::PixelFormatInfoMap& Texture2D::getPixelFormatInfoMap() { return _pixelFormatInfoTables; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTexture2D.h ================================================ /**************************************************************************** Copyright (c) 2008 Apple Inc. All Rights Reserved. Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTEXTURE2D_H__ #define __CCTEXTURE2D_H__ #include #include #include #include "CCObject.h" #include "CCGeometry.h" #include "ccTypes.h" #ifdef EMSCRIPTEN #include "CCGLBufferedNode.h" #endif // EMSCRIPTEN NS_CC_BEGIN class Image; typedef struct _MipmapInfo MipmapInfo; /** * @addtogroup textures * @{ */ //CONSTANTS: class GLProgram; //CLASS INTERFACES: /** @brief Texture2D class. * This class allows to easily create OpenGL 2D textures from images, text or raw data. * The created Texture2D object will always have power-of-two dimensions. * Depending on how you create the Texture2D object, the actual image area of the texture might be smaller than the texture dimensions i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). * Be aware that the content of the generated textures will be upside-down! */ class CC_DLL Texture2D : public Object #ifdef EMSCRIPTEN , public GLBufferedNode #endif // EMSCRIPTEN { public: /** @typedef Texture2D::PixelFormat Possible texture pixel formats */ enum class PixelFormat { //! auto detect the type AUTO, //! 32-bit texture: BGRA8888 BGRA8888, //! 32-bit texture: RGBA8888 RGBA8888, //! 24-bit texture: RGBA888 RGB888, //! 16-bit texture without Alpha channel RGB565, //! 8-bit textures used as masks A8, //! 8-bit intensity texture I8, //! 16-bit textures used as masks AI88, //! 16-bit textures: RGBA4444 RGBA4444, //! 16-bit textures: RGB5A1 RGB5A1, //! 4-bit PVRTC-compressed texture: PVRTC4 PVRTC4, //! 4-bit PVRTC-compressed texture: PVRTC4 (has alpha channel) PVRTC4A, //! 2-bit PVRTC-compressed texture: PVRTC2 PVRTC2, //! 2-bit PVRTC-compressed texture: PVRTC2 (has alpha channel) PVRTC2A, //! ETC-compressed texture: ETC ETC, //! S3TC-compressed texture: S3TC_Dxt1 S3TC_DXT1, //! S3TC-compressed texture: S3TC_Dxt3 S3TC_DXT3, //! S3TC-compressed texture: S3TC_Dxt5 S3TC_DXT5, //! ATITC-compressed texture: ATC_RGB ATC_RGB, //! ATITC-compressed texture: ATC_EXPLICIT_ALPHA ATC_EXPLICIT_ALPHA, //! ATITC-compresed texture: ATC_INTERPOLATED_ALPHA ATC_INTERPOLATED_ALPHA, //! Default texture format: AUTO DEFAULT = AUTO, NONE = -1 }; struct PixelFormatInfo { PixelFormatInfo(GLenum anInternalFormat, GLenum aFormat, GLenum aType, int aBpp, bool aCompressed, bool anAlpha) : internalFormat(anInternalFormat) , format(aFormat) , type(aType) , bpp(aBpp) , compressed(aCompressed) , alpha(anAlpha) {} GLenum internalFormat; GLenum format; GLenum type; int bpp; bool compressed; bool alpha; }; typedef std::map PixelFormatInfoMap; /** Extension to set the Min / Mag filter */ typedef struct _TexParams { GLuint minFilter; GLuint magFilter; GLuint wrapS; GLuint wrapT; }TexParams; public: /** sets the default pixel format for UIImagescontains alpha channel. If the UIImage contains alpha channel, then the options are: - generate 32-bit textures: Texture2D::PixelFormat::RGBA8888 (default one) - generate 24-bit textures: Texture2D::PixelFormat::RGB888 - generate 16-bit textures: Texture2D::PixelFormat::RGBA4444 - generate 16-bit textures: Texture2D::PixelFormat::RGB5A1 - generate 16-bit textures: Texture2D::PixelFormat::RGB565 - generate 8-bit textures: Texture2D::PixelFormat::A8 (only use it if you use just 1 color) How does it work ? - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture) - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used. This parameter is not valid for PVR / PVR.CCZ images. @since v0.8 */ static void setDefaultAlphaPixelFormat(Texture2D::PixelFormat format); /** returns the alpha pixel format @since v0.8 */ static Texture2D::PixelFormat getDefaultAlphaPixelFormat(); CC_DEPRECATED_ATTRIBUTE static Texture2D::PixelFormat defaultAlphaPixelFormat() { return Texture2D::getDefaultAlphaPixelFormat(); }; /** treats (or not) PVR files as if they have alpha premultiplied. Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is possible load them as if they have (or not) the alpha channel premultiplied. By default it is disabled. @since v0.99.5 */ static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied); public: /** * @js ctor */ Texture2D(); /** * @js NA * @lua NA */ virtual ~Texture2D(); /** * @js NA * @lua NA */ virtual std::string getDescription() const; /** These functions are needed to create mutable textures * @js NA * @lua NA */ void releaseData(void *data); /** * @js NA * @lua NA */ void* keepData(void *data, unsigned int length); /** Initializes with a texture2d with data * @js NA * @lua NA */ bool initWithData(const void *data, ssize_t dataLen, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size& contentSize); /** Initializes with mipmaps */ bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh); /** Drawing extensions to make it easy to draw basic quads using a Texture2D object. These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled. */ /** draws a texture at a given point */ void drawAtPoint(const Point& point); /** draws a texture inside a rect */ void drawInRect(const Rect& rect); /** Extensions to make it easy to create a Texture2D object from an image file. */ /** Initializes a texture from a UIImage object. We will use the format you specified with setDefaultAlphaPixelFormat to convert the image for texture. NOTE: It will not convert the pvr image file. */ bool initWithImage(Image * image); /** Initializes a texture from a UIImage object. we will use the format you passed to the function to convert the image format to the texture format. If you pass PixelFormat::Automatic, we will auto detect the image render type and use that type for texture to render. **/ bool initWithImage(Image * image, PixelFormat format); /** Initializes a texture from a string with dimensions, alignment, font name and font size */ bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), TextHAlignment hAlignment = TextHAlignment::CENTER, TextVAlignment vAlignment = TextVAlignment::TOP); /** Initializes a texture from a string using a text definition*/ bool initWithString(const char *text, const FontDefinition& textDefinition); /** sets the min filter, mag filter, wrap s and wrap t texture parameters. If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}. @warning Calling this method could allocate additional texture memory. @since v0.8 * @code * When this function bound into js or lua,the input parameter will be changed * In js: var setBlendFunc(var arg1, var arg2, var arg3, var arg4) * In lua: local setBlendFunc(local arg1, local arg2, local arg3, local arg4) * @endcode */ void setTexParameters(const TexParams& texParams); /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE void setTexParameters(const TexParams* texParams) { return setTexParameters(*texParams); }; /** sets antialias texture parameters: - GL_TEXTURE_MIN_FILTER = GL_LINEAR - GL_TEXTURE_MAG_FILTER = GL_LINEAR @warning Calling this method could allocate additional texture memory. @since v0.8 */ void setAntiAliasTexParameters(); /** sets alias texture parameters: - GL_TEXTURE_MIN_FILTER = GL_NEAREST - GL_TEXTURE_MAG_FILTER = GL_NEAREST @warning Calling this method could allocate additional texture memory. @since v0.8 */ void setAliasTexParameters(); /** Generates mipmap images for the texture. It only works if the texture size is POT (power of 2). @since v0.99.0 */ void generateMipmap(); /** returns the pixel format. @since v2.0 */ const char* getStringForFormat() const; CC_DEPRECATED_ATTRIBUTE const char* stringForFormat() const { return getStringForFormat(); }; /** returns the bits-per-pixel of the in-memory OpenGL texture @since v1.0 */ unsigned int getBitsPerPixelForFormat() const; CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat() const { return getBitsPerPixelForFormat(); }; /** Helper functions that returns bits per pixels for a given format. @since v2.0 */ unsigned int getBitsPerPixelForFormat(Texture2D::PixelFormat format) const; CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat(Texture2D::PixelFormat format) const { return getBitsPerPixelForFormat(format); }; /** content size */ const Size& getContentSizeInPixels(); bool hasPremultipliedAlpha() const; bool hasMipmaps() const; /** Gets the pixel format of the texture */ Texture2D::PixelFormat getPixelFormat() const; /** Gets the width of the texture in pixels */ int getPixelsWide() const; /** Gets the height of the texture in pixels */ int getPixelsHigh() const; /** Gets the texture name */ GLuint getName() const; /** Gets max S */ GLfloat getMaxS() const; /** Sets max S */ void setMaxS(GLfloat maxS); /** Gets max T */ GLfloat getMaxT() const; /** Sets max T */ void setMaxT(GLfloat maxT); Size getContentSize() const; void setShaderProgram(GLProgram* program); GLProgram* getShaderProgram() const; public: static const PixelFormatInfoMap& getPixelFormatInfoMap(); private: /**convert functions*/ /** Convert the format to the format param you specified, if the format is PixelFormat::Automatic, it will detect it automatically and convert to the closest format for you. It will return the converted format to you. if the outData != data, you must delete it manually. */ static PixelFormat convertDataToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, ssize_t* outDataLen); static PixelFormat convertI8ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen); static PixelFormat convertAI88ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen); static PixelFormat convertRGB888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen); static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen); //I8 to XXX static void convertI8ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertI8ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertI8ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertI8ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertI8ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertI8ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData); //AI88 to XXX static void convertAI88ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertAI88ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertAI88ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertAI88ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertAI88ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertAI88ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertAI88ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData); //RGB888 to XXX static void convertRGB888ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGB888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGB888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGB888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGB888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGB888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData); //RGBA8888 to XXX static void convertRGBA8888ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGBA8888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGBA8888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGBA8888ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGBA8888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGBA8888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData); static void convertRGBA8888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData); protected: /** pixel format of the texture */ Texture2D::PixelFormat _pixelFormat; /** width in pixels */ int _pixelsWide; /** height in pixels */ int _pixelsHigh; /** texture name */ GLuint _name; /** texture max S */ GLfloat _maxS; /** texture max T */ GLfloat _maxT; /** content size */ Size _contentSize; /** whether or not the texture has their Alpha premultiplied */ bool _hasPremultipliedAlpha; bool _hasMipmaps; /** shader program used by drawAtPoint and drawInRect */ GLProgram* _shaderProgram; static const PixelFormatInfoMap _pixelFormatInfoTables; }; // end of textures group /// @} NS_CC_END #endif //__CCTEXTURE2D_H__ ================================================ FILE: cocos2d/cocos/2d/CCTextureAtlas.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ // cocos2d #include "CCTextureAtlas.h" #include "CCTextureCache.h" #include "ccMacros.h" #include "CCGLProgram.h" #include "ccGLStateCache.h" #include "CCEventType.h" #include "CCDirector.h" #include "CCGL.h" #include "CCConfiguration.h" // support #include "CCTexture2D.h" #include "CCString.h" #include #include "CCEventDispatcher.h" #include "CCEventListenerCustom.h" //According to some tests GL_TRIANGLE_STRIP is slower, MUCH slower. Probably I'm doing something very wrong // implementation TextureAtlas NS_CC_BEGIN TextureAtlas::TextureAtlas() :_indices(nullptr) ,_dirty(false) ,_texture(nullptr) ,_quads(nullptr) #if CC_ENABLE_CACHE_TEXTURE_DATA ,_backToForegroundlistener(nullptr) #endif {} TextureAtlas::~TextureAtlas() { CCLOGINFO("deallocing TextureAtlas: %p", this); CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); glDeleteBuffers(2, _buffersVBO); if (Configuration::getInstance()->supportsShareableVAO()) { glDeleteVertexArrays(1, &_VAOname); GL::bindVAO(0); } CC_SAFE_RELEASE(_texture); #if CC_ENABLE_CACHE_TEXTURE_DATA Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener); #endif } ssize_t TextureAtlas::getTotalQuads() const { return _totalQuads; } ssize_t TextureAtlas::getCapacity() const { return _capacity; } Texture2D* TextureAtlas::getTexture() const { return _texture; } void TextureAtlas::setTexture(Texture2D * var) { CC_SAFE_RETAIN(var); CC_SAFE_RELEASE(_texture); _texture = var; } V3F_C4B_T2F_Quad* TextureAtlas::getQuads() { //if someone accesses the quads directly, presume that changes will be made _dirty = true; return _quads; } void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads) { _quads = quads; } // TextureAtlas - alloc & init TextureAtlas * TextureAtlas::create(const std::string& file, ssize_t capacity) { TextureAtlas * textureAtlas = new TextureAtlas(); if(textureAtlas && textureAtlas->initWithFile(file, capacity)) { textureAtlas->autorelease(); return textureAtlas; } CC_SAFE_DELETE(textureAtlas); return nullptr; } TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, ssize_t capacity) { TextureAtlas * textureAtlas = new TextureAtlas(); if (textureAtlas && textureAtlas->initWithTexture(texture, capacity)) { textureAtlas->autorelease(); return textureAtlas; } CC_SAFE_DELETE(textureAtlas); return nullptr; } bool TextureAtlas::initWithFile(const std::string& file, ssize_t capacity) { // retained in property Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file); if (texture) { return initWithTexture(texture, capacity); } else { CCLOG("cocos2d: Could not open file: %s", file.c_str()); return false; } } bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity) { CCASSERT(capacity>=0, "Capacity must be >= 0"); // CCASSERT(texture != nullptr, "texture should not be null"); _capacity = capacity; _totalQuads = 0; // retained in property this->_texture = texture; CC_SAFE_RETAIN(_texture); // Re-initialization is not allowed CCASSERT(_quads == nullptr && _indices == nullptr, ""); _quads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(V3F_C4B_T2F_Quad) ); _indices = (GLushort *)malloc( _capacity * 6 * sizeof(GLushort) ); if( ! ( _quads && _indices) && _capacity > 0) { //CCLOG("cocos2d: TextureAtlas: not enough memory"); CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); // release texture, should set it to null, because the destruction will // release it too. see cocos2d-x issue #484 CC_SAFE_RELEASE_NULL(_texture); return false; } memset( _quads, 0, _capacity * sizeof(V3F_C4B_T2F_Quad) ); memset( _indices, 0, _capacity * 6 * sizeof(GLushort) ); #if CC_ENABLE_CACHE_TEXTURE_DATA // listen the event when app go to background _backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(TextureAtlas::listenBackToForeground, this)); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1); #endif this->setupIndices(); if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); } else { setupVBO(); } _dirty = true; return true; } void TextureAtlas::listenBackToForeground(EventCustom* event) { if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); } else { setupVBO(); } // set _dirty to true to force it rebinding buffer _dirty = true; } std::string TextureAtlas::getDescription() const { return StringUtils::format("", static_cast(_totalQuads)); } void TextureAtlas::setupIndices() { if (_capacity == 0) return; for( int i=0; i < _capacity; i++) { #if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP _indices[i*6+0] = i*4+0; _indices[i*6+1] = i*4+0; _indices[i*6+2] = i*4+2; _indices[i*6+3] = i*4+1; _indices[i*6+4] = i*4+3; _indices[i*6+5] = i*4+3; #else _indices[i*6+0] = i*4+0; _indices[i*6+1] = i*4+1; _indices[i*6+2] = i*4+2; // inverted index. issue #179 _indices[i*6+3] = i*4+3; _indices[i*6+4] = i*4+2; _indices[i*6+5] = i*4+1; #endif } } //TextureAtlas - VAO / VBO specific void TextureAtlas::setupVBOandVAO() { glGenVertexArrays(1, &_VAOname); GL::bindVAO(_VAOname); #define kQuadSize sizeof(_quads[0].bl) glGenBuffers(2, &_buffersVBO[0]); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); // vertices glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW); // Must unbind the VAO before changing the element buffer. GL::bindVAO(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); CHECK_GL_ERROR_DEBUG(); } void TextureAtlas::setupVBO() { glGenBuffers(2, &_buffersVBO[0]); mapBuffers(); } void TextureAtlas::mapBuffers() { // Avoid changing the element buffer for whatever VAO might be bound. GL::bindVAO(0); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); CHECK_GL_ERROR_DEBUG(); } // TextureAtlas - Update, Insert, Move & Remove void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, ssize_t index) { CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index"); _totalQuads = MAX( index+1, _totalQuads); _quads[index] = *quad; _dirty = true; } void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, ssize_t index) { CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index"); _totalQuads++; CCASSERT( _totalQuads <= _capacity, "invalid totalQuads"); // issue #575. index can be > totalQuads auto remaining = (_totalQuads-1) - index; // last object doesn't need to be moved if( remaining > 0) { // texture coordinates memmove( &_quads[index+1],&_quads[index], sizeof(_quads[0]) * remaining ); } _quads[index] = *quad; _dirty = true; } void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, ssize_t index, ssize_t amount) { CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount"); _totalQuads += amount; CCASSERT( _totalQuads <= _capacity, "invalid totalQuads"); // issue #575. index can be > totalQuads auto remaining = (_totalQuads-1) - index - amount; // last object doesn't need to be moved if( remaining > 0) { // tex coordinates memmove( &_quads[index+amount],&_quads[index], sizeof(_quads[0]) * remaining ); } auto max = index + amount; int j = 0; for (ssize_t i = index; i < max ; i++) { _quads[index] = quads[j]; index++; j++; } _dirty = true; } void TextureAtlas::insertQuadFromIndex(ssize_t oldIndex, ssize_t newIndex) { CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); if( oldIndex == newIndex ) { return; } // because it is ambiguous in iphone, so we implement abs ourselves // unsigned int howMany = abs( oldIndex - newIndex); auto howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex); auto dst = oldIndex; auto src = oldIndex + 1; if( oldIndex > newIndex) { dst = newIndex+1; src = newIndex; } // texture coordinates V3F_C4B_T2F_Quad quadsBackup = _quads[oldIndex]; memmove( &_quads[dst],&_quads[src], sizeof(_quads[0]) * howMany ); _quads[newIndex] = quadsBackup; _dirty = true; } void TextureAtlas::removeQuadAtIndex(ssize_t index) { CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index"); auto remaining = (_totalQuads-1) - index; // last object doesn't need to be moved if( remaining ) { // texture coordinates memmove( &_quads[index],&_quads[index+1], sizeof(_quads[0]) * remaining ); } _totalQuads--; _dirty = true; } void TextureAtlas::removeQuadsAtIndex(ssize_t index, ssize_t amount) { CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds"); auto remaining = (_totalQuads) - (index + amount); _totalQuads -= amount; if ( remaining ) { memmove( &_quads[index], &_quads[index+amount], sizeof(_quads[0]) * remaining ); } _dirty = true; } void TextureAtlas::removeAllQuads() { _totalQuads = 0; } // TextureAtlas - Resize bool TextureAtlas::resizeCapacity(ssize_t newCapacity) { CCASSERT(newCapacity>=0, "capacity >= 0"); if( newCapacity == _capacity ) { return true; } auto oldCapactiy = _capacity; // update capacity and totolQuads _totalQuads = MIN(_totalQuads, newCapacity); _capacity = newCapacity; V3F_C4B_T2F_Quad* tmpQuads = nullptr; GLushort* tmpIndices = nullptr; // when calling initWithTexture(fileName, 0) on bada device, calloc(0, 1) will fail and return nullptr, // so here must judge whether _quads and _indices is nullptr. if (_quads == nullptr) { tmpQuads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(_quads[0]) ); if (tmpQuads != nullptr) { memset(tmpQuads, 0, _capacity * sizeof(_quads[0]) ); } } else { tmpQuads = (V3F_C4B_T2F_Quad*)realloc( _quads, sizeof(_quads[0]) * _capacity ); if (tmpQuads != nullptr && _capacity > oldCapactiy) { memset(tmpQuads+oldCapactiy, 0, (_capacity - oldCapactiy)*sizeof(_quads[0]) ); } } if (_indices == nullptr) { tmpIndices = (GLushort*)malloc( _capacity * 6 * sizeof(_indices[0]) ); if (tmpIndices != nullptr) { memset( tmpIndices, 0, _capacity * 6 * sizeof(_indices[0]) ); } } else { tmpIndices = (GLushort*)realloc( _indices, sizeof(_indices[0]) * _capacity * 6 ); if (tmpIndices != nullptr && _capacity > oldCapactiy) { memset( tmpIndices+oldCapactiy, 0, (_capacity-oldCapactiy) * 6 * sizeof(_indices[0]) ); } } if( ! ( tmpQuads && tmpIndices) ) { CCLOG("cocos2d: TextureAtlas: not enough memory"); CC_SAFE_FREE(tmpQuads); CC_SAFE_FREE(tmpIndices); CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); _capacity = _totalQuads = 0; return false; } _quads = tmpQuads; _indices = tmpIndices; setupIndices(); mapBuffers(); _dirty = true; return true; } void TextureAtlas::increaseTotalQuadsWith(ssize_t amount) { CCASSERT(amount>=0, "amount >= 0"); _totalQuads += amount; } void TextureAtlas::moveQuadsFromIndex(ssize_t oldIndex, ssize_t amount, ssize_t newIndex) { CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0"); CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); CCASSERT(oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); if( oldIndex == newIndex ) { return; } //create buffer size_t quadSize = sizeof(V3F_C4B_T2F_Quad); V3F_C4B_T2F_Quad* tempQuads = (V3F_C4B_T2F_Quad*)malloc( quadSize * amount); memcpy( tempQuads, &_quads[oldIndex], quadSize * amount ); if (newIndex < oldIndex) { // move quads from newIndex to newIndex + amount to make room for buffer memmove( &_quads[newIndex], &_quads[newIndex+amount], (oldIndex-newIndex)*quadSize); } else { // move quads above back memmove( &_quads[oldIndex], &_quads[oldIndex+amount], (newIndex-oldIndex)*quadSize); } memcpy( &_quads[newIndex], tempQuads, amount*quadSize); free(tempQuads); _dirty = true; } void TextureAtlas::moveQuadsFromIndex(ssize_t index, ssize_t newIndex) { CCASSERT(index>=0 && newIndex>=0, "values must be >= 0"); CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds"); memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0])); } void TextureAtlas::fillWithEmptyQuadsFromIndex(ssize_t index, ssize_t amount) { CCASSERT(index>=0 && amount>=0, "values must be >= 0"); V3F_C4B_T2F_Quad quad; memset(&quad, 0, sizeof(quad)); auto to = index + amount; for (ssize_t i = index ; i < to ; i++) { _quads[i] = quad; } } // TextureAtlas - Drawing void TextureAtlas::drawQuads() { this->drawNumberOfQuads(_totalQuads, 0); } void TextureAtlas::drawNumberOfQuads(ssize_t numberOfQuads) { CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0"); this->drawNumberOfQuads(numberOfQuads, 0); } void TextureAtlas::drawNumberOfQuads(ssize_t numberOfQuads, ssize_t start) { CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0"); if(!numberOfQuads) return; GL::bindTexture2D(_texture->getName()); if (Configuration::getInstance()->supportsShareableVAO()) { // // Using VBO and VAO // // XXX: update is done in draw... perhaps it should be done in a timer if (_dirty) { glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); // option 1: subdata // glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] ); // option 2: data // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); // option 3: orphaning + glMapBuffer glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (numberOfQuads-start), nullptr, GL_DYNAMIC_DRAW); void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); memcpy(buf, _quads, sizeof(_quads[0])* (numberOfQuads-start)); glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); _dirty = false; } GL::bindVAO(_VAOname); #if CC_REBIND_INDICES_BUFFER glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); #endif #if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); #else glDrawElements(GL_TRIANGLES, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); #endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP #if CC_REBIND_INDICES_BUFFER glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #endif // glBindVertexArray(0); } else { // // Using VBO without VAO // #define kQuadSize sizeof(_quads[0].bl) glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); // XXX: update is done in draw... perhaps it should be done in a timer if (_dirty) { glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * numberOfQuads , &_quads[start] ); _dirty = false; } GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); // vertices glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices)); // colors glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); // tex coords glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); #if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP glDrawElements(GL_TRIANGLE_STRIP, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0]))); #else glDrawElements(GL_TRIANGLES, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0]))); #endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } CC_INCREMENT_GL_DRAWS(1); CHECK_GL_ERROR_DEBUG(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTextureAtlas.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTEXTURE_ATLAS_H__ #define __CCTEXTURE_ATLAS_H__ #include "ccTypes.h" #include "CCObject.h" #include "ccConfig.h" #include NS_CC_BEGIN class Texture2D; class EventCustom; class EventListenerCustom; /** * @addtogroup textures * @{ */ /** @brief A class that implements a Texture Atlas. Supported features: * The atlas file can be a PVRTC, PNG or any other format supported by Texture2D * Quads can be updated in runtime * Quads can be added in runtime * Quads can be removed in runtime * Quads can be re-ordered in runtime * The TextureAtlas capacity can be increased or decreased in runtime * OpenGL component: V3F, C4B, T2F. The quads are rendered using an OpenGL ES VBO. To render the quads using an interleaved vertex array list, you should modify the ccConfig.h file */ class CC_DLL TextureAtlas : public Object { public: /** creates a TextureAtlas with an filename and with an initial capacity for Quads. * The TextureAtlas capacity can be increased in runtime. */ static TextureAtlas* create(const std::string& file , ssize_t capacity); /** creates a TextureAtlas with a previously initialized Texture2D object, and * with an initial capacity for n Quads. * The TextureAtlas capacity can be increased in runtime. */ static TextureAtlas* createWithTexture(Texture2D *texture, ssize_t capacity); /** * @js ctor */ TextureAtlas(); /** * @js NA * @lua NA */ virtual ~TextureAtlas(); /** initializes a TextureAtlas with a filename and with a certain capacity for Quads. * The TextureAtlas capacity can be increased in runtime. * * WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) */ bool initWithFile(const std::string& file, ssize_t capacity); /** initializes a TextureAtlas with a previously initialized Texture2D object, and * with an initial capacity for Quads. * The TextureAtlas capacity can be increased in runtime. * * WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) */ bool initWithTexture(Texture2D *texture, ssize_t capacity); /** updates a Quad (texture, vertex and color) at a certain index * index must be between 0 and the atlas capacity - 1 @since v0.8 */ void updateQuad(V3F_C4B_T2F_Quad* quad, ssize_t index); /** Inserts a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1 @since v0.8 */ void insertQuad(V3F_C4B_T2F_Quad* quad, ssize_t index); /** Inserts a c array of quads at a given index index must be between 0 and the atlas capacity - 1 this method doesn't enlarge the array when amount + index > totalQuads @since v1.1 */ void insertQuads(V3F_C4B_T2F_Quad* quads, ssize_t index, ssize_t amount); /** Removes the quad that is located at a certain index and inserts it at a new index This operation is faster than removing and inserting in a quad in 2 different steps @since v0.7.2 */ void insertQuadFromIndex(ssize_t fromIndex, ssize_t newIndex); /** removes a quad at a given index number. The capacity remains the same, but the total number of quads to be drawn is reduced in 1 @since v0.7.2 */ void removeQuadAtIndex(ssize_t index); /** removes a amount of quads starting from index @since 1.1 */ void removeQuadsAtIndex(ssize_t index, ssize_t amount); /** removes all Quads. The TextureAtlas capacity remains untouched. No memory is freed. The total number of quads to be drawn will be 0 @since v0.7.2 */ void removeAllQuads(); /** resize the capacity of the TextureAtlas. * The new capacity can be lower or higher than the current one * It returns true if the resize was successful. * If it fails to resize the capacity it will return false with a new capacity of 0. */ bool resizeCapacity(ssize_t capacity); /** Used internally by ParticleBatchNode don't use this unless you know what you're doing @since 1.1 */ void increaseTotalQuadsWith(ssize_t amount); /** Moves an amount of quads from oldIndex at newIndex @since v1.1 */ void moveQuadsFromIndex(ssize_t oldIndex, ssize_t amount, ssize_t newIndex); /** Moves quads from index till totalQuads to the newIndex Used internally by ParticleBatchNode This method doesn't enlarge the array if newIndex + quads to be moved > capacity @since 1.1 */ void moveQuadsFromIndex(ssize_t index, ssize_t newIndex); /** Ensures that after a realloc quads are still empty Used internally by ParticleBatchNode @since 1.1 */ void fillWithEmptyQuadsFromIndex(ssize_t index, ssize_t amount); /** draws n quads * n can't be greater than the capacity of the Atlas */ void drawNumberOfQuads(ssize_t n); /** draws n quads from an index (offset). n + start can't be greater than the capacity of the atlas @since v1.0 */ void drawNumberOfQuads(ssize_t numberOfQuads, ssize_t start); /** draws all the Atlas's Quads */ void drawQuads(); /** listen the event that coming to foreground on Android */ void listenBackToForeground(EventCustom* event); /** whether or not the array buffer of the VBO needs to be updated*/ inline bool isDirty(void) { return _dirty; } /** specify if the array buffer of the VBO needs to be updated */ inline void setDirty(bool bDirty) { _dirty = bDirty; } /** * @js NA * @lua NA */ virtual std::string getDescription() const; /** Gets the quantity of quads that are going to be drawn */ ssize_t getTotalQuads() const; /** Gets the quantity of quads that can be stored with the current texture atlas size */ ssize_t getCapacity() const; /** Gets the texture of the texture atlas */ Texture2D* getTexture() const; /** Sets the texture for the texture atlas */ void setTexture(Texture2D* texture); /** Gets the quads that are going to be rendered */ V3F_C4B_T2F_Quad* getQuads(); /** Sets the quads that are going to be rendered */ void setQuads(V3F_C4B_T2F_Quad* quads); private: void renderCommand(); void setupIndices(); void mapBuffers(); void setupVBOandVAO(); void setupVBO(); protected: GLushort* _indices; GLuint _VAOname; GLuint _buffersVBO[2]; //0: vertex 1: indices bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated /** quantity of quads that are going to be drawn */ ssize_t _totalQuads; /** quantity of quads that can be stored with the current texture atlas size */ ssize_t _capacity; /** Texture of the texture atlas */ Texture2D* _texture; /** Quads that are going to be rendered */ V3F_C4B_T2F_Quad* _quads; #if CC_ENABLE_CACHE_TEXTURE_DATA EventListenerCustom* _backToForegroundlistener; #endif }; // end of textures group /// @} NS_CC_END #endif //__CCTEXTURE_ATLAS_H__ ================================================ FILE: cocos2d/cocos/2d/CCTextureCache.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include #include #include #include "CCTextureCache.h" #include "CCTexture2D.h" #include "ccMacros.h" #include "CCDirector.h" #include "platform/CCFileUtils.h" #include "ccUtils.h" #include "CCScheduler.h" #include "CCString.h" #ifdef EMSCRIPTEN #include #include "platform/emscripten/CCTextureCacheEmscripten.h" #endif // EMSCRIPTEN using namespace std; NS_CC_BEGIN // implementation TextureCache TextureCache * TextureCache::getInstance() { return Director::getInstance()->getTextureCache(); } TextureCache::TextureCache() : _loadingThread(nullptr) , _asyncStructQueue(nullptr) , _imageInfoQueue(nullptr) , _needQuit(false) , _asyncRefCount(0) { } TextureCache::~TextureCache() { CCLOGINFO("deallocing TextureCache: %p", this); for( auto it=_textures.begin(); it!=_textures.end(); ++it) (it->second)->release(); CC_SAFE_DELETE(_loadingThread); } void TextureCache::destroyInstance() { } TextureCache * TextureCache::sharedTextureCache() { return Director::getInstance()->getTextureCache(); } void TextureCache::purgeSharedTextureCache() { } std::string TextureCache::getDescription() const { return StringUtils::format("", static_cast(_textures.size())); } void TextureCache::addImageAsync(const std::string &path, std::function callback) { Texture2D *texture = nullptr; std::string fullpath = FileUtils::getInstance()->fullPathForFilename(path); auto it = _textures.find(fullpath); if( it != _textures.end() ) texture = it->second; if (texture != nullptr) { callback(texture); return; } // lazy init if (_asyncStructQueue == nullptr) { _asyncStructQueue = new queue(); _imageInfoQueue = new deque(); // create a new thread to load images _loadingThread = new std::thread(&TextureCache::loadImage, this); _needQuit = false; } if (0 == _asyncRefCount) { Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(TextureCache::addImageAsyncCallBack), this, 0, false); } ++_asyncRefCount; // generate async struct AsyncStruct *data = new AsyncStruct(fullpath, callback); // add async struct into queue _asyncStructQueueMutex.lock(); _asyncStructQueue->push(data); _asyncStructQueueMutex.unlock(); _sleepCondition.notify_one(); } void TextureCache::loadImage() { AsyncStruct *asyncStruct = nullptr; while (true) { std::queue *pQueue = _asyncStructQueue; _asyncStructQueueMutex.lock(); if (pQueue->empty()) { _asyncStructQueueMutex.unlock(); if (_needQuit) { break; } else { std::unique_lock lk(_sleepMutex); _sleepCondition.wait(lk); continue; } } else { asyncStruct = pQueue->front(); pQueue->pop(); _asyncStructQueueMutex.unlock(); } Image *image = nullptr; bool generateImage = false; auto it = _textures.find(asyncStruct->filename); if( it == _textures.end() ) { _imageInfoMutex.lock(); ImageInfo *imageInfo; size_t pos = 0; size_t infoSize = _imageInfoQueue->size(); for (; pos < infoSize; pos++) { imageInfo = (*_imageInfoQueue)[pos]; if(imageInfo->asyncStruct->filename.compare(asyncStruct->filename)) break; } _imageInfoMutex.unlock(); if(infoSize == 0 || pos < infoSize) generateImage = true; } if (generateImage) { const std::string& filename = asyncStruct->filename; // generate image image = new Image(); if (image && !image->initWithImageFileThreadSafe(filename)) { CC_SAFE_RELEASE(image); CCLOG("can not load %s", filename.c_str()); continue; } } // generate image info ImageInfo *imageInfo = new ImageInfo(); imageInfo->asyncStruct = asyncStruct; imageInfo->image = image; // put the image info into the queue _imageInfoMutex.lock(); _imageInfoQueue->push_back(imageInfo); _imageInfoMutex.unlock(); } if(_asyncStructQueue != nullptr) { delete _asyncStructQueue; _asyncStructQueue = nullptr; delete _imageInfoQueue; _imageInfoQueue = nullptr; } } void TextureCache::addImageAsyncCallBack(float dt) { // the image is generated in loading thread std::deque *imagesQueue = _imageInfoQueue; _imageInfoMutex.lock(); if (imagesQueue->empty()) { _imageInfoMutex.unlock(); } else { ImageInfo *imageInfo = imagesQueue->front(); imagesQueue->pop_front(); _imageInfoMutex.unlock(); AsyncStruct *asyncStruct = imageInfo->asyncStruct; Image *image = imageInfo->image; const std::string& filename = asyncStruct->filename; Texture2D *texture = nullptr; if (image) { // generate texture in render thread texture = new Texture2D(); texture->initWithImage(image); #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTextureMgr::addImageTexture(texture, filename); #endif // cache the texture. retain it, since it is added in the map _textures.insert( std::make_pair(filename, texture) ); texture->retain(); texture->autorelease(); } else { auto it = _textures.find(asyncStruct->filename); if(it != _textures.end()) texture = it->second; } asyncStruct->callback(texture); if(image) { image->release(); } delete asyncStruct; delete imageInfo; --_asyncRefCount; if (0 == _asyncRefCount) { Director::getInstance()->getScheduler()->unscheduleSelector(schedule_selector(TextureCache::addImageAsyncCallBack), this); } } } Texture2D * TextureCache::addImage(const std::string &path) { Texture2D * texture = nullptr; Image* image = nullptr; // Split up directory and filename // MUTEX: // Needed since addImageAsync calls this method from a different thread std::string fullpath = FileUtils::getInstance()->fullPathForFilename(path); if (fullpath.size() == 0) { return nullptr; } auto it = _textures.find(fullpath); if( it != _textures.end() ) texture = it->second; if (! texture) { // all images are handled by UIImage except PVR extension that is handled by our own handler do { image = new Image(); CC_BREAK_IF(nullptr == image); bool bRet = image->initWithImageFile(fullpath); CC_BREAK_IF(!bRet); texture = new Texture2D(); if( texture && texture->initWithImage(image) ) { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTextureMgr::addImageTexture(texture, fullpath); #endif // texture already retained, no need to re-retain it _textures.insert( std::make_pair(fullpath, texture) ); } else { CCLOG("cocos2d: Couldn't create texture for file:%s in TextureCache", path.c_str()); } } while (0); } CC_SAFE_RELEASE(image); return texture; } Texture2D* TextureCache::addImage(Image *image, const std::string &key) { CCASSERT(image != nullptr, "TextureCache: image MUST not be nil"); Texture2D * texture = nullptr; do { auto it = _textures.find(key); if( it != _textures.end() ) { texture = it->second; break; } // prevents overloading the autorelease pool texture = new Texture2D(); texture->initWithImage(image); if(texture) { _textures.insert( std::make_pair(key, texture) ); texture->retain(); texture->autorelease(); } else { CCLOG("cocos2d: Couldn't add UIImage in TextureCache"); } } while (0); #if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTextureMgr::addImage(texture, image); #endif return texture; } // TextureCache - Remove void TextureCache::removeAllTextures() { for( auto it=_textures.begin(); it!=_textures.end(); ++it ) { (it->second)->release(); } _textures.clear(); } void TextureCache::removeUnusedTextures() { for( auto it=_textures.cbegin(); it!=_textures.cend(); /* nothing */) { Texture2D *tex = it->second; if( tex->getReferenceCount() == 1 ) { CCLOG("cocos2d: TextureCache: removing unused texture: %s", it->first.c_str()); tex->release(); _textures.erase(it++); } else { ++it; } } } void TextureCache::removeTexture(Texture2D* texture) { if( ! texture ) { return; } for( auto it=_textures.cbegin(); it!=_textures.cend(); /* nothing */ ) { if( it->second == texture ) { texture->release(); _textures.erase(it++); break; } else ++it; } } void TextureCache::removeTextureForKey(const std::string &textureKeyName) { std::string key = textureKeyName; auto it = _textures.find(key); if( it == _textures.end() ) { key = FileUtils::getInstance()->fullPathForFilename(textureKeyName); it = _textures.find(key); } if( it != _textures.end() ) { (it->second)->release(); _textures.erase(it); } } Texture2D* TextureCache::getTextureForKey(const std::string &textureKeyName) const { std::string key = textureKeyName; auto it = _textures.find(key); if( it == _textures.end() ) { key = FileUtils::getInstance()->fullPathForFilename(textureKeyName); it = _textures.find(key); } if( it != _textures.end() ) return it->second; return nullptr; } void TextureCache::reloadAllTextures() { //will do nothing // #if CC_ENABLE_CACHE_TEXTURE_DATA // VolatileTextureMgr::reloadAllTextures(); // #endif } void TextureCache::waitForQuit() { // notify sub thread to quick _needQuit = true; _sleepCondition.notify_one(); if (_loadingThread) _loadingThread->join(); } std::string TextureCache::getCachedTextureInfo() const { char buffer[16386]; char buftmp[4096]; memset(buffer,0,sizeof(buffer)); unsigned int count = 0; unsigned int totalBytes = 0; for( auto it = _textures.begin(); it != _textures.end(); ++it ) { memset(buftmp,0,sizeof(buftmp)); Texture2D* tex = it->second; unsigned int bpp = tex->getBitsPerPixelForFormat(); // Each texture takes up width * height * bytesPerPixel bytes. auto bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8; totalBytes += bytes; count++; snprintf(buftmp,sizeof(buftmp)-1,"\"%s\" rc=%lu id=%lu %lu x %lu @ %ld bpp => %lu KB\n", it->first.c_str(), (long)tex->getReferenceCount(), (long)tex->getName(), (long)tex->getPixelsWide(), (long)tex->getPixelsHigh(), (long)bpp, (long)bytes / 1024); strcat(buffer, buftmp); } snprintf(buftmp, sizeof(buftmp)-1, "TextureCache dumpDebugInfo: %ld textures, for %lu KB (%.2f MB)\n", (long)count, (long)totalBytes / 1024, totalBytes / (1024.0f*1024.0f)); strcat(buffer, buftmp); return std::string(buffer); } #if CC_ENABLE_CACHE_TEXTURE_DATA std::list VolatileTextureMgr::_textures; bool VolatileTextureMgr::_isReloading = false; VolatileTexture::VolatileTexture(Texture2D *t) : _texture(t) , _cashedImageType(kInvalid) , _textureData(nullptr) , _pixelFormat(Texture2D::PixelFormat::RGBA8888) , _fileName("") , _text("") , _uiImage(nullptr) { _texParams.minFilter = GL_LINEAR; _texParams.magFilter = GL_LINEAR; _texParams.wrapS = GL_CLAMP_TO_EDGE; _texParams.wrapT = GL_CLAMP_TO_EDGE; } VolatileTexture::~VolatileTexture() { CC_SAFE_RELEASE(_uiImage); } void VolatileTextureMgr::addImageTexture(Texture2D *tt, const std::string& imageFileName) { if (_isReloading) { return; } VolatileTexture *vt = findVolotileTexture(tt); vt->_cashedImageType = VolatileTexture::kImageFile; vt->_fileName = imageFileName; vt->_pixelFormat = tt->getPixelFormat(); } void VolatileTextureMgr::addImage(Texture2D *tt, Image *image) { VolatileTexture *vt = findVolotileTexture(tt); image->retain(); vt->_uiImage = image; vt->_cashedImageType = VolatileTexture::kImage; } VolatileTexture* VolatileTextureMgr::findVolotileTexture(Texture2D *tt) { VolatileTexture *vt = 0; auto i = _textures.begin(); while (i != _textures.end()) { VolatileTexture *v = *i++; if (v->_texture == tt) { vt = v; break; } } if (! vt) { vt = new VolatileTexture(tt); _textures.push_back(vt); } return vt; } void VolatileTextureMgr::addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize) { if (_isReloading) { return; } VolatileTexture *vt = findVolotileTexture(tt); vt->_cashedImageType = VolatileTexture::kImageData; vt->_textureData = data; vt->_dataLen = dataLen; vt->_pixelFormat = pixelFormat; vt->_textureSize = contentSize; } void VolatileTextureMgr::addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition) { if (_isReloading) { return; } VolatileTexture *vt = findVolotileTexture(tt); vt->_cashedImageType = VolatileTexture::kString; vt->_text = text; vt->_fontDefinition = fontDefinition; } void VolatileTextureMgr::setTexParameters(Texture2D *t, const Texture2D::TexParams &texParams) { VolatileTexture *vt = findVolotileTexture(t); if (texParams.minFilter != GL_NONE) vt->_texParams.minFilter = texParams.minFilter; if (texParams.magFilter != GL_NONE) vt->_texParams.magFilter = texParams.magFilter; if (texParams.wrapS != GL_NONE) vt->_texParams.wrapS = texParams.wrapS; if (texParams.wrapT != GL_NONE) vt->_texParams.wrapT = texParams.wrapT; } void VolatileTextureMgr::removeTexture(Texture2D *t) { auto i = _textures.begin(); while (i != _textures.end()) { VolatileTexture *vt = *i++; if (vt->_texture == t) { _textures.remove(vt); delete vt; break; } } } void VolatileTextureMgr::reloadAllTextures() { _isReloading = true; CCLOG("reload all texture"); auto iter = _textures.begin(); while (iter != _textures.end()) { VolatileTexture *vt = *iter++; switch (vt->_cashedImageType) { case VolatileTexture::kImageFile: { Image* image = new Image(); Data data = FileUtils::getInstance()->getDataFromFile(vt->_fileName); if (image && image->initWithImageData(data.getBytes(), data.getSize())) { Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat); vt->_texture->initWithImage(image); Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat); } CC_SAFE_RELEASE(image); } break; case VolatileTexture::kImageData: { vt->_texture->initWithData(vt->_textureData, vt->_dataLen, vt->_pixelFormat, vt->_textureSize.width, vt->_textureSize.height, vt->_textureSize); } break; case VolatileTexture::kString: { vt->_texture->initWithString(vt->_text.c_str(), vt->_fontDefinition); } break; case VolatileTexture::kImage: { vt->_texture->initWithImage(vt->_uiImage); } break; default: break; } vt->_texture->setTexParameters(vt->_texParams); } _isReloading = false; } #endif // CC_ENABLE_CACHE_TEXTURE_DATA NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTextureCache.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTEXTURE_CACHE_H__ #define __CCTEXTURE_CACHE_H__ #include #include #include #include #include #include #include #include #include "CCObject.h" #include "CCTexture2D.h" #include "platform/CCImage.h" #if CC_ENABLE_CACHE_TEXTURE_DATA #include "platform/CCImage.h" #include #endif NS_CC_BEGIN /** * @addtogroup textures * @{ */ /* * from version 3.0, TextureCache will never to treated as a singleton, it will be owned by director. * all call by TextureCache::getInstance() should be replaced by Director::getInstance()->getTextureCache() */ /** @brief Singleton that handles the loading of textures * Once the texture is loaded, the next time it will return * a reference of the previously loaded texture reducing GPU & CPU memory */ class CC_DLL TextureCache : public Object { public: /** Returns the shared instance of the cache */ CC_DEPRECATED_ATTRIBUTE static TextureCache * getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static TextureCache * sharedTextureCache(); /** purges the cache. It releases the retained instance. @since v0.99.0 */ CC_DEPRECATED_ATTRIBUTE static void destroyInstance(); /** @deprecated Use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedTextureCache(); /** Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures */ CC_DEPRECATED_ATTRIBUTE static void reloadAllTextures(); public: /** * @js ctor */ TextureCache(); /** * @js NA * @lua NA */ virtual ~TextureCache(); /** * @js NA * @lua NA */ virtual std::string getDescription() const; // Dictionary* snapshotTextures(); /** Returns a Texture2D object given an filename. * If the filename was not previously loaded, it will create a new Texture2D * object and it will return it. It will use the filename as a key. * Otherwise it will return a reference of a previously loaded image. * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr */ Texture2D* addImage(const std::string &filepath); /* Returns a Texture2D object given a file image * If the file image was not previously loaded, it will create a new Texture2D object and it will return it. * Otherwise it will load a texture in a new thread, and when the image is loaded, the callback will be called with the Texture2D as a parameter. * The callback will be called from the main thread, so it is safe to create any cocos2d object from the callback. * Supported image extensions: .png, .jpg * @since v0.8 */ virtual void addImageAsync(const std::string &filepath, std::function callback); /** Returns a Texture2D object given an Image. * If the image was not previously loaded, it will create a new Texture2D object and it will return it. * Otherwise it will return a reference of a previously loaded image. * The "key" parameter will be used as the "key" for the cache. * If "key" is nil, then a new texture will be created each time. */ Texture2D* addImage(Image *image, const std::string &key); CC_DEPRECATED_ATTRIBUTE Texture2D* addUIImage(Image *image, const std::string& key) { return addImage(image,key); } /** Returns an already created texture. Returns nil if the texture doesn't exist. @since v0.99.5 */ Texture2D* getTextureForKey(const std::string& key) const; CC_DEPRECATED_ATTRIBUTE Texture2D* textureForKey(const std::string& key) const { return getTextureForKey(key); } /** Purges the dictionary of loaded textures. * Call this method if you receive the "Memory Warning" * In the short term: it will free some resources preventing your app from being killed * In the medium term: it will allocate more resources * In the long term: it will be the same */ void removeAllTextures(); /** Removes unused textures * Textures that have a retain count of 1 will be deleted * It is convenient to call this method after when starting a new Scene * @since v0.8 */ void removeUnusedTextures(); /** Deletes a texture from the cache given a texture */ void removeTexture(Texture2D* texture); /** Deletes a texture from the cache given a its key name @since v0.99.4 */ void removeTextureForKey(const std::string &key); /** Output to CCLOG the current contents of this TextureCache * This will attempt to calculate the size of each texture, and the total texture memory in use * * @since v1.0 */ std::string getCachedTextureInfo() const; //wait for texture cahe to quit befor destroy instance //called by director, please do not called outside void waitForQuit(); private: void addImageAsyncCallBack(float dt); void loadImage(); public: struct AsyncStruct { public: AsyncStruct(const std::string& fn, std::function f) : filename(fn), callback(f) {} std::string filename; std::function callback; }; protected: typedef struct _ImageInfo { AsyncStruct *asyncStruct; Image *image; } ImageInfo; std::thread* _loadingThread; std::queue* _asyncStructQueue; std::deque* _imageInfoQueue; std::mutex _asyncStructQueueMutex; std::mutex _imageInfoMutex; std::mutex _sleepMutex; std::condition_variable _sleepCondition; bool _needQuit; int _asyncRefCount; std::unordered_map _textures; }; #if CC_ENABLE_CACHE_TEXTURE_DATA class VolatileTexture { typedef enum { kInvalid = 0, kImageFile, kImageData, kString, kImage, }ccCachedImageType; private: VolatileTexture(Texture2D *t); /** * @js NA * @lua NA */ ~VolatileTexture(); protected: friend class VolatileTextureMgr; Texture2D *_texture; Image *_uiImage; ccCachedImageType _cashedImageType; void *_textureData; int _dataLen; Size _textureSize; Texture2D::PixelFormat _pixelFormat; std::string _fileName; Texture2D::TexParams _texParams; std::string _text; FontDefinition _fontDefinition; }; class VolatileTextureMgr { public: static void addImageTexture(Texture2D *tt, const std::string& imageFileName); static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition); static void addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize); static void addImage(Texture2D *tt, Image *image); static void setTexParameters(Texture2D *t, const Texture2D::TexParams &texParams); static void removeTexture(Texture2D *t); static void reloadAllTextures(); public: static std::list _textures; static bool _isReloading; private: // find VolatileTexture by Texture2D* // if not found, create a new one static VolatileTexture* findVolotileTexture(Texture2D *tt); }; #endif // end of textures group /// @} NS_CC_END #endif //__CCTEXTURE_CACHE_H__ ================================================ FILE: cocos2d/cocos/2d/CCTileMapAtlas.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTileMapAtlas.h" #include "platform/CCFileUtils.h" #include "CCTextureAtlas.h" #include "TGAlib.h" #include "ccConfig.h" #include "CCInteger.h" #include "CCDirector.h" #include "CCString.h" #include NS_CC_BEGIN // implementation TileMapAtlas TileMapAtlas * TileMapAtlas::create(const std::string& tile, const std::string& mapFile, int tileWidth, int tileHeight) { TileMapAtlas *ret = new TileMapAtlas(); if (ret->initWithTileFile(tile, mapFile, tileWidth, tileHeight)) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } bool TileMapAtlas::initWithTileFile(const std::string& tile, const std::string& mapFile, int tileWidth, int tileHeight) { this->loadTGAfile(mapFile); this->calculateItemsToRender(); if( AtlasNode::initWithTileFile(tile, tileWidth, tileHeight, _itemsToRender) ) { this->updateAtlasValues(); this->setContentSize(Size((float)(_TGAInfo->width*_itemWidth), (float)(_TGAInfo->height*_itemHeight))); return true; } return false; } TileMapAtlas::TileMapAtlas() : _itemsToRender(0) , _TGAInfo(nullptr) { } TileMapAtlas::~TileMapAtlas() { if (_TGAInfo) { tgaDestroy(_TGAInfo); } } void TileMapAtlas::releaseMap() { if (_TGAInfo) { tgaDestroy(_TGAInfo); } _TGAInfo = nullptr; } void TileMapAtlas::calculateItemsToRender() { CCASSERT( _TGAInfo != nullptr, "tgaInfo must be non-nil"); _itemsToRender = 0; for(int x=0;x < _TGAInfo->width; x++ ) { for( int y=0; y < _TGAInfo->height; y++ ) { Color3B *ptr = (Color3B*) _TGAInfo->imageData; Color3B value = ptr[x + y * _TGAInfo->width]; if( value.r ) { ++_itemsToRender; } } } } void TileMapAtlas::loadTGAfile(const std::string& file) { std::string fullPath = FileUtils::getInstance()->fullPathForFilename(file); // //Find the path of the file // NSBundle *mainBndl = [Director sharedDirector].loadingBundle; // String *resourcePath = [mainBndl resourcePath]; // String * path = [resourcePath stringByAppendingPathComponent:file]; _TGAInfo = tgaLoad( fullPath.c_str() ); #if 1 if( _TGAInfo->status != TGA_OK ) { CCASSERT(0, "TileMapAtlasLoadTGA : TileMapAtlas cannot load TGA file"); } #endif } // TileMapAtlas - Atlas generation / updates void TileMapAtlas::setTile(const Color3B& tile, const Point& position) { CCASSERT(_TGAInfo != nullptr, "tgaInfo must not be nil"); CCASSERT(position.x < _TGAInfo->width, "Invalid position.x"); CCASSERT(position.y < _TGAInfo->height, "Invalid position.x"); CCASSERT(tile.r != 0, "R component must be non 0"); Color3B *ptr = (Color3B*)_TGAInfo->imageData; Color3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)]; if( value.r == 0 ) { CCLOG("cocos2d: Value.r must be non 0."); } else { ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)] = tile; // XXX: this method consumes a lot of memory // XXX: a tree of something like that shall be implemented std::string key = StringUtils::toString(position.x) + "," + StringUtils::toString(position.y); int num = _posToAtlasIndex[key].asInt(); this->updateAtlasValueAt(position, tile, num); } } Color3B TileMapAtlas::getTileAt(const Point& position) const { CCASSERT( _TGAInfo != nullptr, "tgaInfo must not be nil"); CCASSERT( position.x < _TGAInfo->width, "Invalid position.x"); CCASSERT( position.y < _TGAInfo->height, "Invalid position.y"); Color3B *ptr = (Color3B*)_TGAInfo->imageData; Color3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)]; return value; } void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, int index) { CCASSERT( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index"); V3F_C4B_T2F_Quad* quad = &((_textureAtlas->getQuads())[index]); int x = pos.x; int y = pos.y; float row = (float) (value.r % _itemsPerRow); float col = (float) (value.r / _itemsPerRow); float textureWide = (float) (_textureAtlas->getTexture()->getPixelsWide()); float textureHigh = (float) (_textureAtlas->getTexture()->getPixelsHigh()); float itemWidthInPixels = _itemWidth * CC_CONTENT_SCALE_FACTOR(); float itemHeightInPixels = _itemHeight * CC_CONTENT_SCALE_FACTOR(); #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL float left = (2 * row * itemWidthInPixels + 1) / (2 * textureWide); float right = left + (itemWidthInPixels * 2 - 2) / (2 * textureWide); float top = (2 * col * itemHeightInPixels + 1) / (2 * textureHigh); float bottom = top + (itemHeightInPixels * 2 - 2) / (2 * textureHigh); #else float left = (row * itemWidthInPixels) / textureWide; float right = left + itemWidthInPixels / textureWide; float top = (col * itemHeightInPixels) / textureHigh; float bottom = top + itemHeightInPixels / textureHigh; #endif quad->tl.texCoords.u = left; quad->tl.texCoords.v = top; quad->tr.texCoords.u = right; quad->tr.texCoords.v = top; quad->bl.texCoords.u = left; quad->bl.texCoords.v = bottom; quad->br.texCoords.u = right; quad->br.texCoords.v = bottom; quad->bl.vertices.x = (float) (x * _itemWidth); quad->bl.vertices.y = (float) (y * _itemHeight); quad->bl.vertices.z = 0.0f; quad->br.vertices.x = (float)(x * _itemWidth + _itemWidth); quad->br.vertices.y = (float)(y * _itemHeight); quad->br.vertices.z = 0.0f; quad->tl.vertices.x = (float)(x * _itemWidth); quad->tl.vertices.y = (float)(y * _itemHeight + _itemHeight); quad->tl.vertices.z = 0.0f; quad->tr.vertices.x = (float)(x * _itemWidth + _itemWidth); quad->tr.vertices.y = (float)(y * _itemHeight + _itemHeight); quad->tr.vertices.z = 0.0f; Color4B color(_displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity); quad->tr.colors = color; quad->tl.colors = color; quad->br.colors = color; quad->bl.colors = color; _textureAtlas->setDirty(true); ssize_t totalQuads = _textureAtlas->getTotalQuads(); if (index + 1 > totalQuads) { _textureAtlas->increaseTotalQuadsWith(index + 1 - totalQuads); } } void TileMapAtlas::updateAtlasValues() { CCASSERT( _TGAInfo != nullptr, "tgaInfo must be non-nil"); int total = 0; for(int x=0;x < _TGAInfo->width; x++ ) { for( int y=0; y < _TGAInfo->height; y++ ) { if( total < _itemsToRender ) { Color3B *ptr = (Color3B*) _TGAInfo->imageData; Color3B value = ptr[x + y * _TGAInfo->width]; if( value.r != 0 ) { this->updateAtlasValueAt(Point(x,y), value, total); std::string key = StringUtils::toString(x) + "," + StringUtils::toString(y); _posToAtlasIndex[key] = total; total++; } } } } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTileMapAtlas.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTILE_MAP_ATLAS__ #define __CCTILE_MAP_ATLAS__ #include "CCAtlasNode.h" #include "CCValue.h" NS_CC_BEGIN struct sImageTGA; /** * @addtogroup tilemap_parallax_nodes * @{ */ /** @brief TileMapAtlas is a subclass of AtlasNode. It knows how to render a map based of tiles. The tiles must be in a .PNG format while the map must be a .TGA file. For more information regarding the format, please see this post: http://www.cocos2d-iphone.org/archives/27 All features from AtlasNode are valid in TileMapAtlas IMPORTANT: This class is deprecated. It is maintained for compatibility reasons only. You SHOULD not use this class. Instead, use the newer TMX file format: TMXTiledMap */ class CC_DLL TileMapAtlas : public AtlasNode { public: /** creates a TileMap with a tile file (atlas) with a map file and the width and height of each tile in points. The tile file will be loaded using the TextureMgr. */ static TileMapAtlas * create(const std::string& tile, const std::string& mapFile, int tileWidth, int tileHeight); /** * @js ctor */ TileMapAtlas(); /** * @js NA * @lua NA */ virtual ~TileMapAtlas(); /** initializes a TileMap with a tile file (atlas) with a map file and the width and height of each tile in points. The file will be loaded using the TextureMgr. */ bool initWithTileFile(const std::string& tile, const std::string& mapFile, int tileWidth, int tileHeight); /** returns a tile from position x,y. For the moment only channel R is used */ Color3B getTileAt(const Point& position) const; CC_DEPRECATED_ATTRIBUTE Color3B tileAt(const Point& position) const { return getTileAt(position); }; /** sets a tile at position x,y. For the moment only channel R is used */ void setTile(const Color3B& tile, const Point& position); /** dealloc the map from memory */ void releaseMap(); inline struct sImageTGA* getTGAInfo() const { return _TGAInfo; }; inline void setTGAInfo(struct sImageTGA* TGAInfo) { _TGAInfo = TGAInfo; }; protected: void loadTGAfile(const std::string& file); void calculateItemsToRender(); void updateAtlasValueAt(const Point& pos, const Color3B& value, int index); void updateAtlasValues(); //! x,y to atlas dictionary ValueMap _posToAtlasIndex; //! numbers of tiles to render int _itemsToRender; /** TileMap info */ struct sImageTGA* _TGAInfo; }; // end of tilemap_parallax_nodes group /// @} NS_CC_END #endif //__CCTILE_MAP_ATLAS__ ================================================ FILE: cocos2d/cocos/2d/CCTouch.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTouch.h" #include "CCDirector.h" NS_CC_BEGIN // returns the current touch location in screen coordinates Point Touch::getLocationInView() const { return _point; } // returns the previous touch location in screen coordinates Point Touch::getPreviousLocationInView() const { return _prevPoint; } // returns the start touch location in screen coordinates Point Touch::getStartLocationInView() const { return _startPoint; } // returns the current touch location in OpenGL coordinates Point Touch::getLocation() const { return Director::getInstance()->convertToGL(_point); } // returns the previous touch location in OpenGL coordinates Point Touch::getPreviousLocation() const { return Director::getInstance()->convertToGL(_prevPoint); } // returns the start touch location in OpenGL coordinates Point Touch::getStartLocation() const { return Director::getInstance()->convertToGL(_startPoint); } // returns the delta position between the current location and the previous location in OpenGL coordinates Point Touch::getDelta() const { return getLocation() - getPreviousLocation(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTouch.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_TOUCH_H__ #define __CC_TOUCH_H__ #include "CCObject.h" #include "CCGeometry.h" NS_CC_BEGIN /** * @addtogroup input * @{ */ class CC_DLL Touch : public Object { public: /** how the touches are dispathced */ enum class DispatchMode { /** All at once */ ALL_AT_ONCE, /** one by one */ ONE_BY_ONE, }; Touch() : _id(0), _startPointCaptured(false) {} /** returns the current touch location in OpenGL coordinates */ Point getLocation() const; /** returns the previous touch location in OpenGL coordinates */ Point getPreviousLocation() const; /** returns the start touch location in OpenGL coordinates */ Point getStartLocation() const; /** returns the delta of 2 current touches locations in screen coordinates */ Point getDelta() const; /** returns the current touch location in screen coordinates */ Point getLocationInView() const; /** returns the previous touch location in screen coordinates */ Point getPreviousLocationInView() const; /** returns the start touch location in screen coordinates */ Point getStartLocationInView() const; void setTouchInfo(int id, float x, float y) { _id = id; _prevPoint = _point; _point.x = x; _point.y = y; if (!_startPointCaptured) { _startPoint = _point; _startPointCaptured = true; } } /** * @js getId * @lua getId */ int getID() const { return _id; } private: int _id; bool _startPointCaptured; Point _startPoint; Point _point; Point _prevPoint; }; // end of input group /// @} NS_CC_END #endif // __PLATFORM_TOUCH_H__ ================================================ FILE: cocos2d/cocos/2d/CCTransition.cpp ================================================ /**************************************************************************** Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTransition.h" #include "CCDirector.h" #include "CCActionInterval.h" #include "CCActionInstant.h" #include "CCActionEase.h" #include "CCActionCamera.h" #include "CCActionTiledGrid.h" #include "CCActionGrid.h" #include "CCLayer.h" #include "CCRenderTexture.h" #include "CCNodeGrid.h" NS_CC_BEGIN const unsigned int kSceneFade = 0xFADEFADE; TransitionScene::TransitionScene() { } TransitionScene::~TransitionScene() { _inScene->release(); _outScene->release(); } TransitionScene * TransitionScene::create(float t, Scene *scene) { TransitionScene * pScene = new TransitionScene(); if(pScene && pScene->initWithDuration(t,scene)) { pScene->autorelease(); return pScene; } CC_SAFE_DELETE(pScene); return nullptr; } bool TransitionScene::initWithDuration(float t, Scene *scene) { CCASSERT( scene != nullptr, "Argument scene must be non-nil"); if (Scene::init()) { _duration = t; // retain _inScene = scene; _inScene->retain(); _outScene = Director::getInstance()->getRunningScene(); if (_outScene == nullptr) { _outScene = Scene::create(); } _outScene->retain(); CCASSERT( _inScene != _outScene, "Incoming scene must be different from the outgoing scene" ); sceneOrder(); return true; } else { return false; } } void TransitionScene::sceneOrder() { _isInSceneOnTop = true; } void TransitionScene::draw() { Scene::draw(); if( _isInSceneOnTop ) { _outScene->visit(); _inScene->visit(); } else { _inScene->visit(); _outScene->visit(); } } void TransitionScene::finish() { kmMat4 identity; kmMat4Identity(&identity); // clean up _inScene->setVisible(true); _inScene->setPosition(Point(0,0)); _inScene->setScale(1.0f); _inScene->setRotation(0.0f); _inScene->setAdditionalTransform(identity); _outScene->setVisible(false); _outScene->setPosition(Point(0,0)); _outScene->setScale(1.0f); _outScene->setRotation(0.0f); _outScene->setAdditionalTransform(identity); //[self schedule:@selector(setNewScene:) interval:0]; this->schedule(schedule_selector(TransitionScene::setNewScene), 0); } void TransitionScene::setNewScene(float dt) { CC_UNUSED_PARAM(dt); this->unschedule(schedule_selector(TransitionScene::setNewScene)); // Before replacing, save the "send cleanup to scene" Director *director = Director::getInstance(); _isSendCleanupToScene = director->isSendCleanupToScene(); director->replaceScene(_inScene); // issue #267 _outScene->setVisible(true); } void TransitionScene::hideOutShowIn() { _inScene->setVisible(true); _outScene->setVisible(false); } // custom onEnter void TransitionScene::onEnter() { Scene::onEnter(); // disable events while transitions _eventDispatcher->setEnabled(false); // outScene should not receive the onEnter callback // only the onExitTransitionDidStart _outScene->onExitTransitionDidStart(); _inScene->onEnter(); } // custom onExit void TransitionScene::onExit() { Scene::onExit(); // enable events while transitions _eventDispatcher->setEnabled(true); _outScene->onExit(); // _inScene should not receive the onEnter callback // only the onEnterTransitionDidFinish _inScene->onEnterTransitionDidFinish(); } // custom cleanup void TransitionScene::cleanup() { Scene::cleanup(); if( _isSendCleanupToScene ) _outScene->cleanup(); } // // Oriented Transition // TransitionSceneOriented::TransitionSceneOriented() { } TransitionSceneOriented::~TransitionSceneOriented() { } TransitionSceneOriented * TransitionSceneOriented::create(float t, Scene *scene, Orientation orientation) { TransitionSceneOriented * newScene = new TransitionSceneOriented(); newScene->initWithDuration(t,scene,orientation); newScene->autorelease(); return newScene; } bool TransitionSceneOriented::initWithDuration(float t, Scene *scene, Orientation orientation) { if ( TransitionScene::initWithDuration(t, scene) ) { _orientation = orientation; } return true; } // // RotoZoom // TransitionRotoZoom::TransitionRotoZoom() { } TransitionRotoZoom* TransitionRotoZoom::create(float t, Scene* scene) { TransitionRotoZoom* newScene = new TransitionRotoZoom(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } TransitionRotoZoom::~TransitionRotoZoom() { } void TransitionRotoZoom:: onEnter() { TransitionScene::onEnter(); _inScene->setScale(0.001f); _outScene->setScale(1.0f); _inScene->setAnchorPoint(Point(0.5f, 0.5f)); _outScene->setAnchorPoint(Point(0.5f, 0.5f)); ActionInterval *rotozoom = (ActionInterval*)(Sequence::create ( Spawn::create ( ScaleBy::create(_duration/2, 0.001f), RotateBy::create(_duration/2, 360 * 2), nullptr ), DelayTime::create(_duration/2), nullptr )); _outScene->runAction(rotozoom); _inScene->runAction ( Sequence::create ( rotozoom->reverse(), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ) ); } // // JumpZoom // TransitionJumpZoom::TransitionJumpZoom() { } TransitionJumpZoom::~TransitionJumpZoom() { } TransitionJumpZoom* TransitionJumpZoom::create(float t, Scene* scene) { TransitionJumpZoom* newScene = new TransitionJumpZoom(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionJumpZoom::onEnter() { TransitionScene::onEnter(); Size s = Director::getInstance()->getWinSize(); _inScene->setScale(0.5f); _inScene->setPosition(Point(s.width, 0)); _inScene->setAnchorPoint(Point(0.5f, 0.5f)); _outScene->setAnchorPoint(Point(0.5f, 0.5f)); ActionInterval *jump = JumpBy::create(_duration/4, Point(-s.width,0), s.width/4, 2); ActionInterval *scaleIn = ScaleTo::create(_duration/4, 1.0f); ActionInterval *scaleOut = ScaleTo::create(_duration/4, 0.5f); ActionInterval *jumpZoomOut = (ActionInterval*)(Sequence::create(scaleOut, jump, nullptr)); ActionInterval *jumpZoomIn = (ActionInterval*)(Sequence::create(jump, scaleIn, nullptr)); ActionInterval *delay = DelayTime::create(_duration/2); _outScene->runAction(jumpZoomOut); _inScene->runAction ( Sequence::create ( delay, jumpZoomIn, CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ) ); } // // MoveInL // TransitionMoveInL::TransitionMoveInL() { } TransitionMoveInL::~TransitionMoveInL() { } TransitionMoveInL* TransitionMoveInL::create(float t, Scene* scene) { TransitionMoveInL* newScene = new TransitionMoveInL(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionMoveInL::onEnter() { TransitionScene::onEnter(); this->initScenes(); ActionInterval *a = this->action(); _inScene->runAction ( Sequence::create ( this->easeActionWithAction(a), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ) ); } ActionInterval* TransitionMoveInL::action() { return MoveTo::create(_duration, Point(0,0)); } ActionInterval* TransitionMoveInL::easeActionWithAction(ActionInterval* action) { return EaseOut::create(action, 2.0f); // return [EaseElasticOut actionWithAction:action period:0.4f]; } void TransitionMoveInL::initScenes() { Size s = Director::getInstance()->getWinSize(); _inScene->setPosition(Point(-s.width,0)); } // // MoveInR // TransitionMoveInR::TransitionMoveInR() { } TransitionMoveInR::~TransitionMoveInR() { } TransitionMoveInR* TransitionMoveInR::create(float t, Scene* scene) { TransitionMoveInR* newScene = new TransitionMoveInR(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionMoveInR::initScenes() { Size s = Director::getInstance()->getWinSize(); _inScene->setPosition( Point(s.width,0) ); } // // MoveInT // TransitionMoveInT::TransitionMoveInT() { } TransitionMoveInT::~TransitionMoveInT() { } TransitionMoveInT* TransitionMoveInT::create(float t, Scene* scene) { TransitionMoveInT* newScene = new TransitionMoveInT(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionMoveInT::initScenes() { Size s = Director::getInstance()->getWinSize(); _inScene->setPosition( Point(0,s.height) ); } // // MoveInB // TransitionMoveInB::TransitionMoveInB() { } TransitionMoveInB::~TransitionMoveInB() { } TransitionMoveInB* TransitionMoveInB::create(float t, Scene* scene) { TransitionMoveInB* newScene = new TransitionMoveInB(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionMoveInB::initScenes() { Size s = Director::getInstance()->getWinSize(); _inScene->setPosition( Point(0,-s.height) ); } // // SlideInL // // The adjust factor is needed to prevent issue #442 // One solution is to use DONT_RENDER_IN_SUBPIXELS images, but NO // The other issue is that in some transitions (and I don't know why) // the order should be reversed (In in top of Out or vice-versa). #define ADJUST_FACTOR 0.5f TransitionSlideInL::TransitionSlideInL() { } TransitionSlideInL::~TransitionSlideInL() { } void TransitionSlideInL::onEnter() { TransitionScene::onEnter(); this->initScenes(); ActionInterval *in = this->action(); ActionInterval *out = this->action(); ActionInterval* inAction = easeActionWithAction(in); ActionInterval* outAction = (ActionInterval*)Sequence::create ( easeActionWithAction(out), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); _inScene->runAction(inAction); _outScene->runAction(outAction); } void TransitionSlideInL::sceneOrder() { _isInSceneOnTop = false; } void TransitionSlideInL:: initScenes() { Size s = Director::getInstance()->getWinSize(); _inScene->setPosition( Point(-(s.width-ADJUST_FACTOR),0) ); } ActionInterval* TransitionSlideInL::action() { Size s = Director::getInstance()->getWinSize(); return MoveBy::create(_duration, Point(s.width-ADJUST_FACTOR,0)); } ActionInterval* TransitionSlideInL::easeActionWithAction(ActionInterval* action) { return EaseOut::create(action, 2.0f); } TransitionSlideInL* TransitionSlideInL::create(float t, Scene* scene) { TransitionSlideInL* newScene = new TransitionSlideInL(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } // // SlideInR // TransitionSlideInR::TransitionSlideInR() { } TransitionSlideInR::~TransitionSlideInR() { } TransitionSlideInR* TransitionSlideInR::create(float t, Scene* scene) { TransitionSlideInR* newScene = new TransitionSlideInR(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionSlideInR::sceneOrder() { _isInSceneOnTop = true; } void TransitionSlideInR::initScenes() { Size s = Director::getInstance()->getWinSize(); _inScene->setPosition( Point(s.width-ADJUST_FACTOR,0) ); } ActionInterval* TransitionSlideInR:: action() { Size s = Director::getInstance()->getWinSize(); return MoveBy::create(_duration, Point(-(s.width-ADJUST_FACTOR),0)); } // // SlideInT // TransitionSlideInT::TransitionSlideInT() { } TransitionSlideInT::~TransitionSlideInT() { } TransitionSlideInT* TransitionSlideInT::create(float t, Scene* scene) { TransitionSlideInT* newScene = new TransitionSlideInT(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionSlideInT::sceneOrder() { _isInSceneOnTop = false; } void TransitionSlideInT::initScenes() { Size s = Director::getInstance()->getWinSize(); _inScene->setPosition( Point(0,s.height-ADJUST_FACTOR) ); } ActionInterval* TransitionSlideInT::action() { Size s = Director::getInstance()->getWinSize(); return MoveBy::create(_duration, Point(0,-(s.height-ADJUST_FACTOR))); } // // SlideInB // TransitionSlideInB::TransitionSlideInB() { } TransitionSlideInB::~TransitionSlideInB() { } TransitionSlideInB* TransitionSlideInB::create(float t, Scene* scene) { TransitionSlideInB* newScene = new TransitionSlideInB(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionSlideInB::sceneOrder() { _isInSceneOnTop = true; } void TransitionSlideInB:: initScenes() { Size s = Director::getInstance()->getWinSize(); _inScene->setPosition( Point(0,-(s.height-ADJUST_FACTOR)) ); } ActionInterval* TransitionSlideInB:: action() { Size s = Director::getInstance()->getWinSize(); return MoveBy::create(_duration, Point(0,s.height-ADJUST_FACTOR)); } // // ShrinkGrow Transition // TransitionShrinkGrow::TransitionShrinkGrow() { } TransitionShrinkGrow::~TransitionShrinkGrow() { } TransitionShrinkGrow* TransitionShrinkGrow::create(float t, Scene* scene) { TransitionShrinkGrow* newScene = new TransitionShrinkGrow(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionShrinkGrow::onEnter() { TransitionScene::onEnter(); _inScene->setScale(0.001f); _outScene->setScale(1.0f); _inScene->setAnchorPoint(Point(2/3.0f,0.5f)); _outScene->setAnchorPoint(Point(1/3.0f,0.5f)); ActionInterval* scaleOut = ScaleTo::create(_duration, 0.01f); ActionInterval* scaleIn = ScaleTo::create(_duration, 1.0f); _inScene->runAction(this->easeActionWithAction(scaleIn)); _outScene->runAction ( Sequence::create ( this->easeActionWithAction(scaleOut), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ) ); } ActionInterval* TransitionShrinkGrow:: easeActionWithAction(ActionInterval* action) { return EaseOut::create(action, 2.0f); // return [EaseElasticOut actionWithAction:action period:0.3f]; } // // FlipX Transition // TransitionFlipX::TransitionFlipX() { } TransitionFlipX::~TransitionFlipX() { } void TransitionFlipX::onEnter() { TransitionSceneOriented::onEnter(); ActionInterval *inA, *outA; _inScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; if( _orientation == TransitionScene::Orientation::RIGHT_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; outAngleZ = 0; } else { inDeltaZ = -90; inAngleZ = 90; outDeltaZ = -90; outAngleZ = 0; } inA = (ActionInterval*)Sequence::create ( DelayTime::create(_duration/2), Show::create(), OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); outA = (ActionInterval *)Sequence::create ( OrbitCamera::create(_duration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0), Hide::create(), DelayTime::create(_duration/2), nullptr ); _inScene->runAction(inA); _outScene->runAction(outA); } TransitionFlipX* TransitionFlipX::create(float t, Scene* s, Orientation o) { TransitionFlipX* newScene = new TransitionFlipX(); newScene->initWithDuration(t, s, o); newScene->autorelease(); return newScene; } TransitionFlipX* TransitionFlipX::create(float t, Scene* s) { return TransitionFlipX::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } // // FlipY Transition // TransitionFlipY::TransitionFlipY() { } TransitionFlipY::~TransitionFlipY() { } void TransitionFlipY::onEnter() { TransitionSceneOriented::onEnter(); ActionInterval *inA, *outA; _inScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; if( _orientation == TransitionScene::Orientation::UP_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; outAngleZ = 0; } else { inDeltaZ = -90; inAngleZ = 90; outDeltaZ = -90; outAngleZ = 0; } inA = (ActionInterval*)Sequence::create ( DelayTime::create(_duration/2), Show::create(), OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); outA = (ActionInterval*)Sequence::create ( OrbitCamera::create(_duration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0), Hide::create(), DelayTime::create(_duration/2), nullptr ); _inScene->runAction(inA); _outScene->runAction(outA); } TransitionFlipY* TransitionFlipY::create(float t, Scene* s, Orientation o) { TransitionFlipY* newScene = new TransitionFlipY(); newScene->initWithDuration(t, s, o); newScene->autorelease(); return newScene; } TransitionFlipY* TransitionFlipY::create(float t, Scene* s) { return TransitionFlipY::create(t, s, TransitionScene::Orientation::UP_OVER); } // // FlipAngular Transition // TransitionFlipAngular::TransitionFlipAngular() { } TransitionFlipAngular::~TransitionFlipAngular() { } void TransitionFlipAngular::onEnter() { TransitionSceneOriented::onEnter(); ActionInterval *inA, *outA; _inScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; if( _orientation == TransitionScene::Orientation::RIGHT_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; outAngleZ = 0; } else { inDeltaZ = -90; inAngleZ = 90; outDeltaZ = -90; outAngleZ = 0; } inA = (ActionInterval *)Sequence::create ( DelayTime::create(_duration/2), Show::create(), OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); outA = (ActionInterval *)Sequence::create ( OrbitCamera::create(_duration/2, 1, 0, outAngleZ, outDeltaZ, 45, 0), Hide::create(), DelayTime::create(_duration/2), nullptr ); _inScene->runAction(inA); _outScene->runAction(outA); } TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s, Orientation o) { TransitionFlipAngular* newScene = new TransitionFlipAngular(); newScene->initWithDuration(t, s, o); newScene->autorelease(); return newScene; } TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s) { return TransitionFlipAngular::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } // // ZoomFlipX Transition // TransitionZoomFlipX::TransitionZoomFlipX() { } TransitionZoomFlipX::~TransitionZoomFlipX() { } void TransitionZoomFlipX::onEnter() { TransitionSceneOriented::onEnter(); ActionInterval *inA, *outA; _inScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; if( _orientation == TransitionScene::Orientation::RIGHT_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; outAngleZ = 0; } else { inDeltaZ = -90; inAngleZ = 90; outDeltaZ = -90; outAngleZ = 0; } inA = (ActionInterval *)Sequence::create ( DelayTime::create(_duration/2), Spawn::create ( OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0), ScaleTo::create(_duration/2, 1), Show::create(), nullptr ), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); outA = (ActionInterval *)Sequence::create ( Spawn::create ( OrbitCamera::create(_duration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0), ScaleTo::create(_duration/2, 0.5f), nullptr ), Hide::create(), DelayTime::create(_duration/2), nullptr ); _inScene->setScale(0.5f); _inScene->runAction(inA); _outScene->runAction(outA); } TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s, Orientation o) { TransitionZoomFlipX* newScene = new TransitionZoomFlipX(); newScene->initWithDuration(t, s, o); newScene->autorelease(); return newScene; } TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s) { return TransitionZoomFlipX::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } // // ZoomFlipY Transition // TransitionZoomFlipY::TransitionZoomFlipY() { } TransitionZoomFlipY::~TransitionZoomFlipY() { } void TransitionZoomFlipY::onEnter() { TransitionSceneOriented::onEnter(); ActionInterval *inA, *outA; _inScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; if( _orientation== TransitionScene::Orientation::UP_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; outAngleZ = 0; } else { inDeltaZ = -90; inAngleZ = 90; outDeltaZ = -90; outAngleZ = 0; } inA = (ActionInterval *)Sequence::create ( DelayTime::create(_duration/2), Spawn::create ( OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0), ScaleTo::create(_duration/2, 1), Show::create(), nullptr ), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); outA = (ActionInterval *)Sequence::create ( Spawn::create ( OrbitCamera::create(_duration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0), ScaleTo::create(_duration/2, 0.5f), nullptr ), Hide::create(), DelayTime::create(_duration/2), nullptr ); _inScene->setScale(0.5f); _inScene->runAction(inA); _outScene->runAction(outA); } TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s, Orientation o) { TransitionZoomFlipY* newScene = new TransitionZoomFlipY(); newScene->initWithDuration(t, s, o); newScene->autorelease(); return newScene; } TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s) { return TransitionZoomFlipY::create(t, s, TransitionScene::Orientation::UP_OVER); } // // ZoomFlipAngular Transition // TransitionZoomFlipAngular::TransitionZoomFlipAngular() { } TransitionZoomFlipAngular::~TransitionZoomFlipAngular() { } void TransitionZoomFlipAngular::onEnter() { TransitionSceneOriented::onEnter(); ActionInterval *inA, *outA; _inScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; if( _orientation == TransitionScene::Orientation::RIGHT_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; outAngleZ = 0; } else { inDeltaZ = -90; inAngleZ = 90; outDeltaZ = -90; outAngleZ = 0; } inA = (ActionInterval *)Sequence::create ( DelayTime::create(_duration/2), Spawn::create ( OrbitCamera::create(_duration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0), ScaleTo::create(_duration/2, 1), Show::create(), nullptr ), Show::create(), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); outA = (ActionInterval *)Sequence::create ( Spawn::create ( OrbitCamera::create(_duration/2, 1, 0 , outAngleZ, outDeltaZ, 45, 0), ScaleTo::create(_duration/2, 0.5f), nullptr ), Hide::create(), DelayTime::create(_duration/2), nullptr ); _inScene->setScale(0.5f); _inScene->runAction(inA); _outScene->runAction(outA); } TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s, Orientation o) { TransitionZoomFlipAngular* newScene = new TransitionZoomFlipAngular(); newScene->initWithDuration(t, s, o); newScene->autorelease(); return newScene; } TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s) { return TransitionZoomFlipAngular::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } // // Fade Transition // TransitionFade::TransitionFade() { } TransitionFade::~TransitionFade() { } TransitionFade * TransitionFade::create(float duration, Scene *scene, const Color3B& color) { TransitionFade * transition = new TransitionFade(); transition->initWithDuration(duration, scene, color); transition->autorelease(); return transition; } TransitionFade* TransitionFade::create(float duration,Scene* scene) { return TransitionFade::create(duration, scene, Color3B::BLACK); } bool TransitionFade::initWithDuration(float duration, Scene *scene, const Color3B& color) { if (TransitionScene::initWithDuration(duration, scene)) { _color.r = color.r; _color.g = color.g; _color.b = color.b; _color.a = 0; } return true; } bool TransitionFade::initWithDuration(float t, Scene *scene) { this->initWithDuration(t, scene, Color3B::BLACK); return true; } void TransitionFade :: onEnter() { TransitionScene::onEnter(); LayerColor* l = LayerColor::create(_color); _inScene->setVisible(false); addChild(l, 2, kSceneFade); Node* f = getChildByTag(kSceneFade); ActionInterval* a = (ActionInterval *)Sequence::create ( FadeIn::create(_duration/2), CallFunc::create(CC_CALLBACK_0(TransitionScene::hideOutShowIn,this)), FadeOut::create(_duration/2), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); f->runAction(a); } void TransitionFade::onExit() { TransitionScene::onExit(); this->removeChildByTag(kSceneFade, false); } // // Cross Fade Transition // TransitionCrossFade::TransitionCrossFade() { } TransitionCrossFade::~TransitionCrossFade() { } TransitionCrossFade* TransitionCrossFade::create(float t, Scene* scene) { TransitionCrossFade* newScene = new TransitionCrossFade(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionCrossFade::draw() { // override draw since both scenes (textures) are rendered in 1 scene } void TransitionCrossFade::onEnter() { TransitionScene::onEnter(); // create a transparent color layer // in which we are going to add our rendertextures Color4B color(0,0,0,0); Size size = Director::getInstance()->getWinSize(); LayerColor* layer = LayerColor::create(color); // create the first render texture for inScene RenderTexture* inTexture = RenderTexture::create((int)size.width, (int)size.height); if (nullptr == inTexture) { return; } inTexture->getSprite()->setAnchorPoint( Point(0.5f,0.5f) ); inTexture->setPosition( Point(size.width/2, size.height/2) ); inTexture->setAnchorPoint( Point(0.5f,0.5f) ); // render inScene to its texturebuffer inTexture->begin(); _inScene->visit(); inTexture->end(); // create the second render texture for outScene RenderTexture* outTexture = RenderTexture::create((int)size.width, (int)size.height); outTexture->getSprite()->setAnchorPoint( Point(0.5f,0.5f) ); outTexture->setPosition( Point(size.width/2, size.height/2) ); outTexture->setAnchorPoint( Point(0.5f,0.5f) ); // render outScene to its texturebuffer outTexture->begin(); _outScene->visit(); outTexture->end(); // create blend functions BlendFunc blend1 = {GL_ONE, GL_ONE}; // inScene will lay on background and will not be used with alpha BlendFunc blend2 = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; // we are going to blend outScene via alpha // set blendfunctions inTexture->getSprite()->setBlendFunc(blend1); outTexture->getSprite()->setBlendFunc(blend2); // add render textures to the layer layer->addChild(inTexture); layer->addChild(outTexture); // initial opacity: inTexture->getSprite()->setOpacity(255); outTexture->getSprite()->setOpacity(255); // create the blend action Action* layerAction = Sequence::create ( FadeTo::create(_duration, 0), CallFunc::create(CC_CALLBACK_0(TransitionScene::hideOutShowIn,this)), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr ); // run the blend action outTexture->getSprite()->runAction( layerAction ); // add the layer (which contains our two rendertextures) to the scene addChild(layer, 2, kSceneFade); } // clean up on exit void TransitionCrossFade::onExit() { // remove our layer and release all containing objects this->removeChildByTag(kSceneFade, false); TransitionScene::onExit(); } // // TurnOffTilesTransition // TransitionTurnOffTiles::TransitionTurnOffTiles() { _outSceneProxy = NodeGrid::create(); _outSceneProxy->retain(); } TransitionTurnOffTiles::~TransitionTurnOffTiles() { CC_SAFE_RELEASE(_outSceneProxy); } TransitionTurnOffTiles* TransitionTurnOffTiles::create(float t, Scene* scene) { TransitionTurnOffTiles* newScene = new TransitionTurnOffTiles(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } // override addScenes, and change the order void TransitionTurnOffTiles::sceneOrder() { _isInSceneOnTop = false; } void TransitionTurnOffTiles::onEnter() { TransitionScene::onEnter(); _outSceneProxy->setTarget(_outScene); _outSceneProxy->onEnter(); Size s = Director::getInstance()->getWinSize(); float aspect = s.width / s.height; int x = (int)(12 * aspect); int y = 12; TurnOffTiles* toff = TurnOffTiles::create(_duration, Size(x,y)); ActionInterval* action = easeActionWithAction(toff); _outSceneProxy->runAction ( Sequence::create ( action, CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), StopGrid::create(), nullptr ) ); } void TransitionTurnOffTiles::onExit() { _outSceneProxy->setTarget(nullptr); _outSceneProxy->onExit(); TransitionScene::onExit(); } void TransitionTurnOffTiles::draw() { Scene::draw(); if( _isInSceneOnTop ) { _outSceneProxy->visit(); _inScene->visit(); } else { _inScene->visit(); _outSceneProxy->visit(); } } ActionInterval* TransitionTurnOffTiles:: easeActionWithAction(ActionInterval* action) { return action; } // // SplitCols Transition // TransitionSplitCols::TransitionSplitCols() { _gridProxy = NodeGrid::create(); _gridProxy->retain(); } TransitionSplitCols::~TransitionSplitCols() { CC_SAFE_RELEASE(_gridProxy); } TransitionSplitCols* TransitionSplitCols::create(float t, Scene* scene) { TransitionSplitCols* newScene = new TransitionSplitCols(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionSplitCols::onEnter() { TransitionScene::onEnter(); _gridProxy->setTarget(_outScene); _gridProxy->onEnter(); ActionInterval* split = action(); ActionInterval* seq = (ActionInterval*)Sequence::create ( split, CallFunc::create(CC_CALLBACK_0(TransitionSplitCols::switchTargetToInscene,this)), split->reverse(), nullptr ); _gridProxy->runAction ( Sequence::create ( easeActionWithAction(seq), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), StopGrid::create(), nullptr ) ); } void TransitionSplitCols::switchTargetToInscene() { _gridProxy->setTarget(_inScene); } void TransitionSplitCols::draw() { Scene::draw(); _gridProxy->visit(); } void TransitionSplitCols::onExit() { _gridProxy->setTarget(nullptr); _gridProxy->onExit(); TransitionScene::onExit(); } ActionInterval* TransitionSplitCols:: action() { return SplitCols::create(_duration/2.0f, 3); } ActionInterval* TransitionSplitCols::easeActionWithAction(ActionInterval * action) { return EaseInOut::create(action, 3.0f); } // // SplitRows Transition // TransitionSplitRows::TransitionSplitRows() { } TransitionSplitRows::~TransitionSplitRows() { } ActionInterval* TransitionSplitRows::action() { return SplitRows::create(_duration/2.0f, 3); } TransitionSplitRows* TransitionSplitRows::create(float t, Scene* scene) { TransitionSplitRows* newScene = new TransitionSplitRows(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } // // FadeTR Transition // TransitionFadeTR::TransitionFadeTR() { _outSceneProxy = NodeGrid::create(); _outSceneProxy->retain(); } TransitionFadeTR::~TransitionFadeTR() { CC_SAFE_RELEASE(_outSceneProxy); } TransitionFadeTR* TransitionFadeTR::create(float t, Scene* scene) { TransitionFadeTR* newScene = new TransitionFadeTR(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionFadeTR::sceneOrder() { _isInSceneOnTop = false; } void TransitionFadeTR::onEnter() { TransitionScene::onEnter(); _outSceneProxy->setTarget(_outScene); _outSceneProxy->onEnter(); Size s = Director::getInstance()->getWinSize(); float aspect = s.width / s.height; int x = (int)(12 * aspect); int y = 12; ActionInterval* action = actionWithSize(Size(x,y)); _outSceneProxy->runAction ( Sequence::create ( easeActionWithAction(action), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), StopGrid::create(), nullptr ) ); } void TransitionFadeTR::onExit() { _outSceneProxy->setTarget(nullptr); _outSceneProxy->onExit(); TransitionScene::onExit(); } void TransitionFadeTR::draw() { Scene::draw(); if( _isInSceneOnTop ) { _outSceneProxy->visit(); _inScene->visit(); } else { _inScene->visit(); _outSceneProxy->visit(); } } ActionInterval* TransitionFadeTR::actionWithSize(const Size& size) { return FadeOutTRTiles::create(_duration, size); } ActionInterval* TransitionFadeTR:: easeActionWithAction(ActionInterval* action) { return action; } // // FadeBL Transition // TransitionFadeBL::TransitionFadeBL() { } TransitionFadeBL::~TransitionFadeBL() { } TransitionFadeBL* TransitionFadeBL::create(float t, Scene* scene) { TransitionFadeBL* newScene = new TransitionFadeBL(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } ActionInterval* TransitionFadeBL::actionWithSize(const Size& size) { return FadeOutBLTiles::create(_duration, size); } // // FadeUp Transition // TransitionFadeUp::TransitionFadeUp() { } TransitionFadeUp::~TransitionFadeUp() { } TransitionFadeUp* TransitionFadeUp::create(float t, Scene* scene) { TransitionFadeUp* newScene = new TransitionFadeUp(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } ActionInterval* TransitionFadeUp::actionWithSize(const Size& size) { return FadeOutUpTiles::create(_duration, size); } // // FadeDown Transition // TransitionFadeDown::TransitionFadeDown() { } TransitionFadeDown::~TransitionFadeDown() { } TransitionFadeDown* TransitionFadeDown::create(float t, Scene* scene) { TransitionFadeDown* newScene = new TransitionFadeDown(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } ActionInterval* TransitionFadeDown::actionWithSize(const Size& size) { return FadeOutDownTiles::create(_duration, size); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTransition.h ================================================ /**************************************************************************** Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTRANSITION_H__ #define __CCTRANSITION_H__ #include "CCScene.h" #include "ccTypes.h" NS_CC_BEGIN /** * @addtogroup transition * @{ */ //static creation function macro //c/c++ don't support object creation of using class name //so, all classes need creation method. class ActionInterval; class Node; class NodeGrid; /** @brief TransitionEaseScene can ease the actions of the scene protocol. @since v0.8.2 */ class CC_DLL TransitionEaseScene// : public Object { public: virtual ~TransitionEaseScene() {} /** returns the Ease action that will be performed on a linear action. @since v0.8.2 */ virtual ActionInterval * easeActionWithAction(ActionInterval * action) = 0; }; /** @brief Base class for Transition scenes */ class CC_DLL TransitionScene : public Scene { public: /** Orientation Type used by some transitions */ enum class Orientation { /// An horizontal orientation where the Left is nearer LEFT_OVER = 0, /// An horizontal orientation where the Right is nearer RIGHT_OVER = 1, /// A vertical orientation where the Up is nearer UP_OVER = 0, /// A vertical orientation where the Bottom is nearer DOWN_OVER = 1, }; /** creates a base transition with duration and incoming scene */ static TransitionScene * create(float t, Scene *scene); /** called after the transition finishes */ void finish(void); /** used by some transitions to hide the outer scene */ void hideOutShowIn(void); // // Overrides // virtual void draw() override; virtual void onEnter() override; virtual void onExit() override; virtual void cleanup() override; protected: TransitionScene(); virtual ~TransitionScene(); /** initializes a transition with duration and incoming scene */ bool initWithDuration(float t,Scene* scene); virtual void sceneOrder(); void setNewScene(float dt); Scene *_inScene; Scene *_outScene; float _duration; bool _isInSceneOnTop; bool _isSendCleanupToScene; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionScene); }; /** @brief A Transition that supports orientation like. * Possible orientation: LeftOver, RightOver, UpOver, DownOver */ class CC_DLL TransitionSceneOriented : public TransitionScene { public: /** creates a base transition with duration and incoming scene */ static TransitionSceneOriented * create(float t,Scene* scene, Orientation orientation); protected: TransitionSceneOriented(); virtual ~TransitionSceneOriented(); /** initializes a transition with duration and incoming scene */ bool initWithDuration(float t,Scene* scene,Orientation orientation); Orientation _orientation; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSceneOriented); }; /** @brief TransitionRotoZoom: Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming */ class CC_DLL TransitionRotoZoom : public TransitionScene { public: static TransitionRotoZoom* create(float t, Scene* scene); // // Overrides // virtual void onEnter() override; protected: TransitionRotoZoom(); virtual ~TransitionRotoZoom(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionRotoZoom); }; /** @brief TransitionJumpZoom: Zoom out and jump the outgoing scene, and then jump and zoom in the incoming */ class CC_DLL TransitionJumpZoom : public TransitionScene { public: static TransitionJumpZoom* create(float t, Scene* scene); // // Overrides // virtual void onEnter() override; protected: TransitionJumpZoom(); virtual ~TransitionJumpZoom(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionJumpZoom); }; /** @brief TransitionMoveInL: Move in from to the left the incoming scene. */ class CC_DLL TransitionMoveInL : public TransitionScene, public TransitionEaseScene { public: static TransitionMoveInL* create(float t, Scene* scene); /** returns the action that will be performed */ virtual ActionInterval* action(void); virtual ActionInterval* easeActionWithAction(ActionInterval * action); // // Overrides // virtual void onEnter() override; protected: TransitionMoveInL(); virtual ~TransitionMoveInL(); /** initializes the scenes */ virtual void initScenes(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionMoveInL); }; /** @brief TransitionMoveInR: Move in from to the right the incoming scene. */ class CC_DLL TransitionMoveInR : public TransitionMoveInL { public: static TransitionMoveInR* create(float t, Scene* scene); protected: TransitionMoveInR(); virtual ~TransitionMoveInR(); virtual void initScenes(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionMoveInR); }; /** @brief TransitionMoveInT: Move in from to the top the incoming scene. */ class CC_DLL TransitionMoveInT : public TransitionMoveInL { public: static TransitionMoveInT* create(float t, Scene* scene); protected: TransitionMoveInT(); virtual ~TransitionMoveInT(); virtual void initScenes(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionMoveInT); }; /** @brief TransitionMoveInB: Move in from to the bottom the incoming scene. */ class CC_DLL TransitionMoveInB : public TransitionMoveInL { public: static TransitionMoveInB* create(float t, Scene* scene); protected: TransitionMoveInB(); virtual ~TransitionMoveInB(); virtual void initScenes(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionMoveInB); }; /** @brief TransitionSlideInL: Slide in the incoming scene from the left border. */ class CC_DLL TransitionSlideInL : public TransitionScene, public TransitionEaseScene { public: static TransitionSlideInL* create(float t, Scene* scene); virtual ActionInterval* easeActionWithAction(ActionInterval * action); /** returns the action that will be performed by the incoming and outgoing scene */ virtual ActionInterval* action(void); // // Overrides // virtual void onEnter() override; protected: TransitionSlideInL(); virtual ~TransitionSlideInL(); /** initializes the scenes */ virtual void initScenes(void); virtual void sceneOrder() override; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSlideInL); }; /** @brief TransitionSlideInR: Slide in the incoming scene from the right border. */ class CC_DLL TransitionSlideInR : public TransitionSlideInL { public: static TransitionSlideInR* create(float t, Scene* scene); /** returns the action that will be performed by the incoming and outgoing scene */ virtual ActionInterval* action(void); protected: TransitionSlideInR(); virtual ~TransitionSlideInR(); /** initializes the scenes */ virtual void initScenes(void); virtual void sceneOrder() override; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSlideInR); }; /** @brief TransitionSlideInB: Slide in the incoming scene from the bottom border. */ class CC_DLL TransitionSlideInB : public TransitionSlideInL { public: static TransitionSlideInB* create(float t, Scene* scene); /** returns the action that will be performed by the incoming and outgoing scene */ virtual ActionInterval* action(void); protected: TransitionSlideInB(); virtual ~TransitionSlideInB(); /** initializes the scenes */ virtual void initScenes(); virtual void sceneOrder() override; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSlideInB); }; /** @brief TransitionSlideInT: Slide in the incoming scene from the top border. */ class CC_DLL TransitionSlideInT : public TransitionSlideInL { public: static TransitionSlideInT* create(float t, Scene* scene); /** returns the action that will be performed by the incoming and outgoing scene */ virtual ActionInterval* action(void); protected: TransitionSlideInT(); virtual ~TransitionSlideInT(); /** initializes the scenes */ virtual void initScenes(void); virtual void sceneOrder() override; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSlideInT); }; /** @brief Shrink the outgoing scene while grow the incoming scene */ class CC_DLL TransitionShrinkGrow : public TransitionScene , public TransitionEaseScene { public: static TransitionShrinkGrow* create(float t, Scene* scene); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; virtual ActionInterval* easeActionWithAction(ActionInterval * action) override; protected: TransitionShrinkGrow(); virtual ~TransitionShrinkGrow(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionShrinkGrow); }; /** @brief TransitionFlipX: Flips the screen horizontally. The front face is the outgoing scene and the back face is the incoming scene. */ class CC_DLL TransitionFlipX : public TransitionSceneOriented { public: static TransitionFlipX* create(float t, Scene* s, Orientation o); static TransitionFlipX* create(float t, Scene* s); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; protected: TransitionFlipX(); virtual ~TransitionFlipX(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFlipX); }; /** @brief TransitionFlipY: Flips the screen vertically. The front face is the outgoing scene and the back face is the incoming scene. */ class CC_DLL TransitionFlipY : public TransitionSceneOriented { public: static TransitionFlipY* create(float t, Scene* s, Orientation o); static TransitionFlipY* create(float t, Scene* s); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; protected: TransitionFlipY(); virtual ~TransitionFlipY(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFlipY); }; /** @brief TransitionFlipAngular: Flips the screen half horizontally and half vertically. The front face is the outgoing scene and the back face is the incoming scene. */ class CC_DLL TransitionFlipAngular : public TransitionSceneOriented { public: static TransitionFlipAngular* create(float t, Scene* s, Orientation o); static TransitionFlipAngular* create(float t, Scene* s); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; protected: TransitionFlipAngular(); virtual ~TransitionFlipAngular(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFlipAngular); }; /** @brief TransitionZoomFlipX: Flips the screen horizontally doing a zoom out/in The front face is the outgoing scene and the back face is the incoming scene. */ class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented { public: static TransitionZoomFlipX* create(float t, Scene* s, Orientation o); static TransitionZoomFlipX* create(float t, Scene* s); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; protected: TransitionZoomFlipX(); virtual ~TransitionZoomFlipX(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionZoomFlipX); }; /** @brief TransitionZoomFlipY: Flips the screen vertically doing a little zooming out/in The front face is the outgoing scene and the back face is the incoming scene. */ class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented { public: static TransitionZoomFlipY* create(float t, Scene* s, Orientation o); static TransitionZoomFlipY* create(float t, Scene* s); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; protected: TransitionZoomFlipY(); virtual ~TransitionZoomFlipY(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionZoomFlipY); }; /** @brief TransitionZoomFlipAngular: Flips the screen half horizontally and half vertically doing a little zooming out/in. The front face is the outgoing scene and the back face is the incoming scene. */ class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented { public: static TransitionZoomFlipAngular* create(float t, Scene* s, Orientation o); static TransitionZoomFlipAngular* create(float t, Scene* s); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; protected: TransitionZoomFlipAngular(); virtual ~TransitionZoomFlipAngular(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionZoomFlipAngular); }; /** @brief TransitionFade: Fade out the outgoing scene and then fade in the incoming scene.''' */ class CC_DLL TransitionFade : public TransitionScene { public: /** creates the transition with a duration and with an RGB color * Example: FadeTransition::create(2, scene, Color3B(255,0,0); // red color */ static TransitionFade* create(float duration, Scene* scene, const Color3B& color); static TransitionFade* create(float duration, Scene* scene); /** * @js NA * @lua NA */ virtual void onEnter(); /** * @js NA * @lua NA */ virtual void onExit(); protected: TransitionFade(); virtual ~TransitionFade(); /** initializes the transition with a duration and with an RGB color */ bool initWithDuration(float t, Scene*scene, const Color3B& color); bool initWithDuration(float t, Scene* scene); Color4B _color; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFade); }; class RenderTexture; /** @brief TransitionCrossFade: Cross fades two scenes using the RenderTexture object. */ class CC_DLL TransitionCrossFade : public TransitionScene { public : static TransitionCrossFade* create(float t, Scene* scene); // // Overrides // /** * @js NA * @lua NA */ virtual void draw() override; /** * @js NA * @lua NA */ virtual void onEnter() override; /** * @js NA * @lua NA */ virtual void onExit() override; protected: TransitionCrossFade(); virtual ~TransitionCrossFade(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionCrossFade); }; /** @brief TransitionTurnOffTiles: Turn off the tiles of the outgoing scene in random order */ class CC_DLL TransitionTurnOffTiles : public TransitionScene ,public TransitionEaseScene { public : static TransitionTurnOffTiles* create(float t, Scene* scene); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; virtual void onExit() override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; virtual void draw() override; protected: TransitionTurnOffTiles(); virtual ~TransitionTurnOffTiles(); virtual void sceneOrder() override; NodeGrid* _outSceneProxy; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionTurnOffTiles); }; /** @brief TransitionSplitCols: The odd columns goes upwards while the even columns goes downwards. */ class CC_DLL TransitionSplitCols : public TransitionScene , public TransitionEaseScene { public: static TransitionSplitCols* create(float t, Scene* scene); virtual ActionInterval* action(); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; virtual void onExit() override; virtual void draw() override; protected: TransitionSplitCols(); virtual ~TransitionSplitCols(); void switchTargetToInscene(); NodeGrid* _gridProxy; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSplitCols); }; /** @brief TransitionSplitRows: The odd rows goes to the left while the even rows goes to the right. */ class CC_DLL TransitionSplitRows : public TransitionSplitCols { public: static TransitionSplitRows* create(float t, Scene* scene); // // Overrides // virtual ActionInterval* action(void) override; protected: TransitionSplitRows(); virtual ~TransitionSplitRows(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSplitRows); }; /** @brief TransitionFadeTR: Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner. */ class CC_DLL TransitionFadeTR : public TransitionScene , public TransitionEaseScene { public: static TransitionFadeTR* create(float t, Scene* scene); virtual ActionInterval* actionWithSize(const Size& size); // // Overrides // /** * @js NA * @lua NA */ virtual void onEnter() override; virtual ActionInterval* easeActionWithAction(ActionInterval * action) override; virtual void onExit() override; virtual void draw() override; protected: TransitionFadeTR(); virtual ~TransitionFadeTR(); virtual void sceneOrder(); NodeGrid* _outSceneProxy; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeTR); }; /** @brief TransitionFadeBL: Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. */ class CC_DLL TransitionFadeBL : public TransitionFadeTR { public: static TransitionFadeBL* create(float t, Scene* scene); // // Overrides // virtual ActionInterval* actionWithSize(const Size& size) override; protected: TransitionFadeBL(); virtual ~TransitionFadeBL(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeBL); }; /** @brief TransitionFadeUp: * Fade the tiles of the outgoing scene from the bottom to the top. */ class CC_DLL TransitionFadeUp : public TransitionFadeTR { public: static TransitionFadeUp* create(float t, Scene* scene); // // Overrides // virtual ActionInterval* actionWithSize(const Size& size) override; protected: TransitionFadeUp(); virtual ~TransitionFadeUp(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeUp); }; /** @brief TransitionFadeDown: * Fade the tiles of the outgoing scene from the top to the bottom. */ class CC_DLL TransitionFadeDown : public TransitionFadeTR { public: static TransitionFadeDown* create(float t, Scene* scene); // // Overrides // virtual ActionInterval* actionWithSize(const Size& size) override; protected: TransitionFadeDown(); virtual ~TransitionFadeDown(); private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeDown); }; // end of transition group /// @} NS_CC_END #endif // __CCTRANSITION_H__ ================================================ FILE: cocos2d/cocos/2d/CCTransitionPageTurn.cpp ================================================ /**************************************************************************** Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTransitionPageTurn.h" #include "CCDirector.h" #include "CCActionInterval.h" #include "CCActionInstant.h" #include "CCActionGrid.h" #include "CCActionPageTurn3D.h" #include "CCNodeGrid.h" #include "renderer/CCRenderer.h" NS_CC_BEGIN float TransitionPageTurn::POLYGON_OFFSET_FACTOR = -20.f; float TransitionPageTurn::POLYGON_OFFSET_UNITS = -20.f; TransitionPageTurn::TransitionPageTurn() { _inSceneProxy = NodeGrid::create(); _outSceneProxy = NodeGrid::create(); _inSceneProxy->retain(); _outSceneProxy->retain(); } TransitionPageTurn::~TransitionPageTurn() { CC_SAFE_RELEASE(_inSceneProxy); CC_SAFE_RELEASE(_outSceneProxy); } /** creates a base transition with duration and incoming scene */ TransitionPageTurn * TransitionPageTurn::create(float t, Scene *scene, bool backwards) { TransitionPageTurn * transition = new TransitionPageTurn(); transition->initWithDuration(t,scene,backwards); transition->autorelease(); return transition; } /** initializes a transition with duration and incoming scene */ bool TransitionPageTurn::initWithDuration(float t, Scene *scene, bool backwards) { // XXX: needed before [super init] _back = backwards; if (TransitionScene::initWithDuration(t, scene)) { // do something } return true; } void TransitionPageTurn::sceneOrder() { _isInSceneOnTop = _back; } void TransitionPageTurn::onEnablePolygonOffset() { glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); } void TransitionPageTurn::onDisablePolygonOffset() { glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); } void TransitionPageTurn::draw() { Scene::draw(); if( _isInSceneOnTop ) { _outSceneProxy->visit(); _enableOffsetCmd.init(_globalZOrder); _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd); _inSceneProxy->visit(); _disableOffsetCmd.init(_globalZOrder); _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd); } else { _inSceneProxy->visit(); _enableOffsetCmd.init(_globalZOrder); _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd); _outSceneProxy->visit(); _disableOffsetCmd.init(_globalZOrder); _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd); } } void TransitionPageTurn::onEnter() { TransitionScene::onEnter(); _inSceneProxy->setTarget(_inScene); _outSceneProxy->setTarget(_outScene); _inSceneProxy->onEnter(); _outSceneProxy->onEnter(); Size s = Director::getInstance()->getWinSize(); int x,y; if (s.width > s.height) { x=16; y=12; } else { x=12; y=16; } ActionInterval *action = this->actionWithSize(Size(x,y)); if (! _back ) { _outSceneProxy->runAction ( Sequence::create ( action, CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), StopGrid::create(), nullptr ) ); } else { // to prevent initial flicker _inSceneProxy->setVisible(false); _inSceneProxy->runAction ( Sequence::create ( Show::create(), action, CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), StopGrid::create(), nullptr ) ); } } void TransitionPageTurn::onExit() { _outSceneProxy->setTarget(nullptr); _outSceneProxy->setTarget(nullptr); _outSceneProxy->onExit(); _inSceneProxy->onExit(); TransitionScene::onExit(); } ActionInterval* TransitionPageTurn:: actionWithSize(const Size& vector) { if (_back) { // Get hold of the PageTurn3DAction return ReverseTime::create ( PageTurn3D::create(_duration, vector) ); } else { // Get hold of the PageTurn3DAction return PageTurn3D::create(_duration, vector); } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTransitionPageTurn.h ================================================ /**************************************************************************** Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPAGE_TURN_TRANSITION_H__ #define __CCPAGE_TURN_TRANSITION_H__ #include "CCTransition.h" #include "renderer/CCCustomCommand.h" NS_CC_BEGIN class NodeGrid; /** * @addtogroup transition * @{ */ /** @brief A transition which peels back the bottom right hand corner of a scene to transition to the scene beneath it simulating a page turn. This uses a 3DAction so it's strongly recommended that depth buffering is turned on in Director using: Director::getInstance()->setDepthBufferFormat(kDepthBuffer16); @since v0.8.2 */ class CC_DLL TransitionPageTurn : public TransitionScene { public: /** * Creates a base transition with duration and incoming scene. * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. */ static TransitionPageTurn* create(float t,Scene* scene,bool backwards); /** * @js ctor */ TransitionPageTurn(); /** * @js NA * @lua NA */ virtual ~TransitionPageTurn(); // // Overrides // virtual void draw() override; /** * Creates a base transition with duration and incoming scene. * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. */ bool initWithDuration(float t,Scene* scene,bool backwards); ActionInterval* actionWithSize(const Size& vector); // // Overrides // virtual void onEnter() override; virtual void onExit() override; protected: virtual void sceneOrder() override; protected: NodeGrid* _inSceneProxy; NodeGrid* _outSceneProxy; bool _back; static float POLYGON_OFFSET_FACTOR; static float POLYGON_OFFSET_UNITS; protected: CustomCommand _enableOffsetCmd; CustomCommand _disableOffsetCmd; void onEnablePolygonOffset(); void onDisablePolygonOffset(); }; // end of transition group /// @} NS_CC_END #endif // __CCPAGE_TURN_TRANSITION_H__ ================================================ FILE: cocos2d/cocos/2d/CCTransitionProgress.cpp ================================================ /**************************************************************************** Copyright (c) 2009 Lam Pham Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2012 Ricardo Quesada Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTransitionProgress.h" #include "CCDirector.h" #include "CCRenderTexture.h" #include "CCProgressTimer.h" #include "CCLayer.h" #include "CCActionInstant.h" #include "CCActionProgressTimer.h" NS_CC_BEGIN enum { kSceneRadial = 0xc001, }; TransitionProgress::TransitionProgress() : _to(0.0f) , _from(0.0f) , _sceneToBeModified(nullptr) { } TransitionProgress* TransitionProgress::create(float t, Scene* scene) { TransitionProgress* newScene = new TransitionProgress(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } // TransitionProgress void TransitionProgress::onEnter() { TransitionScene::onEnter(); setupTransition(); // create a transparent color layer // in which we are going to add our rendertextures Size size = Director::getInstance()->getWinSize(); // create the second render texture for outScene RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height); texture->getSprite()->setAnchorPoint(Point(0.5f,0.5f)); texture->setPosition(Point(size.width/2, size.height/2)); texture->setAnchorPoint(Point(0.5f,0.5f)); // render outScene to its texturebuffer texture->beginWithClear(0, 0, 0, 1); _sceneToBeModified->visit(); texture->end(); // Since we've passed the outScene to the texture we don't need it. if (_sceneToBeModified == _outScene) { hideOutShowIn(); } // We need the texture in RenderTexture. ProgressTimer *node = progressTimerNodeWithRenderTexture(texture); // create the blend action ActionInterval* layerAction = (ActionInterval*)Sequence::create( ProgressFromTo::create(_duration, _from, _to), CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)), nullptr); // run the blend action node->runAction(layerAction); // add the layer (which contains our two rendertextures) to the scene addChild(node, 2, kSceneRadial); } // clean up on exit void TransitionProgress::onExit() { // remove our layer and release all containing objects removeChildByTag(kSceneRadial, true); TransitionScene::onExit(); } void TransitionProgress::sceneOrder() { _isInSceneOnTop = false; } void TransitionProgress::setupTransition() { _sceneToBeModified = _outScene; _from = 100; _to = 0; } ProgressTimer* TransitionProgress::progressTimerNodeWithRenderTexture(RenderTexture* texture) { CCASSERT(false, "override me - abstract class"); return nullptr; } // TransitionProgressRadialCCW ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(RenderTexture* texture) { Size size = Director::getInstance()->getWinSize(); ProgressTimer* node = ProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite node->getSprite()->setFlippedY(true); node->setType(ProgressTimer::Type::RADIAL); // Return the radial type that we want to use node->setReverseDirection(false); node->setPercentage(100); node->setPosition(Point(size.width/2, size.height/2)); node->setAnchorPoint(Point(0.5f,0.5f)); return node; } TransitionProgressRadialCCW* TransitionProgressRadialCCW::create(float t, Scene* scene) { TransitionProgressRadialCCW* newScene = new TransitionProgressRadialCCW(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } // TransitionProgressRadialCW TransitionProgressRadialCW* TransitionProgressRadialCW::create(float t, Scene* scene) { TransitionProgressRadialCW* newScene = new TransitionProgressRadialCW(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(RenderTexture* texture) { Size size = Director::getInstance()->getWinSize(); ProgressTimer* node = ProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite node->getSprite()->setFlippedY(true); node->setType( ProgressTimer::Type::RADIAL ); // Return the radial type that we want to use node->setReverseDirection(true); node->setPercentage(100); node->setPosition(Point(size.width/2, size.height/2)); node->setAnchorPoint(Point(0.5f,0.5f)); return node; } // TransitionProgressHorizontal TransitionProgressHorizontal* TransitionProgressHorizontal::create(float t, Scene* scene) { TransitionProgressHorizontal* newScene = new TransitionProgressHorizontal(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(RenderTexture* texture) { Size size = Director::getInstance()->getWinSize(); ProgressTimer* node = ProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite node->getSprite()->setFlippedY(true); node->setType( ProgressTimer::Type::BAR); node->setMidpoint(Point(1, 0)); node->setBarChangeRate(Point(1,0)); node->setPercentage(100); node->setPosition(Point(size.width/2, size.height/2)); node->setAnchorPoint(Point(0.5f,0.5f)); return node; } // TransitionProgressVertical TransitionProgressVertical* TransitionProgressVertical::create(float t, Scene* scene) { TransitionProgressVertical* newScene = new TransitionProgressVertical(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(RenderTexture* texture) { Size size = Director::getInstance()->getWinSize(); ProgressTimer* node = ProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite node->getSprite()->setFlippedY(true); node->setType(ProgressTimer::Type::BAR); node->setMidpoint(Point(0, 0)); node->setBarChangeRate(Point(0,1)); node->setPercentage(100); node->setPosition(Point(size.width/2, size.height/2)); node->setAnchorPoint(Point(0.5f,0.5f)); return node; } // TransitionProgressInOut TransitionProgressInOut* TransitionProgressInOut::create(float t, Scene* scene) { TransitionProgressInOut* newScene = new TransitionProgressInOut(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } void TransitionProgressInOut::sceneOrder() { _isInSceneOnTop = false; } void TransitionProgressInOut::setupTransition() { _sceneToBeModified = _inScene; _from = 0; _to = 100; } ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(RenderTexture* texture) { Size size = Director::getInstance()->getWinSize(); ProgressTimer* node = ProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite node->getSprite()->setFlippedY(true); node->setType( ProgressTimer::Type::BAR); node->setMidpoint(Point(0.5f, 0.5f)); node->setBarChangeRate(Point(1, 1)); node->setPercentage(0); node->setPosition(Point(size.width/2, size.height/2)); node->setAnchorPoint(Point(0.5f,0.5f)); return node; } // TransitionProgressOutIn TransitionProgressOutIn* TransitionProgressOutIn::create(float t, Scene* scene) { TransitionProgressOutIn* newScene = new TransitionProgressOutIn(); if(newScene && newScene->initWithDuration(t, scene)) { newScene->autorelease(); return newScene; } CC_SAFE_DELETE(newScene); return nullptr; } ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(RenderTexture* texture) { Size size = Director::getInstance()->getWinSize(); ProgressTimer* node = ProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite node->getSprite()->setFlippedY(true); node->setType( ProgressTimer::Type::BAR ); node->setMidpoint(Point(0.5f, 0.5f)); node->setBarChangeRate(Point(1, 1)); node->setPercentage(100); node->setPosition(Point(size.width/2, size.height/2)); node->setAnchorPoint(Point(0.5f,0.5f)); return node; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCTransitionProgress.h ================================================ /**************************************************************************** Copyright (c) 2009 Lam Pham Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2012 Ricardo Quesada Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTRANSITIONPROGRESS_H__ #define __CCTRANSITIONPROGRESS_H__ #include "CCTransition.h" NS_CC_BEGIN class ProgressTimer; class RenderTexture; /** * @addtogroup transition * @{ */ class CC_DLL TransitionProgress : public TransitionScene { public: static TransitionProgress* create(float t, Scene* scene); TransitionProgress(); // // Overrides // virtual void onEnter() override; virtual void onExit() override; protected: virtual void sceneOrder() override; protected: virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture); virtual void setupTransition(); protected: float _to; float _from; Scene* _sceneToBeModified; }; /** TransitionRadialCCW transition. A counter clock-wise radial transition to the next scene */ class CC_DLL TransitionProgressRadialCCW : public TransitionProgress { public: static TransitionProgressRadialCCW* create(float t, Scene* scene); protected: // // Overrides // virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override; }; /** TransitionRadialCW transition. A counter clock-wise radial transition to the next scene */ class CC_DLL TransitionProgressRadialCW : public TransitionProgress { public: static TransitionProgressRadialCW* create(float t, Scene* scene); protected: // // Overrides // virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override; }; /** TransitionProgressHorizontal transition. A clock-wise radial transition to the next scene */ class CC_DLL TransitionProgressHorizontal : public TransitionProgress { public: static TransitionProgressHorizontal* create(float t, Scene* scene); protected: // // Overrides // virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override; }; class CC_DLL TransitionProgressVertical : public TransitionProgress { public: static TransitionProgressVertical* create(float t, Scene* scene); protected: // // Overrides // virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override; }; class CC_DLL TransitionProgressInOut : public TransitionProgress { public: static TransitionProgressInOut* create(float t, Scene* scene); protected: // // Overrides // virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override; virtual void sceneOrder() override; virtual void setupTransition() override; }; class CC_DLL TransitionProgressOutIn : public TransitionProgress { public: static TransitionProgressOutIn* create(float t, Scene* scene); protected: // // Overrides // virtual ProgressTimer* progressTimerNodeWithRenderTexture(RenderTexture* texture) override; }; // end of transition group /// @} NS_CC_END #endif /* __CCTRANSITIONPROGRESS_H__ */ ================================================ FILE: cocos2d/cocos/2d/CCUserDefault.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCUserDefault.h" #include "platform/CCCommon.h" #include "platform/CCFileUtils.h" #include "tinyxml2.h" #include "base64.h" #if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) // root name of xml #define USERDEFAULT_ROOT_NAME "userDefaultRoot" #define XML_FILE_NAME "UserDefault.xml" using namespace std; NS_CC_BEGIN /** * define the functions here because we don't want to * export xmlNodePtr and other types in "CCUserDefault.h" */ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLElement** rootNode, tinyxml2::XMLDocument **doc) { tinyxml2::XMLElement* curNode = nullptr; // check the key value if (! pKey) { return nullptr; } do { tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); *doc = xmlDoc; std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath()); if (xmlBuffer.empty()) { CCLOG("can not read xml file"); break; } xmlDoc->Parse(xmlBuffer.c_str(), xmlBuffer.size()); // get root node *rootNode = xmlDoc->RootElement(); if (nullptr == *rootNode) { CCLOG("read root node error"); break; } // find the node curNode = (*rootNode)->FirstChildElement(); while (nullptr != curNode) { const char* nodeName = curNode->Value(); if (!strcmp(nodeName, pKey)) { break; } curNode = curNode->NextSiblingElement(); } } while (0); return curNode; } static void setValueForKey(const char* pKey, const char* pValue) { tinyxml2::XMLElement* rootNode; tinyxml2::XMLDocument* doc; tinyxml2::XMLElement* node; // check the params if (! pKey || ! pValue) { return; } // find the node node = getXMLNodeForKey(pKey, &rootNode, &doc); // if node exist, change the content if (node) { if (node->FirstChild()) { node->FirstChild()->SetValue(pValue); } else { tinyxml2::XMLText* content = doc->NewText(pValue); node->LinkEndChild(content); } } else { if (rootNode) { tinyxml2::XMLElement* tmpNode = doc->NewElement(pKey);//new tinyxml2::XMLElement(pKey); rootNode->LinkEndChild(tmpNode); tinyxml2::XMLText* content = doc->NewText(pValue);//new tinyxml2::XMLText(pValue); tmpNode->LinkEndChild(content); } } // save file and free doc if (doc) { doc->SaveFile(UserDefault::getInstance()->getXMLFilePath().c_str()); delete doc; } } /** * implements of UserDefault */ UserDefault* UserDefault::_userDefault = nullptr; string UserDefault::_filePath = string(""); bool UserDefault::_isFilePathInitialized = false; UserDefault::~UserDefault() { } UserDefault::UserDefault() { } bool UserDefault::getBoolForKey(const char* pKey) { return getBoolForKey(pKey, false); } bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue) { const char* value = nullptr; tinyxml2::XMLElement* rootNode; tinyxml2::XMLDocument* doc; tinyxml2::XMLElement* node; node = getXMLNodeForKey(pKey, &rootNode, &doc); // find the node if (node && node->FirstChild()) { value = (const char*)(node->FirstChild()->Value()); } bool ret = defaultValue; if (value) { ret = (! strcmp(value, "true")); } if (doc) delete doc; return ret; } int UserDefault::getIntegerForKey(const char* pKey) { return getIntegerForKey(pKey, 0); } int UserDefault::getIntegerForKey(const char* pKey, int defaultValue) { const char* value = nullptr; tinyxml2::XMLElement* rootNode; tinyxml2::XMLDocument* doc; tinyxml2::XMLElement* node; node = getXMLNodeForKey(pKey, &rootNode, &doc); // find the node if (node && node->FirstChild()) { value = (const char*)(node->FirstChild()->Value()); } int ret = defaultValue; if (value) { ret = atoi(value); } if(doc) { delete doc; } return ret; } float UserDefault::getFloatForKey(const char* pKey) { return getFloatForKey(pKey, 0.0f); } float UserDefault::getFloatForKey(const char* pKey, float defaultValue) { float ret = (float)getDoubleForKey(pKey, (double)defaultValue); return ret; } double UserDefault::getDoubleForKey(const char* pKey) { return getDoubleForKey(pKey, 0.0); } double UserDefault::getDoubleForKey(const char* pKey, double defaultValue) { const char* value = nullptr; tinyxml2::XMLElement* rootNode; tinyxml2::XMLDocument* doc; tinyxml2::XMLElement* node; node = getXMLNodeForKey(pKey, &rootNode, &doc); // find the node if (node && node->FirstChild()) { value = (const char*)(node->FirstChild()->Value()); } double ret = defaultValue; if (value) { ret = atof(value); } if (doc) delete doc; return ret; } std::string UserDefault::getStringForKey(const char* pKey) { return getStringForKey(pKey, ""); } string UserDefault::getStringForKey(const char* pKey, const std::string & defaultValue) { const char* value = nullptr; tinyxml2::XMLElement* rootNode; tinyxml2::XMLDocument* doc; tinyxml2::XMLElement* node; node = getXMLNodeForKey(pKey, &rootNode, &doc); // find the node if (node && node->FirstChild()) { value = (const char*)(node->FirstChild()->Value()); } string ret = defaultValue; if (value) { ret = string(value); } if (doc) delete doc; return ret; } Data UserDefault::getDataForKey(const char* pKey) { return getDataForKey(pKey, Data::Null); } Data UserDefault::getDataForKey(const char* pKey, const Data& defaultValue) { const char* encodedData = nullptr; tinyxml2::XMLElement* rootNode; tinyxml2::XMLDocument* doc; tinyxml2::XMLElement* node; node = getXMLNodeForKey(pKey, &rootNode, &doc); // find the node if (node && node->FirstChild()) { encodedData = (const char*)(node->FirstChild()->Value()); } Data ret = defaultValue; if (encodedData) { unsigned char * decodedData = nullptr; int decodedDataLen = base64Decode((unsigned char*)encodedData, (unsigned int)strlen(encodedData), &decodedData); if (decodedData) { ret.fastSet(decodedData, decodedDataLen); } } if (doc) delete doc; return ret; } void UserDefault::setBoolForKey(const char* pKey, bool value) { // save bool value as string if (true == value) { setStringForKey(pKey, "true"); } else { setStringForKey(pKey, "false"); } } void UserDefault::setIntegerForKey(const char* pKey, int value) { // check key if (! pKey) { return; } // format the value char tmp[50]; memset(tmp, 0, 50); sprintf(tmp, "%d", value); setValueForKey(pKey, tmp); } void UserDefault::setFloatForKey(const char* pKey, float value) { setDoubleForKey(pKey, value); } void UserDefault::setDoubleForKey(const char* pKey, double value) { // check key if (! pKey) { return; } // format the value char tmp[50]; memset(tmp, 0, 50); sprintf(tmp, "%f", value); setValueForKey(pKey, tmp); } void UserDefault::setStringForKey(const char* pKey, const std::string & value) { // check key if (! pKey) { return; } setValueForKey(pKey, value.c_str()); } void UserDefault::setDataForKey(const char* pKey, const Data& value) { // check key if (! pKey) { return; } char *encodedData = 0; base64Encode(value.getBytes(), static_cast(value.getSize()), &encodedData); setValueForKey(pKey, encodedData); if (encodedData) free(encodedData); } UserDefault* UserDefault::getInstance() { initXMLFilePath(); // only create xml file one time // the file exists after the program exit if ((! isXMLFileExist()) && (! createXMLFile())) { return nullptr; } if (! _userDefault) { _userDefault = new UserDefault(); } return _userDefault; } void UserDefault::destroyInstance() { CC_SAFE_DELETE(_userDefault); } // XXX: deprecated UserDefault* UserDefault::sharedUserDefault() { return UserDefault::getInstance(); } // XXX: deprecated void UserDefault::purgeSharedUserDefault() { return UserDefault::destroyInstance(); } bool UserDefault::isXMLFileExist() { FILE *fp = fopen(_filePath.c_str(), "r"); bool bRet = false; if (fp) { bRet = true; fclose(fp); } return bRet; } void UserDefault::initXMLFilePath() { if (! _isFilePathInitialized) { _filePath += FileUtils::getInstance()->getWritablePath() + XML_FILE_NAME; _isFilePathInitialized = true; } } // create new xml file bool UserDefault::createXMLFile() { bool bRet = false; tinyxml2::XMLDocument *pDoc = new tinyxml2::XMLDocument(); if (nullptr==pDoc) { return false; } tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration(nullptr); if (nullptr==pDeclaration) { return false; } pDoc->LinkEndChild(pDeclaration); tinyxml2::XMLElement *pRootEle = pDoc->NewElement(USERDEFAULT_ROOT_NAME); if (nullptr==pRootEle) { return false; } pDoc->LinkEndChild(pRootEle); bRet = tinyxml2::XML_SUCCESS == pDoc->SaveFile(_filePath.c_str()); if(pDoc) { delete pDoc; } return bRet; } const string& UserDefault::getXMLFilePath() { return _filePath; } void UserDefault::flush() { } NS_CC_END #endif // (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_PLATFORM != CC_PLATFORM_ANDROID) ================================================ FILE: cocos2d/cocos/2d/CCUserDefault.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SUPPORT_CCUSERDEFAULT_H__ #define __SUPPORT_CCUSERDEFAULT_H__ #include "CCPlatformMacros.h" #include #include "CCData.h" NS_CC_BEGIN /** * @addtogroup data_storage * @{ */ /** * UserDefault acts as a tiny database. You can save and get base type values by it. * For example, setBoolForKey("played", true) will add a bool value true into the database. * Its key is "played". You can get the value of the key by getBoolForKey("played"). * * It supports the following base types: * bool, int, float, double, string */ class CC_DLL UserDefault { public: // get value methods /** @brief Get bool value by key, if the key doesn't exist, a default value will return. You can set the default value, or it is false. * @js NA */ bool getBoolForKey(const char* pKey); /** * @js NA */ bool getBoolForKey(const char* pKey, bool defaultValue); /** @brief Get integer value by key, if the key doesn't exist, a default value will return. You can set the default value, or it is 0. * @js NA */ int getIntegerForKey(const char* pKey); /** * @js NA */ int getIntegerForKey(const char* pKey, int defaultValue); /** @brief Get float value by key, if the key doesn't exist, a default value will return. You can set the default value, or it is 0.0f. * @js NA */ float getFloatForKey(const char* pKey); /** * @js NA */ float getFloatForKey(const char* pKey, float defaultValue); /** @brief Get double value by key, if the key doesn't exist, a default value will return. You can set the default value, or it is 0.0. * @js NA */ double getDoubleForKey(const char* pKey); /** * @js NA */ double getDoubleForKey(const char* pKey, double defaultValue); /** @brief Get string value by key, if the key doesn't exist, a default value will return. You can set the default value, or it is "". * @js NA */ std::string getStringForKey(const char* pKey); /** * @js NA */ std::string getStringForKey(const char* pKey, const std::string & defaultValue); /** @brief Get binary data value by key, if the key doesn't exist, a default value will return. You can set the default value, or it is null. * @js NA * @lua NA */ Data getDataForKey(const char* pKey); /** * @js NA * @lua NA */ Data getDataForKey(const char* pKey, const Data& defaultValue); // set value methods /** @brief Set bool value by key. * @js NA */ void setBoolForKey(const char* pKey, bool value); /** @brief Set integer value by key. * @js NA */ void setIntegerForKey(const char* pKey, int value); /** @brief Set float value by key. * @js NA */ void setFloatForKey(const char* pKey, float value); /** @brief Set double value by key. * @js NA */ void setDoubleForKey(const char* pKey, double value); /** @brief Set string value by key. * @js NA */ void setStringForKey(const char* pKey, const std::string & value); /** @brief Set binary data value by key. * @js NA * @lua NA */ void setDataForKey(const char* pKey, const Data& value); /** @brief Save content to xml file * @js NA */ void flush(); /** returns the singleton * @js NA * @lua NA */ static UserDefault* getInstance(); /** * @js NA */ static void destroyInstance(); /** deprecated. Use getInstace() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static UserDefault* sharedUserDefault(); /** * @js NA */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedUserDefault(); /** * @js NA */ const static std::string& getXMLFilePath(); /** * @js NA */ static bool isXMLFileExist(); private: UserDefault(); ~UserDefault(); static bool createXMLFile(); static void initXMLFilePath(); static UserDefault* _userDefault; static std::string _filePath; static bool _isFilePathInitialized; }; // end of data_storage group /// @} NS_CC_END #endif // __SUPPORT_CCUSERDEFAULT_H__ ================================================ FILE: cocos2d/cocos/2d/CCUserDefault.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import "CCUserDefault.h" #import #import "platform/CCFileUtils.h" #import "tinyxml2.h" #import "CCPlatformConfig.h" #import "CCPlatformMacros.h" #import "base64.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #define XML_FILE_NAME "UserDefault.xml" // root name of xml #define USERDEFAULT_ROOT_NAME "userDefaultRoot" #define KEEP_COMPATABILITY using namespace std; NS_CC_BEGIN /** * implements of UserDefault */ UserDefault* UserDefault::_userDefault = nullptr; string UserDefault::_filePath = string(""); bool UserDefault::_isFilePathInitialized = false; #ifdef KEEP_COMPATABILITY static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDocument **doc) { tinyxml2::XMLElement* curNode = nullptr; tinyxml2::XMLElement* rootNode = nullptr; if (! UserDefault::isXMLFileExist()) { return nullptr; } // check the key value if (! pKey) { return nullptr; } do { tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); *doc = xmlDoc; std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath()); if (xmlBuffer.empty()) { NSLog(@"can not read xml file"); break; } xmlDoc->Parse(xmlBuffer.c_str(), xmlBuffer.size()); // get root node rootNode = xmlDoc->RootElement(); if (nullptr == rootNode) { NSLog(@"read root node error"); break; } // find the node curNode = rootNode->FirstChildElement(); if (!curNode) { // There is not xml node, delete xml file. remove(UserDefault::getInstance()->getXMLFilePath().c_str()); return nullptr; } while (nullptr != curNode) { const char* nodeName = curNode->Value(); if (!strcmp(nodeName, pKey)) { // delete the node break; } curNode = curNode->NextSiblingElement(); } } while (0); return curNode; } static void deleteNode(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* node) { if (node) { doc->DeleteNode(node); doc->SaveFile(UserDefault::getInstance()->getXMLFilePath().c_str()); delete doc; } } static void deleteNodeByKey(const char *pKey) { tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); deleteNode(doc, node); } #endif UserDefault::~UserDefault() { } UserDefault::UserDefault() { } bool UserDefault::getBoolForKey(const char* pKey) { return getBoolForKey(pKey, false); } bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { const char* value = (const char*)node->FirstChild()->Value(); bool ret = (! strcmp(value, "true")); // set value in NSUserDefaults setBoolForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif bool ret = defaultValue; NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]]; if (value) { ret = [value boolValue]; } return ret; } int UserDefault::getIntegerForKey(const char* pKey) { return getIntegerForKey(pKey, 0); } int UserDefault::getIntegerForKey(const char* pKey, int defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { int ret = atoi((const char*)node->FirstChild()->Value()); // set value in NSUserDefaults setIntegerForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif int ret = defaultValue; NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]]; if (value) { ret = [value intValue]; } return ret; } float UserDefault::getFloatForKey(const char* pKey) { return getFloatForKey(pKey, 0); } float UserDefault::getFloatForKey(const char* pKey, float defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { float ret = atof((const char*)node->FirstChild()->Value()); // set value in NSUserDefaults setFloatForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif float ret = defaultValue; NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]]; if (value) { ret = [value floatValue]; } return ret; } double UserDefault::getDoubleForKey(const char* pKey) { return getDoubleForKey(pKey, 0); } double UserDefault::getDoubleForKey(const char* pKey, double defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { double ret = atof((const char*)node->FirstChild()->Value()); // set value in NSUserDefaults setDoubleForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif double ret = defaultValue; NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]]; if (value) { ret = [value doubleValue]; } return ret; } std::string UserDefault::getStringForKey(const char* pKey) { return getStringForKey(pKey, ""); } string UserDefault::getStringForKey(const char* pKey, const std::string & defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { string ret = (const char*)node->FirstChild()->Value(); // set value in NSUserDefaults setStringForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif NSString *str = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithUTF8String:pKey]]; if (! str) { return defaultValue; } else { return [str UTF8String]; } } Data UserDefault::getDataForKey(const char* pKey) { return getDataForKey(pKey, Data::Null); } Data UserDefault::getDataForKey(const char* pKey, const Data& defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { const char * encodedData = node->FirstChild()->Value(); unsigned char * decodedData; int decodedDataLen = base64Decode((unsigned char*)encodedData, (unsigned int)strlen(encodedData), &decodedData); if (decodedData) { Data ret; ret.fastSet(decodedData, decodedDataLen); // set value in NSUserDefaults setDataForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } } else { // delete xmle node deleteNode(doc, node); } } #endif NSData *data = [[NSUserDefaults standardUserDefaults] dataForKey:[NSString stringWithUTF8String:pKey]]; if (! data) { return defaultValue; } else { Data ret; ret.copy((unsigned char*)data.bytes, data.length); return ret; } } void UserDefault::setBoolForKey(const char* pKey, bool value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:value] forKey:[NSString stringWithUTF8String:pKey]]; } void UserDefault::setIntegerForKey(const char* pKey, int value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:value] forKey:[NSString stringWithUTF8String:pKey]]; } void UserDefault::setFloatForKey(const char* pKey, float value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithFloat:value] forKey:[NSString stringWithUTF8String:pKey]]; } void UserDefault::setDoubleForKey(const char* pKey, double value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithDouble:value] forKey:[NSString stringWithUTF8String:pKey]]; } void UserDefault::setStringForKey(const char* pKey, const std::string & value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithUTF8String:value.c_str()] forKey:[NSString stringWithUTF8String:pKey]]; } void UserDefault::setDataForKey(const char* pKey, const Data& value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif [[NSUserDefaults standardUserDefaults] setObject:[NSData dataWithBytes: value.getBytes() length: value.getSize()] forKey:[NSString stringWithUTF8String:pKey]]; } UserDefault* UserDefault::getInstance() { #ifdef KEEP_COMPATABILITY initXMLFilePath(); #endif if (! _userDefault) { _userDefault = new UserDefault(); } return _userDefault; } void UserDefault::destroyInstance() { CC_SAFE_DELETE(_userDefault); } // XXX: deprecated UserDefault* UserDefault::sharedUserDefault() { return UserDefault::getInstance(); } // XXX: deprecated void UserDefault::purgeSharedUserDefault() { UserDefault::destroyInstance(); } bool UserDefault::isXMLFileExist() { FILE *fp = fopen(_filePath.c_str(), "r"); bool bRet = false; if (fp) { bRet = true; fclose(fp); } return bRet; } void UserDefault::initXMLFilePath() { #ifdef KEEP_COMPATABILITY if (! _isFilePathInitialized) { // xml file is stored in cache directory before 2.1.2 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; _filePath = [documentsDirectory UTF8String]; _filePath.append("/"); _filePath += XML_FILE_NAME; _isFilePathInitialized = true; } #endif } // create new xml file bool UserDefault::createXMLFile() { return false; } const string& UserDefault::getXMLFilePath() { return _filePath; } void UserDefault::flush() { [[NSUserDefaults standardUserDefaults] synchronize]; } NS_CC_END #endif // (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) ================================================ FILE: cocos2d/cocos/2d/CCUserDefaultAndroid.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCUserDefault.h" #include "CCPlatformConfig.h" #include "platform/CCCommon.h" #include "base64.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" // root name of xml #define USERDEFAULT_ROOT_NAME "userDefaultRoot" #define KEEP_COMPATABILITY #define XML_FILE_NAME "UserDefault.xml" #ifdef KEEP_COMPATABILITY #include "platform/CCFileUtils.h" #include "../tinyxml2/tinyxml2.h" #endif using namespace std; NS_CC_BEGIN /** * implements of UserDefault */ UserDefault* UserDefault::_userDefault = nullptr; string UserDefault::_filePath = string(""); bool UserDefault::_isFilePathInitialized = false; #ifdef KEEP_COMPATABILITY static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDocument **doc) { tinyxml2::XMLElement* curNode = nullptr; tinyxml2::XMLElement* rootNode = nullptr; if (! UserDefault::isXMLFileExist()) { return nullptr; } // check the key value if (! pKey) { return nullptr; } do { tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); *doc = xmlDoc; ssize_t size; std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath().c_str()); if (xmlBuffer.empty()) { CCLOG("can not read xml file"); break; } xmlDoc->Parse(xmlBuffer.c_str()); // get root node rootNode = xmlDoc->RootElement(); if (nullptr == rootNode) { CCLOG("read root node error"); break; } // find the node curNode = rootNode->FirstChildElement(); if (!curNode) { // There is not xml node, delete xml file. remove(UserDefault::getInstance()->getXMLFilePath().c_str()); return nullptr; } while (nullptr != curNode) { const char* nodeName = curNode->Value(); if (!strcmp(nodeName, pKey)) { // delete the node break; } curNode = curNode->NextSiblingElement(); } } while (0); return curNode; } static void deleteNode(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* node) { if (node) { doc->DeleteNode(node); doc->SaveFile(UserDefault::getInstance()->getXMLFilePath().c_str()); delete doc; } } static void deleteNodeByKey(const char *pKey) { tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); deleteNode(doc, node); } #endif UserDefault::~UserDefault() { } UserDefault::UserDefault() { } // XXX: deprecated void UserDefault::purgeSharedUserDefault() { UserDefault::destroyInstance(); } void UserDefault::destroyInstance() { CC_SAFE_DELETE(_userDefault); } bool UserDefault::getBoolForKey(const char* pKey) { return getBoolForKey(pKey, false); } bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { const char* value = (const char*)node->FirstChild()->Value(); bool ret = (! strcmp(value, "true")); // set value in NSUserDefaults setBoolForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif return getBoolForKeyJNI(pKey, defaultValue); } int UserDefault::getIntegerForKey(const char* pKey) { return getIntegerForKey(pKey, 0); } int UserDefault::getIntegerForKey(const char* pKey, int defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { int ret = atoi((const char*)node->FirstChild()->Value()); // set value in NSUserDefaults setIntegerForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif return getIntegerForKeyJNI(pKey, defaultValue); } float UserDefault::getFloatForKey(const char* pKey) { return getFloatForKey(pKey, 0.0f); } float UserDefault::getFloatForKey(const char* pKey, float defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { float ret = atof((const char*)node->FirstChild()->Value()); // set value in NSUserDefaults setFloatForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif return getFloatForKeyJNI(pKey, defaultValue); } double UserDefault::getDoubleForKey(const char* pKey) { return getDoubleForKey(pKey, 0.0); } double UserDefault::getDoubleForKey(const char* pKey, double defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { double ret = atof((const char*)node->FirstChild()->Value()); // set value in NSUserDefaults setDoubleForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif return getDoubleForKeyJNI(pKey, defaultValue); } std::string UserDefault::getStringForKey(const char* pKey) { return getStringForKey(pKey, ""); } string UserDefault::getStringForKey(const char* pKey, const std::string & defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { string ret = (const char*)node->FirstChild()->Value(); // set value in NSUserDefaults setStringForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } else { // delete xmle node deleteNode(doc, node); } } #endif return getStringForKeyJNI(pKey, defaultValue.c_str()); } Data UserDefault::getDataForKey(const char* pKey) { return getDataForKey(pKey, Data::Null); } Data UserDefault::getDataForKey(const char* pKey, const Data& defaultValue) { #ifdef KEEP_COMPATABILITY tinyxml2::XMLDocument* doc = nullptr; tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); if (node) { if (node->FirstChild()) { const char * encodedData = node->FirstChild()->Value(); unsigned char * decodedData; int decodedDataLen = base64Decode((unsigned char*)encodedData, (unsigned int)strlen(encodedData), &decodedData); if (decodedData) { Data ret; ret.fastSet(decodedData, decodedDataLen); // set value in NSUserDefaults setDataForKey(pKey, ret); flush(); // delete xmle node deleteNode(doc, node); return ret; } } else { // delete xmle node deleteNode(doc, node); } } #endif char * encodedDefaultData = NULL; unsigned int encodedDefaultDataLen = !defaultValue.isNull() ? base64Encode(defaultValue.getBytes(), defaultValue.getSize(), &encodedDefaultData) : 0; string encodedStr = getStringForKeyJNI(pKey, encodedDefaultData); if (encodedDefaultData) free(encodedDefaultData); CCLOG("ENCODED STRING: --%s--%d", encodedStr.c_str(), encodedStr.length()); unsigned char * decodedData = NULL; int decodedDataLen = base64Decode((unsigned char*)encodedStr.c_str(), (unsigned int)encodedStr.length(), &decodedData); CCLOG("DECODED DATA: %s %d", decodedData, decodedDataLen); if (decodedData && decodedDataLen) { Data ret; ret.fastSet(decodedData, decodedDataLen); return ret; } return defaultValue; } void UserDefault::setBoolForKey(const char* pKey, bool value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif return setBoolForKeyJNI(pKey, value); } void UserDefault::setIntegerForKey(const char* pKey, int value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif return setIntegerForKeyJNI(pKey, value); } void UserDefault::setFloatForKey(const char* pKey, float value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif return setFloatForKeyJNI(pKey, value); } void UserDefault::setDoubleForKey(const char* pKey, double value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif return setDoubleForKeyJNI(pKey, value); } void UserDefault::setStringForKey(const char* pKey, const std::string & value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif return setStringForKeyJNI(pKey, value.c_str()); } void UserDefault::setDataForKey(const char* pKey, const Data& value) { #ifdef KEEP_COMPATABILITY deleteNodeByKey(pKey); #endif CCLOG("SET DATA FOR KEY: --%s--%d", value.getBytes(), value.getSize()); char * encodedData = nullptr; unsigned int encodedDataLen = base64Encode(value.getBytes(), value.getSize(), &encodedData); CCLOG("SET DATA ENCODED: --%s", encodedData); setStringForKeyJNI(pKey, encodedData); if (encodedData) free(encodedData); } // XXX: deprecated UserDefault* UserDefault::sharedUserDefault() { return UserDefault::getInstance(); } UserDefault* UserDefault::getInstance() { #ifdef KEEP_COMPATABILITY initXMLFilePath(); #endif if (! _userDefault) { _userDefault = new UserDefault(); } return _userDefault; } bool UserDefault::isXMLFileExist() { FILE *fp = fopen(_filePath.c_str(), "r"); bool bRet = false; if (fp) { bRet = true; fclose(fp); } return bRet; } void UserDefault::initXMLFilePath() { #ifdef KEEP_COMPATABILITY if (! _isFilePathInitialized) { // UserDefault.xml is stored in /data/data// before v2.1.2 _filePath += "/data/data/" + getPackageNameJNI() + "/" + XML_FILE_NAME; _isFilePathInitialized = true; } #endif } // create new xml file bool UserDefault::createXMLFile() { return false; } const string& UserDefault::getXMLFilePath() { return _filePath; } void UserDefault::flush() { } NS_CC_END #endif // (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) ================================================ FILE: cocos2d/cocos/2d/CCVertex.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCVertex.h" #include "ccMacros.h" NS_CC_BEGIN void ccVertexLineToPolygon(Point *points, float stroke, Vertex2F *vertices, unsigned int offset, unsigned int nuPoints) { nuPoints += offset; if(nuPoints<=1) return; stroke *= 0.5f; unsigned int idx; unsigned int nuPointsMinus = nuPoints-1; for(unsigned int i = offset; i1.0f) fixVertex = true; if(fixVertex) { vertices[idx1] = p4; vertices[idx1+1] = p3; } } } bool ccVertexLineIntersect(float Ax, float Ay, float Bx, float By, float Cx, float Cy, float Dx, float Dy, float *T) { float distAB, theCos, theSin, newX; // FAIL: Line undefined if ((Ax==Bx && Ay==By) || (Cx==Dx && Cy==Dy)) return false; // Translate system to make A the origin Bx-=Ax; By-=Ay; Cx-=Ax; Cy-=Ay; Dx-=Ax; Dy-=Ay; // Length of segment AB distAB = sqrtf(Bx*Bx+By*By); // Rotate the system so that point B is on the positive X axis. theCos = Bx/distAB; theSin = By/distAB; newX = Cx*theCos+Cy*theSin; Cy = Cy*theCos-Cx*theSin; Cx = newX; newX = Dx*theCos+Dy*theSin; Dy = Dy*theCos-Dx*theSin; Dx = newX; // FAIL: Lines are parallel. if (Cy == Dy) return false; // Discover the relative position of the intersection in the line AB *T = (Dx+(Cx-Dx)*Dy/(Dy-Cy))/distAB; // Success. return true; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/CCVertex.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCVERTEX_H__ #define __CCVERTEX_H__ #include "ccTypes.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ /** @file CCVertex.h */ /** converts a line to a polygon */ void CC_DLL ccVertexLineToPolygon(Point *points, float stroke, Vertex2F *vertices, unsigned int offset, unsigned int nuPoints); /** returns whether or not the line intersects */ bool CC_DLL ccVertexLineIntersect(float Ax, float Ay, float Bx, float By, float Cx, float Cy, float Dx, float Dy, float *T); // end of data_structures group /// @} NS_CC_END #endif /* __CCVERTEX_H__ */ ================================================ FILE: cocos2d/cocos/2d/CMakeLists.txt ================================================ if(WIN32) ADD_DEFINITIONS(-DUNICODE -D_UNICODE) set(PLATFORM_SRC platform/win32/CCStdC.cpp platform/win32/CCFileUtilsWin32.cpp platform/win32/CCCommon.cpp platform/win32/CCApplication.cpp platform/win32/CCEGLView.cpp platform/win32/CCImage.cpp platform/win32/CCDevice.cpp ) elseif(APPLE) else() set(PLATFORM_SRC platform/linux/CCStdC.cpp platform/linux/CCFileUtilsLinux.cpp platform/linux/CCCommon.cpp platform/linux/CCApplication.cpp platform/desktop/CCEGLView.cpp platform/linux/CCImage.cpp platform/linux/CCDevice.cpp ) endif() set(COCOS2D_SRC CCAction.cpp CCActionCamera.cpp CCActionEase.cpp CCActionGrid.cpp CCActionGrid3D.cpp CCActionInstant.cpp CCActionInterval.cpp CCActionManager.cpp CCActionPageTurn3D.cpp CCActionProgressTimer.cpp CCActionTiledGrid.cpp CCActionCatmullRom.cpp CCActionTween.cpp CCAtlasNode.cpp CCNode.cpp CCEventAcceleration.cpp CCEventListenerAcceleration.cpp CCEvent.cpp CCEventDispatcher.cpp CCEventListener.cpp CCEventKeyboard.cpp CCEventListenerKeyboard.cpp CCEventMouse.cpp CCEventListenerMouse.cpp CCTouch.cpp CCEventTouch.cpp CCEventListenerTouch.cpp CCEventCustom.cpp CCEventListenerCustom.cpp CCDrawingPrimitives.cpp CCDrawNode.cpp CCGrabber.cpp CCGrid.cpp CCNodeGrid.cpp CCFont.cpp CCFontAtlas.cpp CCFontAtlasCache.cpp CCFontFNT.cpp CCFontFreeType.cpp CCFontCharMap.cpp CCLabel.cpp CCLabelAtlas.cpp CCLabelBMFont.cpp CCLabelTTF.cpp CCLabelTextFormatter.cpp CCLayer.cpp CCScene.cpp CCTransition.cpp CCTransitionPageTurn.cpp CCTransitionProgress.cpp CCMenu.cpp CCMenuItem.cpp CCMotionStreak.cpp CCProgressTimer.cpp CCClippingNode.cpp CCRenderTexture.cpp CCParticleExamples.cpp CCParticleSystem.cpp CCParticleSystemQuad.cpp CCParticleBatchNode.cpp CCScriptSupport.cpp CCAnimation.cpp CCAnimationCache.cpp CCSprite.cpp CCSpriteBatchNode.cpp CCSpriteFrame.cpp CCSpriteFrameCache.cpp ccUTF8.cpp CCProfiling.cpp CCUserDefault.cpp TransformUtils.cpp base64.cpp ccUtils.cpp CCVertex.cpp CCNotificationCenter.cpp TGAlib.cpp ZipUtils.cpp ccCArray.cpp CCComponent.cpp CCComponentContainer.cpp CCIMEDispatcher.cpp CCTextFieldTTF.cpp CCTexture2D.cpp CCTextureAtlas.cpp CCTextureCache.cpp CCParallaxNode.cpp CCTMXLayer.cpp CCTMXObjectGroup.cpp CCTMXTiledMap.cpp CCTMXXMLParser.cpp CCTileMapAtlas.cpp CCGLProgram.cpp ccGLStateCache.cpp CCShaderCache.cpp ccShaders.cpp CCConfiguration.cpp CCDirector.cpp CCScheduler.cpp ccFPSImages.c ccTypes.cpp cocos2d.cpp CCDeprecated.cpp platform/CCSAXParser.cpp platform/CCThread.cpp platform/CCEGLViewProtocol.cpp platform/CCFileUtils.cpp ../../external/edtaa3func/edtaa3func.cpp renderer/CCCustomCommand.cpp renderer/CCFrustum.cpp renderer/CCGroupCommand.cpp renderer/CCMaterialManager.cpp renderer/CCQuadCommand.cpp renderer/CCBatchCommand.cpp renderer/CCRenderCommand.cpp renderer/CCRenderer.cpp renderer/CCRenderMaterial.cpp ) include(../physics/CMakeLists.txt) add_library(cocos2d STATIC ${COCOS2D_SRC} ${PLATFORM_SRC} ${COCOS_PHYSICS_SRC} ) if(WIN32) if(MINGW) set(COCOS_LINK z jpeg png webp tiff glfw3 glew32 opengl32 iconv freetype bz2 ) else() set(COCOS_LINK libjpeg libpng libwebp libtiff freetype250 glfw3 glew32 opengl32 libiconv libzlib ) endif() elseif(APPLE) else() set(COCOS_LINK jpeg webp tiff freetype fontconfig png pthread glfw GLEW GL X11 rt z ) endif() target_link_libraries(cocos2d cocosbase chipmunk_static tinyxml2 kazmath unzip ${COCOS_LINK} ) set_target_properties(cocos2d PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/2d/TGAlib.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include #include "TGAlib.h" #include "CCData.h" #include "platform/CCFileUtils.h" NS_CC_BEGIN static bool tgaLoadRLEImageData(unsigned char* Buffer, unsigned long bufSize, tImageTGA *info); void tgaFlipImage( tImageTGA *info ); // load the image header field from stream bool tgaLoadHeader(unsigned char* buffer, unsigned long bufSize, tImageTGA *info) { bool ret = false; do { size_t step = sizeof(unsigned char) * 2; CC_BREAK_IF((step + sizeof(unsigned char)) > bufSize); memcpy(&info->type, buffer + step, sizeof(unsigned char)); step += sizeof(unsigned char) * 2; step += sizeof(signed short) * 4; CC_BREAK_IF((step + sizeof(signed short) * 2 + sizeof(unsigned char)) > bufSize); memcpy(&info->width, buffer + step, sizeof(signed short)); memcpy(&info->height, buffer + step + sizeof(signed short), sizeof(signed short)); memcpy(&info->pixelDepth, buffer + step + sizeof(signed short) * 2, sizeof(unsigned char)); step += sizeof(unsigned char); step += sizeof(signed short) * 2; CC_BREAK_IF((step + sizeof(unsigned char)) > bufSize); unsigned char cGarbage; memcpy(&cGarbage, buffer + step, sizeof(unsigned char)); info->flipped = 0; if ( cGarbage & 0x20 ) { info->flipped = 1; } ret = true; } while (0); return ret; } bool tgaLoadImageData(unsigned char *Buffer, unsigned long bufSize, tImageTGA *info) { bool ret = false; do { int mode,total,i; unsigned char aux; size_t step = (sizeof(unsigned char) + sizeof(signed short)) * 6; // mode equal the number of components for each pixel mode = info->pixelDepth / 8; // total is the number of unsigned chars we'll have to read total = info->height * info->width * mode; size_t dataSize = sizeof(unsigned char) * total; CC_BREAK_IF((step + dataSize) > bufSize); memcpy(info->imageData, Buffer + step, dataSize); // mode=3 or 4 implies that the image is RGB(A). However TGA // stores it as BGR(A) so we'll have to swap R and B. if (mode >= 3) { for (i=0; i < total; i+= mode) { aux = info->imageData[i]; info->imageData[i] = info->imageData[i+2]; info->imageData[i+2] = aux; } } ret = true; } while (0); return ret; } static bool tgaLoadRLEImageData(unsigned char* buffer, unsigned long bufSize, tImageTGA *info) { unsigned int mode,total,i, index = 0; unsigned char aux[4], runlength = 0; unsigned int skip = 0, flag = 0; size_t step = (sizeof(unsigned char) + sizeof(signed short)) * 6; // mode equal the number of components for each pixel mode = info->pixelDepth / 8; // total is the number of unsigned chars we'll have to read total = info->height * info->width; for( i = 0; i < total; i++ ) { // if we have a run length pending, run it if ( runlength != 0 ) { // we do, update the run length count runlength--; skip = (flag != 0); } else { // otherwise, read in the run length token CC_BREAK_IF((step + sizeof(unsigned char)) > bufSize); memcpy(&runlength, buffer + step, sizeof(unsigned char)); step += sizeof(unsigned char); // see if it's a RLE encoded sequence flag = runlength & 0x80; if ( flag ) { runlength -= 128; } skip = 0; } // do we need to skip reading this pixel? if ( !skip ) { // no, read in the pixel data CC_BREAK_IF((step + sizeof(unsigned char) * mode) > bufSize); memcpy(aux, buffer + step, sizeof(unsigned char) * mode); step += sizeof(unsigned char) * mode; // mode=3 or 4 implies that the image is RGB(A). However TGA // stores it as BGR(A) so we'll have to swap R and B. if ( mode >= 3 ) { unsigned char tmp; tmp = aux[0]; aux[0] = aux[2]; aux[2] = tmp; } } // add the pixel to our image memcpy(&info->imageData[index], aux, mode); index += mode; } return true; } void tgaFlipImage( tImageTGA *info ) { // mode equal the number of components for each pixel int mode = info->pixelDepth / 8; int rowbytes = info->width*mode; unsigned char *row = (unsigned char *)malloc(rowbytes); int y; if (row == NULL) return; for( y = 0; y < (info->height/2); y++ ) { memcpy(row, &info->imageData[y*rowbytes],rowbytes); memcpy(&info->imageData[y*rowbytes], &info->imageData[(info->height-(y+1))*rowbytes], rowbytes); memcpy(&info->imageData[(info->height-(y+1))*rowbytes], row, rowbytes); } free(row); info->flipped = 0; } tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size) { int mode,total; tImageTGA *info = nullptr; do { CC_BREAK_IF(! buffer); info = (tImageTGA *)malloc(sizeof(tImageTGA)); // get the file header info if (! tgaLoadHeader(buffer, size, info)) { info->status = TGA_ERROR_MEMORY; break; } // check if the image is color indexed if (info->type == 1) { info->status = TGA_ERROR_INDEXED_COLOR; break; } // check for other types (compressed images) if ((info->type != 2) && (info->type !=3) && (info->type !=10) ) { info->status = TGA_ERROR_COMPRESSED_FILE; break; } // mode equals the number of image components mode = info->pixelDepth / 8; // total is the number of unsigned chars to read total = info->height * info->width * mode; // allocate memory for image pixels info->imageData = (unsigned char *)malloc(sizeof(unsigned char) * total); // check to make sure we have the memory required if (info->imageData == NULL) { info->status = TGA_ERROR_MEMORY; break; } bool bLoadImage = false; // finally load the image pixels if ( info->type == 10 ) { bLoadImage = tgaLoadRLEImageData(buffer, size, info); } else { bLoadImage = tgaLoadImageData(buffer, size, info); } // check for errors when reading the pixels if (! bLoadImage) { info->status = TGA_ERROR_READING_FILE; break; } info->status = TGA_OK; if ( info->flipped ) { tgaFlipImage( info ); if ( info->flipped ) { info->status = TGA_ERROR_MEMORY; } } } while(0); return info; } // this is the function to call when we want to load an image tImageTGA * tgaLoad(const char *filename) { Data data = FileUtils::getInstance()->getDataFromFile(filename); if (!data.isNull()) { return tgaLoadBuffer(data.getBytes(), data.getSize()); } return nullptr; } // converts RGB to grayscale void tgaRGBtogreyscale(tImageTGA *info) { int mode,i,j; unsigned char *newImageData; // if the image is already grayscale do nothing if (info->pixelDepth == 8) return; // compute the number of actual components mode = info->pixelDepth / 8; // allocate an array for the new image data newImageData = (unsigned char *)malloc(sizeof(unsigned char) * info->height * info->width); if (newImageData == nullptr) { return; } // convert pixels: grayscale = o.30 * R + 0.59 * G + 0.11 * B for (i = 0,j = 0; j < info->width * info->height; i +=mode, j++) newImageData[j] = (unsigned char)(0.30 * info->imageData[i] + 0.59 * info->imageData[i+1] + 0.11 * info->imageData[i+2]); //free old image data free(info->imageData); // reassign pixelDepth and type according to the new image type info->pixelDepth = 8; info->type = 3; // reassigning imageData to the new array. info->imageData = newImageData; } // releases the memory used for the image void tgaDestroy(tImageTGA *info) { if (info != nullptr) { if (info->imageData != nullptr) { free(info->imageData); } free(info); } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/TGAlib.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SUPPORT_DATA_SUPPORT_TGALIB_H__ #define __SUPPORT_DATA_SUPPORT_TGALIB_H__ namespace cocos2d { enum { TGA_OK, TGA_ERROR_FILE_OPEN, TGA_ERROR_READING_FILE, TGA_ERROR_INDEXED_COLOR, TGA_ERROR_MEMORY, TGA_ERROR_COMPRESSED_FILE, }; /** TGA format */ typedef struct sImageTGA { int status; unsigned char type, pixelDepth; /** map width */ signed short width; /** map height */ signed short height; /** raw data */ unsigned char *imageData; int flipped; } tImageTGA; /// load the image header fields. We only keep those that matter! bool tgaLoadHeader(unsigned char *buffer, unsigned long bufSize, tImageTGA *info); /// loads the image pixels. You shouldn't call this function directly bool tgaLoadImageData(unsigned char *buffer, unsigned long bufSize, tImageTGA *info); /// this is the function to call when we want to load an image buffer. tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size); /// this is the function to call when we want to load an image tImageTGA * tgaLoad(const char *filename); // /converts RGB to grayscale void tgaRGBtogreyscale(tImageTGA *info); /// releases the memory used for the image void tgaDestroy(tImageTGA *info); }//namespace cocos2d #endif // __SUPPORT_DATA_SUPPORT_TGALIB_H__ ================================================ FILE: cocos2d/cocos/2d/TransformUtils.cpp ================================================ /**************************************************************************** Copyright (c) 2009 Valentin Milea Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "TransformUtils.h" #include "CCAffineTransform.h" namespace cocos2d { void CGAffineToGL(const AffineTransform& t, GLfloat *m) { // | m[0] m[4] m[8] m[12] | | m11 m21 m31 m41 | | a c 0 tx | // | m[1] m[5] m[9] m[13] | | m12 m22 m32 m42 | | b d 0 ty | // | m[2] m[6] m[10] m[14] | <=> | m13 m23 m33 m43 | <=> | 0 0 1 0 | // | m[3] m[7] m[11] m[15] | | m14 m24 m34 m44 | | 0 0 0 1 | m[2] = m[3] = m[6] = m[7] = m[8] = m[9] = m[11] = m[14] = 0.0f; m[10] = m[15] = 1.0f; m[0] = t.a; m[4] = t.c; m[12] = t.tx; m[1] = t.b; m[5] = t.d; m[13] = t.ty; } void GLToCGAffine(const GLfloat *m, AffineTransform *t) { t->a = m[0]; t->c = m[4]; t->tx = m[12]; t->b = m[1]; t->d = m[5]; t->ty = m[13]; } }//namespace cocos2d ================================================ FILE: cocos2d/cocos/2d/TransformUtils.h ================================================ /**************************************************************************** Copyright (c) 2009 Valentin Milea Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SUPPORT_TRANSFORM_UTILS_H__ #define __SUPPORT_TRANSFORM_UTILS_H__ // todo: // when in MAC or windows, it includes #include "CCGL.h" namespace cocos2d { struct AffineTransform; void CGAffineToGL(const AffineTransform &t, GLfloat *m); void GLToCGAffine(const GLfloat *m, AffineTransform *t); }//namespace cocos2d #endif // __SUPPORT_TRANSFORM_UTILS_H__ ================================================ FILE: cocos2d/cocos/2d/ZipUtils.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include #include #include "ZipUtils.h" #include "CCData.h" #include "ccMacros.h" #include "platform/CCFileUtils.h" #include "unzip.h" #include NS_CC_BEGIN unsigned int ZipUtils::s_uEncryptedPvrKeyParts[4] = {0,0,0,0}; unsigned int ZipUtils::s_uEncryptionKey[1024]; bool ZipUtils::s_bEncryptionKeyIsValid = false; // --------------------- ZipUtils --------------------- inline void ZipUtils::decodeEncodedPvr(unsigned int *data, ssize_t len) { const int enclen = 1024; const int securelen = 512; const int distance = 64; // check if key was set // make sure to call caw_setkey_part() for all 4 key parts CCASSERT(s_uEncryptedPvrKeyParts[0] != 0, "Cocos2D: CCZ file is encrypted but key part 0 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); CCASSERT(s_uEncryptedPvrKeyParts[1] != 0, "Cocos2D: CCZ file is encrypted but key part 1 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); CCASSERT(s_uEncryptedPvrKeyParts[2] != 0, "Cocos2D: CCZ file is encrypted but key part 2 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); CCASSERT(s_uEncryptedPvrKeyParts[3] != 0, "Cocos2D: CCZ file is encrypted but key part 3 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); // create long key if(!s_bEncryptionKeyIsValid) { unsigned int y, p, e; unsigned int rounds = 6; unsigned int sum = 0; unsigned int z = s_uEncryptionKey[enclen-1]; do { #define DELTA 0x9e3779b9 #define MX (((z>>5^y<<2) + (y>>3^z<<4)) ^ ((sum^y) + (s_uEncryptedPvrKeyParts[(p&3)^e] ^ z))) sum += DELTA; e = (sum >> 2) & 3; for (p = 0; p < enclen - 1; p++) { y = s_uEncryptionKey[p + 1]; z = s_uEncryptionKey[p] += MX; } y = s_uEncryptionKey[0]; z = s_uEncryptionKey[enclen - 1] += MX; } while (--rounds); s_bEncryptionKeyIsValid = true; } int b = 0; int i = 0; // encrypt first part completely for(; i < len && i < securelen; i++) { data[i] ^= s_uEncryptionKey[b++]; if(b >= enclen) { b = 0; } } // encrypt second section partially for(; i < len; i += distance) { data[i] ^= s_uEncryptionKey[b++]; if(b >= enclen) { b = 0; } } } inline unsigned int ZipUtils::checksumPvr(const unsigned int *data, ssize_t len) { unsigned int cs = 0; const int cslen = 128; len = (len < cslen) ? len : cslen; for(int i = 0; i < len; i++) { cs = cs ^ data[i]; } return cs; } // memory in iPhone is precious // Should buffer factor be 1.5 instead of 2 ? #define BUFFER_INC_FACTOR (2) int ZipUtils::inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t *outLength, ssize_t outLenghtHint) { /* ret value */ int err = Z_OK; ssize_t bufferSize = outLenghtHint; *out = (unsigned char*)malloc(bufferSize); z_stream d_stream; /* decompression stream */ d_stream.zalloc = (alloc_func)0; d_stream.zfree = (free_func)0; d_stream.opaque = (voidpf)0; d_stream.next_in = in; d_stream.avail_in = static_cast(inLength); d_stream.next_out = *out; d_stream.avail_out = static_cast(bufferSize); /* window size to hold 256k */ if( (err = inflateInit2(&d_stream, 15 + 32)) != Z_OK ) return err; for (;;) { err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) { break; } switch (err) { case Z_NEED_DICT: err = Z_DATA_ERROR; case Z_DATA_ERROR: case Z_MEM_ERROR: inflateEnd(&d_stream); return err; } // not enough memory ? if (err != Z_STREAM_END) { *out = (unsigned char*)realloc(*out, bufferSize * BUFFER_INC_FACTOR); /* not enough memory, ouch */ if (! *out ) { CCLOG("cocos2d: ZipUtils: realloc failed"); inflateEnd(&d_stream); return Z_MEM_ERROR; } d_stream.next_out = *out + bufferSize; d_stream.avail_out = static_cast(bufferSize); bufferSize *= BUFFER_INC_FACTOR; } } *outLength = bufferSize - d_stream.avail_out; err = inflateEnd(&d_stream); return err; } ssize_t ZipUtils::inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint) { ssize_t outLength = 0; int err = inflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint); if (err != Z_OK || *out == nullptr) { if (err == Z_MEM_ERROR) { CCLOG("cocos2d: ZipUtils: Out of memory while decompressing map data!"); } else if (err == Z_VERSION_ERROR) { CCLOG("cocos2d: ZipUtils: Incompatible zlib version!"); } else if (err == Z_DATA_ERROR) { CCLOG("cocos2d: ZipUtils: Incorrect zlib compressed data!"); } else { CCLOG("cocos2d: ZipUtils: Unknown error while decompressing map data!"); } if(*out) { free(*out); *out = nullptr; } outLength = 0; } return outLength; } ssize_t ZipUtils::inflateMemory(unsigned char *in, ssize_t inLength, unsigned char **out) { // 256k for hint return inflateMemoryWithHint(in, inLength, out, 256 * 1024); } int ZipUtils::inflateGZipFile(const char *path, unsigned char **out) { int len; unsigned int offset = 0; CCASSERT(out, ""); CCASSERT(&*out, ""); gzFile inFile = gzopen(path, "rb"); if( inFile == nullptr ) { CCLOG("cocos2d: ZipUtils: error open gzip file: %s", path); return -1; } /* 512k initial decompress buffer */ unsigned int bufferSize = 512 * 1024; unsigned int totalBufferSize = bufferSize; *out = (unsigned char*)malloc( bufferSize ); if( ! out ) { CCLOG("cocos2d: ZipUtils: out of memory"); return -1; } for (;;) { len = gzread(inFile, *out + offset, bufferSize); if (len < 0) { CCLOG("cocos2d: ZipUtils: error in gzread"); free( *out ); *out = nullptr; return -1; } if (len == 0) { break; } offset += len; // finish reading the file if( (unsigned int)len < bufferSize ) { break; } bufferSize *= BUFFER_INC_FACTOR; totalBufferSize += bufferSize; unsigned char *tmp = (unsigned char*)realloc(*out, totalBufferSize ); if( ! tmp ) { CCLOG("cocos2d: ZipUtils: out of memory"); free( *out ); *out = nullptr; return -1; } *out = tmp; } if (gzclose(inFile) != Z_OK) { CCLOG("cocos2d: ZipUtils: gzclose failed"); } return offset; } bool ZipUtils::isCCZFile(const char *path) { // load file into memory Data compressedData = FileUtils::getInstance()->getDataFromFile(path); if (compressedData.isNull()) { CCLOG("cocos2d: ZipUtils: loading file failed"); return false; } return isCCZBuffer(compressedData.getBytes(), compressedData.getSize()); } bool ZipUtils::isCCZBuffer(const unsigned char *buffer, ssize_t len) { if (static_cast(len) < sizeof(struct CCZHeader)) { return false; } struct CCZHeader *header = (struct CCZHeader*) buffer; return header->sig[0] == 'C' && header->sig[1] == 'C' && header->sig[2] == 'Z' && (header->sig[3] == '!' || header->sig[3] == 'p'); } bool ZipUtils::isGZipFile(const char *path) { // load file into memory Data compressedData = FileUtils::getInstance()->getDataFromFile(path); if (compressedData.isNull()) { CCLOG("cocos2d: ZipUtils: loading file failed"); return false; } return isGZipBuffer(compressedData.getBytes(), compressedData.getSize()); } bool ZipUtils::isGZipBuffer(const unsigned char *buffer, ssize_t len) { if (len < 2) { return false; } return buffer[0] == 0x1F && buffer[1] == 0x8B; } int ZipUtils::inflateCCZBuffer(const unsigned char *buffer, ssize_t bufferLen, unsigned char **out) { struct CCZHeader *header = (struct CCZHeader*) buffer; // verify header if( header->sig[0] == 'C' && header->sig[1] == 'C' && header->sig[2] == 'Z' && header->sig[3] == '!' ) { // verify header version unsigned int version = CC_SWAP_INT16_BIG_TO_HOST( header->version ); if( version > 2 ) { CCLOG("cocos2d: Unsupported CCZ header format"); return -1; } // verify compression format if( CC_SWAP_INT16_BIG_TO_HOST(header->compression_type) != CCZ_COMPRESSION_ZLIB ) { CCLOG("cocos2d: CCZ Unsupported compression method"); return -1; } } else if( header->sig[0] == 'C' && header->sig[1] == 'C' && header->sig[2] == 'Z' && header->sig[3] == 'p' ) { // encrypted ccz file header = (struct CCZHeader*) buffer; // verify header version unsigned int version = CC_SWAP_INT16_BIG_TO_HOST( header->version ); if( version > 0 ) { CCLOG("cocos2d: Unsupported CCZ header format"); return -1; } // verify compression format if( CC_SWAP_INT16_BIG_TO_HOST(header->compression_type) != CCZ_COMPRESSION_ZLIB ) { CCLOG("cocos2d: CCZ Unsupported compression method"); return -1; } // decrypt unsigned int* ints = (unsigned int*)(buffer+12); ssize_t enclen = (bufferLen-12)/4; decodeEncodedPvr(ints, enclen); #if COCOS2D_DEBUG > 0 // verify checksum in debug mode unsigned int calculated = checksumPvr(ints, enclen); unsigned int required = CC_SWAP_INT32_BIG_TO_HOST( header->reserved ); if(calculated != required) { CCLOG("cocos2d: Can't decrypt image file. Is the decryption key valid?"); return -1; } #endif } else { CCLOG("cocos2d: Invalid CCZ file"); return -1; } unsigned int len = CC_SWAP_INT32_BIG_TO_HOST( header->len ); *out = (unsigned char*)malloc( len ); if(! *out ) { CCLOG("cocos2d: CCZ: Failed to allocate memory for texture"); return -1; } unsigned long destlen = len; size_t source = (size_t) buffer + sizeof(*header); int ret = uncompress(*out, &destlen, (Bytef*)source, bufferLen - sizeof(*header) ); if( ret != Z_OK ) { CCLOG("cocos2d: CCZ: Failed to uncompress data"); free( *out ); *out = nullptr; return -1; } return len; } int ZipUtils::inflateCCZFile(const char *path, unsigned char **out) { CCASSERT(out, "Invalid pointer for buffer!"); // load file into memory Data compressedData = FileUtils::getInstance()->getDataFromFile(path); if (compressedData.isNull()) { CCLOG("cocos2d: Error loading CCZ compressed file"); return -1; } return inflateCCZBuffer(compressedData.getBytes(), compressedData.getSize(), out); } void ZipUtils::setPvrEncryptionKeyPart(int index, unsigned int value) { CCASSERT(index >= 0, "Cocos2d: key part index cannot be less than 0"); CCASSERT(index <= 3, "Cocos2d: key part index cannot be greater than 3"); if(s_uEncryptedPvrKeyParts[index] != value) { s_uEncryptedPvrKeyParts[index] = value; s_bEncryptionKeyIsValid = false; } } void ZipUtils::setPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4) { setPvrEncryptionKeyPart(0, keyPart1); setPvrEncryptionKeyPart(1, keyPart2); setPvrEncryptionKeyPart(2, keyPart3); setPvrEncryptionKeyPart(3, keyPart4); } // --------------------- ZipFile --------------------- // from unzip.cpp #define UNZ_MAXFILENAMEINZIP 256 struct ZipEntryInfo { unz_file_pos pos; uLong uncompressed_size; }; class ZipFilePrivate { public: unzFile zipFile; // std::unordered_map is faster if available on the platform typedef std::unordered_map FileListContainer; FileListContainer fileList; }; ZipFile::ZipFile(const std::string &zipFile, const std::string &filter) : _data(new ZipFilePrivate) { _data->zipFile = unzOpen(zipFile.c_str()); setFilter(filter); } ZipFile::~ZipFile() { if (_data && _data->zipFile) { unzClose(_data->zipFile); } CC_SAFE_DELETE(_data); } bool ZipFile::setFilter(const std::string &filter) { bool ret = false; do { CC_BREAK_IF(!_data); CC_BREAK_IF(!_data->zipFile); // clear existing file list _data->fileList.clear(); // UNZ_MAXFILENAMEINZIP + 1 - it is done so in unzLocateFile char szCurrentFileName[UNZ_MAXFILENAMEINZIP + 1]; unz_file_info64 fileInfo; // go through all files and store position information about the required files int err = unzGoToFirstFile64(_data->zipFile, &fileInfo, szCurrentFileName, sizeof(szCurrentFileName) - 1); while (err == UNZ_OK) { unz_file_pos posInfo; int posErr = unzGetFilePos(_data->zipFile, &posInfo); if (posErr == UNZ_OK) { std::string currentFileName = szCurrentFileName; // cache info about filtered files only (like 'assets/') if (filter.empty() || currentFileName.substr(0, filter.length()) == filter) { ZipEntryInfo entry; entry.pos = posInfo; entry.uncompressed_size = (uLong)fileInfo.uncompressed_size; _data->fileList[currentFileName] = entry; } } // next file - also get the information about it err = unzGoToNextFile64(_data->zipFile, &fileInfo, szCurrentFileName, sizeof(szCurrentFileName) - 1); } ret = true; } while(false); return ret; } bool ZipFile::fileExists(const std::string &fileName) const { bool ret = false; do { CC_BREAK_IF(!_data); ret = _data->fileList.find(fileName) != _data->fileList.end(); } while(false); return ret; } unsigned char *ZipFile::getFileData(const std::string &fileName, ssize_t *size) { unsigned char * buffer = nullptr; if (size) *size = 0; do { CC_BREAK_IF(!_data->zipFile); CC_BREAK_IF(fileName.empty()); ZipFilePrivate::FileListContainer::const_iterator it = _data->fileList.find(fileName); CC_BREAK_IF(it == _data->fileList.end()); ZipEntryInfo fileInfo = it->second; int nRet = unzGoToFilePos(_data->zipFile, &fileInfo.pos); CC_BREAK_IF(UNZ_OK != nRet); nRet = unzOpenCurrentFile(_data->zipFile); CC_BREAK_IF(UNZ_OK != nRet); buffer = (unsigned char*)malloc(fileInfo.uncompressed_size); int CC_UNUSED nSize = unzReadCurrentFile(_data->zipFile, buffer, static_cast(fileInfo.uncompressed_size)); CCASSERT(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong"); if (size) { *size = fileInfo.uncompressed_size; } unzCloseCurrentFile(_data->zipFile); } while (0); return buffer; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/ZipUtils.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SUPPORT_ZIPUTILS_H__ #define __SUPPORT_ZIPUTILS_H__ #include #include "CCPlatformConfig.h" #include "CCPlatformDefine.h" #include "CCPlatformMacros.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/CCFileUtilsAndroid.h" #elif(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) // for import ssize_t on win32 platform #include "CCStdC.h" #endif namespace cocos2d { /* XXX: pragma pack ??? */ /** @struct CCZHeader */ struct CCZHeader { unsigned char sig[4]; // signature. Should be 'CCZ!' 4 bytes unsigned short compression_type; // should 0 unsigned short version; // should be 2 (although version type==1 is also supported) unsigned int reserved; // Reserved for users. unsigned int len; // size of the uncompressed file }; enum { CCZ_COMPRESSION_ZLIB, // zlib format. CCZ_COMPRESSION_BZIP2, // bzip2 format (not supported yet) CCZ_COMPRESSION_GZIP, // gzip format (not supported yet) CCZ_COMPRESSION_NONE, // plain (not supported yet) }; class CC_DLL ZipUtils { public: /** * Inflates either zlib or gzip deflated memory. The inflated memory is * expected to be freed by the caller. * * It will allocate 256k for the destination buffer. If it is not enough it will multiply the previous buffer size per 2, until there is enough memory. * @returns the length of the deflated buffer * @since v0.8.1 */ CC_DEPRECATED_ATTRIBUTE static ssize_t ccInflateMemory(unsigned char *in, ssize_t inLength, unsigned char **out) { return inflateMemory(in, inLength, out); } static ssize_t inflateMemory(unsigned char *in, ssize_t inLength, unsigned char **out); /** * Inflates either zlib or gzip deflated memory. The inflated memory is * expected to be freed by the caller. * * outLenghtHint is assumed to be the needed room to allocate the inflated buffer. * * @returns the length of the deflated buffer * @since v1.0.0 */ CC_DEPRECATED_ATTRIBUTE static ssize_t ccInflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint) { return inflateMemoryWithHint(in, inLength, out, outLengthHint); } static ssize_t inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint); /** inflates a GZip file into memory * * @returns the length of the deflated buffer * * @since v0.99.5 */ CC_DEPRECATED_ATTRIBUTE static int ccInflateGZipFile(const char *filename, unsigned char **out) { return inflateGZipFile(filename, out); } static int inflateGZipFile(const char *filename, unsigned char **out); /** test a file is a GZip format file or not * * @returns true is a GZip format file. false is not * * @since v3.0 */ CC_DEPRECATED_ATTRIBUTE static bool ccIsGZipFile(const char *filename) { return isGZipFile(filename); } static bool isGZipFile(const char *filename); /** test the buffer is GZip format or not * * @returns true is GZip format. false is not * * @since v3.0 */ CC_DEPRECATED_ATTRIBUTE static bool ccIsGZipBuffer(const unsigned char *buffer, ssize_t len) { return isGZipBuffer(buffer, len); } static bool isGZipBuffer(const unsigned char *buffer, ssize_t len); /** inflates a CCZ file into memory * * @returns the length of the deflated buffer * * @since v0.99.5 */ CC_DEPRECATED_ATTRIBUTE static int ccInflateCCZFile(const char *filename, unsigned char **out) { return inflateCCZFile(filename, out); } static int inflateCCZFile(const char *filename, unsigned char **out); /** inflates a buffer with CCZ format into memory * * @returns the length of the deflated buffer * * @since v3.0 */ CC_DEPRECATED_ATTRIBUTE static int ccInflateCCZBuffer(const unsigned char *buffer, ssize_t len, unsigned char **out) { return inflateCCZBuffer(buffer, len, out); } static int inflateCCZBuffer(const unsigned char *buffer, ssize_t len, unsigned char **out); /** test a file is a CCZ format file or not * * @returns true is a CCZ format file. false is not * * @since v3.0 */ CC_DEPRECATED_ATTRIBUTE static bool ccIsCCZFile(const char *filename) { return isCCZFile(filename); } static bool isCCZFile(const char *filename); /** test the buffer is CCZ format or not * * @returns true is CCZ format. false is not * * @since v3.0 */ CC_DEPRECATED_ATTRIBUTE static bool ccIsCCZBuffer(const unsigned char *buffer, ssize_t len) { return isCCZBuffer(buffer, len); } static bool isCCZBuffer(const unsigned char *buffer, ssize_t len); /** Sets the pvr.ccz encryption key parts separately for added * security. * * Example: If the key used to encrypt the pvr.ccz file is * 0xaaaaaaaabbbbbbbbccccccccdddddddd you will call this function 4 * different times, preferably from 4 different source files, as follows * * ZipUtils::setPvrEncryptionKeyPart(0, 0xaaaaaaaa); * ZipUtils::setPvrEncryptionKeyPart(1, 0xbbbbbbbb); * ZipUtils::setPvrEncryptionKeyPart(2, 0xcccccccc); * ZipUtils::setPvrEncryptionKeyPart(3, 0xdddddddd); * * Splitting the key into 4 parts and calling the function * from 4 different source files increases the difficulty to * reverse engineer the encryption key. Be aware that encrpytion * is *never* 100% secure and the key code can be cracked by * knowledgable persons. * * IMPORTANT: Be sure to call setPvrEncryptionKey or * setPvrEncryptionKeyPart with all of the key parts *before* loading * the spritesheet or decryption will fail and the spritesheet * will fail to load. * * @param index part of the key [0..3] * @param value value of the key part */ CC_DEPRECATED_ATTRIBUTE static void ccSetPvrEncryptionKeyPart(int index, unsigned int value) { setPvrEncryptionKeyPart(index, value); } static void setPvrEncryptionKeyPart(int index, unsigned int value); /** Sets the pvr.ccz encryption key. * * Example: If the key used to encrypt the pvr.ccz file is * 0xaaaaaaaabbbbbbbbccccccccdddddddd you will call this function with * the key split into 4 parts as follows * * ZipUtils::setPvrEncryptionKey(0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd); * * Note that using this function makes it easier to reverse engineer and * discover the complete key because the key parts are present in one * function call. * * IMPORTANT: Be sure to call setPvrEncryptionKey or * setPvrEncryptionKeyPart with all of the key parts *before* loading * the spritesheet or decryption will fail and the spritesheet * will fail to load. * * @param keyPart1 the key value part 1. * @param keyPart2 the key value part 2. * @param keyPart3 the key value part 3. * @param keyPart4 the key value part 4. */ CC_DEPRECATED_ATTRIBUTE static void ccSetPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4) { setPvrEncryptionKey(keyPart1, keyPart2, keyPart3, keyPart4); } static void setPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4); private: static int inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t *outLength, ssize_t outLenghtHint); static inline void decodeEncodedPvr (unsigned int *data, ssize_t len); static inline unsigned int checksumPvr(const unsigned int *data, ssize_t len); static unsigned int s_uEncryptedPvrKeyParts[4]; static unsigned int s_uEncryptionKey[1024]; static bool s_bEncryptionKeyIsValid; }; // forward declaration class ZipFilePrivate; /** * Zip file - reader helper class. * * It will cache the file list of a particular zip file with positions inside an archive, * so it would be much faster to read some particular files or to check their existance. * * @since v2.0.5 */ class ZipFile { public: /** * Constructor, open zip file and store file list. * * @param zipFile Zip file name * @param filter The first part of file names, which should be accessible. * For example, "assets/". Other files will be missed. * * @since v2.0.5 */ ZipFile(const std::string &zipFile, const std::string &filter = std::string()); virtual ~ZipFile(); /** * Regenerate accessible file list based on a new filter string. * * @param filter New filter string (first part of files names) * @return true whenever zip file is open successfully and it is possible to locate * at least the first file, false otherwise * * @since v2.0.5 */ bool setFilter(const std::string &filter); /** * Check does a file exists or not in zip file * * @param fileName File to be checked on existance * @return true whenever file exists, false otherwise * * @since v2.0.5 */ bool fileExists(const std::string &fileName) const; /** * Get resource file data from a zip file. * @param fileName File name * @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise nullptr. * @warning Recall: you are responsible for calling free() on any Non-nullptr pointer returned. * * @since v2.0.5 */ unsigned char *getFileData(const std::string &fileName, ssize_t *size); private: /** Internal data like zip file pointer / file list array and so on */ ZipFilePrivate *_data; }; } // end of namespace cocos2d #endif // __SUPPORT_ZIPUTILS_H__ ================================================ FILE: cocos2d/cocos/2d/base64.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include #include "base64.h" namespace cocos2d { unsigned char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int _base64Decode(const unsigned char *input, unsigned int input_len, unsigned char *output, unsigned int *output_len ) { static char inalphabet[256], decoder[256]; int i, bits, c = 0, char_count, errors = 0; unsigned int input_idx = 0; unsigned int output_idx = 0; for (i = (sizeof alphabet) - 1; i >= 0 ; i--) { inalphabet[alphabet[i]] = 1; decoder[alphabet[i]] = i; } char_count = 0; bits = 0; for( input_idx=0; input_idx < input_len ; input_idx++ ) { c = input[ input_idx ]; if (c == '=') break; if (c > 255 || ! inalphabet[c]) continue; bits += decoder[c]; char_count++; if (char_count == 4) { output[ output_idx++ ] = (bits >> 16); output[ output_idx++ ] = ((bits >> 8) & 0xff); output[ output_idx++ ] = ( bits & 0xff); bits = 0; char_count = 0; } else { bits <<= 6; } } if( c == '=' ) { switch (char_count) { case 1: #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) std::fprintf(stderr, "base64Decode: encoding incomplete: at least 2 bits missing"); #endif errors++; break; case 2: output[ output_idx++ ] = ( bits >> 10 ); break; case 3: output[ output_idx++ ] = ( bits >> 16 ); output[ output_idx++ ] = (( bits >> 8 ) & 0xff); break; } } else if ( input_idx < input_len ) { if (char_count) { #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) std::fprintf(stderr, "base64 encoding incomplete: at least %d bits truncated", ((4 - char_count) * 6)); #endif errors++; } } *output_len = output_idx; return errors; } void _base64Encode( const unsigned char *input, unsigned int input_len, char *output ) { unsigned int char_count; unsigned int bits; unsigned int input_idx = 0; unsigned int output_idx = 0; char_count = 0; bits = 0; for( input_idx=0; input_idx < input_len ; input_idx++ ) { bits |= input[ input_idx ]; char_count++; if (char_count == 3) { output[ output_idx++ ] = alphabet[(bits >> 18) & 0x3f]; output[ output_idx++ ] = alphabet[(bits >> 12) & 0x3f]; output[ output_idx++ ] = alphabet[(bits >> 6) & 0x3f]; output[ output_idx++ ] = alphabet[bits & 0x3f]; bits = 0; char_count = 0; } else { bits <<= 8; } } if (char_count) { if (char_count == 1) { bits <<= 8; } output[ output_idx++ ] = alphabet[(bits >> 18) & 0x3f]; output[ output_idx++ ] = alphabet[(bits >> 12) & 0x3f]; if (char_count > 1) { output[ output_idx++ ] = alphabet[(bits >> 6) & 0x3f]; } else { output[ output_idx++ ] = '='; } output[ output_idx++ ] = '='; } output[ output_idx++ ] = 0; } int base64Decode(const unsigned char *in, unsigned int inLength, unsigned char **out) { unsigned int outLength = 0; //should be enough to store 6-bit buffers in 8-bit buffers *out = (unsigned char*)malloc(inLength * 3.0f / 4.0f + 1); if( *out ) { int ret = _base64Decode(in, inLength, *out, &outLength); if (ret > 0 ) { #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) printf("Base64Utils: error decoding"); #endif free(*out); *out = nullptr; outLength = 0; } } return outLength; } int base64Encode(const unsigned char *in, unsigned int inLength, char **out) { unsigned int outLength = inLength * 4 / 3 + (inLength % 3 > 0 ? 4 : 0); //should be enough to store 8-bit buffers in 6-bit buffers *out = (char*)malloc(outLength+1); if( *out ) { _base64Encode(in, inLength, *out); } return outLength; } }//namespace cocos2d ================================================ FILE: cocos2d/cocos/2d/base64.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SUPPORT_BASE64_H__ #define __SUPPORT_BASE64_H__ #ifdef __cplusplus extern "C" { #endif namespace cocos2d { /** @file base64 helper functions */ /** * Decodes a 64base encoded memory. The decoded memory is * expected to be freed by the caller by calling `free()` * * @returns the length of the out buffer * @since v0.8.1 */ int base64Decode(const unsigned char *in, unsigned int inLength, unsigned char **out); /** * Encodes bytes into a 64base encoded memory with terminating '\0' character. * The encoded memory is expected to be freed by the caller by calling `free()` * * @returns the length of the out buffer * @since v2.1.4 */ int base64Encode(const unsigned char *in, unsigned int inLength, char **out); }//namespace cocos2d #ifdef __cplusplus } #endif #endif // __SUPPORT_BASE64_H__ ================================================ FILE: cocos2d/cocos/2d/ccCArray.cpp ================================================ /**************************************************************************** Copyright (c) 2007 Scott Lembcke Copyright (c) 2010-2012 cocos2d-x.org CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ccCArray.h" #include "CCObject.h" NS_CC_BEGIN const ssize_t CC_INVALID_INDEX = -1; /** Allocates and initializes a new array with specified capacity */ ccArray* ccArrayNew(ssize_t capacity) { if (capacity == 0) capacity = 7; ccArray *arr = (ccArray*)malloc( sizeof(ccArray) ); arr->num = 0; arr->arr = (Object**)calloc(capacity, sizeof(Object*)); arr->max = capacity; return arr; } /** Frees array after removing all remaining objects. Silently ignores nullptr arr. */ void ccArrayFree(ccArray*& arr) { if( arr == nullptr ) { return; } ccArrayRemoveAllObjects(arr); free(arr->arr); free(arr); arr = nullptr; } void ccArrayDoubleCapacity(ccArray *arr) { arr->max *= 2; Object** newArr = (Object**)realloc( arr->arr, arr->max * sizeof(Object*) ); // will fail when there's not enough memory CCASSERT(newArr != 0, "ccArrayDoubleCapacity failed. Not enough memory"); arr->arr = newArr; } void ccArrayEnsureExtraCapacity(ccArray *arr, ssize_t extra) { while (arr->max < arr->num + extra) { CCLOGINFO("cocos2d: ccCArray: resizing ccArray capacity from [%d] to [%d].", static_cast(arr->max), static_cast(arr->max*2)); ccArrayDoubleCapacity(arr); } } void ccArrayShrink(ccArray *arr) { ssize_t newSize = 0; //only resize when necessary if (arr->max > arr->num && !(arr->num==0 && arr->max==1)) { if (arr->num!=0) { newSize=arr->num; arr->max=arr->num; } else {//minimum capacity of 1, with 0 elements the array would be free'd by realloc newSize=1; arr->max=1; } arr->arr = (Object**)realloc(arr->arr,newSize * sizeof(Object*) ); CCASSERT(arr->arr!=nullptr,"could not reallocate the memory"); } } /** Returns index of first occurrence of object, CC_INVALID_INDEX if object not found. */ ssize_t ccArrayGetIndexOfObject(ccArray *arr, Object* object) { const auto arrNum = arr->num; Object** ptr = arr->arr; for (ssize_t i = 0; i < arrNum; ++i, ++ptr) { if (*ptr == object) return i; } return CC_INVALID_INDEX; } /** Returns a Boolean value that indicates whether object is present in array. */ bool ccArrayContainsObject(ccArray *arr, Object* object) { return ccArrayGetIndexOfObject(arr, object) != CC_INVALID_INDEX; } /** Appends an object. Behavior undefined if array doesn't have enough capacity. */ void ccArrayAppendObject(ccArray *arr, Object* object) { CCASSERT(object != nullptr, "Invalid parameter!"); object->retain(); arr->arr[arr->num] = object; arr->num++; } /** Appends an object. Capacity of arr is increased if needed. */ void ccArrayAppendObjectWithResize(ccArray *arr, Object* object) { ccArrayEnsureExtraCapacity(arr, 1); ccArrayAppendObject(arr, object); } /** Appends objects from plusArr to arr. Behavior undefined if arr doesn't have enough capacity. */ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) { for (ssize_t i = 0; i < plusArr->num; i++) { ccArrayAppendObject(arr, plusArr->arr[i]); } } /** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */ void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr) { ccArrayEnsureExtraCapacity(arr, plusArr->num); ccArrayAppendArray(arr, plusArr); } /** Inserts an object at index */ void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, ssize_t index) { CCASSERT(index<=arr->num, "Invalid index. Out of bounds"); CCASSERT(object != nullptr, "Invalid parameter!"); ccArrayEnsureExtraCapacity(arr, 1); ssize_t remaining = arr->num - index; if (remaining > 0) { memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(Object*) * remaining ); } object->retain(); arr->arr[index] = object; arr->num++; } /** Swaps two objects */ void ccArraySwapObjectsAtIndexes(ccArray *arr, ssize_t index1, ssize_t index2) { CCASSERT(index1>=0 && index1 < arr->num, "(1) Invalid index. Out of bounds"); CCASSERT(index2>=0 && index2 < arr->num, "(2) Invalid index. Out of bounds"); Object* object1 = arr->arr[index1]; arr->arr[index1] = arr->arr[index2]; arr->arr[index2] = object1; } /** Removes all objects from arr */ void ccArrayRemoveAllObjects(ccArray *arr) { while (arr->num > 0) { (arr->arr[--arr->num])->release(); } } /** Removes object at specified index and pushes back all subsequent objects. Behavior undefined if index outside [0, num-1]. */ void ccArrayRemoveObjectAtIndex(ccArray *arr, ssize_t index, bool releaseObj/* = true*/) { CCASSERT(arr && arr->num > 0 && index>=0 && index < arr->num, "Invalid index. Out of bounds"); if (releaseObj) { CC_SAFE_RELEASE(arr->arr[index]); } arr->num--; ssize_t remaining = arr->num - index; if(remaining>0) { memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(Object*)); } } /** Removes object at specified index and fills the gap with the last object, thereby avoiding the need to push back subsequent objects. Behavior undefined if index outside [0, num-1]. */ void ccArrayFastRemoveObjectAtIndex(ccArray *arr, ssize_t index) { CC_SAFE_RELEASE(arr->arr[index]); auto last = --arr->num; arr->arr[index] = arr->arr[last]; } void ccArrayFastRemoveObject(ccArray *arr, Object* object) { auto index = ccArrayGetIndexOfObject(arr, object); if (index != CC_INVALID_INDEX) { ccArrayFastRemoveObjectAtIndex(arr, index); } } /** Searches for the first occurrence of object and removes it. If object is not found the function has no effect. */ void ccArrayRemoveObject(ccArray *arr, Object* object, bool releaseObj/* = true*/) { auto index = ccArrayGetIndexOfObject(arr, object); if (index != CC_INVALID_INDEX) { ccArrayRemoveObjectAtIndex(arr, index, releaseObj); } } /** Removes from arr all objects in minusArr. For each object in minusArr, the first matching instance in arr will be removed. */ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) { for (ssize_t i = 0; i < minusArr->num; i++) { ccArrayRemoveObject(arr, minusArr->arr[i]); } } /** Removes from arr all objects in minusArr. For each object in minusArr, all matching instances in arr will be removed. */ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) { ssize_t back = 0; for (ssize_t i = 0; i < arr->num; i++) { if (ccArrayContainsObject(minusArr, arr->arr[i])) { CC_SAFE_RELEASE(arr->arr[i]); back++; } else { arr->arr[i - back] = arr->arr[i]; } } arr->num -= back; } // #pragma mark - // #pragma mark ccCArray for Values (c structures) /** Allocates and initializes a new C array with specified capacity */ ccCArray* ccCArrayNew(ssize_t capacity) { if (capacity == 0) { capacity = 7; } ccCArray *arr = (ccCArray*)malloc(sizeof(ccCArray)); arr->num = 0; arr->arr = (void**)malloc(capacity * sizeof(void*)); arr->max = capacity; return arr; } /** Frees C array after removing all remaining values. Silently ignores nullptr arr. */ void ccCArrayFree(ccCArray *arr) { if (arr == nullptr) { return; } ccCArrayRemoveAllValues(arr); free(arr->arr); free(arr); } /** Doubles C array capacity */ void ccCArrayDoubleCapacity(ccCArray *arr) { ccArrayDoubleCapacity((ccArray*)arr); } /** Increases array capacity such that max >= num + extra. */ void ccCArrayEnsureExtraCapacity(ccCArray *arr, ssize_t extra) { ccArrayEnsureExtraCapacity((ccArray*)arr,extra); } /** Returns index of first occurrence of value, CC_INVALID_INDEX if value not found. */ ssize_t ccCArrayGetIndexOfValue(ccCArray *arr, void* value) { for(ssize_t i = 0; i < arr->num; i++) { if( arr->arr[i] == value ) return i; } return CC_INVALID_INDEX; } /** Returns a Boolean value that indicates whether value is present in the C array. */ bool ccCArrayContainsValue(ccCArray *arr, void* value) { return ccCArrayGetIndexOfValue(arr, value) != CC_INVALID_INDEX; } /** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */ void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, ssize_t index) { CCASSERT( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); auto remaining = arr->num - index; // make sure it has enough capacity if (arr->num + 1 == arr->max) { ccCArrayDoubleCapacity(arr); } // last Value doesn't need to be moved if( remaining > 0) { // tex coordinates memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(void*) * remaining ); } arr->num++; arr->arr[index] = value; } /** Appends an value. Behavior undefined if array doesn't have enough capacity. */ void ccCArrayAppendValue(ccCArray *arr, void* value) { arr->arr[arr->num] = value; arr->num++; // double the capacity for the next append action // if the num >= max if (arr->num >= arr->max) { ccCArrayDoubleCapacity(arr); } } /** Appends an value. Capacity of arr is increased if needed. */ void ccCArrayAppendValueWithResize(ccCArray *arr, void* value) { ccCArrayEnsureExtraCapacity(arr, 1); ccCArrayAppendValue(arr, value); } /** Appends values from plusArr to arr. Behavior undefined if arr doesn't have enough capacity. */ void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr) { for( ssize_t i = 0; i < plusArr->num; i++) { ccCArrayAppendValue(arr, plusArr->arr[i]); } } /** Appends values from plusArr to arr. Capacity of arr is increased if needed. */ void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr) { ccCArrayEnsureExtraCapacity(arr, plusArr->num); ccCArrayAppendArray(arr, plusArr); } /** Removes all values from arr */ void ccCArrayRemoveAllValues(ccCArray *arr) { arr->num = 0; } /** Removes value at specified index and pushes back all subsequent values. Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ void ccCArrayRemoveValueAtIndex(ccCArray *arr, ssize_t index) { for( ssize_t last = --arr->num; index < last; index++) { arr->arr[index] = arr->arr[index + 1]; } } /** Removes value at specified index and fills the gap with the last value, thereby avoiding the need to push back subsequent values. Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, ssize_t index) { ssize_t last = --arr->num; arr->arr[index] = arr->arr[last]; } /** Searches for the first occurrence of value and removes it. If value is not found the function has no effect. @since v0.99.4 */ void ccCArrayRemoveValue(ccCArray *arr, void* value) { auto index = ccCArrayGetIndexOfValue(arr, value); if (index != CC_INVALID_INDEX) { ccCArrayRemoveValueAtIndex(arr, index); } } /** Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. @since v0.99.4 */ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) { for(ssize_t i = 0; i < minusArr->num; i++) { ccCArrayRemoveValue(arr, minusArr->arr[i]); } } /** Removes from arr all values in minusArr. For each value in minusArr, all matching instances in arr will be removed. @since v0.99.4 */ void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr) { ssize_t back = 0; for(ssize_t i = 0; i < arr->num; i++) { if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) { back++; } else { arr->arr[i - back] = arr->arr[i]; } } arr->num -= back; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/ccCArray.h ================================================ /**************************************************************************** Copyright (c) 2007 Scott Lembcke Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ /** @file based on Chipmunk cpArray. ccArray is a faster alternative to NSMutableArray, it does pretty much the same thing (stores NSObjects and retains/releases them appropriately). It's faster because: - it uses a plain C interface so it doesn't incur Objective-c messaging overhead - it assumes you know what you're doing, so it doesn't spend time on safety checks (index out of bounds, required capacity etc.) - comparisons are done using pointer equality instead of isEqual There are 2 kind of functions: - ccArray functions that manipulates objective-c objects (retain and release are performed) - ccCArray functions that manipulates values like if they were standard C structures (no retain/release is performed) */ #ifndef CC_ARRAY_H #define CC_ARRAY_H #include "ccMacros.h" #include "CCObject.h" #include #include #include NS_CC_BEGIN extern const ssize_t CC_INVALID_INDEX; // Easy integration #define CCARRAYDATA_FOREACH(__array__, __object__) \ __object__=__array__->arr[0]; for(ssize_t i=0, num=__array__->num; iarr[i]) \ typedef struct _ccArray { ssize_t num, max; Object** arr; } ccArray; /** Allocates and initializes a new array with specified capacity */ ccArray* ccArrayNew(ssize_t capacity); /** Frees array after removing all remaining objects. Silently ignores nil arr. */ void ccArrayFree(ccArray*& arr); /** Doubles array capacity */ void ccArrayDoubleCapacity(ccArray *arr); /** Increases array capacity such that max >= num + extra. */ void ccArrayEnsureExtraCapacity(ccArray *arr, ssize_t extra); /** shrinks the array so the memory footprint corresponds with the number of items */ void ccArrayShrink(ccArray *arr); /** Returns index of first occurrence of object, NSNotFound if object not found. */ ssize_t ccArrayGetIndexOfObject(ccArray *arr, Object* object); /** Returns a Boolean value that indicates whether object is present in array. */ bool ccArrayContainsObject(ccArray *arr, Object* object); /** Appends an object. Behavior undefined if array doesn't have enough capacity. */ void ccArrayAppendObject(ccArray *arr, Object* object); /** Appends an object. Capacity of arr is increased if needed. */ void ccArrayAppendObjectWithResize(ccArray *arr, Object* object); /** Appends objects from plusArr to arr. Behavior undefined if arr doesn't have enough capacity. */ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr); /** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */ void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr); /** Inserts an object at index */ void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, ssize_t index); /** Swaps two objects */ void ccArraySwapObjectsAtIndexes(ccArray *arr, ssize_t index1, ssize_t index2); /** Removes all objects from arr */ void ccArrayRemoveAllObjects(ccArray *arr); /** Removes object at specified index and pushes back all subsequent objects. Behavior undefined if index outside [0, num-1]. */ void ccArrayRemoveObjectAtIndex(ccArray *arr, ssize_t index, bool releaseObj = true); /** Removes object at specified index and fills the gap with the last object, thereby avoiding the need to push back subsequent objects. Behavior undefined if index outside [0, num-1]. */ void ccArrayFastRemoveObjectAtIndex(ccArray *arr, ssize_t index); void ccArrayFastRemoveObject(ccArray *arr, Object* object); /** Searches for the first occurrence of object and removes it. If object is not found the function has no effect. */ void ccArrayRemoveObject(ccArray *arr, Object* object, bool releaseObj = true); /** Removes from arr all objects in minusArr. For each object in minusArr, the first matching instance in arr will be removed. */ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr); /** Removes from arr all objects in minusArr. For each object in minusArr, all matching instances in arr will be removed. */ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr); // #pragma mark - // #pragma mark ccCArray for Values (c structures) typedef struct _ccCArray { ssize_t num, max; void** arr; } ccCArray; /** Allocates and initializes a new C array with specified capacity */ ccCArray* ccCArrayNew(ssize_t capacity); /** Frees C array after removing all remaining values. Silently ignores nil arr. */ void ccCArrayFree(ccCArray *arr); /** Doubles C array capacity */ void ccCArrayDoubleCapacity(ccCArray *arr); /** Increases array capacity such that max >= num + extra. */ void ccCArrayEnsureExtraCapacity(ccCArray *arr, ssize_t extra); /** Returns index of first occurrence of value, NSNotFound if value not found. */ ssize_t ccCArrayGetIndexOfValue(ccCArray *arr, void* value); /** Returns a Boolean value that indicates whether value is present in the C array. */ bool ccCArrayContainsValue(ccCArray *arr, void* value); /** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */ void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, ssize_t index); /** Appends an value. Behavior undefined if array doesn't have enough capacity. */ void ccCArrayAppendValue(ccCArray *arr, void* value); /** Appends an value. Capacity of arr is increased if needed. */ void ccCArrayAppendValueWithResize(ccCArray *arr, void* value); /** Appends values from plusArr to arr. Behavior undefined if arr doesn't have enough capacity. */ void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr); /** Appends values from plusArr to arr. Capacity of arr is increased if needed. */ void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr); /** Removes all values from arr */ void ccCArrayRemoveAllValues(ccCArray *arr); /** Removes value at specified index and pushes back all subsequent values. Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ void ccCArrayRemoveValueAtIndex(ccCArray *arr, ssize_t index); /** Removes value at specified index and fills the gap with the last value, thereby avoiding the need to push back subsequent values. Behavior undefined if index outside [0, num-1]. @since v0.99.4 */ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, ssize_t index); /** Searches for the first occurrence of value and removes it. If value is not found the function has no effect. @since v0.99.4 */ void ccCArrayRemoveValue(ccCArray *arr, void* value); /** Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. @since v0.99.4 */ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr); /** Removes from arr all values in minusArr. For each value in minusArr, all matching instances in arr will be removed. @since v0.99.4 */ void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr); NS_CC_END #endif // CC_ARRAY_H ================================================ FILE: cocos2d/cocos/2d/ccConfig.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCCONFIG_H__ #define __CCCONFIG_H__ #include "CCPlatformConfig.h" /** @file cocos2d (cc) configuration file */ /** @def CC_ENABLE_STACKABLE_ACTIONS If enabled, actions that alter the position property (eg: MoveBy, JumpBy, BezierBy, etc..) will be stacked. If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions. If disabled, only the last run action will take effect. Enabled by default. Disable to be compatible with v2.0 and older versions. @since v2.1 */ #ifndef CC_ENABLE_STACKABLE_ACTIONS #define CC_ENABLE_STACKABLE_ACTIONS 1 #endif /** @def CC_ENABLE_GL_STATE_CACHE If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches. In order to use them, you have to use the following functions, instead of the the GL ones: - ccGLUseProgram() instead of glUseProgram() - GL::deleteProgram() instead of glDeleteProgram() - GL::blendFunc() instead of glBlendFunc() If this functionality is disabled, then ccGLUseProgram(), GL::deleteProgram(), GL::blendFunc() will call the GL ones, without using the cache. It is recommended to enable whenever possible to improve speed. If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on. Default value: Enabled by default @since v2.0.0 */ #ifndef CC_ENABLE_GL_STATE_CACHE #define CC_ENABLE_GL_STATE_CACHE 1 #endif /** @def CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL If enabled, the texture coordinates will be calculated by using this formula: - texCoord.left = (rect.origin.x*2+1) / (texture.wide*2); - texCoord.right = texCoord.left + (rect.size.width*2-2)/(texture.wide*2); The same for bottom and top. This formula prevents artifacts by using 99% of the texture. The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool. Affected nodes: - Sprite / SpriteBatchNode and subclasses: LabelBMFont, TMXTiledMap - LabelAtlas - QuadParticleSystem - TileMap To enabled set it to 1. Disabled by default. @since v0.99.5 */ #ifndef CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL #define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0 #endif /** @def CC_DIRECTOR_FPS_INTERVAL Seconds between FPS updates. 0.5 seconds, means that the FPS number will be updated every 0.5 seconds. Having a bigger number means a more reliable FPS Default value: 0.1f */ #ifndef CC_DIRECTOR_STATS_INTERVAL #define CC_DIRECTOR_STATS_INTERVAL (0.1f) #endif /** @def CC_DIRECTOR_FPS_POSITION Position of the FPS Default: 0,0 (bottom-left corner) */ #ifndef CC_DIRECTOR_FPS_POSITION #define CC_DIRECTOR_FPS_POSITION Point(0,0) #endif /** @def CC_DIRECTOR_DISPATCH_FAST_EVENTS If enabled, and only when it is used with FastDirector, the main loop will wait 0.04 seconds to dispatch all the events, even if there are not events to dispatch. If your game uses lot's of events (eg: touches) it might be a good idea to enable this feature. Otherwise, it is safe to leave it disabled. To enable set it to 1. Disabled by default. @warning This feature is experimental */ #ifndef CC_DIRECTOR_DISPATCH_FAST_EVENTS #define CC_DIRECTOR_DISPATCH_FAST_EVENTS 0 #endif /** @def CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD If enabled, cocos2d-mac will run on the Display Link thread. If disabled cocos2d-mac will run in its own thread. If enabled, the images will be drawn at the "correct" time, but the events might not be very responsive. If disabled, some frames might be skipped, but the events will be dispatched as they arrived. To enable set it to a 1, to disable it set to 0. Enabled by default. Only valid for cocos2d-mac. Not supported on cocos2d-ios. */ #ifndef CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD #define CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD 1 #endif /** @def CC_NODE_RENDER_SUBPIXEL If enabled, the Node objects (Sprite, Label,etc) will be able to render in subpixels. If disabled, integer pixels will be used. To enable set it to 1. Enabled by default. */ #ifndef CC_NODE_RENDER_SUBPIXEL #define CC_NODE_RENDER_SUBPIXEL 1 #endif /** @def CC_SPRITEBATCHNODE_RENDER_SUBPIXEL If enabled, the Sprite objects rendered with SpriteBatchNode will be able to render in subpixels. If disabled, integer pixels will be used. To enable set it to 1. Enabled by default. */ #ifndef CC_SPRITEBATCHNODE_RENDER_SUBPIXEL #define CC_SPRITEBATCHNODE_RENDER_SUBPIXEL 1 #endif /** @def CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas. It seems it is the recommend way, but it is much slower, so, enable it at your own risk To enable set it to a value different than 0. Disabled by default. */ #ifndef CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP #define CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP 0 #endif /** @def CC_TEXTURE_ATLAS_USE_VAO By default, TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects). Apple recommends its usage but they might consume a lot of memory, specially if you use many of them. So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it. To disable it set it to 0. Enabled by default. */ #ifndef CC_TEXTURE_ATLAS_USE_VAO #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #define CC_TEXTURE_ATLAS_USE_VAO 1 #else /* Some Windows display adapter driver cannot support VAO. */ /* Some android devices cannot support VAO very well, so we disable it by default for android platform. */ /* Blackberry also doesn't support this feature. */ #define CC_TEXTURE_ATLAS_USE_VAO 0 #endif #endif /** @def CC_USE_LA88_LABELS If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for LabelTTF objects. If it is disabled, it will use A8 (Alpha 8-bit textures). LA88 textures are 6% faster than A8 textures, but they will consume 2x memory. This feature is enabled by default. @since v0.99.5 */ #ifndef CC_USE_LA88_LABELS #define CC_USE_LA88_LABELS 1 #endif /** @def CC_SPRITE_DEBUG_DRAW If enabled, all subclasses of Sprite will draw a bounding box Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default: 0 -- disabled 1 -- draw bounding box 2 -- draw texture box 0 -- disabled 1 -- draw bounding box 2 -- draw texture box */ #ifndef CC_SPRITE_DEBUG_DRAW #define CC_SPRITE_DEBUG_DRAW 0 #endif /** @def CC_SPRITEBATCHNODE_DEBUG_DRAW If enabled, all subclasses of Sprite that are rendered using an SpriteBatchNode draw a bounding box. Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default. */ #ifndef CC_SPRITEBATCHNODE_DEBUG_DRAW #define CC_SPRITEBATCHNODE_DEBUG_DRAW 0 #endif /** @def CC_LABELBMFONT_DEBUG_DRAW If enabled, all subclasses of LabelBMFont will draw a bounding box Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default. */ #ifndef CC_LABELBMFONT_DEBUG_DRAW #define CC_LABELBMFONT_DEBUG_DRAW 0 #endif /** @def CC_LABELATLAS_DEBUG_DRAW If enabled, all subclasses of LabeltAtlas will draw a bounding box Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default. */ #ifndef CC_LABELATLAS_DEBUG_DRAW #define CC_LABELATLAS_DEBUG_DRAW 0 #endif /** @def CC_ENABLE_PROFILERS If enabled, will activate various profilers within cocos2d. This statistical data will be output to the console once per second showing average time (in milliseconds) required to execute the specific routine(s). Useful for debugging purposes only. It is recommended to leave it disabled. To enable set it to a value different than 0. Disabled by default. */ #ifndef CC_ENABLE_PROFILERS #define CC_ENABLE_PROFILERS 0 #endif /** Enable Lua engine debug log */ #ifndef CC_LUA_ENGINE_DEBUG #define CC_LUA_ENGINE_DEBUG 0 #endif /** Use physics integration API */ #ifndef CC_USE_PHYSICS #define CC_USE_PHYSICS 1 #endif #endif // __CCCONFIG_H__ ================================================ FILE: cocos2d/cocos/2d/ccFPSImages.c ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2012 Zynga Inc. * * 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 "ccFPSImages.h" unsigned char cc_fps_images_png[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x06, 0x00, 0x00, 0x00, 0xfd, 0xa9, 0xa6, 0xe4, 0x00, 0x00, 0x0a, 0x43, 0x69, 0x43, 0x43, 0x50, 0x49, 0x43, 0x43, 0x20, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x78, 0xda, 0x9d, 0x53, 0x77, 0x58, 0x93, 0xf7, 0x16, 0x3e, 0xdf, 0xf7, 0x65, 0x0f, 0x56, 0x42, 0xd8, 0xf0, 0xb1, 0x97, 0x6c, 0x81, 0x00, 0x22, 0x23, 0xac, 0x08, 0xc8, 0x10, 0x59, 0xa2, 0x10, 0x92, 0x00, 0x61, 0x84, 0x10, 0x12, 0x40, 0xc5, 0x85, 0x88, 0x0a, 0x56, 0x14, 0x15, 0x11, 0x9c, 0x48, 0x55, 0xc4, 0x82, 0xd5, 0x0a, 0x48, 0x9d, 0x88, 0xe2, 0xa0, 0x28, 0xb8, 0x67, 0x41, 0x8a, 0x88, 0x5a, 0x8b, 0x55, 0x5c, 0x38, 0xee, 0x1f, 0xdc, 0xa7, 0xb5, 0x7d, 0x7a, 0xef, 0xed, 0xed, 0xfb, 0xd7, 0xfb, 0xbc, 0xe7, 0x9c, 0xe7, 0xfc, 0xce, 0x79, 0xcf, 0x0f, 0x80, 0x11, 0x12, 0x26, 0x91, 0xe6, 0xa2, 0x6a, 0x00, 0x39, 0x52, 0x85, 0x3c, 0x3a, 0xd8, 0x1f, 0x8f, 0x4f, 0x48, 0xc4, 0xc9, 0xbd, 0x80, 0x02, 0x15, 0x48, 0xe0, 0x04, 0x20, 0x10, 0xe6, 0xcb, 0xc2, 0x67, 0x05, 0xc5, 0x00, 0x00, 0xf0, 0x03, 0x79, 0x78, 0x7e, 0x74, 0xb0, 0x3f, 0xfc, 0x01, 0xaf, 0x6f, 0x00, 0x02, 0x00, 0x70, 0xd5, 0x2e, 0x24, 0x12, 0xc7, 0xe1, 0xff, 0x83, 0xba, 0x50, 0x26, 0x57, 0x00, 0x20, 0x91, 0x00, 0xe0, 0x22, 0x12, 0xe7, 0x0b, 0x01, 0x90, 0x52, 0x00, 0xc8, 0x2e, 0x54, 0xc8, 0x14, 0x00, 0xc8, 0x18, 0x00, 0xb0, 0x53, 0xb3, 0x64, 0x0a, 0x00, 0x94, 0x00, 0x00, 0x6c, 0x79, 0x7c, 0x42, 0x22, 0x00, 0xaa, 0x0d, 0x00, 0xec, 0xf4, 0x49, 0x3e, 0x05, 0x00, 0xd8, 0xa9, 0x93, 0xdc, 0x17, 0x00, 0xd8, 0xa2, 0x1c, 0xa9, 0x08, 0x00, 0x8d, 0x01, 0x00, 0x99, 0x28, 0x47, 0x24, 0x02, 0x40, 0xbb, 0x00, 0x60, 0x55, 0x81, 0x52, 0x2c, 0x02, 0xc0, 0xc2, 0x00, 0xa0, 0xac, 0x40, 0x22, 0x2e, 0x04, 0xc0, 0xae, 0x01, 0x80, 0x59, 0xb6, 0x32, 0x47, 0x02, 0x80, 0xbd, 0x05, 0x00, 0x76, 0x8e, 0x58, 0x90, 0x0f, 0x40, 0x60, 0x00, 0x80, 0x99, 0x42, 0x2c, 0xcc, 0x00, 0x20, 0x38, 0x02, 0x00, 0x43, 0x1e, 0x13, 0xcd, 0x03, 0x20, 0x4c, 0x03, 0xa0, 0x30, 0xd2, 0xbf, 0xe0, 0xa9, 0x5f, 0x70, 0x85, 0xb8, 0x48, 0x01, 0x00, 0xc0, 0xcb, 0x95, 0xcd, 0x97, 0x4b, 0xd2, 0x33, 0x14, 0xb8, 0x95, 0xd0, 0x1a, 0x77, 0xf2, 0xf0, 0xe0, 0xe2, 0x21, 0xe2, 0xc2, 0x6c, 0xb1, 0x42, 0x61, 0x17, 0x29, 0x10, 0x66, 0x09, 0xe4, 0x22, 0x9c, 0x97, 0x9b, 0x23, 0x13, 0x48, 0xe7, 0x03, 0x4c, 0xce, 0x0c, 0x00, 0x00, 0x1a, 0xf9, 0xd1, 0xc1, 0xfe, 0x38, 0x3f, 0x90, 0xe7, 0xe6, 0xe4, 0xe1, 0xe6, 0x66, 0xe7, 0x6c, 0xef, 0xf4, 0xc5, 0xa2, 0xfe, 0x6b, 0xf0, 0x6f, 0x22, 0x3e, 0x21, 0xf1, 0xdf, 0xfe, 0xbc, 0x8c, 0x02, 0x04, 0x00, 0x10, 0x4e, 0xcf, 0xef, 0xda, 0x5f, 0xe5, 0xe5, 0xd6, 0x03, 0x70, 0xc7, 0x01, 0xb0, 0x75, 0xbf, 0x6b, 0xa9, 0x5b, 0x00, 0xda, 0x56, 0x00, 0x68, 0xdf, 0xf9, 0x5d, 0x33, 0xdb, 0x09, 0xa0, 0x5a, 0x0a, 0xd0, 0x7a, 0xf9, 0x8b, 0x79, 0x38, 0xfc, 0x40, 0x1e, 0x9e, 0xa1, 0x50, 0xc8, 0x3c, 0x1d, 0x1c, 0x0a, 0x0b, 0x0b, 0xed, 0x25, 0x62, 0xa1, 0xbd, 0x30, 0xe3, 0x8b, 0x3e, 0xff, 0x33, 0xe1, 0x6f, 0xe0, 0x8b, 0x7e, 0xf6, 0xfc, 0x40, 0x1e, 0xfe, 0xdb, 0x7a, 0xf0, 0x00, 0x71, 0x9a, 0x40, 0x99, 0xad, 0xc0, 0xa3, 0x83, 0xfd, 0x71, 0x61, 0x6e, 0x76, 0xae, 0x52, 0x8e, 0xe7, 0xcb, 0x04, 0x42, 0x31, 0x6e, 0xf7, 0xe7, 0x23, 0xfe, 0xc7, 0x85, 0x7f, 0xfd, 0x8e, 0x29, 0xd1, 0xe2, 0x34, 0xb1, 0x5c, 0x2c, 0x15, 0x8a, 0xf1, 0x58, 0x89, 0xb8, 0x50, 0x22, 0x4d, 0xc7, 0x79, 0xb9, 0x52, 0x91, 0x44, 0x21, 0xc9, 0x95, 0xe2, 0x12, 0xe9, 0x7f, 0x32, 0xf1, 0x1f, 0x96, 0xfd, 0x09, 0x93, 0x77, 0x0d, 0x00, 0xac, 0x86, 0x4f, 0xc0, 0x4e, 0xb6, 0x07, 0xb5, 0xcb, 0x6c, 0xc0, 0x7e, 0xee, 0x01, 0x02, 0x8b, 0x0e, 0x58, 0xd2, 0x76, 0x00, 0x40, 0x7e, 0xf3, 0x2d, 0x8c, 0x1a, 0x0b, 0x91, 0x00, 0x10, 0x67, 0x34, 0x32, 0x79, 0xf7, 0x00, 0x00, 0x93, 0xbf, 0xf9, 0x8f, 0x40, 0x2b, 0x01, 0x00, 0xcd, 0x97, 0xa4, 0xe3, 0x00, 0x00, 0xbc, 0xe8, 0x18, 0x5c, 0xa8, 0x94, 0x17, 0x4c, 0xc6, 0x08, 0x00, 0x00, 0x44, 0xa0, 0x81, 0x2a, 0xb0, 0x41, 0x07, 0x0c, 0xc1, 0x14, 0xac, 0xc0, 0x0e, 0x9c, 0xc1, 0x1d, 0xbc, 0xc0, 0x17, 0x02, 0x61, 0x06, 0x44, 0x40, 0x0c, 0x24, 0xc0, 0x3c, 0x10, 0x42, 0x06, 0xe4, 0x80, 0x1c, 0x0a, 0xa1, 0x18, 0x96, 0x41, 0x19, 0x54, 0xc0, 0x3a, 0xd8, 0x04, 0xb5, 0xb0, 0x03, 0x1a, 0xa0, 0x11, 0x9a, 0xe1, 0x10, 0xb4, 0xc1, 0x31, 0x38, 0x0d, 0xe7, 0xe0, 0x12, 0x5c, 0x81, 0xeb, 0x70, 0x17, 0x06, 0x60, 0x18, 0x9e, 0xc2, 0x18, 0xbc, 0x86, 0x09, 0x04, 0x41, 0xc8, 0x08, 0x13, 0x61, 0x21, 0x3a, 0x88, 0x11, 0x62, 0x8e, 0xd8, 0x22, 0xce, 0x08, 0x17, 0x99, 0x8e, 0x04, 0x22, 0x61, 0x48, 0x34, 0x92, 0x80, 0xa4, 0x20, 0xe9, 0x88, 0x14, 0x51, 0x22, 0xc5, 0xc8, 0x72, 0xa4, 0x02, 0xa9, 0x42, 0x6a, 0x91, 0x5d, 0x48, 0x23, 0xf2, 0x2d, 0x72, 0x14, 0x39, 0x8d, 0x5c, 0x40, 0xfa, 0x90, 0xdb, 0xc8, 0x20, 0x32, 0x8a, 0xfc, 0x8a, 0xbc, 0x47, 0x31, 0x94, 0x81, 0xb2, 0x51, 0x03, 0xd4, 0x02, 0x75, 0x40, 0xb9, 0xa8, 0x1f, 0x1a, 0x8a, 0xc6, 0xa0, 0x73, 0xd1, 0x74, 0x34, 0x0f, 0x5d, 0x80, 0x96, 0xa2, 0x6b, 0xd1, 0x1a, 0xb4, 0x1e, 0x3d, 0x80, 0xb6, 0xa2, 0xa7, 0xd1, 0x4b, 0xe8, 0x75, 0x74, 0x00, 0x7d, 0x8a, 0x8e, 0x63, 0x80, 0xd1, 0x31, 0x0e, 0x66, 0x8c, 0xd9, 0x61, 0x5c, 0x8c, 0x87, 0x45, 0x60, 0x89, 0x58, 0x1a, 0x26, 0xc7, 0x16, 0x63, 0xe5, 0x58, 0x35, 0x56, 0x8f, 0x35, 0x63, 0x1d, 0x58, 0x37, 0x76, 0x15, 0x1b, 0xc0, 0x9e, 0x61, 0xef, 0x08, 0x24, 0x02, 0x8b, 0x80, 0x13, 0xec, 0x08, 0x5e, 0x84, 0x10, 0xc2, 0x6c, 0x82, 0x90, 0x90, 0x47, 0x58, 0x4c, 0x58, 0x43, 0xa8, 0x25, 0xec, 0x23, 0xb4, 0x12, 0xba, 0x08, 0x57, 0x09, 0x83, 0x84, 0x31, 0xc2, 0x27, 0x22, 0x93, 0xa8, 0x4f, 0xb4, 0x25, 0x7a, 0x12, 0xf9, 0xc4, 0x78, 0x62, 0x3a, 0xb1, 0x90, 0x58, 0x46, 0xac, 0x26, 0xee, 0x21, 0x1e, 0x21, 0x9e, 0x25, 0x5e, 0x27, 0x0e, 0x13, 0x5f, 0x93, 0x48, 0x24, 0x0e, 0xc9, 0x92, 0xe4, 0x4e, 0x0a, 0x21, 0x25, 0x90, 0x32, 0x49, 0x0b, 0x49, 0x6b, 0x48, 0xdb, 0x48, 0x2d, 0xa4, 0x53, 0xa4, 0x3e, 0xd2, 0x10, 0x69, 0x9c, 0x4c, 0x26, 0xeb, 0x90, 0x6d, 0xc9, 0xde, 0xe4, 0x08, 0xb2, 0x80, 0xac, 0x20, 0x97, 0x91, 0xb7, 0x90, 0x0f, 0x90, 0x4f, 0x92, 0xfb, 0xc9, 0xc3, 0xe4, 0xb7, 0x14, 0x3a, 0xc5, 0x88, 0xe2, 0x4c, 0x09, 0xa2, 0x24, 0x52, 0xa4, 0x94, 0x12, 0x4a, 0x35, 0x65, 0x3f, 0xe5, 0x04, 0xa5, 0x9f, 0x32, 0x42, 0x99, 0xa0, 0xaa, 0x51, 0xcd, 0xa9, 0x9e, 0xd4, 0x08, 0xaa, 0x88, 0x3a, 0x9f, 0x5a, 0x49, 0x6d, 0xa0, 0x76, 0x50, 0x2f, 0x53, 0x87, 0xa9, 0x13, 0x34, 0x75, 0x9a, 0x25, 0xcd, 0x9b, 0x16, 0x43, 0xcb, 0xa4, 0x2d, 0xa3, 0xd5, 0xd0, 0x9a, 0x69, 0x67, 0x69, 0xf7, 0x68, 0x2f, 0xe9, 0x74, 0xba, 0x09, 0xdd, 0x83, 0x1e, 0x45, 0x97, 0xd0, 0x97, 0xd2, 0x6b, 0xe8, 0x07, 0xe9, 0xe7, 0xe9, 0x83, 0xf4, 0x77, 0x0c, 0x0d, 0x86, 0x0d, 0x83, 0xc7, 0x48, 0x62, 0x28, 0x19, 0x6b, 0x19, 0x7b, 0x19, 0xa7, 0x18, 0xb7, 0x19, 0x2f, 0x99, 0x4c, 0xa6, 0x05, 0xd3, 0x97, 0x99, 0xc8, 0x54, 0x30, 0xd7, 0x32, 0x1b, 0x99, 0x67, 0x98, 0x0f, 0x98, 0x6f, 0x55, 0x58, 0x2a, 0xf6, 0x2a, 0x7c, 0x15, 0x91, 0xca, 0x12, 0x95, 0x3a, 0x95, 0x56, 0x95, 0x7e, 0x95, 0xe7, 0xaa, 0x54, 0x55, 0x73, 0x55, 0x3f, 0xd5, 0x79, 0xaa, 0x0b, 0x54, 0xab, 0x55, 0x0f, 0xab, 0x5e, 0x56, 0x7d, 0xa6, 0x46, 0x55, 0xb3, 0x50, 0xe3, 0xa9, 0x09, 0xd4, 0x16, 0xab, 0xd5, 0xa9, 0x1d, 0x55, 0xbb, 0xa9, 0x36, 0xae, 0xce, 0x52, 0x77, 0x52, 0x8f, 0x50, 0xcf, 0x51, 0x5f, 0xa3, 0xbe, 0x5f, 0xfd, 0x82, 0xfa, 0x63, 0x0d, 0xb2, 0x86, 0x85, 0x46, 0xa0, 0x86, 0x48, 0xa3, 0x54, 0x63, 0xb7, 0xc6, 0x19, 0x8d, 0x21, 0x16, 0xc6, 0x32, 0x65, 0xf1, 0x58, 0x42, 0xd6, 0x72, 0x56, 0x03, 0xeb, 0x2c, 0x6b, 0x98, 0x4d, 0x62, 0x5b, 0xb2, 0xf9, 0xec, 0x4c, 0x76, 0x05, 0xfb, 0x1b, 0x76, 0x2f, 0x7b, 0x4c, 0x53, 0x43, 0x73, 0xaa, 0x66, 0xac, 0x66, 0x91, 0x66, 0x9d, 0xe6, 0x71, 0xcd, 0x01, 0x0e, 0xc6, 0xb1, 0xe0, 0xf0, 0x39, 0xd9, 0x9c, 0x4a, 0xce, 0x21, 0xce, 0x0d, 0xce, 0x7b, 0x2d, 0x03, 0x2d, 0x3f, 0x2d, 0xb1, 0xd6, 0x6a, 0xad, 0x66, 0xad, 0x7e, 0xad, 0x37, 0xda, 0x7a, 0xda, 0xbe, 0xda, 0x62, 0xed, 0x72, 0xed, 0x16, 0xed, 0xeb, 0xda, 0xef, 0x75, 0x70, 0x9d, 0x40, 0x9d, 0x2c, 0x9d, 0xf5, 0x3a, 0x6d, 0x3a, 0xf7, 0x75, 0x09, 0xba, 0x36, 0xba, 0x51, 0xba, 0x85, 0xba, 0xdb, 0x75, 0xcf, 0xea, 0x3e, 0xd3, 0x63, 0xeb, 0x79, 0xe9, 0x09, 0xf5, 0xca, 0xf5, 0x0e, 0xe9, 0xdd, 0xd1, 0x47, 0xf5, 0x6d, 0xf4, 0xa3, 0xf5, 0x17, 0xea, 0xef, 0xd6, 0xef, 0xd1, 0x1f, 0x37, 0x30, 0x34, 0x08, 0x36, 0x90, 0x19, 0x6c, 0x31, 0x38, 0x63, 0xf0, 0xcc, 0x90, 0x63, 0xe8, 0x6b, 0x98, 0x69, 0xb8, 0xd1, 0xf0, 0x84, 0xe1, 0xa8, 0x11, 0xcb, 0x68, 0xba, 0x91, 0xc4, 0x68, 0xa3, 0xd1, 0x49, 0xa3, 0x27, 0xb8, 0x26, 0xee, 0x87, 0x67, 0xe3, 0x35, 0x78, 0x17, 0x3e, 0x66, 0xac, 0x6f, 0x1c, 0x62, 0xac, 0x34, 0xde, 0x65, 0xdc, 0x6b, 0x3c, 0x61, 0x62, 0x69, 0x32, 0xdb, 0xa4, 0xc4, 0xa4, 0xc5, 0xe4, 0xbe, 0x29, 0xcd, 0x94, 0x6b, 0x9a, 0x66, 0xba, 0xd1, 0xb4, 0xd3, 0x74, 0xcc, 0xcc, 0xc8, 0x2c, 0xdc, 0xac, 0xd8, 0xac, 0xc9, 0xec, 0x8e, 0x39, 0xd5, 0x9c, 0x6b, 0x9e, 0x61, 0xbe, 0xd9, 0xbc, 0xdb, 0xfc, 0x8d, 0x85, 0xa5, 0x45, 0x9c, 0xc5, 0x4a, 0x8b, 0x36, 0x8b, 0xc7, 0x96, 0xda, 0x96, 0x7c, 0xcb, 0x05, 0x96, 0x4d, 0x96, 0xf7, 0xac, 0x98, 0x56, 0x3e, 0x56, 0x79, 0x56, 0xf5, 0x56, 0xd7, 0xac, 0x49, 0xd6, 0x5c, 0xeb, 0x2c, 0xeb, 0x6d, 0xd6, 0x57, 0x6c, 0x50, 0x1b, 0x57, 0x9b, 0x0c, 0x9b, 0x3a, 0x9b, 0xcb, 0xb6, 0xa8, 0xad, 0x9b, 0xad, 0xc4, 0x76, 0x9b, 0x6d, 0xdf, 0x14, 0xe2, 0x14, 0x8f, 0x29, 0xd2, 0x29, 0xf5, 0x53, 0x6e, 0xda, 0x31, 0xec, 0xfc, 0xec, 0x0a, 0xec, 0x9a, 0xec, 0x06, 0xed, 0x39, 0xf6, 0x61, 0xf6, 0x25, 0xf6, 0x6d, 0xf6, 0xcf, 0x1d, 0xcc, 0x1c, 0x12, 0x1d, 0xd6, 0x3b, 0x74, 0x3b, 0x7c, 0x72, 0x74, 0x75, 0xcc, 0x76, 0x6c, 0x70, 0xbc, 0xeb, 0xa4, 0xe1, 0x34, 0xc3, 0xa9, 0xc4, 0xa9, 0xc3, 0xe9, 0x57, 0x67, 0x1b, 0x67, 0xa1, 0x73, 0x9d, 0xf3, 0x35, 0x17, 0xa6, 0x4b, 0x90, 0xcb, 0x12, 0x97, 0x76, 0x97, 0x17, 0x53, 0x6d, 0xa7, 0x8a, 0xa7, 0x6e, 0x9f, 0x7a, 0xcb, 0x95, 0xe5, 0x1a, 0xee, 0xba, 0xd2, 0xb5, 0xd3, 0xf5, 0xa3, 0x9b, 0xbb, 0x9b, 0xdc, 0xad, 0xd9, 0x6d, 0xd4, 0xdd, 0xcc, 0x3d, 0xc5, 0x7d, 0xab, 0xfb, 0x4d, 0x2e, 0x9b, 0x1b, 0xc9, 0x5d, 0xc3, 0x3d, 0xef, 0x41, 0xf4, 0xf0, 0xf7, 0x58, 0xe2, 0x71, 0xcc, 0xe3, 0x9d, 0xa7, 0x9b, 0xa7, 0xc2, 0xf3, 0x90, 0xe7, 0x2f, 0x5e, 0x76, 0x5e, 0x59, 0x5e, 0xfb, 0xbd, 0x1e, 0x4f, 0xb3, 0x9c, 0x26, 0x9e, 0xd6, 0x30, 0x6d, 0xc8, 0xdb, 0xc4, 0x5b, 0xe0, 0xbd, 0xcb, 0x7b, 0x60, 0x3a, 0x3e, 0x3d, 0x65, 0xfa, 0xce, 0xe9, 0x03, 0x3e, 0xc6, 0x3e, 0x02, 0x9f, 0x7a, 0x9f, 0x87, 0xbe, 0xa6, 0xbe, 0x22, 0xdf, 0x3d, 0xbe, 0x23, 0x7e, 0xd6, 0x7e, 0x99, 0x7e, 0x07, 0xfc, 0x9e, 0xfb, 0x3b, 0xfa, 0xcb, 0xfd, 0x8f, 0xf8, 0xbf, 0xe1, 0x79, 0xf2, 0x16, 0xf1, 0x4e, 0x05, 0x60, 0x01, 0xc1, 0x01, 0xe5, 0x01, 0xbd, 0x81, 0x1a, 0x81, 0xb3, 0x03, 0x6b, 0x03, 0x1f, 0x04, 0x99, 0x04, 0xa5, 0x07, 0x35, 0x05, 0x8d, 0x05, 0xbb, 0x06, 0x2f, 0x0c, 0x3e, 0x15, 0x42, 0x0c, 0x09, 0x0d, 0x59, 0x1f, 0x72, 0x93, 0x6f, 0xc0, 0x17, 0xf2, 0x1b, 0xf9, 0x63, 0x33, 0xdc, 0x67, 0x2c, 0x9a, 0xd1, 0x15, 0xca, 0x08, 0x9d, 0x15, 0x5a, 0x1b, 0xfa, 0x30, 0xcc, 0x26, 0x4c, 0x1e, 0xd6, 0x11, 0x8e, 0x86, 0xcf, 0x08, 0xdf, 0x10, 0x7e, 0x6f, 0xa6, 0xf9, 0x4c, 0xe9, 0xcc, 0xb6, 0x08, 0x88, 0xe0, 0x47, 0x6c, 0x88, 0xb8, 0x1f, 0x69, 0x19, 0x99, 0x17, 0xf9, 0x7d, 0x14, 0x29, 0x2a, 0x32, 0xaa, 0x2e, 0xea, 0x51, 0xb4, 0x53, 0x74, 0x71, 0x74, 0xf7, 0x2c, 0xd6, 0xac, 0xe4, 0x59, 0xfb, 0x67, 0xbd, 0x8e, 0xf1, 0x8f, 0xa9, 0x8c, 0xb9, 0x3b, 0xdb, 0x6a, 0xb6, 0x72, 0x76, 0x67, 0xac, 0x6a, 0x6c, 0x52, 0x6c, 0x63, 0xec, 0x9b, 0xb8, 0x80, 0xb8, 0xaa, 0xb8, 0x81, 0x78, 0x87, 0xf8, 0x45, 0xf1, 0x97, 0x12, 0x74, 0x13, 0x24, 0x09, 0xed, 0x89, 0xe4, 0xc4, 0xd8, 0xc4, 0x3d, 0x89, 0xe3, 0x73, 0x02, 0xe7, 0x6c, 0x9a, 0x33, 0x9c, 0xe4, 0x9a, 0x54, 0x96, 0x74, 0x63, 0xae, 0xe5, 0xdc, 0xa2, 0xb9, 0x17, 0xe6, 0xe9, 0xce, 0xcb, 0x9e, 0x77, 0x3c, 0x59, 0x35, 0x59, 0x90, 0x7c, 0x38, 0x85, 0x98, 0x12, 0x97, 0xb2, 0x3f, 0xe5, 0x83, 0x20, 0x42, 0x50, 0x2f, 0x18, 0x4f, 0xe5, 0xa7, 0x6e, 0x4d, 0x1d, 0x13, 0xf2, 0x84, 0x9b, 0x85, 0x4f, 0x45, 0xbe, 0xa2, 0x8d, 0xa2, 0x51, 0xb1, 0xb7, 0xb8, 0x4a, 0x3c, 0x92, 0xe6, 0x9d, 0x56, 0x95, 0xf6, 0x38, 0xdd, 0x3b, 0x7d, 0x43, 0xfa, 0x68, 0x86, 0x4f, 0x46, 0x75, 0xc6, 0x33, 0x09, 0x4f, 0x52, 0x2b, 0x79, 0x91, 0x19, 0x92, 0xb9, 0x23, 0xf3, 0x4d, 0x56, 0x44, 0xd6, 0xde, 0xac, 0xcf, 0xd9, 0x71, 0xd9, 0x2d, 0x39, 0x94, 0x9c, 0x94, 0x9c, 0xa3, 0x52, 0x0d, 0x69, 0x96, 0xb4, 0x2b, 0xd7, 0x30, 0xb7, 0x28, 0xb7, 0x4f, 0x66, 0x2b, 0x2b, 0x93, 0x0d, 0xe4, 0x79, 0xe6, 0x6d, 0xca, 0x1b, 0x93, 0x87, 0xca, 0xf7, 0xe4, 0x23, 0xf9, 0x73, 0xf3, 0xdb, 0x15, 0x6c, 0x85, 0x4c, 0xd1, 0xa3, 0xb4, 0x52, 0xae, 0x50, 0x0e, 0x16, 0x4c, 0x2f, 0xa8, 0x2b, 0x78, 0x5b, 0x18, 0x5b, 0x78, 0xb8, 0x48, 0xbd, 0x48, 0x5a, 0xd4, 0x33, 0xdf, 0x66, 0xfe, 0xea, 0xf9, 0x23, 0x0b, 0x82, 0x16, 0x7c, 0xbd, 0x90, 0xb0, 0x50, 0xb8, 0xb0, 0xb3, 0xd8, 0xb8, 0x78, 0x59, 0xf1, 0xe0, 0x22, 0xbf, 0x45, 0xbb, 0x16, 0x23, 0x8b, 0x53, 0x17, 0x77, 0x2e, 0x31, 0x5d, 0x52, 0xba, 0x64, 0x78, 0x69, 0xf0, 0xd2, 0x7d, 0xcb, 0x68, 0xcb, 0xb2, 0x96, 0xfd, 0x50, 0xe2, 0x58, 0x52, 0x55, 0xf2, 0x6a, 0x79, 0xdc, 0xf2, 0x8e, 0x52, 0x83, 0xd2, 0xa5, 0xa5, 0x43, 0x2b, 0x82, 0x57, 0x34, 0x95, 0xa9, 0x94, 0xc9, 0xcb, 0x6e, 0xae, 0xf4, 0x5a, 0xb9, 0x63, 0x15, 0x61, 0x95, 0x64, 0x55, 0xef, 0x6a, 0x97, 0xd5, 0x5b, 0x56, 0x7f, 0x2a, 0x17, 0x95, 0x5f, 0xac, 0x70, 0xac, 0xa8, 0xae, 0xf8, 0xb0, 0x46, 0xb8, 0xe6, 0xe2, 0x57, 0x4e, 0x5f, 0xd5, 0x7c, 0xf5, 0x79, 0x6d, 0xda, 0xda, 0xde, 0x4a, 0xb7, 0xca, 0xed, 0xeb, 0x48, 0xeb, 0xa4, 0xeb, 0x6e, 0xac, 0xf7, 0x59, 0xbf, 0xaf, 0x4a, 0xbd, 0x6a, 0x41, 0xd5, 0xd0, 0x86, 0xf0, 0x0d, 0xad, 0x1b, 0xf1, 0x8d, 0xe5, 0x1b, 0x5f, 0x6d, 0x4a, 0xde, 0x74, 0xa1, 0x7a, 0x6a, 0xf5, 0x8e, 0xcd, 0xb4, 0xcd, 0xca, 0xcd, 0x03, 0x35, 0x61, 0x35, 0xed, 0x5b, 0xcc, 0xb6, 0xac, 0xdb, 0xf2, 0xa1, 0x36, 0xa3, 0xf6, 0x7a, 0x9d, 0x7f, 0x5d, 0xcb, 0x56, 0xfd, 0xad, 0xab, 0xb7, 0xbe, 0xd9, 0x26, 0xda, 0xd6, 0xbf, 0xdd, 0x77, 0x7b, 0xf3, 0x0e, 0x83, 0x1d, 0x15, 0x3b, 0xde, 0xef, 0x94, 0xec, 0xbc, 0xb5, 0x2b, 0x78, 0x57, 0x6b, 0xbd, 0x45, 0x7d, 0xf5, 0x6e, 0xd2, 0xee, 0x82, 0xdd, 0x8f, 0x1a, 0x62, 0x1b, 0xba, 0xbf, 0xe6, 0x7e, 0xdd, 0xb8, 0x47, 0x77, 0x4f, 0xc5, 0x9e, 0x8f, 0x7b, 0xa5, 0x7b, 0x07, 0xf6, 0x45, 0xef, 0xeb, 0x6a, 0x74, 0x6f, 0x6c, 0xdc, 0xaf, 0xbf, 0xbf, 0xb2, 0x09, 0x6d, 0x52, 0x36, 0x8d, 0x1e, 0x48, 0x3a, 0x70, 0xe5, 0x9b, 0x80, 0x6f, 0xda, 0x9b, 0xed, 0x9a, 0x77, 0xb5, 0x70, 0x5a, 0x2a, 0x0e, 0xc2, 0x41, 0xe5, 0xc1, 0x27, 0xdf, 0xa6, 0x7c, 0x7b, 0xe3, 0x50, 0xe8, 0xa1, 0xce, 0xc3, 0xdc, 0xc3, 0xcd, 0xdf, 0x99, 0x7f, 0xb7, 0xf5, 0x08, 0xeb, 0x48, 0x79, 0x2b, 0xd2, 0x3a, 0xbf, 0x75, 0xac, 0x2d, 0xa3, 0x6d, 0xa0, 0x3d, 0xa1, 0xbd, 0xef, 0xe8, 0x8c, 0xa3, 0x9d, 0x1d, 0x5e, 0x1d, 0x47, 0xbe, 0xb7, 0xff, 0x7e, 0xef, 0x31, 0xe3, 0x63, 0x75, 0xc7, 0x35, 0x8f, 0x57, 0x9e, 0xa0, 0x9d, 0x28, 0x3d, 0xf1, 0xf9, 0xe4, 0x82, 0x93, 0xe3, 0xa7, 0x64, 0xa7, 0x9e, 0x9d, 0x4e, 0x3f, 0x3d, 0xd4, 0x99, 0xdc, 0x79, 0xf7, 0x4c, 0xfc, 0x99, 0x6b, 0x5d, 0x51, 0x5d, 0xbd, 0x67, 0x43, 0xcf, 0x9e, 0x3f, 0x17, 0x74, 0xee, 0x4c, 0xb7, 0x5f, 0xf7, 0xc9, 0xf3, 0xde, 0xe7, 0x8f, 0x5d, 0xf0, 0xbc, 0x70, 0xf4, 0x22, 0xf7, 0x62, 0xdb, 0x25, 0xb7, 0x4b, 0xad, 0x3d, 0xae, 0x3d, 0x47, 0x7e, 0x70, 0xfd, 0xe1, 0x48, 0xaf, 0x5b, 0x6f, 0xeb, 0x65, 0xf7, 0xcb, 0xed, 0x57, 0x3c, 0xae, 0x74, 0xf4, 0x4d, 0xeb, 0x3b, 0xd1, 0xef, 0xd3, 0x7f, 0xfa, 0x6a, 0xc0, 0xd5, 0x73, 0xd7, 0xf8, 0xd7, 0x2e, 0x5d, 0x9f, 0x79, 0xbd, 0xef, 0xc6, 0xec, 0x1b, 0xb7, 0x6e, 0x26, 0xdd, 0x1c, 0xb8, 0x25, 0xba, 0xf5, 0xf8, 0x76, 0xf6, 0xed, 0x17, 0x77, 0x0a, 0xee, 0x4c, 0xdc, 0x5d, 0x7a, 0x8f, 0x78, 0xaf, 0xfc, 0xbe, 0xda, 0xfd, 0xea, 0x07, 0xfa, 0x0f, 0xea, 0x7f, 0xb4, 0xfe, 0xb1, 0x65, 0xc0, 0x6d, 0xe0, 0xf8, 0x60, 0xc0, 0x60, 0xcf, 0xc3, 0x59, 0x0f, 0xef, 0x0e, 0x09, 0x87, 0x9e, 0xfe, 0x94, 0xff, 0xd3, 0x87, 0xe1, 0xd2, 0x47, 0xcc, 0x47, 0xd5, 0x23, 0x46, 0x23, 0x8d, 0x8f, 0x9d, 0x1f, 0x1f, 0x1b, 0x0d, 0x1a, 0xbd, 0xf2, 0x64, 0xce, 0x93, 0xe1, 0xa7, 0xb2, 0xa7, 0x13, 0xcf, 0xca, 0x7e, 0x56, 0xff, 0x79, 0xeb, 0x73, 0xab, 0xe7, 0xdf, 0xfd, 0xe2, 0xfb, 0x4b, 0xcf, 0x58, 0xfc, 0xd8, 0xf0, 0x0b, 0xf9, 0x8b, 0xcf, 0xbf, 0xae, 0x79, 0xa9, 0xf3, 0x72, 0xef, 0xab, 0xa9, 0xaf, 0x3a, 0xc7, 0x23, 0xc7, 0x1f, 0xbc, 0xce, 0x79, 0x3d, 0xf1, 0xa6, 0xfc, 0xad, 0xce, 0xdb, 0x7d, 0xef, 0xb8, 0xef, 0xba, 0xdf, 0xc7, 0xbd, 0x1f, 0x99, 0x28, 0xfc, 0x40, 0xfe, 0x50, 0xf3, 0xd1, 0xfa, 0x63, 0xc7, 0xa7, 0xd0, 0x4f, 0xf7, 0x3e, 0xe7, 0x7c, 0xfe, 0xfc, 0x2f, 0xf7, 0x84, 0xf3, 0xfb, 0x80, 0x39, 0x25, 0x11, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45, 0x07, 0xdc, 0x02, 0x07, 0x10, 0x2f, 0x1c, 0x54, 0x04, 0xda, 0x7f, 0x00, 0x00, 0x10, 0x67, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0x9b, 0x7b, 0x74, 0x15, 0x55, 0x96, 0xc6, 0xbf, 0x53, 0x75, 0xef, 0xcd, 0xbd, 0x79, 0x12, 0xf2, 0x20, 0xa0, 0x04, 0x3a, 0x22, 0x12, 0x12, 0xd3, 0xe1, 0x25, 0x32, 0x40, 0x62, 0xec, 0x81, 0x0e, 0x68, 0x56, 0x8c, 0x01, 0x31, 0xe2, 0x20, 0x06, 0x06, 0x1c, 0x40, 0xe3, 0x00, 0x01, 0x6d, 0x50, 0x0c, 0x59, 0x40, 0x1e, 0xca, 0x43, 0x02, 0x33, 0xe1, 0xd1, 0x4d, 0xc0, 0x51, 0x5a, 0x43, 0x47, 0xda, 0x5e, 0x66, 0xa1, 0x2d, 0x0b, 0x08, 0x2a, 0xd0, 0x4e, 0x46, 0x1e, 0x41, 0x60, 0x50, 0x48, 0x20, 0x08, 0x81, 0x84, 0x57, 0x12, 0x92, 0x9b, 0x5b, 0xf5, 0xcd, 0x1f, 0x9c, 0xd2, 0xe2, 0x7a, 0x11, 0xed, 0xf6, 0x8f, 0x11, 0xeb, 0xb7, 0xd6, 0x5d, 0x21, 0xe1, 0xd4, 0xa9, 0xbd, 0xcf, 0xad, 0xfd, 0x9d, 0x7d, 0xf6, 0x39, 0x05, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xfc, 0x7f, 0x43, 0xfc, 0xc4, 0x7d, 0xa9, 0xf2, 0xa7, 0x2e, 0x3f, 0xf4, 0xd1, 0x4e, 0xf5, 0x6a, 0xa7, 0xc9, 0x9f, 0xdf, 0x87, 0x0a, 0x40, 0x91, 0xfd, 0x69, 0x37, 0xe9, 0xd7, 0x6c, 0x83, 0x22, 0x7f, 0xd7, 0x01, 0x78, 0x7e, 0x40, 0xdf, 0xaa, 0xa9, 0xbd, 0xfe, 0x03, 0xec, 0x51, 0xe4, 0xe7, 0x56, 0xbe, 0x9a, 0xdb, 0x19, 0x50, 0x7e, 0x7c, 0x5d, 0x23, 0xbc, 0xec, 0xd1, 0x6e, 0xe2, 0xaf, 0x30, 0xf5, 0xed, 0x8b, 0x5b, 0xd9, 0x64, 0xfb, 0x11, 0xe3, 0x6f, 0xfe, 0xbe, 0x28, 0xc7, 0x53, 0xb7, 0x42, 0xe7, 0xf6, 0x40, 0xfd, 0xa9, 0x82, 0xdf, 0x6e, 0xb7, 0x07, 0xe8, 0xba, 0xde, 0x05, 0x40, 0x4f, 0x00, 0x54, 0x14, 0xa5, 0x9d, 0xa4, 0x66, 0x7e, 0xf0, 0x14, 0x45, 0x09, 0x20, 0xd9, 0x19, 0x40, 0x6f, 0x00, 0x7d, 0x01, 0x38, 0x65, 0x5b, 0x92, 0xf4, 0x19, 0xa8, 0x8a, 0xa2, 0x38, 0x49, 0x86, 0x03, 0x88, 0x06, 0xa0, 0xda, 0xed, 0x76, 0x8f, 0xae, 0xeb, 0x1d, 0x3e, 0xda, 0xf9, 0x91, 0x0c, 0x05, 0xd0, 0x15, 0x40, 0x02, 0x80, 0x48, 0x00, 0x14, 0x42, 0x28, 0x37, 0x79, 0x68, 0x55, 0x21, 0x44, 0x30, 0x00, 0xc3, 0x9e, 0xde, 0x00, 0xec, 0x00, 0x84, 0xa2, 0x28, 0xba, 0x97, 0xed, 0xdf, 0x3a, 0x2a, 0x84, 0x1d, 0x40, 0xa8, 0xbc, 0x2e, 0x1c, 0x80, 0x6e, 0xb7, 0xdb, 0x85, 0xb7, 0x4d, 0xaa, 0xaa, 0xfa, 0x91, 0x0c, 0x94, 0x76, 0x74, 0x01, 0x10, 0x26, 0x3f, 0xc1, 0x00, 0xe8, 0xe7, 0xe7, 0xa7, 0x6a, 0x9a, 0x66, 0xbe, 0xc6, 0x26, 0x84, 0x08, 0x01, 0x10, 0x01, 0x60, 0x20, 0x80, 0xbb, 0x01, 0xe8, 0x0e, 0x87, 0x43, 0x68, 0x9a, 0x66, 0x08, 0x01, 0x84, 0x10, 0x2a, 0x80, 0x40, 0x00, 0x9d, 0x00, 0x74, 0x93, 0x36, 0x84, 0x99, 0x3e, 0x21, 0x00, 0x84, 0xd3, 0xe9, 0x54, 0x3c, 0x1e, 0x8f, 0xc7, 0x24, 0x02, 0x8a, 0x10, 0x22, 0x50, 0xb6, 0xbf, 0x0b, 0xc0, 0x3d, 0x72, 0xfc, 0x0d, 0x7f, 0xbd, 0xc7, 0x5f, 0x11, 0x42, 0x04, 0xc9, 0xf6, 0x7d, 0x01, 0xc4, 0x1b, 0x62, 0xf6, 0x7d, 0xe3, 0x63, 0xf1, 0xf3, 0xc2, 0xf6, 0x53, 0x09, 0x49, 0x47, 0x47, 0x47, 0xd0, 0x43, 0x0f, 0x3d, 0xb4, 0x63, 0xe6, 0xcc, 0x99, 0x3d, 0x47, 0x8d, 0x1a, 0xb5, 0xd1, 0xed, 0x76, 0xff, 0xeb, 0x8d, 0x71, 0x23, 0x02, 0x75, 0x5d, 0x8f, 0x4d, 0x49, 0x49, 0x59, 0x9b, 0x9d, 0x9d, 0x7d, 0x6f, 0x97, 0x2e, 0x5d, 0x70, 0xf2, 0xe4, 0x49, 0xcc, 0x9f, 0x3f, 0xff, 0xe3, 0x86, 0x86, 0x86, 0x09, 0xaa, 0xaa, 0x9e, 0xd5, 0x34, 0xad, 0xd5, 0x6b, 0x26, 0xf4, 0xd3, 0x75, 0x3d, 0x22, 0x2a, 0x2a, 0x6a, 0xf5, 0xda, 0xb5, 0x6b, 0x47, 0x95, 0x94, 0x94, 0x7c, 0xb5, 0x6d, 0xdb, 0xb6, 0x01, 0x00, 0xae, 0x99, 0x67, 0x37, 0x21, 0x84, 0x43, 0xd7, 0xf5, 0x30, 0x55, 0x55, 0xe7, 0x15, 0x14, 0x14, 0x4c, 0x8b, 0x8d, 0x8d, 0x45, 0x73, 0x73, 0x33, 0x76, 0xef, 0xde, 0xdd, 0x58, 0x52, 0x52, 0x92, 0xaf, 0x28, 0xca, 0x66, 0x5d, 0xd7, 0x9b, 0x00, 0x18, 0x01, 0x27, 0x14, 0x45, 0x09, 0xd6, 0x75, 0xfd, 0x9f, 0x32, 0x33, 0x33, 0x57, 0x67, 0x66, 0x66, 0x46, 0x87, 0x84, 0x84, 0xe0, 0xe4, 0xc9, 0x93, 0x98, 0x39, 0x73, 0xe6, 0x5f, 0xdb, 0xdb, 0xdb, 0xa7, 0xda, 0x6c, 0xb6, 0xb3, 0x1e, 0x8f, 0xa7, 0xd5, 0x3b, 0x28, 0x48, 0x86, 0x00, 0x18, 0x53, 0x58, 0x58, 0xf8, 0x1f, 0xa1, 0xa1, 0xa1, 0xa8, 0xa8, 0xa8, 0x38, 0x5d, 0x59, 0x59, 0x79, 0xaf, 0x97, 0x4d, 0x42, 0xd3, 0x34, 0x57, 0x42, 0x42, 0xc2, 0xc6, 0x89, 0x13, 0x27, 0x3e, 0xe4, 0x76, 0xbb, 0x75, 0x21, 0x04, 0xe5, 0x7d, 0x79, 0xe0, 0xc0, 0x01, 0x65, 0xd3, 0xa6, 0x4d, 0x3d, 0xe4, 0x35, 0x1e, 0xe9, 0x6b, 0x28, 0xc9, 0x11, 0x39, 0x39, 0x39, 0x6b, 0xd2, 0xd2, 0xd2, 0x02, 0xec, 0x76, 0x3b, 0xf6, 0xec, 0xd9, 0xc3, 0xb9, 0x73, 0xe7, 0xbe, 0xa6, 0x28, 0xca, 0x52, 0x92, 0x17, 0x48, 0x76, 0x90, 0x54, 0x01, 0xa4, 0xbc, 0xf2, 0xca, 0x2b, 0xef, 0xba, 0x5c, 0xae, 0x0e, 0x92, 0xc2, 0x4b, 0x08, 0x59, 0x57, 0x57, 0x67, 0x2f, 0x29, 0x29, 0x49, 0x04, 0x50, 0x23, 0x85, 0x4f, 0xb1, 0xd9, 0x6c, 0x21, 0x1e, 0x8f, 0x67, 0x50, 0x7a, 0x7a, 0xfa, 0xea, 0xcc, 0xcc, 0xcc, 0xbb, 0xc2, 0xc2, 0xc2, 0x50, 0x5f, 0x5f, 0x8f, 0x17, 0x5f, 0x7c, 0xf1, 0xe3, 0xc6, 0xc6, 0xc6, 0x89, 0x36, 0x9b, 0xed, 0x6b, 0x8f, 0xc7, 0xd3, 0x62, 0x12, 0xeb, 0x4e, 0xba, 0xae, 0x0f, 0xc8, 0xc8, 0xc8, 0xf8, 0xcf, 0xac, 0xac, 0xac, 0x98, 0xa8, 0xa8, 0x28, 0x1c, 0x3e, 0x7c, 0x18, 0x33, 0x66, 0xcc, 0xd8, 0xea, 0xf1, 0x78, 0x72, 0x54, 0x55, 0x3d, 0x6f, 0xfa, 0xbe, 0x2c, 0x7e, 0xe1, 0x04, 0x01, 0x18, 0xbb, 0x73, 0xe7, 0x4e, 0x56, 0x55, 0x55, 0x11, 0x40, 0x1a, 0x00, 0x97, 0xe9, 0xff, 0xed, 0x00, 0x7a, 0x0e, 0x1c, 0x38, 0xf0, 0x6b, 0x4a, 0x76, 0xee, 0xdc, 0x69, 0xfc, 0x93, 0xbd, 0x7b, 0xf7, 0xfe, 0x40, 0xce, 0xdc, 0x8a, 0x9c, 0x3d, 0x9d, 0xf2, 0xf7, 0x91, 0x00, 0x4a, 0xb7, 0x6c, 0xd9, 0x42, 0x92, 0x7c, 0xee, 0xb9, 0xe7, 0xea, 0x64, 0x26, 0xa0, 0x78, 0xa5, 0xc3, 0x61, 0x00, 0x0a, 0xcf, 0x9c, 0x39, 0x43, 0x92, 0xac, 0xaf, 0xaf, 0x67, 0x53, 0x53, 0x13, 0x49, 0xf2, 0xa3, 0x8f, 0x3e, 0x22, 0x80, 0x69, 0xc6, 0xcc, 0x28, 0x05, 0xc3, 0x09, 0xe0, 0xd7, 0x63, 0xc7, 0x8e, 0xf5, 0x90, 0xe4, 0xc5, 0x8b, 0x17, 0xb9, 0x77, 0xef, 0x5e, 0x92, 0xa4, 0xc7, 0xe3, 0x61, 0xff, 0xfe, 0xfd, 0x77, 0x03, 0x88, 0xf2, 0xce, 0x90, 0x14, 0x45, 0xf1, 0x07, 0xd0, 0x7f, 0xce, 0x9c, 0x39, 0xed, 0x86, 0xed, 0x73, 0xe6, 0xcc, 0x39, 0xe7, 0xc3, 0x26, 0x15, 0x40, 0x8f, 0x59, 0xb3, 0x66, 0x9d, 0xa3, 0x0f, 0xde, 0x7a, 0xeb, 0x2d, 0x9a, 0x32, 0x0e, 0x63, 0xfc, 0x1e, 0x5e, 0xbc, 0x78, 0x31, 0x49, 0xf2, 0xc8, 0x91, 0x23, 0xdf, 0xd8, 0x73, 0xec, 0xd8, 0x31, 0x02, 0x98, 0x29, 0xdb, 0x40, 0xce, 0xda, 0xd3, 0xae, 0x5d, 0xbb, 0xc6, 0x9b, 0x51, 0x5d, 0x5d, 0x4d, 0x00, 0xa3, 0x00, 0x38, 0x0c, 0x81, 0x04, 0x10, 0x3f, 0x63, 0xc6, 0x8c, 0x76, 0x92, 0xec, 0xe8, 0xe8, 0xe0, 0xc7, 0x1f, 0x7f, 0xfc, 0x4d, 0xfb, 0xfb, 0xef, 0xbf, 0xff, 0x6f, 0x72, 0xbc, 0x55, 0xe9, 0xa7, 0x0b, 0xc0, 0xc0, 0xc7, 0x1e, 0x7b, 0xcc, 0x63, 0xb4, 0x31, 0xec, 0xb9, 0x72, 0xe5, 0x0a, 0xa3, 0xa3, 0xa3, 0xff, 0xe2, 0x6b, 0x7c, 0x2c, 0x7e, 0x99, 0x28, 0x00, 0xba, 0x85, 0x86, 0x86, 0x6e, 0x21, 0xc9, 0x09, 0x13, 0x26, 0x9c, 0x92, 0x29, 0xa6, 0xdd, 0xd4, 0x26, 0x10, 0xc0, 0xd4, 0x9a, 0x9a, 0x1a, 0x92, 0x64, 0x48, 0x48, 0xc8, 0x61, 0x00, 0x73, 0x87, 0x0f, 0x1f, 0xde, 0x40, 0x92, 0x1b, 0x37, 0x6e, 0x24, 0x80, 0xa1, 0x32, 0x30, 0x01, 0xc0, 0x15, 0x13, 0x13, 0xb3, 0x65, 0xd7, 0xae, 0x5d, 0x6c, 0x69, 0x69, 0x21, 0x49, 0x9d, 0x24, 0xa7, 0x4f, 0x9f, 0x7e, 0x1a, 0xc0, 0xaf, 0x7c, 0x04, 0x5b, 0xf4, 0xbc, 0x79, 0xf3, 0xae, 0x90, 0xe4, 0x4b, 0x2f, 0xbd, 0xa4, 0x03, 0x58, 0x0a, 0x60, 0xc3, 0xd6, 0xad, 0x5b, 0x49, 0x92, 0x4f, 0x3d, 0xf5, 0xd4, 0x49, 0x00, 0x77, 0x98, 0xae, 0x0b, 0x04, 0xb0, 0x84, 0x24, 0x8f, 0x1f, 0x3f, 0x4e, 0x00, 0xef, 0x00, 0xf8, 0xdd, 0xe3, 0x8f, 0x3f, 0xde, 0x46, 0x92, 0x6f, 0xbc, 0xf1, 0x06, 0x65, 0x1a, 0xee, 0xf0, 0xba, 0xcf, 0x9d, 0xc1, 0xc1, 0xc1, 0x5b, 0x48, 0x72, 0xfd, 0xfa, 0xf5, 0x3a, 0x49, 0xce, 0x9a, 0x35, 0xeb, 0x3c, 0x80, 0x5e, 0x5e, 0xc1, 0x60, 0x07, 0xd0, 0xf7, 0xd5, 0x57, 0x5f, 0x25, 0x49, 0x02, 0xf8, 0x0c, 0xc0, 0x46, 0x21, 0xc4, 0x3a, 0x00, 0xab, 0x5c, 0x2e, 0x57, 0x81, 0x14, 0x2d, 0xa3, 0x5e, 0xd1, 0x6d, 0xf0, 0xe0, 0xc1, 0x7b, 0x48, 0xb2, 0xa2, 0xa2, 0x82, 0x00, 0x96, 0x01, 0xc8, 0x2f, 0x2a, 0x2a, 0x62, 0x43, 0x43, 0x03, 0xb3, 0xb2, 0xb2, 0xbe, 0x30, 0x09, 0xaa, 0xa3, 0x53, 0xa7, 0x4e, 0xf7, 0x87, 0x86, 0x86, 0xbe, 0x19, 0x19, 0x19, 0xf9, 0x76, 0x64, 0x64, 0xe4, 0x96, 0x88, 0x88, 0x88, 0xbf, 0x38, 0x1c, 0x8e, 0x4f, 0x66, 0xce, 0x9c, 0xa9, 0x91, 0x64, 0x66, 0x66, 0xe6, 0x69, 0x99, 0xb6, 0x1b, 0x19, 0x5e, 0x00, 0x80, 0xf9, 0xcd, 0xcd, 0xcd, 0x6c, 0x6b, 0x6b, 0x23, 0x80, 0xdd, 0x00, 0xe6, 0x24, 0x26, 0x26, 0xd6, 0x92, 0x64, 0x79, 0x79, 0x39, 0x01, 0xdc, 0x6f, 0xf2, 0xb7, 0xb3, 0xcd, 0x66, 0x5b, 0x4b, 0x92, 0x4d, 0x4d, 0x4d, 0x04, 0x50, 0x05, 0x60, 0x56, 0xdf, 0xbe, 0x7d, 0x4f, 0x93, 0xe4, 0xdb, 0x6f, 0xbf, 0x4d, 0x00, 0x0f, 0x08, 0x21, 0x5c, 0xd6, 0xe3, 0x6f, 0xe1, 0x07, 0x20, 0x3e, 0x3f, 0x3f, 0xdf, 0x2d, 0x1f, 0xf6, 0x65, 0x72, 0x1d, 0x6b, 0x4e, 0x4d, 0x23, 0xfc, 0xfd, 0xfd, 0x37, 0x91, 0xe4, 0x9e, 0x3d, 0x7b, 0x08, 0x60, 0xaa, 0x5c, 0x53, 0xae, 0xd2, 0x34, 0x8d, 0x8d, 0x8d, 0x8d, 0x04, 0x30, 0xdf, 0x34, 0xcb, 0xb9, 0x62, 0x62, 0x62, 0x36, 0x94, 0x94, 0x94, 0xe8, 0x4b, 0x96, 0x2c, 0xe9, 0xf8, 0xe4, 0x93, 0x4f, 0x34, 0x93, 0x00, 0xc4, 0x78, 0x09, 0x80, 0x0d, 0xc0, 0x3d, 0x1b, 0x36, 0x6c, 0x20, 0x49, 0x46, 0x45, 0x45, 0xbd, 0x0b, 0x20, 0x16, 0xc0, 0xb0, 0x29, 0x53, 0xa6, 0x34, 0x90, 0xe4, 0x8a, 0x15, 0x2b, 0x28, 0x83, 0xd4, 0x08, 0x08, 0x67, 0x44, 0x44, 0xc4, 0xc6, 0xb2, 0xb2, 0x32, 0x66, 0x65, 0x65, 0x11, 0xc0, 0xbd, 0x00, 0x1e, 0x08, 0x0f, 0x0f, 0xdf, 0x4e, 0x92, 0xdb, 0xb6, 0x6d, 0x23, 0x80, 0xdf, 0x78, 0x09, 0x40, 0x27, 0x00, 0x99, 0x95, 0x95, 0x95, 0x5c, 0xb3, 0x66, 0x8d, 0x67, 0xf2, 0xe4, 0xc9, 0x17, 0x49, 0x72, 0xf6, 0xec, 0xd9, 0xbe, 0x04, 0xc0, 0x09, 0x20, 0x65, 0xf3, 0xe6, 0xcd, 0x3c, 0x70, 0xe0, 0x00, 0x01, 0x14, 0x03, 0x78, 0x06, 0x40, 0xba, 0xbc, 0x57, 0x94, 0x49, 0xec, 0x1c, 0x00, 0xee, 0x5d, 0xb9, 0x72, 0x25, 0x49, 0x32, 0x21, 0x21, 0xa1, 0x1a, 0xc0, 0x63, 0x00, 0xc6, 0x02, 0x98, 0x02, 0x60, 0x06, 0x80, 0x24, 0xbb, 0xdd, 0xee, 0x6f, 0xac, 0xa5, 0x64, 0xff, 0x21, 0xb2, 0xb6, 0x10, 0x0d, 0x60, 0x48, 0x42, 0x42, 0xc2, 0x21, 0x92, 0x5c, 0xbe, 0x7c, 0x39, 0x01, 0xa4, 0xaa, 0xaa, 0x1a, 0x62, 0xfa, 0x0e, 0x02, 0x00, 0x2c, 0x32, 0x8d, 0xff, 0x7c, 0x99, 0xa5, 0x55, 0x90, 0x64, 0x65, 0x65, 0x25, 0x01, 0x3c, 0x68, 0xf2, 0x37, 0x2a, 0x23, 0x23, 0xa3, 0x9a, 0x24, 0x57, 0xad, 0x5a, 0x45, 0x00, 0x23, 0x00, 0xf4, 0x01, 0x30, 0xf7, 0xc8, 0x91, 0x23, 0x74, 0xbb, 0xdd, 0x04, 0x50, 0x20, 0x6d, 0xb0, 0xf8, 0x85, 0x13, 0x0a, 0x60, 0x6e, 0x7d, 0x7d, 0x3d, 0xd7, 0xad, 0x5b, 0x67, 0xcc, 0xe4, 0xde, 0x33, 0x43, 0xd7, 0xa4, 0xa4, 0xa4, 0x2a, 0x92, 0xdc, 0xb4, 0x69, 0x13, 0x01, 0xa4, 0xc8, 0xe2, 0x58, 0xce, 0x89, 0x13, 0x27, 0x48, 0x92, 0x8a, 0xa2, 0xac, 0x95, 0x05, 0x27, 0xa8, 0xaa, 0xea, 0x90, 0x0f, 0x57, 0x2f, 0x00, 0xe9, 0xc6, 0x4c, 0x7a, 0x13, 0x01, 0x50, 0x00, 0x84, 0xb9, 0x5c, 0xae, 0x17, 0x01, 0xbc, 0x1c, 0x1c, 0x1c, 0x3c, 0x42, 0x16, 0xc7, 0x7e, 0xbb, 0x64, 0xc9, 0x12, 0x8d, 0x24, 0x17, 0x2d, 0x5a, 0xd4, 0x26, 0x8b, 0x93, 0x46, 0x8a, 0xeb, 0x90, 0x01, 0xdd, 0x03, 0xc0, 0x5d, 0x42, 0x88, 0x2c, 0x00, 0xeb, 0x0a, 0x0b, 0x0b, 0x49, 0x92, 0x63, 0xc6, 0x8c, 0x39, 0x2f, 0x33, 0x0d, 0x9b, 0x0c, 0x3a, 0x3f, 0x00, 0x31, 0x23, 0x46, 0x8c, 0xf8, 0x5f, 0x29, 0x72, 0x15, 0xb9, 0xb9, 0xb9, 0x8d, 0x26, 0x01, 0xb8, 0xcb, 0xcb, 0x26, 0x7f, 0x00, 0xe3, 0xab, 0xab, 0xab, 0x59, 0x56, 0x56, 0xd6, 0xb1, 0x60, 0xc1, 0x82, 0x8e, 0xbd, 0x7b, 0xf7, 0xb2, 0xa2, 0xa2, 0x82, 0x83, 0x07, 0x0f, 0x3e, 0x0e, 0x20, 0x49, 0x06, 0xa8, 0x21, 0x16, 0xe9, 0xdb, 0xb7, 0x6f, 0x37, 0xb2, 0x85, 0xfa, 0xd2, 0xd2, 0x52, 0xbd, 0xbc, 0xbc, 0x9c, 0x05, 0x05, 0x05, 0xed, 0x32, 0x9b, 0xe9, 0x61, 0x12, 0x0c, 0xef, 0xec, 0x2b, 0x02, 0x40, 0xde, 0xa9, 0x53, 0xa7, 0x78, 0xf6, 0xec, 0x59, 0x02, 0x28, 0x34, 0xa7, 0xf3, 0xa6, 0x25, 0xcf, 0x83, 0xcb, 0x97, 0x2f, 0x27, 0x49, 0x26, 0x27, 0x27, 0x37, 0x01, 0x78, 0x7f, 0xe9, 0xd2, 0xa5, 0x6e, 0x92, 0x4c, 0x4b, 0x4b, 0xab, 0x97, 0xe3, 0x63, 0x08, 0x64, 0xd7, 0x09, 0x13, 0x26, 0xd4, 0x90, 0xe4, 0xeb, 0xaf, 0xbf, 0x4e, 0x00, 0xa9, 0x32, 0xa3, 0xf8, 0xdd, 0xb1, 0x63, 0xc7, 0x48, 0x92, 0x01, 0x01, 0x01, 0x6f, 0xc8, 0x7b, 0x5b, 0xfc, 0xc2, 0x77, 0x11, 0x7a, 0x0c, 0x19, 0x32, 0x64, 0x2f, 0x49, 0xf6, 0xeb, 0xd7, 0x6f, 0xb7, 0x51, 0xad, 0xf7, 0x5a, 0xa3, 0xdf, 0x39, 0x66, 0xcc, 0x98, 0xfd, 0x24, 0x59, 0x5a, 0x5a, 0x4a, 0x00, 0x83, 0x64, 0x0a, 0x9c, 0x7d, 0xe8, 0xd0, 0x21, 0x63, 0x59, 0xb0, 0x41, 0x8a, 0x82, 0xf9, 0xe1, 0xf6, 0x07, 0xd0, 0x6f, 0xd9, 0xb2, 0x65, 0xdf, 0x27, 0x00, 0x42, 0x55, 0x55, 0x9b, 0x4c, 0x91, 0x43, 0x64, 0xf0, 0x27, 0x0d, 0x1d, 0x3a, 0xb4, 0x96, 0x24, 0x75, 0x5d, 0x67, 0x58, 0x58, 0xd8, 0x66, 0x1f, 0x59, 0x89, 0x22, 0x67, 0xbc, 0xd0, 0xe9, 0xd3, 0xa7, 0x5f, 0x31, 0xd6, 0xba, 0x79, 0x79, 0x79, 0x04, 0xb0, 0xd2, 0x66, 0xb3, 0xdd, 0x85, 0x6f, 0xb7, 0xbf, 0x22, 0x01, 0x2c, 0xbc, 0x7c, 0xf9, 0x32, 0x9f, 0x7d, 0xf6, 0xd9, 0x26, 0x00, 0x8f, 0xe5, 0xe6, 0xe6, 0x5e, 0x30, 0x2d, 0x01, 0xee, 0xf1, 0x2a, 0xa8, 0x06, 0x00, 0xc8, 0xbd, 0x74, 0xe9, 0x12, 0x49, 0xb2, 0xb6, 0xb6, 0x96, 0x95, 0x95, 0x95, 0xdf, 0xac, 0xb9, 0xc7, 0x8f, 0x1f, 0x7f, 0x19, 0x40, 0x6f, 0xb9, 0x36, 0x77, 0x01, 0x78, 0xea, 0xe0, 0xc1, 0x83, 0x24, 0xa9, 0xb7, 0xb7, 0xb7, 0xf3, 0xe8, 0xd1, 0xa3, 0xac, 0xad, 0xad, 0x35, 0xd7, 0x00, 0x16, 0xca, 0x5d, 0x07, 0xef, 0x1d, 0x09, 0x27, 0x80, 0xc4, 0xf9, 0xf3, 0xe7, 0xbb, 0x49, 0x32, 0x3d, 0x3d, 0xbd, 0x0e, 0xc0, 0xdd, 0x52, 0xb0, 0x6e, 0xc8, 0xd2, 0x84, 0x10, 0x09, 0x00, 0x76, 0x9c, 0x3f, 0x7f, 0xfe, 0x86, 0x7a, 0x81, 0x0c, 0xf0, 0x65, 0x26, 0x7f, 0x01, 0x20, 0x3c, 0x22, 0x22, 0xa2, 0x9c, 0x24, 0x1b, 0x1b, 0x1b, 0x69, 0xb3, 0xd9, 0x3e, 0x03, 0xb0, 0xe8, 0xbe, 0xfb, 0xee, 0xfb, 0xe6, 0xe2, 0x9e, 0x3d, 0x7b, 0x6e, 0x95, 0x19, 0x88, 0xc5, 0x2f, 0x15, 0x21, 0x84, 0x3f, 0x80, 0xa4, 0xb2, 0xb2, 0x32, 0x9e, 0x38, 0x71, 0xc2, 0x28, 0x56, 0x75, 0xf2, 0x6e, 0x06, 0xe0, 0xce, 0x47, 0x1f, 0x7d, 0xf4, 0x73, 0x92, 0x5c, 0xb3, 0x66, 0x0d, 0x01, 0x0c, 0x96, 0x02, 0x30, 0xc9, 0xa8, 0x0b, 0x04, 0x05, 0x05, 0x79, 0x0b, 0x80, 0xb1, 0x96, 0xbe, 0xf7, 0x16, 0x02, 0x00, 0x53, 0xa1, 0x2b, 0x0a, 0xc0, 0xd3, 0xd3, 0xa7, 0x4f, 0x6f, 0x31, 0x1e, 0xd4, 0xb8, 0xb8, 0xb8, 0xaf, 0x01, 0xf4, 0x96, 0x05, 0x3c, 0x73, 0xf0, 0xdb, 0xe5, 0xec, 0xdb, 0x79, 0xe4, 0xc8, 0x91, 0x15, 0xb3, 0x67, 0xcf, 0xbe, 0x68, 0xcc, 0x6e, 0xf9, 0xf9, 0xf9, 0x04, 0xf0, 0x80, 0x0c, 0x1c, 0x07, 0x80, 0xfe, 0x0b, 0x17, 0x2e, 0xf4, 0xd4, 0xd5, 0xd5, 0x11, 0x40, 0x09, 0x80, 0x09, 0xcf, 0x3f, 0xff, 0x7c, 0x93, 0x2c, 0x4c, 0x36, 0x01, 0xe8, 0xe7, 0x70, 0x38, 0xcc, 0x7e, 0xfb, 0x05, 0x04, 0x04, 0x4c, 0xcb, 0xcf, 0xcf, 0xbf, 0x94, 0x9b, 0x9b, 0xdb, 0x06, 0xe0, 0x25, 0x00, 0x53, 0x12, 0x13, 0x13, 0xcf, 0x99, 0xd6, 0xd5, 0x2f, 0x4a, 0xa1, 0xf0, 0x07, 0x30, 0xf1, 0xf0, 0xe1, 0xc3, 0x94, 0x82, 0x72, 0x15, 0x40, 0x11, 0x80, 0x15, 0x6f, 0xbe, 0xf9, 0x26, 0x49, 0xf2, 0x85, 0x17, 0x5e, 0x68, 0x96, 0x33, 0xb4, 0x77, 0xf1, 0x33, 0x02, 0xc0, 0x6a, 0xa3, 0x70, 0x08, 0x60, 0xb6, 0x14, 0x0a, 0xef, 0xf3, 0x1d, 0x21, 0x00, 0x72, 0x8d, 0x2c, 0x63, 0xca, 0x94, 0x29, 0x9e, 0xe4, 0xe4, 0xe4, 0xfd, 0x9b, 0x37, 0x6f, 0x36, 0xfb, 0x3b, 0x4c, 0x0a, 0x8a, 0x21, 0xbc, 0x29, 0x79, 0x79, 0x79, 0xdf, 0x08, 0xc5, 0xe9, 0xd3, 0xa7, 0x49, 0x92, 0x47, 0x8f, 0x1e, 0xd5, 0x49, 0xb2, 0x5b, 0xb7, 0x6e, 0x5b, 0x2c, 0x01, 0xb8, 0x3d, 0xb1, 0xc9, 0x07, 0x20, 0x14, 0x40, 0xa0, 0xa2, 0x28, 0x7e, 0xf0, 0x7d, 0x60, 0xc8, 0x98, 0x19, 0x57, 0x92, 0xe4, 0xcb, 0x2f, 0xbf, 0xdc, 0x26, 0xd3, 0x44, 0x87, 0x8f, 0xb6, 0x5d, 0x87, 0x0c, 0x19, 0xb2, 0xc3, 0x54, 0x01, 0x1f, 0x21, 0x83, 0x75, 0x76, 0x5d, 0x5d, 0x1d, 0x49, 0x52, 0x08, 0x51, 0x2a, 0x45, 0xc1, 0x8c, 0xe3, 0x07, 0x0a, 0x80, 0x5d, 0xa6, 0xbd, 0x0b, 0xde, 0x7b, 0xef, 0x3d, 0x92, 0xe4, 0x17, 0x5f, 0x7c, 0xc1, 0xe8, 0xe8, 0xe8, 0xed, 0x00, 0xe2, 0x55, 0x55, 0x0d, 0x36, 0xfb, 0xe0, 0x74, 0x3a, 0x03, 0x00, 0xfc, 0x5a, 0xae, 0xc9, 0x87, 0xca, 0xe0, 0x1a, 0x00, 0xe0, 0x43, 0x5d, 0xd7, 0x8d, 0x54, 0x7c, 0xa9, 0xac, 0x49, 0xb8, 0x00, 0xcc, 0x6e, 0x69, 0x69, 0x61, 0x79, 0x79, 0xb9, 0x5e, 0x54, 0x54, 0xd4, 0x56, 0x50, 0x50, 0xe0, 0x7e, 0xff, 0xfd, 0xf7, 0x75, 0x63, 0xfd, 0x9c, 0x9d, 0x9d, 0x4d, 0x5c, 0xdf, 0xb7, 0x87, 0x5c, 0xc2, 0xf8, 0x4b, 0x7b, 0xe2, 0x01, 0xc4, 0x2a, 0x8a, 0xd2, 0x43, 0xda, 0x5d, 0x74, 0xe1, 0xc2, 0x05, 0x63, 0xc9, 0x53, 0x2a, 0xc5, 0xd2, 0x05, 0x60, 0x4c, 0x55, 0x55, 0x95, 0x71, 0xdf, 0x72, 0x79, 0xdd, 0x80, 0xd4, 0xd4, 0xd4, 0x43, 0xa6, 0x65, 0xd3, 0x40, 0xaf, 0x2c, 0xc3, 0x0e, 0xa0, 0x77, 0x6e, 0x6e, 0x6e, 0xb3, 0x14, 0x89, 0x56, 0x39, 0xfe, 0x7e, 0x3e, 0xc6, 0x3f, 0x2a, 0x3d, 0x3d, 0xbd, 0xda, 0xd4, 0xd7, 0x54, 0x00, 0xc3, 0x01, 0xac, 0xbf, 0x78, 0xf1, 0x22, 0x4d, 0xb5, 0x9b, 0x60, 0xd9, 0xaf, 0x5d, 0x08, 0xd1, 0x15, 0xc0, 0xb8, 0x07, 0x1f, 0x7c, 0xf0, 0x60, 0x69, 0x69, 0x29, 0x57, 0xaf, 0x5e, 0x4d, 0x87, 0xc3, 0x71, 0xd8, 0xb0, 0x53, 0x16, 0x34, 0xc3, 0xac, 0x70, 0xf9, 0xf9, 0x57, 0xf0, 0xbd, 0x71, 0x02, 0x98, 0xde, 0xbd, 0x7b, 0xf7, 0x95, 0x11, 0x11, 0x11, 0xa5, 0xba, 0xae, 0x87, 0xc1, 0xf7, 0x76, 0x8f, 0x0d, 0x40, 0xd0, 0xa4, 0x49, 0x93, 0x32, 0x01, 0xe0, 0xb5, 0xd7, 0x5e, 0xab, 0x00, 0x70, 0x11, 0xdf, 0xee, 0xb5, 0x9b, 0xe9, 0xa8, 0xae, 0xae, 0x3e, 0x01, 0x00, 0x71, 0x71, 0x71, 0x90, 0x0f, 0x78, 0x37, 0x00, 0x7d, 0xba, 0x77, 0xef, 0x8e, 0xb3, 0x67, 0xcf, 0x82, 0xe4, 0x97, 0x00, 0xdc, 0x7f, 0x4f, 0x22, 0x22, 0xab, 0xfa, 0xe9, 0x9b, 0x36, 0x6d, 0x7a, 0xe5, 0xe1, 0x87, 0x1f, 0xc6, 0x8a, 0x15, 0x2b, 0x10, 0x1b, 0x1b, 0xbb, 0xaa, 0xae, 0xae, 0x6e, 0x01, 0x80, 0x36, 0x4d, 0xd3, 0x84, 0xaa, 0xaa, 0x46, 0x60, 0x88, 0xb6, 0xb6, 0x36, 0xe5, 0xe9, 0xa7, 0x9f, 0x7e, 0xef, 0xd8, 0xb1, 0x63, 0xef, 0xe6, 0xe4, 0xe4, 0xec, 0x96, 0x82, 0xd7, 0x01, 0xe0, 0xe0, 0xf9, 0xf3, 0xe7, 0x8d, 0x8c, 0xc2, 0x85, 0x6f, 0x4f, 0x1f, 0xb6, 0xd5, 0xd6, 0xd6, 0x62, 0xf8, 0xf0, 0xe1, 0x62, 0xe2, 0xc4, 0x89, 0x7e, 0xd9, 0xd9, 0xd9, 0xf6, 0x51, 0xa3, 0x46, 0x09, 0x92, 0x4c, 0x4d, 0x4d, 0x45, 0x4a, 0x4a, 0x0a, 0x4c, 0x05, 0x4c, 0x68, 0x9a, 0xc6, 0xd4, 0xd4, 0xd4, 0xe5, 0xd3, 0xa6, 0x4d, 0xfb, 0xd3, 0xb0, 0x61, 0xc3, 0xfe, 0xa0, 0xeb, 0xba, 0x43, 0x8a, 0x99, 0xd3, 0xe1, 0xb8, 0xae, 0x8f, 0xba, 0xae, 0xb7, 0xe2, 0xdb, 0x93, 0x75, 0x5f, 0xd6, 0xd4, 0xd4, 0x5c, 0x8f, 0x6a, 0xbb, 0xdd, 0x4f, 0x8e, 0xad, 0x50, 0x14, 0x45, 0x01, 0x80, 0x96, 0x96, 0x16, 0x00, 0x68, 0xf3, 0x21, 0x8e, 0x43, 0xc7, 0x8d, 0x1b, 0x17, 0x00, 0x00, 0xeb, 0xd7, 0xaf, 0xff, 0x10, 0xc0, 0x15, 0x1f, 0x63, 0x28, 0x00, 0x28, 0xbd, 0x7a, 0xf5, 0xea, 0x02, 0x00, 0x17, 0x2e, 0x5c, 0x00, 0x80, 0x5a, 0xd9, 0xf6, 0x84, 0xe1, 0xaf, 0xd3, 0xe9, 0x0c, 0x34, 0xed, 0x4a, 0x88, 0xf0, 0xf0, 0xf0, 0x5e, 0x00, 0xe2, 0xb6, 0x6f, 0xdf, 0xfe, 0xd1, 0xd4, 0xa9, 0x53, 0x47, 0x4f, 0x9b, 0x36, 0xed, 0x61, 0xb7, 0xdb, 0xbd, 0xaf, 0x5f, 0xbf, 0x7e, 0xa8, 0xad, 0xad, 0x05, 0xc9, 0x83, 0x00, 0xda, 0xad, 0x10, 0xba, 0xfd, 0x08, 0xcf, 0xce, 0xce, 0x3e, 0x40, 0x92, 0x1f, 0x7c, 0xf0, 0x81, 0xf7, 0xf6, 0x90, 0x99, 0x20, 0x00, 0xe3, 0x77, 0xed, 0xda, 0x65, 0xb4, 0x7b, 0x54, 0x06, 0xa2, 0x2f, 0x02, 0x00, 0xfc, 0x8b, 0xb1, 0x97, 0x1c, 0x13, 0x13, 0x53, 0x0b, 0x60, 0x65, 0x46, 0x46, 0xc6, 0x45, 0xd3, 0xb2, 0x60, 0x90, 0x8f, 0xd9, 0xcb, 0x01, 0x20, 0xde, 0x94, 0x01, 0x9c, 0xc2, 0x77, 0xb7, 0x01, 0x6d, 0x00, 0xa2, 0x8d, 0x8a, 0x7f, 0x75, 0x75, 0x35, 0x13, 0x13, 0x13, 0xcf, 0xa4, 0xa6, 0xa6, 0xd6, 0x8c, 0x1e, 0x3d, 0xfa, 0x7f, 0xd2, 0xd2, 0xd2, 0xf6, 0x25, 0x24, 0x24, 0x6c, 0x97, 0xa9, 0xb1, 0x21, 0x64, 0x9d, 0xbb, 0x77, 0xef, 0xfe, 0x0e, 0x49, 0xee, 0xdf, 0xbf, 0x9f, 0x00, 0xb6, 0x01, 0x28, 0x4c, 0x4e, 0x4e, 0xbe, 0x48, 0x92, 0x9f, 0x7f, 0xfe, 0x39, 0x01, 0x64, 0x4b, 0x61, 0xb0, 0xfb, 0xf9, 0xf9, 0xdd, 0x01, 0xe0, 0xdf, 0xe4, 0x12, 0x67, 0x2e, 0x80, 0x82, 0xc9, 0x93, 0x27, 0xb7, 0x92, 0x64, 0x76, 0x76, 0x76, 0x0b, 0x80, 0x7f, 0x17, 0x42, 0x84, 0x9b, 0x53, 0xee, 0xf8, 0xf8, 0xf8, 0xad, 0x24, 0xf9, 0xe5, 0x97, 0x5f, 0x12, 0xc0, 0x56, 0x00, 0xaf, 0xa6, 0xa5, 0xa5, 0x5d, 0x32, 0x8d, 0xeb, 0x68, 0x39, 0xfb, 0x2b, 0x00, 0xee, 0x48, 0x4a, 0x4a, 0xfa, 0x6f, 0x92, 0xdc, 0xb0, 0x61, 0x03, 0x01, 0xbc, 0x0e, 0xe0, 0xad, 0x1d, 0x3b, 0x76, 0x50, 0x16, 0xe9, 0x8e, 0x00, 0xb8, 0xd3, 0xcb, 0xef, 0x70, 0x55, 0x55, 0xd7, 0x91, 0xe4, 0xb9, 0x73, 0xe7, 0x8c, 0xca, 0x7e, 0xa7, 0x9b, 0x8c, 0x7f, 0x44, 0x5c, 0x5c, 0xdc, 0x87, 0x24, 0xd9, 0xd0, 0xd0, 0x40, 0x55, 0x55, 0xf7, 0x02, 0x58, 0x14, 0x17, 0x17, 0x77, 0xc6, 0xf8, 0x9b, 0xf4, 0xcb, 0x10, 0x01, 0x3f, 0x00, 0x79, 0x2d, 0x2d, 0x2d, 0x46, 0x61, 0x71, 0x37, 0x80, 0x65, 0x4f, 0x3c, 0xf1, 0xc4, 0x65, 0x92, 0x5c, 0xbc, 0x78, 0xb1, 0x2e, 0x45, 0xdc, 0x61, 0x85, 0xcb, 0xed, 0x47, 0xa7, 0x94, 0x94, 0x94, 0x9a, 0xba, 0xba, 0x3a, 0x16, 0x17, 0x17, 0x53, 0xa6, 0xc6, 0x76, 0x1f, 0xed, 0x22, 0x23, 0x23, 0x23, 0xff, 0x48, 0x92, 0x59, 0x59, 0x59, 0x5f, 0x99, 0xab, 0xe6, 0x37, 0xc9, 0x16, 0xba, 0x0f, 0x1b, 0x36, 0xac, 0xc6, 0x58, 0x53, 0x9e, 0x3a, 0x75, 0x8a, 0x24, 0xd9, 0xdc, 0xdc, 0x4c, 0x97, 0xcb, 0x65, 0xac, 0x27, 0x7d, 0xa5, 0xf6, 0xbd, 0x4a, 0x4a, 0x4a, 0x48, 0x92, 0x39, 0x39, 0x39, 0xa7, 0x64, 0xe6, 0xa0, 0x78, 0xb5, 0x19, 0x66, 0xac, 0x6f, 0x7d, 0x51, 0x56, 0x56, 0x46, 0x5c, 0x3f, 0x07, 0x60, 0x37, 0x09, 0xd2, 0x08, 0xa3, 0xea, 0x6f, 0x5e, 0xe3, 0x92, 0x64, 0x7c, 0x7c, 0xfc, 0xdf, 0x64, 0xc0, 0xd9, 0xe4, 0x24, 0x6c, 0x14, 0x19, 0x8d, 0x23, 0xb8, 0x7d, 0xe6, 0xcd, 0x9b, 0xd7, 0x28, 0x53, 0xef, 0xf3, 0x00, 0x62, 0x64, 0xad, 0xc0, 0x2c, 0x78, 0xbf, 0x2d, 0x2e, 0x2e, 0xa6, 0xb7, 0xbf, 0x9a, 0xa6, 0x11, 0xc0, 0x9f, 0xbd, 0x2a, 0xf5, 0x41, 0x00, 0x1e, 0x5d, 0xbd, 0x7a, 0x35, 0x8d, 0xc2, 0x9b, 0x71, 0xd0, 0xe7, 0x9d, 0x77, 0xde, 0x21, 0x80, 0xa7, 0xe4, 0xb1, 0x65, 0x33, 0x61, 0x29, 0x29, 0x29, 0x7f, 0x35, 0x1d, 0x76, 0x4a, 0xc5, 0x8d, 0x87, 0xaf, 0xcc, 0x04, 0x02, 0x78, 0x68, 0xe9, 0xd2, 0xa5, 0xdf, 0xb1, 0x87, 0x24, 0x63, 0x63, 0x63, 0x4f, 0x00, 0xf8, 0x95, 0xe1, 0x83, 0x2c, 0x22, 0xf6, 0x1d, 0x37, 0x6e, 0x9c, 0xdb, 0x68, 0x63, 0xec, 0xd6, 0x48, 0x71, 0x5c, 0x20, 0x77, 0x6c, 0x14, 0x2b, 0x5c, 0x7e, 0xe6, 0x75, 0xbc, 0xef, 0x44, 0xaa, 0xcd, 0xe6, 0xef, 0xf1, 0x78, 0xee, 0xc6, 0xf5, 0x93, 0x6a, 0x97, 0xfd, 0xfd, 0xfd, 0xf7, 0xb5, 0xb6, 0xb6, 0x5e, 0xc1, 0x8d, 0x67, 0xe9, 0x05, 0x80, 0xce, 0xcf, 0x3c, 0xf3, 0xcc, 0x85, 0x49, 0x93, 0x26, 0x61, 0xd0, 0xa0, 0x41, 0x0b, 0x01, 0x2c, 0x07, 0x70, 0x09, 0xbe, 0x5f, 0x40, 0x11, 0x36, 0x9b, 0x2d, 0xc0, 0xe3, 0xf1, 0xdc, 0x11, 0x15, 0x15, 0xb5, 0x72, 0xd6, 0xac, 0x59, 0xbf, 0x09, 0x0a, 0x0a, 0x52, 0xce, 0x9d, 0x3b, 0x77, 0xad, 0xb0, 0xb0, 0xf0, 0xbf, 0x5a, 0x5b, 0x5b, 0xf3, 0x14, 0x45, 0x69, 0xd4, 0x75, 0xfd, 0x9a, 0x8f, 0x5d, 0x86, 0xe0, 0x01, 0x03, 0x06, 0x6c, 0x8d, 0x8f, 0x8f, 0x0f, 0xfe, 0xea, 0xab, 0xaf, 0xf6, 0x57, 0x55, 0x55, 0x3d, 0x2b, 0xd3, 0x57, 0xb3, 0xb8, 0xf4, 0x49, 0x49, 0x49, 0xf9, 0x63, 0xd7, 0xae, 0x5d, 0x75, 0x5d, 0xd7, 0x55, 0xb3, 0x0d, 0xaa, 0xaa, 0xea, 0x47, 0x8f, 0x1e, 0x6d, 0xfe, 0xec, 0xb3, 0xcf, 0x46, 0x03, 0xb8, 0x2a, 0x53, 0x6e, 0xc5, 0x66, 0xb3, 0x85, 0x7a, 0x3c, 0x9e, 0xe4, 0xe4, 0xe4, 0xe4, 0x97, 0x32, 0x32, 0x32, 0x12, 0x5d, 0x2e, 0x17, 0x1a, 0x1a, 0x1a, 0xda, 0x8a, 0x8a, 0x8a, 0xfe, 0x74, 0xf5, 0xea, 0xd5, 0x57, 0x54, 0x55, 0x3d, 0x23, 0x8f, 0xba, 0xfa, 0xf2, 0x27, 0xa8, 0x4f, 0x9f, 0x3e, 0xbf, 0x1f, 0x32, 0x64, 0xc8, 0xdd, 0xc7, 0x8f, 0x1f, 0x3f, 0x52, 0x55, 0x55, 0x35, 0x45, 0xf6, 0x6d, 0xb4, 0x55, 0x6d, 0x36, 0x5b, 0x27, 0xd9, 0x7f, 0xde, 0xd8, 0xb1, 0x63, 0xe3, 0x5d, 0x2e, 0x17, 0xea, 0xea, 0xea, 0x5a, 0xf3, 0xf2, 0xf2, 0x36, 0x02, 0x58, 0x2c, 0x84, 0xb8, 0x40, 0xd2, 0xf0, 0x57, 0x55, 0x14, 0xa5, 0xb3, 0xae, 0xeb, 0xff, 0xfc, 0xe4, 0x93, 0x4f, 0x2e, 0x4e, 0x4e, 0x4e, 0xee, 0xa9, 0x69, 0x1a, 0x3e, 0xfd, 0xf4, 0xd3, 0xba, 0xb2, 0xb2, 0xb2, 0x7c, 0x45, 0x51, 0xfe, 0x2c, 0x8f, 0x32, 0x9b, 0xcf, 0xeb, 0x07, 0x74, 0xee, 0xdc, 0x79, 0xd1, 0x23, 0x8f, 0x3c, 0x92, 0x72, 0xe8, 0xd0, 0xa1, 0xb6, 0x7d, 0xfb, 0xf6, 0x65, 0x02, 0x38, 0x0b, 0xdf, 0x2f, 0x3f, 0xa9, 0xaa, 0xaa, 0x86, 0x6a, 0x9a, 0x96, 0x9c, 0x96, 0x96, 0xb6, 0x70, 0xe4, 0xc8, 0x91, 0x7d, 0xfd, 0xfd, 0xfd, 0xd1, 0xd0, 0xd0, 0xd0, 0x51, 0x5c, 0x5c, 0xfc, 0x6e, 0x53, 0x53, 0xd3, 0xcb, 0xaa, 0xaa, 0xd6, 0x6b, 0x9a, 0xd6, 0x2c, 0x7d, 0x50, 0x54, 0x55, 0x0d, 0xd1, 0x34, 0xad, 0x5f, 0x52, 0x52, 0x52, 0xf1, 0xf8, 0xf1, 0xe3, 0xfb, 0x07, 0x06, 0x06, 0xe2, 0xe0, 0xc1, 0x83, 0x57, 0x0a, 0x0a, 0x0a, 0x5e, 0x05, 0xb0, 0x5e, 0xda, 0xef, 0xb6, 0x42, 0xe8, 0x36, 0x13, 0x00, 0xf9, 0x37, 0x9b, 0x0c, 0x3e, 0xe3, 0x6d, 0x31, 0xef, 0x17, 0x3f, 0x84, 0xd3, 0xe9, 0x0c, 0x68, 0x6b, 0x6b, 0x1b, 0x20, 0x67, 0x97, 0xbd, 0x42, 0x88, 0x2b, 0xb7, 0x78, 0x20, 0x84, 0xa2, 0x28, 0x2e, 0x5d, 0xd7, 0x03, 0xe5, 0x8c, 0xe7, 0xc0, 0xf5, 0xb3, 0xf0, 0xcd, 0x8a, 0xa2, 0x5c, 0xd5, 0x75, 0xdd, 0xd7, 0x7a, 0x52, 0xa8, 0xaa, 0xea, 0xa7, 0x69, 0x9a, 0x5d, 0xa6, 0xa5, 0xed, 0x36, 0x9b, 0xad, 0xdd, 0xe3, 0xf1, 0xb8, 0xbd, 0xc4, 0xc5, 0xe5, 0xf1, 0x78, 0xec, 0xb2, 0x5f, 0xef, 0x59, 0xc9, 0x03, 0xa0, 0x59, 0x55, 0x55, 0xb7, 0xa6, 0x69, 0xed, 0xb8, 0xf1, 0xe5, 0x98, 0x00, 0xf9, 0xc2, 0x4e, 0x90, 0xf4, 0xd9, 0xdb, 0x1e, 0x9f, 0x6f, 0x1d, 0xaa, 0xaa, 0xea, 0xd0, 0x34, 0xcd, 0x4f, 0xfa, 0xe0, 0xf6, 0x61, 0x93, 0x51, 0x5f, 0x09, 0x90, 0x7d, 0x1b, 0xfd, 0xb7, 0x00, 0xb8, 0xaa, 0x28, 0x4a, 0xb3, 0x0f, 0x7f, 0x6d, 0xa6, 0xf6, 0xc6, 0x52, 0xaa, 0x05, 0xc0, 0x55, 0x21, 0x44, 0xb3, 0xf7, 0xcb, 0x3a, 0x42, 0x08, 0x3b, 0x49, 0xa7, 0x1c, 0x97, 0x0e, 0xe9, 0x5f, 0x1b, 0x6e, 0xfe, 0xa6, 0xa4, 0x51, 0xdc, 0x35, 0xec, 0x51, 0x65, 0x5d, 0xe1, 0x8a, 0xb4, 0xc7, 0xfb, 0x5a, 0x55, 0x08, 0xe1, 0x22, 0x19, 0x2c, 0x0b, 0xc2, 0xfe, 0x00, 0x1a, 0x4c, 0xf6, 0x58, 0xc1, 0x7f, 0x9b, 0x0a, 0xc0, 0x8f, 0x29, 0x20, 0x1a, 0xfb, 0xe4, 0xbe, 0x44, 0xe2, 0xfb, 0xee, 0xf9, 0x43, 0x5e, 0x1b, 0xf6, 0xbe, 0x86, 0xff, 0x80, 0x2f, 0xbc, 0x85, 0x1f, 0xca, 0x8f, 0xb4, 0xe7, 0xc7, 0x8e, 0xd3, 0x8f, 0xe9, 0x5f, 0xc1, 0x8d, 0xaf, 0x03, 0xeb, 0x3f, 0xc1, 0xd8, 0xdc, 0xac, 0xff, 0x5b, 0xbd, 0x5e, 0xfd, 0xf7, 0xb4, 0xb7, 0xf8, 0x19, 0xf1, 0x7f, 0x2c, 0x2e, 0x06, 0x08, 0x9c, 0x01, 0xc9, 0x62, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; unsigned int cc_fps_images_len(void) { return sizeof(cc_fps_images_png); } ================================================ FILE: cocos2d/cocos/2d/ccFPSImages.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2012 Zynga Inc. * * 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. */ #ifdef __cplusplus extern "C" { #endif extern unsigned char cc_fps_images_png[]; unsigned int cc_fps_images_len(void); #ifdef __cplusplus } #endif ================================================ FILE: cocos2d/cocos/2d/ccGLStateCache.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ccGLStateCache.h" #include "CCGLProgram.h" #include "CCDirector.h" #include "ccConfig.h" #include "CCConfiguration.h" // extern #include "kazmath/GL/matrix.h" #include "kazmath/kazmath.h" NS_CC_BEGIN namespace { static GLuint s_currentProjectionMatrix = -1; static bool s_vertexAttribPosition = false; static bool s_vertexAttribColor = false; static bool s_vertexAttribTexCoords = false; #if CC_ENABLE_GL_STATE_CACHE #define kMaxActiveTexture 16 static GLuint s_currentShaderProgram = -1; static GLuint s_currentBoundTexture[kMaxActiveTexture] = {(GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, }; static GLenum s_blendingSource = -1; static GLenum s_blendingDest = -1; static int s_GLServerState = 0; static GLuint s_VAO = 0; static GLenum s_activeTexture = -1; #endif // CC_ENABLE_GL_STATE_CACHE } // GL State Cache functions namespace GL { void invalidateStateCache( void ) { kmGLFreeAll(); s_currentProjectionMatrix = -1; s_vertexAttribPosition = false; s_vertexAttribColor = false; s_vertexAttribTexCoords = false; #if CC_ENABLE_GL_STATE_CACHE s_currentShaderProgram = -1; for( int i=0; i < kMaxActiveTexture; i++ ) { s_currentBoundTexture[i] = -1; } s_blendingSource = -1; s_blendingDest = -1; s_GLServerState = 0; s_VAO = 0; #endif // CC_ENABLE_GL_STATE_CACHE } void deleteProgram( GLuint program ) { #if CC_ENABLE_GL_STATE_CACHE if(program == s_currentShaderProgram) { s_currentShaderProgram = -1; } #endif // CC_ENABLE_GL_STATE_CACHE glDeleteProgram( program ); } void useProgram( GLuint program ) { #if CC_ENABLE_GL_STATE_CACHE if( program != s_currentShaderProgram ) { s_currentShaderProgram = program; glUseProgram(program); } #else glUseProgram(program); #endif // CC_ENABLE_GL_STATE_CACHE } static void SetBlending(GLenum sfactor, GLenum dfactor) { if (sfactor == GL_ONE && dfactor == GL_ZERO) { glDisable(GL_BLEND); } else { glEnable(GL_BLEND); glBlendFunc(sfactor, dfactor); } } void blendFunc(GLenum sfactor, GLenum dfactor) { #if CC_ENABLE_GL_STATE_CACHE if (sfactor != s_blendingSource || dfactor != s_blendingDest) { s_blendingSource = sfactor; s_blendingDest = dfactor; SetBlending(sfactor, dfactor); } #else SetBlending( sfactor, dfactor ); #endif // CC_ENABLE_GL_STATE_CACHE } void blendResetToCache(void) { glBlendEquation(GL_FUNC_ADD); #if CC_ENABLE_GL_STATE_CACHE SetBlending(s_blendingSource, s_blendingDest); #else SetBlending(CC_BLEND_SRC, CC_BLEND_DST); #endif // CC_ENABLE_GL_STATE_CACHE } void bindTexture2D(GLuint textureId) { GL::bindTexture2DN(0, textureId); } void bindTexture2DN(GLuint textureUnit, GLuint textureId) { #if CC_ENABLE_GL_STATE_CACHE CCASSERT(textureUnit < kMaxActiveTexture, "textureUnit is too big"); if (s_currentBoundTexture[textureUnit] != textureId) { s_currentBoundTexture[textureUnit] = textureId; activeTexture(GL_TEXTURE0 + textureUnit); glBindTexture(GL_TEXTURE_2D, textureId); } #else glActiveTexture(GL_TEXTURE0 + textureUnit); glBindTexture(GL_TEXTURE_2D, textureId); #endif } void deleteTexture(GLuint textureId) { deleteTextureN(0, textureId); } void deleteTextureN(GLuint textureUnit, GLuint textureId) { #if CC_ENABLE_GL_STATE_CACHE if (s_currentBoundTexture[textureUnit] == textureId) { s_currentBoundTexture[textureUnit] = -1; } #endif // CC_ENABLE_GL_STATE_CACHE glDeleteTextures(1, &textureId); } void activeTexture(GLenum texture) { #if CC_ENABLE_GL_STATE_CACHE if(s_activeTexture != texture) { s_activeTexture = texture; glActiveTexture(s_activeTexture); } #else glActiveTexture(texture); #endif } void bindVAO(GLuint vaoId) { if (Configuration::getInstance()->supportsShareableVAO()) { #if CC_ENABLE_GL_STATE_CACHE if (s_VAO != vaoId) { s_VAO = vaoId; glBindVertexArray(vaoId); } #else glBindVertexArray(vaoId); #endif // CC_ENABLE_GL_STATE_CACHE } } //#pragma mark - GL Vertex Attrib functions void enableVertexAttribs( unsigned int flags ) { bindVAO(0); /* Position */ bool enablePosition = flags & VERTEX_ATTRIB_FLAG_POSITION; if( enablePosition != s_vertexAttribPosition ) { if( enablePosition ) glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION ); else glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION ); s_vertexAttribPosition = enablePosition; } /* Color */ bool enableColor = (flags & VERTEX_ATTRIB_FLAG_COLOR) != 0 ? true : false; if( enableColor != s_vertexAttribColor ) { if( enableColor ) glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR ); else glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR ); s_vertexAttribColor = enableColor; } /* Tex Coords */ bool enableTexCoords = (flags & VERTEX_ATTRIB_FLAG_TEX_COORDS) != 0 ? true : false; if( enableTexCoords != s_vertexAttribTexCoords ) { if( enableTexCoords ) glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS ); else glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS ); s_vertexAttribTexCoords = enableTexCoords; } } //#pragma mark - GL Uniforms functions void setProjectionMatrixDirty( void ) { s_currentProjectionMatrix = -1; } } // Namespace GL NS_CC_END ================================================ FILE: cocos2d/cocos/2d/ccGLStateCache.h ================================================ /**************************************************************************** Copyright (c) 2011 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCGLSTATE_H__ #define __CCGLSTATE_H__ #include "CCGL.h" #include "CCPlatformMacros.h" NS_CC_BEGIN /** * @addtogroup shaders * @{ */ class GLProgram; namespace GL { /** vertex attrib flags */ enum { VERTEX_ATTRIB_FLAT_NONE = 0, VERTEX_ATTRIB_FLAG_POSITION = 1 << 0, VERTEX_ATTRIB_FLAG_COLOR = 1 << 1, VERTEX_ATTRIB_FLAG_TEX_COORDS = 1 << 2, VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = (VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_COLOR | VERTEX_ATTRIB_FLAG_TEX_COORDS), }; /** @file ccGLStateCache.h */ /** Invalidates the GL state cache. If CC_ENABLE_GL_STATE_CACHE it will reset the GL state cache. @since v2.0.0 */ void CC_DLL invalidateStateCache(void); /** Uses the GL program in case program is different than the current one. If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly. @since v2.0.0 */ void CC_DLL useProgram(GLuint program); /** Deletes the GL program. If it is the one that is being used, it invalidates it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glDeleteProgram() directly. @since v2.0.0 */ void CC_DLL deleteProgram(GLuint program); /** Uses a blending function in case it not already used. If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly. @since v2.0.0 */ void CC_DLL blendFunc(GLenum sfactor, GLenum dfactor); /** Resets the blending mode back to the cached state in case you used glBlendFuncSeparate() or glBlendEquation(). If CC_ENABLE_GL_STATE_CACHE is disabled, it will just set the default blending mode using GL_FUNC_ADD. @since v2.0.0 */ void CC_DLL blendResetToCache(void); /** sets the projection matrix as dirty @since v2.0.0 */ void CC_DLL setProjectionMatrixDirty(void); /** Will enable the vertex attribs that are passed as flags. Possible flags: * VERTEX_ATTRIB_FLAG_POSITION * VERTEX_ATTRIB_FLAG_COLOR * VERTEX_ATTRIB_FLAG_TEX_COORDS These flags can be ORed. The flags that are not present, will be disabled. @since v2.0.0 */ void CC_DLL enableVertexAttribs(unsigned int flags); /** If the texture is not already bound to texture unit 0, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. @since v2.0.0 */ void CC_DLL bindTexture2D(GLuint textureId); /** If the texture is not already bound to a given unit, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. @since v2.1.0 */ void CC_DLL bindTexture2DN(GLuint textureUnit, GLuint textureId); /** It will delete a given texture. If the texture was bound, it will invalidate the cached. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. @since v2.0.0 */ void CC_DLL deleteTexture(GLuint textureId); /** It will delete a given texture. If the texture was bound, it will invalidate the cached for the given texture unit. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. @since v2.1.0 */ void CC_DLL deleteTextureN(GLuint textureUnit, GLuint textureId); /** Select active texture unit. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glActiveTexture() directly. @since v3.0 */ void CC_DLL activeTexture(GLenum texture); /** If the vertex array is not already bound, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindVertexArray() directly. @since v2.0.0 */ void CC_DLL bindVAO(GLuint vaoId); // end of shaders group /// @} } // Namespace GL NS_CC_END #endif /* __CCGLSTATE_H__ */ ================================================ FILE: cocos2d/cocos/2d/ccMacros.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCMACROS_H__ #define __CCMACROS_H__ #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #include "CCConsole.h" #include "CCStdC.h" #ifndef CCASSERT #if COCOS2D_DEBUG > 0 extern bool CC_DLL cc_assert_script_compatible(const char *msg); #define CCASSERT(cond, msg) do { \ if (!(cond)) { \ if (!cc_assert_script_compatible(msg) && strlen(msg)) \ cocos2d::log("Assert failed: %s", msg); \ CC_ASSERT(cond); \ } \ } while (0) #else #define CCASSERT(cond, msg) #endif // XXX: Backward compatible #define CCAssert CCASSERT #endif // CCASSERT #include "ccConfig.h" /** @def CC_SWAP simple macro that swaps 2 variables */ #define CC_SWAP(x, y, type) \ { type temp = (x); \ x = y; y = temp; \ } /** @def CCRANDOM_MINUS1_1 returns a random float between -1 and 1 */ #define CCRANDOM_MINUS1_1() ((2.0f*((float)rand()/RAND_MAX))-1.0f) /** @def CCRANDOM_0_1 returns a random float between 0 and 1 */ #define CCRANDOM_0_1() ((float)rand()/RAND_MAX) /** @def CC_DEGREES_TO_RADIANS converts degrees to radians */ #define CC_DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) * 0.01745329252f) // PI / 180 /** @def CC_RADIANS_TO_DEGREES converts radians to degrees */ #define CC_RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) * 57.29577951f) // PI * 180 #define kRepeatForever (UINT_MAX -1) /** @def CC_BLEND_SRC default gl blend src function. Compatible with premultiplied alpha images. */ #define CC_BLEND_SRC GL_ONE #define CC_BLEND_DST GL_ONE_MINUS_SRC_ALPHA /** @def CC_NODE_DRAW_SETUP Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix @since v2.0 */ #define CC_NODE_DRAW_SETUP() \ do { \ CCASSERT(getShaderProgram(), "No shader program set for this node"); \ { \ getShaderProgram()->use(); \ getShaderProgram()->setUniformsForBuiltins(_modelViewTransform); \ } \ } while(0) /** @def CC_DIRECTOR_END Stops and removes the director from memory. Removes the GLView from its parent @since v0.99.4 */ #define CC_DIRECTOR_END() \ do { \ Director *__director = Director::getInstance(); \ __director->end(); \ } while(0) /** @def CC_CONTENT_SCALE_FACTOR On Mac it returns 1; On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1 */ #define CC_CONTENT_SCALE_FACTOR() Director::getInstance()->getContentScaleFactor() /****************************/ /** RETINA DISPLAY ENABLED **/ /****************************/ /** @def CC_RECT_PIXELS_TO_POINTS Converts a rect in pixels to points */ #define CC_RECT_PIXELS_TO_POINTS(__rect_in_pixels__) \ Rect( (__rect_in_pixels__).origin.x / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).origin.y / CC_CONTENT_SCALE_FACTOR(), \ (__rect_in_pixels__).size.width / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).size.height / CC_CONTENT_SCALE_FACTOR() ) /** @def CC_RECT_POINTS_TO_PIXELS Converts a rect in points to pixels */ #define CC_RECT_POINTS_TO_PIXELS(__rect_in_points_points__) \ Rect( (__rect_in_points_points__).origin.x * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).origin.y * CC_CONTENT_SCALE_FACTOR(), \ (__rect_in_points_points__).size.width * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).size.height * CC_CONTENT_SCALE_FACTOR() ) /** @def CC_POINT_PIXELS_TO_POINTS Converts a rect in pixels to points */ #define CC_POINT_PIXELS_TO_POINTS(__pixels__) \ Point( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR()) /** @def CC_POINT_POINTS_TO_PIXELS Converts a rect in points to pixels */ #define CC_POINT_POINTS_TO_PIXELS(__points__) \ Point( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR()) /** @def CC_POINT_PIXELS_TO_POINTS Converts a rect in pixels to points */ #define CC_SIZE_PIXELS_TO_POINTS(__size_in_pixels__) \ Size( (__size_in_pixels__).width / CC_CONTENT_SCALE_FACTOR(), (__size_in_pixels__).height / CC_CONTENT_SCALE_FACTOR()) /** @def CC_POINT_POINTS_TO_PIXELS Converts a rect in points to pixels */ #define CC_SIZE_POINTS_TO_PIXELS(__size_in_points__) \ Size( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_points__).height * CC_CONTENT_SCALE_FACTOR()) #ifndef FLT_EPSILON #define FLT_EPSILON 1.192092896e-07F #endif // FLT_EPSILON #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&);\ void operator=(const TypeName&) /** Helper macros which converts 4-byte little/big endian integral number to the machine native number representation It should work same as apples CFSwapInt32LittleToHost(..) */ /// when define returns true it means that our architecture uses big endian #define CC_HOST_IS_BIG_ENDIAN (bool)(*(unsigned short *)"\0\xff" < 0x100) #define CC_SWAP32(i) ((i & 0x000000ff) << 24 | (i & 0x0000ff00) << 8 | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24) #define CC_SWAP16(i) ((i & 0x00ff) << 8 | (i &0xff00) >> 8) #define CC_SWAP_INT32_LITTLE_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP32(i) : (i) ) #define CC_SWAP_INT16_LITTLE_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP16(i) : (i) ) #define CC_SWAP_INT32_BIG_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? (i) : CC_SWAP32(i) ) #define CC_SWAP_INT16_BIG_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? (i): CC_SWAP16(i) ) /**********************/ /** Profiling Macros **/ /**********************/ #if CC_ENABLE_PROFILERS #define CC_PROFILER_DISPLAY_TIMERS() Profiler::getInstance()->displayTimers() #define CC_PROFILER_PURGE_ALL() Profiler::getInstance()->releaseAllTimers() #define CC_PROFILER_START(__name__) ProfilingBeginTimingBlock(__name__) #define CC_PROFILER_STOP(__name__) ProfilingEndTimingBlock(__name__) #define CC_PROFILER_RESET(__name__) ProfilingResetTimingBlock(__name__) #define CC_PROFILER_START_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingBeginTimingBlock(__name__); } while(0) #define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingEndTimingBlock(__name__); } while(0) #define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingResetTimingBlock(__name__); } while(0) #define CC_PROFILER_START_INSTANCE(__id__, __name__) do{ ProfilingBeginTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) #define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do{ ProfilingEndTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) #else #define CC_PROFILER_DISPLAY_TIMERS() do {} while (0) #define CC_PROFILER_PURGE_ALL() do {} while (0) #define CC_PROFILER_START(__name__) do {} while (0) #define CC_PROFILER_STOP(__name__) do {} while (0) #define CC_PROFILER_RESET(__name__) do {} while (0) #define CC_PROFILER_START_CATEGORY(__cat__, __name__) do {} while(0) #define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do {} while(0) #define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do {} while(0) #define CC_PROFILER_START_INSTANCE(__id__, __name__) do {} while(0) #define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do {} while(0) #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do {} while(0) #endif #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 #define CHECK_GL_ERROR_DEBUG() #else #define CHECK_GL_ERROR_DEBUG() \ do { \ GLenum __error = glGetError(); \ if(__error) { \ cocos2d::log("OpenGL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \ } \ } while (false) #endif /** @def CC_INCREMENT_GL_DRAWS_BY_ONE Increments the GL Draws counts by one. The number of calls per frame are displayed on the screen when the Director's stats are enabled. */ extern unsigned int CC_DLL g_uNumberOfDraws; #define CC_INCREMENT_GL_DRAWS(__n__) g_uNumberOfDraws += __n__ /*******************/ /** Notifications **/ /*******************/ /** @def AnimationFrameDisplayedNotification Notification name when a SpriteFrame is displayed */ #define AnimationFrameDisplayedNotification "CCAnimationFrameDisplayedNotification" #endif // __CCMACROS_H__ ================================================ FILE: cocos2d/cocos/2d/ccShaderEx_SwitchMask_frag.h ================================================ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D u_texture; \n\ uniform sampler2D u_mask; \n\ \n\ void main() \n\ { \n\ vec4 texColor = texture2D(u_texture, v_texCoord); \n\ vec4 maskColor = texture2D(u_mask, v_texCoord); \n\ vec4 finalColor = vec4(texColor.r, texColor.g, texColor.b, maskColor.a * texColor.a); \n\ gl_FragColor = v_fragmentColor * finalColor; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_Label_frag.h ================================================ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ vec4 color = texture2D(CC_Texture0, v_texCoord); \n\ //the texture use dual channel 16-bit output for distance_map \n\ //float dist = color.b+color.g/256.0; \n\ // the texture use single channel 8-bit output for distance_map \n\ float dist = color.a; \n\ //todo:Implementation 'fwidth' for glsl 1.0 \n\ //float width = fwidth(dist); \n\ //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n\ float width = 0.04; \n\ float alpha = smoothstep(0.5-width, 0.5+width, dist); \n\ gl_FragColor = vec4(v_fragmentColor.rgb,alpha); \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_Label_frag_glow.h ================================================ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ uniform vec3 v_effectColor; \n\ \n\ void main() \n\ { \n\ float dist = texture2D(CC_Texture0, v_texCoord).a; \n\ //todo:Implementation 'fwidth' for glsl 1.0 \n\ //float width = fwidth(dist); \n\ //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n\ float width = 0.04; \n\ float alpha = smoothstep(0.5-width, 0.5+width, dist); \n\ //glow \n\ float mu = smoothstep(0.5, 1.0, sqrt(dist)); \n\ vec3 rgb = v_effectColor*(1.0-alpha) + v_fragmentColor.rgb*alpha; \n\ gl_FragColor = vec4(rgb, max(alpha,mu)); \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_Label_frag_outline.h ================================================ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ uniform vec3 v_effectColor; \n\ \n\ void main() \n\ { \n\ float dist = texture2D(CC_Texture0, v_texCoord).a; \n\ //todo:Implementation 'fwidth' for glsl 1.0 \n\ //float width = fwidth(dist); \n\ //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n\ float width = 0.04; \n\ float alpha = smoothstep(0.5-width, 0.5+width, dist); \n\ //outline \n\ float mu = smoothstep(0.545-width, 0.545+width, dist); \n\ vec3 rgb = v_effectColor*(1.0-mu) + v_fragmentColor.rgb*mu; \n\ gl_FragColor = vec4(rgb, max(alpha,mu)); \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_Label_frag_shadow.h ================================================ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ uniform vec3 v_effectColor; \n\ uniform vec2 v_shadowOffset; \n\ \n\ void main() \n\ { \n\ float dist = texture2D(CC_Texture0, v_texCoord).a; \n\ //todo:support for assign offset,but the shadow is limited by renderable area \n\ vec2 offset = vec2(-0.0015,-0.0015); \n\ float dist2 = texture2D(CC_Texture0, v_texCoord+offset).a; \n\ //todo:Implementation 'fwidth' for glsl 1.0 \n\ //float width = fwidth(dist); \n\ //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n\ float width = 0.04; \n\ // If v is 1 then it's inside the Glyph; if it's 0 then it's outside \n\ float v = smoothstep(0.5-width, 0.5+width, dist); \n\ // If s is 1 then it's inside the shadow; if it's 0 then it's outside \n\ float s = smoothstep(0.5-width, 0.5+width, dist2); \n\ if(v == 1.0) gl_FragColor = vec4(v_fragmentColor.rgb,1.0); \n\ else if(v == 0.0) gl_FragColor = vec4(v_effectColor,s); \n\ else \n\ { \n\ vec3 color = v_fragmentColor.rgb*v + v_effectColor*s*(1.0-v); \n\ gl_FragColor = vec4(color,max(s,v)); \n\ } \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_Label_vert.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ attribute vec4 a_color; \n\ \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ varying mediump vec2 v_texCoord; \n\ #else \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ #endif \n\ \n\ void main() \n\ { \n\ gl_Position = CC_MVPMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ v_texCoord = a_texCoord; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionColorLengthTexture_frag.h ================================================ /* Copyright (c) 2012 Scott Lembcke and Howling Moon Software * * 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. */ " \n\ #ifdef GL_ES \n\ // #extension GL_OES_standard_derivatives : enable \n\ \n\ varying mediump vec4 v_color; \n\ varying mediump vec2 v_texcoord; \n\ #else \n\ varying vec4 v_color; \n\ varying vec2 v_texcoord; \n\ #endif \n\ \n\ void main() \n\ { \n\ // #if defined GL_OES_standard_derivatives \n\ // gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n\ // #else \n\ gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); \n\ // #endif \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionColorLengthTexture_vert.h ================================================ /* Copyright (c) 2012 Scott Lembcke and Howling Moon Software * * 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. */ " \n\ #ifdef GL_ES \n\ attribute mediump vec4 a_position; \n\ attribute mediump vec2 a_texcoord; \n\ attribute mediump vec4 a_color; \n\ \n\ varying mediump vec4 v_color; \n\ varying mediump vec2 v_texcoord; \n\ \n\ #else \n\ attribute vec4 a_position; \n\ attribute vec2 a_texcoord; \n\ attribute vec4 a_color; \n\ \n\ varying vec4 v_color; \n\ varying vec2 v_texcoord; \n\ #endif \n\ \n\ void main() \n\ { \n\ v_color = vec4(a_color.rgb * a_color.a, a_color.a); \n\ v_texcoord = a_texcoord; \n\ \n\ gl_Position = CC_MVPMatrix * a_position; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionColor_frag.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ \n\ void main() \n\ { \n\ gl_FragColor = v_fragmentColor; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionColor_vert.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ attribute vec4 a_position; \n\ attribute vec4 a_color; \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ #else \n\ varying vec4 v_fragmentColor; \n\ #endif \n\ \n\ void main() \n\ { \n\ gl_Position = CC_MVPMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTextureA8Color_frag.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ gl_FragColor = vec4( v_fragmentColor.rgb, // RGB from uniform \n\ v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform \n\ ); \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTextureA8Color_vert.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ attribute vec4 a_color; \n\ \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ varying mediump vec2 v_texCoord; \n\ #else \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ #endif \n\ \n\ void main() \n\ { \n\ gl_Position = CC_MVPMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ v_texCoord = a_texCoord; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTextureColorAlphaTest_frag.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Brian Chapados * * 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. */ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ uniform float CC_alpha_value; \n\ \n\ void main() \n\ { \n\ vec4 texColor = texture2D(CC_Texture0, v_texCoord); \n\ \n\ // mimic: glAlphaFunc(GL_GREATER) \n\ // pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value \n\ \n\ if ( texColor.a <= CC_alpha_value ) \n\ discard; \n\ \n\ gl_FragColor = texColor * v_fragmentColor; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTextureColor_frag.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTextureColor_noMVP_frag.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ attribute vec4 a_color; \n\ \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ varying mediump vec2 v_texCoord; \n\ #else \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ #endif \n\ \n\ void main() \n\ { \n\ gl_Position = CC_PMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ v_texCoord = a_texCoord; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTextureColor_vert.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ attribute vec4 a_color; \n\ \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ varying mediump vec2 v_texCoord; \n\ #else \n\ varying vec4 v_fragmentColor; \n\ varying vec2 v_texCoord; \n\ #endif \n\ \n\ void main() \n\ { \n\ gl_Position = CC_MVPMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ v_texCoord = a_texCoord; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTexture_frag.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec2 v_texCoord; \n\ uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ gl_FragColor = texture2D(CC_Texture0, v_texCoord); \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTexture_uColor_frag.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ uniform vec4 u_color; \n\ \n\ varying vec2 v_texCoord; \n\ \n\ uniform sampler2D CC_Texture0; \n\ \n\ void main() \n\ { \n\ gl_FragColor = texture2D(CC_Texture0, v_texCoord) * u_color; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTexture_uColor_vert.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ \n\ #ifdef GL_ES \n\ varying mediump vec2 v_texCoord; \n\ #else \n\ varying vec2 v_texCoord; \n\ #endif \n\ \n\ void main() \n\ { \n\ gl_Position = CC_MVPMatrix * a_position; \n\ v_texCoord = a_texCoord; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_PositionTexture_vert.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ attribute vec4 a_position; \n\ attribute vec2 a_texCoord; \n\ \n\ #ifdef GL_ES \n\ varying mediump vec2 v_texCoord; \n\ #else \n\ varying vec2 v_texCoord; \n\ #endif \n\ \n\ void main() \n\ { \n\ gl_Position = CC_MVPMatrix * a_position; \n\ v_texCoord = a_texCoord; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_Position_uColor_frag.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ #ifdef GL_ES \n\ precision lowp float; \n\ #endif \n\ \n\ varying vec4 v_fragmentColor; \n\ \n\ void main() \n\ { \n\ gl_FragColor = v_fragmentColor; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShader_Position_uColor_vert.h ================================================ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * * Copyright (c) 2011 Ricardo Quesada * Copyright (c) 2012 Zynga Inc. * * 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. */ " \n\ attribute vec4 a_position; \n\ uniform vec4 u_color; \n\ uniform float u_pointSize; \n\ \n\ #ifdef GL_ES \n\ varying lowp vec4 v_fragmentColor; \n\ #else \n\ varying vec4 v_fragmentColor; \n\ #endif \n\ \n\ void main() \n\ { \n\ gl_Position = CC_MVPMatrix * a_position; \n\ gl_PointSize = u_pointSize; \n\ v_fragmentColor = u_color; \n\ } \n\ "; ================================================ FILE: cocos2d/cocos/2d/ccShaders.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Zynga Inc. Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ccShaders.h" NS_CC_BEGIN // const GLchar * ccPosition_uColor_frag = #include "ccShader_Position_uColor_frag.h" const GLchar * ccPosition_uColor_vert = #include "ccShader_Position_uColor_vert.h" // const GLchar * ccPositionColor_frag = #include "ccShader_PositionColor_frag.h" const GLchar * ccPositionColor_vert = #include "ccShader_PositionColor_vert.h" // const GLchar * ccPositionTexture_frag = #include "ccShader_PositionTexture_frag.h" const GLchar * ccPositionTexture_vert = #include "ccShader_PositionTexture_vert.h" // const GLchar * ccPositionTextureA8Color_frag = #include "ccShader_PositionTextureA8Color_frag.h" const GLchar * ccPositionTextureA8Color_vert = #include "ccShader_PositionTextureA8Color_vert.h" // const GLchar * ccPositionTextureColor_frag = #include "ccShader_PositionTextureColor_frag.h" const GLchar * ccPositionTextureColor_vert = #include "ccShader_PositionTextureColor_vert.h" // const GLchar * ccPositionTextureColor_noMVP_frag = #include "ccShader_PositionTextureColor_noMVP_frag.h" const GLchar * ccPositionTextureColor_noMVP_vert = #include "ccShader_PositionTextureColor_noMVP_vert.h" // const GLchar * ccPositionTextureColorAlphaTest_frag = #include "ccShader_PositionTextureColorAlphaTest_frag.h" // const GLchar * ccPositionTexture_uColor_frag = #include "ccShader_PositionTexture_uColor_frag.h" const GLchar * ccPositionTexture_uColor_vert = #include "ccShader_PositionTexture_uColor_vert.h" const GLchar * ccExSwitchMask_frag = #include "ccShaderEx_SwitchMask_frag.h" const GLchar * ccPositionColorLengthTexture_frag = #include "ccShader_PositionColorLengthTexture_frag.h" const GLchar * ccPositionColorLengthTexture_vert = #include "ccShader_PositionColorLengthTexture_vert.h" const GLchar * ccLabelDistanceFieldNormal_frag = #include "ccShader_Label_frag.h" const GLchar * ccLabelDistanceFieldNormal_vert = #include "ccShader_Label_vert.h" const GLchar * ccLabelDistanceFieldGlow_frag = #include "ccShader_Label_frag_glow.h" const GLchar * ccLabelDistanceFieldGlow_vert = #include "ccShader_Label_vert.h" const GLchar * ccLabelDistanceFieldOutline_frag = #include "ccShader_Label_frag_outline.h" const GLchar * ccLabelDistanceFieldOutline_vert = #include "ccShader_Label_vert.h" const GLchar * ccLabelDistanceFieldShadow_frag = #include "ccShader_Label_frag_shadow.h" const GLchar * ccLabelDistanceFieldShadow_vert = #include "ccShader_Label_vert.h" NS_CC_END ================================================ FILE: cocos2d/cocos/2d/ccShaders.h ================================================ /**************************************************************************** Copyright (c) 2011 Zynga Inc. Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCSHADER_H__ #define __CCSHADER_H__ #include "CCGL.h" #include "CCPlatformMacros.h" NS_CC_BEGIN /** * @addtogroup shaders * @{ */ extern CC_DLL const GLchar * ccPosition_uColor_frag; extern CC_DLL const GLchar * ccPosition_uColor_vert; extern CC_DLL const GLchar * ccPositionColor_frag; extern CC_DLL const GLchar * ccPositionColor_vert; extern CC_DLL const GLchar * ccPositionTexture_frag; extern CC_DLL const GLchar * ccPositionTexture_vert; extern CC_DLL const GLchar * ccPositionTextureA8Color_frag; extern CC_DLL const GLchar * ccPositionTextureA8Color_vert; extern CC_DLL const GLchar * ccPositionTextureColor_frag; extern CC_DLL const GLchar * ccPositionTextureColor_vert; extern CC_DLL const GLchar * ccPositionTextureColor_noMVP_frag; extern CC_DLL const GLchar * ccPositionTextureColor_noMVP_vert; extern CC_DLL const GLchar * ccPositionTextureColorAlphaTest_frag; extern CC_DLL const GLchar * ccPositionTexture_uColor_frag; extern CC_DLL const GLchar * ccPositionTexture_uColor_vert; extern CC_DLL const GLchar * ccPositionColorLengthTexture_frag; extern CC_DLL const GLchar * ccPositionColorLengthTexture_vert; extern CC_DLL const GLchar * ccLabelDistanceFieldNormal_frag; extern CC_DLL const GLchar * ccLabelDistanceFieldNormal_vert; extern CC_DLL const GLchar * ccLabelDistanceFieldGlow_frag; extern CC_DLL const GLchar * ccLabelDistanceFieldGlow_vert; extern CC_DLL const GLchar * ccLabelDistanceFieldOutline_frag; extern CC_DLL const GLchar * ccLabelDistanceFieldOutline_vert; extern CC_DLL const GLchar * ccLabelDistanceFieldShadow_frag; extern CC_DLL const GLchar * ccLabelDistanceFieldShadow_vert; extern CC_DLL const GLchar * ccExSwitchMask_frag; // end of shaders group /// @} NS_CC_END #endif /* __CCSHADER_H__ */ ================================================ FILE: cocos2d/cocos/2d/ccTypes.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ccTypes.h" NS_CC_BEGIN const std::string STD_STRING_EMPTY(""); /** * Color3B */ Color3B::Color3B() : r(0) , g(0) , b(0) {} Color3B::Color3B(GLubyte _r, GLubyte _g, GLubyte _b) : r(_r) , g(_g) , b(_b) {} Color3B::Color3B(const Color4B& color) : r(color.r) , g(color.g) , b(color.b) {} Color3B::Color3B(const Color4F& color) : r(color.r * 255.0f) , g(color.g * 255.0f) , b(color.b * 255.0f) {} bool Color3B::operator==(const Color3B& right) const { return (r == right.r && g == right.g && b == right.b); } bool Color3B::operator==(const Color4B& right) const { return (r == right.r && g == right.g && b == right.b && 255 == right.a); } bool Color3B::operator==(const Color4F& right) const { return (right.a == 1.0f && Color4F(*this) == right); } bool Color3B::operator!=(const Color3B& right) const { return !(*this == right); } bool Color3B::operator!=(const Color4B& right) const { return !(*this == right); } bool Color3B::operator!=(const Color4F& right) const { return !(*this == right); } /** * Color4B */ Color4B::Color4B() : r(0) , g(0) , b(0) , a(0) {} Color4B::Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a) : r(_r) , g(_g) , b(_b) , a(_a) {} Color4B::Color4B(const Color3B& color) : r(color.r) , g(color.g) , b(color.b) , a(255) {} Color4B::Color4B(const Color4F& color) : r(color.r * 255) , g(color.g * 255) , b(color.b * 255) , a(color.a * 255) {} bool Color4B::operator==(const Color4B& right) const { return (r == right.r && g == right.g && b == right.b && a == right.a); } bool Color4B::operator==(const Color3B& right) const { return (r == right.r && g == right.g && b == right.b && a == 255); } bool Color4B::operator==(const Color4F& right) const { return (*this == Color4B(right)); } bool Color4B::operator!=(const Color4B& right) const { return !(*this == right); } bool Color4B::operator!=(const Color3B& right) const { return !(*this == right); } bool Color4B::operator!=(const Color4F& right) const { return !(*this == right); } /** * Color4F */ Color4F::Color4F() : r(0.0f) , g(0.0f) , b(0.0f) , a(0.0f) {} Color4F::Color4F(float _r, float _g, float _b, float _a) : r(_r) , g(_g) , b(_b) , a(_a) {} Color4F::Color4F(const Color3B& color) : r(color.r / 255.0f) , g(color.g / 255.0f) , b(color.b / 255.0f) , a(1.0f) {} Color4F::Color4F(const Color4B& color) : r(color.r / 255.0f) , g(color.g / 255.0f) , b(color.b / 255.0f) , a(color.a / 255.0f) {} bool Color4F::operator==(const Color4F& right) const { return (r == right.r && g == right.g && b == right.b && a == right.a); } bool Color4F::operator==(const Color3B& right) const { return (a == 1.0f && Color3B(*this) == right); } bool Color4F::operator==(const Color4B& right) const { return (*this == Color4F(right)); } bool Color4F::operator!=(const Color4F& right) const { return !(*this == right); } bool Color4F::operator!=(const Color3B& right) const { return !(*this == right); } bool Color4F::operator!=(const Color4B& right) const { return !(*this == right); } /** * Color constants */ const Color3B Color3B::WHITE (255, 255, 255); const Color3B Color3B::YELLOW (255, 255, 0); const Color3B Color3B::GREEN ( 0, 255, 0); const Color3B Color3B::BLUE ( 0, 0, 255); const Color3B Color3B::RED (255, 0, 0); const Color3B Color3B::MAGENTA(255, 0, 255); const Color3B Color3B::BLACK ( 0, 0, 0); const Color3B Color3B::ORANGE (255, 127, 0); const Color3B Color3B::GRAY (166, 166, 166); const Color4B Color4B::WHITE (255, 255, 255, 255); const Color4B Color4B::YELLOW (255, 255, 0, 255); const Color4B Color4B::GREEN ( 0, 255, 0, 255); const Color4B Color4B::BLUE ( 0, 0, 255, 255); const Color4B Color4B::RED (255, 0, 0, 255); const Color4B Color4B::MAGENTA(255, 0, 255, 255); const Color4B Color4B::BLACK ( 0, 0, 0, 255); const Color4B Color4B::ORANGE (255, 127, 0, 255); const Color4B Color4B::GRAY (166, 166, 166, 255); const Color4F Color4F::WHITE ( 1, 1, 1, 1); const Color4F Color4F::YELLOW ( 1, 1, 0, 1); const Color4F Color4F::GREEN ( 0, 1, 0, 1); const Color4F Color4F::BLUE ( 0, 0, 1, 1); const Color4F Color4F::RED ( 1, 0, 0, 1); const Color4F Color4F::MAGENTA( 1, 0, 1, 1); const Color4F Color4F::BLACK ( 0, 0, 0, 1); const Color4F Color4F::ORANGE ( 1, 0.5f, 0, 1); const Color4F Color4F::GRAY (0.65f, 0.65f, 0.65f, 1); const BlendFunc BlendFunc::DISABLE = {GL_ONE, GL_ZERO}; const BlendFunc BlendFunc::ALPHA_PREMULTIPLIED = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}; const BlendFunc BlendFunc::ALPHA_NON_PREMULTIPLIED = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; const BlendFunc BlendFunc::ADDITIVE = {GL_SRC_ALPHA, GL_ONE}; NS_CC_END ================================================ FILE: cocos2d/cocos/2d/ccTypes.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTYPES_H__ #define __CCTYPES_H__ #include #include "CCGeometry.h" #include "CCGL.h" NS_CC_BEGIN struct Color4B; struct Color4F; /** RGB color composed of bytes 3 bytes @since v3.0 */ struct Color3B { Color3B(); Color3B(GLubyte _r, GLubyte _g, GLubyte _b); explicit Color3B(const Color4B& color); explicit Color3B(const Color4F& color); bool operator==(const Color3B& right) const; bool operator==(const Color4B& right) const; bool operator==(const Color4F& right) const; bool operator!=(const Color3B& right) const; bool operator!=(const Color4B& right) const; bool operator!=(const Color4F& right) const; bool equals(const Color3B& other) { return (*this == other); } GLubyte r; GLubyte g; GLubyte b; const static Color3B WHITE; const static Color3B YELLOW; const static Color3B BLUE; const static Color3B GREEN; const static Color3B RED; const static Color3B MAGENTA; const static Color3B BLACK; const static Color3B ORANGE; const static Color3B GRAY; }; /** RGBA color composed of 4 bytes @since v3.0 */ struct Color4B { Color4B(); Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a); explicit Color4B(const Color3B& color); explicit Color4B(const Color4F& color); bool operator==(const Color4B& right) const; bool operator==(const Color3B& right) const; bool operator==(const Color4F& right) const; bool operator!=(const Color4B& right) const; bool operator!=(const Color3B& right) const; bool operator!=(const Color4F& right) const; GLubyte r; GLubyte g; GLubyte b; GLubyte a; const static Color4B WHITE; const static Color4B YELLOW; const static Color4B BLUE; const static Color4B GREEN; const static Color4B RED; const static Color4B MAGENTA; const static Color4B BLACK; const static Color4B ORANGE; const static Color4B GRAY; }; /** RGBA color composed of 4 floats @since v3.0 */ struct Color4F { Color4F(); Color4F(float _r, float _g, float _b, float _a); explicit Color4F(const Color3B& color); explicit Color4F(const Color4B& color); bool operator==(const Color4F& right) const; bool operator==(const Color3B& right) const; bool operator==(const Color4B& right) const; bool operator!=(const Color4F& right) const; bool operator!=(const Color3B& right) const; bool operator!=(const Color4B& right) const; bool equals(const Color4F &other) { return (*this == other); } GLfloat r; GLfloat g; GLfloat b; GLfloat a; const static Color4F WHITE; const static Color4F YELLOW; const static Color4F BLUE; const static Color4F GREEN; const static Color4F RED; const static Color4F MAGENTA; const static Color4F BLACK; const static Color4F ORANGE; const static Color4F GRAY; }; /** A vertex composed of 2 floats: x, y @since v3.0 */ struct Vertex2F { Vertex2F(float _x, float _y) :x(_x), y(_y) {} Vertex2F(): x(0.f), y(0.f) {} GLfloat x; GLfloat y; }; /** A vertex composed of 2 floats: x, y @since v3.0 */ struct Vertex3F { Vertex3F(float _x, float _y, float _z) : x(_x) , y(_y) , z(_z) {} Vertex3F(): x(0.f), y(0.f), z(0.f) {} GLfloat x; GLfloat y; GLfloat z; }; /** A texcoord composed of 2 floats: u, y @since v3.0 */ struct Tex2F { Tex2F(float _u, float _v): u(_u), v(_v) {} Tex2F(): u(0.f), v(0.f) {} GLfloat u; GLfloat v; }; //! Point Sprite component struct PointSprite { Vertex2F pos; // 8 bytes Color4B color; // 4 bytes GLfloat size; // 4 bytes }; //! A 2D Quad. 4 * 2 floats struct Quad2 { Vertex2F tl; Vertex2F tr; Vertex2F bl; Vertex2F br; }; //! A 3D Quad. 4 * 3 floats struct Quad3 { Vertex3F bl; Vertex3F br; Vertex3F tl; Vertex3F tr; }; //! a Point with a vertex point, a tex coord point and a color 4B struct V2F_C4B_T2F { //! vertices (2F) Vertex2F vertices; //! colors (4B) Color4B colors; //! tex coords (2F) Tex2F texCoords; }; //! a Point with a vertex point, a tex coord point and a color 4F struct V2F_C4F_T2F { //! vertices (2F) Vertex2F vertices; //! colors (4F) Color4F colors; //! tex coords (2F) Tex2F texCoords; }; //! a Point with a vertex point, a tex coord point and a color 4B struct V3F_C4B_T2F { //! vertices (3F) Vertex3F vertices; // 12 bytes //! colors (4B) Color4B colors; // 4 bytes // tex coords (2F) Tex2F texCoords; // 8 bytes }; //! A Triangle of V2F_C4B_T2F struct V2F_C4B_T2F_Triangle { //! Point A V2F_C4B_T2F a; //! Point B V2F_C4B_T2F b; //! Point B V2F_C4B_T2F c; }; //! A Quad of V2F_C4B_T2F struct V2F_C4B_T2F_Quad { //! bottom left V2F_C4B_T2F bl; //! bottom right V2F_C4B_T2F br; //! top left V2F_C4B_T2F tl; //! top right V2F_C4B_T2F tr; }; //! 4 Vertex3FTex2FColor4B struct V3F_C4B_T2F_Quad { //! top left V3F_C4B_T2F tl; //! bottom left V3F_C4B_T2F bl; //! top right V3F_C4B_T2F tr; //! bottom right V3F_C4B_T2F br; }; //! 4 Vertex2FTex2FColor4F Quad struct V2F_C4F_T2F_Quad { //! bottom left V2F_C4F_T2F bl; //! bottom right V2F_C4F_T2F br; //! top left V2F_C4F_T2F tl; //! top right V2F_C4F_T2F tr; }; //! Blend Function used for textures struct BlendFunc { //! source blend function GLenum src; //! destination blend function GLenum dst; //! Blending disabled. Uses {GL_ONE, GL_ZERO} const static BlendFunc DISABLE; //! Blending enabled for textures with Alpha premultiplied. Uses {GL_ONE, GL_ONE_MINUS_SRC_ALPHA} const static BlendFunc ALPHA_PREMULTIPLIED; //! Blending enabled for textures with Alpha NON premultiplied. Uses {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA} const static BlendFunc ALPHA_NON_PREMULTIPLIED; //! Enables Additive blending. Uses {GL_SRC_ALPHA, GL_ONE} const static BlendFunc ADDITIVE; bool operator==(const BlendFunc &a) const { return src == a.src && dst == a.dst; } bool operator<(const BlendFunc &a) const { return src < a.src || (src < a.src && dst < a.dst); } }; // Label::VAlignment // Label::HAlignment // XXX: If any of these enums are edited and/or reordered, update Texture2D.m //! Vertical text alignment type enum class TextVAlignment { TOP, CENTER, BOTTOM, }; // XXX: If any of these enums are edited and/or reordered, update Texture2D.m //! Horizontal text alignment type enum class TextHAlignment { LEFT, CENTER, RIGHT, }; // types for animation in particle systems // texture coordinates for a quad struct T2F_Quad { //! bottom left Tex2F bl; //! bottom right Tex2F br; //! top left Tex2F tl; //! top right Tex2F tr; }; // struct that holds the size in pixels, texture coordinates and delays for animated ParticleSystemQuad struct AnimationFrameData { T2F_Quad texCoords; float delay; Size size; }; /** types used for defining fonts properties (i.e. font name, size, stroke or shadow) */ // shadow attributes struct FontShadow { public: // shadow is not enabled by default FontShadow() : _shadowEnabled(false) , _shadowBlur(0) , _shadowOpacity(0) {} // true if shadow enabled bool _shadowEnabled; // shadow x and y offset Size _shadowOffset; // shadow blurrines float _shadowBlur; // shadow opacity float _shadowOpacity; }; // stroke attributes struct FontStroke { public: // stroke is disabled by default FontStroke() : _strokeEnabled(false) , _strokeColor(Color3B::BLACK) , _strokeSize(0) {} // true if stroke enabled bool _strokeEnabled; // stroke color Color3B _strokeColor; // stroke size float _strokeSize; }; // font attributes struct FontDefinition { public: /** * @js NA * @lua NA */ FontDefinition() : _fontSize(0) , _alignment(TextHAlignment::CENTER) , _vertAlignment(TextVAlignment::TOP) , _dimensions(Size::ZERO) , _fontFillColor(Color3B::WHITE) {} // font name std::string _fontName; // font size int _fontSize; // horizontal alignment TextHAlignment _alignment; // vertical alignment TextVAlignment _vertAlignment; // renering box Size _dimensions; // font color Color3B _fontFillColor; // font shadow FontShadow _shadow; // font stroke FontStroke _stroke; }; /** @brief The device accelerometer reports values for each axis in units of g-force */ class Acceleration { public: double x; double y; double z; double timestamp; Acceleration(): x(0), y(0), z(0), timestamp(0) {} }; extern const std::string STD_STRING_EMPTY; NS_CC_END #endif //__CCTYPES_H__ ================================================ FILE: cocos2d/cocos/2d/ccUTF8.cpp ================================================ /* * This file uses some implementations of gutf8.c in glib. * * gutf8.c - Operations on UTF-8 strings. * * Copyright (C) 1999 Tom Tromey * Copyright (C) 2000 Red Hat, Inc. * Copyright (c) 2013-2014 Chukong Technologies Inc. * * 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; either * version 2 of the License, or (at your option) any later version. * * 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "ccUTF8.h" #include "platform/CCCommon.h" #include "CCConsole.h" NS_CC_BEGIN int cc_wcslen(const unsigned short* str) { int i=0; while(*str++) i++; return i; } /* Code from GLIB gutf8.c starts here. */ #define UTF8_COMPUTE(Char, Mask, Len) \ if (Char < 128) \ { \ Len = 1; \ Mask = 0x7f; \ } \ else if ((Char & 0xe0) == 0xc0) \ { \ Len = 2; \ Mask = 0x1f; \ } \ else if ((Char & 0xf0) == 0xe0) \ { \ Len = 3; \ Mask = 0x0f; \ } \ else if ((Char & 0xf8) == 0xf0) \ { \ Len = 4; \ Mask = 0x07; \ } \ else if ((Char & 0xfc) == 0xf8) \ { \ Len = 5; \ Mask = 0x03; \ } \ else if ((Char & 0xfe) == 0xfc) \ { \ Len = 6; \ Mask = 0x01; \ } \ else \ Len = -1; #define UTF8_LENGTH(Char) \ ((Char) < 0x80 ? 1 : \ ((Char) < 0x800 ? 2 : \ ((Char) < 0x10000 ? 3 : \ ((Char) < 0x200000 ? 4 : \ ((Char) < 0x4000000 ? 5 : 6))))) #define UTF8_GET(Result, Chars, Count, Mask, Len) \ (Result) = (Chars)[0] & (Mask); \ for ((Count) = 1; (Count) < (Len); ++(Count)) \ { \ if (((Chars)[(Count)] & 0xc0) != 0x80) \ { \ (Result) = -1; \ break; \ } \ (Result) <<= 6; \ (Result) |= ((Chars)[(Count)] & 0x3f); \ } #define UNICODE_VALID(Char) \ ((Char) < 0x110000 && \ (((Char) & 0xFFFFF800) != 0xD800) && \ ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ ((Char) & 0xFFFE) != 0xFFFE) static const char utf8_skip_data[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1 }; static const char *const g_utf8_skip = utf8_skip_data; #define cc_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(unsigned char *)(p)]) /* * @str: the string to search through. * @c: the character to not look for. * * Return value: the index of the last character that is not c. * */ unsigned int cc_utf8_find_last_not_char(std::vector str, unsigned short c) { int len = static_cast(str.size()); int i = len - 1; for (; i >= 0; --i) if (str[i] != c) return i; return i; } /* * @str: the string to trim * @index: the index to start trimming from. * * Trims str st str=[0, index) after the operation. * * Return value: the trimmed string. * */ static void cc_utf8_trim_from(std::vector* str, int index) { int size = static_cast(str->size()); if (index >= size || index < 0) return; str->erase(str->begin() + index, str->begin() + size); } /* * @ch is the unicode character whitespace? * * Reference: http://en.wikipedia.org/wiki/Whitespace_character#Unicode * * Return value: weather the character is a whitespace character. * */ bool isspace_unicode(unsigned short ch) { return (ch >= 0x0009 && ch <= 0x000D) || ch == 0x0020 || ch == 0x0085 || ch == 0x00A0 || ch == 0x1680 || (ch >= 0x2000 && ch <= 0x200A) || ch == 0x2028 || ch == 0x2029 || ch == 0x202F || ch == 0x205F || ch == 0x3000; } void cc_utf8_trim_ws(std::vector* str) { int len = static_cast(str->size()); if ( len <= 0 ) return; int last_index = len - 1; // Only start trimming if the last character is whitespace.. if (isspace_unicode((*str)[last_index])) { for (int i = last_index - 1; i >= 0; --i) { if (isspace_unicode((*str)[i])) last_index = i; else break; } cc_utf8_trim_from(str, last_index); } } /* * cc_utf8_strlen: * @p: pointer to the start of a UTF-8 encoded string. * @max: the maximum number of bytes to examine. If @max * is less than 0, then the string is assumed to be * null-terminated. If @max is 0, @p will not be examined and * may be %nullptr. * * Returns the length of the string in characters. * * Return value: the length of the string in characters **/ long cc_utf8_strlen (const char * p, int max) { long len = 0; const char *start = p; if (!(p != nullptr || max == 0)) { return 0; } if (max < 0) { while (*p) { p = cc_utf8_next_char (p); ++len; } } else { if (max == 0 || !*p) return 0; p = cc_utf8_next_char (p); while (p - start < max && *p) { ++len; p = cc_utf8_next_char (p); } /* only do the last len increment if we got a complete * char (don't count partial chars) */ if (p - start == max) ++len; } return len; } /* * g_utf8_get_char: * @p: a pointer to Unicode character encoded as UTF-8 * * Converts a sequence of bytes encoded as UTF-8 to a Unicode character. * If @p does not point to a valid UTF-8 encoded character, results are * undefined. If you are not sure that the bytes are complete * valid Unicode characters, you should use g_utf8_get_char_validated() * instead. * * Return value: the resulting character **/ static unsigned int cc_utf8_get_char (const char * p) { int i, mask = 0, len; unsigned int result; unsigned char c = (unsigned char) *p; UTF8_COMPUTE (c, mask, len); if (len == -1) return (unsigned int) - 1; UTF8_GET (result, p, i, mask, len); return result; } unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1 */, int* rUtf16Size/* = nullptr */) { long len = cc_utf8_strlen(str_old, length); if (rUtf16Size != nullptr) { *rUtf16Size = static_cast(len); } unsigned short* str_new = new unsigned short[len + 1]; str_new[len] = 0; for (int i = 0; i < len; ++i) { str_new[i] = cc_utf8_get_char(str_old); str_old = cc_utf8_next_char(str_old); } return str_new; } std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str) { int len = cc_wcslen(str); std::vector str_new; for (int i = 0; i < len; ++i) { str_new.push_back(str[i]); } return str_new; } /** * cc_unichar_to_utf8: * @c: a ISO10646 character code * @outbuf: output buffer, must have at least 6 bytes of space. * If %nullptr, the length will be computed and returned * and nothing will be written to @outbuf. * * Converts a single character to UTF-8. * * Return value: number of bytes written **/ int cc_unichar_to_utf8 (unsigned int c, char *outbuf) { int len = 0; int first; int i; if (c < 0x80) { first = 0; len = 1; } else if (c < 0x800) { first = 0xc0; len = 2; } else if (c < 0x10000) { first = 0xe0; len = 3; } else if (c < 0x200000) { first = 0xf0; len = 4; } else if (c < 0x4000000) { first = 0xf8; len = 5; } else { first = 0xfc; len = 6; } if (outbuf) { for (i = len - 1; i > 0; --i) { outbuf[i] = (c & 0x3f) | 0x80; c >>= 6; } outbuf[0] = c | first; } return len; } #define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000) /** * cc_utf16_to_utf8: * @str: a UTF-16 encoded string * @len: the maximum length of @str to use. If @len < 0, then * the string is terminated with a 0 character. * @items_read: location to store number of words read, or %nullptr. * If %nullptr, then %G_CONVERT_ERROR_PARTIAL_INPUT will be * returned in case @str contains a trailing partial * character. If an error occurs then the index of the * invalid input is stored here. * @items_written: location to store number of bytes written, or %nullptr. * The value stored here does not include the trailing * 0 byte. * @error: location to store the error occuring, or %nullptr to ignore * errors. Any of the errors in #GConvertError other than * %G_CONVERT_ERROR_NO_CONVERSION may occur. * * Convert a string from UTF-16 to UTF-8. The result will be * terminated with a 0 byte. * * Return value: a pointer to a newly allocated UTF-8 string. * This value must be freed with free(). If an * error occurs, %nullptr will be returned and * @error set. **/ char * cc_utf16_to_utf8 (const unsigned short *str, int len, long *items_read, long *items_written) { /* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ * are marked. */ const unsigned short *in; char *out; char *result = nullptr; int n_bytes; unsigned int high_surrogate; if (str == 0) return nullptr; n_bytes = 0; in = str; high_surrogate = 0; while ((len < 0 || in - str < len) && *in) { unsigned short c = *in; unsigned int wc; if (c >= 0xdc00 && c < 0xe000) /* low surrogate */ { if (high_surrogate) { wc = SURROGATE_VALUE (high_surrogate, c); high_surrogate = 0; } else { CCLOGERROR("Invalid sequence in conversion input"); goto err_out; } } else { if (high_surrogate) { CCLOGERROR("Invalid sequence in conversion input"); goto err_out; } if (c >= 0xd800 && c < 0xdc00) /* high surrogate */ { high_surrogate = c; goto next1; } else wc = c; } /********** DIFFERENT for UTF8/UCS4 **********/ n_bytes += UTF8_LENGTH (wc); next1: in++; } if (high_surrogate && !items_read) { CCLOGERROR("Partial character sequence at end of input"); goto err_out; } /* At this point, everything is valid, and we just need to convert */ /********** DIFFERENT for UTF8/UCS4 **********/ result = new char[n_bytes + 1]; high_surrogate = 0; out = result; in = str; while (out < result + n_bytes) { unsigned short c = *in; unsigned int wc; if (c >= 0xdc00 && c < 0xe000) /* low surrogate */ { wc = SURROGATE_VALUE (high_surrogate, c); high_surrogate = 0; } else if (c >= 0xd800 && c < 0xdc00) /* high surrogate */ { high_surrogate = c; goto next2; } else wc = c; /********** DIFFERENT for UTF8/UCS4 **********/ out += cc_unichar_to_utf8 (wc, out); next2: in++; } /********** DIFFERENT for UTF8/UCS4 **********/ *out = '\0'; if (items_written) /********** DIFFERENT for UTF8/UCS4 **********/ *items_written = out - result; err_out: if (items_read) *items_read = in - str; return result; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/ccUTF8.h ================================================ /* * Copyright (C) 1999 Tom Tromey * Copyright (C) 2000 Red Hat, Inc. * Copyright (c) 2013-2014 Chukong Technologies Inc. * * 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; either * version 2 of the License, or (at your option) any later version. * * 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef __cocos2dx__ccUTF8__ #define __cocos2dx__ccUTF8__ #include "CCPlatformMacros.h" #include NS_CC_BEGIN CC_DLL int cc_wcslen(const unsigned short* str); CC_DLL void cc_utf8_trim_ws(std::vector* str); /** * Whether the character is a whitespace character. * * @param ch the unicode character * @returns whether the character is a white space character. * * @see http://en.wikipedia.org/wiki/Whitespace_character#Unicode * */ CC_DLL bool isspace_unicode(unsigned short ch); /** * Returns the length of the string in characters. * * @param p pointer to the start of a UTF-8 encoded string. * @param max the maximum number of bytes to examine. If \p max is less than * 0, then the string is assumed to be null-terminated. If \p max * is 0, \p p will not be examined and my be %nullptr. * * @returns the length of the string in characters **/ CC_DLL long cc_utf8_strlen (const char * p, int max); /** * Find the last character that is not equal to the character given. * * @param str the string to be searched. * @param c the character to be searched for. * * @returns the index of the last character that is not \p c. * */ CC_DLL unsigned int cc_utf8_find_last_not_char(std::vector str, unsigned short c); CC_DLL std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str); /** * Creates a utf8 string from a cstring. * * @param str_old pointer to the start of a C string. * * @returns the newly created utf8 string. * */ CC_DLL unsigned short* cc_utf8_to_utf16(const char* str_old, int length = -1, int* rUtf16Size = nullptr); /** * Convert a string from UTF-16 to UTF-8. The result will be null terminated. * * @param str a UTF-16 encoded string * @param len the maximum length of \p str to use. If \p len < 0, then the * string is null terminated. * @param items_read location to store number of words read, or %nullptr. * If %nullptr, then %G_CONVERT_ERROR_PARTIAL_INPUT will be * returned in case \p str contains a trailing partial * character. If an error occurs then the index of the * invalid input is stored here. * @param items_written location to store number of bytes written, or %nullptr. * The value stored here does not include the trailing null. * * @returns a pointer to a newly allocated UTF-8 string. This value must be * freed with free(). If an error occurs, %nullptr will be returned. **/ CC_DLL char * cc_utf16_to_utf8 (const unsigned short *str, int len, long *items_read, long *items_written); NS_CC_END #endif /* defined(__cocos2dx__ccUTF8__) */ ================================================ FILE: cocos2d/cocos/2d/ccUtils.cpp ================================================ /**************************************************************************** Copyright (c) 2010 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ccUtils.h" namespace cocos2d { int ccNextPOT(int x) { x = x - 1; x = x | (x >> 1); x = x | (x >> 2); x = x | (x >> 4); x = x | (x >> 8); x = x | (x >>16); return x + 1; } } ================================================ FILE: cocos2d/cocos/2d/ccUtils.h ================================================ /**************************************************************************** Copyright (c) 2010 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SUPPORT_CC_UTILS_H__ #define __SUPPORT_CC_UTILS_H__ /** @file ccUtils.h Misc free functions */ namespace cocos2d { /* ccNextPOT function is licensed under the same license that is used in Texture2D.m. */ /** returns the Next Power of Two value. Examples: - If "value" is 15, it will return 16. - If "value" is 16, it will return 16. - If "value" is 17, it will return 32. @since v0.99.5 */ int ccNextPOT(int value); } #endif // __SUPPORT_CC_UTILS_H__ ================================================ FILE: cocos2d/cocos/2d/cocos2d.cpp ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCPlatformMacros.h" NS_CC_BEGIN const char* cocos2dVersion() { return "3.0-beta2"; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/cocos2d.h ================================================ /**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __COCOS2D_H__ #define __COCOS2D_H__ // 0x00 HI ME LO // 00 03 00 00 #define COCOS2D_VERSION 0x00030000 // // all cocos2d include files // #include "ccConfig.h" // actions #include "CCAction.h" #include "CCActionInterval.h" #include "CCActionCamera.h" #include "CCActionManager.h" #include "CCActionEase.h" #include "CCActionPageTurn3D.h" #include "CCActionGrid.h" #include "CCActionProgressTimer.h" #include "CCActionGrid3D.h" #include "CCActionTiledGrid.h" #include "CCActionInstant.h" #include "CCActionTween.h" #include "CCActionCatmullRom.h" // base_nodes #include "CCNode.h" #include "CCAtlasNode.h" // cocoa #include "CCAffineTransform.h" #include "CCDictionary.h" #include "CCObject.h" #include "CCArray.h" #include "CCVector.h" #include "CCMap.h" #include "CCGeometry.h" #include "CCSet.h" #include "CCAutoreleasePool.h" #include "CCInteger.h" #include "CCFloat.h" #include "CCDouble.h" #include "CCBool.h" #include "CCString.h" #include "CCNS.h" #include "CCData.h" #include "CCValue.h" // draw nodes #include "CCDrawingPrimitives.h" #include "CCDrawNode.h" // effects #include "CCGrabber.h" #include "CCGrid.h" // include #include "CCEventType.h" #include "CCProtocols.h" #include "ccConfig.h" #include "ccMacros.h" #include "ccTypes.h" // label_nodes #include "CCLabelAtlas.h" #include "CCLabelTTF.h" #include "CCLabelBMFont.h" #include "CCLabel.h" // layers_scenes_transitions_nodes #include "CCLayer.h" #include "CCScene.h" #include "CCTransition.h" #include "CCTransitionPageTurn.h" #include "CCTransitionProgress.h" // menu_nodes #include "CCMenu.h" #include "CCMenuItem.h" // misc_nodes #include "CCClippingNode.h" #include "CCMotionStreak.h" #include "CCProgressTimer.h" #include "CCRenderTexture.h" #include "CCNodeGrid.h" // particle_nodes #include "CCParticleBatchNode.h" #include "CCParticleSystem.h" #include "CCParticleExamples.h" #include "CCParticleSystemQuad.h" // new renderer #include "renderer/CCCustomCommand.h" #include "renderer/CCFrustum.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCMaterialManager.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCRenderCommand.h" #include "renderer/CCRenderCommandPool.h" #include "renderer/CCRenderMaterial.h" #include "renderer/CCRenderer.h" // physics #include "CCPhysicsBody.h" #include "CCPhysicsContact.h" #include "CCPhysicsShape.h" #include "CCPhysicsJoint.h" #include "CCPhysicsWorld.h" // kazmath #include "kazmath/kazmath.h" #include "kazmath/GL/matrix.h" // platform #include "platform/CCDevice.h" #include "platform/CCCommon.h" #include "platform/CCFileUtils.h" #include "platform/CCImage.h" #include "platform/CCSAXParser.h" #include "platform/CCThread.h" #include "CCPlatformConfig.h" #include "CCPlatformMacros.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #include "platform/ios/CCApplication.h" #include "platform/ios/CCEGLView.h" #include "platform/ios/CCGL.h" #include "platform/ios/CCStdC.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/CCApplication.h" #include "platform/android/CCEGLView.h" #include "platform/android/CCGL.h" #include "platform/android/CCStdC.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #if (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY) #include "platform/blackberry/CCApplication.h" #include "platform/blackberry/CCEGLView.h" #include "platform/blackberry/CCGL.h" #include "platform/blackberry/CCStdC.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "platform/win32/CCApplication.h" #include "platform/desktop/CCEGLView.h" #include "platform/win32/CCGL.h" #include "platform/win32/CCStdC.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #include "platform/mac/CCApplication.h" #include "platform/desktop/CCEGLView.h" #include "platform/mac/CCGL.h" #include "platform/mac/CCStdC.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC #if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) #include "platform/linux/CCApplication.h" #include "platform/desktop/CCEGLView.h" #include "platform/linux/CCGL.h" #include "platform/linux/CCStdC.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX // script_support #include "CCScriptSupport.h" // shaders #include "CCGLProgram.h" #include "ccGLStateCache.h" #include "CCShaderCache.h" #include "ccShaders.h" // sprite_nodes #include "CCAnimation.h" #include "CCAnimationCache.h" #include "CCSprite.h" #include "CCSpriteBatchNode.h" #include "CCSpriteFrame.h" #include "CCSpriteFrameCache.h" // support #include "ccUTF8.h" #include "CCNotificationCenter.h" #include "CCProfiling.h" #include "CCConsole.h" #include "CCUserDefault.h" #include "CCVertex.h" // text_input_node #include "CCIMEDelegate.h" #include "CCIMEDispatcher.h" #include "CCTextFieldTTF.h" // textures #include "CCTexture2D.h" #include "CCTextureAtlas.h" #include "CCTextureCache.h" // tilemap_parallax_nodes #include "CCParallaxNode.h" #include "CCTMXLayer.h" #include "CCTMXObjectGroup.h" #include "CCTMXTiledMap.h" #include "CCTMXXMLParser.h" #include "CCTileMapAtlas.h" // EventDispatcher #include "CCEventDispatcher.h" #include "CCEventListenerTouch.h" #include "CCEventTouch.h" #include "CCEventListenerKeyboard.h" #include "CCEventKeyboard.h" #include "CCEventListenerMouse.h" #include "CCEventMouse.h" #include "CCEventAcceleration.h" #include "CCEventListenerAcceleration.h" #include "CCEventCustom.h" #include "CCEventListenerCustom.h" // root #include "CCConfiguration.h" #include "CCDirector.h" #include "CCScheduler.h" // component #include "CCComponent.h" #include "CCComponentContainer.h" // Deprecated include #include "CCDeprecated.h" NS_CC_BEGIN CC_DLL const char* cocos2dVersion(); NS_CC_END #endif // __COCOS2D_H__ ================================================ FILE: cocos2d/cocos/2d/cocos2d.vcxproj ================================================  Debug Win32 Release Win32 libcocos2d {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} cocos2d-x.win32 Win32Proj StaticLibrary Unicode v100 v110 v110_xp StaticLibrary Unicode v100 v110 v110_xp <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false AllRules.ruleset AllRules.ruleset $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) Disabled $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL Level3 OldStyle 4267;4251;4244;%(DisableSpecificWarnings) true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\freetype2\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\glfw3\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\curl\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\jpeg\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\png\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\tiff\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\webp\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\zlib\prebuilt\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\icon\prebuilt\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(OutDir)" $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) false ;%(IgnoreSpecificDefaultLibraries) true Windows $(TargetDir)$(TargetName).lib MachineX86 $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase 4267;4251;4244;%(DisableSpecificWarnings) true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\freetype2\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\glfw3\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\curl\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\jpeg\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\png\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\tiff\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\webp\prebuilt\win32\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\zlib\prebuilt\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\icon\prebuilt\*.*" "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(OutDir)" %(AdditionalDependencies) $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) ;%(IgnoreSpecificDefaultLibraries) true Windows true true $(TargetDir)$(TargetName).lib MachineX86 ================================================ FILE: cocos2d/cocos/2d/cocos2d.vcxproj.filters ================================================  {cc64f5ad-2234-494c-9c51-b7a20c8887aa} {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} {535c04b0-fe2b-44c9-9a8c-9029e2b6de5c} {5b082c5c-d396-43ca-b3b1-997d0f6247d0} {7751500e-ac9e-4604-a96d-670b30b7d8bd} {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} {47fda93e-6eb4-4abc-b5bc-725bf667a395} {3ff2746c-a91b-4b86-93b7-43a9ec14825b} {08593631-5bf5-46aa-9436-62595c4f7bf6} {aeadfa95-9c89-4212-98ae-89ad57db596a} {05e27e68-7574-4a8b-af68-553dd3bafdfa} {b797075f-7437-46d5-b4ee-2aa2c108e98f} {c755509d-1610-4e6c-b01b-e01d4d0de46e} {e1b64497-c099-4f06-8d61-9d4c6b7a215a} {7c71abeb-8b4b-4be8-a23c-e32fedc65fc9} {aec8225f-81a7-4213-b97b-7004d5535398} {cba0f362-878c-438b-ad0f-43d287516357} {32373f63-2c2d-4eab-bc4a-21745ba0b3fb} physics physics physics physics physics base_nodes base_nodes effects effects event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher kazmath\src\GL kazmath\src\GL kazmath\src kazmath\src kazmath\src kazmath\src kazmath\src kazmath\src kazmath\src kazmath\src kazmath\src kazmath\src kazmath\src 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 misc_nodes particle_nodes particle_nodes particle_nodes particle_nodes script_support actions actions actions actions actions actions actions actions actions actions actions actions actions draw_nodes draw_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes platform\etc platform\win32 platform\win32 platform\win32 platform\win32 platform\win32 platform\win32 platform platform platform platform platform platform shaders shaders shaders shaders sprite_nodes sprite_nodes sprite_nodes sprite_nodes sprite_nodes sprite_nodes text_input_node text_input_node textures textures textures tilemap_parallax_nodes tilemap_parallax_nodes tilemap_parallax_nodes tilemap_parallax_nodes tilemap_parallax_nodes tilemap_parallax_nodes support support support support support support support\component support\component support\data_support support\image_support support\tinyxml2 support\user_default support\zip_support support\zip_support support\zip_support base base base base base base base base base base base support event_dispatcher event_dispatcher physics\chipmunk physics\chipmunk physics\chipmunk physics\chipmunk physics\chipmunk base base misc_nodes label_nodes renderer renderer renderer renderer renderer renderer renderer renderer renderer label_nodes platform\desktop physics physics physics physics physics base_nodes base_nodes effects effects event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher event_dispatcher include include include include include include include 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 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 misc_nodes particle_nodes particle_nodes particle_nodes particle_nodes script_support actions actions actions actions actions actions actions actions actions actions actions actions actions draw_nodes draw_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes label_nodes platform\etc platform\win32 platform\win32 platform\win32 platform\win32 platform\win32 platform platform platform platform platform platform platform platform platform platform platform platform platform shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders shaders sprite_nodes sprite_nodes sprite_nodes sprite_nodes sprite_nodes sprite_nodes text_input_node text_input_node text_input_node textures textures textures tilemap_parallax_nodes tilemap_parallax_nodes tilemap_parallax_nodes tilemap_parallax_nodes tilemap_parallax_nodes tilemap_parallax_nodes support support support support support support support support\component support\component support\data_support support\data_support support\data_support support\image_support support\tinyxml2 support\user_default support\zip_support support\zip_support support\zip_support base base base base base base base base base base base base base base base event_dispatcher event_dispatcher physics\chipmunk physics\chipmunk physics\chipmunk physics\chipmunk physics\chipmunk physics\chipmunk base base base base misc_nodes label_nodes renderer renderer renderer renderer renderer renderer renderer renderer renderer renderer label_nodes platform\desktop ================================================ FILE: cocos2d/cocos/2d/cocos2d_headers.props ================================================  $(MSBuildThisFileDirectory)..\..\ $(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\gui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)cocos\2d\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES _VARIADIC_MAX=10;%(PreprocessorDefinitions) $(EngineRoot) true ================================================ FILE: cocos2d/cocos/2d/cocos2dx-Prefix.pch ================================================ // // Prefix header for all source files of the 'cocos2dx' target in the 'cocos2dx' project // #ifdef __OBJC__ #import #endif ================================================ FILE: cocos2d/cocos/2d/cocos2dx.props ================================================  false opengl32.lib;glew32.lib;libzlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;libwebp.lib;libiconv.lib;glfw3.lib;freetype250.lib;winmm.lib;ws2_32.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) false ================================================ FILE: cocos2d/cocos/2d/firePngData.h ================================================ const unsigned char __firePngData[] = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x08, 0x06, 0x00, 0x00, 0x00, 0x73, 0x7A, 0x7A, 0xF4, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4D, 0x41, 0x00, 0x00, 0xAF, 0xC8, 0x37, 0x05, 0x8A, 0xE9, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 0x41, 0x64, 0x6F, 0x62, 0x65, 0x20, 0x49, 0x6D, 0x61, 0x67, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x71, 0xC9, 0x65, 0x3C, 0x00, 0x00, 0x02, 0x64, 0x49, 0x44, 0x41, 0x54, 0x78, 0xDA, 0xC4, 0x97, 0x89, 0x6E, 0xEB, 0x20, 0x10, 0x45, 0xBD, 0xE1, 0x2D, 0x4B, 0xFF, 0xFF, 0x37, 0x5F, 0x5F, 0x0C, 0xD8, 0xC4, 0xAE, 0x2D, 0xDD, 0xA9, 0x6E, 0xA7, 0x38, 0xC1, 0x91, 0xAA, 0x44, 0xBA, 0xCA, 0x06, 0xCC, 0x99, 0x85, 0x01, 0xE7, 0xCB, 0xB2, 0x64, 0xEF, 0x7C, 0x55, 0x2F, 0xCC, 0x69, 0x56, 0x15, 0xAB, 0x72, 0x68, 0x81, 0xE6, 0x55, 0xFE, 0xE8, 0x62, 0x79, 0x62, 0x04, 0x36, 0xA3, 0x06, 0xC0, 0x9B, 0xCA, 0x08, 0xC0, 0x7D, 0x55, 0x80, 0xA6, 0x54, 0x98, 0x67, 0x11, 0xA8, 0xA1, 0x86, 0x3E, 0x0B, 0x44, 0x41, 0x00, 0x33, 0x19, 0x1F, 0x21, 0x43, 0x9F, 0x5F, 0x02, 0x68, 0x49, 0x1D, 0x20, 0x1A, 0x82, 0x28, 0x09, 0xE0, 0x4E, 0xC6, 0x3D, 0x64, 0x57, 0x39, 0x80, 0xBA, 0xA3, 0x00, 0x1D, 0xD4, 0x93, 0x3A, 0xC0, 0x34, 0x0F, 0x00, 0x3C, 0x8C, 0x59, 0x4A, 0x99, 0x44, 0xCA, 0xA6, 0x02, 0x88, 0xC7, 0xA7, 0x55, 0x67, 0xE8, 0x44, 0x10, 0x12, 0x05, 0x0D, 0x30, 0x92, 0xE7, 0x52, 0x33, 0x32, 0x26, 0xC3, 0x38, 0xF7, 0x0C, 0xA0, 0x06, 0x40, 0x0F, 0xC3, 0xD7, 0x55, 0x17, 0x05, 0xD1, 0x92, 0x77, 0x02, 0x20, 0x85, 0xB7, 0x19, 0x18, 0x28, 0x4D, 0x05, 0x19, 0x9F, 0xA1, 0xF1, 0x08, 0xC0, 0x05, 0x10, 0x57, 0x7C, 0x4F, 0x01, 0x10, 0xEF, 0xC5, 0xF8, 0xAC, 0x76, 0xC8, 0x2E, 0x80, 0x14, 0x99, 0xE4, 0xFE, 0x44, 0x51, 0xB8, 0x52, 0x14, 0x3A, 0x32, 0x22, 0x00, 0x13, 0x85, 0xBF, 0x52, 0xC6, 0x05, 0x8E, 0xE5, 0x63, 0x00, 0x86, 0xB6, 0x9C, 0x86, 0x38, 0xAB, 0x54, 0x74, 0x18, 0x5B, 0x50, 0x58, 0x6D, 0xC4, 0xF3, 0x89, 0x6A, 0xC3, 0x61, 0x8E, 0xD9, 0x03, 0xA8, 0x08, 0xA0, 0x55, 0xBB, 0x40, 0x40, 0x3E, 0x00, 0xD2, 0x53, 0x47, 0x94, 0x0E, 0x38, 0xD0, 0x7A, 0x73, 0x64, 0x57, 0xF0, 0x16, 0xFE, 0x95, 0x82, 0x86, 0x1A, 0x4C, 0x4D, 0xE9, 0x68, 0xD5, 0xAE, 0xB8, 0x00, 0xE2, 0x8C, 0xDF, 0x4B, 0xE4, 0xD7, 0xC1, 0xB3, 0x4C, 0x75, 0xC2, 0x36, 0xD2, 0x3F, 0x2A, 0x7C, 0xF7, 0x0C, 0x50, 0x60, 0xB1, 0x4A, 0x81, 0x18, 0x88, 0xD3, 0x22, 0x75, 0xD1, 0x63, 0x5C, 0x80, 0xF7, 0x19, 0x15, 0xA2, 0xA5, 0xB9, 0xB5, 0x5A, 0xB7, 0xA4, 0x34, 0x7D, 0x03, 0x48, 0x5F, 0x17, 0x90, 0x52, 0x01, 0x19, 0x95, 0x9E, 0x1E, 0xD1, 0x30, 0x30, 0x9A, 0x21, 0xD7, 0x0D, 0x81, 0xB3, 0xC1, 0x92, 0x0C, 0xE7, 0xD4, 0x1B, 0xBE, 0x49, 0xF2, 0x04, 0x15, 0x2A, 0x52, 0x06, 0x69, 0x31, 0xCA, 0xB3, 0x22, 0x71, 0xBD, 0x1F, 0x00, 0x4B, 0x82, 0x66, 0xB5, 0xA7, 0x37, 0xCF, 0x6F, 0x78, 0x0F, 0xF8, 0x5D, 0xC6, 0xA4, 0xAC, 0xF7, 0x23, 0x05, 0x6C, 0xE4, 0x4E, 0xE2, 0xE3, 0x95, 0xB7, 0xD3, 0x40, 0xF3, 0xA5, 0x06, 0x1C, 0xFE, 0x1F, 0x09, 0x2A, 0xA8, 0xF5, 0xE6, 0x3D, 0x00, 0xDD, 0xAD, 0x02, 0x2D, 0xC4, 0x4D, 0x66, 0xA0, 0x6A, 0x1F, 0xD5, 0x2E, 0xF8, 0x8F, 0xFF, 0x2D, 0xC6, 0x4F, 0x04, 0x1E, 0x14, 0xD0, 0xAC, 0x01, 0x3C, 0xAA, 0x5C, 0x1F, 0xA9, 0x2E, 0x72, 0xBA, 0x49, 0xB5, 0xC7, 0xFA, 0xC0, 0x27, 0xD2, 0x62, 0x69, 0xAE, 0xA7, 0xC8, 0x04, 0xEA, 0x0F, 0xBF, 0x1A, 0x51, 0x50, 0x61, 0x16, 0x8F, 0x1B, 0xD5, 0x5E, 0x03, 0x75, 0x35, 0xDD, 0x09, 0x6F, 0x88, 0xC4, 0x0D, 0x73, 0x07, 0x82, 0x61, 0x88, 0xE8, 0x59, 0x30, 0x45, 0x8E, 0xD4, 0x7A, 0xA7, 0xBD, 0xDA, 0x07, 0x67, 0x81, 0x40, 0x30, 0x88, 0x55, 0xF5, 0x11, 0x05, 0xF0, 0x58, 0x94, 0x9B, 0x48, 0xEC, 0x60, 0xF1, 0x09, 0xC7, 0xF1, 0x66, 0xFC, 0xDF, 0x0E, 0x84, 0x7F, 0x74, 0x1C, 0x8F, 0x58, 0x44, 0x77, 0xAC, 0x59, 0xB5, 0xD7, 0x67, 0x00, 0x12, 0x85, 0x4F, 0x2A, 0x4E, 0x17, 0xBB, 0x1F, 0xC6, 0x00, 0xB8, 0x99, 0xB0, 0xE7, 0x23, 0x9D, 0xF7, 0xCF, 0x6E, 0x44, 0x83, 0x4A, 0x45, 0x32, 0x40, 0x86, 0x81, 0x7C, 0x8D, 0xBA, 0xAB, 0x1C, 0xA7, 0xDE, 0x09, 0x87, 0x48, 0x21, 0x26, 0x5F, 0x4A, 0xAD, 0xBA, 0x6E, 0x4F, 0xCA, 0xFB, 0x23, 0xB7, 0x62, 0xF7, 0xCA, 0xAD, 0x58, 0x22, 0xC1, 0x00, 0x47, 0x9F, 0x0B, 0x7C, 0xCA, 0x73, 0xC1, 0xDB, 0x9F, 0x8C, 0xF2, 0x17, 0x1E, 0x4E, 0xDF, 0xF2, 0x6C, 0xF8, 0x67, 0xAF, 0x22, 0x7B, 0xF3, 0xEB, 0x4B, 0x80, 0x01, 0x00, 0xB8, 0x21, 0x72, 0x89, 0x08, 0x10, 0x07, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 }; ================================================ FILE: cocos2d/cocos/2d/platform/CCApplicationProtocol.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_APPLICATION_PROTOCOL_H__ #define __CC_APPLICATION_PROTOCOL_H__ NS_CC_BEGIN /** * @addtogroup platform * @{ */ class CC_DLL ApplicationProtocol { public: // Since WINDOWS and ANDROID are defined as macros, we could not just use these keywords in enumeration(Platform). // Therefore, 'OS_' prefix is added to avoid conflicts with the definitions of system macros. enum class Platform { OS_WINDOWS, OS_LINUX, OS_MAC, OS_ANDROID, OS_IPHONE, OS_IPAD, OS_BLACKBERRY, OS_NACL, OS_EMSCRIPTEN, OS_TIZEN }; /** * @js NA * @lua NA */ virtual ~ApplicationProtocol() {} /** @brief Implement Director and Scene init code here. @return true Initialize success, app continue. @return false Initialize failed, app terminate. * @js NA * @lua NA */ virtual bool applicationDidFinishLaunching() = 0; /** @brief This function will be called when the application enters background. * @js NA * @lua NA */ virtual void applicationDidEnterBackground() = 0; /** @brief This function will be called when the application enters foreground. * @js NA * @lua NA */ virtual void applicationWillEnterForeground() = 0; /** @brief Callback by Director for limit FPS. @param interval The time, expressed in seconds, between current frame and next. * @js NA * @lua NA */ virtual void setAnimationInterval(double interval) = 0; /** @brief Get current language config @return Current language config * @js NA * @lua NA */ virtual LanguageType getCurrentLanguage() = 0; /** @brief Get target platform * @js NA * @lua NA */ virtual Platform getTargetPlatform() = 0; }; // end of platform group /// @} NS_CC_END #endif // __CC_APPLICATION_PROTOCOL_H__ ================================================ FILE: cocos2d/cocos/2d/platform/CCCommon.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_COMMON_H__ #define __CC_COMMON_H__ #include "CCPlatformMacros.h" NS_CC_BEGIN /** * @addtogroup platform * @{ */ /** * lua can not deal with ... */ void CC_DLL LuaLog(const char * format); /** @brief Pop out a message box */ void CC_DLL MessageBox(const char * msg, const char * title); /** @brief Enum the language type supported now */ enum class LanguageType { ENGLISH = 0, CHINESE, FRENCH, ITALIAN, GERMAN, SPANISH, RUSSIAN, KOREAN, JAPANESE, HUNGARIAN, PORTUGUESE, ARABIC, NORWEGIAN, POLISH }; // END of platform group /// @} NS_CC_END #endif // __CC_COMMON_H__ ================================================ FILE: cocos2d/cocos/2d/platform/CCDevice.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDEVICE_H__ #define __CCDEVICE_H__ #include "CCPlatformMacros.h" #include "ccMacros.h" NS_CC_BEGIN class CC_DLL Device { public: /** * Gets the DPI of device * @return The DPI of device. */ static int getDPI(); /** * To enable or disable accelerometer. */ static void setAccelerometerEnabled(bool isEnabled); /** * Sets the interval of accelerometer. */ static void setAccelerometerInterval(float interval); private: CC_DISALLOW_IMPLICIT_CONSTRUCTORS(Device); }; NS_CC_END #endif /* __CCDEVICE_H__ */ ================================================ FILE: cocos2d/cocos/2d/platform/CCEGLViewProtocol.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEGLViewProtocol.h" #include "CCTouch.h" #include "CCDirector.h" #include "CCSet.h" #include "CCEventDispatcher.h" NS_CC_BEGIN namespace { static Touch* g_touches[EventTouch::MAX_TOUCHES] = { nullptr }; static unsigned int g_indexBitsUsed = 0; // System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0 static std::map g_touchIdReorderMap; static int getUnUsedIndex() { int i; int temp = g_indexBitsUsed; for (i = 0; i < EventTouch::MAX_TOUCHES; i++) { if (! (temp & 0x00000001)) { g_indexBitsUsed |= (1 << i); return i; } temp >>= 1; } // all bits are used return -1; } static void removeUsedIndexBit(int index) { if (index < 0 || index >= EventTouch::MAX_TOUCHES) { return; } unsigned int temp = 1 << index; temp = ~temp; g_indexBitsUsed &= temp; } } EGLViewProtocol::EGLViewProtocol() : _delegate(nullptr) , _scaleX(1.0f) , _scaleY(1.0f) , _resolutionPolicy(ResolutionPolicy::UNKNOWN) { } EGLViewProtocol::~EGLViewProtocol() { } void EGLViewProtocol::pollInputEvents() { } void EGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy) { CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy"); if (width == 0.0f || height == 0.0f) { return; } _designResolutionSize.setSize(width, height); _scaleX = (float)_screenSize.width / _designResolutionSize.width; _scaleY = (float)_screenSize.height / _designResolutionSize.height; if (resolutionPolicy == ResolutionPolicy::NO_BORDER) { _scaleX = _scaleY = MAX(_scaleX, _scaleY); } if (resolutionPolicy == ResolutionPolicy::SHOW_ALL) { _scaleX = _scaleY = MIN(_scaleX, _scaleY); } if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) { _scaleX = _scaleY; _designResolutionSize.width = ceilf(_screenSize.width/_scaleX); } if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) { _scaleY = _scaleX; _designResolutionSize.height = ceilf(_screenSize.height/_scaleY); } // calculate the rect of viewport float viewPortW = _designResolutionSize.width * _scaleX; float viewPortH = _designResolutionSize.height * _scaleY; _viewPortRect.setRect((_screenSize.width - viewPortW) / 2, (_screenSize.height - viewPortH) / 2, viewPortW, viewPortH); _resolutionPolicy = resolutionPolicy; // reset director's member variables to fit visible rect Director::getInstance()->_winSizeInPoints = getDesignResolutionSize(); Director::getInstance()->createStatsLabel(); Director::getInstance()->setGLDefaultValues(); } const Size& EGLViewProtocol::getDesignResolutionSize() const { return _designResolutionSize; } const Size& EGLViewProtocol::getFrameSize() const { return _screenSize; } void EGLViewProtocol::setFrameSize(float width, float height) { _designResolutionSize = _screenSize = Size(width, height); } Size EGLViewProtocol::getVisibleSize() const { if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) { return Size(_screenSize.width/_scaleX, _screenSize.height/_scaleY); } else { return _designResolutionSize; } } Point EGLViewProtocol::getVisibleOrigin() const { if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) { return Point((_designResolutionSize.width - _screenSize.width/_scaleX)/2, (_designResolutionSize.height - _screenSize.height/_scaleY)/2); } else { return Point::ZERO; } } void EGLViewProtocol::setTouchDelegate(EGLTouchDelegate * delegate) { _delegate = delegate; } void EGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h) { glViewport((GLint)(x * _scaleX + _viewPortRect.origin.x), (GLint)(y * _scaleY + _viewPortRect.origin.y), (GLsizei)(w * _scaleX), (GLsizei)(h * _scaleY)); } void EGLViewProtocol::setScissorInPoints(float x , float y , float w , float h) { glScissor((GLint)(x * _scaleX + _viewPortRect.origin.x), (GLint)(y * _scaleY + _viewPortRect.origin.y), (GLsizei)(w * _scaleX), (GLsizei)(h * _scaleY)); } bool EGLViewProtocol::isScissorEnabled() { return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true; } Rect EGLViewProtocol::getScissorRect() const { GLfloat params[4]; glGetFloatv(GL_SCISSOR_BOX, params); float x = (params[0] - _viewPortRect.origin.x) / _scaleX; float y = (params[1] - _viewPortRect.origin.y) / _scaleY; float w = params[2] / _scaleX; float h = params[3] / _scaleY; return Rect(x, y, w, h); } void EGLViewProtocol::setViewName(const std::string& viewname ) { _viewName = viewname; } const std::string& EGLViewProtocol::getViewName() const { return _viewName; } void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[]) { int id = 0; float x = 0.0f; float y = 0.0f; int unusedIndex = 0; EventTouch touchEvent; for (int i = 0; i < num; ++i) { id = ids[i]; x = xs[i]; y = ys[i]; auto iter = g_touchIdReorderMap.find(id); unusedIndex = 0; // it is a new touch if (iter == g_touchIdReorderMap.end()) { unusedIndex = getUnUsedIndex(); // The touches is more than MAX_TOUCHES ? if (unusedIndex == -1) { CCLOG("The touches is more than MAX_TOUCHES, unusedIndex = %d", unusedIndex); continue; } Touch* touch = g_touches[unusedIndex] = new Touch(); touch->setTouchInfo(unusedIndex, (x - _viewPortRect.origin.x) / _scaleX, (y - _viewPortRect.origin.y) / _scaleY); CCLOGINFO("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y); g_touchIdReorderMap.insert(std::make_pair(id, unusedIndex)); touchEvent._touches.push_back(touch); } } if (touchEvent._touches.size() == 0) { CCLOG("touchesBegan: size = 0"); return; } touchEvent._eventCode = EventTouch::EventCode::BEGAN; auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&touchEvent); } void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[]) { int id = 0; float x = 0.0f; float y = 0.0f; EventTouch touchEvent; for (int i = 0; i < num; ++i) { id = ids[i]; x = xs[i]; y = ys[i]; auto iter = g_touchIdReorderMap.find(id); if (iter == g_touchIdReorderMap.end()) { CCLOG("if the index doesn't exist, it is an error"); continue; } CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y); Touch* touch = g_touches[iter->second]; if (touch) { touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX, (y - _viewPortRect.origin.y) / _scaleY); touchEvent._touches.push_back(touch); } else { // It is error, should return. CCLOG("Moving touches with id: %d error", id); return; } } if (touchEvent._touches.size() == 0) { CCLOG("touchesMoved: size = 0"); return; } touchEvent._eventCode = EventTouch::EventCode::MOVED; auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&touchEvent); } void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]) { int id = 0; float x = 0.0f; float y = 0.0f; EventTouch touchEvent; for (int i = 0; i < num; ++i) { id = ids[i]; x = xs[i]; y = ys[i]; auto iter = g_touchIdReorderMap.find(id); if (iter == g_touchIdReorderMap.end()) { CCLOG("if the index doesn't exist, it is an error"); continue; } /* Add to the set to send to the director */ Touch* touch = g_touches[iter->second]; if (touch) { CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y); touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX, (y - _viewPortRect.origin.y) / _scaleY); touchEvent._touches.push_back(touch); g_touches[iter->second] = nullptr; removeUsedIndexBit(iter->second); g_touchIdReorderMap.erase(id); } else { CCLOG("Ending touches with id: %d error", id); return; } } if (touchEvent._touches.size() == 0) { CCLOG("touchesEnded or touchesCancel: size = 0"); return; } touchEvent._eventCode = eventCode; auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&touchEvent); for (auto& touch : touchEvent._touches) { // release the touch object. touch->release(); } } void EGLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[]) { handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys); } void EGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[]) { handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys); } const Rect& EGLViewProtocol::getViewPortRect() const { return _viewPortRect; } float EGLViewProtocol::getScaleX() const { return _scaleX; } float EGLViewProtocol::getScaleY() const { return _scaleY; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/CCEGLViewProtocol.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCEGLVIEWPROTOCOL_H__ #define __CCEGLVIEWPROTOCOL_H__ #include "ccTypes.h" #include "CCEventTouch.h" #include enum class ResolutionPolicy { // The entire application is visible in the specified area without trying to preserve the original aspect ratio. // Distortion can occur, and the application may appear stretched or compressed. EXACT_FIT, // The entire application fills the specified area, without distortion but possibly with some cropping, // while maintaining the original aspect ratio of the application. NO_BORDER, // The entire application is visible in the specified area without distortion while maintaining the original // aspect ratio of the application. Borders can appear on two sides of the application. SHOW_ALL, // The application takes the height of the design resolution size and modifies the width of the internal // canvas so that it fits the aspect ratio of the device // no distortion will occur however you must make sure your application works on different // aspect ratios FIXED_HEIGHT, // The application takes the width of the design resolution size and modifies the height of the internal // canvas so that it fits the aspect ratio of the device // no distortion will occur however you must make sure your application works on different // aspect ratios FIXED_WIDTH, UNKNOWN, }; NS_CC_BEGIN class EGLTouchDelegate; /** * @addtogroup platform * @{ */ class CC_DLL EGLViewProtocol { public: /** * @js ctor */ EGLViewProtocol(); /** * @js NA * @lua NA */ virtual ~EGLViewProtocol(); /** Force destroying EGL view, subclass must implement this method. */ virtual void end() = 0; /** Get whether opengl render system is ready, subclass must implement this method. */ virtual bool isOpenGLReady() = 0; /** Exchanges the front and back buffers, subclass must implement this method. */ virtual void swapBuffers() = 0; /** Open or close IME keyboard , subclass must implement this method. */ virtual void setIMEKeyboardState(bool open) = 0; /** * Polls input events. Subclass must implement methods if platform * does not provide event callbacks. */ virtual void pollInputEvents(); /** * Get the frame size of EGL view. * In general, it returns the screen size since the EGL view is a fullscreen view. */ virtual const Size& getFrameSize() const; /** * Set the frame size of EGL view. */ virtual void setFrameSize(float width, float height); /** * Get the visible area size of opengl viewport. */ virtual Size getVisibleSize() const; /** * Get the visible origin point of opengl viewport. */ virtual Point getVisibleOrigin() const; /** * Set the design resolution size. * @param width Design resolution width. * @param height Design resolution height. * @param resolutionPolicy The resolution policy desired, you may choose: * [1] EXACT_FIT Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched. * [2] NO_BORDER Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut. * [3] SHOW_ALL Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown. */ virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy); /** Get design resolution size. * Default resolution size is the same as 'getFrameSize'. */ virtual const Size& getDesignResolutionSize() const; /** Set touch delegate */ virtual void setTouchDelegate(EGLTouchDelegate * delegate); /** * Set opengl view port rectangle with points. */ virtual void setViewPortInPoints(float x , float y , float w , float h); /** * Set Scissor rectangle with points. */ virtual void setScissorInPoints(float x , float y , float w , float h); /** * Get whether GL_SCISSOR_TEST is enable */ virtual bool isScissorEnabled(); /** * Get the current scissor rectangle */ virtual Rect getScissorRect() const; virtual void setViewName(const std::string& viewname); const std::string& getViewName() const; /** Touch events are handled by default; if you want to customize your handlers, please override these functions: */ virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]); /** * Get the opengl view port rectangle. */ const Rect& getViewPortRect() const; /** * Get scale factor of the horizontal direction. */ float getScaleX() const; /** * Get scale factor of the vertical direction. */ float getScaleY() const; protected: void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]); EGLTouchDelegate* _delegate; // real screen size Size _screenSize; // resolution size, it is the size appropriate for the app resources. Size _designResolutionSize; // the view port size Rect _viewPortRect; // the view name std::string _viewName; float _scaleX; float _scaleY; ResolutionPolicy _resolutionPolicy; }; // end of platform group /// @} NS_CC_END #endif /* __CCEGLVIEWPROTOCOL_H__ */ ================================================ FILE: cocos2d/cocos/2d/platform/CCFileUtils.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCFileUtils.h" #include "CCData.h" #include "ccMacros.h" #include "CCDirector.h" #include "CCSAXParser.h" #include "tinyxml2.h" #include "unzip.h" #include using namespace std; #if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) NS_CC_BEGIN typedef enum { SAX_NONE = 0, SAX_KEY, SAX_DICT, SAX_INT, SAX_REAL, SAX_STRING, SAX_ARRAY }SAXState; typedef enum { SAX_RESULT_NONE = 0, SAX_RESULT_DICT, SAX_RESULT_ARRAY }SAXResult; class DictMaker : public SAXDelegator { public: SAXResult _resultType; ValueMap _rootDict; ValueVector _rootArray; std::string _curKey; ///< parsed key std::string _curValue; // parsed value SAXState _state; ValueMap* _curDict; ValueVector* _curArray; std::stack _dictStack; std::stack _arrayStack; std::stack _stateStack; public: DictMaker() : _resultType(SAX_RESULT_NONE) { } ~DictMaker() { } ValueMap dictionaryWithContentsOfFile(const std::string& fileName) { _resultType = SAX_RESULT_DICT; SAXParser parser; CCASSERT(parser.init("UTF-8"), "The file format isn't UTF-8"); parser.setDelegator(this); parser.parse(fileName); return _rootDict; } ValueVector arrayWithContentsOfFile(const std::string& fileName) { _resultType = SAX_RESULT_ARRAY; SAXParser parser; CCASSERT(parser.init("UTF-8"), "The file format isn't UTF-8"); parser.setDelegator(this); parser.parse(fileName); return _rootArray; } void startElement(void *ctx, const char *name, const char **atts) { CC_UNUSED_PARAM(ctx); CC_UNUSED_PARAM(atts); std::string sName(name); if( sName == "dict" ) { if(_resultType == SAX_RESULT_DICT && _rootDict.empty()) { _curDict = &_rootDict; } _state = SAX_DICT; SAXState preState = SAX_NONE; if (! _stateStack.empty()) { preState = _stateStack.top(); } if (SAX_ARRAY == preState) { // add a new dictionary into the array _curArray->push_back(Value(ValueMap())); _curDict = &(_curArray->rbegin())->asValueMap(); } else if (SAX_DICT == preState) { // add a new dictionary into the pre dictionary CCASSERT(! _dictStack.empty(), "The state is wrong!"); ValueMap* preDict = _dictStack.top(); (*preDict)[_curKey] = Value(ValueMap()); _curDict = &(*preDict)[_curKey].asValueMap(); } // record the dict state _stateStack.push(_state); _dictStack.push(_curDict); } else if(sName == "key") { _state = SAX_KEY; } else if(sName == "integer") { _state = SAX_INT; } else if(sName == "real") { _state = SAX_REAL; } else if(sName == "string") { _state = SAX_STRING; } else if (sName == "array") { _state = SAX_ARRAY; if (_resultType == SAX_RESULT_ARRAY && _rootArray.empty()) { _curArray = &_rootArray; } SAXState preState = SAX_NONE; if (! _stateStack.empty()) { preState = _stateStack.top(); } if (preState == SAX_DICT) { (*_curDict)[_curKey] = Value(ValueVector()); _curArray = &(*_curDict)[_curKey].asValueVector(); } else if (preState == SAX_ARRAY) { CCASSERT(! _arrayStack.empty(), "The state is wrong!"); ValueVector* preArray = _arrayStack.top(); preArray->push_back(Value(ValueVector())); _curArray = &(_curArray->rbegin())->asValueVector(); } // record the array state _stateStack.push(_state); _arrayStack.push(_curArray); } else { _state = SAX_NONE; } } void endElement(void *ctx, const char *name) { CC_UNUSED_PARAM(ctx); SAXState curState = _stateStack.empty() ? SAX_DICT : _stateStack.top(); std::string sName((char*)name); if( sName == "dict" ) { _stateStack.pop(); _dictStack.pop(); if ( !_dictStack.empty()) { _curDict = _dictStack.top(); } } else if (sName == "array") { _stateStack.pop(); _arrayStack.pop(); if (! _arrayStack.empty()) { _curArray = _arrayStack.top(); } } else if (sName == "true") { if (SAX_ARRAY == curState) { _curArray->push_back(Value(true)); } else if (SAX_DICT == curState) { (*_curDict)[_curKey] = Value(true); } } else if (sName == "false") { if (SAX_ARRAY == curState) { _curArray->push_back(Value(false)); } else if (SAX_DICT == curState) { (*_curDict)[_curKey] = Value(false); } } else if (sName == "string" || sName == "integer" || sName == "real") { if (SAX_ARRAY == curState) { if (sName == "string") _curArray->push_back(Value(_curValue)); else if (sName == "integer") _curArray->push_back(Value(atoi(_curValue.c_str()))); else _curArray->push_back(Value(atof(_curValue.c_str()))); } else if (SAX_DICT == curState) { if (sName == "string") (*_curDict)[_curKey] = Value(_curValue); else if (sName == "integer") (*_curDict)[_curKey] = Value(atoi(_curValue.c_str())); else (*_curDict)[_curKey] = Value(atof(_curValue.c_str())); } _curValue.clear(); } _state = SAX_NONE; } void textHandler(void *ctx, const char *ch, int len) { CC_UNUSED_PARAM(ctx); if (_state == SAX_NONE) { return; } SAXState curState = _stateStack.empty() ? SAX_DICT : _stateStack.top(); std::string text = std::string((char*)ch,0,len); switch(_state) { case SAX_KEY: _curKey = text; break; case SAX_INT: case SAX_REAL: case SAX_STRING: { if (curState == SAX_DICT) { CCASSERT(!_curKey.empty(), "key not found : "); } _curValue.append(text); } break; default: break; } } }; ValueMap FileUtils::getValueMapFromFile(const std::string& filename) { std::string fullPath = fullPathForFilename(filename.c_str()); DictMaker tMaker; return tMaker.dictionaryWithContentsOfFile(fullPath.c_str()); } ValueVector FileUtils::getValueVectorFromFile(const std::string& filename) { std::string fullPath = fullPathForFilename(filename.c_str()); DictMaker tMaker; return tMaker.arrayWithContentsOfFile(fullPath.c_str()); } /* * forward statement */ static tinyxml2::XMLElement* generateElementForArray(const ValueVector& array, tinyxml2::XMLDocument *doc); static tinyxml2::XMLElement* generateElementForDict(const ValueMap& dict, tinyxml2::XMLDocument *doc); /* * Use tinyxml2 to write plist files */ bool FileUtils::writeToFile(ValueMap& dict, const std::string &fullPath) { //CCLOG("tinyxml2 Dictionary %d writeToFile %s", dict->_ID, fullPath.c_str()); tinyxml2::XMLDocument *doc = new tinyxml2::XMLDocument(); if (nullptr == doc) return false; tinyxml2::XMLDeclaration *declaration = doc->NewDeclaration("xml version=\"1.0\" encoding=\"UTF-8\""); if (nullptr == declaration) { delete doc; return false; } doc->LinkEndChild(declaration); tinyxml2::XMLElement *docType = doc->NewElement("!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\""); doc->LinkEndChild(docType); tinyxml2::XMLElement *rootEle = doc->NewElement("plist"); rootEle->SetAttribute("version", "1.0"); if (nullptr == rootEle) { delete doc; return false; } doc->LinkEndChild(rootEle); tinyxml2::XMLElement *innerDict = generateElementForDict(dict, doc); if (nullptr == innerDict ) { delete doc; return false; } rootEle->LinkEndChild(innerDict); bool ret = tinyxml2::XML_SUCCESS == doc->SaveFile(fullPath.c_str()); delete doc; return ret; } /* * Generate tinyxml2::XMLElement for Object through a tinyxml2::XMLDocument */ static tinyxml2::XMLElement* generateElementForObject(const Value& value, tinyxml2::XMLDocument *doc) { // object is String if (value.getType() == Value::Type::STRING) { tinyxml2::XMLElement* node = doc->NewElement("string"); tinyxml2::XMLText* content = doc->NewText(value.asString().c_str()); node->LinkEndChild(content); return node; } // object is integer if (value.getType() == Value::Type::INTEGER) { tinyxml2::XMLElement* node = doc->NewElement("integer"); tinyxml2::XMLText* content = doc->NewText(value.asString().c_str()); node->LinkEndChild(content); return node; } // object is real if (value.getType() == Value::Type::FLOAT || value.getType() == Value::Type::DOUBLE) { tinyxml2::XMLElement* node = doc->NewElement("real"); tinyxml2::XMLText* content = doc->NewText(value.asString().c_str()); node->LinkEndChild(content); return node; } //FIXME:XXX How to deal with Boolean ?? // object is Array if (value.getType() == Value::Type::VECTOR) return generateElementForArray(value.asValueVector(), doc); // object is Dictionary if (value.getType() == Value::Type::MAP) return generateElementForDict(value.asValueMap(), doc); CCLOG("This type cannot appear in property list"); return nullptr; } /* * Generate tinyxml2::XMLElement for Dictionary through a tinyxml2::XMLDocument */ static tinyxml2::XMLElement* generateElementForDict(const ValueMap& dict, tinyxml2::XMLDocument *doc) { tinyxml2::XMLElement* rootNode = doc->NewElement("dict"); for (auto iter = dict.begin(); iter != dict.end(); ++iter) { tinyxml2::XMLElement* tmpNode = doc->NewElement("key"); rootNode->LinkEndChild(tmpNode); tinyxml2::XMLText* content = doc->NewText(iter->first.c_str()); tmpNode->LinkEndChild(content); tinyxml2::XMLElement *element = generateElementForObject(iter->second, doc); if (element) rootNode->LinkEndChild(element); } return rootNode; } /* * Generate tinyxml2::XMLElement for Array through a tinyxml2::XMLDocument */ static tinyxml2::XMLElement* generateElementForArray(const ValueVector& array, tinyxml2::XMLDocument *pDoc) { tinyxml2::XMLElement* rootNode = pDoc->NewElement("array"); for(const auto &value : array) { tinyxml2::XMLElement *element = generateElementForObject(value, pDoc); if (element) rootNode->LinkEndChild(element); } return rootNode; } #else NS_CC_BEGIN /* The subclass FileUtilsApple should override these two method. */ ValueMap FileUtils::getValueMapFromFile(const std::string& filename) {return ValueMap();} ValueVector FileUtils::getValueVectorFromFile(const std::string& filename) {return ValueVector();} bool FileUtils::writeToFile(ValueMap& dict, const std::string &fullPath) {return false;} #endif /* (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) */ FileUtils* FileUtils::s_sharedFileUtils = nullptr; void FileUtils::destroyInstance() { CC_SAFE_DELETE(s_sharedFileUtils); } FileUtils::FileUtils() { } FileUtils::~FileUtils() { } bool FileUtils::init() { _searchPathArray.push_back(_defaultResRootPath); _searchResolutionsOrderArray.push_back(""); return true; } void FileUtils::purgeCachedEntries() { _fullPathCache.clear(); } static Data getData(const std::string& filename, bool forString) { CCASSERT(!filename.empty(), "Invalid filename!"); Data ret; unsigned char* buffer = nullptr; ssize_t size = 0; const char* mode = nullptr; if (forString) mode = "rt"; else mode = "rb"; do { // Read the file from hardware std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename); FILE *fp = fopen(fullPath.c_str(), mode); CC_BREAK_IF(!fp); fseek(fp,0,SEEK_END); size = ftell(fp); fseek(fp,0,SEEK_SET); if (forString) { buffer = (unsigned char*)malloc(sizeof(unsigned char) * (size + 1)); buffer[size] = '\0'; } else { buffer = (unsigned char*)malloc(sizeof(unsigned char) * size); } size = fread(buffer, sizeof(unsigned char), size, fp); fclose(fp); } while (0); if (nullptr == buffer || 0 == size) { std::string msg = "Get data from file("; msg.append(filename).append(") failed!"); CCLOG("%s", msg.c_str()); } else { ret.fastSet(buffer, size); } return ret; } std::string FileUtils::getStringFromFile(const std::string& filename) { Data data = getData(filename, true); if (data.isNull()) return ""; std::string ret((const char*)data.getBytes()); return ret; } Data FileUtils::getDataFromFile(const std::string& filename) { return getData(filename, false); } unsigned char* FileUtils::getFileData(const std::string& filename, const char* mode, ssize_t *size) { unsigned char * buffer = nullptr; CCASSERT(!filename.empty() && size != nullptr && mode != nullptr, "Invalid parameters."); *size = 0; do { // read the file from hardware std::string fullPath = fullPathForFilename(filename); FILE *fp = fopen(fullPath.c_str(), mode); CC_BREAK_IF(!fp); fseek(fp,0,SEEK_END); *size = ftell(fp); fseek(fp,0,SEEK_SET); buffer = (unsigned char*)malloc(*size); *size = fread(buffer,sizeof(unsigned char), *size,fp); fclose(fp); } while (0); if (! buffer) { std::string msg = "Get data from file("; msg.append(filename).append(") failed!"); CCLOG("%s", msg.c_str()); } return buffer; } unsigned char* FileUtils::getFileDataFromZip(const std::string& zipFilePath, const std::string& filename, ssize_t *size) { unsigned char * buffer = nullptr; unzFile file = nullptr; *size = 0; do { CC_BREAK_IF(zipFilePath.empty()); file = unzOpen(zipFilePath.c_str()); CC_BREAK_IF(!file); int ret = unzLocateFile(file, filename.c_str(), 1); CC_BREAK_IF(UNZ_OK != ret); char filePathA[260]; unz_file_info fileInfo; ret = unzGetCurrentFileInfo(file, &fileInfo, filePathA, sizeof(filePathA), nullptr, 0, nullptr, 0); CC_BREAK_IF(UNZ_OK != ret); ret = unzOpenCurrentFile(file); CC_BREAK_IF(UNZ_OK != ret); buffer = (unsigned char*)malloc(fileInfo.uncompressed_size); int CC_UNUSED readedSize = unzReadCurrentFile(file, buffer, static_cast(fileInfo.uncompressed_size)); CCASSERT(readedSize == 0 || readedSize == (int)fileInfo.uncompressed_size, "the file size is wrong"); *size = fileInfo.uncompressed_size; unzCloseCurrentFile(file); } while (0); if (file) { unzClose(file); } return buffer; } std::string FileUtils::getNewFilename(const std::string &filename) { std::string newFileName; // in Lookup Filename dictionary ? auto iter = _filenameLookupDict.find(filename); if (iter == _filenameLookupDict.end()) { newFileName = filename; } else { newFileName = iter->second.asString(); } return newFileName; } std::string FileUtils::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) { std::string file = filename; std::string file_path = ""; size_t pos = filename.find_last_of("/"); if (pos != std::string::npos) { file_path = filename.substr(0, pos+1); file = filename.substr(pos+1); } // searchPath + file_path + resourceDirectory std::string path = searchPath; path += file_path; path += resolutionDirectory; path = getFullPathForDirectoryAndFilename(path, file); //CCLOG("getPathForFilename, fullPath = %s", path.c_str()); return path; } std::string FileUtils::fullPathForFilename(const std::string &filename) { if (isAbsolutePath(filename)) { return filename; } // Already Cached ? auto cacheIter = _fullPathCache.find(filename); if( cacheIter != _fullPathCache.end() ) { return cacheIter->second; } // Get the new file name. std::string newFilename( getNewFilename(filename) ); string fullpath = ""; for (auto searchIt = _searchPathArray.begin(); searchIt != _searchPathArray.end(); ++searchIt) { for (auto resolutionIt = _searchResolutionsOrderArray.begin(); resolutionIt != _searchResolutionsOrderArray.end(); ++resolutionIt) { fullpath = this->getPathForFilename(newFilename, *resolutionIt, *searchIt); if (fullpath.length() > 0) { // Using the filename passed in as key. _fullPathCache.insert(std::pair(filename, fullpath)); return fullpath; } } } CCLOG("cocos2d: fullPathForFilename: No file found at %s. Possible missing file.", filename.c_str()); // XXX: Should it return nullptr ? or an empty string ? // The file wasn't found, return the file name passed in. return filename; } std::string FileUtils::fullPathFromRelativeFile(const std::string &filename, const std::string &relativeFile) { return relativeFile.substr(0, relativeFile.rfind('/')+1) + getNewFilename(filename); } void FileUtils::setSearchResolutionsOrder(const std::vector& searchResolutionsOrder) { bool existDefault = false; _fullPathCache.clear(); _searchResolutionsOrderArray.clear(); for(auto iter = searchResolutionsOrder.begin(); iter != searchResolutionsOrder.end(); ++iter) { std::string resolutionDirectory = *iter; if (!existDefault && resolutionDirectory == "") { existDefault = true; } if (resolutionDirectory.length() > 0 && resolutionDirectory[resolutionDirectory.length()-1] != '/') { resolutionDirectory += "/"; } _searchResolutionsOrderArray.push_back(resolutionDirectory); } if (!existDefault) { _searchResolutionsOrderArray.push_back(""); } } void FileUtils::addSearchResolutionsOrder(const std::string &order) { _searchResolutionsOrderArray.push_back(order); } const std::vector& FileUtils::getSearchResolutionsOrder() { return _searchResolutionsOrderArray; } const std::vector& FileUtils::getSearchPaths() const { return _searchPathArray; } void FileUtils::setSearchPaths(const std::vector& searchPaths) { bool existDefaultRootPath = false; _fullPathCache.clear(); _searchPathArray.clear(); for (auto iter = searchPaths.begin(); iter != searchPaths.end(); ++iter) { std::string prefix; std::string path; if (!isAbsolutePath(*iter)) { // Not an absolute path prefix = _defaultResRootPath; } path = prefix + (*iter); if (path.length() > 0 && path[path.length()-1] != '/') { path += "/"; } if (!existDefaultRootPath && path == _defaultResRootPath) { existDefaultRootPath = true; } _searchPathArray.push_back(path); } if (!existDefaultRootPath) { //CCLOG("Default root path doesn't exist, adding it."); _searchPathArray.push_back(_defaultResRootPath); } } void FileUtils::addSearchPath(const std::string &searchpath) { std::string prefix; if (!isAbsolutePath(searchpath)) prefix = _defaultResRootPath; std::string path = prefix + searchpath; if (path.length() > 0 && path[path.length()-1] != '/') { path += "/"; } _searchPathArray.push_back(path); } void FileUtils::setFilenameLookupDictionary(const ValueMap& filenameLookupDict) { _fullPathCache.clear(); _filenameLookupDict = filenameLookupDict; } void FileUtils::loadFilenameLookupDictionaryFromFile(const std::string &filename) { std::string fullPath = fullPathForFilename(filename); if (fullPath.length() > 0) { ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); if (!dict.empty()) { ValueMap& metadata = dict["metadata"].asValueMap(); int version = metadata["version"].asInt(); if (version != 1) { CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %d. Filename: %s", version, filename.c_str()); return; } setFilenameLookupDictionary( dict["filenames"].asValueMap()); } } } std::string FileUtils::getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) { // get directory+filename, safely adding '/' as necessary std::string ret = directory; if (directory.size() && directory[directory.size()-1] != '/'){ ret += '/'; } ret += filename; // if the file doesn't exist, return an empty string if (!isFileExist(ret)) { ret = ""; } return ret; } bool FileUtils::isAbsolutePath(const std::string& path) const { return (path[0] == '/'); } ////////////////////////////////////////////////////////////////////////// // Notification support when getFileData from invalid file path. ////////////////////////////////////////////////////////////////////////// static bool s_popupNotify = true; void FileUtils::setPopupNotify(bool notify) { s_popupNotify = notify; } bool FileUtils::isPopupNotify() { return s_popupNotify; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/CCFileUtils.h ================================================ /**************************************************************************** Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_FILEUTILS_H__ #define __CC_FILEUTILS_H__ #include #include #include #include "CCPlatformMacros.h" #include "ccTypes.h" #include "CCValue.h" #include "CCData.h" NS_CC_BEGIN /** * @addtogroup platform * @{ */ //! @brief Helper class to handle file operations class CC_DLL FileUtils { public: /** * Gets the instance of FileUtils. */ static FileUtils* getInstance(); /** * Destroys the instance of FileUtils. */ static void destroyInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static FileUtils* sharedFileUtils() { return getInstance(); } /** @deprecated Use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeFileUtils() { destroyInstance(); } /** * The destructor of FileUtils. * @js NA * @lua NA */ virtual ~FileUtils(); /** * Purges the file searching cache. * * @note It should be invoked after the resources were updated. * For instance, in the CocosPlayer sample, every time you run application from CocosBuilder, * All the resources will be downloaded to the writable folder, before new js app launchs, * this method should be invoked to clean the file search cache. */ virtual void purgeCachedEntries(); /** * Gets string from a file. */ virtual std::string getStringFromFile(const std::string& filename); /** * Creates binary data from a file. * @return A data object. */ virtual Data getDataFromFile(const std::string& filename); /** * Gets resource file data * * @param[in] filename The resource file name which contains the path. * @param[in] pszMode The read mode of the file. * @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling free() on any Non-NULL pointer returned. */ CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const std::string& filename, const char* mode, ssize_t *size); /** * Gets resource file data from a zip file. * * @param[in] filename The resource file name which contains the relative path of the zip file. * @param[out] size If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise nullptr. * @warning Recall: you are responsible for calling free() on any Non-nullptr pointer returned. */ virtual unsigned char* getFileDataFromZip(const std::string& zipFilePath, const std::string& filename, ssize_t *size); /** Returns the fullpath for a given filename. First it will try to get a new filename from the "filenameLookup" dictionary. If a new filename can't be found on the dictionary, it will use the original filename. Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. The file search is based on the array element order of search paths and resolution directories. For instance: We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths, and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd") to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/". If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`. Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows: /mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next) /mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next) /mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next) /mnt/sdcard/sprite.pvr.gz (if not found, search next) internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next) internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next) internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next) internal_dir/sprite.pvr.gz (if not found, return "sprite.png") If the filename contains relative path like "gamescene/uilayer/sprite.png", and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`. The file search order will be: /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next) internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next) internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next) internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png") If the new file can't be found on the file system, it will return the parameter filename directly. This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, you might need to load different resources for a given file in the different platforms. @since v2.1 */ virtual std::string fullPathForFilename(const std::string &filename); /** * Loads the filenameLookup dictionary from the contents of a filename. * * @note The plist file name should follow the format below: * * @code * * * * * filenames * * sounds/click.wav * sounds/click.caf * sounds/endgame.wav * sounds/endgame.caf * sounds/gem-0.wav * sounds/gem-0.caf * * metadata * * version * 1 * * * * @endcode * @param filename The plist file name. * @since v2.1 * @js loadFilenameLookup * @lua loadFilenameLookup */ virtual void loadFilenameLookupDictionaryFromFile(const std::string &filename); /** * Sets the filenameLookup dictionary. * * @param pFilenameLookupDict The dictionary for replacing filename. * @since v2.1 */ virtual void setFilenameLookupDictionary(const ValueMap& filenameLookupDict); /** * Gets full path from a file name and the path of the reletive file. * @param filename The file name. * @param pszRelativeFile The path of the relative file. * @return The full path. * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) * */ virtual std::string fullPathFromRelativeFile(const std::string &filename, const std::string &relativeFile); /** * Sets the array that contains the search order of the resources. * * @param searchResolutionsOrder The source array that contains the search order of the resources. * @see getSearchResolutionsOrder(void), fullPathForFilename(const char*). * @since v2.1 * In js:var setSearchResolutionsOrder(var jsval) * @lua NA */ virtual void setSearchResolutionsOrder(const std::vector& searchResolutionsOrder); /** * Append search order of the resources. * * @see setSearchResolutionsOrder(), fullPathForFilename(). * @since v2.1 */ virtual void addSearchResolutionsOrder(const std::string &order); /** * Gets the array that contains the search order of the resources. * * @see setSearchResolutionsOrder(const std::vector&), fullPathForFilename(const char*). * @since v2.1 * @lua NA */ virtual const std::vector& getSearchResolutionsOrder(); /** * Sets the array of search paths. * * You can use this array to modify the search path of the resources. * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array. * * @note This method could access relative path and absolute path. * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. * For instance: * On Android, the default resource root path is "assets/". * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, * "resources-large" will be converted to "assets/resources-large" since it was a relative path. * * @param searchPaths The array contains search paths. * @see fullPathForFilename(const char*) * @since v2.1 * In js:var setSearchPaths(var jsval); * @lua NA */ virtual void setSearchPaths(const std::vector& searchPaths); /** * Add search path. * * @since v2.1 */ void addSearchPath(const std::string & path); /** * Gets the array of search paths. * * @return The array of search paths. * @see fullPathForFilename(const char*). * @lua NA */ virtual const std::vector& getSearchPaths() const; /** * Gets the writable path. * @return The path that can be write/read a file in */ virtual std::string getWritablePath() const = 0; /** * Checks whether a file exists. * * @note If a relative path was passed in, it will be inserted a default root path at the beginning. * @param strFilePath The path of the file, it could be a relative or absolute path. * @return true if the file exists, otherwise it will return false. */ virtual bool isFileExist(const std::string& filePath) const = 0; /** * Checks whether the path is an absolute path. * * @note On Android, if the parameter passed in is relative to "assets/", this method will treat it as an absolute path. * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path. * * @param strPath The path that needs to be checked. * @return true if it's an absolute path, otherwise it will return false. */ virtual bool isAbsolutePath(const std::string& path) const; /** * Sets/Gets whether to pop-up a message box when failed to load an image. */ virtual void setPopupNotify(bool notify); virtual bool isPopupNotify(); /** * Converts the contents of a file to a ValueMap. * @note This method is used internally. */ virtual ValueMap getValueMapFromFile(const std::string& filename); /** * Write a ValueMap to a plist file. * @note This method is used internally. */ virtual bool writeToFile(ValueMap& dict, const std::string& fullPath); /** * Converts the contents of a file to a ValueVector. * @note This method is used internally. */ virtual ValueVector getValueVectorFromFile(const std::string& filename); /** Returns the full path cache */ const std::unordered_map& getFullPathCache() const { return _fullPathCache; } protected: /** * The default constructor. */ FileUtils(); /** * Initializes the instance of FileUtils. It will set _searchPathArray and _searchResolutionsOrderArray to default values. * * @note When you are porting Cocos2d-x to a new platform, you may need to take care of this method. * You could assign a default value to _defaultResRootPath in the subclass of FileUtils(e.g. FileUtilsAndroid). Then invoke the FileUtils::init(). * @return true if successed, otherwise it returns false. * */ virtual bool init(); /** * Gets the new filename from the filename lookup dictionary. * It is possible to have a override names. * @param filename The original filename. * @return The new filename after searching in the filename lookup dictionary. * If the original filename wasn't in the dictionary, it will return the original filename. */ virtual std::string getNewFilename(const std::string &filename); /** * Gets full path for filename, resolution directory and search path. * * @param filename The file name. * @param resolutionDirectory The resolution directory. * @param searchPath The search path. * @return The full path of the file. It will return an empty string if the full path of the file doesn't exist. */ virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath); /** * Gets full path for the directory and the filename. * * @note Only iOS and Mac need to override this method since they are using * `[[NSBundle mainBundle] pathForResource: ofType: inDirectory:]` to make a full path. * Other platforms will use the default implementation of this method. * @param strDirectory The directory contains the file we are looking for. * @param strFilename The name of the file. * @return The full path of the file, if the file can't be found, it will return an empty string. */ virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename); /** Dictionary used to lookup filenames based on a key. * It is used internally by the following methods: * * std::string fullPathForFilename(const char*); * * @since v2.1 */ ValueMap _filenameLookupDict; /** * The vector contains resolution folders. * The lower index of the element in this vector, the higher priority for this resolution directory. */ std::vector _searchResolutionsOrderArray; /** * The vector contains search paths. * The lower index of the element in this vector, the higher priority for this search path. */ std::vector _searchPathArray; /** * The default root path of resources. * If the default root path of resources needs to be changed, do it in the `init` method of FileUtils's subclass. * For instance: * On Android, the default root path of resources will be assigned with "assets/" in FileUtilsAndroid::init(). * Similarly on Blackberry, we assign "app/native/Resources/" to this variable in FileUtilsBlackberry::init(). */ std::string _defaultResRootPath; /** * The full path cache. When a file is found, it will be added into this cache. * This variable is used for improving the performance of file search. */ std::unordered_map _fullPathCache; /** * The singleton pointer of FileUtils. */ static FileUtils* s_sharedFileUtils; }; // end of platform group /// @} NS_CC_END #endif // __CC_FILEUTILS_H__ ================================================ FILE: cocos2d/cocos/2d/platform/CCImage.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_IMAGE_H__ #define __CC_IMAGE_H__ #include "CCObject.h" #include "CCTexture2D.h" // premultiply alpha, or the effect will wrong when want to use other pixel format in Texture2D, // such as RGB888, RGB5A1 #define CC_RGB_PREMULTIPLY_ALPHA(vr, vg, vb, va) \ (unsigned)(((unsigned)((unsigned char)(vr) * ((unsigned char)(va) + 1)) >> 8) | \ ((unsigned)((unsigned char)(vg) * ((unsigned char)(va) + 1) >> 8) << 8) | \ ((unsigned)((unsigned char)(vb) * ((unsigned char)(va) + 1) >> 8) << 16) | \ ((unsigned)(unsigned char)(va) << 24)) NS_CC_BEGIN /** * @addtogroup platform * @{ */ /** @brief Structure which can tell where mipmap begins and how long is it */ typedef struct _MipmapInfo { unsigned char* address; int len; }MipmapInfo; class CC_DLL Image : public Object { public: friend class TextureCache; /** * @js ctor */ Image(); /** * @js NA * @lua NA */ virtual ~Image(); /** Supported formats for Image */ enum class Format { //! JPEG JPG, //! PNG PNG, //! TIFF TIFF, //! WebP WEBP, //! PVR PVR, //! ETC ETC, //! S3TC S3TC, //! ATITC ATITC, //! TGA TGA, //! Raw Data RAW_DATA, //! Unknown format UNKOWN }; enum class TextAlign { CENTER = 0x33, ///< Horizontal center and vertical center. TOP = 0x13, ///< Horizontal center and vertical top. TOP_RIGHT = 0x12, ///< Horizontal right and vertical top. RIGHT = 0x32, ///< Horizontal right and vertical center. BOTTOM_RIGHT = 0x22, ///< Horizontal right and vertical bottom. BOTTOM = 0x23, ///< Horizontal center and vertical bottom. BOTTOM_LEFT = 0x21, ///< Horizontal left and vertical bottom. LEFT = 0x31, ///< Horizontal left and vertical center. TOP_LEFT = 0x11, ///< Horizontal left and vertical top. }; /** @brief Load the image from the specified path. @param path the absolute file path. @return true if loaded correctly. */ bool initWithImageFile(const std::string& path); /** @brief Load image from stream buffer. @param data stream buffer which holds the image data. @param dataLen data length expressed in (number of) bytes. @return true if loaded correctly. * @js NA * @lua NA */ bool initWithImageData(const unsigned char * data, ssize_t dataLen); // @warning kFmtRawData only support RGBA8888 bool initWithRawData(const unsigned char * data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti = false); /** @brief Create image with specified string. @param text the text the image will show (cannot be nil). @param width the image width, if 0, the width will match the text's width. @param height the image height, if 0, the height will match the text's height. @param alignMask the test Alignment @param fontName the name of the font used to draw the text. If nil, use the default system font. @param size the font size, if 0, use the system default size. * @js NA * @lua NA */ bool initWithString( const char * text, int width = 0, int height = 0, TextAlign alignMask = TextAlign::CENTER, const char * fontName = 0, int size = 0); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) bool initWithStringShadowStroke( const char * pText, int nWidth = 0, int nHeight = 0, TextAlign eAlignMask = TextAlign::CENTER, const char * pFontName = 0, int nSize = 0, float textTintR = 1, float textTintG = 1, float textTintB = 1, bool shadow = false, float shadowOffsetX = 0.0, float shadowOffsetY = 0.0, float shadowOpacity = 0.0, float shadowBlur = 0.0, bool stroke = false, float strokeR = 1, float strokeG = 1, float strokeB = 1, float strokeSize = 1 ); #endif // Getters inline unsigned char * getData() { return _data; } inline ssize_t getDataLen() { return _dataLen; } inline Format getFileType() {return _fileType; } inline Texture2D::PixelFormat getRenderFormat() { return _renderFormat; } inline int getWidth() { return _width; } inline int getHeight() { return _height; } inline bool isPremultipliedAlpha() { return _preMulti; } inline int getNumberOfMipmaps() { return _numberOfMipmaps; } inline MipmapInfo* getMipmaps() { return _mipmaps; } inline bool hasPremultipliedAlpha() { return _hasPremultipliedAlpha; } int getBitPerPixel(); bool hasAlpha(); bool isCompressed(); /** @brief Save Image data to the specified file, with specified format. @param filePath the file's absolute path, including file suffix. @param isToRGB whether the image is saved as RGB format. */ bool saveToFile(const std::string &filename, bool isToRGB = true); protected: bool initWithJpgData(const unsigned char * data, ssize_t dataLen); bool initWithPngData(const unsigned char * data, ssize_t dataLen); bool initWithTiffData(const unsigned char * data, ssize_t dataLen); bool initWithWebpData(const unsigned char * data, ssize_t dataLen); bool initWithPVRData(const unsigned char * data, ssize_t dataLen); bool initWithPVRv2Data(const unsigned char * data, ssize_t dataLen); bool initWithPVRv3Data(const unsigned char * data, ssize_t dataLen); bool initWithETCData(const unsigned char * data, ssize_t dataLen); bool initWithS3TCData(const unsigned char * data, ssize_t dataLen); bool initWithATITCData(const unsigned char *data, ssize_t dataLen); typedef struct sImageTGA tImageTGA; bool initWithTGAData(tImageTGA* tgaData); bool saveImageToPNG(const std::string& filePath, bool isToRGB = true); bool saveImageToJPG(const std::string& filePath); private: /** @brief Determine how many mipmaps can we have. Its same as define but it respects namespaces */ static const int MIPMAP_MAX = 16; unsigned char *_data; ssize_t _dataLen; int _width; int _height; Format _fileType; Texture2D::PixelFormat _renderFormat; bool _preMulti; MipmapInfo _mipmaps[MIPMAP_MAX]; // pointer to mipmap images int _numberOfMipmaps; // false if we cann't auto detect the image is premultiplied or not. bool _hasPremultipliedAlpha; std::string _filePath; private: // noncopyable Image(const Image& rImg); Image & operator=(const Image&); /* @brief The same result as with initWithImageFile, but thread safe. It is caused by loadImage() in TextureCache.cpp. @param fullpath full path of the file. @param imageType the type of image, currently only supporting two types. @return true if loaded correctly. */ bool initWithImageFileThreadSafe(const std::string& fullpath); Format detectFormat(const unsigned char * data, ssize_t dataLen); bool isPng(const unsigned char * data, ssize_t dataLen); bool isJpg(const unsigned char * data, ssize_t dataLen); bool isTiff(const unsigned char * data, ssize_t dataLen); bool isWebp(const unsigned char * data, ssize_t dataLen); bool isPvr(const unsigned char * data, ssize_t dataLen); bool isEtc(const unsigned char * data, ssize_t dataLen); bool isS3TC(const unsigned char * data,ssize_t dataLen); bool isATITC(const unsigned char *data, ssize_t dataLen); }; // end of platform group /// @} NS_CC_END #endif // __CC_IMAGE_H__ ================================================ FILE: cocos2d/cocos/2d/platform/CCImageCommon_cpp.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCImage.h" #include "CCData.h" #include #include #ifdef EMSCRIPTEN #include #include #endif // EMSCRIPTEN extern "C" { #include "png.h" #include "tiffio.h" #include "etc1.h" #include "jpeglib.h" } #include "s3tc.h" #include "atitc.h" #include "TGAlib.h" #include "decode.h" #include "ccMacros.h" #include "CCCommon.h" #include "CCStdC.h" #include "CCFileUtils.h" #include "CCConfiguration.h" #include "ccUtils.h" #include "ZipUtils.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "android/CCFileUtilsAndroid.h" #endif #define CC_GL_ATC_RGB_AMD 0x8C92 #define CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 #define CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE NS_CC_BEGIN ////////////////////////////////////////////////////////////////////////// //struct and data for pvr structure namespace { static const int PVR_TEXTURE_FLAG_TYPE_MASK = 0xff; // Values taken from PVRTexture.h from http://www.imgtec.com enum class PVR2TextureFlag { Mipmap = (1<<8), // has mip map levels Twiddle = (1<<9), // is twiddled Bumpmap = (1<<10), // has normals encoded for a bump map Tiling = (1<<11), // is bordered for tiled pvr Cubemap = (1<<12), // is a cubemap/skybox FalseMipCol = (1<<13), // are there false colored MIP levels Volume = (1<<14), // is this a volume texture Alpha = (1<<15), // v2.1 is there transparency info in the texture VerticalFlip = (1<<16), // v2.1 is the texture vertically flipped }; enum class PVR3TextureFlag { PremultipliedAlpha = (1<<1) // has premultiplied alpha }; static const char gPVRTexIdentifier[5] = "PVR!"; // v2 enum class PVR2TexturePixelFormat : unsigned char { RGBA4444 = 0x10, RGBA5551, RGBA8888, RGB565, RGB555, // unsupported RGB888, I8, AI88, PVRTC2BPP_RGBA, PVRTC4BPP_RGBA, BGRA8888, A8, }; // v3 enum class PVR3TexturePixelFormat : uint64_t { PVRTC2BPP_RGB = 0ULL, PVRTC2BPP_RGBA = 1ULL, PVRTC4BPP_RGB = 2ULL, PVRTC4BPP_RGBA = 3ULL, BGRA8888 = 0x0808080861726762ULL, RGBA8888 = 0x0808080861626772ULL, RGBA4444 = 0x0404040461626772ULL, RGBA5551 = 0x0105050561626772ULL, RGB565 = 0x0005060500626772ULL, RGB888 = 0x0008080800626772ULL, A8 = 0x0000000800000061ULL, L8 = 0x000000080000006cULL, LA88 = 0x000008080000616cULL, }; // v2 typedef const std::map _pixel2_formathash; static const _pixel2_formathash::value_type v2_pixel_formathash_value[] = { _pixel2_formathash::value_type(PVR2TexturePixelFormat::BGRA8888, Texture2D::PixelFormat::BGRA8888), _pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA8888, Texture2D::PixelFormat::RGBA8888), _pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA4444, Texture2D::PixelFormat::RGBA4444), _pixel2_formathash::value_type(PVR2TexturePixelFormat::RGBA5551, Texture2D::PixelFormat::RGB5A1), _pixel2_formathash::value_type(PVR2TexturePixelFormat::RGB565, Texture2D::PixelFormat::RGB565), _pixel2_formathash::value_type(PVR2TexturePixelFormat::RGB888, Texture2D::PixelFormat::RGB888), _pixel2_formathash::value_type(PVR2TexturePixelFormat::A8, Texture2D::PixelFormat::A8), _pixel2_formathash::value_type(PVR2TexturePixelFormat::I8, Texture2D::PixelFormat::I8), _pixel2_formathash::value_type(PVR2TexturePixelFormat::AI88, Texture2D::PixelFormat::AI88), #ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG _pixel2_formathash::value_type(PVR2TexturePixelFormat::PVRTC2BPP_RGBA, Texture2D::PixelFormat::PVRTC2A), _pixel2_formathash::value_type(PVR2TexturePixelFormat::PVRTC4BPP_RGBA, Texture2D::PixelFormat::PVRTC4A), #endif }; static const int PVR2_MAX_TABLE_ELEMENTS = sizeof(v2_pixel_formathash_value) / sizeof(v2_pixel_formathash_value[0]); static const _pixel2_formathash v2_pixel_formathash(v2_pixel_formathash_value, v2_pixel_formathash_value + PVR2_MAX_TABLE_ELEMENTS); // v3 typedef const std::map _pixel3_formathash; static _pixel3_formathash::value_type v3_pixel_formathash_value[] = { _pixel3_formathash::value_type(PVR3TexturePixelFormat::BGRA8888, Texture2D::PixelFormat::BGRA8888), _pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA8888, Texture2D::PixelFormat::RGBA8888), _pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA4444, Texture2D::PixelFormat::RGBA4444), _pixel3_formathash::value_type(PVR3TexturePixelFormat::RGBA5551, Texture2D::PixelFormat::RGB5A1), _pixel3_formathash::value_type(PVR3TexturePixelFormat::RGB565, Texture2D::PixelFormat::RGB565), _pixel3_formathash::value_type(PVR3TexturePixelFormat::RGB888, Texture2D::PixelFormat::RGB888), _pixel3_formathash::value_type(PVR3TexturePixelFormat::A8, Texture2D::PixelFormat::A8), _pixel3_formathash::value_type(PVR3TexturePixelFormat::L8, Texture2D::PixelFormat::I8), _pixel3_formathash::value_type(PVR3TexturePixelFormat::LA88, Texture2D::PixelFormat::AI88), #ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG _pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC2BPP_RGB, Texture2D::PixelFormat::PVRTC2), _pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC2BPP_RGBA, Texture2D::PixelFormat::PVRTC2A), _pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC4BPP_RGB, Texture2D::PixelFormat::PVRTC4), _pixel3_formathash::value_type(PVR3TexturePixelFormat::PVRTC4BPP_RGBA, Texture2D::PixelFormat::PVRTC4A), #endif }; static const int PVR3_MAX_TABLE_ELEMENTS = sizeof(v3_pixel_formathash_value) / sizeof(v3_pixel_formathash_value[0]); static const _pixel3_formathash v3_pixel_formathash(v3_pixel_formathash_value, v3_pixel_formathash_value + PVR3_MAX_TABLE_ELEMENTS); typedef struct _PVRTexHeader { unsigned int headerLength; unsigned int height; unsigned int width; unsigned int numMipmaps; unsigned int flags; unsigned int dataLength; unsigned int bpp; unsigned int bitmaskRed; unsigned int bitmaskGreen; unsigned int bitmaskBlue; unsigned int bitmaskAlpha; unsigned int pvrTag; unsigned int numSurfs; } PVRv2TexHeader; #ifdef _MSC_VER #pragma pack(push,1) #endif typedef struct { uint32_t version; uint32_t flags; uint64_t pixelFormat; uint32_t colorSpace; uint32_t channelType; uint32_t height; uint32_t width; uint32_t depth; uint32_t numberOfSurfaces; uint32_t numberOfFaces; uint32_t numberOfMipmaps; uint32_t metadataLength; #ifdef _MSC_VER } PVRv3TexHeader; #pragma pack(pop) #else } __attribute__((packed)) PVRv3TexHeader; #endif } //pvr structure end ////////////////////////////////////////////////////////////////////////// //struct and data for s3tc(dds) struct namespace { struct DDColorKey { uint32_t colorSpaceLowValue; uint32_t colorSpaceHighValue; }; struct DDSCaps { uint32_t caps; uint32_t caps2; uint32_t caps3; uint32_t caps4; }; struct DDPixelFormat { uint32_t size; uint32_t flags; uint32_t fourCC; uint32_t RGBBitCount; uint32_t RBitMask; uint32_t GBitMask; uint32_t BBitMask; uint32_t ABitMask; }; struct DDSURFACEDESC2 { uint32_t size; uint32_t flags; uint32_t height; uint32_t width; union { uint32_t pitch; uint32_t linearSize; } DUMMYUNIONNAMEN1; union { uint32_t backBufferCount; uint32_t depth; } DUMMYUNIONNAMEN5; union { uint32_t mipMapCount; uint32_t refreshRate; uint32_t srcVBHandle; } DUMMYUNIONNAMEN2; uint32_t alphaBitDepth; uint32_t reserved; uint32_t surface; union { DDColorKey ddckCKDestOverlay; uint32_t emptyFaceColor; } DUMMYUNIONNAMEN3; DDColorKey ddckCKDestBlt; DDColorKey ddckCKSrcOverlay; DDColorKey ddckCKSrcBlt; union { DDPixelFormat ddpfPixelFormat; uint32_t FVF; } DUMMYUNIONNAMEN4; DDSCaps ddsCaps; uint32_t textureStage; } ; #pragma pack(push,1) struct S3TCTexHeader { char fileCode[4]; DDSURFACEDESC2 ddsd; }; #pragma pack(pop) } //s3tc struct end ////////////////////////////////////////////////////////////////////////// //struct and data for atitc(ktx) struct namespace { struct ATITCTexHeader { //HEADER char identifier[12]; uint32_t endianness; uint32_t glType; uint32_t glTypeSize; uint32_t glFormat; uint32_t glInternalFormat; uint32_t glBaseInternalFormat; uint32_t pixelWidth; uint32_t pixelHeight; uint32_t pixelDepth; uint32_t numberOfArrayElements; uint32_t numberOfFaces; uint32_t numberOfMipmapLevels; uint32_t bytesOfKeyValueData; }; } //atittc struct end ////////////////////////////////////////////////////////////////////////// namespace { typedef struct { const unsigned char * data; ssize_t size; int offset; }tImageSource; static void pngReadCallback(png_structp png_ptr, png_bytep data, png_size_t length) { tImageSource* isource = (tImageSource*)png_get_io_ptr(png_ptr); if((int)(isource->offset + length) <= isource->size) { memcpy(data, isource->data+isource->offset, length); isource->offset += length; } else { png_error(png_ptr, "pngReaderCallback failed"); } } } ////////////////////////////////////////////////////////////////////////// // Implement Image ////////////////////////////////////////////////////////////////////////// Image::Image() : _data(nullptr) , _dataLen(0) , _width(0) , _height(0) , _fileType(Format::UNKOWN) , _renderFormat(Texture2D::PixelFormat::NONE) , _preMulti(false) , _numberOfMipmaps(0) , _hasPremultipliedAlpha(true) { } Image::~Image() { CC_SAFE_FREE(_data); } bool Image::initWithImageFile(const std::string& path) { bool ret = false; _filePath = FileUtils::getInstance()->fullPathForFilename(path); #ifdef EMSCRIPTEN // Emscripten includes a re-implementation of SDL that uses HTML5 canvas // operations underneath. Consequently, loading images via IMG_Load (an SDL // API) will be a lot faster than running libpng et al as compiled with // Emscripten. SDL_Surface *iSurf = IMG_Load(fullPath.c_str()); int size = 4 * (iSurf->w * iSurf->h); ret = initWithRawData((const unsigned char*)iSurf->pixels, size, iSurf->w, iSurf->h, 8, true); unsigned int *tmp = (unsigned int *)_data; int nrPixels = iSurf->w * iSurf->h; for(int i = 0; i < nrPixels; i++) { unsigned char *p = _data + i * 4; tmp[i] = CC_RGB_PREMULTIPLY_ALPHA( p[0], p[1], p[2], p[3] ); } SDL_FreeSurface(iSurf); #else Data data = FileUtils::getInstance()->getDataFromFile(_filePath); if (!data.isNull()) { ret = initWithImageData(data.getBytes(), data.getSize()); } #endif // EMSCRIPTEN return ret; } bool Image::initWithImageFileThreadSafe(const std::string& fullpath) { bool ret = false; _filePath = fullpath; Data data = FileUtils::getInstance()->getDataFromFile(fullpath); if (!data.isNull()) { ret = initWithImageData(data.getBytes(), data.getSize()); } return ret; } bool Image::initWithImageData(const unsigned char * data, ssize_t dataLen) { bool ret = false; do { CC_BREAK_IF(! data || dataLen <= 0); unsigned char* unpackedData = nullptr; ssize_t unpackedLen = 0; //detecgt and unzip the compress file if (ZipUtils::isCCZBuffer(data, dataLen)) { unpackedLen = ZipUtils::inflateCCZBuffer(data, dataLen, &unpackedData); } else if (ZipUtils::isGZipBuffer(data, dataLen)) { unpackedLen = ZipUtils::inflateMemory(const_cast(data), dataLen, &unpackedData); } else { unpackedData = const_cast(data); unpackedLen = dataLen; } _fileType = detectFormat(unpackedData, unpackedLen); switch (_fileType) { case Format::PNG: ret = initWithPngData(unpackedData, unpackedLen); break; case Format::JPG: ret = initWithJpgData(unpackedData, unpackedLen); break; case Format::TIFF: ret = initWithTiffData(unpackedData, unpackedLen); break; case Format::WEBP: ret = initWithWebpData(unpackedData, unpackedLen); break; case Format::PVR: ret = initWithPVRData(unpackedData, unpackedLen); break; case Format::ETC: ret = initWithETCData(unpackedData, unpackedLen); break; case Format::S3TC: ret = initWithS3TCData(unpackedData, unpackedLen); break; case Format::ATITC: ret = initWithATITCData(unpackedData, unpackedLen); break; default: { // load and detect image format tImageTGA* tgaData = tgaLoadBuffer(unpackedData, unpackedLen); if (tgaData != nullptr && tgaData->status == TGA_OK) { ret = initWithTGAData(tgaData); } else { CCAssert(false, "unsupport image format!"); } free(tgaData); break; } } if(unpackedData != data) { free(unpackedData); } } while (0); return ret; } bool Image::isPng(const unsigned char * data, ssize_t dataLen) { if (dataLen <= 8) { return false; } static const unsigned char PNG_SIGNATURE[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a}; return memcmp(PNG_SIGNATURE, data, sizeof(PNG_SIGNATURE)) == 0; } bool Image::isEtc(const unsigned char * data, ssize_t dataLen) { return etc1_pkm_is_valid((etc1_byte*)data) ? true : false; } bool Image::isS3TC(const unsigned char * data, ssize_t dataLen) { S3TCTexHeader *header = (S3TCTexHeader *)data; if (strncmp(header->fileCode, "DDS", 3) != 0) { CCLOG("cocos2d: the file is not a dds file!"); return false; } return true; } bool Image::isATITC(const unsigned char *data, ssize_t dataLen) { ATITCTexHeader *header = (ATITCTexHeader *)data; if (strncmp(&header->identifier[1], "KTX", 3) != 0) { CCLOG("cocos3d: the file is not a ktx file!"); return false; } return true; } bool Image::isJpg(const unsigned char * data, ssize_t dataLen) { if (dataLen <= 4) { return false; } static const unsigned char JPG_SOI[] = {0xFF, 0xD8}; return memcmp(data, JPG_SOI, 2) == 0; } bool Image::isTiff(const unsigned char * data, ssize_t dataLen) { if (dataLen <= 4) { return false; } static const char* TIFF_II = "II"; static const char* TIFF_MM = "MM"; return (memcmp(data, TIFF_II, 2) == 0 && *(static_cast(data) + 2) == 42 && *(static_cast(data) + 3) == 0) || (memcmp(data, TIFF_MM, 2) == 0 && *(static_cast(data) + 2) == 0 && *(static_cast(data) + 3) == 42); } bool Image::isWebp(const unsigned char * data, ssize_t dataLen) { if (dataLen <= 12) { return false; } static const char* WEBP_RIFF = "RIFF"; static const char* WEBP_WEBP = "WEBP"; return memcmp(data, WEBP_RIFF, 4) == 0 && memcmp(static_cast(data) + 8, WEBP_WEBP, 4) == 0; } bool Image::isPvr(const unsigned char * data, ssize_t dataLen) { if (static_cast(dataLen) < sizeof(PVRv2TexHeader) || static_cast(dataLen) < sizeof(PVRv3TexHeader)) { return false; } const PVRv2TexHeader* headerv2 = static_cast(static_cast(data)); const PVRv3TexHeader* headerv3 = static_cast(static_cast(data)); return memcmp(&headerv2->pvrTag, gPVRTexIdentifier, strlen(gPVRTexIdentifier)) == 0 || CC_SWAP_INT32_BIG_TO_HOST(headerv3->version) == 0x50565203; } Image::Format Image::detectFormat(const unsigned char * data, ssize_t dataLen) { if (isPng(data, dataLen)) { return Format::PNG; } else if (isJpg(data, dataLen)) { return Format::JPG; } else if (isTiff(data, dataLen)) { return Format::TIFF; } else if (isWebp(data, dataLen)) { return Format::WEBP; } else if (isPvr(data, dataLen)) { return Format::PVR; } else if (isEtc(data, dataLen)) { return Format::ETC; } else if (isS3TC(data, dataLen)) { return Format::S3TC; } else if (isATITC(data, dataLen)) { return Format::ATITC; } else { return Format::UNKOWN; } } int Image::getBitPerPixel() { return Texture2D::getPixelFormatInfoMap().at(_renderFormat).bpp; } bool Image::hasAlpha() { return Texture2D::getPixelFormatInfoMap().at(_renderFormat).alpha; } bool Image::isCompressed() { return Texture2D::getPixelFormatInfoMap().at(_renderFormat).compressed; } namespace { /* * ERROR HANDLING: * * The JPEG library's standard error handler (jerror.c) is divided into * several "methods" which you can override individually. This lets you * adjust the behavior without duplicating a lot of code, which you might * have to update with each future release. * * We override the "error_exit" method so that control is returned to the * library's caller when a fatal error occurs, rather than calling exit() * as the standard error_exit method does. * * We use C's setjmp/longjmp facility to return control. This means that the * routine which calls the JPEG library must first execute a setjmp() call to * establish the return point. We want the replacement error_exit to do a * longjmp(). But we need to make the setjmp buffer accessible to the * error_exit routine. To do this, we make a private extension of the * standard JPEG error handler object. (If we were using C++, we'd say we * were making a subclass of the regular error handler.) * * Here's the extended error handler struct: */ struct MyErrorMgr { struct jpeg_error_mgr pub; /* "public" fields */ jmp_buf setjmp_buffer; /* for return to caller */ }; typedef struct MyErrorMgr * MyErrorPtr; /* * Here's the routine that will replace the standard error_exit method: */ METHODDEF(void) myErrorExit(j_common_ptr cinfo) { /* cinfo->err really points to a MyErrorMgr struct, so coerce pointer */ MyErrorPtr myerr = (MyErrorPtr) cinfo->err; /* Always display the message. */ /* We could postpone this until after returning, if we chose. */ /* internal message function cann't show error message in some platforms, so we rewrite it here. * edit it if has version confilict. */ //(*cinfo->err->output_message) (cinfo); char buffer[JMSG_LENGTH_MAX]; (*cinfo->err->format_message) (cinfo, buffer); CCLOG("jpeg error: %s", buffer); /* Return control to the setjmp point */ longjmp(myerr->setjmp_buffer, 1); } } bool Image::initWithJpgData(const unsigned char * data, ssize_t dataLen) { /* these are standard libjpeg structures for reading(decompression) */ struct jpeg_decompress_struct cinfo; /* We use our private extension JPEG error handler. * Note that this struct must live as long as the main JPEG parameter * struct, to avoid dangling-pointer problems. */ struct MyErrorMgr jerr; /* libjpeg data structure for storing one row, that is, scanline of an image */ JSAMPROW row_pointer[1] = {0}; unsigned long location = 0; unsigned int i = 0; bool bRet = false; do { /* We set up the normal JPEG error routines, then override error_exit. */ cinfo.err = jpeg_std_error(&jerr.pub); jerr.pub.error_exit = myErrorExit; /* Establish the setjmp return context for MyErrorExit to use. */ if (setjmp(jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. * We need to clean up the JPEG object, close the input file, and return. */ jpeg_destroy_decompress(&cinfo); break; } /* setup decompression process and source, then read JPEG header */ jpeg_create_decompress( &cinfo ); #ifndef CC_TARGET_QT5 jpeg_mem_src( &cinfo, const_cast(data), dataLen ); #endif /* CC_TARGET_QT5 */ /* reading the image header which contains image information */ #if (JPEG_LIB_VERSION >= 90) // libjpeg 0.9 adds stricter types. jpeg_read_header( &cinfo, TRUE ); #else jpeg_read_header( &cinfo, true ); #endif // we only support RGB or grayscale if (cinfo.jpeg_color_space == JCS_GRAYSCALE) { _renderFormat = Texture2D::PixelFormat::I8; }else { cinfo.out_color_space = JCS_RGB; _renderFormat = Texture2D::PixelFormat::RGB888; } /* Start decompression jpeg here */ jpeg_start_decompress( &cinfo ); /* init image info */ _width = cinfo.output_width; _height = cinfo.output_height; _preMulti = false; row_pointer[0] = static_cast(malloc(cinfo.output_width*cinfo.output_components * sizeof(unsigned char))); CC_BREAK_IF(! row_pointer[0]); _dataLen = cinfo.output_width*cinfo.output_height*cinfo.output_components; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); CC_BREAK_IF(! _data); /* now actually read the jpeg into the raw buffer */ /* read one scan line at a time */ while( cinfo.output_scanline < cinfo.output_height ) { jpeg_read_scanlines( &cinfo, row_pointer, 1 ); for( i=0; i(malloc(_dataLen * sizeof(unsigned char))); CC_BREAK_IF(!_data); for (unsigned short i = 0; i < _height; ++i) { row_pointers[i] = _data + i*rowbytes; } png_read_image(png_ptr, row_pointers); png_read_end(png_ptr, NULL); _preMulti = false; if (row_pointers != nullptr) { free(row_pointers); }; bRet = true; } while (0); if (png_ptr) { png_destroy_read_struct(&png_ptr, (info_ptr) ? &info_ptr : 0, 0); } return bRet; } namespace { static tmsize_t tiffReadProc(thandle_t fd, void* buf, tmsize_t size) { tImageSource* isource = (tImageSource*)fd; uint8* ma; uint64 mb; unsigned long n; unsigned long o; tmsize_t p; ma=(uint8*)buf; mb=size; p=0; while (mb>0) { n=0x80000000UL; if ((uint64)n>mb) n=(unsigned long)mb; if((int)(isource->offset + n) <= isource->size) { memcpy(ma, isource->data+isource->offset, n); isource->offset += n; o = n; } else { return 0; } ma+=o; mb-=o; p+=o; if (o!=n) { break; } } return p; } static tmsize_t tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) { CC_UNUSED_PARAM(fd); CC_UNUSED_PARAM(buf); CC_UNUSED_PARAM(size); return 0; } static uint64 tiffSeekProc(thandle_t fd, uint64 off, int whence) { tImageSource* isource = (tImageSource*)fd; uint64 ret = -1; do { if (whence == SEEK_SET) { CC_BREAK_IF(off >= (uint64)isource->size); ret = isource->offset = (uint32)off; } else if (whence == SEEK_CUR) { CC_BREAK_IF(isource->offset + off >= (uint64)isource->size); ret = isource->offset += (uint32)off; } else if (whence == SEEK_END) { CC_BREAK_IF(off >= (uint64)isource->size); ret = isource->offset = (uint32)(isource->size-1 - off); } else { CC_BREAK_IF(off >= (uint64)isource->size); ret = isource->offset = (uint32)off; } } while (0); return ret; } static uint64 tiffSizeProc(thandle_t fd) { tImageSource* pImageSrc = (tImageSource*)fd; return pImageSrc->size; } static int tiffCloseProc(thandle_t fd) { CC_UNUSED_PARAM(fd); return 0; } static int tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { CC_UNUSED_PARAM(fd); CC_UNUSED_PARAM(pbase); CC_UNUSED_PARAM(psize); return 0; } static void tiffUnmapProc(thandle_t fd, void* base, toff_t size) { CC_UNUSED_PARAM(fd); CC_UNUSED_PARAM(base); CC_UNUSED_PARAM(size); } } bool Image::initWithTiffData(const unsigned char * data, ssize_t dataLen) { bool bRet = false; do { // set the read call back function tImageSource imageSource; imageSource.data = data; imageSource.size = dataLen; imageSource.offset = 0; TIFF* tif = TIFFClientOpen("file.tif", "r", (thandle_t)&imageSource, tiffReadProc, tiffWriteProc, tiffSeekProc, tiffCloseProc, tiffSizeProc, tiffMapProc, tiffUnmapProc); CC_BREAK_IF(NULL == tif); uint32 w = 0, h = 0; uint16 bitsPerSample = 0, samplePerPixel = 0, planarConfig = 0; size_t npixels = 0; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplePerPixel); TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarConfig); npixels = w * h; _renderFormat = Texture2D::PixelFormat::RGBA8888; _width = w; _height = h; _dataLen = npixels * sizeof (uint32); _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); uint32* raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); if (raster != NULL) { if (TIFFReadRGBAImageOriented(tif, w, h, raster, ORIENTATION_TOPLEFT, 0)) { /* the raster data is pre-multiplied by the alpha component after invoking TIFFReadRGBAImageOriented*/ _preMulti = true; memcpy(_data, raster, npixels*sizeof (uint32)); } _TIFFfree(raster); } TIFFClose(tif); bRet = true; } while (0); return bRet; } namespace { bool testFormatForPvr2TCSupport(PVR2TexturePixelFormat format) { if (!Configuration::getInstance()->supportsPVRTC()) { if (format == PVR2TexturePixelFormat::PVRTC2BPP_RGBA || format == PVR2TexturePixelFormat::PVRTC4BPP_RGBA) { return false; } } return true; } bool testFormatForPvr3TCSupport(PVR3TexturePixelFormat format) { if (!Configuration::getInstance()->supportsPVRTC()) { if (format == PVR3TexturePixelFormat::PVRTC2BPP_RGB || format == PVR3TexturePixelFormat::PVRTC2BPP_RGBA || format == PVR3TexturePixelFormat::PVRTC4BPP_RGB || format == PVR3TexturePixelFormat::PVRTC4BPP_RGBA) { return false; } } return true; } } bool Image::initWithPVRv2Data(const unsigned char * data, ssize_t dataLen) { int dataLength = 0, dataOffset = 0, dataSize = 0; int blockSize = 0, widthBlocks = 0, heightBlocks = 0; int width = 0, height = 0; //Cast first sizeof(PVRTexHeader) bytes of data stream as PVRTexHeader const PVRv2TexHeader *header = static_cast(static_cast(data)); //Make sure that tag is in correct formatting if (memcmp(&header->pvrTag, gPVRTexIdentifier, strlen(gPVRTexIdentifier)) != 0) { return false; } Configuration *configuration = Configuration::getInstance(); _hasPremultipliedAlpha = false; unsigned int flags = CC_SWAP_INT32_LITTLE_TO_HOST(header->flags); PVR2TexturePixelFormat formatFlags = static_cast(flags & PVR_TEXTURE_FLAG_TYPE_MASK); bool flipped = (flags & (unsigned int)PVR2TextureFlag::VerticalFlip) ? true : false; if (flipped) { CCLOG("cocos2d: WARNING: Image is flipped. Regenerate it using PVRTexTool"); } if (! configuration->supportsNPOT() && (static_cast(header->width) != ccNextPOT(header->width) || static_cast(header->height) != ccNextPOT(header->height))) { CCLOG("cocos2d: ERROR: Loading an NPOT texture (%dx%d) but is not supported on this device", header->width, header->height); return false; } if (!testFormatForPvr2TCSupport(formatFlags)) { CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags); return false; } if (v2_pixel_formathash.find(formatFlags) == v2_pixel_formathash.end()) { CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags); return false; } auto it = Texture2D::getPixelFormatInfoMap().find(v2_pixel_formathash.at(formatFlags)); if (it == Texture2D::getPixelFormatInfoMap().end()) { CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags); return false; } _renderFormat = it->first; //Reset num of mipmaps _numberOfMipmaps = 0; //Get size of mipmap _width = width = CC_SWAP_INT32_LITTLE_TO_HOST(header->width); _height = height = CC_SWAP_INT32_LITTLE_TO_HOST(header->height); //Get ptr to where data starts.. dataLength = CC_SWAP_INT32_LITTLE_TO_HOST(header->dataLength); //Move by size of header _dataLen = dataLen - sizeof(PVRv2TexHeader); _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy(_data, (unsigned char*)data + sizeof(PVRv2TexHeader), _dataLen); // Calculate the data size for each texture level and respect the minimum number of blocks while (dataOffset < dataLength) { switch (formatFlags) { case PVR2TexturePixelFormat::PVRTC2BPP_RGBA: blockSize = 8 * 4; // Pixel by pixel block size for 2bpp widthBlocks = width / 8; heightBlocks = height / 4; break; case PVR2TexturePixelFormat::PVRTC4BPP_RGBA: blockSize = 4 * 4; // Pixel by pixel block size for 4bpp widthBlocks = width / 4; heightBlocks = height / 4; break; case PVR2TexturePixelFormat::BGRA8888: if (Configuration::getInstance()->supportsBGRA8888() == false) { CCLOG("cocos2d: Image. BGRA8888 not supported on this device"); return false; } default: blockSize = 1; widthBlocks = width; heightBlocks = height; break; } // Clamp to minimum number of blocks if (widthBlocks < 2) { widthBlocks = 2; } if (heightBlocks < 2) { heightBlocks = 2; } dataSize = widthBlocks * heightBlocks * ((blockSize * it->second.bpp) / 8); int packetLength = (dataLength - dataOffset); packetLength = packetLength > dataSize ? dataSize : packetLength; //Make record to the mipmaps array and increment counter _mipmaps[_numberOfMipmaps].address = _data + dataOffset; _mipmaps[_numberOfMipmaps].len = packetLength; _numberOfMipmaps++; dataOffset += packetLength; //Update width and height to the next lower power of two width = MAX(width >> 1, 1); height = MAX(height >> 1, 1); } return true; } bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen) { if (static_cast(dataLen) < sizeof(PVRv3TexHeader)) { return false; } const PVRv3TexHeader *header = static_cast(static_cast(data)); // validate version if (CC_SWAP_INT32_BIG_TO_HOST(header->version) != 0x50565203) { CCLOG("cocos2d: WARNING: pvr file version mismatch"); return false; } // parse pixel format PVR3TexturePixelFormat pixelFormat = static_cast(header->pixelFormat); if (!testFormatForPvr3TCSupport(pixelFormat)) { CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%016llX. Re-encode it with a OpenGL pixel format variant", static_cast(pixelFormat)); return false; } if (v3_pixel_formathash.find(pixelFormat) == v3_pixel_formathash.end()) { CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%016llX. Re-encode it with a OpenGL pixel format variant", static_cast(pixelFormat)); return false; } auto it = Texture2D::getPixelFormatInfoMap().find(v3_pixel_formathash.at(pixelFormat)); if (it == Texture2D::getPixelFormatInfoMap().end()) { CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%016llX. Re-encode it with a OpenGL pixel format variant", static_cast(pixelFormat)); return false; } _renderFormat = it->first; // flags int flags = CC_SWAP_INT32_LITTLE_TO_HOST(header->flags); // PVRv3 specifies premultiply alpha in a flag -- should always respect this in PVRv3 files if (flags & (unsigned int)PVR3TextureFlag::PremultipliedAlpha) { _preMulti = true; } // sizing int width = CC_SWAP_INT32_LITTLE_TO_HOST(header->width); int height = CC_SWAP_INT32_LITTLE_TO_HOST(header->height); _width = width; _height = height; int dataOffset = 0, dataSize = 0; int blockSize = 0, widthBlocks = 0, heightBlocks = 0; _dataLen = dataLen - (sizeof(PVRv3TexHeader) + header->metadataLength); _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy(_data, static_cast(data) + sizeof(PVRv3TexHeader) + header->metadataLength, _dataLen); _numberOfMipmaps = header->numberOfMipmaps; CCAssert(_numberOfMipmaps < MIPMAP_MAX, "Image: Maximum number of mimpaps reached. Increate the CC_MIPMAP_MAX value"); for (int i = 0; i < _numberOfMipmaps; i++) { switch ((PVR3TexturePixelFormat)pixelFormat) { case PVR3TexturePixelFormat::PVRTC2BPP_RGB : case PVR3TexturePixelFormat::PVRTC2BPP_RGBA : blockSize = 8 * 4; // Pixel by pixel block size for 2bpp widthBlocks = width / 8; heightBlocks = height / 4; break; case PVR3TexturePixelFormat::PVRTC4BPP_RGB : case PVR3TexturePixelFormat::PVRTC4BPP_RGBA : blockSize = 4 * 4; // Pixel by pixel block size for 4bpp widthBlocks = width / 4; heightBlocks = height / 4; break; case PVR3TexturePixelFormat::BGRA8888: if( ! Configuration::getInstance()->supportsBGRA8888()) { CCLOG("cocos2d: Image. BGRA8888 not supported on this device"); return false; } default: blockSize = 1; widthBlocks = width; heightBlocks = height; break; } // Clamp to minimum number of blocks if (widthBlocks < 2) { widthBlocks = 2; } if (heightBlocks < 2) { heightBlocks = 2; } dataSize = widthBlocks * heightBlocks * ((blockSize * it->second.bpp) / 8); auto packetLength = _dataLen - dataOffset; packetLength = packetLength > dataSize ? dataSize : packetLength; _mipmaps[i].address = _data + dataOffset; _mipmaps[i].len = static_cast(packetLength); dataOffset += packetLength; CCAssert(dataOffset <= _dataLen, "CCTexurePVR: Invalid lenght"); width = MAX(width >> 1, 1); height = MAX(height >> 1, 1); } return true; } bool Image::initWithETCData(const unsigned char * data, ssize_t dataLen) { const etc1_byte* header = static_cast(data); //check the data if(!etc1_pkm_is_valid(header)) { return false; } _width = etc1_pkm_get_width(header); _height = etc1_pkm_get_height(header); if( 0 == _width || 0 == _height ) { return false; } if(Configuration::getInstance()->supportsETC()) { //old opengl version has no define for GL_ETC1_RGB8_OES, add macro to make compiler happy. #ifdef GL_ETC1_RGB8_OES _renderFormat = Texture2D::PixelFormat::ETC; _dataLen = dataLen - ETC_PKM_HEADER_SIZE; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy(_data, static_cast(data) + ETC_PKM_HEADER_SIZE, _dataLen); return true; #endif } else { CCLOG("cocos2d: Hardware ETC1 decoder not present. Using software decoder"); //if it is not gles or device do not support ETC, decode texture by software int bytePerPixel = 3; unsigned int stride = _width * bytePerPixel; _renderFormat = Texture2D::PixelFormat::RGB888; _dataLen = _width * _height * bytePerPixel; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); if (etc1_decode_image(static_cast(data) + ETC_PKM_HEADER_SIZE, static_cast(_data), _width, _height, bytePerPixel, stride) != 0) { _dataLen = 0; if (_data != nullptr) { free(_data); } return false; } return true; } return false; } bool Image::initWithTGAData(tImageTGA* tgaData) { bool ret = false; do { CC_BREAK_IF(tgaData == nullptr); // tgaLoadBuffer only support type 2, 3, 10 if (2 == tgaData->type || 10 == tgaData->type) { // true color // unsupport RGB555 if (tgaData->pixelDepth == 16) { _renderFormat = Texture2D::PixelFormat::RGB5A1; } else if(tgaData->pixelDepth == 24) { _renderFormat = Texture2D::PixelFormat::RGB888; } else if(tgaData->pixelDepth == 32) { _renderFormat = Texture2D::PixelFormat::RGBA8888; } else { CCLOG("Image WARNING: unsupport true color tga data pixel format. FILE: %s", _filePath.c_str()); break; } } else if(3 == tgaData->type) { // gray if (8 == tgaData->pixelDepth) { _renderFormat = Texture2D::PixelFormat::I8; } else { // actually this won't happen, if it happens, maybe the image file is not a tga CCLOG("Image WARNING: unsupport gray tga data pixel format. FILE: %s", _filePath.c_str()); break; } } _width = tgaData->width; _height = tgaData->height; _data = tgaData->imageData; _dataLen = _width * _height * tgaData->pixelDepth / 8; _fileType = Format::TGA; _preMulti = false; ret = true; }while(false); if (ret) { const unsigned char tgaSuffix[] = ".tga"; for(int i = 0; i < 4; ++i) { if (tolower(_filePath[_filePath.length() - i - 1]) != tgaSuffix[3 - i]) { CCLOG("Image WARNING: the image file suffix is not tga, but parsed as a tga image file. FILE: %s", _filePath.c_str()); break; }; } } else { if (tgaData->imageData != nullptr) { free(tgaData->imageData); _data = nullptr; } } return ret; } namespace { static const uint32_t makeFourCC(char ch0, char ch1, char ch2, char ch3) { const uint32_t fourCC = ((uint32_t)(char)(ch0) | ((uint32_t)(char)(ch1) << 8) | ((uint32_t)(char)(ch2) << 16) | ((uint32_t)(char)(ch3) << 24 )); return fourCC; } } bool Image::initWithS3TCData(const unsigned char * data, ssize_t dataLen) { const uint32_t FOURCC_DXT1 = makeFourCC('D', 'X', 'T', '1'); const uint32_t FOURCC_DXT3 = makeFourCC('D', 'X', 'T', '3'); const uint32_t FOURCC_DXT5 = makeFourCC('D', 'X', 'T', '5'); /* load the .dds file */ S3TCTexHeader *header = (S3TCTexHeader *)data; unsigned char *pixelData = static_cast(malloc((dataLen - sizeof(S3TCTexHeader)) * sizeof(unsigned char))); memcpy((void *)pixelData, data + sizeof(S3TCTexHeader), dataLen - sizeof(S3TCTexHeader)); _width = header->ddsd.width; _height = header->ddsd.height; _numberOfMipmaps = header->ddsd.DUMMYUNIONNAMEN2.mipMapCount; _dataLen = 0; int blockSize = (FOURCC_DXT1 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) ? 8 : 16; /* caculate the dataLen */ int width = _width; int height = _height; if (Configuration::getInstance()->supportsS3TC()) //compressed data length { _dataLen = dataLen - sizeof(S3TCTexHeader); _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy((void *)_data,(void *)pixelData , _dataLen); } else //decompressed data length { for (int i = 0; i < _numberOfMipmaps && (width || height); ++i) { if (width == 0) width = 1; if (height == 0) height = 1; _dataLen += (height * width *4); width >>= 1; height >>= 1; } _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); } /* load the mipmaps */ int encodeOffset = 0; int decodeOffset = 0; width = _width; height = _height; for (int i = 0; i < _numberOfMipmaps && (width || height); ++i) { if (width == 0) width = 1; if (height == 0) height = 1; int size = ((width+3)/4)*((height+3)/4)*blockSize; if (Configuration::getInstance()->supportsS3TC()) { //decode texture throught hardware if (FOURCC_DXT1 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) { _renderFormat = Texture2D::PixelFormat::S3TC_DXT1; } else if (FOURCC_DXT3 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) { _renderFormat = Texture2D::PixelFormat::S3TC_DXT3; } else if (FOURCC_DXT5 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) { _renderFormat = Texture2D::PixelFormat::S3TC_DXT5; } _mipmaps[i].address = (unsigned char *)_data + encodeOffset; _mipmaps[i].len = size; } else { //if it is not gles or device do not support S3TC, decode texture by software CCLOG("cocos2d: Hardware S3TC decoder not present. Using software decoder"); int bytePerPixel = 4; unsigned int stride = width * bytePerPixel; _renderFormat = Texture2D::PixelFormat::RGBA8888; std::vector decodeImageData(stride * height); if (FOURCC_DXT1 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) { s3tc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, S3TCDecodeFlag::DXT1); } else if (FOURCC_DXT3 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) { s3tc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, S3TCDecodeFlag::DXT3); } else if (FOURCC_DXT5 == header->ddsd.DUMMYUNIONNAMEN4.ddpfPixelFormat.fourCC) { s3tc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, S3TCDecodeFlag::DXT5); } _mipmaps[i].address = (unsigned char *)_data + decodeOffset; _mipmaps[i].len = (stride * height); memcpy((void *)_mipmaps[i].address, (void *)&decodeImageData[0], _mipmaps[i].len); decodeOffset += stride * height; } encodeOffset += size; width >>= 1; height >>= 1; } /* end load the mipmaps */ if (pixelData != nullptr) { free(pixelData); }; return true; } bool Image::initWithATITCData(const unsigned char *data, ssize_t dataLen) { /* load the .ktx file */ ATITCTexHeader *header = (ATITCTexHeader *)data; _width = header->pixelWidth; _height = header->pixelHeight; _numberOfMipmaps = header->numberOfMipmapLevels; int blockSize = 0; switch (header->glInternalFormat) { case CC_GL_ATC_RGB_AMD: blockSize = 8; break; case CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: blockSize = 16; break; case CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: blockSize = 16; break; default: break; } /* pixelData point to the compressed data address */ unsigned char *pixelData = (unsigned char *)data + sizeof(ATITCTexHeader) + header->bytesOfKeyValueData + 4; /* caculate the dataLen */ int width = _width; int height = _height; if (Configuration::getInstance()->supportsATITC()) //compressed data length { _dataLen = dataLen - sizeof(ATITCTexHeader) - header->bytesOfKeyValueData - 4; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); memcpy((void *)_data,(void *)pixelData , _dataLen); } else //decompressed data length { for (int i = 0; i < _numberOfMipmaps && (width || height); ++i) { if (width == 0) width = 1; if (height == 0) height = 1; _dataLen += (height * width *4); width >>= 1; height >>= 1; } _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); } /* load the mipmaps */ int encodeOffset = 0; int decodeOffset = 0; width = _width; height = _height; for (int i = 0; i < _numberOfMipmaps && (width || height); ++i) { if (width == 0) width = 1; if (height == 0) height = 1; int size = ((width+3)/4)*((height+3)/4)*blockSize; if (Configuration::getInstance()->supportsATITC()) { /* decode texture throught hardware */ CCLOG("this is atitc H decode"); switch (header->glInternalFormat) { case CC_GL_ATC_RGB_AMD: _renderFormat = Texture2D::PixelFormat::ATC_RGB; break; case CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: _renderFormat = Texture2D::PixelFormat::ATC_EXPLICIT_ALPHA; break; case CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: _renderFormat = Texture2D::PixelFormat::ATC_INTERPOLATED_ALPHA; break; default: break; } _mipmaps[i].address = (unsigned char *)_data + encodeOffset; _mipmaps[i].len = size; } else { /* if it is not gles or device do not support ATITC, decode texture by software */ CCLOG("cocos2d: Hardware ATITC decoder not present. Using software decoder"); int bytePerPixel = 4; unsigned int stride = width * bytePerPixel; _renderFormat = Texture2D::PixelFormat::RGBA8888; std::vector decodeImageData(stride * height); switch (header->glInternalFormat) { case CC_GL_ATC_RGB_AMD: atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_RGB); break; case CC_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_EXPLICIT_ALPHA); break; case CC_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA); break; default: break; } _mipmaps[i].address = (unsigned char *)_data + decodeOffset; _mipmaps[i].len = (stride * height); memcpy((void *)_mipmaps[i].address, (void *)&decodeImageData[0], _mipmaps[i].len); decodeOffset += stride * height; } encodeOffset += (size + 4); width >>= 1; height >>= 1; } /* end load the mipmaps */ return true; } bool Image::initWithPVRData(const unsigned char * data, ssize_t dataLen) { return initWithPVRv2Data(data, dataLen) || initWithPVRv3Data(data, dataLen); } bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen) { bool bRet = false; do { WebPDecoderConfig config; if (WebPInitDecoderConfig(&config) == 0) break; if (WebPGetFeatures(static_cast(data), dataLen, &config.input) != VP8_STATUS_OK) break; if (config.input.width == 0 || config.input.height == 0) break; config.output.colorspace = MODE_RGBA; _renderFormat = Texture2D::PixelFormat::RGBA8888; _width = config.input.width; _height = config.input.height; _dataLen = _width * _height * 4; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); config.output.u.RGBA.rgba = static_cast(_data); config.output.u.RGBA.stride = _width * 4; config.output.u.RGBA.size = _dataLen; config.output.is_external_memory = 1; if (WebPDecode(static_cast(data), dataLen, &config) != VP8_STATUS_OK) { free(_data); _data = NULL; break; } bRet = true; } while (0); return bRet; } bool Image::initWithRawData(const unsigned char * data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti) { bool bRet = false; do { CC_BREAK_IF(0 == width || 0 == height); _height = height; _width = width; _preMulti = preMulti; _renderFormat = Texture2D::PixelFormat::RGBA8888; // only RGBA8888 supported int bytesPerComponent = 4; _dataLen = height * width * bytesPerComponent; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); CC_BREAK_IF(! _data); memcpy(_data, data, _dataLen); bRet = true; } while (0); return bRet; } #if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) bool Image::saveToFile(const std::string& filename, bool bIsToRGB) { //only support for Texture2D::PixelFormat::RGB888 or Texture2D::PixelFormat::RGBA8888 uncompressed data if (isCompressed() || (_renderFormat != Texture2D::PixelFormat::RGB888 && _renderFormat != Texture2D::PixelFormat::RGBA8888)) { CCLOG("cocos2d: Image: saveToFile is only support for Texture2D::PixelFormat::RGB888 or Texture2D::PixelFormat::RGBA8888 uncompressed data for now"); return false; } bool bRet = false; do { CC_BREAK_IF(filename.size() <= 4); std::string strLowerCasePath(filename); for (unsigned int i = 0; i < strLowerCasePath.length(); ++i) { strLowerCasePath[i] = tolower(filename[i]); } if (std::string::npos != strLowerCasePath.find(".png")) { CC_BREAK_IF(!saveImageToPNG(filename, bIsToRGB)); } else if (std::string::npos != strLowerCasePath.find(".jpg")) { CC_BREAK_IF(!saveImageToJPG(filename)); } else { break; } bRet = true; } while (0); return bRet; } #endif bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB) { bool bRet = false; do { FILE *fp; png_structp png_ptr; png_infop info_ptr; png_colorp palette; png_bytep *row_pointers; fp = fopen(filePath.c_str(), "wb"); CC_BREAK_IF(NULL == fp); png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (NULL == png_ptr) { fclose(fp); break; } info_ptr = png_create_info_struct(png_ptr); if (NULL == info_ptr) { fclose(fp); png_destroy_write_struct(&png_ptr, NULL); break; } #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA && CC_TARGET_PLATFORM != CC_PLATFORM_NACL) if (setjmp(png_jmpbuf(png_ptr))) { fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); break; } #endif png_init_io(png_ptr, fp); if (!isToRGB && hasAlpha()) { png_set_IHDR(png_ptr, info_ptr, _width, _height, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); } else { png_set_IHDR(png_ptr, info_ptr, _width, _height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); } palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * sizeof (png_color)); png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); png_write_info(png_ptr, info_ptr); png_set_packing(png_ptr); row_pointers = (png_bytep *)malloc(_height * sizeof(png_bytep)); if(row_pointers == NULL) { fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); break; } if (hasAlpha()) { for (int i = 0; i < (int)_height; i++) { row_pointers[i] = (png_bytep)_data + i * _width * 3; } png_write_image(png_ptr, row_pointers); free(row_pointers); row_pointers = NULL; } else { if (isToRGB) { unsigned char *pTempData = static_cast(malloc(_width * _height * 3 * sizeof(unsigned char*))); if (NULL == pTempData) { fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); break; } for (int i = 0; i < _height; ++i) { for (int j = 0; j < _width; ++j) { pTempData[(i * _width + j) * 3] = _data[(i * _width + j) * 4]; pTempData[(i * _width + j) * 3 + 1] = _data[(i * _width + j) * 4 + 1]; pTempData[(i * _width + j) * 3 + 2] = _data[(i * _width + j) * 4 + 2]; } } for (int i = 0; i < (int)_height; i++) { row_pointers[i] = (png_bytep)pTempData + i * _width * 3; } png_write_image(png_ptr, row_pointers); free(row_pointers); row_pointers = NULL; if (pTempData != nullptr) { free(pTempData); } } else { for (int i = 0; i < (int)_height; i++) { row_pointers[i] = (png_bytep)_data + i * _width * 4; } png_write_image(png_ptr, row_pointers); free(row_pointers); row_pointers = NULL; } } png_write_end(png_ptr, info_ptr); png_free(png_ptr, palette); palette = NULL; png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); bRet = true; } while (0); return bRet; } bool Image::saveImageToJPG(const std::string& filePath) { bool bRet = false; do { struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; FILE * outfile; /* target file */ JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ int row_stride; /* physical row width in image buffer */ cinfo.err = jpeg_std_error(&jerr); /* Now we can initialize the JPEG compression object. */ jpeg_create_compress(&cinfo); CC_BREAK_IF((outfile = fopen(filePath.c_str(), "wb")) == NULL); jpeg_stdio_dest(&cinfo, outfile); cinfo.image_width = _width; /* image width and height, in pixels */ cinfo.image_height = _height; cinfo.input_components = 3; /* # of color components per pixel */ cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ jpeg_set_defaults(&cinfo); jpeg_start_compress(&cinfo, TRUE); row_stride = _width * 3; /* JSAMPLEs per row in image_buffer */ if (hasAlpha()) { unsigned char *pTempData = static_cast(malloc(_width * _height * 3 * sizeof(unsigned char))); if (NULL == pTempData) { jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); fclose(outfile); break; } for (int i = 0; i < _height; ++i) { for (int j = 0; j < _width; ++j) { pTempData[(i * _width + j) * 3] = _data[(i * _width + j) * 4]; pTempData[(i * _width + j) * 3 + 1] = _data[(i * _width + j) * 4 + 1]; pTempData[(i * _width + j) * 3 + 2] = _data[(i * _width + j) * 4 + 2]; } } while (cinfo.next_scanline < cinfo.image_height) { row_pointer[0] = & pTempData[cinfo.next_scanline * row_stride]; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } if (pTempData != nullptr) { free(pTempData); } } else { while (cinfo.next_scanline < cinfo.image_height) { row_pointer[0] = & _data[cinfo.next_scanline * row_stride]; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } } jpeg_finish_compress(&cinfo); fclose(outfile); jpeg_destroy_compress(&cinfo); bRet = true; } while (0); return bRet; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/CCSAXParser.cpp ================================================ /**************************************************************************** Copyright (c) 2010 Максим Аксенов Copyright (c) 2010 cocos2d-x.org Copyright (c) 2013 Martell Malone 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 "CCSAXParser.h" #include "CCFileUtils.h" #include "tinyxml2.h" #include // because its based on windows 8 build :P NS_CC_BEGIN class XmlSaxHander : public tinyxml2::XMLVisitor { public: XmlSaxHander():_ccsaxParserImp(0){}; virtual bool VisitEnter( const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* firstAttribute ); virtual bool VisitExit( const tinyxml2::XMLElement& element ); virtual bool Visit( const tinyxml2::XMLText& text ); virtual bool Visit( const tinyxml2::XMLUnknown&){ return true; } void setSAXParserImp(SAXParser* parser) { _ccsaxParserImp = parser; } private: SAXParser *_ccsaxParserImp; }; bool XmlSaxHander::VisitEnter( const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* firstAttribute ) { //log(" VisitEnter %s",element.Value()); std::vector attsVector; for( const tinyxml2::XMLAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) { //log("%s", attrib->Name()); attsVector.push_back(attrib->Name()); //log("%s",attrib->Value()); attsVector.push_back(attrib->Value()); } // nullptr is used in c++11 //attsVector.push_back(nullptr); attsVector.push_back(nullptr); SAXParser::startElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value(), (const CC_XML_CHAR **)(&attsVector[0])); return true; } bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element ) { //log("VisitExit %s",element.Value()); SAXParser::endElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value()); return true; } bool XmlSaxHander::Visit( const tinyxml2::XMLText& text ) { //log("Visit %s",text.Value()); SAXParser::textHandler(_ccsaxParserImp, (const CC_XML_CHAR *)text.Value(), static_cast(strlen(text.Value()))); return true; } SAXParser::SAXParser() { _delegator = nullptr; } SAXParser::~SAXParser(void) { } bool SAXParser::init(const char *encoding) { CC_UNUSED_PARAM(encoding); // nothing to do return true; } bool SAXParser::parse(const char* xmlData, size_t dataLength) { tinyxml2::XMLDocument tinyDoc; tinyDoc.Parse(xmlData, dataLength); XmlSaxHander printer; printer.setSAXParserImp(this); return tinyDoc.Accept( &printer ); } bool SAXParser::parse(const std::string& filename) { bool ret = false; Data data = FileUtils::getInstance()->getDataFromFile(filename); if (!data.isNull()) { ret = parse((const char*)data.getBytes(), data.getSize()); } return ret; } void SAXParser::startElement(void *ctx, const CC_XML_CHAR *name, const CC_XML_CHAR **atts) { ((SAXParser*)(ctx))->_delegator->startElement(ctx, (char*)name, (const char**)atts); } void SAXParser::endElement(void *ctx, const CC_XML_CHAR *name) { ((SAXParser*)(ctx))->_delegator->endElement(ctx, (char*)name); } void SAXParser::textHandler(void *ctx, const CC_XML_CHAR *name, int len) { ((SAXParser*)(ctx))->_delegator->textHandler(ctx, (char*)name, len); } void SAXParser::setDelegator(SAXDelegator* delegator) { _delegator = delegator; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/CCSAXParser.h ================================================ /**************************************************************************** Copyright (c) 2010 cocos2d-x.org Copyright (c) 2010 Максим Аксенов 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 __CCSAXPARSER_H__ #define __CCSAXPARSER_H__ #include "CCPlatformConfig.h" #include "platform/CCCommon.h" #include NS_CC_BEGIN /** * @addtogroup platform * @{ */ typedef unsigned char CC_XML_CHAR; class CC_DLL SAXDelegator { public: virtual ~SAXDelegator() {} /** * @js NA * @lua NA */ virtual void startElement(void *ctx, const char *name, const char **atts) = 0; /** * @js NA * @lua NA */ virtual void endElement(void *ctx, const char *name) = 0; /** * @js NA * @lua NA */ virtual void textHandler(void *ctx, const char *s, int len) = 0; }; class CC_DLL SAXParser { SAXDelegator* _delegator; public: /** * @js NA * @lua NA */ SAXParser(); /** * @js NA * @lua NA */ ~SAXParser(void); /** * @js NA * @lua NA */ bool init(const char *encoding); /** * @js NA * @lua NA */ bool parse(const char* xmlData, size_t dataLength); /** * @js NA * @lua NA */ bool parse(const std::string& filename); /** * @js NA * @lua NA */ void setDelegator(SAXDelegator* delegator); /** * @js NA * @lua NA */ static void startElement(void *ctx, const CC_XML_CHAR *name, const CC_XML_CHAR **atts); /** * @js NA * @lua NA */ static void endElement(void *ctx, const CC_XML_CHAR *name); /** * @js NA * @lua NA */ static void textHandler(void *ctx, const CC_XML_CHAR *name, int len); }; // end of platform group /// @} NS_CC_END #endif //__CCSAXPARSER_H__ ================================================ FILE: cocos2d/cocos/2d/platform/CCThread.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCThread.h" NS_CC_BEGIN // iOS and Mac already has a Thread.mm #if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_MAC) void* ThreadHelper::createAutoreleasePool() { return nullptr; } void ThreadHelper::releaseAutoreleasePool(void* autoreleasePool) { } #endif NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/CCThread.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_PLATFORM_THREAD_H__ #define __CC_PLATFORM_THREAD_H__ #include #include #include #include "platform/CCCommon.h" #include "CCPlatformMacros.h" #include "CCDirector.h" NS_CC_BEGIN /** * @addtogroup platform * @{ */ /* On iOS, should create autorelease pool when create a new thread * and release it when the thread end. */ class CC_DLL ThreadHelper { public: friend DisplayLinkDirector; /** Create an autorelease pool for objective-c codes. * @js NA * @lua NA */ static void* createAutoreleasePool(); /** * @js NA * @lua NA */ static void releaseAutoreleasePool(void *autoreleasePool); }; // end of platform group /// @} NS_CC_END #endif // __CC_PLATFORM_THREAD_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos2dxandroid_static LOCAL_MODULE_FILENAME := libcocos2dandroid LOCAL_SRC_FILES := \ CCApplication.cpp \ CCCommon.cpp \ CCDevice.cpp \ CCEGLView.cpp \ CCFileUtilsAndroid.cpp \ CCImage.cpp \ nativeactivity.cpp \ jni/DPIJni.cpp \ jni/IMEJni.cpp \ jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp \ jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp \ jni/JniHelper.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/../../../base \ $(LOCAL_PATH)/../../../math/kazmath/include \ $(LOCAL_PATH)/../../../physics LOCAL_LDLIBS := -lGLESv1_CM \ -lGLESv2 \ -lEGL \ -llog \ -lz \ -landroid LOCAL_EXPORT_LDLIBS := -lGLESv1_CM \ -lGLESv2 \ -lEGL \ -llog \ -lz \ -landroid LOCAL_WHOLE_STATIC_LIBRARIES := android_native_app_glue cocos_png_static cocos_jpeg_static cocos_tiff_static cocos_webp_static include $(BUILD_STATIC_LIBRARY) $(call import-module,jpeg/prebuilt/android) $(call import-module,png/prebuilt/android) $(call import-module,tiff/prebuilt/android) $(call import-module,webp/prebuilt/android) $(call import-module,android/native_app_glue) ================================================ FILE: cocos2d/cocos/2d/platform/android/CCApplication.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "jni/JniHelper.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "CCApplication.h" #include "CCDirector.h" #include "CCEGLView.h" #include #include #include #define LOG_TAG "CCApplication_android Debug" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) NS_CC_BEGIN // sharedApplication pointer Application * Application::sm_pSharedApplication = 0; Application::Application() { CCAssert(! sm_pSharedApplication, ""); sm_pSharedApplication = this; } Application::~Application() { CCAssert(this == sm_pSharedApplication, ""); sm_pSharedApplication = NULL; } int Application::run() { // Initialize instance and cocos2d. if (! applicationDidFinishLaunching()) { return 0; } return -1; } void Application::setAnimationInterval(double interval) { // NYI } ////////////////////////////////////////////////////////////////////////// // static member function ////////////////////////////////////////////////////////////////////////// Application* Application::getInstance() { CCAssert(sm_pSharedApplication, ""); return sm_pSharedApplication; } // @deprecated Use getInstance() instead Application* Application::sharedApplication() { return Application::getInstance(); } LanguageType Application::getCurrentLanguage() { std::string languageName = getCurrentLanguageJNI(); const char* pLanguageName = languageName.c_str(); LanguageType ret = LanguageType::ENGLISH; if (0 == strcmp("zh", pLanguageName)) { ret = LanguageType::CHINESE; } else if (0 == strcmp("en", pLanguageName)) { ret = LanguageType::ENGLISH; } else if (0 == strcmp("fr", pLanguageName)) { ret = LanguageType::FRENCH; } else if (0 == strcmp("it", pLanguageName)) { ret = LanguageType::ITALIAN; } else if (0 == strcmp("de", pLanguageName)) { ret = LanguageType::GERMAN; } else if (0 == strcmp("es", pLanguageName)) { ret = LanguageType::SPANISH; } else if (0 == strcmp("ru", pLanguageName)) { ret = LanguageType::RUSSIAN; } else if (0 == strcmp("ko", pLanguageName)) { ret = LanguageType::KOREAN; } else if (0 == strcmp("ja", pLanguageName)) { ret = LanguageType::JAPANESE; } else if (0 == strcmp("hu", pLanguageName)) { ret = LanguageType::HUNGARIAN; } else if (0 == strcmp("pt", pLanguageName)) { ret = LanguageType::PORTUGUESE; } else if (0 == strcmp("ar", pLanguageName)) { ret = LanguageType::ARABIC; } else if (0 == strcmp("nb", pLanguageName)) { ret = LanguageType::NORWEGIAN; } else if (0 == strcmp("pl", pLanguageName)) { ret = LanguageType::POLISH; } return ret; } Application::Platform Application::getTargetPlatform() { return Platform::OS_ANDROID; } void Application::applicationScreenSizeChanged(int newWidth, int newHeight) { } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/android/CCApplication.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_APPLICATION_ANDROID_H__ #define __CC_APPLICATION_ANDROID_H__ #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" NS_CC_BEGIN class CC_DLL Application : public ApplicationProtocol { public: /** * @js ctor */ Application(); /** * @js NA * @lua NA */ virtual ~Application(); /** @brief Callback by Director to limit FPS. @param interval The time, expressed in seconds, between current frame and next. */ void setAnimationInterval(double interval); /** @brief Run the message loop. */ int run(); /** @brief Get current application instance. @return Current application instance pointer. */ static Application* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication(); /** @brief Get current language config @return Current language config */ virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ virtual Platform getTargetPlatform(); /** @brief This function will be called when the application screen size is changed. @param new width @param new height */ virtual void applicationScreenSizeChanged(int newWidth, int newHeight); protected: static Application * sm_pSharedApplication; }; NS_CC_END #endif // __CC_APPLICATION_ANDROID_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/CCCommon.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCCommon.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include #include #include NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) void MessageBox(const char * pszMsg, const char * pszTitle) { showDialogJNI(pszMsg, pszTitle); } void LuaLog(const char * pszFormat) { __android_log_write(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/android/CCDevice.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCDevice.h" #include "jni/DPIJni.h" #include "nativeactivity.h" NS_CC_BEGIN int Device::getDPI() { static int dpi = -1; if (dpi == -1) { dpi = (int)getDPIJNI(); } return dpi; } void Device::setAccelerometerEnabled(bool isEnabled) { if (isEnabled) { enableAccelerometerJni(); } else { disableAccelerometerJni(); } } void Device::setAccelerometerInterval(float interval) { setAccelerometerIntervalJni(interval); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/android/CCEGLView.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEGLView.h" #include "CCSet.h" #include "CCDirector.h" #include "ccMacros.h" #include "jni/IMEJni.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "CCGL.h" #include #include // exists since android 2.3 #include PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0; PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT = 0; PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT = 0; void initExtensions() { glGenVertexArraysOESEXT = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES"); glBindVertexArrayOESEXT = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES"); glDeleteVertexArraysOESEXT = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES"); } NS_CC_BEGIN EGLView::EGLView() { initExtensions(); } EGLView::~EGLView() { } bool EGLView::isOpenGLReady() { return (_screenSize.width != 0 && _screenSize.height != 0); } void EGLView::end() { terminateProcessJNI(); } void EGLView::swapBuffers() { } EGLView* EGLView::getInstance() { static EGLView instance; return &instance; } // XXX: deprecated EGLView* EGLView::sharedOpenGLView() { return EGLView::getInstance(); } void EGLView::setIMEKeyboardState(bool bOpen) { setKeyboardStateJNI((int)bOpen); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/android/CCEGLView.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EGLVIEW_ANDROID_H__ #define __CC_EGLVIEW_ANDROID_H__ #include "CCGeometry.h" #include "platform/CCEGLViewProtocol.h" NS_CC_BEGIN class CC_DLL EGLView : public EGLViewProtocol { public: /** * @js ctor */ EGLView(); /** * @js NA * @lua NA */ virtual ~EGLView(); bool isOpenGLReady(); // keep compatible void end(); void swapBuffers(); void setIMEKeyboardState(bool bOpen); // static function /** @brief get the shared main open gl window */ static EGLView* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView(); }; NS_CC_END #endif // end of __CC_EGLVIEW_ANDROID_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/CCFileUtilsAndroid.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCFileUtilsAndroid.h" #include "platform/CCCommon.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "android/asset_manager.h" #include "android/asset_manager_jni.h" #include #define LOG_TAG "CCFileUtilsAndroid.cpp" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) using namespace std; NS_CC_BEGIN AAssetManager* FileUtilsAndroid::assetmanager = nullptr; void FileUtilsAndroid::setassetmanager(AAssetManager* a) { if (nullptr == a) { LOGD("setassetmanager : received unexpected nullptr parameter"); return; } cocos2d::FileUtilsAndroid::assetmanager = a; } FileUtils* FileUtils::getInstance() { if (s_sharedFileUtils == nullptr) { s_sharedFileUtils = new FileUtilsAndroid(); if(!s_sharedFileUtils->init()) { delete s_sharedFileUtils; s_sharedFileUtils = nullptr; CCLOG("ERROR: Could not init CCFileUtilsAndroid"); } } return s_sharedFileUtils; } FileUtilsAndroid::FileUtilsAndroid() { } FileUtilsAndroid::~FileUtilsAndroid() { } bool FileUtilsAndroid::init() { _defaultResRootPath = "assets/"; return FileUtils::init(); } bool FileUtilsAndroid::isFileExist(const std::string& strFilePath) const { if (0 == strFilePath.length()) { return false; } bool bFound = false; // Check whether file exists in apk. if (strFilePath[0] != '/') { const char* s = strFilePath.c_str(); // Found "assets/" at the beginning of the path and we don't want it if (strFilePath.find(_defaultResRootPath) == 0) s += strlen("assets/"); if (FileUtilsAndroid::assetmanager) { AAsset* aa = AAssetManager_open(FileUtilsAndroid::assetmanager, s, AASSET_MODE_UNKNOWN); if (aa) { bFound = true; AAsset_close(aa); } else { // CCLOG("[AssetManager] ... in APK %s, found = false!", strFilePath.c_str()); } } } else { FILE *fp = fopen(strFilePath.c_str(), "r"); if(fp) { bFound = true; fclose(fp); } } return bFound; } bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath) const { // On Android, there are two situations for full path. // 1) Files in APK, e.g. assets/path/path/file.png // 2) Files not in APK, e.g. /data/data/org.cocos2dx.hellocpp/cache/path/path/file.png, or /sdcard/path/path/file.png. // So these two situations need to be checked on Android. if (strPath[0] == '/' || strPath.find(_defaultResRootPath) == 0) { return true; } return false; } Data FileUtilsAndroid::getData(const std::string& filename, bool forString) { if (filename.empty()) { return Data::Null; } unsigned char* data = nullptr; ssize_t size = 0; string fullPath = fullPathForFilename(filename); if (fullPath[0] != '/') { string relativePath = string(); size_t position = fullPath.find("assets/"); if (0 == position) { // "assets/" is at the beginning of the path and we don't want it relativePath += fullPath.substr(strlen("assets/")); } else { relativePath += fullPath; } LOGD("relative path = %s", relativePath.c_str()); if (nullptr == FileUtilsAndroid::assetmanager) { LOGD("... FileUtilsAndroid::assetmanager is nullptr"); return Data::Null; } // read asset data AAsset* asset = AAssetManager_open(FileUtilsAndroid::assetmanager, relativePath.c_str(), AASSET_MODE_UNKNOWN); if (nullptr == asset) { LOGD("asset is nullptr"); return Data::Null; } off_t fileSize = AAsset_getLength(asset); if (forString) { data = (unsigned char*) malloc(fileSize + 1); data[fileSize] = '\0'; } else { data = (unsigned char*) malloc(fileSize); } int bytesread = AAsset_read(asset, (void*)data, fileSize); size = bytesread; AAsset_close(asset); } else { do { // read rrom other path than user set it //CCLOG("GETTING FILE ABSOLUTE DATA: %s", filename); const char* mode = nullptr; if (forString) mode = "rt"; else mode = "rb"; FILE *fp = fopen(fullPath.c_str(), mode); CC_BREAK_IF(!fp); long fileSize; fseek(fp,0,SEEK_END); fileSize = ftell(fp); fseek(fp,0,SEEK_SET); if (forString) { data = (unsigned char*) malloc(fileSize + 1); data[fileSize] = '\0'; } else { data = (unsigned char*) malloc(fileSize); } fileSize = fread(data,sizeof(unsigned char), fileSize,fp); fclose(fp); size = fileSize; } while (0); } Data ret; if (data == nullptr || size == 0) { std::string msg = "Get data from file("; msg.append(filename).append(") failed!"); CCLOG("%s", msg.c_str()); } else { ret.fastSet(data, size); } return ret; } std::string FileUtilsAndroid::getStringFromFile(const std::string& filename) { Data data = getData(filename, true); std::string ret((const char*)data.getBytes()); return ret; } Data FileUtilsAndroid::getDataFromFile(const std::string& filename) { return getData(filename, false); } unsigned char* FileUtilsAndroid::getFileData(const std::string& filename, const char* mode, ssize_t * size) { unsigned char * data = 0; if ( filename.empty() || (! mode) ) { return 0; } string fullPath = fullPathForFilename(filename); if (fullPath[0] != '/') { string relativePath = string(); size_t position = fullPath.find("assets/"); if (0 == position) { // "assets/" is at the beginning of the path and we don't want it relativePath += fullPath.substr(strlen("assets/")); } else { relativePath += fullPath; } LOGD("relative path = %s", relativePath.c_str()); if (nullptr == FileUtilsAndroid::assetmanager) { LOGD("... FileUtilsAndroid::assetmanager is nullptr"); return nullptr; } // read asset data AAsset* asset = AAssetManager_open(FileUtilsAndroid::assetmanager, relativePath.c_str(), AASSET_MODE_UNKNOWN); if (nullptr == asset) { LOGD("asset is nullptr"); return nullptr; } off_t fileSize = AAsset_getLength(asset); data = (unsigned char*) malloc(fileSize); int bytesread = AAsset_read(asset, (void*)data, fileSize); if (size) { *size = bytesread; } AAsset_close(asset); } else { do { // read rrom other path than user set it //CCLOG("GETTING FILE ABSOLUTE DATA: %s", filename); FILE *fp = fopen(fullPath.c_str(), mode); CC_BREAK_IF(!fp); long fileSize; fseek(fp,0,SEEK_END); fileSize = ftell(fp); fseek(fp,0,SEEK_SET); data = (unsigned char*) malloc(fileSize); fileSize = fread(data,sizeof(unsigned char), fileSize,fp); fclose(fp); if (size) { *size = fileSize; } } while (0); } if (! data) { std::string msg = "Get data from file("; msg.append(filename).append(") failed!"); CCLOG("%s", msg.c_str()); } return data; } string FileUtilsAndroid::getWritablePath() const { // Fix for Nexus 10 (Android 4.2 multi-user environment) // the path is retrieved through Java Context.getCacheDir() method string dir(""); string tmp = getFileDirectoryJNI(); if (tmp.length() > 0) { dir.append(tmp).append("/"); return dir; } else { return ""; } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/android/CCFileUtilsAndroid.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_FILEUTILS_ANDROID_H__ #define __CC_FILEUTILS_ANDROID_H__ #include "platform/CCFileUtils.h" #include "CCPlatformMacros.h" #include "ccTypes.h" #include #include #include "jni.h" #include "android/asset_manager.h" NS_CC_BEGIN /** * @addtogroup platform * @{ */ //! @brief Helper class to handle file operations class CC_DLL FileUtilsAndroid : public FileUtils { friend class FileUtils; FileUtilsAndroid(); public: /** * @js NA * @lua NA */ virtual ~FileUtilsAndroid(); static void setassetmanager(AAssetManager* a); /* override funtions */ bool init(); /** @deprecated Please use FileUtils::getDataFromFile or FileUtils::getStringFromFile instead. */ CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const std::string& filename, const char* mode, ssize_t * size) override; /** * Gets string from a file. */ virtual std::string getStringFromFile(const std::string& filename) override; /** * Creates binary data from a file. * @return A data object. */ virtual Data getDataFromFile(const std::string& filename) override; virtual std::string getWritablePath() const; virtual bool isFileExist(const std::string& strFilePath) const; virtual bool isAbsolutePath(const std::string& strPath) const; private: Data getData(const std::string& filename, bool forString); static AAssetManager* assetmanager; }; // end of platform group /// @} NS_CC_END #endif // __CC_FILEUTILS_ANDROID_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/CCGL.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCGL_H__ #define __CCGL_H__ #define glClearDepth glClearDepthf #define glDeleteVertexArrays glDeleteVertexArraysOES #define glGenVertexArrays glGenVertexArraysOES #define glBindVertexArray glBindVertexArrayOES #define glMapBuffer glMapBufferOES #define glUnmapBuffer glUnmapBufferOES #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES #define GL_WRITE_ONLY GL_WRITE_ONLY_OES // GL_GLEXT_PROTOTYPES isn't defined in glplatform.h on android ndk r7 // we manually define it here #include #ifndef GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES 1 #endif // normal process #include #include // gl2.h doesn't define GLchar on Android typedef char GLchar; // android defines GL_BGRA_EXT but not GL_BRGA #ifndef GL_BGRA #define GL_BGRA 0x80E1 #endif //declare here while define in EGLView_android.cpp extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT; extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT; extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT; #define glGenVertexArraysOES glGenVertexArraysOESEXT #define glBindVertexArrayOES glBindVertexArrayOESEXT #define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT #endif // __CCGL_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/CCImage.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ //#define COCOS2D_DEBUG 1 #define __CC_PLATFORM_IMAGE_CPP__ #include "platform/CCImageCommon_cpp.h" #include "CCPlatformMacros.h" #include "platform/CCImage.h" #include "platform/CCFileUtils.h" #include "jni/JniHelper.h" #include #include #include NS_CC_BEGIN class BitmapDC { public: BitmapDC() : _data(NULL) , _width(0) , _height(0) { } ~BitmapDC(void) { if (_data) { delete [] _data; } } bool getBitmapFromJavaShadowStroke( const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize, float textTintR = 1.0, float textTintG = 1.0, float textTintB = 1.0, bool shadow = false, float shadowDeltaX = 0.0, float shadowDeltaY = 0.0, float shadowBlur = 0.0, float shadowOpacity = 0.0, bool stroke = false, float strokeColorR = 0.0, float strokeColorG = 0.0, float strokeColorB = 0.0, float strokeSize = 0.0 ) { JniMethodInfo methodInfo; if (! JniHelper::getStaticMethodInfo(methodInfo, "org/cocos2dx/lib/Cocos2dxBitmap", "createTextBitmapShadowStroke", "(Ljava/lang/String;Ljava/lang/String;IFFFIIIZFFFFZFFFF)Z")) { CCLOG("%s %d: error to get methodInfo", __FILE__, __LINE__); return false; } // Do a full lookup for the font path using FileUtils in case the given font name is a relative path to a font file asset, // or the path has been mapped to a different location in the app package: std::string fullPathOrFontName = FileUtils::getInstance()->fullPathForFilename(pFontName); // If the path name returned includes the 'assets' dir then that needs to be removed, because the android.content.Context // requires this portion of the path to be omitted for assets inside the app package. if (fullPathOrFontName.find("assets/") == 0) { fullPathOrFontName = fullPathOrFontName.substr(strlen("assets/")); // Chop out the 'assets/' portion of the path. } /**create bitmap * this method call Cococs2dx.createBitmap()(java code) to create the bitmap, the java code * will call Java_org_cocos2dx_lib_Cocos2dxBitmap_nativeInitBitmapDC() to init the width, height * and data. * use this approach to decrease the jni call number */ jstring jstrText = methodInfo.env->NewStringUTF(text); jstring jstrFont = methodInfo.env->NewStringUTF(fullPathOrFontName.c_str()); if(!methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID, jstrText, jstrFont, (int)fontSize, textTintR, textTintG, textTintB, eAlignMask, nWidth, nHeight, shadow, shadowDeltaX, -shadowDeltaY, shadowBlur, shadowOpacity, stroke, strokeColorR, strokeColorG, strokeColorB, strokeSize)) { return false; } methodInfo.env->DeleteLocalRef(jstrText); methodInfo.env->DeleteLocalRef(jstrFont); methodInfo.env->DeleteLocalRef(methodInfo.classID); return true; } bool getBitmapFromJava(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { return getBitmapFromJavaShadowStroke( text, nWidth, nHeight, eAlignMask, pFontName, fontSize ); } public: int _width; int _height; unsigned char *_data; JNIEnv *env; }; static BitmapDC& sharedBitmapDC() { static BitmapDC s_BmpDC; return s_BmpDC; } bool Image::initWithString( const char * pText, int nWidth/* = 0*/, int nHeight/* = 0*/, TextAlign eAlignMask/* = kAlignCenter*/, const char * pFontName/* = nil*/, int nSize/* = 0*/) { bool bRet = false; do { CC_BREAK_IF(! pText); BitmapDC &dc = sharedBitmapDC(); CC_BREAK_IF(! dc.getBitmapFromJava(pText, nWidth, nHeight, eAlignMask, pFontName, nSize)); // assign the dc._data to _data in order to save time _data = dc._data; CC_BREAK_IF(! _data); _width = (short)dc._width; _height = (short)dc._height; _preMulti = true; _renderFormat = Texture2D::PixelFormat::RGBA8888; _dataLen = _width * _height * 4; bRet = true; } while (0); return bRet; } bool Image::initWithStringShadowStroke( const char * pText, int nWidth , int nHeight , TextAlign eAlignMask , const char * pFontName , int nSize , float textTintR, float textTintG, float textTintB, bool shadow, float shadowOffsetX, float shadowOffsetY, float shadowOpacity, float shadowBlur, bool stroke, float strokeR, float strokeG, float strokeB, float strokeSize) { bool bRet = false; do { CC_BREAK_IF(! pText); BitmapDC &dc = sharedBitmapDC(); CC_BREAK_IF(! dc.getBitmapFromJavaShadowStroke(pText, nWidth, nHeight, eAlignMask, pFontName, nSize, textTintR, textTintG, textTintB, shadow, shadowOffsetX, shadowOffsetY, shadowBlur, shadowOpacity, stroke, strokeR, strokeG, strokeB, strokeSize )); // assign the dc._data to _data in order to save time _data = dc._data; CC_BREAK_IF(! _data); _width = (short)dc._width; _height = (short)dc._height; _preMulti = true; _renderFormat = Texture2D::PixelFormat::RGBA8888; _dataLen = _width * _height * 4; // ok bRet = true; } while (0); return bRet; } NS_CC_END // this method is called by Cocos2dxBitmap extern "C" { /** * this method is called by java code to init width, height and pixels data */ JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxBitmap_nativeInitBitmapDC(JNIEnv* env, jobject thiz, int width, int height, jbyteArray pixels) { int size = width * height * 4; cocos2d::BitmapDC& bitmapDC = cocos2d::sharedBitmapDC(); bitmapDC._width = width; bitmapDC._height = height; bitmapDC._data = new unsigned char[size]; env->GetByteArrayRegion(pixels, 0, size, (jbyte*)bitmapDC._data); } }; ================================================ FILE: cocos2d/cocos/2d/platform/android/CCPlatformDefine.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ #include "android/log.h" #define CC_DLL #define CC_NO_MESSAGE_PSEUDOASSERT(cond) \ if (!(cond)) { \ __android_log_print(ANDROID_LOG_ERROR, \ "cocos2d-x assert", \ "%s function:%s line:%d", \ __FILE__, __FUNCTION__, __LINE__); \ } #define CC_MESSAGE_PSEUDOASSERT(cond, msg) \ if (!(cond)) { \ __android_log_print(ANDROID_LOG_ERROR, \ "cocos2d-x assert", \ "file:%s function:%s line:%d, %s", \ __FILE__, __FUNCTION__, __LINE__, msg); \ } #define CC_ASSERT(cond) CC_NO_MESSAGE_PSEUDOASSERT(cond) #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam /* Define NULL pointer value */ #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif #endif /* __CCPLATFORMDEFINE_H__*/ ================================================ FILE: cocos2d/cocos/2d/platform/android/CCStdC.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_STD_C_H__ #define __CC_STD_C_H__ #include "CCPlatformMacros.h" #include #include #include #include #include #include #include #include #include #ifndef MIN #define MIN(x,y) (((x) > (y)) ? (y) : (x)) #endif // MIN #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX #endif // __CC_STD_C_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/java/.classpath ================================================ ================================================ FILE: cocos2d/cocos/2d/platform/android/java/.project ================================================ libcocos2dx 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 ================================================ FILE: cocos2d/cocos/2d/platform/android/java/.settings/org.eclipse.jdt.core.prefs ================================================ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.source=1.6 ================================================ FILE: cocos2d/cocos/2d/platform/android/java/AndroidManifest.xml ================================================ ================================================ FILE: cocos2d/cocos/2d/platform/android/java/ant.properties ================================================ # 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. ================================================ FILE: cocos2d/cocos/2d/platform/android/java/build.xml ================================================ ================================================ FILE: cocos2d/cocos/2d/platform/android/java/proguard-project.txt ================================================ # 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 *; #} ================================================ FILE: cocos2d/cocos/2d/platform/android/java/project.properties ================================================ # 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 android.library=true # Project target. target=android-10 ================================================ FILE: cocos2d/cocos/2d/platform/android/java/res/.gitignore ================================================ ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.LinkedList; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Paint.Align; import android.graphics.Paint.FontMetricsInt; import android.graphics.Rect; import android.graphics.Typeface; import android.text.TextPaint; import android.text.TextUtils; import android.util.FloatMath; import android.util.Log; public class Cocos2dxBitmap { // =========================================================== // Constants // =========================================================== /* The values are the same as cocos2dx/platform/CCImage.h. */ private static final int HORIZONTALALIGN_LEFT = 1; private static final int HORIZONTALALIGN_RIGHT = 2; private static final int HORIZONTALALIGN_CENTER = 3; private static final int VERTICALALIGN_TOP = 1; private static final int VERTICALALIGN_BOTTOM = 2; private static final int VERTICALALIGN_CENTER = 3; // =========================================================== // Fields // =========================================================== private static Context _context; // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== public static void setContext(final Context context) { Cocos2dxBitmap._context = context; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== private static native void nativeInitBitmapDC(final int width, final int height, final byte[] pixels); /** * @param pWidth * the width to draw, it can be 0 * @param pHeight * the height to draw, it can be 0 */ public static void createTextBitmap(String string, final String fontName, final int fontSize, final int alignment, final int width, final int height) { // createTextBitmapShadowStroke( string, fontName, fontSize, 1.0f, 1.0f, 1.0f, // text font and color alignment, width, height, // alignment and size false, 0.0f, 0.0f, 0.0f, 0.0f, // no shadow false, 1.0f, 1.0f, 1.0f, 1.0f); // no stroke } public static boolean createTextBitmapShadowStroke(String string, final String fontName, final int fontSize, final float fontTintR, final float fontTintG, final float fontTintB, final int alignment, final int width, final int height, final boolean shadow, final float shadowDX, final float shadowDY, final float shadowBlur, final float shadowOpacity, final boolean stroke, final float strokeR, final float strokeG, final float strokeB, final float strokeSize) { final int horizontalAlignment = alignment & 0x0F; final int verticalAlignment = (alignment >> 4) & 0x0F; string = Cocos2dxBitmap.refactorString(string); final Paint paint = Cocos2dxBitmap.newPaint(fontName, fontSize, horizontalAlignment); /** * if the first word width less than designed width,It means no words to show */ if(0 != width) { final int firstWordWidth = (int) FloatMath.ceil(paint.measureText(string, 0,1)); if ( firstWordWidth > width) { Log.w("createTextBitmapShadowStroke warning:","the input width is less than the width of the pString's first word\n"); return false; } } // set the paint color paint.setARGB(255, (int)(255.0 * fontTintR), (int)(255.0 * fontTintG), (int)(255.0 * fontTintB)); final TextProperty textProperty = Cocos2dxBitmap.computeTextProperty(string, width, height, paint); final int bitmapTotalHeight = (height == 0 ? textProperty.mTotalHeight: height); // padding needed when using shadows (not used otherwise) float bitmapPaddingX = 0.0f; float bitmapPaddingY = 0.0f; float renderTextDeltaX = 0.0f; float renderTextDeltaY = 0.0f; if ( shadow ) { int shadowColor = ((int)(255 * shadowOpacity) & 0xff) << 24; paint.setShadowLayer(shadowBlur, shadowDX, shadowDY, shadowColor); bitmapPaddingX = Math.abs(shadowDX); bitmapPaddingY = Math.abs(shadowDY); if ( shadowDX < 0.0 ) { renderTextDeltaX = bitmapPaddingX; } if ( shadowDY < 0.0 ) { renderTextDeltaY = bitmapPaddingY; } } if (0 == textProperty.mMaxWidth || 0 == bitmapTotalHeight) { Log.w("createTextBitmapShadowStroke warning:","textProperty MaxWidth is 0 or bitMapTotalHeight is 0\n"); return false; } final Bitmap bitmap = Bitmap.createBitmap(textProperty.mMaxWidth + (int)bitmapPaddingX, bitmapTotalHeight + (int)bitmapPaddingY, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); /* Draw string. */ final FontMetricsInt fontMetricsInt = paint.getFontMetricsInt(); int x = 0; int y = Cocos2dxBitmap.computeY(fontMetricsInt, height, textProperty.mTotalHeight, verticalAlignment); final String[] lines = textProperty.mLines; for (final String line : lines) { x = Cocos2dxBitmap.computeX(line, textProperty.mMaxWidth, horizontalAlignment); canvas.drawText(line, x + renderTextDeltaX, y + renderTextDeltaY, paint); y += textProperty.mHeightPerLine; } // draw again with stroke on if needed if ( stroke ) { final Paint paintStroke = Cocos2dxBitmap.newPaint(fontName, fontSize, horizontalAlignment); paintStroke.setStyle(Paint.Style.STROKE); paintStroke.setStrokeWidth(strokeSize * 0.5f); paintStroke.setARGB(255, (int) (strokeR * 255), (int) (strokeG * 255), (int) (strokeB * 255)); x = 0; y = Cocos2dxBitmap.computeY(fontMetricsInt, height, textProperty.mTotalHeight, verticalAlignment); final String[] lines2 = textProperty.mLines; for (final String line : lines2) { x = Cocos2dxBitmap.computeX(line, textProperty.mMaxWidth, horizontalAlignment); canvas.drawText(line, x + renderTextDeltaX, y + renderTextDeltaY, paintStroke); y += textProperty.mHeightPerLine; } } Cocos2dxBitmap.initNativeObject(bitmap); return true; } private static Paint newPaint(final String fontName, final int fontSize, final int horizontalAlignment) { final Paint paint = new Paint(); paint.setColor(Color.WHITE); paint.setTextSize(fontSize); paint.setAntiAlias(true); /* Set type face for paint, now it support .ttf file. */ if (fontName.endsWith(".ttf")) { try { final Typeface typeFace = Cocos2dxTypefaces.get( Cocos2dxBitmap._context, fontName); paint.setTypeface(typeFace); } catch (final Exception e) { Log.e("Cocos2dxBitmap", "error to create ttf type face: " + fontName); /* The file may not find, use system font. */ paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); } } else { paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); } switch (horizontalAlignment) { case HORIZONTALALIGN_CENTER: paint.setTextAlign(Align.CENTER); break; case HORIZONTALALIGN_RIGHT: paint.setTextAlign(Align.RIGHT); break; case HORIZONTALALIGN_LEFT: default: paint.setTextAlign(Align.LEFT); break; } return paint; } private static TextProperty computeTextProperty(final String string, final int width, final int height, final Paint paint) { final FontMetricsInt fm = paint.getFontMetricsInt(); final int h = (int) Math.ceil(fm.bottom - fm.top); int maxContentWidth = 0; final String[] lines = Cocos2dxBitmap.splitString(string, width, height, paint); if (width != 0) { maxContentWidth = width; } else { /* Compute the max width. */ int temp = 0; for (final String line : lines) { temp = (int) FloatMath.ceil(paint.measureText(line, 0, line.length())); if (temp > maxContentWidth) { maxContentWidth = temp; } } } return new TextProperty(maxContentWidth, h, lines); } private static int computeX(final String text, final int maxWidth, final int horizontalAlignment) { int ret = 0; switch (horizontalAlignment) { case HORIZONTALALIGN_CENTER: ret = maxWidth / 2; break; case HORIZONTALALIGN_RIGHT: ret = maxWidth; break; case HORIZONTALALIGN_LEFT: default: break; } return ret; } private static int computeY(final FontMetricsInt fontMetricsInt, final int constrainHeight, final int totalHeight, final int verticalAlignment) { int y = -fontMetricsInt.top; if (constrainHeight > totalHeight) { switch (verticalAlignment) { case VERTICALALIGN_TOP: y = -fontMetricsInt.top; break; case VERTICALALIGN_CENTER: y = -fontMetricsInt.top + (constrainHeight - totalHeight) / 2; break; case VERTICALALIGN_BOTTOM: y = -fontMetricsInt.top + (constrainHeight - totalHeight); break; default: break; } } return y; } /* * If maxWidth or maxHeight is not 0, split the string to fix the maxWidth * and maxHeight. */ private static String[] splitString(final String string, final int maxWidth, final int maxHeight, final Paint paint) { final String[] lines = string.split("\\n"); String[] ret = null; final FontMetricsInt fm = paint.getFontMetricsInt(); final int heightPerLine = (int) Math.ceil(fm.bottom - fm.top); final int maxLines = maxHeight / heightPerLine; if (maxWidth != 0) { final LinkedList strList = new LinkedList(); for (final String line : lines) { /* * The width of line is exceed maxWidth, should divide it into * two or more lines. */ final int lineWidth = (int) FloatMath.ceil(paint .measureText(line)); if (lineWidth > maxWidth) { strList.addAll(Cocos2dxBitmap.divideStringWithMaxWidth( line, maxWidth, paint)); } else { strList.add(line); } /* Should not exceed the max height. */ if (maxLines > 0 && strList.size() >= maxLines) { break; } } /* Remove exceeding lines. */ if (maxLines > 0 && strList.size() > maxLines) { while (strList.size() > maxLines) { strList.removeLast(); } } ret = new String[strList.size()]; strList.toArray(ret); } else if (maxHeight != 0 && lines.length > maxLines) { /* Remove exceeding lines. */ final LinkedList strList = new LinkedList(); for (int i = 0; i < maxLines; i++) { strList.add(lines[i]); } ret = new String[strList.size()]; strList.toArray(ret); } else { ret = lines; } return ret; } private static LinkedList divideStringWithMaxWidth( final String string, final int maxWidth, final Paint paint) { final int charLength = string.length(); int start = 0; int tempWidth = 0; final LinkedList strList = new LinkedList(); /* Break a String into String[] by the width & should wrap the word. */ for (int i = 1; i <= charLength; ++i) { tempWidth = (int) FloatMath.ceil(paint.measureText(string, start, i)); if (tempWidth >= maxWidth) { final int lastIndexOfSpace = string.substring(0, i) .lastIndexOf(" "); if (lastIndexOfSpace != -1 && lastIndexOfSpace > start) { /* Should wrap the word. */ strList.add(string.substring(start, lastIndexOfSpace)); i = lastIndexOfSpace + 1; // skip space } else { /* Should not exceed the width. */ if (tempWidth > maxWidth) { strList.add(string.substring(start, i - 1)); /* Compute from previous char. */ --i; } else { strList.add(string.substring(start, i)); } } /* Remove spaces at the beginning of a new line. */ while (i < charLength && string.charAt(i) == ' ') { ++i; } start = i; } } /* Add the last chars. */ if (start < charLength) { strList.add(string.substring(start)); } return strList; } private static String refactorString(final String string) { /* Avoid error when content is "". */ if (string.compareTo("") == 0) { return " "; } /* * If the font of "\n" is "" or "\n", insert " " in front of it. For * example: "\nabc" -> " \nabc" "\nabc\n\n" -> " \nabc\n \n". */ final StringBuilder strBuilder = new StringBuilder(string); int start = 0; int index = strBuilder.indexOf("\n"); while (index != -1) { if (index == 0 || strBuilder.charAt(index - 1) == '\n') { strBuilder.insert(start, " "); start = index + 2; } else { start = index + 1; } if (start > strBuilder.length() || index == strBuilder.length()) { break; } index = strBuilder.indexOf("\n", start); } return strBuilder.toString(); } private static void initNativeObject(final Bitmap bitmap) { final byte[] pixels = Cocos2dxBitmap.getPixels(bitmap); if (pixels == null) { return; } Cocos2dxBitmap.nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels); } private static byte[] getPixels(final Bitmap bitmap) { if (bitmap != null) { final byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4]; final ByteBuffer buf = ByteBuffer.wrap(pixels); buf.order(ByteOrder.nativeOrder()); bitmap.copyPixelsToBuffer(buf); return pixels; } return null; } private static int getFontSizeAccordingHeight(int height) { Paint paint = new Paint(); Rect bounds = new Rect(); paint.setTypeface(Typeface.DEFAULT); int incr_text_size = 1; boolean found_desired_size = false; while (!found_desired_size) { paint.setTextSize(incr_text_size); String text = "SghMNy"; paint.getTextBounds(text, 0, text.length(), bounds); incr_text_size++; if (height - bounds.height() <= 2) { found_desired_size = true; } Log.d("font size", "incr size:" + incr_text_size); } return incr_text_size; } private static String getStringWithEllipsis(String string, float width, float fontSize) { if (TextUtils.isEmpty(string)) { return ""; } TextPaint paint = new TextPaint(); paint.setTypeface(Typeface.DEFAULT); paint.setTextSize(fontSize); return TextUtils.ellipsize(string, paint, width, TextUtils.TruncateAt.END).toString(); } // =========================================================== // Inner and Anonymous Classes // =========================================================== private static class TextProperty { /** The max width of lines. */ private final int mMaxWidth; /** The height of all lines. */ private final int mTotalHeight; private final int mHeightPerLine; private final String[] mLines; TextProperty(final int maxWidth, final int heightPerLine, final String[] lines) { this.mMaxWidth = maxWidth; this.mHeightPerLine = heightPerLine; this.mTotalHeight = heightPerLine * lines.length; this.mLines = lines; } } } ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; import android.app.Dialog; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.os.Handler; import android.text.InputFilter; import android.text.InputType; import android.util.TypedValue; import android.view.KeyEvent; import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; public class Cocos2dxEditBoxDialog extends Dialog { // =========================================================== // Constants // =========================================================== /** * The user is allowed to enter any text, including line breaks. */ private final int kEditBoxInputModeAny = 0; /** * The user is allowed to enter an e-mail address. */ private final int kEditBoxInputModeEmailAddr = 1; /** * The user is allowed to enter an integer value. */ private final int kEditBoxInputModeNumeric = 2; /** * The user is allowed to enter a phone number. */ private final int kEditBoxInputModePhoneNumber = 3; /** * The user is allowed to enter a URL. */ private final int kEditBoxInputModeUrl = 4; /** * The user is allowed to enter a real number value. This extends kEditBoxInputModeNumeric by allowing a decimal point. */ private final int kEditBoxInputModeDecimal = 5; /** * The user is allowed to enter any text, except for line breaks. */ private final int kEditBoxInputModeSingleLine = 6; /** * Indicates that the text entered is confidential data that should be obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. */ private final int kEditBoxInputFlagPassword = 0; /** * Indicates that the text entered is sensitive data that the implementation must never store into a dictionary or table for use in predictive, auto-completing, or other accelerated input schemes. A credit card number is an example of sensitive data. */ private final int kEditBoxInputFlagSensitive = 1; /** * This flag is a hint to the implementation that during text editing, the initial letter of each word should be capitalized. */ private final int kEditBoxInputFlagInitialCapsWord = 2; /** * This flag is a hint to the implementation that during text editing, the initial letter of each sentence should be capitalized. */ private final int kEditBoxInputFlagInitialCapsSentence = 3; /** * Capitalize all characters automatically. */ private final int kEditBoxInputFlagInitialCapsAllCharacters = 4; private final int kKeyboardReturnTypeDefault = 0; private final int kKeyboardReturnTypeDone = 1; private final int kKeyboardReturnTypeSend = 2; private final int kKeyboardReturnTypeSearch = 3; private final int kKeyboardReturnTypeGo = 4; // =========================================================== // Fields // =========================================================== private EditText mInputEditText; private TextView mTextViewTitle; private final String mTitle; private final String mMessage; private final int mInputMode; private final int mInputFlag; private final int mReturnType; private final int mMaxLength; private int mInputFlagConstraints; private int mInputModeContraints; private boolean mIsMultiline; // =========================================================== // Constructors // =========================================================== public Cocos2dxEditBoxDialog(final Context pContext, final String pTitle, final String pMessage, final int pInputMode, final int pInputFlag, final int pReturnType, final int pMaxLength) { super(pContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); // super(context, R.style.Theme_Translucent); this.mTitle = pTitle; this.mMessage = pMessage; this.mInputMode = pInputMode; this.mInputFlag = pInputFlag; this.mReturnType = pReturnType; this.mMaxLength = pMaxLength; } @Override protected void onCreate(final Bundle pSavedInstanceState) { super.onCreate(pSavedInstanceState); this.getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000)); final LinearLayout layout = new LinearLayout(this.getContext()); layout.setOrientation(LinearLayout.VERTICAL); final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); this.mTextViewTitle = new TextView(this.getContext()); final LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); textviewParams.leftMargin = textviewParams.rightMargin = this.convertDipsToPixels(10); this.mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); layout.addView(this.mTextViewTitle, textviewParams); this.mInputEditText = new EditText(this.getContext()); final LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); editTextParams.leftMargin = editTextParams.rightMargin = this.convertDipsToPixels(10); layout.addView(this.mInputEditText, editTextParams); this.setContentView(layout, layoutParams); this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); this.mTextViewTitle.setText(this.mTitle); this.mInputEditText.setText(this.mMessage); int oldImeOptions = this.mInputEditText.getImeOptions(); this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI); oldImeOptions = this.mInputEditText.getImeOptions(); switch (this.mInputMode) { case kEditBoxInputModeAny: this.mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE; break; case kEditBoxInputModeEmailAddr: this.mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; break; case kEditBoxInputModeNumeric: this.mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED; break; case kEditBoxInputModePhoneNumber: this.mInputModeContraints = InputType.TYPE_CLASS_PHONE; break; case kEditBoxInputModeUrl: this.mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; break; case kEditBoxInputModeDecimal: this.mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED; break; case kEditBoxInputModeSingleLine: this.mInputModeContraints = InputType.TYPE_CLASS_TEXT; break; default: break; } if (this.mIsMultiline) { this.mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE; } this.mInputEditText.setInputType(this.mInputModeContraints | this.mInputFlagConstraints); switch (this.mInputFlag) { case kEditBoxInputFlagPassword: this.mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; break; case kEditBoxInputFlagSensitive: this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; break; case kEditBoxInputFlagInitialCapsWord: this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS; break; case kEditBoxInputFlagInitialCapsSentence: this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; break; case kEditBoxInputFlagInitialCapsAllCharacters: this.mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; break; default: break; } this.mInputEditText.setInputType(this.mInputFlagConstraints | this.mInputModeContraints); switch (this.mReturnType) { case kKeyboardReturnTypeDefault: this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); break; case kKeyboardReturnTypeDone: this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE); break; case kKeyboardReturnTypeSend: this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND); break; case kKeyboardReturnTypeSearch: this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH); break; case kKeyboardReturnTypeGo: this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO); break; default: this.mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE); break; } if (this.mMaxLength > 0) { this.mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(this.mMaxLength) }); } final Handler initHandler = new Handler(); initHandler.postDelayed(new Runnable() { @Override public void run() { Cocos2dxEditBoxDialog.this.mInputEditText.requestFocus(); Cocos2dxEditBoxDialog.this.mInputEditText.setSelection(Cocos2dxEditBoxDialog.this.mInputEditText.length()); Cocos2dxEditBoxDialog.this.openKeyboard(); } }, 200); this.mInputEditText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { /* If user didn't set keyboard type, this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP'. */ if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null && event.getAction() == KeyEvent.ACTION_DOWN)) { Cocos2dxHelper.setEditTextDialogResult(Cocos2dxEditBoxDialog.this.mInputEditText.getText().toString()); Cocos2dxEditBoxDialog.this.closeKeyboard(); Cocos2dxEditBoxDialog.this.dismiss(); return true; } return false; } }); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== private int convertDipsToPixels(final float pDIPs) { final float scale = this.getContext().getResources().getDisplayMetrics().density; return Math.round(pDIPs * scale); } private void openKeyboard() { final InputMethodManager imm = (InputMethodManager) this.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(this.mInputEditText, 0); } private void closeKeyboard() { final InputMethodManager imm = (InputMethodManager) this.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(this.mInputEditText.getWindowToken(), 0); } // =========================================================== // Inner and Anonymous Classes // =========================================================== } ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; import android.app.Activity; import android.content.Context; import android.text.Editable; import android.text.TextWatcher; import android.view.KeyEvent; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; public class Cocos2dxEditText extends EditText { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private Cocos2dxTextInputWraper mTextWatcher = null; private Context mContext = null; private static Cocos2dxEditText instance = null; // =========================================================== // Constructors // =========================================================== public Cocos2dxEditText(final Context context) { super(context); this.mContext = context; this.mTextWatcher = new Cocos2dxTextInputWraper(context, this); this.setOnEditorActionListener(this.mTextWatcher); ViewGroup.LayoutParams layout = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); Activity activity = (Activity)context; activity.addContentView(this, layout); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== public static Cocos2dxEditText getInstance(final Context context) { if (instance == null) { instance = new Cocos2dxEditText(context); } return instance; } public void closeIMEKeyboard() { this.removeTextChangedListener(mTextWatcher); final InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(this.getWindowToken(), 0); //Cocos2dxHelper.nativeRequestFocus(); } public void openIMEKeyboard() { this.requestFocus(); final String content = nativeGetContent(); this.setText(content); mTextWatcher.setOriginText(content); this.addTextChangedListener(mTextWatcher); final InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(this, InputMethodManager.SHOW_FORCED); } @Override public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) { super.onKeyDown(keyCode, keyEvent); /* Let GlSurfaceView get focus if back key is input. */ if (keyCode == KeyEvent.KEYCODE_BACK) { //Cocos2dxHelper.nativeRequestFocus(); } return true; } // =========================================================== // Methods // =========================================================== private native static String nativeGetContent(); // =========================================================== // Inner and Anonymous Classes // =========================================================== } class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListener { // =========================================================== // Constants // =========================================================== private static final String TAG = Cocos2dxTextInputWraper.class.getSimpleName(); // =========================================================== // Fields // =========================================================== private String mText; private String mOriginText; private Context mContext; private TextView mTextView; // =========================================================== // Constructors // =========================================================== public Cocos2dxTextInputWraper(Context context, TextView textView) { this.mContext = context; this.mTextView = textView; } // =========================================================== // Getter & Setter // =========================================================== private boolean isFullScreenEdit() { final InputMethodManager imm = (InputMethodManager) this.mContext.getSystemService(Context.INPUT_METHOD_SERVICE); return imm.isFullscreenMode(); } public void setOriginText(final String originText) { this.mOriginText = originText; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void afterTextChanged(final Editable s) { if (this.isFullScreenEdit()) { return; } int nModified = s.length() - this.mText.length(); if (nModified > 0) { final String insertText = s.subSequence(this.mText.length(), s.length()).toString(); nativeInsertText(insertText); } else { for (; nModified < 0; ++nModified) { nativeDeleteBackward(); } } this.mText = s.toString(); } @Override public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) { this.mText = pCharSequence.toString(); } @Override public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) { } @Override public boolean onEditorAction(final TextView pTextView, final int pActionID, final KeyEvent pKeyEvent) { if (this.mTextView == pTextView && this.isFullScreenEdit()) { // user press the action button, delete all old text and insert new text for (int i = this.mOriginText.length(); i > 0; i--) { Cocos2dxHelper.runOnGLThread(new Runnable() { @Override public void run() { nativeDeleteBackward(); } }); } String text = pTextView.getText().toString(); /* If user input nothing, translate "\n" to engine. */ if (text.compareTo("") == 0) { text = "\n"; } if ('\n' != text.charAt(text.length() - 1)) { text += '\n'; } final String insertText = text; Cocos2dxHelper.runOnGLThread(new Runnable() { @Override public void run() { nativeInsertText(insertText); } }); } if (pActionID == EditorInfo.IME_ACTION_DONE) { //Cocos2dxHelper.nativeRequestFocus(); } return false; } // =========================================================== // Methods // =========================================================== private native static void nativeInsertText(String text); private native static void nativeDeleteBackward(); // =========================================================== // Inner and Anonymous Classes // =========================================================== } ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; import java.util.concurrent.ConcurrentLinkedQueue; import java.io.UnsupportedEncodingException; import java.util.Locale; import java.lang.Runnable; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.os.Build; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; public class Cocos2dxHelper { // =========================================================== // Constants // =========================================================== private static final String PREFS_NAME = "Cocos2dxPrefsFile"; private static final int RUNNABLES_PER_FRAME = 5; // =========================================================== // Fields // =========================================================== private static Cocos2dxMusic sCocos2dMusic; private static Cocos2dxSound sCocos2dSound; private static AssetManager sAssetManager; private static boolean sAccelerometerEnabled; private static String sPackageName; private static String sFileDirectory; private static Activity sActivity = null; private static Cocos2dxHelperListener sCocos2dxHelperListener; private static ConcurrentLinkedQueue jobs = new ConcurrentLinkedQueue(); /** * Optional meta-that can be in the manifest for this component, specifying * the name of the native shared library to load. If not specified, * "main" is used. */ private static final String META_DATA_LIB_NAME = "android.app.lib_name"; private static final String DEFAULT_LIB_NAME = "main"; // =========================================================== // Constructors // =========================================================== public static void dispatchPendingRunnables() { for (int i = RUNNABLES_PER_FRAME; i > 0; i--) { Runnable job = jobs.poll(); if (job == null) { return; } job.run(); } } public static void runOnGLThread(final Runnable r) { jobs.add(r); } private static boolean sInited = false; public static void init(final Activity activity) { if (!sInited) { final ApplicationInfo applicationInfo = activity.getApplicationInfo(); initListener(); try { // Get the lib_name from AndroidManifest.xml metadata ActivityInfo ai = activity.getPackageManager().getActivityInfo(activity.getIntent().getComponent(), PackageManager.GET_META_DATA); if (null != ai.metaData) { String lib_name = ai.metaData.getString(META_DATA_LIB_NAME); if (null != lib_name) { System.loadLibrary(lib_name); } else { System.loadLibrary(DEFAULT_LIB_NAME); } } } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException("Error getting activity info", e); } Cocos2dxHelper.sPackageName = applicationInfo.packageName; Cocos2dxHelper.sFileDirectory = activity.getFilesDir().getAbsolutePath(); //Cocos2dxHelper.nativeSetApkPath(applicationInfo.sourceDir); Cocos2dxHelper.sCocos2dMusic = new Cocos2dxMusic(activity); Cocos2dxHelper.sCocos2dSound = new Cocos2dxSound(activity); Cocos2dxHelper.sAssetManager = activity.getAssets(); //Cocos2dxHelper.nativeSetAssetManager(sAssetManager); Cocos2dxBitmap.setContext(activity); sActivity = activity; sInited = true; } } public static void initListener() { Cocos2dxHelper.sCocos2dxHelperListener = new Cocos2dxHelperListener() { @Override public void showEditTextDialog(final String title, final String message, final int inputMode, final int inputFlag, final int returnType, final int maxLength) { sActivity.runOnUiThread(new Runnable() { @Override public void run() { new Cocos2dxEditBoxDialog(sActivity, title, message, inputMode, inputFlag, returnType, maxLength).show(); } }); } @Override public void openIMEKeyboard() { sActivity.runOnUiThread(new Runnable() { @Override public void run() { Cocos2dxEditText.getInstance(sActivity).openIMEKeyboard(); } }); } @Override public void closeIMEKeyboard() { sActivity.runOnUiThread(new Runnable() { @Override public void run() { Cocos2dxEditText.getInstance(sActivity).closeIMEKeyboard(); } }); } @Override public void showDialog(final String title, final String message) { sActivity.runOnUiThread(new Runnable() { @Override public void run() { new AlertDialog.Builder(sActivity) .setTitle(title) .setMessage(message) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }).create().show(); } }); } }; } public static Activity getActivity() { return sActivity; } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== private static native void nativeSetEditTextDialogResult(final byte[] pBytes); public static String getCocos2dxPackageName() { return Cocos2dxHelper.sPackageName; } public static String getCocos2dxWritablePath() { return Cocos2dxHelper.sFileDirectory; } public static String getCurrentLanguage() { return Locale.getDefault().getLanguage(); } public static String getDeviceModel(){ return Build.MODEL; } public static AssetManager getAssetManager() { return Cocos2dxHelper.sAssetManager; } public static void preloadBackgroundMusic(final String pPath) { Cocos2dxHelper.sCocos2dMusic.preloadBackgroundMusic(pPath); } public static void playBackgroundMusic(final String pPath, final boolean isLoop) { Cocos2dxHelper.sCocos2dMusic.playBackgroundMusic(pPath, isLoop); } public static void resumeBackgroundMusic() { Cocos2dxHelper.sCocos2dMusic.resumeBackgroundMusic(); } public static void pauseBackgroundMusic() { Cocos2dxHelper.sCocos2dMusic.pauseBackgroundMusic(); } public static void stopBackgroundMusic() { Cocos2dxHelper.sCocos2dMusic.stopBackgroundMusic(); } public static void rewindBackgroundMusic() { Cocos2dxHelper.sCocos2dMusic.rewindBackgroundMusic(); } public static boolean isBackgroundMusicPlaying() { return Cocos2dxHelper.sCocos2dMusic.isBackgroundMusicPlaying(); } public static float getBackgroundMusicVolume() { return Cocos2dxHelper.sCocos2dMusic.getBackgroundVolume(); } public static void setBackgroundMusicVolume(final float volume) { Cocos2dxHelper.sCocos2dMusic.setBackgroundVolume(volume); } public static void preloadEffect(final String path) { Cocos2dxHelper.sCocos2dSound.preloadEffect(path); } public static int playEffect(final String path, final boolean isLoop, final float pitch, final float pan, final float gain) { return Cocos2dxHelper.sCocos2dSound.playEffect(path, isLoop, pitch, pan, gain); } public static void resumeEffect(final int soundId) { Cocos2dxHelper.sCocos2dSound.resumeEffect(soundId); } public static void pauseEffect(final int soundId) { Cocos2dxHelper.sCocos2dSound.pauseEffect(soundId); } public static void stopEffect(final int soundId) { Cocos2dxHelper.sCocos2dSound.stopEffect(soundId); } public static float getEffectsVolume() { return Cocos2dxHelper.sCocos2dSound.getEffectsVolume(); } public static void setEffectsVolume(final float volume) { Cocos2dxHelper.sCocos2dSound.setEffectsVolume(volume); } public static void unloadEffect(final String path) { Cocos2dxHelper.sCocos2dSound.unloadEffect(path); } public static void pauseAllEffects() { Cocos2dxHelper.sCocos2dSound.pauseAllEffects(); } public static void resumeAllEffects() { Cocos2dxHelper.sCocos2dSound.resumeAllEffects(); } public static void stopAllEffects() { Cocos2dxHelper.sCocos2dSound.stopAllEffects(); } public static void end() { Cocos2dxHelper.sCocos2dMusic.end(); Cocos2dxHelper.sCocos2dSound.end(); } public static void terminateProcess() { android.os.Process.killProcess(android.os.Process.myPid()); } private static void showDialog(final String pTitle, final String pMessage) { Cocos2dxHelper.sCocos2dxHelperListener.showDialog(pTitle, pMessage); } private static void showEditTextDialog(final String pTitle, final String pMessage, final int pInputMode, final int pInputFlag, final int pReturnType, final int pMaxLength) { Cocos2dxHelper.sCocos2dxHelperListener.showEditTextDialog(pTitle, pMessage, pInputMode, pInputFlag, pReturnType, pMaxLength); } public static void setEditTextDialogResult(final String pResult) { try { final byte[] bytesUTF8 = pResult.getBytes("UTF8"); Cocos2dxHelper.nativeSetEditTextDialogResult(bytesUTF8); } catch (UnsupportedEncodingException pUnsupportedEncodingException) { /* Nothing. */ } } private static void openIMEKeyboard() { sCocos2dxHelperListener.openIMEKeyboard(); } private static void closeIMEKeyboard() { sCocos2dxHelperListener.closeIMEKeyboard(); } public static int getDPI() { if (sActivity != null) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = sActivity.getWindowManager(); if (wm != null) { Display d = wm.getDefaultDisplay(); if (d != null) { d.getMetrics(metrics); return (int)(metrics.density*160.0f); } } } return -1; } // =========================================================== // Functions for CCUserDefault // =========================================================== public static boolean getBoolForKey(String key, boolean defaultValue) { SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); return settings.getBoolean(key, defaultValue); } public static int getIntegerForKey(String key, int defaultValue) { SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); return settings.getInt(key, defaultValue); } public static float getFloatForKey(String key, float defaultValue) { SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); return settings.getFloat(key, defaultValue); } public static double getDoubleForKey(String key, double defaultValue) { // SharedPreferences doesn't support saving double value SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); return settings.getFloat(key, (float)defaultValue); } public static String getStringForKey(String key, String defaultValue) { SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); return settings.getString(key, defaultValue); } public static void setBoolForKey(String key, boolean value) { SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(key, value); editor.commit(); } public static void setIntegerForKey(String key, int value) { SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putInt(key, value); editor.commit(); } public static void setFloatForKey(String key, float value) { SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putFloat(key, value); editor.commit(); } public static void setDoubleForKey(String key, double value) { // SharedPreferences doesn't support recording double value SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putFloat(key, (float)value); editor.commit(); } public static void setStringForKey(String key, String value) { SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putString(key, value); editor.commit(); } public static native void nativeRequestFocus(); // =========================================================== // Inner and Anonymous Classes // =========================================================== public static interface Cocos2dxHelperListener { public void showDialog(final String title, final String message); public void showEditTextDialog(final String title, final String message, final int inputMode, final int inputFlag, final int returnType, final int maxLength); public void openIMEKeyboard(); public void closeIMEKeyboard(); } } ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLocalStorage.java ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class Cocos2dxLocalStorage { private static final String TAG = "Cocos2dxLocalStorage"; private static String DATABASE_NAME = "jsb.sqlite"; private static String TABLE_NAME = "data"; private static final int DATABASE_VERSION = 1; private static DBOpenHelper mDatabaseOpenHelper = null; private static SQLiteDatabase mDatabase = null; /** * Constructor * @param context The Context within which to work, used to create the DB * @return */ public static boolean init(String dbName, String tableName) { if (Cocos2dxHelper.getActivity() != null) { DATABASE_NAME = dbName; TABLE_NAME = tableName; mDatabaseOpenHelper = new DBOpenHelper(Cocos2dxHelper.getActivity()); mDatabase = mDatabaseOpenHelper.getWritableDatabase(); return true; } return false; } public static void destory() { if (mDatabase != null) { mDatabase.close(); } } public static void setItem(String key, String value) { try { String sql = "replace into "+TABLE_NAME+"(key,value)values(?,?)"; mDatabase.execSQL(sql, new Object[] { key, value }); } catch (Exception e) { e.printStackTrace(); } } public static String getItem(String key) { String ret = null; try { String sql = "select value from "+TABLE_NAME+" where key=?"; Cursor c = mDatabase.rawQuery(sql, new String[]{key}); while (c.moveToNext()) { // only return the first value if (ret != null) { Log.e(TAG, "The key contains more than one value."); break; } ret = c.getString(c.getColumnIndex("value")); } c.close(); } catch (Exception e) { e.printStackTrace(); } return ret == null ? "" : ret; } public static void removeItem(String key) { try { String sql = "delete from "+TABLE_NAME+" where key=?"; mDatabase.execSQL(sql, new Object[] {key}); } catch (Exception e) { e.printStackTrace(); } } /** * This creates/opens the database. */ private static class DBOpenHelper extends SQLiteOpenHelper { DBOpenHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE IF NOT EXISTS "+TABLE_NAME+"(key TEXT PRIMARY KEY,value TEXT);"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data"); //db.execSQL("DROP TABLE IF EXISTS " + VIRTUAL_TABLE); //onCreate(db); } } } ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLuaJavaBridge.java ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; public class Cocos2dxLuaJavaBridge { public static native int callLuaFunctionWithString(int luaFunctionId, String value); public static native int callLuaGlobalFunctionWithString(String luaFunctionName, String value); public static native int retainLuaFunction(int luaFunctionId); public static native int releaseLuaFunction(int luaFunctionId); } ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; import java.io.FileInputStream; import android.content.Context; import android.content.res.AssetFileDescriptor; import android.media.MediaPlayer; import android.util.Log; public class Cocos2dxMusic { // =========================================================== // Constants // =========================================================== private static final String TAG = Cocos2dxMusic.class.getSimpleName(); // =========================================================== // Fields // =========================================================== private final Context mContext; private MediaPlayer mBackgroundMediaPlayer; private float mLeftVolume; private float mRightVolume; private boolean mPaused; private String mCurrentPath; // =========================================================== // Constructors // =========================================================== public Cocos2dxMusic(final Context pContext) { this.mContext = pContext; this.initData(); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public void preloadBackgroundMusic(final String pPath) { if ((this.mCurrentPath == null) || (!this.mCurrentPath.equals(pPath))) { // preload new background music // release old resource and create a new one if (this.mBackgroundMediaPlayer != null) { this.mBackgroundMediaPlayer.release(); } this.mBackgroundMediaPlayer = this.createMediaplayer(pPath); // record the path this.mCurrentPath = pPath; } } public void playBackgroundMusic(final String pPath, final boolean isLoop) { if (this.mCurrentPath == null) { // it is the first time to play background music or end() was called this.mBackgroundMediaPlayer = this.createMediaplayer(pPath); this.mCurrentPath = pPath; } else { if (!this.mCurrentPath.equals(pPath)) { // play new background music // release old resource and create a new one if (this.mBackgroundMediaPlayer != null) { this.mBackgroundMediaPlayer.release(); } this.mBackgroundMediaPlayer = this.createMediaplayer(pPath); // record the path this.mCurrentPath = pPath; } } if (this.mBackgroundMediaPlayer == null) { Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: background media player is null"); } else { // if the music is playing or paused, stop it this.mBackgroundMediaPlayer.stop(); this.mBackgroundMediaPlayer.setLooping(isLoop); try { this.mBackgroundMediaPlayer.prepare(); this.mBackgroundMediaPlayer.seekTo(0); this.mBackgroundMediaPlayer.start(); this.mPaused = false; } catch (final Exception e) { Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: error state"); } } } public void stopBackgroundMusic() { if (this.mBackgroundMediaPlayer != null) { this.mBackgroundMediaPlayer.stop(); // should set the state, if not, the following sequence will be error // play -> pause -> stop -> resume this.mPaused = false; } } public void pauseBackgroundMusic() { if (this.mBackgroundMediaPlayer != null && this.mBackgroundMediaPlayer.isPlaying()) { this.mBackgroundMediaPlayer.pause(); this.mPaused = true; } } public void resumeBackgroundMusic() { if (this.mBackgroundMediaPlayer != null && this.mPaused) { this.mBackgroundMediaPlayer.start(); this.mPaused = false; } } public void rewindBackgroundMusic() { if (this.mBackgroundMediaPlayer != null) { this.mBackgroundMediaPlayer.stop(); try { this.mBackgroundMediaPlayer.prepare(); this.mBackgroundMediaPlayer.seekTo(0); this.mBackgroundMediaPlayer.start(); this.mPaused = false; } catch (final Exception e) { Log.e(Cocos2dxMusic.TAG, "rewindBackgroundMusic: error state"); } } } public boolean isBackgroundMusicPlaying() { boolean ret = false; if (this.mBackgroundMediaPlayer == null) { ret = false; } else { ret = this.mBackgroundMediaPlayer.isPlaying(); } return ret; } public void end() { if (this.mBackgroundMediaPlayer != null) { this.mBackgroundMediaPlayer.release(); } this.initData(); } public float getBackgroundVolume() { if (this.mBackgroundMediaPlayer != null) { return (this.mLeftVolume + this.mRightVolume) / 2; } else { return 0.0f; } } public void setBackgroundVolume(float pVolume) { if (pVolume < 0.0f) { pVolume = 0.0f; } if (pVolume > 1.0f) { pVolume = 1.0f; } this.mLeftVolume = this.mRightVolume = pVolume; if (this.mBackgroundMediaPlayer != null) { this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); } } private void initData() { this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; this.mBackgroundMediaPlayer = null; this.mPaused = false; this.mCurrentPath = null; } /** * create mediaplayer for music * * @param pPath * the pPath relative to assets * @return */ private MediaPlayer createMediaplayer(final String pPath) { MediaPlayer mediaPlayer = new MediaPlayer(); try { if (pPath.startsWith("/")) { final FileInputStream fis = new FileInputStream(pPath); mediaPlayer.setDataSource(fis.getFD()); fis.close(); } else { final AssetFileDescriptor assetFileDescritor = this.mContext.getAssets().openFd(pPath); mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); } mediaPlayer.prepare(); mediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); } catch (final Exception e) { mediaPlayer = null; Log.e(Cocos2dxMusic.TAG, "error: " + e.getMessage(), e); } return mediaPlayer; } // =========================================================== // Inner and Anonymous Classes // =========================================================== } ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.Semaphore; import android.content.Context; import android.media.AudioManager; import android.media.SoundPool; import android.util.Log; public class Cocos2dxSound { // =========================================================== // Constants // =========================================================== private static final String TAG = "Cocos2dxSound"; // =========================================================== // Fields // =========================================================== private final Context mContext; private SoundPool mSoundPool; private float mLeftVolume; private float mRightVolume; // sound path and stream ids map // a file may be played many times at the same time // so there is an array map to a file path private final HashMap> mPathStreamIDsMap = new HashMap>(); private final HashMap mPathSoundIDMap = new HashMap(); private final ArrayList mEffecToPlayWhenLoadedArray = new ArrayList(); private int mStreamIdSyn; private Semaphore mSemaphore; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; private static final float SOUND_RATE = 1.0f; private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; private final static int INVALID_SOUND_ID = -1; private final static int INVALID_STREAM_ID = -1; // =========================================================== // Constructors // =========================================================== public Cocos2dxSound(final Context pContext) { this.mContext = pContext; this.initData(); } private void initData() { this.mSoundPool = new SoundPool(Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, Cocos2dxSound.SOUND_QUALITY); this.mSoundPool.setOnLoadCompleteListener(new OnLoadCompletedListener()); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; this.mSemaphore = new Semaphore(0, true); } // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public int preloadEffect(final String pPath) { Integer soundID = this.mPathSoundIDMap.get(pPath); if (soundID == null) { soundID = this.createSoundIDFromAsset(pPath); // save value just in case if file is really loaded if (soundID != Cocos2dxSound.INVALID_SOUND_ID) { this.mPathSoundIDMap.put(pPath, soundID); } } return soundID; } public void unloadEffect(final String pPath) { // stop effects final ArrayList streamIDs = this.mPathStreamIDsMap.get(pPath); if (streamIDs != null) { for (final Integer pStreamID : streamIDs) { this.mSoundPool.stop(pStreamID); } } this.mPathStreamIDsMap.remove(pPath); // unload effect final Integer soundID = this.mPathSoundIDMap.get(pPath); if(soundID != null){ this.mSoundPool.unload(soundID); this.mPathSoundIDMap.remove(pPath); } } public int playEffect(final String pPath, final boolean pLoop, float pitch, float pan, float gain){ Integer soundID = this.mPathSoundIDMap.get(pPath); int streamID = Cocos2dxSound.INVALID_STREAM_ID; if (soundID != null) { // parameters; pan = -1 for left channel, 1 for right channel, 0 for both channels // play sound streamID = this.doPlayEffect(pPath, soundID.intValue(), pLoop, pitch, pan, gain); } else { // the effect is not prepared soundID = this.preloadEffect(pPath); if (soundID == Cocos2dxSound.INVALID_SOUND_ID) { // can not preload effect return Cocos2dxSound.INVALID_SOUND_ID; } // only allow one playEffect at a time, or the semaphore will not work correctly synchronized(this.mSoundPool) { // add this effect into mEffecToPlayWhenLoadedArray, and it will be played when loaded completely mEffecToPlayWhenLoadedArray.add(new SoundInfoForLoadedCompleted(pPath, soundID.intValue(), pLoop, pitch, pan, gain)); try { // wait OnloadedCompleteListener to set streamID this.mSemaphore.acquire(); streamID = this.mStreamIdSyn; } catch(Exception e) { return Cocos2dxSound.INVALID_SOUND_ID; } } } return streamID; } public void stopEffect(final int pStreamID) { this.mSoundPool.stop(pStreamID); // remove record for (final String pPath : this.mPathStreamIDsMap.keySet()) { if (this.mPathStreamIDsMap.get(pPath).contains(pStreamID)) { this.mPathStreamIDsMap.get(pPath).remove(this.mPathStreamIDsMap.get(pPath).indexOf(pStreamID)); break; } } } public void pauseEffect(final int pStreamID) { this.mSoundPool.pause(pStreamID); } public void resumeEffect(final int pStreamID) { this.mSoundPool.resume(pStreamID); } public void pauseAllEffects() { this.mSoundPool.autoPause(); } public void resumeAllEffects() { // can not only invoke SoundPool.autoResume() here, because // it only resumes all effects paused by pauseAllEffects() if (!this.mPathStreamIDsMap.isEmpty()) { final Iterator>> iter = this.mPathStreamIDsMap.entrySet().iterator(); while (iter.hasNext()) { final Entry> entry = iter.next(); for (final int pStreamID : entry.getValue()) { this.mSoundPool.resume(pStreamID); } } } } @SuppressWarnings("unchecked") public void stopAllEffects() { // stop effects if (!this.mPathStreamIDsMap.isEmpty()) { final Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); while (iter.hasNext()) { final Map.Entry> entry = (Map.Entry>) iter.next(); for (final int pStreamID : entry.getValue()) { this.mSoundPool.stop(pStreamID); } } } // remove records this.mPathStreamIDsMap.clear(); } public float getEffectsVolume() { return (this.mLeftVolume + this.mRightVolume) / 2; } public void setEffectsVolume(float pVolume) { // pVolume should be in [0, 1.0] if (pVolume < 0) { pVolume = 0; } if (pVolume > 1) { pVolume = 1; } this.mLeftVolume = this.mRightVolume = pVolume; // change the volume of playing sounds if (!this.mPathStreamIDsMap.isEmpty()) { final Iterator>> iter = this.mPathStreamIDsMap.entrySet().iterator(); while (iter.hasNext()) { final Entry> entry = iter.next(); for (final int pStreamID : entry.getValue()) { this.mSoundPool.setVolume(pStreamID, this.mLeftVolume, this.mRightVolume); } } } } public void end() { this.mSoundPool.release(); this.mPathStreamIDsMap.clear(); this.mPathSoundIDMap.clear(); this.mEffecToPlayWhenLoadedArray.clear(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; this.initData(); } public int createSoundIDFromAsset(final String pPath) { int soundID = Cocos2dxSound.INVALID_SOUND_ID; try { if (pPath.startsWith("/")) { soundID = this.mSoundPool.load(pPath, 0); } else { soundID = this.mSoundPool.load(this.mContext.getAssets().openFd(pPath), 0); } } catch (final Exception e) { soundID = Cocos2dxSound.INVALID_SOUND_ID; Log.e(Cocos2dxSound.TAG, "error: " + e.getMessage(), e); } // mSoundPool.load returns 0 if something goes wrong, for example a file does not exist if (soundID == 0) { soundID = Cocos2dxSound.INVALID_SOUND_ID; } return soundID; } private float clamp(float value, float min, float max) { return Math.max(min, (Math.min(value, max))); } private int doPlayEffect(final String pPath, final int soundId, final boolean pLoop, float pitch, float pan, float gain) { float leftVolume = this.mLeftVolume * gain * (1.0f - this.clamp(pan, 0.0f, 1.0f)); float rightVolume = this.mRightVolume * gain * (1.0f - this.clamp(-pan, 0.0f, 1.0f)); float soundRate = this.clamp(SOUND_RATE * pitch, 0.5f, 2.0f); // play sound int streamID = this.mSoundPool.play(soundId, this.clamp(leftVolume, 0.0f, 1.0f), this.clamp(rightVolume, 0.0f, 1.0f), Cocos2dxSound.SOUND_PRIORITY, pLoop ? -1 : 0, soundRate); // record stream id ArrayList streamIDs = this.mPathStreamIDsMap.get(pPath); if (streamIDs == null) { streamIDs = new ArrayList(); this.mPathStreamIDsMap.put(pPath, streamIDs); } streamIDs.add(streamID); return streamID; } // =========================================================== // Inner and Anonymous Classes // =========================================================== public class SoundInfoForLoadedCompleted { public int soundID; public boolean isLoop; public float pitch; public float pan; public float gain; public String path; public SoundInfoForLoadedCompleted(String path, int soundId, boolean isLoop, float pitch, float pan, float gain) { this.path = path; this.soundID = soundId; this.isLoop = isLoop; this.pitch = pitch; this.pan = pan; this.gain = gain; } } public class OnLoadCompletedListener implements SoundPool.OnLoadCompleteListener { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { if (status == 0) { // only play effect that are in mEffecToPlayWhenLoadedArray for ( SoundInfoForLoadedCompleted info : mEffecToPlayWhenLoadedArray) { if (sampleId == info.soundID) { // set the stream id which will be returned by playEffect() mStreamIdSyn = doPlayEffect(info.path, info.soundID, info.isLoop, info.pitch, info.pan, info.gain); // remove it from array, because we will break here // so it is safe to do mEffecToPlayWhenLoadedArray.remove(info); break; } } } else { mStreamIdSyn = Cocos2dxSound.INVALID_SOUND_ID; } mSemaphore.release(); } } } ================================================ FILE: cocos2d/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; import java.util.HashMap; import android.content.Context; import android.graphics.Typeface; public class Cocos2dxTypefaces { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private static final HashMap sTypefaceCache = new HashMap(); // =========================================================== // Constructors // =========================================================== // =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public static synchronized Typeface get(final Context pContext, final String pAssetName) { if (!Cocos2dxTypefaces.sTypefaceCache.containsKey(pAssetName)) { Typeface typeface = null; if (pAssetName.startsWith("/")) { typeface = Typeface.createFromFile(pAssetName); } else { typeface = Typeface.createFromAsset(pContext.getAssets(), pAssetName); } Cocos2dxTypefaces.sTypefaceCache.put(pAssetName, typeface); } return Cocos2dxTypefaces.sTypefaceCache.get(pAssetName); } // =========================================================== // Inner and Anonymous Classes // =========================================================== } ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/DPIJni.cpp ================================================ #include "DPIJni.h" #include "jni/JniHelper.h" USING_NS_CC; extern "C" { int getDPIJNI() { JniMethodInfo t; jint ret = -1; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxHelper", "getDPI", "()I")) { ret = t.env->CallStaticIntMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); } return ret; } } // extern "C" ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/DPIJni.h ================================================ #ifndef __DPIJNI_H__ #define __DPIJNI_H__ extern "C" { int getDPIJNI(); } // extern "C" #endif /* __DPIJNI_H__ */ ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/IMEJni.cpp ================================================ /**************************************************************************** Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "IMEJni.h" #include "CCIMEDispatcher.h" #include "JniHelper.h" #include #include #include using namespace cocos2d; extern "C" { void setKeyboardStateJNI(int bOpen) { if (bOpen) { openKeyboardJNI(); } else { closeKeyboardJNI(); } } void openKeyboardJNI() { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxHelper", "openIMEKeyboard", "()V")) { t.env->CallStaticVoidMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); } } void closeKeyboardJNI() { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxHelper", "closeIMEKeyboard", "()V")) { t.env->CallStaticVoidMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); } } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxTextInputWraper_nativeInsertText(JNIEnv* env, jobject thiz, jstring text) { const char* tmpText = env->GetStringUTFChars(text, nullptr); cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(tmpText, strlen(tmpText)); env->ReleaseStringUTFChars(text, tmpText); } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxTextInputWraper_nativeDeleteBackward(JNIEnv* env, jobject thiz) { cocos2d::IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); } JNIEXPORT jstring JNICALL Java_org_cocos2dx_lib_Cocos2dxEditText_nativeGetContent() { JNIEnv * env = 0; if (JniHelper::getJavaVM()->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK || ! env) { return 0; } const std::string& text = cocos2d::IMEDispatcher::sharedDispatcher()->getContentText(); return env->NewStringUTF(text.c_str()); } } ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/IMEJni.h ================================================ /**************************************************************************** Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ANDROID_IME_JNI_H__ #define __ANDROID_IME_JNI_H__ extern "C" { extern void setKeyboardStateJNI(int bOpen); extern void openKeyboardJNI(); extern void closeKeyboardJNI(); } #endif // __ANDROID_IME_JNI_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp ================================================ /**************************************************************************** Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "JniHelper.h" #include #include "CCDirector.h" #include "../CCApplication.h" #include "platform/CCFileUtils.h" #include using namespace cocos2d; int getFontSizeAccordingHeightJni(int height) { int ret = 0; JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getFontSizeAccordingHeight", "(I)I")) { ret = t.env->CallStaticIntMethod(t.classID, t.methodID, height); t.env->DeleteLocalRef(t.classID); } return ret; } std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize) { std::string ret; JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxBitmap", "getStringWithEllipsis", "(Ljava/lang/String;FF)Ljava/lang/String;")) { jstring stringArg1; if (!pszText) { stringArg1 = t.env->NewStringUTF(""); } else { stringArg1 = t.env->NewStringUTF(pszText); } jstring retFromJava = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg1, width, fontSize); const char* str = t.env->GetStringUTFChars(retFromJava, 0); ret = str; t.env->ReleaseStringUTFChars(retFromJava, str); t.env->DeleteLocalRef(stringArg1); t.env->DeleteLocalRef(t.classID); } return ret; } ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h ================================================ /**************************************************************************** Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __EDITBOX_JNI_H__ #define __EDITBOX_JNI_H__ #include int getFontSizeAccordingHeightJni(int height); std::string getStringWithEllipsisJni(const char* pszText, float width, float fontSize); #endif // __EDITBOX_JNI_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include #include #include #include "JniHelper.h" #include "CCString.h" #include "Java_org_cocos2dx_lib_Cocos2dxHelper.h" #define LOG_TAG "Java_org_cocos2dx_lib_Cocos2dxHelper.cpp" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper" EditTextCallback s_pfEditTextCallback = NULL; void* s_ctx = NULL; using namespace cocos2d; using namespace std; string g_apkPath; extern "C" { JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetApkPath(JNIEnv* env, jobject thiz, jstring apkPath) { g_apkPath = JniHelper::jstring2string(apkPath); } } const char * getApkPath() { return g_apkPath.c_str(); } void showDialogJNI(const char * pszMsg, const char * pszTitle) { if (!pszMsg) { return; } JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showDialog", "(Ljava/lang/String;Ljava/lang/String;)V")) { jstring stringArg1; if (!pszTitle) { stringArg1 = t.env->NewStringUTF(""); } else { stringArg1 = t.env->NewStringUTF(pszTitle); } jstring stringArg2 = t.env->NewStringUTF(pszMsg); t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2); t.env->DeleteLocalRef(stringArg1); t.env->DeleteLocalRef(stringArg2); t.env->DeleteLocalRef(t.classID); } } void showEditTextDialogJNI(const char* pszTitle, const char* pszMessage, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx) { if (pszMessage == NULL) { return; } s_pfEditTextCallback = pfEditTextCallback; s_ctx = ctx; JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "showEditTextDialog", "(Ljava/lang/String;Ljava/lang/String;IIII)V")) { jstring stringArg1; if (!pszTitle) { stringArg1 = t.env->NewStringUTF(""); } else { stringArg1 = t.env->NewStringUTF(pszTitle); } jstring stringArg2 = t.env->NewStringUTF(pszMessage); t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2, nInputMode, nInputFlag, nReturnType, nMaxLength); t.env->DeleteLocalRef(stringArg1); t.env->DeleteLocalRef(stringArg2); t.env->DeleteLocalRef(t.classID); } } void terminateProcessJNI() { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "terminateProcess", "()V")) { t.env->CallStaticVoidMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); } } std::string getPackageNameJNI() { JniMethodInfo t; std::string ret(""); if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCocos2dxPackageName", "()Ljava/lang/String;")) { jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); ret = JniHelper::jstring2string(str); t.env->DeleteLocalRef(str); } return ret; } std::string getFileDirectoryJNI() { JniMethodInfo t; std::string ret(""); if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCocos2dxWritablePath", "()Ljava/lang/String;")) { jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); ret = JniHelper::jstring2string(str); t.env->DeleteLocalRef(str); } return ret; } std::string getCurrentLanguageJNI() { JniMethodInfo t; std::string ret(""); if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getCurrentLanguage", "()Ljava/lang/String;")) { jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); ret = JniHelper::jstring2string(str); t.env->DeleteLocalRef(str); } return ret; } // functions for UserDefault bool getBoolForKeyJNI(const char* pKey, bool defaultValue) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getBoolForKey", "(Ljava/lang/String;Z)Z")) { jstring stringArg = t.env->NewStringUTF(pKey); jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, stringArg, defaultValue); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg); return ret; } return defaultValue; } int getIntegerForKeyJNI(const char* pKey, int defaultValue) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getIntegerForKey", "(Ljava/lang/String;I)I")) { jstring stringArg = t.env->NewStringUTF(pKey); jint ret = t.env->CallStaticIntMethod(t.classID, t.methodID, stringArg, defaultValue); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg); return ret; } return defaultValue; } float getFloatForKeyJNI(const char* pKey, float defaultValue) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getFloatForKey", "(Ljava/lang/String;F)F")) { jstring stringArg = t.env->NewStringUTF(pKey); jfloat ret = t.env->CallStaticFloatMethod(t.classID, t.methodID, stringArg, defaultValue); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg); return ret; } return defaultValue; } double getDoubleForKeyJNI(const char* pKey, double defaultValue) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getDoubleForKey", "(Ljava/lang/String;D)D")) { jstring stringArg = t.env->NewStringUTF(pKey); jdouble ret = t.env->CallStaticDoubleMethod(t.classID, t.methodID, stringArg, defaultValue); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg); return ret; } return defaultValue; } std::string getStringForKeyJNI(const char* pKey, const char* defaultValue) { JniMethodInfo t; std::string ret(""); if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getStringForKey", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;")) { jstring stringArg1 = t.env->NewStringUTF(pKey); jstring stringArg2 = t.env->NewStringUTF(defaultValue); jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, stringArg1, stringArg2); ret = JniHelper::jstring2string(str); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg1); t.env->DeleteLocalRef(stringArg2); t.env->DeleteLocalRef(str); return ret; } return defaultValue; } void setBoolForKeyJNI(const char* pKey, bool value) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setBoolForKey", "(Ljava/lang/String;Z)V")) { jstring stringArg = t.env->NewStringUTF(pKey); t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg); } } void setIntegerForKeyJNI(const char* pKey, int value) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setIntegerForKey", "(Ljava/lang/String;I)V")) { jstring stringArg = t.env->NewStringUTF(pKey); t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg); } } void setFloatForKeyJNI(const char* pKey, float value) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setFloatForKey", "(Ljava/lang/String;F)V")) { jstring stringArg = t.env->NewStringUTF(pKey); t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg); } } void setDoubleForKeyJNI(const char* pKey, double value) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setDoubleForKey", "(Ljava/lang/String;D)V")) { jstring stringArg = t.env->NewStringUTF(pKey); t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg, value); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg); } } void setStringForKeyJNI(const char* pKey, const char* value) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setStringForKey", "(Ljava/lang/String;Ljava/lang/String;)V")) { jstring stringArg1 = t.env->NewStringUTF(pKey); jstring stringArg2 = t.env->NewStringUTF(value); t.env->CallStaticVoidMethod(t.classID, t.methodID, stringArg1, stringArg2); t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(stringArg1); t.env->DeleteLocalRef(stringArg2); } } ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ #define __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ #include typedef void (*EditTextCallback)(const char* pText, void* ctx); extern const char * getApkPath(); extern void showDialogJNI(const char * pszMsg, const char * pszTitle); extern void showEditTextDialogJNI(const char* pszTitle, const char* pszContent, int nInputMode, int nInputFlag, int nReturnType, int nMaxLength, EditTextCallback pfEditTextCallback, void* ctx); extern void terminateProcessJNI(); extern std::string getCurrentLanguageJNI(); extern std::string getPackageNameJNI(); extern std::string getFileDirectoryJNI(); // functions for UserDefault extern bool getBoolForKeyJNI(const char* pKey, bool defaultValue); extern int getIntegerForKeyJNI(const char* pKey, int defaultValue); extern float getFloatForKeyJNI(const char* pKey, float defaultValue); extern double getDoubleForKeyJNI(const char* pKey, double defaultValue); extern std::string getStringForKeyJNI(const char* pKey, const char* defaultValue); extern void setBoolForKeyJNI(const char* pKey, bool value); extern void setIntegerForKeyJNI(const char* pKey, int value); extern void setFloatForKeyJNI(const char* pKey, float value); extern void setDoubleForKeyJNI(const char* pKey, double value); extern void setStringForKeyJNI(const char* pKey, const char* value); #endif /* __Java_org_cocos2dx_lib_Cocos2dxHelper_H__ */ ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/JniHelper.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "JniHelper.h" #include #include #include #define LOG_TAG "JniHelper" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) jclass _getClassID(const char *className) { if (NULL == className) { return NULL; } JNIEnv* env = cocos2d::JniHelper::getEnv(); jstring _jstrClassName = env->NewStringUTF(className); jclass _clazz = (jclass) env->CallObjectMethod(cocos2d::JniHelper::classloader, cocos2d::JniHelper::loadclassMethod_methodID, _jstrClassName); if (NULL == _clazz) { LOGD("Classloader failed to find class of %s", className); } env->DeleteLocalRef(_jstrClassName); return _clazz; } namespace cocos2d { JavaVM* JniHelper::_psJavaVM = NULL; jmethodID JniHelper::loadclassMethod_methodID = NULL; jobject JniHelper::classloader = NULL; JNIEnv* JniHelper::env = NULL; static pthread_key_t s_threadKey; JavaVM* JniHelper::getJavaVM() { pthread_t thisthread = pthread_self(); LOGD("JniHelper::getJavaVM(), pthread_self() = %X", thisthread); return _psJavaVM; } void JniHelper::setJavaVM(JavaVM *javaVM) { pthread_t thisthread = pthread_self(); LOGD("JniHelper::setJavaVM(%p), pthread_self() = %X", javaVM, thisthread); _psJavaVM = javaVM; JniHelper::cacheEnv(javaVM); } void JniHelper::detach_current_thread (void *env) { _psJavaVM->DetachCurrentThread(); } bool JniHelper::cacheEnv(JavaVM* jvm) { JNIEnv* _env = NULL; // get jni environment jint ret = jvm->GetEnv((void**)&_env, JNI_VERSION_1_4); switch (ret) { case JNI_OK : // Success! JniHelper::env = _env; return true; case JNI_EDETACHED : // Thread not attached // TODO : If calling AttachCurrentThread() on a native thread // must call DetachCurrentThread() in future. // see: http://developer.android.com/guide/practices/design/jni.html pthread_key_create (&s_threadKey, JniHelper::detach_current_thread); if (jvm->AttachCurrentThread(&_env, NULL) < 0) { LOGD("Failed to get the environment using AttachCurrentThread()"); JniHelper::env = NULL; return false; } else { // Success : Attached and obtained JNIEnv! JniHelper::env = _env; if (pthread_getspecific(s_threadKey) == NULL) pthread_setspecific(s_threadKey, _env); return true; } case JNI_EVERSION : // Cannot recover from this error LOGD("JNI interface version 1.4 not supported"); default : LOGD("Failed to get the environment using GetEnv()"); JniHelper::env = NULL; return false; } } JNIEnv* JniHelper::getEnv() { return JniHelper::env; } bool JniHelper::setClassLoaderFrom(jobject nativeactivityinstance) { JniMethodInfo _getclassloaderMethod; if (!JniHelper::getMethodInfo_DefaultClassLoader(_getclassloaderMethod, "android/app/NativeActivity", "getClassLoader", "()Ljava/lang/ClassLoader;")) { return false; } jobject _c = cocos2d::JniHelper::getEnv()->CallObjectMethod(nativeactivityinstance, _getclassloaderMethod.methodID); if (NULL == _c) { return false; } JniMethodInfo _m; if (!JniHelper::getMethodInfo_DefaultClassLoader(_m, "java/lang/ClassLoader", "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;")) { return false; } JniHelper::classloader = _c; JniHelper::loadclassMethod_methodID = _m.methodID; return true; } bool JniHelper::getStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) { if ((NULL == className) || (NULL == methodName) || (NULL == paramCode)) { return false; } JNIEnv *pEnv = JniHelper::getEnv(); if (!pEnv) { LOGD("Failed to get JNIEnv"); return false; } jclass classID = _getClassID(className); if (! classID) { LOGD("Failed to find class %s", className); return false; } jmethodID methodID = pEnv->GetStaticMethodID(classID, methodName, paramCode); if (! methodID) { LOGD("Failed to find static method id of %s", methodName); return false; } methodinfo.classID = classID; methodinfo.env = pEnv; methodinfo.methodID = methodID; return true; } bool JniHelper::getMethodInfo_DefaultClassLoader(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) { if ((NULL == className) || (NULL == methodName) || (NULL == paramCode)) { return false; } JNIEnv *pEnv = JniHelper::getEnv(); if (!pEnv) { return false; } jclass classID = pEnv->FindClass(className); if (! classID) { LOGD("Failed to find class %s", className); return false; } jmethodID methodID = pEnv->GetMethodID(classID, methodName, paramCode); if (! methodID) { LOGD("Failed to find method id of %s", methodName); pEnv->ExceptionClear(); return false; } methodinfo.classID = classID; methodinfo.env = pEnv; methodinfo.methodID = methodID; return true; } bool JniHelper::getMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode) { if ((NULL == className) || (NULL == methodName) || (NULL == paramCode)) { return false; } JNIEnv *pEnv = JniHelper::getEnv(); if (!pEnv) { return false; } jclass classID = _getClassID(className); if (! classID) { LOGD("Failed to find class %s", className); return false; } jmethodID methodID = pEnv->GetMethodID(classID, methodName, paramCode); if (! methodID) { LOGD("Failed to find method id of %s", methodName); pEnv->ExceptionClear(); return false; } methodinfo.classID = classID; methodinfo.env = pEnv; methodinfo.methodID = methodID; return true; } std::string JniHelper::jstring2string(jstring jstr) { if (jstr == NULL) { return ""; } JNIEnv *pEnv = JniHelper::getEnv(); if (!pEnv) { return NULL; } const char* chars = pEnv->GetStringUTFChars(jstr, NULL); std::string ret(chars); pEnv->ReleaseStringUTFChars(jstr, chars); return ret; } } //namespace cocos2d ================================================ FILE: cocos2d/cocos/2d/platform/android/jni/JniHelper.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ANDROID_JNI_HELPER_H__ #define __ANDROID_JNI_HELPER_H__ #include #include #include "CCPlatformMacros.h" NS_CC_BEGIN typedef struct JniMethodInfo_ { JNIEnv * env; jclass classID; jmethodID methodID; } JniMethodInfo; class CC_DLL JniHelper { public: static void setJavaVM(JavaVM *javaVM); static JavaVM* getJavaVM(); static JNIEnv* getEnv(); static bool setClassLoaderFrom(jobject nativeActivityInstance); static bool getStaticMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); static bool getMethodInfo(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); static std::string jstring2string(jstring str); static jmethodID loadclassMethod_methodID; static jobject classloader; private: static void detach_current_thread (void *env); static bool cacheEnv(JavaVM* jvm); static bool getMethodInfo_DefaultClassLoader(JniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); static JavaVM* _psJavaVM; static JNIEnv* env; }; NS_CC_END #endif // __ANDROID_JNI_HELPER_H__ ================================================ FILE: cocos2d/cocos/2d/platform/android/nativeactivity.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "nativeactivity.h" #include #include #include #include #include #include #include #include #include #include #include "CCDirector.h" #include "CCApplication.h" #include "CCEventType.h" #include "CCFileUtilsAndroid.h" #include "jni/JniHelper.h" #include "CCEGLView.h" #include "CCDrawingPrimitives.h" #include "CCShaderCache.h" #include "CCTextureCache.h" #include "CCEventDispatcher.h" #include "CCEventAcceleration.h" #include "CCEventKeyboard.h" #include "CCEventCustom.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "cocos2dx/nativeactivity.cpp", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "cocos2dx/nativeactivity.cpp", __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "cocos2dx/nativeactivity.cpp", __VA_ARGS__)) #define LOG_RENDER_DEBUG(...) // #define LOG_RENDER_DEBUG(...) ((void)__android_log_print(ANDROID_LOG_INFO, "cocos2dx/nativeactivity.cpp", __VA_ARGS__)) #define LOG_EVENTS_DEBUG(...) // #define LOG_EVENTS_DEBUG(...) ((void)__android_log_print(ANDROID_LOG_INFO, "cocos2dx/nativeactivity.cpp", __VA_ARGS__)) /* For debug builds, always enable the debug traces in this library */ #ifndef NDEBUG # define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "cocos2dx/nativeactivity.cpp", __VA_ARGS__)) #else # define LOGV(...) ((void)0) #endif void cocos_android_app_init(struct android_app* app); /** * Our saved state data. */ struct saved_state { float angle; int32_t x; int32_t y; }; /** * Shared state for our app. */ struct engine { struct android_app* app; ASensorManager* sensorManager; const ASensor* accelerometerSensor; ASensorEventQueue* sensorEventQueue; int animating; EGLDisplay display; EGLSurface surface; EGLContext context; int32_t width; int32_t height; struct saved_state state; }; static bool isContentRectChanged = false; static std::chrono::steady_clock::time_point timeRectChanged; static struct engine engine; static char* editboxText = NULL; extern EditTextCallback s_pfEditTextCallback; extern void* s_ctx; extern "C" { JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxHelper_nativeSetEditTextDialogResult(JNIEnv * env, jobject obj, jbyteArray text) { jsize size = env->GetArrayLength(text); pthread_mutex_lock(&(engine.app->mutex)); if (size > 0) { jbyte * data = (jbyte*)env->GetByteArrayElements(text, 0); char* pBuf = (char*)malloc(size+1); if (pBuf != NULL) { memcpy(pBuf, data, size); pBuf[size] = '\0'; editboxText = pBuf; } env->ReleaseByteArrayElements(text, data, 0); } else { char* pBuf = (char*)malloc(1); pBuf[0] = '\0'; editboxText = pBuf; } pthread_cond_broadcast(&engine.app->cond); pthread_mutex_unlock(&(engine.app->mutex)); } } typedef struct cocos_dimensions { int w; int h; } cocos_dimensions; static void cocos_init(cocos_dimensions d, struct android_app* app) { LOGI("cocos_init(...)"); pthread_t thisthread = pthread_self(); LOGI("pthread_self() = %X", thisthread); cocos2d::FileUtilsAndroid::setassetmanager(app->activity->assetManager); if (!cocos2d::Director::getInstance()->getOpenGLView()) { cocos2d::EGLView *view = cocos2d::EGLView::getInstance(); view->setFrameSize(d.w, d.h); cocos_android_app_init(app); cocos2d::Application::getInstance()->run(); } else { cocos2d::GL::invalidateStateCache(); cocos2d::ShaderCache::getInstance()->reloadDefaultShaders(); cocos2d::DrawPrimitives::init(); cocos2d::VolatileTextureMgr::reloadAllTextures(); cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND); cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent); cocos2d::Director::getInstance()->setGLDefaultValues(); } } /** * Initialize an EGL context for the current display. */ static cocos_dimensions engine_init_display(struct engine* engine) { cocos_dimensions r; r.w = -1; r.h = -1; // initialize OpenGL ES and EGL /* * Here specify the attributes of the desired configuration. * Below, we select an EGLConfig with at least 8 bits per color * component compatible with on-screen windows */ const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_BLUE_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_RED_SIZE, 5, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 8, EGL_NONE }; EGLint w, h, dummy, format; EGLint numConfigs; EGLConfig config; EGLSurface surface; EGLContext context; EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(display, 0, 0); /* Here, the application chooses the configuration it desires. In this * sample, we have a very simplified selection process, where we pick * the first EGLConfig that matches our criteria */ eglChooseConfig(display, attribs, &config, 1, &numConfigs); /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is * guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). * As soon as we picked a EGLConfig, we can safely reconfigure the * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */ eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format); ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format); surface = eglCreateWindowSurface(display, config, engine->app->window, NULL); const EGLint eglContextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; context = eglCreateContext(display, config, NULL, eglContextAttrs); if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { LOGW("Unable to eglMakeCurrent"); return r; } eglQuerySurface(display, surface, EGL_WIDTH, &w); eglQuerySurface(display, surface, EGL_HEIGHT, &h); engine->display = display; engine->context = context; engine->surface = surface; engine->width = w; engine->height = h; engine->state.angle = 0; r.w = w; r.h = h; return r; } /** * Invoke the dispatching of the next bunch of Runnables in the Java-Land */ static bool s_methodInitialized = false; static void dispatch_pending_runnables() { static cocos2d::JniMethodInfo info; if (!s_methodInitialized) { s_methodInitialized = cocos2d::JniHelper::getStaticMethodInfo( info, "org/cocos2dx/lib/Cocos2dxHelper", "dispatchPendingRunnables", "()V" ); if (!s_methodInitialized) { LOGW("Unable to dispatch pending Runnables!"); return; } } info.env->CallStaticVoidMethod(info.classID, info.methodID); } /** * Just the current frame in the display. */ static void engine_draw_frame(struct engine* engine) { LOG_RENDER_DEBUG("engine_draw_frame(...)"); pthread_t thisthread = pthread_self(); LOG_RENDER_DEBUG("pthread_self() = %X", thisthread); if (engine->display == NULL) { // No display. LOGW("engine_draw_frame : No display."); return; } dispatch_pending_runnables(); cocos2d::Director::getInstance()->mainLoop(); LOG_RENDER_DEBUG("engine_draw_frame : just called cocos' mainLoop()"); /* // Just fill the screen with a color. */ /* glClearColor(((float)engine->state.x)/engine->width, engine->state.angle, */ /* ((float)engine->state.y)/engine->height, 1); */ /* glClear(GL_COLOR_BUFFER_BIT); */ if (s_pfEditTextCallback && editboxText) { s_pfEditTextCallback(editboxText, s_ctx); free(editboxText); editboxText = NULL; } eglSwapBuffers(engine->display, engine->surface); } /** * Tear down the EGL context currently associated with the display. */ static void engine_term_display(struct engine* engine) { if (engine->display != EGL_NO_DISPLAY) { eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (engine->context != EGL_NO_CONTEXT) { eglDestroyContext(engine->display, engine->context); } if (engine->surface != EGL_NO_SURFACE) { eglDestroySurface(engine->display, engine->surface); } eglTerminate(engine->display); } engine->animating = 0; engine->display = EGL_NO_DISPLAY; engine->context = EGL_NO_CONTEXT; engine->surface = EGL_NO_SURFACE; } /* * Get X, Y positions and ID's for all pointers */ static void getTouchPos(AInputEvent *event, int ids[], float xs[], float ys[]) { int pointerCount = AMotionEvent_getPointerCount(event); for(int i = 0; i < pointerCount; ++i) { ids[i] = AMotionEvent_getPointerId(event, i); xs[i] = AMotionEvent_getX(event, i); ys[i] = AMotionEvent_getY(event, i); } } /* * Handle Touch Inputs */ static int32_t handle_touch_input(AInputEvent *event) { pthread_t thisthread = pthread_self(); LOG_EVENTS_DEBUG("handle_touch_input(%X), pthread_self() = %X", event, thisthread); switch(AMotionEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK) { case AMOTION_EVENT_ACTION_DOWN: { LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_DOWN"); int pointerId = AMotionEvent_getPointerId(event, 0); float xP = AMotionEvent_getX(event,0); float yP = AMotionEvent_getY(event,0); LOG_EVENTS_DEBUG("Event: Action DOWN x=%f y=%f pointerID=%d\n", xP, yP, pointerId); float x = xP; float y = yP; cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &pointerId, &x, &y); return 1; } break; case AMOTION_EVENT_ACTION_POINTER_DOWN: { LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_POINTER_DOWN"); int pointerIndex = AMotionEvent_getAction(event) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; int pointerId = AMotionEvent_getPointerId(event, pointerIndex); float xP = AMotionEvent_getX(event,pointerIndex); float yP = AMotionEvent_getY(event,pointerIndex); LOG_EVENTS_DEBUG("Event: Action POINTER DOWN x=%f y=%f pointerID=%d\n", xP, yP, pointerId); float x = xP; float y = yP; cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &pointerId, &x, &y); return 1; } break; case AMOTION_EVENT_ACTION_MOVE: { LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_MOVE"); int pointerCount = AMotionEvent_getPointerCount(event); int ids[pointerCount]; float xs[pointerCount], ys[pointerCount]; getTouchPos(event, ids, xs, ys); cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(pointerCount, ids, xs, ys); return 1; } break; case AMOTION_EVENT_ACTION_UP: { LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_UP"); int pointerId = AMotionEvent_getPointerId(event, 0); float xP = AMotionEvent_getX(event,0); float yP = AMotionEvent_getY(event,0); LOG_EVENTS_DEBUG("Event: Action UP x=%f y=%f pointerID=%d\n", xP, yP, pointerId); float x = xP; float y = yP; cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &pointerId, &x, &y); return 1; } break; case AMOTION_EVENT_ACTION_POINTER_UP: { LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_POINTER_UP"); int pointerIndex = AMotionEvent_getAction(event) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; int pointerId = AMotionEvent_getPointerId(event, pointerIndex); float xP = AMotionEvent_getX(event,pointerIndex); float yP = AMotionEvent_getY(event,pointerIndex); LOG_EVENTS_DEBUG("Event: Action POINTER UP x=%f y=%f pointerID=%d\n", xP, yP, pointerIndex); float x = xP; float y = yP; cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &pointerId, &x, &y); return 1; } break; case AMOTION_EVENT_ACTION_CANCEL: { LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_CANCEL"); int pointerCount = AMotionEvent_getPointerCount(event); int ids[pointerCount]; float xs[pointerCount], ys[pointerCount]; getTouchPos(event, ids, xs, ys); cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(pointerCount, ids, xs, ys); return 1; } break; default: LOG_EVENTS_DEBUG("handle_touch_input() default case.... NOT HANDLE"); return 0; break; } } /* * Handle Key Inputs */ static int32_t handle_key_input(AInputEvent *event) { if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_UP) { auto dispatcher = cocos2d::Director::getInstance()->getEventDispatcher(); switch (AKeyEvent_getKeyCode(event)) { case AKEYCODE_BACK: { cocos2d::EventKeyboard event(cocos2d::EventKeyboard::KeyCode::KEY_BACKSPACE, false); dispatcher->dispatchEvent(&event); } return 1; case AKEYCODE_MENU: { cocos2d::EventKeyboard event(cocos2d::EventKeyboard::KeyCode::KEY_MENU, false); dispatcher->dispatchEvent(&event); } return 1; default: break; } } return 0; } /** * Process the next input event. */ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) { pthread_t thisthread = pthread_self(); LOG_EVENTS_DEBUG("engine_handle_input(%X, %X), pthread_self() = %X", app, event, thisthread); struct engine* engine = (struct engine*)app->userData; if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) { engine->animating = 1; engine->state.x = AMotionEvent_getX(event, 0); engine->state.y = AMotionEvent_getY(event, 0); return handle_touch_input(event); } else return handle_key_input(event); return 0; } void enableAccelerometerJni(void) { LOGI("enableAccelerometerJni()"); if (engine.accelerometerSensor != NULL) { ASensorEventQueue_enableSensor(engine.sensorEventQueue, engine.accelerometerSensor); // Set a default sample rate // We'd like to get 60 events per second (in us). ASensorEventQueue_setEventRate(engine.sensorEventQueue, engine.accelerometerSensor, (1000L/60)*1000); } } void disableAccelerometerJni(void) { LOGI("disableAccelerometerJni()"); if (engine.accelerometerSensor != NULL) { ASensorEventQueue_disableSensor(engine.sensorEventQueue, engine.accelerometerSensor); } } void setAccelerometerIntervalJni(float interval) { LOGI("setAccelerometerIntervalJni(%f)", interval); // We'd like to get 60 events per second (in us). ASensorEventQueue_setEventRate(engine.sensorEventQueue, engine.accelerometerSensor, interval * 1000000L); } /** * Process the next main command. */ static void engine_handle_cmd(struct android_app* app, int32_t cmd) { struct engine* engine = (struct engine*)app->userData; switch (cmd) { case APP_CMD_SAVE_STATE: // The system has asked us to save our current state. Do so. engine->app->savedState = malloc(sizeof(struct saved_state)); *((struct saved_state*)engine->app->savedState) = engine->state; engine->app->savedStateSize = sizeof(struct saved_state); break; case APP_CMD_INIT_WINDOW: // The window is being shown, get it ready. if (engine->app->window != NULL) { cocos_dimensions d = engine_init_display(engine); if ((d.w > 0) && (d.h > 0)) { cocos2d::JniHelper::setJavaVM(app->activity->vm); cocos2d::JniHelper::setClassLoaderFrom(app->activity->clazz); // call Cocos2dxHelper.init() cocos2d::JniMethodInfo ccxhelperInit; if (!cocos2d::JniHelper::getStaticMethodInfo(ccxhelperInit, "org/cocos2dx/lib/Cocos2dxHelper", "init", "(Landroid/app/Activity;)V")) { LOGI("cocos2d::JniHelper::getStaticMethodInfo(ccxhelperInit) FAILED"); } ccxhelperInit.env->CallStaticVoidMethod(ccxhelperInit.classID, ccxhelperInit.methodID, app->activity->clazz); cocos_init(d, app); } engine->animating = 1; engine_draw_frame(engine); } break; case APP_CMD_TERM_WINDOW: // The window is being hidden or closed, clean it up. engine_term_display(engine); break; case APP_CMD_GAINED_FOCUS: if (cocos2d::Director::getInstance()->getOpenGLView()) { cocos2d::Application::getInstance()->applicationWillEnterForeground(); engine->animating = 1; } break; case APP_CMD_LOST_FOCUS: { cocos2d::Application::getInstance()->applicationDidEnterBackground(); cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND); cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent); // Also stop animating. engine->animating = 0; engine_draw_frame(engine); } break; } } static void onContentRectChanged(ANativeActivity* activity, const ARect* rect) { timeRectChanged = std::chrono::steady_clock::now(); isContentRectChanged = true; } static void process_input(struct android_app* app, struct android_poll_source* source) { AInputEvent* event = NULL; while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) { LOGV("New input event: type=%d\n", AInputEvent_getType(event)); if (AInputQueue_preDispatchEvent(app->inputQueue, event)) { continue; } int32_t handled = 0; if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event); AInputQueue_finishEvent(app->inputQueue, event, handled); } } /** * This is the main entry point of a native application that is using * android_native_app_glue. It runs in its own thread, with its own * event loop for receiving input events and doing other things. */ void android_main(struct android_app* state) { // Make sure glue isn't stripped. app_dummy(); memset(&engine, 0, sizeof(engine)); state->userData = &engine; state->onAppCmd = engine_handle_cmd; state->onInputEvent = engine_handle_input; state->inputPollSource.process = process_input; engine.app = state; // Prepare to monitor accelerometer engine.sensorManager = ASensorManager_getInstance(); engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager, ASENSOR_TYPE_ACCELEROMETER); engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager, state->looper, LOOPER_ID_USER, NULL, NULL); if (state->savedState != NULL) { // We are starting with a previous saved state; restore from it. engine.state = *(struct saved_state*)state->savedState; } // Screen size change support state->activity->callbacks->onContentRectChanged = onContentRectChanged; // loop waiting for stuff to do. while (1) { // Read all pending events. int ident; int events; struct android_poll_source* source; // If not animating, we will block forever waiting for events. // If animating, we loop until all events are read, then continue // to draw the next frame of animation. while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events, (void**)&source)) >= 0) { // Process this event. if (source != NULL) { source->process(state, source); } // If a sensor has data, process it now. if (ident == LOOPER_ID_USER) { if (engine.accelerometerSensor != NULL) { ASensorEvent event; while (ASensorEventQueue_getEvents(engine.sensorEventQueue, &event, 1) > 0) { LOG_EVENTS_DEBUG("accelerometer: x=%f y=%f z=%f", event.acceleration.x, event.acceleration.y, event.acceleration.z); AConfiguration* _currentconf = AConfiguration_new(); AConfiguration_fromAssetManager(_currentconf, state->activity->assetManager); static int32_t _orientation = AConfiguration_getOrientation(_currentconf); if (ACONFIGURATION_ORIENTATION_LAND != _orientation) { // ACONFIGURATION_ORIENTATION_ANY // ACONFIGURATION_ORIENTATION_PORT // ACONFIGURATION_ORIENTATION_SQUARE cocos2d::Acceleration acc; acc.x = -event.acceleration.x/10; acc.y = -event.acceleration.y/10; acc.z = event.acceleration.z/10; acc.timestamp = 0; cocos2d::EventAcceleration accEvent(acc); auto dispatcher = cocos2d::Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&accEvent); } else { // ACONFIGURATION_ORIENTATION_LAND // swap x and y parameters cocos2d::Acceleration acc; acc.x = event.acceleration.y/10; acc.y = -event.acceleration.x/10; acc.z = event.acceleration.z/10; acc.timestamp = 0; cocos2d::EventAcceleration accEvent(acc); auto dispatcher = cocos2d::Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&accEvent); } } } } // Check if we are exiting. if (state->destroyRequested != 0) { engine_term_display(&engine); memset(&engine, 0, sizeof(engine)); s_methodInitialized = false; return; } } if (engine.animating) { // Done with events; draw next animation frame. engine.state.angle += .01f; if (engine.state.angle > 1) { engine.state.angle = 0; } // Drawing is throttled to the screen update rate, so there // is no need to do timing here. LOG_RENDER_DEBUG("android_main : engine.animating"); engine_draw_frame(&engine); } else { LOG_RENDER_DEBUG("android_main : !engine.animating"); } // Check if screen size changed if (isContentRectChanged) { std::chrono::duration duration( std::chrono::duration_cast>(std::chrono::steady_clock::now() - timeRectChanged)); // Wait about 30 ms to get new width and height. Without waiting we can get old values sometime if (duration.count() > 30) { isContentRectChanged = false; int32_t newWidth = ANativeWindow_getWidth(engine.app->window); int32_t newHeight = ANativeWindow_getHeight(engine.app->window); cocos2d::Application::getInstance()->applicationScreenSizeChanged(newWidth, newHeight); } } } } ================================================ FILE: cocos2d/cocos/2d/platform/android/nativeactivity.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __COCOSNATIVEACTIVITY_H__ #define __COCOSNATIVEACTIVITY_H__ /** * This is the interface to the Android native activity */ void enableAccelerometerJni(void); void disableAccelerometerJni(void); void setAccelerometerIntervalJni(float interval); #endif // __COCOSNATIVEACTIVITY_H__ ================================================ FILE: cocos2d/cocos/2d/platform/apple/CCFileUtilsApple.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_FILEUTILS_APPLE_H__ #define __CC_FILEUTILS_APPLE_H__ #include "CCFileUtils.h" #include #include #include "CCPlatformMacros.h" #include "ccTypes.h" NS_CC_BEGIN /** * @addtogroup platform * @{ */ //! @brief Helper class to handle file operations class CC_DLL FileUtilsApple : public FileUtils { public: /* override funtions */ virtual std::string getWritablePath() const override; virtual bool isFileExist(const std::string& filePath) const override; virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) override; virtual ValueMap getValueMapFromFile(const std::string& filename) override; virtual bool writeToFile(ValueMap& dict, const std::string& fullPath) override; virtual ValueVector getValueVectorFromFile(const std::string& filename) override; }; // end of platform group /// @} NS_CC_END #endif // __CC_FILEUTILS_APPLE_H__ ================================================ FILE: cocos2d/cocos/2d/platform/apple/CCFileUtilsApple.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import #include #include #include "CCString.h" #include "CCFileUtils.h" #include "CCDirector.h" #include "CCSAXParser.h" #include "CCDictionary.h" #include "unzip.h" #include "CCFileUtilsApple.h" NS_CC_BEGIN static void addValueToDict(id nsKey, id nsValue, ValueMap& dict); static void addObjectToNSDict(const std::string& key, const Value& value, NSMutableDictionary *dict); static void addItemToArray(id item, ValueVector& array) { // add string value into array if ([item isKindOfClass:[NSString class]]) { array.push_back(Value([item UTF8String])); return; } // add number value into array(such as int, float, bool and so on) if ([item isKindOfClass:[NSNumber class]]) { array.push_back(Value([item doubleValue])); return; } // add dictionary value into array if ([item isKindOfClass:[NSDictionary class]]) { ValueMap dict; for (id subKey in [item allKeys]) { id subValue = [item objectForKey:subKey]; addValueToDict(subKey, subValue, dict); } array.push_back(Value(dict)); return; } // add array value into array if ([item isKindOfClass:[NSArray class]]) { ValueVector subArray; for (id subItem in item) { addItemToArray(subItem, subArray); } array.push_back(Value(subArray)); return; } } static void addObjectToNSArray(const Value& value, NSMutableArray *array) { // add string into array if (value.getType() == Value::Type::STRING) { NSString *element = [NSString stringWithCString:value.asString().c_str() encoding:NSUTF8StringEncoding]; [array addObject:element]; return; } // add array into array if (value.getType() == Value::Type::VECTOR) { NSMutableArray *element = [NSMutableArray array]; ValueVector valueArray = value.asValueVector(); for (const auto &e : valueArray) { addObjectToNSArray(e, element); } [array addObject:element]; return; } // add dictionary value into array if (value.getType() == Value::Type::MAP) { NSMutableDictionary *element = [NSMutableDictionary dictionary]; auto valueDict = value.asValueMap(); for (auto iter = valueDict.begin(); iter != valueDict.end(); ++iter) { addObjectToNSDict(iter->first, iter->second, element); } [array addObject:element]; } } static void addValueToDict(id nsKey, id nsValue, ValueMap& dict) { // the key must be a string CCASSERT([nsKey isKindOfClass:[NSString class]], "The key should be a string!"); std::string key = [nsKey UTF8String]; // the value is a string if ([nsValue isKindOfClass:[NSString class]]) { dict[key] = Value([nsValue UTF8String]); return; } // the value is a number if ([nsValue isKindOfClass:[NSNumber class]]) { dict[key] = Value([nsValue doubleValue]); return; } // the value is a new dictionary if ([nsValue isKindOfClass:[NSDictionary class]]) { ValueMap subDict; for (id subKey in [nsValue allKeys]) { id subValue = [nsValue objectForKey:subKey]; addValueToDict(subKey, subValue, subDict); } dict[key] = Value(subDict); return; } // the value is a array if ([nsValue isKindOfClass:[NSArray class]]) { ValueVector valueArray; for (id item in nsValue) { addItemToArray(item, valueArray); } dict[key] = Value(valueArray); return; } } static void addObjectToNSDict(const std::string& key, const Value& value, NSMutableDictionary *dict) { NSString *NSkey = [NSString stringWithCString:key.c_str() encoding:NSUTF8StringEncoding]; // the object is a Dictionary if (value.getType() == Value::Type::MAP) { NSMutableDictionary *dictElement = [NSMutableDictionary dictionary]; ValueMap subDict = value.asValueMap(); for (auto iter = subDict.begin(); iter != subDict.end(); ++iter) { addObjectToNSDict(iter->first, iter->second, dictElement); } [dict setObject:dictElement forKey:NSkey]; return; } // the object is a String if (value.getType() == Value::Type::STRING) { NSString *strElement = [NSString stringWithCString:value.asString().c_str() encoding:NSUTF8StringEncoding]; [dict setObject:strElement forKey:NSkey]; return; } // the object is a Array if (value.getType() == Value::Type::VECTOR) { NSMutableArray *arrElement = [NSMutableArray array]; ValueVector array = value.asValueVector(); for(const auto& v : array) { addObjectToNSArray(v, arrElement); } [dict setObject:arrElement forKey:NSkey]; return; } } #pragma mark - FileUtils static NSFileManager* s_fileManager = [NSFileManager defaultManager]; FileUtils* FileUtils::getInstance() { if (s_sharedFileUtils == nullptr) { s_sharedFileUtils = new FileUtilsApple(); if(!s_sharedFileUtils->init()) { delete s_sharedFileUtils; s_sharedFileUtils = nullptr; CCLOG("ERROR: Could not init CCFileUtilsApple"); } } return s_sharedFileUtils; } std::string FileUtilsApple::getWritablePath() const { // save to document folder NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; std::string strRet = [documentsDirectory UTF8String]; strRet.append("/"); return strRet; } bool FileUtilsApple::isFileExist(const std::string& filePath) const { if(filePath.length() == 0) { return false; } bool ret = false; if (filePath[0] != '/') { std::string path; std::string file; size_t pos = filePath.find_last_of("/"); if (pos != std::string::npos) { file = filePath.substr(pos+1); path = filePath.substr(0, pos+1); } else { file = filePath; } NSString* fullpath = [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:file.c_str()] ofType:nil inDirectory:[NSString stringWithUTF8String:path.c_str()]]; if (fullpath != nil) { ret = true; } } else { // Search path is an absolute path. if ([s_fileManager fileExistsAtPath:[NSString stringWithUTF8String:filePath.c_str()]]) { ret = true; } } return ret; } std::string FileUtilsApple::getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) { if (directory[0] != '/') { NSString* fullpath = [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:filename.c_str()] ofType:nil inDirectory:[NSString stringWithUTF8String:directory.c_str()]]; if (fullpath != nil) { return [fullpath UTF8String]; } } else { std::string fullPath = directory+filename; // Search path is an absolute path. if ([s_fileManager fileExistsAtPath:[NSString stringWithUTF8String:fullPath.c_str()]]) { return fullPath; } } return ""; } ValueMap FileUtilsApple::getValueMapFromFile(const std::string& filename) { std::string fullPath = fullPathForFilename(filename); NSString* path = [NSString stringWithUTF8String:fullPath.c_str()]; NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile:path]; ValueMap ret; if (dict != nil) { for (id key in [dict allKeys]) { id value = [dict objectForKey:key]; addValueToDict(key, value, ret); } } return ret; } bool FileUtilsApple::writeToFile(ValueMap& dict, const std::string &fullPath) { //CCLOG("iOS||Mac Dictionary %d write to file %s", dict->_ID, fullPath.c_str()); NSMutableDictionary *nsDict = [NSMutableDictionary dictionary]; for (auto iter = dict.begin(); iter != dict.end(); ++iter) { addObjectToNSDict(iter->first, iter->second, nsDict); } NSString *file = [NSString stringWithUTF8String:fullPath.c_str()]; // do it atomically [nsDict writeToFile:file atomically:YES]; return true; } ValueVector FileUtilsApple::getValueVectorFromFile(const std::string& filename) { // NSString* pPath = [NSString stringWithUTF8String:pFileName]; // NSString* pathExtension= [pPath pathExtension]; // pPath = [pPath stringByDeletingPathExtension]; // pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension]; // fixing cannot read data using Array::createWithContentsOfFile std::string fullPath = fullPathForFilename(filename); NSString* path = [NSString stringWithUTF8String:fullPath.c_str()]; NSArray* array = [NSArray arrayWithContentsOfFile:path]; ValueVector ret; for (id value in array) { addItemToArray(value, ret); } return ret; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/apple/CCLock.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCLock.h" NS_CC_BEGIN Lock::Lock(void) { } Lock::~Lock(void) { } void Lock::lock(void) { } void Lock::unlock(void) { } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/apple/CCLock.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ #define __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ #include "CCPlatformMacros.h" NS_CC_BEGIN class Lock { public: /** * @js ctor */ Lock(void); /** * @js NA * @lua NA */ ~Lock(void); void lock(void); void unlock(void); }; NS_CC_END #endif // __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ ================================================ FILE: cocos2d/cocos/2d/platform/apple/CCThread.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ //#import #include "CCThread.h" NS_CC_BEGIN void* ThreadHelper::createAutoreleasePool() { id pool = [[NSAutoreleasePool alloc] init]; return pool; } void ThreadHelper::releaseAutoreleasePool(void *autoreleasePool) { [(NSAutoreleasePool*)autoreleasePool release]; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/desktop/CCEGLView.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEGLView.h" #include #include "CCDirector.h" #include "CCSet.h" #include "CCTouch.h" #include "CCEventDispatcher.h" #include "CCEventKeyboard.h" #include "CCEventMouse.h" #include "CCIMEDispatcher.h" NS_CC_BEGIN struct keyCodeItem { int glfwKeyCode; EventKeyboard::KeyCode keyCode; }; static std::unordered_map g_keyCodeMap; static keyCodeItem g_keyCodeStructArray[] = { /* The unknown key */ { GLFW_KEY_UNKNOWN , EventKeyboard::KeyCode::KEY_NONE }, /* Printable keys */ { GLFW_KEY_SPACE , EventKeyboard::KeyCode::KEY_SPACE }, { GLFW_KEY_APOSTROPHE , EventKeyboard::KeyCode::KEY_APOSTROPHE }, { GLFW_KEY_COMMA , EventKeyboard::KeyCode::KEY_COMMA }, { GLFW_KEY_MINUS , EventKeyboard::KeyCode::KEY_MINUS }, { GLFW_KEY_PERIOD , EventKeyboard::KeyCode::KEY_PERIOD }, { GLFW_KEY_SLASH , EventKeyboard::KeyCode::KEY_SLASH }, { GLFW_KEY_0 , EventKeyboard::KeyCode::KEY_0 }, { GLFW_KEY_1 , EventKeyboard::KeyCode::KEY_1 }, { GLFW_KEY_2 , EventKeyboard::KeyCode::KEY_2 }, { GLFW_KEY_3 , EventKeyboard::KeyCode::KEY_3 }, { GLFW_KEY_4 , EventKeyboard::KeyCode::KEY_4 }, { GLFW_KEY_5 , EventKeyboard::KeyCode::KEY_5 }, { GLFW_KEY_6 , EventKeyboard::KeyCode::KEY_6 }, { GLFW_KEY_7 , EventKeyboard::KeyCode::KEY_7 }, { GLFW_KEY_8 , EventKeyboard::KeyCode::KEY_8 }, { GLFW_KEY_9 , EventKeyboard::KeyCode::KEY_9 }, { GLFW_KEY_SEMICOLON , EventKeyboard::KeyCode::KEY_SEMICOLON }, { GLFW_KEY_EQUAL , EventKeyboard::KeyCode::KEY_EQUAL }, { GLFW_KEY_A , EventKeyboard::KeyCode::KEY_A }, { GLFW_KEY_B , EventKeyboard::KeyCode::KEY_B }, { GLFW_KEY_C , EventKeyboard::KeyCode::KEY_C }, { GLFW_KEY_D , EventKeyboard::KeyCode::KEY_D }, { GLFW_KEY_E , EventKeyboard::KeyCode::KEY_E }, { GLFW_KEY_F , EventKeyboard::KeyCode::KEY_F }, { GLFW_KEY_G , EventKeyboard::KeyCode::KEY_G }, { GLFW_KEY_H , EventKeyboard::KeyCode::KEY_H }, { GLFW_KEY_I , EventKeyboard::KeyCode::KEY_I }, { GLFW_KEY_J , EventKeyboard::KeyCode::KEY_J }, { GLFW_KEY_K , EventKeyboard::KeyCode::KEY_K }, { GLFW_KEY_L , EventKeyboard::KeyCode::KEY_L }, { GLFW_KEY_M , EventKeyboard::KeyCode::KEY_M }, { GLFW_KEY_N , EventKeyboard::KeyCode::KEY_N }, { GLFW_KEY_O , EventKeyboard::KeyCode::KEY_O }, { GLFW_KEY_P , EventKeyboard::KeyCode::KEY_P }, { GLFW_KEY_Q , EventKeyboard::KeyCode::KEY_Q }, { GLFW_KEY_R , EventKeyboard::KeyCode::KEY_R }, { GLFW_KEY_S , EventKeyboard::KeyCode::KEY_S }, { GLFW_KEY_T , EventKeyboard::KeyCode::KEY_T }, { GLFW_KEY_U , EventKeyboard::KeyCode::KEY_U }, { GLFW_KEY_V , EventKeyboard::KeyCode::KEY_V }, { GLFW_KEY_W , EventKeyboard::KeyCode::KEY_W }, { GLFW_KEY_X , EventKeyboard::KeyCode::KEY_X }, { GLFW_KEY_Y , EventKeyboard::KeyCode::KEY_Y }, { GLFW_KEY_Z , EventKeyboard::KeyCode::KEY_Z }, { GLFW_KEY_LEFT_BRACKET , EventKeyboard::KeyCode::KEY_LEFT_BRACKET }, { GLFW_KEY_BACKSLASH , EventKeyboard::KeyCode::KEY_BACK_SLASH }, { GLFW_KEY_RIGHT_BRACKET , EventKeyboard::KeyCode::KEY_RIGHT_BRACKET }, { GLFW_KEY_GRAVE_ACCENT , EventKeyboard::KeyCode::KEY_GRAVE }, { GLFW_KEY_WORLD_1 , EventKeyboard::KeyCode::KEY_GRAVE }, { GLFW_KEY_WORLD_2 , EventKeyboard::KeyCode::KEY_NONE }, /* Function keys */ { GLFW_KEY_ESCAPE , EventKeyboard::KeyCode::KEY_ESCAPE }, { GLFW_KEY_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER }, { GLFW_KEY_TAB , EventKeyboard::KeyCode::KEY_TAB }, { GLFW_KEY_BACKSPACE , EventKeyboard::KeyCode::KEY_BACKSPACE }, { GLFW_KEY_INSERT , EventKeyboard::KeyCode::KEY_INSERT }, { GLFW_KEY_DELETE , EventKeyboard::KeyCode::KEY_DELETE }, { GLFW_KEY_RIGHT , EventKeyboard::KeyCode::KEY_RIGHT_ARROW }, { GLFW_KEY_LEFT , EventKeyboard::KeyCode::KEY_LEFT_ARROW }, { GLFW_KEY_DOWN , EventKeyboard::KeyCode::KEY_DOWN_ARROW }, { GLFW_KEY_UP , EventKeyboard::KeyCode::KEY_UP_ARROW }, { GLFW_KEY_PAGE_UP , EventKeyboard::KeyCode::KEY_KP_PG_UP }, { GLFW_KEY_PAGE_DOWN , EventKeyboard::KeyCode::KEY_KP_PG_DOWN }, { GLFW_KEY_HOME , EventKeyboard::KeyCode::KEY_KP_HOME }, { GLFW_KEY_END , EventKeyboard::KeyCode::KEY_END }, { GLFW_KEY_CAPS_LOCK , EventKeyboard::KeyCode::KEY_CAPS_LOCK }, { GLFW_KEY_SCROLL_LOCK , EventKeyboard::KeyCode::KEY_SCROLL_LOCK }, { GLFW_KEY_NUM_LOCK , EventKeyboard::KeyCode::KEY_NUM_LOCK }, { GLFW_KEY_PRINT_SCREEN , EventKeyboard::KeyCode::KEY_PRINT }, { GLFW_KEY_PAUSE , EventKeyboard::KeyCode::KEY_PAUSE }, { GLFW_KEY_F1 , EventKeyboard::KeyCode::KEY_F1 }, { GLFW_KEY_F2 , EventKeyboard::KeyCode::KEY_F2 }, { GLFW_KEY_F3 , EventKeyboard::KeyCode::KEY_F3 }, { GLFW_KEY_F4 , EventKeyboard::KeyCode::KEY_F4 }, { GLFW_KEY_F5 , EventKeyboard::KeyCode::KEY_F5 }, { GLFW_KEY_F6 , EventKeyboard::KeyCode::KEY_F6 }, { GLFW_KEY_F7 , EventKeyboard::KeyCode::KEY_F7 }, { GLFW_KEY_F8 , EventKeyboard::KeyCode::KEY_F8 }, { GLFW_KEY_F9 , EventKeyboard::KeyCode::KEY_F9 }, { GLFW_KEY_F10 , EventKeyboard::KeyCode::KEY_F10 }, { GLFW_KEY_F11 , EventKeyboard::KeyCode::KEY_F11 }, { GLFW_KEY_F12 , EventKeyboard::KeyCode::KEY_F12 }, { GLFW_KEY_F13 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F14 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F15 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F16 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F17 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F18 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F19 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F20 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F21 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F22 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F23 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F24 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_F25 , EventKeyboard::KeyCode::KEY_NONE }, { GLFW_KEY_KP_0 , EventKeyboard::KeyCode::KEY_0 }, { GLFW_KEY_KP_1 , EventKeyboard::KeyCode::KEY_1 }, { GLFW_KEY_KP_2 , EventKeyboard::KeyCode::KEY_2 }, { GLFW_KEY_KP_3 , EventKeyboard::KeyCode::KEY_3 }, { GLFW_KEY_KP_4 , EventKeyboard::KeyCode::KEY_4 }, { GLFW_KEY_KP_5 , EventKeyboard::KeyCode::KEY_5 }, { GLFW_KEY_KP_6 , EventKeyboard::KeyCode::KEY_6 }, { GLFW_KEY_KP_7 , EventKeyboard::KeyCode::KEY_7 }, { GLFW_KEY_KP_8 , EventKeyboard::KeyCode::KEY_8 }, { GLFW_KEY_KP_9 , EventKeyboard::KeyCode::KEY_9 }, { GLFW_KEY_KP_DECIMAL , EventKeyboard::KeyCode::KEY_PERIOD }, { GLFW_KEY_KP_DIVIDE , EventKeyboard::KeyCode::KEY_KP_DIVIDE }, { GLFW_KEY_KP_MULTIPLY , EventKeyboard::KeyCode::KEY_KP_MULTIPLY }, { GLFW_KEY_KP_SUBTRACT , EventKeyboard::KeyCode::KEY_KP_MINUS }, { GLFW_KEY_KP_ADD , EventKeyboard::KeyCode::KEY_KP_PLUS }, { GLFW_KEY_KP_ENTER , EventKeyboard::KeyCode::KEY_KP_ENTER }, { GLFW_KEY_KP_EQUAL , EventKeyboard::KeyCode::KEY_EQUAL }, { GLFW_KEY_LEFT_SHIFT , EventKeyboard::KeyCode::KEY_SHIFT }, { GLFW_KEY_LEFT_CONTROL , EventKeyboard::KeyCode::KEY_CTRL }, { GLFW_KEY_LEFT_ALT , EventKeyboard::KeyCode::KEY_ALT }, { GLFW_KEY_LEFT_SUPER , EventKeyboard::KeyCode::KEY_HYPER }, { GLFW_KEY_RIGHT_SHIFT , EventKeyboard::KeyCode::KEY_SHIFT }, { GLFW_KEY_RIGHT_CONTROL , EventKeyboard::KeyCode::KEY_CTRL }, { GLFW_KEY_RIGHT_ALT , EventKeyboard::KeyCode::KEY_ALT }, { GLFW_KEY_RIGHT_SUPER , EventKeyboard::KeyCode::KEY_HYPER }, { GLFW_KEY_MENU , EventKeyboard::KeyCode::KEY_MENU }, { GLFW_KEY_LAST , EventKeyboard::KeyCode::KEY_NONE } }; //begin EGLViewEventHandler class EGLViewEventHandler { public: static bool s_captured; static float s_mouseX; static float s_mouseY; static void onGLFWError(int errorID, const char* errorDesc); static void onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify); static void onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y); static void onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y); static void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); static void onGLFWCharCallback(GLFWwindow* window, unsigned int character); static void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y); static void onGLFWframebuffersize(GLFWwindow* window, int w, int h); }; bool EGLViewEventHandler::s_captured = false; float EGLViewEventHandler::s_mouseX = 0; float EGLViewEventHandler::s_mouseY = 0; void EGLViewEventHandler::onGLFWError(int errorID, const char* errorDesc) { CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc); } void EGLViewEventHandler::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify) { EGLView* eglView = EGLView::getInstance(); if(nullptr == eglView) return; if(GLFW_MOUSE_BUTTON_LEFT == button) { if(GLFW_PRESS == action) { s_captured = true; if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY))) { int id = 0; eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY); } } else if(GLFW_RELEASE == action) { s_captured = false; if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY))) { int id = 0; eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY); } } } if(GLFW_PRESS == action) { EventMouse event(EventMouse::MouseEventType::MOUSE_DOWN); //Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY); event.setMouseButton(button); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } else if(GLFW_RELEASE == action) { EventMouse event(EventMouse::MouseEventType::MOUSE_UP); //Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY); event.setMouseButton(button); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } } void EGLViewEventHandler::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y) { EGLView* eglView = EGLView::getInstance(); if(nullptr == eglView) return; if (eglView->isRetina()) { x *= 2; y *= 2; } s_mouseX = (float)x; s_mouseY = (float)y; s_mouseX /= eglView->getFrameZoomFactor(); s_mouseY /= eglView->getFrameZoomFactor(); if(s_captured) { if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY))) { int id = 0; eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY); } } EventMouse event(EventMouse::MouseEventType::MOUSE_MOVE); //Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } void EGLViewEventHandler::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y) { EGLView* eglView = EGLView::getInstance(); if(nullptr == eglView) return; EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL); //Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here event.setScrollData((float)x, -(float)y); event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } void EGLViewEventHandler::onGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { if (GLFW_REPEAT != action) { EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&event); } } void EGLViewEventHandler::onGLFWCharCallback(GLFWwindow *window, unsigned int character) { IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1); } void EGLViewEventHandler::onGLFWWindowPosCallback(GLFWwindow *windows, int x, int y) { Director::getInstance()->setViewport(); } void EGLViewEventHandler::onGLFWframebuffersize(GLFWwindow* window, int w, int h) { auto view = EGLView::getInstance(); float frameSizeW = view->getFrameSize().width; float frameSizeH = view->getFrameSize().height; float factorX = frameSizeW / w * view->getFrameZoomFactor(); float factorY = frameSizeH / h * view->getFrameZoomFactor();; if (fabs(factorX - 0.5f) < FLT_EPSILON && fabs(factorY - 0.5f) < FLT_EPSILON ) { view->_isRetina = true; view->setFrameZoomFactor(2.0f * view->getFrameZoomFactor()); glfwSetWindowSize(window, static_cast(frameSizeW * 0.5f * view->getFrameZoomFactor()) , static_cast(frameSizeH * 0.5f * view->getFrameZoomFactor())); } else if(fabs(factorX - 2.0f) < FLT_EPSILON && fabs(factorY - 2.0f) < FLT_EPSILON) { view->_isRetina = false; view->setFrameZoomFactor(0.5f * view->getFrameZoomFactor()); glfwSetWindowSize(window, static_cast(frameSizeW * view->getFrameZoomFactor()), static_cast(frameSizeH * view->getFrameZoomFactor())); } } //end EGLViewEventHandler ////////////////////////////////////////////////////////////////////////// // implement EGLView ////////////////////////////////////////////////////////////////////////// EGLView* EGLView::s_pEglView = nullptr; EGLView::EGLView() : _captured(false) , _frameZoomFactor(1.0f) , _supportTouch(false) , _isRetina(false) , _mainWindow(nullptr) , _primaryMonitor(nullptr) { CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n"); _viewName = "cocos2dx"; s_pEglView = this; g_keyCodeMap.clear(); for (auto& item : g_keyCodeStructArray) { g_keyCodeMap[item.glfwKeyCode] = item.keyCode; } glfwSetErrorCallback(EGLViewEventHandler::onGLFWError); glfwInit(); } EGLView::~EGLView() { CCLOGINFO("deallocing EGLView: %p", this); glfwTerminate(); s_pEglView = nullptr; } bool EGLView::init(const std::string& viewName, float width, float height, float frameZoomFactor) { if(_mainWindow != nullptr) return true; setViewName(viewName); setFrameSize(width, height); setFrameZoomFactor(frameZoomFactor); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); _mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName.c_str(), _primaryMonitor, NULL); glfwMakeContextCurrent(_mainWindow); int w, h; glfwGetWindowSize(_mainWindow, &w, &h); int frameBufferW, frameBufferH; glfwGetFramebufferSize(_mainWindow, &frameBufferW, &frameBufferH); if (frameBufferW == 2 * w && frameBufferH == 2 * h) { _isRetina = true; setFrameZoomFactor(frameZoomFactor * 2); glfwSetWindowSize(_mainWindow, width/2 * _frameZoomFactor, height/2 * _frameZoomFactor); } glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::onGLFWMouseCallBack); glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::onGLFWMouseMoveCallBack); glfwSetScrollCallback(_mainWindow, EGLViewEventHandler::onGLFWMouseScrollCallback); glfwSetCharCallback(_mainWindow, EGLViewEventHandler::onGLFWCharCallback); glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::onGLFWKeyCallback); glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::onGLFWWindowPosCallback); glfwSetFramebufferSizeCallback(_mainWindow, EGLViewEventHandler::onGLFWframebuffersize); // check OpenGL version at first const GLubyte* glVersion = glGetString(GL_VERSION); if ( atof((const char*)glVersion) < 1.5 ) { char strComplain[256] = {0}; sprintf(strComplain, "OpenGL 1.5 or higher is required (your version is %s). Please upgrade the driver of your video card.", glVersion); MessageBox(strComplain, "OpenGL version too old"); return false; } initGlew(); // Enable point size by default. glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); return true; } bool EGLView::initWithFullScreen(const std::string& viewName) { _primaryMonitor = glfwGetPrimaryMonitor(); if (nullptr == _primaryMonitor) return false; const GLFWvidmode* videoMode = glfwGetVideoMode(_primaryMonitor); return init(viewName, videoMode->width, videoMode->height, 1.0f); } bool EGLView::isOpenGLReady() { return nullptr != _mainWindow; } void EGLView::end() { if(_mainWindow) glfwSetWindowShouldClose(_mainWindow,1); } void EGLView::swapBuffers() { if(_mainWindow) glfwSwapBuffers(_mainWindow); } bool EGLView::windowShouldClose() { if(_mainWindow) return glfwWindowShouldClose(_mainWindow); else return true; } void EGLView::pollEvents() { glfwPollEvents(); } void EGLView::setIMEKeyboardState(bool /*bOpen*/) { } void EGLView::setFrameZoomFactor(float zoomFactor) { _frameZoomFactor = zoomFactor; Director::getInstance()->setProjection(Director::getInstance()->getProjection()); } float EGLView::getFrameZoomFactor() { return _frameZoomFactor; } void EGLView::setFrameSize(float width, float height) { EGLViewProtocol::setFrameSize(width, height); } void EGLView::setViewPortInPoints(float x , float y , float w , float h) { glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor), (GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor), (GLsizei)(w * _scaleX * _frameZoomFactor), (GLsizei)(h * _scaleY * _frameZoomFactor)); } void EGLView::setScissorInPoints(float x , float y , float w , float h) { glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor), (GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor), (GLsizei)(w * _scaleX * _frameZoomFactor), (GLsizei)(h * _scaleY * _frameZoomFactor)); } EGLView* EGLView::getInstance() { CCASSERT(nullptr != s_pEglView, "EGL singleton should not be null"); return s_pEglView; } // XXX: deprecated EGLView* EGLView::sharedOpenGLView() { return EGLView::getInstance(); } #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) static bool glew_dynamic_binding() { const char *gl_extensions = (const char*)glGetString(GL_EXTENSIONS); // If the current opengl driver doesn't have framebuffers methods, check if an extension exists if (glGenFramebuffers == NULL) { log("OpenGL: glGenFramebuffers is NULL, try to detect an extension"); if (strstr(gl_extensions, "ARB_framebuffer_object")) { log("OpenGL: ARB_framebuffer_object is supported"); glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer"); glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer"); glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffers"); glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress("glGenRenderbuffers"); glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress("glRenderbufferStorage"); glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) wglGetProcAddress("glGetRenderbufferParameteriv"); glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) wglGetProcAddress("glIsFramebuffer"); glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress("glBindFramebuffer"); glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress("glDeleteFramebuffers"); glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress("glGenFramebuffers"); glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress("glCheckFramebufferStatus"); glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) wglGetProcAddress("glFramebufferTexture1D"); glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress("glFramebufferTexture2D"); glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) wglGetProcAddress("glFramebufferTexture3D"); glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress("glFramebufferRenderbuffer"); glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) wglGetProcAddress("glGetFramebufferAttachmentParameteriv"); glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress("glGenerateMipmap"); } else if (strstr(gl_extensions, "EXT_framebuffer_object")) { log("OpenGL: EXT_framebuffer_object is supported"); glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbufferEXT"); glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT"); glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT"); glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress("glGenRenderbuffersEXT"); glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress("glRenderbufferStorageEXT"); glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) wglGetProcAddress("glGetRenderbufferParameterivEXT"); glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) wglGetProcAddress("glIsFramebufferEXT"); glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress("glBindFramebufferEXT"); glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress("glDeleteFramebuffersEXT"); glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress("glGenFramebuffersEXT"); glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress("glCheckFramebufferStatusEXT"); glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) wglGetProcAddress("glFramebufferTexture1DEXT"); glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress("glFramebufferTexture2DEXT"); glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) wglGetProcAddress("glFramebufferTexture3DEXT"); glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress("glFramebufferRenderbufferEXT"); glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) wglGetProcAddress("glGetFramebufferAttachmentParameterivEXT"); glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress("glGenerateMipmapEXT"); } else { log("OpenGL: No framebuffers extension is supported"); log("OpenGL: Any call to Fbo will crash!"); return false; } } return true; } #endif // helper bool EGLView::initGlew() { #if (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) GLenum GlewInitResult = glewInit(); if (GLEW_OK != GlewInitResult) { MessageBox((char *)glewGetErrorString(GlewInitResult), "OpenGL error"); return false; } if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader) { log("Ready for GLSL"); } else { log("Not totally ready :("); } if (glewIsSupported("GL_VERSION_2_0")) { log("Ready for OpenGL 2.0"); } else { log("OpenGL 2.0 not supported"); } #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) if(glew_dynamic_binding() == false) { MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error"); return false; } #endif #endif // (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) return true; } NS_CC_END // end of namespace cocos2d; ================================================ FILE: cocos2d/cocos/2d/platform/desktop/CCEGLView.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EGLVIEW_DESKTOP_H__ #define __CC_EGLVIEW_DESKTOP_H__ #include "platform/CCCommon.h" #include "platform/CCEGLViewProtocol.h" #include "glfw3.h" NS_CC_BEGIN class CC_DLL EGLView : public EGLViewProtocol { public: // static function /** @brief get the shared main open gl window */ static EGLView* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView(); /** * @js ctor */ EGLView(); /** * @js NA * @lua NA */ virtual ~EGLView(); /* override functions */ virtual bool isOpenGLReady(); virtual void end(); virtual void swapBuffers(); virtual void setFrameSize(float width, float height); virtual void setIMEKeyboardState(bool bOpen); /* *frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. */ bool init(const std::string& viewName, float width, float height, float frameZoomFactor = 1.0f); bool initWithFullScreen(const std::string& viewName); //void resize(int width, int height); float getFrameZoomFactor(); //void centerWindow(); virtual void setViewPortInPoints(float x , float y , float w , float h); virtual void setScissorInPoints(float x , float y , float w , float h); bool windowShouldClose(); void pollEvents(); GLFWwindow* getWindow() const { return _mainWindow; } protected: /* * Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. */ void setFrameZoomFactor(float zoomFactor); bool initGlew(); inline bool isRetina() { return _isRetina; }; bool _captured; bool _supportTouch; bool _isRetina; float _frameZoomFactor; static EGLView* s_pEglView; GLFWwindow* _mainWindow; GLFWmonitor* _primaryMonitor; friend class EGLViewEventHandler; }; NS_CC_END // end of namespace cocos2d #endif // end of __CC_EGLVIEW_DESKTOP_H__ ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCApplication.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_APPLICATION_IOS_H__ #define __CC_APPLICATION_IOS_H__ #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" NS_CC_BEGIN class Rect; class CC_DLL Application : public ApplicationProtocol { public: /** * @js ctor */ Application(); /** * @js NA * @lua NA */ virtual ~Application(); /** @brief Run the message loop. */ int run(); /** @brief Get the current application instance. @return Current application instance pointer. */ static Application* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication(); /** @brief Callback by Director for limit FPS. @param interval The time, expressed in seconds, between current frame and next. */ virtual void setAnimationInterval(double interval); /** @brief Get current language config @return Current language config */ virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ virtual Platform getTargetPlatform(); /** @brief This function will be called when the application screen size is changed. @param new width @param new height */ virtual void applicationScreenSizeChanged(int newWidth, int newHeight); protected: static Application * sm_pSharedApplication; }; NS_CC_END #endif // end of __CC_APPLICATION_IOS_H__ ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCApplication.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import "CCApplication.h" #import #import "CCGeometry.h" #import "CCDirectorCaller.h" NS_CC_BEGIN Application* Application::sm_pSharedApplication = 0; Application::Application() { CC_ASSERT(! sm_pSharedApplication); sm_pSharedApplication = this; } Application::~Application() { CC_ASSERT(this == sm_pSharedApplication); sm_pSharedApplication = 0; } int Application::run() { if (applicationDidFinishLaunching()) { [[CCDirectorCaller sharedDirectorCaller] startMainLoop]; } return 0; } void Application::setAnimationInterval(double interval) { [[CCDirectorCaller sharedDirectorCaller] setAnimationInterval: interval ]; } ///////////////////////////////////////////////////////////////////////////////////////////////// // static member function ////////////////////////////////////////////////////////////////////////////////////////////////// Application* Application::getInstance() { CC_ASSERT(sm_pSharedApplication); return sm_pSharedApplication; } // @deprecated Use getInstance() instead Application* Application::sharedApplication() { return Application::getInstance(); } LanguageType Application::getCurrentLanguage() { // get the current language and country config NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSArray *languages = [defaults objectForKey:@"AppleLanguages"]; NSString *currentLanguage = [languages objectAtIndex:0]; // get the current language code.(such as English is "en", Chinese is "zh" and so on) NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage]; NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode]; LanguageType ret = LanguageType::ENGLISH; if ([languageCode isEqualToString:@"zh"]) { ret = LanguageType::CHINESE; } else if ([languageCode isEqualToString:@"en"]) { ret = LanguageType::ENGLISH; } else if ([languageCode isEqualToString:@"fr"]){ ret = LanguageType::FRENCH; } else if ([languageCode isEqualToString:@"it"]){ ret = LanguageType::ITALIAN; } else if ([languageCode isEqualToString:@"de"]){ ret = LanguageType::GERMAN; } else if ([languageCode isEqualToString:@"es"]){ ret = LanguageType::SPANISH; } else if ([languageCode isEqualToString:@"ru"]){ ret = LanguageType::RUSSIAN; } else if ([languageCode isEqualToString:@"ko"]){ ret = LanguageType::KOREAN; } else if ([languageCode isEqualToString:@"ja"]){ ret = LanguageType::JAPANESE; } else if ([languageCode isEqualToString:@"hu"]){ ret = LanguageType::HUNGARIAN; } else if ([languageCode isEqualToString:@"pt"]){ ret = LanguageType::PORTUGUESE; } else if ([languageCode isEqualToString:@"ar"]){ ret = LanguageType::ARABIC; } else if ([languageCode isEqualToString:@"nb"]){ ret = LanguageType::NORWEGIAN; } else if ([languageCode isEqualToString:@"pl"]){ ret = LanguageType::POLISH; } return ret; } Application::Platform Application::getTargetPlatform() { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) // idiom for iOS <= 3.2, otherwise: [UIDevice userInterfaceIdiom] is faster. { return Platform::OS_IPAD; } else { return Platform::OS_IPHONE; } } void Application::applicationScreenSizeChanged(int newWidth, int newHeight) { } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCCommon.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCCommon.h" #include #include #import #include "CCDirector.h" #include "CCConsole.h" NS_CC_BEGIN // ios no MessageBox, use log instead void MessageBox(const char * msg, const char * title) { NSString * tmpTitle = (title) ? [NSString stringWithUTF8String : title] : nil; NSString * tmpMsg = (msg) ? [NSString stringWithUTF8String : msg] : nil; UIAlertView * messageBox = [[UIAlertView alloc] initWithTitle: tmpTitle message: tmpMsg delegate: nil cancelButtonTitle: @"OK" otherButtonTitles: nil]; [messageBox autorelease]; [messageBox show]; } void LuaLog(const char * format) { puts(format); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCDevice.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCDevice.h" #include "ccTypes.h" #include "CCEventDispatcher.h" #include "CCEventAcceleration.h" #include "CCDirector.h" #import // Accelerometer #import #import @interface CCAccelerometerDispatcher : NSObject { cocos2d::Acceleration *_acceleration; CMMotionManager *_motionManager; } + (id) sharedAccelerometerDispather; - (id) init; - (void) setAccelerometerEnabled: (bool) isEnabled; - (void) setAccelerometerInterval:(float) interval; @end @implementation CCAccelerometerDispatcher static CCAccelerometerDispatcher* s_pAccelerometerDispatcher; + (id) sharedAccelerometerDispather { if (s_pAccelerometerDispatcher == nil) { s_pAccelerometerDispatcher = [[self alloc] init]; } return s_pAccelerometerDispatcher; } - (id) init { if( (self = [super init]) ) { _acceleration = new cocos2d::Acceleration(); _motionManager = [[CMMotionManager alloc] init]; } return self; } - (void) dealloc { s_pAccelerometerDispatcher = nullptr; delete _acceleration; [_motionManager release]; [super dealloc]; } - (void) setAccelerometerEnabled: (bool) isEnabled { if (isEnabled) { [_motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) { [self accelerometer:accelerometerData]; }]; } else { [_motionManager stopAccelerometerUpdates]; } } -(void) setAccelerometerInterval:(float)interval { _motionManager.accelerometerUpdateInterval = interval; } - (void)accelerometer:(CMAccelerometerData *)accelerometerData { _acceleration->x = accelerometerData.acceleration.x; _acceleration->y = accelerometerData.acceleration.y; _acceleration->z = accelerometerData.acceleration.z; _acceleration->timestamp = accelerometerData.timestamp; double tmp = _acceleration->x; switch ([[UIApplication sharedApplication] statusBarOrientation]) { case UIInterfaceOrientationLandscapeRight: _acceleration->x = -_acceleration->y; _acceleration->y = tmp; break; case UIInterfaceOrientationLandscapeLeft: _acceleration->x = _acceleration->y; _acceleration->y = -tmp; break; case UIInterfaceOrientationPortraitUpsideDown: _acceleration->x = -_acceleration->y; _acceleration->y = -tmp; break; case UIInterfaceOrientationPortrait: break; } cocos2d::EventAcceleration event(*_acceleration); auto dispatcher = cocos2d::Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&event); } @end // NS_CC_BEGIN int Device::getDPI() { static int dpi = -1; if (dpi == -1) { float scale = 1.0f; if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { scale = [[UIScreen mainScreen] scale]; } if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { dpi = 132 * scale; } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { dpi = 163 * scale; } else { dpi = 160 * scale; } } return dpi; } void Device::setAccelerometerEnabled(bool isEnabled) { [[CCAccelerometerDispatcher sharedAccelerometerDispather] setAccelerometerEnabled:isEnabled]; } void Device::setAccelerometerInterval(float interval) { [[CCAccelerometerDispatcher sharedAccelerometerDispather] setAccelerometerInterval:interval]; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCDirectorCaller.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import @interface CCDirectorCaller : NSObject { id displayLink; int interval; } @property (readwrite) int interval; -(void) startMainLoop; -(void) doCaller: (id) sender; -(void) setAnimationInterval:(double)interval; +(id) sharedDirectorCaller; +(void) destroy; @end ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCDirectorCaller.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import #import "CCDirectorCaller.h" #import "CCDirector.h" static id s_sharedDirectorCaller; @interface NSObject(CADisplayLink) +(id) displayLinkWithTarget: (id)arg1 selector:(SEL)arg2; -(void) addToRunLoop: (id)arg1 forMode: (id)arg2; -(void) setFrameInterval: (int)interval; -(void) invalidate; @end @implementation CCDirectorCaller @synthesize interval; +(id) sharedDirectorCaller { if (s_sharedDirectorCaller == nil) { s_sharedDirectorCaller = [CCDirectorCaller new]; } return s_sharedDirectorCaller; } +(void) destroy { [s_sharedDirectorCaller release]; s_sharedDirectorCaller = nil; } -(void) alloc { interval = 1; } -(void) dealloc { [displayLink release]; [super dealloc]; } -(void) startMainLoop { // Director::setAnimationInterval() is called, we should invalidate it first [displayLink invalidate]; displayLink = nil; displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)]; [displayLink setFrameInterval: self.interval]; [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; } -(void) setAnimationInterval:(double)intervalNew { // Director::setAnimationInterval() is called, we should invalidate it first [displayLink invalidate]; displayLink = nil; self.interval = 60.0 * intervalNew; displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)]; [displayLink setFrameInterval: self.interval]; [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; } -(void) doCaller: (id) sender { cocos2d::Director::getInstance()->mainLoop(); } @end ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCEGLView.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EGLVIEW_IPHONE_H__ #define __CC_EGLVIEW_IPHONE_H__ #include "platform/CCCommon.h" #include "platform/CCEGLViewProtocol.h" NS_CC_BEGIN class CC_DLL EGLView : public EGLViewProtocol { public: /** * @js NA * @lua NA */ EGLView(); /** * @js NA * @lua NA */ ~EGLView(); /** * @js NA * @lua NA */ virtual bool isOpenGLReady(); /** * @js NA * @lua NA */ virtual bool setContentScaleFactor(float contentScaleFactor); // keep compatible /** * @js NA * @lua NA */ virtual void end(); /** * @js NA * @lua NA */ virtual void swapBuffers(); /** * @js NA * @lua NA */ virtual void setIMEKeyboardState(bool bOpen); /** returns the singleton * @js NA */ static EGLView* getInstance(); /** @deprecated Use getInstance() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView(); }; NS_CC_END #endif // end of __CC_EGLVIEW_IPHONE_H__ ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCEGLView.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "EAGLView.h" #include "CCDirectorCaller.h" #include "CCEGLView.h" #include "CCSet.h" #include "CCTouch.h" NS_CC_BEGIN EGLView::EGLView() { _screenSize.width = _designResolutionSize.width = [[CCEAGLView sharedEGLView] getWidth]; _screenSize.height = _designResolutionSize.height = [[CCEAGLView sharedEGLView] getHeight]; } EGLView::~EGLView() { } bool EGLView::isOpenGLReady() { return [CCEAGLView sharedEGLView] != nullptr; } bool EGLView::setContentScaleFactor(float contentScaleFactor) { assert(_resolutionPolicy == ResolutionPolicy::UNKNOWN); // cannot enable retina mode _scaleX = _scaleY = contentScaleFactor; [[CCEAGLView sharedEGLView] setNeedsLayout]; return true; } void EGLView::end() { [CCDirectorCaller destroy]; // destroy EAGLView [[CCEAGLView sharedEGLView] removeFromSuperview]; } void EGLView::swapBuffers() { [[CCEAGLView sharedEGLView] swapBuffers]; } void EGLView::setIMEKeyboardState(bool bOpen) { if (bOpen) { [[CCEAGLView sharedEGLView] becomeFirstResponder]; } else { [[CCEAGLView sharedEGLView] resignFirstResponder]; } } EGLView* EGLView::getInstance() { static EGLView instance; return &instance; } // XXX: deprecated EGLView* EGLView::sharedOpenGLView() { return EGLView::getInstance(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCES2Renderer.h ================================================ /**************************************************************************** Copyright (c) 2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Corpyight (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ // Only compile this code on iOS. These files should NOT be included on your Mac project. // But in case they are included, it won't be compiled. #import "CCPlatformMacros.h" #import "CCESRenderer.h" #import #import @interface CCES2Renderer : NSObject { // The pixel dimensions of the CAEAGLLayer GLint backingWidth_; GLint backingHeight_; unsigned int samplesToUse_; BOOL multiSampling_; unsigned int depthFormat_; unsigned int pixelFormat_; // The OpenGL ES names for the framebuffer and renderbuffer used to render to this view GLuint defaultFramebuffer_; GLuint colorRenderbuffer_; GLuint depthBuffer_; //buffers for MSAA GLuint msaaFramebuffer_; GLuint msaaColorbuffer_; EAGLContext *context_; } /** Color Renderbuffer */ @property (nonatomic,readonly) GLuint colorRenderbuffer; /** Default Renderbuffer */ @property (nonatomic,readonly) GLuint defaultFramebuffer; /** MSAA Framebuffer */ @property (nonatomic,readonly) GLuint msaaFramebuffer; /** MSAA Color Buffer */ @property (nonatomic,readonly) GLuint msaaColorbuffer; /** EAGLContext */ @property (nonatomic,readonly) EAGLContext* context; - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer; @end ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCES2Renderer.m ================================================ /**************************************************************************** Copyright (c) 2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Corpyight (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ // Only compile this code on iOS. These files should NOT be included on your Mac project. // But in case they are included, it won't be compiled. #import "CCPlatformMacros.h" #import "CCES2Renderer.h" #import "OpenGL_Internal.h" #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 #define NSLog(...) do {} while (0) #endif @implementation CCES2Renderer @synthesize context=context_; @synthesize defaultFramebuffer=defaultFramebuffer_; @synthesize colorRenderbuffer=colorRenderbuffer_; @synthesize msaaColorbuffer=msaaColorbuffer_; @synthesize msaaFramebuffer=msaaFramebuffer_; // Create an OpenGL ES 2.0 context - (id) initWithDepthFormat:(unsigned int)depthFormat withPixelFormat:(unsigned int)pixelFormat withSharegroup:(EAGLSharegroup*)sharegroup withMultiSampling:(BOOL) multiSampling withNumberOfSamples:(unsigned int) requestedSamples { self = [super init]; if (self) { if( ! sharegroup ) context_ = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; else context_ = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:sharegroup]; if (!context_ || ![EAGLContext setCurrentContext:context_] ) { [self release]; return nil; } depthFormat_ = depthFormat; pixelFormat_ = pixelFormat; multiSampling_ = multiSampling; // Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer glGenFramebuffers(1, &defaultFramebuffer_); NSAssert( defaultFramebuffer_, @"Can't create default frame buffer"); glGenRenderbuffers(1, &colorRenderbuffer_); NSAssert( colorRenderbuffer_, @"Can't create default render buffer"); glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer_); glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer_); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer_); if (multiSampling_) { GLint maxSamplesAllowed; glGetIntegerv(GL_MAX_SAMPLES_APPLE, &maxSamplesAllowed); samplesToUse_ = MIN(maxSamplesAllowed,requestedSamples); /* Create the MSAA framebuffer (offscreen) */ glGenFramebuffers(1, &msaaFramebuffer_); NSAssert( msaaFramebuffer_, @"Can't create default MSAA frame buffer"); glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebuffer_); } CHECK_GL_ERROR(); } return self; } - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer { // Allocate color buffer backing based on the current layer size glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer_); if( ! [context_ renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer] ) { NSLog(@"failed to call context"); } glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth_); glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight_); NSLog(@"cocos2d: surface size: %dx%d", (int)backingWidth_, (int)backingHeight_); if (multiSampling_) { if ( msaaColorbuffer_) { glDeleteRenderbuffers(1, &msaaColorbuffer_); msaaColorbuffer_ = 0; } /* Create the offscreen MSAA color buffer. After rendering, the contents of this will be blitted into ColorRenderbuffer */ //msaaFrameBuffer needs to be binded glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebuffer_); glGenRenderbuffers(1, &msaaColorbuffer_); NSAssert(msaaFramebuffer_, @"Can't create MSAA color buffer"); glBindRenderbuffer(GL_RENDERBUFFER, msaaColorbuffer_); glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, samplesToUse_, pixelFormat_ , backingWidth_, backingHeight_); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaColorbuffer_); GLenum error; if ( (error=glCheckFramebufferStatus(GL_FRAMEBUFFER)) != GL_FRAMEBUFFER_COMPLETE) { NSLog(@"Failed to make complete framebuffer object 0x%X", error); return NO; } } CHECK_GL_ERROR(); if (depthFormat_) { if( ! depthBuffer_ ) { glGenRenderbuffers(1, &depthBuffer_); NSAssert(depthBuffer_, @"Can't create depth buffer"); } glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer_); if( multiSampling_ ) glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, samplesToUse_, depthFormat_,backingWidth_, backingHeight_); else glRenderbufferStorage(GL_RENDERBUFFER, depthFormat_, backingWidth_, backingHeight_); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer_); if (depthFormat_ == GL_DEPTH24_STENCIL8_OES) { glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthBuffer_); } // bind color buffer glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer_); } CHECK_GL_ERROR(); GLenum error; if( (error=glCheckFramebufferStatus(GL_FRAMEBUFFER)) != GL_FRAMEBUFFER_COMPLETE) { NSLog(@"Failed to make complete framebuffer object 0x%X", error); return NO; } return YES; } -(CGSize) backingSize { return CGSizeMake( backingWidth_, backingHeight_); } - (NSString*) description { return [NSString stringWithFormat:@"<%@ = %08X | size = %ix%i>", [self class], (unsigned int)self, backingWidth_, backingHeight_]; } - (unsigned int) colorRenderBuffer { return colorRenderbuffer_; } - (unsigned int) defaultFrameBuffer { return defaultFramebuffer_; } - (unsigned int) msaaFrameBuffer { return msaaFramebuffer_; } - (unsigned int) msaaColorBuffer { return msaaColorbuffer_; } - (void)dealloc { // CCLOGINFO("deallocing CCES2Renderer: %p", self); // Tear down GL if (defaultFramebuffer_) { glDeleteFramebuffers(1, &defaultFramebuffer_); defaultFramebuffer_ = 0; } if (colorRenderbuffer_) { glDeleteRenderbuffers(1, &colorRenderbuffer_); colorRenderbuffer_ = 0; } if( depthBuffer_ ) { glDeleteRenderbuffers(1, &depthBuffer_ ); depthBuffer_ = 0; } if ( msaaColorbuffer_) { glDeleteRenderbuffers(1, &msaaColorbuffer_); msaaColorbuffer_ = 0; } if ( msaaFramebuffer_) { glDeleteRenderbuffers(1, &msaaFramebuffer_); msaaFramebuffer_ = 0; } // Tear down context if ([EAGLContext currentContext] == context_) [EAGLContext setCurrentContext:nil]; [context_ release]; context_ = nil; [super dealloc]; } @end ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCESRenderer.h ================================================ /**************************************************************************** Copyright (c) 2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org Corpyight (c) 2011 Zynga Inc. Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ // Only compile this code on iOS. These files should NOT be included on your Mac project. // But in case they are included, it won't be compiled. #include "CCPlatformMacros.h" #import #import #import @protocol CCESRenderer - (id) initWithDepthFormat:(unsigned int)depthFormat withPixelFormat:(unsigned int)pixelFormat withSharegroup:(EAGLSharegroup*)sharegroup withMultiSampling:(BOOL) multiSampling withNumberOfSamples:(unsigned int) requestedSamples; - (BOOL) resizeFromLayer:(CAEAGLLayer *)layer; - (EAGLContext*) context; - (CGSize) backingSize; - (unsigned int) colorRenderBuffer; - (unsigned int) defaultFrameBuffer; - (unsigned int) msaaFrameBuffer; - (unsigned int) msaaColorBuffer; @end ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCGL.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __PLATFORM_IOS_CCGL_H__ #define __PLATFORM_IOS_CCGL_H__ #define glClearDepth glClearDepthf #define glDeleteVertexArrays glDeleteVertexArraysOES #define glGenVertexArrays glGenVertexArraysOES #define glBindVertexArray glBindVertexArrayOES #define glMapBuffer glMapBufferOES #define glUnmapBuffer glUnmapBufferOES #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES #define GL_WRITE_ONLY GL_WRITE_ONLY_OES #include #include #endif // __PLATFORM_IOS_CCGL_H__ ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCImage.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCImageCommon_cpp.h" #import "CCImage.h" #import "CCFileUtils.h" #import "platform/CCCommon.h" #import #import #import #include typedef struct { unsigned int height; unsigned int width; bool isPremultipliedAlpha; bool hasShadow; CGSize shadowOffset; float shadowBlur; float shadowOpacity; bool hasStroke; float strokeColorR; float strokeColorG; float strokeColorB; float strokeSize; float tintColorR; float tintColorG; float tintColorB; unsigned char* data; } tImageInfo; static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize) { NSArray *listItems = [str componentsSeparatedByString: @"\n"]; CGSize dim = CGSizeZero; CGSize textRect = CGSizeZero; textRect.width = constrainSize->width > 0 ? constrainSize->width : 0x7fffffff; textRect.height = constrainSize->height > 0 ? constrainSize->height : 0x7fffffff; for (NSString *s in listItems) { CGSize tmp = [s sizeWithFont:font constrainedToSize:textRect]; if (tmp.width > dim.width) { dim.width = tmp.width; } dim.height += tmp.height; } return dim; } // refer Image::ETextAlign #define ALIGN_TOP 1 #define ALIGN_CENTER 3 #define ALIGN_BOTTOM 2 static bool _initWithString(const char * text, cocos2d::Image::TextAlign align, const char * fontName, int size, tImageInfo* info) { bool bRet = false; do { CC_BREAK_IF(! text || ! info); NSString * str = [NSString stringWithUTF8String:text]; NSString * fntName = [NSString stringWithUTF8String:fontName]; CGSize dim, constrainSize; constrainSize.width = info->width; constrainSize.height = info->height; // On iOS custom fonts must be listed beforehand in the App info.plist (in order to be usable) and referenced only the by the font family name itself when // calling [UIFont fontWithName]. Therefore even if the developer adds 'SomeFont.ttf' or 'fonts/SomeFont.ttf' to the App .plist, the font must // be referenced as 'SomeFont' when calling [UIFont fontWithName]. Hence we strip out the folder path components and the extension here in order to get just // the font family name itself. This stripping step is required especially for references to user fonts stored in CCB files; CCB files appear to store // the '.ttf' extensions when referring to custom fonts. fntName = [[fntName lastPathComponent] stringByDeletingPathExtension]; // create the font id font = [UIFont fontWithName:fntName size:size]; if (font) { dim = _calculateStringSize(str, font, &constrainSize); } else { if (!font) { font = [UIFont systemFontOfSize:size]; } if (font) { dim = _calculateStringSize(str, font, &constrainSize); } } CC_BREAK_IF(! font); // compute start point int startH = 0; if (constrainSize.height > dim.height) { // vertical alignment unsigned int vAlignment = ((int)align >> 4) & 0x0F; if (vAlignment == ALIGN_TOP) { startH = 0; } else if (vAlignment == ALIGN_CENTER) { startH = (constrainSize.height - dim.height) / 2; } else { startH = constrainSize.height - dim.height; } } // adjust text rect if (constrainSize.width > 0 && constrainSize.width > dim.width) { dim.width = constrainSize.width; } if (constrainSize.height > 0 && constrainSize.height > dim.height) { dim.height = constrainSize.height; } // compute the padding needed by shadow and stroke float shadowStrokePaddingX = 0.0f; float shadowStrokePaddingY = 0.0f; if ( info->hasStroke ) { shadowStrokePaddingX = ceilf(info->strokeSize); shadowStrokePaddingY = ceilf(info->strokeSize); } if ( info->hasShadow ) { shadowStrokePaddingX = std::max(shadowStrokePaddingX, (float)fabs(info->shadowOffset.width)); shadowStrokePaddingY = std::max(shadowStrokePaddingY, (float)fabs(info->shadowOffset.height)); } // add the padding (this could be 0 if no shadow and no stroke) dim.width += shadowStrokePaddingX; dim.height += shadowStrokePaddingY; unsigned char* data = new unsigned char[(int)(dim.width * dim.height * 4)]; memset(data, 0, (int)(dim.width * dim.height * 4)); // draw text CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(data, dim.width, dim.height, 8, (int)(dim.width) * 4, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); if (!context) { CGColorSpaceRelease(colorSpace); delete[] data; break; } // text color CGContextSetRGBFillColor(context, info->tintColorR, info->tintColorG, info->tintColorB, 1); // move Y rendering to the top of the image CGContextTranslateCTM(context, 0.0f, (dim.height - shadowStrokePaddingY) ); CGContextScaleCTM(context, 1.0f, -1.0f); //NOTE: NSString draws in UIKit referential i.e. renders upside-down compared to CGBitmapContext referential // store the current context UIGraphicsPushContext(context); // measure text size with specified font and determine the rectangle to draw text in unsigned uHoriFlag = (int)align & 0x0f; UITextAlignment testAlign = (UITextAlignment)((2 == uHoriFlag) ? UITextAlignmentRight : (3 == uHoriFlag) ? UITextAlignmentCenter : UITextAlignmentLeft); // take care of stroke if needed if ( info->hasStroke ) { CGContextSetTextDrawingMode(context, kCGTextFillStroke); CGContextSetRGBStrokeColor(context, info->strokeColorR, info->strokeColorG, info->strokeColorB, 1); CGContextSetLineWidth(context, info->strokeSize); } // take care of shadow if needed if ( info->hasShadow ) { CGSize offset; offset.height = info->shadowOffset.height; offset.width = info->shadowOffset.width; CGFloat shadowColorValues[] = {0, 0, 0, info->shadowOpacity}; CGColorRef shadowColor = CGColorCreate (colorSpace, shadowColorValues); CGContextSetShadowWithColor(context, offset, info->shadowBlur, shadowColor); CGColorRelease (shadowColor); } CGColorSpaceRelease(colorSpace); // normal fonts //if( [font isKindOfClass:[UIFont class] ] ) //{ // [str drawInRect:CGRectMake(0, startH, dim.width, dim.height) withFont:font lineBreakMode:(UILineBreakMode)UILineBreakModeWordWrap alignment:align]; //} //else // ZFont class //{ // [FontLabelStringDrawingHelper drawInRect:str rect:CGRectMake(0, startH, dim.width, dim.height) withZFont:font lineBreakMode:(UILineBreakMode)UILineBreakModeWordWrap ////alignment:align]; //} // compute the rect used for rendering the text // based on wether shadows or stroke are enabled float textOriginX = 0.0; float textOrigingY = 0.0; float textWidth = dim.width - shadowStrokePaddingX; float textHeight = dim.height - shadowStrokePaddingY; if ( info->shadowOffset.width < 0 ) { textOriginX = shadowStrokePaddingX; } else { textOriginX = 0.0; } if (info->shadowOffset.height > 0) { textOrigingY = startH; } else { textOrigingY = startH - shadowStrokePaddingY; } CGRect rect = CGRectMake(textOriginX, textOrigingY, textWidth, textHeight); CGContextBeginTransparencyLayerWithRect(context, rect, nullptr); // actually draw the text in the context // XXX: ios7 casting [str drawInRect: rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)testAlign]; CGContextEndTransparencyLayer(context); // pop the context UIGraphicsPopContext(); // release the context CGContextRelease(context); // output params info->data = data; info->isPremultipliedAlpha = true; info->width = dim.width; info->height = dim.height; bRet = true; } while (0); return bRet; } NS_CC_BEGIN bool Image::initWithString( const char * pText, int nWidth /* = 0 */, int nHeight /* = 0 */, TextAlign eAlignMask /* = kAlignCenter */, const char * pFontName /* = nil */, int nSize /* = 0 */) { return initWithStringShadowStroke(pText, nWidth, nHeight, eAlignMask , pFontName, nSize); } bool Image::initWithStringShadowStroke( const char * text, int width , int height , TextAlign alignMask , const char * fontName , int size , float textTintR, float textTintG, float textTintB, bool shadow, float shadowOffsetX, float shadowOffsetY, float shadowOpacity, float shadowBlur, bool stroke, float strokeR, float strokeG, float strokeB, float strokeSize) { tImageInfo info = {0}; info.width = width; info.height = height; info.hasShadow = shadow; info.shadowOffset.width = shadowOffsetX; info.shadowOffset.height = shadowOffsetY; info.shadowBlur = shadowBlur; info.shadowOpacity = shadowOpacity; info.hasStroke = stroke; info.strokeColorR = strokeR; info.strokeColorG = strokeG; info.strokeColorB = strokeB; info.strokeSize = strokeSize; info.tintColorR = textTintR; info.tintColorG = textTintG; info.tintColorB = textTintB; if (! _initWithString(text, alignMask, fontName, size, &info)) { return false; } _height = (short)info.height; _width = (short)info.width; _renderFormat = Texture2D::PixelFormat::RGBA8888; _preMulti = info.isPremultipliedAlpha; _data = info.data; _dataLen = _width * _height * 4; return true; } bool Image::saveToFile(const std::string& filename, bool isToRGB) { bool saveToPNG = false; bool needToCopyPixels = false; if (std::string::npos != filename.find(".png")) { saveToPNG = true; } int bitsPerComponent = 8; int bitsPerPixel = hasAlpha() ? 32 : 24; if ((! saveToPNG) || isToRGB) { bitsPerPixel = 24; } int bytesPerRow = (bitsPerPixel/8) * _width; int myDataLength = bytesPerRow * _height; unsigned char *pixels = _data; // The data has alpha channel, and want to save it with an RGB png file, // or want to save as jpg, remove the alpha channel. if ((saveToPNG && hasAlpha() && isToRGB) || (! saveToPNG)) { pixels = new unsigned char[myDataLength]; for (int i = 0; i < _height; ++i) { for (int j = 0; j < _width; ++j) { pixels[(i * _width + j) * 3] = _data[(i * _width + j) * 4]; pixels[(i * _width + j) * 3 + 1] = _data[(i * _width + j) * 4 + 1]; pixels[(i * _width + j) * 3 + 2] = _data[(i * _width + j) * 4 + 2]; } } needToCopyPixels = true; } // make data provider with data. CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; if (saveToPNG && hasAlpha() && (! isToRGB)) { bitmapInfo |= kCGImageAlphaPremultipliedLast; } CGDataProviderRef provider = CGDataProviderCreateWithData(nullptr, pixels, myDataLength, nullptr); CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGImageRef iref = CGImageCreate(_width, _height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, nullptr, false, kCGRenderingIntentDefault); UIImage* image = [[UIImage alloc] initWithCGImage:iref]; CGImageRelease(iref); CGColorSpaceRelease(colorSpaceRef); CGDataProviderRelease(provider); NSData *data; if (saveToPNG) { data = UIImagePNGRepresentation(image); } else { data = UIImageJPEGRepresentation(image, 1.0f); } [data writeToFile:[NSString stringWithUTF8String:filename.c_str()] atomically:YES]; [image release]; if (needToCopyPixels) { delete [] pixels; } return true; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCPlatformDefine.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ #include #define CC_DLL #define CC_ASSERT(cond) assert(cond) #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam /* Define NULL pointer value */ #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif #endif /* __CCPLATFORMDEFINE_H__*/ ================================================ FILE: cocos2d/cocos/2d/platform/ios/CCStdC.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_STD_C_H__ #define __CC_STD_C_H__ #include "CCPlatformMacros.h" #include #include #include #include #include #include #include #include #include #ifndef MIN #define MIN(x,y) (((x) > (y)) ? (y) : (x)) #endif // MIN #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX #endif // __CC_STD_C_H__ ================================================ FILE: cocos2d/cocos/2d/platform/ios/EAGLView.h ================================================ /* ===== IMPORTANT ===== This is sample code demonstrating API, technology or techniques in development. Although this sample code has been reviewed for technical accuracy, it is not final. Apple is supplying this information to help you plan for the adoption of the technologies and programming interfaces described herein. This information is subject to change, and software implemented based on this sample code should be tested with final operating system software and final documentation. Newer versions of this sample code may be provided with future seeds of the API or technology. For information about updates to this and other developer documentation, view the New & Updated sidebars in subsequent documentation seeds. ===================== File: EAGLView.h Abstract: Convenience class that wraps the CAEAGLLayer from CoreAnimation into a UIView subclass. Version: 1.3 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2008 Apple Inc. All Rights Reserved. */ #import #import #import #import #import #import #import "CCESRenderer.h" //CLASS INTERFACE: /** CCEAGLView Class. * This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. * The view content is basically an EAGL surface you render your OpenGL scene into. * Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. */ @interface CCEAGLView : UIView { id renderer_; EAGLContext *context_; // weak ref NSString *pixelformat_; GLuint depthFormat_; BOOL preserveBackbuffer_; CGSize size_; BOOL discardFramebufferSupported_; //fsaa addition BOOL multisampling_; unsigned int requestedSamples_; BOOL isUseUITextField; @private NSString * markedText_; CGRect caretRect_; CGRect originalRect_; NSNotification* keyboardShowNotification_; BOOL isKeyboardShown_; } @property(nonatomic, readonly) UITextPosition *beginningOfDocument; @property(nonatomic, readonly) UITextPosition *endOfDocument; @property(nonatomic, assign) id inputDelegate; @property(nonatomic, readonly) UITextRange *markedTextRange; @property (nonatomic, copy) NSDictionary *markedTextStyle; @property(readwrite, copy) UITextRange *selectedTextRange; @property(nonatomic, readonly) id tokenizer; @property(nonatomic, readonly, getter = isKeyboardShown) BOOL isKeyboardShown; @property(nonatomic, copy) NSNotification* keyboardShowNotification; /** creates an initializes an CCEAGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer */ + (id) viewWithFrame:(CGRect)frame; /** creates an initializes an CCEAGLView with a frame, a color buffer format, and 0-bit depth buffer */ + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format; /** creates an initializes an CCEAGLView with a frame, a color buffer format, and a depth buffer format */ + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth; /** creates an initializes an CCEAGLView with a frame, a color buffer format, a depth buffer format, a sharegroup, and multisamping */ + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)multisampling numberOfSamples:(unsigned int)samples; // get the view object +(id) sharedEGLView; /** Initializes an CCEAGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer */ - (id) initWithFrame:(CGRect)frame; //These also set the current context /** Initializes an CCEAGLView with a frame, a color buffer format, and 0-bit depth buffer */ - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format; /** Initializes an CCEAGLView with a frame, a color buffer format, a depth buffer format, a sharegroup and multisampling support */ - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)sampling numberOfSamples:(unsigned int)nSamples; /** pixel format: it could be RGBA8 (32-bit) or RGB565 (16-bit) */ @property(nonatomic,readonly) NSString* pixelFormat; /** depth format of the render buffer: 0, 16 or 24 bits*/ @property(nonatomic,readonly) GLuint depthFormat; /** returns surface size in pixels */ @property(nonatomic,readonly) CGSize surfaceSize; /** OpenGL context */ @property(nonatomic,readonly) EAGLContext *context; @property(nonatomic,readwrite) BOOL multiSampling; /** CCEAGLView uses double-buffer. This method swaps the buffers */ -(void) swapBuffers; - (CGRect) convertRectFromViewToSurface:(CGRect)rect; - (CGPoint) convertPointFromViewToSurface:(CGPoint)point; -(int) getWidth; -(int) getHeight; -(void) doAnimationWhenKeyboardMoveWithDuration:(float) duration distance:(float) dis; -(void) doAnimationWhenAnotherEditBeClicked; @end ================================================ FILE: cocos2d/cocos/2d/platform/ios/EAGLView.mm ================================================ /* ===== IMPORTANT ===== This is sample code demonstrating API, technology or techniques in development. Although this sample code has been reviewed for technical accuracy, it is not final. Apple is supplying this information to help you plan for the adoption of the technologies and programming interfaces described herein. This information is subject to change, and software implemented based on this sample code should be tested with final operating system software and final documentation. Newer versions of this sample code may be provided with future seeds of the API or technology. For information about updates to this and other developer documentation, view the New & Updated sidebars in subsequent documentation seeds. ===================== File: EAGLView.m Abstract: Convenience class that wraps the CAEAGLLayer from CoreAnimation into a UIView subclass. Version: 1.3 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2008 Apple Inc. All Rights Reserved. */ #import #import "CCEGLView.h" #import "EAGLView.h" #import "CCES2Renderer.h" #import "CCDirector.h" #import "CCSet.h" #import "CCTouch.h" #import "CCIMEDispatcher.h" #import "OpenGL_Internal.h" #import "CCEGLView.h" //CLASS IMPLEMENTATIONS: #define IOS_MAX_TOUCHES_COUNT 10 static CCEAGLView *__view = 0; @interface CCEAGLView (Private) - (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup; - (unsigned int) convertPixelFormat:(NSString*) pixelFormat; @end @implementation CCEAGLView @synthesize surfaceSize=size_; @synthesize pixelFormat=pixelformat_, depthFormat=depthFormat_; @synthesize context=context_; @synthesize multiSampling=multiSampling_; @synthesize isKeyboardShown=isKeyboardShown_; @synthesize keyboardShowNotification = keyboardShowNotification_; + (Class) layerClass { return [CAEAGLLayer class]; } + (id) viewWithFrame:(CGRect)frame { return [[[self alloc] initWithFrame:frame] autorelease]; } + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format { return [[[self alloc]initWithFrame:frame pixelFormat:format] autorelease]; } + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth { return [[[self alloc] initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0] autorelease]; } + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)multisampling numberOfSamples:(unsigned int)samples { return [[[self alloc]initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:retained sharegroup:sharegroup multiSampling:multisampling numberOfSamples:samples] autorelease]; } + (id) sharedEGLView { return __view; } - (id) initWithFrame:(CGRect)frame { return [self initWithFrame:frame pixelFormat:kEAGLColorFormatRGB565 depthFormat:0 preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0]; } - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format { return [self initWithFrame:frame pixelFormat:format depthFormat:0 preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0]; } - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)sampling numberOfSamples:(unsigned int)nSamples; { if((self = [super initWithFrame:frame])) { isUseUITextField = YES; pixelformat_ = format; depthFormat_ = depth; multiSampling_ = sampling; requestedSamples_ = nSamples; preserveBackbuffer_ = retained; markedText_ = nil; if( ! [self setupSurfaceWithSharegroup:sharegroup] ) { [self release]; return nil; } __view = self; originalRect_ = self.frame; self.keyboardShowNotification = nil; if ([__view respondsToSelector:@selector(setContentScaleFactor:)]) { __view.contentScaleFactor = [[UIScreen mainScreen] scale]; } } return self; } -(id) initWithCoder:(NSCoder *)aDecoder { if( (self = [super initWithCoder:aDecoder]) ) { CAEAGLLayer* eaglLayer = (CAEAGLLayer*)[self layer]; pixelformat_ = kEAGLColorFormatRGB565; depthFormat_ = 0; // GL_DEPTH_COMPONENT24_OES; multiSampling_= NO; requestedSamples_ = 0; size_ = [eaglLayer bounds].size; markedText_ = nil; if( ! [self setupSurfaceWithSharegroup:nil] ) { [self release]; return nil; } } __view = self; return self; } - (void)didMoveToWindow; { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUIKeyboardNotification:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUIKeyboardNotification:) name:UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUIKeyboardNotification:) name:UIKeyboardWillHideNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUIKeyboardNotification:) name:UIKeyboardDidHideNotification object:nil]; } -(int) getWidth { CGSize bound = [self bounds].size; return (int)bound.width * self.contentScaleFactor; } -(int) getHeight { CGSize bound = [self bounds].size; return (int)bound.height * self.contentScaleFactor; } -(BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup { CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; eaglLayer.opaque = YES; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:preserveBackbuffer_], kEAGLDrawablePropertyRetainedBacking, pixelformat_, kEAGLDrawablePropertyColorFormat, nil]; renderer_ = [[CCES2Renderer alloc] initWithDepthFormat:depthFormat_ withPixelFormat:[self convertPixelFormat:pixelformat_] withSharegroup:sharegroup withMultiSampling:multiSampling_ withNumberOfSamples:requestedSamples_]; NSAssert(renderer_, @"OpenGL ES 2.O is required."); if (!renderer_) return NO; context_ = [renderer_ context]; #if GL_EXT_discard_framebuffer == 1 discardFramebufferSupported_ = YES; #else discardFramebufferSupported_ = NO; #endif CHECK_GL_ERROR(); return YES; } - (void) dealloc { [renderer_ release]; self.keyboardShowNotification = nullptr; // implicit release [super dealloc]; } - (void) layoutSubviews { [renderer_ resizeFromLayer:(CAEAGLLayer*)self.layer]; size_ = [renderer_ backingSize]; // Issue #914 #924 // Director *director = [Director sharedDirector]; // [director reshapeProjection:size_]; cocos2d::Size size; size.width = size_.width; size.height = size_.height; //cocos2d::Director::getInstance()->reshapeProjection(size); // Avoid flicker. Issue #350 //[director performSelectorOnMainThread:@selector(drawScene) withObject:nil waitUntilDone:YES]; cocos2d::Director::getInstance()->drawScene(); } - (void) swapBuffers { // IMPORTANT: // - preconditions // -> context_ MUST be the OpenGL context // -> renderbuffer_ must be the the RENDER BUFFER #ifdef __IPHONE_4_0 if (multiSampling_) { /* Resolve from msaaFramebuffer to resolveFramebuffer */ //glDisable(GL_SCISSOR_TEST); glBindFramebuffer(GL_READ_FRAMEBUFFER_APPLE, [renderer_ msaaFrameBuffer]); glBindFramebuffer(GL_DRAW_FRAMEBUFFER_APPLE, [renderer_ defaultFrameBuffer]); glResolveMultisampleFramebufferAPPLE(); } if(discardFramebufferSupported_) { if (multiSampling_) { if (depthFormat_) { GLenum attachments[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT}; glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments); } else { GLenum attachments[] = {GL_COLOR_ATTACHMENT0}; glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 1, attachments); } glBindRenderbuffer(GL_RENDERBUFFER, [renderer_ colorRenderBuffer]); } // not MSAA else if (depthFormat_ ) { GLenum attachments[] = { GL_DEPTH_ATTACHMENT}; glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments); } } #endif // __IPHONE_4_0 if(![context_ presentRenderbuffer:GL_RENDERBUFFER]) { // CCLOG(@"cocos2d: Failed to swap renderbuffer in %s\n", __FUNCTION__); } #if COCOS2D_DEBUG CHECK_GL_ERROR(); #endif // We can safely re-bind the framebuffer here, since this will be the // 1st instruction of the new main loop if( multiSampling_ ) glBindFramebuffer(GL_FRAMEBUFFER, [renderer_ msaaFrameBuffer]); } - (unsigned int) convertPixelFormat:(NSString*) pixelFormat { // define the pixel format GLenum pFormat; if([pixelFormat isEqualToString:@"EAGLColorFormat565"]) pFormat = GL_RGB565; else pFormat = GL_RGBA8_OES; return pFormat; } #pragma mark CCEAGLView - Point conversion - (CGPoint) convertPointFromViewToSurface:(CGPoint)point { CGRect bounds = [self bounds]; CGPoint ret; ret.x = (point.x - bounds.origin.x) / bounds.size.width * size_.width; ret.y = (point.y - bounds.origin.y) / bounds.size.height * size_.height; return ret; } - (CGRect) convertRectFromViewToSurface:(CGRect)rect { CGRect bounds = [self bounds]; CGRect ret; ret.origin.x = (rect.origin.x - bounds.origin.x) / bounds.size.width * size_.width; ret.origin.y = (rect.origin.y - bounds.origin.y) / bounds.size.height * size_.height; ret.size.width = rect.size.width / bounds.size.width * size_.width; ret.size.height = rect.size.height / bounds.size.height * size_.height; return ret; } -(void) handleTouchesAfterKeyboardShow { NSArray *subviews = self.subviews; for(UIView* view in subviews) { if([view isKindOfClass:NSClassFromString(@"CCCustomUITextField")]) { if ([view isFirstResponder]) { [view resignFirstResponder]; return; } } } } // Pass the touches to the superview #pragma mark CCEAGLView - Touch Delegate - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (isKeyboardShown_) { [self handleTouchesAfterKeyboardShow]; return; } UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; int i = 0; for (UITouch *touch in touches) { ids[i] = touch; xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;; ++i; } cocos2d::EGLView::getInstance()->handleTouchesBegin(i, (int*)ids, xs, ys); } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if (isKeyboardShown_) { return; } UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; int i = 0; for (UITouch *touch in touches) { ids[i] = touch; xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;; ++i; } cocos2d::EGLView::getInstance()->handleTouchesMove(i, (int*)ids, xs, ys); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if (isKeyboardShown_) { return; } UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; int i = 0; for (UITouch *touch in touches) { ids[i] = touch; xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;; ++i; } cocos2d::EGLView::getInstance()->handleTouchesEnd(i, (int*)ids, xs, ys); } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { if (isKeyboardShown_) { return; } UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0}; float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; int i = 0; for (UITouch *touch in touches) { ids[i] = touch; xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;; ++i; } cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (int*)ids, xs, ys); } #pragma mark - UIView - Responder - (BOOL)canBecomeFirstResponder { if (nil != markedText_) { [markedText_ release]; } markedText_ = nil; if (isUseUITextField) { return NO; } return YES; } - (BOOL)becomeFirstResponder { isUseUITextField = NO; return [super becomeFirstResponder]; } - (BOOL)resignFirstResponder { isUseUITextField = YES; return [super resignFirstResponder]; } #pragma mark - UIKeyInput protocol - (BOOL)hasText { return NO; } - (void)insertText:(NSString *)text { if (nil != markedText_) { [markedText_ release]; markedText_ = nil; } const char * pszText = [text cStringUsingEncoding:NSUTF8StringEncoding]; cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); } - (void)deleteBackward { if (nil != markedText_) { [markedText_ release]; markedText_ = nil; } cocos2d::IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); } #pragma mark - UITextInputTrait protocol -(UITextAutocapitalizationType) autocapitalizationType { return UITextAutocapitalizationTypeNone; } #pragma mark - UITextInput protocol #pragma mark UITextInput - properties @synthesize beginningOfDocument; @synthesize endOfDocument; @synthesize inputDelegate; @synthesize markedTextRange; @synthesize markedTextStyle; // @synthesize selectedTextRange; // must implement @synthesize tokenizer; /* Text may have a selection, either zero-length (a caret) or ranged. Editing operations are * always performed on the text from this selection. nil corresponds to no selection. */ - (void)setSelectedTextRange:(UITextRange *)aSelectedTextRange; { CCLOG("UITextRange:setSelectedTextRange"); } - (UITextRange *)selectedTextRange; { return [[[UITextRange alloc] init] autorelease]; } #pragma mark UITextInput - Replacing and Returning Text - (NSString *)textInRange:(UITextRange *)range; { CCLOG("textInRange"); return @""; } - (void)replaceRange:(UITextRange *)range withText:(NSString *)theText; { CCLOG("replaceRange"); } #pragma mark UITextInput - Working with Marked and Selected Text /* If text can be selected, it can be marked. Marked text represents provisionally * inserted text that has yet to be confirmed by the user. It requires unique visual * treatment in its display. If there is any marked text, the selection, whether a * caret or an extended range, always resides within. * * Setting marked text either replaces the existing marked text or, if none is present, * inserts it from the current selection. */ - (void)setMarkedTextRange:(UITextRange *)markedTextRange; { CCLOG("setMarkedTextRange"); } - (UITextRange *)markedTextRange; { CCLOG("markedTextRange"); return nil; // Nil if no marked text. } - (void)setMarkedTextStyle:(NSDictionary *)markedTextStyle; { CCLOG("setMarkedTextStyle"); } - (NSDictionary *)markedTextStyle; { CCLOG("markedTextStyle"); return nil; } - (void)setMarkedText:(NSString *)markedText selectedRange:(NSRange)selectedRange; { CCLOG("setMarkedText"); if (markedText == markedText_) { return; } if (nil != markedText_) { [markedText_ release]; } markedText_ = markedText; [markedText_ retain]; } - (void)unmarkText; { CCLOG("unmarkText"); if (nil == markedText_) { return; } const char * pszText = [markedText_ cStringUsingEncoding:NSUTF8StringEncoding]; cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); [markedText_ release]; markedText_ = nil; } #pragma mark Methods for creating ranges and positions. - (UITextRange *)textRangeFromPosition:(UITextPosition *)fromPosition toPosition:(UITextPosition *)toPosition; { CCLOG("textRangeFromPosition"); return nil; } - (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset; { CCLOG("positionFromPosition"); return nil; } - (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset; { CCLOG("positionFromPosition"); return nil; } /* Simple evaluation of positions */ - (NSComparisonResult)comparePosition:(UITextPosition *)position toPosition:(UITextPosition *)other; { CCLOG("comparePosition"); return (NSComparisonResult)0; } - (NSInteger)offsetFromPosition:(UITextPosition *)from toPosition:(UITextPosition *)toPosition; { CCLOG("offsetFromPosition"); return 0; } - (UITextPosition *)positionWithinRange:(UITextRange *)range farthestInDirection:(UITextLayoutDirection)direction; { CCLOG("positionWithinRange"); return nil; } - (UITextRange *)characterRangeByExtendingPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction; { CCLOG("characterRangeByExtendingPosition"); return nil; } #pragma mark Writing direction - (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction; { CCLOG("baseWritingDirectionForPosition"); return UITextWritingDirectionNatural; } - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection forRange:(UITextRange *)range; { CCLOG("setBaseWritingDirection"); } #pragma mark Geometry /* Geometry used to provide, for example, a correction rect. */ - (CGRect)firstRectForRange:(UITextRange *)range; { CCLOG("firstRectForRange"); return CGRectNull; } - (CGRect)caretRectForPosition:(UITextPosition *)position; { CCLOG("caretRectForPosition"); return caretRect_; } #pragma mark Hit testing /* JS - Find the closest position to a given point */ - (UITextPosition *)closestPositionToPoint:(CGPoint)point; { CCLOG("closestPositionToPoint"); return nil; } - (UITextPosition *)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange *)range; { CCLOG("closestPositionToPoint"); return nil; } - (UITextRange *)characterRangeAtPoint:(CGPoint)point; { CCLOG("characterRangeAtPoint"); return nil; } - (NSArray *)selectionRectsForRange:(UITextRange *)range { CCLOG("selectionRectsForRange"); return nil; } #pragma mark - UIKeyboard notification - (void)onUIKeyboardNotification:(NSNotification *)notif; { NSString * type = notif.name; NSDictionary* info = [notif userInfo]; CGRect begin = [self convertRect: [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:self]; CGRect end = [self convertRect: [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:self]; double aniDuration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; CGSize viewSize = self.frame.size; CGFloat tmp; switch ([[UIApplication sharedApplication] statusBarOrientation]) { case UIInterfaceOrientationPortrait: begin.origin.y = viewSize.height - begin.origin.y - begin.size.height; end.origin.y = viewSize.height - end.origin.y - end.size.height; break; case UIInterfaceOrientationPortraitUpsideDown: begin.origin.x = viewSize.width - (begin.origin.x + begin.size.width); end.origin.x = viewSize.width - (end.origin.x + end.size.width); break; case UIInterfaceOrientationLandscapeLeft: tmp = begin.size.width; begin.size.width = begin.size.height; begin.size.height = tmp; tmp = end.size.width; end.size.width = end.size.height; end.size.height = tmp; tmp = viewSize.width; viewSize.width = viewSize.height; viewSize.height = tmp; tmp = begin.origin.x; begin.origin.x = begin.origin.y; begin.origin.y = viewSize.height - tmp - begin.size.height; tmp = end.origin.x; end.origin.x = end.origin.y; end.origin.y = viewSize.height - tmp - end.size.height; break; case UIInterfaceOrientationLandscapeRight: tmp = begin.size.width; begin.size.width = begin.size.height; begin.size.height = tmp; tmp = end.size.width; end.size.width = end.size.height; end.size.height = tmp; tmp = viewSize.width; viewSize.width = viewSize.height; viewSize.height = tmp; tmp = begin.origin.x; begin.origin.x = begin.origin.y; begin.origin.y = tmp; tmp = end.origin.x; end.origin.x = end.origin.y; end.origin.y = tmp; break; default: break; } float scaleX = cocos2d::EGLView::getInstance()->getScaleX(); float scaleY = cocos2d::EGLView::getInstance()->getScaleY(); if (self.contentScaleFactor == 2.0f) { // Convert to pixel coordinate begin = CGRectApplyAffineTransform(begin, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f)); end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f)); } float offestY = cocos2d::EGLView::getInstance()->getViewPortRect().origin.y; CCLOG("offestY = %f", offestY); if (offestY < 0.0f) { begin.origin.y += offestY; begin.size.height -= offestY; end.size.height -= offestY; } // Convert to desigin coordinate begin = CGRectApplyAffineTransform(begin, CGAffineTransformScale(CGAffineTransformIdentity, 1.0f/scaleX, 1.0f/scaleY)); end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, 1.0f/scaleX, 1.0f/scaleY)); cocos2d::IMEKeyboardNotificationInfo notiInfo; notiInfo.begin = cocos2d::Rect(begin.origin.x, begin.origin.y, begin.size.width, begin.size.height); notiInfo.end = cocos2d::Rect(end.origin.x, end.origin.y, end.size.width, end.size.height); notiInfo.duration = (float)aniDuration; cocos2d::IMEDispatcher* dispatcher = cocos2d::IMEDispatcher::sharedDispatcher(); if (UIKeyboardWillShowNotification == type) { self.keyboardShowNotification = notif; // implicit copy dispatcher->dispatchKeyboardWillShow(notiInfo); } else if (UIKeyboardDidShowNotification == type) { //CGSize screenSize = self.window.screen.bounds.size; dispatcher->dispatchKeyboardDidShow(notiInfo); caretRect_ = end; caretRect_.origin.y = viewSize.height - (caretRect_.origin.y + caretRect_.size.height + [UIFont smallSystemFontSize]); caretRect_.size.height = 0; isKeyboardShown_ = YES; } else if (UIKeyboardWillHideNotification == type) { dispatcher->dispatchKeyboardWillHide(notiInfo); } else if (UIKeyboardDidHideNotification == type) { caretRect_ = CGRectZero; dispatcher->dispatchKeyboardDidHide(notiInfo); isKeyboardShown_ = NO; } } -(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)dis { [UIView beginAnimations:nil context:nullptr]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:duration]; [UIView setAnimationBeginsFromCurrentState:YES]; //NSLog(@"[animation] dis = %f, scale = %f \n", dis, cocos2d::EGLView::getInstance()->getScaleY()); if (dis < 0.0f) dis = 0.0f; dis *= cocos2d::EGLView::getInstance()->getScaleY(); if (self.contentScaleFactor == 2.0f) { dis /= 2.0f; } switch ([[UIApplication sharedApplication] statusBarOrientation]) { case UIInterfaceOrientationPortrait: self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height); break; case UIInterfaceOrientationPortraitUpsideDown: self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y + dis, originalRect_.size.width, originalRect_.size.height); break; case UIInterfaceOrientationLandscapeLeft: self.frame = CGRectMake(originalRect_.origin.x - dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); break; case UIInterfaceOrientationLandscapeRight: self.frame = CGRectMake(originalRect_.origin.x + dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); break; default: break; } [UIView commitAnimations]; } -(void) doAnimationWhenAnotherEditBeClicked { if (self.keyboardShowNotification != nil) { [[NSNotificationCenter defaultCenter]postNotification:self.keyboardShowNotification]; } } @end ================================================ FILE: cocos2d/cocos/2d/platform/ios/OpenGL_Internal.h ================================================ /* ===== IMPORTANT ===== This is sample code demonstrating API, technology or techniques in development. Although this sample code has been reviewed for technical accuracy, it is not final. Apple is supplying this information to help you plan for the adoption of the technologies and programming interfaces described herein. This information is subject to change, and software implemented based on this sample code should be tested with final operating system software and final documentation. Newer versions of this sample code may be provided with future seeds of the API or technology. For information about updates to this and other developer documentation, view the New & Updated sidebars in subsequent documentation seeds. ===================== File: OpenGL_Internal.h Abstract: This file is included for support purposes and isn't necessary for understanding this sample. Version: 1.0 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2008 Apple Inc. All Rights Reserved. */ /* Generic error reporting */ #define REPORT_ERROR(__FORMAT__, ...) printf("%s: %s\n", __FUNCTION__, [[NSString stringWithFormat:__FORMAT__, __VA_ARGS__] UTF8String]) /* EAGL and GL functions calling wrappers that log on error */ #define CALL_EAGL_FUNCTION(__FUNC__, ...) ({ EAGLError __error = __FUNC__( __VA_ARGS__ ); if(__error != kEAGLErrorSuccess) printf("%s() called from %s returned error %i\n", #__FUNC__, __FUNCTION__, __error); (__error ? NO : YES); }) //#define CHECK_GL_ERROR() ({ GLenum __error = glGetError(); if(__error) printf("OpenGL error 0x%04X in %s\n", __error, __FUNCTION__); (__error ? NO : YES); }) #define CHECK_GL_ERROR() ({ GLenum __error = glGetError(); if(__error) printf("OpenGL error 0x%04X in %s %d\n", __error, __FUNCTION__, __LINE__); }) /* Optional delegate methods support */ #ifndef __DELEGATE_IVAR__ #define __DELEGATE_IVAR__ _delegate #endif #ifndef __DELEGATE_METHODS_IVAR__ #define __DELEGATE_METHODS_IVAR__ _delegateMethods #endif #define TEST_DELEGATE_METHOD_BIT(__BIT__) (self->__DELEGATE_METHODS_IVAR__ & (1 << __BIT__)) #define SET_DELEGATE_METHOD_BIT(__BIT__, __NAME__) { if([self->__DELEGATE_IVAR__ respondsToSelector:@selector(__NAME__)]) self->__DELEGATE_METHODS_IVAR__ |= (1 << __BIT__); else self->__DELEGATE_METHODS_IVAR__ &= ~(1 << __BIT__); } ================================================ FILE: cocos2d/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.h ================================================ /**************************************************************************** Copyright (c) 2008 Otto Chrons at Seastringo Oy. Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import // when compiling to ARM (iPhone device), hide everything and use system defaults // if you wish to use simulation mode even on the device, remove the #if/#endif #if !TARGET_CPU_ARM #import // this is exactly the same as UIAcceleration, but we can modify the member variables @interface UIAccelerationSimulation: NSObject { NSTimeInterval timestamp; UIAccelerationValue x, y, z; } @property(nonatomic, readonly) NSTimeInterval timestamp; @property(nonatomic, readonly) UIAccelerationValue x, y, z; @end // override UIAccelerometer behavior @interface UIAccelerometer (Simulation) + (UIAccelerometer *)sharedAccelerometer; @end // our own version of the Accelerometer @interface CCAccelerometerSimulation : UIAccelerometer { //CFSocketRef udpSocket; int udpSocket; NSThread *thread; BOOL isExiting; id accelDelegate; UIAccelerationSimulation *accObject; // Threaded notification support NSMutableArray *notifications; NSThread *notificationThread; NSLock *notificationLock; NSMachPort *notificationPort; } @property(nonatomic, assign) id delegate; - (void) setUpThreadingSupport; - (void) handleMachMessage:(void *) msg; - (void) processNotification:(NSNotification *) notification; + (CCAccelerometerSimulation *)getAccelerometer; - (CCAccelerometerSimulation *)initialize; @end #endif ================================================ FILE: cocos2d/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.m ================================================ /**************************************************************************** Copyright (c) 2008 Otto Chrons at Seastringo Oy. Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import "AccelerometerSimulation.h" // when compiling to ARM (iPhone device), hide everything and use system defaults // if you wish to use simulation mode even on the device, remove the #if/#endif #if !TARGET_CPU_ARM #import #define kAccelerometerSimulationPort 10552 @implementation UIAccelerationSimulation @synthesize timestamp; @synthesize x; @synthesize y; @synthesize z; -(UIAccelerationSimulation*)initWithTimestamp:(NSTimeInterval)aTimeStamp X:(UIAccelerationValue)ax Y:(UIAccelerationValue)ay Z:(UIAccelerationValue)az { timestamp = aTimeStamp; x = ax; y = ay; z = az; return self; } @end @implementation UIAccelerometer (Simulation) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" // override the static method and return our simulated version instead + (UIAccelerometer *)sharedAccelerometer { return [CCAccelerometerSimulation getAccelerometer]; } #pragma clang diagnostic pop @end /* // callback that never got called with CFSocket UDP... void mySocketCallBack( CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *info) { AccelerometerSimulation *accSim = (AccelerometerSimulation*)info; NSLog(@"Data %s received", (char*)data); } */ // singleton static CCAccelerometerSimulation *sharedAccelerometer = NULL; @implementation CCAccelerometerSimulation - (void) dealloc { if (sharedAccelerometer) { [sharedAccelerometer release]; sharedAccelerometer = NULL; } [super dealloc]; } // this is straight from developer guide example for multi-threaded notifications - (void) setUpThreadingSupport { if ( notifications ) return; notifications = [[NSMutableArray alloc] init]; notificationLock = [[NSLock alloc] init]; notificationThread = [[NSThread currentThread] retain]; notificationPort = [[NSMachPort alloc] init]; [notificationPort setDelegate:self]; [[NSRunLoop currentRunLoop] addPort:notificationPort forMode:(NSString *) kCFRunLoopCommonModes]; } // this is straight from developer guide example - (void) processNotification:(NSNotification *) notification { if( [NSThread currentThread] != notificationThread ) { // Forward the notification to the correct thread, this is the socket thread NSDate* date = [[NSDate alloc] init]; [notificationLock lock]; [notifications addObject:notification]; [notificationLock unlock]; [notificationPort sendBeforeDate:date components:nil from:nil reserved:0]; [date release]; } else { // now we are in the main thread // Process the notification here; NSString *data = (NSString*)[notification object]; // parse the data, no error handling! NSArray *components = [data componentsSeparatedByString:@","]; // create our own acceleration object [accObject initWithTimestamp:[[components objectAtIndex:1] doubleValue] X:[[components objectAtIndex:2] doubleValue] Y:[[components objectAtIndex:3] doubleValue] Z:[[components objectAtIndex:4] doubleValue]]; [accelDelegate accelerometer:self didAccelerate:(UIAcceleration*)accObject]; } } // this is straight from developer guide example - (void) handleMachMessage:(void *) msg { [notificationLock lock]; while ( [notifications count] ) { NSNotification *notification = [[notifications objectAtIndex:0] retain]; [notifications removeObjectAtIndex:0]; [notificationLock unlock]; [self processNotification:notification]; [notification release]; [notificationLock lock]; }; [notificationLock unlock]; } #ifndef __clang_analyzer__ + (CCAccelerometerSimulation *)getAccelerometer { if( sharedAccelerometer == NULL ) sharedAccelerometer = [[CCAccelerometerSimulation alloc] initialize]; return sharedAccelerometer; } #endif - (void)threadLoop:(id)object { char buffer[1024]; // we never exit... while(1) { int count = recv( udpSocket, buffer, sizeof(buffer), 0 ); if( count > 0 ) { // got data, let's pass it on buffer[count] = 0; NSString *str = [[NSString alloc] initWithUTF8String:buffer]; [[NSNotificationCenter defaultCenter] postNotificationName:@"ThreadAccelNotification" object:str]; [str release]; } } } // initialize our version of the accelerometer - (CCAccelerometerSimulation *)initialize { accObject = [UIAccelerationSimulation alloc]; isExiting = false; // couldn't get the CFSocket version to work with UDP and runloop, so used Berkeley sockets and a thread instead udpSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); // listen on all interfaces sin.sin_addr.s_addr = INADDR_ANY; sin.sin_len = sizeof(struct sockaddr_in); sin.sin_family = AF_INET; sin.sin_port = htons(kAccelerometerSimulationPort); bind(udpSocket, (const struct sockaddr*)&sin, sizeof(sin)); // create a separate thread for receiving UDP packets thread = [[NSThread alloc] initWithTarget:self selector:@selector(threadLoop:) object:nil]; [thread start]; // cross-thread communication setup [self setUpThreadingSupport]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(processNotification:) name:@"ThreadAccelNotification" object:nil]; /* // create and initialize a socket CFSocketContext ctx; ctx.info = self; ctx.version = 0; ctx.retain = NULL; ctx.release = NULL; ctx.copyDescription = NULL; udpSocket = CFSocketCreate(NULL, PF_INET, SOCK_DGRAM, IPPROTO_UDP, kCFSocketDataCallBack | 0xF, mySocketCallBack, NULL); CFRunLoopSourceRef source; CFDataRef addr; CFSocketError theErr; struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); sin.sin_addr.s_addr = INADDR_ANY; sin.sin_len = sizeof(struct sockaddr_in); sin.sin_family = AF_INET; sin.sin_port = htons(10552); addr = CFDataCreate(NULL, (unsigned char *)&sin, sizeof(sin)); theErr = CFSocketConnectToAddress(udpSocket, addr, 0); switch (theErr) { case kCFSocketSuccess: NSLog(@"UDP Logged in"); source = CFSocketCreateRunLoopSource(NULL, udpSocket, 0); CFRunLoopAddSource(CFRunLoopGetMain(), source, kCFRunLoopDefaultMode); break; case kCFSocketError: NSLog(@"UDP Error"); break; default: NSLog(@"UDP Networking Error"); break; } */ return self; } // we grab the delegate setting action - (void)setDelegate:(id)delegate { accelDelegate = delegate; } - (id)delegate { return accelDelegate; } @end #endif ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCApplication.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCApplication.h" #include #include #include #include "CCDirector.h" #include "platform/CCFileUtils.h" #include "CCEGLView.h" NS_CC_BEGIN // sharedApplication pointer Application * Application::sm_pSharedApplication = 0; static long getCurrentMillSecond() { long lLastTime; struct timeval stCurrentTime; gettimeofday(&stCurrentTime,NULL); lLastTime = stCurrentTime.tv_sec*1000+stCurrentTime.tv_usec*0.001; //millseconds return lLastTime; } Application::Application() { CC_ASSERT(! sm_pSharedApplication); sm_pSharedApplication = this; } Application::~Application() { CC_ASSERT(this == sm_pSharedApplication); sm_pSharedApplication = NULL; _animationInterval = 1.0f/60.0f*1000.0f; } int Application::run() { // Initialize instance and cocos2d. if (! applicationDidFinishLaunching()) { return 0; } EGLView* pMainWnd = EGLView::getInstance(); while (!pMainWnd->windowShouldClose()) { long iLastTime = getCurrentMillSecond(); Director::getInstance()->mainLoop(); pMainWnd->pollEvents(); long iCurTime = getCurrentMillSecond(); if (iCurTime-iLastTime<_animationInterval){ usleep((_animationInterval - iCurTime+iLastTime)*1000); } } /* Only work on Desktop * Director::mainLoop is really one frame logic * when we want to close the window, we should call Director::end(); * then call Director::mainLoop to do release of internal resources */ Director::getInstance()->end(); Director::getInstance()->mainLoop(); return -1; } void Application::setAnimationInterval(double interval) { //TODO do something else _animationInterval = interval*1000.0f; } void Application::setResourceRootPath(const std::string& rootResDir) { _resourceRootPath = rootResDir; if (_resourceRootPath[_resourceRootPath.length() - 1] != '/') { _resourceRootPath += '/'; } FileUtils* pFileUtils = FileUtils::getInstance(); std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), _resourceRootPath); pFileUtils->setSearchPaths(searchPaths); } const std::string& Application::getResourceRootPath(void) { return _resourceRootPath; } Application::Platform Application::getTargetPlatform() { return Platform::OS_LINUX; } ////////////////////////////////////////////////////////////////////////// // static member function ////////////////////////////////////////////////////////////////////////// Application* Application::getInstance() { CC_ASSERT(sm_pSharedApplication); return sm_pSharedApplication; } // @deprecated Use getInstance() instead Application* Application::sharedApplication() { return Application::getInstance(); } LanguageType Application::getCurrentLanguage() { char *pLanguageName = getenv("LANG"); LanguageType ret = LanguageType::ENGLISH; if (!pLanguageName) { return LanguageType::ENGLISH; } strtok(pLanguageName, "_"); if (!pLanguageName) { return LanguageType::ENGLISH; } if (0 == strcmp("zh", pLanguageName)) { ret = LanguageType::CHINESE; } else if (0 == strcmp("en", pLanguageName)) { ret = LanguageType::ENGLISH; } else if (0 == strcmp("fr", pLanguageName)) { ret = LanguageType::FRENCH; } else if (0 == strcmp("it", pLanguageName)) { ret = LanguageType::ITALIAN; } else if (0 == strcmp("de", pLanguageName)) { ret = LanguageType::GERMAN; } else if (0 == strcmp("es", pLanguageName)) { ret = LanguageType::SPANISH; } else if (0 == strcmp("ru", pLanguageName)) { ret = LanguageType::RUSSIAN; } else if (0 == strcmp("ko", pLanguageName)) { ret = LanguageType::KOREAN; } else if (0 == strcmp("ja", pLanguageName)) { ret = LanguageType::JAPANESE; } else if (0 == strcmp("hu", pLanguageName)) { ret = LanguageType::HUNGARIAN; } else if (0 == strcmp("pt", pLanguageName)) { ret = LanguageType::PORTUGUESE; } else if (0 == strcmp("ar", pLanguageName)) { ret = LanguageType::ARABIC; } else if (0 == strcmp("nb", pLanguageName)) { ret = LanguageType::NORWEGIAN; } else if (0 == strcmp("pl", pLanguageName)) { ret = LanguageType::POLISH; } return ret; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCApplication.h ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef CCAPLICATION_H_ #define CCAPLICATION_H_ #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" #include NS_CC_BEGIN class Rect; class Application : public ApplicationProtocol { public: /** * @js ctor */ Application(); /** * @js NA * @lua NA */ virtual ~Application(); /** @brief Callback by Director for limit FPS. @param interval The time, which expressed in second in second, between current frame and next. */ void setAnimationInterval(double interval); /** @brief Run the message loop. */ int run(); /** @brief Get current applicaiton instance. @return Current application instance pointer. */ static Application* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication(); /* override functions */ virtual LanguageType getCurrentLanguage(); /** * Sets the Resource root path. * @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir); /** * Gets the Resource root path. * @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void); /** @brief Get target platform */ virtual Platform getTargetPlatform(); protected: long _animationInterval; //micro second std::string _resourceRootPath; static Application * sm_pSharedApplication; }; NS_CC_END #endif /* CCAPLICATION_H_ */ ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCCommon.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCCommon.h" #include "CCStdC.h" #include "CCConsole.h" NS_CC_BEGIN void MessageBox(const char * msg, const char * title) { log("%s: %s", title, msg); } void LuaLog(const char * format) { puts(format); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCDevice.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCDevice.h" #include #include NS_CC_BEGIN int Device::getDPI() { static int dpi = -1; if (dpi == -1) { Display *dpy; char *displayname = NULL; int scr = 0; /* Screen number */ dpy = XOpenDisplay (displayname); /* * there are 2.54 centimeters to an inch; so there are 25.4 millimeters. * * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch)) * = N pixels / (M inch / 25.4) * = N * 25.4 pixels / M inch */ double xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) / ((double) DisplayWidthMM(dpy,scr))); dpi = (int) (xres + 0.5); //printf("dpi = %d\n", dpi); XCloseDisplay (dpy); } return dpi; } void Device::setAccelerometerEnabled(bool isEnabled) { } void Device::setAccelerometerInterval(float interval) { } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCFileUtilsLinux.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCFileUtilsLinux.h" #include "platform/CCCommon.h" #include "ccMacros.h" #include "CCApplication.h" #include "CCString.h" #include #include #include #include using namespace std; NS_CC_BEGIN FileUtils* FileUtils::getInstance() { if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsLinux(); if(!s_sharedFileUtils->init()) { delete s_sharedFileUtils; s_sharedFileUtils = NULL; CCLOG("ERROR: Could not init CCFileUtilsLinux"); } } return s_sharedFileUtils; } FileUtilsLinux::FileUtilsLinux() {} bool FileUtilsLinux::init() { // get application path char fullpath[256] = {0}; ssize_t length = readlink("/proc/self/exe", fullpath, sizeof(fullpath)-1); if (length <= 0) { return false; } fullpath[length] = '\0'; std::string appPath = fullpath; _defaultResRootPath = appPath.substr(0, appPath.find_last_of("/")); _defaultResRootPath += "/Resources/"; // Set writable path to $XDG_CONFIG_HOME or ~/.config// if $XDG_CONFIG_HOME not exists. const char* xdg_config_path = getenv("XDG_CONFIG_HOME"); std::string xdgConfigPath; if (xdg_config_path == NULL) { xdgConfigPath = getenv("HOME"); xdgConfigPath += "/.config"; } else { xdgConfigPath = xdg_config_path; } _writablePath = xdgConfigPath; _writablePath += appPath.substr(appPath.find_last_of("/")); _writablePath += "/"; return FileUtils::init(); } string FileUtilsLinux::getWritablePath() const { struct stat st; stat(_writablePath.c_str(), &st); if (!S_ISDIR(st.st_mode)) { mkdir(_writablePath.c_str(), 0744); } return _writablePath; } bool FileUtilsLinux::isFileExist(const std::string& strFilePath) const { if (0 == strFilePath.length()) { return false; } std::string strPath = strFilePath; if (!isAbsolutePath(strPath)) { // Not absolute path, add the default root path at the beginning. strPath.insert(0, _defaultResRootPath); } struct stat sts; return (stat(strPath.c_str(), &sts) != -1) ? true : false; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCFileUtilsLinux.h ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_FILEUTILS_LINUX_H__ #define __CC_FILEUTILS_LINUX_H__ #include "platform/CCFileUtils.h" #include "CCPlatformMacros.h" #include "ccTypes.h" #include #include NS_CC_BEGIN /** * @addtogroup platform * @{ */ //! @brief Helper class to handle file operations class CC_DLL FileUtilsLinux : public FileUtils { friend class FileUtils; FileUtilsLinux(); std::string _writablePath; public: /* override funtions */ bool init(); virtual std::string getWritablePath() const; virtual bool isFileExist(const std::string& strFilePath) const; }; // end of platform group /// @} NS_CC_END #endif // __CC_FILEUTILS_LINUX_H__ ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCGL.h ================================================ /**************************************************************************** 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. ****************************************************************************/ #ifndef __CCGL_H__ #define __CCGL_H__ #include "GL/glew.h" #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 #endif // __CCGL_H__ ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCImage.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include #include #include #include #include #include "platform/CCFileUtils.h" #include "CCPlatformMacros.h" #define __CC_PLATFORM_IMAGE_CPP__ #include "platform/CCImageCommon_cpp.h" #include "platform/CCImage.h" #include "platform/linux/CCApplication.h" #include "ft2build.h" #include "CCStdC.h" #include FT_FREETYPE_H using namespace std; // as FcFontMatch is quite an expensive call, cache the results of getFontFile static std::map fontCache; struct LineBreakGlyph { FT_UInt glyphIndex; int paintPosition; int glyphWidth; int bearingX; int kerning; int horizAdvance; }; struct LineBreakLine { LineBreakLine() : lineWidth(0) {} std::vector glyphs; int lineWidth; void reset() { glyphs.clear(); lineWidth = 0; } void calculateWidth() { lineWidth = 0; if ( glyphs.empty() == false ) { lineWidth = glyphs.at(glyphs.size() - 1).paintPosition + glyphs.at(glyphs.size() - 1).glyphWidth; } } }; NS_CC_BEGIN class BitmapDC { public: BitmapDC() { libError = FT_Init_FreeType( &library ); FcInit(); _data = NULL; reset(); } ~BitmapDC() { FT_Done_FreeType(library); FcFini(); //data will be deleted by Image // if (_data) { // delete _data; // } reset(); } void reset() { iMaxLineWidth = 0; iMaxLineHeight = 0; textLines.clear(); } int utf8(char **p) { if ((**p & 0x80) == 0x00) { int a = *((*p)++); return a; } if ((**p & 0xE0) == 0xC0) { int a = *((*p)++) & 0x1F; int b = *((*p)++) & 0x3F; return (a << 6) | b; } if ((**p & 0xF0) == 0xE0) { int a = *((*p)++) & 0x0F; int b = *((*p)++) & 0x3F; int c = *((*p)++) & 0x3F; return (a << 12) | (b << 6) | c; } if ((**p & 0xF8) == 0xF0) { int a = *((*p)++) & 0x07; int b = *((*p)++) & 0x3F; int c = *((*p)++) & 0x3F; int d = *((*p)++) & 0x3F; return (a << 18) | (b << 12) | (c << 8) | d; } return 0; } bool isBreakPoint(FT_UInt currentCharacter, FT_UInt previousCharacter) { if ( previousCharacter == '-' || previousCharacter == '/' || previousCharacter == '\\' ) { // we can insert a line break after one of these characters return true; } return false; } bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight) { const char* pText = sText; textLines.clear(); iMaxLineWidth = 0; FT_UInt unicode; FT_UInt prevCharacter = 0; FT_UInt glyphIndex = 0; FT_UInt prevGlyphIndex = 0; FT_Vector delta; LineBreakLine currentLine; int currentPaintPosition = 0; int lastBreakIndex = -1; bool hasKerning = FT_HAS_KERNING( face ); while ((unicode=utf8((char**)&pText))) { if (unicode == '\n') { currentLine.calculateWidth(); iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth); textLines.push_back(currentLine); currentLine.reset(); prevGlyphIndex = 0; prevCharacter = 0; lastBreakIndex = -1; currentPaintPosition = 0; continue; } if ( isBreakPoint(unicode, prevCharacter) ) { lastBreakIndex = currentLine.glyphs.size() - 1; } glyphIndex = FT_Get_Char_Index(face, unicode); if (FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT)) { return false; } if (isspace(unicode)) { currentPaintPosition += face->glyph->metrics.horiAdvance >> 6; prevGlyphIndex = glyphIndex; prevCharacter = unicode; lastBreakIndex = currentLine.glyphs.size(); continue; } LineBreakGlyph glyph; glyph.glyphIndex = glyphIndex; glyph.glyphWidth = face->glyph->metrics.width >> 6; glyph.bearingX = face->glyph->metrics.horiBearingX >> 6; glyph.horizAdvance = face->glyph->metrics.horiAdvance >> 6; glyph.kerning = 0; if (prevGlyphIndex != 0 && hasKerning) { FT_Get_Kerning(face, prevGlyphIndex, glyphIndex, FT_KERNING_DEFAULT, &delta); glyph.kerning = delta.x >> 6; } if (iMaxWidth > 0 && currentPaintPosition + glyph.bearingX + glyph.kerning + glyph.glyphWidth > iMaxWidth) { int glyphCount = currentLine.glyphs.size(); if ( lastBreakIndex >= 0 && lastBreakIndex < glyphCount && currentPaintPosition + glyph.bearingX + glyph.kerning + glyph.glyphWidth - currentLine.glyphs.at(lastBreakIndex).paintPosition < iMaxWidth ) { // we insert a line break at our last break opportunity std::vector tempGlyphs; std::vector::iterator it = currentLine.glyphs.begin(); std::advance(it, lastBreakIndex); tempGlyphs.insert(tempGlyphs.begin(), it, currentLine.glyphs.end()); currentLine.glyphs.erase(it, currentLine.glyphs.end()); currentLine.calculateWidth(); iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth); textLines.push_back(currentLine); currentLine.reset(); currentPaintPosition = 0; for ( it = tempGlyphs.begin(); it != tempGlyphs.end(); it++ ) { if ( currentLine.glyphs.empty() ) { currentPaintPosition = -(*it).bearingX; (*it).kerning = 0; } (*it).paintPosition = currentPaintPosition + (*it).bearingX + (*it).kerning; currentLine.glyphs.push_back((*it)); currentPaintPosition += (*it).kerning + (*it).horizAdvance; } } else { // the current word is too big to fit into one line, insert line break right here currentPaintPosition = 0; glyph.kerning = 0; currentLine.calculateWidth(); iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth); textLines.push_back(currentLine); currentLine.reset(); } prevGlyphIndex = 0; prevCharacter = 0; lastBreakIndex = -1; } else { prevGlyphIndex = glyphIndex; prevCharacter = unicode; } if ( currentLine.glyphs.empty() ) { currentPaintPosition = -glyph.bearingX; } glyph.paintPosition = currentPaintPosition + glyph.bearingX + glyph.kerning; currentLine.glyphs.push_back(glyph); currentPaintPosition += glyph.kerning + glyph.horizAdvance; } if ( currentLine.glyphs.empty() == false ) { currentLine.calculateWidth(); iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth); textLines.push_back(currentLine); } return true; } /** * compute the start pos of every line */ int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) { int lineWidth = textLines.at(line).lineWidth; if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) { return (iMaxLineWidth - lineWidth) / 2; } else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TOP_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) { return (iMaxLineWidth - lineWidth); } // left or other situation return 0; } int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){ int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f); if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT || eAlignMask == Image::TextAlign::RIGHT) { //vertical center return (borderHeight - txtHeight) / 2 + baseLinePos; } else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT || eAlignMask == Image::TextAlign::BOTTOM || eAlignMask == Image::TextAlign::BOTTOM_LEFT) { //vertical bottom return borderHeight - txtHeight + baseLinePos; } // top alignment return baseLinePos; } std::string getFontFile(const char* family_name) { std::string fontPath = family_name; std::map::iterator it = fontCache.find(family_name); if ( it != fontCache.end() ) { return it->second; } // check if the parameter is a font file shipped with the application std::string lowerCasePath = fontPath; std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower); if ( lowerCasePath.find(".ttf") != std::string::npos ) { fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str()); FILE *f = fopen(fontPath.c_str(), "r"); if ( f ) { fclose(f); fontCache.insert(std::pair(family_name, fontPath)); return fontPath; } } // use fontconfig to match the parameter against the fonts installed on the system FcPattern *pattern = FcPatternBuild (0, FC_FAMILY, FcTypeString, family_name, (char *) 0); FcConfigSubstitute(0, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); FcResult result; FcPattern *font = FcFontMatch(0, pattern, &result); if ( font ) { FcChar8 *s = NULL; if ( FcPatternGetString(font, FC_FILE, 0, &s) == FcResultMatch ) { fontPath = (const char*)s; FcPatternDestroy(font); FcPatternDestroy(pattern); fontCache.insert(std::pair(family_name, fontPath)); return fontPath; } FcPatternDestroy(font); } FcPatternDestroy(pattern); return family_name; } bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) { if (libError) { return false; } FT_Face face; std::string fontfile = getFontFile(pFontName); if ( FT_New_Face(library, fontfile.c_str(), 0, &face) ) { //no valid font found use default if ( FT_New_Face(library, "/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 0, &face) ) { return false; } } //select utf8 charmap if ( FT_Select_Charmap(face, FT_ENCODING_UNICODE) ) { FT_Done_Face(face); return false; } if ( FT_Set_Pixel_Sizes(face, fontSize, fontSize) ) { FT_Done_Face(face); return false; } if ( divideString(face, text, nWidth, nHeight) == false ) { FT_Done_Face(face); return false; } //compute the final line width iMaxLineWidth = MAX(iMaxLineWidth, nWidth); //compute the final line height iMaxLineHeight = ceilf(FT_MulFix( face->bbox.yMax - face->bbox.yMin, face->size->metrics.y_scale )/64.0f); int lineHeight = face->size->metrics.height>>6; if ( textLines.size() > 0 ) { iMaxLineHeight += (lineHeight * (textLines.size() -1)); } int txtHeight = iMaxLineHeight; iMaxLineHeight = MAX(iMaxLineHeight, nHeight); _data = new unsigned char[iMaxLineWidth * iMaxLineHeight * 4]; memset(_data,0, iMaxLineWidth * iMaxLineHeight*4); int iCurYCursor = computeLineStartY(face, eAlignMask, txtHeight, iMaxLineHeight); int lineCount = textLines.size(); for (int line = 0; line < lineCount; line++) { int iCurXCursor = computeLineStart(face, eAlignMask, line); int glyphCount = textLines.at(line).glyphs.size(); for (int i = 0; i < glyphCount; i++) { LineBreakGlyph glyph = textLines.at(line).glyphs.at(i); if (FT_Load_Glyph(face, glyph.glyphIndex, FT_LOAD_RENDER)) { continue; } FT_Bitmap& bitmap = face->glyph->bitmap; int yoffset = iCurYCursor - (face->glyph->metrics.horiBearingY >> 6); int xoffset = iCurXCursor + glyph.paintPosition; for (int y = 0; y < bitmap.rows; ++y) { int iY = yoffset + y; if (iY>=iMaxLineHeight) { //exceed the height truncate break; } iY *= iMaxLineWidth; int bitmap_y = y * bitmap.width; for (int x = 0; x < bitmap.width; ++x) { unsigned char cTemp = bitmap.buffer[bitmap_y + x]; if (cTemp == 0) { continue; } int iX = xoffset + x; int iTemp = cTemp << 24 | cTemp << 16 | cTemp << 8 | cTemp; *(int*) &_data[(iY + iX) * 4 + 0] = iTemp; } } } // step to next line iCurYCursor += lineHeight; } // free face FT_Done_Face(face); return true; } public: FT_Library library; unsigned char *_data; int libError; std::vector textLines; int iMaxLineWidth; int iMaxLineHeight; }; static BitmapDC& sharedBitmapDC() { static BitmapDC s_BmpDC; return s_BmpDC; } bool Image::initWithString( const char * text, int width/* = 0*/, int height/* = 0*/, TextAlign alignMask/* = kAlignCenter*/, const char * fontName/* = nil*/, int size/* = 0*/) { bool ret = false; do { CC_BREAK_IF(!text || 0 == strlen(text)); BitmapDC &dc = sharedBitmapDC(); CC_BREAK_IF(! dc.getBitmap(text, width, height, alignMask, fontName, size)); // assign the dc._data to _data in order to save time _data = dc._data; CC_BREAK_IF(! _data); _width = (short)dc.iMaxLineWidth; _height = (short)dc.iMaxLineHeight; _renderFormat = Texture2D::PixelFormat::RGBA8888; _preMulti = true; _dataLen = _width * _height * 4; ret = true; dc.reset(); }while (0); //do nothing return ret; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCPlatformDefine.h ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ #include #if defined(_USRDLL) #define CC_DLL __attribute__ ((visibility ("default"))) #else /* use a DLL library */ #define CC_DLL __attribute__ ((visibility ("default"))) #endif #include #define CC_ASSERT(cond) assert(cond) #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam /* Define NULL pointer value */ #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif #endif /* __CCPLATFORMDEFINE_H__*/ ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCStdC.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCStdC.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) int CC_DLL gettimeofday(struct timeval * val, struct timezone *) { if (val) { SYSTEMTIME wtm; GetLocalTime(&wtm); struct tm tTm; tTm.tm_year = wtm.wYear - 1900; tTm.tm_mon = wtm.wMonth - 1; tTm.tm_mday = wtm.wDay; tTm.tm_hour = wtm.wHour; tTm.tm_min = wtm.wMinute; tTm.tm_sec = wtm.wSecond; tTm.tm_isdst = -1; val->tv_sec = (long)mktime(&tTm); // time_t is 64-bit on win32 val->tv_usec = wtm.wMilliseconds * 1000; } return 0; } #elif (CC_TARGET_PLATFORM == CC_PLATFORM_BADA) using namespace Osp::System; int CC_DLL gettimeofday(struct timeval * val, struct timezone *) { if (val) { long long curTick = 0; SystemTime::GetTicks(curTick); unsigned int ms = curTick; val->tv_sec = ms / 1000; val->tv_usec = (ms % 1000) * 1000; } return 0; } #endif // CC_PLATFORM_WIN32 ================================================ FILE: cocos2d/cocos/2d/platform/linux/CCStdC.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_STD_C_H__ #define __CC_STD_C_H__ #include "CCPlatformMacros.h" #include #include #include #include #include #include #include #include #include #ifndef MIN #define MIN(x,y) (((x) > (y)) ? (y) : (x)) #endif // MIN #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX // some function linux do not have #define tanf tan #define sqrtf sqrt #define cosf cos #define sinf sin #endif // __CC_STD_C_H__ ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCApplication.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_APPLICATION_MAC_H__ #define __CC_APPLICATION_MAC_H__ #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" #include NS_CC_BEGIN class CC_DLL Application : public ApplicationProtocol { public: /** * @js ctor */ Application(); /** * @js NA * @lua NA */ virtual ~Application(); /** @brief Callback by Director for limit FPS. @param interval The time, which expressed in second in second, between current frame and next. */ virtual void setAnimationInterval(double interval); /** @brief Get status bar rectangle in EGLView window. */ /** @brief Run the message loop. * @js NA * @lua NA */ int run(); /** @brief Get current applicaiton instance. @return Current application instance pointer. */ static Application* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication(); /** @brief Get current language config @return Current language config */ virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ virtual Platform getTargetPlatform(); /** * Sets the Resource root path. * @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir); /** * Gets the Resource root path. * @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void); void setStartupScriptFilename(const std::string& startupScriptFile); const std::string& getStartupScriptFilename(void); protected: static Application * sm_pSharedApplication; std::string _resourceRootPath; std::string _startupScriptFilename; }; NS_CC_END #endif // end of __CC_APPLICATION_MAC_H__; ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCApplication.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import "CCApplication.h" #import #include #include "platform/CCFileUtils.h" #include "CCGeometry.h" #include "CCDirector.h" #import "CCDirectorCaller.h" #include "CCEGLView.h" NS_CC_BEGIN Application* Application::sm_pSharedApplication = 0; Application::Application() { CCASSERT(! sm_pSharedApplication, "sm_pSharedApplication already exist"); sm_pSharedApplication = this; } Application::~Application() { CCASSERT(this == sm_pSharedApplication, "sm_pSharedApplication != this"); sm_pSharedApplication = 0; } int Application::run() { if(!applicationDidFinishLaunching()) { return 0; } EGLView* pMainWnd = EGLView::getInstance(); while (!pMainWnd->windowShouldClose()) { Director::getInstance()->mainLoop(); pMainWnd->pollEvents(); } /* Only work on Desktop * Director::mainLoop is really one frame logic * when we want to close the window, we should call Director::end(); * then call Director::mainLoop to do release of internal resources */ Director::getInstance()->end(); Director::getInstance()->mainLoop(); return true; } void Application::setAnimationInterval(double interval) { [[CCDirectorCaller sharedDirectorCaller] setAnimationInterval: interval ]; } Application::Platform Application::getTargetPlatform() { return Platform::OS_MAC; } ///////////////////////////////////////////////////////////////////////////////////////////////// // static member function ////////////////////////////////////////////////////////////////////////////////////////////////// Application* Application::getInstance() { CCASSERT(sm_pSharedApplication, "sm_pSharedApplication not set"); return sm_pSharedApplication; } // @deprecated Use getInstance() instead Application* Application::sharedApplication() { return Application::getInstance(); } LanguageType Application::getCurrentLanguage() { // get the current language and country config NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSArray *languages = [defaults objectForKey:@"AppleLanguages"]; NSString *currentLanguage = [languages objectAtIndex:0]; // get the current language code.(such as English is "en", Chinese is "zh" and so on) NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage]; NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode]; LanguageType ret = LanguageType::ENGLISH; if ([languageCode isEqualToString:@"zh"]) { ret = LanguageType::CHINESE; } else if ([languageCode isEqualToString:@"en"]) { ret = LanguageType::ENGLISH; } else if ([languageCode isEqualToString:@"fr"]){ ret = LanguageType::FRENCH; } else if ([languageCode isEqualToString:@"it"]){ ret = LanguageType::ITALIAN; } else if ([languageCode isEqualToString:@"de"]){ ret = LanguageType::GERMAN; } else if ([languageCode isEqualToString:@"es"]){ ret = LanguageType::SPANISH; } else if ([languageCode isEqualToString:@"ru"]){ ret = LanguageType::RUSSIAN; } else if ([languageCode isEqualToString:@"ko"]){ ret = LanguageType::KOREAN; } else if ([languageCode isEqualToString:@"ja"]){ ret = LanguageType::JAPANESE; } else if ([languageCode isEqualToString:@"hu"]){ ret = LanguageType::HUNGARIAN; } else if ([languageCode isEqualToString:@"pt"]) { ret = LanguageType::PORTUGUESE; } else if ([languageCode isEqualToString:@"ar"]) { ret = LanguageType::ARABIC; } else if ([languageCode isEqualToString:@"nb"]){ ret = LanguageType::NORWEGIAN; } else if ([languageCode isEqualToString:@"pl"]){ ret = LanguageType::POLISH; } return ret; } void Application::setResourceRootPath(const std::string& rootResDir) { _resourceRootPath = rootResDir; if (_resourceRootPath[_resourceRootPath.length() - 1] != '/') { _resourceRootPath += '/'; } FileUtils* pFileUtils = FileUtils::getInstance(); std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), _resourceRootPath); pFileUtils->setSearchPaths(searchPaths); } const std::string& Application::getResourceRootPath(void) { return _resourceRootPath; } void Application::setStartupScriptFilename(const std::string& startupScriptFile) { _startupScriptFilename = startupScriptFile; std::replace(_startupScriptFilename.begin(), _startupScriptFilename.end(), '\\', '/'); } const std::string& Application::getStartupScriptFilename(void) { return _startupScriptFilename; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCCommon.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCCommon.h" #include "CCEGLView.h" #define GLFW_EXPOSE_NATIVE_NSGL #define GLFW_EXPOSE_NATIVE_COCOA #include "glfw3native.h" #include #include #include NS_CC_BEGIN void LuaLog(const char * format) { puts(format); } // ios no MessageBox, use log instead void MessageBox(const char * msg, const char * title) { NSString * tmpTitle = (title) ? [NSString stringWithUTF8String : title] : nil; NSString * tmpMsg = (msg) ? [NSString stringWithUTF8String : msg] : nil; NSAlert *alert = [[[NSAlert alloc] init] autorelease]; [alert addButtonWithTitle:@"OK"]; [alert setMessageText:tmpMsg]; [alert setInformativeText:tmpTitle]; [alert setAlertStyle:NSWarningAlertStyle]; id window = glfwGetCocoaWindow(EGLView::getInstance()->getWindow()); [alert beginSheetModalForWindow:window modalDelegate:[window delegate] didEndSelector:nil contextInfo:nil]; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCDevice.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCDevice.h" NS_CC_BEGIN int Device::getDPI() { //TODO: return 160; } void Device::setAccelerometerEnabled(bool isEnabled) { } void Device::setAccelerometerInterval(float interval) { } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCDirectorCaller.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import #import @interface CCDirectorCaller : NSObject { CVDisplayLinkRef displayLink; NSTimer *renderTimer; int interval; } @property (readwrite) int interval; -(void) startMainLoop; -(void) end; -(void) doCaller: (id) sender; -(void) setAnimationInterval:(double)interval; +(id) sharedDirectorCaller; @end ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCDirectorCaller.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import "CCDirectorCaller.h" #include "CCDirector.h" #include "CCAutoreleasePool.h" #import #import static id s_sharedDirectorCaller; @interface NSObject(CADisplayLink) +(id) displayLinkWithTarget: (id)arg1 selector:(SEL)arg2; -(void) addToRunLoop: (id)arg1 forMode: (id)arg2; -(void) setFrameInterval: (int)interval; -(void) invalidate; @end @implementation CCDirectorCaller @synthesize interval; +(id) sharedDirectorCaller { if (s_sharedDirectorCaller == nil) { s_sharedDirectorCaller = [[CCDirectorCaller alloc] init]; } return s_sharedDirectorCaller; } -(void) alloc { interval = 1; } -(void) dealloc { s_sharedDirectorCaller = nil; CCLOGINFO("deallocing DirectorCaller: %p", self); if (displayLink) { CVDisplayLinkRelease(displayLink); } CCLOG("--------------------------------------------------------------------------------"); CCLOG(""); CCLOG(""); CCLOG(""); [super dealloc]; } - (CVReturn) getFrameForTime:(const CVTimeStamp*)outputTime { #if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD //if( ! runningThread_ ) //runningThread_ = [NSThread currentThread]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; cocos2d::Director::getInstance()->drawScene(); cocos2d::PoolManager::getInstance()->getCurrentPool()->clear(); [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:nil]; // release the objects [pool release]; #else [self performSelector:@selector(drawScene) onThread:[NSThread currentThread] withObject:nil waitUntilDone:YES]; #endif return kCVReturnSuccess; } // This is the renderer output callback function static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext) { // CVReturn result = [(DirectorCaller*)displayLinkContext getFrameForTime:outputTime]; // return result; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; cocos2d::Director::getInstance()->mainLoop(); [pool release]; return kCVReturnSuccess; } - (void)timerFired:(id)sender { // It is good practice in a Cocoa application to allow the system to send the -drawRect: // message when it needs to draw, and not to invoke it directly from the timer. // All we do here is tell the display it needs a refresh NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // run the main cocos2d loop cocos2d::Director::getInstance()->mainLoop(); [pool release]; } -(void) startMainLoop { // Director::setAnimationInterval() is called, we should invalide it first // [displayLink invalidate]; // displayLink = nil; // // displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)]; // [displayLink setFrameInterval: self.interval]; // [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; #if ! CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD NSThread* thread = [[NSThread alloc] initWithTarget:self selector:@selector(mainLoop) object:nil]; [thread start]; #endif // NSTimer [renderTimer invalidate]; renderTimer = nil; renderTimer = [NSTimer timerWithTimeInterval:self.interval/60.0f //a 1ms time interval target:self selector:@selector(timerFired:) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:renderTimer forMode:NSDefaultRunLoopMode]; [[NSRunLoop currentRunLoop] addTimer:renderTimer forMode:NSEventTrackingRunLoopMode]; //Ensure timer fires during resize /* // CVDisplayLink //cocos2d::Director::getInstance()->gettimeofday(); // Create a display link capable of being used with all active displays CVDisplayLinkCreateWithActiveCGDisplays(&displayLink); // Set the renderer output callback function CVDisplayLinkSetOutputCallback(displayLink, &MyDisplayLinkCallback, self); // Set the display link for the current renderer CCEAGLView *openGLView_ = (CCEAGLView*)[CCEAGLView sharedEGLView]; CGLContextObj cglContext = (CGLContextObj)[[openGLView_ openGLContext] CGLContextObj]; CGLPixelFormatObj cglPixelFormat = (CGLPixelFormatObj)[[openGLView_ pixelFormat] CGLPixelFormatObj]; CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, cglContext, cglPixelFormat); // Activate the display link CVDisplayLinkStart(displayLink); */ } -(void) end { [renderTimer invalidate]; renderTimer = nil; [self release]; } -(void) setAnimationInterval:(double)intervalNew { self.interval = 60.0 * intervalNew; [renderTimer invalidate]; renderTimer = nil; renderTimer = [NSTimer timerWithTimeInterval:self.interval/60.0f //a 1ms time interval target:self selector:@selector(timerFired:) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:renderTimer forMode:NSDefaultRunLoopMode]; [[NSRunLoop currentRunLoop] addTimer:renderTimer forMode:NSEventTrackingRunLoopMode]; } -(void) doCaller: (id) sender { cocos2d::Director::getInstance()->mainLoop(); } @end ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCGL.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __PLATFORM_MAC_CCGL_H__ #define __PLATFORM_MAC_CCGL_H__ #import #import #import #define CC_GL_DEPTH24_STENCIL8 -1 #define glDeleteVertexArrays glDeleteVertexArraysAPPLE #define glGenVertexArrays glGenVertexArraysAPPLE #define glBindVertexArray glBindVertexArrayAPPLE #define glClearDepthf glClearDepth #define glDepthRangef glDepthRange #define glReleaseShaderCompiler(xxx) #endif // __PLATFORM_MAC_CCGL_H__ ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCImage.mm ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCImageCommon_cpp.h" #include #include #include "CCDirector.h" #include "ccMacros.h" #include "CCImage.h" #include "CCFileUtils.h" #include "CCTexture2D.h" #include #include #include #include NS_CC_BEGIN typedef struct { int height; int width; bool hasAlpha; bool isPremultipliedAlpha; unsigned char* data; } tImageInfo; static bool _initWithString(const char * text, cocos2d::Image::TextAlign align, const char * fontName, int size, tImageInfo* info, cocos2d::Color3B* strokeColor) { bool ret = false; CCASSERT(text, "Invalid pText"); CCASSERT(info, "Invalid pInfo"); do { NSString * string = [NSString stringWithUTF8String:text]; // font NSFont *font = [[NSFontManager sharedFontManager] fontWithFamily:[NSString stringWithUTF8String:fontName] traits:NSUnboldFontMask | NSUnitalicFontMask weight:0 size:size]; if (font == nil) { font = [[NSFontManager sharedFontManager] fontWithFamily:@"Arial" traits:NSUnboldFontMask | NSUnitalicFontMask weight:0 size:size]; } CC_BREAK_IF(!font); // color NSColor* foregroundColor; if (strokeColor) { foregroundColor = [NSColor colorWithDeviceRed:strokeColor->r/255.0 green:strokeColor->g/255.0 blue:strokeColor->b/255.0 alpha:1]; } else { foregroundColor = [NSColor whiteColor]; } // alignment, linebreak unsigned horiFlag = (int)align & 0x0f; unsigned vertFlag = ((int)align >> 4) & 0x0f; NSTextAlignment textAlign = (2 == horiFlag) ? NSRightTextAlignment : (3 == horiFlag) ? NSCenterTextAlignment : NSLeftTextAlignment; NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease]; [paragraphStyle setParagraphStyle:[NSParagraphStyle defaultParagraphStyle]]; [paragraphStyle setLineBreakMode:NSLineBreakByCharWrapping]; [paragraphStyle setAlignment:textAlign]; // attribute NSDictionary* tokenAttributesDict = [NSDictionary dictionaryWithObjectsAndKeys: foregroundColor,NSForegroundColorAttributeName, font, NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil]; // linebreak if (info->width > 0) { if ([string sizeWithAttributes:tokenAttributesDict].width > info->width) { NSMutableString *lineBreak = [[[NSMutableString alloc] init] autorelease]; NSUInteger length = [string length]; NSRange range = NSMakeRange(0, 1); NSUInteger width = 0; NSUInteger lastBreakLocation = 0; for (NSUInteger i = 0; i < length; i++) { range.location = i; NSString *character = [string substringWithRange:range]; [lineBreak appendString:character]; if ([@"!?.,-= " rangeOfString:character].location != NSNotFound) { lastBreakLocation = i; } width = [lineBreak sizeWithAttributes:tokenAttributesDict].width; if (width > info->width) { [lineBreak insertString:@"\r\n" atIndex:(lastBreakLocation > 0) ? lastBreakLocation : [lineBreak length] - 1]; } } string = lineBreak; } } NSAttributedString *stringWithAttributes =[[[NSAttributedString alloc] initWithString:string attributes:tokenAttributesDict] autorelease]; NSSize realDimensions = [stringWithAttributes size]; // Mac crashes if the width or height is 0 CC_BREAK_IF(realDimensions.width <= 0 || realDimensions.height <= 0); CGSize dimensions = CGSizeMake(info->width, info->height); if(dimensions.width <= 0 && dimensions.height <= 0) { dimensions.width = realDimensions.width; dimensions.height = realDimensions.height; } else if (dimensions.height <= 0) { dimensions.height = realDimensions.height; } NSInteger POTWide = dimensions.width; NSInteger POTHigh = MAX(dimensions.height, realDimensions.height); unsigned char* data; //Alignment CGFloat xPadding = 0; switch (textAlign) { case NSLeftTextAlignment: xPadding = 0; break; case NSCenterTextAlignment: xPadding = (dimensions.width-realDimensions.width)/2.0f; break; case NSRightTextAlignment: xPadding = dimensions.width-realDimensions.width; break; default: break; } // 1: TOP // 2: BOTTOM // 3: CENTER CGFloat yPadding = (1 == vertFlag || realDimensions.height >= dimensions.height) ? (dimensions.height - realDimensions.height) // align to top : (2 == vertFlag) ? 0 // align to bottom : (dimensions.height - realDimensions.height) / 2.0f; // align to center NSRect textRect = NSMakeRect(xPadding, POTHigh - dimensions.height + yPadding, realDimensions.width, realDimensions.height); //Disable antialias [[NSGraphicsContext currentContext] setShouldAntialias:NO]; NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(POTWide, POTHigh)]; [image lockFocus]; // patch for mac retina display and lableTTF [[NSAffineTransform transform] set]; //[stringWithAttributes drawAtPoint:NSMakePoint(xPadding, offsetY)]; // draw at offset position [stringWithAttributes drawInRect:textRect]; //[stringWithAttributes drawInRect:textRect withAttributes:tokenAttributesDict]; NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect (0.0f, 0.0f, POTWide, POTHigh)]; [image unlockFocus]; data = (unsigned char*) [bitmap bitmapData]; //Use the same buffer to improve the performance. NSUInteger textureSize = POTWide*POTHigh*4; unsigned char* dataNew = new unsigned char[textureSize]; if (dataNew) { memcpy(dataNew, data, textureSize); // output params info->width = static_cast(POTWide); info->height = static_cast(POTHigh); info->data = dataNew; info->hasAlpha = true; info->isPremultipliedAlpha = true; ret = true; } [bitmap release]; [image release]; } while (0); return ret; } bool Image::initWithString( const char * text, int width, int height, TextAlign alignMask, const char * fontName, int size) { tImageInfo info = {0}; info.width = width; info.height = height; if (! _initWithString(text, alignMask, fontName, size, &info, nullptr)) //pStrokeColor)) { return false; } _height = (short)info.height; _width = (short)info.width; _renderFormat = Texture2D::PixelFormat::RGBA8888; _preMulti = info.isPremultipliedAlpha; if (_data) { CC_SAFE_DELETE_ARRAY(_data); } _data = info.data; _dataLen = _width * _height * 4; return true; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCPlatformDefine.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ #include #define CC_DLL #if CC_DISABLE_ASSERT > 0 #define CC_ASSERT(cond) #else #define CC_ASSERT(cond) assert(cond) #endif #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam /* Define NULL pointer value */ #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif #endif /* __CCPLATFORMDEFINE_H__*/ ================================================ FILE: cocos2d/cocos/2d/platform/mac/CCStdC.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_STD_C_H__ #define __CC_STD_C_H__ #include "CCPlatformMacros.h" #include #include #include #include #include #include #include #include #include #ifndef MIN #define MIN(x,y) (((x) > (y)) ? (y) : (x)) #endif // MIN #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX #endif // __CC_STD_C_H__ ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCApplication.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCApplication.h" #include "CCEGLView.h" #include "CCDirector.h" #include #include "platform/CCFileUtils.h" /** @brief This function change the PVRFrame show/hide setting in register. @param bEnable If true show the PVRFrame window, otherwise hide. */ static void PVRFrameEnableControlWindow(bool bEnable); NS_CC_BEGIN // sharedApplication pointer Application * Application::sm_pSharedApplication = 0; Application::Application() : _instance(NULL) , _accelTable(NULL) { _instance = GetModuleHandle(NULL); _animationInterval.QuadPart = 0; CC_ASSERT(! sm_pSharedApplication); sm_pSharedApplication = this; } Application::~Application() { CC_ASSERT(this == sm_pSharedApplication); sm_pSharedApplication = NULL; } int Application::run() { PVRFrameEnableControlWindow(false); // Main message loop: LARGE_INTEGER nFreq; LARGE_INTEGER nLast; LARGE_INTEGER nNow; QueryPerformanceFrequency(&nFreq); QueryPerformanceCounter(&nLast); // Initialize instance and cocos2d. if (!applicationDidFinishLaunching()) { return 0; } EGLView* pMainWnd = EGLView::getInstance(); while(!pMainWnd->windowShouldClose()) { QueryPerformanceCounter(&nNow); if (nNow.QuadPart - nLast.QuadPart > _animationInterval.QuadPart) { nLast.QuadPart = nNow.QuadPart; Director::getInstance()->mainLoop(); pMainWnd->pollEvents(); } else { Sleep(0); } } /* Only work on Desktop * Director::mainLoop is really one frame logic * when we want to close the window, we should call Director::end(); * then call Director::mainLoop to do release of internal resources */ Director::getInstance()->end(); Director::getInstance()->mainLoop(); return true; } void Application::setAnimationInterval(double interval) { LARGE_INTEGER nFreq; QueryPerformanceFrequency(&nFreq); _animationInterval.QuadPart = (LONGLONG)(interval * nFreq.QuadPart); } ////////////////////////////////////////////////////////////////////////// // static member function ////////////////////////////////////////////////////////////////////////// Application* Application::getInstance() { CC_ASSERT(sm_pSharedApplication); return sm_pSharedApplication; } // @deprecated Use getInstance() instead Application* Application::sharedApplication() { return Application::getInstance(); } LanguageType Application::getCurrentLanguage() { LanguageType ret = LanguageType::ENGLISH; LCID localeID = GetUserDefaultLCID(); unsigned short primaryLanguageID = localeID & 0xFF; switch (primaryLanguageID) { case LANG_CHINESE: ret = LanguageType::CHINESE; break; case LANG_ENGLISH: ret = LanguageType::ENGLISH; break; case LANG_FRENCH: ret = LanguageType::FRENCH; break; case LANG_ITALIAN: ret = LanguageType::ITALIAN; break; case LANG_GERMAN: ret = LanguageType::GERMAN; break; case LANG_SPANISH: ret = LanguageType::SPANISH; break; case LANG_RUSSIAN: ret = LanguageType::RUSSIAN; break; case LANG_KOREAN: ret = LanguageType::KOREAN; break; case LANG_JAPANESE: ret = LanguageType::JAPANESE; break; case LANG_HUNGARIAN: ret = LanguageType::HUNGARIAN; break; case LANG_PORTUGUESE: ret = LanguageType::PORTUGUESE; break; case LANG_ARABIC: ret = LanguageType::ARABIC; break; case LANG_NORWEGIAN: ret = LanguageType::NORWEGIAN; break; case LANG_POLISH: ret = LanguageType::POLISH; break; } return ret; } Application::Platform Application::getTargetPlatform() { return Platform::OS_WINDOWS; } void Application::setResourceRootPath(const std::string& rootResDir) { _resourceRootPath = rootResDir; std::replace(_resourceRootPath.begin(), _resourceRootPath.end(), '\\', '/'); if (_resourceRootPath[_resourceRootPath.length() - 1] != '/') { _resourceRootPath += '/'; } FileUtils* pFileUtils = FileUtils::getInstance(); std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), _resourceRootPath); pFileUtils->setSearchPaths(searchPaths); } const std::string& Application::getResourceRootPath(void) { return _resourceRootPath; } void Application::setStartupScriptFilename(const std::string& startupScriptFile) { _startupScriptFilename = startupScriptFile; std::replace(_startupScriptFilename.begin(), _startupScriptFilename.end(), '\\', '/'); } NS_CC_END ////////////////////////////////////////////////////////////////////////// // Local function ////////////////////////////////////////////////////////////////////////// static void PVRFrameEnableControlWindow(bool bEnable) { HKEY hKey = 0; // Open PVRFrame control key, if not exist create it. if(ERROR_SUCCESS != RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Imagination Technologies\\PVRVFRame\\STARTUP\\", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, NULL)) { return; } const WCHAR* wszValue = L"hide_gui"; const WCHAR* wszNewData = (bEnable) ? L"NO" : L"YES"; WCHAR wszOldData[256] = {0}; DWORD dwSize = sizeof(wszOldData); LSTATUS status = RegQueryValueExW(hKey, wszValue, 0, NULL, (LPBYTE)wszOldData, &dwSize); if (ERROR_FILE_NOT_FOUND == status // the key not exist || (ERROR_SUCCESS == status // or the hide_gui value is exist && 0 != wcscmp(wszNewData, wszOldData))) // but new data and old data not equal { dwSize = sizeof(WCHAR) * (wcslen(wszNewData) + 1); RegSetValueEx(hKey, wszValue, 0, REG_SZ, (const BYTE *)wszNewData, dwSize); } RegCloseKey(hKey); } ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCApplication.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_APPLICATION_WIN32_H__ #define __CC_APPLICATION_WIN32_H__ #include "CCStdC.h" #include "platform/CCCommon.h" #include "platform/CCApplicationProtocol.h" #include NS_CC_BEGIN class Rect; class CC_DLL Application : public ApplicationProtocol { public: /** * @js ctor */ Application(); /** * @js NA * @lua NA */ virtual ~Application(); /** @brief Run the message loop. */ int run(); /** @brief Get current applicaiton instance. @return Current application instance pointer. */ static Application* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication(); /* override functions */ virtual void setAnimationInterval(double interval); virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ virtual Platform getTargetPlatform(); /** * Sets the Resource root path. * @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir); /** * Gets the Resource root path. * @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void); void setStartupScriptFilename(const std::string& startupScriptFile); const std::string& getStartupScriptFilename(void) { return _startupScriptFilename; } protected: HINSTANCE _instance; HACCEL _accelTable; LARGE_INTEGER _animationInterval; std::string _resourceRootPath; std::string _startupScriptFilename; static Application * sm_pSharedApplication; }; NS_CC_END #endif // __CC_APPLICATION_WIN32_H__ ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCCommon.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCCommon.h" #include "CCStdC.h" NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) void MessageBox(const char * pszMsg, const char * pszTitle) { MessageBoxA(NULL, pszMsg, pszTitle, MB_OK); } void LuaLog(const char *pszMsg) { int bufflen = MultiByteToWideChar(CP_UTF8, 0, pszMsg, -1, NULL, 0); WCHAR* widebuff = new WCHAR[bufflen + 1]; memset(widebuff, 0, sizeof(WCHAR) * (bufflen + 1)); MultiByteToWideChar(CP_UTF8, 0, pszMsg, -1, widebuff, bufflen); OutputDebugStringW(widebuff); OutputDebugStringA("\n"); bufflen = WideCharToMultiByte(CP_ACP, 0, widebuff, -1, NULL, 0, NULL, NULL); char* buff = new char[bufflen + 1]; memset(buff, 0, sizeof(char) * (bufflen + 1)); WideCharToMultiByte(CP_ACP, 0, widebuff, -1, buff, bufflen, NULL, NULL); puts(buff); delete[] widebuff; delete[] buff; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCDevice.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCDevice.h" #include "CCStdC.h" NS_CC_BEGIN int Device::getDPI() { static int dpi = -1; if (dpi == -1) { HDC hScreenDC = GetDC( NULL ); int PixelsX = GetDeviceCaps( hScreenDC, HORZRES ); int MMX = GetDeviceCaps( hScreenDC, HORZSIZE ); ReleaseDC( NULL, hScreenDC ); dpi = 254.0f*PixelsX/MMX/10; } return dpi; } void Device::setAccelerometerEnabled(bool isEnabled) {} void Device::setAccelerometerInterval(float interval) {} NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCFileUtilsWin32.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCFileUtilsWin32.h" #include "platform/CCCommon.h" #include using namespace std; NS_CC_BEGIN #define CC_MAX_PATH 512 // The root path of resources, the character encoding is UTF-8. // UTF-8 is the only encoding supported by cocos2d-x API. static std::string s_resourcePath = ""; // D:\aaa\bbb\ccc\ddd\abc.txt --> D:/aaa/bbb/ccc/ddd/abc.txt static inline std::string convertPathFormatToUnixStyle(const std::string& path) { std::string ret = path; int len = ret.length(); for (int i = 0; i < len; ++i) { if (ret[i] == '\\') { ret[i] = '/'; } } return ret; } static void _checkPath() { if (0 == s_resourcePath.length()) { WCHAR utf16Path[CC_MAX_PATH] = {0}; GetCurrentDirectoryW(sizeof(utf16Path)-1, utf16Path); char utf8Path[CC_MAX_PATH] = {0}; int nNum = WideCharToMultiByte(CP_UTF8, 0, utf16Path, -1, utf8Path, sizeof(utf8Path), NULL, NULL); s_resourcePath = convertPathFormatToUnixStyle(utf8Path); s_resourcePath.append("/"); } } FileUtils* FileUtils::getInstance() { if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsWin32(); if(!s_sharedFileUtils->init()) { delete s_sharedFileUtils; s_sharedFileUtils = NULL; CCLOG("ERROR: Could not init CCFileUtilsWin32"); } } return s_sharedFileUtils; } FileUtilsWin32::FileUtilsWin32() { } bool FileUtilsWin32::init() { _checkPath(); _defaultResRootPath = s_resourcePath; return FileUtils::init(); } bool FileUtilsWin32::isFileExist(const std::string& strFilePath) const { if (0 == strFilePath.length()) { return false; } std::string strPath = strFilePath; if (!isAbsolutePath(strPath)) { // Not absolute path, add the default root path at the beginning. strPath.insert(0, _defaultResRootPath); } WCHAR utf16Buf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, utf16Buf, sizeof(utf16Buf)); return GetFileAttributesW(utf16Buf) != -1 ? true : false; } bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const { if ( strPath.length() > 2 && ( (strPath[0] >= 'a' && strPath[0] <= 'z') || (strPath[0] >= 'A' && strPath[0] <= 'Z') ) && strPath[1] == ':') { return true; } return false; } static Data getData(const std::string& filename, bool forString) { unsigned char *buffer = nullptr; CCASSERT(!filename.empty(), "Invalid parameters."); size_t size = 0; do { // read the file from hardware std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename); WCHAR wszBuf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)); HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL); CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE); size = ::GetFileSize(fileHandle, NULL); if (forString) { buffer = (unsigned char*) malloc(size + 1); buffer[size] = '\0'; } else { buffer = (unsigned char*) malloc(size); } DWORD sizeRead = 0; BOOL successed = FALSE; successed = ::ReadFile(fileHandle, buffer, size, &sizeRead, NULL); ::CloseHandle(fileHandle); if (!successed) { free(buffer); buffer = nullptr; } } while (0); Data ret; if (buffer == nullptr || size == 0) { std::string msg = "Get data from file("; // Gets error code. DWORD errorCode = ::GetLastError(); char errorCodeBuffer[20] = {0}; snprintf(errorCodeBuffer, sizeof(errorCodeBuffer), "%d", errorCode); msg = msg + filename + ") failed, error code is " + errorCodeBuffer; CCLOG("%s", msg.c_str()); } else { ret.fastSet(buffer, size); } return ret; } std::string FileUtilsWin32::getStringFromFile(const std::string& filename) { Data data = getData(filename, true); std::string ret((const char*)data.getBytes()); return ret; } Data FileUtilsWin32::getDataFromFile(const std::string& filename) { return getData(filename, false); } unsigned char* FileUtilsWin32::getFileData(const std::string& filename, const char* mode, ssize_t* size) { unsigned char * pBuffer = NULL; *size = 0; do { // read the file from hardware std::string fullPath = fullPathForFilename(filename); WCHAR wszBuf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)); HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL); CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE); *size = ::GetFileSize(fileHandle, NULL); pBuffer = (unsigned char*) malloc(*size); DWORD sizeRead = 0; BOOL successed = FALSE; successed = ::ReadFile(fileHandle, pBuffer, *size, &sizeRead, NULL); ::CloseHandle(fileHandle); if (!successed) { free(pBuffer); pBuffer = nullptr; } } while (0); if (! pBuffer) { std::string msg = "Get data from file("; // Gets error code. DWORD errorCode = ::GetLastError(); char errorCodeBuffer[20] = {0}; snprintf(errorCodeBuffer, sizeof(errorCodeBuffer), "%d", errorCode); msg = msg + filename + ") failed, error code is " + errorCodeBuffer; CCLOG("%s", msg.c_str()); } return pBuffer; } std::string FileUtilsWin32::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) { std::string unixFileName = convertPathFormatToUnixStyle(filename); std::string unixResolutionDirectory = convertPathFormatToUnixStyle(resolutionDirectory); std::string unixSearchPath = convertPathFormatToUnixStyle(searchPath); return FileUtils::getPathForFilename(unixFileName, unixResolutionDirectory, unixSearchPath); } std::string FileUtilsWin32::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) { std::string unixDirectory = convertPathFormatToUnixStyle(strDirectory); std::string unixFilename = convertPathFormatToUnixStyle(strFilename); return FileUtils::getFullPathForDirectoryAndFilename(unixDirectory, unixFilename); } string FileUtilsWin32::getWritablePath() const { // Get full path of executable, e.g. c:\Program Files (x86)\My Game Folder\MyGame.exe char full_path[CC_MAX_PATH + 1]; ::GetModuleFileNameA(NULL, full_path, CC_MAX_PATH + 1); // Debug app uses executable directory; Non-debug app uses local app data directory #ifndef _DEBUG // Get filename of executable only, e.g. MyGame.exe char *base_name = strrchr(full_path, '\\'); if(base_name) { char app_data_path[CC_MAX_PATH + 1]; // Get local app data directory, e.g. C:\Documents and Settings\username\Local Settings\Application Data if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, app_data_path))) { string ret((char*)app_data_path); // Adding executable filename, e.g. C:\Documents and Settings\username\Local Settings\Application Data\MyGame.exe ret += base_name; // Remove ".exe" extension, e.g. C:\Documents and Settings\username\Local Settings\Application Data\MyGame ret = ret.substr(0, ret.rfind(".")); ret += "\\"; // Create directory if (SUCCEEDED(SHCreateDirectoryExA(NULL, ret.c_str(), NULL))) { return ret; } } } #endif // not defined _DEBUG // If fetching of local app data directory fails, use the executable one string ret((char*)full_path); // remove xxx.exe ret = ret.substr(0, ret.rfind("\\") + 1); ret = convertPathFormatToUnixStyle(ret); return ret; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCFileUtilsWin32.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_FILEUTILS_WIN32_H__ #define __CC_FILEUTILS_WIN32_H__ #include "platform/CCFileUtils.h" #include "CCPlatformMacros.h" #include "ccTypes.h" #include #include NS_CC_BEGIN /** * @addtogroup platform * @{ */ //! @brief Helper class to handle file operations class CC_DLL FileUtilsWin32 : public FileUtils { friend class FileUtils; FileUtilsWin32(); public: /* override funtions */ bool init(); virtual std::string getWritablePath() const; virtual bool isFileExist(const std::string& strFilePath) const; virtual bool isAbsolutePath(const std::string& strPath) const; protected: /** * Gets resource file data * * @param[in] filename The resource file name which contains the path. * @param[in] mode The read mode of the file. * @param[out] size If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const std::string& filename, const char* mode, ssize_t * size) override; /** * Gets string from a file. */ virtual std::string getStringFromFile(const std::string& filename) override; /** * Creates binary data from a file. * @return A data object. */ virtual Data getDataFromFile(const std::string& filename) override; /** * Gets full path for filename, resolution directory and search path. * * @param filename The file name. * @param resolutionDirectory The resolution directory. * @param searchPath The search path. * @return The full path of the file. It will return an empty string if the full path of the file doesn't exist. */ virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) override; /** * Gets full path for the directory and the filename. * * @note Only iOS and Mac need to override this method since they are using * `[[NSBundle mainBundle] pathForResource: ofType: inDirectory:]` to make a full path. * Other platforms will use the default implementation of this method. * @param directory The directory contains the file we are looking for. * @param filename The name of the file. * @return The full path of the file, if the file can't be found, it will return an empty string. */ virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) override; }; // end of platform group /// @} NS_CC_END #endif // __CC_FILEUTILS_WIN32_H__ ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCGL.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCGL_H__ #define __CCGL_H__ #include "GL/glew.h" #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 // These macros are only for making TexturePVR.cpp complied without errors since they are not included in GLEW. #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 #endif // __CCGL_H__ ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCImage.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #define __CC_PLATFORM_IMAGE_CPP__ #if _MSC_VER #include #endif #include "platform/CCImageCommon_cpp.h" NS_CC_BEGIN /** @brief A memory DC which uses to draw text on bitmap. */ class BitmapDC { public: BitmapDC(HWND hWnd = NULL) : _DC(NULL) , _bmp(NULL) , _font((HFONT)GetStockObject(DEFAULT_GUI_FONT)) , _wnd(NULL) { _wnd = hWnd; HDC hdc = GetDC(hWnd); _DC = CreateCompatibleDC(hdc); ReleaseDC(hWnd, hdc); } ~BitmapDC() { prepareBitmap(0, 0); if (_DC) { DeleteDC(_DC); } HFONT hDefFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if (hDefFont != _font) { DeleteObject(_font); _font = hDefFont; } // release temp font resource if (_curFontPath.size() > 0) { wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath); if (pwszBuffer) { RemoveFontResource(pwszBuffer); SendMessage( _wnd, WM_FONTCHANGE, 0, 0); delete [] pwszBuffer; pwszBuffer = NULL; } } } wchar_t * utf8ToUtf16(std::string nString) { wchar_t * pwszBuffer = NULL; do { if (nString.size() < 0) { break; } // utf-8 to utf-16 int nLen = nString.size(); int nBufLen = nLen + 1; pwszBuffer = new wchar_t[nBufLen]; CC_BREAK_IF(! pwszBuffer); memset(pwszBuffer,0,nBufLen); nLen = MultiByteToWideChar(CP_UTF8, 0, nString.c_str(), nLen, pwszBuffer, nBufLen); pwszBuffer[nLen] = '\0'; } while (0); return pwszBuffer; } bool setFont(const char * pFontName = NULL, int nSize = 0) { bool bRet = false; do { std::string fontName = pFontName; std::string fontPath; HFONT hDefFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); LOGFONTA tNewFont = {0}; LOGFONTA tOldFont = {0}; GetObjectA(hDefFont, sizeof(tNewFont), &tNewFont); if (fontName.c_str()) { // create font from ttf file int nFindttf = fontName.find(".ttf"); int nFindTTF = fontName.find(".TTF"); if (nFindttf >= 0 || nFindTTF >= 0) { fontPath = FileUtils::getInstance()->fullPathForFilename(fontName.c_str()); int nFindPos = fontName.rfind("/"); fontName = &fontName[nFindPos+1]; nFindPos = fontName.rfind("."); fontName = fontName.substr(0,nFindPos); } tNewFont.lfCharSet = DEFAULT_CHARSET; strcpy_s(tNewFont.lfFaceName, LF_FACESIZE, fontName.c_str()); } if (nSize) { tNewFont.lfHeight = -nSize; } GetObjectA(_font, sizeof(tOldFont), &tOldFont); if (tOldFont.lfHeight == tNewFont.lfHeight && 0 == strcmp(tOldFont.lfFaceName, tNewFont.lfFaceName)) { // already has the font bRet = true; break; } // delete old font if (_font != hDefFont) { DeleteObject(_font); // release old font register if (_curFontPath.size() > 0) { wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath); if (pwszBuffer) { if(RemoveFontResource(pwszBuffer)) { SendMessage( _wnd, WM_FONTCHANGE, 0, 0); } delete [] pwszBuffer; pwszBuffer = NULL; } } if (fontPath.size() > 0) _curFontPath = fontPath; else _curFontPath.clear(); // register temp font if (_curFontPath.size() > 0) { wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath); if (pwszBuffer) { if(AddFontResource(pwszBuffer)) { SendMessage( _wnd, WM_FONTCHANGE, 0, 0); } delete [] pwszBuffer; pwszBuffer = NULL; } } } _font = NULL; // disable Cleartype tNewFont.lfQuality = ANTIALIASED_QUALITY; // create new font _font = CreateFontIndirectA(&tNewFont); if (! _font) { // create failed, use default font _font = hDefFont; break; } bRet = true; } while (0); return bRet; } SIZE sizeWithText(const wchar_t * pszText, int nLen, DWORD dwFmt, LONG nWidthLimit) { SIZE tRet = {0}; do { CC_BREAK_IF(! pszText || nLen <= 0); RECT rc = {0, 0, 0, 0}; DWORD dwCalcFmt = DT_CALCRECT; if (nWidthLimit > 0) { rc.right = nWidthLimit; dwCalcFmt |= DT_WORDBREAK | (dwFmt & DT_CENTER) | (dwFmt & DT_RIGHT); } // use current font to measure text extent HGDIOBJ hOld = SelectObject(_DC, _font); // measure text size DrawTextW(_DC, pszText, nLen, &rc, dwCalcFmt); SelectObject(_DC, hOld); tRet.cx = rc.right; tRet.cy = rc.bottom; } while (0); return tRet; } bool prepareBitmap(int nWidth, int nHeight) { // release bitmap if (_bmp) { DeleteObject(_bmp); _bmp = NULL; } if (nWidth > 0 && nHeight > 0) { _bmp = CreateBitmap(nWidth, nHeight, 1, 32, NULL); if (! _bmp) { return false; } } return true; } int drawText(const char * pszText, SIZE& tSize, Image::TextAlign eAlign) { int nRet = 0; wchar_t * pwszBuffer = 0; do { CC_BREAK_IF(! pszText); DWORD dwFmt = DT_WORDBREAK; DWORD dwHoriFlag = (int)eAlign & 0x0f; DWORD dwVertFlag = ((int)eAlign & 0xf0) >> 4; switch (dwHoriFlag) { case 1: // left dwFmt |= DT_LEFT; break; case 2: // right dwFmt |= DT_RIGHT; break; case 3: // center dwFmt |= DT_CENTER; break; } int nLen = strlen(pszText); // utf-8 to utf-16 int nBufLen = nLen + 1; pwszBuffer = new wchar_t[nBufLen]; CC_BREAK_IF(! pwszBuffer); memset(pwszBuffer, 0, sizeof(wchar_t)*nBufLen); nLen = MultiByteToWideChar(CP_UTF8, 0, pszText, nLen, pwszBuffer, nBufLen); SIZE newSize = sizeWithText(pwszBuffer, nLen, dwFmt, tSize.cx); RECT rcText = {0}; // if content width is 0, use text size as content size if (tSize.cx <= 0) { tSize = newSize; rcText.right = newSize.cx; rcText.bottom = newSize.cy; } else { LONG offsetX = 0; LONG offsetY = 0; rcText.right = newSize.cx; // store the text width to rectangle // calculate text horizontal offset if (1 != dwHoriFlag // and text isn't align to left && newSize.cx < tSize.cx) // and text's width less then content width, { // then need adjust offset of X. offsetX = (2 == dwHoriFlag) ? tSize.cx - newSize.cx // align to right : (tSize.cx - newSize.cx) / 2; // align to center } // if content height is 0, use text height as content height // else if content height less than text height, use content height to draw text if (tSize.cy <= 0) { tSize.cy = newSize.cy; dwFmt |= DT_NOCLIP; rcText.bottom = newSize.cy; // store the text height to rectangle } else if (tSize.cy < newSize.cy) { // content height larger than text height need, clip text to rect rcText.bottom = tSize.cy; } else { rcText.bottom = newSize.cy; // store the text height to rectangle // content larger than text, need adjust vertical position dwFmt |= DT_NOCLIP; // calculate text vertical offset offsetY = (2 == dwVertFlag) ? tSize.cy - newSize.cy // align to bottom : (3 == dwVertFlag) ? (tSize.cy - newSize.cy) / 2 // align to middle : 0; // align to top } if (offsetX || offsetY) { OffsetRect(&rcText, offsetX, offsetY); } } CC_BREAK_IF(! prepareBitmap(tSize.cx, tSize.cy)); // draw text HGDIOBJ hOldFont = SelectObject(_DC, _font); HGDIOBJ hOldBmp = SelectObject(_DC, _bmp); SetBkMode(_DC, TRANSPARENT); SetTextColor(_DC, RGB(255, 255, 255)); // white color // draw text nRet = DrawTextW(_DC, pwszBuffer, nLen, &rcText, dwFmt); //DrawTextA(_DC, pszText, nLen, &rcText, dwFmt); SelectObject(_DC, hOldBmp); SelectObject(_DC, hOldFont); } while (0); CC_SAFE_DELETE_ARRAY(pwszBuffer); return nRet; } CC_SYNTHESIZE_READONLY(HDC, _DC, DC); CC_SYNTHESIZE_READONLY(HBITMAP, _bmp, Bitmap); private: friend class Image; HFONT _font; HWND _wnd; std::string _curFontPath; }; static BitmapDC& sharedBitmapDC() { static BitmapDC s_BmpDC; return s_BmpDC; } bool Image::initWithString( const char * pText, int nWidth/* = 0*/, int nHeight/* = 0*/, TextAlign eAlignMask/* = kAlignCenter*/, const char * pFontName/* = nil*/, int nSize/* = 0*/) { bool bRet = false; do { CC_BREAK_IF(! pText); BitmapDC& dc = sharedBitmapDC(); if (! dc.setFont(pFontName, nSize)) { log("Can't found font(%s), use system default", pFontName); } // draw text SIZE size = {nWidth, nHeight}; CC_BREAK_IF(! dc.drawText(pText, size, eAlignMask)); _dataLen = size.cx * size.cy * 4; _data = new unsigned char[_dataLen]; CC_BREAK_IF(! _data); struct { BITMAPINFOHEADER bmiHeader; int mask[4]; } bi = {0}; bi.bmiHeader.biSize = sizeof(bi.bmiHeader); CC_BREAK_IF(! GetDIBits(dc.getDC(), dc.getBitmap(), 0, 0, NULL, (LPBITMAPINFO)&bi, DIB_RGB_COLORS)); _width = (short)size.cx; _height = (short)size.cy; _preMulti = false; _renderFormat = Texture2D::PixelFormat::RGBA8888; // copy pixed data bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0) ? - bi.bmiHeader.biHeight : bi.bmiHeader.biHeight; GetDIBits(dc.getDC(), dc.getBitmap(), 0, _height, _data, (LPBITMAPINFO)&bi, DIB_RGB_COLORS); // change pixel's alpha value to 255, when it's RGB != 0 COLORREF * pPixel = NULL; for (int y = 0; y < _height; ++y) { pPixel = (COLORREF *)_data + y * _width; for (int x = 0; x < _width; ++x) { COLORREF& clr = *pPixel; if (GetRValue(clr) || GetGValue(clr) || GetBValue(clr)) { clr |= 0xff000000; } ++pPixel; } } bRet = true; } while (0); return bRet; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCPlatformDefine.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ #ifdef __MINGW32__ #include #endif //#if defined(_USRDLL) // #define CC_DLL __declspec(dllexport) //#else /* use a DLL library */ // #define CC_DLL __declspec(dllimport) //#endif #define CC_DLL #include #if CC_DISABLE_ASSERT > 0 #define CC_ASSERT(cond) #else #define CC_ASSERT(cond) assert(cond) #endif #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam /* Define NULL pointer value */ #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif #endif /* __CCPLATFORMDEFINE_H__*/ ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCStdC.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCStdC.h" #ifndef __MINGW32__ NS_CC_BEGIN int gettimeofday(struct timeval * val, struct timezone *) { if (val) { LARGE_INTEGER liTime, liFreq; QueryPerformanceFrequency( &liFreq ); QueryPerformanceCounter( &liTime ); val->tv_sec = (long)( liTime.QuadPart / liFreq.QuadPart ); val->tv_usec = (long)( liTime.QuadPart * 1000000.0 / liFreq.QuadPart - val->tv_sec * 1000000.0 ); } return 0; } NS_CC_END #endif // __MINGW32__ ================================================ FILE: cocos2d/cocos/2d/platform/win32/CCStdC.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_STD_C_H__ #define __CC_STD_C_H__ //typedef SSIZE_T ssize_t; // ssize_t was redefined as int in libwebsockets.h. // Therefore, to avoid conflict, we needs the same definition. typedef int ssize_t; #include "CCPlatformMacros.h" #include // for math.h on win32 platform #ifndef __MINGW32__ #if !defined(_USE_MATH_DEFINES) #define _USE_MATH_DEFINES // make M_PI can be use #endif #if !defined(isnan) #define isnan _isnan #endif #ifndef snprintf #define snprintf _snprintf #endif #endif // __MINGW32__ #include #include #include #include #include #include #ifndef M_PI #define M_PI 3.14159265358 #endif #ifndef M_PI_2 #define M_PI_2 1.57079632679 #endif // for MIN MAX and sys/time.h on win32 platform #ifdef __MINGW32__ #include #endif // __MINGW32__ #ifndef MIN #define MIN(x,y) (((x) > (y)) ? (y) : (x)) #endif // MIN #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX #if _MSC_VER >= 1600 || defined(__MINGW32__) #include #else #include "./compat/stdint.h" #endif #define _WINSOCKAPI_ #ifndef NOMINMAX #define NOMINMAX #endif // Structure timeval has define in winsock.h, include windows.h for it. #include #ifndef __MINGW32__ #include NS_CC_BEGIN struct timezone { int tz_minuteswest; int tz_dsttime; }; int CC_DLL gettimeofday(struct timeval *, struct timezone *); NS_CC_END #else #undef _WINSOCKAPI_ #include // Conflicted with math.h isnan #include using std::isnan; inline int vsnprintf_s(char *buffer, size_t sizeOfBuffer, size_t count, const char *format, va_list argptr) { return vsnprintf(buffer, sizeOfBuffer, format, argptr); } inline errno_t strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource) { strcpy(strDestination, strSource); return 0; } #endif // __MINGW32__ // Conflicted with cocos2d::MessageBox, so we need to undef it. #ifdef MessageBox #undef MessageBox #endif // Conflicted with ParticleSystem::PositionType::RELATIVE, so we need to undef it. #ifdef RELATIVE #undef RELATIVE #endif // Conflicted with CCBReader::SizeType::RELATIVE and CCBReader::ScaleType::RELATIVE, so we need to undef it. #ifdef ABSOLUTE #undef ABSOLUTE #endif // Conflicted with HttpRequest::Type::DELETE, so we need to undef it. #ifdef DELETE #undef DELETE #endif #undef min #undef max #endif // __CC_STD_C_H__ ================================================ FILE: cocos2d/cocos/2d/platform/win32/compat/stdint.h ================================================ // 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 int16_t int_fast16_t; typedef int32_t int_fast32_t; typedef int64_t int_fast64_t; typedef uint8_t uint_fast8_t; typedef uint16_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_ ] ================================================ FILE: cocos2d/cocos/2d/renderer/CCBatchCommand.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "renderer/CCBatchCommand.h" #include "ccGLStateCache.h" #include "CCTextureAtlas.h" #include "CCTexture2D.h" NS_CC_BEGIN BatchCommand::BatchCommand() : _textureID(0) , _blendType(BlendFunc::DISABLE) , _textureAtlas(nullptr) { _type = RenderCommand::Type::BATCH_COMMAND; _shader = nullptr; } void BatchCommand::init(float globalOrder, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform) { CCASSERT(shader, "shader cannot be nill"); CCASSERT(textureAtlas, "textureAtlas cannot be nill"); _globalOrder = globalOrder; _textureID = textureAtlas->getTexture()->getName(); _blendType = blendType; _shader = shader; _textureAtlas = textureAtlas; _mv = modelViewTransform; } BatchCommand::~BatchCommand() { } void BatchCommand::execute() { // Set material _shader->use(); _shader->setUniformsForBuiltins(_mv); GL::bindTexture2D(_textureID); GL::blendFunc(_blendType.src, _blendType.dst); // Draw _textureAtlas->drawQuads(); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/renderer/CCBatchCommand.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CC_BATCHCOMMAND_H_ #define _CC_BATCHCOMMAND_H_ #include "CCRenderCommand.h" #include "CCGLProgram.h" #include "CCRenderCommandPool.h" #include "kazmath/kazmath.h" NS_CC_BEGIN class TextureAtlas; #define CC_NO_TEXTURE 0 class BatchCommand : public RenderCommand { public: BatchCommand(); ~BatchCommand(); void init(float depth, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform); void execute(); protected: //Material int32_t _materialID; GLuint _textureID; GLProgram* _shader; BlendFunc _blendType; TextureAtlas *_textureAtlas; // ModelView transform kmMat4 _mv; }; NS_CC_END #endif //_CC_BATCHCOMMAND_H_ ================================================ FILE: cocos2d/cocos/2d/renderer/CCCustomCommand.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "renderer/CCCustomCommand.h" NS_CC_BEGIN CustomCommand::CustomCommand() : func(nullptr) { _type = RenderCommand::Type::CUSTOM_COMMAND; } void CustomCommand::init(float globalOrder) { _globalOrder = globalOrder; } CustomCommand::~CustomCommand() { } void CustomCommand::execute() { if(func) { func(); } } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/renderer/CCCustomCommand.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CC_CUSTOMCOMMAND_H_ #define _CC_CUSTOMCOMMAND_H_ #include "CCRenderCommand.h" #include "CCRenderCommandPool.h" NS_CC_BEGIN class CustomCommand : public RenderCommand { public: CustomCommand(); ~CustomCommand(); public: void init(float depth); void execute(); inline bool isTranslucent() { return true; } std::function func; protected: }; NS_CC_END #endif //_CC_CUSTOMCOMMAND_H_ ================================================ FILE: cocos2d/cocos/2d/renderer/CCFrustum.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "renderer/CCFrustum.h" #include "CCConsole.h" #include NS_CC_BEGIN ViewTransform::ViewTransform() { kmVec3Fill(&_position,0,0,0); kmVec3Fill(&_focus,0,0,-1); kmVec3Fill(&_up,0,1,0); _dirty = true; kmMat4Identity(&_matrix); } ViewTransform::~ViewTransform() { } void ViewTransform::Init(const kmVec3 &pos, const kmVec3 &focus, const kmVec3 &up) { _position = pos; _focus = focus; _up = up; _dirty = true; } void ViewTransform::LazyAdjust() const { if(!_dirty) return; kmVec3Subtract(&_adjustDir, &_focus, &_position); kmVec3Normalize(&_adjustDir, &_adjustDir); kmVec3Cross(&_adjustRight, &_adjustDir, &_up); kmVec3Normalize(&_adjustRight, &_adjustRight); kmVec3Cross(&_adjustUp, &_adjustRight, &_adjustDir); kmVec3Normalize(&_adjustUp, &_adjustUp); _dirty = false; } const kmVec3& ViewTransform::getDirection() const { LazyAdjust(); return _adjustDir; } const kmVec3& ViewTransform::getRight() const { LazyAdjust(); return _adjustRight; } const kmVec3& ViewTransform::getUp() const { LazyAdjust(); return _adjustUp; } AABB::AABB(const kmVec3& min, const kmVec3& max) { _min = min; _max = max; if(_min.x > _max.x) { CCLOG("_min.x is greater than _max.x, it will be swapped!"); float temp = _min.x; _min.x = _max.x; _max.x = temp; } if(_min.y > _max.y) { CCLOG("_min.y is greater than _max.y, it will be swapped!"); float temp = _min.y; _min.y = _max.y; _max.y = temp; } if(_min.z > _max.z) { CCLOG("_min.z is greater than _max.z, it will be swapped!"); float temp = _min.z; _min.z = _max.z; _max.z = temp; } } AABB::~AABB() { } kmVec3 AABB::getCenter() const { kmVec3 result; kmVec3Add(&result, &_min, &_max); kmVec3Scale(&result, &result, 0.5f); return result; } float AABB::getDimensionX() const { return _max.x - _min.x; } float AABB::getDimensionY() const { return _max.y - _min.y; } float AABB::getDimensionZ() const { return _max.z - _min.z; } kmVec3 AABB::getPositivePoint(const kmVec3& direction) const { kmVec3 result = _max; if( direction.x < 0 ) result.x = _min.x; if( direction.y < 0 ) result.y = _min.y; if( direction.z < 0 ) result.z = _min.z; return result; } const AABB& AABB::expand(const kmVec3& point) { if(point.x > _max.x) _max.x = point.x; if(point.y > _max.y) _max.y = point.y; if(point.z > _max.z) _max.z = point.z; if(point.x < _min.x) _min.x = point.x; if(point.y < _min.y) _min.y = point.y; if(point.z < _min.z) _min.z = point.z; return *this; } kmVec3 AABB::getNegativePoint(const kmVec3& direction) const { kmVec3 result = _min; if( direction.x < 0 ) result.x = _max.x; if( direction.y < 0 ) result.y = _max.y; if( direction.z < 0 ) result.z = _max.z; return result; } Frustum::Frustum() { } Frustum::~Frustum() { } void Frustum::setupProjectionOrthogonal(const cocos2d::ViewTransform &view, float width, float height, float nearPlane, float farPlane) { kmVec3 cc = view.getPosition(); kmVec3 cDir = view.getDirection(); kmVec3 cRight = view.getRight(); kmVec3 cUp = view.getUp(); kmVec3Normalize(&cDir, &cDir); kmVec3Normalize(&cRight, &cRight); kmVec3Normalize(&cUp, &cUp); //near { kmVec3 point; kmVec3 normal; normal = cDir; kmVec3Scale(&point, &cDir, nearPlane); kmVec3Add(&point, &point, &cc); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_NEAR], &point, &normal); } //far { kmVec3 point; kmVec3 normal; kmVec3Scale(&normal, &cDir, -1); kmVec3Scale(&point, &cDir, farPlane); kmVec3Add(&point, &point, &cc); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_FAR], &point, &normal); } //left { kmVec3 point; kmVec3 normal; normal = cRight; kmVec3Scale(&point, &cRight, -width * 0.5); kmVec3Add(&point, &point, &cc); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_LEFT], &point, &normal); } //right { kmVec3 point; kmVec3 normal; kmVec3Scale(&normal, &cRight, -1); kmVec3Scale(&point, &cRight, width * 0.5); kmVec3Add(&point, &point, &cc); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_RIGHT], &point, &normal); } //bottom { kmVec3 point; kmVec3 normal; normal = cUp; kmVec3Scale(&point, &cUp, -height * 0.5); kmVec3Add(&point, &point, &cc); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_BOTTOM], &point, &normal); } //top { kmVec3 point; kmVec3 normal; kmVec3Scale(&normal, &cUp, -1); kmVec3Scale(&point, &cUp, height * 0.5); kmVec3Add(&point, &point, &cc); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_TOP], &point, &normal); } } void Frustum::setupProjectionPerspective(const ViewTransform& view, float left, float right, float top, float bottom, float nearPlane, float farPlane) { kmVec3 cc = view.getPosition(); kmVec3 cDir = view.getDirection(); kmVec3 cRight = view.getRight(); kmVec3 cUp = view.getUp(); kmVec3Normalize(&cDir, &cDir); kmVec3Normalize(&cRight, &cRight); kmVec3Normalize(&cUp, &cUp); kmVec3 nearCenter; kmVec3 farCenter; kmVec3Scale(&nearCenter, &cDir, nearPlane); kmVec3Add(&nearCenter, &nearCenter, &cc); kmVec3Scale(&farCenter, &cDir, farPlane); kmVec3Add(&farCenter, &farCenter, &cc); //near { kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_NEAR], &nearCenter, &cDir); } //far { kmVec3 normal; kmVec3Scale(&normal, &cDir, -1); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_FAR], &farCenter, &normal); } //left { kmVec3 point; kmVec3Scale(&point, &cRight, left); kmVec3Add(&point, &point, &nearCenter); kmVec3 normal; kmVec3Subtract(&normal, &point, &cc); kmVec3Cross(&normal, &normal, &cUp); kmVec3Normalize(&normal, &normal); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_LEFT], &point, &normal); } //right { kmVec3 point; kmVec3Scale(&point, &cRight, right); kmVec3Add(&point, &point, &nearCenter); kmVec3 normal; kmVec3Subtract(&normal, &point, &cc); kmVec3Cross(&normal, &cUp, &normal); kmVec3Normalize(&normal, &normal); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_RIGHT], &point, &normal); } //bottom { kmVec3 point; kmVec3Scale(&point, &cUp, bottom); kmVec3Add(&point, &point, &nearCenter); kmVec3 normal; kmVec3Subtract(&normal, &point, &cc); kmVec3Cross(&normal, &cRight, &normal); kmVec3Normalize(&normal, &normal); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_BOTTOM], &point, &normal); } //top { kmVec3 point; kmVec3Scale(&point, &cUp, top); kmVec3Add(&point, &point, &nearCenter); kmVec3 normal; kmVec3Subtract(&normal, &point, &cc); kmVec3Cross(&normal, &normal, &cRight); kmVec3Normalize(&normal, &normal); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_TOP], &point, &normal); } } void Frustum::setupProjectionPerspectiveFov(const ViewTransform& view, float fov, float ratio, float nearPlane, float farPlane) { float width = 2 * nearPlane * tan(fov * 0.5); float height = width/ratio; setupProjectionPerspective(view, -width/2, width/2, height/2, -height/2, nearPlane, farPlane); } void Frustum::setupFromMatrix(const kmMat4 &view, const kmMat4 &projection) { kmMat4 mvp; kmMat4Multiply(&mvp, &projection, &view); kmMat4ExtractPlane(&_frustumPlanes[FrustumPlane::FRUSTUM_NEAR], &mvp, KM_PLANE_NEAR); kmMat4ExtractPlane(&_frustumPlanes[FrustumPlane::FRUSTUM_FAR], &mvp, KM_PLANE_FAR); kmMat4ExtractPlane(&_frustumPlanes[FrustumPlane::FRUSTUM_LEFT], &mvp, KM_PLANE_LEFT); kmMat4ExtractPlane(&_frustumPlanes[FrustumPlane::FRUSTUM_RIGHT], &mvp, KM_PLANE_RIGHT); kmMat4ExtractPlane(&_frustumPlanes[FrustumPlane::FRUSTUM_BOTTOM], &mvp, KM_PLANE_BOTTOM); kmMat4ExtractPlane(&_frustumPlanes[FrustumPlane::FRUSTUM_TOP], &mvp, KM_PLANE_TOP); } Frustum::IntersectResult Frustum::intersectPoint(const kmVec3 &point) const { int indexFirst = static_cast(FrustumPlane::FRUSTUM_NEAR); int indexNumber = static_cast(FrustumPlane::FRUSTUM_NUMBER); for(int planeIndex = indexFirst; planeIndex < indexNumber; ++planeIndex) { if(kmPlaneDotCoord(&_frustumPlanes[static_cast(planeIndex)], &point) < 0) return IntersectResult::OUTSIDE; } return IntersectResult::INSIDE; } Frustum::IntersectResult Frustum::intersectAABB(const AABB& aabb) const { IntersectResult result = IntersectResult::INSIDE; int indexFirst = static_cast(FrustumPlane::FRUSTUM_NEAR); int indexNumber = static_cast(FrustumPlane::FRUSTUM_NUMBER); for(int planeIndex = indexFirst; planeIndex < indexNumber; ++planeIndex) { kmPlane plane = _frustumPlanes[static_cast(planeIndex)]; kmVec3 normal = {plane.a, plane.b, plane.c}; kmVec3Normalize(&normal, &normal); kmVec3 positivePoint = aabb.getPositivePoint(normal); kmVec3 negativePoint = aabb.getNegativePoint(normal); if(kmPlaneDotCoord(&plane, &positivePoint) < 0) return IntersectResult::OUTSIDE; if(kmPlaneDotCoord(&plane, &negativePoint) < 0) result = IntersectResult::INTERSECT; } return result; } Frustum::IntersectResult Frustum::intersectSphere(const kmVec3& center, float radius) const { IntersectResult result = IntersectResult::INSIDE; int indexFirst = static_cast(FrustumPlane::FRUSTUM_NEAR); int indexNumber = static_cast(FrustumPlane::FRUSTUM_NUMBER); for(int planeIndex = indexFirst; planeIndex < indexNumber; ++planeIndex) { kmPlane plane = _frustumPlanes[static_cast(planeIndex)]; kmVec3 normal = {plane.a, plane.b, plane.c}; float distance = kmPlaneDotCoord(&plane, ¢er); distance = distance / kmVec3Length(&normal); if(distance < -radius) return IntersectResult::OUTSIDE; if(distance <= radius && distance >= -radius) result = IntersectResult::INTERSECT; } return result; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/renderer/CCFrustum.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_FRUSTUM_H__ #define __CC_FRUSTUM_H__ #include "CCPlatformMacros.h" #include "kazmath/kazmath.h" NS_CC_BEGIN class ViewTransform { public: ViewTransform(); ~ViewTransform(); void Init(const kmVec3& pos, const kmVec3& focus, const kmVec3& up); const kmVec3& getPosition() const { return _position; } const kmVec3& getFocus() const { return _focus; } const kmVec3& getDirection() const; const kmVec3& getRight() const; const kmVec3& getUp() const; protected: void LazyAdjust() const; kmVec3 _position; kmVec3 _focus; kmVec3 _up; mutable bool _dirty; mutable kmMat4 _matrix; mutable kmVec3 _adjustDir; mutable kmVec3 _adjustRight; mutable kmVec3 _adjustUp; }; class AABB { public: AABB(const kmVec3& min, const kmVec3& max); ~AABB(); kmVec3 getCenter() const; float getDimensionX() const; float getDimensionY() const; float getDimensionZ() const; kmVec3 getPositivePoint(const kmVec3& direction) const; kmVec3 getNegativePoint(const kmVec3& direction) const; const AABB& expand(const kmVec3& point); protected: kmVec3 _min; kmVec3 _max; }; class Frustum { public: enum class IntersectResult { OUTSIDE = 0, INTERSECT = 1, INSIDE = 2 }; Frustum(); ~Frustum(); void setupProjectionOrthogonal(const ViewTransform& view, float width, float height, float near, float far); void setupProjectionPerspective(const ViewTransform& view, float left, float right, float top, float bottom, float near, float far); void setupProjectionPerspectiveFov(const ViewTransform& view, float fov, float ratio, float near, float far); void setupFromMatrix(const kmMat4& view, const kmMat4& projection); IntersectResult intersectPoint(const kmVec3& point) const; IntersectResult intersectAABB(const AABB& aabb) const; IntersectResult intersectSphere(const kmVec3& center, float radius) const; protected: enum FrustumPlane { FRUSTUM_NEAR = 0, FRUSTUM_FAR = 1, FRUSTUM_BOTTOM = 2, FRUSTUM_TOP = 3, FRUSTUM_LEFT = 4, FRUSTUM_RIGHT = 5, FRUSTUM_NUMBER = 6 }; kmPlane _frustumPlanes[FrustumPlane::FRUSTUM_NUMBER]; }; NS_CC_END #endif ================================================ FILE: cocos2d/cocos/2d/renderer/CCGroupCommand.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "renderer/CCGroupCommand.h" #include "renderer/CCRenderer.h" #include "CCDirector.h" NS_CC_BEGIN static GroupCommandManager* s_instance; GroupCommandManager *GroupCommandManager::getInstance() { if(!s_instance) { s_instance = new GroupCommandManager(); if(!s_instance->init()) { CC_SAFE_DELETE(s_instance); } } return s_instance; } GroupCommandManager::GroupCommandManager() { } GroupCommandManager::~GroupCommandManager() { CC_SAFE_RELEASE_NULL(s_instance); } bool GroupCommandManager::init() { //0 is the default render group _groupMapping[0] = true; return true; } int GroupCommandManager::getGroupID() { //Reuse old id for(auto it = _groupMapping.begin(); it != _groupMapping.end(); ++it) { if(!it->second) { _groupMapping[it->first] = true; return it->first; } } //Create new ID // int newID = _groupMapping.size(); int newID = Director::getInstance()->getRenderer()->createRenderQueue(); _groupMapping[newID] = true; return newID; } void GroupCommandManager::releaseGroupID(int groupID) { _groupMapping[groupID] = false; } GroupCommand::GroupCommand() { _type = RenderCommand::Type::GROUP_COMMAND; _renderQueueID = GroupCommandManager::getInstance()->getGroupID(); } void GroupCommand::init(float globalOrder) { _globalOrder = globalOrder; GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID); _renderQueueID = GroupCommandManager::getInstance()->getGroupID(); } GroupCommand::~GroupCommand() { GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/renderer/CCGroupCommand.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CC_GROUPCOMMAND_H_ #define _CC_GROUPCOMMAND_H_ #include "CCPlatformMacros.h" #include "CCRenderCommand.h" #include "CCRenderCommandPool.h" #include NS_CC_BEGIN class GroupCommandManager : public Object { public: static GroupCommandManager* getInstance(); ~GroupCommandManager(); bool init(); int getGroupID(); void releaseGroupID(int groupID); protected: GroupCommandManager(); std::unordered_map _groupMapping; }; class GroupCommand : public RenderCommand { public: GroupCommand(); ~GroupCommand(); void init(float depth); inline int getRenderQueueID() const {return _renderQueueID;} protected: int _renderQueueID; }; NS_CC_END #endif //_CC_GROUPCOMMAND_H_ ================================================ FILE: cocos2d/cocos/2d/renderer/CCMaterialManager.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCMaterialManager.h" NS_CC_BEGIN using namespace std; static MaterialManager* s_instance = nullptr; MaterialManager *MaterialManager::getInstance() { if(!s_instance) { s_instance = new MaterialManager(); if(!s_instance->init()) { CC_SAFE_DELETE(s_instance); } } return s_instance; } void MaterialManager::destroyInstance() { CC_SAFE_RELEASE_NULL(s_instance); } void MaterialManager::getMaterialID(GLuint textureID, GLuint shaderID, BlendFunc blendFunc) { } void MaterialManager::registerTexture(GLuint textureID) { } void MaterialManager::unregisterTexture(GLuint textureID) { } void MaterialManager::registerShader(GLuint shaderID) { } void MaterialManager::unregisterShader(GLuint shaderID) { } MaterialManager::MaterialManager() { } MaterialManager::~MaterialManager() { } bool MaterialManager::init() { return false; } int MaterialManager::getTextureID(GLuint textureID) { return 0; } int MaterialManager::getShaderID(GLuint shaderID) { return 0; } int MaterialManager::getBlendFuncID(GLint blendFunc) { return 0; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/renderer/CCMaterialManager.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CC_MATERIALMANAGER_H_ #define _CC_MATERIALMANAGER_H_ #include "CCPlatformMacros.h" #include "CCObject.h" #include "ccTypes.h" #include NS_CC_BEGIN class MaterialManager : public Object { public: static MaterialManager* getInstance(); static void destroyInstance(); void getMaterialID(GLuint textureID, GLuint shaderID, BlendFunc blendFunc); void registerTexture(GLuint textureID); void unregisterTexture(GLuint textureID); void registerShader(GLuint shaderID); void unregisterShader(GLuint shaderID); protected: MaterialManager(); virtual ~MaterialManager(); bool init(); int getTextureID(GLuint textureID); int getShaderID(GLuint shaderID); int getBlendFuncID(GLint blendFunc); std::map _textureIDMapping; std::map _shaderIDMapping; std::map _blendFuncMapping; }; NS_CC_END #endif //_CC_MATERIALMANAGER_H_ ================================================ FILE: cocos2d/cocos/2d/renderer/CCQuadCommand.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "renderer/CCQuadCommand.h" #include "ccGLStateCache.h" NS_CC_BEGIN QuadCommand::QuadCommand() :_textureID(0) ,_blendType(BlendFunc::DISABLE) ,_quadsCount(0) { _type = RenderCommand::Type::QUAD_COMMAND; _shader = nullptr; _quads = nullptr; } void QuadCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv) { _globalOrder = globalOrder; _textureID = textureID; _blendType = blendType; _shader = shader; _quadsCount = quadCount; _quads = quad; _mv = mv; generateMaterialID(); } QuadCommand::~QuadCommand() { } void QuadCommand::generateMaterialID() { //Generate Material ID //TODO fix shader ID generation CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10"); //TODO fix texture ID generation CCASSERT(_textureID < pow(2,18), "TextureID is greater than 2^18"); //TODO fix blend id generation int blendID = 0; if(_blendType == BlendFunc::DISABLE) { blendID = 0; } else if(_blendType == BlendFunc::ALPHA_PREMULTIPLIED) { blendID = 1; } else if(_blendType == BlendFunc::ALPHA_NON_PREMULTIPLIED) { blendID = 2; } else if(_blendType == BlendFunc::ADDITIVE) { blendID = 3; } else { blendID = 4; } //TODO Material ID should be part of the ID // // Temporal hack (later, these 32-bits should be packed in 24-bits // // +---------------------+-------------------+----------------------+ // | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) | // +---------------------+-------------------+----------------------+ _materialID = (uint32_t)_shader->getProgram() << 22 | (uint32_t)blendID << 18 | (uint32_t)_textureID << 0; } void QuadCommand::useMaterial() const { _shader->use(); _shader->setUniformsForBuiltins(); //Set texture GL::bindTexture2D(_textureID); //set blend mode GL::blendFunc(_blendType.src, _blendType.dst); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/renderer/CCQuadCommand.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _CC_QUADCOMMAND_H_ #define _CC_QUADCOMMAND_H_ #include "CCRenderCommand.h" #include "CCGLProgram.h" #include "CCRenderCommandPool.h" #include "kazmath/kazmath.h" NS_CC_BEGIN #define CC_NO_TEXTURE 0 class QuadCommand : public RenderCommand { public: QuadCommand(); ~QuadCommand(); void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, const kmMat4& mv); void useMaterial() const; //TODO use material to decide if it is translucent inline bool isTranslucent() const { return true; } void generateMaterialID(); inline uint32_t getMaterialID() const { return _materialID; } inline GLuint getTextureID() const { return _textureID; } inline V3F_C4B_T2F_Quad* getQuads() const { return _quads; } inline ssize_t getQuadCount() const { return _quadsCount; } inline GLProgram* getShader() const { return _shader; } inline BlendFunc getBlendType() const { return _blendType; } inline const kmMat4& getModelView() const { return _mv; } protected: uint32_t _materialID; //Maternal GLuint _textureID; GLProgram* _shader; // GLuint _shaderID; BlendFunc _blendType; V3F_C4B_T2F_Quad* _quads; ssize_t _quadsCount; kmMat4 _mv; }; NS_CC_END #endif //_CC_QUADCOMMAND_H_ ================================================ FILE: cocos2d/cocos/2d/renderer/CCRenderCommand.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCRenderCommand.h" NS_CC_BEGIN RenderCommand::RenderCommand() : _type(RenderCommand::Type::UNKNOWN_COMMAND) , _globalOrder(0) { } RenderCommand::~RenderCommand() { } void printBits(ssize_t const size, void const * const ptr) { unsigned char *b = (unsigned char*) ptr; unsigned char byte; ssize_t i, j; for (i=size-1;i>=0;i--) { for (j=7;j>=0;j--) { byte = b[i] & (1<>= j; printf("%u", byte); } } puts(""); } void RenderCommand::printID() { printf("Command Depth: %f\n", _globalOrder); } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/renderer/CCRenderCommand.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCRENDERCOMMAND_H_ #define __CCRENDERCOMMAND_H_ #include "CCPlatformMacros.h" #include #include "ccTypes.h" #include "kazmath/GL/matrix.h" NS_CC_BEGIN /** Base class of the RenderCommand hierarchy. The Renderer knows how to render RenderCommands. */ class RenderCommand { public: enum class Type { UNKNOWN_COMMAND, QUAD_COMMAND, CUSTOM_COMMAND, BATCH_COMMAND, GROUP_COMMAND, }; /** Get Render Command Id */ inline float getGlobalOrder() const { return _globalOrder; } /** Returns the Command type */ inline Type getType() const { return _type; } protected: RenderCommand(); virtual ~RenderCommand(); void printID(); // Type used in order to avoid dynamic cast, faster Type _type; // commands are sort by depth float _globalOrder; }; NS_CC_END #endif //__CCRENDERCOMMAND_H_ ================================================ FILE: cocos2d/cocos/2d/renderer/CCRenderCommandPool.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_RENDERCOMMANDPOOL_H__ #define __CC_RENDERCOMMANDPOOL_H__ #include #include #include "CCPlatformMacros.h" NS_CC_BEGIN template class RenderCommandPool { public: RenderCommandPool() { } ~RenderCommandPool() { // if( 0 != _usedPool.size()) // { // CCLOG("All RenderCommand should not be used when Pool is released!"); // } _freePool.clear(); for (typename std::list::iterator iter = _allocatedPoolBlocks.begin(); iter != _allocatedPoolBlocks.end(); ++iter) { delete[] *iter; *iter = nullptr; } _allocatedPoolBlocks.clear(); } T* generateCommand() { T* result = nullptr; if(_freePool.empty()) { AllocateCommands(); } result = _freePool.front(); _freePool.pop_front(); //_usedPool.insert(result); return result; } void pushBackCommand(T* ptr) { // if(_usedPool.find(ptr) == _usedPool.end()) // { // CCLOG("push Back Wrong command!"); // return; // } _freePool.push_back(ptr); //_usedPool.erase(ptr); } private: void AllocateCommands() { static const int COMMANDS_ALLOCATE_BLOCK_SIZE = 32; T* commands = new T[COMMANDS_ALLOCATE_BLOCK_SIZE]; _allocatedPoolBlocks.push_back(commands); for(int index = 0; index < COMMANDS_ALLOCATE_BLOCK_SIZE; ++index) { _freePool.push_back(commands+index); } } std::list _allocatedPoolBlocks; std::list _freePool; //std::set _usedPool; }; NS_CC_END #endif ================================================ FILE: cocos2d/cocos/2d/renderer/CCRenderMaterial.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCRenderMaterial.h" ================================================ FILE: cocos2d/cocos/2d/renderer/CCRenderMaterial.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __RenderMaterial_H_ #define __RenderMaterial_H_ class RenderMaterial { }; #endif //__RenderMaterial_H_ ================================================ FILE: cocos2d/cocos/2d/renderer/CCRenderer.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "renderer/CCRenderer.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCBatchCommand.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCGroupCommand.h" #include "CCShaderCache.h" #include "ccGLStateCache.h" #include "CCConfiguration.h" #include "CCDirector.h" #include "CCEventDispatcher.h" #include "CCEventListenerCustom.h" #include "CCEventType.h" #include NS_CC_BEGIN bool compareRenderCommand(RenderCommand* a, RenderCommand* b) { return a->getGlobalOrder() < b->getGlobalOrder(); } void RenderQueue::push_back(RenderCommand* command) { float z = command->getGlobalOrder(); if(z < 0) _queueNegZ.push_back(command); else if(z > 0) _queuePosZ.push_back(command); else _queue0.push_back(command); } ssize_t RenderQueue::size() const { return _queueNegZ.size() + _queue0.size() + _queuePosZ.size(); } void RenderQueue::sort() { // Don't sort _queue0, it already comes sorted std::sort(std::begin(_queueNegZ), std::end(_queueNegZ), compareRenderCommand); std::sort(std::begin(_queuePosZ), std::end(_queuePosZ), compareRenderCommand); } RenderCommand* RenderQueue::operator[](ssize_t index) const { if(index < _queueNegZ.size()) return _queueNegZ[index]; index -= _queueNegZ.size(); if(index < _queue0.size()) return _queue0[index]; index -= _queue0.size(); if(index < _queuePosZ.size()) return _queuePosZ[index]; CCASSERT(false, "invalid index"); return nullptr; } void RenderQueue::clear() { _queueNegZ.clear(); _queue0.clear(); _queuePosZ.clear(); } // // // #define DEFAULT_RENDER_QUEUE 0 Renderer::Renderer() :_lastMaterialID(0) ,_numQuads(0) ,_glViewAssigned(false) #if CC_ENABLE_CACHE_TEXTURE_DATA ,_cacheTextureListener(nullptr) #endif { _commandGroupStack.push(DEFAULT_RENDER_QUEUE); RenderQueue defaultRenderQueue; _renderGroups.push_back(defaultRenderQueue); RenderStackElement elelment = {DEFAULT_RENDER_QUEUE, 0}; _renderStack.push(elelment); _batchedQuadCommands.reserve(BATCH_QUADCOMMAND_RESEVER_SIZE); } Renderer::~Renderer() { _renderGroups.clear(); glDeleteBuffers(2, _buffersVBO); if (Configuration::getInstance()->supportsShareableVAO()) { glDeleteVertexArrays(1, &_quadVAO); GL::bindVAO(0); } #if CC_ENABLE_CACHE_TEXTURE_DATA Director::getInstance()->getEventDispatcher()->removeEventListener(_cacheTextureListener); #endif } void Renderer::initGLView() { #if CC_ENABLE_CACHE_TEXTURE_DATA _cacheTextureListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ /** listen the event that coming to foreground on Android */ this->setupBuffer(); }); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_cacheTextureListener, -1); #endif setupIndices(); setupBuffer(); _glViewAssigned = true; } void Renderer::setupIndices() { for( int i=0; i < VBO_SIZE; i++) { _indices[i*6+0] = (GLushort) (i*4+0); _indices[i*6+1] = (GLushort) (i*4+1); _indices[i*6+2] = (GLushort) (i*4+2); _indices[i*6+3] = (GLushort) (i*4+3); _indices[i*6+4] = (GLushort) (i*4+2); _indices[i*6+5] = (GLushort) (i*4+1); } } void Renderer::setupBuffer() { if(Configuration::getInstance()->supportsShareableVAO()) { setupVBOAndVAO(); } else { setupVBO(); } } void Renderer::setupVBOAndVAO() { glGenVertexArrays(1, &_quadVAO); GL::bindVAO(_quadVAO); glGenBuffers(2, &_buffersVBO[0]); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * VBO_SIZE, _quads, GL_DYNAMIC_DRAW); // vertices glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B_T2F), (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * VBO_SIZE * 6, _indices, GL_STATIC_DRAW); // Must unbind the VAO before changing the element buffer. GL::bindVAO(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); CHECK_GL_ERROR_DEBUG(); } void Renderer::setupVBO() { glGenBuffers(2, &_buffersVBO[0]); mapBuffers(); } void Renderer::mapBuffers() { // Avoid changing the element buffer for whatever VAO might be bound. GL::bindVAO(0); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * VBO_SIZE, _quads, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * VBO_SIZE * 6, _indices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); CHECK_GL_ERROR_DEBUG(); } void Renderer::addCommand(RenderCommand* command) { int renderQueue =_commandGroupStack.top(); addCommand(command, renderQueue); } void Renderer::addCommand(RenderCommand* command, int renderQueue) { CCASSERT(renderQueue >=0, "Invalid render queue"); CCASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type"); _renderGroups[renderQueue].push_back(command); } void Renderer::pushGroup(int renderQueueID) { _commandGroupStack.push(renderQueueID); } void Renderer::popGroup() { _commandGroupStack.pop(); } int Renderer::createRenderQueue() { RenderQueue newRenderQueue; _renderGroups.push_back(newRenderQueue); return (int)_renderGroups.size() - 1; } void Renderer::render() { //Uncomment this once everything is rendered by new renderer //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //TODO setup camera or MVP if (_glViewAssigned) { //Process render commands //1. Sort render commands based on ID for (auto &renderqueue : _renderGroups) { renderqueue.sort(); } while(!_renderStack.empty()) { RenderQueue currRenderQueue = _renderGroups[_renderStack.top().renderQueueID]; size_t len = currRenderQueue.size(); //Process RenderQueue for(size_t i = _renderStack.top().currentIndex; i < len; i++) { _renderStack.top().currentIndex = i; auto command = currRenderQueue[i]; auto commandType = command->getType(); if(commandType == RenderCommand::Type::QUAD_COMMAND) { auto cmd = static_cast(command); CCASSERT(nullptr!= cmd, "Illegal command for RenderCommand Taged as QUAD_COMMAND"); //Batch quads if(_numQuads + cmd->getQuadCount() > VBO_SIZE) { CCASSERT(cmd->getQuadCount()>= 0 && cmd->getQuadCount() < VBO_SIZE, "VBO is not big enough for quad data, please break the quad data down or use customized render command"); //Draw batched quads if VBO is full drawBatchedQuads(); } _batchedQuadCommands.push_back(cmd); memcpy(_quads + _numQuads, cmd->getQuads(), sizeof(V3F_C4B_T2F_Quad) * cmd->getQuadCount()); convertToWorldCoordinates(_quads + _numQuads, cmd->getQuadCount(), cmd->getModelView()); _numQuads += cmd->getQuadCount(); } else if(commandType == RenderCommand::Type::CUSTOM_COMMAND) { flush(); auto cmd = static_cast(command); cmd->execute(); } else if(commandType == RenderCommand::Type::BATCH_COMMAND) { flush(); auto cmd = static_cast(command); cmd->execute(); } else if(commandType == RenderCommand::Type::GROUP_COMMAND) { flush(); auto cmd = static_cast(command); _renderStack.top().currentIndex = i + 1; //push new renderQueue to renderStack RenderStackElement element = {cmd->getRenderQueueID(), 0}; _renderStack.push(element); //Exit current loop break; } else { CCASSERT(true, "Invalid command"); flush(); } } //Draw the batched quads drawBatchedQuads(); currRenderQueue = _renderGroups[_renderStack.top().renderQueueID]; len = currRenderQueue.size(); //If pop the render stack if we already processed all the commands if(_renderStack.top().currentIndex + 1 >= len) { _renderStack.pop(); } } } for (size_t j = 0 ; j < _renderGroups.size(); j++) { //commands are owned by nodes // for (const auto &cmd : _renderGroups[j]) // { // cmd->releaseToCommandPool(); // } _renderGroups[j].clear(); } //Clear the stack incase gl view hasn't been initialized yet while(!_renderStack.empty()) { _renderStack.pop(); } RenderStackElement element = {DEFAULT_RENDER_QUEUE, 0}; _renderStack.push(element); _lastMaterialID = 0; } void Renderer::convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const kmMat4& modelView) { // kmMat4 matrixP, mvp; // kmGLGetMatrix(KM_GL_PROJECTION, &matrixP); // kmMat4Multiply(&mvp, &matrixP, &modelView); for(ssize_t i=0; ibl.vertices; kmVec3Transform(vec1, vec1, &modelView); kmVec3 *vec2 = (kmVec3*)&q->br.vertices; kmVec3Transform(vec2, vec2, &modelView); kmVec3 *vec3 = (kmVec3*)&q->tr.vertices; kmVec3Transform(vec3, vec3, &modelView); kmVec3 *vec4 = (kmVec3*)&q->tl.vertices; kmVec3Transform(vec4, vec4, &modelView); } } void Renderer::drawBatchedQuads() { //TODO we can improve the draw performance by insert material switching command before hand. int quadsToDraw = 0; int startQuad = 0; //Upload buffer to VBO if(_numQuads <= 0 || _batchedQuadCommands.empty()) { return; } if (Configuration::getInstance()->supportsShareableVAO()) { //Set VBO data glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); // option 1: subdata // glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] ); // option 2: data // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); // option 3: orphaning + glMapBuffer glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (_numQuads), nullptr, GL_DYNAMIC_DRAW); void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); memcpy(buf, _quads, sizeof(_quads[0])* (_numQuads)); glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); //Bind VAO GL::bindVAO(_quadVAO); } else { #define kQuadSize sizeof(_quads[0].bl) glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _numQuads , _quads, GL_DYNAMIC_DRAW); GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); // vertices glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices)); // colors glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); // tex coords glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); } //Start drawing verties in batch //for(auto i = _batchedQuadCommands.begin(); i != _batchedQuadCommands.end(); ++i) for(const auto& cmd : _batchedQuadCommands) { if(_lastMaterialID != cmd->getMaterialID()) { //Draw quads if(quadsToDraw > 0) { glDrawElements(GL_TRIANGLES, (GLsizei) quadsToDraw*6, GL_UNSIGNED_SHORT, (GLvoid*) (startQuad*6*sizeof(_indices[0])) ); CC_INCREMENT_GL_DRAWS(1); startQuad += quadsToDraw; quadsToDraw = 0; } //Use new material cmd->useMaterial(); _lastMaterialID = cmd->getMaterialID(); } quadsToDraw += cmd->getQuadCount(); } //Draw any remaining quad if(quadsToDraw > 0) { glDrawElements(GL_TRIANGLES, (GLsizei) quadsToDraw*6, GL_UNSIGNED_SHORT, (GLvoid*) (startQuad*6*sizeof(_indices[0])) ); CC_INCREMENT_GL_DRAWS(1); } if (Configuration::getInstance()->supportsShareableVAO()) { //Unbind VAO GL::bindVAO(0); } else { glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } _batchedQuadCommands.clear(); _numQuads = 0; } void Renderer::flush() { drawBatchedQuads(); _lastMaterialID = 0; } NS_CC_END ================================================ FILE: cocos2d/cocos/2d/renderer/CCRenderer.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_RENDERER_H_ #define __CC_RENDERER_H_ #include "CCPlatformMacros.h" #include "CCRenderCommand.h" #include "CCGLProgram.h" #include "CCGL.h" #include #include NS_CC_BEGIN class EventListenerCustom; class QuadCommand; /** Class that knows how to sort the Commands. Since the commands that have z==0 are "pushed back" in the correct order, the only Commands that need to be sorted, are the ones that have z <0 and z >0. And that is what this class does. */ class RenderQueue { public: void push_back(RenderCommand* command); ssize_t size() const; void sort(); RenderCommand* operator[](ssize_t index) const; void clear(); protected: std::vector _queueNegZ; std::vector _queue0; std::vector _queuePosZ; }; struct RenderStackElement { int renderQueueID; ssize_t currentIndex; }; class Renderer { public: static const int VBO_SIZE = 65536 / 6; static const int BATCH_QUADCOMMAND_RESEVER_SIZE = 64; Renderer(); ~Renderer(); //TODO manage GLView inside Render itself void initGLView(); //TODO support multiple viewport void addCommand(RenderCommand* command); void addCommand(RenderCommand* command, int renderQueue); void pushGroup(int renderQueueID); void popGroup(); int createRenderQueue(); void render(); protected: void setupIndices(); //Setup VBO or VAO based on OpenGL extensions void setupBuffer(); void setupVBOAndVAO(); void setupVBO(); void mapBuffers(); void drawBatchedQuads(); //Draw the previews queued quads and flush previous context void flush(); void convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const kmMat4& modelView); std::stack _commandGroupStack; std::stack _renderStack; std::vector _renderGroups; uint32_t _lastMaterialID; std::vector _batchedQuadCommands; V3F_C4B_T2F_Quad _quads[VBO_SIZE]; GLushort _indices[6 * VBO_SIZE]; GLuint _quadVAO; GLuint _buffersVBO[2]; //0: vertex 1: indices int _numQuads; bool _glViewAssigned; #if CC_ENABLE_CACHE_TEXTURE_DATA EventListenerCustom* _cacheTextureListener; #endif }; NS_CC_END #endif //__CC_RENDERER_H_ ================================================ FILE: cocos2d/cocos/2d/uthash.h ================================================ /* Copyright (c) 2003-2013, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 UTHASH_H #define UTHASH_H #include /* memcmp,strlen */ #include /* ptrdiff_t */ #include /* exit() */ /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed or, for VS2008 where neither is available, uses casting workarounds. */ #ifdef _MSC_VER /* MS compiler */ #if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ #define DECLTYPE(x) (decltype(x)) #else /* VS2008 or older (or VS2010 in C mode) */ #define NO_DECLTYPE #define DECLTYPE(x) #endif #else /* GNU, Sun and other compilers */ #define DECLTYPE(x) (__typeof(x)) #endif #ifdef NO_DECLTYPE #define DECLTYPE_ASSIGN(dst,src) \ do { \ char **_da_dst = (char**)(&(dst)); \ *_da_dst = (char*)(src); \ } while(0) #else #define DECLTYPE_ASSIGN(dst,src) \ do { \ (dst) = DECLTYPE(dst)(src); \ } while(0) #endif /* a number of the hash function use uint32_t which isn't defined on win32 */ #ifdef _MSC_VER typedef unsigned int uint32_t; typedef unsigned char uint8_t; #else #include /* uint32_t */ #endif #define UTHASH_VERSION 1.9.8 #ifndef uthash_fatal #define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ #endif #ifndef uthash_malloc #define uthash_malloc(sz) malloc(sz) /* malloc fcn */ #endif #ifndef uthash_free #define uthash_free(ptr,sz) free(ptr) /* free fcn */ #endif #ifndef uthash_noexpand_fyi #define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ #endif #ifndef uthash_expand_fyi #define uthash_expand_fyi(tbl) /* can be defined to log expands */ #endif /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS 32 /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS_LOG2 5 /* lg2 of initial number of buckets */ #define HASH_BKT_CAPACITY_THRESH 10 /* expand when bucket count reaches */ /* calculate the element whose hash handle address is hhe */ #define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) #define HASH_FIND(hh,head,keyptr,keylen,out) \ do { \ unsigned _hf_bkt,_hf_hashv; \ out=NULL; \ if (head) { \ HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \ if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \ HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \ keyptr,keylen,out); \ } \ } \ } while (0) #ifdef HASH_BLOOM #define HASH_BLOOM_BITLEN (1ULL << HASH_BLOOM) #define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8) + ((HASH_BLOOM_BITLEN%8) ? 1:0) #define HASH_BLOOM_MAKE(tbl) \ do { \ (tbl)->bloom_nbits = HASH_BLOOM; \ (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \ memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \ (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } while (0) #define HASH_BLOOM_FREE(tbl) \ do { \ uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ } while (0) #define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8))) #define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8))) #define HASH_BLOOM_ADD(tbl,hashv) \ HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) #define HASH_BLOOM_TEST(tbl,hashv) \ HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) #else #define HASH_BLOOM_MAKE(tbl) #define HASH_BLOOM_FREE(tbl) #define HASH_BLOOM_ADD(tbl,hashv) #define HASH_BLOOM_TEST(tbl,hashv) (1) #define HASH_BLOOM_BYTELEN 0 #endif #define HASH_MAKE_TABLE(hh,head) \ do { \ (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \ sizeof(UT_hash_table)); \ if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \ memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \ (head)->hh.tbl->tail = &((head)->hh); \ (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \ memset((head)->hh.tbl->buckets, 0, \ HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ HASH_BLOOM_MAKE((head)->hh.tbl); \ (head)->hh.tbl->signature = HASH_SIGNATURE; \ } while(0) #define HASH_ADD(hh,head,fieldname,keylen_in,add) \ HASH_ADD_KEYPTR(hh,head,&((add)->fieldname),keylen_in,add) #define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \ do { \ replaced=NULL; \ HASH_FIND(hh,head,&((add)->fieldname),keylen_in,replaced); \ if (replaced!=NULL) { \ HASH_DELETE(hh,head,replaced); \ }; \ HASH_ADD(hh,head,fieldname,keylen_in,add); \ } while(0) #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ do { \ unsigned _ha_bkt; \ (add)->hh.next = NULL; \ (add)->hh.key = (char*)keyptr; \ (add)->hh.keylen = (unsigned)keylen_in; \ if (!(head)) { \ head = (add); \ (head)->hh.prev = NULL; \ HASH_MAKE_TABLE(hh,head); \ } else { \ (head)->hh.tbl->tail->next = (add); \ (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ (head)->hh.tbl->tail = &((add)->hh); \ } \ (head)->hh.tbl->num_items++; \ (add)->hh.tbl = (head)->hh.tbl; \ HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \ (add)->hh.hashv, _ha_bkt); \ HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \ HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \ HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \ HASH_FSCK(hh,head); \ } while(0) #define HASH_TO_BKT( hashv, num_bkts, bkt ) \ do { \ bkt = ((hashv) & ((num_bkts) - 1)); \ } while(0) /* delete "delptr" from the hash table. * "the usual" patch-up process for the app-order doubly-linked-list. * The use of _hd_hh_del below deserves special explanation. * These used to be expressed using (delptr) but that led to a bug * if someone used the same symbol for the head and deletee, like * HASH_DELETE(hh,users,users); * We want that to work, but by changing the head (users) below * we were forfeiting our ability to further refer to the deletee (users) * in the patch-up process. Solution: use scratch space to * copy the deletee pointer, then the latter references are via that * scratch pointer rather than through the repointed (users) symbol. */ #define HASH_DELETE(hh,head,delptr) \ do { \ unsigned _hd_bkt; \ struct UT_hash_handle *_hd_hh_del; \ if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \ uthash_free((head)->hh.tbl->buckets, \ (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \ HASH_BLOOM_FREE((head)->hh.tbl); \ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ head = NULL; \ } else { \ _hd_hh_del = &((delptr)->hh); \ if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \ (head)->hh.tbl->tail = \ (UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \ (head)->hh.tbl->hho); \ } \ if ((delptr)->hh.prev) { \ ((UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \ (head)->hh.tbl->hho))->next = (delptr)->hh.next; \ } else { \ DECLTYPE_ASSIGN(head,(delptr)->hh.next); \ } \ if (_hd_hh_del->next) { \ ((UT_hash_handle*)((ptrdiff_t)_hd_hh_del->next + \ (head)->hh.tbl->hho))->prev = \ _hd_hh_del->prev; \ } \ HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ (head)->hh.tbl->num_items--; \ } \ HASH_FSCK(hh,head); \ } while (0) /* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ #define HASH_FIND_STR(head,findstr,out) \ HASH_FIND(hh,head,findstr,strlen(findstr),out) #define HASH_ADD_STR(head,strfield,add) \ HASH_ADD(hh,head,strfield,strlen(add->strfield),add) #define HASH_REPLACE_STR(head,strfield,add,replaced) \ HASH_REPLACE(hh,head,strfield,strlen(add->strfield),add,replaced) #define HASH_FIND_INT(head,findint,out) \ HASH_FIND(hh,head,findint,sizeof(int),out) #define HASH_ADD_INT(head,intfield,add) \ HASH_ADD(hh,head,intfield,sizeof(int),add) #define HASH_REPLACE_INT(head,intfield,add,replaced) \ HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced) #define HASH_FIND_PTR(head,findptr,out) \ HASH_FIND(hh,head,findptr,sizeof(void *),out) #define HASH_ADD_PTR(head,ptrfield,add) \ HASH_ADD(hh,head,ptrfield,sizeof(void *),add) #define HASH_REPLACE_PTR(head,ptrfield,add) \ HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced) #define HASH_DEL(head,delptr) \ HASH_DELETE(hh,head,delptr) /* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined. * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. */ #ifdef HASH_DEBUG #define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) #define HASH_FSCK(hh,head) \ do { \ unsigned _bkt_i; \ unsigned _count, _bkt_count; \ char *_prev; \ struct UT_hash_handle *_thh; \ if (head) { \ _count = 0; \ for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \ _bkt_count = 0; \ _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ _prev = NULL; \ while (_thh) { \ if (_prev != (char*)(_thh->hh_prev)) { \ HASH_OOPS("invalid hh_prev %p, actual %p\n", \ _thh->hh_prev, _prev ); \ } \ _bkt_count++; \ _prev = (char*)(_thh); \ _thh = _thh->hh_next; \ } \ _count += _bkt_count; \ if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ HASH_OOPS("invalid bucket count %d, actual %d\n", \ (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ } \ } \ if (_count != (head)->hh.tbl->num_items) { \ HASH_OOPS("invalid hh item count %d, actual %d\n", \ (head)->hh.tbl->num_items, _count ); \ } \ /* traverse hh in app order; check next/prev integrity, count */ \ _count = 0; \ _prev = NULL; \ _thh = &(head)->hh; \ while (_thh) { \ _count++; \ if (_prev !=(char*)(_thh->prev)) { \ HASH_OOPS("invalid prev %p, actual %p\n", \ _thh->prev, _prev ); \ } \ _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \ _thh = ( _thh->next ? (UT_hash_handle*)((char*)(_thh->next) + \ (head)->hh.tbl->hho) : NULL ); \ } \ if (_count != (head)->hh.tbl->num_items) { \ HASH_OOPS("invalid app item count %d, actual %d\n", \ (head)->hh.tbl->num_items, _count ); \ } \ } \ } while (0) #else #define HASH_FSCK(hh,head) #endif /* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to * the descriptor to which this macro is defined for tuning the hash function. * The app can #include to get the prototype for write(2). */ #ifdef HASH_EMIT_KEYS #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ do { \ unsigned _klen = fieldlen; \ write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ write(HASH_EMIT_KEYS, keyptr, fieldlen); \ } while (0) #else #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) #endif /* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ #ifdef HASH_FUNCTION #define HASH_FCN HASH_FUNCTION #else #define HASH_FCN HASH_JEN #endif /* The Bernstein hash function, used in Perl prior to v5.6 */ #define HASH_BER(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _hb_keylen=keylen; \ char *_hb_key=(char*)(key); \ (hashv) = 0; \ while (_hb_keylen--) { (hashv) = ((hashv) * 33) + *_hb_key++; } \ bkt = (hashv) & (num_bkts-1); \ } while (0) /* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ #define HASH_SAX(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _sx_i; \ char *_hs_key=(char*)(key); \ hashv = 0; \ for(_sx_i=0; _sx_i < keylen; _sx_i++) \ hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ bkt = hashv & (num_bkts-1); \ } while (0) #define HASH_FNV(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _fn_i; \ char *_hf_key=(char*)(key); \ hashv = 2166136261UL; \ for(_fn_i=0; _fn_i < keylen; _fn_i++) \ hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \ bkt = hashv & (num_bkts-1); \ } while(0) #define HASH_OAT(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _ho_i; \ char *_ho_key=(char*)(key); \ hashv = 0; \ for(_ho_i=0; _ho_i < keylen; _ho_i++) { \ hashv += _ho_key[_ho_i]; \ hashv += (hashv << 10); \ hashv ^= (hashv >> 6); \ } \ hashv += (hashv << 3); \ hashv ^= (hashv >> 11); \ hashv += (hashv << 15); \ bkt = hashv & (num_bkts-1); \ } while(0) #define HASH_JEN_MIX(a,b,c) \ do { \ a -= b; a -= c; a ^= ( c >> 13 ); \ b -= c; b -= a; b ^= ( a << 8 ); \ c -= a; c -= b; c ^= ( b >> 13 ); \ a -= b; a -= c; a ^= ( c >> 12 ); \ b -= c; b -= a; b ^= ( a << 16 ); \ c -= a; c -= b; c ^= ( b >> 5 ); \ a -= b; a -= c; a ^= ( c >> 3 ); \ b -= c; b -= a; b ^= ( a << 10 ); \ c -= a; c -= b; c ^= ( b >> 15 ); \ } while (0) #define HASH_JEN(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _hj_i,_hj_j,_hj_k; \ unsigned char *_hj_key=(unsigned char*)(key); \ hashv = 0xfeedbeef; \ _hj_i = _hj_j = 0x9e3779b9; \ _hj_k = (unsigned)keylen; \ while (_hj_k >= 12) { \ _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \ + ( (unsigned)_hj_key[2] << 16 ) \ + ( (unsigned)_hj_key[3] << 24 ) ); \ _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \ + ( (unsigned)_hj_key[6] << 16 ) \ + ( (unsigned)_hj_key[7] << 24 ) ); \ hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \ + ( (unsigned)_hj_key[10] << 16 ) \ + ( (unsigned)_hj_key[11] << 24 ) ); \ \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ \ _hj_key += 12; \ _hj_k -= 12; \ } \ hashv += keylen; \ switch ( _hj_k ) { \ case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); \ case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); \ case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); \ case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); \ case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); \ case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); \ case 5: _hj_j += _hj_key[4]; \ case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); \ case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); \ case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); \ case 1: _hj_i += _hj_key[0]; \ } \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ bkt = hashv & (num_bkts-1); \ } while(0) /* The Paul Hsieh hash function */ #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) #define get16bits(d) (*((const uint16_t *) (d))) #endif #if !defined (get16bits) #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \ +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif #define HASH_SFH(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned char *_sfh_key=(unsigned char*)(key); \ uint32_t _sfh_tmp, _sfh_len = keylen; \ \ int _sfh_rem = _sfh_len & 3; \ _sfh_len >>= 2; \ hashv = 0xcafebabe; \ \ /* Main loop */ \ for (;_sfh_len > 0; _sfh_len--) { \ hashv += get16bits (_sfh_key); \ _sfh_tmp = (uint32_t)(get16bits (_sfh_key+2)) << 11 ^ hashv; \ hashv = (hashv << 16) ^ _sfh_tmp; \ _sfh_key += 2*sizeof (uint16_t); \ hashv += hashv >> 11; \ } \ \ /* Handle end cases */ \ switch (_sfh_rem) { \ case 3: hashv += get16bits (_sfh_key); \ hashv ^= hashv << 16; \ hashv ^= (uint32_t)(_sfh_key[sizeof (uint16_t)] << 18); \ hashv += hashv >> 11; \ break; \ case 2: hashv += get16bits (_sfh_key); \ hashv ^= hashv << 11; \ hashv += hashv >> 17; \ break; \ case 1: hashv += *_sfh_key; \ hashv ^= hashv << 10; \ hashv += hashv >> 1; \ } \ \ /* Force "avalanching" of final 127 bits */ \ hashv ^= hashv << 3; \ hashv += hashv >> 5; \ hashv ^= hashv << 4; \ hashv += hashv >> 17; \ hashv ^= hashv << 25; \ hashv += hashv >> 6; \ bkt = hashv & (num_bkts-1); \ } while(0) #ifdef HASH_USING_NO_STRICT_ALIASING /* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. * MurmurHash uses the faster approach only on CPU's where we know it's safe. * * Note the preprocessor built-in defines can be emitted using: * * gcc -m64 -dM -E - < /dev/null (on gcc) * cc -## a.c (where a.c is a simple test file) (Sun Studio) */ #if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)) #define MUR_GETBLOCK(p,i) p[i] #else /* non intel */ #define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 0x3) == 0) #define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 0x3) == 1) #define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 0x3) == 2) #define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 0x3) == 3) #define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) #if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) #define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) #define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) #define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) #else /* assume little endian non-intel */ #define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) #define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) #define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) #endif #define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \ (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ MUR_ONE_THREE(p)))) #endif #define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) #define MUR_FMIX(_h) \ do { \ _h ^= _h >> 16; \ _h *= 0x85ebca6b; \ _h ^= _h >> 13; \ _h *= 0xc2b2ae35l; \ _h ^= _h >> 16; \ } while(0) #define HASH_MUR(key,keylen,num_bkts,hashv,bkt) \ do { \ const uint8_t *_mur_data = (const uint8_t*)(key); \ const int _mur_nblocks = (keylen) / 4; \ uint32_t _mur_h1 = 0xf88D5353; \ uint32_t _mur_c1 = 0xcc9e2d51; \ uint32_t _mur_c2 = 0x1b873593; \ uint32_t _mur_k1 = 0; \ const uint8_t *_mur_tail; \ const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+_mur_nblocks*4); \ int _mur_i; \ for(_mur_i = -_mur_nblocks; _mur_i; _mur_i++) { \ _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \ _mur_k1 *= _mur_c1; \ _mur_k1 = MUR_ROTL32(_mur_k1,15); \ _mur_k1 *= _mur_c2; \ \ _mur_h1 ^= _mur_k1; \ _mur_h1 = MUR_ROTL32(_mur_h1,13); \ _mur_h1 = _mur_h1*5+0xe6546b64; \ } \ _mur_tail = (const uint8_t*)(_mur_data + _mur_nblocks*4); \ _mur_k1=0; \ switch((keylen) & 3) { \ case 3: _mur_k1 ^= _mur_tail[2] << 16; \ case 2: _mur_k1 ^= _mur_tail[1] << 8; \ case 1: _mur_k1 ^= _mur_tail[0]; \ _mur_k1 *= _mur_c1; \ _mur_k1 = MUR_ROTL32(_mur_k1,15); \ _mur_k1 *= _mur_c2; \ _mur_h1 ^= _mur_k1; \ } \ _mur_h1 ^= (keylen); \ MUR_FMIX(_mur_h1); \ hashv = _mur_h1; \ bkt = hashv & (num_bkts-1); \ } while(0) #endif /* HASH_USING_NO_STRICT_ALIASING */ /* key comparison function; return 0 if keys equal */ #define HASH_KEYCMP(a,b,len) memcmp(a,b,len) /* iterate over items in a known bucket to find desired item */ #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \ do { \ if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \ else out=NULL; \ while (out) { \ if ((out)->hh.keylen == keylen_in) { \ if ((HASH_KEYCMP((out)->hh.key,keyptr,keylen_in)) == 0) break; \ } \ if ((out)->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,(out)->hh.hh_next)); \ else out = NULL; \ } \ } while(0) /* add an item to a bucket */ #define HASH_ADD_TO_BKT(head,addhh) \ do { \ head.count++; \ (addhh)->hh_next = head.hh_head; \ (addhh)->hh_prev = NULL; \ if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \ (head).hh_head=addhh; \ if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \ && (addhh)->tbl->noexpand != 1) { \ HASH_EXPAND_BUCKETS((addhh)->tbl); \ } \ } while(0) /* remove an item from a given bucket */ #define HASH_DEL_IN_BKT(hh,head,hh_del) \ (head).count--; \ if ((head).hh_head == hh_del) { \ (head).hh_head = hh_del->hh_next; \ } \ if (hh_del->hh_prev) { \ hh_del->hh_prev->hh_next = hh_del->hh_next; \ } \ if (hh_del->hh_next) { \ hh_del->hh_next->hh_prev = hh_del->hh_prev; \ } /* Bucket expansion has the effect of doubling the number of buckets * and redistributing the items into the new buckets. Ideally the * items will distribute more or less evenly into the new buckets * (the extent to which this is true is a measure of the quality of * the hash function as it applies to the key domain). * * With the items distributed into more buckets, the chain length * (item count) in each bucket is reduced. Thus by expanding buckets * the hash keeps a bound on the chain length. This bounded chain * length is the essence of how a hash provides constant time lookup. * * The calculation of tbl->ideal_chain_maxlen below deserves some * explanation. First, keep in mind that we're calculating the ideal * maximum chain length based on the *new* (doubled) bucket count. * In fractions this is just n/b (n=number of items,b=new num buckets). * Since the ideal chain length is an integer, we want to calculate * ceil(n/b). We don't depend on floating point arithmetic in this * hash, so to calculate ceil(n/b) with integers we could write * * ceil(n/b) = (n/b) + ((n%b)?1:0) * * and in fact a previous version of this hash did just that. * But now we have improved things a bit by recognizing that b is * always a power of two. We keep its base 2 log handy (call it lb), * so now we can write this with a bit shift and logical AND: * * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) * */ #define HASH_EXPAND_BUCKETS(tbl) \ do { \ unsigned _he_bkt; \ unsigned _he_bkt_i; \ struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ if (!_he_new_buckets) { uthash_fatal( "out of memory"); } \ memset(_he_new_buckets, 0, \ 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ tbl->ideal_chain_maxlen = \ (tbl->num_items >> (tbl->log2_num_buckets+1)) + \ ((tbl->num_items & ((tbl->num_buckets*2)-1)) ? 1 : 0); \ tbl->nonideal_items = 0; \ for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \ { \ _he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \ while (_he_thh) { \ _he_hh_nxt = _he_thh->hh_next; \ HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \ _he_newbkt = &(_he_new_buckets[ _he_bkt ]); \ if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \ tbl->nonideal_items++; \ _he_newbkt->expand_mult = _he_newbkt->count / \ tbl->ideal_chain_maxlen; \ } \ _he_thh->hh_prev = NULL; \ _he_thh->hh_next = _he_newbkt->hh_head; \ if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \ _he_thh; \ _he_newbkt->hh_head = _he_thh; \ _he_thh = _he_hh_nxt; \ } \ } \ uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \ tbl->num_buckets *= 2; \ tbl->log2_num_buckets++; \ tbl->buckets = _he_new_buckets; \ tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \ (tbl->ineff_expands+1) : 0; \ if (tbl->ineff_expands > 1) { \ tbl->noexpand=1; \ uthash_noexpand_fyi(tbl); \ } \ uthash_expand_fyi(tbl); \ } while(0) /* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ /* Note that HASH_SORT assumes the hash handle name to be hh. * HASH_SRT was added to allow the hash handle name to be passed in. */ #define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) #define HASH_SRT(hh,head,cmpfcn) \ do { \ unsigned _hs_i; \ unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \ struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ if (head) { \ _hs_insize = 1; \ _hs_looping = 1; \ _hs_list = &((head)->hh); \ while (_hs_looping) { \ _hs_p = _hs_list; \ _hs_list = NULL; \ _hs_tail = NULL; \ _hs_nmerges = 0; \ while (_hs_p) { \ _hs_nmerges++; \ _hs_q = _hs_p; \ _hs_psize = 0; \ for ( _hs_i = 0; _hs_i < _hs_insize; _hs_i++ ) { \ _hs_psize++; \ _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ ((void*)((char*)(_hs_q->next) + \ (head)->hh.tbl->hho)) : NULL); \ if (! (_hs_q) ) break; \ } \ _hs_qsize = _hs_insize; \ while ((_hs_psize > 0) || ((_hs_qsize > 0) && _hs_q )) { \ if (_hs_psize == 0) { \ _hs_e = _hs_q; \ _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ ((void*)((char*)(_hs_q->next) + \ (head)->hh.tbl->hho)) : NULL); \ _hs_qsize--; \ } else if ( (_hs_qsize == 0) || !(_hs_q) ) { \ _hs_e = _hs_p; \ _hs_p = (UT_hash_handle*)((_hs_p->next) ? \ ((void*)((char*)(_hs_p->next) + \ (head)->hh.tbl->hho)) : NULL); \ _hs_psize--; \ } else if (( \ cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \ DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \ ) <= 0) { \ _hs_e = _hs_p; \ _hs_p = (UT_hash_handle*)((_hs_p->next) ? \ ((void*)((char*)(_hs_p->next) + \ (head)->hh.tbl->hho)) : NULL); \ _hs_psize--; \ } else { \ _hs_e = _hs_q; \ _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ ((void*)((char*)(_hs_q->next) + \ (head)->hh.tbl->hho)) : NULL); \ _hs_qsize--; \ } \ if ( _hs_tail ) { \ _hs_tail->next = ((_hs_e) ? \ ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \ } else { \ _hs_list = _hs_e; \ } \ _hs_e->prev = ((_hs_tail) ? \ ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \ _hs_tail = _hs_e; \ } \ _hs_p = _hs_q; \ } \ _hs_tail->next = NULL; \ if ( _hs_nmerges <= 1 ) { \ _hs_looping=0; \ (head)->hh.tbl->tail = _hs_tail; \ DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ } \ _hs_insize *= 2; \ } \ HASH_FSCK(hh,head); \ } \ } while (0) /* This function selects items from one hash into another hash. * The end result is that the selected items have dual presence * in both hashes. There is no copy of the items made; rather * they are added into the new hash through a secondary hash * hash handle that must be present in the structure. */ #define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ do { \ unsigned _src_bkt, _dst_bkt; \ void *_last_elt=NULL, *_elt; \ UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \ ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \ if (src) { \ for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \ _src_hh; \ _src_hh = _src_hh->hh_next) { \ _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ if (cond(_elt)) { \ _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ _dst_hh->key = _src_hh->key; \ _dst_hh->keylen = _src_hh->keylen; \ _dst_hh->hashv = _src_hh->hashv; \ _dst_hh->prev = _last_elt; \ _dst_hh->next = NULL; \ if (_last_elt_hh) { _last_elt_hh->next = _elt; } \ if (!dst) { \ DECLTYPE_ASSIGN(dst,_elt); \ HASH_MAKE_TABLE(hh_dst,dst); \ } else { \ _dst_hh->tbl = (dst)->hh_dst.tbl; \ } \ HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \ (dst)->hh_dst.tbl->num_items++; \ _last_elt = _elt; \ _last_elt_hh = _dst_hh; \ } \ } \ } \ } \ HASH_FSCK(hh_dst,dst); \ } while (0) #define HASH_CLEAR(hh,head) \ do { \ if (head) { \ uthash_free((head)->hh.tbl->buckets, \ (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \ HASH_BLOOM_FREE((head)->hh.tbl); \ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ (head)=NULL; \ } \ } while(0) #define HASH_OVERHEAD(hh,head) \ (size_t)((((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \ ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \ (sizeof(UT_hash_table)) + \ (HASH_BLOOM_BYTELEN))) #ifdef NO_DECLTYPE #define HASH_ITER(hh,head,el,tmp) \ for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \ el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL)) #else #define HASH_ITER(hh,head,el,tmp) \ for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \ el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)->hh.next:NULL)) #endif /* obtain a count of items in the hash */ #define HASH_COUNT(head) HASH_CNT(hh,head) #define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0) typedef struct UT_hash_bucket { struct UT_hash_handle *hh_head; unsigned count; /* expand_mult is normally set to 0. In this situation, the max chain length * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If * the bucket's chain exceeds this length, bucket expansion is triggered). * However, setting expand_mult to a non-zero value delays bucket expansion * (that would be triggered by additions to this particular bucket) * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. * (The multiplier is simply expand_mult+1). The whole idea of this * multiplier is to reduce bucket expansions, since they are expensive, in * situations where we know that a particular bucket tends to be overused. * It is better to let its chain length grow to a longer yet-still-bounded * value, than to do an O(n) bucket expansion too often. */ unsigned expand_mult; } UT_hash_bucket; /* random signature used only to find hash tables in external analysis */ #define HASH_SIGNATURE 0xa0111fe1 #define HASH_BLOOM_SIGNATURE 0xb12220f2 typedef struct UT_hash_table { UT_hash_bucket *buckets; unsigned num_buckets, log2_num_buckets; unsigned num_items; struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ /* in an ideal situation (all buckets used equally), no bucket would have * more than ceil(#items/#buckets) items. that's the ideal chain length. */ unsigned ideal_chain_maxlen; /* nonideal_items is the number of items in the hash whose chain position * exceeds the ideal chain maxlen. these items pay the penalty for an uneven * hash distribution; reaching them in a chain traversal takes >ideal steps */ unsigned nonideal_items; /* ineffective expands occur when a bucket doubling was performed, but * afterward, more than half the items in the hash had nonideal chain * positions. If this happens on two consecutive expansions we inhibit any * further expansion, as it's not helping; this happens when the hash * function isn't a good fit for the key domain. When expansion is inhibited * the hash will still work, albeit no longer in constant time. */ unsigned ineff_expands, noexpand; uint32_t signature; /* used only to find hash tables in external analysis */ #ifdef HASH_BLOOM uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ uint8_t *bloom_bv; char bloom_nbits; #endif } UT_hash_table; typedef struct UT_hash_handle { struct UT_hash_table *tbl; void *prev; /* prev element in app order */ void *next; /* next element in app order */ struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ struct UT_hash_handle *hh_next; /* next hh in bucket order */ void *key; /* ptr to enclosing struct's key */ unsigned keylen; /* enclosing struct's key len */ unsigned hashv; /* result of hash-fcn(key) */ } UT_hash_handle; #endif /* UTHASH_H */ ================================================ FILE: cocos2d/cocos/2d/utlist.h ================================================ /* Copyright (c) 2007-2013, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 UTLIST_H #define UTLIST_H #define UTLIST_VERSION 1.9.8 #include /* * This file contains macros to manipulate singly and doubly-linked lists. * * 1. LL_ macros: singly-linked lists. * 2. DL_ macros: doubly-linked lists. * 3. CDL_ macros: circular doubly-linked lists. * * To use singly-linked lists, your structure must have a "next" pointer. * To use doubly-linked lists, your structure must "prev" and "next" pointers. * Either way, the pointer to the head of the list must be initialized to NULL. * * ----------------.EXAMPLE ------------------------- * struct item { * int id; * struct item *prev, *next; * } * * struct item *list = NULL: * * int main() { * struct item *item; * ... allocate and populate item ... * DL_APPEND(list, item); * } * -------------------------------------------------- * * For doubly-linked lists, the append and delete macros are O(1) * For singly-linked lists, append and delete are O(n) but prepend is O(1) * The sort macro is O(n log(n)) for all types of single/double/circular lists. */ /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ code), this code uses whatever method is needed or, for VS2008 where neither is available, uses casting workarounds. */ #ifdef _MSC_VER /* MS compiler */ #if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ #define LDECLTYPE(x) decltype(x) #else /* VS2008 or older (or VS2010 in C mode) */ #define NO_DECLTYPE #define LDECLTYPE(x) char* #endif #else /* GNU, Sun and other compilers */ #define LDECLTYPE(x) __typeof(x) #endif /* for VS2008 we use some workarounds to get around the lack of decltype, * namely, we always reassign our tmp variable to the list head if we need * to dereference its prev/next pointers, and save/restore the real head.*/ #ifdef NO_DECLTYPE #define _SV(elt,list) _tmp = (char*)(list); {char **_alias = (char**)&(list); *_alias = (elt); } #define _NEXT(elt,list,next) ((char*)((list)->next)) #define _NEXTASGN(elt,list,to,next) { char **_alias = (char**)&((list)->next); *_alias=(char*)(to); } /* #define _PREV(elt,list,prev) ((char*)((list)->prev)) */ #define _PREVASGN(elt,list,to,prev) { char **_alias = (char**)&((list)->prev); *_alias=(char*)(to); } #define _RS(list) { char **_alias = (char**)&(list); *_alias=_tmp; } #define _CASTASGN(a,b) { char **_alias = (char**)&(a); *_alias=(char*)(b); } #else #define _SV(elt,list) #define _NEXT(elt,list,next) ((elt)->next) #define _NEXTASGN(elt,list,to,next) ((elt)->next)=(to) /* #define _PREV(elt,list,prev) ((elt)->prev) */ #define _PREVASGN(elt,list,to,prev) ((elt)->prev)=(to) #define _RS(list) #define _CASTASGN(a,b) (a)=(b) #endif /****************************************************************************** * The sort macro is an adaptation of Simon Tatham's O(n log(n)) mergesort * * Unwieldy variable names used here to avoid shadowing passed-in variables. * *****************************************************************************/ #define LL_SORT(list, cmp) \ LL_SORT2(list, cmp, next) #define LL_SORT2(list, cmp, next) \ do { \ LDECLTYPE(list) _ls_p; \ LDECLTYPE(list) _ls_q; \ LDECLTYPE(list) _ls_e; \ LDECLTYPE(list) _ls_tail; \ int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ if (list) { \ _ls_insize = 1; \ _ls_looping = 1; \ while (_ls_looping) { \ _CASTASGN(_ls_p,list); \ list = NULL; \ _ls_tail = NULL; \ _ls_nmerges = 0; \ while (_ls_p) { \ _ls_nmerges++; \ _ls_q = _ls_p; \ _ls_psize = 0; \ for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ _ls_psize++; \ _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list,next); _RS(list); \ if (!_ls_q) break; \ } \ _ls_qsize = _ls_insize; \ while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ if (_ls_psize == 0) { \ _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = \ _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--; \ } else if (_ls_qsize == 0 || !_ls_q) { \ _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = \ _NEXT(_ls_p,list,next); _RS(list); _ls_psize--; \ } else if (cmp(_ls_p,_ls_q) <= 0) { \ _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = \ _NEXT(_ls_p,list,next); _RS(list); _ls_psize--; \ } else { \ _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = \ _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--; \ } \ if (_ls_tail) { \ _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list); \ } else { \ _CASTASGN(list,_ls_e); \ } \ _ls_tail = _ls_e; \ } \ _ls_p = _ls_q; \ } \ if (_ls_tail) { \ _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list); \ } \ if (_ls_nmerges <= 1) { \ _ls_looping=0; \ } \ _ls_insize *= 2; \ } \ } \ } while (0) #define DL_SORT(list, cmp) \ DL_SORT2(list, cmp, prev, next) #define DL_SORT2(list, cmp, prev, next) \ do { \ LDECLTYPE(list) _ls_p; \ LDECLTYPE(list) _ls_q; \ LDECLTYPE(list) _ls_e; \ LDECLTYPE(list) _ls_tail; \ int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ if (list) { \ _ls_insize = 1; \ _ls_looping = 1; \ while (_ls_looping) { \ _CASTASGN(_ls_p,list); \ list = NULL; \ _ls_tail = NULL; \ _ls_nmerges = 0; \ while (_ls_p) { \ _ls_nmerges++; \ _ls_q = _ls_p; \ _ls_psize = 0; \ for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ _ls_psize++; \ _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list,next); _RS(list); \ if (!_ls_q) break; \ } \ _ls_qsize = _ls_insize; \ while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ if (_ls_psize == 0) { \ _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = \ _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--; \ } else if (_ls_qsize == 0 || !_ls_q) { \ _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = \ _NEXT(_ls_p,list,next); _RS(list); _ls_psize--; \ } else if (cmp(_ls_p,_ls_q) <= 0) { \ _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = \ _NEXT(_ls_p,list,next); _RS(list); _ls_psize--; \ } else { \ _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = \ _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--; \ } \ if (_ls_tail) { \ _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list); \ } else { \ _CASTASGN(list,_ls_e); \ } \ _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail,prev); _RS(list); \ _ls_tail = _ls_e; \ } \ _ls_p = _ls_q; \ } \ _CASTASGN(list->prev, _ls_tail); \ _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list); \ if (_ls_nmerges <= 1) { \ _ls_looping=0; \ } \ _ls_insize *= 2; \ } \ } \ } while (0) #define CDL_SORT(list, cmp) \ CDL_SORT2(list, cmp, prev, next) #define CDL_SORT2(list, cmp, prev, next) \ do { \ LDECLTYPE(list) _ls_p; \ LDECLTYPE(list) _ls_q; \ LDECLTYPE(list) _ls_e; \ LDECLTYPE(list) _ls_tail; \ LDECLTYPE(list) _ls_oldhead; \ LDECLTYPE(list) _tmp; \ int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \ if (list) { \ _ls_insize = 1; \ _ls_looping = 1; \ while (_ls_looping) { \ _CASTASGN(_ls_p,list); \ _CASTASGN(_ls_oldhead,list); \ list = NULL; \ _ls_tail = NULL; \ _ls_nmerges = 0; \ while (_ls_p) { \ _ls_nmerges++; \ _ls_q = _ls_p; \ _ls_psize = 0; \ for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \ _ls_psize++; \ _SV(_ls_q,list); \ if (_NEXT(_ls_q,list,next) == _ls_oldhead) { \ _ls_q = NULL; \ } else { \ _ls_q = _NEXT(_ls_q,list,next); \ } \ _RS(list); \ if (!_ls_q) break; \ } \ _ls_qsize = _ls_insize; \ while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \ if (_ls_psize == 0) { \ _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = \ _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--; \ if (_ls_q == _ls_oldhead) { _ls_q = NULL; } \ } else if (_ls_qsize == 0 || !_ls_q) { \ _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = \ _NEXT(_ls_p,list,next); _RS(list); _ls_psize--; \ if (_ls_p == _ls_oldhead) { _ls_p = NULL; } \ } else if (cmp(_ls_p,_ls_q) <= 0) { \ _ls_e = _ls_p; _SV(_ls_p,list); _ls_p = \ _NEXT(_ls_p,list,next); _RS(list); _ls_psize--; \ if (_ls_p == _ls_oldhead) { _ls_p = NULL; } \ } else { \ _ls_e = _ls_q; _SV(_ls_q,list); _ls_q = \ _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--; \ if (_ls_q == _ls_oldhead) { _ls_q = NULL; } \ } \ if (_ls_tail) { \ _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list); \ } else { \ _CASTASGN(list,_ls_e); \ } \ _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail,prev); _RS(list); \ _ls_tail = _ls_e; \ } \ _ls_p = _ls_q; \ } \ _CASTASGN(list->prev,_ls_tail); \ _CASTASGN(_tmp,list); \ _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_tmp,next); _RS(list); \ if (_ls_nmerges <= 1) { \ _ls_looping=0; \ } \ _ls_insize *= 2; \ } \ } \ } while (0) /****************************************************************************** * singly linked list macros (non-circular) * *****************************************************************************/ #define LL_PREPEND(head,add) \ LL_PREPEND2(head,add,next) #define LL_PREPEND2(head,add,next) \ do { \ (add)->next = head; \ head = add; \ } while (0) #define LL_CONCAT(head1,head2) \ LL_CONCAT2(head1,head2,next) #define LL_CONCAT2(head1,head2,next) \ do { \ LDECLTYPE(head1) _tmp; \ if (head1) { \ _tmp = head1; \ while (_tmp->next) { _tmp = _tmp->next; } \ _tmp->next=(head2); \ } else { \ (head1)=(head2); \ } \ } while (0) #define LL_APPEND(head,add) \ LL_APPEND2(head,add,next) #define LL_APPEND2(head,add,next) \ do { \ LDECLTYPE(head) _tmp; \ (add)->next=NULL; \ if (head) { \ _tmp = head; \ while (_tmp->next) { _tmp = _tmp->next; } \ _tmp->next=(add); \ } else { \ (head)=(add); \ } \ } while (0) #define LL_DELETE(head,del) \ LL_DELETE2(head,del,next) #define LL_DELETE2(head,del,next) \ do { \ LDECLTYPE(head) _tmp; \ if ((head) == (del)) { \ (head)=(head)->next; \ } else { \ _tmp = head; \ while (_tmp->next && (_tmp->next != (del))) { \ _tmp = _tmp->next; \ } \ if (_tmp->next) { \ _tmp->next = ((del)->next); \ } \ } \ } while (0) /* Here are VS2008 replacements for LL_APPEND and LL_DELETE */ #define LL_APPEND_VS2008(head,add) \ LL_APPEND2_VS2008(head,add,next) #define LL_APPEND2_VS2008(head,add,next) \ do { \ if (head) { \ (add)->next = head; /* use add->next as a temp variable */ \ while ((add)->next->next) { (add)->next = (add)->next->next; } \ (add)->next->next=(add); \ } else { \ (head)=(add); \ } \ (add)->next=NULL; \ } while (0) #define LL_DELETE_VS2008(head,del) \ LL_DELETE2_VS2008(head,del,next) #define LL_DELETE2_VS2008(head,del,next) \ do { \ if ((head) == (del)) { \ (head)=(head)->next; \ } else { \ char *_tmp = (char*)(head); \ while ((head)->next && ((head)->next != (del))) { \ head = (head)->next; \ } \ if ((head)->next) { \ (head)->next = ((del)->next); \ } \ { \ char **_head_alias = (char**)&(head); \ *_head_alias = _tmp; \ } \ } \ } while (0) #ifdef NO_DECLTYPE #undef LL_APPEND #define LL_APPEND LL_APPEND_VS2008 #undef LL_DELETE #define LL_DELETE LL_DELETE_VS2008 #undef LL_DELETE2 #define LL_DELETE2_VS2008 #undef LL_APPEND2 #define LL_APPEND2 LL_APPEND2_VS2008 #undef LL_CONCAT /* no LL_CONCAT_VS2008 */ #undef DL_CONCAT /* no DL_CONCAT_VS2008 */ #endif /* end VS2008 replacements */ #define LL_FOREACH(head,el) \ LL_FOREACH2(head,el,next) #define LL_FOREACH2(head,el,next) \ for(el=head;el;el=(el)->next) #define LL_FOREACH_SAFE(head,el,tmp) \ LL_FOREACH_SAFE2(head,el,tmp,next) #define LL_FOREACH_SAFE2(head,el,tmp,next) \ for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp) #define LL_SEARCH_SCALAR(head,out,field,val) \ LL_SEARCH_SCALAR2(head,out,field,val,next) #define LL_SEARCH_SCALAR2(head,out,field,val,next) \ do { \ LL_FOREACH2(head,out,next) { \ if ((out)->field == (val)) break; \ } \ } while(0) #define LL_SEARCH(head,out,elt,cmp) \ LL_SEARCH2(head,out,elt,cmp,next) #define LL_SEARCH2(head,out,elt,cmp,next) \ do { \ LL_FOREACH2(head,out,next) { \ if ((cmp(out,elt))==0) break; \ } \ } while(0) #define LL_REPLACE_ELEM(head, el, add) \ do { \ LDECLTYPE(head) _tmp; \ assert(head != NULL); \ assert(el != NULL); \ assert(add != NULL); \ (add)->next = (el)->next; \ if ((head) == (el)) { \ (head) = (add); \ } else { \ _tmp = head; \ while (_tmp->next && (_tmp->next != (el))) { \ _tmp = _tmp->next; \ } \ if (_tmp->next) { \ _tmp->next = (add); \ } \ } \ } while (0) #define LL_PREPEND_ELEM(head, el, add) \ do { \ LDECLTYPE(head) _tmp; \ assert(head != NULL); \ assert(el != NULL); \ assert(add != NULL); \ (add)->next = (el); \ if ((head) == (el)) { \ (head) = (add); \ } else { \ _tmp = head; \ while (_tmp->next && (_tmp->next != (el))) { \ _tmp = _tmp->next; \ } \ if (_tmp->next) { \ _tmp->next = (add); \ } \ } \ } while (0) \ /****************************************************************************** * doubly linked list macros (non-circular) * *****************************************************************************/ #define DL_PREPEND(head,add) \ DL_PREPEND2(head,add,prev,next) #define DL_PREPEND2(head,add,prev,next) \ do { \ (add)->next = head; \ if (head) { \ (add)->prev = (head)->prev; \ (head)->prev = (add); \ } else { \ (add)->prev = (add); \ } \ (head) = (add); \ } while (0) #define DL_APPEND(head,add) \ DL_APPEND2(head,add,prev,next) #define DL_APPEND2(head,add,prev,next) \ do { \ if (head) { \ (add)->prev = (head)->prev; \ (head)->prev->next = (add); \ (head)->prev = (add); \ (add)->next = NULL; \ } else { \ (head)=(add); \ (head)->prev = (head); \ (head)->next = NULL; \ } \ } while (0) #define DL_CONCAT(head1,head2) \ DL_CONCAT2(head1,head2,prev,next) #define DL_CONCAT2(head1,head2,prev,next) \ do { \ LDECLTYPE(head1) _tmp; \ if (head2) { \ if (head1) { \ _tmp = (head2)->prev; \ (head2)->prev = (head1)->prev; \ (head1)->prev->next = (head2); \ (head1)->prev = _tmp; \ } else { \ (head1)=(head2); \ } \ } \ } while (0) #define DL_DELETE(head,del) \ DL_DELETE2(head,del,prev,next) #define DL_DELETE2(head,del,prev,next) \ do { \ assert((del)->prev != NULL); \ if ((del)->prev == (del)) { \ (head)=NULL; \ } else if ((del)==(head)) { \ (del)->next->prev = (del)->prev; \ (head) = (del)->next; \ } else { \ (del)->prev->next = (del)->next; \ if ((del)->next) { \ (del)->next->prev = (del)->prev; \ } else { \ (head)->prev = (del)->prev; \ } \ } \ } while (0) #define DL_FOREACH(head,el) \ DL_FOREACH2(head,el,next) #define DL_FOREACH2(head,el,next) \ for(el=head;el;el=(el)->next) /* this version is safe for deleting the elements during iteration */ #define DL_FOREACH_SAFE(head,el,tmp) \ DL_FOREACH_SAFE2(head,el,tmp,next) #define DL_FOREACH_SAFE2(head,el,tmp,next) \ for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp) /* these are identical to their singly-linked list counterparts */ #define DL_SEARCH_SCALAR LL_SEARCH_SCALAR #define DL_SEARCH LL_SEARCH #define DL_SEARCH_SCALAR2 LL_SEARCH_SCALAR2 #define DL_SEARCH2 LL_SEARCH2 #define DL_REPLACE_ELEM(head, el, add) \ do { \ assert(head != NULL); \ assert(el != NULL); \ assert(add != NULL); \ if ((head) == (el)) { \ (head) = (add); \ (add)->next = (el)->next; \ if ((el)->next == NULL) { \ (add)->prev = (add); \ } else { \ (add)->prev = (el)->prev; \ (add)->next->prev = (add); \ } \ } else { \ (add)->next = (el)->next; \ (add)->prev = (el)->prev; \ (add)->prev->next = (add); \ if ((el)->next == NULL) { \ (head)->prev = (add); \ } else { \ (add)->next->prev = (add); \ } \ } \ } while (0) #define DL_PREPEND_ELEM(head, el, add) \ do { \ assert(head != NULL); \ assert(el != NULL); \ assert(add != NULL); \ (add)->next = (el); \ (add)->prev = (el)->prev; \ (el)->prev = (add); \ if ((head) == (el)) { \ (head) = (add); \ } else { \ (add)->prev->next = (add); \ } \ } while (0) \ /****************************************************************************** * circular doubly linked list macros * *****************************************************************************/ #define CDL_PREPEND(head,add) \ CDL_PREPEND2(head,add,prev,next) #define CDL_PREPEND2(head,add,prev,next) \ do { \ if (head) { \ (add)->prev = (head)->prev; \ (add)->next = (head); \ (head)->prev = (add); \ (add)->prev->next = (add); \ } else { \ (add)->prev = (add); \ (add)->next = (add); \ } \ (head)=(add); \ } while (0) #define CDL_DELETE(head,del) \ CDL_DELETE2(head,del,prev,next) #define CDL_DELETE2(head,del,prev,next) \ do { \ if ( ((head)==(del)) && ((head)->next == (head))) { \ (head) = 0L; \ } else { \ (del)->next->prev = (del)->prev; \ (del)->prev->next = (del)->next; \ if ((del) == (head)) (head)=(del)->next; \ } \ } while (0) #define CDL_FOREACH(head,el) \ CDL_FOREACH2(head,el,next) #define CDL_FOREACH2(head,el,next) \ for(el=head;el;el=((el)->next==head ? 0L : (el)->next)) #define CDL_FOREACH_SAFE(head,el,tmp1,tmp2) \ CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next) #define CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next) \ for((el)=(head), ((tmp1)=(head)?((head)->prev):NULL); \ (el) && ((tmp2)=(el)->next, 1); \ ((el) = (((el)==(tmp1)) ? 0L : (tmp2)))) #define CDL_SEARCH_SCALAR(head,out,field,val) \ CDL_SEARCH_SCALAR2(head,out,field,val,next) #define CDL_SEARCH_SCALAR2(head,out,field,val,next) \ do { \ CDL_FOREACH2(head,out,next) { \ if ((out)->field == (val)) break; \ } \ } while(0) #define CDL_SEARCH(head,out,elt,cmp) \ CDL_SEARCH2(head,out,elt,cmp,next) #define CDL_SEARCH2(head,out,elt,cmp,next) \ do { \ CDL_FOREACH2(head,out,next) { \ if ((cmp(out,elt))==0) break; \ } \ } while(0) #define CDL_REPLACE_ELEM(head, el, add) \ do { \ assert(head != NULL); \ assert(el != NULL); \ assert(add != NULL); \ if ((el)->next == (el)) { \ (add)->next = (add); \ (add)->prev = (add); \ (head) = (add); \ } else { \ (add)->next = (el)->next; \ (add)->prev = (el)->prev; \ (add)->next->prev = (add); \ (add)->prev->next = (add); \ if ((head) == (el)) { \ (head) = (add); \ } \ } \ } while (0) #define CDL_PREPEND_ELEM(head, el, add) \ do { \ assert(head != NULL); \ assert(el != NULL); \ assert(add != NULL); \ (add)->next = (el); \ (add)->prev = (el)->prev; \ (el)->prev = (add); \ (add)->prev->next = (add); \ if ((head) == (el)) { \ (head) = (add); \ } \ } while (0) \ #endif /* UTLIST_H */ ================================================ FILE: cocos2d/cocos/audio/CMakeLists.txt ================================================ # architecture if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) set(ARCH_DIR "64-bit") else() set(ARCH_DIR "32-bit") endif() if(WIN32) set(AUDIO_SRC win32/SimpleAudioEngine.cpp win32/MciPlayer.cpp ) elseif(APPLE) else() set(AUDIO_SRC linux/SimpleAudioEngineFMOD.cpp linux/FmodAudioPlayer.cpp ) include_directories( ../../external/linux-specific/fmod/include/${ARCH_DIR} ) endif() add_library(audio STATIC ${AUDIO_SRC} ) if((NOT APPLE) AND (NOT WIN32)) if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) set(FMOD_LIB "fmodex64") else() set(FMOD_LIB "fmodex") endif() target_link_libraries(audio ${FMOD_LIB} ) set_target_properties(audio PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) elseif(WIN32) target_link_libraries(audio Winmm ) endif() ================================================ FILE: cocos2d/cocos/audio/android/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocosdenshion_static LOCAL_MODULE_FILENAME := libcocosdenshion LOCAL_SRC_FILES := cddSimpleAudioEngine.cpp \ ccdandroidUtils.cpp \ jni/cddandroidAndroidJavaEngine.cpp \ opensl/cddandroidOpenSLEngine.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ $(LOCAL_PATH)/../../math/kazmath/include \ $(LOCAL_PATH)/../../2d \ $(LOCAL_PATH)/../../2d/platform/android \ $(LOCAL_PATH)/../../base \ $(LOCAL_PATH)/../../physics LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi include $(BUILD_STATIC_LIBRARY) ================================================ FILE: cocos2d/cocos/audio/android/ccdandroidUtils.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ccdandroidUtils.h" #include "cocos2d.h" #include #include #include "jni/JniHelper.h" USING_NS_CC; namespace CocosDenshion { namespace android { #define I9100_MODEL "GT-I9100" #define LOG_TAG "Device Model" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper" #define METHOD_NAME "getDeviceModel" bool is_buggy_device(void) { JniMethodInfo methodInfo; jstring jstr; if (JniHelper::getStaticMethodInfo(methodInfo, CLASS_NAME, METHOD_NAME, "()Ljava/lang/String;")) { jstr = (jstring)methodInfo.env->CallStaticObjectMethod(methodInfo.classID, methodInfo.methodID); } const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL); if (NULL == deviceModel) { return false; } LOGD("deviceModel = %s", deviceModel); methodInfo.env->ReleaseStringUTFChars(jstr, deviceModel); methodInfo.env->DeleteLocalRef(jstr); if (strcmp(I9100_MODEL, deviceModel) == 0) { LOGD("i9100 model\nSwitch to OpenSLES"); return true; } return false; } std::string getFullPathWithoutAssetsPrefix(const char* pszFilename) { // Changing file path to full path std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(pszFilename); // Removing `assets` since it isn't needed for the API of playing sound. size_t pos = fullPath.find("assets/"); if (pos == 0) { fullPath = fullPath.substr(strlen("assets/")); } return fullPath; } } } ================================================ FILE: cocos2d/cocos/audio/android/ccdandroidUtils.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDANDROIDUTILS_H__ #define __CCDANDROIDUTILS_H__ #include namespace CocosDenshion { namespace android { bool is_buggy_device(void); std::string getFullPathWithoutAssetsPrefix(const char* pszFilename); } } #endif //__CCDANDROIDUTILS_H__ ================================================ FILE: cocos2d/cocos/audio/android/cddSimpleAudioEngine.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "SimpleAudioEngine.h" #include "jni/cddandroidAndroidJavaEngine.h" #include "opensl/cddandroidOpenSLEngine.h" #include "ccdandroidUtils.h" namespace CocosDenshion { static SimpleAudioEngine *s_pEngine = 0; SimpleAudioEngine* SimpleAudioEngine::getInstance() { if (! s_pEngine) { // if (CocosDenshion::android::is_buggy_device()) { // use the Java Audio implementation until compatibility is confirmed s_pEngine = new CocosDenshion::android::AndroidJavaEngine(); // } else { // s_pEngine = new CocosDenshion::android::OpenSLEngine(); // } } return s_pEngine; } void SimpleAudioEngine::end() { if (s_pEngine) { delete s_pEngine; s_pEngine = NULL; } } SimpleAudioEngine::SimpleAudioEngine() { } SimpleAudioEngine::~SimpleAudioEngine() { } // Empty implementations. On Android, only subclasses are meant to be used void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { } void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) { } void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) { } void SimpleAudioEngine::pauseBackgroundMusic() { } void SimpleAudioEngine::resumeBackgroundMusic() { } void SimpleAudioEngine::rewindBackgroundMusic() { } bool SimpleAudioEngine::willPlayBackgroundMusic() { return false; } bool SimpleAudioEngine::isBackgroundMusicPlaying() { return false; } float SimpleAudioEngine::getBackgroundMusicVolume() { return 0.0f; } void SimpleAudioEngine::setBackgroundMusicVolume(float volume) { } float SimpleAudioEngine::getEffectsVolume() { return 0.0f; } void SimpleAudioEngine::setEffectsVolume(float volume) { } unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) { return 0; } void SimpleAudioEngine::pauseEffect(unsigned int nSoundId) { } void SimpleAudioEngine::pauseAllEffects() { } void SimpleAudioEngine::resumeEffect(unsigned int nSoundId) { } void SimpleAudioEngine::resumeAllEffects() { } void SimpleAudioEngine::stopEffect(unsigned int nSoundId) { } void SimpleAudioEngine::stopAllEffects() { } void SimpleAudioEngine::preloadEffect(const char* pszFilePath) { } void SimpleAudioEngine::unloadEffect(const char* pszFilePath) { } } ================================================ FILE: cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cddandroidAndroidJavaEngine.h" #include "platform/android/jni/JniHelper.h" #include "ccdandroidUtils.h" #include #include // logging #define LOG_TAG "cocosdenshion::android::AndroidJavaEngine" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) // Java class #define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper" namespace CocosDenshion { namespace android { bool AndroidJavaEngine::getJNIStaticMethodInfo(cocos2d::JniMethodInfo &methodinfo, const char *methodName, const char *paramCode) { return cocos2d::JniHelper::getStaticMethodInfo(methodinfo, CLASS_NAME, methodName, paramCode); } AndroidJavaEngine::~AndroidJavaEngine() { cocos2d::JniMethodInfo methodInfo; if (!getJNIStaticMethodInfo(methodInfo, "end", "()V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::preloadBackgroundMusic(const char* pszFilePath) { std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath); // void playBackgroundMusic(String,boolean) cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "preloadBackgroundMusic", "(Ljava/lang/String;)V")) { return; } jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str()); methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) { std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath); cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "playBackgroundMusic", "(Ljava/lang/String;Z)V")) { return; } jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str()); methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg, bLoop); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::stopBackgroundMusic(bool bReleaseData) { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "stopBackgroundMusic", "()V")) { return; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::pauseBackgroundMusic() { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "pauseBackgroundMusic", "()V")) { return; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::resumeBackgroundMusic() { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "resumeBackgroundMusic", "()V")) { return; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::rewindBackgroundMusic() { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "rewindBackgroundMusic", "()V")) { return; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); } bool AndroidJavaEngine::willPlayBackgroundMusic() { return true; } bool AndroidJavaEngine::isBackgroundMusicPlaying() { cocos2d::JniMethodInfo methodInfo; jboolean ret = false; if (! getJNIStaticMethodInfo(methodInfo, "isBackgroundMusicPlaying", "()Z")) { return ret; } ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; } float AndroidJavaEngine::getBackgroundMusicVolume() { cocos2d::JniMethodInfo methodInfo; jfloat ret = -1.0; if (! getJNIStaticMethodInfo(methodInfo, "getBackgroundMusicVolume", "()F")) { return ret; } ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; } void AndroidJavaEngine::setBackgroundMusicVolume(float volume) { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "setBackgroundMusicVolume", "(F)V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume); methodInfo.env->DeleteLocalRef(methodInfo.classID); } float AndroidJavaEngine::getEffectsVolume() { cocos2d::JniMethodInfo methodInfo; jfloat ret = -1.0; if (! getJNIStaticMethodInfo(methodInfo, "getEffectsVolume", "()F")) { return ret; } ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; } void AndroidJavaEngine::setEffectsVolume(float volume) { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "setEffectsVolume", "(F)V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume); methodInfo.env->DeleteLocalRef(methodInfo.classID); } unsigned int AndroidJavaEngine::playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) { cocos2d::JniMethodInfo methodInfo; int ret = 0; std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath); if (! getJNIStaticMethodInfo(methodInfo, "playEffect", "(Ljava/lang/String;ZFFF)I")) { return ret; } jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str()); ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID, methodInfo.methodID, stringArg, bLoop, pitch, pan, gain); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); return (unsigned int)ret; } void AndroidJavaEngine::pauseEffect(unsigned int nSoundId) { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "pauseEffect", "(I)V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::pauseAllEffects() { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "pauseAllEffects", "()V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::resumeEffect(unsigned int nSoundId) { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "resumeEffect", "(I)V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::resumeAllEffects() { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "resumeAllEffects", "()V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::stopEffect(unsigned int nSoundId) { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "stopEffect", "(I)V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::stopAllEffects() { cocos2d::JniMethodInfo methodInfo; if (! getJNIStaticMethodInfo(methodInfo, "stopAllEffects", "()V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::preloadEffect(const char* pszFilePath) { cocos2d::JniMethodInfo methodInfo; std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath); if (! getJNIStaticMethodInfo(methodInfo, "preloadEffect", "(Ljava/lang/String;)V")) { return ; } jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str()); methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); } void AndroidJavaEngine::unloadEffect(const char* pszFilePath) { cocos2d::JniMethodInfo methodInfo; std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath); if (! getJNIStaticMethodInfo(methodInfo, "unloadEffect", "(Ljava/lang/String;)V")) { return ; } jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str()); methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); } } } ================================================ FILE: cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CDDANDRIODANDROIDJAVAENGINE_H__ #define __CDDANDRIODANDROIDJAVAENGINE_H__ #include "SimpleAudioEngine.h" #include "platform/android/jni/JniHelper.h" namespace CocosDenshion { namespace android { class AndroidJavaEngine : public SimpleAudioEngine { ~AndroidJavaEngine(); void preloadBackgroundMusic(const char* pszFilePath); void playBackgroundMusic(const char* pszFilePath, bool bLoop); void stopBackgroundMusic(bool bReleaseData); void pauseBackgroundMusic(); void resumeBackgroundMusic(); void rewindBackgroundMusic(); bool willPlayBackgroundMusic(); bool isBackgroundMusicPlaying(); float getBackgroundMusicVolume(); void setBackgroundMusicVolume(float volume); float getEffectsVolume(); void setEffectsVolume(float volume); unsigned int playEffect(const char* pszFilePath, bool bLoop = false, float pitch = 1.0f, float pan = 0.0f, float gain = 1.0f); void pauseEffect(unsigned int nSoundId); void pauseAllEffects(); void resumeEffect(unsigned int nSoundId); void resumeAllEffects(); void stopEffect(unsigned int nSoundId); void stopAllEffects(); void preloadEffect(const char* pszFilePath); void unloadEffect(const char* pszFilePath); private : static bool getJNIStaticMethodInfo(cocos2d::JniMethodInfo &methodinfo, const char *methodName, const char *paramCode); }; } } #endif //__CDDANDRIODANDROIDJAVAENGINE_H__ ================================================ FILE: cocos2d/cocos/audio/android/opensl/OpenSLEngine.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "OpenSLEngine.h" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,"OPENSL_ENGINE.CPP", __VA_ARGS__) using namespace std; OpenSLEngine::OpenSLEngine() :_musicVolume(0), _effectVolume(0) {} OpenSLEngine::~OpenSLEngine() { closeEngine(); } /********************************************************************************** * jni **********************************************************************************/ #define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper" typedef struct JniMethodInfo_ { JNIEnv * env; jclass classID; jmethodID methodID; } JniMethodInfo; extern "C" { static JNIEnv* getJNIEnv(void) { JavaVM* jvm = cocos2d::JniHelper::getJavaVM(); if (NULL == jvm) { LOGD("Failed to get JNIEnv. JniHelper::getJavaVM() is NULL"); return NULL; } JNIEnv *env = NULL; // get jni environment jint ret = jvm->GetEnv((void**)&env, JNI_VERSION_1_4); switch (ret) { case JNI_OK : // Success! return env; case JNI_EDETACHED : // Thread not attached // TODO : If calling AttachCurrentThread() on a native thread // must call DetachCurrentThread() in future. // see: http://developer.android.com/guide/practices/design/jni.html if (jvm->AttachCurrentThread(&env, NULL) < 0) { LOGD("Failed to get the environment using AttachCurrentThread()"); return NULL; } else { // Success : Attached and obtained JNIEnv! return env; } case JNI_EVERSION : // Cannot recover from this error LOGD("JNI interface version 1.4 not supported"); default : LOGD("Failed to get the environment using GetEnv()"); return NULL; } } static jclass getClassID(JNIEnv *pEnv) { jclass ret = pEnv->FindClass(CLASS_NAME); if (! ret) { LOGD("Failed to find class of %s", CLASS_NAME); } return ret; } static bool getStaticMethodInfo(JniMethodInfo &methodinfo, const char *methodName, const char *paramCode) { jmethodID methodID = 0; JNIEnv *pEnv = 0; bool bRet = false; do { pEnv = getJNIEnv(); if (! pEnv) { break; } jclass classID = getClassID(pEnv); methodID = pEnv->GetStaticMethodID(classID, methodName, paramCode); if (! methodID) { LOGD("Failed to find static method id of %s", methodName); break; } methodinfo.classID = classID; methodinfo.env = pEnv; methodinfo.methodID = methodID; bRet = true; } while (0); return bRet; } }; /********************************************************************************* * helper ********************************************************************************/ #define PLAYSTATE_UNKNOWN 0 #define FILE_NOT_FOUND -1 #define ASSET_MANAGER_GETTER "getAssetManager" #define LIBANDROID "libandroid.so" #define MIN_VOLUME_MILLIBEL -4000 #define MAX_VOLUME_MILLIBEL 0 #define RANGE_VOLUME_MILLIBEL 4000 class AudioPlayer { public: SLDataSource audioSrc; SLObjectItf fdPlayerObject; SLPlayItf fdPlayerPlay; SLSeekItf fdPlayerSeek; SLVolumeItf fdPlayerVolume; SLPlaybackRateItf fdPlaybackRate; /// Applies global effects volume, takes effect gain into account. /// @param volume In range 0..1. void applyEffectsVolume(float volume) { SLmillibel finalVolume = int (RANGE_VOLUME_MILLIBEL * (volume * _gain)) + MIN_VOLUME_MILLIBEL; SLresult result = (*fdPlayerVolume)->SetVolumeLevel(fdPlayerVolume, finalVolume); assert(SL_RESULT_SUCCESS == result); } void applyParameters(bool isLooping, float pitch, float pan, float gain, float effectsVolume) { SLresult result = (*fdPlayerSeek)->SetLoop(fdPlayerSeek, (SLboolean) isLooping, 0, SL_TIME_UNKNOWN); assert(SL_RESULT_SUCCESS == result); SLpermille stereo = SLpermille(1000 * pan); result = (*fdPlayerVolume)->EnableStereoPosition(fdPlayerVolume, SL_BOOLEAN_TRUE); assert(SL_RESULT_SUCCESS == result); result = (*fdPlayerVolume)->SetStereoPosition(fdPlayerVolume, stereo); assert(SL_RESULT_SUCCESS == result); SLpermille playbackRate = SLpermille(1000 * pitch); if (fdPlaybackRate) result = (*fdPlaybackRate)->SetRate(fdPlaybackRate, playbackRate); assert(SL_RESULT_SUCCESS == result); _gain = gain; applyEffectsVolume(effectsVolume); } private: float _gain; }; static AudioPlayer s_musicPlayer; /* for background music */ typedef map* > EffectList; typedef pair* > Effect; void* s_pAndroidHandle = NULL; void* s_pOpenSLESHandle = NULL; static EffectList& sharedList() { static EffectList s_List; return s_List; } unsigned int _Hash(const char *key) { unsigned int len = strlen(key); const char *end=key+len; unsigned int hash; for (hash = 0; key < end; key++) { hash *= 16777619; hash ^= (unsigned int) (unsigned char) toupper(*key); } return (hash); } SLInterfaceID getInterfaceID(const char *value) { // clear the error stack dlerror(); SLInterfaceID* IID = (SLInterfaceID*)dlsym(s_pOpenSLESHandle, value); const char* errorInfo = dlerror(); if (errorInfo) { LOGD("Get interface id: %s from OpenSL failed", errorInfo); IID = NULL; } return *IID; } void* getFuncPtr(const char *value) { // clear the error stack dlerror(); void* funcPtr = dlsym(s_pOpenSLESHandle, value); const char* errorInfo = dlerror(); if (errorInfo) { LOGD("Get function from OpenSL failed: %s", errorInfo); funcPtr = NULL; } return funcPtr; } int getFileDescriptor(const char * filename, off_t & start, off_t & length) { JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, ASSET_MANAGER_GETTER, "()Landroid/content/res/AssetManager;")) { methodInfo.env->DeleteLocalRef(methodInfo.classID); return FILE_NOT_FOUND; } jobject assetManager = methodInfo.env->CallStaticObjectMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); AAssetManager* (*AAssetManager_fromJava)(JNIEnv* env, jobject assetManager); AAssetManager_fromJava = (AAssetManager* (*)(JNIEnv* env, jobject assetManager)) dlsym(s_pAndroidHandle, "AAssetManager_fromJava"); AAssetManager* mgr = AAssetManager_fromJava(methodInfo.env, assetManager); assert(NULL != mgr); AAsset* (*AAssetManager_open)(AAssetManager* mgr, const char* filename, int mode); AAssetManager_open = (AAsset* (*)(AAssetManager* mgr, const char* filename, int mode)) dlsym(s_pAndroidHandle, "AAssetManager_open"); AAsset* Asset = AAssetManager_open(mgr, filename, AASSET_MODE_UNKNOWN); if (NULL == Asset) { //LOGD("file not found! Stop preload file: %s", filename); return FILE_NOT_FOUND; } // open asset as file descriptor int (*AAsset_openFileDescriptor)(AAsset* asset, off_t* outStart, off_t* outLength); AAsset_openFileDescriptor = (int (*)(AAsset* asset, off_t* outStart, off_t* outLength)) dlsym(s_pAndroidHandle, "AAsset_openFileDescriptor"); int fd = AAsset_openFileDescriptor(Asset, &start, &length); assert(0 <= fd); void (*AAsset_close)(AAsset* asset); AAsset_close = (void (*)(AAsset* asset)) dlsym(s_pAndroidHandle, "AAsset_close"); AAsset_close(Asset); return fd; } /********************************************************************************** * engine **********************************************************************************/ static SLObjectItf s_pEngineObject = NULL; static SLEngineItf s_pEngineEngine = NULL; static SLObjectItf s_pOutputMixObject = NULL; bool createAudioPlayerBySource(AudioPlayer* player) { // configure audio sink SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, s_pOutputMixObject}; SLDataSink audioSnk = {&loc_outmix, NULL}; // create audio player const SLInterfaceID ids[3] = { getInterfaceID("SL_IID_SEEK"), getInterfaceID("SL_IID_MUTESOLO"), getInterfaceID("SL_IID_VOLUME")}; const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE}; SLresult result = (*s_pEngineEngine)->CreateAudioPlayer(s_pEngineEngine, &(player->fdPlayerObject), &(player->audioSrc), &audioSnk, 3, ids, req); if (SL_RESULT_MEMORY_FAILURE == result) { return false; } // realize the player result = (*(player->fdPlayerObject))->Realize(player->fdPlayerObject, SL_BOOLEAN_FALSE); assert(SL_RESULT_SUCCESS == result); // get the play interface result = (*(player->fdPlayerObject))->GetInterface(player->fdPlayerObject, getInterfaceID("SL_IID_PLAY"), &(player->fdPlayerPlay)); assert(SL_RESULT_SUCCESS == result); // get the volume interface result = (*(player->fdPlayerObject))->GetInterface(player->fdPlayerObject, getInterfaceID("SL_IID_VOLUME"), &(player->fdPlayerVolume)); assert(SL_RESULT_SUCCESS == result); // get the seek interface result = (*(player->fdPlayerObject))->GetInterface(player->fdPlayerObject, getInterfaceID("SL_IID_SEEK"), &(player->fdPlayerSeek)); assert(SL_RESULT_SUCCESS == result); // get the playback rate interface, if available (*(player->fdPlayerObject))->GetInterface(player->fdPlayerObject, getInterfaceID("SL_IID_PLAYBACKRATE"), &(player->fdPlaybackRate)); return true; } bool initAudioPlayer(AudioPlayer* player, const char* filename) { // configure audio source off_t start, length; int fd = getFileDescriptor(filename, start, length); if (FILE_NOT_FOUND == fd) { FILE* fp = fopen(filename , "rb"); if(fp){ SLDataLocator_URI loc_fd = {SL_DATALOCATOR_URI , (SLchar*)filename}; SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED}; player->audioSrc.pLocator = &loc_fd; player->audioSrc.pFormat = &format_mime; return createAudioPlayerBySource(player); } LOGD("file not found! Stop preload file: %s", filename); return false; } SLDataLocator_AndroidFD loc_fd = {SL_DATALOCATOR_ANDROIDFD, fd, start, length}; SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED}; player->audioSrc.pLocator = &loc_fd; player->audioSrc.pFormat = &format_mime; return createAudioPlayerBySource(player); } void destroyAudioPlayer(AudioPlayer * player) { if (player && player->fdPlayerObject != NULL) { SLresult result; result = (*(player->fdPlayerPlay))->SetPlayState(player->fdPlayerPlay, SL_PLAYSTATE_STOPPED); assert(SL_RESULT_SUCCESS == result); (*(player->fdPlayerObject))->Destroy(player->fdPlayerObject); player->fdPlayerObject = NULL; player->fdPlayerPlay = NULL; player->fdPlayerSeek = NULL; player->fdPlayerVolume = NULL; player->fdPlaybackRate = NULL; } } void OpenSLEngine::createEngine(void* pHandle) { assert(pHandle != NULL); s_pOpenSLESHandle = pHandle; // clear the error stack dlerror(); s_pAndroidHandle = dlopen(LIBANDROID, RTLD_LAZY); const char* errorInfo = dlerror(); if (errorInfo) { LOGD("%s", errorInfo); return; } SLresult result; if (s_pEngineObject == NULL) { // create engine SLresult (*slCreateEngine)(SLObjectItf *pEngine, SLuint32 numOptions, const SLEngineOption *pEngineOptions, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean * pInterfaceRequired ); slCreateEngine = (SLresult (*)(SLObjectItf *pEngine, SLuint32 numOptions, const SLEngineOption *pEngineOptions, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean * pInterfaceRequired )) getFuncPtr("slCreateEngine"); result = slCreateEngine(&s_pEngineObject, 0, NULL, 0, NULL, NULL); assert(SL_RESULT_SUCCESS == result); // realize the engine result = (*s_pEngineObject)->Realize(s_pEngineObject, SL_BOOLEAN_FALSE); assert(SL_RESULT_SUCCESS == result); // get the engine interface, which is needed in order to create other objects result = (*s_pEngineObject)->GetInterface(s_pEngineObject, getInterfaceID("SL_IID_ENGINE"), &s_pEngineEngine); assert(SL_RESULT_SUCCESS == result); // create output mix const SLInterfaceID ids[1] = {getInterfaceID("SL_IID_ENVIRONMENTALREVERB")}; const SLboolean req[1] = {SL_BOOLEAN_FALSE}; result = (*s_pEngineEngine)->CreateOutputMix(s_pEngineEngine, &s_pOutputMixObject, 1, ids, req); assert(SL_RESULT_SUCCESS == result); // realize the output mix object in sync. mode result = (*s_pOutputMixObject)->Realize(s_pOutputMixObject, SL_BOOLEAN_FALSE); assert(SL_RESULT_SUCCESS == result); } } void OpenSLEngine::closeEngine() { // destroy background players destroyAudioPlayer(&s_musicPlayer); // destroy effect players vector* vec; EffectList::iterator p = sharedList().begin(); while (p != sharedList().end()) { vec = p->second; for (vector::iterator iter = vec->begin() ; iter != vec->end() ; ++ iter) { destroyAudioPlayer(*iter); } vec->clear(); p++; } sharedList().clear(); // destroy output mix interface if (s_pOutputMixObject) { (*s_pOutputMixObject)->Destroy(s_pOutputMixObject); s_pOutputMixObject = NULL; } // destroy opensl engine if (s_pEngineObject) { (*s_pEngineObject)->Destroy(s_pEngineObject); s_pEngineObject = NULL; s_pEngineEngine = NULL; } LOGD("engine destory"); } /********************************************************************************** * sound effect **********************************************************************************/ typedef struct _CallbackContext { vector* vec; AudioPlayer* player; } CallbackContext; void PlayOverEvent(SLPlayItf caller, void* pContext, SLuint32 playEvent) { CallbackContext* context = (CallbackContext*)pContext; if (playEvent == SL_PLAYEVENT_HEADATEND) { vector::iterator iter; for (iter = (context->vec)->begin() ; iter != (context->vec)->end() ; ++ iter) { if (*iter == context->player) { (context->vec)->erase(iter); break; } } destroyAudioPlayer(context->player); free(context); } } int getSingleEffectState(AudioPlayer * player) { SLuint32 state = 0; SLresult result; result = (*(player->fdPlayerPlay))->GetPlayState(player->fdPlayerPlay, &state); assert(result == SL_RESULT_SUCCESS); return (int)state; } void setSingleEffectState(AudioPlayer * player, int state) { SLresult result; if (player->fdPlayerPlay != NULL) { // don't set to PAUSED state if it's already set to STOPPED state int oldState = getSingleEffectState(player); if (oldState == SL_PLAYSTATE_STOPPED && state == SL_PLAYSTATE_PAUSED) { return; } result = (*(player->fdPlayerPlay))->SetPlayState(player->fdPlayerPlay, state); assert(SL_RESULT_SUCCESS == result); } } void resumeSingleEffect(AudioPlayer * player) { int state = getSingleEffectState(player); // only resume the effect that has been paused if (state == SL_PLAYSTATE_PAUSED) { setSingleEffectState(player, SL_PLAYSTATE_PLAYING); } } bool OpenSLEngine::recreatePlayer(const char* filename) { unsigned int effectID = _Hash(filename); EffectList::iterator p = sharedList().find(effectID); vector* vec = p->second; AudioPlayer* newPlayer = new AudioPlayer(); if (!initAudioPlayer(newPlayer, filename)) { LOGD("failed to recreate"); return false; } vec->push_back(newPlayer); // set callback SLresult result; CallbackContext* context = new CallbackContext(); context->vec = vec; context->player = newPlayer; result = (*(newPlayer->fdPlayerPlay))->RegisterCallback(newPlayer->fdPlayerPlay, PlayOverEvent, (void*)context); assert(SL_RESULT_SUCCESS == result); result = (*(newPlayer->fdPlayerPlay))->SetCallbackEventsMask(newPlayer->fdPlayerPlay, SL_PLAYEVENT_HEADATEND); assert(SL_RESULT_SUCCESS == result); // set volume newPlayer->applyEffectsVolume(_effectVolume); setSingleEffectState(newPlayer, SL_PLAYSTATE_STOPPED); setSingleEffectState(newPlayer, SL_PLAYSTATE_PLAYING); // LOGD("vec count is %d of effectID %d", vec->size(), effectID); return true; } unsigned int OpenSLEngine::preloadEffect(const char * filename) { unsigned int nID = _Hash(filename); // if already exists EffectList::iterator p = sharedList().find(nID); if (p != sharedList().end()) { return nID; } AudioPlayer* player = new AudioPlayer(); if (!initAudioPlayer(player, filename)) { free(player); return FILE_NOT_FOUND; } // set the new player's volume as others' player->applyEffectsVolume(_effectVolume); vector* vec = new vector; vec->push_back(player); sharedList().insert(Effect(nID, vec)); return nID; } void OpenSLEngine::unloadEffect(const char * filename) { unsigned int nID = _Hash(filename); EffectList::iterator p = sharedList().find(nID); if (p != sharedList().end()) { vector* vec = p->second; for (vector::iterator iter = vec->begin() ; iter != vec->end() ; ++ iter) { destroyAudioPlayer(*iter); } vec->clear(); sharedList().erase(nID); } } int OpenSLEngine::getEffectState(unsigned int effectID) { int state = PLAYSTATE_UNKNOWN; EffectList::iterator p = sharedList().find(effectID); if (p != sharedList().end()) { vector* vec = p->second; // get the last player's state vector::reverse_iterator r_iter = vec->rbegin(); state = getSingleEffectState(*r_iter); } return state; } void OpenSLEngine::setEffectState(unsigned int effectID, int state, bool isClear) { EffectList::iterator p = sharedList().find(effectID); if (p != sharedList().end()) { vector* vec = p->second; if (state == SL_PLAYSTATE_STOPPED || state == SL_PLAYSTATE_PAUSED) { // if stopped, clear the recreated players which are unused if (isClear) { setSingleEffectState(*(vec->begin()), state); vector::reverse_iterator r_iter = vec->rbegin(); for (int i = 1, size = vec->size() ; i < size ; ++ i) { destroyAudioPlayer(*r_iter); r_iter ++; vec->pop_back(); } } else { vector::iterator iter; for (iter = vec->begin() ; iter != vec->end() ; ++ iter) { setSingleEffectState(*iter, state); } } } else { setSingleEffectState(*(vec->rbegin()), state); } } } void OpenSLEngine::setAllEffectState(int state) { EffectList::iterator p; for (p = sharedList().begin(); p != sharedList().end(); p ++) { vector* vec = p->second; for (vector::iterator iter = vec->begin() ; iter != vec->end() ; ++ iter) { setSingleEffectState(*iter, state); } } } void OpenSLEngine::resumeEffect(unsigned int effectID) { EffectList::iterator p = sharedList().find(effectID); if (p != sharedList().end()) { vector* vec = p->second; for (vector::iterator iter = vec->begin() ; iter != vec->end() ; ++ iter) { resumeSingleEffect(*iter); } } } void OpenSLEngine::resumeAllEffects() { int state; EffectList::iterator p; for (p = sharedList().begin(); p != sharedList().end() ; ++ p) { vector* vec = p->second; for (vector::iterator iter = vec->begin() ; iter != vec->end() ; ++ iter) { resumeSingleEffect(*iter); } } } void OpenSLEngine::setEffectParameters(unsigned int effectID, bool isLooping, float pitch, float pan, float gain) { vector* vec = sharedList()[effectID]; assert(NULL != vec); // get the first effect player that to be set loop config vector::iterator iter = vec->begin(); AudioPlayer * player = *iter; if (player && player->fdPlayerSeek) { player->applyParameters(isLooping, pitch, pan, gain, _effectVolume); } } void OpenSLEngine::setEffectsVolume(float volume) { assert(volume <= 1.0f && volume >= 0.0f); _effectVolume = volume; EffectList::iterator p; AudioPlayer * player; for (p = sharedList().begin() ; p != sharedList().end() ; ++ p) { vector* vec = p->second; for (vector::iterator iter = vec->begin() ; iter != vec->end() ; ++ iter) { player = *iter; player->applyEffectsVolume(_effectVolume); } } } float OpenSLEngine::getEffectsVolume() { float volume = (_effectVolume - MIN_VOLUME_MILLIBEL) / (1.0f * RANGE_VOLUME_MILLIBEL); return volume; } ================================================ FILE: cocos2d/cocos/audio/android/opensl/OpenSLEngine.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _OPENSL_ENGINE_H_ #define _OPENSL_ENGINE_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class OpenSLEngine { public: OpenSLEngine(); ~OpenSLEngine(); void createEngine(void * pHandle); void closeEngine(); bool preloadBackgroundMusic(const char * filename); void setBackgroundMusicState(int state); int getBackgroundMusicState(); void rewindBackgroundMusic(); void setBackgroundMusicLooping(bool isLooping); void setBackgroundVolume(int volume); int getBackgroundVolume(); bool recreatePlayer(const char* filename); unsigned int preloadEffect(const char * filename); void unloadEffect(const char * filename); int getEffectState(unsigned int effectID); void setEffectState(unsigned int effectID, int state, bool isClear = false); void setAllEffectState(int state); void resumeEffect(unsigned int effectID); void resumeAllEffects(); void setEffectParameters(unsigned int effectID, bool isLooping, float pitch, float pan, float gain); void setEffectsVolume(float volume); float getEffectsVolume(); private: SLmillibel _musicVolume; float _effectVolume; }; #endif ================================================ FILE: cocos2d/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "SimpleAudioEngineOpenSL.h" #include #include #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,"SIMPLEAUDIOENGINE_OPENSL", __VA_ARGS__) #define LIBOPENSLES "libOpenSLES.so" #define PLAYSTATE_UNKNOWN 0 #define PLAYSTATE_STOPPED 1 #define PLAYSTATE_PAUSED 2 #define PLAYSTATE_PLAYING 3 #define FILE_NOT_FOUND -1 static void * s_pHandle = 0; static OpenSLEngine * s_pOpenSL = 0; static SimpleAudioEngineOpenSL * s_pEngine = 0; SimpleAudioEngineOpenSL::SimpleAudioEngineOpenSL() { } SimpleAudioEngineOpenSL::~SimpleAudioEngineOpenSL() { end(); } bool SimpleAudioEngineOpenSL::initEngine() { bool bRet = false; do { if (s_pOpenSL == NULL) { // clear the error stack dlerror(); s_pHandle = dlopen(LIBOPENSLES, RTLD_LAZY); const char* errorInfo = dlerror(); if (errorInfo) { LOGD("%s", errorInfo); bRet = false; break; } s_pOpenSL = new OpenSLEngine(); s_pOpenSL->createEngine(s_pHandle); bRet = true; } } while (0); return bRet; } SimpleAudioEngineOpenSL* SimpleAudioEngineOpenSL::sharedEngine() { if (s_pEngine == NULL) { s_pEngine = new SimpleAudioEngineOpenSL(); } s_pEngine->initEngine(); return s_pEngine; } void SimpleAudioEngineOpenSL::end() { if (s_pOpenSL) { s_pOpenSL->closeEngine(); delete s_pOpenSL; s_pOpenSL = NULL; dlclose(s_pHandle); s_pHandle = NULL; } } float SimpleAudioEngineOpenSL::getEffectsVolume() { return s_pOpenSL->getEffectsVolume(); } void SimpleAudioEngineOpenSL::setEffectsVolume(float volume) { if (volume < 0.0f) volume = 0.0f; if (volume > 1.0f) volume = 1.0f; s_pOpenSL->setEffectsVolume(volume); } unsigned int SimpleAudioEngineOpenSL::playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) { unsigned int soundID = s_pOpenSL->preloadEffect(pszFilePath); if (soundID != FILE_NOT_FOUND) { if (s_pOpenSL->getEffectState(soundID) == PLAYSTATE_PLAYING) { // recreate an effect player. if (s_pOpenSL->recreatePlayer(pszFilePath)) { s_pOpenSL->setEffectParameters(soundID, bLoop, pitch, pan, gain); } } else { s_pOpenSL->setEffectState(soundID, PLAYSTATE_STOPPED); s_pOpenSL->setEffectState(soundID, PLAYSTATE_PLAYING); s_pOpenSL->setEffectParameters(soundID, bLoop, pitch, pan, gain); } } return soundID; } void SimpleAudioEngineOpenSL::pauseEffect(unsigned int nSoundId) { s_pOpenSL->setEffectState(nSoundId, PLAYSTATE_PAUSED); } void SimpleAudioEngineOpenSL::pauseAllEffects() { s_pOpenSL->setAllEffectState(PLAYSTATE_PAUSED); } void SimpleAudioEngineOpenSL::resumeEffect(unsigned int nSoundId) { s_pOpenSL->resumeEffect(nSoundId); } void SimpleAudioEngineOpenSL::resumeAllEffects() { s_pOpenSL->resumeAllEffects(); } void SimpleAudioEngineOpenSL::stopEffect(unsigned int nSoundId) { s_pOpenSL->setEffectState(nSoundId, PLAYSTATE_STOPPED, true); } void SimpleAudioEngineOpenSL::stopAllEffects() { s_pOpenSL->setAllEffectState(PLAYSTATE_STOPPED); } void SimpleAudioEngineOpenSL::preloadEffect(const char* pszFilePath) { s_pOpenSL->preloadEffect(pszFilePath); } void SimpleAudioEngineOpenSL::unloadEffect(const char* pszFilePath) { s_pOpenSL->unloadEffect(pszFilePath); } ================================================ FILE: cocos2d/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _SIMPLE_AUDIO_ENGINE_OPENSL_H_ #define _SIMPLE_AUDIO_ENGINE_OPENSL_H_ #include "OpenSLEngine.h" class SimpleAudioEngineOpenSL { public: SimpleAudioEngineOpenSL(); ~SimpleAudioEngineOpenSL(); bool initEngine(); static SimpleAudioEngineOpenSL* sharedEngine(); static void end(); float getEffectsVolume(); void setEffectsVolume(float volume); unsigned int playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain); void pauseEffect(unsigned int nSoundId); void pauseAllEffects(); void resumeEffect(unsigned int nSoundId); void resumeAllEffects(); void stopEffect(unsigned int nSoundId); void stopAllEffects(); void preloadEffect(const char* pszFilePath); void unloadEffect(const char* pszFilePath); }; #endif ================================================ FILE: cocos2d/cocos/audio/android/opensl/cddandroidOpenSLEngine.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cddandroidOpenSLEngine.h" namespace CocosDenshion { namespace android { OpenSLEngine::~OpenSLEngine() { } void OpenSLEngine::preloadBackgroundMusic(const char* pszFilePath) { } void OpenSLEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) { } void OpenSLEngine::stopBackgroundMusic(bool bReleaseData) { } void OpenSLEngine::pauseBackgroundMusic() { } void OpenSLEngine::resumeBackgroundMusic() { } void OpenSLEngine::rewindBackgroundMusic() { } bool OpenSLEngine::willPlayBackgroundMusic() { } bool OpenSLEngine::isBackgroundMusicPlaying() { } float OpenSLEngine::getBackgroundMusicVolume() { } void OpenSLEngine::setBackgroundMusicVolume(float volume) { } float OpenSLEngine::getEffectsVolume() { } void OpenSLEngine::setEffectsVolume(float volume) { } unsigned int OpenSLEngine::playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) { } void OpenSLEngine::pauseEffect(unsigned int nSoundId) { } void OpenSLEngine::pauseAllEffects() { } void OpenSLEngine::resumeEffect(unsigned int nSoundId) { } void OpenSLEngine::resumeAllEffects() { } void OpenSLEngine::stopEffect(unsigned int nSoundId) { } void OpenSLEngine::stopAllEffects() { } void OpenSLEngine::preloadEffect(const char* pszFilePath) { } void OpenSLEngine::unloadEffect(const char* pszFilePath) { } } } ================================================ FILE: cocos2d/cocos/audio/android/opensl/cddandroidOpenSLEngine.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CDDANDROIDOPENSLENGINE_H__ #define __CDDANDROIDOPENSLENGINE_H__ #include "SimpleAudioEngine.h" namespace CocosDenshion { namespace android { class OpenSLEngine : public SimpleAudioEngine { ~OpenSLEngine(); void preloadBackgroundMusic(const char* pszFilePath); void playBackgroundMusic(const char* pszFilePath, bool bLoop); void stopBackgroundMusic(bool bReleaseData); void pauseBackgroundMusic(); void resumeBackgroundMusic(); void rewindBackgroundMusic(); bool willPlayBackgroundMusic(); bool isBackgroundMusicPlaying(); float getBackgroundMusicVolume(); void setBackgroundMusicVolume(float volume); float getEffectsVolume(); void setEffectsVolume(float volume); unsigned int playEffect(const char* pszFilePath, bool bLoop = false, float pitch = 1.0f, float pan = 0.0f, float gain = 1.0f); void pauseEffect(unsigned int nSoundId); void pauseAllEffects(); void resumeEffect(unsigned int nSoundId); void resumeAllEffects(); void stopEffect(unsigned int nSoundId); void stopAllEffects(); void preloadEffect(const char* pszFilePath); void unloadEffect(const char* pszFilePath); }; } } #endif //__CDDANDROIDOPENSLENGINE_H__ ================================================ FILE: cocos2d/cocos/audio/include/Export.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __EXPORT_COMMON__ #define __EXPORT_COMMON__ #if defined(SHP) #include #define EXPORT_DLL _EXPORT_ #elif defined(_WIN32) #if defined(_EXPORT_DLL_) #define EXPORT_DLL// __declspec(dllexport) #elif defined(IGNORE_EXPORT) #define EXPORT_DLL #else /* use a DLL library */ #define EXPORT_DLL// __declspec(dllimport) #endif #else #if defined(_SHARED_) #define EXPORT_DLL __attribute__((visibility("default"))) #elif defined(IGNORE_EXPORT) #define EXPORT_DLL #else #define EXPORT_DLL #endif #endif #endif // end of __EXPORT_COMMON__ ================================================ FILE: cocos2d/cocos/audio/include/SimpleAudioEngine.h ================================================ /**************************************************************************** Copyright (c) 2010 Steve Oldmeadow Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef _SIMPLE_AUDIO_ENGINE_H_ #define _SIMPLE_AUDIO_ENGINE_H_ #include #include "Export.h" #include #include #include #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #define CC_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) #elif _MSC_VER >= 1400 //vs 2005 or higher #define CC_DEPRECATED_ATTRIBUTE __declspec(deprecated) #else #define CC_DEPRECATED_ATTRIBUTE #endif namespace CocosDenshion { /** @class SimpleAudioEngine @brief Offers a VERY simple interface to play background music & sound effects. @note Make sure to call SimpleAudioEngine::end() when the sound engine is not needed anymore to release allocated resources. */ class EXPORT_DLL SimpleAudioEngine { public: /** @brief Get the shared Engine object,it will new one when first time be called */ static SimpleAudioEngine* getInstance(); /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static SimpleAudioEngine* sharedEngine() { return SimpleAudioEngine::getInstance(); } /** @brief Release the shared Engine object @warning It must be called before the application exit, or a memory leak will be casued. */ static void end(); protected: SimpleAudioEngine(); virtual ~SimpleAudioEngine(); public: /** @brief Preload background music @param pszFilePath The path of the background music file. * @js preloadMusic * @lua preloadMusic */ virtual void preloadBackgroundMusic(const char* pszFilePath); /** @brief Play background music @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo @param bLoop Whether the background music loop or not * @js playMusic * @lua playMusic */ virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop = false); /** @brief Stop playing background music @param bReleaseData If release the background music data or not.As default value is false * @js stopMusic * @lua stopMusic */ virtual void stopBackgroundMusic(bool bReleaseData = false); /** @brief Pause playing background music * @js pauseMusic * @lua pauseMusic */ virtual void pauseBackgroundMusic(); /** @brief Resume playing background music * @js resumeMusic * @lua resumeMusic */ virtual void resumeBackgroundMusic(); /** @brief Rewind playing background music * @js rewindMusic * @lua rewindMusic */ virtual void rewindBackgroundMusic(); /** @brief Indicates whether any background music can be played or not. @return true if background music can be played, otherwise false. * @js willPlayMusic * @lua willPlayMusic */ virtual bool willPlayBackgroundMusic(); /** @brief Indicates whether the background music is playing @return true if the background music is playing, otherwise false * @js isMusicPlaying * @lua isMusicPlaying */ virtual bool isBackgroundMusicPlaying(); // // properties // /** @brief The volume of the background music within the range of 0.0 as the minimum and 1.0 as the maximum. * @js getMusicVolume * @lua getMusicVolume */ virtual float getBackgroundMusicVolume(); /** @brief Set the volume of background music @param volume must be within the range of 0.0 as the minimum and 1.0 as the maximum. * @js setMusicVolume * @lua setMusicVolume */ virtual void setBackgroundMusicVolume(float volume); /** @brief The volume of the effects within the range of 0.0 as the minimum and 1.0 as the maximum. */ virtual float getEffectsVolume(); /** @brief Set the volume of sound effects @param volume must be within the range of 0.0 as the minimum and 1.0 as the maximum. */ virtual void setEffectsVolume(float volume); // // for sound effects /** @brief Play sound effect with a file path, pitch, pan and gain @param pszFilePath The path of the effect file. @param bLoop Determines whether to loop the effect playing or not. The default value is false. @param pitch Frequency, normal value is 1.0. Will also change effect play time. @param pan Stereo effect, in the range of [-1..1] where -1 enables only left channel. @param gain Volume, in the range of [0..1]. The normal value is 1. @return the OpenAL source id @note Full support is under development, now there are limitations: - no pitch effect on Samsung Galaxy S2 with OpenSL backend enabled; - no pitch/pan/gain on emscrippten, win32, marmalade. */ virtual unsigned int playEffect(const char* pszFilePath, bool bLoop = false, float pitch = 1.0f, float pan = 0.0f, float gain = 1.0f); /** @brief Pause playing sound effect @param nSoundId The return value of function playEffect */ virtual void pauseEffect(unsigned int nSoundId); /** @brief Pause all playing sound effect */ virtual void pauseAllEffects(); /** @brief Resume playing sound effect @param nSoundId The return value of function playEffect */ virtual void resumeEffect(unsigned int nSoundId); /** @brief Resume all playing sound effect */ virtual void resumeAllEffects(); /** @brief Stop playing sound effect @param nSoundId The return value of function playEffect */ virtual void stopEffect(unsigned int nSoundId); /** @brief Stop all playing sound effects */ virtual void stopAllEffects(); /** @brief preload a compressed audio file @details the compressed audio will be decoded to wave, then written into an internal buffer in SimpleAudioEngine @param pszFilePath The path of the effect file */ virtual void preloadEffect(const char* pszFilePath); /** @brief unload the preloaded effect from internal buffer @param pszFilePath The path of the effect file */ virtual void unloadEffect(const char* pszFilePath); }; } // end of namespace CocosDenshion #endif // _SIMPLE_AUDIO_ENGINE_H_ ================================================ FILE: cocos2d/cocos/audio/ios/CDAudioManager.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "CocosDenshion.h" #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000 #import #else #import "CDXMacOSXSupport.h" #endif /** Different modes of the engine */ typedef enum { kAMM_FxOnly, //!Other apps will be able to play audio kAMM_FxPlusMusic, //!Only this app will play audio kAMM_FxPlusMusicIfNoOtherAudio, //!If another app is playing audio at start up then allow it to continue and don't play music kAMM_MediaPlayback, //!This app takes over audio e.g music player app kAMM_PlayAndRecord //!App takes over audio and has input and output } tAudioManagerMode; /** Possible states of the engine */ typedef enum { kAMStateUninitialised, //!Audio manager has not been initialised - do not use kAMStateInitialising, //!Audio manager is in the process of initialising - do not use kAMStateInitialised //!Audio manager is initialised - safe to use } tAudioManagerState; typedef enum { kAMRBDoNothing, //Audio manager will not do anything on resign or becoming active kAMRBStopPlay, //Background music is stopped on resign and resumed on become active kAMRBStop //Background music is stopped on resign but not resumed - maybe because you want to do this from within your game } tAudioManagerResignBehavior; /** Notifications */ extern NSString * const kCDN_AudioManagerInitialised; @interface CDAsynchInitialiser : NSOperation {} @end /** CDAudioManager supports two long audio source channels called left and right*/ typedef enum { kASC_Left = 0, kASC_Right = 1 } tAudioSourceChannel; typedef enum { kLAS_Init, kLAS_Loaded, kLAS_Playing, kLAS_Paused, kLAS_Stopped, } tLongAudioSourceState; @class CDLongAudioSource; @protocol CDLongAudioSourceDelegate @optional /** The audio source completed playing */ - (void) cdAudioSourceDidFinishPlaying:(CDLongAudioSource *) audioSource; /** The file used to load the audio source has changed */ - (void) cdAudioSourceFileDidChange:(CDLongAudioSource *) audioSource; @end /** CDLongAudioSource represents an audio source that has a long duration which makes it costly to load into memory for playback as an effect using CDSoundEngine. Examples include background music and narration tracks. The audio file may or may not be compressed. Bear in mind that current iDevices can only use hardware to decode a single compressed audio file at a time and playing multiple compressed files will result in a performance drop as software decompression will take place. @since v0.99 */ @interface CDLongAudioSource : NSObject { AVAudioPlayer *audioSourcePlayer; NSString *audioSourceFilePath; NSInteger numberOfLoops; float volume; id delegate; BOOL mute; BOOL enabled_; BOOL backgroundMusic; // whether background music is paused BOOL paused; @public BOOL systemPaused;//Used for auto resign handling NSTimeInterval systemPauseLocation;//Used for auto resign handling @protected tLongAudioSourceState state; } @property (readonly) AVAudioPlayer *audioSourcePlayer; @property (readonly) NSString *audioSourceFilePath; @property (readwrite, nonatomic) NSInteger numberOfLoops; @property (readwrite, nonatomic) float volume; @property (assign) id delegate; /* This long audio source functions as background music */ @property (readwrite, nonatomic) BOOL backgroundMusic; @property (readonly) BOOL paused; /** Loads the file into the audio source */ -(void) load:(NSString*) filePath; /** Plays the audio source */ -(void) play; /** Stops playing the audio soruce */ -(void) stop; /** Pauses the audio source */ -(void) pause; /** Rewinds the audio source */ -(void) rewind; /** Resumes playing the audio source if it was paused */ -(void) resume; /** Returns whether or not the audio source is playing */ -(BOOL) isPlaying; @end /** CDAudioManager manages audio requirements for a game. It provides access to a CDSoundEngine object for playing sound effects. It provides access to two CDLongAudioSource object (left and right channel) for playing long duration audio such as background music and narration tracks. Additionally it manages the audio session to take care of things like audio session interruption and interacting with the audio of other apps that are running on the device. Requirements: - Firmware: OS 2.2 or greater - Files: CDAudioManager.*, CocosDenshion.* - Frameworks: OpenAL, AudioToolbox, AVFoundation @since v0.8 */ @interface CDAudioManager : NSObject { CDSoundEngine *soundEngine; CDLongAudioSource *backgroundMusic; NSMutableArray *audioSourceChannels; NSString* _audioSessionCategory; BOOL _audioWasPlayingAtStartup; tAudioManagerMode _mode; SEL backgroundMusicCompletionSelector; id backgroundMusicCompletionListener; BOOL willPlayBackgroundMusic; BOOL _mute; BOOL _resigned; BOOL _interrupted; BOOL _audioSessionActive; BOOL enabled_; //For handling resign/become active BOOL _isObservingAppEvents; tAudioManagerResignBehavior _resignBehavior; } @property (readonly) CDSoundEngine *soundEngine; @property (readonly) CDLongAudioSource *backgroundMusic; @property (readonly) BOOL willPlayBackgroundMusic; /** Returns the shared singleton */ + (CDAudioManager *) sharedManager; + (tAudioManagerState) sharedManagerState; /** Configures the shared singleton with a mode*/ + (void) configure: (tAudioManagerMode) mode; /** Initializes the engine asynchronously with a mode */ + (void) initAsynchronously: (tAudioManagerMode) mode; /** Initializes the engine synchronously with a mode, channel definition and a total number of channels */ - (id) init: (tAudioManagerMode) mode; -(void) audioSessionInterrupted; -(void) audioSessionResumed; -(void) setResignBehavior:(tAudioManagerResignBehavior) resignBehavior autoHandle:(BOOL) autoHandle; /** Returns true is audio is muted at a hardware level e.g user has ringer switch set to off */ -(BOOL) isDeviceMuted; /** Returns true if another app is playing audio such as the iPod music player */ -(BOOL) isOtherAudioPlaying; /** Sets the way the audio manager interacts with the operating system such as whether it shares output with other apps or obeys the mute switch */ -(void) setMode:(tAudioManagerMode) mode; /** Shuts down the shared audio manager instance so that it can be reinitialised */ +(void) end; /** Call if you want to use built in resign behavior but need to do some additional audio processing on resign active. */ - (void) applicationWillResignActive; /** Call if you want to use built in resign behavior but need to do some additional audio processing on become active. */ - (void) applicationDidBecomeActive; //New AVAudioPlayer API /** Loads the data from the specified file path to the channel's audio source */ -(CDLongAudioSource*) audioSourceLoad:(NSString*) filePath channel:(tAudioSourceChannel) channel; /** Retrieves the audio source for the specified channel */ -(CDLongAudioSource*) audioSourceForChannel:(tAudioSourceChannel) channel; //Legacy AVAudioPlayer API /** Plays music in background. The music can be looped or not It is recommended to use .aac files as background music since they are decoded by the device (hardware). */ -(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop; /** Preloads a background music */ -(void) preloadBackgroundMusic:(NSString*) filePath; /** Stops playing the background music */ -(void) stopBackgroundMusic; /** Pauses the background music */ -(void) pauseBackgroundMusic; /** Rewinds the background music */ -(void) rewindBackgroundMusic; /** Resumes playing the background music */ -(void) resumeBackgroundMusic; /** Returns whether or not the background music is playing */ -(BOOL) isBackgroundMusicPlaying; -(void) setBackgroundMusicCompletionListener:(id) listener selector:(SEL) selector; @end /** Fader for long audio source objects */ @interface CDLongAudioSourceFader : CDPropertyModifier{} @end static const int kCDNoBuffer = -1; /** Allows buffers to be associated with file names */ @interface CDBufferManager:NSObject{ NSMutableDictionary* loadedBuffers; NSMutableArray *freedBuffers; CDSoundEngine *soundEngine; int nextBufferId; } -(id) initWithEngine:(CDSoundEngine *) theSoundEngine; -(int) bufferForFile:(NSString*) filePath create:(BOOL) create; -(void) releaseBufferForFile:(NSString *) filePath; @end ================================================ FILE: cocos2d/cocos/audio/ios/CDAudioManager.m ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "CDAudioManager.h" NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; //NSOperation object used to asynchronously initialise @implementation CDAsynchInitialiser -(void) main { [super main]; [CDAudioManager sharedManager]; } @end @implementation CDLongAudioSource @synthesize audioSourcePlayer, audioSourceFilePath, delegate, backgroundMusic, paused; -(id) init { if ((self = [super init])) { state = kLAS_Init; volume = 1.0f; mute = NO; enabled_ = YES; paused = NO; } return self; } -(void) dealloc { CDLOGINFO(@"Denshion::CDLongAudioSource - deallocating %@", self); [audioSourcePlayer release]; [audioSourceFilePath release]; [super dealloc]; } -(void) load:(NSString*) filePath { //We have alread loaded a file previously, check if we are being asked to load the same file if (state == kLAS_Init || ![filePath isEqualToString:audioSourceFilePath]) { CDLOGINFO(@"Denshion::CDLongAudioSource - Loading new audio source %@",filePath); //New file if (state != kLAS_Init) { [audioSourceFilePath release];//Release old file path [audioSourcePlayer release];//Release old AVAudioPlayer, they can't be reused } audioSourceFilePath = [filePath copy]; NSError *error = nil; NSString *path = [CDUtilities fullPathFromRelativePath:audioSourceFilePath]; audioSourcePlayer = [(AVAudioPlayer*)[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&error]; if (error == nil) { [audioSourcePlayer prepareToPlay]; audioSourcePlayer.delegate = self; if (delegate && [delegate respondsToSelector:@selector(cdAudioSourceFileDidChange:)]) { //Tell our delegate the file has changed [delegate cdAudioSourceFileDidChange:self]; } } else { CDLOG(@"Denshion::CDLongAudioSource - Error initialising audio player: %@",error); } } else { //Same file - just return it to a consistent state [self pause]; [self rewind]; } audioSourcePlayer.volume = volume; audioSourcePlayer.numberOfLoops = numberOfLoops; state = kLAS_Loaded; } -(void) play { if (enabled_) { self->systemPaused = NO; self->paused = NO; [audioSourcePlayer play]; } else { CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled"); } } -(void) stop { self->paused = NO; [audioSourcePlayer stop]; } -(void) pause { self->paused = YES; [audioSourcePlayer pause]; } -(void) rewind { self->paused = NO; [audioSourcePlayer setCurrentTime:0]; } -(void) resume { self->paused = NO; [audioSourcePlayer play]; } -(BOOL) isPlaying { if (state != kLAS_Init) { return [audioSourcePlayer isPlaying]; } else { return NO; } } -(void) setVolume:(float) newVolume { volume = newVolume; if (state != kLAS_Init && !mute) { audioSourcePlayer.volume = newVolume; } } -(float) volume { return volume; } #pragma mark Audio Interrupt Protocol -(BOOL) mute { return mute; } -(void) setMute:(BOOL) muteValue { if (mute != muteValue) { if (mute) { //Turn sound back on audioSourcePlayer.volume = volume; } else { audioSourcePlayer.volume = 0.0f; } mute = muteValue; } } -(BOOL) enabled { return enabled_; } -(void) setEnabled:(BOOL)enabledValue { if (enabledValue != enabled_) { enabled_ = enabledValue; if (!enabled_) { //"Stop" the sounds [self pause]; [self rewind]; } } } -(NSInteger) numberOfLoops { return numberOfLoops; } -(void) setNumberOfLoops:(NSInteger) loopCount { audioSourcePlayer.numberOfLoops = loopCount; numberOfLoops = loopCount; } - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player finished"); #if TARGET_IPHONE_SIMULATOR CDLOGINFO(@"Denshion::CDLongAudioSource - workaround for OpenAL clobbered audio issue"); //This is a workaround for an issue in all simulators (tested to 3.1.2). Problem is //that OpenAL audio playback is clobbered when an AVAudioPlayer stops. Workaround //is to keep the player playing on an endless loop with 0 volume and then when //it is played again reset the volume and set loop count appropriately. //NB: this workaround is not foolproof but it is good enough for most situations. player.numberOfLoops = -1; player.volume = 0; [player play]; #endif if (delegate && [delegate respondsToSelector:@selector(cdAudioSourceDidFinishPlaying:)]) { [delegate cdAudioSourceDidFinishPlaying:self]; } } -(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player interrupted"); } -(void)audioPlayerEndInterruption:(AVAudioPlayer *)player { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player resumed"); if (self.backgroundMusic) { //Check if background music can play as rules may have changed during //the interruption. This is to address a specific issue in 4.x when //fast task switching if([CDAudioManager sharedManager].willPlayBackgroundMusic) { [player play]; } } else { [player play]; } } @end @interface CDAudioManager (PrivateMethods) -(BOOL) audioSessionSetActive:(BOOL) active; -(BOOL) audioSessionSetCategory:(NSString*) category; -(void) badAlContextHandler; @end @implementation CDAudioManager #define BACKGROUND_MUSIC_CHANNEL kASC_Left @synthesize soundEngine, willPlayBackgroundMusic; static CDAudioManager *sharedManager; static tAudioManagerState _sharedManagerState = kAMStateUninitialised; static tAudioManagerMode configuredMode; static BOOL configured = FALSE; -(BOOL) audioSessionSetActive:(BOOL) active { NSError *activationError = nil; if ([[AVAudioSession sharedInstance] setActive:active error:&activationError]) { _audioSessionActive = active; CDLOGINFO(@"Denshion::CDAudioManager - Audio session set active %i succeeded", active); return YES; } else { //Failed CDLOG(@"Denshion::CDAudioManager - Audio session set active %i failed with error %@", active, activationError); return NO; } } -(BOOL) audioSessionSetCategory:(NSString*) category { NSError *categoryError = nil; if ([[AVAudioSession sharedInstance] setCategory:category error:&categoryError]) { CDLOGINFO(@"Denshion::CDAudioManager - Audio session set category %@ succeeded", category); return YES; } else { //Failed CDLOG(@"Denshion::CDAudioManager - Audio session set category %@ failed with error %@", category, categoryError); return NO; } } // Init + (CDAudioManager *) sharedManager { @synchronized(self) { if (!sharedManager) { if (!configured) { //Set defaults here configuredMode = kAMM_FxPlusMusicIfNoOtherAudio; } sharedManager = [[CDAudioManager alloc] init:configuredMode]; _sharedManagerState = kAMStateInitialised;//This is only really relevant when using asynchronous initialisation [[NSNotificationCenter defaultCenter] postNotificationName:kCDN_AudioManagerInitialised object:nil]; } } return sharedManager; } + (tAudioManagerState) sharedManagerState { return _sharedManagerState; } /** * Call this to set up audio manager asynchronously. Initialisation is finished when sharedManagerState == kAMStateInitialised */ + (void) initAsynchronously: (tAudioManagerMode) mode { @synchronized(self) { if (_sharedManagerState == kAMStateUninitialised) { _sharedManagerState = kAMStateInitialising; [CDAudioManager configure:mode]; CDAsynchInitialiser *initOp = [[[CDAsynchInitialiser alloc] init] autorelease]; NSOperationQueue *opQ = [[[NSOperationQueue alloc] init] autorelease]; [opQ addOperation:initOp]; } } } + (id) alloc { @synchronized(self) { NSAssert(sharedManager == nil, @"Attempted to allocate a second instance of a singleton."); return [super alloc]; } return nil; } /* * Call this method before accessing the shared manager in order to configure the shared audio manager */ + (void) configure: (tAudioManagerMode) mode { configuredMode = mode; configured = TRUE; } -(BOOL) isOtherAudioPlaying { UInt32 isPlaying = 0; UInt32 varSize = sizeof(isPlaying); AudioSessionGetProperty (kAudioSessionProperty_OtherAudioIsPlaying, &varSize, &isPlaying); return (isPlaying != 0); } -(void) setMode:(tAudioManagerMode) mode { _mode = mode; switch (_mode) { case kAMM_FxOnly: //Share audio with other app CDLOGINFO(@"Denshion::CDAudioManager - Audio will be shared"); //_audioSessionCategory = kAudioSessionCategory_AmbientSound; _audioSessionCategory = AVAudioSessionCategoryAmbient; willPlayBackgroundMusic = NO; break; case kAMM_FxPlusMusic: //Use audio exclusively - if other audio is playing it will be stopped CDLOGINFO(@"Denshion::CDAudioManager - Audio will be exclusive"); //_audioSessionCategory = kAudioSessionCategory_SoloAmbientSound; _audioSessionCategory = AVAudioSessionCategorySoloAmbient; willPlayBackgroundMusic = YES; break; case kAMM_MediaPlayback: //Use audio exclusively, ignore mute switch and sleep CDLOGINFO(@"Denshion::CDAudioManager - Media playback mode, audio will be exclusive"); //_audioSessionCategory = kAudioSessionCategory_MediaPlayback; _audioSessionCategory = AVAudioSessionCategoryPlayback; willPlayBackgroundMusic = YES; break; case kAMM_PlayAndRecord: //Use audio exclusively, ignore mute switch and sleep, has inputs and outputs CDLOGINFO(@"Denshion::CDAudioManager - Play and record mode, audio will be exclusive"); //_audioSessionCategory = kAudioSessionCategory_PlayAndRecord; _audioSessionCategory = AVAudioSessionCategoryPlayAndRecord; willPlayBackgroundMusic = YES; break; default: //kAudioManagerFxPlusMusicIfNoOtherAudio if ([self isOtherAudioPlaying]) { CDLOGINFO(@"Denshion::CDAudioManager - Other audio is playing audio will be shared"); //_audioSessionCategory = kAudioSessionCategory_AmbientSound; _audioSessionCategory = AVAudioSessionCategoryAmbient; willPlayBackgroundMusic = NO; } else { CDLOGINFO(@"Denshion::CDAudioManager - Other audio is not playing audio will be exclusive"); //_audioSessionCategory = kAudioSessionCategory_SoloAmbientSound; _audioSessionCategory = AVAudioSessionCategorySoloAmbient; willPlayBackgroundMusic = YES; } break; } [self audioSessionSetCategory:_audioSessionCategory]; } /** * This method is used to work around various bugs introduced in 4.x OS versions. In some circumstances the * audio session is interrupted but never resumed, this results in the loss of OpenAL audio when following * standard practices. If we detect this situation then we will attempt to resume the audio session ourselves. * Known triggers: lock the device then unlock it (iOS 4.2 gm), playback a song using MPMediaPlayer (iOS 4.0) */ - (void) badAlContextHandler { if (_interrupted && alcGetCurrentContext() == NULL) { CDLOG(@"Denshion::CDAudioManager - bad OpenAL context detected, attempting to resume audio session"); [self audioSessionResumed]; } } - (id) init: (tAudioManagerMode) mode { if ((self = [super init])) { //Initialise the audio session AVAudioSession* session = [AVAudioSession sharedInstance]; session.delegate = self; _mode = mode; backgroundMusicCompletionSelector = nil; _isObservingAppEvents = FALSE; _mute = NO; _resigned = NO; _interrupted = NO; enabled_ = YES; _audioSessionActive = NO; [self setMode:mode]; soundEngine = [[CDSoundEngine alloc] init]; //Set up audioSource channels audioSourceChannels = [[NSMutableArray alloc] init]; CDLongAudioSource *leftChannel = [[CDLongAudioSource alloc] init]; leftChannel.backgroundMusic = YES; CDLongAudioSource *rightChannel = [[CDLongAudioSource alloc] init]; rightChannel.backgroundMusic = NO; [audioSourceChannels insertObject:leftChannel atIndex:kASC_Left]; [audioSourceChannels insertObject:rightChannel atIndex:kASC_Right]; [leftChannel release]; [rightChannel release]; //Used to support legacy APIs backgroundMusic = [self audioSourceForChannel:BACKGROUND_MUSIC_CHANNEL]; backgroundMusic.delegate = self; //Add handler for bad al context messages, these are posted by the sound engine. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(badAlContextHandler) name:kCDN_BadAlContext object:nil]; } return self; } -(void) dealloc { CDLOGINFO(@"Denshion::CDAudioManager - deallocating"); [self stopBackgroundMusic]; [soundEngine release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self audioSessionSetActive:NO]; [audioSourceChannels release]; [super dealloc]; } /** Retrieves the audio source for the specified channel */ -(CDLongAudioSource*) audioSourceForChannel:(tAudioSourceChannel) channel { return (CDLongAudioSource*)[audioSourceChannels objectAtIndex:channel]; } /** Loads the data from the specified file path to the channel's audio source */ -(CDLongAudioSource*) audioSourceLoad:(NSString*) filePath channel:(tAudioSourceChannel) channel { CDLongAudioSource *audioSource = [self audioSourceForChannel:channel]; if (audioSource) { [audioSource load:filePath]; } return audioSource; } -(BOOL) isBackgroundMusicPlaying { return [self.backgroundMusic isPlaying]; } //NB: originally I tried using a route change listener and intended to store the current route, //however, on a 3gs running 3.1.2 no route change is generated when the user switches the //ringer mute switch to off (i.e. enables sound) therefore polling is the only reliable way to //determine ringer switch state -(BOOL) isDeviceMuted { #if TARGET_IPHONE_SIMULATOR //Calling audio route stuff on the simulator causes problems return NO; #else CFStringRef newAudioRoute; UInt32 propertySize = sizeof (CFStringRef); AudioSessionGetProperty ( kAudioSessionProperty_AudioRoute, &propertySize, &newAudioRoute ); if (newAudioRoute == NULL) { //Don't expect this to happen but playing safe otherwise a null in the CFStringCompare will cause a crash return YES; } else { CFComparisonResult newDeviceIsMuted = CFStringCompare ( newAudioRoute, (CFStringRef) @"", 0 ); return (newDeviceIsMuted == kCFCompareEqualTo); } #endif } #pragma mark Audio Interrupt Protocol -(BOOL) mute { return _mute; } -(void) setMute:(BOOL) muteValue { if (muteValue != _mute) { _mute = muteValue; [soundEngine setMute:muteValue]; for( CDLongAudioSource *audioSource in audioSourceChannels) { audioSource.mute = muteValue; } } } -(BOOL) enabled { return enabled_; } -(void) setEnabled:(BOOL) enabledValue { if (enabledValue != enabled_) { enabled_ = enabledValue; [soundEngine setEnabled:enabled_]; for( CDLongAudioSource *audioSource in audioSourceChannels) { audioSource.enabled = enabled_; } } } -(CDLongAudioSource*) backgroundMusic { return backgroundMusic; } //Load background music ready for playing -(void) preloadBackgroundMusic:(NSString*) filePath { [self.backgroundMusic load:filePath]; } -(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop { [self.backgroundMusic load:filePath]; if (loop) { [self.backgroundMusic setNumberOfLoops:-1]; } else { [self.backgroundMusic setNumberOfLoops:0]; } if (!willPlayBackgroundMusic || _mute) { CDLOGINFO(@"Denshion::CDAudioManager - play bgm aborted because audio is not exclusive or sound is muted"); return; } [self.backgroundMusic play]; } -(void) stopBackgroundMusic { [self.backgroundMusic stop]; } -(void) pauseBackgroundMusic { [self.backgroundMusic pause]; } -(void) resumeBackgroundMusic { if (!willPlayBackgroundMusic || _mute) { CDLOGINFO(@"Denshion::CDAudioManager - resume bgm aborted because audio is not exclusive or sound is muted"); return; } if (![self.backgroundMusic paused]) { return; } [self.backgroundMusic resume]; } -(void) rewindBackgroundMusic { [self.backgroundMusic rewind]; } -(void) setBackgroundMusicCompletionListener:(id) listener selector:(SEL) selector { backgroundMusicCompletionListener = listener; backgroundMusicCompletionSelector = selector; } /* * Call this method to have the audio manager automatically handle application resign and * become active. Pass a tAudioManagerResignBehavior to indicate the desired behavior * for resigning and becoming active again. * * If autohandle is YES then the applicationWillResignActive and applicationDidBecomActive * methods are automatically called, otherwise you must call them yourself at the appropriate time. * * Based on idea of Dominique Bongard */ -(void) setResignBehavior:(tAudioManagerResignBehavior) resignBehavior autoHandle:(BOOL) autoHandle { if (!_isObservingAppEvents && autoHandle) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) name:@"UIApplicationWillResignActiveNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:@"UIApplicationDidBecomeActiveNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"UIApplicationWillTerminateNotification" object:nil]; _isObservingAppEvents = TRUE; } _resignBehavior = resignBehavior; } - (void) applicationWillResignActive { self->_resigned = YES; //Set the audio sesssion to one that allows sharing so that other audio won't be clobbered on resume [self audioSessionSetCategory:AVAudioSessionCategoryAmbient]; switch (_resignBehavior) { case kAMRBStopPlay: for( CDLongAudioSource *audioSource in audioSourceChannels) { if (audioSource.isPlaying) { audioSource->systemPaused = YES; audioSource->systemPauseLocation = audioSource.audioSourcePlayer.currentTime; [audioSource stop]; } else { //Music is either paused or stopped, if it is paused it will be restarted //by OS so we will stop it. audioSource->systemPaused = NO; [audioSource stop]; } } break; case kAMRBStop: //Stop music regardless of whether it is playing or not because if it was paused //then the OS would resume it for( CDLongAudioSource *audioSource in audioSourceChannels) { [audioSource stop]; } default: break; } CDLOGINFO(@"Denshion::CDAudioManager - handled resign active"); } //Called when application resigns active only if setResignBehavior has been called - (void) applicationWillResignActive:(NSNotification *) notification { [self applicationWillResignActive]; } - (void) applicationDidBecomeActive { if (self->_resigned) { _resigned = NO; //Reset the mode incase something changed with audio while we were inactive [self setMode:_mode]; switch (_resignBehavior) { case kAMRBStopPlay: //Music had been stopped but stop maintains current time //so playing again will continue from where music was before resign active. //We check if music can be played because while we were inactive the user might have //done something that should force music to not play such as starting a track in the iPod if (self.willPlayBackgroundMusic) { for( CDLongAudioSource *audioSource in audioSourceChannels) { if (audioSource->systemPaused) { [audioSource resume]; audioSource->systemPaused = NO; } } } break; default: break; } CDLOGINFO(@"Denshion::CDAudioManager - audio manager handled become active"); } } //Called when application becomes active only if setResignBehavior has been called - (void) applicationDidBecomeActive:(NSNotification *) notification { [self applicationDidBecomeActive]; } //Called when application terminates only if setResignBehavior has been called - (void) applicationWillTerminate:(NSNotification *) notification { CDLOGINFO(@"Denshion::CDAudioManager - audio manager handling terminate"); [self stopBackgroundMusic]; } /** The audio source completed playing */ - (void) cdAudioSourceDidFinishPlaying:(CDLongAudioSource *) audioSource { CDLOGINFO(@"Denshion::CDAudioManager - audio manager got told background music finished"); if (backgroundMusicCompletionSelector != nil) { [backgroundMusicCompletionListener performSelector:backgroundMusicCompletionSelector]; } } -(void) beginInterruption { CDLOGINFO(@"Denshion::CDAudioManager - begin interruption"); [self audioSessionInterrupted]; } -(void) endInterruption { CDLOGINFO(@"Denshion::CDAudioManager - end interruption"); [self audioSessionResumed]; } #if __CC_PLATFORM_IOS >= 40000 -(void) endInterruptionWithFlags:(NSUInteger)flags { CDLOGINFO(@"Denshion::CDAudioManager - interruption ended with flags %i",flags); if (flags == AVAudioSessionInterruptionFlags_ShouldResume) { [self audioSessionResumed]; } } #endif -(void)audioSessionInterrupted { if (!_interrupted) { CDLOGINFO(@"Denshion::CDAudioManager - Audio session interrupted"); _interrupted = YES; // Deactivate the current audio session [self audioSessionSetActive:NO]; if (alcGetCurrentContext() != NULL) { CDLOGINFO(@"Denshion::CDAudioManager - Setting OpenAL context to NULL"); ALenum error = AL_NO_ERROR; // set the current context to NULL will 'shutdown' openAL alcMakeContextCurrent(NULL); if((error = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDAudioManager - Error making context current %x\n", error); } #pragma unused(error) } } } -(void)audioSessionResumed { if (_interrupted) { CDLOGINFO(@"Denshion::CDAudioManager - Audio session resumed"); _interrupted = NO; BOOL activationResult = NO; // Reactivate the current audio session activationResult = [self audioSessionSetActive:YES]; //This code is to handle a problem with iOS 4.0 and 4.01 where reactivating the session can fail if //task switching is performed too rapidly. A test case that reliably reproduces the issue is to call the //iPhone and then hang up after two rings (timing may vary ;)) //Basically we keep waiting and trying to let the OS catch up with itself but the number of tries is //limited. if (!activationResult) { CDLOG(@"Denshion::CDAudioManager - Failure reactivating audio session, will try wait-try cycle"); int activateCount = 0; while (!activationResult && activateCount < 10) { [NSThread sleepForTimeInterval:0.5]; activationResult = [self audioSessionSetActive:YES]; activateCount++; CDLOGINFO(@"Denshion::CDAudioManager - Reactivation attempt %i status = %i",activateCount,activationResult); } } if (alcGetCurrentContext() == NULL) { CDLOGINFO(@"Denshion::CDAudioManager - Restoring OpenAL context"); ALenum error = AL_NO_ERROR; // Restore open al context alcMakeContextCurrent([soundEngine openALContext]); if((error = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDAudioManager - Error making context current%x\n", error); } #pragma unused(error) } } } +(void) end { [sharedManager release]; sharedManager = nil; } @end /////////////////////////////////////////////////////////////////////////////////////// @implementation CDLongAudioSourceFader -(void) _setTargetProperty:(float) newVal { ((CDLongAudioSource*)target).volume = newVal; } -(float) _getTargetProperty { return ((CDLongAudioSource*)target).volume; } -(void) _stopTarget { //Pause instead of stop as stop releases resources and causes problems in the simulator [((CDLongAudioSource*)target) pause]; } -(Class) _allowableType { return [CDLongAudioSource class]; } @end /////////////////////////////////////////////////////////////////////////////////////// @implementation CDBufferManager -(id) initWithEngine:(CDSoundEngine *) theSoundEngine { if ((self = [super init])) { soundEngine = theSoundEngine; loadedBuffers = [[NSMutableDictionary alloc] initWithCapacity:CD_BUFFERS_START]; freedBuffers = [[NSMutableArray alloc] init]; nextBufferId = 0; } return self; } -(void) dealloc { [loadedBuffers release]; [freedBuffers release]; [super dealloc]; } -(int) bufferForFile:(NSString*) filePath create:(BOOL) create { NSNumber* soundId = (NSNumber*)[loadedBuffers objectForKey:filePath]; if(soundId == nil) { if (create) { NSNumber* bufferId = nil; //First try to get a buffer from the free buffers if ([freedBuffers count] > 0) { bufferId = [[[freedBuffers lastObject] retain] autorelease]; [freedBuffers removeLastObject]; CDLOGINFO(@"Denshion::CDBufferManager reusing buffer id %i",[bufferId intValue]); } else { bufferId = [[NSNumber alloc] initWithInt:nextBufferId]; [bufferId autorelease]; CDLOGINFO(@"Denshion::CDBufferManager generating new buffer id %i",[bufferId intValue]); nextBufferId++; } if ([soundEngine loadBuffer:[bufferId intValue] filePath:filePath]) { //File successfully loaded CDLOGINFO(@"Denshion::CDBufferManager buffer loaded %@ %@",bufferId,filePath); [loadedBuffers setObject:bufferId forKey:filePath]; return [bufferId intValue]; } else { //File didn't load, put buffer id on free list [freedBuffers addObject:bufferId]; return kCDNoBuffer; } } else { //No matching buffer was found return kCDNoBuffer; } } else { return [soundId intValue]; } } -(void) releaseBufferForFile:(NSString *) filePath { int bufferId = [self bufferForFile:filePath create:NO]; if (bufferId != kCDNoBuffer) { [soundEngine unloadBuffer:bufferId]; [loadedBuffers removeObjectForKey:filePath]; NSNumber *freedBufferId = [[NSNumber alloc] initWithInt:bufferId]; [freedBufferId autorelease]; [freedBuffers addObject:freedBufferId]; } } @end ================================================ FILE: cocos2d/cocos/audio/ios/CDConfig.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #define COCOSDENSHION_VERSION "Aphex.rc" /** If enabled code useful for debugging such as parameter check assertions will be performed. If you experience any problems you should enable this and test your code with a debug build. */ //#define CD_DEBUG 1 /** The total number of sounds/buffers that can be loaded assuming memory is sufficient */ //Number of buffers slots that will be initially created #define CD_BUFFERS_START 64 //Number of buffers that will be added #define CD_BUFFERS_INCREMENT 16 /** If enabled, OpenAL code will use static buffers. When static buffers are used the audio data is managed outside of OpenAL, this eliminates a memcpy operation which leads to higher performance when loading sounds. However, the downside is that when the audio data is freed you must be certain that it is no longer being accessed otherwise your app will crash. Testing on OS 2.2.1 and 3.1.2 has shown that this may occur if a buffer is being used by a source with state = AL_PLAYING when the buffer is deleted. If the data is freed too quickly after the source is stopped then a crash will occur. The implemented workaround is that when static buffers are used the unloadBuffer code will wait for any playing sources to finish playing before the associated buffer and data are deleted, however, this delay may negate any performance gains that are achieved during loading. Performance tests on a 1st gen iPod running OS 2.2.1 loading the CocosDenshionDemo sounds were ~0.14 seconds without static buffers and ~0.12 seconds when using static buffers. */ //#define CD_USE_STATIC_BUFFERS 1 ================================================ FILE: cocos2d/cocos/audio/ios/CDOpenALSupport.h ================================================ /* Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2009 Apple Inc. All Rights Reserved. $Id$ */ /* This file contains code from version 1.1 and 1.4 of MyOpenALSupport.h taken from Apple's oalTouch version. The 1.4 version code is used for loading IMA4 files, however, this code causes very noticeable clicking when used to load wave files that are looped so the 1.1 version code is used specifically for loading wav files. */ #ifndef __CD_OPENAL_H #define __CD_OPENAL_H #ifdef __cplusplus extern "C" { #endif #import #import #import //Taken from oalTouch MyOpenALSupport 1.1 void* CDloadWaveAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate); void* CDloadCafAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate); void* CDGetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate); #ifdef __cplusplus } #endif #endif ================================================ FILE: cocos2d/cocos/audio/ios/CDOpenALSupport.m ================================================ /* Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2009 Apple Inc. All Rights Reserved. $Id: CDOpenALSupport.h 16 2010-03-11 06:22:10Z steveoldmeadow $ */ #import "CDOpenALSupport.h" #import "CocosDenshion.h" #import #import //Taken from oalTouch MyOpenALSupport 1.1 void* CDloadWaveAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate) { OSStatus err = noErr; UInt64 fileDataSize = 0; AudioStreamBasicDescription theFileFormat; UInt32 thePropertySize = sizeof(theFileFormat); AudioFileID afid = 0; void* theData = NULL; // Open a file with ExtAudioFileOpen() err = AudioFileOpenURL(inFileURL, kAudioFileReadPermission, 0, &afid); if(err) { CDLOG(@"MyGetOpenALAudioData: AudioFileOpenURL FAILED, Error = %ld\n", err); goto Exit; } // Get the audio data format err = AudioFileGetProperty(afid, kAudioFilePropertyDataFormat, &thePropertySize, &theFileFormat); if(err) { CDLOG(@"MyGetOpenALAudioData: AudioFileGetProperty(kAudioFileProperty_DataFormat) FAILED, Error = %ld\n", err); goto Exit; } if (theFileFormat.mChannelsPerFrame > 2) { CDLOG(@"MyGetOpenALAudioData - Unsupported Format, channel count is greater than stereo\n"); goto Exit; } if ((theFileFormat.mFormatID != kAudioFormatLinearPCM) || (!TestAudioFormatNativeEndian(theFileFormat))) { CDLOG(@"MyGetOpenALAudioData - Unsupported Format, must be little-endian PCM\n"); goto Exit; } if ((theFileFormat.mBitsPerChannel != 8) && (theFileFormat.mBitsPerChannel != 16)) { CDLOG(@"MyGetOpenALAudioData - Unsupported Format, must be 8 or 16 bit PCM\n"); goto Exit; } thePropertySize = sizeof(fileDataSize); err = AudioFileGetProperty(afid, kAudioFilePropertyAudioDataByteCount, &thePropertySize, &fileDataSize); if(err) { CDLOG(@"MyGetOpenALAudioData: AudioFileGetProperty(kAudioFilePropertyAudioDataByteCount) FAILED, Error = %ld\n", err); goto Exit; } // Read all the data into memory UInt32 dataSize = (UInt32)fileDataSize; theData = malloc(dataSize); if (theData) { memset(theData, 0, dataSize); AudioFileReadBytes(afid, false, 0, &dataSize, theData); if(err == noErr) { // success *outDataSize = (ALsizei)dataSize; //This fix was added by me, however, 8 bit sounds have a clipping sound at the end so aren't really usable (SO) if (theFileFormat.mBitsPerChannel == 16) { *outDataFormat = (theFileFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; } else { *outDataFormat = (theFileFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8; } *outSampleRate = (ALsizei)theFileFormat.mSampleRate; } else { // failure free (theData); theData = NULL; // make sure to return NULL CDLOG(@"MyGetOpenALAudioData: ExtAudioFileRead FAILED, Error = %ld\n", err); goto Exit; } } Exit: // Dispose the ExtAudioFileRef, it is no longer needed if (afid) AudioFileClose(afid); return theData; } //Taken from oalTouch MyOpenALSupport 1.4 void* CDloadCafAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate) { OSStatus status = noErr; BOOL abort = NO; SInt64 theFileLengthInFrames = 0; AudioStreamBasicDescription theFileFormat; UInt32 thePropertySize = sizeof(theFileFormat); ExtAudioFileRef extRef = NULL; void* theData = NULL; AudioStreamBasicDescription theOutputFormat; UInt32 dataSize = 0; // Open a file with ExtAudioFileOpen() status = ExtAudioFileOpenURL(inFileURL, &extRef); if (status != noErr) { CDLOG(@"MyGetOpenALAudioData: ExtAudioFileOpenURL FAILED, Error = %ld\n", status); abort = YES; } if (abort) goto Exit; // Get the audio data format status = ExtAudioFileGetProperty(extRef, kExtAudioFileProperty_FileDataFormat, &thePropertySize, &theFileFormat); if (status != noErr) { CDLOG(@"MyGetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileDataFormat) FAILED, Error = %ld\n", status); abort = YES; } if (abort) goto Exit; if (theFileFormat.mChannelsPerFrame > 2) { CDLOG(@"MyGetOpenALAudioData - Unsupported Format, channel count is greater than stereo\n"); abort = YES; } if (abort) goto Exit; // Set the client format to 16 bit signed integer (native-endian) data // Maintain the channel count and sample rate of the original source format theOutputFormat.mSampleRate = theFileFormat.mSampleRate; theOutputFormat.mChannelsPerFrame = theFileFormat.mChannelsPerFrame; theOutputFormat.mFormatID = kAudioFormatLinearPCM; theOutputFormat.mBytesPerPacket = 2 * theOutputFormat.mChannelsPerFrame; theOutputFormat.mFramesPerPacket = 1; theOutputFormat.mBytesPerFrame = 2 * theOutputFormat.mChannelsPerFrame; theOutputFormat.mBitsPerChannel = 16; theOutputFormat.mFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger; // Set the desired client (output) data format status = ExtAudioFileSetProperty(extRef, kExtAudioFileProperty_ClientDataFormat, sizeof(theOutputFormat), &theOutputFormat); if (status != noErr) { CDLOG(@"MyGetOpenALAudioData: ExtAudioFileSetProperty(kExtAudioFileProperty_ClientDataFormat) FAILED, Error = %ld\n", status); abort = YES; } if (abort) goto Exit; // Get the total frame count thePropertySize = sizeof(theFileLengthInFrames); status = ExtAudioFileGetProperty(extRef, kExtAudioFileProperty_FileLengthFrames, &thePropertySize, &theFileLengthInFrames); if (status != noErr) { CDLOG(@"MyGetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileLengthFrames) FAILED, Error = %ld\n", status); abort = YES; } if (abort) goto Exit; // Read all the data into memory dataSize = (UInt32) theFileLengthInFrames * theOutputFormat.mBytesPerFrame; theData = malloc(dataSize); if (theData) { memset(theData, 0, dataSize); AudioBufferList theDataBuffer; theDataBuffer.mNumberBuffers = 1; theDataBuffer.mBuffers[0].mDataByteSize = dataSize; theDataBuffer.mBuffers[0].mNumberChannels = theOutputFormat.mChannelsPerFrame; theDataBuffer.mBuffers[0].mData = theData; // Read the data into an AudioBufferList status = ExtAudioFileRead(extRef, (UInt32*)&theFileLengthInFrames, &theDataBuffer); if(status == noErr) { // success *outDataSize = (ALsizei)dataSize; *outDataFormat = (theOutputFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; *outSampleRate = (ALsizei)theOutputFormat.mSampleRate; } else { // failure free (theData); theData = NULL; // make sure to return NULL CDLOG(@"MyGetOpenALAudioData: ExtAudioFileRead FAILED, Error = %ld\n", status); abort = YES; } } if (abort) goto Exit; Exit: // Dispose the ExtAudioFileRef, it is no longer needed if (extRef) ExtAudioFileDispose(extRef); return theData; } void* CDGetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate) { CFStringRef extension = CFURLCopyPathExtension(inFileURL); CFComparisonResult isWavFile = 0; if (extension != NULL) { isWavFile = CFStringCompare (extension,(CFStringRef)@"wav", kCFCompareCaseInsensitive); CFRelease(extension); } if (isWavFile == kCFCompareEqualTo) { return CDloadWaveAudioData(inFileURL, outDataSize, outDataFormat, outSampleRate); } else { return CDloadCafAudioData(inFileURL, outDataSize, outDataFormat, outSampleRate); } } ================================================ FILE: cocos2d/cocos/audio/ios/CocosDenshion.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ /** @file @b IMPORTANT There are 3 different ways of using CocosDenshion. Depending on which you choose you will need to include different files and frameworks. @par SimpleAudioEngine This is recommended for basic audio requirements. If you just want to play some sound fx and some background music and have no interest in learning the lower level workings then this is the interface to use. Requirements: - Firmware: OS 2.2 or greater - Files: SimpleAudioEngine.*, CocosDenshion.* - Frameworks: OpenAL, AudioToolbox, AVFoundation @par CDAudioManager CDAudioManager is basically a thin wrapper around an AVAudioPlayer object used for playing background music and a CDSoundEngine object used for playing sound effects. It manages the audio session for you deals with audio session interruption. It is fairly low level and it is expected you have some understanding of the underlying technologies. For example, for many use cases regarding background music it is expected you will work directly with the backgroundMusic AVAudioPlayer which is exposed as a property. Requirements: - Firmware: OS 2.2 or greater - Files: CDAudioManager.*, CocosDenshion.* - Frameworks: OpenAL, AudioToolbox, AVFoundation @par CDSoundEngine CDSoundEngine is a sound engine built upon OpenAL and derived from Apple's oalTouch example. It can playback up to 32 sounds simultaneously with control over pitch, pan and gain. It can be set up to handle audio session interruption automatically. You may decide to use CDSoundEngine directly instead of CDAudioManager or SimpleAudioEngine because you require OS 2.0 compatibility. Requirements: - Firmware: OS 2.0 or greater - Files: CocosDenshion.* - Frameworks: OpenAL, AudioToolbox */ #import #import #import #import #import "CDConfig.h" #if !defined(CD_DEBUG) || CD_DEBUG == 0 #define CDLOG(...) do {} while (0) #define CDLOGINFO(...) do {} while (0) #elif CD_DEBUG == 1 #define CDLOG(...) NSLog(__VA_ARGS__) #define CDLOGINFO(...) do {} while (0) #elif CD_DEBUG > 1 #define CDLOG(...) NSLog(__VA_ARGS__) #define CDLOGINFO(...) NSLog(__VA_ARGS__) #endif // CD_DEBUG #import "CDOpenALSupport.h" //Tested source limit on 2.2.1 and 3.1.2 with up to 128 sources and appears to work. Older OS versions e.g 2.2 may support only 32 #define CD_SOURCE_LIMIT 32 //Total number of sources we will ever want, may actually get less #define CD_NO_SOURCE 0xFEEDFAC //Return value indicating playback failed i.e. no source #define CD_IGNORE_AUDIO_SESSION 0xBEEFBEE //Used internally to indicate audio session will not be handled #define CD_MUTE 0xFEEDBAB //Return value indicating sound engine is muted or non functioning #define CD_NO_SOUND = -1; #define CD_SAMPLE_RATE_HIGH 44100 #define CD_SAMPLE_RATE_MID 22050 #define CD_SAMPLE_RATE_LOW 16000 #define CD_SAMPLE_RATE_BASIC 8000 #define CD_SAMPLE_RATE_DEFAULT 44100 extern NSString * const kCDN_BadAlContext; extern NSString * const kCDN_AsynchLoadComplete; extern float const kCD_PitchDefault; extern float const kCD_PitchLowerOneOctave; extern float const kCD_PitchHigherOneOctave; extern float const kCD_PanDefault; extern float const kCD_PanFullLeft; extern float const kCD_PanFullRight; extern float const kCD_GainDefault; enum bufferState { CD_BS_EMPTY = 0, CD_BS_LOADED = 1, CD_BS_FAILED = 2 }; typedef struct _sourceGroup { int startIndex; int currentIndex; int totalSources; bool enabled; bool nonInterruptible; int *sourceStatuses;//pointer into array of source status information } sourceGroup; typedef struct _bufferInfo { ALuint bufferId; int bufferState; void* bufferData; ALenum format; ALsizei sizeInBytes; ALsizei frequencyInHertz; } bufferInfo; typedef struct _sourceInfo { bool usable; ALuint sourceId; ALuint attachedBufferId; } sourceInfo; #pragma mark CDAudioTransportProtocol @protocol CDAudioTransportProtocol /** Play the audio */ -(BOOL) play; /** Pause the audio, retain resources */ -(BOOL) pause; /** Stop the audio, release resources */ -(BOOL) stop; /** Return playback to beginning */ -(BOOL) rewind; @end #pragma mark CDAudioInterruptProtocol @protocol CDAudioInterruptProtocol /** Is audio mute */ -(BOOL) mute; /** If YES then audio is silenced but not stopped, calls to start new audio will proceed but silently */ -(void) setMute:(BOOL) muteValue; /** Is audio enabled */ -(BOOL) enabled; /** If NO then all audio is stopped and any calls to start new audio will be ignored */ -(void) setEnabled:(BOOL) enabledValue; @end #pragma mark CDUtilities /** Collection of utilities required by CocosDenshion */ @interface CDUtilities : NSObject { } /** Fundamentally the same as the corresponding method is FileUtils but added to break binding to cocos2d */ +(NSString*) fullPathFromRelativePath:(NSString*) relPath; @end #pragma mark CDSoundEngine /** CDSoundEngine is built upon OpenAL and works with SDK 2.0. CDSoundEngine is a sound engine built upon OpenAL and derived from Apple's oalTouch example. It can playback up to 32 sounds simultaneously with control over pitch, pan and gain. It can be set up to handle audio session interruption automatically. You may decide to use CDSoundEngine directly instead of CDAudioManager or SimpleAudioEngine because you require OS 2.0 compatibility. Requirements: - Firmware: OS 2.0 or greater - Files: CocosDenshion.* - Frameworks: OpenAL, AudioToolbox @since v0.8 */ @class CDSoundSource; @interface CDSoundEngine : NSObject { bufferInfo *_buffers; sourceInfo *_sources; sourceGroup *_sourceGroups; ALCcontext *context; NSUInteger _sourceGroupTotal; UInt32 _audioSessionCategory; BOOL _handleAudioSession; ALfloat _preMuteGain; NSObject *_mutexBufferLoad; BOOL mute_; BOOL enabled_; ALenum lastErrorCode_; BOOL functioning_; float asynchLoadProgress_; BOOL getGainWorks_; //For managing dynamic allocation of sources and buffers int sourceTotal_; int bufferTotal; } @property (readwrite, nonatomic) ALfloat masterGain; @property (readonly) ALenum lastErrorCode;//Last OpenAL error code that was generated @property (readonly) BOOL functioning;//Is the sound engine functioning @property (readwrite) float asynchLoadProgress; @property (readonly) BOOL getGainWorks;//Does getting the gain for a source work /** Total number of sources available */ @property (readonly) int sourceTotal; /** Total number of source groups that have been defined */ @property (readonly) NSUInteger sourceGroupTotal; /** Sets the sample rate for the audio mixer. For best performance this should match the sample rate of your audio content */ +(void) setMixerSampleRate:(Float32) sampleRate; /** Initializes the engine with a group definition and a total number of groups */ -(id)init; /** Plays a sound in a channel group with a pitch, pan and gain. The sound could played looped or not */ -(ALuint) playSound:(int) soundId sourceGroupId:(int)sourceGroupId pitch:(float) pitch pan:(float) pan gain:(float) gain loop:(BOOL) loop; /** Creates and returns a sound source object for the specified sound within the specified source group. */ -(CDSoundSource *) soundSourceForSound:(int) soundId sourceGroupId:(int) sourceGroupId; /** Stops playing a sound */ - (void) stopSound:(ALuint) sourceId; /** Stops playing a source group */ - (void) stopSourceGroup:(int) sourceGroupId; /** Stops all playing sounds */ -(void) stopAllSounds; /** Pause a sound */ -(void) pauseSound:(ALuint) sourceId; /** Pause all sounds */ -(void) pauseAllSounds; /** Resume a sound */ -(void) resumeSound:(ALuint) sourceId; /** Resume all sounds */ -(void) resumeAllSounds; -(void) defineSourceGroups:(NSArray*) sourceGroupDefinitions; -(void) defineSourceGroups:(int[]) sourceGroupDefinitions total:(NSUInteger) total; -(void) setSourceGroupNonInterruptible:(int) sourceGroupId isNonInterruptible:(BOOL) isNonInterruptible; -(void) setSourceGroupEnabled:(int) sourceGroupId enabled:(BOOL) enabled; -(BOOL) sourceGroupEnabled:(int) sourceGroupId; -(BOOL) loadBufferFromData:(int) soundId soundData:(ALvoid*) soundData format:(ALenum) format size:(ALsizei) size freq:(ALsizei) freq; -(BOOL) loadBuffer:(int) soundId filePath:(NSString*) filePath; -(void) loadBuffersAsynchronously:(NSArray *) loadRequests; -(BOOL) unloadBuffer:(int) soundId; -(ALCcontext *) openALContext; /** Returns the duration of the buffer in seconds or a negative value if the buffer id is invalid */ -(float) bufferDurationInSeconds:(int) soundId; /** Returns the size of the buffer in bytes or a negative value if the buffer id is invalid */ -(ALsizei) bufferSizeInBytes:(int) soundId; /** Returns the sampling frequency of the buffer in hertz or a negative value if the buffer id is invalid */ -(ALsizei) bufferFrequencyInHertz:(int) soundId; /** Used internally, never call unless you know what you are doing */ -(void) _soundSourcePreRelease:(CDSoundSource *) soundSource; @end #pragma mark CDSoundSource /** CDSoundSource is a wrapper around an OpenAL sound source. It allows you to manipulate properties such as pitch, gain, pan and looping while the sound is playing. CDSoundSource is based on the old CDSourceWrapper class but with much added functionality. @since v1.0 */ @interface CDSoundSource : NSObject { ALenum lastError; @public ALuint _sourceId; ALuint _sourceIndex; CDSoundEngine* _engine; int _soundId; float _preMuteGain; BOOL enabled_; BOOL mute_; } @property (readwrite, nonatomic) float pitch; @property (readwrite, nonatomic) float gain; @property (readwrite, nonatomic) float pan; @property (readwrite, nonatomic) BOOL looping; @property (readonly) BOOL isPlaying; @property (readwrite, nonatomic) int soundId; /** Returns the duration of the attached buffer in seconds or a negative value if the buffer is invalid */ @property (readonly) float durationInSeconds; /** Stores the last error code that occurred. Check against AL_NO_ERROR */ @property (readonly) ALenum lastError; /** Do not init yourself, get an instance from the sourceForSound factory method on CDSoundEngine */ -(id)init:(ALuint) theSourceId sourceIndex:(int) index soundEngine:(CDSoundEngine*) engine; @end #pragma mark CDAudioInterruptTargetGroup /** Container for objects that implement audio interrupt protocol i.e. they can be muted and enabled. Setting mute and enabled for the group propagates to all children. Designed to be used with your CDSoundSource objects to get them to comply with global enabled and mute settings if that is what you want to do.*/ @interface CDAudioInterruptTargetGroup : NSObject { BOOL mute_; BOOL enabled_; NSMutableArray *children_; } -(void) addAudioInterruptTarget:(NSObject*) interruptibleTarget; @end #pragma mark CDAsynchBufferLoader /** CDAsynchBufferLoader TODO */ @interface CDAsynchBufferLoader : NSOperation { NSArray *_loadRequests; CDSoundEngine *_soundEngine; } -(id) init:(NSArray *)loadRequests soundEngine:(CDSoundEngine *) theSoundEngine; @end #pragma mark CDBufferLoadRequest /** CDBufferLoadRequest */ @interface CDBufferLoadRequest: NSObject { NSString *filePath; int soundId; //id loader; } @property (readonly) NSString *filePath; @property (readonly) int soundId; - (id)init:(int) theSoundId filePath:(const NSString *) theFilePath; @end /** Interpolation type */ typedef enum { kIT_Linear, //!Straight linear interpolation fade kIT_SCurve, //!S curved interpolation kIT_Exponential //!Exponential interpolation } tCDInterpolationType; #pragma mark CDFloatInterpolator @interface CDFloatInterpolator: NSObject { float start; float end; float lastValue; tCDInterpolationType interpolationType; } @property (readwrite, nonatomic) float start; @property (readwrite, nonatomic) float end; @property (readwrite, nonatomic) tCDInterpolationType interpolationType; /** Return a value between min and max based on t which represents fractional progress where 0 is the start and 1 is the end */ -(float) interpolate:(float) t; -(id) init:(tCDInterpolationType) type startVal:(float) startVal endVal:(float) endVal; @end #pragma mark CDPropertyModifier /** Base class for classes that modify properties such as pitch, pan and gain */ @interface CDPropertyModifier: NSObject { CDFloatInterpolator *interpolator; float startValue; float endValue; id target; BOOL stopTargetWhenComplete; } @property (readwrite, nonatomic) BOOL stopTargetWhenComplete; @property (readwrite, nonatomic) float startValue; @property (readwrite, nonatomic) float endValue; @property (readwrite, nonatomic) tCDInterpolationType interpolationType; -(id) init:(id) theTarget interpolationType:(tCDInterpolationType) type startVal:(float) startVal endVal:(float) endVal; /** Set to a fractional value between 0 and 1 where 0 equals the start and 1 equals the end*/ -(void) modify:(float) t; -(void) _setTargetProperty:(float) newVal; -(float) _getTargetProperty; -(void) _stopTarget; -(Class) _allowableType; @end #pragma mark CDSoundSourceFader /** Fader for CDSoundSource objects */ @interface CDSoundSourceFader : CDPropertyModifier{} @end #pragma mark CDSoundSourcePanner /** Panner for CDSoundSource objects */ @interface CDSoundSourcePanner : CDPropertyModifier{} @end #pragma mark CDSoundSourcePitchBender /** Pitch bender for CDSoundSource objects */ @interface CDSoundSourcePitchBender : CDPropertyModifier{} @end #pragma mark CDSoundEngineFader /** Fader for CDSoundEngine objects */ @interface CDSoundEngineFader : CDPropertyModifier{} @end ================================================ FILE: cocos2d/cocos/audio/ios/CocosDenshion.m ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "CocosDenshion.h" ALvoid alBufferDataStaticProc(const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq); ALvoid alcMacOSXMixerOutputRateProc(const ALdouble value); typedef ALvoid AL_APIENTRY (*alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq); ALvoid alBufferDataStaticProc(const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq) { static alBufferDataStaticProcPtr proc = NULL; if (proc == NULL) { proc = (alBufferDataStaticProcPtr) alcGetProcAddress(NULL, (const ALCchar*) "alBufferDataStatic"); } if (proc) proc(bid, format, data, size, freq); return; } typedef ALvoid AL_APIENTRY (*alcMacOSXMixerOutputRateProcPtr) (const ALdouble value); ALvoid alcMacOSXMixerOutputRateProc(const ALdouble value) { static alcMacOSXMixerOutputRateProcPtr proc = NULL; if (proc == NULL) { proc = (alcMacOSXMixerOutputRateProcPtr) alcGetProcAddress(NULL, (const ALCchar*) "alcMacOSXMixerOutputRate"); } if (proc) proc(value); return; } NSString * const kCDN_BadAlContext = @"kCDN_BadAlContext"; NSString * const kCDN_AsynchLoadComplete = @"kCDN_AsynchLoadComplete"; float const kCD_PitchDefault = 1.0f; float const kCD_PitchLowerOneOctave = 0.5f; float const kCD_PitchHigherOneOctave = 2.0f; float const kCD_PanDefault = 0.0f; float const kCD_PanFullLeft = -1.0f; float const kCD_PanFullRight = 1.0f; float const kCD_GainDefault = 1.0f; @interface CDSoundEngine (PrivateMethods) -(BOOL) _initOpenAL; -(void) _testGetGain; -(void) _dumpSourceGroupsInfo; -(void) _getSourceIndexForSourceGroup; -(void) _freeSourceGroups; -(BOOL) _setUpSourceGroups:(int[]) definitions total:(NSUInteger) total; @end #pragma mark - CDUtilities @implementation CDUtilities +(NSString*) fullPathFromRelativePath:(NSString*) relPath { // do not convert an absolute path (starting with '/') if(([relPath length] > 0) && ([relPath characterAtIndex:0] == '/')) { return relPath; } NSMutableArray *imagePathComponents = [NSMutableArray arrayWithArray:[relPath pathComponents]]; NSString *file = [imagePathComponents lastObject]; [imagePathComponents removeLastObject]; NSString *imageDirectory = [NSString pathWithComponents:imagePathComponents]; NSString *fullpath = [[NSBundle mainBundle] pathForResource:file ofType:nil inDirectory:imageDirectory]; if (fullpath == nil) fullpath = relPath; return fullpath; } @end #pragma mark - #pragma mark CDSoundEngine @implementation CDSoundEngine static Float32 _mixerSampleRate; static BOOL _mixerRateSet = NO; @synthesize lastErrorCode = lastErrorCode_; @synthesize functioning = functioning_; @synthesize asynchLoadProgress = asynchLoadProgress_; @synthesize getGainWorks = getGainWorks_; @synthesize sourceTotal = sourceTotal_; + (void) setMixerSampleRate:(Float32) sampleRate { _mixerRateSet = YES; _mixerSampleRate = sampleRate; } - (void) _testGetGain { float testValue = 0.7f; ALuint testSourceId = _sources[0].sourceId; alSourcef(testSourceId, AL_GAIN, 0.0f);//Start from know value alSourcef(testSourceId, AL_GAIN, testValue); ALfloat gainVal; alGetSourcef(testSourceId, AL_GAIN, &gainVal); getGainWorks_ = (gainVal == testValue); } //Generate sources one at a time until we fail -(void) _generateSources { _sources = (sourceInfo*)malloc( sizeof(_sources[0]) * CD_SOURCE_LIMIT); BOOL hasFailed = NO; sourceTotal_ = 0; alGetError();//Clear error while (!hasFailed && sourceTotal_ < CD_SOURCE_LIMIT) { alGenSources(1, &(_sources[sourceTotal_].sourceId)); if (alGetError() == AL_NO_ERROR) { //Now try attaching source to null buffer alSourcei(_sources[sourceTotal_].sourceId, AL_BUFFER, 0); if (alGetError() == AL_NO_ERROR) { _sources[sourceTotal_].usable = true; sourceTotal_++; } else { hasFailed = YES; } } else { _sources[sourceTotal_].usable = false; hasFailed = YES; } } //Mark the rest of the sources as not usable for (int i=sourceTotal_; i < CD_SOURCE_LIMIT; i++) { _sources[i].usable = false; } } -(void) _generateBuffers:(int) startIndex endIndex:(int) endIndex { if (_buffers) { alGetError(); for (int i=startIndex; i <= endIndex; i++) { alGenBuffers(1, &_buffers[i].bufferId); _buffers[i].bufferData = NULL; if (alGetError() == AL_NO_ERROR) { _buffers[i].bufferState = CD_BS_EMPTY; } else { _buffers[i].bufferState = CD_BS_FAILED; CDLOG(@"Denshion::CDSoundEngine - buffer creation failed %i",i); } } } } /** * Internal method called during init */ - (BOOL) _initOpenAL { //ALenum error; context = NULL; ALCdevice *newDevice = NULL; //Set the mixer rate for the audio mixer if (!_mixerRateSet) { _mixerSampleRate = CD_SAMPLE_RATE_DEFAULT; } alcMacOSXMixerOutputRateProc(_mixerSampleRate); CDLOGINFO(@"Denshion::CDSoundEngine - mixer output rate set to %0.2f",_mixerSampleRate); // Create a new OpenAL Device // Pass NULL to specify the system's default output device newDevice = alcOpenDevice(NULL); if (newDevice != NULL) { // Create a new OpenAL Context // The new context will render to the OpenAL Device just created context = alcCreateContext(newDevice, 0); if (context != NULL) { // Make the new context the Current OpenAL Context alcMakeContextCurrent(context); // Create some OpenAL Buffer Objects [self _generateBuffers:0 endIndex:bufferTotal-1]; // Create some OpenAL Source Objects [self _generateSources]; } } else { return FALSE;//No device } alGetError();//Clear error return TRUE; } - (void) dealloc { ALCcontext *currentContext = NULL; ALCdevice *device = NULL; [self stopAllSounds]; CDLOGINFO(@"Denshion::CDSoundEngine - Deallocing sound engine."); [self _freeSourceGroups]; // Delete the Sources CDLOGINFO(@"Denshion::CDSoundEngine - deleting sources."); for (int i=0; i < sourceTotal_; i++) { alSourcei(_sources[i].sourceId, AL_BUFFER, 0);//Detach from current buffer alDeleteSources(1, &(_sources[i].sourceId)); if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - Error deleting source! %x\n", lastErrorCode_); } } // Delete the Buffers CDLOGINFO(@"Denshion::CDSoundEngine - deleting buffers."); for (int i=0; i < bufferTotal; i++) { alDeleteBuffers(1, &_buffers[i].bufferId); #ifdef CD_USE_STATIC_BUFFERS if (_buffers[i].bufferData) { free(_buffers[i].bufferData); } #endif } CDLOGINFO(@"Denshion::CDSoundEngine - free buffers."); free(_buffers); currentContext = alcGetCurrentContext(); //Get device for active context device = alcGetContextsDevice(currentContext); //Release context CDLOGINFO(@"Denshion::CDSoundEngine - destroy context."); alcMakeContextCurrent(NULL); alcDestroyContext(currentContext); //Close device CDLOGINFO(@"Denshion::CDSoundEngine - close device."); alcCloseDevice(device); CDLOGINFO(@"Denshion::CDSoundEngine - free sources."); free(_sources); //Release mutexes [_mutexBufferLoad release]; [super dealloc]; } -(NSUInteger) sourceGroupTotal { return _sourceGroupTotal; } -(void) _freeSourceGroups { CDLOGINFO(@"Denshion::CDSoundEngine freeing source groups"); if(_sourceGroups) { for (int i=0; i < _sourceGroupTotal; i++) { if (_sourceGroups[i].sourceStatuses) { free(_sourceGroups[i].sourceStatuses); CDLOGINFO(@"Denshion::CDSoundEngine freed source statuses %i",i); } } free(_sourceGroups); } } -(BOOL) _redefineSourceGroups:(int[]) definitions total:(NSUInteger) total { if (_sourceGroups) { //Stop all sounds [self stopAllSounds]; //Need to free source groups [self _freeSourceGroups]; } return [self _setUpSourceGroups:definitions total:total]; } -(BOOL) _setUpSourceGroups:(int[]) definitions total:(NSUInteger) total { _sourceGroups = (sourceGroup *)malloc( sizeof(_sourceGroups[0]) * total); if(!_sourceGroups) { CDLOG(@"Denshion::CDSoundEngine - source groups memory allocation failed"); return NO; } _sourceGroupTotal = total; int sourceCount = 0; for (int i=0; i < _sourceGroupTotal; i++) { _sourceGroups[i].startIndex = 0; _sourceGroups[i].currentIndex = _sourceGroups[i].startIndex; _sourceGroups[i].enabled = false; _sourceGroups[i].nonInterruptible = false; _sourceGroups[i].totalSources = definitions[i]; _sourceGroups[i].sourceStatuses = malloc(sizeof(_sourceGroups[i].sourceStatuses[0]) * _sourceGroups[i].totalSources); if (_sourceGroups[i].sourceStatuses) { for (int j=0; j < _sourceGroups[i].totalSources; j++) { //First bit is used to indicate whether source is locked, index is shifted back 1 bit _sourceGroups[i].sourceStatuses[j] = (sourceCount + j) << 1; } } sourceCount += definitions[i]; } return YES; } -(void) defineSourceGroups:(int[]) sourceGroupDefinitions total:(NSUInteger) total { [self _redefineSourceGroups:sourceGroupDefinitions total:total]; } -(void) defineSourceGroups:(NSArray*) sourceGroupDefinitions { CDLOGINFO(@"Denshion::CDSoundEngine - source groups defined by NSArray."); NSUInteger totalDefs = [sourceGroupDefinitions count]; int* defs = (int *)malloc( sizeof(int) * totalDefs); int currentIndex = 0; for (id currentDef in sourceGroupDefinitions) { if ([currentDef isKindOfClass:[NSNumber class]]) { defs[currentIndex] = (int)[(NSNumber*)currentDef integerValue]; CDLOGINFO(@"Denshion::CDSoundEngine - found definition %i.",defs[currentIndex]); } else { CDLOG(@"Denshion::CDSoundEngine - warning, did not understand source definition."); defs[currentIndex] = 0; } currentIndex++; } [self _redefineSourceGroups:defs total:totalDefs]; free(defs); } - (id)init { if ((self = [super init])) { //Create mutexes _mutexBufferLoad = [[NSObject alloc] init]; asynchLoadProgress_ = 0.0f; bufferTotal = CD_BUFFERS_START; _buffers = (bufferInfo *)malloc( sizeof(_buffers[0]) * bufferTotal); // Initialize our OpenAL environment if ([self _initOpenAL]) { //Set up the default source group - a single group that contains all the sources int sourceDefs[1]; sourceDefs[0] = self.sourceTotal; [self _setUpSourceGroups:sourceDefs total:1]; functioning_ = YES; //Synchronize premute gain _preMuteGain = self.masterGain; mute_ = NO; enabled_ = YES; //Test whether get gain works for sources [self _testGetGain]; } else { //Something went wrong with OpenAL functioning_ = NO; } } return self; } /** * Delete the buffer identified by soundId * @return true if buffer deleted successfully, otherwise false */ - (BOOL) unloadBuffer:(int) soundId { //Ensure soundId is within array bounds otherwise memory corruption will occur if (soundId < 0 || soundId >= bufferTotal) { CDLOG(@"Denshion::CDSoundEngine - soundId is outside array bounds, maybe you need to increase CD_MAX_BUFFERS"); return FALSE; } //Before a buffer can be deleted any sources that are attached to it must be stopped for (int i=0; i < sourceTotal_; i++) { //Note: tried getting the AL_BUFFER attribute of the source instead but doesn't //appear to work on a device - just returned zero. if (_buffers[soundId].bufferId == _sources[i].attachedBufferId) { CDLOG(@"Denshion::CDSoundEngine - Found attached source %i %i %i",i,_buffers[soundId].bufferId,_sources[i].sourceId); #ifdef CD_USE_STATIC_BUFFERS //When using static buffers a crash may occur if a source is playing with a buffer that is about //to be deleted even though we stop the source and successfully delete the buffer. Crash is confirmed //on 2.2.1 and 3.1.2, however, it will only occur if a source is used rapidly after having its prior //data deleted. To avoid any possibility of the crash we wait for the source to finish playing. ALint state; alGetSourcei(_sources[i].sourceId, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) { CDLOG(@"Denshion::CDSoundEngine - waiting for source to complete playing before removing buffer data"); alSourcei(_sources[i].sourceId, AL_LOOPING, FALSE);//Turn off looping otherwise loops will never end while (state == AL_PLAYING) { alGetSourcei(_sources[i].sourceId, AL_SOURCE_STATE, &state); usleep(10000); } } #endif //Stop source and detach alSourceStop(_sources[i].sourceId); if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error stopping source: %x\n", lastErrorCode_); } alSourcei(_sources[i].sourceId, AL_BUFFER, 0);//Attach to "NULL" buffer to detach if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error detaching buffer: %x\n", lastErrorCode_); } else { //Record that source is now attached to nothing _sources[i].attachedBufferId = 0; } } } alDeleteBuffers(1, &_buffers[soundId].bufferId); if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error deleting buffer: %x\n", lastErrorCode_); _buffers[soundId].bufferState = CD_BS_FAILED; return FALSE; } else { #ifdef CD_USE_STATIC_BUFFERS //Free previous data, if alDeleteBuffer has returned without error then no if (_buffers[soundId].bufferData) { CDLOGINFO(@"Denshion::CDSoundEngine - freeing static data for soundId %i @ %i",soundId,_buffers[soundId].bufferData); free(_buffers[soundId].bufferData);//Free the old data _buffers[soundId].bufferData = NULL; } #endif } alGenBuffers(1, &_buffers[soundId].bufferId); if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error regenerating buffer: %x\n", lastErrorCode_); _buffers[soundId].bufferState = CD_BS_FAILED; return FALSE; } else { //We now have an empty buffer _buffers[soundId].bufferState = CD_BS_EMPTY; CDLOGINFO(@"Denshion::CDSoundEngine - buffer %i successfully unloaded\n",soundId); return TRUE; } } /** * Load buffers asynchronously * Check asynchLoadProgress for progress. asynchLoadProgress represents fraction of completion. When it equals 1.0 loading * is complete. NB: asynchLoadProgress is simply based on the number of load requests, it does not take into account * file sizes. * @param An array of CDBufferLoadRequest objects */ - (void) loadBuffersAsynchronously:(NSArray *) loadRequests { @synchronized(self) { asynchLoadProgress_ = 0.0f; CDAsynchBufferLoader *loaderOp = [[[CDAsynchBufferLoader alloc] init:loadRequests soundEngine:self] autorelease]; NSOperationQueue *opQ = [[[NSOperationQueue alloc] init] autorelease]; [opQ addOperation:loaderOp]; } } -(BOOL) _resizeBuffers:(int) increment { void * tmpBufferInfos = realloc( _buffers, sizeof(_buffers[0]) * (bufferTotal + increment) ); if(!tmpBufferInfos) { free(tmpBufferInfos); return NO; } else { _buffers = tmpBufferInfos; int oldBufferTotal = bufferTotal; bufferTotal = bufferTotal + increment; [self _generateBuffers:oldBufferTotal endIndex:bufferTotal-1]; return YES; } } -(BOOL) loadBufferFromData:(int) soundId soundData:(ALvoid*) soundData format:(ALenum) format size:(ALsizei) size freq:(ALsizei) freq { @synchronized(_mutexBufferLoad) { if (!functioning_) { //OpenAL initialisation has previously failed CDLOG(@"Denshion::CDSoundEngine - Loading buffer failed because sound engine state != functioning"); return FALSE; } //Ensure soundId is within array bounds otherwise memory corruption will occur if (soundId < 0) { CDLOG(@"Denshion::CDSoundEngine - soundId is negative"); return FALSE; } if (soundId >= bufferTotal) { //Need to resize the buffers int requiredIncrement = CD_BUFFERS_INCREMENT; while (bufferTotal + requiredIncrement < soundId) { requiredIncrement += CD_BUFFERS_INCREMENT; } CDLOGINFO(@"Denshion::CDSoundEngine - attempting to resize buffers by %i for sound %i",requiredIncrement,soundId); if (![self _resizeBuffers:requiredIncrement]) { CDLOG(@"Denshion::CDSoundEngine - buffer resize failed"); return FALSE; } } if (soundData) { if (_buffers[soundId].bufferState != CD_BS_EMPTY) { CDLOGINFO(@"Denshion::CDSoundEngine - non empty buffer, regenerating"); if (![self unloadBuffer:soundId]) { //Deletion of buffer failed, delete buffer routine has set buffer state and lastErrorCode return NO; } } #ifdef CD_DEBUG //Check that sample rate matches mixer rate and warn if they do not if (freq != (int)_mixerSampleRate) { CDLOGINFO(@"Denshion::CDSoundEngine - WARNING sample rate does not match mixer sample rate performance may not be optimal."); } #endif #ifdef CD_USE_STATIC_BUFFERS alBufferDataStaticProc(_buffers[soundId].bufferId, format, soundData, size, freq); _buffers[soundId].bufferData = data;//Save the pointer to the new data #else alBufferData(_buffers[soundId].bufferId, format, soundData, size, freq); #endif if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error attaching audio to buffer: %x", lastErrorCode_); _buffers[soundId].bufferState = CD_BS_FAILED; return FALSE; } } else { CDLOG(@"Denshion::CDSoundEngine Buffer data is null!"); _buffers[soundId].bufferState = CD_BS_FAILED; return FALSE; } _buffers[soundId].format = format; _buffers[soundId].sizeInBytes = size; _buffers[soundId].frequencyInHertz = freq; _buffers[soundId].bufferState = CD_BS_LOADED; CDLOGINFO(@"Denshion::CDSoundEngine Buffer %i loaded format:%i freq:%i size:%i",soundId,format,freq,size); return TRUE; }//end mutex } /** * Load sound data for later play back. * @return TRUE if buffer loaded okay for play back otherwise false */ - (BOOL) loadBuffer:(int) soundId filePath:(NSString*) filePath { ALvoid* data; ALenum format; ALsizei size; ALsizei freq; CDLOGINFO(@"Denshion::CDSoundEngine - Loading openAL buffer %i %@", soundId, filePath); CFURLRef fileURL = nil; NSString *path = [CDUtilities fullPathFromRelativePath:filePath]; if (path) { fileURL = (CFURLRef)[[NSURL fileURLWithPath:path] retain]; } if (fileURL) { data = CDGetOpenALAudioData(fileURL, &size, &format, &freq); CFRelease(fileURL); BOOL result = [self loadBufferFromData:soundId soundData:data format:format size:size freq:freq]; #ifndef CD_USE_STATIC_BUFFERS free(data);//Data can be freed here because alBufferData performs a memcpy #endif return result; } else { CDLOG(@"Denshion::CDSoundEngine Could not find file!\n"); //Don't change buffer state here as it will be the same as before method was called return FALSE; } } -(BOOL) validateBufferId:(int) soundId { if (soundId < 0 || soundId >= bufferTotal) { CDLOGINFO(@"Denshion::CDSoundEngine - validateBufferId buffer outside range %i",soundId); return NO; } else if (_buffers[soundId].bufferState != CD_BS_LOADED) { CDLOGINFO(@"Denshion::CDSoundEngine - validateBufferId invalide buffer state %i",soundId); return NO; } else { return YES; } } -(float) bufferDurationInSeconds:(int) soundId { if ([self validateBufferId:soundId]) { float factor = 0.0f; switch (_buffers[soundId].format) { case AL_FORMAT_MONO8: factor = 1.0f; break; case AL_FORMAT_MONO16: factor = 0.5f; break; case AL_FORMAT_STEREO8: factor = 0.5f; break; case AL_FORMAT_STEREO16: factor = 0.25f; break; } return (float)_buffers[soundId].sizeInBytes/(float)_buffers[soundId].frequencyInHertz * factor; } else { return -1.0f; } } -(ALsizei) bufferSizeInBytes:(int) soundId { if ([self validateBufferId:soundId]) { return _buffers[soundId].sizeInBytes; } else { return -1.0f; } } -(ALsizei) bufferFrequencyInHertz:(int) soundId { if ([self validateBufferId:soundId]) { return _buffers[soundId].frequencyInHertz; } else { return -1.0f; } } - (ALfloat) masterGain { if (mute_) { //When mute the real gain will always be 0 therefore return the preMuteGain value return _preMuteGain; } else { ALfloat gain; alGetListenerf(AL_GAIN, &gain); return gain; } } /** * Overall gain setting multiplier. e.g 0.5 is half the gain. */ - (void) setMasterGain:(ALfloat) newGainValue { if (mute_) { _preMuteGain = newGainValue; } else { alListenerf(AL_GAIN, newGainValue); } } #pragma mark CDSoundEngine AudioInterrupt protocol - (BOOL) mute { return mute_; } /** * Setting mute silences all sounds but playing sounds continue to advance playback */ - (void) setMute:(BOOL) newMuteValue { if (newMuteValue == mute_) { return; } mute_ = newMuteValue; if (mute_) { //Remember what the gain was _preMuteGain = self.masterGain; //Set gain to 0 - do not use the property as this will adjust preMuteGain when muted alListenerf(AL_GAIN, 0.0f); } else { //Restore gain to what it was before being muted self.masterGain = _preMuteGain; } } - (BOOL) enabled { return enabled_; } - (void) setEnabled:(BOOL)enabledValue { if (enabled_ == enabledValue) { return; } enabled_ = enabledValue; if (enabled_ == NO) { [self stopAllSounds]; } } -(void) _lockSource:(int) sourceIndex lock:(BOOL) lock { BOOL found = NO; for (int i=0; i < _sourceGroupTotal && !found; i++) { if (_sourceGroups[i].sourceStatuses) { for (int j=0; j < _sourceGroups[i].totalSources && !found; j++) { //First bit is used to indicate whether source is locked, index is shifted back 1 bit if((_sourceGroups[i].sourceStatuses[j] >> 1)==sourceIndex) { if (lock) { //Set first bit to lock this source _sourceGroups[i].sourceStatuses[j] |= 1; } else { //Unset first bit to unlock this source _sourceGroups[i].sourceStatuses[j] &= ~1; } found = YES; } } } } } -(int) _getSourceIndexForSourceGroup:(int)sourceGroupId { //Ensure source group id is valid to prevent memory corruption if (sourceGroupId < 0 || sourceGroupId >= _sourceGroupTotal) { CDLOG(@"Denshion::CDSoundEngine invalid source group id %i",sourceGroupId); return CD_NO_SOURCE; } int sourceIndex = -1;//Using -1 to indicate no source found BOOL complete = NO; ALint sourceState = 0; sourceGroup *thisSourceGroup = &_sourceGroups[sourceGroupId]; thisSourceGroup->currentIndex = thisSourceGroup->startIndex; while (!complete) { //Iterate over sources looking for one that is not locked, first bit indicates if source is locked if ((thisSourceGroup->sourceStatuses[thisSourceGroup->currentIndex] & 1) == 0) { //This source is not locked sourceIndex = thisSourceGroup->sourceStatuses[thisSourceGroup->currentIndex] >> 1;//shift back to get the index if (thisSourceGroup->nonInterruptible) { //Check if this source is playing, if so it can't be interrupted alGetSourcei(_sources[sourceIndex].sourceId, AL_SOURCE_STATE, &sourceState); if (sourceState != AL_PLAYING) { //complete = YES; //Set start index so next search starts at the next position thisSourceGroup->startIndex = thisSourceGroup->currentIndex + 1; break; } else { sourceIndex = -1;//The source index was no good because the source was playing } } else { //complete = YES; //Set start index so next search starts at the next position thisSourceGroup->startIndex = thisSourceGroup->currentIndex + 1; break; } } thisSourceGroup->currentIndex++; if (thisSourceGroup->currentIndex >= thisSourceGroup->totalSources) { //Reset to the beginning thisSourceGroup->currentIndex = 0; } if (thisSourceGroup->currentIndex == thisSourceGroup->startIndex) { //We have looped around and got back to the start complete = YES; } } //Reset start index to beginning if beyond bounds if (thisSourceGroup->startIndex >= thisSourceGroup->totalSources) { thisSourceGroup->startIndex = 0; } if (sourceIndex >= 0) { return sourceIndex; } else { return CD_NO_SOURCE; } } /** * Play a sound. * @param soundId the id of the sound to play (buffer id). * @param SourceGroupId the source group that will be used to play the sound. * @param pitch pitch multiplier. e.g 1.0 is unaltered, 0.5 is 1 octave lower. * @param pan stereo position. -1 is fully left, 0 is centre and 1 is fully right. * @param gain gain multiplier. e.g. 1.0 is unaltered, 0.5 is half the gain * @param loop should the sound be looped or one shot. * @return the id of the source being used to play the sound or CD_MUTE if the sound engine is muted or non functioning * or CD_NO_SOURCE if a problem occurs setting up the source * */ - (ALuint)playSound:(int) soundId sourceGroupId:(int)sourceGroupId pitch:(float) pitch pan:(float) pan gain:(float) gain loop:(BOOL) loop { #ifdef CD_DEBUG //Sanity check parameters - only in DEBUG NSAssert(soundId >= 0, @"soundId can not be negative"); NSAssert(soundId < bufferTotal, @"soundId exceeds limit"); NSAssert(sourceGroupId >= 0, @"sourceGroupId can not be negative"); NSAssert(sourceGroupId < _sourceGroupTotal, @"sourceGroupId exceeds limit"); NSAssert(pitch > 0, @"pitch must be greater than zero"); NSAssert(pan >= -1 && pan <= 1, @"pan must be between -1 and 1"); NSAssert(gain >= 0, @"gain can not be negative"); #endif //If mute or initialisation has failed or buffer is not loaded then do nothing if (!enabled_ || !functioning_ || _buffers[soundId].bufferState != CD_BS_LOADED || _sourceGroups[sourceGroupId].enabled) { #ifdef CD_DEBUG if (!functioning_) { CDLOGINFO(@"Denshion::CDSoundEngine - sound playback aborted because sound engine is not functioning"); } else if (_buffers[soundId].bufferState != CD_BS_LOADED) { CDLOGINFO(@"Denshion::CDSoundEngine - sound playback aborted because buffer %i is not loaded", soundId); } #endif return CD_MUTE; } int sourceIndex = [self _getSourceIndexForSourceGroup:sourceGroupId];//This method ensures sourceIndex is valid if (sourceIndex != CD_NO_SOURCE) { ALint state; ALuint source = _sources[sourceIndex].sourceId; ALuint buffer = _buffers[soundId].bufferId; alGetError();//Clear the error code alGetSourcei(source, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) { alSourceStop(source); } alSourcei(source, AL_BUFFER, buffer);//Attach to sound alSourcef(source, AL_PITCH, pitch);//Set pitch alSourcei(source, AL_LOOPING, loop);//Set looping alSourcef(source, AL_GAIN, gain);//Set gain/volume float sourcePosAL[] = {pan, 0.0f, 0.0f};//Set position - just using left and right panning alSourcefv(source, AL_POSITION, sourcePosAL); alGetError();//Clear the error code alSourcePlay(source); if((lastErrorCode_ = alGetError()) == AL_NO_ERROR) { //Everything was okay _sources[sourceIndex].attachedBufferId = buffer; return source; } else { if (alcGetCurrentContext() == NULL) { CDLOGINFO(@"Denshion::CDSoundEngine - posting bad OpenAL context message"); [[NSNotificationCenter defaultCenter] postNotificationName:kCDN_BadAlContext object:nil]; } return CD_NO_SOURCE; } } else { return CD_NO_SOURCE; } } -(BOOL) _soundSourceAttachToBuffer:(CDSoundSource*) soundSource soundId:(int) soundId { //Attach the source to the buffer ALint state; ALuint source = soundSource->_sourceId; ALuint buffer = _buffers[soundId].bufferId; alGetSourcei(source, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) { alSourceStop(source); } alGetError();//Clear the error code alSourcei(source, AL_BUFFER, buffer);//Attach to sound data if((lastErrorCode_ = alGetError()) == AL_NO_ERROR) { _sources[soundSource->_sourceIndex].attachedBufferId = buffer; //_sourceBufferAttachments[soundSource->_sourceIndex] = buffer;//Keep track of which soundSource->_soundId = soundId; return YES; } else { return NO; } } /** * Get a sound source for the specified sound in the specified source group */ -(CDSoundSource *) soundSourceForSound:(int) soundId sourceGroupId:(int) sourceGroupId { if (!functioning_) { return nil; } //Check if a source is available int sourceIndex = [self _getSourceIndexForSourceGroup:sourceGroupId]; if (sourceIndex != CD_NO_SOURCE) { CDSoundSource *result = [[CDSoundSource alloc] init:_sources[sourceIndex].sourceId sourceIndex:sourceIndex soundEngine:self]; [self _lockSource:sourceIndex lock:YES]; //Try to attach to the buffer if ([self _soundSourceAttachToBuffer:result soundId:soundId]) { //Set to a known state result.pitch = 1.0f; result.pan = 0.0f; result.gain = 1.0f; result.looping = NO; return [result autorelease]; } else { //Release the sound source we just created, this will also unlock the source [result release]; return nil; } } else { //No available source within that source group return nil; } } -(void) _soundSourcePreRelease:(CDSoundSource *) soundSource { CDLOGINFO(@"Denshion::CDSoundEngine _soundSourcePreRelease %i",soundSource->_sourceIndex); //Unlock the sound source's source [self _lockSource:soundSource->_sourceIndex lock:NO]; } /** * Stop all sounds playing within a source group */ - (void) stopSourceGroup:(int) sourceGroupId { if (!functioning_ || sourceGroupId >= _sourceGroupTotal || sourceGroupId < 0) { return; } int sourceCount = _sourceGroups[sourceGroupId].totalSources; for (int i=0; i < sourceCount; i++) { int sourceIndex = _sourceGroups[sourceGroupId].sourceStatuses[i] >> 1; alSourceStop(_sources[sourceIndex].sourceId); } alGetError();//Clear error in case we stopped any sounds that couldn't be stopped } /** * Stop a sound playing. * @param sourceId an OpenAL source identifier i.e. the return value of playSound */ - (void)stopSound:(ALuint) sourceId { if (!functioning_) { return; } alSourceStop(sourceId); alGetError();//Clear error in case we stopped any sounds that couldn't be stopped } - (void) stopAllSounds { for (int i=0; i < sourceTotal_; i++) { alSourceStop(_sources[i].sourceId); } alGetError();//Clear error in case we stopped any sounds that couldn't be stopped } - (void) pauseSound:(ALuint) sourceId { if (!functioning_) { return; } alSourcePause(sourceId); alGetError();//Clear error in case we pause any sounds that couldn't be paused } - (void) pauseAllSounds { for (int i = 0; i < sourceTotal_; i++) { [self pauseSound:_sources[i].sourceId]; } alGetError();//Clear error in case we stopped any sounds that couldn't be paused } - (void) resumeSound:(ALuint) soundId { if (!functioning_) { return; } // only resume a sound id that is paused ALint state; alGetSourcei(soundId, AL_SOURCE_STATE, &state); if (state != AL_PAUSED) { return; } alSourcePlay(soundId); alGetError();//Clear error in case we stopped any sounds that couldn't be resumed } - (void) resumeAllSounds { for (int i = 0; i < sourceTotal_; i++) { [self resumeSound:_sources[i].sourceId]; } alGetError();//Clear error in case we stopped any sounds that couldn't be resumed } /** * Set a source group as non interruptible. Default is that source groups are interruptible. * Non interruptible means that if a request to play a sound is made for a source group and there are * no free sources available then the play request will be ignored and CD_NO_SOURCE will be returned. */ - (void) setSourceGroupNonInterruptible:(int) sourceGroupId isNonInterruptible:(BOOL) isNonInterruptible { //Ensure source group id is valid to prevent memory corruption if (sourceGroupId < 0 || sourceGroupId >= _sourceGroupTotal) { CDLOG(@"Denshion::CDSoundEngine setSourceGroupNonInterruptible invalid source group id %i",sourceGroupId); return; } if (isNonInterruptible) { _sourceGroups[sourceGroupId].nonInterruptible = true; } else { _sourceGroups[sourceGroupId].nonInterruptible = false; } } /** * Set the mute property for a source group. If mute is turned on any sounds in that source group * will be stopped and further sounds in that source group will play. However, turning mute off * will not restart any sounds that were playing when mute was turned on. Also the mute setting * for the sound engine must be taken into account. If the sound engine is mute no sounds will play * no matter what the source group mute setting is. */ - (void) setSourceGroupEnabled:(int) sourceGroupId enabled:(BOOL) enabled { //Ensure source group id is valid to prevent memory corruption if (sourceGroupId < 0 || sourceGroupId >= _sourceGroupTotal) { CDLOG(@"Denshion::CDSoundEngine setSourceGroupEnabled invalid source group id %i",sourceGroupId); return; } if (enabled) { _sourceGroups[sourceGroupId].enabled = true; [self stopSourceGroup:sourceGroupId]; } else { _sourceGroups[sourceGroupId].enabled = false; } } /** * Return the mute property for the source group identified by sourceGroupId */ - (BOOL) sourceGroupEnabled:(int) sourceGroupId { return _sourceGroups[sourceGroupId].enabled; } -(ALCcontext *) openALContext { return context; } - (void) _dumpSourceGroupsInfo { #ifdef CD_DEBUG CDLOGINFO(@"-------------- source Group Info --------------"); for (int i=0; i < _sourceGroupTotal; i++) { CDLOGINFO(@"Group: %i start:%i total:%i",i,_sourceGroups[i].startIndex, _sourceGroups[i].totalSources); CDLOGINFO(@"----- mute:%i nonInterruptible:%i",_sourceGroups[i].enabled, _sourceGroups[i].nonInterruptible); CDLOGINFO(@"----- Source statuses ----"); for (int j=0; j < _sourceGroups[i].totalSources; j++) { CDLOGINFO(@"Source status:%i index=%i locked=%i",j,_sourceGroups[i].sourceStatuses[j] >> 1, _sourceGroups[i].sourceStatuses[j] & 1); } } #endif } @end /////////////////////////////////////////////////////////////////////////////////////// @implementation CDSoundSource @synthesize lastError; //Macro for handling the al error code #define CDSOUNDSOURCE_UPDATE_LAST_ERROR (lastError = alGetError()) #define CDSOUNDSOURCE_ERROR_HANDLER ( CDSOUNDSOURCE_UPDATE_LAST_ERROR == AL_NO_ERROR) -(id)init:(ALuint) theSourceId sourceIndex:(int) index soundEngine:(CDSoundEngine*) engine { if ((self = [super init])) { _sourceId = theSourceId; _engine = engine; _sourceIndex = index; enabled_ = YES; mute_ = NO; _preMuteGain = self.gain; } return self; } -(void) dealloc { CDLOGINFO(@"Denshion::CDSoundSource deallocated %i",self->_sourceIndex); //Notify sound engine we are about to release [_engine _soundSourcePreRelease:self]; [super dealloc]; } - (void) setPitch:(float) newPitchValue { alSourcef(_sourceId, AL_PITCH, newPitchValue); CDSOUNDSOURCE_UPDATE_LAST_ERROR; } - (void) setGain:(float) newGainValue { if (!mute_) { alSourcef(_sourceId, AL_GAIN, newGainValue); } else { _preMuteGain = newGainValue; } CDSOUNDSOURCE_UPDATE_LAST_ERROR; } - (void) setPan:(float) newPanValue { float sourcePosAL[] = {newPanValue, 0.0f, 0.0f};//Set position - just using left and right panning alSourcefv(_sourceId, AL_POSITION, sourcePosAL); CDSOUNDSOURCE_UPDATE_LAST_ERROR; } - (void) setLooping:(BOOL) newLoopingValue { alSourcei(_sourceId, AL_LOOPING, newLoopingValue); CDSOUNDSOURCE_UPDATE_LAST_ERROR; } - (BOOL) isPlaying { ALint state; alGetSourcei(_sourceId, AL_SOURCE_STATE, &state); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return (state == AL_PLAYING); } - (float) pitch { ALfloat pitchVal; alGetSourcef(_sourceId, AL_PITCH, &pitchVal); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return pitchVal; } - (float) pan { ALfloat sourcePosAL[] = {0.0f,0.0f,0.0f}; alGetSourcefv(_sourceId, AL_POSITION, sourcePosAL); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return sourcePosAL[0]; } - (float) gain { if (!mute_) { ALfloat val; alGetSourcef(_sourceId, AL_GAIN, &val); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return val; } else { return _preMuteGain; } } - (BOOL) looping { ALfloat val; alGetSourcef(_sourceId, AL_LOOPING, &val); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return val; } -(BOOL) stop { alSourceStop(_sourceId); return CDSOUNDSOURCE_ERROR_HANDLER; } -(BOOL) play { if (enabled_) { alSourcePlay(_sourceId); CDSOUNDSOURCE_UPDATE_LAST_ERROR; if (lastError != AL_NO_ERROR) { if (alcGetCurrentContext() == NULL) { CDLOGINFO(@"Denshion::CDSoundSource - posting bad OpenAL context message"); [[NSNotificationCenter defaultCenter] postNotificationName:kCDN_BadAlContext object:nil]; } return NO; } else { return YES; } } else { return NO; } } -(BOOL) pause { alSourcePause(_sourceId); return CDSOUNDSOURCE_ERROR_HANDLER; } -(BOOL) rewind { alSourceRewind(_sourceId); return CDSOUNDSOURCE_ERROR_HANDLER; } -(void) setSoundId:(int) soundId { [_engine _soundSourceAttachToBuffer:self soundId:soundId]; } -(int) soundId { return _soundId; } -(float) durationInSeconds { return [_engine bufferDurationInSeconds:_soundId]; } #pragma mark CDSoundSource AudioInterrupt protocol - (BOOL) mute { return mute_; } /** * Setting mute silences all sounds but playing sounds continue to advance playback */ - (void) setMute:(BOOL) newMuteValue { if (newMuteValue == mute_) { return; } if (newMuteValue) { //Remember what the gain was _preMuteGain = self.gain; self.gain = 0.0f; mute_ = newMuteValue;//Make sure this is done after setting the gain property as the setter behaves differently depending on mute value } else { //Restore gain to what it was before being muted mute_ = newMuteValue; self.gain = _preMuteGain; } } - (BOOL) enabled { return enabled_; } - (void) setEnabled:(BOOL)enabledValue { if (enabled_ == enabledValue) { return; } enabled_ = enabledValue; if (enabled_ == NO) { [self stop]; } } @end //////////////////////////////////////////////////////////////////////////// #pragma mark - CDAudioInterruptTargetGroup @implementation CDAudioInterruptTargetGroup -(id) init { if ((self = [super init])) { children_ = [[NSMutableArray alloc] initWithCapacity:32]; enabled_ = YES; mute_ = NO; } return self; } -(void) addAudioInterruptTarget:(NSObject*) interruptibleTarget { //Synchronize child with group settings; [interruptibleTarget setMute:mute_]; [interruptibleTarget setEnabled:enabled_]; [children_ addObject:interruptibleTarget]; } -(void) removeAudioInterruptTarget:(NSObject*) interruptibleTarget { [children_ removeObjectIdenticalTo:interruptibleTarget]; } - (BOOL) mute { return mute_; } /** * Setting mute silences all sounds but playing sounds continue to advance playback */ - (void) setMute:(BOOL) newMuteValue { if (newMuteValue == mute_) { return; } for (NSObject* target in children_) { [target setMute:newMuteValue]; } } - (BOOL) enabled { return enabled_; } - (void) setEnabled:(BOOL)enabledValue { if (enabledValue == enabled_) { return; } for (NSObject* target in children_) { [target setEnabled:enabledValue]; } } @end //////////////////////////////////////////////////////////////////////////// #pragma mark - CDAsynchBufferLoader @implementation CDAsynchBufferLoader -(id) init:(NSArray *)loadRequests soundEngine:(CDSoundEngine *) theSoundEngine { if ((self = [super init])) { _loadRequests = loadRequests; [_loadRequests retain]; _soundEngine = theSoundEngine; [_soundEngine retain]; } return self; } -(void) main { CDLOGINFO(@"Denshion::CDAsynchBufferLoader - loading buffers"); [super main]; _soundEngine.asynchLoadProgress = 0.0f; if ([_loadRequests count] > 0) { float increment = 1.0f / [_loadRequests count]; //Iterate over load request and load for (CDBufferLoadRequest *loadRequest in _loadRequests) { [_soundEngine loadBuffer:loadRequest.soundId filePath:loadRequest.filePath]; _soundEngine.asynchLoadProgress += increment; } } //Completed _soundEngine.asynchLoadProgress = 1.0f; [[NSNotificationCenter defaultCenter] postNotificationName:kCDN_AsynchLoadComplete object:nil]; } -(void) dealloc { [_loadRequests release]; [_soundEngine release]; [super dealloc]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - CDBufferLoadRequest @implementation CDBufferLoadRequest @synthesize filePath, soundId; -(id) init:(int) theSoundId filePath:(const NSString *) theFilePath { if ((self = [super init])) { soundId = theSoundId; filePath = [theFilePath copy]; } return self; } -(void) dealloc { [filePath release]; [super dealloc]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - CDFloatInterpolator @implementation CDFloatInterpolator @synthesize start,end,interpolationType; -(float) interpolate:(float) t { if (t < 1.0f) { switch (interpolationType) { case kIT_Linear: //Linear interpolation return ((end - start) * t) + start; case kIT_SCurve: //Cubic s curve t^2 * (3 - 2t) return ((float)(t * t * (3.0 - (2.0 * t))) * (end - start)) + start; case kIT_Exponential: //Formulas taken from EaseAction if (end > start) { //Fade in float logDelta = (t==0) ? 0 : powf(2, 10 * (t/1 - 1)) - 1 * 0.001f; return ((end - start) * logDelta) + start; } else { //Fade Out float logDelta = (-powf(2, -10 * t/1) + 1); return ((end - start) * logDelta) + start; } default: return 0.0f; } } else { return end; } } -(id) init:(tCDInterpolationType) type startVal:(float) startVal endVal:(float) endVal { if ((self = [super init])) { start = startVal; end = endVal; interpolationType = type; } return self; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - CDPropertyModifier @implementation CDPropertyModifier @synthesize stopTargetWhenComplete; -(id) init:(id) theTarget interpolationType:(tCDInterpolationType) type startVal:(float) startVal endVal:(float) endVal { if ((self = [super init])) { if (target) { //Release the previous target if there is one [target release]; } target = theTarget; #if CD_DEBUG //Check target is of the required type if (![theTarget isMemberOfClass:[self _allowableType]] ) { CDLOG(@"Denshion::CDPropertyModifier target is not of type %@",[self _allowableType]); NSAssert([theTarget isKindOfClass:[CDSoundEngine class]], @"CDPropertyModifier target not of required type"); } #endif [target retain]; startValue = startVal; endValue = endVal; if (interpolator) { //Release previous interpolator if there is one [interpolator release]; } interpolator = [[CDFloatInterpolator alloc] init:type startVal:startVal endVal:endVal]; stopTargetWhenComplete = NO; } return self; } -(void) dealloc { CDLOGINFO(@"Denshion::CDPropertyModifier deallocated %@",self); [target release]; [interpolator release]; [super dealloc]; } -(void) modify:(float) t { if (t < 1.0) { [self _setTargetProperty:[interpolator interpolate:t]]; } else { //At the end [self _setTargetProperty:endValue]; if (stopTargetWhenComplete) { [self _stopTarget]; } } } -(float) startValue { return startValue; } -(void) setStartValue:(float) startVal { startValue = startVal; interpolator.start = startVal; } -(float) endValue { return startValue; } -(void) setEndValue:(float) endVal { endValue = endVal; interpolator.end = endVal; } -(tCDInterpolationType) interpolationType { return interpolator.interpolationType; } -(void) setInterpolationType:(tCDInterpolationType) interpolationType { interpolator.interpolationType = interpolationType; } -(void) _setTargetProperty:(float) newVal { } -(float) _getTargetProperty { return 0.0f; } -(void) _stopTarget { } -(Class) _allowableType { return [NSObject class]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - CDSoundSourceFader @implementation CDSoundSourceFader -(void) _setTargetProperty:(float) newVal { ((CDSoundSource*)target).gain = newVal; } -(float) _getTargetProperty { return ((CDSoundSource*)target).gain; } -(void) _stopTarget { [((CDSoundSource*)target) stop]; } -(Class) _allowableType { return [CDSoundSource class]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - CDSoundSourcePanner @implementation CDSoundSourcePanner -(void) _setTargetProperty:(float) newVal { ((CDSoundSource*)target).pan = newVal; } -(float) _getTargetProperty { return ((CDSoundSource*)target).pan; } -(void) _stopTarget { [((CDSoundSource*)target) stop]; } -(Class) _allowableType { return [CDSoundSource class]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - CDSoundSourcePitchBender @implementation CDSoundSourcePitchBender -(void) _setTargetProperty:(float) newVal { ((CDSoundSource*)target).pitch = newVal; } -(float) _getTargetProperty { return ((CDSoundSource*)target).pitch; } -(void) _stopTarget { [((CDSoundSource*)target) stop]; } -(Class) _allowableType { return [CDSoundSource class]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - CDSoundEngineFader @implementation CDSoundEngineFader -(void) _setTargetProperty:(float) newVal { ((CDSoundEngine*)target).masterGain = newVal; } -(float) _getTargetProperty { return ((CDSoundEngine*)target).masterGain; } -(void) _stopTarget { [((CDSoundEngine*)target) stopAllSounds]; } -(Class) _allowableType { return [CDSoundEngine class]; } @end ================================================ FILE: cocos2d/cocos/audio/ios/SimpleAudioEngine.mm ================================================ /**************************************************************************** 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. ****************************************************************************/ #include "SimpleAudioEngine.h" #include "SimpleAudioEngine_objc.h" #include "cocos2d.h" USING_NS_CC; static void static_end() { [SimpleAudioEngine end]; } static void static_preloadBackgroundMusic(const char* pszFilePath) { [[SimpleAudioEngine sharedEngine] preloadBackgroundMusic: [NSString stringWithUTF8String: pszFilePath]]; } static void static_playBackgroundMusic(const char* pszFilePath, bool bLoop) { [[SimpleAudioEngine sharedEngine] playBackgroundMusic: [NSString stringWithUTF8String: pszFilePath] loop: bLoop]; } static void static_stopBackgroundMusic() { [[SimpleAudioEngine sharedEngine] stopBackgroundMusic]; } static void static_pauseBackgroundMusic() { [[SimpleAudioEngine sharedEngine] pauseBackgroundMusic]; } static void static_resumeBackgroundMusic() { [[SimpleAudioEngine sharedEngine] resumeBackgroundMusic]; } static void static_rewindBackgroundMusic() { [[SimpleAudioEngine sharedEngine] rewindBackgroundMusic]; } static bool static_willPlayBackgroundMusic() { return [[SimpleAudioEngine sharedEngine] willPlayBackgroundMusic]; } static bool static_isBackgroundMusicPlaying() { return [[SimpleAudioEngine sharedEngine] isBackgroundMusicPlaying]; } static float static_getBackgroundMusicVolume() { return [[SimpleAudioEngine sharedEngine] backgroundMusicVolume]; } static void static_setBackgroundMusicVolume(float volume) { volume = MAX( MIN(volume, 1.0), 0 ); [SimpleAudioEngine sharedEngine].backgroundMusicVolume = volume; } static float static_getEffectsVolume() { return [[SimpleAudioEngine sharedEngine] effectsVolume]; } static void static_setEffectsVolume(float volume) { volume = MAX( MIN(volume, 1.0), 0 ); [SimpleAudioEngine sharedEngine].effectsVolume = volume; } static unsigned int static_playEffect(const char* pszFilePath, bool bLoop, Float32 pszPitch, Float32 pszPan, Float32 pszGain) { return [[SimpleAudioEngine sharedEngine] playEffect:[NSString stringWithUTF8String: pszFilePath] loop:bLoop pitch:pszPitch pan: pszPan gain:pszGain]; } static void static_stopEffect(int nSoundId) { [[SimpleAudioEngine sharedEngine] stopEffect: nSoundId]; } static void static_preloadEffect(const char* pszFilePath) { [[SimpleAudioEngine sharedEngine] preloadEffect: [NSString stringWithUTF8String: pszFilePath]]; } static void static_unloadEffect(const char* pszFilePath) { [[SimpleAudioEngine sharedEngine] unloadEffect: [NSString stringWithUTF8String: pszFilePath]]; } static void static_pauseEffect(unsigned int uSoundId) { [[SimpleAudioEngine sharedEngine] pauseEffect: uSoundId]; } static void static_pauseAllEffects() { [[SimpleAudioEngine sharedEngine] pauseAllEffects]; } static void static_resumeEffect(unsigned int uSoundId) { [[SimpleAudioEngine sharedEngine] resumeEffect: uSoundId]; } static void static_resumeAllEffects() { [[SimpleAudioEngine sharedEngine] resumeAllEffects]; } static void static_stopAllEffects() { [[SimpleAudioEngine sharedEngine] stopAllEffects]; } namespace CocosDenshion { static SimpleAudioEngine *s_pEngine; SimpleAudioEngine::SimpleAudioEngine() { } SimpleAudioEngine::~SimpleAudioEngine() { } SimpleAudioEngine* SimpleAudioEngine::getInstance() { if (! s_pEngine) { s_pEngine = new SimpleAudioEngine(); } return s_pEngine; } void SimpleAudioEngine::end() { if (s_pEngine) { delete s_pEngine; s_pEngine = NULL; } static_end(); } void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); static_preloadBackgroundMusic(fullPath.c_str()); } void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); static_playBackgroundMusic(fullPath.c_str(), bLoop); } void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) { static_stopBackgroundMusic(); } void SimpleAudioEngine::pauseBackgroundMusic() { static_pauseBackgroundMusic(); } void SimpleAudioEngine::resumeBackgroundMusic() { static_resumeBackgroundMusic(); } void SimpleAudioEngine::rewindBackgroundMusic() { static_rewindBackgroundMusic(); } bool SimpleAudioEngine::willPlayBackgroundMusic() { return static_willPlayBackgroundMusic(); } bool SimpleAudioEngine::isBackgroundMusicPlaying() { return static_isBackgroundMusicPlaying(); } float SimpleAudioEngine::getBackgroundMusicVolume() { return static_getBackgroundMusicVolume(); } void SimpleAudioEngine::setBackgroundMusicVolume(float volume) { static_setBackgroundMusicVolume(volume); } float SimpleAudioEngine::getEffectsVolume() { return static_getEffectsVolume(); } void SimpleAudioEngine::setEffectsVolume(float volume) { static_setEffectsVolume(volume); } unsigned int SimpleAudioEngine::playEffect(const char *pszFilePath, bool bLoop, float pitch, float pan, float gain) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); return static_playEffect(fullPath.c_str(), bLoop, pitch, pan, gain); } void SimpleAudioEngine::stopEffect(unsigned int nSoundId) { static_stopEffect(nSoundId); } void SimpleAudioEngine::preloadEffect(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); static_preloadEffect(fullPath.c_str()); } void SimpleAudioEngine::unloadEffect(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); static_unloadEffect(fullPath.c_str()); } void SimpleAudioEngine::pauseEffect(unsigned int uSoundId) { static_pauseEffect(uSoundId); } void SimpleAudioEngine::resumeEffect(unsigned int uSoundId) { static_resumeEffect(uSoundId); } void SimpleAudioEngine::pauseAllEffects() { static_pauseAllEffects(); } void SimpleAudioEngine::resumeAllEffects() { static_resumeAllEffects(); } void SimpleAudioEngine::stopAllEffects() { static_stopAllEffects(); } } // endof namespace CocosDenshion { ================================================ FILE: cocos2d/cocos/audio/ios/SimpleAudioEngine_objc.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "CDAudioManager.h" /** A wrapper to the CDAudioManager object. This is recommended for basic audio requirements. If you just want to play some sound fx and some background music and have no interest in learning the lower level workings then this is the interface to use. Requirements: - Firmware: OS 2.2 or greater - Files: SimpleAudioEngine.*, CocosDenshion.* - Frameworks: OpenAL, AudioToolbox, AVFoundation @since v0.8 */ @interface SimpleAudioEngine : NSObject { BOOL mute_; BOOL enabled_; } /** Background music volume. Range is 0.0f to 1.0f. This will only have an effect if willPlayBackgroundMusic returns YES */ @property (readwrite) float backgroundMusicVolume; /** Effects volume. Range is 0.0f to 1.0f */ @property (readwrite) float effectsVolume; /** If NO it indicates background music will not be played either because no background music is loaded or the audio session does not permit it.*/ @property (readonly) BOOL willPlayBackgroundMusic; /** returns the shared instance of the SimpleAudioEngine object */ + (SimpleAudioEngine*) sharedEngine; /** Preloads a music file so it will be ready to play as background music */ -(void) preloadBackgroundMusic:(NSString*) filePath; /** plays background music in a loop*/ -(void) playBackgroundMusic:(NSString*) filePath; /** plays background music, if loop is true the music will repeat otherwise it will be played once */ -(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop; /** stops playing background music */ -(void) stopBackgroundMusic; /** pauses the background music */ -(void) pauseBackgroundMusic; /** resume background music that has been paused */ -(void) resumeBackgroundMusic; /** rewind the background music */ -(void) rewindBackgroundMusic; /** returns whether or not the background music is playing */ -(BOOL) isBackgroundMusicPlaying; /** plays an audio effect with a file path*/ -(ALuint) playEffect:(NSString*) filePath loop:(BOOL) loop; /** stop a sound that is playing, note you must pass in the soundId that is returned when you started playing the sound with playEffect */ -(void) stopEffect:(ALuint) soundId; /** plays an audio effect with a file path, pitch, pan and gain */ -(ALuint) playEffect:(NSString*) filePath loop:(BOOL)loop pitch:(Float32) pitch pan:(Float32) pan gain:(Float32) gain; /** pause an audio */ -(void) pauseEffect:(ALuint) soundId; /** pause all audioes */ -(void) pauseAllEffects; /** resume an audio */ -(void) resumeEffect:(ALuint) soundId; /** resume all audioes */ -(void) resumeAllEffects; /** stop all audioes */ -(void) stopAllEffects; /** preloads an audio effect */ -(void) preloadEffect:(NSString*) filePath; /** unloads an audio effect from memory */ -(void) unloadEffect:(NSString*) filePath; /** Gets a CDSoundSource object set up to play the specified file. */ -(CDSoundSource *) soundSourceForFile:(NSString*) filePath; /** Shuts down the shared audio engine instance so that it can be reinitialised */ +(void) end; @end ================================================ FILE: cocos2d/cocos/audio/ios/SimpleAudioEngine_objc.m ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "SimpleAudioEngine_objc.h" @implementation SimpleAudioEngine static SimpleAudioEngine *sharedEngine = nil; static CDSoundEngine* soundEngine = nil; static CDAudioManager *am = nil; static CDBufferManager *bufferManager = nil; // Init + (SimpleAudioEngine *) sharedEngine { @synchronized(self) { if (!sharedEngine) sharedEngine = [[SimpleAudioEngine alloc] init]; } return sharedEngine; } + (id) alloc { @synchronized(self) { NSAssert(sharedEngine == nil, @"Attempted to allocate a second instance of a singleton."); return [super alloc]; } return nil; } -(id) init { if((self=[super init])) { am = [CDAudioManager sharedManager]; soundEngine = am.soundEngine; bufferManager = [[CDBufferManager alloc] initWithEngine:soundEngine]; mute_ = NO; enabled_ = YES; } return self; } // Memory - (void) dealloc { am = nil; soundEngine = nil; bufferManager = nil; [super dealloc]; } +(void) end { am = nil; [CDAudioManager end]; [bufferManager release]; [sharedEngine release]; sharedEngine = nil; } #pragma mark SimpleAudioEngine - background music -(void) preloadBackgroundMusic:(NSString*) filePath { [am preloadBackgroundMusic:filePath]; } -(void) playBackgroundMusic:(NSString*) filePath { [am playBackgroundMusic:filePath loop:TRUE]; } -(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop { [am playBackgroundMusic:filePath loop:loop]; } -(void) stopBackgroundMusic { [am stopBackgroundMusic]; } -(void) pauseBackgroundMusic { [am pauseBackgroundMusic]; } -(void) resumeBackgroundMusic { [am resumeBackgroundMusic]; } -(void) rewindBackgroundMusic { [am rewindBackgroundMusic]; } -(BOOL) isBackgroundMusicPlaying { return [am isBackgroundMusicPlaying]; } -(BOOL) willPlayBackgroundMusic { return [am willPlayBackgroundMusic]; } #pragma mark SimpleAudioEngine - sound effects -(ALuint) playEffect:(NSString*) filePath loop:(BOOL) loop { return [self playEffect:filePath loop:loop pitch:1.0f pan:0.0f gain:1.0f]; } -(ALuint) playEffect:(NSString*) filePath loop:(BOOL) loop pitch:(Float32) pitch pan:(Float32) pan gain:(Float32) gain { int soundId = [bufferManager bufferForFile:filePath create:YES]; if (soundId != kCDNoBuffer) { return [soundEngine playSound:soundId sourceGroupId:0 pitch:pitch pan:pan gain:gain loop:loop]; } else { return CD_MUTE; } } -(void) stopEffect:(ALuint) soundId { [soundEngine stopSound:soundId]; } -(void) pauseEffect:(ALuint) soundId { [soundEngine pauseSound: soundId]; } -(void) pauseAllEffects { [soundEngine pauseAllSounds]; } -(void) resumeEffect:(ALuint) soundId { [soundEngine resumeSound: soundId]; } -(void) resumeAllEffects { [soundEngine resumeAllSounds]; } -(void) stopAllEffects { [soundEngine stopAllSounds]; } -(void) preloadEffect:(NSString*) filePath { int soundId = [bufferManager bufferForFile:filePath create:YES]; if (soundId == kCDNoBuffer) { CDLOG(@"Denshion::SimpleAudioEngine sound failed to preload %@",filePath); } } -(void) unloadEffect:(NSString*) filePath { CDLOGINFO(@"Denshion::SimpleAudioEngine unloadedEffect %@",filePath); [bufferManager releaseBufferForFile:filePath]; } #pragma mark Audio Interrupt Protocol -(BOOL) mute { return mute_; } -(void) setMute:(BOOL) muteValue { if (mute_ != muteValue) { mute_ = muteValue; am.mute = mute_; } } -(BOOL) enabled { return enabled_; } -(void) setEnabled:(BOOL) enabledValue { if (enabled_ != enabledValue) { enabled_ = enabledValue; am.enabled = enabled_; } } #pragma mark SimpleAudioEngine - BackgroundMusicVolume -(float) backgroundMusicVolume { return am.backgroundMusic.volume; } -(void) setBackgroundMusicVolume:(float) volume { am.backgroundMusic.volume = volume; } #pragma mark SimpleAudioEngine - EffectsVolume -(float) effectsVolume { return am.soundEngine.masterGain; } -(void) setEffectsVolume:(float) volume { am.soundEngine.masterGain = volume; } -(CDSoundSource *) soundSourceForFile:(NSString*) filePath { int soundId = [bufferManager bufferForFile:filePath create:YES]; if (soundId != kCDNoBuffer) { CDSoundSource *result = [soundEngine soundSourceForSound:soundId sourceGroupId:0]; CDLOGINFO(@"Denshion::SimpleAudioEngine sound source created for %@",filePath); return result; } else { return nil; } } @end ================================================ FILE: cocos2d/cocos/audio/linux/AudioPlayer.h ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef AUDIOPLAYER_H_ #define AUDIOPLAYER_H_ namespace CocosDenshion { class AudioPlayer { public: virtual void close() = 0; /** @brief Preload background music @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo */ virtual void preloadBackgroundMusic(const char* pszFilePath) = 0; /** @brief Play background music @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo @param bLoop Whether the background music loop or not */ virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop = false) = 0; /** @brief Stop playing background music @param bReleaseData If release the background music data or not.As default value is false */ virtual void stopBackgroundMusic(bool bReleaseData = false) = 0; /** @brief Pause playing background music */ virtual void pauseBackgroundMusic() = 0; /** @brief Resume playing background music */ virtual void resumeBackgroundMusic() = 0; /** @brief Rewind playing background music */ virtual void rewindBackgroundMusic() = 0; virtual bool willPlayBackgroundMusic() = 0; /** @brief Whether the background music is playing @return If is playing return true,or return false */ virtual bool isBackgroundMusicPlaying() = 0; // properties /** @brief The volume of the background music max value is 1.0,the min value is 0.0 */ virtual float getBackgroundMusicVolume() = 0; /** @brief set the volume of background music @param volume must be in 0.0~1.0 */ virtual void setBackgroundMusicVolume(float volume) = 0; /** @brief The volume of the effects max value is 1.0,the min value is 0.0 */ virtual float getEffectsVolume() = 0; /** @brief set the volume of sound effecs @param volume must be in 0.0~1.0 */ virtual void setEffectsVolume(float volume) = 0; // for sound effects /** @brief Play sound effect @param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo @bLoop Whether to loop the effect playing, default value is false */ virtual unsigned int playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) = 0; /** @brief Stop playing sound effect @param nSoundId The return value of function playEffect */ virtual void stopEffect(unsigned int nSoundId) = 0; /** @brief preload a compressed audio file @details the compressed audio will be decode to wave, then write into an internal buffer in SimpleaudioEngine */ virtual void preloadEffect(const char* pszFilePath) = 0; /** @brief unload the preloaded effect from internal buffer @param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo */ virtual void unloadEffect(const char* pszFilePath) = 0; /** @brief pause an effect identified by sound id @param[in] uSoundId sound id */ virtual void pauseEffect(unsigned int uSoundId) = 0; /** @brief pause all playing effects */ virtual void pauseAllEffects() = 0; /** @brief resume an effect identified by sound id @param[in] uSoundId sound id */ virtual void resumeEffect(unsigned int uSoundId) = 0; /** @brief resume a effect identified by sound id */ virtual void resumeAllEffects() = 0; /** @brief stop all playing effects */ virtual void stopAllEffects() = 0; }; } #endif /* AUDIOPLAYER_H_ */ ================================================ FILE: cocos2d/cocos/audio/linux/FmodAudioPlayer.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "FmodAudioPlayer.h" #include #include "stdlib.h" #include "assert.h" #include "string.h" #define szMusicSuffix "|" namespace CocosDenshion { FmodAudioPlayer* FmodAudioPlayer::sharedPlayer() { static FmodAudioPlayer s_SharedPlayer; return &s_SharedPlayer; } void ERRCHECKWITHEXIT(FMOD_RESULT result) { if (result != FMOD_OK) { printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result)); // exit(-1); } } bool ERRCHECK(FMOD_RESULT result) { if (result != FMOD_OK) { printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result)); return true; } return false; } FmodAudioPlayer::FmodAudioPlayer() : pMusic(0), pBGMChannel(0), iSoundChannelCount(0) { init(); } void FmodAudioPlayer::init() { //init FMOD_RESULT result; FMOD::ChannelGroup *masterChannelGroup; /* Create a System object and initialize. */ result = FMOD::System_Create(&pSystem); ERRCHECKWITHEXIT(result); result = pSystem->setOutput(FMOD_OUTPUTTYPE_ALSA); ERRCHECKWITHEXIT(result); result = pSystem->init(32, FMOD_INIT_NORMAL, 0); ERRCHECKWITHEXIT(result); result = pSystem->createChannelGroup("Channel Group", &pChannelGroup); ERRCHECKWITHEXIT(result); result = pSystem->getMasterChannelGroup(&masterChannelGroup); ERRCHECKWITHEXIT(result); result = masterChannelGroup->addGroup(pChannelGroup); ERRCHECKWITHEXIT(result); mapEffectSound.clear(); } void FmodAudioPlayer::close() { FMOD_RESULT result; //BGM if (pBGMChannel != NULL) { result = pBGMChannel->stop(); ERRCHECKWITHEXIT(result); pBGMChannel = 0; } if (pMusic != NULL) { result = pMusic->release(); ERRCHECKWITHEXIT(result); pMusic = 0; } result = pChannelGroup->release(); ERRCHECKWITHEXIT(result); sMusicPath.clear(); result = pSystem->close(); ERRCHECKWITHEXIT(result); result = pSystem->release(); ERRCHECKWITHEXIT(result); init(); } FmodAudioPlayer::~FmodAudioPlayer() { FMOD_RESULT result; //BGM if (pBGMChannel != NULL) { result = pBGMChannel->stop(); ERRCHECKWITHEXIT(result); } if (pMusic != NULL) { result = pMusic->release(); ERRCHECKWITHEXIT(result); } result = pChannelGroup->release(); ERRCHECKWITHEXIT(result); result = pSystem->close(); ERRCHECKWITHEXIT(result); result = pSystem->release(); ERRCHECKWITHEXIT(result); } // BGM void FmodAudioPlayer::preloadBackgroundMusic(const char* pszFilePath) { FMOD_RESULT result; pSystem->update(); string sNewMusicPath = string(pszFilePath) + szMusicSuffix; if (pMusic && sNewMusicPath != sMusicPath) { //release old result = pMusic->release(); ERRCHECKWITHEXIT(result); sMusicPath = sNewMusicPath; } result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, &pMusic); ERRCHECK(result); } void FmodAudioPlayer::playBackgroundMusic(const char* pszFilePath, bool bLoop) { pSystem->update(); if (pMusic == NULL) { //did not load it //load the new music FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, &pMusic); if (!ERRCHECK(result)) { sMusicPath = string(pszFilePath) + szMusicSuffix; } } else { string sNewMusicPath = string(pszFilePath) + szMusicSuffix; if (pBGMChannel) { pBGMChannel->stop(); pBGMChannel = 0; } if (sNewMusicPath != sMusicPath) { pMusic->release(); //load the new music FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, &pMusic); if (!ERRCHECK(result)) { sMusicPath = sNewMusicPath; } } } FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pMusic, true, &pBGMChannel); if (!ERRCHECK(result)) { pBGMChannel->setLoopCount((bLoop) ? -1 : 0); result = pBGMChannel->setPaused(false); } } void FmodAudioPlayer::stopBackgroundMusic(bool bReleaseData) { FMOD_RESULT result; pSystem->update(); if (pBGMChannel == NULL || pMusic == NULL) { return; } if (bReleaseData) { result = pBGMChannel->stop(); ERRCHECKWITHEXIT(result); result = pMusic->release(); ERRCHECKWITHEXIT(result); pBGMChannel = 0; pMusic = 0; } else { result = pBGMChannel->stop(); ERRCHECKWITHEXIT(result); pBGMChannel = 0; } sMusicPath.clear(); } void FmodAudioPlayer::pauseBackgroundMusic() { if (pBGMChannel == NULL) { return; } pSystem->update(); FMOD_RESULT result = pBGMChannel->setPaused(true); ERRCHECKWITHEXIT(result); } void FmodAudioPlayer::resumeBackgroundMusic() { if (pBGMChannel == NULL) { return; } pSystem->update(); FMOD_RESULT result = pBGMChannel->setPaused(false); ERRCHECKWITHEXIT(result); } void FmodAudioPlayer::rewindBackgroundMusic() { if (pBGMChannel == NULL) { return; } pSystem->update(); FMOD_RESULT result = pBGMChannel->setPosition(0, FMOD_TIMEUNIT_MS); ERRCHECKWITHEXIT(result); } bool FmodAudioPlayer::willPlayBackgroundMusic() { pSystem->update(); return false; //do it according to win } bool FmodAudioPlayer::isBackgroundMusicPlaying() { bool bPlaying; if (pBGMChannel == NULL) { return false; } pSystem->update(); FMOD_RESULT result = pBGMChannel->isPlaying(&bPlaying); ERRCHECKWITHEXIT(result); return bPlaying; } float FmodAudioPlayer::getBackgroundMusicVolume() { float fVolumn; if (pBGMChannel == NULL) { return 0; } pSystem->update(); FMOD_RESULT result = pBGMChannel->getVolume(&fVolumn); ERRCHECKWITHEXIT(result); return fVolumn; } void FmodAudioPlayer::setBackgroundMusicVolume(float volume) { if (pBGMChannel == NULL) { return; } pSystem->update(); FMOD_RESULT result = pBGMChannel->setVolume(volume); ERRCHECKWITHEXIT(result); } //~BGM // for sound effects float FmodAudioPlayer::getEffectsVolume() { float fVolumn; pSystem->update(); FMOD_RESULT result = pChannelGroup->getVolume(&fVolumn); ERRCHECKWITHEXIT(result); return fVolumn; } void FmodAudioPlayer::setEffectsVolume(float volume) { pSystem->update(); FMOD_RESULT result = pChannelGroup->setVolume(volume); ERRCHECKWITHEXIT(result); } unsigned int FmodAudioPlayer::playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) { FMOD::Channel* pChannel; FMOD::Sound* pSound = NULL; do { pSystem->update(); map::iterator l_it = mapEffectSound.find( string(pszFilePath)); if (l_it == mapEffectSound.end()) { //no load it yet preloadEffect(pszFilePath); l_it = mapEffectSound.find(string(pszFilePath)); } pSound = l_it->second; if (pSound==NULL){ break; } FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pSound, true, &pChannel); if (ERRCHECK(result)) { printf("sound effect in %s could not be played", pszFilePath); break; } pChannel->setChannelGroup(pChannelGroup); pChannel->setPan(pan); float freq = 0; pChannel->getFrequency(&freq); pChannel->setFrequency(pitch * freq); pChannel->setVolume(gain); //set its loop pChannel->setLoopCount((bLoop) ? -1 : 0); result = pChannel->setPaused(false); mapEffectSoundChannel[iSoundChannelCount] = pChannel; return iSoundChannelCount++; } while (0); return 0; } void FmodAudioPlayer::stopEffect(unsigned int nSoundId) { FMOD::Channel* pChannel; pSystem->update(); map::iterator l_it = mapEffectSoundChannel.find(nSoundId); if (l_it == mapEffectSoundChannel.end()) { //no play yet return; } pChannel = l_it->second; //stop the channel; pChannel->stop(); //delete from the map; mapEffectSoundChannel.erase(nSoundId); } void FmodAudioPlayer::pauseEffect(unsigned int uSoundId) { FMOD::Channel* pChannel; pSystem->update(); map::iterator l_it = mapEffectSoundChannel.find(uSoundId); if (l_it == mapEffectSoundChannel.end()) { //no play yet return; } pChannel = l_it->second; //pause the channel; pChannel->setPaused(true); } void FmodAudioPlayer::pauseAllEffects() { FMOD::Channel* pChannel; pSystem->update(); map::iterator l_it = mapEffectSoundChannel.begin(); for (; l_it != mapEffectSoundChannel.end(); l_it++) { pChannel = l_it->second; //pause the channel; pChannel->setPaused(true); } } void FmodAudioPlayer::resumeEffect(unsigned int uSoundId) { FMOD::Channel* pChannel; pSystem->update(); map::iterator l_it = mapEffectSoundChannel.find(uSoundId); if (l_it == mapEffectSoundChannel.end()) { //no play yet return; } pChannel = l_it->second; //resume the channel; pChannel->setPaused(false); } void FmodAudioPlayer::resumeAllEffects() { FMOD::Channel* pChannel; pSystem->update(); map::iterator l_it = mapEffectSoundChannel.begin(); for (; l_it != mapEffectSoundChannel.end(); l_it++) { pChannel = l_it->second; //resume the channel; pChannel->setPaused(false); } } void FmodAudioPlayer::stopAllEffects() { FMOD::Channel* pChannel; pSystem->update(); map::iterator l_it = mapEffectSoundChannel.begin(); for (; l_it != mapEffectSoundChannel.end(); l_it++) { pChannel = l_it->second; //resume the channel; pChannel->stop(); } mapEffectSoundChannel.clear(); } void FmodAudioPlayer::preloadEffect(const char* pszFilePath) { FMOD::Sound* pLoadSound; pSystem->update(); FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, &pLoadSound); if (ERRCHECK(result)){ printf("sound effect in %s could not be preload", pszFilePath); return; } mapEffectSound[string(pszFilePath)] = pLoadSound; } void FmodAudioPlayer::unloadEffect(const char* pszFilePath) { FMOD::Sound* pSound; pSystem->update(); map::iterator l_it = mapEffectSound.find( string(pszFilePath)); if (l_it == mapEffectSound.end()) { //no load yet return; } pSound = l_it->second; //release the sound; pSound->release(); //delete from the map mapEffectSound.erase(string(pszFilePath)); } //~for sound effects } /* namespace CocosDenshion */ ================================================ FILE: cocos2d/cocos/audio/linux/FmodAudioPlayer.h ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef FMODAUDIOPLAYER_H_ #define FMODAUDIOPLAYER_H_ #include "fmod.hpp" #include "fmod_errors.h" #include "AudioPlayer.h" #include "string" #include using namespace std; namespace CocosDenshion { class FmodAudioPlayer : public AudioPlayer{ public: FmodAudioPlayer(); virtual ~FmodAudioPlayer(); static FmodAudioPlayer* sharedPlayer(); virtual void close(); /** @brief Preload background music @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo */ virtual void preloadBackgroundMusic(const char* pszFilePath); /** @brief Play background music @param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo @param bLoop Whether the background music loop or not */ virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop); /** @brief Stop playing background music @param bReleaseData If release the background music data or not.As default value is false */ virtual void stopBackgroundMusic(bool bReleaseData); /** @brief Pause playing background music */ virtual void pauseBackgroundMusic(); /** @brief Resume playing background music */ virtual void resumeBackgroundMusic(); /** @brief Rewind playing background music */ virtual void rewindBackgroundMusic(); virtual bool willPlayBackgroundMusic(); /** @brief Whether the background music is playing @return If is playing return true,or return false */ virtual bool isBackgroundMusicPlaying(); // properties /** @brief The volume of the background music max value is 1.0,the min value is 0.0 */ virtual float getBackgroundMusicVolume(); /** @brief set the volume of background music @param volume must be in 0.0~1.0 */ virtual void setBackgroundMusicVolume(float volume); /** @brief The volume of the effects max value is 1.0,the min value is 0.0 */ virtual float getEffectsVolume(); /** @brief set the volume of sound effecs @param volume must be in 0.0~1.0 */ virtual void setEffectsVolume(float volume); // for sound effects /** @brief Play sound effect @param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo @bLoop Whether to loop the effect playing, default value is false */ virtual unsigned int playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain); /** @brief Stop playing sound effect @param nSoundId The return value of function playEffect */ virtual void stopEffect(unsigned int nSoundId); /** @brief preload a compressed audio file @details the compressed audio will be decode to wave, then write into an internal buffer in SimpleaudioEngine */ virtual void preloadEffect(const char* pszFilePath); /** @brief unload the preloaded effect from internal buffer @param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo */ virtual void unloadEffect(const char* pszFilePath); /** @brief pause an effect identified by sound id @param[in] uSoundId sound id */ virtual void pauseEffect(unsigned int uSoundId); /** @brief pause all playing effects */ virtual void pauseAllEffects(); /** @brief resume an effect identified by sound id @param[in] uSoundId sound id */ virtual void resumeEffect(unsigned int uSoundId); /** @brief resume a effect identified by sound id */ virtual void resumeAllEffects(); /** @brief stop all playing effects */ virtual void stopAllEffects(); private: void init(); map mapEffectSound; map mapEffectSoundChannel; FMOD::System* pSystem; FMOD::Sound* pMusic; //BGM FMOD::Channel* pBGMChannel; FMOD::ChannelGroup* pChannelGroup; unsigned int iSoundChannelCount; string sMusicPath; }; } /* namespace CocosDenshion */ #endif /* FMODAUDIOPLAYER_H_ */ ================================================ FILE: cocos2d/cocos/audio/linux/SimpleAudioEngineFMOD.cpp ================================================ /**************************************************************************** Copyright (c) 2011 Laschweinski Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef OPENAL #include "SimpleAudioEngine.h" #include "FmodAudioPlayer.h" #include "cocos2d.h" USING_NS_CC; namespace CocosDenshion { static AudioPlayer* oAudioPlayer; SimpleAudioEngine::SimpleAudioEngine() { oAudioPlayer = FmodAudioPlayer::sharedPlayer(); } SimpleAudioEngine::~SimpleAudioEngine() { } SimpleAudioEngine* SimpleAudioEngine::getInstance() { static SimpleAudioEngine s_SharedEngine; return &s_SharedEngine; } void SimpleAudioEngine::end() { oAudioPlayer->close(); } ////////////////////////////////////////////////////////////////////////// // BackgroundMusic ////////////////////////////////////////////////////////////////////////// void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); oAudioPlayer->playBackgroundMusic(fullPath.c_str(), bLoop); } void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) { oAudioPlayer->stopBackgroundMusic(bReleaseData); } void SimpleAudioEngine::pauseBackgroundMusic() { oAudioPlayer->pauseBackgroundMusic(); } void SimpleAudioEngine::resumeBackgroundMusic() { oAudioPlayer->resumeBackgroundMusic(); } void SimpleAudioEngine::rewindBackgroundMusic() { oAudioPlayer->rewindBackgroundMusic(); } bool SimpleAudioEngine::willPlayBackgroundMusic() { return oAudioPlayer->willPlayBackgroundMusic(); } bool SimpleAudioEngine::isBackgroundMusicPlaying() { return oAudioPlayer->isBackgroundMusicPlaying(); } void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); return oAudioPlayer->preloadBackgroundMusic(fullPath.c_str()); } ////////////////////////////////////////////////////////////////////////// // effect function ////////////////////////////////////////////////////////////////////////// unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); return oAudioPlayer->playEffect(fullPath.c_str(), bLoop, pitch, pan, gain); } void SimpleAudioEngine::stopEffect(unsigned int nSoundId) { return oAudioPlayer->stopEffect(nSoundId); } void SimpleAudioEngine::preloadEffect(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); return oAudioPlayer->preloadEffect(fullPath.c_str()); } void SimpleAudioEngine::unloadEffect(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); return oAudioPlayer->unloadEffect(fullPath.c_str()); } void SimpleAudioEngine::pauseEffect(unsigned int uSoundId) { oAudioPlayer->pauseEffect(uSoundId); } void SimpleAudioEngine::pauseAllEffects() { oAudioPlayer->pauseAllEffects(); } void SimpleAudioEngine::resumeEffect(unsigned int uSoundId) { oAudioPlayer->resumeEffect(uSoundId); } void SimpleAudioEngine::resumeAllEffects() { oAudioPlayer->resumeAllEffects(); } void SimpleAudioEngine::stopAllEffects() { oAudioPlayer->stopAllEffects(); } ////////////////////////////////////////////////////////////////////////// // volume interface ////////////////////////////////////////////////////////////////////////// float SimpleAudioEngine::getBackgroundMusicVolume() { return oAudioPlayer->getBackgroundMusicVolume(); } void SimpleAudioEngine::setBackgroundMusicVolume(float volume) { return oAudioPlayer->setBackgroundMusicVolume(volume); } float SimpleAudioEngine::getEffectsVolume() { return oAudioPlayer->getEffectsVolume(); } void SimpleAudioEngine::setEffectsVolume(float volume) { return oAudioPlayer->setEffectsVolume(volume); } } // end of namespace CocosDenshion #endif ================================================ FILE: cocos2d/cocos/audio/mac/CDAudioManager.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "CocosDenshion.h" #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30000 #import #else #import "CDXMacOSXSupport.h" #endif /** Different modes of the engine */ typedef enum { kAMM_FxOnly, //!Other apps will be able to play audio kAMM_FxPlusMusic, //!Only this app will play audio kAMM_FxPlusMusicIfNoOtherAudio, //!If another app is playing audio at start up then allow it to continue and don't play music kAMM_MediaPlayback, //!This app takes over audio e.g music player app kAMM_PlayAndRecord //!App takes over audio and has input and output } tAudioManagerMode; /** Possible states of the engine */ typedef enum { kAMStateUninitialised, //!Audio manager has not been initialised - do not use kAMStateInitialising, //!Audio manager is in the process of initialising - do not use kAMStateInitialised //!Audio manager is initialised - safe to use } tAudioManagerState; typedef enum { kAMRBDoNothing, //Audio manager will not do anything on resign or becoming active kAMRBStopPlay, //Background music is stopped on resign and resumed on become active kAMRBStop //Background music is stopped on resign but not resumed - maybe because you want to do this from within your game } tAudioManagerResignBehavior; /** Notifications */ extern NSString * const kCDN_AudioManagerInitialised; @interface CDAsynchInitialiser : NSOperation {} @end /** CDAudioManager supports two long audio source channels called left and right*/ typedef enum { kASC_Left = 0, kASC_Right = 1 } tAudioSourceChannel; typedef enum { kLAS_Init, kLAS_Loaded, kLAS_Playing, kLAS_Paused, kLAS_Stopped, } tLongAudioSourceState; @class CDLongAudioSource; @protocol CDLongAudioSourceDelegate @optional /** The audio source completed playing */ - (void) cdAudioSourceDidFinishPlaying:(CDLongAudioSource *) audioSource; /** The file used to load the audio source has changed */ - (void) cdAudioSourceFileDidChange:(CDLongAudioSource *) audioSource; @end /** CDLongAudioSource represents an audio source that has a long duration which makes it costly to load into memory for playback as an effect using CDSoundEngine. Examples include background music and narration tracks. The audio file may or may not be compressed. Bear in mind that current iDevices can only use hardware to decode a single compressed audio file at a time and playing multiple compressed files will result in a performance drop as software decompression will take place. @since v0.99 */ @interface CDLongAudioSource : NSObject { AVAudioPlayer *audioSourcePlayer; NSString *audioSourceFilePath; NSInteger numberOfLoops; float volume; id delegate; BOOL mute; BOOL enabled_; BOOL backgroundMusic; // whether background music is paused BOOL paused; @public BOOL systemPaused;//Used for auto resign handling NSTimeInterval systemPauseLocation;//Used for auto resign handling @protected tLongAudioSourceState state; } @property (readonly) AVAudioPlayer *audioSourcePlayer; @property (readonly) NSString *audioSourceFilePath; @property (readwrite, nonatomic) NSInteger numberOfLoops; @property (readwrite, nonatomic) float volume; @property (assign) id delegate; /* This long audio source functions as background music */ @property (readwrite, nonatomic) BOOL backgroundMusic; @property (readonly) BOOL paused; /** Loads the file into the audio source */ -(void) load:(NSString*) filePath; /** Plays the audio source */ -(void) play; /** Stops playing the audio soruce */ -(void) stop; /** Pauses the audio source */ -(void) pause; /** Rewinds the audio source */ -(void) rewind; /** Resumes playing the audio source if it was paused */ -(void) resume; /** Returns whether or not the audio source is playing */ -(BOOL) isPlaying; @end /** CDAudioManager manages audio requirements for a game. It provides access to a CDSoundEngine object for playing sound effects. It provides access to two CDLongAudioSource object (left and right channel) for playing long duration audio such as background music and narration tracks. Additionally it manages the audio session to take care of things like audio session interruption and interacting with the audio of other apps that are running on the device. Requirements: - Firmware: OS 2.2 or greater - Files: CDAudioManager.*, CocosDenshion.* - Frameworks: OpenAL, AudioToolbox, AVFoundation @since v0.8 */ @interface CDAudioManager : NSObject { CDSoundEngine *soundEngine; CDLongAudioSource *backgroundMusic; NSMutableArray *audioSourceChannels; NSString* _audioSessionCategory; BOOL _audioWasPlayingAtStartup; tAudioManagerMode _mode; SEL backgroundMusicCompletionSelector; id backgroundMusicCompletionListener; BOOL willPlayBackgroundMusic; BOOL _mute; BOOL _resigned; BOOL _interrupted; BOOL _audioSessionActive; BOOL enabled_; //For handling resign/become active BOOL _isObservingAppEvents; tAudioManagerResignBehavior _resignBehavior; } @property (readonly) CDSoundEngine *soundEngine; @property (readonly) CDLongAudioSource *backgroundMusic; @property (readonly) BOOL willPlayBackgroundMusic; /** Returns the shared singleton */ + (CDAudioManager *) sharedManager; + (tAudioManagerState) sharedManagerState; /** Configures the shared singleton with a mode*/ + (void) configure: (tAudioManagerMode) mode; /** Initializes the engine asynchronously with a mode */ + (void) initAsynchronously: (tAudioManagerMode) mode; /** Initializes the engine synchronously with a mode, channel definition and a total number of channels */ - (id) init: (tAudioManagerMode) mode; -(void) audioSessionInterrupted; -(void) audioSessionResumed; -(void) setResignBehavior:(tAudioManagerResignBehavior) resignBehavior autoHandle:(BOOL) autoHandle; /** Returns true is audio is muted at a hardware level e.g user has ringer switch set to off */ -(BOOL) isDeviceMuted; /** Returns true if another app is playing audio such as the iPod music player */ -(BOOL) isOtherAudioPlaying; /** Sets the way the audio manager interacts with the operating system such as whether it shares output with other apps or obeys the mute switch */ -(void) setMode:(tAudioManagerMode) mode; /** Shuts down the shared audio manager instance so that it can be reinitialised */ +(void) end; /** Call if you want to use built in resign behavior but need to do some additional audio processing on resign active. */ - (void) applicationWillResignActive; /** Call if you want to use built in resign behavior but need to do some additional audio processing on become active. */ - (void) applicationDidBecomeActive; //New AVAudioPlayer API /** Loads the data from the specified file path to the channel's audio source */ -(CDLongAudioSource*) audioSourceLoad:(NSString*) filePath channel:(tAudioSourceChannel) channel; /** Retrieves the audio source for the specified channel */ -(CDLongAudioSource*) audioSourceForChannel:(tAudioSourceChannel) channel; //Legacy AVAudioPlayer API /** Plays music in background. The music can be looped or not It is recommended to use .aac files as background music since they are decoded by the device (hardware). */ -(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop; /** Preloads a background music */ -(void) preloadBackgroundMusic:(NSString*) filePath; /** Stops playing the background music */ -(void) stopBackgroundMusic; /** Pauses the background music */ -(void) pauseBackgroundMusic; /** Rewinds the background music */ -(void) rewindBackgroundMusic; /** Resumes playing the background music */ -(void) resumeBackgroundMusic; /** Returns whether or not the background music is playing */ -(BOOL) isBackgroundMusicPlaying; -(void) setBackgroundMusicCompletionListener:(id) listener selector:(SEL) selector; @end /** Fader for long audio source objects */ @interface CDLongAudioSourceFader : CDPropertyModifier{} @end static const int kCDNoBuffer = -1; /** Allows buffers to be associated with file names */ @interface CDBufferManager:NSObject{ NSMutableDictionary* loadedBuffers; NSMutableArray *freedBuffers; CDSoundEngine *soundEngine; int nextBufferId; } -(id) initWithEngine:(CDSoundEngine *) theSoundEngine; -(int) bufferForFile:(NSString*) filePath create:(BOOL) create; -(void) releaseBufferForFile:(NSString *) filePath; @end ================================================ FILE: cocos2d/cocos/audio/mac/CDAudioManager.m ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "CDAudioManager.h" NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; //NSOperation object used to asynchronously initialise @implementation CDAsynchInitialiser -(void) main { [super main]; [CDAudioManager sharedManager]; } @end @implementation CDLongAudioSource @synthesize audioSourcePlayer, audioSourceFilePath, delegate, backgroundMusic, paused; -(id) init { if ((self = [super init])) { state = kLAS_Init; volume = 1.0f; mute = NO; enabled_ = YES; paused = NO; } return self; } -(void) dealloc { CDLOGINFO(@"Denshion::CDLongAudioSource - deallocating %@", self); [audioSourcePlayer release]; [audioSourceFilePath release]; [super dealloc]; } -(void) load:(NSString*) filePath { //We have alread loaded a file previously, check if we are being asked to load the same file if (state == kLAS_Init || ![filePath isEqualToString:audioSourceFilePath]) { CDLOGINFO(@"Denshion::CDLongAudioSource - Loading new audio source %@",filePath); //New file if (state != kLAS_Init) { [audioSourceFilePath release];//Release old file path [audioSourcePlayer release];//Release old AVAudioPlayer, they can't be reused } audioSourceFilePath = [filePath copy]; NSError *error = nil; NSString *path = [CDUtilities fullPathFromRelativePath:audioSourceFilePath]; audioSourcePlayer = [(AVAudioPlayer*)[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&error]; if (error == nil) { [audioSourcePlayer prepareToPlay]; audioSourcePlayer.delegate = self; if (delegate && [delegate respondsToSelector:@selector(cdAudioSourceFileDidChange:)]) { //Tell our delegate the file has changed [delegate cdAudioSourceFileDidChange:self]; } } else { CDLOG(@"Denshion::CDLongAudioSource - Error initialising audio player: %@",error); } } else { //Same file - just return it to a consistent state [self pause]; [self rewind]; } audioSourcePlayer.volume = volume; audioSourcePlayer.numberOfLoops = numberOfLoops; state = kLAS_Loaded; } -(void) play { if (enabled_) { self->systemPaused = NO; self->paused = NO; [audioSourcePlayer play]; } else { CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled"); } } -(void) stop { self->paused = NO; [audioSourcePlayer stop]; } -(void) pause { self->paused = YES; [audioSourcePlayer pause]; } -(void) rewind { self->paused = NO; [audioSourcePlayer setCurrentTime:0]; } -(void) resume { self->paused = NO; [audioSourcePlayer play]; } -(BOOL) isPlaying { if (state != kLAS_Init) { return [audioSourcePlayer isPlaying]; } else { return NO; } } -(void) setVolume:(float) newVolume { volume = newVolume; if (state != kLAS_Init && !mute) { audioSourcePlayer.volume = newVolume; } } -(float) volume { return volume; } #pragma mark Audio Interrupt Protocol -(BOOL) mute { return mute; } -(void) setMute:(BOOL) muteValue { if (mute != muteValue) { if (mute) { //Turn sound back on audioSourcePlayer.volume = volume; } else { audioSourcePlayer.volume = 0.0f; } mute = muteValue; } } -(BOOL) enabled { return enabled_; } -(void) setEnabled:(BOOL)enabledValue { if (enabledValue != enabled_) { enabled_ = enabledValue; if (!enabled_) { //"Stop" the sounds [self pause]; [self rewind]; } } } -(NSInteger) numberOfLoops { return numberOfLoops; } -(void) setNumberOfLoops:(NSInteger) loopCount { audioSourcePlayer.numberOfLoops = loopCount; numberOfLoops = loopCount; } - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player finished"); #if TARGET_IPHONE_SIMULATOR CDLOGINFO(@"Denshion::CDLongAudioSource - workaround for OpenAL clobbered audio issue"); //This is a workaround for an issue in all simulators (tested to 3.1.2). Problem is //that OpenAL audio playback is clobbered when an AVAudioPlayer stops. Workaround //is to keep the player playing on an endless loop with 0 volume and then when //it is played again reset the volume and set loop count appropriately. //NB: this workaround is not foolproof but it is good enough for most situations. player.numberOfLoops = -1; player.volume = 0; [player play]; #endif if (delegate && [delegate respondsToSelector:@selector(cdAudioSourceDidFinishPlaying:)]) { [delegate cdAudioSourceDidFinishPlaying:self]; } } -(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player interrupted"); } -(void)audioPlayerEndInterruption:(AVAudioPlayer *)player { CDLOGINFO(@"Denshion::CDLongAudioSource - audio player resumed"); if (self.backgroundMusic) { //Check if background music can play as rules may have changed during //the interruption. This is to address a specific issue in 4.x when //fast task switching if([CDAudioManager sharedManager].willPlayBackgroundMusic) { [player play]; } } else { [player play]; } } @end @interface CDAudioManager (PrivateMethods) -(BOOL) audioSessionSetActive:(BOOL) active; -(BOOL) audioSessionSetCategory:(NSString*) category; -(void) badAlContextHandler; @end @implementation CDAudioManager #define BACKGROUND_MUSIC_CHANNEL kASC_Left @synthesize soundEngine, willPlayBackgroundMusic; static CDAudioManager *sharedManager; static tAudioManagerState _sharedManagerState = kAMStateUninitialised; static tAudioManagerMode configuredMode; static BOOL configured = FALSE; -(BOOL) audioSessionSetActive:(BOOL) active { NSError *activationError = nil; if ([[AVAudioSession sharedInstance] setActive:active error:&activationError]) { _audioSessionActive = active; CDLOGINFO(@"Denshion::CDAudioManager - Audio session set active %i succeeded", active); return YES; } else { //Failed CDLOG(@"Denshion::CDAudioManager - Audio session set active %i failed with error %@", active, activationError); return NO; } } -(BOOL) audioSessionSetCategory:(NSString*) category { NSError *categoryError = nil; if ([[AVAudioSession sharedInstance] setCategory:category error:&categoryError]) { CDLOGINFO(@"Denshion::CDAudioManager - Audio session set category %@ succeeded", category); return YES; } else { //Failed CDLOG(@"Denshion::CDAudioManager - Audio session set category %@ failed with error %@", category, categoryError); return NO; } } // Init + (CDAudioManager *) sharedManager { @synchronized(self) { if (!sharedManager) { if (!configured) { //Set defaults here configuredMode = kAMM_FxPlusMusicIfNoOtherAudio; } sharedManager = [[CDAudioManager alloc] init:configuredMode]; _sharedManagerState = kAMStateInitialised;//This is only really relevant when using asynchronous initialisation [[NSNotificationCenter defaultCenter] postNotificationName:kCDN_AudioManagerInitialised object:nil]; } } return sharedManager; } + (tAudioManagerState) sharedManagerState { return _sharedManagerState; } /** * Call this to set up audio manager asynchronously. Initialisation is finished when sharedManagerState == kAMStateInitialised */ + (void) initAsynchronously: (tAudioManagerMode) mode { @synchronized(self) { if (_sharedManagerState == kAMStateUninitialised) { _sharedManagerState = kAMStateInitialising; [CDAudioManager configure:mode]; CDAsynchInitialiser *initOp = [[[CDAsynchInitialiser alloc] init] autorelease]; NSOperationQueue *opQ = [[[NSOperationQueue alloc] init] autorelease]; [opQ addOperation:initOp]; } } } + (id) alloc { @synchronized(self) { NSAssert(sharedManager == nil, @"Attempted to allocate a second instance of a singleton."); return [super alloc]; } return nil; } /* * Call this method before accessing the shared manager in order to configure the shared audio manager */ + (void) configure: (tAudioManagerMode) mode { configuredMode = mode; configured = TRUE; } -(BOOL) isOtherAudioPlaying { UInt32 isPlaying = 0; UInt32 varSize = sizeof(isPlaying); AudioSessionGetProperty (kAudioSessionProperty_OtherAudioIsPlaying, &varSize, &isPlaying); return (isPlaying != 0); } -(void) setMode:(tAudioManagerMode) mode { _mode = mode; switch (_mode) { case kAMM_FxOnly: //Share audio with other app CDLOGINFO(@"Denshion::CDAudioManager - Audio will be shared"); //_audioSessionCategory = kAudioSessionCategory_AmbientSound; _audioSessionCategory = AVAudioSessionCategoryAmbient; willPlayBackgroundMusic = NO; break; case kAMM_FxPlusMusic: //Use audio exclusively - if other audio is playing it will be stopped CDLOGINFO(@"Denshion::CDAudioManager - Audio will be exclusive"); //_audioSessionCategory = kAudioSessionCategory_SoloAmbientSound; _audioSessionCategory = AVAudioSessionCategorySoloAmbient; willPlayBackgroundMusic = YES; break; case kAMM_MediaPlayback: //Use audio exclusively, ignore mute switch and sleep CDLOGINFO(@"Denshion::CDAudioManager - Media playback mode, audio will be exclusive"); //_audioSessionCategory = kAudioSessionCategory_MediaPlayback; _audioSessionCategory = AVAudioSessionCategoryPlayback; willPlayBackgroundMusic = YES; break; case kAMM_PlayAndRecord: //Use audio exclusively, ignore mute switch and sleep, has inputs and outputs CDLOGINFO(@"Denshion::CDAudioManager - Play and record mode, audio will be exclusive"); //_audioSessionCategory = kAudioSessionCategory_PlayAndRecord; _audioSessionCategory = AVAudioSessionCategoryPlayAndRecord; willPlayBackgroundMusic = YES; break; default: //kAudioManagerFxPlusMusicIfNoOtherAudio if ([self isOtherAudioPlaying]) { CDLOGINFO(@"Denshion::CDAudioManager - Other audio is playing audio will be shared"); //_audioSessionCategory = kAudioSessionCategory_AmbientSound; _audioSessionCategory = AVAudioSessionCategoryAmbient; willPlayBackgroundMusic = NO; } else { CDLOGINFO(@"Denshion::CDAudioManager - Other audio is not playing audio will be exclusive"); //_audioSessionCategory = kAudioSessionCategory_SoloAmbientSound; _audioSessionCategory = AVAudioSessionCategorySoloAmbient; willPlayBackgroundMusic = YES; } break; } [self audioSessionSetCategory:_audioSessionCategory]; } /** * This method is used to work around various bugs introduced in 4.x OS versions. In some circumstances the * audio session is interrupted but never resumed, this results in the loss of OpenAL audio when following * standard practices. If we detect this situation then we will attempt to resume the audio session ourselves. * Known triggers: lock the device then unlock it (iOS 4.2 gm), playback a song using MPMediaPlayer (iOS 4.0) */ - (void) badAlContextHandler { if (_interrupted && alcGetCurrentContext() == NULL) { CDLOG(@"Denshion::CDAudioManager - bad OpenAL context detected, attempting to resume audio session"); [self audioSessionResumed]; } } - (id) init: (tAudioManagerMode) mode { if ((self = [super init])) { //Initialise the audio session AVAudioSession* session = [AVAudioSession sharedInstance]; session.delegate = self; _mode = mode; backgroundMusicCompletionSelector = nil; _isObservingAppEvents = FALSE; _mute = NO; _resigned = NO; _interrupted = NO; enabled_ = YES; _audioSessionActive = NO; [self setMode:mode]; soundEngine = [[CDSoundEngine alloc] init]; //Set up audioSource channels audioSourceChannels = [[NSMutableArray alloc] init]; CDLongAudioSource *leftChannel = [[CDLongAudioSource alloc] init]; leftChannel.backgroundMusic = YES; CDLongAudioSource *rightChannel = [[CDLongAudioSource alloc] init]; rightChannel.backgroundMusic = NO; [audioSourceChannels insertObject:leftChannel atIndex:kASC_Left]; [audioSourceChannels insertObject:rightChannel atIndex:kASC_Right]; [leftChannel release]; [rightChannel release]; //Used to support legacy APIs backgroundMusic = [self audioSourceForChannel:BACKGROUND_MUSIC_CHANNEL]; backgroundMusic.delegate = self; //Add handler for bad al context messages, these are posted by the sound engine. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(badAlContextHandler) name:kCDN_BadAlContext object:nil]; } return self; } -(void) dealloc { CDLOGINFO(@"Denshion::CDAudioManager - deallocating"); [self stopBackgroundMusic]; [soundEngine release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self audioSessionSetActive:NO]; [audioSourceChannels release]; [super dealloc]; } /** Retrieves the audio source for the specified channel */ -(CDLongAudioSource*) audioSourceForChannel:(tAudioSourceChannel) channel { return (CDLongAudioSource*)[audioSourceChannels objectAtIndex:channel]; } /** Loads the data from the specified file path to the channel's audio source */ -(CDLongAudioSource*) audioSourceLoad:(NSString*) filePath channel:(tAudioSourceChannel) channel { CDLongAudioSource *audioSource = [self audioSourceForChannel:channel]; if (audioSource) { [audioSource load:filePath]; } return audioSource; } -(BOOL) isBackgroundMusicPlaying { return [self.backgroundMusic isPlaying]; } //NB: originally I tried using a route change listener and intended to store the current route, //however, on a 3gs running 3.1.2 no route change is generated when the user switches the //ringer mute switch to off (i.e. enables sound) therefore polling is the only reliable way to //determine ringer switch state -(BOOL) isDeviceMuted { #if TARGET_IPHONE_SIMULATOR //Calling audio route stuff on the simulator causes problems return NO; #else CFStringRef newAudioRoute; UInt32 propertySize = sizeof (CFStringRef); AudioSessionGetProperty ( kAudioSessionProperty_AudioRoute, &propertySize, &newAudioRoute ); if (newAudioRoute == NULL) { //Don't expect this to happen but playing safe otherwise a null in the CFStringCompare will cause a crash return YES; } else { CFComparisonResult newDeviceIsMuted = CFStringCompare ( newAudioRoute, (CFStringRef) @"", 0 ); return (newDeviceIsMuted == kCFCompareEqualTo); } #endif } #pragma mark Audio Interrupt Protocol -(BOOL) mute { return _mute; } -(void) setMute:(BOOL) muteValue { if (muteValue != _mute) { _mute = muteValue; [soundEngine setMute:muteValue]; for( CDLongAudioSource *audioSource in audioSourceChannels) { audioSource.mute = muteValue; } } } -(BOOL) enabled { return enabled_; } -(void) setEnabled:(BOOL) enabledValue { if (enabledValue != enabled_) { enabled_ = enabledValue; [soundEngine setEnabled:enabled_]; for( CDLongAudioSource *audioSource in audioSourceChannels) { audioSource.enabled = enabled_; } } } -(CDLongAudioSource*) backgroundMusic { return backgroundMusic; } //Load background music ready for playing -(void) preloadBackgroundMusic:(NSString*) filePath { [self.backgroundMusic load:filePath]; } -(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop { [self.backgroundMusic load:filePath]; if (loop) { [self.backgroundMusic setNumberOfLoops:-1]; } else { [self.backgroundMusic setNumberOfLoops:0]; } if (!willPlayBackgroundMusic || _mute) { CDLOGINFO(@"Denshion::CDAudioManager - play bgm aborted because audio is not exclusive or sound is muted"); return; } [self.backgroundMusic play]; } -(void) stopBackgroundMusic { [self.backgroundMusic stop]; } -(void) pauseBackgroundMusic { [self.backgroundMusic pause]; } -(void) resumeBackgroundMusic { if (!willPlayBackgroundMusic || _mute) { CDLOGINFO(@"Denshion::CDAudioManager - resume bgm aborted because audio is not exclusive or sound is muted"); return; } if (![self.backgroundMusic paused]) { return; } [self.backgroundMusic resume]; } -(void) rewindBackgroundMusic { [self.backgroundMusic rewind]; } -(void) setBackgroundMusicCompletionListener:(id) listener selector:(SEL) selector { backgroundMusicCompletionListener = listener; backgroundMusicCompletionSelector = selector; } /* * Call this method to have the audio manager automatically handle application resign and * become active. Pass a tAudioManagerResignBehavior to indicate the desired behavior * for resigning and becoming active again. * * If autohandle is YES then the applicationWillResignActive and applicationDidBecomActive * methods are automatically called, otherwise you must call them yourself at the appropriate time. * * Based on idea of Dominique Bongard */ -(void) setResignBehavior:(tAudioManagerResignBehavior) resignBehavior autoHandle:(BOOL) autoHandle { if (!_isObservingAppEvents && autoHandle) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) name:@"UIApplicationWillResignActiveNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:@"UIApplicationDidBecomeActiveNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"UIApplicationWillTerminateNotification" object:nil]; _isObservingAppEvents = TRUE; } _resignBehavior = resignBehavior; } - (void) applicationWillResignActive { self->_resigned = YES; //Set the audio sesssion to one that allows sharing so that other audio won't be clobbered on resume [self audioSessionSetCategory:AVAudioSessionCategoryAmbient]; switch (_resignBehavior) { case kAMRBStopPlay: for( CDLongAudioSource *audioSource in audioSourceChannels) { if (audioSource.isPlaying) { audioSource->systemPaused = YES; audioSource->systemPauseLocation = audioSource.audioSourcePlayer.currentTime; [audioSource stop]; } else { //Music is either paused or stopped, if it is paused it will be restarted //by OS so we will stop it. audioSource->systemPaused = NO; [audioSource stop]; } } break; case kAMRBStop: //Stop music regardless of whether it is playing or not because if it was paused //then the OS would resume it for( CDLongAudioSource *audioSource in audioSourceChannels) { [audioSource stop]; } default: break; } CDLOGINFO(@"Denshion::CDAudioManager - handled resign active"); } //Called when application resigns active only if setResignBehavior has been called - (void) applicationWillResignActive:(NSNotification *) notification { [self applicationWillResignActive]; } - (void) applicationDidBecomeActive { if (self->_resigned) { _resigned = NO; //Reset the mode incase something changed with audio while we were inactive [self setMode:_mode]; switch (_resignBehavior) { case kAMRBStopPlay: //Music had been stopped but stop maintains current time //so playing again will continue from where music was before resign active. //We check if music can be played because while we were inactive the user might have //done something that should force music to not play such as starting a track in the iPod if (self.willPlayBackgroundMusic) { for( CDLongAudioSource *audioSource in audioSourceChannels) { if (audioSource->systemPaused) { [audioSource resume]; audioSource->systemPaused = NO; } } } break; default: break; } CDLOGINFO(@"Denshion::CDAudioManager - audio manager handled become active"); } } //Called when application becomes active only if setResignBehavior has been called - (void) applicationDidBecomeActive:(NSNotification *) notification { [self applicationDidBecomeActive]; } //Called when application terminates only if setResignBehavior has been called - (void) applicationWillTerminate:(NSNotification *) notification { CDLOGINFO(@"Denshion::CDAudioManager - audio manager handling terminate"); [self stopBackgroundMusic]; } /** The audio source completed playing */ - (void) cdAudioSourceDidFinishPlaying:(CDLongAudioSource *) audioSource { CDLOGINFO(@"Denshion::CDAudioManager - audio manager got told background music finished"); if (backgroundMusicCompletionSelector != nil) { [backgroundMusicCompletionListener performSelector:backgroundMusicCompletionSelector]; } } -(void) beginInterruption { CDLOGINFO(@"Denshion::CDAudioManager - begin interruption"); [self audioSessionInterrupted]; } -(void) endInterruption { CDLOGINFO(@"Denshion::CDAudioManager - end interruption"); [self audioSessionResumed]; } #if __CC_PLATFORM_IOS >= 40000 -(void) endInterruptionWithFlags:(NSUInteger)flags { CDLOGINFO(@"Denshion::CDAudioManager - interruption ended with flags %i",flags); if (flags == AVAudioSessionInterruptionFlags_ShouldResume) { [self audioSessionResumed]; } } #endif -(void)audioSessionInterrupted { if (!_interrupted) { CDLOGINFO(@"Denshion::CDAudioManager - Audio session interrupted"); _interrupted = YES; // Deactivate the current audio session [self audioSessionSetActive:NO]; if (alcGetCurrentContext() != NULL) { CDLOGINFO(@"Denshion::CDAudioManager - Setting OpenAL context to NULL"); ALenum error = AL_NO_ERROR; // set the current context to NULL will 'shutdown' openAL alcMakeContextCurrent(NULL); if((error = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDAudioManager - Error making context current %x\n", error); } #pragma unused(error) } } } -(void)audioSessionResumed { if (_interrupted) { CDLOGINFO(@"Denshion::CDAudioManager - Audio session resumed"); _interrupted = NO; BOOL activationResult = NO; // Reactivate the current audio session activationResult = [self audioSessionSetActive:YES]; //This code is to handle a problem with iOS 4.0 and 4.01 where reactivating the session can fail if //task switching is performed too rapidly. A test case that reliably reproduces the issue is to call the //iPhone and then hang up after two rings (timing may vary ;)) //Basically we keep waiting and trying to let the OS catch up with itself but the number of tries is //limited. if (!activationResult) { CDLOG(@"Denshion::CDAudioManager - Failure reactivating audio session, will try wait-try cycle"); int activateCount = 0; while (!activationResult && activateCount < 10) { [NSThread sleepForTimeInterval:0.5]; activationResult = [self audioSessionSetActive:YES]; activateCount++; CDLOGINFO(@"Denshion::CDAudioManager - Reactivation attempt %i status = %i",activateCount,activationResult); } } if (alcGetCurrentContext() == NULL) { CDLOGINFO(@"Denshion::CDAudioManager - Restoring OpenAL context"); ALenum error = AL_NO_ERROR; // Restore open al context alcMakeContextCurrent([soundEngine openALContext]); if((error = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDAudioManager - Error making context current%x\n", error); } #pragma unused(error) } } } +(void) end { [sharedManager release]; sharedManager = nil; } @end /////////////////////////////////////////////////////////////////////////////////////// @implementation CDLongAudioSourceFader -(void) _setTargetProperty:(float) newVal { ((CDLongAudioSource*)target).volume = newVal; } -(float) _getTargetProperty { return ((CDLongAudioSource*)target).volume; } -(void) _stopTarget { //Pause instead of stop as stop releases resources and causes problems in the simulator [((CDLongAudioSource*)target) pause]; } -(Class) _allowableType { return [CDLongAudioSource class]; } @end /////////////////////////////////////////////////////////////////////////////////////// @implementation CDBufferManager -(id) initWithEngine:(CDSoundEngine *) theSoundEngine { if ((self = [super init])) { soundEngine = theSoundEngine; loadedBuffers = [[NSMutableDictionary alloc] initWithCapacity:CD_BUFFERS_START]; freedBuffers = [[NSMutableArray alloc] init]; nextBufferId = 0; } return self; } -(void) dealloc { [loadedBuffers release]; [freedBuffers release]; [super dealloc]; } -(int) bufferForFile:(NSString*) filePath create:(BOOL) create { NSNumber* soundId = (NSNumber*)[loadedBuffers objectForKey:filePath]; if(soundId == nil) { if (create) { NSNumber* bufferId = nil; //First try to get a buffer from the free buffers if ([freedBuffers count] > 0) { bufferId = [[[freedBuffers lastObject] retain] autorelease]; [freedBuffers removeLastObject]; CDLOGINFO(@"Denshion::CDBufferManager reusing buffer id %i",[bufferId intValue]); } else { bufferId = [[NSNumber alloc] initWithInt:nextBufferId]; [bufferId autorelease]; CDLOGINFO(@"Denshion::CDBufferManager generating new buffer id %i",[bufferId intValue]); nextBufferId++; } if ([soundEngine loadBuffer:[bufferId intValue] filePath:filePath]) { //File successfully loaded CDLOGINFO(@"Denshion::CDBufferManager buffer loaded %@ %@",bufferId,filePath); [loadedBuffers setObject:bufferId forKey:filePath]; return [bufferId intValue]; } else { //File didn't load, put buffer id on free list [freedBuffers addObject:bufferId]; return kCDNoBuffer; } } else { //No matching buffer was found return kCDNoBuffer; } } else { return [soundId intValue]; } } -(void) releaseBufferForFile:(NSString *) filePath { int bufferId = [self bufferForFile:filePath create:NO]; if (bufferId != kCDNoBuffer) { [soundEngine unloadBuffer:bufferId]; [loadedBuffers removeObjectForKey:filePath]; NSNumber *freedBufferId = [[NSNumber alloc] initWithInt:bufferId]; [freedBufferId autorelease]; [freedBuffers addObject:freedBufferId]; } } @end ================================================ FILE: cocos2d/cocos/audio/mac/CDConfig.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #define COCOSDENSHION_VERSION "Aphex.rc" /** If enabled code useful for debugging such as parameter check assertions will be performed. If you experience any problems you should enable this and test your code with a debug build. */ //#define CD_DEBUG 1 /** The total number of sounds/buffers that can be loaded assuming memory is sufficient */ //Number of buffers slots that will be initially created #define CD_BUFFERS_START 64 //Number of buffers that will be added #define CD_BUFFERS_INCREMENT 16 /** If enabled, OpenAL code will use static buffers. When static buffers are used the audio data is managed outside of OpenAL, this eliminates a memcpy operation which leads to higher performance when loading sounds. However, the downside is that when the audio data is freed you must be certain that it is no longer being accessed otherwise your app will crash. Testing on OS 2.2.1 and 3.1.2 has shown that this may occur if a buffer is being used by a source with state = AL_PLAYING when the buffer is deleted. If the data is freed too quickly after the source is stopped then a crash will occur. The implemented workaround is that when static buffers are used the unloadBuffer code will wait for any playing sources to finish playing before the associated buffer and data are deleted, however, this delay may negate any performance gains that are achieved during loading. Performance tests on a 1st gen iPod running OS 2.2.1 loading the CocosDenshionDemo sounds were ~0.14 seconds without static buffers and ~0.12 seconds when using static buffers. */ //#define CD_USE_STATIC_BUFFERS 1 ================================================ FILE: cocos2d/cocos/audio/mac/CDOpenALSupport.h ================================================ /* Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2009 Apple Inc. All Rights Reserved. $Id$ */ /* This file contains code from version 1.1 and 1.4 of MyOpenALSupport.h taken from Apple's oalTouch version. The 1.4 version code is used for loading IMA4 files, however, this code causes very noticeable clicking when used to load wave files that are looped so the 1.1 version code is used specifically for loading wav files. */ #ifndef __CD_OPENAL_H #define __CD_OPENAL_H #ifdef __cplusplus extern "C" { #endif #import #import #import //Taken from oalTouch MyOpenALSupport 1.1 void* CDloadWaveAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate); void* CDloadCafAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate); void* CDGetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate); #ifdef __cplusplus } #endif #endif ================================================ FILE: cocos2d/cocos/audio/mac/CDOpenALSupport.m ================================================ /* Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2009 Apple Inc. All Rights Reserved. $Id: CDOpenALSupport.h 16 2010-03-11 06:22:10Z steveoldmeadow $ */ #import "CDOpenALSupport.h" #import "CocosDenshion.h" #import #import //Taken from oalTouch MyOpenALSupport 1.1 void* CDloadWaveAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate) { OSStatus err = noErr; UInt64 fileDataSize = 0; AudioStreamBasicDescription theFileFormat; UInt32 thePropertySize = sizeof(theFileFormat); AudioFileID afid = 0; void* theData = NULL; // Open a file with ExtAudioFileOpen() err = AudioFileOpenURL(inFileURL, kAudioFileReadPermission, 0, &afid); if(err) { CDLOG(@"MyGetOpenALAudioData: AudioFileOpenURL FAILED, Error = %ld\n", err); goto Exit; } // Get the audio data format err = AudioFileGetProperty(afid, kAudioFilePropertyDataFormat, &thePropertySize, &theFileFormat); if(err) { CDLOG(@"MyGetOpenALAudioData: AudioFileGetProperty(kAudioFileProperty_DataFormat) FAILED, Error = %ld\n", err); goto Exit; } if (theFileFormat.mChannelsPerFrame > 2) { CDLOG(@"MyGetOpenALAudioData - Unsupported Format, channel count is greater than stereo\n"); goto Exit; } if ((theFileFormat.mFormatID != kAudioFormatLinearPCM) || (!TestAudioFormatNativeEndian(theFileFormat))) { CDLOG(@"MyGetOpenALAudioData - Unsupported Format, must be little-endian PCM\n"); goto Exit; } if ((theFileFormat.mBitsPerChannel != 8) && (theFileFormat.mBitsPerChannel != 16)) { CDLOG(@"MyGetOpenALAudioData - Unsupported Format, must be 8 or 16 bit PCM\n"); goto Exit; } thePropertySize = sizeof(fileDataSize); err = AudioFileGetProperty(afid, kAudioFilePropertyAudioDataByteCount, &thePropertySize, &fileDataSize); if(err) { CDLOG(@"MyGetOpenALAudioData: AudioFileGetProperty(kAudioFilePropertyAudioDataByteCount) FAILED, Error = %ld\n", err); goto Exit; } // Read all the data into memory UInt32 dataSize = (UInt32)fileDataSize; theData = malloc(dataSize); if (theData) { memset(theData, 0, dataSize); AudioFileReadBytes(afid, false, 0, &dataSize, theData); if(err == noErr) { // success *outDataSize = (ALsizei)dataSize; //This fix was added by me, however, 8 bit sounds have a clipping sound at the end so aren't really usable (SO) if (theFileFormat.mBitsPerChannel == 16) { *outDataFormat = (theFileFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; } else { *outDataFormat = (theFileFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8; } *outSampleRate = (ALsizei)theFileFormat.mSampleRate; } else { // failure free (theData); theData = NULL; // make sure to return NULL CDLOG(@"MyGetOpenALAudioData: ExtAudioFileRead FAILED, Error = %ld\n", err); goto Exit; } } Exit: // Dispose the ExtAudioFileRef, it is no longer needed if (afid) AudioFileClose(afid); return theData; } //Taken from oalTouch MyOpenALSupport 1.4 void* CDloadCafAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate) { OSStatus status = noErr; BOOL abort = NO; SInt64 theFileLengthInFrames = 0; AudioStreamBasicDescription theFileFormat; UInt32 thePropertySize = sizeof(theFileFormat); ExtAudioFileRef extRef = NULL; void* theData = NULL; AudioStreamBasicDescription theOutputFormat; UInt32 dataSize = 0; // Open a file with ExtAudioFileOpen() status = ExtAudioFileOpenURL(inFileURL, &extRef); if (status != noErr) { CDLOG(@"MyGetOpenALAudioData: ExtAudioFileOpenURL FAILED, Error = %ld\n", status); abort = YES; } if (abort) goto Exit; // Get the audio data format status = ExtAudioFileGetProperty(extRef, kExtAudioFileProperty_FileDataFormat, &thePropertySize, &theFileFormat); if (status != noErr) { CDLOG(@"MyGetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileDataFormat) FAILED, Error = %ld\n", status); abort = YES; } if (abort) goto Exit; if (theFileFormat.mChannelsPerFrame > 2) { CDLOG(@"MyGetOpenALAudioData - Unsupported Format, channel count is greater than stereo\n"); abort = YES; } if (abort) goto Exit; // Set the client format to 16 bit signed integer (native-endian) data // Maintain the channel count and sample rate of the original source format theOutputFormat.mSampleRate = theFileFormat.mSampleRate; theOutputFormat.mChannelsPerFrame = theFileFormat.mChannelsPerFrame; theOutputFormat.mFormatID = kAudioFormatLinearPCM; theOutputFormat.mBytesPerPacket = 2 * theOutputFormat.mChannelsPerFrame; theOutputFormat.mFramesPerPacket = 1; theOutputFormat.mBytesPerFrame = 2 * theOutputFormat.mChannelsPerFrame; theOutputFormat.mBitsPerChannel = 16; theOutputFormat.mFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger; // Set the desired client (output) data format status = ExtAudioFileSetProperty(extRef, kExtAudioFileProperty_ClientDataFormat, sizeof(theOutputFormat), &theOutputFormat); if (status != noErr) { CDLOG(@"MyGetOpenALAudioData: ExtAudioFileSetProperty(kExtAudioFileProperty_ClientDataFormat) FAILED, Error = %ld\n", status); abort = YES; } if (abort) goto Exit; // Get the total frame count thePropertySize = sizeof(theFileLengthInFrames); status = ExtAudioFileGetProperty(extRef, kExtAudioFileProperty_FileLengthFrames, &thePropertySize, &theFileLengthInFrames); if (status != noErr) { CDLOG(@"MyGetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileLengthFrames) FAILED, Error = %ld\n", status); abort = YES; } if (abort) goto Exit; // Read all the data into memory dataSize = (UInt32) theFileLengthInFrames * theOutputFormat.mBytesPerFrame; theData = malloc(dataSize); if (theData) { memset(theData, 0, dataSize); AudioBufferList theDataBuffer; theDataBuffer.mNumberBuffers = 1; theDataBuffer.mBuffers[0].mDataByteSize = dataSize; theDataBuffer.mBuffers[0].mNumberChannels = theOutputFormat.mChannelsPerFrame; theDataBuffer.mBuffers[0].mData = theData; // Read the data into an AudioBufferList status = ExtAudioFileRead(extRef, (UInt32*)&theFileLengthInFrames, &theDataBuffer); if(status == noErr) { // success *outDataSize = (ALsizei)dataSize; *outDataFormat = (theOutputFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; *outSampleRate = (ALsizei)theOutputFormat.mSampleRate; } else { // failure free (theData); theData = NULL; // make sure to return NULL CDLOG(@"MyGetOpenALAudioData: ExtAudioFileRead FAILED, Error = %ld\n", status); abort = YES; } } if (abort) goto Exit; Exit: // Dispose the ExtAudioFileRef, it is no longer needed if (extRef) ExtAudioFileDispose(extRef); return theData; } void* CDGetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei* outSampleRate) { CFStringRef extension = CFURLCopyPathExtension(inFileURL); CFComparisonResult isWavFile = 0; if (extension != NULL) { isWavFile = CFStringCompare (extension,(CFStringRef)@"wav", kCFCompareCaseInsensitive); CFRelease(extension); } if (isWavFile == kCFCompareEqualTo) { return CDloadWaveAudioData(inFileURL, outDataSize, outDataFormat, outSampleRate); } else { return CDloadCafAudioData(inFileURL, outDataSize, outDataFormat, outSampleRate); } } ================================================ FILE: cocos2d/cocos/audio/mac/CDXMacOSXSupport.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ /** A set of proxy classes to allow iOS audio code to run on MacOS X. AVAudioPlayer is implemented using NSSound. AVAudioSession is a "do nothing" class as it isn't really relevant on MacOS X. Limitations: AVAudioPlayer numberOfLoops not correctly supported. Looping is either on or off, can not specify a specific number of loops. AVAudioPlayer panning not supported. AVAudioPlayer metering not supported. AVAudioSession nothing is supported, not applicable to MacOS X. */ #import #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) #import #import enum AudioSessionProperties { kAudioSessionProperty_OtherAudioIsPlaying, kAudioSessionProperty_AudioRoute }; #ifdef __cplusplus extern "C" { #endif extern OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *outData); #ifdef __cplusplus } #endif /** Based on AVAudioPlayer.h header in AVFoundation headers */ @class NSData, NSURL, NSError, NSDictionary; @protocol AVAudioPlayerDelegate; /* This class is available with iPhone 2.2 or later */ @interface AVAudioPlayer : NSObject { // properties id delegate; NSUInteger numberOfChannels; BOOL playing; NSTimeInterval duration; NSURL *url; NSData *data; float pan; float volume; NSTimeInterval currentTime; NSTimeInterval deviceCurrentTime; NSInteger numberOfLoops; BOOL meteringEnabled; @private NSSound* _player; } /* For all of these init calls, if a return value of nil is given you can check outError to see what the problem was. If not nil, then the object is usable for playing */ /* all data must be in the form of an audio file understood by CoreAudio */ - (id)initWithContentsOfURL:(NSURL *)theUrl error:(NSError **)outError; - (id)initWithData:(NSData *)theData error:(NSError **)outError; /* transport control */ /* methods that return BOOL return YES on success and NO on failure. */ - (BOOL)prepareToPlay; /* get ready to play the sound. happens automatically on play. */ - (BOOL)play; /* sound is played asynchronously. */ - (BOOL)playAtTime:(NSTimeInterval) time; /* play a sound some time in the future. time should be greater than deviceCurrentTime. */ - (void)pause; /* pauses playback, but remains ready to play. */ - (void)stop; /* stops playback. no longer ready to play. */ /* properties */ @property(readonly, getter=isPlaying) BOOL playing; @property(readonly) NSUInteger numberOfChannels; @property(readonly) NSTimeInterval duration; /* the duration of the sound. */ @property(assign) id delegate; /* the delegate will be sent playerDidFinishPlaying */ /* one of these three properties will be non-nil based on the init... method used */ @property(readonly) NSURL *url; /* returns nil if object was not created with a URL */ @property(readonly) NSData *data; /* returns nil if object was not created with a data object */ @property float pan; /* set panning. -1.0 is left, 0.0 is center, 1.0 is right. */ @property float volume; /* The volume for the sound. The nominal range is from 0.0 to 1.0. */ /* If the sound is playing, currentTime is the offset into the sound of the current playback position. If the sound is not playing, currentTime is the offset into the sound where playing would start. */ @property NSTimeInterval currentTime; /* returns the current time associated with the output device */ @property(readonly) NSTimeInterval deviceCurrentTime; /* "numberOfLoops" is the number of times that the sound will return to the beginning upon reaching the end. A value of zero means to play the sound just once. A value of one will result in playing the sound twice, and so on.. Any negative number will loop indefinitely until stopped. */ @property NSInteger numberOfLoops; /* metering */ @property(getter=isMeteringEnabled) BOOL meteringEnabled; /* turns level metering on or off. default is off. */ - (void)updateMeters; /* call to refresh meter values */ - (float)peakPowerForChannel:(NSUInteger)channelNumber; /* returns peak power in decibels for a given channel */ - (float)averagePowerForChannel:(NSUInteger)channelNumber; /* returns average power in decibels for a given channel */ @end /* A protocol for delegates of AVAudioPlayer */ @protocol AVAudioPlayerDelegate @optional /* audioPlayerDidFinishPlaying:successfully: is called when a sound has finished playing. This method is NOT called if the player is stopped due to an interruption. */ - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag; /* if an error occurs while decoding it will be reported to the delegate. */ - (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error; /* audioPlayerBeginInterruption: is called when the audio session has been interrupted while the player was playing. The player will have been paused. */ - (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player; /* audioPlayerEndInterruption:withFlags: is called when the audio session interruption has ended and this player had been interrupted while playing. */ /* Currently the only flag is AVAudioSessionInterruptionFlags_ShouldResume. */ - (void)audioPlayerEndInterruption:(AVAudioPlayer *)player withFlags:(NSUInteger)flags; /* audioPlayerEndInterruption: is called when the preferred method, audioPlayerEndInterruption:withFlags:, is not implemented. */ - (void)audioPlayerEndInterruption:(AVAudioPlayer *)player; @end /** Taken from AVAudioSession.h header in AVFoundation headers */ /* This protocol is available with iPhone 3.0 or later */ @protocol AVAudioSessionDelegate; @class NSError, NSString; /* values for the category property */ extern NSString *const AVAudioSessionCategoryAmbient; extern NSString *const AVAudioSessionCategorySoloAmbient; extern NSString *const AVAudioSessionCategoryPlayback; extern NSString *const AVAudioSessionCategoryRecord; extern NSString *const AVAudioSessionCategoryPlayAndRecord; extern NSString *const AVAudioSessionCategoryAudioProcessing; enum { AVAudioSessionInterruptionFlags_ShouldResume = 1 }; enum { AVAudioSessionSetActiveFlags_NotifyOthersOnDeactivation = 1 }; @interface AVAudioSession : NSObject { // properties NSString* category; double preferredHardwareSampleRate; NSTimeInterval preferredIOBufferDuration; BOOL inputIsAvailable; double currentHardwareSampleRate; NSInteger currentHardwareInputNumberOfChannels; NSInteger currentHardwareOutputNumberOfChannels; id delegate; @private __strong void *_impl; } /* returns singleton instance */ + (id)sharedInstance; @property(assign) id delegate; - (BOOL)setActive:(BOOL)beActive error:(NSError**)outError; - (BOOL)setActive:(BOOL)beActive withFlags:(NSInteger)flags error:(NSError**)outError; - (BOOL)setCategory:(NSString*)theCategory error:(NSError**)outError; - (BOOL)setPreferredHardwareSampleRate:(double)sampleRate error:(NSError**)outError; - (BOOL)setPreferredIOBufferDuration:(NSTimeInterval)duration error:(NSError**)outError; @property(readonly) NSString* category; @property(readonly) double preferredHardwareSampleRate; @property(readonly) NSTimeInterval preferredIOBufferDuration; @property(readonly) BOOL inputIsAvailable; @property(readonly) double currentHardwareSampleRate; @property(readonly) NSInteger currentHardwareInputNumberOfChannels; @property(readonly) NSInteger currentHardwareOutputNumberOfChannels; @end /* A protocol for delegates of AVAudioSession */ @protocol AVAudioSessionDelegate @optional - (void)beginInterruption; - (void)endInterruptionWithFlags:(NSUInteger)flags; - (void)endInterruption; /* endInterruptionWithFlags: will be called instead if implemented. */ - (void)inputIsAvailableChanged:(BOOL)isInputAvailable; @end #endif ================================================ FILE: cocos2d/cocos/audio/mac/CDXMacOSXSupport.mm ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) #import "CDXMacOSXSupport.h" #import "SimpleAudioEngine.h" #import "CocosDenshion.h" NSString * const AVAudioSessionCategoryAmbient = @"AVAudioSessionCategoryAmbient"; NSString *const AVAudioSessionCategorySoloAmbient = @"AVAudioSessionCategorySoloAmbient"; NSString *const AVAudioSessionCategoryPlayback = @"AVAudioSessionCategoryPlayback"; NSString *const AVAudioSessionCategoryRecord = @"AVAudioSessionCategoryRecord"; NSString *const AVAudioSessionCategoryPlayAndRecord = @"AVAudioSessionCategoryPlayAndRecord"; NSString *const AVAudioSessionCategoryAudioProcessing = @"AVAudioSessionCategoryAudioProcessing"; OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *outData) { //TODO: set outData appropriately return 0; } @implementation AVAudioPlayer @synthesize delegate, numberOfChannels, pan, deviceCurrentTime, url, data; - (id)initWithContentsOfURL:(NSURL *)theUrl error:(NSError **)outError { if ((self = [super init])) { _player = [[NSSound alloc] initWithContentsOfURL:theUrl byReference:YES]; if (_player != nil) { _player.delegate = self; CDLOG(@"Denshion::CDXMacOSXSupport - NSSound allocated for %@", theUrl); } } return self; } - (id)initWithData:(NSData *)theData error:(NSError **)outError { if ((self = [super init])) { _player = [[NSSound alloc] initWithData:theData]; if (_player != nil) { _player.delegate = self; CDLOG(@"Denshion::CDXMacOSXSupport - NSSound allocated for %@", theData); } } return self; } -(void) dealloc { [_player release]; [super dealloc]; } - (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finished { if (self.delegate && [self.delegate respondsToSelector:@selector(audioPlayerDidFinishPlaying:successfully:)]) { [self.delegate audioPlayerDidFinishPlaying:self successfully:finished]; } } - (BOOL)play { BOOL result; result = [_player play]; if (!result) { //May be paused, try resuming instead result = [_player resume]; } return result; } -(void) pause { [_player pause]; } -(void) stop { [_player stop]; } -(BOOL) isPlaying { return [_player isPlaying]; } -(void) setVolume:(float) vol { [_player setVolume:vol]; } -(float) volume { return [_player volume]; } -(void) setNumberOfLoops:(NSInteger) nOfLoops { if (nOfLoops < 0) { [_player setLoops:YES]; } else { [_player setLoops:NO]; } } -(NSInteger) numberOfLoops { if (_player.loops) { return -1; } else { return 0; } } -(void) setCurrentTime:(NSTimeInterval) aCurrentTime { [_player setCurrentTime:aCurrentTime]; } -(NSTimeInterval) currentTime { return [_player currentTime]; } -(NSTimeInterval) duration { return [_player duration]; } #pragma mark unsupported - (BOOL)prepareToPlay { return YES; } -(BOOL)playAtTime:(NSTimeInterval)time { return YES; } -(void) setMeteringEnabled:(BOOL) enabled { } -(BOOL) isMeteringEnabled { return NO; } - (void)updateMeters{} - (float)peakPowerForChannel:(NSUInteger)channelNumber{return 0.0f;} - (float)averagePowerForChannel:(NSUInteger)channelNumber{return 0.0f;} @end /** A "do nothing" implementation - AVAudioSession is not really relevant to Mac OS X. */ @implementation AVAudioSession @synthesize delegate, category, preferredHardwareSampleRate, preferredIOBufferDuration; @synthesize inputIsAvailable, currentHardwareSampleRate, currentHardwareInputNumberOfChannels, currentHardwareOutputNumberOfChannels; + (id)sharedInstance { return nil; } - (BOOL)setActive:(BOOL)beActive error:(NSError**)outError {return YES;} - (BOOL)setActive:(BOOL)beActive withFlags:(NSInteger)flags error:(NSError**)outError {return YES;} - (BOOL)setCategory:(NSString*)theCategory error:(NSError**)outError {return YES;} - (BOOL)setPreferredHardwareSampleRate:(double)sampleRate error:(NSError**)outError {return YES;} - (BOOL)setPreferredIOBufferDuration:(NSTimeInterval)duration error:(NSError**)outError {return YES;} @end #endif ================================================ FILE: cocos2d/cocos/audio/mac/CocosDenshion.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ /** @file @b IMPORTANT There are 3 different ways of using CocosDenshion. Depending on which you choose you will need to include different files and frameworks. @par SimpleAudioEngine This is recommended for basic audio requirements. If you just want to play some sound fx and some background music and have no interest in learning the lower level workings then this is the interface to use. Requirements: - Firmware: OS 2.2 or greater - Files: SimpleAudioEngine.*, CocosDenshion.* - Frameworks: OpenAL, AudioToolbox, AVFoundation @par CDAudioManager CDAudioManager is basically a thin wrapper around an AVAudioPlayer object used for playing background music and a CDSoundEngine object used for playing sound effects. It manages the audio session for you deals with audio session interruption. It is fairly low level and it is expected you have some understanding of the underlying technologies. For example, for many use cases regarding background music it is expected you will work directly with the backgroundMusic AVAudioPlayer which is exposed as a property. Requirements: - Firmware: OS 2.2 or greater - Files: CDAudioManager.*, CocosDenshion.* - Frameworks: OpenAL, AudioToolbox, AVFoundation @par CDSoundEngine CDSoundEngine is a sound engine built upon OpenAL and derived from Apple's oalTouch example. It can playback up to 32 sounds simultaneously with control over pitch, pan and gain. It can be set up to handle audio session interruption automatically. You may decide to use CDSoundEngine directly instead of CDAudioManager or SimpleAudioEngine because you require OS 2.0 compatibility. Requirements: - Firmware: OS 2.0 or greater - Files: CocosDenshion.* - Frameworks: OpenAL, AudioToolbox */ #import #import #import #import #import "CDConfig.h" #if !defined(CD_DEBUG) || CD_DEBUG == 0 #define CDLOG(...) do {} while (0) #define CDLOGINFO(...) do {} while (0) #elif CD_DEBUG == 1 #define CDLOG(...) NSLog(__VA_ARGS__) #define CDLOGINFO(...) do {} while (0) #elif CD_DEBUG > 1 #define CDLOG(...) NSLog(__VA_ARGS__) #define CDLOGINFO(...) NSLog(__VA_ARGS__) #endif // CD_DEBUG #import "CDOpenALSupport.h" //Tested source limit on 2.2.1 and 3.1.2 with up to 128 sources and appears to work. Older OS versions e.g 2.2 may support only 32 #define CD_SOURCE_LIMIT 32 //Total number of sources we will ever want, may actually get less #define CD_NO_SOURCE 0xFEEDFAC //Return value indicating playback failed i.e. no source #define CD_IGNORE_AUDIO_SESSION 0xBEEFBEE //Used internally to indicate audio session will not be handled #define CD_MUTE 0xFEEDBAB //Return value indicating sound engine is muted or non functioning #define CD_NO_SOUND = -1; #define CD_SAMPLE_RATE_HIGH 44100 #define CD_SAMPLE_RATE_MID 22050 #define CD_SAMPLE_RATE_LOW 16000 #define CD_SAMPLE_RATE_BASIC 8000 #define CD_SAMPLE_RATE_DEFAULT 44100 extern NSString * const kCDN_BadAlContext; extern NSString * const kCDN_AsynchLoadComplete; extern float const kCD_PitchDefault; extern float const kCD_PitchLowerOneOctave; extern float const kCD_PitchHigherOneOctave; extern float const kCD_PanDefault; extern float const kCD_PanFullLeft; extern float const kCD_PanFullRight; extern float const kCD_GainDefault; enum bufferState { CD_BS_EMPTY = 0, CD_BS_LOADED = 1, CD_BS_FAILED = 2 }; typedef struct _sourceGroup { int startIndex; int currentIndex; int totalSources; bool enabled; bool nonInterruptible; int *sourceStatuses;//pointer into array of source status information } sourceGroup; typedef struct _bufferInfo { ALuint bufferId; int bufferState; void* bufferData; ALenum format; ALsizei sizeInBytes; ALsizei frequencyInHertz; } bufferInfo; typedef struct _sourceInfo { bool usable; ALuint sourceId; ALuint attachedBufferId; } sourceInfo; #pragma mark CDAudioTransportProtocol @protocol CDAudioTransportProtocol /** Play the audio */ -(BOOL) play; /** Pause the audio, retain resources */ -(BOOL) pause; /** Stop the audio, release resources */ -(BOOL) stop; /** Return playback to beginning */ -(BOOL) rewind; @end #pragma mark CDAudioInterruptProtocol @protocol CDAudioInterruptProtocol /** Is audio mute */ -(BOOL) mute; /** If YES then audio is silenced but not stopped, calls to start new audio will proceed but silently */ -(void) setMute:(BOOL) muteValue; /** Is audio enabled */ -(BOOL) enabled; /** If NO then all audio is stopped and any calls to start new audio will be ignored */ -(void) setEnabled:(BOOL) enabledValue; @end #pragma mark CDUtilities /** Collection of utilities required by CocosDenshion */ @interface CDUtilities : NSObject { } /** Fundamentally the same as the corresponding method is FileUtils but added to break binding to cocos2d */ +(NSString*) fullPathFromRelativePath:(NSString*) relPath; @end #pragma mark CDSoundEngine /** CDSoundEngine is built upon OpenAL and works with SDK 2.0. CDSoundEngine is a sound engine built upon OpenAL and derived from Apple's oalTouch example. It can playback up to 32 sounds simultaneously with control over pitch, pan and gain. It can be set up to handle audio session interruption automatically. You may decide to use CDSoundEngine directly instead of CDAudioManager or SimpleAudioEngine because you require OS 2.0 compatibility. Requirements: - Firmware: OS 2.0 or greater - Files: CocosDenshion.* - Frameworks: OpenAL, AudioToolbox @since v0.8 */ @class CDSoundSource; @interface CDSoundEngine : NSObject { bufferInfo *_buffers; sourceInfo *_sources; sourceGroup *_sourceGroups; ALCcontext *context; NSUInteger _sourceGroupTotal; UInt32 _audioSessionCategory; BOOL _handleAudioSession; ALfloat _preMuteGain; NSObject *_mutexBufferLoad; BOOL mute_; BOOL enabled_; ALenum lastErrorCode_; BOOL functioning_; float asynchLoadProgress_; BOOL getGainWorks_; //For managing dynamic allocation of sources and buffers int sourceTotal_; int bufferTotal; } @property (readwrite, nonatomic) ALfloat masterGain; @property (readonly) ALenum lastErrorCode;//Last OpenAL error code that was generated @property (readonly) BOOL functioning;//Is the sound engine functioning @property (readwrite) float asynchLoadProgress; @property (readonly) BOOL getGainWorks;//Does getting the gain for a source work /** Total number of sources available */ @property (readonly) int sourceTotal; /** Total number of source groups that have been defined */ @property (readonly) NSUInteger sourceGroupTotal; /** Sets the sample rate for the audio mixer. For best performance this should match the sample rate of your audio content */ +(void) setMixerSampleRate:(Float32) sampleRate; /** Initializes the engine with a group definition and a total number of groups */ -(id)init; /** Plays a sound in a channel group with a pitch, pan and gain. The sound could played looped or not */ -(ALuint) playSound:(int) soundId sourceGroupId:(int)sourceGroupId pitch:(float) pitch pan:(float) pan gain:(float) gain loop:(BOOL) loop; /** Creates and returns a sound source object for the specified sound within the specified source group. */ -(CDSoundSource *) soundSourceForSound:(int) soundId sourceGroupId:(int) sourceGroupId; /** Stops playing a sound */ - (void) stopSound:(ALuint) sourceId; /** Stops playing a source group */ - (void) stopSourceGroup:(int) sourceGroupId; /** Stops all playing sounds */ -(void) stopAllSounds; /** Pause a sound */ -(void) pauseSound:(ALuint) sourceId; /** Pause all sounds */ -(void) pauseAllSounds; /** Resume a sound */ -(void) resumeSound:(ALuint) sourceId; /** Resume all sounds */ -(void) resumeAllSounds; -(void) defineSourceGroups:(NSArray*) sourceGroupDefinitions; -(void) defineSourceGroups:(int[]) sourceGroupDefinitions total:(NSUInteger) total; -(void) setSourceGroupNonInterruptible:(int) sourceGroupId isNonInterruptible:(BOOL) isNonInterruptible; -(void) setSourceGroupEnabled:(int) sourceGroupId enabled:(BOOL) enabled; -(BOOL) sourceGroupEnabled:(int) sourceGroupId; -(BOOL) loadBufferFromData:(int) soundId soundData:(ALvoid*) soundData format:(ALenum) format size:(ALsizei) size freq:(ALsizei) freq; -(BOOL) loadBuffer:(int) soundId filePath:(NSString*) filePath; -(void) loadBuffersAsynchronously:(NSArray *) loadRequests; -(BOOL) unloadBuffer:(int) soundId; -(ALCcontext *) openALContext; /** Returns the duration of the buffer in seconds or a negative value if the buffer id is invalid */ -(float) bufferDurationInSeconds:(int) soundId; /** Returns the size of the buffer in bytes or a negative value if the buffer id is invalid */ -(ALsizei) bufferSizeInBytes:(int) soundId; /** Returns the sampling frequency of the buffer in hertz or a negative value if the buffer id is invalid */ -(ALsizei) bufferFrequencyInHertz:(int) soundId; /** Used internally, never call unless you know what you are doing */ -(void) _soundSourcePreRelease:(CDSoundSource *) soundSource; @end #pragma mark CDSoundSource /** CDSoundSource is a wrapper around an OpenAL sound source. It allows you to manipulate properties such as pitch, gain, pan and looping while the sound is playing. CDSoundSource is based on the old CDSourceWrapper class but with much added functionality. @since v1.0 */ @interface CDSoundSource : NSObject { ALenum lastError; @public ALuint _sourceId; ALuint _sourceIndex; CDSoundEngine* _engine; int _soundId; float _preMuteGain; BOOL enabled_; BOOL mute_; } @property (readwrite, nonatomic) float pitch; @property (readwrite, nonatomic) float gain; @property (readwrite, nonatomic) float pan; @property (readwrite, nonatomic) BOOL looping; @property (readonly) BOOL isPlaying; @property (readwrite, nonatomic) int soundId; /** Returns the duration of the attached buffer in seconds or a negative value if the buffer is invalid */ @property (readonly) float durationInSeconds; /** Stores the last error code that occurred. Check against AL_NO_ERROR */ @property (readonly) ALenum lastError; /** Do not init yourself, get an instance from the sourceForSound factory method on CDSoundEngine */ -(id)init:(ALuint) theSourceId sourceIndex:(int) index soundEngine:(CDSoundEngine*) engine; @end #pragma mark CDAudioInterruptTargetGroup /** Container for objects that implement audio interrupt protocol i.e. they can be muted and enabled. Setting mute and enabled for the group propagates to all children. Designed to be used with your CDSoundSource objects to get them to comply with global enabled and mute settings if that is what you want to do.*/ @interface CDAudioInterruptTargetGroup : NSObject { BOOL mute_; BOOL enabled_; NSMutableArray *children_; } -(void) addAudioInterruptTarget:(NSObject*) interruptibleTarget; @end #pragma mark CDAsynchBufferLoader /** CDAsynchBufferLoader TODO */ @interface CDAsynchBufferLoader : NSOperation { NSArray *_loadRequests; CDSoundEngine *_soundEngine; } -(id) init:(NSArray *)loadRequests soundEngine:(CDSoundEngine *) theSoundEngine; @end #pragma mark CDBufferLoadRequest /** CDBufferLoadRequest */ @interface CDBufferLoadRequest: NSObject { NSString *filePath; int soundId; //id loader; } @property (readonly) NSString *filePath; @property (readonly) int soundId; - (id)init:(int) theSoundId filePath:(const NSString *) theFilePath; @end /** Interpolation type */ typedef enum { kIT_Linear, //!Straight linear interpolation fade kIT_SCurve, //!S curved interpolation kIT_Exponential //!Exponential interpolation } tCDInterpolationType; #pragma mark CDFloatInterpolator @interface CDFloatInterpolator: NSObject { float start; float end; float lastValue; tCDInterpolationType interpolationType; } @property (readwrite, nonatomic) float start; @property (readwrite, nonatomic) float end; @property (readwrite, nonatomic) tCDInterpolationType interpolationType; /** Return a value between min and max based on t which represents fractional progress where 0 is the start and 1 is the end */ -(float) interpolate:(float) t; -(id) init:(tCDInterpolationType) type startVal:(float) startVal endVal:(float) endVal; @end #pragma mark CDPropertyModifier /** Base class for classes that modify properties such as pitch, pan and gain */ @interface CDPropertyModifier: NSObject { CDFloatInterpolator *interpolator; float startValue; float endValue; id target; BOOL stopTargetWhenComplete; } @property (readwrite, nonatomic) BOOL stopTargetWhenComplete; @property (readwrite, nonatomic) float startValue; @property (readwrite, nonatomic) float endValue; @property (readwrite, nonatomic) tCDInterpolationType interpolationType; -(id) init:(id) theTarget interpolationType:(tCDInterpolationType) type startVal:(float) startVal endVal:(float) endVal; /** Set to a fractional value between 0 and 1 where 0 equals the start and 1 equals the end*/ -(void) modify:(float) t; -(void) _setTargetProperty:(float) newVal; -(float) _getTargetProperty; -(void) _stopTarget; -(Class) _allowableType; @end #pragma mark CDSoundSourceFader /** Fader for CDSoundSource objects */ @interface CDSoundSourceFader : CDPropertyModifier{} @end #pragma mark CDSoundSourcePanner /** Panner for CDSoundSource objects */ @interface CDSoundSourcePanner : CDPropertyModifier{} @end #pragma mark CDSoundSourcePitchBender /** Pitch bender for CDSoundSource objects */ @interface CDSoundSourcePitchBender : CDPropertyModifier{} @end #pragma mark CDSoundEngineFader /** Fader for CDSoundEngine objects */ @interface CDSoundEngineFader : CDPropertyModifier{} @end ================================================ FILE: cocos2d/cocos/audio/mac/CocosDenshion.m ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "CocosDenshion.h" ALvoid alBufferDataStaticProc(const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq); ALvoid alcMacOSXMixerOutputRateProc(const ALdouble value); typedef ALvoid AL_APIENTRY (*alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq); ALvoid alBufferDataStaticProc(const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq) { static alBufferDataStaticProcPtr proc = NULL; if (proc == NULL) { proc = (alBufferDataStaticProcPtr) alcGetProcAddress(NULL, (const ALCchar*) "alBufferDataStatic"); } if (proc) proc(bid, format, data, size, freq); return; } typedef ALvoid AL_APIENTRY (*alcMacOSXMixerOutputRateProcPtr) (const ALdouble value); ALvoid alcMacOSXMixerOutputRateProc(const ALdouble value) { static alcMacOSXMixerOutputRateProcPtr proc = NULL; if (proc == NULL) { proc = (alcMacOSXMixerOutputRateProcPtr) alcGetProcAddress(NULL, (const ALCchar*) "alcMacOSXMixerOutputRate"); } if (proc) proc(value); return; } NSString * const kCDN_BadAlContext = @"kCDN_BadAlContext"; NSString * const kCDN_AsynchLoadComplete = @"kCDN_AsynchLoadComplete"; float const kCD_PitchDefault = 1.0f; float const kCD_PitchLowerOneOctave = 0.5f; float const kCD_PitchHigherOneOctave = 2.0f; float const kCD_PanDefault = 0.0f; float const kCD_PanFullLeft = -1.0f; float const kCD_PanFullRight = 1.0f; float const kCD_GainDefault = 1.0f; @interface CDSoundEngine (PrivateMethods) -(BOOL) _initOpenAL; -(void) _testGetGain; -(void) _dumpSourceGroupsInfo; -(void) _getSourceIndexForSourceGroup; -(void) _freeSourceGroups; -(BOOL) _setUpSourceGroups:(int[]) definitions total:(NSUInteger) total; @end #pragma mark - #pragma mark CDUtilities @implementation CDUtilities +(NSString*) fullPathFromRelativePath:(NSString*) relPath { // do not convert an absolute path (starting with '/') if(([relPath length] > 0) && ([relPath characterAtIndex:0] == '/')) { return relPath; } NSMutableArray *imagePathComponents = [NSMutableArray arrayWithArray:[relPath pathComponents]]; NSString *file = [imagePathComponents lastObject]; [imagePathComponents removeLastObject]; NSString *imageDirectory = [NSString pathWithComponents:imagePathComponents]; NSString *fullpath = [[NSBundle mainBundle] pathForResource:file ofType:nil inDirectory:imageDirectory]; if (fullpath == nil) fullpath = relPath; return fullpath; } @end #pragma mark - #pragma mark CDSoundEngine @implementation CDSoundEngine static Float32 _mixerSampleRate; static BOOL _mixerRateSet = NO; @synthesize lastErrorCode = lastErrorCode_; @synthesize functioning = functioning_; @synthesize asynchLoadProgress = asynchLoadProgress_; @synthesize getGainWorks = getGainWorks_; @synthesize sourceTotal = sourceTotal_; + (void) setMixerSampleRate:(Float32) sampleRate { _mixerRateSet = YES; _mixerSampleRate = sampleRate; } - (void) _testGetGain { float testValue = 0.7f; ALuint testSourceId = _sources[0].sourceId; alSourcef(testSourceId, AL_GAIN, 0.0f);//Start from know value alSourcef(testSourceId, AL_GAIN, testValue); ALfloat gainVal; alGetSourcef(testSourceId, AL_GAIN, &gainVal); getGainWorks_ = (gainVal == testValue); } //Generate sources one at a time until we fail -(void) _generateSources { _sources = (sourceInfo*)malloc( sizeof(_sources[0]) * CD_SOURCE_LIMIT); BOOL hasFailed = NO; sourceTotal_ = 0; alGetError();//Clear error while (!hasFailed && sourceTotal_ < CD_SOURCE_LIMIT) { alGenSources(1, &(_sources[sourceTotal_].sourceId)); if (alGetError() == AL_NO_ERROR) { //Now try attaching source to null buffer alSourcei(_sources[sourceTotal_].sourceId, AL_BUFFER, 0); if (alGetError() == AL_NO_ERROR) { _sources[sourceTotal_].usable = true; sourceTotal_++; } else { hasFailed = YES; } } else { _sources[sourceTotal_].usable = false; hasFailed = YES; } } //Mark the rest of the sources as not usable for (int i=sourceTotal_; i < CD_SOURCE_LIMIT; i++) { _sources[i].usable = false; } } -(void) _generateBuffers:(int) startIndex endIndex:(int) endIndex { if (_buffers) { alGetError(); for (int i=startIndex; i <= endIndex; i++) { alGenBuffers(1, &_buffers[i].bufferId); _buffers[i].bufferData = NULL; if (alGetError() == AL_NO_ERROR) { _buffers[i].bufferState = CD_BS_EMPTY; } else { _buffers[i].bufferState = CD_BS_FAILED; CDLOG(@"Denshion::CDSoundEngine - buffer creation failed %i",i); } } } } /** * Internal method called during init */ - (BOOL) _initOpenAL { //ALenum error; context = NULL; ALCdevice *newDevice = NULL; //Set the mixer rate for the audio mixer if (!_mixerRateSet) { _mixerSampleRate = CD_SAMPLE_RATE_DEFAULT; } alcMacOSXMixerOutputRateProc(_mixerSampleRate); CDLOGINFO(@"Denshion::CDSoundEngine - mixer output rate set to %0.2f",_mixerSampleRate); // Create a new OpenAL Device // Pass NULL to specify the system's default output device newDevice = alcOpenDevice(NULL); if (newDevice != NULL) { // Create a new OpenAL Context // The new context will render to the OpenAL Device just created context = alcCreateContext(newDevice, 0); if (context != NULL) { // Make the new context the Current OpenAL Context alcMakeContextCurrent(context); // Create some OpenAL Buffer Objects [self _generateBuffers:0 endIndex:bufferTotal-1]; // Create some OpenAL Source Objects [self _generateSources]; } } else { return FALSE;//No device } alGetError();//Clear error return TRUE; } - (void) dealloc { ALCcontext *currentContext = NULL; ALCdevice *device = NULL; [self stopAllSounds]; CDLOGINFO(@"Denshion::CDSoundEngine - Deallocing sound engine."); [self _freeSourceGroups]; // Delete the Sources CDLOGINFO(@"Denshion::CDSoundEngine - deleting sources."); for (int i=0; i < sourceTotal_; i++) { alSourcei(_sources[i].sourceId, AL_BUFFER, 0);//Detach from current buffer alDeleteSources(1, &(_sources[i].sourceId)); if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - Error deleting source! %x\n", lastErrorCode_); } } // Delete the Buffers CDLOGINFO(@"Denshion::CDSoundEngine - deleting buffers."); for (int i=0; i < bufferTotal; i++) { alDeleteBuffers(1, &_buffers[i].bufferId); #ifdef CD_USE_STATIC_BUFFERS if (_buffers[i].bufferData) { free(_buffers[i].bufferData); } #endif } CDLOGINFO(@"Denshion::CDSoundEngine - free buffers."); free(_buffers); currentContext = alcGetCurrentContext(); //Get device for active context device = alcGetContextsDevice(currentContext); //Release context CDLOGINFO(@"Denshion::CDSoundEngine - destroy context."); alcMakeContextCurrent(NULL); alcDestroyContext(currentContext); //Close device CDLOGINFO(@"Denshion::CDSoundEngine - close device."); alcCloseDevice(device); CDLOGINFO(@"Denshion::CDSoundEngine - free sources."); free(_sources); //Release mutexes [_mutexBufferLoad release]; [super dealloc]; } -(NSUInteger) sourceGroupTotal { return _sourceGroupTotal; } -(void) _freeSourceGroups { CDLOGINFO(@"Denshion::CDSoundEngine freeing source groups"); if(_sourceGroups) { for (int i=0; i < _sourceGroupTotal; i++) { if (_sourceGroups[i].sourceStatuses) { free(_sourceGroups[i].sourceStatuses); CDLOGINFO(@"Denshion::CDSoundEngine freed source statuses %i",i); } } free(_sourceGroups); } } -(BOOL) _redefineSourceGroups:(int[]) definitions total:(NSUInteger) total { if (_sourceGroups) { //Stop all sounds [self stopAllSounds]; //Need to free source groups [self _freeSourceGroups]; } return [self _setUpSourceGroups:definitions total:total]; } -(BOOL) _setUpSourceGroups:(int[]) definitions total:(NSUInteger) total { _sourceGroups = (sourceGroup *)malloc( sizeof(_sourceGroups[0]) * total); if(!_sourceGroups) { CDLOG(@"Denshion::CDSoundEngine - source groups memory allocation failed"); return NO; } _sourceGroupTotal = total; int sourceCount = 0; for (int i=0; i < _sourceGroupTotal; i++) { _sourceGroups[i].startIndex = 0; _sourceGroups[i].currentIndex = _sourceGroups[i].startIndex; _sourceGroups[i].enabled = false; _sourceGroups[i].nonInterruptible = false; _sourceGroups[i].totalSources = definitions[i]; _sourceGroups[i].sourceStatuses = malloc(sizeof(_sourceGroups[i].sourceStatuses[0]) * _sourceGroups[i].totalSources); if (_sourceGroups[i].sourceStatuses) { for (int j=0; j < _sourceGroups[i].totalSources; j++) { //First bit is used to indicate whether source is locked, index is shifted back 1 bit _sourceGroups[i].sourceStatuses[j] = (sourceCount + j) << 1; } } sourceCount += definitions[i]; } return YES; } -(void) defineSourceGroups:(int[]) sourceGroupDefinitions total:(NSUInteger) total { [self _redefineSourceGroups:sourceGroupDefinitions total:total]; } -(void) defineSourceGroups:(NSArray*) sourceGroupDefinitions { CDLOGINFO(@"Denshion::CDSoundEngine - source groups defined by NSArray."); NSUInteger totalDefs = [sourceGroupDefinitions count]; int* defs = (int *)malloc( sizeof(int) * totalDefs); int currentIndex = 0; for (id currentDef in sourceGroupDefinitions) { if ([currentDef isKindOfClass:[NSNumber class]]) { defs[currentIndex] = (int)[(NSNumber*)currentDef integerValue]; CDLOGINFO(@"Denshion::CDSoundEngine - found definition %i.",defs[currentIndex]); } else { CDLOG(@"Denshion::CDSoundEngine - warning, did not understand source definition."); defs[currentIndex] = 0; } currentIndex++; } [self _redefineSourceGroups:defs total:totalDefs]; free(defs); } - (id)init { if ((self = [super init])) { //Create mutexes _mutexBufferLoad = [[NSObject alloc] init]; asynchLoadProgress_ = 0.0f; bufferTotal = CD_BUFFERS_START; _buffers = (bufferInfo *)malloc( sizeof(_buffers[0]) * bufferTotal); // Initialize our OpenAL environment if ([self _initOpenAL]) { //Set up the default source group - a single group that contains all the sources int sourceDefs[1]; sourceDefs[0] = self.sourceTotal; [self _setUpSourceGroups:sourceDefs total:1]; functioning_ = YES; //Synchronize premute gain _preMuteGain = self.masterGain; mute_ = NO; enabled_ = YES; //Test whether get gain works for sources [self _testGetGain]; } else { //Something went wrong with OpenAL functioning_ = NO; } } return self; } /** * Delete the buffer identified by soundId * @return true if buffer deleted successfully, otherwise false */ - (BOOL) unloadBuffer:(int) soundId { //Ensure soundId is within array bounds otherwise memory corruption will occur if (soundId < 0 || soundId >= bufferTotal) { CDLOG(@"Denshion::CDSoundEngine - soundId is outside array bounds, maybe you need to increase CD_MAX_BUFFERS"); return FALSE; } //Before a buffer can be deleted any sources that are attached to it must be stopped for (int i=0; i < sourceTotal_; i++) { //Note: tried getting the AL_BUFFER attribute of the source instead but doesn't //appear to work on a device - just returned zero. if (_buffers[soundId].bufferId == _sources[i].attachedBufferId) { CDLOG(@"Denshion::CDSoundEngine - Found attached source %i %i %i",i,_buffers[soundId].bufferId,_sources[i].sourceId); #ifdef CD_USE_STATIC_BUFFERS //When using static buffers a crash may occur if a source is playing with a buffer that is about //to be deleted even though we stop the source and successfully delete the buffer. Crash is confirmed //on 2.2.1 and 3.1.2, however, it will only occur if a source is used rapidly after having its prior //data deleted. To avoid any possibility of the crash we wait for the source to finish playing. ALint state; alGetSourcei(_sources[i].sourceId, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) { CDLOG(@"Denshion::CDSoundEngine - waiting for source to complete playing before removing buffer data"); alSourcei(_sources[i].sourceId, AL_LOOPING, FALSE);//Turn off looping otherwise loops will never end while (state == AL_PLAYING) { alGetSourcei(_sources[i].sourceId, AL_SOURCE_STATE, &state); usleep(10000); } } #endif //Stop source and detach alSourceStop(_sources[i].sourceId); if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error stopping source: %x\n", lastErrorCode_); } alSourcei(_sources[i].sourceId, AL_BUFFER, 0);//Attach to "NULL" buffer to detach if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error detaching buffer: %x\n", lastErrorCode_); } else { //Record that source is now attached to nothing _sources[i].attachedBufferId = 0; } } } alDeleteBuffers(1, &_buffers[soundId].bufferId); if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error deleting buffer: %x\n", lastErrorCode_); _buffers[soundId].bufferState = CD_BS_FAILED; return FALSE; } else { #ifdef CD_USE_STATIC_BUFFERS //Free previous data, if alDeleteBuffer has returned without error then no if (_buffers[soundId].bufferData) { CDLOGINFO(@"Denshion::CDSoundEngine - freeing static data for soundId %i @ %i",soundId,_buffers[soundId].bufferData); free(_buffers[soundId].bufferData);//Free the old data _buffers[soundId].bufferData = NULL; } #endif } alGenBuffers(1, &_buffers[soundId].bufferId); if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error regenerating buffer: %x\n", lastErrorCode_); _buffers[soundId].bufferState = CD_BS_FAILED; return FALSE; } else { //We now have an empty buffer _buffers[soundId].bufferState = CD_BS_EMPTY; CDLOGINFO(@"Denshion::CDSoundEngine - buffer %i successfully unloaded\n",soundId); return TRUE; } } /** * Load buffers asynchronously * Check asynchLoadProgress for progress. asynchLoadProgress represents fraction of completion. When it equals 1.0 loading * is complete. NB: asynchLoadProgress is simply based on the number of load requests, it does not take into account * file sizes. * @param An array of CDBufferLoadRequest objects */ - (void) loadBuffersAsynchronously:(NSArray *) loadRequests { @synchronized(self) { asynchLoadProgress_ = 0.0f; CDAsynchBufferLoader *loaderOp = [[[CDAsynchBufferLoader alloc] init:loadRequests soundEngine:self] autorelease]; NSOperationQueue *opQ = [[[NSOperationQueue alloc] init] autorelease]; [opQ addOperation:loaderOp]; } } -(BOOL) _resizeBuffers:(int) increment { void * tmpBufferInfos = realloc( _buffers, sizeof(_buffers[0]) * (bufferTotal + increment) ); if(!tmpBufferInfos) { free(tmpBufferInfos); return NO; } else { _buffers = tmpBufferInfos; int oldBufferTotal = bufferTotal; bufferTotal = bufferTotal + increment; [self _generateBuffers:oldBufferTotal endIndex:bufferTotal-1]; return YES; } } -(BOOL) loadBufferFromData:(int) soundId soundData:(ALvoid*) soundData format:(ALenum) format size:(ALsizei) size freq:(ALsizei) freq { @synchronized(_mutexBufferLoad) { if (!functioning_) { //OpenAL initialisation has previously failed CDLOG(@"Denshion::CDSoundEngine - Loading buffer failed because sound engine state != functioning"); return FALSE; } //Ensure soundId is within array bounds otherwise memory corruption will occur if (soundId < 0) { CDLOG(@"Denshion::CDSoundEngine - soundId is negative"); return FALSE; } if (soundId >= bufferTotal) { //Need to resize the buffers int requiredIncrement = CD_BUFFERS_INCREMENT; while (bufferTotal + requiredIncrement < soundId) { requiredIncrement += CD_BUFFERS_INCREMENT; } CDLOGINFO(@"Denshion::CDSoundEngine - attempting to resize buffers by %i for sound %i",requiredIncrement,soundId); if (![self _resizeBuffers:requiredIncrement]) { CDLOG(@"Denshion::CDSoundEngine - buffer resize failed"); return FALSE; } } if (soundData) { if (_buffers[soundId].bufferState != CD_BS_EMPTY) { CDLOGINFO(@"Denshion::CDSoundEngine - non empty buffer, regenerating"); if (![self unloadBuffer:soundId]) { //Deletion of buffer failed, delete buffer routine has set buffer state and lastErrorCode return NO; } } #ifdef CD_DEBUG //Check that sample rate matches mixer rate and warn if they do not if (freq != (int)_mixerSampleRate) { CDLOGINFO(@"Denshion::CDSoundEngine - WARNING sample rate does not match mixer sample rate performance may not be optimal."); } #endif #ifdef CD_USE_STATIC_BUFFERS alBufferDataStaticProc(_buffers[soundId].bufferId, format, soundData, size, freq); _buffers[soundId].bufferData = data;//Save the pointer to the new data #else alBufferData(_buffers[soundId].bufferId, format, soundData, size, freq); #endif if((lastErrorCode_ = alGetError()) != AL_NO_ERROR) { CDLOG(@"Denshion::CDSoundEngine - error attaching audio to buffer: %x", lastErrorCode_); _buffers[soundId].bufferState = CD_BS_FAILED; return FALSE; } } else { CDLOG(@"Denshion::CDSoundEngine Buffer data is null!"); _buffers[soundId].bufferState = CD_BS_FAILED; return FALSE; } _buffers[soundId].format = format; _buffers[soundId].sizeInBytes = size; _buffers[soundId].frequencyInHertz = freq; _buffers[soundId].bufferState = CD_BS_LOADED; CDLOGINFO(@"Denshion::CDSoundEngine Buffer %i loaded format:%i freq:%i size:%i",soundId,format,freq,size); return TRUE; }//end mutex } /** * Load sound data for later play back. * @return TRUE if buffer loaded okay for play back otherwise false */ - (BOOL) loadBuffer:(int) soundId filePath:(NSString*) filePath { ALvoid* data; ALenum format; ALsizei size; ALsizei freq; CDLOGINFO(@"Denshion::CDSoundEngine - Loading openAL buffer %i %@", soundId, filePath); CFURLRef fileURL = nil; NSString *path = [CDUtilities fullPathFromRelativePath:filePath]; if (path) { fileURL = (CFURLRef)[[NSURL fileURLWithPath:path] retain]; } if (fileURL) { data = CDGetOpenALAudioData(fileURL, &size, &format, &freq); CFRelease(fileURL); BOOL result = [self loadBufferFromData:soundId soundData:data format:format size:size freq:freq]; #ifndef CD_USE_STATIC_BUFFERS free(data);//Data can be freed here because alBufferData performs a memcpy #endif return result; } else { CDLOG(@"Denshion::CDSoundEngine Could not find file!\n"); //Don't change buffer state here as it will be the same as before method was called return FALSE; } } -(BOOL) validateBufferId:(int) soundId { if (soundId < 0 || soundId >= bufferTotal) { CDLOGINFO(@"Denshion::CDSoundEngine - validateBufferId buffer outside range %i",soundId); return NO; } else if (_buffers[soundId].bufferState != CD_BS_LOADED) { CDLOGINFO(@"Denshion::CDSoundEngine - validateBufferId invalide buffer state %i",soundId); return NO; } else { return YES; } } -(float) bufferDurationInSeconds:(int) soundId { if ([self validateBufferId:soundId]) { float factor = 0.0f; switch (_buffers[soundId].format) { case AL_FORMAT_MONO8: factor = 1.0f; break; case AL_FORMAT_MONO16: factor = 0.5f; break; case AL_FORMAT_STEREO8: factor = 0.5f; break; case AL_FORMAT_STEREO16: factor = 0.25f; break; } return (float)_buffers[soundId].sizeInBytes/(float)_buffers[soundId].frequencyInHertz * factor; } else { return -1.0f; } } -(ALsizei) bufferSizeInBytes:(int) soundId { if ([self validateBufferId:soundId]) { return _buffers[soundId].sizeInBytes; } else { return -1.0f; } } -(ALsizei) bufferFrequencyInHertz:(int) soundId { if ([self validateBufferId:soundId]) { return _buffers[soundId].frequencyInHertz; } else { return -1.0f; } } - (ALfloat) masterGain { if (mute_) { //When mute the real gain will always be 0 therefore return the preMuteGain value return _preMuteGain; } else { ALfloat gain; alGetListenerf(AL_GAIN, &gain); return gain; } } /** * Overall gain setting multiplier. e.g 0.5 is half the gain. */ - (void) setMasterGain:(ALfloat) newGainValue { if (mute_) { _preMuteGain = newGainValue; } else { alListenerf(AL_GAIN, newGainValue); } } #pragma mark CDSoundEngine AudioInterrupt protocol - (BOOL) mute { return mute_; } /** * Setting mute silences all sounds but playing sounds continue to advance playback */ - (void) setMute:(BOOL) newMuteValue { if (newMuteValue == mute_) { return; } mute_ = newMuteValue; if (mute_) { //Remember what the gain was _preMuteGain = self.masterGain; //Set gain to 0 - do not use the property as this will adjust preMuteGain when muted alListenerf(AL_GAIN, 0.0f); } else { //Restore gain to what it was before being muted self.masterGain = _preMuteGain; } } - (BOOL) enabled { return enabled_; } - (void) setEnabled:(BOOL)enabledValue { if (enabled_ == enabledValue) { return; } enabled_ = enabledValue; if (enabled_ == NO) { [self stopAllSounds]; } } -(void) _lockSource:(int) sourceIndex lock:(BOOL) lock { BOOL found = NO; for (int i=0; i < _sourceGroupTotal && !found; i++) { if (_sourceGroups[i].sourceStatuses) { for (int j=0; j < _sourceGroups[i].totalSources && !found; j++) { //First bit is used to indicate whether source is locked, index is shifted back 1 bit if((_sourceGroups[i].sourceStatuses[j] >> 1)==sourceIndex) { if (lock) { //Set first bit to lock this source _sourceGroups[i].sourceStatuses[j] |= 1; } else { //Unset first bit to unlock this source _sourceGroups[i].sourceStatuses[j] &= ~1; } found = YES; } } } } } -(int) _getSourceIndexForSourceGroup:(int)sourceGroupId { //Ensure source group id is valid to prevent memory corruption if (sourceGroupId < 0 || sourceGroupId >= _sourceGroupTotal) { CDLOG(@"Denshion::CDSoundEngine invalid source group id %i",sourceGroupId); return CD_NO_SOURCE; } int sourceIndex = -1;//Using -1 to indicate no source found BOOL complete = NO; ALint sourceState = 0; sourceGroup *thisSourceGroup = &_sourceGroups[sourceGroupId]; thisSourceGroup->currentIndex = thisSourceGroup->startIndex; while (!complete) { //Iterate over sources looking for one that is not locked, first bit indicates if source is locked if ((thisSourceGroup->sourceStatuses[thisSourceGroup->currentIndex] & 1) == 0) { //This source is not locked sourceIndex = thisSourceGroup->sourceStatuses[thisSourceGroup->currentIndex] >> 1;//shift back to get the index if (thisSourceGroup->nonInterruptible) { //Check if this source is playing, if so it can't be interrupted alGetSourcei(_sources[sourceIndex].sourceId, AL_SOURCE_STATE, &sourceState); if (sourceState != AL_PLAYING) { //complete = YES; //Set start index so next search starts at the next position thisSourceGroup->startIndex = thisSourceGroup->currentIndex + 1; break; } else { sourceIndex = -1;//The source index was no good because the source was playing } } else { //complete = YES; //Set start index so next search starts at the next position thisSourceGroup->startIndex = thisSourceGroup->currentIndex + 1; break; } } thisSourceGroup->currentIndex++; if (thisSourceGroup->currentIndex >= thisSourceGroup->totalSources) { //Reset to the beginning thisSourceGroup->currentIndex = 0; } if (thisSourceGroup->currentIndex == thisSourceGroup->startIndex) { //We have looped around and got back to the start complete = YES; } } //Reset start index to beginning if beyond bounds if (thisSourceGroup->startIndex >= thisSourceGroup->totalSources) { thisSourceGroup->startIndex = 0; } if (sourceIndex >= 0) { return sourceIndex; } else { return CD_NO_SOURCE; } } /** * Play a sound. * @param soundId the id of the sound to play (buffer id). * @param SourceGroupId the source group that will be used to play the sound. * @param pitch pitch multiplier. e.g 1.0 is unaltered, 0.5 is 1 octave lower. * @param pan stereo position. -1 is fully left, 0 is centre and 1 is fully right. * @param gain gain multiplier. e.g. 1.0 is unaltered, 0.5 is half the gain * @param loop should the sound be looped or one shot. * @return the id of the source being used to play the sound or CD_MUTE if the sound engine is muted or non functioning * or CD_NO_SOURCE if a problem occurs setting up the source * */ - (ALuint)playSound:(int) soundId sourceGroupId:(int)sourceGroupId pitch:(float) pitch pan:(float) pan gain:(float) gain loop:(BOOL) loop { #ifdef CD_DEBUG //Sanity check parameters - only in DEBUG NSAssert(soundId >= 0, @"soundId can not be negative"); NSAssert(soundId < bufferTotal, @"soundId exceeds limit"); NSAssert(sourceGroupId >= 0, @"sourceGroupId can not be negative"); NSAssert(sourceGroupId < _sourceGroupTotal, @"sourceGroupId exceeds limit"); NSAssert(pitch > 0, @"pitch must be greater than zero"); NSAssert(pan >= -1 && pan <= 1, @"pan must be between -1 and 1"); NSAssert(gain >= 0, @"gain can not be negative"); #endif //If mute or initialisation has failed or buffer is not loaded then do nothing if (!enabled_ || !functioning_ || _buffers[soundId].bufferState != CD_BS_LOADED || _sourceGroups[sourceGroupId].enabled) { #ifdef CD_DEBUG if (!functioning_) { CDLOGINFO(@"Denshion::CDSoundEngine - sound playback aborted because sound engine is not functioning"); } else if (_buffers[soundId].bufferState != CD_BS_LOADED) { CDLOGINFO(@"Denshion::CDSoundEngine - sound playback aborted because buffer %i is not loaded", soundId); } #endif return CD_MUTE; } int sourceIndex = [self _getSourceIndexForSourceGroup:sourceGroupId];//This method ensures sourceIndex is valid if (sourceIndex != CD_NO_SOURCE) { ALint state; ALuint source = _sources[sourceIndex].sourceId; ALuint buffer = _buffers[soundId].bufferId; alGetError();//Clear the error code alGetSourcei(source, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) { alSourceStop(source); } alSourcei(source, AL_BUFFER, buffer);//Attach to sound alSourcef(source, AL_PITCH, pitch);//Set pitch alSourcei(source, AL_LOOPING, loop);//Set looping alSourcef(source, AL_GAIN, gain);//Set gain/volume float sourcePosAL[] = {pan, 0.0f, 0.0f};//Set position - just using left and right panning alSourcefv(source, AL_POSITION, sourcePosAL); alGetError();//Clear the error code alSourcePlay(source); if((lastErrorCode_ = alGetError()) == AL_NO_ERROR) { //Everything was okay _sources[sourceIndex].attachedBufferId = buffer; return source; } else { if (alcGetCurrentContext() == NULL) { CDLOGINFO(@"Denshion::CDSoundEngine - posting bad OpenAL context message"); [[NSNotificationCenter defaultCenter] postNotificationName:kCDN_BadAlContext object:nil]; } return CD_NO_SOURCE; } } else { return CD_NO_SOURCE; } } -(BOOL) _soundSourceAttachToBuffer:(CDSoundSource*) soundSource soundId:(int) soundId { //Attach the source to the buffer ALint state; ALuint source = soundSource->_sourceId; ALuint buffer = _buffers[soundId].bufferId; alGetSourcei(source, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) { alSourceStop(source); } alGetError();//Clear the error code alSourcei(source, AL_BUFFER, buffer);//Attach to sound data if((lastErrorCode_ = alGetError()) == AL_NO_ERROR) { _sources[soundSource->_sourceIndex].attachedBufferId = buffer; //_sourceBufferAttachments[soundSource->_sourceIndex] = buffer;//Keep track of which soundSource->_soundId = soundId; return YES; } else { return NO; } } /** * Get a sound source for the specified sound in the specified source group */ -(CDSoundSource *) soundSourceForSound:(int) soundId sourceGroupId:(int) sourceGroupId { if (!functioning_) { return nil; } //Check if a source is available int sourceIndex = [self _getSourceIndexForSourceGroup:sourceGroupId]; if (sourceIndex != CD_NO_SOURCE) { CDSoundSource *result = [[CDSoundSource alloc] init:_sources[sourceIndex].sourceId sourceIndex:sourceIndex soundEngine:self]; [self _lockSource:sourceIndex lock:YES]; //Try to attach to the buffer if ([self _soundSourceAttachToBuffer:result soundId:soundId]) { //Set to a known state result.pitch = 1.0f; result.pan = 0.0f; result.gain = 1.0f; result.looping = NO; return [result autorelease]; } else { //Release the sound source we just created, this will also unlock the source [result release]; return nil; } } else { //No available source within that source group return nil; } } -(void) _soundSourcePreRelease:(CDSoundSource *) soundSource { CDLOGINFO(@"Denshion::CDSoundEngine _soundSourcePreRelease %i",soundSource->_sourceIndex); //Unlock the sound source's source [self _lockSource:soundSource->_sourceIndex lock:NO]; } /** * Stop all sounds playing within a source group */ - (void) stopSourceGroup:(int) sourceGroupId { if (!functioning_ || sourceGroupId >= _sourceGroupTotal || sourceGroupId < 0) { return; } int sourceCount = _sourceGroups[sourceGroupId].totalSources; for (int i=0; i < sourceCount; i++) { int sourceIndex = _sourceGroups[sourceGroupId].sourceStatuses[i] >> 1; alSourceStop(_sources[sourceIndex].sourceId); } alGetError();//Clear error in case we stopped any sounds that couldn't be stopped } /** * Stop a sound playing. * @param sourceId an OpenAL source identifier i.e. the return value of playSound */ - (void)stopSound:(ALuint) sourceId { if (!functioning_) { return; } alSourceStop(sourceId); alGetError();//Clear error in case we stopped any sounds that couldn't be stopped } - (void) stopAllSounds { for (int i=0; i < sourceTotal_; i++) { alSourceStop(_sources[i].sourceId); } alGetError();//Clear error in case we stopped any sounds that couldn't be stopped } - (void) pauseSound:(ALuint) sourceId { if (!functioning_) { return; } alSourcePause(sourceId); alGetError();//Clear error in case we pause any sounds that couldn't be paused } - (void) pauseAllSounds { for (int i = 0; i < sourceTotal_; i++) { [self pauseSound:_sources[i].sourceId]; } alGetError();//Clear error in case we stopped any sounds that couldn't be paused } - (void) resumeSound:(ALuint) soundId { if (!functioning_) { return; } // only resume a sound id that is paused ALint state; alGetSourcei(soundId, AL_SOURCE_STATE, &state); if (state != AL_PAUSED) { return; } alSourcePlay(soundId); alGetError();//Clear error in case we stopped any sounds that couldn't be resumed } - (void) resumeAllSounds { for (int i = 0; i < sourceTotal_; i++) { [self resumeSound:_sources[i].sourceId]; } alGetError();//Clear error in case we stopped any sounds that couldn't be resumed } /** * Set a source group as non interruptible. Default is that source groups are interruptible. * Non interruptible means that if a request to play a sound is made for a source group and there are * no free sources available then the play request will be ignored and CD_NO_SOURCE will be returned. */ - (void) setSourceGroupNonInterruptible:(int) sourceGroupId isNonInterruptible:(BOOL) isNonInterruptible { //Ensure source group id is valid to prevent memory corruption if (sourceGroupId < 0 || sourceGroupId >= _sourceGroupTotal) { CDLOG(@"Denshion::CDSoundEngine setSourceGroupNonInterruptible invalid source group id %i",sourceGroupId); return; } if (isNonInterruptible) { _sourceGroups[sourceGroupId].nonInterruptible = true; } else { _sourceGroups[sourceGroupId].nonInterruptible = false; } } /** * Set the mute property for a source group. If mute is turned on any sounds in that source group * will be stopped and further sounds in that source group will play. However, turning mute off * will not restart any sounds that were playing when mute was turned on. Also the mute setting * for the sound engine must be taken into account. If the sound engine is mute no sounds will play * no matter what the source group mute setting is. */ - (void) setSourceGroupEnabled:(int) sourceGroupId enabled:(BOOL) enabled { //Ensure source group id is valid to prevent memory corruption if (sourceGroupId < 0 || sourceGroupId >= _sourceGroupTotal) { CDLOG(@"Denshion::CDSoundEngine setSourceGroupEnabled invalid source group id %i",sourceGroupId); return; } if (enabled) { _sourceGroups[sourceGroupId].enabled = true; [self stopSourceGroup:sourceGroupId]; } else { _sourceGroups[sourceGroupId].enabled = false; } } /** * Return the mute property for the source group identified by sourceGroupId */ - (BOOL) sourceGroupEnabled:(int) sourceGroupId { return _sourceGroups[sourceGroupId].enabled; } -(ALCcontext *) openALContext { return context; } - (void) _dumpSourceGroupsInfo { #ifdef CD_DEBUG CDLOGINFO(@"-------------- source Group Info --------------"); for (int i=0; i < _sourceGroupTotal; i++) { CDLOGINFO(@"Group: %i start:%i total:%i",i,_sourceGroups[i].startIndex, _sourceGroups[i].totalSources); CDLOGINFO(@"----- mute:%i nonInterruptible:%i",_sourceGroups[i].enabled, _sourceGroups[i].nonInterruptible); CDLOGINFO(@"----- Source statuses ----"); for (int j=0; j < _sourceGroups[i].totalSources; j++) { CDLOGINFO(@"Source status:%i index=%i locked=%i",j,_sourceGroups[i].sourceStatuses[j] >> 1, _sourceGroups[i].sourceStatuses[j] & 1); } } #endif } @end /////////////////////////////////////////////////////////////////////////////////////// @implementation CDSoundSource @synthesize lastError; //Macro for handling the al error code #define CDSOUNDSOURCE_UPDATE_LAST_ERROR (lastError = alGetError()) #define CDSOUNDSOURCE_ERROR_HANDLER ( CDSOUNDSOURCE_UPDATE_LAST_ERROR == AL_NO_ERROR) -(id)init:(ALuint) theSourceId sourceIndex:(int) index soundEngine:(CDSoundEngine*) engine { if ((self = [super init])) { _sourceId = theSourceId; _engine = engine; _sourceIndex = index; enabled_ = YES; mute_ = NO; _preMuteGain = self.gain; } return self; } -(void) dealloc { CDLOGINFO(@"Denshion::CDSoundSource deallocated %i",self->_sourceIndex); //Notify sound engine we are about to release [_engine _soundSourcePreRelease:self]; [super dealloc]; } - (void) setPitch:(float) newPitchValue { alSourcef(_sourceId, AL_PITCH, newPitchValue); CDSOUNDSOURCE_UPDATE_LAST_ERROR; } - (void) setGain:(float) newGainValue { if (!mute_) { alSourcef(_sourceId, AL_GAIN, newGainValue); } else { _preMuteGain = newGainValue; } CDSOUNDSOURCE_UPDATE_LAST_ERROR; } - (void) setPan:(float) newPanValue { float sourcePosAL[] = {newPanValue, 0.0f, 0.0f};//Set position - just using left and right panning alSourcefv(_sourceId, AL_POSITION, sourcePosAL); CDSOUNDSOURCE_UPDATE_LAST_ERROR; } - (void) setLooping:(BOOL) newLoopingValue { alSourcei(_sourceId, AL_LOOPING, newLoopingValue); CDSOUNDSOURCE_UPDATE_LAST_ERROR; } - (BOOL) isPlaying { ALint state; alGetSourcei(_sourceId, AL_SOURCE_STATE, &state); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return (state == AL_PLAYING); } - (float) pitch { ALfloat pitchVal; alGetSourcef(_sourceId, AL_PITCH, &pitchVal); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return pitchVal; } - (float) pan { ALfloat sourcePosAL[] = {0.0f,0.0f,0.0f}; alGetSourcefv(_sourceId, AL_POSITION, sourcePosAL); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return sourcePosAL[0]; } - (float) gain { if (!mute_) { ALfloat val; alGetSourcef(_sourceId, AL_GAIN, &val); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return val; } else { return _preMuteGain; } } - (BOOL) looping { ALfloat val; alGetSourcef(_sourceId, AL_LOOPING, &val); CDSOUNDSOURCE_UPDATE_LAST_ERROR; return val; } -(BOOL) stop { alSourceStop(_sourceId); return CDSOUNDSOURCE_ERROR_HANDLER; } -(BOOL) play { if (enabled_) { alSourcePlay(_sourceId); CDSOUNDSOURCE_UPDATE_LAST_ERROR; if (lastError != AL_NO_ERROR) { if (alcGetCurrentContext() == NULL) { CDLOGINFO(@"Denshion::CDSoundSource - posting bad OpenAL context message"); [[NSNotificationCenter defaultCenter] postNotificationName:kCDN_BadAlContext object:nil]; } return NO; } else { return YES; } } else { return NO; } } -(BOOL) pause { alSourcePause(_sourceId); return CDSOUNDSOURCE_ERROR_HANDLER; } -(BOOL) rewind { alSourceRewind(_sourceId); return CDSOUNDSOURCE_ERROR_HANDLER; } -(void) setSoundId:(int) soundId { [_engine _soundSourceAttachToBuffer:self soundId:soundId]; } -(int) soundId { return _soundId; } -(float) durationInSeconds { return [_engine bufferDurationInSeconds:_soundId]; } #pragma mark CDSoundSource AudioInterrupt protocol - (BOOL) mute { return mute_; } /** * Setting mute silences all sounds but playing sounds continue to advance playback */ - (void) setMute:(BOOL) newMuteValue { if (newMuteValue == mute_) { return; } if (newMuteValue) { //Remember what the gain was _preMuteGain = self.gain; self.gain = 0.0f; mute_ = newMuteValue;//Make sure this is done after setting the gain property as the setter behaves differently depending on mute value } else { //Restore gain to what it was before being muted mute_ = newMuteValue; self.gain = _preMuteGain; } } - (BOOL) enabled { return enabled_; } - (void) setEnabled:(BOOL)enabledValue { if (enabled_ == enabledValue) { return; } enabled_ = enabledValue; if (enabled_ == NO) { [self stop]; } } @end //////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDAudioInterruptTargetGroup @implementation CDAudioInterruptTargetGroup -(id) init { if ((self = [super init])) { children_ = [[NSMutableArray alloc] initWithCapacity:32]; enabled_ = YES; mute_ = NO; } return self; } -(void) addAudioInterruptTarget:(NSObject*) interruptibleTarget { //Synchronize child with group settings; [interruptibleTarget setMute:mute_]; [interruptibleTarget setEnabled:enabled_]; [children_ addObject:interruptibleTarget]; } -(void) removeAudioInterruptTarget:(NSObject*) interruptibleTarget { [children_ removeObjectIdenticalTo:interruptibleTarget]; } - (BOOL) mute { return mute_; } /** * Setting mute silences all sounds but playing sounds continue to advance playback */ - (void) setMute:(BOOL) newMuteValue { if (newMuteValue == mute_) { return; } for (NSObject* target in children_) { [target setMute:newMuteValue]; } } - (BOOL) enabled { return enabled_; } - (void) setEnabled:(BOOL)enabledValue { if (enabledValue == enabled_) { return; } for (NSObject* target in children_) { [target setEnabled:enabledValue]; } } @end //////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDAsynchBufferLoader @implementation CDAsynchBufferLoader -(id) init:(NSArray *)loadRequests soundEngine:(CDSoundEngine *) theSoundEngine { if ((self = [super init])) { _loadRequests = loadRequests; [_loadRequests retain]; _soundEngine = theSoundEngine; [_soundEngine retain]; } return self; } -(void) main { CDLOGINFO(@"Denshion::CDAsynchBufferLoader - loading buffers"); [super main]; _soundEngine.asynchLoadProgress = 0.0f; if ([_loadRequests count] > 0) { float increment = 1.0f / [_loadRequests count]; //Iterate over load request and load for (CDBufferLoadRequest *loadRequest in _loadRequests) { [_soundEngine loadBuffer:loadRequest.soundId filePath:loadRequest.filePath]; _soundEngine.asynchLoadProgress += increment; } } //Completed _soundEngine.asynchLoadProgress = 1.0f; [[NSNotificationCenter defaultCenter] postNotificationName:kCDN_AsynchLoadComplete object:nil]; } -(void) dealloc { [_loadRequests release]; [_soundEngine release]; [super dealloc]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDBufferLoadRequest @implementation CDBufferLoadRequest @synthesize filePath, soundId; -(id) init:(int) theSoundId filePath:(const NSString *) theFilePath { if ((self = [super init])) { soundId = theSoundId; filePath = [theFilePath copy]; } return self; } -(void) dealloc { [filePath release]; [super dealloc]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDFloatInterpolator @implementation CDFloatInterpolator @synthesize start,end,interpolationType; -(float) interpolate:(float) t { if (t < 1.0f) { switch (interpolationType) { case kIT_Linear: //Linear interpolation return ((end - start) * t) + start; case kIT_SCurve: //Cubic s curve t^2 * (3 - 2t) return ((float)(t * t * (3.0 - (2.0 * t))) * (end - start)) + start; case kIT_Exponential: //Formulas taken from EaseAction if (end > start) { //Fade in float logDelta = (t==0) ? 0 : powf(2, 10 * (t/1 - 1)) - 1 * 0.001f; return ((end - start) * logDelta) + start; } else { //Fade Out float logDelta = (-powf(2, -10 * t/1) + 1); return ((end - start) * logDelta) + start; } default: return 0.0f; } } else { return end; } } -(id) init:(tCDInterpolationType) type startVal:(float) startVal endVal:(float) endVal { if ((self = [super init])) { start = startVal; end = endVal; interpolationType = type; } return self; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDPropertyModifier @implementation CDPropertyModifier @synthesize stopTargetWhenComplete; -(id) init:(id) theTarget interpolationType:(tCDInterpolationType) type startVal:(float) startVal endVal:(float) endVal { if ((self = [super init])) { if (target) { //Release the previous target if there is one [target release]; } target = theTarget; #if CD_DEBUG //Check target is of the required type if (![theTarget isMemberOfClass:[self _allowableType]] ) { CDLOG(@"Denshion::CDPropertyModifier target is not of type %@",[self _allowableType]); NSAssert([theTarget isKindOfClass:[CDSoundEngine class]], @"CDPropertyModifier target not of required type"); } #endif [target retain]; startValue = startVal; endValue = endVal; if (interpolator) { //Release previous interpolator if there is one [interpolator release]; } interpolator = [[CDFloatInterpolator alloc] init:type startVal:startVal endVal:endVal]; stopTargetWhenComplete = NO; } return self; } -(void) dealloc { CDLOGINFO(@"Denshion::CDPropertyModifier deallocated %@",self); [target release]; [interpolator release]; [super dealloc]; } -(void) modify:(float) t { if (t < 1.0) { [self _setTargetProperty:[interpolator interpolate:t]]; } else { //At the end [self _setTargetProperty:endValue]; if (stopTargetWhenComplete) { [self _stopTarget]; } } } -(float) startValue { return startValue; } -(void) setStartValue:(float) startVal { startValue = startVal; interpolator.start = startVal; } -(float) endValue { return startValue; } -(void) setEndValue:(float) endVal { endValue = endVal; interpolator.end = endVal; } -(tCDInterpolationType) interpolationType { return interpolator.interpolationType; } -(void) setInterpolationType:(tCDInterpolationType) interpolationType { interpolator.interpolationType = interpolationType; } -(void) _setTargetProperty:(float) newVal { } -(float) _getTargetProperty { return 0.0f; } -(void) _stopTarget { } -(Class) _allowableType { return [NSObject class]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDSoundSourceFader @implementation CDSoundSourceFader -(void) _setTargetProperty:(float) newVal { ((CDSoundSource*)target).gain = newVal; } -(float) _getTargetProperty { return ((CDSoundSource*)target).gain; } -(void) _stopTarget { [((CDSoundSource*)target) stop]; } -(Class) _allowableType { return [CDSoundSource class]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDSoundSourcePanner @implementation CDSoundSourcePanner -(void) _setTargetProperty:(float) newVal { ((CDSoundSource*)target).pan = newVal; } -(float) _getTargetProperty { return ((CDSoundSource*)target).pan; } -(void) _stopTarget { [((CDSoundSource*)target) stop]; } -(Class) _allowableType { return [CDSoundSource class]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDSoundSourcePitchBender @implementation CDSoundSourcePitchBender -(void) _setTargetProperty:(float) newVal { ((CDSoundSource*)target).pitch = newVal; } -(float) _getTargetProperty { return ((CDSoundSource*)target).pitch; } -(void) _stopTarget { [((CDSoundSource*)target) stop]; } -(Class) _allowableType { return [CDSoundSource class]; } @end /////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark CDSoundEngineFader @implementation CDSoundEngineFader -(void) _setTargetProperty:(float) newVal { ((CDSoundEngine*)target).masterGain = newVal; } -(float) _getTargetProperty { return ((CDSoundEngine*)target).masterGain; } -(void) _stopTarget { [((CDSoundEngine*)target) stopAllSounds]; } -(Class) _allowableType { return [CDSoundEngine class]; } @end ================================================ FILE: cocos2d/cocos/audio/mac/SimpleAudioEngine.mm ================================================ /**************************************************************************** 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. ****************************************************************************/ #include "SimpleAudioEngine.h" #include "SimpleAudioEngine_objc.h" #include #include "CCFileUtils.h" using namespace cocos2d; static void static_end() { [SimpleAudioEngine end]; } static void static_preloadBackgroundMusic(const char* pszFilePath) { [[SimpleAudioEngine sharedEngine] preloadBackgroundMusic: [NSString stringWithUTF8String: pszFilePath]]; } static void static_playBackgroundMusic(const char* pszFilePath, bool bLoop) { [[SimpleAudioEngine sharedEngine] playBackgroundMusic: [NSString stringWithUTF8String: pszFilePath] loop: bLoop]; } static void static_stopBackgroundMusic() { [[SimpleAudioEngine sharedEngine] stopBackgroundMusic]; } static void static_pauseBackgroundMusic() { [[SimpleAudioEngine sharedEngine] pauseBackgroundMusic]; } static void static_resumeBackgroundMusic() { [[SimpleAudioEngine sharedEngine] resumeBackgroundMusic]; } static void static_rewindBackgroundMusic() { [[SimpleAudioEngine sharedEngine] rewindBackgroundMusic]; } static bool static_willPlayBackgroundMusic() { return [[SimpleAudioEngine sharedEngine] willPlayBackgroundMusic]; } static bool static_isBackgroundMusicPlaying() { return [[SimpleAudioEngine sharedEngine] isBackgroundMusicPlaying]; } static float static_getBackgroundMusicVolume() { return [[SimpleAudioEngine sharedEngine] backgroundMusicVolume]; } static void static_setBackgroundMusicVolume(float volume) { volume = MAX( MIN(volume, 1.0), 0 ); [SimpleAudioEngine sharedEngine].backgroundMusicVolume = volume; } static float static_getEffectsVolume() { return [[SimpleAudioEngine sharedEngine] effectsVolume]; } static void static_setEffectsVolume(float volume) { volume = MAX( MIN(volume, 1.0), 0 ); [SimpleAudioEngine sharedEngine].effectsVolume = volume; } static unsigned int static_playEffect(const char* pszFilePath, bool bLoop, Float32 pszPitch, Float32 pszPan, Float32 pszGain) { return [[SimpleAudioEngine sharedEngine] playEffect:[NSString stringWithUTF8String: pszFilePath] loop:bLoop pitch:pszPitch pan: pszPan gain:pszGain ]; } static void static_stopEffect(int nSoundId) { [[SimpleAudioEngine sharedEngine] stopEffect: nSoundId]; } static void static_preloadEffect(const char* pszFilePath) { [[SimpleAudioEngine sharedEngine] preloadEffect: [NSString stringWithUTF8String: pszFilePath]]; } static void static_unloadEffect(const char* pszFilePath) { [[SimpleAudioEngine sharedEngine] unloadEffect: [NSString stringWithUTF8String: pszFilePath]]; } static void static_pauseEffect(unsigned int uSoundId) { [[SimpleAudioEngine sharedEngine] pauseEffect: uSoundId]; } static void static_pauseAllEffects() { [[SimpleAudioEngine sharedEngine] pauseAllEffects]; } static void static_resumeEffect(unsigned int uSoundId) { [[SimpleAudioEngine sharedEngine] resumeEffect: uSoundId]; } static void static_resumeAllEffects() { [[SimpleAudioEngine sharedEngine] resumeAllEffects]; } static void static_stopAllEffects() { [[SimpleAudioEngine sharedEngine] stopAllEffects]; } namespace CocosDenshion { static SimpleAudioEngine *s_pEngine; SimpleAudioEngine::SimpleAudioEngine() { } SimpleAudioEngine::~SimpleAudioEngine() { } SimpleAudioEngine* SimpleAudioEngine::getInstance() { if (! s_pEngine) { s_pEngine = new SimpleAudioEngine(); } return s_pEngine; } void SimpleAudioEngine::end() { if (s_pEngine) { delete s_pEngine; s_pEngine = NULL; } static_end(); } void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); static_preloadBackgroundMusic(fullPath.c_str()); } void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); static_playBackgroundMusic(fullPath.c_str(), bLoop); } void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) { static_stopBackgroundMusic(); } void SimpleAudioEngine::pauseBackgroundMusic() { static_pauseBackgroundMusic(); } void SimpleAudioEngine::resumeBackgroundMusic() { static_resumeBackgroundMusic(); } void SimpleAudioEngine::rewindBackgroundMusic() { static_rewindBackgroundMusic(); } bool SimpleAudioEngine::willPlayBackgroundMusic() { return static_willPlayBackgroundMusic(); } bool SimpleAudioEngine::isBackgroundMusicPlaying() { return static_isBackgroundMusicPlaying(); } float SimpleAudioEngine::getBackgroundMusicVolume() { return static_getBackgroundMusicVolume(); } void SimpleAudioEngine::setBackgroundMusicVolume(float volume) { static_setBackgroundMusicVolume(volume); } float SimpleAudioEngine::getEffectsVolume() { return static_getEffectsVolume(); } void SimpleAudioEngine::setEffectsVolume(float volume) { static_setEffectsVolume(volume); } unsigned int SimpleAudioEngine::playEffect(const char *pszFilePath, bool bLoop, float pitch, float pan, float gain) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); return static_playEffect(fullPath.c_str(), bLoop, pitch, pan, gain); } void SimpleAudioEngine::stopEffect(unsigned int nSoundId) { static_stopEffect(nSoundId); } void SimpleAudioEngine::preloadEffect(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); static_preloadEffect(fullPath.c_str()); } void SimpleAudioEngine::unloadEffect(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); static_unloadEffect(fullPath.c_str()); } void SimpleAudioEngine::pauseEffect(unsigned int uSoundId) { static_pauseEffect(uSoundId); } void SimpleAudioEngine::resumeEffect(unsigned int uSoundId) { static_resumeEffect(uSoundId); } void SimpleAudioEngine::pauseAllEffects() { static_pauseAllEffects(); } void SimpleAudioEngine::resumeAllEffects() { static_resumeAllEffects(); } void SimpleAudioEngine::stopAllEffects() { static_stopAllEffects(); } } ================================================ FILE: cocos2d/cocos/audio/mac/SimpleAudioEngine_objc.h ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "CDAudioManager.h" /** A wrapper to the CDAudioManager object. This is recommended for basic audio requirements. If you just want to play some sound fx and some background music and have no interest in learning the lower level workings then this is the interface to use. Requirements: - Firmware: OS 2.2 or greater - Files: SimpleAudioEngine.*, CocosDenshion.* - Frameworks: OpenAL, AudioToolbox, AVFoundation @since v0.8 */ @interface SimpleAudioEngine : NSObject { BOOL mute_; BOOL enabled_; } /** Background music volume. Range is 0.0f to 1.0f. This will only have an effect if willPlayBackgroundMusic returns YES */ @property (readwrite) float backgroundMusicVolume; /** Effects volume. Range is 0.0f to 1.0f */ @property (readwrite) float effectsVolume; /** If NO it indicates background music will not be played either because no background music is loaded or the audio session does not permit it.*/ @property (readonly) BOOL willPlayBackgroundMusic; /** returns the shared instance of the SimpleAudioEngine object */ + (SimpleAudioEngine*) sharedEngine; /** Preloads a music file so it will be ready to play as background music */ -(void) preloadBackgroundMusic:(NSString*) filePath; /** plays background music in a loop*/ -(void) playBackgroundMusic:(NSString*) filePath; /** plays background music, if loop is true the music will repeat otherwise it will be played once */ -(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop; /** stops playing background music */ -(void) stopBackgroundMusic; /** pauses the background music */ -(void) pauseBackgroundMusic; /** resume background music that has been paused */ -(void) resumeBackgroundMusic; /** rewind the background music */ -(void) rewindBackgroundMusic; /** returns whether or not the background music is playing */ -(BOOL) isBackgroundMusicPlaying; /** plays an audio effect with a file path*/ -(ALuint) playEffect:(NSString*) filePath loop:(BOOL) loop; /** stop a sound that is playing, note you must pass in the soundId that is returned when you started playing the sound with playEffect */ -(void) stopEffect:(ALuint) soundId; /** plays an audio effect with a file path, pitch, pan and gain */ -(ALuint) playEffect:(NSString*) filePath loop:(BOOL)loop pitch:(Float32) pitch pan:(Float32) pan gain:(Float32) gain; /** pause an audio */ -(void) pauseEffect:(ALuint) soundId; /** pause all audioes */ -(void) pauseAllEffects; /** resume an audio */ -(void) resumeEffect:(ALuint) soundId; /** resume all audioes */ -(void) resumeAllEffects; /** stop all audioes */ -(void) stopAllEffects; /** preloads an audio effect */ -(void) preloadEffect:(NSString*) filePath; /** unloads an audio effect from memory */ -(void) unloadEffect:(NSString*) filePath; /** Gets a CDSoundSource object set up to play the specified file. */ -(CDSoundSource *) soundSourceForFile:(NSString*) filePath; /** Shuts down the shared audio engine instance so that it can be reinitialised */ +(void) end; @end ================================================ FILE: cocos2d/cocos/audio/mac/SimpleAudioEngine_objc.m ================================================ /* Copyright (c) 2010 Steve Oldmeadow 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. $Id$ */ #import "SimpleAudioEngine_objc.h" @implementation SimpleAudioEngine static SimpleAudioEngine *sharedEngine = nil; static CDSoundEngine* soundEngine = nil; static CDAudioManager *am = nil; static CDBufferManager *bufferManager = nil; // Init + (SimpleAudioEngine *) sharedEngine { @synchronized(self) { if (!sharedEngine) sharedEngine = [[SimpleAudioEngine alloc] init]; } return sharedEngine; } + (id) alloc { @synchronized(self) { NSAssert(sharedEngine == nil, @"Attempted to allocate a second instance of a singleton."); return [super alloc]; } return nil; } -(id) init { if((self=[super init])) { am = [CDAudioManager sharedManager]; soundEngine = am.soundEngine; bufferManager = [[CDBufferManager alloc] initWithEngine:soundEngine]; mute_ = NO; enabled_ = YES; } return self; } // Memory - (void) dealloc { am = nil; soundEngine = nil; bufferManager = nil; [super dealloc]; } +(void) end { am = nil; [CDAudioManager end]; [bufferManager release]; [sharedEngine release]; sharedEngine = nil; } #pragma mark SimpleAudioEngine - background music -(void) preloadBackgroundMusic:(NSString*) filePath { [am preloadBackgroundMusic:filePath]; } -(void) playBackgroundMusic:(NSString*) filePath { [am playBackgroundMusic:filePath loop:TRUE]; } -(void) playBackgroundMusic:(NSString*) filePath loop:(BOOL) loop { [am playBackgroundMusic:filePath loop:loop]; } -(void) stopBackgroundMusic { [am stopBackgroundMusic]; } -(void) pauseBackgroundMusic { [am pauseBackgroundMusic]; } -(void) resumeBackgroundMusic { [am resumeBackgroundMusic]; } -(void) rewindBackgroundMusic { [am rewindBackgroundMusic]; } -(BOOL) isBackgroundMusicPlaying { return [am isBackgroundMusicPlaying]; } -(BOOL) willPlayBackgroundMusic { return [am willPlayBackgroundMusic]; } #pragma mark SimpleAudioEngine - sound effects -(ALuint) playEffect:(NSString*) filePath loop:(BOOL) loop { return [self playEffect:filePath loop:loop pitch:1.0f pan:0.0f gain:1.0f]; } -(ALuint) playEffect:(NSString*) filePath loop:(BOOL) loop pitch:(Float32) pitch pan:(Float32) pan gain:(Float32) gain { int soundId = [bufferManager bufferForFile:filePath create:YES]; if (soundId != kCDNoBuffer) { return [soundEngine playSound:soundId sourceGroupId:0 pitch:pitch pan:pan gain:gain loop:loop]; } else { return CD_MUTE; } } -(void) stopEffect:(ALuint) soundId { [soundEngine stopSound:soundId]; } -(void) pauseEffect:(ALuint) soundId { [soundEngine pauseSound: soundId]; } -(void) pauseAllEffects { [soundEngine pauseAllSounds]; } -(void) resumeEffect:(ALuint) soundId { [soundEngine resumeSound: soundId]; } -(void) resumeAllEffects { [soundEngine resumeAllSounds]; } -(void) stopAllEffects { [soundEngine stopAllSounds]; } -(void) preloadEffect:(NSString*) filePath { int soundId = [bufferManager bufferForFile:filePath create:YES]; if (soundId == kCDNoBuffer) { CDLOG(@"Denshion::SimpleAudioEngine sound failed to preload %@",filePath); } } -(void) unloadEffect:(NSString*) filePath { CDLOGINFO(@"Denshion::SimpleAudioEngine unloadedEffect %@",filePath); [bufferManager releaseBufferForFile:filePath]; } #pragma mark Audio Interrupt Protocol -(BOOL) mute { return mute_; } -(void) setMute:(BOOL) muteValue { if (mute_ != muteValue) { mute_ = muteValue; am.mute = mute_; } } -(BOOL) enabled { return enabled_; } -(void) setEnabled:(BOOL) enabledValue { if (enabled_ != enabledValue) { enabled_ = enabledValue; am.enabled = enabled_; } } #pragma mark SimpleAudioEngine - BackgroundMusicVolume -(float) backgroundMusicVolume { return am.backgroundMusic.volume; } -(void) setBackgroundMusicVolume:(float) volume { am.backgroundMusic.volume = volume; } #pragma mark SimpleAudioEngine - EffectsVolume -(float) effectsVolume { return am.soundEngine.masterGain; } -(void) setEffectsVolume:(float) volume { am.soundEngine.masterGain = volume; } -(CDSoundSource *) soundSourceForFile:(NSString*) filePath { int soundId = [bufferManager bufferForFile:filePath create:YES]; if (soundId != kCDNoBuffer) { CDSoundSource *result = [soundEngine soundSourceForSound:soundId sourceGroupId:0]; CDLOGINFO(@"Denshion::SimpleAudioEngine sound source created for %@",filePath); return result; } else { return nil; } } @end ================================================ FILE: cocos2d/cocos/audio/openal/OpenALDecoder.cpp ================================================ #include "OpenALDecoder.h" #include #include #include #if CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN #include #include #include using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Media; #endif #ifndef DISABLE_VORBIS #include #endif #ifdef ENABLE_MPG123 #include #endif namespace CocosDenshion { static int checkALError(const char *funcName) { int err = alGetError(); if (err != AL_NO_ERROR) { switch (err) { case AL_INVALID_NAME: fprintf(stderr, "AL_INVALID_NAME in %s\n", funcName); break; case AL_INVALID_ENUM: fprintf(stderr, "AL_INVALID_ENUM in %s\n", funcName); break; case AL_INVALID_VALUE: fprintf(stderr, "AL_INVALID_VALUE in %s\n", funcName); break; case AL_INVALID_OPERATION: fprintf(stderr, "AL_INVALID_OPERATION in %s\n", funcName); break; case AL_OUT_OF_MEMORY: fprintf(stderr, "AL_OUT_OF_MEMORY in %s\n", funcName); break; } } return err; } class AlutDecoder : public OpenALDecoder { bool decode(OpenALFile &file, ALuint &result) { if (!file.mapToMemory()) return false; result = alutCreateBufferFromFileImage(file.mappedFile, file.fileSize); if (AL_NONE == result) return false; return true; } bool acceptsFormat(Format format) const { return Wav == format || Raw == format; } }; class DataRaii { public: char *data; size_t size; DataRaii() : data(0), size(0) {} ~DataRaii() { delete [] data; } }; #ifdef ENABLE_MPG123 class Mpg123Decoder : public OpenALDecoder { private: mpg123_handle *handle; public: class MpgOpenRaii { public: mpg123_handle *handle; MpgOpenRaii(mpg123_handle *handle) : handle(handle) {} ~MpgOpenRaii() { mpg123_close(handle); } }; bool getInfo(ALenum &format, ALsizei &freq, ALsizei &size) const { int channels = 0; int encoding = 0; long rate = 0; if (MPG123_OK != mpg123_getformat(handle, &rate, &channels, &encoding)) return false; size = mpg123_length(handle); if (size == MPG123_ERR) return false; freq = rate; if (encoding == MPG123_ENC_UNSIGNED_8) { if (channels == 1) format = AL_FORMAT_MONO8; else format = AL_FORMAT_STEREO8; } else { if (channels == 1) format = AL_FORMAT_MONO16; else format = AL_FORMAT_STEREO16; } return true; } bool decode(OpenALFile &file, ALuint &result) { if (MPG123_OK != mpg123_open_fd(handle, fileno(file.file))) return false; MpgOpenRaii raii(handle); ALenum format = AL_NONE; ALsizei freq = 0; ALsizei size = 0; if (!getInfo(format, freq, size)) return false; DataRaii pcm; pcm.size = size; if (format == AL_FORMAT_MONO16 || format == AL_FORMAT_STEREO16) pcm.size *= 2; pcm.data = new char[pcm.size]; size_t done = 0; if (MPG123_DONE != mpg123_read(handle, (unsigned char*)pcm.data, pcm.size, &done)) return false; CCLOG("MP3 BUFFER SIZE: %ld, FORMAT %i.", (long)done, (int)format); return initALBuffer(result, format, pcm.data, done, freq); } bool acceptsFormat(Format format) const { return Mp3 == format; } Mpg123Decoder() : handle(mpg123_new(NULL, NULL)) { if (MPG123_OK != mpg123_format(handle, 44100, MPG123_MONO | MPG123_STEREO, MPG123_ENC_UNSIGNED_8 | MPG123_ENC_SIGNED_16)) CCLOG("ERROR (CocosDenshion): cannot set specified mpg123 format."); } ~Mpg123Decoder() { mpg123_delete(handle); } }; #endif #ifndef DISABLE_VORBIS class VorbisDecoder : public OpenALDecoder { class OggRaii { public: OggVorbis_File file; ~OggRaii() { ov_clear(&file); } }; public: bool decode(OpenALFile &file, ALuint &result) { OggRaii ogg; int status = ov_test(file.file, &ogg.file, 0, 0); if (status != 0) { ov_clear(&ogg.file); return false; } status = ov_test_open(&ogg.file); if (status != 0) { fprintf(stderr, "Could not open OGG file '%s'\n", file.debugName.c_str()); return false; } // As vorbis documentation says, we should not fclose() file // after successful opening by vorbis functions. file.file = NULL; vorbis_info *info = ov_info(&ogg.file, -1); ALenum format = (info->channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16; DataRaii pcm; pcm.size = ov_pcm_total(&ogg.file, -1) * info->channels * 2; pcm.data = new char[pcm.size]; size_t size = 0; int section = 0; while (size < pcm.size) { status = ov_read(&ogg.file, pcm.data + size, pcm.size - size, 0, 2, 1, §ion); if (status > 0) { size += status; } else if (status < 0) { fprintf(stderr, "OGG file decoding stopped, file '%s'\n", file.debugName.c_str()); return false; } else { break; } } if (size == 0) { fprintf(stderr, "Unable to read OGG data from '%s'\n", file.debugName.c_str()); return false; } return initALBuffer(result, format, pcm.data, pcm.size, info->rate); } bool acceptsFormat(Format format) const { return Vorbis == format; } }; #endif #if CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN class TizenDecoder : public OpenALDecoder { public: static TizenDecoder *create(Format format) { TizenDecoder *decoder = new TizenDecoder(format); if (decoder && !decoder->init()) { delete decoder; decoder = NULL; } return decoder; } bool decode(OpenALFile &file, ALuint &result) { if (!file.mapToMemory()) return false; ByteBuffer inputBuffer; inputBuffer.Construct(/*capacity*/ file.fileSize); inputBuffer.SetArray((const byte*)file.mappedFile, 0, file.fileSize); inputBuffer.Flip(); ByteBuffer pcm; pcm.Construct(/*capacity*/ 2 * file.fileSize); AudioSampleType sampleType = AUDIO_TYPE_NONE; AudioChannelType channelType = AUDIO_CHANNEL_TYPE_NONE; int sampleRate = 0; if (E_SUCCESS != _decoder.Probe(inputBuffer, sampleType, channelType, sampleRate)) return false; while (inputBuffer.GetRemaining()) { auto ret = _decoder.Decode(inputBuffer, pcm); if (ret == E_OUT_OF_MEMORY) { pcm.ExpandCapacity(2 * pcm.GetCapacity()); } else if (IsFailed(ret)) { AppLogTag("CocosDenshion(TizenDecoder)", "failed to decode file '%s', supported format is %s.", file.debugName.c_str(), getCodecName()); return false; } } return initALBuffer(result, getALFormat(sampleType, channelType), pcm.GetPointer(), pcm.GetPosition(), sampleRate); } bool acceptsFormat(Format format) const { return _format == format; } private: TizenDecoder(Format format) : _format(format) { } bool init() { HashMap option; option.Construct(); option.Add(*(new Integer(MEDIA_PROPERTY_AUDIO_CHANNEL_TYPE)), *(new Integer(AUDIO_CHANNEL_TYPE_NONE))); option.Add(*(new Integer(MEDIA_PROPERTY_AUDIO_SAMPLE_RATE)), *(new Integer(44100))); result r = _decoder.Construct(getCodecType()); if (IsFailed(r)) return false; else AppLogTag("CocosDenshion", "Tizen device supports audio format %s.", getCodecName()); return true; } ALenum getALFormat(AudioSampleType sampleType, AudioChannelType channelType) { if (sampleType == AUDIO_TYPE_PCM_U8) { if (channelType == AUDIO_CHANNEL_TYPE_MONO) return AL_FORMAT_MONO8; return AL_FORMAT_STEREO8; } if (sampleType == AUDIO_TYPE_PCM_S16_LE) { if (channelType == AUDIO_CHANNEL_TYPE_MONO) return AL_FORMAT_MONO16; return AL_FORMAT_STEREO16; } AppLogTag("CocosDenshion(TizenDecoder)", "unsuppored sampleType=%d.", sampleType, channelType); return AL_NONE; } CodecType getCodecType() const { switch (_format) { case Mp3: return CODEC_MP3; case Vorbis: return CODEC_VORBIS; case Flac: return CODEC_FLAC; case Midi: return CODEC_MIDI; case Aac: return CODEC_AAC; default: break; } return CODEC_UNKNOWN; } const char *getCodecName() const { switch (_format) { case Mp3: return "mp3"; case Vorbis: return "vorbis"; case Flac: return "flac"; case Midi: return "midi"; case Aac: return "aac"; default: break; } return "unknown"; } Format _format; AudioDecoder _decoder; }; #endif std::vector OpenALDecoder::_decoders; void OpenALDecoder::installDecoders() { #if CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN addDecoder(TizenDecoder::create(Mp3)); addDecoder(TizenDecoder::create(Vorbis)); addDecoder(TizenDecoder::create(Flac)); addDecoder(TizenDecoder::create(Midi)); addDecoder(TizenDecoder::create(Aac)); #else #if !defined(DISABLE_VORBIS) addDecoder(new VorbisDecoder()); #endif #if defined(ENABLE_MPG123) addDecoder(new Mpg123Decoder()); #endif #endif addDecoder(new AlutDecoder()); } void OpenALDecoder::addDecoder(OpenALDecoder *decoder) { if (decoder) _decoders.push_back(decoder); } bool OpenALDecoder::initALBuffer(ALuint &result, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq) { // Load audio data into a buffer. alGenBuffers(1, &result); if (checkALError("initALBuffer:alGenBuffers") != AL_NO_ERROR) { fprintf(stderr, "Couldn't generate OpenAL buffer\n"); return false; } alBufferData(result, format, data, size, freq); checkALError("initALBuffer:alBufferData"); return true; } const std::vector &OpenALDecoder::getDecoders() { return _decoders; } void OpenALFile::clear() { if (mappedFile) { ::munmap(mappedFile, fileSize); mappedFile = 0; fileSize = 0; } if (file) { fclose(file); file = 0; } } bool OpenALFile::mapToMemory() { if (!file) return false; if (mappedFile != NULL) return true; const int fd = fileno(file); struct stat fileStats; if (0 != fstat(fd, &fileStats)) return false; fileSize = fileStats.st_size; mappedFile = ::mmap(NULL, fileSize, PROT_READ, MAP_PRIVATE, fd, 0); if (mappedFile != MAP_FAILED) return true; mappedFile = NULL; return false; } } // namespace CocosDenshion ================================================ FILE: cocos2d/cocos/audio/openal/OpenALDecoder.h ================================================ #ifndef COCOSDENSHION_OPENALLOADER_H #define COCOSDENSHION_OPENALLOADER_H #include #include #include #include #include "cocos2d.h" #if CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN #define DISABLE_VORBIS #endif namespace CocosDenshion { struct OpenALFile { std::string debugName; ///< For logging. FILE *file; void *mappedFile; ///< Reserved by decoders. size_t fileSize; ///< Reserved by decoders. OpenALFile() : file(0), mappedFile(0), fileSize(0) {} ~OpenALFile() { clear(); } /// Unmaps from memory and closes file. void clear(); /// Performs memory map, if was not mapped before. bool mapToMemory(); }; class OpenALDecoder { public: enum Format { Mp3 = 0, Vorbis, Wav, Raw, Flac, Midi, Aac }; virtual ~OpenALDecoder() {} /// Returns true if such format is supported and decoding was successful. virtual bool decode(OpenALFile &file, ALuint &result) = 0; virtual bool acceptsFormat(Format format) const = 0; static const std::vector &getDecoders(); static void installDecoders(); protected: static void addDecoder(OpenALDecoder *decoder); bool initALBuffer(ALuint &result, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq); static std::vector _decoders; }; } // namespace CocosDenshion #endif // COCOSDENSHION_OPENALLOADER_H ================================================ FILE: cocos2d/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "SimpleAudioEngine.h" #include #include #include #include #include #include #include #include #include "OpenALDecoder.h" #ifdef ENABLE_MPG123 #include #endif USING_NS_CC; using namespace std; namespace CocosDenshion { struct soundData { ALuint buffer; ALuint source; bool isLooped; float pitch; float pan; float gain; }; typedef map EffectsMap; EffectsMap s_effects; typedef enum { PLAYING, STOPPED, PAUSED, } playStatus; static float s_volume = 1.0f; static float s_effectVolume = 1.0f; struct backgroundMusicData { ALuint buffer; ALuint source; }; typedef map BackgroundMusicsMap; BackgroundMusicsMap s_backgroundMusics; static ALuint s_backgroundSource = AL_NONE; static SimpleAudioEngine *s_engine = nullptr; static int checkALError(const char *funcName) { int err = alGetError(); if (err != AL_NO_ERROR) { switch (err) { case AL_INVALID_NAME: fprintf(stderr, "AL_INVALID_NAME in %s\n", funcName); break; case AL_INVALID_ENUM: fprintf(stderr, "AL_INVALID_ENUM in %s\n", funcName); break; case AL_INVALID_VALUE: fprintf(stderr, "AL_INVALID_VALUE in %s\n", funcName); break; case AL_INVALID_OPERATION: fprintf(stderr, "AL_INVALID_OPERATION in %s\n", funcName); break; case AL_OUT_OF_MEMORY: fprintf(stderr, "AL_OUT_OF_MEMORY in %s\n", funcName); break; } } return err; } static void stopBackground(bool bReleaseData) { // The background music might have been already stopped // Stop request can come from // - stopBackgroundMusic(..) // - end(..) if (s_backgroundSource != AL_NONE) alSourceStop(s_backgroundSource); if (bReleaseData) { for (auto it = s_backgroundMusics.begin(); it != s_backgroundMusics.end(); ++it) { if (it->second->source == s_backgroundSource) { alDeleteSources(1, &it->second->source); checkALError("stopBackground:alDeleteSources"); alDeleteBuffers(1, &it->second->buffer); checkALError("stopBackground:alDeleteBuffers"); delete it->second; s_backgroundMusics.erase(it); break; } } } s_backgroundSource = AL_NONE; } static void setBackgroundVolume(float volume) { alSourcef(s_backgroundSource, AL_GAIN, volume); } SimpleAudioEngine::SimpleAudioEngine() { alutInit(0, 0); #ifdef ENABLE_MPG123 mpg123_init(); #endif checkALError("SimpleAudioEngine:alutInit"); OpenALDecoder::installDecoders(); } SimpleAudioEngine::~SimpleAudioEngine() { #ifdef ENABLE_MPG123 mpg123_exit(); #endif alutExit(); } SimpleAudioEngine* SimpleAudioEngine::getInstance() { if (!s_engine) s_engine = new SimpleAudioEngine(); return s_engine; } void SimpleAudioEngine::end() { checkALError("end:init"); // clear all the sound effects EffectsMap::const_iterator end = s_effects.end(); for (auto it = s_effects.begin(); it != end; ++it) { alSourceStop(it->second->source); checkALError("end:alSourceStop"); alDeleteSources(1, &it->second->source); checkALError("end:alDeleteSources"); alDeleteBuffers(1, &it->second->buffer); checkALError("end:alDeleteBuffers"); delete it->second; } s_effects.clear(); // and the background music too stopBackground(true); for (auto it = s_backgroundMusics.begin(); it != s_backgroundMusics.end(); ++it) { alSourceStop(it->second->source); checkALError("end:alSourceStop"); alDeleteSources(1, &it->second->source); checkALError("end:alDeleteSources"); alDeleteBuffers(1, &it->second->buffer); checkALError("end:alDeleteBuffers"); delete it->second; } s_backgroundMusics.clear(); CC_SAFE_DELETE(s_engine); } // // background audio // void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); BackgroundMusicsMap::const_iterator it = s_backgroundMusics.find(fullPath); if (it == s_backgroundMusics.end()) { ALuint buffer = AL_NONE; bool success = false; OpenALFile file; file.debugName = pszFilePath; file.file = fopen(fullPath.c_str(), "rb"); if (!file.file) { fprintf(stderr, "Cannot read file: '%s'\n", fullPath.data()); return; } const std::vector &decoders = OpenALDecoder::getDecoders(); for (size_t i = 0, n = decoders.size(); !success && i < n; ++i) success = decoders[i]->decode(file, buffer); file.clear(); ALuint source = AL_NONE; alGenSources(1, &source); checkALError("preloadBackgroundMusic:alGenSources"); alSourcei(source, AL_BUFFER, buffer); checkALError("preloadBackgroundMusic:alSourcei"); backgroundMusicData* data = new backgroundMusicData(); data->buffer = buffer; data->source = source; s_backgroundMusics.insert(BackgroundMusicsMap::value_type(fullPath, data)); } } void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) { // If there is already a background music source we stop it first if (s_backgroundSource != AL_NONE) stopBackgroundMusic(false); // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); BackgroundMusicsMap::const_iterator it = s_backgroundMusics.find(fullPath); if (it == s_backgroundMusics.end()) { preloadBackgroundMusic(fullPath.c_str()); it = s_backgroundMusics.find(fullPath); } if (it != s_backgroundMusics.end()) { s_backgroundSource = it->second->source; alSourcei(s_backgroundSource, AL_LOOPING, bLoop ? AL_TRUE : AL_FALSE); setBackgroundVolume(s_volume); alSourcePlay(s_backgroundSource); checkALError("playBackgroundMusic:alSourcePlay"); } } void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) { // If there is no source, then there is nothing that can be stopped if (s_backgroundSource == AL_NONE) return; ALint state; alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) stopBackground(bReleaseData); } void SimpleAudioEngine::pauseBackgroundMusic() { // If there is no source, then there is nothing that can be paused if (s_backgroundSource == AL_NONE) return; ALint state; alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) alSourcePause(s_backgroundSource); checkALError("pauseBackgroundMusic:alSourcePause"); } void SimpleAudioEngine::resumeBackgroundMusic() { // If there is no source, then there is nothing that can be resumed if (s_backgroundSource == AL_NONE) return; ALint state; alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state); if (state == AL_PAUSED) alSourcePlay(s_backgroundSource); checkALError("resumeBackgroundMusic:alSourcePlay"); } void SimpleAudioEngine::rewindBackgroundMusic() { // If there is no source, then there is nothing that can be rewinded if (s_backgroundSource == AL_NONE) return; // Rewind and prevent the last state the source had ALint state; alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state); alSourceRewind(s_backgroundSource); if (state == AL_PLAYING) { alSourcePlay(s_backgroundSource); } else if (state == AL_PAUSED) { alSourcePlay(s_backgroundSource); alSourcePause(s_backgroundSource); } checkALError("rewindBackgroundMusic:alSourceRewind"); } bool SimpleAudioEngine::willPlayBackgroundMusic() { // We are able to play background music // if we have a valid background source if (s_backgroundSource == AL_NONE) return false; return (alIsSource(s_backgroundSource) == AL_TRUE ? true : false); } bool SimpleAudioEngine::isBackgroundMusicPlaying() { // If there is no source, then there is nothing that is playing if (s_backgroundSource == AL_NONE) return false; ALint play_status; alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &play_status); checkALError("isBackgroundMusicPlaying:alGetSourcei"); return (play_status == AL_PLAYING); } float SimpleAudioEngine::getBackgroundMusicVolume() { return s_volume; } void SimpleAudioEngine::setBackgroundMusicVolume(float volume) { if (s_volume != volume && volume >= -0.0001 && volume <= 1.0001) { s_volume = volume; // No source, no background music, no volume adjustment if (s_backgroundSource != AL_NONE) { setBackgroundVolume(volume); } } } // // Effect audio (using OpenAL) // float SimpleAudioEngine::getEffectsVolume() { return s_effectVolume; } void SimpleAudioEngine::setEffectsVolume(float volume) { if (volume != s_effectVolume) { EffectsMap::const_iterator end = s_effects.end(); for (EffectsMap::const_iterator it = s_effects.begin(); it != end; it++) { alSourcef(it->second->source, AL_GAIN, volume * it->second->gain); } s_effectVolume = volume; } } unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) { std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); EffectsMap::iterator iter = s_effects.find(fullPath); if (iter == s_effects.end()) { preloadEffect(fullPath.c_str()); // let's try again iter = s_effects.find(fullPath); if (iter == s_effects.end()) { fprintf(stderr, "could not find play sound %s\n", fullPath.c_str()); return -1; } } checkALError("playEffect:init"); soundData &d = *iter->second; d.isLooped = bLoop; d.pitch = pitch; d.pan = pan; d.gain = gain; alSourcei(d.source, AL_LOOPING, d.isLooped ? AL_TRUE : AL_FALSE); alSourcef(d.source, AL_GAIN, s_effectVolume * d.gain); alSourcef(d.source, AL_PITCH, d.pitch); float sourcePosAL[] = {d.pan, 0.0f, 0.0f};//Set position - just using left and right panning alSourcefv(d.source, AL_POSITION, sourcePosAL); alSourcePlay(d.source); checkALError("playEffect:alSourcePlay"); return d.source; } void SimpleAudioEngine::stopEffect(unsigned int nSoundId) { alSourceStop(nSoundId); checkALError("stopEffect:alSourceStop"); } void SimpleAudioEngine::preloadEffect(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); EffectsMap::iterator iter = s_effects.find(fullPath); // check if we have this already if (iter == s_effects.end()) { ALuint buffer = AL_NONE; ALuint source = AL_NONE; soundData *data = new soundData; checkALError("preloadEffect:init"); OpenALFile file; file.debugName = pszFilePath; file.file = fopen(fullPath.c_str(), "rb"); if (!file.file) { fprintf(stderr, "Cannot read file: '%s'\n", fullPath.data()); return; } bool success = false; const std::vector &decoders = OpenALDecoder::getDecoders(); for (size_t i = 0, n = decoders.size(); !success && i < n; ++i) success = decoders[i]->decode(file, buffer); file.clear(); alGenSources(1, &source); if (checkALError("preloadEffect:alGenSources") != AL_NO_ERROR) { alDeleteBuffers(1, &buffer); return; } alSourcei(source, AL_BUFFER, buffer); checkALError("preloadEffect:alSourcei"); data->isLooped = false; data->buffer = buffer; data->source = source; data->pitch = 1.0; data->pan = 0.0; data->gain = 1.0; s_effects.insert(EffectsMap::value_type(fullPath, data)); } } void SimpleAudioEngine::unloadEffect(const char* pszFilePath) { // Changing file path to full path std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath); EffectsMap::iterator iter = s_effects.find(fullPath); if (iter != s_effects.end()) { checkALError("unloadEffect:init"); alSourceStop(iter->second->source); checkALError("unloadEffect:alSourceStop"); alDeleteSources(1, &iter->second->source); checkALError("unloadEffect:DeletSources"); alDeleteBuffers(1, &iter->second->buffer); checkALError("unloadEffect:alDeleteBuffers"); delete iter->second; s_effects.erase(iter); } } void SimpleAudioEngine::pauseEffect(unsigned int nSoundId) { ALint state; alGetSourcei(nSoundId, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) alSourcePause(nSoundId); checkALError("pauseEffect:alSourcePause"); } void SimpleAudioEngine::pauseAllEffects() { EffectsMap::iterator iter = s_effects.begin(); ALint state; while (iter != s_effects.end()) { alGetSourcei(iter->second->source, AL_SOURCE_STATE, &state); if (state == AL_PLAYING) alSourcePause(iter->second->source); checkALError("pauseAllEffects:alSourcePause"); ++iter; } } void SimpleAudioEngine::resumeEffect(unsigned int nSoundId) { ALint state; alGetSourcei(nSoundId, AL_SOURCE_STATE, &state); if (state == AL_PAUSED) alSourcePlay(nSoundId); checkALError("resumeEffect:alSourcePlay"); } void SimpleAudioEngine::resumeAllEffects() { EffectsMap::iterator iter = s_effects.begin(); ALint state; while (iter != s_effects.end()) { alGetSourcei(iter->second->source, AL_SOURCE_STATE, &state); if (state == AL_PAUSED) alSourcePlay(iter->second->source); checkALError("resumeAllEffects:alSourcePlay"); ++iter; } } void SimpleAudioEngine::stopAllEffects() { EffectsMap::iterator iter = s_effects.begin(); if (iter != s_effects.end()) { checkALError("stopAllEffects:init"); alSourceStop(iter->second->source); checkALError("stopAllEffects:alSourceStop"); } } } // namespace CocosDenshion { ================================================ FILE: cocos2d/cocos/audio/proj.win32/CocosDenshion.vcxproj ================================================  Debug Win32 Release Win32 libAudio {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} CocosDenshion.win32 Win32Proj StaticLibrary NotSet v100 v110 v110_xp StaticLibrary NotSet v100 v110 v110_xp <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false AllRules.ruleset AllRules.ruleset $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) Disabled $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue 4251 true winmm.lib;libcocos2d.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll true Windows $(TargetDir)$(TargetName).lib MachineX86 $(OutDir) $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase 4251 true winmm.lib;libcocos2d.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll true Windows true true $(TargetDir)$(TargetName).lib MachineX86 $(OutDir) ================================================ FILE: cocos2d/cocos/audio/proj.win32/CocosDenshion.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx Header Files Header Files Header Files Source Files Source Files ================================================ FILE: cocos2d/cocos/audio/win32/MciPlayer.cpp ================================================ #include "MciPlayer.h" #define WIN_CLASS_NAME "CocosDenshionCallbackWnd" #define BREAK_IF(cond) if (cond) break; namespace CocosDenshion { static HINSTANCE s_hInstance; static MCIERROR s_mciError; LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); MciPlayer::MciPlayer() : _wnd(NULL) , _dev(0L) , _soundID(0) , _times(0) , _playing(false) { if (! s_hInstance) { s_hInstance = GetModuleHandle( NULL ); // Grab An Instance For Our Window WNDCLASS wc; // Windows Class Structure // Redraw On Size, And Own DC For Window. wc.style = 0; wc.lpfnWndProc = _SoundPlayProc; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra Window Data wc.cbWndExtra = 0; // No Extra Window Data wc.hInstance = s_hInstance; // Set The Instance wc.hIcon = 0; // Load The Default Icon wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = WIN_CLASS_NAME; // Set The Class Name if (! RegisterClass(&wc) && 1410 != GetLastError()) { return; } } _wnd = CreateWindowEx( WS_EX_APPWINDOW, // Extended Style For The Window WIN_CLASS_NAME, // Class Name NULL, // Window Title WS_POPUPWINDOW,/*WS_OVERLAPPEDWINDOW*/ // Defined Window Style 0, 0, // Window Position 0, // Window Width 0, // Window Height NULL, // No Parent Window NULL, // No Menu s_hInstance, // Instance NULL ); if (_wnd) { SetWindowLongPtr(_wnd, GWLP_USERDATA, (LONG_PTR)this); } } MciPlayer::~MciPlayer() { Close(); DestroyWindow(_wnd); } void MciPlayer::Open(const char* pFileName, UINT uId) { // WCHAR * pBuf = NULL; do { BREAK_IF(! pFileName || ! _wnd); int nLen = (int)strlen(pFileName); BREAK_IF(! nLen); // pBuf = new WCHAR[nLen + 1]; // BREAK_IF(! pBuf); // MultiByteToWideChar(CP_ACP, 0, pFileName, nLen + 1, pBuf, nLen + 1); Close(); MCI_OPEN_PARMS mciOpen = {0}; MCIERROR mciError; mciOpen.lpstrDeviceType = (LPCTSTR)MCI_ALL_DEVICE_ID; mciOpen.lpstrElementName = pFileName; mciError = mciSendCommand(0,MCI_OPEN, MCI_OPEN_ELEMENT, reinterpret_cast(&mciOpen)); BREAK_IF(mciError); _dev = mciOpen.wDeviceID; _soundID = uId; _playing = false; } while (0); } void MciPlayer::Play(UINT uTimes /* = 1 */) { if (! _dev) { return; } MCI_PLAY_PARMS mciPlay = {0}; mciPlay.dwCallback = reinterpret_cast(_wnd); s_mciError = mciSendCommand(_dev,MCI_PLAY, MCI_FROM|MCI_NOTIFY,reinterpret_cast(&mciPlay)); if (! s_mciError) { _playing = true; _times = uTimes; } } void MciPlayer::Close() { if (_playing) { Stop(); } if (_dev) { _SendGenericCommand(MCI_CLOSE); } _dev = 0; _playing = false; } void MciPlayer::Pause() { _SendGenericCommand(MCI_PAUSE); } void MciPlayer::Resume() { _SendGenericCommand(MCI_RESUME); } void MciPlayer::Stop() { _SendGenericCommand(MCI_STOP); _playing = false; } void MciPlayer::Rewind() { if (! _dev) { return; } mciSendCommand(_dev, MCI_SEEK, MCI_SEEK_TO_START, 0); MCI_PLAY_PARMS mciPlay = {0}; mciPlay.dwCallback = reinterpret_cast(_wnd); _playing = mciSendCommand(_dev, MCI_PLAY, MCI_NOTIFY,reinterpret_cast(&mciPlay)) ? false : true; } bool MciPlayer::IsPlaying() { return _playing; } UINT MciPlayer::GetSoundID() { return _soundID; } ////////////////////////////////////////////////////////////////////////// // private member ////////////////////////////////////////////////////////////////////////// void MciPlayer::_SendGenericCommand(int nCommand) { if (! _dev) { return; } mciSendCommand(_dev, nCommand, 0, 0); } ////////////////////////////////////////////////////////////////////////// // static function ////////////////////////////////////////////////////////////////////////// LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { MciPlayer * pPlayer = NULL; if (MM_MCINOTIFY == Msg && MCI_NOTIFY_SUCCESSFUL == wParam &&(pPlayer = (MciPlayer *)GetWindowLongPtr(hWnd, GWLP_USERDATA))) { if (pPlayer->_times) { --pPlayer->_times; } if (pPlayer->_times) { mciSendCommand(lParam, MCI_SEEK, MCI_SEEK_TO_START, 0); MCI_PLAY_PARMS mciPlay = {0}; mciPlay.dwCallback = reinterpret_cast(hWnd); mciSendCommand(lParam, MCI_PLAY, MCI_NOTIFY,reinterpret_cast(&mciPlay)); } else { pPlayer->_playing = false; } return 0; } return DefWindowProc(hWnd, Msg, wParam, lParam); } } // end of namespace CocosDenshion ================================================ FILE: cocos2d/cocos/audio/win32/MciPlayer.h ================================================ #ifndef _MCI_PLAYER_WIN32_H_ #define _MCI_PLAYER_WIN32_H_ #include "CCStdC.h" #include namespace CocosDenshion { class MciPlayer { public: MciPlayer(); ~MciPlayer(); void Close(); /** @brief ļ @param pFileName ŵļƣҪļ· @param nTimes ļѭĬֵΪ 1һ */ void Open(const char* pFileName, UINT uId); void Play(UINT uTimes = 1); /** @brief ͣ */ void Pause(); /** @brief */ void Resume(); /** @brief ֹͣ */ void Stop(); /** @brief ² */ void Rewind(); /** @brief ȡǰǷڲ */ bool IsPlaying(); /** @brief ȡǰŵЧ ID @return ǰŵЧID */ UINT GetSoundID(); private: friend LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); void _SendGenericCommand(int nCommand); HWND _wnd; MCIDEVICEID _dev; UINT _soundID; UINT _times; bool _playing; }; } // end of namespace CocosDenshion #endif ================================================ FILE: cocos2d/cocos/audio/win32/SimpleAudioEngine.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "SimpleAudioEngine.h" #include #include #include "MciPlayer.h" #include "cocos2d.h" USING_NS_CC; using namespace std; namespace CocosDenshion { typedef map EffectList; typedef pair Effect; static char s_szRootPath[MAX_PATH]; static DWORD s_dwRootLen; static char s_szFullPath[MAX_PATH]; static std::string _FullPath(const char * szPath); static unsigned int _Hash(const char *key); #define BREAK_IF(cond) if (cond) break; static EffectList& sharedList() { static EffectList s_List; return s_List; } static MciPlayer& sharedMusic() { static MciPlayer s_Music; return s_Music; } SimpleAudioEngine::SimpleAudioEngine() { } SimpleAudioEngine::~SimpleAudioEngine() { } SimpleAudioEngine* SimpleAudioEngine::getInstance() { static SimpleAudioEngine s_SharedEngine; return &s_SharedEngine; } void SimpleAudioEngine::end() { sharedMusic().Close(); EffectList::iterator p = sharedList().begin(); while (p != sharedList().end()) { delete p->second; p->second = NULL; p++; } sharedList().clear(); return; } ////////////////////////////////////////////////////////////////////////// // BackgroundMusic ////////////////////////////////////////////////////////////////////////// void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) { if (! pszFilePath) { return; } sharedMusic().Open(_FullPath(pszFilePath).c_str(), _Hash(pszFilePath)); sharedMusic().Play((bLoop) ? -1 : 1); } void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) { if (bReleaseData) { sharedMusic().Close(); } else { sharedMusic().Stop(); } } void SimpleAudioEngine::pauseBackgroundMusic() { sharedMusic().Pause(); } void SimpleAudioEngine::resumeBackgroundMusic() { sharedMusic().Resume(); } void SimpleAudioEngine::rewindBackgroundMusic() { sharedMusic().Rewind(); } bool SimpleAudioEngine::willPlayBackgroundMusic() { return false; } bool SimpleAudioEngine::isBackgroundMusicPlaying() { return sharedMusic().IsPlaying(); } ////////////////////////////////////////////////////////////////////////// // effect function ////////////////////////////////////////////////////////////////////////// unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop, float pitch, float pan, float gain) { unsigned int nRet = _Hash(pszFilePath); preloadEffect(pszFilePath); EffectList::iterator p = sharedList().find(nRet); if (p != sharedList().end()) { p->second->Play((bLoop) ? -1 : 1); } return nRet; } void SimpleAudioEngine::stopEffect(unsigned int nSoundId) { EffectList::iterator p = sharedList().find(nSoundId); if (p != sharedList().end()) { p->second->Stop(); } } void SimpleAudioEngine::preloadEffect(const char* pszFilePath) { int nRet = 0; do { BREAK_IF(! pszFilePath); nRet = _Hash(pszFilePath); BREAK_IF(sharedList().end() != sharedList().find(nRet)); sharedList().insert(Effect(nRet, new MciPlayer())); MciPlayer * pPlayer = sharedList()[nRet]; pPlayer->Open(_FullPath(pszFilePath).c_str(), nRet); BREAK_IF(nRet == pPlayer->GetSoundID()); delete pPlayer; sharedList().erase(nRet); nRet = 0; } while (0); } void SimpleAudioEngine::pauseEffect(unsigned int nSoundId) { EffectList::iterator p = sharedList().find(nSoundId); if (p != sharedList().end()) { p->second->Pause(); } } void SimpleAudioEngine::pauseAllEffects() { EffectList::iterator iter; for (iter = sharedList().begin(); iter != sharedList().end(); iter++) { iter->second->Pause(); } } void SimpleAudioEngine::resumeEffect(unsigned int nSoundId) { EffectList::iterator p = sharedList().find(nSoundId); if (p != sharedList().end()) { p->second->Resume(); } } void SimpleAudioEngine::resumeAllEffects() { EffectList::iterator iter; for (iter = sharedList().begin(); iter != sharedList().end(); iter++) { iter->second->Resume(); } } void SimpleAudioEngine::stopAllEffects() { EffectList::iterator iter; for (iter = sharedList().begin(); iter != sharedList().end(); iter++) { iter->second->Stop(); } } void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) { } void SimpleAudioEngine::unloadEffect(const char* pszFilePath) { unsigned int nID = _Hash(pszFilePath); EffectList::iterator p = sharedList().find(nID); if (p != sharedList().end()) { delete p->second; p->second = NULL; sharedList().erase(nID); } } ////////////////////////////////////////////////////////////////////////// // volume interface ////////////////////////////////////////////////////////////////////////// float SimpleAudioEngine::getBackgroundMusicVolume() { return 1.0; } void SimpleAudioEngine::setBackgroundMusicVolume(float volume) { } float SimpleAudioEngine::getEffectsVolume() { return 1.0; } void SimpleAudioEngine::setEffectsVolume(float volume) { } ////////////////////////////////////////////////////////////////////////// // static function ////////////////////////////////////////////////////////////////////////// static std::string _FullPath(const char * szPath) { return FileUtils::getInstance()->fullPathForFilename(szPath); } unsigned int _Hash(const char *key) { unsigned int len = strlen(key); const char *end=key+len; unsigned int hash; for (hash = 0; key < end; key++) { hash *= 16777619; hash ^= (unsigned int) (unsigned char) toupper(*key); } return (hash); } } // end of namespace CocosDenshion ================================================ FILE: cocos2d/cocos/base/CCAffineTransform.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAffineTransform.h" #include #include using namespace std; NS_CC_BEGIN AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty) { AffineTransform t; t.a = a; t.b = b; t.c = c; t.d = d; t.tx = tx; t.ty = ty; return t; } Point __CCPointApplyAffineTransform(const Point& point, const AffineTransform& t) { Point p; p.x = (float)((double)t.a * point.x + (double)t.c * point.y + t.tx); p.y = (float)((double)t.b * point.x + (double)t.d * point.y + t.ty); return p; } Point PointApplyTransform(const Point& point, const kmMat4& transform) { kmVec3 vec = {point.x, point.y, 0}; kmVec3Transform(&vec, &vec, &transform); return Point(vec.x, vec.y); } Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t) { Size s; s.width = (float)((double)t.a * size.width + (double)t.c * size.height); s.height = (float)((double)t.b * size.width + (double)t.d * size.height); return s; } AffineTransform AffineTransformMakeIdentity() { return __CCAffineTransformMake(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); } extern const AffineTransform AffineTransformIdentity = AffineTransformMakeIdentity(); const AffineTransform AffineTransform::IDENTITY = AffineTransformMakeIdentity(); Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform) { float top = rect.getMinY(); float left = rect.getMinX(); float right = rect.getMaxX(); float bottom = rect.getMaxY(); Point topLeft = PointApplyAffineTransform(Point(left, top), anAffineTransform); Point topRight = PointApplyAffineTransform(Point(right, top), anAffineTransform); Point bottomLeft = PointApplyAffineTransform(Point(left, bottom), anAffineTransform); Point bottomRight = PointApplyAffineTransform(Point(right, bottom), anAffineTransform); float minX = min(min(topLeft.x, topRight.x), min(bottomLeft.x, bottomRight.x)); float maxX = max(max(topLeft.x, topRight.x), max(bottomLeft.x, bottomRight.x)); float minY = min(min(topLeft.y, topRight.y), min(bottomLeft.y, bottomRight.y)); float maxY = max(max(topLeft.y, topRight.y), max(bottomLeft.y, bottomRight.y)); return Rect(minX, minY, (maxX - minX), (maxY - minY)); } Rect RectApplyTransform(const Rect& rect, const kmMat4& transform) { float top = rect.getMinY(); float left = rect.getMinX(); float right = rect.getMaxX(); float bottom = rect.getMaxY(); kmVec3 topLeft = {left, top}; kmVec3 topRight = {right, top}; kmVec3 bottomLeft = {left, bottom}; kmVec3 bottomRight = {right, bottom}; kmVec3Transform(&topLeft, &topLeft, &transform); kmVec3Transform(&topRight, &topRight, &transform); kmVec3Transform(&bottomLeft, &bottomLeft, &transform); kmVec3Transform(&bottomRight, &bottomRight, &transform); float minX = min(min(topLeft.x, topRight.x), min(bottomLeft.x, bottomRight.x)); float maxX = max(max(topLeft.x, topRight.x), max(bottomLeft.x, bottomRight.x)); float minY = min(min(topLeft.y, topRight.y), min(bottomLeft.y, bottomRight.y)); float maxY = max(max(topLeft.y, topRight.y), max(bottomLeft.y, bottomRight.y)); return Rect(minX, minY, (maxX - minX), (maxY - minY)); } AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty) { return __CCAffineTransformMake(t.a, t.b, t.c, t.d, t.tx + t.a * tx + t.c * ty, t.ty + t.b * tx + t.d * ty); } AffineTransform AffineTransformScale(const AffineTransform& t, float sx, float sy) { return __CCAffineTransformMake(t.a * sx, t.b * sx, t.c * sy, t.d * sy, t.tx, t.ty); } AffineTransform AffineTransformRotate(const AffineTransform& t, float anAngle) { float sine = sinf(anAngle); float cosine = cosf(anAngle); return __CCAffineTransformMake( t.a * cosine + t.c * sine, t.b * cosine + t.d * sine, t.c * cosine - t.a * sine, t.d * cosine - t.b * sine, t.tx, t.ty); } /* Concatenate `t2' to `t1' and return the result: t' = t1 * t2 */ AffineTransform AffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2) { return __CCAffineTransformMake( t1.a * t2.a + t1.b * t2.c, t1.a * t2.b + t1.b * t2.d, //a,b t1.c * t2.a + t1.d * t2.c, t1.c * t2.b + t1.d * t2.d, //c,d t1.tx * t2.a + t1.ty * t2.c + t2.tx, //tx t1.tx * t2.b + t1.ty * t2.d + t2.ty); //ty } kmMat4 TransformConcat(const kmMat4& t1, const kmMat4& t2) { kmMat4 ret; kmMat4Multiply(&ret, &t1, &t2); return ret; } /* Return true if `t1' and `t2' are equal, false otherwise. */ bool AffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2) { return (t1.a == t2.a && t1.b == t2.b && t1.c == t2.c && t1.d == t2.d && t1.tx == t2.tx && t1.ty == t2.ty); } AffineTransform AffineTransformInvert(const AffineTransform& t) { float determinant = 1 / (t.a * t.d - t.b * t.c); return __CCAffineTransformMake(determinant * t.d, -determinant * t.b, -determinant * t.c, determinant * t.a, determinant * (t.c * t.ty - t.d * t.tx), determinant * (t.b * t.tx - t.a * t.ty) ); } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCAffineTransform.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __COCOA_CGAFFINETRANSFORM_H__ #define __COCOA_CGAFFINETRANSFORM_H__ #include "CCGeometry.h" #include "CCPlatformMacros.h" #include "kazmath/kazmath.h" NS_CC_BEGIN struct AffineTransform { float a, b, c, d; float tx, ty; static const AffineTransform IDENTITY; }; CC_DLL AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty); #define AffineTransformMake __CCAffineTransformMake CC_DLL Point __CCPointApplyAffineTransform(const Point& point, const AffineTransform& t); #define PointApplyAffineTransform __CCPointApplyAffineTransform CC_DLL Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t); #define SizeApplyAffineTransform __CCSizeApplyAffineTransform CC_DLL AffineTransform AffineTransformMakeIdentity(); CC_DLL Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform); CC_DLL Rect RectApplyTransform(const Rect& rect, const kmMat4& transform); CC_DLL Point PointApplyTransform(const Point& point, const kmMat4& transform); CC_DLL AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty); CC_DLL AffineTransform AffineTransformRotate(const AffineTransform& aTransform, float anAngle); CC_DLL AffineTransform AffineTransformScale(const AffineTransform& t, float sx, float sy); CC_DLL AffineTransform AffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2); CC_DLL bool AffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2); CC_DLL AffineTransform AffineTransformInvert(const AffineTransform& t); kmMat4 TransformConcat(const kmMat4& t1, const kmMat4& t2); extern CC_DLL const AffineTransform AffineTransformIdentity; NS_CC_END #endif // __COCOA_CGAFFINETRANSFORM_H__ ================================================ FILE: cocos2d/cocos/base/CCArray.cpp ================================================ /**************************************************************************** Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCArray.h" #include "CCString.h" #include "platform/CCFileUtils.h" NS_CC_BEGIN #if CC_USE_ARRAY_VECTOR // ---------------------------------------------------------------------------------- // std::vector implementation // ---------------------------------------------------------------------------------- __Array::__Array() : data(NULL) { init(); } __Array* __Array::create() { __Array* array = new __Array(); if (array && array->initWithCapacity(7)) { array->autorelease(); } else { CC_SAFE_DELETE(array); } return array; } __Array* __Array::createWithObject(Object* object) { __Array* array = new __Array(); if (array && array->initWithObject(object)) { array->autorelease(); } else { CC_SAFE_DELETE(array); } return array; } __Array* __Array::create(Object* object, ...) { va_list args; va_start(args,object); __Array* array = create(); if (array && object) { array->addObject(object); Object *i = va_arg(args, Object*); while (i) { array->addObject(i); i = va_arg(args, Object*); } } else { CC_SAFE_DELETE(array); } va_end(args); return array; } __Array* __Array::createWithArray(__Array* otherArray) { return otherArray->clone(); } __Array* __Array::createWithCapacity(int capacity) { CCASSERT(capacity>=0, "Invalid capacity"); __Array* array = new __Array(); if (array && array->initWithCapacity(capacity)) { array->autorelease(); } else { CC_SAFE_DELETE(array); } return array; } __Array* __Array::createWithContentsOfFile(const std::string& fileName) { __Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName); if (ret != nullptr) { ret->autorelease(); } return ret; } __Array* __Array::createWithContentsOfFileThreadSafe(const std::string& fileName) { return FileUtils::getInstance()->createArrayWithContentsOfFile(fileName); } bool __Array::init() { return initWithCapacity(7); } bool __Array::initWithObject(Object* object) { bool ret = initWithCapacity(7); if (ret) { addObject(object); } return ret; } /** Initializes an array with some objects */ bool __Array::initWithObjects(Object* object, ...) { bool ret = false; do { CC_BREAK_IF(object == nullptr); va_list args; va_start(args, object); if (object) { this->addObject(object); Object* i = va_arg(args, Object*); while (i) { this->addObject(i); i = va_arg(args, Object*); } ret = true; } va_end(args); } while (false); return ret; } bool __Array::initWithCapacity(int capacity) { CCASSERT(capacity>=0, "Invalid capacity"); data.reserve(capacity); return true; } bool __Array::initWithArray(__Array* otherArray) { data = otherArray->data; return true; } ssize_t __Array::getIndexOfObject(Object* object) const { auto it = data.begin(); for (ssize_t i = 0; it != data.end(); ++it, ++i) { if (it->get() == object) { return i; } } return -1; } Object* __Array::getRandomObject() { if (data.size()==0) { return nullptr; } float r = CCRANDOM_0_1(); if (r == 1) // to prevent from accessing data-arr[data->num], out of range. { r = 0; } r *= data.size(); return data[r].get(); } bool __Array::containsObject(Object* object) const { ssize_t i = this->getIndexOfObject(object); return (i >= 0); } bool __Array::isEqualToArray(__Array* otherArray) { for (ssize_t i = 0; i < this->count(); ++i) { if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) { return false; } } return true; } void __Array::addObject(Object* object) { data.push_back(RCPtr(object)); } void __Array::addObjectsFromArray(__Array* otherArray) { data.insert(data.end(), otherArray->data.begin(), otherArray->data.end()); } void __Array::insertObject(Object* object, int index) { data.insert(std::begin(data) + index, RCPtr(object)); } void __Array::setObject(Object* object, int index) { data[index] = RCPtr(object); } void __Array::removeLastObject(bool releaseObj) { CCASSERT(data.size(), "no objects added"); data.pop_back(); } void __Array::removeObject(Object* object, bool releaseObj /* ignored */) { data.erase(std::remove(data.begin(), data.end(), object)); } void __Array::removeObjectAtIndex(ssize_t index, bool releaseObj /* ignored */) { auto obj = data[index]; data.erase(data.begin() + index); } void __Array::removeObjectsInArray(__Array* otherArray) { CCASSERT(false, "not implemented"); } void __Array::removeAllObjects() { data.erase(std::begin(data), std::end(data)); } void __Array::fastRemoveObjectAtIndex(int index) { removeObjectAtIndex(index); } void __Array::fastRemoveObject(Object* object) { removeObject(object); } void __Array::exchangeObject(Object* object1, Object* object2) { ssize_t idx1 = getIndexOfObject(object1); ssize_t idx2 = getIndexOfObject(object2); CCASSERT(idx1 >= 0 && idx2 >= 2, "invalid object index"); std::swap(data[idx1], data[idx2]); } void __Array::exchangeObjectAtIndex(ssize_t index1, ssize_t index2) { std::swap(data[index1], data[index2]); } void __Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject /* ignored */) { data[index] = object; } void __Array::reverseObjects() { std::reverse(std::begin(data), std::end(data)); } void __Array::reduceMemoryFootprint() { // N/A } __Array::~Array() { CCLOGINFO("deallocing Array: %p - len: %d", this, count() ); } __Array* __Array::clone() const { __Array* ret = new __Array(); ret->autorelease(); ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1); Object* obj = nullptr; Object* tmpObj = nullptr; Clonable* clonable = nullptr; CCARRAY_FOREACH(this, obj) { clonable = dynamic_cast(obj); if (clonable) { tmpObj = dynamic_cast(clonable->clone()); if (tmpObj) { ret->addObject(tmpObj); } } else { CCLOGWARN("%s isn't clonable.", typeid(*obj).name()); } } return ret; } void __Array::acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } // ---------------------------------------------------------------------------------- // ccArray implementation // ---------------------------------------------------------------------------------- #else __Array::__Array() : data(nullptr) { // init(); } __Array* __Array::create() { __Array* array = new __Array(); if (array && array->initWithCapacity(7)) { array->autorelease(); } else { CC_SAFE_DELETE(array); } return array; } __Array* __Array::createWithObject(Object* object) { __Array* array = new __Array(); if (array && array->initWithObject(object)) { array->autorelease(); } else { CC_SAFE_DELETE(array); } return array; } __Array* __Array::create(Object* object, ...) { va_list args; va_start(args,object); __Array* array = create(); if (array && object) { array->addObject(object); Object *i = va_arg(args, Object*); while (i) { array->addObject(i); i = va_arg(args, Object*); } } else { CC_SAFE_DELETE(array); } va_end(args); return array; } __Array* __Array::createWithArray(__Array* otherArray) { return otherArray->clone(); } __Array* __Array::createWithCapacity(ssize_t capacity) { CCASSERT(capacity>=0, "Invalid capacity"); __Array* array = new __Array(); if (array && array->initWithCapacity(capacity)) { array->autorelease(); } else { CC_SAFE_DELETE(array); } return array; } __Array* __Array::createWithContentsOfFile(const std::string& fileName) { __Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName); if (ret != nullptr) { ret->autorelease(); } return ret; } __Array* __Array::createWithContentsOfFileThreadSafe(const std::string& fileName) { ValueVector arr = FileUtils::getInstance()->getValueVectorFromFile(fileName); __Array* ret = __Array::createWithCapacity(static_cast(arr.size())); for(const auto &value : arr) { ret->addObject(__String::create(value.asString())); } return ret; } bool __Array::init() { CCASSERT(!data, "Array cannot be re-initialized"); return initWithCapacity(7); } bool __Array::initWithObject(Object* object) { CCASSERT(!data, "Array cannot be re-initialized"); bool ret = initWithCapacity(7); if (ret) { addObject(object); } return ret; } /** Initializes an array with some objects */ bool __Array::initWithObjects(Object* object, ...) { CCASSERT(!data, "Array cannot be re-initialized"); bool ret = false; do { CC_BREAK_IF(object == nullptr); va_list args; va_start(args, object); if (object) { this->addObject(object); Object* i = va_arg(args, Object*); while (i) { this->addObject(i); i = va_arg(args, Object*); } ret = true; } va_end(args); } while (false); return ret; } bool __Array::initWithCapacity(ssize_t capacity) { CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized"); data = ccArrayNew(capacity); return true; } bool __Array::initWithArray(__Array* otherArray) { CCASSERT(!data, "Array cannot be re-initialized"); bool ret = false; do { CC_BREAK_IF(! initWithCapacity(otherArray->data->num)); addObjectsFromArray(otherArray); ret = true; } while (0); return ret; } ssize_t __Array::getIndexOfObject(Object* object) const { return ccArrayGetIndexOfObject(data, object); } Object* __Array::getRandomObject() { if (data->num == 0) { return nullptr; } float r = CCRANDOM_0_1(); if (r == 1) // to prevent from accessing data-arr[data->num], out of range. { r = 0; } return data->arr[static_cast(data->num * r)]; } bool __Array::containsObject(Object* object) const { return ccArrayContainsObject(data, object); } bool __Array::isEqualToArray(__Array* otherArray) { for (int i = 0; i < this->count(); ++i) { if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i))) { return false; } } return true; } void __Array::addObject(Object* object) { CCASSERT(data, "Array not initialized"); ccArrayAppendObjectWithResize(data, object); } void __Array::addObjectsFromArray(__Array* otherArray) { CCASSERT(data, "Array not initialized"); ccArrayAppendArrayWithResize(data, otherArray->data); } void __Array::insertObject(Object* object, ssize_t index) { CCASSERT(data, "Array not initialized"); ccArrayInsertObjectAtIndex(data, object, index); } void __Array::setObject(Object* object, ssize_t index) { CCASSERT(index >= 0 && index < count(), "Invalid index"); if (object != data->arr[index]) { data->arr[index]->release(); data->arr[index] = object; object->retain(); } } void __Array::removeLastObject(bool releaseObj) { CCASSERT(data->num, "no objects added"); ccArrayRemoveObjectAtIndex(data, data->num - 1, releaseObj); } void __Array::removeObject(Object* object, bool releaseObj/* = true*/) { ccArrayRemoveObject(data, object, releaseObj); } void __Array::removeObjectAtIndex(ssize_t index, bool releaseObj) { ccArrayRemoveObjectAtIndex(data, index, releaseObj); } void __Array::removeObjectsInArray(__Array* otherArray) { ccArrayRemoveArray(data, otherArray->data); } void __Array::removeAllObjects() { ccArrayRemoveAllObjects(data); } void __Array::fastRemoveObjectAtIndex(ssize_t index) { ccArrayFastRemoveObjectAtIndex(data, index); } void __Array::fastRemoveObject(Object* object) { ccArrayFastRemoveObject(data, object); } void __Array::exchangeObject(Object* object1, Object* object2) { auto index1 = ccArrayGetIndexOfObject(data, object1); if (index1 == CC_INVALID_INDEX) { return; } auto index2 = ccArrayGetIndexOfObject(data, object2); if (index2 == CC_INVALID_INDEX) { return; } ccArraySwapObjectsAtIndexes(data, index1, index2); } void __Array::exchangeObjectAtIndex(ssize_t index1, ssize_t index2) { ccArraySwapObjectsAtIndexes(data, index1, index2); } void __Array::replaceObjectAtIndex(ssize_t index, Object* object, bool releaseObject/* = true*/) { ccArrayInsertObjectAtIndex(data, object, index); ccArrayRemoveObjectAtIndex(data, index + 1); } void __Array::reverseObjects() { if (data->num > 1) { // floorf(), since in the case of an even number, the number of swaps stays the same auto count = static_cast(floorf(data->num/2.f)); ssize_t maxIndex = data->num - 1; for (ssize_t i = 0; i < count ; ++i) { ccArraySwapObjectsAtIndexes(data, i, maxIndex); --maxIndex; } } } void __Array::reduceMemoryFootprint() { ccArrayShrink(data); } __Array::~__Array() { CCLOGINFO("deallocing Array: %p - len: %d", this, count() ); ccArrayFree(data); } __Array* __Array::clone() const { __Array* ret = new __Array(); ret->autorelease(); ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1); Object* obj = nullptr; Object* tmpObj = nullptr; Clonable* clonable = nullptr; CCARRAY_FOREACH(this, obj) { clonable = dynamic_cast(obj); if (clonable) { tmpObj = dynamic_cast(clonable->clone()); if (tmpObj) { ret->addObject(tmpObj); } } else { CCLOGWARN("%s isn't clonable.", typeid(*obj).name()); } } return ret; } void __Array::acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } #endif // uses ccArray NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCArray.h ================================================ /**************************************************************************** Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCARRAY_H__ #define __CCARRAY_H__ #define CC_USE_ARRAY_VECTOR 0 #if CC_USE_ARRAY_VECTOR #include #include #include "CCObject.h" #include "ccMacros.h" #else #include "ccCArray.h" #endif #if CC_USE_ARRAY_VECTOR /** * A reference counting-managed pointer for classes derived from RCBase which can * be used as C pointer * Original code: http://www.codeproject.com/Articles/64111/Building-a-Quick-and-Handy-Reference-Counting-Clas * License: http://www.codeproject.com/info/cpol10.aspx */ template < class T > class RCPtr { public: //Construct using a C pointer //e.g. RCPtr< T > x = new T(); RCPtr(T* ptr = nullptr) : _ptr(ptr) { if(ptr != nullptr) {ptr->retain();} } //Copy constructor RCPtr(const RCPtr &ptr) : _ptr(ptr._ptr) { // printf("Array: copy constructor: %p\n", this); if(_ptr != NULL) {_ptr->retain();} } //Move constructor RCPtr(RCPtr &&ptr) : _ptr(ptr._ptr) { // printf("Array: Move Constructor: %p\n", this); ptr._ptr = nullptr; } ~RCPtr() { // printf("Array: Destructor: %p\n", this); if(_ptr != nullptr) {_ptr->release();} } //Assign a pointer //e.g. x = new T(); RCPtr &operator=(T* ptr) { // printf("Array: operator= T*: %p\n", this); //The following grab and release operations have to be performed //in that order to handle the case where ptr == _ptr //(See comment below by David Garlisch) if(ptr != nullptr) {ptr->retain();} if(_ptr != nullptr) {_ptr->release();} _ptr = ptr; return (*this); } //Assign another RCPtr RCPtr &operator=(const RCPtr &ptr) { // printf("Array: operator= const&: %p\n", this); return (*this) = ptr._ptr; } //Retrieve actual pointer T* get() const { return _ptr; } //Some overloaded operators to facilitate dealing with an RCPtr //as a conventional C pointer. //Without these operators, one can still use the less transparent //get() method to access the pointer. T* operator->() const {return _ptr;} //x->member T &operator*() const {return *_ptr;} //*x, (*x).member explicit operator T*() const {return _ptr;} //T* y = x; explicit operator bool() const {return _ptr != nullptr;} //if(x) {/*x is not NULL*/} bool operator==(const RCPtr &ptr) {return _ptr == ptr._ptr;} bool operator==(const T *ptr) {return _ptr == ptr;} private: T *_ptr; //Actual pointer }; #endif // CC_USE_ARRAY_VECTOR /** * @addtogroup data_structures * @{ */ /** @def CCARRAY_FOREACH A convenience macro to iterate over a Array using. It is faster than the "fast enumeration" interface. @since v0.99.4 */ /* In cocos2d-iphone 1.0.0, This macro have been update to like this: #define CCARRAY_FOREACH(__array__, __object__) \ if (__array__ && __array__->data->num > 0) \ for(id *__arr__ = __array__->data->arr, *end = __array__->data->arr + __array__->data->num-1; \ __arr__ <= end && ((__object__ = *__arr__) != nil || true); \ __arr__++) I found that it's not work in C++. So it keep what it's look like in version 1.0.0-rc3. ---By Bin */ #if CC_USE_ARRAY_VECTOR #define CCARRAY_FOREACH(__array__, __object__) \ if (__array__) \ for( auto __it__ = (__array__)->data.begin(); \ __it__ != (__array__)->data.end() && ((__object__) = __it__->get()) != nullptr; \ ++__it__) #define CCARRAY_FOREACH_REVERSE(__array__, __object__) \ if (__array__) \ for( auto __it__ = (__array__)->data.rbegin(); \ __it__ != (__array__)->data.rend() && ((__object__) = __it__->get()) != nullptr; \ ++__it__ ) #define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0) #else // ! CC_USE_ARRAY_VECTOR -------------------------- #define CCARRAY_FOREACH(__array__, __object__) \ if ((__array__) && (__array__)->data->num > 0) \ for(Object** __arr__ = (__array__)->data->arr, **__end__ = (__array__)->data->arr + (__array__)->data->num-1; \ __arr__ <= __end__ && (((__object__) = *__arr__) != NULL/* || true*/); \ __arr__++) #define CCARRAY_FOREACH_REVERSE(__array__, __object__) \ if ((__array__) && (__array__)->data->num > 0) \ for(Object** __arr__ = (__array__)->data->arr + (__array__)->data->num-1, **__end__ = (__array__)->data->arr; \ __arr__ >= __end__ && (((__object__) = *__arr__) != NULL/* || true*/); \ __arr__--) #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) #define CCARRAY_VERIFY_TYPE(__array__, __type__) \ do { \ if ((__array__) && (__array__)->data->num > 0) \ for(Object** __arr__ = (__array__)->data->arr, \ **__end__ = (__array__)->data->arr + (__array__)->data->num-1; __arr__ <= __end__; __arr__++) \ CCASSERT(dynamic_cast<__type__>(*__arr__), "element type is wrong!"); \ } while(false) #else #define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0) #endif #endif // ! CC_USE_ARRAY_VECTOR // Common defines ----------------------------------------------------------------------------------------------- #define arrayMakeObjectsPerformSelector(pArray, func, elementType) \ do { \ if(pArray && pArray->count() > 0) \ { \ Object* child; \ CCARRAY_FOREACH(pArray, child) \ { \ elementType pNode = static_cast(child); \ if(pNode) \ { \ pNode->func(); \ } \ } \ } \ } \ while(false) #define arrayMakeObjectsPerformSelectorWithObject(pArray, func, object, elementType) \ do { \ if(pArray && pArray->count() > 0) \ { \ Object* child; \ CCARRAY_FOREACH(pArray, child) \ { \ elementType pNode = static_cast(child); \ if(pNode) \ { \ pNode->func(object); \ } \ } \ } \ } \ while(false) NS_CC_BEGIN class CC_DLL __Array : public Object, public Clonable { public: /** Creates an empty array. Default capacity is 10 * @js NA * @lua NA */ static __Array* create(); /** Create an array with objects * @js NA */ static __Array* create(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; /** Create an array with one object * @js NA */ static __Array* createWithObject(Object* object); /** Create an array with a default capacity * @js NA */ static __Array* createWithCapacity(ssize_t capacity); /** Create an array with from an existing array * @js NA */ static __Array* createWithArray(__Array* otherArray); /** @brief Generate a Array pointer by file @param pFileName The file name of *.plist file @return The Array pointer generated from the file * @js NA */ static __Array* createWithContentsOfFile(const std::string& pFileName); /* @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). * @js NA * @lua NA */ static __Array* createWithContentsOfFileThreadSafe(const std::string& pFileName); /** * @js NA * @lua NA */ ~__Array(); /** Initializes an array * @js NA * @lua NA */ bool init(); /** Initializes an array with one object * @js NA * @lua NA */ bool initWithObject(Object* object); /** Initializes an array with some objects * @js NA * @lua NA */ bool initWithObjects(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; /** Initializes an array with capacity * @js NA * @lua NA */ bool initWithCapacity(ssize_t capacity); /** Initializes an array with an existing array * @js NA * @lua NA */ bool initWithArray(__Array* otherArray); // Querying an Array /** Returns element count of the array * @js NA */ ssize_t count() const { #if CC_USE_ARRAY_VECTOR return data.size(); #else return data->num; #endif } /** Returns capacity of the array * @js NA */ ssize_t capacity() const { #if CC_USE_ARRAY_VECTOR return data.capacity(); #else return data->max; #endif } /** Returns index of a certain object, return UINT_MAX if doesn't contain the object * @js NA * @lua NA */ ssize_t getIndexOfObject(Object* object) const; /** * @js NA */ CC_DEPRECATED_ATTRIBUTE ssize_t indexOfObject(Object* object) const { return getIndexOfObject(object); } /** Returns an element with a certain index * @js NA * @lua NA */ Object* getObjectAtIndex(ssize_t index) { CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()"); #if CC_USE_ARRAY_VECTOR return data[index].get(); #else return data->arr[index]; #endif } CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(ssize_t index) { return getObjectAtIndex(index); } /** Returns the last element of the array * @js NA */ Object* getLastObject() { #if CC_USE_ARRAY_VECTOR return data.back().get(); #else if(data->num > 0) return data->arr[data->num-1]; return nullptr; #endif } /** * @js NA */ CC_DEPRECATED_ATTRIBUTE Object* lastObject() { return getLastObject(); } /** Returns a random element * @js NA * @lua NA */ Object* getRandomObject(); /** * @js NA */ CC_DEPRECATED_ATTRIBUTE Object* randomObject() { return getRandomObject(); } /** Returns a Boolean value that indicates whether object is present in array. * @js NA */ bool containsObject(Object* object) const; /** @since 1.1 * @js NA */ bool isEqualToArray(__Array* otherArray); // Adding Objects /** Add a certain object * @js NA */ void addObject(Object* object); /** * @js NA */ /** Add all elements of an existing array * @js NA */ void addObjectsFromArray(__Array* otherArray); /** Insert a certain object at a certain index * @js NA */ void insertObject(Object* object, ssize_t index); /** sets a certain object at a certain index * @js NA * @lua NA */ void setObject(Object* object, ssize_t index); /** sets a certain object at a certain index without retaining. Use it with caution * @js NA * @lua NA */ void fastSetObject(Object* object, ssize_t index) { #if CC_USE_ARRAY_VECTOR setObject(object, index); #else // no retain data->arr[index] = object; #endif } /** * @js NA * @lua NA */ void swap( ssize_t indexOne, ssize_t indexTwo ) { CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices"); #if CC_USE_ARRAY_VECTOR std::swap(data[indexOne], data[indexTwo]); #else std::swap(data->arr[indexOne], data->arr[indexTwo]); #endif } // Removing Objects /** Remove last object * @js NA */ void removeLastObject(bool releaseObj = true); /** Remove a certain object * @js NA */ void removeObject(Object* object, bool releaseObj = true); /** Remove an element with a certain index * @js NA */ void removeObjectAtIndex(ssize_t index, bool releaseObj = true); /** Remove all elements * @js NA */ void removeObjectsInArray(__Array* otherArray); /** Remove all objects * @js NA */ void removeAllObjects(); /** Fast way to remove a certain object * @js NA */ void fastRemoveObject(Object* object); /** Fast way to remove an element with a certain index * @js NA */ void fastRemoveObjectAtIndex(ssize_t index); // Rearranging Content /** Swap two elements * @js NA */ void exchangeObject(Object* object1, Object* object2); /** Swap two elements with certain indexes * @js NA */ void exchangeObjectAtIndex(ssize_t index1, ssize_t index2); /** Replace object at index with another object. * @js NA */ void replaceObjectAtIndex(ssize_t index, Object* object, bool releaseObject = true); /** Revers the array * @js NA */ void reverseObjects(); /* Shrinks the array so the memory footprint corresponds with the number of items * @js NA */ void reduceMemoryFootprint(); /* override functions * @js NA */ virtual void acceptVisitor(DataVisitor &visitor); /** * @js NA * @lua NA */ virtual __Array* clone() const; // ------------------------------------------ // Iterators // ------------------------------------------ #if CC_USE_ARRAY_VECTOR typedef std::vector>::iterator iterator; typedef std::vector>::const_iterator const_iterator; /** * @js NA * @lua NA */ iterator begin() { return data.begin(); } /** * @js NA * @lua NA */ iterator end() { return data.end(); } const_iterator cbegin() { return data.cbegin(); } /** * @js NA * @lua NA */ const_iterator cend() { return data.cend(); } std::vector> data; #else /** * @js NA * @lua NA */ Object** begin() { return &data->arr[0]; } /** * @js NA * @lua NA */ Object** end() { return &data->arr[data->num]; } ccArray* data; #endif //protected: /** * @js NA * @lua NA */ __Array(); }; // end of data_structure group /// @} NS_CC_END #endif // __CCARRAY_H__ ================================================ FILE: cocos2d/cocos/base/CCAutoreleasePool.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAutoreleasePool.h" #include "ccMacros.h" NS_CC_BEGIN AutoreleasePool::AutoreleasePool() : _name("") #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) , _isClearing(false) #endif { _managedObjectArray.reserve(150); PoolManager::getInstance()->push(this); } AutoreleasePool::AutoreleasePool(const std::string &name) : _name(name) #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) , _isClearing(false) #endif { _managedObjectArray.reserve(150); PoolManager::getInstance()->push(this); } AutoreleasePool::~AutoreleasePool() { CCLOGINFO("deallocing AutoreleasePool: %p", this); clear(); PoolManager::getInstance()->pop(); } void AutoreleasePool::addObject(Object* object) { _managedObjectArray.push_back(object); } void AutoreleasePool::clear() { #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) _isClearing = true; #endif for (const auto &obj : _managedObjectArray) { obj->release(); } _managedObjectArray.clear(); #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) _isClearing = false; #endif } bool AutoreleasePool::contains(Object* object) const { for (const auto& obj : _managedObjectArray) { if (obj == object) return true; } return false; } void AutoreleasePool::dump() { CCLOG("autorelease pool: %s, number of managed object %d\n", _name.c_str(), static_cast(_managedObjectArray.size())); CCLOG("%20s%20s%20s", "Object pointer", "Object id", "reference count"); for (const auto &obj : _managedObjectArray) { CCLOG("%20p%20u%20u\n", obj, obj->_ID, obj->getReferenceCount()); } } //-------------------------------------------------------------------- // // PoolManager // //-------------------------------------------------------------------- PoolManager* PoolManager::s_singleInstance = nullptr; PoolManager* PoolManager::getInstance() { if (s_singleInstance == nullptr) { s_singleInstance = new PoolManager(); // Add the first auto release pool s_singleInstance->_curReleasePool = new AutoreleasePool("cocos2d autorelease pool"); s_singleInstance->_releasePoolStack.push_back(s_singleInstance->_curReleasePool); } return s_singleInstance; } void PoolManager::destroyInstance() { delete s_singleInstance; s_singleInstance = nullptr; } PoolManager::PoolManager() { } PoolManager::~PoolManager() { CCLOGINFO("deallocing PoolManager: %p", this); while (!_releasePoolStack.empty()) { AutoreleasePool* pool = _releasePoolStack.back(); _releasePoolStack.pop_back(); delete pool; } } AutoreleasePool* PoolManager::getCurrentPool() const { return _curReleasePool; } bool PoolManager::isObjectInPools(Object* obj) const { for (const auto& pool : _releasePoolStack) { if (pool->contains(obj)) return true; } return false; } void PoolManager::push(AutoreleasePool *pool) { _releasePoolStack.push_back(pool); _curReleasePool = pool; } void PoolManager::pop() { // Can not pop the pool that created by engine CC_ASSERT(_releasePoolStack.size() >= 1); _releasePoolStack.pop_back(); // Should update _curReleasePool if a temple pool is released if (_releasePoolStack.size() > 1) { _curReleasePool = _releasePoolStack.back(); } } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCAutoreleasePool.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __AUTORELEASEPOOL_H__ #define __AUTORELEASEPOOL_H__ #include #include #include #include "CCObject.h" NS_CC_BEGIN /** * @addtogroup base_nodes * @{ */ class CC_DLL AutoreleasePool { public: /** * @warn Don't create an auto release pool in heap, create it in stack. * @js NA * @lua NA */ AutoreleasePool(); /** * Create an autorelease pool with specific name. This name is useful for debugging. */ AutoreleasePool(const std::string &name); /** * @js NA * @lua NA */ ~AutoreleasePool(); /** * Add a given object to this pool. * * The same object may be added several times to the same pool; When the * pool is destructed, the object's Object::release() method will be called * for each time it was added. * * @param object The object to add to the pool. * @js NA * @lua NA */ void addObject(Object *object); /** * Clear the autorelease pool. * * Object::release() will be called for each time the managed object is * added to the pool. * @js NA * @lua NA */ void clear(); #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) /** * Whether the pool is doing `clear` operation. */ bool isClearing() const { return _isClearing; }; #endif /** * Checks whether the pool contains the specified object. */ bool contains(Object* object) const; /** * Dump the objects that are put into autorelease pool. It is used for debugging. * * The result will look like: * Object pointer address object id reference count * */ void dump(); private: /** * The underlying array of object managed by the pool. * * Although Array retains the object once when an object is added, proper * Object::release() is called outside the array to make sure that the pool * does not affect the managed object's reference count. So an object can * be destructed properly by calling Object::release() even if the object * is in the pool. */ std::vector _managedObjectArray; std::string _name; #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) /** * The flag for checking whether the pool is doing `clear` operation. */ bool _isClearing; #endif }; class CC_DLL PoolManager { public: /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static PoolManager* sharedPoolManager() { return getInstance(); } static PoolManager* getInstance(); /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static void purgePoolManager() { destroyInstance(); } static void destroyInstance(); /** * Get current auto release pool, there is at least one auto release pool that created by engine. * You can create your own auto release pool at demand, which will be put into auto releae pool stack. */ AutoreleasePool *getCurrentPool() const; bool isObjectInPools(Object* obj) const; /** * @js NA * @lua NA */ friend class AutoreleasePool; private: PoolManager(); ~PoolManager(); void push(AutoreleasePool *pool); void pop(); static PoolManager* s_singleInstance; std::deque _releasePoolStack; AutoreleasePool *_curReleasePool; }; // end of base_nodes group /// @} NS_CC_END #endif //__AUTORELEASEPOOL_H__ ================================================ FILE: cocos2d/cocos/base/CCBool.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCBOOL_H__ #define __CCBOOL_H__ #include "CCObject.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ class CC_DLL __Bool : public Object, public Clonable { public: __Bool(bool v) : _value(v) {} bool getValue() const {return _value;} static __Bool* create(bool v) { __Bool* pRet = new __Bool(v); if (pRet) { pRet->autorelease(); } return pRet; } /* override functions */ virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } __Bool* clone() const { return __Bool::create(_value); } private: bool _value; }; // end of data_structure group /// @} NS_CC_END #endif /* __CCBOOL_H__ */ ================================================ FILE: cocos2d/cocos/base/CCConsole.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCConsole.h" #include #include #include #include #include #if defined(_MSC_VER) || defined(__MINGW32__) #include #include #define bzero(a, b) memset(a, 0, b); #else #include #include #include #include #include #include #endif #include "CCDirector.h" #include "CCScheduler.h" #include "CCScene.h" #include "CCPlatformConfig.h" #include "platform/CCFileUtils.h" #include "CCConfiguration.h" #include "CCTextureCache.h" NS_CC_BEGIN // helper free functions // dprintf() is not defined in Android // so we add our own 'dpritnf' static ssize_t mydprintf(int sock, const char *format, ...) { va_list args; char buf[16386]; va_start(args, format); vsnprintf(buf, sizeof(buf), format, args); va_end(args); return write(sock, buf, strlen(buf)); } static int printSceneGraph(int fd, Node* node, int level) { int total = 1; for(int i=0; igetDescription().c_str()); for(const auto& child: node->getChildren()) total += printSceneGraph(fd, child, level+1); return total; } static void printSceneGraphBoot(int fd) { write(fd,"\n",1); auto scene = Director::getInstance()->getRunningScene(); int total = printSceneGraph(fd, scene, 0); mydprintf(fd, "Total Nodes: %d\n", total); } static void printFileUtils(int fd) { FileUtils* fu = FileUtils::getInstance(); mydprintf(fd, "\nSearch Paths:\n"); auto list = fu->getSearchPaths(); for( const auto &item : list) { mydprintf(fd, "%s\n", item.c_str()); } mydprintf(fd, "\nResolution Order:\n"); list = fu->getSearchResolutionsOrder(); for( const auto &item : list) { mydprintf(fd, "%s\n", item.c_str()); } mydprintf(fd, "\nWriteble Path:\n"); mydprintf(fd, "%s\n", fu->getWritablePath().c_str()); mydprintf(fd, "\nFull Path Cache:\n"); auto cache = fu->getFullPathCache(); for( const auto &item : cache) { mydprintf(fd, "%s -> %s\n", item.first.c_str(), item.second.c_str()); } } #if defined(__MINGW32__) static const char* inet_ntop(int af, const void* src, char* dst, int cnt) { struct sockaddr_in srcaddr; memset(&srcaddr, 0, sizeof(struct sockaddr_in)); memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr)); srcaddr.sin_family = af; if (WSAAddressToString((struct sockaddr*) &srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD) &cnt) != 0) { return nullptr; } return dst; } #endif // // Free functions to log // static void _log(const char *format, va_list args) { char buf[MAX_LOG_LENGTH]; vsnprintf(buf, MAX_LOG_LENGTH-3, format, args); strcat(buf, "\n"); #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf); #elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 WCHAR wszBuf[MAX_LOG_LENGTH] = {0}; MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf)); OutputDebugStringW(wszBuf); OutputDebugStringA("\n"); WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), buf, sizeof(buf), NULL, FALSE); printf("%s\n", buf); #else // Linux, Mac, iOS, etc fprintf(stdout, "cocos2d: %s", buf); fflush(stdout); #endif Director::getInstance()->getConsole()->log(buf); } // XXX: Deprecated void CCLog(const char * format, ...) { va_list args; va_start(args, format); _log(format, args); va_end(args); } void log(const char * format, ...) { va_list args; va_start(args, format); _log(format, args); va_end(args); } // // Console code // Console::Console() : _listenfd(-1) , _running(false) , _endThread(false) , _userCommands(nullptr) , _maxUserCommands(0) , _sendDebugStrings(false) { // VS2012 doesn't support initializer list, so we create a new array and assign its elements to '_command'. Command commands[] = { { "config", std::bind(&Console::commandConfig, this, std::placeholders::_1, std::placeholders::_2) }, { "debug msg on", [&](int fd, const char* command) { _sendDebugStrings = true; } }, { "debug msg off", [&](int fd, const char* command) { _sendDebugStrings = false; } }, { "exit", std::bind(&Console::commandExit, this, std::placeholders::_1, std::placeholders::_2) }, { "fileutils dump", std::bind(&Console::commandFileUtilsDump, this, std::placeholders::_1, std::placeholders::_2) }, { "fps on", [](int fd, const char* command) { Director *dir = Director::getInstance(); Scheduler *sched = dir->getScheduler(); sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, true)); } }, { "fps off", [](int fd, const char* command) { Director *dir = Director::getInstance(); Scheduler *sched = dir->getScheduler(); sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, false)); } }, { "help", std::bind(&Console::commandHelp, this, std::placeholders::_1, std::placeholders::_2) }, { "scene graph", std::bind(&Console::commandSceneGraph, this, std::placeholders::_1, std::placeholders::_2) }, { "textures", std::bind(&Console::commandTextures, this, std::placeholders::_1, std::placeholders::_2) }, }; _maxCommands = sizeof(commands)/sizeof(commands[0]); for (int i = 0; i < _maxCommands; ++i) { _commands[i] = commands[i]; } } Console::~Console() { stop(); } bool Console::listenOnTCP(int port) { int listenfd, n; const int on = 1; struct addrinfo hints, *res, *ressave; char serv[30]; snprintf(serv, sizeof(serv)-1, "%d", port ); serv[sizeof(serv)-1]=0; bzero(&hints, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; hints.ai_family = AF_INET; // AF_UNSPEC: Do we need IPv6 ? hints.ai_socktype = SOCK_STREAM; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) WSADATA wsaData; n = WSAStartup(MAKEWORD(2, 2),&wsaData); #endif if ( (n = getaddrinfo(NULL, serv, &hints, &res)) != 0) { fprintf(stderr,"net_listen error for %s: %s", serv, gai_strerror(n)); return false; } ressave = res; do { listenfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (listenfd < 0) continue; /* error, try next one */ setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)); if (bind(listenfd, res->ai_addr, res->ai_addrlen) == 0) break; /* success */ close(listenfd); /* bind error, close and try next one */ } while ( (res = res->ai_next) != NULL); if (res == NULL) { perror("net_listen:"); freeaddrinfo(ressave); return false; } listen(listenfd, 50); if (res->ai_family == AF_INET) { char buf[INET_ADDRSTRLEN] = ""; struct sockaddr_in *sin = (struct sockaddr_in*) res->ai_addr; if( inet_ntop(res->ai_family, &sin->sin_addr, buf, sizeof(buf)) != NULL ) cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin_port)); else perror("inet_ntop"); } else if (res->ai_family == AF_INET6) { char buf[INET6_ADDRSTRLEN] = ""; struct sockaddr_in6 *sin = (struct sockaddr_in6*) res->ai_addr; if( inet_ntop(res->ai_family, &sin->sin6_addr, buf, sizeof(buf)) != NULL ) cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port)); else perror("inet_ntop"); } freeaddrinfo(ressave); return listenOnFileDescriptor(listenfd); } bool Console::listenOnFileDescriptor(int fd) { if(_running) { cocos2d::log("Console already started. 'stop' it before calling 'listen' again"); return false; } _listenfd = fd; _thread = std::thread( std::bind( &Console::loop, this) ); return true; } void Console::stop() { if( _running ) { _endThread = true; _thread.join(); } } void Console::setUserCommands(Command *commands, int numberOfCommands) { _userCommands = commands; _maxUserCommands = numberOfCommands; } // // commands // void Console::commandHelp(int fd, const char* command) { const char help[] = "\nAvailable commands:\n"; write(fd, help, sizeof(help)); for(int i=0; i<_maxCommands; ++i) { write(fd,"\t",1); write(fd, _commands[i].name, strlen(_commands[i].name)); write(fd,"\n",1); } // User commands for(int i=0; i<_maxUserCommands; ++i) { write(fd,"\t",1); write(fd, _userCommands[i].name, strlen(_userCommands[i].name)); write(fd,"\n",1); } } void Console::commandExit(int fd, const char *command) { FD_CLR(fd, &_read_set); _fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end()); close(fd); } void Console::commandSceneGraph(int fd, const char *command) { Scheduler *sched = Director::getInstance()->getScheduler(); sched->performFunctionInCocosThread( std::bind(&printSceneGraphBoot, fd) ); } void Console::commandFileUtilsDump(int fd, const char *command) { Scheduler *sched = Director::getInstance()->getScheduler(); sched->performFunctionInCocosThread( std::bind(&printFileUtils, fd) ); } void Console::commandConfig(int fd, const char *command) { Scheduler *sched = Director::getInstance()->getScheduler(); sched->performFunctionInCocosThread( [&](){ mydprintf(fd, "%s", Configuration::getInstance()->getInfo().c_str()); } ); } void Console::commandTextures(int fd, const char *command) { Scheduler *sched = Director::getInstance()->getScheduler(); sched->performFunctionInCocosThread( [&](){ mydprintf(fd, "%s", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); } ); } bool Console::parseCommand(int fd) { auto r = readline(fd); if(r < 1) return false; bool found=false; for(int i=0; i < _maxCommands; ++i) { if( strncmp(_buffer, _commands[i].name,strlen(_commands[i].name)) == 0 ) { // XXX TODO FIXME // Ideally this loop should execute the function in the cocos2d according to a variable // But clang crashes in runtime when doing that (bug in clang, not in the code). // So, unfortunately, the only way to fix it was to move that logic to the callback itself _commands[i].callback(fd, _buffer); found = true; break; } } // user commands for(int i=0; i < _maxUserCommands && !found; ++i) { if( strncmp(_buffer, _userCommands[i].name,strlen(_userCommands[i].name)) == 0 ) { _userCommands[i].callback(fd, _buffer); found = true; break; } } if(!found && strcmp(_buffer, "\r\n")!=0) { const char err[] = "Unknown command. Type 'help' for options\n"; write(fd, err, sizeof(err)); } sendPrompt(fd); return true; } // // Helpers // void Console::sendPrompt(int fd) { const char prompt[] = "\n> "; write(fd, prompt, sizeof(prompt)); } ssize_t Console::readline(int fd) { int maxlen = sizeof(_buffer)-1; ssize_t n, rc; char c, *ptr; ptr = _buffer; for( n=1; n to_remove; for(const auto &fd: _fds) { if(FD_ISSET(fd,©_set)) { if( ! parseCommand(fd) ) { to_remove.push_back(fd); } if(--nready <= 0) break; } } /* remove closed conections */ for(int fd: to_remove) { FD_CLR(fd, &_read_set); _fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end()); } } /* Any message for the remote console ? send it! */ if( !_DebugStrings.empty() ) { _DebugStringsMutex.lock(); for(const auto &str : _DebugStrings) { for(const auto &fd : _fds) { write(fd, str.c_str(), str.length()); } } _DebugStrings.clear(); _DebugStringsMutex.unlock(); } } // clean up: ignore stdin, stdout and stderr for(const auto &fd: _fds ) close(fd); close(_listenfd); _running = false; } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCConsole.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCCONSOLE_H__ #define __CCCONSOLE_H__ #if defined(_MSC_VER) || defined(__MINGW32__) #include #include //typedef SSIZE_T ssize_t; // ssize_t was redefined as int in libwebsockets.h. // Therefore, to avoid conflict, we needs the same definition. typedef int ssize_t; #else #include #endif #include #include #include #include #include #include #include "ccMacros.h" #include "CCPlatformMacros.h" NS_CC_BEGIN /// The max length of CCLog message. static const int MAX_LOG_LENGTH = 16*1024; /** @brief Output Debug message. */ void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2); /** Console is helper class that lets the developer control the game from TCP connection. Console will spawn a new thread that will listen to a specified TCP port. Console has a basic token parser. Each token is associated with an std::function. If the std::function<> needs to use the cocos2d API, it needs to call ``` scheduler->performFunctionInCocosThread( ... ); ``` */ class CC_DLL Console { public: struct Command { const char *name; std::function callback; }; /** Constructor */ Console(); /** Destructor */ virtual ~Console(); /** starts listening to specifed TCP port */ bool listenOnTCP(int port); /** starts listening to specifed file descriptor */ bool listenOnFileDescriptor(int fd); /** stops the Console. 'stop' will be called at destruction time as well */ void stop(); /** sets user tokens */ void setUserCommands( Command* commands, int numberOfCommands); /** log something in the console */ void log(const char *buf); protected: void loop(); ssize_t readline(int fd); bool parseCommand(int fd); void sendPrompt(int fd); void addClient(); // Add commands here void commandHelp(int fd, const char *command); void commandExit(int fd, const char *command); void commandSceneGraph(int fd, const char *command); void commandFileUtilsDump(int fd, const char *command); void commandConfig(int fd, const char *command); void commandTextures(int fd, const char *command); // file descriptor: socket, console, etc. int _listenfd; int _maxfd; std::vector _fds; std::thread _thread; fd_set _read_set; bool _running; bool _endThread; char _buffer[512]; struct Command _commands[64]; int _maxCommands; struct Command *_userCommands; int _maxUserCommands; // strings generated by cocos2d sent to the remote console bool _sendDebugStrings; std::mutex _DebugStringsMutex; std::vector _DebugStrings; private: CC_DISALLOW_COPY_AND_ASSIGN(Console); }; NS_CC_END #endif /* defined(__CCCONSOLE_H__) */ ================================================ FILE: cocos2d/cocos/base/CCData.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCData.h" #include "platform/CCCommon.h" #include "ccMacros.h" #include NS_CC_BEGIN const Data Data::Null; Data::Data() : _bytes(nullptr), _size(0) { CCLOGINFO("In the empty constructor of Data."); } Data::Data(Data&& other) : _bytes(nullptr), _size(0) { CCLOGINFO("In the move constructor of Data."); move(other); } Data::Data(const Data& other) : _bytes(nullptr), _size(0) { CCLOGINFO("In the copy constructor of Data."); copy(other._bytes, other._size); } Data::~Data() { CCLOGINFO("deallocing Data: %p", this); clear(); } Data& Data::operator= (const Data& other) { CCLOGINFO("In the copy assignment of Data."); copy(other._bytes, other._size); return *this; } Data& Data::operator= (Data&& other) { CCLOGINFO("In the move assignment of Data."); move(other); return *this; } void Data::move(Data& other) { _bytes = other._bytes; _size = other._size; other._bytes = nullptr; other._size = 0; } bool Data::isNull() const { return (_bytes == nullptr || _size == 0); } unsigned char* Data::getBytes() const { return _bytes; } ssize_t Data::getSize() const { return _size; } void Data::copy(unsigned char* bytes, const ssize_t size) { clear(); if (size > 0) { _size = size; _bytes = (unsigned char*)malloc(sizeof(unsigned char) * _size); memcpy(_bytes, bytes, _size); } } void Data::fastSet(unsigned char* bytes, const ssize_t size) { _bytes = bytes; _size = size; } void Data::clear() { free(_bytes); _bytes = nullptr; _size = 0; } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCData.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDATA_H__ #define __CCDATA_H__ #include "CCPlatformMacros.h" #include // for ssize_t on android #include // for ssize_t on linux #include "CCStdC.h" // for ssize_t on window NS_CC_BEGIN class CC_DLL Data { public: static const Data Null; Data(); Data(const Data& other); Data(Data&& other); ~Data(); // Assignment operator Data& operator= (const Data& other); Data& operator= (Data&& other); /** * @js NA * @lua NA */ unsigned char* getBytes() const; /** * @js NA * @lua NA */ ssize_t getSize() const; /** Copies the buffer pointer and its size. * @note This method will copy the whole buffer. * Developer should free the pointer after invoking this method. * @see Data::fastSet */ void copy(unsigned char* bytes, const ssize_t size); /** Fast set the buffer pointer and its size. Please use it carefully. * @param bytes The buffer pointer, note that it have to be allocated by 'malloc' or 'calloc', * since in the destructor of Data, the buffer will be deleted by 'free'. * @note 1. This method will move the ownship of 'bytes'pointer to Data, * 2. The pointer should not be used outside after it was passed to this method. * @see Data::copy */ void fastSet(unsigned char* bytes, const ssize_t size); /** Clears data, free buffer and reset data size */ void clear(); /** Check whether the data is null. */ bool isNull() const; private: void move(Data& other); private: unsigned char* _bytes; ssize_t _size; }; NS_CC_END #endif // __CCDATA_H__ ================================================ FILE: cocos2d/cocos/base/CCDataVisitor.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCObject.h" #include "CCBool.h" #include "CCInteger.h" #include "CCFloat.h" #include "CCDouble.h" #include "CCString.h" #include "CCArray.h" #include "CCDictionary.h" #include "CCSet.h" NS_CC_BEGIN void DataVisitor::visit(const __Bool *value) { visitObject(value); } void DataVisitor::visit(const __Integer *value) { visitObject(value); } void DataVisitor::visit(const __Float *value) { visitObject(value); } void DataVisitor::visit(const __Double *value) { visitObject(value); } void DataVisitor::visit(const __String *value) { visitObject(value); } void DataVisitor::visit(const __Array *value) { visitObject(value); } void DataVisitor::visit(const __Dictionary *value) { visitObject(value); } void DataVisitor::visit(const __Set *value) { visitObject(value); } // PrettyPrinter PrettyPrinter::PrettyPrinter(int indentLevel/* = 0 */) { setIndentLevel(indentLevel); } void PrettyPrinter::clear() { _result.clear(); } std::string PrettyPrinter::getResult() { return _result; } void PrettyPrinter::visitObject(const Object *p) { char buf[50] = {0}; sprintf(buf, "%p", p); _result += buf; } void PrettyPrinter::visit(const __Bool * p) { char buf[50] = {0}; sprintf(buf, "%s", p->getValue() ? "true" : "false"); _result += buf; } void PrettyPrinter::visit(const __Integer *p) { char buf[50] = {0}; sprintf(buf, "%d", p->getValue()); _result += buf; } void PrettyPrinter::visit(const __Float *p) { char buf[50] = {0}; sprintf(buf, "%f", p->getValue()); _result += buf; } void PrettyPrinter::visit(const __Double *p) { char buf[50] = {0}; sprintf(buf, "%lf", p->getValue()); _result += buf; } void PrettyPrinter::visit(const __String *p) { _result += p->getCString(); } void PrettyPrinter::visit(const __Array *p) { _result += "\n"; _result += _indentStr; _result += "\n"; setIndentLevel(_indentLevel+1); Object* obj; int i = 0; char buf[50] = {0}; CCARRAY_FOREACH(p, obj) { if (i > 0) { _result += "\n"; } sprintf(buf, "%s%02d: ", _indentStr.c_str(), i); _result += buf; PrettyPrinter v(_indentLevel); obj->acceptVisitor(v); _result += v.getResult(); i++; } setIndentLevel(_indentLevel-1); _result += "\n"; _result += _indentStr; _result += ""; } void PrettyPrinter::visit(const __Dictionary *p) { _result += "\n"; _result += _indentStr; _result += "\n"; setIndentLevel(_indentLevel+1); DictElement* element; bool bFirstElement = true; char buf[1000] = {0}; CCDICT_FOREACH(p, element) { if (!bFirstElement) { _result += "\n"; } sprintf(buf, "%s%s: ", _indentStr.c_str(),element->getStrKey()); _result += buf; PrettyPrinter v(_indentLevel); element->getObject()->acceptVisitor(v); _result += v.getResult(); bFirstElement = false; } setIndentLevel(_indentLevel-1); _result += "\n"; _result += _indentStr; _result += ""; } void PrettyPrinter::visit(const __Set *p) { _result += "\n"; _result += _indentStr; _result += "\n"; setIndentLevel(_indentLevel+1); int i = 0; __Set* tmp = const_cast<__Set*>(p); __SetIterator it = tmp->begin(); for (; it != tmp->end(); ++it, ++i) { if (i > 0) { _result += "\n"; } _result += _indentStr.c_str(); PrettyPrinter v(_indentLevel); (*it)->acceptVisitor(v); _result += v.getResult(); } setIndentLevel(_indentLevel-1); _result += "\n"; _result += _indentStr; _result += "\n"; } void PrettyPrinter::setIndentLevel(int indentLevel) { _indentLevel = indentLevel; _indentStr.clear(); for (int i = 0; i < _indentLevel; ++i) { _indentStr += "\t"; } } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCDataVisitor.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDATAVISITOR_H__ #define __CCDATAVISITOR_H__ #include "CCPlatformMacros.h" #include NS_CC_BEGIN class Object; class __Bool; class __Integer; class __Float; class __Double; class __String; class __Array; class __Dictionary; class __Set; /** * @addtogroup data_structures * @{ */ /** * Visitor that helps to perform action that depends on polymorphic object type * * Use cases: * - data serialization, * - pretty printing of Object * * - safe value reading from Array, __Dictionary, Set * * Usage: * 1. subclass DataVisitor * 2. overload visit() methods for object that you need to handle * 3. handle other objects in visitObject() * 4. pass your visitor to Object::acceptVisitor() */ class CC_DLL DataVisitor { public: /** * @js NA * @lua NA */ virtual ~DataVisitor() {} /** default method, called from non-overloaded methods and for unrecognized objects */ virtual void visitObject(const Object *p) = 0; virtual void visit(const __Bool *p); virtual void visit(const __Integer *p); virtual void visit(const __Float *p); virtual void visit(const __Double *p); virtual void visit(const __String *p); virtual void visit(const __Array *p); virtual void visit(const __Dictionary *p); virtual void visit(const __Set *p); }; class CC_DLL PrettyPrinter : public DataVisitor { public: PrettyPrinter(int indentLevel = 0); virtual void clear(); virtual std::string getResult(); virtual void visitObject(const Object *p); virtual void visit(const __Bool * p); virtual void visit(const __Integer *p); virtual void visit(const __Float *p); virtual void visit(const __Double *p); virtual void visit(const __String *p); virtual void visit(const __Array *p); virtual void visit(const __Dictionary *p); virtual void visit(const __Set *p); private: void setIndentLevel(int indentLevel); int _indentLevel; std::string _indentStr; std::string _result; }; // end of data_structure group /// @} NS_CC_END #endif // __CCDATAVISITOR_H__ ================================================ FILE: cocos2d/cocos/base/CCDictionary.cpp ================================================ /**************************************************************************** Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCDictionary.h" #include "CCString.h" #include "CCInteger.h" #include "platform/CCFileUtils.h" #include "CCString.h" #include "CCBool.h" #include "CCInteger.h" #include "CCFloat.h" #include "CCDouble.h" #include "CCArray.h" using namespace std; NS_CC_BEGIN // ----------------------------------------------------------------------- // DictElement DictElement::DictElement(const char* pszKey, Object* pObject) { CCASSERT(pszKey && strlen(pszKey) > 0, "Invalid key value."); _intKey = 0; const char* pStart = pszKey; size_t len = strlen(pszKey); if (len > MAX_KEY_LEN ) { char* pEnd = (char*)&pszKey[len-1]; pStart = pEnd - (MAX_KEY_LEN-1); } strcpy(_strKey, pStart); _object = pObject; memset(&hh, 0, sizeof(hh)); } DictElement::DictElement(intptr_t iKey, Object* pObject) { _strKey[0] = '\0'; _intKey = iKey; _object = pObject; memset(&hh, 0, sizeof(hh)); } DictElement::~DictElement() { CCLOGINFO("deallocing DictElement: %p", this); } // ----------------------------------------------------------------------- // __Dictionary __Dictionary::__Dictionary() : _elements(NULL) , _dictType(kDictUnknown) { } __Dictionary::~__Dictionary() { CCLOGINFO("deallocing __Dictionary: %p", this); removeAllObjects(); } unsigned int __Dictionary::count() { return HASH_COUNT(_elements); } __Array* __Dictionary::allKeys() { int iKeyCount = this->count(); if (iKeyCount <= 0) return NULL; __Array* array = __Array::createWithCapacity(iKeyCount); DictElement *pElement, *tmp; if (_dictType == kDictStr) { HASH_ITER(hh, _elements, pElement, tmp) { __String* pOneKey = new __String(pElement->_strKey); array->addObject(pOneKey); CC_SAFE_RELEASE(pOneKey); } } else if (_dictType == kDictInt) { HASH_ITER(hh, _elements, pElement, tmp) { __Integer* pOneKey = new __Integer(static_cast(pElement->_intKey)); array->addObject(pOneKey); CC_SAFE_RELEASE(pOneKey); } } return array; } __Array* __Dictionary::allKeysForObject(Object* object) { int iKeyCount = this->count(); if (iKeyCount <= 0) return NULL; __Array* array = __Array::create(); DictElement *pElement, *tmp; if (_dictType == kDictStr) { HASH_ITER(hh, _elements, pElement, tmp) { if (object == pElement->_object) { __String* pOneKey = new __String(pElement->_strKey); array->addObject(pOneKey); CC_SAFE_RELEASE(pOneKey); } } } else if (_dictType == kDictInt) { HASH_ITER(hh, _elements, pElement, tmp) { if (object == pElement->_object) { __Integer* pOneKey = new __Integer(static_cast(pElement->_intKey)); array->addObject(pOneKey); CC_SAFE_RELEASE(pOneKey); } } } return array; } Object* __Dictionary::objectForKey(const std::string& key) { // if dictionary wasn't initialized, return NULL directly. if (_dictType == kDictUnknown) return NULL; // __Dictionary only supports one kind of key, string or integer. // This method uses string as key, therefore we should make sure that the key type of this __Dictionary is string. CCASSERT(_dictType == kDictStr, "this dictionary does not use string as key."); Object* pRetObject = NULL; DictElement *pElement = NULL; HASH_FIND_STR(_elements, key.c_str(), pElement); if (pElement != NULL) { pRetObject = pElement->_object; } return pRetObject; } Object* __Dictionary::objectForKey(intptr_t key) { // if dictionary wasn't initialized, return NULL directly. if (_dictType == kDictUnknown) return NULL; // __Dictionary only supports one kind of key, string or integer. // This method uses integer as key, therefore we should make sure that the key type of this __Dictionary is integer. CCASSERT(_dictType == kDictInt, "this dictionary does not use integer as key."); Object* pRetObject = NULL; DictElement *pElement = NULL; HASH_FIND_PTR(_elements, &key, pElement); if (pElement != NULL) { pRetObject = pElement->_object; } return pRetObject; } const __String* __Dictionary::valueForKey(const std::string& key) { __String* pStr = dynamic_cast<__String*>(objectForKey(key)); if (pStr == NULL) { pStr = __String::create(""); } return pStr; } const __String* __Dictionary::valueForKey(intptr_t key) { __String* pStr = dynamic_cast<__String*>(objectForKey(key)); if (pStr == NULL) { pStr = __String::create(""); } return pStr; } void __Dictionary::setObject(Object* pObject, const std::string& key) { CCASSERT(key.length() > 0 && pObject != NULL, "Invalid Argument!"); if (_dictType == kDictUnknown) { _dictType = kDictStr; } CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as key."); DictElement *pElement = NULL; HASH_FIND_STR(_elements, key.c_str(), pElement); if (pElement == NULL) { setObjectUnSafe(pObject, key); } else if (pElement->_object != pObject) { Object* pTmpObj = pElement->_object; pTmpObj->retain(); removeObjectForElememt(pElement); setObjectUnSafe(pObject, key); pTmpObj->release(); } } void __Dictionary::setObject(Object* pObject, intptr_t key) { CCASSERT(pObject != NULL, "Invalid Argument!"); if (_dictType == kDictUnknown) { _dictType = kDictInt; } CCASSERT(_dictType == kDictInt, "this dictionary doesn't use integer as key."); DictElement *pElement = NULL; HASH_FIND_PTR(_elements, &key, pElement); if (pElement == NULL) { setObjectUnSafe(pObject, key); } else if (pElement->_object != pObject) { Object* pTmpObj = pElement->_object; pTmpObj->retain(); removeObjectForElememt(pElement); setObjectUnSafe(pObject, key); pTmpObj->release(); } } void __Dictionary::removeObjectForKey(const std::string& key) { if (_dictType == kDictUnknown) { return; } CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as its key"); CCASSERT(key.length() > 0, "Invalid Argument!"); DictElement *pElement = NULL; HASH_FIND_STR(_elements, key.c_str(), pElement); removeObjectForElememt(pElement); } void __Dictionary::removeObjectForKey(intptr_t key) { if (_dictType == kDictUnknown) { return; } CCASSERT(_dictType == kDictInt, "this dictionary doesn't use integer as its key"); DictElement *pElement = NULL; HASH_FIND_PTR(_elements, &key, pElement); removeObjectForElememt(pElement); } void __Dictionary::setObjectUnSafe(Object* pObject, const std::string& key) { pObject->retain(); DictElement* pElement = new DictElement(key.c_str(), pObject); HASH_ADD_STR(_elements, _strKey, pElement); } void __Dictionary::setObjectUnSafe(Object* pObject, const intptr_t key) { pObject->retain(); DictElement* pElement = new DictElement(key, pObject); HASH_ADD_PTR(_elements, _intKey, pElement); } void __Dictionary::removeObjectsForKeys(__Array* pKey__Array) { Object* pObj = NULL; CCARRAY_FOREACH(pKey__Array, pObj) { __String* pStr = static_cast<__String*>(pObj); removeObjectForKey(pStr->getCString()); } } void __Dictionary::removeObjectForElememt(DictElement* pElement) { if (pElement != NULL) { HASH_DEL(_elements, pElement); pElement->_object->release(); CC_SAFE_DELETE(pElement); } } void __Dictionary::removeAllObjects() { DictElement *pElement, *tmp; HASH_ITER(hh, _elements, pElement, tmp) { HASH_DEL(_elements, pElement); pElement->_object->release(); CC_SAFE_DELETE(pElement); } } Object* __Dictionary::randomObject() { if (_dictType == kDictUnknown) { return NULL; } Object* key = allKeys()->getRandomObject(); if (_dictType == kDictInt) { return objectForKey( static_cast<__Integer*>(key)->getValue()); } else if (_dictType == kDictStr) { return objectForKey( static_cast<__String*>(key)->getCString()); } else { return NULL; } } __Dictionary* __Dictionary::create() { __Dictionary* ret = new __Dictionary(); if (ret && ret->init() ) { ret->autorelease(); } return ret; } bool __Dictionary::init() { return true; } __Dictionary* __Dictionary::createWithDictionary(__Dictionary* srcDict) { return srcDict->clone(); } static __Array* visitArray(const ValueVector& array); static __Dictionary* visitDict(const ValueMap& dict) { __Dictionary* ret = new __Dictionary(); ret->init(); for (auto iter = dict.begin(); iter != dict.end(); ++iter) { if (iter->second.getType() == Value::Type::MAP) { const ValueMap& subDict = iter->second.asValueMap(); auto sub = visitDict(subDict); ret->setObject(sub, iter->first); sub->release(); } else if (iter->second.getType() == Value::Type::VECTOR) { const ValueVector& arr = iter->second.asValueVector(); auto sub = visitArray(arr); ret->setObject(sub, iter->first); sub->release(); } else { auto str = new __String(iter->second.asString()); ret->setObject(str, iter->first); str->release(); } } return ret; } static __Array* visitArray(const ValueVector& array) { __Array* ret = new __Array(); ret->init(); for(const auto &value : array) { if (value.getType() == Value::Type::MAP) { const ValueMap& subDict = value.asValueMap(); auto sub = visitDict(subDict); ret->addObject(sub); sub->release(); } else if (value.getType() == Value::Type::VECTOR) { const ValueVector& arr = value.asValueVector(); auto sub = visitArray(arr); ret->addObject(sub); sub->release(); } else { auto str = new __String(value.asString()); ret->addObject(str); str->release(); } } return ret; } __Dictionary* __Dictionary::createWithContentsOfFileThreadSafe(const char *pFileName) { return visitDict(FileUtils::getInstance()->getValueMapFromFile(pFileName)); } void __Dictionary::acceptVisitor(DataVisitor &visitor) { return visitor.visit(this); } __Dictionary* __Dictionary::createWithContentsOfFile(const char *pFileName) { auto ret = createWithContentsOfFileThreadSafe(pFileName); if (ret != nullptr) { ret->autorelease(); } return ret; } static ValueMap ccdictionary_to_valuemap(__Dictionary* dict); static ValueVector ccarray_to_valuevector(__Array* arr) { ValueVector ret; Object* obj; CCARRAY_FOREACH(arr, obj) { Value arrElement; __String* strVal = nullptr; __Dictionary* dictVal = nullptr; __Array* arrVal = nullptr; __Double* doubleVal = nullptr; __Bool* boolVal = nullptr; __Float* floatVal = nullptr; __Integer* intVal = nullptr; if ((strVal = dynamic_cast<__String *>(obj))) { arrElement = Value(strVal->getCString()); } else if ((dictVal = dynamic_cast<__Dictionary*>(obj))) { arrElement = ccdictionary_to_valuemap(dictVal); } else if ((arrVal = dynamic_cast<__Array*>(obj))) { arrElement = ccarray_to_valuevector(arrVal); } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { arrElement = Value(doubleVal->getValue()); } else if ((floatVal = dynamic_cast<__Float*>(obj))) { arrElement = Value(floatVal->getValue()); } else if ((intVal = dynamic_cast<__Integer*>(obj))) { arrElement = Value(intVal->getValue()); } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { arrElement = boolVal->getValue() ? Value(true) : Value(false); } else { CCASSERT(false, "the type isn't suppored."); } ret.push_back(arrElement); } return ret; } static ValueMap ccdictionary_to_valuemap(__Dictionary* dict) { ValueMap ret; DictElement* pElement = nullptr; CCDICT_FOREACH(dict, pElement) { Object* obj = pElement->getObject(); __String* strVal = nullptr; __Dictionary* dictVal = nullptr; __Array* arrVal = nullptr; __Double* doubleVal = nullptr; __Bool* boolVal = nullptr; __Float* floatVal = nullptr; __Integer* intVal = nullptr; Value dictElement; if ((strVal = dynamic_cast<__String *>(obj))) { dictElement = Value(strVal->getCString()); } else if ((dictVal = dynamic_cast<__Dictionary*>(obj))) { dictElement = ccdictionary_to_valuemap(dictVal); } else if ((arrVal = dynamic_cast<__Array*>(obj))) { dictElement = ccarray_to_valuevector(arrVal); } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { dictElement = Value(doubleVal->getValue()); } else if ((floatVal = dynamic_cast<__Float*>(obj))) { dictElement = Value(floatVal->getValue()); } else if ((intVal = dynamic_cast<__Integer*>(obj))) { dictElement = Value(intVal->getValue()); } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { dictElement = boolVal->getValue() ? Value(true) : Value(false); } else { CCASSERT(false, "the type isn't suppored."); } const char* key = pElement->getStrKey(); if (key && strlen(key) > 0) { ret[key] = dictElement; } } return ret; } bool __Dictionary::writeToFile(const char *fullPath) { ValueMap dict = ccdictionary_to_valuemap(this); return FileUtils::getInstance()->writeToFile(dict, fullPath); } __Dictionary* __Dictionary::clone() const { __Dictionary* newDict = __Dictionary::create(); DictElement* element = NULL; Object* tmpObj = NULL; Clonable* obj = NULL; if (_dictType == kDictInt) { CCDICT_FOREACH(this, element) { obj = dynamic_cast(element->getObject()); if (obj) { tmpObj = dynamic_cast(obj->clone()); if (tmpObj) { newDict->setObject(tmpObj, element->getIntKey()); } } else { CCLOGWARN("%s isn't clonable.", typeid(*element->getObject()).name()); } } } else if (_dictType == kDictStr) { CCDICT_FOREACH(this, element) { obj = dynamic_cast(element->getObject()); if (obj) { tmpObj = dynamic_cast(obj->clone()); if (tmpObj) { newDict->setObject(tmpObj, element->getStrKey()); } } else { CCLOGWARN("%s isn't clonable.", typeid(*element->getObject()).name()); } } } return newDict; } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCDictionary.h ================================================ /**************************************************************************** Copyright (c) 2012 cocos2d-x.org opyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDICTIONARY_H__ #define __CCDICTIONARY_H__ #include "uthash.h" #include "CCObject.h" #include "CCArray.h" #include "CCString.h" NS_CC_BEGIN class __Dictionary; /** * @addtogroup data_structures * @{ */ /** * DictElement is used for traversing Dictionary. * * A DictElement is one element of Dictionary, it contains two properties, key and object. * Its key has two different type (integer and string). * * @note The key type is unique, all the elements in Dictionary has the same key type(integer or string). * @code * DictElement* pElement; * CCDICT_FOREACH(dict, pElement) * { * const char*key = pElement->getStrKey(); * // You certainly know the type of value, so we assume that it's a Sprite. * Sprite* pSprite = static_cast(pElement->getObject()); * // ...... * } * @endcode * */ class CC_DLL DictElement { private: /** * Constructor of DictElement. It's only for internal usage. Dictionary is its friend class. * * @param pszKey The string key of this element. * @param pObject The object of this element. */ DictElement(const char* pszKey, Object* pObject); /** * Constructor of DictElement. It's only for internal usage. Dictionary is its friend class. * * @param iKey The integer key of this element. * @param pObject The object of this element. */ DictElement(intptr_t iKey, Object* pObject); public: /** * The destructor of DictElement. * @js NA * @lua NA */ ~DictElement(); // Inline functions need to be implemented in header file on Android. /** * Get the string key of this element. * @note This method assumes you know the key type in the element. * If the element's key type is integer, invoking this method will cause an assert. * * @return The string key of this element. */ inline const char* getStrKey() const { CCASSERT(_strKey[0] != '\0', "Should not call this function for integer dictionary"); return _strKey; } /** * Get the integer key of this element. * @note This method assumes you know the key type in the element. * If the element's key type is string, invoking this method will cause an assert. * * @return The integer key of this element. */ inline intptr_t getIntKey() const { CCASSERT(_strKey[0] == '\0', "Should not call this function for string dictionary"); return _intKey; } /** * Get the object of this element. * * @return The object of this element. */ inline Object* getObject() const { return _object; } private: // The max length of string key. #define MAX_KEY_LEN 256 // char array is needed for HASH_ADD_STR in UT_HASH. // So it's a pain that all elements will allocate 256 bytes for this array. char _strKey[MAX_KEY_LEN]; // hash key of string type intptr_t _intKey; // hash key of integer type Object* _object; // hash value public: UT_hash_handle hh; // makes this class hashable friend class __Dictionary; // declare Dictionary as friend class }; /** The macro for traversing dictionary * * @note It's faster than getting all keys and traversing keys to get objects by objectForKey. * It's also safe to remove elements while traversing. */ #define CCDICT_FOREACH(__dict__, __el__) \ DictElement* pTmp##__dict__##__el__ = nullptr; \ if (__dict__) \ HASH_ITER(hh, (__dict__)->_elements, __el__, pTmp##__dict__##__el__) /** * Dictionary is a class like NSDictionary in Obj-C . * * @note Only the pointer of Object or its subclass can be inserted to Dictionary. * @code * // Create a dictionary, return an autorelease object. * Dictionary* pDict = Dictionary::create(); * * // Insert objects to dictionary * String* pValue1 = String::create("100"); * String* pValue2 = String::create("120"); * Integer* pValue3 = Integer::create(200); * pDict->setObject(pValue1, "key1"); * pDict->setObject(pValue2, "key2"); * pDict->setObject(pValue3, "key3"); * * // Get the object for key * String* pStr1 = static_cast(pDict->objectForKey("key1")); * log("{ key1: %s }", pStr1->getCString()); * Integer* pInteger = static_cast(pDict->objectForKey("key3")); * log("{ key3: %d }", pInteger->getValue()); * @endcode * */ class CC_DLL __Dictionary : public Object, public Clonable { public: /** * The constructor of Dictionary. * @js NA * @lua NA */ __Dictionary(); /** * The destructor of Dictionary * @js NA * @lua NA */ ~__Dictionary(); /** Initializes the dictionary. It returns true if the initializations was successful. * @js NA * @lua NA */ bool init(); /** * Get the count of elements in Dictionary. * * @return The count of elements. * @js NA */ unsigned int count(); /** * Return all keys of elements. * * @return The array contains all keys of elements. It's an autorelease object yet. * @js NA */ __Array* allKeys(); /** * Get all keys according to the specified object. * @warning We use '==' to compare two objects * @return The array contains all keys for the specified object. It's an autorelease object yet. * @js NA */ __Array* allKeysForObject(Object* object); /** * Get the object according to the specified string key. * * @note The dictionary needs to use string as key. If integer is passed, an assert will appear. * @param key The string key for searching. * @return The object matches the key. You need to force convert it to the type you know. * @code * // Assume that the elements are String* pointers. Convert it by following code. * String* pStr = static_cast(pDict->objectForKey("key1")); * // Do something about pStr. * // If you don't know the object type, properly you need to use dynamic_cast to check it. * String* pStr2 = dynamic_cast(pDict->objectForKey("key1")); * if (pStr2 != NULL) { * // Do something about pStr2 * } * @endcode * @see objectForKey(intptr_t) * @js NA */ Object* objectForKey(const std::string& key); /** * Get the object according to the specified integer key. * * @note The dictionary needs to use integer as key. If string is passed, an assert will appear. * @param key The integer key for searching. * @return The object matches the key. * @see objectForKey(const std::string&) * @js NA */ Object* objectForKey(intptr_t key); /** Get the value according to the specified string key. * * @note Be careful to use this function since it assumes the objects in the dictionary are __String pointer. * @param key The string key for searching * @return An instance of String. * It will return an empty string if the objects aren't __String pointer or the key wasn't found. * @see valueForKey(intptr_t) * @js NA */ const __String* valueForKey(const std::string& key); /** Get the value according to the specified integer key. * * @note Be careful to use this function since it assumes the objects in the dictionary are __String pointer. * @param key The string key for searching. * @return An instance of String. * It will return an empty string if the objects aren't __String pointer or the key wasn't found. * @see valueForKey(intptr_t) * @js NA */ const __String* valueForKey(intptr_t key); /** Insert an object to dictionary, and match it with the specified string key. * * @note Whe the first time this method is invoked, the key type will be set to string. * After that you can't setObject with an integer key. * If the dictionary contains the key you passed, the object matching the key will be released and removed from dictionary. * Then the new object will be inserted after that. * * @param pObject The Object to be inserted. * @param key The string key for searching. * @see setObject(Object*, intptr_t) * @js NA */ void setObject(Object* pObject, const std::string& key); /** Insert an object to dictionary, and match it with the specified string key. * * @note Then the first time this method is invoked, the key type will be set to string. * After that you can't setObject with an integer key. * If the dictionary contains the key you passed, the object matching the key will be released and removed from dictionary. * Then the new object will be inserted after that. * @param pObject The Object to be inserted. * @param key The string key for searching. * @see setObject(Object*, const std::string&) * @js NA */ void setObject(Object* pObject, intptr_t key); /** * Remove an object by the specified string key. * * @param key The string key for searching. * @see removeObjectForKey(intptr_t), removeObjectsForKeys(__Array*), * removeObjectForElememt(DictElement*), removeAllObjects(). * @js NA */ void removeObjectForKey(const std::string& key); /** * Remove an object by the specified integer key. * * @param key The integer key for searching. * @see removeObjectForKey(const std::string&), removeObjectsForKeys(__Array*), * removeObjectForElememt(DictElement*), removeAllObjects(). * @js NA */ void removeObjectForKey(intptr_t key); /** * Remove objects by an array of keys. * * @param pKeyArray The array contains keys to be removed. * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * removeObjectForElememt(DictElement*), removeAllObjects(). * @js NA */ void removeObjectsForKeys(__Array* pKey__Array); /** * Remove an object by an element. * * @param pElement The element need to be removed. * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * removeObjectsForKeys(__Array*), removeAllObjects(). * @js NA * @lua NA */ void removeObjectForElememt(DictElement* pElement); /** * Remove all objects in the dictionary. * * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * removeObjectsForKeys(__Array*), removeObjectForElememt(DictElement*). * @js NA */ void removeAllObjects(); /** * Return a random object in the dictionary. * * @return The random object. * @see objectForKey(intptr_t), objectForKey(const std::string&) * @js NA * @lua NA */ Object* randomObject(); /** * Create a dictionary. * @return A dictionary which is an autorelease object. * @see createWithDictionary(Dictionary*), createWithContentsOfFile(const char*), createWithContentsOfFileThreadSafe(const char*). * @js NA */ static __Dictionary* create(); /** * Create a dictionary with an existing dictionary. * * @param srcDict The exist dictionary. * @return A dictionary which is an autorelease object. * @see create(), createWithContentsOfFile(const char*), createWithContentsOfFileThreadSafe(const char*). * @js NA */ static __Dictionary* createWithDictionary(__Dictionary* srcDict); /** * Create a dictionary with a plist file. * @param pFileName The name of the plist file. * @return A dictionary which is an autorelease object. * @see create(), createWithDictionary(Dictionary*), createWithContentsOfFileThreadSafe(const char*). * @js NA */ static __Dictionary* createWithContentsOfFile(const char *pFileName); /** * Write a dictionary to a plist file. * @param fullPath The full path of the plist file. You can get writeable path by getWritablePath() * @return true if successed, false if failed * @js NA * @lua NA */ bool writeToFile(const char *fullPath); /** * Create a dictionary with a plist file. * * @note the return object isn't an autorelease object. * This can make sure not using autorelease pool in a new thread. * Therefore, you need to manage the lifecycle of the return object. * It means that when you don't need it, CC_SAFE_RELEASE needs to be invoked. * * @param pFileName The name of the plist file. * @return A dictionary which isn't an autorelease object. * @js NA * @lua NA */ static __Dictionary* createWithContentsOfFileThreadSafe(const char *pFileName); /* override functions * @js NA * @lua NA */ virtual void acceptVisitor(DataVisitor &visitor); /** * @js NA * @lua NA */ virtual __Dictionary* clone() const; private: /** * For internal usage, invoked by setObject. */ void setObjectUnSafe(Object* pObject, const std::string& key); void setObjectUnSafe(Object* pObject, const intptr_t key); public: /** * All the elements in dictionary. * * @note For internal usage, we need to declare this member variable as public since it's used in UT_HASH. */ DictElement* _elements; private: /** The support type of dictionary, it's confirmed when setObject is invoked. */ enum DictType { kDictUnknown = 0, kDictStr, kDictInt }; /** * The type of dictionary, it's assigned to kDictUnknown by default. */ DictType _dictType; }; // end of data_structure group /// @} NS_CC_END #endif /* __CCDICTIONARY_H__ */ ================================================ FILE: cocos2d/cocos/base/CCDouble.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies 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 __CCDOUBLE_H__ #define __CCDOUBLE_H__ #include "CCObject.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ class CC_DLL __Double : public Object, public Clonable { public: __Double(double v) : _value(v) {} double getValue() const {return _value;} static __Double* create(double v) { __Double* pRet = new __Double(v); if (pRet) { pRet->autorelease(); } return pRet; } /* override functions */ virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } __Double* clone() const { return __Double::create(_value); } private: double _value; }; // end of data_structure group /// @} NS_CC_END #endif /* __CCDOUBLE_H__ */ ================================================ FILE: cocos2d/cocos/base/CCFloat.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies 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 __CCFLOAT_H__ #define __CCFLOAT_H__ #include "CCObject.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ class CC_DLL __Float : public Object, public Clonable { public: __Float(float v) : _value(v) {} float getValue() const {return _value;} static __Float* create(float v) { __Float* pRet = new __Float(v); if (pRet) { pRet->autorelease(); } return pRet; } /* override functions */ virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } __Float* clone() const { return __Float::create(_value); } private: float _value; }; // end of data_structure group /// @} NS_CC_END #endif /* __CCFLOAT_H__ */ ================================================ FILE: cocos2d/cocos/base/CCGeometry.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 "CCGeometry.h" #include "ccMacros.h" #include // implementation of Point NS_CC_BEGIN Point::Point(void) : x(0), y(0) { } Point::Point(float xx, float yy) : x(xx), y(yy) { } Point::Point(const Point& other) : x(other.x), y(other.y) { } Point::Point(const Size& size) : x(size.width), y(size.height) { } Point& Point::operator= (const Point& other) { setPoint(other.x, other.y); return *this; } Point& Point::operator= (const Size& size) { setPoint(size.width, size.height); return *this; } Point Point::operator+(const Point& right) const { return Point(this->x + right.x, this->y + right.y); } Point& Point::operator+=(const Point& right) { this->x += right.x; this->y += right.y; return *this; } Point Point::operator-(const Point& right) const { return Point(this->x - right.x, this->y - right.y); } Point& Point::operator-=(const Point& right) { this->x -= right.x; this->y -= right.y; return *this; } Point Point::operator-() const { return Point(-x, -y); } bool Point::operator==(const Point& right) { return this->x == right.x && this->y == right.y; } bool Point::operator!=(const Point& right) { return this->x != right.x || this->y != right.y; } bool Point::operator==(const Point& right) const { return this->x == right.x && this->y == right.y; } bool Point::operator!=(const Point& right) const { return this->x != right.x || this->y != right.y; } Point Point::operator*(float a) const { return Point(this->x * a, this->y * a); } Point Point::operator/(float a) const { CCASSERT(a!=0, "CCPoint division by 0."); return Point(this->x / a, this->y / a); } void Point::setPoint(float xx, float yy) { this->x = xx; this->y = yy; } bool Point::equals(const Point& target) const { return (fabs(this->x - target.x) < FLT_EPSILON) && (fabs(this->y - target.y) < FLT_EPSILON); } bool Point::fuzzyEquals(const Point& b, float var) const { if(x - var <= b.x && b.x <= x + var) if(y - var <= b.y && b.y <= y + var) return true; return false; } float Point::getAngle(const Point& other) const { Point a2 = normalize(); Point b2 = other.normalize(); float angle = atan2f(a2.cross(b2), a2.dot(b2)); if( fabs(angle) < FLT_EPSILON ) return 0.f; return angle; } Point Point::rotateByAngle(const Point& pivot, float angle) const { return pivot + (*this - pivot).rotate(Point::forAngle(angle)); } bool Point::isOneDemensionSegmentOverlap(float A, float B, float C, float D, float *S, float *E) { float ABmin = MIN(A, B); float ABmax = MAX(A, B); float CDmin = MIN(C, D); float CDmax = MAX(C, D); if (ABmax < CDmin || CDmax < ABmin) { // ABmin->ABmax->CDmin->CDmax or CDmin->CDmax->ABmin->ABmax return false; } else { if (ABmin >= CDmin && ABmin <= CDmax) { // CDmin->ABmin->CDmax->ABmax or CDmin->ABmin->ABmax->CDmax if (S != nullptr) *S = ABmin; if (E != nullptr) *E = CDmax < ABmax ? CDmax : ABmax; } else if (ABmax >= CDmin && ABmax <= CDmax) { // ABmin->CDmin->ABmax->CDmax if (S != nullptr) *S = CDmin; if (E != nullptr) *E = ABmax; } else { // ABmin->CDmin->CDmax->ABmax if (S != nullptr) *S = CDmin; if (E != nullptr) *E = CDmax; } return true; } } bool Point::isLineIntersect(const Point& A, const Point& B, const Point& C, const Point& D, float *S, float *T) { // FAIL: Line undefined if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) { return false; } const float denom = crossProduct2Vector(A, B, C, D); if (denom == 0) { // Lines parallel or overlap return false; } if (S != nullptr) *S = crossProduct2Vector(C, D, C, A) / denom; if (T != nullptr) *T = crossProduct2Vector(A, B, C, A) / denom; return true; } bool Point::isLineParallel(const Point& A, const Point& B, const Point& C, const Point& D) { // FAIL: Line undefined if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) { return false; } if (crossProduct2Vector(A, B, C, D) == 0) { // line overlap if (crossProduct2Vector(C, D, C, A) == 0 || crossProduct2Vector(A, B, C, A) == 0) { return false; } return true; } return false; } bool Point::isLineOverlap(const Point& A, const Point& B, const Point& C, const Point& D) { // FAIL: Line undefined if ( (A.x==B.x && A.y==B.y) || (C.x==D.x && C.y==D.y) ) { return false; } if (crossProduct2Vector(A, B, C, D) == 0 && (crossProduct2Vector(C, D, C, A) == 0 || crossProduct2Vector(A, B, C, A) == 0)) { return true; } return false; } bool Point::isSegmentOverlap(const Point& A, const Point& B, const Point& C, const Point& D, Point* S, Point* E) { if (isLineOverlap(A, B, C, D)) { return isOneDemensionSegmentOverlap(A.x, B.x, C.x, D.x, &S->x, &E->x) && isOneDemensionSegmentOverlap(A.y, B.y, C.y, D.y, &S->y, &E->y); } return false; } bool Point::isSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D) { float S, T; if (isLineIntersect(A, B, C, D, &S, &T )&& (S >= 0.0f && S <= 1.0f && T >= 0.0f && T <= 1.0f)) { return true; } return false; } Point Point::getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D) { float S, T; if (isLineIntersect(A, B, C, D, &S, &T)) { // Point of intersection Point P; P.x = A.x + S * (B.x - A.x); P.y = A.y + S * (B.y - A.y); return P; } return Point::ZERO; } const Point Point::ZERO = Point(0.0f, 0.0f); const Point Point::ANCHOR_MIDDLE = Point(0.5f, 0.5f); const Point Point::ANCHOR_BOTTOM_LEFT = Point(0.0f, 0.0f); const Point Point::ANCHOR_TOP_LEFT = Point(0.0f, 1.0f); const Point Point::ANCHOR_BOTTOM_RIGHT = Point(1.0f, 0.0f); const Point Point::ANCHOR_TOP_RIGHT = Point(1.0f, 1.0f); const Point Point::ANCHOR_MIDDLE_RIGHT = Point(1.0f, 0.5f); const Point Point::ANCHOR_MIDDLE_LEFT = Point(0.0f, 0.5f); const Point Point::ANCHOR_MIDDLE_TOP = Point(0.5f, 1.0f); const Point Point::ANCHOR_MIDDLE_BOTTOM = Point(0.5f, 0.0f); // implementation of Size Size::Size(void) : width(0), height(0) { } Size::Size(float w, float h) : width(w), height(h) { } Size::Size(const Size& other) : width(other.width), height(other.height) { } Size::Size(const Point& point) : width(point.x), height(point.y) { } Size& Size::operator= (const Size& other) { setSize(other.width, other.height); return *this; } Size& Size::operator= (const Point& point) { setSize(point.x, point.y); return *this; } Size Size::operator+(const Size& right) const { return Size(this->width + right.width, this->height + right.height); } Size Size::operator-(const Size& right) const { return Size(this->width - right.width, this->height - right.height); } Size Size::operator*(float a) const { return Size(this->width * a, this->height * a); } Size Size::operator/(float a) const { CCASSERT(a!=0, "CCSize division by 0."); return Size(this->width / a, this->height / a); } void Size::setSize(float w, float h) { this->width = w; this->height = h; } bool Size::equals(const Size& target) const { return (fabs(this->width - target.width) < FLT_EPSILON) && (fabs(this->height - target.height) < FLT_EPSILON); } const Size Size::ZERO = Size(0, 0); // implementation of Rect Rect::Rect(void) { setRect(0.0f, 0.0f, 0.0f, 0.0f); } Rect::Rect(float x, float y, float width, float height) { setRect(x, y, width, height); } Rect::Rect(const Rect& other) { setRect(other.origin.x, other.origin.y, other.size.width, other.size.height); } Rect& Rect::operator= (const Rect& other) { setRect(other.origin.x, other.origin.y, other.size.width, other.size.height); return *this; } void Rect::setRect(float x, float y, float width, float height) { // CGRect can support width<0 or height<0 // CCASSERT(width >= 0.0f && height >= 0.0f, "width and height of Rect must not less than 0."); origin.x = x; origin.y = y; size.width = width; size.height = height; } bool Rect::equals(const Rect& rect) const { return (origin.equals(rect.origin) && size.equals(rect.size)); } float Rect::getMaxX() const { return origin.x + size.width; } float Rect::getMidX() const { return origin.x + size.width / 2.0f; } float Rect::getMinX() const { return origin.x; } float Rect::getMaxY() const { return origin.y + size.height; } float Rect::getMidY() const { return origin.y + size.height / 2.0f; } float Rect::getMinY() const { return origin.y; } bool Rect::containsPoint(const Point& point) const { bool bRet = false; if (point.x >= getMinX() && point.x <= getMaxX() && point.y >= getMinY() && point.y <= getMaxY()) { bRet = true; } return bRet; } bool Rect::intersectsRect(const Rect& rect) const { return !( getMaxX() < rect.getMinX() || rect.getMaxX() < getMinX() || getMaxY() < rect.getMinY() || rect.getMaxY() < getMinY()); } Rect Rect::unionWithRect(const Rect & rect) const { float thisLeftX = origin.x; float thisRightX = origin.x + size.width; float thisTopY = origin.y + size.height; float thisBottomY = origin.y; if (thisRightX < thisLeftX) { std::swap(thisRightX, thisLeftX); // This rect has negative width } if (thisTopY < thisBottomY) { std::swap(thisTopY, thisBottomY); // This rect has negative height } float otherLeftX = rect.origin.x; float otherRightX = rect.origin.x + rect.size.width; float otherTopY = rect.origin.y + rect.size.height; float otherBottomY = rect.origin.y; if (otherRightX < otherLeftX) { std::swap(otherRightX, otherLeftX); // Other rect has negative width } if (otherTopY < otherBottomY) { std::swap(otherTopY, otherBottomY); // Other rect has negative height } float combinedLeftX = std::min(thisLeftX, otherLeftX); float combinedRightX = std::max(thisRightX, otherRightX); float combinedTopY = std::max(thisTopY, otherTopY); float combinedBottomY = std::min(thisBottomY, otherBottomY); return Rect(combinedLeftX, combinedBottomY, combinedRightX - combinedLeftX, combinedTopY - combinedBottomY); } const Rect Rect::ZERO = Rect(0, 0, 0, 0); NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCGeometry.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 __CCGEMETRY_H__ #define __CCGEMETRY_H__ #include #include #include "CCPlatformMacros.h" #include "CCObject.h" #include "ccMacros.h" NS_CC_BEGIN /** Clamp a value between from and to. @since v0.99.1 */ inline float clampf(float value, float min_inclusive, float max_inclusive) { if (min_inclusive > max_inclusive) { CC_SWAP(min_inclusive, max_inclusive, float); } return value < min_inclusive ? min_inclusive : value < max_inclusive? value : max_inclusive; } /** * @addtogroup data_structures * @{ */ // for Point assignement operator and copy constructor class CC_DLL Size; class CC_DLL Point { public: float x; float y; public: /** * @js NA */ Point(); /** * @js NA */ Point(float x, float y); /** * @js NA * @lua NA */ Point(const Point& other); /** * @js NA * @lua NA */ explicit Point(const Size& size); /** * @js NA * @lua NA */ Point& operator= (const Point& other); /** * @js NA * @lua NA */ Point& operator= (const Size& size); /** * @js NA * @lua NA */ Point operator+(const Point& right) const; /** * @js NA * @lua NA */ Point& operator+=(const Point& right); /** * @js NA * @lua NA */ Point operator-(const Point& right) const; /** * @js NA * @lua NA */ Point& operator-=(const Point& right); /** * @js NA * @lua NA */ Point operator-() const; /** * @js NA * @lua NA */ bool operator==(const Point& right); /** * @js NA * @lua NA */ bool operator!=(const Point& right); /** * @js NA * @lua NA */ bool operator==(const Point& right) const; /** * @js NA * @lua NA */ bool operator!=(const Point& right) const; /** * @js NA * @lua NA */ Point operator*(float a) const; /** * @js NA * @lua NA */ Point operator/(float a) const; /** * @js NA * @lua NA */ void setPoint(float x, float y); /** * @js NA */ bool equals(const Point& target) const; /** @returns if points have fuzzy equality which means equal with some degree of variance. @since v2.1.4 * @js NA * @lua NA */ bool fuzzyEquals(const Point& target, float variance) const; /** Calculates distance between point an origin @return float @since v2.1.4 * @js NA * @lua NA */ inline float getLength() const { return sqrtf(x*x + y*y); }; /** Calculates the square length of a Point (not calling sqrt() ) @return float @since v2.1.4 * @js NA * @lua NA */ inline float getLengthSq() const { return dot(*this); //x*x + y*y; }; /** Calculates the square distance between two points (not calling sqrt() ) @return float @since v2.1.4 * @js NA * @lua NA */ inline float getDistanceSq(const Point& other) const { return (*this - other).getLengthSq(); }; /** Calculates the distance between two points @return float @since v2.1.4 * @js NA * @lua NA */ inline float getDistance(const Point& other) const { return (*this - other).getLength(); }; /** @returns the angle in radians between this vector and the x axis @since v2.1.4 * @js NA * @lua NA */ inline float getAngle() const { return atan2f(y, x); }; /** @returns the angle in radians between two vector directions @since v2.1.4 * @js NA * @lua NA */ float getAngle(const Point& other) const; /** Calculates dot product of two points. @return float @since v2.1.4 * @js NA * @lua NA */ inline float dot(const Point& other) const { return x*other.x + y*other.y; }; /** Calculates cross product of two points. @return float @since v2.1.4 * @js NA * @lua NA */ inline float cross(const Point& other) const { return x*other.y - y*other.x; }; /** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0 @return Point @since v2.1.4 * @js NA * @lua NA */ inline Point getPerp() const { return Point(-y, x); }; /** Calculates midpoint between two points. @return Point @since v3.0 * @js NA * @lua NA */ inline Point getMidpoint(const Point& other) const { return Point((x + other.x) / 2.0f, (y + other.y) / 2.0f); } /** Clamp a point between from and to. @since v3.0 * @js NA * @lua NA */ inline Point getClampPoint(const Point& min_inclusive, const Point& max_inclusive) const { return Point(clampf(x,min_inclusive.x,max_inclusive.x), clampf(y, min_inclusive.y, max_inclusive.y)); } /** Run a math operation function on each point component * absf, fllorf, ceilf, roundf * any function that has the signature: float func(float); * For example: let's try to take the floor of x,y * p.compOp(floorf); @since v3.0 * @js NA * @lua NA */ inline Point compOp(std::function function) const { return Point(function(x), function(y)); } /** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0 @return Point @since v2.1.4 * @js NA * @lua NA */ inline Point getRPerp() const { return Point(y, -x); }; /** Calculates the projection of this over other. @return Point @since v2.1.4 * @js NA * @lua NA */ inline Point project(const Point& other) const { return other * (dot(other)/other.dot(other)); }; /** Complex multiplication of two points ("rotates" two points). @return Point vector with an angle of this.getAngle() + other.getAngle(), and a length of this.getLength() * other.getLength(). @since v2.1.4 * @js NA * @lua NA */ inline Point rotate(const Point& other) const { return Point(x*other.x - y*other.y, x*other.y + y*other.x); }; /** Unrotates two points. @return Point vector with an angle of this.getAngle() - other.getAngle(), and a length of this.getLength() * other.getLength(). @since v2.1.4 * @js NA * @lua NA */ inline Point unrotate(const Point& other) const { return Point(x*other.x + y*other.y, y*other.x - x*other.y); }; /** Returns point multiplied to a length of 1. * If the point is 0, it returns (1, 0) @return Point @since v2.1.4 * @js NA * @lua NA */ inline Point normalize() const { float length = getLength(); if(length == 0.) return Point(1.f, 0); return *this / getLength(); }; /** Linear Interpolation between two points a and b @returns alpha == 0 ? a alpha == 1 ? b otherwise a value between a..b @since v2.1.4 * @js NA * @lua NA */ inline Point lerp(const Point& other, float alpha) const { return *this * (1.f - alpha) + other * alpha; }; /** Rotates a point counter clockwise by the angle around a pivot @param pivot is the pivot, naturally @param angle is the angle of rotation ccw in radians @returns the rotated point @since v2.1.4 * @js NA * @lua NA */ Point rotateByAngle(const Point& pivot, float angle) const; /** * @js NA * @lua NA */ static inline Point forAngle(const float a) { return Point(cosf(a), sinf(a)); } /** A general line-line intersection test @param A the startpoint for the first line L1 = (A - B) @param B the endpoint for the first line L1 = (A - B) @param C the startpoint for the second line L2 = (C - D) @param D the endpoint for the second line L2 = (C - D) @param S the range for a hitpoint in L1 (p = A + S*(B - A)) @param T the range for a hitpoint in L2 (p = C + T*(D - C)) @returns whether these two lines interects. Note that to truly test intersection for segments we have to make sure that S & T lie within [0..1] and for rays, make sure S & T > 0 the hit point is C + T * (D - C); the hit point also is A + S * (B - A); @since 3.0 * @js NA * @lua NA */ static bool isLineIntersect(const Point& A, const Point& B, const Point& C, const Point& D, float *S = nullptr, float *T = nullptr); /** returns true if Line A-B overlap with segment C-D @since v3.0 * @js NA * @lua NA */ static bool isLineOverlap(const Point& A, const Point& B, const Point& C, const Point& D); /** returns true if Line A-B parallel with segment C-D @since v3.0 * @js NA * @lua NA */ static bool isLineParallel(const Point& A, const Point& B, const Point& C, const Point& D); /** returns true if Segment A-B overlap with segment C-D @since v3.0 * @js NA * @lua NA */ static bool isSegmentOverlap(const Point& A, const Point& B, const Point& C, const Point& D, Point* S = nullptr, Point* E = nullptr); /** returns true if Segment A-B intersects with segment C-D @since v3.0 * @js NA * @lua NA */ static bool isSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D); /** returns the intersection point of line A-B, C-D @since v3.0 * @js NA * @lua NA */ static Point getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D); /** equals to Point(0,0) */ static const Point ZERO; /** equals to Point(0.5, 0.5) */ static const Point ANCHOR_MIDDLE; /** equals to Point(0, 0) */ static const Point ANCHOR_BOTTOM_LEFT; /** equals to Point(0, 1) */ static const Point ANCHOR_TOP_LEFT; /** equals to Point(1, 0) */ static const Point ANCHOR_BOTTOM_RIGHT; /** equals to Point(1, 1) */ static const Point ANCHOR_TOP_RIGHT; /** equals to Point(1, 0.5) */ static const Point ANCHOR_MIDDLE_RIGHT; /** equals to Point(0, 0.5) */ static const Point ANCHOR_MIDDLE_LEFT; /** equals to Point(0.5, 1) */ static const Point ANCHOR_MIDDLE_TOP; /** equals to Point(0.5, 0) */ static const Point ANCHOR_MIDDLE_BOTTOM; private: // returns true if segment A-B intersects with segment C-D. S->E is the ovderlap part static bool isOneDemensionSegmentOverlap(float A, float B, float C, float D, float *S, float * E); // cross procuct of 2 vector. A->B X C->D static float crossProduct2Vector(const Point& A, const Point& B, const Point& C, const Point& D) { return (D.y - C.y) * (B.x - A.x) - (D.x - C.x) * (B.y - A.y); } }; class CC_DLL Size { public: float width; float height; public: /** * @js NA */ Size(); /** * @js NA */ Size(float width, float height); /** * @js NA * @lua NA */ Size(const Size& other); /** * @js NA * @lua NA */ explicit Size(const Point& point); /** * @js NA * @lua NA */ Size& operator= (const Size& other); /** * @js NA * @lua NA */ Size& operator= (const Point& point); /** * @js NA * @lua NA */ Size operator+(const Size& right) const; /** * @js NA * @lua NA */ Size operator-(const Size& right) const; /** * @js NA * @lua NA */ Size operator*(float a) const; /** * @js NA * @lua NA */ Size operator/(float a) const; /** * @js NA * @lua NA */ void setSize(float width, float height); /** * @js NA */ bool equals(const Size& target) const; static const Size ZERO; }; class CC_DLL Rect { public: Point origin; Size size; public: /** * @js NA */ Rect(); /** * @js NA */ Rect(float x, float y, float width, float height); /** * @js NA * @lua NA */ Rect(const Rect& other); /** * @js NA * @lua NA */ Rect& operator= (const Rect& other); /** * @js NA * @lua NA */ void setRect(float x, float y, float width, float height); /** * @js NA */ float getMinX() const; /// return the leftmost x-value of current rect /** * @js NA */ float getMidX() const; /// return the midpoint x-value of current rect /** * @js NA */ float getMaxX() const; /// return the rightmost x-value of current rect /** * @js NA */ float getMinY() const; /// return the bottommost y-value of current rect /** * @js NA */ float getMidY() const; /// return the midpoint y-value of current rect /** * @js NA */ float getMaxY() const; /// return the topmost y-value of current rect /** * @js NA */ bool equals(const Rect& rect) const; /** * @js NA */ bool containsPoint(const Point& point) const; /** * @js NA */ bool intersectsRect(const Rect& rect) const; /** * @js NA * @lua NA */ Rect unionWithRect(const Rect & rect) const; static const Rect ZERO; }; // end of data_structure group /// @} NS_CC_END #endif // __CCGEMETRY_H__ ================================================ FILE: cocos2d/cocos/base/CCInteger.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies 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 __CCINTEGER_H__ #define __CCINTEGER_H__ #include "CCObject.h" #include "platform/CCCommon.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ class CC_DLL __Integer : public Object, public Clonable { public: static __Integer* create(int v) { __Integer* pRet = new __Integer(v); pRet->autorelease(); return pRet; } /** * @js NA */ __Integer(int v) : _value(v) {} int getValue() const {return _value;} /** * @js NA * @lua NA */ virtual ~__Integer() { CCLOGINFO("deallocing ~__Integer: %p", this); } /* override functions */ virtual void acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } // overrides virtual __Integer* clone() const override { return __Integer::create(_value); } private: int _value; }; // end of data_structure group /// @} NS_CC_END #endif /* __CCINTEGER_H__ */ ================================================ FILE: cocos2d/cocos/base/CCMap.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies 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 __CCMAP_H__ #define __CCMAP_H__ #define USE_STD_UNORDERED_MAP 1 #include "ccMacros.h" #include "CCObject.h" #include #if USE_STD_UNORDERED_MAP #include #else #include #endif NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ template class CC_DLL Map { public: // ------------------------------------------ // Iterators // ------------------------------------------ #if USE_STD_UNORDERED_MAP typedef std::unordered_map RefMap; #else typedef std::map RefMap; #endif typedef typename RefMap::iterator iterator; typedef typename RefMap::const_iterator const_iterator; iterator begin() { return _data.begin(); } const_iterator begin() const { return _data.begin(); } iterator end() { return _data.end(); } const_iterator end() const { return _data.end(); } const_iterator cbegin() const { return _data.cbegin(); } const_iterator cend() const { return _data.cend(); } /** Default constructor */ Map() : _data() { static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the default constructor of Map!"); } /** Contructor with capacity */ explicit Map(ssize_t capacity) : _data() { static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the constructor with capacity of Map!"); _data.reserve(capacity); } /** Copy constructor */ Map(const Map& other) { static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the copy constructor of Map!"); _data = other._data; addRefForAllObjects(); } /** Move constructor */ Map(Map&& other) { static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the move constructor of Map!"); _data = std::move(other._data); } /** Destructor * It will release all objects in map. */ ~Map() { CCLOGINFO("In the destructor of Map!"); clear(); } /** Sets capacity of the map */ void reserve(ssize_t capacity) { #if USE_STD_UNORDERED_MAP _data.reserve(capacity); #endif } /** Returns the number of buckets in the Map container. */ ssize_t bucketCount() const { #if USE_STD_UNORDERED_MAP return _data.bucket_count(); #else return 0; #endif } /** Returns the number of elements in bucket n. */ ssize_t bucketSize(ssize_t n) const { #if USE_STD_UNORDERED_MAP return _data.bucket_size(n); #else return 0; #endif } /** Returns the bucket number where the element with key k is located. */ ssize_t bucket(const K& k) const { #if USE_STD_UNORDERED_MAP return _data.bucket(k); #else return 0; #endif } /** The number of elements in the map. */ ssize_t size() const { return _data.size(); } /** Returns a bool value indicating whether the map container is empty, i.e. whether its size is 0. * @note This function does not modify the content of the container in any way. * To clear the content of an array object, member function unordered_map::clear exists. */ bool empty() const { return _data.empty(); } /** Returns all keys in the map */ std::vector keys() const { std::vector keys; if (!_data.empty()) { keys.reserve(_data.size()); for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter) { keys.push_back(iter->first); } } return keys; } /** Returns all keys that matches the object */ std::vector keys(V object) const { std::vector keys; if (!_data.empty()) { keys.reserve(_data.size() / 10); for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter) { if (iter->second == object) { keys.push_back(iter->first); } } } keys.shrink_to_fit(); return keys; } /** @brief Returns a reference to the mapped value of the element with key k in the map. * @note If key does not match the key of any element in the container, the function return nullptr. * @param key Key value of the element whose mapped value is accessed. * Member type K is the keys for the elements in the container. defined in Map as an alias of its first template parameter (Key). */ const V at(const K& key) const { auto iter = _data.find(key); if (iter != _data.end()) return iter->second; return nullptr; } V at(const K& key) { auto iter = _data.find(key); if (iter != _data.end()) return iter->second; return nullptr; } /** @brief Searches the container for an element with 'key' as key and returns an iterator to it if found, * otherwise it returns an iterator to Map::end (the element past the end of the container). * @param key Key to be searched for. * Member type 'K' is the type of the keys for the elements in the container, * defined in Map as an alias of its first template parameter (Key). * */ const_iterator find(const K& key) const { return _data.find(key); } iterator find(const K& key) { return _data.find(key); } /** @brief Inserts new elements in the map. * @note If the container has already contained the key, this function will erase the old pair(key, object) and insert the new pair. * @param key The key to be inserted. * @param object The object to be inserted. */ void insert(const K& key, V object) { CCASSERT(object != nullptr, "Object is nullptr!"); erase(key); _data.insert(std::make_pair(key, object)); object->retain(); } /** @brief Removes an element with an iterator from the Map container. * @param position Iterator pointing to a single element to be removed from the Map. * Member type const_iterator is a forward iterator type. */ iterator erase(const_iterator position) { CCASSERT(position != _data.cend(), "Invalid iterator!"); position->second->release(); return _data.erase(position); } /** @brief Removes an element with an iterator from the Map container. * @param k Key of the element to be erased. * Member type 'K' is the type of the keys for the elements in the container, * defined in Map as an alias of its first template parameter (Key). */ size_t erase(const K& k) { auto iter = _data.find(k); if (iter != _data.end()) { iter->second->release(); _data.erase(iter); return 1; } return 0; } /** @brief Removes some elements with a vector which contains keys in the map. * @param keys Keys of elements to be erased. */ void erase(const std::vector& keys) { for(const auto &key : keys) { this->erase(key); } } /** All the elements in the Map container are dropped: * their reference count will be decreased, and they are removed from the container, * leaving it with a size of 0. */ void clear() { for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter) { iter->second->release(); } _data.clear(); } /** @brief Gets a random object in the map * @return Returns the random object if the map isn't empty, otherwise it returns nullptr. */ V getRandomObject() const { if (!_data.empty()) { ssize_t randIdx = rand() % _data.size(); const_iterator randIter = _data.begin(); std::advance(randIter , randIdx); return randIter->second; } return nullptr; } // Don't uses operator since we could not decide whether it needs 'retain'/'release'. // V& operator[] ( const K& key ) // { // CCLOG("copy: [] ref"); // return _data[key]; // } // // V& operator[] ( K&& key ) // { // CCLOG("move [] ref"); // return _data[key]; // } // const V& operator[] ( const K& key ) const // { // CCLOG("const copy []"); // return _data.at(key); // } // // const V& operator[] ( K&& key ) const // { // CCLOG("const move []"); // return _data.at(key); // } /** Copy assignment operator */ Map& operator= ( const Map& other ) { if (this != &other) { CCLOGINFO("In the copy assignment operator of Map!"); clear(); _data = other._data; addRefForAllObjects(); } return *this; } /** Move assignment operator */ Map& operator= ( Map&& other ) { if (this != &other) { CCLOGINFO("In the move assignment operator of Map!"); clear(); _data = std::move(other._data); } return *this; } protected: /** Retains all the objects in the map */ void addRefForAllObjects() { for (auto iter = _data.begin(); iter != _data.end(); ++iter) { iter->second->retain(); } } RefMap _data; }; // end of data_structure group /// @} NS_CC_END #endif /* __CCMAP_H__ */ ================================================ FILE: cocos2d/cocos/base/CCNS.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 "CCNS.h" #include #include #include #include using namespace std; NS_CC_BEGIN typedef std::vector strArray; // string toolkit static inline void split(const std::string& src, const std::string& token, strArray& vect) { size_t nend = 0; size_t nbegin = 0; size_t tokenSize = token.size(); while(nend != std::string::npos) { nend = src.find(token, nbegin); if(nend == std::string::npos) vect.push_back(src.substr(nbegin, src.length()-nbegin)); else vect.push_back(src.substr(nbegin, nend-nbegin)); nbegin = nend + tokenSize; } } // first, judge whether the form of the string like this: {x,y} // if the form is right,the string will be split into the parameter strs; // or the parameter strs will be empty. // if the form is right return true,else return false. static bool splitWithForm(const std::string& str, strArray& strs) { bool bRet = false; do { CC_BREAK_IF(str.empty()); // string is empty std::string content = str; CC_BREAK_IF(content.length() == 0); size_t nPosLeft = content.find('{'); size_t nPosRight = content.find('}'); // don't have '{' and '}' CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos); // '}' is before '{' CC_BREAK_IF(nPosLeft > nPosRight); std::string pointStr = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1); // nothing between '{' and '}' CC_BREAK_IF(pointStr.length() == 0); size_t nPos1 = pointStr.find('{'); size_t nPos2 = pointStr.find('}'); // contain '{' or '}' CC_BREAK_IF(nPos1 != std::string::npos || nPos2 != std::string::npos); split(pointStr, ",", strs); if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0) { strs.clear(); break; } bRet = true; } while (0); return bRet; } // implement the functions Rect RectFromString(const std::string& str) { Rect result = Rect::ZERO; do { CC_BREAK_IF(str.empty()); std::string content = str; // find the first '{' and the third '}' size_t nPosLeft = content.find('{'); size_t nPosRight = content.find('}'); for (int i = 1; i < 3; ++i) { if (nPosRight == std::string::npos) { break; } nPosRight = content.find('}', nPosRight + 1); } CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos); content = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1); size_t nPointEnd = content.find('}'); CC_BREAK_IF(nPointEnd == std::string::npos); nPointEnd = content.find(',', nPointEnd); CC_BREAK_IF(nPointEnd == std::string::npos); // get the point string and size string std::string pointStr = content.substr(0, nPointEnd); std::string sizeStr = content.substr(nPointEnd + 1, content.length() - nPointEnd); // split the string with ',' strArray pointInfo; CC_BREAK_IF(!splitWithForm(pointStr.c_str(), pointInfo)); strArray sizeInfo; CC_BREAK_IF(!splitWithForm(sizeStr.c_str(), sizeInfo)); float x = (float) atof(pointInfo[0].c_str()); float y = (float) atof(pointInfo[1].c_str()); float width = (float) atof(sizeInfo[0].c_str()); float height = (float) atof(sizeInfo[1].c_str()); result = Rect(x, y, width, height); } while (0); return result; } Point PointFromString(const std::string& str) { Point ret = Point::ZERO; do { strArray strs; CC_BREAK_IF(!splitWithForm(str, strs)); float x = (float) atof(strs[0].c_str()); float y = (float) atof(strs[1].c_str()); ret = Point(x, y); } while (0); return ret; } Size SizeFromString(const std::string& pszContent) { Size ret = Size::ZERO; do { strArray strs; CC_BREAK_IF(!splitWithForm(pszContent, strs)); float width = (float) atof(strs[0].c_str()); float height = (float) atof(strs[1].c_str()); ret = Size(width, height); } while (0); return ret; } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCNS.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 __PLATFOMR_CCNS_H__ #define __PLATFOMR_CCNS_H__ #include "CCGeometry.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ /** @brief Returns a Core Graphics rectangle structure corresponding to the data in a given string. @param pszContent A string object whose contents are of the form "{{x,y},{w, h}}", where x is the x coordinate, y is the y coordinate, w is the width, and h is the height. These components can represent integer or float values. An example of a valid string is "{{3,2},{4,5}}". The string is not localized, so items are always separated with a comma. @return A Core Graphics structure that represents a rectangle. If the string is not well-formed, the function returns Rect::ZERO. */ Rect CC_DLL RectFromString(const std::string& str); /** @brief Returns a Core Graphics point structure corresponding to the data in a given string. @param pszContent A string object whose contents are of the form "{x,y}", where x is the x coordinate and y is the y coordinate. The x and y values can represent integer or float values. An example of a valid string is "{3.0,2.5}". The string is not localized, so items are always separated with a comma. @return A Core Graphics structure that represents a point. If the string is not well-formed, the function returns Point::ZERO. */ Point CC_DLL PointFromString(const std::string& str); /** @brief Returns a Core Graphics size structure corresponding to the data in a given string. @param pszContent A string object whose contents are of the form "{w, h}", where w is the width and h is the height. The w and h values can be integer or float values. An example of a valid string is "{3.0,2.5}". The string is not localized, so items are always separated with a comma. @return A Core Graphics structure that represents a size. If the string is not well-formed, the function returns Size::ZERO. */ Size CC_DLL SizeFromString(const std::string& str); // end of data_structure group /// @} NS_CC_END #endif // __PLATFOMR_CCNS_H__ ================================================ FILE: cocos2d/cocos/base/CCObject.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 "CCObject.h" #include "CCAutoreleasePool.h" #include "ccMacros.h" #include "CCScriptSupport.h" NS_CC_BEGIN Object::Object() : _luaID(0) , _referenceCount(1) // when the object is created, the reference count of it is 1 { static unsigned int uObjectCount = 0; _ID = ++uObjectCount; } Object::~Object() { // if the object is referenced by Lua engine, remove it if (_luaID) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptObjectByObject(this); } else { ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript) { pEngine->removeScriptObjectByObject(this); } } } Object* Object::autorelease() { PoolManager::getInstance()->getCurrentPool()->addObject(this); return this; } void Object::release() { CCASSERT(_referenceCount > 0, "reference count should greater than 0"); --_referenceCount; if (_referenceCount == 0) { #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) auto poolManager = PoolManager::getInstance(); if (!poolManager->getCurrentPool()->isClearing() && poolManager->isObjectInPools(this)) { // Trigger an assert if the reference count is 0 but the object is still in autorelease pool. // This happens when 'autorelease/release' were not used in pairs with 'new/retain'. // // Wrong usage (1): // // auto obj = Node::create(); // Ref = 1, but it's an autorelease object which means it was in the autorelease pool. // obj->autorelease(); // Wrong: If you wish to invoke autorelease several times, you should retain `obj` first. // // Wrong usage (2): // // auto obj = Node::create(); // obj->release(); // Wrong: obj is an autorelease object, it will be released when clearing current pool. // // Correct usage (1): // // auto obj = Node::create(); // |- new Node(); // `new` is the pair of the `autorelease` of next line // |- autorelease(); // The pair of `new Node`. // // obj->retain(); // obj->autorelease(); // This `autorelease` is the pair of `retain` of previous line. // // Correct usage (2): // // auto obj = Node::create(); // obj->retain(); // obj->release(); // This `release` is the pair of `retain` of previous line. CCASSERT(false, "The reference shouldn't be 0 because it is still in autorelease pool."); } #endif delete this; } } bool Object::isSingleReference() const { return _referenceCount == 1; } unsigned int Object::getReferenceCount() const { return _referenceCount; } bool Object::isEqual(const Object *object) { return this == object; } void Object::acceptVisitor(DataVisitor &visitor) { visitor.visitObject(this); } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCObject.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 __CCOBJECT_H__ #define __CCOBJECT_H__ #include "CCDataVisitor.h" #include "ccMacros.h" #include "CCConsole.h" #ifdef EMSCRIPTEN #include #endif // EMSCRIPTEN NS_CC_BEGIN /** * @addtogroup base_nodes * @{ */ class Object; class Node; /** Interface that defines how to clone an object */ class CC_DLL Clonable { public: /** returns a copy of the object */ virtual Clonable* clone() const = 0; /** * @js NA * @lua NA */ virtual ~Clonable() {}; /** returns a copy of the object. @deprecated Use clone() instead */ CC_DEPRECATED_ATTRIBUTE Object* copy() const { // use "clone" instead CC_ASSERT(false); return nullptr; } }; class CC_DLL Object { public: /// object id, ScriptSupport need public _ID unsigned int _ID; /// Lua reference id int _luaID; protected: /// count of references unsigned int _referenceCount; public: /** * Constructor * * The object's reference count is 1 after construction. * @js NA */ Object(); /** * @js NA * @lua NA */ virtual ~Object(); /** * Release the ownership immediately. * * This decrements the object's reference count. * * If the reference count reaches 0 after the descrement, this object is * destructed. * * @see retain, autorelease * @js NA */ void release(); /** * Retains the ownership. * * This increases the object's reference count. * * @see release, autorelease * @js NA */ inline void retain() { CCASSERT(_referenceCount > 0, "reference count should greater than 0"); ++_referenceCount; } /** * Release the ownership sometime soon automatically. * * This descrements the object's reference count at the end of current * autorelease pool block. * * If the reference count reaches 0 after the descrement, this object is * destructed. * * @returns The object itself. * * @see AutoreleasePool, retain, release * @js NA * @lua NA */ Object* autorelease(); /** * Returns a boolean value that indicates whether there is only one * reference to the object. That is, whether the reference count is 1. * * @returns Whether the object's reference count is 1. * @js NA */ CC_DEPRECATED_ATTRIBUTE bool isSingleReference() const; /** * Returns the object's current reference count. * * @returns The object's reference count. * @js NA */ CC_DEPRECATED_ATTRIBUTE unsigned int retainCount() const { return getReferenceCount(); }; unsigned int getReferenceCount() const; /** * Returns a boolean value that indicates whether this object and a given * object are equal. * * @param object The object to be compared to this object. * * @returns True if this object and @p object are equal, otherwise false. * @js NA * @lua NA */ virtual bool isEqual(const Object* object); /** * @js NA * @lua NA */ virtual void acceptVisitor(DataVisitor &visitor); /** * @js NA * @lua NA */ virtual void update(float dt) {CC_UNUSED_PARAM(dt);}; friend class AutoreleasePool; }; typedef void (Object::*SEL_SCHEDULE)(float); typedef void (Object::*SEL_CallFunc)(); typedef void (Object::*SEL_CallFuncN)(Node*); typedef void (Object::*SEL_CallFuncND)(Node*, void*); typedef void (Object::*SEL_CallFuncO)(Object*); typedef void (Object::*SEL_MenuHandler)(Object*); typedef int (Object::*SEL_Compare)(Object*); #define schedule_selector(_SELECTOR) static_cast(&_SELECTOR) #define callfunc_selector(_SELECTOR) static_cast(&_SELECTOR) #define callfuncN_selector(_SELECTOR) static_cast(&_SELECTOR) #define callfuncND_selector(_SELECTOR) static_cast(&_SELECTOR) #define callfuncO_selector(_SELECTOR) static_cast(&_SELECTOR) #define menu_selector(_SELECTOR) static_cast(&_SELECTOR) #define event_selector(_SELECTOR) static_cast(&_SELECTOR) #define compare_selector(_SELECTOR) static_cast(&_SELECTOR) // new callbacks based on C++11 #define CC_CALLBACK_0(__selector__,__target__, ...) std::bind(&__selector__,__target__, ##__VA_ARGS__) #define CC_CALLBACK_1(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, ##__VA_ARGS__) #define CC_CALLBACK_2(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, ##__VA_ARGS__) #define CC_CALLBACK_3(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3 ##__VA_ARGS__) // end of base_nodes group /// @} NS_CC_END #endif // __CCOBJECT_H__ ================================================ FILE: cocos2d/cocos/base/CCPlatformConfig.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 __CC_PLATFORM_CONFIG_H__ #define __CC_PLATFORM_CONFIG_H__ /** Config of cocos2d-x project, per target platform. */ ////////////////////////////////////////////////////////////////////////// // pre configure ////////////////////////////////////////////////////////////////////////// // define supported target platform macro which CC uses. #define CC_PLATFORM_UNKNOWN 0 #define CC_PLATFORM_IOS 1 #define CC_PLATFORM_ANDROID 2 #define CC_PLATFORM_WIN32 3 #define CC_PLATFORM_MARMALADE 4 #define CC_PLATFORM_LINUX 5 #define CC_PLATFORM_BADA 6 #define CC_PLATFORM_BLACKBERRY 7 #define CC_PLATFORM_MAC 8 #define CC_PLATFORM_NACL 9 #define CC_PLATFORM_EMSCRIPTEN 10 #define CC_PLATFORM_TIZEN 11 #define CC_PLATFORM_QT5 12 // Determine target platform by compile environment macro. #define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN // mac #if defined(CC_TARGET_OS_MAC) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_MAC #endif // iphone #if defined(CC_TARGET_OS_IPHONE) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_IOS #endif // android #if defined(ANDROID) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_ANDROID #endif // win32 #if defined(WIN32) && defined(_WINDOWS) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_WIN32 #endif // linux #if defined(LINUX) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_LINUX #endif // marmalade #if defined(MARMALADE) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_MARMALADE #endif // bada #if defined(SHP) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_BADA #endif // qnx #if defined(__QNX__) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_BLACKBERRY #endif // native client #if defined(__native_client__) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_NACL #endif // Emscripten #if defined(EMSCRIPTEN) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_EMSCRIPTEN #endif // tizen #if defined(TIZEN) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_TIZEN #endif // qt5 #if defined(CC_TARGET_QT5) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_QT5 #endif ////////////////////////////////////////////////////////////////////////// // post configure ////////////////////////////////////////////////////////////////////////// // check user set platform #if ! CC_TARGET_PLATFORM #error "Cannot recognize the target platform; are you targeting an unsupported platform?" #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #ifndef __MINGW32__ #pragma warning (disable:4127) #endif #endif // CC_PLATFORM_WIN32 #endif // __CC_PLATFORM_CONFIG_H__ ================================================ FILE: cocos2d/cocos/base/CCPlatformMacros.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 __CC_PLATFORM_MACROS_H__ #define __CC_PLATFORM_MACROS_H__ /** * define some platform specific macros */ #include "ccConfig.h" #include "CCPlatformConfig.h" #include "CCPlatformDefine.h" /** * define a create function for a specific type, such as Layer * @param \__TYPE__ class type to add create(), such as Layer */ #define CREATE_FUNC(__TYPE__) \ static __TYPE__* create() \ { \ __TYPE__ *pRet = new __TYPE__(); \ if (pRet && pRet->init()) \ { \ pRet->autorelease(); \ return pRet; \ } \ else \ { \ delete pRet; \ pRet = NULL; \ return NULL; \ } \ } /** * define a node function for a specific type, such as Layer * @param \__TYPE__ class type to add node(), such as Layer * @deprecated This interface will be deprecated sooner or later. */ #define NODE_FUNC(__TYPE__) \ CC_DEPRECATED_ATTRIBUTE static __TYPE__* node() \ { \ __TYPE__ *pRet = new __TYPE__(); \ if (pRet && pRet->init()) \ { \ pRet->autorelease(); \ return pRet; \ } \ else \ { \ delete pRet; \ pRet = NULL; \ return NULL; \ } \ } /** @def CC_ENABLE_CACHE_TEXTURE_DATA Enable it if you want to cache the texture data. Not enabling for Emscripten any more -- doesn't seem necessary and don't want to be different from other platforms unless there's a good reason. It's new in cocos2d-x since v0.99.5 */ #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #define CC_ENABLE_CACHE_TEXTURE_DATA 1 #else #define CC_ENABLE_CACHE_TEXTURE_DATA 0 #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN) /* Application will crash in glDrawElements function on some win32 computers and some android devices. Indices should be bound again while drawing to avoid this bug. */ #define CC_REBIND_INDICES_BUFFER 1 #else #define CC_REBIND_INDICES_BUFFER 0 #endif // generic macros // namespace cocos2d {} #ifdef __cplusplus #define NS_CC_BEGIN namespace cocos2d { #define NS_CC_END } #define USING_NS_CC using namespace cocos2d #else #define NS_CC_BEGIN #define NS_CC_END #define USING_NS_CC #endif /** CC_PROPERTY_READONLY is used to declare a protected variable. We can use getter to read the variable. @param varType the type of variable. @param varName variable name. @param funName "get + funName" will be the name of the getter. @warning The getter is a public virtual function, you should rewrite it first. The variables and methods declared after CC_PROPERTY_READONLY are all public. If you need protected or private, please declare. */ #define CC_PROPERTY_READONLY(varType, varName, funName)\ protected: varType varName;\ public: virtual varType get##funName(void) const; #define CC_PROPERTY_READONLY_PASS_BY_REF(varType, varName, funName)\ protected: varType varName;\ public: virtual const varType& get##funName(void) const; /** CC_PROPERTY is used to declare a protected variable. We can use getter to read the variable, and use the setter to change the variable. @param varType the type of variable. @param varName variable name. @param funName "get + funName" will be the name of the getter. "set + funName" will be the name of the setter. @warning The getter and setter are public virtual functions, you should rewrite them first. The variables and methods declared after CC_PROPERTY are all public. If you need protected or private, please declare. */ #define CC_PROPERTY(varType, varName, funName)\ protected: varType varName;\ public: virtual varType get##funName(void);\ public: virtual void set##funName(varType var); #define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)\ protected: varType varName;\ public: virtual const varType& get##funName(void) const;\ public: virtual void set##funName(const varType& var); /** CC_SYNTHESIZE_READONLY is used to declare a protected variable. We can use getter to read the variable. @param varType the type of variable. @param varName variable name. @param funName "get + funName" will be the name of the getter. @warning The getter is a public inline function. The variables and methods declared after CC_SYNTHESIZE_READONLY are all public. If you need protected or private, please declare. */ #define CC_SYNTHESIZE_READONLY(varType, varName, funName)\ protected: varType varName;\ public: virtual varType get##funName(void) const { return varName; } #define CC_SYNTHESIZE_READONLY_PASS_BY_REF(varType, varName, funName)\ protected: varType varName;\ public: virtual const varType& get##funName(void) const { return varName; } /** CC_SYNTHESIZE is used to declare a protected variable. We can use getter to read the variable, and use the setter to change the variable. @param varType the type of variable. @param varName variable name. @param funName "get + funName" will be the name of the getter. "set + funName" will be the name of the setter. @warning The getter and setter are public inline functions. The variables and methods declared after CC_SYNTHESIZE are all public. If you need protected or private, please declare. */ #define CC_SYNTHESIZE(varType, varName, funName)\ protected: varType varName;\ public: virtual varType get##funName(void) const { return varName; }\ public: virtual void set##funName(varType var){ varName = var; } #define CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)\ protected: varType varName;\ public: virtual const varType& get##funName(void) const { return varName; }\ public: virtual void set##funName(const varType& var){ varName = var; } #define CC_SYNTHESIZE_RETAIN(varType, varName, funName) \ private: varType varName; \ public: virtual varType get##funName(void) const { return varName; } \ public: virtual void set##funName(varType var) \ { \ if (varName != var) \ { \ CC_SAFE_RETAIN(var); \ CC_SAFE_RELEASE(varName); \ varName = var; \ } \ } #define CC_SAFE_DELETE(p) do { delete (p); (p) = nullptr; } while(0) #define CC_SAFE_DELETE_ARRAY(p) do { if(p) { delete[] (p); (p) = nullptr; } } while(0) #define CC_SAFE_FREE(p) do { if(p) { free(p); (p) = nullptr; } } while(0) #define CC_SAFE_RELEASE(p) do { if(p) { (p)->release(); } } while(0) #define CC_SAFE_RELEASE_NULL(p) do { if(p) { (p)->release(); (p) = nullptr; } } while(0) #define CC_SAFE_RETAIN(p) do { if(p) { (p)->retain(); } } while(0) #define CC_BREAK_IF(cond) if(cond) break #define __CCLOGWITHFUNCTION(s, ...) \ log("%s : %s",__FUNCTION__, StringUtils::format(s, ##__VA_ARGS__).c_str()) // cocos2d debug #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 #define CCLOG(...) do {} while (0) #define CCLOGINFO(...) do {} while (0) #define CCLOGERROR(...) do {} while (0) #define CCLOGWARN(...) do {} while (0) #elif COCOS2D_DEBUG == 1 #define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__) #define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__) #define CCLOGINFO(format,...) do {} while (0) #define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__) #elif COCOS2D_DEBUG > 1 #define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__) #define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__) #define CCLOGINFO(format,...) cocos2d::log(format, ##__VA_ARGS__) #define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__) #endif // COCOS2D_DEBUG // Lua engine debug #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 || CC_LUA_ENGINE_DEBUG == 0 #define LUALOG(...) #else #define LUALOG(format, ...) cocos2d::log(format, ##__VA_ARGS__) #endif // Lua engine debug // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #if defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUG__ == 4) && (__GNUC_MINOR__ >= 4))) \ || (defined(__clang__) && (__clang_major__ >= 3)) || (_MSC_VER >= 1800) #define CC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName &) = delete; \ TypeName &operator =(const TypeName &) = delete; #else #define CC_DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName &); \ TypeName &operator =(const TypeName &); #endif // A macro to disallow all the implicit constructors, namely the // default constructor, copy constructor and operator= functions. // // This should be used in the private: declarations for a class // that wants to prevent anyone from instantiating it. This is // especially useful for classes containing only static methods. #define CC_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ TypeName(); \ CC_DISALLOW_COPY_AND_ASSIGN(TypeName) /* * only certain compilers support __attribute__((deprecated)) */ #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #define CC_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) #elif _MSC_VER >= 1400 //vs 2005 or higher #define CC_DEPRECATED_ATTRIBUTE __declspec(deprecated) #else #define CC_DEPRECATED_ATTRIBUTE #endif /* * only certain compiler support __attribute__((format)) * formatPos - 1-based position of format string argument * argPos - 1-based position of first format-dependent argument */ #if defined(__GNUC__) && (__GNUC__ >= 4) #define CC_FORMAT_PRINTF(formatPos, argPos) __attribute__((__format__(printf, formatPos, argPos))) #elif defined(__has_attribute) #if __has_attribute(format) #define CC_FORMAT_PRINTF(formatPos, argPos) __attribute__((__format__(printf, formatPos, argPos))) #endif // __has_attribute(format) #else #define CC_FORMAT_PRINTF(formatPos, argPos) #endif #if defined(_MSC_VER) #define CC_FORMAT_PRINTF_SIZE_T "%08lX" #else #define CC_FORMAT_PRINTF_SIZE_T "%08zX" #endif #ifdef __GNUC__ #define CC_UNUSED __attribute__ ((unused)) #else #define CC_UNUSED #endif // // CC_REQUIRES_NULL_TERMINATION // #if !defined(CC_REQUIRES_NULL_TERMINATION) #if defined(__APPLE_CC__) && (__APPLE_CC__ >= 5549) #define CC_REQUIRES_NULL_TERMINATION __attribute__((sentinel(0,1))) #elif defined(__GNUC__) #define CC_REQUIRES_NULL_TERMINATION __attribute__((sentinel)) #else #define CC_REQUIRES_NULL_TERMINATION #endif #endif #endif // __CC_PLATFORM_MACROS_H__ ================================================ FILE: cocos2d/cocos/base/CCSet.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 "CCSet.h" using namespace std; NS_CC_BEGIN __Set::__Set(void) { _set = new set; } __Set::__Set(const __Set &r__SetObject) { _set = new set(*r__SetObject._set); // call retain of members __SetIterator iter; for (iter = _set->begin(); iter != _set->end(); ++iter) { if (! (*iter)) { break; } (*iter)->retain(); } } __Set::~__Set(void) { removeAllObjects(); CC_SAFE_DELETE(_set); } void __Set::acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } __Set * __Set::create() { __Set * pRet = new __Set(); if (pRet != NULL) { pRet->autorelease(); } return pRet; } __Set* __Set::copy(void) { __Set *p__Set = new __Set(*this); return p__Set; } __Set* __Set::mutableCopy(void) { return copy(); } int __Set::count(void) { return (int)_set->size(); } void __Set::addObject(Object *pObject) { if (_set->count(pObject) == 0) { CC_SAFE_RETAIN(pObject); _set->insert(pObject); } } void __Set::removeObject(Object *pObject) { if (_set->erase(pObject) > 0) { CC_SAFE_RELEASE(pObject); } } void __Set::removeAllObjects() { __SetIterator it = _set->begin(); __SetIterator tmp; while (it != _set->end()) { if (!(*it)) { break; } tmp = it; ++tmp; Object * obj = *it; _set->erase(it); CC_SAFE_RELEASE(obj); it = tmp; } } bool __Set::containsObject(Object *pObject) { return _set->find(pObject) != _set->end(); } __SetIterator __Set::begin(void) { return _set->begin(); } __SetIterator __Set::end(void) { return _set->end(); } Object* __Set::anyObject() { if (!_set || _set->empty()) { return 0; } __SetIterator it; for( it = _set->begin(); it != _set->end(); ++it) { if (*it) { return (*it); } } return 0; } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCSet.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 __CC_SET_H__ #define __CC_SET_H__ #include #include "CCObject.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ typedef std::set::iterator __SetIterator; class CC_DLL __Set : public Object { public: /** * @js ctor */ __Set(void); __Set(const __Set &rSetObject); /** * @js NA * @lua NA */ virtual ~__Set(void); /** * @brief Create and return a new empty set. */ static __Set * create(); /** *@brief Return a copy of the Set, it will copy all the elements. */ __Set* copy(); /** *@brief It is the same as copy(). */ __Set* mutableCopy(); /** *@brief Return the number of elements the Set contains. */ int count(); /** *@brief Add a element into Set, it will retain the element. */ void addObject(Object *pObject); /** *@brief Remove the given element, nothing todo if no element equals pObject. */ void removeObject(Object *pObject); /** *@brief Remove all elements of the set */ void removeAllObjects(); /** *@brief Check if Set contains a element equals pObject. */ bool containsObject(Object *pObject); /** *@brief Return the iterator that points to the first element. * @js NA * @lua NA */ __SetIterator begin(); /** *@brief Return the iterator that points to the position after the last element. * @js NA * @lua NA */ __SetIterator end(); /** *@brief Return the first element if it contains elements, or null if it doesn't contain any element. */ Object* anyObject(); /** * @js NA * @lua NA */ virtual void acceptVisitor(DataVisitor &visitor); private: std::set *_set; }; // end of data_structure group /// @} NS_CC_END #endif // __CC_SET_H__ ================================================ FILE: cocos2d/cocos/base/CCString.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 "CCString.h" #include "platform/CCFileUtils.h" #include "ccMacros.h" #include #include #include "CCArray.h" NS_CC_BEGIN #define kMaxStringLen (1024*100) __String::__String() :_string("") {} __String::__String(const char * str) :_string(str) {} __String::__String(const std::string& str) :_string(str) {} __String::__String(const __String& str) :_string(str.getCString()) {} __String::~__String() { CCLOGINFO("deallocing __String: %p", this); _string.clear(); } __String& __String::operator= (const __String& other) { if (this != &other) { _string = other._string; } return *this; } bool __String::initWithFormatAndValist(const char* format, va_list ap) { bool bRet = false; char* pBuf = (char*)malloc(kMaxStringLen); if (pBuf != NULL) { vsnprintf(pBuf, kMaxStringLen, format, ap); _string = pBuf; free(pBuf); bRet = true; } return bRet; } bool __String::initWithFormat(const char* format, ...) { bool bRet = false; _string.clear(); va_list ap; va_start(ap, format); bRet = initWithFormatAndValist(format, ap); va_end(ap); return bRet; } int __String::intValue() const { if (length() == 0) { return 0; } return atoi(_string.c_str()); } unsigned int __String::uintValue() const { if (length() == 0) { return 0; } return (unsigned int)atoi(_string.c_str()); } float __String::floatValue() const { if (length() == 0) { return 0.0f; } return (float)atof(_string.c_str()); } double __String::doubleValue() const { if (length() == 0) { return 0.0; } return atof(_string.c_str()); } bool __String::boolValue() const { if (length() == 0) { return false; } if (0 == strcmp(_string.c_str(), "0") || 0 == strcmp(_string.c_str(), "false")) { return false; } return true; } const char* __String::getCString() const { return _string.c_str(); } int __String::length() const { return static_cast(_string.length()); } int __String::compare(const char * pStr) const { return strcmp(getCString(), pStr); } void __String::append(const std::string& str) { _string.append(str); } void __String::appendWithFormat(const char* format, ...) { va_list ap; va_start(ap, format); char* pBuf = (char*)malloc(kMaxStringLen); if (pBuf != NULL) { vsnprintf(pBuf, kMaxStringLen, format, ap); _string.append(pBuf); free(pBuf); } va_end(ap); } __Array* __String::componentsSeparatedByString(const char *delimiter) { __Array* result = __Array::create(); std::string strTmp = _string; size_t cutAt; while( (cutAt = strTmp.find_first_of(delimiter)) != strTmp.npos ) { if(cutAt > 0) { result->addObject(__String::create(strTmp.substr(0, cutAt))); } strTmp = strTmp.substr(cutAt + 1); } if(strTmp.length() > 0) { result->addObject(__String::create(strTmp)); } return result; } bool __String::isEqual(const Object* pObject) { bool bRet = false; const __String* pStr = dynamic_cast(pObject); if (pStr != NULL) { if (0 == _string.compare(pStr->_string)) { bRet = true; } } return bRet; } __String* __String::create(const std::string& str) { __String* ret = new __String(str); ret->autorelease(); return ret; } __String* __String::createWithData(const unsigned char* data, int nLen) { __String* ret = NULL; if (data != NULL) { char* pStr = (char*)malloc(nLen+1); if (pStr != NULL) { pStr[nLen] = '\0'; if (nLen > 0) { memcpy(pStr, data, nLen); } ret = __String::create(pStr); free(pStr); } } return ret; } __String* __String::createWithFormat(const char* format, ...) { __String* ret = __String::create(""); va_list ap; va_start(ap, format); ret->initWithFormatAndValist(format, ap); va_end(ap); return ret; } __String* __String::createWithContentsOfFile(const char* filename) { std::string str = FileUtils::getInstance()->getStringFromFile(filename); return __String::create(std::move(str)); } void __String::acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } __String* __String::clone() const { return __String::create(_string); } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCString.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 __CCSTRING_H__ #define __CCSTRING_H__ #if (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY) #include #endif #include #include #include #include #include "CCObject.h" NS_CC_BEGIN /** * @addtogroup data_structures * @{ */ class CC_DLL __String : public Object, public Clonable { public: /** * @js NA * @lua NA */ __String(); /** * @js NA * @lua NA */ __String(const char* str); /** * @js NA * @lua NA */ __String(const std::string& str); /** * @js NA * @lua NA */ __String(const __String& str); /** * @js NA * @lua NA */ virtual ~__String(); /* override assignment operator * @js NA * @lua NA */ __String& operator= (const __String& other); /** init a string with format, it's similar with the c function 'sprintf' * @js NA * @lua NA */ bool initWithFormat(const char* format, ...) CC_FORMAT_PRINTF(2, 3); /** convert to int value * @js NA */ int intValue() const; /** convert to unsigned int value * @js NA */ unsigned int uintValue() const; /** convert to float value * @js NA */ float floatValue() const; /** convert to double value * @js NA */ double doubleValue() const; /** convert to bool value * @js NA */ bool boolValue() const; /** get the C string * @js NA */ const char* getCString() const; /** get the length of string * @js NA */ int length() const; /** compare to a c string * @js NA */ int compare(const char *) const; /** append additional characters at the end of its current value * @js NA * @lua NA */ void append(const std::string& str); /** append(w/ format) additional characters at the end of its current value * @js NA * @lua NA */ void appendWithFormat(const char* format, ...); /** split a string * @js NA * @lua NA */ __Array* componentsSeparatedByString(const char *delimiter); /* override functions * @js NA */ virtual bool isEqual(const Object* pObject); /** create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer. * @return A String pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. * @js NA */ static __String* create(const std::string& str); /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, * if you want to change it, you should modify the kMax__StringLen macro in __String.cpp file. * @return A String pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. * @js NA */ static __String* createWithFormat(const char* format, ...) CC_FORMAT_PRINTF(1, 2); /** create a string with binary data * @return A String pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. * @js NA */ static __String* createWithData(const unsigned char* pData, int nLen); /** create a string with a file, * @return A String pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. * @js NA */ static __String* createWithContentsOfFile(const char* filename); /** * @js NA * @lua NA */ virtual void acceptVisitor(DataVisitor &visitor); /** * @js NA * @lua NA */ virtual __String* clone() const; private: /** only for internal use */ bool initWithFormatAndValist(const char* format, va_list ap); public: std::string _string; }; struct StringCompare : public std::binary_function<__String *, __String *, bool> { public: bool operator() (__String * a, __String * b) const { return strcmp(a->getCString(), b->getCString()) < 0; } }; #define StringMake(str) String::create(str) #define ccs StringMake class StringUtils { public: template static std::string toString(T arg) { std::stringstream ss; ss << arg; return ss.str(); } static std::string format(const char* format, ...) CC_FORMAT_PRINTF(1, 2) { #define CC_MAX_STRING_LENGTH (1024*100) std::string ret; va_list ap; va_start(ap, format); char* buf = (char*)malloc(CC_MAX_STRING_LENGTH); if (buf != nullptr) { vsnprintf(buf, CC_MAX_STRING_LENGTH, format, ap); ret = buf; free(buf); } va_end(ap); return ret; } }; // end of data_structure group /// @} NS_CC_END #endif //__CCSTRING_H__ ================================================ FILE: cocos2d/cocos/base/CCValue.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies 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 "CCValue.h" #include NS_CC_BEGIN const Value Value::Null; Value::Value() : _vectorData(new ValueVector()) , _mapData(new ValueMap()) , _intKeyMapData(new ValueMapIntKey()) , _type(Type::NONE) { } Value::Value(unsigned char v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::BYTE) { _baseData.byteVal = v; } Value::Value(int v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::INTEGER) { _baseData.intVal = v; } Value::Value(float v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::FLOAT) { _baseData.floatVal = v; } Value::Value(double v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::DOUBLE) { _baseData.doubleVal = v; } Value::Value(bool v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::BOOLEAN) { _baseData.boolVal = v; } Value::Value(const char* v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::STRING) { _strData = v; } Value::Value(const std::string& v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::STRING) { _strData = v; } Value::Value(const ValueVector& v) : _vectorData(new ValueVector()) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::VECTOR) { *_vectorData = v; } Value::Value(ValueVector&& v) : _vectorData(new ValueVector()) , _mapData(nullptr) , _intKeyMapData(nullptr) , _type(Type::VECTOR) { *_vectorData = std::move(v); } Value::Value(const ValueMap& v) : _vectorData(nullptr) , _mapData(new ValueMap()) , _intKeyMapData(nullptr) , _type(Type::MAP) { *_mapData = v; } Value::Value(ValueMap&& v) : _vectorData(nullptr) , _mapData(new ValueMap()) , _intKeyMapData(nullptr) , _type(Type::MAP) { *_mapData = std::move(v); } Value::Value(const ValueMapIntKey& v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(new ValueMapIntKey()) , _type(Type::INT_KEY_MAP) { *_intKeyMapData = v; } Value::Value(ValueMapIntKey&& v) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(new ValueMapIntKey()) , _type(Type::INT_KEY_MAP) { *_intKeyMapData = std::move(v); } Value::Value(const Value& other) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) { *this = other; } Value::Value(Value&& other) : _vectorData(nullptr) , _mapData(nullptr) , _intKeyMapData(nullptr) { *this = std::move(other); } Value::~Value() { clear(); } Value& Value::operator= (const Value& other) { if (this != &other) { switch (other._type) { case Type::BYTE: _baseData.byteVal = other._baseData.byteVal; break; case Type::INTEGER: _baseData.intVal = other._baseData.intVal; break; case Type::FLOAT: _baseData.floatVal = other._baseData.floatVal; break; case Type::DOUBLE: _baseData.doubleVal = other._baseData.doubleVal; break; case Type::BOOLEAN: _baseData.boolVal = other._baseData.boolVal; break; case Type::STRING: _strData = other._strData; break; case Type::VECTOR: if (_vectorData == nullptr) _vectorData = new ValueVector(); *_vectorData = *other._vectorData; break; case Type::MAP: if (_mapData == nullptr) _mapData = new ValueMap(); *_mapData = *other._mapData; break; case Type::INT_KEY_MAP: if (_intKeyMapData == nullptr) _intKeyMapData = new ValueMapIntKey(); *_intKeyMapData = *other._intKeyMapData; break; default: break; } _type = other._type; } return *this; } Value& Value::operator= (Value&& other) { if (this != &other) { switch (other._type) { case Type::BYTE: _baseData.byteVal = other._baseData.byteVal; break; case Type::INTEGER: _baseData.intVal = other._baseData.intVal; break; case Type::FLOAT: _baseData.floatVal = other._baseData.floatVal; break; case Type::DOUBLE: _baseData.doubleVal = other._baseData.doubleVal; break; case Type::BOOLEAN: _baseData.boolVal = other._baseData.boolVal; break; case Type::STRING: _strData = other._strData; break; case Type::VECTOR: CC_SAFE_DELETE(_vectorData); _vectorData = other._vectorData; break; case Type::MAP: CC_SAFE_DELETE(_mapData); _mapData = other._mapData; break; case Type::INT_KEY_MAP: CC_SAFE_DELETE(_intKeyMapData); _intKeyMapData = other._intKeyMapData; break; default: break; } _type = other._type; other._vectorData = nullptr; other._mapData = nullptr; other._intKeyMapData = nullptr; other._type = Type::NONE; } return *this; } Value& Value::operator= (unsigned char v) { clear(); _type = Type::BYTE; _baseData.byteVal = v; return *this; } Value& Value::operator= (int v) { clear(); _type = Type::INTEGER; _baseData.intVal = v; return *this; } Value& Value::operator= (float v) { clear(); _type = Type::FLOAT; _baseData.floatVal = v; return *this; } Value& Value::operator= (double v) { clear(); _type = Type::DOUBLE; _baseData.doubleVal = v; return *this; } Value& Value::operator= (bool v) { clear(); _type = Type::BOOLEAN; _baseData.boolVal = v; return *this; } Value& Value::operator= (const char* v) { clear(); _type = Type::STRING; _strData = v ? v : ""; return *this; } Value& Value::operator= (const std::string& v) { clear(); _type = Type::STRING; _strData = v; return *this; } Value& Value::operator= (const ValueVector& v) { clear(); _type = Type::VECTOR; _vectorData = new ValueVector(); *_vectorData = v; return *this; } Value& Value::operator= (ValueVector&& v) { clear(); _type = Type::VECTOR; _vectorData = new ValueVector(); *_vectorData = std::move(v); return *this; } Value& Value::operator= (const ValueMap& v) { clear(); _type = Type::MAP; _mapData = new ValueMap(); *_mapData = v; return *this; } Value& Value::operator= (ValueMap&& v) { clear(); _type = Type::MAP; _mapData = new ValueMap(); *_mapData = std::move(v); return *this; } Value& Value::operator= (const ValueMapIntKey& v) { clear(); _type = Type::INT_KEY_MAP; _intKeyMapData = new ValueMapIntKey(); *_intKeyMapData = v; return *this; } Value& Value::operator= (ValueMapIntKey&& v) { clear(); _type = Type::INT_KEY_MAP; _intKeyMapData = new ValueMapIntKey(); *_intKeyMapData = std::move(v); return *this; } /// unsigned char Value::asByte() const { CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); if (_type == Type::BYTE) { return _baseData.byteVal; } if (_type == Type::INTEGER) { return static_cast(_baseData.intVal); } if (_type == Type::STRING) { return static_cast(atoi(_strData.c_str())); } if (_type == Type::FLOAT) { return static_cast(_baseData.floatVal); } if (_type == Type::DOUBLE) { return static_cast(_baseData.doubleVal); } if (_type == Type::BOOLEAN) { return _baseData.boolVal ? 1 : 0; } return 0; } int Value::asInt() const { CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); if (_type == Type::INTEGER) { return _baseData.intVal; } if (_type == Type::BYTE) { return _baseData.byteVal; } if (_type == Type::STRING) { return atoi(_strData.c_str()); } if (_type == Type::FLOAT) { return static_cast(_baseData.floatVal); } if (_type == Type::DOUBLE) { return static_cast(_baseData.doubleVal); } if (_type == Type::BOOLEAN) { return _baseData.boolVal ? 1 : 0; } return 0; } float Value::asFloat() const { CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); if (_type == Type::FLOAT) { return _baseData.floatVal; } if (_type == Type::BYTE) { return static_cast(_baseData.byteVal); } if (_type == Type::STRING) { return atof(_strData.c_str()); } if (_type == Type::INTEGER) { return static_cast(_baseData.intVal); } if (_type == Type::DOUBLE) { return static_cast(_baseData.doubleVal); } if (_type == Type::BOOLEAN) { return _baseData.boolVal ? 1.0f : 0.0f; } return 0.0f; } double Value::asDouble() const { CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); if (_type == Type::DOUBLE) { return _baseData.doubleVal; } if (_type == Type::BYTE) { return static_cast(_baseData.byteVal); } if (_type == Type::STRING) { return static_cast(atof(_strData.c_str())); } if (_type == Type::INTEGER) { return static_cast(_baseData.intVal); } if (_type == Type::FLOAT) { return static_cast(_baseData.floatVal); } if (_type == Type::BOOLEAN) { return _baseData.boolVal ? 1.0 : 0.0; } return 0.0; } bool Value::asBool() const { CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); if (_type == Type::BOOLEAN) { return _baseData.boolVal; } if (_type == Type::BYTE) { return _baseData.byteVal == 0 ? false : true; } if (_type == Type::STRING) { return (_strData == "0" || _strData == "false") ? false : true; } if (_type == Type::INTEGER) { return _baseData.intVal == 0 ? false : true; } if (_type == Type::FLOAT) { return _baseData.floatVal == 0.0f ? false : true; } if (_type == Type::DOUBLE) { return _baseData.doubleVal == 0.0 ? false : true; } return true; } std::string Value::asString() const { CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); if (_type == Type::STRING) { return _strData; } std::stringstream ret; switch (_type) { case Type::BYTE: ret << _baseData.byteVal; break; case Type::INTEGER: ret << _baseData.intVal; break; case Type::FLOAT: ret << _baseData.floatVal; break; case Type::DOUBLE: ret << _baseData.doubleVal; break; case Type::BOOLEAN: ret << (_baseData.boolVal ? "true" : "false"); break; default: break; } return ret.str(); } ValueVector& Value::asValueVector() { if (nullptr == _vectorData) _vectorData = new ValueVector(); return *_vectorData; } const ValueVector& Value::asValueVector() const { static const ValueVector EMPTY_VALUEVECTOR; if (nullptr == _vectorData) return EMPTY_VALUEVECTOR; return *_vectorData; } ValueMap& Value::asValueMap() { if (nullptr == _mapData) _mapData = new ValueMap(); return *_mapData; } const ValueMap& Value::asValueMap() const { static const ValueMap EMPTY_VALUEMAP; if (nullptr == _mapData) return EMPTY_VALUEMAP; return *_mapData; } ValueMapIntKey& Value::asIntKeyMap() { if (nullptr == _intKeyMapData) _intKeyMapData = new ValueMapIntKey(); return *_intKeyMapData; } const ValueMapIntKey& Value::asIntKeyMap() const { static const ValueMapIntKey EMPTY_VALUEMAP_INT_KEY; if (nullptr == _intKeyMapData) return EMPTY_VALUEMAP_INT_KEY; return *_intKeyMapData; } static std::string getTabs(int depth) { std::string tabWidth; for (int i = 0; i < depth; ++i) { tabWidth += "\t"; } return tabWidth; } static std::string visit(const Value& v, int depth); static std::string visitVector(const ValueVector& v, int depth) { std::stringstream ret; if (depth > 0) ret << "\n"; ret << getTabs(depth) << "[\n"; int i = 0; for (const auto& child : v) { ret << getTabs(depth+1) << i << ": " << visit(child, depth + 1); ++i; } ret << getTabs(depth) << "]\n"; return ret.str(); } template static std::string visitMap(const T& v, int depth) { std::stringstream ret; if (depth > 0) ret << "\n"; ret << getTabs(depth) << "{\n"; for (auto iter = v.begin(); iter != v.end(); ++iter) { ret << getTabs(depth + 1) << iter->first << ": "; ret << visit(iter->second, depth + 1); } ret << getTabs(depth) << "}\n"; return ret.str(); } static std::string visit(const Value& v, int depth) { std::stringstream ret; switch (v.getType()) { case Value::Type::NONE: case Value::Type::BYTE: case Value::Type::INTEGER: case Value::Type::FLOAT: case Value::Type::DOUBLE: case Value::Type::BOOLEAN: case Value::Type::STRING: ret << v.asString() << "\n"; break; case Value::Type::VECTOR: ret << visitVector(v.asValueVector(), depth); break; case Value::Type::MAP: ret << visitMap(v.asValueMap(), depth); break; case Value::Type::INT_KEY_MAP: ret << visitMap(v.asIntKeyMap(), depth); break; default: CCASSERT(false, "Invalid type!"); break; } return ret.str(); } std::string Value::getDescription() { std::string ret("\n"); ret += visit(*this, 0); return ret; } void Value::clear() { _type = Type::NONE; _baseData.doubleVal = 0.0; _strData.clear(); CC_SAFE_DELETE(_vectorData); CC_SAFE_DELETE(_mapData); CC_SAFE_DELETE(_intKeyMapData); } NS_CC_END ================================================ FILE: cocos2d/cocos/base/CCValue.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies 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 __cocos2d_libs__CCValue__ #define __cocos2d_libs__CCValue__ #include "CCPlatformMacros.h" #include "ccMacros.h" #include #include #include NS_CC_BEGIN class Value; typedef std::vector ValueVector; typedef std::unordered_map ValueMap; typedef std::unordered_map ValueMapIntKey; class Value { public: static const Value Null; Value(); explicit Value(unsigned char v); explicit Value(int v); explicit Value(float v); explicit Value(double v); explicit Value(bool v); explicit Value(const char* v); explicit Value(const std::string& v); explicit Value(const ValueVector& v); explicit Value(ValueVector&& v); explicit Value(const ValueMap& v); explicit Value(ValueMap&& v); explicit Value(const ValueMapIntKey& v); explicit Value(ValueMapIntKey&& v); Value(const Value& other); Value(Value&& other); ~Value(); // assignment operator Value& operator= (const Value& other); Value& operator= (Value&& other); Value& operator= (unsigned char v); Value& operator= (int v); Value& operator= (float v); Value& operator= (double v); Value& operator= (bool v); Value& operator= (const char* v); Value& operator= (const std::string& v); Value& operator= (const ValueVector& v); Value& operator= (ValueVector&& v); Value& operator= (const ValueMap& v); Value& operator= (ValueMap&& v); Value& operator= (const ValueMapIntKey& v); Value& operator= (ValueMapIntKey&& v); unsigned char asByte() const; int asInt() const; float asFloat() const; double asDouble() const; bool asBool() const; std::string asString() const; ValueVector& asValueVector(); const ValueVector& asValueVector() const; ValueMap& asValueMap(); const ValueMap& asValueMap() const; ValueMapIntKey& asIntKeyMap(); const ValueMapIntKey& asIntKeyMap() const; inline bool isNull() const { return _type == Type::NONE; } enum class Type { NONE, BYTE, INTEGER, FLOAT, DOUBLE, BOOLEAN, STRING, VECTOR, MAP, INT_KEY_MAP }; inline Type getType() const { return _type; }; std::string getDescription(); private: void clear(); union { unsigned char byteVal; int intVal; float floatVal; double doubleVal; bool boolVal; }_baseData; std::string _strData; ValueVector* _vectorData; ValueMap* _mapData; ValueMapIntKey* _intKeyMapData; Type _type; }; NS_CC_END #endif /* defined(__cocos2d_libs__CCValue__) */ ================================================ FILE: cocos2d/cocos/base/CCVector.h ================================================ /**************************************************************************** Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies 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 __CCVECTOR_H__ #define __CCVECTOR_H__ #include "ccMacros.h" #include "CCObject.h" #include #include #include // for std::find NS_CC_BEGIN template class CC_DLL Vector { public: // ------------------------------------------ // Iterators // ------------------------------------------ typedef typename std::vector::iterator iterator; typedef typename std::vector::const_iterator const_iterator; typedef typename std::vector::reverse_iterator reverse_iterator; typedef typename std::vector::const_reverse_iterator const_reverse_iterator; iterator begin() { return _data.begin(); } const_iterator begin() const { return _data.begin(); } iterator end() { return _data.end(); } const_iterator end() const { return _data.end(); } const_iterator cbegin() const { return _data.cbegin(); } const_iterator cend() const { return _data.cend(); } reverse_iterator rbegin() { return _data.rbegin(); } const_reverse_iterator rbegin() const { return _data.rbegin(); } reverse_iterator rend() { return _data.rend(); } const_reverse_iterator rend() const { return _data.rend(); } const_reverse_iterator crbegin() const { return _data.crbegin(); } const_reverse_iterator crend() const { return _data.crend(); } /** Constructor */ Vector() : _data() { static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); } /** Constructor with a capacity */ explicit Vector(ssize_t capacity) : _data() { static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the default constructor with capacity of Vector."); reserve(capacity); } /** Destructor */ ~Vector() { CCLOGINFO("In the destructor of Vector."); clear(); } /** Copy constructor */ Vector(const Vector& other) { static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the copy constructor!"); _data = other._data; addRefForAllObjects(); } /** Move constructor */ Vector(Vector&& other) { static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the move constructor of Vector!"); _data = std::move(other._data); } /** Copy assignment operator */ Vector& operator=(const Vector& other) { if (this != &other) { CCLOGINFO("In the copy assignment operator!"); clear(); _data = other._data; addRefForAllObjects(); } return *this; } /** Move assignment operator */ Vector& operator=(Vector&& other) { if (this != &other) { CCLOGINFO("In the move assignment operator!"); clear(); _data = std::move(other._data); } return *this; } // Don't uses operator since we could not decide whether it needs 'retain'/'release'. // T& operator[](int index) // { // return _data[index]; // } // // const T& operator[](int index) const // { // return _data[index]; // } /** @brief Request a change in capacity * @param capacity Minimum capacity for the vector. * If n is greater than the current vector capacity, * the function causes the container to reallocate its storage increasing its capacity to n (or greater). */ void reserve(ssize_t n) { _data.reserve(n); } /** @brief Returns the size of the storage space currently allocated for the vector, expressed in terms of elements. * @note This capacity is not necessarily equal to the vector size. * It can be equal or greater, with the extra space allowing to accommodate for growth without the need to reallocate on each insertion. * @return The size of the currently allocated storage capacity in the vector, measured in terms of the number elements it can hold. */ ssize_t capacity() const { return _data.capacity(); } /** @brief Returns the number of elements in the vector. * @note This is the number of actual objects held in the vector, which is not necessarily equal to its storage capacity. * @return The number of elements in the container. */ ssize_t size() const { return _data.size(); } /** @brief Returns whether the vector is empty (i.e. whether its size is 0). * @note This function does not modify the container in any way. To clear the content of a vector, see Vector::clear. */ bool empty() const { return _data.empty(); } /** Returns the maximum number of elements that the vector can hold. */ ssize_t max_size() const { return _data.max_size(); } /** Returns index of a certain object, return UINT_MAX if doesn't contain the object */ ssize_t getIndex(T object) const { auto iter = std::find(_data.begin(), _data.end(), object); if (iter != _data.end()) return iter - _data.begin(); return -1; } /** @brief Find the object in the vector. * @return Returns an iterator to the first element in the range [first,last) that compares equal to val. * If no such element is found, the function returns last. */ const_iterator find(T object) const { return std::find(_data.begin(), _data.end(), object); } iterator find(T object) { return std::find(_data.begin(), _data.end(), object); } /** Returns the element at position 'index' in the vector. */ T at(ssize_t index) const { CCASSERT( index >= 0 && index < size(), "index out of range in getObjectAtIndex()"); return _data[index]; } /** Returns the first element in the vector. */ T front() const { return _data.front(); } /** Returns the last element of the vector. */ T back() const { return _data.back(); } /** Returns a random element of the vector. */ T getRandomObject() const { if (!_data.empty()) { ssize_t randIdx = rand() % _data.size(); return *(_data.begin() + randIdx); } return nullptr; } /** Returns a Boolean value that indicates whether object is present in vector. */ bool contains(T object) const { return( std::find(_data.begin(), _data.end(), object) != _data.end() ); } /** Returns true if the two vectors are equal */ bool equals(const Vector &other) { ssize_t s = this->size(); if (s != other.size()) return false; for (ssize_t i = 0; i < s; i++) { if (!this->at(i)->isEqual(other.at(i))) { return false; } } return true; } // Adds objects /** @brief Adds a new element at the end of the vector, after its current last element. * @note This effectively increases the container size by one, * which causes an automatic reallocation of the allocated storage space * if -and only if- the new vector size surpasses the current vector capacity. */ void pushBack(T object) { CCASSERT(object != nullptr, "The object should not be nullptr"); _data.push_back( object ); object->retain(); } /** Push all elements of an existing vector to the end of current vector. */ void pushBack(const Vector& other) { for(const auto &obj : other) { _data.push_back(obj); obj->retain(); } } /** @brief Insert a certain object at a certain index * @note The vector is extended by inserting new elements before the element at the specified 'index', * effectively increasing the container size by the number of elements inserted. * This causes an automatic reallocation of the allocated storage space * if -and only if- the new vector size surpasses the current vector capacity. */ void insert(ssize_t index, T object) { CCASSERT(index >= 0 && index <= size(), "Invalid index!"); CCASSERT(object != nullptr, "The object should not be nullptr"); _data.insert((std::begin(_data) + index), object); object->retain(); } // Removes Objects /** Removes the last element in the vector, * effectively reducing the container size by one, decrease the referece count of the deleted object. */ void popBack() { CCASSERT(!_data.empty(), "no objects added"); auto last = _data.back(); _data.pop_back(); last->release(); } /** @brief Remove a certain object. * @param object The object to be removed. * @param toRelease Whether to decrease the referece count of the deleted object. */ void eraseObject(T object, bool toRelease = true) { CCASSERT(object != nullptr, "The object should not be nullptr"); auto iter = std::find(_data.begin(), _data.end(), object); if (iter != _data.end()) _data.erase(iter); if (toRelease) object->release(); } /** @brief Removes from the vector with an iterator. * @param position Iterator pointing to a single element to be removed from the vector. * @return An iterator pointing to the new location of the element that followed the last element erased by the function call. * This is the container end if the operation erased the last element in the sequence. */ iterator erase(iterator position) { CCASSERT(position >= _data.begin() && position < _data.end(), "Invalid position!"); (*position)->release(); return _data.erase(position); } /** @brief Removes from the vector with a range of elements ( [first, last) ). * @param first The beginning of the range * @param last The end of the range, the 'last' will not used, it's only for indicating the end of range. * @return An iterator pointing to the new location of the element that followed the last element erased by the function call. * This is the container end if the operation erased the last element in the sequence. */ iterator erase(iterator first, iterator last) { for (auto iter = first; iter != last; ++iter) { (*iter)->release(); } return _data.erase(first, last); } /** @brief Removes from the vector with an index. * @param index The index of the element to be removed from the vector. * @return An iterator pointing to the new location of the element that followed the last element erased by the function call. * This is the container end if the operation erased the last element in the sequence. */ iterator erase(ssize_t index) { CCASSERT(!_data.empty() && index >=0 && index < size(), "Invalid index!"); auto it = std::next( begin(), index ); (*it)->release(); return _data.erase(it); } /** @brief Removes all elements from the vector (which are destroyed), leaving the container with a size of 0. * @note All the elements in the vector will be released (referece count will be decreased). */ void clear() { for( auto it = std::begin(_data); it != std::end(_data); ++it ) { (*it)->release(); } _data.clear(); } // Rearranging Content /** Swap two elements */ void swap(T object1, T object2) { ssize_t idx1 = getIndex(object1); ssize_t idx2 = getIndex(object2); CCASSERT(idx1>=0 && idx2>=0, "invalid object index"); std::swap( _data[idx1], _data[idx2] ); } /** Swap two elements with certain indexes */ void swap(ssize_t index1, ssize_t index2) { CCASSERT(index1 >=0 && index1 < size() && index2 >= 0 && index2 < size(), "Invalid indices"); std::swap( _data[index1], _data[index2] ); } /** Replace object at index with another object. */ void replace(ssize_t index, T object) { CCASSERT(index >= 0 && index < size(), "Invalid index!"); CCASSERT(object != nullptr, "The object should not be nullptr"); _data[index]->release(); _data[index] = object; object->retain(); } /** reverses the vector */ void reverse() { std::reverse( std::begin(_data), std::end(_data) ); } /** Shrinks the vector so the memory footprint corresponds with the number of items */ void shrinkToFit() { _data.shrink_to_fit(); } protected: /** Retains all the objects in the vector */ void addRefForAllObjects() { for(const auto &obj : _data) { obj->retain(); } } std::vector _data; }; // end of data_structure group /// @} NS_CC_END #endif // __CCVECTOR_H__ ================================================ FILE: cocos2d/cocos/base/CMakeLists.txt ================================================ set(COCOS_BASE_SRC CCAffineTransform.cpp CCAutoreleasePool.cpp CCGeometry.cpp CCNS.cpp CCObject.cpp CCSet.cpp CCArray.cpp CCDictionary.cpp CCString.cpp CCDataVisitor.cpp CCData.cpp CCValue.cpp etc1.cpp s3tc.cpp atitc.cpp CCConsole.cpp ) add_library(cocosbase STATIC ${COCOS_BASE_SRC} ) if(WIN32) target_link_libraries(cocosbase Ws2_32 ) endif() set_target_properties(cocosbase PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/base/atitc.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "atitc.h" //Decode ATITC encode block to 4x4 RGB32 pixels static void atitc_decode_block(uint8_t **blockData, uint32_t *decodeBlockData, unsigned int stride, bool oneBitAlphaFlag, uint64_t alpha, ATITCDecodeFlag decodeFlag) { unsigned int colorValue0 = 0 , colorValue1 = 0, initAlpha = (!oneBitAlphaFlag * 255u) << 24; unsigned int rb0 = 0, rb1 = 0, rb2 = 0, rb3 = 0, g0 = 0, g1 = 0, g2 = 0, g3 = 0; bool msb = 0; uint32_t colors[4], pixelsIndex = 0; /* load the two color values*/ memcpy((void *)&colorValue0, *blockData, 2); (*blockData) += 2; memcpy((void *)&colorValue1, *blockData, 2); (*blockData) += 2; //extract the msb flag msb = (colorValue0 & 0x8000) != 0; /* the channel is r5g6b5 , 16 bits */ rb0 = (colorValue0 << 3 | colorValue0 << 9) & 0xf800f8; rb1 = (colorValue1 << 3 | colorValue1 << 8) & 0xf800f8; g0 = (colorValue0 << 6) & 0x00fc00; g1 = (colorValue1 << 5) & 0x00fc00; g0 += (g0 >> 6) & 0x000300; g1 += (g1 >> 6) & 0x000300; /* interpolate the other two color values */ if (!msb) { colors[0] = rb0 + g0 + initAlpha; colors[3] = rb1 + g1 + initAlpha; rb2 = (((2*rb0 + rb1) * 21) >> 6) & 0xff00ff; rb3 = (((2*rb1 + rb0) * 21) >> 6) & 0xff00ff; g2 = (((2*g0 + g1 ) * 21) >> 6) & 0x00ff00; g3 = (((2*g1 + g0 ) * 21) >> 6) & 0x00ff00; colors[2] = rb3 + g3 + initAlpha; colors[1] = rb2 + g2 + initAlpha; } else { colors[2] = rb0 + g0 + initAlpha; colors[3] = rb1 + g1 + initAlpha; rb2 = (rb0 - (rb1 >> 2)) & 0xff00ff; g2 = (g0 - (g1 >> 2)) & 0x00ff00; colors[0] = 0 ; colors[1] = rb2 + g2 + initAlpha; } /*read the pixelsIndex , 2bits per pixel, 4 bytes */ memcpy((void*)&pixelsIndex, *blockData, 4); (*blockData) += 4; if (ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA == decodeFlag) { // atitc_interpolated_alpha use interpolate alpha // 8-Alpha block: derive the other six alphas. // Bit code 000 = alpha0, 001 = alpha1, other are interpolated. unsigned int alphaArray[8]; alphaArray[0] = (alpha ) & 0xff ; alphaArray[1] = (alpha >> 8) & 0xff ; if (alphaArray[0] >= alphaArray[1]) { alphaArray[2] = (alphaArray[0]*6 + alphaArray[1]*1) / 7; alphaArray[3] = (alphaArray[0]*5 + alphaArray[1]*2) / 7; alphaArray[4] = (alphaArray[0]*4 + alphaArray[1]*3) / 7; alphaArray[5] = (alphaArray[0]*3 + alphaArray[1]*4) / 7; alphaArray[6] = (alphaArray[0]*2 + alphaArray[1]*5) / 7; alphaArray[7] = (alphaArray[0]*1 + alphaArray[1]*6) / 7; } else if (alphaArray[0] < alphaArray[1]) { alphaArray[2] = (alphaArray[0]*4 + alphaArray[1]*1) / 5; alphaArray[3] = (alphaArray[0]*3 + alphaArray[1]*2) / 5; alphaArray[4] = (alphaArray[0]*2 + alphaArray[1]*3) / 5; alphaArray[5] = (alphaArray[0]*1 + alphaArray[1]*4) / 5; alphaArray[6] = 0; alphaArray[7] = 255; } // read the flowing 48bit indices (16*3) alpha >>= 16; for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { decodeBlockData[x] = (alphaArray[alpha & 5] << 24) + colors[pixelsIndex & 3]; pixelsIndex >>= 2; alpha >>= 3; } decodeBlockData += stride; } } //if (atc_interpolated_alpha == comFlag) else { /* atc_rgb atc_explicit_alpha use explicit alpha */ for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { initAlpha = (static_cast(alpha) & 0x0f) << 28; initAlpha += initAlpha >> 4; decodeBlockData[x] = initAlpha + colors[pixelsIndex & 3]; pixelsIndex >>= 2; alpha >>= 4; } decodeBlockData += stride; } } } //Decode ATITC encode data to RGB32 void atitc_decode(uint8_t *encodeData, //in_data uint8_t *decodeData, //out_data const int pixelsWidth, const int pixelsHeight, ATITCDecodeFlag decodeFlag) { uint32_t *decodeBlockData = (uint32_t *)decodeData; for (int block_y = 0; block_y < pixelsHeight / 4; ++block_y, decodeBlockData += 3 * pixelsWidth) //stride = 3*width { for (int block_x = 0; block_x < pixelsWidth / 4; ++block_x, decodeBlockData += 4) //skip 4 pixels { uint64_t blockAlpha = 0; switch (decodeFlag) { case ATITCDecodeFlag::ATC_RGB: { atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 0, 0LL, ATITCDecodeFlag::ATC_RGB); } break; case ATITCDecodeFlag::ATC_EXPLICIT_ALPHA: { memcpy((void *)&blockAlpha, encodeData, 8); encodeData += 8; atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 1, blockAlpha, ATITCDecodeFlag::ATC_EXPLICIT_ALPHA); } break; case ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA: { memcpy((void *)&blockAlpha, encodeData, 8); encodeData += 8; atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 1, blockAlpha, ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA); } break; default: break; }//switch }//for block_x }//for block_y } ================================================ FILE: cocos2d/cocos/base/atitc.h ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef COCOS2DX_PLATFORM_THIRDPARTY_ATITC_ #define COCOS2DX_PLATFORM_THIRDPARTY_ATITC_ #include "CCStdC.h" enum class ATITCDecodeFlag { ATC_RGB = 1, ATC_EXPLICIT_ALPHA = 3, ATC_INTERPOLATED_ALPHA = 5, }; //Decode ATITC encode data to RGB32 void atitc_decode(uint8_t *encode_data, uint8_t *decode_data, const int pixelsWidth, const int pixelsHeight, ATITCDecodeFlag decodeFlag ); #endif /* defined(COCOS2DX_PLATFORM_THIRDPARTY_ATITC_) */ ================================================ FILE: cocos2d/cocos/base/etc1.cpp ================================================ // Copyright 2009 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "etc1.h" #include /* From http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt The number of bits that represent a 4x4 texel block is 64 bits if is given by ETC1_RGB8_OES. The data for a block is a number of bytes, {q0, q1, q2, q3, q4, q5, q6, q7} where byte q0 is located at the lowest memory address and q7 at the highest. The 64 bits specifying the block is then represented by the following 64 bit integer: int64bit = 256*(256*(256*(256*(256*(256*(256*q0+q1)+q2)+q3)+q4)+q5)+q6)+q7; ETC1_RGB8_OES: a) bit layout in bits 63 through 32 if diffbit = 0 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 ----------------------------------------------- | base col1 | base col2 | base col1 | base col2 | | R1 (4bits)| R2 (4bits)| G1 (4bits)| G2 (4bits)| ----------------------------------------------- 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 --------------------------------------------------- | base col1 | base col2 | table | table |diff|flip| | B1 (4bits)| B2 (4bits)| cw 1 | cw 2 |bit |bit | --------------------------------------------------- b) bit layout in bits 63 through 32 if diffbit = 1 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 ----------------------------------------------- | base col1 | dcol 2 | base col1 | dcol 2 | | R1' (5 bits) | dR2 | G1' (5 bits) | dG2 | ----------------------------------------------- 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 --------------------------------------------------- | base col 1 | dcol 2 | table | table |diff|flip| | B1' (5 bits) | dB2 | cw 1 | cw 2 |bit |bit | --------------------------------------------------- c) bit layout in bits 31 through 0 (in both cases) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 ----------------------------------------------- | most significant pixel index bits | | p| o| n| m| l| k| j| i| h| g| f| e| d| c| b| a| ----------------------------------------------- 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -------------------------------------------------- | least significant pixel index bits | | p| o| n| m| l| k| j| i| h| g| f| e| d| c | b | a | -------------------------------------------------- Add table 3.17.2: Intensity modifier sets for ETC1 compressed textures: table codeword modifier table ------------------ ---------------------- 0 -8 -2 2 8 1 -17 -5 5 17 2 -29 -9 9 29 3 -42 -13 13 42 4 -60 -18 18 60 5 -80 -24 24 80 6 -106 -33 33 106 7 -183 -47 47 183 Add table 3.17.3 Mapping from pixel index values to modifier values for ETC1 compressed textures: pixel index value --------------- msb lsb resulting modifier value ----- ----- ------------------------- 1 1 -b (large negative value) 1 0 -a (small negative value) 0 0 a (small positive value) 0 1 b (large positive value) */ static const int kModifierTable[] = { /* 0 */2, 8, -2, -8, /* 1 */5, 17, -5, -17, /* 2 */9, 29, -9, -29, /* 3 */13, 42, -13, -42, /* 4 */18, 60, -18, -60, /* 5 */24, 80, -24, -80, /* 6 */33, 106, -33, -106, /* 7 */47, 183, -47, -183 }; static const int kLookup[8] = { 0, 1, 2, 3, -4, -3, -2, -1 }; static inline etc1_byte clamp(int x) { return (etc1_byte) (x >= 0 ? (x < 255 ? x : 255) : 0); } static inline int convert4To8(int b) { int c = b & 0xf; return (c << 4) | c; } static inline int convert5To8(int b) { int c = b & 0x1f; return (c << 3) | (c >> 2); } static inline int convert6To8(int b) { int c = b & 0x3f; return (c << 2) | (c >> 4); } static inline int divideBy255(int d) { return (d + 128 + (d >> 8)) >> 8; } static inline int convert8To4(int b) { int c = b & 0xff; return divideBy255(c * 15); } static inline int convert8To5(int b) { int c = b & 0xff; return divideBy255(c * 31); } static inline int convertDiff(int base, int diff) { return convert5To8((0x1f & base) + kLookup[0x7 & diff]); } static void decode_subblock(etc1_byte* pOut, int r, int g, int b, const int* table, etc1_uint32 low, bool second, bool flipped) { int baseX = 0; int baseY = 0; if (second) { if (flipped) { baseY = 2; } else { baseX = 2; } } for (int i = 0; i < 8; i++) { int x, y; if (flipped) { x = baseX + (i >> 1); y = baseY + (i & 1); } else { x = baseX + (i >> 2); y = baseY + (i & 3); } int k = y + (x * 4); int offset = ((low >> k) & 1) | ((low >> (k + 15)) & 2); int delta = table[offset]; etc1_byte* q = pOut + 3 * (x + 4 * y); *q++ = clamp(r + delta); *q++ = clamp(g + delta); *q++ = clamp(b + delta); } } // Input is an ETC1 compressed version of the data. // Output is a 4 x 4 square of 3-byte pixels in form R, G, B void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut) { etc1_uint32 high = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3]; etc1_uint32 low = (pIn[4] << 24) | (pIn[5] << 16) | (pIn[6] << 8) | pIn[7]; int r1, r2, g1, g2, b1, b2; if (high & 2) { // differential int rBase = high >> 27; int gBase = high >> 19; int bBase = high >> 11; r1 = convert5To8(rBase); r2 = convertDiff(rBase, high >> 24); g1 = convert5To8(gBase); g2 = convertDiff(gBase, high >> 16); b1 = convert5To8(bBase); b2 = convertDiff(bBase, high >> 8); } else { // not differential r1 = convert4To8(high >> 28); r2 = convert4To8(high >> 24); g1 = convert4To8(high >> 20); g2 = convert4To8(high >> 16); b1 = convert4To8(high >> 12); b2 = convert4To8(high >> 8); } int tableIndexA = 7 & (high >> 5); int tableIndexB = 7 & (high >> 2); const int* tableA = kModifierTable + tableIndexA * 4; const int* tableB = kModifierTable + tableIndexB * 4; bool flipped = (high & 1) != 0; decode_subblock(pOut, r1, g1, b1, tableA, low, false, flipped); decode_subblock(pOut, r2, g2, b2, tableB, low, true, flipped); } typedef struct { etc1_uint32 high; etc1_uint32 low; etc1_uint32 score; // Lower is more accurate } etc_compressed; static inline void take_best(etc_compressed* a, const etc_compressed* b) { if (a->score > b->score) { *a = *b; } } static void etc_average_colors_subblock(const etc1_byte* pIn, etc1_uint32 inMask, etc1_byte* pColors, bool flipped, bool second) { int r = 0; int g = 0; int b = 0; if (flipped) { int by = 0; if (second) { by = 2; } for (int y = 0; y < 2; y++) { int yy = by + y; for (int x = 0; x < 4; x++) { int i = x + 4 * yy; if (inMask & (1 << i)) { const etc1_byte* p = pIn + i * 3; r += *(p++); g += *(p++); b += *(p++); } } } } else { int bx = 0; if (second) { bx = 2; } for (int y = 0; y < 4; y++) { for (int x = 0; x < 2; x++) { int xx = bx + x; int i = xx + 4 * y; if (inMask & (1 << i)) { const etc1_byte* p = pIn + i * 3; r += *(p++); g += *(p++); b += *(p++); } } } } pColors[0] = (etc1_byte)((r + 4) >> 3); pColors[1] = (etc1_byte)((g + 4) >> 3); pColors[2] = (etc1_byte)((b + 4) >> 3); } static inline int square(int x) { return x * x; } static etc1_uint32 chooseModifier(const etc1_byte* pBaseColors, const etc1_byte* pIn, etc1_uint32 *pLow, int bitIndex, const int* pModifierTable) { etc1_uint32 bestScore = ~0; int bestIndex = 0; int pixelR = pIn[0]; int pixelG = pIn[1]; int pixelB = pIn[2]; int r = pBaseColors[0]; int g = pBaseColors[1]; int b = pBaseColors[2]; for (int i = 0; i < 4; i++) { int modifier = pModifierTable[i]; int decodedG = clamp(g + modifier); etc1_uint32 score = (etc1_uint32) (6 * square(decodedG - pixelG)); if (score >= bestScore) { continue; } int decodedR = clamp(r + modifier); score += (etc1_uint32) (3 * square(decodedR - pixelR)); if (score >= bestScore) { continue; } int decodedB = clamp(b + modifier); score += (etc1_uint32) square(decodedB - pixelB); if (score < bestScore) { bestScore = score; bestIndex = i; } } etc1_uint32 lowMask = (((bestIndex >> 1) << 16) | (bestIndex & 1)) << bitIndex; *pLow |= lowMask; return bestScore; } static void etc_encode_subblock_helper(const etc1_byte* pIn, etc1_uint32 inMask, etc_compressed* pCompressed, bool flipped, bool second, const etc1_byte* pBaseColors, const int* pModifierTable) { int score = pCompressed->score; if (flipped) { int by = 0; if (second) { by = 2; } for (int y = 0; y < 2; y++) { int yy = by + y; for (int x = 0; x < 4; x++) { int i = x + 4 * yy; if (inMask & (1 << i)) { score += chooseModifier(pBaseColors, pIn + i * 3, &pCompressed->low, yy + x * 4, pModifierTable); } } } } else { int bx = 0; if (second) { bx = 2; } for (int y = 0; y < 4; y++) { for (int x = 0; x < 2; x++) { int xx = bx + x; int i = xx + 4 * y; if (inMask & (1 << i)) { score += chooseModifier(pBaseColors, pIn + i * 3, &pCompressed->low, y + xx * 4, pModifierTable); } } } } pCompressed->score = score; } static bool inRange4bitSigned(int color) { return color >= -4 && color <= 3; } static void etc_encodeBaseColors(etc1_byte* pBaseColors, const etc1_byte* pColors, etc_compressed* pCompressed) { int r1, g1, b1, r2, g2, b2; // 8 bit base colors for sub-blocks bool differential; { int r51 = convert8To5(pColors[0]); int g51 = convert8To5(pColors[1]); int b51 = convert8To5(pColors[2]); int r52 = convert8To5(pColors[3]); int g52 = convert8To5(pColors[4]); int b52 = convert8To5(pColors[5]); r1 = convert5To8(r51); g1 = convert5To8(g51); b1 = convert5To8(b51); int dr = r52 - r51; int dg = g52 - g51; int db = b52 - b51; differential = inRange4bitSigned(dr) && inRange4bitSigned(dg) && inRange4bitSigned(db); if (differential) { r2 = convert5To8(r51 + dr); g2 = convert5To8(g51 + dg); b2 = convert5To8(b51 + db); pCompressed->high |= (r51 << 27) | ((7 & dr) << 24) | (g51 << 19) | ((7 & dg) << 16) | (b51 << 11) | ((7 & db) << 8) | 2; } } if (!differential) { int r41 = convert8To4(pColors[0]); int g41 = convert8To4(pColors[1]); int b41 = convert8To4(pColors[2]); int r42 = convert8To4(pColors[3]); int g42 = convert8To4(pColors[4]); int b42 = convert8To4(pColors[5]); r1 = convert4To8(r41); g1 = convert4To8(g41); b1 = convert4To8(b41); r2 = convert4To8(r42); g2 = convert4To8(g42); b2 = convert4To8(b42); pCompressed->high |= (r41 << 28) | (r42 << 24) | (g41 << 20) | (g42 << 16) | (b41 << 12) | (b42 << 8); } pBaseColors[0] = r1; pBaseColors[1] = g1; pBaseColors[2] = b1; pBaseColors[3] = r2; pBaseColors[4] = g2; pBaseColors[5] = b2; } static void etc_encode_block_helper(const etc1_byte* pIn, etc1_uint32 inMask, const etc1_byte* pColors, etc_compressed* pCompressed, bool flipped) { pCompressed->score = ~0; pCompressed->high = (flipped ? 1 : 0); pCompressed->low = 0; etc1_byte pBaseColors[6]; etc_encodeBaseColors(pBaseColors, pColors, pCompressed); int originalHigh = pCompressed->high; const int* pModifierTable = kModifierTable; for (int i = 0; i < 8; i++, pModifierTable += 4) { etc_compressed temp; temp.score = 0; temp.high = originalHigh | (i << 5); temp.low = 0; etc_encode_subblock_helper(pIn, inMask, &temp, flipped, false, pBaseColors, pModifierTable); take_best(pCompressed, &temp); } pModifierTable = kModifierTable; etc_compressed firstHalf = *pCompressed; for (int i = 0; i < 8; i++, pModifierTable += 4) { etc_compressed temp; temp.score = firstHalf.score; temp.high = firstHalf.high | (i << 2); temp.low = firstHalf.low; etc_encode_subblock_helper(pIn, inMask, &temp, flipped, true, pBaseColors + 3, pModifierTable); if (i == 0) { *pCompressed = temp; } else { take_best(pCompressed, &temp); } } } static void writeBigEndian(etc1_byte* pOut, etc1_uint32 d) { pOut[0] = (etc1_byte)(d >> 24); pOut[1] = (etc1_byte)(d >> 16); pOut[2] = (etc1_byte)(d >> 8); pOut[3] = (etc1_byte) d; } // Input is a 4 x 4 square of 3-byte pixels in form R, G, B // inmask is a 16-bit mask where bit (1 << (x + y * 4)) tells whether the corresponding (x,y) // pixel is valid or not. Invalid pixel color values are ignored when compressing. // Output is an ETC1 compressed version of the data. void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 inMask, etc1_byte* pOut) { etc1_byte colors[6]; etc1_byte flippedColors[6]; etc_average_colors_subblock(pIn, inMask, colors, false, false); etc_average_colors_subblock(pIn, inMask, colors + 3, false, true); etc_average_colors_subblock(pIn, inMask, flippedColors, true, false); etc_average_colors_subblock(pIn, inMask, flippedColors + 3, true, true); etc_compressed a, b; etc_encode_block_helper(pIn, inMask, colors, &a, false); etc_encode_block_helper(pIn, inMask, flippedColors, &b, true); take_best(&a, &b); writeBigEndian(pOut, a.high); writeBigEndian(pOut + 4, a.low); } // Return the size of the encoded image data (does not include size of PKM header). etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height) { return (((width + 3) & ~3) * ((height + 3) & ~3)) >> 1; } // Encode an entire image. // pIn - pointer to the image data. Formatted such that the Red component of // pixel (x,y) is at pIn + pixelSize * x + stride * y + redOffset; // pOut - pointer to encoded data. Must be large enough to store entire encoded image. int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height, etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut) { if (pixelSize < 2 || pixelSize > 3) { return -1; } static const unsigned short kYMask[] = { 0x0, 0xf, 0xff, 0xfff, 0xffff }; static const unsigned short kXMask[] = { 0x0, 0x1111, 0x3333, 0x7777, 0xffff }; etc1_byte block[ETC1_DECODED_BLOCK_SIZE]; etc1_byte encoded[ETC1_ENCODED_BLOCK_SIZE]; etc1_uint32 encodedWidth = (width + 3) & ~3; etc1_uint32 encodedHeight = (height + 3) & ~3; for (etc1_uint32 y = 0; y < encodedHeight; y += 4) { etc1_uint32 yEnd = height - y; if (yEnd > 4) { yEnd = 4; } int ymask = kYMask[yEnd]; for (etc1_uint32 x = 0; x < encodedWidth; x += 4) { etc1_uint32 xEnd = width - x; if (xEnd > 4) { xEnd = 4; } int mask = ymask & kXMask[xEnd]; for (etc1_uint32 cy = 0; cy < yEnd; cy++) { etc1_byte* q = block + (cy * 4) * 3; const etc1_byte* p = pIn + pixelSize * x + stride * (y + cy); if (pixelSize == 3) { memcpy(q, p, xEnd * 3); } else { for (etc1_uint32 cx = 0; cx < xEnd; cx++) { int pixel = (p[1] << 8) | p[0]; *q++ = convert5To8(pixel >> 11); *q++ = convert6To8(pixel >> 5); *q++ = convert5To8(pixel); p += pixelSize; } } } etc1_encode_block(block, mask, encoded); memcpy(pOut, encoded, sizeof(encoded)); pOut += sizeof(encoded); } } return 0; } // Decode an entire image. // pIn - pointer to encoded data. // pOut - pointer to the image data. Will be written such that the Red component of // pixel (x,y) is at pIn + pixelSize * x + stride * y + redOffset. Must be // large enough to store entire image. int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut, etc1_uint32 width, etc1_uint32 height, etc1_uint32 pixelSize, etc1_uint32 stride) { if (pixelSize < 2 || pixelSize > 3) { return -1; } etc1_byte block[ETC1_DECODED_BLOCK_SIZE]; etc1_uint32 encodedWidth = (width + 3) & ~3; etc1_uint32 encodedHeight = (height + 3) & ~3; for (etc1_uint32 y = 0; y < encodedHeight; y += 4) { etc1_uint32 yEnd = height - y; if (yEnd > 4) { yEnd = 4; } for (etc1_uint32 x = 0; x < encodedWidth; x += 4) { etc1_uint32 xEnd = width - x; if (xEnd > 4) { xEnd = 4; } etc1_decode_block(pIn, block); pIn += ETC1_ENCODED_BLOCK_SIZE; for (etc1_uint32 cy = 0; cy < yEnd; cy++) { const etc1_byte* q = block + (cy * 4) * 3; etc1_byte* p = pOut + pixelSize * x + stride * (y + cy); if (pixelSize == 3) { memcpy(p, q, xEnd * 3); } else { for (etc1_uint32 cx = 0; cx < xEnd; cx++) { etc1_byte r = *q++; etc1_byte g = *q++; etc1_byte b = *q++; etc1_uint32 pixel = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); *p++ = (etc1_byte) pixel; *p++ = (etc1_byte) (pixel >> 8); } } } } } return 0; } static const char kMagic[] = { 'P', 'K', 'M', ' ', '1', '0' }; static const etc1_uint32 ETC1_PKM_FORMAT_OFFSET = 6; static const etc1_uint32 ETC1_PKM_ENCODED_WIDTH_OFFSET = 8; static const etc1_uint32 ETC1_PKM_ENCODED_HEIGHT_OFFSET = 10; static const etc1_uint32 ETC1_PKM_WIDTH_OFFSET = 12; static const etc1_uint32 ETC1_PKM_HEIGHT_OFFSET = 14; static const etc1_uint32 ETC1_RGB_NO_MIPMAPS = 0; static void writeBEUint16(etc1_byte* pOut, etc1_uint32 data) { pOut[0] = (etc1_byte) (data >> 8); pOut[1] = (etc1_byte) data; } static etc1_uint32 readBEUint16(const etc1_byte* pIn) { return (pIn[0] << 8) | pIn[1]; } // Format a PKM header void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height) { memcpy(pHeader, kMagic, sizeof(kMagic)); etc1_uint32 encodedWidth = (width + 3) & ~3; etc1_uint32 encodedHeight = (height + 3) & ~3; writeBEUint16(pHeader + ETC1_PKM_FORMAT_OFFSET, ETC1_RGB_NO_MIPMAPS); writeBEUint16(pHeader + ETC1_PKM_ENCODED_WIDTH_OFFSET, encodedWidth); writeBEUint16(pHeader + ETC1_PKM_ENCODED_HEIGHT_OFFSET, encodedHeight); writeBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET, width); writeBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET, height); } // Check if a PKM header is correctly formatted. etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader) { if (memcmp(pHeader, kMagic, sizeof(kMagic))) { return false; } etc1_uint32 format = readBEUint16(pHeader + ETC1_PKM_FORMAT_OFFSET); etc1_uint32 encodedWidth = readBEUint16(pHeader + ETC1_PKM_ENCODED_WIDTH_OFFSET); etc1_uint32 encodedHeight = readBEUint16(pHeader + ETC1_PKM_ENCODED_HEIGHT_OFFSET); etc1_uint32 width = readBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET); etc1_uint32 height = readBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET); return format == ETC1_RGB_NO_MIPMAPS && encodedWidth >= width && encodedWidth - width < 4 && encodedHeight >= height && encodedHeight - height < 4; } // Read the image width from a PKM header etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader) { return readBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET); } // Read the image height from a PKM header etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader){ return readBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET); } ================================================ FILE: cocos2d/cocos/base/etc1.h ================================================ // Copyright 2009 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef __etc1_h__ #define __etc1_h__ #define ETC1_ENCODED_BLOCK_SIZE 8 #define ETC1_DECODED_BLOCK_SIZE 48 #ifndef ETC1_RGB8_OES #define ETC1_RGB8_OES 0x8D64 #endif typedef unsigned char etc1_byte; typedef int etc1_bool; typedef unsigned int etc1_uint32; #ifdef __cplusplus extern "C" { #endif // Encode a block of pixels. // // pIn is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a // 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R // value of pixel (x, y). // // validPixelMask is a 16-bit mask where bit (1 << (x + y * 4)) indicates whether // the corresponding (x,y) pixel is valid. Invalid pixel color values are ignored when compressing. // // pOut is an ETC1 compressed version of the data. void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 validPixelMask, etc1_byte* pOut); // Decode a block of pixels. // // pIn is an ETC1 compressed version of the data. // // pOut is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a // 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R // value of pixel (x, y). void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut); // Return the size of the encoded image data (does not include size of PKM header). etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height); // Encode an entire image. // pIn - pointer to the image data. Formatted such that // pixel (x,y) is at pIn + pixelSize * x + stride * y; // pOut - pointer to encoded data. Must be large enough to store entire encoded image. // pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image. // returns non-zero if there is an error. int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height, etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut); // Decode an entire image. // pIn - pointer to encoded data. // pOut - pointer to the image data. Will be written such that // pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be // large enough to store entire image. // pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image. // returns non-zero if there is an error. int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut, etc1_uint32 width, etc1_uint32 height, etc1_uint32 pixelSize, etc1_uint32 stride); // Size of a PKM header, in bytes. #define ETC_PKM_HEADER_SIZE 16 // Format a PKM header void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height); // Check if a PKM header is correctly formatted. etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader); // Read the image width from a PKM header etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader); // Read the image height from a PKM header etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader); #ifdef __cplusplus } #endif #endif ================================================ FILE: cocos2d/cocos/base/s3tc.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies 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 "s3tc.h" //Decode S3TC encode block to 4x4 RGB32 pixels static void s3tc_decode_block(uint8_t **blockData, uint32_t *decodeBlockData, unsigned int stride, bool oneBitAlphaFlag, uint64_t alpha, S3TCDecodeFlag decodeFlag) { unsigned int colorValue0 = 0 , colorValue1 = 0, initAlpha = (!oneBitAlphaFlag * 255u) << 24; unsigned int rb0 = 0, rb1 = 0, rb2 = 0, rb3 = 0, g0 = 0, g1 = 0, g2 = 0, g3 = 0; uint32_t colors[4], pixelsIndex = 0; /* load the two color values*/ memcpy((void *)&colorValue0, *blockData, 2); (*blockData) += 2; memcpy((void *)&colorValue1, *blockData, 2); (*blockData) += 2; /* the channel is r5g6b5 , 16 bits */ rb0 = (colorValue0 << 19 | colorValue0 >> 8) & 0xf800f8; rb1 = (colorValue1 << 19 | colorValue1 >> 8) & 0xf800f8; g0 = (colorValue0 << 5) & 0x00fc00; g1 = (colorValue1 << 5) & 0x00fc00; g0 += (g0 >> 6) & 0x000300; g1 += (g1 >> 6) & 0x000300; colors[0] = rb0 + g0 + initAlpha; colors[1] = rb1 + g1 + initAlpha; /* interpolate the other two color values */ if (colorValue0 > colorValue1 || oneBitAlphaFlag) { rb2 = (((2*rb0 + rb1) * 21) >> 6) & 0xff00ff; rb3 = (((2*rb1 + rb0) * 21) >> 6) & 0xff00ff; g2 = (((2*g0 + g1 ) * 21) >> 6) & 0x00ff00; g3 = (((2*g1 + g0 ) * 21) >> 6) & 0x00ff00; colors[3] = rb3 + g3 + initAlpha; } else { rb2 = ((rb0+rb1) >> 1) & 0xff00ff; g2 = ((g0 +g1 ) >> 1) & 0x00ff00; colors[3] = 0 ; } colors[2] = rb2 + g2 + initAlpha; /*read the pixelsIndex , 2bits per pixel, 4 bytes */ memcpy((void*)&pixelsIndex, *blockData, 4); (*blockData) += 4; if (S3TCDecodeFlag::DXT5 == decodeFlag) { //dxt5 use interpolate alpha // 8-Alpha block: derive the other six alphas. // Bit code 000 = alpha0, 001 = alpha1, other are interpolated. unsigned int alphaArray[8]; alphaArray[0] = (alpha ) & 0xff ; alphaArray[1] = (alpha >> 8) & 0xff ; if (alphaArray[0] >= alphaArray[1]) { alphaArray[2] = (alphaArray[0]*6 + alphaArray[1]*1) / 7; alphaArray[3] = (alphaArray[0]*5 + alphaArray[1]*2) / 7; alphaArray[4] = (alphaArray[0]*4 + alphaArray[1]*3) / 7; alphaArray[5] = (alphaArray[0]*3 + alphaArray[1]*4) / 7; alphaArray[6] = (alphaArray[0]*2 + alphaArray[1]*5) / 7; alphaArray[7] = (alphaArray[0]*1 + alphaArray[1]*6) / 7; } else if (alphaArray[0] < alphaArray[1]) { alphaArray[2] = (alphaArray[0]*4 + alphaArray[1]*1) / 5; alphaArray[3] = (alphaArray[0]*3 + alphaArray[1]*2) / 5; alphaArray[4] = (alphaArray[0]*2 + alphaArray[1]*3) / 5; alphaArray[5] = (alphaArray[0]*1 + alphaArray[1]*4) / 5; alphaArray[6] = 0; alphaArray[7] = 255; } // read the flowing 48bit indices (16*3) alpha >>= 16; for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { decodeBlockData[x] = (alphaArray[alpha & 5] << 24) + colors[pixelsIndex & 3]; pixelsIndex >>= 2; alpha >>= 3; } decodeBlockData += stride; } } //if (dxt5 == comFlag) else { //dxt1 dxt3 use explicit alpha for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { initAlpha = (static_cast(alpha) & 0x0f) << 28; initAlpha += initAlpha >> 4; decodeBlockData[x] = initAlpha + colors[pixelsIndex & 3]; pixelsIndex >>= 2; alpha >>= 4; } decodeBlockData += stride; } } } //Decode S3TC encode data to RGB32 void s3tc_decode(uint8_t *encodeData, //in_data uint8_t *decodeData, //out_data const int pixelsWidth, const int pixelsHeight, S3TCDecodeFlag decodeFlag) { uint32_t *decodeBlockData = (uint32_t *)decodeData; for (int block_y = 0; block_y < pixelsHeight / 4; ++block_y, decodeBlockData += 3 * pixelsWidth) //stride = 3*width { for(int block_x = 0; block_x < pixelsWidth / 4; ++block_x, decodeBlockData += 4) //skip 4 pixels { uint64_t blockAlpha = 0; switch (decodeFlag) { case S3TCDecodeFlag::DXT1: { s3tc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 0, 0LL, S3TCDecodeFlag::DXT1); } break; case S3TCDecodeFlag::DXT3: { memcpy((void *)&blockAlpha, encodeData, 8); encodeData += 8; s3tc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 1, blockAlpha, S3TCDecodeFlag::DXT3); } break; case S3TCDecodeFlag::DXT5: { memcpy((void *)&blockAlpha, encodeData, 8); encodeData += 8; s3tc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 1, blockAlpha, S3TCDecodeFlag::DXT5); } break; default: break; }//switch }//for block_x }//for block_y } ================================================ FILE: cocos2d/cocos/base/s3tc.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies 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 COCOS2DX_PLATFORM_THIRDPARTY_S3TC_ #define COCOS2DX_PLATFORM_THIRDPARTY_S3TC_ #include "CCStdC.h" enum class S3TCDecodeFlag { DXT1 = 1, DXT3 = 3, DXT5 = 5, }; //Decode S3TC encode data to RGB32 void s3tc_decode(uint8_t *encode_data, uint8_t *decode_data, const int pixelsWidth, const int pixelsHeight, S3TCDecodeFlag decodeFlag ); #endif /* defined(COCOS2DX_PLATFORM_THIRDPARTY_S3TC_) */ ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocosbuilder_static LOCAL_MODULE_FILENAME := libcocosbuilder LOCAL_SRC_FILES := CCBAnimationManager.cpp \ CCBFileLoader.cpp \ CCBKeyframe.cpp \ CCBReader.cpp \ CCBSequence.cpp \ CCBSequenceProperty.cpp \ CCControlButtonLoader.cpp \ CCControlLoader.cpp \ CCLabelBMFontLoader.cpp \ CCLabelTTFLoader.cpp \ CCLayerColorLoader.cpp \ CCLayerGradientLoader.cpp \ CCLayerLoader.cpp \ CCMenuItemImageLoader.cpp \ CCMenuItemLoader.cpp \ CCNode+CCBRelativePositioning.cpp \ CCNodeLoader.cpp \ CCNodeLoaderLibrary.cpp \ CCParticleSystemQuadLoader.cpp \ CCScale9SpriteLoader.cpp \ CCScrollViewLoader.cpp \ CCSpriteLoader.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../../.. LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \ $(LOCAL_PATH) \ $(LOCAL_PATH)/../../.. LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos_extension_static include $(BUILD_STATIC_LIBRARY) $(call import-module,extensions) ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp ================================================ #include "CCBAnimationManager.h" #include "CCBSequence.h" #include "CCBSequenceProperty.h" #include "CCBReader.h" #include "CCBKeyframe.h" #include "CCNode+CCBRelativePositioning.h" #include #include #include "SimpleAudioEngine.h" #include "CCBSelectorResolver.h" using namespace cocos2d; using namespace std; using namespace cocos2d::extension; namespace cocosbuilder { // Implementation of CCBAinmationManager CCBAnimationManager::CCBAnimationManager() : _jsControlled(false) , _owner(nullptr) , _autoPlaySequenceId(0) , _rootNode(nullptr) , _rootContainerSize(Size::ZERO) , _delegate(nullptr) , _runningSequence(nullptr) { init(); } bool CCBAnimationManager::init() { _target = nullptr; _animationCompleteCallbackFunc = nullptr; return true; } CCBAnimationManager::~CCBAnimationManager() { // DictElement *pElement = nullptr; // CCDICT_FOREACH(_nodeSequences, pElement) // { // Node *node = (Node*)pElement->getIntKey(); // node->release(); // } // // CCDICT_FOREACH(_baseValues, pElement) // { // Node *node = (Node*)pElement->getIntKey(); // node->release(); // } if (_rootNode) { _rootNode->stopAllActions(); } setRootNode(nullptr); setDelegate(nullptr); for (auto iter = _objects.begin(); iter != _objects.end(); ++iter) { for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) { iter2->second->release(); } } CC_SAFE_RELEASE(_target); } Vector& CCBAnimationManager::getSequences() { return _sequences; } void CCBAnimationManager::setSequences(const Vector& seq) { _sequences = seq; } int CCBAnimationManager::getAutoPlaySequenceId() { return _autoPlaySequenceId; } void CCBAnimationManager::setAutoPlaySequenceId(int autoPlaySequenceId) { _autoPlaySequenceId = autoPlaySequenceId; } Node* CCBAnimationManager::getRootNode() { return _rootNode; } void CCBAnimationManager::setRootNode(Node *pRootNode) { _rootNode = pRootNode; } void CCBAnimationManager::setDocumentControllerName(const std::string &name) { _documentControllerName = name; } std::string CCBAnimationManager::getDocumentControllerName() { return _documentControllerName; } void CCBAnimationManager::addDocumentCallbackNode(Node *node) { _documentCallbackNodes.pushBack(node); } void CCBAnimationManager::addDocumentCallbackName(std::string name) { _documentCallbackNames.push_back(Value(name)); } void CCBAnimationManager::addDocumentCallbackControlEvents(Control::EventType eventType) { _documentCallbackControlEvents.push_back(Value(static_cast(eventType))); } ValueVector& CCBAnimationManager::getDocumentCallbackNames() { return _documentCallbackNames; } Vector& CCBAnimationManager::getDocumentCallbackNodes() { return _documentCallbackNodes; } ValueVector& CCBAnimationManager::getDocumentCallbackControlEvents() { return _documentCallbackControlEvents; } void CCBAnimationManager::addDocumentOutletNode(Node *node) { _documentOutletNodes.pushBack(node); } void CCBAnimationManager::addDocumentOutletName(std::string name) { _documentOutletNames.push_back(Value(name)); } ValueVector& CCBAnimationManager::getDocumentOutletNames() { return _documentOutletNames; } Vector& CCBAnimationManager::getDocumentOutletNodes() { return _documentOutletNodes; } std::string CCBAnimationManager::getLastCompletedSequenceName() { return _lastCompletedSequenceName; } ValueVector& CCBAnimationManager::getKeyframeCallbacks() { return _keyframeCallbacks; } const Size& CCBAnimationManager::getRootContainerSize() { return _rootContainerSize; } void CCBAnimationManager::setRootContainerSize(const Size &rootContainerSize) { _rootContainerSize.setSize(rootContainerSize.width, rootContainerSize.height); } CCBAnimationManagerDelegate* CCBAnimationManager::getDelegate() { return _delegate; } void CCBAnimationManager::setDelegate(CCBAnimationManagerDelegate *pDelegate) { CC_SAFE_RELEASE(dynamic_cast(_delegate)); _delegate = pDelegate; CC_SAFE_RETAIN(dynamic_cast(_delegate)); } const char* CCBAnimationManager::getRunningSequenceName() { if (_runningSequence) { return _runningSequence->getName(); } return nullptr; } const Size& CCBAnimationManager::getContainerSize(Node *pNode) { if (pNode) { return pNode->getContentSize(); } else { return _rootContainerSize; } } // refer to CCBReader::readNodeGraph() for data structure of pSeq void CCBAnimationManager::addNode(Node *pNode, const std::unordered_map>& seq) { // pNode->retain(); _nodeSequences[pNode] = seq; } void CCBAnimationManager::setBaseValue(const Value& value, Node *pNode, const std::string& propName) { auto& props = _baseValues[pNode]; props[propName] = value; } const Value& CCBAnimationManager::getBaseValue(Node *pNode, const std::string& propName) { auto& props = _baseValues[pNode]; return props[propName]; } void CCBAnimationManager::setObject(Object* obj, Node *pNode, const std::string& propName) { auto& props = _objects[pNode]; auto iter = props.find(propName); if (iter != props.end()) iter->second->release(); props[propName] = obj; obj->retain(); } Object* CCBAnimationManager::getObject(Node *pNode, const std::string& propName) { auto& props = _objects[pNode]; auto iter = props.find(propName); if (iter != props.end()) return iter->second; return nullptr; } int CCBAnimationManager::getSequenceId(const char* pSequenceName) { string seqName(pSequenceName); for (auto& seq : _sequences) { if (seqName.compare(seq->getName()) == 0) { return seq->getSequenceId(); } } return -1; } CCBSequence* CCBAnimationManager::getSequence(int nSequenceId) { for (auto& seq : _sequences) { if (seq->getSequenceId() == nSequenceId) { return seq; } } return nullptr; } float CCBAnimationManager::getSequenceDuration(const char *pSequenceName) { int id = getSequenceId(pSequenceName); if (id != -1) return getSequence(id)->getDuration(); return 0; } void CCBAnimationManager::moveAnimationsFromNode(Node* fromNode, Node* toNode) { // Move base values auto baseValueIter = _baseValues.find(fromNode); if(baseValueIter != _baseValues.end()) { _baseValues.erase(baseValueIter); _baseValues[toNode] = baseValueIter->second; // fromNode->release(); // toNode->retain(); } auto objIter = _objects.find(fromNode); if (objIter != _objects.end()) { _objects.erase(objIter); _objects[toNode] = objIter->second; } // Move seqs auto seqsIter = _nodeSequences.find(fromNode); if (seqsIter != _nodeSequences.end()) { _nodeSequences.erase(seqsIter); _nodeSequences[toNode] = seqsIter->second; // fromNode->release(); // toNode->retain(); } } // Refer to CCBReader::readKeyframe() for the real type of value ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const std::string& propName, Node *pNode) { float duration = pKeyframe1->getTime() - (pKeyframe0 ? pKeyframe0->getTime() : 0); if (propName == "rotationX") { return CCBRotateXTo::create(duration, pKeyframe1->getValue().asFloat()); } else if (propName == "rotationY") { return CCBRotateYTo::create(duration, pKeyframe1->getValue().asFloat()); } else if (propName == "rotation") { return CCBRotateTo::create(duration, pKeyframe1->getValue().asFloat()); } else if (propName == "opacity") { return FadeTo::create(duration, pKeyframe1->getValue().asByte()); } else if (propName == "color") { auto c = pKeyframe1->getValue().asValueMap(); unsigned char r = c["r"].asByte(); unsigned char g = c["g"].asByte(); unsigned char b = c["b"].asByte(); return TintTo::create(duration, r, g, b); } else if (propName == "visible") { if (pKeyframe1->getValue().asBool()) { return Sequence::createWithTwoActions(DelayTime::create(duration), Show::create()); } else { return Sequence::createWithTwoActions(DelayTime::create(duration), Hide::create()); } } else if (propName == "displayFrame") { return Sequence::createWithTwoActions(DelayTime::create(duration), CCBSetSpriteFrame::create(static_cast(pKeyframe1->getObject()))); } else if (propName == "position") { // Get position type auto& array = getBaseValue(pNode, propName).asValueVector(); CCBReader::PositionType type = (CCBReader::PositionType)array[2].asInt(); // Get relative position auto value = pKeyframe1->getValue().asValueVector(); float x = value[0].asFloat(); float y = value[1].asFloat(); Size containerSize = getContainerSize(pNode->getParent()); Point absPos = getAbsolutePosition(Point(x,y), type, containerSize, propName); return MoveTo::create(duration, absPos); } else if (propName == "scale") { // Get position type auto& array = getBaseValue(pNode, propName).asValueVector(); CCBReader::ScaleType type = (CCBReader::ScaleType)array[2].asInt(); // Get relative scale auto value = pKeyframe1->getValue().asValueVector(); float x = value[0].asFloat(); float y = value[1].asFloat(); if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION) { float resolutionScale = CCBReader::getResolutionScale(); x *= resolutionScale; y *= resolutionScale; } return ScaleTo::create(duration, x, y); } else if (propName == "skew") { // Get relative skew auto& value = pKeyframe1->getValue().asValueVector(); float x = value[0].asFloat(); float y = value[1].asFloat(); return SkewTo::create(duration, x, y); } else { log("CCBReader: Failed to create animation for property: %s", propName.c_str()); } return nullptr; } void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node *pNode, const Value& value, Object* obj, float fTweenDuration) { if (fTweenDuration > 0) { // Create a fake keyframe to generate the action from CCBKeyframe *kf1 = new CCBKeyframe(); kf1->autorelease(); kf1->setObject(obj); kf1->setValue(value); kf1->setTime(fTweenDuration); kf1->setEasingType(CCBKeyframe::EasingType::LINEAR); // Animate ActionInterval *tweenAction = getAction(nullptr, kf1, propName, pNode); pNode->runAction(tweenAction); } else { // Just set the value if (propName == "position") { // Get position type auto& array = getBaseValue(pNode, propName).asValueVector(); CCBReader::PositionType type = (CCBReader::PositionType)array[2].asInt(); // Get relative position auto& valueVector = value.asValueVector(); float x = valueVector[0].asFloat(); float y = valueVector[1].asFloat(); pNode->setPosition(getAbsolutePosition(Point(x,y), type, getContainerSize(pNode->getParent()), propName)); } else if (propName == "scale") { // Get scale type auto& array = getBaseValue(pNode, propName).asValueVector(); CCBReader::ScaleType type = (CCBReader::ScaleType)array[2].asInt(); // Get relative scale auto& valueVector = value.asValueVector(); float x = valueVector[0].asFloat(); float y = valueVector[1].asFloat(); setRelativeScale(pNode, x, y, type, propName); } else if(propName == "skew") { // Get relative scale auto& valueVector = value.asValueVector(); float x = valueVector[0].asFloat(); float y = valueVector[1].asFloat(); pNode->setSkewX(x); pNode->setSkewY(y); } else { // [node setValue:value forKey:name]; // TODO only handle rotation, opacity, displayFrame, color if (propName == "rotation") { float rotate = value.asFloat(); pNode->setRotation(rotate); } else if(propName == "rotationX") { float rotate = value.asFloat(); pNode->setRotationX(rotate); }else if(propName == "rotationY") { float rotate = value.asFloat(); pNode->setRotationY(rotate); } else if (propName == "opacity") { unsigned char opacity = value.asByte(); pNode->setOpacity(opacity); } else if (propName == "displayFrame") { static_cast(pNode)->setSpriteFrame(static_cast(obj)); } else if (propName == "color") { auto c = value.asValueMap(); unsigned char r = c["r"].asByte(); unsigned char g = c["g"].asByte(); unsigned char b = c["b"].asByte(); pNode->setColor(Color3B(r, g, b)); } else if (propName == "visible") { bool visible = value.asBool(); pNode->setVisible(visible); } else { log("unsupported property name is %s", propName.c_str()); CCASSERT(false, "unsupported property now"); } } } } void CCBAnimationManager::setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration) { auto& keyframes = pSeqProp->getKeyframes(); if (keyframes.empty()) { // Use base value (no animation) auto& baseValue = getBaseValue(pNode, pSeqProp->getName()); auto obj = getObject(pNode, pSeqProp->getName()); CCASSERT(!baseValue.isNull(), "No baseValue found for property"); setAnimatedProperty(pSeqProp->getName(), pNode, baseValue, obj, fTweenDuration); } else { // Use first keyframe CCBKeyframe *keyframe = keyframes.at(0); setAnimatedProperty(pSeqProp->getName(), pNode, keyframe->getValue(), keyframe->getObject(), fTweenDuration); } } ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, CCBKeyframe::EasingType easingType, float fEasingOpt) { if (dynamic_cast(pAction)) { return pAction; } if (easingType == CCBKeyframe::EasingType::LINEAR) { return pAction; } else if (easingType == CCBKeyframe::EasingType::INSTANT) { return CCBEaseInstant::create(pAction); } else if (easingType == CCBKeyframe::EasingType::CUBIC_IN) { return EaseIn::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::CUBIC_OUT) { return EaseOut::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::CUBIC_INOUT) { return EaseInOut::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::BACK_IN) { return EaseBackIn::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BACK_OUT) { return EaseBackOut::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BACK_INOUT) { return EaseBackInOut::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BOUNCE_IN) { return EaseBounceIn::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BOUNCE_OUT) { return EaseBounceOut::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BOUNCE_INOUT) { return EaseBounceInOut::create(pAction); } else if (easingType == CCBKeyframe::EasingType::ELASTIC_IN) { return EaseElasticIn::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::ELASTIC_OUT) { return EaseElasticOut::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::ELASTIC_INOUT) { return EaseElasticInOut::create(pAction, fEasingOpt); } else { log("CCBReader: Unkown easing type %d", easingType); return pAction; } } Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* channel) { float lastKeyframeTime = 0; Vector actions; auto& keyframes = channel->getKeyframes(); ssize_t numKeyframes = keyframes.size(); for (long i = 0; i < numKeyframes; ++i) { CCBKeyframe *keyframe = keyframes.at(i); float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime; lastKeyframeTime = keyframe->getTime(); if(timeSinceLastKeyframe > 0) { actions.pushBack(DelayTime::create(timeSinceLastKeyframe)); } auto& keyVal = keyframe->getValue().asValueVector(); std::string selectorName = keyVal[0].asString(); CCBReader::TargetType selectorTarget = (CCBReader::TargetType)keyVal[1].asInt(); if(_jsControlled) { std::stringstream callbackName; callbackName << static_cast(selectorTarget); callbackName << ":" + selectorName; auto callback = _keyframeCallFuncs.at(callbackName.str()); if (nullptr != callback) { CallFunc* callbackClone = callback->clone(); if (callbackClone != nullptr) { actions.pushBack(callbackClone); } } } else { Object* target = nullptr; if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) target = _rootNode; else if (selectorTarget == CCBReader::TargetType::OWNER) target = _owner; if(target != nullptr) { if(selectorName.length() > 0) { SEL_CallFuncN selCallFunc = 0; CCBSelectorResolver* targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != nullptr) { selCallFunc = targetAsCCBSelectorResolver->onResolveCCBCCCallFuncSelector(target, selectorName.c_str ()); } if(selCallFunc == 0) { CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); } else { auto savedTarget = std::make_shared>(); savedTarget->pushBack(target); auto callback = CallFuncN::create([savedTarget, selCallFunc](Node* sender){ auto t = savedTarget->at(0); (t->*selCallFunc)(sender); }); actions.pushBack(callback); } } else { CCLOG("Unexpected empty selector."); } } } } if(actions.size() < 1) return nullptr; return (Object *) Sequence::create(actions); } Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel) { float lastKeyframeTime = 0; Vector actions; auto& keyframes = channel->getKeyframes(); ssize_t numKeyframes = keyframes.size(); for (int i = 0; i < numKeyframes; ++i) { CCBKeyframe *keyframe = keyframes.at(i); float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime; lastKeyframeTime = keyframe->getTime(); if(timeSinceLastKeyframe > 0) { actions.pushBack(DelayTime::create(timeSinceLastKeyframe)); } stringstream ss (stringstream::in | stringstream::out); auto& keyVal = keyframe->getValue().asValueVector(); std::string soundFile = keyVal[0].asString(); float pitch, pan, gain; ss << keyVal[1].asString(); ss >> pitch; ss.flush(); ss << keyVal[2].asString(); ss >> pan; ss.flush(); ss << keyVal[3].asString(); ss >> gain; ss.flush(); actions.pushBack(CCBSoundEffect::actionWithSoundFile(soundFile, pitch, pan, gain)); } if(actions.size() < 1) return nullptr; return Sequence::create(actions); } void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration) { auto& keyframes = pSeqProp->getKeyframes(); ssize_t numKeyframes = keyframes.size(); if (numKeyframes > 1) { // Make an animation! Vector actions; CCBKeyframe *keyframeFirst = keyframes.at(0); float timeFirst = keyframeFirst->getTime() + fTweenDuration; if (timeFirst > 0) { actions.pushBack(DelayTime::create(timeFirst)); } for (ssize_t i = 0; i < numKeyframes - 1; ++i) { CCBKeyframe *kf0 = keyframes.at(i); CCBKeyframe *kf1 = keyframes.at(i+1); ActionInterval *action = getAction(kf0, kf1, pSeqProp->getName(), pNode); if (action) { // Apply easing action = getEaseAction(action, kf0->getEasingType(), kf0->getEasingOpt()); actions.pushBack(action); } } auto seq = Sequence::create(actions); pNode->runAction(seq); } } void CCBAnimationManager::runAnimations(const char *pName, float fTweenDuration) { runAnimationsForSequenceNamedTweenDuration(pName, fTweenDuration); } void CCBAnimationManager::runAnimations(const char *pName) { runAnimationsForSequenceNamed(pName); } void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuraiton) { runAnimationsForSequenceIdTweenDuration(nSeqId, fTweenDuraiton); } void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, float fTweenDuration) { CCASSERT(nSeqId != -1, "Sequence id couldn't be found"); _rootNode->stopAllActions(); for (auto nodeSeqIter = _nodeSequences.begin(); nodeSeqIter != _nodeSequences.end(); ++nodeSeqIter) { Node *node = nodeSeqIter->first; node->stopAllActions(); // Refer to CCBReader::readKeyframe() for the real type of value auto seqs = nodeSeqIter->second; auto seqNodeProps = seqs[nSeqId]; std::set seqNodePropNames; if (!seqNodeProps.empty()) { // Reset nodes that have sequence node properties, and run actions on them for (auto iter = seqNodeProps.begin(); iter != seqNodeProps.end(); ++iter) { const std::string propName = iter->first; CCBSequenceProperty *seqProp = iter->second; seqNodePropNames.insert(propName); setFirstFrame(node, seqProp, fTweenDuration); runAction(node, seqProp, fTweenDuration); } } // Reset the nodes that may have been changed by other timelines auto& nodeBaseValues = _baseValues[node]; if (!nodeBaseValues.empty()) { for (auto iter = nodeBaseValues.begin(); iter != nodeBaseValues.end(); ++iter) { if (seqNodePropNames.find(iter->first) == seqNodePropNames.end()) { setAnimatedProperty(iter->first, node, iter->second, nullptr, fTweenDuration); } } } auto& nodeObject = _objects[node]; if (!nodeObject.empty()) { for (auto iter = nodeObject.begin(); iter != nodeObject.end(); ++iter) { if (seqNodePropNames.find(iter->first) == seqNodePropNames.end()) { setAnimatedProperty(iter->first, node, Value(), iter->second, fTweenDuration); } } } } // Make callback at end of sequence CCBSequence *seq = getSequence(nSeqId); Action *completeAction = Sequence::createWithTwoActions(DelayTime::create(seq->getDuration() + fTweenDuration), CallFunc::create( CC_CALLBACK_0(CCBAnimationManager::sequenceCompleted,this))); _rootNode->runAction(completeAction); // Set the running scene if(seq->getCallbackChannel() != nullptr) { Action* action = (Action *)actionForCallbackChannel(seq->getCallbackChannel()); if(action != nullptr) { _rootNode->runAction(action); } } if(seq->getSoundChannel() != nullptr) { Action* action = (Action *)actionForSoundChannel(seq->getSoundChannel()); if(action != nullptr) { _rootNode->runAction(action); } } _runningSequence = getSequence(nSeqId); } void CCBAnimationManager::runAnimationsForSequenceNamedTweenDuration(const char *pName, float fTweenDuration) { int seqId = getSequenceId(pName); runAnimationsForSequenceIdTweenDuration(seqId, fTweenDuration); } void CCBAnimationManager::runAnimationsForSequenceNamed(const char *pName) { runAnimationsForSequenceNamedTweenDuration(pName, 0); } void CCBAnimationManager::debug() { } void CCBAnimationManager::setAnimationCompletedCallback(Object *target, SEL_CallFunc callbackFunc) { if (target) { target->retain(); } if (_target) { _target->release(); } _target = target; _animationCompleteCallbackFunc = callbackFunc; } void CCBAnimationManager::setCallFunc(CallFunc* callFunc, const std::string &callbackNamed) { _keyframeCallFuncs.insert(callbackNamed, callFunc); } void CCBAnimationManager::sequenceCompleted() { const char *runningSequenceName = _runningSequence->getName(); int nextSeqId = _runningSequence->getChainedSequenceId(); _runningSequence = nullptr; if(_lastCompletedSequenceName != runningSequenceName) { _lastCompletedSequenceName = runningSequenceName; } if (nextSeqId != -1) { runAnimationsForSequenceIdTweenDuration(nextSeqId, 0); } if (_delegate) { // There may be another runAnimation() call in this delegate method // which will assign _runningSequence _delegate->completedAnimationSequenceNamed(runningSequenceName); } if (_target && _animationCompleteCallbackFunc) { (_target->*_animationCompleteCallbackFunc)(); } } // Custom actions /************************************************************ CCBSetSpriteFrame ************************************************************/ CCBSetSpriteFrame* CCBSetSpriteFrame::create(SpriteFrame *pSpriteFrame) { CCBSetSpriteFrame *ret = new CCBSetSpriteFrame(); if (ret) { if (ret->initWithSpriteFrame(pSpriteFrame)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool CCBSetSpriteFrame::initWithSpriteFrame(SpriteFrame *pSpriteFrame) { _spriteFrame = pSpriteFrame; CC_SAFE_RETAIN(_spriteFrame); return true; } CCBSetSpriteFrame::~CCBSetSpriteFrame() { CC_SAFE_RELEASE_NULL(_spriteFrame); } CCBSetSpriteFrame* CCBSetSpriteFrame::clone() const { // no copy constructor auto a = new CCBSetSpriteFrame(); a->initWithSpriteFrame(_spriteFrame); a->autorelease(); return a; } CCBSetSpriteFrame* CCBSetSpriteFrame::reverse() const { // returns a copy of itself return this->clone(); } void CCBSetSpriteFrame::update(float time) { static_cast(_target)->setSpriteFrame(_spriteFrame); } /************************************************************ CCBSoundEffect ************************************************************/ CCBSoundEffect* CCBSoundEffect::actionWithSoundFile(const std::string &filename, float pitch, float pan, float gain) { CCBSoundEffect* pRet = new CCBSoundEffect(); if (pRet != nullptr && pRet->initWithSoundFile(filename, pitch, pan, gain)) { pRet->autorelease(); } else { CC_SAFE_DELETE(pRet); } return pRet; } CCBSoundEffect::~CCBSoundEffect() { } bool CCBSoundEffect::initWithSoundFile(const std::string &filename, float pitch, float pan, float gain) { _soundFile = filename; _pitch = pitch; _pan = pan; _gain = gain; return true; } CCBSoundEffect* CCBSoundEffect::clone() const { // no copy constructor auto a = new CCBSoundEffect(); a->initWithSoundFile(_soundFile, _pitch, _pan, _gain); a->autorelease(); return a; } CCBSoundEffect* CCBSoundEffect::reverse() const { // returns a copy of itself return this->clone(); } void CCBSoundEffect::update(float time) { CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(_soundFile.c_str()); } /************************************************************ CCBRotateTo ************************************************************/ CCBRotateTo* CCBRotateTo::create(float fDuration, float fAngle) { CCBRotateTo *ret = new CCBRotateTo(); if (ret) { if (ret->initWithDuration(fDuration, fAngle)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool CCBRotateTo::initWithDuration(float fDuration, float fAngle) { if (ActionInterval::initWithDuration(fDuration)) { _dstAngle = fAngle; return true; } else { return false; } } CCBRotateTo* CCBRotateTo::clone() const { // no copy constructor auto a = new CCBRotateTo(); a->initWithDuration(_duration, _dstAngle); a->autorelease(); return a; } CCBRotateTo* CCBRotateTo::reverse() const { CCASSERT(false, "reverse() is not supported in CCBRotateTo"); return nullptr; } void CCBRotateTo::startWithTarget(Node *pNode) { ActionInterval::startWithTarget(pNode); _startAngle = _target->getRotation(); _diffAngle = _dstAngle - _startAngle; } void CCBRotateTo::update(float time) { _target->setRotation(_startAngle + (_diffAngle * time)) ; } /************************************************************ CCBRotateXTO ************************************************************/ CCBRotateXTo* CCBRotateXTo::create(float fDuration, float fAngle) { CCBRotateXTo *ret = new CCBRotateXTo(); if (ret) { if (ret->initWithDuration(fDuration, fAngle)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool CCBRotateXTo::initWithDuration(float fDuration, float fAngle) { if (ActionInterval::initWithDuration(fDuration)) { _dstAngle = fAngle; return true; } else { return false; } } void CCBRotateXTo::startWithTarget(Node *pNode) { //CCActionInterval::startWithTarget(pNode); _originalTarget = pNode; _target = pNode; _elapsed = 0.0f; _firstTick = true; _startAngle = _target->getRotationX(); _diffAngle = _dstAngle - _startAngle; } CCBRotateXTo* CCBRotateXTo::clone() const { // no copy constructor auto a = new CCBRotateXTo(); a->initWithDuration(_duration, _dstAngle); a->autorelease(); return a; } CCBRotateXTo* CCBRotateXTo::reverse() const { CCASSERT(false, "reverse() is not supported in CCBRotateXTo"); return nullptr; } void CCBRotateXTo::update(float time) { _target->setRotationX(_startAngle + (_diffAngle * time)) ; } /************************************************************ CCBRotateYTO ************************************************************/ CCBRotateYTo* CCBRotateYTo::create(float fDuration, float fAngle) { CCBRotateYTo *ret = new CCBRotateYTo(); if (ret) { if (ret->initWithDuration(fDuration, fAngle)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool CCBRotateYTo::initWithDuration(float fDuration, float fAngle) { if (ActionInterval::initWithDuration(fDuration)) { _dstAngle = fAngle; return true; } else { return false; } } CCBRotateYTo* CCBRotateYTo::clone() const { // no copy constructor auto a = new CCBRotateYTo(); a->initWithDuration(_duration, _dstAngle); a->autorelease(); return a; } CCBRotateYTo* CCBRotateYTo::reverse() const { CCASSERT(false, "reverse() is not supported in CCBRotateXTo"); return nullptr; } void CCBRotateYTo::startWithTarget(Node *pNode) { // ActionInterval::startWithTarget(pNode); _originalTarget = pNode; _target = pNode; _elapsed = 0.0f; _firstTick = true; _startAngle = _target->getRotationY(); _diffAngle = _dstAngle - _startAngle; } void CCBRotateYTo::update(float time) { _target->setRotationY(_startAngle + (_diffAngle * time)) ; } /************************************************************ CCBEaseInstant ************************************************************/ CCBEaseInstant* CCBEaseInstant::create(ActionInterval *pAction) { CCBEaseInstant *pRet = new CCBEaseInstant(); if (pRet && pRet->initWithAction(pAction)) { pRet->autorelease(); } else { CC_SAFE_RELEASE_NULL(pRet); } return pRet; } CCBEaseInstant* CCBEaseInstant::clone() const { // no copy constructor auto a = new CCBEaseInstant(); a->initWithAction(_inner); a->autorelease(); return a; } CCBEaseInstant* CCBEaseInstant::reverse() const { return CCBEaseInstant::create(_inner->reverse()); } void CCBEaseInstant::update(float dt) { if (dt < 0) { _inner->update(0); } else { _inner->update(1); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBAnimationManager.h ================================================ #ifndef __CCB_CCBANIMATION_MANAGER_H__ #define __CCB_CCBANIMATION_MANAGER_H__ #include "CCMap.h" #include "CCActionInterval.h" #include "CCActionInstant.h" #include "CCActionEase.h" #include "extensions/ExtensionMacros.h" #include "CCBSequence.h" #include "CCBSequenceProperty.h" #include "extensions/GUI/CCControlExtension/CCControl.h" namespace cocosbuilder { class CCBAnimationManagerDelegate { public: virtual ~CCBAnimationManagerDelegate() {} virtual void completedAnimationSequenceNamed(const char *name) = 0; }; class CCBAnimationManager : public cocos2d::Object { public: bool _jsControlled; /** * @js ctor */ CCBAnimationManager(); /** * @js NA * @lua NA */ ~CCBAnimationManager(); cocos2d::Object *_owner; virtual bool init(); cocos2d::Vector& getSequences(); void setSequences(const cocos2d::Vector& seq); int getAutoPlaySequenceId(); void setAutoPlaySequenceId(int autoPlaySequenceId); cocos2d::Node* getRootNode(); void setRootNode(cocos2d::Node* pRootNode); // weak reference void addDocumentCallbackNode(cocos2d::Node *node); void addDocumentCallbackName(std::string name); void addDocumentCallbackControlEvents(cocos2d::extension::Control::EventType eventType); void addDocumentOutletNode(cocos2d::Node *node); void addDocumentOutletName(std::string name); void setDocumentControllerName(const std::string &name); std::string getDocumentControllerName(); cocos2d::ValueVector& getDocumentCallbackNames(); cocos2d::Vector& getDocumentCallbackNodes(); cocos2d::ValueVector& getDocumentCallbackControlEvents(); cocos2d::ValueVector& getDocumentOutletNames(); cocos2d::Vector& getDocumentOutletNodes(); std::string getLastCompletedSequenceName(); cocos2d::ValueVector& getKeyframeCallbacks(); const cocos2d::Size& getRootContainerSize(); void setRootContainerSize(const cocos2d::Size &rootContainerSize); CCBAnimationManagerDelegate* getDelegate(); void setDelegate(CCBAnimationManagerDelegate* pDelegate); // retain const char* getRunningSequenceName(); const cocos2d::Size& getContainerSize(cocos2d::Node* pNode); void addNode(cocos2d::Node *pNode, const std::unordered_map>& seq); void setBaseValue(const cocos2d::Value& value, cocos2d::Node *pNode, const std::string& propName); void setObject(cocos2d::Object* obj, cocos2d::Node *pNode, const std::string& propName); void moveAnimationsFromNode(cocos2d::Node* fromNode, cocos2d::Node* toNode); /** @deprecated This interface will be deprecated sooner or later.*/ CC_DEPRECATED_ATTRIBUTE void runAnimations(const char *pName, float fTweenDuration); /** @deprecated This interface will be deprecated sooner or later.*/ CC_DEPRECATED_ATTRIBUTE void runAnimations(const char *pName); /** @deprecated This interface will be deprecated sooner or later.*/ CC_DEPRECATED_ATTRIBUTE void runAnimations(int nSeqId, float fTweenDuraiton); void runAnimationsForSequenceNamedTweenDuration(const char *pName, float fTweenDuration); void runAnimationsForSequenceNamed(const char *pName); void runAnimationsForSequenceIdTweenDuration(int nSeqId, float fTweenDuraiton); /** * when this function bound to js ,the second param are callfunc_selector * @lua NA */ void setAnimationCompletedCallback(cocos2d::Object *target, cocos2d::SEL_CallFunc callbackFunc); void debug(); /** * @js setCallFuncForJSCallbackNamed */ void setCallFunc(cocos2d::CallFunc *callFunc, const std::string &callbackNamed); cocos2d::Object* actionForCallbackChannel(CCBSequenceProperty* channel); cocos2d::Object* actionForSoundChannel(CCBSequenceProperty* channel); // return -1 if timeline not exsit int getSequenceId(const char* pSequenceName); // get timeline duration float getSequenceDuration(const char* pSequenceName); private: const cocos2d::Value& getBaseValue(cocos2d::Node *pNode, const std::string& propName); Object* getObject(cocos2d::Node *pNode, const std::string& propName); CCBSequence* getSequence(int nSequenceId); cocos2d::ActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const std::string& propName, cocos2d::Node *pNode); void setAnimatedProperty(const std::string& propName,cocos2d::Node *pNode, const cocos2d::Value& value, Object* obj, float fTweenDuraion); void setFirstFrame(cocos2d::Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); cocos2d::ActionInterval* getEaseAction(cocos2d::ActionInterval *pAction, CCBKeyframe::EasingType easingType, float fEasingOpt); void runAction(cocos2d::Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration); void sequenceCompleted(); private: cocos2d::Vector _sequences; std::unordered_map>> _nodeSequences; std::unordered_map> _baseValues; std::unordered_map> _objects; int _autoPlaySequenceId; cocos2d::Node *_rootNode; cocos2d::Size _rootContainerSize; CCBAnimationManagerDelegate *_delegate; CCBSequence *_runningSequence; cocos2d::ValueVector _documentOutletNames; cocos2d::Vector _documentOutletNodes; cocos2d::ValueVector _documentCallbackNames; cocos2d::Vector _documentCallbackNodes; cocos2d::ValueVector _documentCallbackControlEvents; cocos2d::ValueVector _keyframeCallbacks; cocos2d::Map _keyframeCallFuncs; std::string _documentControllerName; std::string _lastCompletedSequenceName; cocos2d::SEL_CallFunc _animationCompleteCallbackFunc; cocos2d::Object *_target; }; class CCBSetSpriteFrame : public cocos2d::ActionInstant { public: /** creates a Place action with a position */ static CCBSetSpriteFrame* create(cocos2d::SpriteFrame *pSpriteFrame); /** * @js NA * @lua NA */ ~CCBSetSpriteFrame(); bool initWithSpriteFrame(cocos2d::SpriteFrame *pSpriteFrame); // Overrides virtual void update(float time) override; virtual CCBSetSpriteFrame* clone() const override; virtual CCBSetSpriteFrame* reverse() const override; private: cocos2d::SpriteFrame *_spriteFrame; }; class CCBSoundEffect : public cocos2d::ActionInstant { public: static CCBSoundEffect* actionWithSoundFile(const std::string &file, float pitch, float pan, float gain); /** * @js NA * @lua NA */ ~CCBSoundEffect(); bool initWithSoundFile(const std::string &file, float pitch, float pan, float gain); // Overrides virtual void update(float time) override; virtual CCBSoundEffect* clone() const override; virtual CCBSoundEffect* reverse() const override; private: std::string _soundFile; float _pitch, _pan, _gain; }; class CCBRotateTo : public cocos2d::ActionInterval { public: static CCBRotateTo* create(float fDuration, float fAngle); bool initWithDuration(float fDuration, float fAngle); // Override virtual void update(float time) override; virtual CCBRotateTo* clone() const override; virtual CCBRotateTo* reverse() const override; virtual void startWithTarget(cocos2d::Node *pNode) override; private: float _startAngle; float _dstAngle; float _diffAngle; }; class CCBRotateXTo: public cocos2d::ActionInterval { public: static CCBRotateXTo* create(float fDuration, float fAngle); bool initWithDuration(float fDuration, float fAngle); // Overrides virtual void startWithTarget(cocos2d::Node *pNode) override; virtual CCBRotateXTo* clone() const override; virtual CCBRotateXTo* reverse() const override; virtual void update(float time) override; private: float _startAngle; float _dstAngle; float _diffAngle; }; class CCBRotateYTo: public cocos2d::ActionInterval { public: static CCBRotateYTo* create(float fDuration, float fAngle); bool initWithDuration(float fDuration, float fAngle); // Override virtual void startWithTarget(cocos2d::Node *pNode) override; virtual CCBRotateYTo* clone() const override; virtual CCBRotateYTo* reverse() const override; virtual void update(float time) override; private: float _startAngle; float _dstAngle; float _diffAngle; }; class CCBEaseInstant : public cocos2d::ActionEase { public: static CCBEaseInstant* create(cocos2d::ActionInterval *pAction); virtual CCBEaseInstant* clone() const override; virtual CCBEaseInstant* reverse() const override; virtual void update(float dt) override; }; } #endif // __CCB_CCBANIMATION_MANAGER_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBFileLoader.cpp ================================================ #include "CCBFileLoader.h" using namespace cocos2d; namespace cocosbuilder { #define PROPERTY_CCBFILE "ccbFile" void CCBFileLoader::onHandlePropTypeCCBFile(Node * pNode, Node * pParent, const char * pPropertyName, Node * pCCBFileNode, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_CCBFILE) == 0) { ((CCBFile*)pNode)->setCCBFileNode(pCCBFileNode); } else { NodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBFileLoader.h ================================================ #ifndef _CCB_CCBFILELOADER_H_ #define _CCB_CCBFILELOADER_H_ #include "CCNodeLoader.h" #include "CCBReader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class CCBFileLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~CCBFileLoader() {}; /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBFile); virtual void onHandlePropTypeCCBFile(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Node * pCCBFileNode, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBKeyframe.cpp ================================================ #include "CCBKeyframe.h" using namespace cocos2d; namespace cocosbuilder { CCBKeyframe::CCBKeyframe() : _time(0.0f) , _easingType(EasingType::INSTANT) , _easingOpt(0.0f) , _object(nullptr) {} CCBKeyframe::~CCBKeyframe() { CC_SAFE_RELEASE(_object); } const Value& CCBKeyframe::getValue() const { return _value; } void CCBKeyframe::setValue(const Value& value) { _value = value; } Object* CCBKeyframe::getObject() const { return _object; } void CCBKeyframe::setObject(Object* obj) { CC_SAFE_RETAIN(obj); CC_SAFE_RELEASE(_object); _object = obj; } float CCBKeyframe::getTime() { return _time; } void CCBKeyframe::setTime(float fTime) { _time = fTime; } CCBKeyframe::EasingType CCBKeyframe::getEasingType() { return _easingType; } void CCBKeyframe::setEasingType(CCBKeyframe::EasingType easingType) { _easingType = easingType; } float CCBKeyframe::getEasingOpt() { return _easingOpt; } void CCBKeyframe::setEasingOpt(float fEasingOpt) { _easingOpt = fEasingOpt; } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBKeyframe.h ================================================ #ifndef __CCB_KEYFRAME_H__ #define __CCB_KEYFRAME_H__ #include "CCObject.h" #include "CCValue.h" namespace cocosbuilder { class CCBKeyframe : public cocos2d::Object { public: enum class EasingType { INSTANT, LINEAR, CUBIC_IN, CUBIC_OUT, CUBIC_INOUT, ELASTIC_IN, ELASTIC_OUT, ELASTIC_INOUT, BOUNCE_IN, BOUNCE_OUT, BOUNCE_INOUT, BACK_IN, BACK_OUT, BACK_INOUT, }; /** * @js ctor */ CCBKeyframe(); /** * @js NA * @lua NA */ ~CCBKeyframe(); const cocos2d::Value& getValue() const; void setValue(const cocos2d::Value& value); cocos2d::Object* getObject() const; void setObject(cocos2d::Object* obj); float getTime(); void setTime(float fTime); EasingType getEasingType(); void setEasingType(EasingType easingType); float getEasingOpt(); void setEasingOpt(float fEasingOpt); private: cocos2d::Value _value; cocos2d::Object* _object; float _time; EasingType _easingType; float _easingOpt; }; } #endif // __CCB_KEYFRAME_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBMemberVariableAssigner.h ================================================ #ifndef _CCB_CCBMEMBERVARIABLEASSIGNER_H_ #define _CCB_CCBMEMBERVARIABLEASSIGNER_H_ namespace cocosbuilder { #define CCB_MEMBERVARIABLEASSIGNER_GLUE(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) \ if (pTarget == TARGET && 0 == strcmp(pMemberVariableName, (MEMBERVARIABLENAME))) { \ MEMBERVARIABLETYPE pOldVar = MEMBERVARIABLE; \ MEMBERVARIABLE = dynamic_cast(pNode); \ CC_ASSERT(MEMBERVARIABLE); \ if (pOldVar != MEMBERVARIABLE) { \ CC_SAFE_RELEASE(pOldVar); \ MEMBERVARIABLE->retain(); \ } \ return true; \ } #define CCB_MEMBERVARIABLEASSIGNER_GLUE_WEAK(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) \ if (pTarget == TARGET && 0 == strcmp(pMemberVariableName, MEMBERVARIABLENAME)) { \ MEMBERVARIABLE = dynamic_cast(pNode); \ CC_ASSERT(MEMBERVARIABLE); \ return true; \ } class CCBMemberVariableAssigner { public: /** * @js NA * @lua NA */ virtual ~CCBMemberVariableAssigner() {}; /** * The callback function of assigning member variable. * @note The member variable must be Node or its subclass. * @param target The custom class. * @param memberVariableName The name of the member variable. * @param node The member variable. * @return Whether the assignment was successful. */ virtual bool onAssignCCBMemberVariable(cocos2d::Object* target, const char* memberVariableName, cocos2d::Node* node) = 0; /** * The callback function of assigning custom properties. * @note The member variable must be Integer, Float, Boolean or String. * @param target The custom class. * @param memberVariableName The name of the member variable. * @param value The value of the property. * @return Whether the assignment was successful. */ virtual bool onAssignCCBCustomProperty(cocos2d::Object* target, const char* memberVariableName, const cocos2d::Value& value) { return false; }; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBReader.cpp ================================================ #include #include #include "CCDirector.h" #include "platform/CCFileUtils.h" #include "CCScene.h" #include "CCTextureCache.h" #include "CCSpriteFrameCache.h" #include "CCBReader.h" #include "CCNodeLoader.h" #include "CCNodeLoaderLibrary.h" #include "CCNodeLoaderListener.h" #include "CCBMemberVariableAssigner.h" #include "CCBSelectorResolver.h" #include "CCBAnimationManager.h" #include "CCBSequenceProperty.h" #include "CCBKeyframe.h" using namespace std; using namespace cocos2d; using namespace cocos2d::extension; namespace cocosbuilder {; /************************************************************************* Implementation of CCBFile *************************************************************************/ CCBFile::CCBFile():_CCBFileNode(nullptr) {} CCBFile* CCBFile::create() { CCBFile *ret = new CCBFile(); if (ret) { ret->autorelease(); } return ret; } Node* CCBFile::getCCBFileNode() { return _CCBFileNode; } void CCBFile::setCCBFileNode(Node *pNode) { CC_SAFE_RELEASE(_CCBFileNode); _CCBFileNode = pNode; CC_SAFE_RETAIN(_CCBFileNode); } /************************************************************************* Implementation of CCBReader *************************************************************************/ CCBReader::CCBReader(NodeLoaderLibrary * pNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver, NodeLoaderListener * pNodeLoaderListener) : _data(nullptr) , _bytes(nullptr) , _currentByte(-1) , _currentBit(-1) , _owner(nullptr) , _animationManager(nullptr) , _animatedProps(nullptr) { this->_nodeLoaderLibrary = pNodeLoaderLibrary; this->_nodeLoaderLibrary->retain(); this->_CCBMemberVariableAssigner = pCCBMemberVariableAssigner; this->_CCBSelectorResolver = pCCBSelectorResolver; this->_nodeLoaderListener = pNodeLoaderListener; init(); } CCBReader::CCBReader(CCBReader * ccbReader) : _data(nullptr) , _bytes(nullptr) , _currentByte(-1) , _currentBit(-1) , _owner(nullptr) , _animationManager(nullptr) , _animatedProps(nullptr) { this->_loadedSpriteSheets = ccbReader->_loadedSpriteSheets; this->_nodeLoaderLibrary = ccbReader->_nodeLoaderLibrary; this->_nodeLoaderLibrary->retain(); this->_CCBMemberVariableAssigner = ccbReader->_CCBMemberVariableAssigner; this->_CCBSelectorResolver = ccbReader->_CCBSelectorResolver; this->_nodeLoaderListener = ccbReader->_nodeLoaderListener; this->_CCBRootPath = ccbReader->getCCBRootPath(); init(); } CCBReader::CCBReader() : _data(nullptr) , _bytes(nullptr) , _currentByte(-1) , _currentBit(-1) , _owner(nullptr) , _animationManager(nullptr) , _nodeLoaderLibrary(nullptr) , _nodeLoaderListener(nullptr) , _CCBMemberVariableAssigner(nullptr) , _CCBSelectorResolver(nullptr) { init(); } CCBReader::~CCBReader() { CC_SAFE_RELEASE_NULL(_owner); this->_nodeLoaderLibrary->release(); _ownerOutletNames.clear(); _ownerCallbackNames.clear(); // Clear string cache. this->_stringCache.clear(); setAnimationManager(nullptr); } void CCBReader::setCCBRootPath(const char* ccbRootPath) { CCASSERT(ccbRootPath != nullptr, ""); _CCBRootPath = ccbRootPath; } const std::string& CCBReader::getCCBRootPath() const { return _CCBRootPath; } bool CCBReader::init() { // Setup action manager CCBAnimationManager *pActionManager = new CCBAnimationManager(); setAnimationManager(pActionManager); pActionManager->release(); // Setup resolution scale and container size _animationManager->setRootContainerSize(Director::getInstance()->getWinSize()); return true; } CCBAnimationManager* CCBReader::getAnimationManager() { return _animationManager; } void CCBReader::setAnimationManager(CCBAnimationManager *pAnimationManager) { CC_SAFE_RELEASE(_animationManager); _animationManager = pAnimationManager; CC_SAFE_RETAIN(_animationManager); } CCBReader::CCBAnimationManagerMapPtr CCBReader::getAnimationManagers() { return _animationManagers; } void CCBReader::setAnimationManagers(CCBAnimationManagerMapPtr x) { _animationManagers = x; } CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() { return this->_CCBMemberVariableAssigner; } CCBSelectorResolver * CCBReader::getCCBSelectorResolver() { return this->_CCBSelectorResolver; } set* CCBReader::getAnimatedProperties() { return _animatedProps; } set& CCBReader::getLoadedSpriteSheet() { return _loadedSpriteSheets; } Object* CCBReader::getOwner() { return _owner; } Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName) { return this->readNodeGraphFromFile(pCCBFileName, nullptr); } Node* CCBReader::readNodeGraphFromFile(const char* pCCBFileName, Object* pOwner) { return this->readNodeGraphFromFile(pCCBFileName, pOwner, Director::getInstance()->getWinSize()); } Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Object *pOwner, const Size &parentSize) { if (nullptr == pCCBFileName || strlen(pCCBFileName) == 0) { return nullptr; } std::string strCCBFileName(pCCBFileName); std::string strSuffix(".ccbi"); // Add ccbi suffix if (!CCBReader::endsWith(strCCBFileName.c_str(), strSuffix.c_str())) { strCCBFileName += strSuffix; } std::string strPath = FileUtils::getInstance()->fullPathForFilename(strCCBFileName.c_str()); auto dataPtr = std::make_shared(FileUtils::getInstance()->getDataFromFile(strPath)); Node *ret = this->readNodeGraphFromData(dataPtr, pOwner, parentSize); return ret; } Node* CCBReader::readNodeGraphFromData(std::shared_ptr data, Object *pOwner, const Size &parentSize) { _data = data; _bytes =_data->getBytes(); _currentByte = 0; _currentBit = 0; _owner = pOwner; CC_SAFE_RETAIN(_owner); _animationManager->setRootContainerSize(parentSize); _animationManager->_owner = _owner; Node *pNodeGraph = readFileWithCleanUp(true, std::make_shared()); if (pNodeGraph && _animationManager->getAutoPlaySequenceId() != -1) { // Auto play animations _animationManager->runAnimationsForSequenceIdTweenDuration(_animationManager->getAutoPlaySequenceId(), 0); } // Assign actionManagers to userObject for (auto iter = _animationManagers->begin(); iter != _animationManagers->end(); ++iter) { Node* pNode = iter->first; CCBAnimationManager* manager = iter->second; pNode->setUserObject(manager); if (_jsControlled) { _nodesWithAnimationManagers.pushBack(pNode); _animationManagersForNodes.pushBack(manager); } } return pNodeGraph; } Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName) { return createSceneWithNodeGraphFromFile(pCCBFileName, nullptr); } Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Object *pOwner) { return createSceneWithNodeGraphFromFile(pCCBFileName, pOwner, Director::getInstance()->getWinSize()); } Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Object *pOwner, const Size &parentSize) { Node *pNode = readNodeGraphFromFile(pCCBFileName, pOwner, parentSize); Scene *pScene = Scene::create(); pScene->addChild(pNode); return pScene; } void CCBReader::cleanUpNodeGraph(Node *node) { node->setUserObject(nullptr); auto& children = node->getChildren(); for(const auto &obj : children) { cleanUpNodeGraph(obj); } } Node* CCBReader::readFileWithCleanUp(bool bCleanUp, CCBAnimationManagerMapPtr am) { if (! readHeader()) { return nullptr; } if (! readStringCache()) { return nullptr; } if (! readSequences()) { return nullptr; } setAnimationManagers(am); Node *pNode = readNodeGraph(nullptr); _animationManagers->insert(pNode, _animationManager); if (bCleanUp) { cleanUpNodeGraph(pNode); } return pNode; } bool CCBReader::readStringCache() { int numStrings = this->readInt(false); for(int i = 0; i < numStrings; i++) { this->_stringCache.push_back(this->readUTF8()); } return true; } bool CCBReader::readHeader() { /* If no bytes loaded, don't crash about it. */ if(this->_bytes == nullptr) { return false; } /* Read magic bytes */ int magicBytes = *((int*)(this->_bytes + this->_currentByte)); this->_currentByte += 4; if(CC_SWAP_INT32_BIG_TO_HOST(magicBytes) != (*reinterpret_cast("ccbi"))) { return false; } /* Read version. */ int version = this->readInt(false); if(version != CCB_VERSION) { log("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, CCB_VERSION); return false; } // Read JS check _jsControlled = this->readBool(); _animationManager->_jsControlled = _jsControlled; return true; } unsigned char CCBReader::readByte() { unsigned char byte = this->_bytes[this->_currentByte]; this->_currentByte++; return byte; } bool CCBReader::readBool() { return 0 == this->readByte() ? false : true; } std::string CCBReader::readUTF8() { std::string ret; int b0 = this->readByte(); int b1 = this->readByte(); int numBytes = b0 << 8 | b1; char* pStr = (char*)malloc(numBytes+1); memcpy(pStr, _bytes+_currentByte, numBytes); pStr[numBytes] = '\0'; ret = pStr; free(pStr); _currentByte += numBytes; return ret; } bool CCBReader::getBit() { bool bit; unsigned char byte = *(this->_bytes + this->_currentByte); if(byte & (1 << this->_currentBit)) { bit = true; } else { bit = false; } this->_currentBit++; if(this->_currentBit >= 8) { this->_currentBit = 0; this->_currentByte++; } return bit; } void CCBReader::alignBits() { if(this->_currentBit) { this->_currentBit = 0; this->_currentByte++; } } int CCBReader::readInt(bool pSigned) { // Read encoded int int numBits = 0; while(!this->getBit()) { numBits++; } long long current = 0; for(int a = numBits - 1; a >= 0; a--) { if(this->getBit()) { current |= 1LL << a; } } current |= 1LL << numBits; int num; if(pSigned) { int s = current % 2; if(s) { num = static_cast(current / 2); } else { num = static_cast(-current / 2); } } else { num = static_cast(current - 1); } this->alignBits(); return num; } float CCBReader::readFloat() { FloatType type = static_cast(this->readByte()); switch (type) { case FloatType::_0: return 0; case FloatType::_1: return 1; case FloatType::MINUS1: return -1; case FloatType::_05: return 0.5f; case FloatType::INTEGER: return (float)this->readInt(true); default: { /* using a memcpy since the compiler isn't * doing the float ptr math correctly on device. * TODO still applies in C++ ? */ unsigned char* pF = (this->_bytes + this->_currentByte); float f = 0; // N.B - in order to avoid an unaligned memory access crash on 'memcpy()' the the (void*) casts of the source and // destination pointers are EXTREMELY important for the ARM compiler. // // Without a (void*) cast, the ARM compiler makes the assumption that the float* pointer is naturally aligned // according to it's type size (aligned along 4 byte boundaries) and thus tries to call a more optimized // version of memcpy() which makes this alignment assumption also. When reading back from a file of course our pointers // may not be aligned, hence we need to avoid the compiler making this assumption. The (void*) cast serves this purpose, // and causes the ARM compiler to choose the slower, more generalized (unaligned) version of memcpy() // // For more about this compiler behavior, see: // http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3934.html memcpy((void*) &f, (const void*) pF, sizeof(float)); this->_currentByte += sizeof(float); return f; } } } std::string CCBReader::readCachedString() { int n = this->readInt(false); return this->_stringCache[n]; } Node * CCBReader::readNodeGraph(Node * pParent) { /* Read class name. */ std::string className = this->readCachedString(); std::string _jsControlledName; if(_jsControlled) { _jsControlledName = this->readCachedString(); } // Read assignment type and name TargetType memberVarAssignmentType = static_cast(this->readInt(false)); std::string memberVarAssignmentName; if(memberVarAssignmentType != TargetType::NONE) { memberVarAssignmentName = this->readCachedString(); } NodeLoader *ccNodeLoader = this->_nodeLoaderLibrary->getNodeLoader(className.c_str()); if (! ccNodeLoader) { log("no corresponding node loader for %s", className.c_str()); return nullptr; } Node *node = ccNodeLoader->loadNode(pParent, this); // Set root node if (! _animationManager->getRootNode()) { _animationManager->setRootNode(node); } // Assign controller if(_jsControlled && node == _animationManager->getRootNode()) { _animationManager->setDocumentControllerName(_jsControlledName); } // Read animated properties std::unordered_map> seqs; _animatedProps = new set(); int numSequence = readInt(false); for (int i = 0; i < numSequence; ++i) { int seqId = readInt(false); Map seqNodeProps; int numProps = readInt(false); for (int j = 0; j < numProps; ++j) { CCBSequenceProperty *seqProp = new CCBSequenceProperty(); seqProp->autorelease(); seqProp->setName(readCachedString().c_str()); seqProp->setType(readInt(false)); _animatedProps->insert(seqProp->getName()); int numKeyframes = readInt(false); for (int k = 0; k < numKeyframes; ++k) { CCBKeyframe *keyframe = readKeyframe(static_cast(seqProp->getType())); seqProp->getKeyframes().pushBack(keyframe); } seqNodeProps.insert(seqProp->getName(), seqProp); } seqs[seqId] = seqNodeProps; } if (!seqs.empty()) { _animationManager->addNode(node, seqs); } // Read properties ccNodeLoader->parseProperties(node, pParent, this); bool isCCBFileNode = (nullptr == dynamic_cast(node)) ? false : true; // Handle sub ccb files (remove middle node) if (isCCBFileNode) { CCBFile *ccbFileNode = (CCBFile*)node; Node *embeddedNode = ccbFileNode->getCCBFileNode(); embeddedNode->setPosition(ccbFileNode->getPosition()); embeddedNode->setRotation(ccbFileNode->getRotation()); embeddedNode->setScaleX(ccbFileNode->getScaleX()); embeddedNode->setScaleY(ccbFileNode->getScaleY()); embeddedNode->setTag(ccbFileNode->getTag()); embeddedNode->setVisible(true); //embeddedNode->ignoreAnchorPointForPosition(ccbFileNode->isIgnoreAnchorPointForPosition()); _animationManager->moveAnimationsFromNode(ccbFileNode, embeddedNode); ccbFileNode->setCCBFileNode(nullptr); node = embeddedNode; } #ifdef CCB_ENABLE_JAVASCRIPT /* if (memberVarAssignmentType && memberVarAssignmentName && ![memberVarAssignmentName isEqualToString:@""]) { [[JSCocoa sharedController] setObject:node withName:memberVarAssignmentName]; }*/ #else if (memberVarAssignmentType != TargetType::NONE) { if(!_jsControlled) { Object * target = nullptr; if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT) { target = _animationManager->getRootNode(); } else if(memberVarAssignmentType == TargetType::OWNER) { target = this->_owner; } if(target != nullptr) { CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast(target); bool assigned = false; if (memberVarAssignmentType != TargetType::NONE) { if(targetAsCCBMemberVariableAssigner != nullptr) { assigned = targetAsCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName.c_str(), node); } if(!assigned && this->_CCBMemberVariableAssigner != nullptr) { assigned = this->_CCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName.c_str(), node); } } } } else { if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT) { _animationManager->addDocumentOutletName(memberVarAssignmentName); _animationManager->addDocumentOutletNode(node); } else { _ownerOutletNames.push_back(memberVarAssignmentName); _ownerOutletNodes.pushBack(node); } } } // Assign custom properties. if (!ccNodeLoader->getCustomProperties().empty()) { bool customAssigned = false; if(!_jsControlled) { Object * target = node; if(target != nullptr) { CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast(target); if(targetAsCCBMemberVariableAssigner != nullptr) { auto& customPropeties = ccNodeLoader->getCustomProperties(); for (auto iter = customPropeties.begin(); iter != customPropeties.end(); ++iter) { customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, iter->first.c_str(), iter->second); if(!customAssigned && this->_CCBMemberVariableAssigner != nullptr) { customAssigned = this->_CCBMemberVariableAssigner->onAssignCCBCustomProperty(target, iter->first.c_str(), iter->second); } } } } } } #endif // CCB_ENABLE_JAVASCRIPT delete _animatedProps; _animatedProps = nullptr; /* Read and add children. */ int numChildren = this->readInt(false); for(int i = 0; i < numChildren; i++) { Node * child = this->readNodeGraph(node); node->addChild(child); } // FIX ISSUE #1860: "onNodeLoaded will be called twice if ccb was added as a CCBFile". // If it's a sub-ccb node, skip notification to NodeLoaderListener since it will be // notified at LINE #734: Node * child = this->readNodeGraph(node); if (!isCCBFileNode) { // Call onNodeLoaded NodeLoaderListener * nodeAsNodeLoaderListener = dynamic_cast(node); if(nodeAsNodeLoaderListener != nullptr) { nodeAsNodeLoaderListener->onNodeLoaded(node, ccNodeLoader); } else if(this->_nodeLoaderListener != nullptr) { this->_nodeLoaderListener->onNodeLoaded(node, ccNodeLoader); } } return node; } CCBKeyframe* CCBReader::readKeyframe(PropertyType type) { CCBKeyframe *keyframe = new CCBKeyframe(); keyframe->autorelease(); keyframe->setTime(readFloat()); CCBKeyframe::EasingType easingType = static_cast(readInt(false)); float easingOpt = 0; Value value; if (easingType == CCBKeyframe::EasingType::CUBIC_IN || easingType == CCBKeyframe::EasingType::CUBIC_OUT || easingType == CCBKeyframe::EasingType::CUBIC_INOUT || easingType == CCBKeyframe::EasingType::ELASTIC_IN || easingType == CCBKeyframe::EasingType::ELASTIC_OUT || easingType == CCBKeyframe::EasingType::ELASTIC_INOUT) { easingOpt = readFloat(); } keyframe->setEasingType(easingType); keyframe->setEasingOpt(easingOpt); if (type == PropertyType::CHECK) { value = readBool(); } else if (type == PropertyType::BYTE) { value = readByte(); } else if (type == PropertyType::COLOR3) { unsigned char r = readByte(); unsigned char g = readByte(); unsigned char b = readByte(); ValueMap colorMap; colorMap["r"] = r; colorMap["g"] = g; colorMap["b"] = b; value = colorMap; } else if (type == PropertyType::DEGREES) { value = readFloat(); } else if (type == PropertyType::SCALE_LOCK || type == PropertyType::POSITION || type == PropertyType::FLOAT_XY) { float a = readFloat(); float b = readFloat(); ValueVector ab; ab.push_back(Value(a)); ab.push_back(Value(b)); value = ab; } else if (type == PropertyType::SPRITEFRAME) { std::string spriteSheet = readCachedString(); std::string spriteFile = readCachedString(); SpriteFrame* spriteFrame; if (spriteSheet.length() == 0) { spriteFile = _CCBRootPath + spriteFile; Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); Rect bounds = Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = SpriteFrame::createWithTexture(texture, bounds); } else { spriteSheet = _CCBRootPath + spriteSheet; SpriteFrameCache* frameCache = SpriteFrameCache::getInstance(); // Load the sprite sheet only if it is not loaded if (_loadedSpriteSheets.find(spriteSheet) == _loadedSpriteSheets.end()) { frameCache->addSpriteFramesWithFile(spriteSheet.c_str()); _loadedSpriteSheets.insert(spriteSheet); } spriteFrame = frameCache->getSpriteFrameByName(spriteFile.c_str()); } keyframe->setObject(spriteFrame); } if (!value.isNull()) keyframe->setValue(value); return keyframe; } bool CCBReader::readCallbackKeyframesForSeq(CCBSequence* seq) { int numKeyframes = readInt(false); if(!numKeyframes) return true; CCBSequenceProperty* channel = new CCBSequenceProperty(); channel->autorelease(); for(int i = 0; i < numKeyframes; ++i) { float time = readFloat(); std::string callbackName = readCachedString(); int callbackType = readInt(false); ValueVector valueVector; valueVector.push_back(Value(callbackName)); valueVector.push_back(Value(callbackType)); CCBKeyframe* keyframe = new CCBKeyframe(); keyframe->autorelease(); keyframe->setTime(time); keyframe->setValue(Value(valueVector)); if(_jsControlled) { std::stringstream callbackIdentifier; callbackIdentifier << callbackType; callbackIdentifier << ":" + callbackName; _animationManager->getKeyframeCallbacks().push_back(Value(callbackIdentifier.str())); } channel->getKeyframes().pushBack(keyframe); } seq->setCallbackChannel(channel); return true; } bool CCBReader::readSoundKeyframesForSeq(CCBSequence* seq) { int numKeyframes = readInt(false); if(!numKeyframes) return true; CCBSequenceProperty* channel = new CCBSequenceProperty(); channel->autorelease(); for(int i = 0; i < numKeyframes; ++i) { float time = readFloat(); std::string soundFile = readCachedString(); float pitch = readFloat(); float pan = readFloat(); float gain = readFloat(); ValueVector vec; vec.push_back(Value(soundFile)); vec.push_back(Value(pitch)); vec.push_back(Value(pan)); vec.push_back(Value(gain)); CCBKeyframe* keyframe = new CCBKeyframe(); keyframe->setTime(time); keyframe->setValue(Value(vec)); channel->getKeyframes().pushBack(keyframe); keyframe->release(); } seq->setSoundChannel(channel); return true; } Node * CCBReader::readNodeGraph() { return this->readNodeGraph(nullptr); } bool CCBReader::readSequences() { auto& sequences = _animationManager->getSequences(); int numSeqs = readInt(false); for (int i = 0; i < numSeqs; i++) { CCBSequence *seq = new CCBSequence(); seq->autorelease(); seq->setDuration(readFloat()); seq->setName(readCachedString().c_str()); seq->setSequenceId(readInt(false)); seq->setChainedSequenceId(readInt(true)); if(!readCallbackKeyframesForSeq(seq)) return false; if(!readSoundKeyframesForSeq(seq)) return false; sequences.pushBack(seq); } _animationManager->setAutoPlaySequenceId(readInt(true)); return true; } std::string CCBReader::lastPathComponent(const char* pPath) { std::string path(pPath); size_t slashPos = path.find_last_of("/"); if(slashPos != std::string::npos) { return path.substr(slashPos + 1, path.length() - slashPos); } return path; } std::string CCBReader::deletePathExtension(const char* pPath) { std::string path(pPath); size_t dotPos = path.find_last_of("."); if(dotPos != std::string::npos) { return path.substr(0, dotPos); } return path; } std::string CCBReader::toLowerCase(const char* pString) { std::string copy(pString); std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); return copy; } bool CCBReader::endsWith(const char* pString, const char* pEnding) { std::string string(pString); std::string ending(pEnding); if(string.length() >= ending.length()) { return (string.compare(string.length() - ending.length(), ending.length(), ending) == 0); } else { return false; } } bool CCBReader::isJSControlled() { return _jsControlled; } void CCBReader::addOwnerCallbackName(const std::string& name) { _ownerCallbackNames.push_back(name); } void CCBReader::addOwnerCallbackNode(Node *node) { _ownerCallbackNodes.pushBack(node); } void CCBReader::addOwnerCallbackControlEvents(Control::EventType type) { _ownerOwnerCallbackControlEvents.push_back(Value((int)type)); } void CCBReader::addDocumentCallbackName(const std::string& name) { _animationManager->addDocumentCallbackName(name); } void CCBReader::addDocumentCallbackNode(Node *node) { _animationManager->addDocumentCallbackNode(node); } void CCBReader::addDocumentCallbackControlEvents(Control::EventType eventType) { _animationManager->addDocumentCallbackControlEvents(eventType); } ValueVector CCBReader::getOwnerCallbackNames() { ValueVector ret; ret.reserve(_ownerCallbackNames.size()); std::vector::iterator it = _ownerCallbackNames.begin(); for (; it != _ownerCallbackNames.end(); ++it) { ret.push_back(Value(*it)); } return ret; } Vector& CCBReader::getOwnerCallbackNodes() { return _ownerCallbackNodes; } ValueVector& CCBReader::getOwnerCallbackControlEvents() { return _ownerOwnerCallbackControlEvents; } ValueVector CCBReader::getOwnerOutletNames() { ValueVector ret; ret.reserve(_ownerOutletNames.size()); std::vector::iterator it = _ownerOutletNames.begin(); for (; it != _ownerOutletNames.end(); ++it) { ret.push_back(Value(*it)); } return ret; } Vector& CCBReader::getOwnerOutletNodes() { return _ownerOutletNodes; } Vector& CCBReader::getNodesWithAnimationManagers() { return _nodesWithAnimationManagers; } Vector& CCBReader::getAnimationManagersForNodes() { return _animationManagersForNodes; } void CCBReader::addOwnerOutletName(std::string name) { _ownerOutletNames.push_back(name); } void CCBReader::addOwnerOutletNode(Node *node) { if (nullptr == node) return; _ownerOutletNodes.pushBack(node); } /************************************************************************ Static functions ************************************************************************/ static float __ccbResolutionScale = 1.0f; float CCBReader::getResolutionScale() { return __ccbResolutionScale; } void CCBReader::setResolutionScale(float scale) { __ccbResolutionScale = scale; } }; ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBReader.h ================================================ #ifndef _CCB_CCBREADER_H_ #define _CCB_CCBREADER_H_ #include #include #include "CCNode.h" #include "CCData.h" #include "CCMap.h" #include "CCBSequence.h" #include "extensions/GUI/CCControlExtension/CCControl.h" #define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ T * ptr = new T(); \ if(ptr != NULL) { \ ptr->autorelease(); \ return ptr; \ } \ CC_SAFE_DELETE(ptr); \ return NULL; \ } #define CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(T, METHOD) static T * METHOD() { \ T * ptr = new T(); \ if(ptr != NULL && ptr->init()) { \ ptr->autorelease(); \ return ptr; \ } \ CC_SAFE_DELETE(ptr); \ return NULL; \ } #define CCB_VERSION 5 namespace cocosbuilder { /** * @addtogroup cocosbuilder * @{ */ class CCBFile : public cocos2d::Node { private: cocos2d::Node *_CCBFileNode; public: CCBFile(); static CCBFile* create(); cocos2d::Node* getCCBFileNode(); void setCCBFileNode(Node *pNode); // retain }; /* Forward declaration. */ class NodeLoader; class NodeLoaderLibrary; class NodeLoaderListener; class CCBMemberVariableAssigner; class CCBSelectorResolver; class CCBAnimationManager; class CCBKeyframe; /** * @brief Parse CCBI file which is generated by CocosBuilder */ class CCBReader : public cocos2d::Object { public: enum class PropertyType { POSITION = 0, SIZE, POINT, POINT_LOCK, SCALE_LOCK, DEGREES, INTEGER, FLOAT, FLOAT_VAR, CHECK, SPRITEFRAME, TEXTURE, BYTE, COLOR3, COLOR4F_VAR, FLIP, BLEND_MODE, FNT_FILE, TEXT, FONT_TTF, INTEGER_LABELED, BLOCK, ANIMATION, CCB_FILE, STRING, BLOCK_CONTROL, FLOAT_SCALE, FLOAT_XY }; enum class FloatType { _0 = 0, _1, MINUS1, _05, INTEGER, FULL }; enum class PlatformType { ALL = 0, IOS, MAC }; enum class TargetType { NONE = 0, DOCUMENT_ROOT = 1, OWNER = 2, }; enum class PositionType { RELATIVE_BOTTOM_LEFT, RELATIVE_TOP_LEFT, RELATIVE_TOP_RIGHT, RELATIVE_BOTTOM_RIGHT, PERCENT, MULTIPLY_RESOLUTION, }; enum class SizeType { ABSOLUTE, PERCENT, RELATIVE_CONTAINER, HORIZONTAL_PERCENT, VERTICAL_PERCENT, MULTIPLY_RESOLUTION, }; enum class ScaleType { ABSOLUTE, MULTIPLY_RESOLUTION }; /** * @js NA * @lua NA */ CCBReader(NodeLoaderLibrary *pNodeLoaderLibrary, CCBMemberVariableAssigner *pCCBMemberVariableAssigner = NULL, CCBSelectorResolver *pCCBSelectorResolver = NULL, NodeLoaderListener *pNodeLoaderListener = NULL); /** * @js NA * @lua NA */ CCBReader(CCBReader *ccbReader); /** * @js NA * @lua NA */ virtual ~CCBReader(); /** * @js NA * @lua NA */ CCBReader(); void setCCBRootPath(const char* ccbRootPath); const std::string& getCCBRootPath() const; cocos2d::Node* readNodeGraphFromFile(const char *pCCBFileName); cocos2d::Node* readNodeGraphFromFile(const char *pCCBFileName, cocos2d::Object *pOwner); cocos2d::Node* readNodeGraphFromFile(const char *pCCBFileName, cocos2d::Object *pOwner, const cocos2d::Size &parentSize); /** * @js NA * @lua NA */ cocos2d::Node* readNodeGraphFromData(std::shared_ptr data, cocos2d::Object *pOwner, const cocos2d::Size &parentSize); /** @lua NA */ cocos2d::Scene* createSceneWithNodeGraphFromFile(const char *pCCBFileName); /** @lua NA */ cocos2d::Scene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, cocos2d::Object *pOwner); /** @lua NA */ cocos2d::Scene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, cocos2d::Object *pOwner, const cocos2d::Size &parentSize); /** * @js NA * @lua NA */ CCBMemberVariableAssigner* getCCBMemberVariableAssigner(); /** * @js NA * @lua NA */ CCBSelectorResolver* getCCBSelectorResolver(); /** * @js getActionManager * @lua getActionManager */ CCBAnimationManager* getAnimationManager(); /** * @js setActionManager * @lua setActionManager */ void setAnimationManager(CCBAnimationManager *pAnimationManager); /** Used in NodeLoader::parseProperties() * @js NA * @lua NA */ std::set* getAnimatedProperties(); /** * @js NA * @lua NA */ std::set& getLoadedSpriteSheet(); /** * @js NA * @lua NA */ cocos2d::Object* getOwner(); /* Utility methods. * @js NA * @lua NA */ static std::string lastPathComponent(const char* pString); /** * @js NA * @lua NA */ static std::string deletePathExtension(const char* pString); /** * @js NA * @lua NA */ static std::string toLowerCase(const char* pString); /** * @js NA * @lua NA */ static bool endsWith(const char* pString, const char* pEnding); /* Parse methods. * @js NA * @lua NA */ int readInt(bool pSigned); /** * @js NA * @lua NA */ unsigned char readByte(); /** * @js NA * @lua NA */ bool readBool(); std::string readUTF8(); /** * @js NA * @lua NA */ float readFloat(); /** * @js NA * @lua NA */ std::string readCachedString(); /** * @js NA * @lua NA */ bool isJSControlled(); bool readCallbackKeyframesForSeq(CCBSequence* seq); bool readSoundKeyframesForSeq(CCBSequence* seq); cocos2d::ValueVector getOwnerCallbackNames(); cocos2d::Vector& getOwnerCallbackNodes(); cocos2d::ValueVector& getOwnerCallbackControlEvents(); cocos2d::ValueVector getOwnerOutletNames(); cocos2d::Vector& getOwnerOutletNodes(); cocos2d::Vector& getNodesWithAnimationManagers(); cocos2d::Vector& getAnimationManagersForNodes(); typedef cocos2d::Map CCBAnimationManagerMap; typedef std::shared_ptr CCBAnimationManagerMapPtr; /** * @js NA * @lua NA */ CCBAnimationManagerMapPtr getAnimationManagers(); /** * @js NA * @lua NA */ void setAnimationManagers(CCBAnimationManagerMapPtr x); /** * @js NA * @lua NA */ void addOwnerCallbackName(const std::string& name); /** * @js NA * @lua NA */ void addOwnerCallbackNode(cocos2d::Node *node); void addOwnerCallbackControlEvents(cocos2d::extension::Control::EventType type); /** * @js NA * @lua NA */ void addDocumentCallbackName(const std::string& name); /** * @js NA * @lua NA */ void addDocumentCallbackNode(cocos2d::Node *node); void addDocumentCallbackControlEvents(cocos2d::extension::Control::EventType eventType); /** * @js NA * @lua NA */ static float getResolutionScale(); static void setResolutionScale(float scale); /** * @js NA * @lua NA */ cocos2d::Node* readFileWithCleanUp(bool bCleanUp, CCBAnimationManagerMapPtr am); void addOwnerOutletName(std::string name); void addOwnerOutletNode(cocos2d::Node *node); private: void cleanUpNodeGraph(cocos2d::Node *pNode); bool readSequences(); CCBKeyframe* readKeyframe(PropertyType type); bool readHeader(); bool readStringCache(); //void readStringCacheEntry(); cocos2d::Node* readNodeGraph(); cocos2d::Node* readNodeGraph(cocos2d::Node * pParent); bool getBit(); void alignBits(); bool init(); friend class NodeLoader; private: std::shared_ptr _data; unsigned char *_bytes; int _currentByte; int _currentBit; std::vector _stringCache; std::set _loadedSpriteSheets; cocos2d::Object *_owner; CCBAnimationManager* _animationManager; //retain CCBAnimationManagerMapPtr _animationManagers; std::set *_animatedProps; NodeLoaderLibrary *_nodeLoaderLibrary; NodeLoaderListener *_nodeLoaderListener; CCBMemberVariableAssigner *_CCBMemberVariableAssigner; CCBSelectorResolver *_CCBSelectorResolver; std::vector _ownerOutletNames; cocos2d::Vector _ownerOutletNodes; cocos2d::Vector _nodesWithAnimationManagers; cocos2d::Vector _animationManagersForNodes; std::vector _ownerCallbackNames; cocos2d::Vector _ownerCallbackNodes; cocos2d::ValueVector _ownerOwnerCallbackControlEvents; std::string _CCBRootPath; bool _jsControlled; }; // end of effects group /// @} } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBSelectorResolver.h ================================================ #ifndef _CCB_CCBSELECTORRESOLVER_H_ #define _CCB_CCBSELECTORRESOLVER_H_ #include "extensions//GUI/CCControlExtension/CCInvocation.h" namespace cocosbuilder { #define CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(TARGET, SELECTORNAME, METHOD) if(pTarget == TARGET && strcmp(pSelectorName, SELECTORNAME) == 0) { \ return menu_selector(METHOD); \ } #define CCB_SELECTORRESOLVER_CCCONTROL_GLUE(TARGET, SELECTORNAME, METHOD) if(pTarget == TARGET && strcmp(pSelectorName, SELECTORNAME) == 0) { \ return cccontrol_selector(METHOD); \ } #define CCB_SELECTORRESOLVER_CALLFUNC_GLUE(TARGET, SELECTORNAME, METHOD) if(pTarget == TARGET && strcmp(pSelectorName, SELECTORNAME) == 0) { \ return callfuncN_selector(METHOD); \ } class CCBSelectorResolver { public: /** * @js NA * @lua NA */ virtual ~CCBSelectorResolver() {}; virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char* pSelectorName) = 0; virtual cocos2d::SEL_CallFuncN onResolveCCBCCCallFuncSelector(cocos2d::Object * pTarget, const char* pSelectorName) { return NULL; }; virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char* pSelectorName) = 0; }; class CCBScriptOwnerProtocol { public: /** * @js NA * @lua NA */ virtual ~CCBScriptOwnerProtocol() {}; virtual CCBSelectorResolver * createNew() = 0; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBSequence.cpp ================================================ #include "CCBSequence.h" using namespace cocos2d; using namespace std; namespace cocosbuilder { CCBSequence::CCBSequence() : _duration(0.0f) , _name("") , mSequenceId(0) , mChainedSequenceId(0) , mCallbackChannel(NULL) , mSoundChannel(NULL) {} CCBSequence::~CCBSequence() { CC_SAFE_RELEASE(mCallbackChannel); CC_SAFE_RELEASE(mSoundChannel); } float CCBSequence::getDuration() { return _duration; } void CCBSequence::setDuration(float fDuration) { _duration = fDuration; } const char* CCBSequence::getName() { return _name.c_str(); } void CCBSequence::setName(const char *pName) { _name = pName; } int CCBSequence::getSequenceId() { return mSequenceId; } void CCBSequence::setSequenceId(int nSequenceId) { mSequenceId = nSequenceId; } CCBSequenceProperty* CCBSequence::getCallbackChannel() { return mCallbackChannel; } void CCBSequence::setCallbackChannel(CCBSequenceProperty* callbackChannel) { CC_SAFE_RELEASE(mCallbackChannel); mCallbackChannel = callbackChannel; CC_SAFE_RETAIN(mCallbackChannel); } CCBSequenceProperty* CCBSequence::getSoundChannel() { return mSoundChannel; } void CCBSequence::setSoundChannel(CCBSequenceProperty* soundChannel) { CC_SAFE_RELEASE(mSoundChannel); mSoundChannel = soundChannel; CC_SAFE_RETAIN(mSoundChannel); } int CCBSequence::getChainedSequenceId() { return mChainedSequenceId; } void CCBSequence::setChainedSequenceId(int nChainedSequenceId) { mChainedSequenceId = nChainedSequenceId; } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBSequence.h ================================================ #ifndef __CCB_CCSEQUENCE_H__ #define __CCB_CCSEQUENCE_H__ #include #include "CCObject.h" #include "CCBSequenceProperty.h" namespace cocosbuilder { class CCBSequence : public cocos2d::Object { public: CCBSequence(); /** * @js NA * @lua NA */ ~CCBSequence(); float getDuration(); void setDuration(float fDuration); CCBSequenceProperty* getCallbackChannel(); void setCallbackChannel(CCBSequenceProperty* callbackChannel); CCBSequenceProperty* getSoundChannel(); void setSoundChannel(CCBSequenceProperty* soundChannel); const char* getName(); void setName(const char *pName); int getSequenceId(); void setSequenceId(int nSequenceId); int getChainedSequenceId(); void setChainedSequenceId(int nChainedSequenceId); private: float _duration; std::string _name; int mSequenceId; int mChainedSequenceId; CCBSequenceProperty* mCallbackChannel; CCBSequenceProperty* mSoundChannel; }; } #endif // __CCB_CCSEQUENCE_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBSequenceProperty.cpp ================================================ #include "CCBSequenceProperty.h" using namespace cocos2d; using namespace std; namespace cocosbuilder { CCBSequenceProperty::CCBSequenceProperty() : _name("") , _type(0) { init(); } bool CCBSequenceProperty::init() { return true; } CCBSequenceProperty::~CCBSequenceProperty() { } const char* CCBSequenceProperty::getName() { return _name.c_str(); } void CCBSequenceProperty::setName(const char *pName) { _name = pName; } int CCBSequenceProperty::getType() { return _type; } void CCBSequenceProperty::setType(int type) { _type = type; } cocos2d::Vector& CCBSequenceProperty::getKeyframes() { return _keyframes; } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCBSequenceProperty.h ================================================ #ifndef __CCB_SEQUENCE_PROPERTY_H__ #define __CCB_SEQUENCE_PROPERTY_H__ #include "CCObject.h" #include "CCVector.h" #include "CCBKeyframe.h" namespace cocosbuilder { class CCBSequenceProperty : public cocos2d::Object { public: /** * @js ctor */ CCBSequenceProperty(); /** * @js NA * @lua NA */ ~CCBSequenceProperty(); virtual bool init(); const char* getName(); void setName(const char* pName); int getType(); void setType(int type); cocos2d::Vector& getKeyframes(); private: std::string _name; int _type; cocos2d::Vector _keyframes; }; } #endif // __CCB_SEQUENCE_PROPERTY_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCControlButtonLoader.cpp ================================================ #include "CCControlButtonLoader.h" using namespace cocos2d; using namespace cocos2d::extension; namespace cocosbuilder {; #define PROPERTY_ZOOMONTOUCHDOWN "zoomOnTouchDown" #define PROPERTY_TITLE_NORMAL "title|1" #define PROPERTY_TITLE_HIGHLIGHTED "title|2" #define PROPERTY_TITLE_DISABLED "title|3" #define PROPERTY_TITLECOLOR_NORMAL "titleColor|1" #define PROPERTY_TITLECOLOR_HIGHLIGHTED "titleColor|2" #define PROPERTY_TITLECOLOR_DISABLED "titleColor|3" #define PROPERTY_TITLETTF_NORMAL "titleTTF|1" #define PROPERTY_TITLETTF_HIGHLIGHTED "titleTTF|2" #define PROPERTY_TITLETTF_DISABLED "titleTTF|3" #define PROPERTY_TITLETTFSIZE_NORMAL "titleTTFSize|1" #define PROPERTY_TITLETTFSIZE_HIGHLIGHTED "titleTTFSize|2" #define PROPERTY_TITLETTFSIZE_DISABLED "titleTTFSize|3" #define PROPERTY_LABELANCHORPOINT "labelAnchorPoint" #define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder! #define PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL "backgroundSpriteFrame|1" #define PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED "backgroundSpriteFrame|2" #define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|3" void ControlButtonLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_ZOOMONTOUCHDOWN) == 0) { ((ControlButton *)pNode)->setZoomOnTouchDown(pCheck); } else { ControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader); } } void ControlButtonLoader::onHandlePropTypeString(Node * pNode, Node * pParent, const char * pPropertyName, const char * pString, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) { ((ControlButton *)pNode)->setTitleForState(pString, Control::State::NORMAL); } else if(strcmp(pPropertyName, PROPERTY_TITLE_HIGHLIGHTED) == 0) { ((ControlButton *)pNode)->setTitleForState(pString, Control::State::HIGH_LIGHTED); } else if(strcmp(pPropertyName, PROPERTY_TITLE_DISABLED) == 0) { ((ControlButton *)pNode)->setTitleForState(pString, Control::State::DISABLED); } else { ControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, ccbReader); } } void ControlButtonLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_TITLETTF_NORMAL) == 0) { ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::NORMAL); } else if(strcmp(pPropertyName, PROPERTY_TITLETTF_HIGHLIGHTED) == 0) { ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::HIGH_LIGHTED); } else if(strcmp(pPropertyName, PROPERTY_TITLETTF_DISABLED) == 0) { ((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::DISABLED); } else { ControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, ccbReader); } } void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_NORMAL) == 0) { ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::NORMAL); } else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) { ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::HIGH_LIGHTED); } else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_DISABLED) == 0) { ((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::DISABLED); } else { ControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, ccbReader); } } void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_LABELANCHORPOINT) == 0) { ((ControlButton *)pNode)->setLabelAnchorPoint(pPoint); } else { ControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, ccbReader); } } void ControlButtonLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { ((ControlButton *)pNode)->setPreferredSize(pSize); } else { ControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader); } } void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { if(pSpriteFrame != NULL) { ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::NORMAL); } } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { if(pSpriteFrame != NULL) { ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::HIGH_LIGHTED); } } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { if(pSpriteFrame != NULL) { ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::DISABLED); } } else { ControlLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader); } } void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) { ((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::NORMAL); } else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) { ((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::HIGH_LIGHTED); } else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_DISABLED) == 0) { ((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::DISABLED); } else { ControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); } } }; ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCControlButtonLoader.h ================================================ #ifndef _CCB_CCCONTROLBUTTONLOADER_H_ #define _CCB_CCCONTROLBUTTONLOADER_H_ #include "CCControlLoader.h" #include "extensions//GUI/CCControlExtension/CCControlButton.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class ControlButtonLoader : public ControlLoader { public: /** * @js NA * @lua NA */ virtual ~ControlButtonLoader() {}; /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ControlButtonLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::extension::ControlButton); virtual void onHandlePropTypeCheck(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader); virtual void onHandlePropTypeString(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char * pString, CCBReader * ccbReader); virtual void onHandlePropTypeFontTTF(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader); virtual void onHandlePropTypeFloatScale(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader); virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Point pPoint, CCBReader * ccbReader); virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader); virtual void onHandlePropTypeSpriteFrame(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::SpriteFrame * pSpriteFrame, CCBReader * ccbReader); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCControlLoader.cpp ================================================ #include "CCControlLoader.h" using namespace cocos2d; using namespace cocos2d::extension; namespace cocosbuilder { #define PROPERTY_ENABLED "enabled" #define PROPERTY_SELECTED "selected" #define PROPERTY_CCCONTROL "ccControl" void ControlLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_ENABLED) == 0) { ((Control *)pNode)->setEnabled(pCheck); } else if(strcmp(pPropertyName, PROPERTY_SELECTED) == 0) { ((Control *)pNode)->setSelected(pCheck); } else { NodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader); } } void ControlLoader::onHandlePropTypeBlockControl(Node * pNode, Node * pParent, const char * pPropertyName, BlockControlData * pBlockControlData, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_CCCONTROL) == 0) { ((Control *)pNode)->addTargetWithActionForControlEvents(pBlockControlData->_target, pBlockControlData->mSELControlHandler, pBlockControlData->mControlEvents); } else { NodeLoader::onHandlePropTypeBlockControl(pNode, pParent, pPropertyName, pBlockControlData, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCControlLoader.h ================================================ #ifndef _CCB_CCCONTROLLOADER_H_ #define _CCB_CCCONTROLLOADER_H_ #include "CCNodeLoader.h" #include "extensions/GUI/CCControlExtension/CCControl.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class ControlLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~ControlLoader() {}; protected: CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::extension::Control); virtual void onHandlePropTypeBlockControl(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, BlockControlData * pBlockControlData, CCBReader * ccbReader); virtual void onHandlePropTypeCheck(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLabelBMFontLoader.cpp ================================================ #include "CCLabelBMFontLoader.h" using namespace cocos2d; namespace cocosbuilder { #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" #define PROPERTY_FNTFILE "fntFile" #define PROPERTY_STRING "string" void LabelBMFontLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((LabelBMFont *)pNode)->setColor(pColor3B); } else { NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); } } void LabelBMFontLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((LabelBMFont *)pNode)->setOpacity(pByte); } else { NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader); } } void LabelBMFontLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((LabelBMFont *)pNode)->setBlendFunc(pBlendFunc); } else { NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader); } } void LabelBMFontLoader::onHandlePropTypeFntFile(Node * pNode, Node * pParent, const char * pPropertyName, const char* pFntFile, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_FNTFILE) == 0) { ((LabelBMFont *)pNode)->setFntFile(pFntFile); } else { NodeLoader::onHandlePropTypeFntFile(pNode, pParent, pPropertyName, pFntFile, ccbReader); } } void LabelBMFontLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char* pText, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { ((LabelBMFont *)pNode)->setString(pText); } else { NodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLabelBMFontLoader.h ================================================ #ifndef _CCB_CCLABELBMFONTLOADER_H_ #define _CCB_CCLABELBMFONTLOADER_H_ #include "CCObject.h" #include "CCLabelBMFont.h" #include "CCNodeLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class LabelBMFontLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~LabelBMFontLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LabelBMFontLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::LabelBMFont); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader); virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader); virtual void onHandlePropTypeFntFile(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char* pFntFile, CCBReader * ccbReader); virtual void onHandlePropTypeText(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char* pText, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLabelTTFLoader.cpp ================================================ #include "CCLabelTTFLoader.h" using namespace cocos2d; #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" #define PROPERTY_FONTNAME "fontName" #define PROPERTY_FONTSIZE "fontSize" #define PROPERTY_HORIZONTALALIGNMENT "horizontalAlignment" #define PROPERTY_VERTICALALIGNMENT "verticalAlignment" #define PROPERTY_STRING "string" #define PROPERTY_DIMENSIONS "dimensions" namespace cocosbuilder { void LabelTTFLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((LabelTTF *)pNode)->setColor(pColor3B); } else { NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); } } void LabelTTFLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((LabelTTF *)pNode)->setOpacity(pByte); } else { NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader); } } void LabelTTFLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((LabelTTF *)pNode)->setBlendFunc(pBlendFunc); } else { NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader); } } void LabelTTFLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_FONTNAME) == 0) { ((LabelTTF *)pNode)->setFontName(pFontTTF); } else { NodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, ccbReader); } } void LabelTTFLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char * pText, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { ((LabelTTF *)pNode)->setString(pText); } else { NodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, ccbReader); } } void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_FONTSIZE) == 0) { ((LabelTTF *)pNode)->setFontSize(pFloatScale); } else { NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, ccbReader); } } void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { ((LabelTTF *)pNode)->setHorizontalAlignment(TextHAlignment(pIntegerLabeled)); } else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { ((LabelTTF *)pNode)->setVerticalAlignment(TextVAlignment(pIntegerLabeled)); } else { NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, ccbReader); } } void LabelTTFLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_DIMENSIONS) == 0) { ((LabelTTF *)pNode)->setDimensions(pSize); } else { NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLabelTTFLoader.h ================================================ #ifndef _CCB_CCLABELTTFLOADER_H_ #define _CCB_CCLABELTTFLOADER_H_ #include "CCObject.h" #include "CCLabelTTF.h" #include "CCNodeLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class LabelTTFLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~LabelTTFLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LabelTTFLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::LabelTTF); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader); virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader); virtual void onHandlePropTypeFontTTF(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader); virtual void onHandlePropTypeText(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char * pText, CCBReader * ccbReader); virtual void onHandlePropTypeFloatScale(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader); virtual void onHandlePropTypeIntegerLabeled(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader); virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLayerColorLoader.cpp ================================================ #include "CCLayerColorLoader.h" using namespace cocos2d; namespace cocosbuilder { #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" void LayerColorLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((LayerColor *)pNode)->setColor(pColor3B); } else { LayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); } } void LayerColorLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((LayerColor *)pNode)->setOpacity(pByte); } else { LayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader); } } void LayerColorLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((LayerColor *)pNode)->setBlendFunc(pBlendFunc); } else { LayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLayerColorLoader.h ================================================ #ifndef _CCB_CCLAYERCOLORLOADER_H_ #define _CCB_CCLAYERCOLORLOADER_H_ #include "CCLayerLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class LayerColorLoader : public LayerLoader { public: /** * @js NA * @lua NA */ virtual ~LayerColorLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LayerColorLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::LayerColor); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader); virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.cpp ================================================ #include "CCLayerGradientLoader.h" using namespace cocos2d; #define PROPERTY_STARTCOLOR "startColor" #define PROPERTY_ENDCOLOR "endColor" #define PROPERTY_STARTOPACITY "startOpacity" #define PROPERTY_ENDOPACITY "endOpacity" #define PROPERTY_VECTOR "vector" #define PROPERTY_BLENDFUNC "blendFunc" namespace cocosbuilder { void LayerGradientLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) { ((LayerGradient *)pNode)->setStartColor(pColor3B); } else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) { ((LayerGradient *)pNode)->setEndColor(pColor3B); } else { LayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); } } void LayerGradientLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_STARTOPACITY) == 0) { ((LayerGradient *)pNode)->setStartOpacity(pByte); } else if(strcmp(pPropertyName, PROPERTY_ENDOPACITY) == 0) { ((LayerGradient *)pNode)->setEndOpacity(pByte); } else { LayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader); } } void LayerGradientLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((LayerGradient *)pNode)->setBlendFunc(pBlendFunc); } else { LayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader); } } void LayerGradientLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) { ((LayerGradient *)pNode)->setVector(pPoint); // TODO Not passed along the ccbi file. // ((LayerGradient *)pNode)->setCompressedInterpolation(true); } else { LayerLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLayerGradientLoader.h ================================================ #ifndef _CCB_CCLAYERGRADIENTLOADER_H_ #define _CCB_CCLAYERGRADIENTLOADER_H_ #include "CCLayerLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class LayerGradientLoader : public LayerLoader { public: /** * @js NA * @lua NA */ virtual ~LayerGradientLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LayerGradientLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::LayerGradient); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader); virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Point pPoint, CCBReader * ccbReader); virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLayerLoader.cpp ================================================ #include "CCLayerLoader.h" using namespace cocos2d; #define PROPERTY_TOUCH_ENABLED "isTouchEnabled" #define PROPERTY_ACCELEROMETER_ENABLED "isAccelerometerEnabled" #define PROPERTY_MOUSE_ENABLED "isMouseEnabled" #define PROPERTY_KEYBOARD_ENABLED "isKeyboardEnabled" #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (push) #pragma warning (disable: 4996) #endif using namespace cocos2d; namespace cocosbuilder { void LayerLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_TOUCH_ENABLED) == 0) { ((Layer *)pNode)->setTouchEnabled(pCheck); } else if(strcmp(pPropertyName, PROPERTY_ACCELEROMETER_ENABLED) == 0) { ((Layer *)pNode)->setAccelerometerEnabled(pCheck); } else if(strcmp(pPropertyName, PROPERTY_MOUSE_ENABLED) == 0) { // TODO XXX CCLOG("The property '%s' is not supported!", PROPERTY_MOUSE_ENABLED); } else if(strcmp(pPropertyName, PROPERTY_KEYBOARD_ENABLED) == 0) { // TODO XXX CCLOG("The property '%s' is not supported!", PROPERTY_KEYBOARD_ENABLED); // This comes closest: ((Layer *)pNode)->setKeypadEnabled(pCheck); } else { NodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader); } } } #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic warning "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher #pragma warning (pop) #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCLayerLoader.h ================================================ #ifndef _CCB_CCLAYERLOADER_H_ #define _CCB_CCLAYERLOADER_H_ #include "CCNodeLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class LayerLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~LayerLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LayerLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::Layer); virtual void onHandlePropTypeCheck(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCMenuItemImageLoader.cpp ================================================ #include "CCMenuItemImageLoader.h" using namespace cocos2d; #define PROPERTY_NORMALDISPLAYFRAME "normalSpriteFrame" #define PROPERTY_SELECTEDDISPLAYFRAME "selectedSpriteFrame" #define PROPERTY_DISABLEDDISPLAYFRAME "disabledSpriteFrame" namespace cocosbuilder { void MenuItemImageLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) { if(pSpriteFrame != NULL) { ((MenuItemImage *)pNode)->setNormalSpriteFrame(pSpriteFrame); } } else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) { if(pSpriteFrame != NULL) { ((MenuItemImage *)pNode)->setSelectedSpriteFrame(pSpriteFrame); } } else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) { if(pSpriteFrame != NULL) { ((MenuItemImage *)pNode)->setDisabledSpriteFrame(pSpriteFrame); } } else { MenuItemLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCMenuItemImageLoader.h ================================================ #ifndef _CCB_CCMENUITEMIMAGELOADER_H_ #define _CCB_CCMENUITEMIMAGELOADER_H_ #include "CCMenuItemLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class MenuItemImageLoader : public MenuItemLoader { public: /** * @js NA * @lua NA */ virtual ~MenuItemImageLoader() {}; /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(MenuItemImageLoader, loader); protected: /** * @js NA * @lua NA */ CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::MenuItemImage); /** * @js NA * @lua NA */ virtual void onHandlePropTypeSpriteFrame(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::SpriteFrame * pSpriteFrame, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCMenuItemLoader.cpp ================================================ #include "CCMenuItemLoader.h" using namespace cocos2d; #define PROPERTY_BLOCK "block" #define PROPERTY_ISENABLED "isEnabled" namespace cocosbuilder { void MenuItemLoader::onHandlePropTypeBlock(Node * pNode, Node * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) { if (NULL != pBlockData) // Add this condition to allow MenuItemImage without target/selector predefined { ((MenuItem *)pNode)->setCallback( std::bind( pBlockData->mSELMenuHandler, pBlockData->_target, std::placeholders::_1) ); // ((MenuItem *)pNode)->setTarget(pBlockData->_target, pBlockData->mSELMenuHandler); } } else { NodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, ccbReader); } } void MenuItemLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) { ((MenuItem *)pNode)->setEnabled(pCheck); } else { NodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCMenuItemLoader.h ================================================ #ifndef _CCB_CCMENUITEMLOADER_H_ #define _CCB_CCMENUITEMLOADER_H_ #include "CCObject.h" #include "CCMenuItem.h" #include "CCLayerLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class MenuItemLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~MenuItemLoader() {}; protected: /** * @js NA * @lua NA */ CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::MenuItem); /** * @js NA * @lua NA */ virtual void onHandlePropTypeBlock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeCheck(cocos2d::Node * pNode,cocos2d:: Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCMenuLoader.h ================================================ #ifndef _CCB_CCMENULOADER_H_ #define _CCB_CCMENULOADER_H_ #include "CCLayerLoader.h" #include "CCObject.h" #include "CCMenu.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class MenuLoader : public LayerLoader { public: /** * @js NA * @lua NA */ virtual ~MenuLoader() {}; /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(MenuLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::Menu); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.cpp ================================================ #include "CCNode+CCBRelativePositioning.h" #include "CCBReader.h" using namespace cocos2d; namespace cocosbuilder { Point getAbsolutePosition(const Point &pt, CCBReader::PositionType type, const Size &containerSize, const std::string& propName) { Point absPt = Point(0,0); if (type == CCBReader::PositionType::RELATIVE_BOTTOM_LEFT) { absPt = pt; } else if (type == CCBReader::PositionType::RELATIVE_TOP_LEFT) { absPt.x = pt.x; absPt.y = containerSize.height - pt.y; } else if (type == CCBReader::PositionType::RELATIVE_TOP_RIGHT) { absPt.x = containerSize.width - pt.x; absPt.y = containerSize.height - pt.y; } else if (type == CCBReader::PositionType::RELATIVE_BOTTOM_RIGHT) { absPt.x = containerSize.width - pt.x; absPt.y = pt.y; } else if (type == CCBReader::PositionType::PERCENT) { absPt.x = (int)(containerSize.width * pt.x / 100.0f); absPt.y = (int)(containerSize.height * pt.y / 100.0f); } else if (type == CCBReader::PositionType::MULTIPLY_RESOLUTION) { float resolutionScale = CCBReader::getResolutionScale(); absPt.x = pt.x * resolutionScale; absPt.y = pt.y * resolutionScale; } return absPt; } void setRelativeScale(Node *pNode, float scaleX, float scaleY, CCBReader::ScaleType type, const std::string& propName) { CCASSERT(pNode, "pNode should not be null"); if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION) { float resolutionScale = CCBReader::getResolutionScale(); scaleX *= resolutionScale; scaleY *= resolutionScale; } pNode->setScaleX(scaleX); pNode->setScaleY(scaleY); } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCNode+CCBRelativePositioning.h ================================================ #ifndef __CCB_CCNODE_RELATIVEPOSITIONING_H__ #define __CCB_CCNODE_RELATIVEPOSITIONING_H__ #include "CCBReader.h" namespace cocosbuilder { extern cocos2d::Point getAbsolutePosition(const cocos2d::Point &pt, CCBReader::PositionType type, const cocos2d::Size &containerSize, const std::string&propName); extern void setRelativeScale(cocos2d::Node *node, float scaleX, float scaleY, CCBReader::ScaleType type, const std::string& propName); } #endif // __CCB_CCNODE_RELATIVEPOSITIONING_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp ================================================ #include "cocos2d.h" #include "CCNodeLoader.h" #include "CCBSelectorResolver.h" #include "CCBMemberVariableAssigner.h" #include "CCBAnimationManager.h" #include "CCNode+CCBRelativePositioning.h" using namespace std; using namespace cocos2d; using namespace cocos2d::extension; namespace cocosbuilder { NodeLoader::NodeLoader() { } NodeLoader::~NodeLoader() { } ValueMap& NodeLoader::getCustomProperties() { return _customProperties; } Node * NodeLoader::loadNode(Node * pParent, CCBReader * ccbReader) { Node * ccNode = this->createNode(pParent, ccbReader); //clear _customProperties, ready for load next node. _customProperties.clear(); return ccNode; } void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbReader) { int numRegularProps = ccbReader->readInt(false); int numExturaProps = ccbReader->readInt(false); int propertyCount = numRegularProps + numExturaProps; for(int i = 0; i < propertyCount; i++) { bool isExtraProp = (i >= numRegularProps); CCBReader::PropertyType type = (CCBReader::PropertyType)ccbReader->readInt(false); std::string propertyName = ccbReader->readCachedString(); // Check if the property can be set for this platform bool setProp = false; CCBReader::PlatformType platform = (CCBReader::PlatformType)ccbReader->readByte(); if(platform == CCBReader::PlatformType::ALL) { setProp = true; } // Cocos2d-x is using touch event callback for all platforms, // it's different from cocos2d-iphone which uses mouse event for Mac port. // So we just need to touch event by using CCBReader::PlatformType::IOS. //#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) if(platform == CCBReader::PlatformType::IOS) { setProp = true; } // #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) // if(platform == CCBReader::PlatformType::MAC) // { // setProp = true; // } // #endif // Forward properties for sub ccb files if (dynamic_cast(pNode) != NULL) { CCBFile *ccbNode = (CCBFile*)pNode; if (ccbNode->getCCBFileNode() && isExtraProp) { pNode = ccbNode->getCCBFileNode(); // Skip properties that doesn't have a value to override Array *extraPropsNames = (Array*)pNode->getUserObject(); Object* pObj = NULL; bool bFound = false; CCARRAY_FOREACH(extraPropsNames, pObj) { String* pStr = static_cast(pObj); if (0 == pStr->compare(propertyName.c_str())) { bFound = true; break; } } setProp &= bFound; } } else if (isExtraProp && pNode == ccbReader->getAnimationManager()->getRootNode()) { Array *extraPropsNames = static_cast(pNode->getUserObject()); if (! extraPropsNames) { extraPropsNames = Array::create(); pNode->setUserObject(extraPropsNames); } extraPropsNames->addObject(String::create(propertyName)); } switch(type) { case CCBReader::PropertyType::POSITION: { Point position = this->parsePropTypePosition(pNode, pParent, ccbReader, propertyName.c_str()); if (setProp) { this->onHandlePropTypePosition(pNode, pParent, propertyName.c_str(), position, ccbReader); } break; } case CCBReader::PropertyType::POINT: { Point point = this->parsePropTypePoint(pNode, pParent, ccbReader); if (setProp) { this->onHandlePropTypePoint(pNode, pParent, propertyName.c_str(), point, ccbReader); } break; } case CCBReader::PropertyType::POINT_LOCK: { Point pointLock = this->parsePropTypePointLock(pNode, pParent, ccbReader); if (setProp) { this->onHandlePropTypePointLock(pNode, pParent, propertyName.c_str(), pointLock, ccbReader); } break; } case CCBReader::PropertyType::SIZE: { Size size = this->parsePropTypeSize(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeSize(pNode, pParent, propertyName.c_str(), size, ccbReader); } break; } case CCBReader::PropertyType::SCALE_LOCK: { float * scaleLock = this->parsePropTypeScaleLock(pNode, pParent, ccbReader, propertyName.c_str()); if(setProp) { this->onHandlePropTypeScaleLock(pNode, pParent, propertyName.c_str(), scaleLock, ccbReader); } CC_SAFE_DELETE_ARRAY(scaleLock); break; } case CCBReader::PropertyType::FLOAT: { float f = this->parsePropTypeFloat(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeFloat(pNode, pParent, propertyName.c_str(), f, ccbReader); } break; } case CCBReader::PropertyType::FLOAT_XY: { float * xy = this->parsePropTypeFloatXY(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeFloatXY(pNode, pParent, propertyName.c_str(), xy, ccbReader); } CC_SAFE_DELETE_ARRAY(xy); break; } case CCBReader::PropertyType::DEGREES: { float degrees = this->parsePropTypeDegrees(pNode, pParent, ccbReader, propertyName.c_str()); if(setProp) { this->onHandlePropTypeDegrees(pNode, pParent, propertyName.c_str(), degrees, ccbReader); } break; } case CCBReader::PropertyType::FLOAT_SCALE: { float floatScale = this->parsePropTypeFloatScale(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeFloatScale(pNode, pParent, propertyName.c_str(), floatScale, ccbReader); } break; } case CCBReader::PropertyType::INTEGER: { int integer = this->parsePropTypeInteger(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeInteger(pNode, pParent, propertyName.c_str(), integer, ccbReader); } break; } case CCBReader::PropertyType::INTEGER_LABELED: { int integerLabeled = this->parsePropTypeIntegerLabeled(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeIntegerLabeled(pNode, pParent, propertyName.c_str(), integerLabeled, ccbReader); } break; } case CCBReader::PropertyType::FLOAT_VAR: { float * floatVar = this->parsePropTypeFloatVar(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeFloatVar(pNode, pParent, propertyName.c_str(), floatVar, ccbReader); } CC_SAFE_DELETE_ARRAY(floatVar); break; } case CCBReader::PropertyType::CHECK: { bool check = this->parsePropTypeCheck(pNode, pParent, ccbReader, propertyName.c_str()); if(setProp) { this->onHandlePropTypeCheck(pNode, pParent, propertyName.c_str(), check, ccbReader); } break; } case CCBReader::PropertyType::SPRITEFRAME: { SpriteFrame * ccSpriteFrame = this->parsePropTypeSpriteFrame(pNode, pParent, ccbReader, propertyName.c_str()); if(setProp) { this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName.c_str(), ccSpriteFrame, ccbReader); } break; } case CCBReader::PropertyType::ANIMATION: { Animation * ccAnimation = this->parsePropTypeAnimation(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeAnimation(pNode, pParent, propertyName.c_str(), ccAnimation, ccbReader); } break; } case CCBReader::PropertyType::TEXTURE: { Texture2D * ccTexture2D = this->parsePropTypeTexture(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeTexture(pNode, pParent, propertyName.c_str(), ccTexture2D, ccbReader); } break; } case CCBReader::PropertyType::BYTE: { unsigned char byte = this->parsePropTypeByte(pNode, pParent, ccbReader, propertyName.c_str()); if(setProp) { this->onHandlePropTypeByte(pNode, pParent, propertyName.c_str(), byte, ccbReader); } break; } case CCBReader::PropertyType::COLOR3: { Color3B color3B = this->parsePropTypeColor3(pNode, pParent, ccbReader, propertyName.c_str()); if(setProp) { this->onHandlePropTypeColor3(pNode, pParent, propertyName.c_str(), color3B, ccbReader); } break; } case CCBReader::PropertyType::COLOR4F_VAR: { Color4F * color4FVar = this->parsePropTypeColor4FVar(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName.c_str(), color4FVar, ccbReader); } CC_SAFE_DELETE_ARRAY(color4FVar); break; } case CCBReader::PropertyType::FLIP: { bool * flip = this->parsePropTypeFlip(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeFlip(pNode, pParent, propertyName.c_str(), flip, ccbReader); } CC_SAFE_DELETE_ARRAY(flip); break; } case CCBReader::PropertyType::BLEND_MODE: { BlendFunc blendFunc = this->parsePropTypeBlendFunc(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeBlendFunc(pNode, pParent, propertyName.c_str(), blendFunc, ccbReader); } break; } case CCBReader::PropertyType::FNT_FILE: { std::string fntFile = ccbReader->getCCBRootPath() + this->parsePropTypeFntFile(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeFntFile(pNode, pParent, propertyName.c_str(), fntFile.c_str(), ccbReader); } break; } case CCBReader::PropertyType::FONT_TTF: { std::string fontTTF = this->parsePropTypeFontTTF(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeFontTTF(pNode, pParent, propertyName.c_str(), fontTTF.c_str(), ccbReader); } break; } case CCBReader::PropertyType::STRING: { std::string string = this->parsePropTypeString(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeString(pNode, pParent, propertyName.c_str(), string.c_str(), ccbReader); } break; } case CCBReader::PropertyType::TEXT: { std::string text = this->parsePropTypeText(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeText(pNode, pParent, propertyName.c_str(), text.c_str(), ccbReader); } break; } case CCBReader::PropertyType::BLOCK: { BlockData * blockData = this->parsePropTypeBlock(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeBlock(pNode, pParent, propertyName.c_str(), blockData, ccbReader); } CC_SAFE_DELETE(blockData); break; } case CCBReader::PropertyType::BLOCK_CONTROL: { BlockControlData * blockControlData = this->parsePropTypeBlockControl(pNode, pParent, ccbReader); if(setProp && blockControlData != NULL) { this->onHandlePropTypeBlockControl(pNode, pParent, propertyName.c_str(), blockControlData, ccbReader); } CC_SAFE_DELETE(blockControlData); break; } case CCBReader::PropertyType::CCB_FILE: { Node * ccbFileNode = this->parsePropTypeCCBFile(pNode, pParent, ccbReader); if(setProp) { this->onHandlePropTypeCCBFile(pNode, pParent, propertyName.c_str(), ccbFileNode, ccbReader); } break; } default: ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(type); break; } } } Point NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) { float x = ccbReader->readFloat(); float y = ccbReader->readFloat(); CCBReader::PositionType type = static_cast(ccbReader->readInt(false)); Size containerSize = ccbReader->getAnimationManager()->getContainerSize(pParent); Point pt = getAbsolutePosition(Point(x,y), type, containerSize, pPropertyName); pNode->setPosition(pt); if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end()) { ValueVector vec; vec.push_back(Value(x)); vec.push_back(Value(y)); vec.push_back(Value((int)type)); ccbReader->getAnimationManager()->setBaseValue(Value(vec), pNode, pPropertyName); } return pt; } Point NodeLoader::parsePropTypePoint(Node * pNode, Node * pParent, CCBReader * ccbReader) { float x = ccbReader->readFloat(); float y = ccbReader->readFloat(); return Point(x, y); } Point NodeLoader::parsePropTypePointLock(Node * pNode, Node * pParent, CCBReader * ccbReader) { float x = ccbReader->readFloat(); float y = ccbReader->readFloat(); return Point(x, y); } Size NodeLoader::parsePropTypeSize(Node * pNode, Node * pParent, CCBReader * ccbReader) { float width = ccbReader->readFloat(); float height = ccbReader->readFloat(); CCBReader::SizeType type = static_cast(ccbReader->readInt(false)); Size containerSize = ccbReader->getAnimationManager()->getContainerSize(pParent); switch (type) { case CCBReader::SizeType::ABSOLUTE: { /* Nothing. */ break; } case CCBReader::SizeType::RELATIVE_CONTAINER: { width = containerSize.width - width; height = containerSize.height - height; break; } case CCBReader::SizeType::PERCENT: { width = (int)(containerSize.width * width / 100.0f); height = (int)(containerSize.height * height / 100.0f); break; } case CCBReader::SizeType::HORIZONTAL_PERCENT: { width = (int)(containerSize.width * width / 100.0f); break; } case CCBReader::SizeType::VERTICAL_PERCENT: { height = (int)(containerSize.height * height / 100.0f); break; } case CCBReader::SizeType::MULTIPLY_RESOLUTION: { float resolutionScale = CCBReader::getResolutionScale(); width *= resolutionScale; height *= resolutionScale; break; } default: { log("Unknown CCB type."); } break; } return Size(width, height); } float * NodeLoader::parsePropTypeFloatXY(Node * pNode, Node * pParent, CCBReader * ccbReader) { float x = ccbReader->readFloat(); float y = ccbReader->readFloat(); float * floatXY = new float[2]; floatXY[0] = x; floatXY[1] = y; return floatXY; } float * NodeLoader::parsePropTypeScaleLock(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) { float x = ccbReader->readFloat(); float y = ccbReader->readFloat(); CCBReader::ScaleType type = static_cast(ccbReader->readInt(false)); setRelativeScale(pNode, x, y, type, pPropertyName); if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end()) { ValueVector baseValue; baseValue.push_back(Value(x)); baseValue.push_back(Value(y)); baseValue.push_back(Value((int)type)); ccbReader->getAnimationManager()->setBaseValue(Value(baseValue), pNode, pPropertyName); } if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION) { x *= ccbReader->getResolutionScale(); y *= ccbReader->getResolutionScale(); } float * scaleLock = new float[2]; scaleLock[0] = x; scaleLock[1] = y; return scaleLock; } float NodeLoader::parsePropTypeFloat(Node * pNode, Node * pParent, CCBReader * ccbReader) { return ccbReader->readFloat(); } float NodeLoader::parsePropTypeDegrees(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) { float ret = ccbReader->readFloat(); if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end()) { ccbReader->getAnimationManager()->setBaseValue(Value(ret), pNode, pPropertyName); } return ret; } float NodeLoader::parsePropTypeFloatScale(Node * pNode, Node * pParent, CCBReader * ccbReader) { float f = ccbReader->readFloat(); CCBReader::ScaleType type = static_cast(ccbReader->readInt(false)); if(type == CCBReader::ScaleType::MULTIPLY_RESOLUTION) { f *= ccbReader->getResolutionScale(); } return f; } int NodeLoader::parsePropTypeInteger(Node * pNode, Node * pParent, CCBReader * ccbReader) { return ccbReader->readInt(true); } int NodeLoader::parsePropTypeIntegerLabeled(Node * pNode, Node * pParent, CCBReader * ccbReader) { return ccbReader->readInt(true); } float * NodeLoader::parsePropTypeFloatVar(Node * pNode, Node * pParent, CCBReader * ccbReader) { float f = ccbReader->readFloat(); float fVar = ccbReader->readFloat(); float * arr = new float[2]; arr[0] = f; arr[1] = fVar; return arr; } bool NodeLoader::parsePropTypeCheck(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) { bool ret = ccbReader->readBool(); if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end()) { ccbReader->getAnimationManager()->setBaseValue(Value(ret), pNode, pPropertyName); } return ret; } SpriteFrame * NodeLoader::parsePropTypeSpriteFrame(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) { std::string spriteSheet = ccbReader->readCachedString(); std::string spriteFile = ccbReader->readCachedString(); SpriteFrame *spriteFrame = NULL; if (spriteFile.length() != 0) { if (spriteSheet.length() == 0) { spriteFile = ccbReader->getCCBRootPath() + spriteFile; Texture2D * texture = Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); if(texture != NULL) { Rect bounds = Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = SpriteFrame::createWithTexture(texture, bounds); } } else { SpriteFrameCache * frameCache = SpriteFrameCache::getInstance(); spriteSheet = ccbReader->getCCBRootPath() + spriteSheet; // Load the sprite sheet only if it is not loaded if (ccbReader->getLoadedSpriteSheet().find(spriteSheet) == ccbReader->getLoadedSpriteSheet().end()) { frameCache->addSpriteFramesWithFile(spriteSheet.c_str()); ccbReader->getLoadedSpriteSheet().insert(spriteSheet); } spriteFrame = frameCache->getSpriteFrameByName(spriteFile.c_str()); } if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end()) { ccbReader->getAnimationManager()->setObject(spriteFrame, pNode, pPropertyName); } } return spriteFrame; } Animation * NodeLoader::parsePropTypeAnimation(Node * pNode, Node * pParent, CCBReader * ccbReader) { std::string animationFile = ccbReader->getCCBRootPath() + ccbReader->readCachedString(); std::string animation = ccbReader->readCachedString(); Animation * ccAnimation = NULL; // Support for stripping relative file paths, since ios doesn't currently // know what to do with them, since its pulling from bundle. // Eventually this should be handled by a client side asset manager // interface which figured out what resources to load. // TODO Does this problem exist in C++? animation = CCBReader::lastPathComponent(animation.c_str()); animationFile = CCBReader::lastPathComponent(animationFile.c_str()); if (animation.length() > 0) { AnimationCache * animationCache = AnimationCache::getInstance(); animationCache->addAnimationsWithFile(animationFile.c_str()); ccAnimation = animationCache->getAnimation(animation.c_str()); } return ccAnimation; } Texture2D * NodeLoader::parsePropTypeTexture(Node * pNode, Node * pParent, CCBReader * ccbReader) { std::string spriteFile = ccbReader->getCCBRootPath() + ccbReader->readCachedString(); if (spriteFile.length() > 0) { return Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); } else { return NULL; } } unsigned char NodeLoader::parsePropTypeByte(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) { unsigned char ret = ccbReader->readByte(); if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end()) { ccbReader->getAnimationManager()->setBaseValue(Value(ret), pNode, pPropertyName); } return ret; } Color3B NodeLoader::parsePropTypeColor3(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) { unsigned char r = ccbReader->readByte(); unsigned char g = ccbReader->readByte(); unsigned char b = ccbReader->readByte(); Color3B color(r, g, b); ValueMap colorMap; colorMap["r"] = r; colorMap["g"] = g; colorMap["b"] = b; if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end()) { ccbReader->getAnimationManager()->setBaseValue(Value(colorMap), pNode, pPropertyName); } return color; } Color4F * NodeLoader::parsePropTypeColor4FVar(Node * pNode, Node * pParent, CCBReader * ccbReader) { float red = ccbReader->readFloat(); float green = ccbReader->readFloat(); float blue = ccbReader->readFloat(); float alpha = ccbReader->readFloat(); float redVar = ccbReader->readFloat(); float greenVar = ccbReader->readFloat(); float blueVar = ccbReader->readFloat(); float alphaVar = ccbReader->readFloat(); Color4F * colors = new Color4F[2]; colors[0].r = red; colors[0].g = green; colors[0].b = blue; colors[0].a = alpha; colors[1].r = redVar; colors[1].g = greenVar; colors[1].b = blueVar; colors[1].a = alphaVar; return colors; } bool * NodeLoader::parsePropTypeFlip(Node * pNode, Node * pParent, CCBReader * ccbReader) { bool flipX = ccbReader->readBool(); bool flipY = ccbReader->readBool(); bool * arr = new bool[2]; arr[0] = flipX; arr[1] = flipY; return arr; } BlendFunc NodeLoader::parsePropTypeBlendFunc(Node * pNode, Node * pParent, CCBReader * ccbReader) { int source = ccbReader->readInt(false); int destination = ccbReader->readInt(false); BlendFunc blendFunc; blendFunc.src = source; blendFunc.dst = destination; return blendFunc; } std::string NodeLoader::parsePropTypeFntFile(Node * pNode, Node * pParent, CCBReader * ccbReader) { return ccbReader->readCachedString(); } std::string NodeLoader::parsePropTypeString(Node * pNode, Node * pParent, CCBReader * ccbReader) { return ccbReader->readCachedString(); } std::string NodeLoader::parsePropTypeText(Node * pNode, Node * pParent, CCBReader * ccbReader) { return ccbReader->readCachedString(); } std::string NodeLoader::parsePropTypeFontTTF(Node * pNode, Node * pParent, CCBReader * ccbReader) { std::string fontTTF = ccbReader->readCachedString(); // String * ttfEnding = String::create(".ttf"); // TODO Fix me if it is wrong /* If the fontTTF comes with the ".ttf" extension, prepend the absolute path. * System fonts come without the ".ttf" extension and do not need the path prepended. */ /* if(CCBReader::endsWith(CCBReader::toLowerCase(fontTTF), ttfEnding)){ fontTTF = CCBReader::concat(ccbReader->getCCBRootPath(), fontTTF); } */ return fontTTF; } BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBReader * ccbReader) { std::string selectorName = ccbReader->readCachedString(); CCBReader::TargetType selectorTarget = static_cast(ccbReader->readInt(false)); if(selectorTarget != CCBReader::TargetType::NONE) { Object * target = NULL; if(!ccbReader->isJSControlled()) { if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) { target = ccbReader->getAnimationManager()->getRootNode(); } else if(selectorTarget == CCBReader::TargetType::OWNER) { target = ccbReader->getOwner(); } if(target != NULL) { if(selectorName.length() > 0) { SEL_MenuHandler selMenuHandler = 0; CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != NULL) { selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str()); } if(selMenuHandler == 0) { CCBSelectorResolver * ccbSelectorResolver = ccbReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str()); } } if(selMenuHandler == 0) { CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); } else { BlockData * blockData = new BlockData(); blockData->mSELMenuHandler = selMenuHandler; blockData->_target = target; return blockData; } } else { CCLOG("Unexpected empty selector."); } } else { CCLOG("Unexpected NULL target for selector."); } } else { if (selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) { ccbReader->addDocumentCallbackNode(pNode); ccbReader->addDocumentCallbackName(selectorName); // Since there isn't a Control::EventType::NONE, add a TOUCH_DOWN type as a placeholder. ccbReader->addDocumentCallbackControlEvents(Control::EventType::TOUCH_DOWN); } else if (selectorTarget == CCBReader::TargetType::OWNER) { ccbReader->addOwnerCallbackNode(pNode); ccbReader->addOwnerCallbackName(selectorName); // Since there isn't a Control::EventType::NONE, add a TOUCH_DOWN type as a placeholder. ccbReader->addOwnerCallbackControlEvents(Control::EventType::TOUCH_DOWN); } } } return NULL; } BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pParent, CCBReader * ccbReader) { std::string selectorName = ccbReader->readCachedString(); CCBReader::TargetType selectorTarget = static_cast(ccbReader->readInt(false)); int controlEvents = ccbReader->readInt(false); if(selectorTarget != CCBReader::TargetType::NONE) { if(!ccbReader->isJSControlled()) { Object * target = NULL; if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) { target = ccbReader->getAnimationManager()->getRootNode(); } else if(selectorTarget == CCBReader::TargetType::OWNER) { target = ccbReader->getOwner(); } if(target != NULL) { if(selectorName.length() > 0) { Control::Handler selControlHandler = 0; CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != NULL) { selControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str()); } if(selControlHandler == 0) { CCBSelectorResolver * ccbSelectorResolver = ccbReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { selControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str()); } } if(selControlHandler == 0) { CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); } else { BlockControlData * blockControlData = new BlockControlData(); blockControlData->mSELControlHandler = selControlHandler; blockControlData->_target = target; blockControlData->mControlEvents = (Control::EventType)controlEvents; return blockControlData; } } else { CCLOG("Unexpected empty selector."); } } else { CCLOG("Unexpected NULL target for selector."); } } else { if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) { ccbReader->addDocumentCallbackNode(pNode); ccbReader->addDocumentCallbackName(selectorName); ccbReader->addDocumentCallbackControlEvents((Control::EventType)controlEvents); } else { ccbReader->addOwnerCallbackNode(pNode); ccbReader->addOwnerCallbackName(selectorName); ccbReader->addOwnerCallbackControlEvents((Control::EventType)controlEvents); } } } return NULL; } Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader * pCCBReader) { std::string ccbFileName = pCCBReader->getCCBRootPath() + pCCBReader->readCachedString(); /* Change path extension to .ccbi. */ std::string ccbFileWithoutPathExtension = CCBReader::deletePathExtension(ccbFileName.c_str()); ccbFileName = ccbFileWithoutPathExtension + ".ccbi"; // Load sub file std::string path = FileUtils::getInstance()->fullPathForFilename(ccbFileName.c_str()); auto dataPtr = std::make_shared(FileUtils::getInstance()->getDataFromFile(path)); CCBReader * reader = new CCBReader(pCCBReader); reader->autorelease(); reader->getAnimationManager()->setRootContainerSize(pParent->getContentSize()); reader->_data = dataPtr; reader->_bytes = dataPtr->getBytes(); reader->_currentByte = 0; reader->_currentBit = 0; CC_SAFE_RETAIN(pCCBReader->_owner); reader->_owner = pCCBReader->_owner; reader->getAnimationManager()->_owner = reader->_owner; // The assignments below are done in the CCBReader constructor. // reader->_ownerOutletNames = pCCBReader->_ownerOutletNames; // reader->_ownerOutletNodes = pCCBReader->_ownerOutletNodes; // reader->_ownerOutletNodes->retain(); // reader->_ownerCallbackNames = pCCBReader->_ownerCallbackNames; // reader->_ownerCallbackNodes = pCCBReader->_ownerCallbackNodes; // reader->_ownerCallbackNodes->retain(); Node * ccbFileNode = reader->readFileWithCleanUp(false, pCCBReader->getAnimationManagers()); if (ccbFileNode && reader->getAnimationManager()->getAutoPlaySequenceId() != -1) { // Auto play animations reader->getAnimationManager()->runAnimationsForSequenceIdTweenDuration(reader->getAnimationManager()->getAutoPlaySequenceId(), 0); } if (reader->isJSControlled() && pCCBReader->isJSControlled() && NULL == reader->_owner) { //set variables and callback to owner //set callback auto ownerCallbackNames = reader->getOwnerCallbackNames(); auto& ownerCallbackNodes = reader->getOwnerCallbackNodes(); if (!ownerCallbackNames.empty() && !ownerCallbackNodes.empty()) { CCASSERT(ownerCallbackNames.size() == ownerCallbackNodes.size(), ""); ssize_t nCount = ownerCallbackNames.size(); for (ssize_t i = 0 ; i < nCount; i++) { pCCBReader->addOwnerCallbackName(ownerCallbackNames[i].asString()); pCCBReader->addOwnerCallbackNode(ownerCallbackNodes.at(i)); } } //set variables auto ownerOutletNames = reader->getOwnerOutletNames(); auto ownerOutletNodes = reader->getOwnerOutletNodes(); if (!ownerOutletNames.empty() && !ownerOutletNodes.empty()) { CCASSERT(ownerOutletNames.size() == ownerOutletNodes.size(), ""); ssize_t nCount = ownerOutletNames.size(); for (ssize_t i = 0 ; i < nCount; i++) { pCCBReader->addOwnerOutletName(ownerOutletNames.at(i).asString()); pCCBReader->addOwnerOutletNode(ownerOutletNodes.at(i)); } } } return ccbFileNode; } void NodeLoader::onHandlePropTypePosition(Node * pNode, Node * pParent, const char* pPropertyName, Point pPosition, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_POSITION) == 0) { pNode->setPosition(pPosition); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void NodeLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char* pPropertyName, Point pPoint, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_ANCHORPOINT) == 0) { pNode->setAnchorPoint(pPoint); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void NodeLoader::onHandlePropTypePointLock(Node * pNode, Node * pParent, const char* pPropertyName, Point pPointLock, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char* pPropertyName, Size pSize, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { pNode->setContentSize(pSize); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void NodeLoader::onHandlePropTypeFloatXY(Node * pNode, Node * pParent, const char* pPropertyName, float * pFloat, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_SKEW) == 0) { pNode->setSkewX(pFloat[0]); pNode->setSkewY(pFloat[1]); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void NodeLoader::onHandlePropTypeScaleLock(Node * pNode, Node * pParent, const char* pPropertyName, float * pScaleLock, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_SCALE) == 0) { pNode->setScaleX(pScaleLock[0]); pNode->setScaleY(pScaleLock[1]); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void NodeLoader::onHandlePropTypeFloat(Node * pNode, Node * pParent, const char* pPropertyName, float pFloat, CCBReader * ccbReader) { // ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); // It may be a custom property, add it to custom property dictionary. _customProperties[pPropertyName] = Value(pFloat); } void NodeLoader::onHandlePropTypeDegrees(Node * pNode, Node * pParent, const char* pPropertyName, float pDegrees, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) { pNode->setRotation(pDegrees); } else if(strcmp(pPropertyName, PROPERTY_ROTATIONX) == 0) { pNode->setRotationX(pDegrees); } else if(strcmp(pPropertyName, PROPERTY_ROTATIONY) == 0) { pNode->setRotationY(pDegrees); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void NodeLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char* pPropertyName, float pFloatScale, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeInteger(Node * pNode, Node * pParent, const char* pPropertyName, int pInteger, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_TAG) == 0) { pNode->setTag(pInteger); } else { // ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); // It may be a custom property, add it to custom property dictionary. _customProperties[pPropertyName] = Value(pInteger); } } void NodeLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char* pPropertyName, int pIntegerLabeled, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeFloatVar(Node * pNode, Node * pParent, const char* pPropertyName, float * pFloatVar, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char* pPropertyName, bool pCheck, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_VISIBLE) == 0) { pNode->setVisible(pCheck); } else if(strcmp(pPropertyName, PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { pNode->ignoreAnchorPointForPosition(pCheck); } else { //ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); // It may be a custom property, add it to custom property dictionary. _customProperties[pPropertyName] = Value(pCheck); } } void NodeLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char* pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeAnimation(Node * pNode, Node * pParent, const char* pPropertyName, Animation * pAnimation, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeTexture(Node * pNode, Node * pParent, const char* pPropertyName, Texture2D * pTexture2D, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char* pPropertyName, unsigned char pByte, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char* pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char* pPropertyName, Color4F * pColor4FVar, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeFlip(Node * pNode, Node * pParent, const char* pPropertyName, bool * pFlip, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char* pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeFntFile(Node * pNode, Node * pParent, const char* pPropertyName, const char* pFntFile, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeString(Node * pNode, Node * pParent, const char* pPropertyName, const char * pString, CCBReader * ccbReader) { // ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); // It may be a custom property, add it to custom property dictionary. _customProperties[pPropertyName] = Value(pString); } void NodeLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const char* pPropertyName, const char * pText, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char* pPropertyName, const char * pFontTTF, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeBlock(Node * pNode, Node * pParent, const char* pPropertyName, BlockData * pBlockData, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeBlockControl(Node * pNode, Node * pParent, const char* pPropertyName, BlockControlData * pBlockControlData, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void NodeLoader::onHandlePropTypeCCBFile(Node * pNode, Node * pParent, const char* pPropertyName, Node * pCCBFileNode, CCBReader * ccbReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCNodeLoader.h ================================================ #ifndef _CCB_CCNODELOADER_H_ #define _CCB_CCNODELOADER_H_ #include "extensions/GUI/CCControlExtension/CCInvocation.h" #include "CCBReader.h" #include "extensions/GUI/CCControlExtension/CCControl.h" namespace cocosbuilder { #define PROPERTY_POSITION "position" #define PROPERTY_CONTENTSIZE "contentSize" #define PROPERTY_SKEW "skew" #define PROPERTY_ANCHORPOINT "anchorPoint" #define PROPERTY_SCALE "scale" #define PROPERTY_ROTATION "rotation" #define PROPERTY_ROTATIONX "rotationX" #define PROPERTY_ROTATIONY "rotationY" #define PROPERTY_TAG "tag" #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_VISIBLE "visible" #define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) cocos2d::log("Unexpected property: '%s'!\n", PROPERTY); assert(false) #define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) cocos2d::log("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) #define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createNode(cocos2d::Node * pParent, cocosbuilder::CCBReader * ccbReader) { \ return T::create(); \ } #define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createNode(cocos2d::Node * pParent, cocosbuilder::CCBReader * ccbReader) = 0 struct BlockData { cocos2d::SEL_MenuHandler mSELMenuHandler; cocos2d::Object * _target; }; struct BlockControlData { cocos2d::extension::Control::Handler mSELControlHandler; cocos2d::Object * _target; cocos2d::extension::Control::EventType mControlEvents; }; /* Forward declaration. */ class CCBReader; class NodeLoader : public cocos2d::Object { public: /** * @js NA * @lua NA */ NodeLoader(); /** * @js NA * @lua NA */ virtual ~NodeLoader(); /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(NodeLoader, loader); /** * @js NA * @lua NA */ virtual cocos2d::Node * loadNode(cocos2d::Node *, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void parseProperties(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual cocos2d::ValueMap& getCustomProperties(); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::Node); virtual cocos2d::Point parsePropTypePosition(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); virtual cocos2d::Point parsePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual cocos2d::Point parsePropTypePointLock(cocos2d::Node * pNode,cocos2d:: Node * pParent, CCBReader * ccbReader); virtual cocos2d::Size parsePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual float * parsePropTypeScaleLock(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); virtual float parsePropTypeFloat(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual float parsePropTypeDegrees(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); virtual float parsePropTypeFloatScale(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual int parsePropTypeInteger(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual int parsePropTypeIntegerLabeled(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual float * parsePropTypeFloatVar(cocos2d::Node * pNode,cocos2d::Node * pParent, CCBReader * ccbReader); virtual bool parsePropTypeCheck(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); virtual cocos2d::SpriteFrame * parsePropTypeSpriteFrame(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); virtual cocos2d::Animation * parsePropTypeAnimation(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual cocos2d::Texture2D * parsePropTypeTexture(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual unsigned char parsePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); virtual cocos2d::Color3B parsePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader, const char *pPropertyName); virtual cocos2d::Color4F * parsePropTypeColor4FVar(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual bool * parsePropTypeFlip(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual cocos2d::BlendFunc parsePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual std::string parsePropTypeFntFile(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual std::string parsePropTypeString(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual std::string parsePropTypeText(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual std::string parsePropTypeFontTTF(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual BlockData * parsePropTypeBlock(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual BlockControlData * parsePropTypeBlockControl(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual cocos2d::Node * parsePropTypeCCBFile(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual float * parsePropTypeFloatXY(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader); virtual void onHandlePropTypePosition(cocos2d::Node * pNode,cocos2d:: Node * pParent, const char* pPropertyName, cocos2d::Point pPosition, CCBReader * ccbReader); virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Point pPoint, CCBReader * ccbReader); virtual void onHandlePropTypePointLock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Point pPointLock, CCBReader * ccbReader); virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader); virtual void onHandlePropTypeScaleLock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float * pScaleLock, CCBReader * ccbReader); virtual void onHandlePropTypeFloat(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float pFloat, CCBReader * ccbReader); virtual void onHandlePropTypeDegrees(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float pDegrees, CCBReader * ccbReader); virtual void onHandlePropTypeFloatScale(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float pFloatScale, CCBReader * ccbReader); virtual void onHandlePropTypeInteger(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, int pInteger, CCBReader * ccbReader); virtual void onHandlePropTypeIntegerLabeled(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, int pIntegerLabeled, CCBReader * ccbReader); virtual void onHandlePropTypeFloatVar(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float * pFoatVar, CCBReader * ccbReader); virtual void onHandlePropTypeFloatXY(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float * pFoatVar, CCBReader * ccbReader); virtual void onHandlePropTypeCheck(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, bool pCheck, CCBReader * ccbReader); virtual void onHandlePropTypeSpriteFrame(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::SpriteFrame * pSpriteFrame, CCBReader * ccbReader); virtual void onHandlePropTypeAnimation(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Animation * pAnimation, CCBReader * ccbReader); virtual void onHandlePropTypeTexture(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Texture2D * pTexture2D, CCBReader * ccbReader); virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, unsigned char pByte, CCBReader * ccbReader); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); virtual void onHandlePropTypeColor4FVar(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Color4F * pColor4FVar, CCBReader * ccbReader); virtual void onHandlePropTypeFlip(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, bool * pFlip, CCBReader * ccbReader); virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader); virtual void onHandlePropTypeFntFile(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const char * pFntFile, CCBReader * ccbReader); virtual void onHandlePropTypeString(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const char * pString, CCBReader * ccbReader); virtual void onHandlePropTypeText(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const char * pText, CCBReader * ccbReader); virtual void onHandlePropTypeFontTTF(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const char * pFontTTF, CCBReader * ccbReader); virtual void onHandlePropTypeBlock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, BlockData * pBlockData, CCBReader * ccbReader); virtual void onHandlePropTypeBlockControl(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, BlockControlData * pBlockControlData, CCBReader * ccbReader); virtual void onHandlePropTypeCCBFile(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Node * pCCBFileNode, CCBReader * ccbReader); protected: cocos2d::ValueMap _customProperties; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCNodeLoaderLibrary.cpp ================================================ #include "CCNodeLoaderLibrary.h" #include "CCLayerLoader.h" #include "CCLayerColorLoader.h" #include "CCLayerGradientLoader.h" #include "CCLabelBMFontLoader.h" #include "CCLabelTTFLoader.h" #include "CCSpriteLoader.h" #include "CCScale9SpriteLoader.h" #include "CCBFileLoader.h" #include "CCMenuLoader.h" #include "CCMenuItemLoader.h" #include "CCMenuItemImageLoader.h" #include "CCControlButtonLoader.h" #include "CCParticleSystemQuadLoader.h" #include "CCScrollViewLoader.h" using namespace cocos2d; namespace cocosbuilder { NodeLoaderLibrary::NodeLoaderLibrary() { } NodeLoaderLibrary::~NodeLoaderLibrary() { this->purge(true); } void NodeLoaderLibrary::registerDefaultNodeLoaders() { this->registerNodeLoader("CCNode", NodeLoader::loader()); this->registerNodeLoader("CCLayer", LayerLoader::loader()); this->registerNodeLoader("CCLayerColor", LayerColorLoader::loader()); this->registerNodeLoader("CCLayerGradient", LayerGradientLoader::loader()); this->registerNodeLoader("CCSprite", SpriteLoader::loader()); this->registerNodeLoader("CCLabelBMFont", LabelBMFontLoader::loader()); this->registerNodeLoader("CCLabelTTF", LabelTTFLoader::loader()); this->registerNodeLoader("CCScale9Sprite", Scale9SpriteLoader::loader()); this->registerNodeLoader("CCScrollView", ScrollViewLoader::loader()); this->registerNodeLoader("CCBFile", CCBFileLoader::loader()); this->registerNodeLoader("CCMenu", MenuLoader::loader()); this->registerNodeLoader("CCMenuItemImage", MenuItemImageLoader::loader()); this->registerNodeLoader("CCControlButton", ControlButtonLoader::loader()); this->registerNodeLoader("CCParticleSystemQuad", ParticleSystemQuadLoader::loader()); } void NodeLoaderLibrary::registerNodeLoader(const char * pClassName, NodeLoader * pNodeLoader) { pNodeLoader->retain(); this->_nodeLoaders.insert(NodeLoaderMapEntry(pClassName, pNodeLoader)); } void NodeLoaderLibrary::unregisterNodeLoader(const char * pClassName) { NodeLoaderMap::iterator ccNodeLoadersIterator = this->_nodeLoaders.find(pClassName); if (ccNodeLoadersIterator != this->_nodeLoaders.end()) { ccNodeLoadersIterator->second->release(); _nodeLoaders.erase(ccNodeLoadersIterator); } else { CCLOG("The loader (%s) doesn't exist", pClassName); } } NodeLoader * NodeLoaderLibrary::getNodeLoader(const char* pClassName) { NodeLoaderMap::iterator ccNodeLoadersIterator = this->_nodeLoaders.find(pClassName); assert(ccNodeLoadersIterator != this->_nodeLoaders.end()); return ccNodeLoadersIterator->second; } void NodeLoaderLibrary::purge(bool pReleaseNodeLoaders) { if(pReleaseNodeLoaders) { for(NodeLoaderMap::iterator it = this->_nodeLoaders.begin(); it != this->_nodeLoaders.end(); it++) { it->second->release(); } } this->_nodeLoaders.clear(); } static NodeLoaderLibrary * sSharedNodeLoaderLibrary = NULL; NodeLoaderLibrary * NodeLoaderLibrary::getInstance() { if(sSharedNodeLoaderLibrary == NULL) { sSharedNodeLoaderLibrary = new NodeLoaderLibrary(); sSharedNodeLoaderLibrary->registerDefaultNodeLoaders(); } return sSharedNodeLoaderLibrary; } void NodeLoaderLibrary::destroyInstance() { CC_SAFE_DELETE(sSharedNodeLoaderLibrary); } NodeLoaderLibrary * NodeLoaderLibrary::newDefaultNodeLoaderLibrary() { NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::library(); ccNodeLoaderLibrary->registerDefaultNodeLoaders(); return ccNodeLoaderLibrary; } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCNodeLoaderLibrary.h ================================================ #ifndef _CCB_CCNODELOADERLIBRARY_H_ #define _CCB_CCNODELOADERLIBRARY_H_ #include "CCBReader.h" namespace cocosbuilder { class NodeLoader; typedef std::map NodeLoaderMap; typedef std::pair NodeLoaderMapEntry; class NodeLoaderLibrary : public cocos2d::Object { public: /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(NodeLoaderLibrary, library); /** * @js NA * @lua NA */ NodeLoaderLibrary(); /** * @js NA * @lua NA */ virtual ~NodeLoaderLibrary(); /** * @js NA * @lua NA */ void registerDefaultNodeLoaders(); /** * @js NA * @lua NA */ void registerNodeLoader(const char * pClassName, NodeLoader * pNodeLoader); //void registerNodeLoader(String * pClassName, NodeLoader * pNodeLoader); /** * @js NA * @lua NA */ void unregisterNodeLoader(const char * pClassName); //void unregisterNodeLoader(String * pClassName); /** * @js NA * @lua NA */ NodeLoader * getNodeLoader(const char * pClassName); //CCNodeLoader * getNodeLoader(String * pClassName); /** * @js NA * @lua NA */ void purge(bool pDelete); /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE void registerDefaultCCNodeLoaders() { registerDefaultNodeLoaders(); } /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE void registerCCNodeLoader(const char * pClassName, NodeLoader * pNodeLoader) { registerNodeLoader(pClassName, pNodeLoader); }; /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE void unregisterCCNodeLoader(const char * pClassName) { unregisterNodeLoader(pClassName); }; /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE NodeLoader * getCCNodeLoader(const char * pClassName) { return getNodeLoader(pClassName); }; public: /** * @js NA * @lua NA */ static NodeLoaderLibrary * getInstance(); /** * @js NA * @lua NA */ static void destroyInstance(); /** * @js NA * @lua NA */ static NodeLoaderLibrary * newDefaultNodeLoaderLibrary(); /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static NodeLoaderLibrary * sharedNodeLoaderLibrary() { return NodeLoaderLibrary::getInstance(); }; /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedNodeLoaderLibrary() { NodeLoaderLibrary::destroyInstance(); }; /** * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE static NodeLoaderLibrary * newDefaultCCNodeLoaderLibrary() { return NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); }; private: NodeLoaderMap _nodeLoaders; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCNodeLoaderListener.h ================================================ #ifndef _CCB_CCNODELOADERLISTENER_H_ #define _CCB_CCNODELOADERLISTENER_H_ namespace cocosbuilder { class NodeLoaderListener { public: /** * @js NA * @lua NA */ virtual ~NodeLoaderListener() {}; /** * @js NA * @lua NA */ virtual void onNodeLoaded(cocos2d::Node * pNode, NodeLoader * pNodeLoader) = 0; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.cpp ================================================ #include "CCParticleSystemQuadLoader.h" using namespace cocos2d; #define PROPERTY_EMITERMODE "emitterMode" #define PROPERTY_POSVAR "posVar" #define PROPERTY_EMISSIONRATE "emissionRate" #define PROPERTY_DURATION "duration" #define PROPERTY_TOTALPARTICLES "totalParticles" #define PROPERTY_LIFE "life" #define PROPERTY_STARTSIZE "startSize" #define PROPERTY_ENDSIZE "endSize" #define PROPERTY_STARTSPIN "startSpin" #define PROPERTY_ENDSPIN "endSpin" #define PROPERTY_ANGLE "angle" #define PROPERTY_STARTCOLOR "startColor" #define PROPERTY_ENDCOLOR "endColor" #define PROPERTY_BLENDFUNC "blendFunc" #define PROPERTY_GRAVITY "gravity" #define PROPERTY_SPEED "speed" #define PROPERTY_TANGENTIALACCEL "tangentialAccel" #define PROPERTY_RADIALACCEL "radialAccel" #define PROPERTY_TEXTURE "texture" #define PROPERTY_STARTRADIUS "startRadius" #define PROPERTY_ENDRADIUS "endRadius" #define PROPERTY_ROTATEPERSECOND "rotatePerSecond" namespace cocosbuilder { void ParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_EMITERMODE) == 0) { ((ParticleSystemQuad *)pNode)->setEmitterMode((ParticleSystem::Mode)pIntegerLabeled); } else { NodeLoader::onHandlePropTypeIntegerLabeled(pNode, pParent, pPropertyName, pIntegerLabeled, ccbReader); } } void ParticleSystemQuadLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_POSVAR) == 0) { ((ParticleSystemQuad *)pNode)->setPosVar(pPoint); } else if(strcmp(pPropertyName, PROPERTY_GRAVITY) == 0) { ((ParticleSystemQuad *)pNode)->setGravity(pPoint); } else { NodeLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, ccbReader); } } void ParticleSystemQuadLoader::onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_EMISSIONRATE) == 0) { ((ParticleSystemQuad *)pNode)->setEmissionRate(pFloat); } else if(strcmp(pPropertyName, PROPERTY_DURATION) == 0) { ((ParticleSystemQuad *)pNode)->setDuration(pFloat); } else { NodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, ccbReader); } } void ParticleSystemQuadLoader::onHandlePropTypeInteger(Node * pNode, Node * pParent, const char * pPropertyName, int pInteger, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_TOTALPARTICLES) == 0) { ((ParticleSystemQuad *)pNode)->setTotalParticles(pInteger); } else { NodeLoader::onHandlePropTypeInteger(pNode, pParent, pPropertyName, pInteger, ccbReader); } } void ParticleSystemQuadLoader::onHandlePropTypeFloatVar(Node * pNode, Node * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_LIFE) == 0) { ((ParticleSystemQuad *)pNode)->setLife(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setLifeVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_STARTSIZE) == 0) { ((ParticleSystemQuad *)pNode)->setStartSize(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setStartSizeVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_ENDSIZE) == 0) { ((ParticleSystemQuad *)pNode)->setEndSize(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setEndSizeVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_STARTSPIN) == 0) { ((ParticleSystemQuad *)pNode)->setStartSpin(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setStartSpinVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_ENDSPIN) == 0) { ((ParticleSystemQuad *)pNode)->setEndSpin(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setEndSpinVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_ANGLE) == 0) { ((ParticleSystemQuad *)pNode)->setAngle(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setAngleVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_SPEED) == 0) { ((ParticleSystemQuad *)pNode)->setSpeed(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setSpeedVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_TANGENTIALACCEL) == 0) { ((ParticleSystemQuad *)pNode)->setTangentialAccel(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setTangentialAccelVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_RADIALACCEL) == 0) { ((ParticleSystemQuad *)pNode)->setRadialAccel(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setRadialAccelVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_STARTRADIUS) == 0) { ((ParticleSystemQuad *)pNode)->setStartRadius(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setStartRadiusVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_ENDRADIUS) == 0) { ((ParticleSystemQuad *)pNode)->setEndRadius(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setEndRadiusVar(pFloatVar[1]); } else if(strcmp(pPropertyName, PROPERTY_ROTATEPERSECOND) == 0) { ((ParticleSystemQuad *)pNode)->setRotatePerSecond(pFloatVar[0]); ((ParticleSystemQuad *)pNode)->setRotatePerSecondVar(pFloatVar[1]); } else { NodeLoader::onHandlePropTypeFloatVar(pNode, pParent, pPropertyName, pFloatVar, ccbReader); } } void ParticleSystemQuadLoader::onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char * pPropertyName, Color4F * pColor4FVar, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) { ((ParticleSystemQuad *)pNode)->setStartColor(pColor4FVar[0]); ((ParticleSystemQuad *)pNode)->setStartColorVar(pColor4FVar[1]); } else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) { ((ParticleSystemQuad *)pNode)->setEndColor(pColor4FVar[0]); ((ParticleSystemQuad *)pNode)->setEndColorVar(pColor4FVar[1]); } else { NodeLoader::onHandlePropTypeColor4FVar(pNode, pParent, pPropertyName, pColor4FVar, ccbReader); } } void ParticleSystemQuadLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((ParticleSystemQuad *)pNode)->setBlendFunc(pBlendFunc); } else { NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader); } } void ParticleSystemQuadLoader::onHandlePropTypeTexture(Node * pNode, Node * pParent, const char * pPropertyName, Texture2D * pTexture2D, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_TEXTURE) == 0) { static_cast(pNode)->setTexture(pTexture2D); if(pTexture2D) { static_cast(pNode)->setBlendAdditive(true); } } else { NodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pTexture2D, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCParticleSystemQuadLoader.h ================================================ #ifndef _CCB_CCPARTICLESYSTEMQUADLOADER_H_ #define _CCB_CCPARTICLESYSTEMQUADLOADER_H_ #include "CCObject.h" #include "CCParticleSystemQuad.h" #include "CCNodeLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class ParticleSystemQuadLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~ParticleSystemQuadLoader() {}; /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(cocosbuilder::ParticleSystemQuadLoader, loader); protected: /** * @js NA * @lua NA */ CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::ParticleSystemQuad); /** * @js NA * @lua NA */ virtual void onHandlePropTypeIntegerLabeled(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Point pPoint, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeFloat(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, float pFloat, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeInteger(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, int pInteger, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeFloatVar(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeColor4FVar(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color4F * pColor4FVar, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeTexture(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Texture2D * pTexture2D, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.cpp ================================================ #include "CCScale9SpriteLoader.h" using namespace cocos2d; using namespace cocos2d::extension; #define PROPERTY_CONTENTSIZE "contentSize" #define PROPERTY_SPRITEFRAME "spriteFrame" #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" #define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder! #define PROPERTY_INSETLEFT "insetLeft" #define PROPERTY_INSETTOP "insetTop" #define PROPERTY_INSETRIGHT "insetRight" #define PROPERTY_INSETBOTTOM "insetBottom" namespace cocosbuilder { void Scale9SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_SPRITEFRAME) == 0) { ((Scale9Sprite *)pNode)->setSpriteFrame(pSpriteFrame); } else { NodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader); } } void Scale9SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((Scale9Sprite *)pNode)->setColor(pColor3B); } else { NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); } } void Scale9SpriteLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((Scale9Sprite *)pNode)->setOpacity(pByte); } else { NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader); } } void Scale9SpriteLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { // TODO Not exported by CocosBuilder yet! // ((Scale9Sprite *)pNode)->setBlendFunc(pBlendFunc); } else { NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader); } } void Scale9SpriteLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { //((Scale9Sprite *)pNode)->setContentSize(pSize); } else if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { ((Scale9Sprite *)pNode)->setPreferredSize(pSize); } else { NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader); } } void Scale9SpriteLoader::onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_INSETLEFT) == 0) { ((Scale9Sprite *)pNode)->setInsetLeft(pFloat); } else if(strcmp(pPropertyName, PROPERTY_INSETTOP) == 0) { ((Scale9Sprite *)pNode)->setInsetTop(pFloat); } else if(strcmp(pPropertyName, PROPERTY_INSETRIGHT) == 0) { ((Scale9Sprite *)pNode)->setInsetRight(pFloat); } else if(strcmp(pPropertyName, PROPERTY_INSETBOTTOM) == 0) { ((Scale9Sprite *)pNode)->setInsetBottom(pFloat); } else { NodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h ================================================ #ifndef _CCB_CCSCALE9SPRITELOADER_H_ #define _CCB_CCSCALE9SPRITELOADER_H_ #include "CCNodeLoader.h" #include "CCScale9SpriteLoader.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class Scale9SpriteLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~Scale9SpriteLoader() {}; /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(Scale9SpriteLoader, loader); protected: /** * @js NA * @lua NA */ virtual cocos2d::extension::Scale9Sprite * createNode(cocos2d::Node * pParent, cocosbuilder::CCBReader * ccbReader) { cocos2d::extension::Scale9Sprite* pNode = cocos2d::extension::Scale9Sprite::create(); pNode->setAnchorPoint(cocos2d::Point(0,0)); return pNode; }; /** * @js NA * @lua NA */ virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeSpriteFrame(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::SpriteFrame * pSpriteFrame, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader); /** * @js NA * @lua NA */ virtual void onHandlePropTypeFloat(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, float pFloat, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCScrollViewLoader.cpp ================================================ #include "CCScrollViewLoader.h" using namespace cocos2d; using namespace cocos2d::extension; #define PROPERTY_CONTAINER "container" #define PROPERTY_DIRECTION "direction" #define PROPERTY_CLIPSTOBOUNDS "clipsToBounds" #define PROPERTY_BOUNCES "bounces" #define PROPERTY_SCALE "scale" namespace cocosbuilder { void ScrollViewLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { ((ScrollView *)pNode)->setViewSize(pSize); } else { NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader); } } void ScrollViewLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_CLIPSTOBOUNDS) == 0) { ((ScrollView *)pNode)->setClippingToBounds(pCheck); } else if(strcmp(pPropertyName, PROPERTY_BOUNCES) == 0) { ((ScrollView *)pNode)->setBounceable(pCheck); } else { NodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader); } } void ScrollViewLoader::onHandlePropTypeCCBFile(Node * pNode, Node * pParent, const char * pPropertyName, Node * pCCBFileNode, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_CONTAINER) == 0) { ((ScrollView *)pNode)->setContainer(pCCBFileNode); ((ScrollView *)pNode)->updateInset(); } else { NodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, ccbReader); } } void ScrollViewLoader::onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_SCALE) == 0) { ((ScrollView *)pNode)->setScale(pFloat); } else { NodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, ccbReader); } } void ScrollViewLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_DIRECTION) == 0) { ((ScrollView *)pNode)->setDirection(ScrollView::Direction(pIntegerLabeled)); } else { NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCScrollViewLoader.h ================================================ #ifndef _CCB_CCSCROLLVIEWLOADER_H_ #define _CCB_CCSCROLLVIEWLOADER_H_ #include "CCNodeLoader.h" #include "extensions/GUI/CCScrollView/CCScrollView.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class ScrollViewLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~ScrollViewLoader() {}; /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ScrollViewLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::extension::ScrollView); virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader); virtual void onHandlePropTypeCCBFile(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Node * pCCBFileNode, CCBReader * ccbReader); virtual void onHandlePropTypeCheck(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader); virtual void onHandlePropTypeFloat(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, float pFloat, CCBReader * ccbReader); virtual void onHandlePropTypeIntegerLabeled(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCSpriteLoader.cpp ================================================ #include "CCSpriteLoader.h" using namespace cocos2d; #define PROPERTY_FLIP "flip" #define PROPERTY_DISPLAYFRAME "displayFrame" #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" namespace cocosbuilder { void SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) { if(pSpriteFrame != NULL) { ((Sprite *)pNode)->setSpriteFrame(pSpriteFrame); } else { CCLOG("ERROR: SpriteFrame NULL"); } } else { NodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader); } } void SpriteLoader::onHandlePropTypeFlip(Node * pNode, Node * pParent, const char * pPropertyName, bool * pFlip, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_FLIP) == 0) { ((Sprite *)pNode)->setFlippedX(pFlip[0]); ((Sprite *)pNode)->setFlippedY(pFlip[1]); } else { NodeLoader::onHandlePropTypeFlip(pNode, pParent, pPropertyName, pFlip, ccbReader); } } void SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((Sprite *)pNode)->setColor(pColor3B); } else { NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); } } void SpriteLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((Sprite *)pNode)->setOpacity(pByte); } else { NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader); } } void SpriteLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((Sprite *)pNode)->setBlendFunc(pBlendFunc); } else { NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader); } } } ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CCSpriteLoader.h ================================================ #ifndef _CCB_CCSPRITELOADER_H_ #define _CCB_CCSPRITELOADER_H_ #include "CCNodeLoader.h" namespace cocosbuilder { /* Forward declaration. */ class CCBReader; class SpriteLoader : public NodeLoader { public: /** * @js NA * @lua NA */ virtual ~SpriteLoader() {}; /** * @js NA * @lua NA */ CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(SpriteLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::Sprite); virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader); virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader); virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pCCBBlendFunc, CCBReader * ccbReader); virtual void onHandlePropTypeSpriteFrame(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::SpriteFrame * pSpriteFrame, CCBReader * ccbReader); virtual void onHandlePropTypeFlip(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, bool * pFlip, CCBReader * ccbReader); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CMakeLists.txt ================================================ set(CCB_SRC CCBFileLoader.cpp CCMenuItemImageLoader.cpp CCBReader.cpp CCMenuItemLoader.cpp CCControlButtonLoader.cpp CCNodeLoader.cpp CCControlLoader.cpp CCNodeLoaderLibrary.cpp CCLabelBMFontLoader.cpp CCParticleSystemQuadLoader.cpp CCLabelTTFLoader.cpp CCScale9SpriteLoader.cpp CCLayerColorLoader.cpp CCScrollViewLoader.cpp CCLayerGradientLoader.cpp CCSpriteLoader.cpp CCLayerLoader.cpp CCBAnimationManager.cpp CCBKeyframe.cpp CCBSequence.cpp CCBSequenceProperty.cpp CCNode+CCBRelativePositioning.cpp ) include_directories( .. ) add_library(cocosbuilder STATIC ${CCB_SRC} ) set_target_properties(cocosbuilder PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/CocosBuilder.h ================================================ #ifndef __EDITOR_SUPPORT_COCOSBUILDER_H__ #define __EDITOR_SUPPORT_COCOSBUILDER_H__ #include "cocosbuilder/CCBAnimationManager.h" #include "cocosbuilder/CCBFileLoader.h" #include "cocosbuilder/CCBKeyframe.h" #include "cocosbuilder/CCBMemberVariableAssigner.h" #include "cocosbuilder/CCBReader.h" #include "cocosbuilder/CCBSelectorResolver.h" #include "cocosbuilder/CCBSequence.h" #include "cocosbuilder/CCBSequenceProperty.h" #include "cocosbuilder/CCControlButtonLoader.h" #include "cocosbuilder/CCControlLoader.h" #include "cocosbuilder/CCLabelBMFontLoader.h" #include "cocosbuilder/CCLabelTTFLoader.h" #include "cocosbuilder/CCLayerColorLoader.h" #include "cocosbuilder/CCLayerGradientLoader.h" #include "cocosbuilder/CCLayerLoader.h" #include "cocosbuilder/CCMenuItemImageLoader.h" #include "cocosbuilder/CCMenuItemLoader.h" #include "cocosbuilder/CCMenuLoader.h" #include "cocosbuilder/CCNode+CCBRelativePositioning.h" #include "cocosbuilder/CCNodeLoader.h" #include "cocosbuilder/CCNodeLoaderLibrary.h" #include "cocosbuilder/CCNodeLoaderListener.h" #include "cocosbuilder/CCParticleSystemQuadLoader.h" #include "cocosbuilder/CCScale9SpriteLoader.h" #include "cocosbuilder/CCScrollViewLoader.h" #include "cocosbuilder/CCSpriteLoader.h" #endif // __EDITOR_SUPPORT_COCOSBUILDER_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj ================================================  Debug Win32 Release Win32 {811C0DAB-7B96-4BD3-A154-B7572B58E4AB} libCocosBuilder StaticLibrary true v100 v110 v110_xp Unicode StaticLibrary false v100 v110 v110_xp true Unicode $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled $(EngineRoot);$(EngineRoot)extensions;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true 4267;4251;4244;%(DisableSpecificWarnings) false OldStyle true Level3 MaxSpeed true true $(EngineRoot);$(EngineRoot)extensions;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true true ================================================ FILE: cocos2d/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj.filters ================================================  {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocostudio_static LOCAL_MODULE_FILENAME := libcocostudio LOCAL_SRC_FILES := CCActionFrame.cpp \ CCActionEaseEx.cpp \ CCActionFrameEasing.cpp \ CCActionManagerEx.cpp \ CCActionNode.cpp \ CCActionObject.cpp \ CCArmature.cpp \ CCBone.cpp \ CCArmatureAnimation.cpp \ CCProcessBase.cpp \ CCTween.cpp \ CCDatas.cpp \ CCBatchNode.cpp \ CCDecorativeDisplay.cpp \ CCDisplayFactory.cpp \ CCDisplayManager.cpp \ CCSkin.cpp \ CCColliderDetector.cpp \ CCArmatureDataManager.cpp \ CCArmatureDefine.cpp \ CCDataReaderHelper.cpp \ CCSpriteFrameCacheHelper.cpp \ CCTransformHelp.cpp \ CCTweenFunction.cpp \ CCUtilMath.cpp \ CCComAttribute.cpp \ CCComAudio.cpp \ CCComController.cpp \ CCComRender.cpp \ CCInputDelegate.cpp \ DictionaryHelper.cpp \ CCSGUIReader.cpp \ CCSSceneReader.cpp \ ObjectFactory.cpp \ TriggerBase.cpp \ TriggerMng.cpp \ TriggerObj.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../../../external LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \ $(LOCAL_PATH)/../../../external \ $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../.. LOCAL_CFLAGS += -Wno-psabi -fexceptions LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_gui_static include $(BUILD_STATIC_LIBRARY) $(call import-module,2d) $(call import-module,audio/android) $(call import-module,gui) ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionEaseEx.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionEaseEx.h" using namespace cocos2d; namespace cocostudio { static inline float bezieratFunction( float a, float b, float c, float d, float t ) { return (powf(1-t,3) * a + 3*t*(powf(1-t,2))*b + 3*powf(t,2)*(1-t)*c + powf(t,3)*d ); } EaseBezierAction* EaseBezierAction::create(cocos2d::ActionInterval* action) { EaseBezierAction *ret = new EaseBezierAction(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } void EaseBezierAction::setBezierParamer( float p0, float p1, float p2, float p3) { _p0 = p0; _p1 = p1; _p2 = p2; _p3 = p3; } EaseBezierAction* EaseBezierAction::clone() const { // no copy constructor auto a = new EaseBezierAction(); a->initWithAction(_inner->clone()); a->setBezierParamer(_p0,_p1,_p2,_p3); a->autorelease(); return a; } void EaseBezierAction::update(float time) { _inner->update(bezieratFunction(_p0,_p1,_p2,_p3,time)); } EaseBezierAction* EaseBezierAction::reverse() const { EaseBezierAction* reverseAction = EaseBezierAction::create(_inner->reverse()); reverseAction->setBezierParamer(_p3,_p2,_p1,_p0); return reverseAction; } // // EaseQuadraticActionIn // EaseQuadraticActionIn* EaseQuadraticActionIn::create(ActionInterval* action) { EaseQuadraticActionIn *ret = new EaseQuadraticActionIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuadraticActionIn* EaseQuadraticActionIn::clone() const { // no copy constructor auto a = new EaseQuadraticActionIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuadraticActionIn::update(float time) { _inner->update(powf(time,2)); } EaseQuadraticActionIn* EaseQuadraticActionIn::reverse() const { return EaseQuadraticActionIn::create(_inner->reverse()); } // // EaseQuadraticActionOut // EaseQuadraticActionOut* EaseQuadraticActionOut::create(ActionInterval* action) { EaseQuadraticActionOut *ret = new EaseQuadraticActionOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuadraticActionOut* EaseQuadraticActionOut::clone() const { // no copy constructor auto a = new EaseQuadraticActionOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuadraticActionOut::update(float time) { _inner->update(-time*(time-2)); } EaseQuadraticActionOut* EaseQuadraticActionOut::reverse() const { return EaseQuadraticActionOut::create(_inner->reverse()); } // // EaseQuadraticActionInOut // EaseQuadraticActionInOut* EaseQuadraticActionInOut::create(ActionInterval* action) { EaseQuadraticActionInOut *ret = new EaseQuadraticActionInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuadraticActionInOut* EaseQuadraticActionInOut::clone() const { // no copy constructor auto a = new EaseQuadraticActionInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuadraticActionInOut::update(float time) { float resultTime = time; time = time*2; if (time < 1) { resultTime = time * time * 0.5f; } else { --time; resultTime = -0.5f * (time * (time - 2) - 1); } _inner->update(resultTime); } EaseQuadraticActionInOut* EaseQuadraticActionInOut::reverse() const { return EaseQuadraticActionInOut::create(_inner->reverse()); } // // EaseQuarticActionIn // EaseQuarticActionIn* EaseQuarticActionIn::create(ActionInterval* action) { EaseQuarticActionIn *ret = new EaseQuarticActionIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuarticActionIn* EaseQuarticActionIn::clone() const { // no copy constructor auto a = new EaseQuarticActionIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuarticActionIn::update(float time) { _inner->update(powf(time,4.0f)); } EaseQuarticActionIn* EaseQuarticActionIn::reverse() const { return EaseQuarticActionIn::create(_inner->reverse()); } // // EaseQuarticActionOut // EaseQuarticActionOut* EaseQuarticActionOut::create(ActionInterval* action) { EaseQuarticActionOut *ret = new EaseQuarticActionOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuarticActionOut* EaseQuarticActionOut::clone() const { // no copy constructor auto a = new EaseQuarticActionOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuarticActionOut::update(float time) { float tempTime = time -1; _inner->update(1- powf(tempTime,4.0f)); } EaseQuarticActionOut* EaseQuarticActionOut::reverse() const { return EaseQuarticActionOut::create(_inner->reverse()); } // // EaseQuarticActionInOut // EaseQuarticActionInOut* EaseQuarticActionInOut::create(ActionInterval* action) { EaseQuarticActionInOut *ret = new EaseQuarticActionInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuarticActionInOut* EaseQuarticActionInOut::clone() const { // no copy constructor auto a = new EaseQuarticActionInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuarticActionInOut::update(float time) { float tempTime = time * 2; if (tempTime < 1) tempTime = powf(tempTime,4.0f) * 0.5f; else { tempTime -= 2; tempTime = 1 - powf(tempTime,4.0f)* 0.5f; } _inner->update(tempTime); } EaseQuarticActionInOut* EaseQuarticActionInOut::reverse() const { return EaseQuarticActionInOut::create(_inner->reverse()); } // // EaseQuinticActionIn // EaseQuinticActionIn* EaseQuinticActionIn::create(ActionInterval* action) { EaseQuinticActionIn *ret = new EaseQuinticActionIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuinticActionIn* EaseQuinticActionIn::clone() const { // no copy constructor auto a = new EaseQuinticActionIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuinticActionIn::update(float time) { _inner->update(powf(time,5.0f)); } EaseQuinticActionIn* EaseQuinticActionIn::reverse() const { return EaseQuinticActionIn::create(_inner->reverse()); } // // EaseQuinticActionOut // EaseQuinticActionOut* EaseQuinticActionOut::create(ActionInterval* action) { EaseQuinticActionOut *ret = new EaseQuinticActionOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuinticActionOut* EaseQuinticActionOut::clone() const { // no copy constructor auto a = new EaseQuinticActionOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuinticActionOut::update(float time) { float tempTime = time -1; _inner->update(1 + powf(tempTime,5.0f)); } EaseQuinticActionOut* EaseQuinticActionOut::reverse() const { return EaseQuinticActionOut::create(_inner->reverse()); } // // EaseQuinticActionInOut // EaseQuinticActionInOut* EaseQuinticActionInOut::create(ActionInterval* action) { EaseQuinticActionInOut *ret = new EaseQuinticActionInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseQuinticActionInOut* EaseQuinticActionInOut::clone() const { // no copy constructor auto a = new EaseQuinticActionInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseQuinticActionInOut::update(float time) { float tempTime = time * 2; if (tempTime < 1) tempTime = powf(tempTime,5.0f) * 0.5f; else { tempTime -= 2; tempTime = 1 + powf(tempTime,5.0f)* 0.5f; } _inner->update(tempTime); } EaseQuinticActionInOut* EaseQuinticActionInOut::reverse() const { return EaseQuinticActionInOut::create(_inner->reverse()); } // // EaseCircleActionIn // EaseCircleActionIn* EaseCircleActionIn::create(ActionInterval* action) { EaseCircleActionIn *ret = new EaseCircleActionIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseCircleActionIn* EaseCircleActionIn::clone() const { // no copy constructor auto a = new EaseCircleActionIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseCircleActionIn::update(float time) { _inner->update(1-sqrt(1-powf(time,2.0f))); } EaseCircleActionIn* EaseCircleActionIn::reverse() const { return EaseCircleActionIn::create(_inner->reverse()); } // // EaseCircleActionOut // EaseCircleActionOut* EaseCircleActionOut::create(ActionInterval* action) { EaseCircleActionOut *ret = new EaseCircleActionOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseCircleActionOut* EaseCircleActionOut::clone() const { // no copy constructor auto a = new EaseCircleActionOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseCircleActionOut::update(float time) { float tempTime = time - 1; _inner->update(sqrt(1-powf(tempTime,2.0f))); } EaseCircleActionOut* EaseCircleActionOut::reverse() const { return EaseCircleActionOut::create(_inner->reverse()); } // // EaseCircleActionInOut // EaseCircleActionInOut* EaseCircleActionInOut::create(ActionInterval* action) { EaseCircleActionInOut *ret = new EaseCircleActionInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseCircleActionInOut* EaseCircleActionInOut::clone() const { // no copy constructor auto a = new EaseCircleActionInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseCircleActionInOut::update(float time) { float tempTime = time * 2; if (tempTime < 1) tempTime = (1- sqrt(1 - powf(tempTime,2.0f))) * 0.5f; else { tempTime -= 2; tempTime = (1+ sqrt(1 - powf(tempTime,2.0f))) * 0.5f; } _inner->update(time); } EaseCircleActionInOut* EaseCircleActionInOut::reverse() const { return EaseCircleActionInOut::create(_inner->reverse()); } // // EaseCubicActionIn // EaseCubicActionIn* EaseCubicActionIn::create(ActionInterval* action) { EaseCubicActionIn *ret = new EaseCubicActionIn(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseCubicActionIn* EaseCubicActionIn::clone() const { // no copy constructor auto a = new EaseCubicActionIn(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseCubicActionIn::update(float time) { _inner->update(powf(time,3.0f)); } EaseCubicActionIn* EaseCubicActionIn::reverse() const { return EaseCubicActionIn::create(_inner->reverse()); } // // EaseCubicActionOut // EaseCubicActionOut* EaseCubicActionOut::create(ActionInterval* action) { EaseCubicActionOut *ret = new EaseCubicActionOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseCubicActionOut* EaseCubicActionOut::clone() const { // no copy constructor auto a = new EaseCubicActionOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseCubicActionOut::update(float time) { time -= 1; _inner->update(1+powf(time,3.0f)); } EaseCubicActionOut* EaseCubicActionOut::reverse() const { return EaseCubicActionOut::create(_inner->reverse()); } // // EaseCubicActionInOut // EaseCubicActionInOut* EaseCubicActionInOut::create(ActionInterval* action) { EaseCubicActionInOut *ret = new EaseCubicActionInOut(); if (ret) { if (ret->initWithAction(action)) { ret->autorelease(); } else { CC_SAFE_RELEASE_NULL(ret); } } return ret; } EaseCubicActionInOut* EaseCubicActionInOut::clone() const { // no copy constructor auto a = new EaseCubicActionInOut(); a->initWithAction(_inner->clone()); a->autorelease(); return a; } void EaseCubicActionInOut::update(float time) { float tempTime = time * 2; if (tempTime < 1) tempTime = powf(tempTime,3.0f) * 0.5f; else { tempTime -= 2; tempTime = 1 + powf(tempTime,3.0f)* 0.5f; } _inner->update(time); } EaseCubicActionInOut* EaseCubicActionInOut::reverse() const { return EaseCubicActionInOut::create(_inner->reverse()); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionEaseEx.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ActionEaseEx_H__ #define __ActionEaseEx_H__ #include "cocostudio/CocoStudio.h" namespace cocostudio { /** @brief Ease Bezier @ingroup Actions */ class EaseBezierAction : public cocos2d::ActionEase { public: /** creates the action */ static EaseBezierAction* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseBezierAction* clone() const override; virtual EaseBezierAction* reverse() const override; virtual void setBezierParamer( float p0, float p1, float p2, float p3); protected: EaseBezierAction() {} virtual ~EaseBezierAction() {} float _p0; float _p1; float _p2; float _p3; private: CC_DISALLOW_COPY_AND_ASSIGN(EaseBezierAction); }; /** @brief Ease Quadratic In @ingroup Actions */ class EaseQuadraticActionIn:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuadraticActionIn* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuadraticActionIn* clone() const override; virtual EaseQuadraticActionIn* reverse() const override; protected: EaseQuadraticActionIn() {} virtual ~EaseQuadraticActionIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionIn); }; /** @brief Ease Quadratic Out @ingroup Actions */ class EaseQuadraticActionOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuadraticActionOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuadraticActionOut* clone() const override; virtual EaseQuadraticActionOut* reverse() const override; protected: EaseQuadraticActionOut() {} virtual ~EaseQuadraticActionOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionOut); }; /** @brief Ease Quadratic InOut @ingroup Actions */ class EaseQuadraticActionInOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuadraticActionInOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuadraticActionInOut* clone() const override; virtual EaseQuadraticActionInOut* reverse() const override; protected: EaseQuadraticActionInOut() {} virtual ~EaseQuadraticActionInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuadraticActionInOut); }; /** @brief Ease Quartic In @ingroup Actions */ class EaseQuarticActionIn:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuarticActionIn* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuarticActionIn* clone() const override; virtual EaseQuarticActionIn* reverse() const override; protected: EaseQuarticActionIn() {} virtual ~EaseQuarticActionIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionIn); }; /** @brief Ease Quartic Out @ingroup Actions */ class EaseQuarticActionOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuarticActionOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuarticActionOut* clone() const override; virtual EaseQuarticActionOut* reverse() const override; protected: EaseQuarticActionOut() {} virtual ~EaseQuarticActionOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionOut); }; /** @brief Ease Quartic InOut @ingroup Actions */ class EaseQuarticActionInOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuarticActionInOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuarticActionInOut* clone() const override; virtual EaseQuarticActionInOut* reverse() const override; protected: EaseQuarticActionInOut() {} virtual ~EaseQuarticActionInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuarticActionInOut); }; /** @brief Ease Quintic In @ingroup Actions */ class EaseQuinticActionIn:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuinticActionIn* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuinticActionIn* clone() const override; virtual EaseQuinticActionIn* reverse() const override; protected: EaseQuinticActionIn() {} virtual ~EaseQuinticActionIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionIn); }; /** @brief Ease Quintic Out @ingroup Actions */ class EaseQuinticActionOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuinticActionOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuinticActionOut* clone() const override; virtual EaseQuinticActionOut* reverse() const override; protected: EaseQuinticActionOut() {} virtual ~EaseQuinticActionOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionOut); }; /** @brief Ease Quintic InOut @ingroup Actions */ class EaseQuinticActionInOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseQuinticActionInOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseQuinticActionInOut* clone() const override; virtual EaseQuinticActionInOut* reverse() const override; protected: EaseQuinticActionInOut() {} virtual ~EaseQuinticActionInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseQuinticActionInOut); }; /** @brief Ease Circle In @ingroup Actions */ class EaseCircleActionIn:public cocos2d::ActionEase { public: /** creates the action */ static EaseCircleActionIn* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseCircleActionIn* clone() const override; virtual EaseCircleActionIn* reverse() const override; protected: EaseCircleActionIn() {} virtual ~EaseCircleActionIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionIn); }; /** @brief Ease Circle Out @ingroup Actions */ class EaseCircleActionOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseCircleActionOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseCircleActionOut* clone() const override; virtual EaseCircleActionOut* reverse() const override; protected: EaseCircleActionOut() {} virtual ~EaseCircleActionOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionOut); }; /** @brief Ease Circle InOut @ingroup Actions */ class EaseCircleActionInOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseCircleActionInOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseCircleActionInOut* clone() const override; virtual EaseCircleActionInOut* reverse() const override; protected: EaseCircleActionInOut() {} virtual ~EaseCircleActionInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseCircleActionInOut); }; /** @brief Ease Cubic In @ingroup Actions */ class EaseCubicActionIn:public cocos2d::ActionEase { public: /** creates the action */ static EaseCubicActionIn* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseCubicActionIn* clone() const override; virtual EaseCubicActionIn* reverse() const override; protected: EaseCubicActionIn() {} virtual ~EaseCubicActionIn() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionIn); }; /** @brief Ease Cubic Out @ingroup Actions */ class EaseCubicActionOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseCubicActionOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseCubicActionOut* clone() const override; virtual EaseCubicActionOut* reverse() const override; protected: EaseCubicActionOut() {} virtual ~EaseCubicActionOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionOut); }; /** @brief Ease Cubic InOut @ingroup Actions */ class EaseCubicActionInOut:public cocos2d::ActionEase { public: /** creates the action */ static EaseCubicActionInOut* create(cocos2d::ActionInterval* action); virtual void update(float time) override; virtual EaseCubicActionInOut* clone() const override; virtual EaseCubicActionInOut* reverse() const override; protected: EaseCubicActionInOut() {} virtual ~EaseCubicActionInOut() {} private: CC_DISALLOW_COPY_AND_ASSIGN(EaseCubicActionInOut); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionFrame.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionFrame.h" #include "CCActionEaseEx.h" using namespace cocos2d; namespace cocostudio { ActionFrame::ActionFrame() : _frameType(0) , _frameIndex(0) , _fTime(0.0f) , _easingType(FrameEaseType::LINERAR) { } ActionFrame::~ActionFrame() { } void ActionFrame::setFrameIndex(int index) { _frameIndex = index; } int ActionFrame::getFrameIndex() { return _frameIndex; } void ActionFrame::setFrameTime(float fTime) { _fTime = fTime; } float ActionFrame::getFrameTime() { return _fTime; } void ActionFrame::setFrameType(int frameType) { _frameType = frameType; } int ActionFrame::getFrameType() { return _frameType; } void ActionFrame::setEasingType(int easingType) { _easingType = (FrameEaseType)easingType; } int ActionFrame::getEasingType() { return (int)_easingType; } ActionInterval* ActionFrame::getAction(float fDuration) { log("Need a definition of for ActionFrame"); return nullptr; } ActionInterval* ActionFrame::getAction(float fDuration,ActionFrame* srcFrame) { return this->getAction(fDuration); } void ActionFrame::setEasingParameter(std::vector& parameter) { _Parameter.clear(); for (size_t i = 0; isetBezierParamer(_Parameter[0],_Parameter[1],_Parameter[2],_Parameter[3]); return cAction; } break; case FrameEaseType::LINERAR: return action; break; case FrameEaseType::SINE_EASEIN: return EaseSineIn::create(action); break; case FrameEaseType::SINE_EASEOUT: return EaseSineOut::create(action); break; case FrameEaseType::SINE_EASEINOUT: return EaseSineInOut::create(action); break; case FrameEaseType::QUAD_EASEIN: return EaseQuadraticActionIn::create(action); break; case FrameEaseType::QUAD_EASEOUT: return EaseQuadraticActionOut::create(action); break; case FrameEaseType::QUAD_EASEINOUT: return EaseQuadraticActionInOut::create(action); break; case FrameEaseType::CUBIC_EASEIN: return EaseCubicActionIn::create(action); break; case FrameEaseType::CUBIC_EASEOUT: return EaseCubicActionOut::create(action); break; case FrameEaseType::CUBIC_EASEINOUT: return EaseCubicActionInOut::create(action); break; case FrameEaseType::QUART_EASEIN: return EaseQuarticActionIn::create(action); break; case FrameEaseType::QUART_EASEOUT: return EaseQuadraticActionOut::create(action); break; case FrameEaseType::QUART_EASEINOUT: return EaseQuarticActionInOut::create(action); break; case FrameEaseType::QUINT_EASEIN: return EaseQuinticActionIn::create(action); break; case FrameEaseType::QUINT_EASEOUT: return EaseQuinticActionOut::create(action); break; case FrameEaseType::QUINT_EASEINOUT: return EaseQuinticActionInOut::create(action); break; case FrameEaseType::EXPO_EASEIN: return EaseExponentialIn::create(action); break; case FrameEaseType::EXPO_EASEOUT: return EaseExponentialOut::create(action); break; case FrameEaseType::EXPO_EASEINOUT: return EaseExponentialInOut::create(action); break; case FrameEaseType::CIRC_EASEIN: return EaseCircleActionIn::create(action); break; case FrameEaseType::CIRC_EASEOUT: return EaseCircleActionOut::create(action); break; case FrameEaseType::CIRC_EASEINOUT: return EaseCircleActionInOut::create(action); break; case FrameEaseType::ELASTIC_EASEIN: { return EaseElasticIn::create(action); } break; case FrameEaseType::ELASTIC_EASEOUT: { return EaseElasticOut::create(action); } break; case FrameEaseType::ELASTIC_EASEINOUT: { return EaseElasticInOut::create(action); } break; case FrameEaseType::BACK_EASEIN: return EaseBackIn::create(action); break; case FrameEaseType::BACK_EASEOUT: return EaseBackOut::create(action); break; case FrameEaseType::BACK_EASEINOUT: return EaseBackInOut::create(action); break; case FrameEaseType::BOUNCE_EASEIN: return EaseBounceIn::create(action); break; case FrameEaseType::BOUNCE_EASEOUT: return EaseBounceOut::create(action); break; case FrameEaseType::BOUNCE_EASEINOUT: return EaseBounceInOut::create(action); break; default: return action; break; } } ////////////////////////////////////////////////////////////////////////// ActionMoveFrame::ActionMoveFrame() : _position(Point(0.0f,0.0f)) { _frameType = (int)kKeyframeMove; } ActionMoveFrame::~ActionMoveFrame() { } void ActionMoveFrame::setPosition(Point pos) { _position = pos; } Point ActionMoveFrame::getPosition() { return _position; } ActionInterval* ActionMoveFrame::getAction(float fDuration) { return this->getEasingAction(CCMoveTo::create(fDuration,_position)); } ////////////////////////////////////////////////////////////////////////// ActionScaleFrame::ActionScaleFrame() : _scaleX(1.0f) , _scaleY(1.0f) { _frameType = (int)kKeyframeScale; } ActionScaleFrame::~ActionScaleFrame() { } void ActionScaleFrame::setScaleX(float scaleX) { _scaleX = scaleX; } float ActionScaleFrame::getScaleX() { return _scaleX; } void ActionScaleFrame::setScaleY(float scaleY) { _scaleY = scaleY; } float ActionScaleFrame::getScaleY() { return _scaleY; } ActionInterval* ActionScaleFrame::getAction(float fDuration) { return this->getEasingAction(CCScaleTo::create(fDuration,_scaleX,_scaleY)); } ActionRotationFrame::ActionRotationFrame() : _rotation(0.0f) { _frameType = (int)kKeyframeRotate; } ActionRotationFrame::~ActionRotationFrame() { } void ActionRotationFrame::setRotation(float rotation) { _rotation = rotation; } float ActionRotationFrame::getRotation() { return _rotation; } ActionInterval* ActionRotationFrame::getAction(float fDuration) { return this->getEasingAction(CCRotateTo::create(fDuration,_rotation)); } ActionInterval* ActionRotationFrame::getAction(float fDuration,ActionFrame* srcFrame) { ActionRotationFrame* srcRotationFrame = static_cast(srcFrame); if (srcRotationFrame == nullptr) { return this->getAction(fDuration); } else { float diffRotation = _rotation - srcRotationFrame->_rotation; return this->getEasingAction(CCRotateBy::create(fDuration,diffRotation)); } } ActionFadeFrame::ActionFadeFrame() : _opacity(255) { _frameType = (int)kKeyframeFade; } ActionFadeFrame::~ActionFadeFrame() { } void ActionFadeFrame::setOpacity(int opacity) { _opacity = opacity; } int ActionFadeFrame::getOpacity() { return _opacity; } ActionInterval* ActionFadeFrame::getAction(float fDuration) { return this->getEasingAction(CCFadeTo::create(fDuration,_opacity)); } ActionTintFrame::ActionTintFrame() : _color(Color3B(255,255,255)) { _frameType = (int)kKeyframeTint; } ActionTintFrame::~ActionTintFrame() { } void ActionTintFrame::setColor(Color3B ccolor) { _color = ccolor; } Color3B ActionTintFrame::getColor() { return _color; } ActionInterval* ActionTintFrame::getAction(float fDuration) { return this->getEasingAction(CCTintTo::create(fDuration,_color.r,_color.g,_color.b)); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionFrame.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ActionFRAME_H__ #define __ActionFRAME_H__ #include "CCGeometry.h" #include "CCActionInterval.h" namespace cocostudio { enum FrameType { kKeyframeMove = 0, kKeyframeScale, kKeyframeRotate, kKeyframeTint, kKeyframeFade, kKeyframeMax }; enum class FrameEaseType { Custom = -1, LINERAR = 0, SINE_EASEIN, SINE_EASEOUT, SINE_EASEINOUT, QUAD_EASEIN, QUAD_EASEOUT, QUAD_EASEINOUT, CUBIC_EASEIN, CUBIC_EASEOUT, CUBIC_EASEINOUT, QUART_EASEIN, QUART_EASEOUT, QUART_EASEINOUT, QUINT_EASEIN, QUINT_EASEOUT, QUINT_EASEINOUT, EXPO_EASEIN, EXPO_EASEOUT, EXPO_EASEINOUT, CIRC_EASEIN, CIRC_EASEOUT, CIRC_EASEINOUT, ELASTIC_EASEIN, ELASTIC_EASEOUT, ELASTIC_EASEINOUT, BACK_EASEIN, BACK_EASEOUT, BACK_EASEINOUT, BOUNCE_EASEIN, BOUNCE_EASEOUT, BOUNCE_EASEINOUT, TWEEN_EASING_MAX = 10000 }; /** * @js NA * @lua NA */ class ActionFrame:public cocos2d::Object { public: /** * Default constructor */ ActionFrame(); /** * Default destructor */ virtual ~ActionFrame(); /** * Changes the index of action frame * * @param index the index of action frame */ void setFrameIndex(int index); /** * Gets the index of action frame * * @return the index of action frame */ int getFrameIndex(); /** * Changes the time of action frame * * @param fTime the time of action frame */ void setFrameTime(float fTime); /** * Gets the time of action frame * * @return fTime the time of action frame */ float getFrameTime(); /** * Changes the type of action frame * * @param frameType the type of action frame */ void setFrameType(int frameType); /** * Gets the type of action frame * * @return the type of action frame */ int getFrameType(); /** * Changes the easing type. * * @param easingType the easing type. */ void setEasingType(int easingType); /** * Gets the easing type. * * @return the easing type. */ int getEasingType(); /** * Gets the ActionInterval of ActionFrame. * * @parame duration the duration time of ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getAction(float duration); /** * Gets the ActionInterval of ActionFrame. * * @parame duration the duration time of ActionFrame * * @parame duration the source ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getAction(float duration,ActionFrame* srcFrame); /** *Set the ActionInterval easing parameter. * *@parame parameter the parameter for frame ease * */ virtual void setEasingParameter(std::vector& parameter); protected: /** * Gets the Easing Action of ActionFrame. * * @parame action the duration time of ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getEasingAction(cocos2d::ActionInterval* action); protected: int _frameType; int _frameIndex; float _fTime; FrameEaseType _easingType; std::vector _Parameter; }; /** * @js NA * @lua NA */ class ActionMoveFrame:public ActionFrame { public: /** * Default constructor */ ActionMoveFrame(); /** * Default destructor */ virtual ~ActionMoveFrame(); /** * Changes the move action position. * * @param the move action position. */ void setPosition(cocos2d::Point pos); /** * Gets the move action position. * * @return the move action position. */ cocos2d::Point getPosition(); /** * Gets the ActionInterval of ActionFrame. * * @parame duration the duration time of ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getAction(float duration); protected: cocos2d::Point _position; }; /** * @js NA * @lua NA */ class ActionScaleFrame:public ActionFrame { public: /** * Default constructor */ ActionScaleFrame(); /** * Default destructor */ virtual ~ActionScaleFrame(); /** * Changes the scale action scaleX. * * @param the scale action scaleX. */ void setScaleX(float scaleX); /** * Gets the scale action scaleX. * * @return the scale action scaleX. */ float getScaleX(); /** * Changes the scale action scaleY. * * @param rotation the scale action scaleY. */ void setScaleY(float scaleY); /** * Gets the scale action scaleY. * * @return the the scale action scaleY. */ float getScaleY(); /** * Gets the ActionInterval of ActionFrame. * * @parame duration the duration time of ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getAction(float duration); protected: float _scaleX; float _scaleY; }; /** * @js NA * @lua NA */ class ActionRotationFrame:public ActionFrame { public: /** * Default constructor */ ActionRotationFrame(); /** * Default destructor */ virtual ~ActionRotationFrame(); /** * Changes rotate action rotation. * * @param rotation rotate action rotation. */ void setRotation(float rotation); /** * Gets the rotate action rotation. * * @return the rotate action rotation. */ float getRotation(); /** * Gets the ActionInterval of ActionFrame. * * @parame duration the duration time of ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getAction(float duration); /** * Gets the ActionInterval of ActionFrame. * * @parame duration the duration time of ActionFrame * * @parame duration the source ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getAction(float duration,ActionFrame* srcFrame); public: float _rotation; }; /** * @js NA * @lua NA */ class ActionFadeFrame:public ActionFrame { public: /** * Default constructor */ ActionFadeFrame(); /** * Default destructor */ virtual ~ActionFadeFrame(); /** * Changes the fade action opacity. * * @param opacity the fade action opacity */ void setOpacity(int opacity); /** * Gets the fade action opacity. * * @return the fade action opacity. */ int getOpacity(); /** * Gets the ActionInterval of ActionFrame. * * @parame duration the duration time of ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getAction(float duration); protected: float _opacity; }; /** * @js NA * @lua NA */ class ActionTintFrame:public ActionFrame { public: /** * Default constructor */ ActionTintFrame(); /** * Default destructor */ virtual ~ActionTintFrame(); /** * Changes the tint action color. * * @param ccolor the tint action color */ void setColor(cocos2d::Color3B ccolor); /** * Gets the tint action color. * * @return the tint action color. */ cocos2d::Color3B getColor(); /** * Gets the ActionInterval of ActionFrame. * * @parame duration the duration time of ActionFrame * * @return ActionInterval */ virtual cocos2d::ActionInterval* getAction(float duration); protected: cocos2d::Color3B _color; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionFrameEasing.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include #include "cocostudio/CCActionFrameEasing.h" #include "cocostudio/DictionaryHelper.h" namespace cocostudio { #ifndef M_PI_X_2 #define M_PI_X_2 (float)M_PI * 2.0f #endif ActionFrameEasing::ActionFrameEasing() { } ActionFrameEasing::~ActionFrameEasing() { } float ActionFrameEasing::bounceTime(float t) { if (t < 1 / 2.75) { return 7.5625f * t * t; } else if (t < 2 / 2.75) { t -= 1.5f / 2.75f; return 7.5625f * t * t + 0.75f; } else if (t < 2.5 / 2.75) { t -= 2.25f / 2.75f; return 7.5625f * t * t + 0.9375f; } t -= 2.625f / 2.75f; return 7.5625f * t * t + 0.984375f; } float ActionFrameEasing::easeValue(float t) { if (_type == FrameEasingType::kframeEasingInstant) { if (t < 1) return 0; else return 1; } else if (_type == FrameEasingType::kframeEasingLinear) { return t; } else if (_type == FrameEasingType::kframeEasingCubicIn) { float rate = _fValue; return powf(t,rate); } else if (_type == FrameEasingType::kframeEasingCubicOut) { float rate = _fValue; return powf(t,1/rate); } else if (_type == FrameEasingType::kframeEasingCubicInOut) { float rate = _fValue; t *= 2; if (t < 1) { return 0.5f * powf (t, rate); } else { return 1.0f - 0.5f * powf(2-t, rate); } } else if (_type == FrameEasingType::kframeEasingElasticIn) { float period = _fValue; float newT = 0; if (t == 0 || t == 1) newT = t; else { float s = period / 4; t = t - 1; newT = -powf(2, 10 * t) * sinf( (t-s) * M_PI_X_2 / period); } return newT; } else if (_type == FrameEasingType::kframeEasingElasticOut) { float period = _fValue; float newT = 0; if (t == 0 || t == 1) { newT = t; } else { float s = period / 4; newT = powf(2, -10 * t) * sinf( (t-s) *M_PI_X_2 / period) + 1; } return newT; } else if (_type == FrameEasingType::kframeEasingElasticInOut) { float period = _fValue; float newT = 0; if( t == 0 || t == 1 ) newT = t; else { t = t * 2; if(! period ) period = 0.3f * 1.5f; float s = period / 4; t = t -1; if( t < 0 ) newT = -0.5f * powf(2, 10 * t) * sinf((t - s) * M_PI_X_2 / period); else newT = powf(2, -10 * t) * sinf((t - s) * M_PI_X_2 / period) * 0.5f + 1; } return newT; } else if (_type == FrameEasingType::kframeEasingBounceIn) { float newT = 1 - bounceTime(1-t); return newT; } else if (_type == FrameEasingType::kframeEasingBounceOut) { float newT = bounceTime(t); return newT; } else if (_type == FrameEasingType::kframeEasingBounceInOut) { float newT = 0; if (t < 0.5) { t = t * 2; newT = (1 - bounceTime(1-t) ) * 0.5f; } else newT = bounceTime(t * 2 - 1) * 0.5f + 0.5f; return newT; } else if (_type == FrameEasingType::kframeEasingBackIn) { float overshoot = 1.70158f; return t * t * ((overshoot + 1) * t - overshoot); } else if (_type == FrameEasingType::kframeEasingBackOut) { float overshoot = 1.70158f; t = t - 1; return t * t * ((overshoot + 1) * t + overshoot) + 1; } else if (_type == FrameEasingType::kframeEasingBackInOut) { float overshoot = 1.70158f * 1.525f; t = t * 2; if (t < 1) return (t * t * ((overshoot + 1) * t - overshoot)) / 2; else { t = t - 2; return (t * t * ((overshoot + 1) * t + overshoot)) / 2 + 1; } } return 0; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionFrameEasing.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ActionFrameEasing_H__ #define __ActionFrameEasing_H__ #include "CCObject.h" namespace cocostudio { enum FrameEasingType { kframeEasingInstant, kframeEasingLinear, kframeEasingCubicIn, kframeEasingCubicOut, kframeEasingCubicInOut, kframeEasingElasticIn, kframeEasingElasticOut, kframeEasingElasticInOut, kframeEasingBounceIn, kframeEasingBounceOut, kframeEasingBounceInOut, kframeEasingBackIn, kframeEasingBackOut, kframeEasingBackInOut, }; /** * @js NA * @lua NA */ class ActionFrameEasing:public cocos2d::Object { protected: FrameEasingType _type; float _fValue; public: ActionFrameEasing(); virtual ~ActionFrameEasing(); float bounceTime(float t); float easeValue(float t); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionManagerEx.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCActionManagerEx.h" #include "cocostudio/DictionaryHelper.h" using namespace cocos2d; namespace cocostudio { static ActionManagerEx* sharedActionManager = nullptr; ActionManagerEx* ActionManagerEx::getInstance() { if (!sharedActionManager) { sharedActionManager = new ActionManagerEx(); } return sharedActionManager; } void ActionManagerEx::destroyInstance() { CC_SAFE_DELETE(sharedActionManager); } ActionManagerEx::ActionManagerEx() { } ActionManagerEx::~ActionManagerEx() { _actionDic.clear(); } void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::Value &dic,Object* root) { std::string path = jsonName; ssize_t pos = path.find_last_of("/"); std::string fileName = path.substr(pos+1,path.length()); CCLOG("filename == %s",fileName.c_str()); cocos2d::Vector actionList; int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist"); for (int i=0; iautorelease(); const rapidjson::Value &actionDic = DICTOOL->getDictionaryFromArray_json(dic, "actionlist", i); action->initWithDictionary(actionDic,root); actionList.pushBack(action); } _actionDic.insert(std::pair>(fileName, actionList)); } ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* actionName) { auto iterator = _actionDic.find(jsonName); if (iterator == _actionDic.end()) { return nullptr; } auto actionList = iterator->second; for (int i = 0; i < actionList.size(); i++) { ActionObject* action = actionList.at(i); if (strcmp(actionName, action->getName()) == 0) { return action; } } return nullptr; } ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* actionName) { ActionObject* action = getActionByName(jsonName,actionName); if (action) { action->play(); } return action; } ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* actionName, CallFunc* func) { ActionObject* action = getActionByName(jsonName,actionName); if (action) { action->play(func); } return action; } void ActionManagerEx::releaseActions() { _actionDic.clear(); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionManagerEx.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ActionMANAGER_H__ #define __ActionMANAGER_H__ #include "cocostudio/CCActionObject.h" #include "cocostudio/DictionaryHelper.h" namespace cocostudio { class ActionManagerEx:public cocos2d::Object { public: /** * Default constructor * @js ctor */ ActionManagerEx(); /** * Default destructor * @js NA * @lua NA */ virtual ~ActionManagerEx(); /** * Gets the static instance of ActionManager. * @js getInstance * @lua getInstance */ static ActionManagerEx* getInstance(); /** * Purges ActionManager point. * @js purge * @lua destroyActionManager */ static void destroyInstance(); /** * Gets an ActionObject with a name. * * @param jsonName UI file name * * @param actionName action name in the UI file. * * @return ActionObject which named as the param name */ ActionObject* getActionByName(const char* jsonName,const char* actionName); /** * Play an Action with a name. * * @param jsonName UI file name * * @param actionName action name in teh UIfile. * * @return ActionObject which named as the param name */ ActionObject* playActionByName(const char* jsonName,const char* actionName); /** * Play an Action with a name. * * @param jsonName UI file name * * @param actionName action name in teh UIfile. * * @param func ui action call back */ ActionObject* playActionByName(const char* jsonName,const char* actionName, cocos2d::CallFunc* func); /*init properties with json dictionay*/ void initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Object* root); /** * Release all actions. * */ void releaseActions(); protected: std::unordered_map> _actionDic; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionNode.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCActionNode.h" #include "cocostudio/CCActionFrameEasing.h" #include "cocostudio/DictionaryHelper.h" #include "gui/UIWidget.h" #include "gui/UIHelper.h" using namespace cocos2d; using namespace gui; namespace cocostudio { ActionNode::ActionNode() : _currentFrameIndex(0) , _destFrameIndex(0) , _fUnitTime(0.1f) , _actionTag(0) , _actionSpawn(nullptr) , _action(nullptr) , _object(nullptr) , _frameArrayNum(0) { _frameArrayNum = (int)kKeyframeMax; for(int i = 0; i < _frameArrayNum; i++) { _frameArray.push_back( new cocos2d::Vector()); } } ActionNode::~ActionNode() { if (_action == nullptr) { CC_SAFE_RELEASE_NULL(_actionSpawn); } else { CC_SAFE_RELEASE_NULL(_action); } for (auto object : _frameArray) { object->clear(); CC_SAFE_DELETE(object); } _frameArray.clear(); } void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root) { setActionTag(DICTOOL->getIntValue_json(dic, "ActionTag")); int actionFrameCount = DICTOOL->getArrayCount_json(dic, "actionframelist"); for (int i=0; igetDictionaryFromArray_json(dic, "actionframelist", i); int frameInex = DICTOOL->getIntValue_json(actionFrameDic,"frameid"); bool existPosition = DICTOOL->checkObjectExist_json(actionFrameDic,"positionx"); if (existPosition) { float positionX = DICTOOL->getFloatValue_json(actionFrameDic, "positionx"); float positionY = DICTOOL->getFloatValue_json(actionFrameDic, "positiony"); ActionMoveFrame* actionFrame = new ActionMoveFrame(); actionFrame->autorelease(); actionFrame->setFrameIndex(frameInex); actionFrame->setPosition(Point(positionX, positionY)); auto cActionArray = _frameArray.at((int)kKeyframeMove); cActionArray->pushBack(actionFrame); } bool existScale = DICTOOL->checkObjectExist_json(actionFrameDic,"scalex"); if (existScale) { float scaleX = DICTOOL->getFloatValue_json(actionFrameDic, "scalex"); float scaleY = DICTOOL->getFloatValue_json(actionFrameDic, "scaley"); ActionScaleFrame* actionFrame = new ActionScaleFrame(); actionFrame->autorelease(); actionFrame->setFrameIndex(frameInex); actionFrame->setScaleX(scaleX); actionFrame->setScaleY(scaleY); auto cActionArray = _frameArray.at((int)kKeyframeScale); cActionArray->pushBack(actionFrame); } bool existRotation = DICTOOL->checkObjectExist_json(actionFrameDic,"rotation"); if (existRotation) { float rotation = DICTOOL->getFloatValue_json(actionFrameDic, "rotation"); ActionRotationFrame* actionFrame = new ActionRotationFrame(); actionFrame->autorelease(); actionFrame->setFrameIndex(frameInex); actionFrame->setRotation(rotation); auto cActionArray = _frameArray.at((int)kKeyframeRotate); cActionArray->pushBack(actionFrame); } bool existOpacity = DICTOOL->checkObjectExist_json(actionFrameDic,"opacity"); if (existOpacity) { int opacity = DICTOOL->getIntValue_json(actionFrameDic, "opacity"); ActionFadeFrame* actionFrame = new ActionFadeFrame(); actionFrame->autorelease(); actionFrame->setFrameIndex(frameInex); actionFrame->setOpacity(opacity); auto cActionArray = _frameArray.at((int)kKeyframeTint); cActionArray->pushBack(actionFrame); } bool existColor = DICTOOL->checkObjectExist_json(actionFrameDic,"colorr"); if (existColor) { int colorR = DICTOOL->getIntValue_json(actionFrameDic, "colorr"); int colorG = DICTOOL->getIntValue_json(actionFrameDic, "colorg"); int colorB = DICTOOL->getIntValue_json(actionFrameDic, "colorb"); ActionTintFrame* actionFrame = new ActionTintFrame(); actionFrame->autorelease(); actionFrame->setFrameIndex(frameInex); actionFrame->setColor(Color3B(colorR,colorG,colorB)); auto cActionArray = _frameArray.at((int)kKeyframeFade); cActionArray->pushBack(actionFrame); } } initActionNodeFromRoot(root); } void ActionNode::initActionNodeFromRoot(Object* root) { Node* rootNode = dynamic_cast(root); if (rootNode != nullptr) { Widget* rootWidget = dynamic_cast(root); if (rootWidget != nullptr) { Widget* widget = Helper::seekActionWidgetByActionTag(rootWidget, getActionTag()); if (widget != nullptr) { setObject(widget); } } } } void ActionNode::setUnitTime(float fTime) { _fUnitTime = fTime; this->refreshActionProperty(); } float ActionNode::getUnitTime() { return _fUnitTime; } void ActionNode::setActionTag(int tag) { _actionTag = tag; } int ActionNode::getActionTag() { return _actionTag; } void ActionNode::setObject(Object* node) { _object = node; } Object* ActionNode::getObject() { return _object; } Node* ActionNode::getActionNode() { Node* cNode = dynamic_cast(_object); if (cNode != nullptr) { return cNode; } else { Widget* rootWidget = dynamic_cast(_object); if (rootWidget != nullptr) { return rootWidget; } } return nullptr; } void ActionNode::insertFrame(int index, ActionFrame* frame) { if (frame == nullptr) { return; } int frameType = frame->getFrameType(); if(frameType < _frameArray.size()) { auto cArray = _frameArray.at(frameType); cArray->insert(index, frame); } } void ActionNode::addFrame(ActionFrame* frame) { if (frame == nullptr) { return; } int frameType = frame->getFrameType(); if(frameType < _frameArray.size()) { auto cArray = _frameArray.at(frameType); cArray->pushBack(frame); } } void ActionNode::deleteFrame(ActionFrame* frame) { if (frame == nullptr) { return; } int frameType = frame->getFrameType(); if(frameType < _frameArray.size()) { auto cArray = _frameArray.at(frameType); cArray->eraseObject(frame); } } void ActionNode::clearAllFrame() { for(auto array : _frameArray) { array->clear(); } } Spawn * ActionNode::refreshActionProperty() { if ( _object == nullptr ) { return nullptr; } Vector cSpawnArray; for (int n = 0; n < _frameArrayNum; n++) { auto cArray = _frameArray.at(n); if (cArray->size() <= 0) { continue; } Vector cSequenceArray; auto frameCount = cArray->size(); for (int i = 0; i < frameCount; i++) { auto frame = cArray->at(i); if (i == 0) { } else { auto srcFrame = cArray->at(i-1); float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime(); Action* cAction = frame->getAction(duration); if(cAction != nullptr) cSequenceArray.pushBack(static_cast(cAction)); } } Sequence* cSequence = Sequence::create(cSequenceArray); if (cSequence != nullptr) { cSpawnArray.pushBack(cSequence); } } if (_action == nullptr) { CC_SAFE_RELEASE_NULL(_actionSpawn); } else { CC_SAFE_RELEASE_NULL(_action); } _actionSpawn = Spawn::create(cSpawnArray); CC_SAFE_RETAIN(_actionSpawn); return _actionSpawn; } void ActionNode::playAction() { if ( _object == nullptr || _actionSpawn == nullptr) { return; } if (_action!=nullptr) { _action->release(); } _action = Sequence::create(_actionSpawn, nullptr); _action->retain(); this->runAction(); } void ActionNode::runAction() { Node* cNode = this->getActionNode(); if (cNode != nullptr && _action != nullptr) { cNode->runAction(_action); } } void ActionNode::stopAction() { Node* cNode = this->getActionNode(); if (cNode != nullptr && _action != nullptr) { cNode->stopAction(_action); } } int ActionNode::getFirstFrameIndex() { int frameindex = 99999; bool bFindFrame = false; for (int n = 0; n < _frameArrayNum; n++) { auto cArray = _frameArray.at(n); if (cArray->empty()) { continue; } bFindFrame = true; auto frame = cArray->at(0); int iFrameIndex = frame->getFrameIndex(); if (frameindex > iFrameIndex) { frameindex = iFrameIndex; } } if (!bFindFrame) { frameindex = 0; } return frameindex; } int ActionNode::getLastFrameIndex() { int frameindex = -1; bool bFindFrame = false; for (int n = 0; n < _frameArrayNum; n++) { auto cArray = _frameArray.at(n); if (cArray->empty()) { continue; } bFindFrame = true; ssize_t lastInex = cArray->size() - 1; auto frame = cArray->at(lastInex); int iFrameIndex = frame->getFrameIndex(); if (frameindex < iFrameIndex) { frameindex = iFrameIndex; } } if (!bFindFrame) { frameindex = 0; } return frameindex; } bool ActionNode::updateActionToTimeLine(float fTime) { bool bFindFrame = false; ActionFrame* srcFrame = nullptr; // ActionFrame* destFrame = nullptr; for (int n = 0; n < _frameArrayNum; n++) { auto cArray = _frameArray.at(n); if (cArray->empty()) { continue; } ssize_t frameCount = cArray->size(); for (int i = 0; i < frameCount; i++) { auto frame = cArray->at(i); if (frame->getFrameIndex()*getUnitTime() == fTime) { this->easingToFrame(1.0f,1.0f,nullptr,frame); bFindFrame = true; break; } else if (frame->getFrameIndex()*getUnitTime() > fTime) { if (i == 0) { this->easingToFrame(1.0f,1.0f,nullptr,frame); bFindFrame = false; } else { srcFrame = cArray->at(i-1); float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex())*getUnitTime(); float delaytime = fTime - srcFrame->getFrameIndex()*getUnitTime(); this->easingToFrame(duration,1.0f,nullptr,srcFrame); //float easingTime = ActionFrameEasing::bounceTime(delaytime); this->easingToFrame(duration,delaytime/duration,srcFrame,frame); bFindFrame = true; } break; } } } return bFindFrame; } void ActionNode::easingToFrame(float duration,float delayTime,ActionFrame* srcFrame,ActionFrame* destFrame) { Action* cAction = destFrame->getAction(duration,srcFrame); Node* cNode = this->getActionNode(); if (cAction == nullptr || cNode == nullptr) { return; } cAction->startWithTarget(cNode); cAction->update(delayTime); } bool ActionNode::isActionDoneOnce() { if (_action == nullptr) { return true; } return _action->isDone(); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionNode.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ActionNODE_H__ #define __ActionNODE_H__ #include "cocostudio/CCActionFrame.h" #include "cocostudio/DictionaryHelper.h" namespace cocostudio { /** * @js NA * @lua NA */ class ActionNode:public cocos2d::Object { public: /** * Default constructor */ ActionNode(); /** * Default destructor */ virtual ~ActionNode(); /** * Sets the time interval of frame. * * @param fTime the time interval of frame */ void setUnitTime(float fTime); /** * Gets the time interval of frame. * * @return fTime the time interval of frame */ float getUnitTime(); /** * Sets tag for ActionNode * * @param tag tag of ActionNode */ void setActionTag(int tag); /** * Gets tag for ActionNode * * @return tag tag of ActionNode */ int getActionTag(); /** * Sets node which will run a action. * * @param node which will run a action */ void setObject(cocos2d::Object* node); /** * Gets node which will run a action. * * @return node which will run a action */ cocos2d::Object* getObject(); /** * Insets a ActionFrame to ActionNode. * * @param index the index of ActionFrame * * @param frame the ActionFrame which will be inserted */ void insertFrame(int index, ActionFrame* frame); /** * Pushs back a ActionFrame to ActionNode. * * @param frame the ActionFrame which will be added */ void addFrame(ActionFrame* frame); /** * Remove a ActionFrame from ActionNode. * * @param frame the ActionFrame which will be removed */ void deleteFrame(ActionFrame* frame ); /** * Remove all ActionFrames from ActionNode. */ void clearAllFrame(); /** * Gets index of first ActionFrame. * * @return index of first ActionFrame */ int getFirstFrameIndex(); /** * Gets index of last ActionFrame. * * @return index of last ActionFrame */ int getLastFrameIndex(); /** * Updates action states to some time. * * @param fTime the time when need to update */ virtual bool updateActionToTimeLine(float fTime); /** * Play the action. */ virtual void playAction(); /** * Stop the action. */ virtual void stopAction(); /*init properties with a json dictionary*/ virtual void initWithDictionary(const rapidjson::Value& dic,Object* root); /** * Gets if the action is done once time. * * @return that if the action is done once time */ virtual bool isActionDoneOnce(); protected: int _currentFrameIndex; int _destFrameIndex; float _fUnitTime; int _actionTag; cocos2d::Spawn * _actionSpawn; cocos2d::Action* _action; cocos2d::Object* _object; std::vector*> _frameArray; int _frameArrayNum; protected: virtual cocos2d::Node* getActionNode(); virtual cocos2d::Spawn * refreshActionProperty(); virtual void runAction(); virtual void initActionNodeFromRoot(cocos2d::Object* root); virtual void easingToFrame(float duration,float delayTime,ActionFrame* srcFrame,ActionFrame* destFrame); }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionObject.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCActionObject.h" #include "cocostudio/DictionaryHelper.h" #include "CCDirector.h" #include "CCScheduler.h" #include "CCActionInstant.h" using namespace cocos2d; namespace cocostudio { ActionObject::ActionObject() : _name("") , _loop(false) , _bPause(false) , _bPlaying(false) , _fUnitTime(0.1f) , _currentTime(0.0f) , _pScheduler(nullptr) , _CallBack(nullptr) , _fTotalTime(0.0f) { _pScheduler = Director::getInstance()->getScheduler(); CC_SAFE_RETAIN(_pScheduler); } ActionObject::~ActionObject() { _actionNodeList.clear(); CC_SAFE_RELEASE(_pScheduler); } void ActionObject::setName(const char* name) { _name.assign(name); } const char* ActionObject::getName() { return _name.c_str(); } void ActionObject::setLoop(bool bLoop) { _loop = bLoop; } bool ActionObject::getLoop() { return _loop; } void ActionObject::setUnitTime(float fTime) { _fUnitTime = fTime; for(const auto &e : _actionNodeList) { e->setUnitTime(_fUnitTime); } } float ActionObject::getUnitTime() { return _fUnitTime; } float ActionObject::getCurrentTime() { return _currentTime; } void ActionObject::setCurrentTime(float fTime) { _currentTime = fTime; } float ActionObject::getTotalTime() { return _fTotalTime; } bool ActionObject::isPlaying() { return _bPlaying; } void ActionObject::initWithDictionary(const rapidjson::Value& dic, Object* root) { setName(DICTOOL->getStringValue_json(dic, "name")); setLoop(DICTOOL->getBooleanValue_json(dic, "loop")); setUnitTime(DICTOOL->getFloatValue_json(dic, "unittime")); int actionNodeCount = DICTOOL->getArrayCount_json(dic, "actionnodelist"); int maxLength = 0; for (int i=0; iautorelease(); const rapidjson::Value& actionNodeDic = DICTOOL->getDictionaryFromArray_json(dic, "actionnodelist", i); actionNode->initWithDictionary(actionNodeDic,root); actionNode->setUnitTime(getUnitTime()); _actionNodeList.pushBack(actionNode); int length = actionNode->getLastFrameIndex() - actionNode->getFirstFrameIndex(); if(length > maxLength) maxLength = length; } _fTotalTime = maxLength*_fTotalTime; } void ActionObject::addActionNode(ActionNode* node) { if (node == nullptr) { return; } _actionNodeList.pushBack(node); node->setUnitTime(_fUnitTime); } void ActionObject::removeActionNode(ActionNode* node) { if (node == nullptr) { return; } _actionNodeList.eraseObject(node); } void ActionObject::play() { stop(); this->updateToFrameByTime(0.0f); for(const auto &e : _actionNodeList) { e->playAction(); } if (_loop) { _pScheduler->scheduleSelector(schedule_selector(ActionObject::simulationActionUpdate), this, 0.0f , kRepeatForever, 0.0f, false); } else { _pScheduler->scheduleSelector(schedule_selector(ActionObject::simulationActionUpdate), this, 0.0f, false); } } void ActionObject::play(CallFunc* func) { this->play(); this->_CallBack = func; } void ActionObject::pause() { _bPause = true; } void ActionObject::stop() { for(const auto &e : _actionNodeList) { e->stopAction(); } _pScheduler->unscheduleSelector(schedule_selector(ActionObject::simulationActionUpdate), this); _bPause = false; } void ActionObject::updateToFrameByTime(float fTime) { _currentTime = fTime; for(const auto &e : _actionNodeList) { e->updateActionToTimeLine(fTime); } } void ActionObject::simulationActionUpdate(float dt) { bool isEnd = true; for(const auto &e : _actionNodeList) { if (!e->isActionDoneOnce()) { isEnd = false; break; } } if (isEnd) { if (_CallBack != nullptr) { _CallBack->execute(); } if (_loop) { this->play(); } } } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCActionObject.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __ActionObject_H__ #define __ActionObject_H__ #include "CCActionNode.h" #include "cocostudio/DictionaryHelper.h" namespace cocostudio { /** * @js NA * @lua NA */ class ActionObject:public cocos2d::Object { public: /** * Default constructor */ ActionObject(); /** * Default destructor */ virtual ~ActionObject(); /** * Sets name for object * * @param name name of object */ void setName(const char* name); /** * Sets name for object * * @return name of object */ const char* getName(); /** * Sets if the action will loop play. * * @param bLoop that if the action will loop play */ void setLoop(bool bLoop); /** * Gets if the action will loop play. * * @return that if the action will loop play */ bool getLoop(); /** * Sets the time interval of frame. * * @param fTime the time interval of frame */ void setUnitTime(float fTime); /** * Gets the time interval of frame. * * @return fTime the time interval of frame */ float getUnitTime(); /** * Sets the current time of frame. * * @param fTime the current time of frame */ void setCurrentTime(float fTime); /** * Gets the current time of frame. * * @return fTime the current time of frame */ float getCurrentTime(); /** * Gets the total time of frame. * * @return fTime the current time of frame */ float getTotalTime(); /** * Return if the action is playing. * * @return true if the action is playing, false the otherwise */ bool isPlaying(); /** * Play the action. */ void play(); /** * Play the action. * * @ Action Call Back */ void play(cocos2d::CallFunc* func); /** * Pause the action. */ void pause(); /** * Stop the action. */ void stop(); /** * Adds a ActionNode to play the action. * * @node the ActionNode which will play the action */ void addActionNode(ActionNode* node); /** * Removes a ActionNode which play the action. * * @node the ActionNode which play the action */ void removeActionNode(ActionNode* node); /*update frame method*/ void updateToFrameByTime(float fTime); /*init properties with a json dictionary*/ void initWithDictionary(const rapidjson::Value& dic,Object* root); /*scheduler update function*/ void simulationActionUpdate(float dt); protected: cocos2d::Vector _actionNodeList;/*actionnode*/ std::string _name; bool _loop; bool _bPause; bool _bPlaying; float _fUnitTime; float _currentTime; cocos2d::Scheduler *_pScheduler; cocos2d::CallFunc *_CallBack; float _fTotalTime; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCArmature.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCArmature.h" #include "cocostudio/CCArmatureDataManager.h" #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDataReaderHelper.h" #include "cocostudio/CCDatas.h" #include "cocostudio/CCSkin.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" #include "CCShaderCache.h" #include "CCDrawingPrimitives.h" #if ENABLE_PHYSICS_BOX2D_DETECT #include "Box2D/Box2D.h" #elif ENABLE_PHYSICS_CHIPMUNK_DETECT #include "chipmunk.h" #endif using namespace cocos2d; namespace cocostudio { Armature *Armature::create() { Armature *armature = new Armature(); if (armature && armature->init()) { armature->autorelease(); return armature; } CC_SAFE_DELETE(armature); return nullptr; } Armature *Armature::create(const std::string& name) { Armature *armature = new Armature(); if (armature && armature->init(name)) { armature->autorelease(); return armature; } CC_SAFE_DELETE(armature); return nullptr; } Armature *Armature::create(const std::string& name, Bone *parentBone) { Armature *armature = new Armature(); if (armature && armature->init(name, parentBone)) { armature->autorelease(); return armature; } CC_SAFE_DELETE(armature); return nullptr; } Armature::Armature() : _armatureData(nullptr) , _batchNode(nullptr) , _parentBone(nullptr) , _armatureTransformDirty(true) , _animation(nullptr) { } Armature::~Armature(void) { _boneDic.clear(); _topBoneList.clear(); CC_SAFE_DELETE(_animation); } bool Armature::init() { return init(""); } bool Armature::init(const std::string& name) { bool bRet = false; do { removeAllChildren(); CC_SAFE_DELETE(_animation); _animation = new ArmatureAnimation(); _animation->init(this); _boneDic.clear(); _topBoneList.clear(); _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; _name = name; ArmatureDataManager *armatureDataManager = ArmatureDataManager::getInstance(); if(!_name.empty()) { AnimationData *animationData = armatureDataManager->getAnimationData(name); CCASSERT(animationData, "AnimationData not exist! "); _animation->setAnimationData(animationData); ArmatureData *armatureData = armatureDataManager->getArmatureData(name); CCASSERT(armatureData, ""); _armatureData = armatureData; for (auto& element : armatureData->boneDataDic) { Bone *bone = createBone(element.first.c_str()); //! init bone's Tween to 1st movement's 1st frame do { MovementData *movData = animationData->getMovement(animationData->movementNames.at(0).c_str()); CC_BREAK_IF(!movData); MovementBoneData *movBoneData = movData->getMovementBoneData(bone->getName().c_str()); CC_BREAK_IF(!movBoneData || movBoneData->frameList.size() <= 0); FrameData *frameData = movBoneData->getFrameData(0); CC_BREAK_IF(!frameData); bone->getTweenData()->copy(frameData); bone->changeDisplayWithIndex(frameData->displayIndex, false); } while (0); } update(0); updateOffsetPoint(); } else { _name = "new_armature"; _armatureData = ArmatureData::create(); _armatureData->name = _name; AnimationData *animationData = AnimationData::create(); animationData->name = _name; armatureDataManager->addArmatureData(_name.c_str(), _armatureData); armatureDataManager->addAnimationData(_name.c_str(), animationData); _animation->setAnimationData(animationData); } setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); setCascadeOpacityEnabled(true); setCascadeColorEnabled(true); bRet = true; } while (0); return bRet; } bool Armature::init(const std::string& name, Bone *parentBone) { _parentBone = parentBone; return init(name); } Bone *Armature::createBone(const std::string& boneName) { Bone *existedBone = getBone(boneName); if(existedBone != nullptr) return existedBone; BoneData *boneData = (BoneData *)_armatureData->getBoneData(boneName); std::string parentName = boneData->parentName; Bone *bone = nullptr; if( parentName.length() != 0 ) { createBone(parentName.c_str()); bone = Bone::create(boneName); addBone(bone, parentName.c_str()); } else { bone = Bone::create(boneName); addBone(bone, ""); } bone->setBoneData(boneData); bone->getDisplayManager()->changeDisplayWithIndex(-1, false); return bone; } void Armature::addBone(Bone *bone, const std::string& parentName) { CCASSERT( bone != nullptr, "Argument must be non-nil"); CCASSERT(_boneDic.at(bone->getName()) == nullptr, "bone already added. It can't be added again"); if (!parentName.empty()) { Bone *boneParent = _boneDic.at(parentName); if (boneParent) { boneParent->addChildBone(bone); } else { _topBoneList.pushBack(bone); } } else { _topBoneList.pushBack(bone); } bone->setArmature(this); _boneDic.insert(bone->getName(), bone); addChild(bone); } void Armature::removeBone(Bone *bone, bool recursion) { CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!"); bone->setArmature(nullptr); bone->removeFromParent(recursion); if (_topBoneList.contains(bone)) { _topBoneList.eraseObject(bone); } _boneDic.erase(bone->getName()); removeChild(bone, true); } Bone *Armature::getBone(const std::string& name) const { return _boneDic.at(name); } void Armature::changeBoneParent(Bone *bone, const std::string& parentName) { CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!"); if(bone->getParentBone()) { bone->getParentBone()->getChildren().eraseObject(bone); bone->setParentBone(nullptr); } if (!parentName.empty()) { Bone *boneParent = _boneDic.at(parentName); if (boneParent) { boneParent->addChildBone(bone); if (_topBoneList.contains(bone)) { _topBoneList.eraseObject(bone); } } else { _topBoneList.pushBack(bone); } } } const cocos2d::Map& Armature::getBoneDic() const { return _boneDic; } const kmMat4& Armature::getNodeToParentTransform() const { if (_transformDirty) _armatureTransformDirty = true; return Node::getNodeToParentTransform(); } void Armature::updateOffsetPoint() { // Set contentsize and Calculate anchor point. Rect rect = getBoundingBox(); setContentSize(rect.size); _offsetPoint = Point(-rect.origin.x, -rect.origin.y); if (rect.size.width != 0 && rect.size.height != 0) { setAnchorPoint(Point(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height)); } } void Armature::setAnchorPoint(const Point& point) { if( ! point.equals(_anchorPoint)) { _anchorPoint = point; _anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y); _realAnchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y); _transformDirty = _inverseDirty = true; } } const Point& Armature::getAnchorPointInPoints() const { return _realAnchorPointInPoints; } void Armature::setAnimation(ArmatureAnimation *animation) { _animation = animation; } ArmatureAnimation *Armature::getAnimation() const { return _animation; } bool Armature::getArmatureTransformDirty() const { return _armatureTransformDirty; } void Armature::update(float dt) { _animation->update(dt); for(const auto &bone : _topBoneList) { bone->update(dt); } _armatureTransformDirty = false; } void Armature::draw() { if (_parentBone == nullptr && _batchNode == nullptr) { CC_NODE_DRAW_SETUP(); } for (auto& object : _children) { if (Bone *bone = dynamic_cast(object)) { Node *node = bone->getDisplayRenderNode(); if (nullptr == node) continue; switch (bone->getDisplayRenderNodeType()) { case CS_DISPLAY_SPRITE: { Skin *skin = static_cast(node); skin->updateTransform(); bool blendDirty = bone->isBlendDirty(); if (blendDirty) { skin->setBlendFunc(bone->getBlendFunc()); } skin->draw(); } break; case CS_DISPLAY_ARMATURE: { node->draw(); } break; default: { node->visit(); CC_NODE_DRAW_SETUP(); } break; } } else if(Node *node = dynamic_cast(object)) { node->visit(); CC_NODE_DRAW_SETUP(); } } } void Armature::onEnter() { Node::onEnter(); scheduleUpdate(); } void Armature::onExit() { Node::onExit(); unscheduleUpdate(); } void Armature::visit() { // quick return if not visible. children won't be drawn. if (!_visible) { return; } kmGLPushMatrix(); transform(); sortAllChildren(); draw(); // reset for next frame _orderOfArrival = 0; kmGLPopMatrix(); } Rect Armature::getBoundingBox() const { float minx, miny, maxx, maxy = 0; bool first = true; Rect boundingBox = Rect(0, 0, 0, 0); for (const auto& object : _children) { if (Bone *bone = dynamic_cast(object)) { Rect r = bone->getDisplayManager()->getBoundingBox(); if(first) { minx = r.getMinX(); miny = r.getMinY(); maxx = r.getMaxX(); maxy = r.getMaxY(); first = false; } else { minx = r.getMinX() < boundingBox.getMinX() ? r.getMinX() : boundingBox.getMinX(); miny = r.getMinY() < boundingBox.getMinY() ? r.getMinY() : boundingBox.getMinY(); maxx = r.getMaxX() > boundingBox.getMaxX() ? r.getMaxX() : boundingBox.getMaxX(); maxy = r.getMaxY() > boundingBox.getMaxY() ? r.getMaxY() : boundingBox.getMaxY(); } boundingBox.setRect(minx, miny, maxx - minx, maxy - miny); } } return RectApplyTransform(boundingBox, getNodeToParentTransform()); } Bone *Armature::getBoneAtPoint(float x, float y) const { long length = _children.size(); Bone *bs; for(long i = length - 1; i >= 0; i--) { bs = static_cast( _children.at(i) ); if(bs->getDisplayManager()->containPoint(x, y)) { return bs; } } return nullptr; } void Armature::setParentBone(Bone *parentBone) { _parentBone = parentBone; for (auto& element : _boneDic) { element.second->setArmature(this); } } Bone *Armature::getParentBone() const { return _parentBone; } #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT void CCArmature::setColliderFilter(ColliderFilter *filter) { for (auto& element : _boneDic) { element.second->setColliderFilter(filter); } } #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX void CCArmature::drawContour() { for(auto& element : _boneDic) { Bone *bone = element.second; ColliderDetector *detector = bone->getColliderDetector(); if (!detector) continue; const cocos2d::Vector& bodyList = detector->getColliderBodyList(); for (auto& object : bodyList) { ColliderBody *body = static_cast(object); const std::vector &vertexList = body->getCalculatedVertexList(); unsigned long length = vertexList.size(); Point *points = new Point[length]; for (unsigned long i = 0; iSetUserData(this); for(auto& object : _children) { if (Bone *bone = dynamic_cast(object)) { auto displayList = bone->getDisplayManager()->getDecorativeDisplayList(); for(auto displayObject : displayList) { ColliderDetector *detector = static_cast(displayObject)->getColliderDetector(); if (detector != nullptr) { detector->setBody(_body); } } } } } b2Fixture *Armature::getShapeList() { if (_body) { return _body->GetFixtureList(); } else { return nullptr; } } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT cpBody *Armature::getBody() const { return _body; } void Armature::setBody(cpBody *body) { if (_body == body) { return; } _body = body; _body->data = this; for (const auto& object : _children) { if (Bone *bone = dynamic_cast(object)) { auto displayList = bone->getDisplayManager()->getDecorativeDisplayList(); for (const auto& displayObject : displayList) { auto detector = displayObject->getColliderDetector(); if (detector != nullptr) { detector->setBody(body); } }); } } } cpShape *Armature::getShapeList() { if (_body) { return _body->shapeList_private; } else { return nullptr; } } #endif } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCArmature.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCARMATURE_H__ #define __CCARMATURE_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCBone.h" #include "cocostudio/CCBatchNode.h" #include "cocostudio/CCArmatureAnimation.h" #include "cocostudio/CCSpriteFrameCacheHelper.h" #include "cocostudio/CCArmatureDataManager.h" class b2Body; struct cpBody; namespace cocostudio { CC_DEPRECATED_ATTRIBUTE typedef ProcessBase CCProcessBase; CC_DEPRECATED_ATTRIBUTE typedef BaseData CCBaseData; CC_DEPRECATED_ATTRIBUTE typedef DisplayData CCDisplayData; CC_DEPRECATED_ATTRIBUTE typedef SpriteDisplayData CCSpriteDisplayData; CC_DEPRECATED_ATTRIBUTE typedef ArmatureDisplayData CCArmatureDisplayData; CC_DEPRECATED_ATTRIBUTE typedef ParticleDisplayData CCParticleDisplayData; CC_DEPRECATED_ATTRIBUTE typedef BoneData CCBoneData; CC_DEPRECATED_ATTRIBUTE typedef FrameData CCFrameData; CC_DEPRECATED_ATTRIBUTE typedef MovementBoneData CCMovementBoneData; CC_DEPRECATED_ATTRIBUTE typedef MovementData CCMovementData; CC_DEPRECATED_ATTRIBUTE typedef AnimationData CCAnimationData; CC_DEPRECATED_ATTRIBUTE typedef ContourData CCContourData; CC_DEPRECATED_ATTRIBUTE typedef TextureData CCTextureData; CC_DEPRECATED_ATTRIBUTE typedef DecorativeDisplay CCDecorativeDisplay; CC_DEPRECATED_ATTRIBUTE typedef DisplayData CCDisplayData; CC_DEPRECATED_ATTRIBUTE typedef DisplayFactory CCDisplayFactory; CC_DEPRECATED_ATTRIBUTE typedef BatchNode CCBatchNode; CC_DEPRECATED_ATTRIBUTE typedef DecorativeDisplay CCDecorativeDisplay; CC_DEPRECATED_ATTRIBUTE typedef DisplayManager CCDisplayManager; CC_DEPRECATED_ATTRIBUTE typedef ColliderBody CCColliderBody; CC_DEPRECATED_ATTRIBUTE typedef ColliderDetector CCColliderDetector; CC_DEPRECATED_ATTRIBUTE typedef SpriteFrameCacheHelper CCSpriteFrameCacheHelper; CC_DEPRECATED_ATTRIBUTE typedef TweenFunction CCTweenFunction; CC_DEPRECATED_ATTRIBUTE typedef ArmatureData CCArmatureData; CC_DEPRECATED_ATTRIBUTE typedef Bone CCBone; CC_DEPRECATED_ATTRIBUTE typedef ArmatureAnimation CCArmatureAnimation; CC_DEPRECATED_ATTRIBUTE typedef Armature CCArmature; CC_DEPRECATED_ATTRIBUTE typedef ArmatureDataManager CCArmatureDataManager; CC_DEPRECATED_ATTRIBUTE typedef TweenType CCTweenType; class Armature : public cocos2d::Node, public cocos2d::BlendProtocol { public: /** * Allocates and initializes an armature. * @return An initialized armature which is marked as "autorelease". */ static Armature *create(); /** * Allocates an armature, and use the ArmatureData named name in ArmatureDataManager to initializes the armature. * * @param name Armature will use the name to find the ArmatureData to initializes it. * @return A initialized armature which is marked as "autorelease". */ static Armature *create(const std::string& name); static Armature *create(const std::string& name, Bone *parentBone); public: /** * @js ctor */ Armature(); /** * @js NA * @lua NA */ virtual ~Armature(void); /** * Init the empty armature */ virtual bool init() override; /** * Init an armature with specified name * @param name Armature name */ virtual bool init(const std::string& name); virtual bool init(const std::string& name, Bone *parentBone); /** * Add a Bone to this Armature, * * @param bone The Bone you want to add to Armature * @param parentName The parent Bone's name you want to add to . If it's nullptr, then set Armature to its parent */ virtual void addBone(Bone *bone, const std::string& parentName); /** * Get a bone with the specified name * * @param name The bone's name you want to get */ virtual Bone *getBone(const std::string& name) const; /** * Change a bone's parent with the specified parent name. * * @param bone The bone you want to change parent * @param parentName The new parent's name. */ virtual void changeBoneParent(Bone *bone, const std::string& parentName); /** * Remove a bone with the specified name. If recursion it will also remove child Bone recursionly. * * @param bone The bone you want to remove * @param recursion Determine whether remove the bone's child recursion. */ virtual void removeBone(Bone *bone, bool recursion); /** * Get Armature's bone dictionary * @return Armature's bone dictionary */ const cocos2d::Map& getBoneDic() const; /** * This boundingBox will calculate all bones' boundingBox every time */ virtual cocos2d::Rect getBoundingBox() const override; Bone *getBoneAtPoint(float x, float y) const; // overrides /** * @js NA * @lua NA */ virtual void visit() override; virtual void update(float dt) override; virtual void draw() override; virtual void onEnter() override; virtual void onExit() override; virtual const kmMat4& getNodeToParentTransform() const override; /** * @js NA * @lua NA */ inline void setBlendFunc(const cocos2d::BlendFunc &blendFunc) override { _blendFunc = blendFunc; } /** * @js NA * @lua NA */ inline const cocos2d::BlendFunc &getBlendFunc(void) const override{ return _blendFunc; } /** * Set contentsize and Calculate anchor point. */ virtual void updateOffsetPoint(); virtual void setAnchorPoint(const cocos2d::Point& point) override; virtual const cocos2d::Point& getAnchorPointInPoints() const override; virtual void setAnimation(ArmatureAnimation *animation); virtual ArmatureAnimation *getAnimation() const; virtual bool getArmatureTransformDirty() const; #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT virtual void setColliderFilter(ColliderFilter *filter); #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX virtual void drawContour(); #endif virtual void setArmatureData(ArmatureData *armatureData) { _armatureData = armatureData; } virtual ArmatureData *getArmatureData() const { return _armatureData; } virtual void setName(const std::string &name) { _name = name; } virtual const std::string &getName() const { return _name; } virtual void setParentBone(Bone *parentBone); virtual Bone *getParentBone() const; virtual void setVersion(float version) { _version = version; } virtual float getVersion() const { return _version; } virtual void setBatchNode(BatchNode *batchNode) { _batchNode = batchNode; } virtual BatchNode *getBatchNode() const { return _batchNode; } #if ENABLE_PHYSICS_BOX2D_DETECT virtual b2Fixture *getShapeList(); /** * @js NA * @lua NA */ virtual void setBody(b2Body *body); /** * @js NA * @lua NA */ virtual b2Body *getBody() const; #elif ENABLE_PHYSICS_CHIPMUNK_DETECT /** * @js NA * @lua NA */ virtual cpShape *getShapeList(); /** * @js NA * @lua NA */ virtual void setBody(cpBody *body); /** * @js NA * @lua NA */ virtual cpBody *getBody() const; #endif protected: /* * Used to create Bone internal * @js NA * @lua NA */ Bone *createBone(const std::string& boneName ); protected: ArmatureData *_armatureData; BatchNode *_batchNode; std::string _name; Bone *_parentBone; float _version; mutable bool _armatureTransformDirty; cocos2d::Map _boneDic; //! The dictionary of the bones, include all bones in the armature, no matter it is the direct bone or the indirect bone. It is different from m_pChindren. cocos2d::Vector _topBoneList; cocos2d::BlendFunc _blendFunc; //! It's required for CCTextureProtocol inheritance cocos2d::Point _offsetPoint; cocos2d::Point _realAnchorPointInPoints; ArmatureAnimation *_animation; #if ENABLE_PHYSICS_BOX2D_DETECT b2Body *_body; #elif ENABLE_PHYSICS_CHIPMUNK_DETECT cpBody *_body; #endif }; } #endif /*__CCARMATURE_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCArmatureAnimation.h" #include "cocostudio/CCArmature.h" #include "cocostudio/CCBone.h" #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCUtilMath.h" #include "cocostudio/CCDatas.h" using namespace cocos2d; namespace cocostudio { ArmatureAnimation *ArmatureAnimation::create(Armature *armature) { ArmatureAnimation *pArmatureAnimation = new ArmatureAnimation(); if (pArmatureAnimation && pArmatureAnimation->init(armature)) { pArmatureAnimation->autorelease(); return pArmatureAnimation; } CC_SAFE_DELETE(pArmatureAnimation); return nullptr; } ArmatureAnimation::ArmatureAnimation() : _animationData(nullptr) , _speedScale(1) , _movementData(nullptr) , _armature(nullptr) , _movementID("") , _toIndex(0) , _ignoreFrameEvent(false) , _onMovementList(false) , _movementListLoop(false) , _movementListDurationTo(-1) , _userObject(nullptr) , _movementEventCallFunc(nullptr) , _frameEventCallFunc(nullptr) , _movementEventTarget(nullptr) , _frameEventTarget(nullptr) , _movementEventListener(nullptr) , _frameEventListener(nullptr) { } ArmatureAnimation::~ArmatureAnimation(void) { CC_SAFE_RELEASE_NULL(_animationData); CC_SAFE_RELEASE_NULL(_userObject); } bool ArmatureAnimation::init(Armature *armature) { bool bRet = false; do { _armature = armature; _tweenList.clear(); bRet = true; } while (0); return bRet; } void ArmatureAnimation::pause() { for (const auto& tween : _tweenList) { tween->pause(); } ProcessBase::pause(); } void ArmatureAnimation::resume() { for (const auto& tween : _tweenList) { tween->resume(); } ProcessBase::resume(); } void ArmatureAnimation::stop() { for (const auto& tween : _tweenList) { tween->stop(); } _tweenList.clear(); ProcessBase::stop(); } void ArmatureAnimation::setAnimationScale(float animationScale ) { setSpeedScale(animationScale); } float ArmatureAnimation::getAnimationScale() const { return getSpeedScale(); } void ArmatureAnimation::setSpeedScale(float speedScale) { if(speedScale == _speedScale) { return; } _speedScale = speedScale; _processScale = !_movementData ? _speedScale : _speedScale * _movementData->scale; const Map& map = _armature->getBoneDic(); for(auto& element : map) { Bone *bone = element.second; bone->getTween()->setProcessScale(_processScale); if (bone->getChildArmature()) { bone->getChildArmature()->getAnimation()->setProcessScale(_processScale); } } } float ArmatureAnimation::getSpeedScale() const { return _speedScale; } void ArmatureAnimation::play(const std::string& animationName, int durationTo, int loop) { CCASSERT(_animationData, "_animationData can not be null"); _movementData = _animationData->getMovement(animationName.c_str()); CCASSERT(_movementData, "_movementData can not be null"); //! Get key frame count _rawDuration = _movementData->duration; _movementID = animationName; _processScale = _speedScale * _movementData->scale; //! Further processing parameters durationTo = (durationTo == -1) ? _movementData->durationTo : durationTo; int durationTween = _movementData->durationTween == 0 ? _rawDuration : _movementData->durationTween; TweenType tweenEasing = _movementData->tweenEasing; loop = (loop < 0) ? _movementData->loop : loop; _onMovementList = false; ProcessBase::play(durationTo, durationTween, loop, tweenEasing); if (_rawDuration == 0) { _loopType = SINGLE_FRAME; } else { if (loop) { _loopType = ANIMATION_TO_LOOP_FRONT; } else { _loopType = ANIMATION_NO_LOOP; } _durationTween = durationTween; } MovementBoneData *movementBoneData = nullptr; _tweenList.clear(); const Map& map = _armature->getBoneDic(); for(auto& element : map) { Bone *bone = element.second; movementBoneData = static_cast(_movementData->movBoneDataDic.at(bone->getName())); Tween *tween = bone->getTween(); if(movementBoneData && movementBoneData->frameList.size() > 0) { _tweenList.pushBack(tween); movementBoneData->duration = _movementData->duration; tween->play(movementBoneData, durationTo, durationTween, loop, tweenEasing); tween->setProcessScale(_processScale); if (bone->getChildArmature()) { bone->getChildArmature()->getAnimation()->setProcessScale(_processScale); } } else { if(!bone->isIgnoreMovementBoneData()) { //! this bone is not include in this movement, so hide it bone->getDisplayManager()->changeDisplayWithIndex(-1, false); tween->stop(); } } } _armature->update(0); } void ArmatureAnimation::playByIndex(int animationIndex, int durationTo, int loop) { playWithIndex(animationIndex, durationTo, loop); } void ArmatureAnimation::playWithIndex(int animationIndex, int durationTo, int loop) { std::vector &movName = _animationData->movementNames; CC_ASSERT((animationIndex > -1) && ((unsigned int)animationIndex < movName.size())); std::string animationName = movName.at(animationIndex); play(animationName.c_str(), durationTo, loop); } void ArmatureAnimation::playWithNames(const std::vector& movementNames, int durationTo, bool loop) { _movementList.clear(); _movementListLoop = loop; _movementListDurationTo = durationTo; _onMovementList = true; _movementIndex = 0; _movementList = movementNames; updateMovementList(); } void ArmatureAnimation::playWithIndexes(const std::vector& movementIndexes, int durationTo, bool loop) { _movementList.clear(); _movementListLoop = loop; _movementListDurationTo = durationTo; _onMovementList = true; _movementIndex = 0; std::vector &movName = _animationData->movementNames; for(auto& index : movementIndexes) { std::string name = movName.at(index); _movementList.push_back(name); } updateMovementList(); } void ArmatureAnimation::gotoAndPlay(int frameIndex) { if (!_movementData || frameIndex < 0 || frameIndex >= _movementData->duration) { CCLOG("Please ensure you have played a movement, and the frameIndex is in the range."); return; } bool ignoreFrameEvent = _ignoreFrameEvent; _ignoreFrameEvent = true; _isPlaying = true; _isComplete = _isPause = false; ProcessBase::gotoFrame(frameIndex); _currentPercent = (float)_curFrameIndex / ((float)_movementData->duration-1); _currentFrame = _nextFrameIndex * _currentPercent; for (const auto &tween : _tweenList) { tween->gotoAndPlay(frameIndex); } _armature->update(0); _ignoreFrameEvent = ignoreFrameEvent; } void ArmatureAnimation::gotoAndPause(int frameIndex) { gotoAndPlay(frameIndex); pause(); } ssize_t ArmatureAnimation::getMovementCount() const { return _animationData->getMovementCount(); } void ArmatureAnimation::update(float dt) { ProcessBase::update(dt); for (const auto &tween : _tweenList) { tween->update(dt); } while (_frameEventQueue.size() > 0) { FrameEvent *event = _frameEventQueue.front(); _frameEventQueue.pop(); _ignoreFrameEvent = true; if(_frameEventTarget) { (_frameEventTarget->*_frameEventCallFunc)(event->bone, event->frameEventName, event->originFrameIndex, event->currentFrameIndex); } if (_frameEventListener) { _frameEventListener(event->bone, event->frameEventName, event->originFrameIndex, event->currentFrameIndex); } _ignoreFrameEvent = false; CC_SAFE_DELETE(event); } while (_movementEventQueue.size() > 0) { MovementEvent *event = _movementEventQueue.front(); _movementEventQueue.pop(); if(_movementEventTarget) { (_movementEventTarget->*_movementEventCallFunc)(event->armature, event->movementType, event->movementID); } if (_movementEventListener) { _movementEventListener(event->armature, event->movementType, event->movementID); } CC_SAFE_DELETE(event); } } void ArmatureAnimation::updateHandler() { if (_currentPercent >= 1) { switch(_loopType) { case ANIMATION_NO_LOOP: { _loopType = ANIMATION_MAX; _currentFrame = (_currentPercent - 1) * _nextFrameIndex; _currentPercent = _currentFrame / _durationTween; if (_currentPercent >= 1.0f) { } else { _nextFrameIndex = _durationTween; movementEvent(_armature, START, _movementID.c_str()); break; } } break; case ANIMATION_MAX: case SINGLE_FRAME: { _currentPercent = 1; _isComplete = true; _isPlaying = false; movementEvent(_armature, COMPLETE, _movementID.c_str()); updateMovementList(); } break; case ANIMATION_TO_LOOP_FRONT: { _loopType = ANIMATION_LOOP_FRONT; _currentPercent = fmodf(_currentPercent, 1); _currentFrame = _nextFrameIndex == 0 ? 0 : fmodf(_currentFrame, _nextFrameIndex); _nextFrameIndex = _durationTween > 0 ? _durationTween : 1; movementEvent(_armature, START, _movementID.c_str()); } break; default: { //_currentPercent = fmodf(_currentPercent, 1); _currentFrame = fmodf(_currentFrame, _nextFrameIndex); _toIndex = 0; movementEvent(_armature, LOOP_COMPLETE, _movementID.c_str()); } break; } } } std::string ArmatureAnimation::getCurrentMovementID() const { if (_isComplete) { return ""; } return _movementID; } void ArmatureAnimation::setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc) { _movementEventTarget = target; _movementEventCallFunc = callFunc; } void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc) { _frameEventTarget = target; _frameEventCallFunc = callFunc; } void ArmatureAnimation::setMovementEventCallFunc(std::function listener) { _movementEventListener = listener; } void ArmatureAnimation::setFrameEventCallFunc(std::function listener) { _frameEventListener = listener; } void ArmatureAnimation::setUserObject(Object *pUserObject) { CC_SAFE_RETAIN(pUserObject); CC_SAFE_RELEASE(_userObject); _userObject = pUserObject; } void ArmatureAnimation::frameEvent(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex) { if ((_frameEventTarget && _frameEventCallFunc) || _frameEventListener) { FrameEvent *frameEvent = new FrameEvent(); frameEvent->bone = bone; frameEvent->frameEventName = frameEventName; frameEvent->originFrameIndex = originFrameIndex; frameEvent->currentFrameIndex = currentFrameIndex; _frameEventQueue.push(frameEvent); } } void ArmatureAnimation::movementEvent(Armature *armature, MovementEventType movementType, const std::string& movementID) { if ((_movementEventTarget && _movementEventCallFunc) || _movementEventListener) { MovementEvent *movementEvent = new MovementEvent(); movementEvent->armature = armature; movementEvent->movementType = movementType; movementEvent->movementID = movementID; _movementEventQueue.push(movementEvent); } } void ArmatureAnimation::updateMovementList() { if (_onMovementList) { if (_movementListLoop) { play(_movementList.at(_movementIndex).c_str(), _movementListDurationTo, 0); _movementIndex++; if (_movementIndex >= _movementList.size()) { _movementIndex = 0; } } else { if (_movementIndex < _movementList.size()) { play(_movementList.at(_movementIndex).c_str(), _movementListDurationTo, 0); _movementIndex++; } else { _onMovementList = false; } } _onMovementList = true; } } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCArmatureAnimation.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCANIMATION_H__ #define __CCANIMATION_H__ #include "cocostudio/CCProcessBase.h" #include "cocostudio/CCTween.h" #include namespace cocostudio { enum MovementEventType { START, COMPLETE, LOOP_COMPLETE }; class Armature; class Bone; typedef void (cocos2d::Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const std::string&); typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const std::string&, int, int); #define movementEvent_selector(_SELECTOR) (cocostudio::SEL_MovementEventCallFunc)(&_SELECTOR) #define frameEvent_selector(_SELECTOR) (cocostudio::SEL_FrameEventCallFunc)(&_SELECTOR) struct FrameEvent { Bone *bone; std::string frameEventName; int originFrameIndex; int currentFrameIndex; }; struct MovementEvent { Armature *armature; MovementEventType movementType; std::string movementID; }; class ArmatureAnimation : public ProcessBase { public: /** * Create with a Armature * @param armature The Armature ArmatureAnimation will bind to */ static ArmatureAnimation *create(Armature *armature); public: /** * @js ctor */ ArmatureAnimation(); /** * @js NA * @lua NA */ virtual ~ArmatureAnimation(void); /** * Init with a Armature * @param armature The Armature ArmatureAnimation will bind to */ virtual bool init(Armature *armature); /** * Scale animation play speed. * This method is deprecated, please use setSpeedScale. * @param animationScale Scale value */ CC_DEPRECATED_ATTRIBUTE virtual void setAnimationScale(float animationScale); CC_DEPRECATED_ATTRIBUTE virtual float getAnimationScale() const; /** * Scale animation play speed. * @param animationScale Scale value */ virtual void setSpeedScale(float speedScale); virtual float getSpeedScale() const; //! The animation update speed CC_DEPRECATED_ATTRIBUTE virtual void setAnimationInternal(float animationInternal) {} using ProcessBase::play; /** * Play animation by animation name. * * @param animationName The animation name you want to play * @param durationTo The frames between two animation changing-over. * It's meaning is changing to this animation need how many frames * * -1 : use the value from MovementData get from flash design panel * @param loop Whether the animation is loop * * loop < 0 : use the value from MovementData get from flash design panel * loop = 0 : this animation is not loop * loop > 0 : this animation is loop */ virtual void play(const std::string& animationName, int durationTo = -1, int loop = -1); /** * Play animation by index, the other param is the same to play. * @deprecated, please use playWithIndex * @param animationIndex the animation index you want to play */ CC_DEPRECATED_ATTRIBUTE virtual void playByIndex(int animationIndex, int durationTo = -1, int loop = -1); virtual void playWithIndex(int animationIndex, int durationTo = -1, int loop = -1); virtual void playWithNames(const std::vector& movementNames, int durationTo = -1, bool loop = true); virtual void playWithIndexes(const std::vector& movementIndexes, int durationTo = -1, bool loop = true); /** * Go to specified frame and play current movement. * You need first switch to the movement you want to play, then call this function. * * example : playByIndex(0); * gotoAndPlay(0); * playByIndex(1); * gotoAndPlay(0); * gotoAndPlay(15); */ virtual void gotoAndPlay(int frameIndex); /** * Go to specified frame and pause current movement. */ virtual void gotoAndPause(int frameIndex); /** * Pause the Process */ virtual void pause(); /** * Resume the Process */ virtual void resume(); /** * Stop the Process */ virtual void stop(); /** * Get movement count */ ssize_t getMovementCount() const; void update(float dt); /** * Get current movementID * @return The name of current movement */ std::string getCurrentMovementID() const; /** * Set armature's movement event callback function * To disconnect this event, just setMovementEventCallFunc(nullptr, nullptr); */ CC_DEPRECATED_ATTRIBUTE void setMovementEventCallFunc(cocos2d::Object *target, SEL_MovementEventCallFunc callFunc); /** * Set armature's frame event callback function * To disconnect this event, just setFrameEventCallFunc(nullptr, nullptr); */ CC_DEPRECATED_ATTRIBUTE void setFrameEventCallFunc(cocos2d::Object *target, SEL_FrameEventCallFunc callFunc); void setMovementEventCallFunc(std::function listener); void setFrameEventCallFunc(std::function listener); virtual void setAnimationData(AnimationData *data) { if (_animationData != data) { CC_SAFE_RETAIN(data); CC_SAFE_RELEASE(_animationData); _animationData = data; } } virtual AnimationData *getAnimationData() const { return _animationData; } /** * Returns a user assigned Object * * Similar to userData, but instead of holding a void* it holds an object * * @return A user assigned Object * @js NA * @lua NA */ virtual Object* getUserObject() { return _userObject; } /** * @js NA * @lua NA */ virtual const Object* getUserObject() const { return _userObject; } /** * Returns a user assigned Object * * Similar to UserData, but instead of holding a void* it holds an object. * The UserObject will be retained once in this method, * and the previous UserObject (if existed) will be relese. * The UserObject will be released in Node's destructure. * * @param userObject A user assigned Object */ virtual void setUserObject(Object *userObject); protected: /** * Update(float dt) will call this handler, you can handle your logic here * @js NA * @lua NA */ void updateHandler(); /** * Update current key frame, and process auto stop, pause * @js NA * @lua NA */ void updateFrameData(float currentPercent); /** * Emit a frame event * @js NA * @lua NA */ void frameEvent(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex); /** * Emit a movement event */ void movementEvent(Armature *armature, MovementEventType movementType, const std::string& movementID); void updateMovementList(); bool isIgnoreFrameEvent() const { return _ignoreFrameEvent; } friend class Tween; protected: //! AnimationData save all MovementDatas this animation used. AnimationData *_animationData; //! Scale the animation speed float _speedScale; MovementData *_movementData; //! MovementData save all MovementFrameDatas this animation used. Armature *_armature; //! A weak reference of armature std::string _movementID; //! Current movment's name int _toIndex; //! The frame index in MovementData->m_pMovFrameDataArr, it's different from m_iFrameIndex. cocos2d::Vector _tweenList; bool _ignoreFrameEvent; std::queue _frameEventQueue; std::queue _movementEventQueue; std::vector _movementList; bool _onMovementList; bool _movementListLoop; unsigned int _movementIndex; int _movementListDurationTo; cocos2d::Object *_userObject; protected: /** * MovementEvent CallFunc. * @param Armature* a Armature * @param MovementEventType, Event Type, like START, COMPLETE. * @param const char*, Movement ID, also called Movement Name */ SEL_MovementEventCallFunc _movementEventCallFunc; /** * FrameEvent CallFunc. * @param Bone*, a Bone * @param const char*, the name of this frame event * @param int, origin frame index * @param int, current frame index, animation may be delayed */ SEL_FrameEventCallFunc _frameEventCallFunc; cocos2d::Object *_movementEventTarget; cocos2d::Object *_frameEventTarget; std::function _movementEventListener; std::function _frameEventListener; }; } #endif /*__CCANIMATION_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCSpriteFrameCache.h" #include "cocostudio/CCArmatureDataManager.h" #include "cocostudio/CCTransformHelp.h" #include "cocostudio/CCDataReaderHelper.h" #include "cocostudio/CCSpriteFrameCacheHelper.h" using namespace cocos2d; namespace cocostudio { static ArmatureDataManager *s_sharedArmatureDataManager = nullptr; ArmatureDataManager *ArmatureDataManager::getInstance() { if (s_sharedArmatureDataManager == nullptr) { s_sharedArmatureDataManager = new ArmatureDataManager(); if (!s_sharedArmatureDataManager || !s_sharedArmatureDataManager->init()) { CC_SAFE_DELETE(s_sharedArmatureDataManager); } } return s_sharedArmatureDataManager; } void ArmatureDataManager::destroyInstance() { SpriteFrameCacheHelper::purge(); DataReaderHelper::purge(); CC_SAFE_RELEASE_NULL(s_sharedArmatureDataManager); } ArmatureDataManager::ArmatureDataManager(void) { _armarureDatas.clear(); _animationDatas.clear(); _textureDatas.clear(); _autoLoadSpriteFile = false; } ArmatureDataManager::~ArmatureDataManager(void) { _animationDatas.clear(); _armarureDatas.clear(); _textureDatas.clear(); _relativeDatas.clear(); } bool ArmatureDataManager::init() { bool bRet = false; do { _armarureDatas.clear(); _animationDatas.clear(); _textureDatas.clear(); bRet = true; } while (0); return bRet; } void ArmatureDataManager::removeArmatureFileInfo(const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { for (std::string str : data->armatures) { removeArmatureData(str.c_str()); } for (std::string str : data->animations) { removeAnimationData(str.c_str()); } for (std::string str : data->textures) { removeTextureData(str.c_str()); } for (std::string str : data->plistFiles) { SpriteFrameCache::getInstance()->removeSpriteFramesFromFile(str.c_str()); } _relativeDatas.erase(configFilePath); DataReaderHelper::getInstance()->removeConfigFile(configFilePath); } } void ArmatureDataManager::addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { data->armatures.push_back(id); } _armarureDatas.insert(id, armatureData); } ArmatureData *ArmatureDataManager::getArmatureData(const std::string& id) { ArmatureData *armatureData = nullptr; armatureData = (ArmatureData *)_armarureDatas.at(id); return armatureData; } void ArmatureDataManager::removeArmatureData(const std::string& id) { _armarureDatas.erase(id); } void ArmatureDataManager::addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { data->animations.push_back(id); } _animationDatas.insert(id, animationData); } AnimationData *ArmatureDataManager::getAnimationData(const std::string& id) { AnimationData *animationData = nullptr; animationData = (AnimationData *)_animationDatas.at(id); return animationData; } void ArmatureDataManager::removeAnimationData(const std::string& id) { _animationDatas.erase(id); } void ArmatureDataManager::addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { data->textures.push_back(id); } _textureDatas.insert(id, textureData); } TextureData *ArmatureDataManager::getTextureData(const std::string& id) { TextureData *textureData = nullptr; textureData = (TextureData *)_textureDatas.at(id); return textureData; } void ArmatureDataManager::removeTextureData(const std::string& id) { _textureDatas.erase(id); } void ArmatureDataManager::addArmatureFileInfo(const std::string& configFilePath) { addRelativeData(configFilePath); _autoLoadSpriteFile = true; DataReaderHelper::getInstance()->addDataFromFile(configFilePath); } void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& configFilePath, Object *target, SEL_SCHEDULE selector) { addRelativeData(configFilePath); _autoLoadSpriteFile = true; DataReaderHelper::getInstance()->addDataFromFileAsync("", "", configFilePath, target, selector); } void ArmatureDataManager::addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath) { addRelativeData(configFilePath); _autoLoadSpriteFile = false; DataReaderHelper::getInstance()->addDataFromFile(configFilePath); addSpriteFrameFromFile(plistPath, imagePath); } void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, Object *target, SEL_SCHEDULE selector) { addRelativeData(configFilePath); _autoLoadSpriteFile = false; DataReaderHelper::getInstance()->addDataFromFileAsync(imagePath, plistPath, configFilePath, target, selector); addSpriteFrameFromFile(plistPath, imagePath); } void ArmatureDataManager::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { data->plistFiles.push_back(plistPath); } SpriteFrameCacheHelper::getInstance()->addSpriteFrameFromFile(plistPath, imagePath); } bool ArmatureDataManager::isAutoLoadSpriteFile() { return _autoLoadSpriteFile; } const cocos2d::Map& ArmatureDataManager::getArmatureDatas() const { return _armarureDatas; } const cocos2d::Map& ArmatureDataManager::getAnimationDatas() const { return _animationDatas; } const cocos2d::Map& ArmatureDataManager::getTextureDatas() const { return _textureDatas; } void CCArmatureDataManager::addRelativeData(const std::string& configFilePath) { if (_relativeDatas.find(configFilePath) == _relativeDatas.end()) { _relativeDatas[configFilePath] = RelativeData(); } } RelativeData *CCArmatureDataManager::getRelativeData(const std::string& configFilePath) { return &_relativeDatas[configFilePath]; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCArmatureDataManager.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCARMATUREDATAMANAGER_H__ #define __CCARMATUREDATAMANAGER_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDatas.h" namespace cocostudio { struct RelativeData { std::vector plistFiles; std::vector armatures; std::vector animations; std::vector textures; }; /** * @brief format and manage armature configuration and armature animation */ class ArmatureDataManager : public cocos2d::Object { public: /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static ArmatureDataManager *sharedArmatureDataManager() { return ArmatureDataManager::getInstance(); } /** @deprecated Use destoryInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purge() { ArmatureDataManager::destroyInstance(); }; static ArmatureDataManager *getInstance(); static void destroyInstance(); private: /** * @js ctor */ ArmatureDataManager(void); /** * @js NA * @lua NA */ ~ArmatureDataManager(void); public: /** * Init ArmatureDataManager */ virtual bool init(); /** * Add armature data * @param id The id of the armature data * @param armatureData ArmatureData * */ void addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath = ""); /** * @brief get armature data * @param id the id of the armature data you want to get * @return ArmatureData * */ ArmatureData *getArmatureData(const std::string& id); /** * @brief remove armature data * @param id the id of the armature data you want to get */ void removeArmatureData(const std::string& id); /** * @brief add animation data * @param id the id of the animation data * @return AnimationData * */ void addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath = ""); /** * @brief get animation data from _animationDatas(Dictionary) * @param id the id of the animation data you want to get * @return AnimationData * */ AnimationData *getAnimationData(const std::string& id); /** * @brief remove animation data * @param id the id of the animation data */ void removeAnimationData(const std::string& id); /** * @brief add texture data * @param id the id of the texture data * @return TextureData * */ void addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath = ""); /** * @brief get texture data * @param id the id of the texture data you want to get * @return TextureData * */ TextureData *getTextureData(const std::string& id); /** * @brief remove texture data * @param id the id of the texture data you want to get */ void removeTextureData(const std::string& id); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. */ void addArmatureFileInfo(const std::string& configFilePath); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. * It will load data in a new thread */ void addArmatureFileInfoAsync(const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. */ void addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. * It will load data in a new thread */ void addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); /** * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name */ void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath = ""); virtual void removeArmatureFileInfo(const std::string& configFilePath); /** * @brief Juge whether or not need auto load sprite file */ bool isAutoLoadSpriteFile(); const cocos2d::Map& getArmatureDatas() const; const cocos2d::Map& getAnimationDatas() const; const cocos2d::Map& getTextureDatas() const; protected: void addRelativeData(const std::string& configFilePath); RelativeData *getRelativeData(const std::string& configFilePath); private: /** * @brief save amature datas * @key std::string * @value ArmatureData * */ cocos2d::Map _armarureDatas; /** * @brief save animation datas * @key std::string * @value AnimationData * */ cocos2d::Map _animationDatas; /** * @brief save texture datas * @key std::string * @value TextureData * */ cocos2d::Map _textureDatas; bool _autoLoadSpriteFile; std::unordered_map _relativeDatas; }; } #endif/*__CCARMATUREDATAMANAGER_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCArmatureDefine.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCArmatureDefine.h" namespace cocostudio { const char *armatureVersion() { return "1.1.0.0"; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCArmatureDefine.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCARMATUREDEFINE_H__ #define __CCARMATUREDEFINE_H__ #define VERSION_COMBINED 0.30f #define VERSION_CHANGE_ROTATION_RANGE 1.0f #define VERSION_COLOR_READING 1.1f #ifndef AUTO_ADD_SPRITE_FRAME_NAME_PREFIX #define AUTO_ADD_SPRITE_FRAME_NAME_PREFIX 0 #endif // !AUTO_ADD_SPRITE_FRAME_NAME_PREFIX #ifndef ENABLE_PHYSICS_BOX2D_DETECT #define ENABLE_PHYSICS_BOX2D_DETECT 0 #endif #ifndef ENABLE_PHYSICS_CHIPMUNK_DETECT #define ENABLE_PHYSICS_CHIPMUNK_DETECT 0 #endif #ifndef ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX #define ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX 1 #endif #define CS_RETURN_IF(cond) if (cond) return #define CS_RETURN_NULL_IF(cond) if (cond) return nullptr; namespace cocostudio { const char *armatureVersion(); } #endif /*__CCARMATUREDEFINE_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCBatchNode.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCBatchNode.h" #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCArmature.h" #include "cocostudio/CCSkin.h" #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" #include "CCShaderCache.h" #include "CCDirector.h" using namespace cocos2d; namespace cocostudio { BatchNode *BatchNode::create() { BatchNode *batchNode = new BatchNode(); if (batchNode && batchNode->init()) { batchNode->autorelease(); return batchNode; } CC_SAFE_DELETE(batchNode); return nullptr; } BatchNode::BatchNode() : _groupCommand(nullptr) { } BatchNode::~BatchNode() { CC_SAFE_DELETE(_groupCommand); } bool BatchNode::init() { bool ret = Node::init(); setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return ret; } void BatchNode::addChild(Node *pChild) { Node::addChild(pChild); } void BatchNode::addChild(Node *child, int zOrder) { Node::addChild(child, zOrder); } void BatchNode::addChild(Node *child, int zOrder, int tag) { Node::addChild(child, zOrder, tag); Armature *armature = dynamic_cast(child); if (armature != nullptr) { armature->setBatchNode(this); if (_groupCommand == nullptr) { _groupCommand = new GroupCommand(); } } } void BatchNode::removeChild(Node* child, bool cleanup) { Armature *armature = dynamic_cast(child); if (armature != nullptr) { armature->setBatchNode(nullptr); } Node::removeChild(child, cleanup); } void BatchNode::visit() { // quick return if not visible. children won't be drawn. if (!_visible) { return; } kmGLPushMatrix(); transform(); sortAllChildren(); draw(); // reset for next frame _orderOfArrival = 0; kmGLPopMatrix(); } void BatchNode::draw() { if (_children.empty()) { return; } CC_NODE_DRAW_SETUP(); bool pushed = false; for(auto object : _children) { Armature *armature = dynamic_cast(object); if (armature) { if (!pushed) { generateGroupCommand(); pushed = true; } armature->visit(); } else { Director::getInstance()->getRenderer()->popGroup(); pushed = false; ((Node *)object)->visit(); } } } void BatchNode::generateGroupCommand() { Renderer* renderer = Director::getInstance()->getRenderer(); _groupCommand->init(_globalZOrder); renderer->addCommand(_groupCommand); renderer->pushGroup(_groupCommand->getRenderQueueID()); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCBatchNode.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCBATCHNODE_H__ #define __CCBATCHNODE_H__ #include "CCNode.h" #include "cocostudio/CCArmatureDefine.h" namespace cocos2d { class GroupCommand; } namespace cocostudio { class BatchNode : public cocos2d::Node { public: static BatchNode *create(); public: /** * @js ctor */ BatchNode(); /** * @ js NA * @ lua NA */ ~BatchNode(); /** * @js NA */ virtual bool init() override; virtual void addChild(cocos2d::Node *pChild) override; virtual void addChild(cocos2d::Node *pChild, int zOrder) override; virtual void addChild(cocos2d::Node *pChild, int zOrder, int tag) override; virtual void removeChild(cocos2d::Node* child, bool cleanup) override; /** * @js NA * @lua NA */ virtual void visit() override; /** * @js NA */ void draw() override; protected: void generateGroupCommand(); cocos2d::GroupCommand* _groupCommand; }; } #endif /*__CCBATCHNODE_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCBone.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCBone.h" #include "cocostudio/CCArmature.h" #include "cocostudio/CCUtilMath.h" #include "cocostudio/CCArmatureDataManager.h" #include "cocostudio/CCTransformHelp.h" #include "cocostudio/CCDisplayManager.h" using namespace cocos2d; namespace cocostudio { Bone *Bone::create() { Bone *pBone = new Bone(); if (pBone && pBone->init()) { pBone->autorelease(); return pBone; } CC_SAFE_DELETE(pBone); return nullptr; } Bone *Bone::create(const std::string& name) { Bone *pBone = new Bone(); if (pBone && pBone->init(name)) { pBone->autorelease(); return pBone; } CC_SAFE_DELETE(pBone); return nullptr; } Bone::Bone() { _tweenData = nullptr; _parentBone = nullptr; _armature = nullptr; _childArmature = nullptr; _boneData = nullptr; _tween = nullptr; _tween = nullptr; _displayManager = nullptr; _ignoreMovementBoneData = false; // _worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0); kmMat4Identity(&_worldTransform); _boneTransformDirty = true; _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; _blendDirty = false; _worldInfo = nullptr; _armatureParentBone = nullptr; _dataVersion = 0; } Bone::~Bone(void) { CC_SAFE_DELETE(_tweenData); CC_SAFE_DELETE(_tween); CC_SAFE_DELETE(_displayManager); CC_SAFE_DELETE(_worldInfo); CC_SAFE_RELEASE_NULL(_boneData); CC_SAFE_RELEASE(_childArmature); } bool Bone::init() { return Bone::init(nullptr); } bool Bone::init(const std::string& name) { bool bRet = false; do { _name = name; CC_SAFE_DELETE(_tweenData); _tweenData = new FrameData(); CC_SAFE_DELETE(_tween); _tween = new Tween(); _tween->init(this); CC_SAFE_DELETE(_displayManager); _displayManager = new DisplayManager(); _displayManager->init(this); CC_SAFE_DELETE(_worldInfo); _worldInfo = new BaseData(); CC_SAFE_DELETE(_boneData); _boneData = new BoneData(); bRet = true; } while (0); return bRet; } void Bone::setBoneData(BoneData *boneData) { CCASSERT(nullptr != boneData, "_boneData must not be nullptr"); if (_boneData != boneData) { CC_SAFE_RETAIN(boneData); CC_SAFE_RELEASE(_boneData); _boneData = boneData; } _name = _boneData->name; _localZOrder = _boneData->zOrder; _displayManager->initDisplayList(boneData); } BoneData *Bone::getBoneData() const { return _boneData; } void Bone::setArmature(Armature *armature) { _armature = armature; if (_armature) { _tween->setAnimation(_armature->getAnimation()); _dataVersion = _armature->getArmatureData()->dataVersion; _armatureParentBone = _armature->getParentBone(); } else { _armatureParentBone = nullptr; } } Armature *Bone::getArmature() const { return _armature; } void Bone::update(float delta) { if (_parentBone) _boneTransformDirty = _boneTransformDirty || _parentBone->isTransformDirty(); if (_armatureParentBone && !_boneTransformDirty) { _boneTransformDirty = _armatureParentBone->isTransformDirty(); } if (_boneTransformDirty) { if (_dataVersion >= VERSION_COMBINED) { TransformHelp::nodeConcat(*_tweenData, *_boneData); _tweenData->scaleX -= 1; _tweenData->scaleY -= 1; } _worldInfo->copy(_tweenData); _worldInfo->x = _tweenData->x + _position.x; _worldInfo->y = _tweenData->y + _position.y; _worldInfo->scaleX = _tweenData->scaleX * _scaleX; _worldInfo->scaleY = _tweenData->scaleY * _scaleY; _worldInfo->skewX = _tweenData->skewX + _skewX + _rotationX; _worldInfo->skewY = _tweenData->skewY + _skewY - _rotationY; if(_parentBone) { applyParentTransform(_parentBone); } else { if (_armatureParentBone) { applyParentTransform(_armatureParentBone); } } TransformHelp::nodeToMatrix(*_worldInfo, _worldTransform); if (_armatureParentBone) { _worldTransform = TransformConcat(_worldTransform, _armature->getNodeToParentTransform()); } } DisplayFactory::updateDisplay(this, delta, _boneTransformDirty || _armature->getArmatureTransformDirty()); for(const auto &obj: _children) { Bone *childBone = static_cast(obj); childBone->update(delta); } _boneTransformDirty = false; } void Bone::applyParentTransform(Bone *parent) { float x = _worldInfo->x; float y = _worldInfo->y; _worldInfo->x = x * parent->_worldTransform.mat[0] + y * parent->_worldTransform.mat[4] + parent->_worldInfo->x; _worldInfo->y = x * parent->_worldTransform.mat[1] + y * parent->_worldTransform.mat[5] + parent->_worldInfo->y; _worldInfo->scaleX = _worldInfo->scaleX * parent->_worldInfo->scaleX; _worldInfo->scaleY = _worldInfo->scaleY * parent->_worldInfo->scaleY; _worldInfo->skewX = _worldInfo->skewX + parent->_worldInfo->skewX; _worldInfo->skewY = _worldInfo->skewY + parent->_worldInfo->skewY; } void CCBone::setBlendFunc(const BlendFunc& blendFunc) { if (_blendFunc.src != blendFunc.src && _blendFunc.dst != blendFunc.dst) { _blendFunc = blendFunc; _blendDirty = true; } } void Bone::updateDisplayedColor(const Color3B &parentColor) { _realColor = Color3B(255, 255, 255); Node::updateDisplayedColor(parentColor); } void Bone::updateDisplayedOpacity(GLubyte parentOpacity) { _realOpacity = 255; Node::updateDisplayedOpacity(parentOpacity); } void Bone::updateColor() { Node *display = _displayManager->getDisplayRenderNode(); if(display != nullptr) { display->setColor(Color3B(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255, _displayedColor.b * _tweenData->b / 255)); display->setOpacity(_displayedOpacity * _tweenData->a / 255); } } void Bone::updateZOrder() { if (_dataVersion >= VERSION_COMBINED) { int zorder = _tweenData->zOrder + _boneData->zOrder; setLocalZOrder(zorder); } else { setLocalZOrder(_tweenData->zOrder); } } void Bone::addChildBone(Bone *child) { CCASSERT( nullptr != child, "Argument must be non-nil"); CCASSERT( nullptr == child->_parentBone, "child already added. It can't be added again"); if(_children.empty()) { _children.reserve(4); } if (_children.getIndex(child) == CC_INVALID_INDEX) { _children.pushBack(child); child->setParentBone(this); } } void Bone::removeChildBone(Bone *bone, bool recursion) { if (!_children.empty() && _children.getIndex(bone) != CC_INVALID_INDEX ) { if(recursion) { auto ccbones = bone->_children; for(auto& object : ccbones) { Bone *ccBone = static_cast(object); bone->removeChildBone(ccBone, recursion); } } bone->setParentBone(nullptr); bone->getDisplayManager()->setCurrentDecorativeDisplay(nullptr); _children.eraseObject(bone); } } void Bone::removeFromParent(bool recursion) { if (nullptr != _parentBone) { _parentBone->removeChildBone(this, recursion); } } void Bone::setParentBone(Bone *parent) { _parentBone = parent; } Bone *Bone::getParentBone() { return _parentBone; } void Bone::setChildArmature(Armature *armature) { if (_childArmature != armature) { if (armature == nullptr && _childArmature) { _childArmature->setParentBone(nullptr); } CC_SAFE_RETAIN(armature); CC_SAFE_RELEASE(_childArmature); _childArmature = armature; } } Armature *Bone::getChildArmature() const { return _childArmature; } Tween *Bone::getTween() { return _tween; } void Bone::setLocalZOrder(int zOrder) { if (_localZOrder != zOrder) Node::setLocalZOrder(zOrder); } kmMat4 Bone::getNodeToArmatureTransform() const { return _worldTransform; } kmMat4 Bone::getNodeToWorldTransform() const { return TransformConcat(_worldTransform, _armature->getNodeToWorldTransform()); } Node *Bone::getDisplayRenderNode() { return _displayManager->getDisplayRenderNode(); } DisplayType Bone::getDisplayRenderNodeType() { return _displayManager->getDisplayRenderNodeType(); } void Bone::addDisplay(DisplayData *displayData, int index) { _displayManager->addDisplay(displayData, index); } void Bone::addDisplay(Node *display, int index) { _displayManager->addDisplay(display, index); } void Bone::removeDisplay(int index) { _displayManager->removeDisplay(index); } void Bone::changeDisplayByIndex(int index, bool force) { changeDisplayWithIndex(index, force); } void Bone::changeDisplayByName(const std::string &name, bool force) { changeDisplayWithName(name, force); } void Bone::changeDisplayWithIndex(int index, bool force) { _displayManager->changeDisplayWithIndex(index, force); } void Bone::changeDisplayWithName(const std::string& name, bool force) { _displayManager->changeDisplayWithName(name, force); } ColliderDetector* Bone::getColliderDetector() const { if (DecorativeDisplay *decoDisplay = _displayManager->getCurrentDecorativeDisplay()) { if (ColliderDetector *detector = decoDisplay->getColliderDetector()) { return detector; } } return nullptr; } #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT void Bone::setColliderFilter(ColliderFilter *filter) { auto array = _displayManager->getDecorativeDisplayList(); for(auto& object : array) { DecorativeDisplay *decoDisplay = static_cast(object); if (ColliderDetector *detector = decoDisplay->getColliderDetector()) { detector->setColliderFilter(filter); } } } ColliderFilter *Bone::getColliderFilter() { if (DecorativeDisplay *decoDisplay = _displayManager->getCurrentDecorativeDisplay()) { if (ColliderDetector *detector = decoDisplay->getColliderDetector()) { return detector->getColliderFilter(); } } return nullptr; } #endif } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCBone.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCBONE_H__ #define __CCBONE_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDatas.h" #include "cocostudio/CCTween.h" #include "cocostudio/CCDecorativeDisplay.h" #include "cocostudio/CCDisplayManager.h" namespace cocostudio { class Armature; class Bone : public cocos2d::Node { public: /** * Allocates and initializes a bone. * @return A initialized bone which is marked as "autorelease". */ static Bone *create(); /** * Allocates and initializes a bone. * * @param name If name is not null, then set name to the bone's name * @return A initialized bone which is marked as "autorelease". */ static Bone *create(const std::string& name); public: /** * @js ctor */ Bone(); /** * @js NA * @lua NA */ virtual ~Bone(void); /** * Initializes an empty Bone with nothing init. */ virtual bool init() override; /** * Initializes a Bone with the specified name * @param name Bone's name. */ virtual bool init(const std::string& name); /** * Add display and use displayData to init the display. * If index already have a display, then replace it. * If index is current display index, then also change display to _index * * @param displayData it include the display information, like DisplayType. * If you want to create a sprite display, then create a SpriteDisplayData param * * @param index the index of the display you want to replace or add to * -1 : append display from back */ void addDisplay(DisplayData *displayData, int index); void addDisplay(cocos2d::Node *display, int index); void removeDisplay(int index); CC_DEPRECATED_ATTRIBUTE void changeDisplayByIndex(int index, bool force); CC_DEPRECATED_ATTRIBUTE void changeDisplayByName(const std::string& name, bool force); void changeDisplayWithIndex(int index, bool force); void changeDisplayWithName(const std::string& name, bool force); /** * Add a child to this bone, and it will let this child call setParent(Bone *parent) function to set self to it's parent * @param child the child you want to add */ void addChildBone(Bone *child); /** * Set parent bone. * If parent is NUll, then also remove this bone from armature. * It will not set the Armature, if you want to add the bone to a Armature, you should use Armature::addBone(Bone *bone, const char* parentName). * * @param parent the parent bone. * nullptr : remove this bone from armature */ void setParentBone(Bone *parent); /** * Get parent bone * @return parent bone */ Bone *getParentBone(); using Node::removeFromParent; /** * Remove itself from its parent. * @param recursion whether or not to remove childBone's display */ void removeFromParent(bool recursion); /** * Removes a child Bone * @param bone the bone you want to remove */ void removeChildBone(Bone *bone, bool recursion); void update(float delta) override; void updateDisplayedColor(const cocos2d::Color3B &parentColor) override; void updateDisplayedOpacity(GLubyte parentOpacity) override; //! Update color to render display virtual void updateColor() override; //! Update zorder void updateZOrder(); virtual void setLocalZOrder(int zOrder) override; Tween *getTween(); /* * Whether or not the bone's transform property changed. if true, the bone will update the transform. */ virtual void setTransformDirty(bool dirty) { _boneTransformDirty = dirty; } virtual bool isTransformDirty() { return _boneTransformDirty; } virtual kmMat4 getNodeToArmatureTransform() const; virtual kmMat4 getNodeToWorldTransform() const override; Node *getDisplayRenderNode(); DisplayType getDisplayRenderNodeType(); /* * Get the ColliderBody list in this bone. The object in the Array is ColliderBody. */ virtual ColliderDetector* getColliderDetector() const; #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT virtual void setColliderFilter(ColliderFilter *filter); virtual ColliderFilter *getColliderFilter(); #endif virtual void setBoneData(BoneData *boneData); virtual BoneData *getBoneData() const; virtual void setArmature(Armature *armature); virtual Armature *getArmature() const; virtual void setChildArmature(Armature *childArmature); virtual Armature *getChildArmature() const; virtual DisplayManager *getDisplayManager() const { return _displayManager; } /** * @lua NA */ virtual void setIgnoreMovementBoneData(bool ignore) { _ignoreMovementBoneData = ignore; } virtual bool isIgnoreMovementBoneData() const { return _ignoreMovementBoneData; } /* * This function is deprecated, please use isIgnoreMovementBoneData() * @lua NA */ CC_DEPRECATED_ATTRIBUTE virtual bool getIgnoreMovementBoneData() const { return isIgnoreMovementBoneData(); } /* * Set blend function */ virtual void setBlendFunc(const cocos2d::BlendFunc& blendFunc); virtual cocos2d::BlendFunc getBlendFunc(void) { return _blendFunc; } /* * Set if blend function is dirty */ virtual void setBlendDirty(bool dirty) { _blendDirty = dirty; } virtual bool isBlendDirty(void) { return _blendDirty; } virtual FrameData *getTweenData() const { return _tweenData; } virtual void setName(const std::string &name) { _name = name; } virtual const std::string getName() const { return _name; } virtual BaseData *getWorldInfo() const { return _worldInfo; } protected: void applyParentTransform(Bone *parent); /* * The origin state of the Bone. Display's state is effected by _boneData, m_pNode, _tweenData * when call setData function, it will copy from the BoneData. */ BoneData *_boneData; //! A weak reference to the Armature Armature *_armature; //! A weak reference to the child Armature Armature *_childArmature; DisplayManager *_displayManager; /* * When Armature play an animation, if there is not a MovementBoneData of this bone in this MovementData, this bone will be hidden. * Set IgnoreMovementBoneData to true, then this bone will also be shown. */ bool _ignoreMovementBoneData; cocos2d::BlendFunc _blendFunc; bool _blendDirty; Tween *_tween; //! Calculate tween effect //! Used for making tween effect in every frame FrameData *_tweenData; std::string _name; Bone *_parentBone; //! A weak reference to its parent bool _boneTransformDirty; //! Whether or not transform dirty //! self Transform, use this to change display's state kmMat4 _worldTransform; BaseData *_worldInfo; //! Armature's parent bone Bone *_armatureParentBone; //! Data version float _dataVersion; }; } #endif /*__CCBONE_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCColliderDetector.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCColliderDetector.h" #include "cocostudio/CCBone.h" #include "cocostudio/CCTransformHelp.h" using namespace cocos2d; namespace cocostudio { #if ENABLE_PHYSICS_BOX2D_DETECT ColliderFilter::ColliderFilter(uint16 categoryBits, uint16 maskBits, int16 groupIndex) : _categoryBits(categoryBits) , _maskBits(maskBits) , _groupIndex(groupIndex) { } void ColliderFilter::updateShape(b2Fixture *fixture) { b2Filter filter; filter.categoryBits = _categoryBits; filter.groupIndex = _groupIndex; filter.maskBits = _maskBits; fixture->SetFilterData(filter); } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT ColliderFilter::ColliderFilter(cpCollisionType collisionType, cpGroup group) : _collisionType(collisionType) , _group(group) { } void ColliderFilter::updateShape(cpShape *shape) { shape->collision_type = _collisionType; shape->group = _group; } #endif #if ENABLE_PHYSICS_BOX2D_DETECT ColliderBody::ColliderBody(ContourData *contourData) : _fixture(nullptr) , _contourData(contourData) { CC_SAFE_RETAIN(_contourData); _filter = new ColliderFilter(); #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX _calculatedVertexList = Array::create(); CC_SAFE_RETAIN(_calculatedVertexList); #endif } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT ColliderBody::ColliderBody(ContourData *contourData) : _shape(nullptr) , _contourData(contourData) { CC_SAFE_RETAIN(_contourData); _filter = new ColliderFilter(); #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX _calculatedVertexList = Array::create(); CC_SAFE_RETAIN(_calculatedVertexList); #endif } #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX ColliderBody::ColliderBody(ContourData *contourData) : _contourData(contourData) { CC_SAFE_RETAIN(_contourData); } #endif ColliderBody::~ColliderBody() { CC_SAFE_RELEASE(_contourData); #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT CC_SAFE_DELETE(_filter); #endif } #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT void ColliderBody::setColliderFilter(ColliderFilter *filter) { *_filter = *filter; } ColliderFilter *ColliderBody::getColliderFilter() { return _filter; } #endif ColliderDetector *ColliderDetector::create() { ColliderDetector *pColliderDetector = new ColliderDetector(); if (pColliderDetector && pColliderDetector->init()) { pColliderDetector->autorelease(); return pColliderDetector; } CC_SAFE_DELETE(pColliderDetector); return nullptr; } ColliderDetector *ColliderDetector::create(Bone *bone) { ColliderDetector *pColliderDetector = new ColliderDetector(); if (pColliderDetector && pColliderDetector->init(bone)) { pColliderDetector->autorelease(); return pColliderDetector; } CC_SAFE_DELETE(pColliderDetector); return nullptr; } ColliderDetector::ColliderDetector() : _active(false) { #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT _body = nullptr; _filter = nullptr; #endif } ColliderDetector::~ColliderDetector() { _colliderBodyList.clear(); #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT CC_SAFE_DELETE(_filter); #endif } bool ColliderDetector::init() { _colliderBodyList.clear(); #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT _filter = new ColliderFilter(); #endif return true; } bool ColliderDetector::init(Bone *bone) { init(); setBone(bone); return true; } void ColliderDetector::addContourData(ContourData *contourData) { ColliderBody *colliderBody = new ColliderBody(contourData); _colliderBodyList.pushBack(colliderBody); colliderBody->release(); #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX std::vector &calculatedVertexList = colliderBody->_calculatedVertexList; unsigned long num = contourData->vertexList.size(); for (unsigned long i = 0; i < num; i++) { calculatedVertexList.push_back(Point()); } #endif } void ColliderDetector::addContourDataList(cocos2d::Vector &contourDataList) { for (const auto &contourData : contourDataList) { this->addContourData(contourData); } } void ColliderDetector::removeContourData(ContourData *contourData) { std::vector eraseList; for (const auto &body : _colliderBodyList) { if (body && body->getContourData() == contourData) { eraseList.push_back(body); } } for (const auto &body : eraseList) { this->_colliderBodyList.eraseObject(body); } } void ColliderDetector::removeAll() { _colliderBodyList.clear(); } void ColliderDetector::setActive(bool active) { if (_active == active) { return; } _active = active; #if ENABLE_PHYSICS_BOX2D_DETECT if (_body) { if (active) { setBody(_body); } else { for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; b2Fixture *fixture = colliderBody->getB2Fixture(); _body->DestroyFixture(fixture); colliderBody->setB2Fixture(nullptr); } } } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT if (_body) { if (_active) { for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; cpShape *shape = colliderBody->getShape(); if(shape->space_private == nullptr) { cpSpaceAddShape(_body->space_private, shape); } } } else { for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; cpShape *shape = colliderBody->getShape(); if (shape->space_private != nullptr) { cpSpaceRemoveShape(_body->space_private, shape); } } } } #endif } bool ColliderDetector::getActive() { return _active; } const cocos2d::Vector& ColliderDetector::getColliderBodyList() { return _colliderBodyList; } #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT void ColliderDetector::setColliderFilter(ColliderFilter *filter) { *_filter = *filter; for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; colliderBody->setColliderFilter(filter); #if ENABLE_PHYSICS_BOX2D_DETECT if (colliderBody->getB2Fixture()) { colliderBody->getColliderFilter()->updateShape(colliderBody->getB2Fixture()); } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT if (colliderBody->getShape()) { colliderBody->getColliderFilter()->updateShape(colliderBody->getShape()); } #endif } } ColliderFilter *ColliderDetector::getColliderFilter() { return _filter; } #endif Point helpPoint; void ColliderDetector::updateTransform(kmMat4 &t) { if (!_active) { return; } for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; ContourData *contourData = colliderBody->getContourData(); #if ENABLE_PHYSICS_BOX2D_DETECT b2PolygonShape *shape = nullptr; if (_body != nullptr) { shape = (b2PolygonShape *)colliderBody->getB2Fixture()->GetShape(); } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT cpPolyShape *shape = nullptr; if (_body != nullptr) { shape = (cpPolyShape *)colliderBody->getShape(); } #endif unsigned long num = contourData->vertexList.size(); std::vector &vs = contourData->vertexList; #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX std::vector &cvs = colliderBody->_calculatedVertexList; #endif for (unsigned long i = 0; i < num; i++) { helpPoint.setPoint( vs.at(i).x, vs.at(i).y); helpPoint = PointApplyTransform(helpPoint, t); #if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX cvs.at(i).x = helpPoint.x; cvs.at(i).y = helpPoint.y; #endif #if ENABLE_PHYSICS_BOX2D_DETECT if (shape != nullptr) { b2Vec2 &bv = shape->m_vertices[i]; bv.Set(helpPoint.x / PT_RATIO, helpPoint.y / PT_RATIO); } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT if (shape != nullptr) { cpVect v ; v.x = helpPoint.x; v.y = helpPoint.y; shape->verts[i] = v; } #endif } #if ENABLE_PHYSICS_CHIPMUNK_DETECT cpConvexHull((int)num, shape->verts, nullptr, nullptr, 0); for (unsigned long i = 0; i < num; i++) { cpVect b = shape->verts[(i + 1) % shape->numVerts]; cpVect n = cpvnormalize(cpvperp(cpvsub(b, shape->verts[i]))); shape->planes[i].n = n; shape->planes[i].d = cpvdot(n, shape->verts[i]); } #endif } } #if ENABLE_PHYSICS_BOX2D_DETECT void ColliderDetector::setBody(b2Body *pBody) { _body = pBody; for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; ContourData *contourData = colliderBody->getContourData(); b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.size()]; int i = 0; for(auto& v : contourData->vertexList) { b2bv[i].Set(v.x / PT_RATIO, v.y / PT_RATIO); i++; } b2PolygonShape polygon; polygon.Set(b2bv, (int)contourData->vertexList.size()); CC_SAFE_DELETE(b2bv); b2FixtureDef fixtureDef; fixtureDef.shape = &polygon; fixtureDef.isSensor = true; b2Fixture *fixture = _body->CreateFixture(&fixtureDef); fixture->SetUserData(_bone); if (colliderBody->getB2Fixture() != nullptr) { _body->DestroyFixture(colliderBody->getB2Fixture()); } colliderBody->setB2Fixture(fixture); colliderBody->getColliderFilter()->updateShape(fixture); } } b2Body *ColliderDetector::getBody() const { return _body; } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT void ColliderDetector::setBody(cpBody *pBody) { _body = pBody; for(auto& object : _colliderBodyList) { ColliderBody *colliderBody = (ColliderBody *)object; ContourData *contourData = colliderBody->getContourData(); ssize_t num = contourData->vertexList.size(); auto vs = contourData->vertexList; cpVect *verts = new cpVect[num]; for (int i = 0; i < num; i++) { verts[num - 1 - i].x = vs.at(i).x; verts[num - 1 - i].y = vs.at(i).y; } cpShape *shape = cpPolyShapeNew(_body, (int)num, verts, cpvzero); shape->sensor = true; shape->data = _bone; if (_active) { cpSpaceAddShape(_body->space_private, shape); } colliderBody->setShape(shape); colliderBody->getColliderFilter()->updateShape(shape); delete []verts; } } cpBody *ColliderDetector::getBody() const { return _body; } #endif } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCColliderDetector.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCCOLLIDERDETECTOR_H__ #define __CCCOLLIDERDETECTOR_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDatas.h" #ifndef PT_RATIO #define PT_RATIO 32 #endif #if ENABLE_PHYSICS_CHIPMUNK_DETECT #include "chipmunk.h" #elif ENABLE_PHYSICS_BOX2D_DETECT #include "Box2D/Box2D.h" #endif namespace cocostudio { class Bone; /** * @js NA * @lua NA */ class ColliderFilter { public: virtual ~ColliderFilter() { } #if ENABLE_PHYSICS_BOX2D_DETECT public: ColliderFilter(uint16 categoryBits = 0x0001, uint16 maskBits = 0xFFFF, int16 groupIndex = 0); void updateShape(b2Fixture *fixture); virtual void setCategoryBits(uint16 categoryBits) { _categoryBits = categoryBits; } virtual uint16 getCategoryBits() const { return _categoryBits; } virtual void setMaskBits(uint16 maskBits) { _maskBits = maskBits; } virtual uint16 getMaskBits() const { return _maskBits; } virtual void setGroupIndex(int16 groupIndex) { _groupIndex = groupIndex; } virtual int16 getGroupIndex() const { return _groupIndex; } protected: uint16 _categoryBits; uint16 _maskBits; int16 _groupIndex; #elif ENABLE_PHYSICS_CHIPMUNK_DETECT public: ColliderFilter(cpCollisionType collisionType = 0, cpGroup group = 0); void updateShape(cpShape *shape); virtual void setCollisionType(cpCollisionType collisionType) { _collisionType = collisionType; } virtual cpCollisionType getCollisionType() const { return _collisionType; } virtual void setGroup(cpGroup group) { _group = group; } virtual cpGroup getGroup() const { return _group; } protected: cpCollisionType _collisionType; cpGroup _group; #endif }; class ColliderBody : public cocos2d::Object { public: ColliderBody(ContourData *contourData); ~ColliderBody(); inline ContourData *getContourData() { return _contourData; } #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT void setColliderFilter(ColliderFilter *filter); ColliderFilter *getColliderFilter(); #endif #if ENABLE_PHYSICS_BOX2D_DETECT virtual void setB2Fixture(b2Fixture *fixture) { _fixture = fixture; } virtual b2Fixture *getB2Fixture() const { return _fixture; } #elif ENABLE_PHYSICS_CHIPMUNK_DETECT virtual void setShape(cpShape *shape) { _shape = shape; } virtual cpShape *getShape() const { return _shape; } #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX virtual const std::vector &getCalculatedVertexList() const { return _calculatedVertexList; } #endif private: #if ENABLE_PHYSICS_BOX2D_DETECT b2Fixture *_fixture; ColliderFilter *_filter; #elif ENABLE_PHYSICS_CHIPMUNK_DETECT cpShape *_shape; ColliderFilter *_filter; #elif ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX std::vector _calculatedVertexList; #endif ContourData *_contourData; friend class ColliderDetector; }; /* * @brief ContourSprite used to draw the contour of the display * @js NA * @lua NA */ class ColliderDetector : public cocos2d::Object { public: static ColliderDetector *create(); static ColliderDetector *create(Bone *bone); public: /** * @js ctor */ ColliderDetector(); /** * @js NA * @lua NA */ ~ColliderDetector(void); virtual bool init(); virtual bool init(Bone *bone); void addContourData(ContourData *contourData); void addContourDataList(cocos2d::Vector &contourDataList); void removeContourData(ContourData *contourData); void removeAll(); void updateTransform(kmMat4 &t); void setActive(bool active); bool getActive(); const cocos2d::Vector& getColliderBodyList(); #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT virtual void setColliderFilter(ColliderFilter *filter); virtual ColliderFilter *getColliderFilter(); #endif virtual void setBone(Bone *bone) { _bone = bone; } virtual Bone *getBone() const { return _bone; } #if ENABLE_PHYSICS_BOX2D_DETECT virtual void setBody(b2Body *body); virtual b2Body *getBody() const; #elif ENABLE_PHYSICS_CHIPMUNK_DETECT virtual void setBody(cpBody *body); virtual cpBody *getBody() const; #endif protected: cocos2d::Vector _colliderBodyList; Bone *_bone; #if ENABLE_PHYSICS_BOX2D_DETECT b2Body *_body; ColliderFilter *_filter; #elif ENABLE_PHYSICS_CHIPMUNK_DETECT cpBody *_body; ColliderFilter *_filter; #endif protected: bool _active; }; } #endif /*__CCCOLLIDERDETECTOR_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComAttribute.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCComAttribute.h" using namespace cocos2d; namespace cocostudio { IMPLEMENT_CLASS_COMPONENT_INFO(ComAttribute) ComAttribute::ComAttribute(void) { _name = "CCComAttribute"; } ComAttribute::~ComAttribute(void) { _dict.clear(); } bool ComAttribute::init() { return true; } void ComAttribute::setInt(const std::string& key, int value) { _dict[key] = cocos2d::Value(value); } void ComAttribute::setFloat(const std::string& key, float value) { _dict[key] = cocos2d::Value(value); } void ComAttribute::setBool(const std::string& key, bool value) { _dict[key] = cocos2d::Value(value); } void ComAttribute::setString(const std::string& key, const std::string& value) { _dict[key] = cocos2d::Value(value); } int ComAttribute::getInt(const std::string& key, int def) const { if (_dict.find(key) != _dict.end()) { const cocos2d::Value& v = _dict.at(key); return v.asInt(); } if (!DICTOOL->checkObjectExist_json(_doc, key.c_str())) { return def; } return DICTOOL->getIntValue_json(_doc, key.c_str()); } float ComAttribute::getFloat(const std::string& key, float def) const { if (_dict.find(key) != _dict.end()) { const cocos2d::Value& v = _dict.at(key); return v.asFloat(); } if (!DICTOOL->checkObjectExist_json(_doc, key.c_str())) { return def; } return DICTOOL->getFloatValue_json(_doc, key.c_str()); } bool ComAttribute::getBool(const std::string& key, bool def) const { if (_dict.find(key) != _dict.end()) { const cocos2d::Value& v = _dict.at(key); return v.asBool(); } if (!DICTOOL->checkObjectExist_json(_doc, key.c_str())) { return def; } return DICTOOL->getBooleanValue_json(_doc, key.c_str()); } std::string ComAttribute::getString(const std::string& key, const std::string& def) const { if (_dict.find(key) != _dict.end()) { const cocos2d::Value& v = _dict.at(key); return v.asString(); } if (!DICTOOL->checkObjectExist_json(_doc, key.c_str())) { return def; } return DICTOOL->getStringValue_json(_doc, key.c_str()); } ComAttribute* ComAttribute::create(void) { ComAttribute * pRet = new ComAttribute(); if (pRet && pRet->init()) { pRet->autorelease(); } else { CC_SAFE_DELETE(pRet); } return pRet; } bool ComAttribute::serialize(void* r) { bool bRet = false; do { CC_BREAK_IF(r == nullptr); rapidjson::Value *v = (rapidjson::Value *)r; const char *className = DICTOOL->getStringValue_json(*v, "classname"); CC_BREAK_IF(className == nullptr); const char *comName = DICTOOL->getStringValue_json(*v, "name"); if (comName != nullptr) { setName(comName); } else { setName(className); } const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData"); CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData)); const char *file = DICTOOL->getStringValue_json(fileData, "path"); CC_BREAK_IF(file == nullptr); std::string filePath; if (file != nullptr) { filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); } int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); CC_BREAK_IF(resType != 0); parse(filePath.c_str()); bRet = true; } while (0); return bRet; } bool ComAttribute::parse(const std::string &jsonFile) { bool ret = false; do { std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonFile); _doc.Parse<0>(contentStr.c_str()); CC_BREAK_IF(_doc.HasParseError()); ret = true; } while (0); return ret; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComAttribute.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EXTENTIONS_CCCOMATTRIBUTE_H__ #define __CC_EXTENTIONS_CCCOMATTRIBUTE_H__ #include "CCComBase.h" namespace cocostudio { class ComAttribute : public cocos2d::Component { DECLARE_CLASS_COMPONENT_INFO protected: /** * @js ctor */ ComAttribute(void); /** * @js NA * @lua NA */ virtual ~ComAttribute(void); public: static ComAttribute* create(void); virtual bool init() override; virtual bool serialize(void* r) override; void setInt(const std::string& key, int value); void setFloat(const std::string& key, float value); void setBool(const std::string& key, bool value); void setString(const std::string& key, const std::string& value); int getInt(const std::string& key, int def = 0) const; float getFloat(const std::string& key, float def = 0.0f) const; bool getBool(const std::string& key, bool def = false) const; std::string getString(const std::string& key, const std::string& def = "") const; bool parse(const std::string &jsonFile); private: cocos2d::ValueMap _dict; rapidjson::Document _doc; }; } #endif // __FUNDATION__CCCOMPONENT_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComAudio.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCComAudio.h" #include "SimpleAudioEngine.h" namespace cocostudio { IMPLEMENT_CLASS_COMPONENT_INFO(ComAudio) ComAudio::ComAudio(void) : _filePath("") , _loop(false) { _name = "CCComAudio"; } ComAudio::~ComAudio(void) { } bool ComAudio::init() { return true; } void ComAudio::onEnter() { } void ComAudio::onExit() { stopBackgroundMusic(true); stopAllEffects(); } bool ComAudio::isEnabled() const { return _enabled; } void ComAudio::setEnabled(bool b) { _enabled = b; } bool ComAudio::serialize(void* r) { bool bRet = false; do { CC_BREAK_IF(r == nullptr); rapidjson::Value *v = (rapidjson::Value *)r; const char *className = DICTOOL->getStringValue_json(*v, "classname"); CC_BREAK_IF(className == nullptr); const char *comName = DICTOOL->getStringValue_json(*v, "name"); if (comName != nullptr) { setName(comName); } else { setName(className); } const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData"); CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData)); const char *file = DICTOOL->getStringValue_json(fileData, "path"); CC_BREAK_IF(file == nullptr); std::string filePath; if (file != nullptr) { filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); } int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); CC_BREAK_IF(resType != 0); if (strcmp(className, "CCBackgroundAudio") == 0) { preloadBackgroundMusic(filePath.c_str()); bool loop = DICTOOL->getIntValue_json(*v, "loop") != 0? true:false; setLoop(loop); playBackgroundMusic(filePath.c_str(), loop); } else if(strcmp(className, "CCComAudio") == 0) { preloadEffect(filePath.c_str()); } else { CC_BREAK_IF(true); } bRet = true; } while (0); return bRet; } ComAudio* ComAudio::create(void) { ComAudio * pRet = new ComAudio(); if (pRet && pRet->init()) { pRet->autorelease(); } else { CC_SAFE_DELETE(pRet); } return pRet; } void ComAudio::end() { CocosDenshion::SimpleAudioEngine::end(); } void ComAudio::preloadBackgroundMusic(const char* pszFilePath) { CocosDenshion::SimpleAudioEngine::getInstance()->preloadBackgroundMusic(pszFilePath); setFile(pszFilePath); setLoop(false); } void ComAudio::playBackgroundMusic(const char* pszFilePath, bool loop) { CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic(pszFilePath, loop); } void ComAudio::playBackgroundMusic(const char* pszFilePath) { CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic(pszFilePath); } void ComAudio::playBackgroundMusic() { CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic(_filePath.c_str(), _loop); } void ComAudio::stopBackgroundMusic(bool bReleaseData) { CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic(bReleaseData); } void ComAudio::stopBackgroundMusic() { CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic(); } void ComAudio::pauseBackgroundMusic() { CocosDenshion::SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); } void ComAudio::resumeBackgroundMusic() { CocosDenshion::SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); } void ComAudio::rewindBackgroundMusic() { CocosDenshion::SimpleAudioEngine::getInstance()->rewindBackgroundMusic(); } bool ComAudio::willPlayBackgroundMusic() { return CocosDenshion::SimpleAudioEngine::getInstance()->willPlayBackgroundMusic(); } bool ComAudio::isBackgroundMusicPlaying() { return CocosDenshion::SimpleAudioEngine::getInstance()->isBackgroundMusicPlaying(); } float ComAudio::getBackgroundMusicVolume() { return CocosDenshion::SimpleAudioEngine::getInstance()->getBackgroundMusicVolume(); } void ComAudio::setBackgroundMusicVolume(float volume) { CocosDenshion::SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(volume); } float ComAudio::getEffectsVolume() { return CocosDenshion::SimpleAudioEngine::getInstance()->getEffectsVolume(); } void ComAudio::setEffectsVolume(float volume) { CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(volume); } unsigned int ComAudio::playEffect(const char* pszFilePath, bool loop) { return CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(pszFilePath, loop); } unsigned int ComAudio::playEffect(const char* pszFilePath) { return CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(pszFilePath); } unsigned int ComAudio::playEffect() { return CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(_filePath.c_str(), _loop); } void ComAudio::pauseEffect(unsigned int nSoundId) { return CocosDenshion::SimpleAudioEngine::getInstance()->pauseEffect(nSoundId); } void ComAudio::pauseAllEffects() { CocosDenshion::SimpleAudioEngine::getInstance()->pauseAllEffects(); } void ComAudio::resumeEffect(unsigned int nSoundId) { CocosDenshion::SimpleAudioEngine::getInstance()->resumeEffect(nSoundId); } void ComAudio::resumeAllEffects() { CocosDenshion::SimpleAudioEngine::getInstance()->resumeAllEffects(); } void ComAudio::stopEffect(unsigned int nSoundId) { CocosDenshion::SimpleAudioEngine::getInstance()->stopEffect(nSoundId); } void ComAudio::stopAllEffects() { CocosDenshion::SimpleAudioEngine::getInstance()->stopAllEffects(); } void ComAudio::preloadEffect(const char* pszFilePath) { CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect(pszFilePath); setFile(pszFilePath); setLoop(false); } void ComAudio::unloadEffect(const char *pszFilePath) { CocosDenshion::SimpleAudioEngine::getInstance()->unloadEffect(pszFilePath); } void ComAudio::setFile(const char* pszFilePath) { _filePath.assign(pszFilePath); } void ComAudio::setLoop(bool loop) { _loop = loop; } const char* ComAudio::getFile() { return _filePath.c_str(); } bool ComAudio::isLoop() { return _loop; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComAudio.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EXTENTIONS_CCCOMAUDIO_H__ #define __CC_EXTENTIONS_CCCOMAUDIO_H__ #include "CCComBase.h" namespace cocostudio { class ComAudio : public cocos2d::Component { DECLARE_CLASS_COMPONENT_INFO protected: /** * @js ctor */ ComAudio(void); /** * @js NA * @lua NA */ virtual ~ComAudio(void); public: virtual bool init() override; /** * @js NA * @lua NA */ virtual void onEnter() override; /** * @js NA * @lua NA */ virtual void onExit() override; virtual bool isEnabled() const override; virtual void setEnabled(bool b) override; virtual bool serialize(void* r) override; static ComAudio* create(void); public: void end(); void preloadBackgroundMusic(const char* pszFilePath); void playBackgroundMusic(const char* pszFilePath, bool bLoop); void playBackgroundMusic(const char* pszFilePath); void playBackgroundMusic(); void stopBackgroundMusic(bool bReleaseData); void stopBackgroundMusic(); void pauseBackgroundMusic(); void resumeBackgroundMusic(); void rewindBackgroundMusic(); bool willPlayBackgroundMusic(); bool isBackgroundMusicPlaying(); float getBackgroundMusicVolume(); void setBackgroundMusicVolume(float volume); float getEffectsVolume(); void setEffectsVolume(float volume); unsigned int playEffect(const char* pszFilePath, bool bLoop); unsigned int playEffect(const char* pszFilePath); unsigned int playEffect(); void pauseEffect(unsigned int nSoundId); void pauseAllEffects(); void resumeEffect(unsigned int nSoundId); void resumeAllEffects(); void stopEffect(unsigned int nSoundId); void stopAllEffects(); void preloadEffect(const char* pszFilePath); void unloadEffect(const char* pszFilePath); void setFile(const char* pszFilePath); const char* getFile(); void setLoop(bool bLoop); bool isLoop(); private: std::string _filePath; bool _loop; }; } #endif // __FUNDATION__CCCOMPONENT_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComBase.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EXTENTIONS_CCCOMBASE_H__ #define __CC_EXTENTIONS_CCCOMBASE_H__ #include "ObjectFactory.h" #include "DictionaryHelper.h" #include #define DECLARE_CLASS_COMPONENT_INFO \ public: \ static cocostudio::ObjectFactory::TInfo Type; \ static cocos2d::Object* createInstance(void); \ #define IMPLEMENT_CLASS_COMPONENT_INFO(className) \ cocos2d::Object* className::createInstance(void) \ { \ return className::create(); \ } \ cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \ #define CREATE_CLASS_COMPONENT_INFO(className) \ cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComController.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCComController.h" namespace cocostudio { IMPLEMENT_CLASS_COMPONENT_INFO(ComController) ComController::ComController(void) { _name = "CCComController"; } ComController::~ComController(void) { } bool ComController::init() { return true; } void ComController::onEnter() { } void ComController::onExit() { } void ComController::update(float delta) { } bool ComController::isEnabled() const { return _enabled; } void ComController::setEnabled(bool b) { _enabled = b; } ComController* ComController::create(void) { ComController * pRet = new ComController(); if (pRet && pRet->init()) { pRet->autorelease(); } else { CC_SAFE_DELETE(pRet); } return pRet; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComController.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EXTENTIONS_CCCOMCONTROLLER_H__ #define __CC_EXTENTIONS_CCCOMCONTROLLER_H__ #include "CCComBase.h" #include "cocostudio/CCInputDelegate.h" namespace cocostudio { class ComController : public cocos2d::Component, public InputDelegate { DECLARE_CLASS_COMPONENT_INFO public: /** * @js ctor */ ComController(void); public: /** * @js NA * @lua NA */ virtual ~ComController(void); virtual bool init() override; /** * @js NA * @lua NA */ virtual void onEnter() override; /** * @js NA * @lua NA */ virtual void onExit() override; virtual void update(float delta) override; virtual bool isEnabled() const override; virtual void setEnabled(bool b) override; static ComController* create(void); }; } #endif // __FUNDATION__CCCOMPONENT_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComRender.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCComRender.h" #include "cocostudio/CocoStudio.h" using namespace cocos2d; namespace cocostudio { IMPLEMENT_CLASS_COMPONENT_INFO(ComRender) ComRender::ComRender(void) : _render(nullptr) { _name = "CCComRender"; } ComRender::ComRender(cocos2d::Node *node, const char *comName) { _render = node; _name.assign(comName); } ComRender::~ComRender(void) { _render = nullptr; } void ComRender::onEnter() { if (_owner != nullptr) { _owner->addChild(_render); } } void ComRender::onExit() { _render = nullptr; } cocos2d::Node* ComRender::getNode() { return _render; } void ComRender::setNode(cocos2d::Node *node) { _render = node; } bool ComRender::serialize(void* r) { bool bRet = false; do { CC_BREAK_IF(r == nullptr); rapidjson::Value *v = (rapidjson::Value *)r; const char *className = DICTOOL->getStringValue_json(*v, "classname"); CC_BREAK_IF(className == nullptr); const char *comName = DICTOOL->getStringValue_json(*v, "name"); if (comName != nullptr) { setName(comName); } else { setName(className); } const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData"); CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData)); const char *file = DICTOOL->getStringValue_json(fileData, "path"); const char *plist = DICTOOL->getStringValue_json(fileData, "plistFile"); CC_BREAK_IF(file == nullptr && plist == nullptr); std::string filePath; std::string plistPath; if (file != nullptr) { filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); } if (plist != nullptr) { plistPath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(plist)); } int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); if (resType == 0) { if (strcmp(className, "CCSprite") == 0 && filePath.find(".png") != std::string::npos) { _render = Sprite::create(filePath.c_str()); } else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != std::string::npos) { _render = TMXTiledMap::create(filePath.c_str()); } else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != std::string::npos) { _render = ParticleSystemQuad::create(filePath.c_str()); _render->setPosition(Point(0.0f, 0.0f)); } else if(strcmp(className, "CCArmature") == 0) { std::string reDir = filePath; std::string file_path = ""; size_t pos = reDir.find_last_of('/'); if (pos != std::string::npos) { file_path = reDir.substr(0, pos+1); } rapidjson::Document doc; if(!readJson(filePath.c_str(), doc)) { log("read json file[%s] error!\n", filePath.c_str()); continue; } const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0); const char *name = DICTOOL->getStringValue_json(subData, "name"); ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str()); Armature *pAr = Armature::create(name); _render = pAr; const char *actionName = DICTOOL->getStringValue_json(*v, "selectedactionname"); if (actionName != nullptr && pAr->getAnimation() != nullptr) { pAr->getAnimation()->play(actionName); } } else if(strcmp(className, "GUIComponent") == 0) { cocos2d::gui::Widget* widget = GUIReader::getInstance()->widgetFromJsonFile(filePath.c_str()); _render = widget; } else { CC_BREAK_IF(true); } } else if (resType == 1) { if (strcmp(className, "CCSprite") == 0) { std::string strPngFile = plistPath; std::string::size_type pos = strPngFile.find(".plist"); if (pos == strPngFile.npos) { continue; } strPngFile.replace(pos, strPngFile.length(), ".png"); SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str()); _render = Sprite::createWithSpriteFrameName(filePath.c_str()); } else { CC_BREAK_IF(true); } } else { CC_BREAK_IF(true); } bRet = true; } while (0); return bRet; } ComRender* ComRender::create(void) { ComRender * ret = new ComRender(); if (ret != nullptr && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } ComRender* ComRender::create(cocos2d::Node *node, const char *comName) { ComRender * ret = new ComRender(node, comName); if (ret != nullptr && ret->init()) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } return ret; } bool ComRender::readJson(const std::string &fileName, rapidjson::Document &doc) { bool ret = false; do { std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName); doc.Parse<0>(contentStr.c_str()); CC_BREAK_IF(doc.HasParseError()); ret = true; } while (0); return ret; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCComRender.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EXTENTIONS_CCCOMRENDER_H__ #define __CC_EXTENTIONS_CCCOMRENDER_H__ #include "CCComBase.h" namespace cocostudio { class ComRender : public cocos2d::Component { DECLARE_CLASS_COMPONENT_INFO protected: /** * @js ctor */ ComRender(void); ComRender(cocos2d::Node *node, const char *comName); /** * @js NA * @lua NA */ virtual ~ComRender(void); public: /** * @js NA * @lua NA */ virtual void onEnter() override; /** * @js NA * @lua NA */ virtual void onExit() override; virtual bool serialize(void* r) override; virtual cocos2d::Node* getNode(); virtual void setNode(cocos2d::Node *node); static ComRender* create(void); static ComRender* create(cocos2d::Node *node, const char *comName); private: bool readJson(const std::string &fileName, rapidjson::Document &doc); private: cocos2d::Node *_render; }; } #endif // __FUNDATION__CCCOMPONENT_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "platform/CCFileUtils.h" #include "CCDirector.h" #include "CCScheduler.h" #include "tinyxml2.h" #include "cocostudio/CCDataReaderHelper.h" #include "cocostudio/CCArmatureDataManager.h" #include "cocostudio/CCTransformHelp.h" #include "cocostudio/CCUtilMath.h" #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDatas.h" using namespace cocos2d; static const char *VERSION = "version"; static const float VERSION_2_0 = 2.0f; static const char *ARMATURES = "armatures"; static const char *ARMATURE = "armature"; static const char *BONE = "b"; static const char *DISPLAY = "d"; static const char *ANIMATIONS = "animations"; static const char *ANIMATION = "animation"; static const char *MOVEMENT = "mov"; static const char *FRAME = "f"; static const char *TEXTURE_ATLAS = "TextureAtlas"; static const char *SUB_TEXTURE = "SubTexture"; static const char *A_NAME = "name"; static const char *A_DURATION = "dr"; static const char *A_FRAME_INDEX = "fi"; static const char *A_DURATION_TO = "to"; static const char *A_DURATION_TWEEN = "drTW"; static const char *A_LOOP = "lp"; static const char *A_MOVEMENT_SCALE = "sc"; static const char *A_MOVEMENT_DELAY = "dl"; static const char *A_DISPLAY_INDEX = "dI"; static const char *A_PLIST = "plist"; static const char *A_PARENT = "parent"; static const char *A_SKEW_X = "kX"; static const char *A_SKEW_Y = "kY"; static const char *A_SCALE_X = "cX"; static const char *A_SCALE_Y = "cY"; static const char *A_Z = "z"; static const char *A_EVENT = "evt"; static const char *A_SOUND = "sd"; static const char *A_SOUND_EFFECT = "sdE"; static const char *A_TWEEN_EASING = "twE"; static const char *A_EASING_PARAM = "twEP"; static const char *A_TWEEN_ROTATE = "twR"; static const char *A_IS_ARMATURE = "isArmature"; static const char *A_DISPLAY_TYPE = "displayType"; static const char *A_MOVEMENT = "mov"; static const char *A_X = "x"; static const char *A_Y = "y"; static const char *A_COCOS2DX_X = "cocos2d_x"; static const char *A_COCOS2DX_Y = "cocos2d_y"; static const char *A_WIDTH = "width"; static const char *A_HEIGHT = "height"; static const char *A_PIVOT_X = "pX"; static const char *A_PIVOT_Y = "pY"; static const char *A_COCOS2D_PIVOT_X = "cocos2d_pX"; static const char *A_COCOS2D_PIVOT_Y = "cocos2d_pY"; static const char *A_BLEND_TYPE = "bd"; static const char *A_BLEND_SRC = "bd_src"; static const char *A_BLEND_DST = "bd_dst"; static const char *A_ALPHA = "a"; static const char *A_RED = "r"; static const char *A_GREEN = "g"; static const char *A_BLUE = "b"; static const char *A_ALPHA_OFFSET = "aM"; static const char *A_RED_OFFSET = "rM"; static const char *A_GREEN_OFFSET = "gM"; static const char *A_BLUE_OFFSET = "bM"; static const char *A_COLOR_TRANSFORM = "colorTransform"; static const char *A_TWEEN_FRAME = "tweenFrame"; static const char *CONTOUR = "con"; static const char *CONTOUR_VERTEX = "con_vt"; static const char *FL_NAN = "NaN"; static const char *FRAME_DATA = "frame_data"; static const char *MOVEMENT_BONE_DATA = "mov_bone_data"; static const char *MOVEMENT_DATA = "mov_data"; static const char *ANIMATION_DATA = "animation_data"; static const char *DISPLAY_DATA = "display_data"; static const char *SKIN_DATA = "skin_data"; static const char *BONE_DATA = "bone_data"; static const char *ARMATURE_DATA = "armature_data"; static const char *CONTOUR_DATA = "contour_data"; static const char *TEXTURE_DATA = "texture_data"; static const char *VERTEX_POINT = "vertex"; static const char *COLOR_INFO = "color"; static const char *CONFIG_FILE_PATH = "config_file_path"; static const char *CONTENT_SCALE = "content_scale"; namespace cocostudio { float s_PositionReadScale = 1; std::vector DataReaderHelper::_configFileList; DataReaderHelper *DataReaderHelper::_dataReaderHelper = nullptr; //! Async load void DataReaderHelper::loadData() { AsyncStruct *pAsyncStruct = nullptr; while (true) { std::queue *pQueue = _asyncStructQueue; _asyncStructQueueMutex.lock(); // get async struct from queue if (pQueue->empty()) { _asyncStructQueueMutex.unlock(); if (need_quit) { break; } else { std::unique_lock lk(_sleepMutex); _sleepCondition.wait(lk); continue; } } else { pAsyncStruct = pQueue->front(); pQueue->pop(); _asyncStructQueueMutex.unlock(); } // generate data info DataInfo *pDataInfo = new DataInfo(); pDataInfo->asyncStruct = pAsyncStruct; pDataInfo->filename = pAsyncStruct->filename; pDataInfo->baseFilePath = pAsyncStruct->baseFilePath; if (pAsyncStruct->configType == DragonBone_XML) { DataReaderHelper::addDataFromCache(pAsyncStruct->fileContent.c_str(), pDataInfo); } else if(pAsyncStruct->configType == CocoStudio_JSON) { DataReaderHelper::addDataFromJsonCache(pAsyncStruct->fileContent.c_str(), pDataInfo); } // put the image info into the queue _dataInfoMutex.lock(); _dataQueue->push(pDataInfo); _dataInfoMutex.unlock(); } if( _asyncStructQueue != nullptr ) { delete _asyncStructQueue; _asyncStructQueue = nullptr; delete _dataQueue; _dataQueue = nullptr; } } DataReaderHelper *DataReaderHelper::getInstance() { if(!_dataReaderHelper) { _dataReaderHelper = new DataReaderHelper(); } return _dataReaderHelper; } void DataReaderHelper::setPositionReadScale(float scale) { s_PositionReadScale = scale; } float DataReaderHelper::getPositionReadScale() { return s_PositionReadScale; } void DataReaderHelper::purge() { _configFileList.clear(); CC_SAFE_RELEASE_NULL(_dataReaderHelper); } DataReaderHelper::DataReaderHelper() : _loadingThread(nullptr) , _asyncRefCount(0) , _asyncRefTotalCount(0) , need_quit(false) , _asyncStructQueue(nullptr) , _dataQueue(nullptr) { } DataReaderHelper::~DataReaderHelper() { need_quit = true; _sleepCondition.notify_one(); if (_loadingThread) _loadingThread->join(); CC_SAFE_DELETE(_loadingThread); _dataReaderHelper = nullptr; } void DataReaderHelper::addDataFromFile(const std::string& filePath) { /* * Check if file is already added to ArmatureDataManager, if then return. */ for(unsigned int i = 0; i < _configFileList.size(); i++) { if (_configFileList[i] == filePath) { return; } } _configFileList.push_back(filePath); //! find the base file path std::string basefilePath = filePath; size_t pos = basefilePath.find_last_of("/"); if (pos != std::string::npos) { basefilePath = basefilePath.substr(0, pos + 1); } else { basefilePath = ""; } std::string filePathStr = filePath; size_t startPos = filePathStr.find_last_of("."); std::string str = &filePathStr[startPos]; // Read content from file std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filePath); std::string contentStr = FileUtils::getInstance()->getStringFromFile(fullPath); DataInfo dataInfo; dataInfo.filename = filePathStr; dataInfo.asyncStruct = nullptr; dataInfo.baseFilePath = basefilePath; if (str == ".xml") { DataReaderHelper::addDataFromCache(contentStr, &dataInfo); } else if(str == ".json" || str == ".ExportJson") { DataReaderHelper::addDataFromJsonCache(contentStr, &dataInfo); } } void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, Object *target, SEL_SCHEDULE selector) { /* * Check if file is already added to ArmatureDataManager, if then return. */ for(unsigned int i = 0; i < _configFileList.size(); i++) { if (_configFileList[i] == filePath) { if (target && selector) { if (_asyncRefTotalCount == 0 && _asyncRefCount == 0) { (target->*selector)(1); } else { (target->*selector)((_asyncRefTotalCount - _asyncRefCount) / (float)_asyncRefTotalCount); } } return; } } _configFileList.push_back(filePath); //! find the base file path std::string basefilePath = filePath; size_t pos = basefilePath.find_last_of("/"); if (pos != std::string::npos) { basefilePath = basefilePath.substr(0, pos + 1); } else { basefilePath = ""; } // lazy init if (_asyncStructQueue == nullptr) { _asyncStructQueue = new std::queue(); _dataQueue = new std::queue(); // create a new thread to load images _loadingThread = new std::thread(&DataReaderHelper::loadData, this); need_quit = false; } if (0 == _asyncRefCount) { Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this, 0, false); } ++_asyncRefCount; ++_asyncRefTotalCount; if (target) { target->retain(); } // generate async struct AsyncStruct *data = new AsyncStruct(); data->filename = filePath; data->baseFilePath = basefilePath; data->target = target; data->selector = selector; data->autoLoadSpriteFile = ArmatureDataManager::getInstance()->isAutoLoadSpriteFile(); data->imagePath = imagePath; data->plistPath = plistPath; std::string filePathStr = filePath; size_t startPos = filePathStr.find_last_of("."); std::string str = &filePathStr[startPos]; std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filePath); // XXX fileContent is being leaked data->fileContent = FileUtils::getInstance()->getStringFromFile(fullPath); if (str == ".xml") { data->configType = DragonBone_XML; } else if(str == ".json" || str == ".ExportJson") { data->configType = CocoStudio_JSON; } // add async struct into queue _asyncStructQueueMutex.lock(); _asyncStructQueue->push(data); _asyncStructQueueMutex.unlock(); _sleepCondition.notify_one(); } void DataReaderHelper::addDataAsyncCallBack(float dt) { // the data is generated in loading thread std::queue *dataQueue = _dataQueue; _dataInfoMutex.lock(); if (dataQueue->empty()) { _dataInfoMutex.unlock(); } else { DataInfo *pDataInfo = dataQueue->front(); dataQueue->pop(); _dataInfoMutex.unlock(); AsyncStruct *pAsyncStruct = pDataInfo->asyncStruct; if (pAsyncStruct->imagePath != "" && pAsyncStruct->plistPath != "") { _getFileMutex.lock(); ArmatureDataManager::getInstance()->addSpriteFrameFromFile(pAsyncStruct->plistPath.c_str(), pAsyncStruct->imagePath.c_str()); _getFileMutex.unlock(); } while (!pDataInfo->configFileQueue.empty()) { std::string configPath = pDataInfo->configFileQueue.front(); _getFileMutex.lock(); ArmatureDataManager::getInstance()->addSpriteFrameFromFile((pAsyncStruct->baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct->baseFilePath + configPath + ".png").c_str()); _getFileMutex.unlock(); pDataInfo->configFileQueue.pop(); } Object *target = pAsyncStruct->target; SEL_SCHEDULE selector = pAsyncStruct->selector; --_asyncRefCount; if (target && selector) { (target->*selector)((_asyncRefTotalCount - _asyncRefCount) / (float)_asyncRefTotalCount); target->release(); } delete pAsyncStruct; delete pDataInfo; if (0 == _asyncRefCount) { _asyncRefTotalCount = 0; Director::getInstance()->getScheduler()->unscheduleSelector(schedule_selector(DataReaderHelper::addDataAsyncCallBack), this); } } } void DataReaderHelper::removeConfigFile(const std::string& configFile) { std::vector::iterator it = _configFileList.end(); for (std::vector::iterator i = _configFileList.begin(); i != _configFileList.end(); i++) { if (*i == configFile) { it = i; } } if (it != _configFileList.end()) { _configFileList.erase(it); } } void DataReaderHelper::addDataFromCache(const std::string& pFileContent, DataInfo *dataInfo) { tinyxml2::XMLDocument document; document.Parse(pFileContent.c_str()); tinyxml2::XMLElement *root = document.RootElement(); CCASSERT(root, "XML error or XML is empty."); root->QueryFloatAttribute(VERSION, &dataInfo->flashToolVersion); /* * Begin decode armature data from xml */ tinyxml2::XMLElement *armaturesXML = root->FirstChildElement(ARMATURES); tinyxml2::XMLElement *armatureXML = armaturesXML->FirstChildElement(ARMATURE); while(armatureXML) { ArmatureData *armatureData = DataReaderHelper::decodeArmature(armatureXML, dataInfo); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.lock(); } ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData, dataInfo->filename.c_str()); armatureData->release(); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.unlock(); } armatureXML = armatureXML->NextSiblingElement(ARMATURE); } /* * Begin decode animation data from xml */ tinyxml2::XMLElement *animationsXML = root->FirstChildElement(ANIMATIONS); tinyxml2::XMLElement *animationXML = animationsXML->FirstChildElement(ANIMATION); while(animationXML) { AnimationData *animationData = DataReaderHelper::decodeAnimation(animationXML, dataInfo); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.lock(); } ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData, dataInfo->filename.c_str()); animationData->release(); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.unlock(); } animationXML = animationXML->NextSiblingElement(ANIMATION); } /* * Begin decode texture data from xml */ tinyxml2::XMLElement *texturesXML = root->FirstChildElement(TEXTURE_ATLAS); tinyxml2::XMLElement *textureXML = texturesXML->FirstChildElement(SUB_TEXTURE); while(textureXML) { TextureData *textureData = DataReaderHelper::decodeTexture(textureXML, dataInfo); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.lock(); } ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData, dataInfo->filename.c_str()); textureData->release(); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.unlock(); } textureXML = textureXML->NextSiblingElement(SUB_TEXTURE); } } ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML, DataInfo *dataInfo) { ArmatureData *armatureData = new ArmatureData(); armatureData->init(); armatureData->name = armatureXML->Attribute(A_NAME); tinyxml2::XMLElement *boneXML = armatureXML->FirstChildElement(BONE); while( boneXML ) { /* * If this bone have parent, then get the parent bone xml */ const char *parentName = boneXML->Attribute(A_PARENT); tinyxml2::XMLElement *parentXML = nullptr; if (parentName) { parentXML = armatureXML->FirstChildElement(BONE); std::string parentNameStr = parentName; while (parentXML) { if (parentNameStr == parentXML->Attribute(A_NAME)) { break; } parentXML = parentXML->NextSiblingElement(BONE); } } BoneData *boneData = decodeBone(boneXML, parentXML, dataInfo); armatureData->addBoneData(boneData); boneData->release(); boneXML = boneXML->NextSiblingElement(BONE); } return armatureData; } BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXml, DataInfo *dataInfo) { BoneData *boneData = new BoneData(); boneData->init(); std::string name = boneXML->Attribute(A_NAME); boneData->name = name; if( boneXML->Attribute(A_PARENT) != nullptr ) { boneData->parentName = boneXML->Attribute(A_PARENT); } boneXML->QueryIntAttribute(A_Z, &boneData->zOrder); tinyxml2::XMLElement *displayXML = boneXML->FirstChildElement(DISPLAY); while(displayXML) { DisplayData *displayData = decodeBoneDisplay(displayXML, dataInfo); boneData->addDisplayData(displayData); displayData->release(); displayXML = displayXML->NextSiblingElement(DISPLAY); } return boneData; } DisplayData *DataReaderHelper::decodeBoneDisplay(tinyxml2::XMLElement *displayXML, DataInfo *dataInfo) { int _isArmature = 0; DisplayData *displayData; if( displayXML->QueryIntAttribute(A_IS_ARMATURE, &(_isArmature)) == tinyxml2::XML_SUCCESS ) { if(!_isArmature) { displayData = new SpriteDisplayData(); displayData->displayType = CS_DISPLAY_SPRITE; } else { displayData = new ArmatureDisplayData(); displayData->displayType = CS_DISPLAY_ARMATURE; } } else { displayData = new SpriteDisplayData(); displayData->displayType = CS_DISPLAY_SPRITE; } if(displayXML->Attribute(A_NAME) != nullptr ) { if(!_isArmature) { ((SpriteDisplayData *)displayData)->displayName = displayXML->Attribute(A_NAME); } else { ((ArmatureDisplayData *)displayData)->displayName = displayXML->Attribute(A_NAME); } } return displayData; } AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animationXML, DataInfo *dataInfo) { AnimationData *aniData = new AnimationData(); const char *name = animationXML->Attribute(A_NAME); ArmatureData *armatureData = ArmatureDataManager::getInstance()->getArmatureData(name); aniData->name = name; tinyxml2::XMLElement *movementXML = animationXML->FirstChildElement(MOVEMENT); while( movementXML ) { MovementData *movementData = decodeMovement(movementXML, armatureData, dataInfo); aniData->addMovement(movementData); movementData->release(); movementXML = movementXML->NextSiblingElement(MOVEMENT); } return aniData; } MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData, DataInfo *dataInfo) { MovementData *movementData = new MovementData(); const char *movName = movementXML->Attribute(A_NAME); movementData->name = movName; int duration, durationTo, durationTween, loop, tweenEasing = 0; if( movementXML->QueryIntAttribute(A_DURATION, &(duration)) == tinyxml2::XML_SUCCESS) { movementData->duration = duration; } if( movementXML->QueryIntAttribute(A_DURATION_TO, &(durationTo)) == tinyxml2::XML_SUCCESS) { movementData->durationTo = durationTo; } if( movementXML->QueryIntAttribute(A_DURATION_TWEEN, &(durationTween)) == tinyxml2::XML_SUCCESS) { movementData->durationTween = durationTween; } if( movementXML->QueryIntAttribute(A_LOOP, &(loop)) == tinyxml2::XML_SUCCESS) { movementData->loop = (loop != 0); } const char *_easing = movementXML->Attribute(A_TWEEN_EASING); if(_easing != nullptr) { std::string str = _easing; if(str != FL_NAN) { if( movementXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS) { movementData->tweenEasing = tweenEasing == 2 ? Sine_EaseInOut : (TweenType)tweenEasing; } } else { movementData->tweenEasing = Linear; } } tinyxml2::XMLElement *movBoneXml = movementXML->FirstChildElement(BONE); while(movBoneXml) { const char *boneName = movBoneXml->Attribute(A_NAME); if (movementData->getMovementBoneData(boneName)) { movBoneXml = movBoneXml->NextSiblingElement(); continue; } BoneData *boneData = (BoneData *)armatureData->getBoneData(boneName); std::string parentName = boneData->parentName; tinyxml2::XMLElement *parentXml = nullptr; if (parentName.length() != 0) { parentXml = movementXML->FirstChildElement(BONE); while (parentXml) { if (parentName == parentXml->Attribute(A_NAME)) { break; } parentXml = parentXml->NextSiblingElement(BONE); } } MovementBoneData *moveBoneData = decodeMovementBone(movBoneXml, parentXml, boneData, dataInfo); movementData->addMovementBoneData(moveBoneData); moveBoneData->release(); movBoneXml = movBoneXml->NextSiblingElement(BONE); } return movementData; } MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData, DataInfo *dataInfo) { MovementBoneData *movBoneData = new MovementBoneData(); movBoneData->init(); float scale, delay; if( movBoneXml ) { if( movBoneXml->QueryFloatAttribute(A_MOVEMENT_SCALE, &scale) == tinyxml2::XML_SUCCESS ) { movBoneData->scale = scale; } if( movBoneXml->QueryFloatAttribute(A_MOVEMENT_DELAY, &delay) == tinyxml2::XML_SUCCESS ) { if(delay > 0) { delay -= 1; } movBoneData->delay = delay; } } unsigned long length = 0; unsigned long index = 0; int parentTotalDuration = 0; int currentDuration = 0; tinyxml2::XMLElement *parentFrameXML = nullptr; std::vector parentXmlList; /* * get the parent frame xml list, we need get the origin data */ if( parentXml != nullptr ) { parentFrameXML = parentXml->FirstChildElement(FRAME); while (parentFrameXML) { parentXmlList.push_back(parentFrameXML); parentFrameXML = parentFrameXML->NextSiblingElement(FRAME); } parentFrameXML = nullptr; length = parentXmlList.size(); } int totalDuration = 0; std::string name = movBoneXml->Attribute(A_NAME); movBoneData->name = name; tinyxml2::XMLElement *frameXML = movBoneXml->FirstChildElement(FRAME); while( frameXML ) { if(parentXml) { /* * in this loop we get the corresponding parent frame xml */ while(index < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) { parentFrameXML = parentXmlList[index]; parentTotalDuration += currentDuration; parentFrameXML->QueryIntAttribute(A_DURATION, ¤tDuration); index++; } } FrameData *frameData = decodeFrame( frameXML, parentFrameXML, boneData, dataInfo); movBoneData->addFrameData(frameData); frameData->release(); frameData->frameID = totalDuration; totalDuration += frameData->duration; movBoneData->duration = totalDuration; frameXML = frameXML->NextSiblingElement(FRAME); } //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) auto frames = movBoneData->frameList; for (long j = movBoneData->frameList.size() - 1; j >= 0; j--) { if (j > 0) { float difSkewX = frames.at(j)->skewX - frames.at(j-1)->skewX; float difSkewY = frames.at(j)->skewY - frames.at(j-1)->skewY; if (difSkewX < -M_PI || difSkewX > M_PI) { frames.at(j-1)->skewX = difSkewX < 0 ? frames.at(j-1)->skewX - 2 * M_PI : frames.at(j-1)->skewX + 2 * M_PI; } if (difSkewY < -M_PI || difSkewY > M_PI) { frames.at(j-1)->skewY = difSkewY < 0 ? frames.at(j-1)->skewY - 2 * M_PI : frames.at(j-1)->skewY + 2 * M_PI; } } } // FrameData *frameData = new FrameData(); frameData->copy((FrameData *)movBoneData->frameList.back()); frameData->frameID = movBoneData->duration; movBoneData->addFrameData(frameData); frameData->release(); return movBoneData; } FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo) { float x = 0, y = 0, scale_x = 0, scale_y = 0, skew_x = 0, skew_y = 0, tweenRotate = 0; int duration = 0, displayIndex = 0, zOrder = 0, tweenEasing = 0, blendType = 0; FrameData *frameData = new FrameData(); if(frameXML->Attribute(A_MOVEMENT) != nullptr) { frameData->strMovement = frameXML->Attribute(A_MOVEMENT); } if(frameXML->Attribute(A_EVENT) != nullptr) { frameData->strEvent = frameXML->Attribute(A_EVENT); } if(frameXML->Attribute(A_SOUND) != nullptr) { frameData->strSound = frameXML->Attribute(A_SOUND); } if(frameXML->Attribute(A_SOUND_EFFECT) != nullptr) { frameData->strSoundEffect = frameXML->Attribute(A_SOUND_EFFECT); } bool tweenFrame = false; if (frameXML->QueryBoolAttribute(A_TWEEN_FRAME, &tweenFrame) == tinyxml2::XML_SUCCESS) { frameData->isTween = tweenFrame; } if (dataInfo->flashToolVersion >= VERSION_2_0) { if(frameXML->QueryFloatAttribute(A_COCOS2DX_X, &x) == tinyxml2::XML_SUCCESS) { frameData->x = x; frameData->x *= s_PositionReadScale; } if(frameXML->QueryFloatAttribute(A_COCOS2DX_Y, &y) == tinyxml2::XML_SUCCESS) { frameData->y = -y; frameData->y *= s_PositionReadScale; } } else { if(frameXML->QueryFloatAttribute(A_X, &x) == tinyxml2::XML_SUCCESS) { frameData->x = x; frameData->x *= s_PositionReadScale; } if(frameXML->QueryFloatAttribute(A_Y, &y) == tinyxml2::XML_SUCCESS) { frameData->y = -y; frameData->y *= s_PositionReadScale; } } if( frameXML->QueryFloatAttribute(A_SCALE_X, &scale_x) == tinyxml2::XML_SUCCESS ) { frameData->scaleX = scale_x; } if( frameXML->QueryFloatAttribute(A_SCALE_Y, &scale_y) == tinyxml2::XML_SUCCESS ) { frameData->scaleY = scale_y; } if( frameXML->QueryFloatAttribute(A_SKEW_X, &skew_x) == tinyxml2::XML_SUCCESS ) { frameData->skewX = CC_DEGREES_TO_RADIANS(skew_x); } if( frameXML->QueryFloatAttribute(A_SKEW_Y, &skew_y) == tinyxml2::XML_SUCCESS ) { frameData->skewY = CC_DEGREES_TO_RADIANS(-skew_y); } if( frameXML->QueryIntAttribute(A_DURATION, &duration) == tinyxml2::XML_SUCCESS ) { frameData->duration = duration; } if( frameXML->QueryIntAttribute(A_DISPLAY_INDEX, &displayIndex) == tinyxml2::XML_SUCCESS ) { frameData->displayIndex = displayIndex; } if( frameXML->QueryIntAttribute(A_Z, &zOrder) == tinyxml2::XML_SUCCESS ) { frameData->zOrder = zOrder; } if( frameXML->QueryFloatAttribute(A_TWEEN_ROTATE, &tweenRotate) == tinyxml2::XML_SUCCESS ) { frameData->tweenRotate = tweenRotate; } if ( frameXML->QueryIntAttribute(A_BLEND_TYPE, &blendType) == tinyxml2::XML_SUCCESS ) { switch (blendType) { case BLEND_NORMAL: { frameData->blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } break; case BLEND_ADD: { frameData->blendFunc.src = GL_SRC_ALPHA; frameData->blendFunc.dst = GL_ONE; } break; case BLEND_MULTIPLY: { frameData->blendFunc.src = GL_DST_COLOR; frameData->blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; } break; case BLEND_SCREEN: { frameData->blendFunc.src = GL_ONE; frameData->blendFunc.dst = GL_ONE_MINUS_SRC_COLOR; } break; default: { frameData->blendFunc.src = CC_BLEND_SRC; frameData->blendFunc.dst = CC_BLEND_DST; } break; } } tinyxml2::XMLElement *colorTransformXML = frameXML->FirstChildElement(A_COLOR_TRANSFORM); if (colorTransformXML) { int alpha, red, green, blue = 100; int alphaOffset, redOffset, greenOffset, blueOffset = 0; colorTransformXML->QueryIntAttribute(A_ALPHA, &alpha); colorTransformXML->QueryIntAttribute(A_RED, &red); colorTransformXML->QueryIntAttribute(A_GREEN, &green); colorTransformXML->QueryIntAttribute(A_BLUE, &blue) ; colorTransformXML->QueryIntAttribute(A_ALPHA_OFFSET, &alphaOffset); colorTransformXML->QueryIntAttribute(A_RED_OFFSET, &redOffset); colorTransformXML->QueryIntAttribute(A_GREEN_OFFSET, &greenOffset); colorTransformXML->QueryIntAttribute(A_BLUE_OFFSET, &blueOffset) ; frameData->a = 2.55 * alphaOffset + alpha; frameData->r = 2.55 * redOffset + red; frameData->g = 2.55 * greenOffset + green; frameData->b = 2.55 * blueOffset + blue; frameData->isUseColorInfo = true; } const char *_easing = frameXML->Attribute(A_TWEEN_EASING); if(_easing != nullptr) { std::string str = _easing; if(str != FL_NAN) { if( frameXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS) { frameData->tweenEasing = tweenEasing == 2 ? Sine_EaseInOut : (TweenType)tweenEasing; } } else { frameData->tweenEasing = Linear; } } if(parentFrameXml) { /* * recalculate frame data from parent frame data, use for translate matrix */ BaseData helpNode; if (dataInfo->flashToolVersion >= VERSION_2_0) { parentFrameXml->QueryFloatAttribute(A_COCOS2DX_X, &helpNode.x); parentFrameXml->QueryFloatAttribute(A_COCOS2DX_Y, &helpNode.y); } else { parentFrameXml->QueryFloatAttribute(A_X, &helpNode.x); parentFrameXml->QueryFloatAttribute(A_Y, &helpNode.y); } parentFrameXml->QueryFloatAttribute(A_SKEW_X, &helpNode.skewX); parentFrameXml->QueryFloatAttribute(A_SKEW_Y, &helpNode.skewY); helpNode.y = -helpNode.y; helpNode.skewX = CC_DEGREES_TO_RADIANS(helpNode.skewX); helpNode.skewY = CC_DEGREES_TO_RADIANS(-helpNode.skewY); TransformHelp::transformFromParent(*frameData, helpNode); } return frameData; } TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML, DataInfo *dataInfo) { TextureData *textureData = new TextureData(); textureData->init(); if( textureXML->Attribute(A_NAME) != nullptr) { textureData->name = textureXML->Attribute(A_NAME); } float px, py, width, height = 0; if(dataInfo->flashToolVersion >= VERSION_2_0) { textureXML->QueryFloatAttribute(A_COCOS2D_PIVOT_X, &px); textureXML->QueryFloatAttribute(A_COCOS2D_PIVOT_Y, &py); } else { textureXML->QueryFloatAttribute(A_PIVOT_X, &px); textureXML->QueryFloatAttribute(A_PIVOT_Y, &py); } textureXML->QueryFloatAttribute(A_WIDTH, &width); textureXML->QueryFloatAttribute(A_HEIGHT, &height); float anchorPointX = px / width; float anchorPointY = (height - py) / height; textureData->pivotX = anchorPointX; textureData->pivotY = anchorPointY; tinyxml2::XMLElement *contourXML = textureXML->FirstChildElement(CONTOUR); while (contourXML) { ContourData *contourData = decodeContour(contourXML, dataInfo); textureData->addContourData(contourData); contourData->release(); contourXML = contourXML->NextSiblingElement(CONTOUR); } return textureData; } ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo) { ContourData *contourData = new ContourData(); contourData->init(); tinyxml2::XMLElement *vertexDataXML = contourXML->FirstChildElement(CONTOUR_VERTEX); while (vertexDataXML) { Point vertex; vertexDataXML->QueryFloatAttribute(A_X, &vertex.x); vertexDataXML->QueryFloatAttribute(A_Y, &vertex.y); vertex.y = -vertex.y; contourData->vertexList.push_back(vertex); vertexDataXML = vertexDataXML->NextSiblingElement(CONTOUR_VERTEX); } return contourData; } void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo) { rapidjson::Document json; json.Parse<0>(fileContent.c_str()); if (json.HasParseError()) { CCLOG("GetParseError %s\n",json.GetParseError()); } dataInfo->contentScale = DICTOOL->getFloatValue_json(json, CONTENT_SCALE, 1.0f); // Decode armatures int length = DICTOOL->getArrayCount_json(json, ARMATURE_DATA); for (int i = 0; i < length; i++) { const rapidjson::Value &armatureDic = DICTOOL->getSubDictionary_json(json, ARMATURE_DATA, i); ArmatureData *armatureData = decodeArmature(armatureDic, dataInfo); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.lock(); } ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData); armatureData->release(); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.unlock(); } } // Decode animations length = DICTOOL->getArrayCount_json(json, ANIMATION_DATA); //json[ANIMATION_DATA].IsNull() ? 0 : json[ANIMATION_DATA].Size(); for (int i = 0; i < length; i++) { const rapidjson::Value &animationDic = DICTOOL->getSubDictionary_json(json, ANIMATION_DATA, i); AnimationData *animationData = decodeAnimation(animationDic, dataInfo); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.lock(); } ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData); animationData->release(); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.unlock(); } } // Decode textures length = DICTOOL->getArrayCount_json(json, TEXTURE_DATA); for (int i = 0; i < length; i++) { const rapidjson::Value &textureDic = DICTOOL->getSubDictionary_json(json, TEXTURE_DATA, i); TextureData *textureData = decodeTexture(textureDic); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.lock(); } ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData); textureData->release(); if (dataInfo->asyncStruct) { _dataReaderHelper->_addDataMutex.unlock(); } } // Auto load sprite file bool autoLoad = dataInfo->asyncStruct == nullptr ? ArmatureDataManager::getInstance()->isAutoLoadSpriteFile() : dataInfo->asyncStruct->autoLoadSpriteFile; if (autoLoad) { length = DICTOOL->getArrayCount_json(json, CONFIG_FILE_PATH); // json[CONFIG_FILE_PATH].IsNull() ? 0 : json[CONFIG_FILE_PATH].Size(); for (int i = 0; i < length; i++) { const char *path = DICTOOL->getStringValueFromArray_json(json, CONFIG_FILE_PATH, i); // json[CONFIG_FILE_PATH][i].IsNull() ? NULL : json[CONFIG_FILE_PATH][i].GetString(); if (path == nullptr) { CCLOG("load CONFIG_FILE_PATH error."); return; } std::string filePath = path; filePath = filePath.erase(filePath.find_last_of(".")); if (dataInfo->asyncStruct) { dataInfo->configFileQueue.push(filePath); } else { std::string plistPath = filePath + ".plist"; std::string pngPath = filePath + ".png"; ArmatureDataManager::getInstance()->addSpriteFrameFromFile((dataInfo->baseFilePath + plistPath).c_str(), (dataInfo->baseFilePath + pngPath).c_str()); } } } } ArmatureData *DataReaderHelper::decodeArmature(const rapidjson::Value& json, DataInfo *dataInfo) { ArmatureData *armatureData = new ArmatureData(); armatureData->init(); const char *name = DICTOOL->getStringValue_json(json, A_NAME); if(name != nullptr) { armatureData->name = name; } dataInfo->cocoStudioVersion = armatureData->dataVersion = DICTOOL->getFloatValue_json(json, VERSION, 0.1f); int length = DICTOOL->getArrayCount_json(json, BONE_DATA, 0); for (int i = 0; i < length; i++) { const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, BONE_DATA, i); //json[BONE_DATA][i]; BoneData *boneData = decodeBone(dic, dataInfo); armatureData->addBoneData(boneData); boneData->release(); } return armatureData; } BoneData *DataReaderHelper::decodeBone(const rapidjson::Value& json, DataInfo *dataInfo) { BoneData *boneData = new BoneData(); boneData->init(); decodeNode(boneData, json, dataInfo); const char *str = DICTOOL->getStringValue_json(json, A_NAME); if(str != nullptr) { boneData->name = str; } str = DICTOOL->getStringValue_json(json, A_PARENT); if(str != nullptr) { boneData->parentName = str; } int length = DICTOOL->getArrayCount_json(json, DISPLAY_DATA); for (int i = 0; i < length; i++) { const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, DISPLAY_DATA, i); DisplayData *displayData = decodeBoneDisplay(dic, dataInfo); boneData->addDisplayData(displayData); displayData->release(); } return boneData; } DisplayData *DataReaderHelper::decodeBoneDisplay(const rapidjson::Value& json, DataInfo *dataInfo) { DisplayType displayType = (DisplayType)(DICTOOL->getIntValue_json(json, A_DISPLAY_TYPE, CS_DISPLAY_SPRITE)); DisplayData *displayData = nullptr; switch (displayType) { case CS_DISPLAY_SPRITE: { displayData = new SpriteDisplayData(); const char *name = DICTOOL->getStringValue_json(json, A_NAME); if(name != NULL) { ((SpriteDisplayData *)displayData)->displayName = name; } const rapidjson::Value &dicArray = DICTOOL->getSubDictionary_json(json, SKIN_DATA); if(!dicArray.IsNull()) { rapidjson::SizeType index = 0; const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(dicArray, index); if (!dic.IsNull()) { SpriteDisplayData *sdd = (SpriteDisplayData *)displayData; sdd->skinData.x = DICTOOL->getFloatValue_json(dic, A_X) * s_PositionReadScale; sdd->skinData.y = DICTOOL->getFloatValue_json(dic, A_Y) * s_PositionReadScale; sdd->skinData.scaleX = DICTOOL->getFloatValue_json(dic, A_SCALE_X, 1.0f); sdd->skinData.scaleY = DICTOOL->getFloatValue_json(dic, A_SCALE_Y, 1.0f); sdd->skinData.skewX = DICTOOL->getFloatValue_json(dic, A_SKEW_X, 1.0f); sdd->skinData.skewY = DICTOOL->getFloatValue_json(dic, A_SKEW_Y, 1.0f); sdd->skinData.x *= dataInfo->contentScale; sdd->skinData.y *= dataInfo->contentScale; } } } break; case CS_DISPLAY_ARMATURE: { displayData = new ArmatureDisplayData(); const char *name = DICTOOL->getStringValue_json(json, A_NAME); if(name != nullptr) { ((ArmatureDisplayData *)displayData)->displayName = name; } } break; case CS_DISPLAY_PARTICLE: { displayData = new ParticleDisplayData(); const char *plist = DICTOOL->getStringValue_json(json, A_PLIST); if(plist != nullptr) { if (dataInfo->asyncStruct) { static_cast(displayData)->displayName = dataInfo->asyncStruct->baseFilePath + plist; } else { static_cast(displayData)->displayName = dataInfo->baseFilePath + plist; } } } break; default: displayData = new SpriteDisplayData(); break; } displayData->displayType = displayType; return displayData; } AnimationData *DataReaderHelper::decodeAnimation(const rapidjson::Value& json, DataInfo *dataInfo) { AnimationData *aniData = new AnimationData(); const char *name = DICTOOL->getStringValue_json(json, A_NAME); if(name != nullptr) { aniData->name = name; } int length = DICTOOL->getArrayCount_json(json, MOVEMENT_DATA); for (int i = 0; i < length; i++) { const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, MOVEMENT_DATA, i); MovementData *movementData = decodeMovement(dic, dataInfo); aniData->addMovement(movementData); movementData->release(); } return aniData; } MovementData *DataReaderHelper::decodeMovement(const rapidjson::Value& json, DataInfo *dataInfo) { MovementData *movementData = new MovementData(); movementData->loop = DICTOOL->getBooleanValue_json(json, A_LOOP, true); movementData->durationTween = DICTOOL->getIntValue_json(json, A_DURATION_TWEEN, 0); movementData->durationTo = DICTOOL->getIntValue_json(json, A_DURATION_TO, 0); movementData->duration = DICTOOL->getIntValue_json(json, A_DURATION, 0); if (!DICTOOL->checkObjectExist_json(json, A_DURATION)) { movementData->scale = 1.0f; } else { movementData->scale = DICTOOL->getFloatValue_json(json, A_MOVEMENT_SCALE, 1.0f); } movementData->tweenEasing = (TweenType)(DICTOOL->getIntValue_json(json, A_TWEEN_EASING, Linear)); const char *name = DICTOOL->getStringValue_json(json, A_NAME); if(name != nullptr) { movementData->name = name; } int length = DICTOOL->getArrayCount_json(json, MOVEMENT_BONE_DATA); for (int i = 0; i < length; i++) { const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, MOVEMENT_BONE_DATA, i); MovementBoneData *movementBoneData = decodeMovementBone(dic, dataInfo); movementData->addMovementBoneData(movementBoneData); movementBoneData->release(); } return movementData; } MovementBoneData *DataReaderHelper::decodeMovementBone(const rapidjson::Value& json, DataInfo *dataInfo) { MovementBoneData *movementBoneData = new MovementBoneData(); movementBoneData->init(); movementBoneData->delay = DICTOOL->getFloatValue_json(json, A_MOVEMENT_DELAY); const char *name = DICTOOL->getStringValue_json(json, A_NAME); if(name != nullptr) { movementBoneData->name = name; } rapidjson::SizeType length = DICTOOL->getArrayCount_json(json, FRAME_DATA); for (rapidjson::SizeType i = 0; i < length; i++) { const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, FRAME_DATA, i); FrameData *frameData = decodeFrame(dic, dataInfo); movementBoneData->addFrameData(frameData); frameData->release(); if (dataInfo->cocoStudioVersion < VERSION_COMBINED) { frameData->frameID = movementBoneData->duration; movementBoneData->duration += frameData->duration; } } if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE) { //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) auto frames = movementBoneData->frameList; for (long i = frames.size() - 1; i >= 0; i--) { if (i > 0) { float difSkewX = frames.at(i)->skewX - frames.at(i-1)->skewX; float difSkewY = frames.at(i)->skewY - frames.at(i-1)->skewY; if (difSkewX < -M_PI || difSkewX > M_PI) { frames.at(i-1)->skewX = difSkewX < 0 ? frames.at(i-1)->skewX - 2 * M_PI : frames.at(i-1)->skewX + 2 * M_PI; } if (difSkewY < -M_PI || difSkewY > M_PI) { frames.at(i-1)->skewY = difSkewY < 0 ? frames.at(i-1)->skewY - 2 * M_PI : frames.at(i-1)->skewY + 2 * M_PI; } } } } if (dataInfo->cocoStudioVersion < VERSION_COMBINED) { if (movementBoneData->frameList.size() > 0) { FrameData *frameData = new FrameData(); frameData->copy((FrameData *)movementBoneData->frameList.back()); movementBoneData->addFrameData(frameData); frameData->release(); frameData->frameID = movementBoneData->duration; } } return movementBoneData; } FrameData *DataReaderHelper::decodeFrame(const rapidjson::Value& json, DataInfo *dataInfo) { FrameData *frameData = new FrameData(); decodeNode(frameData, json, dataInfo); frameData->tweenEasing = (TweenType)(DICTOOL->getIntValue_json(json, A_TWEEN_EASING, Linear)); frameData->displayIndex = DICTOOL->getIntValue_json(json, A_DISPLAY_INDEX); frameData->blendFunc.src = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_SRC, BlendFunc::ALPHA_NON_PREMULTIPLIED.src)); frameData->blendFunc.dst = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_DST, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst)); frameData->isTween = DICTOOL->getBooleanValue_json(json, A_TWEEN_FRAME, true); const char *event = DICTOOL->getStringValue_json(json, A_EVENT); if (event != nullptr) { frameData->strEvent = event; } if (dataInfo->cocoStudioVersion < VERSION_COMBINED) { frameData->duration = DICTOOL->getIntValue_json(json, A_DURATION, 1); } else { frameData->frameID = DICTOOL->getIntValue_json(json, A_FRAME_INDEX); } int length = DICTOOL->getArrayCount_json(json, A_EASING_PARAM); if (length != 0) { frameData->easingParams = new float[length]; for (int i = 0; i < length; i++) { frameData->easingParams[i] = DICTOOL->getFloatValueFromArray_json(json, A_EASING_PARAM, i); } } return frameData; } TextureData *DataReaderHelper::decodeTexture(const rapidjson::Value& json) { TextureData *textureData = new TextureData(); textureData->init(); const char *name = DICTOOL->getStringValue_json(json, A_NAME); if(name != nullptr) { textureData->name = name; } textureData->width = DICTOOL->getFloatValue_json(json, A_WIDTH); textureData->height = DICTOOL->getFloatValue_json(json, A_HEIGHT); textureData->pivotX = DICTOOL->getFloatValue_json(json, A_PIVOT_X); textureData->pivotY = DICTOOL->getFloatValue_json(json, A_PIVOT_Y); int length = DICTOOL->getArrayCount_json(json, CONTOUR_DATA); for (int i = 0; i < length; i++) { const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, CONTOUR_DATA, i); ContourData *contourData = decodeContour(dic); textureData->contourDataList.pushBack(contourData); contourData->release(); } return textureData; } ContourData *DataReaderHelper::decodeContour(const rapidjson::Value& json) { ContourData *contourData = new ContourData(); contourData->init(); int length = DICTOOL->getArrayCount_json(json, VERTEX_POINT); for (int i = length - 1; i >= 0; i--) { const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, VERTEX_POINT, i); Point vertex; vertex.x = DICTOOL->getFloatValue_json(dic, A_X); vertex.y = DICTOOL->getFloatValue_json(dic, A_Y); contourData->vertexList.push_back(vertex); } return contourData; } void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, DataInfo *dataInfo) { node->x = DICTOOL->getFloatValue_json(json, A_X) * s_PositionReadScale; node->y = DICTOOL->getFloatValue_json(json, A_Y) * s_PositionReadScale; node->x *= dataInfo->contentScale; node->y *= dataInfo->contentScale; node->zOrder = DICTOOL->getIntValue_json(json, A_Z); node->skewX = DICTOOL->getFloatValue_json(json, A_SKEW_X); node->skewY = DICTOOL->getFloatValue_json(json, A_SKEW_Y); node->scaleX = DICTOOL->getFloatValue_json(json, A_SCALE_X, 1.0f); node->scaleY = DICTOOL->getFloatValue_json(json, A_SCALE_Y, 1.0f); if (dataInfo->cocoStudioVersion < VERSION_COLOR_READING) { if (DICTOOL->checkObjectExist_json(json, 0)) { const rapidjson::Value &colorDic = DICTOOL->getSubDictionary_json(json, 0); node->a = DICTOOL->getIntValue_json(colorDic, A_ALPHA, 255); node->r = DICTOOL->getIntValue_json(colorDic, A_RED, 255); node->g = DICTOOL->getIntValue_json(colorDic, A_GREEN, 255); node->b = DICTOOL->getIntValue_json(colorDic, A_BLUE, 255); node->isUseColorInfo = true; } } else { if (DICTOOL->checkObjectExist_json(json, COLOR_INFO)) { const rapidjson::Value &colorDic = DICTOOL->getSubDictionary_json(json, COLOR_INFO); //json.getSubDictionary(COLOR_INFO); node->a = DICTOOL->getIntValue_json(colorDic, A_ALPHA, 255); node->r = DICTOOL->getIntValue_json(colorDic, A_RED, 255); node->g = DICTOOL->getIntValue_json(colorDic, A_GREEN, 255); node->b = DICTOOL->getIntValue_json(colorDic, A_BLUE, 255); node->isUseColorInfo = true; } } } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDataReaderHelper.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDATAREADERHELPER_H__ #define __CCDATAREADERHELPER_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDatas.h" #include "cocostudio/CCArmature.h" #include "cocostudio/DictionaryHelper.h" #include #include #include #include #include #include namespace tinyxml2 { class XMLElement; } namespace cocostudio { /** * @js NA * @lua NA */ class DataReaderHelper : cocos2d::Object { protected: enum ConfigType { DragonBone_XML, CocoStudio_JSON }; typedef struct _AsyncStruct { std::string filename; std::string fileContent; ConfigType configType; std::string baseFilePath; cocos2d::Object *target; cocos2d::SEL_SCHEDULE selector; bool autoLoadSpriteFile; std::string imagePath; std::string plistPath; } AsyncStruct; typedef struct _DataInfo { AsyncStruct *asyncStruct; std::queue configFileQueue; float contentScale; std::string filename; std::string baseFilePath; float flashToolVersion; float cocoStudioVersion; } DataInfo; public: /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static DataReaderHelper *sharedDataReaderHelper() { return DataReaderHelper::getInstance(); } static DataReaderHelper *getInstance(); /** * Scale the position data, used for multiresolution adapter * It won't effect the data already read. */ static void setPositionReadScale(float scale); static float getPositionReadScale(); static void purge(); public: /** * @js ctor */ DataReaderHelper(); /** * @js NA * @lua NA */ ~DataReaderHelper(); void addDataFromFile(const std::string& filePath); void addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); void addDataAsyncCallBack(float dt); void removeConfigFile(const std::string& configFile); public: /** * Translate XML export from Dragon Bone flash tool to datas, and save them. * When you add a new xml, the data already saved will be keeped. * * @param xmlPath The cache of the xml */ static void addDataFromCache(const std::string& pFileContent, DataInfo *dataInfo = nullptr); /** * Decode Armature Datas from xml export from Dragon Bone flash tool */ static ArmatureData *decodeArmature(tinyxml2::XMLElement *armatureXML, DataInfo *dataInfo); static BoneData *decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXML, DataInfo *dataInfo); static DisplayData *decodeBoneDisplay(tinyxml2::XMLElement *displayXML, DataInfo *dataInfo); /** * Decode ArmatureAnimation Datas from xml export from Dragon Bone flash tool */ static AnimationData *decodeAnimation(tinyxml2::XMLElement *animationXML, DataInfo *dataInfo); static MovementData *decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData, DataInfo *dataInfo); static MovementBoneData *decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData, DataInfo *dataInfo); static FrameData *decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo); /** * Decode Texture Datas from xml export from Dragon Bone flash tool */ static TextureData *decodeTexture(tinyxml2::XMLElement *textureXML, DataInfo *dataInfo); /** * Decode Contour Datas from xml export from Dragon Bone flash tool */ static ContourData *decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo); public: static void addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo = nullptr); static ArmatureData *decodeArmature(const rapidjson::Value& json, DataInfo *dataInfo); static BoneData *decodeBone(const rapidjson::Value& json, DataInfo *dataInfo); static DisplayData *decodeBoneDisplay(const rapidjson::Value& json, DataInfo *dataInfo); static AnimationData *decodeAnimation(const rapidjson::Value& json, DataInfo *dataInfo); static MovementData *decodeMovement(const rapidjson::Value& json, DataInfo *dataInfo); static MovementBoneData *decodeMovementBone(const rapidjson::Value& json, DataInfo *dataInfo); static FrameData *decodeFrame(const rapidjson::Value& json, DataInfo *dataInfo); static TextureData *decodeTexture(const rapidjson::Value& json); static ContourData *decodeContour(const rapidjson::Value& json); static void decodeNode(BaseData *node, const rapidjson::Value& json, DataInfo *dataInfo); protected: void loadData(); std::condition_variable _sleepCondition; std::thread *_loadingThread; std::mutex _sleepMutex; std::mutex _asyncStructQueueMutex; std::mutex _dataInfoMutex; std::mutex _addDataMutex; std::mutex _getFileMutex; unsigned long _asyncRefCount; unsigned long _asyncRefTotalCount; bool need_quit; std::queue *_asyncStructQueue; std::queue *_dataQueue; static std::vector _configFileList; static DataReaderHelper *_dataReaderHelper; }; } #endif /*__CCDATAREADERHELPER_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDatas.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCDatas.h" #include "cocostudio/CCUtilMath.h" #include "cocostudio/CCTransformHelp.h" using namespace cocos2d; namespace cocostudio { BaseData::BaseData() : x(0.0f) , y(0.0f) , zOrder(0) , skewX(0.0f) , skewY(0.0f) , scaleX(1.0f) , scaleY(1.0f) , tweenRotate(0.0f) , isUseColorInfo(false) , a(255) , r(255) , g(255) , b(255) { } BaseData::~BaseData() { } void BaseData::copy(const BaseData *node ) { x = node->x; y = node->y; zOrder = node->zOrder; scaleX = node->scaleX; scaleY = node->scaleY; skewX = node->skewX; skewY = node->skewY; tweenRotate = node->tweenRotate; isUseColorInfo = node->isUseColorInfo; r = node->r; g = node->g; b = node->b; a = node->a; } void BaseData::subtract(BaseData *from, BaseData *to, bool limit) { x = to->x - from->x; y = to->y - from->y; scaleX = to->scaleX - from->scaleX; scaleY = to->scaleY - from->scaleY; skewX = to->skewX - from->skewX; skewY = to->skewY - from->skewY; if(isUseColorInfo || from->isUseColorInfo || to->isUseColorInfo) { a = to->a - from->a; r = to->r - from->r; g = to->g - from->g; b = to->b - from->b; isUseColorInfo = true; } else { a = r = g = b = 0; isUseColorInfo = false; } if (limit) { if (skewX > M_PI) { skewX -= (float)CC_DOUBLE_PI; } if (skewX < -M_PI) { skewX += (float)CC_DOUBLE_PI; } if (skewY > M_PI) { skewY -= (float)CC_DOUBLE_PI; } if (skewY < -M_PI) { skewY += (float)CC_DOUBLE_PI; } } if (to->tweenRotate) { skewX += to->tweenRotate * M_PI * 2; skewY -= to->tweenRotate * M_PI * 2; } } void BaseData::setColor(const Color4B &color) { r = color.r; g = color.g; b = color.b; a = color.a; } Color4B BaseData::getColor() { return Color4B(r, g, b, a); } const std::string DisplayData::changeDisplayToTexture(const std::string& displayName) { // remove .xxx std::string textureName = displayName; size_t startPos = textureName.find_last_of("."); if(startPos != std::string::npos) { textureName = textureName.erase(startPos); } return textureName; } DisplayData::DisplayData(void) : displayType(CS_DISPLAY_MAX) , displayName("") { } void DisplayData::copy(DisplayData *displayData) { displayName = displayData->displayName; displayType = displayData->displayType; } SpriteDisplayData::SpriteDisplayData(void) { displayType = CS_DISPLAY_SPRITE; } void SpriteDisplayData::copy(DisplayData *displayData) { DisplayData::copy(displayData); if (SpriteDisplayData *sdd = dynamic_cast(displayData)) { skinData = sdd->skinData; } } ArmatureDisplayData::ArmatureDisplayData(void) { displayType = CS_DISPLAY_ARMATURE; } ParticleDisplayData::ParticleDisplayData(void) { displayType = CS_DISPLAY_PARTICLE; } BoneData::BoneData(void) : name("") , parentName("") { } BoneData::~BoneData(void) { } bool BoneData::init() { return true; } void BoneData::addDisplayData(DisplayData *displayData) { displayDataList.pushBack(displayData); } DisplayData *BoneData::getDisplayData(int index) { return displayDataList.at(index); } ArmatureData::ArmatureData() : dataVersion(0.1f) { } ArmatureData::~ArmatureData() { } bool ArmatureData::init() { return true; } void ArmatureData::addBoneData(BoneData *boneData) { boneDataDic.insert(boneData->name, boneData); } BoneData *ArmatureData::getBoneData(const std::string& boneName) { return static_cast(boneDataDic.at(boneName)); } FrameData::FrameData(void) : frameID(0) , duration(1) , tweenEasing(Linear) , easingParamNumber(0) , easingParams(NULL) , isTween(true) , displayIndex(0) , blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED) , strEvent("") , strMovement("") , strSound("") , strSoundEffect("") { } FrameData::~FrameData(void) { CC_SAFE_DELETE(easingParams); } void FrameData::copy(const BaseData *baseData) { BaseData::copy(baseData); if (const FrameData *frameData = dynamic_cast(baseData)) { duration = frameData->duration; displayIndex = frameData->displayIndex; tweenEasing = frameData->tweenEasing; easingParamNumber = frameData->easingParamNumber; CC_SAFE_DELETE(easingParams); if (easingParamNumber != 0) { easingParams = new float[easingParamNumber]; for (int i = 0; ieasingParams[i]; } } blendFunc = frameData->blendFunc; } } MovementBoneData::MovementBoneData() : delay(0.0f) , scale(1.0f) , duration(0) , name("") { } MovementBoneData::~MovementBoneData(void) { } bool MovementBoneData::init() { return true; } void MovementBoneData::addFrameData(FrameData *frameData) { frameList.pushBack(frameData); } FrameData *MovementBoneData::getFrameData(int index) { return frameList.at(index); } MovementData::MovementData(void) : name("") , duration(0) , scale(1.0f) , durationTo(0) , durationTween(0) , loop(true) , tweenEasing(Linear) { } MovementData::~MovementData(void) { } void MovementData::addMovementBoneData(MovementBoneData *movBoneData) { movBoneDataDic.insert(movBoneData->name, movBoneData); } MovementBoneData *MovementData::getMovementBoneData(const std::string& boneName) { return movBoneDataDic.at(boneName); } AnimationData::AnimationData(void) { } AnimationData::~AnimationData(void) { } void AnimationData::addMovement(MovementData *movData) { movementDataDic.insert(movData->name, movData); movementNames.push_back(movData->name); } MovementData *AnimationData::getMovement(const std::string& movementName) { return movementDataDic.at(movementName); } ssize_t AnimationData::getMovementCount() { return movementDataDic.size(); } ContourData::ContourData() { } ContourData::~ContourData() { } bool ContourData::init() { return true; } void ContourData::addVertex(Point &vertex) { vertexList.push_back(vertex); } TextureData::TextureData() : height(0.0f) , width(0.0f) , pivotX(0.5f) , pivotY(0.5f) , name("") { } TextureData::~TextureData() { } bool TextureData::init() { return true; } void TextureData::addContourData(ContourData *contourData) { contourDataList.pushBack(contourData); } ContourData *TextureData::getContourData(int index) { return contourDataList.at(index); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDatas.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCARMATURE_DATAS_H__ #define __CCARMATURE_DATAS_H__ #include "CCObject.h" #include "ccTypes.h" #include "CCVector.h" #include "CCMap.h" #include "CCAffineTransform.h" #include "CCNode.h" #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCTweenFunction.h" #define CC_CREATE_NO_PARAM_NO_INIT(varType)\ public: \ static inline varType *create(void){ \ varType *var = new varType();\ if (var)\ {\ var->autorelease();\ return var;\ }\ CC_SAFE_DELETE(var);\ return nullptr;\ } #define CC_CREATE_NO_PARAM(varType)\ public: \ static inline varType *create(void){ \ varType *var = new varType();\ if (var && var->init())\ {\ var->autorelease();\ return var;\ }\ CC_SAFE_DELETE(var);\ return nullptr;\ } namespace cocostudio { /** * The base node include a lot of attributes. * @js NA * @lua NA */ class BaseData : public cocos2d::Object { public: CC_CREATE_NO_PARAM_NO_INIT(BaseData) public: /** * @js ctor */ BaseData(); /** * @js NA * @lua NA */ ~BaseData(void); /* * Copy data from node * @param node A BaseData to copy data */ virtual void copy(const BaseData *node); /* * Calculate two BaseData's between value(to - from) and set to self * * @param from from BaseData * @param to to BaseData */ virtual void subtract(BaseData *from, BaseData *to, bool limit); virtual void setColor(const cocos2d::Color4B &color); virtual cocos2d::Color4B getColor(); public: float x; //! position x attribute float y; //! position y attribute int zOrder; //! zorder attribute, used to order the Bone's depth order /** * x y skewX skewY scaleX scaleY used to calculate transform matrix * skewX, skewY can have rotation effect * To get more matrix information, you can have a look at this pape : http://www.senocular.com/flash/tutorials/transformmatrix/ */ float skewX; float skewY; float scaleX; float scaleY; float tweenRotate; //! SkewX, SkewY, and TweenRotate effect the rotation bool isUseColorInfo; //! Whether or not this frame have the color changed Info int a, r, g, b; }; /** * DisplayType distinguish which type your display is. */ enum DisplayType { CS_DISPLAY_SPRITE, //! display is a single Sprite CS_DISPLAY_ARMATURE, //! display is a Armature CS_DISPLAY_PARTICLE, //! display is a CCParticle. CS_DISPLAY_MAX }; /** * @js NA * @lua NA */ class DisplayData : public cocos2d::Object { public: CC_CREATE_NO_PARAM_NO_INIT(DisplayData) static const std::string changeDisplayToTexture(const std::string& displayName); public: /** * @js ctor */ DisplayData(); /** * @js NA * @lua NA */ virtual ~DisplayData(void) {} virtual void copy(DisplayData *displayData); DisplayType displayType; //! mark which type your display is std::string displayName; }; /** * @js NA * @lua NA */ class SpriteDisplayData : public DisplayData { public: CC_CREATE_NO_PARAM_NO_INIT(SpriteDisplayData) public: /** * @js ctor */ SpriteDisplayData(); /** * @js NA * @lua NA */ virtual ~SpriteDisplayData() {}; void copy(DisplayData *displayData); public: BaseData skinData; }; /** * @js NA * @lua NA */ class ArmatureDisplayData : public DisplayData { public: CC_CREATE_NO_PARAM_NO_INIT(ArmatureDisplayData) public: /** * @js ctor */ ArmatureDisplayData(); /** * @js NA * @lua NA */ virtual ~ArmatureDisplayData() {} }; /** * @js NA * @lua NA */ class ParticleDisplayData : public DisplayData { public: CC_CREATE_NO_PARAM_NO_INIT(ParticleDisplayData) public: /** * @js ctor */ ParticleDisplayData(); /** * @js NA * @lua NA */ virtual ~ParticleDisplayData() {}; }; /** * BoneData used to init a Bone. * BoneData keeps a DisplayData list, a Bone can have many display to change. * The display information saved in the DisplayData * @js NA * @lua NA */ class BoneData : public BaseData { public: CC_CREATE_NO_PARAM(BoneData) public: /** * @js ctor */ BoneData(void); /** * @js NA * @lua NA */ ~BoneData(void); virtual bool init(); void addDisplayData(DisplayData *displayData); DisplayData *getDisplayData(int index); public: std::string name; //! the bone's name std::string parentName; //! the bone parent's name cocos2d::Vector displayDataList; //! save DisplayData informations for the Bone cocos2d::AffineTransform boneDataTransform; }; /** * ArmatureData saved the Armature name and Bonedata needed for the CCBones in this Armature * When we create a Armature, we need to get each Bone's BoneData as it's init information. * So we can get a BoneData from the Dictionary saved in the ArmatureData. * @js NA * @lua NA */ class ArmatureData : public cocos2d::Object { public: CC_CREATE_NO_PARAM(ArmatureData) public: /** * @js ctor */ ArmatureData(); /** * @js NA * @lua NA */ ~ArmatureData(); bool init(); void addBoneData(BoneData *boneData); BoneData *getBoneData(const std::string& boneName); public: std::string name; cocos2d::Map boneDataDic; float dataVersion; }; enum BlendType { BLEND_NORMAL, BLEND_LAYER, BLEND_DARKEN, BLEND_MULTIPLY, BLEND_LIGHTEN, BLEND_SCREEN, BLEND_OVERLAY, BLEND_HARD_LIGHT, BLEND_ADD, BLEND_SUBSTRACT, BLEND_DIFFERENCE, BLEND_INVERT, BLEND_ALPHA, BLEND_ERASE }; /** * @js NA * @lua NA */ class FrameData : public BaseData { public: CC_CREATE_NO_PARAM_NO_INIT(FrameData) public: /** * @js ctor */ FrameData(); /** * @js NA * @lua NA */ ~FrameData(); virtual void copy(const BaseData *baseData); public: int frameID; int duration; //! The frame will last duration frames TweenType tweenEasing; //! Every frame's tween easing effect int easingParamNumber; float *easingParams; bool isTween; //! Whether it's a tween key frame /** * The current display index when change to this frame. * If value is -1, then display will not be shown. */ int displayIndex; cocos2d::BlendFunc blendFunc; std::string strEvent; /** * strMovement, strEvent, strSound, strSoundEffect do not support yet */ std::string strMovement; std::string strSound; std::string strSoundEffect; }; /** * @js NA * @lua NA */ class MovementBoneData : public cocos2d::Object { public: CC_CREATE_NO_PARAM(MovementBoneData) public: /** * @js ctor */ MovementBoneData(); /** * @js NA * @lua NA */ ~MovementBoneData(void); virtual bool init(); void addFrameData(FrameData *frameData); FrameData *getFrameData(int index); public: float delay; //! movement delay percent, this value can produce a delay effect float scale; //! scale this movement float duration; //! this Bone in this movement will last m_iDuration frames std::string name; //! bone name cocos2d::Vector frameList; }; /** * @js NA * @lua NA */ class MovementData : public cocos2d::Object { public: CC_CREATE_NO_PARAM_NO_INIT(MovementData) public: /** * @js ctor */ MovementData(void); /** * @js NA * @lua NA */ ~MovementData(void); void addMovementBoneData(MovementBoneData *movBoneData); MovementBoneData *getMovementBoneData(const std::string& boneName); public: std::string name; int duration; //! the frames this movement will last float scale; //! scale this movement /** * Change to this movement will last durationTo frames. Use this effect can avoid too suddenly changing. * * Example : current movement is "stand", we want to change to "run", then we fill durationTo frames before * change to "run" instead of changing to "run" directly. */ int durationTo; /* * This is different from duration, durationTween contain tween effect. * duration is the raw time that the animation will last, it's the same with the time you edit in the Action Editor. * durationTween is the actual time you want this animation last. * Example : If we edit 10 frames in the flash, then duration is 10. When we set durationTween to 50, the movement will last 50 frames, the extra 40 frames will auto filled with tween effect */ int durationTween; bool loop; //! whether the movement was looped /** * Which tween easing effect the movement use * TWEEN_EASING_MAX : use the value from MovementData get from flash design panel */ TweenType tweenEasing; /** * @brief save movment bone data * @key const std::string& * @value MovementBoneData * */ cocos2d::Map movBoneDataDic; }; /** * AnimationData include all movement infomation for the Armature * The struct is AnimationData -> MovementData -> MovementBoneData -> FrameData * -> MovementFrameData * @js NA * @lua NA */ class AnimationData : public cocos2d::Object { public: CC_CREATE_NO_PARAM_NO_INIT(AnimationData) public: /** * @js ctor */ AnimationData(void); /** * @js NA * @lua NA */ ~AnimationData(void); void addMovement(MovementData *movData); MovementData *getMovement(const std::string& movementName); ssize_t getMovementCount(); public: std::string name; cocos2d::Map movementDataDic; std::vector movementNames; }; /* * ContourData include a contour vertex information * @js NA * @lua NA */ class ContourData : public cocos2d::Object { public: CC_CREATE_NO_PARAM(ContourData) public: /** * @js ctor */ ContourData(); /** * @js NA * @lua NA */ ~ContourData(void); virtual bool init(); virtual void addVertex(cocos2d::Point &vertex); public: std::vector vertexList; //! Save contour vertex info, vertex saved in a Point }; /* * TextureData include a texture's information * @js NA * @lua NA */ class TextureData : public cocos2d::Object { public: CC_CREATE_NO_PARAM(TextureData) public: /** * @js ctor */ TextureData(); /** * @js NA * @lua NA */ ~TextureData(void); virtual bool init(); void addContourData(ContourData *contourData); ContourData *getContourData(int index); public: float height; //! The texture's width, height float width; float pivotX; //! The texture's anchor point float pivotY; std::string name; //! The texture's name cocos2d::Vector contourDataList; }; } #endif /*__CCARMATURE_DATAS_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCDecorativeDisplay.h" using namespace cocos2d; namespace cocostudio { DecorativeDisplay *DecorativeDisplay::create() { DecorativeDisplay *pDisplay = new DecorativeDisplay(); if (pDisplay && pDisplay->init()) { pDisplay->autorelease(); return pDisplay; } CC_SAFE_DELETE(pDisplay); return nullptr; } DecorativeDisplay::DecorativeDisplay() : _display(nullptr) , _displayData(nullptr) { #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX _colliderDetector = nullptr; #endif } DecorativeDisplay::~DecorativeDisplay(void) { CC_SAFE_RELEASE_NULL(_displayData); CC_SAFE_RELEASE_NULL(_display); #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX CC_SAFE_RELEASE_NULL(_colliderDetector); #endif } bool DecorativeDisplay::init() { return true; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDecorativeDisplay.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDECORATIVEDISPLAY_H__ #define __CCDECORATIVEDISPLAY_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDisplayFactory.h" #include "cocostudio/CCDatas.h" #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX #include "cocostudio/CCColliderDetector.h" #endif namespace cocostudio { /** * @js NA * @lua NA */ class DecorativeDisplay: public cocos2d::Object { public: static DecorativeDisplay *create(); public: DecorativeDisplay(void); ~DecorativeDisplay(void); virtual bool init(); virtual void setDisplay(cocos2d::Node *display) { if (_display != display) { CC_SAFE_RETAIN(display); CC_SAFE_RELEASE(_display); _display = display; } } virtual cocos2d::Node *getDisplay() const { return _display; } virtual void setDisplayData(DisplayData *data) { if (_displayData != data) { CC_SAFE_RETAIN(data); CC_SAFE_RELEASE(_displayData); _displayData = data; } } virtual DisplayData *getDisplayData() const { return _displayData; } #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX virtual void setColliderDetector(ColliderDetector *detector) { if (_colliderDetector != detector) { CC_SAFE_RETAIN(detector); CC_SAFE_RELEASE(_colliderDetector); _colliderDetector = detector; } } virtual ColliderDetector *getColliderDetector() const { return _colliderDetector; } #endif protected: cocos2d::Node *_display; DisplayData *_displayData; #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX ColliderDetector *_colliderDetector; #endif }; } #endif /*__CCDECORATIVEDISPLAY_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDisplayFactory.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCDisplayFactory.h" #include "cocostudio/CCBone.h" #include "cocostudio/CCArmature.h" #include "cocostudio/CCSkin.h" #include "cocostudio/CCSpriteFrameCacheHelper.h" #include "cocostudio/CCArmatureDataManager.h" #include "cocostudio/CCTransformHelp.h" #include "CCParticleSystemQuad.h" using namespace cocos2d; namespace cocostudio { void DisplayFactory::addDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData) { switch(displayData->displayType) { case CS_DISPLAY_SPRITE: addSpriteDisplay(bone, decoDisplay, displayData); break; case CS_DISPLAY_PARTICLE: addParticleDisplay(bone, decoDisplay, displayData); break; case CS_DISPLAY_ARMATURE: addArmatureDisplay(bone, decoDisplay, displayData); break; default: break; } } void DisplayFactory::createDisplay(Bone *bone, DecorativeDisplay *decoDisplay) { switch(decoDisplay->getDisplayData()->displayType) { case CS_DISPLAY_SPRITE: createSpriteDisplay(bone, decoDisplay); break; case CS_DISPLAY_PARTICLE: createParticleDisplay(bone, decoDisplay); break; case CS_DISPLAY_ARMATURE: createArmatureDisplay(bone, decoDisplay); break; default: break; } } void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty) { Node *display = bone->getDisplayRenderNode(); CS_RETURN_IF(!display); switch(bone->getDisplayRenderNodeType()) { case CS_DISPLAY_SPRITE: if (dirty) { static_cast(display)->updateArmatureTransform(); } break; case CS_DISPLAY_PARTICLE: updateParticleDisplay(bone, display, dt); break; case CS_DISPLAY_ARMATURE: updateArmatureDisplay(bone, display, dt); break; default: { display->setAdditionalTransform(bone->getNodeToArmatureTransform()); } break; } #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX if (dirty) { DecorativeDisplay *decoDisplay = bone->getDisplayManager()->getCurrentDecorativeDisplay(); ColliderDetector *detector = decoDisplay->getColliderDetector(); if (detector) { do { #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT CC_BREAK_IF(!detector->getBody()); #endif kmMat4 displayTransform = display->getNodeToParentTransform(); Point anchorPoint = display->getAnchorPointInPoints(); anchorPoint = PointApplyTransform(anchorPoint, displayTransform); displayTransform.mat[12] = anchorPoint.x; displayTransform.mat[13] = anchorPoint.y; kmMat4 t = TransformConcat( bone->getArmature()->getNodeToParentTransform(),displayTransform); detector->updateTransform(t); } while (0); } } #endif } void DisplayFactory::addSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData) { SpriteDisplayData *sdp = SpriteDisplayData::create(); sdp->copy((SpriteDisplayData *)displayData); decoDisplay->setDisplayData(sdp); createSpriteDisplay(bone, decoDisplay); } void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay) { Skin *skin = nullptr; SpriteDisplayData *displayData = (SpriteDisplayData *)decoDisplay->getDisplayData(); std::string textureName = displayData->displayName; size_t startPos = textureName.find_last_of("."); if(startPos != std::string::npos) { textureName = textureName.erase(startPos); } //! create display if(textureName.length() == 0) { skin = Skin::create(); } else { skin = Skin::createWithSpriteFrameName((textureName + ".png").c_str()); } decoDisplay->setDisplay(skin); if (skin == nullptr) { return; } skin->setBone(bone); initSpriteDisplay(bone, decoDisplay, displayData->displayName.c_str(), skin); Armature *armature = bone->getArmature(); if (armature) { if (armature->getArmatureData()->dataVersion >= VERSION_COMBINED) { skin->setSkinData(displayData->skinData); } else { skin->setSkinData(*bone->getBoneData()); } } } void DisplayFactory::initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay, const char *displayName, Skin *skin) { //! remove .xxx std::string textureName = displayName; size_t startPos = textureName.find_last_of("."); if(startPos != std::string::npos) { textureName = textureName.erase(startPos); } TextureData *textureData = ArmatureDataManager::getInstance()->getTextureData(textureName.c_str()); if(textureData) { //! Init display anchorPoint, every Texture have a anchor point skin->setAnchorPoint(Point( textureData->pivotX, textureData->pivotY)); } #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX if (textureData && textureData->contourDataList.size() > 0) { //! create ContourSprite ColliderDetector *colliderDetector = ColliderDetector::create(bone); colliderDetector->addContourDataList(textureData->contourDataList); decoDisplay->setColliderDetector(colliderDetector); } #endif } void DisplayFactory::addArmatureDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData) { ArmatureDisplayData *adp = ArmatureDisplayData::create(); adp->copy((ArmatureDisplayData *)displayData); decoDisplay->setDisplayData(adp); createArmatureDisplay(bone, decoDisplay); } void DisplayFactory::createArmatureDisplay(Bone *bone, DecorativeDisplay *decoDisplay) { ArmatureDisplayData *displayData = (ArmatureDisplayData *)decoDisplay->getDisplayData(); Armature *armature = Armature::create(displayData->displayName.c_str(), bone); decoDisplay->setDisplay(armature); } void DisplayFactory::updateArmatureDisplay(Bone *bone, Node *display, float dt) { Armature *armature = (Armature *)display; if(armature) { armature->sortAllChildren(); armature->update(dt); } } void DisplayFactory::addParticleDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData) { ParticleDisplayData *adp = ParticleDisplayData::create(); adp->copy((ParticleDisplayData *)displayData); decoDisplay->setDisplayData(adp); createParticleDisplay(bone, decoDisplay); } void DisplayFactory::createParticleDisplay(Bone *bone, DecorativeDisplay *decoDisplay) { ParticleDisplayData *displayData = (ParticleDisplayData *)decoDisplay->getDisplayData(); ParticleSystem *system = ParticleSystemQuad::create(displayData->displayName.c_str()); system->removeFromParent(); Armature *armature = bone->getArmature(); if (armature) { system->setParent(armature); } decoDisplay->setDisplay(system); } void DisplayFactory::updateParticleDisplay(Bone *bone, Node *display, float dt) { ParticleSystem *system = (ParticleSystem *)display; BaseData node; TransformHelp::matrixToNode(bone->getNodeToArmatureTransform(), node); system->setPosition(node.x, node.y); system->setScaleX(node.scaleX); system->setScaleY(node.scaleY); system->update(dt); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDisplayFactory.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDISPLAYFACTORY_H__ #define __CCDISPLAYFACTORY_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDatas.h" namespace cocostudio { class Skin; class Bone; class DecorativeDisplay; class DisplayData; /** * @js NA * @lua NA */ class DisplayFactory { public: static void addDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData); static void createDisplay(Bone *bone, DecorativeDisplay *decoDisplay); static void updateDisplay(Bone *bone, float dt, bool dirty); static void addSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData); static void createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay); static void initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay, const char *displayName, Skin *skin); static void addArmatureDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData); static void createArmatureDisplay(Bone *bone, DecorativeDisplay *decoDisplay); static void updateArmatureDisplay(Bone *bone, cocos2d::Node *display, float dt); static void addParticleDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData); static void createParticleDisplay(Bone *bone, DecorativeDisplay *decoDisplay); static void updateParticleDisplay(Bone *bone, cocos2d::Node *display, float dt); }; } #endif /*__CCDISPLAYFACTORY_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDisplayManager.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCDisplayManager.h" #include "cocostudio/CCBone.h" #include "cocostudio/CCArmature.h" #include "cocostudio/CCUtilMath.h" #include "cocostudio/CCSkin.h" #include "CCParticleSystemQuad.h" using namespace cocos2d; namespace cocostudio { DisplayManager *DisplayManager::create(Bone *bone) { DisplayManager *pDisplayManager = new DisplayManager(); if (pDisplayManager && pDisplayManager->init(bone)) { pDisplayManager->autorelease(); return pDisplayManager; } CC_SAFE_DELETE(pDisplayManager); return nullptr; } DisplayManager::DisplayManager() : _displayRenderNode(nullptr) , _displayType(CS_DISPLAY_MAX) , _currentDecoDisplay(nullptr) , _displayIndex(-1) , _forceChangeDisplay(false) , _visible(true) , _bone(nullptr) { } DisplayManager::~DisplayManager() { _decoDisplayList.clear(); if( _displayRenderNode ) { _displayRenderNode->removeFromParentAndCleanup(true); if(_displayRenderNode->getReferenceCount() > 0) CC_SAFE_RELEASE_NULL(_displayRenderNode); } } bool DisplayManager::init(Bone *bone) { bool ret = false; do { _bone = bone; initDisplayList(bone->getBoneData()); ret = true; } while (0); return ret; } void DisplayManager::addDisplay(DisplayData *displayData, int index) { DecorativeDisplay *decoDisplay = nullptr; if( (index >= 0) && (index < _decoDisplayList.size()) ) { decoDisplay = (DecorativeDisplay *)_decoDisplayList.at(index); } else { decoDisplay = DecorativeDisplay::create(); _decoDisplayList.pushBack(decoDisplay); } DisplayFactory::addDisplay(_bone, decoDisplay, displayData); //! if changed display index is current display index, then change current display to the new display if(index == _displayIndex) { _displayIndex = -1; changeDisplayWithIndex(index, false); } } void DisplayManager::addDisplay(Node *display, int index) { DecorativeDisplay *decoDisplay = nullptr; if( (index >= 0) && (index < _decoDisplayList.size()) ) { decoDisplay = _decoDisplayList.at(index); } else { decoDisplay = DecorativeDisplay::create(); _decoDisplayList.pushBack(decoDisplay); } DisplayData *displayData = nullptr; if (Skin *skin = dynamic_cast(display)) { skin->setBone(_bone); displayData = SpriteDisplayData::create(); DisplayFactory::initSpriteDisplay(_bone, decoDisplay, skin->getDisplayName().c_str(), skin); if (SpriteDisplayData *spriteDisplayData = (SpriteDisplayData *)decoDisplay->getDisplayData()) { skin->setSkinData(spriteDisplayData->skinData); ((SpriteDisplayData *)displayData)->skinData = spriteDisplayData->skinData; } else { bool find = false; for (long i = _decoDisplayList.size()-2; i>=0; i--) { DecorativeDisplay *dd = _decoDisplayList.at(i); SpriteDisplayData *sdd = static_cast(dd->getDisplayData()); if (sdd) { find = true; skin->setSkinData(sdd->skinData); static_cast(displayData)->skinData = sdd->skinData; break; } } if (!find) { BaseData baseData; skin->setSkinData(baseData); } } } else if (dynamic_cast(display)) { displayData = ParticleDisplayData::create(); display->removeFromParent(); Armature *armature = _bone->getArmature(); if (armature) { display->setParent(armature); } } else if(Armature *armature = dynamic_cast(display)) { displayData = ArmatureDisplayData::create(); displayData->displayName = armature->getName(); armature->setParentBone(_bone); } else { displayData = DisplayData::create(); } decoDisplay->setDisplay(display); decoDisplay->setDisplayData(displayData); //! if changed display index is current display index, then change current display to the new display if(index == _displayIndex) { _displayIndex = -1; changeDisplayWithIndex(index, false); } } void DisplayManager::removeDisplay(int index) { if(index == _displayIndex) { setCurrentDecorativeDisplay(nullptr); _displayIndex = -1; } _decoDisplayList.erase(index); } const cocos2d::Vector& DisplayManager::getDecorativeDisplayList() const { return _decoDisplayList; } void DisplayManager::changeDisplayWithIndex(int index, bool force) { CCASSERT( index < (int)_decoDisplayList.size(), "the _index value is out of range"); _forceChangeDisplay = force; //! If index is equal to current display index,then do nothing if ( _displayIndex == index) return; _displayIndex = index; //! If displayIndex < 0, it means you want to hide you display if (_displayIndex < 0) { if(_displayRenderNode) { _displayRenderNode->removeFromParentAndCleanup(true); setCurrentDecorativeDisplay(nullptr); } return; } DecorativeDisplay *decoDisplay = (DecorativeDisplay *)_decoDisplayList.at(_displayIndex); setCurrentDecorativeDisplay(decoDisplay); } void CCDisplayManager::changeDisplayWithName(const std::string& name, bool force) { for (int i = 0; i<_decoDisplayList.size(); i++) { if (_decoDisplayList.at(i)->getDisplayData()->displayName == name) { changeDisplayWithIndex(i, force); break; } } } void DisplayManager::setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay) { #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX if (_currentDecoDisplay && _currentDecoDisplay->getColliderDetector()) { _currentDecoDisplay->getColliderDetector()->setActive(false); } #endif _currentDecoDisplay = decoDisplay; #if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX if (_currentDecoDisplay && _currentDecoDisplay->getColliderDetector()) { _currentDecoDisplay->getColliderDetector()->setActive(true); } #endif Node *displayRenderNode = _currentDecoDisplay == nullptr ? nullptr : _currentDecoDisplay->getDisplay(); if (_displayRenderNode) { if (dynamic_cast(_displayRenderNode) != nullptr) { _bone->setChildArmature(nullptr); } _displayRenderNode->removeFromParentAndCleanup(true); _displayRenderNode->release(); } _displayRenderNode = displayRenderNode; if(_displayRenderNode) { if (Armature *armature = dynamic_cast(_displayRenderNode)) { _bone->setChildArmature(armature); } else if (ParticleSystemQuad *particle = dynamic_cast(_displayRenderNode)) { particle->resetSystem(); } _displayRenderNode->setColor(_bone->getDisplayedColor()); _displayRenderNode->setOpacity(_bone->getDisplayedOpacity()); _displayRenderNode->retain(); _displayRenderNode->setVisible(_visible); _displayType = _currentDecoDisplay->getDisplayData()->displayType; } else { _displayType = CS_DISPLAY_MAX; } } Node *DisplayManager::getDisplayRenderNode() const { return _displayRenderNode; } DisplayType DisplayManager::getDisplayRenderNodeType() const { return _displayType; } int DisplayManager::getCurrentDisplayIndex() const { return _displayIndex; } DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay() const { return _currentDecoDisplay; } DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index) const { return _decoDisplayList.at(index); } void DisplayManager::initDisplayList(BoneData *boneData) { _decoDisplayList.clear(); CS_RETURN_IF(!boneData); for(auto& object : boneData->displayDataList) { DisplayData *displayData = static_cast(object); DecorativeDisplay *decoDisplay = DecorativeDisplay::create(); decoDisplay->setDisplayData(displayData); DisplayFactory::createDisplay(_bone, decoDisplay); _decoDisplayList.pushBack(decoDisplay); } } bool DisplayManager::containPoint(Point &point) { if(!_visible || _displayIndex < 0) { return false; } bool ret = false; switch (_currentDecoDisplay->getDisplayData()->displayType) { case CS_DISPLAY_SPRITE: { /* * First we first check if the point is in the sprite content rect. If false, then we continue to check * the contour point. If this step is also false, then we can say the bone not contain this point. * */ Point outPoint = Point(0, 0); Sprite *sprite = (Sprite *)_currentDecoDisplay->getDisplay(); sprite = (Sprite *)sprite->getChildByTag(0); ret = CC_SPRITE_CONTAIN_POINT_WITH_RETURN(sprite, point, outPoint); } break; default: break; } return ret; } bool DisplayManager::containPoint(float x, float y) { Point p = Point(x, y); return containPoint(p); } void DisplayManager::setVisible(bool visible) { if(!_displayRenderNode) return; _visible = visible; _displayRenderNode->setVisible(visible); } bool DisplayManager::isVisible() const { return _visible; } Size DisplayManager::getContentSize() const { CS_RETURN_IF(!_displayRenderNode) Size(0, 0); return _displayRenderNode->getContentSize(); } Rect DisplayManager::getBoundingBox() const { CS_RETURN_IF(!_displayRenderNode) Rect(0, 0, 0, 0); return _displayRenderNode->getBoundingBox(); } Point DisplayManager::getAnchorPoint() const { CS_RETURN_IF(!_displayRenderNode) Point(0, 0); return _displayRenderNode->getAnchorPoint(); } Point DisplayManager::getAnchorPointInPoints() const { CS_RETURN_IF(!_displayRenderNode) Point(0, 0); return _displayRenderNode->getAnchorPointInPoints(); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCDisplayManager.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCDISPLAYMANAGER_H__ #define __CCDISPLAYMANAGER_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDecorativeDisplay.h" #include "cocostudio/CCDatas.h" namespace cocostudio { class Bone; /**! DisplayManager manages Bone's display * @js NA * @lua NA */ class DisplayManager : public cocos2d::Object { public: static DisplayManager *create(Bone *bone); public: DisplayManager(); ~DisplayManager(); bool init(Bone *bone); /** * Use BoneData to init the display list. * If display is a sprite, and it have texture info in the TexutreData, then use TexutreData to init the display's anchor point * If the display is a Armature, then create a new Armature */ virtual void initDisplayList(BoneData *boneData); /** * Add display and use _DisplayData init the display. * If index already have a display, then replace it. * If index is current display index, then also change display to _index * * @param displayData it include the display information, like DisplayType. * If you want to create a sprite display, then create a SpriteDisplayData param * * @param index the index of the display you want to replace or add to * -1 : append display from back */ void addDisplay(DisplayData *displayData, int index); void addDisplay(cocos2d::Node *display, int index); void removeDisplay(int index); const cocos2d::Vector& getDecorativeDisplayList() const; /* * @deprecated, please use changeDisplayWithIndex and changeDisplayWithName */ CC_DEPRECATED_ATTRIBUTE void changeDisplayByIndex(int index, bool force); CC_DEPRECATED_ATTRIBUTE void changeDisplayByName(const std::string& name, bool force); /** * Change display by index. You can just use this method to change display in the display list. * The display list is just used for this bone, and it is the displays you may use in every frame. * * Note : if index is the same with prev index, the method will not effect * * @param index The index of the display you want to change * @param force If true, then force change display to specified display, or current display will set to display index edit in the flash every key frame. */ void changeDisplayWithIndex(int index, bool force); void changeDisplayWithName(const std::string& name, bool force); cocos2d::Node *getDisplayRenderNode() const; DisplayType getDisplayRenderNodeType() const; int getCurrentDisplayIndex() const; virtual void setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay); virtual DecorativeDisplay *getCurrentDecorativeDisplay() const; virtual DecorativeDisplay *getDecorativeDisplayByIndex( int index) const; /** * Sets whether the display is visible * The default value is true, a node is default to visible * * @param visible true if the node is visible, false if the node is hidden. */ virtual void setVisible(bool visible); /** * Determines if the display is visible * * @see setVisible(bool) * @return true if the node is visible, false if the node is hidden. */ virtual bool isVisible() const; cocos2d::Size getContentSize() const; cocos2d::Rect getBoundingBox() const; cocos2d::Point getAnchorPoint() const; cocos2d::Point getAnchorPointInPoints() const; /** * Check if the position is inside the bone. */ virtual bool containPoint(cocos2d::Point &_point); /** * Check if the position is inside the bone. */ virtual bool containPoint(float x, float y); virtual void setForceChangeDisplay(bool force) { _forceChangeDisplay = force; } virtual bool isForceChangeDisplay() const { return _forceChangeDisplay; } protected: cocos2d::Vector _decoDisplayList; //! Display render node. cocos2d::Node *_displayRenderNode; //! Display render node type DisplayType _displayType; //! Include current display information, like contour sprite, etc. DecorativeDisplay *_currentDecoDisplay; //! Current display index int _displayIndex; bool _forceChangeDisplay; //! Whether of not the bone is visible. Default is true bool _visible; Bone *_bone; }; } #endif /*__CCDISPLAYMANAGER_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCInputDelegate.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCInputDelegate.h" #include "CCDirector.h" #include "platform/CCDevice.h" #include "CCEventListenerTouch.h" #include "CCEventListenerAcceleration.h" #include "CCEventListenerKeyboard.h" using namespace cocos2d; namespace cocostudio { InputDelegate::InputDelegate(void) : _touchEnabled(false) , _touchListener(nullptr) , _accelerometerEnabled(false) , _accelerometerListener(nullptr) , _keypadEnabled(false) , _keyboardListener(nullptr) , _touchPriority(-1) , _touchMode(Touch::DispatchMode::ALL_AT_ONCE) { } InputDelegate::~InputDelegate(void) { auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->removeEventListener(_touchListener); dispatcher->removeEventListener(_keyboardListener); dispatcher->removeEventListener(_accelerometerListener); Device::setAccelerometerEnabled(false); } bool InputDelegate::onTouchBegan(Touch *pTouch, Event *pEvent) { CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); return true; } void InputDelegate::onTouchMoved(Touch *pTouch, Event *pEvent) { CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); } void InputDelegate::onTouchEnded(Touch *pTouch, Event *pEvent) { CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); } void InputDelegate::onTouchCancelled(Touch *pTouch, Event *pEvent) { CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); } void InputDelegate::onTouchesBegan(const std::vector& pTouches, Event *pEvent) { CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent); } void InputDelegate::onTouchesMoved(const std::vector& pTouches, Event *pEvent) { CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent); } void InputDelegate::onTouchesEnded(const std::vector& pTouches, Event *pEvent) { CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent); } void InputDelegate::onTouchesCancelled(const std::vector& pTouches, Event *pEvent) { CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent); } bool InputDelegate::isTouchEnabled() const { return _touchEnabled; } void InputDelegate::setTouchEnabled(bool enabled) { if (_touchEnabled != enabled) { auto dispatcher = Director::getInstance()->getEventDispatcher(); _touchEnabled = enabled; if (enabled) { if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE ) { // Register Touch Event auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = CC_CALLBACK_2(InputDelegate::onTouchesBegan, this); listener->onTouchesMoved = CC_CALLBACK_2(InputDelegate::onTouchesMoved, this); listener->onTouchesEnded = CC_CALLBACK_2(InputDelegate::onTouchesEnded, this); listener->onTouchesCancelled = CC_CALLBACK_2(InputDelegate::onTouchesCancelled, this); dispatcher->addEventListenerWithFixedPriority(listener, _touchPriority); _touchListener = listener; } else { // Register Touch Event auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); listener->onTouchBegan = CC_CALLBACK_2(InputDelegate::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(InputDelegate::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(InputDelegate::onTouchEnded, this); listener->onTouchCancelled = CC_CALLBACK_2(InputDelegate::onTouchCancelled, this); dispatcher->addEventListenerWithFixedPriority(listener, _touchPriority); _touchListener = listener; } } else { dispatcher->removeEventListener(_touchListener); } } } void InputDelegate::setTouchMode(Touch::DispatchMode mode) { if(_touchMode != mode) { _touchMode = mode; if( _touchEnabled) { setTouchEnabled(false); setTouchEnabled(true); } } } void InputDelegate::setTouchPriority(int priority) { if (_touchPriority != priority) { _touchPriority = priority; if( _touchEnabled) { setTouchEnabled(false); setTouchEnabled(true); } } } int InputDelegate::getTouchPriority() const { return _touchPriority; } Touch::DispatchMode InputDelegate::getTouchMode() const { return _touchMode; } bool InputDelegate::isAccelerometerEnabled() const { return _accelerometerEnabled; } void InputDelegate::setAccelerometerEnabled(bool enabled) { if (enabled != _accelerometerEnabled) { _accelerometerEnabled = enabled; auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->removeEventListener(_accelerometerListener); _accelerometerListener = nullptr; Device::setAccelerometerEnabled(enabled); if (enabled) { auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(InputDelegate::onAcceleration, this)); dispatcher->addEventListenerWithFixedPriority(listener, -1); _accelerometerListener = listener; } } } bool InputDelegate::isKeypadEnabled() const { return _keypadEnabled; } void InputDelegate::setKeypadEnabled(bool enabled) { if (enabled != _keypadEnabled) { _keypadEnabled = enabled; auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->removeEventListener(_keyboardListener); if (enabled) { auto listener = EventListenerKeyboard::create(); listener->onKeyPressed = CC_CALLBACK_2(InputDelegate::onKeyPressed, this); listener->onKeyReleased = CC_CALLBACK_2(InputDelegate::onKeyReleased, this); dispatcher->addEventListenerWithFixedPriority(listener, -1); _keyboardListener = listener; } } } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCInputDelegate.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_EXTENTIONS_CCINPUTDELEGATE_H__ #define __CC_EXTENTIONS_CCINPUTDELEGATE_H__ #include "CCPlatformMacros.h" #include "CCTouch.h" #include "CCEvent.h" #include "ccTypes.h" #include "CCEventKeyboard.h" #include "CCEventListener.h" namespace cocostudio { /** * @lua NA */ class InputDelegate { protected: /** * @js ctor */ InputDelegate(void); /** * @js NA */ virtual ~InputDelegate(void); public: virtual bool isTouchEnabled() const; virtual void setTouchEnabled(bool value); virtual bool isAccelerometerEnabled() const; virtual void setAccelerometerEnabled(bool value); virtual bool isKeypadEnabled() const; virtual void setKeypadEnabled(bool value); virtual void setTouchMode(cocos2d::Touch::DispatchMode mode); virtual cocos2d::Touch::DispatchMode getTouchMode() const; virtual void setTouchPriority(int priority); virtual int getTouchPriority() const; /** @deprecated Please override onAcceleration */ /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual void didAccelerate(cocos2d::Acceleration* accelerationValue) final { CC_UNUSED_PARAM(accelerationValue); }; // Deprecated touch callbacks. /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual bool ccTouchBegan(cocos2d::Touch *pTouch, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); return false;}; /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual void ccTouchMoved(cocos2d::Touch *pTouch, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual void ccTouchEnded(cocos2d::Touch *pTouch, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual void ccTouchCancelled(cocos2d::Touch *pTouch, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesBegan(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesMoved(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesEnded(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesCancelled(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ virtual void onAcceleration(cocos2d::Acceleration* acc, cocos2d::Event* event) {}; /** * @js NA */ virtual void onKeyPressed(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event* event) {}; /** * @js NA */ virtual void onKeyReleased(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event* event) {}; /** * @js NA */ virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event); /** * @js NA */ virtual void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event); /** * @js NA */ virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event); /** * @js NA */ virtual void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event); /** * @js NA */ virtual void onTouchesBegan(const std::vector& touches, cocos2d::Event *event); /** * @js NA */ virtual void onTouchesMoved(const std::vector& touches, cocos2d::Event *event); /** * @js NA */ virtual void onTouchesEnded(const std::vector& touches, cocos2d::Event *event); /** * @js NA */ virtual void onTouchesCancelled(const std::vector& touches, cocos2d::Event *event); protected: bool _touchEnabled; cocos2d::EventListener* _touchListener; bool _accelerometerEnabled; cocos2d::EventListener* _accelerometerListener; bool _keypadEnabled; cocos2d::EventListener* _keyboardListener; private: int _touchPriority; cocos2d::Touch::DispatchMode _touchMode; }; } #endif // __FUNDATION__CCCOMPONENT_H__ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCProcessBase.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCProcessBase.h" #include "cocostudio/CCUtilMath.h" using namespace cocos2d; namespace cocostudio { ProcessBase::ProcessBase(void) : _processScale(1) , _isPause(true) , _isComplete(true) , _isPlaying(false) , _currentPercent(0.0f) , _rawDuration(0) , _loopType(ANIMATION_LOOP_BACK) , _tweenEasing(Linear) , _animationInternal(1/60.0f) , _durationTween(0) , _currentFrame(0) , _curFrameIndex(0) , _isLoopBack(false) { } ProcessBase::~ProcessBase(void) { } void ProcessBase::pause() { _isPause = true; _isPlaying = false; } void ProcessBase::resume() { _isPause = false; _isPlaying = true; } void ProcessBase::stop() { _isComplete = true; _isPlaying = false; } void ProcessBase::play(int durationTo, int durationTween, int loop, int tweenEasing) { _isComplete = false; _isPause = false; _isPlaying = true; _currentFrame = 0; /* * Set m_iTotalFrames to durationTo, it is used for change tween between two animation. * When changing end, m_iTotalFrames will be setted to _durationTween */ _nextFrameIndex = durationTo; _tweenEasing = (TweenType)tweenEasing; } void ProcessBase::update(float dt) { if (_isComplete || _isPause) { return; } /* * Fileter the m_iDuration <=0 and dt >1 * If dt>1, generally speaking the reason is the device is stuck. */ if(_rawDuration <= 0 || dt > 1) { return; } if (_nextFrameIndex <= 0) { _currentPercent = 1; _currentFrame = 0; } else { /* * update _currentFrame, every update add the frame passed. * dt/_animationInternal determine it is not a frame animation. If frame speed changed, it will not make our * animation speed slower or quicker. */ _currentFrame += _processScale * (dt / _animationInternal); _currentPercent = _currentFrame / _nextFrameIndex; /* * if _currentFrame is bigger or equal than m_iTotalFrames, then reduce it util _currentFrame is * smaller than m_iTotalFrames */ _currentFrame = fmodf(_currentFrame, _nextFrameIndex); } updateHandler(); } void ProcessBase::gotoFrame(int frameIndex) { if (_loopType == ANIMATION_NO_LOOP) { _loopType = ANIMATION_MAX; } else if (_loopType == ANIMATION_TO_LOOP_FRONT) { _loopType = ANIMATION_LOOP_FRONT; } _curFrameIndex = frameIndex; _nextFrameIndex = _durationTween; } int ProcessBase::getCurrentFrameIndex() { _curFrameIndex = (_rawDuration-1) * _currentPercent; return _curFrameIndex; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCProcessBase.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPROCESSBASE_H__ #define __CCPROCESSBASE_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDatas.h" namespace cocostudio { enum AnimationType { SINGLE_FRAME = -4, //! the animation just have one frame ANIMATION_NO_LOOP, //! the animation isn't loop ANIMATION_TO_LOOP_FRONT, //! the animation loop from front ANIMATION_TO_LOOP_BACK, //! the animation loop from back ANIMATION_LOOP_FRONT, //! the animation loop from front ANIMATION_LOOP_BACK, //! the animation loop from back ANIMATION_MAX, }; /** * @js NA * @lua NA */ class ProcessBase : public cocos2d::Object { public: ProcessBase(void); virtual ~ProcessBase(void); /** * Play animation by animation name. * * @param durationTo The frames between two animation changing-over. * It's meaning is changing to this animation need how many frames * * -1 : use the value from MovementData get from flash design panel * @param durationTween The frame count you want to play in the game. * if _durationTween is 80, then the animation will played 80 frames in a loop * * -1 : use the value from MovementData get from flash design panel * * @param loop Whether the animation is loop * * loop < 0 : use the value from MovementData get from flash design panel * loop = 0 : this animation is not loop * loop > 0 : this animation is loop * * @param tweenEasing Tween easing is used for calculate easing effect * * TWEEN_EASING_MAX : use the value from MovementData get from flash design panel * -1 : fade out * 0 : line * 1 : fade in * 2 : fade in and out * */ virtual void play(int durationTo, int durationTween, int loop, int tweenEasing); /** * Pause the Process */ virtual void pause(); /** * Resume the Process */ virtual void resume(); /** * Stop the Process */ virtual void stop(); /** * You should never call this function, unless you know what you do * Update the Process, include current process, current frame and son on * * @param The duration since last update */ virtual void update(float dt); virtual int getCurrentFrameIndex(); virtual void setProcessScale(float processScale) { _processScale = processScale; } virtual float getProcessScale() const { return _processScale; } virtual void setIsPause(bool pause) { _isPause = pause; } virtual bool isPause() const { return _isPause; } virtual void setIsComplete(bool complete) { _isComplete = complete; } virtual bool isComplete() const { return _isComplete; } virtual void setIsPlaying(bool playing) { _isPlaying = playing; } virtual bool isPlaying() const { return _isPlaying; } virtual float getCurrentPercent() const { return _currentPercent; } virtual int getRawDuration() const { return _rawDuration; } protected: virtual void gotoFrame(int frameIndex); /** * Update(float dt) will call this handler, you can handle your logic here */ virtual void updateHandler() {}; protected: //! Scale the process speed float _processScale; //! Set and get whether the aniamtion is pause bool _isPause; //! Set and get whether the aniamtion is complete bool _isComplete; //! Set and get whether the aniamtion is playing bool _isPlaying; //! Current percent this process arrived float _currentPercent; //! The raw duration int _rawDuration; //! The animation whether or not loop AnimationType _loopType; //! The tween easing effect TweenType _tweenEasing; //! The animation update speed float _animationInternal; protected: //! The durantion frame count will run int _durationTween; //! Current frame this process arrived, this frame is tween frame float _currentFrame; //! Frame index it the time line int _curFrameIndex; //! Next frame this process need run to int _nextFrameIndex; bool _isLoopBack; }; } #endif /*__CCPROCESSBASE_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCSGUIReader.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCSGUIReader.h" #include "gui/CocosGUI.h" #include "cocostudio/CCActionManagerEx.h" #include #include using namespace cocos2d::gui; using namespace cocos2d; namespace cocostudio { static GUIReader* sharedReader = nullptr; GUIReader::GUIReader(): m_strFilePath("") { } GUIReader::~GUIReader() { } GUIReader* GUIReader::getInstance() { if (!sharedReader) { sharedReader = new GUIReader(); } return sharedReader; } void GUIReader::destroyInstance() { CC_SAFE_DELETE(sharedReader); } int GUIReader::getVersionInteger(const char *str) { std::string strVersion = str; size_t length = strVersion.length(); if (length < 7) { return 0; } size_t pos = strVersion.find_first_of("."); std::string t = strVersion.substr(0,pos); strVersion = strVersion.substr(pos+1,strVersion.length()-1); pos = strVersion.find_first_of("."); std::string h = strVersion.substr(0,pos); strVersion = strVersion.substr(pos+1,strVersion.length()-1); pos = strVersion.find_first_of("."); std::string te = strVersion.substr(0,pos); strVersion = strVersion.substr(pos+1,strVersion.length()-1); pos = strVersion.find_first_of("."); std::string s = strVersion.substr(0,pos); int it = atoi(t.c_str()); int ih = atoi(h.c_str()); int ite = atoi(te.c_str()); int is = atoi(s.c_str()); int iVersion = it*1000+ih*100+ite*10+is; CCLOG("iversion %d",iVersion); return iVersion; /************************/ } void GUIReader::storeFileDesignSize(const char *fileName, const cocos2d::Size &size) { std::string keyWidth = fileName; keyWidth.append("width"); std::string keyHeight = fileName; keyHeight.append("height"); _fileDesignSizes[keyWidth] = Value(size.width); _fileDesignSizes[keyHeight] = Value(size.height); } const cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const { std::string keyWidth = fileName; keyWidth.append("width"); std::string keyHeight = fileName; keyHeight.append("height"); float w = _fileDesignSizes.at(keyWidth).asFloat(); float h = _fileDesignSizes.at(keyHeight).asFloat(); return Size(w, h); } Widget* GUIReader::widgetFromJsonFile(const char *fileName) { std::string jsonpath; rapidjson::Document jsonDict; jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName); size_t pos = jsonpath.find_last_of('/'); m_strFilePath = jsonpath.substr(0,pos+1); std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonpath); jsonDict.Parse<0>(contentStr.c_str()); if (jsonDict.HasParseError()) { CCLOG("GetParseError %s\n",jsonDict.GetParseError()); } Widget* widget = nullptr; const char* fileVersion = DICTOOL->getStringValue_json(jsonDict, "version"); WidgetPropertiesReader * pReader = nullptr; if (fileVersion) { int versionInteger = getVersionInteger(fileVersion); if (versionInteger < 250) { pReader = new WidgetPropertiesReader0250(); widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); } else { pReader = new WidgetPropertiesReader0300(); widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); } } else { pReader = new WidgetPropertiesReader0250(); widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); } CC_SAFE_DELETE(pReader); return widget; } Widget* WidgetPropertiesReader0250::createWidget(const rapidjson::Value& data, const char* fullPath, const char* fileName) { m_strFilePath = fullPath; int texturesCount = DICTOOL->getArrayCount_json(data, "textures"); for (int i=0; igetStringValueFromArray_json(data, "textures", i); std::string tp = fullPath; tp.append(file); CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(tp.c_str()); } float fileDesignWidth = DICTOOL->getFloatValue_json(data, "designWidth"); float fileDesignHeight = DICTOOL->getFloatValue_json(data, "designHeight"); if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { CCLOGERROR("Read design size error!\n"); Size winSize = Director::getInstance()->getWinSize(); GUIReader::getInstance()->storeFileDesignSize(fileName, winSize); } else { GUIReader::getInstance()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); } const rapidjson::Value& widgetTree = DICTOOL->getSubDictionary_json(data, "widgetTree"); Widget* widget = widgetFromJsonDictionary(widgetTree); /* *********temp********* */ if (widget->getContentSize().equals(Size::ZERO)) { Layout* rootWidget = dynamic_cast(widget); rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); } /* ********************** */ // widget->setFileDesignSize(Size(fileDesignWidth, fileDesignHeight)); const rapidjson::Value& actions = DICTOOL->getSubDictionary_json(data, "animation"); /* *********temp********* */ // ActionManager::getInstance()->releaseActions(); /* ********************** */ CCLOG("file name == [%s]",fileName); Object* rootWidget = (Object*) widget; ActionManagerEx::getInstance()->initWithDictionary(fileName,actions,rootWidget); return widget; } Widget* WidgetPropertiesReader0250::widgetFromJsonDictionary(const rapidjson::Value&data) { Widget* widget = nullptr; const char* classname = DICTOOL->getStringValue_json(data, "classname"); const rapidjson::Value& uiOptions = DICTOOL->getSubDictionary_json(data, "options"); if (classname && strcmp(classname, "Button") == 0) { widget = cocos2d::gui::Button::create(); setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "CheckBox") == 0) { widget = CheckBox::create(); setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "Label") == 0) { widget = cocos2d::gui::Text::create(); setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LabelAtlas") == 0) { widget = cocos2d::gui::TextAtlas::create(); setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LoadingBar") == 0) { widget = cocos2d::gui::LoadingBar::create(); setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); }else if (classname && strcmp(classname, "ScrollView") == 0){ widget = cocos2d::gui::ScrollView::create(); setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextArea") == 0) { widget = cocos2d::gui::Text::create(); setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextButton") == 0) { widget = cocos2d::gui::Button::create(); setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextField") == 0) { widget = cocos2d::gui::TextField::create(); setPropsForTextFieldFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "ImageView") == 0) { widget = cocos2d::gui::ImageView::create(); setPropsForImageViewFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "Panel") == 0) { widget = Layout::create(); setPropsForLayoutFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "Slider") == 0) { widget = cocos2d::gui::Slider::create(); setPropsForSliderFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LabelBMFont") == 0) { widget = cocos2d::gui::TextBMFont::create(); setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "DragPanel") == 0) { widget = cocos2d::gui::ScrollView::create(); setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } int childrenCount = DICTOOL->getArrayCount_json(data, "children"); for (int i=0;igetDictionaryFromArray_json(data, "children", i); Widget* child = widgetFromJsonDictionary(subData); if (child) { widget->addChild(child); } } return widget; } void WidgetPropertiesReader0250::setPropsForWidgetFromJsonDictionary(Widget*widget,const rapidjson::Value&options) { bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, "ignoreSize"); if (ignoreSizeExsit) { widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, "ignoreSize")); } float w = DICTOOL->getFloatValue_json(options, "width"); float h = DICTOOL->getFloatValue_json(options, "height"); widget->setSize(Size(w, h)); widget->setTag(DICTOOL->getIntValue_json(options, "tag")); widget->setActionTag(DICTOOL->getIntValue_json(options, "actiontag")); widget->setTouchEnabled(DICTOOL->getBooleanValue_json(options, "touchAble")); const char* name = DICTOOL->getStringValue_json(options, "name"); const char* widgetName = name?name:"default"; widget->setName(widgetName); float x = DICTOOL->getFloatValue_json(options, "x"); float y = DICTOOL->getFloatValue_json(options, "y"); widget->setPosition(Point(x,y)); bool sx = DICTOOL->checkObjectExist_json(options, "scaleX"); if (sx) { widget->setScaleX(DICTOOL->getFloatValue_json(options, "scaleX")); } bool sy = DICTOOL->checkObjectExist_json(options, "scaleY"); if (sy) { widget->setScaleY(DICTOOL->getFloatValue_json(options, "scaleY")); } bool rt = DICTOOL->checkObjectExist_json(options, "rotation"); if (rt) { widget->setRotation(DICTOOL->getFloatValue_json(options, "rotation")); } bool vb = DICTOOL->checkObjectExist_json(options, "visible"); if (vb) { widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible")); } int z = DICTOOL->getIntValue_json(options, "ZOrder"); widget->setLocalZOrder(z); } void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(Widget *widget, const rapidjson::Value&options) { bool op = DICTOOL->checkObjectExist_json(options, "opacity"); if (op) { widget->setOpacity(DICTOOL->getIntValue_json(options, "opacity")); } bool cr = DICTOOL->checkObjectExist_json(options, "colorR"); bool cg = DICTOOL->checkObjectExist_json(options, "colorG"); bool cb = DICTOOL->checkObjectExist_json(options, "colorB"); int colorR = cr ? DICTOOL->getIntValue_json(options, "colorR") : 255; int colorG = cg ? DICTOOL->getIntValue_json(options, "colorG") : 255; int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255; widget->setColor(Color3B(colorR, colorG, colorB)); bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX"); float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY"); float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); widget->setAnchorPoint(Point(apxf, apyf)); bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); widget->setFlipX(flipX); widget->setFlipY(flipY); } void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::Button* button = static_cast(widget); bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); button->setScale9Enabled(scale9Enable); std::string tp_n = m_strFilePath; std::string tp_p = m_strFilePath; std::string tp_d = m_strFilePath; const char* normalFileName = DICTOOL->getStringValue_json(options, "normal"); const char* pressedFileName = DICTOOL->getStringValue_json(options, "pressed"); const char* disabledFileName = DICTOOL->getStringValue_json(options, "disabled"); const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); if (scale9Enable) { float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); if (useMergedTexture) { button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); } else { button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); } button->setCapInsets(Rect(cx, cy, cw, ch)); bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); if (sw && sh) { float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); button->setSize(Size(swf, shf)); } } else { if (useMergedTexture) { button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); } else { button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); } } bool tt = DICTOOL->checkObjectExist_json(options, "text"); if (tt) { const char* text = DICTOOL->getStringValue_json(options, "text"); if (text) { button->setTitleText(text); } } bool cr = DICTOOL->checkObjectExist_json(options, "textColorR"); bool cg = DICTOOL->checkObjectExist_json(options, "textColorG"); bool cb = DICTOOL->checkObjectExist_json(options, "textColorB"); int cri = cr?DICTOOL->getIntValue_json(options, "textColorR"):255; int cgi = cg?DICTOOL->getIntValue_json(options, "textColorG"):255; int cbi = cb?DICTOOL->getIntValue_json(options, "textColorB"):255; button->setTitleColor(Color3B(cri,cgi,cbi)); bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); if (fs) { button->setTitleFontSize(DICTOOL->getIntValue_json(options, "fontSize")); } bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { button->setTitleFontName(DICTOOL->getStringValue_json(options, "fontName")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForCheckBoxFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); CheckBox* checkBox = static_cast(widget); const char* backGroundFileName = DICTOOL->getStringValue_json(options, "backGroundBox"); const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(options, "backGroundBoxSelected"); const char* frontCrossFileName = DICTOOL->getStringValue_json(options, "frontCross"); const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(options, "backGroundBoxDisabled"); const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "frontCrossDisabled"); std::string tp_b = m_strFilePath; std::string tp_bs = m_strFilePath; std::string tp_c = m_strFilePath; std::string tp_bd = m_strFilePath; std::string tp_cd = m_strFilePath; const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():nullptr; const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():nullptr; const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():nullptr; const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():nullptr; const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():nullptr; bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); if (useMergedTexture) { checkBox->loadTextures(backGroundFileName, backGroundSelectedFileName, frontCrossFileName,backGroundDisabledFileName,frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); } else { checkBox->loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp,backGroundDisabledFileName_tp,frontCrossDisabledFileName_tp); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::ImageView* imageView = static_cast(widget); const char* imageFileName = DICTOOL->getStringValue_json(options, "fileName"); bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); bool scale9Enable = false; if (scale9EnableExist) { scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); } imageView->setScale9Enabled(scale9Enable); std::string tp_i = m_strFilePath; const char* imageFileName_tp = nullptr; if (imageFileName && (strcmp(imageFileName, "") != 0)) { imageFileName_tp = tp_i.append(imageFileName).c_str(); } bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); if (scale9Enable) { if (useMergedTexture) { imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); } else { imageView->loadTexture(imageFileName_tp); } bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); if (sw && sh) { float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); imageView->setSize(Size(swf, shf)); } float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); imageView->setCapInsets(Rect(cx, cy, cw, ch)); } else { if (useMergedTexture) { imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); } else { imageView->loadTexture(imageFileName_tp); } } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForLabelFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::Text* label = static_cast(widget); bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable"); label->setTouchScaleChangeEnabled(touchScaleChangeAble); const char* text = DICTOOL->getStringValue_json(options, "text"); label->setText(text); bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); if (fs) { label->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); } bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { label->setFontName(DICTOOL->getStringValue_json(options, "fontName")); } bool aw = DICTOOL->checkObjectExist_json(options, "areaWidth"); bool ah = DICTOOL->checkObjectExist_json(options, "areaHeight"); if (aw && ah) { Size size = Size(DICTOOL->getFloatValue_json(options, "areaWidth"),DICTOOL->getFloatValue_json(options,"areaHeight")); label->setTextAreaSize(size); } bool ha = DICTOOL->checkObjectExist_json(options, "hAlignment"); if (ha) { label->setTextHorizontalAlignment((TextHAlignment)DICTOOL->getIntValue_json(options, "hAlignment")); } bool va = DICTOOL->checkObjectExist_json(options, "vAlignment"); if (va) { label->setTextVerticalAlignment((TextVAlignment)DICTOOL->getIntValue_json(options, "vAlignment")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::TextAtlas* labelAtlas = static_cast(widget); bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); bool ih = DICTOOL->checkObjectExist_json(options, "itemHeight"); bool scm = DICTOOL->checkObjectExist_json(options, "startCharMap"); if (sv && cmf && iw && ih && scm && (strcmp(DICTOOL->getStringValue_json(options, "charMapFile"), "") != 0)) { std::string tp_c = m_strFilePath; const char* cmf_tp = nullptr; const char* cmft = DICTOOL->getStringValue_json(options, "charMapFile"); cmf_tp = tp_c.append(cmft).c_str(); labelAtlas->setProperty(DICTOOL->getStringValue_json(options, "stringValue"),cmf_tp,DICTOOL->getIntValue_json(options, "itemWidth"),DICTOOL->getIntValue_json(options,"itemHeight"),DICTOOL->getStringValue_json(options, "startCharMap")); labelAtlas->setProperty(DICTOOL->getStringValue_json(options, "stringValue"),cmf_tp,DICTOOL->getIntValue_json(options, "itemWidth") / CC_CONTENT_SCALE_FACTOR() ,DICTOOL->getIntValue_json(options,"itemHeight") / CC_CONTENT_SCALE_FACTOR(), DICTOOL->getStringValue_json(options, "startCharMap")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); Layout* containerWidget = static_cast(widget); if (!dynamic_cast(containerWidget) && !dynamic_cast(containerWidget)) { containerWidget->setClippingEnabled(DICTOOL->getBooleanValue_json(options, "clipAble")); } Layout* panel = (Layout*)widget; bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, "backGroundScale9Enable"); panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); int cr = DICTOOL->getIntValue_json(options, "bgColorR"); int cg = DICTOOL->getIntValue_json(options, "bgColorG"); int cb = DICTOOL->getIntValue_json(options, "bgColorB"); int scr = DICTOOL->getIntValue_json(options, "bgStartColorR"); int scg = DICTOOL->getIntValue_json(options, "bgStartColorG"); int scb = DICTOOL->getIntValue_json(options, "bgStartColorB"); int ecr = DICTOOL->getIntValue_json(options, "bgEndColorR"); int ecg = DICTOOL->getIntValue_json(options, "bgEndColorG"); int ecb = DICTOOL->getIntValue_json(options, "bgEndColorB"); float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); int colorType = DICTOOL->getIntValue_json(options, "colorType"); panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); panel->setBackGroundColor(Color3B(cr, cg, cb)); panel->setBackGroundColorOpacity(co); std::string tp_b = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(options, "backGroundImage"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); if (backGroundScale9Enable) { float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); if (useMergedTexture) { panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); } else { panel->setBackGroundImage(imageFileName_tp); } panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); } else { if (useMergedTexture) { panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); } else { panel->setBackGroundImage(imageFileName_tp); } } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForScrollViewFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForLayoutFromJsonDictionary(widget, options); cocos2d::gui::ScrollView* scrollView = static_cast(widget); float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); int direction = DICTOOL->getFloatValue_json(options, "direction"); scrollView->setDirection((SCROLLVIEW_DIR)direction); scrollView->setBounceEnabled(DICTOOL->getBooleanValue_json(options, "bounceEnable")); setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::Slider* slider = static_cast(widget); bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable"); slider->setScale9Enabled(barTextureScale9Enable); bool bt = DICTOOL->checkObjectExist_json(options, "barFileName"); float barLength = DICTOOL->getFloatValue_json(options, "length"); bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); if (bt) { if (barTextureScale9Enable) { std::string tp_b = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(options, "barFileName"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); } else { slider->loadBarTexture(imageFileName_tp); } slider->setSize(Size(barLength, slider->getContentSize().height)); } else { std::string tp_b = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(options, "barFileName"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); } else { slider->loadBarTexture(imageFileName_tp); } } } std::string tp_n = m_strFilePath; std::string tp_p = m_strFilePath; std::string tp_d = m_strFilePath; const char* normalFileName = DICTOOL->getStringValue_json(options, "ballNormal"); const char* pressedFileName = DICTOOL->getStringValue_json(options, "ballPressed"); const char* disabledFileName = DICTOOL->getStringValue_json(options, "ballDisabled"); const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; if (useMergedTexture) { slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); } else { slider->loadSlidBallTextures(normalFileName_tp,pressedFileName_tp,disabledFileName_tp); } slider->setPercent(DICTOOL->getIntValue_json(options, "percent")); std::string tp_b = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(options, "progressBarFileName"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { slider->loadProgressBarTexture(imageFileName, UI_TEX_TYPE_PLIST); } else { slider->loadProgressBarTexture(imageFileName_tp); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForTextFieldFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::TextField* textField = static_cast(widget); bool ph = DICTOOL->checkObjectExist_json(options, "placeHolder"); if (ph) { textField->setPlaceHolder(DICTOOL->getStringValue_json(options, "placeHolder")); } textField->setText(DICTOOL->getStringValue_json(options, "text")); bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); if (fs) { textField->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); } bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { textField->setFontName(DICTOOL->getStringValue_json(options, "fontName")); } bool tsw = DICTOOL->checkObjectExist_json(options, "touchSizeWidth"); bool tsh = DICTOOL->checkObjectExist_json(options, "touchSizeHeight"); if (tsw && tsh) { textField->setTouchSize(Size(DICTOOL->getFloatValue_json(options, "touchSizeWidth"), DICTOOL->getFloatValue_json(options,"touchSizeHeight"))); } float dw = DICTOOL->getFloatValue_json(options, "width"); float dh = DICTOOL->getFloatValue_json(options, "height"); if (dw > 0.0f || dh > 0.0f) { //textField->setSize(Size(dw, dh)); } bool maxLengthEnable = DICTOOL->getBooleanValue_json(options, "maxLengthEnable"); textField->setMaxLengthEnabled(maxLengthEnable); if (maxLengthEnable) { int maxLength = DICTOOL->getIntValue_json(options, "maxLength"); textField->setMaxLength(maxLength); } bool passwordEnable = DICTOOL->getBooleanValue_json(options, "passwordEnable"); textField->setPasswordEnabled(passwordEnable); if (passwordEnable) { textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, "passwordStyleText")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForLoadingBarFromJsonDictionary(Widget *widget, const rapidjson::Value&options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::LoadingBar* loadingBar = static_cast(widget); bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); std::string tp_b = m_strFilePath; const char*imageFileName = DICTOOL->getStringValue_json(options, "texture"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); } else { loadingBar->loadTexture(imageFileName_tp); } loadingBar->setDirection(LoadingBarType(DICTOOL->getIntValue_json(options, "direction"))); loadingBar->setPercent(DICTOOL->getIntValue_json(options, "percent")); setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0250::setPropsForLabelBMFontFromJsonDictionary(Widget *widget, const rapidjson::Value&options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::TextBMFont* labelBMFont = static_cast(widget); std::string tp_c = m_strFilePath; const char* cmf_tp = nullptr; const char* cmft = DICTOOL->getStringValue_json(options, "fileName"); cmf_tp = tp_c.append(cmft).c_str(); labelBMFont->setFntFile(cmf_tp); const char* text = DICTOOL->getStringValue_json(options, "text"); labelBMFont->setText(text); setColorPropsForWidgetFromJsonDictionary(widget,options); } /*0.3.0.0~1.0.0.0*/ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, const char* fullPath, const char* fileName) { m_strFilePath = fullPath; int texturesCount = DICTOOL->getArrayCount_json(data, "textures"); for (int i=0; igetStringValueFromArray_json(data, "textures", i); std::string tp = fullPath; tp.append(file); SpriteFrameCache::getInstance()->addSpriteFramesWithFile(tp.c_str()); } float fileDesignWidth = DICTOOL->getFloatValue_json(data, "designWidth"); float fileDesignHeight = DICTOOL->getFloatValue_json(data, "designHeight"); if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { CCLOGERROR("Read design size error!\n"); Size winSize = Director::getInstance()->getWinSize(); GUIReader::getInstance()->storeFileDesignSize(fileName, winSize); } else { GUIReader::getInstance()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); } const rapidjson::Value& widgetTree = DICTOOL->getSubDictionary_json(data, "widgetTree"); Widget* widget = widgetFromJsonDictionary(widgetTree); /* *********temp********* */ if (widget->getContentSize().equals(Size::ZERO)) { Layout* rootWidget = dynamic_cast(widget); rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); } /* ********************** */ // widget->setFileDesignSize(Size(fileDesignWidth, fileDesignHeight)); const rapidjson::Value& actions = DICTOOL->getSubDictionary_json(data, "animation"); /* *********temp********* */ // ActionManager::getInstance()->releaseActions(); /* ********************** */ CCLOG("file name == [%s]",fileName); Object* rootWidget = (Object*) widget; ActionManagerEx::getInstance()->initWithDictionary(fileName,actions,rootWidget); return widget; } Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Value&data) { Widget* widget = nullptr; const char* classname = DICTOOL->getStringValue_json(data, "classname"); const rapidjson::Value& uiOptions = DICTOOL->getSubDictionary_json(data, "options"); if (classname && strcmp(classname, "Button") == 0) { widget = cocos2d::gui::Button::create(); setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "CheckBox") == 0) { widget = CheckBox::create(); setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "Label") == 0) { widget = cocos2d::gui::Text::create(); setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LabelAtlas") == 0) { widget = cocos2d::gui::TextAtlas::create(); setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LoadingBar") == 0) { widget = cocos2d::gui::LoadingBar::create(); setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); }else if (classname && strcmp(classname, "ScrollView") == 0){ widget = cocos2d::gui::ScrollView::create(); setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextArea") == 0) { widget = cocos2d::gui::Text::create(); setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextButton") == 0) { widget = cocos2d::gui::Button::create(); setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextField") == 0) { widget = cocos2d::gui::TextField::create(); setPropsForTextFieldFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "ImageView") == 0) { widget = cocos2d::gui::ImageView::create(); setPropsForImageViewFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "Panel") == 0) { widget = Layout::create(); setPropsForLayoutFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "Slider") == 0) { widget = cocos2d::gui::Slider::create(); setPropsForSliderFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LabelBMFont") == 0) { widget = cocos2d::gui::TextBMFont::create(); setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "DragPanel") == 0) { widget = cocos2d::gui::ScrollView::create(); setPropsForScrollViewFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "ListView") == 0) { widget = cocos2d::gui::ListView::create(); setPropsForListViewFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "PageView") == 0) { widget = cocos2d::gui::PageView::create(); setPropsForPageViewFromJsonDictionary(widget, uiOptions); } int childrenCount = DICTOOL->getArrayCount_json(data, "children"); for (int i=0;igetDictionaryFromArray_json(data, "children", i); Widget* child = widgetFromJsonDictionary(subData); if (child) { PageView* pageView = dynamic_cast(widget); if (pageView) { pageView->addPage(static_cast(child)); } else { ListView* listView = dynamic_cast(widget); if (listView) { listView->pushBackCustomItem(child); } else { widget->addChild(child); } } } } return widget; } void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widget,const rapidjson::Value&options) { bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, "ignoreSize"); if (ignoreSizeExsit) { widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, "ignoreSize")); } widget->setSizeType((SizeType)DICTOOL->getIntValue_json(options, "sizeType")); widget->setPositionType((PositionType)DICTOOL->getIntValue_json(options, "positionType")); widget->setSizePercent(Point(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); widget->setPositionPercent(Point(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY"))); float w = DICTOOL->getFloatValue_json(options, "width"); float h = DICTOOL->getFloatValue_json(options, "height"); widget->setSize(Size(w, h)); widget->setTag(DICTOOL->getIntValue_json(options, "tag")); widget->setActionTag(DICTOOL->getIntValue_json(options, "actiontag")); widget->setTouchEnabled(DICTOOL->getBooleanValue_json(options, "touchAble")); const char* name = DICTOOL->getStringValue_json(options, "name"); const char* widgetName = name?name:"default"; widget->setName(widgetName); float x = DICTOOL->getFloatValue_json(options, "x"); float y = DICTOOL->getFloatValue_json(options, "y"); widget->setPosition(Point(x,y)); bool sx = DICTOOL->checkObjectExist_json(options, "scaleX"); if (sx) { widget->setScaleX(DICTOOL->getFloatValue_json(options, "scaleX")); } bool sy = DICTOOL->checkObjectExist_json(options, "scaleY"); if (sy) { widget->setScaleY(DICTOOL->getFloatValue_json(options, "scaleY")); } bool rt = DICTOOL->checkObjectExist_json(options, "rotation"); if (rt) { widget->setRotation(DICTOOL->getFloatValue_json(options, "rotation")); } bool vb = DICTOOL->checkObjectExist_json(options, "visible"); if (vb) { widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible")); } int z = DICTOOL->getIntValue_json(options, "ZOrder"); widget->setLocalZOrder(z); bool layout = DICTOOL->checkObjectExist_json(options, "layoutParameter"); if (layout) { const rapidjson::Value& layoutParameterDic = DICTOOL->getSubDictionary_json(options, "layoutParameter"); int paramType = DICTOOL->getIntValue_json(layoutParameterDic, "type"); LayoutParameter* parameter = nullptr; switch (paramType) { case 0: break; case 1: { parameter = LinearLayoutParameter::create(); int gravity = DICTOOL->getIntValue_json(layoutParameterDic, "gravity"); ((LinearLayoutParameter*)parameter)->setGravity((LinearGravity)gravity); break; } case 2: { parameter = RelativeLayoutParameter::create(); RelativeLayoutParameter* rParameter = (RelativeLayoutParameter*)parameter; const char* relativeName = DICTOOL->getStringValue_json(layoutParameterDic, "relativeName"); rParameter->setRelativeName(relativeName); const char* relativeToName = DICTOOL->getStringValue_json(layoutParameterDic, "relativeToName"); rParameter->setRelativeToWidgetName(relativeToName); int align = DICTOOL->getIntValue_json(layoutParameterDic, "align"); rParameter->setAlign((RelativeAlign)align); break; } default: break; } if (parameter) { float mgl = DICTOOL->getFloatValue_json(layoutParameterDic, "marginLeft"); float mgt = DICTOOL->getFloatValue_json(layoutParameterDic, "marginTop"); float mgr = DICTOOL->getFloatValue_json(layoutParameterDic, "marginRight"); float mgb = DICTOOL->getFloatValue_json(layoutParameterDic, "marginDown"); parameter->setMargin(Margin(mgl, mgt, mgr, mgb)); widget->setLayoutParameter(parameter); } } } void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(Widget *widget, const rapidjson::Value&options) { bool op = DICTOOL->checkObjectExist_json(options, "opacity"); if (op) { widget->setOpacity(DICTOOL->getIntValue_json(options, "opacity")); } bool cr = DICTOOL->checkObjectExist_json(options, "colorR"); bool cg = DICTOOL->checkObjectExist_json(options, "colorG"); bool cb = DICTOOL->checkObjectExist_json(options, "colorB"); int colorR = cr ? DICTOOL->getIntValue_json(options, "colorR") : 255; int colorG = cg ? DICTOOL->getIntValue_json(options, "colorG") : 255; int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255; widget->setColor(Color3B(colorR, colorG, colorB)); bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX"); float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY"); float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); widget->setAnchorPoint(Point(apxf, apyf)); bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); widget->setFlipX(flipX); widget->setFlipY(flipY); } void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::Button* button = static_cast(widget); bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); button->setScale9Enabled(scale9Enable); const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "normalData"); int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); switch (normalType) { case 0: { std::string tp_n = m_strFilePath; const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; button->loadTextureNormal(normalFileName_tp); break; } case 1: { const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); button->loadTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); break; } default: break; } const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData"); int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); switch (pressedType) { case 0: { std::string tp_p = m_strFilePath; const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; button->loadTexturePressed(pressedFileName_tp); break; } case 1: { const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); button->loadTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); break; } default: break; } const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData"); int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); switch (disabledType) { case 0: { std::string tp_d = m_strFilePath; const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; button->loadTextureDisabled(disabledFileName_tp); break; } case 1: { const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); button->loadTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); break; } default: break; } if (scale9Enable) { float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); button->setCapInsets(Rect(cx, cy, cw, ch)); bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); if (sw && sh) { float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); button->setSize(Size(swf, shf)); } } bool tt = DICTOOL->checkObjectExist_json(options, "text"); if (tt) { const char* text = DICTOOL->getStringValue_json(options, "text"); if (text) { button->setTitleText(text); } } bool cr = DICTOOL->checkObjectExist_json(options, "textColorR"); bool cg = DICTOOL->checkObjectExist_json(options, "textColorG"); bool cb = DICTOOL->checkObjectExist_json(options, "textColorB"); int cri = cr?DICTOOL->getIntValue_json(options, "textColorR"):255; int cgi = cg?DICTOOL->getIntValue_json(options, "textColorG"):255; int cbi = cb?DICTOOL->getIntValue_json(options, "textColorB"):255; button->setTitleColor(Color3B(cri,cgi,cbi)); bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); if (fs) { button->setTitleFontSize(DICTOOL->getIntValue_json(options, "fontSize")); } bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { button->setTitleFontName(DICTOOL->getStringValue_json(options, "fontName")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); CheckBox* checkBox = static_cast(widget); const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData"); int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType"); switch (backGroundType) { case 0: { std::string tp_b = m_strFilePath; const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():nullptr; checkBox->loadTextureBackGround(backGroundFileName_tp); break; } case 1: { const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); checkBox->loadTextureBackGround(backGroundFileName,UI_TEX_TYPE_PLIST); break; } default: break; } const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData"); int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType"); switch (backGroundSelectedType) { case 0: { std::string tp_bs = m_strFilePath; const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():nullptr; checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp); break; } case 1: { const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,UI_TEX_TYPE_PLIST); break; } default: break; } const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData"); int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType"); switch (frontCrossType) { case 0: { std::string tp_c = m_strFilePath; const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():nullptr; checkBox->loadTextureFrontCross(frontCrossFileName_tp); break; } case 1: { const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); checkBox->loadTextureFrontCross(frontCrossFileName,UI_TEX_TYPE_PLIST); break; } default: break; } const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData"); int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType"); switch (backGroundDisabledType) { case 0: { std::string tp_bd = m_strFilePath; const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():nullptr; checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); break; } case 1: { const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,UI_TEX_TYPE_PLIST); break; } default: break; } const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData"); int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType"); switch (frontCrossDisabledType) { case 0: { std::string tp_cd = m_strFilePath; const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():nullptr; checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); break; } case 1: { const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); break; } default: break; } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForImageViewFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::ImageView* imageView = static_cast(widget); const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); switch (imageFileNameType) { case 0: { std::string tp_i = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); const char* imageFileName_tp = nullptr; if (imageFileName && (strcmp(imageFileName, "") != 0)) { imageFileName_tp = tp_i.append(imageFileName).c_str(); imageView->loadTexture(imageFileName_tp); } break; } case 1: { const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); break; } default: break; } bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); bool scale9Enable = false; if (scale9EnableExist) { scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); } imageView->setScale9Enabled(scale9Enable); if (scale9Enable) { bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); if (sw && sh) { float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); imageView->setSize(Size(swf, shf)); } float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); imageView->setCapInsets(Rect(cx, cy, cw, ch)); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForLabelFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::Text* label = static_cast(widget); bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable"); label->setTouchScaleChangeEnabled(touchScaleChangeAble); const char* text = DICTOOL->getStringValue_json(options, "text"); label->setText(text); bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); if (fs) { label->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); } bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { label->setFontName(DICTOOL->getStringValue_json(options, "fontName")); } bool aw = DICTOOL->checkObjectExist_json(options, "areaWidth"); bool ah = DICTOOL->checkObjectExist_json(options, "areaHeight"); if (aw && ah) { Size size = Size(DICTOOL->getFloatValue_json(options, "areaWidth"),DICTOOL->getFloatValue_json(options,"areaHeight")); label->setTextAreaSize(size); } bool ha = DICTOOL->checkObjectExist_json(options, "hAlignment"); if (ha) { label->setTextHorizontalAlignment((TextHAlignment)DICTOOL->getIntValue_json(options, "hAlignment")); } bool va = DICTOOL->checkObjectExist_json(options, "vAlignment"); if (va) { label->setTextVerticalAlignment((TextVAlignment)DICTOOL->getIntValue_json(options, "vAlignment")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForLabelAtlasFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::TextAtlas* labelAtlas = static_cast(widget); bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); bool ih = DICTOOL->checkObjectExist_json(options, "itemHeight"); bool scm = DICTOOL->checkObjectExist_json(options, "startCharMap"); if (sv && cmf && iw && ih && scm) { const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, "charMapFileData"); int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); switch (cmfType) { case 0: { std::string tp_c = m_strFilePath; const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); const char* cmf_tp = tp_c.append(cmfPath).c_str(); labelAtlas->setProperty(DICTOOL->getStringValue_json(options, "stringValue"),cmf_tp,DICTOOL->getIntValue_json(options, "itemWidth") / CC_CONTENT_SCALE_FACTOR(),DICTOOL->getIntValue_json(options,"itemHeight") / CC_CONTENT_SCALE_FACTOR(), DICTOOL->getStringValue_json(options, "startCharMap")); break; } case 1: CCLOG("Wrong res type of LabelAtlas!"); break; default: break; } } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); Layout* panel = static_cast(widget); if (!dynamic_cast(widget) && !dynamic_cast(widget)) { panel->setClippingEnabled(DICTOOL->getBooleanValue_json(options, "clipAble")); } bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, "backGroundScale9Enable"); panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); int cr = DICTOOL->getIntValue_json(options, "bgColorR"); int cg = DICTOOL->getIntValue_json(options, "bgColorG"); int cb = DICTOOL->getIntValue_json(options, "bgColorB"); int scr = DICTOOL->getIntValue_json(options, "bgStartColorR"); int scg = DICTOOL->getIntValue_json(options, "bgStartColorG"); int scb = DICTOOL->getIntValue_json(options, "bgStartColorB"); int ecr = DICTOOL->getIntValue_json(options, "bgEndColorR"); int ecg = DICTOOL->getIntValue_json(options, "bgEndColorG"); int ecb = DICTOOL->getIntValue_json(options, "bgEndColorB"); float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); int colorType = DICTOOL->getIntValue_json(options, "colorType"); panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); panel->setBackGroundColor(Color3B(cr, cg, cb)); panel->setBackGroundColorOpacity(co); const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); switch (imageFileNameType) { case 0: { std::string tp_b = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; panel->setBackGroundImage(imageFileName_tp); break; } case 1: { const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); break; } default: break; } if (backGroundScale9Enable) { float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); } panel->setLayoutType((LayoutType)DICTOOL->getIntValue_json(options, "layoutType")); setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForScrollViewFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForLayoutFromJsonDictionary(widget, options); cocos2d::gui::ScrollView* scrollView = static_cast(widget); float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); int direction = DICTOOL->getFloatValue_json(options, "direction"); scrollView->setDirection((SCROLLVIEW_DIR)direction); scrollView->setBounceEnabled(DICTOOL->getBooleanValue_json(options, "bounceEnable")); setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::Slider* slider = static_cast(widget); bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable"); slider->setScale9Enabled(barTextureScale9Enable); bool bt = DICTOOL->checkObjectExist_json(options, "barFileName"); float barLength = DICTOOL->getFloatValue_json(options, "length"); if (bt) { if (barTextureScale9Enable) { const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); switch (imageFileType) { case 0: { std::string tp_b = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; slider->loadBarTexture(imageFileName_tp); break; } case 1: { const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); break; } default: break; } slider->setSize(Size(barLength, slider->getContentSize().height)); } else { const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); switch (imageFileType) { case 0: { std::string tp_b = m_strFilePath; const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; slider->loadBarTexture(imageFileName_tp); break; } case 1: { const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); break; } default: break; } } } const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData"); int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); switch (normalType) { case 0: { std::string tp_n = m_strFilePath; const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; slider->loadSlidBallTextureNormal(normalFileName_tp); break; } case 1: { const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); slider->loadSlidBallTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); break; } default: break; } const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData"); int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); switch (pressedType) { case 0: { std::string tp_p = m_strFilePath; const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; slider->loadSlidBallTexturePressed(pressedFileName_tp); break; } case 1: { const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); slider->loadSlidBallTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); break; } default: break; } const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData"); int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); switch (disabledType) { case 0: { std::string tp_d = m_strFilePath; const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; slider->loadSlidBallTextureDisabled(disabledFileName_tp); break; } case 1: { const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); slider->loadSlidBallTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); break; } default: break; } slider->setPercent(DICTOOL->getIntValue_json(options, "percent")); const rapidjson::Value& progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData"); int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType"); switch (progressBarType) { case 0: { std::string tp_b = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; slider->loadProgressBarTexture(imageFileName_tp); break; } case 1: { const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); slider->loadProgressBarTexture(imageFileName,UI_TEX_TYPE_PLIST); break; } default: break; } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForTextFieldFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::TextField* textField = static_cast(widget); bool ph = DICTOOL->checkObjectExist_json(options, "placeHolder"); if (ph) { textField->setPlaceHolder(DICTOOL->getStringValue_json(options, "placeHolder")); } textField->setText(DICTOOL->getStringValue_json(options, "text")); bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); if (fs) { textField->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); } bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); if (fn) { textField->setFontName(DICTOOL->getStringValue_json(options, "fontName")); } bool tsw = DICTOOL->checkObjectExist_json(options, "touchSizeWidth"); bool tsh = DICTOOL->checkObjectExist_json(options, "touchSizeHeight"); if (tsw && tsh) { textField->setTouchSize(Size(DICTOOL->getFloatValue_json(options, "touchSizeWidth"), DICTOOL->getFloatValue_json(options,"touchSizeHeight"))); } float dw = DICTOOL->getFloatValue_json(options, "width"); float dh = DICTOOL->getFloatValue_json(options, "height"); if (dw > 0.0f || dh > 0.0f) { //textField->setSize(Size(dw, dh)); } bool maxLengthEnable = DICTOOL->getBooleanValue_json(options, "maxLengthEnable"); textField->setMaxLengthEnabled(maxLengthEnable); if (maxLengthEnable) { int maxLength = DICTOOL->getIntValue_json(options, "maxLength"); textField->setMaxLength(maxLength); } bool passwordEnable = DICTOOL->getBooleanValue_json(options, "passwordEnable"); textField->setPasswordEnabled(passwordEnable); if (passwordEnable) { textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, "passwordStyleText")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForLoadingBarFromJsonDictionary(Widget *widget, const rapidjson::Value&options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::LoadingBar* loadingBar = static_cast(widget); const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); switch (imageFileNameType) { case 0: { std::string tp_i = m_strFilePath; const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); const char* imageFileName_tp = nullptr; if (imageFileName && (strcmp(imageFileName, "") != 0)) { imageFileName_tp = tp_i.append(imageFileName).c_str(); loadingBar->loadTexture(imageFileName_tp); } break; } case 1: { const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); break; } default: break; } /* gui mark add load bar scale9 parse */ bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); loadingBar->setScale9Enabled(scale9Enable); if (scale9Enable) { float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); loadingBar->setCapInsets(Rect(cx, cy, cw, ch)); float width = DICTOOL->getFloatValue_json(options, "width"); float height = DICTOOL->getFloatValue_json(options, "height"); loadingBar->setSize(Size(width, height)); } /**/ loadingBar->setDirection(LoadingBarType(DICTOOL->getIntValue_json(options, "direction"))); loadingBar->setPercent(DICTOOL->getIntValue_json(options, "percent")); setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForLabelBMFontFromJsonDictionary(Widget *widget, const rapidjson::Value&options) { setPropsForWidgetFromJsonDictionary(widget, options); cocos2d::gui::TextBMFont* labelBMFont = static_cast(widget); const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); switch (cmfType) { case 0: { std::string tp_c = m_strFilePath; const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); const char* cmf_tp = tp_c.append(cmfPath).c_str(); labelBMFont->setFntFile(cmf_tp); break; } case 1: CCLOG("Wrong res type of LabelAtlas!"); break; default: break; } const char* text = DICTOOL->getStringValue_json(options, "text"); labelBMFont->setText(text); setColorPropsForWidgetFromJsonDictionary(widget,options); } void WidgetPropertiesReader0300::setPropsForPageViewFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForLayoutFromJsonDictionary(widget, options); } void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(Widget* widget, const rapidjson::Value& options) { setPropsForLayoutFromJsonDictionary(widget, options); ListView* listView = static_cast(widget); float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); listView->setInnerContainerSize(Size(innerWidth, innerHeight)); int direction = DICTOOL->getFloatValue_json(options, "direction"); listView->setDirection((SCROLLVIEW_DIR)direction); ListViewGravity gravity = (ListViewGravity)DICTOOL->getIntValue_json(options, "gravity"); listView->setGravity(gravity); float itemMargin = DICTOOL->getFloatValue_json(options, "itemMargin"); listView->setItemsMargin(itemMargin); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCSGUIReader.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCSGUIREADER_H__ #define __CCSGUIREADER_H__ #include "gui/UIWidget.h" #include "cocostudio/DictionaryHelper.h" namespace cocostudio { #define kCCSVersion 1.0 class GUIReader : public cocos2d::Object { public: CC_DEPRECATED_ATTRIBUTE static GUIReader* shareReader() { return GUIReader::getInstance(); }; CC_DEPRECATED_ATTRIBUTE static void purgeGUIReader() { GUIReader::destroyInstance(); }; static GUIReader* getInstance(); static void destroyInstance(); cocos2d::gui::Widget* widgetFromJsonFile(const char* fileName); int getVersionInteger(const char* str); /** * @js NA */ void storeFileDesignSize(const char* fileName, const cocos2d::Size &size); /** * @js NA */ const cocos2d::Size getFileDesignSize(const char* fileName) const; protected: GUIReader(); ~GUIReader(); std::string m_strFilePath; cocos2d::ValueMap _fileDesignSizes; }; class WidgetPropertiesReader : public cocos2d::Object { public: virtual cocos2d::gui::Widget* createWidget(const rapidjson::Value& dic, const char* fullPath, const char* fileName)=0; virtual cocos2d::gui::Widget* widgetFromJsonDictionary(const rapidjson::Value& data) = 0; protected: std::string m_strFilePath; }; class WidgetPropertiesReader0250 : public WidgetPropertiesReader { public: WidgetPropertiesReader0250(){}; virtual ~WidgetPropertiesReader0250(){}; virtual cocos2d::gui::Widget* createWidget(const rapidjson::Value& dic, const char* fullPath, const char* fileName); virtual cocos2d::gui::Widget* widgetFromJsonDictionary(const rapidjson::Value& dic); virtual void setPropsForWidgetFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setColorPropsForWidgetFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForButtonFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForCheckBoxFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForImageViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLabelFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLabelAtlasFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLabelBMFontFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLoadingBarFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForSliderFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForTextFieldFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLayoutFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForScrollViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); }; class WidgetPropertiesReader0300 : public WidgetPropertiesReader { public: WidgetPropertiesReader0300(){}; virtual ~WidgetPropertiesReader0300(){}; virtual cocos2d::gui::Widget* createWidget(const rapidjson::Value& dic, const char* fullPath, const char* fileName); virtual cocos2d::gui::Widget* widgetFromJsonDictionary(const rapidjson::Value& dic); virtual void setPropsForWidgetFromJsonDictionary(cocos2d::gui::Widget*,const rapidjson::Value& options); virtual void setColorPropsForWidgetFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForButtonFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForCheckBoxFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForImageViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLabelFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLabelAtlasFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLabelBMFontFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLoadingBarFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForSliderFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForTextFieldFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForLayoutFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForPageViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForScrollViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options); virtual void setPropsForListViewFromJsonDictionary(cocos2d::gui::Widget* widget, const rapidjson::Value& options); }; } #endif /* defined(__CCSGUIReader__) */ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCSSceneReader.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CocoStudio.h" #include "gui/CocosGUI.h" #include "SimpleAudioEngine.h" #include "ObjectFactory.h" using namespace cocos2d; using namespace gui; namespace cocostudio { SceneReader* SceneReader::s_sharedReader = nullptr; SceneReader::SceneReader() : _fnSelector(nullptr) , _node(nullptr) { ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAttribute)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComRender)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAudio)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComController)); } SceneReader::~SceneReader() { } const char* SceneReader::sceneReaderVersion() { return "1.0.0.0"; } cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName) { rapidjson::Document jsonDict; do { CC_BREAK_IF(!readJson(fileName, jsonDict)); _node = createObject(jsonDict, nullptr); TriggerMng::getInstance()->parse(jsonDict); } while (0); return _node; } bool SceneReader::readJson(const std::string &fileName, rapidjson::Document &doc) { bool bRet = false; do { std::string jsonpath = FileUtils::getInstance()->fullPathForFilename(fileName); std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonpath); doc.Parse<0>(contentStr.c_str()); CC_BREAK_IF(doc.HasParseError()); bRet = true; } while (0); return bRet; } Node* SceneReader::nodeByTag(Node *parent, int tag) { if (parent == nullptr) { return nullptr; } Node *_retNode = nullptr; Vector& Children = parent->getChildren(); Vector::iterator iter = Children.begin(); while (iter != Children.end()) { Node* pNode = *iter; if(pNode != nullptr && pNode->getTag() == tag) { _retNode = pNode; break; } else { _retNode = nodeByTag(pNode, tag); if (_retNode != nullptr) { break; } } ++iter; } return _retNode; } Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* parent) { const char *className = DICTOOL->getStringValue_json(dict, "classname"); if(strcmp(className, "CCNode") == 0) { Node* gb = nullptr; if(nullptr == parent) { gb = Node::create(); } else { gb = Node::create(); parent->addChild(gb); } setPropertyFromJsonDict(dict, gb); int count = DICTOOL->getArrayCount_json(dict, "components"); for (int i = 0; i < count; i++) { const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(dict, "components", i); if (!DICTOOL->checkObjectExist_json(subDict)) { break; } const char *comName = DICTOOL->getStringValue_json(subDict, "classname"); Component *com = ObjectFactory::getInstance()->createComponent(comName); if (com != NULL) { if (com->serialize((void*)(&subDict))) { gb->addComponent(com); } else { com = nullptr; } } if(_fnSelector != nullptr) { _fnSelector(com, (void*)(&subDict)); } } int length = DICTOOL->getArrayCount_json(dict, "gameobjects"); for (int i = 0; i < length; ++i) { const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(dict, "gameobjects", i); if (!DICTOOL->checkObjectExist_json(subDict)) { break; } createObject(subDict, gb); } return gb; } return nullptr; } void SceneReader::setTarget(const std::function& selector) { _fnSelector = selector; } Node* SceneReader::getNodeByTag(int nTag) { if (_node == nullptr) { return nullptr; } if (_node->getTag() == nTag) { return _node; } return nodeByTag(_node, nTag); } void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d::Node *node) { float x = DICTOOL->getFloatValue_json(root, "x"); float y = DICTOOL->getFloatValue_json(root, "y"); node->setPosition(Point(x, y)); const bool bVisible = (DICTOOL->getIntValue_json(root, "visible", 1) != 0); node->setVisible(bVisible); int nTag = DICTOOL->getIntValue_json(root, "objecttag", -1); node->setTag(nTag); int nZorder = DICTOOL->getIntValue_json(root, "zorder"); node->setLocalZOrder(nZorder); float fScaleX = DICTOOL->getFloatValue_json(root, "scalex", 1.0); float fScaleY = DICTOOL->getFloatValue_json(root, "scaley", 1.0); node->setScaleX(fScaleX); node->setScaleY(fScaleY); float fRotationZ = DICTOOL->getFloatValue_json(root, "rotation"); node->setRotation(fRotationZ); } SceneReader* SceneReader::getInstance() { if (s_sharedReader == nullptr) { s_sharedReader = new SceneReader(); } return s_sharedReader; } void SceneReader::destroyInstance() { DictionaryHelper::destroyInstance(); TriggerMng::destroyInstance(); CocosDenshion::SimpleAudioEngine::end(); CC_SAFE_DELETE(s_sharedReader); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCSSceneReader.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCSSCENEREADER_H__ #define __CCSSCENEREADER_H__ #include "cocostudio/DictionaryHelper.h" namespace cocostudio { class SceneReader { public: static SceneReader* getInstance(); /** * @js purge * @lua destroySceneReader */ static void destroyInstance(); static const char* sceneReaderVersion(); cocos2d::Node* createNodeWithSceneFile(const std::string &fileName); void setTarget(const std::function& selector); cocos2d::Node* getNodeByTag(int nTag); private: SceneReader(void); virtual ~SceneReader(void); cocos2d::Node* createObject(const rapidjson::Value& dict, cocos2d::Node* parent); void setPropertyFromJsonDict(const rapidjson::Value& dict, cocos2d::Node *node); bool readJson(const std::string &fileName, rapidjson::Document& doc); cocos2d::Node* nodeByTag(cocos2d::Node *parent, int tag); private: static SceneReader* s_sharedReader; std::function _fnSelector; cocos2d::Node* _node; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCSkin.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCSpriteFrame.h" #include "CCSpriteFrameCache.h" #include "CCDirector.h" #include "renderer/CCRenderer.h" #include "cocostudio/CCSkin.h" #include "cocostudio/CCTransformHelp.h" #include "cocostudio/CCSpriteFrameCacheHelper.h" #include "cocostudio/CCArmature.h" using namespace cocos2d; namespace cocostudio { #if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL #define RENDER_IN_SUBPIXEL #else #define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) #endif #define SET_VERTEX3F(_v_, _x_, _y_, _z_) (_v_).x = (_x_); (_v_).y = (_y_); (_v_).z = (_z_); Skin *Skin::create() { Skin *skin = new Skin(); if(skin && skin->init()) { skin->autorelease(); return skin; } CC_SAFE_DELETE(skin); return nullptr; } Skin *Skin::createWithSpriteFrameName(const std::string& pszSpriteFrameName) { Skin *skin = new Skin(); if(skin && skin->initWithSpriteFrameName(pszSpriteFrameName)) { skin->autorelease(); return skin; } CC_SAFE_DELETE(skin); return nullptr; } Skin *Skin::create(const std::string& pszFileName) { Skin *skin = new Skin(); if(skin && skin->initWithFile(pszFileName)) { skin->autorelease(); return skin; } CC_SAFE_DELETE(skin); return nullptr; } Skin::Skin() : _bone(nullptr) , _armature(nullptr) , _displayName("") { kmMat4Identity(&_skinTransform); } bool Skin::initWithSpriteFrameName(const std::string& spriteFrameName) { CCAssert(spriteFrameName != "", ""); SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); bool ret = true; if (pFrame != nullptr) { ret = initWithSpriteFrame(pFrame); } else { CCLOG("Cann't find CCSpriteFrame with %s. Please check your .plist file", spriteFrameName.c_str()); ret = false; } _displayName = spriteFrameName; return ret; } bool Skin::initWithFile(const std::string& filename) { bool ret = Sprite::initWithFile(filename); _displayName = filename; return ret; } void Skin::setSkinData(const BaseData &var) { _skinData = var; setScaleX(_skinData.scaleX); setScaleY(_skinData.scaleY); setRotationX(CC_RADIANS_TO_DEGREES(_skinData.skewX)); setRotationY(CC_RADIANS_TO_DEGREES(-_skinData.skewY)); setPosition(Point(_skinData.x, _skinData.y)); _skinTransform = getNodeToParentTransform(); updateArmatureTransform(); } const BaseData &Skin::getSkinData() const { return _skinData; } void Skin::updateArmatureTransform() { _transform = TransformConcat(_bone->getNodeToArmatureTransform(), _skinTransform); // if(_armature && _armature->getBatchNode()) // { // _transform = TransformConcat(_transform, _armature->getNodeToParentTransform()); // } } void Skin::updateTransform() { // If it is not visible, or one of its ancestors is not visible, then do nothing: if( !_visible) { _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vertex3F(0, 0, 0); } else { // // calculate the Quad based on the Affine Matrix // Size &size = _rect.size; float x1 = _offsetPosition.x; float y1 = _offsetPosition.y; float x2 = x1 + size.width; float y2 = y1 + size.height; float x = _transform.mat[12]; float y = _transform.mat[13]; float cr = _transform.mat[0]; float sr = _transform.mat[1]; float cr2 = _transform.mat[5]; float sr2 = -_transform.mat[4]; float ax = x1 * cr - y1 * sr2 + x; float ay = x1 * sr + y1 * cr2 + y; float bx = x2 * cr - y1 * sr2 + x; float by = x2 * sr + y1 * cr2 + y; float cx = x2 * cr - y2 * sr2 + x; float cy = x2 * sr + y2 * cr2 + y; float dx = x1 * cr - y2 * sr2 + x; float dy = x1 * sr + y2 * cr2 + y; SET_VERTEX3F( _quad.bl.vertices, RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ ); SET_VERTEX3F( _quad.br.vertices, RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ ); SET_VERTEX3F( _quad.tl.vertices, RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ ); SET_VERTEX3F( _quad.tr.vertices, RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ ); } // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS if (_textureAtlas) { _textureAtlas->updateQuad(&_quad, _textureAtlas->getTotalQuads()); } } kmMat4 Skin::getNodeToWorldTransform() const { return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(), _transform); } kmMat4 Skin::getNodeToWorldTransformAR() const { kmMat4 displayTransform = _transform; Point anchorPoint = _anchorPointInPoints; anchorPoint = PointApplyTransform(anchorPoint, displayTransform); displayTransform.mat[12] = anchorPoint.x; displayTransform.mat[13] = anchorPoint.y; return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(),displayTransform); } void Skin::draw() { kmMat4 mv; kmGLGetMatrix(KM_GL_MODELVIEW, &mv); //TODO implement z order _quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } void Skin::setBone(Bone *bone) { _bone = bone; if(Armature *armature = _bone->getArmature()) { _armature = armature; } } Bone *Skin::getBone() const { return _bone; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCSkin.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCSKIN_H__ #define __CCSKIN_H__ #include "CCSprite.h" #include "renderer/CCQuadCommand.h" #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCBone.h" namespace cocostudio { class Skin : public cocos2d::Sprite { public: static Skin *create(); static Skin *createWithSpriteFrameName(const std::string& pszSpriteFrameName); static Skin *create(const std::string& pszFileName); public: /** * @js ctor */ Skin(); virtual bool initWithSpriteFrameName(const std::string& spriteFrameName) override; virtual bool initWithFile(const std::string& filename) override; void updateArmatureTransform(); void updateTransform() override; kmMat4 getNodeToWorldTransform() const override; kmMat4 getNodeToWorldTransformAR() const; virtual void draw() override; /** * @js NA * @lua NA */ virtual void setSkinData(const BaseData &data); /** * @js NA * @lua NA */ virtual const BaseData &getSkinData() const; virtual void setBone(Bone *bone); virtual Bone *getBone() const; virtual const std::string &getDisplayName() const { return _displayName; } protected: BaseData _skinData; Bone *_bone; Armature *_armature; kmMat4 _skinTransform; std::string _displayName; cocos2d::QuadCommand _quadCommand; // quad command }; } #endif /*__CCSKIN_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCSpriteFrameCacheHelper.h" #include "CCSpriteFrameCache.h" using namespace cocos2d; namespace cocostudio { SpriteFrameCacheHelper *SpriteFrameCacheHelper::_spriteFrameCacheHelper = nullptr; SpriteFrameCacheHelper *SpriteFrameCacheHelper::getInstance() { if(!_spriteFrameCacheHelper) { _spriteFrameCacheHelper = new SpriteFrameCacheHelper(); } return _spriteFrameCacheHelper; } void SpriteFrameCacheHelper::purge() { delete _spriteFrameCacheHelper; _spriteFrameCacheHelper = nullptr; } void SpriteFrameCacheHelper::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath) { SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath, imagePath); } SpriteFrameCacheHelper::SpriteFrameCacheHelper() { } SpriteFrameCacheHelper::~SpriteFrameCacheHelper() { } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCSPRITEFRAMECACHEHELPER_H__ #define __CCSPRITEFRAMECACHEHELPER_H__ #include "CCPlatformMacros.h" #include "cocostudio/CCArmatureDefine.h" #include #include namespace cocostudio { /** * @js NA * @lua NA */ class SpriteFrameCacheHelper { public: /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static SpriteFrameCacheHelper *sharedSpriteFrameCacheHelper(){ return SpriteFrameCacheHelper::getInstance(); } static SpriteFrameCacheHelper *getInstance(); static void purge(); public: /** * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name */ void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath); private: SpriteFrameCacheHelper(); ~SpriteFrameCacheHelper(); static SpriteFrameCacheHelper *_spriteFrameCacheHelper; }; } #endif /*__CCSPRITEFRAMECACHEHELPER_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCTransformHelp.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCTransformHelp.h" #include "cocostudio/CCUtilMath.h" using namespace cocos2d; namespace cocostudio { AffineTransform TransformHelp::helpMatrix1; AffineTransform TransformHelp::helpMatrix2; Point TransformHelp::helpPoint1; Point TransformHelp::helpPoint2; BaseData helpParentNode; TransformHelp::TransformHelp() { } void TransformHelp::transformFromParent(BaseData &node, const BaseData &parentNode) { nodeToMatrix(node, helpMatrix1); nodeToMatrix(parentNode, helpMatrix2); helpMatrix2 = AffineTransformInvert(helpMatrix2); helpMatrix1 = AffineTransformConcat(helpMatrix1, helpMatrix2); matrixToNode(helpMatrix1, node); } void TransformHelp::transformToParent(BaseData &node, const BaseData &parentNode) { nodeToMatrix(node, helpMatrix1); nodeToMatrix(parentNode, helpMatrix2); helpMatrix1 = AffineTransformConcat(helpMatrix1, helpMatrix2); matrixToNode(helpMatrix1, node); } void TransformHelp::transformFromParentWithoutScale(BaseData &node, const BaseData &parentNode) { helpParentNode.copy(&parentNode); helpParentNode.scaleX = 1; helpParentNode.scaleY = 1; nodeToMatrix(node, helpMatrix1); nodeToMatrix(helpParentNode, helpMatrix2); helpMatrix2 = AffineTransformInvert(helpMatrix2); helpMatrix1 = AffineTransformConcat(helpMatrix1, helpMatrix2); matrixToNode(helpMatrix1, node); } void TransformHelp::transformToParentWithoutScale(BaseData &node, const BaseData &parentNode) { helpParentNode.copy(&parentNode); helpParentNode.scaleX = 1; helpParentNode.scaleY = 1; nodeToMatrix(node, helpMatrix1); nodeToMatrix(helpParentNode, helpMatrix2); helpMatrix1 = AffineTransformConcat(helpMatrix1, helpMatrix2); matrixToNode(helpMatrix1, node); } void TransformHelp::nodeToMatrix(const BaseData &node, AffineTransform &matrix) { if (node.skewX == -node.skewY) { double sine = sin(node.skewX); double cosine = cos(node.skewX); matrix.a = node.scaleX * cosine; matrix.b = node.scaleX * -sine; matrix.c = node.scaleY * sine; matrix.d = node.scaleY * cosine; } else { matrix.a = node.scaleX * cos(node.skewY); matrix.b = node.scaleX * sin(node.skewY); matrix.c = node.scaleY * sin(node.skewX); matrix.d = node.scaleY * cos(node.skewX); } matrix.tx = node.x; matrix.ty = node.y; } void TransformHelp::nodeToMatrix(const BaseData &node, kmMat4 &matrix) { kmMat4Identity(&matrix); if (node.skewX == -node.skewY) { double sine = sin(node.skewX); double cosine = cos(node.skewX); matrix.mat[0] = node.scaleX * cosine; matrix.mat[1] = node.scaleX * -sine; matrix.mat[4] = node.scaleY * sine; matrix.mat[5] = node.scaleY * cosine; } else { matrix.mat[0] = node.scaleX * cos(node.skewY); matrix.mat[1] = node.scaleX * sin(node.skewY); matrix.mat[4] = node.scaleY * sin(node.skewX); matrix.mat[5] = node.scaleY * cos(node.skewX); } matrix.mat[12] = node.x; matrix.mat[13] = node.y; } void TransformHelp::matrixToNode(const AffineTransform &matrix, BaseData &node) { /* * In as3 language, there is a function called "deltaTransformPoint", it calculate a point used give Transform * but not used the tx, ty value. we simulate the function here */ helpPoint1.x = 0; helpPoint1.y = 1; helpPoint1 = PointApplyAffineTransform(helpPoint1, matrix); helpPoint1.x -= matrix.tx; helpPoint1.y -= matrix.ty; helpPoint2.x = 1; helpPoint2.y = 0; helpPoint2 = PointApplyAffineTransform(helpPoint2, matrix); helpPoint2.x -= matrix.tx; helpPoint2.y -= matrix.ty; node.skewX = -(atan2f(helpPoint1.y, helpPoint1.x) - 1.5707964f); node.skewY = atan2f(helpPoint2.y, helpPoint2.x); node.scaleX = sqrt(matrix.a * matrix.a + matrix.b * matrix.b); node.scaleY = sqrt(matrix.c * matrix.c + matrix.d * matrix.d); node.x = matrix.tx; node.y = matrix.ty; } void TransformHelp::matrixToNode(const kmMat4 &matrix, BaseData &node) { /* * In as3 language, there is a function called "deltaTransformPoint", it calculate a point used give Transform * but not used the tx, ty value. we simulate the function here */ helpPoint1.x = 0; helpPoint1.y = 1; helpPoint1 = PointApplyTransform(helpPoint1, matrix); helpPoint1.x -= matrix.mat[12]; helpPoint1.y -= matrix.mat[13]; helpPoint2.x = 1; helpPoint2.y = 0; helpPoint2 = PointApplyTransform(helpPoint2, matrix); helpPoint2.x -= matrix.mat[12]; helpPoint2.y -= matrix.mat[13]; node.skewX = -(atan2f(helpPoint1.y, helpPoint1.x) - 1.5707964f); node.skewY = atan2f(helpPoint2.y, helpPoint2.x); node.scaleX = sqrt(matrix.mat[0] * matrix.mat[0] + matrix.mat[1] * matrix.mat[1]); node.scaleY = sqrt(matrix.mat[4] * matrix.mat[4] + matrix.mat[5] * matrix.mat[5]); node.x = matrix.mat[12]; node.y = matrix.mat[13]; } void TransformHelp::nodeConcat(BaseData &target, BaseData &source) { target.x += source.x; target.y += source.y; target.skewX += source.skewX; target.skewY += source.skewY; target.scaleX += source.scaleX; target.scaleY += source.scaleY; } void TransformHelp::nodeSub(BaseData &target, BaseData &source) { target.x -= source.x; target.y -= source.y; target.skewX -= source.skewX; target.skewY -= source.skewY; target.scaleX -= source.scaleX; target.scaleY -= source.scaleY; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCTransformHelp.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTRANSFORMHELP_H__ #define __CCTRANSFORMHELP_H__ #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDatas.h" namespace cocostudio { /* * use to calculate the matrix of node from parent node * @js NA * @lua NA */ class TransformHelp { public: TransformHelp(); static void transformFromParent(BaseData &node, const BaseData &parentNode); static void transformToParent(BaseData &node, const BaseData &parentNode); static void transformFromParentWithoutScale(BaseData &node, const BaseData &parentNode); static void transformToParentWithoutScale(BaseData &node, const BaseData &parentNode); static void nodeToMatrix(const BaseData &_node, cocos2d::AffineTransform &_matrix); static void nodeToMatrix(const BaseData &node, kmMat4 &matrix); static void matrixToNode(const cocos2d::AffineTransform &_matrix, BaseData &_node); static void matrixToNode(const kmMat4 &_matrix, BaseData &_node); static void nodeConcat(BaseData &target, BaseData &source); static void nodeSub(BaseData &target, BaseData &source); public: static cocos2d::AffineTransform helpMatrix1; static cocos2d::AffineTransform helpMatrix2; static cocos2d::Point helpPoint1; static cocos2d::Point helpPoint2; }; } #endif /*__CCTRANSFORMHELP_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCTween.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCTween.h" #include "cocostudio/CCArmatureAnimation.h" #include "cocostudio/CCBone.h" #include "cocostudio/CCArmature.h" #include "cocostudio/CCUtilMath.h" #include "cocostudio/CCTweenFunction.h" #include "cocostudio/CCTransformHelp.h" namespace cocostudio { Tween *Tween::create(Bone *bone) { Tween *pTween = new Tween(); if (pTween && pTween->init(bone)) { pTween->autorelease(); return pTween; } CC_SAFE_DELETE(pTween); return nullptr; } Tween::Tween() : _movementBoneData(nullptr) , _tweenData(nullptr) , _from(nullptr) , _to(nullptr) , _between(nullptr) , _bone(nullptr) , _frameTweenEasing(Linear) , _fromIndex(0) , _toIndex(0) , _animation(nullptr) , _passLastFrame(false) { } Tween::~Tween(void) { CC_SAFE_DELETE( _from ); CC_SAFE_DELETE( _between ); } bool Tween::init(Bone *bone) { bool bRet = false; do { _from = new FrameData(); _between = new FrameData(); _bone = bone; _tweenData = _bone->getTweenData(); _tweenData->displayIndex = -1; _animation = _bone->getArmature() != nullptr ? _bone->getArmature()->getAnimation() : nullptr; bRet = true; } while (0); return bRet; } void Tween::play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing) { ProcessBase::play(durationTo, durationTween, loop, tweenEasing); if (loop) { _loopType = ANIMATION_TO_LOOP_FRONT; } else { _loopType = ANIMATION_NO_LOOP; } _totalDuration = 0; _betweenDuration = 0; _fromIndex = _toIndex = 0; bool difMovement = movementBoneData != _movementBoneData; setMovementBoneData(movementBoneData); _rawDuration = _movementBoneData->duration; FrameData *nextKeyFrame = _movementBoneData->getFrameData(0); _tweenData->displayIndex = nextKeyFrame->displayIndex; if (_bone->getArmature()->getArmatureData()->dataVersion >= VERSION_COMBINED) { TransformHelp::nodeSub(*_tweenData, *_bone->getBoneData()); _tweenData->scaleX += 1; _tweenData->scaleY += 1; } if (_rawDuration == 0 ) { _loopType = SINGLE_FRAME; if(durationTo == 0) { setBetween(nextKeyFrame, nextKeyFrame); } else { setBetween(_tweenData, nextKeyFrame); } _frameTweenEasing = Linear; } else if (_movementBoneData->frameList.size() > 1) { _durationTween = durationTween * _movementBoneData->scale; if (loop && _movementBoneData->delay != 0) { setBetween(_tweenData, tweenNodeTo(updateFrameData(1 - _movementBoneData->delay), _between)); } else { if (!difMovement || durationTo == 0) { setBetween(nextKeyFrame, nextKeyFrame); } else { setBetween(_tweenData, nextKeyFrame); } } } tweenNodeTo(0); } void Tween::gotoAndPlay(int frameIndex) { ProcessBase::gotoFrame(frameIndex); _totalDuration = 0; _betweenDuration = 0; _fromIndex = _toIndex = 0; _isPlaying = true; _isComplete = _isPause = false; _currentPercent = (float)_curFrameIndex / ((float)_rawDuration-1); _currentFrame = _nextFrameIndex * _currentPercent; } void Tween::gotoAndPause(int frameIndex) { gotoAndPlay(frameIndex); pause(); } void Tween::updateHandler() { if (_currentPercent >= 1) { switch(_loopType) { case SINGLE_FRAME: { _currentPercent = 1; _isComplete = true; _isPlaying = false; } break; case ANIMATION_NO_LOOP: { _loopType = ANIMATION_MAX; if (_durationTween <= 0) { _currentPercent = 1; } else { _currentPercent = (_currentPercent - 1) * _nextFrameIndex / _durationTween; } if (_currentPercent >= 1) { _currentPercent = 1; _isComplete = true; _isPlaying = false; break; } else { _nextFrameIndex = _durationTween; _currentFrame = _currentPercent * _nextFrameIndex; _totalDuration = 0; _betweenDuration = 0; _fromIndex = _toIndex = 0; break; } } break; case ANIMATION_TO_LOOP_FRONT: { _loopType = ANIMATION_LOOP_FRONT; _nextFrameIndex = _durationTween > 0 ? _durationTween : 1; if (_movementBoneData->delay != 0) { // _currentFrame = (1 - _movementBoneData->delay) * (float)_nextFrameIndex; _currentPercent = _currentFrame / _nextFrameIndex; } else { _currentPercent = 0; _currentFrame = 0; } _totalDuration = 0; _betweenDuration = 0; _fromIndex = _toIndex = 0; } break; case ANIMATION_MAX: { _currentPercent = 1; _isComplete = true; _isPlaying = false; } break; default: { _currentFrame = fmodf(_currentFrame, _nextFrameIndex); } break; } } if (_currentPercent < 1 && _loopType <= ANIMATION_TO_LOOP_BACK) { _currentPercent = sin(_currentPercent * CC_HALF_PI); } float percent = _currentPercent; if (_loopType > ANIMATION_TO_LOOP_BACK) { percent = updateFrameData(percent); } if(_frameTweenEasing != TWEEN_EASING_MAX) { tweenNodeTo(percent); } } void Tween::setBetween(FrameData *from, FrameData *to, bool limit) { do { if(from->displayIndex < 0 && to->displayIndex >= 0) { _from->copy(to); _between->subtract(to, to, limit); break; } else if(to->displayIndex < 0 && from->displayIndex >= 0) { _from->copy(from); _between->subtract(to, to, limit); break; } _from->copy(from); _between->subtract(from, to, limit); } while (0); if (!from->isTween) { _tweenData->copy(from); _tweenData->isTween = true; } arriveKeyFrame(from); } void Tween::arriveKeyFrame(FrameData *keyFrameData) { if(keyFrameData) { DisplayManager *displayManager = _bone->getDisplayManager(); //! Change bone's display int displayIndex = keyFrameData->displayIndex; if (!displayManager->isForceChangeDisplay()) { displayManager->changeDisplayWithIndex(displayIndex, false); } //! Update bone zorder, bone's zorder is determined by frame zorder and bone zorder _tweenData->zOrder = keyFrameData->zOrder; _bone->updateZOrder(); //! Update blend type _bone->setBlendFunc(keyFrameData->blendFunc); //! Update child armature's movement Armature *childAramture = _bone->getChildArmature(); if(childAramture) { if(keyFrameData->strMovement.length() != 0) { childAramture->getAnimation()->play(keyFrameData->strMovement.c_str()); } } } } FrameData *Tween::tweenNodeTo(float percent, FrameData *node) { node = node == nullptr ? _tweenData : node; if (!_from->isTween) { percent = 0; } node->x = _from->x + percent * _between->x; node->y = _from->y + percent * _between->y; node->scaleX = _from->scaleX + percent * _between->scaleX; node->scaleY = _from->scaleY + percent * _between->scaleY; node->skewX = _from->skewX + percent * _between->skewX; node->skewY = _from->skewY + percent * _between->skewY; _bone->setTransformDirty(true); if (node && _between->isUseColorInfo) { tweenColorTo(percent, node); } return node; } void Tween::tweenColorTo(float percent, FrameData *node) { node->a = _from->a + percent * _between->a; node->r = _from->r + percent * _between->r; node->g = _from->g + percent * _between->g; node->b = _from->b + percent * _between->b; _bone->updateColor(); } float Tween::updateFrameData(float currentPercent) { if (currentPercent > 1 && _movementBoneData->delay != 0) { currentPercent = fmodf(currentPercent, 1); } float playedTime = ((float)_rawDuration-1) * currentPercent; //! If play to current frame's front or back, then find current frame again if (playedTime < _totalDuration || playedTime >= _totalDuration + _betweenDuration) { /* * Get frame length, if _toIndex >= _length, then set _toIndex to 0, start anew. * _toIndex is next index will play */ long length = _movementBoneData->frameList.size(); cocos2d::Vector &frames = _movementBoneData->frameList; FrameData *from = nullptr; FrameData *to = nullptr; if (playedTime < frames.at(0)->frameID) { from = to = frames.at(0); setBetween(from, to); return _currentPercent; } if(playedTime >= frames.at(length - 1)->frameID) { // If _passLastFrame is true and playedTime >= frames[length - 1]->frameID, then do not need to go on. if (_passLastFrame) { from = to = frames.at(length - 1); setBetween(from, to); return _currentPercent; } _passLastFrame = true; } else { _passLastFrame = false; } do { _fromIndex = _toIndex; from = frames.at(_fromIndex); _totalDuration = from->frameID; _toIndex = _fromIndex + 1; if (_toIndex >= length) { _toIndex = 0; } to = frames.at(_toIndex); //! Guaranteed to trigger frame event if(from->strEvent.length() != 0 && !_animation->isIgnoreFrameEvent()) { _animation->frameEvent(_bone, from->strEvent.c_str(), from->frameID, playedTime); } if (playedTime == from->frameID || (_passLastFrame && _fromIndex == length-1)) { break; } } while (playedTime < from->frameID || playedTime >= to->frameID); _betweenDuration = to->frameID - from->frameID; _frameTweenEasing = from->tweenEasing; setBetween(from, to, false); } currentPercent = _betweenDuration == 0 ? 0 : (playedTime - _totalDuration) / (float)_betweenDuration; /* * If frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween. */ TweenType tweenType = (_frameTweenEasing != Linear) ? _frameTweenEasing : _tweenEasing; if (tweenType != TWEEN_EASING_MAX && tweenType != Linear && !_passLastFrame) { currentPercent = TweenFunction::tweenTo(currentPercent, tweenType, _from->easingParams); } return currentPercent; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCTween.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTWEEN_H__ #define __CCTWEEN_H__ #include "cocostudio/CCProcessBase.h" #include "cocostudio/CCTweenFunction.h" namespace cocostudio { class Bone; class ArmatureAnimation; /** * @js NA * @lua NA */ class Tween : public ProcessBase { public: /** * Create with a Bone * @param bone the Bone Tween will bind to */ static Tween *create(Bone *bone); public: Tween(void); virtual ~Tween(void); /** * Init with a Bone * @param bone the Bone Tween will bind to */ virtual bool init(Bone *bone); using ProcessBase::play; /** * Start the Process * * @param movementBoneData the MovementBoneData include all FrameData * @param durationTo the number of frames changing to this animation needs. * @param durationTween the number of frames this animation actual last. * * @param loop whether the animation is loop * * loop < 0 : use the value from MovementData get from Action Editor * loop = 0 : this animation is not loop * loop > 0 : this animation is loop * * @param tweenEasing tween easing is used for calculate easing effect * * TWEEN_EASING_MAX : use the value from MovementData get from Action Editor * -1 : fade out * 0 : line * 1 : fade in * 2 : fade in and out * */ virtual void play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing); inline void setAnimation(ArmatureAnimation *animation) { _animation = animation; } inline ArmatureAnimation *getAnimation() const { return _animation; } virtual void gotoAndPlay(int frameIndex); virtual void gotoAndPause(int frameIndex); virtual void setMovementBoneData(MovementBoneData *data) { _movementBoneData = data; } virtual const MovementBoneData *getMovementBoneData() const { return _movementBoneData; } protected: /** * Update(float dt) will call this handler, you can handle your logic here */ virtual void updateHandler(); /** * Calculate which frame arrived, and if current frame have event, then call the event listener */ virtual float updateFrameData(float currentPercent); /** * Calculate the between value of _from and _to, and give it to between frame data */ virtual void setBetween(FrameData *from, FrameData *to, bool limit = true); /** * According to the percent to calculate current FrameData with tween effect */ virtual FrameData *tweenNodeTo(float percent, FrameData *node = nullptr); /** * According to the percent to calculate current color with tween effect */ virtual void tweenColorTo(float percent, FrameData *node); /** * Update display index and process the key frame event when arrived a key frame */ virtual void arriveKeyFrame(FrameData *keyFrameData); protected: //! A weak reference to the current MovementBoneData. The data is in the data pool MovementBoneData *_movementBoneData; FrameData *_tweenData; //! The computational tween frame data, //! A weak reference to the Bone's tweenData FrameData *_from; //! From frame data, used for calculate between value FrameData *_to; //! To frame data, used for calculate between value FrameData *_between; //! Between frame data, used for calculate current FrameData(m_pNode) value Bone *_bone; //! A weak reference to the Bone TweenType _frameTweenEasing; //! Dedermine which tween effect current frame use int _betweenDuration; //! Current key frame will last _betweenDuration frames int _totalDuration; int _fromIndex; //! The current frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex int _toIndex; //! The next frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex ArmatureAnimation *_animation; bool _passLastFrame; //! If current frame index is more than the last frame's index }; } #endif /*__CCTWEEN_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCTweenFunction.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCTweenFunction.h" #include "cocostudio/CCUtilMath.h" #ifndef M_PI_X_2 #define M_PI_X_2 (float)M_PI * 2.0f #endif namespace cocostudio { float TweenFunction::tweenTo(float time, TweenType type, float *easingParam) { float delta = 0; switch (type) { case CUSTOM_EASING: delta = customEase(time, easingParam); break; case Linear: delta = linear(time); break; case Sine_EaseIn: delta = sineEaseIn(time); break; case Sine_EaseOut: delta = sineEaseOut(time); break; case Sine_EaseInOut: delta = sineEaseInOut(time); break; case Quad_EaseIn: delta = quadEaseIn(time); break; case Quad_EaseOut: delta = quadEaseOut(time); break; case Quad_EaseInOut: delta = quadEaseInOut(time); break; case Cubic_EaseIn: delta = cubicEaseIn(time); break; case Cubic_EaseOut: delta = cubicEaseOut(time); break; case Cubic_EaseInOut: delta = cubicEaseInOut(time); break; case Quart_EaseIn: delta = quartEaseIn(time); break; case Quart_EaseOut: delta = quartEaseOut(time); break; case Quart_EaseInOut: delta = quartEaseInOut(time); break; case Quint_EaseIn: delta = quintEaseIn(time); break; case Quint_EaseOut: delta = quintEaseOut(time); break; case Quint_EaseInOut: delta = quintEaseInOut(time); break; case Expo_EaseIn: delta = expoEaseIn(time); break; case Expo_EaseOut: delta = expoEaseOut(time); break; case Expo_EaseInOut: delta = expoEaseInOut(time); break; case Circ_EaseIn: delta = circEaseIn(time); break; case Circ_EaseOut: delta = circEaseOut(time); break; case Circ_EaseInOut: delta = circEaseInOut(time); break; case Elastic_EaseIn: delta = elasticEaseIn(time, easingParam); break; case Elastic_EaseOut: delta = elasticEaseOut(time, easingParam); break; case Elastic_EaseInOut: delta = elasticEaseInOut(time, easingParam); break; case Back_EaseIn: delta = backEaseIn(time); break; case Back_EaseOut: delta = backEaseOut(time); break; case Back_EaseInOut: delta = backEaseInOut(time); break; case Bounce_EaseIn: delta = bounceEaseIn(time); break; case Bounce_EaseOut: delta = bounceEaseOut(time); break; case Bounce_EaseInOut: delta = bounceEaseInOut(time); break; default: delta = sineEaseInOut(time); break; } return delta; } // Linear float TweenFunction::linear(float time) { return time; } // Sine Ease float TweenFunction::sineEaseIn(float time) { return -1 * cosf(time * (float)M_PI_2) + 1; } float TweenFunction::sineEaseOut(float time) { return sinf(time * (float)M_PI_2); } float TweenFunction::sineEaseInOut(float time) { return -0.5f * (cosf((float)M_PI * time) - 1); } // Quad Ease float TweenFunction::quadEaseIn(float time) { return time * time; } float TweenFunction::quadEaseOut(float time) { return -1 * time * (time - 2); } float TweenFunction::quadEaseInOut(float time) { time = time*2; if (time < 1) return 0.5f * time * time; --time; return -0.5f * (time * (time - 2) - 1); } // Cubic Ease float TweenFunction::cubicEaseIn(float time) { return time * time * time; } float TweenFunction::cubicEaseOut(float time) { time -= 1; return (time * time * time + 1); } float TweenFunction::cubicEaseInOut(float time) { time = time*2; if (time < 1) return 0.5f * time * time * time; time -= 2; return 0.5f * (time * time * time + 2); } // Quart Ease float TweenFunction::quartEaseIn(float time) { return time * time * time * time; } float TweenFunction::quartEaseOut(float time) { time -= 1; return -(time * time * time * time - 1); } float TweenFunction::quartEaseInOut(float time) { time = time*2; if (time < 1) return 0.5f * time * time * time * time; time -= 2; return -0.5f * (time * time * time * time - 2); } // Quint Ease float TweenFunction::quintEaseIn(float time) { return time * time * time * time * time; } float TweenFunction::quintEaseOut(float time) { time -=1; return (time * time * time * time * time + 1); } float TweenFunction::quintEaseInOut(float time) { time = time*2; if (time < 1) return 0.5f * time * time * time * time * time; time -= 2; return 0.5f * (time * time * time * time * time + 2); } // Expo Ease float TweenFunction::expoEaseIn(float time) { return time == 0 ? 0 : powf(2, 10 * (time/1 - 1)) - 1 * 0.001f; } float TweenFunction::expoEaseOut(float time) { return time == 1 ? 1 : (-powf(2, -10 * time / 1) + 1); } float TweenFunction::expoEaseInOut(float time) { time /= 0.5f; if (time < 1) { time = 0.5f * powf(2, 10 * (time - 1)); } else { time = 0.5f * (-powf(2, -10 * (time - 1)) + 2); } return time; } // Circ Ease float TweenFunction::circEaseIn(float time) { return -1 * (sqrt(1 - time * time) - 1); } float TweenFunction::circEaseOut(float time) { time = time - 1; return sqrt(1 - time * time); } float TweenFunction::circEaseInOut(float time) { time = time * 2; if (time < 1) return -0.5f * (sqrt(1 - time * time) - 1); time -= 2; return 0.5f * (sqrt(1 - time * time) + 1); } // Elastic Ease float TweenFunction::elasticEaseIn(float time, float *easingParam) { float period = 0.3f; if (easingParam != NULL) { period = easingParam[0]; } float newT = 0; if (time == 0 || time == 1) { newT = time; } else { float s = period / 4; time = time - 1; newT = -powf(2, 10 * time) * sinf((time - s) * M_PI_X_2 / period); } return newT; } float TweenFunction::elasticEaseOut(float time, float *easingParam) { float period = 0.3f; if (easingParam != NULL) { period = easingParam[0]; } float newT = 0; if (time == 0 || time == 1) { newT = time; } else { float s = period / 4; newT = powf(2, -10 * time) * sinf((time - s) * M_PI_X_2 / period) + 1; } return newT; } float TweenFunction::elasticEaseInOut(float time, float *easingParam) { float period = 0.3f; if (easingParam != NULL) { period = easingParam[0]; } float newT = 0; if (time == 0 || time == 1) { newT = time; } else { time = time * 2; if (! period) { period = 0.3f * 1.5f; } float s = period / 4; time = time - 1; if (time < 0) { newT = -0.5f * powf(2, 10 * time) * sinf((time -s) * M_PI_X_2 / period); } else { newT = powf(2, -10 * time) * sinf((time - s) * M_PI_X_2 / period) * 0.5f + 1; } } return newT; } // Back Ease float TweenFunction::backEaseIn(float time) { float overshoot = 1.70158f; return time * time * ((overshoot + 1) * time - overshoot); } float TweenFunction::backEaseOut(float time) { float overshoot = 1.70158f; time = time - 1; return time * time * ((overshoot + 1) * time + overshoot) + 1; } float TweenFunction::backEaseInOut(float time) { float overshoot = 1.70158f * 1.525f; time = time * 2; if (time < 1) { return (time * time * ((overshoot + 1) * time - overshoot)) / 2; } else { time = time - 2; return (time * time * ((overshoot + 1) * time + overshoot)) / 2 + 1; } } // Bounce Ease float bounceTime(float time) { if (time < 1 / 2.75) { return 7.5625f * time * time; } else if (time < 2 / 2.75) { time -= 1.5f / 2.75f; return 7.5625f * time * time + 0.75f; } else if(time < 2.5 / 2.75) { time -= 2.25f / 2.75f; return 7.5625f * time * time + 0.9375f; } time -= 2.625f / 2.75f; return 7.5625f * time * time + 0.984375f; } float TweenFunction::bounceEaseIn(float time) { return 1 - bounceTime(1 - time); } float TweenFunction::bounceEaseOut(float time) { return bounceTime(time); } float TweenFunction::bounceEaseInOut(float time) { float newT = 0; if (time < 0.5f) { time = time * 2; newT = (1 - bounceTime(1 - time)) * 0.5f; } else { newT = bounceTime(time * 2 - 1) * 0.5f + 0.5f; } return newT; } // Custom Ease float TweenFunction::customEase(float time, float *easingParam) { if (easingParam) { float tt = 1-time; return easingParam[1]*tt*tt*tt + 3*easingParam[3]*time*tt*tt + 3*easingParam[5]*time*time*tt + easingParam[7]*time*time*time; } return time; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCTweenFunction.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCTWEENFUNCTION_H__ #define __CCTWEENFUNCTION_H__ #include "cocostudio/CCArmatureDefine.h" #include namespace cocostudio { enum TweenType { CUSTOM_EASING = -1, Linear, Sine_EaseIn, Sine_EaseOut, Sine_EaseInOut, Quad_EaseIn, Quad_EaseOut, Quad_EaseInOut, Cubic_EaseIn, Cubic_EaseOut, Cubic_EaseInOut, Quart_EaseIn, Quart_EaseOut, Quart_EaseInOut, Quint_EaseIn, Quint_EaseOut, Quint_EaseInOut, Expo_EaseIn, Expo_EaseOut, Expo_EaseInOut, Circ_EaseIn, Circ_EaseOut, Circ_EaseInOut, Elastic_EaseIn, Elastic_EaseOut, Elastic_EaseInOut, Back_EaseIn, Back_EaseOut, Back_EaseInOut, Bounce_EaseIn, Bounce_EaseOut, Bounce_EaseInOut, TWEEN_EASING_MAX = 10000 }; /** * @js NA * @lua NA */ class TweenFunction { public: static float tweenTo(float time, TweenType type, float *easingParam); static float linear(float time); static float sineEaseIn(float time); static float sineEaseOut(float time); static float sineEaseInOut(float time); static float quadEaseIn(float time); static float quadEaseOut(float time); static float quadEaseInOut(float time); static float cubicEaseIn(float time); static float cubicEaseOut(float time); static float cubicEaseInOut(float time); static float quartEaseIn(float time); static float quartEaseOut(float time); static float quartEaseInOut(float time); static float quintEaseIn(float time); static float quintEaseOut(float time); static float quintEaseInOut(float time); static float expoEaseIn(float time); static float expoEaseOut(float time); static float expoEaseInOut(float time); static float circEaseIn(float time); static float circEaseOut(float time); static float circEaseInOut(float time); static float elasticEaseIn(float time, float *easingParam); static float elasticEaseOut(float time, float *easingParam); static float elasticEaseInOut(float time, float *easingParam); static float backEaseIn(float time); static float backEaseOut(float time); static float backEaseInOut(float time); static float bounceEaseIn(float time); static float bounceEaseOut(float time); static float bounceEaseInOut(float time); static float customEase(float time, float *easingParam); }; } #endif /*__CCTWEENFUNCTION_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCUtilMath.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCUtilMath.h" using namespace cocos2d; namespace cocostudio { bool isSpriteContainPoint(Sprite *sprite, Point point, Point &outPoint) { outPoint = sprite->convertToNodeSpace(point); Size s = sprite->getContentSize(); Rect r(0, 0, s.width, s.height); return r.containsPoint(outPoint); } bool isSpriteContainPoint(Sprite *sprite, Point point) { Point p = Point(0, 0); return isSpriteContainPoint(sprite, point, p); } Point bezierTo(float t, Point &point1, Point &point2, Point &point3) { Point p; p.x = pow((1 - t), 2) * point1.x + 2 * t * (1 - t) * point2.x + pow(t, 2) * point3.x; p.y = pow((1 - t), 2) * point1.y + 2 * t * (1 - t) * point2.y + pow(t, 2) * point3.y; return p; } Point bezierTo(float t, Point &point1, Point &point2, Point &point3, Point &point4) { Point p; p.x = point1.x * pow((1 - t), 3) + 3 * t * point2.x * pow((1 - t), 2) + 3 * point3.x * pow(t, 2) * (1 - t) + point4.x * pow(t, 3); p.y = point1.y * pow((1 - t), 3) + 3 * t * point2.y * pow((1 - t), 2) + 3 * point3.y * pow(t, 2) * (1 - t) + point4.y * pow(t, 3); return p; } Point circleTo(float t, Point ¢er, float radius, float fromRadian, float radianDif) { Point p; p.x = center.x + radius * cos(fromRadian + radianDif * t); p.y = center.y + radius * sin(fromRadian + radianDif * t); return p; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CCUtilMath.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCUTILMATH_H__ #define __CCUTILMATH_H__ #include "CCSprite.h" #include "cocostudio/CCArmatureDefine.h" #include namespace cocostudio { #define CC_DOUBLE_PI (M_PI*2) #define CC_HALF_PI (M_PI * 0.5f) //! hit test function bool isSpriteContainPoint(cocos2d::Sprite *sprite, cocos2d::Point point); bool isSpriteContainPoint(cocos2d::Sprite *sprite, cocos2d::Point point, cocos2d::Point &outPoint); #define CC_SPRITE_CONTAIN_POINT(sprite, point) isSpriteContainPoint((sprite), (point)) #define CC_SPRITE_CONTAIN_POINT_WITH_RETURN(sprite, point, outPoint) isSpriteContainPoint((sprite), (point), outPoint) //! motion curve function cocos2d::Point bezierTo(float t, cocos2d::Point &point1, cocos2d::Point &point2, cocos2d::Point &point3); cocos2d::Point bezierTo(float t, cocos2d::Point &point1, cocos2d::Point &point2, cocos2d::Point &point3, cocos2d::Point &point4); cocos2d::Point circleTo(float t, cocos2d::Point ¢er, float radius, float fromRadian, float radianDif); } #endif /*__CCUTILMATH_H__*/ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CMakeLists.txt ================================================ set(CS_SRC CCActionEaseEx.cpp CCActionFrame.cpp CCActionFrameEasing.cpp CCActionManagerEx.cpp CCActionNode.cpp CCActionObject.cpp CCArmature.cpp CCBone.cpp CCArmatureAnimation.cpp CCProcessBase.cpp CCTween.cpp CCDatas.cpp CCBatchNode.cpp CCDecorativeDisplay.cpp CCDisplayFactory.cpp CCDisplayManager.cpp CCSkin.cpp CCColliderDetector.cpp CCArmatureDataManager.cpp CCArmatureDefine.cpp CCDataReaderHelper.cpp CCSpriteFrameCacheHelper.cpp CCTransformHelp.cpp CCTweenFunction.cpp CCUtilMath.cpp CCComAttribute.cpp CCComAudio.cpp CCComController.cpp CCComRender.cpp CCInputDelegate.cpp DictionaryHelper.cpp CCSGUIReader.cpp CCSSceneReader.cpp ObjectFactory.cpp TriggerBase.cpp TriggerMng.cpp TriggerObj.cpp ) include_directories( .. ) add_library(cocostudio STATIC ${CS_SRC} ) target_link_libraries(cocostudio ) set_target_properties(cocostudio PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/CocoStudio.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __EDITOR_SUPPORT_COCOSTUDIO_H__ #define __EDITOR_SUPPORT_COCOSTUDIO_H__ #include "cocostudio/CCActionFrame.h" #include "cocostudio/CCActionFrameEasing.h" #include "cocostudio/CCActionManagerEx.h" #include "cocostudio/CCActionNode.h" #include "cocostudio/CCActionObject.h" #include "cocostudio/CCArmature.h" #include "cocostudio/CCBone.h" #include "cocostudio/CCArmatureAnimation.h" #include "cocostudio/CCProcessBase.h" #include "cocostudio/CCTween.h" #include "cocostudio/CCDatas.h" #include "cocostudio/CCBatchNode.h" #include "cocostudio/CCDecorativeDisplay.h" #include "cocostudio/CCDisplayFactory.h" #include "cocostudio/CCDisplayManager.h" #include "cocostudio/CCSkin.h" #include "cocostudio/CCColliderDetector.h" #include "cocostudio/CCArmatureDataManager.h" #include "cocostudio/CCArmatureDefine.h" #include "cocostudio/CCDataReaderHelper.h" #include "cocostudio/CCSpriteFrameCacheHelper.h" #include "cocostudio/CCTransformHelp.h" #include "cocostudio/CCTweenFunction.h" #include "cocostudio/CCUtilMath.h" #include "cocostudio/CCComBase.h" #include "cocostudio/CCComAttribute.h" #include "cocostudio/CCComAudio.h" #include "cocostudio/CCComController.h" #include "cocostudio/CCComRender.h" #include "cocostudio/CCInputDelegate.h" #include "cocostudio/DictionaryHelper.h" #include "cocostudio/CCSGUIReader.h" #include "cocostudio/CCSSceneReader.h" #include "cocostudio/TriggerBase.h" #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/DictionaryHelper.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCPlatformMacros.h" #include "cocostudio/DictionaryHelper.h" namespace cocostudio { static DictionaryHelper* sharedHelper = nullptr; DictionaryHelper::DictionaryHelper() { } DictionaryHelper::~DictionaryHelper() { } DictionaryHelper* DictionaryHelper::getInstance() { if (!sharedHelper) { sharedHelper = new DictionaryHelper(); } return sharedHelper; } void DictionaryHelper::destroyInstance() { CC_SAFE_DELETE(sharedHelper); } const rapidjson::Value& DictionaryHelper::getSubDictionary_json(const rapidjson::Value &root, const char* key) { return root[key]; } const rapidjson::Value& DictionaryHelper::getSubDictionary_json(const rapidjson::Value &root, const char* key, int idx) { return root[key][idx]; } const rapidjson::Value& DictionaryHelper::getSubDictionary_json(const rapidjson::Value &root, int idx) { return root[idx]; } int DictionaryHelper::getIntValue_json(const rapidjson::Value& root, const char* key, int def) { int nRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[key].IsNull()); nRet = root[key].GetInt(); } while (0); return nRet; } float DictionaryHelper::getFloatValue_json(const rapidjson::Value& root,const char* key, float def) { float fRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[key].IsNull()); fRet = (float)root[key].GetDouble(); } while (0); return fRet; } bool DictionaryHelper::getBooleanValue_json(const rapidjson::Value& root,const char* key, bool def) { bool bRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[key].IsNull()); bRet = root[key].GetBool(); } while (0); return bRet; } const char* DictionaryHelper::getStringValue_json(const rapidjson::Value& root,const char* key, const char *def) { const char* sRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[key].IsNull()); sRet = root[key].GetString(); } while (0); return sRet; } int DictionaryHelper::getArrayCount_json(const rapidjson::Value& root, const char* key, int def) { int nRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[key].IsNull()); nRet = (int)(root[key].Size()); } while (0); return nRet; } int DictionaryHelper::getIntValueFromArray_json(const rapidjson::Value& root,const char* arrayKey,int idx, int def) { int nRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[arrayKey].IsNull()); CC_BREAK_IF(root[arrayKey][idx].IsNull()); nRet = root[arrayKey][idx].GetInt(); } while (0); return nRet; } float DictionaryHelper::getFloatValueFromArray_json(const rapidjson::Value& root,const char* arrayKey,int idx, float def) { float fRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[arrayKey].IsNull()); CC_BREAK_IF(root[arrayKey][idx].IsNull()); fRet = (float)root[arrayKey][idx].GetDouble(); } while (0); return fRet; } bool DictionaryHelper::getBoolValueFromArray_json(const rapidjson::Value& root,const char* arrayKey,int idx, bool def) { bool bRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[arrayKey].IsNull()); CC_BREAK_IF(root[arrayKey][idx].IsNull()); bRet = root[arrayKey][idx].GetBool(); } while (0); return bRet; } const char* DictionaryHelper::getStringValueFromArray_json(const rapidjson::Value& root,const char* arrayKey,int idx, const char *def) { const char *sRet = def; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(root[arrayKey].IsNull()); CC_BREAK_IF(root[arrayKey][idx].IsNull()); sRet = root[arrayKey][idx].GetString(); } while (0); return sRet; } const rapidjson::Value &DictionaryHelper::getDictionaryFromArray_json(const rapidjson::Value &root, const char* key,int idx) { return root[key][idx]; } bool DictionaryHelper::checkObjectExist_json(const rapidjson::Value &root) { bool bRet = false; do { CC_BREAK_IF(root.IsNull()); bRet = true; } while (0); return bRet; } bool DictionaryHelper::checkObjectExist_json(const rapidjson::Value &root,const char* key) { bool bRet = false; do { CC_BREAK_IF(root.IsNull()); bRet = root.HasMember(key); } while (0); return bRet; } bool DictionaryHelper::checkObjectExist_json(const rapidjson::Value &root, int index) { bool bRet = false; do { CC_BREAK_IF(root.IsNull()); CC_BREAK_IF(!root.IsArray()); CC_BREAK_IF(index < 0 || root.Size() <= (unsigned int )index); bRet = true; } while (0); return bRet; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/DictionaryHelper.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __DICTIONARYHELPER_H__ #define __DICTIONARYHELPER_H__ #include "json/document.h" #define DICTOOL DictionaryHelper::getInstance() namespace cocostudio { /** * @js NA * @lua NA */ class DictionaryHelper { public: DictionaryHelper(); ~DictionaryHelper(); static DictionaryHelper* getInstance(); static void destroyInstance(); const rapidjson::Value& getSubDictionary_json(const rapidjson::Value &root, const char* key); const rapidjson::Value& getSubDictionary_json(const rapidjson::Value &root, const char* key, int idx); const rapidjson::Value& getSubDictionary_json(const rapidjson::Value &root, int idx); int getIntValue_json(const rapidjson::Value& root, const char* key, int def = 0); float getFloatValue_json(const rapidjson::Value& root,const char* key, float def = 0.0f); bool getBooleanValue_json(const rapidjson::Value& root,const char* key, bool def = false); const char* getStringValue_json(const rapidjson::Value& root,const char* key, const char *def = NULL); int getArrayCount_json(const rapidjson::Value& root,const char* key, int def = 0); int getIntValueFromArray_json(const rapidjson::Value& root,const char* arrayKey,int idx, int def = 0); float getFloatValueFromArray_json(const rapidjson::Value& root,const char* arrayKey,int idx, float def = 0.0f); bool getBoolValueFromArray_json(const rapidjson::Value& root,const char* arrayKey,int idx, bool def = false); const char* getStringValueFromArray_json(const rapidjson::Value& root,const char* arrayKey,int idx, const char *def = NULL); const rapidjson::Value &getDictionaryFromArray_json(const rapidjson::Value &root, const char* key,int idx); bool checkObjectExist_json(const rapidjson::Value &root); bool checkObjectExist_json(const rapidjson::Value &root, const char* key); bool checkObjectExist_json(const rapidjson::Value &root, int index); }; } #endif /* defined(__CocoGUI__DictionaryHelper__) */ ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/ObjectFactory.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ObjectFactory.h" using namespace cocos2d; namespace cocostudio { ObjectFactory::TInfo::TInfo(void) :_class("") ,_fun(nullptr) { } ObjectFactory::TInfo::TInfo(const std::string& type, Instance ins) :_class(type) ,_fun(ins) { ObjectFactory::getInstance()->registerType(*this); } ObjectFactory::TInfo::TInfo(const TInfo &t) { _class = t._class; _fun = t._fun; } ObjectFactory::TInfo::~TInfo(void) { _class = ""; _fun = nullptr; } ObjectFactory::TInfo& ObjectFactory::TInfo::operator= (const TInfo &t) { _class = t._class; _fun = t._fun; return *this; } ObjectFactory* ObjectFactory::_sharedFactory = nullptr; ObjectFactory::ObjectFactory(void) { } ObjectFactory::~ObjectFactory(void) { _typeMap.clear(); } ObjectFactory* ObjectFactory::getInstance() { if ( nullptr == _sharedFactory) { _sharedFactory = new ObjectFactory(); } return _sharedFactory; } void ObjectFactory::destroyInstance() { CC_SAFE_DELETE(_sharedFactory); } Object* ObjectFactory::createObject(const std::string &name) { Object *o = nullptr; do { const TInfo t = _typeMap[name]; CC_BREAK_IF(t._fun == nullptr); o = t._fun(); } while (0); return o; } Component* ObjectFactory::createComponent(const std::string &name) { std::string comName; if (name == "CCSprite" || name == "CCTMXTiledMap" || name == "CCParticleSystemQuad" || name == "CCArmature" || name == "GUIComponent") { comName = "ComRender"; } else if (name == "CCComAudio" || name == "CCBackgroundAudio") { comName = "ComAudio"; } else if (name == "CCComController") { comName = "ComController"; } else if (name == "CCComAttribute") { comName = "ComAttribute"; } else if (name == "CCScene") { comName = "Scene"; } else { CCASSERT(false, "Unregistered Component!"); } Object *o = NULL; do { const TInfo t = _typeMap[comName]; CC_BREAK_IF(t._fun == NULL); o = t._fun(); } while (0); return (Component*)o; } void ObjectFactory::registerType(const TInfo &t) { _typeMap.insert(std::make_pair(t._class, t)); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/ObjectFactory.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __TRIGGERFACTORY_H__ #define __TRIGGERFACTORY_H__ #include "cocos2d.h" #include #include namespace cocostudio { class ObjectFactory { public: typedef cocos2d::Object* (*Instance)(void); struct TInfo { TInfo(void); TInfo(const std::string& type, Instance ins = NULL); TInfo(const TInfo &t); ~TInfo(void); TInfo& operator= (const TInfo &t); std::string _class; Instance _fun; }; typedef std::unordered_map FactoryMap; static ObjectFactory* getInstance(); static void destroyInstance(); cocos2d::Object* createObject(const std::string &name); cocos2d::Component* createComponent(const std::string &name); void registerType(const TInfo &t); void removeAll(); protected: ObjectFactory(void); virtual ~ObjectFactory(void); private: static ObjectFactory *_sharedFactory; FactoryMap _typeMap; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/TriggerBase.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "TriggerBase.h" using namespace cocos2d; using namespace cocostudio; void sendEvent(unsigned int event) { cocos2d::Vector *array = TriggerMng::getInstance()->get(event); do { CC_BREAK_IF(array == nullptr); for (const auto& object : *array) { if(object != nullptr && object->detect()) { object->done(); } } } while (0); } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/TriggerBase.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __TRIGGEREVENT_H__ #define __TRIGGEREVENT_H__ #include "cocos2d.h" #include "cocostudio/CocoStudio.h" #include "ObjectFactory.h" #include "TriggerObj.h" #include "TriggerMng.h" #define DECLARE_CLASS_INFO \ public: \ static cocostudio::ObjectFactory::TInfo Type; \ static cocos2d::Object* createInstance(void); \ #define IMPLEMENT_CLASS_INFO(className) \ cocos2d::Object* className::createInstance(void) \ { \ return new className; \ } \ cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \ void sendEvent(unsigned int event); #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/TriggerMng.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "TriggerMng.h" #include "json/filestream.h" #include "json/prettywriter.h" #include "json/stringbuffer.h" using namespace cocos2d; namespace cocostudio { TriggerMng* TriggerMng::_sharedTriggerMng = nullptr; TriggerMng::TriggerMng(void) : _movementDispatches(new std::unordered_map) { } TriggerMng::~TriggerMng(void) { removeAll(); _eventTriggers.clear(); _triggerObjs.clear(); removeAllArmatureMovementCallBack(); CC_SAFE_DELETE(_movementDispatches); } const char* TriggerMng::triggerMngVersion() { return "1.0.0.0"; } TriggerMng* TriggerMng::getInstance() { if (nullptr == _sharedTriggerMng) { _sharedTriggerMng = new TriggerMng(); } return _sharedTriggerMng; } void TriggerMng::destroyInstance() { CC_SAFE_DELETE(_sharedTriggerMng); } void TriggerMng::parse(const rapidjson::Value &root) { CCLOG("%s", triggerMngVersion()); int count = DICTOOL->getArrayCount_json(root, "Triggers"); ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); bool useBindings = engine != nullptr; if (useBindings) { if (count > 0) { const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(root, "Triggers"); rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); subDict.Accept(writer); engine->parseConfig(ScriptEngineProtocol::ConfigType::COCOSTUDIO, buffer.GetString()); } } else { for (int i = 0; i < count; ++i) { const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(root, "Triggers", i); TriggerObj *obj = TriggerObj::create(); obj->serialize(subDict); auto &vInt = obj->getEvents(); for (const auto& e : vInt) { add((unsigned int)e, obj); } _triggerObjs.insert(std::pair(obj->getId(), obj)); } } } cocos2d::Vector* TriggerMng::get(unsigned int event) const { CCAssert(event >= 0, "Argument must be larger than 0"); auto iter = _eventTriggers.find(event); if (iter == _eventTriggers.end()) { return nullptr; } return iter->second; } TriggerObj* TriggerMng::getTriggerObj(unsigned int id) const { auto iter = _triggerObjs.find(id); if (iter == _triggerObjs.end()) { return nullptr; } return iter->second; } bool TriggerMng::add(unsigned int event, TriggerObj *obj) { bool ret = false; CCAssert(obj != nullptr, "Argument must be non-nil"); do { auto iterator = _eventTriggers.find(event); if (iterator == _eventTriggers.end()) { auto array = new cocos2d::Vector(); array->pushBack(obj); _eventTriggers.insert(std::make_pair(event, array)); } else { Vector* temp = iterator->second; if(temp->find(obj) == temp->end()) { temp->pushBack(obj); } } ret = true; } while(0); return ret; } void TriggerMng::removeAll(void) { auto etIter = _eventTriggers.begin(); for (;etIter != _eventTriggers.end(); ++etIter) { for (auto toIter = etIter->second->begin(); toIter != etIter->second->end(); ++toIter) { (*toIter)->removeAll(); } etIter->second->clear(); CC_SAFE_DELETE(etIter->second); } _eventTriggers.clear(); } bool TriggerMng::remove(unsigned int event) { bool bRet = false; CCAssert(event >= 0, "event must be larger than 0"); do { auto iterator = _eventTriggers.find(event); if(iterator != _eventTriggers.end()) { for(auto &obj : *iterator->second) { obj->removeAll(); } iterator->second->clear(); CC_SAFE_DELETE(iterator->second); } _eventTriggers.erase(event); bRet = true; } while(0); return bRet; } bool TriggerMng::remove(unsigned int event, TriggerObj *Obj) { bool bRet = false; CCAssert(event >= 0, "event must be larger than 0"); CCAssert(Obj != 0, "TriggerObj must be not 0"); do { auto iterator = _eventTriggers.find(event); if(iterator != _eventTriggers.end()) { for(auto &triobj : *iterator->second) { if (triobj != nullptr && triobj == Obj) { triobj->removeAll(); break; } } iterator->second->eraseObject(Obj); } bRet = true; } while(0); return bRet; } bool TriggerMng::removeTriggerObj(unsigned int id) { TriggerObj *obj = getTriggerObj(id); if (obj == nullptr) { return false; } auto &_vInt = obj->getEvents(); for (auto iter = _vInt.begin(); iter != _vInt.end(); ++iter) { remove(*iter, obj); } return true; } bool TriggerMng::isEmpty(void) const { return _eventTriggers.empty(); } void TriggerMng::addArmatureMovementCallBack(Armature *pAr, Object *pTarget, SEL_MovementEventCallFunc mecf) { if (pAr == nullptr || _movementDispatches == nullptr || pTarget == nullptr || mecf == nullptr) { return; } auto iter = _movementDispatches->find(pAr); ArmatureMovementDispatcher *amd = nullptr; if (iter == _movementDispatches->end()) { amd = new ArmatureMovementDispatcher(); pAr->getAnimation()->setMovementEventCallFunc(CC_CALLBACK_0(ArmatureMovementDispatcher::animationEvent, amd, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); amd->addAnimationEventCallBack(pTarget, mecf); _movementDispatches->insert(std::make_pair(pAr, amd)); } else { amd = iter->second; amd->addAnimationEventCallBack(pTarget, mecf); } } void TriggerMng::removeArmatureMovementCallBack(Armature *pAr, Object *pTarget, SEL_MovementEventCallFunc mecf) { if (pAr == nullptr || _movementDispatches == nullptr || pTarget == nullptr || mecf == nullptr) { return; } auto iter =_movementDispatches->find(pAr); ArmatureMovementDispatcher *amd = nullptr; if (iter == _movementDispatches->end()) { return; } else { amd = iter->second; amd->removeAnnimationEventCallBack(pTarget, mecf); } } void TriggerMng::removeArmatureAllMovementCallBack(Armature *pAr) { if (pAr == nullptr) { return; } auto iter = _movementDispatches->find(pAr); if (iter == _movementDispatches->end()) { return; } else { CC_SAFE_DELETE(iter->second); _movementDispatches->erase(iter); } } void TriggerMng::removeAllArmatureMovementCallBack() { auto iter = _movementDispatches->begin(); while (iter != _movementDispatches->end()) { removeArmatureAllMovementCallBack(iter->first); } _movementDispatches->clear(); } ArmatureMovementDispatcher::ArmatureMovementDispatcher(void) : _mapEventAnimation(nullptr) { _mapEventAnimation = new std::unordered_map ; } ArmatureMovementDispatcher::~ArmatureMovementDispatcher(void) { _mapEventAnimation->clear(); CC_SAFE_DELETE(_mapEventAnimation); } void ArmatureMovementDispatcher::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID) { for (auto iter = _mapEventAnimation->begin(); iter != _mapEventAnimation->end(); ++iter) { (iter->first->*iter->second)(armature, movementType, movementID); } } void ArmatureMovementDispatcher::addAnimationEventCallBack(Object *pTarget, SEL_MovementEventCallFunc mecf) { _mapEventAnimation->insert(std::make_pair(pTarget, mecf)); } void ArmatureMovementDispatcher::removeAnnimationEventCallBack(Object *pTarget, SEL_MovementEventCallFunc mecf) { _mapEventAnimation->erase(pTarget); } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/TriggerMng.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __TRIGGERMNG_H__ #define __TRIGGERMNG_H__ #include "cocos2d.h" #include "CocoStudio.h" namespace cocostudio { class TriggerObj; class ArmatureMovementDispatcher : public cocos2d::Object { public: ArmatureMovementDispatcher(void); ~ArmatureMovementDispatcher(void); public: void addAnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); void removeAnnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); void animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID); private: std::unordered_map *_mapEventAnimation; }; class TriggerMng { public: TriggerMng(void); virtual ~TriggerMng(void); public: static TriggerMng* getInstance(); static void destroyInstance(); static const char* triggerMngVersion(); public: void parse(const rapidjson::Value &root); void removeAll(void); cocos2d::Vector* get(unsigned int event) const; TriggerObj* getTriggerObj(unsigned int id) const; bool add(unsigned int event, TriggerObj *pObj); bool remove(unsigned int event); bool remove(unsigned int event, TriggerObj *pObj); bool removeTriggerObj(unsigned int id); bool isEmpty(void) const; void addArmatureMovementCallBack(Armature *pAr, cocos2d::Object *pTarget, SEL_MovementEventCallFunc mecf); void removeArmatureMovementCallBack(Armature *pAr, cocos2d::Object *pTarget, SEL_MovementEventCallFunc mecf); void removeArmatureAllMovementCallBack(Armature *pAr); void removeAllArmatureMovementCallBack(); private: std::unordered_map*> _eventTriggers; static TriggerMng *_sharedTriggerMng; std::unordered_map _triggerObjs; std::unordered_map *_movementDispatches; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/TriggerObj.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "TriggerObj.h" using namespace cocos2d; namespace cocostudio { BaseTriggerCondition::BaseTriggerCondition(void) { } BaseTriggerCondition::~BaseTriggerCondition(void) { } bool BaseTriggerCondition::init() { return true; } bool BaseTriggerCondition::detect() { return true; } void BaseTriggerCondition::serialize(const rapidjson::Value &val) { } void BaseTriggerCondition::removeAll() { } BaseTriggerAction::BaseTriggerAction(void) { } BaseTriggerAction::~BaseTriggerAction(void) { } bool BaseTriggerAction::init() { return true; } void BaseTriggerAction::done() { } void BaseTriggerAction::serialize(const rapidjson::Value &val) { } void BaseTriggerAction::removeAll() { } TriggerObj::TriggerObj(void) :_id(UINT_MAX) ,_enabled(true) { _vInt.clear(); } TriggerObj::~TriggerObj(void) { _vInt.clear(); } bool TriggerObj::init() { return true; } TriggerObj* TriggerObj::create() { TriggerObj * pRet = new TriggerObj(); if (pRet && pRet->init()) { pRet->autorelease(); } else { CC_SAFE_DELETE(pRet); } return pRet; } bool TriggerObj::detect() { if (!_enabled || _cons.empty()) { return true; } bool ret = true; for (const auto& con : _cons) { ret = ret && con->detect(); } return ret; } void TriggerObj::done() { if (!_enabled || _acts.empty()) { return; } for (const auto& act : _acts) { act->done(); } } void TriggerObj::removeAll() { for (const auto& con : _cons) { con->removeAll(); } for (const auto& act : _acts) { act->removeAll(); } _cons.clear(); _acts.clear(); } void TriggerObj::serialize(const rapidjson::Value &val) { _id = (unsigned int)(DICTOOL->getIntValue_json(val, "id")); int count = DICTOOL->getArrayCount_json(val, "conditions"); for (int i = 0; i < count; ++i) { const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "conditions", i); const char *classname = DICTOOL->getStringValue_json(subDict, "classname"); if (classname == nullptr) { continue; } BaseTriggerCondition *con = dynamic_cast(ObjectFactory::getInstance()->createObject(classname)); if(con == nullptr) { CCLOG("class %s can not be implemented!", classname); CCASSERT(con != nullptr, ""); } CCASSERT(con != nullptr, ""); con->serialize(subDict); con->init(); _cons.pushBack(con); } count = DICTOOL->getArrayCount_json(val, "actions"); for (int i = 0; i < count; ++i) { const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "actions", i); const char *classname = DICTOOL->getStringValue_json(subDict, "classname"); if (classname == nullptr) { continue; } BaseTriggerAction *act = dynamic_cast(ObjectFactory::getInstance()->createObject(classname)); if(act == nullptr) { CCLOG("class %s can not be implemented!", classname); CCASSERT(act != nullptr, ""); } act->serialize(subDict); act->init(); _acts.pushBack(act); } int length = DICTOOL->getArrayCount_json(val, "events"); for (int i = 0; i < length; ++i) { const rapidjson::Value &sub = DICTOOL->getSubDictionary_json(val, "events", i); int event = DICTOOL->getIntValue_json(sub, "id"); if (event < 0) { continue; } _vInt.push_back(event); } } unsigned int TriggerObj::getId() { return _id; } void TriggerObj::setEnabled(bool enabled) { _enabled = enabled; } std::vector& TriggerObj::getEvents() { return _vInt; } } ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/TriggerObj.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __TRIGGEROBJ_H__ #define __TRIGGEROBJ_H__ #include "cocos2d.h" #include "CocoStudio.h" #include namespace cocostudio { class BaseTriggerCondition : public cocos2d::Object { protected: BaseTriggerCondition(void); public: virtual ~BaseTriggerCondition(void); virtual bool init(); virtual bool detect(); virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); }; class BaseTriggerAction : public cocos2d::Object { protected: BaseTriggerAction(void); public: virtual ~BaseTriggerAction(void); virtual bool init(); virtual void done(); virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); }; class TriggerObj : public cocos2d::Object { public: TriggerObj(void); virtual ~TriggerObj(void); virtual bool init(); static TriggerObj* create(void); virtual bool detect(); virtual void done(); virtual void removeAll(); virtual void serialize(const rapidjson::Value &val); unsigned int getId(); void setEnabled(bool enabled); std::vector& getEvents(); private: cocos2d::Vector _cons; cocos2d::Vector _acts; unsigned int _id; bool _enabled; std::vector _vInt; }; } #endif ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj ================================================  Debug Win32 Release Win32 {B57CF53F-2E49-4031-9822-047CC0E6BDE2} libCocosStudio StaticLibrary true v100 v110 v110_xp Unicode StaticLibrary false v100 v110 v110_xp true Unicode $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true 4267;4251;4244;%(DisableSpecificWarnings) false OldStyle true Level3 MaxSpeed true true WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) true true true ================================================ FILE: cocos2d/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters ================================================  {d793b86c-0905-4c9b-b6bc-161e351c9eb2} {855f2366-3429-4f77-a080-a41a39c99270} {1a8c6b14-fb28-4485-8417-9b6838fbc4ef} {42f1ce3f-46ab-4a16-a96e-9eb076c873f7} {f8271f80-1663-4425-91c8-7365ec3af017} {48f28446-ffe4-4aa1-a34c-8968c3367ae6} {ad9b4fd1-dc17-4704-9c60-7709eb916f13} {55c682b3-7a48-4fab-ad5a-eb979f3c305e} {c6464479-e0ab-4afc-96fc-1ffc73e40232} {023e3440-1259-4981-ba54-24390d1df447} {f1f20817-9232-4967-a4dd-77550e84e39b} {5149f922-cf29-4a4b-b604-f15c6e8856b0} {59eee6d9-bbfd-4193-be1d-6c18fc38f896} components components components components components json reader reader armature\animation armature\animation armature\animation armature\datas armature\display armature\display armature\display armature\display armature\display armature\utils armature\utils armature\utils armature\utils armature\utils armature\utils armature\utils armature\physics armature armature action action action action action action trigger trigger trigger trigger components components components components components json reader reader armature\animation armature\animation armature\animation armature\datas armature\display armature\display armature\display armature\display armature\display armature\utils armature\utils armature\utils armature\utils armature\utils armature\utils armature\utils armature\physics armature armature json\rapidjson json\rapidjson json\rapidjson json\rapidjson json\rapidjson json\rapidjson json\rapidjson json\rapidjson\internal json\rapidjson\internal json\rapidjson\internal action action action action action action trigger trigger trigger trigger components ================================================ FILE: cocos2d/cocos/editor-support/spine/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := spine_static LOCAL_MODULE_FILENAME := libspine LOCAL_SRC_FILES := Animation.cpp \ AnimationState.cpp \ AnimationStateData.cpp \ Atlas.cpp \ AtlasAttachmentLoader.cpp \ Attachment.cpp \ AttachmentLoader.cpp \ Bone.cpp \ BoneData.cpp \ CCSkeleton.cpp \ CCSkeletonAnimation.cpp \ Json.cpp \ RegionAttachment.cpp \ Skeleton.cpp \ SkeletonData.cpp \ SkeletonJson.cpp \ Skin.cpp \ Slot.cpp \ SlotData.cpp \ BoundingBoxAttachment.cpp \ Event.cpp \ EventData.cpp \ SkeletonBounds.cpp \ extension.cpp \ spine-cocos2dx.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \ $(LOCAL_PATH)/.. LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static include $(BUILD_STATIC_LIBRARY) $(call import-module,2d) ================================================ FILE: cocos2d/cocos/editor-support/spine/Animation.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include spAnimation* spAnimation_create (const char* name, int timelineCount) { spAnimation* self = NEW(spAnimation); MALLOC_STR(self->name, name); self->timelineCount = timelineCount; self->timelines = MALLOC(spTimeline*, timelineCount); return self; } void spAnimation_dispose (spAnimation* self) { int i; for (i = 0; i < self->timelineCount; ++i) spTimeline_dispose(self->timelines[i]); FREE(self->timelines); FREE(self->name); FREE(self); } void spAnimation_apply (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events, int* eventCount) { int i, n = self->timelineCount; if (loop && self->duration) { time = FMOD(time, self->duration); lastTime = FMOD(lastTime, self->duration); } for (i = 0; i < n; ++i) spTimeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, 1); } void spAnimation_mix (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events, int* eventCount, float alpha) { int i, n = self->timelineCount; if (loop && self->duration) { time = FMOD(time, self->duration); lastTime = FMOD(lastTime, self->duration); } for (i = 0; i < n; ++i) spTimeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventCount, alpha); } /**/ typedef struct _spTimelineVtable { void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha); void (*dispose) (spTimeline* self); } _spTimelineVtable; void _spTimeline_init (spTimeline* self, spTimelineType type, /**/ void (*dispose) (spTimeline* self), /**/ void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha)) { CONST_CAST(spTimelineType, self->type) = type; CONST_CAST(_spTimelineVtable*, self->vtable) = NEW(_spTimelineVtable); VTABLE(spTimeline, self)->dispose = dispose; VTABLE(spTimeline, self)->apply = apply; } void _spTimeline_deinit (spTimeline* self) { FREE(self->vtable); } void spTimeline_dispose (spTimeline* self) { VTABLE(spTimeline, self)->dispose(self); } void spTimeline_apply (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { VTABLE(spTimeline, self)->apply(self, skeleton, lastTime, time, firedEvents, eventCount, alpha); } /**/ static const float CURVE_LINEAR = 0; static const float CURVE_STEPPED = -1; static const int CURVE_SEGMENTS = 10; void _spCurveTimeline_init (spCurveTimeline* self, spTimelineType type, int frameCount, /**/ void (*dispose) (spTimeline* self), /**/ void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha)) { _spTimeline_init(SUPER(self), type, dispose, apply); self->curves = CALLOC(float, (frameCount - 1) * 6); } void _spCurveTimeline_deinit (spCurveTimeline* self) { _spTimeline_deinit(SUPER(self)); FREE(self->curves); } void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex) { self->curves[frameIndex * 6] = CURVE_LINEAR; } void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex) { self->curves[frameIndex * 6] = CURVE_STEPPED; } void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2) { float subdiv_step = 1.0f / CURVE_SEGMENTS; float subdiv_step2 = subdiv_step * subdiv_step; float subdiv_step3 = subdiv_step2 * subdiv_step; float pre1 = 3 * subdiv_step; float pre2 = 3 * subdiv_step2; float pre4 = 6 * subdiv_step2; float pre5 = 6 * subdiv_step3; float tmp1x = -cx1 * 2 + cx2; float tmp1y = -cy1 * 2 + cy2; float tmp2x = (cx1 - cx2) * 3 + 1; float tmp2y = (cy1 - cy2) * 3 + 1; int i = frameIndex * 6; self->curves[i] = cx1 * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3; self->curves[i + 1] = cy1 * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3; self->curves[i + 2] = tmp1x * pre4 + tmp2x * pre5; self->curves[i + 3] = tmp1y * pre4 + tmp2y * pre5; self->curves[i + 4] = tmp2x * pre5; self->curves[i + 5] = tmp2y * pre5; } float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent) { float dfy; float ddfx; float ddfy; float dddfx; float dddfy; float x, y; int i; int curveIndex = frameIndex * 6; float dfx = self->curves[curveIndex]; if (dfx == CURVE_LINEAR) return percent; if (dfx == CURVE_STEPPED) return 0; dfy = self->curves[curveIndex + 1]; ddfx = self->curves[curveIndex + 2]; ddfy = self->curves[curveIndex + 3]; dddfx = self->curves[curveIndex + 4]; dddfy = self->curves[curveIndex + 5]; x = dfx, y = dfy; i = CURVE_SEGMENTS - 2; while (1) { if (x >= percent) { float lastX = x - dfx; float lastY = y - dfy; return lastY + (y - lastY) * (percent - lastX) / (x - lastX); } if (i == 0) break; i--; dfx += ddfx; dfy += ddfy; ddfx += dddfx; ddfy += dddfy; x += dfx; y += dfy; } return y + (1 - y) * (percent - x) / (1 - x); /* Last point is 1,1. */ } /* @param target After the first and before the last entry. */ static int binarySearch (float *values, int valuesLength, float target, int step) { int low = 0, current; int high = valuesLength / step - 2; if (high == 0) return step; current = high >> 1; while (1) { if (values[(current + 1) * step] <= target) low = current + 1; else high = current; if (low == high) return (low + 1) * step; current = (low + high) >> 1; } return 0; } /*static int linearSearch (float *values, int valuesLength, float target, int step) { int i, last = valuesLength - step; for (i = 0; i <= last; i += step) { if (values[i] <= target) continue; return i; } return -1; }*/ /**/ void _spBaseTimeline_dispose (spTimeline* timeline) { struct spBaseTimeline* self = SUB_CAST(struct spBaseTimeline, timeline); _spCurveTimeline_deinit(SUPER(self)); FREE(self->frames); FREE(self); } /* Many timelines have structure identical to struct spBaseTimeline and extend spCurveTimeline. **/ struct spBaseTimeline* _spBaseTimeline_create (int frameCount, spTimelineType type, int frameSize, /**/ void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha)) { struct spBaseTimeline* self = NEW(struct spBaseTimeline); _spCurveTimeline_init(SUPER(self), type, frameCount, _spBaseTimeline_dispose, apply); CONST_CAST(int, self->framesLength) = frameCount * frameSize; CONST_CAST(float*, self->frames) = CALLOC(float, self->framesLength); return self; } /**/ static const int ROTATE_LAST_FRAME_TIME = -2; static const int ROTATE_FRAME_VALUE = 1; void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { spBone *bone; int frameIndex; float lastFrameValue, frameTime, percent, amount; spRotateTimeline* self = SUB_CAST(spRotateTimeline, timeline); if (time < self->frames[0]) return; /* Time is before first frame. */ bone = skeleton->bones[self->boneIndex]; if (time >= self->frames[self->framesLength - 2]) { /* Time is after last frame. */ amount = bone->data->rotation + self->frames[self->framesLength - 1] - bone->rotation; while (amount > 180) amount -= 360; while (amount < -180) amount += 360; bone->rotation += amount * alpha; return; } /* Interpolate between the last frame and the current frame. */ frameIndex = binarySearch(self->frames, self->framesLength, time, 2); lastFrameValue = self->frames[frameIndex - 1]; frameTime = self->frames[frameIndex]; percent = 1 - (time - frameTime) / (self->frames[frameIndex + ROTATE_LAST_FRAME_TIME] - frameTime); percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 2 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); amount = self->frames[frameIndex + ROTATE_FRAME_VALUE] - lastFrameValue; while (amount > 180) amount -= 360; while (amount < -180) amount += 360; amount = bone->data->rotation + (lastFrameValue + amount * percent) - bone->rotation; while (amount > 180) amount -= 360; while (amount < -180) amount += 360; bone->rotation += amount * alpha; } spRotateTimeline* spRotateTimeline_create (int frameCount) { return _spBaseTimeline_create(frameCount, TIMELINE_ROTATE, 2, _spRotateTimeline_apply); } void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float angle) { frameIndex *= 2; self->frames[frameIndex] = time; self->frames[frameIndex + 1] = angle; } /**/ static const int TRANSLATE_LAST_FRAME_TIME = -3; static const int TRANSLATE_FRAME_X = 1; static const int TRANSLATE_FRAME_Y = 2; void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { spBone *bone; int frameIndex; float lastFrameX, lastFrameY, frameTime, percent; spTranslateTimeline* self = SUB_CAST(spTranslateTimeline, timeline); if (time < self->frames[0]) return; /* Time is before first frame. */ bone = skeleton->bones[self->boneIndex]; if (time >= self->frames[self->framesLength - 3]) { /* Time is after last frame. */ bone->x += (bone->data->x + self->frames[self->framesLength - 2] - bone->x) * alpha; bone->y += (bone->data->y + self->frames[self->framesLength - 1] - bone->y) * alpha; return; } /* Interpolate between the last frame and the current frame. */ frameIndex = binarySearch(self->frames, self->framesLength, time, 3); lastFrameX = self->frames[frameIndex - 2]; lastFrameY = self->frames[frameIndex - 1]; frameTime = self->frames[frameIndex]; percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_LAST_FRAME_TIME] - frameTime); percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); bone->x += (bone->data->x + lastFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - lastFrameX) * percent - bone->x) * alpha; bone->y += (bone->data->y + lastFrameY + (self->frames[frameIndex + TRANSLATE_FRAME_Y] - lastFrameY) * percent - bone->y) * alpha; } spTranslateTimeline* spTranslateTimeline_create (int frameCount) { return _spBaseTimeline_create(frameCount, TIMELINE_TRANLATE, 3, _spTranslateTimeline_apply); } void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y) { frameIndex *= 3; self->frames[frameIndex] = time; self->frames[frameIndex + 1] = x; self->frames[frameIndex + 2] = y; } /**/ void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { spBone *bone; int frameIndex; float lastFrameX, lastFrameY, frameTime, percent; spScaleTimeline* self = SUB_CAST(spScaleTimeline, timeline); if (time < self->frames[0]) return; /* Time is before first frame. */ bone = skeleton->bones[self->boneIndex]; if (time >= self->frames[self->framesLength - 3]) { /* Time is after last frame. */ bone->scaleX += (bone->data->scaleX - 1 + self->frames[self->framesLength - 2] - bone->scaleX) * alpha; bone->scaleY += (bone->data->scaleY - 1 + self->frames[self->framesLength - 1] - bone->scaleY) * alpha; return; } /* Interpolate between the last frame and the current frame. */ frameIndex = binarySearch(self->frames, self->framesLength, time, 3); lastFrameX = self->frames[frameIndex - 2]; lastFrameY = self->frames[frameIndex - 1]; frameTime = self->frames[frameIndex]; percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_LAST_FRAME_TIME] - frameTime); percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); bone->scaleX += (bone->data->scaleX - 1 + lastFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - lastFrameX) * percent - bone->scaleX) * alpha; bone->scaleY += (bone->data->scaleY - 1 + lastFrameY + (self->frames[frameIndex + TRANSLATE_FRAME_Y] - lastFrameY) * percent - bone->scaleY) * alpha; } spScaleTimeline* spScaleTimeline_create (int frameCount) { return _spBaseTimeline_create(frameCount, TIMELINE_SCALE, 3, _spScaleTimeline_apply); } void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y) { spTranslateTimeline_setFrame(self, frameIndex, time, x, y); } /**/ static const int COLOR_LAST_FRAME_TIME = -5; static const int COLOR_FRAME_R = 1; static const int COLOR_FRAME_G = 2; static const int COLOR_FRAME_B = 3; static const int COLOR_FRAME_A = 4; void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { spSlot *slot; int frameIndex; float lastFrameR, lastFrameG, lastFrameB, lastFrameA, percent, frameTime; float r, g, b, a; spColorTimeline* self = (spColorTimeline*)timeline; if (time < self->frames[0]) return; /* Time is before first frame. */ slot = skeleton->slots[self->slotIndex]; if (time >= self->frames[self->framesLength - 5]) { /* Time is after last frame. */ int i = self->framesLength - 1; slot->r = self->frames[i - 3]; slot->g = self->frames[i - 2]; slot->b = self->frames[i - 1]; slot->a = self->frames[i]; return; } /* Interpolate between the last frame and the current frame. */ frameIndex = binarySearch(self->frames, self->framesLength, time, 5); lastFrameR = self->frames[frameIndex - 4]; lastFrameG = self->frames[frameIndex - 3]; lastFrameB = self->frames[frameIndex - 2]; lastFrameA = self->frames[frameIndex - 1]; frameTime = self->frames[frameIndex]; percent = 1 - (time - frameTime) / (self->frames[frameIndex + COLOR_LAST_FRAME_TIME] - frameTime); percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 5 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent)); r = lastFrameR + (self->frames[frameIndex + COLOR_FRAME_R] - lastFrameR) * percent; g = lastFrameG + (self->frames[frameIndex + COLOR_FRAME_G] - lastFrameG) * percent; b = lastFrameB + (self->frames[frameIndex + COLOR_FRAME_B] - lastFrameB) * percent; a = lastFrameA + (self->frames[frameIndex + COLOR_FRAME_A] - lastFrameA) * percent; if (alpha < 1) { slot->r += (r - slot->r) * alpha; slot->g += (g - slot->g) * alpha; slot->b += (b - slot->b) * alpha; slot->a += (a - slot->a) * alpha; } else { slot->r = r; slot->g = g; slot->b = b; slot->a = a; } } spColorTimeline* spColorTimeline_create (int frameCount) { return (spColorTimeline*)_spBaseTimeline_create(frameCount, TIMELINE_COLOR, 5, _spColorTimeline_apply); } void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a) { frameIndex *= 5; self->frames[frameIndex] = time; self->frames[frameIndex + 1] = r; self->frames[frameIndex + 2] = g; self->frames[frameIndex + 3] = b; self->frames[frameIndex + 4] = a; } /**/ void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { int frameIndex; const char* attachmentName; spAttachmentTimeline* self = (spAttachmentTimeline*)timeline; if (time < self->frames[0]) return; /* Time is before first frame. */ if (time >= self->frames[self->framesLength - 1]) /* Time is after last frame. */ frameIndex = self->framesLength - 1; else frameIndex = binarySearch(self->frames, self->framesLength, time, 1) - 1; attachmentName = self->attachmentNames[frameIndex]; spSlot_setAttachment(skeleton->slots[self->slotIndex], attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0); } void _spAttachmentTimeline_dispose (spTimeline* timeline) { spAttachmentTimeline* self = SUB_CAST(spAttachmentTimeline, timeline); int i; _spTimeline_deinit(timeline); for (i = 0; i < self->framesLength; ++i) FREE(self->attachmentNames[i]); FREE(self->attachmentNames); FREE(self->frames); FREE(self); } spAttachmentTimeline* spAttachmentTimeline_create (int frameCount) { spAttachmentTimeline* self = NEW(spAttachmentTimeline); _spTimeline_init(SUPER(self), TIMELINE_ATTACHMENT, _spAttachmentTimeline_dispose, _spAttachmentTimeline_apply); CONST_CAST(int, self->framesLength) = frameCount; CONST_CAST(float*, self->frames) = CALLOC(float, frameCount); CONST_CAST(char**, self->attachmentNames) = CALLOC(char*, frameCount); return self; } void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName) { self->frames[frameIndex] = time; FREE(self->attachmentNames[frameIndex]); if (attachmentName) MALLOC_STR(self->attachmentNames[frameIndex], attachmentName); else self->attachmentNames[frameIndex] = 0; } /**/ /** Fires events for frames > lastTime and <= time. */ void _spEventTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { spEventTimeline* self = (spEventTimeline*)timeline; int frameIndex; if (!firedEvents) return; if (lastTime > time) { /* Fire events after last time for looped animations. */ _spEventTimeline_apply(timeline, skeleton, lastTime, (float)INT_MAX, firedEvents, eventCount, alpha); lastTime = -1; } else if (lastTime >= self->frames[self->framesLength - 1]) /* Last time is after last frame. */ return; if (time < self->frames[0]) return; /* Time is before first frame. */ if (lastTime < self->frames[0]) frameIndex = 0; else { float frame; frameIndex = binarySearch(self->frames, self->framesLength, lastTime, 1); frame = self->frames[frameIndex]; while (frameIndex > 0) { /* Fire multiple events with the same frame. */ if (self->frames[frameIndex - 1] != frame) break; frameIndex--; } } for (; frameIndex < self->framesLength && time >= self->frames[frameIndex]; frameIndex++) { firedEvents[*eventCount] = self->events[frameIndex]; (*eventCount)++; } } void _spEventTimeline_dispose (spTimeline* timeline) { spEventTimeline* self = SUB_CAST(spEventTimeline, timeline); int i; _spTimeline_deinit(timeline); for (i = 0; i < self->framesLength; ++i) spEvent_dispose(self->events[i]); FREE(self->events); FREE(self->frames); FREE(self); } spEventTimeline* spEventTimeline_create (int frameCount) { spEventTimeline* self = NEW(spEventTimeline); _spTimeline_init(SUPER(self), TIMELINE_EVENT, _spEventTimeline_dispose, _spEventTimeline_apply); CONST_CAST(int, self->framesLength) = frameCount; CONST_CAST(float*, self->frames) = CALLOC(float, frameCount); CONST_CAST(spEvent**, self->events) = CALLOC(spEvent*, frameCount); return self; } void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, float time, spEvent* event) { self->frames[frameIndex] = time; FREE(self->events[frameIndex]); self->events[frameIndex] = event; } /**/ void _spDrawOrderTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha) { int i; int frameIndex; const int* drawOrderToSetupIndex; spDrawOrderTimeline* self = (spDrawOrderTimeline*)timeline; if (time < self->frames[0]) return; /* Time is before first frame. */ if (time >= self->frames[self->framesLength - 1]) /* Time is after last frame. */ frameIndex = self->framesLength - 1; else frameIndex = binarySearch(self->frames, self->framesLength, time, 1) - 1; drawOrderToSetupIndex = self->drawOrders[frameIndex]; if (!drawOrderToSetupIndex) memcpy(skeleton->drawOrder, skeleton->slots, self->slotCount * sizeof(int)); else { for (i = 0; i < self->slotCount; i++) skeleton->drawOrder[i] = skeleton->slots[drawOrderToSetupIndex[i]]; } } void _spDrawOrderTimeline_dispose (spTimeline* timeline) { spDrawOrderTimeline* self = SUB_CAST(spDrawOrderTimeline, timeline); int i; _spTimeline_deinit(timeline); for (i = 0; i < self->framesLength; ++i) FREE(self->drawOrders[i]); FREE(self->drawOrders); FREE(self->frames); FREE(self); } spDrawOrderTimeline* spDrawOrderTimeline_create (int frameCount, int slotCount) { spDrawOrderTimeline* self = NEW(spDrawOrderTimeline); _spTimeline_init(SUPER(self), TIMELINE_DRAWORDER, _spDrawOrderTimeline_dispose, _spDrawOrderTimeline_apply); CONST_CAST(int, self->framesLength) = frameCount; CONST_CAST(float*, self->frames) = CALLOC(float, frameCount); CONST_CAST(int**, self->drawOrders) = CALLOC(int*, frameCount); CONST_CAST(int, self->slotCount) = slotCount; return self; } void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder) { self->frames[frameIndex] = time; FREE(self->drawOrders[frameIndex]); if (!drawOrder) self->drawOrders[frameIndex] = 0; else { self->drawOrders[frameIndex] = MALLOC(int, self->slotCount); memcpy(CONST_CAST(int*, self->drawOrders[frameIndex]), drawOrder, self->slotCount * sizeof(int)); } } ================================================ FILE: cocos2d/cocos/editor-support/spine/Animation.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_ANIMATION_H_ #define SPINE_ANIMATION_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct spTimeline spTimeline; struct spSkeleton; typedef struct { const char* const name; float duration; int timelineCount; spTimeline** timelines; } spAnimation; spAnimation* spAnimation_create (const char* name, int timelineCount); void spAnimation_dispose (spAnimation* self); /** Poses the skeleton at the specified time for this animation. * @param lastTime The last time the animation was applied. * @param events Any triggered events are added. */ void spAnimation_apply (const spAnimation* self, struct spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events, int* eventCount); /** Poses the skeleton at the specified time for this animation mixed with the current pose. * @param lastTime The last time the animation was applied. * @param events Any triggered events are added. * @param alpha The amount of this animation that affects the current pose. */ void spAnimation_mix (const spAnimation* self, struct spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events, int* eventCount, float alpha); #ifdef SPINE_SHORT_NAMES typedef spAnimation Animation; #define Animation_create(...) spAnimation_create(__VA_ARGS__) #define Animation_dispose(...) spAnimation_dispose(__VA_ARGS__) #define Animation_apply(...) spAnimation_apply(__VA_ARGS__) #define Animation_mix(...) spAnimation_mix(__VA_ARGS__) #endif /**/ typedef enum { TIMELINE_SCALE, TIMELINE_ROTATE, TIMELINE_TRANLATE, TIMELINE_COLOR, TIMELINE_ATTACHMENT, TIMELINE_EVENT, TIMELINE_DRAWORDER } spTimelineType; struct spTimeline { const spTimelineType type; const void* const vtable; }; void spTimeline_dispose (spTimeline* self); void spTimeline_apply (const spTimeline* self, struct spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha); #ifdef SPINE_SHORT_NAMES typedef spTimeline Timeline; #define Timeline_dispose(...) spTimeline_dispose(__VA_ARGS__) #define Timeline_apply(...) spTimeline_apply(__VA_ARGS__) #endif /**/ typedef struct { spTimeline super; float* curves; /* dfx, dfy, ddfx, ddfy, dddfx, dddfy, ... */ } spCurveTimeline; void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex); void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex); /* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next. * cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of * the difference between the keyframe's values. */ void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2); float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent); #ifdef SPINE_SHORT_NAMES typedef spCurveTimeline CurveTimeline; #define CurveTimeline_setLinear(...) spCurveTimeline_setLinear(__VA_ARGS__) #define CurveTimeline_setStepped(...) spCurveTimeline_setStepped(__VA_ARGS__) #define CurveTimeline_setCurve(...) spCurveTimeline_setCurve(__VA_ARGS__) #define CurveTimeline_getCurvePercent(...) spCurveTimeline_getCurvePercent(__VA_ARGS__) #endif /**/ typedef struct spBaseTimeline { spCurveTimeline super; int const framesLength; float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */ int boneIndex; } spRotateTimeline; spRotateTimeline* spRotateTimeline_create (int frameCount); void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float angle); #ifdef SPINE_SHORT_NAMES typedef spRotateTimeline RotateTimeline; #define RotateTimeline_create(...) spRotateTimeline_create(__VA_ARGS__) #define RotateTimeline_setFrame(...) spRotateTimeline_setFrame(__VA_ARGS__) #endif /**/ typedef struct spBaseTimeline spTranslateTimeline; spTranslateTimeline* spTranslateTimeline_create (int frameCount); void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y); #ifdef SPINE_SHORT_NAMES typedef spTranslateTimeline TranslateTimeline; #define TranslateTimeline_create(...) spTranslateTimeline_create(__VA_ARGS__) #define TranslateTimeline_setFrame(...) spTranslateTimeline_setFrame(__VA_ARGS__) #endif /**/ typedef struct spBaseTimeline spScaleTimeline; spScaleTimeline* spScaleTimeline_create (int frameCount); void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y); #ifdef SPINE_SHORT_NAMES typedef spScaleTimeline ScaleTimeline; #define ScaleTimeline_create(...) spScaleTimeline_create(__VA_ARGS__) #define ScaleTimeline_setFrame(...) spScaleTimeline_setFrame(__VA_ARGS__) #endif /**/ typedef struct { spCurveTimeline super; int const framesLength; float* const frames; /* time, r, g, b, a, ... */ int slotIndex; } spColorTimeline; spColorTimeline* spColorTimeline_create (int frameCount); void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a); #ifdef SPINE_SHORT_NAMES typedef spColorTimeline ColorTimeline; #define ColorTimeline_create(...) spColorTimeline_create(__VA_ARGS__) #define ColorTimeline_setFrame(...) spColorTimeline_setFrame(__VA_ARGS__) #endif /**/ typedef struct { spTimeline super; int const framesLength; float* const frames; /* time, ... */ int slotIndex; const char** const attachmentNames; } spAttachmentTimeline; spAttachmentTimeline* spAttachmentTimeline_create (int frameCount); /* @param attachmentName May be 0. */ void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName); #ifdef SPINE_SHORT_NAMES typedef spAttachmentTimeline AttachmentTimeline; #define AttachmentTimeline_create(...) spAttachmentTimeline_create(__VA_ARGS__) #define AttachmentTimeline_setFrame(...) spAttachmentTimeline_setFrame(__VA_ARGS__) #endif /**/ typedef struct { spTimeline super; int const framesLength; float* const frames; /* time, ... */ spEvent** const events; } spEventTimeline; spEventTimeline* spEventTimeline_create (int frameCount); void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, float time, spEvent* event); #ifdef SPINE_SHORT_NAMES typedef spEventTimeline EventTimeline; #define EventTimeline_create(...) spEventTimeline_create(__VA_ARGS__) #define EventTimeline_setFrame(...) spEventTimeline_setFrame(__VA_ARGS__) #endif /**/ typedef struct { spTimeline super; int const framesLength; float* const frames; /* time, ... */ const int** const drawOrders; int const slotCount; } spDrawOrderTimeline; spDrawOrderTimeline* spDrawOrderTimeline_create (int frameCount, int slotCount); void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder); #ifdef SPINE_SHORT_NAMES typedef spDrawOrderTimeline DrawOrderTimeline; #define DrawOrderTimeline_create(...) spDrawOrderTimeline_create(__VA_ARGS__) #define DrawOrderTimeline_setFrame(...) spDrawOrderTimeline_setFrame(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_ANIMATION_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/AnimationState.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include #include #include #include #include #include spTrackEntry* _spTrackEntry_create () { spTrackEntry* entry = NEW(spTrackEntry); entry->timeScale = 1; entry->lastTime = -1; return entry; } void _spTrackEntry_dispose (spTrackEntry* entry) { FREE(entry); } void _spTrackEntry_disposeAll (spTrackEntry* entry) { while (entry) { spTrackEntry* next = entry->next; _spTrackEntry_dispose(entry); entry = next; } } /**/ typedef struct { spAnimationState super; spEvent** events; } _spAnimationState; void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* entry); spAnimationState* spAnimationState_create (spAnimationStateData* data) { _spAnimationState* internal = NEW(_spAnimationState); spAnimationState* self = SUPER(internal); internal->events = MALLOC(spEvent*, 64); self->timeScale = 1; CONST_CAST(spAnimationStateData*, self->data) = data; return self; } void spAnimationState_dispose (spAnimationState* self) { int i; _spAnimationState* internal = SUB_CAST(_spAnimationState, self); FREE(internal->events); for (i = 0; i < self->trackCount; i++) _spTrackEntry_disposeAll(self->tracks[i]); FREE(self->tracks); FREE(self); } void spAnimationState_update (spAnimationState* self, float delta) { int i; float trackDelta; delta *= self->timeScale; for (i = 0; i < self->trackCount; i++) { spTrackEntry* current = self->tracks[i]; if (!current) continue; trackDelta = delta * current->timeScale; current->time += trackDelta; if (current->previous) { current->previous->time += trackDelta; current->mixTime += trackDelta; } if (current->next) { if (current->lastTime >= current->next->delay) _spAnimationState_setCurrent(self, i, current->next); } else { /* End non-looping animation when it reaches its end time and there is no next entry. */ if (!current->loop && current->lastTime >= current->endTime) spAnimationState_clearTrack(self, i); } } } void spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) { _spAnimationState* internal = SUB_CAST(_spAnimationState, self); int i, ii; int eventCount; float time; spTrackEntry* previous; for (i = 0; i < self->trackCount; i++) { spTrackEntry* current = self->tracks[i]; if (!current) continue; eventCount = 0; time = current->time; if (!current->loop && time > current->endTime) time = current->endTime; previous = current->previous; if (!previous) { spAnimation_apply(current->animation, skeleton, current->lastTime, time, current->loop, internal->events, &eventCount); } else { float alpha = current->mixTime / current->mixDuration; float previousTime = previous->time; if (!previous->loop && previousTime > previous->endTime) previousTime = previous->endTime; spAnimation_apply(previous->animation, skeleton, previousTime, previousTime, previous->loop, 0, 0); if (alpha >= 1) { alpha = 1; _spTrackEntry_dispose(current->previous); current->previous = 0; } spAnimation_mix(current->animation, skeleton, current->lastTime, time, current->loop, internal->events, &eventCount, alpha); } for (ii = 0; ii < eventCount; ii++) { spEvent* event = internal->events[ii]; if (current->listener) current->listener(self, i, ANIMATION_EVENT, event, 0); if (self->listener) self->listener(self, i, ANIMATION_EVENT, event, 0); } /* Check if completed the animation or a loop iteration. */ if (current->loop ? (FMOD(current->lastTime, current->endTime) > FMOD(time, current->endTime)) // : (current->lastTime < current->endTime && time >= current->endTime)) { int count = (int)(time / current->endTime); if (current->listener) current->listener(self, i, ANIMATION_COMPLETE, 0, count); if (self->listener) self->listener(self, i, ANIMATION_COMPLETE, 0, count); if (i >= self->trackCount || self->tracks[i] != current) continue; } if (i >= self->trackCount || self->tracks[i] != current) continue; current->lastTime = current->time; } } void spAnimationState_clearTracks (spAnimationState* self) { int i; for (i = 0; i < self->trackCount; i++) spAnimationState_clearTrack(self, i); self->trackCount = 0; } void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) { spTrackEntry* current; if (trackIndex >= self->trackCount) return; current = self->tracks[trackIndex]; if (!current) return; if (current->listener) current->listener(self, trackIndex, ANIMATION_END, 0, 0); if (self->listener) self->listener(self, trackIndex, ANIMATION_END, 0, 0); self->tracks[trackIndex] = 0; if (current->previous) _spTrackEntry_dispose(current->previous); _spTrackEntry_disposeAll(current); } spTrackEntry* _spAnimationState_expandToIndex (spAnimationState* self, int index) { spTrackEntry** newTracks; if (index < self->trackCount) return self->tracks[index]; newTracks = CALLOC(spTrackEntry*, index + 1); memcpy(newTracks, self->tracks, self->trackCount * sizeof(spTrackEntry*)); FREE(self->tracks); self->tracks = newTracks; self->trackCount = index + 1; return 0; } void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* entry) { spTrackEntry* current = _spAnimationState_expandToIndex(self, index); if (current) { if (current->previous) { _spTrackEntry_dispose(current->previous); current->previous = 0; } if (current->listener) current->listener(self, index, ANIMATION_END, 0, 0); if (self->listener) self->listener(self, index, ANIMATION_END, 0, 0); entry->mixDuration = spAnimationStateData_getMix(self->data, current->animation, entry->animation); if (entry->mixDuration > 0) { entry->mixTime = 0; entry->previous = current; } else _spTrackEntry_dispose(current); } self->tracks[index] = entry; if (entry->listener) current->listener(self, index, ANIMATION_START, 0, 0); if (self->listener) self->listener(self, index, ANIMATION_START, 0, 0); } spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop) { spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName); return spAnimationState_setAnimation(self, trackIndex, animation, loop); } spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop) { spTrackEntry* entry; spTrackEntry* current = _spAnimationState_expandToIndex(self, trackIndex); if (current) _spTrackEntry_disposeAll(current->next); entry = _spTrackEntry_create(); entry->animation = animation; entry->loop = loop; entry->endTime = animation->duration; _spAnimationState_setCurrent(self, trackIndex, entry); return entry; } spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop, float delay) { spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName); return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay); } spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, float delay) { spTrackEntry* last; spTrackEntry* entry = _spTrackEntry_create(); entry->animation = animation; entry->loop = loop; entry->endTime = animation->duration; last = _spAnimationState_expandToIndex(self, trackIndex); if (last) { while (last->next) last = last->next; last->next = entry; } else self->tracks[trackIndex] = entry; if (delay <= 0) { if (last) delay += last->endTime - spAnimationStateData_getMix(self->data, last->animation, animation); else delay = 0; } entry->delay = delay; return entry; } spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex) { if (trackIndex >= self->trackCount) return 0; return self->tracks[trackIndex]; } ================================================ FILE: cocos2d/cocos/editor-support/spine/AnimationState.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_ANIMATIONSTATE_H_ #define SPINE_ANIMATIONSTATE_H_ #include #include #include #ifdef __cplusplus extern "C" { #endif typedef enum { ANIMATION_START, ANIMATION_END, ANIMATION_COMPLETE, ANIMATION_EVENT } spEventType; typedef struct spAnimationState spAnimationState; typedef void (*spAnimationStateListener) (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount); typedef struct spTrackEntry spTrackEntry; struct spTrackEntry { spTrackEntry* next; spTrackEntry* previous; spAnimation* animation; int/*bool*/loop; float delay, time, lastTime, endTime, timeScale; spAnimationStateListener listener; float mixTime, mixDuration; }; struct spAnimationState { spAnimationStateData* const data; float timeScale; spAnimationStateListener listener; void* context; int trackCount; spTrackEntry** tracks; }; /* @param data May be 0 for no mixing. */ spAnimationState* spAnimationState_create (spAnimationStateData* data); void spAnimationState_dispose (spAnimationState* self); void spAnimationState_update (spAnimationState* self, float delta); void spAnimationState_apply (spAnimationState* self, struct spSkeleton* skeleton); void spAnimationState_clearTracks (spAnimationState* self); void spAnimationState_clearTrack (spAnimationState* self, int trackIndex); /** Set the current animation. Any queued animations are cleared. */ spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop); spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop); /** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix * duration. */ spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop, float delay); spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, float delay); spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex); #ifdef SPINE_SHORT_NAMES typedef spEventType EventType; typedef spAnimationStateListener AnimationStateListener; typedef spTrackEntry TrackEntry; typedef spAnimationState AnimationState; #define AnimationState_create(...) spAnimationState_create(__VA_ARGS__) #define AnimationState_dispose(...) spAnimationState_dispose(__VA_ARGS__) #define AnimationState_update(...) spAnimationState_update(__VA_ARGS__) #define AnimationState_apply(...) spAnimationState_apply(__VA_ARGS__) #define AnimationState_clearTracks(...) spAnimationState_clearTracks(__VA_ARGS__) #define AnimationState_clearTrack(...) spAnimationState_clearTrack(__VA_ARGS__) #define AnimationState_setAnimationByName(...) spAnimationState_setAnimationByName(__VA_ARGS__) #define AnimationState_setAnimation(...) spAnimationState_setAnimation(__VA_ARGS__) #define AnimationState_addAnimationByName(...) spAnimationState_addAnimationByName(__VA_ARGS__) #define AnimationState_addAnimation(...) spAnimationState_addAnimation(__VA_ARGS__) #define AnimationState_getCurrent(...) spAnimationState_getCurrent(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_ANIMATIONSTATE_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/AnimationStateData.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include typedef struct _ToEntry _ToEntry; struct _ToEntry { spAnimation* animation; float duration; _ToEntry* next; }; _ToEntry* _ToEntry_create (spAnimation* to, float duration) { _ToEntry* self = NEW(_ToEntry); self->animation = to; self->duration = duration; return self; } void _ToEntry_dispose (_ToEntry* self) { FREE(self); } /**/ typedef struct _FromEntry _FromEntry; struct _FromEntry { spAnimation* animation; _ToEntry* toEntries; _FromEntry* next; }; _FromEntry* _FromEntry_create (spAnimation* from) { _FromEntry* self = NEW(_FromEntry); self->animation = from; return self; } void _FromEntry_dispose (_FromEntry* self) { FREE(self); } /**/ spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData) { spAnimationStateData* self = NEW(spAnimationStateData); CONST_CAST(spSkeletonData*, self->skeletonData) = skeletonData; return self; } void spAnimationStateData_dispose (spAnimationStateData* self) { _ToEntry* toEntry; _ToEntry* nextToEntry; _FromEntry* nextFromEntry; _FromEntry* fromEntry = (_FromEntry*)self->entries; while (fromEntry) { toEntry = fromEntry->toEntries; while (toEntry) { nextToEntry = toEntry->next; _ToEntry_dispose(toEntry); toEntry = nextToEntry; } nextFromEntry = fromEntry->next; _FromEntry_dispose(fromEntry); fromEntry = nextFromEntry; } FREE(self); } void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration) { spAnimation* to; spAnimation* from = spSkeletonData_findAnimation(self->skeletonData, fromName); if (!from) return; to = spSkeletonData_findAnimation(self->skeletonData, toName); if (!to) return; spAnimationStateData_setMix(self, from, to, duration); } void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration) { /* Find existing FromEntry. */ _ToEntry* toEntry; _FromEntry* fromEntry = (_FromEntry*)self->entries; while (fromEntry) { if (fromEntry->animation == from) { /* Find existing ToEntry. */ toEntry = fromEntry->toEntries; while (toEntry) { if (toEntry->animation == to) { toEntry->duration = duration; return; } toEntry = toEntry->next; } break; /* Add new ToEntry to the existing FromEntry. */ } fromEntry = fromEntry->next; } if (!fromEntry) { fromEntry = _FromEntry_create(from); fromEntry->next = (_FromEntry*)self->entries; CONST_CAST(_FromEntry*, self->entries) = fromEntry; } toEntry = _ToEntry_create(to, duration); toEntry->next = fromEntry->toEntries; fromEntry->toEntries = toEntry; } float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to) { _FromEntry* fromEntry = (_FromEntry*)self->entries; while (fromEntry) { if (fromEntry->animation == from) { _ToEntry* toEntry = fromEntry->toEntries; while (toEntry) { if (toEntry->animation == to) return toEntry->duration; toEntry = toEntry->next; } } fromEntry = fromEntry->next; } return self->defaultMix; } ================================================ FILE: cocos2d/cocos/editor-support/spine/AnimationStateData.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_ANIMATIONSTATEDATA_H_ #define SPINE_ANIMATIONSTATEDATA_H_ #include #include #ifdef __cplusplus extern "C" { #endif typedef struct { spSkeletonData* const skeletonData; float defaultMix; const void* const entries; } spAnimationStateData; spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData); void spAnimationStateData_dispose (spAnimationStateData* self); void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration); void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration); /* Returns 0 if there is no mixing between the animations. */ float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to); #ifdef SPINE_SHORT_NAMES typedef spAnimationStateData AnimationStateData; #define AnimationStateData_create(...) spAnimationStateData_create(__VA_ARGS__) #define AnimationStateData_dispose(...) spAnimationStateData_dispose(__VA_ARGS__) #define AnimationStateData_setMixByName(...) spAnimationStateData_setMixByName(__VA_ARGS__) #define AnimationStateData_setMix(...) spAnimationStateData_setMix(__VA_ARGS__) #define AnimationStateData_getMix(...) spAnimationStateData_getMix(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_ANIMATIONSTATEDATA_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/Atlas.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include spAtlasPage* spAtlasPage_create (const char* name) { spAtlasPage* self = NEW(spAtlasPage); MALLOC_STR(self->name, name); return self; } void spAtlasPage_dispose (spAtlasPage* self) { _spAtlasPage_disposeTexture(self); FREE(self->name); FREE(self); } /**/ spAtlasRegion* spAtlasRegion_create () { return NEW(spAtlasRegion) ; } void spAtlasRegion_dispose (spAtlasRegion* self) { FREE(self->name); FREE(self->splits); FREE(self->pads); FREE(self); } /**/ typedef struct { const char* begin; const char* end; } Str; static void trim (Str* str) { while (isspace(*str->begin) && str->begin < str->end) (str->begin)++; if (str->begin == str->end) return; str->end--; while (isspace(*str->end) && str->end >= str->begin) str->end--; str->end++; } /* Tokenize string without modification. Returns 0 on failure. */ static int readLine (const char* begin, const char* end, Str* str) { static const char* nextStart; if (begin) { nextStart = begin; return 1; } if (nextStart == end) return 0; str->begin = nextStart; /* Find next delimiter. */ while (nextStart != end && *nextStart != '\n') nextStart++; str->end = nextStart; trim(str); if (nextStart != end) nextStart++; return 1; } /* Moves str->begin past the first occurence of c. Returns 0 on failure. */ static int beginPast (Str* str, char c) { const char* begin = str->begin; while (1) { char lastSkippedChar = *begin; if (begin == str->end) return 0; begin++; if (lastSkippedChar == c) break; } str->begin = begin; return 1; } /* Returns 0 on failure. */ static int readValue (const char* end, Str* str) { readLine(0, end, str); if (!beginPast(str, ':')) return 0; trim(str); return 1; } /* Returns the number of tuple values read (2, 4, or 0 for failure). */ static int readTuple (const char* end, Str tuple[]) { int i; Str str; readLine(0, end, &str); if (!beginPast(&str, ':')) return 0; for (i = 0; i < 3; ++i) { tuple[i].begin = str.begin; if (!beginPast(&str, ',')) { if (i == 0) return 0; break; } tuple[i].end = str.begin - 2; trim(&tuple[i]); } tuple[i].begin = str.begin; tuple[i].end = str.end; trim(&tuple[i]); return i + 1; } static char* mallocString (Str* str) { long length = str->end - str->begin; char* string = MALLOC(char, length + 1); memcpy(string, str->begin, length); string[length] = '\0'; return string; } static int indexOf (const char** array, int count, Str* str) { long length = str->end - str->begin; int i; for (i = count - 1; i >= 0; i--) if (strncmp(array[i], str->begin, length) == 0) return i; return -1; } static int equals (Str* str, const char* other) { return strncmp(other, str->begin, str->end - str->begin) == 0; } static int toInt (Str* str) { return static_cast(strtol(str->begin, (char**)&str->end, 10)); } static spAtlas* abortAtlas (spAtlas* self) { spAtlas_dispose(self); return 0; } static const char* formatNames[] = {"Alpha", "Intensity", "LuminanceAlpha", "RGB565", "RGBA4444", "RGB888", "RGBA8888"}; static const char* textureFilterNames[] = {"Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest", "MipMapNearestLinear", "MipMapLinearLinear"}; spAtlas* spAtlas_readAtlas (const char* begin, int length, const char* dir) { int count; const char* end = begin + length; size_t dirLength = strlen(dir); int needsSlash = dirLength > 0 && dir[dirLength - 1] != '/' && dir[dirLength - 1] != '\\'; spAtlas* self = NEW(spAtlas); spAtlasPage *page = 0; spAtlasPage *lastPage = 0; spAtlasRegion *lastRegion = 0; Str str; Str tuple[4]; readLine(begin, 0, 0); while (readLine(0, end, &str)) { if (str.end - str.begin == 0) { page = 0; } else if (!page) { char* name = mallocString(&str); char* path = MALLOC(char, dirLength + needsSlash + strlen(name) + 1); memcpy(path, dir, dirLength); if (needsSlash) path[dirLength] = '/'; strcpy(path + dirLength + needsSlash, name); page = spAtlasPage_create(name); FREE(name); if (lastPage) lastPage->next = page; else self->pages = page; lastPage = page; if (!readValue(end, &str)) return abortAtlas(self); page->format = (spAtlasFormat)indexOf(formatNames, 7, &str); if (!readTuple(end, tuple)) return abortAtlas(self); page->minFilter = (spAtlasFilter)indexOf(textureFilterNames, 7, tuple); page->magFilter = (spAtlasFilter)indexOf(textureFilterNames, 7, tuple + 1); if (!readValue(end, &str)) return abortAtlas(self); if (!equals(&str, "none")) { page->uWrap = *str.begin == 'x' ? ATLAS_REPEAT : (*str.begin == 'y' ? ATLAS_CLAMPTOEDGE : ATLAS_REPEAT); page->vWrap = *str.begin == 'x' ? ATLAS_CLAMPTOEDGE : (*str.begin == 'y' ? ATLAS_REPEAT : ATLAS_REPEAT); } _spAtlasPage_createTexture(page, path); FREE(path); } else { spAtlasRegion *region = spAtlasRegion_create(); if (lastRegion) lastRegion->next = region; else self->regions = region; lastRegion = region; region->page = page; region->name = mallocString(&str); if (!readValue(end, &str)) return abortAtlas(self); region->rotate = equals(&str, "true"); if (readTuple(end, tuple) != 2) return abortAtlas(self); region->x = toInt(tuple); region->y = toInt(tuple + 1); if (readTuple(end, tuple) != 2) return abortAtlas(self); region->width = toInt(tuple); region->height = toInt(tuple + 1); region->u = region->x / (float)page->width; region->v = region->y / (float)page->height; if (region->rotate) { region->u2 = (region->x + region->height) / (float)page->width; region->v2 = (region->y + region->width) / (float)page->height; } else { region->u2 = (region->x + region->width) / (float)page->width; region->v2 = (region->y + region->height) / (float)page->height; } if (!(count = readTuple(end, tuple))) return abortAtlas(self); if (count == 4) { /* split is optional */ region->splits = MALLOC(int, 4); region->splits[0] = toInt(tuple); region->splits[1] = toInt(tuple + 1); region->splits[2] = toInt(tuple + 2); region->splits[3] = toInt(tuple + 3); if (!(count = readTuple(end, tuple))) return abortAtlas(self); if (count == 4) { /* pad is optional, but only present with splits */ region->pads = MALLOC(int, 4); region->pads[0] = toInt(tuple); region->pads[1] = toInt(tuple + 1); region->pads[2] = toInt(tuple + 2); region->pads[3] = toInt(tuple + 3); if (!readTuple(end, tuple)) return abortAtlas(self); } } region->originalWidth = toInt(tuple); region->originalHeight = toInt(tuple + 1); readTuple(end, tuple); region->offsetX = toInt(tuple); region->offsetY = toInt(tuple + 1); if (!readValue(end, &str)) return abortAtlas(self); region->index = toInt(&str); } } return self; } spAtlas* spAtlas_readAtlasFile (const char* path) { long dirLength; char *dir; int length; const char* data; spAtlas* atlas = 0; /* Get directory from atlas path. */ const char* lastForwardSlash = strrchr(path, '/'); const char* lastBackwardSlash = strrchr(path, '\\'); const char* lastSlash = lastForwardSlash > lastBackwardSlash ? lastForwardSlash : lastBackwardSlash; if (lastSlash == path) lastSlash++; /* Never drop starting slash. */ dirLength = lastSlash ? lastSlash - path : 0; dir = MALLOC(char, dirLength + 1); memcpy(dir, path, dirLength); dir[dirLength] = '\0'; data = _spUtil_readFile(path, &length); if (data) atlas = spAtlas_readAtlas(data, length, dir); FREE(data); FREE(dir); return atlas; } void spAtlas_dispose (spAtlas* self) { spAtlasRegion* region, *nextRegion; spAtlasPage* page = self->pages; while (page) { spAtlasPage* nextPage = page->next; spAtlasPage_dispose(page); page = nextPage; } region = self->regions; while (region) { nextRegion = region->next; spAtlasRegion_dispose(region); region = nextRegion; } FREE(self); } spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name) { spAtlasRegion* region = self->regions; while (region) { if (strcmp(region->name, name) == 0) return region; region = region->next; } return 0; } ================================================ FILE: cocos2d/cocos/editor-support/spine/Atlas.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_ATLAS_H_ #define SPINE_ATLAS_H_ #ifdef __cplusplus extern "C" { #endif typedef enum { ATLAS_ALPHA, ATLAS_INTENSITY, ATLAS_LUMINANCE_ALPHA, ATLAS_RGB565, ATLAS_RGBA4444, ATLAS_RGB888, ATLAS_RGBA8888 } spAtlasFormat; typedef enum { ATLAS_NEAREST, ATLAS_LINEAR, ATLAS_MIPMAP, ATLAS_MIPMAP_NEAREST_NEAREST, ATLAS_MIPMAP_LINEAR_NEAREST, ATLAS_MIPMAP_NEAREST_LINEAR, ATLAS_MIPMAP_LINEAR_LINEAR } spAtlasFilter; typedef enum { ATLAS_MIRROREDREPEAT, ATLAS_CLAMPTOEDGE, ATLAS_REPEAT } spAtlasWrap; typedef struct spAtlasPage spAtlasPage; struct spAtlasPage { const char* name; spAtlasFormat format; spAtlasFilter minFilter, magFilter; spAtlasWrap uWrap, vWrap; void* rendererObject; int width, height; spAtlasPage* next; }; spAtlasPage* spAtlasPage_create (const char* name); void spAtlasPage_dispose (spAtlasPage* self); #ifdef SPINE_SHORT_NAMES typedef spAtlasFormat AtlasFormat; typedef spAtlasFilter AtlasFilter; typedef spAtlasWrap AtlasWrap; typedef spAtlasPage AtlasPage; #define AtlasPage_create(...) spAtlasPage_create(__VA_ARGS__) #define AtlasPage_dispose(...) spAtlasPage_dispose(__VA_ARGS__) #endif /**/ typedef struct spAtlasRegion spAtlasRegion; struct spAtlasRegion { const char* name; int x, y, width, height; float u, v, u2, v2; int offsetX, offsetY; int originalWidth, originalHeight; int index; int/*bool*/rotate; int/*bool*/flip; int* splits; int* pads; spAtlasPage* page; spAtlasRegion* next; }; spAtlasRegion* spAtlasRegion_create (); void spAtlasRegion_dispose (spAtlasRegion* self); #ifdef SPINE_SHORT_NAMES typedef spAtlasRegion AtlasRegion; #define AtlasRegion_create(...) spAtlasRegion_create(__VA_ARGS__) #define AtlasRegion_dispose(...) spAtlasRegion_dispose(__VA_ARGS__) #endif /**/ typedef struct { spAtlasPage* pages; spAtlasRegion* regions; } spAtlas; /* Image files referenced in the atlas file will be prefixed with dir. */ spAtlas* spAtlas_readAtlas (const char* data, int length, const char* dir); /* Image files referenced in the atlas file will be prefixed with the directory containing the atlas file. */ spAtlas* spAtlas_readAtlasFile (const char* path); void spAtlas_dispose (spAtlas* atlas); /* Returns 0 if the region was not found. */ spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name); #ifdef SPINE_SHORT_NAMES typedef spAtlas Atlas; #define Atlas_readAtlas(...) spAtlas_readAtlas(__VA_ARGS__) #define Atlas_readAtlasFile(...) spAtlas_readAtlasFile(__VA_ARGS__) #define Atlas_dispose(...) spAtlas_dispose(__VA_ARGS__) #define Atlas_findRegion(...) spAtlas_findRegion(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_ATLAS_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/AtlasAttachmentLoader.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include spAttachment* _spAtlasAttachmentLoader_newAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type, const char* name) { spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader); switch (type) { case ATTACHMENT_REGION: { spRegionAttachment* attachment; spAtlasRegion* region = spAtlas_findRegion(self->atlas, name); if (!region) { _spAttachmentLoader_setError(loader, "Region not found: ", name); return 0; } attachment = spRegionAttachment_create(name); attachment->rendererObject = region; spRegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate); attachment->regionOffsetX = region->offsetX; attachment->regionOffsetY = region->offsetY; attachment->regionWidth = region->width; attachment->regionHeight = region->height; attachment->regionOriginalWidth = region->originalWidth; attachment->regionOriginalHeight = region->originalHeight; return SUPER(attachment); } case ATTACHMENT_BOUNDING_BOX: return SUPER(spBoundingBoxAttachment_create(name)); default: _spAttachmentLoader_setUnknownTypeError(loader, type); return 0; } } spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas) { spAtlasAttachmentLoader* self = NEW(spAtlasAttachmentLoader); _spAttachmentLoader_init(SUPER(self), _spAttachmentLoader_deinit, _spAtlasAttachmentLoader_newAttachment); self->atlas = atlas; return self; } ================================================ FILE: cocos2d/cocos/editor-support/spine/AtlasAttachmentLoader.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_ATLASATTACHMENTLOADER_H_ #define SPINE_ATLASATTACHMENTLOADER_H_ #include #include #ifdef __cplusplus extern "C" { #endif typedef struct { spAttachmentLoader super; spAtlas* atlas; } spAtlasAttachmentLoader; spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas); #ifdef SPINE_SHORT_NAMES typedef spAtlasAttachmentLoader AtlasAttachmentLoader; #define AtlasAttachmentLoader_create(...) spAtlasAttachmentLoader_create(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_ATLASATTACHMENTLOADER_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/Attachment.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include typedef struct _spAttachmentVtable { void (*dispose) (spAttachment* self); } _spAttachmentVtable; void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/ void (*dispose) (spAttachment* self)) { CONST_CAST(_spAttachmentVtable*, self->vtable) = NEW(_spAttachmentVtable); VTABLE(spAttachment, self) ->dispose = dispose; MALLOC_STR(self->name, name); self->type = type; } void _spAttachment_deinit (spAttachment* self) { FREE(self->vtable); FREE(self->name); } void spAttachment_dispose (spAttachment* self) { VTABLE(spAttachment, self) ->dispose(self); } ================================================ FILE: cocos2d/cocos/editor-support/spine/Attachment.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_ATTACHMENT_H_ #define SPINE_ATTACHMENT_H_ #ifdef __cplusplus extern "C" { #endif struct spSlot; typedef enum { ATTACHMENT_REGION, ATTACHMENT_REGION_SEQUENCE, ATTACHMENT_BOUNDING_BOX } spAttachmentType; typedef struct spAttachment spAttachment; struct spAttachment { const char* const name; spAttachmentType type; const void* const vtable; }; void spAttachment_dispose (spAttachment* self); #ifdef SPINE_SHORT_NAMES typedef spAttachmentType AttachmentType; typedef spAttachment Attachment; #define Attachment_dispose(...) spAttachment_dispose(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_ATTACHMENT_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/AttachmentLoader.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include typedef struct _spAttachmentLoaderVtable { spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name); void (*dispose) (spAttachmentLoader* self); } _spAttachmentLoaderVtable; void _spAttachmentLoader_init (spAttachmentLoader* self, /**/ void (*dispose) (spAttachmentLoader* self), /**/ spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name)) { CONST_CAST(_spAttachmentLoaderVtable*, self->vtable) = NEW(_spAttachmentLoaderVtable); VTABLE(spAttachmentLoader, self)->dispose = dispose; VTABLE(spAttachmentLoader, self)->newAttachment = newAttachment; } void _spAttachmentLoader_deinit (spAttachmentLoader* self) { FREE(self->vtable); FREE(self->error1); FREE(self->error2); } void spAttachmentLoader_dispose (spAttachmentLoader* self) { VTABLE(spAttachmentLoader, self)->dispose(self); FREE(self); } spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name) { FREE(self->error1); FREE(self->error2); self->error1 = 0; self->error2 = 0; return VTABLE(spAttachmentLoader, self)->newAttachment(self, skin, type, name); } void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2) { FREE(self->error1); FREE(self->error2); MALLOC_STR(self->error1, error1); MALLOC_STR(self->error2, error2); } void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type) { char buffer[16]; sprintf(buffer, "%d", type); _spAttachmentLoader_setError(self, "Unknown attachment type: ", buffer); } ================================================ FILE: cocos2d/cocos/editor-support/spine/AttachmentLoader.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_ATTACHMENTLOADER_H_ #define SPINE_ATTACHMENTLOADER_H_ #include #include #ifdef __cplusplus extern "C" { #endif typedef struct spAttachmentLoader spAttachmentLoader; struct spAttachmentLoader { const char* error1; const char* error2; const void* const vtable; #ifdef __cplusplus spAttachmentLoader () : error1(0), error2(0), vtable(0) { } #endif }; void spAttachmentLoader_dispose (spAttachmentLoader* self); /* Returns 0 to not load an attachment. If 0 is returned and spAttachmentLoader.error1 is set, an error occurred. */ spAttachment* spAttachmentLoader_newAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name); #ifdef SPINE_SHORT_NAMES typedef spAttachmentLoader AttachmentLoader; #define AttachmentLoader_dispose(...) spAttachmentLoader_dispose(__VA_ARGS__) #define AttachmentLoader_newAttachment(...) spAttachmentLoader_newAttachment(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_ATTACHMENTLOADER_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/Bone.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include static int yDown; void spBone_setYDown (int value) { yDown = value; } spBone* spBone_create (spBoneData* data, spBone* parent) { spBone* self = NEW(spBone); CONST_CAST(spBoneData*, self->data) = data; CONST_CAST(spBone*, self->parent) = parent; spBone_setToSetupPose(self); return self; } void spBone_dispose (spBone* self) { FREE(self); } void spBone_setToSetupPose (spBone* self) { self->x = self->data->x; self->y = self->data->y; self->rotation = self->data->rotation; self->scaleX = self->data->scaleX; self->scaleY = self->data->scaleY; } void spBone_updateWorldTransform (spBone* self, int flipX, int flipY) { float radians, cosine, sine; if (self->parent) { CONST_CAST(float, self->worldX) = self->x * self->parent->m00 + self->y * self->parent->m01 + self->parent->worldX; CONST_CAST(float, self->worldY) = self->x * self->parent->m10 + self->y * self->parent->m11 + self->parent->worldY; if (self->data->inheritScale) { CONST_CAST(float, self->worldScaleX) = self->parent->worldScaleX * self->scaleX; CONST_CAST(float, self->worldScaleY) = self->parent->worldScaleY * self->scaleY; } else { CONST_CAST(float, self->worldScaleX) = self->scaleX; CONST_CAST(float, self->worldScaleY) = self->scaleY; } CONST_CAST(float, self->worldRotation) = self->data->inheritRotation ? self->parent->worldRotation + self->rotation : self->rotation; } else { CONST_CAST(float, self->worldX) = flipX ? -self->x : self->x; CONST_CAST(float, self->worldY) = (flipY && flipY != yDown) ? -self->y : self->y; CONST_CAST(float, self->worldScaleX) = self->scaleX; CONST_CAST(float, self->worldScaleY) = self->scaleY; CONST_CAST(float, self->worldRotation) = self->rotation; } radians = (float)(self->worldRotation * 3.1415926535897932385 / 180); #ifdef __STDC_VERSION__ cosine = cosf(radians); sine = sinf(radians); #else cosine = (float)cos(radians); sine = (float)sin(radians); #endif CONST_CAST(float, self->m00) = cosine * self->worldScaleX; CONST_CAST(float, self->m10) = sine * self->worldScaleX; CONST_CAST(float, self->m01) = -sine * self->worldScaleY; CONST_CAST(float, self->m11) = cosine * self->worldScaleY; if (flipX) { CONST_CAST(float, self->m00) = -self->m00; CONST_CAST(float, self->m01) = -self->m01; } if (flipY != yDown) { CONST_CAST(float, self->m10) = -self->m10; CONST_CAST(float, self->m11) = -self->m11; } } ================================================ FILE: cocos2d/cocos/editor-support/spine/Bone.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_BONE_H_ #define SPINE_BONE_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct spBone spBone; struct spBone { spBoneData* const data; spBone* const parent; float x, y; float rotation; float scaleX, scaleY; float const m00, m01, worldX; /* a b x */ float const m10, m11, worldY; /* c d y */ float const worldRotation; float const worldScaleX, worldScaleY; }; void spBone_setYDown (int/*bool*/yDown); /* @param parent May be 0. */ spBone* spBone_create (spBoneData* data, spBone* parent); void spBone_dispose (spBone* self); void spBone_setToSetupPose (spBone* self); void spBone_updateWorldTransform (spBone* self, int/*bool*/flipX, int/*bool*/flipY); #ifdef SPINE_SHORT_NAMES typedef spBone Bone; #define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__) #define Bone_create(...) spBone_create(__VA_ARGS__) #define Bone_dispose(...) spBone_dispose(__VA_ARGS__) #define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__) #define Bone_updateWorldTransform(...) spBone_updateWorldTransform(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_BONE_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/BoneData.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include spBoneData* spBoneData_create (const char* name, spBoneData* parent) { spBoneData* self = NEW(spBoneData); MALLOC_STR(self->name, name); CONST_CAST(spBoneData*, self->parent) = parent; self->scaleX = 1; self->scaleY = 1; self->inheritScale = 1; self->inheritRotation = 1; return self; } void spBoneData_dispose (spBoneData* self) { FREE(self->name); FREE(self); } ================================================ FILE: cocos2d/cocos/editor-support/spine/BoneData.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_BONEDATA_H_ #define SPINE_BONEDATA_H_ #ifdef __cplusplus extern "C" { #endif typedef struct spBoneData spBoneData; struct spBoneData { const char* const name; spBoneData* const parent; float length; float x, y; float rotation; float scaleX, scaleY; int/*bool*/inheritScale, inheritRotation; }; spBoneData* spBoneData_create (const char* name, spBoneData* parent); void spBoneData_dispose (spBoneData* self); #ifdef SPINE_SHORT_NAMES typedef spBoneData BoneData; #define BoneData_create(...) spBoneData_create(__VA_ARGS__) #define BoneData_dispose(...) spBoneData_dispose(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_BONEDATA_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/BoundingBoxAttachment.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include void _spBoundingBoxAttachment_dispose (spAttachment* attachment) { spBoundingBoxAttachment* self = SUB_CAST(spBoundingBoxAttachment, attachment); _spAttachment_deinit(attachment); FREE(self->vertices); FREE(self); } spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name) { spBoundingBoxAttachment* self = NEW(spBoundingBoxAttachment); _spAttachment_init(SUPER(self), name, ATTACHMENT_BOUNDING_BOX, _spBoundingBoxAttachment_dispose); return self; } void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, float x, float y, spBone* bone, float* worldVertices) { int i; float px, py; float* vertices = self->vertices; x += bone->worldX; y += bone->worldY; for (i = 0; i < self->verticesCount; i += 2) { px = vertices[i]; py = vertices[i + 1]; worldVertices[i] = px * bone->m00 + py * bone->m01 + x; worldVertices[i + 1] = px * bone->m10 + py * bone->m11 + y; } } ================================================ FILE: cocos2d/cocos/editor-support/spine/BoundingBoxAttachment.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_BOUNDINGBOXATTACHMENT_H_ #define SPINE_BOUNDINGBOXATTACHMENT_H_ #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct spBoundingBoxAttachment spBoundingBoxAttachment; struct spBoundingBoxAttachment { spAttachment super; int verticesCount; float* vertices; }; spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name); void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, float x, float y, spBone* bone, float* vertices); #ifdef SPINE_SHORT_NAMES typedef spBoundingBoxAttachment BoundingBoxAttachment; #define BoundingBoxAttachment_create(...) spBoundingBoxAttachment_create(__VA_ARGS__) #define BoundingBoxAttachment_computeWorldVertices(...) spBoundingBoxAttachment_computeWorldVertices(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_BOUNDINGBOXATTACHMENT_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/CCSkeleton.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include USING_NS_CC; using std::min; using std::max; namespace spine { Skeleton* Skeleton::createWithData (spSkeletonData* skeletonData, bool isOwnsSkeletonData) { Skeleton* node = new Skeleton(skeletonData, isOwnsSkeletonData); node->autorelease(); return node; } Skeleton* Skeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) { Skeleton* node = new Skeleton(skeletonDataFile, atlas, scale); node->autorelease(); return node; } Skeleton* Skeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) { Skeleton* node = new Skeleton(skeletonDataFile, atlasFile, scale); node->autorelease(); return node; } void Skeleton::initialize () { atlas = 0; debugSlots = false; debugBones = false; timeScale = 1; blendFunc.src = BlendFunc::ALPHA_PREMULTIPLIED.src; blendFunc.dst = BlendFunc::ALPHA_PREMULTIPLIED.dst; setOpacityModifyRGB(true); setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); scheduleUpdate(); } void Skeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) { skeleton = spSkeleton_create(skeletonData); rootBone = skeleton->bones[0]; this->ownsSkeletonData = isOwnsSkeletonData; } Skeleton::Skeleton () { initialize(); } Skeleton::Skeleton (spSkeletonData *skeletonData, bool isOwnsSkeletonData) { initialize(); setSkeletonData(skeletonData, isOwnsSkeletonData); } Skeleton::Skeleton (const char* skeletonDataFile, spAtlas* aAtlas, float scale) { initialize(); spSkeletonJson* json = spSkeletonJson_create(aAtlas); json->scale = scale == 0 ? (1 / Director::getInstance()->getContentScaleFactor()) : scale; spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile); CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data."); spSkeletonJson_dispose(json); setSkeletonData(skeletonData, true); } Skeleton::Skeleton (const char* skeletonDataFile, const char* atlasFile, float scale) { initialize(); atlas = spAtlas_readAtlasFile(atlasFile); CCAssert(atlas, "Error reading atlas file."); spSkeletonJson* json = spSkeletonJson_create(atlas); json->scale = scale == 0 ? (1 / Director::getInstance()->getContentScaleFactor()) : scale; spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile); CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data file."); spSkeletonJson_dispose(json); setSkeletonData(skeletonData, true); } Skeleton::~Skeleton () { if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data); if (atlas) spAtlas_dispose(atlas); spSkeleton_dispose(skeleton); } void Skeleton::update (float deltaTime) { spSkeleton_update(skeleton, deltaTime * timeScale); } void Skeleton::draw() { kmGLMatrixMode(KM_GL_MODELVIEW); kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix); _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } void Skeleton::onDraw () { kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPushMatrix(); kmGLLoadMatrix(&_oldTransMatrix); CC_NODE_DRAW_SETUP(); GL::blendFunc(blendFunc.src, blendFunc.dst); Color3B color = getColor(); skeleton->r = color.r / (float)255; skeleton->g = color.g / (float)255; skeleton->b = color.b / (float)255; skeleton->a = getOpacity() / (float)255; if (premultipliedAlpha) { skeleton->r *= skeleton->a; skeleton->g *= skeleton->a; skeleton->b *= skeleton->a; } int additive = 0; TextureAtlas* textureAtlas = 0; V3F_C4B_T2F_Quad quad; quad.tl.vertices.z = 0; quad.tr.vertices.z = 0; quad.bl.vertices.z = 0; quad.br.vertices.z = 0; for (int i = 0, n = skeleton->slotCount; i < n; i++) { spSlot* slot = skeleton->drawOrder[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment); if (slot->data->additiveBlending != additive) { if (textureAtlas) { textureAtlas->drawQuads(); textureAtlas->removeAllQuads(); } additive = !additive; GL::blendFunc(blendFunc.src, additive ? GL_ONE : blendFunc.dst); } else if (regionTextureAtlas != textureAtlas && textureAtlas) { textureAtlas->drawQuads(); textureAtlas->removeAllQuads(); } textureAtlas = regionTextureAtlas; setFittedBlendingFunc(textureAtlas); ssize_t quadCount = textureAtlas->getTotalQuads(); if (textureAtlas->getCapacity() == quadCount) { textureAtlas->drawQuads(); textureAtlas->removeAllQuads(); if (!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return; } spRegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha); textureAtlas->updateQuad(&quad, quadCount); } if (textureAtlas) { textureAtlas->drawQuads(); textureAtlas->removeAllQuads(); } if (debugSlots) { // Slots. DrawPrimitives::setDrawColor4B(0, 0, 255, 255); glLineWidth(1); Point points[4]; V3F_C4B_T2F_Quad tmpQuad; for (int i = 0, n = skeleton->slotCount; i < n; i++) { spSlot* slot = skeleton->drawOrder[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; spRegionAttachment_updateQuad(attachment, slot, &tmpQuad); points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y); points[1] = Point(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y); points[2] = Point(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y); points[3] = Point(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y); DrawPrimitives::drawPoly(points, 4, true); } } if (debugBones) { // Bone lengths. glLineWidth(2); DrawPrimitives::setDrawColor4B(255, 0, 0, 255); for (int i = 0, n = skeleton->boneCount; i < n; i++) { spBone *bone = skeleton->bones[i]; float x = bone->data->length * bone->m00 + bone->worldX; float y = bone->data->length * bone->m10 + bone->worldY; DrawPrimitives::drawLine(Point(bone->worldX, bone->worldY), Point(x, y)); } // Bone origins. DrawPrimitives::setPointSize(4); DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue. for (int i = 0, n = skeleton->boneCount; i < n; i++) { spBone *bone = skeleton->bones[i]; DrawPrimitives::drawPoint(Point(bone->worldX, bone->worldY)); if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255); } } kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPopMatrix(); } TextureAtlas* Skeleton::getTextureAtlas (spRegionAttachment* regionAttachment) const { return (TextureAtlas*)((spAtlasRegion*)regionAttachment->rendererObject)->page->rendererObject; } Rect Skeleton::getBoundingBox () const { float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN; float scaleX = getScaleX(); float scaleY = getScaleY(); float vertices[8]; for (int i = 0; i < skeleton->slotCount; ++i) { spSlot* slot = skeleton->slots[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices); minX = min(minX, vertices[VERTEX_X1] * scaleX); minY = min(minY, vertices[VERTEX_Y1] * scaleY); maxX = max(maxX, vertices[VERTEX_X1] * scaleX); maxY = max(maxY, vertices[VERTEX_Y1] * scaleY); minX = min(minX, vertices[VERTEX_X4] * scaleX); minY = min(minY, vertices[VERTEX_Y4] * scaleY); maxX = max(maxX, vertices[VERTEX_X4] * scaleX); maxY = max(maxY, vertices[VERTEX_Y4] * scaleY); minX = min(minX, vertices[VERTEX_X2] * scaleX); minY = min(minY, vertices[VERTEX_Y2] * scaleY); maxX = max(maxX, vertices[VERTEX_X2] * scaleX); maxY = max(maxY, vertices[VERTEX_Y2] * scaleY); minX = min(minX, vertices[VERTEX_X3] * scaleX); minY = min(minY, vertices[VERTEX_Y3] * scaleY); maxX = max(maxX, vertices[VERTEX_X3] * scaleX); maxY = max(maxY, vertices[VERTEX_Y3] * scaleY); } Point position = getPosition(); return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY); } // --- Convenience methods for Skeleton_* functions. void Skeleton::updateWorldTransform () { spSkeleton_updateWorldTransform(skeleton); } void Skeleton::setToSetupPose () { spSkeleton_setToSetupPose(skeleton); } void Skeleton::setBonesToSetupPose () { spSkeleton_setBonesToSetupPose(skeleton); } void Skeleton::setSlotsToSetupPose () { spSkeleton_setSlotsToSetupPose(skeleton); } spBone* Skeleton::findBone (const char* boneName) const { return spSkeleton_findBone(skeleton, boneName); } spSlot* Skeleton::findSlot (const char* slotName) const { return spSkeleton_findSlot(skeleton, slotName); } bool Skeleton::setSkin (const char* skinName) { return spSkeleton_setSkinByName(skeleton, skinName) ? true : false; } spAttachment* Skeleton::getAttachment (const char* slotName, const char* attachmentName) const { return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName); } bool Skeleton::setAttachment (const char* slotName, const char* attachmentName) { return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false; } // --- CCBlendProtocol const cocos2d::BlendFunc& Skeleton::getBlendFunc () const { return blendFunc; } void Skeleton::setBlendFunc (const cocos2d::BlendFunc& aBlendFunc) { this->blendFunc = aBlendFunc; } void Skeleton::setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture) { if(nextRenderedTexture->getTexture() && nextRenderedTexture->getTexture()->hasPremultipliedAlpha()) { GL::blendFunc(BlendFunc::ALPHA_PREMULTIPLIED.src, BlendFunc::ALPHA_PREMULTIPLIED.dst); } else { GL::blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED.src, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst); } } } ================================================ FILE: cocos2d/cocos/editor-support/spine/CCSkeleton.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_CCSKELETON_H_ #define SPINE_CCSKELETON_H_ #include #include "CCNode.h" #include "CCProtocols.h" #include "CCTextureAtlas.h" #include "renderer/CCCustomCommand.h" namespace spine { /** Draws a skeleton. */ class Skeleton: public cocos2d::Node, public cocos2d::BlendProtocol { public: spSkeleton* skeleton; spBone* rootBone; float timeScale; bool debugSlots; bool debugBones; bool premultipliedAlpha; cocos2d::BlendFunc blendFunc; static Skeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false); static Skeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); static Skeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0); Skeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false); Skeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); Skeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 0); virtual ~Skeleton (); virtual void update (float deltaTime) override; virtual void draw() override; void onDraw(); virtual cocos2d::Rect getBoundingBox () const override; // --- Convenience methods for common Skeleton_* functions. void updateWorldTransform (); void setToSetupPose (); void setBonesToSetupPose (); void setSlotsToSetupPose (); /* Returns 0 if the bone was not found. */ spBone* findBone (const char* boneName) const; /* Returns 0 if the slot was not found. */ spSlot* findSlot (const char* slotName) const; /* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are * attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found. * @param skin May be 0.*/ bool setSkin (const char* skinName); /* Returns 0 if the slot or attachment was not found. */ spAttachment* getAttachment (const char* slotName, const char* attachmentName) const; /* Returns false if the slot or attachment was not found. */ bool setAttachment (const char* slotName, const char* attachmentName); // --- CCBlendProtocol virtual const cocos2d::BlendFunc& getBlendFunc() const override; virtual void setBlendFunc(const cocos2d::BlendFunc& func) override; protected: Skeleton (); void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData); virtual cocos2d::TextureAtlas* getTextureAtlas (spRegionAttachment* regionAttachment) const; private: bool ownsSkeletonData; spAtlas* atlas; void initialize (); // Util function that setting blend-function by nextRenderedTexture's premultiplied flag void setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture); cocos2d::CustomCommand _customCommand; kmMat4 _oldTransMatrix; }; } #endif /* SPINE_CCSKELETON_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/CCSkeletonAnimation.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include USING_NS_CC; using std::min; using std::max; using std::vector; namespace spine { static void callback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) { ((SkeletonAnimation*)state->context)->onAnimationStateEvent(trackIndex, type, event, loopCount); } SkeletonAnimation* SkeletonAnimation::createWithData (spSkeletonData* skeletonData) { SkeletonAnimation* node = new SkeletonAnimation(skeletonData); node->autorelease(); return node; } SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) { SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlas, scale); node->autorelease(); return node; } SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) { SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlasFile, scale); node->autorelease(); return node; } void SkeletonAnimation::initialize () { listenerInstance = 0; listenerMethod = 0; ownsAnimationStateData = true; state = spAnimationState_create(spAnimationStateData_create(skeleton->data)); state->context = this; state->listener = callback; } SkeletonAnimation::SkeletonAnimation (spSkeletonData *skeletonData) : Skeleton(skeletonData) { initialize(); } SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale) : Skeleton(skeletonDataFile, atlas, scale) { initialize(); } SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale) : Skeleton(skeletonDataFile, atlasFile, scale) { initialize(); } SkeletonAnimation::~SkeletonAnimation () { if (ownsAnimationStateData) spAnimationStateData_dispose(state->data); spAnimationState_dispose(state); } void SkeletonAnimation::update (float deltaTime) { super::update(deltaTime); deltaTime *= timeScale; spAnimationState_update(state, deltaTime); spAnimationState_apply(state, skeleton); spSkeleton_updateWorldTransform(skeleton); } void SkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) { CCAssert(stateData, "stateData cannot be null."); if (ownsAnimationStateData) spAnimationStateData_dispose(state->data); spAnimationState_dispose(state); ownsAnimationStateData = false; state = spAnimationState_create(stateData); state->context = this; state->listener = callback; } void SkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) { spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration); } void SkeletonAnimation::setAnimationListener (Object* instance, SEL_AnimationStateEvent method) { listenerInstance = instance; listenerMethod = method; } spTrackEntry* SkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) { spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name); if (!animation) { log("Spine: Animation not found: %s", name); return 0; } return spAnimationState_setAnimation(state, trackIndex, animation, loop); } spTrackEntry* SkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) { spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name); if (!animation) { log("Spine: Animation not found: %s", name); return 0; } return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay); } spTrackEntry* SkeletonAnimation::getCurrent (int trackIndex) { return spAnimationState_getCurrent(state, trackIndex); } void SkeletonAnimation::clearTracks () { spAnimationState_clearTracks(state); } void SkeletonAnimation::clearTrack (int trackIndex) { spAnimationState_clearTrack(state, trackIndex); } void SkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) { if (listenerInstance) (listenerInstance->*listenerMethod)(this, trackIndex, type, event, loopCount); } } ================================================ FILE: cocos2d/cocos/editor-support/spine/CCSkeletonAnimation.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_CCSKELETONANIMATION_H_ #define SPINE_CCSKELETONANIMATION_H_ #include #include namespace spine { class SkeletonAnimation; typedef void (cocos2d::Object::*SEL_AnimationStateEvent)(spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount); #define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR) /** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be * played later. */ class SkeletonAnimation: public Skeleton { public: spAnimationState* state; static SkeletonAnimation* createWithData (spSkeletonData* skeletonData); static SkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); static SkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0); SkeletonAnimation (spSkeletonData* skeletonData); SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0); SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0); virtual ~SkeletonAnimation (); virtual void update (float deltaTime); void setAnimationStateData (spAnimationStateData* stateData); void setMix (const char* fromAnimation, const char* toAnimation, float duration); void setAnimationListener (cocos2d::Object* instance, SEL_AnimationStateEvent method); spTrackEntry* setAnimation (int trackIndex, const char* name, bool loop); spTrackEntry* addAnimation (int trackIndex, const char* name, bool loop, float delay = 0); spTrackEntry* getCurrent (int trackIndex = 0); void clearTracks (); void clearTrack (int trackIndex = 0); virtual void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount); protected: SkeletonAnimation (); private: typedef Skeleton super; cocos2d::Object* listenerInstance; SEL_AnimationStateEvent listenerMethod; bool ownsAnimationStateData; void initialize (); }; } #endif /* SPINE_CCSKELETONANIMATION_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/CMakeLists.txt ================================================ set(SPINE_SRC Animation.cpp AnimationState.cpp AnimationStateData.cpp Atlas.cpp AtlasAttachmentLoader.cpp Attachment.cpp AttachmentLoader.cpp Bone.cpp BoneData.cpp BoundingBoxAttachment.cpp Event.cpp EventData.cpp Json.cpp RegionAttachment.cpp Skeleton.cpp SkeletonBounds.cpp SkeletonData.cpp SkeletonJson.cpp Skin.cpp Slot.cpp SlotData.cpp Slot.cpp SlotData.cpp extension.cpp spine-cocos2dx.cpp CCSkeleton.cpp CCSkeletonAnimation.cpp BoundingBoxAttachment.cpp Event.cpp EventData.cpp SkeletonBounds.cpp ) include_directories( .. ) add_library(spine STATIC ${SPINE_SRC} ) set_target_properties(spine PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/editor-support/spine/Event.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include spEvent* spEvent_create (spEventData* data) { spEvent* self = NEW(spEvent); CONST_CAST(spEventData*, self->data) = data; return self; } void spEvent_dispose (spEvent* self) { FREE(self->stringValue); FREE(self); } ================================================ FILE: cocos2d/cocos/editor-support/spine/Event.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_EVENT_H_ #define SPINE_EVENT_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct spEvent spEvent; struct spEvent { spEventData* const data; int intValue; float floatValue; const char* stringValue; }; spEvent* spEvent_create (spEventData* data); void spEvent_dispose (spEvent* self); #ifdef SPINE_SHORT_NAMES typedef spEvent Event; #define Event_create(...) spEvent_create(__VA_ARGS__) #define Event_dispose(...) spEvent_dispose(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_EVENT_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/EventData.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include spEventData* spEventData_create (const char* name) { spEventData* self = NEW(spEventData); MALLOC_STR(self->name, name); return self; } void spEventData_dispose (spEventData* self) { FREE(self->stringValue); FREE(self->name); FREE(self); } ================================================ FILE: cocos2d/cocos/editor-support/spine/EventData.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_EVENTDATA_H_ #define SPINE_EVENTDATA_H_ #ifdef __cplusplus extern "C" { #endif typedef struct spEventData spEventData; struct spEventData { const char* const name; int intValue; float floatValue; const char* stringValue; }; spEventData* spEventData_create (const char* name); void spEventData_dispose (spEventData* self); #ifdef SPINE_SHORT_NAMES typedef spEventData EventData; #define EventData_create(...) spEventData_create(__VA_ARGS__) #define EventData_dispose(...) spEventData_dispose(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_EVENTDATA_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/Json.cpp ================================================ /* Copyright (c) 2009 Dave Gamble Permission is hereby granted, dispose 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. */ /* Json */ /* JSON parser in C. */ #include "Json.h" #include #include #include static const char* ep; const char* Json_getError (void) { return ep; } static int Json_strcasecmp (const char* s1, const char* s2) { if (!s1) return (s1 == s2) ? 0 : 1; if (!s2) return 1; for (; tolower(*s1) == tolower(*s2); ++s1, ++s2) if (*s1 == 0) return 0; return tolower(*(const unsigned char*)s1) - tolower(*(const unsigned char*)s2); } /* Internal constructor. */ static Json *Json_new (void) { return (Json*)CALLOC(Json, 1); } /* Delete a Json structure. */ void Json_dispose (Json *c) { Json *next; while (c) { next = c->next; if (c->child) Json_dispose(c->child); if (c->valueString) FREE(c->valueString); if (c->name) FREE(c->name); FREE(c); c = next; } } /* Parse the input text to generate a number, and populate the result into item. */ static const char* parse_number (Json *item, const char* num) { float n = 0, sign = 1, scale = 0; int subscale = 0, signsubscale = 1; /* Could use sscanf for this? */ if (*num == '-') sign = -1, num++; /* Has sign? */ if (*num == '0') num++; /* is zero */ if (*num >= '1' && *num <= '9') do n = (n * 10.0f) + (*num++ - '0'); while (*num >= '0' && *num <= '9'); /* Number? */ if (*num == '.' && num[1] >= '0' && num[1] <= '9') { num++; do n = (n * 10.0f) + (*num++ - '0'), scale--; while (*num >= '0' && *num <= '9'); } /* Fractional part? */ if (*num == 'e' || *num == 'E') /* Exponent? */ { num++; if (*num == '+') num++; else if (*num == '-') signsubscale = -1, num++; /* With sign? */ while (*num >= '0' && *num <= '9') subscale = (subscale * 10) + (*num++ - '0'); /* Number? */ } n = sign * n * (float)pow(10.0f, (scale + subscale * signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */ item->valueFloat = n; item->valueInt = (int)n; item->type = Json_Number; return num; } /* Parse the input text into an unescaped cstring, and populate item. */ static const unsigned char firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; static const char* parse_string (Json *item, const char* str) { const char* ptr = str + 1; char* ptr2; char* out; int len = 0; unsigned uc, uc2; if (*str != '\"') { ep = str; return 0; } /* not a string! */ while (*ptr != '\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */ out = (char*)malloc(len + 1); /* This is how long we need for the string, roughly. */ if (!out) return 0; ptr = str + 1; ptr2 = out; while (*ptr != '\"' && *ptr) { if (*ptr != '\\') *ptr2++ = *ptr++; else { ptr++; switch (*ptr) { case 'b': *ptr2++ = '\b'; break; case 'f': *ptr2++ = '\f'; break; case 'n': *ptr2++ = '\n'; break; case 'r': *ptr2++ = '\r'; break; case 't': *ptr2++ = '\t'; break; case 'u': /* transcode utf16 to utf8. */ sscanf(ptr + 1, "%4x", &uc); ptr += 4; /* get the unicode char. */ if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) break; /* check for invalid. */ if (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs. */ { if (ptr[1] != '\\' || ptr[2] != 'u') break; /* missing second-half of surrogate. */ sscanf(ptr + 3, "%4x", &uc2); ptr += 6; if (uc2 < 0xDC00 || uc2 > 0xDFFF) break; /* invalid second-half of surrogate. */ uc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF)); } len = 4; if (uc < 0x80) len = 1; else if (uc < 0x800) len = 2; else if (uc < 0x10000) len = 3; ptr2 += len; switch (len) { case 4: *--ptr2 = ((uc | 0x80) & 0xBF); uc >>= 6; case 3: *--ptr2 = ((uc | 0x80) & 0xBF); uc >>= 6; case 2: *--ptr2 = ((uc | 0x80) & 0xBF); uc >>= 6; case 1: *--ptr2 = (uc | firstByteMark[len]); } ptr2 += len; break; default: *ptr2++ = *ptr; break; } ptr++; } } *ptr2 = 0; if (*ptr == '\"') ptr++; item->valueString = out; item->type = Json_String; return ptr; } /* Predeclare these prototypes. */ static const char* parse_value (Json *item, const char* value); static const char* parse_array (Json *item, const char* value); static const char* parse_object (Json *item, const char* value); /* Utility to jump whitespace and cr/lf */ static const char* skip (const char* in) { while (in && *in && (unsigned char)*in <= 32) in++; return in; } /* Parse an object - create a new root, and populate. */ Json *Json_create (const char* value) { const char* end = 0; Json *c = Json_new(); ep = 0; if (!c) return 0; /* memory fail */ end = parse_value(c, skip(value)); if (!end) { Json_dispose(c); return 0; } /* parse failure. ep is set. */ return c; } /* Parser core - when encountering text, process appropriately. */ static const char* parse_value (Json *item, const char* value) { if (!value) return 0; /* Fail on null. */ if (!strncmp(value, "null", 4)) { item->type = Json_NULL; return value + 4; } if (!strncmp(value, "false", 5)) { item->type = Json_False; return value + 5; } if (!strncmp(value, "true", 4)) { item->type = Json_True; item->valueInt = 1; return value + 4; } if (*value == '\"') { return parse_string(item, value); } if (*value == '-' || (*value >= '0' && *value <= '9')) { return parse_number(item, value); } if (*value == '[') { return parse_array(item, value); } if (*value == '{') { return parse_object(item, value); } ep = value; return 0; /* failure. */ } /* Build an array from input text. */ static const char* parse_array (Json *item, const char* value) { Json *child; if (*value != '[') { ep = value; return 0; } /* not an array! */ item->type = Json_Array; value = skip(value + 1); if (*value == ']') return value + 1; /* empty array. */ item->child = child = Json_new(); if (!item->child) return 0; /* memory fail */ value = skip(parse_value(child, skip(value))); /* skip any spacing, get the value. */ if (!value) return 0; item->size = 1; while (*value == ',') { Json *new_item; if (!(new_item = Json_new())) return 0; /* memory fail */ child->next = new_item; new_item->prev = child; child = new_item; value = skip(parse_value(child, skip(value + 1))); if (!value) return 0; /* memory fail */ item->size++; } if (*value == ']') return value + 1; /* end of array */ ep = value; return 0; /* malformed. */ } /* Build an object from the text. */ static const char* parse_object (Json *item, const char* value) { Json *child; if (*value != '{') { ep = value; return 0; } /* not an object! */ item->type = Json_Object; value = skip(value + 1); if (*value == '}') return value + 1; /* empty array. */ item->child = child = Json_new(); if (!item->child) return 0; value = skip(parse_string(child, skip(value))); if (!value) return 0; child->name = child->valueString; child->valueString = 0; if (*value != ':') { ep = value; return 0; } /* fail! */ value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */ if (!value) return 0; item->size = 1; while (*value == ',') { Json *new_item; if (!(new_item = Json_new())) return 0; /* memory fail */ child->next = new_item; new_item->prev = child; child = new_item; value = skip(parse_string(child, skip(value + 1))); if (!value) return 0; child->name = child->valueString; child->valueString = 0; if (*value != ':') { ep = value; return 0; } /* fail! */ value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */ if (!value) return 0; item->size++; } if (*value == '}') return value + 1; /* end of array */ ep = value; return 0; /* malformed. */ } Json *Json_getItem (Json *object, const char* string) { Json *c = object->child; while (c && Json_strcasecmp(c->name, string)) c = c->next; return c; } const char* Json_getString (Json* object, const char* name, const char* defaultValue) { object = Json_getItem(object, name); if (object) return object->valueString; return defaultValue; } float Json_getFloat (Json* value, const char* name, float defaultValue) { value = Json_getItem(value, name); return value ? value->valueFloat : defaultValue; } int Json_getInt (Json* value, const char* name, int defaultValue) { value = Json_getItem(value, name); return value ? value->valueInt : defaultValue; } ================================================ FILE: cocos2d/cocos/editor-support/spine/Json.h ================================================ /* Copyright (c) 2009 Dave Gamble Permission is hereby granted, dispose 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. */ /* Esoteric Software: Removed everything except parsing, shorter method names, more get methods, double to float, formatted. */ #ifndef SPINE_JSON_H_ #define SPINE_JSON_H_ #ifdef __cplusplus extern "C" { #endif /* Json Types: */ #define Json_False 0 #define Json_True 1 #define Json_NULL 2 #define Json_Number 3 #define Json_String 4 #define Json_Array 5 #define Json_Object 6 /* The Json structure: */ typedef struct Json { struct Json* next; struct Json* prev; /* next/prev allow you to walk array/object chains. Alternatively, use getSize/getItem */ struct Json* child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ int type; /* The type of the item, as above. */ int size; /* The number of children. */ const char* valueString; /* The item's string, if type==Json_String */ int valueInt; /* The item's number, if type==Json_Number */ float valueFloat; /* The item's number, if type==Json_Number */ const char* name; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ } Json; /* Supply a block of JSON, and this returns a Json object you can interrogate. Call Json_dispose when finished. */ Json* Json_create (const char* value); /* Delete a Json entity and all subentities. */ void Json_dispose (Json* json); /* Get item "string" from object. Case insensitive. */ Json* Json_getItem (Json* json, const char* string); const char* Json_getString (Json* json, const char* name, const char* defaultValue); float Json_getFloat (Json* json, const char* name, float defaultValue); int Json_getInt (Json* json, const char* name, int defaultValue); /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when Json_create() returns 0. 0 when Json_create() succeeds. */ const char* Json_getError (void); #ifdef __cplusplus } #endif #endif /* SPINE_JSON_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/RegionAttachment.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include void _spRegionAttachment_dispose (spAttachment* attachment) { spRegionAttachment* self = SUB_CAST(spRegionAttachment, attachment); _spAttachment_deinit(attachment); FREE(self); } spRegionAttachment* spRegionAttachment_create (const char* name) { spRegionAttachment* self = NEW(spRegionAttachment); self->scaleX = 1; self->scaleY = 1; _spAttachment_init(SUPER(self), name, ATTACHMENT_REGION, _spRegionAttachment_dispose); return self; } void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate) { if (rotate) { self->uvs[VERTEX_X2] = u; self->uvs[VERTEX_Y2] = v2; self->uvs[VERTEX_X3] = u; self->uvs[VERTEX_Y3] = v; self->uvs[VERTEX_X4] = u2; self->uvs[VERTEX_Y4] = v; self->uvs[VERTEX_X1] = u2; self->uvs[VERTEX_Y1] = v2; } else { self->uvs[VERTEX_X1] = u; self->uvs[VERTEX_Y1] = v2; self->uvs[VERTEX_X2] = u; self->uvs[VERTEX_Y2] = v; self->uvs[VERTEX_X3] = u2; self->uvs[VERTEX_Y3] = v; self->uvs[VERTEX_X4] = u2; self->uvs[VERTEX_Y4] = v2; } } void spRegionAttachment_updateOffset (spRegionAttachment* self) { float regionScaleX = self->width / self->regionOriginalWidth * self->scaleX; float regionScaleY = self->height / self->regionOriginalHeight * self->scaleY; float localX = -self->width / 2 * self->scaleX + self->regionOffsetX * regionScaleX; float localY = -self->height / 2 * self->scaleY + self->regionOffsetY * regionScaleY; float localX2 = localX + self->regionWidth * regionScaleX; float localY2 = localY + self->regionHeight * regionScaleY; float radians = (float)(self->rotation * 3.1415926535897932385 / 180); #ifdef __STDC_VERSION__ float cosine = cosf(radians); float sine = sinf(radians); #else float cosine = (float)cos(radians); float sine = (float)sin(radians); #endif float localXCos = localX * cosine + self->x; float localXSin = localX * sine; float localYCos = localY * cosine + self->y; float localYSin = localY * sine; float localX2Cos = localX2 * cosine + self->x; float localX2Sin = localX2 * sine; float localY2Cos = localY2 * cosine + self->y; float localY2Sin = localY2 * sine; self->offset[VERTEX_X1] = localXCos - localYSin; self->offset[VERTEX_Y1] = localYCos + localXSin; self->offset[VERTEX_X2] = localXCos - localY2Sin; self->offset[VERTEX_Y2] = localY2Cos + localXSin; self->offset[VERTEX_X3] = localX2Cos - localY2Sin; self->offset[VERTEX_Y3] = localY2Cos + localX2Sin; self->offset[VERTEX_X4] = localX2Cos - localYSin; self->offset[VERTEX_Y4] = localYCos + localX2Sin; } void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, float x, float y, spBone* bone, float* vertices) { float* offset = self->offset; x += bone->worldX; y += bone->worldY; vertices[VERTEX_X1] = offset[VERTEX_X1] * bone->m00 + offset[VERTEX_Y1] * bone->m01 + x; vertices[VERTEX_Y1] = offset[VERTEX_X1] * bone->m10 + offset[VERTEX_Y1] * bone->m11 + y; vertices[VERTEX_X2] = offset[VERTEX_X2] * bone->m00 + offset[VERTEX_Y2] * bone->m01 + x; vertices[VERTEX_Y2] = offset[VERTEX_X2] * bone->m10 + offset[VERTEX_Y2] * bone->m11 + y; vertices[VERTEX_X3] = offset[VERTEX_X3] * bone->m00 + offset[VERTEX_Y3] * bone->m01 + x; vertices[VERTEX_Y3] = offset[VERTEX_X3] * bone->m10 + offset[VERTEX_Y3] * bone->m11 + y; vertices[VERTEX_X4] = offset[VERTEX_X4] * bone->m00 + offset[VERTEX_Y4] * bone->m01 + x; vertices[VERTEX_Y4] = offset[VERTEX_X4] * bone->m10 + offset[VERTEX_Y4] * bone->m11 + y; } ================================================ FILE: cocos2d/cocos/editor-support/spine/RegionAttachment.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_REGIONATTACHMENT_H_ #define SPINE_REGIONATTACHMENT_H_ #include #include #include #ifdef __cplusplus extern "C" { #endif typedef enum { VERTEX_X1 = 0, VERTEX_Y1, VERTEX_X2, VERTEX_Y2, VERTEX_X3, VERTEX_Y3, VERTEX_X4, VERTEX_Y4 } spVertexIndex; typedef struct spRegionAttachment spRegionAttachment; struct spRegionAttachment { spAttachment super; float x, y, scaleX, scaleY, rotation, width, height; void* rendererObject; int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */ int regionWidth, regionHeight; /* Unrotated, stripped pixel size. */ int regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped pixel size. */ float offset[8]; float uvs[8]; }; spRegionAttachment* spRegionAttachment_create (const char* name); void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate); void spRegionAttachment_updateOffset (spRegionAttachment* self); void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, float x, float y, spBone* bone, float* vertices); #ifdef SPINE_SHORT_NAMES typedef spVertexIndex VertexIndex; typedef spRegionAttachment RegionAttachment; #define RegionAttachment_create(...) spRegionAttachment_create(__VA_ARGS__) #define RegionAttachment_setUVs(...) spRegionAttachment_setUVs(__VA_ARGS__) #define RegionAttachment_updateOffset(...) spRegionAttachment_updateOffset(__VA_ARGS__) #define RegionAttachment_computeWorldVertices(...) spRegionAttachment_computeWorldVertices(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_REGIONATTACHMENT_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/Skeleton.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include spSkeleton* spSkeleton_create (spSkeletonData* data) { int i, ii; spSkeleton* self = NEW(spSkeleton); CONST_CAST(spSkeletonData*, self->data) = data; self->boneCount = self->data->boneCount; self->bones = MALLOC(spBone*, self->boneCount); for (i = 0; i < self->boneCount; ++i) { spBoneData* boneData = self->data->bones[i]; spBone* parent = 0; if (boneData->parent) { /* Find parent bone. */ for (ii = 0; ii < self->boneCount; ++ii) { if (data->bones[ii] == boneData->parent) { parent = self->bones[ii]; break; } } } self->bones[i] = spBone_create(boneData, parent); } CONST_CAST(spBone*, self->root) = self->bones[0]; self->slotCount = data->slotCount; self->slots = MALLOC(spSlot*, self->slotCount); for (i = 0; i < self->slotCount; ++i) { spSlotData *slotData = data->slots[i]; /* Find bone for the slotData's boneData. */ spBone* bone = 0; for (ii = 0; ii < self->boneCount; ++ii) { if (data->bones[ii] == slotData->boneData) { bone = self->bones[ii]; break; } } self->slots[i] = spSlot_create(slotData, self, bone); } self->drawOrder = MALLOC(spSlot*, self->slotCount); memcpy(self->drawOrder, self->slots, sizeof(spSlot*) * self->slotCount); self->r = 1; self->g = 1; self->b = 1; self->a = 1; return self; } void spSkeleton_dispose (spSkeleton* self) { int i; for (i = 0; i < self->boneCount; ++i) spBone_dispose(self->bones[i]); FREE(self->bones); for (i = 0; i < self->slotCount; ++i) spSlot_dispose(self->slots[i]); FREE(self->slots); FREE(self->drawOrder); FREE(self); } void spSkeleton_updateWorldTransform (const spSkeleton* self) { int i; for (i = 0; i < self->boneCount; ++i) spBone_updateWorldTransform(self->bones[i], self->flipX, self->flipY); } void spSkeleton_setToSetupPose (const spSkeleton* self) { spSkeleton_setBonesToSetupPose(self); spSkeleton_setSlotsToSetupPose(self); } void spSkeleton_setBonesToSetupPose (const spSkeleton* self) { int i; for (i = 0; i < self->boneCount; ++i) spBone_setToSetupPose(self->bones[i]); } void spSkeleton_setSlotsToSetupPose (const spSkeleton* self) { int i; memcpy(self->drawOrder, self->slots, self->slotCount * sizeof(int)); for (i = 0; i < self->slotCount; ++i) spSlot_setToSetupPose(self->slots[i]); } spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName) { int i; for (i = 0; i < self->boneCount; ++i) if (strcmp(self->data->bones[i]->name, boneName) == 0) return self->bones[i]; return 0; } int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName) { int i; for (i = 0; i < self->boneCount; ++i) if (strcmp(self->data->bones[i]->name, boneName) == 0) return i; return -1; } spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName) { int i; for (i = 0; i < self->slotCount; ++i) if (strcmp(self->data->slots[i]->name, slotName) == 0) return self->slots[i]; return 0; } int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName) { int i; for (i = 0; i < self->slotCount; ++i) if (strcmp(self->data->slots[i]->name, slotName) == 0) return i; return -1; } int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName) { spSkin *skin; if (!skinName) { spSkeleton_setSkin(self, 0); return 1; } skin = spSkeletonData_findSkin(self->data, skinName); if (!skin) return 0; spSkeleton_setSkin(self, skin); return 1; } void spSkeleton_setSkin (spSkeleton* self, spSkin* newSkin) { if (self->skin && newSkin) spSkin_attachAll(newSkin, self, self->skin); CONST_CAST(spSkin*, self->skin) = newSkin; } spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName) { int slotIndex = spSkeletonData_findSlotIndex(self->data, slotName); return spSkeleton_getAttachmentForSlotIndex(self, slotIndex, attachmentName); } spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName) { if (slotIndex == -1) return 0; if (self->skin) { spAttachment *attachment = spSkin_getAttachment(self->skin, slotIndex, attachmentName); if (attachment) return attachment; } if (self->data->defaultSkin) { spAttachment *attachment = spSkin_getAttachment(self->data->defaultSkin, slotIndex, attachmentName); if (attachment) return attachment; } return 0; } int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName) { int i; for (i = 0; i < self->slotCount; ++i) { spSlot *slot = self->slots[i]; if (strcmp(slot->data->name, slotName) == 0) { if (!attachmentName) spSlot_setAttachment(slot, 0); else { spAttachment* attachment = spSkeleton_getAttachmentForSlotIndex(self, i, attachmentName); if (!attachment) return 0; spSlot_setAttachment(slot, attachment); } return 1; } } return 0; } void spSkeleton_update (spSkeleton* self, float deltaTime) { self->time += deltaTime; } ================================================ FILE: cocos2d/cocos/editor-support/spine/Skeleton.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_SKELETON_H_ #define SPINE_SKELETON_H_ #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct spSkeleton spSkeleton; struct spSkeleton { spSkeletonData* const data; int boneCount; spBone** bones; spBone* const root; int slotCount; spSlot** slots; spSlot** drawOrder; spSkin* const skin; float r, g, b, a; float time; int/*bool*/flipX, flipY; float x, y; }; spSkeleton* spSkeleton_create (spSkeletonData* data); void spSkeleton_dispose (spSkeleton* self); void spSkeleton_updateWorldTransform (const spSkeleton* self); void spSkeleton_setToSetupPose (const spSkeleton* self); void spSkeleton_setBonesToSetupPose (const spSkeleton* self); void spSkeleton_setSlotsToSetupPose (const spSkeleton* self); /* Returns 0 if the bone was not found. */ spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName); /* Returns -1 if the bone was not found. */ int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName); /* Returns 0 if the slot was not found. */ spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName); /* Returns -1 if the slot was not found. */ int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName); /* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are * attached if the corresponding attachment from the old skin was attached. * @param skin May be 0.*/ void spSkeleton_setSkin (spSkeleton* self, spSkin* skin); /* Returns 0 if the skin was not found. See spSkeleton_setSkin. * @param skinName May be 0. */ int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName); /* Returns 0 if the slot or attachment was not found. */ spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName); /* Returns 0 if the slot or attachment was not found. */ spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName); /* Returns 0 if the slot or attachment was not found. */ int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName); void spSkeleton_update (spSkeleton* self, float deltaTime); #ifdef SPINE_SHORT_NAMES typedef spSkeleton Skeleton; #define Skeleton_create(...) spSkeleton_create(__VA_ARGS__) #define Skeleton_dispose(...) spSkeleton_dispose(__VA_ARGS__) #define Skeleton_updateWorldTransform(...) spSkeleton_updateWorldTransform(__VA_ARGS__) #define Skeleton_setToSetupPose(...) spSkeleton_setToSetupPose(__VA_ARGS__) #define Skeleton_setBonesToSetupPose(...) spSkeleton_setBonesToSetupPose(__VA_ARGS__) #define Skeleton_setSlotsToSetupPose(...) spSkeleton_setSlotsToSetupPose(__VA_ARGS__) #define Skeleton_findBone(...) spSkeleton_findBone(__VA_ARGS__) #define Skeleton_findBoneIndex(...) spSkeleton_findBoneIndex(__VA_ARGS__) #define Skeleton_findSlot(...) spSkeleton_findSlot(__VA_ARGS__) #define Skeleton_findSlotIndex(...) spSkeleton_findSlotIndex(__VA_ARGS__) #define Skeleton_setSkin(...) spSkeleton_setSkin(__VA_ARGS__) #define Skeleton_setSkinByName(...) spSkeleton_setSkinByName(__VA_ARGS__) #define Skeleton_getAttachmentForSlotName(...) spSkeleton_getAttachmentForSlotName(__VA_ARGS__) #define Skeleton_getAttachmentForSlotIndex(...) spSkeleton_getAttachmentForSlotIndex(__VA_ARGS__) #define Skeleton_setAttachment(...) spSkeleton_setAttachment(__VA_ARGS__) #define Skeleton_update(...) spSkeleton_update(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_SKELETON_H_*/ ================================================ FILE: cocos2d/cocos/editor-support/spine/SkeletonBounds.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include spPolygon* spPolygon_create (int capacity) { spPolygon* self = NEW(spPolygon); self->capacity = capacity; CONST_CAST(float*, self->vertices) = MALLOC(float, capacity); return self; } void spPolygon_dispose (spPolygon* self) { FREE(self->vertices); FREE(self); } int/*bool*/spPolygon_containsPoint (spPolygon* self, float x, float y) { int prevIndex = self->count - 2; int inside = 0; int i; for (i = 0; i < self->count; i += 2) { float vertexY = self->vertices[i + 1]; float prevY = self->vertices[prevIndex + 1]; if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { float vertexX = self->vertices[i]; if (vertexX + (y - vertexY) / (prevY - vertexY) * (self->vertices[prevIndex] - vertexX) < x) inside = !inside; } prevIndex = i; } return inside; } int/*bool*/spPolygon_intersectsSegment (spPolygon* self, float x1, float y1, float x2, float y2) { float width12 = x1 - x2, height12 = y1 - y2; float det1 = x1 * y2 - y1 * x2; float x3 = self->vertices[self->count - 2], y3 = self->vertices[self->count - 1]; int i; for (i = 0; i < self->count; i += 2) { float x4 = self->vertices[i], y4 = self->vertices[i + 1]; float det2 = x3 * y4 - y3 * x4; float width34 = x3 - x4, height34 = y3 - y4; float det3 = width12 * height34 - height12 * width34; float x = (det1 * width34 - width12 * det2) / det3; if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { float y = (det1 * height34 - height12 * det2) / det3; if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return 1; } x3 = x4; y3 = y4; } return 0; } /**/ typedef struct { spSkeletonBounds super; int capacity; } _spSkeletonBounds; spSkeletonBounds* spSkeletonBounds_create () { return SUPER(NEW(_spSkeletonBounds)); } void spSkeletonBounds_dispose (spSkeletonBounds* self) { int i; for (i = 0; i < SUB_CAST(_spSkeletonBounds, self)->capacity; ++i) if (self->polygons[i]) spPolygon_dispose(self->polygons[i]); FREE(self->polygons); FREE(self->boundingBoxes); FREE(self); } void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb) { int i; _spSkeletonBounds* internal = SUB_CAST(_spSkeletonBounds, self); if (internal->capacity < skeleton->slotCount) { spPolygon** newPolygons; FREE(self->boundingBoxes); self->boundingBoxes = MALLOC(spBoundingBoxAttachment*, skeleton->slotCount); newPolygons = CALLOC(spPolygon*, skeleton->slotCount); memcpy(newPolygons, self->polygons, internal->capacity); FREE(self->polygons); self->polygons = newPolygons; internal->capacity = skeleton->slotCount; } self->minX = (float)INT_MAX; self->minY = (float)INT_MAX; self->maxX = (float)INT_MIN; self->maxY = (float)INT_MIN; self->count = 0; for (i = 0; i < skeleton->slotCount; ++i) { spPolygon* polygon; spBoundingBoxAttachment* boundingBox; spSlot* slot = skeleton->slots[i]; spAttachment* attachment = slot->attachment; if (!attachment || attachment->type != ATTACHMENT_BOUNDING_BOX) continue; boundingBox = (spBoundingBoxAttachment*)attachment; self->boundingBoxes[self->count] = boundingBox; polygon = self->polygons[self->count]; if (!polygon || polygon->capacity < boundingBox->verticesCount) { if (polygon) spPolygon_dispose(polygon); self->polygons[self->count] = polygon = spPolygon_create(boundingBox->verticesCount); } polygon->count = boundingBox->verticesCount; spBoundingBoxAttachment_computeWorldVertices(boundingBox, skeleton->x, skeleton->y, slot->bone, polygon->vertices); if (updateAabb) { int ii = 0; for (; ii < polygon->count; ii += 2) { float x = polygon->vertices[ii]; float y = polygon->vertices[ii + 1]; if (x < self->minX) self->minX = x; if (y < self->minY) self->minY = y; if (x > self->maxX) self->maxX = x; if (y > self->maxY) self->maxY = y; } } ++self->count; } } int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y) { return x >= self->minX && x <= self->maxX && y >= self->minY && y <= self->maxY; } int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) { float m, x, y; if ((x1 <= self->minX && x2 <= self->minX) || (y1 <= self->minY && y2 <= self->minY) || (x1 >= self->maxX && x2 >= self->maxX) || (y1 >= self->maxY && y2 >= self->maxY)) return 0; m = (y2 - y1) / (x2 - x1); y = m * (self->minX - x1) + y1; if (y > self->minY && y < self->maxY) return 1; y = m * (self->maxX - x1) + y1; if (y > self->minY && y < self->maxY) return 1; x = (self->minY - y1) / m + x1; if (x > self->minX && x < self->maxX) return 1; x = (self->maxY - y1) / m + x1; if (x > self->minX && x < self->maxX) return 1; return 0; } int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds) { return self->minX < bounds->maxX && self->maxX > bounds->minX && self->minY < bounds->maxY && self->maxY > bounds->minY; } spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y) { int i; for (i = 0; i < self->count; ++i) if (spPolygon_containsPoint(self->polygons[i], x, y)) return self->boundingBoxes[i]; return 0; } spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) { int i; for (i = 0; i < self->count; ++i) if (spPolygon_intersectsSegment(self->polygons[i], x1, y1, x2, y2)) return self->boundingBoxes[i]; return 0; } spPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox) { int i; for (i = 0; i < self->count; ++i) if (self->boundingBoxes[i] == boundingBox) return self->polygons[i]; return 0; } ================================================ FILE: cocos2d/cocos/editor-support/spine/SkeletonBounds.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_SKELETONBOUNDS_H_ #define SPINE_SKELETONBOUNDS_H_ #include #include #ifdef __cplusplus extern "C" { #endif typedef struct { float* const vertices; int count; int capacity; } spPolygon; spPolygon* spPolygon_create (int capacity); void spPolygon_dispose (spPolygon* self); int/*bool*/spPolygon_containsPoint (spPolygon* polygon, float x, float y); int/*bool*/spPolygon_intersectsSegment (spPolygon* polygon, float x1, float y1, float x2, float y2); #ifdef SPINE_SHORT_NAMES typedef spPolygon Polygon; #define Polygon_create(...) spPolygon_create(__VA_ARGS__) #define Polygon_dispose(...) spPolygon_dispose(__VA_ARGS__) #define Polygon_containsPoint(...) spPolygon_containsPoint(__VA_ARGS__) #define Polygon_intersectsSegment(...) spPolygon_intersectsSegment(__VA_ARGS__) #endif /**/ typedef struct { int count; spBoundingBoxAttachment** boundingBoxes; spPolygon** polygons; float minX, minY, maxX, maxY; } spSkeletonBounds; spSkeletonBounds* spSkeletonBounds_create (); void spSkeletonBounds_dispose (spSkeletonBounds* self); void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb); /** Returns true if the axis aligned bounding box contains the point. */ int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y); /** Returns true if the axis aligned bounding box intersects the line segment. */ int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2); /** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */ int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds); /** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more * efficient to only call this method if spSkeletonBounds_aabbContainsPoint returns true. */ spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y); /** Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually * more efficient to only call this method if spSkeletonBounds_aabbIntersectsSegment returns true. */ spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2); /** Returns the polygon for the specified bounding box, or null. */ spPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox); #ifdef SPINE_SHORT_NAMES typedef spSkeletonBounds SkeletonBounds; #define SkeletonBounds_create(...) spSkeletonBounds_create(__VA_ARGS__) #define SkeletonBounds_dispose(...) spSkeletonBounds_dispose(__VA_ARGS__) #define SkeletonBounds_update(...) spSkeletonBounds_update(__VA_ARGS__) #define SkeletonBounds_aabbContainsPoint(...) spSkeletonBounds_aabbContainsPoint(__VA_ARGS__) #define SkeletonBounds_aabbIntersectsSegment(...) spSkeletonBounds_aabbIntersectsSegment(__VA_ARGS__) #define SkeletonBounds_aabbIntersectsSkeleton(...) spSkeletonBounds_aabbIntersectsSkeleton(__VA_ARGS__) #define SkeletonBounds_containsPoint(...) spSkeletonBounds_containsPoint(__VA_ARGS__) #define SkeletonBounds_intersectsSegment(...) spSkeletonBounds_intersectsSegment(__VA_ARGS__) #define SkeletonBounds_getPolygon(...) spSkeletonBounds_getPolygon(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_SKELETONBOUNDS_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/SkeletonData.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include spSkeletonData* spSkeletonData_create () { return NEW(spSkeletonData); } void spSkeletonData_dispose (spSkeletonData* self) { int i; for (i = 0; i < self->boneCount; ++i) spBoneData_dispose(self->bones[i]); FREE(self->bones); for (i = 0; i < self->slotCount; ++i) spSlotData_dispose(self->slots[i]); FREE(self->slots); for (i = 0; i < self->skinCount; ++i) spSkin_dispose(self->skins[i]); FREE(self->skins); for (i = 0; i < self->animationCount; ++i) spAnimation_dispose(self->animations[i]); FREE(self->animations); for (i = 0; i < self->eventCount; ++i) spEventData_dispose(self->events[i]); FREE(self->events); FREE(self); } spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName) { int i; for (i = 0; i < self->boneCount; ++i) if (strcmp(self->bones[i]->name, boneName) == 0) return self->bones[i]; return 0; } int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName) { int i; for (i = 0; i < self->boneCount; ++i) if (strcmp(self->bones[i]->name, boneName) == 0) return i; return -1; } spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName) { int i; for (i = 0; i < self->slotCount; ++i) if (strcmp(self->slots[i]->name, slotName) == 0) return self->slots[i]; return 0; } int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName) { int i; for (i = 0; i < self->slotCount; ++i) if (strcmp(self->slots[i]->name, slotName) == 0) return i; return -1; } spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName) { int i; for (i = 0; i < self->skinCount; ++i) if (strcmp(self->skins[i]->name, skinName) == 0) return self->skins[i]; return 0; } spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName) { int i; for (i = 0; i < self->eventCount; ++i) if (strcmp(self->events[i]->name, eventName) == 0) return self->events[i]; return 0; } spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName) { int i; for (i = 0; i < self->animationCount; ++i) if (strcmp(self->animations[i]->name, animationName) == 0) return self->animations[i]; return 0; } ================================================ FILE: cocos2d/cocos/editor-support/spine/SkeletonData.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_SKELETONDATA_H_ #define SPINE_SKELETONDATA_H_ #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct { int boneCount; spBoneData** bones; int slotCount; spSlotData** slots; int skinCount; spSkin** skins; spSkin* defaultSkin; int eventCount; spEventData** events; int animationCount; spAnimation** animations; } spSkeletonData; spSkeletonData* spSkeletonData_create (); void spSkeletonData_dispose (spSkeletonData* self); spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName); int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName); spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName); int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName); spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName); spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName); spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName); #ifdef SPINE_SHORT_NAMES typedef spSkeletonData SkeletonData; #define SkeletonData_create(...) spSkeletonData_create(__VA_ARGS__) #define SkeletonData_dispose(...) spSkeletonData_dispose(__VA_ARGS__) #define SkeletonData_findBone(...) spSkeletonData_findBone(__VA_ARGS__) #define SkeletonData_findBoneIndex(...) spSkeletonData_findBoneIndex(__VA_ARGS__) #define SkeletonData_findSlot(...) spSkeletonData_findSlot(__VA_ARGS__) #define SkeletonData_findSlotIndex(...) spSkeletonData_findSlotIndex(__VA_ARGS__) #define SkeletonData_findSkin(...) spSkeletonData_findSkin(__VA_ARGS__) #define SkeletonData_findEvent(...) spSkeletonData_findEvent(__VA_ARGS__) #define SkeletonData_findAnimation(...) spSkeletonData_findAnimation(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_SKELETONDATA_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/SkeletonJson.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include "Json.h" #include #include #include typedef struct { spSkeletonJson super; int ownsLoader; } _spSkeletonJson; spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader) { spSkeletonJson* self = SUPER(NEW(_spSkeletonJson)); self->scale = 1; self->attachmentLoader = attachmentLoader; return self; } spSkeletonJson* spSkeletonJson_create (spAtlas* atlas) { spAtlasAttachmentLoader* attachmentLoader = spAtlasAttachmentLoader_create(atlas); spSkeletonJson* self = spSkeletonJson_createWithLoader(SUPER(attachmentLoader)); SUB_CAST(_spSkeletonJson, self)->ownsLoader = 1; return self; } void spSkeletonJson_dispose (spSkeletonJson* self) { if (SUB_CAST(_spSkeletonJson, self)->ownsLoader) spAttachmentLoader_dispose(self->attachmentLoader); FREE(self->error); FREE(self); } void _spSkeletonJson_setError (spSkeletonJson* self, Json* root, const char* value1, const char* value2) { char message[256]; size_t length = 0; FREE(self->error); strcpy(message, value1); length = strlen(value1); if (value2) strncat(message + length, value2, 256 - length); MALLOC_STR(self->error, message); if (root) Json_dispose(root); } static float toColor (const char* value, int index) { char digits[3]; char *error; if (strlen(value) != 8) return -1; value += index * 2; digits[0] = *value; digits[1] = *(value + 1); digits[2] = '\0'; auto color = strtoul(digits, &error, 16); if (*error != 0) return -1; return color / (float)255; } static void readCurve (spCurveTimeline* timeline, int frameIndex, Json* frame) { Json* curve = Json_getItem(frame, "curve"); if (!curve) return; if (curve->type == Json_String && strcmp(curve->valueString, "stepped") == 0) spCurveTimeline_setStepped(timeline, frameIndex); else if (curve->type == Json_Array) { Json* child0 = curve->child; Json* child1 = child0->next; Json* child2 = child1->next; Json* child3 = child2->next; spCurveTimeline_setCurve(timeline, frameIndex, child0->valueFloat, child1->valueFloat, child2->valueFloat, child3->valueFloat); } } static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* root, spSkeletonData *skeletonData) { int i; spAnimation* animation; Json* bones = Json_getItem(root, "bones"); Json* slots = Json_getItem(root, "slots"); Json* drawOrder = Json_getItem(root, "draworder"); Json* events = Json_getItem(root, "events"); Json *boneMap, *slotMap; int timelineCount = 0; for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next) timelineCount += boneMap->size; for (slotMap = slots ? slots->child : 0; slotMap; slotMap = slotMap->next) timelineCount += slotMap->size; if (events) ++timelineCount; if (drawOrder) ++timelineCount; animation = spAnimation_create(root->name, timelineCount); animation->timelineCount = 0; skeletonData->animations[skeletonData->animationCount] = animation; ++skeletonData->animationCount; for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next) { Json *timelineArray; int boneIndex = spSkeletonData_findBoneIndex(skeletonData, boneMap->name); if (boneIndex == -1) { spAnimation_dispose(animation); _spSkeletonJson_setError(self, root, "spBone not found: ", boneMap->name); return 0; } for (timelineArray = boneMap->child; timelineArray; timelineArray = timelineArray->next) { Json* frame; float duration; if (strcmp(timelineArray->name, "rotate") == 0) { spRotateTimeline *timeline = spRotateTimeline_create(timelineArray->size); timeline->boneIndex = boneIndex; for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) { spRotateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "angle", 0)); readCurve(SUPER(timeline), i, frame); } animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[timelineArray->size * 2 - 2]; if (duration > animation->duration) animation->duration = duration; } else { int isScale = strcmp(timelineArray->name, "scale") == 0; if (isScale || strcmp(timelineArray->name, "translate") == 0) { float scale = isScale ? 1 : self->scale; spTranslateTimeline *timeline = isScale ? spScaleTimeline_create(timelineArray->size) : spTranslateTimeline_create(timelineArray->size); timeline->boneIndex = boneIndex; for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) { spTranslateTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), Json_getFloat(frame, "x", 0) * scale, Json_getFloat(frame, "y", 0) * scale); readCurve(SUPER(timeline), i, frame); } animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[timelineArray->size * 3 - 3]; if (duration > animation->duration) animation->duration = duration; } else { spAnimation_dispose(animation); _spSkeletonJson_setError(self, 0, "Invalid timeline type for a bone: ", timelineArray->name); return 0; } } } } for (slotMap = slots ? slots->child : 0; slotMap; slotMap = slotMap->next) { Json *timelineArray; int slotIndex = spSkeletonData_findSlotIndex(skeletonData, slotMap->name); if (slotIndex == -1) { spAnimation_dispose(animation); _spSkeletonJson_setError(self, root, "Slot not found: ", slotMap->name); return 0; } for (timelineArray = slotMap->child; timelineArray; timelineArray = timelineArray->next) { Json* frame; float duration; if (strcmp(timelineArray->name, "color") == 0) { spColorTimeline *timeline = spColorTimeline_create(timelineArray->size); timeline->slotIndex = slotIndex; for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) { const char* s = Json_getString(frame, "color", 0); spColorTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2), toColor(s, 3)); readCurve(SUPER(timeline), i, frame); } animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[timelineArray->size * 5 - 5]; if (duration > animation->duration) animation->duration = duration; } else if (strcmp(timelineArray->name, "attachment") == 0) { spAttachmentTimeline *timeline = spAttachmentTimeline_create(timelineArray->size); timeline->slotIndex = slotIndex; for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) { Json* name = Json_getItem(frame, "name"); spAttachmentTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), name->type == Json_NULL ? 0 : name->valueString); } animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[timelineArray->size - 1]; if (duration > animation->duration) animation->duration = duration; } else { spAnimation_dispose(animation); _spSkeletonJson_setError(self, 0, "Invalid timeline type for a slot: ", timelineArray->name); return 0; } } } if (events) { Json* frame; float duration; spEventTimeline* timeline = spEventTimeline_create(events->size); for (frame = events->child, i = 0; frame; frame = frame->next, ++i) { spEvent* event; const char* stringValue; spEventData* eventData = spSkeletonData_findEvent(skeletonData, Json_getString(frame, "name", 0)); if (!eventData) { spAnimation_dispose(animation); _spSkeletonJson_setError(self, 0, "Event not found: ", Json_getString(frame, "name", 0)); return 0; } event = spEvent_create(eventData); event->intValue = Json_getInt(frame, "int", eventData->intValue); event->floatValue = Json_getFloat(frame, "float", eventData->floatValue); stringValue = Json_getString(frame, "string", eventData->stringValue); if (stringValue) MALLOC_STR(event->stringValue, stringValue); spEventTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), event); } animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[events->size - 1]; if (duration > animation->duration) animation->duration = duration; } if (drawOrder) { Json* frame; float duration; spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrder->size, skeletonData->slotCount); for (frame = drawOrder->child, i = 0; frame; frame = frame->next, ++i) { int ii; int* drawOrderArray = 0; Json* offsets = Json_getItem(frame, "offsets"); if (offsets) { Json* offsetMap; int* unchanged = MALLOC(int, skeletonData->slotCount - offsets->size); int originalIndex = 0, unchangedIndex = 0; drawOrderArray = MALLOC(int, skeletonData->slotCount); for (ii = skeletonData->slotCount - 1; ii >= 0; --ii) drawOrderArray[ii] = -1; for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) { int slotIndex = spSkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0)); if (slotIndex == -1) { spAnimation_dispose(animation); _spSkeletonJson_setError(self, 0, "Slot not found: ", Json_getString(offsetMap, "slot", 0)); return 0; } /* Collect unchanged items. */ while (originalIndex != slotIndex) unchanged[unchangedIndex++] = originalIndex++; /* Set changed items. */ drawOrderArray[originalIndex + Json_getInt(offsetMap, "offset", 0)] = originalIndex; ++originalIndex; } /* Collect remaining unchanged items. */ while (originalIndex < skeletonData->slotCount) unchanged[unchangedIndex++] = originalIndex++; /* Fill in unchanged items. */ for (ii = skeletonData->slotCount - 1; ii >= 0; ii--) if (drawOrderArray[ii] == -1) drawOrderArray[ii] = unchanged[--unchangedIndex]; FREE(unchanged); } spDrawOrderTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), drawOrderArray); FREE(drawOrderArray); } animation->timelines[animation->timelineCount++] = (spTimeline*)timeline; duration = timeline->frames[drawOrder->size - 1]; if (duration > animation->duration) animation->duration = duration; } return animation; } spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path) { int length; spSkeletonData* skeletonData; const char* json = _spUtil_readFile(path, &length); if (!json) { _spSkeletonJson_setError(self, 0, "Unable to read skeleton file: ", path); return 0; } skeletonData = spSkeletonJson_readSkeletonData(self, json); FREE(json); return skeletonData; } spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json) { int i; spSkeletonData* skeletonData; Json *root, *bones, *boneMap, *slots, *skins, *animations, *events; FREE(self->error); CONST_CAST(char*, self->error) = 0; root = Json_create(json); if (!root) { _spSkeletonJson_setError(self, 0, "Invalid skeleton JSON: ", Json_getError()); return 0; } skeletonData = spSkeletonData_create(); bones = Json_getItem(root, "bones"); skeletonData->bones = MALLOC(spBoneData*, bones->size); for (boneMap = bones->child, i = 0; boneMap; boneMap = boneMap->next, ++i) { spBoneData* boneData; spBoneData* parent = 0; const char* parentName = Json_getString(boneMap, "parent", 0); if (parentName) { parent = spSkeletonData_findBone(skeletonData, parentName); if (!parent) { spSkeletonData_dispose(skeletonData); _spSkeletonJson_setError(self, root, "Parent bone not found: ", parentName); return 0; } } boneData = spBoneData_create(Json_getString(boneMap, "name", 0), parent); boneData->length = Json_getFloat(boneMap, "length", 0) * self->scale; boneData->x = Json_getFloat(boneMap, "x", 0) * self->scale; boneData->y = Json_getFloat(boneMap, "y", 0) * self->scale; boneData->rotation = Json_getFloat(boneMap, "rotation", 0); boneData->scaleX = Json_getFloat(boneMap, "scaleX", 1); boneData->scaleY = Json_getFloat(boneMap, "scaleY", 1); boneData->inheritScale = Json_getInt(boneMap, "inheritScale", 1); boneData->inheritRotation = Json_getInt(boneMap, "inheritRotation", 1); skeletonData->bones[i] = boneData; ++skeletonData->boneCount; } slots = Json_getItem(root, "slots"); if (slots) { Json *slotMap; skeletonData->slots = MALLOC(spSlotData*, slots->size); for (slotMap = slots->child, i = 0; slotMap; slotMap = slotMap->next, ++i) { spSlotData* slotData; const char* color; Json *attachmentItem; const char* boneName = Json_getString(slotMap, "bone", 0); spBoneData* boneData = spSkeletonData_findBone(skeletonData, boneName); if (!boneData) { spSkeletonData_dispose(skeletonData); _spSkeletonJson_setError(self, root, "spSlot bone not found: ", boneName); return 0; } slotData = spSlotData_create(Json_getString(slotMap, "name", 0), boneData); color = Json_getString(slotMap, "color", 0); if (color) { slotData->r = toColor(color, 0); slotData->g = toColor(color, 1); slotData->b = toColor(color, 2); slotData->a = toColor(color, 3); } attachmentItem = Json_getItem(slotMap, "attachment"); if (attachmentItem) spSlotData_setAttachmentName(slotData, attachmentItem->valueString); slotData->additiveBlending = Json_getInt(slotMap, "additive", 0); skeletonData->slots[i] = slotData; ++skeletonData->slotCount; } } skins = Json_getItem(root, "skins"); if (skins) { Json *slotMap; skeletonData->skins = MALLOC(spSkin*, skins->size); for (slotMap = skins->child, i = 0; slotMap; slotMap = slotMap->next, ++i) { Json *attachmentsMap; spSkin *skin = spSkin_create(slotMap->name); skeletonData->skins[i] = skin; ++skeletonData->skinCount; if (strcmp(slotMap->name, "default") == 0) skeletonData->defaultSkin = skin; for (attachmentsMap = slotMap->child; attachmentsMap; attachmentsMap = attachmentsMap->next) { int slotIndex = spSkeletonData_findSlotIndex(skeletonData, attachmentsMap->name); Json *attachmentMap; for (attachmentMap = attachmentsMap->child; attachmentMap; attachmentMap = attachmentMap->next) { spAttachment* attachment; const char* skinAttachmentName = attachmentMap->name; const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName); const char* typeString = Json_getString(attachmentMap, "type", "region"); spAttachmentType type; if (strcmp(typeString, "region") == 0) type = ATTACHMENT_REGION; else if (strcmp(typeString, "boundingbox") == 0) type = ATTACHMENT_BOUNDING_BOX; else if (strcmp(typeString, "regionsequence") == 0) type = ATTACHMENT_REGION_SEQUENCE; else { spSkeletonData_dispose(skeletonData); _spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString); return 0; } attachment = spAttachmentLoader_newAttachment(self->attachmentLoader, skin, type, attachmentName); if (!attachment) { if (self->attachmentLoader->error1) { spSkeletonData_dispose(skeletonData); _spSkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2); return 0; } continue; } switch (attachment->type) { case ATTACHMENT_REGION: case ATTACHMENT_REGION_SEQUENCE: { spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment; regionAttachment->x = Json_getFloat(attachmentMap, "x", 0) * self->scale; regionAttachment->y = Json_getFloat(attachmentMap, "y", 0) * self->scale; regionAttachment->scaleX = Json_getFloat(attachmentMap, "scaleX", 1); regionAttachment->scaleY = Json_getFloat(attachmentMap, "scaleY", 1); regionAttachment->rotation = Json_getFloat(attachmentMap, "rotation", 0); regionAttachment->width = Json_getFloat(attachmentMap, "width", 32) * self->scale; regionAttachment->height = Json_getFloat(attachmentMap, "height", 32) * self->scale; spRegionAttachment_updateOffset(regionAttachment); break; } case ATTACHMENT_BOUNDING_BOX: { spBoundingBoxAttachment* box = (spBoundingBoxAttachment*)attachment; Json* verticesArray = Json_getItem(attachmentMap, "vertices"); Json* vertex; int j = 0; box->verticesCount = verticesArray->size; box->vertices = MALLOC(float, verticesArray->size); for (vertex = verticesArray->child, j = 0; vertex; vertex = vertex->next, ++j) box->vertices[j] = vertex->valueFloat * self->scale; break; } } spSkin_addAttachment(skin, slotIndex, skinAttachmentName, attachment); } } } } /* Events. */ events = Json_getItem(root, "events"); if (events) { Json *eventMap; const char* stringValue; skeletonData->events = MALLOC(spEventData*, events->size); for (eventMap = events->child; eventMap; eventMap = eventMap->next) { spEventData* eventData = spEventData_create(eventMap->name); eventData->intValue = Json_getInt(eventMap, "int", 0); eventData->floatValue = Json_getFloat(eventMap, "float", 0); stringValue = Json_getString(eventMap, "string", 0); if (stringValue) MALLOC_STR(eventData->stringValue, stringValue); skeletonData->events[skeletonData->eventCount++] = eventData; } } /* Animations. */ animations = Json_getItem(root, "animations"); if (animations) { Json *animationMap; skeletonData->animations = MALLOC(spAnimation*, animations->size); for (animationMap = animations->child; animationMap; animationMap = animationMap->next) _spSkeletonJson_readAnimation(self, animationMap, skeletonData); } Json_dispose(root); return skeletonData; } ================================================ FILE: cocos2d/cocos/editor-support/spine/SkeletonJson.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_SKELETONJSON_H_ #define SPINE_SKELETONJSON_H_ #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct { float scale; spAttachmentLoader* attachmentLoader; const char* const error; } spSkeletonJson; spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader); spSkeletonJson* spSkeletonJson_create (spAtlas* atlas); void spSkeletonJson_dispose (spSkeletonJson* self); spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json); spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path); #ifdef SPINE_SHORT_NAMES typedef spSkeletonJson SkeletonJson; #define SkeletonJson_createWithLoader(...) spSkeletonJson_createWithLoader(__VA_ARGS__) #define SkeletonJson_create(...) spSkeletonJson_create(__VA_ARGS__) #define SkeletonJson_dispose(...) spSkeletonJson_dispose(__VA_ARGS__) #define SkeletonJson_readSkeletonData(...) spSkeletonJson_readSkeletonData(__VA_ARGS__) #define SkeletonJson_readSkeletonDataFile(...) spSkeletonJson_readSkeletonDataFile(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_SKELETONJSON_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/Skin.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include typedef struct _Entry _Entry; struct _Entry { int slotIndex; const char* name; spAttachment* attachment; _Entry* next; }; _Entry* _Entry_create (int slotIndex, const char* name, spAttachment* attachment) { _Entry* self = NEW(_Entry); self->slotIndex = slotIndex; MALLOC_STR(self->name, name); self->attachment = attachment; return self; } void _Entry_dispose (_Entry* self) { spAttachment_dispose(self->attachment); FREE(self->name); FREE(self); } /**/ typedef struct { spSkin super; _Entry* entries; } _spSkin; spSkin* spSkin_create (const char* name) { spSkin* self = SUPER(NEW(_spSkin)); MALLOC_STR(self->name, name); return self; } void spSkin_dispose (spSkin* self) { _Entry* entry = SUB_CAST(_spSkin, self)->entries; while (entry) { _Entry* nextEntry = entry->next; _Entry_dispose(entry); entry = nextEntry; } FREE(self->name); FREE(self); } void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment) { _Entry* newEntry = _Entry_create(slotIndex, name, attachment); newEntry->next = SUB_CAST(_spSkin, self)->entries; SUB_CAST(_spSkin, self)->entries = newEntry; } spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name) { const _Entry* entry = SUB_CAST(_spSkin, self)->entries; while (entry) { if (entry->slotIndex == slotIndex && strcmp(entry->name, name) == 0) return entry->attachment; entry = entry->next; } return 0; } const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex) { const _Entry* entry = SUB_CAST(_spSkin, self)->entries; int i = 0; while (entry) { if (entry->slotIndex == slotIndex) { if (i == attachmentIndex) return entry->name; i++; } entry = entry->next; } return 0; } void spSkin_attachAll (const spSkin* self, spSkeleton* skeleton, const spSkin* oldSkin) { const _Entry *entry = SUB_CAST(_spSkin, oldSkin)->entries; while (entry) { spSlot *slot = skeleton->slots[entry->slotIndex]; if (slot->attachment == entry->attachment) { spAttachment *attachment = spSkin_getAttachment(self, entry->slotIndex, entry->name); if (attachment) spSlot_setAttachment(slot, attachment); } entry = entry->next; } } ================================================ FILE: cocos2d/cocos/editor-support/spine/Skin.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_SKIN_H_ #define SPINE_SKIN_H_ #include #ifdef __cplusplus extern "C" { #endif struct spSkeleton; typedef struct { const char* const name; } spSkin; spSkin* spSkin_create (const char* name); void spSkin_dispose (spSkin* self); /* The Skin owns the attachment. */ void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment); /* Returns 0 if the attachment was not found. */ spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name); /* Returns 0 if the slot or attachment was not found. */ const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex); /** Attach each attachment in this skin if the corresponding attachment in oldSkin is currently attached. */ void spSkin_attachAll (const spSkin* self, struct spSkeleton* skeleton, const spSkin* oldspSkin); #ifdef SPINE_SHORT_NAMES typedef spSkin Skin; #define Skin_create(...) spSkin_create(__VA_ARGS__) #define Skin_dispose(...) spSkin_dispose(__VA_ARGS__) #define Skin_addAttachment(...) spSkin_addAttachment(__VA_ARGS__) #define Skin_getAttachment(...) spSkin_getAttachment(__VA_ARGS__) #define Skin_getAttachmentName(...) spSkin_getAttachmentName(__VA_ARGS__) #define Skin_attachAll(...) spSkin_attachAll(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_SKIN_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/Slot.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include #include typedef struct { spSlot super; float attachmentTime; } _spSlot; spSlot* spSlot_create (spSlotData* data, spSkeleton* skeleton, spBone* bone) { spSlot* self = SUPER(NEW(_spSlot)); CONST_CAST(spSlotData*, self->data) = data; CONST_CAST(spSkeleton*, self->skeleton) = skeleton; CONST_CAST(spBone*, self->bone) = bone; spSlot_setToSetupPose(self); return self; } void spSlot_dispose (spSlot* self) { FREE(self); } void spSlot_setAttachment (spSlot* self, spAttachment* attachment) { CONST_CAST(spAttachment*, self->attachment) = attachment; SUB_CAST(_spSlot, self) ->attachmentTime = self->skeleton->time; } void spSlot_setAttachmentTime (spSlot* self, float time) { SUB_CAST(_spSlot, self) ->attachmentTime = self->skeleton->time - time; } float spSlot_getAttachmentTime (const spSlot* self) { return self->skeleton->time - SUB_CAST(_spSlot, self) ->attachmentTime; } void spSlot_setToSetupPose (spSlot* self) { spAttachment* attachment = 0; self->r = self->data->r; self->g = self->data->g; self->b = self->data->b; self->a = self->data->a; if (self->data->attachmentName) { /* Find slot index. */ int i; for (i = 0; i < self->skeleton->data->slotCount; ++i) { if (self->data == self->skeleton->data->slots[i]) { attachment = spSkeleton_getAttachmentForSlotIndex(self->skeleton, i, self->data->attachmentName); break; } } } spSlot_setAttachment(self, attachment); } ================================================ FILE: cocos2d/cocos/editor-support/spine/Slot.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_SLOT_H_ #define SPINE_SLOT_H_ #include #include #include #ifdef __cplusplus extern "C" { #endif struct spSkeleton; typedef struct spSlot { spSlotData* const data; struct spSkeleton* const skeleton; spBone* const bone; float r, g, b, a; spAttachment* const attachment; } spSlot; spSlot* spSlot_create (spSlotData* data, struct spSkeleton* skeleton, spBone* bone); void spSlot_dispose (spSlot* self); /* @param attachment May be 0 to clear the attachment for the slot. */ void spSlot_setAttachment (spSlot* self, spAttachment* attachment); void spSlot_setAttachmentTime (spSlot* self, float time); float spSlot_getAttachmentTime (const spSlot* self); void spSlot_setToSetupPose (spSlot* self); #ifdef SPINE_SHORT_NAMES typedef spSlot Slot; #define Slot_create(...) spSlot_create(__VA_ARGS__) #define Slot_dispose(...) spSlot_dispose(__VA_ARGS__) #define Slot_setAttachment(...) spSlot_setAttachment(__VA_ARGS__) #define Slot_setAttachmentTime(...) spSlot_setAttachmentTime(__VA_ARGS__) #define Slot_getAttachmentTime(...) spSlot_getAttachmentTime(__VA_ARGS__) #define Slot_setToSetupPose(...) spSlot_setToSetupPose(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_SLOT_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/SlotData.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include spSlotData* spSlotData_create (const char* name, spBoneData* boneData) { spSlotData* self = NEW(spSlotData); MALLOC_STR(self->name, name); CONST_CAST(spBoneData*, self->boneData) = boneData; self->r = 1; self->g = 1; self->b = 1; self->a = 1; return self; } void spSlotData_dispose (spSlotData* self) { FREE(self->name); FREE(self->attachmentName); FREE(self); } void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName) { FREE(self->attachmentName); if (attachmentName) MALLOC_STR(self->attachmentName, attachmentName); else CONST_CAST(char*, self->attachmentName) = 0; } ================================================ FILE: cocos2d/cocos/editor-support/spine/SlotData.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_SLOTDATA_H_ #define SPINE_SLOTDATA_H_ #include #ifdef __cplusplus extern "C" { #endif typedef struct { const char* const name; const spBoneData* const boneData; const char* const attachmentName; float r, g, b, a; int/*bool*/additiveBlending; } spSlotData; spSlotData* spSlotData_create (const char* name, spBoneData* boneData); void spSlotData_dispose (spSlotData* self); /* @param attachmentName May be 0 for no setup pose attachment. */ void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName); #ifdef SPINE_SHORT_NAMES typedef spSlotData SlotData; #define SlotData_create(...) spSlotData_create(__VA_ARGS__) #define SlotData_dispose(...) spSlotData_dispose(__VA_ARGS__) #define SlotData_setAttachmentName(...) spSlotData_setAttachmentName(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_SLOTDATA_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/extension.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include static void* (*mallocFunc) (size_t size) = malloc; static void (*freeFunc) (void* ptr) = free; void* _malloc (size_t size) { return mallocFunc(size); } void* _calloc (size_t num, size_t size) { void* ptr = mallocFunc(num * size); if (ptr) memset(ptr, 0, num * size); return ptr; } void _free (void* ptr) { freeFunc(ptr); } void _setMalloc (void* (*malloc) (size_t size)) { mallocFunc = malloc; } void _setFree (void (*free) (void* ptr)) { freeFunc = free; } char* _readFile (const char* path, int* length) { char *data; FILE *file = fopen(path, "rb"); if (!file) return 0; fseek(file, 0, SEEK_END); *length = (int)ftell(file); fseek(file, 0, SEEK_SET); data = MALLOC(char, *length); fread(data, 1, *length, file); fclose(file); return data; } ================================================ FILE: cocos2d/cocos/editor-support/spine/extension.h ================================================ /* Implementation notes: - An OOP style is used where each "class" is made up of a struct and a number of functions prefixed with the struct name. - struct fields that are const are readonly. Either they are set in a create function and can never be changed, or they can only be changed by calling a function. - Inheritance is done using a struct field named "super" as the first field, allowing the struct to be cast to its "super class". This works because a pointer to a struct is guaranteed to be a pointer to the first struct field. - Classes intended for inheritance provide init/deinit functions which subclasses must call in their create/dispose functions. - Polymorphism is done by a base class providing function pointers in its init function. The public API delegates to this function. - Subclasses do not provide a dispose function, instead the base class' dispose function should be used, which will delegate to a dispose function pointer. - Classes not designed for inheritance cannot be extended because they may use an internal subclass to hide private data and don't expose function pointers. - The public API hides implementation details, such as init/deinit functions. An internal API is exposed by extension.h to allow classes to be extended. Internal functions begin with underscore (_). - OOP in C tends to lose type safety. Macros for casting are provided in extension.h to give context for why a cast is being done. - If SPINE_SHORT_NAMES is defined, the "sp" prefix for all class names is optional. */ #ifndef SPINE_EXTENSION_H_ #define SPINE_EXTENSION_H_ /* All allocation uses these. */ #define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * COUNT)) #define CALLOC(TYPE,COUNT) ((TYPE*)_calloc(COUNT, sizeof(TYPE))) #define NEW(TYPE) CALLOC(TYPE,1) /* Gets the direct super class. Type safe. */ #define SUPER(VALUE) (&VALUE->super) /* Cast to a super class. Not type safe, use with care. Prefer SUPER() where possible. */ #define SUPER_CAST(TYPE,VALUE) ((TYPE*)VALUE) /* Cast to a sub class. Not type safe, use with care. */ #define SUB_CAST(TYPE,VALUE) ((TYPE*)VALUE) /* Casts away const. Can be used as an lvalue. Not type safe, use with care. */ #define CONST_CAST(TYPE,VALUE) (*(TYPE*)&VALUE) /* Gets the vtable for the specified type. Not type safe, use with care. */ #define VTABLE(TYPE,VALUE) ((_##TYPE##Vtable*)((TYPE*)VALUE)->vtable) /* Frees memory. Can be used on const types. */ #define FREE(VALUE) _free((void*)VALUE) /* Allocates a new char[], assigns it to TO, and copies FROM to it. Can be used on const types. */ #define MALLOC_STR(TO,FROM) strcpy(CONST_CAST(char*, TO) = (char*)malloc(strlen(FROM) + 1), FROM) #ifdef __STDC_VERSION__ #define FMOD(A,B) fmodf(A, B) #else #define FMOD(A,B) (float)fmod(A, B) #endif #include #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* * Functions that must be implemented: */ void _spAtlasPage_createTexture (spAtlasPage* self, const char* path); void _spAtlasPage_disposeTexture (spAtlasPage* self); char* _spUtil_readFile (const char* path, int* length); #ifdef SPINE_SHORT_NAMES #define _AtlasPage_createTexture(...) _spAtlasPage_createTexture(__VA_ARGS__) #define _AtlasPage_disposeTexture(...) _spAtlasPage_disposeTexture(__VA_ARGS__) #define _Util_readFile(...) _spUtil_readFile(__VA_ARGS__) #endif /* * Internal API available for extension: */ void* _malloc (size_t size); void* _calloc (size_t num, size_t size); void _free (void* ptr); void _setMalloc (void* (*_malloc) (size_t size)); void _setFree (void (*_free) (void* ptr)); char* _readFile (const char* path, int* length); /**/ void _spAttachmentLoader_init (spAttachmentLoader* self, /**/ void (*dispose) (spAttachmentLoader* self), /**/ spAttachment* (*newAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name)); void _spAttachmentLoader_deinit (spAttachmentLoader* self); void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2); void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type); #ifdef SPINE_SHORT_NAMES #define _AttachmentLoader_init(...) _spAttachmentLoader_init(__VA_ARGS__) #define _AttachmentLoader_deinit(...) _spAttachmentLoader_deinit(__VA_ARGS__) #define _AttachmentLoader_setError(...) _spAttachmentLoader_setError(__VA_ARGS__) #define _AttachmentLoader_setUnknownTypeError(...) _spAttachmentLoader_setUnknownTypeError(__VA_ARGS__) #endif /**/ void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/ void (*dispose) (spAttachment* self)); void _spAttachment_deinit (spAttachment* self); #ifdef SPINE_SHORT_NAMES #define _Attachment_init(...) _spAttachment_init(__VA_ARGS__) #define _Attachment_deinit(...) _spAttachment_deinit(__VA_ARGS__) #endif /**/ void _spTimeline_init (spTimeline* self, spTimelineType type, /**/ void (*dispose) (spTimeline* self), /**/ void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha)); void _spTimeline_deinit (spTimeline* self); #ifdef SPINE_SHORT_NAMES #define _Timeline_init(...) _spTimeline_init(__VA_ARGS__) #define _Timeline_deinit(...) _spTimeline_deinit(__VA_ARGS__) #endif /**/ void _spCurveTimeline_init (spCurveTimeline* self, spTimelineType type, int frameCount, /**/ void (*dispose) (spTimeline* self), /**/ void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventCount, float alpha)); void _spCurveTimeline_deinit (spCurveTimeline* self); #ifdef SPINE_SHORT_NAMES #define _CurveTimeline_init(...) _spCurveTimeline_init(__VA_ARGS__) #define _CurveTimeline_deinit(...) _spCurveTimeline_deinit(__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* SPINE_EXTENSION_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/proj.win32/libSpine.vcxproj ================================================  Debug Win32 Release Win32 {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} libSpine StaticLibrary true v100 v110 v110_xp Unicode StaticLibrary false v100 v110 v110_xp true Unicode $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled $(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true 4267;4251;4244;%(DisableSpecificWarnings) false true Level3 MaxSpeed true true WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) true true true ================================================ FILE: cocos2d/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters ================================================  {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files ================================================ FILE: cocos2d/cocos/editor-support/spine/spine-cocos2dx.cpp ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. *****************************************************************************/ #include #include USING_NS_CC; void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path); TextureAtlas* textureAtlas = TextureAtlas::createWithTexture(texture, 4); textureAtlas->retain(); self->rendererObject = textureAtlas; // Using getContentSize to make it supports the strategy of loading resources in cocos2d-x. // self->width = texture->getPixelsWide(); // self->height = texture->getPixelsHigh(); self->width = texture->getContentSize().width; self->height = texture->getContentSize().height; } void _spAtlasPage_disposeTexture (spAtlasPage* self) { ((TextureAtlas*)self->rendererObject)->release(); } char* _spUtil_readFile (const char* path, int* length) { char* ret = nullptr; int size = 0; Data data = FileUtils::getInstance()->getDataFromFile(path); if (!data.isNull()) { size = static_cast(data.getSize()); *length = size; // Allocates one more byte for string terminal, it will be safe when parsing JSON file in Spine runtime. ret = (char*)malloc(size + 1); ret[size] = '\0'; memcpy(ret, data.getBytes(), size); } return ret; } /**/ void spRegionAttachment_updateQuad (spRegionAttachment* self, spSlot* slot, V3F_C4B_T2F_Quad* quad, bool premultipliedAlpha) { float vertices[8]; spRegionAttachment_computeWorldVertices(self, slot->skeleton->x, slot->skeleton->y, slot->bone, vertices); GLubyte r = slot->skeleton->r * slot->r * 255; GLubyte g = slot->skeleton->g * slot->g * 255; GLubyte b = slot->skeleton->b * slot->b * 255; float normalizedAlpha = slot->skeleton->a * slot->a; if (premultipliedAlpha) { r *= normalizedAlpha; g *= normalizedAlpha; b *= normalizedAlpha; } GLubyte a = normalizedAlpha * 255; quad->bl.colors.r = r; quad->bl.colors.g = g; quad->bl.colors.b = b; quad->bl.colors.a = a; quad->tl.colors.r = r; quad->tl.colors.g = g; quad->tl.colors.b = b; quad->tl.colors.a = a; quad->tr.colors.r = r; quad->tr.colors.g = g; quad->tr.colors.b = b; quad->tr.colors.a = a; quad->br.colors.r = r; quad->br.colors.g = g; quad->br.colors.b = b; quad->br.colors.a = a; quad->bl.vertices.x = vertices[VERTEX_X1]; quad->bl.vertices.y = vertices[VERTEX_Y1]; quad->tl.vertices.x = vertices[VERTEX_X2]; quad->tl.vertices.y = vertices[VERTEX_Y2]; quad->tr.vertices.x = vertices[VERTEX_X3]; quad->tr.vertices.y = vertices[VERTEX_Y3]; quad->br.vertices.x = vertices[VERTEX_X4]; quad->br.vertices.y = vertices[VERTEX_Y4]; quad->bl.texCoords.u = self->uvs[VERTEX_X1]; quad->bl.texCoords.v = self->uvs[VERTEX_Y1]; quad->tl.texCoords.u = self->uvs[VERTEX_X2]; quad->tl.texCoords.v = self->uvs[VERTEX_Y2]; quad->tr.texCoords.u = self->uvs[VERTEX_X3]; quad->tr.texCoords.v = self->uvs[VERTEX_Y3]; quad->br.texCoords.u = self->uvs[VERTEX_X4]; quad->br.texCoords.v = self->uvs[VERTEX_Y4]; } ================================================ FILE: cocos2d/cocos/editor-support/spine/spine-cocos2dx.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_COCOS2DX_H_ #define SPINE_COCOS2DX_H_ #include #include "cocos2d.h" #include #include void spRegionAttachment_updateQuad (spRegionAttachment* self, spSlot* slot, cocos2d::V3F_C4B_T2F_Quad* quad, bool premultiplied = false); #endif /* SPINE_COCOS2DX_H_ */ ================================================ FILE: cocos2d/cocos/editor-support/spine/spine.h ================================================ /****************************************************************************** * Spine Runtime Software License - Version 1.1 * * Copyright (c) 2013, Esoteric Software * All rights reserved. * * Redistribution and use in source and binary forms in whole or in part, with * or without modification, are permitted provided that the following conditions * are met: * * 1. A Spine Essential, Professional, Enterprise, or Education License must * be purchased from Esoteric Software and the license must remain valid: * http://esotericsoftware.com/ * 2. Redistributions of source code must retain this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer. * 3. Redistributions in binary form must reproduce this license, which is the * above copyright notice, this declaration of conditions and the following * disclaimer, in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 SPINE_SPINE_H_ #define SPINE_SPINE_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* SPINE_SPINE_H_ */ ================================================ FILE: cocos2d/cocos/gui/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos_gui_static LOCAL_MODULE_FILENAME := libgui LOCAL_SRC_FILES := \ UIWidget.cpp \ UILayout.cpp \ UILayoutParameter.cpp \ UILayoutDefine.cpp \ CocosGUI.cpp \ UIHelper.cpp \ UIListView.cpp \ UIPageView.cpp \ UIScrollView.cpp \ UIButton.cpp \ UICheckBox.cpp \ UIImageView.cpp \ UIText.cpp \ UITextAtlas.cpp \ UITextBMFont.cpp \ UILoadingBar.cpp \ UISlider.cpp \ UITextField.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../editor-support LOCAL_C_INCLUDES := $(LOCAL_PATH)/../2d \ $(LOCAL_PATH)/../../external \ $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/../editor-support LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static include $(BUILD_STATIC_LIBRARY) $(call import-module,extensions) $(call import-module,2d) ================================================ FILE: cocos2d/cocos/gui/CMakeLists.txt ================================================ set(GUI_SRC UIWidget.cpp UILayout.cpp UILayoutParameter.cpp UILayoutDefine.cpp CocosGUI.cpp UIHelper.cpp UIListView.cpp UIPageView.cpp UIScrollView.cpp UIButton.cpp UICheckBox.cpp UIImageView.cpp UIText.cpp UITextAtlas.cpp UITextBMFont.cpp UILoadingBar.cpp UISlider.cpp UITextField.cpp ) add_library(gui STATIC ${GUI_SRC} ) set_target_properties(gui PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/gui/CocosGUI.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/CocosGUI.h" NS_CC_BEGIN namespace gui { const char* CocosGUIVersion() { return "CocosGUI v1.0.0.0"; } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/CocosGUI.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __COCOSGUI_H__ #define __COCOSGUI_H__ #include "gui/UIWidget.h" #include "gui/UILayout.h" #include "gui/UIButton.h" #include "gui/UICheckBox.h" #include "gui/UIImageView.h" #include "gui/UIText.h" #include "gui/UITextAtlas.h" #include "gui/UILoadingBar.h" #include "gui/UIScrollView.h" #include "gui/UIListView.h" #include "gui/UISlider.h" #include "gui/UITextField.h" #include "gui/UITextBMFont.h" #include "gui/UIPageView.h" #include "gui/UIHelper.h" NS_CC_BEGIN namespace gui { const char* CocosGUIVersion(); } NS_CC_END #endif /* defined(__CocosGUITest__Cocos__) */ ================================================ FILE: cocos2d/cocos/gui/UIButton.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UIButton.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" NS_CC_BEGIN namespace gui { static const int NORMAL_RENDERER_Z = (-2); static const int PRESSED_RENDERER_Z = (-2); static const int DISABLED_RENDERER_Z = (-2); static const int TITLE_RENDERER_Z = (-1); Button::Button(): _buttonNormalRenderer(nullptr), _buttonClickedRenderer(nullptr), _buttonDisableRenderer(nullptr), _titleRenderer(nullptr), _normalFileName(""), _clickedFileName(""), _disabledFileName(""), _prevIgnoreSize(true), _scale9Enabled(false), _capInsetsNormal(Rect::ZERO), _capInsetsPressed(Rect::ZERO), _capInsetsDisabled(Rect::ZERO), _normalTexType(UI_TEX_TYPE_LOCAL), _pressedTexType(UI_TEX_TYPE_LOCAL), _disabledTexType(UI_TEX_TYPE_LOCAL), _normalTextureSize(_size), _pressedTextureSize(_size), _disabledTextureSize(_size), _pressedActionEnabled(false), _titleColor(Color3B::WHITE), _normalTextureScaleXInSize(1.0f), _normalTextureScaleYInSize(1.0f), _pressedTextureScaleXInSize(1.0f), _pressedTextureScaleYInSize(1.0f), _normalTextureLoaded(false), _pressedTextureLoaded(false), _disabledTextureLoaded(false) { } Button::~Button() { } Button* Button::create() { Button* widget = new Button(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } bool Button::init() { if (Widget::init()) { return true; } return false; } void Button::initRenderer() { _buttonNormalRenderer = Sprite::create(); _buttonClickedRenderer = Sprite::create(); _buttonDisableRenderer = Sprite::create(); _titleRenderer = LabelTTF::create(); Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1); Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1); Node::addChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1); Node::addChild(_titleRenderer, TITLE_RENDERER_Z, -1); } void Button::setScale9Enabled(bool able) { if (_scale9Enabled == able) { return; } _brightStyle = BRIGHT_NONE; _scale9Enabled = able; Node::removeChild(_buttonNormalRenderer); Node::removeChild(_buttonClickedRenderer); Node::removeChild(_buttonDisableRenderer); _buttonNormalRenderer = nullptr; _buttonClickedRenderer = nullptr; _buttonDisableRenderer = nullptr; if (_scale9Enabled) { _buttonNormalRenderer = extension::Scale9Sprite::create(); _buttonClickedRenderer = extension::Scale9Sprite::create(); _buttonDisableRenderer = extension::Scale9Sprite::create(); } else { _buttonNormalRenderer = Sprite::create(); _buttonClickedRenderer = Sprite::create(); _buttonDisableRenderer = Sprite::create(); } loadTextureNormal(_normalFileName.c_str(), _normalTexType); loadTexturePressed(_clickedFileName.c_str(), _pressedTexType); loadTextureDisabled(_disabledFileName.c_str(), _disabledTexType); Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1); Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1); Node::addChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; ignoreContentAdaptWithSize(false); _prevIgnoreSize = ignoreBefore; } else { ignoreContentAdaptWithSize(_prevIgnoreSize); } setCapInsetsNormalRenderer(_capInsetsNormal); setCapInsetsPressedRenderer(_capInsetsPressed); setCapInsetsDisabledRenderer(_capInsetsDisabled); setBright(_bright); } void Button::ignoreContentAdaptWithSize(bool ignore) { if (!_scale9Enabled || (_scale9Enabled && !ignore)) { Widget::ignoreContentAdaptWithSize(ignore); _prevIgnoreSize = ignore; } } void Button::loadTextures(const char* normal,const char* selected,const char* disabled,TextureResType texType) { loadTextureNormal(normal,texType); loadTexturePressed(selected,texType); loadTextureDisabled(disabled,texType); } void Button::loadTextureNormal(const char* normal,TextureResType texType) { if (!normal || strcmp(normal, "") == 0) { return; } _normalFileName = normal; _normalTexType = texType; if (_scale9Enabled) { extension::Scale9Sprite* normalRendererScale9 = static_cast(_buttonNormalRenderer); switch (_normalTexType) { case UI_TEX_TYPE_LOCAL: normalRendererScale9->initWithFile(normal); break; case UI_TEX_TYPE_PLIST: normalRendererScale9->initWithSpriteFrameName(normal); break; default: break; } normalRendererScale9->setCapInsets(_capInsetsNormal); } else { Sprite* normalRenderer = static_cast(_buttonNormalRenderer); switch (_normalTexType) { case UI_TEX_TYPE_LOCAL: normalRenderer->setTexture(normal); break; case UI_TEX_TYPE_PLIST: normalRenderer->setSpriteFrame(normal); break; default: break; } } _normalTextureSize = _buttonNormalRenderer->getContentSize(); updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); normalTextureScaleChangedWithSize(); _normalTextureLoaded = true; } void Button::loadTexturePressed(const char* selected,TextureResType texType) { if (!selected || strcmp(selected, "") == 0) { return; } _clickedFileName = selected; _pressedTexType = texType; if (_scale9Enabled) { extension::Scale9Sprite* clickedRendererScale9 = static_cast(_buttonClickedRenderer); switch (_pressedTexType) { case UI_TEX_TYPE_LOCAL: clickedRendererScale9->initWithFile(selected); break; case UI_TEX_TYPE_PLIST: clickedRendererScale9->initWithSpriteFrameName(selected); break; default: break; } clickedRendererScale9->setCapInsets(_capInsetsPressed); } else { Sprite* clickedRenderer = static_cast(_buttonClickedRenderer); switch (_pressedTexType) { case UI_TEX_TYPE_LOCAL: clickedRenderer->setTexture(selected); break; case UI_TEX_TYPE_PLIST: clickedRenderer->setSpriteFrame(selected); break; default: break; } } _pressedTextureSize = _buttonClickedRenderer->getContentSize(); updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); pressedTextureScaleChangedWithSize(); _pressedTextureLoaded = true; } void Button::loadTextureDisabled(const char* disabled,TextureResType texType) { if (!disabled || strcmp(disabled, "") == 0) { return; } _disabledFileName = disabled; _disabledTexType = texType; if (_scale9Enabled) { extension::Scale9Sprite* disabledScale9 = static_cast(_buttonDisableRenderer); switch (_disabledTexType) { case UI_TEX_TYPE_LOCAL: disabledScale9->initWithFile(disabled); break; case UI_TEX_TYPE_PLIST: disabledScale9->initWithSpriteFrameName(disabled); break; default: break; } disabledScale9->setCapInsets(_capInsetsDisabled); } else { Sprite* disabledRenderer = static_cast(_buttonDisableRenderer); switch (_disabledTexType) { case UI_TEX_TYPE_LOCAL: disabledRenderer->setTexture(disabled); break; case UI_TEX_TYPE_PLIST: disabledRenderer->setSpriteFrame(disabled); break; default: break; } } _disabledTextureSize = _buttonDisableRenderer->getContentSize(); updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); disabledTextureScaleChangedWithSize(); _disabledTextureLoaded = true; } void Button::setCapInsets(const Rect &capInsets) { setCapInsetsNormalRenderer(capInsets); setCapInsetsPressedRenderer(capInsets); setCapInsetsDisabledRenderer(capInsets); } void Button::setCapInsetsNormalRenderer(const Rect &capInsets) { _capInsetsNormal = capInsets; if (!_scale9Enabled) { return; } static_cast(_buttonNormalRenderer)->setCapInsets(capInsets); } void Button::setCapInsetsPressedRenderer(const Rect &capInsets) { _capInsetsPressed = capInsets; if (!_scale9Enabled) { return; } static_cast(_buttonClickedRenderer)->setCapInsets(capInsets); } void Button::setCapInsetsDisabledRenderer(const Rect &capInsets) { _capInsetsDisabled = capInsets; if (!_scale9Enabled) { return; } static_cast(_buttonDisableRenderer)->setCapInsets(capInsets); } void Button::onPressStateChangedToNormal() { _buttonNormalRenderer->setVisible(true); _buttonClickedRenderer->setVisible(false); _buttonDisableRenderer->setVisible(false); if (_pressedTextureLoaded) { if (_pressedActionEnabled) { _buttonNormalRenderer->stopAllActions(); _buttonClickedRenderer->stopAllActions(); Action *zoomAction = ScaleTo::create(0.05f, _normalTextureScaleXInSize, _normalTextureScaleYInSize); _buttonNormalRenderer->runAction(zoomAction); _buttonClickedRenderer->setScale(_pressedTextureScaleXInSize, _pressedTextureScaleYInSize); } } else { _buttonNormalRenderer->stopAllActions(); Action *zoomAction = ScaleTo::create(0.05f, _normalTextureScaleXInSize, _normalTextureScaleYInSize); _buttonNormalRenderer->runAction(zoomAction); } } void Button::onPressStateChangedToPressed() { if (_pressedTextureLoaded) { _buttonNormalRenderer->setVisible(false); _buttonClickedRenderer->setVisible(true); _buttonDisableRenderer->setVisible(false); if (_pressedActionEnabled) { _buttonNormalRenderer->stopAllActions(); _buttonClickedRenderer->stopAllActions(); Action *zoomAction = ScaleTo::create(0.05f, _pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f); _buttonClickedRenderer->runAction(zoomAction); _buttonNormalRenderer->setScale(_pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f); } } else { _buttonNormalRenderer->setVisible(true); _buttonClickedRenderer->setVisible(true); _buttonDisableRenderer->setVisible(false); _buttonNormalRenderer->stopAllActions(); Action *zoomAction = ScaleTo::create(0.05f, _pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f); _buttonNormalRenderer->runAction(zoomAction); } } void Button::onPressStateChangedToDisabled() { _buttonNormalRenderer->setVisible(false); _buttonClickedRenderer->setVisible(false); _buttonDisableRenderer->setVisible(true); _buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize); _buttonClickedRenderer->setScale(_pressedTextureScaleXInSize, _pressedTextureScaleYInSize); } void Button::setFlipX(bool flipX) { _titleRenderer->setFlippedX(flipX); if (_scale9Enabled) { return; } static_cast(_buttonNormalRenderer)->setFlippedX(flipX); static_cast(_buttonClickedRenderer)->setFlippedX(flipX); static_cast(_buttonDisableRenderer)->setFlippedX(flipX); } void Button::setFlipY(bool flipY) { _titleRenderer->setFlippedY(flipY); if (_scale9Enabled) { return; } static_cast(_buttonNormalRenderer)->setFlippedY(flipY); static_cast(_buttonClickedRenderer)->setFlippedY(flipY); static_cast(_buttonDisableRenderer)->setFlippedY(flipY); } bool Button::isFlipX() { if (_scale9Enabled) { return false; } return static_cast(_buttonNormalRenderer)->isFlippedX(); } bool Button::isFlipY() { if (_scale9Enabled) { return false; } return static_cast(_buttonNormalRenderer)->isFlippedY(); } void Button::setAnchorPoint(const Point &pt) { Widget::setAnchorPoint(pt); _buttonNormalRenderer->setAnchorPoint(pt); _buttonClickedRenderer->setAnchorPoint(pt); _buttonDisableRenderer->setAnchorPoint(pt); _titleRenderer->setPosition(Point(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y))); } void Button::onSizeChanged() { Widget::onSizeChanged(); normalTextureScaleChangedWithSize(); pressedTextureScaleChangedWithSize(); disabledTextureScaleChangedWithSize(); } const Size& Button::getContentSize() const { return _normalTextureSize; } Node* Button::getVirtualRenderer() { if (_bright) { switch (_brightStyle) { case BRIGHT_NORMAL: return _buttonNormalRenderer; case BRIGHT_HIGHLIGHT: return _buttonClickedRenderer; default: return nullptr; } } else { return _buttonDisableRenderer; } } void Button::normalTextureScaleChangedWithSize() { if (_ignoreSize) { if (!_scale9Enabled) { _buttonNormalRenderer->setScale(1.0f); _normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f; _size = _normalTextureSize; } } else { if (_scale9Enabled) { static_cast(_buttonNormalRenderer)->setPreferredSize(_size); _normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f; } else { Size textureSize = _normalTextureSize; if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _buttonNormalRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _buttonNormalRenderer->setScaleX(scaleX); _buttonNormalRenderer->setScaleY(scaleY); _normalTextureScaleXInSize = scaleX; _normalTextureScaleYInSize = scaleY; } } } void Button::pressedTextureScaleChangedWithSize() { if (_ignoreSize) { if (!_scale9Enabled) { _buttonClickedRenderer->setScale(1.0f); _pressedTextureScaleXInSize = _pressedTextureScaleYInSize = 1.0f; } } else { if (_scale9Enabled) { static_cast(_buttonClickedRenderer)->setPreferredSize(_size); _pressedTextureScaleXInSize = _pressedTextureScaleYInSize = 1.0f; } else { Size textureSize = _pressedTextureSize; if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _buttonClickedRenderer->setScale(1.0f); return; } float scaleX = _size.width / _pressedTextureSize.width; float scaleY = _size.height / _pressedTextureSize.height; _buttonClickedRenderer->setScaleX(scaleX); _buttonClickedRenderer->setScaleY(scaleY); _pressedTextureScaleXInSize = scaleX; _pressedTextureScaleYInSize = scaleY; } } } void Button::disabledTextureScaleChangedWithSize() { if (_ignoreSize) { if (!_scale9Enabled) { _buttonDisableRenderer->setScale(1.0f); } } else { if (_scale9Enabled) { static_cast(_buttonDisableRenderer)->setPreferredSize(_size); } else { Size textureSize = _disabledTextureSize; if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _buttonDisableRenderer->setScale(1.0f); return; } float scaleX = _size.width / _disabledTextureSize.width; float scaleY = _size.height / _disabledTextureSize.height; _buttonDisableRenderer->setScaleX(scaleX); _buttonDisableRenderer->setScaleY(scaleY); } } } void Button::setPressedActionEnabled(bool enabled) { _pressedActionEnabled = enabled; } void Button::setTitleText(const std::string& text) { _titleRenderer->setString(text); } const std::string& Button::getTitleText() const { return _titleRenderer->getString(); } void Button::setTitleColor(const Color3B& color) { _titleColor = color; _titleRenderer->updateDisplayedColor(color); } const Color3B& Button::getTitleColor() const { return _titleRenderer->getColor(); } void Button::setTitleFontSize(float size) { _titleRenderer->setFontSize(size); } float Button::getTitleFontSize() const { return _titleRenderer->getFontSize(); } void Button::setTitleFontName(const char* fontName) { _titleRenderer->setFontName(fontName); } const char* Button::getTitleFontName() const { return _titleRenderer->getFontName().c_str(); } void Button::setColor(const Color3B &color) { Widget::setColor(color); setTitleColor(_titleColor); } std::string Button::getDescription() const { return "Button"; } Widget* Button::createCloneInstance() { return Button::create(); } void Button::copySpecialProperties(Widget *widget) { Button* button = dynamic_cast(widget); if (button) { _prevIgnoreSize = button->_prevIgnoreSize; setScale9Enabled(button->_scale9Enabled); loadTextureNormal(button->_normalFileName.c_str(), button->_normalTexType); loadTexturePressed(button->_clickedFileName.c_str(), button->_pressedTexType); loadTextureDisabled(button->_disabledFileName.c_str(), button->_disabledTexType); setCapInsetsNormalRenderer(button->_capInsetsNormal); setCapInsetsPressedRenderer(button->_capInsetsPressed); setCapInsetsDisabledRenderer(button->_capInsetsDisabled); setTitleText(button->getTitleText()); setTitleFontName(button->getTitleFontName()); setTitleFontSize(button->getTitleFontSize()); setTitleColor(button->getTitleColor()); setPressedActionEnabled(button->_pressedActionEnabled); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UIButton.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UIBUTTON_H__ #define __UIBUTTON_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui{ /** * @js NA * @lua NA */ class Button : public Widget { public: /** * Default constructor */ Button(); /** * Default destructor */ virtual ~Button(); /** * Allocates and initializes. */ static Button* create(); /** * Load textures for button. * * @param normal normal state texture. * * @param selected selected state texture. * * @param disabled dark state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextures(const char* normal,const char* selected,const char* disabled,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load normal state texture for button. * * @param normal normal state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextureNormal(const char* normal, TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load selected state texture for button. * * @param selected selected state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTexturePressed(const char* selected, TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load dark state texture for button. * * @param disabled dark state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextureDisabled(const char* disabled, TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Sets capinsets for button, if button is using scale9 renderer. * * @param capInsets capinsets for button */ void setCapInsets(const Rect &capInsets); /** * Sets capinsets for button, if button is using scale9 renderer. * * @param capInsets capinsets for button */ void setCapInsetsNormalRenderer(const Rect &capInsets); /** * Sets capinsets for button, if button is using scale9 renderer. * * @param capInsets capinsets for button */ void setCapInsetsPressedRenderer(const Rect &capInsets); /** * Sets capinsets for button, if button is using scale9 renderer. * * @param capInsets capinsets for button */ void setCapInsetsDisabledRenderer(const Rect &capInsets); //override "setAnchorPoint" of widget. virtual void setAnchorPoint(const Point &pt) override; /** * Sets if button is using scale9 renderer. * * @param true that using scale9 renderer, false otherwise. */ virtual void setScale9Enabled(bool able); //override "setFlipX" of widget. virtual void setFlipX(bool flipX) override; //override "setFlipY" of widget. virtual void setFlipY(bool flipY) override; //override "isFlipX" of widget. virtual bool isFlipX() override; //override "isFlipY" of widget. virtual bool isFlipY() override; /** * Changes if button can be clicked zoom effect. * * @param true that can be clicked zoom effect, false otherwise. */ void setPressedActionEnabled(bool enabled); //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; //override "getContentSize" method of widget. virtual const Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; /** * Sets color to widget * * It default change the color of widget's children. * * @param color */ virtual void setColor(const Color3B &color) override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; void setTitleText(const std::string& text); const std::string& getTitleText() const; void setTitleColor(const Color3B& color); const Color3B& getTitleColor() const; void setTitleFontSize(float size); float getTitleFontSize() const; void setTitleFontName(const char* fontName); const char* getTitleFontName() const; protected: virtual bool init() override; virtual void initRenderer() override; virtual void onPressStateChangedToNormal() override; virtual void onPressStateChangedToPressed() override; virtual void onPressStateChangedToDisabled() override; virtual void onSizeChanged() override; void normalTextureScaleChangedWithSize(); void pressedTextureScaleChangedWithSize(); void disabledTextureScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: Node* _buttonNormalRenderer; Node* _buttonClickedRenderer; Node* _buttonDisableRenderer; LabelTTF* _titleRenderer; std::string _normalFileName; std::string _clickedFileName; std::string _disabledFileName; bool _prevIgnoreSize; bool _scale9Enabled; Rect _capInsetsNormal; Rect _capInsetsPressed; Rect _capInsetsDisabled; TextureResType _normalTexType; TextureResType _pressedTexType; TextureResType _disabledTexType; Size _normalTextureSize; Size _pressedTextureSize; Size _disabledTextureSize; bool _pressedActionEnabled; Color3B _titleColor; float _normalTextureScaleXInSize; float _normalTextureScaleYInSize; float _pressedTextureScaleXInSize; float _pressedTextureScaleYInSize; bool _normalTextureLoaded; bool _pressedTextureLoaded; bool _disabledTextureLoaded; }; } NS_CC_END #endif /* defined(__CocoGUI__Button__) */ ================================================ FILE: cocos2d/cocos/gui/UICheckBox.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UICheckBox.h" NS_CC_BEGIN namespace gui { static const int BACKGROUNDBOX_RENDERER_Z = (-1); static const int BACKGROUNDSELECTEDBOX_RENDERER_Z = (-1); static const int FRONTCROSS_RENDERER_Z = (-1); static const int BACKGROUNDBOXDISABLED_RENDERER_Z = (-1); static const int FRONTCROSSDISABLED_RENDERER_Z = (-1); CheckBox::CheckBox(): _backGroundBoxRenderer(nullptr), _backGroundSelectedBoxRenderer(nullptr), _frontCrossRenderer(nullptr), _backGroundBoxDisabledRenderer(nullptr), _frontCrossDisabledRenderer(nullptr), _isSelected(true), _checkBoxEventListener(nullptr), _checkBoxEventSelector(nullptr), _backGroundTexType(UI_TEX_TYPE_LOCAL), _backGroundSelectedTexType(UI_TEX_TYPE_LOCAL), _frontCrossTexType(UI_TEX_TYPE_LOCAL), _backGroundDisabledTexType(UI_TEX_TYPE_LOCAL), _frontCrossDisabledTexType(UI_TEX_TYPE_LOCAL), _backGroundFileName(""), _backGroundSelectedFileName(""), _frontCrossFileName(""), _backGroundDisabledFileName(""), _frontCrossDisabledFileName("") { } CheckBox::~CheckBox() { _checkBoxEventListener = nullptr; _checkBoxEventSelector = nullptr; } CheckBox* CheckBox::create() { CheckBox* widget = new CheckBox(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } bool CheckBox::init() { if (Widget::init()) { setSelectedState(false); return true; } return false; } void CheckBox::initRenderer() { _backGroundBoxRenderer = Sprite::create(); _backGroundSelectedBoxRenderer = Sprite::create(); _frontCrossRenderer = Sprite::create(); _backGroundBoxDisabledRenderer = Sprite::create(); _frontCrossDisabledRenderer = Sprite::create(); Node::addChild(_backGroundBoxRenderer, BACKGROUNDBOX_RENDERER_Z, -1); Node::addChild(_backGroundSelectedBoxRenderer, BACKGROUNDSELECTEDBOX_RENDERER_Z, -1); Node::addChild(_frontCrossRenderer, FRONTCROSS_RENDERER_Z, -1); Node::addChild(_backGroundBoxDisabledRenderer, BACKGROUNDBOXDISABLED_RENDERER_Z, -1); Node::addChild(_frontCrossDisabledRenderer, FRONTCROSSDISABLED_RENDERER_Z, -1); } void CheckBox::loadTextures(const char *backGround, const char *backGroundSelected, const char *cross,const char* backGroundDisabled,const char* frontCrossDisabled,TextureResType texType) { loadTextureBackGround(backGround,texType); loadTextureBackGroundSelected(backGroundSelected,texType); loadTextureFrontCross(cross,texType); loadTextureBackGroundDisabled(backGroundDisabled,texType); loadTextureFrontCrossDisabled(frontCrossDisabled,texType); } void CheckBox::loadTextureBackGround(const char *backGround,TextureResType texType) { if (!backGround || strcmp(backGround, "") == 0) { return; } _backGroundFileName = backGround; _backGroundTexType = texType; switch (_backGroundTexType) { case UI_TEX_TYPE_LOCAL: _backGroundBoxRenderer->setTexture(backGround); break; case UI_TEX_TYPE_PLIST: _backGroundBoxRenderer->setSpriteFrame(backGround); break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); backGroundTextureScaleChangedWithSize(); } void CheckBox::loadTextureBackGroundSelected(const char *backGroundSelected,TextureResType texType) { if (!backGroundSelected || strcmp(backGroundSelected, "") == 0) { return; } _backGroundSelectedFileName = backGroundSelected; _backGroundSelectedTexType = texType; switch (_backGroundSelectedTexType) { case UI_TEX_TYPE_LOCAL: _backGroundSelectedBoxRenderer->setTexture(backGroundSelected); break; case UI_TEX_TYPE_PLIST: _backGroundSelectedBoxRenderer->setSpriteFrame(backGroundSelected); break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); backGroundSelectedTextureScaleChangedWithSize(); } void CheckBox::loadTextureFrontCross(const char *cross,TextureResType texType) { if (!cross || strcmp(cross, "") == 0) { return; } _frontCrossFileName = cross; _frontCrossTexType = texType; switch (_frontCrossTexType) { case UI_TEX_TYPE_LOCAL: _frontCrossRenderer->setTexture(cross); break; case UI_TEX_TYPE_PLIST: _frontCrossRenderer->setSpriteFrame(cross); break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); frontCrossTextureScaleChangedWithSize(); } void CheckBox::loadTextureBackGroundDisabled(const char *backGroundDisabled,TextureResType texType) { if (!backGroundDisabled || strcmp(backGroundDisabled, "") == 0) { return; } _backGroundDisabledFileName = backGroundDisabled; _backGroundDisabledTexType = texType; switch (_backGroundDisabledTexType) { case UI_TEX_TYPE_LOCAL: _backGroundBoxDisabledRenderer->setTexture(backGroundDisabled); break; case UI_TEX_TYPE_PLIST: _backGroundBoxDisabledRenderer->setSpriteFrame(backGroundDisabled); break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); backGroundDisabledTextureScaleChangedWithSize(); } void CheckBox::loadTextureFrontCrossDisabled(const char *frontCrossDisabled,TextureResType texType) { if (!frontCrossDisabled || strcmp(frontCrossDisabled, "") == 0) { return; } _frontCrossDisabledFileName = frontCrossDisabled; _frontCrossDisabledTexType = texType; switch (_frontCrossDisabledTexType) { case UI_TEX_TYPE_LOCAL: _frontCrossDisabledRenderer->setTexture(frontCrossDisabled); break; case UI_TEX_TYPE_PLIST: _frontCrossDisabledRenderer->setSpriteFrame(frontCrossDisabled); break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); frontCrossDisabledTextureScaleChangedWithSize(); } void CheckBox::onTouchEnded(Touch *touch, Event *unusedEvent) { _touchEndPos = touch->getLocation(); if (_focus) { releaseUpEvent(); if (_isSelected){ setSelectedState(false); unSelectedEvent(); } else { setSelectedState(true); selectedEvent(); } } setFocused(false); Widget* widgetParent = getWidgetParent(); if (widgetParent) { widgetParent->checkChildInfo(2,this,_touchEndPos); } } void CheckBox::onPressStateChangedToNormal() { _backGroundBoxRenderer->setVisible(true); _backGroundSelectedBoxRenderer->setVisible(false); _backGroundBoxDisabledRenderer->setVisible(false); _frontCrossDisabledRenderer->setVisible(false); } void CheckBox::onPressStateChangedToPressed() { _backGroundBoxRenderer->setVisible(false); _backGroundSelectedBoxRenderer->setVisible(true); _backGroundBoxDisabledRenderer->setVisible(false); _frontCrossDisabledRenderer->setVisible(false); } void CheckBox::onPressStateChangedToDisabled() { _backGroundBoxRenderer->setVisible(false); _backGroundSelectedBoxRenderer->setVisible(false); _backGroundBoxDisabledRenderer->setVisible(true); _frontCrossRenderer->setVisible(false); if (_isSelected) { _frontCrossDisabledRenderer->setVisible(true); } } void CheckBox::setSelectedState(bool selected) { if (selected == _isSelected) { return; } _isSelected = selected; _frontCrossRenderer->setVisible(_isSelected); } bool CheckBox::getSelectedState() { return _isSelected; } void CheckBox::selectedEvent() { if (_checkBoxEventListener && _checkBoxEventSelector) { (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_SELECTED); } } void CheckBox::unSelectedEvent() { if (_checkBoxEventListener && _checkBoxEventSelector) { (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_UNSELECTED); } } void CheckBox::addEventListenerCheckBox(Object *target, SEL_SelectedStateEvent selector) { _checkBoxEventListener = target; _checkBoxEventSelector = selector; } void CheckBox::setFlipX(bool flipX) { _backGroundBoxRenderer->setFlippedX(flipX); _backGroundSelectedBoxRenderer->setFlippedX(flipX); _frontCrossRenderer->setFlippedX(flipX); _backGroundBoxDisabledRenderer->setFlippedX(flipX); _frontCrossDisabledRenderer->setFlippedX(flipX); } void CheckBox::setFlipY(bool flipY) { _backGroundBoxRenderer->setFlippedY(flipY); _backGroundSelectedBoxRenderer->setFlippedY(flipY); _frontCrossRenderer->setFlippedY(flipY); _backGroundBoxDisabledRenderer->setFlippedY(flipY); _frontCrossDisabledRenderer->setFlippedY(flipY); } bool CheckBox::isFlipX() { return _backGroundBoxRenderer->isFlippedX(); } bool CheckBox::isFlipY() { return _backGroundBoxRenderer->isFlippedY(); } void CheckBox::setAnchorPoint(const Point &pt) { Widget::setAnchorPoint(pt); _backGroundBoxRenderer->setAnchorPoint(pt); _backGroundSelectedBoxRenderer->setAnchorPoint(pt); _backGroundBoxDisabledRenderer->setAnchorPoint(pt); _frontCrossRenderer->setAnchorPoint(pt); _frontCrossDisabledRenderer->setAnchorPoint(pt); } void CheckBox::onSizeChanged() { Widget::onSizeChanged(); backGroundTextureScaleChangedWithSize(); backGroundSelectedTextureScaleChangedWithSize(); frontCrossTextureScaleChangedWithSize(); backGroundDisabledTextureScaleChangedWithSize(); frontCrossDisabledTextureScaleChangedWithSize(); } const Size& CheckBox::getContentSize() const { return _backGroundBoxRenderer->getContentSize(); } Node* CheckBox::getVirtualRenderer() { return _backGroundBoxRenderer; } void CheckBox::backGroundTextureScaleChangedWithSize() { if (_ignoreSize) { _backGroundBoxRenderer->setScale(1.0f); _size = _backGroundBoxRenderer->getContentSize(); } else { Size textureSize = _backGroundBoxRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _backGroundBoxRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _backGroundBoxRenderer->setScaleX(scaleX); _backGroundBoxRenderer->setScaleY(scaleY); } } void CheckBox::backGroundSelectedTextureScaleChangedWithSize() { if (_ignoreSize) { _backGroundSelectedBoxRenderer->setScale(1.0f); } else { Size textureSize = _backGroundSelectedBoxRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _backGroundSelectedBoxRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _backGroundSelectedBoxRenderer->setScaleX(scaleX); _backGroundSelectedBoxRenderer->setScaleY(scaleY); } } void CheckBox::frontCrossTextureScaleChangedWithSize() { if (_ignoreSize) { _frontCrossRenderer->setScale(1.0f); } else { Size textureSize = _frontCrossRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _frontCrossRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _frontCrossRenderer->setScaleX(scaleX); _frontCrossRenderer->setScaleY(scaleY); } } void CheckBox::backGroundDisabledTextureScaleChangedWithSize() { if (_ignoreSize) { _backGroundBoxDisabledRenderer->setScale(1.0f); } else { Size textureSize = _backGroundBoxDisabledRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _backGroundBoxDisabledRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _backGroundBoxDisabledRenderer->setScaleX(scaleX); _backGroundBoxDisabledRenderer->setScaleY(scaleY); } } void CheckBox::frontCrossDisabledTextureScaleChangedWithSize() { if (_ignoreSize) { _frontCrossDisabledRenderer->setScale(1.0f); } else { Size textureSize = _frontCrossDisabledRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _frontCrossDisabledRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _frontCrossDisabledRenderer->setScaleX(scaleX); _frontCrossDisabledRenderer->setScaleY(scaleY); } } std::string CheckBox::getDescription() const { return "CheckBox"; } Widget* CheckBox::createCloneInstance() { return CheckBox::create(); } void CheckBox::copySpecialProperties(Widget *widget) { CheckBox* checkBox = dynamic_cast(widget); if (checkBox) { loadTextureBackGround(checkBox->_backGroundFileName.c_str(), checkBox->_backGroundTexType); loadTextureBackGroundSelected(checkBox->_backGroundSelectedFileName.c_str(), checkBox->_backGroundSelectedTexType); loadTextureFrontCross(checkBox->_frontCrossFileName.c_str(), checkBox->_frontCrossTexType); loadTextureBackGroundDisabled(checkBox->_backGroundDisabledFileName.c_str(), checkBox->_backGroundDisabledTexType); loadTextureFrontCrossDisabled(checkBox->_frontCrossDisabledFileName.c_str(), checkBox->_frontCrossDisabledTexType); setSelectedState(checkBox->_isSelected); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UICheckBox.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UICHECKBOX_H__ #define __UICHECKBOX_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { typedef enum { CHECKBOX_STATE_EVENT_SELECTED, CHECKBOX_STATE_EVENT_UNSELECTED }CheckBoxEventType; typedef void (Object::*SEL_SelectedStateEvent)(Object*,CheckBoxEventType); #define checkboxselectedeventselector(_SELECTOR) (SEL_SelectedStateEvent)(&_SELECTOR) /** * @js NA * @lua NA */ class CheckBox : public Widget { public: /** * Default constructor */ CheckBox(); /** * Default destructor */ virtual ~CheckBox(); /** * Allocates and initializes. */ static CheckBox* create(); /** * Load textures for checkbox. * * @param backGround backGround texture. * * @param backGroundSelected backGround selected state texture. * * @param cross cross texture. * * @param frontCrossDisabled cross dark state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextures(const char* backGround,const char* backGroundSelected,const char* cross,const char* backGroundDisabled,const char* frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load backGround texture for checkbox. * * @param backGround backGround texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextureBackGround(const char* backGround,TextureResType type = UI_TEX_TYPE_LOCAL); /** * Load backGroundSelected texture for checkbox. * * @param backGroundSelected backGround selected state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextureBackGroundSelected(const char* backGroundSelected,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load cross texture for checkbox. * * @param cross cross texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextureFrontCross(const char* cross,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load backGroundDisabled texture for checkbox. * * @param backGroundDisabled backGroundDisabled texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextureBackGroundDisabled(const char* backGroundDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load frontCrossDisabled texture for checkbox. * * @param frontCrossDisabled frontCrossDisabled texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTextureFrontCrossDisabled(const char* frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Sets selcted state for checkbox. * * @param selected true that checkbox is selected, false otherwise. */ void setSelectedState(bool selected); /** * Gets selcted state of checkbox. * * @return selected true that checkbox is selected, false otherwise. */ bool getSelectedState(); //override "setAnchorPoint" method of widget. virtual void setAnchorPoint(const Point &pt) override; //add a call back function would called when checkbox is selected or unselected. void addEventListenerCheckBox(Object* target,SEL_SelectedStateEvent selector); //override "setFlipX" method of widget. virtual void setFlipX(bool flipX) override; //override "setFlipY" method of widget. virtual void setFlipY(bool flipY) override; //override "isFlipX" method of widget. virtual bool isFlipX() override; //override "isFlipY" method of widget. virtual bool isFlipY() override; //override "onTouchEnded" method of widget. virtual void onTouchEnded(Touch *touch, Event *unusedEvent); //override "getContentSize" method of widget. virtual const Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; protected: virtual bool init() override; virtual void initRenderer() override; virtual void onPressStateChangedToNormal() override; virtual void onPressStateChangedToPressed() override; virtual void onPressStateChangedToDisabled() override; void selectedEvent(); void unSelectedEvent(); virtual void onSizeChanged() override; void backGroundTextureScaleChangedWithSize(); void backGroundSelectedTextureScaleChangedWithSize(); void frontCrossTextureScaleChangedWithSize(); void backGroundDisabledTextureScaleChangedWithSize(); void frontCrossDisabledTextureScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: Sprite* _backGroundBoxRenderer; Sprite* _backGroundSelectedBoxRenderer; Sprite* _frontCrossRenderer; Sprite* _backGroundBoxDisabledRenderer; Sprite* _frontCrossDisabledRenderer; bool _isSelected; Object* _checkBoxEventListener; SEL_SelectedStateEvent _checkBoxEventSelector; TextureResType _backGroundTexType; TextureResType _backGroundSelectedTexType; TextureResType _frontCrossTexType; TextureResType _backGroundDisabledTexType; TextureResType _frontCrossDisabledTexType; std::string _backGroundFileName; std::string _backGroundSelectedFileName; std::string _frontCrossFileName; std::string _backGroundDisabledFileName; std::string _frontCrossDisabledFileName; }; } NS_CC_END #endif /* defined(__CocoGUI__CheckBox__) */ ================================================ FILE: cocos2d/cocos/gui/UIHelper.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CocosGUI.h" NS_CC_BEGIN namespace gui { Widget* Helper::seekWidgetByTag(Widget* root, int tag) { if (!root) { return nullptr; } if (root->getTag() == tag) { return root; } const auto& arrayRootChildren = root->getChildren(); ssize_t length = arrayRootChildren.size(); for (ssize_t i=0;i(arrayRootChildren.at(i)); Widget* res = seekWidgetByTag(child,tag); if (res != nullptr) { return res; } } return nullptr; } Widget* Helper::seekWidgetByName(Widget* root, const char *name) { if (!root) { return nullptr; } if (strcmp(root->getName(), name) == 0) { return root; } const auto& arrayRootChildren = root->getChildren(); for (auto& subWidget : arrayRootChildren) { Widget* child = static_cast(subWidget); Widget* res = seekWidgetByName(child,name); if (res != nullptr) { return res; } } return nullptr; } Widget* Helper::seekWidgetByRelativeName(Widget *root, const char *name) { if (!root) { return nullptr; } const auto& arrayRootChildren = root->getChildren(); for (auto& subWidget : arrayRootChildren) { Widget* child = static_cast(subWidget); RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); if (layoutParameter && strcmp(layoutParameter->getRelativeName(), name) == 0) { return child; } } return nullptr; } /*temp action*/ Widget* Helper::seekActionWidgetByActionTag(Widget* root, int tag) { if (!root) { return nullptr; } if (root->getActionTag() == tag) { return root; } const auto& arrayRootChildren = root->getChildren(); for (auto& subWidget : arrayRootChildren) { Widget* child = static_cast(subWidget); Widget* res = seekActionWidgetByActionTag(child,tag); if (res != nullptr) { return res; } } return nullptr; } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UIHelper.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UIHELPER_H__ #define __UIHELPER_H__ NS_CC_BEGIN namespace gui { /** * @js NA * @lua NA */ class Helper { public: /** * Finds a widget whose tag equals to param tag from root widget. * * @param root widget which will be seeked. * * @tag tag value. * * @return finded result. */ static Widget* seekWidgetByTag(Widget* root, int tag); /** * Finds a widget whose name equals to param name from root widget. * * @param root widget which will be seeked. * * @name name value. * * @return finded result. */ static Widget* seekWidgetByName(Widget* root, const char* name); /** * Finds a widget whose name equals to param name from root widget. * * RelativeLayout will call this method to find the widget witch is needed. * * @param root widget which will be seeked. * * @name name value. * * @return finded result. */ static Widget* seekWidgetByRelativeName(Widget* root, const char* name); /*temp action*/ static Widget* seekActionWidgetByActionTag(Widget* root, int tag); }; } NS_CC_END #endif /* defined(__CocoGUI__UISystem__) */ ================================================ FILE: cocos2d/cocos/gui/UIImageView.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UIImageView.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" NS_CC_BEGIN namespace gui { #define STATIC_CAST_CCSPRITE static_cast(_imageRenderer) #define STATIC_CAST_SCALE9SPRITE static_cast(_imageRenderer) static const int IMAGE_RENDERER_Z = (-1); ImageView::ImageView(): _scale9Enabled(false), _prevIgnoreSize(true), _capInsets(Rect::ZERO), _imageRenderer(nullptr), _textureFile(""), _imageTexType(UI_TEX_TYPE_LOCAL), _imageTextureSize(_size) { } ImageView::~ImageView() { } ImageView* ImageView::create() { ImageView* widget = new ImageView(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } void ImageView::initRenderer() { _imageRenderer = Sprite::create(); Node::addChild(_imageRenderer, IMAGE_RENDERER_Z, -1); } void ImageView::loadTexture(const char *fileName, TextureResType texType) { if (!fileName || strcmp(fileName, "") == 0) { return; } _textureFile = fileName; _imageTexType = texType; switch (_imageTexType) { case UI_TEX_TYPE_LOCAL: if (_scale9Enabled) { extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE; imageRendererScale9->initWithFile(fileName); imageRendererScale9->setCapInsets(_capInsets); } else { Sprite* imageRenderer = STATIC_CAST_CCSPRITE; imageRenderer->setTexture(fileName); } break; case UI_TEX_TYPE_PLIST: if (_scale9Enabled) { extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE; imageRendererScale9->initWithSpriteFrameName(fileName); imageRendererScale9->setCapInsets(_capInsets); } else { Sprite* imageRenderer = STATIC_CAST_CCSPRITE; imageRenderer->setSpriteFrame(fileName); } break; default: break; } _imageTextureSize = _imageRenderer->getContentSize(); updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); imageTextureScaleChangedWithSize(); } void ImageView::setTextureRect(const Rect &rect) { if (_scale9Enabled) { } else { STATIC_CAST_CCSPRITE->setTextureRect(rect); } } void ImageView::setFlipX(bool flipX) { if (_scale9Enabled) { } else { STATIC_CAST_CCSPRITE->setFlippedX(flipX); } } void ImageView::setFlipY(bool flipY) { if (_scale9Enabled) { } else { STATIC_CAST_CCSPRITE->setFlippedY(flipY); } } bool ImageView::isFlipX() { if (_scale9Enabled) { return false; } else { return STATIC_CAST_CCSPRITE->isFlippedX(); } } bool ImageView::isFlipY() { if (_scale9Enabled) { return false; } else { return STATIC_CAST_CCSPRITE->isFlippedY(); } } void ImageView::setScale9Enabled(bool able) { if (_scale9Enabled == able) { return; } _scale9Enabled = able; Node::removeChild(_imageRenderer); _imageRenderer = nullptr; if (_scale9Enabled) { _imageRenderer = extension::Scale9Sprite::create(); } else { _imageRenderer = Sprite::create(); } loadTexture(_textureFile.c_str(),_imageTexType); Node::addChild(_imageRenderer, IMAGE_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; ignoreContentAdaptWithSize(false); _prevIgnoreSize = ignoreBefore; } else { ignoreContentAdaptWithSize(_prevIgnoreSize); } setCapInsets(_capInsets); } void ImageView::ignoreContentAdaptWithSize(bool ignore) { if (!_scale9Enabled || (_scale9Enabled && !ignore)) { Widget::ignoreContentAdaptWithSize(ignore); _prevIgnoreSize = ignore; } } void ImageView::setCapInsets(const Rect &capInsets) { _capInsets = capInsets; if (!_scale9Enabled) { return; } STATIC_CAST_SCALE9SPRITE->setCapInsets(capInsets); } void ImageView::setAnchorPoint(const Point &pt) { Widget::setAnchorPoint(pt); _imageRenderer->setAnchorPoint(pt); } void ImageView::onSizeChanged() { Widget::onSizeChanged(); imageTextureScaleChangedWithSize(); } const Size& ImageView::getContentSize() const { return _imageTextureSize; } Node* ImageView::getVirtualRenderer() { return _imageRenderer; } void ImageView::imageTextureScaleChangedWithSize() { if (_ignoreSize) { if (!_scale9Enabled) { _imageRenderer->setScale(1.0f); _size = _imageTextureSize; } } else { if (_scale9Enabled) { static_cast(_imageRenderer)->setPreferredSize(_size); } else { Size textureSize = _imageRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _imageRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _imageRenderer->setScaleX(scaleX); _imageRenderer->setScaleY(scaleY); } } } std::string ImageView::getDescription() const { return "ImageView"; } Widget* ImageView::createCloneInstance() { return ImageView::create(); } void ImageView::copySpecialProperties(Widget *widget) { ImageView* imageView = dynamic_cast(widget); if (imageView) { _prevIgnoreSize = imageView->_prevIgnoreSize; setScale9Enabled(imageView->_scale9Enabled); loadTexture(imageView->_textureFile.c_str(), imageView->_imageTexType); setCapInsets(imageView->_capInsets); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UIImageView.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UIIMAGEVIEW_H__ #define __UIIMAGEVIEW_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { /** * @js NA * @lua NA */ class ImageView : public Widget { public: /** * Default constructor */ ImageView(); /** * Default destructor */ virtual ~ImageView(); /** * Allocates and initializes. */ static ImageView* create(); /** * Load texture for imageview. * * @param fileName file name of texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTexture(const char* fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Updates the texture rect of the ImageView in points. * It will call setTextureRect:rotated:untrimmedSize with rotated = NO, and utrimmedSize = rect.size. */ void setTextureRect(const Rect& rect); /** * Sets if imageview is using scale9 renderer. * * @param true that using scale9 renderer, false otherwise. */ void setScale9Enabled(bool able); /** * Sets capinsets for imageview, if imageview is using scale9 renderer. * * @param capInsets capinsets for imageview */ void setCapInsets(const Rect &capInsets); //override "setFlipX" method of widget. virtual void setFlipX(bool flipX) override; //override "setFlipY" method of widget. virtual void setFlipY(bool flipY) override; //override "isFlipX" method of widget. virtual bool isFlipX() override; //override "isFlipY" method of widget. virtual bool isFlipY() override; //override "setAnchorPoint" method of widget. virtual void setAnchorPoint(const Point &pt) override; //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; virtual const Size& getContentSize() const override; virtual Node* getVirtualRenderer() override; protected: virtual void initRenderer() override; virtual void onSizeChanged() override; void imageTextureScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: bool _scale9Enabled; bool _prevIgnoreSize; Rect _capInsets; Node* _imageRenderer; std::string _textureFile; TextureResType _imageTexType; Size _imageTextureSize; }; } NS_CC_END #endif /* defined(__CocoGUI__ImageView__) */ ================================================ FILE: cocos2d/cocos/gui/UILayout.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UILayout.h" #include "gui/UIHelper.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" #include "kazmath/GL/matrix.h" #include "CCGLProgram.h" #include "CCShaderCache.h" #include "CCDirector.h" #include "CCDrawingPrimitives.h" #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCCustomCommand.h" NS_CC_BEGIN namespace gui { static const int BACKGROUNDIMAGE_Z = (-1); static const int BCAKGROUNDCOLORRENDERER_Z = (-2); static GLint g_sStencilBits = -1; static GLint s_layer = -1; Layout::Layout(): _clippingEnabled(false), _backGroundScale9Enabled(false), _backGroundImage(nullptr), _backGroundImageFileName(""), _backGroundImageCapInsets(Rect::ZERO), _colorType(LAYOUT_COLOR_NONE), _bgImageTexType(UI_TEX_TYPE_LOCAL), _colorRender(nullptr), _gradientRender(nullptr), _cColor(Color3B::WHITE), _gStartColor(Color3B::WHITE), _gEndColor(Color3B::WHITE), _alongVector(Point(0.0f, -1.0f)), _cOpacity(255), _backGroundImageTextureSize(Size::ZERO), _layoutType(LAYOUT_ABSOLUTE), _clippingType(LAYOUT_CLIPPING_STENCIL), _clippingStencil(nullptr), _scissorRectDirty(false), _clippingRect(Rect::ZERO), _clippingParent(nullptr), _doLayoutDirty(true), _currentStencilEnabled(GL_FALSE), _currentStencilWriteMask(~0), _currentStencilFunc(GL_ALWAYS), _currentStencilRef(0), _currentStencilValueMask(~0), _currentStencilFail(GL_KEEP), _currentStencilPassDepthFail(GL_KEEP), _currentStencilPassDepthPass(GL_KEEP), _currentDepthWriteMask(GL_TRUE), _currentAlphaTestEnabled(GL_FALSE), _currentAlphaTestFunc(GL_ALWAYS), _currentAlphaTestRef(1) { _widgetType = WidgetTypeContainer; } Layout::~Layout() { CC_SAFE_RELEASE(_clippingStencil); } void Layout::onEnter() { Widget::onEnter(); if (_clippingStencil) { _clippingStencil->onEnter(); } } void Layout::onExit() { Widget::onExit(); if (_clippingStencil) { _clippingStencil->onExit(); } } Layout* Layout::create() { Layout* layout = new Layout(); if (layout && layout->init()) { layout->autorelease(); return layout; } CC_SAFE_DELETE(layout); return nullptr; } bool Layout::init() { if (Node::init()) { initRenderer(); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setBright(true); ignoreContentAdaptWithSize(false); setSize(Size::ZERO); setAnchorPoint(Point::ZERO); return true; } return false; } void Layout::addChild(Node *child) { Widget::addChild(child); } void Layout::addChild(Node * child, int zOrder) { Widget::addChild(child, zOrder); } void Layout::addChild(Node *child, int zOrder, int tag) { supplyTheLayoutParameterLackToChild(static_cast(child)); Widget::addChild(child, zOrder, tag); _doLayoutDirty = true; } bool Layout::isClippingEnabled() { return _clippingEnabled; } bool Layout::hitTest(const Point &pt) { Point nsp = convertToNodeSpace(pt); Rect bb = Rect(0.0f, 0.0f, _size.width, _size.height); if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height) { return true; } return false; } void Layout::visit() { if (!_enabled) { return; } if (_clippingEnabled) { switch (_clippingType) { case LAYOUT_CLIPPING_STENCIL: stencilClippingVisit(); break; case LAYOUT_CLIPPING_SCISSOR: scissorClippingVisit(); break; default: break; } } else { Node::visit(); } } void Layout::sortAllChildren() { Widget::sortAllChildren(); doLayout(); } void Layout::stencilClippingVisit() { if(!_visible) return; kmGLPushMatrix(); transform(); //Add group command Renderer* renderer = Director::getInstance()->getRenderer(); _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); _beforeVisitCmdStencil.init(_globalZOrder); _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this); renderer->addCommand(&_beforeVisitCmdStencil); _clippingStencil->visit(); _afterDrawStencilCmd.init(_globalZOrder); _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this); renderer->addCommand(&_afterDrawStencilCmd); int i = 0; if(!_children.empty()) { sortAllChildren(); // draw children zOrder < 0 for( ; i < _children.size(); i++ ) { auto node = _children.at(i); if ( node && node->getLocalZOrder() < 0 ) node->visit(); else break; } // self draw this->draw(); for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) (*it)->visit(); } else { this->draw(); } _afterVisitCmdStencil.init(_globalZOrder); _afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this); renderer->addCommand(&_afterVisitCmdStencil); renderer->popGroup(); kmGLPopMatrix(); } void Layout::onBeforeVisitStencil() { s_layer++; GLint mask_layer = 0x1 << s_layer; GLint mask_layer_l = mask_layer - 1; _mask_layer_le = mask_layer | mask_layer_l; _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); glEnable(GL_STENCIL_TEST); CHECK_GL_ERROR_DEBUG(); glStencilMask(mask_layer); glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); glDepthMask(GL_FALSE); glStencilFunc(GL_NEVER, mask_layer, mask_layer); glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPushMatrix(); kmGLLoadIdentity(); kmGLMatrixMode(KM_GL_PROJECTION); kmGLPushMatrix(); kmGLLoadIdentity(); DrawPrimitives::drawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1)); kmGLMatrixMode(KM_GL_PROJECTION); kmGLPopMatrix(); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPopMatrix(); glStencilFunc(GL_NEVER, mask_layer, mask_layer); glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); } void Layout::onAfterDrawStencil() { glDepthMask(_currentDepthWriteMask); glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); } void Layout::onAfterVisitStencil() { glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); glStencilMask(_currentStencilWriteMask); if (!_currentStencilEnabled) { glDisable(GL_STENCIL_TEST); } s_layer--; } void Layout::onBeforeVisitScissor() { Rect clippingRect = getClippingRect(); glEnable(GL_SCISSOR_TEST); EGLView::getInstance()->setScissorInPoints(clippingRect.origin.x, clippingRect.origin.y, clippingRect.size.width, clippingRect.size.height); } void Layout::onAfterVisitScissor() { glDisable(GL_SCISSOR_TEST); } void Layout::scissorClippingVisit() { Renderer* renderer = Director::getInstance()->getRenderer(); _beforeVisitCmdScissor.init(_globalZOrder); _beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this); renderer->addCommand(&_beforeVisitCmdScissor); Node::visit(); _afterVisitCmdScissor.init(_globalZOrder); _afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this); renderer->addCommand(&_afterVisitCmdScissor); } void Layout::setClippingEnabled(bool able) { if (able == _clippingEnabled) { return; } _clippingEnabled = able; switch (_clippingType) { case LAYOUT_CLIPPING_STENCIL: if (able) { static bool once = true; if (once) { glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits); if (g_sStencilBits <= 0) { CCLOG("Stencil buffer is not enabled."); } once = false; } _clippingStencil = DrawNode::create(); if (_running) { _clippingStencil->onEnter(); } _clippingStencil->retain(); setStencilClippingSize(_size); } else { if (_running) { _clippingStencil->onExit(); } _clippingStencil->release(); _clippingStencil = nullptr; } break; default: break; } } void Layout::setClippingType(LayoutClippingType type) { if (type == _clippingType) { return; } bool clippingEnabled = isClippingEnabled(); setClippingEnabled(false); _clippingType = type; setClippingEnabled(clippingEnabled); } void Layout::setStencilClippingSize(const Size &size) { if (_clippingEnabled && _clippingType == LAYOUT_CLIPPING_STENCIL) { Point rect[4]; rect[0] = Point::ZERO; rect[1] = Point(_size.width, 0); rect[2] = Point(_size.width, _size.height); rect[3] = Point(0, _size.height); Color4F green(0, 1, 0, 1); _clippingStencil->clear(); _clippingStencil->drawPolygon(rect, 4, green, 0, green); } } const Rect& Layout::getClippingRect() { Point worldPos = convertToWorldSpace(Point::ZERO); AffineTransform t = getNodeToWorldAffineTransform(); float scissorWidth = _size.width*t.a; float scissorHeight = _size.height*t.d; Rect parentClippingRect; Layout* parent = this; bool firstClippingParentFounded = false; while (parent) { parent = dynamic_cast(parent->getParent()); if(parent) { if (parent->isClippingEnabled()) { if (!firstClippingParentFounded) { _clippingParent = parent; firstClippingParentFounded = true; break; } } } } if (_clippingParent) { parentClippingRect = _clippingParent->getClippingRect(); float finalX = worldPos.x - (scissorWidth * _anchorPoint.x); float finalY = worldPos.y - (scissorHeight * _anchorPoint.y); float finalWidth = scissorWidth; float finalHeight = scissorHeight; float leftOffset = worldPos.x - parentClippingRect.origin.x; if (leftOffset < 0.0f) { finalX = parentClippingRect.origin.x; finalWidth += leftOffset; } float rightOffset = (worldPos.x + scissorWidth) - (parentClippingRect.origin.x + parentClippingRect.size.width); if (rightOffset > 0.0f) { finalWidth -= rightOffset; } float topOffset = (worldPos.y + scissorHeight) - (parentClippingRect.origin.y + parentClippingRect.size.height); if (topOffset > 0.0f) { finalHeight -= topOffset; } float bottomOffset = worldPos.y - parentClippingRect.origin.y; if (bottomOffset < 0.0f) { finalY = parentClippingRect.origin.x; finalHeight += bottomOffset; } if (finalWidth < 0.0f) { finalWidth = 0.0f; } if (finalHeight < 0.0f) { finalHeight = 0.0f; } _clippingRect.origin.x = finalX; _clippingRect.origin.y = finalY; _clippingRect.size.width = finalWidth; _clippingRect.size.height = finalHeight; } else { _clippingRect.origin.x = worldPos.x - (scissorWidth * _anchorPoint.x); _clippingRect.origin.y = worldPos.y - (scissorHeight * _anchorPoint.y); _clippingRect.size.width = scissorWidth; _clippingRect.size.height = scissorHeight; } return _clippingRect; } void Layout::onSizeChanged() { Widget::onSizeChanged(); setContentSize(_size); setStencilClippingSize(_size); _doLayoutDirty = true; if (_backGroundImage) { _backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f)); if (_backGroundScale9Enabled && _backGroundImage) { static_cast(_backGroundImage)->setPreferredSize(_size); } } if (_colorRender) { _colorRender->setContentSize(_size); } if (_gradientRender) { _gradientRender->setContentSize(_size); } } void Layout::setBackGroundImageScale9Enabled(bool able) { if (_backGroundScale9Enabled == able) { return; } Node::removeChild(_backGroundImage); _backGroundImage = nullptr; _backGroundScale9Enabled = able; if (_backGroundScale9Enabled) { _backGroundImage = extension::Scale9Sprite::create(); Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } else { _backGroundImage = Sprite::create(); Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } setBackGroundImage(_backGroundImageFileName.c_str(),_bgImageTexType); setBackGroundImageCapInsets(_backGroundImageCapInsets); } void Layout::setBackGroundImage(const char* fileName,TextureResType texType) { if (!fileName || strcmp(fileName, "") == 0) { return; } if (_backGroundImage == nullptr) { addBackGroundImage(); } _backGroundImageFileName = fileName; _bgImageTexType = texType; if (_backGroundScale9Enabled) { extension::Scale9Sprite* bgiScale9 = static_cast(_backGroundImage); switch (_bgImageTexType) { case UI_TEX_TYPE_LOCAL: bgiScale9->initWithFile(fileName); break; case UI_TEX_TYPE_PLIST: bgiScale9->initWithSpriteFrameName(fileName); break; default: break; } bgiScale9->setPreferredSize(_size); } else { switch (_bgImageTexType) { case UI_TEX_TYPE_LOCAL: static_cast(_backGroundImage)->setTexture(fileName); break; case UI_TEX_TYPE_PLIST: static_cast(_backGroundImage)->setSpriteFrame(fileName); break; default: break; } } if (_backGroundScale9Enabled) { extension::Scale9Sprite* bgiScale9 = static_cast(_backGroundImage); bgiScale9->setColor(getColor()); bgiScale9->setOpacity(getOpacity()); } else { Sprite* bgiScale9 = static_cast(_backGroundImage); bgiScale9->setColor(getColor()); bgiScale9->setOpacity(getOpacity()); } _backGroundImageTextureSize = _backGroundImage->getContentSize(); _backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f)); } void Layout::setBackGroundImageCapInsets(const Rect &capInsets) { _backGroundImageCapInsets = capInsets; if (_backGroundScale9Enabled && _backGroundImage) { static_cast(_backGroundImage)->setCapInsets(capInsets); } } void Layout::supplyTheLayoutParameterLackToChild(Widget *child) { if (!child) { return; } switch (_layoutType) { case LAYOUT_ABSOLUTE: break; case LAYOUT_LINEAR_HORIZONTAL: case LAYOUT_LINEAR_VERTICAL: { LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); if (!layoutParameter) { child->setLayoutParameter(LinearLayoutParameter::create()); } break; } case LAYOUT_RELATIVE: { RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); if (!layoutParameter) { child->setLayoutParameter(RelativeLayoutParameter::create()); } break; } default: break; } } void Layout::addBackGroundImage() { if (_backGroundScale9Enabled) { _backGroundImage = extension::Scale9Sprite::create(); _backGroundImage->setLocalZOrder(-1); Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); static_cast(_backGroundImage)->setPreferredSize(_size); } else { _backGroundImage = Sprite::create(); _backGroundImage->setLocalZOrder(-1); Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } _backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f)); } void Layout::removeBackGroundImage() { if (!_backGroundImage) { return; } Node::removeChild(_backGroundImage); _backGroundImage = nullptr; _backGroundImageFileName = ""; _backGroundImageTextureSize = Size::ZERO; } void Layout::setBackGroundColorType(LayoutBackGroundColorType type) { if (_colorType == type) { return; } switch (_colorType) { case LAYOUT_COLOR_NONE: if (_colorRender) { Node::removeChild(_colorRender); _colorRender = nullptr; } if (_gradientRender) { Node::removeChild(_gradientRender); _gradientRender = nullptr; } break; case LAYOUT_COLOR_SOLID: if (_colorRender) { Node::removeChild(_colorRender); _colorRender = nullptr; } break; case LAYOUT_COLOR_GRADIENT: if (_gradientRender) { Node::removeChild(_gradientRender); _gradientRender = nullptr; } break; default: break; } _colorType = type; switch (_colorType) { case LAYOUT_COLOR_NONE: break; case LAYOUT_COLOR_SOLID: _colorRender = LayerColor::create(); _colorRender->setContentSize(_size); _colorRender->setOpacity(_cOpacity); _colorRender->setColor(_cColor); Node::addChild(_colorRender, BCAKGROUNDCOLORRENDERER_Z, -1); break; case LAYOUT_COLOR_GRADIENT: _gradientRender = LayerGradient::create(); _gradientRender->setContentSize(_size); _gradientRender->setOpacity(_cOpacity); _gradientRender->setStartColor(_gStartColor); _gradientRender->setEndColor(_gEndColor); _gradientRender->setVector(_alongVector); Node::addChild(_gradientRender, BCAKGROUNDCOLORRENDERER_Z, -1); break; default: break; } } void Layout::setBackGroundColor(const Color3B &color) { _cColor = color; if (_colorRender) { _colorRender->setColor(color); } } void Layout::setBackGroundColor(const Color3B &startColor, const Color3B &endColor) { _gStartColor = startColor; if (_gradientRender) { _gradientRender->setStartColor(startColor); } _gEndColor = endColor; if (_gradientRender) { _gradientRender->setEndColor(endColor); } } void Layout::setBackGroundColorOpacity(int opacity) { _cOpacity = opacity; switch (_colorType) { case LAYOUT_COLOR_NONE: break; case LAYOUT_COLOR_SOLID: _colorRender->setOpacity(opacity); break; case LAYOUT_COLOR_GRADIENT: _gradientRender->setOpacity(opacity); break; default: break; } } void Layout::setBackGroundColorVector(const Point &vector) { _alongVector = vector; if (_gradientRender) { _gradientRender->setVector(vector); } } const Size& Layout::getBackGroundImageTextureSize() const { return _backGroundImageTextureSize; } void Layout::setLayoutType(LayoutType type) { _layoutType = type; for (auto& child : _widgetChildren) { if (child) { supplyTheLayoutParameterLackToChild(static_cast(child)); } } _doLayoutDirty = true; } LayoutType Layout::getLayoutType() const { return _layoutType; } void Layout::requestDoLayout() { _doLayoutDirty = true; } void Layout::doLayout() { if (!_doLayoutDirty) { return; } switch (_layoutType) { case LAYOUT_ABSOLUTE: break; case LAYOUT_LINEAR_VERTICAL: { Size layoutSize = getSize(); float topBoundary = layoutSize.height; for (auto& subWidget : _widgetChildren) { Widget* child = static_cast(subWidget); LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); if (layoutParameter) { LinearGravity childGravity = layoutParameter->getGravity(); Point ap = child->getAnchorPoint(); Size cs = child->getSize(); float finalPosX = ap.x * cs.width; float finalPosY = topBoundary - ((1.0f-ap.y) * cs.height); switch (childGravity) { case LINEAR_GRAVITY_NONE: case LINEAR_GRAVITY_LEFT: break; case LINEAR_GRAVITY_RIGHT: finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width); break; case LINEAR_GRAVITY_CENTER_HORIZONTAL: finalPosX = layoutSize.width / 2.0f - cs.width * (0.5f-ap.x); break; default: break; } Margin mg = layoutParameter->getMargin(); finalPosX += mg.left; finalPosY -= mg.top; child->setPosition(Point(finalPosX, finalPosY)); topBoundary = child->getBottomInParent() - mg.bottom; } } break; } case LAYOUT_LINEAR_HORIZONTAL: { Size layoutSize = getSize(); float leftBoundary = 0.0f; for (auto& subWidget : _widgetChildren) { Widget* child = static_cast(subWidget); LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); if (layoutParameter) { LinearGravity childGravity = layoutParameter->getGravity(); Point ap = child->getAnchorPoint(); Size cs = child->getSize(); float finalPosX = leftBoundary + (ap.x * cs.width); float finalPosY = layoutSize.height - (1.0f - ap.y) * cs.height; switch (childGravity) { case LINEAR_GRAVITY_NONE: case LINEAR_GRAVITY_TOP: break; case LINEAR_GRAVITY_BOTTOM: finalPosY = ap.y * cs.height; break; case LINEAR_GRAVITY_CENTER_VERTICAL: finalPosY = layoutSize.height / 2.0f - cs.height * (0.5f - ap.y); break; default: break; } Margin mg = layoutParameter->getMargin(); finalPosX += mg.left; finalPosY -= mg.top; child->setPosition(Point(finalPosX, finalPosY)); leftBoundary = child->getRightInParent() + mg.right; } } break; } case LAYOUT_RELATIVE: { ssize_t unlayoutChildCount = _widgetChildren.size(); Size layoutSize = getSize(); for (auto& subWidget : _widgetChildren) { Widget* child = static_cast(subWidget); RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); layoutParameter->_put = false; } while (unlayoutChildCount > 0) { for (auto& subWidget : _widgetChildren) { Widget* child = static_cast(subWidget); RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); if (layoutParameter) { if (layoutParameter->_put) { continue; } Point ap = child->getAnchorPoint(); Size cs = child->getSize(); RelativeAlign align = layoutParameter->getAlign(); const char* relativeName = layoutParameter->getRelativeToWidgetName(); Widget* relativeWidget = nullptr; RelativeLayoutParameter* relativeWidgetLP = nullptr; float finalPosX = 0.0f; float finalPosY = 0.0f; if (relativeName && strcmp(relativeName, "")) { relativeWidget = Helper::seekWidgetByRelativeName(this, relativeName); if (relativeWidget) { relativeWidgetLP = dynamic_cast(relativeWidget->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); } } switch (align) { case RELATIVE_ALIGN_NONE: case RELATIVE_ALIGN_PARENT_TOP_LEFT: finalPosX = ap.x * cs.width; finalPosY = layoutSize.height - ((1.0f - ap.y) * cs.height); break; case RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL: finalPosX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x); finalPosY = layoutSize.height - ((1.0f - ap.y) * cs.height); break; case RELATIVE_ALIGN_PARENT_TOP_RIGHT: finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width); finalPosY = layoutSize.height - ((1.0f - ap.y) * cs.height); break; case RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL: finalPosX = ap.x * cs.width; finalPosY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y); break; case RELATIVE_CENTER_IN_PARENT: finalPosX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x); finalPosY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y); break; case RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL: finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width); finalPosY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y); break; case RELATIVE_ALIGN_PARENT_LEFT_BOTTOM: finalPosX = ap.x * cs.width; finalPosY = ap.y * cs.height; break; case RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL: finalPosX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x); finalPosY = ap.y * cs.height; break; case RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM: finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width); finalPosY = ap.y * cs.height; break; case RELATIVE_LOCATION_ABOVE_LEFTALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } float locationBottom = relativeWidget->getTopInParent(); float locationLeft = relativeWidget->getLeftInParent(); finalPosY = locationBottom + ap.y * cs.height; finalPosX = locationLeft + ap.x * cs.width; } break; case RELATIVE_LOCATION_ABOVE_CENTER: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } Size rbs = relativeWidget->getSize(); float locationBottom = relativeWidget->getTopInParent(); finalPosY = locationBottom + ap.y * cs.height; finalPosX = relativeWidget->getLeftInParent() + rbs.width * 0.5f + ap.x * cs.width - cs.width * 0.5f; } break; case RELATIVE_LOCATION_ABOVE_RIGHTALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } float locationBottom = relativeWidget->getTopInParent(); float locationRight = relativeWidget->getRightInParent(); finalPosY = locationBottom + ap.y * cs.height; finalPosX = locationRight - (1.0f - ap.x) * cs.width; } break; case RELATIVE_LOCATION_LEFT_OF_TOPALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } float locationTop = relativeWidget->getTopInParent(); float locationRight = relativeWidget->getLeftInParent(); finalPosY = locationTop - (1.0f - ap.y) * cs.height; finalPosX = locationRight - (1.0f - ap.x) * cs.width; } break; case RELATIVE_LOCATION_LEFT_OF_CENTER: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } Size rbs = relativeWidget->getSize(); float locationRight = relativeWidget->getLeftInParent(); finalPosX = locationRight - (1.0f - ap.x) * cs.width; finalPosY = relativeWidget->getBottomInParent() + rbs.height * 0.5f + ap.y * cs.height - cs.height * 0.5f; } break; case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } float locationBottom = relativeWidget->getBottomInParent(); float locationRight = relativeWidget->getLeftInParent(); finalPosY = locationBottom + ap.y * cs.height; finalPosX = locationRight - (1.0f - ap.x) * cs.width; } break; case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } float locationTop = relativeWidget->getTopInParent(); float locationLeft = relativeWidget->getRightInParent(); finalPosY = locationTop - (1.0f - ap.y) * cs.height; finalPosX = locationLeft + ap.x * cs.width; } break; case RELATIVE_LOCATION_RIGHT_OF_CENTER: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } Size rbs = relativeWidget->getSize(); float locationLeft = relativeWidget->getRightInParent(); finalPosX = locationLeft + ap.x * cs.width; finalPosY = relativeWidget->getBottomInParent() + rbs.height * 0.5f + ap.y * cs.height - cs.height * 0.5f; } break; case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } float locationBottom = relativeWidget->getBottomInParent(); float locationLeft = relativeWidget->getRightInParent(); finalPosY = locationBottom + ap.y * cs.height; finalPosX = locationLeft + ap.x * cs.width; } break; case RELATIVE_LOCATION_BELOW_LEFTALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } float locationTop = relativeWidget->getBottomInParent(); float locationLeft = relativeWidget->getLeftInParent(); finalPosY = locationTop - (1.0f - ap.y) * cs.height; finalPosX = locationLeft + ap.x * cs.width; } break; case RELATIVE_LOCATION_BELOW_CENTER: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } Size rbs = relativeWidget->getSize(); float locationTop = relativeWidget->getBottomInParent(); finalPosY = locationTop - (1.0f - ap.y) * cs.height; finalPosX = relativeWidget->getLeftInParent() + rbs.width * 0.5f + ap.x * cs.width - cs.width * 0.5f; } break; case RELATIVE_LOCATION_BELOW_RIGHTALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) { continue; } float locationTop = relativeWidget->getBottomInParent(); float locationRight = relativeWidget->getRightInParent(); finalPosY = locationTop - (1.0f - ap.y) * cs.height; finalPosX = locationRight - (1.0f - ap.x) * cs.width; } break; default: break; } Margin relativeWidgetMargin; Margin mg = layoutParameter->getMargin(); if (relativeWidgetLP) { relativeWidgetMargin = relativeWidgetLP->getMargin(); } //handle margin switch (align) { case RELATIVE_ALIGN_NONE: case RELATIVE_ALIGN_PARENT_TOP_LEFT: finalPosX += mg.left; finalPosY -= mg.top; break; case RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL: finalPosY -= mg.top; break; case RELATIVE_ALIGN_PARENT_TOP_RIGHT: finalPosX -= mg.right; finalPosY -= mg.top; break; case RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL: finalPosX += mg.left; break; case RELATIVE_CENTER_IN_PARENT: break; case RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL: finalPosX -= mg.right; break; case RELATIVE_ALIGN_PARENT_LEFT_BOTTOM: finalPosX += mg.left; finalPosY += mg.bottom; break; case RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL: finalPosY += mg.bottom; break; case RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM: finalPosX -= mg.right; finalPosY += mg.bottom; break; case RELATIVE_LOCATION_ABOVE_LEFTALIGN: finalPosY += mg.bottom; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT) { finalPosY += relativeWidgetMargin.top; } finalPosX += mg.left; break; case RELATIVE_LOCATION_ABOVE_RIGHTALIGN: finalPosY += mg.bottom; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT) { finalPosY += relativeWidgetMargin.top; } finalPosX -= mg.right; break; case RELATIVE_LOCATION_ABOVE_CENTER: finalPosY += mg.bottom; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT) { finalPosY += relativeWidgetMargin.top; } break; case RELATIVE_LOCATION_LEFT_OF_TOPALIGN: finalPosX -= mg.right; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) { finalPosX -= relativeWidgetMargin.left; } finalPosY -= mg.top; break; case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN: finalPosX -= mg.right; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) { finalPosX -= relativeWidgetMargin.left; } finalPosY += mg.bottom; break; case RELATIVE_LOCATION_LEFT_OF_CENTER: finalPosX -= mg.right; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) { finalPosX -= relativeWidgetMargin.left; } break; case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN: finalPosX += mg.left; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) { finalPosX += relativeWidgetMargin.right; } finalPosY -= mg.top; break; case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN: finalPosX += mg.left; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) { finalPosX += relativeWidgetMargin.right; } finalPosY += mg.bottom; break; case RELATIVE_LOCATION_RIGHT_OF_CENTER: finalPosX += mg.left; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) { finalPosX += relativeWidgetMargin.right; } break; case RELATIVE_LOCATION_BELOW_LEFTALIGN: finalPosY -= mg.top; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) { finalPosY -= relativeWidgetMargin.bottom; } finalPosX += mg.left; break; case RELATIVE_LOCATION_BELOW_RIGHTALIGN: finalPosY -= mg.top; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) { finalPosY -= relativeWidgetMargin.bottom; } finalPosX -= mg.right; break; case RELATIVE_LOCATION_BELOW_CENTER: finalPosY -= mg.top; if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) { finalPosY -= relativeWidgetMargin.bottom; } break; default: break; } child->setPosition(Point(finalPosX, finalPosY)); layoutParameter->_put = true; unlayoutChildCount--; } } } break; } default: break; } _doLayoutDirty = false; } std::string Layout::getDescription() const { return "Layout"; } Widget* Layout::createCloneInstance() { return Layout::create(); } void Layout::copyClonedWidgetChildren(Widget* model) { Widget::copyClonedWidgetChildren(model); } void Layout::copySpecialProperties(Widget *widget) { Layout* layout = dynamic_cast(widget); if (layout) { setBackGroundImageScale9Enabled(layout->_backGroundScale9Enabled); setBackGroundImage(layout->_backGroundImageFileName.c_str(),layout->_bgImageTexType); setBackGroundImageCapInsets(layout->_backGroundImageCapInsets); setBackGroundColorType(layout->_colorType); setBackGroundColor(layout->_cColor); setBackGroundColor(layout->_gStartColor, layout->_gEndColor); setBackGroundColorOpacity(layout->_cOpacity); setBackGroundColorVector(layout->_alongVector); setLayoutType(layout->_layoutType); setClippingEnabled(layout->_clippingEnabled); setClippingType(layout->_clippingType); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UILayout.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __LAYOUT_H__ #define __LAYOUT_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { typedef enum { LAYOUT_COLOR_NONE, LAYOUT_COLOR_SOLID, LAYOUT_COLOR_GRADIENT }LayoutBackGroundColorType; typedef enum { LAYOUT_ABSOLUTE, LAYOUT_LINEAR_VERTICAL, LAYOUT_LINEAR_HORIZONTAL, LAYOUT_RELATIVE }LayoutType; typedef enum { LAYOUT_CLIPPING_STENCIL, LAYOUT_CLIPPING_SCISSOR }LayoutClippingType; /** * @js NA * @lua NA */ class Layout : public Widget { public: /** * Default constructor */ Layout(); /** * Default destructor */ virtual ~Layout(); /** * Allocates and initializes a layout. */ static Layout* create(); //background /** * Sets a background image for layout * * @param fileName image file path. * * @param texType @see TextureResType. UI_TEX_TYPE_LOCAL means local file, UI_TEX_TYPE_PLIST means sprite frame. */ void setBackGroundImage(const char* fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Sets a background image capinsets for layout, if the background image is a scale9 render. * * @param capinsets of background image. * */ void setBackGroundImageCapInsets(const Rect& capInsets); /** * Sets Color Type for layout. * * @param type @see LayoutBackGroundColorType. */ void setBackGroundColorType(LayoutBackGroundColorType type); /** * Sets background iamge use scale9 renderer. * * @param enabled true that use scale9 renderer, false otherwise. */ void setBackGroundImageScale9Enabled(bool enabled); /** * Sets background color for layout, if color type is LAYOUT_COLOR_SOLID * * @param color */ void setBackGroundColor(const Color3B &color); /** * Sets background color for layout, if color type is LAYOUT_COLOR_GRADIENT * * @param start color * * @param end color */ void setBackGroundColor(const Color3B &startColor, const Color3B &endColor); /** * Sets background opacity layout. * * @param opacity */ void setBackGroundColorOpacity(int opacity); /** * Sets background color vector for layout, if color type is LAYOUT_COLOR_GRADIENT * * @param vector */ void setBackGroundColorVector(const Point &vector); /** * Remove the background image of layout. */ void removeBackGroundImage(); /** * Gets background image texture size. * * @return background image texture size. */ const Size& getBackGroundImageTextureSize() const; /** * Changes if layout can clip it's content and child. * * If you really need this, please enable it. But it would reduce the rendering efficiency. * * @param clipping enabled. */ virtual void setClippingEnabled(bool enabled); void setClippingType(LayoutClippingType type); /** * Gets if layout is clipping enabled. * * @return if layout is clipping enabled. */ virtual bool isClippingEnabled(); /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; /** * Sets LayoutType. * * @see LayoutType * * @param LayoutType */ virtual void setLayoutType(LayoutType type); /** * Gets LayoutType. * * @see LayoutType * * @return LayoutType */ virtual LayoutType getLayoutType() const; virtual void addChild(Node * child) override; /** * Adds a child to the container with a z-order * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) */ virtual void addChild(Node * child, int zOrder) override; /** * Adds a child to the container with z order and tag * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) * @param tag A interger to identify the node easily. Please refer to setTag(int) */ virtual void addChild(Node* child, int zOrder, int tag) override; virtual void visit(); virtual void sortAllChildren() override; void requestDoLayout(); virtual void onEnter() override; virtual void onExit() override; virtual bool hitTest(const Point &pt); protected: //override "init" method of widget. virtual bool init() override; //override "onSizeChanged" method of widget. virtual void onSizeChanged() override; //init background image renderer. void addBackGroundImage(); void supplyTheLayoutParameterLackToChild(Widget* child); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; void stencilClippingVisit(); void scissorClippingVisit(); void setStencilClippingSize(const Size& size); const Rect& getClippingRect(); virtual void doLayout(); //clipping void onBeforeVisitStencil(); void onAfterDrawStencil(); void onAfterVisitStencil(); void onBeforeVisitScissor(); void onAfterVisitScissor(); protected: bool _clippingEnabled; //background bool _backGroundScale9Enabled; Node* _backGroundImage; std::string _backGroundImageFileName; Rect _backGroundImageCapInsets; LayoutBackGroundColorType _colorType; TextureResType _bgImageTexType; LayerColor* _colorRender; LayerGradient* _gradientRender; Color3B _cColor; Color3B _gStartColor; Color3B _gEndColor; Point _alongVector; int _cOpacity; Size _backGroundImageTextureSize; LayoutType _layoutType; LayoutClippingType _clippingType; DrawNode* _clippingStencil; bool _scissorRectDirty; Rect _clippingRect; Layout* _clippingParent; bool _doLayoutDirty; //clipping GLboolean _currentStencilEnabled; GLuint _currentStencilWriteMask; GLenum _currentStencilFunc; GLint _currentStencilRef; GLuint _currentStencilValueMask; GLenum _currentStencilFail; GLenum _currentStencilPassDepthFail; GLenum _currentStencilPassDepthPass; GLboolean _currentDepthWriteMask; GLboolean _currentAlphaTestEnabled; GLenum _currentAlphaTestFunc; GLclampf _currentAlphaTestRef; GLint _mask_layer_le; GroupCommand _groupCommand; CustomCommand _beforeVisitCmdStencil; CustomCommand _afterDrawStencilCmd; CustomCommand _afterVisitCmdStencil; CustomCommand _beforeVisitCmdScissor; CustomCommand _afterVisitCmdScissor; }; } NS_CC_END #endif /* defined(__Layout__) */ ================================================ FILE: cocos2d/cocos/gui/UILayoutDefine.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "UILayoutDefine.h" NS_CC_BEGIN namespace gui { Margin::Margin(void) : left(0), top(0), right(0), bottom(0) { } Margin::Margin(float l, float t, float r, float b) : left(l), top(t), right(r), bottom(b) { } Margin::Margin(const Margin& other) : left(other.left), top(other.top), right(other.right), bottom(other.bottom) { } Margin& Margin::operator= (const Margin& other) { setMargin(other.left, other.top, other.right, other.bottom); return *this; } void Margin::setMargin(float l, float t, float r, float b) { left = l; top = t; right = r; bottom = b; } bool Margin::equals(const Margin &target) const { return (left == target.left && top == target.top && right == target.right && bottom == target.bottom); } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UILayoutDefine.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UILAYOUTDEFINE_H__ #define __UILAYOUTDEFINE_H__ #include "cocos2d.h" NS_CC_BEGIN namespace gui { /** * @js NA * @lua NA */ class Margin { public: float left; float top; float right; float bottom; public: Margin(); Margin(float l, float t, float r, float b); Margin(const Margin& other); Margin& operator= (const Margin& other); void setMargin(float l, float t, float r, float b); bool equals(const Margin& target) const; }; const Margin MarginZero = Margin(); typedef enum { LINEAR_GRAVITY_NONE, LINEAR_GRAVITY_LEFT, LINEAR_GRAVITY_TOP, LINEAR_GRAVITY_RIGHT, LINEAR_GRAVITY_BOTTOM, LINEAR_GRAVITY_CENTER_VERTICAL, LINEAR_GRAVITY_CENTER_HORIZONTAL }LinearGravity; typedef enum { RELATIVE_ALIGN_NONE, RELATIVE_ALIGN_PARENT_TOP_LEFT, RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL, RELATIVE_ALIGN_PARENT_TOP_RIGHT, RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL, RELATIVE_CENTER_IN_PARENT, RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL, RELATIVE_ALIGN_PARENT_LEFT_BOTTOM, RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL, RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM, RELATIVE_LOCATION_ABOVE_LEFTALIGN, RELATIVE_LOCATION_ABOVE_CENTER, RELATIVE_LOCATION_ABOVE_RIGHTALIGN, RELATIVE_LOCATION_LEFT_OF_TOPALIGN, RELATIVE_LOCATION_LEFT_OF_CENTER, RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN, RELATIVE_LOCATION_RIGHT_OF_TOPALIGN, RELATIVE_LOCATION_RIGHT_OF_CENTER, RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN, RELATIVE_LOCATION_BELOW_LEFTALIGN, RELATIVE_LOCATION_BELOW_CENTER, RELATIVE_LOCATION_BELOW_RIGHTALIGN }RelativeAlign; } NS_CC_END #endif /* defined(__UILayoutDefine__) */ ================================================ FILE: cocos2d/cocos/gui/UILayoutParameter.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UILayoutParameter.h" #include "gui/UILayout.h" NS_CC_BEGIN namespace gui { LayoutParameter* LayoutParameter::create() { LayoutParameter* parameter = new LayoutParameter(); if (parameter) { parameter->autorelease(); return parameter; } CC_SAFE_DELETE(parameter); return nullptr; } void LayoutParameter::setMargin(const Margin &margin) { _margin = margin; } const Margin& LayoutParameter::getMargin() const { return _margin; } LayoutParameterType LayoutParameter::getLayoutType() const { return _layoutParameterType; } LinearLayoutParameter* LinearLayoutParameter::create() { LinearLayoutParameter* parameter = new LinearLayoutParameter(); if (parameter) { parameter->autorelease(); return parameter; } CC_SAFE_DELETE(parameter); return nullptr; } void LinearLayoutParameter::setGravity(LinearGravity gravity) { _linearGravity = gravity; } LinearGravity LinearLayoutParameter::getGravity() const { return _linearGravity; } RelativeLayoutParameter* RelativeLayoutParameter::create() { RelativeLayoutParameter* parameter = new RelativeLayoutParameter(); if (parameter) { parameter->autorelease(); return parameter; } CC_SAFE_DELETE(parameter); return nullptr; } void RelativeLayoutParameter::setAlign(RelativeAlign align) { _relativeAlign = align; } RelativeAlign RelativeLayoutParameter::getAlign() const { return _relativeAlign; } void RelativeLayoutParameter::setRelativeToWidgetName(const char *name) { _relativeWidgetName = name; } const char* RelativeLayoutParameter::getRelativeToWidgetName() const { return _relativeWidgetName.c_str(); } void RelativeLayoutParameter::setRelativeName(const char* name) { _relativeLayoutName = name; } const char* RelativeLayoutParameter::getRelativeName() const { return _relativeLayoutName.c_str(); } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UILayoutParameter.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __LAYOUTPARMETER_H__ #define __LAYOUTPARMETER_H__ #include "gui/UILayoutDefine.h" NS_CC_BEGIN namespace gui { typedef enum { LAYOUT_PARAMETER_NONE, LAYOUT_PARAMETER_LINEAR, LAYOUT_PARAMETER_RELATIVE }LayoutParameterType; /** * @js NA * @lua NA */ class LayoutParameter : public Object { public: /** * Default constructor */ LayoutParameter() : _margin(Margin()){_layoutParameterType = LAYOUT_PARAMETER_NONE;}; /** * Default destructor */ virtual ~LayoutParameter(){}; /** * Allocates and initializes. * @return A initialized LayoutParameter which is marked as "autorelease". */ static LayoutParameter* create(); /** * Sets Margin parameter for LayoutParameter. * * @see Margin * * @param margin */ void setMargin(const Margin& margin); /** * Gets Margin parameter of LayoutParameter. * * @see Margin * * @return const Margin& */ const Margin& getMargin() const; /** * Gets LayoutParameterType of LayoutParameter. * * @see LayoutParameterType * * @return LayoutParameterType */ LayoutParameterType getLayoutType() const; protected: Margin _margin; LayoutParameterType _layoutParameterType; }; /** * @js NA * @lua NA */ class LinearLayoutParameter : public LayoutParameter { public: /** * Default constructor */ LinearLayoutParameter() : _linearGravity(LINEAR_GRAVITY_NONE){_layoutParameterType = LAYOUT_PARAMETER_LINEAR;}; /** * Default destructor */ virtual ~LinearLayoutParameter(){}; /** * Allocates and initializes. * @return A initialized LayoutParameter which is marked as "autorelease". */ static LinearLayoutParameter* create(); /** * Sets LinearGravity parameter for LayoutParameter. * * @see LinearGravity * * @param LinearGravity */ void setGravity(LinearGravity gravity); /** * Gets LinearGravity parameter for LayoutParameter. * * @see LinearGravity * * @return LinearGravity */ LinearGravity getGravity() const; protected: LinearGravity _linearGravity; }; /** * @js NA * @lua NA */ class RelativeLayoutParameter : public LayoutParameter { public: /** * Default constructor */ RelativeLayoutParameter() : _relativeAlign(RELATIVE_ALIGN_NONE),_relativeWidgetName(""),_relativeLayoutName(""),_put(false){_layoutParameterType = LAYOUT_PARAMETER_RELATIVE;}; /** * Default destructor */ virtual ~RelativeLayoutParameter(){}; /** * Allocates and initializes. * @return A initialized LayoutParameter which is marked as "autorelease". */ static RelativeLayoutParameter* create(); /** * Sets RelativeAlign parameter for LayoutParameter. * * @see RelativeAlign * * @param RelativeAlign */ void setAlign(RelativeAlign align); /** * Gets RelativeAlign parameter for LayoutParameter. * * @see RelativeAlign * * @return RelativeAlign */ RelativeAlign getAlign() const; /** * Sets a key for LayoutParameter. Witch widget named this is relative to. * * @param name */ void setRelativeToWidgetName(const char* name); /** * Gets the key of LayoutParameter. Witch widget named this is relative to. * * @return name */ const char* getRelativeToWidgetName() const; /** * Sets a name in Relative Layout for LayoutParameter. * * @param name */ void setRelativeName(const char* name); /** * Gets a name in Relative Layout of LayoutParameter. * * @return name */ const char* getRelativeName() const; protected: RelativeAlign _relativeAlign; std::string _relativeWidgetName; std::string _relativeLayoutName; bool _put; friend class Layout; }; } NS_CC_END #endif /* defined(__LayoutParameter__) */ ================================================ FILE: cocos2d/cocos/gui/UIListView.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UIListView.h" #include "gui/UIHelper.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" NS_CC_BEGIN namespace gui { ListView::ListView(): _model(nullptr), _gravity(LISTVIEW_GRAVITY_CENTER_HORIZONTAL), _itemsMargin(0.0f), _listViewEventListener(nullptr), _listViewEventSelector(nullptr), _curSelectedIndex(0), _refreshViewDirty(true) { } ListView::~ListView() { _listViewEventListener = nullptr; _listViewEventSelector = nullptr; _items.clear(); } ListView* ListView::create() { ListView* widget = new ListView(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } bool ListView::init() { if (ScrollView::init()) { setLayoutType(LAYOUT_LINEAR_VERTICAL); return true; } return false; } void ListView::setItemModel(Widget *model) { if (!model) { return; } CC_SAFE_RELEASE_NULL(_model); _model = model; CC_SAFE_RETAIN(_model); } void ListView::updateInnerContainerSize() { switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: { size_t length = _items.size(); float totalHeight = (length - 1) * _itemsMargin; for (auto& item : _items) { totalHeight += item->getSize().height; } float finalWidth = _size.width; float finalHeight = totalHeight; setInnerContainerSize(Size(finalWidth, finalHeight)); break; } case SCROLLVIEW_DIR_HORIZONTAL: { size_t length = _items.size(); float totalWidth = (length - 1) * _itemsMargin; for (auto& item : _items) { totalWidth += item->getSize().width; } float finalWidth = totalWidth; float finalHeight = _size.height; setInnerContainerSize(Size(finalWidth, finalHeight)); break; } default: break; } } void ListView::remedyLayoutParameter(Widget *item) { if (!item) { return; } switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: { LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); if (!llp) { LinearLayoutParameter* defaultLp = LinearLayoutParameter::create(); switch (_gravity) { case LISTVIEW_GRAVITY_LEFT: defaultLp->setGravity(LINEAR_GRAVITY_LEFT); break; case LISTVIEW_GRAVITY_RIGHT: defaultLp->setGravity(LINEAR_GRAVITY_RIGHT); break; case LISTVIEW_GRAVITY_CENTER_HORIZONTAL: defaultLp->setGravity(LINEAR_GRAVITY_CENTER_HORIZONTAL); break; default: break; } if (getIndex(item) == 0) { defaultLp->setMargin(MarginZero); } else { defaultLp->setMargin(Margin(0.0f, _itemsMargin, 0.0f, 0.0f)); } item->setLayoutParameter(defaultLp); } else { if (getIndex(item) == 0) { llp->setMargin(MarginZero); } else { llp->setMargin(Margin(0.0f, _itemsMargin, 0.0f, 0.0f)); } switch (_gravity) { case LISTVIEW_GRAVITY_LEFT: llp->setGravity(LINEAR_GRAVITY_LEFT); break; case LISTVIEW_GRAVITY_RIGHT: llp->setGravity(LINEAR_GRAVITY_RIGHT); break; case LISTVIEW_GRAVITY_CENTER_HORIZONTAL: llp->setGravity(LINEAR_GRAVITY_CENTER_HORIZONTAL); break; default: break; } } break; } case SCROLLVIEW_DIR_HORIZONTAL: { LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); if (!llp) { LinearLayoutParameter* defaultLp = LinearLayoutParameter::create(); switch (_gravity) { case LISTVIEW_GRAVITY_TOP: defaultLp->setGravity(LINEAR_GRAVITY_TOP); break; case LISTVIEW_GRAVITY_BOTTOM: defaultLp->setGravity(LINEAR_GRAVITY_BOTTOM); break; case LISTVIEW_GRAVITY_CENTER_VERTICAL: defaultLp->setGravity(LINEAR_GRAVITY_CENTER_VERTICAL); break; default: break; } if (getIndex(item) == 0) { defaultLp->setMargin(MarginZero); } else { defaultLp->setMargin(Margin(_itemsMargin, 0.0f, 0.0f, 0.0f)); } item->setLayoutParameter(defaultLp); } else { if (getIndex(item) == 0) { llp->setMargin(MarginZero); } else { llp->setMargin(Margin(_itemsMargin, 0.0f, 0.0f, 0.0f)); } switch (_gravity) { case LISTVIEW_GRAVITY_TOP: llp->setGravity(LINEAR_GRAVITY_TOP); break; case LISTVIEW_GRAVITY_BOTTOM: llp->setGravity(LINEAR_GRAVITY_BOTTOM); break; case LISTVIEW_GRAVITY_CENTER_VERTICAL: llp->setGravity(LINEAR_GRAVITY_CENTER_VERTICAL); break; default: break; } } break; } default: break; } } void ListView::pushBackDefaultItem() { if (!_model) { return; } Widget* newItem = _model->clone(); _items.pushBack(newItem); remedyLayoutParameter(newItem); addChild(newItem); _refreshViewDirty = true; } void ListView::insertDefaultItem(ssize_t index) { if (!_model) { return; } Widget* newItem = _model->clone(); _items.insert(index, newItem); remedyLayoutParameter(newItem); addChild(newItem); _refreshViewDirty = true; } void ListView::pushBackCustomItem(Widget* item) { _items.pushBack(item); remedyLayoutParameter(item); addChild(item); _refreshViewDirty = true; } void ListView::insertCustomItem(Widget* item, ssize_t index) { _items.insert(index, item); remedyLayoutParameter(item); addChild(item); _refreshViewDirty = true; } void ListView::removeItem(ssize_t index) { Widget* item = getItem(index); if (!item) { return; } _items.eraseObject(item); removeChild(item); _refreshViewDirty = true; } void ListView::removeLastItem() { removeItem(_items.size() -1); } void ListView::removeAllItems() { _items.clear(); removeAllChildren(); } Widget* ListView::getItem(ssize_t index) { if (index < 0 || index >= _items.size()) { return nullptr; } return _items.at(index); } Vector& ListView::getItems() { return _items; } ssize_t ListView::getIndex(Widget *item) const { if (!item) { return -1; } return _items.getIndex(item); } void ListView::setGravity(ListViewGravity gravity) { if (_gravity == gravity) { return; } _gravity = gravity; _refreshViewDirty = true; } void ListView::setItemsMargin(float margin) { if (_itemsMargin == margin) { return; } _itemsMargin = margin; _refreshViewDirty = true; } void ListView::setDirection(SCROLLVIEW_DIR dir) { switch (dir) { case SCROLLVIEW_DIR_VERTICAL: setLayoutType(LAYOUT_LINEAR_VERTICAL); break; case SCROLLVIEW_DIR_HORIZONTAL: setLayoutType(LAYOUT_LINEAR_HORIZONTAL); break; case SCROLLVIEW_DIR_BOTH: return; default: return; break; } ScrollView::setDirection(dir); } void ListView::requestRefreshView() { _refreshViewDirty = true; } void ListView::refreshView() { ssize_t length = _items.size(); for (int i=0; isetLocalZOrder(i); remedyLayoutParameter(item); } updateInnerContainerSize(); } void ListView::sortAllChildren() { ScrollView::sortAllChildren(); if (_refreshViewDirty) { refreshView(); _refreshViewDirty = false; } } void ListView::addEventListenerListView(Object *target, SEL_ListViewEvent selector) { _listViewEventListener = target; _listViewEventSelector = selector; } void ListView::selectedItemEvent() { if (_listViewEventListener && _listViewEventSelector) { (_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECTEDITEM); } } void ListView::interceptTouchEvent(int handleState, Widget *sender, const Point &touchPoint) { ScrollView::interceptTouchEvent(handleState, sender, touchPoint); if (handleState != 1) { Widget* parent = sender; while (parent) { if (parent && parent->getParent() == _innerContainer) { _curSelectedIndex = getIndex(parent); break; } parent = dynamic_cast(parent->getParent()); } selectedItemEvent(); } } ssize_t ListView::getCurSelectedIndex() const { return _curSelectedIndex; } void ListView::onSizeChanged() { ScrollView::onSizeChanged(); _refreshViewDirty = true; } std::string ListView::getDescription() const { return "ListView"; } Widget* ListView::createCloneInstance() { return ListView::create(); } void ListView::copyClonedWidgetChildren(Widget* model) { auto& arrayItems = static_cast(model)->getItems(); for (auto& item : arrayItems) { pushBackCustomItem(item->clone()); } } void ListView::copySpecialProperties(Widget *widget) { ListView* listViewEx = dynamic_cast(widget); if (listViewEx) { ScrollView::copySpecialProperties(widget); setItemModel(listViewEx->_model); setItemsMargin(listViewEx->_itemsMargin); setGravity(listViewEx->_gravity); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UIListView.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UILISTVIEW_H__ #define __UILISTVIEW_H__ #include "gui/UIScrollView.h" NS_CC_BEGIN namespace gui{ typedef enum { LISTVIEW_GRAVITY_LEFT, LISTVIEW_GRAVITY_RIGHT, LISTVIEW_GRAVITY_CENTER_HORIZONTAL, LISTVIEW_GRAVITY_TOP, LISTVIEW_GRAVITY_BOTTOM, LISTVIEW_GRAVITY_CENTER_VERTICAL, }ListViewGravity; typedef enum { LISTVIEW_ONSELECTEDITEM }ListViewEventType; typedef void (Object::*SEL_ListViewEvent)(Object*,ListViewEventType); #define listvieweventselector(_SELECTOR) (SEL_ListViewEvent)(&_SELECTOR) class ListView : public ScrollView { public: /** * Default constructor */ ListView(); /** * Default destructor */ virtual ~ListView(); /** * Allocates and initializes. */ static ListView* create(); /** * Sets a item model for listview * * A model will be cloned for adding default item. * * @param model item model for listview */ void setItemModel(Widget* model); /** * Push back a default item(create by a cloned model) into listview. */ void pushBackDefaultItem(); /** * Insert a default item(create by a cloned model) into listview. */ void insertDefaultItem(ssize_t index); /** * Push back custom item into listview. */ void pushBackCustomItem(Widget* item); /** * Insert custom item into listview. */ void insertCustomItem(Widget* item, ssize_t index); /** * Removes the last item of listview. */ void removeLastItem(); /** * Removes a item whose index is same as the parameter. * * @param index of item. */ void removeItem(ssize_t index); void removeAllItems(); /** * Returns a item whose index is same as the parameter. * * @param index of item. * * @return the item widget. */ Widget* getItem(ssize_t index); /** * Returns the item container. */ Vector& getItems(); /** * Returns the index of item. * * @param item the item which need to be checked. * * @return the index of item. */ ssize_t getIndex(Widget* item) const; /** * Changes the gravity of listview. * @see ListViewGravity */ void setGravity(ListViewGravity gravity); /** * Changes the margin between each item. * * @param margin */ void setItemsMargin(float margin); virtual void sortAllChildren() override; ssize_t getCurSelectedIndex() const; void addEventListenerListView(Object* target, SEL_ListViewEvent selector); /** * Changes scroll direction of scrollview. * * @see SCROLLVIEW_DIR SCROLLVIEW_DIR_VERTICAL means vertical scroll, SCROLLVIEW_DIR_HORIZONTAL means horizontal scroll * * @param SCROLLVIEW_DIR */ virtual void setDirection(SCROLLVIEW_DIR dir) override; virtual std::string getDescription() const override; void requestRefreshView(); protected: virtual void addChild(Node* child) override{ScrollView::addChild(child);}; virtual void addChild(Node * child, int zOrder) override{ScrollView::addChild(child, zOrder);}; virtual void addChild(Node* child, int zOrder, int tag) override{ScrollView::addChild(child, zOrder, tag);}; virtual void removeChild(Node* widget, bool cleanup = true) override{ScrollView::removeChild(widget, cleanup);}; virtual void removeAllChildren() override{removeAllChildrenWithCleanup(true);}; virtual void removeAllChildrenWithCleanup(bool cleanup) override {ScrollView::removeAllChildrenWithCleanup(cleanup);}; virtual Vector& getChildren() override{return ScrollView::getChildren();}; virtual const Vector& getChildren() const override{return ScrollView::getChildren();}; virtual ssize_t getChildrenCount() const override {return ScrollView::getChildrenCount();}; virtual Node * getChildByTag(int tag) override {return ScrollView::getChildByTag(tag);}; virtual Widget* getChildByName(const char* name) override {return ScrollView::getChildByName(name);}; virtual bool init() override; void updateInnerContainerSize(); void remedyLayoutParameter(Widget* item); virtual void onSizeChanged() override; virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; void selectedItemEvent(); virtual void interceptTouchEvent(int handleState,Widget* sender,const Point &touchPoint) override; void refreshView(); protected: Widget* _model; Vector _items; ListViewGravity _gravity; float _itemsMargin; Object* _listViewEventListener; SEL_ListViewEvent _listViewEventSelector; ssize_t _curSelectedIndex; bool _refreshViewDirty; }; } NS_CC_END #endif /* defined(__ListView__) */ ================================================ FILE: cocos2d/cocos/gui/UILoadingBar.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UILoadingBar.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" NS_CC_BEGIN namespace gui { static const int BAR_RENDERER_Z = (-1); LoadingBar::LoadingBar(): _barType(LoadingBarTypeLeft), _percent(100), _totalLength(0), _barRenderer(nullptr), _renderBarTexType(UI_TEX_TYPE_LOCAL), _barRendererTextureSize(Size::ZERO), _scale9Enabled(false), _prevIgnoreSize(true), _capInsets(Rect::ZERO), _textureFile("") { } LoadingBar::~LoadingBar() { } LoadingBar* LoadingBar::create() { LoadingBar* widget = new LoadingBar(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } void LoadingBar::initRenderer() { _barRenderer = Sprite::create(); Node::addChild(_barRenderer, BAR_RENDERER_Z, -1); _barRenderer->setAnchorPoint(Point(0.0,0.5)); } void LoadingBar::setDirection(LoadingBarType dir) { if (_barType == dir) { return; } _barType = dir; switch (_barType) { case LoadingBarTypeLeft: _barRenderer->setAnchorPoint(Point(0.0f,0.5f)); _barRenderer->setPosition(Point(-_totalLength*0.5f,0.0f)); if (!_scale9Enabled) { static_cast(_barRenderer)->setFlippedX(false); } break; case LoadingBarTypeRight: _barRenderer->setAnchorPoint(Point(1.0f,0.5f)); _barRenderer->setPosition(Point(_totalLength*0.5f,0.0f)); if (!_scale9Enabled) { static_cast(_barRenderer)->setFlippedX(true); } break; } } int LoadingBar::getDirection() { return _barType; } void LoadingBar::loadTexture(const char* texture,TextureResType texType) { if (!texture || strcmp(texture, "") == 0) { return; } _renderBarTexType = texType; _textureFile = texture; switch (_renderBarTexType) { case UI_TEX_TYPE_LOCAL: if (_scale9Enabled) { extension::Scale9Sprite* barRendererScale9 = static_cast(_barRenderer); barRendererScale9->initWithFile(texture); barRendererScale9->setCapInsets(_capInsets); } else { static_cast(_barRenderer)->setTexture(texture); } break; case UI_TEX_TYPE_PLIST: if (_scale9Enabled) { extension::Scale9Sprite* barRendererScale9 = static_cast(_barRenderer); barRendererScale9->initWithSpriteFrameName(texture); barRendererScale9->setCapInsets(_capInsets); } else { static_cast(_barRenderer)->setSpriteFrame(texture); } break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); _barRendererTextureSize = _barRenderer->getContentSize(); switch (_barType) { case LoadingBarTypeLeft: _barRenderer->setAnchorPoint(Point(0.0f,0.5f)); if (!_scale9Enabled) { static_cast(_barRenderer)->setFlippedX(false); } break; case LoadingBarTypeRight: _barRenderer->setAnchorPoint(Point(1.0f,0.5f)); if (!_scale9Enabled) { static_cast(_barRenderer)->setFlippedX(true); } break; } barRendererScaleChangedWithSize(); } void LoadingBar::setScale9Enabled(bool enabled) { if (_scale9Enabled == enabled) { return; } _scale9Enabled = enabled; Node::removeChild(_barRenderer); _barRenderer = nullptr; if (_scale9Enabled) { _barRenderer = extension::Scale9Sprite::create(); } else { _barRenderer = Sprite::create(); } loadTexture(_textureFile.c_str(),_renderBarTexType); Node::addChild(_barRenderer, BAR_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; ignoreContentAdaptWithSize(false); _prevIgnoreSize = ignoreBefore; } else { ignoreContentAdaptWithSize(_prevIgnoreSize); } setCapInsets(_capInsets); } void LoadingBar::setCapInsets(const Rect &capInsets) { _capInsets = capInsets; if (!_scale9Enabled) { return; } static_cast(_barRenderer)->setCapInsets(capInsets); } void LoadingBar::setPercent(int percent) { if ( percent < 0 || percent > 100) { return; } if (_totalLength <= 0) { return; } _percent = percent; float res = _percent / 100.0f; if (_scale9Enabled) { setScale9Scale(); } else { Sprite* spriteRenderer = static_cast(_barRenderer); Rect rect = spriteRenderer->getTextureRect(); rect.size.width = _barRendererTextureSize.width * res; spriteRenderer->setTextureRect(rect, spriteRenderer->isTextureRectRotated(), rect.size); } } int LoadingBar::getPercent() { return _percent; } void LoadingBar::onSizeChanged() { Widget::onSizeChanged(); barRendererScaleChangedWithSize(); } void LoadingBar::ignoreContentAdaptWithSize(bool ignore) { if (!_scale9Enabled || (_scale9Enabled && !ignore)) { Widget::ignoreContentAdaptWithSize(ignore); _prevIgnoreSize = ignore; } } const Size& LoadingBar::getContentSize() const { return _barRendererTextureSize; } Node* LoadingBar::getVirtualRenderer() { return _barRenderer; } void LoadingBar::barRendererScaleChangedWithSize() { if (_ignoreSize) { if (!_scale9Enabled) { _totalLength = _barRendererTextureSize.width; _barRenderer->setScale(1.0f); _size = _barRendererTextureSize; } } else { _totalLength = _size.width; if (_scale9Enabled) { setScale9Scale(); } else { Size textureSize = _barRendererTextureSize; if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _barRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _barRenderer->setScaleX(scaleX); _barRenderer->setScaleY(scaleY); } } switch (_barType) { case LoadingBarTypeLeft: _barRenderer->setPosition(Point(-_totalLength * 0.5f, 0.0f)); break; case LoadingBarTypeRight: _barRenderer->setPosition(Point(_totalLength * 0.5f, 0.0f)); break; default: break; } } void LoadingBar::setScale9Scale() { float width = (float)(_percent) / 100.0f * _totalLength; static_cast(_barRenderer)->setPreferredSize(Size(width, _size.height)); } std::string LoadingBar::getDescription() const { return "LoadingBar"; } Widget* LoadingBar::createCloneInstance() { return LoadingBar::create(); } void LoadingBar::copySpecialProperties(Widget *widget) { LoadingBar* loadingBar = dynamic_cast(widget); if (loadingBar) { _prevIgnoreSize = loadingBar->_prevIgnoreSize; setScale9Enabled(loadingBar->_scale9Enabled); loadTexture(loadingBar->_textureFile.c_str(), loadingBar->_renderBarTexType); setCapInsets(loadingBar->_capInsets); setPercent(loadingBar->_percent); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UILoadingBar.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UILOADINGBAR_H__ #define __UILOADINGBAR_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { typedef enum { LoadingBarTypeLeft, LoadingBarTypeRight }LoadingBarType; /** * @js NA * @lua NA */ class LoadingBar : public Widget { public: /** * Default constructor */ LoadingBar(); /** * Default destructor */ virtual ~LoadingBar(); /** * Allocates and initializes. */ static LoadingBar* create(); /** * Changes the progress direction of loadingbar. * * @see LoadingBarType LoadingBarTypeLeft means progress left to right, LoadingBarTypeRight otherwise. * * @param LoadingBarType */ void setDirection(LoadingBarType dir); /** * Gets the progress direction of loadingbar. * * @see LoadingBarType LoadingBarTypeLeft means progress left to right, LoadingBarTypeRight otherwise. * * @param LoadingBarType */ int getDirection(); /** * Load texture for loadingbar. * * @param fileName file name of texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadTexture(const char* texture,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Changes the progress direction of loadingbar. * * @param percent percent value from 1 to 100. */ void setPercent(int percent); /** * Gets the progress direction of loadingbar. * * @return percent percent value from 1 to 100. */ int getPercent(); /** * Sets if loadingbar is using scale9 renderer. * * @param true that using scale9 renderer, false otherwise. */ void setScale9Enabled(bool enabled); /** * Sets capinsets for loadingbar, if loadingbar is using scale9 renderer. * * @param capInsets capinsets for loadingbar */ void setCapInsets(const Rect &capInsets); //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; //override "getContentSize" method of widget. virtual const Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; protected: virtual void initRenderer() override; virtual void onSizeChanged() override; void setScale9Scale(); void barRendererScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: LoadingBarType _barType; int _percent; float _totalLength; Node* _barRenderer; TextureResType _renderBarTexType; Size _barRendererTextureSize; bool _scale9Enabled; bool _prevIgnoreSize; Rect _capInsets; std::string _textureFile; }; } NS_CC_END #endif /* defined(__CocoGUI__LoadingBar__) */ ================================================ FILE: cocos2d/cocos/gui/UIPageView.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UIPageView.h" NS_CC_BEGIN namespace gui { PageView::PageView(): _curPageIdx(0), _touchMoveDir(PAGEVIEW_TOUCHLEFT), _touchStartLocation(0.0f), _touchMoveStartLocation(0.0f), _movePagePoint(Point::ZERO), _leftChild(nullptr), _rightChild(nullptr), _leftBoundary(0.0f), _rightBoundary(0.0f), _isAutoScrolling(false), _autoScrollDistance(0.0f), _autoScrollSpeed(0.0f), _autoScrollDir(0), _childFocusCancelOffset(5.0f), _pageViewEventListener(nullptr), _pageViewEventSelector(nullptr) { } PageView::~PageView() { _pages.clear(); _pageViewEventListener = nullptr; _pageViewEventSelector = nullptr; } PageView* PageView::create() { PageView* widget = new PageView(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } void PageView::onEnter() { Layout::onEnter(); scheduleUpdate(); } bool PageView::init() { if (Layout::init()) { setClippingEnabled(true); setTouchEnabled(true); return true; } return false; } void PageView::addWidgetToPage(Widget *widget, ssize_t pageIdx, bool forceCreate) { if (!widget) { return; } if (pageIdx < 0) { return; } ssize_t pageCount = _pages.size(); if (pageIdx < 0 || pageIdx >= pageCount) { if (forceCreate) { if (pageIdx > pageCount) { CCLOG("pageIdx is %d, it will be added as page id [%d]",static_cast(pageIdx),static_cast(pageCount)); } Layout* newPage = createPage(); newPage->addChild(widget); addPage(newPage); } } else { Layout * page = _pages.at(pageIdx); page->addChild(widget); } } Layout* PageView::createPage() { Layout* newPage = Layout::create(); newPage->setSize(getSize()); return newPage; } void PageView::addPage(Layout* page) { if (!page) { return; } if (page->getWidgetType() != WidgetTypeContainer) { return; } if (_pages.contains(page)) { return; } Size pSize = page->getSize(); Size pvSize = getSize(); if (!pSize.equals(pvSize)) { CCLOG("page size does not match pageview size, it will be force sized!"); page->setSize(pvSize); } page->setPosition(Point(getPositionXByIndex(_pages.size()), 0)); _pages.pushBack(page); addChild(page); updateBoundaryPages(); } void PageView::insertPage(Layout* page, int idx) { if (idx < 0) { return; } if (!page) { return; } if (page->getWidgetType() != WidgetTypeContainer) { return; } if (_pages.contains(page)) { return; } ssize_t pageCount = _pages.size(); if (idx >= pageCount) { addPage(page); } else { _pages.insert(idx, page); page->setPosition(Point(getPositionXByIndex(idx), 0)); addChild(page); Size pSize = page->getSize(); Size pvSize = getSize(); if (!pSize.equals(pvSize)) { CCLOG("page size does not match pageview size, it will be force sized!"); page->setSize(pvSize); } ssize_t length = _pages.size(); for (ssize_t i=(idx+1); igetPosition(); behindPage->setPosition(Point(formerPos.x+getSize().width, 0)); } updateBoundaryPages(); } } void PageView::removePage(Layout* page) { if (!page) { return; } removeChild(page); updateChildrenPosition(); updateBoundaryPages(); } void PageView::removePageAtIndex(ssize_t index) { if (index < 0 || index >= _pages.size()) { return; } Layout* page = _pages.at(index); removePage(page); } void PageView::removeAllPages() { removeAllChildren(); } void PageView::updateBoundaryPages() { if (_pages.size() <= 0) { _leftChild = nullptr; _rightChild = nullptr; return; } _leftChild = _pages.at(0); _rightChild = _pages.at(_pages.size()-1); } float PageView::getPositionXByIndex(ssize_t idx) { return (getSize().width*(idx-_curPageIdx)); } void PageView::addChild(Node *child) { Layout::addChild(child); } void PageView::addChild(Node * child, int zOrder) { Layout::addChild(child, zOrder); } void PageView::addChild(Node *child, int zOrder, int tag) { Layout::addChild(child, zOrder, tag); } void PageView::removeChild(Node *child, bool cleanup) { if (_pages.contains(static_cast(child))) { _pages.eraseObject(static_cast(child)); } Layout::removeChild(child, cleanup); } void PageView::onSizeChanged() { Layout::onSizeChanged(); _rightBoundary = getSize().width; updateChildrenSize(); updateChildrenPosition(); } void PageView::updateChildrenSize() { Size selfSize = getSize(); for (auto& page : _pages) { page->setSize(selfSize); } } void PageView::updateChildrenPosition() { ssize_t pageCount = _pages.size(); if (pageCount <= 0) { _curPageIdx = 0; return; } if (_curPageIdx >= pageCount) { _curPageIdx = pageCount-1; } float pageWidth = getSize().width; for (int i=0; isetPosition(Point((i-_curPageIdx)*pageWidth, 0)); } } void PageView::removeAllChildren() { removeAllChildrenWithCleanup(true); } void PageView::removeAllChildrenWithCleanup(bool cleanup) { _pages.clear(); Layout::removeAllChildrenWithCleanup(cleanup); } void PageView::scrollToPage(ssize_t idx) { if (idx < 0 || idx >= _pages.size()) { return; } _curPageIdx = idx; Widget* curPage = _pages.at(idx); _autoScrollDistance = -(curPage->getPosition().x); _autoScrollSpeed = fabs(_autoScrollDistance)/0.2f; _autoScrollDir = _autoScrollDistance > 0 ? 1 : 0; _isAutoScrolling = true; } void PageView::update(float dt) { if (_isAutoScrolling) { switch (_autoScrollDir) { case 0: { float step = _autoScrollSpeed*dt; if (_autoScrollDistance + step >= 0.0f) { step = -_autoScrollDistance; _autoScrollDistance = 0.0f; _isAutoScrolling = false; } else { _autoScrollDistance += step; } scrollPages(-step); if (!_isAutoScrolling) { pageTurningEvent(); } break; } break; case 1: { float step = _autoScrollSpeed*dt; if (_autoScrollDistance - step <= 0.0f) { step = _autoScrollDistance; _autoScrollDistance = 0.0f; _isAutoScrolling = false; } else { _autoScrollDistance -= step; } scrollPages(step); if (!_isAutoScrolling) { pageTurningEvent(); } break; } default: break; } } } bool PageView::onTouchBegan(Touch *touch, Event *unusedEvent) { bool pass = Layout::onTouchBegan(touch, unusedEvent); if (_hitted) { handlePressLogic(touch->getLocation()); } return pass; } void PageView::onTouchMoved(Touch *touch, Event *unusedEvent) { _touchMovePos = touch->getLocation(); handleMoveLogic(_touchMovePos); Widget* widgetParent = getWidgetParent(); if (widgetParent) { widgetParent->checkChildInfo(1,this,_touchMovePos); } moveEvent(); } void PageView::onTouchEnded(Touch *touch, Event *unusedEvent) { Layout::onTouchEnded(touch, unusedEvent); handleReleaseLogic(_touchEndPos); } void PageView::onTouchCancelled(Touch *touch, Event *unusedEvent) { Layout::onTouchCancelled(touch, unusedEvent); handleReleaseLogic(touch->getLocation()); } void PageView::movePages(float offset) { for (auto& page : _pages) { _movePagePoint.x = page->getPosition().x + offset; _movePagePoint.y = page->getPosition().y; page->setPosition(_movePagePoint); } } bool PageView::scrollPages(float touchOffset) { if (_pages.size() <= 0) { return false; } if (!_leftChild || !_rightChild) { return false; } float realOffset = touchOffset; switch (_touchMoveDir) { case PAGEVIEW_TOUCHLEFT: // left if (_rightChild->getRightInParent() + touchOffset <= _rightBoundary) { realOffset = _rightBoundary - _rightChild->getRightInParent(); movePages(realOffset); return false; } break; case PAGEVIEW_TOUCHRIGHT: // right if (_leftChild->getLeftInParent() + touchOffset >= _leftBoundary) { realOffset = _leftBoundary - _leftChild->getLeftInParent(); movePages(realOffset); return false; } break; default: break; } movePages(realOffset); return true; } void PageView::handlePressLogic(const Point &touchPoint) { Point nsp = convertToNodeSpace(touchPoint); _touchMoveStartLocation = nsp.x; _touchStartLocation = nsp.x; } void PageView::handleMoveLogic(const Point &touchPoint) { Point nsp = convertToNodeSpace(touchPoint); float offset = 0.0; float moveX = nsp.x; offset = moveX - _touchMoveStartLocation; _touchMoveStartLocation = moveX; if (offset < 0) { _touchMoveDir = PAGEVIEW_TOUCHLEFT; } else if (offset > 0) { _touchMoveDir = PAGEVIEW_TOUCHRIGHT; } scrollPages(offset); } void PageView::handleReleaseLogic(const Point &touchPoint) { if (_pages.size() <= 0) { return; } Widget* curPage = _pages.at(_curPageIdx); if (curPage) { Point curPagePos = curPage->getPosition(); ssize_t pageCount = _pages.size(); float curPageLocation = curPagePos.x; float pageWidth = getSize().width; float boundary = pageWidth/2.0f; if (curPageLocation <= -boundary) { if (_curPageIdx >= pageCount-1) { scrollPages(-curPageLocation); } else { scrollToPage(_curPageIdx+1); } } else if (curPageLocation >= boundary) { if (_curPageIdx <= 0) { scrollPages(-curPageLocation); } else { scrollToPage(_curPageIdx-1); } } else { scrollToPage(_curPageIdx); } } } void PageView::checkChildInfo(int handleState,Widget* sender, const Point &touchPoint) { interceptTouchEvent(handleState, sender, touchPoint); } void PageView::interceptTouchEvent(int handleState, Widget *sender, const Point &touchPoint) { switch (handleState) { case 0: handlePressLogic(touchPoint); break; case 1: { float offset = 0; offset = fabs(sender->getTouchStartPos().x - touchPoint.x); if (offset > _childFocusCancelOffset) { sender->setFocused(false); handleMoveLogic(touchPoint); } } break; case 2: handleReleaseLogic(touchPoint); break; case 3: handleReleaseLogic(touchPoint); break; } } void PageView::pageTurningEvent() { if (_pageViewEventListener && _pageViewEventSelector) { (_pageViewEventListener->*_pageViewEventSelector)(this, PAGEVIEW_EVENT_TURNING); } } void PageView::addEventListenerPageView(Object *target, SEL_PageViewEvent selector) { _pageViewEventListener = target; _pageViewEventSelector = selector; } ssize_t PageView::getCurPageIndex() const { return _curPageIdx; } Vector& PageView::getPages() { return _pages; } Layout* PageView::getPage(ssize_t index) { if (index < 0 || index >= _pages.size()) { return nullptr; } return _pages.at(index); } std::string PageView::getDescription() const { return "PageView"; } Widget* PageView::createCloneInstance() { return PageView::create(); } void PageView::copyClonedWidgetChildren(Widget* model) { auto& modelPages = static_cast(model)->getPages(); for (auto& page : modelPages) { addPage(dynamic_cast(page->clone())); } } void PageView::copySpecialProperties(Widget *widget) { PageView* pageView = dynamic_cast(widget); if (pageView) { Layout::copySpecialProperties(widget); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UIPageView.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UIPAGEVIEW_H__ #define __UIPAGEVIEW_H__ #include "gui/UILayout.h" #include "gui/UIScrollInterface.h" NS_CC_BEGIN namespace gui { typedef enum { PAGEVIEW_EVENT_TURNING, }PageViewEventType; typedef void (Object::*SEL_PageViewEvent)(Object*, PageViewEventType); #define pagevieweventselector(_SELECTOR)(SEL_PageViewEvent)(&_SELECTOR) typedef enum { PAGEVIEW_TOUCHLEFT, PAGEVIEW_TOUCHRIGHT }PVTouchDir; class PageView : public Layout , public UIScrollInterface { public: /** * Default constructor */ PageView(); /** * Default destructor */ virtual ~PageView(); /** * Allocates and initializes. */ static PageView* create(); /** * Add a widget to a page of pageview. * * @param widget widget to be added to pageview. * * @param pageIdx index of page. * * @param forceCreate if force create and there is no page exsit, pageview would create a default page for adding widget. */ void addWidgetToPage(Widget* widget, ssize_t pageIdx, bool forceCreate); /** * Push back a page to pageview. * * @param page page to be added to pageview. */ void addPage(Layout* page); /** * Inert a page to pageview. * * @param page page to be added to pageview. */ void insertPage(Layout* page, int idx); /** * Remove a page of pageview. * * @param page page which will be removed. */ void removePage(Layout* page); /** * Remove a page at index of pageview. * * @param index index of page. */ void removePageAtIndex(ssize_t index); void removeAllPages(); /** * scroll pageview to index. * * @param idx index of page. */ void scrollToPage(ssize_t idx); /** * Gets current page index. * * @return current page index. */ ssize_t getCurPageIndex() const; Vector& getPages(); Layout* getPage(ssize_t index); // event void addEventListenerPageView(Object *target, SEL_PageViewEvent selector); virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override; virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override; virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override; //override "update" method of widget. virtual void update(float dt) override; /** * Sets LayoutType. * * @see LayoutType * * @param LayoutType */ virtual void setLayoutType(LayoutType type) override{}; /** * Gets LayoutType. * * @see LayoutType * * @return LayoutType */ virtual LayoutType getLayoutType() const override{return LAYOUT_ABSOLUTE;}; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; virtual void onEnter() override; protected: virtual void addChild(Node * child) override; virtual void addChild(Node * child, int zOrder) override; virtual void addChild(Node* child, int zOrder, int tag) override; virtual void removeChild(Node* widget, bool cleanup = true) override; virtual void removeAllChildren() override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual Vector& getChildren() override{return Widget::getChildren();}; virtual const Vector& getChildren() const override{return Widget::getChildren();}; virtual ssize_t getChildrenCount() const override {return Widget::getChildrenCount();}; virtual Node * getChildByTag(int tag) override {return Widget::getChildByTag(tag);}; virtual Widget* getChildByName(const char* name) override {return Widget::getChildByName(name);}; virtual bool init() override; Layout* createPage(); float getPositionXByIndex(ssize_t idx); void updateBoundaryPages(); virtual void handlePressLogic(const Point &touchPoint) override; virtual void handleMoveLogic(const Point &touchPoint) override; virtual void handleReleaseLogic(const Point &touchPoint) override; virtual void interceptTouchEvent(int handleState, Widget* sender, const Point &touchPoint) override; virtual void checkChildInfo(int handleState, Widget* sender, const Point &touchPoint) override; virtual bool scrollPages(float touchOffset); void movePages(float offset); void pageTurningEvent(); void updateChildrenSize(); void updateChildrenPosition(); virtual void onSizeChanged() override; virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; virtual void setClippingEnabled(bool enabled) override {Layout::setClippingEnabled(enabled);}; virtual void doLayout() override{if (!_doLayoutDirty){return;} _doLayoutDirty = false;}; protected: ssize_t _curPageIdx; Vector _pages; PVTouchDir _touchMoveDir; float _touchStartLocation; float _touchMoveStartLocation; Point _movePagePoint; Widget* _leftChild; Widget* _rightChild; float _leftBoundary; float _rightBoundary; bool _isAutoScrolling; float _autoScrollDistance; float _autoScrollSpeed; int _autoScrollDir; float _childFocusCancelOffset; Object* _pageViewEventListener; SEL_PageViewEvent _pageViewEventSelector; }; } NS_CC_END #endif /* defined(__PageView__) */ ================================================ FILE: cocos2d/cocos/gui/UIScrollInterface.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UISCROLLDELEGATE_H__ #define __UISCROLLDELEGATE_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { class UIScrollInterface { public: virtual ~UIScrollInterface() {} protected: virtual void handlePressLogic(const Point &touchPoint) = 0; virtual void handleMoveLogic(const Point &touchPoint) = 0; virtual void handleReleaseLogic(const Point &touchPoint) = 0; virtual void interceptTouchEvent(int handleState, Widget* sender, const Point &touchPoint) = 0; }; } NS_CC_END #endif /* defined(__UIScrollDelegate__) */ ================================================ FILE: cocos2d/cocos/gui/UIScrollView.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UIScrollView.h" NS_CC_BEGIN namespace gui { static const float AUTOSCROLLMAXSPEED = 1000.0f; const Point SCROLLDIR_UP = Point(0.0f, 1.0f); const Point SCROLLDIR_DOWN = Point(0.0f, -1.0f); const Point SCROLLDIR_LEFT = Point(-1.0f, 0.0f); const Point SCROLLDIR_RIGHT = Point(1.0f, 0.0f); ScrollView::ScrollView(): _innerContainer(nullptr), _direction(SCROLLVIEW_DIR_VERTICAL), _touchBeganPoint(Point::ZERO), _touchMovedPoint(Point::ZERO), _touchEndedPoint(Point::ZERO), _touchMovingPoint(Point::ZERO), _autoScrollDir(Point::ZERO), _topBoundary(0.0f), _bottomBoundary(0.0f), _leftBoundary(0.0f), _rightBoundary(0.0f), _bounceTopBoundary(0.0f), _bounceBottomBoundary(0.0f), _bounceLeftBoundary(0.0f), _bounceRightBoundary(0.0f), _autoScroll(false), _autoScrollAddUpTime(0.0f), _autoScrollOriginalSpeed(0.0f), _autoScrollAcceleration(-1000.0f), _isAutoScrollSpeedAttenuated(false), _needCheckAutoScrollDestination(false), _autoScrollDestination(Point::ZERO), _bePressed(false), _slidTime(0.0f), _moveChildPoint(Point::ZERO), _childFocusCancelOffset(5.0f), _leftBounceNeeded(false), _topBounceNeeded(false), _rightBounceNeeded(false), _bottomBounceNeeded(false), _bounceEnabled(false), _bouncing(false), _bounceDir(Point::ZERO), _bounceOriginalSpeed(0.0f), _inertiaScrollEnabled(true), _scrollViewEventListener(nullptr), _scrollViewEventSelector(nullptr) { } ScrollView::~ScrollView() { _scrollViewEventListener = nullptr; _scrollViewEventSelector = nullptr; } ScrollView* ScrollView::create() { ScrollView* widget = new ScrollView(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } void ScrollView::onEnter() { Layout::onEnter(); scheduleUpdate(); } bool ScrollView::init() { if (Layout::init()) { setTouchEnabled(true); setClippingEnabled(true); _innerContainer->setTouchEnabled(false); return true; } return false; } void ScrollView::initRenderer() { Layout::initRenderer(); _innerContainer = Layout::create(); Layout::addChild(_innerContainer,1,1); } void ScrollView::onSizeChanged() { Layout::onSizeChanged(); _topBoundary = _size.height; _rightBoundary = _size.width; float bounceBoundaryParameterX = _size.width / 3.0f; float bounceBoundaryParameterY = _size.height / 3.0f; _bounceTopBoundary = _size.height - bounceBoundaryParameterY; _bounceBottomBoundary = bounceBoundaryParameterY; _bounceLeftBoundary = bounceBoundaryParameterX; _bounceRightBoundary = _size.width - bounceBoundaryParameterX; Size innerSize = _innerContainer->getSize(); float orginInnerSizeWidth = innerSize.width; float orginInnerSizeHeight = innerSize.height; float innerSizeWidth = MAX(orginInnerSizeWidth, _size.width); float innerSizeHeight = MAX(orginInnerSizeHeight, _size.height); _innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight)); _innerContainer->setPosition(Point(0, _size.height - _innerContainer->getSize().height)); } void ScrollView::setInnerContainerSize(const Size &size) { float innerSizeWidth = _size.width; float innerSizeHeight = _size.height; Size originalInnerSize = _innerContainer->getSize(); if (size.width < _size.width) { CCLOG("Inner width <= scrollview width, it will be force sized!"); } else { innerSizeWidth = size.width; } if (size.height < _size.height) { CCLOG("Inner height <= scrollview height, it will be force sized!"); } else { innerSizeHeight = size.height; } _innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight)); switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: { Size newInnerSize = _innerContainer->getSize(); float offset = originalInnerSize.height - newInnerSize.height; scrollChildren(0.0f, offset); break; } case SCROLLVIEW_DIR_HORIZONTAL: { if (_innerContainer->getRightInParent() <= _size.width) { Size newInnerSize = _innerContainer->getSize(); float offset = originalInnerSize.width - newInnerSize.width; scrollChildren(offset, 0.0f); } break; } case SCROLLVIEW_DIR_BOTH: { Size newInnerSize = _innerContainer->getSize(); float offsetY = originalInnerSize.height - newInnerSize.height; float offsetX = 0.0f; if (_innerContainer->getRightInParent() <= _size.width) { offsetX = originalInnerSize.width - newInnerSize.width; } scrollChildren(offsetX, offsetY); break; } default: break; } if (_innerContainer->getLeftInParent() > 0.0f) { _innerContainer->setPosition(Point(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width, _innerContainer->getPosition().y)); } if (_innerContainer->getRightInParent() < _size.width) { _innerContainer->setPosition(Point(_size.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width), _innerContainer->getPosition().y)); } if (_innerContainer->getPosition().y > 0.0f) { _innerContainer->setPosition(Point(_innerContainer->getPosition().x, _innerContainer->getAnchorPoint().y * _innerContainer->getSize().height)); } if (_innerContainer->getTopInParent() < _size.height) { _innerContainer->setPosition(Point(_innerContainer->getPosition().x, _size.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height)); } } const Size& ScrollView::getInnerContainerSize() const { return _innerContainer->getSize(); } void ScrollView::addChild(Node *child) { Layout::addChild(child); } void ScrollView::addChild(Node * child, int zOrder) { Layout::addChild(child, zOrder); } void ScrollView::addChild(Node *child, int zOrder, int tag) { return _innerContainer->addChild(child, zOrder, tag); } void ScrollView::removeAllChildren() { removeAllChildrenWithCleanup(true); } void ScrollView::removeAllChildrenWithCleanup(bool cleanup) { _innerContainer->removeAllChildrenWithCleanup(cleanup); } void ScrollView::removeChild(Node* child, bool cleanup) { return _innerContainer->removeChild(child, cleanup); } Vector& ScrollView::getChildren() { return _innerContainer->getChildren(); } const Vector& ScrollView::getChildren() const { return _innerContainer->getChildren(); } ssize_t ScrollView::getChildrenCount() const { return _innerContainer->getChildrenCount(); } Node* ScrollView::getChildByTag(int tag) { return _innerContainer->getChildByTag(tag); } Widget* ScrollView::getChildByName(const char *name) { return _innerContainer->getChildByName(name); } void ScrollView::moveChildren(float offsetX, float offsetY) { _moveChildPoint = _innerContainer->getPosition() + Point(offsetX, offsetY); _innerContainer->setPosition(_moveChildPoint); } void ScrollView::autoScrollChildren(float dt) { float lastTime = _autoScrollAddUpTime; _autoScrollAddUpTime += dt; if (_isAutoScrollSpeedAttenuated) { float nowSpeed = _autoScrollOriginalSpeed + _autoScrollAcceleration * _autoScrollAddUpTime; if (nowSpeed <= 0.0f) { stopAutoScrollChildren(); checkNeedBounce(); } else { float timeParam = lastTime * 2 + dt; float offset = (_autoScrollOriginalSpeed + _autoScrollAcceleration * timeParam * 0.5f) * dt; float offsetX = offset * _autoScrollDir.x; float offsetY = offset * _autoScrollDir.y; if (!scrollChildren(offsetX, offsetY)) { stopAutoScrollChildren(); checkNeedBounce(); } } } else { if (_needCheckAutoScrollDestination) { float xOffset = _autoScrollDir.x * dt * _autoScrollOriginalSpeed; float yOffset = _autoScrollDir.y * dt * _autoScrollOriginalSpeed; bool notDone = checkCustomScrollDestination(&xOffset, &yOffset); bool scrollCheck = scrollChildren(xOffset, yOffset); if (!notDone || !scrollCheck) { stopAutoScrollChildren(); checkNeedBounce(); } } else { if (!scrollChildren(_autoScrollDir.x * dt * _autoScrollOriginalSpeed, _autoScrollDir.y * dt * _autoScrollOriginalSpeed)) { stopAutoScrollChildren(); checkNeedBounce(); } } } } void ScrollView::bounceChildren(float dt) { if (_bounceOriginalSpeed <= 0.0f) { stopBounceChildren(); } if (!bounceScrollChildren(_bounceDir.x * dt * _bounceOriginalSpeed, _bounceDir.y * dt * _bounceOriginalSpeed)) { stopBounceChildren(); } } bool ScrollView::checkNeedBounce() { if (!_bounceEnabled) { return false; } checkBounceBoundary(); if (_topBounceNeeded || _bottomBounceNeeded || _leftBounceNeeded || _rightBounceNeeded) { if (_topBounceNeeded && _leftBounceNeeded) { Point scrollVector = Point(0.0f, _size.height) - Point(_innerContainer->getLeftInParent(), _innerContainer->getTopInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.normalize(); startBounceChildren(orSpeed); } else if (_topBounceNeeded && _rightBounceNeeded) { Point scrollVector = Point(_size.width, _size.height) - Point(_innerContainer->getRightInParent(), _innerContainer->getTopInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.normalize(); startBounceChildren(orSpeed); } else if (_bottomBounceNeeded && _leftBounceNeeded) { Point scrollVector = Point::ZERO - Point(_innerContainer->getLeftInParent(), _innerContainer->getBottomInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.normalize(); startBounceChildren(orSpeed); } else if (_bottomBounceNeeded && _rightBounceNeeded) { Point scrollVector = Point(_size.width, 0.0f) - Point(_innerContainer->getRightInParent(), _innerContainer->getBottomInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.normalize(); startBounceChildren(orSpeed); } else if (_topBounceNeeded) { Point scrollVector = Point(0.0f, _size.height) - Point(0.0f, _innerContainer->getTopInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.normalize(); startBounceChildren(orSpeed); } else if (_bottomBounceNeeded) { Point scrollVector = Point::ZERO - Point(0.0f, _innerContainer->getBottomInParent()); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.normalize(); startBounceChildren(orSpeed); } else if (_leftBounceNeeded) { Point scrollVector = Point::ZERO - Point(_innerContainer->getLeftInParent(), 0.0f); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.normalize(); startBounceChildren(orSpeed); } else if (_rightBounceNeeded) { Point scrollVector = Point(_size.width, 0.0f) - Point(_innerContainer->getRightInParent(), 0.0f); float orSpeed = scrollVector.getLength()/(0.2f); _bounceDir = scrollVector.normalize(); startBounceChildren(orSpeed); } return true; } return false; } void ScrollView::checkBounceBoundary() { float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos > _bottomBoundary) { scrollToBottomEvent(); _bottomBounceNeeded = true; } else { _bottomBounceNeeded = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos < _topBoundary) { scrollToTopEvent(); _topBounceNeeded = true; } else { _topBounceNeeded = false; } float icRightPos = _innerContainer->getRightInParent(); if (icRightPos < _rightBoundary) { scrollToRightEvent(); _rightBounceNeeded = true; } else { _rightBounceNeeded = false; } float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos > _leftBoundary) { scrollToLeftEvent(); _leftBounceNeeded = true; } else { _leftBounceNeeded = false; } } void ScrollView::startBounceChildren(float v) { _bounceOriginalSpeed = v; _bouncing = true; } void ScrollView::stopBounceChildren() { _bouncing = false; _bounceOriginalSpeed = 0.0f; _leftBounceNeeded = false; _rightBounceNeeded = false; _topBounceNeeded = false; _bottomBounceNeeded = false; } void ScrollView::startAutoScrollChildrenWithOriginalSpeed(const Point& dir, float v, bool attenuated, float acceleration) { stopAutoScrollChildren(); _autoScrollDir = dir; _isAutoScrollSpeedAttenuated = attenuated; _autoScrollOriginalSpeed = v; _autoScroll = true; _autoScrollAcceleration = acceleration; } void ScrollView::startAutoScrollChildrenWithDestination(const Point& des, float time, bool attenuated) { _needCheckAutoScrollDestination = false; _autoScrollDestination = des; Point dis = des - _innerContainer->getPosition(); Point dir = dis.normalize(); float orSpeed = 0.0f; float acceleration = -1000.0f; if (attenuated) { acceleration = (-(2 * dis.getLength())) / (time * time); orSpeed = 2 * dis.getLength() / time; } else { _needCheckAutoScrollDestination = true; orSpeed = dis.getLength() / time; } startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, attenuated, acceleration); } void ScrollView::jumpToDestination(const Point &des) { float finalOffsetX = des.x; float finalOffsetY = des.y; switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: if (des.y <= 0) { finalOffsetY = MAX(des.y, _size.height - _innerContainer->getSize().height); } break; case SCROLLVIEW_DIR_HORIZONTAL: if (des.x <= 0) { finalOffsetX = MAX(des.x, _size.width - _innerContainer->getSize().width); } break; case SCROLLVIEW_DIR_BOTH: if (des.y <= 0) { finalOffsetY = MAX(des.y, _size.height - _innerContainer->getSize().height); } if (des.x <= 0) { finalOffsetX = MAX(des.x, _size.width - _innerContainer->getSize().width); } break; default: break; } _innerContainer->setPosition(Point(finalOffsetX, finalOffsetY)); } void ScrollView::stopAutoScrollChildren() { _autoScroll = false; _autoScrollOriginalSpeed = 0.0f; _autoScrollAddUpTime = 0.0f; } bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY) { bool scrollenabled = true; if (touchOffsetX > 0.0f && touchOffsetY > 0.0f) //first quadrant //bounce to top-right { float realOffsetX = touchOffsetX; float realOffsetY = touchOffsetY; float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + realOffsetX >= _rightBoundary) { realOffsetX = _rightBoundary - icRightPos; bounceRightEvent(); scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY >= _topBoundary) { realOffsetY = _topBoundary - icTopPos; bounceTopEvent(); scrollenabled = false; } moveChildren(realOffsetX, realOffsetY); } else if(touchOffsetX < 0.0f && touchOffsetY > 0.0f) //second quadrant //bounce to top-left { float realOffsetX = touchOffsetX; float realOffsetY = touchOffsetY; float icLefrPos = _innerContainer->getLeftInParent(); if (icLefrPos + realOffsetX <= _leftBoundary) { realOffsetX = _leftBoundary - icLefrPos; bounceLeftEvent(); scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY >= _topBoundary) { realOffsetY = _topBoundary - icTopPos; bounceTopEvent(); scrollenabled = false; } moveChildren(realOffsetX, realOffsetY); } else if (touchOffsetX < 0.0f && touchOffsetY < 0.0f) //third quadrant //bounce to bottom-left { float realOffsetX = touchOffsetX; float realOffsetY = touchOffsetY; float icLefrPos = _innerContainer->getLeftInParent(); if (icLefrPos + realOffsetX <= _leftBoundary) { realOffsetX = _leftBoundary - icLefrPos; bounceLeftEvent(); scrollenabled = false; } float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY <= _bottomBoundary) { realOffsetY = _bottomBoundary - icBottomPos; bounceBottomEvent(); scrollenabled = false; } moveChildren(realOffsetX, realOffsetY); } else if (touchOffsetX > 0.0f && touchOffsetY < 0.0f) //forth quadrant //bounce to bottom-right { float realOffsetX = touchOffsetX; float realOffsetY = touchOffsetY; float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + realOffsetX >= _rightBoundary) { realOffsetX = _rightBoundary - icRightPos; bounceRightEvent(); scrollenabled = false; } float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY <= _bottomBoundary) { realOffsetY = _bottomBoundary - icBottomPos; bounceBottomEvent(); scrollenabled = false; } moveChildren(realOffsetX, realOffsetY); } else if (touchOffsetX == 0.0f && touchOffsetY > 0.0f) // bounce to top { float realOffsetY = touchOffsetY; float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY >= _topBoundary) { realOffsetY = _topBoundary - icTopPos; bounceTopEvent(); scrollenabled = false; } moveChildren(0.0f, realOffsetY); } else if (touchOffsetX == 0.0f && touchOffsetY < 0.0f) //bounce to bottom { float realOffsetY = touchOffsetY; float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY <= _bottomBoundary) { realOffsetY = _bottomBoundary - icBottomPos; bounceBottomEvent(); scrollenabled = false; } moveChildren(0.0f, realOffsetY); } else if (touchOffsetX > 0.0f && touchOffsetY == 0.0f) //bounce to right { float realOffsetX = touchOffsetX; float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + realOffsetX >= _rightBoundary) { realOffsetX = _rightBoundary - icRightPos; bounceRightEvent(); scrollenabled = false; } moveChildren(realOffsetX, 0.0f); } else if (touchOffsetX < 0.0f && touchOffsetY == 0.0f) //bounce to left { float realOffsetX = touchOffsetX; float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + realOffsetX <= _leftBoundary) { realOffsetX = _leftBoundary - icLeftPos; bounceLeftEvent(); scrollenabled = false; } moveChildren(realOffsetX, 0.0f); } return scrollenabled; } bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchOffsetY) { bool scrollenabled = true; switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: // vertical { if (_autoScrollDir.y > 0) { float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + *touchOffsetY >= _autoScrollDestination.y) { *touchOffsetY = _autoScrollDestination.y - icBottomPos; scrollenabled = false; } } else { float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + *touchOffsetY <= _autoScrollDestination.y) { *touchOffsetY = _autoScrollDestination.y - icBottomPos; scrollenabled = false; } } break; } case SCROLLVIEW_DIR_HORIZONTAL: // horizontal { if (_autoScrollDir.x > 0) { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + *touchOffsetX >= _autoScrollDestination.x) { *touchOffsetX = _autoScrollDestination.x - icLeftPos; scrollenabled = false; } } else { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + *touchOffsetX <= _autoScrollDestination.x) { *touchOffsetX = _autoScrollDestination.x - icLeftPos; scrollenabled = false; } } break; } case SCROLLVIEW_DIR_BOTH: { if (*touchOffsetX > 0.0f && *touchOffsetY > 0.0f) // up right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + *touchOffsetX >= _autoScrollDestination.x) { *touchOffsetX = _autoScrollDestination.x - icLeftPos; scrollenabled = false; } float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + *touchOffsetY >= _autoScrollDestination.y) { *touchOffsetY = _autoScrollDestination.y - icBottomPos; scrollenabled = false; } } else if (*touchOffsetX < 0.0f && *touchOffsetY > 0.0f) // up left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + *touchOffsetX <= _autoScrollDestination.x) { *touchOffsetX = _autoScrollDestination.x - icRightPos; scrollenabled = false; } float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + *touchOffsetY >= _autoScrollDestination.y) { *touchOffsetY = _autoScrollDestination.y - icBottomPos; scrollenabled = false; } } else if (*touchOffsetX < 0.0f && *touchOffsetY < 0.0f) // down left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + *touchOffsetX <= _autoScrollDestination.x) { *touchOffsetX = _autoScrollDestination.x - icRightPos; scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + *touchOffsetY <= _autoScrollDestination.y) { *touchOffsetY = _autoScrollDestination.y - icTopPos; scrollenabled = false; } } else if (*touchOffsetX > 0.0f && *touchOffsetY < 0.0f) // down right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + *touchOffsetX >= _autoScrollDestination.x) { *touchOffsetX = _autoScrollDestination.x - icLeftPos; scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + *touchOffsetY <= _autoScrollDestination.y) { *touchOffsetY = _autoScrollDestination.y - icTopPos; scrollenabled = false; } } else if (*touchOffsetX == 0.0f && *touchOffsetY > 0.0f) // up { float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + *touchOffsetY >= _autoScrollDestination.y) { *touchOffsetY = _autoScrollDestination.y - icBottomPos; scrollenabled = false; } } else if (*touchOffsetX < 0.0f && *touchOffsetY == 0.0f) // left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + *touchOffsetX <= _autoScrollDestination.x) { *touchOffsetX = _autoScrollDestination.x - icRightPos; scrollenabled = false; } } else if (*touchOffsetX == 0.0f && *touchOffsetY < 0.0f) // down { float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + *touchOffsetY <= _autoScrollDestination.y) { *touchOffsetY = _autoScrollDestination.y - icTopPos; scrollenabled = false; } } else if (*touchOffsetX > 0.0f && *touchOffsetY == 0.0f) // right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + *touchOffsetX >= _autoScrollDestination.x) { *touchOffsetX = _autoScrollDestination.x - icLeftPos; scrollenabled = false; } } break; } default: break; } return scrollenabled; } bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY) { bool scrollenabled = true; scrollingEvent(); switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: // vertical { float realOffset = touchOffsetY; if (_bounceEnabled) { float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY >= _bounceBottomBoundary) { realOffset = _bounceBottomBoundary - icBottomPos; scrollToBottomEvent(); scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY <= _bounceTopBoundary) { realOffset = _bounceTopBoundary - icTopPos; scrollToTopEvent(); scrollenabled = false; } } else { float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY >= _bottomBoundary) { realOffset = _bottomBoundary - icBottomPos; scrollToBottomEvent(); scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY <= _topBoundary) { realOffset = _topBoundary - icTopPos; scrollToTopEvent(); scrollenabled = false; } } moveChildren(0.0f, realOffset); break; } case SCROLLVIEW_DIR_HORIZONTAL: // horizontal { float realOffset = touchOffsetX; if (_bounceEnabled) { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + touchOffsetX <= _bounceRightBoundary) { realOffset = _bounceRightBoundary - icRightPos; scrollToRightEvent(); scrollenabled = false; } float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + touchOffsetX >= _bounceLeftBoundary) { realOffset = _bounceLeftBoundary - icLeftPos; scrollToLeftEvent(); scrollenabled = false; } } else { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + touchOffsetX <= _rightBoundary) { realOffset = _rightBoundary - icRightPos; scrollToRightEvent(); scrollenabled = false; } float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + touchOffsetX >= _leftBoundary) { realOffset = _leftBoundary - icLeftPos; scrollToLeftEvent(); scrollenabled = false; } } moveChildren(realOffset, 0.0f); break; } case SCROLLVIEW_DIR_BOTH: { float realOffsetX = touchOffsetX; float realOffsetY = touchOffsetY; if (_bounceEnabled) { if (touchOffsetX > 0.0f && touchOffsetY > 0.0f) // up right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + touchOffsetX >= _bounceLeftBoundary) { realOffsetX = _bounceLeftBoundary - icLeftPos; scrollToLeftEvent(); scrollenabled = false; } float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY >= _bounceBottomBoundary) { realOffsetY = _bounceBottomBoundary - icBottomPos; scrollToBottomEvent(); scrollenabled = false; } } else if (touchOffsetX < 0.0f && touchOffsetY > 0.0f) // up left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + touchOffsetX <= _bounceRightBoundary) { realOffsetX = _bounceRightBoundary - icRightPos; scrollToRightEvent(); scrollenabled = false; } float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY >= _bounceBottomBoundary) { realOffsetY = _bounceBottomBoundary - icBottomPos; scrollToBottomEvent(); scrollenabled = false; } } else if (touchOffsetX < 0.0f && touchOffsetY < 0.0f) // down left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + touchOffsetX <= _bounceRightBoundary) { realOffsetX = _bounceRightBoundary - icRightPos; scrollToRightEvent(); scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY <= _bounceTopBoundary) { realOffsetY = _bounceTopBoundary - icTopPos; scrollToTopEvent(); scrollenabled = false; } } else if (touchOffsetX > 0.0f && touchOffsetY < 0.0f) // down right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + touchOffsetX >= _bounceLeftBoundary) { realOffsetX = _bounceLeftBoundary - icLeftPos; scrollToLeftEvent(); scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY <= _bounceTopBoundary) { realOffsetY = _bounceTopBoundary - icTopPos; scrollToTopEvent(); scrollenabled = false; } } else if (touchOffsetX == 0.0f && touchOffsetY > 0.0f) // up { float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY >= _bounceBottomBoundary) { realOffsetY = _bounceBottomBoundary - icBottomPos; scrollToBottomEvent(); scrollenabled = false; } } else if (touchOffsetX < 0.0f && touchOffsetY == 0.0f) // left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + touchOffsetX <= _bounceRightBoundary) { realOffsetX = _bounceRightBoundary - icRightPos; scrollToRightEvent(); scrollenabled = false; } } else if (touchOffsetX == 0.0f && touchOffsetY < 0.0f) // down { float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY <= _bounceTopBoundary) { realOffsetY = _bounceTopBoundary - icTopPos; scrollToTopEvent(); scrollenabled = false; } } else if (touchOffsetX > 0.0f && touchOffsetY == 0.0f) // right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + touchOffsetX >= _bounceLeftBoundary) { realOffsetX = _bounceLeftBoundary - icLeftPos; scrollToLeftEvent(); scrollenabled = false; } } } else { if (touchOffsetX > 0.0f && touchOffsetY > 0.0f) // up right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + touchOffsetX >= _leftBoundary) { realOffsetX = _leftBoundary - icLeftPos; scrollToLeftEvent(); scrollenabled = false; } float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY >= _bottomBoundary) { realOffsetY = _bottomBoundary - icBottomPos; scrollToBottomEvent(); scrollenabled = false; } } else if (touchOffsetX < 0.0f && touchOffsetY > 0.0f) // up left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + touchOffsetX <= _rightBoundary) { realOffsetX = _rightBoundary - icRightPos; scrollToRightEvent(); scrollenabled = false; } float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY >= _bottomBoundary) { realOffsetY = _bottomBoundary - icBottomPos; scrollToBottomEvent(); scrollenabled = false; } } else if (touchOffsetX < 0.0f && touchOffsetY < 0.0f) // down left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + touchOffsetX <= _rightBoundary) { realOffsetX = _rightBoundary - icRightPos; scrollToRightEvent(); scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY <= _topBoundary) { realOffsetY = _topBoundary - icTopPos; scrollToTopEvent(); scrollenabled = false; } } else if (touchOffsetX > 0.0f && touchOffsetY < 0.0f) // down right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + touchOffsetX >= _leftBoundary) { realOffsetX = _leftBoundary - icLeftPos; scrollToLeftEvent(); scrollenabled = false; } float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY <= _topBoundary) { realOffsetY = _topBoundary - icTopPos; scrollToTopEvent(); scrollenabled = false; } } else if (touchOffsetX == 0.0f && touchOffsetY > 0.0f) // up { float icBottomPos = _innerContainer->getBottomInParent(); if (icBottomPos + touchOffsetY >= _bottomBoundary) { realOffsetY = _bottomBoundary - icBottomPos; scrollToBottomEvent(); scrollenabled = false; } } else if (touchOffsetX < 0.0f && touchOffsetY == 0.0f) // left { float icRightPos = _innerContainer->getRightInParent(); if (icRightPos + touchOffsetX <= _rightBoundary) { realOffsetX = _rightBoundary - icRightPos; scrollToRightEvent(); scrollenabled = false; } } else if (touchOffsetX == 0.0f && touchOffsetY < 0.0f) // down { float icTopPos = _innerContainer->getTopInParent(); if (icTopPos + touchOffsetY <= _topBoundary) { realOffsetY = _topBoundary - icTopPos; scrollToTopEvent(); scrollenabled = false; } } else if (touchOffsetX > 0.0f && touchOffsetY == 0.0f) // right { float icLeftPos = _innerContainer->getLeftInParent(); if (icLeftPos + touchOffsetX >= _leftBoundary) { realOffsetX = _leftBoundary - icLeftPos; scrollToLeftEvent(); scrollenabled = false; } } } moveChildren(realOffsetX, realOffsetY); break; } default: break; } return scrollenabled; } void ScrollView::scrollToBottom(float time, bool attenuated) { startAutoScrollChildrenWithDestination(Point(_innerContainer->getPosition().x, 0.0f), time, attenuated); } void ScrollView::scrollToTop(float time, bool attenuated) { startAutoScrollChildrenWithDestination(Point(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height), time, attenuated); } void ScrollView::scrollToLeft(float time, bool attenuated) { startAutoScrollChildrenWithDestination(Point(0.0f, _innerContainer->getPosition().y), time, attenuated); } void ScrollView::scrollToRight(float time, bool attenuated) { startAutoScrollChildrenWithDestination(Point(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y), time, attenuated); } void ScrollView::scrollToTopLeft(float time, bool attenuated) { if (_direction != SCROLLVIEW_DIR_BOTH) { CCLOG("Scroll diretion is not both!"); return; } startAutoScrollChildrenWithDestination(Point(0.0f, _size.height - _innerContainer->getSize().height), time, attenuated); } void ScrollView::scrollToTopRight(float time, bool attenuated) { if (_direction != SCROLLVIEW_DIR_BOTH) { CCLOG("Scroll diretion is not both!"); return; } startAutoScrollChildrenWithDestination(Point(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height), time, attenuated); } void ScrollView::scrollToBottomLeft(float time, bool attenuated) { if (_direction != SCROLLVIEW_DIR_BOTH) { CCLOG("Scroll diretion is not both!"); return; } startAutoScrollChildrenWithDestination(Point::ZERO, time, attenuated); } void ScrollView::scrollToBottomRight(float time, bool attenuated) { if (_direction != SCROLLVIEW_DIR_BOTH) { CCLOG("Scroll diretion is not both!"); return; } startAutoScrollChildrenWithDestination(Point(_size.width - _innerContainer->getSize().width, 0.0f), time, attenuated); } void ScrollView::scrollToPercentVertical(float percent, float time, bool attenuated) { float minY = _size.height - _innerContainer->getSize().height; float h = - minY; startAutoScrollChildrenWithDestination(Point(_innerContainer->getPosition().x, minY + percent * h / 100.0f), time, attenuated); } void ScrollView::scrollToPercentHorizontal(float percent, float time, bool attenuated) { float w = _innerContainer->getSize().width - _size.width; startAutoScrollChildrenWithDestination(Point(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated); } void ScrollView::scrollToPercentBothDirection(const Point& percent, float time, bool attenuated) { if (_direction != SCROLLVIEW_DIR_BOTH) { return; } float minY = _size.height - _innerContainer->getSize().height; float h = - minY; float w = _innerContainer->getSize().width - _size.width; startAutoScrollChildrenWithDestination(Point(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated); } void ScrollView::jumpToBottom() { jumpToDestination(Point(_innerContainer->getPosition().x, 0.0f)); } void ScrollView::jumpToTop() { jumpToDestination(Point(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height)); } void ScrollView::jumpToLeft() { jumpToDestination(Point(0.0f, _innerContainer->getPosition().y)); } void ScrollView::jumpToRight() { jumpToDestination(Point(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y)); } void ScrollView::jumpToTopLeft() { if (_direction != SCROLLVIEW_DIR_BOTH) { CCLOG("Scroll diretion is not both!"); return; } jumpToDestination(Point(0.0f, _size.height - _innerContainer->getSize().height)); } void ScrollView::jumpToTopRight() { if (_direction != SCROLLVIEW_DIR_BOTH) { CCLOG("Scroll diretion is not both!"); return; } jumpToDestination(Point(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height)); } void ScrollView::jumpToBottomLeft() { if (_direction != SCROLLVIEW_DIR_BOTH) { CCLOG("Scroll diretion is not both!"); return; } jumpToDestination(Point::ZERO); } void ScrollView::jumpToBottomRight() { if (_direction != SCROLLVIEW_DIR_BOTH) { CCLOG("Scroll diretion is not both!"); return; } jumpToDestination(Point(_size.width - _innerContainer->getSize().width, 0.0f)); } void ScrollView::jumpToPercentVertical(float percent) { float minY = _size.height - _innerContainer->getSize().height; float h = - minY; jumpToDestination(Point(_innerContainer->getPosition().x, minY + percent * h / 100.0f)); } void ScrollView::jumpToPercentHorizontal(float percent) { float w = _innerContainer->getSize().width - _size.width; jumpToDestination(Point(-(percent * w / 100.0f), _innerContainer->getPosition().y)); } void ScrollView::jumpToPercentBothDirection(const Point& percent) { if (_direction != SCROLLVIEW_DIR_BOTH) { return; } float minY = _size.height - _innerContainer->getSize().height; float h = - minY; float w = _innerContainer->getSize().width - _size.width; jumpToDestination(Point(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f)); } void ScrollView::startRecordSlidAction() { if (_autoScroll) { stopAutoScrollChildren(); } if (_bouncing) { stopBounceChildren(); } _slidTime = 0.0f; } void ScrollView::endRecordSlidAction() { if (!checkNeedBounce() && _inertiaScrollEnabled) { if (_slidTime <= 0.016f) { return; } float totalDis = 0.0f; Point dir; switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: totalDis = _touchEndedPoint.y - _touchBeganPoint.y; if (totalDis < 0.0f) { dir = SCROLLDIR_DOWN; } else { dir = SCROLLDIR_UP; } break; case SCROLLVIEW_DIR_HORIZONTAL: totalDis = _touchEndedPoint.x - _touchBeganPoint.x; if (totalDis < 0.0f) { dir = SCROLLDIR_LEFT; } else { dir = SCROLLDIR_RIGHT; } break; case SCROLLVIEW_DIR_BOTH: { Point subVector = _touchEndedPoint - _touchBeganPoint; totalDis = subVector.getLength(); dir = subVector.normalize(); break; } default: break; } float orSpeed = MIN(fabs(totalDis)/(_slidTime), AUTOSCROLLMAXSPEED); startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, true, -1000); _slidTime = 0.0f; } } void ScrollView::handlePressLogic(const Point &touchPoint) { _touchBeganPoint = convertToNodeSpace(touchPoint); _touchMovingPoint = _touchBeganPoint; startRecordSlidAction(); _bePressed = true; } void ScrollView::handleMoveLogic(const Point &touchPoint) { _touchMovedPoint = convertToNodeSpace(touchPoint); Point delta = _touchMovedPoint - _touchMovingPoint; _touchMovingPoint = _touchMovedPoint; switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: // vertical { scrollChildren(0.0f, delta.y); break; } case SCROLLVIEW_DIR_HORIZONTAL: // horizontal { scrollChildren(delta.x, 0.0f); break; } case SCROLLVIEW_DIR_BOTH: // both { scrollChildren(delta.x, delta.y); break; } default: break; } } void ScrollView::handleReleaseLogic(const Point &touchPoint) { _touchEndedPoint = convertToNodeSpace(touchPoint); endRecordSlidAction(); _bePressed = false; } bool ScrollView::onTouchBegan(Touch *touch, Event *unusedEvent) { bool pass = Layout::onTouchBegan(touch, unusedEvent); if (_hitted) { handlePressLogic(_touchStartPos); } return pass; } void ScrollView::onTouchMoved(Touch *touch, Event *unusedEvent) { Layout::onTouchMoved(touch, unusedEvent); handleMoveLogic(_touchMovePos); } void ScrollView::onTouchEnded(Touch *touch, Event *unusedEvent) { Layout::onTouchEnded(touch, unusedEvent); handleReleaseLogic(_touchEndPos); } void ScrollView::onTouchCancelled(Touch *touch, Event *unusedEvent) { Layout::onTouchCancelled(touch, unusedEvent); handleReleaseLogic(touch->getLocation()); } void ScrollView::update(float dt) { if (_autoScroll) { autoScrollChildren(dt); } if (_bouncing) { bounceChildren(dt); } recordSlidTime(dt); } void ScrollView::recordSlidTime(float dt) { if (_bePressed) { _slidTime += dt; } } void ScrollView::interceptTouchEvent(int handleState, Widget *sender, const Point &touchPoint) { switch (handleState) { case 0: handlePressLogic(touchPoint); break; case 1: { float offset = (sender->getTouchStartPos() - touchPoint).getLength(); if (offset > _childFocusCancelOffset) { sender->setFocused(false); handleMoveLogic(touchPoint); } } break; case 2: handleReleaseLogic(touchPoint); break; case 3: handleReleaseLogic(touchPoint); break; } } void ScrollView::checkChildInfo(int handleState,Widget* sender,const Point &touchPoint) { interceptTouchEvent(handleState, sender, touchPoint); } void ScrollView::scrollToTopEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP); } } void ScrollView::scrollToBottomEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); } } void ScrollView::scrollToLeftEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT); } } void ScrollView::scrollToRightEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); } } void ScrollView::scrollingEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLLING); } } void ScrollView::bounceTopEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_TOP); } } void ScrollView::bounceBottomEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_BOTTOM); } } void ScrollView::bounceLeftEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_LEFT); } } void ScrollView::bounceRightEvent() { if (_scrollViewEventListener && _scrollViewEventSelector) { (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_RIGHT); } } void ScrollView::addEventListenerScrollView(Object *target, SEL_ScrollViewEvent selector) { _scrollViewEventListener = target; _scrollViewEventSelector = selector; } void ScrollView::setDirection(SCROLLVIEW_DIR dir) { _direction = dir; } SCROLLVIEW_DIR ScrollView::getDirection() { return _direction; } void ScrollView::setBounceEnabled(bool enabled) { _bounceEnabled = enabled; } bool ScrollView::isBounceEnabled() const { return _bounceEnabled; } void ScrollView::setInertiaScrollEnabled(bool enabled) { _inertiaScrollEnabled = enabled; } bool ScrollView::isInertiaScrollEnabled() const { return _inertiaScrollEnabled; } Layout* ScrollView::getInnerContainer() { return _innerContainer; } void ScrollView::setLayoutType(LayoutType type) { _innerContainer->setLayoutType(type); } LayoutType ScrollView::getLayoutType() const { return _innerContainer->getLayoutType(); } void ScrollView::doLayout() { if (!_doLayoutDirty) { return; } _doLayoutDirty = false; } std::string ScrollView::getDescription() const { return "ScrollView"; } Widget* ScrollView::createCloneInstance() { return ScrollView::create(); } void ScrollView::copyClonedWidgetChildren(Widget* model) { Layout::copyClonedWidgetChildren(model); } void ScrollView::copySpecialProperties(Widget *widget) { ScrollView* scrollView = dynamic_cast(widget); if (scrollView) { Layout::copySpecialProperties(widget); setInnerContainerSize(scrollView->getInnerContainerSize()); setDirection(scrollView->_direction); setBounceEnabled(scrollView->_bounceEnabled); setInertiaScrollEnabled(scrollView->_inertiaScrollEnabled); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UIScrollView.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UISCROLLVIEW_H__ #define __UISCROLLVIEW_H__ #include "gui/UILayout.h" #include "gui/UIScrollInterface.h" NS_CC_BEGIN namespace gui { enum SCROLLVIEW_DIR { SCROLLVIEW_DIR_NONE, SCROLLVIEW_DIR_VERTICAL, SCROLLVIEW_DIR_HORIZONTAL, SCROLLVIEW_DIR_BOTH }; typedef enum { SCROLLVIEW_EVENT_SCROLL_TO_TOP, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM, SCROLLVIEW_EVENT_SCROLL_TO_LEFT, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT, SCROLLVIEW_EVENT_SCROLLING, SCROLLVIEW_EVENT_BOUNCE_TOP, SCROLLVIEW_EVENT_BOUNCE_BOTTOM, SCROLLVIEW_EVENT_BOUNCE_LEFT, SCROLLVIEW_EVENT_BOUNCE_RIGHT }ScrollviewEventType; typedef void (Object::*SEL_ScrollViewEvent)(Object*, ScrollviewEventType); #define scrollvieweventselector(_SELECTOR) (SEL_ScrollViewEvent)(&_SELECTOR) class ScrollView : public Layout , public UIScrollInterface { public: /** * Default constructor */ ScrollView(); /** * Default destructor */ virtual ~ScrollView(); /** * Allocates and initializes. */ static ScrollView* create(); /** * Changes scroll direction of scrollview. * * @see SCROLLVIEW_DIR SCROLLVIEW_DIR_VERTICAL means vertical scroll, SCROLLVIEW_DIR_HORIZONTAL means horizontal scroll * * @param SCROLLVIEW_DIR */ virtual void setDirection(SCROLLVIEW_DIR dir); /** * Gets scroll direction of scrollview. * * @see SCROLLVIEW_DIR SCROLLVIEW_DIR_VERTICAL means vertical scroll, SCROLLVIEW_DIR_HORIZONTAL means horizontal scroll * * @return SCROLLVIEW_DIR */ SCROLLVIEW_DIR getDirection(); /** * Gets inner container of scrollview. * * Inner container is the container of scrollview's children. * * @return inner container. */ Layout* getInnerContainer(); /** * Scroll inner container to bottom boundary of scrollview. */ void scrollToBottom(float time, bool attenuated); /** * Scroll inner container to top boundary of scrollview. */ void scrollToTop(float time, bool attenuated); /** * Scroll inner container to left boundary of scrollview. */ void scrollToLeft(float time, bool attenuated); /** * Scroll inner container to right boundary of scrollview. */ void scrollToRight(float time, bool attenuated); /** * Scroll inner container to top and left boundary of scrollview. */ void scrollToTopLeft(float time, bool attenuated); /** * Scroll inner container to top and right boundary of scrollview. */ void scrollToTopRight(float time, bool attenuated); /** * Scroll inner container to bottom and left boundary of scrollview. */ void scrollToBottomLeft(float time, bool attenuated); /** * Scroll inner container to bottom and right boundary of scrollview. */ void scrollToBottomRight(float time, bool attenuated); /** * Scroll inner container to vertical percent position of scrollview. */ void scrollToPercentVertical(float percent, float time, bool attenuated); /** * Scroll inner container to horizontal percent position of scrollview. */ void scrollToPercentHorizontal(float percent, float time, bool attenuated); /** * Scroll inner container to both direction percent position of scrollview. */ void scrollToPercentBothDirection(const Point& percent, float time, bool attenuated); /** * Move inner container to bottom boundary of scrollview. */ void jumpToBottom(); /** * Move inner container to top boundary of scrollview. */ void jumpToTop(); /** * Move inner container to left boundary of scrollview. */ void jumpToLeft(); /** * Move inner container to right boundary of scrollview. */ void jumpToRight(); /** * Move inner container to top and left boundary of scrollview. */ void jumpToTopLeft(); /** * Move inner container to top and right boundary of scrollview. */ void jumpToTopRight(); /** * Move inner container to bottom and left boundary of scrollview. */ void jumpToBottomLeft(); /** * Move inner container to bottom and right boundary of scrollview. */ void jumpToBottomRight(); /** * Move inner container to vertical percent position of scrollview. */ void jumpToPercentVertical(float percent); /** * Move inner container to horizontal percent position of scrollview. */ void jumpToPercentHorizontal(float percent); /** * Move inner container to both direction percent position of scrollview. */ void jumpToPercentBothDirection(const Point& percent); /** * Changes inner container size of scrollview. * * Inner container size must be larger than or equal scrollview's size. * * @param inner container size. */ void setInnerContainerSize(const Size &size); /** * Gets inner container size of scrollview. * * Inner container size must be larger than or equal scrollview's size. * * @return inner container size. */ const Size& getInnerContainerSize() const; /** * Add call back function called scrollview event triggered */ void addEventListenerScrollView(Object* target, SEL_ScrollViewEvent selector); virtual void addChild(Node * child) override; /** * Adds a child to the container with a z-order * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) */ virtual void addChild(Node * child, int zOrder) override; /** * Adds a child to the container with z order and tag * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) * @param tag A interger to identify the node easily. Please refer to setTag(int) */ virtual void addChild(Node* child, int zOrder, int tag) override; //override "removeAllChildrenAndCleanUp" method of widget. virtual void removeAllChildren() override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; //override "removeChild" method of widget. virtual void removeChild(Node* child, bool cleaup = true) override; //override "getChildren" method of widget. virtual Vector& getChildren() override; virtual const Vector& getChildren() const override; virtual ssize_t getChildrenCount() const override; virtual Node * getChildByTag(int tag) override; virtual Widget* getChildByName(const char* name) override; virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override; virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override; virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override; virtual void update(float dt) override; void setBounceEnabled(bool enabled); bool isBounceEnabled() const; void setInertiaScrollEnabled(bool enabled); bool isInertiaScrollEnabled() const; /** * Sets LayoutType. * * @see LayoutType * * @param LayoutType */ virtual void setLayoutType(LayoutType type) override; /** * Gets LayoutType. * * @see LayoutType * * @return LayoutType */ virtual LayoutType getLayoutType() const override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; virtual void onEnter() override; protected: virtual bool init() override; virtual void initRenderer() override; void moveChildren(float offsetX, float offsetY); void autoScrollChildren(float dt); void bounceChildren(float dt); void checkBounceBoundary(); bool checkNeedBounce(); void startAutoScrollChildrenWithOriginalSpeed(const Point& dir, float v, bool attenuated, float acceleration); void startAutoScrollChildrenWithDestination(const Point& des, float time, bool attenuated); void jumpToDestination(const Point& des); void stopAutoScrollChildren(); void startBounceChildren(float v); void stopBounceChildren(); bool checkCustomScrollDestination(float* touchOffsetX, float* touchOffsetY); virtual bool scrollChildren(float touchOffsetX, float touchOffsetY); bool bounceScrollChildren(float touchOffsetX, float touchOffsetY); void startRecordSlidAction(); virtual void endRecordSlidAction(); virtual void handlePressLogic(const Point &touchPoint) override; virtual void handleMoveLogic(const Point &touchPoint) override; virtual void handleReleaseLogic(const Point &touchPoint) override; virtual void interceptTouchEvent(int handleState,Widget* sender,const Point &touchPoint) override; virtual void checkChildInfo(int handleState,Widget* sender,const Point &touchPoint) override; void recordSlidTime(float dt); void scrollToTopEvent(); void scrollToBottomEvent(); void scrollToLeftEvent(); void scrollToRightEvent(); void scrollingEvent(); void bounceTopEvent(); void bounceBottomEvent(); void bounceLeftEvent(); void bounceRightEvent(); virtual void onSizeChanged() override; virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; virtual void setClippingEnabled(bool able) override{Layout::setClippingEnabled(able);}; virtual void doLayout() override; protected: Layout* _innerContainer; SCROLLVIEW_DIR _direction; Point _touchBeganPoint; Point _touchMovedPoint; Point _touchEndedPoint; Point _touchMovingPoint; Point _autoScrollDir; float _topBoundary; float _bottomBoundary; float _leftBoundary; float _rightBoundary; float _bounceTopBoundary; float _bounceBottomBoundary; float _bounceLeftBoundary; float _bounceRightBoundary; bool _autoScroll; float _autoScrollAddUpTime; float _autoScrollOriginalSpeed; float _autoScrollAcceleration; bool _isAutoScrollSpeedAttenuated; bool _needCheckAutoScrollDestination; Point _autoScrollDestination; bool _bePressed; float _slidTime; Point _moveChildPoint; float _childFocusCancelOffset; bool _leftBounceNeeded; bool _topBounceNeeded; bool _rightBounceNeeded; bool _bottomBounceNeeded; bool _bounceEnabled; bool _bouncing; Point _bounceDir; float _bounceOriginalSpeed; bool _inertiaScrollEnabled; Object* _scrollViewEventListener; SEL_ScrollViewEvent _scrollViewEventSelector; }; } NS_CC_END #endif /* defined(__CocoGUI__ScrollView__) */ ================================================ FILE: cocos2d/cocos/gui/UISlider.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UISlider.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" NS_CC_BEGIN namespace gui { static const int BASEBAR_RENDERER_Z = (-2); static const int PROGRESSBAR_RENDERER_Z = (-2); static const int SLIDBALL_RENDERER_Z = (-1); Slider::Slider(): _barRenderer(nullptr), _progressBarRenderer(nullptr), _progressBarTextureSize(Size::ZERO), _slidBallNormalRenderer(nullptr), _slidBallPressedRenderer(nullptr), _slidBallDisabledRenderer(nullptr), _slidBallRenderer(nullptr), _barLength(0.0), _percent(0), _scale9Enabled(false), _prevIgnoreSize(true), _textureFile(""), _progressBarTextureFile(""), _slidBallNormalTextureFile(""), _slidBallPressedTextureFile(""), _slidBallDisabledTextureFile(""), _capInsetsBarRenderer(Rect::ZERO), _capInsetsProgressBarRenderer(Rect::ZERO), _sliderEventListener(nullptr), _sliderEventSelector(nullptr), _barTexType(UI_TEX_TYPE_LOCAL), _progressBarTexType(UI_TEX_TYPE_LOCAL), _ballNTexType(UI_TEX_TYPE_LOCAL), _ballPTexType(UI_TEX_TYPE_LOCAL), _ballDTexType(UI_TEX_TYPE_LOCAL) { } Slider::~Slider() { _sliderEventListener = nullptr; _sliderEventSelector = nullptr; } Slider* Slider::create() { Slider* widget = new Slider(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } void Slider::initRenderer() { _barRenderer = Sprite::create(); _progressBarRenderer = Sprite::create(); _progressBarRenderer->setAnchorPoint(Point(0.0f, 0.5f)); Node::addChild(_barRenderer, BASEBAR_RENDERER_Z, -1); Node::addChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1); _slidBallNormalRenderer = Sprite::create(); _slidBallPressedRenderer = Sprite::create(); _slidBallPressedRenderer->setVisible(false); _slidBallDisabledRenderer = Sprite::create(); _slidBallDisabledRenderer->setVisible(false); _slidBallRenderer = Node::create(); _slidBallRenderer->addChild(_slidBallNormalRenderer); _slidBallRenderer->addChild(_slidBallPressedRenderer); _slidBallRenderer->addChild(_slidBallDisabledRenderer); Node::addChild(_slidBallRenderer, SLIDBALL_RENDERER_Z, -1); } void Slider::loadBarTexture(const char* fileName, TextureResType texType) { if (!fileName || strcmp(fileName, "") == 0) { return; } _textureFile = fileName; _barTexType = texType; switch (_barTexType) { case UI_TEX_TYPE_LOCAL: if (_scale9Enabled) { static_cast(_barRenderer)->initWithFile(fileName); } else { static_cast(_barRenderer)->setTexture(fileName); } break; case UI_TEX_TYPE_PLIST: if (_scale9Enabled) { static_cast(_barRenderer)->initWithSpriteFrameName(fileName); } else { static_cast(_barRenderer)->setSpriteFrame(fileName); } break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); barRendererScaleChangedWithSize(); } void Slider::loadProgressBarTexture(const char *fileName, TextureResType texType) { if (!fileName || strcmp(fileName, "") == 0) { return; } _progressBarTextureFile = fileName; _progressBarTexType = texType; switch (_progressBarTexType) { case UI_TEX_TYPE_LOCAL: if (_scale9Enabled) { static_cast(_progressBarRenderer)->initWithFile(fileName); } else { static_cast(_progressBarRenderer)->setTexture(fileName); } break; case UI_TEX_TYPE_PLIST: if (_scale9Enabled) { static_cast(_progressBarRenderer)->initWithSpriteFrameName(fileName); } else { static_cast(_progressBarRenderer)->setSpriteFrame(fileName); } break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); _progressBarRenderer->setAnchorPoint(Point(0.0f, 0.5f)); _progressBarTextureSize = _progressBarRenderer->getContentSize(); progressBarRendererScaleChangedWithSize(); } void Slider::setScale9Enabled(bool able) { if (_scale9Enabled == able) { return; } _scale9Enabled = able; Node::removeChild(_barRenderer); Node::removeChild(_progressBarRenderer); _barRenderer = nullptr; _progressBarRenderer = nullptr; if (_scale9Enabled) { _barRenderer = extension::Scale9Sprite::create(); _progressBarRenderer = extension::Scale9Sprite::create(); } else { _barRenderer = Sprite::create(); _progressBarRenderer = Sprite::create(); } loadBarTexture(_textureFile.c_str(), _barTexType); loadProgressBarTexture(_progressBarTextureFile.c_str(), _progressBarTexType); Node::addChild(_barRenderer, BASEBAR_RENDERER_Z, -1); Node::addChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; ignoreContentAdaptWithSize(false); _prevIgnoreSize = ignoreBefore; } else { ignoreContentAdaptWithSize(_prevIgnoreSize); } setCapInsetsBarRenderer(_capInsetsBarRenderer); setCapInsetProgressBarRebderer(_capInsetsProgressBarRenderer); } void Slider::ignoreContentAdaptWithSize(bool ignore) { if (!_scale9Enabled || (_scale9Enabled && !ignore)) { Widget::ignoreContentAdaptWithSize(ignore); _prevIgnoreSize = ignore; } } void Slider::setCapInsets(const Rect &capInsets) { setCapInsetsBarRenderer(capInsets); setCapInsetProgressBarRebderer(capInsets); } void Slider::setCapInsetsBarRenderer(const Rect &capInsets) { _capInsetsBarRenderer = capInsets; if (!_scale9Enabled) { return; } static_cast(_barRenderer)->setCapInsets(capInsets); } void Slider::setCapInsetProgressBarRebderer(const Rect &capInsets) { _capInsetsProgressBarRenderer = capInsets; if (!_scale9Enabled) { return; } static_cast(_progressBarRenderer)->setCapInsets(capInsets); } void Slider::loadSlidBallTextures(const char* normal,const char* pressed,const char* disabled,TextureResType texType) { loadSlidBallTextureNormal(normal, texType); loadSlidBallTexturePressed(pressed,texType); loadSlidBallTextureDisabled(disabled,texType); } void Slider::loadSlidBallTextureNormal(const char* normal,TextureResType texType) { if (!normal || strcmp(normal, "") == 0) { return; } _slidBallNormalTextureFile = normal; _ballNTexType = texType; switch (_ballNTexType) { case UI_TEX_TYPE_LOCAL: _slidBallNormalRenderer->setTexture(normal); break; case UI_TEX_TYPE_PLIST: _slidBallNormalRenderer->setSpriteFrame(normal); break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); } void Slider::loadSlidBallTexturePressed(const char* pressed,TextureResType texType) { if (!pressed || strcmp(pressed, "") == 0) { return; } _slidBallPressedTextureFile = pressed; _ballPTexType = texType; switch (_ballPTexType) { case UI_TEX_TYPE_LOCAL: _slidBallPressedRenderer->setTexture(pressed); break; case UI_TEX_TYPE_PLIST: _slidBallPressedRenderer->setSpriteFrame(pressed); break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); } void Slider::loadSlidBallTextureDisabled(const char* disabled,TextureResType texType) { if (!disabled || strcmp(disabled, "") == 0) { return; } _slidBallDisabledTextureFile = disabled; _ballDTexType = texType; switch (_ballDTexType) { case UI_TEX_TYPE_LOCAL: _slidBallDisabledRenderer->setTexture(disabled); break; case UI_TEX_TYPE_PLIST: _slidBallDisabledRenderer->setSpriteFrame(disabled); break; default: break; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); } void Slider::setPercent(int percent) { if (percent > 100) { percent = 100; } if (percent < 0) { percent = 0; } _percent = percent; float res = percent / 100.0f; float dis = _barLength * res; _slidBallRenderer->setPosition(Point(-_barLength/2.0f + dis, 0.0f)); if (_scale9Enabled) { static_cast(_progressBarRenderer)->setPreferredSize(Size(dis,_progressBarTextureSize.height)); } else { Sprite* spriteRenderer = static_cast(_progressBarRenderer); Rect rect = spriteRenderer->getTextureRect(); rect.size.width = _progressBarTextureSize.width * res; spriteRenderer->setTextureRect(rect, spriteRenderer->isTextureRectRotated(), rect.size); } } bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent) { bool pass = Widget::onTouchBegan(touch, unusedEvent); if (_hitted) { Point nsp = convertToNodeSpace(_touchStartPos); setPercent(getPercentWithBallPos(nsp.x)); percentChangedEvent(); } return pass; } void Slider::onTouchMoved(Touch *touch, Event *unusedEvent) { _touchMovePos = touch->getLocation(); Point nsp = convertToNodeSpace(_touchMovePos); _slidBallRenderer->setPosition(Point(nsp.x,0)); setPercent(getPercentWithBallPos(nsp.x)); percentChangedEvent(); } void Slider::onTouchEnded(Touch *touch, Event *unusedEvent) { Widget::onTouchEnded(touch, unusedEvent); } void Slider::onTouchCancelled(Touch *touch, Event *unusedEvent) { Widget::onTouchCancelled(touch, unusedEvent); } float Slider::getPercentWithBallPos(float px) { return (((px-(-_barLength/2.0f))/_barLength)*100.0f); } void Slider::addEventListenerSlider(Object *target, SEL_SlidPercentChangedEvent selector) { _sliderEventListener = target; _sliderEventSelector = selector; } void Slider::percentChangedEvent() { if (_sliderEventListener && _sliderEventSelector) { (_sliderEventListener->*_sliderEventSelector)(this,SLIDER_PERCENTCHANGED); } } int Slider::getPercent() { return _percent; } void Slider::onSizeChanged() { Widget::onSizeChanged(); barRendererScaleChangedWithSize(); progressBarRendererScaleChangedWithSize(); } const Size& Slider::getContentSize() const { return _barRenderer->getContentSize(); } Node* Slider::getVirtualRenderer() { return _barRenderer; } void Slider::barRendererScaleChangedWithSize() { if (_ignoreSize) { _barRenderer->setScale(1.0f); _size = _barRenderer->getContentSize(); _barLength = _size.width; } else { _barLength = _size.width; if (_scale9Enabled) { static_cast(_barRenderer)->setPreferredSize(_size); } else { Size btextureSize = _barRenderer->getContentSize(); if (btextureSize.width <= 0.0f || btextureSize.height <= 0.0f) { _barRenderer->setScale(1.0f); return; } float bscaleX = _size.width / btextureSize.width; float bscaleY = _size.height / btextureSize.height; _barRenderer->setScaleX(bscaleX); _barRenderer->setScaleY(bscaleY); } } setPercent(_percent); } void Slider::progressBarRendererScaleChangedWithSize() { if (_ignoreSize) { if (!_scale9Enabled) { Size ptextureSize = _progressBarTextureSize; float pscaleX = _size.width / ptextureSize.width; float pscaleY = _size.height / ptextureSize.height; _progressBarRenderer->setScaleX(pscaleX); _progressBarRenderer->setScaleY(pscaleY); } } else { if (_scale9Enabled) { static_cast(_progressBarRenderer)->setPreferredSize(_size); } else { Size ptextureSize = _progressBarTextureSize; if (ptextureSize.width <= 0.0f || ptextureSize.height <= 0.0f) { _progressBarRenderer->setScale(1.0f); return; } float pscaleX = _size.width / ptextureSize.width; float pscaleY = _size.height / ptextureSize.height; _progressBarRenderer->setScaleX(pscaleX); _progressBarRenderer->setScaleY(pscaleY); } } _progressBarRenderer->setPosition(Point(-_barLength * 0.5f, 0.0f)); setPercent(_percent); } void Slider::onPressStateChangedToNormal() { _slidBallNormalRenderer->setVisible(true); _slidBallPressedRenderer->setVisible(false); _slidBallDisabledRenderer->setVisible(false); } void Slider::onPressStateChangedToPressed() { _slidBallNormalRenderer->setVisible(false); _slidBallPressedRenderer->setVisible(true); _slidBallDisabledRenderer->setVisible(false); } void Slider::onPressStateChangedToDisabled() { _slidBallNormalRenderer->setVisible(false); _slidBallPressedRenderer->setVisible(false); _slidBallDisabledRenderer->setVisible(true); } std::string Slider::getDescription() const { return "Slider"; } Widget* Slider::createCloneInstance() { return Slider::create(); } void Slider::copySpecialProperties(Widget *widget) { Slider* slider = dynamic_cast(widget); if (slider) { _prevIgnoreSize = slider->_prevIgnoreSize; setScale9Enabled(slider->_scale9Enabled); loadBarTexture(slider->_textureFile.c_str(), slider->_barTexType); loadProgressBarTexture(slider->_progressBarTextureFile.c_str(), slider->_progressBarTexType); loadSlidBallTextureNormal(slider->_slidBallNormalTextureFile.c_str(), slider->_ballNTexType); loadSlidBallTexturePressed(slider->_slidBallPressedTextureFile.c_str(), slider->_ballPTexType); loadSlidBallTextureDisabled(slider->_slidBallDisabledTextureFile.c_str(), slider->_ballDTexType); setPercent(slider->getPercent()); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UISlider.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UISLIDER_H__ #define __UISLIDER_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { typedef enum { SLIDER_PERCENTCHANGED }SliderEventType; typedef void (Object::*SEL_SlidPercentChangedEvent)(Object*,SliderEventType); #define sliderpercentchangedselector(_SELECTOR) (SEL_SlidPercentChangedEvent)(&_SELECTOR) /** * @js NA * @lua NA */ class Slider : public Widget { public: /** * Default constructor */ Slider(); /** * Default destructor */ virtual ~Slider(); /** * Allocates and initializes. */ static Slider* create(); /** * Load texture for slider bar. * * @param fileName file name of texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadBarTexture(const char* fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Sets if slider is using scale9 renderer. * * @param true that using scale9 renderer, false otherwise. */ void setScale9Enabled(bool able); /** * Sets capinsets for slider, if slider is using scale9 renderer. * * @param capInsets capinsets for slider */ void setCapInsets(const Rect &capInsets); /** * Sets capinsets for slider, if slider is using scale9 renderer. * * @param capInsets capinsets for slider */ void setCapInsetsBarRenderer(const Rect &capInsets); /** * Sets capinsets for slider, if slider is using scale9 renderer. * * @param capInsets capinsets for slider */ void setCapInsetProgressBarRebderer(const Rect &capInsets); /** * Load textures for slider ball. * * @param slider ball normal normal state texture. * * @param slider ball selected selected state texture. * * @param slider ball disabled dark state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadSlidBallTextures(const char* normal,const char* pressed,const char* disabled,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load normal state texture for slider ball. * * @param normal normal state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadSlidBallTextureNormal(const char* normal,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load selected state texture for slider ball. * * @param selected selected state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadSlidBallTexturePressed(const char* pressed,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load dark state texture for slider ball. * * @param disabled dark state texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadSlidBallTextureDisabled(const char* disabled,TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Load dark state texture for slider progress bar. * * @param fileName file path of texture. * * @param texType @see UI_TEX_TYPE_LOCAL */ void loadProgressBarTexture(const char* fileName, TextureResType texType = UI_TEX_TYPE_LOCAL); /** * Changes the progress direction of slider. * * @param percent percent value from 1 to 100. */ void setPercent(int percent); /** * Gets the progress direction of slider. * * @return percent percent value from 1 to 100. */ int getPercent(); /** * Add call back function called when slider's percent has changed to slider. */ void addEventListenerSlider(Object* target,SEL_SlidPercentChangedEvent selector); virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override; virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override; virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override; //override "getContentSize" method of widget. virtual const Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; protected: virtual void initRenderer() override; float getPercentWithBallPos(float location); void percentChangedEvent(); virtual void onPressStateChangedToNormal() override; virtual void onPressStateChangedToPressed() override; virtual void onPressStateChangedToDisabled() override; virtual void onSizeChanged() override; void barRendererScaleChangedWithSize(); void progressBarRendererScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: Node* _barRenderer; Node* _progressBarRenderer; Size _progressBarTextureSize; Sprite* _slidBallNormalRenderer; Sprite* _slidBallPressedRenderer; Sprite* _slidBallDisabledRenderer; Node* _slidBallRenderer; float _barLength; int _percent; bool _scale9Enabled; bool _prevIgnoreSize; std::string _textureFile; std::string _progressBarTextureFile; std::string _slidBallNormalTextureFile; std::string _slidBallPressedTextureFile; std::string _slidBallDisabledTextureFile; Rect _capInsetsBarRenderer; Rect _capInsetsProgressBarRenderer; Object* _sliderEventListener; SEL_SlidPercentChangedEvent _sliderEventSelector; TextureResType _barTexType; TextureResType _progressBarTexType; TextureResType _ballNTexType; TextureResType _ballPTexType; TextureResType _ballDTexType; }; } NS_CC_END #endif /* defined(__CocoGUI__Slider__) */ ================================================ FILE: cocos2d/cocos/gui/UIText.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UIText.h" NS_CC_BEGIN namespace gui { static const int LABEL_RENDERER_Z = (-1); Text::Text(): _touchScaleChangeEnabled(false), _normalScaleValueX(1.0f), _normalScaleValueY(1.0f), _fontName("Thonburi"), _fontSize(10), _onSelectedScaleOffset(0.5), _labelRenderer(nullptr) { } Text::~Text() { } Text* Text::create() { Text* widget = new Text(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } bool Text::init() { if (Widget::init()) { return true; } return false; } void Text::initRenderer() { _labelRenderer = LabelTTF::create(); Node::addChild(_labelRenderer, LABEL_RENDERER_Z, -1); } void Text::setText(const std::string& text) { if (text.size()==0) return; _labelRenderer->setString(text); labelScaleChangedWithSize(); } const std::string& Text::getStringValue() { return _labelRenderer->getString(); } ssize_t Text::getStringLength() { return _labelRenderer->getString().size(); } void Text::setFontSize(int size) { _fontSize = size; _labelRenderer->setFontSize(size); labelScaleChangedWithSize(); } void Text::setFontName(const std::string& name) { _fontName = name; _labelRenderer->setFontName(name); labelScaleChangedWithSize(); } void Text::setTextAreaSize(const Size &size) { _labelRenderer->setDimensions(size); labelScaleChangedWithSize(); } void Text::setTextHorizontalAlignment(TextHAlignment alignment) { _labelRenderer->setHorizontalAlignment(alignment); labelScaleChangedWithSize(); } void Text::setTextVerticalAlignment(TextVAlignment alignment) { _labelRenderer->setVerticalAlignment(alignment); labelScaleChangedWithSize(); } void Text::setTouchScaleChangeEnabled(bool enable) { _touchScaleChangeEnabled = enable; _normalScaleValueX = getScaleX(); _normalScaleValueY = getScaleY(); } void Text::setScale(float fScale) { Widget::setScale(fScale); _normalScaleValueX = _normalScaleValueY = fScale; } void Text::setScaleX(float fScaleX) { Widget::setScaleX(fScaleX); } void Text::setScaleY(float fScaleY) { Widget::setScaleY(fScaleY); } bool Text::isTouchScaleChangeEnabled() { return _touchScaleChangeEnabled; } void Text::onPressStateChangedToNormal() { if (!_touchScaleChangeEnabled) { return; } clickScale(_normalScaleValueX, _normalScaleValueY); } void Text::onPressStateChangedToPressed() { if (!_touchScaleChangeEnabled) { return; } _normalScaleValueX = getScaleX(); _normalScaleValueY = getScaleY(); clickScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset); } void Text::onPressStateChangedToDisabled() { } void Text::clickScale(float scaleX, float scaleY) { setScaleX(scaleX); setScaleY(scaleY); } void Text::setFlipX(bool flipX) { _labelRenderer->setFlippedX(flipX); } void Text::setFlipY(bool flipY) { _labelRenderer->setFlippedY(flipY); } bool Text::isFlipX() { return _labelRenderer->isFlippedX(); } bool Text::isFlipY() { return _labelRenderer->isFlippedY(); } void Text::setAnchorPoint(const Point &pt) { Widget::setAnchorPoint(pt); _labelRenderer->setAnchorPoint(pt); } void Text::onSizeChanged() { Widget::onSizeChanged(); labelScaleChangedWithSize(); } const Size& Text::getContentSize() const { return _labelRenderer->getContentSize(); } Node* Text::getVirtualRenderer() { return _labelRenderer; } void Text::labelScaleChangedWithSize() { if (_ignoreSize) { _labelRenderer->setScale(1.0f); _size = _labelRenderer->getContentSize(); } else { Size textureSize = _labelRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _labelRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _labelRenderer->setScaleX(scaleX); _labelRenderer->setScaleY(scaleY); } } std::string Text::getDescription() const { return "Label"; } Widget* Text::createCloneInstance() { return Text::create(); } void Text::copySpecialProperties(Widget *widget) { Text* label = dynamic_cast(widget); if (label) { setFontName(label->_fontName.c_str()); setFontSize(label->_labelRenderer->getFontSize()); setText(label->getStringValue()); setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled); setTextHorizontalAlignment(label->_labelRenderer->getHorizontalAlignment()); setTextVerticalAlignment(label->_labelRenderer->getVerticalAlignment()); setTextAreaSize(label->_labelRenderer->getDimensions()); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UIText.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UILABEL_H__ #define __UILABEL_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { /** * @js NA * @lua NA */ class Text : public Widget { public: /** * Default constructor */ Text(); /** * Default destructor */ virtual ~Text(); /** * Allocates and initializes. */ static Text* create(); /** * Changes the string value of label. * * @param text string value. */ void setText(const std::string& text); /** * Gets the string value of label. * * @return text string value. */ const std::string& getStringValue(); /** * Gets the string length of label. * * @return string length. */ ssize_t getStringLength(); /** * Sets the font size of label. * * @param font size. */ void setFontSize(int size); /** * Sets the font name of label. * * @param font name. */ void setFontName(const std::string& name); /** * Sets the touch scale enabled of label. * * @param touch scale enabled of label. */ void setTouchScaleChangeEnabled(bool enabled); /** * Gets the touch scale enabled of label. * * @return touch scale enabled of label. */ bool isTouchScaleChangeEnabled(); /** * Changes both X and Y scale factor of the widget. * * 1.0 is the default scale factor. It modifies the X and Y scale at the same time. * * @param scale The scale factor for both X and Y axis. */ virtual void setScale(float fScale) override; /** * Changes the scale factor on X axis of this widget * * The deafult value is 1.0 if you haven't changed it before * * @param fScaleX The scale factor on X axis. */ virtual void setScaleX(float fScaleX) override; /** * Changes the scale factor on Y axis of this widget * * The Default value is 1.0 if you haven't changed it before. * * @param fScaleY The scale factor on Y axis. */ virtual void setScaleY(float fScaleY) override; //override "setFlipX" method of widget. virtual void setFlipX(bool flipX) override; //override "setFlipY" method of widget. virtual void setFlipY(bool flipY) override; //override "isFlipX" method of widget. virtual bool isFlipX() override; //override "isFlipY" method of widget. virtual bool isFlipY() override; //override "setAnchorPoint" method of widget. virtual void setAnchorPoint(const Point &pt) override; //override "getContentSize" method of widget. virtual const Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; void setTextAreaSize(const Size &size); void setTextHorizontalAlignment(TextHAlignment alignment); void setTextVerticalAlignment(TextVAlignment alignment); protected: virtual bool init() override; virtual void initRenderer() override; virtual void onPressStateChangedToNormal() override; virtual void onPressStateChangedToPressed() override; virtual void onPressStateChangedToDisabled() override; virtual void onSizeChanged() override; void clickScale(float scaleX, float scaleY); void labelScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: bool _touchScaleChangeEnabled; float _normalScaleValueX; float _normalScaleValueY; std::string _fontName; int _fontSize; float _onSelectedScaleOffset; LabelTTF* _labelRenderer; }; } NS_CC_END #endif /* defined(__CocoGUI__Label__) */ ================================================ FILE: cocos2d/cocos/gui/UITextAtlas.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UITextAtlas.h" NS_CC_BEGIN namespace gui { static const int LABELATLAS_RENDERER_Z = (-1); TextAtlas::TextAtlas(): _labelAtlasRenderer(nullptr), _stringValue(""), _charMapFileName(""), _itemWidth(0), _itemHeight(0), _startCharMap("") { } TextAtlas::~TextAtlas() { } TextAtlas* TextAtlas::create() { TextAtlas* widget = new TextAtlas(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } void TextAtlas::initRenderer() { _labelAtlasRenderer = LabelAtlas::create(); Node::addChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1); } void TextAtlas::setProperty(const std::string& stringValue, const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap) { _stringValue = stringValue; _charMapFileName = charMapFile; _itemWidth = itemWidth; _itemHeight = itemHeight; _startCharMap = startCharMap; _labelAtlasRenderer->initWithString(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0])); updateAnchorPoint(); labelAtlasScaleChangedWithSize(); } void TextAtlas::setStringValue(const std::string& value) { _stringValue = value; _labelAtlasRenderer->setString(value); labelAtlasScaleChangedWithSize(); } const std::string& TextAtlas::getStringValue() const { return _labelAtlasRenderer->getString(); } void TextAtlas::setAnchorPoint(const Point &pt) { Widget::setAnchorPoint(pt); _labelAtlasRenderer->setAnchorPoint(Point(pt.x, pt.y)); } void TextAtlas::onSizeChanged() { Widget::onSizeChanged(); labelAtlasScaleChangedWithSize(); } const Size& TextAtlas::getContentSize() const { return _labelAtlasRenderer->getContentSize(); } Node* TextAtlas::getVirtualRenderer() { return _labelAtlasRenderer; } void TextAtlas::labelAtlasScaleChangedWithSize() { if (_ignoreSize) { _labelAtlasRenderer->setScale(1.0f); _size = _labelAtlasRenderer->getContentSize(); } else { Size textureSize = _labelAtlasRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _labelAtlasRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _labelAtlasRenderer->setScaleX(scaleX); _labelAtlasRenderer->setScaleY(scaleY); } } std::string TextAtlas::getDescription() const { return "TextAtlas"; } Widget* TextAtlas::createCloneInstance() { return TextAtlas::create(); } void TextAtlas::copySpecialProperties(Widget *widget) { TextAtlas* labelAtlas = dynamic_cast(widget); if (labelAtlas) { setProperty(labelAtlas->_stringValue, labelAtlas->_charMapFileName, labelAtlas->_itemWidth, labelAtlas->_itemHeight, labelAtlas->_startCharMap); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UITextAtlas.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UILABELATLAS_H__ #define __UILABELATLAS_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { /** * @js NA * @lua NA */ class TextAtlas : public Widget { public: /** * Default constructor */ TextAtlas(); /** * Default destructor */ virtual ~TextAtlas(); /** * Allocates and initializes. */ static TextAtlas* create(); /** initializes the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ void setProperty(const std::string& stringValue,const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap); //set string value for labelatlas. void setStringValue(const std::string& value); //get string value for labelatlas. const std::string& getStringValue() const; //override "setAnchorPoint" method of widget. virtual void setAnchorPoint(const Point &pt) override; //override "getContentSize" method of widget. virtual const Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; protected: virtual void initRenderer() override; virtual void onSizeChanged() override; void labelAtlasScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: LabelAtlas* _labelAtlasRenderer; std::string _stringValue; std::string _charMapFileName; int _itemWidth; int _itemHeight; std::string _startCharMap; }; } NS_CC_END #endif /* defined(__CocoGUI__LabelAtlas__) */ ================================================ FILE: cocos2d/cocos/gui/UITextBMFont.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UITextBMFont.h" NS_CC_BEGIN namespace gui { static const int LABELBMFONT_RENDERER_Z = (-1); TextBMFont::TextBMFont(): _labelBMFontRenderer(nullptr), _fntFileHasInit(false), _fntFileName(""), _stringValue("") { } TextBMFont::~TextBMFont() { } TextBMFont* TextBMFont::create() { TextBMFont* widget = new TextBMFont(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } void TextBMFont::initRenderer() { _labelBMFontRenderer = cocos2d::LabelBMFont::create(); Node::addChild(_labelBMFontRenderer, LABELBMFONT_RENDERER_Z, -1); } void TextBMFont::setFntFile(const char *fileName) { if (!fileName || strcmp(fileName, "") == 0) { return; } _fntFileName = fileName; _labelBMFontRenderer->initWithString("", fileName); updateAnchorPoint(); labelBMFontScaleChangedWithSize(); _fntFileHasInit = true; setText(_stringValue.c_str()); } void TextBMFont::setText(const char* value) { if (!value) { return; } _stringValue = value; if (!_fntFileHasInit) { return; } _labelBMFontRenderer->setString(value); labelBMFontScaleChangedWithSize(); } const char* TextBMFont::getStringValue() { return _stringValue.c_str(); } void TextBMFont::setAnchorPoint(const Point &pt) { Widget::setAnchorPoint(pt); _labelBMFontRenderer->setAnchorPoint(pt); } void TextBMFont::onSizeChanged() { Widget::onSizeChanged(); labelBMFontScaleChangedWithSize(); } const Size& TextBMFont::getContentSize() const { return _labelBMFontRenderer->getContentSize(); } Node* TextBMFont::getVirtualRenderer() { return _labelBMFontRenderer; } void TextBMFont::labelBMFontScaleChangedWithSize() { if (_ignoreSize) { _labelBMFontRenderer->setScale(1.0f); _size = _labelBMFontRenderer->getContentSize(); } else { Size textureSize = _labelBMFontRenderer->getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _labelBMFontRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _labelBMFontRenderer->setScaleX(scaleX); _labelBMFontRenderer->setScaleY(scaleY); } } std::string TextBMFont::getDescription() const { return "TextBMFont"; } Widget* TextBMFont::createCloneInstance() { return TextBMFont::create(); } void TextBMFont::copySpecialProperties(Widget *widget) { TextBMFont* labelBMFont = dynamic_cast(widget); if (labelBMFont) { setFntFile(labelBMFont->_fntFileName.c_str()); setText(labelBMFont->_stringValue.c_str()); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UITextBMFont.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UILABELBMFONT_H__ #define __UILABELBMFONT_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { /** * @js NA * @lua NA */ class TextBMFont : public Widget { public: /** * Default constructor */ TextBMFont(); /** * Default destructor */ virtual ~TextBMFont(); /** * Allocates and initializes. */ static TextBMFont* create(); /** init a bitmap font atlas with an initial string and the FNT file */ void setFntFile(const char* fileName); /** set string value for labelbmfont*/ void setText(const char* value); /** get string value for labelbmfont*/ const char* getStringValue(); virtual void setAnchorPoint(const Point &pt) override; virtual const Size& getContentSize() const override; virtual Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; protected: virtual void initRenderer() override; virtual void onSizeChanged() override; void labelBMFontScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: cocos2d::LabelBMFont* _labelBMFontRenderer; bool _fntFileHasInit; std::string _fntFileName; std::string _stringValue; }; } NS_CC_END #endif /* defined(__LabelBMFont__) */ ================================================ FILE: cocos2d/cocos/gui/UITextField.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UITextField.h" NS_CC_BEGIN namespace gui { UICCTextField::UICCTextField() : _maxLengthEnabled(false) , _maxLength(0) , _passwordEnabled(false) , _passwordStyleText("*") , _attachWithIME(false) , _detachWithIME(false) , _insertText(false) , _deleteBackward(false) { } UICCTextField::~UICCTextField() { } UICCTextField * UICCTextField::create(const char *placeholder, const char *fontName, float fontSize) { UICCTextField *pRet = new UICCTextField(); if(pRet && pRet->initWithString("", fontName, fontSize)) { pRet->autorelease(); if (placeholder) { pRet->setPlaceHolder(placeholder); } return pRet; } CC_SAFE_DELETE(pRet); return nullptr; } void UICCTextField::onEnter() { TextFieldTTF::setDelegate(this); } bool UICCTextField::onTextFieldAttachWithIME(TextFieldTTF *pSender) { setAttachWithIME(true); return false; } bool UICCTextField::onTextFieldInsertText(TextFieldTTF *pSender, const char *text, int nLen) { if (nLen == 1 && strcmp(text, "\n") == 0) { return false; } setInsertText(true); if (_maxLengthEnabled) { if (TextFieldTTF::getCharCount() >= _maxLength) { return true; } } return false; } bool UICCTextField::onTextFieldDeleteBackward(TextFieldTTF *pSender, const char *delText, int nLen) { setDeleteBackward(true); return false; } bool UICCTextField::onTextFieldDetachWithIME(TextFieldTTF *pSender) { setDetachWithIME(true); return false; } void UICCTextField::insertText(const char * text, int len) { std::string str_text = text; ssize_t str_len = TextFieldTTF::getString().size(); if (strcmp(text, "\n") != 0) { if (_maxLengthEnabled) { int multiple = 1; char value = text[0]; if (value < 0 || value > 127) { multiple = 3; } if (str_len + len > _maxLength * multiple) { str_text = str_text.substr(0, _maxLength * multiple); len = _maxLength * multiple; /* int mod = str_len % 3; int offset = (mod == 0) ? 0 : (3 - mod); int amount = str_len + offset; str_text = str_text.substr(0, _maxLength - amount); // CCLOG("str_test = %s", str_text.c_str()); */ } } } TextFieldTTF::insertText(str_text.c_str(), len); // password if (_passwordEnabled) { if (TextFieldTTF::getCharCount() > 0) { setPasswordText(_inputText.c_str()); } } } void UICCTextField::deleteBackward() { TextFieldTTF::deleteBackward(); if (TextFieldTTF::getCharCount() > 0) { // password if (_passwordEnabled) { setPasswordText(_inputText.c_str()); } } } void UICCTextField::openIME() { TextFieldTTF::attachWithIME(); } void UICCTextField::closeIME() { TextFieldTTF::detachWithIME(); } void UICCTextField::setMaxLengthEnabled(bool enable) { _maxLengthEnabled = enable; } bool UICCTextField::isMaxLengthEnabled() { return _maxLengthEnabled; } void UICCTextField::setMaxLength(int length) { _maxLength = length; } int UICCTextField::getMaxLength() { return _maxLength; } int UICCTextField::getCharCount() { return TextFieldTTF::getCharCount(); } void UICCTextField::setPasswordEnabled(bool enable) { _passwordEnabled = enable; } bool UICCTextField::isPasswordEnabled() { return _passwordEnabled; } void UICCTextField::setPasswordStyleText(const char* styleText) { if (strlen(styleText) > 1) { return; } char value = styleText[0]; if (value < 33 || value > 126) { return; } _passwordStyleText = styleText; } void UICCTextField::setPasswordText(const char *text) { std::string tempStr; for (size_t i = 0; i < strlen(text); ++i) { tempStr.append(_passwordStyleText); } LabelTTF::setString(tempStr.c_str()); } void UICCTextField::setAttachWithIME(bool attach) { _attachWithIME = attach; } bool UICCTextField::getAttachWithIME() { return _attachWithIME; } void UICCTextField::setDetachWithIME(bool detach) { _detachWithIME = detach; } bool UICCTextField::getDetachWithIME() { return _detachWithIME; } void UICCTextField::setInsertText(bool insert) { _insertText = insert; } bool UICCTextField::getInsertText() { return _insertText; } void UICCTextField::setDeleteBackward(bool deleteBackward) { _deleteBackward = deleteBackward; } bool UICCTextField::getDeleteBackward() { return _deleteBackward; } static const int TEXTFIELD_RENDERER_Z = (-1); TextField::TextField(): _textFieldRenderer(nullptr), _touchWidth(0.0f), _touchHeight(0.0f), _useTouchArea(false), _textFieldEventListener(nullptr), _textFieldEventSelector(nullptr), _passwordStyleText("") { } TextField::~TextField() { _textFieldEventListener = nullptr; _textFieldEventSelector = nullptr; } TextField* TextField::create() { TextField* widget = new TextField(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } void TextField::onEnter() { Widget::onEnter(); scheduleUpdate(); } void TextField::initRenderer() { _textFieldRenderer = UICCTextField::create("input words here", "Thonburi", 20); Node::addChild(_textFieldRenderer, TEXTFIELD_RENDERER_Z, -1); } void TextField::setTouchSize(const Size &size) { _useTouchArea = true; _touchWidth = size.width; _touchHeight = size.height; } void TextField::setText(const std::string& text) { std::string strText(text); if (isMaxLengthEnabled()) { strText = strText.substr(0, getMaxLength()); } const char* content = strText.c_str(); if (isPasswordEnabled()) { _textFieldRenderer->setPasswordText(content); _textFieldRenderer->insertText(content, static_cast(strlen(content))); } else { _textFieldRenderer->setString(content); } textfieldRendererScaleChangedWithSize(); } void TextField::setPlaceHolder(const std::string& value) { _textFieldRenderer->setPlaceHolder(value); textfieldRendererScaleChangedWithSize(); } void TextField::setFontSize(int size) { _textFieldRenderer->setFontSize(size); textfieldRendererScaleChangedWithSize(); } void TextField::setFontName(const std::string& name) { _textFieldRenderer->setFontName(name); textfieldRendererScaleChangedWithSize(); } void TextField::didNotSelectSelf() { _textFieldRenderer->detachWithIME(); } const std::string& TextField::getStringValue() { return _textFieldRenderer->getString(); } bool TextField::onTouchBegan(Touch *touch, Event *unusedEvent) { bool pass = Widget::onTouchBegan(touch, unusedEvent); if (_hitted) { _textFieldRenderer->attachWithIME(); } return pass; } void TextField::setMaxLengthEnabled(bool enable) { _textFieldRenderer->setMaxLengthEnabled(enable); } bool TextField::isMaxLengthEnabled() { return _textFieldRenderer->isMaxLengthEnabled(); } void TextField::setMaxLength(int length) { _textFieldRenderer->setMaxLength(length); } int TextField::getMaxLength() { return _textFieldRenderer->getMaxLength(); } void TextField::setPasswordEnabled(bool enable) { _textFieldRenderer->setPasswordEnabled(enable); } bool TextField::isPasswordEnabled() { return _textFieldRenderer->isPasswordEnabled(); } void TextField::setPasswordStyleText(const char *styleText) { _textFieldRenderer->setPasswordStyleText(styleText); _passwordStyleText = styleText; } void TextField::update(float dt) { if (getAttachWithIME()) { attachWithIMEEvent(); setAttachWithIME(false); } if (getDetachWithIME()) { detachWithIMEEvent(); setDetachWithIME(false); } if (getInsertText()) { insertTextEvent(); setInsertText(false); textfieldRendererScaleChangedWithSize(); } if (getDeleteBackward()) { deleteBackwardEvent(); setDeleteBackward(false); } } bool TextField::getAttachWithIME() { return _textFieldRenderer->getAttachWithIME(); } void TextField::setAttachWithIME(bool attach) { _textFieldRenderer->setAttachWithIME(attach); } bool TextField::getDetachWithIME() { return _textFieldRenderer->getDetachWithIME(); } void TextField::setDetachWithIME(bool detach) { _textFieldRenderer->setDetachWithIME(detach); } bool TextField::getInsertText() { return _textFieldRenderer->getInsertText(); } void TextField::setInsertText(bool insertText) { _textFieldRenderer->setInsertText(insertText); } bool TextField::getDeleteBackward() { return _textFieldRenderer->getDeleteBackward(); } void TextField::setDeleteBackward(bool deleteBackward) { _textFieldRenderer->setDeleteBackward(deleteBackward); } void TextField::attachWithIMEEvent() { if (_textFieldEventListener && _textFieldEventSelector) { (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME); } } void TextField::detachWithIMEEvent() { if (_textFieldEventListener && _textFieldEventSelector) { (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME); } } void TextField::insertTextEvent() { if (_textFieldEventListener && _textFieldEventSelector) { (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_INSERT_TEXT); } } void TextField::deleteBackwardEvent() { if (_textFieldEventListener && _textFieldEventSelector) { (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD); } } void TextField::addEventListenerTextField(Object *target, SEL_TextFieldEvent selecor) { _textFieldEventListener = target; _textFieldEventSelector = selecor; } void TextField::setAnchorPoint(const Point &pt) { Widget::setAnchorPoint(pt); _textFieldRenderer->setAnchorPoint(pt); } void TextField::onSizeChanged() { Widget::onSizeChanged(); textfieldRendererScaleChangedWithSize(); } void TextField::textfieldRendererScaleChangedWithSize() { if (_ignoreSize) { _textFieldRenderer->setScale(1.0f); _size = getContentSize(); } else { Size textureSize = getContentSize(); if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) { _textFieldRenderer->setScale(1.0f); return; } float scaleX = _size.width / textureSize.width; float scaleY = _size.height / textureSize.height; _textFieldRenderer->setScaleX(scaleX); _textFieldRenderer->setScaleY(scaleY); } } const Size& TextField::getContentSize() const { return _textFieldRenderer->getContentSize(); } Node* TextField::getVirtualRenderer() { return _textFieldRenderer; } std::string TextField::getDescription() const { return "TextField"; } void TextField::attachWithIME() { _textFieldRenderer->attachWithIME(); } Widget* TextField::createCloneInstance() { return TextField::create(); } void TextField::copySpecialProperties(Widget *widget) { TextField* textField = dynamic_cast(widget); if (textField) { setText(textField->_textFieldRenderer->getString()); setPlaceHolder(textField->getStringValue()); setFontSize(textField->_textFieldRenderer->getFontSize()); setFontName(textField->_textFieldRenderer->getFontName().c_str()); setMaxLengthEnabled(textField->isMaxLengthEnabled()); setMaxLength(textField->getMaxLength()); setPasswordEnabled(textField->isPasswordEnabled()); setPasswordStyleText(textField->_passwordStyleText.c_str()); setAttachWithIME(textField->getAttachWithIME()); setDetachWithIME(textField->getDetachWithIME()); setInsertText(textField->getInsertText()); setDeleteBackward(textField->getDeleteBackward()); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UITextField.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UITEXTFIELD_H__ #define __UITEXTFIELD_H__ #include "gui/UIWidget.h" NS_CC_BEGIN namespace gui { /** * @js NA * @lua NA */ class UICCTextField: public TextFieldTTF, public TextFieldDelegate { public: UICCTextField(); ~UICCTextField(); virtual void onEnter(); // static static UICCTextField* create(const char *placeholder, const char *fontName, float fontSize); // CCTextFieldDelegate virtual bool onTextFieldAttachWithIME(TextFieldTTF *pSender) override; virtual bool onTextFieldDetachWithIME(TextFieldTTF * pSender) override; virtual bool onTextFieldInsertText(TextFieldTTF * pSender, const char * text, int nLen) override; virtual bool onTextFieldDeleteBackward(TextFieldTTF * pSender, const char * delText, int nLen) override; void insertText(const char* text, int len); void deleteBackward(); void openIME(); void closeIME(); void setMaxLengthEnabled(bool enable); bool isMaxLengthEnabled(); void setMaxLength(int length); int getMaxLength(); int getCharCount(); void setPasswordEnabled(bool enable); bool isPasswordEnabled(); void setPasswordStyleText(const char* styleText); void setPasswordText(const char* text); void setAttachWithIME(bool attach); bool getAttachWithIME(); void setDetachWithIME(bool detach); bool getDetachWithIME(); void setInsertText(bool insert); bool getInsertText(); void setDeleteBackward(bool deleteBackward); bool getDeleteBackward(); protected: bool _maxLengthEnabled; int _maxLength; bool _passwordEnabled; std::string _passwordStyleText; bool _attachWithIME; bool _detachWithIME; bool _insertText; bool _deleteBackward; }; typedef enum { TEXTFIELD_EVENT_ATTACH_WITH_IME, TEXTFIELD_EVENT_DETACH_WITH_IME, TEXTFIELD_EVENT_INSERT_TEXT, TEXTFIELD_EVENT_DELETE_BACKWARD, }TextFiledEventType; typedef void (Object::*SEL_TextFieldEvent)(Object*, TextFiledEventType); #define textfieldeventselector(_SELECTOR) (SEL_TextFieldEvent)(&_SELECTOR) /** class UITextField : public Widget * @js NA * @lua NA */ class TextField : public Widget { public: TextField(); virtual ~TextField(); static TextField* create(); void setTouchSize(const Size &size); void setText(const std::string& text); void setPlaceHolder(const std::string& value); void setFontSize(int size); void setFontName(const std::string& name); virtual void didNotSelectSelf(); const std::string& getStringValue(); virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; void setMaxLengthEnabled(bool enable); bool isMaxLengthEnabled(); void setMaxLength(int length); int getMaxLength(); void setPasswordEnabled(bool enable); bool isPasswordEnabled(); void setPasswordStyleText(const char* styleText); virtual void update(float dt) override; bool getAttachWithIME(); void setAttachWithIME(bool attach); bool getDetachWithIME(); void setDetachWithIME(bool detach); bool getInsertText(); void setInsertText(bool insertText); bool getDeleteBackward(); void setDeleteBackward(bool deleteBackward); void addEventListenerTextField(Object* target, SEL_TextFieldEvent selecor); virtual void setAnchorPoint(const Point &pt) override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; virtual const Size& getContentSize() const override; virtual Node* getVirtualRenderer() override; void attachWithIME(); virtual void onEnter() override; protected: // event virtual void initRenderer() override; void attachWithIMEEvent(); void detachWithIMEEvent(); void insertTextEvent(); void deleteBackwardEvent(); virtual void onSizeChanged() override; void textfieldRendererScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: UICCTextField* _textFieldRenderer; float _touchWidth; float _touchHeight; bool _useTouchArea; Object* _textFieldEventListener; SEL_TextFieldEvent _textFieldEventSelector; std::string _passwordStyleText; }; } NS_CC_END #endif /* defined(__TextField__) */ ================================================ FILE: cocos2d/cocos/gui/UIWidget.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "gui/UIWidget.h" #include "gui/UILayout.h" #include "gui/UIHelper.h" NS_CC_BEGIN namespace gui { Widget::Widget(): _enabled(true), _bright(true), _touchEnabled(false), _touchPassedEnabled(false), _focus(false), _brightStyle(BRIGHT_NONE), _touchStartPos(Point::ZERO), _touchMovePos(Point::ZERO), _touchEndPos(Point::ZERO), _touchEventListener(nullptr), _touchEventSelector(nullptr), _name("default"), _widgetType(WidgetTypeWidget), _actionTag(0), _size(Size::ZERO), _customSize(Size::ZERO), _ignoreSize(false), _affectByClipping(false), _sizeType(SIZE_ABSOLUTE), _sizePercent(Point::ZERO), _positionType(POSITION_ABSOLUTE), _positionPercent(Point::ZERO), _reorderWidgetChildDirty(true), _hitted(false), _touchListener(nullptr) { } Widget::~Widget() { _touchEventListener = nullptr; _touchEventSelector = nullptr; _widgetChildren.clear(); setTouchEnabled(false); _nodes.clear(); } Widget* Widget::create() { Widget* widget = new Widget(); if (widget && widget->init()) { widget->autorelease(); return widget; } CC_SAFE_DELETE(widget); return nullptr; } bool Widget::init() { if (Node::init()) { initRenderer(); setCascadeColorEnabled(true); setCascadeOpacityEnabled(true); setBright(true); ignoreContentAdaptWithSize(true); setAnchorPoint(Point(0.5f, 0.5f)); return true; } return false; } void Widget::onEnter() { updateSizeAndPosition(); Node::onEnter(); } void Widget::onExit() { unscheduleUpdate(); Node::onExit(); } void Widget::visit() { if (_enabled) { Node::visit(); } } void Widget::addChild(Node *child) { Node::addChild(child); } void Widget::addChild(Node * child, int zOrder) { Node::addChild(child, zOrder); } void Widget::addChild(Node* child, int zOrder, int tag) { CCASSERT(dynamic_cast(child) != nullptr, "Widget only supports Widgets as children"); Node::addChild(child, zOrder, tag); _widgetChildren.pushBack(child); } void Widget::sortAllChildren() { _reorderWidgetChildDirty = _reorderChildDirty; Node::sortAllChildren(); if( _reorderWidgetChildDirty ) { std::sort( std::begin(_widgetChildren), std::end(_widgetChildren), nodeComparisonLess ); _reorderWidgetChildDirty = false; } } Node* Widget::getChildByTag(int aTag) { CCASSERT( aTag != Node::INVALID_TAG, "Invalid tag"); for (auto& child : _widgetChildren) { if(child && child->getTag() == aTag) return child; } return nullptr; } Vector& Widget::getChildren() { return _widgetChildren; } const Vector& Widget::getChildren() const { return _widgetChildren; } ssize_t Widget::getChildrenCount() const { return _widgetChildren.size(); } Widget* Widget::getWidgetParent() { return dynamic_cast(getParent()); } void Widget::removeFromParent() { removeFromParentAndCleanup(true); } void Widget::removeFromParentAndCleanup(bool cleanup) { Node::removeFromParentAndCleanup(cleanup); } void Widget::removeChild(Node *child, bool cleanup) { Node::removeChild(child, cleanup); _widgetChildren.eraseObject(child); } void Widget::removeChildByTag(int tag, bool cleanup) { CCASSERT( tag != Node::INVALID_TAG, "Invalid tag"); Node *child = getChildByTag(tag); if (child == nullptr) { CCLOG("cocos2d: removeChildByTag(tag = %d): child not found!", tag); } else { removeChild(child, cleanup); } } void Widget::removeAllChildren() { removeAllChildrenWithCleanup(true); } void Widget::removeAllChildrenWithCleanup(bool cleanup) { for (auto& child : _widgetChildren) { if (child) { Node::removeChild(child); } } _widgetChildren.clear(); } void Widget::setEnabled(bool enabled) { _enabled = enabled; for (auto& child : _widgetChildren) { if (child) { static_cast(child)->setEnabled(enabled); } } } Widget* Widget::getChildByName(const char *name) { for (auto& child : _widgetChildren) { if (child) { Widget* widgetChild = static_cast(child); if (strcmp(widgetChild->getName(), name) == 0) { return widgetChild; } } } return nullptr; } void Widget::addNode(Node* node) { addNode(node, node->getLocalZOrder(), node->getTag()); } void Widget::addNode(Node * node, int zOrder) { addNode(node, zOrder, node->getTag()); } void Widget::addNode(Node* node, int zOrder, int tag) { CCAssert(dynamic_cast(node) == nullptr, "Widget only supports Nodes as renderer"); Node::addChild(node, zOrder, tag); _nodes.pushBack(node); } Node* Widget::getNodeByTag(int tag) { CCAssert( tag != Node::INVALID_TAG, "Invalid tag"); for (auto& node : _nodes) { if(node && node->getTag() == tag) return node; } return nullptr; } Vector& Widget::getNodes() { return _nodes; } void Widget::removeNode(Node* node) { Node::removeChild(node); _nodes.eraseObject(node); } void Widget::removeNodeByTag(int tag) { CCAssert( tag != Node::INVALID_TAG, "Invalid tag"); Node *node = this->getNodeByTag(tag); if (node == nullptr) { CCLOG("cocos2d: removeNodeByTag(tag = %d): child not found!", tag); } else { this->removeNode(node); } } void Widget::removeAllNodes() { for (auto& node : _nodes) { if (node) { Node::removeChild(node); } } _nodes.clear(); } void Widget::initRenderer() { } void Widget::setSize(const Size &size) { _customSize = size; if (_ignoreSize) { _size = getContentSize(); } else { _size = size; } if (_running) { Widget* widgetParent = getWidgetParent(); Size pSize; if (widgetParent) { pSize = widgetParent->getSize(); } else { pSize = _parent->getContentSize(); } float spx = 0.0f; float spy = 0.0f; if (pSize.width > 0.0f) { spx = _customSize.width / pSize.width; } if (pSize.height > 0.0f) { spy = _customSize.height / pSize.height; } _sizePercent = Point(spx, spy); } onSizeChanged(); } void Widget::setSizePercent(const Point &percent) { _sizePercent = percent; Size cSize = _customSize; if (_running) { Widget* widgetParent = getWidgetParent(); if (widgetParent) { cSize = Size(widgetParent->getSize().width * percent.x , widgetParent->getSize().height * percent.y); } else { cSize = Size(_parent->getContentSize().width * percent.x , _parent->getContentSize().height * percent.y); } } if (_ignoreSize) { _size = getContentSize(); } else { _size = cSize; } _customSize = cSize; onSizeChanged(); } void Widget::updateSizeAndPosition() { switch (_sizeType) { case SIZE_ABSOLUTE: { if (_ignoreSize) { _size = getContentSize(); } else { _size = _customSize; } Widget* widgetParent = getWidgetParent(); if (widgetParent) { Size pSize = widgetParent->getSize(); float spx = 0.0f; float spy = 0.0f; if (pSize.width > 0.0f) { spx = _customSize.width / pSize.width; } if (pSize.height > 0.0f) { spy = _customSize.height / pSize.height; } _sizePercent = Point(spx, spy); } else { Size pSize = _parent->getContentSize(); float spx = 0.0f; float spy = 0.0f; if (pSize.width > 0.0f) { spx = _customSize.width / pSize.width; } if (pSize.height > 0.0f) { spy = _customSize.height / pSize.height; } _sizePercent = Point(spx, spy); } break; } case SIZE_PERCENT: { Widget* widgetParent = getWidgetParent(); if (widgetParent) { Size cSize = Size(widgetParent->getSize().width * _sizePercent.x , widgetParent->getSize().height * _sizePercent.y); if (_ignoreSize) { _size = getContentSize(); } else { _size = cSize; } _customSize = cSize; } else { Size cSize = Size(_parent->getContentSize().width * _sizePercent.x , _parent->getContentSize().height * _sizePercent.y); if (_ignoreSize) { _size = getContentSize(); } else { _size = cSize; } _customSize = cSize; } } break; default: break; } onSizeChanged(); Point absPos = getPosition(); switch (_positionType) { case POSITION_ABSOLUTE: { Widget* widgetParent = getWidgetParent(); if (widgetParent) { Size pSize = widgetParent->getSize(); if (pSize.width <= 0.0f || pSize.height <= 0.0f) { _positionPercent = Point::ZERO; } else { _positionPercent = Point(absPos.x / pSize.width, absPos.y / pSize.height); } } else { Size pSize = _parent->getContentSize(); if (pSize.width <= 0.0f || pSize.height <= 0.0f) { _positionPercent = Point::ZERO; } else { _positionPercent = Point(absPos.x / pSize.width, absPos.y / pSize.height); } } break; } case POSITION_PERCENT: { Widget* widgetParent = getWidgetParent(); if (widgetParent) { Size parentSize = widgetParent->getSize(); absPos = Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); } else { Size parentSize = _parent->getContentSize(); absPos = Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); } break; } default: break; } setPosition(absPos); } void Widget::setSizeType(SizeType type) { _sizeType = type; } SizeType Widget::getSizeType() const { return _sizeType; } void Widget::ignoreContentAdaptWithSize(bool ignore) { _ignoreSize = ignore; if (_ignoreSize) { Size s = getContentSize(); _size = s; } else { _size = _customSize; } onSizeChanged(); } bool Widget::isIgnoreContentAdaptWithSize() const { return _ignoreSize; } const Size& Widget::getSize() const { return _size; } const Point& Widget::getSizePercent() const { return _sizePercent; } Point Widget::getWorldPosition() { return convertToWorldSpace(Point::ZERO); } Node* Widget::getVirtualRenderer() { return this; } void Widget::onSizeChanged() { for (auto& child : getChildren()) { if (child) { static_cast(child)->updateSizeAndPosition(); } } } const Size& Widget::getContentSize() const { return _size; } void Widget::setTouchEnabled(bool enable) { if (enable == _touchEnabled) { return; } _touchEnabled = enable; if (_touchEnabled) { _touchListener = EventListenerTouchOneByOne::create(); CC_SAFE_RETAIN(_touchListener); _touchListener->setSwallowTouches(true); _touchListener->onTouchBegan = CC_CALLBACK_2(Widget::onTouchBegan, this); _touchListener->onTouchMoved = CC_CALLBACK_2(Widget::onTouchMoved, this); _touchListener->onTouchEnded = CC_CALLBACK_2(Widget::onTouchEnded, this); _touchListener->onTouchCancelled = CC_CALLBACK_2(Widget::onTouchCancelled, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(_touchListener, this); } else { _eventDispatcher->removeEventListener(_touchListener); CC_SAFE_RELEASE_NULL(_touchListener); } } bool Widget::isTouchEnabled() const { return _touchEnabled; } bool Widget::isFocused() const { return _focus; } void Widget::setFocused(bool fucos) { if (fucos == _focus) { return; } _focus = fucos; if (_bright) { if (_focus) { setBrightStyle(BRIGHT_HIGHLIGHT); } else { setBrightStyle(BRIGHT_NORMAL); } } else { onPressStateChangedToDisabled(); } } void Widget::setBright(bool bright) { _bright = bright; if (_bright) { _brightStyle = BRIGHT_NONE; setBrightStyle(BRIGHT_NORMAL); } else { onPressStateChangedToDisabled(); } } void Widget::setBrightStyle(BrightStyle style) { if (_brightStyle == style) { return; } _brightStyle = style; switch (_brightStyle) { case BRIGHT_NORMAL: onPressStateChangedToNormal(); break; case BRIGHT_HIGHLIGHT: onPressStateChangedToPressed(); break; default: break; } } void Widget::onPressStateChangedToNormal() { } void Widget::onPressStateChangedToPressed() { } void Widget::onPressStateChangedToDisabled() { } void Widget::didNotSelectSelf() { } bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent) { _hitted = false; if (isEnabled() && isTouchEnabled()) { _touchStartPos = touch->getLocation(); if(hitTest(_touchStartPos) && clippingParentAreaContainPoint(_touchStartPos)) { _hitted = true; } } if (!_hitted) { return false; } setFocused(true); Widget* widgetParent = getWidgetParent(); if (widgetParent) { widgetParent->checkChildInfo(0,this,_touchStartPos); } pushDownEvent(); return !_touchPassedEnabled; } void Widget::onTouchMoved(Touch *touch, Event *unusedEvent) { _touchMovePos = touch->getLocation(); setFocused(hitTest(_touchMovePos)); Widget* widgetParent = getWidgetParent(); if (widgetParent) { widgetParent->checkChildInfo(1,this,_touchMovePos); } moveEvent(); } void Widget::onTouchEnded(Touch *touch, Event *unusedEvent) { _touchEndPos = touch->getLocation(); bool focus = _focus; setFocused(false); Widget* widgetParent = getWidgetParent(); if (widgetParent) { widgetParent->checkChildInfo(2,this,_touchEndPos); } if (focus) { releaseUpEvent(); } else { cancelUpEvent(); } } void Widget::onTouchCancelled(Touch *touch, Event *unusedEvent) { setFocused(false); cancelUpEvent(); } void Widget::pushDownEvent() { if (_touchEventListener && _touchEventSelector) { (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_BEGAN); } } void Widget::moveEvent() { if (_touchEventListener && _touchEventSelector) { (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_MOVED); } } void Widget::releaseUpEvent() { if (_touchEventListener && _touchEventSelector) { (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_ENDED); } } void Widget::cancelUpEvent() { if (_touchEventListener && _touchEventSelector) { (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_CANCELED); } } void Widget::addTouchEventListener(Object *target, SEL_TouchEvent selector) { _touchEventListener = target; _touchEventSelector = selector; } bool Widget::hitTest(const Point &pt) { Point nsp = convertToNodeSpace(pt); Rect bb = Rect(-_size.width * _anchorPoint.x, -_size.height * _anchorPoint.y, _size.width, _size.height); if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height) { return true; } return false; } bool Widget::clippingParentAreaContainPoint(const Point &pt) { _affectByClipping = false; Widget* parent = getWidgetParent(); Widget* clippingParent = nullptr; while (parent) { Layout* layoutParent = dynamic_cast(parent); if (layoutParent) { if (layoutParent->isClippingEnabled()) { _affectByClipping = true; clippingParent = layoutParent; break; } } parent = parent->getWidgetParent(); } if (!_affectByClipping) { return true; } if (clippingParent) { bool bRet = false; if (clippingParent->hitTest(pt)) { bRet = true; } if (bRet) { return clippingParent->clippingParentAreaContainPoint(pt); } return false; } return true; } void Widget::checkChildInfo(int handleState, Widget *sender, const Point &touchPoint) { Widget* widgetParent = getWidgetParent(); if (widgetParent) { widgetParent->checkChildInfo(handleState,sender,touchPoint); } } void Widget::setPosition(const Point &pos) { if (_running) { Widget* widgetParent = getWidgetParent(); if (widgetParent) { Size pSize = widgetParent->getSize(); if (pSize.width <= 0.0f || pSize.height <= 0.0f) { _positionPercent = Point::ZERO; } else { _positionPercent = Point(pos.x / pSize.width, pos.y / pSize.height); } } } Node::setPosition(pos); } void Widget::setPositionPercent(const Point &percent) { _positionPercent = percent; if (_running) { Widget* widgetParent = getWidgetParent(); if (widgetParent) { Size parentSize = widgetParent->getSize(); Point absPos = Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); setPosition(absPos); } } } void Widget::updateAnchorPoint() { setAnchorPoint(getAnchorPoint()); } const Point& Widget::getPositionPercent() { return _positionPercent; } void Widget::setPositionType(PositionType type) { _positionType = type; } PositionType Widget::getPositionType() const { return _positionType; } bool Widget::isBright() const { return _bright; } bool Widget::isEnabled() const { return _enabled; } float Widget::getLeftInParent() { return getPosition().x - getAnchorPoint().x * _size.width;; } float Widget::getBottomInParent() { return getPosition().y - getAnchorPoint().y * _size.height;; } float Widget::getRightInParent() { return getLeftInParent() + _size.width; } float Widget::getTopInParent() { return getBottomInParent() + _size.height; } const Point& Widget::getTouchStartPos() { return _touchStartPos; } const Point& Widget::getTouchMovePos() { return _touchMovePos; } const Point& Widget::getTouchEndPos() { return _touchEndPos; } void Widget::setName(const char* name) { _name = name; } const char* Widget::getName() const { return _name.c_str(); } WidgetType Widget::getWidgetType() const { return _widgetType; } void Widget::setLayoutParameter(LayoutParameter *parameter) { if (!parameter) { return; } _layoutParameterDictionary.insert(parameter->getLayoutType(), parameter); } LayoutParameter* Widget::getLayoutParameter(LayoutParameterType type) { return dynamic_cast(_layoutParameterDictionary.at(type)); } std::string Widget::getDescription() const { return "Widget"; } Widget* Widget::clone() { Widget* clonedWidget = createCloneInstance(); clonedWidget->copyProperties(this); clonedWidget->copyClonedWidgetChildren(this); return clonedWidget; } Widget* Widget::createCloneInstance() { return Widget::create(); } void Widget::copyClonedWidgetChildren(Widget* model) { auto& modelChildren = model->getChildren(); for (auto& subWidget : modelChildren) { Widget* child = static_cast(subWidget); addChild(child->clone()); } } void Widget::copySpecialProperties(Widget* model) { } void Widget::copyProperties(Widget *widget) { setEnabled(widget->isEnabled()); setVisible(widget->isVisible()); setBright(widget->isBright()); setTouchEnabled(widget->isTouchEnabled()); _touchPassedEnabled = false; setLocalZOrder(widget->getLocalZOrder()); setTag(widget->getTag()); setName(widget->getName()); setActionTag(widget->getActionTag()); _ignoreSize = widget->_ignoreSize; _size = widget->_size; _customSize = widget->_customSize; copySpecialProperties(widget); _sizeType = widget->getSizeType(); _sizePercent = widget->_sizePercent; _positionType = widget->_positionType; _positionPercent = widget->_positionPercent; setPosition(widget->getPosition()); setAnchorPoint(widget->getAnchorPoint()); setScaleX(widget->getScaleX()); setScaleY(widget->getScaleY()); setRotation(widget->getRotation()); setRotationX(widget->getRotationX()); setRotationY(widget->getRotationY()); setFlipX(widget->isFlipX()); setFlipY(widget->isFlipY()); setColor(widget->getColor()); setOpacity(widget->getOpacity()); setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled()); setCascadeColorEnabled(widget->isCascadeColorEnabled()); onSizeChanged(); } /*temp action*/ void Widget::setActionTag(int tag) { _actionTag = tag; } int Widget::getActionTag() { return _actionTag; } } NS_CC_END ================================================ FILE: cocos2d/cocos/gui/UIWidget.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __UIWIDGET_H__ #define __UIWIDGET_H__ #include "cocos2d.h" #include "gui/UILayoutDefine.h" #include "gui/UILayoutParameter.h" NS_CC_BEGIN namespace gui { typedef enum { BRIGHT_NONE = -1, BRIGHT_NORMAL, BRIGHT_HIGHLIGHT }BrightStyle; typedef enum { WidgetTypeWidget, //control WidgetTypeContainer //container }WidgetType; typedef enum { UI_TEX_TYPE_LOCAL, UI_TEX_TYPE_PLIST }TextureResType; typedef enum { TOUCH_EVENT_BEGAN, TOUCH_EVENT_MOVED, TOUCH_EVENT_ENDED, TOUCH_EVENT_CANCELED }TouchEventType; typedef enum { SIZE_ABSOLUTE, SIZE_PERCENT }SizeType; typedef enum { POSITION_ABSOLUTE, POSITION_PERCENT }PositionType; typedef void (Object::*SEL_TouchEvent)(Object*,TouchEventType); #define toucheventselector(_SELECTOR) (SEL_TouchEvent)(&_SELECTOR) /** * @js NA * @lua NA */ class Widget : public Node { public: /** * Default constructor */ Widget(void); /** * Default destructor */ virtual ~Widget(); /** * Allocates and initializes a widget. */ static Widget* create(); /** * Sets whether the widget is enabled * * Highest control of widget. * The default value is true, a widget is default to enabled * * @param enabled true if the widget is enabled, widget may be touched and visible, false if the widget is disabled, widget cannot be touched and hidden. */ virtual void setEnabled(bool enabled); /** * Determines if the widget is enabled * * @return true if the widget is enabled, false if the widget is disabled. */ bool isEnabled() const; /** * Sets whether the widget is bright * * The default value is true, a widget is default to bright * * @param visible true if the widget is bright, false if the widget is dark. */ void setBright(bool bright); /** * Determines if the widget is bright * * @return true if the widget is bright, false if the widget is dark. */ bool isBright() const; /** * Sets whether the widget is touch enabled * * The default value is false, a widget is default to touch disabled * * @param visible true if the widget is touch enabled, false if the widget is touch disabled. */ virtual void setTouchEnabled(bool enabled); /** * To set the bright style of widget. * * @see BrightStyle * * @param style BRIGHT_NORMAL the widget is normal state, BRIGHT_HIGHLIGHT the widget is height light state. */ void setBrightStyle(BrightStyle style); /** * Determines if the widget is touch enabled * * @return true if the widget is touch enabled, false if the widget is touch disabled. */ bool isTouchEnabled() const; /** * Determines if the widget is on focused * * @return true if the widget is on focused, false if the widget is not on focused. */ bool isFocused() const; /** * Sets whether the widget is on focused * * The default value is false, a widget is default to not on focused * * @param fucosed true if the widget is on focused, false if the widget is not on focused. */ void setFocused(bool fucosed); /** * Gets the left boundary position of this widget. * * @return The left boundary position of this widget. */ float getLeftInParent(); /** * Gets the bottom boundary position of this widget. * * @return The bottom boundary position of this widget. */ float getBottomInParent(); /** * Gets the right boundary position of this widget. * * @return The right boundary position of this widget. */ float getRightInParent(); /** * Gets the top boundary position of this widget. * * @return The top boundary position of this widget. */ float getTopInParent(); /** * Adds a child to the container with z-order as 0. * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node */ virtual void addChild(Node * child) override; /** * Adds a child to the container with a z-order * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) */ virtual void addChild(Node * child, int zOrder) override; /** * Adds a child to the container with z order and tag * * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) * @param tag A interger to identify the node easily. Please refer to setTag(int) */ virtual void addChild(Node* child, int zOrder, int tag) override; /** * Gets a child from the container with its tag * * @param tag An identifier to find the child node. * * @return a Node object whose tag equals to the input parameter */ virtual Node * getChildByTag(int tag) override; virtual void sortAllChildren() override; /** * Return an array of children * * Composing a "tree" structure is a very important feature of Node * Here's a sample code of traversing children array: @code Node* node = NULL; CCARRAY_FOREACH(parent->getChildren(), node) { node->setPosition(0,0); } @endcode * This sample code traverses all children nodes, and set their position to (0,0) * * @return An array of children */ virtual Vector& getChildren() override; virtual const Vector& getChildren() const override; /** * Get the amount of children. * * @return The amount of children. */ virtual ssize_t getChildrenCount() const override; /** * Removes this node itself from its parent node with a cleanup. * If the node orphan, then nothing happens. * @see `removeFromParentAndCleanup(bool)` */ virtual void removeFromParent() override; /** * Removes this node itself from its parent node. * If the node orphan, then nothing happens. * @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. * @js removeFromParent * @lua removeFromParent */ virtual void removeFromParentAndCleanup(bool cleanup) override; /** * Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. * * @param child The child node which will be removed. * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ virtual void removeChild(Node* child, bool cleanup = true) override; /** * Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter * * @param tag An interger number that identifies a child node * @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. */ virtual void removeChildByTag(int tag, bool cleanup = true) override; /** * Removes all children from the container with a cleanup. * * @see `removeAllChildrenWithCleanup(bool)` */ virtual void removeAllChildren() override; /** * Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter. * * @param cleanup true if all running actions on all children nodes should be cleanup, false oterwise. * @js removeAllChildren * @lua removeAllChildren */ virtual void removeAllChildrenWithCleanup(bool cleanup) override; /** * Gets a child from the container with its name * * @param name An key to find the child widget. * * @return a Widget object whose name equals to the input parameter */ virtual Widget* getChildByName(const char* name); virtual void addNode(Node* node); virtual void addNode(Node * node, int zOrder); virtual void addNode(Node* node, int zOrder, int tag); virtual Node * getNodeByTag(int tag); virtual Vector& getNodes(); virtual void removeNode(Node* node); virtual void removeNodeByTag(int tag); virtual void removeAllNodes(); virtual void visit() override; /** * Sets the touch event target/selector of the menu item */ void addTouchEventListener(Object* target,SEL_TouchEvent selector); //cocos2d property /** * Changes the position (x,y) of the widget in OpenGL coordinates * * Usually we use p(x,y) to compose Point object. * The original point (0,0) is at the left-bottom corner of screen. * * @param position The position (x,y) of the widget in OpenGL coordinates */ virtual void setPosition(const Point &pos) override; /** * Changes the position (x,y) of the widget in OpenGL coordinates * * Usually we use p(x,y) to compose Point object. * The original point (0,0) is at the left-bottom corner of screen. * * @param percent The percent (x,y) of the widget in OpenGL coordinates */ void setPositionPercent(const Point &percent); /** * Gets the percent (x,y) of the widget in OpenGL coordinates * * @see setPosition(const Point&) * * @return The percent (x,y) of the widget in OpenGL coordinates */ const Point& getPositionPercent(); /** * Changes the position type of the widget * * @see PositionType * * @param type the position type of widget */ void setPositionType(PositionType type); /** * Gets the position type of the widget * * @see PositionType * * @return type the position type of widget */ PositionType getPositionType() const; /** * Sets whether the widget should be flipped horizontally or not. * * @param bFlipX true if the widget should be flipped horizaontally, false otherwise. */ virtual void setFlipX(bool flipX){}; /** * Returns the flag which indicates whether the widget is flipped horizontally or not. * * It only flips the texture of the widget, and not the texture of the widget's children. * Also, flipping the texture doesn't alter the anchorPoint. * If you want to flip the anchorPoint too, and/or to flip the children too use: * widget->setScaleX(sprite->getScaleX() * -1); * * @return true if the widget is flipped horizaontally, false otherwise. */ virtual bool isFlipX(){return false;}; /** * Sets whether the widget should be flipped vertically or not. * * @param bFlipY true if the widget should be flipped vertically, flase otherwise. */ virtual void setFlipY(bool flipY){}; /** * Return the flag which indicates whether the widget is flipped vertically or not. * * It only flips the texture of the widget, and not the texture of the widget's children. * Also, flipping the texture doesn't alter the anchorPoint. * If you want to flip the anchorPoint too, and/or to flip the children too use: * widget->setScaleY(widget->getScaleY() * -1); * * @return true if the widget is flipped vertically, flase otherwise. */ virtual bool isFlipY(){return false;}; /** * A call back function when widget lost of focus. */ void didNotSelectSelf(); /* * Checks a point if in parent's area. * * @param point * * @return true if the point is in parent's area, flase otherwise. */ bool clippingParentAreaContainPoint(const Point &pt); /* * Sends the touch event to widget's parent */ virtual void checkChildInfo(int handleState,Widget* sender,const Point &touchPoint); /* * Gets the touch began point of widget when widget is selected. * * @return the touch began point. */ const Point& getTouchStartPos(); /* * Gets the touch move point of widget when widget is selected. * * @return the touch move point. */ const Point& getTouchMovePos(); /* * Gets the touch end point of widget when widget is selected. * * @return the touch end point. */ const Point& getTouchEndPos(); /** * Changes the name that is used to identify the widget easily. * * @param A const char* that indentifies the widget. */ void setName(const char* name); /** * Returns a name that is used to identify the widget easily. * * You can set tags to widget then identify them easily. * * @return A const char* that identifies the widget. */ const char* getName() const; /** * Returns a type that is widget's type * * @see WidgetType * * @return A WidgetType */ WidgetType getWidgetType() const; /** * Changes the size that is widget's size * * @param size that is widget's size */ virtual void setSize(const Size &size); /** * Changes the percent that is widget's percent size * * @param percent that is widget's percent size */ virtual void setSizePercent(const Point &percent); /** * Changes the size type of widget. * * @see SizeType * * @param type that is widget's size type */ void setSizeType(SizeType type); /** * Gets the size type of widget. * * @see SizeType * * @param type that is widget's size type */ SizeType getSizeType() const; /** * Returns size of widget * * @return size */ const Size& getSize() const; /** * Returns size percent of widget * * @return size percent */ const Point& getSizePercent() const; /** * Checks a point if is in widget's space * * @param point * * @return true if the point is in widget's space, flase otherwise. */ virtual bool hitTest(const Point &pt); virtual bool onTouchBegan(Touch *touch, Event *unusedEvent); virtual void onTouchMoved(Touch *touch, Event *unusedEvent); virtual void onTouchEnded(Touch *touch, Event *unusedEvent); virtual void onTouchCancelled(Touch *touch, Event *unusedEvent); /** * Sets a LayoutParameter to widget. * * @see LayoutParameter * * @param LayoutParameter pointer * * @param type Relative or Linear */ void setLayoutParameter(LayoutParameter* parameter); /** * Gets LayoutParameter of widget. * * @see LayoutParameter * * @param type Relative or Linear * * @return LayoutParameter */ LayoutParameter* getLayoutParameter(LayoutParameterType type); /** * Ignore the widget size * * @param ignore, true that widget will ignore it's size, use texture size, false otherwise. Default value is true. */ virtual void ignoreContentAdaptWithSize(bool ignore); /** * Gets the widget if is ignore it's size. * * @param ignore, true that widget will ignore it's size, use texture size, false otherwise. Default value is true. */ bool isIgnoreContentAdaptWithSize() const; /** * Gets world position of widget. * * @return world position of widget. */ Point getWorldPosition(); /** * Gets the Virtual Renderer of widget. * * For example, a button's Virtual Renderer is it's texture renderer. * * @return Node pointer. */ virtual Node* getVirtualRenderer(); /** * Gets the content size of widget. * * Content size is widget's texture size. */ virtual const Size& getContentSize() const; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; Widget* clone(); virtual void onEnter() override; virtual void onExit() override; void updateSizeAndPosition(); /*temp action*/ void setActionTag(int tag); int getActionTag(); protected: //call back function called when size changed. virtual void onSizeChanged(); //initializes state of widget. virtual bool init(); //initializes renderer of widget. virtual void initRenderer(); //call back function called widget's state changed to normal. virtual void onPressStateChangedToNormal(); //call back function called widget's state changed to selected. virtual void onPressStateChangedToPressed(); //call back function called widget's state changed to dark. virtual void onPressStateChangedToDisabled(); void pushDownEvent(); void moveEvent(); void releaseUpEvent(); void cancelUpEvent(); void updateAnchorPoint(); void copyProperties(Widget* model); virtual Widget* createCloneInstance(); virtual void copySpecialProperties(Widget* model); virtual void copyClonedWidgetChildren(Widget* model); Widget* getWidgetParent(); protected: bool _enabled; ///< Highest control of widget bool _bright; ///< is this widget bright bool _touchEnabled; ///< is this widget touch endabled bool _touchPassedEnabled; ///< is the touch event should be passed bool _focus; ///< is the widget on focus BrightStyle _brightStyle; ///< bright style Point _touchStartPos; ///< touch began point Point _touchMovePos; ///< touch moved point Point _touchEndPos; ///< touch ended point Object* _touchEventListener; SEL_TouchEvent _touchEventSelector; std::string _name; WidgetType _widgetType; int _actionTag; Size _size; Size _customSize; bool _ignoreSize; bool _affectByClipping; SizeType _sizeType; Point _sizePercent; PositionType _positionType; Point _positionPercent; bool _reorderWidgetChildDirty; bool _hitted; EventListenerTouchOneByOne* _touchListener; Map _layoutParameterDictionary; Vector _widgetChildren; Vector _nodes; }; } NS_CC_END #endif /* defined(__Widget__) */ ================================================ FILE: cocos2d/cocos/gui/proj.win32/libGUI.vcxproj ================================================  Debug Win32 Release Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A} libGUI StaticLibrary true v100 v110 v110_xp Unicode StaticLibrary false v100 v110 v110_xp true Unicode $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true 4267;4251;4244;%(DisableSpecificWarnings) false OldStyle true Level3 MaxSpeed true true WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) true true true ================================================ FILE: cocos2d/cocos/gui/proj.win32/libGUI.vcxproj.filters ================================================  {e31ab7d3-b8b2-467f-9e08-fd5fe168b491} {f9d13563-9e5e-4b35-b0e7-d41f587efa42} {ed8a2ae0-5690-4d0d-829b-7c07164c0597} {5f6e9e52-fbe7-4073-ac71-98632f9e6781} {b59b178a-b7e0-4826-ba07-44c46cd29a10} UIWidgets\ScrollWidget UIWidgets\ScrollWidget UIWidgets\ScrollWidget UIWidgets\ScrollWidget UIWidgets UIWidgets UIWidgets UIWidgets UIWidgets UIWidgets System System Layouts BaseClasses Layouts Layouts UIWidgets UIWidgets UIWidgets UIWidgets\ScrollWidget UIWidgets\ScrollWidget UIWidgets\ScrollWidget UIWidgets UIWidgets UIWidgets UIWidgets UIWidgets UIWidgets System System Layouts BaseClasses Layouts Layouts UIWidgets UIWidgets UIWidgets ================================================ FILE: cocos2d/cocos/math/kazmath/CMakeLists.txt ================================================ SET(KAZMATH_SOURCES mat4.c mat3.c plane.c vec4.c quaternion.c vec2.c vec3.c utility.c aabb.c ray2.c GL/mat4stack.c GL/matrix.c ) ADD_SUBDIRECTORY(src) set_target_properties(kazmath PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/GL/mat4stack.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 C_STACK_H_INCLUDED #define C_STACK_H_INCLUDED #include "../mat4.h" typedef struct km_mat4_stack { int capacity; //The total item capacity int item_count; //The number of items kmMat4* top; kmMat4* stack; } km_mat4_stack; #ifdef __cplusplus extern "C" { #endif void km_mat4_stack_initialize(km_mat4_stack* stack); void km_mat4_stack_push(km_mat4_stack* stack, const kmMat4* item); void km_mat4_stack_pop(km_mat4_stack* stack, kmMat4* pOut); void km_mat4_stack_release(km_mat4_stack* stack); #ifdef __cplusplus } #endif #endif // C_STACK_H_INCLUDED ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/GL/matrix.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 KM_GL_MATRIX_H_INCLUDED #define KM_GL_MATRIX_H_INCLUDED #include "CCPlatformMacros.h" #define KM_GL_MODELVIEW 0x1700 #define KM_GL_PROJECTION 0x1701 #define KM_GL_TEXTURE 0x1702 typedef unsigned int kmGLEnum; #include "../mat4.h" #include "../vec3.h" #ifdef __cplusplus extern "C" { #endif void CC_DLL kmGLFreeAll(void); void CC_DLL kmGLPushMatrix(void); void CC_DLL kmGLPopMatrix(void); void CC_DLL kmGLMatrixMode(kmGLEnum mode); void CC_DLL kmGLLoadIdentity(void); void CC_DLL kmGLLoadMatrix(const kmMat4* pIn); void CC_DLL kmGLMultMatrix(const kmMat4* pIn); void CC_DLL kmGLTranslatef(float x, float y, float z); void CC_DLL kmGLRotatef(float angle, float x, float y, float z); void CC_DLL kmGLScalef(float x, float y, float z); void CC_DLL kmGLGetMatrix(kmGLEnum mode, kmMat4* pOut); #ifdef __cplusplus } #endif #endif // MATRIX_H_INCLUDED ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/aabb.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 KAZMATH_AABB_H_INCLUDED #define KAZMATH_AABB_H_INCLUDED #include "CCPlatformMacros.h" #include "vec3.h" #include "utility.h" #ifdef __cplusplus extern "C" { #endif /** * A structure that represents an axis-aligned * bounding box. */ typedef struct kmAABB { kmVec3 min; /** The max corner of the box */ kmVec3 max; /** The min corner of the box */ } kmAABB; CC_DLL const int kmAABBContainsPoint(const kmVec3* pPoint, const kmAABB* pBox); CC_DLL kmAABB* const kmAABBAssign(kmAABB* pOut, const kmAABB* pIn); CC_DLL kmAABB* const kmAABBScale(kmAABB* pOut, const kmAABB* pIn, kmScalar s); #ifdef __cplusplus } #endif #endif ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/kazmath.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 KAZMATH_H_INCLUDED #define KAZMATH_H_INCLUDED #include "vec2.h" #include "vec3.h" #include "mat3.h" #include "mat4.h" #include "utility.h" #include "quaternion.h" #include "plane.h" #include "aabb.h" #include "ray2.h" #endif // KAZMATH_H_INCLUDED ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/mat3.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 MAT3_H_INCLUDED #define MAT3_H_INCLUDED #include "CCPlatformMacros.h" #include "utility.h" struct kmVec3; struct kmQuaternion; typedef struct kmMat3{ kmScalar mat[9]; } kmMat3; #ifdef __cplusplus extern "C" { #endif CC_DLL kmMat3* const kmMat3Fill(kmMat3* pOut, const kmScalar* pMat); CC_DLL kmMat3* const kmMat3Adjugate(kmMat3* pOut, const kmMat3* pIn); CC_DLL kmMat3* const kmMat3Identity(kmMat3* pOut); CC_DLL kmMat3* const kmMat3Inverse(kmMat3* pOut, const kmScalar pDeterminate, const kmMat3* pM); CC_DLL const int kmMat3IsIdentity(const kmMat3* pIn); CC_DLL kmMat3* const kmMat3Transpose(kmMat3* pOut, const kmMat3* pIn); CC_DLL const kmScalar kmMat3Determinant(const kmMat3* pIn); CC_DLL kmMat3* const kmMat3Multiply(kmMat3* pOut, const kmMat3* pM1, const kmMat3* pM2); CC_DLL kmMat3* const kmMat3ScalarMultiply(kmMat3* pOut, const kmMat3* pM, const kmScalar pFactor); CC_DLL kmMat3* const kmMat3RotationAxisAngle(kmMat3* pOut, const struct kmVec3* axis, kmScalar radians); CC_DLL struct kmVec3* const kmMat3RotationToAxisAngle(struct kmVec3* pAxis, kmScalar* radians, const kmMat3* pIn); CC_DLL kmMat3* const kmMat3Assign(kmMat3* pOut, const kmMat3* pIn); CC_DLL const int kmMat3AreEqual(const kmMat3* pM1, const kmMat3* pM2); CC_DLL kmMat3* const kmMat3RotationX(kmMat3* pOut, const kmScalar radians); CC_DLL kmMat3* const kmMat3RotationY(kmMat3* pOut, const kmScalar radians); CC_DLL kmMat3* const kmMat3RotationZ(kmMat3* pOut, const kmScalar radians); CC_DLL kmMat3* const kmMat3Rotation(kmMat3* pOut, const kmScalar radians); CC_DLL kmMat3* const kmMat3Scaling(kmMat3* pOut, const kmScalar x, const kmScalar y); CC_DLL kmMat3* const kmMat3Translation(kmMat3* pOut, const kmScalar x, const kmScalar y); CC_DLL kmMat3* const kmMat3RotationQuaternion(kmMat3* pOut, const struct kmQuaternion* pIn); CC_DLL kmMat3* const kmMat3RotationAxisAngle(kmMat3* pOut, const struct kmVec3* axis, kmScalar radians); CC_DLL struct kmVec3* const kmMat3RotationToAxisAngle(struct kmVec3* pAxis, kmScalar* radians, const kmMat3* pIn); #ifdef __cplusplus } #endif #endif // MAT3_H_INCLUDED ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/mat4.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 MAT4_H_INCLUDED #define MAT4_H_INCLUDED #include "CCPlatformMacros.h" #include "utility.h" struct kmVec3; struct kmMat3; struct kmQuaternion; struct kmPlane; /* A 4x4 matrix | 0 4 8 12 | mat = | 1 5 9 13 | | 2 6 10 14 | | 3 7 11 15 | */ #ifdef __cplusplus extern "C" { #endif typedef struct kmMat4 { kmScalar mat[16]; } kmMat4; CC_DLL kmMat4* const kmMat4Fill(kmMat4* pOut, const kmScalar* pMat); CC_DLL kmMat4* const kmMat4Identity(kmMat4* pOut); CC_DLL kmMat4* const kmMat4Inverse(kmMat4* pOut, const kmMat4* pM); CC_DLL const int kmMat4IsIdentity(const kmMat4* pIn); CC_DLL kmMat4* const kmMat4Transpose(kmMat4* pOut, const kmMat4* pIn); CC_DLL kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2); CC_DLL kmMat4* const kmMat4Assign(kmMat4* pOut, const kmMat4* pIn); CC_DLL const int kmMat4AreEqual(const kmMat4* pM1, const kmMat4* pM2); CC_DLL kmMat4* const kmMat4RotationX(kmMat4* pOut, const kmScalar radians); CC_DLL kmMat4* const kmMat4RotationY(kmMat4* pOut, const kmScalar radians); CC_DLL kmMat4* const kmMat4RotationZ(kmMat4* pOut, const kmScalar radians); CC_DLL kmMat4* const kmMat4RotationPitchYawRoll(kmMat4* pOut, const kmScalar pitch, const kmScalar yaw, const kmScalar roll); CC_DLL kmMat4* const kmMat4RotationQuaternion(kmMat4* pOut, const struct kmQuaternion* pQ); CC_DLL kmMat4* const kmMat4RotationTranslation(kmMat4* pOut, const struct kmMat3* rotation, const struct kmVec3* translation); CC_DLL kmMat4* const kmMat4Scaling(kmMat4* pOut, const kmScalar x, const kmScalar y, const kmScalar z); CC_DLL kmMat4* const kmMat4Translation(kmMat4* pOut, const kmScalar x, const kmScalar y, const kmScalar z); CC_DLL struct kmVec3* const kmMat4GetUpVec3(struct kmVec3* pOut, const kmMat4* pIn); CC_DLL struct kmVec3* const kmMat4GetRightVec3(struct kmVec3* pOut, const kmMat4* pIn); CC_DLL struct kmVec3* const kmMat4GetForwardVec3(struct kmVec3* pOut, const kmMat4* pIn); CC_DLL kmMat4* const kmMat4PerspectiveProjection(kmMat4* pOut, kmScalar fovY, kmScalar aspect, kmScalar zNear, kmScalar zFar); CC_DLL kmMat4* const kmMat4OrthographicProjection(kmMat4* pOut, kmScalar left, kmScalar right, kmScalar bottom, kmScalar top, kmScalar nearVal, kmScalar farVal); CC_DLL kmMat4* const kmMat4LookAt(kmMat4* pOut, const struct kmVec3* pEye, const struct kmVec3* pCenter, const struct kmVec3* pUp); CC_DLL kmMat4* const kmMat4RotationAxisAngle(kmMat4* pOut, const struct kmVec3* axis, kmScalar radians); CC_DLL struct kmMat3* const kmMat4ExtractRotation(struct kmMat3* pOut, const kmMat4* pIn); CC_DLL struct kmPlane* const kmMat4ExtractPlane(struct kmPlane* pOut, const kmMat4* pIn, const kmEnum plane); CC_DLL struct kmVec3* const kmMat4RotationToAxisAngle(struct kmVec3* pAxis, kmScalar* radians, const kmMat4* pIn); #ifdef __cplusplus } #endif #endif /* MAT4_H_INCLUDED */ ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/neon_matrix_impl.h ================================================ /* NEON math library for the iPhone / iPod touch Copyright (c) 2009 Justin Saunders This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef __NEON_MATRIX_IMPL_H__ #define __NEON_MATRIX_IMPL_H__ #ifdef __arm__ #if defined(__QNX__) || defined(CC_TARGET_QT5)|| defined(ANDROID) || defined(I3D_ARCH_ARM) || defined(__native_client__) || defined(TIZEN) // MARMALADE CHANGE: Added for Marmalade support // blackberry and android don't have arm/arch.h but it defines __arm__ #else #include "arm/arch.h" #endif #endif // __arm__ // Matrices are assumed to be stored in column major format according to OpenGL // specification. // Multiplies two 4x4 matrices (a,b) outputting a 4x4 matrix (output) void NEON_Matrix4Mul(const float* a, const float* b, float* output ); // Multiplies a 4x4 matrix (m) with a vector 4 (v), outputting a vector 4 void NEON_Matrix4Vector4Mul(const float* m, const float* v, float* output); #endif // __NEON_MATRIX_IMPL_H__ ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/plane.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 PLANE_H_INCLUDED #define PLANE_H_INCLUDED #define KM_PLANE_LEFT 0 #define KM_PLANE_RIGHT 1 #define KM_PLANE_BOTTOM 2 #define KM_PLANE_TOP 3 #define KM_PLANE_NEAR 4 #define KM_PLANE_FAR 5 #include "CCPlatformMacros.h" #include "utility.h" struct kmVec3; struct kmVec4; struct kmMat4; typedef struct kmPlane { kmScalar a, b, c, d; } kmPlane; #ifdef __cplusplus extern "C" { #endif typedef enum POINT_CLASSIFICATION { POINT_INFRONT_OF_PLANE = 0, POINT_BEHIND_PLANE, POINT_ON_PLANE, } POINT_CLASSIFICATION; CC_DLL const kmScalar kmPlaneDot(const kmPlane* pP, const struct kmVec4* pV); CC_DLL const kmScalar kmPlaneDotCoord(const kmPlane* pP, const struct kmVec3* pV); CC_DLL const kmScalar kmPlaneDotNormal(const kmPlane* pP, const struct kmVec3* pV); CC_DLL kmPlane* const kmPlaneFromPointNormal(kmPlane* pOut, const struct kmVec3* pPoint, const struct kmVec3* pNormal); CC_DLL kmPlane* const kmPlaneFromPoints(kmPlane* pOut, const struct kmVec3* p1, const struct kmVec3* p2, const struct kmVec3* p3); CC_DLL kmVec3* const kmPlaneIntersectLine(struct kmVec3* pOut, const kmPlane* pP, const struct kmVec3* pV1, const struct kmVec3* pV2); CC_DLL kmPlane* const kmPlaneNormalize(kmPlane* pOut, const kmPlane* pP); CC_DLL kmPlane* const kmPlaneScale(kmPlane* pOut, const kmPlane* pP, kmScalar s); CC_DLL const POINT_CLASSIFICATION kmPlaneClassifyPoint(const kmPlane* pIn, const kmVec3* pP); /** Classifies a point against a plane */ #ifdef __cplusplus } #endif #endif // PLANE_H_INCLUDED ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/quaternion.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 QUATERNION_H_INCLUDED #define QUATERNION_H_INCLUDED #ifdef __cplusplus extern "C" { #endif #include "CCPlatformMacros.h" #include "utility.h" struct kmMat4; struct kmMat3; struct kmVec3; typedef struct kmQuaternion { kmScalar x; kmScalar y; kmScalar z; kmScalar w; } kmQuaternion; CC_DLL kmQuaternion* const kmQuaternionConjugate(kmQuaternion* pOut, const kmQuaternion* pIn); ///< Returns pOut, sets pOut to the conjugate of pIn CC_DLL const kmScalar kmQuaternionDot(const kmQuaternion* q1, const kmQuaternion* q2); ///< Returns the dot product of the 2 quaternions CC_DLL kmQuaternion* kmQuaternionExp(kmQuaternion* pOut, const kmQuaternion* pIn); ///< Returns the exponential of the quaternion ///< Makes the passed quaternion an identity quaternion CC_DLL kmQuaternion* kmQuaternionIdentity(kmQuaternion* pOut); ///< Returns the inverse of the passed Quaternion CC_DLL kmQuaternion* kmQuaternionInverse(kmQuaternion* pOut, const kmQuaternion* pIn); ///< Returns true if the quaternion is an identity quaternion CC_DLL int kmQuaternionIsIdentity(const kmQuaternion* pIn); ///< Returns the length of the quaternion CC_DLL kmScalar kmQuaternionLength(const kmQuaternion* pIn); ///< Returns the length of the quaternion squared (prevents a sqrt) CC_DLL kmScalar kmQuaternionLengthSq(const kmQuaternion* pIn); ///< Returns the natural logarithm CC_DLL kmQuaternion* kmQuaternionLn(kmQuaternion* pOut, const kmQuaternion* pIn); ///< Multiplies 2 quaternions together CC_DLL kmQuaternion* kmQuaternionMultiply(kmQuaternion* pOut, const kmQuaternion* q1, const kmQuaternion* q2); ///< Normalizes a quaternion CC_DLL kmQuaternion* kmQuaternionNormalize(kmQuaternion* pOut, const kmQuaternion* pIn); ///< Rotates a quaternion around an axis CC_DLL kmQuaternion* kmQuaternionRotationAxis(kmQuaternion* pOut, const struct kmVec3* pV, kmScalar angle); ///< Creates a quaternion from a rotation matrix CC_DLL kmQuaternion* kmQuaternionRotationMatrix(kmQuaternion* pOut, const struct kmMat3* pIn); ///< Create a quaternion from yaw, pitch and roll CC_DLL kmQuaternion* kmQuaternionRotationYawPitchRoll(kmQuaternion* pOut, kmScalar yaw, kmScalar pitch, kmScalar roll); ///< Interpolate between 2 quaternions CC_DLL kmQuaternion* kmQuaternionSlerp(kmQuaternion* pOut, const kmQuaternion* q1, const kmQuaternion* q2, kmScalar t); ///< Get the axis and angle of rotation from a quaternion CC_DLL void kmQuaternionToAxisAngle(const kmQuaternion* pIn, struct kmVec3* pVector, kmScalar* pAngle); ///< Scale a quaternion CC_DLL kmQuaternion* kmQuaternionScale(kmQuaternion* pOut, const kmQuaternion* pIn, kmScalar s); CC_DLL kmQuaternion* kmQuaternionAssign(kmQuaternion* pOut, const kmQuaternion* pIn); CC_DLL kmQuaternion* kmQuaternionAdd(kmQuaternion* pOut, const kmQuaternion* pQ1, const kmQuaternion* pQ2); CC_DLL kmQuaternion* kmQuaternionRotationBetweenVec3(kmQuaternion* pOut, const struct kmVec3* vec1, const struct kmVec3* vec2, const struct kmVec3* fallback); CC_DLL struct kmVec3* kmQuaternionMultiplyVec3(struct kmVec3* pOut, const kmQuaternion* q, const struct kmVec3* v); #ifdef __cplusplus } #endif #endif ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/ray2.h ================================================ /* Copyright (c) 2011, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 RAY_2_H #define RAY_2_H #include "CCPlatformMacros.h" #include "utility.h" #include "vec2.h" #ifdef __cplusplus extern "C" { #endif typedef struct kmRay2 { kmVec2 start; kmVec2 dir; } kmRay2; CC_DLL void kmRay2Fill(kmRay2* ray, kmScalar px, kmScalar py, kmScalar vx, kmScalar vy); CC_DLL kmBool kmRay2IntersectLineSegment(const kmRay2* ray, const kmVec2* p1, const kmVec2* p2, kmVec2* intersection); CC_DLL kmBool kmRay2IntersectTriangle(const kmRay2* ray, const kmVec2* p1, const kmVec2* p2, const kmVec2* p3, kmVec2* intersection, kmVec2* normal_out); CC_DLL kmBool kmRay2IntersectCircle(const kmRay2* ray, const kmVec2 centre, const kmScalar radius, kmVec2* intersection); #ifdef __cplusplus } #endif #endif ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/utility.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 UTILITY_H_INCLUDED #define UTILITY_H_INCLUDED #include "CCPlatformMacros.h" #include #ifndef kmScalar #define kmScalar float #endif #ifndef kmBool #define kmBool unsigned char #endif #ifndef kmEnum #define kmEnum unsigned int #endif #ifndef KM_FALSE #define KM_FALSE 0 #endif #ifndef KM_TRUE #define KM_TRUE 1 #endif #define kmPI 3.141592f #define kmPIOver180 0.017453f // PI / 180 #define kmPIUnder180 57.295779f // 180 / PI #define kmEpsilon 1.0 / 64.0 #ifdef __cplusplus extern "C" { #endif CC_DLL kmScalar kmSQR(kmScalar s); CC_DLL kmScalar kmDegreesToRadians(kmScalar degrees); CC_DLL kmScalar kmRadiansToDegrees(kmScalar radians); CC_DLL kmScalar kmMin(kmScalar lhs, kmScalar rhs); CC_DLL kmScalar kmMax(kmScalar lhs, kmScalar rhs); CC_DLL kmBool kmAlmostEqual(kmScalar lhs, kmScalar rhs); #ifdef __cplusplus } #endif #endif /* UTILITY_H_INCLUDED */ ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/vec2.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 VEC2_H_INCLUDED #define VEC2_H_INCLUDED #include "CCPlatformMacros.h" struct kmMat3; #ifndef kmScalar #define kmScalar float #endif #pragma pack(push) /* push current alignment to stack */ #pragma pack(1) /* set alignment to 1 byte boundary */ typedef struct kmVec2 { kmScalar x; kmScalar y; } kmVec2; #pragma pack(pop) #ifdef __cplusplus extern "C" { #endif CC_DLL kmVec2* kmVec2Fill(kmVec2* pOut, kmScalar x, kmScalar y); CC_DLL kmScalar kmVec2Length(const kmVec2* pIn); ///< Returns the length of the vector CC_DLL kmScalar kmVec2LengthSq(const kmVec2* pIn); ///< Returns the square of the length of the vector CC_DLL kmVec2* kmVec2Normalize(kmVec2* pOut, const kmVec2* pIn); ///< Returns the vector passed in set to unit length CC_DLL kmVec2* kmVec2Add(kmVec2* pOut, const kmVec2* pV1, const kmVec2* pV2); ///< Adds 2 vectors and returns the result CC_DLL kmScalar kmVec2Dot(const kmVec2* pV1, const kmVec2* pV2); /** Returns the Dot product which is the cosine of the angle between the two vectors multiplied by their lengths */ CC_DLL kmVec2* kmVec2Subtract(kmVec2* pOut, const kmVec2* pV1, const kmVec2* pV2); ///< Subtracts 2 vectors and returns the result CC_DLL kmVec2* kmVec2Transform(kmVec2* pOut, const kmVec2* pV1, const struct kmMat3* pM); /** Transform the Vector */ CC_DLL kmVec2* kmVec2TransformCoord(kmVec2* pOut, const kmVec2* pV, const struct kmMat3* pM); /// #ifndef kmScalar #define kmScalar float #endif struct kmMat4; typedef struct kmVec3 { kmScalar x; kmScalar y; kmScalar z; } kmVec3; #ifdef __cplusplus extern "C" { #endif CC_DLL kmVec3* kmVec3Fill(kmVec3* pOut, kmScalar x, kmScalar y, kmScalar z); CC_DLL kmScalar kmVec3Length(const kmVec3* pIn); /** Returns the length of the vector */ CC_DLL kmScalar kmVec3LengthSq(const kmVec3* pIn); /** Returns the square of the length of the vector */ CC_DLL kmVec3* kmVec3Normalize(kmVec3* pOut, const kmVec3* pIn); /** Returns the vector passed in set to unit length */ CC_DLL kmVec3* kmVec3Cross(kmVec3* pOut, const kmVec3* pV1, const kmVec3* pV2); /** Returns a vector perpendicular to 2 other vectors */ CC_DLL kmScalar kmVec3Dot(const kmVec3* pV1, const kmVec3* pV2); /** Returns the cosine of the angle between 2 vectors */ CC_DLL kmVec3* kmVec3Add(kmVec3* pOut, const kmVec3* pV1, const kmVec3* pV2); /** Adds 2 vectors and returns the result */ CC_DLL kmVec3* kmVec3Subtract(kmVec3* pOut, const kmVec3* pV1, const kmVec3* pV2); /** Subtracts 2 vectors and returns the result */ CC_DLL kmVec3* kmVec3Transform(kmVec3* pOut, const kmVec3* pV1, const struct kmMat4* pM); /** Transforms a vector (assuming w=1) by a given matrix */ CC_DLL kmVec3* kmVec3TransformNormal(kmVec3* pOut, const kmVec3* pV, const struct kmMat4* pM);/**Transforms a 3D normal by a given matrix */ CC_DLL kmVec3* kmVec3TransformCoord(kmVec3* pOut, const kmVec3* pV, const struct kmMat4* pM); /**Transforms a 3D vector by a given matrix, projecting the result back into w = 1. */ CC_DLL kmVec3* kmVec3Scale(kmVec3* pOut, const kmVec3* pIn, const kmScalar s); /** Scales a vector to length s */ CC_DLL int kmVec3AreEqual(const kmVec3* p1, const kmVec3* p2); CC_DLL kmVec3* kmVec3InverseTransform(kmVec3* pOut, const kmVec3* pV, const struct kmMat4* pM); CC_DLL kmVec3* kmVec3InverseTransformNormal(kmVec3* pOut, const kmVec3* pVect, const struct kmMat4* pM); CC_DLL kmVec3* kmVec3Assign(kmVec3* pOut, const kmVec3* pIn); CC_DLL kmVec3* kmVec3Zero(kmVec3* pOut); #ifdef __cplusplus } #endif #endif /* VEC3_H_INCLUDED */ ================================================ FILE: cocos2d/cocos/math/kazmath/include/kazmath/vec4.h ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 VEC4_H_INCLUDED #define VEC4_H_INCLUDED #include "CCPlatformMacros.h" #include "utility.h" struct kmMat4; #pragma pack(push) /* push current alignment to stack */ #pragma pack(1) /* set alignment to 1 byte boundary */ typedef struct kmVec4 { kmScalar x; kmScalar y; kmScalar z; kmScalar w; } kmVec4; #pragma pack(pop) #ifdef __cplusplus extern "C" { #endif CC_DLL kmVec4* kmVec4Fill(kmVec4* pOut, kmScalar x, kmScalar y, kmScalar z, kmScalar w); CC_DLL kmVec4* kmVec4Add(kmVec4* pOut, const kmVec4* pV1, const kmVec4* pV2); CC_DLL kmScalar kmVec4Dot(const kmVec4* pV1, const kmVec4* pV2); CC_DLL kmScalar kmVec4Length(const kmVec4* pIn); CC_DLL kmScalar kmVec4LengthSq(const kmVec4* pIn); CC_DLL kmVec4* kmVec4Lerp(kmVec4* pOut, const kmVec4* pV1, const kmVec4* pV2, kmScalar t); CC_DLL kmVec4* kmVec4Normalize(kmVec4* pOut, const kmVec4* pIn); CC_DLL kmVec4* kmVec4Scale(kmVec4* pOut, const kmVec4* pIn, const kmScalar s); ///< Scales a vector to length s CC_DLL kmVec4* kmVec4Subtract(kmVec4* pOut, const kmVec4* pV1, const kmVec4* pV2); CC_DLL kmVec4* kmVec4Transform(kmVec4* pOut, const kmVec4* pV, const struct kmMat4* pM); CC_DLL kmVec4* kmVec4TransformArray(kmVec4* pOut, unsigned int outStride, const kmVec4* pV, unsigned int vStride, const struct kmMat4* pM, unsigned int count); CC_DLL int kmVec4AreEqual(const kmVec4* p1, const kmVec4* p2); CC_DLL kmVec4* kmVec4Assign(kmVec4* pOut, const kmVec4* pIn); #ifdef __cplusplus } #endif #endif // VEC4_H_INCLUDED ================================================ FILE: cocos2d/cocos/math/kazmath/src/CMakeLists.txt ================================================ #ADD_LIBRARY(Kazmath STATIC ${KAZMATH_SRCS}) #INSTALL(TARGETS Kazmath ARCHIVE DESTINATION lib) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include ) ADD_LIBRARY(kazmath STATIC ${KAZMATH_SOURCES}) INSTALL(TARGETS kazmath ARCHIVE DESTINATION lib) #ADD_LIBRARY(KazmathGL STATIC ${GL_UTILS_SRCS}) #INSTALL(TARGETS KazmathGL ARCHIVE DESTINATION lib) INSTALL(FILES ${KAZMATH_HEADERS} DESTINATION include/kazmath) INSTALL(FILES ${GL_UTILS_HEADERS} DESTINATION include/kazmath/GL) ================================================ FILE: cocos2d/cocos/math/kazmath/src/ChangeLog ================================================ ------------------------------------------------------------ revno: 111 committer: Kazade branch nick: kazmath timestamp: Thu 2010-08-19 12:07:29 +0100 message: Fix #620352. Fix a reference to kmMat4RotationAxisAngle ------------------------------------------------------------ revno: 110 committer: Carsten Haubld branch nick: kazmath timestamp: Wed 2010-04-21 12:55:39 +0200 message: applied the change to the header files as well ------------------------------------------------------------ revno: 109 committer: Carsten Haubld branch nick: kazmath timestamp: Wed 2010-04-21 12:54:06 +0200 message: fixed kmMat4RotationAxis ------------------------------------------------------------ revno: 108 [merge] committer: Carsten Haubld branch nick: kazmath timestamp: Wed 2010-04-21 12:27:53 +0200 message: fixed CMake in kazmathxx due to missing utility.h ------------------------------------------------------------ revno: 107 committer: Carsten Haubld branch nick: kazmath timestamp: Wed 2010-04-21 12:22:40 +0200 message: fixed mat4 rotation axis by normalizing the axis first ------------------------------------------------------------ revno: 106 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2010-01-09 16:56:04 +0000 message: Add cmake module ------------------------------------------------------------ revno: 105 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2010-01-09 16:23:31 +0000 message: Remove kazmodel - it really should belong in its own repo ------------------------------------------------------------ revno: 104 committer: Luke Benstead branch nick: kazmath timestamp: Fri 2010-01-08 23:03:13 +0000 message: Reorganize the headers so that the tests can compile in place ------------------------------------------------------------ revno: 103 committer: Carsten Haubld branch nick: kazmath timestamp: Mon 2009-08-31 11:21:42 +0200 message: Operators now inline, constructors fixed ------------------------------------------------------------ revno: 102 committer: Carsten Haubld branch nick: kazmath timestamp: Sat 2009-08-29 11:42:59 +0200 message: fixed some compilation errors - still how do we define operators in headers correctly?? ------------------------------------------------------------ revno: 101 committer: Luke Benstead branch nick: kazmath timestamp: Wed 2009-08-26 10:37:52 +0100 message: Added the header defines ------------------------------------------------------------ revno: 100 committer: Luke Benstead branch nick: kazmath timestamp: Wed 2009-08-26 09:38:47 +0100 message: Added a V2 for kazmathxx ------------------------------------------------------------ revno: 99 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-08-02 08:08:26 +0100 message: Added missing header file to one of the tests ------------------------------------------------------------ revno: 98 committer: Carsten Haubld branch nick: kazmath timestamp: Sat 2009-08-01 12:05:25 +0200 message: No longer doing self assignment in kmMat4Inverse ------------------------------------------------------------ revno: 97 committer: Carsten Haubld branch nick: kazmath timestamp: Sat 2009-08-01 11:15:36 +0200 message: Fixed kmMat4Inverse ------------------------------------------------------------ revno: 96 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2009-08-01 09:20:33 +0100 message: Fixed some whitespace issues in plane.c ------------------------------------------------------------ revno: 95 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2009-08-01 09:17:01 +0100 message: Rename kmAABBPointInBox to kmAABBContainsPoint ------------------------------------------------------------ revno: 94 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2009-08-01 09:16:28 +0100 message: Implement kmAABBPointInBox ------------------------------------------------------------ revno: 93 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2009-08-01 09:14:00 +0100 message: Implement kmAABBAssign ------------------------------------------------------------ revno: 92 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2009-08-01 09:10:36 +0100 message: Fixed some whitespace and added some comments ------------------------------------------------------------ revno: 91 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2009-08-01 08:56:13 +0100 message: Implemented (untested) kmMat4RotationTranslation to construct a 4x4 matrix from a 3x3 + vec3 ------------------------------------------------------------ revno: 90 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-07-05 07:55:45 +0100 message: Added kmMat3RotationX, kmMat3RotationY and kmMat3RotationZ ------------------------------------------------------------ revno: 89 committer: Carsten Haubld branch nick: kazmath timestamp: Sat 2009-06-27 09:38:20 +0200 message: Fixed a crash? ------------------------------------------------------------ revno: 88 committer: Luke Benstead branch nick: kazmath timestamp: Tue 2009-04-28 09:52:57 +0100 message: Added a test for kmMat4Transpose ------------------------------------------------------------ revno: 87 committer: Luke Benstead branch nick: kazmath timestamp: Tue 2009-04-28 08:49:59 +0100 message: Added a commented test for kmMat4Inverse, however kmMat4Adjugate and kmMat4Determinate need implementing ------------------------------------------------------------ revno: 86 committer: Luke Benstead branch nick: kazmath timestamp: Tue 2009-04-28 08:46:03 +0100 message: Fixed bug in kmQuaternionRotationMatrix ------------------------------------------------------------ revno: 85 committer: Luke Benstead branch nick: kazmath timestamp: Tue 2009-04-28 08:41:27 +0100 message: Added missing include to test_mat3.cpp ------------------------------------------------------------ revno: 84 committer: Carsten Haubld branch nick: kazmath timestamp: Mon 2009-04-27 22:59:08 +0200 message: fixed CMakeLists.txt for the tests ------------------------------------------------------------ revno: 83 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 21:34:20 +0100 message: Added a test for kmMat3Translation ------------------------------------------------------------ revno: 82 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 21:32:19 +0100 message: Fixed bugs in kmMat3Scaling and kmMat3Translation, added test for kmMat3Scaling ------------------------------------------------------------ revno: 81 [merge] committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 19:04:56 +0100 message: Merge from upstream. Fixed mismatching prototype in quaternion.c ------------------------------------------------------------ revno: 80 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 19:01:35 +0100 message: Added a test for kmMat3AreEqual. Fixed a bug in kmMat3AreEqual ------------------------------------------------------------ revno: 79 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 18:57:28 +0100 message: Added a test for kmMat3IsIdentity ------------------------------------------------------------ revno: 78 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 18:54:48 +0100 message: Added a test for kmMat3Identity ------------------------------------------------------------ revno: 77 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 18:52:14 +0100 message: Added a test for kmMat3Fill ------------------------------------------------------------ revno: 76 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 18:46:30 +0100 message: Added some mat3 unit tests. Fixed a bug in kmMat3AreEqual ------------------------------------------------------------ revno: 75 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 11:08:43 +0100 message: Added mat4 test stub ------------------------------------------------------------ revno: 74 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 11:06:12 +0100 message: Enabled unit testing in cmake ------------------------------------------------------------ revno: 73 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 10:44:37 +0100 message: Added cmakelists.txt to the tests subfolder ------------------------------------------------------------ revno: 72 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 10:37:34 +0100 message: Added stub mat3 test file ------------------------------------------------------------ revno: 71 committer: Luke Benstead branch nick: kazmath timestamp: Mon 2009-04-27 10:35:48 +0100 message: Added tests folder for new boost::unit based tests ------------------------------------------------------------ revno: 70 committer: Carsten Haubld branch nick: kazmath timestamp: Sun 2009-04-26 14:25:48 +0200 message: Fixed the new quaternion -> Matrix -> AngleAxis methods and added them to mat4 ------------------------------------------------------------ revno: 69 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 12:40:08 +0100 message: Added kazmodel to the kazlibs repo ------------------------------------------------------------ revno: 68 [merge] committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 12:34:27 +0100 message: Merge from upstream ------------------------------------------------------------ revno: 67 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 12:33:43 +0100 message: Reorganized bzr ------------------------------------------------------------ revno: 66 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 10:00:18 +0100 message: Renamed kmMat3RotationAxis to kmMat3RotationAxisAngle to be more accurate ------------------------------------------------------------ revno: 65 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 09:57:19 +0100 message: Fixed some compilation errors ------------------------------------------------------------ revno: 64 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 09:54:12 +0100 message: Added untested implementation of kmMat3RotationToAxisAngle ------------------------------------------------------------ revno: 63 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 09:49:17 +0100 message: Added stub for kmMat3RotationToAxisAngle() ------------------------------------------------------------ revno: 62 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 09:45:58 +0100 message: Corrected a typo ------------------------------------------------------------ revno: 61 committer: Luke Benstead branch nick: kazmath timestamp: Sun 2009-04-26 09:44:39 +0100 message: Fixed broken Quaternion functions Added (untested) kmMat3RotationAxis() ------------------------------------------------------------ revno: 60 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2009-04-18 08:55:29 +0100 message: Fixed some errors in the quaternion header. Changed kmQuaternionRotationMatrix to accept a kmMat3 instead of kmMat4 ------------------------------------------------------------ revno: 59 committer: Luke Benstead branch nick: kazmath timestamp: Sat 2009-04-18 08:42:38 +0100 message: Added kmMat3RotationQuaternion ------------------------------------------------------------ revno: 58 committer: Carsten Haubld branch nick: kazmath timestamp: Sun 2009-04-05 11:58:29 +0200 message: Added mat3 ------------------------------------------------------------ revno: 57 [merge] committer: Carsten Haubld branch nick: kazmath timestamp: Sun 2009-04-05 11:54:15 +0200 message: Implemented mat4 and vec4 for kazmathxx ------------------------------------------------------------ revno: 56 committer: Carsten Haubld branch nick: kazmath timestamp: Sun 2009-04-05 11:53:07 +0200 message: Implemented mat4 and vec4 for kazmathxx ------------------------------------------------------------ revno: 55 committer: Carsten Haubld branch nick: kazmath timestamp: Fri 2009-03-13 16:46:26 +0100 message: added km::vec3 to kazmathxx ------------------------------------------------------------ revno: 54 committer: Carsten Haubld branch nick: kazmath timestamp: Fri 2009-03-13 16:14:51 +0100 message: Fixed: kmVec2 is no longer transformed by kmMat4\nAdded km::vec2 ------------------------------------------------------------ revno: 53 committer: Carsten Haubld branch nick: kazmath timestamp: Fri 2009-03-13 15:38:53 +0100 message: Added folder for kazmathxx ------------------------------------------------------------ revno: 52 [merge] committer: Luke Benstead branch nick: trunk timestamp: Fri 2009-03-13 14:04:32 +0000 message: Merge from upstream ------------------------------------------------------------ revno: 51 committer: Luke Benstead branch nick: trunk timestamp: Fri 2009-03-13 14:00:14 +0000 message: Fixed for C89 ------------------------------------------------------------ revno: 50 committer: Carsten Haubold timestamp: Tue 2008-12-30 12:45:23 +0100 message: fixed kmGLTranslate ------------------------------------------------------------ revno: 49 committer: Carsten Haubold timestamp: Tue 2008-12-30 12:15:27 +0100 message: fixed some stack memory leaks ------------------------------------------------------------ revno: 48 committer: Carsten Haubold timestamp: Tue 2008-12-30 11:01:35 +0100 message: The GL matrix stacks now work as expected - matrix multiplication was the wrong way round ------------------------------------------------------------ revno: 47 committer: Carsten Haubold timestamp: Tue 2008-12-30 10:52:28 +0100 message: Debug output ------------------------------------------------------------ revno: 46 committer: Carsten Haubold timestamp: Mon 2008-12-29 18:32:13 +0100 message: Fixed some compiler errors ------------------------------------------------------------ revno: 45 committer: Luke timestamp: Wed 2008-11-19 08:36:47 +0000 message: Added kmGLTranslatef, kmGLScalef and kmGLRotatef ------------------------------------------------------------ revno: 44 committer: Luke timestamp: Tue 2008-11-04 20:57:30 +0000 message: Fixed up kazmathxx ------------------------------------------------------------ revno: 43 committer: Luke timestamp: Wed 2008-10-29 09:24:32 +0000 message: Started implementing C++ operators in kazmathxx.h ------------------------------------------------------------ revno: 42 committer: Luke timestamp: Tue 2008-10-28 18:21:16 +0000 message: Added kazmathxx.h for C++ usage ------------------------------------------------------------ revno: 41 committer: Luke timestamp: Tue 2008-10-28 11:00:41 +0000 message: Added Doxygen documentation ------------------------------------------------------------ revno: 40 committer: Luke timestamp: Tue 2008-10-28 08:46:19 +0000 message: Began documenting the kmPlane functions. Changed some assert(0)s to include a not implemented message ------------------------------------------------------------ revno: 39 committer: Luke timestamp: Tue 2008-10-28 08:42:24 +0000 message: - Wrote stubs for the AABB functions which raise assertions if used. - Documented the AABB functions - Changed the definition of kmAABBPointInBox so that it actually makes sense ------------------------------------------------------------ revno: 38 committer: Luke timestamp: Tue 2008-10-28 08:38:48 +0000 message: - Documented utility.c ------------------------------------------------------------ revno: 37 committer: Luke timestamp: Tue 2008-10-28 08:36:30 +0000 message: - Documented vec3.c in detail. - Fixed up a not-implemented assertion. - Changed existing doc strings to C style - /** */ ------------------------------------------------------------ revno: 36 committer: Luke timestamp: Tue 2008-10-28 08:30:00 +0000 message: Removed uneccessary files from git ------------------------------------------------------------ revno: 35 committer: Luke timestamp: Tue 2008-10-28 08:28:49 +0000 message: - Documented all the functions in mat4.c - Fixed up all asserts in mat4.c to include a message - Tidied up the code. Mat4.c is now done. ------------------------------------------------------------ revno: 34 committer: Luke timestamp: Mon 2008-10-27 21:52:33 +0000 message: Added potential 0.1 release binary ------------------------------------------------------------ revno: 33 committer: Luke Benstead timestamp: Mon 2008-10-27 21:46:55 +0000 message: Changed the README to include the BSD license ------------------------------------------------------------ revno: 32 committer: Luke Benstead timestamp: Mon 2008-10-27 21:45:51 +0000 message: Added the modified BSD license to all source files ------------------------------------------------------------ revno: 31 committer: Luke Benstead timestamp: Mon 2008-10-27 21:11:51 +0000 message: Fixed the installation of header files in CMake ------------------------------------------------------------ revno: 30 committer: Luke timestamp: Mon 2008-10-27 21:05:51 +0000 message: Added kazmath project files ------------------------------------------------------------ revno: 29 [merge] committer: Luke timestamp: Mon 2008-10-27 21:03:22 +0000 message: Merge branch 'master' of git@github.com:Kazade/kazmath ------------------------------------------------------------ revno: 28 committer: Luke timestamp: Mon 2008-10-27 21:02:04 +0000 message: Finally got kazmath compiling on VC++, man that compiler sucks! Have MS not heard of C99? ------------------------------------------------------------ revno: 27 committer: Luke Benstead timestamp: Sun 2008-10-26 21:35:24 +0000 message: Changed the readme slightly, we need to change the license everywhere ------------------------------------------------------------ revno: 26 committer: Luke Benstead timestamp: Sun 2008-10-26 21:21:47 +0000 message: Implemented the stacks test, fixed the undefined references I was getting ------------------------------------------------------------ revno: 25 committer: Luke Benstead timestamp: Sun 2008-10-26 20:59:34 +0000 message: Removed the old matrix stack stuff ------------------------------------------------------------ revno: 24 committer: Luke Benstead timestamp: Sun 2008-10-26 20:11:58 +0000 message: Started implementing the matrix stack tests ------------------------------------------------------------ revno: 23 committer: Luke Benstead timestamp: Sun 2008-10-26 10:56:51 +0000 message: Started new implementation of the GL matrix stack ------------------------------------------------------------ revno: 22 committer: Carsten Haubold timestamp: Thu 2008-08-28 12:37:41 +0200 message: Added kmGLRotation ------------------------------------------------------------ revno: 21 committer: Luke Benstead timestamp: Thu 2008-08-28 09:24:00 +0100 message: We now have a working matrix stack ------------------------------------------------------------ revno: 20 committer: Luke Benstead timestamp: Wed 2008-08-27 13:34:49 +0100 message: Fixed the stack memory constants ------------------------------------------------------------ revno: 19 committer: Luke Benstead timestamp: Wed 2008-08-27 13:33:12 +0100 message: Added the initial gl_utils implementation for replacing the matrix functionality deprecated in OpenGL 3.0 ------------------------------------------------------------ revno: 18 committer: Carsten Haubold timestamp: Mon 2008-08-25 12:46:16 +0200 message: Fixed a bug in kmMat4LookAt ------------------------------------------------------------ revno: 17 [merge] committer: Carsten Haubold timestamp: Sun 2008-08-24 22:07:49 +0200 message: Merge branch 'master' of git@github.com:Kazade/kazmath ------------------------------------------------------------ revno: 16 committer: Carsten Haubold timestamp: Sun 2008-08-24 22:06:45 +0200 message: Added kmMat4LookAt ------------------------------------------------------------ revno: 15 committer: Carsten Haubold timestamp: Wed 2008-08-20 11:18:10 +0200 message: Added Fill methods for all Vec and Mat structs ------------------------------------------------------------ revno: 14 committer: Carsten Haubold timestamp: Tue 2008-08-19 22:31:55 +0200 message: Added UnitTests, changed bool to int and fixed some minor bugs ------------------------------------------------------------ revno: 13 committer: Carsten Haubold timestamp: Sun 2008-08-17 23:19:21 +0200 message: removed .svn entries which did not belong here ------------------------------------------------------------ revno: 12 committer: Carsten Haubold timestamp: Sun 2008-08-17 23:17:07 +0200 message: some tweaks on matrices and first test-app, PerspectiveProjection is correct ! ------------------------------------------------------------ revno: 11 committer: Carsten Haubold timestamp: Sun 2008-08-17 16:04:09 +0200 message: Renamed cotangent to cotangens ------------------------------------------------------------ revno: 10 committer: Luke Benstead timestamp: Sat 2008-08-16 21:51:22 +0100 message: Added kmMat4PerspectiveProjection and kmMat4OrthographicProjection ------------------------------------------------------------ revno: 9 committer: Luke Benstead timestamp: Thu 2008-08-14 21:15:45 +0100 message: Added the aabb struct ------------------------------------------------------------ revno: 8 committer: Luke Benstead timestamp: Thu 2008-08-14 17:57:43 +0100 message: Added the kmAABB structure ------------------------------------------------------------ revno: 7 committer: Luke Benstead timestamp: Thu 2008-08-14 14:32:24 +0100 message: Fixed broken kmMat3Transpose ------------------------------------------------------------ revno: 6 committer: Luke Benstead timestamp: Thu 2008-08-14 14:21:04 +0100 message: Fixed broken kmMat4Translation, w component was not set ------------------------------------------------------------ revno: 5 committer: Luke Benstead timestamp: Thu 2008-08-14 14:01:47 +0100 message: Added mat3.c and mat3.h to the cmake file ------------------------------------------------------------ revno: 4 committer: Luke Benstead timestamp: Thu 2008-08-14 13:56:26 +0100 message: Added the authors section to the readme ------------------------------------------------------------ revno: 3 committer: Luke Benstead timestamp: Thu 2008-08-14 13:55:41 +0100 message: Updated the readme file ------------------------------------------------------------ revno: 2 committer: Luke Benstead timestamp: Thu 2008-08-14 13:53:26 +0100 message: Added kazmath to git ------------------------------------------------------------ revno: 1 committer: Luke Benstead timestamp: Thu 2008-08-14 13:47:51 +0100 message: First commit ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions. ================================================ FILE: cocos2d/cocos/math/kazmath/src/GL/mat4stack.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include #include #include #include #define INITIAL_SIZE 30 #define INCREMENT 50 #include "kazmath/GL/mat4stack.h" void km_mat4_stack_initialize(km_mat4_stack* stack) { stack->stack = (kmMat4*) malloc(sizeof(kmMat4) * INITIAL_SIZE); //allocate the memory stack->capacity = INITIAL_SIZE; //Set the capacity to 10 stack->top = NULL; //Set the top to NULL stack->item_count = 0; }; void km_mat4_stack_push(km_mat4_stack* stack, const kmMat4* item) { stack->top = &stack->stack[stack->item_count]; kmMat4Assign(stack->top, item); stack->item_count++; if(stack->item_count >= stack->capacity) { kmMat4* temp = NULL; stack->capacity += INCREMENT; temp = stack->stack; stack->stack = (kmMat4*) malloc(stack->capacity*sizeof(kmMat4)); memcpy(stack->stack, temp, sizeof(kmMat4)*(stack->capacity - INCREMENT)); free(temp); stack->top = &stack->stack[stack->item_count - 1]; } } void km_mat4_stack_pop(km_mat4_stack* stack, kmMat4* pOut) { assert(stack->item_count && "Cannot pop an empty stack"); stack->item_count--; stack->top = &stack->stack[stack->item_count - 1]; } void km_mat4_stack_release(km_mat4_stack* stack) { if (stack->stack) { free(stack->stack); stack->stack = NULL; } stack->top = NULL; stack->item_count = 0; stack->capacity = 0; } ================================================ FILE: cocos2d/cocos/math/kazmath/src/GL/matrix.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include #include #include "kazmath/GL/matrix.h" #include "kazmath/GL/mat4stack.h" km_mat4_stack modelview_matrix_stack; km_mat4_stack projection_matrix_stack; km_mat4_stack texture_matrix_stack; km_mat4_stack* current_stack = NULL; static unsigned char initialized = 0; void lazyInitialize() { if (!initialized) { kmMat4 identity; //Temporary identity matrix //Initialize all 3 stacks //modelview_matrix_stack = (km_mat4_stack*) malloc(sizeof(km_mat4_stack)); km_mat4_stack_initialize(&modelview_matrix_stack); //projection_matrix_stack = (km_mat4_stack*) malloc(sizeof(km_mat4_stack)); km_mat4_stack_initialize(&projection_matrix_stack); //texture_matrix_stack = (km_mat4_stack*) malloc(sizeof(km_mat4_stack)); km_mat4_stack_initialize(&texture_matrix_stack); current_stack = &modelview_matrix_stack; initialized = 1; kmMat4Identity(&identity); //Make sure that each stack has the identity matrix km_mat4_stack_push(&modelview_matrix_stack, &identity); km_mat4_stack_push(&projection_matrix_stack, &identity); km_mat4_stack_push(&texture_matrix_stack, &identity); } } void kmGLMatrixMode(kmGLEnum mode) { lazyInitialize(); switch(mode) { case KM_GL_MODELVIEW: current_stack = &modelview_matrix_stack; break; case KM_GL_PROJECTION: current_stack = &projection_matrix_stack; break; case KM_GL_TEXTURE: current_stack = &texture_matrix_stack; break; default: assert(0 && "Invalid matrix mode specified"); //TODO: Proper error handling break; } } void kmGLPushMatrix(void) { kmMat4 top; lazyInitialize(); //Initialize the stacks if they haven't been already //Duplicate the top of the stack (i.e the current matrix) kmMat4Assign(&top, current_stack->top); km_mat4_stack_push(current_stack, &top); } void kmGLPopMatrix(void) { assert(initialized && "Cannot Pop empty matrix stack"); //No need to lazy initialize, you shouldn't be popping first anyway! km_mat4_stack_pop(current_stack, NULL); } void kmGLLoadIdentity() { lazyInitialize(); kmMat4Identity(current_stack->top); //Replace the top matrix with the identity matrix } void kmGLFreeAll() { //Clear the matrix stacks km_mat4_stack_release(&modelview_matrix_stack); km_mat4_stack_release(&projection_matrix_stack); km_mat4_stack_release(&texture_matrix_stack); //Delete the matrices initialized = 0; //Set to uninitialized current_stack = NULL; //Set the current stack to point nowhere } void kmGLMultMatrix(const kmMat4* pIn) { lazyInitialize(); kmMat4Multiply(current_stack->top, current_stack->top, pIn); } void kmGLLoadMatrix(const kmMat4* pIn) { lazyInitialize(); kmMat4Assign(current_stack->top, pIn); } void kmGLGetMatrix(kmGLEnum mode, kmMat4* pOut) { lazyInitialize(); switch(mode) { case KM_GL_MODELVIEW: kmMat4Assign(pOut, modelview_matrix_stack.top); break; case KM_GL_PROJECTION: kmMat4Assign(pOut, projection_matrix_stack.top); break; case KM_GL_TEXTURE: kmMat4Assign(pOut, texture_matrix_stack.top); break; default: assert(1 && "Invalid matrix mode specified"); //TODO: Proper error handling break; } } void kmGLTranslatef(float x, float y, float z) { kmMat4 translation; //Create a rotation matrix using the axis and the angle kmMat4Translation(&translation,x,y,z); //Multiply the rotation matrix by the current matrix kmMat4Multiply(current_stack->top, current_stack->top, &translation); } void kmGLRotatef(float angle, float x, float y, float z) { kmVec3 axis; kmMat4 rotation; //Create an axis vector kmVec3Fill(&axis, x, y, z); //Create a rotation matrix using the axis and the angle kmMat4RotationAxisAngle(&rotation, &axis, kmDegreesToRadians(angle)); //Multiply the rotation matrix by the current matrix kmMat4Multiply(current_stack->top, current_stack->top, &rotation); } void kmGLScalef(float x, float y, float z) { kmMat4 scaling; kmMat4Scaling(&scaling, x, y, z); kmMat4Multiply(current_stack->top, current_stack->top, &scaling); } ================================================ FILE: cocos2d/cocos/math/kazmath/src/aabb.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include "kazmath/aabb.h" /** * Returns KM_TRUE if point is in the specified AABB, returns * KM_FALSE otherwise. */ const int kmAABBContainsPoint(const kmVec3* pPoint, const kmAABB* pBox) { if(pPoint->x >= pBox->min.x && pPoint->x <= pBox->max.x && pPoint->y >= pBox->min.y && pPoint->y <= pBox->max.y && pPoint->z >= pBox->min.z && pPoint->z <= pBox->max.z) { return KM_TRUE; } return KM_FALSE; } /** * Assigns pIn to pOut, returns pOut. */ kmAABB* const kmAABBAssign(kmAABB* pOut, const kmAABB* pIn) { kmVec3Assign(&pOut->min, &pIn->min); kmVec3Assign(&pOut->max, &pIn->max); return pOut; } /** * Scales pIn by s, stores the resulting AABB in pOut. Returns pOut */ kmAABB* const kmAABBScale(kmAABB* pOut, const kmAABB* pIn, kmScalar s) { assert(0 && "Not implemented"); return 0; } ================================================ FILE: cocos2d/cocos/math/kazmath/src/mat3.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include #include #include #include "kazmath/utility.h" #include "kazmath/vec3.h" #include "kazmath/mat3.h" #include "kazmath/quaternion.h" kmMat3* const kmMat3Fill(kmMat3* pOut, const kmScalar* pMat) { memcpy(pOut->mat, pMat, sizeof(kmScalar) * 9); return pOut; } /** Sets pOut to an identity matrix returns pOut*/ kmMat3* const kmMat3Identity(kmMat3* pOut) { memset(pOut->mat, 0, sizeof(float) * 9); pOut->mat[0] = pOut->mat[4] = pOut->mat[8] = 1.0f; return pOut; } const kmScalar kmMat3Determinant(const kmMat3* pIn) { kmScalar output; /* calculating the determinant following the rule of sarus, | 0 3 6 | 0 3 | m = | 1 4 7 | 1 4 | | 2 5 8 | 2 5 | now sum up the products of the diagonals going to the right (i.e. 0,4,8) and subtract the products of the other diagonals (i.e. 2,4,6) */ output = pIn->mat[0] * pIn->mat[4] * pIn->mat[8] + pIn->mat[1] * pIn->mat[5] * pIn->mat[6] + pIn->mat[2] * pIn->mat[3] * pIn->mat[7]; output -= pIn->mat[2] * pIn->mat[4] * pIn->mat[6] + pIn->mat[0] * pIn->mat[5] * pIn->mat[7] + pIn->mat[1] * pIn->mat[3] * pIn->mat[8]; return output; } kmMat3* const kmMat3Adjugate(kmMat3* pOut, const kmMat3* pIn) { pOut->mat[0] = pIn->mat[4] * pIn->mat[8] - pIn->mat[5] * pIn->mat[7]; pOut->mat[1] = pIn->mat[2] * pIn->mat[7] - pIn->mat[1] * pIn->mat[8]; pOut->mat[2] = pIn->mat[1] * pIn->mat[5] - pIn->mat[2] * pIn->mat[4]; pOut->mat[3] = pIn->mat[5] * pIn->mat[6] - pIn->mat[3] * pIn->mat[8]; pOut->mat[4] = pIn->mat[0] * pIn->mat[8] - pIn->mat[2] * pIn->mat[6]; pOut->mat[5] = pIn->mat[2] * pIn->mat[3] - pIn->mat[0] * pIn->mat[5]; pOut->mat[6] = pIn->mat[3] * pIn->mat[7] - pIn->mat[4] * pIn->mat[6]; // XXX: pIn->mat[9] is invalid! // pOut->mat[7] = pIn->mat[1] * pIn->mat[6] - pIn->mat[9] * pIn->mat[7]; pOut->mat[8] = pIn->mat[0] * pIn->mat[4] - pIn->mat[1] * pIn->mat[3]; return pOut; } kmMat3* const kmMat3Inverse(kmMat3* pOut, const kmScalar pDeterminate, const kmMat3* pM) { kmScalar detInv; kmMat3 adjugate; if(pDeterminate == 0.0) { return NULL; } detInv = 1.0f / pDeterminate; kmMat3Adjugate(&adjugate, pM); kmMat3ScalarMultiply(pOut, &adjugate, detInv); return pOut; } /** Returns true if pIn is an identity matrix */ const int kmMat3IsIdentity(const kmMat3* pIn) { static const float identity [] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}; return (memcmp(identity, pIn->mat, sizeof(float) * 9) == 0); } /** Sets pOut to the transpose of pIn, returns pOut */ kmMat3* const kmMat3Transpose(kmMat3* pOut, const kmMat3* pIn) { int z, x; for (z = 0; z < 3; ++z) { for (x = 0; x < 3; ++x) { pOut->mat[(z * 3) + x] = pIn->mat[(x * 3) + z]; } } return pOut; } /* Multiplies pM1 with pM2, stores the result in pOut, returns pOut */ kmMat3* const kmMat3Multiply(kmMat3* pOut, const kmMat3* pM1, const kmMat3* pM2) { float mat[9]; const float *m1 = pM1->mat, *m2 = pM2->mat; mat[0] = m1[0] * m2[0] + m1[3] * m2[1] + m1[6] * m2[2]; mat[1] = m1[1] * m2[0] + m1[4] * m2[1] + m1[7] * m2[2]; mat[2] = m1[2] * m2[0] + m1[5] * m2[1] + m1[8] * m2[2]; mat[3] = m1[0] * m2[3] + m1[3] * m2[4] + m1[6] * m2[5]; mat[4] = m1[1] * m2[3] + m1[4] * m2[4] + m1[7] * m2[5]; mat[5] = m1[2] * m2[3] + m1[5] * m2[4] + m1[8] * m2[5]; mat[6] = m1[0] * m2[6] + m1[3] * m2[7] + m1[6] * m2[8]; mat[7] = m1[1] * m2[6] + m1[4] * m2[7] + m1[7] * m2[8]; mat[8] = m1[2] * m2[6] + m1[5] * m2[7] + m1[8] * m2[8]; memcpy(pOut->mat, mat, sizeof(float)*9); return pOut; } kmMat3* const kmMat3ScalarMultiply(kmMat3* pOut, const kmMat3* pM, const kmScalar pFactor) { float mat[9]; int i; for(i = 0; i < 9; i++) { mat[i] = pM->mat[i] * pFactor; } memcpy(pOut->mat, mat, sizeof(float)*9); return pOut; } /** Assigns the value of pIn to pOut */ kmMat3* const kmMat3Assign(kmMat3* pOut, const kmMat3* pIn) { assert(pOut != pIn); //You have tried to self-assign!! memcpy(pOut->mat, pIn->mat, sizeof(float)*9); return pOut; } /** Returns true if the 2 matrices are equal (approximately) */ const int kmMat3AreEqual(const kmMat3* pMat1, const kmMat3* pMat2) { int i; if (pMat1 == pMat2) { return KM_TRUE; } for (i = 0; i < 9; ++i) { if (!(pMat1->mat[i] + kmEpsilon > pMat2->mat[i] && pMat1->mat[i] - kmEpsilon < pMat2->mat[i])) { return KM_FALSE; } } return KM_TRUE; } /* Rotation around the z axis so everything stays planar in XY */ kmMat3* const kmMat3Rotation(kmMat3* pOut, const float radians) { /* | cos(A) -sin(A) 0 | M = | sin(A) cos(A) 0 | | 0 0 1 | */ pOut->mat[0] = cosf(radians); pOut->mat[1] = sinf(radians); pOut->mat[2] = 0.0f; pOut->mat[3] = -sinf(radians);; pOut->mat[4] = cosf(radians); pOut->mat[5] = 0.0f; pOut->mat[6] = 0.0f; pOut->mat[7] = 0.0f; pOut->mat[8] = 1.0f; return pOut; } /** Builds a scaling matrix */ kmMat3* const kmMat3Scaling(kmMat3* pOut, const kmScalar x, const kmScalar y) { // memset(pOut->mat, 0, sizeof(float) * 9); kmMat3Identity(pOut); pOut->mat[0] = x; pOut->mat[4] = y; return pOut; } kmMat3* const kmMat3Translation(kmMat3* pOut, const kmScalar x, const kmScalar y) { // memset(pOut->mat, 0, sizeof(float) * 9); kmMat3Identity(pOut); pOut->mat[6] = x; pOut->mat[7] = y; // pOut->mat[8] = 1.0; return pOut; } kmMat3* const kmMat3RotationQuaternion(kmMat3* pOut, const kmQuaternion* pIn) { if (!pIn || !pOut) { return NULL; } // First row pOut->mat[0] = 1.0f - 2.0f * (pIn->y * pIn->y + pIn->z * pIn->z); pOut->mat[1] = 2.0f * (pIn->x * pIn->y - pIn->w * pIn->z); pOut->mat[2] = 2.0f * (pIn->x * pIn->z + pIn->w * pIn->y); // Second row pOut->mat[3] = 2.0f * (pIn->x * pIn->y + pIn->w * pIn->z); pOut->mat[4] = 1.0f - 2.0f * (pIn->x * pIn->x + pIn->z * pIn->z); pOut->mat[5] = 2.0f * (pIn->y * pIn->z - pIn->w * pIn->x); // Third row pOut->mat[6] = 2.0f * (pIn->x * pIn->z - pIn->w * pIn->y); pOut->mat[7] = 2.0f * (pIn->y * pIn->z + pIn->w * pIn->x); pOut->mat[8] = 1.0f - 2.0f * (pIn->x * pIn->x + pIn->y * pIn->y); return pOut; } kmMat3* const kmMat3RotationAxisAngle(kmMat3* pOut, const struct kmVec3* axis, kmScalar radians) { float rcos = cosf(radians); float rsin = sinf(radians); pOut->mat[0] = rcos + axis->x * axis->x * (1 - rcos); pOut->mat[1] = axis->z * rsin + axis->y * axis->x * (1 - rcos); pOut->mat[2] = -axis->y * rsin + axis->z * axis->x * (1 - rcos); pOut->mat[3] = -axis->z * rsin + axis->x * axis->y * (1 - rcos); pOut->mat[4] = rcos + axis->y * axis->y * (1 - rcos); pOut->mat[5] = axis->x * rsin + axis->z * axis->y * (1 - rcos); pOut->mat[6] = axis->y * rsin + axis->x * axis->z * (1 - rcos); pOut->mat[7] = -axis->x * rsin + axis->y * axis->z * (1 - rcos); pOut->mat[8] = rcos + axis->z * axis->z * (1 - rcos); return pOut; } kmVec3* const kmMat3RotationToAxisAngle(kmVec3* pAxis, kmScalar* radians, const kmMat3* pIn) { /*Surely not this easy?*/ kmQuaternion temp; kmQuaternionRotationMatrix(&temp, pIn); kmQuaternionToAxisAngle(&temp, pAxis, radians); return pAxis; } /** * Builds an X-axis rotation matrix and stores it in pOut, returns pOut */ kmMat3* const kmMat3RotationX(kmMat3* pOut, const float radians) { /* | 1 0 0 | M = | 0 cos(A) -sin(A) | | 0 sin(A) cos(A) | */ pOut->mat[0] = 1.0f; pOut->mat[1] = 0.0f; pOut->mat[2] = 0.0f; pOut->mat[3] = 0.0f; pOut->mat[4] = cosf(radians); pOut->mat[5] = sinf(radians); pOut->mat[6] = 0.0f; pOut->mat[7] = -sinf(radians); pOut->mat[8] = cosf(radians); return pOut; } /** * Builds a rotation matrix using the rotation around the Y-axis * The result is stored in pOut, pOut is returned. */ kmMat3* const kmMat3RotationY(kmMat3* pOut, const float radians) { /* | cos(A) 0 sin(A) | M = | 0 1 0 | | -sin(A) 0 cos(A) | */ pOut->mat[0] = cosf(radians); pOut->mat[1] = 0.0f; pOut->mat[2] = -sinf(radians); pOut->mat[3] = 0.0f; pOut->mat[4] = 1.0f; pOut->mat[5] = 0.0f; pOut->mat[6] = sinf(radians); pOut->mat[7] = 0.0f; pOut->mat[8] = cosf(radians); return pOut; } /** * Builds a rotation matrix around the Z-axis. The resulting * matrix is stored in pOut. pOut is returned. */ kmMat3* const kmMat3RotationZ(kmMat3* pOut, const float radians) { /* | cos(A) -sin(A) 0 | M = | sin(A) cos(A) 0 | | 0 0 1 | */ pOut->mat[0] = cosf(radians); pOut->mat[1] =-sinf(radians); pOut->mat[2] = 0.0f; pOut->mat[3] = sinf(radians);; pOut->mat[4] = cosf(radians); pOut->mat[5] = 0.0f; pOut->mat[6] = 0.0f; pOut->mat[7] = 0.0f; pOut->mat[8] = 1.0f; return pOut; } ================================================ FILE: cocos2d/cocos/math/kazmath/src/mat4.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ /** * @file mat4.c */ #include #include #include #include "kazmath/utility.h" #include "kazmath/vec3.h" #include "kazmath/mat4.h" #include "kazmath/mat3.h" #include "kazmath/quaternion.h" #include "kazmath/plane.h" #include "kazmath/neon_matrix_impl.h" /** * Fills a kmMat4 structure with the values from a 16 * element array of floats * @Params pOut - A pointer to the destination matrix * pMat - A 16 element array of floats * @Return Returns pOut so that the call can be nested */ kmMat4* const kmMat4Fill(kmMat4* pOut, const kmScalar* pMat) { memcpy(pOut->mat, pMat, sizeof(kmScalar) * 16); return pOut; } /** * Sets pOut to an identity matrix returns pOut * @Params pOut - A pointer to the matrix to set to identity * @Return Returns pOut so that the call can be nested */ kmMat4* const kmMat4Identity(kmMat4* pOut) { memset(pOut->mat, 0, sizeof(float) * 16); pOut->mat[0] = pOut->mat[5] = pOut->mat[10] = pOut->mat[15] = 1.0f; return pOut; } float get(const kmMat4 * pIn, int row, int col) { return pIn->mat[row + 4*col]; } void set(kmMat4 * pIn, int row, int col, float value) { pIn->mat[row + 4*col] = value; } void swap(kmMat4 * pIn, int r1, int c1, int r2, int c2) { float tmp = get(pIn,r1,c1); set(pIn,r1,c1,get(pIn,r2,c2)); set(pIn,r2,c2, tmp); } //Returns an upper and a lower triangular matrix which are L and R in the Gauss algorithm int gaussj(kmMat4 *a, kmMat4 *b) { int i, icol = 0, irow = 0, j, k, l, ll, n = 4, m = 4; float big, dum, pivinv; int indxc[4] = {0}; int indxr[4] = {0}; int ipiv[4] = {0}; for (j = 0; j < n; j++) { ipiv[j] = 0; } for (i = 0; i < n; i++) { big = 0.0f; for (j = 0; j < n; j++) { if (ipiv[j] != 1) { for (k = 0; k < n; k++) { if (ipiv[k] == 0) { if (abs(get(a,j, k)) >= big) { big = abs(get(a,j, k)); irow = j; icol = k; } } } } } ++(ipiv[icol]); if (irow != icol) { for (l = 0; l < n; l++) { swap(a,irow, l, icol, l); } for (l = 0; l < m; l++) { swap(b,irow, l, icol, l); } } indxr[i] = irow; indxc[i] = icol; if (get(a,icol, icol) == 0.0) { return KM_FALSE; } pivinv = 1.0f / get(a,icol, icol); set(a,icol, icol, 1.0f); for (l = 0; l < n; l++) { set(a,icol, l, get(a,icol, l) * pivinv); } for (l = 0; l < m; l++) { set(b,icol, l, get(b,icol, l) * pivinv); } for (ll = 0; ll < n; ll++) { if (ll != icol) { dum = get(a,ll, icol); set(a,ll, icol, 0.0f); for (l = 0; l < n; l++) { set(a,ll, l, get(a,ll, l) - get(a,icol, l) * dum); } for (l = 0; l < m; l++) { set(b,ll, l, get(a,ll, l) - get(b,icol, l) * dum); } } } } // This is the end of the main loop over columns of the reduction. It only remains to unscram- // ble the solution in view of the column interchanges. We do this by interchanging pairs of // columns in the reverse order that the permutation was built up. for (l = n - 1; l >= 0; l--) { if (indxr[l] != indxc[l]) { for (k = 0; k < n; k++) { swap(a,k, indxr[l], k, indxc[l]); } } } return KM_TRUE; } /** * Calculates the inverse of pM and stores the result in * pOut. * @Return Returns NULL if there is no inverse, else pOut */ kmMat4* const kmMat4Inverse(kmMat4* pOut, const kmMat4* pM) { kmMat4 inv; kmMat4 tmp; kmMat4Assign(&inv, pM); kmMat4Identity(&tmp); if(gaussj(&inv, &tmp) == KM_FALSE) { return NULL; } kmMat4Assign(pOut, &inv); return pOut; } /** * Returns KM_TRUE if pIn is an identity matrix * KM_FALSE otherwise */ const int kmMat4IsIdentity(const kmMat4* pIn) { static const float identity [] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; return (memcmp(identity, pIn->mat, sizeof(float) * 16) == 0); } /** * Sets pOut to the transpose of pIn, returns pOut */ kmMat4* const kmMat4Transpose(kmMat4* pOut, const kmMat4* pIn) { int x, z; for (z = 0; z < 4; ++z) { for (x = 0; x < 4; ++x) { pOut->mat[(z * 4) + x] = pIn->mat[(x * 4) + z]; } } return pOut; } /** * Multiplies pM1 with pM2, stores the result in pOut, returns pOut */ kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2) { #if defined(__ARM_NEON__) && !defined(__arm64__) // It is possible to skip the memcpy() since "out" does not overwrite p1 or p2. // otherwise a temp must be needed. float *mat = pOut->mat; // Invert column-order with row-order NEON_Matrix4Mul( &pM2->mat[0], &pM1->mat[0], &mat[0] ); #else float mat[16]; const float *m1 = pM1->mat, *m2 = pM2->mat; mat[0] = m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3]; mat[1] = m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3]; mat[2] = m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3]; mat[3] = m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3]; mat[4] = m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7]; mat[5] = m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7]; mat[6] = m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7]; mat[7] = m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7]; mat[8] = m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11]; mat[9] = m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11]; mat[10] = m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11]; mat[11] = m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11]; mat[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15]; mat[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15]; mat[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]; mat[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]; memcpy(pOut->mat, mat, sizeof(pOut->mat)); #endif return pOut; } /** * Assigns the value of pIn to pOut */ kmMat4* const kmMat4Assign(kmMat4* pOut, const kmMat4* pIn) { assert(pOut != pIn && "You have tried to self-assign!!"); memcpy(pOut->mat, pIn->mat, sizeof(float)*16); return pOut; } /** * Returns KM_TRUE if the 2 matrices are equal (approximately) */ const int kmMat4AreEqual(const kmMat4* pMat1, const kmMat4* pMat2) { int i = 0; assert(pMat1 != pMat2 && "You are comparing the same thing!"); for (i = 0; i < 16; ++i) { if (!(pMat1->mat[i] + kmEpsilon > pMat2->mat[i] && pMat1->mat[i] - kmEpsilon < pMat2->mat[i])) { return KM_FALSE; } } return KM_TRUE; } /** * Build a rotation matrix from an axis and an angle. Result is stored in pOut. * pOut is returned. */ kmMat4* const kmMat4RotationAxisAngle(kmMat4* pOut, const kmVec3* axis, kmScalar radians) { float rcos = cosf(radians); float rsin = sinf(radians); kmVec3 normalizedAxis; kmVec3Normalize(&normalizedAxis, axis); pOut->mat[0] = rcos + normalizedAxis.x * normalizedAxis.x * (1 - rcos); pOut->mat[1] = normalizedAxis.z * rsin + normalizedAxis.y * normalizedAxis.x * (1 - rcos); pOut->mat[2] = -normalizedAxis.y * rsin + normalizedAxis.z * normalizedAxis.x * (1 - rcos); pOut->mat[3] = 0.0f; pOut->mat[4] = -normalizedAxis.z * rsin + normalizedAxis.x * normalizedAxis.y * (1 - rcos); pOut->mat[5] = rcos + normalizedAxis.y * normalizedAxis.y * (1 - rcos); pOut->mat[6] = normalizedAxis.x * rsin + normalizedAxis.z * normalizedAxis.y * (1 - rcos); pOut->mat[7] = 0.0f; pOut->mat[8] = normalizedAxis.y * rsin + normalizedAxis.x * normalizedAxis.z * (1 - rcos); pOut->mat[9] = -normalizedAxis.x * rsin + normalizedAxis.y * normalizedAxis.z * (1 - rcos); pOut->mat[10] = rcos + normalizedAxis.z * normalizedAxis.z * (1 - rcos); pOut->mat[11] = 0.0f; pOut->mat[12] = 0.0f; pOut->mat[13] = 0.0f; pOut->mat[14] = 0.0f; pOut->mat[15] = 1.0f; return pOut; } /** * Builds an X-axis rotation matrix and stores it in pOut, returns pOut */ kmMat4* const kmMat4RotationX(kmMat4* pOut, const float radians) { /* | 1 0 0 0 | M = | 0 cos(A) -sin(A) 0 | | 0 sin(A) cos(A) 0 | | 0 0 0 1 | */ pOut->mat[0] = 1.0f; pOut->mat[1] = 0.0f; pOut->mat[2] = 0.0f; pOut->mat[3] = 0.0f; pOut->mat[4] = 0.0f; pOut->mat[5] = cosf(radians); pOut->mat[6] = sinf(radians); pOut->mat[7] = 0.0f; pOut->mat[8] = 0.0f; pOut->mat[9] = -sinf(radians); pOut->mat[10] = cosf(radians); pOut->mat[11] = 0.0f; pOut->mat[12] = 0.0f; pOut->mat[13] = 0.0f; pOut->mat[14] = 0.0f; pOut->mat[15] = 1.0f; return pOut; } /** * Builds a rotation matrix using the rotation around the Y-axis * The result is stored in pOut, pOut is returned. */ kmMat4* const kmMat4RotationY(kmMat4* pOut, const float radians) { /* | cos(A) 0 sin(A) 0 | M = | 0 1 0 0 | | -sin(A) 0 cos(A) 0 | | 0 0 0 1 | */ pOut->mat[0] = cosf(radians); pOut->mat[1] = 0.0f; pOut->mat[2] = -sinf(radians); pOut->mat[3] = 0.0f; pOut->mat[4] = 0.0f; pOut->mat[5] = 1.0f; pOut->mat[6] = 0.0f; pOut->mat[7] = 0.0f; pOut->mat[8] = sinf(radians); pOut->mat[9] = 0.0f; pOut->mat[10] = cosf(radians); pOut->mat[11] = 0.0f; pOut->mat[12] = 0.0f; pOut->mat[13] = 0.0f; pOut->mat[14] = 0.0f; pOut->mat[15] = 1.0f; return pOut; } /** * Builds a rotation matrix around the Z-axis. The resulting * matrix is stored in pOut. pOut is returned. */ kmMat4* const kmMat4RotationZ(kmMat4* pOut, const float radians) { /* | cos(A) -sin(A) 0 0 | M = | sin(A) cos(A) 0 0 | | 0 0 1 0 | | 0 0 0 1 | */ pOut->mat[0] = cosf(radians); pOut->mat[1] = sinf(radians); pOut->mat[2] = 0.0f; pOut->mat[3] = 0.0f; pOut->mat[4] = -sinf(radians);; pOut->mat[5] = cosf(radians); pOut->mat[6] = 0.0f; pOut->mat[7] = 0.0f; pOut->mat[8] = 0.0f; pOut->mat[9] = 0.0f; pOut->mat[10] = 1.0f; pOut->mat[11] = 0.0f; pOut->mat[12] = 0.0f; pOut->mat[13] = 0.0f; pOut->mat[14] = 0.0f; pOut->mat[15] = 1.0f; return pOut; } /** * Builds a rotation matrix from pitch, yaw and roll. The resulting * matrix is stored in pOut and pOut is returned */ kmMat4* const kmMat4RotationPitchYawRoll(kmMat4* pOut, const kmScalar pitch, const kmScalar yaw, const kmScalar roll) { double cr = cos(pitch); double sr = sin(pitch); double cp = cos(yaw); double sp = sin(yaw); double cy = cos(roll); double sy = sin(roll); double srsp = sr * sp; double crsp = cr * sp; pOut->mat[0] = (kmScalar) cp * cy; pOut->mat[4] = (kmScalar) cp * sy; pOut->mat[8] = (kmScalar) - sp; pOut->mat[1] = (kmScalar) srsp * cy - cr * sy; pOut->mat[5] = (kmScalar) srsp * sy + cr * cy; pOut->mat[9] = (kmScalar) sr * cp; pOut->mat[2] = (kmScalar) crsp * cy + sr * sy; pOut->mat[6] = (kmScalar) crsp * sy - sr * cy; pOut->mat[10] = (kmScalar) cr * cp; pOut->mat[3] = pOut->mat[7] = pOut->mat[11] = 0.0; pOut->mat[15] = 1.0; return pOut; } /** Converts a quaternion to a rotation matrix, * the result is stored in pOut, returns pOut */ kmMat4* const kmMat4RotationQuaternion(kmMat4* pOut, const kmQuaternion* pQ) { pOut->mat[0] = 1.0f - 2.0f * (pQ->y * pQ->y + pQ->z * pQ->z ); pOut->mat[1] = 2.0f * (pQ->x * pQ->y + pQ->z * pQ->w); pOut->mat[2] = 2.0f * (pQ->x * pQ->z - pQ->y * pQ->w); pOut->mat[3] = 0.0f; // Second row pOut->mat[4] = 2.0f * ( pQ->x * pQ->y - pQ->z * pQ->w ); pOut->mat[5] = 1.0f - 2.0f * ( pQ->x * pQ->x + pQ->z * pQ->z ); pOut->mat[6] = 2.0f * (pQ->z * pQ->y + pQ->x * pQ->w ); pOut->mat[7] = 0.0f; // Third row pOut->mat[8] = 2.0f * ( pQ->x * pQ->z + pQ->y * pQ->w ); pOut->mat[9] = 2.0f * ( pQ->y * pQ->z - pQ->x * pQ->w ); pOut->mat[10] = 1.0f - 2.0f * ( pQ->x * pQ->x + pQ->y * pQ->y ); pOut->mat[11] = 0.0f; // Fourth row pOut->mat[12] = 0; pOut->mat[13] = 0; pOut->mat[14] = 0; pOut->mat[15] = 1.0f; return pOut; } /** Builds a scaling matrix */ kmMat4* const kmMat4Scaling(kmMat4* pOut, const kmScalar x, const kmScalar y, const kmScalar z) { memset(pOut->mat, 0, sizeof(float) * 16); pOut->mat[0] = x; pOut->mat[5] = y; pOut->mat[10] = z; pOut->mat[15] = 1.0f; return pOut; } /** * Builds a translation matrix. All other elements in the matrix * will be set to zero except for the diagonal which is set to 1.0 */ kmMat4* const kmMat4Translation(kmMat4* pOut, const kmScalar x, const kmScalar y, const kmScalar z) { //FIXME: Write a test for this memset(pOut->mat, 0, sizeof(float) * 16); pOut->mat[0] = 1.0f; pOut->mat[5] = 1.0f; pOut->mat[10] = 1.0f; pOut->mat[12] = x; pOut->mat[13] = y; pOut->mat[14] = z; pOut->mat[15] = 1.0f; return pOut; } /** * Get the up vector from a matrix. pIn is the matrix you * wish to extract the vector from. pOut is a pointer to the * kmVec3 structure that should hold the resulting vector */ kmVec3* const kmMat4GetUpVec3(kmVec3* pOut, const kmMat4* pIn) { pOut->x = pIn->mat[4]; pOut->y = pIn->mat[5]; pOut->z = pIn->mat[6]; kmVec3Normalize(pOut, pOut); return pOut; } /** Extract the right vector from a 4x4 matrix. The result is * stored in pOut. Returns pOut. */ kmVec3* const kmMat4GetRightVec3(kmVec3* pOut, const kmMat4* pIn) { pOut->x = pIn->mat[0]; pOut->y = pIn->mat[1]; pOut->z = pIn->mat[2]; kmVec3Normalize(pOut, pOut); return pOut; } /** * Extract the forward vector from a 4x4 matrix. The result is * stored in pOut. Returns pOut. */ kmVec3* const kmMat4GetForwardVec3(kmVec3* pOut, const kmMat4* pIn) { pOut->x = pIn->mat[8]; pOut->y = pIn->mat[9]; pOut->z = pIn->mat[10]; kmVec3Normalize(pOut, pOut); return pOut; } /** * Creates a perspective projection matrix in the * same way as gluPerspective */ kmMat4* const kmMat4PerspectiveProjection(kmMat4* pOut, kmScalar fovY, kmScalar aspect, kmScalar zNear, kmScalar zFar) { kmScalar r = kmDegreesToRadians(fovY / 2); kmScalar deltaZ = zFar - zNear; kmScalar s = sin(r); kmScalar cotangent = 0; if (deltaZ == 0 || s == 0 || aspect == 0) { return NULL; } //cos(r) / sin(r) = cot(r) cotangent = cos(r) / s; kmMat4Identity(pOut); pOut->mat[0] = cotangent / aspect; pOut->mat[5] = cotangent; pOut->mat[10] = -(zFar + zNear) / deltaZ; pOut->mat[11] = -1; pOut->mat[14] = -2 * zNear * zFar / deltaZ; pOut->mat[15] = 0; return pOut; } /** Creates an orthographic projection matrix like glOrtho */ kmMat4* const kmMat4OrthographicProjection(kmMat4* pOut, kmScalar left, kmScalar right, kmScalar bottom, kmScalar top, kmScalar nearVal, kmScalar farVal) { kmScalar tx = -((right + left) / (right - left)); kmScalar ty = -((top + bottom) / (top - bottom)); kmScalar tz = -((farVal + nearVal) / (farVal - nearVal)); kmMat4Identity(pOut); pOut->mat[0] = 2 / (right - left); pOut->mat[5] = 2 / (top - bottom); pOut->mat[10] = -2 / (farVal - nearVal); pOut->mat[12] = tx; pOut->mat[13] = ty; pOut->mat[14] = tz; return pOut; } /** * Builds a translation matrix in the same way as gluLookAt() * the resulting matrix is stored in pOut. pOut is returned. */ kmMat4* const kmMat4LookAt(kmMat4* pOut, const kmVec3* pEye, const kmVec3* pCenter, const kmVec3* pUp) { kmVec3 f, up, s, u; kmMat4 translate; kmVec3Subtract(&f, pCenter, pEye); kmVec3Normalize(&f, &f); kmVec3Assign(&up, pUp); kmVec3Normalize(&up, &up); kmVec3Cross(&s, &f, &up); kmVec3Normalize(&s, &s); kmVec3Cross(&u, &s, &f); kmVec3Normalize(&s, &s); kmMat4Identity(pOut); pOut->mat[0] = s.x; pOut->mat[4] = s.y; pOut->mat[8] = s.z; pOut->mat[1] = u.x; pOut->mat[5] = u.y; pOut->mat[9] = u.z; pOut->mat[2] = -f.x; pOut->mat[6] = -f.y; pOut->mat[10] = -f.z; kmMat4Translation(&translate, -pEye->x, -pEye->y, -pEye->z); kmMat4Multiply(pOut, pOut, &translate); return pOut; } /** * Extract a 3x3 rotation matrix from the input 4x4 transformation. * Stores the result in pOut, returns pOut */ kmMat3* const kmMat4ExtractRotation(kmMat3* pOut, const kmMat4* pIn) { pOut->mat[0] = pIn->mat[0]; pOut->mat[1] = pIn->mat[1]; pOut->mat[2] = pIn->mat[2]; pOut->mat[3] = pIn->mat[4]; pOut->mat[4] = pIn->mat[5]; pOut->mat[5] = pIn->mat[6]; pOut->mat[6] = pIn->mat[8]; pOut->mat[7] = pIn->mat[9]; pOut->mat[8] = pIn->mat[10]; return pOut; } /** * Take the rotation from a 4x4 transformation matrix, and return it as an axis and an angle (in radians) * returns the output axis. */ kmVec3* const kmMat4RotationToAxisAngle(kmVec3* pAxis, kmScalar* radians, const kmMat4* pIn) { /*Surely not this easy?*/ kmQuaternion temp; kmMat3 rotation; kmMat4ExtractRotation(&rotation, pIn); kmQuaternionRotationMatrix(&temp, &rotation); kmQuaternionToAxisAngle(&temp, pAxis, radians); return pAxis; } /** Build a 4x4 OpenGL transformation matrix using a 3x3 rotation matrix, * and a 3d vector representing a translation. Assign the result to pOut, * pOut is also returned. */ kmMat4* const kmMat4RotationTranslation(kmMat4* pOut, const kmMat3* rotation, const kmVec3* translation) { pOut->mat[0] = rotation->mat[0]; pOut->mat[1] = rotation->mat[1]; pOut->mat[2] = rotation->mat[2]; pOut->mat[3] = 0.0f; pOut->mat[4] = rotation->mat[3]; pOut->mat[5] = rotation->mat[4]; pOut->mat[6] = rotation->mat[5]; pOut->mat[7] = 0.0f; pOut->mat[8] = rotation->mat[6]; pOut->mat[9] = rotation->mat[7]; pOut->mat[10] = rotation->mat[8]; pOut->mat[11] = 0.0f; pOut->mat[12] = translation->x; pOut->mat[13] = translation->y; pOut->mat[14] = translation->z; pOut->mat[15] = 1.0f; return pOut; } kmPlane* const kmMat4ExtractPlane(kmPlane* pOut, const kmMat4* pIn, const kmEnum plane) { float t = 1.0f; switch(plane) { case KM_PLANE_RIGHT: pOut->a = pIn->mat[3] - pIn->mat[0]; pOut->b = pIn->mat[7] - pIn->mat[4]; pOut->c = pIn->mat[11] - pIn->mat[8]; pOut->d = pIn->mat[15] - pIn->mat[12]; break; case KM_PLANE_LEFT: pOut->a = pIn->mat[3] + pIn->mat[0]; pOut->b = pIn->mat[7] + pIn->mat[4]; pOut->c = pIn->mat[11] + pIn->mat[8]; pOut->d = pIn->mat[15] + pIn->mat[12]; break; case KM_PLANE_BOTTOM: pOut->a = pIn->mat[3] + pIn->mat[1]; pOut->b = pIn->mat[7] + pIn->mat[5]; pOut->c = pIn->mat[11] + pIn->mat[9]; pOut->d = pIn->mat[15] + pIn->mat[13]; break; case KM_PLANE_TOP: pOut->a = pIn->mat[3] - pIn->mat[1]; pOut->b = pIn->mat[7] - pIn->mat[5]; pOut->c = pIn->mat[11] - pIn->mat[9]; pOut->d = pIn->mat[15] - pIn->mat[13]; break; case KM_PLANE_FAR: pOut->a = pIn->mat[3] - pIn->mat[2]; pOut->b = pIn->mat[7] - pIn->mat[6]; pOut->c = pIn->mat[11] - pIn->mat[10]; pOut->d = pIn->mat[15] - pIn->mat[14]; break; case KM_PLANE_NEAR: pOut->a = pIn->mat[3] + pIn->mat[2]; pOut->b = pIn->mat[7] + pIn->mat[6]; pOut->c = pIn->mat[11] + pIn->mat[10]; pOut->d = pIn->mat[15] + pIn->mat[14]; break; default: assert(0 && "Invalid plane index"); } t = sqrtf(pOut->a * pOut->a + pOut->b * pOut->b + pOut->c * pOut->c); pOut->a /= t; pOut->b /= t; pOut->c /= t; pOut->d /= t; return pOut; } ================================================ FILE: cocos2d/cocos/math/kazmath/src/neon_matrix_impl.c ================================================ /* NEON math library for the iPhone / iPod touch Copyright (c) 2009 Justin Saunders This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "kazmath/neon_matrix_impl.h" #if defined(__ARM_NEON__) && !defined(__arm64__) void NEON_Matrix4Mul(const float* a, const float* b, float* output ) { __asm__ volatile ( // Store A & B leaving room for q4-q7, which should be preserved "vldmia %1, { q0-q3 } \n\t" "vldmia %2, { q8-q11 }\n\t" // result = first column of B x first row of A "vmul.f32 q12, q8, d0[0]\n\t" "vmul.f32 q13, q8, d2[0]\n\t" "vmul.f32 q14, q8, d4[0]\n\t" "vmul.f32 q15, q8, d6[0]\n\t" // result += second column of B x second row of A "vmla.f32 q12, q9, d0[1]\n\t" "vmla.f32 q13, q9, d2[1]\n\t" "vmla.f32 q14, q9, d4[1]\n\t" "vmla.f32 q15, q9, d6[1]\n\t" // result += third column of B x third row of A "vmla.f32 q12, q10, d1[0]\n\t" "vmla.f32 q13, q10, d3[0]\n\t" "vmla.f32 q14, q10, d5[0]\n\t" "vmla.f32 q15, q10, d7[0]\n\t" // result += last column of B x last row of A "vmla.f32 q12, q11, d1[1]\n\t" "vmla.f32 q13, q11, d3[1]\n\t" "vmla.f32 q14, q11, d5[1]\n\t" "vmla.f32 q15, q11, d7[1]\n\t" // output = result registers "vstmia %0, { q12-q15 }" : // no output : "r" (output), "r" (a), "r" (b) // input - note *value* of pointer doesn't change : "memory", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15" //clobber ); } void NEON_Matrix4Vector4Mul(const float* m, const float* v, float* output) { __asm__ volatile ( // Store m & v - avoiding q4-q7 which need to be preserved - q0 = result "vldmia %1, { q8-q11 } \n\t" // q8-q11 = m "vldmia %2, { q1 } \n\t" // q1 = v // result = first column of A x V.x "vmul.f32 q0, q8, d2[0]\n\t" // result += second column of A x V.y "vmla.f32 q0, q9, d2[1]\n\t" // result += third column of A x V.z "vmla.f32 q0, q10, d3[0]\n\t" // result += last column of A x V.w "vmla.f32 q0, q11, d3[1]\n\t" // output = result registers "vstmia %0, { q0 }" : // no output : "r" (output), "r" (m), "r" (v) // input - note *value* of pointer doesn't change : "memory", "q0", "q1", "q8", "q9", "q10", "q11" //clobber ); } #endif ================================================ FILE: cocos2d/cocos/math/kazmath/src/plane.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include #include #include "kazmath/vec3.h" #include "kazmath/vec4.h" #include "kazmath/plane.h" const kmScalar kmPlaneDot(const kmPlane* pP, const kmVec4* pV) { //a*x + b*y + c*z + d*w return (pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d * pV->w); } const kmScalar kmPlaneDotCoord(const kmPlane* pP, const kmVec3* pV) { return (pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d); } const kmScalar kmPlaneDotNormal(const kmPlane* pP, const kmVec3* pV) { return (pP->a * pV->x + pP->b * pV->y + pP->c * pV->z); } kmPlane* const kmPlaneFromPointNormal(kmPlane* pOut, const kmVec3* pPoint, const kmVec3* pNormal) { /* Planea = Nx Planeb = Ny Planec = Nz Planed = −N⋅P */ pOut->a = pNormal->x; pOut->b = pNormal->y; pOut->c = pNormal->z; pOut->d = -kmVec3Dot(pNormal, pPoint); return pOut; } /** * Creates a plane from 3 points. The result is stored in pOut. * pOut is returned. */ kmPlane* const kmPlaneFromPoints(kmPlane* pOut, const kmVec3* p1, const kmVec3* p2, const kmVec3* p3) { /* v = (B − A) × (C − A) n = 1⁄|v| v Outa = nx Outb = ny Outc = nz Outd = −n⋅A */ kmVec3 n, v1, v2; kmVec3Subtract(&v1, p2, p1); //Create the vectors for the 2 sides of the triangle kmVec3Subtract(&v2, p3, p1); kmVec3Cross(&n, &v1, &v2); //Use the cross product to get the normal kmVec3Normalize(&n, &n); //Normalize it and assign to pOut->m_N pOut->a = n.x; pOut->b = n.y; pOut->c = n.z; pOut->d = kmVec3Dot(kmVec3Scale(&n, &n, -1.0), p1); return pOut; } kmVec3* const kmPlaneIntersectLine(kmVec3* pOut, const kmPlane* pP, const kmVec3* pV1, const kmVec3* pV2) { /* n = (Planea, Planeb, Planec) d = V − U Out = U − d⋅(Pd + n⋅U)⁄(d⋅n) [iff d⋅n ≠ 0] */ kmVec3 d; assert(0 && "Not implemented"); kmVec3Subtract(&d, pV2, pV1); //Get the direction vector //TODO: Continue here! /*if (fabs(kmVec3Dot(&pP->m_N, &d)) > kmEpsilon) { //If we get here then the plane and line are parallel (i.e. no intersection) pOut = nullptr; //Set to nullptr return pOut; } */ return NULL; } kmPlane* const kmPlaneNormalize(kmPlane* pOut, const kmPlane* pP) { kmVec3 n; kmScalar l = 0; n.x = pP->a; n.y = pP->b; n.z = pP->c; l = 1.0f / kmVec3Length(&n); //Get 1/length kmVec3Normalize(&n, &n); //Normalize the vector and assign to pOut pOut->a = n.x; pOut->b = n.y; pOut->c = n.z; pOut->d = pP->d * l; //Scale the D value and assign to pOut return pOut; } kmPlane* const kmPlaneScale(kmPlane* pOut, const kmPlane* pP, kmScalar s) { assert(0 && "Not implemented"); return NULL; } /** * Returns POINT_INFRONT_OF_PLANE if pP is infront of pIn. Returns * POINT_BEHIND_PLANE if it is behind. Returns POINT_ON_PLANE otherwise */ const POINT_CLASSIFICATION kmPlaneClassifyPoint(const kmPlane* pIn, const kmVec3* pP) { // This function will determine if a point is on, in front of, or behind // the plane. First we store the dot product of the plane and the point. float distance = pIn->a * pP->x + pIn->b * pP->y + pIn->c * pP->z + pIn->d; // Simply put if the dot product is greater than 0 then it is infront of it. // If it is less than 0 then it is behind it. And if it is 0 then it is on it. if(distance > 0.001) return POINT_INFRONT_OF_PLANE; if(distance < -0.001) return POINT_BEHIND_PLANE; return POINT_ON_PLANE; } ================================================ FILE: cocos2d/cocos/math/kazmath/src/quaternion.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include #include #include "kazmath/utility.h" #include "kazmath/mat3.h" #include "kazmath/vec3.h" #include "kazmath/quaternion.h" #ifndef NULL #define NULL ((void *)0) #endif ///< Returns pOut, sets pOut to the conjugate of pIn kmQuaternion* const kmQuaternionConjugate(kmQuaternion* pOut, const kmQuaternion* pIn) { pOut->x = -pIn->x; pOut->y = -pIn->y; pOut->z = -pIn->z; pOut->w = pIn->w; return pOut; } ///< Returns the dot product of the 2 quaternions const kmScalar kmQuaternionDot(const kmQuaternion* q1, const kmQuaternion* q2) { // A dot B = B dot A = AtBt + AxBx + AyBy + AzBz return (q1->w * q2->w + q1->x * q2->x + q1->y * q2->y + q1->z * q2->z); } ///< Returns the exponential of the quaternion kmQuaternion* kmQuaternionExp(kmQuaternion* pOut, const kmQuaternion* pIn) { assert(0); return pOut; } ///< Makes the passed quaternion an identity quaternion kmQuaternion* kmQuaternionIdentity(kmQuaternion* pOut) { pOut->x = 0.0; pOut->y = 0.0; pOut->z = 0.0; pOut->w = 1.0; return pOut; } ///< Returns the inverse of the passed Quaternion kmQuaternion* kmQuaternionInverse(kmQuaternion* pOut, const kmQuaternion* pIn) { kmScalar l = kmQuaternionLength(pIn); kmQuaternion tmp; if (fabs(l) > kmEpsilon) { pOut->x = 0.0; pOut->y = 0.0; pOut->z = 0.0; pOut->w = 0.0; return pOut; } ///Get the conjugute and divide by the length kmQuaternionScale(pOut, kmQuaternionConjugate(&tmp, pIn), 1.0f / l); return pOut; } ///< Returns true if the quaternion is an identity quaternion int kmQuaternionIsIdentity(const kmQuaternion* pIn) { return (pIn->x == 0.0 && pIn->y == 0.0 && pIn->z == 0.0 && pIn->w == 1.0); } ///< Returns the length of the quaternion kmScalar kmQuaternionLength(const kmQuaternion* pIn) { return sqrtf(kmQuaternionLengthSq(pIn)); } ///< Returns the length of the quaternion squared (prevents a sqrt) kmScalar kmQuaternionLengthSq(const kmQuaternion* pIn) { return pIn->x * pIn->x + pIn->y * pIn->y + pIn->z * pIn->z + pIn->w * pIn->w; } ///< Returns the natural logarithm kmQuaternion* kmQuaternionLn(kmQuaternion* pOut, const kmQuaternion* pIn) { /* A unit quaternion, is defined by: Q == (cos(theta), sin(theta) * v) where |v| = 1 The natural logarithm of Q is, ln(Q) = (0, theta * v) */ assert(0); return pOut; } ///< Multiplies 2 quaternions together extern kmQuaternion* kmQuaternionMultiply(kmQuaternion* pOut, const kmQuaternion* q1, const kmQuaternion* q2) { pOut->w = q1->w * q2->w - q1->x * q2->x - q1->y * q2->y - q1->z * q2->z; pOut->x = q1->w * q2->x + q1->x * q2->w + q1->y * q2->z - q1->z * q2->y; pOut->y = q1->w * q2->y + q1->y * q2->w + q1->z * q2->x - q1->x * q2->z; pOut->z = q1->w * q2->z + q1->z * q2->w + q1->x * q2->y - q1->y * q2->x; return pOut; } ///< Normalizes a quaternion kmQuaternion* kmQuaternionNormalize(kmQuaternion* pOut, const kmQuaternion* pIn) { kmScalar length = kmQuaternionLength(pIn); assert(fabs(length) > kmEpsilon); kmQuaternionScale(pOut, pIn, 1.0f / length); return pOut; } ///< Rotates a quaternion around an axis kmQuaternion* kmQuaternionRotationAxis(kmQuaternion* pOut, const kmVec3* pV, kmScalar angle) { kmScalar rad = angle * 0.5f; kmScalar scale = sinf(rad); pOut->w = cosf(rad); pOut->x = pV->x * scale; pOut->y = pV->y * scale; pOut->z = pV->z * scale; return pOut; } ///< Creates a quaternion from a rotation matrix kmQuaternion* kmQuaternionRotationMatrix(kmQuaternion* pOut, const kmMat3* pIn) { /* Note: The OpenGL matrices are transposed from the description below taken from the Matrix and Quaternion FAQ if ( mat[0] > mat[5] && mat[0] > mat[10] ) { // Column 0: S = sqrt( 1.0 + mat[0] - mat[5] - mat[10] ) * 2; X = 0.25 * S; Y = (mat[4] + mat[1] ) / S; Z = (mat[2] + mat[8] ) / S; W = (mat[9] - mat[6] ) / S; } else if ( mat[5] > mat[10] ) { // Column 1: S = sqrt( 1.0 + mat[5] - mat[0] - mat[10] ) * 2; X = (mat[4] + mat[1] ) / S; Y = 0.25 * S; Z = (mat[9] + mat[6] ) / S; W = (mat[2] - mat[8] ) / S; } else { // Column 2: S = sqrt( 1.0 + mat[10] - mat[0] - mat[5] ) * 2; X = (mat[2] + mat[8] ) / S; Y = (mat[9] + mat[6] ) / S; Z = 0.25 * S; W = (mat[4] - mat[1] ) / S; } */ float x, y, z, w; float *pMatrix = NULL; float m4x4[16] = {0}; float scale = 0.0f; float diagonal = 0.0f; if(!pIn) { return NULL; } /* 0 3 6 1 4 7 2 5 8 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15*/ m4x4[0] = pIn->mat[0]; m4x4[1] = pIn->mat[3]; m4x4[2] = pIn->mat[6]; m4x4[4] = pIn->mat[1]; m4x4[5] = pIn->mat[4]; m4x4[6] = pIn->mat[7]; m4x4[8] = pIn->mat[2]; m4x4[9] = pIn->mat[5]; m4x4[10] = pIn->mat[8]; m4x4[15] = 1; pMatrix = &m4x4[0]; diagonal = pMatrix[0] + pMatrix[5] + pMatrix[10] + 1; if(diagonal > kmEpsilon) { // Calculate the scale of the diagonal scale = (float)sqrt(diagonal ) * 2; // Calculate the x, y, x and w of the quaternion through the respective equation x = ( pMatrix[9] - pMatrix[6] ) / scale; y = ( pMatrix[2] - pMatrix[8] ) / scale; z = ( pMatrix[4] - pMatrix[1] ) / scale; w = 0.25f * scale; } else { // If the first element of the diagonal is the greatest value if ( pMatrix[0] > pMatrix[5] && pMatrix[0] > pMatrix[10] ) { // Find the scale according to the first element, and double that value scale = (float)sqrt( 1.0f + pMatrix[0] - pMatrix[5] - pMatrix[10] ) * 2.0f; // Calculate the x, y, x and w of the quaternion through the respective equation x = 0.25f * scale; y = (pMatrix[4] + pMatrix[1] ) / scale; z = (pMatrix[2] + pMatrix[8] ) / scale; w = (pMatrix[9] - pMatrix[6] ) / scale; } // Else if the second element of the diagonal is the greatest value else if (pMatrix[5] > pMatrix[10]) { // Find the scale according to the second element, and double that value scale = (float)sqrt( 1.0f + pMatrix[5] - pMatrix[0] - pMatrix[10] ) * 2.0f; // Calculate the x, y, x and w of the quaternion through the respective equation x = (pMatrix[4] + pMatrix[1] ) / scale; y = 0.25f * scale; z = (pMatrix[9] + pMatrix[6] ) / scale; w = (pMatrix[2] - pMatrix[8] ) / scale; } // Else the third element of the diagonal is the greatest value else { // Find the scale according to the third element, and double that value scale = (float)sqrt( 1.0f + pMatrix[10] - pMatrix[0] - pMatrix[5] ) * 2.0f; // Calculate the x, y, x and w of the quaternion through the respective equation x = (pMatrix[2] + pMatrix[8] ) / scale; y = (pMatrix[9] + pMatrix[6] ) / scale; z = 0.25f * scale; w = (pMatrix[4] - pMatrix[1] ) / scale; } } pOut->x = x; pOut->y = y; pOut->z = z; pOut->w = w; return pOut; #if 0 kmScalar T = pIn->mat[0] + pIn->mat[5] + pIn->mat[10]; if (T > kmEpsilon) { //If the trace is greater than zero we always use this calculation: /* S = sqrt(T) * 2; X = ( mat[9] - mat[6] ) / S; Y = ( mat[2] - mat[8] ) / S; Z = ( mat[4] - mat[1] ) / S; W = 0.25 * S;*/ /* kmScalar s = sqrtf(T) * 2; pOut->x = (pIn->mat[9] - pIn->mat[6]) / s; pOut->y = (pIn->mat[8] - pIn->mat[2]) / s; pOut->z = (pIn->mat[1] - pIn->mat[4]) / s; pOut->w = 0.25f * s; kmQuaternionNormalize(pOut, pOut); return pOut; } //Otherwise the calculation depends on which major diagonal element has the greatest value. if (pIn->mat[0] > pIn->mat[5] && pIn->mat[0] > pIn->mat[10]) { kmScalar s = sqrtf(1 + pIn->mat[0] - pIn->mat[5] - pIn->mat[10]) * 2; pOut->x = 0.25f * s; pOut->y = (pIn->mat[1] + pIn->mat[4]) / s; pOut->z = (pIn->mat[8] + pIn->mat[2]) / s; pOut->w = (pIn->mat[9] - pIn->mat[6]) / s; } else if (pIn->mat[5] > pIn->mat[10]) { kmScalar s = sqrtf(1 + pIn->mat[5] - pIn->mat[0] - pIn->mat[10]) * 2; pOut->x = (pIn->mat[1] + pIn->mat[4]) / s; pOut->y = 0.25f * s; pOut->z = (pIn->mat[9] + pIn->mat[6]) / s; pOut->w = (pIn->mat[8] - pIn->mat[2]) / s; } else { kmScalar s = sqrt(1.0f + pIn->mat[10] - pIn->mat[0] - pIn->mat[5]) * 2.0f; pOut->x = (pIn->mat[8] + pIn->mat[2] ) / s; pOut->y = (pIn->mat[6] + pIn->mat[9] ) / s; pOut->z = 0.25f * s; pOut->w = (pIn->mat[1] - pIn->mat[4] ) / s; } kmQuaternionNormalize(pOut, pOut); return pOut;*/ #endif // 0 } ///< Create a quaternion from yaw, pitch and roll kmQuaternion* kmQuaternionRotationYawPitchRoll(kmQuaternion* pOut, kmScalar yaw, kmScalar pitch, kmScalar roll) { kmScalar ex, ey, ez; // temp half euler angles kmScalar cr, cp, cy, sr, sp, sy, cpcy, spsy; // temp vars in roll,pitch yaw ex = kmDegreesToRadians(pitch) / 2.0f; // convert to rads and half them ey = kmDegreesToRadians(yaw) / 2.0f; ez = kmDegreesToRadians(roll) / 2.0f; cr = cosf(ex); cp = cosf(ey); cy = cosf(ez); sr = sinf(ex); sp = sinf(ey); sy = sinf(ez); cpcy = cp * cy; spsy = sp * sy; pOut->w = cr * cpcy + sr * spsy; pOut->x = sr * cpcy - cr * spsy; pOut->y = cr * sp * cy + sr * cp * sy; pOut->z = cr * cp * sy - sr * sp * cy; kmQuaternionNormalize(pOut, pOut); return pOut; } ///< Interpolate between 2 quaternions kmQuaternion* kmQuaternionSlerp(kmQuaternion* pOut, const kmQuaternion* q1, const kmQuaternion* q2, kmScalar t) { /*float CosTheta = Q0.DotProd(Q1); float Theta = acosf(CosTheta); float SinTheta = sqrtf(1.0f-CosTheta*CosTheta); float Sin_T_Theta = sinf(T*Theta)/SinTheta; float Sin_OneMinusT_Theta = sinf((1.0f-T)*Theta)/SinTheta; Quaternion Result = Q0*Sin_OneMinusT_Theta; Result += (Q1*Sin_T_Theta); return Result;*/ if (q1->x == q2->x && q1->y == q2->y && q1->z == q2->z && q1->w == q2->w) { pOut->x = q1->x; pOut->y = q1->y; pOut->z = q1->z; pOut->w = q1->w; return pOut; } { kmScalar ct = kmQuaternionDot(q1, q2); kmScalar theta = acosf(ct); kmScalar st = sqrtf(1.0 - kmSQR(ct)); kmScalar stt = sinf(t * theta) / st; kmScalar somt = sinf((1.0 - t) * theta) / st; kmQuaternion temp, temp2; kmQuaternionScale(&temp, q1, somt); kmQuaternionScale(&temp2, q2, stt); kmQuaternionAdd(pOut, &temp, &temp2); } return pOut; } ///< Get the axis and angle of rotation from a quaternion void kmQuaternionToAxisAngle(const kmQuaternion* pIn, kmVec3* pAxis, kmScalar* pAngle) { kmScalar tempAngle; // temp angle kmScalar scale; // temp vars tempAngle = acosf(pIn->w); scale = sqrtf(kmSQR(pIn->x) + kmSQR(pIn->y) + kmSQR(pIn->z)); if (((scale > -kmEpsilon) && scale < kmEpsilon) || (scale < 2*kmPI + kmEpsilon && scale > 2*kmPI - kmEpsilon)) // angle is 0 or 360 so just simply set axis to 0,0,1 with angle 0 { *pAngle = 0.0f; pAxis->x = 0.0f; pAxis->y = 0.0f; pAxis->z = 1.0f; } else { *pAngle = tempAngle * 2.0f; // angle in radians pAxis->x = pIn->x / scale; pAxis->y = pIn->y / scale; pAxis->z = pIn->z / scale; kmVec3Normalize(pAxis, pAxis); } } kmQuaternion* kmQuaternionScale(kmQuaternion* pOut, const kmQuaternion* pIn, kmScalar s) { pOut->x = pIn->x * s; pOut->y = pIn->y * s; pOut->z = pIn->z * s; pOut->w = pIn->w * s; return pOut; } kmQuaternion* kmQuaternionAssign(kmQuaternion* pOut, const kmQuaternion* pIn) { memcpy(pOut, pIn, sizeof(float) * 4); return pOut; } kmQuaternion* kmQuaternionAdd(kmQuaternion* pOut, const kmQuaternion* pQ1, const kmQuaternion* pQ2) { pOut->x = pQ1->x + pQ2->x; pOut->y = pQ1->y + pQ2->y; pOut->z = pQ1->z + pQ2->z; pOut->w = pQ1->w + pQ2->w; return pOut; } /** Adapted from the OGRE engine! Gets the shortest arc quaternion to rotate this vector to the destination vector. @remarks If you call this with a dest vector that is close to the inverse of this vector, we will rotate 180 degrees around the 'fallbackAxis' (if specified, or a generated axis if not) since in this case ANY axis of rotation is valid. */ kmQuaternion* kmQuaternionRotationBetweenVec3(kmQuaternion* pOut, const kmVec3* vec1, const kmVec3* vec2, const kmVec3* fallback) { kmVec3 v1, v2; kmScalar a; kmVec3Assign(&v1, vec1); kmVec3Assign(&v2, vec2); kmVec3Normalize(&v1, &v1); kmVec3Normalize(&v2, &v2); a = kmVec3Dot(&v1, &v2); if (a >= 1.0) { kmQuaternionIdentity(pOut); return pOut; } if (a < (1e-6f - 1.0f)) { if (fabs(kmVec3LengthSq(fallback)) < kmEpsilon) { kmQuaternionRotationAxis(pOut, fallback, kmPI); } else { kmVec3 axis; kmVec3 X; X.x = 1.0; X.y = 0.0; X.z = 0.0; kmVec3Cross(&axis, &X, vec1); //If axis is zero if (fabs(kmVec3LengthSq(&axis)) < kmEpsilon) { kmVec3 Y; Y.x = 0.0; Y.y = 1.0; Y.z = 0.0; kmVec3Cross(&axis, &Y, vec1); } kmVec3Normalize(&axis, &axis); kmQuaternionRotationAxis(pOut, &axis, kmPI); } } else { kmScalar s = sqrtf((1+a) * 2); kmScalar invs = 1 / s; kmVec3 c; kmVec3Cross(&c, &v1, &v2); pOut->x = c.x * invs; pOut->y = c.y * invs; pOut->z = c.z * invs; pOut->w = s * 0.5f; kmQuaternionNormalize(pOut, pOut); } return pOut; } kmVec3* kmQuaternionMultiplyVec3(kmVec3* pOut, const kmQuaternion* q, const kmVec3* v) { kmVec3 uv, uuv, qvec; qvec.x = q->x; qvec.y = q->y; qvec.z = q->z; kmVec3Cross(&uv, &qvec, v); kmVec3Cross(&uuv, &qvec, &uv); kmVec3Scale(&uv, &uv, (2.0f * q->w)); kmVec3Scale(&uuv, &uuv, 2.0f); kmVec3Add(pOut, v, &uv); kmVec3Add(pOut, pOut, &uuv); return pOut; } ================================================ FILE: cocos2d/cocos/math/kazmath/src/ray2.c ================================================ #include #include #include "kazmath/ray2.h" void kmRay2Fill(kmRay2* ray, kmScalar px, kmScalar py, kmScalar vx, kmScalar vy) { ray->start.x = px; ray->start.y = py; ray->dir.x = vx; ray->dir.y = vy; } kmBool kmRay2IntersectLineSegment(const kmRay2* ray, const kmVec2* p1, const kmVec2* p2, kmVec2* intersection) { float x1 = ray->start.x; float y1 = ray->start.y; float x2 = ray->start.x + ray->dir.x; float y2 = ray->start.y + ray->dir.y; float x3 = p1->x; float y3 = p1->y; float x4 = p2->x; float y4 = p2->y; float denom = (y4 -y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); float ua, x, y; //If denom is zero, the lines are parallel if(denom > -kmEpsilon && denom < kmEpsilon) { return KM_FALSE; } ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denom; // float ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denom; x = x1 + ua * (x2 - x1); y = y1 + ua * (y2 - y1); if(x < kmMin(p1->x, p2->x) - kmEpsilon || x > kmMax(p1->x, p2->x) + kmEpsilon || y < kmMin(p1->y, p2->y) - kmEpsilon || y > kmMax(p1->y, p2->y) + kmEpsilon) { //Outside of line //printf("Outside of line, %f %f (%f %f)(%f, %f)\n", x, y, p1->x, p1->y, p2->x, p2->y); return KM_FALSE; } if(x < kmMin(x1, x2) - kmEpsilon || x > kmMax(x1, x2) + kmEpsilon || y < kmMin(y1, y2) - kmEpsilon || y > kmMax(y1, y2) + kmEpsilon) { //printf("Outside of ray, %f %f (%f %f)(%f, %f)\n", x, y, x1, y1, x2, y2); return KM_FALSE; } intersection->x = x; intersection->y = y; return KM_TRUE; /* kmScalar A1, B1, C1; kmScalar A2, B2, C2; A1 = ray->dir.y; B1 = ray->dir.x; C1 = A1 * ray->start.x + B1 * ray->start.y; A2 = p2->y - p1->y; B2 = p2->x - p1->x; C2 = A2 * p1->x + B2 * p1->y; double det = (A1 * B2) - (A2 * B1); if(det == 0) { printf("Parallel\n"); return KM_FALSE; } double x = (B2*C1 - B1*C2) / det; double y = (A1*C2 - A2*C1) / det; if(x < min(p1->x, p2->x) - kmEpsilon || x > max(p1->x, p2->x) + kmEpsilon || y < min(p1->y, p2->y) - kmEpsilon || y > max(p1->y, p2->y) + kmEpsilon) { //Outside of line printf("Outside of line, %f %f (%f %f)(%f, %f)\n", x, y, p1->x, p1->y, p2->x, p2->y); return KM_FALSE; } kmScalar x1 = ray->start.x; kmScalar x2 = ray->start.x + ray->dir.x; kmScalar y1 = ray->start.y; kmScalar y2 = ray->start.y + ray->dir.y; if(x < min(x1, x2) - kmEpsilon || x > max(x1, x2) + kmEpsilon || y < min(y1, y2) - kmEpsilon || y > max(y1, y2) + kmEpsilon) { printf("Outside of ray, %f %f (%f %f)(%f, %f)\n", x, y, x1, y1, x2, y2); return KM_FALSE; } intersection->x = x; intersection->y = y; return KM_TRUE;*/ } void calculate_line_normal(kmVec2 p1, kmVec2 p2, kmVec2* normal_out) { kmVec2 tmp; kmVec2Subtract(&tmp, &p2, &p1); //Get direction vector normal_out->x = -tmp.y; normal_out->y = tmp.x; kmVec2Normalize(normal_out, normal_out); //TODO: should check that the normal is pointing out of the triangle } kmBool kmRay2IntersectTriangle(const kmRay2* ray, const kmVec2* p1, const kmVec2* p2, const kmVec2* p3, kmVec2* intersection, kmVec2* normal_out) { kmVec2 intersect; kmVec2 final_intersect = {0., 0.}, normal = {0., 0.}; // Silencing LLVM SA. kmScalar distance = 10000.0f; kmBool intersected = KM_FALSE; if(kmRay2IntersectLineSegment(ray, p1, p2, &intersect)) { kmVec2 tmp; kmScalar this_distance; intersected = KM_TRUE; this_distance = kmVec2Length(kmVec2Subtract(&tmp, &intersect, &ray->start)); if(this_distance < distance) { final_intersect.x = intersect.x; final_intersect.y = intersect.y; distance = this_distance; calculate_line_normal(*p1, *p2, &normal); } } if(kmRay2IntersectLineSegment(ray, p2, p3, &intersect)) { kmVec2 tmp; kmScalar this_distance; intersected = KM_TRUE; this_distance = kmVec2Length(kmVec2Subtract(&tmp, &intersect, &ray->start)); if(this_distance < distance) { final_intersect.x = intersect.x; final_intersect.y = intersect.y; distance = this_distance; calculate_line_normal(*p2, *p3, &normal); } } if(kmRay2IntersectLineSegment(ray, p3, p1, &intersect)) { kmVec2 tmp; kmScalar this_distance; intersected = KM_TRUE; this_distance = kmVec2Length(kmVec2Subtract(&tmp, &intersect, &ray->start)); if(this_distance < distance) { final_intersect.x = intersect.x; final_intersect.y = intersect.y; //distance = this_distance; calculate_line_normal(*p3, *p1, &normal); } } if(intersected) { intersection->x = final_intersect.x; intersection->y = final_intersect.y; if(normal_out) { normal_out->x = normal.x; normal_out->y = normal.y; } } return intersected; } kmBool kmRay2IntersectCircle(const kmRay2* ray, const kmVec2 centre, const kmScalar radius, kmVec2* intersection) { assert(0 && "Not implemented"); return 0; } ================================================ FILE: cocos2d/cocos/math/kazmath/src/utility.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include "kazmath/utility.h" /** * Returns the square of s (e.g. s*s) */ kmScalar kmSQR(kmScalar s) { return s*s; } /** * Returns degrees as radians. */ kmScalar kmDegreesToRadians(kmScalar degrees) { return degrees * kmPIOver180; } /** * Returns radians as degrees */ kmScalar kmRadiansToDegrees(kmScalar radians) { return radians * kmPIUnder180; } kmScalar kmMin(kmScalar lhs, kmScalar rhs) { return (lhs < rhs)? lhs : rhs; } kmScalar kmMax(kmScalar lhs, kmScalar rhs) { return (lhs > rhs)? lhs : rhs; } kmBool kmAlmostEqual(kmScalar lhs, kmScalar rhs) { return (lhs + kmEpsilon > rhs && lhs - kmEpsilon < rhs); } ================================================ FILE: cocos2d/cocos/math/kazmath/src/vec2.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include #include #include "kazmath/mat3.h" #include "kazmath/vec2.h" #include "kazmath/utility.h" kmVec2* kmVec2Fill(kmVec2* pOut, kmScalar x, kmScalar y) { pOut->x = x; pOut->y = y; return pOut; } kmScalar kmVec2Length(const kmVec2* pIn) { return sqrtf(kmSQR(pIn->x) + kmSQR(pIn->y)); } kmScalar kmVec2LengthSq(const kmVec2* pIn) { return kmSQR(pIn->x) + kmSQR(pIn->y); } kmVec2* kmVec2Normalize(kmVec2* pOut, const kmVec2* pIn) { kmScalar l = 1.0f / kmVec2Length(pIn); kmVec2 v; v.x = pIn->x * l; v.y = pIn->y * l; pOut->x = v.x; pOut->y = v.y; return pOut; } kmVec2* kmVec2Add(kmVec2* pOut, const kmVec2* pV1, const kmVec2* pV2) { pOut->x = pV1->x + pV2->x; pOut->y = pV1->y + pV2->y; return pOut; } kmScalar kmVec2Dot(const kmVec2* pV1, const kmVec2* pV2) { return pV1->x * pV2->x + pV1->y * pV2->y; } kmVec2* kmVec2Subtract(kmVec2* pOut, const kmVec2* pV1, const kmVec2* pV2) { pOut->x = pV1->x - pV2->x; pOut->y = pV1->y - pV2->y; return pOut; } kmVec2* kmVec2Transform(kmVec2* pOut, const kmVec2* pV, const kmMat3* pM) { kmVec2 v; v.x = pV->x * pM->mat[0] + pV->y * pM->mat[3] + pM->mat[6]; v.y = pV->x * pM->mat[1] + pV->y * pM->mat[4] + pM->mat[7]; pOut->x = v.x; pOut->y = v.y; return pOut; } kmVec2* kmVec2TransformCoord(kmVec2* pOut, const kmVec2* pV, const kmMat3* pM) { assert(0); return NULL; } kmVec2* kmVec2Scale(kmVec2* pOut, const kmVec2* pIn, const kmScalar s) { pOut->x = pIn->x * s; pOut->y = pIn->y * s; return pOut; } int kmVec2AreEqual(const kmVec2* p1, const kmVec2* p2) { return ( (p1->x < p2->x + kmEpsilon && p1->x > p2->x - kmEpsilon) && (p1->y < p2->y + kmEpsilon && p1->y > p2->y - kmEpsilon) ); } ================================================ FILE: cocos2d/cocos/math/kazmath/src/vec3.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ /** * @file vec3.c */ #include #include #include "kazmath/utility.h" #include "kazmath/vec4.h" #include "kazmath/mat4.h" #include "kazmath/vec3.h" /** * Fill a kmVec3 structure using 3 floating point values * The result is store in pOut, returns pOut */ kmVec3* kmVec3Fill(kmVec3* pOut, kmScalar x, kmScalar y, kmScalar z) { pOut->x = x; pOut->y = y; pOut->z = z; return pOut; } /** * Returns the length of the vector */ kmScalar kmVec3Length(const kmVec3* pIn) { return sqrtf(kmSQR(pIn->x) + kmSQR(pIn->y) + kmSQR(pIn->z)); } /** * Returns the square of the length of the vector */ kmScalar kmVec3LengthSq(const kmVec3* pIn) { return kmSQR(pIn->x) + kmSQR(pIn->y) + kmSQR(pIn->z); } /** * Returns the vector passed in set to unit length * the result is stored in pOut. */ kmVec3* kmVec3Normalize(kmVec3* pOut, const kmVec3* pIn) { kmScalar l = 1.0f / kmVec3Length(pIn); kmVec3 v; v.x = pIn->x * l; v.y = pIn->y * l; v.z = pIn->z * l; pOut->x = v.x; pOut->y = v.y; pOut->z = v.z; return pOut; } /** * Returns a vector perpendicular to 2 other vectors. * The result is stored in pOut. */ kmVec3* kmVec3Cross(kmVec3* pOut, const kmVec3* pV1, const kmVec3* pV2) { kmVec3 v; v.x = (pV1->y * pV2->z) - (pV1->z * pV2->y); v.y = (pV1->z * pV2->x) - (pV1->x * pV2->z); v.z = (pV1->x * pV2->y) - (pV1->y * pV2->x); pOut->x = v.x; pOut->y = v.y; pOut->z = v.z; return pOut; } /** * Returns the cosine of the angle between 2 vectors */ kmScalar kmVec3Dot(const kmVec3* pV1, const kmVec3* pV2) { return ( pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z ); } /** * Adds 2 vectors and returns the result. The resulting * vector is stored in pOut. */ kmVec3* kmVec3Add(kmVec3* pOut, const kmVec3* pV1, const kmVec3* pV2) { kmVec3 v; v.x = pV1->x + pV2->x; v.y = pV1->y + pV2->y; v.z = pV1->z + pV2->z; pOut->x = v.x; pOut->y = v.y; pOut->z = v.z; return pOut; } /** * Subtracts 2 vectors and returns the result. The result is stored in * pOut. */ kmVec3* kmVec3Subtract(kmVec3* pOut, const kmVec3* pV1, const kmVec3* pV2) { kmVec3 v; v.x = pV1->x - pV2->x; v.y = pV1->y - pV2->y; v.z = pV1->z - pV2->z; pOut->x = v.x; pOut->y = v.y; pOut->z = v.z; return pOut; } /** * Transforms vector (x, y, z, 1) by a given matrix. The result * is stored in pOut. pOut is returned. */ kmVec3* kmVec3Transform(kmVec3* pOut, const kmVec3* pV, const kmMat4* pM) { /* a = (Vx, Vy, Vz, 1) b = (a×M)T Out = (bx, by, bz) */ kmVec3 v; v.x = pV->x * pM->mat[0] + pV->y * pM->mat[4] + pV->z * pM->mat[8] + pM->mat[12]; v.y = pV->x * pM->mat[1] + pV->y * pM->mat[5] + pV->z * pM->mat[9] + pM->mat[13]; v.z = pV->x * pM->mat[2] + pV->y * pM->mat[6] + pV->z * pM->mat[10] + pM->mat[14]; pOut->x = v.x; pOut->y = v.y; pOut->z = v.z; return pOut; } kmVec3* kmVec3InverseTransform(kmVec3* pOut, const kmVec3* pVect, const kmMat4* pM) { kmVec3 v1, v2; v1.x = pVect->x - pM->mat[12]; v1.y = pVect->y - pM->mat[13]; v1.z = pVect->z - pM->mat[14]; v2.x = v1.x * pM->mat[0] + v1.y * pM->mat[1] + v1.z * pM->mat[2]; v2.y = v1.x * pM->mat[4] + v1.y * pM->mat[5] + v1.z * pM->mat[6]; v2.z = v1.x * pM->mat[8] + v1.y * pM->mat[9] + v1.z * pM->mat[10]; pOut->x = v2.x; pOut->y = v2.y; pOut->z = v2.z; return pOut; } kmVec3* kmVec3InverseTransformNormal(kmVec3* pOut, const kmVec3* pVect, const kmMat4* pM) { kmVec3 v; v.x = pVect->x * pM->mat[0] + pVect->y * pM->mat[1] + pVect->z * pM->mat[2]; v.y = pVect->x * pM->mat[4] + pVect->y * pM->mat[5] + pVect->z * pM->mat[6]; v.z = pVect->x * pM->mat[8] + pVect->y * pM->mat[9] + pVect->z * pM->mat[10]; pOut->x = v.x; pOut->y = v.y; pOut->z = v.z; return pOut; } kmVec3* kmVec3TransformCoord(kmVec3* pOut, const kmVec3* pV, const kmMat4* pM) { /* a = (Vx, Vy, Vz, 1) b = (a×M)T Out = 1⁄bw(bx, by, bz) */ kmVec4 v; kmVec4 inV; kmVec4Fill(&inV, pV->x, pV->y, pV->z, 1.0); kmVec4Transform(&v, &inV,pM); pOut->x = v.x / v.w; pOut->y = v.y / v.w; pOut->z = v.z / v.w; return pOut; } kmVec3* kmVec3TransformNormal(kmVec3* pOut, const kmVec3* pV, const kmMat4* pM) { /* a = (Vx, Vy, Vz, 0) b = (a×M)T Out = (bx, by, bz) */ //Omits the translation, only scaling + rotating kmVec3 v; v.x = pV->x * pM->mat[0] + pV->y * pM->mat[4] + pV->z * pM->mat[8]; v.y = pV->x * pM->mat[1] + pV->y * pM->mat[5] + pV->z * pM->mat[9]; v.z = pV->x * pM->mat[2] + pV->y * pM->mat[6] + pV->z * pM->mat[10]; pOut->x = v.x; pOut->y = v.y; pOut->z = v.z; return pOut; } /** * Scales a vector to length s. Does not normalize first, * you should do that! */ kmVec3* kmVec3Scale(kmVec3* pOut, const kmVec3* pIn, const kmScalar s) { pOut->x = pIn->x * s; pOut->y = pIn->y * s; pOut->z = pIn->z * s; return pOut; } /** * Returns KM_TRUE if the 2 vectors are approximately equal */ int kmVec3AreEqual(const kmVec3* p1, const kmVec3* p2) { if ((p1->x < (p2->x + kmEpsilon) && p1->x > (p2->x - kmEpsilon)) && (p1->y < (p2->y + kmEpsilon) && p1->y > (p2->y - kmEpsilon)) && (p1->z < (p2->z + kmEpsilon) && p1->z > (p2->z - kmEpsilon))) { return 1; } return 0; } /** * Assigns pIn to pOut. Returns pOut. If pIn and pOut are the same * then nothing happens but pOut is still returned */ kmVec3* kmVec3Assign(kmVec3* pOut, const kmVec3* pIn) { if (pOut == pIn) { return pOut; } pOut->x = pIn->x; pOut->y = pIn->y; pOut->z = pIn->z; return pOut; } /** * Sets all the elements of pOut to zero. Returns pOut. */ kmVec3* kmVec3Zero(kmVec3* pOut) { pOut->x = 0.0f; pOut->y = 0.0f; pOut->z = 0.0f; return pOut; } ================================================ FILE: cocos2d/cocos/math/kazmath/src/vec4.c ================================================ /* Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ #include #include #include "kazmath/utility.h" #include "kazmath/vec4.h" #include "kazmath/mat4.h" kmVec4* kmVec4Fill(kmVec4* pOut, kmScalar x, kmScalar y, kmScalar z, kmScalar w) { pOut->x = x; pOut->y = y; pOut->z = z; pOut->w = w; return pOut; } /// Adds 2 4D vectors together. The result is store in pOut, the function returns /// pOut so that it can be nested in another function. kmVec4* kmVec4Add(kmVec4* pOut, const kmVec4* pV1, const kmVec4* pV2) { pOut->x = pV1->x + pV2->x; pOut->y = pV1->y + pV2->y; pOut->z = pV1->z + pV2->z; pOut->w = pV1->w + pV2->w; return pOut; } /// Returns the dot product of 2 4D vectors kmScalar kmVec4Dot(const kmVec4* pV1, const kmVec4* pV2) { return ( pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z + pV1->w * pV2->w ); } /// Returns the length of a 4D vector, this uses a sqrt so if the squared length will do use /// kmVec4LengthSq kmScalar kmVec4Length(const kmVec4* pIn) { return sqrtf(kmSQR(pIn->x) + kmSQR(pIn->y) + kmSQR(pIn->z) + kmSQR(pIn->w)); } /// Returns the length of the 4D vector squared. kmScalar kmVec4LengthSq(const kmVec4* pIn) { return kmSQR(pIn->x) + kmSQR(pIn->y) + kmSQR(pIn->z) + kmSQR(pIn->w); } /// Returns the interpolation of 2 4D vectors based on t. Currently not implemented! kmVec4* kmVec4Lerp(kmVec4* pOut, const kmVec4* pV1, const kmVec4* pV2, kmScalar t) { assert(0); return pOut; } /// Normalizes a 4D vector. The result is stored in pOut. pOut is returned kmVec4* kmVec4Normalize(kmVec4* pOut, const kmVec4* pIn) { kmScalar l = 1.0f / kmVec4Length(pIn); pOut->x *= l; pOut->y *= l; pOut->z *= l; pOut->w *= l; return pOut; } /// Scales a vector to the required length. This performs a Normalize before multiplying by S. kmVec4* kmVec4Scale(kmVec4* pOut, const kmVec4* pIn, const kmScalar s) { kmVec4Normalize(pOut, pIn); pOut->x *= s; pOut->y *= s; pOut->z *= s; pOut->w *= s; return pOut; } /// Subtracts one 4D pV2 from pV1. The result is stored in pOut. pOut is returned kmVec4* kmVec4Subtract(kmVec4* pOut, const kmVec4* pV1, const kmVec4* pV2) { pOut->x = pV1->x - pV2->x; pOut->y = pV1->y - pV2->y; pOut->z = pV1->z - pV2->z; pOut->w = pV1->w - pV2->w; return pOut; } /// Transforms a 4D vector by a matrix, the result is stored in pOut, and pOut is returned. kmVec4* kmVec4Transform(kmVec4* pOut, const kmVec4* pV, const kmMat4* pM) { pOut->x = pV->x * pM->mat[0] + pV->y * pM->mat[4] + pV->z * pM->mat[8] + pV->w * pM->mat[12]; pOut->y = pV->x * pM->mat[1] + pV->y * pM->mat[5] + pV->z * pM->mat[9] + pV->w * pM->mat[13]; pOut->z = pV->x * pM->mat[2] + pV->y * pM->mat[6] + pV->z * pM->mat[10] + pV->w * pM->mat[14]; pOut->w = pV->x * pM->mat[3] + pV->y * pM->mat[7] + pV->z * pM->mat[11] + pV->w * pM->mat[15]; return pOut; } /// Loops through an input array transforming each vec4 by the matrix. kmVec4* kmVec4TransformArray(kmVec4* pOut, unsigned int outStride, const kmVec4* pV, unsigned int vStride, const kmMat4* pM, unsigned int count) { unsigned int i = 0; //Go through all of the vectors while (i < count) { const kmVec4* in = pV + (i * vStride); //Get a pointer to the current input kmVec4* out = pOut + (i * outStride); //and the current output kmVec4Transform(out, in, pM); //Perform transform on it ++i; } return pOut; } int kmVec4AreEqual(const kmVec4* p1, const kmVec4* p2) { return ( (p1->x < p2->x + kmEpsilon && p1->x > p2->x - kmEpsilon) && (p1->y < p2->y + kmEpsilon && p1->y > p2->y - kmEpsilon) && (p1->z < p2->z + kmEpsilon && p1->z > p2->z - kmEpsilon) && (p1->w < p2->w + kmEpsilon && p1->w > p2->w - kmEpsilon) ); } kmVec4* kmVec4Assign(kmVec4* pOut, const kmVec4* pIn) { assert(pOut != pIn); memcpy(pOut, pIn, sizeof(float) * 4); return pOut; } ================================================ FILE: cocos2d/cocos/network/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos_network_static LOCAL_MODULE_FILENAME := libnetwork LOCAL_SRC_FILES := HttpClient.cpp \ SocketIO.cpp \ WebSocket.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \ $(LOCAL_PATH)/.. LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_curl_static LOCAL_WHOLE_STATIC_LIBRARIES += libwebsockets_static include $(BUILD_STATIC_LIBRARY) $(call import-module,2d) $(call import-module,curl/prebuilt/android) $(call import-module, websockets/prebuilt/android) ================================================ FILE: cocos2d/cocos/network/CMakeLists.txt ================================================ if(WIN32) set(PLATFORM_SRC WebSocket.cpp ) set(PLATFORM_LINK websockets ) endif() set(NETWORK_SRC HttpClient.cpp SocketIO.cpp ${PLATFORM_SRC} ) add_library(network STATIC ${NETWORK_SRC} ) target_link_libraries(network curl ${PLATFORM_LINK} ) set_target_properties(network PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/network/HttpClient.cpp ================================================ /**************************************************************************** Copyright (c) 2012 greathqy Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "HttpClient.h" #include #include #include #include #include "CCVector.h" #include "CCDirector.h" #include "CCScheduler.h" #include "curl/curl.h" #include "platform/CCFileUtils.h" NS_CC_BEGIN namespace network { static std::mutex s_requestQueueMutex; static std::mutex s_responseQueueMutex; static std::mutex s_SleepMutex; static std::condition_variable s_SleepCondition; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) typedef int int32_t; #endif static bool s_need_quit = false; static Vector* s_requestQueue = nullptr; static Vector* s_responseQueue = nullptr; static HttpClient *s_pHttpClient = nullptr; // pointer to singleton static char s_errorBuffer[CURL_ERROR_SIZE] = {0}; typedef size_t (*write_callback)(void *ptr, size_t size, size_t nmemb, void *stream); static std::string s_cookieFilename = ""; // Callback function used by libcurl for collect response data static size_t writeData(void *ptr, size_t size, size_t nmemb, void *stream) { std::vector *recvBuffer = (std::vector*)stream; size_t sizes = size * nmemb; // add data to the end of recvBuffer // write data maybe called more than once in a single request recvBuffer->insert(recvBuffer->end(), (char*)ptr, (char*)ptr+sizes); return sizes; } // Callback function used by libcurl for collect header data static size_t writeHeaderData(void *ptr, size_t size, size_t nmemb, void *stream) { std::vector *recvBuffer = (std::vector*)stream; size_t sizes = size * nmemb; // add data to the end of recvBuffer // write data maybe called more than once in a single request recvBuffer->insert(recvBuffer->end(), (char*)ptr, (char*)ptr+sizes); return sizes; } static int processGetTask(HttpRequest *request, write_callback callback, void *stream, long *errorCode, write_callback headerCallback, void *headerStream); static int processPostTask(HttpRequest *request, write_callback callback, void *stream, long *errorCode, write_callback headerCallback, void *headerStream); static int processPutTask(HttpRequest *request, write_callback callback, void *stream, long *errorCode, write_callback headerCallback, void *headerStream); static int processDeleteTask(HttpRequest *request, write_callback callback, void *stream, long *errorCode, write_callback headerCallback, void *headerStream); // int processDownloadTask(HttpRequest *task, write_callback callback, void *stream, int32_t *errorCode); // Worker thread void HttpClient::networkThread() { HttpRequest *request = nullptr; auto scheduler = Director::getInstance()->getScheduler(); while (true) { if (s_need_quit) { break; } // step 1: send http request if the requestQueue isn't empty request = nullptr; s_requestQueueMutex.lock(); //Get request task from queue if (!s_requestQueue->empty()) { request = s_requestQueue->at(0); s_requestQueue->erase(0); } s_requestQueueMutex.unlock(); if (nullptr == request) { // Wait for http request tasks from main thread std::unique_lock lk(s_SleepMutex); s_SleepCondition.wait(lk); continue; } // step 2: libcurl sync access // Create a HttpResponse object, the default setting is http access failed HttpResponse *response = new HttpResponse(request); // request's refcount = 2 here, it's retained by HttpRespose constructor request->release(); // ok, refcount = 1 now, only HttpResponse hold it. long responseCode = -1; int retValue = 0; // Process the request -> get response packet switch (request->getRequestType()) { case HttpRequest::Type::GET: // HTTP GET retValue = processGetTask(request, writeData, response->getResponseData(), &responseCode, writeHeaderData, response->getResponseHeader()); break; case HttpRequest::Type::POST: // HTTP POST retValue = processPostTask(request, writeData, response->getResponseData(), &responseCode, writeHeaderData, response->getResponseHeader()); break; case HttpRequest::Type::PUT: retValue = processPutTask(request, writeData, response->getResponseData(), &responseCode, writeHeaderData, response->getResponseHeader()); break; case HttpRequest::Type::DELETE: retValue = processDeleteTask(request, writeData, response->getResponseData(), &responseCode, writeHeaderData, response->getResponseHeader()); break; default: CCASSERT(true, "CCHttpClient: unkown request type, only GET and POSt are supported"); break; } // write data to HttpResponse response->setResponseCode(responseCode); if (retValue != 0) { response->setSucceed(false); response->setErrorBuffer(s_errorBuffer); } else { response->setSucceed(true); } // add response packet into queue s_responseQueueMutex.lock(); s_responseQueue->pushBack(response); s_responseQueueMutex.unlock(); scheduler->performFunctionInCocosThread(CC_CALLBACK_0(HttpClient::dispatchResponseCallbacks, this)); } // cleanup: if worker thread received quit signal, clean up un-completed request queue s_requestQueueMutex.lock(); s_requestQueue->clear(); s_requestQueueMutex.unlock(); if (s_requestQueue != nullptr) { delete s_requestQueue; s_requestQueue = nullptr; delete s_responseQueue; s_responseQueue = nullptr; } } //Configure curl's timeout property static bool configureCURL(CURL *handle) { if (!handle) { return false; } int32_t code; code = curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, s_errorBuffer); if (code != CURLE_OK) { return false; } code = curl_easy_setopt(handle, CURLOPT_TIMEOUT, HttpClient::getInstance()->getTimeoutForRead()); if (code != CURLE_OK) { return false; } code = curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, HttpClient::getInstance()->getTimeoutForConnect()); if (code != CURLE_OK) { return false; } curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0L); // FIXED #3224: The subthread of CCHttpClient interrupts main thread if timeout comes. // Document is here: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOSIGNAL curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L); return true; } class CURLRaii { /// Instance of CURL CURL *_curl; /// Keeps custom header data curl_slist *_headers; public: CURLRaii() : _curl(curl_easy_init()) , _headers(nullptr) { } ~CURLRaii() { if (_curl) curl_easy_cleanup(_curl); /* free the linked list for header data */ if (_headers) curl_slist_free_all(_headers); } template bool setOption(CURLoption option, T data) { return CURLE_OK == curl_easy_setopt(_curl, option, data); } /** * @brief Inits CURL instance for common usage * @param request Null not allowed * @param callback Response write callback * @param stream Response write stream */ bool init(HttpRequest *request, write_callback callback, void *stream, write_callback headerCallback, void *headerStream) { if (!_curl) return false; if (!configureCURL(_curl)) return false; /* get custom header data (if set) */ std::vector headers=request->getHeaders(); if(!headers.empty()) { /* append custom headers one by one */ for (std::vector::iterator it = headers.begin(); it != headers.end(); ++it) _headers = curl_slist_append(_headers,it->c_str()); /* set custom headers for curl */ if (!setOption(CURLOPT_HTTPHEADER, _headers)) return false; } if (!s_cookieFilename.empty()) { if (!setOption(CURLOPT_COOKIEFILE, s_cookieFilename.c_str())) { return false; } if (!setOption(CURLOPT_COOKIEJAR, s_cookieFilename.c_str())) { return false; } } return setOption(CURLOPT_URL, request->getUrl()) && setOption(CURLOPT_WRITEFUNCTION, callback) && setOption(CURLOPT_WRITEDATA, stream) && setOption(CURLOPT_HEADERFUNCTION, headerCallback) && setOption(CURLOPT_HEADERDATA, headerStream); } /// @param responseCode Null not allowed bool perform(long *responseCode) { if (CURLE_OK != curl_easy_perform(_curl)) return false; CURLcode code = curl_easy_getinfo(_curl, CURLINFO_RESPONSE_CODE, responseCode); if (code != CURLE_OK || *responseCode != 200) { CCLOGERROR("Curl curl_easy_getinfo failed: %s", curl_easy_strerror(code)); return false; } // Get some mor data. return true; } }; //Process Get Request static int processGetTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream) { CURLRaii curl; bool ok = curl.init(request, callback, stream, headerCallback, headerStream) && curl.setOption(CURLOPT_FOLLOWLOCATION, true) && curl.perform(responseCode); return ok ? 0 : 1; } //Process POST Request static int processPostTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream) { CURLRaii curl; bool ok = curl.init(request, callback, stream, headerCallback, headerStream) && curl.setOption(CURLOPT_POST, 1) && curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData()) && curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize()) && curl.perform(responseCode); return ok ? 0 : 1; } //Process PUT Request static int processPutTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream) { CURLRaii curl; bool ok = curl.init(request, callback, stream, headerCallback, headerStream) && curl.setOption(CURLOPT_CUSTOMREQUEST, "PUT") && curl.setOption(CURLOPT_POSTFIELDS, request->getRequestData()) && curl.setOption(CURLOPT_POSTFIELDSIZE, request->getRequestDataSize()) && curl.perform(responseCode); return ok ? 0 : 1; } //Process DELETE Request static int processDeleteTask(HttpRequest *request, write_callback callback, void *stream, long *responseCode, write_callback headerCallback, void *headerStream) { CURLRaii curl; bool ok = curl.init(request, callback, stream, headerCallback, headerStream) && curl.setOption(CURLOPT_CUSTOMREQUEST, "DELETE") && curl.setOption(CURLOPT_FOLLOWLOCATION, true) && curl.perform(responseCode); return ok ? 0 : 1; } // HttpClient implementation HttpClient* HttpClient::getInstance() { if (s_pHttpClient == nullptr) { s_pHttpClient = new HttpClient(); } return s_pHttpClient; } void HttpClient::destroyInstance() { CC_SAFE_DELETE(s_pHttpClient); } void HttpClient::enableCookies(const char* cookieFile) { if (cookieFile) { s_cookieFilename = std::string(cookieFile); } else { s_cookieFilename = (FileUtils::getInstance()->getWritablePath() + "cookieFile.txt"); } } HttpClient::HttpClient() : _timeoutForConnect(30) , _timeoutForRead(60) { } HttpClient::~HttpClient() { s_need_quit = true; if (s_requestQueue != nullptr) { s_SleepCondition.notify_one(); } s_pHttpClient = nullptr; } //Lazy create semaphore & mutex & thread bool HttpClient::lazyInitThreadSemphore() { if (s_requestQueue != nullptr) { return true; } else { s_requestQueue = new Vector(); s_responseQueue = new Vector(); auto t = std::thread(CC_CALLBACK_0(HttpClient::networkThread, this)); t.detach(); s_need_quit = false; } return true; } //Add a get task to queue void HttpClient::send(HttpRequest* request) { if (false == lazyInitThreadSemphore()) { return; } if (!request) { return; } request->retain(); s_requestQueueMutex.lock(); s_requestQueue->pushBack(request); s_requestQueueMutex.unlock(); // Notify thread start to work s_SleepCondition.notify_one(); } // Poll and notify main thread if responses exists in queue void HttpClient::dispatchResponseCallbacks() { // log("CCHttpClient::dispatchResponseCallbacks is running"); HttpResponse* response = nullptr; s_responseQueueMutex.lock(); if (!s_responseQueue->empty()) { response = s_responseQueue->at(0); s_responseQueue->erase(0); } s_responseQueueMutex.unlock(); if (response) { HttpRequest *request = response->getHttpRequest(); Object *pTarget = request->getTarget(); SEL_HttpResponse pSelector = request->getSelector(); if (pTarget && pSelector) { (pTarget->*pSelector)(this, response); } response->release(); } } } NS_CC_END ================================================ FILE: cocos2d/cocos/network/HttpClient.h ================================================ /**************************************************************************** Copyright (c) 2012 greathqy Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCHTTPREQUEST_H__ #define __CCHTTPREQUEST_H__ #include "network/HttpRequest.h" #include "network/HttpResponse.h" #include "network/HttpClient.h" NS_CC_BEGIN namespace network { /** * @addtogroup Network * @{ */ /** @brief Singleton that handles asynchrounous http requests * Once the request completed, a callback will issued in main thread when it provided during make request */ class HttpClient { public: /** Return the shared instance **/ static HttpClient *getInstance(); /** Relase the shared instance **/ static void destroyInstance(); /** Enable cookie support. **/ void enableCookies(const char* cookieFile); /** * Add a get request to task queue * @param request a HttpRequest object, which includes url, response callback etc. please make sure request->_requestData is clear before calling "send" here. */ void send(HttpRequest* request); /** * Change the connect timeout * @param value The desired timeout. */ inline void setTimeoutForConnect(int value) {_timeoutForConnect = value;}; /** * Get connect timeout * @return int */ inline int getTimeoutForConnect() {return _timeoutForConnect;} /** * Change the download timeout * @param value */ inline void setTimeoutForRead(int value) {_timeoutForRead = value;}; /** * Get download timeout * @return int */ inline int getTimeoutForRead() {return _timeoutForRead;}; private: HttpClient(); virtual ~HttpClient(); bool init(void); /** * Init pthread mutex, semaphore, and create new thread for http requests * @return bool */ bool lazyInitThreadSemphore(); void networkThread(); /** Poll function called from main thread to dispatch callbacks when http requests finished **/ void dispatchResponseCallbacks(); private: int _timeoutForConnect; int _timeoutForRead; }; // end of Network group /// @} } NS_CC_END #endif //__CCHTTPREQUEST_H__ ================================================ FILE: cocos2d/cocos/network/HttpRequest.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __HTTP_REQUEST_H__ #define __HTTP_REQUEST_H__ #include "CCPlatformMacros.h" #include "CCObject.h" NS_CC_BEGIN namespace network { class HttpClient; class HttpResponse; typedef void (cocos2d::Object::*SEL_HttpResponse)(HttpClient* client, HttpResponse* response); #define httpresponse_selector(_SELECTOR) (cocos2d::network::SEL_HttpResponse)(&_SELECTOR) /** @brief defines the object which users must packed for HttpClient::send(HttpRequest*) method. Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample @since v2.0.2 */ class HttpRequest : public cocos2d::Object { public: /** Use this enum type as param in setReqeustType(param) */ enum class Type { GET, POST, PUT, DELETE, UNKNOWN, }; /** Constructor Because HttpRequest object will be used between UI thead and network thread, requestObj->autorelease() is forbidden to avoid crashes in AutoreleasePool new/retain/release still works, which means you need to release it manually Please refer to HttpRequestTest.cpp to find its usage */ HttpRequest() { _requestType = Type::UNKNOWN; _url.clear(); _requestData.clear(); _tag.clear(); _pTarget = NULL; _pSelector = NULL; _pUserData = NULL; }; /** Destructor */ virtual ~HttpRequest() { if (_pTarget) { _pTarget->release(); } }; /** Override autorelease method to avoid developers to call it */ cocos2d::Object* autorelease(void) { CCASSERT(false, "HttpResponse is used between network thread and ui thread \ therefore, autorelease is forbidden here"); return NULL; } // setter/getters for properties /** Required field for HttpRequest object before being sent. kHttpGet & kHttpPost is currently supported */ inline void setRequestType(Type type) { _requestType = type; }; /** Get back the kHttpGet/Post/... enum value */ inline Type getRequestType() { return _requestType; }; /** Required field for HttpRequest object before being sent. */ inline void setUrl(const char* url) { _url = url; }; /** Get back the setted url */ inline const char* getUrl() { return _url.c_str(); }; /** Option field. You can set your post data here */ inline void setRequestData(const char* buffer, unsigned int len) { _requestData.assign(buffer, buffer + len); }; /** Get the request data pointer back */ inline char* getRequestData() { if(_requestData.size() != 0) return &(_requestData.front()); return nullptr; } /** Get the size of request data back */ inline ssize_t getRequestDataSize() { return _requestData.size(); } /** Option field. You can set a string tag to identify your request, this tag can be found in HttpResponse->getHttpRequest->getTag() */ inline void setTag(const char* tag) { _tag = tag; }; /** Get the string tag back to identify the request. The best practice is to use it in your MyClass::onMyHttpRequestCompleted(sender, HttpResponse*) callback */ inline const char* getTag() { return _tag.c_str(); }; /** Option field. You can attach a customed data in each request, and get it back in response callback. But you need to new/delete the data pointer manully */ inline void setUserData(void* pUserData) { _pUserData = pUserData; }; /** Get the pre-setted custom data pointer back. Don't forget to delete it. HttpClient/HttpResponse/HttpRequest will do nothing with this pointer */ inline void* getUserData() { return _pUserData; }; /** Required field. You should set the callback selector function at ack the http request completed */ CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(cocos2d::Object* pTarget, cocos2d::SEL_CallFuncND pSelector) { setResponseCallback(pTarget, (SEL_HttpResponse) pSelector); } inline void setResponseCallback(cocos2d::Object* pTarget, SEL_HttpResponse pSelector) { _pTarget = pTarget; _pSelector = pSelector; if (_pTarget) { _pTarget->retain(); } } /** Get the target of callback selector funtion, mainly used by HttpClient */ inline cocos2d::Object* getTarget() { return _pTarget; } /* This sub class is just for migration SEL_CallFuncND to SEL_HttpResponse, someday this way will be removed */ class _prxy { public: _prxy( SEL_HttpResponse cb ) :_cb(cb) {} ~_prxy(){}; operator SEL_HttpResponse() const { return _cb; } CC_DEPRECATED_ATTRIBUTE operator cocos2d::SEL_CallFuncND() const { return (cocos2d::SEL_CallFuncND) _cb; } protected: SEL_HttpResponse _cb; }; /** Get the selector function pointer, mainly used by HttpClient */ inline _prxy getSelector() { return _prxy(_pSelector); } /** Set any custom headers **/ inline void setHeaders(std::vector pHeaders) { _headers=pHeaders; } /** Get custom headers **/ inline std::vector getHeaders() { return _headers; } protected: // properties Type _requestType; /// kHttpRequestGet, kHttpRequestPost or other enums std::string _url; /// target url that this request is sent to std::vector _requestData; /// used for POST std::string _tag; /// user defined tag, to identify different requests in response callback cocos2d::Object* _pTarget; /// callback target of pSelector function SEL_HttpResponse _pSelector; /// callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response) void* _pUserData; /// You can add your customed data here std::vector _headers; /// custom http headers }; } NS_CC_END #endif //__HTTP_REQUEST_H__ ================================================ FILE: cocos2d/cocos/network/HttpResponse.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __HTTP_RESPONSE__ #define __HTTP_RESPONSE__ #include "network/HttpRequest.h" NS_CC_BEGIN namespace network { /** @brief defines the object which users will receive at onHttpCompleted(sender, HttpResponse) callback Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample @since v2.0.2 */ class HttpResponse : public cocos2d::Object { public: /** Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually @param request the corresponding HttpRequest which leads to this response */ HttpResponse(HttpRequest* request) { _pHttpRequest = request; if (_pHttpRequest) { _pHttpRequest->retain(); } _succeed = false; _responseData.clear(); _errorBuffer.clear(); } /** Destructor, it will be called in HttpClient internal, users don't need to desturct HttpResponse object manully */ virtual ~HttpResponse() { if (_pHttpRequest) { _pHttpRequest->release(); } } /** Override autorelease method to prevent developers from calling it */ cocos2d::Object* autorelease(void) { CCASSERT(false, "HttpResponse is used between network thread and ui thread \ therefore, autorelease is forbidden here"); return NULL; } // getters, will be called by users /** Get the corresponding HttpRequest object which leads to this response There's no paired setter for it, coz it's already setted in class constructor */ inline HttpRequest* getHttpRequest() { return _pHttpRequest; } /** To see if the http reqeust is returned successfully, Althrough users can judge if (http return code = 200), we want an easier way If this getter returns false, you can call getResponseCode and getErrorBuffer to find more details */ inline bool isSucceed() { return _succeed; }; /** Get the http response raw data */ inline std::vector* getResponseData() { return &_responseData; } /** get the Rawheader **/ inline std::vector* getResponseHeader() { return &_responseHeader; } /** Get the http response errorCode * I know that you want to see http 200 :) */ inline long getResponseCode() { return _responseCode; } /** Get the rror buffer which will tell you more about the reason why http request failed */ inline const char* getErrorBuffer() { return _errorBuffer.c_str(); } // setters, will be called by HttpClient // users should avoid invoking these methods /** Set if the http request is returned successfully, Althrough users can judge if (http code == 200), we want a easier way This setter is mainly used in HttpClient, users mustn't set it directly */ inline void setSucceed(bool value) { _succeed = value; }; /** Set the http response raw buffer, is used by HttpClient */ inline void setResponseData(std::vector* data) { _responseData = *data; } /** Set the http response Header raw buffer, is used by HttpClient */ inline void setResponseHeader(std::vector* data) { _responseHeader = *data; } /** Set the http response errorCode */ inline void setResponseCode(long value) { _responseCode = value; } /** Set the error buffer which will tell you more the reason why http request failed */ inline void setErrorBuffer(const char* value) { _errorBuffer.clear(); _errorBuffer.assign(value); }; protected: bool initWithRequest(HttpRequest* request); // properties HttpRequest* _pHttpRequest; /// the corresponding HttpRequest pointer who leads to this response bool _succeed; /// to indecate if the http reqeust is successful simply std::vector _responseData; /// the returned raw data. You can also dump it as a string std::vector _responseHeader; /// the returned raw header data. You can also dump it as a string long _responseCode; /// the status code returned from libcurl, e.g. 200, 404 std::string _errorBuffer; /// if _responseCode != 200, please read _errorBuffer to find the reason }; } NS_CC_END #endif //__HTTP_RESPONSE_H__ ================================================ FILE: cocos2d/cocos/network/SocketIO.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Chris Hannon Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *based on the SocketIO library created by LearnBoost at http://socket.io *using spec version 1 found at https://github.com/LearnBoost/socket.io-spec ****************************************************************************/ #include "SocketIO.h" #include "CCDirector.h" #include "CCScheduler.h" #include "WebSocket.h" #include "HttpClient.h" #include #include NS_CC_BEGIN namespace network { //class declarations /** * @brief The implementation of the socket.io connection * Clients/endpoints may share the same impl to accomplish multiplexing on the same websocket */ class SIOClientImpl : public cocos2d::Object, public WebSocket::Delegate { private: int _port, _heartbeat, _timeout; std::string _host, _sid, _uri; bool _connected; WebSocket *_ws; Map _clients; public: SIOClientImpl(const std::string& host, int port); virtual ~SIOClientImpl(void); static SIOClientImpl* create(const std::string& host, int port); virtual void onOpen(WebSocket* ws); virtual void onMessage(WebSocket* ws, const WebSocket::Data& data); virtual void onClose(WebSocket* ws); virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error); void connect(); void disconnect(); bool init(); void handshake(); void handshakeResponse(HttpClient *sender, HttpResponse *response); void openSocket(); void heartbeat(float dt); SIOClient* getClient(const std::string& endpoint); void addClient(const std::string& endpoint, SIOClient* client); void connectToEndpoint(const std::string& endpoint); void disconnectFromEndpoint(const std::string& endpoint); void send(std::string endpoint, std::string s); void emit(std::string endpoint, std::string eventname, std::string args); }; //method implementations //begin SIOClientImpl methods SIOClientImpl::SIOClientImpl(const std::string& host, int port) : _port(port), _host(host), _connected(false) { std::stringstream s; s << host << ":" << port; _uri = s.str(); _ws = nullptr; } SIOClientImpl::~SIOClientImpl() { if (_connected) disconnect(); CC_SAFE_DELETE(_ws); } void SIOClientImpl::handshake() { log("SIOClientImpl::handshake() called"); std::stringstream pre; pre << "http://" << _uri << "/socket.io/1"; HttpRequest* request = new HttpRequest(); request->setUrl(pre.str().c_str()); request->setRequestType(HttpRequest::Type::GET); request->setResponseCallback(this, httpresponse_selector(SIOClientImpl::handshakeResponse)); request->setTag("handshake"); log("SIOClientImpl::handshake() waiting"); HttpClient::getInstance()->send(request); request->release(); return; } void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) { log("SIOClientImpl::handshakeResponse() called"); if (0 != strlen(response->getHttpRequest()->getTag())) { log("%s completed", response->getHttpRequest()->getTag()); } long statusCode = response->getResponseCode(); char statusString[64] = {}; sprintf(statusString, "HTTP Status Code: %ld, tag = %s", statusCode, response->getHttpRequest()->getTag()); log("response code: %ld", statusCode); if (!response->isSucceed()) { log("SIOClientImpl::handshake() failed"); log("error buffer: %s", response->getErrorBuffer()); for (auto iter = _clients.begin(); iter != _clients.end(); ++iter) { iter->second->getDelegate()->onError(iter->second, response->getErrorBuffer()); } return; } log("SIOClientImpl::handshake() succeeded"); std::vector *buffer = response->getResponseData(); std::stringstream s; for (unsigned int i = 0; i < buffer->size(); i++) { s << (*buffer)[i]; } log("SIOClientImpl::handshake() dump data: %s", s.str().c_str()); std::string res = s.str(); std::string sid; size_t pos = 0; int heartbeat = 0, timeout = 0; pos = res.find(":"); if(pos != std::string::npos) { sid = res.substr(0, pos); res.erase(0, pos+1); } pos = res.find(":"); if(pos != std::string::npos) { heartbeat = atoi(res.substr(pos+1, res.size()).c_str()); } pos = res.find(":"); if(pos != std::string::npos) { timeout = atoi(res.substr(pos+1, res.size()).c_str()); } _sid = sid; _heartbeat = heartbeat; _timeout = timeout; openSocket(); return; } void SIOClientImpl::openSocket() { log("SIOClientImpl::openSocket() called"); std::stringstream s; s << _uri << "/socket.io/1/websocket/" << _sid; _ws = new WebSocket(); if (!_ws->init(*this, s.str())) { CC_SAFE_DELETE(_ws); } return; } bool SIOClientImpl::init() { log("SIOClientImpl::init() successful"); return true; } void SIOClientImpl::connect() { this->handshake(); } void SIOClientImpl::disconnect() { if(_ws->getReadyState() == WebSocket::State::OPEN) { std::string s = "0::"; _ws->send(s); log("Disconnect sent"); _ws->close(); } Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); _connected = false; SocketIO::getInstance()->removeSocket(_uri); } SIOClientImpl* SIOClientImpl::create(const std::string& host, int port) { SIOClientImpl *s = new SIOClientImpl(host, port); if (s && s->init()) { return s; } return nullptr; } SIOClient* SIOClientImpl::getClient(const std::string& endpoint) { return _clients.at(endpoint); } void SIOClientImpl::addClient(const std::string& endpoint, SIOClient* client) { _clients.insert(endpoint, client); } void SIOClientImpl::connectToEndpoint(const std::string& endpoint) { std::string path = endpoint == "/" ? "" : endpoint; std::string s = "1::" + path; _ws->send(s); } void SIOClientImpl::disconnectFromEndpoint(const std::string& endpoint) { _clients.erase(endpoint); if (_clients.empty() || endpoint == "/") { log("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect"); if(_connected) this->disconnect(); } else { std::string path = endpoint == "/" ? "" : endpoint; std::string s = "0::" + path; _ws->send(s); } } void SIOClientImpl::heartbeat(float dt) { std::string s = "2::"; _ws->send(s); log("Heartbeat sent"); } void SIOClientImpl::send(std::string endpoint, std::string s) { std::stringstream pre; std::string path = endpoint == "/" ? "" : endpoint; pre << "3::" << path << ":" << s; std::string msg = pre.str(); log("sending message: %s", msg.c_str()); _ws->send(msg); } void SIOClientImpl::emit(std::string endpoint, std::string eventname, std::string args) { std::stringstream pre; std::string path = endpoint == "/" ? "" : endpoint; pre << "5::" << path << ":{\"name\":\"" << eventname << "\",\"args\":" << args << "}"; std::string msg = pre.str(); log("emitting event with data: %s", msg.c_str()); _ws->send(msg); } void SIOClientImpl::onOpen(WebSocket* ws) { _connected = true; SocketIO::getInstance()->addSocket(_uri, this); for (auto iter = _clients.begin(); iter != _clients.end(); ++iter) { iter->second->onOpen(); } Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9f), false); log("SIOClientImpl::onOpen socket connected!"); } void SIOClientImpl::onMessage(WebSocket* ws, const WebSocket::Data& data) { log("SIOClientImpl::onMessage received: %s", data.bytes); int control = atoi(&data.bytes[0]); std::string payload, msgid, endpoint, s_data, eventname; payload = data.bytes; size_t pos, pos2; pos = payload.find(":"); if(pos != std::string::npos ) { payload.erase(0, pos+1); } pos = payload.find(":"); if(pos != std::string::npos ) { msgid = atoi(payload.substr(0, pos+1).c_str()); } payload.erase(0, pos+1); pos = payload.find(":"); if(pos != std::string::npos) { endpoint = payload.substr(0, pos); payload.erase(0, pos+1); } else { endpoint = payload; } if (endpoint == "") endpoint = "/"; s_data = payload; SIOClient *c = NULL; c = getClient(endpoint); if (c == NULL) log("SIOClientImpl::onMessage client lookup returned NULL"); switch(control) { case 0: log("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str()); if(c) c->receivedDisconnect(); disconnectFromEndpoint(endpoint); break; case 1: log("Connected to endpoint: %s \n",endpoint.c_str()); if(c) c->onConnect(); break; case 2: log("Heartbeat received\n"); break; case 3: log("Message received: %s \n", s_data.c_str()); if(c) c->getDelegate()->onMessage(c, s_data); break; case 4: log("JSON Message Received: %s \n", s_data.c_str()); if(c) c->getDelegate()->onMessage(c, s_data); break; case 5: log("Event Received with data: %s \n", s_data.c_str()); if(c) { eventname = ""; pos = s_data.find(":"); pos2 = s_data.find(","); if(pos2 > pos) { s_data = s_data.substr(pos+1, pos2-pos-1); std::remove_copy(s_data.begin(), s_data.end(), std::back_inserter(eventname), '"'); } c->fireEvent(eventname, payload); } break; case 6: log("Message Ack\n"); break; case 7: log("Error\n"); if(c) c->getDelegate()->onError(c, s_data); break; case 8: log("Noop\n"); break; } return; } void SIOClientImpl::onClose(WebSocket* ws) { if (!_clients.empty()) { for (auto iter = _clients.begin(); iter != _clients.end(); ++iter) { iter->second->receivedDisconnect(); } } this->release(); } void SIOClientImpl::onError(WebSocket* ws, const WebSocket::ErrorCode& error) { } //begin SIOClient methods SIOClient::SIOClient(const std::string& host, int port, const std::string& path, SIOClientImpl* impl, SocketIO::SIODelegate& delegate) : _port(port) , _host(host) , _path(path) , _connected(false) , _socket(impl) , _delegate(&delegate) { } SIOClient::~SIOClient(void) { if (_connected) { _socket->disconnectFromEndpoint(_path); } } void SIOClient::onOpen() { if (_path != "/") { _socket->connectToEndpoint(_path); } } void SIOClient::onConnect() { _connected = true; _delegate->onConnect(this); } void SIOClient::send(std::string s) { if (_connected) { _socket->send(_path, s); } else { _delegate->onError(this, "Client not yet connected"); } } void SIOClient::emit(std::string eventname, std::string args) { if(_connected) { _socket->emit(_path, eventname, args); } else { _delegate->onError(this, "Client not yet connected"); } } void SIOClient::disconnect() { _connected = false; _socket->disconnectFromEndpoint(_path); _delegate->onClose(this); this->release(); } void SIOClient::receivedDisconnect() { _connected = false; _delegate->onClose(this); this->release(); } void SIOClient::on(const std::string& eventName, SIOEvent e) { _eventRegistry[eventName] = e; } void SIOClient::fireEvent(const std::string& eventName, const std::string& data) { log("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str()); if(_eventRegistry[eventName]) { SIOEvent e = _eventRegistry[eventName]; e(this, data); return; } log("SIOClient::fireEvent no event with name %s found", eventName.c_str()); } //begin SocketIO methods SocketIO *SocketIO::_inst = nullptr; SocketIO::SocketIO() { } SocketIO::~SocketIO(void) { } SocketIO* SocketIO::getInstance() { if (nullptr == _inst) _inst = new SocketIO(); return _inst; } void SocketIO::destroyInstance() { CC_SAFE_DELETE(_inst); } SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string& uri) { std::string host = uri; int port = 0; size_t pos = 0; pos = host.find("//"); if (pos != std::string::npos) { host.erase(0, pos+2); } pos = host.find(":"); if (pos != std::string::npos) { port = atoi(host.substr(pos+1, host.size()).c_str()); } pos = host.find("/", 0); std::string path = "/"; if (pos != std::string::npos) { path += host.substr(pos + 1, host.size()); } pos = host.find(":"); if (pos != std::string::npos) { host.erase(pos, host.size()); } else if ((pos = host.find("/")) != std::string::npos) { host.erase(pos, host.size()); } std::stringstream s; s << host << ":" << port; SIOClientImpl* socket = nullptr; SIOClient *c = nullptr; socket = SocketIO::getInstance()->getSocket(s.str()); if(socket == nullptr) { //create a new socket, new client, connect socket = SIOClientImpl::create(host, port); c = new SIOClient(host, port, path, socket, delegate); socket->addClient(path, c); socket->connect(); } else { //check if already connected to endpoint, handle c = socket->getClient(path); if(c == NULL) { c = new SIOClient(host, port, path, socket, delegate); socket->addClient(path, c); socket->connectToEndpoint(path); } } return c; } SIOClientImpl* SocketIO::getSocket(const std::string& uri) { return _sockets.at(uri); } void SocketIO::addSocket(const std::string& uri, SIOClientImpl* socket) { _sockets.insert(uri, socket); } void SocketIO::removeSocket(const std::string& uri) { _sockets.erase(uri); } } NS_CC_END ================================================ FILE: cocos2d/cocos/network/SocketIO.h ================================================ /**************************************************************************** Copyright (c) 2013 Chris Hannon http://www.channon.us Copyright (c) 2013-2014 Chukong Technologies Inc. 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. *based on the SocketIO library created by LearnBoost at http://socket.io *using spec version 1 found at https://github.com/LearnBoost/socket.io-spec Usage is described below, a full working example can be found in TestCpp under ExtionsTest/NetworkTest/SocketIOTest creating a new connection to a socket.io server running at localhost:3000 SIOClient *client = SocketIO::connect(*delegate, "ws://localhost:3000"); the connection process will begin and if successful delegate::onOpen will be called if the connection process results in an error, delegate::onError will be called with the err msg sending a message to the server client->send("Hello!"); emitting an event to be handled by the server, argument json formatting is up to you client->emit("eventname", "[{\"arg\":\"value\"}]"); registering an event callback, target should be a member function in a subclass of SIODelegate CC_CALLBACK_2 is used to wrap the callback with std::bind and store as an SIOEvent client->on("eventname", CC_CALLBACK_2(TargetClass::targetfunc, *targetclass_instance)); event target function should match this pattern, *this pointer will be made available void TargetClass::targetfunc(SIOClient *, const std::string&) disconnect from the endpoint by calling disconnect(), onClose will be called on the delegate once complete in the onClose method the pointer should be set to NULL or used to connect to a new endpoint client->disconnect(); ****************************************************************************/ #ifndef __CC_SOCKETIO_H__ #define __CC_SOCKETIO_H__ #include "CCPlatformMacros.h" #include "CCMap.h" #include NS_CC_BEGIN namespace network { //forward declarations class SIOClientImpl; class SIOClient; /** * @brief Singleton and wrapper class to provide static creation method as well as registry of all sockets */ class SocketIO { public: static SocketIO* getInstance(); static void destroyInstance(); /** * @brief The delegate class to process socket.io events */ class SIODelegate { public: virtual ~SIODelegate() {} virtual void onConnect(SIOClient* client) = 0; virtual void onMessage(SIOClient* client, const std::string& data) = 0; virtual void onClose(SIOClient* client) = 0; virtual void onError(SIOClient* client, const std::string& data) = 0; }; /** * @brief Static client creation method, similar to socketio.connect(uri) in JS * @param delegate The delegate which want to receive events from the socket.io client * @param uri The URI of the socket.io server * @return An initialized SIOClient if connected successfully, otherwise NULL */ static SIOClient* connect(SocketIO::SIODelegate& delegate, const std::string& uri); private: SocketIO(); virtual ~SocketIO(void); static SocketIO *_inst; cocos2d::Map _sockets; SIOClientImpl* getSocket(const std::string& uri); void addSocket(const std::string& uri, SIOClientImpl* socket); void removeSocket(const std::string& uri); friend class SIOClientImpl; private: CC_DISALLOW_COPY_AND_ASSIGN(SocketIO) }; //c++11 style callbacks entities will be created using CC_CALLBACK (which uses std::bind) typedef std::function SIOEvent; //c++11 map to callbacks typedef std::unordered_map EventRegistry; /** * @brief A single connection to a socket.io endpoint */ class SIOClient : public cocos2d::Object { private: int _port; std::string _host, _path, _tag; bool _connected; SIOClientImpl* _socket; SocketIO::SIODelegate* _delegate; EventRegistry _eventRegistry; void fireEvent(const std::string& eventName, const std::string& data); void onOpen(); void onConnect(); void receivedDisconnect(); friend class SIOClientImpl; public: SIOClient(const std::string& host, int port, const std::string& path, SIOClientImpl* impl, SocketIO::SIODelegate& delegate); virtual ~SIOClient(void); /** * @brief Returns the delegate for the client */ SocketIO::SIODelegate* getDelegate() { return _delegate; }; /** * @brief Disconnect from the endpoint, onClose will be called on the delegate when comlpete */ void disconnect(); /** * @brief Send a message to the socket.io server */ void send(std::string s); /** * @brief The delegate class to process socket.io events */ void emit(std::string eventname, std::string args); /** * @brief Used to resgister a socket.io event callback * Event argument should be passed using CC_CALLBACK2(&Base::function, this) */ void on(const std::string& eventName, SIOEvent e); inline void setTag(const char* tag) { _tag = tag; }; inline const char* getTag() { return _tag.c_str(); }; }; } NS_CC_END #endif /* defined(__CC_JSB_SOCKETIO_H__) */ ================================================ FILE: cocos2d/cocos/network/WebSocket.cpp ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "[WebSocket module] is based in part on the work of the libwebsockets project (http://libwebsockets.org)" ****************************************************************************/ #include "WebSocket.h" #include "CCDirector.h" #include "CCScheduler.h" #include #include #include #include #include #include "libwebsockets.h" #define WS_WRITE_BUFFER_SIZE 2048 NS_CC_BEGIN namespace network { class WsMessage { public: WsMessage() : what(0), obj(nullptr){} unsigned int what; // message type void* obj; }; /** * @brief Websocket thread helper, it's used for sending message between UI thread and websocket thread. */ class WsThreadHelper : public Object { public: WsThreadHelper(); ~WsThreadHelper(); // Creates a new thread bool createThread(const WebSocket& ws); // Quits sub-thread (websocket thread). void quitSubThread(); // Schedule callback function virtual void update(float dt); // Sends message to UI thread. It's needed to be invoked in sub-thread. void sendMessageToUIThread(WsMessage *msg); // Sends message to sub-thread(websocket thread). It's needs to be invoked in UI thread. void sendMessageToSubThread(WsMessage *msg); // Waits the sub-thread (websocket thread) to exit, void joinSubThread(); protected: void wsThreadEntryFunc(); private: std::list* _UIWsMessageQueue; std::list* _subThreadWsMessageQueue; std::mutex _UIWsMessageQueueMutex; std::mutex _subThreadWsMessageQueueMutex; std::thread* _subThreadInstance; WebSocket* _ws; bool _needQuit; friend class WebSocket; }; // Wrapper for converting websocket callback from static function to member function of WebSocket class. class WebSocketCallbackWrapper { public: static int onSocketCallback(struct libwebsocket_context *ctx, struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { // Gets the user data from context. We know that it's a 'WebSocket' instance. WebSocket* wsInstance = (WebSocket*)libwebsocket_context_user(ctx); if (wsInstance) { return wsInstance->onSocketCallback(ctx, wsi, reason, user, in, len); } return 0; } }; // Implementation of WsThreadHelper WsThreadHelper::WsThreadHelper() : _subThreadInstance(nullptr) , _ws(nullptr) , _needQuit(false) { _UIWsMessageQueue = new std::list(); _subThreadWsMessageQueue = new std::list(); Director::getInstance()->getScheduler()->scheduleUpdateForTarget(this, 0, false); } WsThreadHelper::~WsThreadHelper() { Director::getInstance()->getScheduler()->unscheduleAllForTarget(this); joinSubThread(); CC_SAFE_DELETE(_subThreadInstance); delete _UIWsMessageQueue; delete _subThreadWsMessageQueue; } bool WsThreadHelper::createThread(const WebSocket& ws) { _ws = const_cast(&ws); // Creates websocket thread _subThreadInstance = new std::thread(&WsThreadHelper::wsThreadEntryFunc, this); return true; } void WsThreadHelper::quitSubThread() { _needQuit = true; } void WsThreadHelper::wsThreadEntryFunc() { _ws->onSubThreadStarted(); while (!_needQuit) { if (_ws->onSubThreadLoop()) { break; } } _ws->onSubThreadEnded(); } void WsThreadHelper::sendMessageToUIThread(WsMessage *msg) { std::lock_guard lk(_UIWsMessageQueueMutex); _UIWsMessageQueue->push_back(msg); } void WsThreadHelper::sendMessageToSubThread(WsMessage *msg) { std::lock_guard lk(_subThreadWsMessageQueueMutex); _subThreadWsMessageQueue->push_back(msg); } void WsThreadHelper::joinSubThread() { if (_subThreadInstance->joinable()) { _subThreadInstance->join(); } } void WsThreadHelper::update(float dt) { WsMessage *msg = nullptr; // Returns quickly if no message std::lock_guard lk(_UIWsMessageQueueMutex); if (0 == _UIWsMessageQueue->size()) { return; } // Gets message msg = *(_UIWsMessageQueue->begin()); _UIWsMessageQueue->pop_front(); if (_ws) { _ws->onUIThreadReceiveMessage(msg); } CC_SAFE_DELETE(msg); } enum WS_MSG { WS_MSG_TO_SUBTRHEAD_SENDING_STRING = 0, WS_MSG_TO_SUBTRHEAD_SENDING_BINARY, WS_MSG_TO_UITHREAD_OPEN, WS_MSG_TO_UITHREAD_MESSAGE, WS_MSG_TO_UITHREAD_ERROR, WS_MSG_TO_UITHREAD_CLOSE }; WebSocket::WebSocket() : _readyState(State::CONNECTING) , _port(80) , _wsHelper(nullptr) , _wsInstance(nullptr) , _wsContext(nullptr) , _delegate(nullptr) , _SSLConnection(0) , _wsProtocols(nullptr) , _pendingFrameDataLen(0) , _currentDataLen(0) , _currentData(nullptr) { } WebSocket::~WebSocket() { close(); CC_SAFE_RELEASE_NULL(_wsHelper); for (int i = 0; _wsProtocols[i].callback != nullptr; ++i) { CC_SAFE_DELETE_ARRAY(_wsProtocols[i].name); } CC_SAFE_DELETE_ARRAY(_wsProtocols); } bool WebSocket::init(const Delegate& delegate, const std::string& url, const std::vector* protocols/* = nullptr*/) { bool ret = false; bool useSSL = false; std::string host = url; size_t pos = 0; int port = 80; _delegate = const_cast(&delegate); //ws:// pos = host.find("ws://"); if (pos == 0) host.erase(0,5); pos = host.find("wss://"); if (pos == 0) { host.erase(0,6); useSSL = true; } pos = host.find(":"); if (pos != std::string::npos) port = atoi(host.substr(pos+1, host.size()).c_str()); pos = host.find("/", 0); std::string path = "/"; if (pos != std::string::npos) path += host.substr(pos + 1, host.size()); pos = host.find(":"); if(pos != std::string::npos){ host.erase(pos, host.size()); }else if((pos = host.find("/")) != std::string::npos) { host.erase(pos, host.size()); } _host = host; _port = port; _path = path; _SSLConnection = useSSL ? 1 : 0; CCLOG("[WebSocket::init] _host: %s, _port: %d, _path: %s", _host.c_str(), _port, _path.c_str()); size_t protocolCount = 0; if (protocols && protocols->size() > 0) { protocolCount = protocols->size(); } else { protocolCount = 1; } _wsProtocols = new libwebsocket_protocols[protocolCount+1]; memset(_wsProtocols, 0, sizeof(libwebsocket_protocols)*(protocolCount+1)); if (protocols && protocols->size() > 0) { int i = 0; for (std::vector::const_iterator iter = protocols->begin(); iter != protocols->end(); ++iter, ++i) { char* name = new char[(*iter).length()+1]; strcpy(name, (*iter).c_str()); _wsProtocols[i].name = name; _wsProtocols[i].callback = WebSocketCallbackWrapper::onSocketCallback; } } else { char* name = new char[20]; strcpy(name, "default-protocol"); _wsProtocols[0].name = name; _wsProtocols[0].callback = WebSocketCallbackWrapper::onSocketCallback; } // WebSocket thread needs to be invoked at the end of this method. _wsHelper = new WsThreadHelper(); ret = _wsHelper->createThread(*this); return ret; } void WebSocket::send(const std::string& message) { if (_readyState == State::OPEN) { // In main thread WsMessage* msg = new WsMessage(); msg->what = WS_MSG_TO_SUBTRHEAD_SENDING_STRING; Data* data = new Data(); data->bytes = new char[message.length()+1]; strcpy(data->bytes, message.c_str()); data->len = static_cast(message.length()); msg->obj = data; _wsHelper->sendMessageToSubThread(msg); } } void WebSocket::send(const unsigned char* binaryMsg, unsigned int len) { CCASSERT(binaryMsg != nullptr && len > 0, "parameter invalid."); if (_readyState == State::OPEN) { // In main thread WsMessage* msg = new WsMessage(); msg->what = WS_MSG_TO_SUBTRHEAD_SENDING_BINARY; Data* data = new Data(); data->bytes = new char[len]; memcpy((void*)data->bytes, (void*)binaryMsg, len); data->len = len; msg->obj = data; _wsHelper->sendMessageToSubThread(msg); } } void WebSocket::close() { Director::getInstance()->getScheduler()->unscheduleAllForTarget(_wsHelper); if (_readyState == State::CLOSING || _readyState == State::CLOSED) { return; } CCLOG("websocket (%p) connection closed by client", this); _readyState = State::CLOSED; _wsHelper->joinSubThread(); // onClose callback needs to be invoked at the end of this method // since websocket instance may be deleted in 'onClose'. _delegate->onClose(this); } WebSocket::State WebSocket::getReadyState() { return _readyState; } int WebSocket::onSubThreadLoop() { if (_readyState == State::CLOSED || _readyState == State::CLOSING) { libwebsocket_context_destroy(_wsContext); // return 1 to exit the loop. return 1; } if (_wsContext && _readyState != State::CLOSED && _readyState != State::CLOSING) { libwebsocket_service(_wsContext, 0); } // Sleep 50 ms std::this_thread::sleep_for(std::chrono::milliseconds(50)); // return 0 to continue the loop. return 0; } void WebSocket::onSubThreadStarted() { struct lws_context_creation_info info; memset(&info, 0, sizeof info); /* * create the websocket context. This tracks open connections and * knows how to route any traffic and which protocol version to use, * and if each connection is client or server side. * * For this client-only demo, we tell it to not listen on any port. */ info.port = CONTEXT_PORT_NO_LISTEN; info.protocols = _wsProtocols; #ifndef LWS_NO_EXTENSIONS info.extensions = libwebsocket_get_internal_extensions(); #endif info.gid = -1; info.uid = -1; info.user = (void*)this; _wsContext = libwebsocket_create_context(&info); if(nullptr != _wsContext) { _readyState = State::CONNECTING; std::string name; for (int i = 0; _wsProtocols[i].callback != nullptr; ++i) { name += (_wsProtocols[i].name); if (_wsProtocols[i+1].callback != nullptr) name += ", "; } _wsInstance = libwebsocket_client_connect(_wsContext, _host.c_str(), _port, _SSLConnection, _path.c_str(), _host.c_str(), _host.c_str(), name.c_str(), -1); } } void WebSocket::onSubThreadEnded() { } int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, struct libwebsocket *wsi, int reason, void *user, void *in, ssize_t len) { //CCLOG("socket callback for %d reason", reason); CCASSERT(_wsContext == nullptr || ctx == _wsContext, "Invalid context."); CCASSERT(_wsInstance == nullptr || wsi == nullptr || wsi == _wsInstance, "Invaild websocket instance."); switch (reason) { case LWS_CALLBACK_DEL_POLL_FD: case LWS_CALLBACK_PROTOCOL_DESTROY: case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: { WsMessage* msg = nullptr; if (reason == LWS_CALLBACK_CLIENT_CONNECTION_ERROR || (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == State::CONNECTING) || (reason == LWS_CALLBACK_DEL_POLL_FD && _readyState == State::CONNECTING) ) { msg = new WsMessage(); msg->what = WS_MSG_TO_UITHREAD_ERROR; _readyState = State::CLOSING; } else if (reason == LWS_CALLBACK_PROTOCOL_DESTROY && _readyState == State::CLOSING) { msg = new WsMessage(); msg->what = WS_MSG_TO_UITHREAD_CLOSE; } if (msg) { _wsHelper->sendMessageToUIThread(msg); } } break; case LWS_CALLBACK_CLIENT_ESTABLISHED: { WsMessage* msg = new WsMessage(); msg->what = WS_MSG_TO_UITHREAD_OPEN; _readyState = State::OPEN; /* * start the ball rolling, * LWS_CALLBACK_CLIENT_WRITEABLE will come next service */ libwebsocket_callback_on_writable(ctx, wsi); _wsHelper->sendMessageToUIThread(msg); } break; case LWS_CALLBACK_CLIENT_WRITEABLE: { std::lock_guard lk(_wsHelper->_subThreadWsMessageQueueMutex); std::list::iterator iter = _wsHelper->_subThreadWsMessageQueue->begin(); int bytesWrite = 0; for (; iter != _wsHelper->_subThreadWsMessageQueue->end();) { WsMessage* subThreadMsg = *iter; if ( WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what || WS_MSG_TO_SUBTRHEAD_SENDING_BINARY == subThreadMsg->what) { Data* data = (Data*)subThreadMsg->obj; const size_t c_bufferSize = WS_WRITE_BUFFER_SIZE; size_t remaining = data->len - data->issued; size_t n = std::min(remaining, c_bufferSize ); CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", static_cast(data->len), static_cast(data->issued), static_cast(remaining), static_cast(n)); unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING]; memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes + data->issued, n); int writeProtocol; if (data->issued == 0) { if (WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what) { writeProtocol = LWS_WRITE_TEXT; } else { writeProtocol = LWS_WRITE_BINARY; } // If we have more than 1 fragment if (data->len > c_bufferSize) writeProtocol |= LWS_WRITE_NO_FIN; } else { // we are in the middle of fragments writeProtocol = LWS_WRITE_CONTINUATION; // and if not in the last fragment if (remaining != n) writeProtocol |= LWS_WRITE_NO_FIN; } bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], n, (libwebsocket_write_protocol)writeProtocol); CCLOG("[websocket:send] bytesWrite => %d", bytesWrite); // Buffer overrun? if (bytesWrite < 0) { break; } // Do we have another fragments to send? else if (remaining != n) { data->issued += n; break; } // Safely done! else { CC_SAFE_DELETE_ARRAY(data->bytes); CC_SAFE_DELETE(data); CC_SAFE_DELETE_ARRAY(buf); _wsHelper->_subThreadWsMessageQueue->erase(iter++); CC_SAFE_DELETE(subThreadMsg); } } } /* get notified as soon as we can write again */ libwebsocket_callback_on_writable(ctx, wsi); } break; case LWS_CALLBACK_CLOSED: { CCLOG("%s", "connection closing.."); _wsHelper->quitSubThread(); if (_readyState != State::CLOSED) { WsMessage* msg = new WsMessage(); _readyState = State::CLOSED; msg->what = WS_MSG_TO_UITHREAD_CLOSE; _wsHelper->sendMessageToUIThread(msg); } } break; case LWS_CALLBACK_CLIENT_RECEIVE: { if (in && len > 0) { // Accumulate the data (increasing the buffer as we go) if (_currentDataLen == 0) { _currentData = new char[len]; memcpy (_currentData, in, len); _currentDataLen = len; } else { char *new_data = new char [_currentDataLen + len]; memcpy (new_data, _currentData, _currentDataLen); memcpy (new_data + _currentDataLen, in, len); CC_SAFE_DELETE_ARRAY(_currentData); _currentData = new_data; _currentDataLen = _currentDataLen + len; } _pendingFrameDataLen = libwebsockets_remaining_packet_payload (wsi); if (_pendingFrameDataLen > 0) { //CCLOG("%ld bytes of pending data to receive, consider increasing the libwebsocket rx_buffer_size value.", _pendingFrameDataLen); } // If no more data pending, send it to the client thread if (_pendingFrameDataLen == 0) { WsMessage* msg = new WsMessage(); msg->what = WS_MSG_TO_UITHREAD_MESSAGE; char* bytes = nullptr; Data* data = new Data(); if (lws_frame_is_binary(wsi)) { bytes = new char[_currentDataLen]; data->isBinary = true; } else { bytes = new char[_currentDataLen+1]; bytes[_currentDataLen] = '\0'; data->isBinary = false; } memcpy(bytes, _currentData, _currentDataLen); data->bytes = bytes; data->len = _currentDataLen; msg->obj = (void*)data; CC_SAFE_DELETE_ARRAY(_currentData); _currentData = nullptr; _currentDataLen = 0; _wsHelper->sendMessageToUIThread(msg); } } } break; default: break; } return 0; } void WebSocket::onUIThreadReceiveMessage(WsMessage* msg) { switch (msg->what) { case WS_MSG_TO_UITHREAD_OPEN: { _delegate->onOpen(this); } break; case WS_MSG_TO_UITHREAD_MESSAGE: { Data* data = (Data*)msg->obj; _delegate->onMessage(this, *data); CC_SAFE_DELETE_ARRAY(data->bytes); CC_SAFE_DELETE(data); } break; case WS_MSG_TO_UITHREAD_CLOSE: { _delegate->onClose(this); } break; case WS_MSG_TO_UITHREAD_ERROR: { // FIXME: The exact error needs to be checked. WebSocket::ErrorCode err = ErrorCode::CONNECTION_FAILURE; _delegate->onError(this, err); } break; default: break; } } } NS_CC_END ================================================ FILE: cocos2d/cocos/network/WebSocket.h ================================================ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "[WebSocket module] is based in part on the work of the libwebsockets project (http://libwebsockets.org)" ****************************************************************************/ #ifndef __CC_WEBSOCKET_H__ #define __CC_WEBSOCKET_H__ #include "CCPlatformMacros.h" #include "CCStdC.h" #include #include #include struct libwebsocket; struct libwebsocket_context; struct libwebsocket_protocols; NS_CC_BEGIN namespace network { class WsThreadHelper; class WsMessage; class WebSocket { public: /** * @js ctor */ WebSocket(); /** * @js NA * @lua NA */ virtual ~WebSocket(); /** * @brief Data structure for message */ struct Data { Data():bytes(nullptr), len(0), issued(0), isBinary(false){} char* bytes; ssize_t len, issued; bool isBinary; }; /** * @brief Errors in websocket */ enum class ErrorCode { TIME_OUT, CONNECTION_FAILURE, UNKNOWN, }; /** * Websocket state */ enum class State { CONNECTING, OPEN, CLOSING, CLOSED, }; /** * @brief The delegate class to process websocket events. */ class Delegate { public: virtual ~Delegate() {} virtual void onOpen(WebSocket* ws) = 0; virtual void onMessage(WebSocket* ws, const Data& data) = 0; virtual void onClose(WebSocket* ws) = 0; virtual void onError(WebSocket* ws, const ErrorCode& error) = 0; }; /** * @brief The initialized method for websocket. * It needs to be invoked right after websocket instance is allocated. * @param delegate The delegate which want to receive event from websocket. * @param url The URL of websocket server. * @return true: Success, false: Failure */ bool init(const Delegate& delegate, const std::string& url, const std::vector* protocols = nullptr); /** * @brief Sends string data to websocket server. */ void send(const std::string& message); /** * @brief Sends binary data to websocket server. */ void send(const unsigned char* binaryMsg, unsigned int len); /** * @brief Closes the connection to server. */ void close(); /** * @brief Gets current state of connection. */ State getReadyState(); private: virtual void onSubThreadStarted(); virtual int onSubThreadLoop(); virtual void onSubThreadEnded(); virtual void onUIThreadReceiveMessage(WsMessage* msg); friend class WebSocketCallbackWrapper; int onSocketCallback(struct libwebsocket_context *ctx, struct libwebsocket *wsi, int reason, void *user, void *in, ssize_t len); private: State _readyState; std::string _host; unsigned int _port; std::string _path; ssize_t _pendingFrameDataLen; ssize_t _currentDataLen; char *_currentData; friend class WsThreadHelper; WsThreadHelper* _wsHelper; struct libwebsocket* _wsInstance; struct libwebsocket_context* _wsContext; Delegate* _delegate; int _SSLConnection; struct libwebsocket_protocols* _wsProtocols; }; } NS_CC_END #endif /* defined(__CC_JSB_WEBSOCKET_H__) */ ================================================ FILE: cocos2d/cocos/network/proj.win32/libNetwork.vcxproj ================================================  Debug Win32 Release Win32 libNetwork {DF2638C0-8128-4847-867C-6EAFE3DEE7B5} network.win32 Win32Proj StaticLibrary Unicode v100 v110 v110_xp StaticLibrary NotSet v100 v110 v110_xp <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false AllRules.ruleset AllRules.ruleset $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) Disabled $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;$(EngineRoot)cocos;$(EngineRoot)external\websockets\include\win32;$(EngineRoot)external\curl\include\win32;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue 4251 true winmm.lib;libcocos2d.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll true Windows $(TargetDir)$(TargetName).lib MachineX86 $(OutDir) $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;$(EngineRoot)cocos;$(EngineRoot)external\websockets\include\win32;$(EngineRoot)external\curl\include\win32;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase 4251 true winmm.lib;libcocos2d.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll true Windows true true $(TargetDir)$(TargetName).lib MachineX86 $(OutDir) ================================================ FILE: cocos2d/cocos/network/proj.win32/libNetwork.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx Header Files Header Files Header Files Header Files Header Files Source Files Source Files Source Files ================================================ FILE: cocos2d/cocos/physics/CCPhysicsBody.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCPhysicsBody.h" #if CC_USE_PHYSICS #include #include #include #include "chipmunk.h" #include "CCPhysicsShape.h" #include "CCPhysicsJoint.h" #include "CCPhysicsWorld.h" #include "chipmunk/CCPhysicsBodyInfo_chipmunk.h" #include "chipmunk/CCPhysicsJointInfo_chipmunk.h" #include "chipmunk/CCPhysicsWorldInfo_chipmunk.h" #include "chipmunk/CCPhysicsShapeInfo_chipmunk.h" #include "chipmunk/CCPhysicsHelper_chipmunk.h" NS_CC_BEGIN extern const float PHYSICS_INFINITY; namespace { static const float MASS_DEFAULT = 1.0; static const float MOMENT_DEFAULT = 200; } PhysicsBody::PhysicsBody() : _node(nullptr) , _world(nullptr) , _info(nullptr) , _dynamic(true) , _enable(true) , _rotationEnable(true) , _gravityEnable(true) , _massDefault(true) , _momentDefault(true) , _mass(MASS_DEFAULT) , _area(0.0f) , _density(0.0f) , _moment(MOMENT_DEFAULT) , _linearDamping(0.0f) , _angularDamping(0.0f) , _tag(0) , _categoryBitmask(UINT_MAX) , _collisionBitmask(UINT_MAX) , _contactTestBitmask(UINT_MAX) , _group(0) { } PhysicsBody::~PhysicsBody() { for (auto it = _joints.begin(); it != _joints.end(); ++it) { PhysicsJoint* joint = *it; PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyB() : joint->getBodyA(); other->removeJoint(joint); delete joint; } CC_SAFE_DELETE(_info); } PhysicsBody* PhysicsBody::create() { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::create(float mass) { PhysicsBody* body = new PhysicsBody(); if (body) { body->_mass = mass; body->_massDefault = false; if (body->init()) { body->autorelease(); return body; } } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::create(float mass, float moment) { PhysicsBody* body = new PhysicsBody(); if (body) { body->_mass = mass; body->_massDefault = false; body->_moment = moment; body->_momentDefault = false; if (body->init()) { body->autorelease(); return body; } } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::createCircle(float radius, const PhysicsMaterial& material, const Point& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeCircle::create(radius, material, offset)); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::createBox(const Size& size, const PhysicsMaterial& material, const Point& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeBox::create(size, material, offset)); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::createPolygon(const Point* points, int count, const PhysicsMaterial& material, const Point& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapePolygon::create(points, count, material, offset)); body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::createEdgeSegment(const Point& a, const Point& b, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgeSegment::create(a, b, material, border)); body->_dynamic = false; body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::createEdgeBox(const Size& size, const PhysicsMaterial& material, float border/* = 1*/, const Point& offset) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgeBox::create(size, material, border, offset)); body->_dynamic = false; body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::createEdgePolygon(const Point* points, int count, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgePolygon::create(points, count, material, border)); body->_dynamic = false; body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; } PhysicsBody* PhysicsBody::createEdgeChain(const Point* points, int count, const PhysicsMaterial& material, float border/* = 1*/) { PhysicsBody* body = new PhysicsBody(); if (body && body->init()) { body->addShape(PhysicsShapeEdgeChain::create(points, count, material, border)); body->_dynamic = false; body->autorelease(); return body; } CC_SAFE_DELETE(body); return nullptr; } bool PhysicsBody::init() { do { _info = new PhysicsBodyInfo(); CC_BREAK_IF(_info == nullptr); _info->setBody(cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment))); CC_BREAK_IF(_info->getBody() == nullptr); return true; } while (false); return false; } void PhysicsBody::removeJoint(PhysicsJoint* joint) { auto it = std::find(_joints.begin(), _joints.end(), joint); if (it != _joints.end()) { _joints.erase(it); } } void PhysicsBody::setDynamic(bool dynamic) { if (dynamic != _dynamic) { _dynamic = dynamic; if (dynamic) { cpBodySetMass(_info->getBody(), _mass); cpBodySetMoment(_info->getBody(), _moment); if (_world != nullptr) { // reset the gravity enable if (isGravityEnabled()) { _gravityEnable = false; setGravityEnable(true); } cpSpaceAddBody(_world->_info->getSpace(), _info->getBody()); } } else { if (_world != nullptr) { cpSpaceRemoveBody(_world->_info->getSpace(), _info->getBody()); } // avoid incorrect collion simulation. cpBodySetMass(_info->getBody(), PHYSICS_INFINITY); cpBodySetMoment(_info->getBody(), PHYSICS_INFINITY); cpBodySetVel(_info->getBody(), cpvzero); cpBodySetAngVel(_info->getBody(), 0.0f); } } } void PhysicsBody::setRotationEnable(bool enable) { if (_rotationEnable != enable) { cpBodySetMoment(_info->getBody(), enable ? _moment : PHYSICS_INFINITY); _rotationEnable = enable; } } void PhysicsBody::setGravityEnable(bool enable) { if (_gravityEnable != enable) { _gravityEnable = enable; if (_world != nullptr) { if (enable) { applyForce(_world->getGravity() * _mass); }else { applyForce(-_world->getGravity() * _mass); } } } } void PhysicsBody::setPosition(Point position) { cpBodySetPos(_info->getBody(), PhysicsHelper::point2cpv(position)); } void PhysicsBody::setRotation(float rotation) { cpBodySetAngle(_info->getBody(), PhysicsHelper::float2cpfloat(rotation * M_PI / 180.0f)); } Point PhysicsBody::getPosition() const { cpVect vec = cpBodyGetPos(_info->getBody()); return PhysicsHelper::cpv2point(vec); } float PhysicsBody::getRotation() const { return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_info->getBody()) / M_PI * 180.0f); } PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/* = true*/) { if (shape == nullptr) return nullptr; // add shape to body if (_shapes.getIndex(shape) == -1) { shape->setBody(this); // calculate the area, mass, and desity // area must update before mass, because the density changes depend on it. if (addMassAndMoment) { _area += shape->getArea(); addMass(shape->getMass()); addMoment(shape->getMoment()); } if (_world != nullptr) { _world->addShape(shape); } _shapes.pushBack(shape); if (_group != CP_NO_GROUP && shape->getGroup() == CP_NO_GROUP) { shape->setGroup(_group); } } return shape; } void PhysicsBody::applyForce(const Vect& force) { applyForce(force, Point::ZERO); } void PhysicsBody::applyForce(const Vect& force, const Point& offset) { cpBodyApplyForce(_info->getBody(), PhysicsHelper::point2cpv(force), PhysicsHelper::point2cpv(offset)); } void PhysicsBody::resetForces() { cpBodyResetForces(_info->getBody()); // if _gravityEnable is false, add a reverse of gravity force to body if (_world != nullptr && !_gravityEnable) { applyForce(-_world->getGravity() * _mass); } } void PhysicsBody::applyImpulse(const Vect& impulse) { applyImpulse(impulse, Point()); } void PhysicsBody::applyImpulse(const Vect& impulse, const Point& offset) { cpBodyApplyImpulse(_info->getBody(), PhysicsHelper::point2cpv(impulse), PhysicsHelper::point2cpv(offset)); } void PhysicsBody::applyTorque(float torque) { cpBodySetTorque(_info->getBody(), PhysicsHelper::float2cpfloat(torque)); } void PhysicsBody::setMass(float mass) { if (mass <= 0) { return; } _mass = mass; _massDefault = false; // update density if (_mass == PHYSICS_INFINITY) { _density = PHYSICS_INFINITY; } else { if (_area > 0) { _density = _mass / _area; }else { _density = 0; } } // the static body's mass and moment is always infinity if (_dynamic) { cpBodySetMass(_info->getBody(), PhysicsHelper::float2cpfloat(_mass)); } } void PhysicsBody::addMass(float mass) { if (mass == PHYSICS_INFINITY) { _mass = PHYSICS_INFINITY; _massDefault = false; _density = PHYSICS_INFINITY; } else if (mass == -PHYSICS_INFINITY) { return; } else if (_mass != PHYSICS_INFINITY) { if (_massDefault) { _mass = 0; _massDefault = false; } if (_mass + mass > 0) { _mass += mass; }else { _mass = MASS_DEFAULT; _massDefault = true; } if (_area > 0) { _density = _mass / _area; } else { _density = 0; } } // the static body's mass and moment is always infinity if (_dynamic) { cpBodySetMass(_info->getBody(), PhysicsHelper::float2cpfloat(_mass)); } } void PhysicsBody::addMoment(float moment) { if (moment == PHYSICS_INFINITY) { // if moment is PHYSICS_INFINITY, the moment of the body will become PHYSICS_INFINITY _moment = PHYSICS_INFINITY; _momentDefault = false; } else if (moment == -PHYSICS_INFINITY) { // if moment is -PHYSICS_INFINITY, it won't change return; } else { // if moment of the body is PHYSICS_INFINITY is has no effect if (_moment != PHYSICS_INFINITY) { if (_momentDefault) { _moment = 0; _momentDefault = false; } if (_moment + moment > 0) { _moment += moment; } else { _moment = MOMENT_DEFAULT; _momentDefault = true; } } } // the static body's mass and moment is always infinity if (_rotationEnable && _dynamic) { cpBodySetMoment(_info->getBody(), PhysicsHelper::float2cpfloat(_moment)); } } void PhysicsBody::setVelocity(const Point& velocity) { if (!_dynamic) { CCLOG("physics warning: your can't set velocity for a static body."); return; } cpBodySetVel(_info->getBody(), PhysicsHelper::point2cpv(velocity)); } Point PhysicsBody::getVelocity() { return PhysicsHelper::cpv2point(cpBodyGetVel(_info->getBody())); } Point PhysicsBody::getVelocityAtLocalPoint(const Point& point) { return PhysicsHelper::cpv2point(cpBodyGetVelAtLocalPoint(_info->getBody(), PhysicsHelper::point2cpv(point))); } Point PhysicsBody::getVelocityAtWorldPoint(const Point& point) { return PhysicsHelper::cpv2point(cpBodyGetVelAtWorldPoint(_info->getBody(), PhysicsHelper::point2cpv(point))); } void PhysicsBody::setAngularVelocity(float velocity) { if (!_dynamic) { CCLOG("physics warning: your can't set angular velocity for a static body."); return; } cpBodySetAngVel(_info->getBody(), PhysicsHelper::float2cpfloat(velocity)); } float PhysicsBody::getAngularVelocity() { return PhysicsHelper::cpfloat2float(cpBodyGetAngVel(_info->getBody())); } void PhysicsBody::setVelocityLimit(float limit) { cpBodySetVelLimit(_info->getBody(), PhysicsHelper::float2cpfloat(limit)); } float PhysicsBody::getVelocityLimit() { return PhysicsHelper::cpfloat2float(cpBodyGetVelLimit(_info->getBody())); } void PhysicsBody::setAngularVelocityLimit(float limit) { cpBodySetVelLimit(_info->getBody(), PhysicsHelper::float2cpfloat(limit)); } float PhysicsBody::getAngularVelocityLimit() { return PhysicsHelper::cpfloat2float(cpBodyGetAngVelLimit(_info->getBody())); } void PhysicsBody::setMoment(float moment) { _moment = moment; _momentDefault = false; // the static body's mass and moment is always infinity if (_rotationEnable && _dynamic) { cpBodySetMoment(_info->getBody(), PhysicsHelper::float2cpfloat(_moment)); } } PhysicsShape* PhysicsBody::getShape(int tag) const { for (auto& shape : _shapes) { if (shape->getTag() == tag) { return shape; } } return nullptr; } void PhysicsBody::removeShape(int tag, bool reduceMassAndMoment/* = true*/) { for (auto& shape : _shapes) { if (shape->getTag() == tag) { removeShape(shape, reduceMassAndMoment); return; } } } void PhysicsBody::removeShape(PhysicsShape* shape, bool reduceMassAndMoment/* = true*/) { if (_shapes.getIndex(shape) != -1) { // deduce the area, mass and moment // area must update before mass, because the density changes depend on it. if (reduceMassAndMoment) { _area -= shape->getArea(); addMass(-shape->getMass()); addMoment(-shape->getMoment()); } //remove if (_world) { _world->removeShape(shape); } // set shape->_body = nullptr make the shape->setBody will not trigger the _body->removeShape function call. shape->_body = nullptr; shape->setBody(nullptr); _shapes.eraseObject(shape); } } void PhysicsBody::removeAllShapes(bool reduceMassAndMoment/* = true*/) { for (auto& child : _shapes) { PhysicsShape* shape = dynamic_cast(child); // deduce the area, mass and moment // area must update before mass, because the density changes depend on it. if (reduceMassAndMoment) { _area -= shape->getArea(); addMass(-shape->getMass()); addMoment(-shape->getMoment()); } if (_world) { _world->removeShape(shape); } // set shape->_body = nullptr make the shape->setBody will not trigger the _body->removeShape function call. shape->_body = nullptr; shape->setBody(nullptr); } _shapes.clear(); } void PhysicsBody::removeFromWorld() { if (_world) { _world->removeBody(this); } } void PhysicsBody::setEnable(bool enable) { if (_enable != enable) { _enable = enable; if (_world) { if (enable) { _world->addBodyOrDelay(this); }else { _world->removeBodyOrDelay(this); } } } } bool PhysicsBody::isResting() const { return cpBodyIsSleeping(_info->getBody()) == cpTrue; } void PhysicsBody::update(float delta) { // damping compute if (_dynamic && !isResting()) { _info->getBody()->v.x *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); _info->getBody()->v.y *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f); _info->getBody()->w *= cpfclamp(1.0f - delta * _angularDamping, 0.0f, 1.0f); } } void PhysicsBody::setCategoryBitmask(int bitmask) { _categoryBitmask = bitmask; for (auto& shape : _shapes) { shape->setCategoryBitmask(bitmask); } } void PhysicsBody::setContactTestBitmask(int bitmask) { _contactTestBitmask = bitmask; for (auto& shape : _shapes) { shape->setContactTestBitmask(bitmask); } } void PhysicsBody::setCollisionBitmask(int bitmask) { _collisionBitmask = bitmask; for (auto& shape : _shapes) { shape->setCollisionBitmask(bitmask); } } void PhysicsBody::setGroup(int group) { for (auto& shape : _shapes) { shape->setGroup(group); } } Point PhysicsBody::world2Local(const Point& point) { return PhysicsHelper::cpv2point(cpBodyWorld2Local(_info->getBody(), PhysicsHelper::point2cpv(point))); } Point PhysicsBody::local2World(const Point& point) { return PhysicsHelper::cpv2point(cpBodyLocal2World(_info->getBody(), PhysicsHelper::point2cpv(point))); } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/CCPhysicsBody.h ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPHYSICS_BODY_H__ #define __CCPHYSICS_BODY_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "CCObject.h" #include "CCGeometry.h" #include "CCPhysicsShape.h" #include "CCVector.h" NS_CC_BEGIN class Sprite; class PhysicsWorld; class PhysicsJoint; class PhysicsBodyInfo; typedef Point Vect; const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT(0.1f, 0.5f, 0.5f); /** * A body affect by physics. * it can attach one or more shapes. * if you create body with createXXX, it will automatically compute mass and moment with density your specified(which is PHYSICSBODY_MATERIAL_DEFAULT by default, and the density value is 0.1f), and it based on the formular: mass = density * area. * if you create body with createEdgeXXX, the mass and moment will be PHYSICS_INFINITY by default. and it's a static body. * you can change mass and moment with setMass() and setMoment(). and you can change the body to be dynamic or static by use function setDynamic(). */ class PhysicsBody : public Object { public: /** create a body with defult mass and moment. */ static PhysicsBody* create(); /** create a body with mass and defult moment. */ static PhysicsBody* create(float mass); /** create a body with mass and moment. */ static PhysicsBody* create(float mass, float moment); /** Create a body contains a circle shape. */ static PhysicsBody* createCircle(float radius, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Point& offset = Point::ZERO); /** Create a body contains a box shape. */ static PhysicsBody* createBox(const Size& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Point& offset = Point::ZERO); /** * @brief Create a body contains a polygon shape. * points is an array of Point structs defining a convex hull with a clockwise winding. */ static PhysicsBody* createPolygon(const Point* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, const Point& offset = Point::ZERO); /** Create a body contains a EdgeSegment shape. */ static PhysicsBody* createEdgeSegment(const Point& a, const Point& b, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); /** Create a body contains a EdgeBox shape. */ static PhysicsBody* createEdgeBox(const Size& size, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1, const Point& offset = Point::ZERO); /** Create a body contains a EdgePolygon shape. */ static PhysicsBody* createEdgePolygon(const Point* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); /** Create a body contains a EdgeChain shape. */ static PhysicsBody* createEdgeChain(const Point* points, int count, const PhysicsMaterial& material = PHYSICSBODY_MATERIAL_DEFAULT, float border = 1); /* * @brief add a shape to body * @param shape the shape to be added * @param addMassAndMoment if this is true, the shape's mass and moment will be added to body. the default is true */ virtual PhysicsShape* addShape(PhysicsShape* shape, bool addMassAndMoment = true); /* * @brief remove a shape from body * @param shape the shape to be removed * @param reduceMassAndMoment if this is true, the body mass and moment will be reduced by shape. the default is true */ void removeShape(PhysicsShape* shape, bool reduceMassAndMoment = true); /* * @brief remove a shape from body * @param tag the tag of the shape to be removed * @param reduceMassAndMoment if this is true, the body mass and moment will be reduced by shape. the default is true */ void removeShape(int tag, bool reduceMassAndMoment = true); /* remove all shapes */ void removeAllShapes(bool reduceMassAndMoment = true); /* get the body shapes. */ inline const Vector& getShapes() const { return _shapes; } /* get the first shape of the body shapes. */ inline PhysicsShape* getFirstShape() const { return _shapes.size() >= 1 ? _shapes.at(0) : nullptr; } /* get the shape of the body. */ PhysicsShape* getShape(int tag) const; /** Applies a immediate force to body. */ virtual void applyForce(const Vect& force); /** Applies a immediate force to body. */ virtual void applyForce(const Vect& force, const Point& offset); /** reset all the force applied to body. */ virtual void resetForces(); /** Applies a continuous force to body. */ virtual void applyImpulse(const Vect& impulse); /** Applies a continuous force to body. */ virtual void applyImpulse(const Vect& impulse, const Point& offset); /** Applies a torque force to body. */ virtual void applyTorque(float torque); /** set the velocity of a body */ virtual void setVelocity(const Vect& velocity); /** get the velocity of a body */ virtual Point getVelocity(); /** set the angular velocity of a body */ virtual void setAngularVelocity(float velocity); /** get the angular velocity of a body at a local point */ virtual Point getVelocityAtLocalPoint(const Point& point); /** get the angular velocity of a body at a world point */ virtual Point getVelocityAtWorldPoint(const Point& point); /** get the angular velocity of a body */ virtual float getAngularVelocity(); /** set the max of velocity */ virtual void setVelocityLimit(float limit); /** get the max of velocity */ virtual float getVelocityLimit(); /** set the max of angular velocity */ virtual void setAngularVelocityLimit(float limit); /** get the max of angular velocity */ virtual float getAngularVelocityLimit(); /** remove the body from the world it added to */ void removeFromWorld(); /** get the world body added to. */ inline PhysicsWorld* getWorld() const { return _world; } /** get all joints the body have */ inline const std::vector& getJoints() const { return _joints; } /** get the sprite the body set to. */ inline Node* getNode() const { return _node; } /** * A mask that defines which categories this physics body belongs to. * Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. You define the mask values used in your game. In conjunction with the collisionBitMask and contactTestBitMask properties, you define which physics bodies interact with each other and when your game is notified of these interactions. * The default value is 0xFFFFFFFF (all bits set). */ void setCategoryBitmask(int bitmask); /** * A mask that defines which categories of bodies cause intersection notifications with this physics body. * When two bodies share the same space, each body’s category mask is tested against the other body’s contact mask by performing a logical AND operation. If either comparison results in a non-zero value, an PhysicsContact object is created and passed to the physics world’s delegate. For best performance, only set bits in the contacts mask for interactions you are interested in. * The default value is 0x00000000 (all bits cleared). */ void setContactTestBitmask(int bitmask); /** * A mask that defines which categories of physics bodies can collide with this physics body. * When two physics bodies contact each other, a collision may occur. This body’s collision mask is compared to the other body’s category mask by performing a logical AND operation. If the result is a non-zero value, then this body is affected by the collision. Each body independently chooses whether it wants to be affected by the other body. For example, you might use this to avoid collision calculations that would make negligible changes to a body’s velocity. * The default value is 0xFFFFFFFF (all bits set). */ void setCollisionBitmask(int bitmask); /** get the category bit mask */ inline int getCategoryBitmask() const { return _categoryBitmask; } /** get the contact test bit mask */ inline int getContactTestBitmask() const { return _contactTestBitmask; } /** get the collision bit mask */ inline int getCollisionBitmask() const { return _collisionBitmask; } /** * set the group of body * Collision groups let you specify an integral group index. You can have all fixtures with the same group index always collide (positive index) or never collide (negative index) * it have high priority than bit masks */ void setGroup(int group); /** get the group of body */ inline int getGroup() const { return _group; } /** get the body position. */ Point getPosition() const; /** get the body rotation. */ float getRotation() const; /** * @brief test the body is dynamic or not. * a dynamic body will effect with gravity. */ inline bool isDynamic() const { return _dynamic; } /** * @brief set dynamic to body. * a dynamic body will effect with gravity. */ void setDynamic(bool dynamic); /** * @brief set the body mass. * @note if you need add/subtract mass to body, don't use setMass(getMass() +/- mass), because the mass of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMass() instead. */ void setMass(float mass); /** get the body mass. */ inline float getMass() const { return _mass; } /** * @brief add mass to body. * if _mass(mass of the body) == PHYSICS_INFINITY, it remains. * if mass == PHYSICS_INFINITY, _mass will be PHYSICS_INFINITY. * if mass == -PHYSICS_INFINITY, _mass will not change. * if mass + _mass <= 0, _mass will equal to MASS_DEFAULT(1.0) * other wise, mass = mass + _mass; */ void addMass(float mass); /** * @brief set the body moment of inertia. * @note if you need add/subtract moment to body, don't use setMoment(getMoment() +/- moment), because the moment of body may be equal to PHYSICS_INFINITY, it will cause some unexpected result, please use addMoment() instead. */ void setMoment(float moment); /** get the body moment of inertia. */ inline float getMoment(float moment) const { return _moment; } /** * @brief add moment of inertia to body. * if _moment(moment of the body) == PHYSICS_INFINITY, it remains. * if moment == PHYSICS_INFINITY, _moment will be PHYSICS_INFINITY. * if moment == -PHYSICS_INFINITY, _moment will not change. * if moment + _moment <= 0, _moment will equal to MASS_DEFAULT(1.0) * other wise, moment = moment + _moment; */ void addMoment(float moment); /** get linear damping. */ inline float getLinearDamping() const { return _linearDamping; } /** * set linear damping. * it is used to simulate fluid or air friction forces on the body. * the value is 0.0f to 1.0f. */ inline void setLinearDamping(float damping) { _linearDamping = damping; } /** get angular damping. */ inline float getAngularDamping() const { return _angularDamping; } /** * set angular damping. * it is used to simulate fluid or air friction forces on the body. * the value is 0.0f to 1.0f. */ inline void setAngularDamping(float damping) { _angularDamping = damping; } /** whether the body is at rest */ bool isResting() const; /** * whether the body is enabled * if the body it isn't enabled, it will not has simulation by world */ inline bool isEnabled() const { return _enable; } /** * set the enable value. * if the body it isn't enabled, it will not has simulation by world */ void setEnable(bool enable); /** whether the body can rotation */ inline bool isRotationEnabled() const { return _rotationEnable; } /** set the body is allow rotation or not */ void setRotationEnable(bool enable); /** whether this physics body is affected by the physics world’s gravitational force. */ inline bool isGravityEnabled() const { return _gravityEnable; } /** set the body is affected by the physics world's gravitational force or not. */ void setGravityEnable(bool enable); /** get the body's tag */ inline int getTag() const { return _tag; } /** set the body's tag */ inline void setTag(int tag) { _tag = tag; } /** convert the world point to local */ Point world2Local(const Point& point); /** convert the local point to world */ Point local2World(const Point& point); protected: bool init(); virtual void setPosition(Point position); virtual void setRotation(float rotation); virtual void update(float delta) override; void removeJoint(PhysicsJoint* joint); protected: PhysicsBody(); virtual ~PhysicsBody(); protected: Node* _node; std::vector _joints; Vector _shapes; PhysicsWorld* _world; PhysicsBodyInfo* _info; bool _dynamic; bool _enable; bool _rotationEnable; bool _gravityEnable; bool _massDefault; bool _momentDefault; float _mass; float _area; float _density; float _moment; float _linearDamping; float _angularDamping; int _tag; int _categoryBitmask; int _collisionBitmask; int _contactTestBitmask; int _group; friend class PhysicsWorld; friend class PhysicsShape; friend class PhysicsJoint; friend class Node; }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_BODY_H__ ================================================ FILE: cocos2d/cocos/physics/CCPhysicsContact.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCPhysicsContact.h" #if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPhysicsBody.h" #include "chipmunk/CCPhysicsContactInfo_chipmunk.h" #include "chipmunk/CCPhysicsHelper_chipmunk.h" #include "CCEventCustom.h" NS_CC_BEGIN const char* PHYSICSCONTACT_EVENT_NAME = "PhysicsContactEvent"; PhysicsContact::PhysicsContact() : Event(Event::Type::CUSTOM) , _world(nullptr) , _shapeA(nullptr) , _shapeB(nullptr) , _eventCode(EventCode::NONE) , _info(nullptr) , _notificationEnable(true) , _begin(false) , _result(true) , _data(nullptr) , _contactInfo(nullptr) , _contactData(nullptr) { } PhysicsContact::~PhysicsContact() { CC_SAFE_DELETE(_info); CC_SAFE_DELETE(_contactData); } PhysicsContact* PhysicsContact::construct(PhysicsShape* a, PhysicsShape* b) { PhysicsContact * contact = new PhysicsContact(); if(contact && contact->init(a, b)) { return contact; } CC_SAFE_DELETE(contact); return nullptr; } bool PhysicsContact::init(PhysicsShape* a, PhysicsShape* b) { do { CC_BREAK_IF(a == nullptr || b == nullptr); CC_BREAK_IF(!(_info = new PhysicsContactInfo(this))); _shapeA = a; _shapeB = b; return true; } while(false); return false; } void PhysicsContact::generateContactData() { if (_contactInfo == nullptr) { return; } cpArbiter* arb = static_cast(_contactInfo); _contactData = new PhysicsContactData(); _contactData->count = cpArbiterGetCount(arb); for (int i=0; i<_contactData->count && ipoints[i] = PhysicsHelper::cpv2point(cpArbiterGetPoint(arb, i)); } _contactData->normal = _contactData->count > 0 ? PhysicsHelper::cpv2point(cpArbiterGetNormal(arb, 0)) : Point::ZERO; } // PhysicsContactPreSolve implementation PhysicsContactPreSolve::PhysicsContactPreSolve(PhysicsContactData* data, void* contactInfo) : _preContactData(data) , _contactInfo(contactInfo) { } PhysicsContactPreSolve::~PhysicsContactPreSolve() { CC_SAFE_DELETE(_preContactData); } float PhysicsContactPreSolve::getElasticity() const { return static_cast(_contactInfo)->e; } float PhysicsContactPreSolve::getFriction() const { return static_cast(_contactInfo)->u; } Point PhysicsContactPreSolve::getSurfaceVelocity() const { return PhysicsHelper::cpv2point(static_cast(_contactInfo)->surface_vr); } void PhysicsContactPreSolve::setElasticity(float elasticity) { static_cast(_contactInfo)->e = elasticity; } void PhysicsContactPreSolve::setFriction(float friction) { static_cast(_contactInfo)->u = friction; } void PhysicsContactPreSolve::setSurfaceVelocity(const Vect& velocity) { static_cast(_contactInfo)->surface_vr = PhysicsHelper::point2cpv(velocity); } void PhysicsContactPreSolve::ignore() { cpArbiterIgnore(static_cast(_contactInfo)); } // PhysicsContactPostSolve implementation PhysicsContactPostSolve::PhysicsContactPostSolve(void* contactInfo) : _contactInfo(contactInfo) { } PhysicsContactPostSolve::~PhysicsContactPostSolve() { } float PhysicsContactPostSolve::getElasticity() const { return static_cast(_contactInfo)->e; } float PhysicsContactPostSolve::getFriction() const { return static_cast(_contactInfo)->u; } Point PhysicsContactPostSolve::getSurfaceVelocity() const { return PhysicsHelper::cpv2point(static_cast(_contactInfo)->surface_vr); } EventListenerPhysicsContact::EventListenerPhysicsContact() : onContactBegin(nullptr) , onContactPreSolve(nullptr) , onContactPostSolve(nullptr) , onContactSeperate(nullptr) { } bool EventListenerPhysicsContact::init() { auto func = [this](EventCustom* event) -> void { onEvent(event); }; return EventListenerCustom::init(PHYSICSCONTACT_EVENT_NAME, func); } void EventListenerPhysicsContact::onEvent(EventCustom* event) { PhysicsContact& contact = *(PhysicsContact*)(event->getUserData()); switch (contact.getEventCode()) { case PhysicsContact::EventCode::BEGIN: { bool ret = true; if (onContactBegin != nullptr && hitTest(contact.getShapeA(), contact.getShapeB())) { contact._begin = true; contact.generateContactData(); // the mask has high priority than _listener->onContactBegin. // so if the mask test is false, the two bodies won't have collision. if (ret) { ret = onContactBegin(event, contact); }else { onContactBegin(event, contact); } } contact.setResult(ret); break; } case PhysicsContact::EventCode::PRESOLVE: { bool ret = true; if (onContactPreSolve != nullptr && hitTest(contact.getShapeA(), contact.getShapeB())) { PhysicsContactPreSolve solve(contact._begin ? nullptr : contact._contactData, contact._contactInfo); contact._begin = false; contact.generateContactData(); ret = onContactPreSolve(event, contact, solve); } contact.setResult(ret); break; } case PhysicsContact::EventCode::POSTSOLVE: { if (onContactPostSolve != nullptr && hitTest(contact.getShapeA(), contact.getShapeB())) { PhysicsContactPostSolve solve(contact._contactInfo); onContactPostSolve(event, contact, solve); } break; } case PhysicsContact::EventCode::SEPERATE: { if (onContactSeperate != nullptr && hitTest(contact.getShapeA(), contact.getShapeB())) { onContactSeperate(event, contact); } break; } default: break; } } EventListenerPhysicsContact::~EventListenerPhysicsContact() { } EventListenerPhysicsContact* EventListenerPhysicsContact::create() { EventListenerPhysicsContact* obj = new EventListenerPhysicsContact(); if (obj != nullptr && obj->init()) { obj->autorelease(); return obj; } CC_SAFE_DELETE(obj); return nullptr; } bool EventListenerPhysicsContact::hitTest(PhysicsShape* shapeA, PhysicsShape* shapeB) { CC_UNUSED_PARAM(shapeA); CC_UNUSED_PARAM(shapeB); return true; } bool EventListenerPhysicsContact::checkAvailable() { if (onContactBegin == nullptr && onContactPreSolve == nullptr && onContactPostSolve == nullptr && onContactSeperate == nullptr) { CCASSERT(false, "Invalid PhysicsContactListener."); return false; } return true; } EventListenerPhysicsContact* EventListenerPhysicsContact::clone() { EventListenerPhysicsContact* obj = EventListenerPhysicsContact::create(); if (obj != nullptr) { obj->onContactBegin = onContactBegin; obj->onContactPreSolve = onContactPreSolve; obj->onContactPostSolve = onContactPostSolve; obj->onContactSeperate = onContactSeperate; return obj; } CC_SAFE_DELETE(obj); return nullptr; } EventListenerPhysicsContactWithBodies* EventListenerPhysicsContactWithBodies::create(PhysicsBody* bodyA, PhysicsBody* bodyB) { EventListenerPhysicsContactWithBodies* obj = new EventListenerPhysicsContactWithBodies(); if (obj != nullptr && obj->init()) { obj->_a = bodyA; obj->_b = bodyB; obj->autorelease(); return obj; } CC_SAFE_DELETE(obj); return nullptr; } EventListenerPhysicsContactWithBodies::EventListenerPhysicsContactWithBodies() : _a(nullptr) , _b(nullptr) { } EventListenerPhysicsContactWithBodies::~EventListenerPhysicsContactWithBodies() { } bool EventListenerPhysicsContactWithBodies::hitTest(PhysicsShape* shapeA, PhysicsShape* shapeB) { if ((shapeA->getBody() == _a && shapeB->getBody() == _b) || (shapeA->getBody() == _b && shapeB->getBody() == _a)) { return true; } return false; } EventListenerPhysicsContactWithBodies* EventListenerPhysicsContactWithBodies::clone() { EventListenerPhysicsContactWithBodies* obj = EventListenerPhysicsContactWithBodies::create(_a, _b); if (obj != nullptr) { obj->onContactBegin = onContactBegin; obj->onContactPreSolve = onContactPreSolve; obj->onContactPostSolve = onContactPostSolve; obj->onContactSeperate = onContactSeperate; return obj; } CC_SAFE_DELETE(obj); return nullptr; } EventListenerPhysicsContactWithShapes::EventListenerPhysicsContactWithShapes() : _a(nullptr) , _b(nullptr) { } EventListenerPhysicsContactWithShapes::~EventListenerPhysicsContactWithShapes() { } EventListenerPhysicsContactWithShapes* EventListenerPhysicsContactWithShapes::create(PhysicsShape* shapeA, PhysicsShape* shapeB) { EventListenerPhysicsContactWithShapes* obj = new EventListenerPhysicsContactWithShapes(); if (obj != nullptr && obj->init()) { obj->_a = shapeA; obj->_b = shapeB; obj->autorelease(); return obj; } CC_SAFE_DELETE(obj); return nullptr; } bool EventListenerPhysicsContactWithShapes::hitTest(PhysicsShape* shapeA, PhysicsShape* shapeB) { if ((shapeA == _a && shapeB == _b) || (shapeA == _b && shapeB == _a)) { return true; } return false; } EventListenerPhysicsContactWithShapes* EventListenerPhysicsContactWithShapes::clone() { EventListenerPhysicsContactWithShapes* obj = EventListenerPhysicsContactWithShapes::create(_a, _b); if (obj != nullptr) { obj->onContactBegin = onContactBegin; obj->onContactPreSolve = onContactPreSolve; obj->onContactPostSolve = onContactPostSolve; obj->onContactSeperate = onContactSeperate; return obj; } CC_SAFE_DELETE(obj); return nullptr; } EventListenerPhysicsContactWithGroup::EventListenerPhysicsContactWithGroup() : _group(CP_NO_GROUP) { } EventListenerPhysicsContactWithGroup::~EventListenerPhysicsContactWithGroup() { } EventListenerPhysicsContactWithGroup* EventListenerPhysicsContactWithGroup::create(int group) { EventListenerPhysicsContactWithGroup* obj = new EventListenerPhysicsContactWithGroup(); if (obj != nullptr && obj->init()) { obj->_group = group; obj->autorelease(); return obj; } CC_SAFE_DELETE(obj); return nullptr; } bool EventListenerPhysicsContactWithGroup::hitTest(PhysicsShape* shapeA, PhysicsShape* shapeB) { if (shapeA->getGroup() == _group || shapeB->getGroup() == _group) { return true; } return false; } EventListenerPhysicsContactWithGroup* EventListenerPhysicsContactWithGroup::clone() { EventListenerPhysicsContactWithGroup* obj = EventListenerPhysicsContactWithGroup::create(_group); if (obj != nullptr) { obj->onContactBegin = onContactBegin; obj->onContactPreSolve = onContactPreSolve; obj->onContactPostSolve = onContactPostSolve; obj->onContactSeperate = onContactSeperate; return obj; } CC_SAFE_DELETE(obj); return nullptr; } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/CCPhysicsContact.h ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPHYSICS_CONTACT_H__ #define __CCPHYSICS_CONTACT_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "CCObject.h" #include "CCGeometry.h" #include "CCEventListenerCustom.h" #include "CCEvent.h" NS_CC_BEGIN class PhysicsShape; class PhysicsBody; class PhysicsWorld; class PhysicsContactInfo; typedef Point Vect; typedef struct PhysicsContactData { static const int POINT_MAX = 4; Point points[POINT_MAX]; int count; Point normal; PhysicsContactData() : count(0) {} }PhysicsContactData; /** * @brief Contact infomation. it will created automatically when two shape contact with each other. and it will destoried automatically when two shape separated. */ class PhysicsContact : public Event { public: enum class EventCode { NONE, BEGIN, PRESOLVE, POSTSOLVE, SEPERATE }; /** get contact shape A. */ inline PhysicsShape* getShapeA() const { return _shapeA; } /** get contact shape B. */ inline PhysicsShape* getShapeB() const { return _shapeB; } /** get contact data */ inline const PhysicsContactData* getContactData() const { return _contactData; } /** get data. */ inline void* getData() const { return _data; } /** * @brief set data to contact. you must manage the memory yourself, Generally you can set data at contact begin, and distory it at contact seperate. */ inline void setData(void* data) { _data = data; } /** get the event code */ EventCode getEventCode() const { return _eventCode; }; private: static PhysicsContact* construct(PhysicsShape* a, PhysicsShape* b); bool init(PhysicsShape* a, PhysicsShape* b); void setEventCode(EventCode eventCode) { _eventCode = eventCode; }; inline bool isNotificationEnabled() const { return _notificationEnable; } inline void setNotificationEnable(bool enable) { _notificationEnable = enable; } inline PhysicsWorld* getWorld() const { return _world; } inline void setWorld(PhysicsWorld* world) { _world = world; } inline void setResult(bool result) { _result = result; } inline bool resetResult() { bool ret = _result; _result = true; return ret; } void generateContactData(); private: PhysicsContact(); ~PhysicsContact(); private: PhysicsWorld* _world; PhysicsShape* _shapeA; PhysicsShape* _shapeB; EventCode _eventCode; PhysicsContactInfo* _info; bool _notificationEnable; bool _begin; bool _result; void* _data; void* _contactInfo; PhysicsContactData* _contactData; friend class EventListenerPhysicsContact; friend class PhysicsWorldCallback; friend class PhysicsWorld; }; /* * @brief presolve value generated when onContactPreSolve called. */ class PhysicsContactPreSolve { public: /** get elasticity between two bodies*/ float getElasticity() const; /** get friction between two bodies*/ float getFriction() const; /** get surface velocity between two bodies*/ Point getSurfaceVelocity() const; /** set the elasticity*/ void setElasticity(float elasticity); /** set the friction*/ void setFriction(float friction); /** set the surface velocity*/ void setSurfaceVelocity(const Vect& velocity); /** ignore the rest of the contact presolve and postsolve callbacks */ void ignore(); private: PhysicsContactPreSolve(PhysicsContactData* data, void* contactInfo); ~PhysicsContactPreSolve(); private: float _elasticity; float _friction; Point _surfaceVelocity; PhysicsContactData* _preContactData; void* _contactInfo; friend class EventListenerPhysicsContact; }; /* * @brief postsolve value generated when onContactPostSolve called. */ class PhysicsContactPostSolve { public: /** get elasticity between two bodies*/ float getElasticity() const; /** get friction between two bodies*/ float getFriction() const; /** get surface velocity between two bodies*/ Point getSurfaceVelocity() const; private: PhysicsContactPostSolve(void* contactInfo); ~PhysicsContactPostSolve(); private: void* _contactInfo; friend class EventListenerPhysicsContact; }; /* contact listener. it will recive all the contact callbacks. */ class EventListenerPhysicsContact : public EventListenerCustom { public: /** create the listener */ static EventListenerPhysicsContact* create(); virtual bool checkAvailable() override; virtual EventListenerPhysicsContact* clone() override; protected: /** * it will be call when two body have contact. * if return false, it will not invoke callbacks */ virtual bool hitTest(PhysicsShape* shapeA, PhysicsShape* shapeB); public: /* * @brief it will called at two shapes start to contact, and only call it once. */ std::function onContactBegin; /* * @brief Two shapes are touching during this step. Return false from the callback to make world ignore the collision this step or true to process it normally. Additionally, you may override collision values, elasticity, or surface velocity values. */ std::function onContactPreSolve; /* * @brief Two shapes are touching and their collision response has been processed. You can retrieve the collision impulse or kinetic energy at this time if you want to use it to calculate sound volumes or damage amounts. See cpArbiter for more info */ std::function onContactPostSolve; /* * @brief it will called at two shapes separated, and only call it once. * onContactBegin and onContactSeperate will called in pairs. */ std::function onContactSeperate; protected: bool init(); void onEvent(EventCustom* event); protected: EventListenerPhysicsContact(); virtual ~EventListenerPhysicsContact(); friend class PhysicsWorld; }; /** this event listener only be called when bodyA and bodyB have contacts */ class EventListenerPhysicsContactWithBodies : public EventListenerPhysicsContact { public: static EventListenerPhysicsContactWithBodies* create(PhysicsBody* bodyA, PhysicsBody* bodyB); virtual bool hitTest(PhysicsShape* shapeA, PhysicsShape* shapeB) override; virtual EventListenerPhysicsContactWithBodies* clone() override; protected: PhysicsBody* _a; PhysicsBody* _b; protected: EventListenerPhysicsContactWithBodies(); virtual ~EventListenerPhysicsContactWithBodies(); }; /** this event listener only be called when shapeA and shapeB have contacts */ class EventListenerPhysicsContactWithShapes : public EventListenerPhysicsContact { public: static EventListenerPhysicsContactWithShapes* create(PhysicsShape* shapeA, PhysicsShape* shapeB); virtual bool hitTest(PhysicsShape* shapeA, PhysicsShape* shapeB) override; virtual EventListenerPhysicsContactWithShapes* clone() override; protected: PhysicsShape* _a; PhysicsShape* _b; protected: EventListenerPhysicsContactWithShapes(); virtual ~EventListenerPhysicsContactWithShapes(); }; /** this event listener only be called when shapeA or shapeB is in the group your specified */ class EventListenerPhysicsContactWithGroup : public EventListenerPhysicsContact { public: static EventListenerPhysicsContactWithGroup* create(int group); virtual bool hitTest(PhysicsShape* shapeA, PhysicsShape* shapeB) override; virtual EventListenerPhysicsContactWithGroup* clone() override; protected: int _group; protected: EventListenerPhysicsContactWithGroup(); virtual ~EventListenerPhysicsContactWithGroup(); }; NS_CC_END #endif // CC_USE_PHYSICS #endif //__CCPHYSICS_CONTACT_H__ ================================================ FILE: cocos2d/cocos/physics/CCPhysicsJoint.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCPhysicsJoint.h" #if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPhysicsBody.h" #include "CCPhysicsWorld.h" #include "chipmunk/CCPhysicsJointInfo_chipmunk.h" #include "chipmunk/CCPhysicsBodyInfo_chipmunk.h" #include "chipmunk/CCPhysicsShapeInfo_chipmunk.h" #include "chipmunk/CCPhysicsHelper_chipmunk.h" #include "CCNode.h" NS_CC_BEGIN PhysicsJoint::PhysicsJoint() : _bodyA(nullptr) , _bodyB(nullptr) , _world(nullptr) , _info(nullptr) , _enable(false) , _collisionEnable(true) , _destoryMark(false) , _tag(0) { } PhysicsJoint::~PhysicsJoint() { // reset the shapes collision group setCollisionEnable(true); CC_SAFE_DELETE(_info); } bool PhysicsJoint::init(cocos2d::PhysicsBody *a, cocos2d::PhysicsBody *b) { do { CCASSERT(a != nullptr && b != nullptr, "the body passed in is nil"); CCASSERT(a != b, "the two bodies are equal"); CC_BREAK_IF(!(_info = new PhysicsJointInfo(this))); _bodyA = a; _bodyA->_joints.push_back(this); _bodyB = b; _bodyB->_joints.push_back(this); return true; } while (false); return false; } void PhysicsJoint::setEnable(bool enable) { if (_enable != enable) { _enable = enable; if (_world != nullptr) { if (enable) { _world->addJointOrDelay(this); }else { _world->removeJointOrDelay(this); } } } } PhysicsBodyInfo* PhysicsJoint::getBodyInfo(PhysicsBody* body) const { return body->_info; } Node* PhysicsJoint::getBodyNode(PhysicsBody* body) const { return body->_node; } void PhysicsJoint::setCollisionEnable(bool enable) { if (_collisionEnable != enable) { _collisionEnable = enable; } } void PhysicsJoint::removeFormWorld() { if (_world) { _world->removeJoint(this, false); } } void PhysicsJoint::destroy(PhysicsJoint* joint) { if (joint!= nullptr) { // remove the joint and delete it. if (joint->_world != nullptr) { joint->_world->removeJoint(joint, true); } else { if (joint->_bodyA != nullptr) { joint->_bodyA->removeJoint(joint); } if (joint->_bodyB != nullptr) { joint->_bodyB->removeJoint(joint); } delete joint; } } } void PhysicsJoint::setMaxForce(float force) { for (cpConstraint* joint : _info->getJoints()) { joint->maxForce = PhysicsHelper::float2cpfloat(force); } } float PhysicsJoint::getMaxForce() const { return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce); } PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr) { PhysicsJointFixed* joint = new PhysicsJointFixed(); if (joint && joint->init(a, b, anchr)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); getBodyNode(a)->setPosition(anchr); getBodyNode(b)->setPosition(anchr); // add a pivot joint to fixed two body together cpConstraint* joint = cpPivotJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::point2cpv(anchr)); CC_BREAK_IF(joint == nullptr); _info->add(joint); // add a gear joint to make two body have the same rotation. joint = cpGearJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), 0, 1); CC_BREAK_IF(joint == nullptr); _info->add(joint); setCollisionEnable(false); return true; } while (false); return false; } PhysicsJointPin* PhysicsJointPin::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr) { PhysicsJointPin* joint = new PhysicsJointPin(); if (joint && joint->init(a, b, anchr)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Point& anchr) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpPivotJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::point2cpv(anchr)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max) { PhysicsJointLimit* joint = new PhysicsJointLimit(); if (joint && joint->init(a, b, anchr1, anchr2, min, max)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) { return construct(a, b, anchr1, anchr2, 0, b->local2World(anchr1).getDistance(a->local2World(anchr2))); } bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpSlideJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2), PhysicsHelper::float2cpfloat(min), PhysicsHelper::float2cpfloat(max)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } float PhysicsJointLimit::getMin() const { return PhysicsHelper::cpfloat2float(cpSlideJointGetMin(_info->getJoints().front())); } void PhysicsJointLimit::setMin(float min) { cpSlideJointSetMin(_info->getJoints().front(), PhysicsHelper::float2cpfloat(min)); } float PhysicsJointLimit::getMax() const { return PhysicsHelper::cpfloat2float(cpSlideJointGetMax(_info->getJoints().front())); } void PhysicsJointLimit::setMax(float max) { cpSlideJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max)); } Point PhysicsJointLimit::getAnchr1() const { return PhysicsHelper::cpv2point(cpSlideJointGetAnchr1(_info->getJoints().front())); } void PhysicsJointLimit::setAnchr1(const Point& anchr) { cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); } Point PhysicsJointLimit::getAnchr2() const { return PhysicsHelper::cpv2point(cpSlideJointGetAnchr2(_info->getJoints().front())); } void PhysicsJointLimit::setAnchr2(const Point& anchr) { cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); } PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) { PhysicsJointDistance* joint = new PhysicsJointDistance(); if (joint && joint->init(a, b, anchr1, anchr2)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpPinJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } float PhysicsJointDistance::getDistance() const { return PhysicsHelper::cpfloat2float(cpPinJointGetDist(_info->getJoints().front())); } void PhysicsJointDistance::setDistance(float distance) { cpPinJointSetDist(_info->getJoints().front(), PhysicsHelper::float2cpfloat(distance)); } PhysicsJointSpring* PhysicsJointSpring::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping) { PhysicsJointSpring* joint = new PhysicsJointSpring(); if (joint && joint->init(a, b, anchr1, anchr2, stiffness, damping)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpDampedSpringNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2), PhysicsHelper::float2cpfloat(_bodyB->local2World(anchr1).getDistance(_bodyA->local2World(anchr2))), PhysicsHelper::float2cpfloat(stiffness), PhysicsHelper::float2cpfloat(damping)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } Point PhysicsJointSpring::getAnchr1() const { return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr1(_info->getJoints().front())); } void PhysicsJointSpring::setAnchr1(const Point& anchr) { cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); } Point PhysicsJointSpring::getAnchr2() const { return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr2(_info->getJoints().front())); } void PhysicsJointSpring::setAnchr2(const Point& anchr) { cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr)); } float PhysicsJointSpring::getRestLength() const { return PhysicsHelper::cpfloat2float(cpDampedSpringGetRestLength(_info->getJoints().front())); } void PhysicsJointSpring::setRestLength(float restLength) { cpDampedSpringSetRestLength(_info->getJoints().front(), PhysicsHelper::float2cpfloat(restLength)); } float PhysicsJointSpring::getStiffness() const { return PhysicsHelper::cpfloat2float(cpDampedSpringGetStiffness(_info->getJoints().front())); } void PhysicsJointSpring::setStiffness(float stiffness) { cpDampedSpringSetStiffness(_info->getJoints().front(), PhysicsHelper::float2cpfloat(stiffness)); } float PhysicsJointSpring::getDamping() const { return PhysicsHelper::cpfloat2float(cpDampedSpringGetDamping(_info->getJoints().front())); } void PhysicsJointSpring::setDamping(float damping) { cpDampedSpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); } PhysicsJointGroove* PhysicsJointGroove::construct(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2) { PhysicsJointGroove* joint = new PhysicsJointGroove(); if (joint && joint->init(a, b, grooveA, grooveB, anchr2)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpGrooveJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::point2cpv(grooveA), PhysicsHelper::point2cpv(grooveB), PhysicsHelper::point2cpv(anchr2)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } Point PhysicsJointGroove::getGrooveA() const { return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveA(_info->getJoints().front())); } void PhysicsJointGroove::setGrooveA(const Point& grooveA) { cpGrooveJointSetGrooveA(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveA)); } Point PhysicsJointGroove::getGrooveB() const { return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveB(_info->getJoints().front())); } void PhysicsJointGroove::setGrooveB(const Point& grooveB) { cpGrooveJointSetGrooveB(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveB)); } Point PhysicsJointGroove::getAnchr2() const { return PhysicsHelper::cpv2point(cpGrooveJointGetAnchr2(_info->getJoints().front())); } void PhysicsJointGroove::setAnchr2(const Point& anchr2) { cpGrooveJointSetAnchr2(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr2)); } PhysicsJointRotarySpring* PhysicsJointRotarySpring::construct(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping) { PhysicsJointRotarySpring* joint = new PhysicsJointRotarySpring(); if (joint && joint->init(a, b, stiffness, damping)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointRotarySpring::init(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpDampedRotarySpringNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::float2cpfloat(_bodyB->getRotation() - _bodyA->getRotation()), PhysicsHelper::float2cpfloat(stiffness), PhysicsHelper::float2cpfloat(damping)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } float PhysicsJointRotarySpring::getRestAngle() const { return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetRestAngle(_info->getJoints().front())); } void PhysicsJointRotarySpring::setRestAngle(float restAngle) { cpDampedRotarySpringSetRestAngle(_info->getJoints().front(), PhysicsHelper::float2cpfloat(restAngle)); } float PhysicsJointRotarySpring::getStiffness() const { return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetStiffness(_info->getJoints().front())); } void PhysicsJointRotarySpring::setStiffness(float stiffness) { cpDampedRotarySpringSetStiffness(_info->getJoints().front(), PhysicsHelper::float2cpfloat(stiffness)); } float PhysicsJointRotarySpring::getDamping() const { return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetDamping(_info->getJoints().front())); } void PhysicsJointRotarySpring::setDamping(float damping) { cpDampedRotarySpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping)); } PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b, float min, float max) { PhysicsJointRotaryLimit* joint = new PhysicsJointRotaryLimit(); if (joint && joint->init(a, b, min, max)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b) { return construct(a, b, 0.0f, 0.0f); } bool PhysicsJointRotaryLimit::init(PhysicsBody* a, PhysicsBody* b, float min, float max) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpRotaryLimitJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::float2cpfloat(min), PhysicsHelper::float2cpfloat(max)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } float PhysicsJointRotaryLimit::getMin() const { return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMin(_info->getJoints().front())); } void PhysicsJointRotaryLimit::setMin(float min) { cpRotaryLimitJointSetMin(_info->getJoints().front(), PhysicsHelper::float2cpfloat(min)); } float PhysicsJointRotaryLimit::getMax() const { return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMax(_info->getJoints().front())); } void PhysicsJointRotaryLimit::setMax(float max) { cpRotaryLimitJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max)); } PhysicsJointRatchet* PhysicsJointRatchet::construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet) { PhysicsJointRatchet* joint = new PhysicsJointRatchet(); if (joint && joint->init(a, b, phase, ratchet)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointRatchet::init(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpRatchetJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::float2cpfloat(phase), PhysicsHelper::cpfloat2float(ratchet)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } float PhysicsJointRatchet::getAngle() const { return PhysicsHelper::cpfloat2float(cpRatchetJointGetAngle(_info->getJoints().front())); } void PhysicsJointRatchet::setAngle(float angle) { cpRatchetJointSetAngle(_info->getJoints().front(), PhysicsHelper::float2cpfloat(angle)); } float PhysicsJointRatchet::getPhase() const { return PhysicsHelper::cpfloat2float(cpRatchetJointGetPhase(_info->getJoints().front())); } void PhysicsJointRatchet::setPhase(float phase) { cpRatchetJointSetPhase(_info->getJoints().front(), PhysicsHelper::float2cpfloat(phase)); } float PhysicsJointRatchet::getRatchet() const { return PhysicsHelper::cpfloat2float(cpRatchetJointGetRatchet(_info->getJoints().front())); } void PhysicsJointRatchet::setRatchet(float ratchet) { cpRatchetJointSetRatchet(_info->getJoints().front(), PhysicsHelper::float2cpfloat(ratchet)); } PhysicsJointGear* PhysicsJointGear::construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet) { PhysicsJointGear* joint = new PhysicsJointGear(); if (joint && joint->init(a, b, phase, ratchet)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointGear::init(PhysicsBody* a, PhysicsBody* b, float phase, float ratio) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpGearJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::float2cpfloat(phase), PhysicsHelper::float2cpfloat(ratio)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } float PhysicsJointGear::getPhase() const { return PhysicsHelper::cpfloat2float(cpGearJointGetPhase(_info->getJoints().front())); } void PhysicsJointGear::setPhase(float phase) { cpGearJointSetPhase(_info->getJoints().front(), PhysicsHelper::float2cpfloat(phase)); } float PhysicsJointGear::getRatio() const { return PhysicsHelper::cpfloat2float(cpGearJointGetRatio(_info->getJoints().front())); } void PhysicsJointGear::setRatio(float ratio) { cpGearJointSetRatio(_info->getJoints().front(), PhysicsHelper::float2cpfloat(ratio)); } PhysicsJointMotor* PhysicsJointMotor::construct(PhysicsBody* a, PhysicsBody* b, float rate) { PhysicsJointMotor* joint = new PhysicsJointMotor(); if (joint && joint->init(a, b, rate)) { return joint; } CC_SAFE_DELETE(joint); return nullptr; } bool PhysicsJointMotor::init(PhysicsBody* a, PhysicsBody* b, float rate) { do { CC_BREAK_IF(!PhysicsJoint::init(a, b)); cpConstraint* joint = cpSimpleMotorNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(), PhysicsHelper::float2cpfloat(rate)); CC_BREAK_IF(joint == nullptr); _info->add(joint); return true; } while (false); return false; } float PhysicsJointMotor::getRate() const { return PhysicsHelper::cpfloat2float(cpSimpleMotorGetRate(_info->getJoints().front())); } void PhysicsJointMotor::setRate(float rate) { cpSimpleMotorSetRate(_info->getJoints().front(), PhysicsHelper::float2cpfloat(rate)); } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/CCPhysicsJoint.h ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPHYSICS_JOINT_H__ #define __CCPHYSICS_JOINT_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "CCObject.h" #include "CCGeometry.h" NS_CC_BEGIN class PhysicsBody; class PhysicsWorld; class PhysicsJointInfo; class PhysicsBodyInfo; /* * @brief An PhysicsJoint object connects two physics bodies together. */ class PhysicsJoint { protected: PhysicsJoint(); virtual ~PhysicsJoint() = 0; public: inline PhysicsBody* getBodyA() const { return _bodyA; } inline PhysicsBody* getBodyB() const { return _bodyB; } inline PhysicsWorld* getWorld() const { return _world; } inline int getTag() const { return _tag; } inline void setTag(int tag) { _tag = tag; } inline bool isEnabled() const { return _enable; } /** Enable/Disable the joint */ void setEnable(bool enable); inline bool isCollisionEnabled() const { return _collisionEnable; } /** Enable/disable the collision between two bodies */ void setCollisionEnable(bool enable); /** Remove the joint from the world */ void removeFormWorld(); /** Distory the joint*/ static void destroy(PhysicsJoint* joint); /** Set the max force between two bodies */ void setMaxForce(float force); /** Get the max force setting */ float getMaxForce() const; protected: bool init(PhysicsBody* a, PhysicsBody* b); /** * PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. */ PhysicsBodyInfo* getBodyInfo(PhysicsBody* body) const; Node* getBodyNode(PhysicsBody* body) const; protected: PhysicsBody* _bodyA; PhysicsBody* _bodyB; PhysicsWorld* _world; PhysicsJointInfo* _info; bool _enable; bool _collisionEnable; bool _destoryMark; int _tag; friend class PhysicsBody; friend class PhysicsWorld; friend class PhysicsDebugDraw; }; /* * @brief A fixed joint fuses the two bodies together at a reference point. Fixed joints are useful for creating complex shapes that can be broken apart later. */ class PhysicsJointFixed : public PhysicsJoint { public: static PhysicsJointFixed* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr); protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr); protected: PhysicsJointFixed() {} virtual ~PhysicsJointFixed() {} }; /* * @brief A limit joint imposes a maximum distance between the two bodies, as if they were connected by a rope. */ class PhysicsJointLimit : public PhysicsJoint { public: static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max); Point getAnchr1() const; void setAnchr1(const Point& anchr1); Point getAnchr2() const; void setAnchr2(const Point& anchr2); float getMin() const; void setMin(float min); float getMax() const; void setMax(float max); protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max); protected: PhysicsJointLimit() {} virtual ~PhysicsJointLimit() {} }; /* * @brief A pin joint allows the two bodies to independently rotate around the anchor point as if pinned together. */ class PhysicsJointPin : public PhysicsJoint { public: static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr); protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr); protected: PhysicsJointPin() {} virtual ~PhysicsJointPin() {} }; /** Set the fixed distance with two bodies */ class PhysicsJointDistance : public PhysicsJoint { public: static PhysicsJointDistance* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); float getDistance() const; void setDistance(float distance); protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); protected: PhysicsJointDistance() {} virtual ~PhysicsJointDistance() {} }; /** Connecting two physics bodies together with a spring. */ class PhysicsJointSpring : public PhysicsJoint { public: static PhysicsJointSpring* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping); Point getAnchr1() const; void setAnchr1(const Point& anchr1); Point getAnchr2() const; void setAnchr2(const Point& anchr2); float getRestLength() const; void setRestLength(float restLength); float getStiffness() const; void setStiffness(float stiffness); float getDamping() const; void setDamping(float damping); protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping); protected: PhysicsJointSpring() {} virtual ~PhysicsJointSpring() {} }; /** Attach body a to a line, and attach body b to a dot */ class PhysicsJointGroove : public PhysicsJoint { public: static PhysicsJointGroove* construct(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2); Point getGrooveA() const; void setGrooveA(const Point& grooveA); Point getGrooveB() const; void setGrooveB(const Point& grooveB); Point getAnchr2() const; void setAnchr2(const Point& anchr2); protected: bool init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr); protected: PhysicsJointGroove() {} virtual ~PhysicsJointGroove() {} }; /** Likes a spring joint, but works with rotary */ class PhysicsJointRotarySpring : public PhysicsJoint { public: static PhysicsJointRotarySpring* construct(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping); float getRestAngle() const; void setRestAngle(float restAngle); float getStiffness() const; void setStiffness(float stiffness); float getDamping() const; void setDamping(float damping); protected: bool init(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping); protected: PhysicsJointRotarySpring() {} virtual ~PhysicsJointRotarySpring() {} }; /** Likes a limit joint, but works with rotary */ class PhysicsJointRotaryLimit : public PhysicsJoint { public: static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b, float min, float max); static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b); float getMin() const; void setMin(float min); float getMax() const; void setMax(float max); protected: bool init(PhysicsBody* a, PhysicsBody* b, float min, float max); protected: PhysicsJointRotaryLimit() {} virtual ~PhysicsJointRotaryLimit() {} }; /** Works like a socket wrench. */ class PhysicsJointRatchet : public PhysicsJoint { public: static PhysicsJointRatchet* construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet); float getAngle() const; void setAngle(float angle); float getPhase() const; void setPhase(float phase); float getRatchet() const; void setRatchet(float ratchet); protected: bool init(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet); protected: PhysicsJointRatchet() {} virtual ~PhysicsJointRatchet() {} }; /** Keeps the angular velocity ratio of a pair of bodies constant. */ class PhysicsJointGear : public PhysicsJoint { public: static PhysicsJointGear* construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratio); float getPhase() const; void setPhase(float phase); float getRatio() const; void setRatio(float ratchet); protected: bool init(PhysicsBody* a, PhysicsBody* b, float phase, float ratio); protected: PhysicsJointGear() {} virtual ~PhysicsJointGear() {} }; /** Keeps the relative angular velocity of a pair of bodies constant */ class PhysicsJointMotor : public PhysicsJoint { public: static PhysicsJointMotor* construct(PhysicsBody* a, PhysicsBody* b, float rate); float getRate() const; void setRate(float rate); protected: bool init(PhysicsBody* a, PhysicsBody* b, float rate); protected: PhysicsJointMotor() {} virtual ~PhysicsJointMotor() {} }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_JOINT_H__ ================================================ FILE: cocos2d/cocos/physics/CCPhysicsShape.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCPhysicsShape.h" #if CC_USE_PHYSICS #include #include "chipmunk.h" #include "CCPhysicsBody.h" #include "CCPhysicsWorld.h" #include "chipmunk/CCPhysicsBodyInfo_chipmunk.h" #include "chipmunk/CCPhysicsShapeInfo_chipmunk.h" #include "chipmunk/CCPhysicsHelper_chipmunk.h" NS_CC_BEGIN extern const float PHYSICS_INFINITY; PhysicsShape::PhysicsShape() : _body(nullptr) , _info(nullptr) , _type(Type::UNKNOWN) , _area(0) , _mass(0) , _moment(0) , _tag(0) , _categoryBitmask(UINT_MAX) , _collisionBitmask(UINT_MAX) , _contactTestBitmask(UINT_MAX) , _group(0) { } PhysicsShape::~PhysicsShape() { CC_SAFE_DELETE(_info); } bool PhysicsShape::init(Type type) { _info = new PhysicsShapeInfo(this); if (_info == nullptr) return false; _type = type; return true; } void PhysicsShape::setMass(float mass) { if (mass < 0) { return; } if (_body) { _body->addMass(-_mass); _body->addMass(mass); }; _mass = mass; } void PhysicsShape::setMoment(float moment) { if (moment < 0) { return; } if (_body) { _body->addMoment(-_moment); _body->addMoment(moment); }; _moment = moment; } void PhysicsShape::setMaterial(const PhysicsMaterial& material) { setDensity(material.density); setRestitution(material.restitution); setFriction(material.friction); } PhysicsBodyInfo* PhysicsShape::bodyInfo() const { if (_body != nullptr) { return _body->_info; }else { return nullptr; } } PhysicsShapeCircle::PhysicsShapeCircle() { } PhysicsShapeCircle::~PhysicsShapeCircle() { } PhysicsShapeBox::PhysicsShapeBox() { } PhysicsShapeBox::~PhysicsShapeBox() { } PhysicsShapePolygon::PhysicsShapePolygon() { } PhysicsShapePolygon::~PhysicsShapePolygon() { } PhysicsShapeEdgeBox::PhysicsShapeEdgeBox() { } PhysicsShapeEdgeBox::~PhysicsShapeEdgeBox() { } PhysicsShapeEdgeChain::PhysicsShapeEdgeChain() { } PhysicsShapeEdgeChain::~PhysicsShapeEdgeChain() { } PhysicsShapeEdgePolygon::PhysicsShapeEdgePolygon() { } PhysicsShapeEdgePolygon::~PhysicsShapeEdgePolygon() { } PhysicsShapeEdgeSegment::PhysicsShapeEdgeSegment() { } PhysicsShapeEdgeSegment::~PhysicsShapeEdgeSegment() { } void PhysicsShape::setDensity(float density) { if (density < 0) { return; } _material.density = density; if (_material.density == PHYSICS_INFINITY) { setMass(PHYSICS_INFINITY); }else if (_area > 0) { setMass(PhysicsHelper::float2cpfloat(_material.density * _area)); } } void PhysicsShape::setRestitution(float restitution) { _material.restitution = restitution; for (cpShape* shape : _info->getShapes()) { cpShapeSetElasticity(shape, PhysicsHelper::float2cpfloat(restitution)); } } void PhysicsShape::setFriction(float friction) { _material.friction = friction; for (cpShape* shape : _info->getShapes()) { cpShapeSetFriction(shape, PhysicsHelper::float2cpfloat(friction)); } } void PhysicsShape::recenterPoints(Point* points, int count, const Point& center) { cpVect* cpvs = new cpVect[count]; cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); PhysicsHelper::cpvs2points(cpvs, points, count); delete[] cpvs; if (center != Point::ZERO) { for (int i = 0; i < count; ++i) { points[i] += center; } } } Point PhysicsShape::getPolyonCenter(const Point* points, int count) { cpVect* cpvs = new cpVect[count]; cpVect center = cpCentroidForPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); delete[] cpvs; return PhysicsHelper::cpv2point(center); } void PhysicsShape::setBody(PhysicsBody *body) { // already added if (body != nullptr && _body == body) { return; } if (_body != nullptr) { _body->removeShape(this); } if (body == nullptr) { _info->setBody(nullptr); _body = nullptr; }else { _info->setBody(body->_info->getBody()); _body = body; } } // PhysicsShapeCircle PhysicsShapeCircle* PhysicsShapeCircle::create(float radius, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset/* = Point(0, 0)*/) { PhysicsShapeCircle* shape = new PhysicsShapeCircle(); if (shape && shape->init(radius, material, offset)) { shape->autorelease(); return shape; } CC_SAFE_DELETE(shape); return nullptr; } bool PhysicsShapeCircle::init(float radius, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset /*= Point(0, 0)*/) { do { CC_BREAK_IF(!PhysicsShape::init(Type::CIRCLE)); cpShape* shape = cpCircleShapeNew(_info->getSharedBody(), radius, PhysicsHelper::point2cpv(offset)); CC_BREAK_IF(shape == nullptr); _info->add(shape); _area = calculateArea(); _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; _moment = calculateDefaultMoment(); setMaterial(material); return true; } while (false); return false; } float PhysicsShapeCircle::calculateArea(float radius) { return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, radius)); } float PhysicsShapeCircle::calculateMoment(float mass, float radius, const Point& offset) { return mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForCircle(PhysicsHelper::float2cpfloat(mass), 0, PhysicsHelper::float2cpfloat(radius), PhysicsHelper::point2cpv(offset))); } float PhysicsShapeCircle::calculateArea() { return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, cpCircleShapeGetRadius(_info->getShapes().front()))); } float PhysicsShapeCircle::calculateDefaultMoment() { cpShape* shape = _info->getShapes().front(); return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForCircle(PhysicsHelper::float2cpfloat(_mass), 0, cpCircleShapeGetRadius(shape), cpCircleShapeGetOffset(shape))); } float PhysicsShapeCircle::getRadius() const { return PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(_info->getShapes().front())); } Point PhysicsShapeCircle::getOffset() { return PhysicsHelper::cpv2point(cpCircleShapeGetOffset(_info->getShapes().front())); } // PhysicsShapeEdgeSegment PhysicsShapeEdgeSegment* PhysicsShapeEdgeSegment::create(const Point& a, const Point& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { PhysicsShapeEdgeSegment* shape = new PhysicsShapeEdgeSegment(); if (shape && shape->init(a, b, material, border)) { shape->autorelease(); return shape; } CC_SAFE_DELETE(shape); return nullptr; } bool PhysicsShapeEdgeSegment::init(const Point& a, const Point& b, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { do { CC_BREAK_IF(!PhysicsShape::init(Type::EDGESEGMENT)); cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), PhysicsHelper::point2cpv(a), PhysicsHelper::point2cpv(b), PhysicsHelper::float2cpfloat(border)); CC_BREAK_IF(shape == nullptr); _info->add(shape); _mass = PHYSICS_INFINITY; _moment = PHYSICS_INFINITY; _center = a.getMidpoint(b); setMaterial(material); return true; } while (false); return false; } Point PhysicsShapeEdgeSegment::getPointA() const { return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->ta); } Point PhysicsShapeEdgeSegment::getPointB() const { return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->tb); } Point PhysicsShapeEdgeSegment::getCenter() { return _center; } // PhysicsShapeBox PhysicsShapeBox* PhysicsShapeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset/* = Point(0, 0)*/) { PhysicsShapeBox* shape = new PhysicsShapeBox(); if (shape && shape->init(size, material, offset)) { shape->autorelease(); return shape; } CC_SAFE_DELETE(shape); return nullptr; } bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset /*= Point(0, 0)*/) { do { CC_BREAK_IF(!PhysicsShape::init(Type::BOX)); cpVect wh = PhysicsHelper::size2cpv(size); cpVect vec[4] = { {-wh.x/2.0f, -wh.y/2.0f}, {-wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, -wh.y/2.0f} }; cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), 4, vec, PhysicsHelper::point2cpv(offset)); CC_BREAK_IF(shape == nullptr); _info->add(shape); _offset = offset; _area = calculateArea(); _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; _moment = calculateDefaultMoment(); setMaterial(material); return true; } while (false); return false; } float PhysicsShapeBox::calculateArea(const Size& size) { cpVect wh = PhysicsHelper::size2cpv(size); cpVect vec[4] = { {-wh.x/2.0f, -wh.y/2.0f}, {-wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, -wh.y/2.0f} }; return PhysicsHelper::cpfloat2float(cpAreaForPoly(4, vec)); } float PhysicsShapeBox::calculateMoment(float mass, const Size& size, const Point& offset) { cpVect wh = PhysicsHelper::size2cpv(size); cpVect vec[4] = { {-wh.x/2.0f, -wh.y/2.0f}, {-wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, -wh.y/2.0f} }; return mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForPoly(PhysicsHelper::float2cpfloat(mass), 4, vec, PhysicsHelper::point2cpv(offset))); } float PhysicsShapeBox::calculateArea() { cpShape* shape = _info->getShapes().front(); return PhysicsHelper::cpfloat2float(cpAreaForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); } float PhysicsShapeBox::calculateDefaultMoment() { cpShape* shape = _info->getShapes().front(); return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, cpvzero)); } void PhysicsShapeBox::getPoints(Point* points) const { cpShape* shape = _info->getShapes().front(); PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, points, ((cpPolyShape*)shape)->numVerts); } Size PhysicsShapeBox::getSize() const { cpShape* shape = _info->getShapes().front(); return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 0), cpPolyShapeGetVert(shape, 1)), cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2)))); } // PhysicsShapePolygon PhysicsShapePolygon* PhysicsShapePolygon::create(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset/* = Point(0, 0)*/) { PhysicsShapePolygon* shape = new PhysicsShapePolygon(); if (shape && shape->init(points, count, material, offset)) { shape->autorelease(); return shape; } CC_SAFE_DELETE(shape); return nullptr; } bool PhysicsShapePolygon::init(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, const Point& offset/* = Point(0, 0)*/) { do { CC_BREAK_IF(!PhysicsShape::init(Type::POLYGEN)); cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), count, vecs, PhysicsHelper::point2cpv(offset)); CC_SAFE_DELETE_ARRAY(vecs); CC_BREAK_IF(shape == nullptr); _info->add(shape); _area = calculateArea(); _mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area; _moment = calculateDefaultMoment(); _center = PhysicsHelper::cpv2point(cpCentroidForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); setMaterial(material); return true; } while (false); return false; } float PhysicsShapePolygon::calculateArea(const Point* points, int count) { cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs)); CC_SAFE_DELETE_ARRAY(vecs); return area; } float PhysicsShapePolygon::calculateMoment(float mass, const Point* points, int count, const Point& offset) { cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset))); CC_SAFE_DELETE_ARRAY(vecs); return moment; } float PhysicsShapePolygon::calculateArea() { cpShape* shape = _info->getShapes().front(); return PhysicsHelper::cpfloat2float(cpAreaForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts)); } float PhysicsShapePolygon::calculateDefaultMoment() { cpShape* shape = _info->getShapes().front(); return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, cpvzero)); } Point PhysicsShapePolygon::getPoint(int i) const { return PhysicsHelper::cpv2point(cpPolyShapeGetVert(_info->getShapes().front(), i)); } void PhysicsShapePolygon::getPoints(Point* outPoints) const { cpShape* shape = _info->getShapes().front(); PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, outPoints, ((cpPolyShape*)shape)->numVerts); } int PhysicsShapePolygon::getPointsCount() const { return ((cpPolyShape*)_info->getShapes().front())->numVerts; } Point PhysicsShapePolygon::getCenter() { return _center; } // PhysicsShapeEdgeBox PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Point& offset/* = Point(0, 0)*/) { PhysicsShapeEdgeBox* shape = new PhysicsShapeEdgeBox(); if (shape && shape->init(size, material, border, offset)) { shape->autorelease(); return shape; } CC_SAFE_DELETE(shape); return nullptr; } bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/, const Point& offset/*= Point(0, 0)*/) { do { CC_BREAK_IF(!PhysicsShape::init(Type::EDGEBOX)); cpVect vec[4] = {}; vec[0] = PhysicsHelper::point2cpv(Point(-size.width/2+offset.x, -size.height/2+offset.y)); vec[1] = PhysicsHelper::point2cpv(Point(+size.width/2+offset.x, -size.height/2+offset.y)); vec[2] = PhysicsHelper::point2cpv(Point(+size.width/2+offset.x, +size.height/2+offset.y)); vec[3] = PhysicsHelper::point2cpv(Point(-size.width/2+offset.x, +size.height/2+offset.y)); int i = 0; for (; i < 4; ++i) { cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[(i+1)%4], PhysicsHelper::float2cpfloat(border)); CC_BREAK_IF(shape == nullptr); _info->add(shape); } CC_BREAK_IF(i < 4); _offset = offset; _mass = PHYSICS_INFINITY; _moment = PHYSICS_INFINITY; setMaterial(material); return true; } while (false); return false; } void PhysicsShapeEdgeBox::getPoints(cocos2d::Point *outPoints) const { int i = 0; for(auto shape : _info->getShapes()) { outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a); } } // PhysicsShapeEdgeBox PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { PhysicsShapeEdgePolygon* shape = new PhysicsShapeEdgePolygon(); if (shape && shape->init(points, count, material, border)) { shape->autorelease(); return shape; } CC_SAFE_DELETE(shape); return nullptr; } bool PhysicsShapeEdgePolygon::init(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { cpVect* vec = nullptr; do { CC_BREAK_IF(!PhysicsShape::init(Type::EDGEPOLYGEN)); vec = new cpVect[count]; PhysicsHelper::points2cpvs(points, vec, count); _center = PhysicsHelper::cpv2point(cpCentroidForPoly(count, vec)); int i = 0; for (; i < count; ++i) { cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[(i+1)%count], PhysicsHelper::float2cpfloat(border)); CC_BREAK_IF(shape == nullptr); cpShapeSetElasticity(shape, 1.0f); cpShapeSetFriction(shape, 1.0f); _info->add(shape); } CC_SAFE_DELETE_ARRAY(vec); CC_BREAK_IF(i < count); _mass = PHYSICS_INFINITY; _moment = PHYSICS_INFINITY; setMaterial(material); return true; } while (false); CC_SAFE_DELETE_ARRAY(vec); return false; } Point PhysicsShapeEdgePolygon::getCenter() { return _center; } void PhysicsShapeEdgePolygon::getPoints(cocos2d::Point *outPoints) const { int i = 0; for(auto shape : _info->getShapes()) { outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a); } } int PhysicsShapeEdgePolygon::getPointsCount() const { return static_cast(_info->getShapes().size() + 1); } // PhysicsShapeEdgeChain PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { PhysicsShapeEdgeChain* shape = new PhysicsShapeEdgeChain(); if (shape && shape->init(points, count, material, border)) { shape->autorelease(); return shape; } CC_SAFE_DELETE(shape); return nullptr; } bool PhysicsShapeEdgeChain::init(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { cpVect* vec = nullptr; do { CC_BREAK_IF(!PhysicsShape::init(Type::EDGECHAIN)); vec = new cpVect[count]; PhysicsHelper::points2cpvs(points, vec, count); _center = PhysicsHelper::cpv2point(cpCentroidForPoly(count, vec)); int i = 0; for (; i < count - 1; ++i) { cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[i+1], PhysicsHelper::float2cpfloat(border)); CC_BREAK_IF(shape == nullptr); cpShapeSetElasticity(shape, 1.0f); cpShapeSetFriction(shape, 1.0f); _info->add(shape); } CC_SAFE_DELETE_ARRAY(vec); CC_BREAK_IF(i < count); _mass = PHYSICS_INFINITY; _moment = PHYSICS_INFINITY; setMaterial(material); return true; } while (false); CC_SAFE_DELETE_ARRAY(vec); return false; } Point PhysicsShapeEdgeChain::getCenter() { return _center; } void PhysicsShapeEdgeChain::getPoints(Point* outPoints) const { int i = 0; for(auto shape : _info->getShapes()) { outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a); } outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)_info->getShapes().back())->a); } int PhysicsShapeEdgeChain::getPointsCount() const { return static_cast(_info->getShapes().size() + 1); } void PhysicsShape::setGroup(int group) { if (group < 0) { for (auto shape : _info->getShapes()) { cpShapeSetGroup(shape, (cpGroup)group); } } _group = group; } bool PhysicsShape::containsPoint(const Point& point) const { for (auto shape : _info->getShapes()) { if (cpShapePointQuery(shape, PhysicsHelper::point2cpv(point))) { return true; } } return false; } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/CCPhysicsShape.h ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPHYSICS_SHAPE_H__ #define __CCPHYSICS_SHAPE_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "CCObject.h" #include "CCGeometry.h" NS_CC_BEGIN class PhysicsShapeInfo; class PhysicsBody; class PhysicsBodyInfo; typedef struct PhysicsMaterial { float density; ///< The density of the object. float restitution; ///< The bounciness of the physics body. float friction; ///< The roughness of the surface of a shape. PhysicsMaterial() : density(0.0f) , restitution(0.0f) , friction(0.0f) {} PhysicsMaterial(float aDensity, float aRestitution, float aFriction) : density(aDensity) , restitution(aRestitution) , friction(aFriction) {} }PhysicsMaterial; const PhysicsMaterial PHYSICSSHAPE_MATERIAL_DEFAULT(0.0f, 0.5f, 0.5f); /** * @brief A shape for body. You do not create PhysicsWorld objects directly, instead, you can view PhysicsBody to see how to create it. */ class PhysicsShape : public Object { public: enum class Type { UNKNOWN, CIRCLE, BOX, POLYGEN, EDGESEGMENT, EDGEBOX, EDGEPOLYGEN, EDGECHAIN, }; public: /** Get the body that this shape attaches */ inline PhysicsBody* getBody() const { return _body; } /** Return the type of this shape */ inline Type getType() const { return _type; } /** return the area of this shape */ inline float getArea() const { return _area; } /** get moment */ inline float getMoment() const { return _moment; } /** Set moment, it will change the body's moment this shape attaches */ void setMoment(float moment); inline void setTag(int tag) { _tag = tag; } inline int getTag() const { return _tag; } /** get mass */ inline float getMass() const { return _mass; } /** Set mass, it will change the body's mass this shape attaches */ void setMass(float mass); inline float getDensity() const { return _material.density; } void setDensity(float density); inline float getRestitution() const { return _material.restitution; } void setRestitution(float restitution); inline float getFriction() const { return _material.friction; } void setFriction(float friction); const PhysicsMaterial& getMaterial() const { return _material; } void setMaterial(const PhysicsMaterial& material); /** Calculate the default moment value */ virtual float calculateDefaultMoment() { return 0.0f; } /** Get offset */ virtual Point getOffset() { return Point::ZERO; } /** Get center of this shape */ virtual Point getCenter() { return getOffset(); } /** Test point is in shape or not */ bool containsPoint(const Point& point) const; /** move the points to the center */ static void recenterPoints(Point* points, int count, const Point& center = Point::ZERO); /** get center of the polyon points */ static Point getPolyonCenter(const Point* points, int count); /** * A mask that defines which categories this physics body belongs to. * Every physics body in a scene can be assigned to up to 32 different categories, each corresponding to a bit in the bit mask. You define the mask values used in your game. In conjunction with the collisionBitMask and contactTestBitMask properties, you define which physics bodies interact with each other and when your game is notified of these interactions. * The default value is 0xFFFFFFFF (all bits set). */ inline void setCategoryBitmask(int bitmask) { _categoryBitmask = bitmask; } inline int getCategoryBitmask() const { return _categoryBitmask; } /** * A mask that defines which categories of bodies cause intersection notifications with this physics body. * When two bodies share the same space, each body’s category mask is tested against the other body’s contact mask by performing a logical AND operation. If either comparison results in a non-zero value, an PhysicsContact object is created and passed to the physics world’s delegate. For best performance, only set bits in the contacts mask for interactions you are interested in. * The default value is 0x00000000 (all bits cleared). */ inline void setContactTestBitmask(int bitmask) { _contactTestBitmask = bitmask; } inline int getContactTestBitmask() const { return _contactTestBitmask; } /** * A mask that defines which categories of physics bodies can collide with this physics body. * When two physics bodies contact each other, a collision may occur. This body’s collision mask is compared to the other body’s category mask by performing a logical AND operation. If the result is a non-zero value, then this body is affected by the collision. Each body independently chooses whether it wants to be affected by the other body. For example, you might use this to avoid collision calculations that would make negligible changes to a body’s velocity. * The default value is 0xFFFFFFFF (all bits set). */ inline void setCollisionBitmask(int bitmask) { _collisionBitmask = bitmask; } inline int getCollisionBitmask() const { return _collisionBitmask; } void setGroup(int group); inline int getGroup() { return _group; } protected: bool init(Type type); /** * @brief PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. */ PhysicsBodyInfo* bodyInfo() const; void setBody(PhysicsBody* body); /** calculate the area of this shape */ virtual float calculateArea() { return 0.0f; } protected: PhysicsShape(); virtual ~PhysicsShape() = 0; protected: PhysicsBody* _body; PhysicsShapeInfo* _info; Type _type; float _area; float _mass; float _moment; PhysicsMaterial _material; int _tag; int _categoryBitmask; int _collisionBitmask; int _contactTestBitmask; int _group; friend class PhysicsWorld; friend class PhysicsBody; friend class PhysicsJoint; friend class PhysicsDebugDraw; }; /** A circle shape */ class PhysicsShapeCircle : public PhysicsShape { public: static PhysicsShapeCircle* create(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Point& offset = Point(0, 0)); static float calculateArea(float radius); static float calculateMoment(float mass, float radius, const Point& offset = Point::ZERO); virtual float calculateDefaultMoment() override; float getRadius() const; virtual Point getOffset() override; protected: bool init(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Point& offset = Point::ZERO); virtual float calculateArea() override; protected: PhysicsShapeCircle(); virtual ~PhysicsShapeCircle(); }; /** A box shape */ class PhysicsShapeBox : public PhysicsShape { public: static PhysicsShapeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Point& offset = Point::ZERO); static float calculateArea(const Size& size); static float calculateMoment(float mass, const Size& size, const Point& offset = Point::ZERO); virtual float calculateDefaultMoment() override; void getPoints(Point* outPoints) const; int getPointsCount() const { return 4; } Size getSize() const; virtual Point getOffset() override { return _offset; } protected: bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Point& offset = Point::ZERO); virtual float calculateArea() override; protected: PhysicsShapeBox(); virtual ~PhysicsShapeBox(); protected: Point _offset; }; /** A polygon shape */ class PhysicsShapePolygon : public PhysicsShape { public: static PhysicsShapePolygon* create(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Point& offset = Point::ZERO); static float calculateArea(const Point* points, int count); static float calculateMoment(float mass, const Point* points, int count, const Point& offset = Point::ZERO); float calculateDefaultMoment() override; Point getPoint(int i) const; void getPoints(Point* outPoints) const; int getPointsCount() const; virtual Point getCenter() override; protected: bool init(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Point& offset = Point::ZERO); float calculateArea() override; protected: PhysicsShapePolygon(); virtual ~PhysicsShapePolygon(); protected: Point _center; }; /** A segment shape */ class PhysicsShapeEdgeSegment : public PhysicsShape { public: static PhysicsShapeEdgeSegment* create(const Point& a, const Point& b, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); Point getPointA() const; Point getPointB() const; virtual Point getCenter() override; protected: bool init(const Point& a, const Point& b, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); protected: PhysicsShapeEdgeSegment(); virtual ~PhysicsShapeEdgeSegment(); protected: Point _center; friend class PhysicsBody; }; /** An edge box shape */ class PhysicsShapeEdgeBox : public PhysicsShape { public: static PhysicsShapeEdgeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, const Point& offset = Point::ZERO); virtual Point getOffset() override { return _offset; } void getPoints(Point* outPoints) const; int getPointsCount() const { return 4; } protected: bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, const Point& offset = Point::ZERO); protected: PhysicsShapeEdgeBox(); virtual ~PhysicsShapeEdgeBox(); protected: Point _offset; friend class PhysicsBody; }; /** An edge polygon shape */ class PhysicsShapeEdgePolygon : public PhysicsShape { public: static PhysicsShapeEdgePolygon* create(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); virtual Point getCenter() override; void getPoints(Point* outPoints) const; int getPointsCount() const; protected: bool init(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); protected: PhysicsShapeEdgePolygon(); virtual ~PhysicsShapeEdgePolygon(); friend class PhysicsBody; protected: Point _center; }; /** a chain shape */ class PhysicsShapeEdgeChain : public PhysicsShape { public: static PhysicsShapeEdgeChain* create(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); virtual Point getCenter() override; void getPoints(Point* outPoints) const; int getPointsCount() const; protected: bool init(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1); protected: PhysicsShapeEdgeChain(); virtual ~PhysicsShapeEdgeChain(); protected: Point _center; friend class PhysicsBody; }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_FIXTURE_H__ ================================================ FILE: cocos2d/cocos/physics/CCPhysicsWorld.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCPhysicsWorld.h" #if CC_USE_PHYSICS #include #include "chipmunk.h" #include "CCPhysicsBody.h" #include "CCPhysicsShape.h" #include "CCPhysicsContact.h" #include "CCPhysicsJoint.h" #include "CCPhysicsContact.h" #include "chipmunk/CCPhysicsWorldInfo_chipmunk.h" #include "chipmunk/CCPhysicsBodyInfo_chipmunk.h" #include "chipmunk/CCPhysicsShapeInfo_chipmunk.h" #include "chipmunk/CCPhysicsContactInfo_chipmunk.h" #include "chipmunk/CCPhysicsJointInfo_chipmunk.h" #include "chipmunk/CCPhysicsHelper_chipmunk.h" #include "CCDrawNode.h" #include "CCArray.h" #include "CCScene.h" #include "CCDirector.h" #include "CCEventDispatcher.h" #include "CCEventCustom.h" #include NS_CC_BEGIN const float PHYSICS_INFINITY = INFINITY; extern const char* PHYSICSCONTACT_EVENT_NAME; const int PhysicsWorld::DEBUGDRAW_NONE = 0x00; const int PhysicsWorld::DEBUGDRAW_SHAPE = 0x01; const int PhysicsWorld::DEBUGDRAW_JOINT = 0x02; const int PhysicsWorld::DEBUGDRAW_CONTACT = 0x04; const int PhysicsWorld::DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT; namespace { typedef struct RayCastCallbackInfo { PhysicsWorld* world; PhysicsRayCastCallbackFunc func; Point p1; Point p2; void* data; }RayCastCallbackInfo; typedef struct RectQueryCallbackInfo { PhysicsWorld* world; PhysicsQueryRectCallbackFunc func; void* data; }RectQueryCallbackInfo; typedef struct PointQueryCallbackInfo { PhysicsWorld* world; PhysicsQueryPointCallbackFunc func; void* data; }PointQueryCallbackInfo; } class PhysicsWorldCallback { public: static int collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, PhysicsWorld *world); static int collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world); static void collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world); static void collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world); static void rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect n, RayCastCallbackInfo *info); static void queryRectCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info); static void queryPointFunc(cpShape *shape, cpFloat distance, cpVect point, PointQueryCallbackInfo *info); static void getShapesAtPointFunc(cpShape *shape, cpFloat distance, cpVect point, Vector* arr); public: static bool continues; }; bool PhysicsWorldCallback::continues = true; int PhysicsWorldCallback::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, PhysicsWorld *world) { CP_ARBITER_GET_SHAPES(arb, a, b); auto ita = PhysicsShapeInfo::getMap().find(a); auto itb = PhysicsShapeInfo::getMap().find(b); CC_ASSERT(ita != PhysicsShapeInfo::getMap().end() && itb != PhysicsShapeInfo::getMap().end()); PhysicsContact* contact = PhysicsContact::construct(ita->second->getShape(), itb->second->getShape()); arb->data = contact; contact->_contactInfo = arb; return world->collisionBeginCallback(*contact); } int PhysicsWorldCallback::collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world) { return world->collisionPreSolveCallback(*static_cast(arb->data)); } void PhysicsWorldCallback::collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world) { world->collisionPostSolveCallback(*static_cast(arb->data)); } void PhysicsWorldCallback::collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, PhysicsWorld *world) { PhysicsContact* contact = static_cast(arb->data); world->collisionSeparateCallback(*contact); delete contact; } void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect n, RayCastCallbackInfo *info) { if (!PhysicsWorldCallback::continues) { return; } auto it = PhysicsShapeInfo::getMap().find(shape); CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); PhysicsRayCastInfo callbackInfo = { it->second->getShape(), info->p1, info->p2, Point(info->p1.x+(info->p2.x-info->p1.x)*t, info->p1.y+(info->p2.y-info->p1.y)*t), Point(n.x, n.y), (float)t, }; PhysicsWorldCallback::continues = info->func(*info->world, callbackInfo, info->data); } void PhysicsWorldCallback::queryRectCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info) { auto it = PhysicsShapeInfo::getMap().find(shape); CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); if (!PhysicsWorldCallback::continues) { return; } PhysicsWorldCallback::continues = info->func(*info->world, *it->second->getShape(), info->data); } void PhysicsWorldCallback::getShapesAtPointFunc(cpShape *shape, cpFloat distance, cpVect point, Vector* arr) { auto it = PhysicsShapeInfo::getMap().find(shape); CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); arr->pushBack(it->second->getShape()); } void PhysicsWorldCallback::queryPointFunc(cpShape *shape, cpFloat distance, cpVect point, PointQueryCallbackInfo *info) { auto it = PhysicsShapeInfo::getMap().find(shape); CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); PhysicsWorldCallback::continues = info->func(*info->world, *it->second->getShape(), info->data); } void PhysicsWorld::debugDraw() { if (_debugDraw == nullptr) { _debugDraw = new PhysicsDebugDraw(*this); } if (_debugDraw && !_bodies.empty()) { if (_debugDraw->begin()) { if (_debugDrawMask & DEBUGDRAW_SHAPE) { for (Object* obj : _bodies) { PhysicsBody* body = dynamic_cast(obj); for (auto& shape : body->getShapes()) { _debugDraw->drawShape(*dynamic_cast(shape)); } } } if (_debugDrawMask & DEBUGDRAW_JOINT) { for (auto joint : _joints) { _debugDraw->drawJoint(*joint); } } _debugDraw->end(); } } } int PhysicsWorld::collisionBeginCallback(PhysicsContact& contact) { bool ret = true; PhysicsShape* shapeA = contact.getShapeA(); PhysicsShape* shapeB = contact.getShapeB(); PhysicsBody* bodyA = shapeA->getBody(); PhysicsBody* bodyB = shapeB->getBody(); std::vector jointsA = bodyA->getJoints(); // check the joint is collision enable or not for (PhysicsJoint* joint : jointsA) { if (std::find(_joints.begin(), _joints.end(), joint) == _joints.end()) { continue; } if (!joint->isCollisionEnabled()) { PhysicsBody* body = joint->getBodyA() == bodyA ? joint->getBodyB() : joint->getBodyA(); if (body == bodyB) { contact.setNotificationEnable(false); return false; } } } // bitmask check if ((shapeA->getCategoryBitmask() & shapeB->getContactTestBitmask()) == 0 || (shapeB->getContactTestBitmask() & shapeA->getCategoryBitmask()) == 0) { contact.setNotificationEnable(false); } if (shapeA->getGroup() != 0 && shapeA->getGroup() == shapeB->getGroup()) { ret = shapeA->getGroup() > 0; } else { if ((shapeA->getCategoryBitmask() & shapeB->getCollisionBitmask()) == 0 || (shapeB->getCategoryBitmask() & shapeA->getCollisionBitmask()) == 0) { ret = false; } } contact.setEventCode(PhysicsContact::EventCode::BEGIN); contact.setWorld(this); EventCustom event(PHYSICSCONTACT_EVENT_NAME); event.setUserData(&contact); _scene->getEventDispatcher()->dispatchEvent(&event); return ret ? contact.resetResult() : false; } int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact) { if (!contact.isNotificationEnabled()) { cpArbiterIgnore(static_cast(contact._contactInfo)); return true; } contact.setEventCode(PhysicsContact::EventCode::PRESOLVE); contact.setWorld(this); EventCustom event(PHYSICSCONTACT_EVENT_NAME); event.setUserData(&contact); _scene->getEventDispatcher()->dispatchEvent(&event); return contact.resetResult(); } void PhysicsWorld::collisionPostSolveCallback(PhysicsContact& contact) { if (!contact.isNotificationEnabled()) { return; } contact.setEventCode(PhysicsContact::EventCode::POSTSOLVE); contact.setWorld(this); EventCustom event(PHYSICSCONTACT_EVENT_NAME); event.setUserData(&contact); _scene->getEventDispatcher()->dispatchEvent(&event); } void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact) { if (!contact.isNotificationEnabled()) { return; } contact.setEventCode(PhysicsContact::EventCode::SEPERATE); contact.setWorld(this); EventCustom event(PHYSICSCONTACT_EVENT_NAME); event.setUserData(&contact); _scene->getEventDispatcher()->dispatchEvent(&event); } void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Point& point1, const Point& point2, void* data) { CCASSERT(func != nullptr, "func shouldn't be nullptr"); if (func != nullptr) { RayCastCallbackInfo info = { this, func, point1, point2, data }; PhysicsWorldCallback::continues = true; cpSpaceSegmentQuery(this->_info->getSpace(), PhysicsHelper::point2cpv(point1), PhysicsHelper::point2cpv(point2), CP_ALL_LAYERS, CP_NO_GROUP, (cpSpaceSegmentQueryFunc)PhysicsWorldCallback::rayCastCallbackFunc, &info); } } void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect, void* data) { CCASSERT(func != nullptr, "func shouldn't be nullptr"); if (func != nullptr) { RectQueryCallbackInfo info = {this, func, data}; PhysicsWorldCallback::continues = true; cpSpaceBBQuery(this->_info->getSpace(), PhysicsHelper::rect2cpbb(rect), CP_ALL_LAYERS, CP_NO_GROUP, (cpSpaceBBQueryFunc)PhysicsWorldCallback::queryRectCallbackFunc, &info); } } void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Point& point, void* data) { CCASSERT(func != nullptr, "func shouldn't be nullptr"); if (func != nullptr) { PointQueryCallbackInfo info = {this, func, data}; PhysicsWorldCallback::continues = true; cpSpaceNearestPointQuery(this->_info->getSpace(), PhysicsHelper::point2cpv(point), 0, CP_ALL_LAYERS, CP_NO_GROUP, (cpSpaceNearestPointQueryFunc)PhysicsWorldCallback::queryPointFunc, &info); } } Vector PhysicsWorld::getShapes(const Point& point) const { Vector arr; cpSpaceNearestPointQuery(this->_info->getSpace(), PhysicsHelper::point2cpv(point), 0, CP_ALL_LAYERS, CP_NO_GROUP, (cpSpaceNearestPointQueryFunc)PhysicsWorldCallback::getShapesAtPointFunc, &arr); return arr; } PhysicsShape* PhysicsWorld::getShape(const Point& point) const { cpShape* shape = cpSpaceNearestPointQueryNearest(this->_info->getSpace(), PhysicsHelper::point2cpv(point), 0, CP_ALL_LAYERS, CP_NO_GROUP, nullptr); return shape == nullptr ? nullptr : PhysicsShapeInfo::getMap().find(shape)->second->getShape(); } void PhysicsDebugDraw::drawShape(PhysicsShape& shape) { for (auto it = shape._info->getShapes().begin(); it != shape._info->getShapes().end(); ++it) { cpShape *subShape = *it; switch ((*it)->klass_private->type) { case CP_CIRCLE_SHAPE: { float radius = PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(subShape)); Point centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(subShape))) + PhysicsHelper::cpv2point(cpCircleShapeGetOffset(subShape)); static const int CIRCLE_SEG_NUM = 12; Point seg[CIRCLE_SEG_NUM] = {}; for (int i = 0; i < CIRCLE_SEG_NUM; ++i) { float angle = (float)i * M_PI / (float)CIRCLE_SEG_NUM * 2.0f; Point d(radius * cosf(angle), radius * sinf(angle)); seg[i] = centre + d; } _drawNode->drawPolygon(seg, CIRCLE_SEG_NUM, Color4F(1.0f, 0.0f, 0.0f, 0.3f), 1, Color4F(1, 0, 0, 1)); break; } case CP_SEGMENT_SHAPE: { cpSegmentShape *seg = (cpSegmentShape *)subShape; _drawNode->drawSegment(PhysicsHelper::cpv2point(seg->ta), PhysicsHelper::cpv2point(seg->tb), PhysicsHelper::cpfloat2float(seg->r==0 ? 1 : seg->r), Color4F(1, 0, 0, 1)); break; } case CP_POLY_SHAPE: { cpPolyShape* poly = (cpPolyShape*)subShape; int num = poly->numVerts; Point* seg = new Point[num]; PhysicsHelper::cpvs2points(poly->tVerts, seg, num); _drawNode->drawPolygon(seg, num, Color4F(1.0f, 0.0f, 0.0f, 0.3f), 1.0f, Color4F(1.0f, 0.0f, 0.0f, 1.0f)); delete[] seg; break; } default: break; } } } void PhysicsDebugDraw::drawJoint(PhysicsJoint& joint) { for (auto it = joint._info->getJoints().begin(); it != joint._info->getJoints().end(); ++it) { cpConstraint *constraint = *it; cpBody *body_a = constraint->a; cpBody *body_b = constraint->b; const cpConstraintClass *klass = constraint->klass_private; if(klass == cpPinJointGetClass()) { cpPinJoint *subJoint = (cpPinJoint *)constraint; cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot)); cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot)); _drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); } else if(klass == cpSlideJointGetClass()) { cpSlideJoint *subJoint = (cpSlideJoint *)constraint; cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot)); cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot)); _drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); } else if(klass == cpPivotJointGetClass()) { cpPivotJoint *subJoint = (cpPivotJoint *)constraint; cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot)); cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot)); _drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); } else if(klass == cpGrooveJointGetClass()) { cpGrooveJoint *subJoint = (cpGrooveJoint *)constraint; cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->grv_a, body_a->rot)); cpVect b = cpvadd(body_a->p, cpvrotate(subJoint->grv_b, body_a->rot)); cpVect c = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot)); _drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(c), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); } else if(klass == cpDampedSpringGetClass()) { cpDampedSpring *subJoint = (cpDampedSpring *)constraint; cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot)); cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot)); _drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); _drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); } } } void PhysicsDebugDraw::drawContact() { } PhysicsWorld* PhysicsWorld::construct(Scene& scene) { PhysicsWorld * world = new PhysicsWorld(); if(world && world->init(scene)) { return world; } CC_SAFE_DELETE(world); return nullptr; } bool PhysicsWorld::init(Scene& scene) { do { _info = new PhysicsWorldInfo(); CC_BREAK_IF(_info == nullptr); _scene = &scene; _info->setGravity(_gravity); cpSpaceSetDefaultCollisionHandler(_info->getSpace(), (cpCollisionBeginFunc)PhysicsWorldCallback::collisionBeginCallbackFunc, (cpCollisionPreSolveFunc)PhysicsWorldCallback::collisionPreSolveCallbackFunc, (cpCollisionPostSolveFunc)PhysicsWorldCallback::collisionPostSolveCallbackFunc, (cpCollisionSeparateFunc)PhysicsWorldCallback::collisionSeparateCallbackFunc, this); return true; } while (false); return false; } void PhysicsWorld::addBody(PhysicsBody* body) { CCASSERT(body != nullptr, "the body can not be nullptr"); if (body->getWorld() == this) { return; } if (body->getWorld() != nullptr) { body->removeFromWorld(); } addBodyOrDelay(body); _bodies.pushBack(body); body->_world = this; } void PhysicsWorld::doAddBody(PhysicsBody* body) { if (body->isEnabled()) { //is gravity enable if (!body->isGravityEnabled()) { body->applyForce(-_gravity); } // add body to space if (body->isDynamic()) { _info->addBody(*body->_info); } // add shapes to space for (auto& shape : body->getShapes()) { addShape(dynamic_cast(shape)); } } } void PhysicsWorld::addBodyOrDelay(PhysicsBody* body) { auto removeBodyIter = _delayRemoveBodies.find(body); if (removeBodyIter != _delayRemoveBodies.end()) { _delayRemoveBodies.erase(removeBodyIter); return; } if (_info->isLocked()) { if (_delayAddBodies.find(body) == _delayAddBodies.end()) { _delayAddBodies.pushBack(body); _delayDirty = true; } } else { doAddBody(body); } } void PhysicsWorld::updateBodies() { if (_info->isLocked()) { return; } for (auto& body : _delayAddBodies) { doAddBody(body); } for (auto& body : _delayRemoveBodies) { doRemoveBody(body); } _delayAddBodies.clear(); _delayRemoveBodies.clear(); } void PhysicsWorld::removeBody(int tag) { for (auto& body : _bodies) { if (body->getTag() == tag) { removeBody(body); return; } } } void PhysicsWorld::removeBody(PhysicsBody* body) { if (body->getWorld() != this) { CCLOG("Physics Warnning: this body doesn't belong to this world"); return; } // destory the body's joints for (auto joint : body->_joints) { // set destroy param to false to keep the iterator available removeJoint(joint, false); PhysicsBody* other = (joint->getBodyA() == body ? joint->getBodyB() : body); other->removeJoint(joint); // test the distraction is delaied or not if (_delayRemoveJoints.size() > 0 && _delayRemoveJoints.back() == joint) { joint->_destoryMark = true; } else { delete joint; } } body->_joints.clear(); removeBodyOrDelay(body); _bodies.eraseObject(body); body->_world = nullptr; } void PhysicsWorld::removeBodyOrDelay(PhysicsBody* body) { if (_delayAddBodies.getIndex(body) != CC_INVALID_INDEX) { _delayAddBodies.eraseObject(body); return; } if (_info->isLocked()) { if (_delayRemoveBodies.getIndex(body) == CC_INVALID_INDEX) { _delayRemoveBodies.pushBack(body); _delayDirty = true; } }else { doRemoveBody(body); } } void PhysicsWorld::doAddJoint(PhysicsJoint *joint) { if (joint == nullptr || joint->_info == nullptr) { return; } _info->addJoint(*joint->_info); } void PhysicsWorld::removeJoint(PhysicsJoint* joint, bool destroy) { if (joint->getWorld() != this) { if (destroy) { CCLOG("physics warnning: the joint is not in this world, it won't be destoried utill the body it conntect is destoried"); } return; } removeJointOrDelay(joint); _joints.remove(joint); joint->_world = nullptr; // clean the connection to this joint if (destroy) { if (joint->getBodyA() != nullptr) { joint->getBodyA()->removeJoint(joint); } if (joint->getBodyB() != nullptr) { joint->getBodyB()->removeJoint(joint); } // test the distraction is delaied or not if (_delayRemoveJoints.size() > 0 && _delayRemoveJoints.back() == joint) { joint->_destoryMark = true; } else { delete joint; } } } void PhysicsWorld::updateJoints() { if (_info->isLocked()) { return; } for (auto joint : _delayAddJoints) { doAddJoint(joint); } for (auto joint : _delayRemoveJoints) { doRemoveJoint(joint); if (joint->_destoryMark) { delete joint; } } _delayAddJoints.clear(); _delayRemoveJoints.clear(); } void PhysicsWorld::removeShape(PhysicsShape* shape) { if (shape != nullptr) { _info->removeShape(*shape->_info); } } void PhysicsWorld::addJointOrDelay(PhysicsJoint* joint) { auto it = std::find(_delayRemoveJoints.begin(), _delayRemoveJoints.end(), joint); if (it != _delayRemoveJoints.end()) { _delayRemoveJoints.erase(it); return; } if (_info->isLocked()) { if (std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint) == _delayAddJoints.end()) { _delayAddJoints.push_back(joint); _delayDirty = true; } }else { doAddJoint(joint); } } void PhysicsWorld::removeJointOrDelay(PhysicsJoint* joint) { auto it = std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint); if (it != _delayAddJoints.end()) { _delayAddJoints.erase(it); return; } if (_info->isLocked()) { if (std::find(_delayRemoveJoints.begin(), _delayRemoveJoints.end(), joint) == _delayRemoveJoints.end()) { _delayRemoveJoints.push_back(joint); _delayDirty = true; } }else { doRemoveJoint(joint); } } void PhysicsWorld::addJoint(PhysicsJoint* joint) { if (joint->getWorld() != nullptr && joint->getWorld() != this) { joint->removeFormWorld(); } addJointOrDelay(joint); _joints.push_back(joint); joint->_world = this; } void PhysicsWorld::removeAllJoints(bool destroy) { for (auto joint : _joints) { removeJointOrDelay(joint); joint->_world = nullptr; // clean the connection to this joint if (destroy) { if (joint->getBodyA() != nullptr) { joint->getBodyA()->removeJoint(joint); } if (joint->getBodyB() != nullptr) { joint->getBodyB()->removeJoint(joint); } // test the distraction is delaied or not if (_delayRemoveJoints.size() > 0 && _delayRemoveJoints.back() == joint) { joint->_destoryMark = true; } else { delete joint; } } } _joints.clear(); } void PhysicsWorld::addShape(PhysicsShape* shape) { if (shape != nullptr) { _info->addShape(*shape->_info); } } void PhysicsWorld::doRemoveBody(PhysicsBody* body) { CCASSERT(body != nullptr, "the body can not be nullptr"); // reset the gravity if (!body->isGravityEnabled()) { body->applyForce(-_gravity); } // remove shaps for (auto& shape : body->getShapes()) { removeShape(shape); } // remove body _info->removeBody(*body->_info); } void PhysicsWorld::doRemoveJoint(PhysicsJoint* joint) { _info->removeJoint(*joint->_info); } void PhysicsWorld::removeAllBodies() { for (auto& child : _bodies) { removeBodyOrDelay(child); child->_world = nullptr; } _bodies.clear(); } void PhysicsWorld::setDebugDrawMask(int mask) { if (mask == DEBUGDRAW_NONE) { CC_SAFE_DELETE(_debugDraw); } _debugDrawMask = mask; } const Vector& PhysicsWorld::getAllBodies() const { return _bodies; } PhysicsBody* PhysicsWorld::getBody(int tag) const { for (auto& body : _bodies) { if (body->getTag() == tag) { return body; } } return nullptr; } void PhysicsWorld::setGravity(const Vect& gravity) { if (!_bodies.empty()) { for (auto& body : _bodies) { // reset gravity for body if (!body->isGravityEnabled()) { body->applyForce(-_gravity); body->applyForce(gravity); } } } _gravity = gravity; _info->setGravity(gravity); } void PhysicsWorld::update(float delta) { if (_delayDirty) { // the updateJoints must run before the updateBodies. updateJoints(); updateBodies(); _delayDirty = !(_delayAddBodies.size() == 0 && _delayRemoveBodies.size() == 0 && _delayAddJoints.size() == 0 && _delayRemoveJoints.size() == 0); } for (auto& body : _bodies) { body->update(delta); } _updateTime += delta; if (++_updateRateCount >= _updateRate) { _info->step(_updateTime * _speed); _updateRateCount = 0; _updateTime = 0.0f; } if (_debugDrawMask != DEBUGDRAW_NONE) { debugDraw(); } } PhysicsWorld::PhysicsWorld() : _gravity(Point(0.0f, -98.0f)) , _speed(1.0f) , _updateRate(1) , _updateRateCount(0) , _updateTime(0.0f) , _info(nullptr) , _scene(nullptr) , _delayDirty(false) , _debugDraw(nullptr) , _debugDrawMask(DEBUGDRAW_NONE) { } PhysicsWorld::~PhysicsWorld() { removeAllJoints(true); removeAllBodies(); CC_SAFE_DELETE(_info); CC_SAFE_DELETE(_debugDraw); } PhysicsDebugDraw::PhysicsDebugDraw(PhysicsWorld& world) : _drawNode(nullptr) , _world(world) { } PhysicsDebugDraw::~PhysicsDebugDraw() { if (_drawNode != nullptr) { _drawNode->removeFromParent(); _drawNode = nullptr; } } bool PhysicsDebugDraw::begin() { if (_drawNode != nullptr) { _drawNode->removeFromParent(); _drawNode = nullptr; } _drawNode = DrawNode::create(); if (_drawNode == nullptr) { return false; } _world.getScene().addChild(_drawNode); return true; } void PhysicsDebugDraw::end() { } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/CCPhysicsWorld.h ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CCPHYSICS_WORLD_H__ #define __CCPHYSICS_WORLD_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "CCVector.h" #include "CCObject.h" #include "CCGeometry.h" #include NS_CC_BEGIN class PhysicsBody; class PhysicsJoint; class PhysicsWorldInfo; class PhysicsShape; class PhysicsContact; typedef Point Vect; class Sprite; class Scene; class DrawNode; class PhysicsDebugDraw; class PhysicsWorld; typedef struct PhysicsRayCastInfo { PhysicsShape* shape; Point start; Point end; //< in lua, it's name is "ended" Point contact; Vect normal; float fraction; void* data; }PhysicsRayCastInfo; /** * @brief Called for each fixture found in the query. You control how the ray cast * proceeds by returning a float: * return true: continue * return false: terminate the ray cast * @param fixture the fixture hit by the ray * @param point the point of initial intersection * @param normal the normal vector at the point of intersection * @return true to continue, false to terminate */ typedef std::function PhysicsRayCastCallbackFunc; typedef std::function PhysicsQueryRectCallbackFunc; typedef PhysicsQueryRectCallbackFunc PhysicsQueryPointCallbackFunc; /** * @brief An PhysicsWorld object simulates collisions and other physical properties. You do not create PhysicsWorld objects directly; instead, you can get it from an Scene object. */ class PhysicsWorld { public: static const int DEBUGDRAW_NONE; ///< draw nothing static const int DEBUGDRAW_SHAPE; ///< draw shapes static const int DEBUGDRAW_JOINT; ///< draw joints static const int DEBUGDRAW_CONTACT; ///< draw contact static const int DEBUGDRAW_ALL; ///< draw all public: /** Adds a joint to the physics world.*/ virtual void addJoint(PhysicsJoint* joint); /** Remove a joint from physics world.*/ virtual void removeJoint(PhysicsJoint* joint, bool destroy); /** Remove all joints from physics world.*/ virtual void removeAllJoints(bool destroy); /** Remove a body from physics world. */ virtual void removeBody(PhysicsBody* body); /** Remove body by tag. */ virtual void removeBody(int tag); /** Remove all bodies from physics world. */ virtual void removeAllBodies(); /** Searches for physics shapes that intersects the ray. */ void rayCast(PhysicsRayCastCallbackFunc func, const Point& start, const Point& end, void* data); /** Searches for physics shapes that contains in the rect. */ void queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect, void* data); /** Searches for physics shapes that contains the point. */ void queryPoint(PhysicsQueryPointCallbackFunc func, const Point& point, void* data); /** Get phsyics shapes that contains the point. */ Vector getShapes(const Point& point) const; /** return physics shape that contains the point. */ PhysicsShape* getShape(const Point& point) const; /** Get all the bodys that in the physics world. */ const Vector& getAllBodies() const; /** Get body by tag */ PhysicsBody* getBody(int tag) const; /** Get scene contain this physics world */ inline Scene& getScene() const { return *_scene; } /** get the gravity value */ inline Vect getGravity() const { return _gravity; } /** set the gravity value */ void setGravity(const Vect& gravity); /** Set the speed of physics world, speed is the rate at which the simulation executes. default value is 1.0 */ inline void setSpeed(float speed) { if(speed >= 0.0f) { _speed = speed; } } /** get the speed of physics world */ inline float getSpeed() { return _speed; } /** * set the update rate of physics world, update rate is the value of EngineUpdateTimes/PhysicsWorldUpdateTimes. * set it higher can improve performance, set it lower can improve accuracy of physics world simulation. * default value is 1.0 */ inline void setUpdateRate(int rate) { if(rate > 0) { _updateRate = rate; } } /** get the update rate */ inline int getUpdateRate() { return _updateRate; } /** set the debug draw mask */ void setDebugDrawMask(int mask); /** get the bebug draw mask */ inline int getDebugDrawMask() { return _debugDrawMask; } protected: static PhysicsWorld* construct(Scene& scene); bool init(Scene& scene); virtual void addBody(PhysicsBody* body); virtual void addShape(PhysicsShape* shape); virtual void removeShape(PhysicsShape* shape); virtual void update(float delta); virtual void debugDraw(); virtual int collisionBeginCallback(PhysicsContact& contact); virtual int collisionPreSolveCallback(PhysicsContact& contact); virtual void collisionPostSolveCallback(PhysicsContact& contact); virtual void collisionSeparateCallback(PhysicsContact& contact); virtual void doAddBody(PhysicsBody* body); virtual void doRemoveBody(PhysicsBody* body); virtual void doAddJoint(PhysicsJoint* joint); virtual void doRemoveJoint(PhysicsJoint* joint); virtual void addBodyOrDelay(PhysicsBody* body); virtual void removeBodyOrDelay(PhysicsBody* body); virtual void addJointOrDelay(PhysicsJoint* joint); virtual void removeJointOrDelay(PhysicsJoint* joint); virtual void updateBodies(); virtual void updateJoints(); protected: Vect _gravity; float _speed; int _updateRate; int _updateRateCount; float _updateTime; PhysicsWorldInfo* _info; Vector _bodies; std::list _joints; Scene* _scene; bool _delayDirty; PhysicsDebugDraw* _debugDraw; int _debugDrawMask; Vector _delayAddBodies; Vector _delayRemoveBodies; std::vector _delayAddJoints; std::vector _delayRemoveJoints; protected: PhysicsWorld(); virtual ~PhysicsWorld(); friend class Sprite; friend class Scene; friend class PhysicsBody; friend class PhysicsShape; friend class PhysicsJoint; friend class PhysicsWorldCallback; friend class PhysicsDebugDraw; }; class PhysicsDebugDraw { protected: virtual bool begin(); virtual void end(); virtual void drawShape(PhysicsShape& shape); virtual void drawJoint(PhysicsJoint& joint); virtual void drawContact(); protected: PhysicsDebugDraw(PhysicsWorld& world); virtual ~PhysicsDebugDraw(); protected: DrawNode* _drawNode; PhysicsWorld& _world; friend class PhysicsWorld; }; extern const float PHYSICS_INFINITY; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_WORLD_H__ ================================================ FILE: cocos2d/cocos/physics/CMakeLists.txt ================================================ set(COCOS_PHYSICS_SRC ../physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp ../physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp ../physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp ../physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp ../physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp ../physics/CCPhysicsBody.cpp ../physics/CCPhysicsContact.cpp ../physics/CCPhysicsShape.cpp ../physics/CCPhysicsJoint.cpp ../physics/CCPhysicsWorld.cpp ) ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp ================================================ /**************************************************************************** Copyright (c) 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 "CCPhysicsBodyInfo_chipmunk.h" #if CC_USE_PHYSICS NS_CC_BEGIN PhysicsBodyInfo::PhysicsBodyInfo() : _body(nullptr) { } PhysicsBodyInfo::~PhysicsBodyInfo() { if (_body) cpBodyFree(_body); } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.h ================================================ /**************************************************************************** Copyright (c) 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 __CCPHYSICS_BODY_INFO_CHIPMUNK_H__ #define __CCPHYSICS_BODY_INFO_CHIPMUNK_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPlatformMacros.h" #include "CCObject.h" NS_CC_BEGIN class PhysicsBodyInfo { public: inline cpBody* getBody() const { return _body; } inline void setBody(cpBody* body) { _body = body; } private: PhysicsBodyInfo(); ~PhysicsBodyInfo(); private: cpBody* _body; friend class PhysicsBody; }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_BODY_INFO_CHIPMUNK_H__ ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp ================================================ /**************************************************************************** Copyright (c) 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 "CCPhysicsContactInfo_chipmunk.h" #if CC_USE_PHYSICS NS_CC_BEGIN PhysicsContactInfo::PhysicsContactInfo(PhysicsContact* contact) : _contact(contact) { } PhysicsContactInfo::~PhysicsContactInfo() { } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.h ================================================ /**************************************************************************** Copyright (c) 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 __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__ #define __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPlatformMacros.h" NS_CC_BEGIN class PhysicsContact; class PhysicsContactInfo { public: inline PhysicsContact* getContact() const { return _contact; } private: PhysicsContactInfo(PhysicsContact* contact); ~PhysicsContactInfo(); private: PhysicsContact* _contact; friend class PhysicsContact; }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__ ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsHelper_chipmunk.h ================================================ /**************************************************************************** Copyright (c) 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 __CCPHYSICS_HELPER_CHIPMUNK_H__ #define __CCPHYSICS_HELPER_CHIPMUNK_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPlatformMacros.h" #include "CCGeometry.h" NS_CC_BEGIN class PhysicsHelper { public: static Point cpv2point(const cpVect& vec) { return Point(vec.x, vec.y); } static cpVect point2cpv(const Point& point) { return cpv(point.x, point.y); } static Size cpv2size(const cpVect& vec) { return Size(vec.x, vec.y); } static cpVect size2cpv(const Size& size) { return cpv(size.width, size.height); } static float cpfloat2float(cpFloat f) { return f; } static cpFloat float2cpfloat(float f) { return f; } static cpBB rect2cpbb(const Rect& rect) { return cpBBNew(rect.origin.x, rect.origin.y, rect.origin.x + rect.size.width, rect.origin.y + rect.size.height); } static Rect cpbb2rect(const cpBB& bb) { return Rect(bb.l, bb.b, bb.r - bb.l, bb.t - bb.b); } static Point* cpvs2points(const cpVect* cpvs, Point* out, int count) { for (int i = 0; i < count; ++i) { out[i] = cpv2point(cpvs[i]); } return out; } static cpVect* points2cpvs(const Point* points, cpVect* out, int count) { for (int i = 0; i < count; ++i) { out[i] = point2cpv(points[i]); } return out; } }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_HELPER_CHIPMUNK_H__ ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp ================================================ /**************************************************************************** Copyright (c) 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 "CCPhysicsJointInfo_chipmunk.h" #if CC_USE_PHYSICS #include #include NS_CC_BEGIN std::unordered_map PhysicsJointInfo::_map; PhysicsJointInfo::PhysicsJointInfo(PhysicsJoint* joint) : _joint(joint) { } PhysicsJointInfo::~PhysicsJointInfo() { for (cpConstraint* joint : _joints) { cpConstraintFree(joint); } } void PhysicsJointInfo::add(cpConstraint* joint) { if (joint == nullptr) return; _joints.push_back(joint); _map.insert(std::pair(joint, this)); } void PhysicsJointInfo::remove(cpConstraint* joint) { if (joint == nullptr) return; auto it = std::find(_joints.begin(), _joints.end(), joint); if (it != _joints.end()) { _joints.erase(it); auto mit = _map.find(joint); if (mit != _map.end()) _map.erase(mit); cpConstraintFree(joint); } } void PhysicsJointInfo::removeAll() { for (cpConstraint* joint : _joints) { auto mit = _map.find(joint); if (mit != _map.end()) _map.erase(mit); cpConstraintFree(joint); } _joints.clear(); } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.h ================================================ /**************************************************************************** Copyright (c) 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 __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__ #define __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include "chipmunk.h" #include "CCPlatformMacros.h" #include #include NS_CC_BEGIN class PhysicsJoint; class PhysicsJointInfo { public: void add(cpConstraint* shape); void remove(cpConstraint* shape); void removeAll(); PhysicsJoint* getJoint() const { return _joint; } std::vector& getJoints() { return _joints; } static std::unordered_map& getMap() { return _map; } protected: PhysicsJointInfo(PhysicsJoint* joint); ~PhysicsJointInfo(); std::vector _joints; PhysicsJoint* _joint; static std::unordered_map _map; friend class PhysicsJoint; }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__ ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp ================================================ /**************************************************************************** Copyright (c) 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 "CCPhysicsShapeInfo_chipmunk.h" #if CC_USE_PHYSICS #include #include NS_CC_BEGIN std::unordered_map PhysicsShapeInfo::_map; cpBody* PhysicsShapeInfo::_sharedBody = nullptr; PhysicsShapeInfo::PhysicsShapeInfo(PhysicsShape* shape) : _shape(shape) , _group(CP_NO_GROUP) { if (_sharedBody == nullptr) { _sharedBody = cpBodyNewStatic(); } _body = _sharedBody; } PhysicsShapeInfo::~PhysicsShapeInfo() { for (auto shape : _shapes) { auto it = _map.find(shape); if (it != _map.end()) _map.erase(shape); cpShapeFree(shape); } } void PhysicsShapeInfo::setGroup(cpGroup group) { this->_group = group; for (cpShape* shape : _shapes) { cpShapeSetGroup(shape, group); } } void PhysicsShapeInfo::setBody(cpBody* body) { if (this->_body != body) { this->_body = body; for (cpShape* shape : _shapes) { cpShapeSetBody(shape, body == nullptr ? _sharedBody : body); } } } void PhysicsShapeInfo::add(cpShape* shape) { if (shape == nullptr) return; cpShapeSetGroup(shape, _group); _shapes.push_back(shape); _map.insert(std::pair(shape, this)); } void PhysicsShapeInfo::remove(cpShape* shape) { if (shape == nullptr) return; auto it = std::find(_shapes.begin(), _shapes.end(), shape); if (it != _shapes.end()) { _shapes.erase(it); auto mit = _map.find(shape); if (mit != _map.end()) _map.erase(mit); cpShapeFree(shape); } } void PhysicsShapeInfo::removeAll() { for (cpShape* shape : _shapes) { auto mit = _map.find(shape); if (mit != _map.end()) _map.erase(mit); cpShapeFree(shape); } _shapes.clear(); } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.h ================================================ /**************************************************************************** Copyright (c) 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 __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__ #define __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include #include #include "chipmunk.h" #include "CCPlatformMacros.h" NS_CC_BEGIN class PhysicsShape; class PhysicsShapeInfo { public: void add(cpShape* shape); void remove(cpShape* shape); void removeAll(); void setGroup(cpGroup group); void setBody(cpBody* body); PhysicsShape* getShape() const { return _shape; } std::vector& getShapes() { return _shapes; } cpBody* getBody() const { return _body; } cpGroup getGourp() const { return _group; } static std::unordered_map& getMap() { return _map; } static cpBody* getSharedBody() { return _sharedBody; } protected: PhysicsShapeInfo(PhysicsShape* shape); ~PhysicsShapeInfo(); std::vector _shapes; PhysicsShape* _shape; cpBody* _body; cpGroup _group; static std::unordered_map _map; static cpBody* _sharedBody; friend class PhysicsShape; }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__ ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp ================================================ /**************************************************************************** Copyright (c) 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 "CCPhysicsWorldInfo_chipmunk.h" #if CC_USE_PHYSICS #include "CCPhysicsHelper_chipmunk.h" #include "CCPhysicsBodyInfo_chipmunk.h" #include "CCPhysicsShapeInfo_chipmunk.h" #include "CCPhysicsJointInfo_chipmunk.h" NS_CC_BEGIN PhysicsWorldInfo::PhysicsWorldInfo() { _space = cpSpaceNew(); } PhysicsWorldInfo::~PhysicsWorldInfo() { cpSpaceFree(_space); } void PhysicsWorldInfo::setGravity(const Vect& gravity) { cpSpaceSetGravity(_space, PhysicsHelper::point2cpv(gravity)); } void PhysicsWorldInfo::addBody(PhysicsBodyInfo& body) { if (!cpSpaceContainsBody(_space, body.getBody())) { cpSpaceAddBody(_space, body.getBody()); } } void PhysicsWorldInfo::removeBody(PhysicsBodyInfo& body) { if (cpSpaceContainsBody(_space, body.getBody())) { cpSpaceRemoveBody(_space, body.getBody()); } } void PhysicsWorldInfo::addShape(PhysicsShapeInfo& shape) { for (auto cps : shape.getShapes()) { cpSpaceAddShape(_space, cps); } } void PhysicsWorldInfo::removeShape(PhysicsShapeInfo& shape) { for (auto cps : shape.getShapes()) { if (cpSpaceContainsShape(_space, cps)) { cpSpaceRemoveShape(_space, cps); } } } void PhysicsWorldInfo::addJoint(PhysicsJointInfo& joint) { for (auto subjoint : joint.getJoints()) { cpSpaceAddConstraint(_space, subjoint); } } void PhysicsWorldInfo::removeJoint(PhysicsJointInfo& joint) { for (auto subjoint : joint.getJoints()) { cpSpaceRemoveConstraint(_space, subjoint); } } NS_CC_END #endif // CC_USE_PHYSICS ================================================ FILE: cocos2d/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h ================================================ /**************************************************************************** Copyright (c) 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 __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__ #define __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__ #include "ccConfig.h" #if CC_USE_PHYSICS #include #include "chipmunk.h" #include "CCPlatformMacros.h" #include "CCGeometry.h" NS_CC_BEGIN typedef Point Vect; class PhysicsBodyInfo; class PhysicsJointInfo; class PhysicsShapeInfo; class PhysicsWorldInfo { public: cpSpace* getSpace() const { return _space; } void addShape(PhysicsShapeInfo& shape); void removeShape(PhysicsShapeInfo& shape); void addBody(PhysicsBodyInfo& body); void removeBody(PhysicsBodyInfo& body); void addJoint(PhysicsJointInfo& joint); void removeJoint(PhysicsJointInfo& joint); void setGravity(const Vect& gravity); inline bool isLocked() { return 0 == _space->locked_private ? false : true; } inline void step(float delta) { cpSpaceStep(_space, delta); } private: PhysicsWorldInfo(); ~PhysicsWorldInfo(); private: cpSpace* _space; friend class PhysicsWorld; }; NS_CC_END #endif // CC_USE_PHYSICS #endif // __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__ ================================================ FILE: cocos2d/cocos/scripting/CMakeLists.txt ================================================ set(LUABINDING_SRC auto-generated/lua-bindings/lua_cocos2dx_auto.cpp auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp auto-generated/lua-bindings/lua_cocos2dx_gui_auto.cpp auto-generated/lua-bindings/lua_cocos2dx_spine_auto.cpp auto-generated/lua-bindings/lua_cocos2dx_physics_auto.cpp lua/bindings/tolua_fix.c lua/bindings/CCLuaBridge.cpp lua/bindings/CCLuaEngine.cpp lua/bindings/CCLuaStack.cpp lua/bindings/CCLuaValue.cpp lua/bindings/Cocos2dxLuaLoader.cpp lua/bindings/CCBProxy.cpp lua/bindings/LuaOpengl.cpp lua/bindings/LuaScriptHandlerMgr.cpp lua/bindings/LuaBasicConversions.cpp lua/bindings/lua_cocos2dx_manual.cpp lua/bindings/lua_cocos2dx_extension_manual.cpp lua/bindings/lua_cocos2dx_coco_studio_manual.cpp lua/bindings/lua_cocos2dx_gui_manual.cpp lua/bindings/lua_cocos2dx_spine_manual.cpp lua/bindings/lua_cocos2dx_physics_manual.cpp lua/bindings/lua_cocos2dx_deprecated.cpp lua/bindings/lua_xml_http_request.cpp lua/bindings/LuaSkeletonAnimation.cpp ) include_directories( auto-generated/lua-bindings lua/bindings ../../cocos/editor-support/cocosbuilder ../../cocos/editor-support/cocostudio ../../cocos/editor-support/spine ../../cocos/gui ../../external/lua/lua ../../external/lua/tolua ) add_library(luabinding STATIC ${LUABINDING_SRC} ) target_link_libraries(luabinding tolua lua spine ) set_target_properties(luabinding PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/cocos/scripting/auto-generated/README.md ================================================ bindings-auto-generated ======================= Automatically generate javascript binding and lua binding codes for cocos2d-x ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_auto.cpp ================================================ #include "jsb_cocos2dx_auto.hpp" #include "cocos2d_specifics.hpp" #include "cocos2d.h" #include "SimpleAudioEngine.h" template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedValue initializing(cx); JSBool isNewValid = JS_TRUE; JSObject* global = ScriptingCore::getInstance()->getGlobalObject(); isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && JSVAL_TO_BOOLEAN(initializing); if (isNewValid) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); return JS_TRUE; } JS_ReportError(cx, "Don't use `new cc.XXX`, please use `cc.XXX.create` instead! "); return JS_FALSE; } static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { return JS_FALSE; } static JSBool js_is_native_obj(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { vp.set(BOOLEAN_TO_JSVAL(JS_TRUE)); return JS_TRUE; } JSClass *jsb_cocos2d_Action_class; JSObject *jsb_cocos2d_Action_prototype; JSBool js_cocos2dx_Action_startWithTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_startWithTarget : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Action_startWithTarget : Error processing arguments"); cobj->startWithTarget(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_startWithTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Action_setOriginalTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_setOriginalTarget : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Action_setOriginalTarget : Error processing arguments"); cobj->setOriginalTarget(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_setOriginalTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Action_clone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_clone : Invalid Native Object"); if (argc == 0) { cocos2d::Action* ret = cobj->clone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_clone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Action_getOriginalTarget(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_getOriginalTarget : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getOriginalTarget(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_getOriginalTarget : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Action_stop(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_stop : Invalid Native Object"); if (argc == 0) { cobj->stop(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_stop : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Action_update(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_update : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Action_update : Error processing arguments"); cobj->update(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_update : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Action_getTarget(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_getTarget : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getTarget(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_getTarget : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Action_step(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_step : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Action_step : Error processing arguments"); cobj->step(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_step : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Action_setTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_setTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Action_setTag : Error processing arguments"); cobj->setTag(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_setTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Action_getTag(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_getTag : Invalid Native Object"); if (argc == 0) { int ret = cobj->getTag(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_getTag : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Action_setTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_setTarget : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Action_setTarget : Error processing arguments"); cobj->setTarget(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_setTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Action_isDone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_isDone : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isDone(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_isDone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Action_reverse(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Action_reverse : Invalid Native Object"); if (argc == 0) { cocos2d::Action* ret = cobj->reverse(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Action_reverse : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_Action_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Action)", obj); } void js_register_cocos2dx_Action(JSContext *cx, JSObject *global) { jsb_cocos2d_Action_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Action_class->name = "Action"; jsb_cocos2d_Action_class->addProperty = JS_PropertyStub; jsb_cocos2d_Action_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Action_class->getProperty = JS_PropertyStub; jsb_cocos2d_Action_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Action_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Action_class->resolve = JS_ResolveStub; jsb_cocos2d_Action_class->convert = JS_ConvertStub; jsb_cocos2d_Action_class->finalize = js_cocos2d_Action_finalize; jsb_cocos2d_Action_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("startWithTarget", js_cocos2dx_Action_startWithTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOriginalTarget", js_cocos2dx_Action_setOriginalTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clone", js_cocos2dx_Action_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOriginalTarget", js_cocos2dx_Action_getOriginalTarget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stop", js_cocos2dx_Action_stop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", js_cocos2dx_Action_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTarget", js_cocos2dx_Action_getTarget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("step", js_cocos2dx_Action_step, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTag", js_cocos2dx_Action_setTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTag", js_cocos2dx_Action_getTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTarget", js_cocos2dx_Action_setTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isDone", js_cocos2dx_Action_isDone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reverse", js_cocos2dx_Action_reverse, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Action_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Action_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Action", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Action_class; p->proto = jsb_cocos2d_Action_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FiniteTimeAction_class; JSObject *jsb_cocos2d_FiniteTimeAction_prototype; JSBool js_cocos2dx_FiniteTimeAction_setDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FiniteTimeAction* cobj = (cocos2d::FiniteTimeAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FiniteTimeAction_setDuration : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FiniteTimeAction_setDuration : Error processing arguments"); cobj->setDuration(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FiniteTimeAction_setDuration : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FiniteTimeAction_getDuration(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FiniteTimeAction* cobj = (cocos2d::FiniteTimeAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FiniteTimeAction_getDuration : Invalid Native Object"); if (argc == 0) { double ret = cobj->getDuration(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FiniteTimeAction_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Action_prototype; void js_cocos2d_FiniteTimeAction_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FiniteTimeAction)", obj); } void js_register_cocos2dx_FiniteTimeAction(JSContext *cx, JSObject *global) { jsb_cocos2d_FiniteTimeAction_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FiniteTimeAction_class->name = "FiniteTimeAction"; jsb_cocos2d_FiniteTimeAction_class->addProperty = JS_PropertyStub; jsb_cocos2d_FiniteTimeAction_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FiniteTimeAction_class->getProperty = JS_PropertyStub; jsb_cocos2d_FiniteTimeAction_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FiniteTimeAction_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FiniteTimeAction_class->resolve = JS_ResolveStub; jsb_cocos2d_FiniteTimeAction_class->convert = JS_ConvertStub; jsb_cocos2d_FiniteTimeAction_class->finalize = js_cocos2d_FiniteTimeAction_finalize; jsb_cocos2d_FiniteTimeAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setDuration", js_cocos2dx_FiniteTimeAction_setDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDuration", js_cocos2dx_FiniteTimeAction_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_FiniteTimeAction_prototype = JS_InitClass( cx, global, jsb_cocos2d_Action_prototype, jsb_cocos2d_FiniteTimeAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FiniteTimeAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FiniteTimeAction_class; p->proto = jsb_cocos2d_FiniteTimeAction_prototype; p->parentProto = jsb_cocos2d_Action_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Speed_class; JSObject *jsb_cocos2d_Speed_prototype; JSBool js_cocos2dx_Speed_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Speed_setInnerAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Speed_setInnerAction : Error processing arguments"); cobj->setInnerAction(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Speed_setInnerAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Speed_setSpeed(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Speed_setSpeed : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Speed_setSpeed : Error processing arguments"); cobj->setSpeed(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Speed_setSpeed : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Speed_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Speed_getInnerAction : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->getInnerAction(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Speed_getInnerAction : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Speed_getSpeed(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Speed_getSpeed : Invalid Native Object"); if (argc == 0) { double ret = cobj->getSpeed(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Speed_getSpeed : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Speed_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::ActionInterval* arg0; double arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Speed_create : Error processing arguments"); cocos2d::Speed* ret = cocos2d::Speed::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Speed*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Speed_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Action_prototype; void js_cocos2d_Speed_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Speed)", obj); } void js_register_cocos2dx_Speed(JSContext *cx, JSObject *global) { jsb_cocos2d_Speed_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Speed_class->name = "Speed"; jsb_cocos2d_Speed_class->addProperty = JS_PropertyStub; jsb_cocos2d_Speed_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Speed_class->getProperty = JS_PropertyStub; jsb_cocos2d_Speed_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Speed_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Speed_class->resolve = JS_ResolveStub; jsb_cocos2d_Speed_class->convert = JS_ConvertStub; jsb_cocos2d_Speed_class->finalize = js_cocos2d_Speed_finalize; jsb_cocos2d_Speed_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setInnerAction", js_cocos2dx_Speed_setInnerAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSpeed", js_cocos2dx_Speed_setSpeed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInnerAction", js_cocos2dx_Speed_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpeed", js_cocos2dx_Speed_getSpeed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Speed_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Speed_prototype = JS_InitClass( cx, global, jsb_cocos2d_Action_prototype, jsb_cocos2d_Speed_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Speed", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Speed_class; p->proto = jsb_cocos2d_Speed_prototype; p->parentProto = jsb_cocos2d_Action_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Follow_class; JSObject *jsb_cocos2d_Follow_prototype; JSBool js_cocos2dx_Follow_setBoudarySet(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Follow* cobj = (cocos2d::Follow *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Follow_setBoudarySet : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Follow_setBoudarySet : Error processing arguments"); cobj->setBoudarySet(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Follow_setBoudarySet : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Follow_isBoundarySet(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Follow* cobj = (cocos2d::Follow *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Follow_isBoundarySet : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isBoundarySet(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Follow_isBoundarySet : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Follow_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Follow_create : Error processing arguments"); cocos2d::Follow* ret = cocos2d::Follow::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Follow*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { cocos2d::Node* arg0; cocos2d::Rect arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccrect(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Follow_create : Error processing arguments"); cocos2d::Follow* ret = cocos2d::Follow::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Follow*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Follow_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Action_prototype; void js_cocos2d_Follow_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Follow)", obj); } void js_register_cocos2dx_Follow(JSContext *cx, JSObject *global) { jsb_cocos2d_Follow_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Follow_class->name = "Follow"; jsb_cocos2d_Follow_class->addProperty = JS_PropertyStub; jsb_cocos2d_Follow_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Follow_class->getProperty = JS_PropertyStub; jsb_cocos2d_Follow_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Follow_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Follow_class->resolve = JS_ResolveStub; jsb_cocos2d_Follow_class->convert = JS_ConvertStub; jsb_cocos2d_Follow_class->finalize = js_cocos2d_Follow_finalize; jsb_cocos2d_Follow_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setBoudarySet", js_cocos2dx_Follow_setBoudarySet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBoundarySet", js_cocos2dx_Follow_isBoundarySet, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Follow_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Follow_prototype = JS_InitClass( cx, global, jsb_cocos2d_Action_prototype, jsb_cocos2d_Follow_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Follow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Follow_class; p->proto = jsb_cocos2d_Follow_prototype; p->parentProto = jsb_cocos2d_Action_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_GLProgram_class; JSObject *jsb_cocos2d_GLProgram_prototype; JSBool js_cocos2dx_GLProgram_getFragmentShaderLog(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_getFragmentShaderLog : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getFragmentShaderLog(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_getFragmentShaderLog : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_addAttribute(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_addAttribute : Invalid Native Object"); if (argc == 2) { const char* arg0; unsigned int arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_uint32(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_addAttribute : Error processing arguments"); cobj->addAttribute(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_addAttribute : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv : Invalid Native Object"); if (argc == 3) { int arg0; const float* arg1; unsigned int arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR float*; ok &= jsval_to_uint32(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv : Error processing arguments"); cobj->setUniformLocationWithMatrix4fv(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_getUniformLocationForName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_getUniformLocationForName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_getUniformLocationForName : Error processing arguments"); int ret = cobj->getUniformLocationForName(arg0); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_getUniformLocationForName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_use(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_use : Invalid Native Object"); if (argc == 0) { cobj->use(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_use : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_getVertexShaderLog(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_getVertexShaderLog : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getVertexShaderLog(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_getVertexShaderLog : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_initWithVertexShaderByteArray(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_initWithVertexShaderByteArray : Invalid Native Object"); if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_initWithVertexShaderByteArray : Error processing arguments"); JSBool ret = cobj->initWithVertexShaderByteArray(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_initWithVertexShaderByteArray : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_initWithVertexShaderFilename(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_initWithVertexShaderFilename : Invalid Native Object"); if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_initWithVertexShaderFilename : Error processing arguments"); JSBool ret = cobj->initWithVertexShaderFilename(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_initWithVertexShaderFilename : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformsForBuiltins(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::GLProgram* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformsForBuiltins : Invalid Native Object"); do { if (argc == 1) { kmMat4 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmMat4; if (!ok) { ok = JS_TRUE; break; } cobj->setUniformsForBuiltins(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 0) { cobj->setUniformsForBuiltins(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformsForBuiltins : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWith3i(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith3i : Invalid Native Object"); if (argc == 4) { int arg0; int arg1; int arg2; int arg3; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith3i : Error processing arguments"); cobj->setUniformLocationWith3i(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith3i : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWith3iv(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith3iv : Invalid Native Object"); if (argc == 3) { int arg0; int* arg1; unsigned int arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR int*; ok &= jsval_to_uint32(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith3iv : Error processing arguments"); cobj->setUniformLocationWith3iv(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith3iv : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_updateUniforms(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_updateUniforms : Invalid Native Object"); if (argc == 0) { cobj->updateUniforms(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_updateUniforms : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWith4iv(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith4iv : Invalid Native Object"); if (argc == 3) { int arg0; int* arg1; unsigned int arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR int*; ok &= jsval_to_uint32(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith4iv : Error processing arguments"); cobj->setUniformLocationWith4iv(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith4iv : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv : Invalid Native Object"); if (argc == 3) { int arg0; const float* arg1; unsigned int arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR float*; ok &= jsval_to_uint32(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv : Error processing arguments"); cobj->setUniformLocationWithMatrix2fv(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_link(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_link : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->link(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_link : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWith2iv(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith2iv : Invalid Native Object"); if (argc == 3) { int arg0; int* arg1; unsigned int arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR int*; ok &= jsval_to_uint32(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith2iv : Error processing arguments"); cobj->setUniformLocationWith2iv(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith2iv : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv : Invalid Native Object"); if (argc == 3) { int arg0; const float* arg1; unsigned int arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR float*; ok &= jsval_to_uint32(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv : Error processing arguments"); cobj->setUniformLocationWithMatrix3fv(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_reset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_reset : Invalid Native Object"); if (argc == 0) { cobj->reset(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_reset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWith4i(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith4i : Invalid Native Object"); if (argc == 5) { int arg0; int arg1; int arg2; int arg3; int arg4; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith4i : Error processing arguments"); cobj->setUniformLocationWith4i(arg0, arg1, arg2, arg3, arg4); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith4i : wrong number of arguments: %d, was expecting %d", argc, 5); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWith1i(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith1i : Invalid Native Object"); if (argc == 2) { int arg0; int arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith1i : Error processing arguments"); cobj->setUniformLocationWith1i(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith1i : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_setUniformLocationWith2i(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith2i : Invalid Native Object"); if (argc == 3) { int arg0; int arg1; int arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GLProgram_setUniformLocationWith2i : Error processing arguments"); cobj->setUniformLocationWith2i(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith2i : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_GLProgram_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::GLProgram* cobj = new cocos2d::GLProgram(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::GLProgram"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GLProgram_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_GLProgram_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (GLProgram)", obj); } void js_register_cocos2dx_GLProgram(JSContext *cx, JSObject *global) { jsb_cocos2d_GLProgram_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_GLProgram_class->name = "GLProgram"; jsb_cocos2d_GLProgram_class->addProperty = JS_PropertyStub; jsb_cocos2d_GLProgram_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_GLProgram_class->getProperty = JS_PropertyStub; jsb_cocos2d_GLProgram_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_GLProgram_class->enumerate = JS_EnumerateStub; jsb_cocos2d_GLProgram_class->resolve = JS_ResolveStub; jsb_cocos2d_GLProgram_class->convert = JS_ConvertStub; jsb_cocos2d_GLProgram_class->finalize = js_cocos2d_GLProgram_finalize; jsb_cocos2d_GLProgram_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getFragmentShaderLog", js_cocos2dx_GLProgram_getFragmentShaderLog, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addAttribute", js_cocos2dx_GLProgram_addAttribute, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWithMatrix4fv", js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUniformLocationForName", js_cocos2dx_GLProgram_getUniformLocationForName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("use", js_cocos2dx_GLProgram_use, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVertexShaderLog", js_cocos2dx_GLProgram_getVertexShaderLog, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithString", js_cocos2dx_GLProgram_initWithVertexShaderByteArray, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_GLProgram_initWithVertexShaderFilename, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformsForBuiltins", js_cocos2dx_GLProgram_setUniformsForBuiltins, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith3i", js_cocos2dx_GLProgram_setUniformLocationWith3i, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith3iv", js_cocos2dx_GLProgram_setUniformLocationWith3iv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateUniforms", js_cocos2dx_GLProgram_updateUniforms, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith4iv", js_cocos2dx_GLProgram_setUniformLocationWith4iv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWithMatrix2fv", js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("link", js_cocos2dx_GLProgram_link, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith2iv", js_cocos2dx_GLProgram_setUniformLocationWith2iv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWithMatrix3fv", js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reset", js_cocos2dx_GLProgram_reset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith4i", js_cocos2dx_GLProgram_setUniformLocationWith4i, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationI32", js_cocos2dx_GLProgram_setUniformLocationWith1i, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith2i", js_cocos2dx_GLProgram_setUniformLocationWith2i, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_GLProgram_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_GLProgram_class, js_cocos2dx_GLProgram_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "GLProgram", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_GLProgram_class; p->proto = jsb_cocos2d_GLProgram_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Touch_class; JSObject *jsb_cocos2d_Touch_prototype; JSBool js_cocos2dx_Touch_getPreviousLocationInView(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_getPreviousLocationInView : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getPreviousLocationInView(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_getPreviousLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Touch_getLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_getLocation : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getLocation(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_getLocation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Touch_getDelta(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_getDelta : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getDelta(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_getDelta : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Touch_getStartLocationInView(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_getStartLocationInView : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getStartLocationInView(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_getStartLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Touch_getStartLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_getStartLocation : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getStartLocation(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_getStartLocation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Touch_getID(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_getID : Invalid Native Object"); if (argc == 0) { int ret = cobj->getID(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_getID : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Touch_setTouchInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_setTouchInfo : Invalid Native Object"); if (argc == 3) { int arg0; double arg1; double arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Touch_setTouchInfo : Error processing arguments"); cobj->setTouchInfo(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_setTouchInfo : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_Touch_getLocationInView(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_getLocationInView : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getLocationInView(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_getLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Touch_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Touch_getPreviousLocation : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getPreviousLocation(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_getPreviousLocation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Touch_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Touch* cobj = new cocos2d::Touch(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Touch"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Touch_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_Touch_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Touch)", obj); } void js_register_cocos2dx_Touch(JSContext *cx, JSObject *global) { jsb_cocos2d_Touch_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Touch_class->name = "Touch"; jsb_cocos2d_Touch_class->addProperty = JS_PropertyStub; jsb_cocos2d_Touch_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Touch_class->getProperty = JS_PropertyStub; jsb_cocos2d_Touch_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Touch_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Touch_class->resolve = JS_ResolveStub; jsb_cocos2d_Touch_class->convert = JS_ConvertStub; jsb_cocos2d_Touch_class->finalize = js_cocos2d_Touch_finalize; jsb_cocos2d_Touch_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getPreviousLocationInView", js_cocos2dx_Touch_getPreviousLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLocation", js_cocos2dx_Touch_getLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDelta", js_cocos2dx_Touch_getDelta, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartLocationInView", js_cocos2dx_Touch_getStartLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartLocation", js_cocos2dx_Touch_getStartLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getId", js_cocos2dx_Touch_getID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchInfo", js_cocos2dx_Touch_setTouchInfo, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLocationInView", js_cocos2dx_Touch_getLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPreviousLocation", js_cocos2dx_Touch_getPreviousLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Touch_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Touch_class, js_cocos2dx_Touch_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Touch", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Touch_class; p->proto = jsb_cocos2d_Touch_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Texture2D_class; JSObject *jsb_cocos2d_Texture2D_prototype; JSBool js_cocos2dx_Texture2D_getShaderProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getShaderProgram : Invalid Native Object"); if (argc == 0) { cocos2d::GLProgram* ret = cobj->getShaderProgram(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GLProgram*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getShaderProgram : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getMaxT(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getMaxT : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMaxT(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getMaxT : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getStringForFormat(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getStringForFormat : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getStringForFormat(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getStringForFormat : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Texture2D* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_initWithImage : Invalid Native Object"); do { if (argc == 2) { cocos2d::Image* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D::PixelFormat arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithImage(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 1) { cocos2d::Image* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithImage(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Texture2D_initWithImage : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_setShaderProgram(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_setShaderProgram : Invalid Native Object"); if (argc == 1) { cocos2d::GLProgram* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Texture2D_setShaderProgram : Error processing arguments"); cobj->setShaderProgram(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_setShaderProgram : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getMaxS(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getMaxS : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMaxS(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getMaxS : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_hasPremultipliedAlpha : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->hasPremultipliedAlpha(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_hasPremultipliedAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_initWithMipmaps(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_initWithMipmaps : Invalid Native Object"); if (argc == 5) { cocos2d::_MipmapInfo* arg0; int arg1; cocos2d::Texture2D::PixelFormat arg2; int arg3; int arg4; #pragma warning NO CONVERSION TO NATIVE FOR _MipmapInfo*; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Texture2D_initWithMipmaps : Error processing arguments"); JSBool ret = cobj->initWithMipmaps(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_initWithMipmaps : wrong number of arguments: %d, was expecting %d", argc, 5); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getPixelsHigh(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getPixelsHigh : Invalid Native Object"); if (argc == 0) { int ret = cobj->getPixelsHigh(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getPixelsHigh : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getBitsPerPixelForFormat(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Texture2D* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getBitsPerPixelForFormat : Invalid Native Object"); do { if (argc == 1) { cocos2d::Texture2D::PixelFormat arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } unsigned int ret = cobj->getBitsPerPixelForFormat(arg0); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { unsigned int ret = cobj->getBitsPerPixelForFormat(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Texture2D_getBitsPerPixelForFormat : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getName : Invalid Native Object"); if (argc == 0) { unsigned int ret = cobj->getName(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_initWithString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Texture2D* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_initWithString : Invalid Native Object"); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::FontDefinition arg1; ok &= jsval_to_FontDefinition(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 4) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg3; ok &= jsval_to_ccsize(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 5) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg3; ok &= jsval_to_ccsize(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 6) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg3; ok &= jsval_to_ccsize(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextVAlignment arg5; ok &= jsval_to_int32(cx, argv[5], (int32_t *)&arg5); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4, arg5); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Texture2D_initWithString : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_setMaxT(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_setMaxT : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Texture2D_setMaxT : Error processing arguments"); cobj->setMaxT(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_setMaxT : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_drawInRect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_drawInRect : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Texture2D_drawInRect : Error processing arguments"); cobj->drawInRect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_drawInRect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getContentSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getContentSize : Invalid Native Object"); if (argc == 0) { cocos2d::Size ret = cobj->getContentSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_setAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_setAliasTexParameters : Invalid Native Object"); if (argc == 0) { cobj->setAliasTexParameters(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_setAliasTexParameters : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_setAntiAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_setAntiAliasTexParameters : Invalid Native Object"); if (argc == 0) { cobj->setAntiAliasTexParameters(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_setAntiAliasTexParameters : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_generateMipmap(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_generateMipmap : Invalid Native Object"); if (argc == 0) { cobj->generateMipmap(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_generateMipmap : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getDescription(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getDescription : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getDescription(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getDescription : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getPixelFormat(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getPixelFormat : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getPixelFormat(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getPixelFormat : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getContentSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getContentSizeInPixels : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getContentSizeInPixels(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getContentSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getPixelsWide(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_getPixelsWide : Invalid Native Object"); if (argc == 0) { int ret = cobj->getPixelsWide(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getPixelsWide : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_drawAtPoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_drawAtPoint : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Texture2D_drawAtPoint : Error processing arguments"); cobj->drawAtPoint(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_drawAtPoint : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_hasMipmaps(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_hasMipmaps : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->hasMipmaps(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_hasMipmaps : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_setMaxS(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Texture2D_setMaxS : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Texture2D_setMaxS : Error processing arguments"); cobj->setMaxS(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_setMaxS : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Texture2D::PixelFormat arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat : Error processing arguments"); cocos2d::Texture2D::setDefaultAlphaPixelFormat(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_getDefaultAlphaPixelFormat(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { int ret = (int)cocos2d::Texture2D::getDefaultAlphaPixelFormat(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_getDefaultAlphaPixelFormat : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha : Error processing arguments"); cocos2d::Texture2D::PVRImagesHavePremultipliedAlpha(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Texture2D_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Texture2D* cobj = new cocos2d::Texture2D(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Texture2D"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Texture2D_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_Texture2D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Texture2D)", obj); } void js_register_cocos2dx_Texture2D(JSContext *cx, JSObject *global) { jsb_cocos2d_Texture2D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Texture2D_class->name = "Texture2D"; jsb_cocos2d_Texture2D_class->addProperty = JS_PropertyStub; jsb_cocos2d_Texture2D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Texture2D_class->getProperty = JS_PropertyStub; jsb_cocos2d_Texture2D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Texture2D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Texture2D_class->resolve = JS_ResolveStub; jsb_cocos2d_Texture2D_class->convert = JS_ConvertStub; jsb_cocos2d_Texture2D_class->finalize = js_cocos2d_Texture2D_finalize; jsb_cocos2d_Texture2D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getShaderProgram", js_cocos2dx_Texture2D_getShaderProgram, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxT", js_cocos2dx_Texture2D_getMaxT, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringForFormat", js_cocos2dx_Texture2D_getStringForFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithImage", js_cocos2dx_Texture2D_initWithImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setShaderProgram", js_cocos2dx_Texture2D_setShaderProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxS", js_cocos2dx_Texture2D_getMaxS, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hasPremultipliedAlpha", js_cocos2dx_Texture2D_hasPremultipliedAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithMipmaps", js_cocos2dx_Texture2D_initWithMipmaps, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPixelsHigh", js_cocos2dx_Texture2D_getPixelsHigh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBitsPerPixelForFormat", js_cocos2dx_Texture2D_getBitsPerPixelForFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_Texture2D_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithString", js_cocos2dx_Texture2D_initWithString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxT", js_cocos2dx_Texture2D_setMaxT, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawInRect", js_cocos2dx_Texture2D_drawInRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentSize", js_cocos2dx_Texture2D_getContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAliasTexParameters", js_cocos2dx_Texture2D_setAliasTexParameters, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAntiAliasTexParameters", js_cocos2dx_Texture2D_setAntiAliasTexParameters, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("generateMipmap", js_cocos2dx_Texture2D_generateMipmap, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDescription", js_cocos2dx_Texture2D_getDescription, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPixelFormat", js_cocos2dx_Texture2D_getPixelFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentSizeInPixels", js_cocos2dx_Texture2D_getContentSizeInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPixelsWide", js_cocos2dx_Texture2D_getPixelsWide, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawAtPoint", js_cocos2dx_Texture2D_drawAtPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hasMipmaps", js_cocos2dx_Texture2D_hasMipmaps, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxS", js_cocos2dx_Texture2D_setMaxS, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("setDefaultAlphaPixelFormat", js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDefaultAlphaPixelFormat", js_cocos2dx_Texture2D_getDefaultAlphaPixelFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("PVRImagesHavePremultipliedAlpha", js_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Texture2D_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Texture2D_class, js_cocos2dx_Texture2D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Texture2D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Texture2D_class; p->proto = jsb_cocos2d_Texture2D_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Node_class; JSObject *jsb_cocos2d_Node_prototype; JSBool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_addChild : Invalid Native Object"); do { if (argc == 2) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cobj->addChild(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj->addChild(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 3) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cobj->addChild(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_addChild : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_removeComponent : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_removeComponent : Error processing arguments"); JSBool ret = cobj->removeComponent(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_removeComponent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setPhysicsBody : Invalid Native Object"); if (argc == 1) { cocos2d::PhysicsBody* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::PhysicsBody*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setPhysicsBody : Error processing arguments"); cobj->setPhysicsBody(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setPhysicsBody : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getShaderProgram(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getShaderProgram : Invalid Native Object"); do { if (argc == 0) { const cocos2d::GLProgram* ret = cobj->getShaderProgram(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GLProgram*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::GLProgram* ret = cobj->getShaderProgram(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GLProgram*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_getShaderProgram : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_getDescription(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getDescription : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getDescription(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getDescription : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setOpacityModifyRGB : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setOpacityModifyRGB : Error processing arguments"); cobj->setOpacityModifyRGB(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setCascadeOpacityEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setCascadeOpacityEnabled : Error processing arguments"); cobj->setCascadeOpacityEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setCascadeOpacityEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getChildren(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getChildren : Invalid Native Object"); do { if (argc == 0) { const cocos2d::Vector& ret = cobj->getChildren(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::Vector& ret = cobj->getChildren(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_getChildren : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_pause(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_pause : Invalid Native Object"); if (argc == 0) { cobj->pause(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_pause : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_convertToWorldSpaceAR(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_convertToWorldSpaceAR : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_convertToWorldSpaceAR : Error processing arguments"); cocos2d::Point ret = cobj->convertToWorldSpaceAR(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_convertToWorldSpaceAR : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_isIgnoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_isIgnoreAnchorPointForPosition : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isIgnoreAnchorPointForPosition(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_isIgnoreAnchorPointForPosition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_updateDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_updateDisplayedOpacity : Invalid Native Object"); if (argc == 1) { uint16_t arg0; ok &= jsval_to_uint16(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_updateDisplayedOpacity : Error processing arguments"); cobj->updateDisplayedOpacity(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_updateDisplayedOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setRotation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setRotation : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setRotation : Error processing arguments"); cobj->setRotation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setRotation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setLocalZOrder : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setLocalZOrder : Error processing arguments"); cobj->setLocalZOrder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setLocalZOrder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setScaleY(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setScaleY : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setScaleY : Error processing arguments"); cobj->setScaleY(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setScaleY : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setScaleX(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setScaleX : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setScaleX : Error processing arguments"); cobj->setScaleX(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setScaleX : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color3B& ret = cobj->getColor(); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_removeAllComponents(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_removeAllComponents : Invalid Native Object"); if (argc == 0) { cobj->removeAllComponents(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_removeAllComponents : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node__setLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node__setLocalZOrder : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node__setLocalZOrder : Error processing arguments"); cobj->_setLocalZOrder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node__setLocalZOrder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getTag(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getTag : Invalid Native Object"); if (argc == 0) { int ret = cobj->getTag(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getTag : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getNodeToWorldAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getNodeToWorldAffineTransform : Invalid Native Object"); if (argc == 0) { cocos2d::AffineTransform ret = cobj->getNodeToWorldAffineTransform(); jsval jsret = JSVAL_NULL; jsret = ccaffinetransform_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getNodeToWorldAffineTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getNodeToWorldTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getNodeToWorldTransform : Invalid Native Object"); if (argc == 0) { kmMat4 ret = cobj->getNodeToWorldTransform(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getNodeToWorldTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_removeChild : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_removeChild : Error processing arguments"); cobj->removeChild(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { cocos2d::Node* arg0; JSBool arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_removeChild : Error processing arguments"); cobj->removeChild(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_removeChild : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_convertToWorldSpace(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_convertToWorldSpace : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_convertToWorldSpace : Error processing arguments"); cocos2d::Point ret = cobj->convertToWorldSpace(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_convertToWorldSpace : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getScene(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getScene : Invalid Native Object"); if (argc == 0) { cocos2d::Scene* ret = cobj->getScene(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getScene : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getEventDispatcher : Invalid Native Object"); if (argc == 0) { cocos2d::EventDispatcher* ret = cobj->getEventDispatcher(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EventDispatcher*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getEventDispatcher : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setSkewX(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setSkewX : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setSkewX : Error processing arguments"); cobj->setSkewX(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setSkewX : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setSkewY(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setSkewY : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setSkewY : Error processing arguments"); cobj->setSkewY(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setSkewY : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getOpacity(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getOpacity : Invalid Native Object"); if (argc == 0) { uint16_t ret = cobj->getOpacity(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_convertTouchToNodeSpace(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_convertTouchToNodeSpace : Invalid Native Object"); if (argc == 1) { cocos2d::Touch* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_convertTouchToNodeSpace : Error processing arguments"); cocos2d::Point ret = cobj->convertTouchToNodeSpace(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_convertTouchToNodeSpace : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_removeAllChildrenWithCleanup : Invalid Native Object"); do { if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->removeAllChildrenWithCleanup(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 0) { cobj->removeAllChildren(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_removeAllChildrenWithCleanup : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_getRotationX(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getRotationX : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRotationX(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getRotationX : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getRotationY(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getRotationY : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRotationY(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getRotationY : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getNodeToParentAffineTransform : Invalid Native Object"); if (argc == 0) { cocos2d::AffineTransform ret = cobj->getNodeToParentAffineTransform(); jsval jsret = JSVAL_NULL; jsret = ccaffinetransform_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getNodeToParentAffineTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_isCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_isCascadeOpacityEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isCascadeOpacityEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_isCascadeOpacityEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setParent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setParent : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setParent : Error processing arguments"); cobj->setParent(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setParent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getNodeToParentTransform : Invalid Native Object"); if (argc == 0) { const kmMat4& ret = cobj->getNodeToParentTransform(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getNodeToParentTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_resume(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_resume : Invalid Native Object"); if (argc == 0) { cobj->resume(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_resume : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getPhysicsBody : Invalid Native Object"); if (argc == 0) { cocos2d::PhysicsBody* ret = cobj->getPhysicsBody(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::PhysicsBody*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getPhysicsBody : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_stopActionByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_stopActionByTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_stopActionByTag : Error processing arguments"); cobj->stopActionByTag(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_stopActionByTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_reorderChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_reorderChild : Invalid Native Object"); if (argc == 2) { cocos2d::Node* arg0; int arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_reorderChild : Error processing arguments"); cobj->reorderChild(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_reorderChild : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_Node_ignoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_ignoreAnchorPointForPosition : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_ignoreAnchorPointForPosition : Error processing arguments"); cobj->ignoreAnchorPointForPosition(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_ignoreAnchorPointForPosition : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setColor : Error processing arguments"); cobj->setColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setPositionY(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setPositionY : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setPositionY : Error processing arguments"); cobj->setPositionY(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setPositionY : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setPositionX(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setPositionX : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setPositionX : Error processing arguments"); cobj->setPositionX(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setPositionX : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setNodeToParentTransform : Invalid Native Object"); if (argc == 1) { kmMat4 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmMat4; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setNodeToParentTransform : Error processing arguments"); cobj->setNodeToParentTransform(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setNodeToParentTransform : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getAnchorPoint : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getAnchorPoint(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getNumberOfRunningActions(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getNumberOfRunningActions : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getNumberOfRunningActions(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getNumberOfRunningActions : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_updateTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_updateTransform : Invalid Native Object"); if (argc == 0) { cobj->updateTransform(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_updateTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_isVisible(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_isVisible : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isVisible(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_isVisible : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getChildrenCount(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getChildrenCount : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getChildrenCount(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getChildrenCount : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_convertToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_convertToNodeSpaceAR : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_convertToNodeSpaceAR : Error processing arguments"); cocos2d::Point ret = cobj->convertToNodeSpaceAR(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_convertToNodeSpaceAR : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_addComponent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_addComponent : Invalid Native Object"); if (argc == 1) { cocos2d::Component* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Component*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_addComponent : Error processing arguments"); JSBool ret = cobj->addComponent(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_addComponent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_visit(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_visit : Invalid Native Object"); if (argc == 0) { cobj->visit(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_visit : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setShaderProgram(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setShaderProgram : Invalid Native Object"); if (argc == 1) { cocos2d::GLProgram* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setShaderProgram : Error processing arguments"); cobj->setShaderProgram(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setShaderProgram : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getRotation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getRotation : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRotation(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getRotation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getLocalZOrder : Invalid Native Object"); if (argc == 0) { int ret = cobj->getLocalZOrder(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getLocalZOrder : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getAnchorPointInPoints(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getAnchorPointInPoints : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getAnchorPointInPoints(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getAnchorPointInPoints : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_runAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_runAction : Invalid Native Object"); if (argc == 1) { cocos2d::Action* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_runAction : Error processing arguments"); cocos2d::Action* ret = cobj->runAction(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_runAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_transform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_transform : Invalid Native Object"); if (argc == 0) { cobj->transform(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_transform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setVertexZ(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setVertexZ : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setVertexZ : Error processing arguments"); cobj->setVertexZ(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setVertexZ : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setScheduler : Invalid Native Object"); if (argc == 1) { cocos2d::Scheduler* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scheduler*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setScheduler : Error processing arguments"); cobj->setScheduler(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setScheduler : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_stopAllActions(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_stopAllActions : Invalid Native Object"); if (argc == 0) { cobj->stopAllActions(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_stopAllActions : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getSkewX(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getSkewX : Invalid Native Object"); if (argc == 0) { double ret = cobj->getSkewX(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getSkewX : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getSkewY(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getSkewY : Invalid Native Object"); if (argc == 0) { double ret = cobj->getSkewY(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getSkewY : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getDisplayedColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getDisplayedColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color3B& ret = cobj->getDisplayedColor(); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getDisplayedColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getActionByTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_getActionByTag : Error processing arguments"); cocos2d::Action* ret = cobj->getActionByTag(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getActionByTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setRotationX(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setRotationX : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setRotationX : Error processing arguments"); cobj->setRotationX(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setRotationX : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setRotationY(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setRotationY : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setRotationY : Error processing arguments"); cobj->setRotationY(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setRotationY : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setAdditionalTransform(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setAdditionalTransform : Invalid Native Object"); do { if (argc == 1) { kmMat4 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmMat4; if (!ok) { ok = JS_TRUE; break; } cobj->setAdditionalTransform(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { cocos2d::AffineTransform arg0; ok &= jsval_to_ccaffinetransform(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setAdditionalTransform(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_setAdditionalTransform : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_getDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getDisplayedOpacity : Invalid Native Object"); if (argc == 0) { uint16_t ret = cobj->getDisplayedOpacity(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getDisplayedOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getScheduler(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getScheduler : Invalid Native Object"); do { if (argc == 0) { const cocos2d::Scheduler* ret = cobj->getScheduler(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Scheduler*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::Scheduler* ret = cobj->getScheduler(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Scheduler*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_getScheduler : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_getParentToNodeAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getParentToNodeAffineTransform : Invalid Native Object"); if (argc == 0) { cocos2d::AffineTransform ret = cobj->getParentToNodeAffineTransform(); jsval jsret = JSVAL_NULL; jsret = ccaffinetransform_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getParentToNodeAffineTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getOrderOfArrival(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getOrderOfArrival : Invalid Native Object"); if (argc == 0) { int ret = cobj->getOrderOfArrival(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getOrderOfArrival : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setActionManager(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setActionManager : Invalid Native Object"); if (argc == 1) { cocos2d::ActionManager* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionManager*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setActionManager : Error processing arguments"); cobj->setActionManager(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setActionManager : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getPosition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getPosition : Invalid Native Object"); do { if (argc == 2) { float* arg0; #pragma warning NO CONVERSION TO NATIVE FOR float*; if (!ok) { ok = JS_TRUE; break; } float* arg1; #pragma warning NO CONVERSION TO NATIVE FOR float*; if (!ok) { ok = JS_TRUE; break; } cobj->getPosition(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::Point& ret = cobj->getPosition(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_getPosition : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_isRunning(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_isRunning : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isRunning(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_isRunning : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getParent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getParent : Invalid Native Object"); do { if (argc == 0) { const cocos2d::Node* ret = cobj->getParent(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::Node* ret = cobj->getParent(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_getParent : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_getPositionY(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getPositionY : Invalid Native Object"); if (argc == 0) { double ret = cobj->getPositionY(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getPositionY : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getPositionX(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getPositionX : Invalid Native Object"); if (argc == 0) { double ret = cobj->getPositionX(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getPositionX : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_removeChildByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_removeChildByTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_removeChildByTag : Error processing arguments"); cobj->removeChildByTag(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { int arg0; JSBool arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_removeChildByTag : Error processing arguments"); cobj->removeChildByTag(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_removeChildByTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_updateDisplayedColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_updateDisplayedColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_updateDisplayedColor : Error processing arguments"); cobj->updateDisplayedColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_updateDisplayedColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setVisible(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setVisible : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setVisible : Error processing arguments"); cobj->setVisible(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setVisible : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getParentToNodeTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getParentToNodeTransform : Invalid Native Object"); if (argc == 0) { const kmMat4& ret = cobj->getParentToNodeTransform(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getParentToNodeTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getVertexZ(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getVertexZ : Invalid Native Object"); if (argc == 0) { double ret = cobj->getVertexZ(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getVertexZ : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setGlobalZOrder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setGlobalZOrder : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setGlobalZOrder : Error processing arguments"); cobj->setGlobalZOrder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setGlobalZOrder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setScale(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setScale : Invalid Native Object"); do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj->setScale(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setScale(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_setScale : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_getChildByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getChildByTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_getChildByTag : Error processing arguments"); cocos2d::Node* ret = cobj->getChildByTag(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getChildByTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setOrderOfArrival(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setOrderOfArrival : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setOrderOfArrival : Error processing arguments"); cobj->setOrderOfArrival(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setOrderOfArrival : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getScaleY(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getScaleY : Invalid Native Object"); if (argc == 0) { double ret = cobj->getScaleY(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getScaleY : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getScaleX(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getScaleX : Invalid Native Object"); if (argc == 0) { double ret = cobj->getScaleX(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getScaleX : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getWorldToNodeAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getWorldToNodeAffineTransform : Invalid Native Object"); if (argc == 0) { cocos2d::AffineTransform ret = cobj->getWorldToNodeAffineTransform(); jsval jsret = JSVAL_NULL; jsret = ccaffinetransform_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getWorldToNodeAffineTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setCascadeColorEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setCascadeColorEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setCascadeColorEnabled : Error processing arguments"); cobj->setCascadeColorEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setCascadeColorEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setOpacity(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setOpacity : Invalid Native Object"); if (argc == 1) { uint16_t arg0; ok &= jsval_to_uint16(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setOpacity : Error processing arguments"); cobj->setOpacity(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_cleanup(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_cleanup : Invalid Native Object"); if (argc == 0) { cobj->cleanup(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_cleanup : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getComponent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getComponent : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_getComponent : Error processing arguments"); cocos2d::Component* ret = cobj->getComponent(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getComponent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getContentSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getContentSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getContentSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getBoundingBox : Invalid Native Object"); if (argc == 0) { cocos2d::Rect ret = cobj->getBoundingBox(); jsval jsret = JSVAL_NULL; jsret = ccrect_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getBoundingBox : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_updatePhysicsTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_updatePhysicsTransform : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->updatePhysicsTransform(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_updatePhysicsTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setEventDispatcher : Invalid Native Object"); if (argc == 1) { cocos2d::EventDispatcher* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EventDispatcher*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setEventDispatcher : Error processing arguments"); cobj->setEventDispatcher(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setEventDispatcher : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getGlobalZOrder(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getGlobalZOrder : Invalid Native Object"); if (argc == 0) { double ret = cobj->getGlobalZOrder(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getGlobalZOrder : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_draw(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_draw : Invalid Native Object"); if (argc == 0) { cobj->draw(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_draw : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_transformAncestors(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_transformAncestors : Invalid Native Object"); if (argc == 0) { cobj->transformAncestors(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_transformAncestors : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_setUserObject(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setUserObject : Invalid Native Object"); if (argc == 1) { cocos2d::Object* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setUserObject : Error processing arguments"); cobj->setUserObject(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setUserObject : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_removeFromParentAndCleanup(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_removeFromParentAndCleanup : Invalid Native Object"); do { if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->removeFromParentAndCleanup(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 0) { cobj->removeFromParent(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_removeFromParentAndCleanup : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_convertTouchToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_convertTouchToNodeSpaceAR : Invalid Native Object"); if (argc == 1) { cocos2d::Touch* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_convertTouchToNodeSpaceAR : Error processing arguments"); cocos2d::Point ret = cobj->convertTouchToNodeSpaceAR(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_convertTouchToNodeSpaceAR : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_update(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_update : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_update : Error processing arguments"); cobj->update(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_update : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_sortAllChildren(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_sortAllChildren : Invalid Native Object"); if (argc == 0) { cobj->sortAllChildren(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_sortAllChildren : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getWorldToNodeTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getWorldToNodeTransform : Invalid Native Object"); if (argc == 0) { kmMat4 ret = cobj->getWorldToNodeTransform(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getWorldToNodeTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_getScale(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getScale : Invalid Native Object"); if (argc == 0) { double ret = cobj->getScale(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_getScale : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_convertToNodeSpace(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_convertToNodeSpace : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_convertToNodeSpace : Error processing arguments"); cocos2d::Point ret = cobj->convertToNodeSpace(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_convertToNodeSpace : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_setTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_setTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_setTag : Error processing arguments"); cobj->setTag(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_setTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_isCascadeColorEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_isCascadeColorEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isCascadeColorEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_isCascadeColorEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_isOpacityModifyRGB : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isOpacityModifyRGB(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_isOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Node_stopAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_stopAction : Invalid Native Object"); if (argc == 1) { cocos2d::Action* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Node_stopAction : Error processing arguments"); cobj->stopAction(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_stopAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Node_getActionManager(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Node* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Node_getActionManager : Invalid Native Object"); do { if (argc == 0) { const cocos2d::ActionManager* ret = cobj->getActionManager(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionManager*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::ActionManager* ret = cobj->getActionManager(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionManager*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Node_getActionManager : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Node_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Node* ret = cocos2d::Node::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Node_create : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_Node_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Node)", obj); } static JSBool js_cocos2d_Node_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::Node *nobj = cocos2d::Node::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Node"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_Node(JSContext *cx, JSObject *global) { jsb_cocos2d_Node_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Node_class->name = "Node"; jsb_cocos2d_Node_class->addProperty = JS_PropertyStub; jsb_cocos2d_Node_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Node_class->getProperty = JS_PropertyStub; jsb_cocos2d_Node_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Node_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Node_class->resolve = JS_ResolveStub; jsb_cocos2d_Node_class->convert = JS_ConvertStub; jsb_cocos2d_Node_class->finalize = js_cocos2d_Node_finalize; jsb_cocos2d_Node_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("addChild", js_cocos2dx_Node_addChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeComponent", js_cocos2dx_Node_removeComponent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPhysicsBody", js_cocos2dx_Node_setPhysicsBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getShaderProgram", js_cocos2dx_Node_getShaderProgram, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDescription", js_cocos2dx_Node_getDescription, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOpacityModifyRGB", js_cocos2dx_Node_setOpacityModifyRGB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCascadeOpacityEnabled", js_cocos2dx_Node_setCascadeOpacityEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getChildren", js_cocos2dx_Node_getChildren, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pause", js_cocos2dx_Node_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertToWorldSpaceAR", js_cocos2dx_Node_convertToWorldSpaceAR, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isIgnoreAnchorPointForPosition", js_cocos2dx_Node_isIgnoreAnchorPointForPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateDisplayedOpacity", js_cocos2dx_Node_updateDisplayedOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotation", js_cocos2dx_Node_setRotation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setZOrder", js_cocos2dx_Node_setLocalZOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScaleY", js_cocos2dx_Node_setScaleY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScaleX", js_cocos2dx_Node_setScaleX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getColor", js_cocos2dx_Node_getColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllComponents", js_cocos2dx_Node_removeAllComponents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("_setLocalZOrder", js_cocos2dx_Node__setLocalZOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTag", js_cocos2dx_Node_getTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeToWorldAffineTransform", js_cocos2dx_Node_getNodeToWorldAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeToWorldTransform", js_cocos2dx_Node_getNodeToWorldTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeChild", js_cocos2dx_Node_removeChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertToWorldSpace", js_cocos2dx_Node_convertToWorldSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScene", js_cocos2dx_Node_getScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEventDispatcher", js_cocos2dx_Node_getEventDispatcher, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSkewX", js_cocos2dx_Node_setSkewX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSkewY", js_cocos2dx_Node_setSkewY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOpacity", js_cocos2dx_Node_getOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertTouchToNodeSpace", js_cocos2dx_Node_convertTouchToNodeSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllChildren", js_cocos2dx_Node_removeAllChildrenWithCleanup, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRotationX", js_cocos2dx_Node_getRotationX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRotationY", js_cocos2dx_Node_getRotationY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeToParentAffineTransform", js_cocos2dx_Node_getNodeToParentAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isCascadeOpacityEnabled", js_cocos2dx_Node_isCascadeOpacityEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setParent", js_cocos2dx_Node_setParent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeToParentTransform", js_cocos2dx_Node_getNodeToParentTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resume", js_cocos2dx_Node_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPhysicsBody", js_cocos2dx_Node_getPhysicsBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopActionByTag", js_cocos2dx_Node_stopActionByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reorderChild", js_cocos2dx_Node_reorderChild, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ignoreAnchorPointForPosition", js_cocos2dx_Node_ignoreAnchorPointForPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setColor", js_cocos2dx_Node_setColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPositionY", js_cocos2dx_Node_setPositionY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPositionX", js_cocos2dx_Node_setPositionX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setNodeToParentTransform", js_cocos2dx_Node_setNodeToParentTransform, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnchorPoint", js_cocos2dx_Node_getAnchorPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNumberOfRunningActions", js_cocos2dx_Node_getNumberOfRunningActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateTransform", js_cocos2dx_Node_updateTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isVisible", js_cocos2dx_Node_isVisible, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getChildrenCount", js_cocos2dx_Node_getChildrenCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertToNodeSpaceAR", js_cocos2dx_Node_convertToNodeSpaceAR, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addComponent", js_cocos2dx_Node_addComponent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("visit", js_cocos2dx_Node_visit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setShaderProgram", js_cocos2dx_Node_setShaderProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRotation", js_cocos2dx_Node_getRotation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZOrder", js_cocos2dx_Node_getLocalZOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnchorPointInPoints", js_cocos2dx_Node_getAnchorPointInPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("runAction", js_cocos2dx_Node_runAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("transform", js_cocos2dx_Node_transform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVertexZ", js_cocos2dx_Node_setVertexZ, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScheduler", js_cocos2dx_Node_setScheduler, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopAllActions", js_cocos2dx_Node_stopAllActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSkewX", js_cocos2dx_Node_getSkewX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSkewY", js_cocos2dx_Node_getSkewY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisplayedColor", js_cocos2dx_Node_getDisplayedColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActionByTag", js_cocos2dx_Node_getActionByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotationX", js_cocos2dx_Node_setRotationX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotationY", js_cocos2dx_Node_setRotationY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAdditionalTransform", js_cocos2dx_Node_setAdditionalTransform, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisplayedOpacity", js_cocos2dx_Node_getDisplayedOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScheduler", js_cocos2dx_Node_getScheduler, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParentToNodeAffineTransform", js_cocos2dx_Node_getParentToNodeAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOrderOfArrival", js_cocos2dx_Node_getOrderOfArrival, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setActionManager", js_cocos2dx_Node_setActionManager, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPosition", js_cocos2dx_Node_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isRunning", js_cocos2dx_Node_isRunning, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParent", js_cocos2dx_Node_getParent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionY", js_cocos2dx_Node_getPositionY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionX", js_cocos2dx_Node_getPositionX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeChildByTag", js_cocos2dx_Node_removeChildByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateDisplayedColor", js_cocos2dx_Node_updateDisplayedColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVisible", js_cocos2dx_Node_setVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParentToNodeTransform", js_cocos2dx_Node_getParentToNodeTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVertexZ", js_cocos2dx_Node_getVertexZ, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGlobalZOrder", js_cocos2dx_Node_setGlobalZOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale", js_cocos2dx_Node_setScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getChildByTag", js_cocos2dx_Node_getChildByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOrderOfArrival", js_cocos2dx_Node_setOrderOfArrival, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScaleY", js_cocos2dx_Node_getScaleY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScaleX", js_cocos2dx_Node_getScaleX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWorldToNodeAffineTransform", js_cocos2dx_Node_getWorldToNodeAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCascadeColorEnabled", js_cocos2dx_Node_setCascadeColorEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOpacity", js_cocos2dx_Node_setOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("cleanup", js_cocos2dx_Node_cleanup, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getComponent", js_cocos2dx_Node_getComponent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentSize", js_cocos2dx_Node_getContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBoundingBox", js_cocos2dx_Node_getBoundingBox, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updatePhysicsTransform", js_cocos2dx_Node_updatePhysicsTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEventDispatcher", js_cocos2dx_Node_setEventDispatcher, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGlobalZOrder", js_cocos2dx_Node_getGlobalZOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("draw", js_cocos2dx_Node_draw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("transformAncestors", js_cocos2dx_Node_transformAncestors, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUserObject", js_cocos2dx_Node_setUserObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeFromParent", js_cocos2dx_Node_removeFromParentAndCleanup, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertTouchToNodeSpaceAR", js_cocos2dx_Node_convertTouchToNodeSpaceAR, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", js_cocos2dx_Node_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("sortAllChildren", js_cocos2dx_Node_sortAllChildren, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWorldToNodeTransform", js_cocos2dx_Node_getWorldToNodeTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScale", js_cocos2dx_Node_getScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertToNodeSpace", js_cocos2dx_Node_convertToNodeSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTag", js_cocos2dx_Node_setTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isCascadeColorEnabled", js_cocos2dx_Node_isCascadeColorEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isOpacityModifyRGB", js_cocos2dx_Node_isOpacityModifyRGB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopAction", js_cocos2dx_Node_stopAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActionManager", js_cocos2dx_Node_getActionManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_Node_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Node_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Node_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Node_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Node", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Node_class; p->proto = jsb_cocos2d_Node_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d___NodeRGBA_class; JSObject *jsb_cocos2d___NodeRGBA_prototype; extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d___NodeRGBA_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (__NodeRGBA)", obj); } void js_register_cocos2dx___NodeRGBA(JSContext *cx, JSObject *global) { jsb_cocos2d___NodeRGBA_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d___NodeRGBA_class->name = "NodeRGBA"; jsb_cocos2d___NodeRGBA_class->addProperty = JS_PropertyStub; jsb_cocos2d___NodeRGBA_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d___NodeRGBA_class->getProperty = JS_PropertyStub; jsb_cocos2d___NodeRGBA_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d___NodeRGBA_class->enumerate = JS_EnumerateStub; jsb_cocos2d___NodeRGBA_class->resolve = JS_ResolveStub; jsb_cocos2d___NodeRGBA_class->convert = JS_ConvertStub; jsb_cocos2d___NodeRGBA_class->finalize = js_cocos2d___NodeRGBA_finalize; jsb_cocos2d___NodeRGBA_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d___NodeRGBA_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d___NodeRGBA_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "NodeRGBA", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d___NodeRGBA_class; p->proto = jsb_cocos2d___NodeRGBA_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_SpriteFrame_class; JSObject *jsb_cocos2d_SpriteFrame_prototype; JSBool js_cocos2dx_SpriteFrame_clone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_clone : Invalid Native Object"); if (argc == 0) { cocos2d::SpriteFrame* ret = cobj->clone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_clone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_setRotated(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setRotated : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setRotated : Error processing arguments"); cobj->setRotated(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setRotated : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_setTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setTexture : Invalid Native Object"); if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setTexture : Error processing arguments"); cobj->setTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::SpriteFrame* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_initWithTexture : Invalid Native Object"); do { if (argc == 5) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg3; ok &= jsval_to_ccpoint(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg4; ok &= jsval_to_ccsize(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithTexture(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithTexture(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_SpriteFrame_initWithTexture : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_setRectInPixels(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setRectInPixels : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setRectInPixels : Error processing arguments"); cobj->setRectInPixels(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setRectInPixels : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_getTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_getTexture : Invalid Native Object"); if (argc == 0) { cocos2d::Texture2D* ret = cobj->getTexture(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_getRect(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_getRect : Invalid Native Object"); if (argc == 0) { const cocos2d::Rect& ret = cobj->getRect(); jsval jsret = JSVAL_NULL; jsret = ccrect_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getRect : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_setOffsetInPixels(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setOffsetInPixels : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setOffsetInPixels : Error processing arguments"); cobj->setOffsetInPixels(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setOffsetInPixels : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_getRectInPixels(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_getRectInPixels : Invalid Native Object"); if (argc == 0) { const cocos2d::Rect& ret = cobj->getRectInPixels(); jsval jsret = JSVAL_NULL; jsret = ccrect_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getRectInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_setOriginalSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setOriginalSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setOriginalSize : Error processing arguments"); cobj->setOriginalSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setOriginalSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_getOriginalSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_getOriginalSizeInPixels : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getOriginalSizeInPixels(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getOriginalSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_setOriginalSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setOriginalSizeInPixels : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setOriginalSizeInPixels : Error processing arguments"); cobj->setOriginalSizeInPixels(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setOriginalSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_setOffset(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setOffset : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setOffset : Error processing arguments"); cobj->setOffset(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setOffset : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_getOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_getOffset : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getOffset(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getOffset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_isRotated(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_isRotated : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isRotated(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_isRotated : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_initWithTextureFilename(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::SpriteFrame* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_initWithTextureFilename : Invalid Native Object"); do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg3; ok &= jsval_to_ccpoint(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg4; ok &= jsval_to_ccsize(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithTextureFilename(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithTextureFilename(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_SpriteFrame_initWithTextureFilename : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_setRect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setRect : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_setRect : Error processing arguments"); cobj->setRect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setRect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_getOffsetInPixels(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_getOffsetInPixels : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getOffsetInPixels(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getOffsetInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrame_getOriginalSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getOriginalSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getOriginalSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg3; ok &= jsval_to_ccpoint(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg4; ok &= jsval_to_ccsize(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::create(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_SpriteFrame_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrame_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 5) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg3; ok &= jsval_to_ccpoint(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg4; ok &= jsval_to_ccsize(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::createWithTexture(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::createWithTexture(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_SpriteFrame_createWithTexture : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_SpriteFrame_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SpriteFrame)", obj); } void js_register_cocos2dx_SpriteFrame(JSContext *cx, JSObject *global) { jsb_cocos2d_SpriteFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SpriteFrame_class->name = "SpriteFrame"; jsb_cocos2d_SpriteFrame_class->addProperty = JS_PropertyStub; jsb_cocos2d_SpriteFrame_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_SpriteFrame_class->getProperty = JS_PropertyStub; jsb_cocos2d_SpriteFrame_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_SpriteFrame_class->enumerate = JS_EnumerateStub; jsb_cocos2d_SpriteFrame_class->resolve = JS_ResolveStub; jsb_cocos2d_SpriteFrame_class->convert = JS_ConvertStub; jsb_cocos2d_SpriteFrame_class->finalize = js_cocos2d_SpriteFrame_finalize; jsb_cocos2d_SpriteFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("clone", js_cocos2dx_SpriteFrame_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotated", js_cocos2dx_SpriteFrame_setRotated, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTexture", js_cocos2dx_SpriteFrame_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTexture", js_cocos2dx_SpriteFrame_initWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRectInPixels", js_cocos2dx_SpriteFrame_setRectInPixels, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTexture", js_cocos2dx_SpriteFrame_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRect", js_cocos2dx_SpriteFrame_getRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOffsetInPixels", js_cocos2dx_SpriteFrame_setOffsetInPixels, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRectInPixels", js_cocos2dx_SpriteFrame_getRectInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOriginalSize", js_cocos2dx_SpriteFrame_setOriginalSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOriginalSizeInPixels", js_cocos2dx_SpriteFrame_getOriginalSizeInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOriginalSizeInPixels", js_cocos2dx_SpriteFrame_setOriginalSizeInPixels, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOffset", js_cocos2dx_SpriteFrame_setOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOffset", js_cocos2dx_SpriteFrame_getOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isRotated", js_cocos2dx_SpriteFrame_isRotated, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTextureFilename", js_cocos2dx_SpriteFrame_initWithTextureFilename, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRect", js_cocos2dx_SpriteFrame_setRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOffsetInPixels", js_cocos2dx_SpriteFrame_getOffsetInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOriginalSize", js_cocos2dx_SpriteFrame_getOriginalSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_SpriteFrame_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTexture", js_cocos2dx_SpriteFrame_createWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_SpriteFrame_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_SpriteFrame_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SpriteFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_SpriteFrame_class; p->proto = jsb_cocos2d_SpriteFrame_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_AnimationFrame_class; JSObject *jsb_cocos2d_AnimationFrame_prototype; JSBool js_cocos2dx_AnimationFrame_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_setSpriteFrame : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_setSpriteFrame : Error processing arguments"); cobj->setSpriteFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationFrame_setSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AnimationFrame_getUserInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::AnimationFrame* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_getUserInfo : Invalid Native Object"); do { if (argc == 0) { cocos2d::ValueMap& ret = cobj->getUserInfo(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::ValueMap& ret = cobj->getUserInfo(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_AnimationFrame_getUserInfo : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_AnimationFrame_setDelayUnits(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_setDelayUnits : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_setDelayUnits : Error processing arguments"); cobj->setDelayUnits(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationFrame_setDelayUnits : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AnimationFrame_clone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_clone : Invalid Native Object"); if (argc == 0) { cocos2d::AnimationFrame* ret = cobj->clone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::AnimationFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationFrame_clone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_AnimationFrame_getSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_getSpriteFrame : Invalid Native Object"); if (argc == 0) { cocos2d::SpriteFrame* ret = cobj->getSpriteFrame(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationFrame_getSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_AnimationFrame_getDelayUnits(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_getDelayUnits : Invalid Native Object"); if (argc == 0) { double ret = cobj->getDelayUnits(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationFrame_getDelayUnits : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_AnimationFrame_setUserInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_setUserInfo : Invalid Native Object"); if (argc == 1) { cocos2d::ValueMap arg0; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_setUserInfo : Error processing arguments"); cobj->setUserInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationFrame_setUserInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AnimationFrame_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { cocos2d::SpriteFrame* arg0; double arg1; cocos2d::ValueMap arg2; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= jsval_to_ccvaluemap(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationFrame_create : Error processing arguments"); cocos2d::AnimationFrame* ret = cocos2d::AnimationFrame::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::AnimationFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationFrame_create : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_AnimationFrame_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (AnimationFrame)", obj); } void js_register_cocos2dx_AnimationFrame(JSContext *cx, JSObject *global) { jsb_cocos2d_AnimationFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_AnimationFrame_class->name = "AnimationFrame"; jsb_cocos2d_AnimationFrame_class->addProperty = JS_PropertyStub; jsb_cocos2d_AnimationFrame_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_AnimationFrame_class->getProperty = JS_PropertyStub; jsb_cocos2d_AnimationFrame_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_AnimationFrame_class->enumerate = JS_EnumerateStub; jsb_cocos2d_AnimationFrame_class->resolve = JS_ResolveStub; jsb_cocos2d_AnimationFrame_class->convert = JS_ConvertStub; jsb_cocos2d_AnimationFrame_class->finalize = js_cocos2d_AnimationFrame_finalize; jsb_cocos2d_AnimationFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setSpriteFrame", js_cocos2dx_AnimationFrame_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUserInfo", js_cocos2dx_AnimationFrame_getUserInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDelayUnits", js_cocos2dx_AnimationFrame_setDelayUnits, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clone", js_cocos2dx_AnimationFrame_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpriteFrame", js_cocos2dx_AnimationFrame_getSpriteFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDelayUnits", js_cocos2dx_AnimationFrame_getDelayUnits, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUserInfo", js_cocos2dx_AnimationFrame_setUserInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_AnimationFrame_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_AnimationFrame_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_AnimationFrame_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "AnimationFrame", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_AnimationFrame_class; p->proto = jsb_cocos2d_AnimationFrame_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Animation_class; JSObject *jsb_cocos2d_Animation_prototype; JSBool js_cocos2dx_Animation_getLoops(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_getLoops : Invalid Native Object"); if (argc == 0) { unsigned int ret = cobj->getLoops(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_getLoops : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Animation_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_addSpriteFrame : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animation_addSpriteFrame : Error processing arguments"); cobj->addSpriteFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_addSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Animation_setRestoreOriginalFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_setRestoreOriginalFrame : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animation_setRestoreOriginalFrame : Error processing arguments"); cobj->setRestoreOriginalFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_setRestoreOriginalFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Animation_clone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_clone : Invalid Native Object"); if (argc == 0) { cocos2d::Animation* ret = cobj->clone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_clone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Animation_getDuration(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_getDuration : Invalid Native Object"); if (argc == 0) { double ret = cobj->getDuration(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Animation_setFrames(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_setFrames : Invalid Native Object"); if (argc == 1) { cocos2d::Vector arg0; ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animation_setFrames : Error processing arguments"); cobj->setFrames(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_setFrames : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Animation_getFrames(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_getFrames : Invalid Native Object"); if (argc == 0) { const cocos2d::Vector& ret = cobj->getFrames(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_getFrames : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Animation_setLoops(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_setLoops : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animation_setLoops : Error processing arguments"); cobj->setLoops(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_setLoops : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Animation_setDelayPerUnit(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_setDelayPerUnit : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animation_setDelayPerUnit : Error processing arguments"); cobj->setDelayPerUnit(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_setDelayPerUnit : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Animation_addSpriteFrameWithFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_addSpriteFrameWithFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animation_addSpriteFrameWithFile : Error processing arguments"); cobj->addSpriteFrameWithFile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_addSpriteFrameWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Animation_getTotalDelayUnits(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_getTotalDelayUnits : Invalid Native Object"); if (argc == 0) { double ret = cobj->getTotalDelayUnits(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_getTotalDelayUnits : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Animation_getDelayPerUnit(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_getDelayPerUnit : Invalid Native Object"); if (argc == 0) { double ret = cobj->getDelayPerUnit(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_getDelayPerUnit : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Animation_getRestoreOriginalFrame(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_getRestoreOriginalFrame : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getRestoreOriginalFrame(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_getRestoreOriginalFrame : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Animation_addSpriteFrameWithTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animation_addSpriteFrameWithTexture : Invalid Native Object"); if (argc == 2) { cocos2d::Texture2D* arg0; cocos2d::Rect arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccrect(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animation_addSpriteFrameWithTexture : Error processing arguments"); cobj->addSpriteFrameWithTexture(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animation_addSpriteFrameWithTexture : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } void js_cocos2d_Animation_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Animation)", obj); } void js_register_cocos2dx_Animation(JSContext *cx, JSObject *global) { jsb_cocos2d_Animation_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Animation_class->name = "Animation"; jsb_cocos2d_Animation_class->addProperty = JS_PropertyStub; jsb_cocos2d_Animation_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Animation_class->getProperty = JS_PropertyStub; jsb_cocos2d_Animation_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Animation_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Animation_class->resolve = JS_ResolveStub; jsb_cocos2d_Animation_class->convert = JS_ConvertStub; jsb_cocos2d_Animation_class->finalize = js_cocos2d_Animation_finalize; jsb_cocos2d_Animation_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getLoops", js_cocos2dx_Animation_getLoops, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSpriteFrame", js_cocos2dx_Animation_addSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRestoreOriginalFrame", js_cocos2dx_Animation_setRestoreOriginalFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clone", js_cocos2dx_Animation_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDuration", js_cocos2dx_Animation_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFrames", js_cocos2dx_Animation_setFrames, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFrames", js_cocos2dx_Animation_getFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLoops", js_cocos2dx_Animation_setLoops, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDelayPerUnit", js_cocos2dx_Animation_setDelayPerUnit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSpriteFrameWithFile", js_cocos2dx_Animation_addSpriteFrameWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTotalDelayUnits", js_cocos2dx_Animation_getTotalDelayUnits, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDelayPerUnit", js_cocos2dx_Animation_getDelayPerUnit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRestoreOriginalFrame", js_cocos2dx_Animation_getRestoreOriginalFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSpriteFrameWithTexture", js_cocos2dx_Animation_addSpriteFrameWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Animation_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Animation_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Animation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Animation_class; p->proto = jsb_cocos2d_Animation_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ActionInterval_class; JSObject *jsb_cocos2d_ActionInterval_prototype; JSBool js_cocos2dx_ActionInterval_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionInterval_getAmplitudeRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitudeRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionInterval_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ActionInterval_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionInterval_setAmplitudeRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionInterval_setAmplitudeRate : Error processing arguments"); cobj->setAmplitudeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionInterval_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionInterval_getElapsed(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionInterval_getElapsed : Invalid Native Object"); if (argc == 0) { double ret = cobj->getElapsed(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionInterval_getElapsed : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_FiniteTimeAction_prototype; void js_cocos2d_ActionInterval_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ActionInterval)", obj); } void js_register_cocos2dx_ActionInterval(JSContext *cx, JSObject *global) { jsb_cocos2d_ActionInterval_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ActionInterval_class->name = "ActionInterval"; jsb_cocos2d_ActionInterval_class->addProperty = JS_PropertyStub; jsb_cocos2d_ActionInterval_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ActionInterval_class->getProperty = JS_PropertyStub; jsb_cocos2d_ActionInterval_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ActionInterval_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ActionInterval_class->resolve = JS_ResolveStub; jsb_cocos2d_ActionInterval_class->convert = JS_ConvertStub; jsb_cocos2d_ActionInterval_class->finalize = js_cocos2d_ActionInterval_finalize; jsb_cocos2d_ActionInterval_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAmplitudeRate", js_cocos2dx_ActionInterval_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitudeRate", js_cocos2dx_ActionInterval_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getElapsed", js_cocos2dx_ActionInterval_getElapsed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_ActionInterval_prototype = JS_InitClass( cx, global, jsb_cocos2d_FiniteTimeAction_prototype, jsb_cocos2d_ActionInterval_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ActionInterval", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ActionInterval_class; p->proto = jsb_cocos2d_ActionInterval_prototype; p->parentProto = jsb_cocos2d_FiniteTimeAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Sequence_class; JSObject *jsb_cocos2d_Sequence_prototype; extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Sequence_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Sequence)", obj); } void js_register_cocos2dx_Sequence(JSContext *cx, JSObject *global) { jsb_cocos2d_Sequence_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Sequence_class->name = "Sequence"; jsb_cocos2d_Sequence_class->addProperty = JS_PropertyStub; jsb_cocos2d_Sequence_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Sequence_class->getProperty = JS_PropertyStub; jsb_cocos2d_Sequence_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Sequence_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Sequence_class->resolve = JS_ResolveStub; jsb_cocos2d_Sequence_class->convert = JS_ConvertStub; jsb_cocos2d_Sequence_class->finalize = js_cocos2d_Sequence_finalize; jsb_cocos2d_Sequence_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Sequence_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_Sequence_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Sequence", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Sequence_class; p->proto = jsb_cocos2d_Sequence_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Repeat_class; JSObject *jsb_cocos2d_Repeat_prototype; JSBool js_cocos2dx_Repeat_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Repeat* cobj = (cocos2d::Repeat *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Repeat_setInnerAction : Invalid Native Object"); if (argc == 1) { cocos2d::FiniteTimeAction* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Repeat_setInnerAction : Error processing arguments"); cobj->setInnerAction(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Repeat_setInnerAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Repeat_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Repeat* cobj = (cocos2d::Repeat *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Repeat_getInnerAction : Invalid Native Object"); if (argc == 0) { cocos2d::FiniteTimeAction* ret = cobj->getInnerAction(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FiniteTimeAction*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Repeat_getInnerAction : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Repeat_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::FiniteTimeAction* arg0; unsigned int arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_uint32(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Repeat_create : Error processing arguments"); cocos2d::Repeat* ret = cocos2d::Repeat::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Repeat*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Repeat_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Repeat_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Repeat)", obj); } void js_register_cocos2dx_Repeat(JSContext *cx, JSObject *global) { jsb_cocos2d_Repeat_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Repeat_class->name = "Repeat"; jsb_cocos2d_Repeat_class->addProperty = JS_PropertyStub; jsb_cocos2d_Repeat_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Repeat_class->getProperty = JS_PropertyStub; jsb_cocos2d_Repeat_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Repeat_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Repeat_class->resolve = JS_ResolveStub; jsb_cocos2d_Repeat_class->convert = JS_ConvertStub; jsb_cocos2d_Repeat_class->finalize = js_cocos2d_Repeat_finalize; jsb_cocos2d_Repeat_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setInnerAction", js_cocos2dx_Repeat_setInnerAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInnerAction", js_cocos2dx_Repeat_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Repeat_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Repeat_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_Repeat_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Repeat", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Repeat_class; p->proto = jsb_cocos2d_Repeat_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_RepeatForever_class; JSObject *jsb_cocos2d_RepeatForever_prototype; JSBool js_cocos2dx_RepeatForever_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RepeatForever* cobj = (cocos2d::RepeatForever *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RepeatForever_setInnerAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RepeatForever_setInnerAction : Error processing arguments"); cobj->setInnerAction(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RepeatForever_setInnerAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RepeatForever_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RepeatForever* cobj = (cocos2d::RepeatForever *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RepeatForever_getInnerAction : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->getInnerAction(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RepeatForever_getInnerAction : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RepeatForever_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RepeatForever_create : Error processing arguments"); cocos2d::RepeatForever* ret = cocos2d::RepeatForever::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RepeatForever*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RepeatForever_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_RepeatForever_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RepeatForever)", obj); } void js_register_cocos2dx_RepeatForever(JSContext *cx, JSObject *global) { jsb_cocos2d_RepeatForever_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_RepeatForever_class->name = "RepeatForever"; jsb_cocos2d_RepeatForever_class->addProperty = JS_PropertyStub; jsb_cocos2d_RepeatForever_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_RepeatForever_class->getProperty = JS_PropertyStub; jsb_cocos2d_RepeatForever_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_RepeatForever_class->enumerate = JS_EnumerateStub; jsb_cocos2d_RepeatForever_class->resolve = JS_ResolveStub; jsb_cocos2d_RepeatForever_class->convert = JS_ConvertStub; jsb_cocos2d_RepeatForever_class->finalize = js_cocos2d_RepeatForever_finalize; jsb_cocos2d_RepeatForever_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setInnerAction", js_cocos2dx_RepeatForever_setInnerAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInnerAction", js_cocos2dx_RepeatForever_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_RepeatForever_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_RepeatForever_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_RepeatForever_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "RepeatForever", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_RepeatForever_class; p->proto = jsb_cocos2d_RepeatForever_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Spawn_class; JSObject *jsb_cocos2d_Spawn_prototype; extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Spawn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Spawn)", obj); } void js_register_cocos2dx_Spawn(JSContext *cx, JSObject *global) { jsb_cocos2d_Spawn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Spawn_class->name = "Spawn"; jsb_cocos2d_Spawn_class->addProperty = JS_PropertyStub; jsb_cocos2d_Spawn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Spawn_class->getProperty = JS_PropertyStub; jsb_cocos2d_Spawn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Spawn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Spawn_class->resolve = JS_ResolveStub; jsb_cocos2d_Spawn_class->convert = JS_ConvertStub; jsb_cocos2d_Spawn_class->finalize = js_cocos2d_Spawn_finalize; jsb_cocos2d_Spawn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Spawn_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_Spawn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Spawn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Spawn_class; p->proto = jsb_cocos2d_Spawn_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_RotateTo_class; JSObject *jsb_cocos2d_RotateTo_prototype; JSBool js_cocos2dx_RotateTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::RotateTo* ret = cocos2d::RotateTo::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RotateTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::RotateTo* ret = cocos2d::RotateTo::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RotateTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_RotateTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_RotateTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RotateTo)", obj); } void js_register_cocos2dx_RotateTo(JSContext *cx, JSObject *global) { jsb_cocos2d_RotateTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_RotateTo_class->name = "RotateTo"; jsb_cocos2d_RotateTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_RotateTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_RotateTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_RotateTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_RotateTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_RotateTo_class->resolve = JS_ResolveStub; jsb_cocos2d_RotateTo_class->convert = JS_ConvertStub; jsb_cocos2d_RotateTo_class->finalize = js_cocos2d_RotateTo_finalize; jsb_cocos2d_RotateTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_RotateTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_RotateTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_RotateTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "RotateTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_RotateTo_class; p->proto = jsb_cocos2d_RotateTo_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_RotateBy_class; JSObject *jsb_cocos2d_RotateBy_prototype; JSBool js_cocos2dx_RotateBy_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::RotateBy* ret = cocos2d::RotateBy::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RotateBy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::RotateBy* ret = cocos2d::RotateBy::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RotateBy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_RotateBy_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_RotateBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RotateBy)", obj); } void js_register_cocos2dx_RotateBy(JSContext *cx, JSObject *global) { jsb_cocos2d_RotateBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_RotateBy_class->name = "RotateBy"; jsb_cocos2d_RotateBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_RotateBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_RotateBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_RotateBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_RotateBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_RotateBy_class->resolve = JS_ResolveStub; jsb_cocos2d_RotateBy_class->convert = JS_ConvertStub; jsb_cocos2d_RotateBy_class->finalize = js_cocos2d_RotateBy_finalize; jsb_cocos2d_RotateBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_RotateBy_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_RotateBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_RotateBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "RotateBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_RotateBy_class; p->proto = jsb_cocos2d_RotateBy_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MoveBy_class; JSObject *jsb_cocos2d_MoveBy_prototype; JSBool js_cocos2dx_MoveBy_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Point arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MoveBy_create : Error processing arguments"); cocos2d::MoveBy* ret = cocos2d::MoveBy::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::MoveBy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MoveBy_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_MoveBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MoveBy)", obj); } void js_register_cocos2dx_MoveBy(JSContext *cx, JSObject *global) { jsb_cocos2d_MoveBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MoveBy_class->name = "MoveBy"; jsb_cocos2d_MoveBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_MoveBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MoveBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_MoveBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MoveBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MoveBy_class->resolve = JS_ResolveStub; jsb_cocos2d_MoveBy_class->convert = JS_ConvertStub; jsb_cocos2d_MoveBy_class->finalize = js_cocos2d_MoveBy_finalize; jsb_cocos2d_MoveBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_MoveBy_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_MoveBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_MoveBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MoveBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MoveBy_class; p->proto = jsb_cocos2d_MoveBy_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MoveTo_class; JSObject *jsb_cocos2d_MoveTo_prototype; JSBool js_cocos2dx_MoveTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Point arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MoveTo_create : Error processing arguments"); cocos2d::MoveTo* ret = cocos2d::MoveTo::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::MoveTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MoveTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_MoveBy_prototype; void js_cocos2d_MoveTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MoveTo)", obj); } void js_register_cocos2dx_MoveTo(JSContext *cx, JSObject *global) { jsb_cocos2d_MoveTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MoveTo_class->name = "MoveTo"; jsb_cocos2d_MoveTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_MoveTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MoveTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_MoveTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MoveTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MoveTo_class->resolve = JS_ResolveStub; jsb_cocos2d_MoveTo_class->convert = JS_ConvertStub; jsb_cocos2d_MoveTo_class->finalize = js_cocos2d_MoveTo_finalize; jsb_cocos2d_MoveTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_MoveTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_MoveTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_MoveBy_prototype, jsb_cocos2d_MoveTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MoveTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MoveTo_class; p->proto = jsb_cocos2d_MoveTo_prototype; p->parentProto = jsb_cocos2d_MoveBy_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_SkewTo_class; JSObject *jsb_cocos2d_SkewTo_prototype; JSBool js_cocos2dx_SkewTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { double arg0; double arg1; double arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SkewTo_create : Error processing arguments"); cocos2d::SkewTo* ret = cocos2d::SkewTo::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SkewTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SkewTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_SkewTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SkewTo)", obj); } void js_register_cocos2dx_SkewTo(JSContext *cx, JSObject *global) { jsb_cocos2d_SkewTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SkewTo_class->name = "SkewTo"; jsb_cocos2d_SkewTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_SkewTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_SkewTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_SkewTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_SkewTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_SkewTo_class->resolve = JS_ResolveStub; jsb_cocos2d_SkewTo_class->convert = JS_ConvertStub; jsb_cocos2d_SkewTo_class->finalize = js_cocos2d_SkewTo_finalize; jsb_cocos2d_SkewTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_SkewTo_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_SkewTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_SkewTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SkewTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_SkewTo_class; p->proto = jsb_cocos2d_SkewTo_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_SkewBy_class; JSObject *jsb_cocos2d_SkewBy_prototype; JSBool js_cocos2dx_SkewBy_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { double arg0; double arg1; double arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SkewBy_create : Error processing arguments"); cocos2d::SkewBy* ret = cocos2d::SkewBy::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SkewBy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SkewBy_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_SkewTo_prototype; void js_cocos2d_SkewBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SkewBy)", obj); } void js_register_cocos2dx_SkewBy(JSContext *cx, JSObject *global) { jsb_cocos2d_SkewBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SkewBy_class->name = "SkewBy"; jsb_cocos2d_SkewBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_SkewBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_SkewBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_SkewBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_SkewBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_SkewBy_class->resolve = JS_ResolveStub; jsb_cocos2d_SkewBy_class->convert = JS_ConvertStub; jsb_cocos2d_SkewBy_class->finalize = js_cocos2d_SkewBy_finalize; jsb_cocos2d_SkewBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_SkewBy_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_SkewBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_SkewTo_prototype, jsb_cocos2d_SkewBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SkewBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_SkewBy_class; p->proto = jsb_cocos2d_SkewBy_prototype; p->parentProto = jsb_cocos2d_SkewTo_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_JumpBy_class; JSObject *jsb_cocos2d_JumpBy_prototype; JSBool js_cocos2dx_JumpBy_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Point arg1; double arg2; int arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_JumpBy_create : Error processing arguments"); cocos2d::JumpBy* ret = cocos2d::JumpBy::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::JumpBy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_JumpBy_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_JumpBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (JumpBy)", obj); } void js_register_cocos2dx_JumpBy(JSContext *cx, JSObject *global) { jsb_cocos2d_JumpBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_JumpBy_class->name = "JumpBy"; jsb_cocos2d_JumpBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_JumpBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_JumpBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_JumpBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_JumpBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_JumpBy_class->resolve = JS_ResolveStub; jsb_cocos2d_JumpBy_class->convert = JS_ConvertStub; jsb_cocos2d_JumpBy_class->finalize = js_cocos2d_JumpBy_finalize; jsb_cocos2d_JumpBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_JumpBy_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_JumpBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_JumpBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "JumpBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_JumpBy_class; p->proto = jsb_cocos2d_JumpBy_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_JumpTo_class; JSObject *jsb_cocos2d_JumpTo_prototype; JSBool js_cocos2dx_JumpTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Point arg1; double arg2; int arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_JumpTo_create : Error processing arguments"); cocos2d::JumpTo* ret = cocos2d::JumpTo::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::JumpTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_JumpTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_JumpBy_prototype; void js_cocos2d_JumpTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (JumpTo)", obj); } void js_register_cocos2dx_JumpTo(JSContext *cx, JSObject *global) { jsb_cocos2d_JumpTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_JumpTo_class->name = "JumpTo"; jsb_cocos2d_JumpTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_JumpTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_JumpTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_JumpTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_JumpTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_JumpTo_class->resolve = JS_ResolveStub; jsb_cocos2d_JumpTo_class->convert = JS_ConvertStub; jsb_cocos2d_JumpTo_class->finalize = js_cocos2d_JumpTo_finalize; jsb_cocos2d_JumpTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_JumpTo_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_JumpTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_JumpBy_prototype, jsb_cocos2d_JumpTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "JumpTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_JumpTo_class; p->proto = jsb_cocos2d_JumpTo_prototype; p->parentProto = jsb_cocos2d_JumpBy_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_BezierBy_class; JSObject *jsb_cocos2d_BezierBy_prototype; extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_BezierBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (BezierBy)", obj); } void js_register_cocos2dx_BezierBy(JSContext *cx, JSObject *global) { jsb_cocos2d_BezierBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_BezierBy_class->name = "BezierBy"; jsb_cocos2d_BezierBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_BezierBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_BezierBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_BezierBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_BezierBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_BezierBy_class->resolve = JS_ResolveStub; jsb_cocos2d_BezierBy_class->convert = JS_ConvertStub; jsb_cocos2d_BezierBy_class->finalize = js_cocos2d_BezierBy_finalize; jsb_cocos2d_BezierBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_BezierBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_BezierBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "BezierBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_BezierBy_class; p->proto = jsb_cocos2d_BezierBy_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_BezierTo_class; JSObject *jsb_cocos2d_BezierTo_prototype; extern JSObject *jsb_cocos2d_BezierBy_prototype; void js_cocos2d_BezierTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (BezierTo)", obj); } void js_register_cocos2dx_BezierTo(JSContext *cx, JSObject *global) { jsb_cocos2d_BezierTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_BezierTo_class->name = "BezierTo"; jsb_cocos2d_BezierTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_BezierTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_BezierTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_BezierTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_BezierTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_BezierTo_class->resolve = JS_ResolveStub; jsb_cocos2d_BezierTo_class->convert = JS_ConvertStub; jsb_cocos2d_BezierTo_class->finalize = js_cocos2d_BezierTo_finalize; jsb_cocos2d_BezierTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_BezierTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_BezierBy_prototype, jsb_cocos2d_BezierTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "BezierTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_BezierTo_class; p->proto = jsb_cocos2d_BezierTo_prototype; p->parentProto = jsb_cocos2d_BezierBy_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ScaleTo_class; JSObject *jsb_cocos2d_ScaleTo_prototype; JSBool js_cocos2dx_ScaleTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::ScaleTo* ret = cocos2d::ScaleTo::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ScaleTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::ScaleTo* ret = cocos2d::ScaleTo::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ScaleTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_ScaleTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ScaleTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ScaleTo)", obj); } void js_register_cocos2dx_ScaleTo(JSContext *cx, JSObject *global) { jsb_cocos2d_ScaleTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ScaleTo_class->name = "ScaleTo"; jsb_cocos2d_ScaleTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_ScaleTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ScaleTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_ScaleTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ScaleTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ScaleTo_class->resolve = JS_ResolveStub; jsb_cocos2d_ScaleTo_class->convert = JS_ConvertStub; jsb_cocos2d_ScaleTo_class->finalize = js_cocos2d_ScaleTo_finalize; jsb_cocos2d_ScaleTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ScaleTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ScaleTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_ScaleTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ScaleTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ScaleTo_class; p->proto = jsb_cocos2d_ScaleTo_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ScaleBy_class; JSObject *jsb_cocos2d_ScaleBy_prototype; JSBool js_cocos2dx_ScaleBy_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::ScaleBy* ret = cocos2d::ScaleBy::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ScaleBy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::ScaleBy* ret = cocos2d::ScaleBy::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ScaleBy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_ScaleBy_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ScaleTo_prototype; void js_cocos2d_ScaleBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ScaleBy)", obj); } void js_register_cocos2dx_ScaleBy(JSContext *cx, JSObject *global) { jsb_cocos2d_ScaleBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ScaleBy_class->name = "ScaleBy"; jsb_cocos2d_ScaleBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_ScaleBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ScaleBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_ScaleBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ScaleBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ScaleBy_class->resolve = JS_ResolveStub; jsb_cocos2d_ScaleBy_class->convert = JS_ConvertStub; jsb_cocos2d_ScaleBy_class->finalize = js_cocos2d_ScaleBy_finalize; jsb_cocos2d_ScaleBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ScaleBy_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ScaleBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_ScaleTo_prototype, jsb_cocos2d_ScaleBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ScaleBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ScaleBy_class; p->proto = jsb_cocos2d_ScaleBy_prototype; p->parentProto = jsb_cocos2d_ScaleTo_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Blink_class; JSObject *jsb_cocos2d_Blink_prototype; JSBool js_cocos2dx_Blink_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; int arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Blink_create : Error processing arguments"); cocos2d::Blink* ret = cocos2d::Blink::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Blink*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Blink_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Blink_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Blink)", obj); } void js_register_cocos2dx_Blink(JSContext *cx, JSObject *global) { jsb_cocos2d_Blink_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Blink_class->name = "Blink"; jsb_cocos2d_Blink_class->addProperty = JS_PropertyStub; jsb_cocos2d_Blink_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Blink_class->getProperty = JS_PropertyStub; jsb_cocos2d_Blink_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Blink_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Blink_class->resolve = JS_ResolveStub; jsb_cocos2d_Blink_class->convert = JS_ConvertStub; jsb_cocos2d_Blink_class->finalize = js_cocos2d_Blink_finalize; jsb_cocos2d_Blink_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Blink_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Blink_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_Blink_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Blink", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Blink_class; p->proto = jsb_cocos2d_Blink_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FadeIn_class; JSObject *jsb_cocos2d_FadeIn_prototype; JSBool js_cocos2dx_FadeIn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeIn_create : Error processing arguments"); cocos2d::FadeIn* ret = cocos2d::FadeIn::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FadeIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeIn_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_FadeIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeIn)", obj); } void js_register_cocos2dx_FadeIn(JSContext *cx, JSObject *global) { jsb_cocos2d_FadeIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeIn_class->name = "FadeIn"; jsb_cocos2d_FadeIn_class->addProperty = JS_PropertyStub; jsb_cocos2d_FadeIn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FadeIn_class->getProperty = JS_PropertyStub; jsb_cocos2d_FadeIn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FadeIn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FadeIn_class->resolve = JS_ResolveStub; jsb_cocos2d_FadeIn_class->convert = JS_ConvertStub; jsb_cocos2d_FadeIn_class->finalize = js_cocos2d_FadeIn_finalize; jsb_cocos2d_FadeIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FadeIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FadeIn_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_FadeIn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FadeIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FadeIn_class; p->proto = jsb_cocos2d_FadeIn_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FadeOut_class; JSObject *jsb_cocos2d_FadeOut_prototype; JSBool js_cocos2dx_FadeOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOut_create : Error processing arguments"); cocos2d::FadeOut* ret = cocos2d::FadeOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FadeOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_FadeOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOut)", obj); } void js_register_cocos2dx_FadeOut(JSContext *cx, JSObject *global) { jsb_cocos2d_FadeOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOut_class->name = "FadeOut"; jsb_cocos2d_FadeOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_FadeOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FadeOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_FadeOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FadeOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FadeOut_class->resolve = JS_ResolveStub; jsb_cocos2d_FadeOut_class->convert = JS_ConvertStub; jsb_cocos2d_FadeOut_class->finalize = js_cocos2d_FadeOut_finalize; jsb_cocos2d_FadeOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FadeOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FadeOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_FadeOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FadeOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FadeOut_class; p->proto = jsb_cocos2d_FadeOut_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FadeTo_class; JSObject *jsb_cocos2d_FadeTo_prototype; JSBool js_cocos2dx_FadeTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; uint16_t arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_uint16(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeTo_create : Error processing arguments"); cocos2d::FadeTo* ret = cocos2d::FadeTo::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FadeTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_FadeTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeTo)", obj); } void js_register_cocos2dx_FadeTo(JSContext *cx, JSObject *global) { jsb_cocos2d_FadeTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeTo_class->name = "FadeTo"; jsb_cocos2d_FadeTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_FadeTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FadeTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_FadeTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FadeTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FadeTo_class->resolve = JS_ResolveStub; jsb_cocos2d_FadeTo_class->convert = JS_ConvertStub; jsb_cocos2d_FadeTo_class->finalize = js_cocos2d_FadeTo_finalize; jsb_cocos2d_FadeTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FadeTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FadeTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_FadeTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FadeTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FadeTo_class; p->proto = jsb_cocos2d_FadeTo_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TintTo_class; JSObject *jsb_cocos2d_TintTo_prototype; JSBool js_cocos2dx_TintTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; uint16_t arg1; uint16_t arg2; uint16_t arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_uint16(cx, argv[1], &arg1); ok &= jsval_to_uint16(cx, argv[2], &arg2); ok &= jsval_to_uint16(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TintTo_create : Error processing arguments"); cocos2d::TintTo* ret = cocos2d::TintTo::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TintTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TintTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_TintTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TintTo)", obj); } void js_register_cocos2dx_TintTo(JSContext *cx, JSObject *global) { jsb_cocos2d_TintTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TintTo_class->name = "TintTo"; jsb_cocos2d_TintTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_TintTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TintTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_TintTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TintTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TintTo_class->resolve = JS_ResolveStub; jsb_cocos2d_TintTo_class->convert = JS_ConvertStub; jsb_cocos2d_TintTo_class->finalize = js_cocos2d_TintTo_finalize; jsb_cocos2d_TintTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TintTo_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TintTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_TintTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TintTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TintTo_class; p->proto = jsb_cocos2d_TintTo_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TintBy_class; JSObject *jsb_cocos2d_TintBy_prototype; JSBool js_cocos2dx_TintBy_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], &arg2); ok &= jsval_to_int32(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TintBy_create : Error processing arguments"); cocos2d::TintBy* ret = cocos2d::TintBy::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TintBy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TintBy_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_TintBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TintBy)", obj); } void js_register_cocos2dx_TintBy(JSContext *cx, JSObject *global) { jsb_cocos2d_TintBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TintBy_class->name = "TintBy"; jsb_cocos2d_TintBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_TintBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TintBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_TintBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TintBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TintBy_class->resolve = JS_ResolveStub; jsb_cocos2d_TintBy_class->convert = JS_ConvertStub; jsb_cocos2d_TintBy_class->finalize = js_cocos2d_TintBy_finalize; jsb_cocos2d_TintBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TintBy_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TintBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_TintBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TintBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TintBy_class; p->proto = jsb_cocos2d_TintBy_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_DelayTime_class; JSObject *jsb_cocos2d_DelayTime_prototype; JSBool js_cocos2dx_DelayTime_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_DelayTime_create : Error processing arguments"); cocos2d::DelayTime* ret = cocos2d::DelayTime::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::DelayTime*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DelayTime_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_DelayTime_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (DelayTime)", obj); } void js_register_cocos2dx_DelayTime(JSContext *cx, JSObject *global) { jsb_cocos2d_DelayTime_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_DelayTime_class->name = "DelayTime"; jsb_cocos2d_DelayTime_class->addProperty = JS_PropertyStub; jsb_cocos2d_DelayTime_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_DelayTime_class->getProperty = JS_PropertyStub; jsb_cocos2d_DelayTime_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_DelayTime_class->enumerate = JS_EnumerateStub; jsb_cocos2d_DelayTime_class->resolve = JS_ResolveStub; jsb_cocos2d_DelayTime_class->convert = JS_ConvertStub; jsb_cocos2d_DelayTime_class->finalize = js_cocos2d_DelayTime_finalize; jsb_cocos2d_DelayTime_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_DelayTime_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_DelayTime_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_DelayTime_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "DelayTime", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_DelayTime_class; p->proto = jsb_cocos2d_DelayTime_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Animate_class; JSObject *jsb_cocos2d_Animate_prototype; JSBool js_cocos2dx_Animate_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Animate* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Animate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animate_getAnimation : Invalid Native Object"); do { if (argc == 0) { const cocos2d::Animation* ret = cobj->getAnimation(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::Animation* ret = cobj->getAnimation(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Animate_getAnimation : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Animate_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Animate* cobj = (cocos2d::Animate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Animate_setAnimation : Invalid Native Object"); if (argc == 1) { cocos2d::Animation* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animate_setAnimation : Error processing arguments"); cobj->setAnimation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animate_setAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Animate_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Animation* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Animate_create : Error processing arguments"); cocos2d::Animate* ret = cocos2d::Animate::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Animate*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Animate_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_Animate_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Animate)", obj); } void js_register_cocos2dx_Animate(JSContext *cx, JSObject *global) { jsb_cocos2d_Animate_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Animate_class->name = "Animate"; jsb_cocos2d_Animate_class->addProperty = JS_PropertyStub; jsb_cocos2d_Animate_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Animate_class->getProperty = JS_PropertyStub; jsb_cocos2d_Animate_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Animate_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Animate_class->resolve = JS_ResolveStub; jsb_cocos2d_Animate_class->convert = JS_ConvertStub; jsb_cocos2d_Animate_class->finalize = js_cocos2d_Animate_finalize; jsb_cocos2d_Animate_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAnimation", js_cocos2dx_Animate_getAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimation", js_cocos2dx_Animate_setAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Animate_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Animate_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_Animate_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Animate", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Animate_class; p->proto = jsb_cocos2d_Animate_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TargetedAction_class; JSObject *jsb_cocos2d_TargetedAction_prototype; JSBool js_cocos2dx_TargetedAction_getForcedTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TargetedAction* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TargetedAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TargetedAction_getForcedTarget : Invalid Native Object"); do { if (argc == 0) { const cocos2d::Node* ret = cobj->getForcedTarget(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::Node* ret = cobj->getForcedTarget(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TargetedAction_getForcedTarget : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TargetedAction_setForcedTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TargetedAction* cobj = (cocos2d::TargetedAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TargetedAction_setForcedTarget : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TargetedAction_setForcedTarget : Error processing arguments"); cobj->setForcedTarget(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TargetedAction_setForcedTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TargetedAction_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Node* arg0; cocos2d::FiniteTimeAction* arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TargetedAction_create : Error processing arguments"); cocos2d::TargetedAction* ret = cocos2d::TargetedAction::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TargetedAction*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TargetedAction_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_TargetedAction_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TargetedAction)", obj); } void js_register_cocos2dx_TargetedAction(JSContext *cx, JSObject *global) { jsb_cocos2d_TargetedAction_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TargetedAction_class->name = "TargetedAction"; jsb_cocos2d_TargetedAction_class->addProperty = JS_PropertyStub; jsb_cocos2d_TargetedAction_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TargetedAction_class->getProperty = JS_PropertyStub; jsb_cocos2d_TargetedAction_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TargetedAction_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TargetedAction_class->resolve = JS_ResolveStub; jsb_cocos2d_TargetedAction_class->convert = JS_ConvertStub; jsb_cocos2d_TargetedAction_class->finalize = js_cocos2d_TargetedAction_finalize; jsb_cocos2d_TargetedAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getForcedTarget", js_cocos2dx_TargetedAction_getForcedTarget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setForcedTarget", js_cocos2dx_TargetedAction_setForcedTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TargetedAction_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TargetedAction_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_TargetedAction_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TargetedAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TargetedAction_class; p->proto = jsb_cocos2d_TargetedAction_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ActionCamera_class; JSObject *jsb_cocos2d_ActionCamera_prototype; JSBool js_cocos2dx_ActionCamera_setEye(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::ActionCamera* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionCamera_setEye : Invalid Native Object"); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cobj->setEye(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { kmVec3 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmVec3; if (!ok) { ok = JS_TRUE; break; } cobj->setEye(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_ActionCamera_setEye : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ActionCamera_getEye(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionCamera_getEye : Invalid Native Object"); if (argc == 0) { const kmVec3& ret = cobj->getEye(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmVec3; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionCamera_getEye : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ActionCamera_setUp(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionCamera_setUp : Invalid Native Object"); if (argc == 1) { kmVec3 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmVec3; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionCamera_setUp : Error processing arguments"); cobj->setUp(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionCamera_setUp : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionCamera_getCenter(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionCamera_getCenter : Invalid Native Object"); if (argc == 0) { const kmVec3& ret = cobj->getCenter(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmVec3; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionCamera_getCenter : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ActionCamera_setCenter(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionCamera_setCenter : Invalid Native Object"); if (argc == 1) { kmVec3 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmVec3; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionCamera_setCenter : Error processing arguments"); cobj->setCenter(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionCamera_setCenter : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionCamera_getUp(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionCamera_getUp : Invalid Native Object"); if (argc == 0) { const kmVec3& ret = cobj->getUp(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmVec3; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionCamera_getUp : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ActionCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ActionCamera* cobj = new cocos2d::ActionCamera(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionCamera"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionCamera_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ActionCamera_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ActionCamera)", obj); } void js_register_cocos2dx_ActionCamera(JSContext *cx, JSObject *global) { jsb_cocos2d_ActionCamera_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ActionCamera_class->name = "ActionCamera"; jsb_cocos2d_ActionCamera_class->addProperty = JS_PropertyStub; jsb_cocos2d_ActionCamera_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ActionCamera_class->getProperty = JS_PropertyStub; jsb_cocos2d_ActionCamera_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ActionCamera_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ActionCamera_class->resolve = JS_ResolveStub; jsb_cocos2d_ActionCamera_class->convert = JS_ConvertStub; jsb_cocos2d_ActionCamera_class->finalize = js_cocos2d_ActionCamera_finalize; jsb_cocos2d_ActionCamera_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEye", js_cocos2dx_ActionCamera_setEye, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEye", js_cocos2dx_ActionCamera_getEye, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUp", js_cocos2dx_ActionCamera_setUp, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCenter", js_cocos2dx_ActionCamera_getCenter, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCenter", js_cocos2dx_ActionCamera_setCenter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUp", js_cocos2dx_ActionCamera_getUp, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_ActionCamera_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_ActionCamera_class, js_cocos2dx_ActionCamera_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ActionCamera", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ActionCamera_class; p->proto = jsb_cocos2d_ActionCamera_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_OrbitCamera_class; JSObject *jsb_cocos2d_OrbitCamera_prototype; JSBool js_cocos2dx_OrbitCamera_sphericalRadius(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::OrbitCamera* cobj = (cocos2d::OrbitCamera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_OrbitCamera_sphericalRadius : Invalid Native Object"); if (argc == 3) { float* arg0; float* arg1; float* arg2; #pragma warning NO CONVERSION TO NATIVE FOR float*; #pragma warning NO CONVERSION TO NATIVE FOR float*; #pragma warning NO CONVERSION TO NATIVE FOR float*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_OrbitCamera_sphericalRadius : Error processing arguments"); cobj->sphericalRadius(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_OrbitCamera_sphericalRadius : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_OrbitCamera_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::OrbitCamera* cobj = (cocos2d::OrbitCamera *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_OrbitCamera_initWithDuration : Invalid Native Object"); if (argc == 7) { double arg0; double arg1; double arg2; double arg3; double arg4; double arg5; double arg6; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); ok &= JS_ValueToNumber(cx, argv[4], &arg4); ok &= JS_ValueToNumber(cx, argv[5], &arg5); ok &= JS_ValueToNumber(cx, argv[6], &arg6); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_OrbitCamera_initWithDuration : Error processing arguments"); JSBool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3, arg4, arg5, arg6); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_OrbitCamera_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 7); return JS_FALSE; } JSBool js_cocos2dx_OrbitCamera_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 7) { double arg0; double arg1; double arg2; double arg3; double arg4; double arg5; double arg6; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); ok &= JS_ValueToNumber(cx, argv[4], &arg4); ok &= JS_ValueToNumber(cx, argv[5], &arg5); ok &= JS_ValueToNumber(cx, argv[6], &arg6); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_OrbitCamera_create : Error processing arguments"); cocos2d::OrbitCamera* ret = cocos2d::OrbitCamera::create(arg0, arg1, arg2, arg3, arg4, arg5, arg6); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::OrbitCamera*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_OrbitCamera_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_OrbitCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::OrbitCamera* cobj = new cocos2d::OrbitCamera(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::OrbitCamera"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_OrbitCamera_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionCamera_prototype; void js_cocos2d_OrbitCamera_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (OrbitCamera)", obj); } void js_register_cocos2dx_OrbitCamera(JSContext *cx, JSObject *global) { jsb_cocos2d_OrbitCamera_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_OrbitCamera_class->name = "OrbitCamera"; jsb_cocos2d_OrbitCamera_class->addProperty = JS_PropertyStub; jsb_cocos2d_OrbitCamera_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_OrbitCamera_class->getProperty = JS_PropertyStub; jsb_cocos2d_OrbitCamera_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_OrbitCamera_class->enumerate = JS_EnumerateStub; jsb_cocos2d_OrbitCamera_class->resolve = JS_ResolveStub; jsb_cocos2d_OrbitCamera_class->convert = JS_ConvertStub; jsb_cocos2d_OrbitCamera_class->finalize = js_cocos2d_OrbitCamera_finalize; jsb_cocos2d_OrbitCamera_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("sphericalRadius", js_cocos2dx_OrbitCamera_sphericalRadius, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithDuration", js_cocos2dx_OrbitCamera_initWithDuration, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_OrbitCamera_create, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_OrbitCamera_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionCamera_prototype, jsb_cocos2d_OrbitCamera_class, js_cocos2dx_OrbitCamera_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "OrbitCamera", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_OrbitCamera_class; p->proto = jsb_cocos2d_OrbitCamera_prototype; p->parentProto = jsb_cocos2d_ActionCamera_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ActionManager_class; JSObject *jsb_cocos2d_ActionManager_prototype; JSBool js_cocos2dx_ActionManager_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_getActionByTag : Invalid Native Object"); if (argc == 2) { int arg0; const cocos2d::Node* arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (const cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_getActionByTag : Error processing arguments"); cocos2d::Action* ret = cobj->getActionByTag(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_getActionByTag : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_removeActionByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_removeActionByTag : Invalid Native Object"); if (argc == 2) { int arg0; cocos2d::Node* arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_removeActionByTag : Error processing arguments"); cobj->removeActionByTag(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_removeActionByTag : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_removeAllActions(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_removeAllActions : Invalid Native Object"); if (argc == 0) { cobj->removeAllActions(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_removeAllActions : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_addAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_addAction : Invalid Native Object"); if (argc == 3) { cocos2d::Action* arg0; cocos2d::Node* arg1; JSBool arg2; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_addAction : Error processing arguments"); cobj->addAction(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_addAction : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_resumeTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_resumeTarget : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_resumeTarget : Error processing arguments"); cobj->resumeTarget(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_resumeTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget : Invalid Native Object"); if (argc == 1) { const cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (const cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget : Error processing arguments"); ssize_t ret = cobj->getNumberOfRunningActionsInTarget(arg0); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_removeAllActionsFromTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_removeAllActionsFromTarget : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_removeAllActionsFromTarget : Error processing arguments"); cobj->removeAllActionsFromTarget(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_removeAllActionsFromTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_resumeTargets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_resumeTargets : Invalid Native Object"); if (argc == 1) { cocos2d::Vector arg0; ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_resumeTargets : Error processing arguments"); cobj->resumeTargets(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_resumeTargets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_removeAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_removeAction : Invalid Native Object"); if (argc == 1) { cocos2d::Action* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Action*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_removeAction : Error processing arguments"); cobj->removeAction(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_removeAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_pauseTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_pauseTarget : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionManager_pauseTarget : Error processing arguments"); cobj->pauseTarget(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_pauseTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_pauseAllRunningActions(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionManager_pauseAllRunningActions : Invalid Native Object"); if (argc == 0) { cocos2d::Vector ret = cobj->pauseAllRunningActions(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_pauseAllRunningActions : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ActionManager_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ActionManager* cobj = new cocos2d::ActionManager(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionManager"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionManager_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_ActionManager_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ActionManager)", obj); } void js_register_cocos2dx_ActionManager(JSContext *cx, JSObject *global) { jsb_cocos2d_ActionManager_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ActionManager_class->name = "ActionManager"; jsb_cocos2d_ActionManager_class->addProperty = JS_PropertyStub; jsb_cocos2d_ActionManager_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ActionManager_class->getProperty = JS_PropertyStub; jsb_cocos2d_ActionManager_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ActionManager_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ActionManager_class->resolve = JS_ResolveStub; jsb_cocos2d_ActionManager_class->convert = JS_ConvertStub; jsb_cocos2d_ActionManager_class->finalize = js_cocos2d_ActionManager_finalize; jsb_cocos2d_ActionManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getActionByTag", js_cocos2dx_ActionManager_getActionByTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeActionByTag", js_cocos2dx_ActionManager_removeActionByTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllActions", js_cocos2dx_ActionManager_removeAllActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addAction", js_cocos2dx_ActionManager_addAction, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resumeTarget", js_cocos2dx_ActionManager_resumeTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNumberOfRunningActionsInTarget", js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllActionsFromTarget", js_cocos2dx_ActionManager_removeAllActionsFromTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resumeTargets", js_cocos2dx_ActionManager_resumeTargets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAction", js_cocos2dx_ActionManager_removeAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pauseTarget", js_cocos2dx_ActionManager_pauseTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pauseAllRunningActions", js_cocos2dx_ActionManager_pauseAllRunningActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_ActionManager_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_ActionManager_class, js_cocos2dx_ActionManager_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ActionManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ActionManager_class; p->proto = jsb_cocos2d_ActionManager_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ActionEase_class; JSObject *jsb_cocos2d_ActionEase_prototype; JSBool js_cocos2dx_ActionEase_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionEase* cobj = (cocos2d::ActionEase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionEase_getInnerAction : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->getInnerAction(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionEase_getInnerAction : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ActionEase_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ActionEase)", obj); } void js_register_cocos2dx_ActionEase(JSContext *cx, JSObject *global) { jsb_cocos2d_ActionEase_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ActionEase_class->name = "ActionEase"; jsb_cocos2d_ActionEase_class->addProperty = JS_PropertyStub; jsb_cocos2d_ActionEase_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ActionEase_class->getProperty = JS_PropertyStub; jsb_cocos2d_ActionEase_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ActionEase_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ActionEase_class->resolve = JS_ResolveStub; jsb_cocos2d_ActionEase_class->convert = JS_ConvertStub; jsb_cocos2d_ActionEase_class->finalize = js_cocos2d_ActionEase_finalize; jsb_cocos2d_ActionEase_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getInnerAction", js_cocos2dx_ActionEase_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_ActionEase_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_ActionEase_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ActionEase", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ActionEase_class; p->proto = jsb_cocos2d_ActionEase_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseRateAction_class; JSObject *jsb_cocos2d_EaseRateAction_prototype; JSBool js_cocos2dx_EaseRateAction_setRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EaseRateAction* cobj = (cocos2d::EaseRateAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EaseRateAction_setRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseRateAction_setRate : Error processing arguments"); cobj->setRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseRateAction_setRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_EaseRateAction_getRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EaseRateAction* cobj = (cocos2d::EaseRateAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EaseRateAction_getRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseRateAction_getRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseRateAction_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseRateAction)", obj); } void js_register_cocos2dx_EaseRateAction(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseRateAction_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseRateAction_class->name = "EaseRateAction"; jsb_cocos2d_EaseRateAction_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseRateAction_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseRateAction_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseRateAction_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseRateAction_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseRateAction_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseRateAction_class->convert = JS_ConvertStub; jsb_cocos2d_EaseRateAction_class->finalize = js_cocos2d_EaseRateAction_finalize; jsb_cocos2d_EaseRateAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setRate", js_cocos2dx_EaseRateAction_setRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRate", js_cocos2dx_EaseRateAction_getRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_EaseRateAction_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseRateAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseRateAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseRateAction_class; p->proto = jsb_cocos2d_EaseRateAction_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseIn_class; JSObject *jsb_cocos2d_EaseIn_prototype; JSBool js_cocos2dx_EaseIn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::ActionInterval* arg0; double arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseIn_create : Error processing arguments"); cocos2d::EaseIn* ret = cocos2d::EaseIn::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseIn_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseRateAction_prototype; void js_cocos2d_EaseIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseIn)", obj); } void js_register_cocos2dx_EaseIn(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseIn_class->name = "EaseIn"; jsb_cocos2d_EaseIn_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseIn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseIn_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseIn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseIn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseIn_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseIn_class->convert = JS_ConvertStub; jsb_cocos2d_EaseIn_class->finalize = js_cocos2d_EaseIn_finalize; jsb_cocos2d_EaseIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseIn_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseIn_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseRateAction_prototype, jsb_cocos2d_EaseIn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseIn_class; p->proto = jsb_cocos2d_EaseIn_prototype; p->parentProto = jsb_cocos2d_EaseRateAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseOut_class; JSObject *jsb_cocos2d_EaseOut_prototype; JSBool js_cocos2dx_EaseOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::ActionInterval* arg0; double arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseOut_create : Error processing arguments"); cocos2d::EaseOut* ret = cocos2d::EaseOut::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseRateAction_prototype; void js_cocos2d_EaseOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseOut)", obj); } void js_register_cocos2dx_EaseOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseOut_class->name = "EaseOut"; jsb_cocos2d_EaseOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseOut_class->finalize = js_cocos2d_EaseOut_finalize; jsb_cocos2d_EaseOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseOut_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseRateAction_prototype, jsb_cocos2d_EaseOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseOut_class; p->proto = jsb_cocos2d_EaseOut_prototype; p->parentProto = jsb_cocos2d_EaseRateAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseInOut_class; JSObject *jsb_cocos2d_EaseInOut_prototype; JSBool js_cocos2dx_EaseInOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::ActionInterval* arg0; double arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseInOut_create : Error processing arguments"); cocos2d::EaseInOut* ret = cocos2d::EaseInOut::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseInOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseInOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseRateAction_prototype; void js_cocos2d_EaseInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseInOut)", obj); } void js_register_cocos2dx_EaseInOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseInOut_class->name = "EaseInOut"; jsb_cocos2d_EaseInOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseInOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseInOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseInOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseInOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseInOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseInOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseInOut_class->finalize = js_cocos2d_EaseInOut_finalize; jsb_cocos2d_EaseInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseInOut_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseInOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseRateAction_prototype, jsb_cocos2d_EaseInOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseInOut_class; p->proto = jsb_cocos2d_EaseInOut_prototype; p->parentProto = jsb_cocos2d_EaseRateAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseExponentialIn_class; JSObject *jsb_cocos2d_EaseExponentialIn_prototype; JSBool js_cocos2dx_EaseExponentialIn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseExponentialIn_create : Error processing arguments"); cocos2d::EaseExponentialIn* ret = cocos2d::EaseExponentialIn::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseExponentialIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseExponentialIn_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseExponentialIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialIn)", obj); } void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseExponentialIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseExponentialIn_class->name = "EaseExponentialIn"; jsb_cocos2d_EaseExponentialIn_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseExponentialIn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseExponentialIn_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseExponentialIn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseExponentialIn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseExponentialIn_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseExponentialIn_class->convert = JS_ConvertStub; jsb_cocos2d_EaseExponentialIn_class->finalize = js_cocos2d_EaseExponentialIn_finalize; jsb_cocos2d_EaseExponentialIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseExponentialIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseExponentialIn_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseExponentialIn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseExponentialIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseExponentialIn_class; p->proto = jsb_cocos2d_EaseExponentialIn_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseExponentialOut_class; JSObject *jsb_cocos2d_EaseExponentialOut_prototype; JSBool js_cocos2dx_EaseExponentialOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseExponentialOut_create : Error processing arguments"); cocos2d::EaseExponentialOut* ret = cocos2d::EaseExponentialOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseExponentialOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseExponentialOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseExponentialOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialOut)", obj); } void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseExponentialOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseExponentialOut_class->name = "EaseExponentialOut"; jsb_cocos2d_EaseExponentialOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseExponentialOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseExponentialOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseExponentialOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseExponentialOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseExponentialOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseExponentialOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseExponentialOut_class->finalize = js_cocos2d_EaseExponentialOut_finalize; jsb_cocos2d_EaseExponentialOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseExponentialOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseExponentialOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseExponentialOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseExponentialOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseExponentialOut_class; p->proto = jsb_cocos2d_EaseExponentialOut_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseExponentialInOut_class; JSObject *jsb_cocos2d_EaseExponentialInOut_prototype; JSBool js_cocos2dx_EaseExponentialInOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseExponentialInOut_create : Error processing arguments"); cocos2d::EaseExponentialInOut* ret = cocos2d::EaseExponentialInOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseExponentialInOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseExponentialInOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseExponentialInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialInOut)", obj); } void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseExponentialInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseExponentialInOut_class->name = "EaseExponentialInOut"; jsb_cocos2d_EaseExponentialInOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseExponentialInOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseExponentialInOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseExponentialInOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseExponentialInOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseExponentialInOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseExponentialInOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseExponentialInOut_class->finalize = js_cocos2d_EaseExponentialInOut_finalize; jsb_cocos2d_EaseExponentialInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseExponentialInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseExponentialInOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseExponentialInOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseExponentialInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseExponentialInOut_class; p->proto = jsb_cocos2d_EaseExponentialInOut_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseSineIn_class; JSObject *jsb_cocos2d_EaseSineIn_prototype; JSBool js_cocos2dx_EaseSineIn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseSineIn_create : Error processing arguments"); cocos2d::EaseSineIn* ret = cocos2d::EaseSineIn::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseSineIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseSineIn_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseSineIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineIn)", obj); } void js_register_cocos2dx_EaseSineIn(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseSineIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseSineIn_class->name = "EaseSineIn"; jsb_cocos2d_EaseSineIn_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseSineIn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseSineIn_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseSineIn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseSineIn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseSineIn_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseSineIn_class->convert = JS_ConvertStub; jsb_cocos2d_EaseSineIn_class->finalize = js_cocos2d_EaseSineIn_finalize; jsb_cocos2d_EaseSineIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseSineIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseSineIn_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseSineIn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseSineIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseSineIn_class; p->proto = jsb_cocos2d_EaseSineIn_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseSineOut_class; JSObject *jsb_cocos2d_EaseSineOut_prototype; JSBool js_cocos2dx_EaseSineOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseSineOut_create : Error processing arguments"); cocos2d::EaseSineOut* ret = cocos2d::EaseSineOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseSineOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseSineOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseSineOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineOut)", obj); } void js_register_cocos2dx_EaseSineOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseSineOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseSineOut_class->name = "EaseSineOut"; jsb_cocos2d_EaseSineOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseSineOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseSineOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseSineOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseSineOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseSineOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseSineOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseSineOut_class->finalize = js_cocos2d_EaseSineOut_finalize; jsb_cocos2d_EaseSineOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseSineOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseSineOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseSineOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseSineOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseSineOut_class; p->proto = jsb_cocos2d_EaseSineOut_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseSineInOut_class; JSObject *jsb_cocos2d_EaseSineInOut_prototype; JSBool js_cocos2dx_EaseSineInOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseSineInOut_create : Error processing arguments"); cocos2d::EaseSineInOut* ret = cocos2d::EaseSineInOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseSineInOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseSineInOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseSineInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineInOut)", obj); } void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseSineInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseSineInOut_class->name = "EaseSineInOut"; jsb_cocos2d_EaseSineInOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseSineInOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseSineInOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseSineInOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseSineInOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseSineInOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseSineInOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseSineInOut_class->finalize = js_cocos2d_EaseSineInOut_finalize; jsb_cocos2d_EaseSineInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseSineInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseSineInOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseSineInOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseSineInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseSineInOut_class; p->proto = jsb_cocos2d_EaseSineInOut_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseElastic_class; JSObject *jsb_cocos2d_EaseElastic_prototype; JSBool js_cocos2dx_EaseElastic_setPeriod(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EaseElastic* cobj = (cocos2d::EaseElastic *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EaseElastic_setPeriod : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseElastic_setPeriod : Error processing arguments"); cobj->setPeriod(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseElastic_setPeriod : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_EaseElastic_getPeriod(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EaseElastic* cobj = (cocos2d::EaseElastic *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EaseElastic_getPeriod : Invalid Native Object"); if (argc == 0) { double ret = cobj->getPeriod(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseElastic_getPeriod : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseElastic_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseElastic)", obj); } void js_register_cocos2dx_EaseElastic(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseElastic_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseElastic_class->name = "EaseElastic"; jsb_cocos2d_EaseElastic_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseElastic_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseElastic_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseElastic_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseElastic_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseElastic_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseElastic_class->convert = JS_ConvertStub; jsb_cocos2d_EaseElastic_class->finalize = js_cocos2d_EaseElastic_finalize; jsb_cocos2d_EaseElastic_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setPeriod", js_cocos2dx_EaseElastic_setPeriod, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPeriod", js_cocos2dx_EaseElastic_getPeriod, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_EaseElastic_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseElastic_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseElastic", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseElastic_class; p->proto = jsb_cocos2d_EaseElastic_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseElasticIn_class; JSObject *jsb_cocos2d_EaseElasticIn_prototype; JSBool js_cocos2dx_EaseElasticIn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::EaseElasticIn* ret = cocos2d::EaseElasticIn::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::EaseElasticIn* ret = cocos2d::EaseElasticIn::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_EaseElasticIn_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseElastic_prototype; void js_cocos2d_EaseElasticIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticIn)", obj); } void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseElasticIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseElasticIn_class->name = "EaseElasticIn"; jsb_cocos2d_EaseElasticIn_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseElasticIn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseElasticIn_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseElasticIn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseElasticIn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseElasticIn_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseElasticIn_class->convert = JS_ConvertStub; jsb_cocos2d_EaseElasticIn_class->finalize = js_cocos2d_EaseElasticIn_finalize; jsb_cocos2d_EaseElasticIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseElasticIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseElasticIn_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseElastic_prototype, jsb_cocos2d_EaseElasticIn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseElasticIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseElasticIn_class; p->proto = jsb_cocos2d_EaseElasticIn_prototype; p->parentProto = jsb_cocos2d_EaseElastic_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseElasticOut_class; JSObject *jsb_cocos2d_EaseElasticOut_prototype; JSBool js_cocos2dx_EaseElasticOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::EaseElasticOut* ret = cocos2d::EaseElasticOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::EaseElasticOut* ret = cocos2d::EaseElasticOut::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_EaseElasticOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseElastic_prototype; void js_cocos2d_EaseElasticOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticOut)", obj); } void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseElasticOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseElasticOut_class->name = "EaseElasticOut"; jsb_cocos2d_EaseElasticOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseElasticOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseElasticOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseElasticOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseElasticOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseElasticOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseElasticOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseElasticOut_class->finalize = js_cocos2d_EaseElasticOut_finalize; jsb_cocos2d_EaseElasticOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseElasticOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseElasticOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseElastic_prototype, jsb_cocos2d_EaseElasticOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseElasticOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseElasticOut_class; p->proto = jsb_cocos2d_EaseElasticOut_prototype; p->parentProto = jsb_cocos2d_EaseElastic_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseElasticInOut_class; JSObject *jsb_cocos2d_EaseElasticInOut_prototype; JSBool js_cocos2dx_EaseElasticInOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::EaseElasticInOut* ret = cocos2d::EaseElasticInOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticInOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::EaseElasticInOut* ret = cocos2d::EaseElasticInOut::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticInOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_EaseElasticInOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseElastic_prototype; void js_cocos2d_EaseElasticInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticInOut)", obj); } void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseElasticInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseElasticInOut_class->name = "EaseElasticInOut"; jsb_cocos2d_EaseElasticInOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseElasticInOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseElasticInOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseElasticInOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseElasticInOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseElasticInOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseElasticInOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseElasticInOut_class->finalize = js_cocos2d_EaseElasticInOut_finalize; jsb_cocos2d_EaseElasticInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseElasticInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseElasticInOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseElastic_prototype, jsb_cocos2d_EaseElasticInOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseElasticInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseElasticInOut_class; p->proto = jsb_cocos2d_EaseElasticInOut_prototype; p->parentProto = jsb_cocos2d_EaseElastic_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseBounce_class; JSObject *jsb_cocos2d_EaseBounce_prototype; JSBool js_cocos2dx_EaseBounce_bounceTime(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EaseBounce* cobj = (cocos2d::EaseBounce *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EaseBounce_bounceTime : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseBounce_bounceTime : Error processing arguments"); double ret = cobj->bounceTime(arg0); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseBounce_bounceTime : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseBounce_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounce)", obj); } void js_register_cocos2dx_EaseBounce(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseBounce_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBounce_class->name = "EaseBounce"; jsb_cocos2d_EaseBounce_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseBounce_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseBounce_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseBounce_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseBounce_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseBounce_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseBounce_class->convert = JS_ConvertStub; jsb_cocos2d_EaseBounce_class->finalize = js_cocos2d_EaseBounce_finalize; jsb_cocos2d_EaseBounce_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("bounceTime", js_cocos2dx_EaseBounce_bounceTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_EaseBounce_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseBounce_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseBounce", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseBounce_class; p->proto = jsb_cocos2d_EaseBounce_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseBounceIn_class; JSObject *jsb_cocos2d_EaseBounceIn_prototype; JSBool js_cocos2dx_EaseBounceIn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseBounceIn_create : Error processing arguments"); cocos2d::EaseBounceIn* ret = cocos2d::EaseBounceIn::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseBounceIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseBounceIn_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseBounce_prototype; void js_cocos2d_EaseBounceIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceIn)", obj); } void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseBounceIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBounceIn_class->name = "EaseBounceIn"; jsb_cocos2d_EaseBounceIn_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseBounceIn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseBounceIn_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseBounceIn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseBounceIn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseBounceIn_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseBounceIn_class->convert = JS_ConvertStub; jsb_cocos2d_EaseBounceIn_class->finalize = js_cocos2d_EaseBounceIn_finalize; jsb_cocos2d_EaseBounceIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseBounceIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseBounceIn_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseBounce_prototype, jsb_cocos2d_EaseBounceIn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseBounceIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseBounceIn_class; p->proto = jsb_cocos2d_EaseBounceIn_prototype; p->parentProto = jsb_cocos2d_EaseBounce_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseBounceOut_class; JSObject *jsb_cocos2d_EaseBounceOut_prototype; JSBool js_cocos2dx_EaseBounceOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseBounceOut_create : Error processing arguments"); cocos2d::EaseBounceOut* ret = cocos2d::EaseBounceOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseBounceOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseBounceOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseBounce_prototype; void js_cocos2d_EaseBounceOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceOut)", obj); } void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseBounceOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBounceOut_class->name = "EaseBounceOut"; jsb_cocos2d_EaseBounceOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseBounceOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseBounceOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseBounceOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseBounceOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseBounceOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseBounceOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseBounceOut_class->finalize = js_cocos2d_EaseBounceOut_finalize; jsb_cocos2d_EaseBounceOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseBounceOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseBounceOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseBounce_prototype, jsb_cocos2d_EaseBounceOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseBounceOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseBounceOut_class; p->proto = jsb_cocos2d_EaseBounceOut_prototype; p->parentProto = jsb_cocos2d_EaseBounce_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseBounceInOut_class; JSObject *jsb_cocos2d_EaseBounceInOut_prototype; JSBool js_cocos2dx_EaseBounceInOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseBounceInOut_create : Error processing arguments"); cocos2d::EaseBounceInOut* ret = cocos2d::EaseBounceInOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseBounceInOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseBounceInOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EaseBounce_prototype; void js_cocos2d_EaseBounceInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceInOut)", obj); } void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseBounceInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBounceInOut_class->name = "EaseBounceInOut"; jsb_cocos2d_EaseBounceInOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseBounceInOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseBounceInOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseBounceInOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseBounceInOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseBounceInOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseBounceInOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseBounceInOut_class->finalize = js_cocos2d_EaseBounceInOut_finalize; jsb_cocos2d_EaseBounceInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseBounceInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseBounceInOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_EaseBounce_prototype, jsb_cocos2d_EaseBounceInOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseBounceInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseBounceInOut_class; p->proto = jsb_cocos2d_EaseBounceInOut_prototype; p->parentProto = jsb_cocos2d_EaseBounce_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseBackIn_class; JSObject *jsb_cocos2d_EaseBackIn_prototype; JSBool js_cocos2dx_EaseBackIn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseBackIn_create : Error processing arguments"); cocos2d::EaseBackIn* ret = cocos2d::EaseBackIn::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseBackIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseBackIn_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseBackIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackIn)", obj); } void js_register_cocos2dx_EaseBackIn(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseBackIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBackIn_class->name = "EaseBackIn"; jsb_cocos2d_EaseBackIn_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseBackIn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseBackIn_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseBackIn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseBackIn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseBackIn_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseBackIn_class->convert = JS_ConvertStub; jsb_cocos2d_EaseBackIn_class->finalize = js_cocos2d_EaseBackIn_finalize; jsb_cocos2d_EaseBackIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseBackIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseBackIn_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseBackIn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseBackIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseBackIn_class; p->proto = jsb_cocos2d_EaseBackIn_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseBackOut_class; JSObject *jsb_cocos2d_EaseBackOut_prototype; JSBool js_cocos2dx_EaseBackOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseBackOut_create : Error processing arguments"); cocos2d::EaseBackOut* ret = cocos2d::EaseBackOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseBackOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseBackOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseBackOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackOut)", obj); } void js_register_cocos2dx_EaseBackOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseBackOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBackOut_class->name = "EaseBackOut"; jsb_cocos2d_EaseBackOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseBackOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseBackOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseBackOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseBackOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseBackOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseBackOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseBackOut_class->finalize = js_cocos2d_EaseBackOut_finalize; jsb_cocos2d_EaseBackOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseBackOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseBackOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseBackOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseBackOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseBackOut_class; p->proto = jsb_cocos2d_EaseBackOut_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EaseBackInOut_class; JSObject *jsb_cocos2d_EaseBackInOut_prototype; JSBool js_cocos2dx_EaseBackInOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EaseBackInOut_create : Error processing arguments"); cocos2d::EaseBackInOut* ret = cocos2d::EaseBackInOut::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EaseBackInOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EaseBackInOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionEase_prototype; void js_cocos2d_EaseBackInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackInOut)", obj); } void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JSObject *global) { jsb_cocos2d_EaseBackInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EaseBackInOut_class->name = "EaseBackInOut"; jsb_cocos2d_EaseBackInOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_EaseBackInOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EaseBackInOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_EaseBackInOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EaseBackInOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EaseBackInOut_class->resolve = JS_ResolveStub; jsb_cocos2d_EaseBackInOut_class->convert = JS_ConvertStub; jsb_cocos2d_EaseBackInOut_class->finalize = js_cocos2d_EaseBackInOut_finalize; jsb_cocos2d_EaseBackInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_EaseBackInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EaseBackInOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionEase_prototype, jsb_cocos2d_EaseBackInOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EaseBackInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EaseBackInOut_class; p->proto = jsb_cocos2d_EaseBackInOut_prototype; p->parentProto = jsb_cocos2d_ActionEase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ActionInstant_class; JSObject *jsb_cocos2d_ActionInstant_prototype; extern JSObject *jsb_cocos2d_FiniteTimeAction_prototype; void js_cocos2d_ActionInstant_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ActionInstant)", obj); } void js_register_cocos2dx_ActionInstant(JSContext *cx, JSObject *global) { jsb_cocos2d_ActionInstant_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ActionInstant_class->name = "ActionInstant"; jsb_cocos2d_ActionInstant_class->addProperty = JS_PropertyStub; jsb_cocos2d_ActionInstant_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ActionInstant_class->getProperty = JS_PropertyStub; jsb_cocos2d_ActionInstant_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ActionInstant_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ActionInstant_class->resolve = JS_ResolveStub; jsb_cocos2d_ActionInstant_class->convert = JS_ConvertStub; jsb_cocos2d_ActionInstant_class->finalize = js_cocos2d_ActionInstant_finalize; jsb_cocos2d_ActionInstant_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_ActionInstant_prototype = JS_InitClass( cx, global, jsb_cocos2d_FiniteTimeAction_prototype, jsb_cocos2d_ActionInstant_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ActionInstant", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ActionInstant_class; p->proto = jsb_cocos2d_ActionInstant_prototype; p->parentProto = jsb_cocos2d_FiniteTimeAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Show_class; JSObject *jsb_cocos2d_Show_prototype; JSBool js_cocos2dx_Show_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Show* ret = cocos2d::Show::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Show*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Show_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_Show_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Show)", obj); } void js_register_cocos2dx_Show(JSContext *cx, JSObject *global) { jsb_cocos2d_Show_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Show_class->name = "Show"; jsb_cocos2d_Show_class->addProperty = JS_PropertyStub; jsb_cocos2d_Show_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Show_class->getProperty = JS_PropertyStub; jsb_cocos2d_Show_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Show_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Show_class->resolve = JS_ResolveStub; jsb_cocos2d_Show_class->convert = JS_ConvertStub; jsb_cocos2d_Show_class->finalize = js_cocos2d_Show_finalize; jsb_cocos2d_Show_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Show_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Show_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_Show_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Show", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Show_class; p->proto = jsb_cocos2d_Show_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Hide_class; JSObject *jsb_cocos2d_Hide_prototype; JSBool js_cocos2dx_Hide_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Hide* ret = cocos2d::Hide::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Hide*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Hide_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_Hide_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Hide)", obj); } void js_register_cocos2dx_Hide(JSContext *cx, JSObject *global) { jsb_cocos2d_Hide_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Hide_class->name = "Hide"; jsb_cocos2d_Hide_class->addProperty = JS_PropertyStub; jsb_cocos2d_Hide_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Hide_class->getProperty = JS_PropertyStub; jsb_cocos2d_Hide_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Hide_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Hide_class->resolve = JS_ResolveStub; jsb_cocos2d_Hide_class->convert = JS_ConvertStub; jsb_cocos2d_Hide_class->finalize = js_cocos2d_Hide_finalize; jsb_cocos2d_Hide_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Hide_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Hide_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_Hide_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Hide", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Hide_class; p->proto = jsb_cocos2d_Hide_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ToggleVisibility_class; JSObject *jsb_cocos2d_ToggleVisibility_prototype; JSBool js_cocos2dx_ToggleVisibility_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ToggleVisibility* ret = cocos2d::ToggleVisibility::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ToggleVisibility*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ToggleVisibility_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_ToggleVisibility_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ToggleVisibility)", obj); } void js_register_cocos2dx_ToggleVisibility(JSContext *cx, JSObject *global) { jsb_cocos2d_ToggleVisibility_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ToggleVisibility_class->name = "ToggleVisibility"; jsb_cocos2d_ToggleVisibility_class->addProperty = JS_PropertyStub; jsb_cocos2d_ToggleVisibility_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ToggleVisibility_class->getProperty = JS_PropertyStub; jsb_cocos2d_ToggleVisibility_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ToggleVisibility_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ToggleVisibility_class->resolve = JS_ResolveStub; jsb_cocos2d_ToggleVisibility_class->convert = JS_ConvertStub; jsb_cocos2d_ToggleVisibility_class->finalize = js_cocos2d_ToggleVisibility_finalize; jsb_cocos2d_ToggleVisibility_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ToggleVisibility_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ToggleVisibility_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_ToggleVisibility_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ToggleVisibility", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ToggleVisibility_class; p->proto = jsb_cocos2d_ToggleVisibility_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_RemoveSelf_class; JSObject *jsb_cocos2d_RemoveSelf_prototype; JSBool js_cocos2dx_RemoveSelf_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 0) { cocos2d::RemoveSelf* ret = cocos2d::RemoveSelf::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RemoveSelf*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RemoveSelf_create : Error processing arguments"); cocos2d::RemoveSelf* ret = cocos2d::RemoveSelf::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RemoveSelf*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RemoveSelf_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_RemoveSelf_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RemoveSelf)", obj); } void js_register_cocos2dx_RemoveSelf(JSContext *cx, JSObject *global) { jsb_cocos2d_RemoveSelf_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_RemoveSelf_class->name = "RemoveSelf"; jsb_cocos2d_RemoveSelf_class->addProperty = JS_PropertyStub; jsb_cocos2d_RemoveSelf_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_RemoveSelf_class->getProperty = JS_PropertyStub; jsb_cocos2d_RemoveSelf_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_RemoveSelf_class->enumerate = JS_EnumerateStub; jsb_cocos2d_RemoveSelf_class->resolve = JS_ResolveStub; jsb_cocos2d_RemoveSelf_class->convert = JS_ConvertStub; jsb_cocos2d_RemoveSelf_class->finalize = js_cocos2d_RemoveSelf_finalize; jsb_cocos2d_RemoveSelf_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_RemoveSelf_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_RemoveSelf_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_RemoveSelf_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "RemoveSelf", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_RemoveSelf_class; p->proto = jsb_cocos2d_RemoveSelf_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FlipX_class; JSObject *jsb_cocos2d_FlipX_prototype; JSBool js_cocos2dx_FlipX_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FlipX_create : Error processing arguments"); cocos2d::FlipX* ret = cocos2d::FlipX::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FlipX*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FlipX_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_FlipX_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FlipX)", obj); } void js_register_cocos2dx_FlipX(JSContext *cx, JSObject *global) { jsb_cocos2d_FlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FlipX_class->name = "FlipX"; jsb_cocos2d_FlipX_class->addProperty = JS_PropertyStub; jsb_cocos2d_FlipX_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FlipX_class->getProperty = JS_PropertyStub; jsb_cocos2d_FlipX_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FlipX_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FlipX_class->resolve = JS_ResolveStub; jsb_cocos2d_FlipX_class->convert = JS_ConvertStub; jsb_cocos2d_FlipX_class->finalize = js_cocos2d_FlipX_finalize; jsb_cocos2d_FlipX_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FlipX_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FlipX_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_FlipX_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FlipX_class; p->proto = jsb_cocos2d_FlipX_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FlipY_class; JSObject *jsb_cocos2d_FlipY_prototype; JSBool js_cocos2dx_FlipY_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FlipY_create : Error processing arguments"); cocos2d::FlipY* ret = cocos2d::FlipY::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FlipY*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FlipY_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_FlipY_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FlipY)", obj); } void js_register_cocos2dx_FlipY(JSContext *cx, JSObject *global) { jsb_cocos2d_FlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FlipY_class->name = "FlipY"; jsb_cocos2d_FlipY_class->addProperty = JS_PropertyStub; jsb_cocos2d_FlipY_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FlipY_class->getProperty = JS_PropertyStub; jsb_cocos2d_FlipY_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FlipY_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FlipY_class->resolve = JS_ResolveStub; jsb_cocos2d_FlipY_class->convert = JS_ConvertStub; jsb_cocos2d_FlipY_class->finalize = js_cocos2d_FlipY_finalize; jsb_cocos2d_FlipY_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FlipY_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FlipY_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_FlipY_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FlipY_class; p->proto = jsb_cocos2d_FlipY_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Place_class; JSObject *jsb_cocos2d_Place_prototype; JSBool js_cocos2dx_Place_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Place_create : Error processing arguments"); cocos2d::Place* ret = cocos2d::Place::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Place*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Place_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_Place_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Place)", obj); } void js_register_cocos2dx_Place(JSContext *cx, JSObject *global) { jsb_cocos2d_Place_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Place_class->name = "Place"; jsb_cocos2d_Place_class->addProperty = JS_PropertyStub; jsb_cocos2d_Place_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Place_class->getProperty = JS_PropertyStub; jsb_cocos2d_Place_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Place_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Place_class->resolve = JS_ResolveStub; jsb_cocos2d_Place_class->convert = JS_ConvertStub; jsb_cocos2d_Place_class->finalize = js_cocos2d_Place_finalize; jsb_cocos2d_Place_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Place_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Place_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_Place_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Place", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Place_class; p->proto = jsb_cocos2d_Place_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_CallFunc_class; JSObject *jsb_cocos2d_CallFunc_prototype; JSBool js_cocos2dx_CallFunc_execute(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CallFunc* cobj = (cocos2d::CallFunc *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_CallFunc_execute : Invalid Native Object"); if (argc == 0) { cobj->execute(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CallFunc_execute : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CallFunc_getTargetCallback(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CallFunc* cobj = (cocos2d::CallFunc *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_CallFunc_getTargetCallback : Invalid Native Object"); if (argc == 0) { cocos2d::Object* ret = cobj->getTargetCallback(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Object*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CallFunc_getTargetCallback : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CallFunc_setTargetCallback(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CallFunc* cobj = (cocos2d::CallFunc *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_CallFunc_setTargetCallback : Invalid Native Object"); if (argc == 1) { cocos2d::Object* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_CallFunc_setTargetCallback : Error processing arguments"); cobj->setTargetCallback(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CallFunc_setTargetCallback : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_CallFunc_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CallFunc)", obj); } void js_register_cocos2dx_CallFunc(JSContext *cx, JSObject *global) { jsb_cocos2d_CallFunc_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_CallFunc_class->name = "CallFunc"; jsb_cocos2d_CallFunc_class->addProperty = JS_PropertyStub; jsb_cocos2d_CallFunc_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_CallFunc_class->getProperty = JS_PropertyStub; jsb_cocos2d_CallFunc_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_CallFunc_class->enumerate = JS_EnumerateStub; jsb_cocos2d_CallFunc_class->resolve = JS_ResolveStub; jsb_cocos2d_CallFunc_class->convert = JS_ConvertStub; jsb_cocos2d_CallFunc_class->finalize = js_cocos2d_CallFunc_finalize; jsb_cocos2d_CallFunc_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("execute", js_cocos2dx_CallFunc_execute, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTargetCallback", js_cocos2dx_CallFunc_getTargetCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTargetCallback", js_cocos2dx_CallFunc_setTargetCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_CallFunc_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_CallFunc_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "CallFunc", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_CallFunc_class; p->proto = jsb_cocos2d_CallFunc_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_GridAction_class; JSObject *jsb_cocos2d_GridAction_prototype; JSBool js_cocos2dx_GridAction_getGrid(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridAction* cobj = (cocos2d::GridAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridAction_getGrid : Invalid Native Object"); if (argc == 0) { cocos2d::GridBase* ret = cobj->getGrid(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridAction_getGrid : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_GridAction_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (GridAction)", obj); } void js_register_cocos2dx_GridAction(JSContext *cx, JSObject *global) { jsb_cocos2d_GridAction_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_GridAction_class->name = "GridAction"; jsb_cocos2d_GridAction_class->addProperty = JS_PropertyStub; jsb_cocos2d_GridAction_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_GridAction_class->getProperty = JS_PropertyStub; jsb_cocos2d_GridAction_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_GridAction_class->enumerate = JS_EnumerateStub; jsb_cocos2d_GridAction_class->resolve = JS_ResolveStub; jsb_cocos2d_GridAction_class->convert = JS_ConvertStub; jsb_cocos2d_GridAction_class->finalize = js_cocos2d_GridAction_finalize; jsb_cocos2d_GridAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getGrid", js_cocos2dx_GridAction_getGrid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_GridAction_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_GridAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "GridAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_GridAction_class; p->proto = jsb_cocos2d_GridAction_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Grid3DAction_class; JSObject *jsb_cocos2d_Grid3DAction_prototype; JSBool js_cocos2dx_Grid3DAction_getGrid(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Grid3DAction* cobj = (cocos2d::Grid3DAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Grid3DAction_getGrid : Invalid Native Object"); if (argc == 0) { cocos2d::GridBase* ret = cobj->getGrid(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Grid3DAction_getGrid : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_GridAction_prototype; void js_cocos2d_Grid3DAction_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Grid3DAction)", obj); } void js_register_cocos2dx_Grid3DAction(JSContext *cx, JSObject *global) { jsb_cocos2d_Grid3DAction_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Grid3DAction_class->name = "Grid3DAction"; jsb_cocos2d_Grid3DAction_class->addProperty = JS_PropertyStub; jsb_cocos2d_Grid3DAction_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Grid3DAction_class->getProperty = JS_PropertyStub; jsb_cocos2d_Grid3DAction_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Grid3DAction_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Grid3DAction_class->resolve = JS_ResolveStub; jsb_cocos2d_Grid3DAction_class->convert = JS_ConvertStub; jsb_cocos2d_Grid3DAction_class->finalize = js_cocos2d_Grid3DAction_finalize; jsb_cocos2d_Grid3DAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getGrid", js_cocos2dx_Grid3DAction_getGrid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Grid3DAction_prototype = JS_InitClass( cx, global, jsb_cocos2d_GridAction_prototype, jsb_cocos2d_Grid3DAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Grid3DAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Grid3DAction_class; p->proto = jsb_cocos2d_Grid3DAction_prototype; p->parentProto = jsb_cocos2d_GridAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TiledGrid3DAction_class; JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; JSBool js_cocos2dx_TiledGrid3DAction_getGrid(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TiledGrid3DAction* cobj = (cocos2d::TiledGrid3DAction *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TiledGrid3DAction_getGrid : Invalid Native Object"); if (argc == 0) { cocos2d::GridBase* ret = cobj->getGrid(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TiledGrid3DAction_getGrid : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_GridAction_prototype; void js_cocos2d_TiledGrid3DAction_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TiledGrid3DAction)", obj); } void js_register_cocos2dx_TiledGrid3DAction(JSContext *cx, JSObject *global) { jsb_cocos2d_TiledGrid3DAction_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TiledGrid3DAction_class->name = "TiledGrid3DAction"; jsb_cocos2d_TiledGrid3DAction_class->addProperty = JS_PropertyStub; jsb_cocos2d_TiledGrid3DAction_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TiledGrid3DAction_class->getProperty = JS_PropertyStub; jsb_cocos2d_TiledGrid3DAction_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TiledGrid3DAction_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TiledGrid3DAction_class->resolve = JS_ResolveStub; jsb_cocos2d_TiledGrid3DAction_class->convert = JS_ConvertStub; jsb_cocos2d_TiledGrid3DAction_class->finalize = js_cocos2d_TiledGrid3DAction_finalize; jsb_cocos2d_TiledGrid3DAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getGrid", js_cocos2dx_TiledGrid3DAction_getGrid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_TiledGrid3DAction_prototype = JS_InitClass( cx, global, jsb_cocos2d_GridAction_prototype, jsb_cocos2d_TiledGrid3DAction_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TiledGrid3DAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TiledGrid3DAction_class; p->proto = jsb_cocos2d_TiledGrid3DAction_prototype; p->parentProto = jsb_cocos2d_GridAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_StopGrid_class; JSObject *jsb_cocos2d_StopGrid_prototype; JSBool js_cocos2dx_StopGrid_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::StopGrid* ret = cocos2d::StopGrid::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::StopGrid*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_StopGrid_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_StopGrid_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (StopGrid)", obj); } void js_register_cocos2dx_StopGrid(JSContext *cx, JSObject *global) { jsb_cocos2d_StopGrid_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_StopGrid_class->name = "StopGrid"; jsb_cocos2d_StopGrid_class->addProperty = JS_PropertyStub; jsb_cocos2d_StopGrid_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_StopGrid_class->getProperty = JS_PropertyStub; jsb_cocos2d_StopGrid_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_StopGrid_class->enumerate = JS_EnumerateStub; jsb_cocos2d_StopGrid_class->resolve = JS_ResolveStub; jsb_cocos2d_StopGrid_class->convert = JS_ConvertStub; jsb_cocos2d_StopGrid_class->finalize = js_cocos2d_StopGrid_finalize; jsb_cocos2d_StopGrid_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_StopGrid_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_StopGrid_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_StopGrid_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "StopGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_StopGrid_class; p->proto = jsb_cocos2d_StopGrid_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ReuseGrid_class; JSObject *jsb_cocos2d_ReuseGrid_prototype; JSBool js_cocos2dx_ReuseGrid_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ReuseGrid_create : Error processing arguments"); cocos2d::ReuseGrid* ret = cocos2d::ReuseGrid::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ReuseGrid*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ReuseGrid_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInstant_prototype; void js_cocos2d_ReuseGrid_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ReuseGrid)", obj); } void js_register_cocos2dx_ReuseGrid(JSContext *cx, JSObject *global) { jsb_cocos2d_ReuseGrid_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ReuseGrid_class->name = "ReuseGrid"; jsb_cocos2d_ReuseGrid_class->addProperty = JS_PropertyStub; jsb_cocos2d_ReuseGrid_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ReuseGrid_class->getProperty = JS_PropertyStub; jsb_cocos2d_ReuseGrid_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ReuseGrid_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ReuseGrid_class->resolve = JS_ResolveStub; jsb_cocos2d_ReuseGrid_class->convert = JS_ConvertStub; jsb_cocos2d_ReuseGrid_class->finalize = js_cocos2d_ReuseGrid_finalize; jsb_cocos2d_ReuseGrid_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ReuseGrid_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ReuseGrid_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInstant_prototype, jsb_cocos2d_ReuseGrid_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ReuseGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ReuseGrid_class; p->proto = jsb_cocos2d_ReuseGrid_prototype; p->parentProto = jsb_cocos2d_ActionInstant_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Waves3D_class; JSObject *jsb_cocos2d_Waves3D_prototype; JSBool js_cocos2dx_Waves3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Waves3D_getAmplitudeRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitudeRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves3D_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Waves3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Waves3D_setAmplitude : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Waves3D_setAmplitude : Error processing arguments"); cobj->setAmplitude(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves3D_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Waves3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Waves3D_setAmplitudeRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Waves3D_setAmplitudeRate : Error processing arguments"); cobj->setAmplitudeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves3D_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Waves3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Waves3D_getAmplitude : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitude(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves3D_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Waves3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_uint32(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Waves3D_create : Error processing arguments"); cocos2d::Waves3D* ret = cocos2d::Waves3D::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Waves3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_Waves3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Waves3D)", obj); } void js_register_cocos2dx_Waves3D(JSContext *cx, JSObject *global) { jsb_cocos2d_Waves3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Waves3D_class->name = "Waves3D"; jsb_cocos2d_Waves3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_Waves3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Waves3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_Waves3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Waves3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Waves3D_class->resolve = JS_ResolveStub; jsb_cocos2d_Waves3D_class->convert = JS_ConvertStub; jsb_cocos2d_Waves3D_class->finalize = js_cocos2d_Waves3D_finalize; jsb_cocos2d_Waves3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAmplitudeRate", js_cocos2dx_Waves3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitude", js_cocos2dx_Waves3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitudeRate", js_cocos2dx_Waves3D_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitude", js_cocos2dx_Waves3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Waves3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Waves3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_Waves3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Waves3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Waves3D_class; p->proto = jsb_cocos2d_Waves3D_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FlipX3D_class; JSObject *jsb_cocos2d_FlipX3D_prototype; JSBool js_cocos2dx_FlipX3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FlipX3D_create : Error processing arguments"); cocos2d::FlipX3D* ret = cocos2d::FlipX3D::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FlipX3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FlipX3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_FlipX3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FlipX3D)", obj); } void js_register_cocos2dx_FlipX3D(JSContext *cx, JSObject *global) { jsb_cocos2d_FlipX3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FlipX3D_class->name = "FlipX3D"; jsb_cocos2d_FlipX3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_FlipX3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FlipX3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_FlipX3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FlipX3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FlipX3D_class->resolve = JS_ResolveStub; jsb_cocos2d_FlipX3D_class->convert = JS_ConvertStub; jsb_cocos2d_FlipX3D_class->finalize = js_cocos2d_FlipX3D_finalize; jsb_cocos2d_FlipX3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FlipX3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FlipX3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_FlipX3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FlipX3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FlipX3D_class; p->proto = jsb_cocos2d_FlipX3D_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FlipY3D_class; JSObject *jsb_cocos2d_FlipY3D_prototype; JSBool js_cocos2dx_FlipY3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FlipY3D_create : Error processing arguments"); cocos2d::FlipY3D* ret = cocos2d::FlipY3D::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FlipY3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FlipY3D_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_FlipY3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::FlipY3D* cobj = new cocos2d::FlipY3D(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipY3D"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FlipY3D_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_FlipX3D_prototype; void js_cocos2d_FlipY3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FlipY3D)", obj); } void js_register_cocos2dx_FlipY3D(JSContext *cx, JSObject *global) { jsb_cocos2d_FlipY3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FlipY3D_class->name = "FlipY3D"; jsb_cocos2d_FlipY3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_FlipY3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FlipY3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_FlipY3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FlipY3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FlipY3D_class->resolve = JS_ResolveStub; jsb_cocos2d_FlipY3D_class->convert = JS_ConvertStub; jsb_cocos2d_FlipY3D_class->finalize = js_cocos2d_FlipY3D_finalize; jsb_cocos2d_FlipY3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FlipY3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FlipY3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_FlipX3D_prototype, jsb_cocos2d_FlipY3D_class, js_cocos2dx_FlipY3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FlipY3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FlipY3D_class; p->proto = jsb_cocos2d_FlipY3D_prototype; p->parentProto = jsb_cocos2d_FlipX3D_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Lens3D_class; JSObject *jsb_cocos2d_Lens3D_prototype; JSBool js_cocos2dx_Lens3D_setPosition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Lens3D_setPosition : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Lens3D_setPosition : Error processing arguments"); cobj->setPosition(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Lens3D_setPosition : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Lens3D_setConcave(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Lens3D_setConcave : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Lens3D_setConcave : Error processing arguments"); cobj->setConcave(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Lens3D_setConcave : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Lens3D_setLensEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Lens3D_setLensEffect : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Lens3D_setLensEffect : Error processing arguments"); cobj->setLensEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Lens3D_setLensEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Lens3D_getPosition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Lens3D_getPosition : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getPosition(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Lens3D_getPosition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Lens3D_getLensEffect(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Lens3D_getLensEffect : Invalid Native Object"); if (argc == 0) { double ret = cobj->getLensEffect(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Lens3D_getLensEffect : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Lens3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Size arg1; cocos2d::Point arg2; double arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Lens3D_create : Error processing arguments"); cocos2d::Lens3D* ret = cocos2d::Lens3D::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Lens3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Lens3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_Lens3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Lens3D)", obj); } void js_register_cocos2dx_Lens3D(JSContext *cx, JSObject *global) { jsb_cocos2d_Lens3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Lens3D_class->name = "Lens3D"; jsb_cocos2d_Lens3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_Lens3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Lens3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_Lens3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Lens3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Lens3D_class->resolve = JS_ResolveStub; jsb_cocos2d_Lens3D_class->convert = JS_ConvertStub; jsb_cocos2d_Lens3D_class->finalize = js_cocos2d_Lens3D_finalize; jsb_cocos2d_Lens3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setPosition", js_cocos2dx_Lens3D_setPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setConcave", js_cocos2dx_Lens3D_setConcave, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLensEffect", js_cocos2dx_Lens3D_setLensEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPosition", js_cocos2dx_Lens3D_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLensEffect", js_cocos2dx_Lens3D_getLensEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Lens3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Lens3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_Lens3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Lens3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Lens3D_class; p->proto = jsb_cocos2d_Lens3D_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Ripple3D_class; JSObject *jsb_cocos2d_Ripple3D_prototype; JSBool js_cocos2dx_Ripple3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Ripple3D_setAmplitudeRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Ripple3D_setAmplitudeRate : Error processing arguments"); cobj->setAmplitudeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Ripple3D_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Ripple3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Ripple3D_getAmplitudeRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitudeRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Ripple3D_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Ripple3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Ripple3D_setAmplitude : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Ripple3D_setAmplitude : Error processing arguments"); cobj->setAmplitude(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Ripple3D_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Ripple3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Ripple3D_getAmplitude : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitude(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Ripple3D_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Ripple3D_setPosition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Ripple3D_setPosition : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Ripple3D_setPosition : Error processing arguments"); cobj->setPosition(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Ripple3D_setPosition : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Ripple3D_getPosition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Ripple3D_getPosition : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getPosition(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Ripple3D_getPosition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Ripple3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 6) { double arg0; cocos2d::Size arg1; cocos2d::Point arg2; double arg3; unsigned int arg4; double arg5; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); ok &= jsval_to_uint32(cx, argv[4], &arg4); ok &= JS_ValueToNumber(cx, argv[5], &arg5); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Ripple3D_create : Error processing arguments"); cocos2d::Ripple3D* ret = cocos2d::Ripple3D::create(arg0, arg1, arg2, arg3, arg4, arg5); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Ripple3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Ripple3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_Ripple3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Ripple3D)", obj); } void js_register_cocos2dx_Ripple3D(JSContext *cx, JSObject *global) { jsb_cocos2d_Ripple3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Ripple3D_class->name = "Ripple3D"; jsb_cocos2d_Ripple3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_Ripple3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Ripple3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_Ripple3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Ripple3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Ripple3D_class->resolve = JS_ResolveStub; jsb_cocos2d_Ripple3D_class->convert = JS_ConvertStub; jsb_cocos2d_Ripple3D_class->finalize = js_cocos2d_Ripple3D_finalize; jsb_cocos2d_Ripple3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setAmplitudeRate", js_cocos2dx_Ripple3D_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitudeRate", js_cocos2dx_Ripple3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitude", js_cocos2dx_Ripple3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitude", js_cocos2dx_Ripple3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPosition", js_cocos2dx_Ripple3D_setPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPosition", js_cocos2dx_Ripple3D_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Ripple3D_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Ripple3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_Ripple3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Ripple3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Ripple3D_class; p->proto = jsb_cocos2d_Ripple3D_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Shaky3D_class; JSObject *jsb_cocos2d_Shaky3D_prototype; JSBool js_cocos2dx_Shaky3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Size arg1; int arg2; JSBool arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= JS_ValueToBoolean(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Shaky3D_create : Error processing arguments"); cocos2d::Shaky3D* ret = cocos2d::Shaky3D::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Shaky3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Shaky3D_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Shaky3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Shaky3D* cobj = new cocos2d::Shaky3D(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Shaky3D"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Shaky3D_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_Shaky3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Shaky3D)", obj); } void js_register_cocos2dx_Shaky3D(JSContext *cx, JSObject *global) { jsb_cocos2d_Shaky3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Shaky3D_class->name = "Shaky3D"; jsb_cocos2d_Shaky3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_Shaky3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Shaky3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_Shaky3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Shaky3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Shaky3D_class->resolve = JS_ResolveStub; jsb_cocos2d_Shaky3D_class->convert = JS_ConvertStub; jsb_cocos2d_Shaky3D_class->finalize = js_cocos2d_Shaky3D_finalize; jsb_cocos2d_Shaky3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Shaky3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Shaky3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_Shaky3D_class, js_cocos2dx_Shaky3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Shaky3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Shaky3D_class; p->proto = jsb_cocos2d_Shaky3D_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Liquid_class; JSObject *jsb_cocos2d_Liquid_prototype; JSBool js_cocos2dx_Liquid_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Liquid_getAmplitudeRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitudeRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Liquid_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Liquid_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Liquid_setAmplitude : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Liquid_setAmplitude : Error processing arguments"); cobj->setAmplitude(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Liquid_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Liquid_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Liquid_getAmplitude : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitude(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Liquid_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Liquid_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Liquid_setAmplitudeRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Liquid_setAmplitudeRate : Error processing arguments"); cobj->setAmplitudeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Liquid_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Liquid_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_uint32(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Liquid_create : Error processing arguments"); cocos2d::Liquid* ret = cocos2d::Liquid::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Liquid*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Liquid_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Liquid_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Liquid* cobj = new cocos2d::Liquid(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Liquid"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Liquid_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_Liquid_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Liquid)", obj); } void js_register_cocos2dx_Liquid(JSContext *cx, JSObject *global) { jsb_cocos2d_Liquid_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Liquid_class->name = "Liquid"; jsb_cocos2d_Liquid_class->addProperty = JS_PropertyStub; jsb_cocos2d_Liquid_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Liquid_class->getProperty = JS_PropertyStub; jsb_cocos2d_Liquid_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Liquid_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Liquid_class->resolve = JS_ResolveStub; jsb_cocos2d_Liquid_class->convert = JS_ConvertStub; jsb_cocos2d_Liquid_class->finalize = js_cocos2d_Liquid_finalize; jsb_cocos2d_Liquid_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAmplitudeRate", js_cocos2dx_Liquid_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitude", js_cocos2dx_Liquid_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitude", js_cocos2dx_Liquid_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitudeRate", js_cocos2dx_Liquid_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Liquid_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Liquid_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_Liquid_class, js_cocos2dx_Liquid_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Liquid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Liquid_class; p->proto = jsb_cocos2d_Liquid_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Waves_class; JSObject *jsb_cocos2d_Waves_prototype; JSBool js_cocos2dx_Waves_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Waves_getAmplitudeRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitudeRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Waves_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Waves_setAmplitude : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Waves_setAmplitude : Error processing arguments"); cobj->setAmplitude(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Waves_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Waves_getAmplitude : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitude(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Waves_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Waves_setAmplitudeRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Waves_setAmplitudeRate : Error processing arguments"); cobj->setAmplitudeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Waves_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 6) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; JSBool arg4; JSBool arg5; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_uint32(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); ok &= JS_ValueToBoolean(cx, argv[4], &arg4); ok &= JS_ValueToBoolean(cx, argv[5], &arg5); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Waves_create : Error processing arguments"); cocos2d::Waves* ret = cocos2d::Waves::create(arg0, arg1, arg2, arg3, arg4, arg5); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Waves*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Waves_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Waves* cobj = new cocos2d::Waves(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Waves"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Waves_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_Waves_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Waves)", obj); } void js_register_cocos2dx_Waves(JSContext *cx, JSObject *global) { jsb_cocos2d_Waves_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Waves_class->name = "Waves"; jsb_cocos2d_Waves_class->addProperty = JS_PropertyStub; jsb_cocos2d_Waves_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Waves_class->getProperty = JS_PropertyStub; jsb_cocos2d_Waves_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Waves_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Waves_class->resolve = JS_ResolveStub; jsb_cocos2d_Waves_class->convert = JS_ConvertStub; jsb_cocos2d_Waves_class->finalize = js_cocos2d_Waves_finalize; jsb_cocos2d_Waves_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAmplitudeRate", js_cocos2dx_Waves_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitude", js_cocos2dx_Waves_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitude", js_cocos2dx_Waves_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitudeRate", js_cocos2dx_Waves_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Waves_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Waves_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_Waves_class, js_cocos2dx_Waves_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Waves", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Waves_class; p->proto = jsb_cocos2d_Waves_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Twirl_class; JSObject *jsb_cocos2d_Twirl_prototype; JSBool js_cocos2dx_Twirl_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Twirl_setAmplitudeRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Twirl_setAmplitudeRate : Error processing arguments"); cobj->setAmplitudeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Twirl_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Twirl_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Twirl_getAmplitudeRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitudeRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Twirl_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Twirl_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Twirl_setAmplitude : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Twirl_setAmplitude : Error processing arguments"); cobj->setAmplitude(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Twirl_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Twirl_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Twirl_getAmplitude : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitude(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Twirl_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Twirl_setPosition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Twirl_setPosition : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Twirl_setPosition : Error processing arguments"); cobj->setPosition(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Twirl_setPosition : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Twirl_getPosition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Twirl_getPosition : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getPosition(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Twirl_getPosition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Twirl_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 5) { double arg0; cocos2d::Size arg1; cocos2d::Point arg2; unsigned int arg3; double arg4; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); ok &= jsval_to_uint32(cx, argv[3], &arg3); ok &= JS_ValueToNumber(cx, argv[4], &arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Twirl_create : Error processing arguments"); cocos2d::Twirl* ret = cocos2d::Twirl::create(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Twirl*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Twirl_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Twirl_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Twirl* cobj = new cocos2d::Twirl(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Twirl"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Twirl_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_Twirl_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Twirl)", obj); } void js_register_cocos2dx_Twirl(JSContext *cx, JSObject *global) { jsb_cocos2d_Twirl_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Twirl_class->name = "Twirl"; jsb_cocos2d_Twirl_class->addProperty = JS_PropertyStub; jsb_cocos2d_Twirl_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Twirl_class->getProperty = JS_PropertyStub; jsb_cocos2d_Twirl_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Twirl_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Twirl_class->resolve = JS_ResolveStub; jsb_cocos2d_Twirl_class->convert = JS_ConvertStub; jsb_cocos2d_Twirl_class->finalize = js_cocos2d_Twirl_finalize; jsb_cocos2d_Twirl_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setAmplitudeRate", js_cocos2dx_Twirl_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitudeRate", js_cocos2dx_Twirl_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitude", js_cocos2dx_Twirl_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitude", js_cocos2dx_Twirl_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPosition", js_cocos2dx_Twirl_setPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPosition", js_cocos2dx_Twirl_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Twirl_create, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Twirl_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_Twirl_class, js_cocos2dx_Twirl_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Twirl", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Twirl_class; p->proto = jsb_cocos2d_Twirl_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_PageTurn3D_class; JSObject *jsb_cocos2d_PageTurn3D_prototype; JSBool js_cocos2dx_PageTurn3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_PageTurn3D_create : Error processing arguments"); cocos2d::PageTurn3D* ret = cocos2d::PageTurn3D::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::PageTurn3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_PageTurn3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Grid3DAction_prototype; void js_cocos2d_PageTurn3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PageTurn3D)", obj); } void js_register_cocos2dx_PageTurn3D(JSContext *cx, JSObject *global) { jsb_cocos2d_PageTurn3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_PageTurn3D_class->name = "PageTurn3D"; jsb_cocos2d_PageTurn3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_PageTurn3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_PageTurn3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_PageTurn3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_PageTurn3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_PageTurn3D_class->resolve = JS_ResolveStub; jsb_cocos2d_PageTurn3D_class->convert = JS_ConvertStub; jsb_cocos2d_PageTurn3D_class->finalize = js_cocos2d_PageTurn3D_finalize; jsb_cocos2d_PageTurn3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_PageTurn3D_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_PageTurn3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_Grid3DAction_prototype, jsb_cocos2d_PageTurn3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "PageTurn3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_PageTurn3D_class; p->proto = jsb_cocos2d_PageTurn3D_prototype; p->parentProto = jsb_cocos2d_Grid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ProgressTo_class; JSObject *jsb_cocos2d_ProgressTo_prototype; JSBool js_cocos2dx_ProgressTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; double arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ProgressTo_create : Error processing arguments"); cocos2d::ProgressTo* ret = cocos2d::ProgressTo::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ProgressTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ProgressTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProgressTo)", obj); } void js_register_cocos2dx_ProgressTo(JSContext *cx, JSObject *global) { jsb_cocos2d_ProgressTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ProgressTo_class->name = "ProgressTo"; jsb_cocos2d_ProgressTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_ProgressTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ProgressTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_ProgressTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ProgressTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ProgressTo_class->resolve = JS_ResolveStub; jsb_cocos2d_ProgressTo_class->convert = JS_ConvertStub; jsb_cocos2d_ProgressTo_class->finalize = js_cocos2d_ProgressTo_finalize; jsb_cocos2d_ProgressTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ProgressTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ProgressTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_ProgressTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProgressTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ProgressTo_class; p->proto = jsb_cocos2d_ProgressTo_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ProgressFromTo_class; JSObject *jsb_cocos2d_ProgressFromTo_prototype; JSBool js_cocos2dx_ProgressFromTo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { double arg0; double arg1; double arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ProgressFromTo_create : Error processing arguments"); cocos2d::ProgressFromTo* ret = cocos2d::ProgressFromTo::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ProgressFromTo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressFromTo_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ProgressFromTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProgressFromTo)", obj); } void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JSObject *global) { jsb_cocos2d_ProgressFromTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ProgressFromTo_class->name = "ProgressFromTo"; jsb_cocos2d_ProgressFromTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_ProgressFromTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ProgressFromTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_ProgressFromTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ProgressFromTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ProgressFromTo_class->resolve = JS_ResolveStub; jsb_cocos2d_ProgressFromTo_class->convert = JS_ConvertStub; jsb_cocos2d_ProgressFromTo_class->finalize = js_cocos2d_ProgressFromTo_finalize; jsb_cocos2d_ProgressFromTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ProgressFromTo_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ProgressFromTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_ProgressFromTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProgressFromTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ProgressFromTo_class; p->proto = jsb_cocos2d_ProgressFromTo_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ShakyTiles3D_class; JSObject *jsb_cocos2d_ShakyTiles3D_prototype; JSBool js_cocos2dx_ShakyTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Size arg1; int arg2; JSBool arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= JS_ValueToBoolean(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ShakyTiles3D_create : Error processing arguments"); cocos2d::ShakyTiles3D* ret = cocos2d::ShakyTiles3D::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ShakyTiles3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShakyTiles3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_ShakyTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ShakyTiles3D)", obj); } void js_register_cocos2dx_ShakyTiles3D(JSContext *cx, JSObject *global) { jsb_cocos2d_ShakyTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ShakyTiles3D_class->name = "ShakyTiles3D"; jsb_cocos2d_ShakyTiles3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_ShakyTiles3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ShakyTiles3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_ShakyTiles3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ShakyTiles3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ShakyTiles3D_class->resolve = JS_ResolveStub; jsb_cocos2d_ShakyTiles3D_class->convert = JS_ConvertStub; jsb_cocos2d_ShakyTiles3D_class->finalize = js_cocos2d_ShakyTiles3D_finalize; jsb_cocos2d_ShakyTiles3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ShakyTiles3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ShakyTiles3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_ShakyTiles3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ShakyTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ShakyTiles3D_class; p->proto = jsb_cocos2d_ShakyTiles3D_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ShatteredTiles3D_class; JSObject *jsb_cocos2d_ShatteredTiles3D_prototype; JSBool js_cocos2dx_ShatteredTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Size arg1; int arg2; JSBool arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= JS_ValueToBoolean(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ShatteredTiles3D_create : Error processing arguments"); cocos2d::ShatteredTiles3D* ret = cocos2d::ShatteredTiles3D::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ShatteredTiles3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShatteredTiles3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_ShatteredTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ShatteredTiles3D)", obj); } void js_register_cocos2dx_ShatteredTiles3D(JSContext *cx, JSObject *global) { jsb_cocos2d_ShatteredTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ShatteredTiles3D_class->name = "ShatteredTiles3D"; jsb_cocos2d_ShatteredTiles3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_ShatteredTiles3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ShatteredTiles3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_ShatteredTiles3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ShatteredTiles3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ShatteredTiles3D_class->resolve = JS_ResolveStub; jsb_cocos2d_ShatteredTiles3D_class->convert = JS_ConvertStub; jsb_cocos2d_ShatteredTiles3D_class->finalize = js_cocos2d_ShatteredTiles3D_finalize; jsb_cocos2d_ShatteredTiles3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ShatteredTiles3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ShatteredTiles3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_ShatteredTiles3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ShatteredTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ShatteredTiles3D_class; p->proto = jsb_cocos2d_ShatteredTiles3D_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ShuffleTiles_class; JSObject *jsb_cocos2d_ShuffleTiles_prototype; JSBool js_cocos2dx_ShuffleTiles_placeTile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ShuffleTiles* cobj = (cocos2d::ShuffleTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ShuffleTiles_placeTile : Invalid Native Object"); if (argc == 2) { cocos2d::Point arg0; cocos2d::Tile* arg1; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); #pragma warning NO CONVERSION TO NATIVE FOR Tile*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ShuffleTiles_placeTile : Error processing arguments"); cobj->placeTile(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_placeTile : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ShuffleTiles_shuffle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ShuffleTiles* cobj = (cocos2d::ShuffleTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ShuffleTiles_shuffle : Invalid Native Object"); if (argc == 2) { unsigned int* arg0; unsigned int arg1; #pragma warning NO CONVERSION TO NATIVE FOR unsigned int*; ok &= jsval_to_uint32(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ShuffleTiles_shuffle : Error processing arguments"); cobj->shuffle(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_shuffle : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ShuffleTiles_getDelta(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ShuffleTiles* cobj = (cocos2d::ShuffleTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ShuffleTiles_getDelta : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ShuffleTiles_getDelta : Error processing arguments"); cocos2d::Size ret = cobj->getDelta(arg0); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_getDelta : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ShuffleTiles_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { double arg0; cocos2d::Size arg1; unsigned int arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_uint32(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ShuffleTiles_create : Error processing arguments"); cocos2d::ShuffleTiles* ret = cocos2d::ShuffleTiles::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ShuffleTiles*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_ShuffleTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ShuffleTiles)", obj); } void js_register_cocos2dx_ShuffleTiles(JSContext *cx, JSObject *global) { jsb_cocos2d_ShuffleTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ShuffleTiles_class->name = "ShuffleTiles"; jsb_cocos2d_ShuffleTiles_class->addProperty = JS_PropertyStub; jsb_cocos2d_ShuffleTiles_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ShuffleTiles_class->getProperty = JS_PropertyStub; jsb_cocos2d_ShuffleTiles_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ShuffleTiles_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ShuffleTiles_class->resolve = JS_ResolveStub; jsb_cocos2d_ShuffleTiles_class->convert = JS_ConvertStub; jsb_cocos2d_ShuffleTiles_class->finalize = js_cocos2d_ShuffleTiles_finalize; jsb_cocos2d_ShuffleTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("placeTile", js_cocos2dx_ShuffleTiles_placeTile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("shuffle", js_cocos2dx_ShuffleTiles_shuffle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDelta", js_cocos2dx_ShuffleTiles_getDelta, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ShuffleTiles_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ShuffleTiles_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_ShuffleTiles_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ShuffleTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ShuffleTiles_class; p->proto = jsb_cocos2d_ShuffleTiles_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FadeOutTRTiles_class; JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; JSBool js_cocos2dx_FadeOutTRTiles_turnOnTile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FadeOutTRTiles* cobj = (cocos2d::FadeOutTRTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_turnOnTile : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_turnOnTile : Error processing arguments"); cobj->turnOnTile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_turnOnTile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FadeOutTRTiles_turnOffTile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FadeOutTRTiles* cobj = (cocos2d::FadeOutTRTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_turnOffTile : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_turnOffTile : Error processing arguments"); cobj->turnOffTile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_turnOffTile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FadeOutTRTiles_transformTile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FadeOutTRTiles* cobj = (cocos2d::FadeOutTRTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_transformTile : Invalid Native Object"); if (argc == 2) { cocos2d::Point arg0; double arg1; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_transformTile : Error processing arguments"); cobj->transformTile(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_transformTile : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_FadeOutTRTiles_testFunc(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FadeOutTRTiles* cobj = (cocos2d::FadeOutTRTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_testFunc : Invalid Native Object"); if (argc == 2) { cocos2d::Size arg0; double arg1; ok &= jsval_to_ccsize(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_testFunc : Error processing arguments"); double ret = cobj->testFunc(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_testFunc : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_FadeOutTRTiles_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutTRTiles_create : Error processing arguments"); cocos2d::FadeOutTRTiles* ret = cocos2d::FadeOutTRTiles::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FadeOutTRTiles*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_FadeOutTRTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutTRTiles)", obj); } void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JSObject *global) { jsb_cocos2d_FadeOutTRTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOutTRTiles_class->name = "FadeOutTRTiles"; jsb_cocos2d_FadeOutTRTiles_class->addProperty = JS_PropertyStub; jsb_cocos2d_FadeOutTRTiles_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FadeOutTRTiles_class->getProperty = JS_PropertyStub; jsb_cocos2d_FadeOutTRTiles_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FadeOutTRTiles_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FadeOutTRTiles_class->resolve = JS_ResolveStub; jsb_cocos2d_FadeOutTRTiles_class->convert = JS_ConvertStub; jsb_cocos2d_FadeOutTRTiles_class->finalize = js_cocos2d_FadeOutTRTiles_finalize; jsb_cocos2d_FadeOutTRTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("turnOnTile", js_cocos2dx_FadeOutTRTiles_turnOnTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("turnOffTile", js_cocos2dx_FadeOutTRTiles_turnOffTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("transformTile", js_cocos2dx_FadeOutTRTiles_transformTile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("testFunc", js_cocos2dx_FadeOutTRTiles_testFunc, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FadeOutTRTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FadeOutTRTiles_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_FadeOutTRTiles_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FadeOutTRTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FadeOutTRTiles_class; p->proto = jsb_cocos2d_FadeOutTRTiles_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FadeOutBLTiles_class; JSObject *jsb_cocos2d_FadeOutBLTiles_prototype; JSBool js_cocos2dx_FadeOutBLTiles_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutBLTiles_create : Error processing arguments"); cocos2d::FadeOutBLTiles* ret = cocos2d::FadeOutBLTiles::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FadeOutBLTiles*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutBLTiles_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; void js_cocos2d_FadeOutBLTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutBLTiles)", obj); } void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JSObject *global) { jsb_cocos2d_FadeOutBLTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOutBLTiles_class->name = "FadeOutBLTiles"; jsb_cocos2d_FadeOutBLTiles_class->addProperty = JS_PropertyStub; jsb_cocos2d_FadeOutBLTiles_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FadeOutBLTiles_class->getProperty = JS_PropertyStub; jsb_cocos2d_FadeOutBLTiles_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FadeOutBLTiles_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FadeOutBLTiles_class->resolve = JS_ResolveStub; jsb_cocos2d_FadeOutBLTiles_class->convert = JS_ConvertStub; jsb_cocos2d_FadeOutBLTiles_class->finalize = js_cocos2d_FadeOutBLTiles_finalize; jsb_cocos2d_FadeOutBLTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FadeOutBLTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FadeOutBLTiles_prototype = JS_InitClass( cx, global, jsb_cocos2d_FadeOutTRTiles_prototype, jsb_cocos2d_FadeOutBLTiles_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FadeOutBLTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FadeOutBLTiles_class; p->proto = jsb_cocos2d_FadeOutBLTiles_prototype; p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FadeOutUpTiles_class; JSObject *jsb_cocos2d_FadeOutUpTiles_prototype; JSBool js_cocos2dx_FadeOutUpTiles_transformTile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FadeOutUpTiles* cobj = (cocos2d::FadeOutUpTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FadeOutUpTiles_transformTile : Invalid Native Object"); if (argc == 2) { cocos2d::Point arg0; double arg1; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutUpTiles_transformTile : Error processing arguments"); cobj->transformTile(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutUpTiles_transformTile : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_FadeOutUpTiles_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutUpTiles_create : Error processing arguments"); cocos2d::FadeOutUpTiles* ret = cocos2d::FadeOutUpTiles::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FadeOutUpTiles*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutUpTiles_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; void js_cocos2d_FadeOutUpTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutUpTiles)", obj); } void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JSObject *global) { jsb_cocos2d_FadeOutUpTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOutUpTiles_class->name = "FadeOutUpTiles"; jsb_cocos2d_FadeOutUpTiles_class->addProperty = JS_PropertyStub; jsb_cocos2d_FadeOutUpTiles_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FadeOutUpTiles_class->getProperty = JS_PropertyStub; jsb_cocos2d_FadeOutUpTiles_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FadeOutUpTiles_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FadeOutUpTiles_class->resolve = JS_ResolveStub; jsb_cocos2d_FadeOutUpTiles_class->convert = JS_ConvertStub; jsb_cocos2d_FadeOutUpTiles_class->finalize = js_cocos2d_FadeOutUpTiles_finalize; jsb_cocos2d_FadeOutUpTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("transformTile", js_cocos2dx_FadeOutUpTiles_transformTile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FadeOutUpTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FadeOutUpTiles_prototype = JS_InitClass( cx, global, jsb_cocos2d_FadeOutTRTiles_prototype, jsb_cocos2d_FadeOutUpTiles_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FadeOutUpTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FadeOutUpTiles_class; p->proto = jsb_cocos2d_FadeOutUpTiles_prototype; p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FadeOutDownTiles_class; JSObject *jsb_cocos2d_FadeOutDownTiles_prototype; JSBool js_cocos2dx_FadeOutDownTiles_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FadeOutDownTiles_create : Error processing arguments"); cocos2d::FadeOutDownTiles* ret = cocos2d::FadeOutDownTiles::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FadeOutDownTiles*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FadeOutDownTiles_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_FadeOutUpTiles_prototype; void js_cocos2d_FadeOutDownTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutDownTiles)", obj); } void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JSObject *global) { jsb_cocos2d_FadeOutDownTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FadeOutDownTiles_class->name = "FadeOutDownTiles"; jsb_cocos2d_FadeOutDownTiles_class->addProperty = JS_PropertyStub; jsb_cocos2d_FadeOutDownTiles_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FadeOutDownTiles_class->getProperty = JS_PropertyStub; jsb_cocos2d_FadeOutDownTiles_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FadeOutDownTiles_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FadeOutDownTiles_class->resolve = JS_ResolveStub; jsb_cocos2d_FadeOutDownTiles_class->convert = JS_ConvertStub; jsb_cocos2d_FadeOutDownTiles_class->finalize = js_cocos2d_FadeOutDownTiles_finalize; jsb_cocos2d_FadeOutDownTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_FadeOutDownTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FadeOutDownTiles_prototype = JS_InitClass( cx, global, jsb_cocos2d_FadeOutUpTiles_prototype, jsb_cocos2d_FadeOutDownTiles_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FadeOutDownTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FadeOutDownTiles_class; p->proto = jsb_cocos2d_FadeOutDownTiles_prototype; p->parentProto = jsb_cocos2d_FadeOutUpTiles_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TurnOffTiles_class; JSObject *jsb_cocos2d_TurnOffTiles_prototype; JSBool js_cocos2dx_TurnOffTiles_turnOnTile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TurnOffTiles* cobj = (cocos2d::TurnOffTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TurnOffTiles_turnOnTile : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TurnOffTiles_turnOnTile : Error processing arguments"); cobj->turnOnTile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_turnOnTile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TurnOffTiles_turnOffTile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TurnOffTiles* cobj = (cocos2d::TurnOffTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TurnOffTiles_turnOffTile : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TurnOffTiles_turnOffTile : Error processing arguments"); cobj->turnOffTile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_turnOffTile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TurnOffTiles_shuffle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TurnOffTiles* cobj = (cocos2d::TurnOffTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TurnOffTiles_shuffle : Invalid Native Object"); if (argc == 2) { unsigned int* arg0; unsigned int arg1; #pragma warning NO CONVERSION TO NATIVE FOR unsigned int*; ok &= jsval_to_uint32(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TurnOffTiles_shuffle : Error processing arguments"); cobj->shuffle(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_shuffle : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_TurnOffTiles_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } unsigned int arg2; ok &= jsval_to_uint32(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TurnOffTiles* ret = cocos2d::TurnOffTiles::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TurnOffTiles*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::TurnOffTiles* ret = cocos2d::TurnOffTiles::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TurnOffTiles*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_TurnOffTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TurnOffTiles)", obj); } void js_register_cocos2dx_TurnOffTiles(JSContext *cx, JSObject *global) { jsb_cocos2d_TurnOffTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TurnOffTiles_class->name = "TurnOffTiles"; jsb_cocos2d_TurnOffTiles_class->addProperty = JS_PropertyStub; jsb_cocos2d_TurnOffTiles_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TurnOffTiles_class->getProperty = JS_PropertyStub; jsb_cocos2d_TurnOffTiles_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TurnOffTiles_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TurnOffTiles_class->resolve = JS_ResolveStub; jsb_cocos2d_TurnOffTiles_class->convert = JS_ConvertStub; jsb_cocos2d_TurnOffTiles_class->finalize = js_cocos2d_TurnOffTiles_finalize; jsb_cocos2d_TurnOffTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("turnOnTile", js_cocos2dx_TurnOffTiles_turnOnTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("turnOffTile", js_cocos2dx_TurnOffTiles_turnOffTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("shuffle", js_cocos2dx_TurnOffTiles_shuffle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TurnOffTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TurnOffTiles_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_TurnOffTiles_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TurnOffTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TurnOffTiles_class; p->proto = jsb_cocos2d_TurnOffTiles_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_WavesTiles3D_class; JSObject *jsb_cocos2d_WavesTiles3D_prototype; JSBool js_cocos2dx_WavesTiles3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_WavesTiles3D_getAmplitudeRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitudeRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_WavesTiles3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_WavesTiles3D_setAmplitude : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_WavesTiles3D_setAmplitude : Error processing arguments"); cobj->setAmplitude(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_WavesTiles3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_WavesTiles3D_setAmplitudeRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_WavesTiles3D_setAmplitudeRate : Error processing arguments"); cobj->setAmplitudeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_WavesTiles3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_WavesTiles3D_getAmplitude : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitude(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_WavesTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_uint32(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_WavesTiles3D_create : Error processing arguments"); cocos2d::WavesTiles3D* ret = cocos2d::WavesTiles3D::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::WavesTiles3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_WavesTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (WavesTiles3D)", obj); } void js_register_cocos2dx_WavesTiles3D(JSContext *cx, JSObject *global) { jsb_cocos2d_WavesTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_WavesTiles3D_class->name = "WavesTiles3D"; jsb_cocos2d_WavesTiles3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_WavesTiles3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_WavesTiles3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_WavesTiles3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_WavesTiles3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_WavesTiles3D_class->resolve = JS_ResolveStub; jsb_cocos2d_WavesTiles3D_class->convert = JS_ConvertStub; jsb_cocos2d_WavesTiles3D_class->finalize = js_cocos2d_WavesTiles3D_finalize; jsb_cocos2d_WavesTiles3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAmplitudeRate", js_cocos2dx_WavesTiles3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitude", js_cocos2dx_WavesTiles3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitudeRate", js_cocos2dx_WavesTiles3D_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitude", js_cocos2dx_WavesTiles3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_WavesTiles3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_WavesTiles3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_WavesTiles3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "WavesTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_WavesTiles3D_class; p->proto = jsb_cocos2d_WavesTiles3D_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_JumpTiles3D_class; JSObject *jsb_cocos2d_JumpTiles3D_prototype; JSBool js_cocos2dx_JumpTiles3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_JumpTiles3D_getAmplitudeRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitudeRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_JumpTiles3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_JumpTiles3D_setAmplitude : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_JumpTiles3D_setAmplitude : Error processing arguments"); cobj->setAmplitude(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_JumpTiles3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_JumpTiles3D_setAmplitudeRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_JumpTiles3D_setAmplitudeRate : Error processing arguments"); cobj->setAmplitudeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_JumpTiles3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_JumpTiles3D_getAmplitude : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAmplitude(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_JumpTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_ccsize(cx, argv[1], &arg1); ok &= jsval_to_uint32(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_JumpTiles3D_create : Error processing arguments"); cocos2d::JumpTiles3D* ret = cocos2d::JumpTiles3D::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::JumpTiles3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_JumpTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (JumpTiles3D)", obj); } void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JSObject *global) { jsb_cocos2d_JumpTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_JumpTiles3D_class->name = "JumpTiles3D"; jsb_cocos2d_JumpTiles3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_JumpTiles3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_JumpTiles3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_JumpTiles3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_JumpTiles3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_JumpTiles3D_class->resolve = JS_ResolveStub; jsb_cocos2d_JumpTiles3D_class->convert = JS_ConvertStub; jsb_cocos2d_JumpTiles3D_class->finalize = js_cocos2d_JumpTiles3D_finalize; jsb_cocos2d_JumpTiles3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAmplitudeRate", js_cocos2dx_JumpTiles3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitude", js_cocos2dx_JumpTiles3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAmplitudeRate", js_cocos2dx_JumpTiles3D_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAmplitude", js_cocos2dx_JumpTiles3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_JumpTiles3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_JumpTiles3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_JumpTiles3D_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "JumpTiles3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_JumpTiles3D_class; p->proto = jsb_cocos2d_JumpTiles3D_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_SplitRows_class; JSObject *jsb_cocos2d_SplitRows_prototype; JSBool js_cocos2dx_SplitRows_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; unsigned int arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_uint32(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SplitRows_create : Error processing arguments"); cocos2d::SplitRows* ret = cocos2d::SplitRows::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SplitRows*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SplitRows_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_SplitRows_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SplitRows)", obj); } void js_register_cocos2dx_SplitRows(JSContext *cx, JSObject *global) { jsb_cocos2d_SplitRows_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SplitRows_class->name = "SplitRows"; jsb_cocos2d_SplitRows_class->addProperty = JS_PropertyStub; jsb_cocos2d_SplitRows_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_SplitRows_class->getProperty = JS_PropertyStub; jsb_cocos2d_SplitRows_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_SplitRows_class->enumerate = JS_EnumerateStub; jsb_cocos2d_SplitRows_class->resolve = JS_ResolveStub; jsb_cocos2d_SplitRows_class->convert = JS_ConvertStub; jsb_cocos2d_SplitRows_class->finalize = js_cocos2d_SplitRows_finalize; jsb_cocos2d_SplitRows_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_SplitRows_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_SplitRows_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_SplitRows_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SplitRows", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_SplitRows_class; p->proto = jsb_cocos2d_SplitRows_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_SplitCols_class; JSObject *jsb_cocos2d_SplitCols_prototype; JSBool js_cocos2dx_SplitCols_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; unsigned int arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_uint32(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SplitCols_create : Error processing arguments"); cocos2d::SplitCols* ret = cocos2d::SplitCols::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SplitCols*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SplitCols_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; void js_cocos2d_SplitCols_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SplitCols)", obj); } void js_register_cocos2dx_SplitCols(JSContext *cx, JSObject *global) { jsb_cocos2d_SplitCols_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SplitCols_class->name = "SplitCols"; jsb_cocos2d_SplitCols_class->addProperty = JS_PropertyStub; jsb_cocos2d_SplitCols_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_SplitCols_class->getProperty = JS_PropertyStub; jsb_cocos2d_SplitCols_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_SplitCols_class->enumerate = JS_EnumerateStub; jsb_cocos2d_SplitCols_class->resolve = JS_ResolveStub; jsb_cocos2d_SplitCols_class->convert = JS_ConvertStub; jsb_cocos2d_SplitCols_class->finalize = js_cocos2d_SplitCols_finalize; jsb_cocos2d_SplitCols_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_SplitCols_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_SplitCols_prototype = JS_InitClass( cx, global, jsb_cocos2d_TiledGrid3DAction_prototype, jsb_cocos2d_SplitCols_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SplitCols", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_SplitCols_class; p->proto = jsb_cocos2d_SplitCols_prototype; p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ActionTween_class; JSObject *jsb_cocos2d_ActionTween_prototype; JSBool js_cocos2dx_ActionTween_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ActionTween* cobj = (cocos2d::ActionTween *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ActionTween_initWithDuration : Invalid Native Object"); if (argc == 4) { double arg0; std::string arg1; double arg2; double arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionTween_initWithDuration : Error processing arguments"); JSBool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionTween_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_ActionTween_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { double arg0; std::string arg1; double arg2; double arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ActionTween_create : Error processing arguments"); cocos2d::ActionTween* ret = cocos2d::ActionTween::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionTween*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ActionTween_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_ActionTween_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ActionTween)", obj); } void js_register_cocos2dx_ActionTween(JSContext *cx, JSObject *global) { jsb_cocos2d_ActionTween_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ActionTween_class->name = "ActionTween"; jsb_cocos2d_ActionTween_class->addProperty = JS_PropertyStub; jsb_cocos2d_ActionTween_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ActionTween_class->getProperty = JS_PropertyStub; jsb_cocos2d_ActionTween_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ActionTween_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ActionTween_class->resolve = JS_ResolveStub; jsb_cocos2d_ActionTween_class->convert = JS_ConvertStub; jsb_cocos2d_ActionTween_class->finalize = js_cocos2d_ActionTween_finalize; jsb_cocos2d_ActionTween_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_ActionTween_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ActionTween_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ActionTween_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_ActionTween_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ActionTween", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ActionTween_class; p->proto = jsb_cocos2d_ActionTween_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_CardinalSplineTo_class; JSObject *jsb_cocos2d_CardinalSplineTo_prototype; JSBool js_cocos2dx_CardinalSplineTo_getPoints(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CardinalSplineTo* cobj = (cocos2d::CardinalSplineTo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_CardinalSplineTo_getPoints : Invalid Native Object"); if (argc == 0) { cocos2d::PointArray* ret = cobj->getPoints(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::PointArray*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CardinalSplineTo_getPoints : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CardinalSplineTo_updatePosition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CardinalSplineTo* cobj = (cocos2d::CardinalSplineTo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_CardinalSplineTo_updatePosition : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_CardinalSplineTo_updatePosition : Error processing arguments"); cobj->updatePosition(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CardinalSplineTo_updatePosition : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CardinalSplineTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CardinalSplineTo* cobj = (cocos2d::CardinalSplineTo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_CardinalSplineTo_initWithDuration : Invalid Native Object"); if (argc == 3) { double arg0; cocos2d::PointArray* arg1; double arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::PointArray*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_CardinalSplineTo_initWithDuration : Error processing arguments"); JSBool ret = cobj->initWithDuration(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CardinalSplineTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_CardinalSplineTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::CardinalSplineTo* cobj = new cocos2d::CardinalSplineTo(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::CardinalSplineTo"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CardinalSplineTo_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_ActionInterval_prototype; void js_cocos2d_CardinalSplineTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CardinalSplineTo)", obj); } void js_register_cocos2dx_CardinalSplineTo(JSContext *cx, JSObject *global) { jsb_cocos2d_CardinalSplineTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_CardinalSplineTo_class->name = "CardinalSplineTo"; jsb_cocos2d_CardinalSplineTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_CardinalSplineTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_CardinalSplineTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_CardinalSplineTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_CardinalSplineTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_CardinalSplineTo_class->resolve = JS_ResolveStub; jsb_cocos2d_CardinalSplineTo_class->convert = JS_ConvertStub; jsb_cocos2d_CardinalSplineTo_class->finalize = js_cocos2d_CardinalSplineTo_finalize; jsb_cocos2d_CardinalSplineTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getPoints", js_cocos2dx_CardinalSplineTo_getPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updatePosition", js_cocos2dx_CardinalSplineTo_updatePosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithDuration", js_cocos2dx_CardinalSplineTo_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_CardinalSplineTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_ActionInterval_prototype, jsb_cocos2d_CardinalSplineTo_class, js_cocos2dx_CardinalSplineTo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "CardinalSplineTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_CardinalSplineTo_class; p->proto = jsb_cocos2d_CardinalSplineTo_prototype; p->parentProto = jsb_cocos2d_ActionInterval_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_CardinalSplineBy_class; JSObject *jsb_cocos2d_CardinalSplineBy_prototype; JSBool js_cocos2dx_CardinalSplineBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::CardinalSplineBy* cobj = new cocos2d::CardinalSplineBy(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::CardinalSplineBy"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CardinalSplineBy_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_CardinalSplineTo_prototype; void js_cocos2d_CardinalSplineBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CardinalSplineBy)", obj); } void js_register_cocos2dx_CardinalSplineBy(JSContext *cx, JSObject *global) { jsb_cocos2d_CardinalSplineBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_CardinalSplineBy_class->name = "CardinalSplineBy"; jsb_cocos2d_CardinalSplineBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_CardinalSplineBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_CardinalSplineBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_CardinalSplineBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_CardinalSplineBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_CardinalSplineBy_class->resolve = JS_ResolveStub; jsb_cocos2d_CardinalSplineBy_class->convert = JS_ConvertStub; jsb_cocos2d_CardinalSplineBy_class->finalize = js_cocos2d_CardinalSplineBy_finalize; jsb_cocos2d_CardinalSplineBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_CardinalSplineBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_CardinalSplineTo_prototype, jsb_cocos2d_CardinalSplineBy_class, js_cocos2dx_CardinalSplineBy_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "CardinalSplineBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_CardinalSplineBy_class; p->proto = jsb_cocos2d_CardinalSplineBy_prototype; p->parentProto = jsb_cocos2d_CardinalSplineTo_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_CatmullRomTo_class; JSObject *jsb_cocos2d_CatmullRomTo_prototype; JSBool js_cocos2dx_CatmullRomTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CatmullRomTo* cobj = (cocos2d::CatmullRomTo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_CatmullRomTo_initWithDuration : Invalid Native Object"); if (argc == 2) { double arg0; cocos2d::PointArray* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::PointArray*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_CatmullRomTo_initWithDuration : Error processing arguments"); JSBool ret = cobj->initWithDuration(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CatmullRomTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } extern JSObject *jsb_cocos2d_CardinalSplineTo_prototype; void js_cocos2d_CatmullRomTo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CatmullRomTo)", obj); } void js_register_cocos2dx_CatmullRomTo(JSContext *cx, JSObject *global) { jsb_cocos2d_CatmullRomTo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_CatmullRomTo_class->name = "CatmullRomTo"; jsb_cocos2d_CatmullRomTo_class->addProperty = JS_PropertyStub; jsb_cocos2d_CatmullRomTo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_CatmullRomTo_class->getProperty = JS_PropertyStub; jsb_cocos2d_CatmullRomTo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_CatmullRomTo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_CatmullRomTo_class->resolve = JS_ResolveStub; jsb_cocos2d_CatmullRomTo_class->convert = JS_ConvertStub; jsb_cocos2d_CatmullRomTo_class->finalize = js_cocos2d_CatmullRomTo_finalize; jsb_cocos2d_CatmullRomTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_CatmullRomTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_CatmullRomTo_prototype = JS_InitClass( cx, global, jsb_cocos2d_CardinalSplineTo_prototype, jsb_cocos2d_CatmullRomTo_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "CatmullRomTo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_CatmullRomTo_class; p->proto = jsb_cocos2d_CatmullRomTo_prototype; p->parentProto = jsb_cocos2d_CardinalSplineTo_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_CatmullRomBy_class; JSObject *jsb_cocos2d_CatmullRomBy_prototype; JSBool js_cocos2dx_CatmullRomBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CatmullRomBy* cobj = (cocos2d::CatmullRomBy *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_CatmullRomBy_initWithDuration : Invalid Native Object"); if (argc == 2) { double arg0; cocos2d::PointArray* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::PointArray*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_CatmullRomBy_initWithDuration : Error processing arguments"); JSBool ret = cobj->initWithDuration(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_CatmullRomBy_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } extern JSObject *jsb_cocos2d_CardinalSplineBy_prototype; void js_cocos2d_CatmullRomBy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CatmullRomBy)", obj); } void js_register_cocos2dx_CatmullRomBy(JSContext *cx, JSObject *global) { jsb_cocos2d_CatmullRomBy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_CatmullRomBy_class->name = "CatmullRomBy"; jsb_cocos2d_CatmullRomBy_class->addProperty = JS_PropertyStub; jsb_cocos2d_CatmullRomBy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_CatmullRomBy_class->getProperty = JS_PropertyStub; jsb_cocos2d_CatmullRomBy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_CatmullRomBy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_CatmullRomBy_class->resolve = JS_ResolveStub; jsb_cocos2d_CatmullRomBy_class->convert = JS_ConvertStub; jsb_cocos2d_CatmullRomBy_class->finalize = js_cocos2d_CatmullRomBy_finalize; jsb_cocos2d_CatmullRomBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("initWithDuration", js_cocos2dx_CatmullRomBy_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_CatmullRomBy_prototype = JS_InitClass( cx, global, jsb_cocos2d_CardinalSplineBy_prototype, jsb_cocos2d_CatmullRomBy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "CatmullRomBy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_CatmullRomBy_class; p->proto = jsb_cocos2d_CatmullRomBy_prototype; p->parentProto = jsb_cocos2d_CardinalSplineBy_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_AtlasNode_class; JSObject *jsb_cocos2d_AtlasNode_prototype; JSBool js_cocos2dx_AtlasNode_updateAtlasValues(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AtlasNode_updateAtlasValues : Invalid Native Object"); if (argc == 0) { cobj->updateAtlasValues(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AtlasNode_updateAtlasValues : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_AtlasNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AtlasNode_getTexture : Invalid Native Object"); if (argc == 0) { cocos2d::Texture2D* ret = cobj->getTexture(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AtlasNode_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_AtlasNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AtlasNode_setTextureAtlas : Invalid Native Object"); if (argc == 1) { cocos2d::TextureAtlas* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AtlasNode_setTextureAtlas : Error processing arguments"); cobj->setTextureAtlas(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AtlasNode_setTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AtlasNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AtlasNode_getTextureAtlas : Invalid Native Object"); if (argc == 0) { cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TextureAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AtlasNode_getTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_AtlasNode_getQuadsToDraw(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AtlasNode_getQuadsToDraw : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getQuadsToDraw(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AtlasNode_getQuadsToDraw : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_AtlasNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AtlasNode_setTexture : Invalid Native Object"); if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AtlasNode_setTexture : Error processing arguments"); cobj->setTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AtlasNode_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AtlasNode_setQuadsToDraw(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AtlasNode_setQuadsToDraw : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AtlasNode_setQuadsToDraw : Error processing arguments"); cobj->setQuadsToDraw(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AtlasNode_setQuadsToDraw : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AtlasNode_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { std::string arg0; int arg1; int arg2; int arg3; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AtlasNode_create : Error processing arguments"); cocos2d::AtlasNode* ret = cocos2d::AtlasNode::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::AtlasNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AtlasNode_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_AtlasNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (AtlasNode)", obj); } void js_register_cocos2dx_AtlasNode(JSContext *cx, JSObject *global) { jsb_cocos2d_AtlasNode_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_AtlasNode_class->name = "AtlasNode"; jsb_cocos2d_AtlasNode_class->addProperty = JS_PropertyStub; jsb_cocos2d_AtlasNode_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_AtlasNode_class->getProperty = JS_PropertyStub; jsb_cocos2d_AtlasNode_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_AtlasNode_class->enumerate = JS_EnumerateStub; jsb_cocos2d_AtlasNode_class->resolve = JS_ResolveStub; jsb_cocos2d_AtlasNode_class->convert = JS_ConvertStub; jsb_cocos2d_AtlasNode_class->finalize = js_cocos2d_AtlasNode_finalize; jsb_cocos2d_AtlasNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("updateAtlasValues", js_cocos2dx_AtlasNode_updateAtlasValues, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTexture", js_cocos2dx_AtlasNode_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextureAtlas", js_cocos2dx_AtlasNode_setTextureAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureAtlas", js_cocos2dx_AtlasNode_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getQuadsToDraw", js_cocos2dx_AtlasNode_getQuadsToDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTexture", js_cocos2dx_AtlasNode_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setQuadsToDraw", js_cocos2dx_AtlasNode_setQuadsToDraw, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_AtlasNode_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_AtlasNode_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_AtlasNode_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "AtlasNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_AtlasNode_class; p->proto = jsb_cocos2d_AtlasNode_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_DrawNode_class; JSObject *jsb_cocos2d_DrawNode_prototype; JSBool js_cocos2dx_DrawNode_drawQuadraticBezier(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawQuadraticBezier : Invalid Native Object"); if (argc == 5) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::Point arg2; unsigned int arg3; cocos2d::Color4F arg4; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); ok &= jsval_to_uint32(cx, argv[3], &arg3); ok &= jsval_to_cccolor4f(cx, argv[4], &arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawQuadraticBezier : Error processing arguments"); cobj->drawQuadraticBezier(arg0, arg1, arg2, arg3, arg4); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DrawNode_drawQuadraticBezier : wrong number of arguments: %d, was expecting %d", argc, 5); return JS_FALSE; } JSBool js_cocos2dx_DrawNode_onDraw(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_DrawNode_onDraw : Invalid Native Object"); if (argc == 0) { cobj->onDraw(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DrawNode_onDraw : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_DrawNode_clear(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_DrawNode_clear : Invalid Native Object"); if (argc == 0) { cobj->clear(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DrawNode_clear : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_DrawNode_drawTriangle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawTriangle : Invalid Native Object"); if (argc == 4) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::Point arg2; cocos2d::Color4F arg3; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); ok &= jsval_to_cccolor4f(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawTriangle : Error processing arguments"); cobj->drawTriangle(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DrawNode_drawTriangle : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_DrawNode_drawDot(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawDot : Invalid Native Object"); if (argc == 3) { cocos2d::Point arg0; double arg1; cocos2d::Color4F arg2; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= jsval_to_cccolor4f(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawDot : Error processing arguments"); cobj->drawDot(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DrawNode_drawDot : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_DrawNode_drawCubicBezier(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawCubicBezier : Invalid Native Object"); if (argc == 6) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::Point arg2; cocos2d::Point arg3; unsigned int arg4; cocos2d::Color4F arg5; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); ok &= jsval_to_ccpoint(cx, argv[3], &arg3); ok &= jsval_to_uint32(cx, argv[4], &arg4); ok &= jsval_to_cccolor4f(cx, argv[5], &arg5); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawCubicBezier : Error processing arguments"); cobj->drawCubicBezier(arg0, arg1, arg2, arg3, arg4, arg5); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DrawNode_drawCubicBezier : wrong number of arguments: %d, was expecting %d", argc, 6); return JS_FALSE; } JSBool js_cocos2dx_DrawNode_drawSegment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawSegment : Invalid Native Object"); if (argc == 4) { cocos2d::Point arg0; cocos2d::Point arg1; double arg2; cocos2d::Color4F arg3; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= jsval_to_cccolor4f(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_DrawNode_drawSegment : Error processing arguments"); cobj->drawSegment(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DrawNode_drawSegment : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_DrawNode_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::DrawNode* ret = cocos2d::DrawNode::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::DrawNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_DrawNode_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_DrawNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (DrawNode)", obj); } static JSBool js_cocos2d_DrawNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::DrawNode *nobj = cocos2d::DrawNode::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::DrawNode"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_DrawNode(JSContext *cx, JSObject *global) { jsb_cocos2d_DrawNode_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_DrawNode_class->name = "DrawNode"; jsb_cocos2d_DrawNode_class->addProperty = JS_PropertyStub; jsb_cocos2d_DrawNode_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_DrawNode_class->getProperty = JS_PropertyStub; jsb_cocos2d_DrawNode_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_DrawNode_class->enumerate = JS_EnumerateStub; jsb_cocos2d_DrawNode_class->resolve = JS_ResolveStub; jsb_cocos2d_DrawNode_class->convert = JS_ConvertStub; jsb_cocos2d_DrawNode_class->finalize = js_cocos2d_DrawNode_finalize; jsb_cocos2d_DrawNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("drawQuadraticBezier", js_cocos2dx_DrawNode_drawQuadraticBezier, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onDraw", js_cocos2dx_DrawNode_onDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clear", js_cocos2dx_DrawNode_clear, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawTriangle", js_cocos2dx_DrawNode_drawTriangle, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawDot", js_cocos2dx_DrawNode_drawDot, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawCubicBezier", js_cocos2dx_DrawNode_drawCubicBezier, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawSegment", js_cocos2dx_DrawNode_drawSegment, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_DrawNode_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_DrawNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_DrawNode_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_DrawNode_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "DrawNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_DrawNode_class; p->proto = jsb_cocos2d_DrawNode_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_LabelAtlas_class; JSObject *jsb_cocos2d_LabelAtlas_prototype; JSBool js_cocos2dx_LabelAtlas_setString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelAtlas* cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelAtlas_setString : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelAtlas_setString : Error processing arguments"); cobj->setString(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelAtlas_setString : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelAtlas_initWithString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::LabelAtlas* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelAtlas_initWithString : Invalid Native Object"); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } int arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } int arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } int arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } int arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_LabelAtlas_initWithString : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_LabelAtlas_updateAtlasValues(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelAtlas* cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelAtlas_updateAtlasValues : Invalid Native Object"); if (argc == 0) { cobj->updateAtlasValues(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelAtlas_updateAtlasValues : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelAtlas_getString(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelAtlas* cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelAtlas_getString : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getString(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelAtlas_getString : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelAtlas_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } int arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } int arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_LabelAtlas_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_AtlasNode_prototype; void js_cocos2d_LabelAtlas_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LabelAtlas)", obj); } void js_register_cocos2dx_LabelAtlas(JSContext *cx, JSObject *global) { jsb_cocos2d_LabelAtlas_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LabelAtlas_class->name = "LabelAtlas"; jsb_cocos2d_LabelAtlas_class->addProperty = JS_PropertyStub; jsb_cocos2d_LabelAtlas_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_LabelAtlas_class->getProperty = JS_PropertyStub; jsb_cocos2d_LabelAtlas_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_LabelAtlas_class->enumerate = JS_EnumerateStub; jsb_cocos2d_LabelAtlas_class->resolve = JS_ResolveStub; jsb_cocos2d_LabelAtlas_class->convert = JS_ConvertStub; jsb_cocos2d_LabelAtlas_class->finalize = js_cocos2d_LabelAtlas_finalize; jsb_cocos2d_LabelAtlas_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setString", js_cocos2dx_LabelAtlas_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithString", js_cocos2dx_LabelAtlas_initWithString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateAtlasValues", js_cocos2dx_LabelAtlas_updateAtlasValues, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_LabelAtlas_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("_create", js_cocos2dx_LabelAtlas_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_LabelAtlas_prototype = JS_InitClass( cx, global, jsb_cocos2d_AtlasNode_prototype, jsb_cocos2d_LabelAtlas_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LabelAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_LabelAtlas_class; p->proto = jsb_cocos2d_LabelAtlas_prototype; p->parentProto = jsb_cocos2d_AtlasNode_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Director_class; JSObject *jsb_cocos2d_Director_prototype; JSBool js_cocos2dx_Director_pause(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_pause : Invalid Native Object"); if (argc == 0) { cobj->pause(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_pause : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setContentScaleFactor : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setContentScaleFactor : Error processing arguments"); cobj->setContentScaleFactor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setContentScaleFactor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_getContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getContentScaleFactor : Invalid Native Object"); if (argc == 0) { double ret = cobj->getContentScaleFactor(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getContentScaleFactor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getWinSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getWinSizeInPixels : Invalid Native Object"); if (argc == 0) { cocos2d::Size ret = cobj->getWinSizeInPixels(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getWinSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getDeltaTime(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getDeltaTime : Invalid Native Object"); if (argc == 0) { double ret = cobj->getDeltaTime(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getDeltaTime : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setGLDefaultValues(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setGLDefaultValues : Invalid Native Object"); if (argc == 0) { cobj->setGLDefaultValues(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setGLDefaultValues : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setActionManager(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setActionManager : Invalid Native Object"); if (argc == 1) { cocos2d::ActionManager* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionManager*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setActionManager : Error processing arguments"); cobj->setActionManager(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setActionManager : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_setAlphaBlending(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setAlphaBlending : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setAlphaBlending : Error processing arguments"); cobj->setAlphaBlending(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setAlphaBlending : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_popToRootScene(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_popToRootScene : Invalid Native Object"); if (argc == 0) { cobj->popToRootScene(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_popToRootScene : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getNotificationNode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getNotificationNode : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getNotificationNode(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getNotificationNode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getWinSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getWinSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getWinSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getWinSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_end(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_end : Invalid Native Object"); if (argc == 0) { cobj->end(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_end : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getTextureCache(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getTextureCache : Invalid Native Object"); if (argc == 0) { cocos2d::TextureCache* ret = cobj->getTextureCache(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TextureCache*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getTextureCache : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_isSendCleanupToScene(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_isSendCleanupToScene : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isSendCleanupToScene(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_isSendCleanupToScene : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getVisibleOrigin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getVisibleOrigin : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getVisibleOrigin(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getVisibleOrigin : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_mainLoop(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_mainLoop : Invalid Native Object"); if (argc == 0) { cobj->mainLoop(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_mainLoop : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setDepthTest(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setDepthTest : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setDepthTest : Error processing arguments"); cobj->setDepthTest(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setDepthTest : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_getFrameRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getFrameRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getFrameRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getFrameRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getSecondsPerFrame(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getSecondsPerFrame : Invalid Native Object"); if (argc == 0) { double ret = cobj->getSecondsPerFrame(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getSecondsPerFrame : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_convertToUI(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_convertToUI : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_convertToUI : Error processing arguments"); cocos2d::Point ret = cobj->convertToUI(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_convertToUI : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_setDefaultValues(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setDefaultValues : Invalid Native Object"); if (argc == 0) { cobj->setDefaultValues(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setDefaultValues : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setScheduler : Invalid Native Object"); if (argc == 1) { cocos2d::Scheduler* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scheduler*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setScheduler : Error processing arguments"); cobj->setScheduler(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setScheduler : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_startAnimation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_startAnimation : Invalid Native Object"); if (argc == 0) { cobj->startAnimation(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_startAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getRunningScene(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getRunningScene : Invalid Native Object"); if (argc == 0) { cocos2d::Scene* ret = cobj->getRunningScene(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getRunningScene : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setViewport(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setViewport : Invalid Native Object"); if (argc == 0) { cobj->setViewport(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setViewport : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_stopAnimation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_stopAnimation : Invalid Native Object"); if (argc == 0) { cobj->stopAnimation(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_stopAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_popToSceneStackLevel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_popToSceneStackLevel : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_popToSceneStackLevel : Error processing arguments"); cobj->popToSceneStackLevel(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_popToSceneStackLevel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_resume(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_resume : Invalid Native Object"); if (argc == 0) { cobj->resume(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_resume : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_isNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_isNextDeltaTimeZero : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isNextDeltaTimeZero(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_isNextDeltaTimeZero : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setOpenGLView(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setOpenGLView : Invalid Native Object"); if (argc == 1) { cocos2d::EGLView* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::EGLView*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setOpenGLView : Error processing arguments"); cobj->setOpenGLView(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setOpenGLView : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_convertToGL(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_convertToGL : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_convertToGL : Error processing arguments"); cocos2d::Point ret = cobj->convertToGL(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_convertToGL : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_purgeCachedData(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_purgeCachedData : Invalid Native Object"); if (argc == 0) { cobj->purgeCachedData(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_purgeCachedData : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getTotalFrames(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getTotalFrames : Invalid Native Object"); if (argc == 0) { unsigned int ret = cobj->getTotalFrames(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getTotalFrames : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_runWithScene(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_runWithScene : Invalid Native Object"); if (argc == 1) { cocos2d::Scene* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_runWithScene : Error processing arguments"); cobj->runWithScene(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_runWithScene : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_setNotificationNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setNotificationNode : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setNotificationNode : Error processing arguments"); cobj->setNotificationNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setNotificationNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_drawScene(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_drawScene : Invalid Native Object"); if (argc == 0) { cobj->drawScene(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_drawScene : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_popScene(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_popScene : Invalid Native Object"); if (argc == 0) { cobj->popScene(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_popScene : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_isDisplayStats(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_isDisplayStats : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isDisplayStats(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_isDisplayStats : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setProjection(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setProjection : Invalid Native Object"); if (argc == 1) { cocos2d::Director::Projection arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setProjection : Error processing arguments"); cobj->setProjection(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setProjection : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_getConsole(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getConsole : Invalid Native Object"); if (argc == 0) { cocos2d::Console* ret = cobj->getConsole(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Console*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getConsole : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getZEye(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getZEye : Invalid Native Object"); if (argc == 0) { double ret = cobj->getZEye(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getZEye : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setNextDeltaTimeZero : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setNextDeltaTimeZero : Error processing arguments"); cobj->setNextDeltaTimeZero(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setNextDeltaTimeZero : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_getVisibleSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getVisibleSize : Invalid Native Object"); if (argc == 0) { cocos2d::Size ret = cobj->getVisibleSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getVisibleSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getScheduler(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getScheduler : Invalid Native Object"); if (argc == 0) { cocos2d::Scheduler* ret = cobj->getScheduler(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Scheduler*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getScheduler : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_pushScene : Invalid Native Object"); if (argc == 1) { cocos2d::Scene* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_pushScene : Error processing arguments"); cobj->pushScene(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_pushScene : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_getAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getAnimationInterval : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAnimationInterval(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getAnimationInterval : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_isPaused(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_isPaused : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isPaused(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_isPaused : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_setDisplayStats(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setDisplayStats : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setDisplayStats : Error processing arguments"); cobj->setDisplayStats(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setDisplayStats : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_replaceScene(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_replaceScene : Invalid Native Object"); if (argc == 1) { cocos2d::Scene* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_replaceScene : Error processing arguments"); cobj->replaceScene(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_replaceScene : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_setAnimationInterval : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Director_setAnimationInterval : Error processing arguments"); cobj->setAnimationInterval(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_setAnimationInterval : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Director_getActionManager(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Director_getActionManager : Invalid Native Object"); if (argc == 0) { cocos2d::ActionManager* ret = cobj->getActionManager(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionManager*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getActionManager : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Director_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Director* ret = cocos2d::Director::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Director*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Director_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_Director_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Director)", obj); } void js_register_cocos2dx_Director(JSContext *cx, JSObject *global) { jsb_cocos2d_Director_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Director_class->name = "Director"; jsb_cocos2d_Director_class->addProperty = JS_PropertyStub; jsb_cocos2d_Director_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Director_class->getProperty = JS_PropertyStub; jsb_cocos2d_Director_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Director_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Director_class->resolve = JS_ResolveStub; jsb_cocos2d_Director_class->convert = JS_ConvertStub; jsb_cocos2d_Director_class->finalize = js_cocos2d_Director_finalize; jsb_cocos2d_Director_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("pause", js_cocos2dx_Director_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setContentScaleFactor", js_cocos2dx_Director_setContentScaleFactor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentScaleFactor", js_cocos2dx_Director_getContentScaleFactor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWinSizeInPixels", js_cocos2dx_Director_getWinSizeInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDeltaTime", js_cocos2dx_Director_getDeltaTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGLDefaultValues", js_cocos2dx_Director_setGLDefaultValues, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setActionManager", js_cocos2dx_Director_setActionManager, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlphaBlending", js_cocos2dx_Director_setAlphaBlending, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("popToRootScene", js_cocos2dx_Director_popToRootScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNotificationNode", js_cocos2dx_Director_getNotificationNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWinSize", js_cocos2dx_Director_getWinSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("end", js_cocos2dx_Director_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureCache", js_cocos2dx_Director_getTextureCache, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSendCleanupToScene", js_cocos2dx_Director_isSendCleanupToScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVisibleOrigin", js_cocos2dx_Director_getVisibleOrigin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("mainLoop", js_cocos2dx_Director_mainLoop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDepthTest", js_cocos2dx_Director_setDepthTest, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFrameRate", js_cocos2dx_Director_getFrameRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSecondsPerFrame", js_cocos2dx_Director_getSecondsPerFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertToUI", js_cocos2dx_Director_convertToUI, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDefaultValues", js_cocos2dx_Director_setDefaultValues, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_Director_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScheduler", js_cocos2dx_Director_setScheduler, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("startAnimation", js_cocos2dx_Director_startAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRunningScene", js_cocos2dx_Director_getRunningScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setViewport", js_cocos2dx_Director_setViewport, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopAnimation", js_cocos2dx_Director_stopAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("popToSceneStackLevel", js_cocos2dx_Director_popToSceneStackLevel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resume", js_cocos2dx_Director_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isNextDeltaTimeZero", js_cocos2dx_Director_isNextDeltaTimeZero, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOpenGLView", js_cocos2dx_Director_setOpenGLView, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertToGL", js_cocos2dx_Director_convertToGL, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("purgeCachedData", js_cocos2dx_Director_purgeCachedData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTotalFrames", js_cocos2dx_Director_getTotalFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("runWithScene", js_cocos2dx_Director_runWithScene, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setNotificationNode", js_cocos2dx_Director_setNotificationNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawScene", js_cocos2dx_Director_drawScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("popScene", js_cocos2dx_Director_popScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isDisplayStats", js_cocos2dx_Director_isDisplayStats, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProjection", js_cocos2dx_Director_setProjection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getConsole", js_cocos2dx_Director_getConsole, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZEye", js_cocos2dx_Director_getZEye, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setNextDeltaTimeZero", js_cocos2dx_Director_setNextDeltaTimeZero, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVisibleSize", js_cocos2dx_Director_getVisibleSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScheduler", js_cocos2dx_Director_getScheduler, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pushScene", js_cocos2dx_Director_pushScene, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnimationInterval", js_cocos2dx_Director_getAnimationInterval, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPaused", js_cocos2dx_Director_isPaused, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDisplayStats", js_cocos2dx_Director_setDisplayStats, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("replaceScene", js_cocos2dx_Director_replaceScene, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimationInterval", js_cocos2dx_Director_setAnimationInterval, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActionManager", js_cocos2dx_Director_getActionManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("getInstance", js_cocos2dx_Director_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Director_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Director_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Director", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Director_class; p->proto = jsb_cocos2d_Director_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_GridBase_class; JSObject *jsb_cocos2d_GridBase_prototype; JSBool js_cocos2dx_GridBase_setGridSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_setGridSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GridBase_setGridSize : Error processing arguments"); cobj->setGridSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_setGridSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_GridBase_calculateVertexPoints(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_calculateVertexPoints : Invalid Native Object"); if (argc == 0) { cobj->calculateVertexPoints(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_calculateVertexPoints : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_afterDraw(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_afterDraw : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GridBase_afterDraw : Error processing arguments"); cobj->afterDraw(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_afterDraw : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_GridBase_beforeDraw(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_beforeDraw : Invalid Native Object"); if (argc == 0) { cobj->beforeDraw(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_beforeDraw : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_isTextureFlipped(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_isTextureFlipped : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isTextureFlipped(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_isTextureFlipped : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_getGridSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_getGridSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getGridSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_getGridSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_getStep(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_getStep : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getStep(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_getStep : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_set2DProjection(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_set2DProjection : Invalid Native Object"); if (argc == 0) { cobj->set2DProjection(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_set2DProjection : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_setStep(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_setStep : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GridBase_setStep : Error processing arguments"); cobj->setStep(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_setStep : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_GridBase_setTextureFlipped(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_setTextureFlipped : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GridBase_setTextureFlipped : Error processing arguments"); cobj->setTextureFlipped(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_setTextureFlipped : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_GridBase_blit(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_blit : Invalid Native Object"); if (argc == 0) { cobj->blit(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_blit : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_setActive(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_setActive : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GridBase_setActive : Error processing arguments"); cobj->setActive(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_setActive : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_GridBase_getReuseGrid(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_getReuseGrid : Invalid Native Object"); if (argc == 0) { int ret = cobj->getReuseGrid(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_getReuseGrid : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::GridBase* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_initWithSize : Invalid Native Object"); do { if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithSize(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 3) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithSize(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_GridBase_initWithSize : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_GridBase_setReuseGrid(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_setReuseGrid : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_GridBase_setReuseGrid : Error processing arguments"); cobj->setReuseGrid(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_setReuseGrid : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_GridBase_isActive(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_isActive : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isActive(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_isActive : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_reuse(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_GridBase_reuse : Invalid Native Object"); if (argc == 0) { cobj->reuse(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_GridBase_reuse : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_GridBase_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::GridBase* ret = cocos2d::GridBase::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::GridBase* ret = cocos2d::GridBase::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_GridBase_create : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_GridBase_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (GridBase)", obj); } void js_register_cocos2dx_GridBase(JSContext *cx, JSObject *global) { jsb_cocos2d_GridBase_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_GridBase_class->name = "GridBase"; jsb_cocos2d_GridBase_class->addProperty = JS_PropertyStub; jsb_cocos2d_GridBase_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_GridBase_class->getProperty = JS_PropertyStub; jsb_cocos2d_GridBase_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_GridBase_class->enumerate = JS_EnumerateStub; jsb_cocos2d_GridBase_class->resolve = JS_ResolveStub; jsb_cocos2d_GridBase_class->convert = JS_ConvertStub; jsb_cocos2d_GridBase_class->finalize = js_cocos2d_GridBase_finalize; jsb_cocos2d_GridBase_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setGridSize", js_cocos2dx_GridBase_setGridSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("calculateVertexPoints", js_cocos2dx_GridBase_calculateVertexPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("afterDraw", js_cocos2dx_GridBase_afterDraw, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("beforeDraw", js_cocos2dx_GridBase_beforeDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTextureFlipped", js_cocos2dx_GridBase_isTextureFlipped, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGridSize", js_cocos2dx_GridBase_getGridSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStep", js_cocos2dx_GridBase_getStep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("set2DProjection", js_cocos2dx_GridBase_set2DProjection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStep", js_cocos2dx_GridBase_setStep, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextureFlipped", js_cocos2dx_GridBase_setTextureFlipped, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("blit", js_cocos2dx_GridBase_blit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setActive", js_cocos2dx_GridBase_setActive, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getReuseGrid", js_cocos2dx_GridBase_getReuseGrid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithSize", js_cocos2dx_GridBase_initWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setReuseGrid", js_cocos2dx_GridBase_setReuseGrid, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isActive", js_cocos2dx_GridBase_isActive, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reuse", js_cocos2dx_GridBase_reuse, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_GridBase_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_GridBase_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_GridBase_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "GridBase", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_GridBase_class; p->proto = jsb_cocos2d_GridBase_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Grid3D_class; JSObject *jsb_cocos2d_Grid3D_prototype; JSBool js_cocos2dx_Grid3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Grid3D* ret = cocos2d::Grid3D::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Grid3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Grid3D* ret = cocos2d::Grid3D::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Grid3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_Grid3D_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Grid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Grid3D* cobj = new cocos2d::Grid3D(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Grid3D"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Grid3D_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_GridBase_prototype; void js_cocos2d_Grid3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Grid3D)", obj); } void js_register_cocos2dx_Grid3D(JSContext *cx, JSObject *global) { jsb_cocos2d_Grid3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Grid3D_class->name = "Grid3D"; jsb_cocos2d_Grid3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_Grid3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Grid3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_Grid3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Grid3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Grid3D_class->resolve = JS_ResolveStub; jsb_cocos2d_Grid3D_class->convert = JS_ConvertStub; jsb_cocos2d_Grid3D_class->finalize = js_cocos2d_Grid3D_finalize; jsb_cocos2d_Grid3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Grid3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Grid3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_GridBase_prototype, jsb_cocos2d_Grid3D_class, js_cocos2dx_Grid3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Grid3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Grid3D_class; p->proto = jsb_cocos2d_Grid3D_prototype; p->parentProto = jsb_cocos2d_GridBase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TiledGrid3D_class; JSObject *jsb_cocos2d_TiledGrid3D_prototype; JSBool js_cocos2dx_TiledGrid3D_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TiledGrid3D* ret = cocos2d::TiledGrid3D::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TiledGrid3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TiledGrid3D* ret = cocos2d::TiledGrid3D::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TiledGrid3D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TiledGrid3D_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TiledGrid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TiledGrid3D* cobj = new cocos2d::TiledGrid3D(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TiledGrid3D"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TiledGrid3D_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_GridBase_prototype; void js_cocos2d_TiledGrid3D_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TiledGrid3D)", obj); } void js_register_cocos2dx_TiledGrid3D(JSContext *cx, JSObject *global) { jsb_cocos2d_TiledGrid3D_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TiledGrid3D_class->name = "TiledGrid3D"; jsb_cocos2d_TiledGrid3D_class->addProperty = JS_PropertyStub; jsb_cocos2d_TiledGrid3D_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TiledGrid3D_class->getProperty = JS_PropertyStub; jsb_cocos2d_TiledGrid3D_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TiledGrid3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TiledGrid3D_class->resolve = JS_ResolveStub; jsb_cocos2d_TiledGrid3D_class->convert = JS_ConvertStub; jsb_cocos2d_TiledGrid3D_class->finalize = js_cocos2d_TiledGrid3D_finalize; jsb_cocos2d_TiledGrid3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TiledGrid3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TiledGrid3D_prototype = JS_InitClass( cx, global, jsb_cocos2d_GridBase_prototype, jsb_cocos2d_TiledGrid3D_class, js_cocos2dx_TiledGrid3D_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TiledGrid3D", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TiledGrid3D_class; p->proto = jsb_cocos2d_TiledGrid3D_prototype; p->parentProto = jsb_cocos2d_GridBase_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Sprite_class; JSObject *jsb_cocos2d_Sprite_prototype; JSBool js_cocos2dx_Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Sprite* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setSpriteFrame : Invalid Native Object"); do { if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj->setSpriteFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setSpriteFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Sprite_setSpriteFrame : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Sprite* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setTexture : Invalid Native Object"); do { if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj->setTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Sprite_setTexture : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Sprite_getTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_getTexture : Invalid Native Object"); if (argc == 0) { cocos2d::Texture2D* ret = cobj->getTexture(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setFlippedY : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_setFlippedY : Error processing arguments"); cobj->setFlippedY(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_setFlippedY : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setFlippedX : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_setFlippedX : Error processing arguments"); cobj->setFlippedX(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_setFlippedX : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_getBatchNode : Invalid Native Object"); if (argc == 0) { cocos2d::SpriteBatchNode* ret = cobj->getBatchNode(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_getBatchNode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_getOffsetPosition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_getOffsetPosition : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getOffsetPosition(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_getOffsetPosition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_removeAllChildrenWithCleanup : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_removeAllChildrenWithCleanup : Error processing arguments"); cobj->removeAllChildrenWithCleanup(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_removeAllChildrenWithCleanup : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_updateQuadVertices(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_updateQuadVertices : Invalid Native Object"); if (argc == 0) { cobj->updateQuadVertices(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_updateQuadVertices : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_updateTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_updateTransform : Invalid Native Object"); if (argc == 0) { cobj->updateTransform(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_updateTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Sprite* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setTextureRect : Invalid Native Object"); do { if (argc == 3) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool arg1; ok &= JS_ValueToBoolean(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg2; ok &= jsval_to_ccsize(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cobj->setTextureRect(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setTextureRect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Sprite_setTextureRect : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Sprite_isFrameDisplayed(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_isFrameDisplayed : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_isFrameDisplayed : Error processing arguments"); JSBool ret = cobj->isFrameDisplayed(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_isFrameDisplayed : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_getAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_getAtlasIndex : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getAtlasIndex(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_getAtlasIndex : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setBatchNode : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteBatchNode* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteBatchNode*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_setBatchNode : Error processing arguments"); cobj->setBatchNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_setBatchNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setDisplayFrameWithAnimationName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setDisplayFrameWithAnimationName : Invalid Native Object"); if (argc == 2) { std::string arg0; ssize_t arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_ssize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_setDisplayFrameWithAnimationName : Error processing arguments"); cobj->setDisplayFrameWithAnimationName(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_setDisplayFrameWithAnimationName : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setTextureAtlas : Invalid Native Object"); if (argc == 1) { cocos2d::TextureAtlas* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_setTextureAtlas : Error processing arguments"); cobj->setTextureAtlas(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_setTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_getSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_getSpriteFrame : Invalid Native Object"); if (argc == 0) { cocos2d::SpriteFrame* ret = cobj->getSpriteFrame(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_getSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_isDirty(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_isDirty : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isDirty(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_isDirty : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setAtlasIndex : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_setAtlasIndex : Error processing arguments"); cobj->setAtlasIndex(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_setAtlasIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setDirty(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setDirty : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_setDirty : Error processing arguments"); cobj->setDirty(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_setDirty : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_isTextureRectRotated(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_isTextureRectRotated : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isTextureRectRotated(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_isTextureRectRotated : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_getTextureRect(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_getTextureRect : Invalid Native Object"); if (argc == 0) { const cocos2d::Rect& ret = cobj->getTextureRect(); jsval jsret = JSVAL_NULL; jsret = ccrect_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_getTextureRect : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_getTextureAtlas : Invalid Native Object"); if (argc == 0) { cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TextureAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_getTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_isFlippedX : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isFlippedX(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_isFlippedX : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_isFlippedY : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isFlippedY(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_isFlippedY : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Sprite_setVertexRect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Sprite_setVertexRect : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_setVertexRect : Error processing arguments"); cobj->setVertexRect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_setVertexRect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Sprite_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::Sprite* ret = cocos2d::Sprite::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_Sprite_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Sprite_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_Sprite_createWithTexture : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_createWithSpriteFrameName : Error processing arguments"); cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrameName(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_createWithSpriteFrameName : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Sprite_createWithSpriteFrame : Error processing arguments"); cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrame(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Sprite_createWithSpriteFrame : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_Sprite_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Sprite)", obj); } static JSBool js_cocos2d_Sprite_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::Sprite *nobj = cocos2d::Sprite::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Sprite"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_Sprite(JSContext *cx, JSObject *global) { jsb_cocos2d_Sprite_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Sprite_class->name = "Sprite"; jsb_cocos2d_Sprite_class->addProperty = JS_PropertyStub; jsb_cocos2d_Sprite_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Sprite_class->getProperty = JS_PropertyStub; jsb_cocos2d_Sprite_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Sprite_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Sprite_class->resolve = JS_ResolveStub; jsb_cocos2d_Sprite_class->convert = JS_ConvertStub; jsb_cocos2d_Sprite_class->finalize = js_cocos2d_Sprite_finalize; jsb_cocos2d_Sprite_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setSpriteFrame", js_cocos2dx_Sprite_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTexture", js_cocos2dx_Sprite_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTexture", js_cocos2dx_Sprite_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFlippedY", js_cocos2dx_Sprite_setFlippedY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFlippedX", js_cocos2dx_Sprite_setFlippedX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBatchNode", js_cocos2dx_Sprite_getBatchNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOffsetPosition", js_cocos2dx_Sprite_getOffsetPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllChildrenWithCleanup", js_cocos2dx_Sprite_removeAllChildrenWithCleanup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateQuadVertices", js_cocos2dx_Sprite_updateQuadVertices, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateTransform", js_cocos2dx_Sprite_updateTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextureRect", js_cocos2dx_Sprite_setTextureRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFrameDisplayed", js_cocos2dx_Sprite_isFrameDisplayed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAtlasIndex", js_cocos2dx_Sprite_getAtlasIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBatchNode", js_cocos2dx_Sprite_setBatchNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDisplayFrameWithAnimationName", js_cocos2dx_Sprite_setDisplayFrameWithAnimationName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextureAtlas", js_cocos2dx_Sprite_setTextureAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpriteFrame", js_cocos2dx_Sprite_getSpriteFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isDirty", js_cocos2dx_Sprite_isDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAtlasIndex", js_cocos2dx_Sprite_setAtlasIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDirty", js_cocos2dx_Sprite_setDirty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTextureRectRotated", js_cocos2dx_Sprite_isTextureRectRotated, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureRect", js_cocos2dx_Sprite_getTextureRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureAtlas", js_cocos2dx_Sprite_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFlippedX", js_cocos2dx_Sprite_isFlippedX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFlippedY", js_cocos2dx_Sprite_isFlippedY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVertexRect", js_cocos2dx_Sprite_setVertexRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_Sprite_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Sprite_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTexture", js_cocos2dx_Sprite_createWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithSpriteFrameName", js_cocos2dx_Sprite_createWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithSpriteFrame", js_cocos2dx_Sprite_createWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Sprite_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_Sprite_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Sprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Sprite_class; p->proto = jsb_cocos2d_Sprite_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_LabelTTF_class; JSObject *jsb_cocos2d_LabelTTF_prototype; JSBool js_cocos2dx_LabelTTF_enableShadow(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_enableShadow : Invalid Native Object"); if (argc == 3) { cocos2d::Size arg0; double arg1; double arg2; ok &= jsval_to_ccsize(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_enableShadow : Error processing arguments"); cobj->enableShadow(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 4) { cocos2d::Size arg0; double arg1; double arg2; JSBool arg3; ok &= jsval_to_ccsize(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= JS_ValueToBoolean(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_enableShadow : Error processing arguments"); cobj->enableShadow(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_enableShadow : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_setDimensions(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setDimensions : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setDimensions : Error processing arguments"); cobj->setDimensions(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_setDimensions : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_getFontSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_getFontSize : Invalid Native Object"); if (argc == 0) { double ret = cobj->getFontSize(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_getFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_getString(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_getString : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getString(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_getString : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_setTextDefinition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setTextDefinition : Invalid Native Object"); if (argc == 1) { cocos2d::FontDefinition arg0; ok &= jsval_to_FontDefinition(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setTextDefinition : Error processing arguments"); cobj->setTextDefinition(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_setTextDefinition : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_setFontName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setFontName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setFontName : Error processing arguments"); cobj->setFontName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_setFontName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_getHorizontalAlignment : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getHorizontalAlignment(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_getHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_initWithStringAndTextDefinition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_initWithStringAndTextDefinition : Invalid Native Object"); if (argc == 2) { std::string arg0; cocos2d::FontDefinition arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_FontDefinition(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_initWithStringAndTextDefinition : Error processing arguments"); JSBool ret = cobj->initWithStringAndTextDefinition(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_initWithStringAndTextDefinition : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_setString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setString : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setString : Error processing arguments"); cobj->setString(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_setString : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_initWithString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::LabelTTF* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_initWithString : Invalid Native Object"); do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg3; ok &= jsval_to_ccsize(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 3) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 6) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg3; ok &= jsval_to_ccsize(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextVAlignment arg5; ok &= jsval_to_int32(cx, argv[5], (int32_t *)&arg5); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4, arg5); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_LabelTTF_initWithString : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_setFontFillColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setFontFillColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setFontFillColor : Error processing arguments"); cobj->setFontFillColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { cocos2d::Color3B arg0; JSBool arg1; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setFontFillColor : Error processing arguments"); cobj->setFontFillColor(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_setFontFillColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_enableStroke(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_enableStroke : Invalid Native Object"); if (argc == 2) { cocos2d::Color3B arg0; double arg1; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_enableStroke : Error processing arguments"); cobj->enableStroke(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { cocos2d::Color3B arg0; double arg1; JSBool arg2; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_enableStroke : Error processing arguments"); cobj->enableStroke(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_enableStroke : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_getDimensions(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_getDimensions : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getDimensions(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_getDimensions : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_setVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setVerticalAlignment : Invalid Native Object"); if (argc == 1) { cocos2d::TextVAlignment arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setVerticalAlignment : Error processing arguments"); cobj->setVerticalAlignment(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_setVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setFontSize : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setFontSize : Error processing arguments"); cobj->setFontSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_getVerticalAlignment : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getVerticalAlignment(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_getVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_getTextDefinition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_getTextDefinition : Invalid Native Object"); if (argc == 0) { cocos2d::FontDefinition ret = cobj->getTextDefinition(); jsval jsret = JSVAL_NULL; jsret = FontDefinition_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_getTextDefinition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_getFontName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_getFontName : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getFontName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_getFontName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setHorizontalAlignment : Invalid Native Object"); if (argc == 1) { cocos2d::TextHAlignment arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_setHorizontalAlignment : Error processing arguments"); cobj->setHorizontalAlignment(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_setHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_disableShadow(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_disableShadow : Invalid Native Object"); if (argc == 0) { cobj->disableShadow(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_disableShadow : Error processing arguments"); cobj->disableShadow(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_disableShadow : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_disableStroke(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelTTF_disableStroke : Invalid Native Object"); if (argc == 0) { cobj->disableStroke(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_disableStroke : Error processing arguments"); cobj->disableStroke(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_disableStroke : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg3; ok &= jsval_to_ccsize(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 6) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg3; ok &= jsval_to_ccsize(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg4; ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextVAlignment arg5; ok &= jsval_to_int32(cx, argv[5], (int32_t *)&arg5); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2, arg3, arg4, arg5); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_LabelTTF_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_createWithFontDefinition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { std::string arg0; cocos2d::FontDefinition arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_FontDefinition(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelTTF_createWithFontDefinition : Error processing arguments"); cocos2d::LabelTTF* ret = cocos2d::LabelTTF::createWithFontDefinition(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_createWithFontDefinition : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_LabelTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::LabelTTF* cobj = new cocos2d::LabelTTF(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::LabelTTF"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelTTF_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Sprite_prototype; void js_cocos2d_LabelTTF_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LabelTTF)", obj); } void js_register_cocos2dx_LabelTTF(JSContext *cx, JSObject *global) { jsb_cocos2d_LabelTTF_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LabelTTF_class->name = "LabelTTF"; jsb_cocos2d_LabelTTF_class->addProperty = JS_PropertyStub; jsb_cocos2d_LabelTTF_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_LabelTTF_class->getProperty = JS_PropertyStub; jsb_cocos2d_LabelTTF_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_LabelTTF_class->enumerate = JS_EnumerateStub; jsb_cocos2d_LabelTTF_class->resolve = JS_ResolveStub; jsb_cocos2d_LabelTTF_class->convert = JS_ConvertStub; jsb_cocos2d_LabelTTF_class->finalize = js_cocos2d_LabelTTF_finalize; jsb_cocos2d_LabelTTF_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("enableShadow", js_cocos2dx_LabelTTF_enableShadow, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDimensions", js_cocos2dx_LabelTTF_setDimensions, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontSize", js_cocos2dx_LabelTTF_getFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_LabelTTF_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextDefinition", js_cocos2dx_LabelTTF_setTextDefinition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontName", js_cocos2dx_LabelTTF_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHorizontalAlignment", js_cocos2dx_LabelTTF_getHorizontalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithStringAndTextDefinition", js_cocos2dx_LabelTTF_initWithStringAndTextDefinition, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setString", js_cocos2dx_LabelTTF_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithString", js_cocos2dx_LabelTTF_initWithString, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_LabelTTF_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontFillColor", js_cocos2dx_LabelTTF_setFontFillColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableStroke", js_cocos2dx_LabelTTF_enableStroke, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDimensions", js_cocos2dx_LabelTTF_getDimensions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVerticalAlignment", js_cocos2dx_LabelTTF_setVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontSize", js_cocos2dx_LabelTTF_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVerticalAlignment", js_cocos2dx_LabelTTF_getVerticalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextDefinition", js_cocos2dx_LabelTTF_getTextDefinition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontName", js_cocos2dx_LabelTTF_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHorizontalAlignment", js_cocos2dx_LabelTTF_setHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("disableShadow", js_cocos2dx_LabelTTF_disableShadow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("disableStroke", js_cocos2dx_LabelTTF_disableStroke, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_LabelTTF_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithFontDefinition", js_cocos2dx_LabelTTF_createWithFontDefinition, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_LabelTTF_prototype = JS_InitClass( cx, global, jsb_cocos2d_Sprite_prototype, jsb_cocos2d_LabelTTF_class, js_cocos2dx_LabelTTF_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LabelTTF", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_LabelTTF_class; p->proto = jsb_cocos2d_LabelTTF_prototype; p->parentProto = jsb_cocos2d_Sprite_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_SpriteBatchNode_class; JSObject *jsb_cocos2d_SpriteBatchNode_prototype; JSBool js_cocos2dx_SpriteBatchNode_appendChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_appendChild : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_appendChild : Error processing arguments"); cobj->appendChild(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_appendChild : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_reorderBatch(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_reorderBatch : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_reorderBatch : Error processing arguments"); cobj->reorderBatch(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_reorderBatch : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_initWithTexture : Invalid Native Object"); if (argc == 2) { cocos2d::Texture2D* arg0; ssize_t arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ssize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_initWithTexture : Error processing arguments"); JSBool ret = cobj->initWithTexture(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_initWithTexture : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild : Error processing arguments"); ssize_t ret = cobj->lowestAtlasIndexInChild(arg0); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_atlasIndexForChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_atlasIndexForChild : Invalid Native Object"); if (argc == 2) { cocos2d::Sprite* arg0; int arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_atlasIndexForChild : Error processing arguments"); ssize_t ret = cobj->atlasIndexForChild(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_atlasIndexForChild : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_setTextureAtlas : Invalid Native Object"); if (argc == 1) { cocos2d::TextureAtlas* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_setTextureAtlas : Error processing arguments"); cobj->setTextureAtlas(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_setTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder : Invalid Native Object"); if (argc == 2) { cocos2d::Sprite* arg0; ssize_t arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ssize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder : Error processing arguments"); ssize_t ret = cobj->rebuildIndexInOrder(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity : Invalid Native Object"); if (argc == 0) { cobj->increaseAtlasCapacity(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_getTextureAtlas : Invalid Native Object"); if (argc == 0) { cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TextureAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_getTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_init(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::SpriteBatchNode* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_init : Invalid Native Object"); do { if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } ssize_t arg1; ok &= jsval_to_ssize(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithFile(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_init : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_setTexture : Invalid Native Object"); if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_setTexture : Error processing arguments"); cobj->setTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_getTexture : Invalid Native Object"); if (argc == 0) { cocos2d::Texture2D* ret = cobj->getTexture(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild : Error processing arguments"); ssize_t ret = cobj->highestAtlasIndexInChild(arg0); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_removeChildAtIndex : Invalid Native Object"); if (argc == 2) { ssize_t arg0; JSBool arg1; ok &= jsval_to_ssize(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_removeChildAtIndex : Error processing arguments"); cobj->removeChildAtIndex(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_removeChildAtIndex : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas : Error processing arguments"); cobj->removeSpriteFromAtlas(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_create : Error processing arguments"); cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { std::string arg0; ssize_t arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_ssize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_create : Error processing arguments"); cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_createWithTexture : Error processing arguments"); cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::createWithTexture(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { cocos2d::Texture2D* arg0; ssize_t arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ssize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_createWithTexture : Error processing arguments"); cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::createWithTexture(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_createWithTexture : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SpriteBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::SpriteBatchNode* cobj = new cocos2d::SpriteBatchNode(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::SpriteBatchNode"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_SpriteBatchNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SpriteBatchNode)", obj); } void js_register_cocos2dx_SpriteBatchNode(JSContext *cx, JSObject *global) { jsb_cocos2d_SpriteBatchNode_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SpriteBatchNode_class->name = "SpriteBatchNode"; jsb_cocos2d_SpriteBatchNode_class->addProperty = JS_PropertyStub; jsb_cocos2d_SpriteBatchNode_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_SpriteBatchNode_class->getProperty = JS_PropertyStub; jsb_cocos2d_SpriteBatchNode_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_SpriteBatchNode_class->enumerate = JS_EnumerateStub; jsb_cocos2d_SpriteBatchNode_class->resolve = JS_ResolveStub; jsb_cocos2d_SpriteBatchNode_class->convert = JS_ConvertStub; jsb_cocos2d_SpriteBatchNode_class->finalize = js_cocos2d_SpriteBatchNode_finalize; jsb_cocos2d_SpriteBatchNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("appendChild", js_cocos2dx_SpriteBatchNode_appendChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reorderBatch", js_cocos2dx_SpriteBatchNode_reorderBatch, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTexture", js_cocos2dx_SpriteBatchNode_initWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("lowestAtlasIndexInChild", js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("atlasIndexForChild", js_cocos2dx_SpriteBatchNode_atlasIndexForChild, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextureAtlas", js_cocos2dx_SpriteBatchNode_setTextureAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("rebuildIndexInOrder", js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("increaseAtlasCapacity", js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureAtlas", js_cocos2dx_SpriteBatchNode_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_SpriteBatchNode_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTexture", js_cocos2dx_SpriteBatchNode_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTexture", js_cocos2dx_SpriteBatchNode_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("highestAtlasIndexInChild", js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeChildAtIndex", js_cocos2dx_SpriteBatchNode_removeChildAtIndex, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeSpriteFromAtlas", js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_SpriteBatchNode_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTexture", js_cocos2dx_SpriteBatchNode_createWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_SpriteBatchNode_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_SpriteBatchNode_class, js_cocos2dx_SpriteBatchNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SpriteBatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_SpriteBatchNode_class; p->proto = jsb_cocos2d_SpriteBatchNode_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_LabelBMFont_class; JSObject *jsb_cocos2d_LabelBMFont_prototype; JSBool js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace : Error processing arguments"); cobj->setLineBreakWithoutSpace(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setScaleY(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setScaleY : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setScaleY : Error processing arguments"); cobj->setScaleY(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setScaleY : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setScaleX(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setScaleX : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setScaleX : Error processing arguments"); cobj->setScaleX(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setScaleX : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_isOpacityModifyRGB : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isOpacityModifyRGB(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_isOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_createFontChars(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_createFontChars : Invalid Native Object"); if (argc == 0) { cobj->createFontChars(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_createFontChars : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_getString(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_getString : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getString(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_getString : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::LabelBMFont* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setString : Invalid Native Object"); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool arg1; ok &= JS_ValueToBoolean(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj->setString(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setString(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setString : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_initWithString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_initWithString : Invalid Native Object"); if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_initWithString : Error processing arguments"); JSBool ret = cobj->initWithString(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 3) { std::string arg0; std::string arg1; double arg2; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_initWithString : Error processing arguments"); JSBool ret = cobj->initWithString(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 4) { std::string arg0; std::string arg1; double arg2; cocos2d::TextHAlignment arg3; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_initWithString : Error processing arguments"); JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 5) { std::string arg0; std::string arg1; double arg2; cocos2d::TextHAlignment arg3; cocos2d::Point arg4; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); ok &= jsval_to_ccpoint(cx, argv[4], &arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_initWithString : Error processing arguments"); JSBool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_initWithString : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setCString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setCString : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setCString : Error processing arguments"); cobj->setCString(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setCString : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setScale(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setScale : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setScale : Error processing arguments"); cobj->setScale(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setScale : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setOpacityModifyRGB : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setOpacityModifyRGB : Error processing arguments"); cobj->setOpacityModifyRGB(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setFntFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setFntFile : Error processing arguments"); cobj->setFntFile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setFntFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_getFntFile(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_getFntFile : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getFntFile(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_getFntFile : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_updateLabel(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_updateLabel : Invalid Native Object"); if (argc == 0) { cobj->updateLabel(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_updateLabel : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setAlignment : Invalid Native Object"); if (argc == 1) { cocos2d::TextHAlignment arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setAlignment : Error processing arguments"); cobj->setAlignment(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_setWidth(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setWidth : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LabelBMFont_setWidth : Error processing arguments"); cobj->setWidth(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setWidth : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_purgeCachedData(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::LabelBMFont::purgeCachedData(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_purgeCachedData : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 4) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg4; ok &= jsval_to_ccpoint(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_LabelBMFont_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_LabelBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::LabelBMFont* cobj = new cocos2d::LabelBMFont(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::LabelBMFont"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LabelBMFont_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype; void js_cocos2d_LabelBMFont_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LabelBMFont)", obj); } void js_register_cocos2dx_LabelBMFont(JSContext *cx, JSObject *global) { jsb_cocos2d_LabelBMFont_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LabelBMFont_class->name = "LabelBMFont"; jsb_cocos2d_LabelBMFont_class->addProperty = JS_PropertyStub; jsb_cocos2d_LabelBMFont_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_LabelBMFont_class->getProperty = JS_PropertyStub; jsb_cocos2d_LabelBMFont_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_LabelBMFont_class->enumerate = JS_EnumerateStub; jsb_cocos2d_LabelBMFont_class->resolve = JS_ResolveStub; jsb_cocos2d_LabelBMFont_class->convert = JS_ConvertStub; jsb_cocos2d_LabelBMFont_class->finalize = js_cocos2d_LabelBMFont_finalize; jsb_cocos2d_LabelBMFont_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setLineBreakWithoutSpace", js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScaleY", js_cocos2dx_LabelBMFont_setScaleY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScaleX", js_cocos2dx_LabelBMFont_setScaleX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isOpacityModifyRGB", js_cocos2dx_LabelBMFont_isOpacityModifyRGB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createFontChars", js_cocos2dx_LabelBMFont_createFontChars, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_LabelBMFont_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setString", js_cocos2dx_LabelBMFont_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithString", js_cocos2dx_LabelBMFont_initWithString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCString", js_cocos2dx_LabelBMFont_setCString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale", js_cocos2dx_LabelBMFont_setScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOpacityModifyRGB", js_cocos2dx_LabelBMFont_setOpacityModifyRGB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFntFile", js_cocos2dx_LabelBMFont_setFntFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_LabelBMFont_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFntFile", js_cocos2dx_LabelBMFont_getFntFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateLabel", js_cocos2dx_LabelBMFont_updateLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlignment", js_cocos2dx_LabelBMFont_setAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setWidth", js_cocos2dx_LabelBMFont_setWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("purgeCachedData", js_cocos2dx_LabelBMFont_purgeCachedData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("create", js_cocos2dx_LabelBMFont_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_LabelBMFont_prototype = JS_InitClass( cx, global, jsb_cocos2d_SpriteBatchNode_prototype, jsb_cocos2d_LabelBMFont_class, js_cocos2dx_LabelBMFont_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LabelBMFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_LabelBMFont_class; p->proto = jsb_cocos2d_LabelBMFont_prototype; p->parentProto = jsb_cocos2d_SpriteBatchNode_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Label_class; JSObject *jsb_cocos2d_Label_prototype; JSBool js_cocos2dx_Label_getString(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getString : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getString(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getString : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_assignNewUTF16String(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_assignNewUTF16String : Invalid Native Object"); if (argc == 1) { unsigned short* arg0; #pragma warning NO CONVERSION TO NATIVE FOR unsigned short*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_assignNewUTF16String : Error processing arguments"); cobj->assignNewUTF16String(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_assignNewUTF16String : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Label_setLabelEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_setLabelEffect : Invalid Native Object"); if (argc == 2) { cocos2d::LabelEffect arg0; cocos2d::Color3B arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_cccolor3b(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_setLabelEffect : Error processing arguments"); cobj->setLabelEffect(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_setLabelEffect : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_Label_getCommonLineHeight(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getCommonLineHeight : Invalid Native Object"); if (argc == 0) { int ret = cobj->getCommonLineHeight(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getCommonLineHeight : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_breakLineWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_breakLineWithoutSpace : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->breakLineWithoutSpace(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_breakLineWithoutSpace : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_setWidth : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_setWidth : Error processing arguments"); cobj->setWidth(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_setWidth : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getMaxLineWidth : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMaxLineWidth(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getMaxLineWidth : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_getScaleY(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getScaleY : Invalid Native Object"); if (argc == 0) { double ret = cobj->getScaleY(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getScaleY : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_getScaleX(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getScaleX : Invalid Native Object"); if (argc == 0) { double ret = cobj->getScaleX(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getScaleX : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_setString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_setString : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_setString : Error processing arguments"); cobj->setString(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_setString : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Label_getKernings(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getKernings : Invalid Native Object"); if (argc == 0) { int* ret = cobj->getKernings(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR int*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getKernings : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_setBMFontFilePath : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_setBMFontFilePath : Error processing arguments"); JSBool ret = cobj->setBMFontFilePath(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_setBMFontFilePath : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Label_recordPlaceholderInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_recordPlaceholderInfo : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_recordPlaceholderInfo : Error processing arguments"); JSBool ret = cobj->recordPlaceholderInfo(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_recordPlaceholderInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Label_getFontAtlas(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getFontAtlas : Invalid Native Object"); if (argc == 0) { cocos2d::FontAtlas* ret = cobj->getFontAtlas(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FontAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getFontAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_setLineBreakWithoutSpace : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_setLineBreakWithoutSpace : Error processing arguments"); cobj->setLineBreakWithoutSpace(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_setLineBreakWithoutSpace : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Label_getStringNumLines(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getStringNumLines : Invalid Native Object"); if (argc == 0) { int ret = cobj->getStringNumLines(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getStringNumLines : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_getUTF16String(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getUTF16String : Invalid Native Object"); if (argc == 0) { unsigned short* ret = cobj->getUTF16String(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR unsigned short*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getUTF16String : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_getStringLenght(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getStringLenght : Invalid Native Object"); if (argc == 0) { int ret = cobj->getStringLenght(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getStringLenght : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_onDraw(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_onDraw : Invalid Native Object"); if (argc == 0) { cobj->onDraw(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_onDraw : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::Label* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_setCharMap : Invalid Native Object"); do { if (argc == 4) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } int arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->setCharMap(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 4) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } int arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->setCharMap(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->setCharMap(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_Label_setCharMap : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getLetter : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_getLetter : Error processing arguments"); cocos2d::Sprite* ret = cobj->getLetter(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getLetter : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Label_getTextAlignment(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_getTextAlignment : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getTextAlignment(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_getTextAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_setAlignment : Invalid Native Object"); if (argc == 1) { cocos2d::TextHAlignment arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_setAlignment : Error processing arguments"); cobj->setAlignment(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_setAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Label_recordLetterInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_recordLetterInfo : Invalid Native Object"); if (argc == 3) { cocos2d::Point arg0; unsigned short arg1; int arg2; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= jsval_to_ushort(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_recordLetterInfo : Error processing arguments"); JSBool ret = cobj->recordLetterInfo(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_recordLetterInfo : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_Label_createWithBMFont(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_createWithBMFont : Error processing arguments"); cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 3) { std::string arg0; std::string arg1; cocos2d::TextHAlignment arg2; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_createWithBMFont : Error processing arguments"); cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 4) { std::string arg0; std::string arg1; cocos2d::TextHAlignment arg2; int arg3; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_createWithBMFont : Error processing arguments"); cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_createWithBMFont : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Label_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Label* ret = cocos2d::Label::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Label_createWithCharMap(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 4) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } int arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 4) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } int arg3; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_Label_createWithCharMap : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype; void js_cocos2d_Label_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Label)", obj); } void js_register_cocos2dx_Label(JSContext *cx, JSObject *global) { jsb_cocos2d_Label_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Label_class->name = "Label"; jsb_cocos2d_Label_class->addProperty = JS_PropertyStub; jsb_cocos2d_Label_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Label_class->getProperty = JS_PropertyStub; jsb_cocos2d_Label_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Label_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Label_class->resolve = JS_ResolveStub; jsb_cocos2d_Label_class->convert = JS_ConvertStub; jsb_cocos2d_Label_class->finalize = js_cocos2d_Label_finalize; jsb_cocos2d_Label_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getString", js_cocos2dx_Label_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("assignNewUTF16String", js_cocos2dx_Label_assignNewUTF16String, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLabelEffect", js_cocos2dx_Label_setLabelEffect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCommonLineHeight", js_cocos2dx_Label_getCommonLineHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("breakLineWithoutSpace", js_cocos2dx_Label_breakLineWithoutSpace, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setWidth", js_cocos2dx_Label_setWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxLineWidth", js_cocos2dx_Label_getMaxLineWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScaleY", js_cocos2dx_Label_getScaleY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScaleX", js_cocos2dx_Label_getScaleX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setString", js_cocos2dx_Label_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getKernings", js_cocos2dx_Label_getKernings, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBMFontFilePath", js_cocos2dx_Label_setBMFontFilePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("recordPlaceholderInfo", js_cocos2dx_Label_recordPlaceholderInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontAtlas", js_cocos2dx_Label_getFontAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLineBreakWithoutSpace", js_cocos2dx_Label_setLineBreakWithoutSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringNumLines", js_cocos2dx_Label_getStringNumLines, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUTF16String", js_cocos2dx_Label_getUTF16String, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringLenght", js_cocos2dx_Label_getStringLenght, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onDraw", js_cocos2dx_Label_onDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCharMap", js_cocos2dx_Label_setCharMap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLetter", js_cocos2dx_Label_getLetter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextAlignment", js_cocos2dx_Label_getTextAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlignment", js_cocos2dx_Label_setAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("recordLetterInfo", js_cocos2dx_Label_recordLetterInfo, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("createWithBMFont", js_cocos2dx_Label_createWithBMFont, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("create", js_cocos2dx_Label_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithCharMap", js_cocos2dx_Label_createWithCharMap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Label_prototype = JS_InitClass( cx, global, jsb_cocos2d_SpriteBatchNode_prototype, jsb_cocos2d_Label_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Label", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Label_class; p->proto = jsb_cocos2d_Label_prototype; p->parentProto = jsb_cocos2d_SpriteBatchNode_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Layer_class; JSObject *jsb_cocos2d_Layer_prototype; JSBool js_cocos2dx_Layer_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Layer* ret = cocos2d::Layer::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Layer*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Layer_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_Layer_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Layer)", obj); } static JSBool js_cocos2d_Layer_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::Layer *nobj = cocos2d::Layer::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Layer"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_Layer(JSContext *cx, JSObject *global) { jsb_cocos2d_Layer_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Layer_class->name = "Layer"; jsb_cocos2d_Layer_class->addProperty = JS_PropertyStub; jsb_cocos2d_Layer_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Layer_class->getProperty = JS_PropertyStub; jsb_cocos2d_Layer_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Layer_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Layer_class->resolve = JS_ResolveStub; jsb_cocos2d_Layer_class->convert = JS_ConvertStub; jsb_cocos2d_Layer_class->finalize = js_cocos2d_Layer_finalize; jsb_cocos2d_Layer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("ctor", js_cocos2d_Layer_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Layer_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Layer_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_Layer_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Layer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Layer_class; p->proto = jsb_cocos2d_Layer_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d___LayerRGBA_class; JSObject *jsb_cocos2d___LayerRGBA_prototype; JSBool js_cocos2dx___LayerRGBA_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::__LayerRGBA* ret = cocos2d::__LayerRGBA::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::__LayerRGBA*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx___LayerRGBA_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Layer_prototype; void js_cocos2d___LayerRGBA_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (__LayerRGBA)", obj); } void js_register_cocos2dx___LayerRGBA(JSContext *cx, JSObject *global) { jsb_cocos2d___LayerRGBA_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d___LayerRGBA_class->name = "LayerRGBA"; jsb_cocos2d___LayerRGBA_class->addProperty = JS_PropertyStub; jsb_cocos2d___LayerRGBA_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d___LayerRGBA_class->getProperty = JS_PropertyStub; jsb_cocos2d___LayerRGBA_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d___LayerRGBA_class->enumerate = JS_EnumerateStub; jsb_cocos2d___LayerRGBA_class->resolve = JS_ResolveStub; jsb_cocos2d___LayerRGBA_class->convert = JS_ConvertStub; jsb_cocos2d___LayerRGBA_class->finalize = js_cocos2d___LayerRGBA_finalize; jsb_cocos2d___LayerRGBA_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx___LayerRGBA_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d___LayerRGBA_prototype = JS_InitClass( cx, global, jsb_cocos2d_Layer_prototype, jsb_cocos2d___LayerRGBA_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LayerRGBA", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d___LayerRGBA_class; p->proto = jsb_cocos2d___LayerRGBA_prototype; p->parentProto = jsb_cocos2d_Layer_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_LayerColor_class; JSObject *jsb_cocos2d_LayerColor_prototype; JSBool js_cocos2dx_LayerColor_changeWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerColor_changeWidthAndHeight : Invalid Native Object"); if (argc == 2) { double arg0; double arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerColor_changeWidthAndHeight : Error processing arguments"); cobj->changeWidthAndHeight(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerColor_changeWidthAndHeight : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_LayerColor_onDraw(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerColor_onDraw : Invalid Native Object"); if (argc == 0) { cobj->onDraw(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerColor_onDraw : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LayerColor_changeWidth(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerColor_changeWidth : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerColor_changeWidth : Error processing arguments"); cobj->changeWidth(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerColor_changeWidth : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerColor_changeHeight(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerColor_changeHeight : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerColor_changeHeight : Error processing arguments"); cobj->changeHeight(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerColor_changeHeight : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerColor_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { cocos2d::Color4B arg0; ok &= jsval_to_cccolor4b(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::LayerColor* ret = cocos2d::LayerColor::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LayerColor*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::LayerColor* ret = cocos2d::LayerColor::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LayerColor*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 1) { cocos2d::Color4B arg0; ok &= jsval_to_cccolor4b(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::LayerColor* ret = cocos2d::LayerColor::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LayerColor*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_LayerColor_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Layer_prototype; void js_cocos2d_LayerColor_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LayerColor)", obj); } static JSBool js_cocos2d_LayerColor_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::LayerColor *nobj = cocos2d::LayerColor::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerColor"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_LayerColor(JSContext *cx, JSObject *global) { jsb_cocos2d_LayerColor_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LayerColor_class->name = "LayerColor"; jsb_cocos2d_LayerColor_class->addProperty = JS_PropertyStub; jsb_cocos2d_LayerColor_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_LayerColor_class->getProperty = JS_PropertyStub; jsb_cocos2d_LayerColor_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_LayerColor_class->enumerate = JS_EnumerateStub; jsb_cocos2d_LayerColor_class->resolve = JS_ResolveStub; jsb_cocos2d_LayerColor_class->convert = JS_ConvertStub; jsb_cocos2d_LayerColor_class->finalize = js_cocos2d_LayerColor_finalize; jsb_cocos2d_LayerColor_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("changeWidthAndHeight", js_cocos2dx_LayerColor_changeWidthAndHeight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onDraw", js_cocos2dx_LayerColor_onDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("changeWidth", js_cocos2dx_LayerColor_changeWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("changeHeight", js_cocos2dx_LayerColor_changeHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_LayerColor_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_LayerColor_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_LayerColor_prototype = JS_InitClass( cx, global, jsb_cocos2d_Layer_prototype, jsb_cocos2d_LayerColor_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LayerColor", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_LayerColor_class; p->proto = jsb_cocos2d_LayerColor_prototype; p->parentProto = jsb_cocos2d_Layer_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_LayerGradient_class; JSObject *jsb_cocos2d_LayerGradient_prototype; JSBool js_cocos2dx_LayerGradient_getStartColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_getStartColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color3B& ret = cobj->getStartColor(); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_getStartColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_isCompressedInterpolation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_isCompressedInterpolation : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isCompressedInterpolation(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_isCompressedInterpolation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_getStartOpacity(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_getStartOpacity : Invalid Native Object"); if (argc == 0) { uint16_t ret = cobj->getStartOpacity(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_getStartOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_setVector(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setVector : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setVector : Error processing arguments"); cobj->setVector(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_setVector : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_setStartOpacity(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setStartOpacity : Invalid Native Object"); if (argc == 1) { uint16_t arg0; ok &= jsval_to_uint16(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setStartOpacity : Error processing arguments"); cobj->setStartOpacity(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_setStartOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_setCompressedInterpolation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setCompressedInterpolation : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setCompressedInterpolation : Error processing arguments"); cobj->setCompressedInterpolation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_setCompressedInterpolation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_setEndOpacity(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setEndOpacity : Invalid Native Object"); if (argc == 1) { uint16_t arg0; ok &= jsval_to_uint16(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setEndOpacity : Error processing arguments"); cobj->setEndOpacity(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_setEndOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_getVector(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_getVector : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getVector(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_getVector : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_initWithColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::LayerGradient* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_initWithColor : Invalid Native Object"); do { if (argc == 2) { cocos2d::Color4B arg0; ok &= jsval_to_cccolor4b(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Color4B arg1; ok &= jsval_to_cccolor4b(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithColor(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 3) { cocos2d::Color4B arg0; ok &= jsval_to_cccolor4b(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Color4B arg1; ok &= jsval_to_cccolor4b(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg2; ok &= jsval_to_ccpoint(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithColor(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_LayerGradient_initWithColor : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_setEndColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setEndColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setEndColor : Error processing arguments"); cobj->setEndColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_setEndColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_getEndColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_getEndColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color3B& ret = cobj->getEndColor(); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_getEndColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_getEndOpacity(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_getEndOpacity : Invalid Native Object"); if (argc == 0) { uint16_t ret = cobj->getEndOpacity(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_getEndOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_setStartColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setStartColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerGradient_setStartColor : Error processing arguments"); cobj->setStartColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerGradient_setStartColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerGradient_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { cocos2d::Color4B arg0; ok &= jsval_to_cccolor4b(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Color4B arg1; ok &= jsval_to_cccolor4b(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LayerGradient*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LayerGradient*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { cocos2d::Color4B arg0; ok &= jsval_to_cccolor4b(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Color4B arg1; ok &= jsval_to_cccolor4b(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg2; ok &= jsval_to_ccpoint(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LayerGradient*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_LayerGradient_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_LayerColor_prototype; void js_cocos2d_LayerGradient_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LayerGradient)", obj); } static JSBool js_cocos2d_LayerGradient_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::LayerGradient *nobj = cocos2d::LayerGradient::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerGradient"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_LayerGradient(JSContext *cx, JSObject *global) { jsb_cocos2d_LayerGradient_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LayerGradient_class->name = "LayerGradient"; jsb_cocos2d_LayerGradient_class->addProperty = JS_PropertyStub; jsb_cocos2d_LayerGradient_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_LayerGradient_class->getProperty = JS_PropertyStub; jsb_cocos2d_LayerGradient_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_LayerGradient_class->enumerate = JS_EnumerateStub; jsb_cocos2d_LayerGradient_class->resolve = JS_ResolveStub; jsb_cocos2d_LayerGradient_class->convert = JS_ConvertStub; jsb_cocos2d_LayerGradient_class->finalize = js_cocos2d_LayerGradient_finalize; jsb_cocos2d_LayerGradient_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getStartColor", js_cocos2dx_LayerGradient_getStartColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isCompressedInterpolation", js_cocos2dx_LayerGradient_isCompressedInterpolation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartOpacity", js_cocos2dx_LayerGradient_getStartOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVector", js_cocos2dx_LayerGradient_setVector, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartOpacity", js_cocos2dx_LayerGradient_setStartOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCompressedInterpolation", js_cocos2dx_LayerGradient_setCompressedInterpolation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndOpacity", js_cocos2dx_LayerGradient_setEndOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVector", js_cocos2dx_LayerGradient_getVector, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_LayerGradient_initWithColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndColor", js_cocos2dx_LayerGradient_setEndColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndColor", js_cocos2dx_LayerGradient_getEndColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndOpacity", js_cocos2dx_LayerGradient_getEndOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartColor", js_cocos2dx_LayerGradient_setStartColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_LayerGradient_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_LayerGradient_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_LayerGradient_prototype = JS_InitClass( cx, global, jsb_cocos2d_LayerColor_prototype, jsb_cocos2d_LayerGradient_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LayerGradient", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_LayerGradient_class; p->proto = jsb_cocos2d_LayerGradient_prototype; p->parentProto = jsb_cocos2d_LayerColor_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_LayerMultiplex_class; JSObject *jsb_cocos2d_LayerMultiplex_prototype; JSBool js_cocos2dx_LayerMultiplex_switchToAndReleaseMe(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerMultiplex* cobj = (cocos2d::LayerMultiplex *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerMultiplex_switchToAndReleaseMe : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerMultiplex_switchToAndReleaseMe : Error processing arguments"); cobj->switchToAndReleaseMe(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerMultiplex_switchToAndReleaseMe : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerMultiplex_addLayer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerMultiplex* cobj = (cocos2d::LayerMultiplex *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerMultiplex_addLayer : Invalid Native Object"); if (argc == 1) { cocos2d::Layer* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Layer*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerMultiplex_addLayer : Error processing arguments"); cobj->addLayer(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerMultiplex_addLayer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_LayerMultiplex_switchTo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::LayerMultiplex* cobj = (cocos2d::LayerMultiplex *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_LayerMultiplex_switchTo : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_LayerMultiplex_switchTo : Error processing arguments"); cobj->switchTo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_LayerMultiplex_switchTo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_Layer_prototype; void js_cocos2d_LayerMultiplex_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LayerMultiplex)", obj); } static JSBool js_cocos2d_LayerMultiplex_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::LayerMultiplex *nobj = cocos2d::LayerMultiplex::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerMultiplex"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_LayerMultiplex(JSContext *cx, JSObject *global) { jsb_cocos2d_LayerMultiplex_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LayerMultiplex_class->name = "LayerMultiplex"; jsb_cocos2d_LayerMultiplex_class->addProperty = JS_PropertyStub; jsb_cocos2d_LayerMultiplex_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_LayerMultiplex_class->getProperty = JS_PropertyStub; jsb_cocos2d_LayerMultiplex_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_LayerMultiplex_class->enumerate = JS_EnumerateStub; jsb_cocos2d_LayerMultiplex_class->resolve = JS_ResolveStub; jsb_cocos2d_LayerMultiplex_class->convert = JS_ConvertStub; jsb_cocos2d_LayerMultiplex_class->finalize = js_cocos2d_LayerMultiplex_finalize; jsb_cocos2d_LayerMultiplex_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("switchToAndReleaseMe", js_cocos2dx_LayerMultiplex_switchToAndReleaseMe, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addLayer", js_cocos2dx_LayerMultiplex_addLayer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("switchTo", js_cocos2dx_LayerMultiplex_switchTo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_LayerMultiplex_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_LayerMultiplex_prototype = JS_InitClass( cx, global, jsb_cocos2d_Layer_prototype, jsb_cocos2d_LayerMultiplex_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LayerMultiplex", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_LayerMultiplex_class; p->proto = jsb_cocos2d_LayerMultiplex_prototype; p->parentProto = jsb_cocos2d_Layer_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Scene_class; JSObject *jsb_cocos2d_Scene_prototype; JSBool js_cocos2dx_Scene_getPhysicsWorld(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Scene_getPhysicsWorld : Invalid Native Object"); if (argc == 0) { cocos2d::PhysicsWorld* ret = cobj->getPhysicsWorld(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::PhysicsWorld*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Scene_getPhysicsWorld : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Scene_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Scene* ret = cocos2d::Scene::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Scene_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Scene_createWithPhysics(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Scene* ret = cocos2d::Scene::createWithPhysics(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Scene_createWithPhysics : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_Scene_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Scene)", obj); } static JSBool js_cocos2d_Scene_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::Scene *nobj = cocos2d::Scene::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Scene"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_Scene(JSContext *cx, JSObject *global) { jsb_cocos2d_Scene_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Scene_class->name = "Scene"; jsb_cocos2d_Scene_class->addProperty = JS_PropertyStub; jsb_cocos2d_Scene_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Scene_class->getProperty = JS_PropertyStub; jsb_cocos2d_Scene_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Scene_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Scene_class->resolve = JS_ResolveStub; jsb_cocos2d_Scene_class->convert = JS_ConvertStub; jsb_cocos2d_Scene_class->finalize = js_cocos2d_Scene_finalize; jsb_cocos2d_Scene_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getPhysicsWorld", js_cocos2dx_Scene_getPhysicsWorld, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_Scene_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Scene_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithPhysics", js_cocos2dx_Scene_createWithPhysics, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Scene_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_Scene_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Scene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Scene_class; p->proto = jsb_cocos2d_Scene_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionEaseScene_class; JSObject *jsb_cocos2d_TransitionEaseScene_prototype; JSBool js_cocos2dx_TransitionEaseScene_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionEaseScene* cobj = (cocos2d::TransitionEaseScene *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionEaseScene_easeActionWithAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionEaseScene_easeActionWithAction : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionEaseScene_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } void js_cocos2d_TransitionEaseScene_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionEaseScene)", obj); } void js_register_cocos2dx_TransitionEaseScene(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionEaseScene_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionEaseScene_class->name = "TransitionEaseScene"; jsb_cocos2d_TransitionEaseScene_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionEaseScene_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionEaseScene_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionEaseScene_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionEaseScene_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionEaseScene_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionEaseScene_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionEaseScene_class->finalize = js_cocos2d_TransitionEaseScene_finalize; jsb_cocos2d_TransitionEaseScene_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("easeActionWithAction", js_cocos2dx_TransitionEaseScene_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_TransitionEaseScene_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_TransitionEaseScene_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionEaseScene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionEaseScene_class; p->proto = jsb_cocos2d_TransitionEaseScene_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionScene_class; JSObject *jsb_cocos2d_TransitionScene_prototype; JSBool js_cocos2dx_TransitionScene_finish(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionScene* cobj = (cocos2d::TransitionScene *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionScene_finish : Invalid Native Object"); if (argc == 0) { cobj->finish(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionScene_finish : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TransitionScene_hideOutShowIn(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionScene* cobj = (cocos2d::TransitionScene *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionScene_hideOutShowIn : Invalid Native Object"); if (argc == 0) { cobj->hideOutShowIn(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionScene_hideOutShowIn : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TransitionScene_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionScene_create : Error processing arguments"); cocos2d::TransitionScene* ret = cocos2d::TransitionScene::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionScene*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionScene_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Scene_prototype; void js_cocos2d_TransitionScene_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionScene)", obj); } void js_register_cocos2dx_TransitionScene(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionScene_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionScene_class->name = "TransitionScene"; jsb_cocos2d_TransitionScene_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionScene_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionScene_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionScene_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionScene_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionScene_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionScene_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionScene_class->finalize = js_cocos2d_TransitionScene_finalize; jsb_cocos2d_TransitionScene_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("finish", js_cocos2dx_TransitionScene_finish, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hideOutShowIn", js_cocos2dx_TransitionScene_hideOutShowIn, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionScene_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionScene_prototype = JS_InitClass( cx, global, jsb_cocos2d_Scene_prototype, jsb_cocos2d_TransitionScene_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionScene", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionScene_class; p->proto = jsb_cocos2d_TransitionScene_prototype; p->parentProto = jsb_cocos2d_Scene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionSceneOriented_class; JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; JSBool js_cocos2dx_TransitionSceneOriented_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { double arg0; cocos2d::Scene* arg1; cocos2d::TransitionScene::Orientation arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSceneOriented_create : Error processing arguments"); cocos2d::TransitionSceneOriented* ret = cocos2d::TransitionSceneOriented::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSceneOriented*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSceneOriented_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionSceneOriented_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSceneOriented)", obj); } void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionSceneOriented_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSceneOriented_class->name = "TransitionSceneOriented"; jsb_cocos2d_TransitionSceneOriented_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionSceneOriented_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionSceneOriented_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionSceneOriented_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionSceneOriented_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionSceneOriented_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionSceneOriented_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionSceneOriented_class->finalize = js_cocos2d_TransitionSceneOriented_finalize; jsb_cocos2d_TransitionSceneOriented_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionSceneOriented_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionSceneOriented_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionSceneOriented_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionSceneOriented", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionSceneOriented_class; p->proto = jsb_cocos2d_TransitionSceneOriented_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionRotoZoom_class; JSObject *jsb_cocos2d_TransitionRotoZoom_prototype; JSBool js_cocos2dx_TransitionRotoZoom_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionRotoZoom_create : Error processing arguments"); cocos2d::TransitionRotoZoom* ret = cocos2d::TransitionRotoZoom::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionRotoZoom*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionRotoZoom_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionRotoZoom_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionRotoZoom)", obj); } void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionRotoZoom_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionRotoZoom_class->name = "TransitionRotoZoom"; jsb_cocos2d_TransitionRotoZoom_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionRotoZoom_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionRotoZoom_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionRotoZoom_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionRotoZoom_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionRotoZoom_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionRotoZoom_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionRotoZoom_class->finalize = js_cocos2d_TransitionRotoZoom_finalize; jsb_cocos2d_TransitionRotoZoom_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionRotoZoom_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionRotoZoom_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionRotoZoom_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionRotoZoom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionRotoZoom_class; p->proto = jsb_cocos2d_TransitionRotoZoom_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionJumpZoom_class; JSObject *jsb_cocos2d_TransitionJumpZoom_prototype; JSBool js_cocos2dx_TransitionJumpZoom_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionJumpZoom_create : Error processing arguments"); cocos2d::TransitionJumpZoom* ret = cocos2d::TransitionJumpZoom::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionJumpZoom*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionJumpZoom_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionJumpZoom_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionJumpZoom)", obj); } void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionJumpZoom_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionJumpZoom_class->name = "TransitionJumpZoom"; jsb_cocos2d_TransitionJumpZoom_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionJumpZoom_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionJumpZoom_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionJumpZoom_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionJumpZoom_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionJumpZoom_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionJumpZoom_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionJumpZoom_class->finalize = js_cocos2d_TransitionJumpZoom_finalize; jsb_cocos2d_TransitionJumpZoom_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionJumpZoom_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionJumpZoom_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionJumpZoom_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionJumpZoom", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionJumpZoom_class; p->proto = jsb_cocos2d_TransitionJumpZoom_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionMoveInL_class; JSObject *jsb_cocos2d_TransitionMoveInL_prototype; JSBool js_cocos2dx_TransitionMoveInL_action(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionMoveInL* cobj = (cocos2d::TransitionMoveInL *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionMoveInL_action : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->action(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionMoveInL_action : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TransitionMoveInL_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionMoveInL* cobj = (cocos2d::TransitionMoveInL *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionMoveInL_easeActionWithAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionMoveInL_easeActionWithAction : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionMoveInL_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TransitionMoveInL_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionMoveInL_create : Error processing arguments"); cocos2d::TransitionMoveInL* ret = cocos2d::TransitionMoveInL::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionMoveInL*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionMoveInL_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionMoveInL_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInL)", obj); } void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionMoveInL_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionMoveInL_class->name = "TransitionMoveInL"; jsb_cocos2d_TransitionMoveInL_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionMoveInL_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionMoveInL_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionMoveInL_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionMoveInL_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionMoveInL_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionMoveInL_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionMoveInL_class->finalize = js_cocos2d_TransitionMoveInL_finalize; jsb_cocos2d_TransitionMoveInL_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionMoveInL_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("easeActionWithAction", js_cocos2dx_TransitionMoveInL_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionMoveInL_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionMoveInL_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionMoveInL_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionMoveInL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionMoveInL_class; p->proto = jsb_cocos2d_TransitionMoveInL_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionMoveInR_class; JSObject *jsb_cocos2d_TransitionMoveInR_prototype; JSBool js_cocos2dx_TransitionMoveInR_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionMoveInR_create : Error processing arguments"); cocos2d::TransitionMoveInR* ret = cocos2d::TransitionMoveInR::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionMoveInR*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionMoveInR_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; void js_cocos2d_TransitionMoveInR_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInR)", obj); } void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionMoveInR_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionMoveInR_class->name = "TransitionMoveInR"; jsb_cocos2d_TransitionMoveInR_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionMoveInR_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionMoveInR_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionMoveInR_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionMoveInR_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionMoveInR_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionMoveInR_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionMoveInR_class->finalize = js_cocos2d_TransitionMoveInR_finalize; jsb_cocos2d_TransitionMoveInR_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionMoveInR_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionMoveInR_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionMoveInL_prototype, jsb_cocos2d_TransitionMoveInR_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionMoveInR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionMoveInR_class; p->proto = jsb_cocos2d_TransitionMoveInR_prototype; p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionMoveInT_class; JSObject *jsb_cocos2d_TransitionMoveInT_prototype; JSBool js_cocos2dx_TransitionMoveInT_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionMoveInT_create : Error processing arguments"); cocos2d::TransitionMoveInT* ret = cocos2d::TransitionMoveInT::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionMoveInT*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionMoveInT_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; void js_cocos2d_TransitionMoveInT_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInT)", obj); } void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionMoveInT_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionMoveInT_class->name = "TransitionMoveInT"; jsb_cocos2d_TransitionMoveInT_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionMoveInT_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionMoveInT_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionMoveInT_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionMoveInT_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionMoveInT_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionMoveInT_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionMoveInT_class->finalize = js_cocos2d_TransitionMoveInT_finalize; jsb_cocos2d_TransitionMoveInT_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionMoveInT_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionMoveInT_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionMoveInL_prototype, jsb_cocos2d_TransitionMoveInT_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionMoveInT", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionMoveInT_class; p->proto = jsb_cocos2d_TransitionMoveInT_prototype; p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionMoveInB_class; JSObject *jsb_cocos2d_TransitionMoveInB_prototype; JSBool js_cocos2dx_TransitionMoveInB_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionMoveInB_create : Error processing arguments"); cocos2d::TransitionMoveInB* ret = cocos2d::TransitionMoveInB::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionMoveInB*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionMoveInB_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; void js_cocos2d_TransitionMoveInB_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInB)", obj); } void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionMoveInB_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionMoveInB_class->name = "TransitionMoveInB"; jsb_cocos2d_TransitionMoveInB_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionMoveInB_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionMoveInB_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionMoveInB_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionMoveInB_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionMoveInB_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionMoveInB_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionMoveInB_class->finalize = js_cocos2d_TransitionMoveInB_finalize; jsb_cocos2d_TransitionMoveInB_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionMoveInB_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionMoveInB_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionMoveInL_prototype, jsb_cocos2d_TransitionMoveInB_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionMoveInB", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionMoveInB_class; p->proto = jsb_cocos2d_TransitionMoveInB_prototype; p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionSlideInL_class; JSObject *jsb_cocos2d_TransitionSlideInL_prototype; JSBool js_cocos2dx_TransitionSlideInL_action(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionSlideInL* cobj = (cocos2d::TransitionSlideInL *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInL_action : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->action(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInL_action : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TransitionSlideInL_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionSlideInL* cobj = (cocos2d::TransitionSlideInL *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInL_easeActionWithAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInL_easeActionWithAction : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInL_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TransitionSlideInL_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInL_create : Error processing arguments"); cocos2d::TransitionSlideInL* ret = cocos2d::TransitionSlideInL::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSlideInL*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInL_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionSlideInL_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInL)", obj); } void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionSlideInL_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSlideInL_class->name = "TransitionSlideInL"; jsb_cocos2d_TransitionSlideInL_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionSlideInL_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionSlideInL_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionSlideInL_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionSlideInL_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionSlideInL_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionSlideInL_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionSlideInL_class->finalize = js_cocos2d_TransitionSlideInL_finalize; jsb_cocos2d_TransitionSlideInL_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionSlideInL_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("easeActionWithAction", js_cocos2dx_TransitionSlideInL_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionSlideInL_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionSlideInL_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionSlideInL_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionSlideInL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionSlideInL_class; p->proto = jsb_cocos2d_TransitionSlideInL_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionSlideInR_class; JSObject *jsb_cocos2d_TransitionSlideInR_prototype; JSBool js_cocos2dx_TransitionSlideInR_action(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionSlideInR* cobj = (cocos2d::TransitionSlideInR *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInR_action : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->action(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInR_action : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TransitionSlideInR_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInR_create : Error processing arguments"); cocos2d::TransitionSlideInR* ret = cocos2d::TransitionSlideInR::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSlideInR*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInR_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; void js_cocos2d_TransitionSlideInR_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInR)", obj); } void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionSlideInR_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSlideInR_class->name = "TransitionSlideInR"; jsb_cocos2d_TransitionSlideInR_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionSlideInR_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionSlideInR_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionSlideInR_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionSlideInR_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionSlideInR_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionSlideInR_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionSlideInR_class->finalize = js_cocos2d_TransitionSlideInR_finalize; jsb_cocos2d_TransitionSlideInR_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionSlideInR_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionSlideInR_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionSlideInR_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSlideInL_prototype, jsb_cocos2d_TransitionSlideInR_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionSlideInR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionSlideInR_class; p->proto = jsb_cocos2d_TransitionSlideInR_prototype; p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionSlideInB_class; JSObject *jsb_cocos2d_TransitionSlideInB_prototype; JSBool js_cocos2dx_TransitionSlideInB_action(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionSlideInB* cobj = (cocos2d::TransitionSlideInB *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInB_action : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->action(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInB_action : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TransitionSlideInB_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInB_create : Error processing arguments"); cocos2d::TransitionSlideInB* ret = cocos2d::TransitionSlideInB::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSlideInB*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInB_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; void js_cocos2d_TransitionSlideInB_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInB)", obj); } void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionSlideInB_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSlideInB_class->name = "TransitionSlideInB"; jsb_cocos2d_TransitionSlideInB_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionSlideInB_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionSlideInB_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionSlideInB_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionSlideInB_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionSlideInB_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionSlideInB_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionSlideInB_class->finalize = js_cocos2d_TransitionSlideInB_finalize; jsb_cocos2d_TransitionSlideInB_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionSlideInB_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionSlideInB_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionSlideInB_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSlideInL_prototype, jsb_cocos2d_TransitionSlideInB_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionSlideInB", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionSlideInB_class; p->proto = jsb_cocos2d_TransitionSlideInB_prototype; p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionSlideInT_class; JSObject *jsb_cocos2d_TransitionSlideInT_prototype; JSBool js_cocos2dx_TransitionSlideInT_action(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionSlideInT* cobj = (cocos2d::TransitionSlideInT *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInT_action : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->action(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInT_action : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TransitionSlideInT_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSlideInT_create : Error processing arguments"); cocos2d::TransitionSlideInT* ret = cocos2d::TransitionSlideInT::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSlideInT*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSlideInT_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; void js_cocos2d_TransitionSlideInT_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInT)", obj); } void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionSlideInT_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSlideInT_class->name = "TransitionSlideInT"; jsb_cocos2d_TransitionSlideInT_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionSlideInT_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionSlideInT_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionSlideInT_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionSlideInT_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionSlideInT_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionSlideInT_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionSlideInT_class->finalize = js_cocos2d_TransitionSlideInT_finalize; jsb_cocos2d_TransitionSlideInT_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionSlideInT_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionSlideInT_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionSlideInT_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSlideInL_prototype, jsb_cocos2d_TransitionSlideInT_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionSlideInT", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionSlideInT_class; p->proto = jsb_cocos2d_TransitionSlideInT_prototype; p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionShrinkGrow_class; JSObject *jsb_cocos2d_TransitionShrinkGrow_prototype; JSBool js_cocos2dx_TransitionShrinkGrow_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionShrinkGrow* cobj = (cocos2d::TransitionShrinkGrow *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionShrinkGrow_easeActionWithAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionShrinkGrow_easeActionWithAction : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionShrinkGrow_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TransitionShrinkGrow_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionShrinkGrow_create : Error processing arguments"); cocos2d::TransitionShrinkGrow* ret = cocos2d::TransitionShrinkGrow::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionShrinkGrow*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionShrinkGrow_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionShrinkGrow_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionShrinkGrow)", obj); } void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionShrinkGrow_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionShrinkGrow_class->name = "TransitionShrinkGrow"; jsb_cocos2d_TransitionShrinkGrow_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionShrinkGrow_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionShrinkGrow_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionShrinkGrow_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionShrinkGrow_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionShrinkGrow_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionShrinkGrow_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionShrinkGrow_class->finalize = js_cocos2d_TransitionShrinkGrow_finalize; jsb_cocos2d_TransitionShrinkGrow_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("easeActionWithAction", js_cocos2dx_TransitionShrinkGrow_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionShrinkGrow_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionShrinkGrow_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionShrinkGrow_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionShrinkGrow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionShrinkGrow_class; p->proto = jsb_cocos2d_TransitionShrinkGrow_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionFlipX_class; JSObject *jsb_cocos2d_TransitionFlipX_prototype; JSBool js_cocos2dx_TransitionFlipX_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionFlipX* ret = cocos2d::TransitionFlipX::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipX*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionScene::Orientation arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionFlipX* ret = cocos2d::TransitionFlipX::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipX*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TransitionFlipX_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionFlipX_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipX)", obj); } void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionFlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFlipX_class->name = "TransitionFlipX"; jsb_cocos2d_TransitionFlipX_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionFlipX_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionFlipX_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionFlipX_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionFlipX_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionFlipX_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionFlipX_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionFlipX_class->finalize = js_cocos2d_TransitionFlipX_finalize; jsb_cocos2d_TransitionFlipX_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionFlipX_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionFlipX_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSceneOriented_prototype, jsb_cocos2d_TransitionFlipX_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionFlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionFlipX_class; p->proto = jsb_cocos2d_TransitionFlipX_prototype; p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionFlipY_class; JSObject *jsb_cocos2d_TransitionFlipY_prototype; JSBool js_cocos2dx_TransitionFlipY_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionFlipY* ret = cocos2d::TransitionFlipY::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipY*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionScene::Orientation arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionFlipY* ret = cocos2d::TransitionFlipY::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipY*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TransitionFlipY_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionFlipY_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipY)", obj); } void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionFlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFlipY_class->name = "TransitionFlipY"; jsb_cocos2d_TransitionFlipY_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionFlipY_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionFlipY_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionFlipY_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionFlipY_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionFlipY_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionFlipY_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionFlipY_class->finalize = js_cocos2d_TransitionFlipY_finalize; jsb_cocos2d_TransitionFlipY_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionFlipY_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionFlipY_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSceneOriented_prototype, jsb_cocos2d_TransitionFlipY_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionFlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionFlipY_class; p->proto = jsb_cocos2d_TransitionFlipY_prototype; p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionFlipAngular_class; JSObject *jsb_cocos2d_TransitionFlipAngular_prototype; JSBool js_cocos2dx_TransitionFlipAngular_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionFlipAngular* ret = cocos2d::TransitionFlipAngular::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipAngular*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionScene::Orientation arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionFlipAngular* ret = cocos2d::TransitionFlipAngular::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipAngular*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TransitionFlipAngular_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionFlipAngular_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipAngular)", obj); } void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionFlipAngular_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFlipAngular_class->name = "TransitionFlipAngular"; jsb_cocos2d_TransitionFlipAngular_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionFlipAngular_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionFlipAngular_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionFlipAngular_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionFlipAngular_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionFlipAngular_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionFlipAngular_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionFlipAngular_class->finalize = js_cocos2d_TransitionFlipAngular_finalize; jsb_cocos2d_TransitionFlipAngular_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionFlipAngular_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionFlipAngular_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSceneOriented_prototype, jsb_cocos2d_TransitionFlipAngular_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionFlipAngular", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionFlipAngular_class; p->proto = jsb_cocos2d_TransitionFlipAngular_prototype; p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionZoomFlipX_class; JSObject *jsb_cocos2d_TransitionZoomFlipX_prototype; JSBool js_cocos2dx_TransitionZoomFlipX_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionZoomFlipX* ret = cocos2d::TransitionZoomFlipX::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipX*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionScene::Orientation arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionZoomFlipX* ret = cocos2d::TransitionZoomFlipX::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipX*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TransitionZoomFlipX_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionZoomFlipX_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipX)", obj); } void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionZoomFlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionZoomFlipX_class->name = "TransitionZoomFlipX"; jsb_cocos2d_TransitionZoomFlipX_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionZoomFlipX_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionZoomFlipX_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionZoomFlipX_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionZoomFlipX_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionZoomFlipX_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionZoomFlipX_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionZoomFlipX_class->finalize = js_cocos2d_TransitionZoomFlipX_finalize; jsb_cocos2d_TransitionZoomFlipX_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionZoomFlipX_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionZoomFlipX_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSceneOriented_prototype, jsb_cocos2d_TransitionZoomFlipX_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionZoomFlipX", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionZoomFlipX_class; p->proto = jsb_cocos2d_TransitionZoomFlipX_prototype; p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionZoomFlipY_class; JSObject *jsb_cocos2d_TransitionZoomFlipY_prototype; JSBool js_cocos2dx_TransitionZoomFlipY_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionZoomFlipY* ret = cocos2d::TransitionZoomFlipY::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipY*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionScene::Orientation arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionZoomFlipY* ret = cocos2d::TransitionZoomFlipY::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipY*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TransitionZoomFlipY_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionZoomFlipY_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipY)", obj); } void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionZoomFlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionZoomFlipY_class->name = "TransitionZoomFlipY"; jsb_cocos2d_TransitionZoomFlipY_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionZoomFlipY_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionZoomFlipY_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionZoomFlipY_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionZoomFlipY_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionZoomFlipY_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionZoomFlipY_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionZoomFlipY_class->finalize = js_cocos2d_TransitionZoomFlipY_finalize; jsb_cocos2d_TransitionZoomFlipY_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionZoomFlipY_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionZoomFlipY_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSceneOriented_prototype, jsb_cocos2d_TransitionZoomFlipY_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionZoomFlipY", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionZoomFlipY_class; p->proto = jsb_cocos2d_TransitionZoomFlipY_prototype; p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionZoomFlipAngular_class; JSObject *jsb_cocos2d_TransitionZoomFlipAngular_prototype; JSBool js_cocos2dx_TransitionZoomFlipAngular_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionZoomFlipAngular* ret = cocos2d::TransitionZoomFlipAngular::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipAngular*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionScene::Orientation arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionZoomFlipAngular* ret = cocos2d::TransitionZoomFlipAngular::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipAngular*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TransitionZoomFlipAngular_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; void js_cocos2d_TransitionZoomFlipAngular_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipAngular)", obj); } void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionZoomFlipAngular_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionZoomFlipAngular_class->name = "TransitionZoomFlipAngular"; jsb_cocos2d_TransitionZoomFlipAngular_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionZoomFlipAngular_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionZoomFlipAngular_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionZoomFlipAngular_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionZoomFlipAngular_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionZoomFlipAngular_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionZoomFlipAngular_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionZoomFlipAngular_class->finalize = js_cocos2d_TransitionZoomFlipAngular_finalize; jsb_cocos2d_TransitionZoomFlipAngular_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionZoomFlipAngular_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionZoomFlipAngular_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSceneOriented_prototype, jsb_cocos2d_TransitionZoomFlipAngular_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionZoomFlipAngular", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionZoomFlipAngular_class; p->proto = jsb_cocos2d_TransitionZoomFlipAngular_prototype; p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionFade_class; JSObject *jsb_cocos2d_TransitionFade_prototype; JSBool js_cocos2dx_TransitionFade_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionFade* ret = cocos2d::TransitionFade::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFade*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Scene* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Color3B arg2; ok &= jsval_to_cccolor3b(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TransitionFade* ret = cocos2d::TransitionFade::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFade*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TransitionFade_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionFade_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFade)", obj); } void js_register_cocos2dx_TransitionFade(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionFade_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFade_class->name = "TransitionFade"; jsb_cocos2d_TransitionFade_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionFade_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionFade_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionFade_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionFade_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionFade_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionFade_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionFade_class->finalize = js_cocos2d_TransitionFade_finalize; jsb_cocos2d_TransitionFade_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionFade_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionFade_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionFade_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionFade", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionFade_class; p->proto = jsb_cocos2d_TransitionFade_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionCrossFade_class; JSObject *jsb_cocos2d_TransitionCrossFade_prototype; JSBool js_cocos2dx_TransitionCrossFade_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionCrossFade_create : Error processing arguments"); cocos2d::TransitionCrossFade* ret = cocos2d::TransitionCrossFade::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionCrossFade*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionCrossFade_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionCrossFade_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionCrossFade)", obj); } void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionCrossFade_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionCrossFade_class->name = "TransitionCrossFade"; jsb_cocos2d_TransitionCrossFade_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionCrossFade_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionCrossFade_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionCrossFade_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionCrossFade_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionCrossFade_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionCrossFade_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionCrossFade_class->finalize = js_cocos2d_TransitionCrossFade_finalize; jsb_cocos2d_TransitionCrossFade_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionCrossFade_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionCrossFade_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionCrossFade_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionCrossFade", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionCrossFade_class; p->proto = jsb_cocos2d_TransitionCrossFade_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionTurnOffTiles_class; JSObject *jsb_cocos2d_TransitionTurnOffTiles_prototype; JSBool js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionTurnOffTiles* cobj = (cocos2d::TransitionTurnOffTiles *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TransitionTurnOffTiles_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionTurnOffTiles_create : Error processing arguments"); cocos2d::TransitionTurnOffTiles* ret = cocos2d::TransitionTurnOffTiles::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionTurnOffTiles*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionTurnOffTiles_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionTurnOffTiles_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionTurnOffTiles)", obj); } void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionTurnOffTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionTurnOffTiles_class->name = "TransitionTurnOffTiles"; jsb_cocos2d_TransitionTurnOffTiles_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionTurnOffTiles_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionTurnOffTiles_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionTurnOffTiles_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionTurnOffTiles_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionTurnOffTiles_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionTurnOffTiles_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionTurnOffTiles_class->finalize = js_cocos2d_TransitionTurnOffTiles_finalize; jsb_cocos2d_TransitionTurnOffTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("easeActionWithAction", js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionTurnOffTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionTurnOffTiles_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionTurnOffTiles_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionTurnOffTiles", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionTurnOffTiles_class; p->proto = jsb_cocos2d_TransitionTurnOffTiles_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionSplitCols_class; JSObject *jsb_cocos2d_TransitionSplitCols_prototype; JSBool js_cocos2dx_TransitionSplitCols_action(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionSplitCols* cobj = (cocos2d::TransitionSplitCols *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionSplitCols_action : Invalid Native Object"); if (argc == 0) { cocos2d::ActionInterval* ret = cobj->action(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSplitCols_action : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TransitionSplitCols_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionSplitCols* cobj = (cocos2d::TransitionSplitCols *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionSplitCols_easeActionWithAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSplitCols_easeActionWithAction : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSplitCols_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TransitionSplitCols_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSplitCols_create : Error processing arguments"); cocos2d::TransitionSplitCols* ret = cocos2d::TransitionSplitCols::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSplitCols*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSplitCols_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionSplitCols_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSplitCols)", obj); } void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionSplitCols_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSplitCols_class->name = "TransitionSplitCols"; jsb_cocos2d_TransitionSplitCols_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionSplitCols_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionSplitCols_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionSplitCols_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionSplitCols_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionSplitCols_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionSplitCols_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionSplitCols_class->finalize = js_cocos2d_TransitionSplitCols_finalize; jsb_cocos2d_TransitionSplitCols_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("action", js_cocos2dx_TransitionSplitCols_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("easeActionWithAction", js_cocos2dx_TransitionSplitCols_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionSplitCols_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionSplitCols_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionSplitCols_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionSplitCols", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionSplitCols_class; p->proto = jsb_cocos2d_TransitionSplitCols_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionSplitRows_class; JSObject *jsb_cocos2d_TransitionSplitRows_prototype; JSBool js_cocos2dx_TransitionSplitRows_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionSplitRows_create : Error processing arguments"); cocos2d::TransitionSplitRows* ret = cocos2d::TransitionSplitRows::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSplitRows*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionSplitRows_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionSplitCols_prototype; void js_cocos2d_TransitionSplitRows_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSplitRows)", obj); } void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionSplitRows_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionSplitRows_class->name = "TransitionSplitRows"; jsb_cocos2d_TransitionSplitRows_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionSplitRows_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionSplitRows_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionSplitRows_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionSplitRows_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionSplitRows_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionSplitRows_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionSplitRows_class->finalize = js_cocos2d_TransitionSplitRows_finalize; jsb_cocos2d_TransitionSplitRows_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionSplitRows_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionSplitRows_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionSplitCols_prototype, jsb_cocos2d_TransitionSplitRows_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionSplitRows", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionSplitRows_class; p->proto = jsb_cocos2d_TransitionSplitRows_prototype; p->parentProto = jsb_cocos2d_TransitionSplitCols_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionFadeTR_class; JSObject *jsb_cocos2d_TransitionFadeTR_prototype; JSBool js_cocos2dx_TransitionFadeTR_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionFadeTR* cobj = (cocos2d::TransitionFadeTR *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionFadeTR_easeActionWithAction : Invalid Native Object"); if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ActionInterval*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionFadeTR_easeActionWithAction : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionFadeTR_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TransitionFadeTR_actionWithSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionFadeTR* cobj = (cocos2d::TransitionFadeTR *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionFadeTR_actionWithSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionFadeTR_actionWithSize : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->actionWithSize(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionFadeTR_actionWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TransitionFadeTR_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionFadeTR_create : Error processing arguments"); cocos2d::TransitionFadeTR* ret = cocos2d::TransitionFadeTR::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFadeTR*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionFadeTR_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionFadeTR_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeTR)", obj); } void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionFadeTR_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFadeTR_class->name = "TransitionFadeTR"; jsb_cocos2d_TransitionFadeTR_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionFadeTR_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionFadeTR_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionFadeTR_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionFadeTR_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionFadeTR_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionFadeTR_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionFadeTR_class->finalize = js_cocos2d_TransitionFadeTR_finalize; jsb_cocos2d_TransitionFadeTR_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("easeActionWithAction", js_cocos2dx_TransitionFadeTR_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("actionWithSize", js_cocos2dx_TransitionFadeTR_actionWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionFadeTR_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionFadeTR_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionFadeTR_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionFadeTR", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionFadeTR_class; p->proto = jsb_cocos2d_TransitionFadeTR_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionFadeBL_class; JSObject *jsb_cocos2d_TransitionFadeBL_prototype; JSBool js_cocos2dx_TransitionFadeBL_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionFadeBL_create : Error processing arguments"); cocos2d::TransitionFadeBL* ret = cocos2d::TransitionFadeBL::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFadeBL*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionFadeBL_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; void js_cocos2d_TransitionFadeBL_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeBL)", obj); } void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionFadeBL_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFadeBL_class->name = "TransitionFadeBL"; jsb_cocos2d_TransitionFadeBL_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionFadeBL_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionFadeBL_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionFadeBL_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionFadeBL_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionFadeBL_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionFadeBL_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionFadeBL_class->finalize = js_cocos2d_TransitionFadeBL_finalize; jsb_cocos2d_TransitionFadeBL_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionFadeBL_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionFadeBL_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionFadeTR_prototype, jsb_cocos2d_TransitionFadeBL_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionFadeBL", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionFadeBL_class; p->proto = jsb_cocos2d_TransitionFadeBL_prototype; p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionFadeUp_class; JSObject *jsb_cocos2d_TransitionFadeUp_prototype; JSBool js_cocos2dx_TransitionFadeUp_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionFadeUp_create : Error processing arguments"); cocos2d::TransitionFadeUp* ret = cocos2d::TransitionFadeUp::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFadeUp*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionFadeUp_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; void js_cocos2d_TransitionFadeUp_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeUp)", obj); } void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionFadeUp_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFadeUp_class->name = "TransitionFadeUp"; jsb_cocos2d_TransitionFadeUp_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionFadeUp_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionFadeUp_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionFadeUp_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionFadeUp_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionFadeUp_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionFadeUp_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionFadeUp_class->finalize = js_cocos2d_TransitionFadeUp_finalize; jsb_cocos2d_TransitionFadeUp_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionFadeUp_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionFadeUp_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionFadeTR_prototype, jsb_cocos2d_TransitionFadeUp_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionFadeUp", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionFadeUp_class; p->proto = jsb_cocos2d_TransitionFadeUp_prototype; p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionFadeDown_class; JSObject *jsb_cocos2d_TransitionFadeDown_prototype; JSBool js_cocos2dx_TransitionFadeDown_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionFadeDown_create : Error processing arguments"); cocos2d::TransitionFadeDown* ret = cocos2d::TransitionFadeDown::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFadeDown*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionFadeDown_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; void js_cocos2d_TransitionFadeDown_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeDown)", obj); } void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionFadeDown_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionFadeDown_class->name = "TransitionFadeDown"; jsb_cocos2d_TransitionFadeDown_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionFadeDown_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionFadeDown_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionFadeDown_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionFadeDown_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionFadeDown_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionFadeDown_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionFadeDown_class->finalize = js_cocos2d_TransitionFadeDown_finalize; jsb_cocos2d_TransitionFadeDown_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionFadeDown_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionFadeDown_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionFadeTR_prototype, jsb_cocos2d_TransitionFadeDown_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionFadeDown", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionFadeDown_class; p->proto = jsb_cocos2d_TransitionFadeDown_prototype; p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionPageTurn_class; JSObject *jsb_cocos2d_TransitionPageTurn_prototype; JSBool js_cocos2dx_TransitionPageTurn_actionWithSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionPageTurn* cobj = (cocos2d::TransitionPageTurn *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionPageTurn_actionWithSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionPageTurn_actionWithSize : Error processing arguments"); cocos2d::ActionInterval* ret = cobj->actionWithSize(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionPageTurn_actionWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TransitionPageTurn_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TransitionPageTurn* cobj = (cocos2d::TransitionPageTurn *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TransitionPageTurn_initWithDuration : Invalid Native Object"); if (argc == 3) { double arg0; cocos2d::Scene* arg1; JSBool arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionPageTurn_initWithDuration : Error processing arguments"); JSBool ret = cobj->initWithDuration(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionPageTurn_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_TransitionPageTurn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { double arg0; cocos2d::Scene* arg1; JSBool arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionPageTurn_create : Error processing arguments"); cocos2d::TransitionPageTurn* ret = cocos2d::TransitionPageTurn::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionPageTurn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionPageTurn_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TransitionPageTurn_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TransitionPageTurn* cobj = new cocos2d::TransitionPageTurn(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionPageTurn"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionPageTurn_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionPageTurn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionPageTurn)", obj); } void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionPageTurn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionPageTurn_class->name = "TransitionPageTurn"; jsb_cocos2d_TransitionPageTurn_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionPageTurn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionPageTurn_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionPageTurn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionPageTurn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionPageTurn_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionPageTurn_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionPageTurn_class->finalize = js_cocos2d_TransitionPageTurn_finalize; jsb_cocos2d_TransitionPageTurn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("actionWithSize", js_cocos2dx_TransitionPageTurn_actionWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithDuration", js_cocos2dx_TransitionPageTurn_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionPageTurn_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionPageTurn_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionPageTurn_class, js_cocos2dx_TransitionPageTurn_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionPageTurn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionPageTurn_class; p->proto = jsb_cocos2d_TransitionPageTurn_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionProgress_class; JSObject *jsb_cocos2d_TransitionProgress_prototype; JSBool js_cocos2dx_TransitionProgress_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionProgress_create : Error processing arguments"); cocos2d::TransitionProgress* ret = cocos2d::TransitionProgress::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgress*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionProgress_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TransitionProgress_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TransitionProgress* cobj = new cocos2d::TransitionProgress(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgress"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionProgress_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionScene_prototype; void js_cocos2d_TransitionProgress_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgress)", obj); } void js_register_cocos2dx_TransitionProgress(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionProgress_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgress_class->name = "TransitionProgress"; jsb_cocos2d_TransitionProgress_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgress_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionProgress_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgress_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionProgress_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionProgress_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionProgress_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionProgress_class->finalize = js_cocos2d_TransitionProgress_finalize; jsb_cocos2d_TransitionProgress_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionProgress_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionProgress_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionScene_prototype, jsb_cocos2d_TransitionProgress_class, js_cocos2dx_TransitionProgress_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionProgress", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionProgress_class; p->proto = jsb_cocos2d_TransitionProgress_prototype; p->parentProto = jsb_cocos2d_TransitionScene_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionProgressRadialCCW_class; JSObject *jsb_cocos2d_TransitionProgressRadialCCW_prototype; JSBool js_cocos2dx_TransitionProgressRadialCCW_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionProgressRadialCCW_create : Error processing arguments"); cocos2d::TransitionProgressRadialCCW* ret = cocos2d::TransitionProgressRadialCCW::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressRadialCCW*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionProgressRadialCCW_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressRadialCCW_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressRadialCCW)", obj); } void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionProgressRadialCCW_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressRadialCCW_class->name = "TransitionProgressRadialCCW"; jsb_cocos2d_TransitionProgressRadialCCW_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressRadialCCW_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionProgressRadialCCW_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressRadialCCW_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionProgressRadialCCW_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionProgressRadialCCW_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionProgressRadialCCW_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionProgressRadialCCW_class->finalize = js_cocos2d_TransitionProgressRadialCCW_finalize; jsb_cocos2d_TransitionProgressRadialCCW_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionProgressRadialCCW_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionProgressRadialCCW_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionProgress_prototype, jsb_cocos2d_TransitionProgressRadialCCW_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionProgressRadialCCW", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionProgressRadialCCW_class; p->proto = jsb_cocos2d_TransitionProgressRadialCCW_prototype; p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionProgressRadialCW_class; JSObject *jsb_cocos2d_TransitionProgressRadialCW_prototype; JSBool js_cocos2dx_TransitionProgressRadialCW_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionProgressRadialCW_create : Error processing arguments"); cocos2d::TransitionProgressRadialCW* ret = cocos2d::TransitionProgressRadialCW::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressRadialCW*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionProgressRadialCW_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressRadialCW_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressRadialCW)", obj); } void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionProgressRadialCW_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressRadialCW_class->name = "TransitionProgressRadialCW"; jsb_cocos2d_TransitionProgressRadialCW_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressRadialCW_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionProgressRadialCW_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressRadialCW_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionProgressRadialCW_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionProgressRadialCW_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionProgressRadialCW_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionProgressRadialCW_class->finalize = js_cocos2d_TransitionProgressRadialCW_finalize; jsb_cocos2d_TransitionProgressRadialCW_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionProgressRadialCW_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionProgressRadialCW_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionProgress_prototype, jsb_cocos2d_TransitionProgressRadialCW_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionProgressRadialCW", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionProgressRadialCW_class; p->proto = jsb_cocos2d_TransitionProgressRadialCW_prototype; p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionProgressHorizontal_class; JSObject *jsb_cocos2d_TransitionProgressHorizontal_prototype; JSBool js_cocos2dx_TransitionProgressHorizontal_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionProgressHorizontal_create : Error processing arguments"); cocos2d::TransitionProgressHorizontal* ret = cocos2d::TransitionProgressHorizontal::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressHorizontal*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionProgressHorizontal_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressHorizontal_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressHorizontal)", obj); } void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionProgressHorizontal_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressHorizontal_class->name = "TransitionProgressHorizontal"; jsb_cocos2d_TransitionProgressHorizontal_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressHorizontal_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionProgressHorizontal_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressHorizontal_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionProgressHorizontal_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionProgressHorizontal_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionProgressHorizontal_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionProgressHorizontal_class->finalize = js_cocos2d_TransitionProgressHorizontal_finalize; jsb_cocos2d_TransitionProgressHorizontal_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionProgressHorizontal_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionProgressHorizontal_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionProgress_prototype, jsb_cocos2d_TransitionProgressHorizontal_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionProgressHorizontal", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionProgressHorizontal_class; p->proto = jsb_cocos2d_TransitionProgressHorizontal_prototype; p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionProgressVertical_class; JSObject *jsb_cocos2d_TransitionProgressVertical_prototype; JSBool js_cocos2dx_TransitionProgressVertical_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionProgressVertical_create : Error processing arguments"); cocos2d::TransitionProgressVertical* ret = cocos2d::TransitionProgressVertical::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressVertical*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionProgressVertical_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressVertical_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressVertical)", obj); } void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionProgressVertical_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressVertical_class->name = "TransitionProgressVertical"; jsb_cocos2d_TransitionProgressVertical_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressVertical_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionProgressVertical_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressVertical_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionProgressVertical_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionProgressVertical_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionProgressVertical_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionProgressVertical_class->finalize = js_cocos2d_TransitionProgressVertical_finalize; jsb_cocos2d_TransitionProgressVertical_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionProgressVertical_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionProgressVertical_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionProgress_prototype, jsb_cocos2d_TransitionProgressVertical_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionProgressVertical", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionProgressVertical_class; p->proto = jsb_cocos2d_TransitionProgressVertical_prototype; p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionProgressInOut_class; JSObject *jsb_cocos2d_TransitionProgressInOut_prototype; JSBool js_cocos2dx_TransitionProgressInOut_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionProgressInOut_create : Error processing arguments"); cocos2d::TransitionProgressInOut* ret = cocos2d::TransitionProgressInOut::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressInOut*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionProgressInOut_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressInOut_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressInOut)", obj); } void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionProgressInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressInOut_class->name = "TransitionProgressInOut"; jsb_cocos2d_TransitionProgressInOut_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressInOut_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionProgressInOut_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressInOut_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionProgressInOut_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionProgressInOut_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionProgressInOut_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionProgressInOut_class->finalize = js_cocos2d_TransitionProgressInOut_finalize; jsb_cocos2d_TransitionProgressInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionProgressInOut_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionProgressInOut_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionProgress_prototype, jsb_cocos2d_TransitionProgressInOut_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionProgressInOut", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionProgressInOut_class; p->proto = jsb_cocos2d_TransitionProgressInOut_prototype; p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TransitionProgressOutIn_class; JSObject *jsb_cocos2d_TransitionProgressOutIn_prototype; JSBool js_cocos2dx_TransitionProgressOutIn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Scene*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TransitionProgressOutIn_create : Error processing arguments"); cocos2d::TransitionProgressOutIn* ret = cocos2d::TransitionProgressOutIn::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressOutIn*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TransitionProgressOutIn_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_TransitionProgress_prototype; void js_cocos2d_TransitionProgressOutIn_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressOutIn)", obj); } void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JSObject *global) { jsb_cocos2d_TransitionProgressOutIn_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TransitionProgressOutIn_class->name = "TransitionProgressOutIn"; jsb_cocos2d_TransitionProgressOutIn_class->addProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressOutIn_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TransitionProgressOutIn_class->getProperty = JS_PropertyStub; jsb_cocos2d_TransitionProgressOutIn_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TransitionProgressOutIn_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TransitionProgressOutIn_class->resolve = JS_ResolveStub; jsb_cocos2d_TransitionProgressOutIn_class->convert = JS_ConvertStub; jsb_cocos2d_TransitionProgressOutIn_class->finalize = js_cocos2d_TransitionProgressOutIn_finalize; jsb_cocos2d_TransitionProgressOutIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TransitionProgressOutIn_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TransitionProgressOutIn_prototype = JS_InitClass( cx, global, jsb_cocos2d_TransitionProgress_prototype, jsb_cocos2d_TransitionProgressOutIn_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TransitionProgressOutIn", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TransitionProgressOutIn_class; p->proto = jsb_cocos2d_TransitionProgressOutIn_prototype; p->parentProto = jsb_cocos2d_TransitionProgress_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MenuItem_class; JSObject *jsb_cocos2d_MenuItem_prototype; JSBool js_cocos2dx_MenuItem_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItem_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItem_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItem_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItem_activate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItem_activate : Invalid Native Object"); if (argc == 0) { cobj->activate(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItem_activate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItem_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItem_isEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItem_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItem_selected(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItem_selected : Invalid Native Object"); if (argc == 0) { cobj->selected(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItem_selected : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItem_isSelected(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItem_isSelected : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isSelected(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItem_isSelected : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItem_unselected(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItem_unselected : Invalid Native Object"); if (argc == 0) { cobj->unselected(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItem_unselected : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItem_rect(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItem_rect : Invalid Native Object"); if (argc == 0) { cocos2d::Rect ret = cobj->rect(); jsval jsret = JSVAL_NULL; jsret = ccrect_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItem_rect : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_MenuItem_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MenuItem)", obj); } void js_register_cocos2dx_MenuItem(JSContext *cx, JSObject *global) { jsb_cocos2d_MenuItem_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MenuItem_class->name = "MenuItem"; jsb_cocos2d_MenuItem_class->addProperty = JS_PropertyStub; jsb_cocos2d_MenuItem_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MenuItem_class->getProperty = JS_PropertyStub; jsb_cocos2d_MenuItem_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MenuItem_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MenuItem_class->resolve = JS_ResolveStub; jsb_cocos2d_MenuItem_class->convert = JS_ConvertStub; jsb_cocos2d_MenuItem_class->finalize = js_cocos2d_MenuItem_finalize; jsb_cocos2d_MenuItem_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEnabled", js_cocos2dx_MenuItem_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("activate", js_cocos2dx_MenuItem_activate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isEnabled", js_cocos2dx_MenuItem_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("selected", js_cocos2dx_MenuItem_selected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSelected", js_cocos2dx_MenuItem_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("unselected", js_cocos2dx_MenuItem_unselected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("rect", js_cocos2dx_MenuItem_rect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_MenuItem_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_MenuItem_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MenuItem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MenuItem_class; p->proto = jsb_cocos2d_MenuItem_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MenuItemLabel_class; JSObject *jsb_cocos2d_MenuItemLabel_prototype; JSBool js_cocos2dx_MenuItemLabel_getDisabledColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemLabel_getDisabledColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color3B& ret = cobj->getDisabledColor(); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_getDisabledColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemLabel_setString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemLabel_setString : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemLabel_setString : Error processing arguments"); cobj->setString(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_setString : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemLabel_setLabel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemLabel_setLabel : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemLabel_setLabel : Error processing arguments"); cobj->setLabel(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_setLabel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemLabel_setDisabledColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemLabel_setDisabledColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemLabel_setDisabledColor : Error processing arguments"); cobj->setDisabledColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_setDisabledColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemLabel_getLabel(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemLabel_getLabel : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getLabel(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_getLabel : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_MenuItem_prototype; void js_cocos2d_MenuItemLabel_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemLabel)", obj); } void js_register_cocos2dx_MenuItemLabel(JSContext *cx, JSObject *global) { jsb_cocos2d_MenuItemLabel_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MenuItemLabel_class->name = "MenuItemLabel"; jsb_cocos2d_MenuItemLabel_class->addProperty = JS_PropertyStub; jsb_cocos2d_MenuItemLabel_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MenuItemLabel_class->getProperty = JS_PropertyStub; jsb_cocos2d_MenuItemLabel_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MenuItemLabel_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MenuItemLabel_class->resolve = JS_ResolveStub; jsb_cocos2d_MenuItemLabel_class->convert = JS_ConvertStub; jsb_cocos2d_MenuItemLabel_class->finalize = js_cocos2d_MenuItemLabel_finalize; jsb_cocos2d_MenuItemLabel_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getDisabledColor", js_cocos2dx_MenuItemLabel_getDisabledColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setString", js_cocos2dx_MenuItemLabel_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLabel", js_cocos2dx_MenuItemLabel_setLabel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDisabledColor", js_cocos2dx_MenuItemLabel_setDisabledColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLabel", js_cocos2dx_MenuItemLabel_getLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_MenuItemLabel_prototype = JS_InitClass( cx, global, jsb_cocos2d_MenuItem_prototype, jsb_cocos2d_MenuItemLabel_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MenuItemLabel", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MenuItemLabel_class; p->proto = jsb_cocos2d_MenuItemLabel_prototype; p->parentProto = jsb_cocos2d_MenuItem_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MenuItemAtlasFont_class; JSObject *jsb_cocos2d_MenuItemAtlasFont_prototype; extern JSObject *jsb_cocos2d_MenuItemLabel_prototype; void js_cocos2d_MenuItemAtlasFont_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemAtlasFont)", obj); } void js_register_cocos2dx_MenuItemAtlasFont(JSContext *cx, JSObject *global) { jsb_cocos2d_MenuItemAtlasFont_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MenuItemAtlasFont_class->name = "MenuItemAtlasFont"; jsb_cocos2d_MenuItemAtlasFont_class->addProperty = JS_PropertyStub; jsb_cocos2d_MenuItemAtlasFont_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MenuItemAtlasFont_class->getProperty = JS_PropertyStub; jsb_cocos2d_MenuItemAtlasFont_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MenuItemAtlasFont_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MenuItemAtlasFont_class->resolve = JS_ResolveStub; jsb_cocos2d_MenuItemAtlasFont_class->convert = JS_ConvertStub; jsb_cocos2d_MenuItemAtlasFont_class->finalize = js_cocos2d_MenuItemAtlasFont_finalize; jsb_cocos2d_MenuItemAtlasFont_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_MenuItemAtlasFont_prototype = JS_InitClass( cx, global, jsb_cocos2d_MenuItemLabel_prototype, jsb_cocos2d_MenuItemAtlasFont_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MenuItemAtlasFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MenuItemAtlasFont_class; p->proto = jsb_cocos2d_MenuItemAtlasFont_prototype; p->parentProto = jsb_cocos2d_MenuItemLabel_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MenuItemFont_class; JSObject *jsb_cocos2d_MenuItemFont_prototype; JSBool js_cocos2dx_MenuItemFont_setFontNameObj(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemFont_setFontNameObj : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemFont_setFontNameObj : Error processing arguments"); cobj->setFontNameObj(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemFont_setFontNameObj : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemFont_getFontSizeObj(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemFont_getFontSizeObj : Invalid Native Object"); if (argc == 0) { int ret = cobj->getFontSizeObj(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemFont_getFontSizeObj : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemFont_getFontNameObj(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemFont_getFontNameObj : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getFontNameObj(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemFont_getFontNameObj : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemFont_setFontSizeObj(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemFont_setFontSizeObj : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemFont_setFontSizeObj : Error processing arguments"); cobj->setFontSizeObj(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemFont_setFontSizeObj : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemFont_setFontName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemFont_setFontName : Error processing arguments"); cocos2d::MenuItemFont::setFontName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemFont_setFontName : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_MenuItemFont_getFontSize(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { int ret = cocos2d::MenuItemFont::getFontSize(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemFont_getFontSize : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_MenuItemFont_getFontName(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { const std::string& ret = cocos2d::MenuItemFont::getFontName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemFont_getFontName : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_MenuItemFont_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemFont_setFontSize : Error processing arguments"); cocos2d::MenuItemFont::setFontSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemFont_setFontSize : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_MenuItemLabel_prototype; void js_cocos2d_MenuItemFont_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemFont)", obj); } static JSBool js_cocos2d_MenuItemFont_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::MenuItemFont *nobj = cocos2d::MenuItemFont::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemFont"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_MenuItemFont(JSContext *cx, JSObject *global) { jsb_cocos2d_MenuItemFont_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MenuItemFont_class->name = "MenuItemFont"; jsb_cocos2d_MenuItemFont_class->addProperty = JS_PropertyStub; jsb_cocos2d_MenuItemFont_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MenuItemFont_class->getProperty = JS_PropertyStub; jsb_cocos2d_MenuItemFont_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MenuItemFont_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MenuItemFont_class->resolve = JS_ResolveStub; jsb_cocos2d_MenuItemFont_class->convert = JS_ConvertStub; jsb_cocos2d_MenuItemFont_class->finalize = js_cocos2d_MenuItemFont_finalize; jsb_cocos2d_MenuItemFont_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setFontName", js_cocos2dx_MenuItemFont_setFontNameObj, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontSize", js_cocos2dx_MenuItemFont_getFontSizeObj, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontName", js_cocos2dx_MenuItemFont_getFontNameObj, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontSize", js_cocos2dx_MenuItemFont_setFontSizeObj, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_MenuItemFont_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("setFontName", js_cocos2dx_MenuItemFont_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontSize", js_cocos2dx_MenuItemFont_getFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontName", js_cocos2dx_MenuItemFont_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontSize", js_cocos2dx_MenuItemFont_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_MenuItemFont_prototype = JS_InitClass( cx, global, jsb_cocos2d_MenuItemLabel_prototype, jsb_cocos2d_MenuItemFont_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MenuItemFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MenuItemFont_class; p->proto = jsb_cocos2d_MenuItemFont_prototype; p->parentProto = jsb_cocos2d_MenuItemLabel_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MenuItemSprite_class; JSObject *jsb_cocos2d_MenuItemSprite_prototype; JSBool js_cocos2dx_MenuItemSprite_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemSprite_selected(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_selected : Invalid Native Object"); if (argc == 0) { cobj->selected(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_selected : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemSprite_setNormalImage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_setNormalImage : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_setNormalImage : Error processing arguments"); cobj->setNormalImage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_setNormalImage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemSprite_setDisabledImage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_setDisabledImage : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_setDisabledImage : Error processing arguments"); cobj->setDisabledImage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_setDisabledImage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemSprite_setSelectedImage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_setSelectedImage : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_setSelectedImage : Error processing arguments"); cobj->setSelectedImage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_setSelectedImage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemSprite_getDisabledImage(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_getDisabledImage : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getDisabledImage(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_getDisabledImage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemSprite_getSelectedImage(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_getSelectedImage : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getSelectedImage(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_getSelectedImage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemSprite_getNormalImage(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_getNormalImage : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getNormalImage(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_getNormalImage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemSprite_unselected(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemSprite_unselected : Invalid Native Object"); if (argc == 0) { cobj->unselected(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_unselected : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_MenuItem_prototype; void js_cocos2d_MenuItemSprite_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemSprite)", obj); } void js_register_cocos2dx_MenuItemSprite(JSContext *cx, JSObject *global) { jsb_cocos2d_MenuItemSprite_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MenuItemSprite_class->name = "MenuItemSprite"; jsb_cocos2d_MenuItemSprite_class->addProperty = JS_PropertyStub; jsb_cocos2d_MenuItemSprite_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MenuItemSprite_class->getProperty = JS_PropertyStub; jsb_cocos2d_MenuItemSprite_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MenuItemSprite_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MenuItemSprite_class->resolve = JS_ResolveStub; jsb_cocos2d_MenuItemSprite_class->convert = JS_ConvertStub; jsb_cocos2d_MenuItemSprite_class->finalize = js_cocos2d_MenuItemSprite_finalize; jsb_cocos2d_MenuItemSprite_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEnabled", js_cocos2dx_MenuItemSprite_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("selected", js_cocos2dx_MenuItemSprite_selected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setNormalImage", js_cocos2dx_MenuItemSprite_setNormalImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDisabledImage", js_cocos2dx_MenuItemSprite_setDisabledImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelectedImage", js_cocos2dx_MenuItemSprite_setSelectedImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisabledImage", js_cocos2dx_MenuItemSprite_getDisabledImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSelectedImage", js_cocos2dx_MenuItemSprite_getSelectedImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNormalImage", js_cocos2dx_MenuItemSprite_getNormalImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("unselected", js_cocos2dx_MenuItemSprite_unselected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_MenuItemSprite_prototype = JS_InitClass( cx, global, jsb_cocos2d_MenuItem_prototype, jsb_cocos2d_MenuItemSprite_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MenuItemSprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MenuItemSprite_class; p->proto = jsb_cocos2d_MenuItemSprite_prototype; p->parentProto = jsb_cocos2d_MenuItem_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MenuItemImage_class; JSObject *jsb_cocos2d_MenuItemImage_prototype; JSBool js_cocos2dx_MenuItemImage_setDisabledSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemImage* cobj = (cocos2d::MenuItemImage *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemImage_setDisabledSpriteFrame : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemImage_setDisabledSpriteFrame : Error processing arguments"); cobj->setDisabledSpriteFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemImage_setDisabledSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemImage_setSelectedSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemImage* cobj = (cocos2d::MenuItemImage *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemImage_setSelectedSpriteFrame : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemImage_setSelectedSpriteFrame : Error processing arguments"); cobj->setSelectedSpriteFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemImage_setSelectedSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemImage_setNormalSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemImage* cobj = (cocos2d::MenuItemImage *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemImage_setNormalSpriteFrame : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemImage_setNormalSpriteFrame : Error processing arguments"); cobj->setNormalSpriteFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemImage_setNormalSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_MenuItemSprite_prototype; void js_cocos2d_MenuItemImage_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemImage)", obj); } void js_register_cocos2dx_MenuItemImage(JSContext *cx, JSObject *global) { jsb_cocos2d_MenuItemImage_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MenuItemImage_class->name = "MenuItemImage"; jsb_cocos2d_MenuItemImage_class->addProperty = JS_PropertyStub; jsb_cocos2d_MenuItemImage_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MenuItemImage_class->getProperty = JS_PropertyStub; jsb_cocos2d_MenuItemImage_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MenuItemImage_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MenuItemImage_class->resolve = JS_ResolveStub; jsb_cocos2d_MenuItemImage_class->convert = JS_ConvertStub; jsb_cocos2d_MenuItemImage_class->finalize = js_cocos2d_MenuItemImage_finalize; jsb_cocos2d_MenuItemImage_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setDisabledSpriteFrame", js_cocos2dx_MenuItemImage_setDisabledSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelectedSpriteFrame", js_cocos2dx_MenuItemImage_setSelectedSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setNormalSpriteFrame", js_cocos2dx_MenuItemImage_setNormalSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_MenuItemImage_prototype = JS_InitClass( cx, global, jsb_cocos2d_MenuItemSprite_prototype, jsb_cocos2d_MenuItemImage_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MenuItemImage", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MenuItemImage_class; p->proto = jsb_cocos2d_MenuItemImage_prototype; p->parentProto = jsb_cocos2d_MenuItemSprite_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MenuItemToggle_class; JSObject *jsb_cocos2d_MenuItemToggle_prototype; JSBool js_cocos2dx_MenuItemToggle_setSubItems(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemToggle_setSubItems : Invalid Native Object"); if (argc == 1) { cocos2d::Vector arg0; ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemToggle_setSubItems : Error processing arguments"); cobj->setSubItems(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_setSubItems : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemToggle_getSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemToggle_getSelectedIndex : Invalid Native Object"); if (argc == 0) { unsigned int ret = cobj->getSelectedIndex(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_getSelectedIndex : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemToggle_addSubItem(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemToggle_addSubItem : Invalid Native Object"); if (argc == 1) { cocos2d::MenuItem* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::MenuItem*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemToggle_addSubItem : Error processing arguments"); cobj->addSubItem(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_addSubItem : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MenuItemToggle_getSelectedItem(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemToggle_getSelectedItem : Invalid Native Object"); if (argc == 0) { cocos2d::MenuItem* ret = cobj->getSelectedItem(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::MenuItem*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_getSelectedItem : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MenuItemToggle_setSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MenuItemToggle_setSelectedIndex : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MenuItemToggle_setSelectedIndex : Error processing arguments"); cobj->setSelectedIndex(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_setSelectedIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_MenuItem_prototype; void js_cocos2d_MenuItemToggle_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemToggle)", obj); } void js_register_cocos2dx_MenuItemToggle(JSContext *cx, JSObject *global) { jsb_cocos2d_MenuItemToggle_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MenuItemToggle_class->name = "MenuItemToggle"; jsb_cocos2d_MenuItemToggle_class->addProperty = JS_PropertyStub; jsb_cocos2d_MenuItemToggle_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MenuItemToggle_class->getProperty = JS_PropertyStub; jsb_cocos2d_MenuItemToggle_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MenuItemToggle_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MenuItemToggle_class->resolve = JS_ResolveStub; jsb_cocos2d_MenuItemToggle_class->convert = JS_ConvertStub; jsb_cocos2d_MenuItemToggle_class->finalize = js_cocos2d_MenuItemToggle_finalize; jsb_cocos2d_MenuItemToggle_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setSubItems", js_cocos2dx_MenuItemToggle_setSubItems, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSelectedIndex", js_cocos2dx_MenuItemToggle_getSelectedIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSubItem", js_cocos2dx_MenuItemToggle_addSubItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSelectedItem", js_cocos2dx_MenuItemToggle_getSelectedItem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelectedIndex", js_cocos2dx_MenuItemToggle_setSelectedIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_MenuItemToggle_prototype = JS_InitClass( cx, global, jsb_cocos2d_MenuItem_prototype, jsb_cocos2d_MenuItemToggle_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MenuItemToggle", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MenuItemToggle_class; p->proto = jsb_cocos2d_MenuItemToggle_prototype; p->parentProto = jsb_cocos2d_MenuItem_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Menu_class; JSObject *jsb_cocos2d_Menu_prototype; JSBool js_cocos2dx_Menu_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Menu_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Menu_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Menu_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Menu_alignItemsVertically(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Menu_alignItemsVertically : Invalid Native Object"); if (argc == 0) { cobj->alignItemsVertically(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Menu_alignItemsVertically : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Menu_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Menu_isEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Menu_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Menu_alignItemsHorizontallyWithPadding(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Menu_alignItemsHorizontallyWithPadding : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Menu_alignItemsHorizontallyWithPadding : Error processing arguments"); cobj->alignItemsHorizontallyWithPadding(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Menu_alignItemsHorizontallyWithPadding : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Menu_alignItemsVerticallyWithPadding(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Menu_alignItemsVerticallyWithPadding : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Menu_alignItemsVerticallyWithPadding : Error processing arguments"); cobj->alignItemsVerticallyWithPadding(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Menu_alignItemsVerticallyWithPadding : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Menu_alignItemsHorizontally(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Menu_alignItemsHorizontally : Invalid Native Object"); if (argc == 0) { cobj->alignItemsHorizontally(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Menu_alignItemsHorizontally : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Layer_prototype; void js_cocos2d_Menu_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Menu)", obj); } void js_register_cocos2dx_Menu(JSContext *cx, JSObject *global) { jsb_cocos2d_Menu_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Menu_class->name = "Menu"; jsb_cocos2d_Menu_class->addProperty = JS_PropertyStub; jsb_cocos2d_Menu_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Menu_class->getProperty = JS_PropertyStub; jsb_cocos2d_Menu_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Menu_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Menu_class->resolve = JS_ResolveStub; jsb_cocos2d_Menu_class->convert = JS_ConvertStub; jsb_cocos2d_Menu_class->finalize = js_cocos2d_Menu_finalize; jsb_cocos2d_Menu_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEnabled", js_cocos2dx_Menu_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("alignItemsVertically", js_cocos2dx_Menu_alignItemsVertically, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isEnabled", js_cocos2dx_Menu_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("alignItemsHorizontallyWithPadding", js_cocos2dx_Menu_alignItemsHorizontallyWithPadding, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("alignItemsVerticallyWithPadding", js_cocos2dx_Menu_alignItemsVerticallyWithPadding, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("alignItemsHorizontally", js_cocos2dx_Menu_alignItemsHorizontally, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Menu_prototype = JS_InitClass( cx, global, jsb_cocos2d_Layer_prototype, jsb_cocos2d_Menu_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Menu", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Menu_class; p->proto = jsb_cocos2d_Menu_prototype; p->parentProto = jsb_cocos2d_Layer_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ClippingNode_class; JSObject *jsb_cocos2d_ClippingNode_prototype; JSBool js_cocos2dx_ClippingNode_isInverted(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ClippingNode* cobj = (cocos2d::ClippingNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ClippingNode_isInverted : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isInverted(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ClippingNode_isInverted : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ClippingNode_setInverted(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ClippingNode* cobj = (cocos2d::ClippingNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ClippingNode_setInverted : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ClippingNode_setInverted : Error processing arguments"); cobj->setInverted(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ClippingNode_setInverted : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ClippingNode_setStencil(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ClippingNode* cobj = (cocos2d::ClippingNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ClippingNode_setStencil : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ClippingNode_setStencil : Error processing arguments"); cobj->setStencil(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ClippingNode_setStencil : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ClippingNode_getAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ClippingNode* cobj = (cocos2d::ClippingNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ClippingNode_getAlphaThreshold : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAlphaThreshold(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ClippingNode_getAlphaThreshold : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ClippingNode_getStencil(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ClippingNode* cobj = (cocos2d::ClippingNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ClippingNode_getStencil : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getStencil(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ClippingNode_getStencil : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ClippingNode_setAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ClippingNode* cobj = (cocos2d::ClippingNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ClippingNode_setAlphaThreshold : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ClippingNode_setAlphaThreshold : Error processing arguments"); cobj->setAlphaThreshold(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ClippingNode_setAlphaThreshold : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ClippingNode_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::ClippingNode* ret = cocos2d::ClippingNode::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ClippingNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::ClippingNode* ret = cocos2d::ClippingNode::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ClippingNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_ClippingNode_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_ClippingNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ClippingNode)", obj); } void js_register_cocos2dx_ClippingNode(JSContext *cx, JSObject *global) { jsb_cocos2d_ClippingNode_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ClippingNode_class->name = "ClippingNode"; jsb_cocos2d_ClippingNode_class->addProperty = JS_PropertyStub; jsb_cocos2d_ClippingNode_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ClippingNode_class->getProperty = JS_PropertyStub; jsb_cocos2d_ClippingNode_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ClippingNode_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ClippingNode_class->resolve = JS_ResolveStub; jsb_cocos2d_ClippingNode_class->convert = JS_ConvertStub; jsb_cocos2d_ClippingNode_class->finalize = js_cocos2d_ClippingNode_finalize; jsb_cocos2d_ClippingNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("isInverted", js_cocos2dx_ClippingNode_isInverted, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInverted", js_cocos2dx_ClippingNode_setInverted, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStencil", js_cocos2dx_ClippingNode_setStencil, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAlphaThreshold", js_cocos2dx_ClippingNode_getAlphaThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStencil", js_cocos2dx_ClippingNode_getStencil, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlphaThreshold", js_cocos2dx_ClippingNode_setAlphaThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ClippingNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ClippingNode_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_ClippingNode_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ClippingNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ClippingNode_class; p->proto = jsb_cocos2d_ClippingNode_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_MotionStreak_class; JSObject *jsb_cocos2d_MotionStreak_prototype; JSBool js_cocos2dx_MotionStreak_reset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MotionStreak_reset : Invalid Native Object"); if (argc == 0) { cobj->reset(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MotionStreak_reset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MotionStreak_setTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MotionStreak_setTexture : Invalid Native Object"); if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MotionStreak_setTexture : Error processing arguments"); cobj->setTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MotionStreak_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MotionStreak_getTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MotionStreak_getTexture : Invalid Native Object"); if (argc == 0) { cocos2d::Texture2D* ret = cobj->getTexture(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MotionStreak_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MotionStreak_tintWithColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MotionStreak_tintWithColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MotionStreak_tintWithColor : Error processing arguments"); cobj->tintWithColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MotionStreak_tintWithColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MotionStreak_setStartingPositionInitialized(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MotionStreak_setStartingPositionInitialized : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MotionStreak_setStartingPositionInitialized : Error processing arguments"); cobj->setStartingPositionInitialized(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MotionStreak_setStartingPositionInitialized : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MotionStreak_isStartingPositionInitialized(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MotionStreak_isStartingPositionInitialized : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isStartingPositionInitialized(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MotionStreak_isStartingPositionInitialized : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MotionStreak_isFastMode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MotionStreak_isFastMode : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isFastMode(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MotionStreak_isFastMode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_MotionStreak_setFastMode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_MotionStreak_setFastMode : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_MotionStreak_setFastMode : Error processing arguments"); cobj->setFastMode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_MotionStreak_setFastMode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_MotionStreak_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 5) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Color3B arg3; ok &= jsval_to_cccolor3b(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* arg4; do { if (!argv[4].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[4]); proxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::MotionStreak* ret = cocos2d::MotionStreak::create(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::MotionStreak*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 5) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Color3B arg3; ok &= jsval_to_cccolor3b(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } std::string arg4; ok &= jsval_to_std_string(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::MotionStreak* ret = cocos2d::MotionStreak::create(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::MotionStreak*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_MotionStreak_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_MotionStreak_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (MotionStreak)", obj); } void js_register_cocos2dx_MotionStreak(JSContext *cx, JSObject *global) { jsb_cocos2d_MotionStreak_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_MotionStreak_class->name = "MotionStreak"; jsb_cocos2d_MotionStreak_class->addProperty = JS_PropertyStub; jsb_cocos2d_MotionStreak_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_MotionStreak_class->getProperty = JS_PropertyStub; jsb_cocos2d_MotionStreak_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_MotionStreak_class->enumerate = JS_EnumerateStub; jsb_cocos2d_MotionStreak_class->resolve = JS_ResolveStub; jsb_cocos2d_MotionStreak_class->convert = JS_ConvertStub; jsb_cocos2d_MotionStreak_class->finalize = js_cocos2d_MotionStreak_finalize; jsb_cocos2d_MotionStreak_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("reset", js_cocos2dx_MotionStreak_reset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTexture", js_cocos2dx_MotionStreak_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTexture", js_cocos2dx_MotionStreak_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("tintWithColor", js_cocos2dx_MotionStreak_tintWithColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartingPositionInitialized", js_cocos2dx_MotionStreak_setStartingPositionInitialized, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isStartingPositionInitialized", js_cocos2dx_MotionStreak_isStartingPositionInitialized, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFastMode", js_cocos2dx_MotionStreak_isFastMode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFastMode", js_cocos2dx_MotionStreak_setFastMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_MotionStreak_create, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_MotionStreak_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_MotionStreak_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "MotionStreak", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_MotionStreak_class; p->proto = jsb_cocos2d_MotionStreak_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ProgressTimer_class; JSObject *jsb_cocos2d_ProgressTimer_prototype; JSBool js_cocos2dx_ProgressTimer_isReverseDirection(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_isReverseDirection : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isReverseDirection(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_isReverseDirection : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_setBarChangeRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setBarChangeRate : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setBarChangeRate : Error processing arguments"); cobj->setBarChangeRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setBarChangeRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_getPercentage(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_getPercentage : Invalid Native Object"); if (argc == 0) { double ret = cobj->getPercentage(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getPercentage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_setSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setSprite : Error processing arguments"); cobj->setSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_getType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_getType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_getSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_getSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_setMidpoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setMidpoint : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setMidpoint : Error processing arguments"); cobj->setMidpoint(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setMidpoint : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_getBarChangeRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_getBarChangeRate : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getBarChangeRate(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getBarChangeRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_setReverseDirection(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::ProgressTimer* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setReverseDirection : Invalid Native Object"); do { if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setReverseDirection(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setReverseProgress(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setReverseDirection : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_getMidpoint(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_getMidpoint : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getMidpoint(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getMidpoint : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_setPercentage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setPercentage : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setPercentage : Error processing arguments"); cobj->setPercentage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setPercentage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_setType(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setType : Invalid Native Object"); if (argc == 1) { cocos2d::ProgressTimer::Type arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_setType : Error processing arguments"); cobj->setType(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setType : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ProgressTimer_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ProgressTimer_create : Error processing arguments"); cocos2d::ProgressTimer* ret = cocos2d::ProgressTimer::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ProgressTimer*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ProgressTimer_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_ProgressTimer_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProgressTimer)", obj); } void js_register_cocos2dx_ProgressTimer(JSContext *cx, JSObject *global) { jsb_cocos2d_ProgressTimer_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ProgressTimer_class->name = "ProgressTimer"; jsb_cocos2d_ProgressTimer_class->addProperty = JS_PropertyStub; jsb_cocos2d_ProgressTimer_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ProgressTimer_class->getProperty = JS_PropertyStub; jsb_cocos2d_ProgressTimer_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ProgressTimer_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ProgressTimer_class->resolve = JS_ResolveStub; jsb_cocos2d_ProgressTimer_class->convert = JS_ConvertStub; jsb_cocos2d_ProgressTimer_class->finalize = js_cocos2d_ProgressTimer_finalize; jsb_cocos2d_ProgressTimer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("isReverseDirection", js_cocos2dx_ProgressTimer_isReverseDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBarChangeRate", js_cocos2dx_ProgressTimer_setBarChangeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPercentage", js_cocos2dx_ProgressTimer_getPercentage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSprite", js_cocos2dx_ProgressTimer_setSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getType", js_cocos2dx_ProgressTimer_getType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSprite", js_cocos2dx_ProgressTimer_getSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMidpoint", js_cocos2dx_ProgressTimer_setMidpoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBarChangeRate", js_cocos2dx_ProgressTimer_getBarChangeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setReverseDirection", js_cocos2dx_ProgressTimer_setReverseDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMidpoint", js_cocos2dx_ProgressTimer_getMidpoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPercentage", js_cocos2dx_ProgressTimer_setPercentage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setType", js_cocos2dx_ProgressTimer_setType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ProgressTimer_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ProgressTimer_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_ProgressTimer_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProgressTimer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ProgressTimer_class; p->proto = jsb_cocos2d_ProgressTimer_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_RenderTexture_class; JSObject *jsb_cocos2d_RenderTexture_prototype; JSBool js_cocos2dx_RenderTexture_clearStencil(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_clearStencil : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_clearStencil : Error processing arguments"); cobj->clearStencil(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_clearStencil : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_getClearDepth(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_getClearDepth : Invalid Native Object"); if (argc == 0) { double ret = cobj->getClearDepth(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_getClearDepth : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_getClearStencil(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_getClearStencil : Invalid Native Object"); if (argc == 0) { int ret = cobj->getClearStencil(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_getClearStencil : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_end(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_end : Invalid Native Object"); if (argc == 0) { cobj->end(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_end : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_setClearStencil(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setClearStencil : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setClearStencil : Error processing arguments"); cobj->setClearStencil(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_setClearStencil : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_setSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setSprite : Error processing arguments"); cobj->setSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_setSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_getSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_getSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_getSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_isAutoDraw(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_isAutoDraw : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isAutoDraw(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_isAutoDraw : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_setClearFlags(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setClearFlags : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setClearFlags : Error processing arguments"); cobj->setClearFlags(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_setClearFlags : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_begin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_begin : Invalid Native Object"); if (argc == 0) { cobj->begin(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_begin : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::RenderTexture* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_saveToFile : Invalid Native Object"); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Image::Format arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->saveToFile(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->saveToFile(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_RenderTexture_saveToFile : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_setAutoDraw(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setAutoDraw : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setAutoDraw : Error processing arguments"); cobj->setAutoDraw(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_setAutoDraw : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_setClearColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setClearColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color4F arg0; ok &= jsval_to_cccolor4f(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setClearColor : Error processing arguments"); cobj->setClearColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_setClearColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_endToLua(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_endToLua : Invalid Native Object"); if (argc == 0) { cobj->endToLua(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_endToLua : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_beginWithClear(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::RenderTexture* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_beginWithClear : Invalid Native Object"); do { if (argc == 5) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } double arg3; ok &= JS_ValueToNumber(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } double arg4; ok &= JS_ValueToNumber(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } cobj->beginWithClear(arg0, arg1, arg2, arg3, arg4); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 4) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } double arg3; ok &= JS_ValueToNumber(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cobj->beginWithClear(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 6) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } double arg3; ok &= JS_ValueToNumber(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } double arg4; ok &= JS_ValueToNumber(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } int arg5; ok &= jsval_to_int32(cx, argv[5], (int32_t *)&arg5); if (!ok) { ok = JS_TRUE; break; } cobj->beginWithClear(arg0, arg1, arg2, arg3, arg4, arg5); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_RenderTexture_beginWithClear : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_clearDepth(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_clearDepth : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_clearDepth : Error processing arguments"); cobj->clearDepth(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_clearDepth : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_getClearColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_getClearColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color4F& ret = cobj->getClearColor(); jsval jsret = JSVAL_NULL; jsret = cccolor4f_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_getClearColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_clear(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_clear : Invalid Native Object"); if (argc == 4) { double arg0; double arg1; double arg2; double arg3; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_clear : Error processing arguments"); cobj->clear(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_clear : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_getClearFlags(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_getClearFlags : Invalid Native Object"); if (argc == 0) { unsigned int ret = cobj->getClearFlags(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_getClearFlags : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_newImage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_newImage : Invalid Native Object"); if (argc == 0) { cocos2d::Image* ret = cobj->newImage(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Image*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_newImage : Error processing arguments"); cocos2d::Image* ret = cobj->newImage(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Image*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_newImage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_setClearDepth(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setClearDepth : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_RenderTexture_setClearDepth : Error processing arguments"); cobj->setClearDepth(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_setClearDepth : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_initWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::RenderTexture* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_RenderTexture_initWithWidthAndHeight : Invalid Native Object"); do { if (argc == 4) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D::PixelFormat arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } unsigned int arg3; ok &= jsval_to_uint32(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithWidthAndHeight(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 3) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D::PixelFormat arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithWidthAndHeight(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_RenderTexture_initWithWidthAndHeight : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D::PixelFormat arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RenderTexture*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 4) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D::PixelFormat arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } unsigned int arg3; ok &= jsval_to_uint32(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RenderTexture*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::RenderTexture*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_RenderTexture_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_RenderTexture_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::RenderTexture* cobj = new cocos2d::RenderTexture(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::RenderTexture"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_RenderTexture_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_RenderTexture_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RenderTexture)", obj); } void js_register_cocos2dx_RenderTexture(JSContext *cx, JSObject *global) { jsb_cocos2d_RenderTexture_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_RenderTexture_class->name = "RenderTexture"; jsb_cocos2d_RenderTexture_class->addProperty = JS_PropertyStub; jsb_cocos2d_RenderTexture_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_RenderTexture_class->getProperty = JS_PropertyStub; jsb_cocos2d_RenderTexture_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_RenderTexture_class->enumerate = JS_EnumerateStub; jsb_cocos2d_RenderTexture_class->resolve = JS_ResolveStub; jsb_cocos2d_RenderTexture_class->convert = JS_ConvertStub; jsb_cocos2d_RenderTexture_class->finalize = js_cocos2d_RenderTexture_finalize; jsb_cocos2d_RenderTexture_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("clearStencil", js_cocos2dx_RenderTexture_clearStencil, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getClearDepth", js_cocos2dx_RenderTexture_getClearDepth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getClearStencil", js_cocos2dx_RenderTexture_getClearStencil, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("end", js_cocos2dx_RenderTexture_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClearStencil", js_cocos2dx_RenderTexture_setClearStencil, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSprite", js_cocos2dx_RenderTexture_setSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSprite", js_cocos2dx_RenderTexture_getSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isAutoDraw", js_cocos2dx_RenderTexture_isAutoDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClearFlags", js_cocos2dx_RenderTexture_setClearFlags, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("begin", js_cocos2dx_RenderTexture_begin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("saveToFile", js_cocos2dx_RenderTexture_saveToFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAutoDraw", js_cocos2dx_RenderTexture_setAutoDraw, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClearColor", js_cocos2dx_RenderTexture_setClearColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("endToLua", js_cocos2dx_RenderTexture_endToLua, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("beginWithClear", js_cocos2dx_RenderTexture_beginWithClear, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clearDepth", js_cocos2dx_RenderTexture_clearDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getClearColor", js_cocos2dx_RenderTexture_getClearColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clear", js_cocos2dx_RenderTexture_clear, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getClearFlags", js_cocos2dx_RenderTexture_getClearFlags, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("newImage", js_cocos2dx_RenderTexture_newImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClearDepth", js_cocos2dx_RenderTexture_setClearDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithWidthAndHeight", js_cocos2dx_RenderTexture_initWithWidthAndHeight, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_RenderTexture_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_RenderTexture_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_RenderTexture_class, js_cocos2dx_RenderTexture_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "RenderTexture", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_RenderTexture_class; p->proto = jsb_cocos2d_RenderTexture_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_NodeGrid_class; JSObject *jsb_cocos2d_NodeGrid_prototype; JSBool js_cocos2dx_NodeGrid_setTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::NodeGrid* cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_NodeGrid_setTarget : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_NodeGrid_setTarget : Error processing arguments"); cobj->setTarget(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_NodeGrid_setTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_NodeGrid_getGrid(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::NodeGrid* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_NodeGrid_getGrid : Invalid Native Object"); do { if (argc == 0) { const cocos2d::GridBase* ret = cobj->getGrid(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::GridBase* ret = cobj->getGrid(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_NodeGrid_getGrid : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_NodeGrid_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::NodeGrid* ret = cocos2d::NodeGrid::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::NodeGrid*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_NodeGrid_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_NodeGrid_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (NodeGrid)", obj); } void js_register_cocos2dx_NodeGrid(JSContext *cx, JSObject *global) { jsb_cocos2d_NodeGrid_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_NodeGrid_class->name = "NodeGrid"; jsb_cocos2d_NodeGrid_class->addProperty = JS_PropertyStub; jsb_cocos2d_NodeGrid_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_NodeGrid_class->getProperty = JS_PropertyStub; jsb_cocos2d_NodeGrid_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_NodeGrid_class->enumerate = JS_EnumerateStub; jsb_cocos2d_NodeGrid_class->resolve = JS_ResolveStub; jsb_cocos2d_NodeGrid_class->convert = JS_ConvertStub; jsb_cocos2d_NodeGrid_class->finalize = js_cocos2d_NodeGrid_finalize; jsb_cocos2d_NodeGrid_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setTarget", js_cocos2dx_NodeGrid_setTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGrid", js_cocos2dx_NodeGrid_getGrid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_NodeGrid_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_NodeGrid_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_NodeGrid_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "NodeGrid", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_NodeGrid_class; p->proto = jsb_cocos2d_NodeGrid_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleBatchNode_class; JSObject *jsb_cocos2d_ParticleBatchNode_prototype; JSBool js_cocos2dx_ParticleBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_setTexture : Invalid Native Object"); if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_setTexture : Error processing arguments"); cobj->setTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_disableParticle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_disableParticle : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_disableParticle : Error processing arguments"); cobj->disableParticle(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_disableParticle : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_getTexture : Invalid Native Object"); if (argc == 0) { cocos2d::Texture2D* ret = cobj->getTexture(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_setTextureAtlas : Invalid Native Object"); if (argc == 1) { cocos2d::TextureAtlas* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextureAtlas*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_setTextureAtlas : Error processing arguments"); cobj->setTextureAtlas(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_setTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup : Error processing arguments"); cobj->removeAllChildrenWithCleanup(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_getTextureAtlas : Invalid Native Object"); if (argc == 0) { cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TextureAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_getTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_insertChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_insertChild : Invalid Native Object"); if (argc == 2) { cocos2d::ParticleSystem* arg0; int arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ParticleSystem*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_insertChild : Error processing arguments"); cobj->insertChild(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_insertChild : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_visit(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_visit : Invalid Native Object"); if (argc == 0) { cobj->visit(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_visit : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_removeChildAtIndex : Invalid Native Object"); if (argc == 2) { int arg0; JSBool arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_removeChildAtIndex : Error processing arguments"); cobj->removeChildAtIndex(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_removeChildAtIndex : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_create : Error processing arguments"); cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { std::string arg0; int arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_create : Error processing arguments"); cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_createWithTexture : Error processing arguments"); cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::createWithTexture(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { cocos2d::Texture2D* arg0; int arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleBatchNode_createWithTexture : Error processing arguments"); cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::createWithTexture(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_createWithTexture : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_ParticleBatchNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleBatchNode)", obj); } void js_register_cocos2dx_ParticleBatchNode(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleBatchNode_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleBatchNode_class->name = "ParticleBatchNode"; jsb_cocos2d_ParticleBatchNode_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleBatchNode_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleBatchNode_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleBatchNode_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleBatchNode_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleBatchNode_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleBatchNode_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleBatchNode_class->finalize = js_cocos2d_ParticleBatchNode_finalize; jsb_cocos2d_ParticleBatchNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setTexture", js_cocos2dx_ParticleBatchNode_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("disableParticle", js_cocos2dx_ParticleBatchNode_disableParticle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTexture", js_cocos2dx_ParticleBatchNode_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextureAtlas", js_cocos2dx_ParticleBatchNode_setTextureAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllChildrenWithCleanup", js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureAtlas", js_cocos2dx_ParticleBatchNode_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("insertChild", js_cocos2dx_ParticleBatchNode_insertChild, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("visit", js_cocos2dx_ParticleBatchNode_visit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeChildAtIndex", js_cocos2dx_ParticleBatchNode_removeChildAtIndex, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleBatchNode_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTexture", js_cocos2dx_ParticleBatchNode_createWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleBatchNode_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_ParticleBatchNode_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleBatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleBatchNode_class; p->proto = jsb_cocos2d_ParticleBatchNode_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleSystem_class; JSObject *jsb_cocos2d_ParticleSystem_prototype; JSBool js_cocos2dx_ParticleSystem_getStartSizeVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getStartSizeVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getStartSizeVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartSizeVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getTexture : Invalid Native Object"); if (argc == 0) { cocos2d::Texture2D* ret = cobj->getTexture(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_isFull(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_isFull : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isFull(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isFull : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getBatchNode : Invalid Native Object"); if (argc == 0) { cocos2d::ParticleBatchNode* ret = cobj->getBatchNode(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getBatchNode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getStartColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getStartColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color4F& ret = cobj->getStartColor(); jsval jsret = JSVAL_NULL; jsret = cccolor4f_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getPositionType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getPositionType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getPositionType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getPositionType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setPosVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setPosVar : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setPosVar : Error processing arguments"); cobj->setPosVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setPosVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEndSpin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEndSpin : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEndSpin(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndSpin : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setRotatePerSecondVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRotatePerSecondVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRotatePerSecondVar : Error processing arguments"); cobj->setRotatePerSecondVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRotatePerSecondVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getStartSpinVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getStartSpinVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getStartSpinVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartSpinVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getRadialAccelVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getRadialAccelVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRadialAccelVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRadialAccelVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEndSizeVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEndSizeVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEndSizeVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndSizeVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setRotation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRotation : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRotation : Error processing arguments"); cobj->setRotation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRotation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setTangentialAccel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setTangentialAccel : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setTangentialAccel : Error processing arguments"); cobj->setTangentialAccel(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setTangentialAccel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setScaleY(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setScaleY : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setScaleY : Error processing arguments"); cobj->setScaleY(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setScaleY : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setScaleX(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setScaleX : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setScaleX : Error processing arguments"); cobj->setScaleX(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setScaleX : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getRadialAccel(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getRadialAccel : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRadialAccel(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRadialAccel : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setStartRadius(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartRadius : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartRadius : Error processing arguments"); cobj->setStartRadius(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartRadius : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setRotatePerSecond(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRotatePerSecond : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRotatePerSecond : Error processing arguments"); cobj->setRotatePerSecond(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRotatePerSecond : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEndSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndSize : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndSize : Error processing arguments"); cobj->setEndSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getGravity(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getGravity : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getGravity(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getGravity : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getTangentialAccel(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getTangentialAccel : Invalid Native Object"); if (argc == 0) { double ret = cobj->getTangentialAccel(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getTangentialAccel : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEndRadius(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndRadius : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndRadius : Error processing arguments"); cobj->setEndRadius(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndRadius : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getSpeed(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getSpeed : Invalid Native Object"); if (argc == 0) { double ret = cobj->getSpeed(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getSpeed : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getAngle : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAngle(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getAngle : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEndColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color4F arg0; ok &= jsval_to_cccolor4f(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndColor : Error processing arguments"); cobj->setEndColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setStartSpin(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartSpin : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartSpin : Error processing arguments"); cobj->setStartSpin(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartSpin : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setDuration : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setDuration : Error processing arguments"); cobj->setDuration(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setDuration : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setTexture : Invalid Native Object"); if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setTexture : Error processing arguments"); cobj->setTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getPosVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getPosVar : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getPosVar(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getPosVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_updateWithNoTime(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_updateWithNoTime : Invalid Native Object"); if (argc == 0) { cobj->updateWithNoTime(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_updateWithNoTime : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_isBlendAdditive(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_isBlendAdditive : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isBlendAdditive(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isBlendAdditive : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getSpeedVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getSpeedVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getSpeedVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getSpeedVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setPositionType(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setPositionType : Invalid Native Object"); if (argc == 1) { cocos2d::ParticleSystem::PositionType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setPositionType : Error processing arguments"); cobj->setPositionType(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setPositionType : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_stopSystem(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_stopSystem : Invalid Native Object"); if (argc == 0) { cobj->stopSystem(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_stopSystem : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getSourcePosition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getSourcePosition : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getSourcePosition(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getSourcePosition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setLifeVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setLifeVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setLifeVar : Error processing arguments"); cobj->setLifeVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setLifeVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setTotalParticles : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setTotalParticles : Error processing arguments"); cobj->setTotalParticles(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEndColorVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndColorVar : Invalid Native Object"); if (argc == 1) { cocos2d::Color4F arg0; ok &= jsval_to_cccolor4f(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndColorVar : Error processing arguments"); cobj->setEndColorVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndColorVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_updateQuadWithParticle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_updateQuadWithParticle : Invalid Native Object"); if (argc == 2) { cocos2d::sParticle* arg0; cocos2d::Point arg1; #pragma warning NO CONVERSION TO NATIVE FOR sParticle*; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_updateQuadWithParticle : Error processing arguments"); cobj->updateQuadWithParticle(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_updateQuadWithParticle : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getAtlasIndex : Invalid Native Object"); if (argc == 0) { int ret = cobj->getAtlasIndex(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getAtlasIndex : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getStartSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getStartSize : Invalid Native Object"); if (argc == 0) { double ret = cobj->getStartSize(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setStartSpinVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartSpinVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartSpinVar : Error processing arguments"); cobj->setStartSpinVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartSpinVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_resetSystem(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_resetSystem : Invalid Native Object"); if (argc == 0) { cobj->resetSystem(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_resetSystem : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setAtlasIndex : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setAtlasIndex : Error processing arguments"); cobj->setAtlasIndex(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setAtlasIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setTangentialAccelVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setTangentialAccelVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setTangentialAccelVar : Error processing arguments"); cobj->setTangentialAccelVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setTangentialAccelVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEndRadiusVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndRadiusVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndRadiusVar : Error processing arguments"); cobj->setEndRadiusVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndRadiusVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEndRadius(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEndRadius : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEndRadius(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndRadius : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_isOpacityModifyRGB : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isOpacityModifyRGB(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_isActive(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_isActive : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isActive(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isActive : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setRadialAccelVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRadialAccelVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRadialAccelVar : Error processing arguments"); cobj->setRadialAccelVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRadialAccelVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setStartSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartSize : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartSize : Error processing arguments"); cobj->setStartSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setSpeed(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setSpeed : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setSpeed : Error processing arguments"); cobj->setSpeed(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setSpeed : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getStartSpin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getStartSpin : Invalid Native Object"); if (argc == 0) { double ret = cobj->getStartSpin(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartSpin : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getRotatePerSecond(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getRotatePerSecond : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRotatePerSecond(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRotatePerSecond : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_initParticle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_initParticle : Invalid Native Object"); if (argc == 1) { cocos2d::sParticle* arg0; #pragma warning NO CONVERSION TO NATIVE FOR sParticle*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_initParticle : Error processing arguments"); cobj->initParticle(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_initParticle : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEmitterMode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEmitterMode : Invalid Native Object"); if (argc == 1) { cocos2d::ParticleSystem::Mode arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEmitterMode : Error processing arguments"); cobj->setEmitterMode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEmitterMode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getDuration(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getDuration : Invalid Native Object"); if (argc == 0) { double ret = cobj->getDuration(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setSourcePosition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setSourcePosition : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setSourcePosition : Error processing arguments"); cobj->setSourcePosition(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setSourcePosition : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEndSpinVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEndSpinVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEndSpinVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndSpinVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setBlendAdditive(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setBlendAdditive : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setBlendAdditive : Error processing arguments"); cobj->setBlendAdditive(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setBlendAdditive : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setLife(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setLife : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setLife : Error processing arguments"); cobj->setLife(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setLife : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setAngleVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setAngleVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setAngleVar : Error processing arguments"); cobj->setAngleVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setAngleVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setRotationIsDir(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRotationIsDir : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRotationIsDir : Error processing arguments"); cobj->setRotationIsDir(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRotationIsDir : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEndSizeVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndSizeVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndSizeVar : Error processing arguments"); cobj->setEndSizeVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndSizeVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setAngle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setAngle : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setAngle : Error processing arguments"); cobj->setAngle(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setAngle : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setBatchNode : Invalid Native Object"); if (argc == 1) { cocos2d::ParticleBatchNode* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ParticleBatchNode*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setBatchNode : Error processing arguments"); cobj->setBatchNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setBatchNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getTangentialAccelVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getTangentialAccelVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getTangentialAccelVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getTangentialAccelVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEmitterMode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEmitterMode : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getEmitterMode(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEmitterMode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEndSpinVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndSpinVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndSpinVar : Error processing arguments"); cobj->setEndSpinVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndSpinVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getAngleVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getAngleVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getAngleVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getAngleVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setStartColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color4F arg0; ok &= jsval_to_cccolor4f(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartColor : Error processing arguments"); cobj->setStartColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getRotatePerSecondVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getRotatePerSecondVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRotatePerSecondVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRotatePerSecondVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEndSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEndSize : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEndSize(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getLife(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getLife : Invalid Native Object"); if (argc == 0) { double ret = cobj->getLife(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getLife : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setSpeedVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setSpeedVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setSpeedVar : Error processing arguments"); cobj->setSpeedVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setSpeedVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish : Error processing arguments"); cobj->setAutoRemoveOnFinish(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setGravity(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setGravity : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setGravity : Error processing arguments"); cobj->setGravity(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_postStep(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_postStep : Invalid Native Object"); if (argc == 0) { cobj->postStep(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_postStep : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEmissionRate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEmissionRate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEmissionRate : Error processing arguments"); cobj->setEmissionRate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEmissionRate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEndColorVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEndColorVar : Invalid Native Object"); if (argc == 0) { const cocos2d::Color4F& ret = cobj->getEndColorVar(); jsval jsret = JSVAL_NULL; jsret = cccolor4f_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndColorVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getRotationIsDir(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getRotationIsDir : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getRotationIsDir(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRotationIsDir : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setScale(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setScale : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setScale : Error processing arguments"); cobj->setScale(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setScale : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEmissionRate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEmissionRate : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEmissionRate(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEmissionRate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEndColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEndColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color4F& ret = cobj->getEndColor(); jsval jsret = JSVAL_NULL; jsret = cccolor4f_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getLifeVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getLifeVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getLifeVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getLifeVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setStartSizeVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartSizeVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartSizeVar : Error processing arguments"); cobj->setStartSizeVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartSizeVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setOpacityModifyRGB : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setOpacityModifyRGB : Error processing arguments"); cobj->setOpacityModifyRGB(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_addParticle(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_addParticle : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->addParticle(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_addParticle : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getStartRadius(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getStartRadius : Invalid Native Object"); if (argc == 0) { double ret = cobj->getStartRadius(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartRadius : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getParticleCount(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getParticleCount : Invalid Native Object"); if (argc == 0) { unsigned int ret = cobj->getParticleCount(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getParticleCount : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getStartRadiusVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getStartRadiusVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getStartRadiusVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartRadiusVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setStartColorVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartColorVar : Invalid Native Object"); if (argc == 1) { cocos2d::Color4F arg0; ok &= jsval_to_cccolor4f(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartColorVar : Error processing arguments"); cobj->setStartColorVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartColorVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setEndSpin(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndSpin : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setEndSpin : Error processing arguments"); cobj->setEndSpin(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndSpin : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setRadialAccel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRadialAccel : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setRadialAccel : Error processing arguments"); cobj->setRadialAccel(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRadialAccel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isAutoRemoveOnFinish(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getTotalParticles : Invalid Native Object"); if (argc == 0) { int ret = cobj->getTotalParticles(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_setStartRadiusVar(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartRadiusVar : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_setStartRadiusVar : Error processing arguments"); cobj->setStartRadiusVar(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartRadiusVar : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getEndRadiusVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getEndRadiusVar : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEndRadiusVar(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndRadiusVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_getStartColorVar(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_getStartColorVar : Invalid Native Object"); if (argc == 0) { const cocos2d::Color4F& ret = cobj->getStartColorVar(); jsval jsret = JSVAL_NULL; jsret = cccolor4f_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartColorVar : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_create : Error processing arguments"); cocos2d::ParticleSystem* ret = cocos2d::ParticleSystem::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystem*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystem_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystem_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleSystem* ret = cocos2d::ParticleSystem::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystem*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystem_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_ParticleSystem_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSystem)", obj); } void js_register_cocos2dx_ParticleSystem(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleSystem_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleSystem_class->name = "ParticleSystem"; jsb_cocos2d_ParticleSystem_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleSystem_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleSystem_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleSystem_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleSystem_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleSystem_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleSystem_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleSystem_class->finalize = js_cocos2d_ParticleSystem_finalize; jsb_cocos2d_ParticleSystem_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getStartSizeVar", js_cocos2dx_ParticleSystem_getStartSizeVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTexture", js_cocos2dx_ParticleSystem_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFull", js_cocos2dx_ParticleSystem_isFull, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBatchNode", js_cocos2dx_ParticleSystem_getBatchNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartColor", js_cocos2dx_ParticleSystem_getStartColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionType", js_cocos2dx_ParticleSystem_getPositionType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPosVar", js_cocos2dx_ParticleSystem_setPosVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndSpin", js_cocos2dx_ParticleSystem_getEndSpin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotatePerSecondVar", js_cocos2dx_ParticleSystem_setRotatePerSecondVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartSpinVar", js_cocos2dx_ParticleSystem_getStartSpinVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRadialAccelVar", js_cocos2dx_ParticleSystem_getRadialAccelVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndSizeVar", js_cocos2dx_ParticleSystem_getEndSizeVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotation", js_cocos2dx_ParticleSystem_setRotation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTangentialAccel", js_cocos2dx_ParticleSystem_setTangentialAccel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScaleY", js_cocos2dx_ParticleSystem_setScaleY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScaleX", js_cocos2dx_ParticleSystem_setScaleX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRadialAccel", js_cocos2dx_ParticleSystem_getRadialAccel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartRadius", js_cocos2dx_ParticleSystem_setStartRadius, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotatePerSecond", js_cocos2dx_ParticleSystem_setRotatePerSecond, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndSize", js_cocos2dx_ParticleSystem_setEndSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGravity", js_cocos2dx_ParticleSystem_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTangentialAccel", js_cocos2dx_ParticleSystem_getTangentialAccel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndRadius", js_cocos2dx_ParticleSystem_setEndRadius, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpeed", js_cocos2dx_ParticleSystem_getSpeed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAngle", js_cocos2dx_ParticleSystem_getAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndColor", js_cocos2dx_ParticleSystem_setEndColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartSpin", js_cocos2dx_ParticleSystem_setStartSpin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDuration", js_cocos2dx_ParticleSystem_setDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTexture", js_cocos2dx_ParticleSystem_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPosVar", js_cocos2dx_ParticleSystem_getPosVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateWithNoTime", js_cocos2dx_ParticleSystem_updateWithNoTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBlendAdditive", js_cocos2dx_ParticleSystem_isBlendAdditive, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpeedVar", js_cocos2dx_ParticleSystem_getSpeedVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPositionType", js_cocos2dx_ParticleSystem_setPositionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopSystem", js_cocos2dx_ParticleSystem_stopSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSourcePosition", js_cocos2dx_ParticleSystem_getSourcePosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLifeVar", js_cocos2dx_ParticleSystem_setLifeVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTotalParticles", js_cocos2dx_ParticleSystem_setTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndColorVar", js_cocos2dx_ParticleSystem_setEndColorVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateQuadWithParticle", js_cocos2dx_ParticleSystem_updateQuadWithParticle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAtlasIndex", js_cocos2dx_ParticleSystem_getAtlasIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartSize", js_cocos2dx_ParticleSystem_getStartSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartSpinVar", js_cocos2dx_ParticleSystem_setStartSpinVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resetSystem", js_cocos2dx_ParticleSystem_resetSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAtlasIndex", js_cocos2dx_ParticleSystem_setAtlasIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTangentialAccelVar", js_cocos2dx_ParticleSystem_setTangentialAccelVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndRadiusVar", js_cocos2dx_ParticleSystem_setEndRadiusVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndRadius", js_cocos2dx_ParticleSystem_getEndRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isOpacityModifyRGB", js_cocos2dx_ParticleSystem_isOpacityModifyRGB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isActive", js_cocos2dx_ParticleSystem_isActive, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRadialAccelVar", js_cocos2dx_ParticleSystem_setRadialAccelVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartSize", js_cocos2dx_ParticleSystem_setStartSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSpeed", js_cocos2dx_ParticleSystem_setSpeed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartSpin", js_cocos2dx_ParticleSystem_getStartSpin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRotatePerSecond", js_cocos2dx_ParticleSystem_getRotatePerSecond, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initParticle", js_cocos2dx_ParticleSystem_initParticle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEmitterMode", js_cocos2dx_ParticleSystem_setEmitterMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDuration", js_cocos2dx_ParticleSystem_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSourcePosition", js_cocos2dx_ParticleSystem_setSourcePosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndSpinVar", js_cocos2dx_ParticleSystem_getEndSpinVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBlendAdditive", js_cocos2dx_ParticleSystem_setBlendAdditive, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLife", js_cocos2dx_ParticleSystem_setLife, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAngleVar", js_cocos2dx_ParticleSystem_setAngleVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRotationIsDir", js_cocos2dx_ParticleSystem_setRotationIsDir, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndSizeVar", js_cocos2dx_ParticleSystem_setEndSizeVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAngle", js_cocos2dx_ParticleSystem_setAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBatchNode", js_cocos2dx_ParticleSystem_setBatchNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTangentialAccelVar", js_cocos2dx_ParticleSystem_getTangentialAccelVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEmitterMode", js_cocos2dx_ParticleSystem_getEmitterMode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndSpinVar", js_cocos2dx_ParticleSystem_setEndSpinVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAngleVar", js_cocos2dx_ParticleSystem_getAngleVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartColor", js_cocos2dx_ParticleSystem_setStartColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRotatePerSecondVar", js_cocos2dx_ParticleSystem_getRotatePerSecondVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndSize", js_cocos2dx_ParticleSystem_getEndSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLife", js_cocos2dx_ParticleSystem_getLife, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSpeedVar", js_cocos2dx_ParticleSystem_setSpeedVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAutoRemoveOnFinish", js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGravity", js_cocos2dx_ParticleSystem_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("postStep", js_cocos2dx_ParticleSystem_postStep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEmissionRate", js_cocos2dx_ParticleSystem_setEmissionRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndColorVar", js_cocos2dx_ParticleSystem_getEndColorVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRotationIsDir", js_cocos2dx_ParticleSystem_getRotationIsDir, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale", js_cocos2dx_ParticleSystem_setScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEmissionRate", js_cocos2dx_ParticleSystem_getEmissionRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndColor", js_cocos2dx_ParticleSystem_getEndColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLifeVar", js_cocos2dx_ParticleSystem_getLifeVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartSizeVar", js_cocos2dx_ParticleSystem_setStartSizeVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOpacityModifyRGB", js_cocos2dx_ParticleSystem_setOpacityModifyRGB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addParticle", js_cocos2dx_ParticleSystem_addParticle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartRadius", js_cocos2dx_ParticleSystem_getStartRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParticleCount", js_cocos2dx_ParticleSystem_getParticleCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartRadiusVar", js_cocos2dx_ParticleSystem_getStartRadiusVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartColorVar", js_cocos2dx_ParticleSystem_setStartColorVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndSpin", js_cocos2dx_ParticleSystem_setEndSpin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRadialAccel", js_cocos2dx_ParticleSystem_setRadialAccel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isAutoRemoveOnFinish", js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTotalParticles", js_cocos2dx_ParticleSystem_getTotalParticles, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStartRadiusVar", js_cocos2dx_ParticleSystem_setStartRadiusVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEndRadiusVar", js_cocos2dx_ParticleSystem_getEndRadiusVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartColorVar", js_cocos2dx_ParticleSystem_getStartColorVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleSystem_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSystem_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleSystem_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_ParticleSystem_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleSystem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleSystem_class; p->proto = jsb_cocos2d_ParticleSystem_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleSystemQuad_class; JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; JSBool js_cocos2dx_ParticleSystemQuad_setDisplayFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystemQuad* cobj = (cocos2d::ParticleSystemQuad *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystemQuad_setDisplayFrame : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystemQuad_setDisplayFrame : Error processing arguments"); cobj->setDisplayFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_setDisplayFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystemQuad_setTextureWithRect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParticleSystemQuad* cobj = (cocos2d::ParticleSystemQuad *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParticleSystemQuad_setTextureWithRect : Invalid Native Object"); if (argc == 2) { cocos2d::Texture2D* arg0; cocos2d::Rect arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccrect(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystemQuad_setTextureWithRect : Error processing arguments"); cobj->setTextureWithRect(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_setTextureWithRect : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystemQuad_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystemQuad*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystemQuad*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleSystemQuad_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSystemQuad_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystemQuad*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystem_prototype; void js_cocos2d_ParticleSystemQuad_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSystemQuad)", obj); } void js_register_cocos2dx_ParticleSystemQuad(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleSystemQuad_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleSystemQuad_class->name = "ParticleSystem"; jsb_cocos2d_ParticleSystemQuad_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleSystemQuad_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleSystemQuad_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleSystemQuad_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleSystemQuad_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleSystemQuad_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleSystemQuad_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleSystemQuad_class->finalize = js_cocos2d_ParticleSystemQuad_finalize; jsb_cocos2d_ParticleSystemQuad_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setDisplayFrame", js_cocos2dx_ParticleSystemQuad_setDisplayFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextureWithRect", js_cocos2dx_ParticleSystemQuad_setTextureWithRect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleSystemQuad_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSystemQuad_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleSystemQuad_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystem_prototype, jsb_cocos2d_ParticleSystemQuad_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleSystem", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleSystemQuad_class; p->proto = jsb_cocos2d_ParticleSystemQuad_prototype; p->parentProto = jsb_cocos2d_ParticleSystem_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleFire_class; JSObject *jsb_cocos2d_ParticleFire_prototype; JSBool js_cocos2dx_ParticleFire_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleFire* ret = cocos2d::ParticleFire::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFire*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleFire_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleFire_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleFire_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleFire* ret = cocos2d::ParticleFire::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFire*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleFire_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleFire_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleFire)", obj); } void js_register_cocos2dx_ParticleFire(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleFire_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleFire_class->name = "ParticleFire"; jsb_cocos2d_ParticleFire_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleFire_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleFire_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleFire_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleFire_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleFire_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleFire_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleFire_class->finalize = js_cocos2d_ParticleFire_finalize; jsb_cocos2d_ParticleFire_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleFire_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleFire_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleFire_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleFire_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleFire", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleFire_class; p->proto = jsb_cocos2d_ParticleFire_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleFireworks_class; JSObject *jsb_cocos2d_ParticleFireworks_prototype; JSBool js_cocos2dx_ParticleFireworks_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleFireworks* ret = cocos2d::ParticleFireworks::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFireworks*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleFireworks_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleFireworks_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleFireworks_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleFireworks* ret = cocos2d::ParticleFireworks::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFireworks*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleFireworks_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleFireworks_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleFireworks)", obj); } void js_register_cocos2dx_ParticleFireworks(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleFireworks_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleFireworks_class->name = "ParticleFireworks"; jsb_cocos2d_ParticleFireworks_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleFireworks_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleFireworks_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleFireworks_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleFireworks_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleFireworks_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleFireworks_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleFireworks_class->finalize = js_cocos2d_ParticleFireworks_finalize; jsb_cocos2d_ParticleFireworks_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleFireworks_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleFireworks_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleFireworks_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleFireworks_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleFireworks", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleFireworks_class; p->proto = jsb_cocos2d_ParticleFireworks_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleSun_class; JSObject *jsb_cocos2d_ParticleSun_prototype; JSBool js_cocos2dx_ParticleSun_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleSun* ret = cocos2d::ParticleSun::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSun*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSun_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleSun_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSun_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleSun* ret = cocos2d::ParticleSun::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSun*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSun_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleSun_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSun)", obj); } void js_register_cocos2dx_ParticleSun(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleSun_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleSun_class->name = "ParticleSun"; jsb_cocos2d_ParticleSun_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleSun_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleSun_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleSun_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleSun_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleSun_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleSun_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleSun_class->finalize = js_cocos2d_ParticleSun_finalize; jsb_cocos2d_ParticleSun_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleSun_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSun_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleSun_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleSun_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleSun", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleSun_class; p->proto = jsb_cocos2d_ParticleSun_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleGalaxy_class; JSObject *jsb_cocos2d_ParticleGalaxy_prototype; JSBool js_cocos2dx_ParticleGalaxy_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleGalaxy* ret = cocos2d::ParticleGalaxy::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleGalaxy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleGalaxy_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleGalaxy_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleGalaxy_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleGalaxy* ret = cocos2d::ParticleGalaxy::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleGalaxy*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleGalaxy_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleGalaxy_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleGalaxy)", obj); } void js_register_cocos2dx_ParticleGalaxy(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleGalaxy_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleGalaxy_class->name = "ParticleGalaxy"; jsb_cocos2d_ParticleGalaxy_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleGalaxy_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleGalaxy_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleGalaxy_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleGalaxy_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleGalaxy_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleGalaxy_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleGalaxy_class->finalize = js_cocos2d_ParticleGalaxy_finalize; jsb_cocos2d_ParticleGalaxy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleGalaxy_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleGalaxy_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleGalaxy_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleGalaxy_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleGalaxy", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleGalaxy_class; p->proto = jsb_cocos2d_ParticleGalaxy_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleFlower_class; JSObject *jsb_cocos2d_ParticleFlower_prototype; JSBool js_cocos2dx_ParticleFlower_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleFlower* ret = cocos2d::ParticleFlower::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFlower*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleFlower_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleFlower_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleFlower_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleFlower* ret = cocos2d::ParticleFlower::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFlower*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleFlower_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleFlower_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleFlower)", obj); } void js_register_cocos2dx_ParticleFlower(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleFlower_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleFlower_class->name = "ParticleFlower"; jsb_cocos2d_ParticleFlower_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleFlower_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleFlower_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleFlower_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleFlower_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleFlower_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleFlower_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleFlower_class->finalize = js_cocos2d_ParticleFlower_finalize; jsb_cocos2d_ParticleFlower_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleFlower_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleFlower_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleFlower_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleFlower_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleFlower", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleFlower_class; p->proto = jsb_cocos2d_ParticleFlower_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleMeteor_class; JSObject *jsb_cocos2d_ParticleMeteor_prototype; JSBool js_cocos2dx_ParticleMeteor_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleMeteor* ret = cocos2d::ParticleMeteor::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleMeteor*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleMeteor_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleMeteor_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleMeteor_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleMeteor* ret = cocos2d::ParticleMeteor::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleMeteor*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleMeteor_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleMeteor_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleMeteor)", obj); } void js_register_cocos2dx_ParticleMeteor(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleMeteor_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleMeteor_class->name = "ParticleMeteor"; jsb_cocos2d_ParticleMeteor_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleMeteor_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleMeteor_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleMeteor_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleMeteor_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleMeteor_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleMeteor_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleMeteor_class->finalize = js_cocos2d_ParticleMeteor_finalize; jsb_cocos2d_ParticleMeteor_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleMeteor_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleMeteor_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleMeteor_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleMeteor_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleMeteor", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleMeteor_class; p->proto = jsb_cocos2d_ParticleMeteor_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleSpiral_class; JSObject *jsb_cocos2d_ParticleSpiral_prototype; JSBool js_cocos2dx_ParticleSpiral_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleSpiral* ret = cocos2d::ParticleSpiral::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSpiral*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSpiral_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleSpiral_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSpiral_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleSpiral* ret = cocos2d::ParticleSpiral::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSpiral*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSpiral_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleSpiral_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSpiral)", obj); } void js_register_cocos2dx_ParticleSpiral(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleSpiral_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleSpiral_class->name = "ParticleSpiral"; jsb_cocos2d_ParticleSpiral_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleSpiral_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleSpiral_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleSpiral_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleSpiral_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleSpiral_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleSpiral_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleSpiral_class->finalize = js_cocos2d_ParticleSpiral_finalize; jsb_cocos2d_ParticleSpiral_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleSpiral_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSpiral_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleSpiral_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleSpiral_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleSpiral", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleSpiral_class; p->proto = jsb_cocos2d_ParticleSpiral_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleExplosion_class; JSObject *jsb_cocos2d_ParticleExplosion_prototype; JSBool js_cocos2dx_ParticleExplosion_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleExplosion* ret = cocos2d::ParticleExplosion::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleExplosion*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleExplosion_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleExplosion_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleExplosion_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleExplosion* ret = cocos2d::ParticleExplosion::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleExplosion*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleExplosion_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleExplosion_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleExplosion)", obj); } void js_register_cocos2dx_ParticleExplosion(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleExplosion_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleExplosion_class->name = "ParticleExplosion"; jsb_cocos2d_ParticleExplosion_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleExplosion_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleExplosion_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleExplosion_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleExplosion_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleExplosion_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleExplosion_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleExplosion_class->finalize = js_cocos2d_ParticleExplosion_finalize; jsb_cocos2d_ParticleExplosion_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleExplosion_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleExplosion_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleExplosion_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleExplosion_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleExplosion", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleExplosion_class; p->proto = jsb_cocos2d_ParticleExplosion_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleSmoke_class; JSObject *jsb_cocos2d_ParticleSmoke_prototype; JSBool js_cocos2dx_ParticleSmoke_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleSmoke* ret = cocos2d::ParticleSmoke::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSmoke*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSmoke_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleSmoke_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSmoke_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleSmoke* ret = cocos2d::ParticleSmoke::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSmoke*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSmoke_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleSmoke_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSmoke)", obj); } void js_register_cocos2dx_ParticleSmoke(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleSmoke_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleSmoke_class->name = "ParticleSmoke"; jsb_cocos2d_ParticleSmoke_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleSmoke_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleSmoke_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleSmoke_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleSmoke_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleSmoke_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleSmoke_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleSmoke_class->finalize = js_cocos2d_ParticleSmoke_finalize; jsb_cocos2d_ParticleSmoke_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleSmoke_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSmoke_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleSmoke_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleSmoke_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleSmoke", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleSmoke_class; p->proto = jsb_cocos2d_ParticleSmoke_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleSnow_class; JSObject *jsb_cocos2d_ParticleSnow_prototype; JSBool js_cocos2dx_ParticleSnow_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleSnow* ret = cocos2d::ParticleSnow::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSnow*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSnow_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleSnow_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleSnow_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleSnow* ret = cocos2d::ParticleSnow::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSnow*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleSnow_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleSnow_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSnow)", obj); } void js_register_cocos2dx_ParticleSnow(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleSnow_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleSnow_class->name = "ParticleSnow"; jsb_cocos2d_ParticleSnow_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleSnow_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleSnow_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleSnow_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleSnow_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleSnow_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleSnow_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleSnow_class->finalize = js_cocos2d_ParticleSnow_finalize; jsb_cocos2d_ParticleSnow_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleSnow_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSnow_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleSnow_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleSnow_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleSnow", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleSnow_class; p->proto = jsb_cocos2d_ParticleSnow_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParticleRain_class; JSObject *jsb_cocos2d_ParticleRain_prototype; JSBool js_cocos2dx_ParticleRain_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParticleRain* ret = cocos2d::ParticleRain::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleRain*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleRain_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParticleRain_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParticleRain_createWithTotalParticles : Error processing arguments"); cocos2d::ParticleRain* ret = cocos2d::ParticleRain::createWithTotalParticles(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParticleRain*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParticleRain_createWithTotalParticles : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; void js_cocos2d_ParticleRain_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParticleRain)", obj); } void js_register_cocos2dx_ParticleRain(JSContext *cx, JSObject *global) { jsb_cocos2d_ParticleRain_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParticleRain_class->name = "ParticleRain"; jsb_cocos2d_ParticleRain_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParticleRain_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParticleRain_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParticleRain_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParticleRain_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParticleRain_class->resolve = JS_ResolveStub; jsb_cocos2d_ParticleRain_class->convert = JS_ConvertStub; jsb_cocos2d_ParticleRain_class->finalize = js_cocos2d_ParticleRain_finalize; jsb_cocos2d_ParticleRain_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParticleRain_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithTotalParticles", js_cocos2dx_ParticleRain_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParticleRain_prototype = JS_InitClass( cx, global, jsb_cocos2d_ParticleSystemQuad_prototype, jsb_cocos2d_ParticleRain_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParticleRain", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParticleRain_class; p->proto = jsb_cocos2d_ParticleRain_prototype; p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_FileUtils_class; JSObject *jsb_cocos2d_FileUtils_prototype; JSBool js_cocos2dx_FileUtils_fullPathForFilename(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_fullPathForFilename : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_fullPathForFilename : Error processing arguments"); std::string ret = cobj->fullPathForFilename(arg0); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_fullPathForFilename : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_getStringFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_getStringFromFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_getStringFromFile : Error processing arguments"); std::string ret = cobj->getStringFromFile(arg0); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_getStringFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_setFilenameLookupDictionary(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_setFilenameLookupDictionary : Invalid Native Object"); if (argc == 1) { cocos2d::ValueMap arg0; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_setFilenameLookupDictionary : Error processing arguments"); cobj->setFilenameLookupDictionary(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_setFilenameLookupDictionary : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_isAbsolutePath(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_isAbsolutePath : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_isAbsolutePath : Error processing arguments"); JSBool ret = cobj->isAbsolutePath(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_isAbsolutePath : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile : Error processing arguments"); cobj->loadFilenameLookupDictionaryFromFile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_isPopupNotify(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_isPopupNotify : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isPopupNotify(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_isPopupNotify : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_getValueVectorFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_getValueVectorFromFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_getValueVectorFromFile : Error processing arguments"); cocos2d::ValueVector ret = cobj->getValueVectorFromFile(arg0); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_getValueVectorFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_writeToFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_writeToFile : Invalid Native Object"); if (argc == 2) { cocos2d::ValueMap arg0; std::string arg1; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_writeToFile : Error processing arguments"); JSBool ret = cobj->writeToFile(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_writeToFile : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_getValueMapFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_getValueMapFromFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_getValueMapFromFile : Error processing arguments"); cocos2d::ValueMap ret = cobj->getValueMapFromFile(arg0); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_getValueMapFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_addSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_addSearchResolutionsOrder : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_addSearchResolutionsOrder : Error processing arguments"); cobj->addSearchResolutionsOrder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_addSearchResolutionsOrder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_addSearchPath : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_addSearchPath : Error processing arguments"); cobj->addSearchPath(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_addSearchPath : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_isFileExist(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_isFileExist : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_isFileExist : Error processing arguments"); JSBool ret = cobj->isFileExist(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_isFileExist : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_purgeCachedEntries(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_purgeCachedEntries : Invalid Native Object"); if (argc == 0) { cobj->purgeCachedEntries(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_purgeCachedEntries : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_fullPathFromRelativeFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_FileUtils_fullPathFromRelativeFile : Invalid Native Object"); if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_FileUtils_fullPathFromRelativeFile : Error processing arguments"); std::string ret = cobj->fullPathFromRelativeFile(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_fullPathFromRelativeFile : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_FileUtils_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::FileUtils* ret = cocos2d::FileUtils::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::FileUtils*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_FileUtils_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_FileUtils_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (FileUtils)", obj); } void js_register_cocos2dx_FileUtils(JSContext *cx, JSObject *global) { jsb_cocos2d_FileUtils_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_FileUtils_class->name = "FileUtils"; jsb_cocos2d_FileUtils_class->addProperty = JS_PropertyStub; jsb_cocos2d_FileUtils_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_FileUtils_class->getProperty = JS_PropertyStub; jsb_cocos2d_FileUtils_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_FileUtils_class->enumerate = JS_EnumerateStub; jsb_cocos2d_FileUtils_class->resolve = JS_ResolveStub; jsb_cocos2d_FileUtils_class->convert = JS_ConvertStub; jsb_cocos2d_FileUtils_class->finalize = js_cocos2d_FileUtils_finalize; jsb_cocos2d_FileUtils_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("fullPathForFilename", js_cocos2dx_FileUtils_fullPathForFilename, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringFromFile", js_cocos2dx_FileUtils_getStringFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFilenameLookupDictionary", js_cocos2dx_FileUtils_setFilenameLookupDictionary, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isAbsolutePath", js_cocos2dx_FileUtils_isAbsolutePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadFilenameLookup", js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPopupNotify", js_cocos2dx_FileUtils_isPopupNotify, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getValueVectorFromFile", js_cocos2dx_FileUtils_getValueVectorFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("writeToFile", js_cocos2dx_FileUtils_writeToFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getValueMapFromFile", js_cocos2dx_FileUtils_getValueMapFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSearchResolutionsOrder", js_cocos2dx_FileUtils_addSearchResolutionsOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSearchPath", js_cocos2dx_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFileExist", js_cocos2dx_FileUtils_isFileExist, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("purgeCachedEntries", js_cocos2dx_FileUtils_purgeCachedEntries, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("fullPathFromRelativeFile", js_cocos2dx_FileUtils_fullPathFromRelativeFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("getInstance", js_cocos2dx_FileUtils_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_FileUtils_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_FileUtils_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "FileUtils", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_FileUtils_class; p->proto = jsb_cocos2d_FileUtils_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_SAXParser_class; JSObject *jsb_cocos2d_SAXParser_prototype; JSBool js_cocos2dx_SAXParser_init(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SAXParser* cobj = (cocos2d::SAXParser *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SAXParser_init : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SAXParser_init : Error processing arguments"); JSBool ret = cobj->init(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SAXParser_init : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } void js_cocos2d_SAXParser_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SAXParser)", obj); } void js_register_cocos2dx_SAXParser(JSContext *cx, JSObject *global) { jsb_cocos2d_SAXParser_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SAXParser_class->name = "SAXParser"; jsb_cocos2d_SAXParser_class->addProperty = JS_PropertyStub; jsb_cocos2d_SAXParser_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_SAXParser_class->getProperty = JS_PropertyStub; jsb_cocos2d_SAXParser_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_SAXParser_class->enumerate = JS_EnumerateStub; jsb_cocos2d_SAXParser_class->resolve = JS_ResolveStub; jsb_cocos2d_SAXParser_class->convert = JS_ConvertStub; jsb_cocos2d_SAXParser_class->finalize = js_cocos2d_SAXParser_finalize; jsb_cocos2d_SAXParser_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("init", js_cocos2dx_SAXParser_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_SAXParser_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_SAXParser_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SAXParser", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_SAXParser_class; p->proto = jsb_cocos2d_SAXParser_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Application_class; JSObject *jsb_cocos2d_Application_prototype; JSBool js_cocos2dx_Application_getTargetPlatform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Application_getTargetPlatform : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getTargetPlatform(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Application_getTargetPlatform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Application_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Application_setAnimationInterval : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Application_setAnimationInterval : Error processing arguments"); cobj->setAnimationInterval(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Application_setAnimationInterval : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Application_getCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Application_getCurrentLanguage : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getCurrentLanguage(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Application_getCurrentLanguage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Application_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Application* ret = cocos2d::Application::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Application*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Application_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_Application_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Application)", obj); } void js_register_cocos2dx_Application(JSContext *cx, JSObject *global) { jsb_cocos2d_Application_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Application_class->name = "Application"; jsb_cocos2d_Application_class->addProperty = JS_PropertyStub; jsb_cocos2d_Application_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Application_class->getProperty = JS_PropertyStub; jsb_cocos2d_Application_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Application_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Application_class->resolve = JS_ResolveStub; jsb_cocos2d_Application_class->convert = JS_ConvertStub; jsb_cocos2d_Application_class->finalize = js_cocos2d_Application_finalize; jsb_cocos2d_Application_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getTargetPlatform", js_cocos2dx_Application_getTargetPlatform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimationInterval", js_cocos2dx_Application_setAnimationInterval, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentLanguage", js_cocos2dx_Application_getCurrentLanguage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("getInstance", js_cocos2dx_Application_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Application_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Application_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Application", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Application_class; p->proto = jsb_cocos2d_Application_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EGLViewProtocol_class; JSObject *jsb_cocos2d_EGLViewProtocol_prototype; JSBool js_cocos2dx_EGLViewProtocol_getVisibleOrigin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EGLViewProtocol* cobj = (cocos2d::EGLViewProtocol *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EGLViewProtocol_getVisibleOrigin : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getVisibleOrigin(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EGLViewProtocol_getVisibleOrigin : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_EGLViewProtocol_getVisibleSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EGLViewProtocol* cobj = (cocos2d::EGLViewProtocol *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EGLViewProtocol_getVisibleSize : Invalid Native Object"); if (argc == 0) { cocos2d::Size ret = cobj->getVisibleSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EGLViewProtocol_getVisibleSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_EGLViewProtocol_setDesignResolutionSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EGLViewProtocol* cobj = (cocos2d::EGLViewProtocol *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EGLViewProtocol_setDesignResolutionSize : Invalid Native Object"); if (argc == 3) { double arg0; double arg1; ResolutionPolicy arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EGLViewProtocol_setDesignResolutionSize : Error processing arguments"); cobj->setDesignResolutionSize(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EGLViewProtocol_setDesignResolutionSize : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } void js_cocos2d_EGLViewProtocol_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EGLViewProtocol)", obj); } void js_register_cocos2dx_EGLViewProtocol(JSContext *cx, JSObject *global) { jsb_cocos2d_EGLViewProtocol_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EGLViewProtocol_class->name = "EGLViewProtocol"; jsb_cocos2d_EGLViewProtocol_class->addProperty = JS_PropertyStub; jsb_cocos2d_EGLViewProtocol_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EGLViewProtocol_class->getProperty = JS_PropertyStub; jsb_cocos2d_EGLViewProtocol_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EGLViewProtocol_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EGLViewProtocol_class->resolve = JS_ResolveStub; jsb_cocos2d_EGLViewProtocol_class->convert = JS_ConvertStub; jsb_cocos2d_EGLViewProtocol_class->finalize = js_cocos2d_EGLViewProtocol_finalize; jsb_cocos2d_EGLViewProtocol_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getVisibleOrigin", js_cocos2dx_EGLViewProtocol_getVisibleOrigin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVisibleSize", js_cocos2dx_EGLViewProtocol_getVisibleSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDesignResolutionSize", js_cocos2dx_EGLViewProtocol_setDesignResolutionSize, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_EGLViewProtocol_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_EGLViewProtocol_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EGLViewProtocol", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EGLViewProtocol_class; p->proto = jsb_cocos2d_EGLViewProtocol_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_EGLView_class; JSObject *jsb_cocos2d_EGLView_prototype; JSBool js_cocos2dx_EGLView_setIMEKeyboardState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EGLView* cobj = (cocos2d::EGLView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EGLView_setIMEKeyboardState : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_EGLView_setIMEKeyboardState : Error processing arguments"); cobj->setIMEKeyboardState(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EGLView_setIMEKeyboardState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_EGLView_isOpenGLReady(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::EGLView* cobj = (cocos2d::EGLView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_EGLView_isOpenGLReady : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isOpenGLReady(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EGLView_isOpenGLReady : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_EGLView_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::EGLView* ret = cocos2d::EGLView::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::EGLView*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_EGLView_getInstance : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_EGLViewProtocol_prototype; void js_cocos2d_EGLView_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EGLView)", obj); } void js_register_cocos2dx_EGLView(JSContext *cx, JSObject *global) { jsb_cocos2d_EGLView_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_EGLView_class->name = "EGLView"; jsb_cocos2d_EGLView_class->addProperty = JS_PropertyStub; jsb_cocos2d_EGLView_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_EGLView_class->getProperty = JS_PropertyStub; jsb_cocos2d_EGLView_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_EGLView_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EGLView_class->resolve = JS_ResolveStub; jsb_cocos2d_EGLView_class->convert = JS_ConvertStub; jsb_cocos2d_EGLView_class->finalize = js_cocos2d_EGLView_finalize; jsb_cocos2d_EGLView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setIMEKeyboardState", js_cocos2dx_EGLView_setIMEKeyboardState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isOpenGLReady", js_cocos2dx_EGLView_isOpenGLReady, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("getInstance", js_cocos2dx_EGLView_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_EGLView_prototype = JS_InitClass( cx, global, jsb_cocos2d_EGLViewProtocol_prototype, jsb_cocos2d_EGLView_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EGLView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_EGLView_class; p->proto = jsb_cocos2d_EGLView_prototype; p->parentProto = jsb_cocos2d_EGLViewProtocol_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ShaderCache_class; JSObject *jsb_cocos2d_ShaderCache_prototype; JSBool js_cocos2dx_ShaderCache_reloadDefaultShaders(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ShaderCache* cobj = (cocos2d::ShaderCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ShaderCache_reloadDefaultShaders : Invalid Native Object"); if (argc == 0) { cobj->reloadDefaultShaders(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShaderCache_reloadDefaultShaders : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ShaderCache_addProgram(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ShaderCache* cobj = (cocos2d::ShaderCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ShaderCache_addProgram : Invalid Native Object"); if (argc == 2) { cocos2d::GLProgram* arg0; std::string arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GLProgram*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ShaderCache_addProgram : Error processing arguments"); cobj->addProgram(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShaderCache_addProgram : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ShaderCache_getProgram(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ShaderCache* cobj = (cocos2d::ShaderCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ShaderCache_getProgram : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ShaderCache_getProgram : Error processing arguments"); cocos2d::GLProgram* ret = cobj->getProgram(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::GLProgram*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShaderCache_getProgram : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ShaderCache_loadDefaultShaders(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ShaderCache* cobj = (cocos2d::ShaderCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ShaderCache_loadDefaultShaders : Invalid Native Object"); if (argc == 0) { cobj->loadDefaultShaders(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShaderCache_loadDefaultShaders : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_ShaderCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ShaderCache::destroyInstance(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShaderCache_destroyInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ShaderCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ShaderCache* ret = cocos2d::ShaderCache::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ShaderCache*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShaderCache_getInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ShaderCache_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ShaderCache* cobj = new cocos2d::ShaderCache(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::ShaderCache"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ShaderCache_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_ShaderCache_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ShaderCache)", obj); } void js_register_cocos2dx_ShaderCache(JSContext *cx, JSObject *global) { jsb_cocos2d_ShaderCache_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ShaderCache_class->name = "ShaderCache"; jsb_cocos2d_ShaderCache_class->addProperty = JS_PropertyStub; jsb_cocos2d_ShaderCache_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ShaderCache_class->getProperty = JS_PropertyStub; jsb_cocos2d_ShaderCache_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ShaderCache_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ShaderCache_class->resolve = JS_ResolveStub; jsb_cocos2d_ShaderCache_class->convert = JS_ConvertStub; jsb_cocos2d_ShaderCache_class->finalize = js_cocos2d_ShaderCache_finalize; jsb_cocos2d_ShaderCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("reloadDefaultShaders", js_cocos2dx_ShaderCache_reloadDefaultShaders, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addProgram", js_cocos2dx_ShaderCache_addProgram, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProgram", js_cocos2dx_ShaderCache_getProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadDefaultShaders", js_cocos2dx_ShaderCache_loadDefaultShaders, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("destroyInstance", js_cocos2dx_ShaderCache_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_cocos2dx_ShaderCache_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ShaderCache_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_ShaderCache_class, js_cocos2dx_ShaderCache_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ShaderCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ShaderCache_class; p->proto = jsb_cocos2d_ShaderCache_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_AnimationCache_class; JSObject *jsb_cocos2d_AnimationCache_prototype; JSBool js_cocos2dx_AnimationCache_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationCache_getAnimation : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationCache_getAnimation : Error processing arguments"); cocos2d::Animation* ret = cobj->getAnimation(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_getAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AnimationCache_addAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationCache_addAnimation : Invalid Native Object"); if (argc == 2) { cocos2d::Animation* arg0; std::string arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Animation*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationCache_addAnimation : Error processing arguments"); cobj->addAnimation(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_addAnimation : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_AnimationCache_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationCache_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_AnimationCache_addAnimationsWithDictionary(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationCache_addAnimationsWithDictionary : Invalid Native Object"); if (argc == 2) { cocos2d::ValueMap arg0; std::string arg1; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationCache_addAnimationsWithDictionary : Error processing arguments"); cobj->addAnimationsWithDictionary(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_addAnimationsWithDictionary : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_AnimationCache_removeAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationCache_removeAnimation : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationCache_removeAnimation : Error processing arguments"); cobj->removeAnimation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_removeAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AnimationCache_addAnimationsWithFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_AnimationCache_addAnimationsWithFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_AnimationCache_addAnimationsWithFile : Error processing arguments"); cobj->addAnimationsWithFile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_addAnimationsWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_AnimationCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::AnimationCache::destroyInstance(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_destroyInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_AnimationCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::AnimationCache* ret = cocos2d::AnimationCache::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::AnimationCache*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_getInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_AnimationCache_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::AnimationCache* cobj = new cocos2d::AnimationCache(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::AnimationCache"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_AnimationCache_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_AnimationCache_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (AnimationCache)", obj); } void js_register_cocos2dx_AnimationCache(JSContext *cx, JSObject *global) { jsb_cocos2d_AnimationCache_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_AnimationCache_class->name = "AnimationCache"; jsb_cocos2d_AnimationCache_class->addProperty = JS_PropertyStub; jsb_cocos2d_AnimationCache_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_AnimationCache_class->getProperty = JS_PropertyStub; jsb_cocos2d_AnimationCache_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_AnimationCache_class->enumerate = JS_EnumerateStub; jsb_cocos2d_AnimationCache_class->resolve = JS_ResolveStub; jsb_cocos2d_AnimationCache_class->convert = JS_ConvertStub; jsb_cocos2d_AnimationCache_class->finalize = js_cocos2d_AnimationCache_finalize; jsb_cocos2d_AnimationCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAnimation", js_cocos2dx_AnimationCache_getAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addAnimation", js_cocos2dx_AnimationCache_addAnimation, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_AnimationCache_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addAnimationsWithDictionary", js_cocos2dx_AnimationCache_addAnimationsWithDictionary, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAnimation", js_cocos2dx_AnimationCache_removeAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addAnimations", js_cocos2dx_AnimationCache_addAnimationsWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("destroyInstance", js_cocos2dx_AnimationCache_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_cocos2dx_AnimationCache_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_AnimationCache_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_AnimationCache_class, js_cocos2dx_AnimationCache_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "AnimationCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_AnimationCache_class; p->proto = jsb_cocos2d_AnimationCache_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_SpriteFrameCache_class; JSObject *jsb_cocos2d_SpriteFrameCache_prototype; JSBool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::SpriteFrameCache* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile : Invalid Native Object"); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj->addSpriteFramesWithFile(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->addSpriteFramesWithFile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj->addSpriteFramesWithFile(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_addSpriteFrame : Invalid Native Object"); if (argc == 2) { cocos2d::SpriteFrame* arg0; std::string arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_addSpriteFrame : Error processing arguments"); cobj->addSpriteFrame(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_addSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames : Invalid Native Object"); if (argc == 0) { cobj->removeUnusedSpriteFrames(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_getSpriteFrameByName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_getSpriteFrameByName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_getSpriteFrameByName : Error processing arguments"); cocos2d::SpriteFrame* ret = cobj->getSpriteFrameByName(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_getSpriteFrameByName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile : Error processing arguments"); cobj->removeSpriteFramesFromFile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_removeSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_removeSpriteFrames : Invalid Native Object"); if (argc == 0) { cobj->removeSpriteFrames(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFrames : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture : Invalid Native Object"); if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture : Error processing arguments"); cobj->removeSpriteFramesFromTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName : Error processing arguments"); cobj->removeSpriteFrameByName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::SpriteFrameCache::destroyInstance(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_destroyInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SpriteFrameCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::SpriteFrameCache* ret = cocos2d::SpriteFrameCache::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrameCache*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_SpriteFrameCache_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SpriteFrameCache)", obj); } void js_register_cocos2dx_SpriteFrameCache(JSContext *cx, JSObject *global) { jsb_cocos2d_SpriteFrameCache_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_SpriteFrameCache_class->name = "SpriteFrameCache"; jsb_cocos2d_SpriteFrameCache_class->addProperty = JS_PropertyStub; jsb_cocos2d_SpriteFrameCache_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_SpriteFrameCache_class->getProperty = JS_PropertyStub; jsb_cocos2d_SpriteFrameCache_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_SpriteFrameCache_class->enumerate = JS_EnumerateStub; jsb_cocos2d_SpriteFrameCache_class->resolve = JS_ResolveStub; jsb_cocos2d_SpriteFrameCache_class->convert = JS_ConvertStub; jsb_cocos2d_SpriteFrameCache_class->finalize = js_cocos2d_SpriteFrameCache_finalize; jsb_cocos2d_SpriteFrameCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("addSpriteFrames", js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSpriteFrame", js_cocos2dx_SpriteFrameCache_addSpriteFrame, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeUnusedSpriteFrames", js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpriteFrame", js_cocos2dx_SpriteFrameCache_getSpriteFrameByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeSpriteFramesFromFile", js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_SpriteFrameCache_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeSpriteFrames", js_cocos2dx_SpriteFrameCache_removeSpriteFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeSpriteFramesFromTexture", js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeSpriteFrameByName", js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("destroyInstance", js_cocos2dx_SpriteFrameCache_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_cocos2dx_SpriteFrameCache_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_SpriteFrameCache_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_SpriteFrameCache_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SpriteFrameCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_SpriteFrameCache_class; p->proto = jsb_cocos2d_SpriteFrameCache_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TextFieldTTF_class; JSObject *jsb_cocos2d_TextFieldTTF_prototype; JSBool js_cocos2dx_TextFieldTTF_getCharCount(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_getCharCount : Invalid Native Object"); if (argc == 0) { int ret = cobj->getCharCount(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_getCharCount : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_getDelegate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_getDelegate : Invalid Native Object"); if (argc == 0) { cocos2d::TextFieldDelegate* ret = cobj->getDelegate(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TextFieldDelegate*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_getDelegate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_setSecureTextEntry(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_setSecureTextEntry : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_setSecureTextEntry : Error processing arguments"); cobj->setSecureTextEntry(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_setSecureTextEntry : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_getColorSpaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_getColorSpaceHolder : Invalid Native Object"); if (argc == 0) { const cocos2d::Color3B& ret = cobj->getColorSpaceHolder(); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_getColorSpaceHolder : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_initWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TextFieldTTF* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_initWithPlaceHolder : Invalid Native Object"); do { if (argc == 3) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithPlaceHolder(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } std::string arg3; ok &= jsval_to_std_string(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } double arg4; ok &= JS_ValueToNumber(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithPlaceHolder(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_initWithPlaceHolder : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_setColorSpaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_setColorSpaceHolder : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_setColorSpaceHolder : Error processing arguments"); cobj->setColorSpaceHolder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_setColorSpaceHolder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_detachWithIME(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_detachWithIME : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->detachWithIME(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_detachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_setDelegate : Invalid Native Object"); if (argc == 1) { cocos2d::TextFieldDelegate* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TextFieldDelegate*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_setDelegate : Error processing arguments"); cobj->setDelegate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_setDelegate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_setPlaceHolder : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_setPlaceHolder : Error processing arguments"); cobj->setPlaceHolder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_setPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_isSecureTextEntry(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_isSecureTextEntry : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isSecureTextEntry(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_isSecureTextEntry : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_getPlaceHolder : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getPlaceHolder(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_getPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_attachWithIME(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextFieldTTF_attachWithIME : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->attachWithIME(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_attachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextFieldTTF* ret = cocos2d::TextFieldTTF::textFieldWithPlaceHolder(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TextFieldTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 5) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextHAlignment arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } std::string arg3; ok &= jsval_to_std_string(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } double arg4; ok &= JS_ValueToNumber(cx, argv[4], &arg4); if (!ok) { ok = JS_TRUE; break; } cocos2d::TextFieldTTF* ret = cocos2d::TextFieldTTF::textFieldWithPlaceHolder(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TextFieldTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TextFieldTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TextFieldTTF* cobj = new cocos2d::TextFieldTTF(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TextFieldTTF"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_LabelTTF_prototype; void js_cocos2d_TextFieldTTF_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TextFieldTTF)", obj); } void js_register_cocos2dx_TextFieldTTF(JSContext *cx, JSObject *global) { jsb_cocos2d_TextFieldTTF_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TextFieldTTF_class->name = "TextFieldTTF"; jsb_cocos2d_TextFieldTTF_class->addProperty = JS_PropertyStub; jsb_cocos2d_TextFieldTTF_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TextFieldTTF_class->getProperty = JS_PropertyStub; jsb_cocos2d_TextFieldTTF_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TextFieldTTF_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TextFieldTTF_class->resolve = JS_ResolveStub; jsb_cocos2d_TextFieldTTF_class->convert = JS_ConvertStub; jsb_cocos2d_TextFieldTTF_class->finalize = js_cocos2d_TextFieldTTF_finalize; jsb_cocos2d_TextFieldTTF_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getCharCount", js_cocos2dx_TextFieldTTF_getCharCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDelegate", js_cocos2dx_TextFieldTTF_getDelegate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSecureTextEntry", js_cocos2dx_TextFieldTTF_setSecureTextEntry, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getColorSpaceHolder", js_cocos2dx_TextFieldTTF_getColorSpaceHolder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithPlaceHolder", js_cocos2dx_TextFieldTTF_initWithPlaceHolder, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setColorSpaceHolder", js_cocos2dx_TextFieldTTF_setColorSpaceHolder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("detachWithIME", js_cocos2dx_TextFieldTTF_detachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDelegate", js_cocos2dx_TextFieldTTF_setDelegate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlaceHolder", js_cocos2dx_TextFieldTTF_setPlaceHolder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSecureTextEntry", js_cocos2dx_TextFieldTTF_isSecureTextEntry, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPlaceHolder", js_cocos2dx_TextFieldTTF_getPlaceHolder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("attachWithIME", js_cocos2dx_TextFieldTTF_attachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("textFieldWithPlaceHolder", js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TextFieldTTF_prototype = JS_InitClass( cx, global, jsb_cocos2d_LabelTTF_prototype, jsb_cocos2d_TextFieldTTF_class, js_cocos2dx_TextFieldTTF_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TextFieldTTF", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TextFieldTTF_class; p->proto = jsb_cocos2d_TextFieldTTF_prototype; p->parentProto = jsb_cocos2d_LabelTTF_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TextureCache_class; JSObject *jsb_cocos2d_TextureCache_prototype; JSBool js_cocos2dx_TextureCache_removeTextureForKey(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_removeTextureForKey : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TextureCache_removeTextureForKey : Error processing arguments"); cobj->removeTextureForKey(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_removeTextureForKey : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_removeAllTextures(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_removeAllTextures : Invalid Native Object"); if (argc == 0) { cobj->removeAllTextures(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_removeAllTextures : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_getDescription(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_getDescription : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getDescription(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_getDescription : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_getCachedTextureInfo(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_getCachedTextureInfo : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getCachedTextureInfo(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_getCachedTextureInfo : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TextureCache* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_addImage : Invalid Native Object"); do { if (argc == 2) { cocos2d::Image* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Image*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* ret = cobj->addImage(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Texture2D* ret = cobj->addImage(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TextureCache_addImage : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_getTextureForKey(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_getTextureForKey : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TextureCache_getTextureForKey : Error processing arguments"); cocos2d::Texture2D* ret = cobj->getTextureForKey(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_getTextureForKey : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_removeUnusedTextures(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_removeUnusedTextures : Invalid Native Object"); if (argc == 0) { cobj->removeUnusedTextures(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_removeUnusedTextures : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_removeTexture : Invalid Native Object"); if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Texture2D*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TextureCache_removeTexture : Error processing arguments"); cobj->removeTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_removeTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_waitForQuit(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TextureCache_waitForQuit : Invalid Native Object"); if (argc == 0) { cobj->waitForQuit(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_waitForQuit : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TextureCache_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TextureCache* cobj = new cocos2d::TextureCache(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TextureCache"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TextureCache_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_TextureCache_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TextureCache)", obj); } void js_register_cocos2dx_TextureCache(JSContext *cx, JSObject *global) { jsb_cocos2d_TextureCache_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TextureCache_class->name = "TextureCache"; jsb_cocos2d_TextureCache_class->addProperty = JS_PropertyStub; jsb_cocos2d_TextureCache_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TextureCache_class->getProperty = JS_PropertyStub; jsb_cocos2d_TextureCache_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TextureCache_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TextureCache_class->resolve = JS_ResolveStub; jsb_cocos2d_TextureCache_class->convert = JS_ConvertStub; jsb_cocos2d_TextureCache_class->finalize = js_cocos2d_TextureCache_finalize; jsb_cocos2d_TextureCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("removeTextureForKey", js_cocos2dx_TextureCache_removeTextureForKey, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllTextures", js_cocos2dx_TextureCache_removeAllTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDescription", js_cocos2dx_TextureCache_getDescription, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCachedTextureInfo", js_cocos2dx_TextureCache_getCachedTextureInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addImage", js_cocos2dx_TextureCache_addImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureForKey", js_cocos2dx_TextureCache_getTextureForKey, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeUnusedTextures", js_cocos2dx_TextureCache_removeUnusedTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeTexture", js_cocos2dx_TextureCache_removeTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("waitForQuit", js_cocos2dx_TextureCache_waitForQuit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_TextureCache_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_TextureCache_class, js_cocos2dx_TextureCache_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TextureCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TextureCache_class; p->proto = jsb_cocos2d_TextureCache_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_ParallaxNode_class; JSObject *jsb_cocos2d_ParallaxNode_prototype; JSBool js_cocos2dx_ParallaxNode_getParallaxArray(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::ParallaxNode* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParallaxNode_getParallaxArray : Invalid Native Object"); do { if (argc == 0) { const cocos2d::_ccArray* ret = cobj->getParallaxArray(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR _ccArray*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { cocos2d::_ccArray* ret = cobj->getParallaxArray(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR _ccArray*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_ParallaxNode_getParallaxArray : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_ParallaxNode_addChild(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParallaxNode* cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParallaxNode_addChild : Invalid Native Object"); if (argc == 4) { cocos2d::Node* arg0; int arg1; cocos2d::Point arg2; cocos2d::Point arg3; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); ok &= jsval_to_ccpoint(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParallaxNode_addChild : Error processing arguments"); cobj->addChild(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParallaxNode_addChild : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParallaxNode* cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup : Error processing arguments"); cobj->removeAllChildrenWithCleanup(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParallaxNode_setParallaxArray(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ParallaxNode* cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_ParallaxNode_setParallaxArray : Invalid Native Object"); if (argc == 1) { cocos2d::_ccArray* arg0; #pragma warning NO CONVERSION TO NATIVE FOR _ccArray*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_ParallaxNode_setParallaxArray : Error processing arguments"); cobj->setParallaxArray(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParallaxNode_setParallaxArray : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ParallaxNode_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::ParallaxNode* ret = cocos2d::ParallaxNode::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ParallaxNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_ParallaxNode_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_ParallaxNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ParallaxNode)", obj); } void js_register_cocos2dx_ParallaxNode(JSContext *cx, JSObject *global) { jsb_cocos2d_ParallaxNode_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ParallaxNode_class->name = "ParallaxNode"; jsb_cocos2d_ParallaxNode_class->addProperty = JS_PropertyStub; jsb_cocos2d_ParallaxNode_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_ParallaxNode_class->getProperty = JS_PropertyStub; jsb_cocos2d_ParallaxNode_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_ParallaxNode_class->enumerate = JS_EnumerateStub; jsb_cocos2d_ParallaxNode_class->resolve = JS_ResolveStub; jsb_cocos2d_ParallaxNode_class->convert = JS_ConvertStub; jsb_cocos2d_ParallaxNode_class->finalize = js_cocos2d_ParallaxNode_finalize; jsb_cocos2d_ParallaxNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getParallaxArray", js_cocos2dx_ParallaxNode_getParallaxArray, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addChild", js_cocos2dx_ParallaxNode_addChild, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllChildrenWithCleanup", js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setParallaxArray", js_cocos2dx_ParallaxNode_setParallaxArray, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_ParallaxNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_ParallaxNode_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_ParallaxNode_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ParallaxNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_ParallaxNode_class; p->proto = jsb_cocos2d_ParallaxNode_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TMXObjectGroup_class; JSObject *jsb_cocos2d_TMXObjectGroup_prototype; JSBool js_cocos2dx_TMXObjectGroup_setPositionOffset(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_setPositionOffset : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_setPositionOffset : Error processing arguments"); cobj->setPositionOffset(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_setPositionOffset : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_getProperty(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_getProperty : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_getProperty : Error processing arguments"); cocos2d::Value ret = cobj->getProperty(arg0); jsval jsret = JSVAL_NULL; jsret = ccvalue_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getProperty : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_getPositionOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_getPositionOffset : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getPositionOffset(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getPositionOffset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_getObject(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_getObject : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_getObject : Error processing arguments"); cocos2d::ValueMap ret = cobj->getObject(arg0); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getObject : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_getObjects(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXObjectGroup* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_getObjects : Invalid Native Object"); do { if (argc == 0) { cocos2d::ValueVector& ret = cobj->getObjects(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::ValueVector& ret = cobj->getObjects(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getObjects : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_setGroupName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_setGroupName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_setGroupName : Error processing arguments"); cobj->setGroupName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_setGroupName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_getProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXObjectGroup* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_getProperties : Invalid Native Object"); do { if (argc == 0) { cocos2d::ValueMap& ret = cobj->getProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::ValueMap& ret = cobj->getProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getProperties : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_getGroupName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_getGroupName : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getGroupName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getGroupName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_setProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_setProperties : Invalid Native Object"); if (argc == 1) { cocos2d::ValueMap arg0; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_setProperties : Error processing arguments"); cobj->setProperties(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_setObjects(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_setObjects : Invalid Native Object"); if (argc == 1) { cocos2d::ValueVector arg0; ok &= jsval_to_ccvaluevector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXObjectGroup_setObjects : Error processing arguments"); cobj->setObjects(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_setObjects : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXObjectGroup_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TMXObjectGroup* cobj = new cocos2d::TMXObjectGroup(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXObjectGroup"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_TMXObjectGroup_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TMXObjectGroup)", obj); } void js_register_cocos2dx_TMXObjectGroup(JSContext *cx, JSObject *global) { jsb_cocos2d_TMXObjectGroup_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TMXObjectGroup_class->name = "TMXObjectGroup"; jsb_cocos2d_TMXObjectGroup_class->addProperty = JS_PropertyStub; jsb_cocos2d_TMXObjectGroup_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TMXObjectGroup_class->getProperty = JS_PropertyStub; jsb_cocos2d_TMXObjectGroup_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TMXObjectGroup_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TMXObjectGroup_class->resolve = JS_ResolveStub; jsb_cocos2d_TMXObjectGroup_class->convert = JS_ConvertStub; jsb_cocos2d_TMXObjectGroup_class->finalize = js_cocos2d_TMXObjectGroup_finalize; jsb_cocos2d_TMXObjectGroup_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setPositionOffset", js_cocos2dx_TMXObjectGroup_setPositionOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProperty", js_cocos2dx_TMXObjectGroup_getProperty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionOffset", js_cocos2dx_TMXObjectGroup_getPositionOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getObject", js_cocos2dx_TMXObjectGroup_getObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getObjects", js_cocos2dx_TMXObjectGroup_getObjects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGroupName", js_cocos2dx_TMXObjectGroup_setGroupName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProperties", js_cocos2dx_TMXObjectGroup_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGroupName", js_cocos2dx_TMXObjectGroup_getGroupName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProperties", js_cocos2dx_TMXObjectGroup_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setObjects", js_cocos2dx_TMXObjectGroup_setObjects, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_TMXObjectGroup_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_TMXObjectGroup_class, js_cocos2dx_TMXObjectGroup_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TMXObjectGroup", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TMXObjectGroup_class; p->proto = jsb_cocos2d_TMXObjectGroup_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TMXLayerInfo_class; JSObject *jsb_cocos2d_TMXLayerInfo_prototype; JSBool js_cocos2dx_TMXLayerInfo_setProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayerInfo* cobj = (cocos2d::TMXLayerInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayerInfo_setProperties : Invalid Native Object"); if (argc == 1) { cocos2d::ValueMap arg0; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayerInfo_setProperties : Error processing arguments"); cobj->setProperties(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayerInfo_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayerInfo_getProperties(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayerInfo* cobj = (cocos2d::TMXLayerInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayerInfo_getProperties : Invalid Native Object"); if (argc == 0) { cocos2d::ValueMap& ret = cobj->getProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayerInfo_getProperties : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXLayerInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TMXLayerInfo* cobj = new cocos2d::TMXLayerInfo(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXLayerInfo"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayerInfo_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_TMXLayerInfo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TMXLayerInfo)", obj); } void js_register_cocos2dx_TMXLayerInfo(JSContext *cx, JSObject *global) { jsb_cocos2d_TMXLayerInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TMXLayerInfo_class->name = "TMXLayerInfo"; jsb_cocos2d_TMXLayerInfo_class->addProperty = JS_PropertyStub; jsb_cocos2d_TMXLayerInfo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TMXLayerInfo_class->getProperty = JS_PropertyStub; jsb_cocos2d_TMXLayerInfo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TMXLayerInfo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TMXLayerInfo_class->resolve = JS_ResolveStub; jsb_cocos2d_TMXLayerInfo_class->convert = JS_ConvertStub; jsb_cocos2d_TMXLayerInfo_class->finalize = js_cocos2d_TMXLayerInfo_finalize; jsb_cocos2d_TMXLayerInfo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setProperties", js_cocos2dx_TMXLayerInfo_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProperties", js_cocos2dx_TMXLayerInfo_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_TMXLayerInfo_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_TMXLayerInfo_class, js_cocos2dx_TMXLayerInfo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TMXLayerInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TMXLayerInfo_class; p->proto = jsb_cocos2d_TMXLayerInfo_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TMXTilesetInfo_class; JSObject *jsb_cocos2d_TMXTilesetInfo_prototype; JSBool js_cocos2dx_TMXTilesetInfo_rectForGID(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTilesetInfo* cobj = (cocos2d::TMXTilesetInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTilesetInfo_rectForGID : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTilesetInfo_rectForGID : Error processing arguments"); cocos2d::Rect ret = cobj->rectForGID(arg0); jsval jsret = JSVAL_NULL; jsret = ccrect_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTilesetInfo_rectForGID : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTilesetInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TMXTilesetInfo* cobj = new cocos2d::TMXTilesetInfo(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXTilesetInfo"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTilesetInfo_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_TMXTilesetInfo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TMXTilesetInfo)", obj); } void js_register_cocos2dx_TMXTilesetInfo(JSContext *cx, JSObject *global) { jsb_cocos2d_TMXTilesetInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TMXTilesetInfo_class->name = "TMXTilesetInfo"; jsb_cocos2d_TMXTilesetInfo_class->addProperty = JS_PropertyStub; jsb_cocos2d_TMXTilesetInfo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TMXTilesetInfo_class->getProperty = JS_PropertyStub; jsb_cocos2d_TMXTilesetInfo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TMXTilesetInfo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TMXTilesetInfo_class->resolve = JS_ResolveStub; jsb_cocos2d_TMXTilesetInfo_class->convert = JS_ConvertStub; jsb_cocos2d_TMXTilesetInfo_class->finalize = js_cocos2d_TMXTilesetInfo_finalize; jsb_cocos2d_TMXTilesetInfo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("rectForGID", js_cocos2dx_TMXTilesetInfo_rectForGID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_TMXTilesetInfo_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_TMXTilesetInfo_class, js_cocos2dx_TMXTilesetInfo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TMXTilesetInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TMXTilesetInfo_class; p->proto = jsb_cocos2d_TMXTilesetInfo_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TMXMapInfo_class; JSObject *jsb_cocos2d_TMXMapInfo_prototype; JSBool js_cocos2dx_TMXMapInfo_setObjectGroups(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setObjectGroups : Invalid Native Object"); if (argc == 1) { cocos2d::Vector arg0; ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setObjectGroups : Error processing arguments"); cobj->setObjectGroups(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setObjectGroups : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setTileSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setTileSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setTileSize : Error processing arguments"); cobj->setTileSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setTileSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_initWithTMXFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_initWithTMXFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_initWithTMXFile : Error processing arguments"); JSBool ret = cobj->initWithTMXFile(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_initWithTMXFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getOrientation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getOrientation : Invalid Native Object"); if (argc == 0) { int ret = cobj->getOrientation(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getOrientation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_isStoringCharacters(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_isStoringCharacters : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isStoringCharacters(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_isStoringCharacters : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setLayers(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setLayers : Invalid Native Object"); if (argc == 1) { cocos2d::Vector arg0; ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setLayers : Error processing arguments"); cobj->setLayers(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setLayers : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_parseXMLFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_parseXMLFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_parseXMLFile : Error processing arguments"); JSBool ret = cobj->parseXMLFile(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_parseXMLFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getParentElement(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getParentElement : Invalid Native Object"); if (argc == 0) { int ret = cobj->getParentElement(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getParentElement : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setTMXFileName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setTMXFileName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setTMXFileName : Error processing arguments"); cobj->setTMXFileName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setTMXFileName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_parseXMLString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_parseXMLString : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_parseXMLString : Error processing arguments"); JSBool ret = cobj->parseXMLString(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_parseXMLString : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getLayers(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXMapInfo* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getLayers : Invalid Native Object"); do { if (argc == 0) { cocos2d::Vector& ret = cobj->getLayers(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::Vector& ret = cobj->getLayers(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getLayers : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getTilesets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXMapInfo* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getTilesets : Invalid Native Object"); do { if (argc == 0) { cocos2d::Vector& ret = cobj->getTilesets(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::Vector& ret = cobj->getTilesets(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getTilesets : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getParentGID(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getParentGID : Invalid Native Object"); if (argc == 0) { int ret = cobj->getParentGID(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getParentGID : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setParentElement(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setParentElement : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setParentElement : Error processing arguments"); cobj->setParentElement(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setParentElement : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_initWithXML(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_initWithXML : Invalid Native Object"); if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_initWithXML : Error processing arguments"); JSBool ret = cobj->initWithXML(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_initWithXML : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setParentGID(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setParentGID : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setParentGID : Error processing arguments"); cobj->setParentGID(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setParentGID : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getLayerAttribs(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getLayerAttribs : Invalid Native Object"); if (argc == 0) { int ret = cobj->getLayerAttribs(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getLayerAttribs : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getTileSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getTileSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getTileSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getTileSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getTileProperties(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getTileProperties : Invalid Native Object"); if (argc == 0) { cocos2d::ValueMapIntKey& ret = cobj->getTileProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemapintkey_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getTileProperties : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXMapInfo* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getObjectGroups : Invalid Native Object"); do { if (argc == 0) { cocos2d::Vector& ret = cobj->getObjectGroups(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::Vector& ret = cobj->getObjectGroups(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getObjectGroups : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getTMXFileName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getTMXFileName : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getTMXFileName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getTMXFileName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setCurrentString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setCurrentString : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setCurrentString : Error processing arguments"); cobj->setCurrentString(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setCurrentString : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setProperties : Invalid Native Object"); if (argc == 1) { cocos2d::ValueMap arg0; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setProperties : Error processing arguments"); cobj->setProperties(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setOrientation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setOrientation : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setOrientation : Error processing arguments"); cobj->setOrientation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setOrientation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setTileProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setTileProperties : Invalid Native Object"); if (argc == 1) { cocos2d::ValueMapIntKey arg0; ok &= jsval_to_ccvaluemapintkey(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setTileProperties : Error processing arguments"); cobj->setTileProperties(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setTileProperties : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setMapSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setMapSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setMapSize : Error processing arguments"); cobj->setMapSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setMapSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setStoringCharacters(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setStoringCharacters : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setStoringCharacters : Error processing arguments"); cobj->setStoringCharacters(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setStoringCharacters : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getMapSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getMapSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getMapSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getMapSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setTilesets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setTilesets : Invalid Native Object"); if (argc == 1) { cocos2d::Vector arg0; ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setTilesets : Error processing arguments"); cobj->setTilesets(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setTilesets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXMapInfo* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getProperties : Invalid Native Object"); do { if (argc == 0) { cocos2d::ValueMap& ret = cobj->getProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::ValueMap& ret = cobj->getProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getProperties : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_getCurrentString(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_getCurrentString : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getCurrentString(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getCurrentString : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_setLayerAttribs(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setLayerAttribs : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_setLayerAttribs : Error processing arguments"); cobj->setLayerAttribs(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setLayerAttribs : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_create : Error processing arguments"); cocos2d::TMXMapInfo* ret = cocos2d::TMXMapInfo::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TMXMapInfo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_createWithXML(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXMapInfo_createWithXML : Error processing arguments"); cocos2d::TMXMapInfo* ret = cocos2d::TMXMapInfo::createWithXML(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TMXMapInfo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_createWithXML : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXMapInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TMXMapInfo* cobj = new cocos2d::TMXMapInfo(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXMapInfo"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_TMXMapInfo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TMXMapInfo)", obj); } void js_register_cocos2dx_TMXMapInfo(JSContext *cx, JSObject *global) { jsb_cocos2d_TMXMapInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TMXMapInfo_class->name = "TMXMapInfo"; jsb_cocos2d_TMXMapInfo_class->addProperty = JS_PropertyStub; jsb_cocos2d_TMXMapInfo_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TMXMapInfo_class->getProperty = JS_PropertyStub; jsb_cocos2d_TMXMapInfo_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TMXMapInfo_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TMXMapInfo_class->resolve = JS_ResolveStub; jsb_cocos2d_TMXMapInfo_class->convert = JS_ConvertStub; jsb_cocos2d_TMXMapInfo_class->finalize = js_cocos2d_TMXMapInfo_finalize; jsb_cocos2d_TMXMapInfo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setObjectGroups", js_cocos2dx_TMXMapInfo_setObjectGroups, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTileSize", js_cocos2dx_TMXMapInfo_setTileSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTMXFile", js_cocos2dx_TMXMapInfo_initWithTMXFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOrientation", js_cocos2dx_TMXMapInfo_getOrientation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isStoringCharacters", js_cocos2dx_TMXMapInfo_isStoringCharacters, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLayers", js_cocos2dx_TMXMapInfo_setLayers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("parseXMLFile", js_cocos2dx_TMXMapInfo_parseXMLFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParentElement", js_cocos2dx_TMXMapInfo_getParentElement, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTMXFileName", js_cocos2dx_TMXMapInfo_setTMXFileName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("parseXMLString", js_cocos2dx_TMXMapInfo_parseXMLString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayers", js_cocos2dx_TMXMapInfo_getLayers, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTilesets", js_cocos2dx_TMXMapInfo_getTilesets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParentGID", js_cocos2dx_TMXMapInfo_getParentGID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setParentElement", js_cocos2dx_TMXMapInfo_setParentElement, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithXML", js_cocos2dx_TMXMapInfo_initWithXML, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setParentGID", js_cocos2dx_TMXMapInfo_setParentGID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayerAttribs", js_cocos2dx_TMXMapInfo_getLayerAttribs, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTileSize", js_cocos2dx_TMXMapInfo_getTileSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTileProperties", js_cocos2dx_TMXMapInfo_getTileProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getObjectGroups", js_cocos2dx_TMXMapInfo_getObjectGroups, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTMXFileName", js_cocos2dx_TMXMapInfo_getTMXFileName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCurrentString", js_cocos2dx_TMXMapInfo_setCurrentString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProperties", js_cocos2dx_TMXMapInfo_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOrientation", js_cocos2dx_TMXMapInfo_setOrientation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTileProperties", js_cocos2dx_TMXMapInfo_setTileProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMapSize", js_cocos2dx_TMXMapInfo_setMapSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStoringCharacters", js_cocos2dx_TMXMapInfo_setStoringCharacters, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMapSize", js_cocos2dx_TMXMapInfo_getMapSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTilesets", js_cocos2dx_TMXMapInfo_setTilesets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProperties", js_cocos2dx_TMXMapInfo_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentString", js_cocos2dx_TMXMapInfo_getCurrentString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLayerAttribs", js_cocos2dx_TMXMapInfo_setLayerAttribs, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TMXMapInfo_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithXML", js_cocos2dx_TMXMapInfo_createWithXML, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TMXMapInfo_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_TMXMapInfo_class, js_cocos2dx_TMXMapInfo_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TMXMapInfo", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TMXMapInfo_class; p->proto = jsb_cocos2d_TMXMapInfo_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TMXLayer_class; JSObject *jsb_cocos2d_TMXLayer_prototype; JSBool js_cocos2dx_TMXLayer_getTileGIDAt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getTileGIDAt : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getTileGIDAt : Error processing arguments"); int ret = cobj->getTileGIDAt(arg0); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { cocos2d::Point arg0; cocos2d::ccTMXTileFlags_* arg1; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); #pragma warning NO CONVERSION TO NATIVE FOR ccTMXTileFlags_*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getTileGIDAt : Error processing arguments"); int ret = cobj->getTileGIDAt(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getTileGIDAt : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getPositionAt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getPositionAt : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getPositionAt : Error processing arguments"); cocos2d::Point ret = cobj->getPositionAt(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getPositionAt : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setLayerOrientation : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setLayerOrientation : Error processing arguments"); cobj->setLayerOrientation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_setLayerOrientation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_releaseMap(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_releaseMap : Invalid Native Object"); if (argc == 0) { cobj->releaseMap(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_releaseMap : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setTiles(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setTiles : Invalid Native Object"); if (argc == 1) { int* arg0; #pragma warning NO CONVERSION TO NATIVE FOR int*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setTiles : Error processing arguments"); cobj->setTiles(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_setTiles : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getLayerSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getLayerSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getLayerSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getLayerSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setMapTileSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setMapTileSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setMapTileSize : Error processing arguments"); cobj->setMapTileSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_setMapTileSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getLayerOrientation : Invalid Native Object"); if (argc == 0) { int ret = cobj->getLayerOrientation(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getLayerOrientation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setProperties : Invalid Native Object"); if (argc == 1) { cocos2d::ValueMap arg0; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setProperties : Error processing arguments"); cobj->setProperties(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setLayerName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setLayerName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setLayerName : Error processing arguments"); cobj->setLayerName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_setLayerName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_removeTileAt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_removeTileAt : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_removeTileAt : Error processing arguments"); cobj->removeTileAt(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_removeTileAt : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_initWithTilesetInfo : Invalid Native Object"); if (argc == 3) { cocos2d::TMXTilesetInfo* arg0; cocos2d::TMXLayerInfo* arg1; cocos2d::TMXMapInfo* arg2; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::TMXLayerInfo*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::TMXMapInfo*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_initWithTilesetInfo : Error processing arguments"); JSBool ret = cobj->initWithTilesetInfo(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_initWithTilesetInfo : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setupTiles(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setupTiles : Invalid Native Object"); if (argc == 0) { cobj->setupTiles(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_setupTiles : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setTileGID(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXLayer* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setTileGID : Invalid Native Object"); do { if (argc == 3) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::ccTMXTileFlags_ arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cobj->setTileGID(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 2) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj->setTileGID(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXLayer_setTileGID : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getMapTileSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getMapTileSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getMapTileSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getMapTileSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getProperty(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getProperty : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getProperty : Error processing arguments"); cocos2d::Value ret = cobj->getProperty(arg0); jsval jsret = JSVAL_NULL; jsret = ccvalue_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getProperty : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setLayerSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setLayerSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setLayerSize : Error processing arguments"); cobj->setLayerSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_setLayerSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getLayerName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getLayerName : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getLayerName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getLayerName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_setTileSet(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setTileSet : Invalid Native Object"); if (argc == 1) { cocos2d::TMXTilesetInfo* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_setTileSet : Error processing arguments"); cobj->setTileSet(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_setTileSet : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getTileSet(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getTileSet : Invalid Native Object"); if (argc == 0) { cocos2d::TMXTilesetInfo* ret = cobj->getTileSet(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TMXTilesetInfo*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getTileSet : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXLayer* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getProperties : Invalid Native Object"); do { if (argc == 0) { cocos2d::ValueMap& ret = cobj->getProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::ValueMap& ret = cobj->getProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXLayer_getProperties : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_getTileAt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getTileAt : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_getTileAt : Error processing arguments"); cocos2d::Sprite* ret = cobj->getTileAt(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_getTileAt : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { cocos2d::TMXTilesetInfo* arg0; cocos2d::TMXLayerInfo* arg1; cocos2d::TMXMapInfo* arg2; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::TMXTilesetInfo*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::TMXLayerInfo*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::TMXMapInfo*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXLayer_create : Error processing arguments"); cocos2d::TMXLayer* ret = cocos2d::TMXLayer::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TMXLayer*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXLayer_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TMXLayer* cobj = new cocos2d::TMXLayer(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXLayer"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXLayer_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype; void js_cocos2d_TMXLayer_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TMXLayer)", obj); } void js_register_cocos2dx_TMXLayer(JSContext *cx, JSObject *global) { jsb_cocos2d_TMXLayer_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TMXLayer_class->name = "TMXLayer"; jsb_cocos2d_TMXLayer_class->addProperty = JS_PropertyStub; jsb_cocos2d_TMXLayer_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TMXLayer_class->getProperty = JS_PropertyStub; jsb_cocos2d_TMXLayer_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TMXLayer_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TMXLayer_class->resolve = JS_ResolveStub; jsb_cocos2d_TMXLayer_class->convert = JS_ConvertStub; jsb_cocos2d_TMXLayer_class->finalize = js_cocos2d_TMXLayer_finalize; jsb_cocos2d_TMXLayer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getTileGIDAt", js_cocos2dx_TMXLayer_getTileGIDAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionAt", js_cocos2dx_TMXLayer_getPositionAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLayerOrientation", js_cocos2dx_TMXLayer_setLayerOrientation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("releaseMap", js_cocos2dx_TMXLayer_releaseMap, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTiles", js_cocos2dx_TMXLayer_setTiles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayerSize", js_cocos2dx_TMXLayer_getLayerSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMapTileSize", js_cocos2dx_TMXLayer_setMapTileSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayerOrientation", js_cocos2dx_TMXLayer_getLayerOrientation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProperties", js_cocos2dx_TMXLayer_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLayerName", js_cocos2dx_TMXLayer_setLayerName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeTileAt", js_cocos2dx_TMXLayer_removeTileAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTilesetInfo", js_cocos2dx_TMXLayer_initWithTilesetInfo, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setupTiles", js_cocos2dx_TMXLayer_setupTiles, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTileGID", js_cocos2dx_TMXLayer_setTileGID, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMapTileSize", js_cocos2dx_TMXLayer_getMapTileSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProperty", js_cocos2dx_TMXLayer_getProperty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLayerSize", js_cocos2dx_TMXLayer_setLayerSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayerName", js_cocos2dx_TMXLayer_getLayerName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTileSet", js_cocos2dx_TMXLayer_setTileSet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTileSet", js_cocos2dx_TMXLayer_getTileSet, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProperties", js_cocos2dx_TMXLayer_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTileAt", js_cocos2dx_TMXLayer_getTileAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TMXLayer_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TMXLayer_prototype = JS_InitClass( cx, global, jsb_cocos2d_SpriteBatchNode_prototype, jsb_cocos2d_TMXLayer_class, js_cocos2dx_TMXLayer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TMXLayer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TMXLayer_class; p->proto = jsb_cocos2d_TMXLayer_prototype; p->parentProto = jsb_cocos2d_SpriteBatchNode_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TMXTiledMap_class; JSObject *jsb_cocos2d_TMXTiledMap_prototype; JSBool js_cocos2dx_TMXTiledMap_setObjectGroups(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setObjectGroups : Invalid Native Object"); if (argc == 1) { cocos2d::Vector arg0; ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setObjectGroups : Error processing arguments"); cobj->setObjectGroups(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setObjectGroups : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getProperty(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getProperty : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getProperty : Error processing arguments"); cocos2d::Value ret = cobj->getProperty(arg0); jsval jsret = JSVAL_NULL; jsret = ccvalue_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getProperty : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_setMapSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setMapSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setMapSize : Error processing arguments"); cobj->setMapSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setMapSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getObjectGroup(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getObjectGroup : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getObjectGroup : Error processing arguments"); cocos2d::TMXObjectGroup* ret = cobj->getObjectGroup(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TMXObjectGroup*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getObjectGroup : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::TMXTiledMap* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getObjectGroups : Invalid Native Object"); do { if (argc == 0) { cocos2d::Vector& ret = cobj->getObjectGroups(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const cocos2d::Vector& ret = cobj->getObjectGroups(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getObjectGroups : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getTileSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getTileSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getTileSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getTileSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getMapSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getMapSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getMapSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getMapSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getProperties(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getProperties : Invalid Native Object"); if (argc == 0) { cocos2d::ValueMap& ret = cobj->getProperties(); jsval jsret = JSVAL_NULL; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getProperties : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getPropertiesForGID(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getPropertiesForGID : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getPropertiesForGID : Error processing arguments"); cocos2d::Value ret = cobj->getPropertiesForGID(arg0); jsval jsret = JSVAL_NULL; jsret = ccvalue_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getPropertiesForGID : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_setTileSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setTileSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setTileSize : Error processing arguments"); cobj->setTileSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setTileSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_setProperties(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setProperties : Invalid Native Object"); if (argc == 1) { cocos2d::ValueMap arg0; ok &= jsval_to_ccvaluemap(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setProperties : Error processing arguments"); cobj->setProperties(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getLayer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getLayer : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getLayer : Error processing arguments"); cocos2d::TMXLayer* ret = cobj->getLayer(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TMXLayer*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getLayer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_getMapOrientation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_getMapOrientation : Invalid Native Object"); if (argc == 0) { int ret = cobj->getMapOrientation(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getMapOrientation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_setMapOrientation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setMapOrientation : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_setMapOrientation : Error processing arguments"); cobj->setMapOrientation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setMapOrientation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_create : Error processing arguments"); cocos2d::TMXTiledMap* ret = cocos2d::TMXTiledMap::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TMXTiledMap*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TMXTiledMap_createWithXML(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TMXTiledMap_createWithXML : Error processing arguments"); cocos2d::TMXTiledMap* ret = cocos2d::TMXTiledMap::createWithXML(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TMXTiledMap*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_createWithXML : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_TMXTiledMap_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TMXTiledMap)", obj); } void js_register_cocos2dx_TMXTiledMap(JSContext *cx, JSObject *global) { jsb_cocos2d_TMXTiledMap_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TMXTiledMap_class->name = "TMXTiledMap"; jsb_cocos2d_TMXTiledMap_class->addProperty = JS_PropertyStub; jsb_cocos2d_TMXTiledMap_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TMXTiledMap_class->getProperty = JS_PropertyStub; jsb_cocos2d_TMXTiledMap_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TMXTiledMap_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TMXTiledMap_class->resolve = JS_ResolveStub; jsb_cocos2d_TMXTiledMap_class->convert = JS_ConvertStub; jsb_cocos2d_TMXTiledMap_class->finalize = js_cocos2d_TMXTiledMap_finalize; jsb_cocos2d_TMXTiledMap_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setObjectGroups", js_cocos2dx_TMXTiledMap_setObjectGroups, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProperty", js_cocos2dx_TMXTiledMap_getProperty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMapSize", js_cocos2dx_TMXTiledMap_setMapSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getObjectGroup", js_cocos2dx_TMXTiledMap_getObjectGroup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getObjectGroups", js_cocos2dx_TMXTiledMap_getObjectGroups, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTileSize", js_cocos2dx_TMXTiledMap_getTileSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMapSize", js_cocos2dx_TMXTiledMap_getMapSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProperties", js_cocos2dx_TMXTiledMap_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPropertiesForGID", js_cocos2dx_TMXTiledMap_getPropertiesForGID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTileSize", js_cocos2dx_TMXTiledMap_setTileSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProperties", js_cocos2dx_TMXTiledMap_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayer", js_cocos2dx_TMXTiledMap_getLayer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMapOrientation", js_cocos2dx_TMXTiledMap_getMapOrientation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMapOrientation", js_cocos2dx_TMXTiledMap_setMapOrientation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TMXTiledMap_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithXML", js_cocos2dx_TMXTiledMap_createWithXML, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TMXTiledMap_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_TMXTiledMap_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TMXTiledMap", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TMXTiledMap_class; p->proto = jsb_cocos2d_TMXTiledMap_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_TileMapAtlas_class; JSObject *jsb_cocos2d_TileMapAtlas_prototype; JSBool js_cocos2dx_TileMapAtlas_initWithTileFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_initWithTileFile : Invalid Native Object"); if (argc == 4) { std::string arg0; std::string arg1; int arg2; int arg3; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_initWithTileFile : Error processing arguments"); JSBool ret = cobj->initWithTileFile(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_initWithTileFile : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_TileMapAtlas_releaseMap(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_releaseMap : Invalid Native Object"); if (argc == 0) { cobj->releaseMap(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_releaseMap : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TileMapAtlas_getTGAInfo(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_getTGAInfo : Invalid Native Object"); if (argc == 0) { cocos2d::sImageTGA* ret = cobj->getTGAInfo(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR sImageTGA*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_getTGAInfo : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_TileMapAtlas_getTileAt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_getTileAt : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_getTileAt : Error processing arguments"); cocos2d::Color3B ret = cobj->getTileAt(arg0); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_getTileAt : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TileMapAtlas_setTile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_setTile : Invalid Native Object"); if (argc == 2) { cocos2d::Color3B arg0; cocos2d::Point arg1; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_setTile : Error processing arguments"); cobj->setTile(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_setTile : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_TileMapAtlas_setTGAInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_setTGAInfo : Invalid Native Object"); if (argc == 1) { cocos2d::sImageTGA* arg0; #pragma warning NO CONVERSION TO NATIVE FOR sImageTGA*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_setTGAInfo : Error processing arguments"); cobj->setTGAInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_setTGAInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_TileMapAtlas_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 4) { std::string arg0; std::string arg1; int arg2; int arg3; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_TileMapAtlas_create : Error processing arguments"); cocos2d::TileMapAtlas* ret = cocos2d::TileMapAtlas::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::TileMapAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_TileMapAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::TileMapAtlas* cobj = new cocos2d::TileMapAtlas(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::TileMapAtlas"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_AtlasNode_prototype; void js_cocos2d_TileMapAtlas_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TileMapAtlas)", obj); } void js_register_cocos2dx_TileMapAtlas(JSContext *cx, JSObject *global) { jsb_cocos2d_TileMapAtlas_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_TileMapAtlas_class->name = "TileMapAtlas"; jsb_cocos2d_TileMapAtlas_class->addProperty = JS_PropertyStub; jsb_cocos2d_TileMapAtlas_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_TileMapAtlas_class->getProperty = JS_PropertyStub; jsb_cocos2d_TileMapAtlas_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_TileMapAtlas_class->enumerate = JS_EnumerateStub; jsb_cocos2d_TileMapAtlas_class->resolve = JS_ResolveStub; jsb_cocos2d_TileMapAtlas_class->convert = JS_ConvertStub; jsb_cocos2d_TileMapAtlas_class->finalize = js_cocos2d_TileMapAtlas_finalize; jsb_cocos2d_TileMapAtlas_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("initWithTileFile", js_cocos2dx_TileMapAtlas_initWithTileFile, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("releaseMap", js_cocos2dx_TileMapAtlas_releaseMap, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTGAInfo", js_cocos2dx_TileMapAtlas_getTGAInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTileAt", js_cocos2dx_TileMapAtlas_getTileAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTile", js_cocos2dx_TileMapAtlas_setTile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTGAInfo", js_cocos2dx_TileMapAtlas_setTGAInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_TileMapAtlas_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_TileMapAtlas_prototype = JS_InitClass( cx, global, jsb_cocos2d_AtlasNode_prototype, jsb_cocos2d_TileMapAtlas_class, js_cocos2dx_TileMapAtlas_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TileMapAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_TileMapAtlas_class; p->proto = jsb_cocos2d_TileMapAtlas_prototype; p->parentProto = jsb_cocos2d_AtlasNode_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Timer_class; JSObject *jsb_cocos2d_Timer_prototype; JSBool js_cocos2dx_Timer_getInterval(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Timer* cobj = (cocos2d::Timer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Timer_getInterval : Invalid Native Object"); if (argc == 0) { double ret = cobj->getInterval(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Timer_getInterval : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Timer_setInterval(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Timer* cobj = (cocos2d::Timer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Timer_setInterval : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Timer_setInterval : Error processing arguments"); cobj->setInterval(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Timer_setInterval : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Timer_initWithScriptHandler(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Timer* cobj = (cocos2d::Timer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Timer_initWithScriptHandler : Invalid Native Object"); if (argc == 2) { int arg0; double arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Timer_initWithScriptHandler : Error processing arguments"); JSBool ret = cobj->initWithScriptHandler(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Timer_initWithScriptHandler : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_Timer_update(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Timer* cobj = (cocos2d::Timer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Timer_update : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Timer_update : Error processing arguments"); cobj->update(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Timer_update : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Timer_getScriptHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Timer* cobj = (cocos2d::Timer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Timer_getScriptHandler : Invalid Native Object"); if (argc == 0) { int ret = cobj->getScriptHandler(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Timer_getScriptHandler : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Timer_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Timer* cobj = new cocos2d::Timer(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Timer"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Timer_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_Timer_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Timer)", obj); } void js_register_cocos2dx_Timer(JSContext *cx, JSObject *global) { jsb_cocos2d_Timer_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Timer_class->name = "Timer"; jsb_cocos2d_Timer_class->addProperty = JS_PropertyStub; jsb_cocos2d_Timer_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Timer_class->getProperty = JS_PropertyStub; jsb_cocos2d_Timer_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Timer_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Timer_class->resolve = JS_ResolveStub; jsb_cocos2d_Timer_class->convert = JS_ConvertStub; jsb_cocos2d_Timer_class->finalize = js_cocos2d_Timer_finalize; jsb_cocos2d_Timer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getInterval", js_cocos2dx_Timer_getInterval, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInterval", js_cocos2dx_Timer_setInterval, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithScriptHandler", js_cocos2dx_Timer_initWithScriptHandler, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", js_cocos2dx_Timer_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScriptHandler", js_cocos2dx_Timer_getScriptHandler, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Timer_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Timer_class, js_cocos2dx_Timer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Timer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Timer_class; p->proto = jsb_cocos2d_Timer_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Scheduler_class; JSObject *jsb_cocos2d_Scheduler_prototype; JSBool js_cocos2dx_Scheduler_setTimeScale(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Scheduler_setTimeScale : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Scheduler_setTimeScale : Error processing arguments"); cobj->setTimeScale(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Scheduler_setTimeScale : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Scheduler_performFunctionInCocosThread(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Scheduler_performFunctionInCocosThread : Invalid Native Object"); if (argc == 1) { std::function arg0; do { std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); auto lambda = [=]() -> void { jsval rval; JSBool ok = func->invoke(0, nullptr, rval); if (!ok && JS_IsExceptionPending(cx)) { JS_ReportPendingException(cx); } }; arg0 = lambda; } while(0) ; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Scheduler_performFunctionInCocosThread : Error processing arguments"); cobj->performFunctionInCocosThread(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Scheduler_performFunctionInCocosThread : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Scheduler_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Scheduler_getTimeScale : Invalid Native Object"); if (argc == 0) { double ret = cobj->getTimeScale(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Scheduler_getTimeScale : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Scheduler_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Scheduler* cobj = new cocos2d::Scheduler(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Scheduler"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Scheduler_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_Scheduler_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Scheduler)", obj); } void js_register_cocos2dx_Scheduler(JSContext *cx, JSObject *global) { jsb_cocos2d_Scheduler_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Scheduler_class->name = "Scheduler"; jsb_cocos2d_Scheduler_class->addProperty = JS_PropertyStub; jsb_cocos2d_Scheduler_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Scheduler_class->getProperty = JS_PropertyStub; jsb_cocos2d_Scheduler_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Scheduler_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Scheduler_class->resolve = JS_ResolveStub; jsb_cocos2d_Scheduler_class->convert = JS_ConvertStub; jsb_cocos2d_Scheduler_class->finalize = js_cocos2d_Scheduler_finalize; jsb_cocos2d_Scheduler_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setTimeScale", js_cocos2dx_Scheduler_setTimeScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("performFunctionInCocosThread", js_cocos2dx_Scheduler_performFunctionInCocosThread, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTimeScale", js_cocos2dx_Scheduler_getTimeScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Scheduler_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Scheduler_class, js_cocos2dx_Scheduler_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Scheduler", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Scheduler_class; p->proto = jsb_cocos2d_Scheduler_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_Component_class; JSObject *jsb_cocos2d_Component_prototype; JSBool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Component_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_setName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Component_setName : Error processing arguments"); cobj->setName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_setName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_isEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Component_serialize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_serialize : Invalid Native Object"); if (argc == 1) { void* arg0; #pragma warning NO CONVERSION TO NATIVE FOR void*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Component_serialize : Error processing arguments"); JSBool ret = cobj->serialize(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_serialize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Component_update(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_update : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Component_update : Error processing arguments"); cobj->update(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_update : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_getOwner : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getOwner(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_getOwner : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_setOwner : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Component_setOwner : Error processing arguments"); cobj->setOwner(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_setOwner : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Component_getName : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_getName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Component* ret = cocos2d::Component::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Component_create : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_Component_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Component)", obj); } void js_register_cocos2dx_Component(JSContext *cx, JSObject *global) { jsb_cocos2d_Component_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Component_class->name = "Component"; jsb_cocos2d_Component_class->addProperty = JS_PropertyStub; jsb_cocos2d_Component_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_Component_class->getProperty = JS_PropertyStub; jsb_cocos2d_Component_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_Component_class->enumerate = JS_EnumerateStub; jsb_cocos2d_Component_class->resolve = JS_ResolveStub; jsb_cocos2d_Component_class->convert = JS_ConvertStub; jsb_cocos2d_Component_class->finalize = js_cocos2d_Component_finalize; jsb_cocos2d_Component_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEnabled", js_cocos2dx_Component_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setName", js_cocos2dx_Component_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isEnabled", js_cocos2dx_Component_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("serialize", js_cocos2dx_Component_serialize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", js_cocos2dx_Component_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOwner", js_cocos2dx_Component_getOwner, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_Component_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOwner", js_cocos2dx_Component_setOwner, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_Component_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_Component_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_Component_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_Component_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Component", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_Component_class; p->proto = jsb_cocos2d_Component_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_CocosDenshion_SimpleAudioEngine_class; JSObject *jsb_CocosDenshion_SimpleAudioEngine_prototype; JSBool js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic : Error processing arguments"); cobj->preloadBackgroundMusic(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic : Invalid Native Object"); if (argc == 0) { cobj->stopBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic : Error processing arguments"); cobj->stopBackgroundMusic(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_stopAllEffects(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_stopAllEffects : Invalid Native Object"); if (argc == 0) { cobj->stopAllEffects(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_stopAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume : Invalid Native Object"); if (argc == 0) { double ret = cobj->getBackgroundMusicVolume(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic : Invalid Native Object"); if (argc == 0) { cobj->resumeBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume : Error processing arguments"); cobj->setBackgroundMusicVolume(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_preloadEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_preloadEffect : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_preloadEffect : Error processing arguments"); cobj->preloadEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_preloadEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isBackgroundMusicPlaying(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_getEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_getEffectsVolume : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEffectsVolume(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_getEffectsVolume : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->willPlayBackgroundMusic(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_pauseEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_pauseEffect : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_pauseEffect : Error processing arguments"); cobj->pauseEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_pauseEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_playEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playEffect : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); unsigned int ret = cobj->playEffect(arg0); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { const char* arg0; JSBool arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); unsigned int ret = cobj->playEffect(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 3) { const char* arg0; JSBool arg1; double arg2; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); unsigned int ret = cobj->playEffect(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 4) { const char* arg0; JSBool arg1; double arg2; double arg3; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); unsigned int ret = cobj->playEffect(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 5) { const char* arg0; JSBool arg1; double arg2; double arg3; double arg4; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); ok &= JS_ValueToNumber(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); ok &= JS_ValueToNumber(cx, argv[4], &arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); unsigned int ret = cobj->playEffect(arg0, arg1, arg2, arg3, arg4); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_playEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic : Invalid Native Object"); if (argc == 0) { cobj->rewindBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_playBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playBackgroundMusic : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playBackgroundMusic : Error processing arguments"); cobj->playBackgroundMusic(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; JSBool arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_playBackgroundMusic : Error processing arguments"); cobj->playBackgroundMusic(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_playBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_resumeAllEffects(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_resumeAllEffects : Invalid Native Object"); if (argc == 0) { cobj->resumeAllEffects(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_resumeAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_setEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_setEffectsVolume : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_setEffectsVolume : Error processing arguments"); cobj->setEffectsVolume(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_setEffectsVolume : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_stopEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_stopEffect : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_stopEffect : Error processing arguments"); cobj->stopEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_stopEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic : Invalid Native Object"); if (argc == 0) { cobj->pauseBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_pauseAllEffects(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_pauseAllEffects : Invalid Native Object"); if (argc == 0) { cobj->pauseAllEffects(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_pauseAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_unloadEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_unloadEffect : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_unloadEffect : Error processing arguments"); cobj->unloadEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_unloadEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_resumeEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_resumeEffect : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_SimpleAudioEngine_resumeEffect : Error processing arguments"); cobj->resumeEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_resumeEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_end(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { CocosDenshion::SimpleAudioEngine::end(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_end : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_SimpleAudioEngine_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { CocosDenshion::SimpleAudioEngine* ret = CocosDenshion::SimpleAudioEngine::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (CocosDenshion::SimpleAudioEngine*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_getInstance : wrong number of arguments"); return JS_FALSE; } void js_CocosDenshion_SimpleAudioEngine_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SimpleAudioEngine)", obj); } void js_register_cocos2dx_SimpleAudioEngine(JSContext *cx, JSObject *global) { jsb_CocosDenshion_SimpleAudioEngine_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_CocosDenshion_SimpleAudioEngine_class->name = "AudioEngine"; jsb_CocosDenshion_SimpleAudioEngine_class->addProperty = JS_PropertyStub; jsb_CocosDenshion_SimpleAudioEngine_class->delProperty = JS_DeletePropertyStub; jsb_CocosDenshion_SimpleAudioEngine_class->getProperty = JS_PropertyStub; jsb_CocosDenshion_SimpleAudioEngine_class->setProperty = JS_StrictPropertyStub; jsb_CocosDenshion_SimpleAudioEngine_class->enumerate = JS_EnumerateStub; jsb_CocosDenshion_SimpleAudioEngine_class->resolve = JS_ResolveStub; jsb_CocosDenshion_SimpleAudioEngine_class->convert = JS_ConvertStub; jsb_CocosDenshion_SimpleAudioEngine_class->finalize = js_CocosDenshion_SimpleAudioEngine_finalize; jsb_CocosDenshion_SimpleAudioEngine_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("preloadMusic", js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopMusic", js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopAllEffects", js_cocos2dx_SimpleAudioEngine_stopAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMusicVolume", js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resumeMusic", js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMusicVolume", js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("preloadEffect", js_cocos2dx_SimpleAudioEngine_preloadEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isMusicPlaying", js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEffectsVolume", js_cocos2dx_SimpleAudioEngine_getEffectsVolume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("willPlayMusic", js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pauseEffect", js_cocos2dx_SimpleAudioEngine_pauseEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("playEffect", js_cocos2dx_SimpleAudioEngine_playEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("rewindMusic", js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("playMusic", js_cocos2dx_SimpleAudioEngine_playBackgroundMusic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resumeAllEffects", js_cocos2dx_SimpleAudioEngine_resumeAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEffectsVolume", js_cocos2dx_SimpleAudioEngine_setEffectsVolume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopEffect", js_cocos2dx_SimpleAudioEngine_stopEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pauseMusic", js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pauseAllEffects", js_cocos2dx_SimpleAudioEngine_pauseAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("unloadEffect", js_cocos2dx_SimpleAudioEngine_unloadEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resumeEffect", js_cocos2dx_SimpleAudioEngine_resumeEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("end", js_cocos2dx_SimpleAudioEngine_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_cocos2dx_SimpleAudioEngine_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_CocosDenshion_SimpleAudioEngine_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_CocosDenshion_SimpleAudioEngine_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "AudioEngine", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_CocosDenshion_SimpleAudioEngine_class; p->proto = jsb_CocosDenshion_SimpleAudioEngine_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } void register_all_cocos2dx(JSContext* cx, JSObject* obj) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; js_register_cocos2dx_Action(cx, obj); js_register_cocos2dx_FiniteTimeAction(cx, obj); js_register_cocos2dx_ActionInstant(cx, obj); js_register_cocos2dx_Hide(cx, obj); js_register_cocos2dx_Node(cx, obj); js_register_cocos2dx_Scene(cx, obj); js_register_cocos2dx_TransitionScene(cx, obj); js_register_cocos2dx_TransitionEaseScene(cx, obj); js_register_cocos2dx_TransitionMoveInL(cx, obj); js_register_cocos2dx_TransitionMoveInB(cx, obj); js_register_cocos2dx_Layer(cx, obj); js_register_cocos2dx___LayerRGBA(cx, obj); js_register_cocos2dx_AtlasNode(cx, obj); js_register_cocos2dx_TileMapAtlas(cx, obj); js_register_cocos2dx_TransitionMoveInT(cx, obj); js_register_cocos2dx_TransitionMoveInR(cx, obj); js_register_cocos2dx_ParticleSystem(cx, obj); js_register_cocos2dx_ParticleSystemQuad(cx, obj); js_register_cocos2dx_ParticleSnow(cx, obj); js_register_cocos2dx_ActionInterval(cx, obj); js_register_cocos2dx_ActionCamera(cx, obj); js_register_cocos2dx_ProgressFromTo(cx, obj); js_register_cocos2dx_MoveBy(cx, obj); js_register_cocos2dx_MoveTo(cx, obj); js_register_cocos2dx_JumpBy(cx, obj); js_register_cocos2dx_ActionEase(cx, obj); js_register_cocos2dx_EaseBounce(cx, obj); js_register_cocos2dx_EaseBounceIn(cx, obj); js_register_cocos2dx_TransitionRotoZoom(cx, obj); js_register_cocos2dx_Director(cx, obj); js_register_cocos2dx_Texture2D(cx, obj); js_register_cocos2dx_EaseElastic(cx, obj); js_register_cocos2dx_EaseElasticOut(cx, obj); js_register_cocos2dx_EaseBackOut(cx, obj); js_register_cocos2dx_TransitionSceneOriented(cx, obj); js_register_cocos2dx_TransitionFlipX(cx, obj); js_register_cocos2dx_Spawn(cx, obj); js_register_cocos2dx_SimpleAudioEngine(cx, obj); js_register_cocos2dx_SkewTo(cx, obj); js_register_cocos2dx_SkewBy(cx, obj); js_register_cocos2dx_TransitionProgress(cx, obj); js_register_cocos2dx_TransitionProgressVertical(cx, obj); js_register_cocos2dx_TMXTiledMap(cx, obj); js_register_cocos2dx_GridAction(cx, obj); js_register_cocos2dx_Grid3DAction(cx, obj); js_register_cocos2dx_FadeIn(cx, obj); js_register_cocos2dx_AnimationCache(cx, obj); js_register_cocos2dx_FlipX3D(cx, obj); js_register_cocos2dx_FlipY3D(cx, obj); js_register_cocos2dx_EaseSineInOut(cx, obj); js_register_cocos2dx_TransitionFlipAngular(cx, obj); js_register_cocos2dx_EGLViewProtocol(cx, obj); js_register_cocos2dx_EGLView(cx, obj); js_register_cocos2dx_EaseElasticInOut(cx, obj); js_register_cocos2dx_Show(cx, obj); js_register_cocos2dx_FadeOut(cx, obj); js_register_cocos2dx_CallFunc(cx, obj); js_register_cocos2dx_Waves3D(cx, obj); js_register_cocos2dx_ParticleFireworks(cx, obj); js_register_cocos2dx_MenuItem(cx, obj); js_register_cocos2dx_MenuItemSprite(cx, obj); js_register_cocos2dx_MenuItemImage(cx, obj); js_register_cocos2dx_ParticleFire(cx, obj); js_register_cocos2dx_TransitionZoomFlipAngular(cx, obj); js_register_cocos2dx_EaseRateAction(cx, obj); js_register_cocos2dx_EaseIn(cx, obj); js_register_cocos2dx_EaseExponentialInOut(cx, obj); js_register_cocos2dx_EaseBackInOut(cx, obj); js_register_cocos2dx_EaseExponentialOut(cx, obj); js_register_cocos2dx_SpriteBatchNode(cx, obj); js_register_cocos2dx_Label(cx, obj); js_register_cocos2dx_Application(cx, obj); js_register_cocos2dx_DelayTime(cx, obj); js_register_cocos2dx_LabelAtlas(cx, obj); js_register_cocos2dx_LabelBMFont(cx, obj); js_register_cocos2dx_TransitionFadeTR(cx, obj); js_register_cocos2dx_TransitionFadeBL(cx, obj); js_register_cocos2dx_EaseElasticIn(cx, obj); js_register_cocos2dx_ParticleSpiral(cx, obj); js_register_cocos2dx_TiledGrid3DAction(cx, obj); js_register_cocos2dx_FadeOutTRTiles(cx, obj); js_register_cocos2dx_FadeOutUpTiles(cx, obj); js_register_cocos2dx_FadeOutDownTiles(cx, obj); js_register_cocos2dx_TextureCache(cx, obj); js_register_cocos2dx_ActionTween(cx, obj); js_register_cocos2dx_TransitionFadeDown(cx, obj); js_register_cocos2dx_ParticleSun(cx, obj); js_register_cocos2dx_TransitionProgressHorizontal(cx, obj); js_register_cocos2dx_TMXObjectGroup(cx, obj); js_register_cocos2dx_TMXLayer(cx, obj); js_register_cocos2dx_FlipX(cx, obj); js_register_cocos2dx_FlipY(cx, obj); js_register_cocos2dx_TransitionSplitCols(cx, obj); js_register_cocos2dx_Timer(cx, obj); js_register_cocos2dx_FadeTo(cx, obj); js_register_cocos2dx_Repeat(cx, obj); js_register_cocos2dx_Place(cx, obj); js_register_cocos2dx_GLProgram(cx, obj); js_register_cocos2dx_EaseBounceOut(cx, obj); js_register_cocos2dx_RenderTexture(cx, obj); js_register_cocos2dx_TintBy(cx, obj); js_register_cocos2dx_TransitionShrinkGrow(cx, obj); js_register_cocos2dx_Sprite(cx, obj); js_register_cocos2dx_LabelTTF(cx, obj); js_register_cocos2dx_ClippingNode(cx, obj); js_register_cocos2dx_ParticleFlower(cx, obj); js_register_cocos2dx_ParticleSmoke(cx, obj); js_register_cocos2dx_LayerMultiplex(cx, obj); js_register_cocos2dx_Blink(cx, obj); js_register_cocos2dx_ShaderCache(cx, obj); js_register_cocos2dx_JumpTo(cx, obj); js_register_cocos2dx_ParticleExplosion(cx, obj); js_register_cocos2dx_TransitionJumpZoom(cx, obj); js_register_cocos2dx_Touch(cx, obj); js_register_cocos2dx_SAXParser(cx, obj); js_register_cocos2dx_AnimationFrame(cx, obj); js_register_cocos2dx_NodeGrid(cx, obj); js_register_cocos2dx_TMXLayerInfo(cx, obj); js_register_cocos2dx_TMXTilesetInfo(cx, obj); js_register_cocos2dx_GridBase(cx, obj); js_register_cocos2dx_TiledGrid3D(cx, obj); js_register_cocos2dx_ParticleGalaxy(cx, obj); js_register_cocos2dx_Twirl(cx, obj); js_register_cocos2dx_MenuItemLabel(cx, obj); js_register_cocos2dx_LayerColor(cx, obj); js_register_cocos2dx_FadeOutBLTiles(cx, obj); js_register_cocos2dx_LayerGradient(cx, obj); js_register_cocos2dx_TargetedAction(cx, obj); js_register_cocos2dx_RepeatForever(cx, obj); js_register_cocos2dx_CardinalSplineTo(cx, obj); js_register_cocos2dx_CardinalSplineBy(cx, obj); js_register_cocos2dx_TransitionFlipY(cx, obj); js_register_cocos2dx_TurnOffTiles(cx, obj); js_register_cocos2dx_TintTo(cx, obj); js_register_cocos2dx_CatmullRomTo(cx, obj); js_register_cocos2dx_ToggleVisibility(cx, obj); js_register_cocos2dx_DrawNode(cx, obj); js_register_cocos2dx_TransitionTurnOffTiles(cx, obj); js_register_cocos2dx_RotateTo(cx, obj); js_register_cocos2dx_TransitionSplitRows(cx, obj); js_register_cocos2dx_TransitionProgressRadialCCW(cx, obj); js_register_cocos2dx_ScaleTo(cx, obj); js_register_cocos2dx_TransitionPageTurn(cx, obj); js_register_cocos2dx_BezierBy(cx, obj); js_register_cocos2dx_BezierTo(cx, obj); js_register_cocos2dx_Menu(cx, obj); js_register_cocos2dx_SpriteFrame(cx, obj); js_register_cocos2dx_ActionManager(cx, obj); js_register_cocos2dx_TransitionFade(cx, obj); js_register_cocos2dx_TransitionZoomFlipX(cx, obj); js_register_cocos2dx_SpriteFrameCache(cx, obj); js_register_cocos2dx_TransitionCrossFade(cx, obj); js_register_cocos2dx_Ripple3D(cx, obj); js_register_cocos2dx_TransitionSlideInL(cx, obj); js_register_cocos2dx_TransitionSlideInT(cx, obj); js_register_cocos2dx_StopGrid(cx, obj); js_register_cocos2dx_ShakyTiles3D(cx, obj); js_register_cocos2dx_PageTurn3D(cx, obj); js_register_cocos2dx_Grid3D(cx, obj); js_register_cocos2dx_TransitionProgressInOut(cx, obj); js_register_cocos2dx_EaseBackIn(cx, obj); js_register_cocos2dx_SplitRows(cx, obj); js_register_cocos2dx_Follow(cx, obj); js_register_cocos2dx_Animate(cx, obj); js_register_cocos2dx_ShuffleTiles(cx, obj); js_register_cocos2dx_ProgressTimer(cx, obj); js_register_cocos2dx_ParticleMeteor(cx, obj); js_register_cocos2dx_EaseInOut(cx, obj); js_register_cocos2dx_TransitionZoomFlipY(cx, obj); js_register_cocos2dx_ScaleBy(cx, obj); js_register_cocos2dx_Lens3D(cx, obj); js_register_cocos2dx_Animation(cx, obj); js_register_cocos2dx_TMXMapInfo(cx, obj); js_register_cocos2dx_EaseExponentialIn(cx, obj); js_register_cocos2dx_ReuseGrid(cx, obj); js_register_cocos2dx_MenuItemAtlasFont(cx, obj); js_register_cocos2dx_Liquid(cx, obj); js_register_cocos2dx_OrbitCamera(cx, obj); js_register_cocos2dx_ParticleBatchNode(cx, obj); js_register_cocos2dx_Component(cx, obj); js_register_cocos2dx_TextFieldTTF(cx, obj); js_register_cocos2dx_ParticleRain(cx, obj); js_register_cocos2dx_Waves(cx, obj); js_register_cocos2dx_EaseOut(cx, obj); js_register_cocos2dx_MenuItemFont(cx, obj); js_register_cocos2dx_TransitionFadeUp(cx, obj); js_register_cocos2dx_EaseSineOut(cx, obj); js_register_cocos2dx_JumpTiles3D(cx, obj); js_register_cocos2dx_MenuItemToggle(cx, obj); js_register_cocos2dx_RemoveSelf(cx, obj); js_register_cocos2dx_SplitCols(cx, obj); js_register_cocos2dx_MotionStreak(cx, obj); js_register_cocos2dx_RotateBy(cx, obj); js_register_cocos2dx_FileUtils(cx, obj); js_register_cocos2dx_ProgressTo(cx, obj); js_register_cocos2dx_TransitionProgressOutIn(cx, obj); js_register_cocos2dx_CatmullRomBy(cx, obj); js_register_cocos2dx_Sequence(cx, obj); js_register_cocos2dx_Shaky3D(cx, obj); js_register_cocos2dx_TransitionProgressRadialCW(cx, obj); js_register_cocos2dx_EaseBounceInOut(cx, obj); js_register_cocos2dx_TransitionSlideInR(cx, obj); js_register_cocos2dx___NodeRGBA(cx, obj); js_register_cocos2dx_ParallaxNode(cx, obj); js_register_cocos2dx_Scheduler(cx, obj); js_register_cocos2dx_EaseSineIn(cx, obj); js_register_cocos2dx_WavesTiles3D(cx, obj); js_register_cocos2dx_TransitionSlideInB(cx, obj); js_register_cocos2dx_Speed(cx, obj); js_register_cocos2dx_ShatteredTiles3D(cx, obj); } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_auto.hpp ================================================ #ifndef __cocos2dx_h__ #define __cocos2dx_h__ #include "jsapi.h" #include "jsfriendapi.h" extern JSClass *jsb_cocos2d_Action_class; extern JSObject *jsb_cocos2d_Action_prototype; JSBool js_cocos2dx_Action_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Action_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Action(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Action_startWithTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_setOriginalTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_clone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_getOriginalTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_stop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_update(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_getTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_step(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_setTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_getTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_setTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_isDone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Action_reverse(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FiniteTimeAction_class; extern JSObject *jsb_cocos2d_FiniteTimeAction_prototype; JSBool js_cocos2dx_FiniteTimeAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FiniteTimeAction_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FiniteTimeAction(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FiniteTimeAction_setDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FiniteTimeAction_getDuration(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Speed_class; extern JSObject *jsb_cocos2d_Speed_prototype; JSBool js_cocos2dx_Speed_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Speed_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Speed(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Speed_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Speed_setSpeed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Speed_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Speed_getSpeed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Speed_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Follow_class; extern JSObject *jsb_cocos2d_Follow_prototype; JSBool js_cocos2dx_Follow_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Follow_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Follow(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Follow_setBoudarySet(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Follow_isBoundarySet(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Follow_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_GLProgram_class; extern JSObject *jsb_cocos2d_GLProgram_prototype; JSBool js_cocos2dx_GLProgram_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_GLProgram_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_GLProgram(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_GLProgram_getFragmentShaderLog(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_addAttribute(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_getUniformLocationForName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_use(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_getVertexShaderLog(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_initWithVertexShaderByteArray(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_initWithVertexShaderFilename(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformsForBuiltins(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWith3i(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWith3iv(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_updateUniforms(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWith4iv(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_link(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWith2iv(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_reset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWith4i(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWith1i(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_setUniformLocationWith2i(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GLProgram_GLProgram(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Touch_class; extern JSObject *jsb_cocos2d_Touch_prototype; JSBool js_cocos2dx_Touch_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Touch_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Touch(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Touch_getPreviousLocationInView(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_getLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_getDelta(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_getStartLocationInView(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_getStartLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_getID(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_setTouchInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_getLocationInView(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Touch_Touch(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Texture2D_class; extern JSObject *jsb_cocos2d_Texture2D_prototype; JSBool js_cocos2dx_Texture2D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Texture2D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Texture2D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Texture2D_getShaderProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getMaxT(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getStringForFormat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_setShaderProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getMaxS(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_initWithMipmaps(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getPixelsHigh(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getBitsPerPixelForFormat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_initWithString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_setMaxT(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_drawInRect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getContentSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_setAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_setAntiAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_generateMipmap(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getDescription(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getPixelFormat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getContentSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getPixelsWide(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_drawAtPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_hasMipmaps(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_setMaxS(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_getDefaultAlphaPixelFormat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Texture2D_Texture2D(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Node_class; extern JSObject *jsb_cocos2d_Node_prototype; JSBool js_cocos2dx_Node_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Node_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Node(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getShaderProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getDescription(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getChildren(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_pause(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_convertToWorldSpaceAR(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_isIgnoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_updateDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setRotation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setScaleY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setScaleX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_removeAllComponents(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node__setLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getNodeToWorldAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getNodeToWorldTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_convertToWorldSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setSkewX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setSkewY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_convertTouchToNodeSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getRotationX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getRotationY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_isCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setParent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_resume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_stopActionByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_reorderChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_ignoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setPositionY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setPositionX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getNumberOfRunningActions(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_updateTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_isVisible(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getChildrenCount(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_convertToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_addComponent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_visit(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setShaderProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getRotation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getAnchorPointInPoints(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_runAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_transform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setVertexZ(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setScheduler(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_stopAllActions(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getSkewX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getSkewY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getDisplayedColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setRotationX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setRotationY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setAdditionalTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getScheduler(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getParentToNodeAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getOrderOfArrival(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setActionManager(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_isRunning(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getParent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getPositionY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getPositionX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_removeChildByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_updateDisplayedColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setVisible(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getParentToNodeTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getVertexZ(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setGlobalZOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getChildByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setOrderOfArrival(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getScaleY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getScaleX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getWorldToNodeAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setCascadeColorEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_cleanup(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getComponent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getContentSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_updatePhysicsTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getGlobalZOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_draw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_transformAncestors(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setUserObject(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_removeFromParentAndCleanup(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_convertTouchToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_update(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_sortAllChildren(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getWorldToNodeTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_convertToNodeSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_setTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_isCascadeColorEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_stopAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_getActionManager(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Node_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d___NodeRGBA_class; extern JSObject *jsb_cocos2d___NodeRGBA_prototype; JSBool js_cocos2dx___NodeRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx___NodeRGBA_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx___NodeRGBA(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocos2d_SpriteFrame_class; extern JSObject *jsb_cocos2d_SpriteFrame_prototype; JSBool js_cocos2dx_SpriteFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SpriteFrame_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SpriteFrame(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SpriteFrame_clone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_setRotated(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_setTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_setRectInPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_getTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_getRect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_setOffsetInPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_getRectInPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_setOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_getOriginalSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_setOriginalSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_setOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_getOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_isRotated(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_initWithTextureFilename(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_setRect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_getOffsetInPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrame_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_AnimationFrame_class; extern JSObject *jsb_cocos2d_AnimationFrame_prototype; JSBool js_cocos2dx_AnimationFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_AnimationFrame_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_AnimationFrame(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_AnimationFrame_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationFrame_getUserInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationFrame_setDelayUnits(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationFrame_clone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationFrame_getSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationFrame_getDelayUnits(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationFrame_setUserInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationFrame_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Animation_class; extern JSObject *jsb_cocos2d_Animation_prototype; JSBool js_cocos2dx_Animation_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Animation_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Animation(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Animation_getLoops(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_setRestoreOriginalFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_clone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_getDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_setFrames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_getFrames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_setLoops(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_setDelayPerUnit(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_addSpriteFrameWithFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_getTotalDelayUnits(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_getDelayPerUnit(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_getRestoreOriginalFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animation_addSpriteFrameWithTexture(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ActionInterval_class; extern JSObject *jsb_cocos2d_ActionInterval_prototype; JSBool js_cocos2dx_ActionInterval_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ActionInterval_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ActionInterval(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ActionInterval_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionInterval_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionInterval_getElapsed(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Sequence_class; extern JSObject *jsb_cocos2d_Sequence_prototype; JSBool js_cocos2dx_Sequence_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Sequence_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Sequence(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocos2d_Repeat_class; extern JSObject *jsb_cocos2d_Repeat_prototype; JSBool js_cocos2dx_Repeat_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Repeat_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Repeat(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Repeat_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Repeat_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Repeat_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_RepeatForever_class; extern JSObject *jsb_cocos2d_RepeatForever_prototype; JSBool js_cocos2dx_RepeatForever_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_RepeatForever_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_RepeatForever(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_RepeatForever_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RepeatForever_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RepeatForever_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Spawn_class; extern JSObject *jsb_cocos2d_Spawn_prototype; JSBool js_cocos2dx_Spawn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Spawn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Spawn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocos2d_RotateTo_class; extern JSObject *jsb_cocos2d_RotateTo_prototype; JSBool js_cocos2dx_RotateTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_RotateTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_RotateTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_RotateTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_RotateBy_class; extern JSObject *jsb_cocos2d_RotateBy_prototype; JSBool js_cocos2dx_RotateBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_RotateBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_RotateBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_RotateBy_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MoveBy_class; extern JSObject *jsb_cocos2d_MoveBy_prototype; JSBool js_cocos2dx_MoveBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MoveBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MoveBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MoveBy_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MoveTo_class; extern JSObject *jsb_cocos2d_MoveTo_prototype; JSBool js_cocos2dx_MoveTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MoveTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MoveTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MoveTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_SkewTo_class; extern JSObject *jsb_cocos2d_SkewTo_prototype; JSBool js_cocos2dx_SkewTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SkewTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SkewTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SkewTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_SkewBy_class; extern JSObject *jsb_cocos2d_SkewBy_prototype; JSBool js_cocos2dx_SkewBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SkewBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SkewBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SkewBy_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_JumpBy_class; extern JSObject *jsb_cocos2d_JumpBy_prototype; JSBool js_cocos2dx_JumpBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_JumpBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_JumpBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_JumpBy_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_JumpTo_class; extern JSObject *jsb_cocos2d_JumpTo_prototype; JSBool js_cocos2dx_JumpTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_JumpTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_JumpTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_JumpTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_BezierBy_class; extern JSObject *jsb_cocos2d_BezierBy_prototype; JSBool js_cocos2dx_BezierBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_BezierBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_BezierBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocos2d_BezierTo_class; extern JSObject *jsb_cocos2d_BezierTo_prototype; JSBool js_cocos2dx_BezierTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_BezierTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_BezierTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocos2d_ScaleTo_class; extern JSObject *jsb_cocos2d_ScaleTo_prototype; JSBool js_cocos2dx_ScaleTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ScaleTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ScaleTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ScaleTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ScaleBy_class; extern JSObject *jsb_cocos2d_ScaleBy_prototype; JSBool js_cocos2dx_ScaleBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ScaleBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ScaleBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ScaleBy_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Blink_class; extern JSObject *jsb_cocos2d_Blink_prototype; JSBool js_cocos2dx_Blink_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Blink_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Blink(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Blink_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FadeIn_class; extern JSObject *jsb_cocos2d_FadeIn_prototype; JSBool js_cocos2dx_FadeIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FadeIn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FadeIn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FadeIn_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FadeOut_class; extern JSObject *jsb_cocos2d_FadeOut_prototype; JSBool js_cocos2dx_FadeOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FadeOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FadeOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FadeOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FadeTo_class; extern JSObject *jsb_cocos2d_FadeTo_prototype; JSBool js_cocos2dx_FadeTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FadeTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FadeTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FadeTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TintTo_class; extern JSObject *jsb_cocos2d_TintTo_prototype; JSBool js_cocos2dx_TintTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TintTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TintTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TintTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TintBy_class; extern JSObject *jsb_cocos2d_TintBy_prototype; JSBool js_cocos2dx_TintBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TintBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TintBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TintBy_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_DelayTime_class; extern JSObject *jsb_cocos2d_DelayTime_prototype; JSBool js_cocos2dx_DelayTime_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_DelayTime_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_DelayTime(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_DelayTime_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Animate_class; extern JSObject *jsb_cocos2d_Animate_prototype; JSBool js_cocos2dx_Animate_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Animate_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Animate(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Animate_getAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animate_setAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Animate_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TargetedAction_class; extern JSObject *jsb_cocos2d_TargetedAction_prototype; JSBool js_cocos2dx_TargetedAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TargetedAction_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TargetedAction(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TargetedAction_getForcedTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TargetedAction_setForcedTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TargetedAction_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ActionCamera_class; extern JSObject *jsb_cocos2d_ActionCamera_prototype; JSBool js_cocos2dx_ActionCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ActionCamera_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ActionCamera(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ActionCamera_setEye(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionCamera_getEye(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionCamera_setUp(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionCamera_getCenter(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionCamera_setCenter(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionCamera_getUp(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionCamera_ActionCamera(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_OrbitCamera_class; extern JSObject *jsb_cocos2d_OrbitCamera_prototype; JSBool js_cocos2dx_OrbitCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_OrbitCamera_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_OrbitCamera(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_OrbitCamera_sphericalRadius(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_OrbitCamera_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_OrbitCamera_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_OrbitCamera_OrbitCamera(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ActionManager_class; extern JSObject *jsb_cocos2d_ActionManager_prototype; JSBool js_cocos2dx_ActionManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ActionManager_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ActionManager(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ActionManager_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_removeActionByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_removeAllActions(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_addAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_resumeTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_removeAllActionsFromTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_resumeTargets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_removeAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_pauseTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_pauseAllRunningActions(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionManager_ActionManager(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ActionEase_class; extern JSObject *jsb_cocos2d_ActionEase_prototype; JSBool js_cocos2dx_ActionEase_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ActionEase_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ActionEase(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ActionEase_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseRateAction_class; extern JSObject *jsb_cocos2d_EaseRateAction_prototype; JSBool js_cocos2dx_EaseRateAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseRateAction_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseRateAction(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseRateAction_setRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_EaseRateAction_getRate(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseIn_class; extern JSObject *jsb_cocos2d_EaseIn_prototype; JSBool js_cocos2dx_EaseIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseIn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseIn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseIn_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseOut_class; extern JSObject *jsb_cocos2d_EaseOut_prototype; JSBool js_cocos2dx_EaseOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseInOut_class; extern JSObject *jsb_cocos2d_EaseInOut_prototype; JSBool js_cocos2dx_EaseInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseInOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseInOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseInOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseExponentialIn_class; extern JSObject *jsb_cocos2d_EaseExponentialIn_prototype; JSBool js_cocos2dx_EaseExponentialIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseExponentialIn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseExponentialIn_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseExponentialOut_class; extern JSObject *jsb_cocos2d_EaseExponentialOut_prototype; JSBool js_cocos2dx_EaseExponentialOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseExponentialOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseExponentialOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseExponentialInOut_class; extern JSObject *jsb_cocos2d_EaseExponentialInOut_prototype; JSBool js_cocos2dx_EaseExponentialInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseExponentialInOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseExponentialInOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseSineIn_class; extern JSObject *jsb_cocos2d_EaseSineIn_prototype; JSBool js_cocos2dx_EaseSineIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseSineIn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseSineIn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseSineIn_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseSineOut_class; extern JSObject *jsb_cocos2d_EaseSineOut_prototype; JSBool js_cocos2dx_EaseSineOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseSineOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseSineOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseSineOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseSineInOut_class; extern JSObject *jsb_cocos2d_EaseSineInOut_prototype; JSBool js_cocos2dx_EaseSineInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseSineInOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseSineInOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseElastic_class; extern JSObject *jsb_cocos2d_EaseElastic_prototype; JSBool js_cocos2dx_EaseElastic_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseElastic_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseElastic(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseElastic_setPeriod(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_EaseElastic_getPeriod(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseElasticIn_class; extern JSObject *jsb_cocos2d_EaseElasticIn_prototype; JSBool js_cocos2dx_EaseElasticIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseElasticIn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseElasticIn_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseElasticOut_class; extern JSObject *jsb_cocos2d_EaseElasticOut_prototype; JSBool js_cocos2dx_EaseElasticOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseElasticOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseElasticOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseElasticInOut_class; extern JSObject *jsb_cocos2d_EaseElasticInOut_prototype; JSBool js_cocos2dx_EaseElasticInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseElasticInOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseElasticInOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseBounce_class; extern JSObject *jsb_cocos2d_EaseBounce_prototype; JSBool js_cocos2dx_EaseBounce_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseBounce_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseBounce(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseBounce_bounceTime(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseBounceIn_class; extern JSObject *jsb_cocos2d_EaseBounceIn_prototype; JSBool js_cocos2dx_EaseBounceIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseBounceIn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseBounceIn_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseBounceOut_class; extern JSObject *jsb_cocos2d_EaseBounceOut_prototype; JSBool js_cocos2dx_EaseBounceOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseBounceOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseBounceOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseBounceInOut_class; extern JSObject *jsb_cocos2d_EaseBounceInOut_prototype; JSBool js_cocos2dx_EaseBounceInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseBounceInOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseBounceInOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseBackIn_class; extern JSObject *jsb_cocos2d_EaseBackIn_prototype; JSBool js_cocos2dx_EaseBackIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseBackIn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseBackIn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseBackIn_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseBackOut_class; extern JSObject *jsb_cocos2d_EaseBackOut_prototype; JSBool js_cocos2dx_EaseBackOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseBackOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseBackOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseBackOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EaseBackInOut_class; extern JSObject *jsb_cocos2d_EaseBackInOut_prototype; JSBool js_cocos2dx_EaseBackInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EaseBackInOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EaseBackInOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ActionInstant_class; extern JSObject *jsb_cocos2d_ActionInstant_prototype; JSBool js_cocos2dx_ActionInstant_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ActionInstant_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ActionInstant(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocos2d_Show_class; extern JSObject *jsb_cocos2d_Show_prototype; JSBool js_cocos2dx_Show_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Show_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Show(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Show_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Hide_class; extern JSObject *jsb_cocos2d_Hide_prototype; JSBool js_cocos2dx_Hide_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Hide_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Hide(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Hide_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ToggleVisibility_class; extern JSObject *jsb_cocos2d_ToggleVisibility_prototype; JSBool js_cocos2dx_ToggleVisibility_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ToggleVisibility_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ToggleVisibility(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ToggleVisibility_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_RemoveSelf_class; extern JSObject *jsb_cocos2d_RemoveSelf_prototype; JSBool js_cocos2dx_RemoveSelf_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_RemoveSelf_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_RemoveSelf(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_RemoveSelf_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FlipX_class; extern JSObject *jsb_cocos2d_FlipX_prototype; JSBool js_cocos2dx_FlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FlipX_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FlipX(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FlipX_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FlipY_class; extern JSObject *jsb_cocos2d_FlipY_prototype; JSBool js_cocos2dx_FlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FlipY_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FlipY(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FlipY_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Place_class; extern JSObject *jsb_cocos2d_Place_prototype; JSBool js_cocos2dx_Place_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Place_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Place(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Place_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_CallFunc_class; extern JSObject *jsb_cocos2d_CallFunc_prototype; JSBool js_cocos2dx_CallFunc_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_CallFunc_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_CallFunc(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_CallFunc_execute(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_CallFunc_getTargetCallback(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_CallFunc_setTargetCallback(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_GridAction_class; extern JSObject *jsb_cocos2d_GridAction_prototype; JSBool js_cocos2dx_GridAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_GridAction_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_GridAction(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_GridAction_getGrid(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Grid3DAction_class; extern JSObject *jsb_cocos2d_Grid3DAction_prototype; JSBool js_cocos2dx_Grid3DAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Grid3DAction_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Grid3DAction(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Grid3DAction_getGrid(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TiledGrid3DAction_class; extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; JSBool js_cocos2dx_TiledGrid3DAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TiledGrid3DAction_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TiledGrid3DAction(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TiledGrid3DAction_getGrid(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_StopGrid_class; extern JSObject *jsb_cocos2d_StopGrid_prototype; JSBool js_cocos2dx_StopGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_StopGrid_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_StopGrid(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_StopGrid_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ReuseGrid_class; extern JSObject *jsb_cocos2d_ReuseGrid_prototype; JSBool js_cocos2dx_ReuseGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ReuseGrid_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ReuseGrid(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ReuseGrid_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Waves3D_class; extern JSObject *jsb_cocos2d_Waves3D_prototype; JSBool js_cocos2dx_Waves3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Waves3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Waves3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Waves3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FlipX3D_class; extern JSObject *jsb_cocos2d_FlipX3D_prototype; JSBool js_cocos2dx_FlipX3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FlipX3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FlipX3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FlipX3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FlipY3D_class; extern JSObject *jsb_cocos2d_FlipY3D_prototype; JSBool js_cocos2dx_FlipY3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FlipY3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FlipY3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FlipY3D_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FlipY3D_FlipY3D(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Lens3D_class; extern JSObject *jsb_cocos2d_Lens3D_prototype; JSBool js_cocos2dx_Lens3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Lens3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Lens3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Lens3D_setPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Lens3D_setConcave(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Lens3D_setLensEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Lens3D_getPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Lens3D_getLensEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Lens3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Ripple3D_class; extern JSObject *jsb_cocos2d_Ripple3D_prototype; JSBool js_cocos2dx_Ripple3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Ripple3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Ripple3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Ripple3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Ripple3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Ripple3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Ripple3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Ripple3D_setPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Ripple3D_getPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Ripple3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Shaky3D_class; extern JSObject *jsb_cocos2d_Shaky3D_prototype; JSBool js_cocos2dx_Shaky3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Shaky3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Shaky3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Shaky3D_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Shaky3D_Shaky3D(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Liquid_class; extern JSObject *jsb_cocos2d_Liquid_prototype; JSBool js_cocos2dx_Liquid_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Liquid_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Liquid(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Liquid_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Liquid_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Liquid_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Liquid_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Liquid_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Liquid_Liquid(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Waves_class; extern JSObject *jsb_cocos2d_Waves_prototype; JSBool js_cocos2dx_Waves_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Waves_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Waves(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Waves_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Waves_Waves(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Twirl_class; extern JSObject *jsb_cocos2d_Twirl_prototype; JSBool js_cocos2dx_Twirl_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Twirl_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Twirl(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Twirl_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Twirl_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Twirl_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Twirl_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Twirl_setPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Twirl_getPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Twirl_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Twirl_Twirl(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_PageTurn3D_class; extern JSObject *jsb_cocos2d_PageTurn3D_prototype; JSBool js_cocos2dx_PageTurn3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_PageTurn3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_PageTurn3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_PageTurn3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ProgressTo_class; extern JSObject *jsb_cocos2d_ProgressTo_prototype; JSBool js_cocos2dx_ProgressTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ProgressTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ProgressTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ProgressTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ProgressFromTo_class; extern JSObject *jsb_cocos2d_ProgressFromTo_prototype; JSBool js_cocos2dx_ProgressFromTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ProgressFromTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ProgressFromTo_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ShakyTiles3D_class; extern JSObject *jsb_cocos2d_ShakyTiles3D_prototype; JSBool js_cocos2dx_ShakyTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ShakyTiles3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ShakyTiles3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ShakyTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ShatteredTiles3D_class; extern JSObject *jsb_cocos2d_ShatteredTiles3D_prototype; JSBool js_cocos2dx_ShatteredTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ShatteredTiles3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ShatteredTiles3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ShatteredTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ShuffleTiles_class; extern JSObject *jsb_cocos2d_ShuffleTiles_prototype; JSBool js_cocos2dx_ShuffleTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ShuffleTiles_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ShuffleTiles(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ShuffleTiles_placeTile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShuffleTiles_shuffle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShuffleTiles_getDelta(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShuffleTiles_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FadeOutTRTiles_class; extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; JSBool js_cocos2dx_FadeOutTRTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FadeOutTRTiles_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FadeOutTRTiles_turnOnTile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FadeOutTRTiles_turnOffTile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FadeOutTRTiles_transformTile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FadeOutTRTiles_testFunc(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FadeOutTRTiles_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FadeOutBLTiles_class; extern JSObject *jsb_cocos2d_FadeOutBLTiles_prototype; JSBool js_cocos2dx_FadeOutBLTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FadeOutBLTiles_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FadeOutBLTiles_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FadeOutUpTiles_class; extern JSObject *jsb_cocos2d_FadeOutUpTiles_prototype; JSBool js_cocos2dx_FadeOutUpTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FadeOutUpTiles_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FadeOutUpTiles_transformTile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FadeOutUpTiles_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FadeOutDownTiles_class; extern JSObject *jsb_cocos2d_FadeOutDownTiles_prototype; JSBool js_cocos2dx_FadeOutDownTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FadeOutDownTiles_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FadeOutDownTiles_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TurnOffTiles_class; extern JSObject *jsb_cocos2d_TurnOffTiles_prototype; JSBool js_cocos2dx_TurnOffTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TurnOffTiles_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TurnOffTiles(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TurnOffTiles_turnOnTile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TurnOffTiles_turnOffTile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TurnOffTiles_shuffle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TurnOffTiles_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_WavesTiles3D_class; extern JSObject *jsb_cocos2d_WavesTiles3D_prototype; JSBool js_cocos2dx_WavesTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_WavesTiles3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_WavesTiles3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_WavesTiles3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_WavesTiles3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_WavesTiles3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_WavesTiles3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_WavesTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_JumpTiles3D_class; extern JSObject *jsb_cocos2d_JumpTiles3D_prototype; JSBool js_cocos2dx_JumpTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_JumpTiles3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_JumpTiles3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_JumpTiles3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_JumpTiles3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_JumpTiles3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_JumpTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_SplitRows_class; extern JSObject *jsb_cocos2d_SplitRows_prototype; JSBool js_cocos2dx_SplitRows_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SplitRows_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SplitRows(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SplitRows_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_SplitCols_class; extern JSObject *jsb_cocos2d_SplitCols_prototype; JSBool js_cocos2dx_SplitCols_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SplitCols_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SplitCols(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SplitCols_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ActionTween_class; extern JSObject *jsb_cocos2d_ActionTween_prototype; JSBool js_cocos2dx_ActionTween_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ActionTween_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ActionTween(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ActionTween_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ActionTween_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_CardinalSplineTo_class; extern JSObject *jsb_cocos2d_CardinalSplineTo_prototype; JSBool js_cocos2dx_CardinalSplineTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_CardinalSplineTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_CardinalSplineTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_CardinalSplineTo_getPoints(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_CardinalSplineTo_updatePosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_CardinalSplineTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_CardinalSplineTo_CardinalSplineTo(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_CardinalSplineBy_class; extern JSObject *jsb_cocos2d_CardinalSplineBy_prototype; JSBool js_cocos2dx_CardinalSplineBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_CardinalSplineBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_CardinalSplineBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_CardinalSplineBy_CardinalSplineBy(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_CatmullRomTo_class; extern JSObject *jsb_cocos2d_CatmullRomTo_prototype; JSBool js_cocos2dx_CatmullRomTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_CatmullRomTo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_CatmullRomTo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_CatmullRomTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_CatmullRomBy_class; extern JSObject *jsb_cocos2d_CatmullRomBy_prototype; JSBool js_cocos2dx_CatmullRomBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_CatmullRomBy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_CatmullRomBy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_CatmullRomBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_AtlasNode_class; extern JSObject *jsb_cocos2d_AtlasNode_prototype; JSBool js_cocos2dx_AtlasNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_AtlasNode_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_AtlasNode(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_AtlasNode_updateAtlasValues(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AtlasNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AtlasNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AtlasNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AtlasNode_getQuadsToDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AtlasNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AtlasNode_setQuadsToDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AtlasNode_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_DrawNode_class; extern JSObject *jsb_cocos2d_DrawNode_prototype; JSBool js_cocos2dx_DrawNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_DrawNode_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_DrawNode(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_DrawNode_drawQuadraticBezier(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_DrawNode_onDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_DrawNode_clear(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_DrawNode_drawTriangle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_DrawNode_drawDot(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_DrawNode_drawCubicBezier(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_DrawNode_drawSegment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_DrawNode_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_LabelAtlas_class; extern JSObject *jsb_cocos2d_LabelAtlas_prototype; JSBool js_cocos2dx_LabelAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_LabelAtlas_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_LabelAtlas(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_LabelAtlas_setString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelAtlas_initWithString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelAtlas_updateAtlasValues(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelAtlas_getString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelAtlas_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Director_class; extern JSObject *jsb_cocos2d_Director_prototype; JSBool js_cocos2dx_Director_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Director_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Director(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Director_pause(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getWinSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getDeltaTime(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setGLDefaultValues(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setActionManager(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setAlphaBlending(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_popToRootScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getNotificationNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getWinSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_end(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getTextureCache(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_isSendCleanupToScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getVisibleOrigin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_mainLoop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setDepthTest(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getFrameRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getSecondsPerFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_convertToUI(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setDefaultValues(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setScheduler(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_startAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getRunningScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setViewport(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_stopAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_popToSceneStackLevel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_resume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_isNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setOpenGLView(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_convertToGL(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_purgeCachedData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getTotalFrames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_runWithScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setNotificationNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_drawScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_popScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_isDisplayStats(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setProjection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getConsole(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getZEye(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getVisibleSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getScheduler(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_isPaused(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setDisplayStats(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_replaceScene(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getActionManager(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Director_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_GridBase_class; extern JSObject *jsb_cocos2d_GridBase_prototype; JSBool js_cocos2dx_GridBase_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_GridBase_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_GridBase(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_GridBase_setGridSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_calculateVertexPoints(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_afterDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_beforeDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_isTextureFlipped(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_getGridSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_getStep(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_set2DProjection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_setStep(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_setTextureFlipped(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_blit(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_setActive(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_getReuseGrid(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_setReuseGrid(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_isActive(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_reuse(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_GridBase_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Grid3D_class; extern JSObject *jsb_cocos2d_Grid3D_prototype; JSBool js_cocos2dx_Grid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Grid3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Grid3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Grid3D_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Grid3D_Grid3D(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TiledGrid3D_class; extern JSObject *jsb_cocos2d_TiledGrid3D_prototype; JSBool js_cocos2dx_TiledGrid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TiledGrid3D_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TiledGrid3D(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TiledGrid3D_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TiledGrid3D_TiledGrid3D(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Sprite_class; extern JSObject *jsb_cocos2d_Sprite_prototype; JSBool js_cocos2dx_Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Sprite_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Sprite(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_getTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_getOffsetPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_updateQuadVertices(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_updateTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_isFrameDisplayed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_getAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setDisplayFrameWithAnimationName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_getSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_isDirty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setDirty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_isTextureRectRotated(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_getTextureRect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_setVertexRect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_LabelTTF_class; extern JSObject *jsb_cocos2d_LabelTTF_prototype; JSBool js_cocos2dx_LabelTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_LabelTTF_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_LabelTTF(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_LabelTTF_enableShadow(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_setDimensions(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_getFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_getString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_setTextDefinition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_setFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_initWithStringAndTextDefinition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_setString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_initWithString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_setFontFillColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_enableStroke(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_getDimensions(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_setVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_getTextDefinition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_getFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_disableShadow(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_disableStroke(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_createWithFontDefinition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelTTF_LabelTTF(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_SpriteBatchNode_class; extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype; JSBool js_cocos2dx_SpriteBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SpriteBatchNode_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SpriteBatchNode(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SpriteBatchNode_appendChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_reorderBatch(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_atlasIndexForChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteBatchNode_SpriteBatchNode(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_LabelBMFont_class; extern JSObject *jsb_cocos2d_LabelBMFont_prototype; JSBool js_cocos2dx_LabelBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_LabelBMFont_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_LabelBMFont(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setScaleY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setScaleX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_createFontChars(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_getString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_initWithString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setCString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_getFntFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_updateLabel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_setWidth(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_purgeCachedData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LabelBMFont_LabelBMFont(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Label_class; extern JSObject *jsb_cocos2d_Label_prototype; JSBool js_cocos2dx_Label_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Label_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Label(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Label_getString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_assignNewUTF16String(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_setLabelEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getCommonLineHeight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_breakLineWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getScaleY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getScaleX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_setString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getKernings(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_recordPlaceholderInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getFontAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getStringNumLines(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getUTF16String(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getStringLenght(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_onDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_getTextAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_recordLetterInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_createWithBMFont(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Label_createWithCharMap(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Layer_class; extern JSObject *jsb_cocos2d_Layer_prototype; JSBool js_cocos2dx_Layer_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Layer_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Layer(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Layer_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d___LayerRGBA_class; extern JSObject *jsb_cocos2d___LayerRGBA_prototype; JSBool js_cocos2dx___LayerRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx___LayerRGBA_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx___LayerRGBA(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx___LayerRGBA_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_LayerColor_class; extern JSObject *jsb_cocos2d_LayerColor_prototype; JSBool js_cocos2dx_LayerColor_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_LayerColor_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_LayerColor(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_LayerColor_changeWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerColor_onDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerColor_changeWidth(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerColor_changeHeight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerColor_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_LayerGradient_class; extern JSObject *jsb_cocos2d_LayerGradient_prototype; JSBool js_cocos2dx_LayerGradient_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_LayerGradient_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_LayerGradient(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_LayerGradient_getStartColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_isCompressedInterpolation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_getStartOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_setVector(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_setStartOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_setCompressedInterpolation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_setEndOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_getVector(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_initWithColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_setEndColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_getEndColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_getEndOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_setStartColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerGradient_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_LayerMultiplex_class; extern JSObject *jsb_cocos2d_LayerMultiplex_prototype; JSBool js_cocos2dx_LayerMultiplex_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_LayerMultiplex_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_LayerMultiplex(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_LayerMultiplex_switchToAndReleaseMe(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerMultiplex_addLayer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_LayerMultiplex_switchTo(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Scene_class; extern JSObject *jsb_cocos2d_Scene_prototype; JSBool js_cocos2dx_Scene_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Scene_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Scene(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Scene_getPhysicsWorld(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Scene_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Scene_createWithPhysics(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionEaseScene_class; extern JSObject *jsb_cocos2d_TransitionEaseScene_prototype; JSBool js_cocos2dx_TransitionEaseScene_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionEaseScene_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionEaseScene(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionEaseScene_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionScene_class; extern JSObject *jsb_cocos2d_TransitionScene_prototype; JSBool js_cocos2dx_TransitionScene_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionScene_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionScene(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionScene_finish(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionScene_hideOutShowIn(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionScene_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionSceneOriented_class; extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; JSBool js_cocos2dx_TransitionSceneOriented_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionSceneOriented_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionSceneOriented_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionRotoZoom_class; extern JSObject *jsb_cocos2d_TransitionRotoZoom_prototype; JSBool js_cocos2dx_TransitionRotoZoom_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionRotoZoom_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionRotoZoom_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionJumpZoom_class; extern JSObject *jsb_cocos2d_TransitionJumpZoom_prototype; JSBool js_cocos2dx_TransitionJumpZoom_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionJumpZoom_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionJumpZoom_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionMoveInL_class; extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; JSBool js_cocos2dx_TransitionMoveInL_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionMoveInL_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionMoveInL_action(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionMoveInL_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionMoveInL_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionMoveInR_class; extern JSObject *jsb_cocos2d_TransitionMoveInR_prototype; JSBool js_cocos2dx_TransitionMoveInR_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionMoveInR_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionMoveInR_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionMoveInT_class; extern JSObject *jsb_cocos2d_TransitionMoveInT_prototype; JSBool js_cocos2dx_TransitionMoveInT_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionMoveInT_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionMoveInT_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionMoveInB_class; extern JSObject *jsb_cocos2d_TransitionMoveInB_prototype; JSBool js_cocos2dx_TransitionMoveInB_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionMoveInB_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionMoveInB_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionSlideInL_class; extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; JSBool js_cocos2dx_TransitionSlideInL_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionSlideInL_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionSlideInL_action(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionSlideInL_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionSlideInL_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionSlideInR_class; extern JSObject *jsb_cocos2d_TransitionSlideInR_prototype; JSBool js_cocos2dx_TransitionSlideInR_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionSlideInR_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionSlideInR_action(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionSlideInR_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionSlideInB_class; extern JSObject *jsb_cocos2d_TransitionSlideInB_prototype; JSBool js_cocos2dx_TransitionSlideInB_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionSlideInB_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionSlideInB_action(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionSlideInB_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionSlideInT_class; extern JSObject *jsb_cocos2d_TransitionSlideInT_prototype; JSBool js_cocos2dx_TransitionSlideInT_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionSlideInT_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionSlideInT_action(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionSlideInT_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionShrinkGrow_class; extern JSObject *jsb_cocos2d_TransitionShrinkGrow_prototype; JSBool js_cocos2dx_TransitionShrinkGrow_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionShrinkGrow_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionShrinkGrow_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionShrinkGrow_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionFlipX_class; extern JSObject *jsb_cocos2d_TransitionFlipX_prototype; JSBool js_cocos2dx_TransitionFlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionFlipX_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionFlipX_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionFlipY_class; extern JSObject *jsb_cocos2d_TransitionFlipY_prototype; JSBool js_cocos2dx_TransitionFlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionFlipY_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionFlipY_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionFlipAngular_class; extern JSObject *jsb_cocos2d_TransitionFlipAngular_prototype; JSBool js_cocos2dx_TransitionFlipAngular_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionFlipAngular_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionFlipAngular_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionZoomFlipX_class; extern JSObject *jsb_cocos2d_TransitionZoomFlipX_prototype; JSBool js_cocos2dx_TransitionZoomFlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionZoomFlipX_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionZoomFlipX_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionZoomFlipY_class; extern JSObject *jsb_cocos2d_TransitionZoomFlipY_prototype; JSBool js_cocos2dx_TransitionZoomFlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionZoomFlipY_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionZoomFlipY_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionZoomFlipAngular_class; extern JSObject *jsb_cocos2d_TransitionZoomFlipAngular_prototype; JSBool js_cocos2dx_TransitionZoomFlipAngular_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionZoomFlipAngular_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionZoomFlipAngular_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionFade_class; extern JSObject *jsb_cocos2d_TransitionFade_prototype; JSBool js_cocos2dx_TransitionFade_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionFade_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionFade(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionFade_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionCrossFade_class; extern JSObject *jsb_cocos2d_TransitionCrossFade_prototype; JSBool js_cocos2dx_TransitionCrossFade_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionCrossFade_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionCrossFade_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionTurnOffTiles_class; extern JSObject *jsb_cocos2d_TransitionTurnOffTiles_prototype; JSBool js_cocos2dx_TransitionTurnOffTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionTurnOffTiles_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionTurnOffTiles_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionSplitCols_class; extern JSObject *jsb_cocos2d_TransitionSplitCols_prototype; JSBool js_cocos2dx_TransitionSplitCols_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionSplitCols_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionSplitCols_action(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionSplitCols_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionSplitCols_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionSplitRows_class; extern JSObject *jsb_cocos2d_TransitionSplitRows_prototype; JSBool js_cocos2dx_TransitionSplitRows_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionSplitRows_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionSplitRows_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionFadeTR_class; extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; JSBool js_cocos2dx_TransitionFadeTR_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionFadeTR_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionFadeTR_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionFadeTR_actionWithSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionFadeTR_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionFadeBL_class; extern JSObject *jsb_cocos2d_TransitionFadeBL_prototype; JSBool js_cocos2dx_TransitionFadeBL_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionFadeBL_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionFadeBL_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionFadeUp_class; extern JSObject *jsb_cocos2d_TransitionFadeUp_prototype; JSBool js_cocos2dx_TransitionFadeUp_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionFadeUp_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionFadeUp_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionFadeDown_class; extern JSObject *jsb_cocos2d_TransitionFadeDown_prototype; JSBool js_cocos2dx_TransitionFadeDown_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionFadeDown_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionFadeDown_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionPageTurn_class; extern JSObject *jsb_cocos2d_TransitionPageTurn_prototype; JSBool js_cocos2dx_TransitionPageTurn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionPageTurn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionPageTurn_actionWithSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionPageTurn_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionPageTurn_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionPageTurn_TransitionPageTurn(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionProgress_class; extern JSObject *jsb_cocos2d_TransitionProgress_prototype; JSBool js_cocos2dx_TransitionProgress_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionProgress_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionProgress(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionProgress_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TransitionProgress_TransitionProgress(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionProgressRadialCCW_class; extern JSObject *jsb_cocos2d_TransitionProgressRadialCCW_prototype; JSBool js_cocos2dx_TransitionProgressRadialCCW_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionProgressRadialCCW_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionProgressRadialCCW_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionProgressRadialCW_class; extern JSObject *jsb_cocos2d_TransitionProgressRadialCW_prototype; JSBool js_cocos2dx_TransitionProgressRadialCW_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionProgressRadialCW_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionProgressRadialCW_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionProgressHorizontal_class; extern JSObject *jsb_cocos2d_TransitionProgressHorizontal_prototype; JSBool js_cocos2dx_TransitionProgressHorizontal_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionProgressHorizontal_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionProgressHorizontal_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionProgressVertical_class; extern JSObject *jsb_cocos2d_TransitionProgressVertical_prototype; JSBool js_cocos2dx_TransitionProgressVertical_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionProgressVertical_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionProgressVertical_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionProgressInOut_class; extern JSObject *jsb_cocos2d_TransitionProgressInOut_prototype; JSBool js_cocos2dx_TransitionProgressInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionProgressInOut_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionProgressInOut_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TransitionProgressOutIn_class; extern JSObject *jsb_cocos2d_TransitionProgressOutIn_prototype; JSBool js_cocos2dx_TransitionProgressOutIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TransitionProgressOutIn_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TransitionProgressOutIn_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MenuItem_class; extern JSObject *jsb_cocos2d_MenuItem_prototype; JSBool js_cocos2dx_MenuItem_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MenuItem_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MenuItem(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MenuItem_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItem_activate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItem_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItem_selected(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItem_isSelected(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItem_unselected(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItem_rect(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MenuItemLabel_class; extern JSObject *jsb_cocos2d_MenuItemLabel_prototype; JSBool js_cocos2dx_MenuItemLabel_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MenuItemLabel_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MenuItemLabel(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MenuItemLabel_getDisabledColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemLabel_setString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemLabel_setLabel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemLabel_setDisabledColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemLabel_getLabel(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MenuItemAtlasFont_class; extern JSObject *jsb_cocos2d_MenuItemAtlasFont_prototype; JSBool js_cocos2dx_MenuItemAtlasFont_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MenuItemAtlasFont_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MenuItemAtlasFont(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocos2d_MenuItemFont_class; extern JSObject *jsb_cocos2d_MenuItemFont_prototype; JSBool js_cocos2dx_MenuItemFont_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MenuItemFont_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MenuItemFont(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MenuItemFont_setFontNameObj(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemFont_getFontSizeObj(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemFont_getFontNameObj(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemFont_setFontSizeObj(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemFont_setFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemFont_getFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemFont_getFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemFont_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MenuItemSprite_class; extern JSObject *jsb_cocos2d_MenuItemSprite_prototype; JSBool js_cocos2dx_MenuItemSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MenuItemSprite_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MenuItemSprite(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MenuItemSprite_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemSprite_selected(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemSprite_setNormalImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemSprite_setDisabledImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemSprite_setSelectedImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemSprite_getDisabledImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemSprite_getSelectedImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemSprite_getNormalImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemSprite_unselected(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MenuItemImage_class; extern JSObject *jsb_cocos2d_MenuItemImage_prototype; JSBool js_cocos2dx_MenuItemImage_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MenuItemImage_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MenuItemImage(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MenuItemImage_setDisabledSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemImage_setSelectedSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemImage_setNormalSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MenuItemToggle_class; extern JSObject *jsb_cocos2d_MenuItemToggle_prototype; JSBool js_cocos2dx_MenuItemToggle_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MenuItemToggle_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MenuItemToggle(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MenuItemToggle_setSubItems(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemToggle_getSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemToggle_addSubItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemToggle_getSelectedItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MenuItemToggle_setSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Menu_class; extern JSObject *jsb_cocos2d_Menu_prototype; JSBool js_cocos2dx_Menu_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Menu_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Menu(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Menu_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Menu_alignItemsVertically(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Menu_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Menu_alignItemsHorizontallyWithPadding(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Menu_alignItemsVerticallyWithPadding(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Menu_alignItemsHorizontally(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ClippingNode_class; extern JSObject *jsb_cocos2d_ClippingNode_prototype; JSBool js_cocos2dx_ClippingNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ClippingNode_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ClippingNode(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ClippingNode_isInverted(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ClippingNode_setInverted(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ClippingNode_setStencil(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ClippingNode_getAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ClippingNode_getStencil(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ClippingNode_setAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ClippingNode_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_MotionStreak_class; extern JSObject *jsb_cocos2d_MotionStreak_prototype; JSBool js_cocos2dx_MotionStreak_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_MotionStreak_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_MotionStreak(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_MotionStreak_reset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MotionStreak_setTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MotionStreak_getTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MotionStreak_tintWithColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MotionStreak_setStartingPositionInitialized(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MotionStreak_isStartingPositionInitialized(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MotionStreak_isFastMode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MotionStreak_setFastMode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_MotionStreak_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ProgressTimer_class; extern JSObject *jsb_cocos2d_ProgressTimer_prototype; JSBool js_cocos2dx_ProgressTimer_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ProgressTimer_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ProgressTimer(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ProgressTimer_isReverseDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_setBarChangeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_getPercentage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_setSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_getType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_getSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_setMidpoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_getBarChangeRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_setReverseDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_getMidpoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_setPercentage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_setType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ProgressTimer_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_RenderTexture_class; extern JSObject *jsb_cocos2d_RenderTexture_prototype; JSBool js_cocos2dx_RenderTexture_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_RenderTexture_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_RenderTexture(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_RenderTexture_clearStencil(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_getClearDepth(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_getClearStencil(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_end(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_setClearStencil(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_setSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_getSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_isAutoDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_setClearFlags(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_begin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_setAutoDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_setClearColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_endToLua(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_beginWithClear(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_clearDepth(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_getClearColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_clear(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_getClearFlags(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_newImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_setClearDepth(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_initWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_RenderTexture_RenderTexture(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_NodeGrid_class; extern JSObject *jsb_cocos2d_NodeGrid_prototype; JSBool js_cocos2dx_NodeGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_NodeGrid_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_NodeGrid(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_NodeGrid_setTarget(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_NodeGrid_getGrid(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_NodeGrid_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleBatchNode_class; extern JSObject *jsb_cocos2d_ParticleBatchNode_prototype; JSBool js_cocos2dx_ParticleBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleBatchNode_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleBatchNode(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_disableParticle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_insertChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_visit(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleSystem_class; extern JSObject *jsb_cocos2d_ParticleSystem_prototype; JSBool js_cocos2dx_ParticleSystem_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleSystem_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleSystem(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleSystem_getStartSizeVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_isFull(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getStartColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getPositionType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setPosVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEndSpin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setRotatePerSecondVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getStartSpinVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getRadialAccelVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEndSizeVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setRotation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setTangentialAccel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setScaleY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setScaleX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getRadialAccel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setStartRadius(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setRotatePerSecond(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEndSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getGravity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getTangentialAccel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEndRadius(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getSpeed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getAngle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEndColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setStartSpin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getPosVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_updateWithNoTime(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_isBlendAdditive(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getSpeedVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setPositionType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_stopSystem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getSourcePosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setLifeVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEndColorVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_updateQuadWithParticle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getStartSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setStartSpinVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_resetSystem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setTangentialAccelVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEndRadiusVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEndRadius(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_isActive(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setRadialAccelVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setStartSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setSpeed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getStartSpin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getRotatePerSecond(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_initParticle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEmitterMode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setSourcePosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEndSpinVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setBlendAdditive(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setLife(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setAngleVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setRotationIsDir(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEndSizeVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setAngle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getTangentialAccelVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEmitterMode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEndSpinVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getAngleVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setStartColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getRotatePerSecondVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEndSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getLife(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setSpeedVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setGravity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_postStep(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEmissionRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEndColorVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getRotationIsDir(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEmissionRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEndColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getLifeVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setStartSizeVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_addParticle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getStartRadius(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getParticleCount(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getStartRadiusVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setStartColorVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setEndSpin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setRadialAccel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_setStartRadiusVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getEndRadiusVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_getStartColorVar(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystem_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleSystemQuad_class; extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; JSBool js_cocos2dx_ParticleSystemQuad_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleSystemQuad_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleSystemQuad(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleSystemQuad_setDisplayFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystemQuad_setTextureWithRect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystemQuad_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSystemQuad_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleFire_class; extern JSObject *jsb_cocos2d_ParticleFire_prototype; JSBool js_cocos2dx_ParticleFire_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleFire_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleFire(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleFire_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleFire_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleFireworks_class; extern JSObject *jsb_cocos2d_ParticleFireworks_prototype; JSBool js_cocos2dx_ParticleFireworks_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleFireworks_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleFireworks(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleFireworks_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleFireworks_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleSun_class; extern JSObject *jsb_cocos2d_ParticleSun_prototype; JSBool js_cocos2dx_ParticleSun_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleSun_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleSun(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleSun_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSun_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleGalaxy_class; extern JSObject *jsb_cocos2d_ParticleGalaxy_prototype; JSBool js_cocos2dx_ParticleGalaxy_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleGalaxy_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleGalaxy(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleGalaxy_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleGalaxy_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleFlower_class; extern JSObject *jsb_cocos2d_ParticleFlower_prototype; JSBool js_cocos2dx_ParticleFlower_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleFlower_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleFlower(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleFlower_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleFlower_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleMeteor_class; extern JSObject *jsb_cocos2d_ParticleMeteor_prototype; JSBool js_cocos2dx_ParticleMeteor_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleMeteor_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleMeteor(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleMeteor_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleMeteor_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleSpiral_class; extern JSObject *jsb_cocos2d_ParticleSpiral_prototype; JSBool js_cocos2dx_ParticleSpiral_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleSpiral_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleSpiral(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleSpiral_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSpiral_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleExplosion_class; extern JSObject *jsb_cocos2d_ParticleExplosion_prototype; JSBool js_cocos2dx_ParticleExplosion_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleExplosion_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleExplosion(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleExplosion_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleExplosion_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleSmoke_class; extern JSObject *jsb_cocos2d_ParticleSmoke_prototype; JSBool js_cocos2dx_ParticleSmoke_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleSmoke_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleSmoke(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleSmoke_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSmoke_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleSnow_class; extern JSObject *jsb_cocos2d_ParticleSnow_prototype; JSBool js_cocos2dx_ParticleSnow_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleSnow_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleSnow(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleSnow_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleSnow_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParticleRain_class; extern JSObject *jsb_cocos2d_ParticleRain_prototype; JSBool js_cocos2dx_ParticleRain_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParticleRain_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParticleRain(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParticleRain_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParticleRain_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_FileUtils_class; extern JSObject *jsb_cocos2d_FileUtils_prototype; JSBool js_cocos2dx_FileUtils_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_FileUtils_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_FileUtils(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_FileUtils_fullPathForFilename(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_getStringFromFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_setFilenameLookupDictionary(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_isAbsolutePath(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_isPopupNotify(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_getValueVectorFromFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_writeToFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_getValueMapFromFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_addSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_isFileExist(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_purgeCachedEntries(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_fullPathFromRelativeFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_FileUtils_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_SAXParser_class; extern JSObject *jsb_cocos2d_SAXParser_prototype; JSBool js_cocos2dx_SAXParser_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SAXParser_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SAXParser(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SAXParser_init(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Application_class; extern JSObject *jsb_cocos2d_Application_prototype; JSBool js_cocos2dx_Application_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Application_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Application(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Application_getTargetPlatform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Application_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Application_getCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Application_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EGLViewProtocol_class; extern JSObject *jsb_cocos2d_EGLViewProtocol_prototype; JSBool js_cocos2dx_EGLViewProtocol_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EGLViewProtocol_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EGLViewProtocol(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EGLViewProtocol_getVisibleOrigin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_EGLViewProtocol_getVisibleSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_EGLViewProtocol_setDesignResolutionSize(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_EGLView_class; extern JSObject *jsb_cocos2d_EGLView_prototype; JSBool js_cocos2dx_EGLView_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_EGLView_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_EGLView(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_EGLView_setIMEKeyboardState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_EGLView_isOpenGLReady(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_EGLView_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ShaderCache_class; extern JSObject *jsb_cocos2d_ShaderCache_prototype; JSBool js_cocos2dx_ShaderCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ShaderCache_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ShaderCache(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ShaderCache_reloadDefaultShaders(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShaderCache_addProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShaderCache_getProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShaderCache_loadDefaultShaders(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShaderCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShaderCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ShaderCache_ShaderCache(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_AnimationCache_class; extern JSObject *jsb_cocos2d_AnimationCache_prototype; JSBool js_cocos2dx_AnimationCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_AnimationCache_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_AnimationCache(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_AnimationCache_getAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationCache_addAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationCache_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationCache_addAnimationsWithDictionary(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationCache_removeAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationCache_addAnimationsWithFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_AnimationCache_AnimationCache(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_SpriteFrameCache_class; extern JSObject *jsb_cocos2d_SpriteFrameCache_prototype; JSBool js_cocos2dx_SpriteFrameCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SpriteFrameCache_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SpriteFrameCache(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_getSpriteFrameByName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_removeSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SpriteFrameCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TextFieldTTF_class; extern JSObject *jsb_cocos2d_TextFieldTTF_prototype; JSBool js_cocos2dx_TextFieldTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TextFieldTTF_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TextFieldTTF(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TextFieldTTF_getCharCount(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_getDelegate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_setSecureTextEntry(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_getColorSpaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_initWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_setColorSpaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_detachWithIME(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_setDelegate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_isSecureTextEntry(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_attachWithIME(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextFieldTTF_TextFieldTTF(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TextureCache_class; extern JSObject *jsb_cocos2d_TextureCache_prototype; JSBool js_cocos2dx_TextureCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TextureCache_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TextureCache(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TextureCache_removeTextureForKey(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_removeAllTextures(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_getDescription(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_getCachedTextureInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_getTextureForKey(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_removeUnusedTextures(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_waitForQuit(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TextureCache_TextureCache(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_ParallaxNode_class; extern JSObject *jsb_cocos2d_ParallaxNode_prototype; JSBool js_cocos2dx_ParallaxNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_ParallaxNode_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ParallaxNode(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_ParallaxNode_getParallaxArray(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParallaxNode_addChild(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParallaxNode_setParallaxArray(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_ParallaxNode_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TMXObjectGroup_class; extern JSObject *jsb_cocos2d_TMXObjectGroup_prototype; JSBool js_cocos2dx_TMXObjectGroup_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TMXObjectGroup_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TMXObjectGroup(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TMXObjectGroup_setPositionOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_getProperty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_getPositionOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_getObject(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_getObjects(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_setGroupName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_getProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_getGroupName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_setProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_setObjects(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXObjectGroup_TMXObjectGroup(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TMXLayerInfo_class; extern JSObject *jsb_cocos2d_TMXLayerInfo_prototype; JSBool js_cocos2dx_TMXLayerInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TMXLayerInfo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TMXLayerInfo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TMXLayerInfo_setProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayerInfo_getProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayerInfo_TMXLayerInfo(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TMXTilesetInfo_class; extern JSObject *jsb_cocos2d_TMXTilesetInfo_prototype; JSBool js_cocos2dx_TMXTilesetInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TMXTilesetInfo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TMXTilesetInfo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TMXTilesetInfo_rectForGID(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTilesetInfo_TMXTilesetInfo(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TMXMapInfo_class; extern JSObject *jsb_cocos2d_TMXMapInfo_prototype; JSBool js_cocos2dx_TMXMapInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TMXMapInfo_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TMXMapInfo(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TMXMapInfo_setObjectGroups(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setTileSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_initWithTMXFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getOrientation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_isStoringCharacters(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setLayers(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_parseXMLFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getParentElement(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setTMXFileName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_parseXMLString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getLayers(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getTilesets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getParentGID(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setParentElement(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_initWithXML(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setParentGID(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getLayerAttribs(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getTileSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getTileProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getTMXFileName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setCurrentString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setOrientation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setTileProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setMapSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setStoringCharacters(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getMapSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setTilesets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_getCurrentString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_setLayerAttribs(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_createWithXML(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXMapInfo_TMXMapInfo(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TMXLayer_class; extern JSObject *jsb_cocos2d_TMXLayer_prototype; JSBool js_cocos2dx_TMXLayer_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TMXLayer_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TMXLayer(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TMXLayer_getTileGIDAt(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getPositionAt(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_releaseMap(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setTiles(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getLayerSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setMapTileSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setLayerName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_removeTileAt(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setupTiles(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setTileGID(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getMapTileSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getProperty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setLayerSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getLayerName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_setTileSet(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getTileSet(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_getTileAt(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXLayer_TMXLayer(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TMXTiledMap_class; extern JSObject *jsb_cocos2d_TMXTiledMap_prototype; JSBool js_cocos2dx_TMXTiledMap_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TMXTiledMap_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TMXTiledMap(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TMXTiledMap_setObjectGroups(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getProperty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_setMapSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getObjectGroup(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getTileSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getMapSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getPropertiesForGID(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_setTileSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_setProperties(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getLayer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_getMapOrientation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_setMapOrientation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TMXTiledMap_createWithXML(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_TileMapAtlas_class; extern JSObject *jsb_cocos2d_TileMapAtlas_prototype; JSBool js_cocos2dx_TileMapAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_TileMapAtlas_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_TileMapAtlas(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_TileMapAtlas_initWithTileFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TileMapAtlas_releaseMap(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TileMapAtlas_getTGAInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TileMapAtlas_getTileAt(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TileMapAtlas_setTile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TileMapAtlas_setTGAInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TileMapAtlas_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_TileMapAtlas_TileMapAtlas(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Timer_class; extern JSObject *jsb_cocos2d_Timer_prototype; JSBool js_cocos2dx_Timer_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Timer_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Timer(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Timer_getInterval(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Timer_setInterval(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Timer_initWithScriptHandler(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Timer_update(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Timer_getScriptHandler(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Timer_Timer(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Scheduler_class; extern JSObject *jsb_cocos2d_Scheduler_prototype; JSBool js_cocos2dx_Scheduler_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Scheduler_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Scheduler(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Scheduler_setTimeScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Scheduler_performFunctionInCocosThread(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Scheduler_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Scheduler_Scheduler(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_Component_class; extern JSObject *jsb_cocos2d_Component_prototype; JSBool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Component_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Component(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_serialize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_update(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_CocosDenshion_SimpleAudioEngine_class; extern JSObject *jsb_CocosDenshion_SimpleAudioEngine_prototype; JSBool js_cocos2dx_SimpleAudioEngine_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_SimpleAudioEngine_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_SimpleAudioEngine(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_stopAllEffects(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_preloadEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_getEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_pauseEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_playEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_playBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_resumeAllEffects(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_setEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_stopEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_pauseAllEffects(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_unloadEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_resumeEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_end(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_SimpleAudioEngine_getInstance(JSContext *cx, uint32_t argc, jsval *vp); #endif ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_auto_api.js ================================================ /** * @module cocos2dx */ var cc = cc || {}; /** * @class Action */ cc.Action = { /** * @method startWithTarget * @param {cocos2d::Node*} */ startWithTarget : function () {}, /** * @method setOriginalTarget * @param {cocos2d::Node*} */ setOriginalTarget : function () {}, /** * @method clone * @return A value converted from C/C++ "cocos2d::Action*" */ clone : function () {}, /** * @method getOriginalTarget * @return A value converted from C/C++ "cocos2d::Node*" */ getOriginalTarget : function () {}, /** * @method stop */ stop : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method getTarget * @return A value converted from C/C++ "cocos2d::Node*" */ getTarget : function () {}, /** * @method step * @param {float} */ step : function () {}, /** * @method setTag * @param {int} */ setTag : function () {}, /** * @method getTag * @return A value converted from C/C++ "int" */ getTag : function () {}, /** * @method setTarget * @param {cocos2d::Node*} */ setTarget : function () {}, /** * @method isDone * @return A value converted from C/C++ "bool" */ isDone : function () {}, /** * @method reverse * @return A value converted from C/C++ "cocos2d::Action*" */ reverse : function () {}, }; /** * @class FiniteTimeAction */ cc.FiniteTimeAction = { /** * @method setDuration * @param {float} */ setDuration : function () {}, /** * @method getDuration * @return A value converted from C/C++ "float" */ getDuration : function () {}, }; /** * @class Speed */ cc.Speed = { /** * @method setInnerAction * @param {cocos2d::ActionInterval*} */ setInnerAction : function () {}, /** * @method setSpeed * @param {float} */ setSpeed : function () {}, /** * @method getInnerAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ getInnerAction : function () {}, /** * @method getSpeed * @return A value converted from C/C++ "float" */ getSpeed : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Speed*" * @param {cocos2d::ActionInterval*} * @param {float} */ create : function () {}, }; /** * @class Follow */ cc.Follow = { /** * @method setBoudarySet * @param {bool} */ setBoudarySet : function () {}, /** * @method isBoundarySet * @return A value converted from C/C++ "bool" */ isBoundarySet : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Follow*" * @param {cocos2d::Node*} * @param {const cocos2d::Rect&} */ create : function () {}, }; /** * @class GLProgram */ cc.GLProgram = { /** * @method getFragmentShaderLog * @return A value converted from C/C++ "std::string" */ getFragmentShaderLog : function () {}, /** * @method addAttribute * @param {const char*} * @param {GLuint} */ addAttribute : function () {}, /** * @method setUniformLocationWithMatrix4fv * @param {GLint} * @param {const GLfloat*} * @param {unsigned int} */ setUniformLocationWithMatrix4fv : function () {}, /** * @method getUniformLocationForName * @return A value converted from C/C++ "GLint" * @param {const char*} */ getUniformLocationForName : function () {}, /** * @method use */ use : function () {}, /** * @method getVertexShaderLog * @return A value converted from C/C++ "std::string" */ getVertexShaderLog : function () {}, /** * @method initWithVertexShaderByteArray * @return A value converted from C/C++ "bool" * @param {const GLchar*} * @param {const GLchar*} */ initWithVertexShaderByteArray : function () {}, /** * @method initWithVertexShaderFilename * @return A value converted from C/C++ "bool" * @param {const char*} * @param {const char*} */ initWithVertexShaderFilename : function () {}, /** * @method setUniformLocationWith3i * @param {GLint} * @param {GLint} * @param {GLint} * @param {GLint} */ setUniformLocationWith3i : function () {}, /** * @method setUniformLocationWith3iv * @param {GLint} * @param {GLint*} * @param {unsigned int} */ setUniformLocationWith3iv : function () {}, /** * @method updateUniforms */ updateUniforms : function () {}, /** * @method setUniformLocationWith4iv * @param {GLint} * @param {GLint*} * @param {unsigned int} */ setUniformLocationWith4iv : function () {}, /** * @method setUniformLocationWithMatrix2fv * @param {GLint} * @param {const GLfloat*} * @param {unsigned int} */ setUniformLocationWithMatrix2fv : function () {}, /** * @method link * @return A value converted from C/C++ "bool" */ link : function () {}, /** * @method setUniformLocationWith2iv * @param {GLint} * @param {GLint*} * @param {unsigned int} */ setUniformLocationWith2iv : function () {}, /** * @method setUniformLocationWithMatrix3fv * @param {GLint} * @param {const GLfloat*} * @param {unsigned int} */ setUniformLocationWithMatrix3fv : function () {}, /** * @method reset */ reset : function () {}, /** * @method setUniformLocationWith4i * @param {GLint} * @param {GLint} * @param {GLint} * @param {GLint} * @param {GLint} */ setUniformLocationWith4i : function () {}, /** * @method setUniformLocationWith1i * @param {GLint} * @param {GLint} */ setUniformLocationWith1i : function () {}, /** * @method setUniformLocationWith2i * @param {GLint} * @param {GLint} * @param {GLint} */ setUniformLocationWith2i : function () {}, /** * @method GLProgram * @constructor */ GLProgram : function () {}, }; /** * @class Touch */ cc.Touch = { /** * @method getPreviousLocationInView * @return A value converted from C/C++ "cocos2d::Point" */ getPreviousLocationInView : function () {}, /** * @method getLocation * @return A value converted from C/C++ "cocos2d::Point" */ getLocation : function () {}, /** * @method getDelta * @return A value converted from C/C++ "cocos2d::Point" */ getDelta : function () {}, /** * @method getStartLocationInView * @return A value converted from C/C++ "cocos2d::Point" */ getStartLocationInView : function () {}, /** * @method getStartLocation * @return A value converted from C/C++ "cocos2d::Point" */ getStartLocation : function () {}, /** * @method getID * @return A value converted from C/C++ "int" */ getID : function () {}, /** * @method setTouchInfo * @param {int} * @param {float} * @param {float} */ setTouchInfo : function () {}, /** * @method getLocationInView * @return A value converted from C/C++ "cocos2d::Point" */ getLocationInView : function () {}, /** * @method getPreviousLocation * @return A value converted from C/C++ "cocos2d::Point" */ getPreviousLocation : function () {}, /** * @method Touch * @constructor */ Touch : function () {}, }; /** * @class Texture2D */ cc.Texture2D = { /** * @method getShaderProgram * @return A value converted from C/C++ "cocos2d::GLProgram*" */ getShaderProgram : function () {}, /** * @method getMaxT * @return A value converted from C/C++ "GLfloat" */ getMaxT : function () {}, /** * @method getStringForFormat * @return A value converted from C/C++ "const char*" */ getStringForFormat : function () {}, /** * @method setShaderProgram * @param {cocos2d::GLProgram*} */ setShaderProgram : function () {}, /** * @method getMaxS * @return A value converted from C/C++ "GLfloat" */ getMaxS : function () {}, /** * @method hasPremultipliedAlpha * @return A value converted from C/C++ "bool" */ hasPremultipliedAlpha : function () {}, /** * @method initWithMipmaps * @return A value converted from C/C++ "bool" * @param {cocos2d::MipmapInfo*} * @param {int} * @param {cocos2d::Texture2D::PixelFormat} * @param {int} * @param {int} */ initWithMipmaps : function () {}, /** * @method getPixelsHigh * @return A value converted from C/C++ "int" */ getPixelsHigh : function () {}, /** * @method getName * @return A value converted from C/C++ "GLuint" */ getName : function () {}, /** * @method setMaxT * @param {GLfloat} */ setMaxT : function () {}, /** * @method drawInRect * @param {const cocos2d::Rect&} */ drawInRect : function () {}, /** * @method getContentSize * @return A value converted from C/C++ "cocos2d::Size" */ getContentSize : function () {}, /** * @method setAliasTexParameters */ setAliasTexParameters : function () {}, /** * @method setAntiAliasTexParameters */ setAntiAliasTexParameters : function () {}, /** * @method generateMipmap */ generateMipmap : function () {}, /** * @method getDescription * @return A value converted from C/C++ "std::string" */ getDescription : function () {}, /** * @method getPixelFormat * @return A value converted from C/C++ "cocos2d::Texture2D::PixelFormat" */ getPixelFormat : function () {}, /** * @method getContentSizeInPixels * @return A value converted from C/C++ "const cocos2d::Size&" */ getContentSizeInPixels : function () {}, /** * @method getPixelsWide * @return A value converted from C/C++ "int" */ getPixelsWide : function () {}, /** * @method drawAtPoint * @param {const cocos2d::Point&} */ drawAtPoint : function () {}, /** * @method hasMipmaps * @return A value converted from C/C++ "bool" */ hasMipmaps : function () {}, /** * @method setMaxS * @param {GLfloat} */ setMaxS : function () {}, /** * @method setDefaultAlphaPixelFormat * @param {cocos2d::Texture2D::PixelFormat} */ setDefaultAlphaPixelFormat : function () {}, /** * @method getDefaultAlphaPixelFormat * @return A value converted from C/C++ "cocos2d::Texture2D::PixelFormat" */ getDefaultAlphaPixelFormat : function () {}, /** * @method PVRImagesHavePremultipliedAlpha * @param {bool} */ PVRImagesHavePremultipliedAlpha : function () {}, /** * @method Texture2D * @constructor */ Texture2D : function () {}, }; /** * @class Node */ cc.Node = { /** * @method removeComponent * @return A value converted from C/C++ "bool" * @param {const std::string&} */ removeComponent : function () {}, /** * @method setPhysicsBody * @param {cocos2d::PhysicsBody*} */ setPhysicsBody : function () {}, /** * @method getDescription * @return A value converted from C/C++ "std::string" */ getDescription : function () {}, /** * @method setOpacityModifyRGB * @param {bool} */ setOpacityModifyRGB : function () {}, /** * @method setCascadeOpacityEnabled * @param {bool} */ setCascadeOpacityEnabled : function () {}, /** * @method pause */ pause : function () {}, /** * @method convertToWorldSpaceAR * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToWorldSpaceAR : function () {}, /** * @method isIgnoreAnchorPointForPosition * @return A value converted from C/C++ "bool" */ isIgnoreAnchorPointForPosition : function () {}, /** * @method updateDisplayedOpacity * @param {GLubyte} */ updateDisplayedOpacity : function () {}, /** * @method setRotation * @param {float} */ setRotation : function () {}, /** * @method setLocalZOrder * @param {int} */ setLocalZOrder : function () {}, /** * @method setScaleY * @param {float} */ setScaleY : function () {}, /** * @method setScaleX * @param {float} */ setScaleX : function () {}, /** * @method getColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getColor : function () {}, /** * @method removeAllComponents */ removeAllComponents : function () {}, /** * @method _setLocalZOrder * @param {int} */ _setLocalZOrder : function () {}, /** * @method getTag * @return A value converted from C/C++ "int" */ getTag : function () {}, /** * @method getNodeToWorldAffineTransform * @return A value converted from C/C++ "cocos2d::AffineTransform" */ getNodeToWorldAffineTransform : function () {}, /** * @method getNodeToWorldTransform * @return A value converted from C/C++ "kmMat4" */ getNodeToWorldTransform : function () {}, /** * @method removeChild * @param {cocos2d::Node*} * @param {bool} */ removeChild : function () {}, /** * @method convertToWorldSpace * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToWorldSpace : function () {}, /** * @method getScene * @return A value converted from C/C++ "cocos2d::Scene*" */ getScene : function () {}, /** * @method getEventDispatcher * @return A value converted from C/C++ "cocos2d::EventDispatcher*" */ getEventDispatcher : function () {}, /** * @method setSkewX * @param {float} */ setSkewX : function () {}, /** * @method setSkewY * @param {float} */ setSkewY : function () {}, /** * @method getOpacity * @return A value converted from C/C++ "GLubyte" */ getOpacity : function () {}, /** * @method convertTouchToNodeSpace * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ convertTouchToNodeSpace : function () {}, /** * @method getRotationX * @return A value converted from C/C++ "float" */ getRotationX : function () {}, /** * @method getRotationY * @return A value converted from C/C++ "float" */ getRotationY : function () {}, /** * @method getNodeToParentAffineTransform * @return A value converted from C/C++ "cocos2d::AffineTransform" */ getNodeToParentAffineTransform : function () {}, /** * @method isCascadeOpacityEnabled * @return A value converted from C/C++ "bool" */ isCascadeOpacityEnabled : function () {}, /** * @method setParent * @param {cocos2d::Node*} */ setParent : function () {}, /** * @method getNodeToParentTransform * @return A value converted from C/C++ "const kmMat4&" */ getNodeToParentTransform : function () {}, /** * @method resume */ resume : function () {}, /** * @method getPhysicsBody * @return A value converted from C/C++ "cocos2d::PhysicsBody*" */ getPhysicsBody : function () {}, /** * @method stopActionByTag * @param {int} */ stopActionByTag : function () {}, /** * @method reorderChild * @param {cocos2d::Node*} * @param {int} */ reorderChild : function () {}, /** * @method ignoreAnchorPointForPosition * @param {bool} */ ignoreAnchorPointForPosition : function () {}, /** * @method setColor * @param {const cocos2d::Color3B&} */ setColor : function () {}, /** * @method setPositionY * @param {float} */ setPositionY : function () {}, /** * @method setPositionX * @param {float} */ setPositionX : function () {}, /** * @method setNodeToParentTransform * @param {const kmMat4&} */ setNodeToParentTransform : function () {}, /** * @method getAnchorPoint * @return A value converted from C/C++ "const cocos2d::Point&" */ getAnchorPoint : function () {}, /** * @method getNumberOfRunningActions * @return A value converted from C/C++ "ssize_t" */ getNumberOfRunningActions : function () {}, /** * @method updateTransform */ updateTransform : function () {}, /** * @method isVisible * @return A value converted from C/C++ "bool" */ isVisible : function () {}, /** * @method getChildrenCount * @return A value converted from C/C++ "ssize_t" */ getChildrenCount : function () {}, /** * @method convertToNodeSpaceAR * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToNodeSpaceAR : function () {}, /** * @method addComponent * @return A value converted from C/C++ "bool" * @param {cocos2d::Component*} */ addComponent : function () {}, /** * @method visit */ visit : function () {}, /** * @method setShaderProgram * @param {cocos2d::GLProgram*} */ setShaderProgram : function () {}, /** * @method getRotation * @return A value converted from C/C++ "float" */ getRotation : function () {}, /** * @method getLocalZOrder * @return A value converted from C/C++ "int" */ getLocalZOrder : function () {}, /** * @method getAnchorPointInPoints * @return A value converted from C/C++ "const cocos2d::Point&" */ getAnchorPointInPoints : function () {}, /** * @method runAction * @return A value converted from C/C++ "cocos2d::Action*" * @param {cocos2d::Action*} */ runAction : function () {}, /** * @method transform */ transform : function () {}, /** * @method setVertexZ * @param {float} */ setVertexZ : function () {}, /** * @method setScheduler * @param {cocos2d::Scheduler*} */ setScheduler : function () {}, /** * @method stopAllActions */ stopAllActions : function () {}, /** * @method getSkewX * @return A value converted from C/C++ "float" */ getSkewX : function () {}, /** * @method getSkewY * @return A value converted from C/C++ "float" */ getSkewY : function () {}, /** * @method getDisplayedColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getDisplayedColor : function () {}, /** * @method getActionByTag * @return A value converted from C/C++ "cocos2d::Action*" * @param {int} */ getActionByTag : function () {}, /** * @method setRotationX * @param {float} */ setRotationX : function () {}, /** * @method setRotationY * @param {float} */ setRotationY : function () {}, /** * @method getDisplayedOpacity * @return A value converted from C/C++ "GLubyte" */ getDisplayedOpacity : function () {}, /** * @method getParentToNodeAffineTransform * @return A value converted from C/C++ "cocos2d::AffineTransform" */ getParentToNodeAffineTransform : function () {}, /** * @method getOrderOfArrival * @return A value converted from C/C++ "int" */ getOrderOfArrival : function () {}, /** * @method setActionManager * @param {cocos2d::ActionManager*} */ setActionManager : function () {}, /** * @method isRunning * @return A value converted from C/C++ "bool" */ isRunning : function () {}, /** * @method getPositionY * @return A value converted from C/C++ "float" */ getPositionY : function () {}, /** * @method getPositionX * @return A value converted from C/C++ "float" */ getPositionX : function () {}, /** * @method removeChildByTag * @param {int} * @param {bool} */ removeChildByTag : function () {}, /** * @method updateDisplayedColor * @param {const cocos2d::Color3B&} */ updateDisplayedColor : function () {}, /** * @method setVisible * @param {bool} */ setVisible : function () {}, /** * @method getParentToNodeTransform * @return A value converted from C/C++ "const kmMat4&" */ getParentToNodeTransform : function () {}, /** * @method getVertexZ * @return A value converted from C/C++ "float" */ getVertexZ : function () {}, /** * @method setGlobalZOrder * @param {float} */ setGlobalZOrder : function () {}, /** * @method getChildByTag * @return A value converted from C/C++ "cocos2d::Node*" * @param {int} */ getChildByTag : function () {}, /** * @method setOrderOfArrival * @param {int} */ setOrderOfArrival : function () {}, /** * @method getScaleY * @return A value converted from C/C++ "float" */ getScaleY : function () {}, /** * @method getScaleX * @return A value converted from C/C++ "float" */ getScaleX : function () {}, /** * @method getWorldToNodeAffineTransform * @return A value converted from C/C++ "cocos2d::AffineTransform" */ getWorldToNodeAffineTransform : function () {}, /** * @method setCascadeColorEnabled * @param {bool} */ setCascadeColorEnabled : function () {}, /** * @method setOpacity * @param {GLubyte} */ setOpacity : function () {}, /** * @method cleanup */ cleanup : function () {}, /** * @method getComponent * @return A value converted from C/C++ "cocos2d::Component*" * @param {const std::string&} */ getComponent : function () {}, /** * @method getContentSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getContentSize : function () {}, /** * @method getBoundingBox * @return A value converted from C/C++ "cocos2d::Rect" */ getBoundingBox : function () {}, /** * @method updatePhysicsTransform * @return A value converted from C/C++ "bool" */ updatePhysicsTransform : function () {}, /** * @method setEventDispatcher * @param {cocos2d::EventDispatcher*} */ setEventDispatcher : function () {}, /** * @method getGlobalZOrder * @return A value converted from C/C++ "float" */ getGlobalZOrder : function () {}, /** * @method draw */ draw : function () {}, /** * @method transformAncestors */ transformAncestors : function () {}, /** * @method setUserObject * @param {cocos2d::Object*} */ setUserObject : function () {}, /** * @method convertTouchToNodeSpaceAR * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ convertTouchToNodeSpaceAR : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method sortAllChildren */ sortAllChildren : function () {}, /** * @method getWorldToNodeTransform * @return A value converted from C/C++ "kmMat4" */ getWorldToNodeTransform : function () {}, /** * @method getScale * @return A value converted from C/C++ "float" */ getScale : function () {}, /** * @method convertToNodeSpace * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToNodeSpace : function () {}, /** * @method setTag * @param {int} */ setTag : function () {}, /** * @method isCascadeColorEnabled * @return A value converted from C/C++ "bool" */ isCascadeColorEnabled : function () {}, /** * @method isOpacityModifyRGB * @return A value converted from C/C++ "bool" */ isOpacityModifyRGB : function () {}, /** * @method stopAction * @param {cocos2d::Action*} */ stopAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Node*" */ create : function () {}, }; /** * @class __NodeRGBA */ cc.NodeRGBA = { }; /** * @class SpriteFrame */ cc.SpriteFrame = { /** * @method clone * @return A value converted from C/C++ "cocos2d::SpriteFrame*" */ clone : function () {}, /** * @method setRotated * @param {bool} */ setRotated : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method setRectInPixels * @param {const cocos2d::Rect&} */ setRectInPixels : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method getRect * @return A value converted from C/C++ "const cocos2d::Rect&" */ getRect : function () {}, /** * @method setOffsetInPixels * @param {const cocos2d::Point&} */ setOffsetInPixels : function () {}, /** * @method getRectInPixels * @return A value converted from C/C++ "const cocos2d::Rect&" */ getRectInPixels : function () {}, /** * @method setOriginalSize * @param {const cocos2d::Size&} */ setOriginalSize : function () {}, /** * @method getOriginalSizeInPixels * @return A value converted from C/C++ "const cocos2d::Size&" */ getOriginalSizeInPixels : function () {}, /** * @method setOriginalSizeInPixels * @param {const cocos2d::Size&} */ setOriginalSizeInPixels : function () {}, /** * @method setOffset * @param {const cocos2d::Point&} */ setOffset : function () {}, /** * @method getOffset * @return A value converted from C/C++ "const cocos2d::Point&" */ getOffset : function () {}, /** * @method isRotated * @return A value converted from C/C++ "bool" */ isRotated : function () {}, /** * @method setRect * @param {const cocos2d::Rect&} */ setRect : function () {}, /** * @method getOffsetInPixels * @return A value converted from C/C++ "const cocos2d::Point&" */ getOffsetInPixels : function () {}, /** * @method getOriginalSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getOriginalSize : function () {}, }; /** * @class AnimationFrame */ cc.AnimationFrame = { /** * @method setSpriteFrame * @param {cocos2d::SpriteFrame*} */ setSpriteFrame : function () {}, /** * @method setDelayUnits * @param {float} */ setDelayUnits : function () {}, /** * @method clone * @return A value converted from C/C++ "cocos2d::AnimationFrame*" */ clone : function () {}, /** * @method getSpriteFrame * @return A value converted from C/C++ "cocos2d::SpriteFrame*" */ getSpriteFrame : function () {}, /** * @method getDelayUnits * @return A value converted from C/C++ "float" */ getDelayUnits : function () {}, /** * @method setUserInfo * @param {const cocos2d::ValueMap&} */ setUserInfo : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::AnimationFrame*" * @param {cocos2d::SpriteFrame*} * @param {float} * @param {const cocos2d::ValueMap&} */ create : function () {}, }; /** * @class Animation */ cc.Animation = { /** * @method getLoops * @return A value converted from C/C++ "unsigned int" */ getLoops : function () {}, /** * @method addSpriteFrame * @param {cocos2d::SpriteFrame*} */ addSpriteFrame : function () {}, /** * @method setRestoreOriginalFrame * @param {bool} */ setRestoreOriginalFrame : function () {}, /** * @method clone * @return A value converted from C/C++ "cocos2d::Animation*" */ clone : function () {}, /** * @method getDuration * @return A value converted from C/C++ "float" */ getDuration : function () {}, /** * @method setFrames * @param {const cocos2d::Vector&} */ setFrames : function () {}, /** * @method getFrames * @return A value converted from C/C++ "const cocos2d::Vector&" */ getFrames : function () {}, /** * @method setLoops * @param {unsigned int} */ setLoops : function () {}, /** * @method setDelayPerUnit * @param {float} */ setDelayPerUnit : function () {}, /** * @method addSpriteFrameWithFile * @param {const std::string&} */ addSpriteFrameWithFile : function () {}, /** * @method getTotalDelayUnits * @return A value converted from C/C++ "float" */ getTotalDelayUnits : function () {}, /** * @method getDelayPerUnit * @return A value converted from C/C++ "float" */ getDelayPerUnit : function () {}, /** * @method getRestoreOriginalFrame * @return A value converted from C/C++ "bool" */ getRestoreOriginalFrame : function () {}, /** * @method addSpriteFrameWithTexture * @param {cocos2d::Texture2D*} * @param {const cocos2d::Rect&} */ addSpriteFrameWithTexture : function () {}, }; /** * @class ActionInterval */ cc.ActionInterval = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getElapsed * @return A value converted from C/C++ "float" */ getElapsed : function () {}, }; /** * @class Sequence */ cc.Sequence = { }; /** * @class Repeat */ cc.Repeat = { /** * @method setInnerAction * @param {cocos2d::FiniteTimeAction*} */ setInnerAction : function () {}, /** * @method getInnerAction * @return A value converted from C/C++ "cocos2d::FiniteTimeAction*" */ getInnerAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Repeat*" * @param {cocos2d::FiniteTimeAction*} * @param {unsigned int} */ create : function () {}, }; /** * @class RepeatForever */ cc.RepeatForever = { /** * @method setInnerAction * @param {cocos2d::ActionInterval*} */ setInnerAction : function () {}, /** * @method getInnerAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ getInnerAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::RepeatForever*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class Spawn */ cc.Spawn = { }; /** * @class RotateTo */ cc.RotateTo = { }; /** * @class RotateBy */ cc.RotateBy = { }; /** * @class MoveBy */ cc.MoveBy = { /** * @method create * @return A value converted from C/C++ "cocos2d::MoveBy*" * @param {float} * @param {const cocos2d::Point&} */ create : function () {}, }; /** * @class MoveTo */ cc.MoveTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::MoveTo*" * @param {float} * @param {const cocos2d::Point&} */ create : function () {}, }; /** * @class SkewTo */ cc.SkewTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::SkewTo*" * @param {float} * @param {float} * @param {float} */ create : function () {}, }; /** * @class SkewBy */ cc.SkewBy = { /** * @method create * @return A value converted from C/C++ "cocos2d::SkewBy*" * @param {float} * @param {float} * @param {float} */ create : function () {}, }; /** * @class JumpBy */ cc.JumpBy = { /** * @method create * @return A value converted from C/C++ "cocos2d::JumpBy*" * @param {float} * @param {const cocos2d::Point&} * @param {float} * @param {int} */ create : function () {}, }; /** * @class JumpTo */ cc.JumpTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::JumpTo*" * @param {float} * @param {const cocos2d::Point&} * @param {float} * @param {int} */ create : function () {}, }; /** * @class BezierBy */ cc.BezierBy = { }; /** * @class BezierTo */ cc.BezierTo = { }; /** * @class ScaleTo */ cc.ScaleTo = { }; /** * @class ScaleBy */ cc.ScaleBy = { }; /** * @class Blink */ cc.Blink = { /** * @method create * @return A value converted from C/C++ "cocos2d::Blink*" * @param {float} * @param {int} */ create : function () {}, }; /** * @class FadeIn */ cc.FadeIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeIn*" * @param {float} */ create : function () {}, }; /** * @class FadeOut */ cc.FadeOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOut*" * @param {float} */ create : function () {}, }; /** * @class FadeTo */ cc.FadeTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeTo*" * @param {float} * @param {GLubyte} */ create : function () {}, }; /** * @class TintTo */ cc.TintTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::TintTo*" * @param {float} * @param {GLubyte} * @param {GLubyte} * @param {GLubyte} */ create : function () {}, }; /** * @class TintBy */ cc.TintBy = { /** * @method create * @return A value converted from C/C++ "cocos2d::TintBy*" * @param {float} * @param {GLshort} * @param {GLshort} * @param {GLshort} */ create : function () {}, }; /** * @class DelayTime */ cc.DelayTime = { /** * @method create * @return A value converted from C/C++ "cocos2d::DelayTime*" * @param {float} */ create : function () {}, }; /** * @class Animate */ cc.Animate = { /** * @method setAnimation * @param {cocos2d::Animation*} */ setAnimation : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Animate*" * @param {cocos2d::Animation*} */ create : function () {}, }; /** * @class TargetedAction */ cc.TargetedAction = { /** * @method setForcedTarget * @param {cocos2d::Node*} */ setForcedTarget : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TargetedAction*" * @param {cocos2d::Node*} * @param {cocos2d::FiniteTimeAction*} */ create : function () {}, }; /** * @class ActionCamera */ cc.ActionCamera = { /** * @method getEye * @return A value converted from C/C++ "const kmVec3&" */ getEye : function () {}, /** * @method setUp * @param {const kmVec3&} */ setUp : function () {}, /** * @method getCenter * @return A value converted from C/C++ "const kmVec3&" */ getCenter : function () {}, /** * @method setCenter * @param {const kmVec3&} */ setCenter : function () {}, /** * @method getUp * @return A value converted from C/C++ "const kmVec3&" */ getUp : function () {}, /** * @method ActionCamera * @constructor */ ActionCamera : function () {}, }; /** * @class OrbitCamera */ cc.OrbitCamera = { /** * @method sphericalRadius * @param {float*} * @param {float*} * @param {float*} */ sphericalRadius : function () {}, /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} */ initWithDuration : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::OrbitCamera*" * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} */ create : function () {}, /** * @method OrbitCamera * @constructor */ OrbitCamera : function () {}, }; /** * @class ActionManager */ cc.ActionManager = { /** * @method getActionByTag * @return A value converted from C/C++ "cocos2d::Action*" * @param {int} * @param {const cocos2d::Node*} */ getActionByTag : function () {}, /** * @method removeActionByTag * @param {int} * @param {cocos2d::Node*} */ removeActionByTag : function () {}, /** * @method removeAllActions */ removeAllActions : function () {}, /** * @method addAction * @param {cocos2d::Action*} * @param {cocos2d::Node*} * @param {bool} */ addAction : function () {}, /** * @method resumeTarget * @param {cocos2d::Node*} */ resumeTarget : function () {}, /** * @method getNumberOfRunningActionsInTarget * @return A value converted from C/C++ "ssize_t" * @param {const cocos2d::Node*} */ getNumberOfRunningActionsInTarget : function () {}, /** * @method removeAllActionsFromTarget * @param {cocos2d::Node*} */ removeAllActionsFromTarget : function () {}, /** * @method resumeTargets * @param {const cocos2d::Vector&} */ resumeTargets : function () {}, /** * @method removeAction * @param {cocos2d::Action*} */ removeAction : function () {}, /** * @method pauseTarget * @param {cocos2d::Node*} */ pauseTarget : function () {}, /** * @method pauseAllRunningActions * @return A value converted from C/C++ "cocos2d::Vector" */ pauseAllRunningActions : function () {}, /** * @method ActionManager * @constructor */ ActionManager : function () {}, }; /** * @class ActionEase */ cc.ActionEase = { /** * @method getInnerAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ getInnerAction : function () {}, }; /** * @class EaseRateAction */ cc.EaseRateAction = { /** * @method setRate * @param {float} */ setRate : function () {}, /** * @method getRate * @return A value converted from C/C++ "float" */ getRate : function () {}, }; /** * @class EaseIn */ cc.EaseIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseIn*" * @param {cocos2d::ActionInterval*} * @param {float} */ create : function () {}, }; /** * @class EaseOut */ cc.EaseOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseOut*" * @param {cocos2d::ActionInterval*} * @param {float} */ create : function () {}, }; /** * @class EaseInOut */ cc.EaseInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseInOut*" * @param {cocos2d::ActionInterval*} * @param {float} */ create : function () {}, }; /** * @class EaseExponentialIn */ cc.EaseExponentialIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseExponentialIn*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseExponentialOut */ cc.EaseExponentialOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseExponentialOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseExponentialInOut */ cc.EaseExponentialInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseExponentialInOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseSineIn */ cc.EaseSineIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseSineIn*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseSineOut */ cc.EaseSineOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseSineOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseSineInOut */ cc.EaseSineInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseSineInOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseElastic */ cc.EaseElastic = { /** * @method setPeriod * @param {float} */ setPeriod : function () {}, /** * @method getPeriod * @return A value converted from C/C++ "float" */ getPeriod : function () {}, }; /** * @class EaseElasticIn */ cc.EaseElasticIn = { }; /** * @class EaseElasticOut */ cc.EaseElasticOut = { }; /** * @class EaseElasticInOut */ cc.EaseElasticInOut = { }; /** * @class EaseBounce */ cc.EaseBounce = { /** * @method bounceTime * @return A value converted from C/C++ "float" * @param {float} */ bounceTime : function () {}, }; /** * @class EaseBounceIn */ cc.EaseBounceIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBounceIn*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBounceOut */ cc.EaseBounceOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBounceOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBounceInOut */ cc.EaseBounceInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBounceInOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBackIn */ cc.EaseBackIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBackIn*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBackOut */ cc.EaseBackOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBackOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBackInOut */ cc.EaseBackInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBackInOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class ActionInstant */ cc.ActionInstant = { }; /** * @class Show */ cc.Show = { /** * @method create * @return A value converted from C/C++ "cocos2d::Show*" */ create : function () {}, }; /** * @class Hide */ cc.Hide = { /** * @method create * @return A value converted from C/C++ "cocos2d::Hide*" */ create : function () {}, }; /** * @class ToggleVisibility */ cc.ToggleVisibility = { /** * @method create * @return A value converted from C/C++ "cocos2d::ToggleVisibility*" */ create : function () {}, }; /** * @class RemoveSelf */ cc.RemoveSelf = { /** * @method create * @return A value converted from C/C++ "cocos2d::RemoveSelf*" */ create : function () {}, }; /** * @class FlipX */ cc.FlipX = { /** * @method create * @return A value converted from C/C++ "cocos2d::FlipX*" * @param {bool} */ create : function () {}, }; /** * @class FlipY */ cc.FlipY = { /** * @method create * @return A value converted from C/C++ "cocos2d::FlipY*" * @param {bool} */ create : function () {}, }; /** * @class Place */ cc.Place = { /** * @method create * @return A value converted from C/C++ "cocos2d::Place*" * @param {const cocos2d::Point&} */ create : function () {}, }; /** * @class CallFunc */ cc.CallFunc = { /** * @method execute */ execute : function () {}, /** * @method getTargetCallback * @return A value converted from C/C++ "cocos2d::Object*" */ getTargetCallback : function () {}, /** * @method setTargetCallback * @param {cocos2d::Object*} */ setTargetCallback : function () {}, }; /** * @class GridAction */ cc.GridAction = { /** * @method getGrid * @return A value converted from C/C++ "cocos2d::GridBase*" */ getGrid : function () {}, }; /** * @class Grid3DAction */ cc.Grid3DAction = { /** * @method getGrid * @return A value converted from C/C++ "cocos2d::GridBase*" */ getGrid : function () {}, }; /** * @class TiledGrid3DAction */ cc.TiledGrid3DAction = { /** * @method getGrid * @return A value converted from C/C++ "cocos2d::GridBase*" */ getGrid : function () {}, }; /** * @class StopGrid */ cc.StopGrid = { /** * @method create * @return A value converted from C/C++ "cocos2d::StopGrid*" */ create : function () {}, }; /** * @class ReuseGrid */ cc.ReuseGrid = { /** * @method create * @return A value converted from C/C++ "cocos2d::ReuseGrid*" * @param {int} */ create : function () {}, }; /** * @class Waves3D */ cc.Waves3D = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Waves3D*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} */ create : function () {}, }; /** * @class FlipX3D */ cc.FlipX3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::FlipX3D*" * @param {float} */ create : function () {}, }; /** * @class FlipY3D */ cc.FlipY3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::FlipY3D*" * @param {float} */ create : function () {}, /** * @method FlipY3D * @constructor */ FlipY3D : function () {}, }; /** * @class Lens3D */ cc.Lens3D = { /** * @method setPosition * @param {const cocos2d::Point&} */ setPosition : function () {}, /** * @method setConcave * @param {bool} */ setConcave : function () {}, /** * @method setLensEffect * @param {float} */ setLensEffect : function () {}, /** * @method getPosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getPosition : function () {}, /** * @method getLensEffect * @return A value converted from C/C++ "float" */ getLensEffect : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Lens3D*" * @param {float} * @param {const cocos2d::Size&} * @param {const cocos2d::Point&} * @param {float} */ create : function () {}, }; /** * @class Ripple3D */ cc.Ripple3D = { /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method setPosition * @param {const cocos2d::Point&} */ setPosition : function () {}, /** * @method getPosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getPosition : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Ripple3D*" * @param {float} * @param {const cocos2d::Size&} * @param {const cocos2d::Point&} * @param {float} * @param {unsigned int} * @param {float} */ create : function () {}, }; /** * @class Shaky3D */ cc.Shaky3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::Shaky3D*" * @param {float} * @param {const cocos2d::Size&} * @param {int} * @param {bool} */ create : function () {}, /** * @method Shaky3D * @constructor */ Shaky3D : function () {}, }; /** * @class Liquid */ cc.Liquid = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Liquid*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} */ create : function () {}, /** * @method Liquid * @constructor */ Liquid : function () {}, }; /** * @class Waves */ cc.Waves = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Waves*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} * @param {bool} * @param {bool} */ create : function () {}, /** * @method Waves * @constructor */ Waves : function () {}, }; /** * @class Twirl */ cc.Twirl = { /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method setPosition * @param {const cocos2d::Point&} */ setPosition : function () {}, /** * @method getPosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getPosition : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Twirl*" * @param {float} * @param {const cocos2d::Size&} * @param {cocos2d::Point} * @param {unsigned int} * @param {float} */ create : function () {}, /** * @method Twirl * @constructor */ Twirl : function () {}, }; /** * @class PageTurn3D */ cc.PageTurn3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::PageTurn3D*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class ProgressTo */ cc.ProgressTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::ProgressTo*" * @param {float} * @param {float} */ create : function () {}, }; /** * @class ProgressFromTo */ cc.ProgressFromTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::ProgressFromTo*" * @param {float} * @param {float} * @param {float} */ create : function () {}, }; /** * @class ShakyTiles3D */ cc.ShakyTiles3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::ShakyTiles3D*" * @param {float} * @param {const cocos2d::Size&} * @param {int} * @param {bool} */ create : function () {}, }; /** * @class ShatteredTiles3D */ cc.ShatteredTiles3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::ShatteredTiles3D*" * @param {float} * @param {const cocos2d::Size&} * @param {int} * @param {bool} */ create : function () {}, }; /** * @class ShuffleTiles */ cc.ShuffleTiles = { /** * @method placeTile * @param {const cocos2d::Point&} * @param {cocos2d::Tile*} */ placeTile : function () {}, /** * @method shuffle * @param {unsigned int*} * @param {unsigned int} */ shuffle : function () {}, /** * @method getDelta * @return A value converted from C/C++ "cocos2d::Size" * @param {const cocos2d::Size&} */ getDelta : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ShuffleTiles*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} */ create : function () {}, }; /** * @class FadeOutTRTiles */ cc.FadeOutTRTiles = { /** * @method turnOnTile * @param {const cocos2d::Point&} */ turnOnTile : function () {}, /** * @method turnOffTile * @param {const cocos2d::Point&} */ turnOffTile : function () {}, /** * @method transformTile * @param {const cocos2d::Point&} * @param {float} */ transformTile : function () {}, /** * @method testFunc * @return A value converted from C/C++ "float" * @param {const cocos2d::Size&} * @param {float} */ testFunc : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOutTRTiles*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class FadeOutBLTiles */ cc.FadeOutBLTiles = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOutBLTiles*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class FadeOutUpTiles */ cc.FadeOutUpTiles = { /** * @method transformTile * @param {const cocos2d::Point&} * @param {float} */ transformTile : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOutUpTiles*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class FadeOutDownTiles */ cc.FadeOutDownTiles = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOutDownTiles*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class TurnOffTiles */ cc.TurnOffTiles = { /** * @method turnOnTile * @param {const cocos2d::Point&} */ turnOnTile : function () {}, /** * @method turnOffTile * @param {const cocos2d::Point&} */ turnOffTile : function () {}, /** * @method shuffle * @param {unsigned int*} * @param {unsigned int} */ shuffle : function () {}, }; /** * @class WavesTiles3D */ cc.WavesTiles3D = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::WavesTiles3D*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} */ create : function () {}, }; /** * @class JumpTiles3D */ cc.JumpTiles3D = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::JumpTiles3D*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} */ create : function () {}, }; /** * @class SplitRows */ cc.SplitRows = { /** * @method create * @return A value converted from C/C++ "cocos2d::SplitRows*" * @param {float} * @param {unsigned int} */ create : function () {}, }; /** * @class SplitCols */ cc.SplitCols = { /** * @method create * @return A value converted from C/C++ "cocos2d::SplitCols*" * @param {float} * @param {unsigned int} */ create : function () {}, }; /** * @class ActionTween */ cc.ActionTween = { /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {const std::string&} * @param {float} * @param {float} */ initWithDuration : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ActionTween*" * @param {float} * @param {const std::string&} * @param {float} * @param {float} */ create : function () {}, }; /** * @class CardinalSplineTo */ cc.CardinalSplineTo = { /** * @method getPoints * @return A value converted from C/C++ "cocos2d::PointArray*" */ getPoints : function () {}, /** * @method updatePosition * @param {cocos2d::Point&} */ updatePosition : function () {}, /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {cocos2d::PointArray*} * @param {float} */ initWithDuration : function () {}, /** * @method CardinalSplineTo * @constructor */ CardinalSplineTo : function () {}, }; /** * @class CardinalSplineBy */ cc.CardinalSplineBy = { /** * @method CardinalSplineBy * @constructor */ CardinalSplineBy : function () {}, }; /** * @class CatmullRomTo */ cc.CatmullRomTo = { /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {cocos2d::PointArray*} */ initWithDuration : function () {}, }; /** * @class CatmullRomBy */ cc.CatmullRomBy = { /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {cocos2d::PointArray*} */ initWithDuration : function () {}, }; /** * @class AtlasNode */ cc.AtlasNode = { /** * @method updateAtlasValues */ updateAtlasValues : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method setTextureAtlas * @param {cocos2d::TextureAtlas*} */ setTextureAtlas : function () {}, /** * @method getTextureAtlas * @return A value converted from C/C++ "cocos2d::TextureAtlas*" */ getTextureAtlas : function () {}, /** * @method getQuadsToDraw * @return A value converted from C/C++ "ssize_t" */ getQuadsToDraw : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method setQuadsToDraw * @param {ssize_t} */ setQuadsToDraw : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::AtlasNode*" * @param {const std::string&} * @param {int} * @param {int} * @param {int} */ create : function () {}, }; /** * @class DrawNode */ cc.DrawNode = { /** * @method drawQuadraticBezier * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {unsigned int} * @param {const cocos2d::Color4F&} */ drawQuadraticBezier : function () {}, /** * @method onDraw */ onDraw : function () {}, /** * @method clear */ clear : function () {}, /** * @method drawTriangle * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Color4F&} */ drawTriangle : function () {}, /** * @method drawDot * @param {const cocos2d::Point&} * @param {float} * @param {const cocos2d::Color4F&} */ drawDot : function () {}, /** * @method drawCubicBezier * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {unsigned int} * @param {const cocos2d::Color4F&} */ drawCubicBezier : function () {}, /** * @method drawSegment * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {float} * @param {const cocos2d::Color4F&} */ drawSegment : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::DrawNode*" */ create : function () {}, }; /** * @class LabelAtlas */ cc.LabelAtlas = { /** * @method setString * @param {const std::string&} */ setString : function () {}, /** * @method updateAtlasValues */ updateAtlasValues : function () {}, /** * @method getString * @return A value converted from C/C++ "const std::string&" */ getString : function () {}, }; /** * @class Director */ cc.Director = { /** * @method pause */ pause : function () {}, /** * @method setContentScaleFactor * @param {float} */ setContentScaleFactor : function () {}, /** * @method getContentScaleFactor * @return A value converted from C/C++ "float" */ getContentScaleFactor : function () {}, /** * @method getWinSizeInPixels * @return A value converted from C/C++ "cocos2d::Size" */ getWinSizeInPixels : function () {}, /** * @method getDeltaTime * @return A value converted from C/C++ "float" */ getDeltaTime : function () {}, /** * @method setGLDefaultValues */ setGLDefaultValues : function () {}, /** * @method setActionManager * @param {cocos2d::ActionManager*} */ setActionManager : function () {}, /** * @method setAlphaBlending * @param {bool} */ setAlphaBlending : function () {}, /** * @method popToRootScene */ popToRootScene : function () {}, /** * @method getNotificationNode * @return A value converted from C/C++ "cocos2d::Node*" */ getNotificationNode : function () {}, /** * @method getWinSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getWinSize : function () {}, /** * @method end */ end : function () {}, /** * @method getTextureCache * @return A value converted from C/C++ "cocos2d::TextureCache*" */ getTextureCache : function () {}, /** * @method isSendCleanupToScene * @return A value converted from C/C++ "bool" */ isSendCleanupToScene : function () {}, /** * @method getVisibleOrigin * @return A value converted from C/C++ "cocos2d::Point" */ getVisibleOrigin : function () {}, /** * @method mainLoop */ mainLoop : function () {}, /** * @method setDepthTest * @param {bool} */ setDepthTest : function () {}, /** * @method getFrameRate * @return A value converted from C/C++ "float" */ getFrameRate : function () {}, /** * @method getSecondsPerFrame * @return A value converted from C/C++ "float" */ getSecondsPerFrame : function () {}, /** * @method convertToUI * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToUI : function () {}, /** * @method setDefaultValues */ setDefaultValues : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setScheduler * @param {cocos2d::Scheduler*} */ setScheduler : function () {}, /** * @method startAnimation */ startAnimation : function () {}, /** * @method getRunningScene * @return A value converted from C/C++ "cocos2d::Scene*" */ getRunningScene : function () {}, /** * @method setViewport */ setViewport : function () {}, /** * @method stopAnimation */ stopAnimation : function () {}, /** * @method popToSceneStackLevel * @param {int} */ popToSceneStackLevel : function () {}, /** * @method resume */ resume : function () {}, /** * @method isNextDeltaTimeZero * @return A value converted from C/C++ "bool" */ isNextDeltaTimeZero : function () {}, /** * @method setOpenGLView * @param {cocos2d::EGLView*} */ setOpenGLView : function () {}, /** * @method convertToGL * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToGL : function () {}, /** * @method purgeCachedData */ purgeCachedData : function () {}, /** * @method getTotalFrames * @return A value converted from C/C++ "unsigned int" */ getTotalFrames : function () {}, /** * @method runWithScene * @param {cocos2d::Scene*} */ runWithScene : function () {}, /** * @method setNotificationNode * @param {cocos2d::Node*} */ setNotificationNode : function () {}, /** * @method drawScene */ drawScene : function () {}, /** * @method popScene */ popScene : function () {}, /** * @method isDisplayStats * @return A value converted from C/C++ "bool" */ isDisplayStats : function () {}, /** * @method setProjection * @param {cocos2d::Director::Projection} */ setProjection : function () {}, /** * @method getConsole * @return A value converted from C/C++ "cocos2d::Console*" */ getConsole : function () {}, /** * @method getZEye * @return A value converted from C/C++ "float" */ getZEye : function () {}, /** * @method setNextDeltaTimeZero * @param {bool} */ setNextDeltaTimeZero : function () {}, /** * @method getVisibleSize * @return A value converted from C/C++ "cocos2d::Size" */ getVisibleSize : function () {}, /** * @method getScheduler * @return A value converted from C/C++ "cocos2d::Scheduler*" */ getScheduler : function () {}, /** * @method pushScene * @param {cocos2d::Scene*} */ pushScene : function () {}, /** * @method getAnimationInterval * @return A value converted from C/C++ "double" */ getAnimationInterval : function () {}, /** * @method isPaused * @return A value converted from C/C++ "bool" */ isPaused : function () {}, /** * @method setDisplayStats * @param {bool} */ setDisplayStats : function () {}, /** * @method replaceScene * @param {cocos2d::Scene*} */ replaceScene : function () {}, /** * @method setAnimationInterval * @param {double} */ setAnimationInterval : function () {}, /** * @method getActionManager * @return A value converted from C/C++ "cocos2d::ActionManager*" */ getActionManager : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::Director*" */ getInstance : function () {}, }; /** * @class GridBase */ cc.GridBase = { /** * @method setGridSize * @param {const cocos2d::Size&} */ setGridSize : function () {}, /** * @method calculateVertexPoints */ calculateVertexPoints : function () {}, /** * @method afterDraw * @param {cocos2d::Node*} */ afterDraw : function () {}, /** * @method beforeDraw */ beforeDraw : function () {}, /** * @method isTextureFlipped * @return A value converted from C/C++ "bool" */ isTextureFlipped : function () {}, /** * @method getGridSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getGridSize : function () {}, /** * @method getStep * @return A value converted from C/C++ "const cocos2d::Point&" */ getStep : function () {}, /** * @method set2DProjection */ set2DProjection : function () {}, /** * @method setStep * @param {const cocos2d::Point&} */ setStep : function () {}, /** * @method setTextureFlipped * @param {bool} */ setTextureFlipped : function () {}, /** * @method blit */ blit : function () {}, /** * @method setActive * @param {bool} */ setActive : function () {}, /** * @method getReuseGrid * @return A value converted from C/C++ "int" */ getReuseGrid : function () {}, /** * @method setReuseGrid * @param {int} */ setReuseGrid : function () {}, /** * @method isActive * @return A value converted from C/C++ "bool" */ isActive : function () {}, /** * @method reuse */ reuse : function () {}, }; /** * @class Grid3D */ cc.Grid3D = { /** * @method Grid3D * @constructor */ Grid3D : function () {}, }; /** * @class TiledGrid3D */ cc.TiledGrid3D = { /** * @method TiledGrid3D * @constructor */ TiledGrid3D : function () {}, }; /** * @class Sprite */ cc.Sprite = { /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method setFlippedY * @param {bool} */ setFlippedY : function () {}, /** * @method setFlippedX * @param {bool} */ setFlippedX : function () {}, /** * @method getBatchNode * @return A value converted from C/C++ "cocos2d::SpriteBatchNode*" */ getBatchNode : function () {}, /** * @method getOffsetPosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getOffsetPosition : function () {}, /** * @method removeAllChildrenWithCleanup * @param {bool} */ removeAllChildrenWithCleanup : function () {}, /** * @method updateQuadVertices */ updateQuadVertices : function () {}, /** * @method updateTransform */ updateTransform : function () {}, /** * @method isFrameDisplayed * @return A value converted from C/C++ "bool" * @param {cocos2d::SpriteFrame*} */ isFrameDisplayed : function () {}, /** * @method getAtlasIndex * @return A value converted from C/C++ "ssize_t" */ getAtlasIndex : function () {}, /** * @method setBatchNode * @param {cocos2d::SpriteBatchNode*} */ setBatchNode : function () {}, /** * @method setDisplayFrameWithAnimationName * @param {const std::string&} * @param {ssize_t} */ setDisplayFrameWithAnimationName : function () {}, /** * @method setTextureAtlas * @param {cocos2d::TextureAtlas*} */ setTextureAtlas : function () {}, /** * @method getSpriteFrame * @return A value converted from C/C++ "cocos2d::SpriteFrame*" */ getSpriteFrame : function () {}, /** * @method isDirty * @return A value converted from C/C++ "bool" */ isDirty : function () {}, /** * @method setAtlasIndex * @param {ssize_t} */ setAtlasIndex : function () {}, /** * @method setDirty * @param {bool} */ setDirty : function () {}, /** * @method isTextureRectRotated * @return A value converted from C/C++ "bool" */ isTextureRectRotated : function () {}, /** * @method getTextureRect * @return A value converted from C/C++ "const cocos2d::Rect&" */ getTextureRect : function () {}, /** * @method getTextureAtlas * @return A value converted from C/C++ "cocos2d::TextureAtlas*" */ getTextureAtlas : function () {}, /** * @method isFlippedX * @return A value converted from C/C++ "bool" */ isFlippedX : function () {}, /** * @method isFlippedY * @return A value converted from C/C++ "bool" */ isFlippedY : function () {}, /** * @method setVertexRect * @param {const cocos2d::Rect&} */ setVertexRect : function () {}, /** * @method createWithSpriteFrameName * @return A value converted from C/C++ "cocos2d::Sprite*" * @param {const std::string&} */ createWithSpriteFrameName : function () {}, /** * @method createWithSpriteFrame * @return A value converted from C/C++ "cocos2d::Sprite*" * @param {cocos2d::SpriteFrame*} */ createWithSpriteFrame : function () {}, }; /** * @class LabelTTF */ cc.LabelTTF = { /** * @method enableShadow * @param {const cocos2d::Size&} * @param {float} * @param {float} * @param {bool} */ enableShadow : function () {}, /** * @method setDimensions * @param {const cocos2d::Size&} */ setDimensions : function () {}, /** * @method getFontSize * @return A value converted from C/C++ "float" */ getFontSize : function () {}, /** * @method getString * @return A value converted from C/C++ "const std::string&" */ getString : function () {}, /** * @method setTextDefinition * @param {const cocos2d::FontDefinition&} */ setTextDefinition : function () {}, /** * @method setFontName * @param {const std::string&} */ setFontName : function () {}, /** * @method getHorizontalAlignment * @return A value converted from C/C++ "cocos2d::TextHAlignment" */ getHorizontalAlignment : function () {}, /** * @method initWithStringAndTextDefinition * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {cocos2d::FontDefinition&} */ initWithStringAndTextDefinition : function () {}, /** * @method setString * @param {const std::string&} */ setString : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setFontFillColor * @param {const cocos2d::Color3B&} * @param {bool} */ setFontFillColor : function () {}, /** * @method enableStroke * @param {const cocos2d::Color3B&} * @param {float} * @param {bool} */ enableStroke : function () {}, /** * @method getDimensions * @return A value converted from C/C++ "const cocos2d::Size&" */ getDimensions : function () {}, /** * @method setVerticalAlignment * @param {cocos2d::TextVAlignment} */ setVerticalAlignment : function () {}, /** * @method setFontSize * @param {float} */ setFontSize : function () {}, /** * @method getVerticalAlignment * @return A value converted from C/C++ "cocos2d::TextVAlignment" */ getVerticalAlignment : function () {}, /** * @method getTextDefinition * @return A value converted from C/C++ "cocos2d::FontDefinition" */ getTextDefinition : function () {}, /** * @method getFontName * @return A value converted from C/C++ "const std::string&" */ getFontName : function () {}, /** * @method setHorizontalAlignment * @param {cocos2d::TextHAlignment} */ setHorizontalAlignment : function () {}, /** * @method disableShadow */ disableShadow : function () {}, /** * @method disableStroke */ disableStroke : function () {}, /** * @method createWithFontDefinition * @return A value converted from C/C++ "cocos2d::LabelTTF*" * @param {const std::string&} * @param {cocos2d::FontDefinition&} */ createWithFontDefinition : function () {}, /** * @method LabelTTF * @constructor */ LabelTTF : function () {}, }; /** * @class SpriteBatchNode */ cc.SpriteBatchNode = { /** * @method appendChild * @param {cocos2d::Sprite*} */ appendChild : function () {}, /** * @method reorderBatch * @param {bool} */ reorderBatch : function () {}, /** * @method initWithTexture * @return A value converted from C/C++ "bool" * @param {cocos2d::Texture2D*} * @param {ssize_t} */ initWithTexture : function () {}, /** * @method lowestAtlasIndexInChild * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::Sprite*} */ lowestAtlasIndexInChild : function () {}, /** * @method atlasIndexForChild * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::Sprite*} * @param {int} */ atlasIndexForChild : function () {}, /** * @method setTextureAtlas * @param {cocos2d::TextureAtlas*} */ setTextureAtlas : function () {}, /** * @method rebuildIndexInOrder * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::Sprite*} * @param {ssize_t} */ rebuildIndexInOrder : function () {}, /** * @method increaseAtlasCapacity */ increaseAtlasCapacity : function () {}, /** * @method getTextureAtlas * @return A value converted from C/C++ "cocos2d::TextureAtlas*" */ getTextureAtlas : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method highestAtlasIndexInChild * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::Sprite*} */ highestAtlasIndexInChild : function () {}, /** * @method removeChildAtIndex * @param {ssize_t} * @param {bool} */ removeChildAtIndex : function () {}, /** * @method removeSpriteFromAtlas * @param {cocos2d::Sprite*} */ removeSpriteFromAtlas : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::SpriteBatchNode*" * @param {const std::string&} * @param {ssize_t} */ create : function () {}, /** * @method createWithTexture * @return A value converted from C/C++ "cocos2d::SpriteBatchNode*" * @param {cocos2d::Texture2D*} * @param {ssize_t} */ createWithTexture : function () {}, /** * @method SpriteBatchNode * @constructor */ SpriteBatchNode : function () {}, }; /** * @class LabelBMFont */ cc.LabelBMFont = { /** * @method setLineBreakWithoutSpace * @param {bool} */ setLineBreakWithoutSpace : function () {}, /** * @method setScaleY * @param {float} */ setScaleY : function () {}, /** * @method setScaleX * @param {float} */ setScaleX : function () {}, /** * @method isOpacityModifyRGB * @return A value converted from C/C++ "bool" */ isOpacityModifyRGB : function () {}, /** * @method createFontChars */ createFontChars : function () {}, /** * @method getString * @return A value converted from C/C++ "const std::string&" */ getString : function () {}, /** * @method initWithString * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {const std::string&} * @param {float} * @param {cocos2d::TextHAlignment} * @param {cocos2d::Point} */ initWithString : function () {}, /** * @method setCString * @param {const char*} */ setCString : function () {}, /** * @method setScale * @param {float} */ setScale : function () {}, /** * @method setOpacityModifyRGB * @param {bool} */ setOpacityModifyRGB : function () {}, /** * @method setFntFile * @param {const std::string&} */ setFntFile : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method getFntFile * @return A value converted from C/C++ "const std::string&" */ getFntFile : function () {}, /** * @method updateLabel */ updateLabel : function () {}, /** * @method setAlignment * @param {cocos2d::TextHAlignment} */ setAlignment : function () {}, /** * @method setWidth * @param {float} */ setWidth : function () {}, /** * @method purgeCachedData */ purgeCachedData : function () {}, /** * @method LabelBMFont * @constructor */ LabelBMFont : function () {}, }; /** * @class Label */ cc.Label = { /** * @method getString * @return A value converted from C/C++ "const std::string&" */ getString : function () {}, /** * @method assignNewUTF16String * @param {unsigned short*} */ assignNewUTF16String : function () {}, /** * @method setLabelEffect * @param {cocos2d::LabelEffect} * @param {const cocos2d::Color3B&} */ setLabelEffect : function () {}, /** * @method getCommonLineHeight * @return A value converted from C/C++ "int" */ getCommonLineHeight : function () {}, /** * @method breakLineWithoutSpace * @return A value converted from C/C++ "bool" */ breakLineWithoutSpace : function () {}, /** * @method setWidth * @param {float} */ setWidth : function () {}, /** * @method getMaxLineWidth * @return A value converted from C/C++ "float" */ getMaxLineWidth : function () {}, /** * @method getScaleY * @return A value converted from C/C++ "float" */ getScaleY : function () {}, /** * @method getScaleX * @return A value converted from C/C++ "float" */ getScaleX : function () {}, /** * @method setString * @param {const std::string&} */ setString : function () {}, /** * @method getKernings * @return A value converted from C/C++ "int*" */ getKernings : function () {}, /** * @method setBMFontFilePath * @return A value converted from C/C++ "bool" * @param {const std::string&} */ setBMFontFilePath : function () {}, /** * @method recordPlaceholderInfo * @return A value converted from C/C++ "bool" * @param {int} */ recordPlaceholderInfo : function () {}, /** * @method getFontAtlas * @return A value converted from C/C++ "cocos2d::FontAtlas*" */ getFontAtlas : function () {}, /** * @method setLineBreakWithoutSpace * @param {bool} */ setLineBreakWithoutSpace : function () {}, /** * @method getStringNumLines * @return A value converted from C/C++ "int" */ getStringNumLines : function () {}, /** * @method getUTF16String * @return A value converted from C/C++ "unsigned short*" */ getUTF16String : function () {}, /** * @method getStringLenght * @return A value converted from C/C++ "int" */ getStringLenght : function () {}, /** * @method onDraw */ onDraw : function () {}, /** * @method getLetter * @return A value converted from C/C++ "cocos2d::Sprite*" * @param {int} */ getLetter : function () {}, /** * @method getTextAlignment * @return A value converted from C/C++ "cocos2d::TextHAlignment" */ getTextAlignment : function () {}, /** * @method setAlignment * @param {cocos2d::TextHAlignment} */ setAlignment : function () {}, /** * @method recordLetterInfo * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} * @param {unsigned short} * @param {int} */ recordLetterInfo : function () {}, /** * @method createWithBMFont * @return A value converted from C/C++ "cocos2d::Label*" * @param {const std::string&} * @param {const std::string&} * @param {const cocos2d::TextHAlignment&} * @param {int} */ createWithBMFont : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Label*" */ create : function () {}, }; /** * @class Layer */ cc.Layer = { /** * @method create * @return A value converted from C/C++ "cocos2d::Layer*" */ create : function () {}, }; /** * @class __LayerRGBA */ cc.LayerRGBA = { /** * @method create * @return A value converted from C/C++ "cocos2d::__LayerRGBA*" */ create : function () {}, }; /** * @class LayerColor */ cc.LayerColor = { /** * @method changeWidthAndHeight * @param {GLfloat} * @param {GLfloat} */ changeWidthAndHeight : function () {}, /** * @method onDraw */ onDraw : function () {}, /** * @method changeWidth * @param {GLfloat} */ changeWidth : function () {}, /** * @method changeHeight * @param {GLfloat} */ changeHeight : function () {}, }; /** * @class LayerGradient */ cc.LayerGradient = { /** * @method getStartColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getStartColor : function () {}, /** * @method isCompressedInterpolation * @return A value converted from C/C++ "bool" */ isCompressedInterpolation : function () {}, /** * @method getStartOpacity * @return A value converted from C/C++ "GLubyte" */ getStartOpacity : function () {}, /** * @method setVector * @param {const cocos2d::Point&} */ setVector : function () {}, /** * @method setStartOpacity * @param {GLubyte} */ setStartOpacity : function () {}, /** * @method setCompressedInterpolation * @param {bool} */ setCompressedInterpolation : function () {}, /** * @method setEndOpacity * @param {GLubyte} */ setEndOpacity : function () {}, /** * @method getVector * @return A value converted from C/C++ "const cocos2d::Point&" */ getVector : function () {}, /** * @method setEndColor * @param {const cocos2d::Color3B&} */ setEndColor : function () {}, /** * @method getEndColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getEndColor : function () {}, /** * @method getEndOpacity * @return A value converted from C/C++ "GLubyte" */ getEndOpacity : function () {}, /** * @method setStartColor * @param {const cocos2d::Color3B&} */ setStartColor : function () {}, }; /** * @class LayerMultiplex */ cc.LayerMultiplex = { /** * @method switchToAndReleaseMe * @param {int} */ switchToAndReleaseMe : function () {}, /** * @method addLayer * @param {cocos2d::Layer*} */ addLayer : function () {}, /** * @method switchTo * @param {int} */ switchTo : function () {}, }; /** * @class Scene */ cc.Scene = { /** * @method getPhysicsWorld * @return A value converted from C/C++ "cocos2d::PhysicsWorld*" */ getPhysicsWorld : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Scene*" */ create : function () {}, /** * @method createWithPhysics * @return A value converted from C/C++ "cocos2d::Scene*" */ createWithPhysics : function () {}, }; /** * @class TransitionEaseScene */ cc.TransitionEaseScene = { /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, }; /** * @class TransitionScene */ cc.TransitionScene = { /** * @method finish */ finish : function () {}, /** * @method hideOutShowIn */ hideOutShowIn : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionScene*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSceneOriented */ cc.TransitionSceneOriented = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSceneOriented*" * @param {float} * @param {cocos2d::Scene*} * @param {cocos2d::TransitionScene::Orientation} */ create : function () {}, }; /** * @class TransitionRotoZoom */ cc.TransitionRotoZoom = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionRotoZoom*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionJumpZoom */ cc.TransitionJumpZoom = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionJumpZoom*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionMoveInL */ cc.TransitionMoveInL = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionMoveInL*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionMoveInR */ cc.TransitionMoveInR = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionMoveInR*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionMoveInT */ cc.TransitionMoveInT = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionMoveInT*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionMoveInB */ cc.TransitionMoveInB = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionMoveInB*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSlideInL */ cc.TransitionSlideInL = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSlideInL*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSlideInR */ cc.TransitionSlideInR = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSlideInR*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSlideInB */ cc.TransitionSlideInB = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSlideInB*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSlideInT */ cc.TransitionSlideInT = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSlideInT*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionShrinkGrow */ cc.TransitionShrinkGrow = { /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionShrinkGrow*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFlipX */ cc.TransitionFlipX = { }; /** * @class TransitionFlipY */ cc.TransitionFlipY = { }; /** * @class TransitionFlipAngular */ cc.TransitionFlipAngular = { }; /** * @class TransitionZoomFlipX */ cc.TransitionZoomFlipX = { }; /** * @class TransitionZoomFlipY */ cc.TransitionZoomFlipY = { }; /** * @class TransitionZoomFlipAngular */ cc.TransitionZoomFlipAngular = { }; /** * @class TransitionFade */ cc.TransitionFade = { }; /** * @class TransitionCrossFade */ cc.TransitionCrossFade = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionCrossFade*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionTurnOffTiles */ cc.TransitionTurnOffTiles = { /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionTurnOffTiles*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSplitCols */ cc.TransitionSplitCols = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSplitCols*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSplitRows */ cc.TransitionSplitRows = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSplitRows*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFadeTR */ cc.TransitionFadeTR = { /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method actionWithSize * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {const cocos2d::Size&} */ actionWithSize : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionFadeTR*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFadeBL */ cc.TransitionFadeBL = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionFadeBL*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFadeUp */ cc.TransitionFadeUp = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionFadeUp*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFadeDown */ cc.TransitionFadeDown = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionFadeDown*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionPageTurn */ cc.TransitionPageTurn = { /** * @method actionWithSize * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {const cocos2d::Size&} */ actionWithSize : function () {}, /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {cocos2d::Scene*} * @param {bool} */ initWithDuration : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionPageTurn*" * @param {float} * @param {cocos2d::Scene*} * @param {bool} */ create : function () {}, /** * @method TransitionPageTurn * @constructor */ TransitionPageTurn : function () {}, }; /** * @class TransitionProgress */ cc.TransitionProgress = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgress*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, /** * @method TransitionProgress * @constructor */ TransitionProgress : function () {}, }; /** * @class TransitionProgressRadialCCW */ cc.TransitionProgressRadialCCW = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressRadialCCW*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressRadialCW */ cc.TransitionProgressRadialCW = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressRadialCW*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressHorizontal */ cc.TransitionProgressHorizontal = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressHorizontal*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressVertical */ cc.TransitionProgressVertical = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressVertical*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressInOut */ cc.TransitionProgressInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressInOut*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressOutIn */ cc.TransitionProgressOutIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressOutIn*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class MenuItem */ cc.MenuItem = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method activate */ activate : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method selected */ selected : function () {}, /** * @method isSelected * @return A value converted from C/C++ "bool" */ isSelected : function () {}, /** * @method unselected */ unselected : function () {}, /** * @method rect * @return A value converted from C/C++ "cocos2d::Rect" */ rect : function () {}, }; /** * @class MenuItemLabel */ cc.MenuItemLabel = { /** * @method getDisabledColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getDisabledColor : function () {}, /** * @method setString * @param {const std::string&} */ setString : function () {}, /** * @method setLabel * @param {cocos2d::Node*} */ setLabel : function () {}, /** * @method setDisabledColor * @param {const cocos2d::Color3B&} */ setDisabledColor : function () {}, /** * @method getLabel * @return A value converted from C/C++ "cocos2d::Node*" */ getLabel : function () {}, }; /** * @class MenuItemAtlasFont */ cc.MenuItemAtlasFont = { }; /** * @class MenuItemFont */ cc.MenuItemFont = { /** * @method setFontNameObj * @param {const std::string&} */ setFontNameObj : function () {}, /** * @method getFontSizeObj * @return A value converted from C/C++ "int" */ getFontSizeObj : function () {}, /** * @method getFontNameObj * @return A value converted from C/C++ "const std::string&" */ getFontNameObj : function () {}, /** * @method setFontSizeObj * @param {int} */ setFontSizeObj : function () {}, /** * @method setFontName * @param {const std::string&} */ setFontName : function () {}, /** * @method getFontSize * @return A value converted from C/C++ "int" */ getFontSize : function () {}, /** * @method getFontName * @return A value converted from C/C++ "const std::string&" */ getFontName : function () {}, /** * @method setFontSize * @param {int} */ setFontSize : function () {}, }; /** * @class MenuItemSprite */ cc.MenuItemSprite = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method selected */ selected : function () {}, /** * @method setNormalImage * @param {cocos2d::Node*} */ setNormalImage : function () {}, /** * @method setDisabledImage * @param {cocos2d::Node*} */ setDisabledImage : function () {}, /** * @method setSelectedImage * @param {cocos2d::Node*} */ setSelectedImage : function () {}, /** * @method getDisabledImage * @return A value converted from C/C++ "cocos2d::Node*" */ getDisabledImage : function () {}, /** * @method getSelectedImage * @return A value converted from C/C++ "cocos2d::Node*" */ getSelectedImage : function () {}, /** * @method getNormalImage * @return A value converted from C/C++ "cocos2d::Node*" */ getNormalImage : function () {}, /** * @method unselected */ unselected : function () {}, }; /** * @class MenuItemImage */ cc.MenuItemImage = { /** * @method setDisabledSpriteFrame * @param {cocos2d::SpriteFrame*} */ setDisabledSpriteFrame : function () {}, /** * @method setSelectedSpriteFrame * @param {cocos2d::SpriteFrame*} */ setSelectedSpriteFrame : function () {}, /** * @method setNormalSpriteFrame * @param {cocos2d::SpriteFrame*} */ setNormalSpriteFrame : function () {}, }; /** * @class MenuItemToggle */ cc.MenuItemToggle = { /** * @method setSubItems * @param {const cocos2d::Vector&} */ setSubItems : function () {}, /** * @method getSelectedIndex * @return A value converted from C/C++ "unsigned int" */ getSelectedIndex : function () {}, /** * @method addSubItem * @param {cocos2d::MenuItem*} */ addSubItem : function () {}, /** * @method getSelectedItem * @return A value converted from C/C++ "cocos2d::MenuItem*" */ getSelectedItem : function () {}, /** * @method setSelectedIndex * @param {unsigned int} */ setSelectedIndex : function () {}, }; /** * @class Menu */ cc.Menu = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method alignItemsVertically */ alignItemsVertically : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method alignItemsHorizontallyWithPadding * @param {float} */ alignItemsHorizontallyWithPadding : function () {}, /** * @method alignItemsVerticallyWithPadding * @param {float} */ alignItemsVerticallyWithPadding : function () {}, /** * @method alignItemsHorizontally */ alignItemsHorizontally : function () {}, }; /** * @class ClippingNode */ cc.ClippingNode = { /** * @method isInverted * @return A value converted from C/C++ "bool" */ isInverted : function () {}, /** * @method setInverted * @param {bool} */ setInverted : function () {}, /** * @method setStencil * @param {cocos2d::Node*} */ setStencil : function () {}, /** * @method getAlphaThreshold * @return A value converted from C/C++ "GLfloat" */ getAlphaThreshold : function () {}, /** * @method getStencil * @return A value converted from C/C++ "cocos2d::Node*" */ getStencil : function () {}, /** * @method setAlphaThreshold * @param {GLfloat} */ setAlphaThreshold : function () {}, }; /** * @class MotionStreak */ cc.MotionStreak = { /** * @method reset */ reset : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method tintWithColor * @param {const cocos2d::Color3B&} */ tintWithColor : function () {}, /** * @method setStartingPositionInitialized * @param {bool} */ setStartingPositionInitialized : function () {}, /** * @method isStartingPositionInitialized * @return A value converted from C/C++ "bool" */ isStartingPositionInitialized : function () {}, /** * @method isFastMode * @return A value converted from C/C++ "bool" */ isFastMode : function () {}, /** * @method setFastMode * @param {bool} */ setFastMode : function () {}, }; /** * @class ProgressTimer */ cc.ProgressTimer = { /** * @method isReverseDirection * @return A value converted from C/C++ "bool" */ isReverseDirection : function () {}, /** * @method setBarChangeRate * @param {const cocos2d::Point&} */ setBarChangeRate : function () {}, /** * @method getPercentage * @return A value converted from C/C++ "float" */ getPercentage : function () {}, /** * @method setSprite * @param {cocos2d::Sprite*} */ setSprite : function () {}, /** * @method getType * @return A value converted from C/C++ "cocos2d::ProgressTimer::Type" */ getType : function () {}, /** * @method getSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSprite : function () {}, /** * @method setMidpoint * @param {const cocos2d::Point&} */ setMidpoint : function () {}, /** * @method getBarChangeRate * @return A value converted from C/C++ "cocos2d::Point" */ getBarChangeRate : function () {}, /** * @method getMidpoint * @return A value converted from C/C++ "cocos2d::Point" */ getMidpoint : function () {}, /** * @method setPercentage * @param {float} */ setPercentage : function () {}, /** * @method setType * @param {cocos2d::ProgressTimer::Type} */ setType : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ProgressTimer*" * @param {cocos2d::Sprite*} */ create : function () {}, }; /** * @class RenderTexture */ cc.RenderTexture = { /** * @method clearStencil * @param {int} */ clearStencil : function () {}, /** * @method getClearDepth * @return A value converted from C/C++ "float" */ getClearDepth : function () {}, /** * @method getClearStencil * @return A value converted from C/C++ "int" */ getClearStencil : function () {}, /** * @method end */ end : function () {}, /** * @method setClearStencil * @param {int} */ setClearStencil : function () {}, /** * @method setSprite * @param {cocos2d::Sprite*} */ setSprite : function () {}, /** * @method getSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSprite : function () {}, /** * @method isAutoDraw * @return A value converted from C/C++ "bool" */ isAutoDraw : function () {}, /** * @method setClearFlags * @param {unsigned int} */ setClearFlags : function () {}, /** * @method begin */ begin : function () {}, /** * @method setAutoDraw * @param {bool} */ setAutoDraw : function () {}, /** * @method setClearColor * @param {const cocos2d::Color4F&} */ setClearColor : function () {}, /** * @method endToLua */ endToLua : function () {}, /** * @method clearDepth * @param {float} */ clearDepth : function () {}, /** * @method getClearColor * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getClearColor : function () {}, /** * @method clear * @param {float} * @param {float} * @param {float} * @param {float} */ clear : function () {}, /** * @method getClearFlags * @return A value converted from C/C++ "unsigned int" */ getClearFlags : function () {}, /** * @method newImage * @return A value converted from C/C++ "cocos2d::Image*" */ newImage : function () {}, /** * @method setClearDepth * @param {float} */ setClearDepth : function () {}, /** * @method RenderTexture * @constructor */ RenderTexture : function () {}, }; /** * @class NodeGrid */ cc.NodeGrid = { /** * @method setTarget * @param {cocos2d::Node*} */ setTarget : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::NodeGrid*" */ create : function () {}, }; /** * @class ParticleBatchNode */ cc.ParticleBatchNode = { /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method disableParticle * @param {int} */ disableParticle : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method setTextureAtlas * @param {cocos2d::TextureAtlas*} */ setTextureAtlas : function () {}, /** * @method removeAllChildrenWithCleanup * @param {bool} */ removeAllChildrenWithCleanup : function () {}, /** * @method getTextureAtlas * @return A value converted from C/C++ "cocos2d::TextureAtlas*" */ getTextureAtlas : function () {}, /** * @method insertChild * @param {cocos2d::ParticleSystem*} * @param {int} */ insertChild : function () {}, /** * @method visit */ visit : function () {}, /** * @method removeChildAtIndex * @param {int} * @param {bool} */ removeChildAtIndex : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleBatchNode*" * @param {const std::string&} * @param {int} */ create : function () {}, /** * @method createWithTexture * @return A value converted from C/C++ "cocos2d::ParticleBatchNode*" * @param {cocos2d::Texture2D*} * @param {int} */ createWithTexture : function () {}, }; /** * @class ParticleSystem */ cc.ParticleSystem = { /** * @method getStartSizeVar * @return A value converted from C/C++ "float" */ getStartSizeVar : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method isFull * @return A value converted from C/C++ "bool" */ isFull : function () {}, /** * @method getBatchNode * @return A value converted from C/C++ "cocos2d::ParticleBatchNode*" */ getBatchNode : function () {}, /** * @method getStartColor * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getStartColor : function () {}, /** * @method getPositionType * @return A value converted from C/C++ "cocos2d::ParticleSystem::PositionType" */ getPositionType : function () {}, /** * @method setPosVar * @param {const cocos2d::Point&} */ setPosVar : function () {}, /** * @method getEndSpin * @return A value converted from C/C++ "float" */ getEndSpin : function () {}, /** * @method setRotatePerSecondVar * @param {float} */ setRotatePerSecondVar : function () {}, /** * @method getStartSpinVar * @return A value converted from C/C++ "float" */ getStartSpinVar : function () {}, /** * @method getRadialAccelVar * @return A value converted from C/C++ "float" */ getRadialAccelVar : function () {}, /** * @method getEndSizeVar * @return A value converted from C/C++ "float" */ getEndSizeVar : function () {}, /** * @method setRotation * @param {float} */ setRotation : function () {}, /** * @method setTangentialAccel * @param {float} */ setTangentialAccel : function () {}, /** * @method setScaleY * @param {float} */ setScaleY : function () {}, /** * @method setScaleX * @param {float} */ setScaleX : function () {}, /** * @method getRadialAccel * @return A value converted from C/C++ "float" */ getRadialAccel : function () {}, /** * @method setStartRadius * @param {float} */ setStartRadius : function () {}, /** * @method setRotatePerSecond * @param {float} */ setRotatePerSecond : function () {}, /** * @method setEndSize * @param {float} */ setEndSize : function () {}, /** * @method getGravity * @return A value converted from C/C++ "const cocos2d::Point&" */ getGravity : function () {}, /** * @method getTangentialAccel * @return A value converted from C/C++ "float" */ getTangentialAccel : function () {}, /** * @method setEndRadius * @param {float} */ setEndRadius : function () {}, /** * @method getSpeed * @return A value converted from C/C++ "float" */ getSpeed : function () {}, /** * @method getAngle * @return A value converted from C/C++ "float" */ getAngle : function () {}, /** * @method setEndColor * @param {const cocos2d::Color4F&} */ setEndColor : function () {}, /** * @method setStartSpin * @param {float} */ setStartSpin : function () {}, /** * @method setDuration * @param {float} */ setDuration : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method getPosVar * @return A value converted from C/C++ "const cocos2d::Point&" */ getPosVar : function () {}, /** * @method updateWithNoTime */ updateWithNoTime : function () {}, /** * @method isBlendAdditive * @return A value converted from C/C++ "bool" */ isBlendAdditive : function () {}, /** * @method getSpeedVar * @return A value converted from C/C++ "float" */ getSpeedVar : function () {}, /** * @method setPositionType * @param {cocos2d::ParticleSystem::PositionType} */ setPositionType : function () {}, /** * @method stopSystem */ stopSystem : function () {}, /** * @method getSourcePosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getSourcePosition : function () {}, /** * @method setLifeVar * @param {float} */ setLifeVar : function () {}, /** * @method setTotalParticles * @param {int} */ setTotalParticles : function () {}, /** * @method setEndColorVar * @param {const cocos2d::Color4F&} */ setEndColorVar : function () {}, /** * @method updateQuadWithParticle * @param {cocos2d::tParticle*} * @param {const cocos2d::Point&} */ updateQuadWithParticle : function () {}, /** * @method getAtlasIndex * @return A value converted from C/C++ "int" */ getAtlasIndex : function () {}, /** * @method getStartSize * @return A value converted from C/C++ "float" */ getStartSize : function () {}, /** * @method setStartSpinVar * @param {float} */ setStartSpinVar : function () {}, /** * @method resetSystem */ resetSystem : function () {}, /** * @method setAtlasIndex * @param {int} */ setAtlasIndex : function () {}, /** * @method setTangentialAccelVar * @param {float} */ setTangentialAccelVar : function () {}, /** * @method setEndRadiusVar * @param {float} */ setEndRadiusVar : function () {}, /** * @method getEndRadius * @return A value converted from C/C++ "float" */ getEndRadius : function () {}, /** * @method isOpacityModifyRGB * @return A value converted from C/C++ "bool" */ isOpacityModifyRGB : function () {}, /** * @method isActive * @return A value converted from C/C++ "bool" */ isActive : function () {}, /** * @method setRadialAccelVar * @param {float} */ setRadialAccelVar : function () {}, /** * @method setStartSize * @param {float} */ setStartSize : function () {}, /** * @method setSpeed * @param {float} */ setSpeed : function () {}, /** * @method getStartSpin * @return A value converted from C/C++ "float" */ getStartSpin : function () {}, /** * @method getRotatePerSecond * @return A value converted from C/C++ "float" */ getRotatePerSecond : function () {}, /** * @method initParticle * @param {cocos2d::tParticle*} */ initParticle : function () {}, /** * @method setEmitterMode * @param {cocos2d::ParticleSystem::Mode} */ setEmitterMode : function () {}, /** * @method getDuration * @return A value converted from C/C++ "float" */ getDuration : function () {}, /** * @method setSourcePosition * @param {const cocos2d::Point&} */ setSourcePosition : function () {}, /** * @method getEndSpinVar * @return A value converted from C/C++ "float" */ getEndSpinVar : function () {}, /** * @method setBlendAdditive * @param {bool} */ setBlendAdditive : function () {}, /** * @method setLife * @param {float} */ setLife : function () {}, /** * @method setAngleVar * @param {float} */ setAngleVar : function () {}, /** * @method setRotationIsDir * @param {bool} */ setRotationIsDir : function () {}, /** * @method setEndSizeVar * @param {float} */ setEndSizeVar : function () {}, /** * @method setAngle * @param {float} */ setAngle : function () {}, /** * @method setBatchNode * @param {cocos2d::ParticleBatchNode*} */ setBatchNode : function () {}, /** * @method getTangentialAccelVar * @return A value converted from C/C++ "float" */ getTangentialAccelVar : function () {}, /** * @method getEmitterMode * @return A value converted from C/C++ "cocos2d::ParticleSystem::Mode" */ getEmitterMode : function () {}, /** * @method setEndSpinVar * @param {float} */ setEndSpinVar : function () {}, /** * @method getAngleVar * @return A value converted from C/C++ "float" */ getAngleVar : function () {}, /** * @method setStartColor * @param {const cocos2d::Color4F&} */ setStartColor : function () {}, /** * @method getRotatePerSecondVar * @return A value converted from C/C++ "float" */ getRotatePerSecondVar : function () {}, /** * @method getEndSize * @return A value converted from C/C++ "float" */ getEndSize : function () {}, /** * @method getLife * @return A value converted from C/C++ "float" */ getLife : function () {}, /** * @method setSpeedVar * @param {float} */ setSpeedVar : function () {}, /** * @method setAutoRemoveOnFinish * @param {bool} */ setAutoRemoveOnFinish : function () {}, /** * @method setGravity * @param {const cocos2d::Point&} */ setGravity : function () {}, /** * @method postStep */ postStep : function () {}, /** * @method setEmissionRate * @param {float} */ setEmissionRate : function () {}, /** * @method getEndColorVar * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getEndColorVar : function () {}, /** * @method getRotationIsDir * @return A value converted from C/C++ "bool" */ getRotationIsDir : function () {}, /** * @method setScale * @param {float} */ setScale : function () {}, /** * @method getEmissionRate * @return A value converted from C/C++ "float" */ getEmissionRate : function () {}, /** * @method getEndColor * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getEndColor : function () {}, /** * @method getLifeVar * @return A value converted from C/C++ "float" */ getLifeVar : function () {}, /** * @method setStartSizeVar * @param {float} */ setStartSizeVar : function () {}, /** * @method setOpacityModifyRGB * @param {bool} */ setOpacityModifyRGB : function () {}, /** * @method addParticle * @return A value converted from C/C++ "bool" */ addParticle : function () {}, /** * @method getStartRadius * @return A value converted from C/C++ "float" */ getStartRadius : function () {}, /** * @method getParticleCount * @return A value converted from C/C++ "unsigned int" */ getParticleCount : function () {}, /** * @method getStartRadiusVar * @return A value converted from C/C++ "float" */ getStartRadiusVar : function () {}, /** * @method setStartColorVar * @param {const cocos2d::Color4F&} */ setStartColorVar : function () {}, /** * @method setEndSpin * @param {float} */ setEndSpin : function () {}, /** * @method setRadialAccel * @param {float} */ setRadialAccel : function () {}, /** * @method isAutoRemoveOnFinish * @return A value converted from C/C++ "bool" */ isAutoRemoveOnFinish : function () {}, /** * @method getTotalParticles * @return A value converted from C/C++ "int" */ getTotalParticles : function () {}, /** * @method setStartRadiusVar * @param {float} */ setStartRadiusVar : function () {}, /** * @method getEndRadiusVar * @return A value converted from C/C++ "float" */ getEndRadiusVar : function () {}, /** * @method getStartColorVar * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getStartColorVar : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSystem*" * @param {const std::string&} */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSystem*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSystemQuad */ cc.ParticleSystem = { /** * @method setDisplayFrame * @param {cocos2d::SpriteFrame*} */ setDisplayFrame : function () {}, /** * @method setTextureWithRect * @param {cocos2d::Texture2D*} * @param {const cocos2d::Rect&} */ setTextureWithRect : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSystemQuad*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleFire */ cc.ParticleFire = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleFire*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleFire*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleFireworks */ cc.ParticleFireworks = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleFireworks*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleFireworks*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSun */ cc.ParticleSun = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSun*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSun*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleGalaxy */ cc.ParticleGalaxy = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleGalaxy*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleGalaxy*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleFlower */ cc.ParticleFlower = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleFlower*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleFlower*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleMeteor */ cc.ParticleMeteor = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleMeteor*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleMeteor*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSpiral */ cc.ParticleSpiral = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSpiral*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSpiral*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleExplosion */ cc.ParticleExplosion = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleExplosion*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleExplosion*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSmoke */ cc.ParticleSmoke = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSmoke*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSmoke*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSnow */ cc.ParticleSnow = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSnow*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSnow*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleRain */ cc.ParticleRain = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleRain*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleRain*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class FileUtils */ cc.FileUtils = { /** * @method fullPathForFilename * @return A value converted from C/C++ "std::string" * @param {const std::string&} */ fullPathForFilename : function () {}, /** * @method getStringFromFile * @return A value converted from C/C++ "std::string" * @param {const std::string&} */ getStringFromFile : function () {}, /** * @method setFilenameLookupDictionary * @param {const cocos2d::ValueMap&} */ setFilenameLookupDictionary : function () {}, /** * @method isAbsolutePath * @return A value converted from C/C++ "bool" * @param {const std::string&} */ isAbsolutePath : function () {}, /** * @method loadFilenameLookupDictionaryFromFile * @param {const std::string&} */ loadFilenameLookupDictionaryFromFile : function () {}, /** * @method isPopupNotify * @return A value converted from C/C++ "bool" */ isPopupNotify : function () {}, /** * @method getValueVectorFromFile * @return A value converted from C/C++ "cocos2d::ValueVector" * @param {const std::string&} */ getValueVectorFromFile : function () {}, /** * @method writeToFile * @return A value converted from C/C++ "bool" * @param {cocos2d::ValueMap&} * @param {const std::string&} */ writeToFile : function () {}, /** * @method getValueMapFromFile * @return A value converted from C/C++ "cocos2d::ValueMap" * @param {const std::string&} */ getValueMapFromFile : function () {}, /** * @method addSearchResolutionsOrder * @param {const std::string&} */ addSearchResolutionsOrder : function () {}, /** * @method addSearchPath * @param {const std::string&} */ addSearchPath : function () {}, /** * @method isFileExist * @return A value converted from C/C++ "bool" * @param {const std::string&} */ isFileExist : function () {}, /** * @method purgeCachedEntries */ purgeCachedEntries : function () {}, /** * @method fullPathFromRelativeFile * @return A value converted from C/C++ "std::string" * @param {const std::string&} * @param {const std::string&} */ fullPathFromRelativeFile : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::FileUtils*" */ getInstance : function () {}, }; /** * @class SAXParser */ cc.SAXParser = { /** * @method init * @return A value converted from C/C++ "bool" * @param {const char*} */ init : function () {}, }; /** * @class Application */ cc.Application = { /** * @method getTargetPlatform * @return A value converted from C/C++ "cocos2d::ApplicationProtocol::Platform" */ getTargetPlatform : function () {}, /** * @method setAnimationInterval * @param {double} */ setAnimationInterval : function () {}, /** * @method getCurrentLanguage * @return A value converted from C/C++ "cocos2d::LanguageType" */ getCurrentLanguage : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::Application*" */ getInstance : function () {}, }; /** * @class EGLViewProtocol */ cc.EGLViewProtocol = { /** * @method getVisibleOrigin * @return A value converted from C/C++ "cocos2d::Point" */ getVisibleOrigin : function () {}, /** * @method getVisibleSize * @return A value converted from C/C++ "cocos2d::Size" */ getVisibleSize : function () {}, /** * @method setDesignResolutionSize * @param {float} * @param {float} * @param {ResolutionPolicy} */ setDesignResolutionSize : function () {}, }; /** * @class EGLView */ cc.EGLView = { /** * @method setIMEKeyboardState * @param {bool} */ setIMEKeyboardState : function () {}, /** * @method isOpenGLReady * @return A value converted from C/C++ "bool" */ isOpenGLReady : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::EGLView*" */ getInstance : function () {}, }; /** * @class ShaderCache */ cc.ShaderCache = { /** * @method reloadDefaultShaders */ reloadDefaultShaders : function () {}, /** * @method addProgram * @param {cocos2d::GLProgram*} * @param {const std::string&} */ addProgram : function () {}, /** * @method getProgram * @return A value converted from C/C++ "cocos2d::GLProgram*" * @param {const std::string&} */ getProgram : function () {}, /** * @method loadDefaultShaders */ loadDefaultShaders : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::ShaderCache*" */ getInstance : function () {}, /** * @method ShaderCache * @constructor */ ShaderCache : function () {}, }; /** * @class AnimationCache */ cc.AnimationCache = { /** * @method getAnimation * @return A value converted from C/C++ "cocos2d::Animation*" * @param {const std::string&} */ getAnimation : function () {}, /** * @method addAnimation * @param {cocos2d::Animation*} * @param {const std::string&} */ addAnimation : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method addAnimationsWithDictionary * @param {const cocos2d::ValueMap&} * @param {const std::string&} */ addAnimationsWithDictionary : function () {}, /** * @method removeAnimation * @param {const std::string&} */ removeAnimation : function () {}, /** * @method addAnimationsWithFile * @param {const std::string&} */ addAnimationsWithFile : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::AnimationCache*" */ getInstance : function () {}, /** * @method AnimationCache * @constructor */ AnimationCache : function () {}, }; /** * @class SpriteFrameCache */ cc.SpriteFrameCache = { /** * @method addSpriteFrame * @param {cocos2d::SpriteFrame*} * @param {const std::string&} */ addSpriteFrame : function () {}, /** * @method removeUnusedSpriteFrames */ removeUnusedSpriteFrames : function () {}, /** * @method getSpriteFrameByName * @return A value converted from C/C++ "cocos2d::SpriteFrame*" * @param {const std::string&} */ getSpriteFrameByName : function () {}, /** * @method removeSpriteFramesFromFile * @param {const std::string&} */ removeSpriteFramesFromFile : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method removeSpriteFrames */ removeSpriteFrames : function () {}, /** * @method removeSpriteFramesFromTexture * @param {cocos2d::Texture2D*} */ removeSpriteFramesFromTexture : function () {}, /** * @method removeSpriteFrameByName * @param {const std::string&} */ removeSpriteFrameByName : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::SpriteFrameCache*" */ getInstance : function () {}, }; /** * @class TextFieldTTF */ cc.TextFieldTTF = { /** * @method getCharCount * @return A value converted from C/C++ "int" */ getCharCount : function () {}, /** * @method getDelegate * @return A value converted from C/C++ "cocos2d::TextFieldDelegate*" */ getDelegate : function () {}, /** * @method setSecureTextEntry * @param {bool} */ setSecureTextEntry : function () {}, /** * @method getColorSpaceHolder * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getColorSpaceHolder : function () {}, /** * @method setColorSpaceHolder * @param {const cocos2d::Color3B&} */ setColorSpaceHolder : function () {}, /** * @method detachWithIME * @return A value converted from C/C++ "bool" */ detachWithIME : function () {}, /** * @method setDelegate * @param {cocos2d::TextFieldDelegate*} */ setDelegate : function () {}, /** * @method setPlaceHolder * @param {const std::string&} */ setPlaceHolder : function () {}, /** * @method isSecureTextEntry * @return A value converted from C/C++ "bool" */ isSecureTextEntry : function () {}, /** * @method getPlaceHolder * @return A value converted from C/C++ "const std::string&" */ getPlaceHolder : function () {}, /** * @method attachWithIME * @return A value converted from C/C++ "bool" */ attachWithIME : function () {}, /** * @method TextFieldTTF * @constructor */ TextFieldTTF : function () {}, }; /** * @class TextureCache */ cc.TextureCache = { /** * @method removeTextureForKey * @param {const std::string&} */ removeTextureForKey : function () {}, /** * @method removeAllTextures */ removeAllTextures : function () {}, /** * @method getDescription * @return A value converted from C/C++ "std::string" */ getDescription : function () {}, /** * @method getCachedTextureInfo * @return A value converted from C/C++ "std::string" */ getCachedTextureInfo : function () {}, /** * @method getTextureForKey * @return A value converted from C/C++ "cocos2d::Texture2D*" * @param {const std::string&} */ getTextureForKey : function () {}, /** * @method removeUnusedTextures */ removeUnusedTextures : function () {}, /** * @method removeTexture * @param {cocos2d::Texture2D*} */ removeTexture : function () {}, /** * @method waitForQuit */ waitForQuit : function () {}, /** * @method TextureCache * @constructor */ TextureCache : function () {}, }; /** * @class ParallaxNode */ cc.ParallaxNode = { /** * @method addChild * @param {cocos2d::Node*} * @param {int} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} */ addChild : function () {}, /** * @method removeAllChildrenWithCleanup * @param {bool} */ removeAllChildrenWithCleanup : function () {}, /** * @method setParallaxArray * @param {cocos2d::_ccArray*} */ setParallaxArray : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ParallaxNode*" */ create : function () {}, }; /** * @class TMXObjectGroup */ cc.TMXObjectGroup = { /** * @method setPositionOffset * @param {const cocos2d::Point&} */ setPositionOffset : function () {}, /** * @method getProperty * @return A value converted from C/C++ "cocos2d::Value" * @param {const std::string&} */ getProperty : function () {}, /** * @method getPositionOffset * @return A value converted from C/C++ "const cocos2d::Point&" */ getPositionOffset : function () {}, /** * @method getObject * @return A value converted from C/C++ "cocos2d::ValueMap" * @param {const std::string&} */ getObject : function () {}, /** * @method setGroupName * @param {const std::string&} */ setGroupName : function () {}, /** * @method getGroupName * @return A value converted from C/C++ "const std::string&" */ getGroupName : function () {}, /** * @method setProperties * @param {const cocos2d::ValueMap&} */ setProperties : function () {}, /** * @method setObjects * @param {const cocos2d::ValueVector&} */ setObjects : function () {}, /** * @method TMXObjectGroup * @constructor */ TMXObjectGroup : function () {}, }; /** * @class TMXLayerInfo */ cc.TMXLayerInfo = { /** * @method setProperties * @param {cocos2d::ValueMap} */ setProperties : function () {}, /** * @method getProperties * @return A value converted from C/C++ "cocos2d::ValueMap&" */ getProperties : function () {}, /** * @method TMXLayerInfo * @constructor */ TMXLayerInfo : function () {}, }; /** * @class TMXTilesetInfo */ cc.TMXTilesetInfo = { /** * @method rectForGID * @return A value converted from C/C++ "cocos2d::Rect" * @param {int} */ rectForGID : function () {}, /** * @method TMXTilesetInfo * @constructor */ TMXTilesetInfo : function () {}, }; /** * @class TMXMapInfo */ cc.TMXMapInfo = { /** * @method setObjectGroups * @param {const cocos2d::Vector&} */ setObjectGroups : function () {}, /** * @method setTileSize * @param {const cocos2d::Size&} */ setTileSize : function () {}, /** * @method initWithTMXFile * @return A value converted from C/C++ "bool" * @param {const std::string&} */ initWithTMXFile : function () {}, /** * @method getOrientation * @return A value converted from C/C++ "int" */ getOrientation : function () {}, /** * @method isStoringCharacters * @return A value converted from C/C++ "bool" */ isStoringCharacters : function () {}, /** * @method setLayers * @param {const cocos2d::Vector&} */ setLayers : function () {}, /** * @method parseXMLFile * @return A value converted from C/C++ "bool" * @param {const std::string&} */ parseXMLFile : function () {}, /** * @method getParentElement * @return A value converted from C/C++ "int" */ getParentElement : function () {}, /** * @method setTMXFileName * @param {const std::string&} */ setTMXFileName : function () {}, /** * @method parseXMLString * @return A value converted from C/C++ "bool" * @param {const std::string&} */ parseXMLString : function () {}, /** * @method getParentGID * @return A value converted from C/C++ "int" */ getParentGID : function () {}, /** * @method setParentElement * @param {int} */ setParentElement : function () {}, /** * @method initWithXML * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {const std::string&} */ initWithXML : function () {}, /** * @method setParentGID * @param {int} */ setParentGID : function () {}, /** * @method getLayerAttribs * @return A value converted from C/C++ "int" */ getLayerAttribs : function () {}, /** * @method getTileSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getTileSize : function () {}, /** * @method getTileProperties * @return A value converted from C/C++ "cocos2d::ValueMapIntKey&" */ getTileProperties : function () {}, /** * @method getTMXFileName * @return A value converted from C/C++ "const std::string&" */ getTMXFileName : function () {}, /** * @method setCurrentString * @param {const std::string&} */ setCurrentString : function () {}, /** * @method setProperties * @param {const cocos2d::ValueMap&} */ setProperties : function () {}, /** * @method setOrientation * @param {int} */ setOrientation : function () {}, /** * @method setTileProperties * @param {const cocos2d::ValueMapIntKey&} */ setTileProperties : function () {}, /** * @method setMapSize * @param {const cocos2d::Size&} */ setMapSize : function () {}, /** * @method setStoringCharacters * @param {bool} */ setStoringCharacters : function () {}, /** * @method getMapSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getMapSize : function () {}, /** * @method setTilesets * @param {const cocos2d::Vector&} */ setTilesets : function () {}, /** * @method getCurrentString * @return A value converted from C/C++ "const std::string&" */ getCurrentString : function () {}, /** * @method setLayerAttribs * @param {int} */ setLayerAttribs : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TMXMapInfo*" * @param {const std::string&} */ create : function () {}, /** * @method createWithXML * @return A value converted from C/C++ "cocos2d::TMXMapInfo*" * @param {const std::string&} * @param {const std::string&} */ createWithXML : function () {}, /** * @method TMXMapInfo * @constructor */ TMXMapInfo : function () {}, }; /** * @class TMXLayer */ cc.TMXLayer = { /** * @method getTileGIDAt * @return A value converted from C/C++ "int" * @param {const cocos2d::Point&} * @param {cocos2d::ccTMXTileFlags*} */ getTileGIDAt : function () {}, /** * @method getPositionAt * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ getPositionAt : function () {}, /** * @method setLayerOrientation * @param {int} */ setLayerOrientation : function () {}, /** * @method releaseMap */ releaseMap : function () {}, /** * @method setTiles * @param {int*} */ setTiles : function () {}, /** * @method getLayerSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getLayerSize : function () {}, /** * @method setMapTileSize * @param {const cocos2d::Size&} */ setMapTileSize : function () {}, /** * @method getLayerOrientation * @return A value converted from C/C++ "int" */ getLayerOrientation : function () {}, /** * @method setProperties * @param {const cocos2d::ValueMap&} */ setProperties : function () {}, /** * @method setLayerName * @param {const std::string&} */ setLayerName : function () {}, /** * @method removeTileAt * @param {const cocos2d::Point&} */ removeTileAt : function () {}, /** * @method initWithTilesetInfo * @return A value converted from C/C++ "bool" * @param {cocos2d::TMXTilesetInfo*} * @param {cocos2d::TMXLayerInfo*} * @param {cocos2d::TMXMapInfo*} */ initWithTilesetInfo : function () {}, /** * @method setupTiles */ setupTiles : function () {}, /** * @method getMapTileSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getMapTileSize : function () {}, /** * @method getProperty * @return A value converted from C/C++ "cocos2d::Value" * @param {const std::string&} */ getProperty : function () {}, /** * @method setLayerSize * @param {const cocos2d::Size&} */ setLayerSize : function () {}, /** * @method getLayerName * @return A value converted from C/C++ "const std::string&" */ getLayerName : function () {}, /** * @method setTileSet * @param {cocos2d::TMXTilesetInfo*} */ setTileSet : function () {}, /** * @method getTileSet * @return A value converted from C/C++ "cocos2d::TMXTilesetInfo*" */ getTileSet : function () {}, /** * @method getTileAt * @return A value converted from C/C++ "cocos2d::Sprite*" * @param {const cocos2d::Point&} */ getTileAt : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TMXLayer*" * @param {cocos2d::TMXTilesetInfo*} * @param {cocos2d::TMXLayerInfo*} * @param {cocos2d::TMXMapInfo*} */ create : function () {}, /** * @method TMXLayer * @constructor */ TMXLayer : function () {}, }; /** * @class TMXTiledMap */ cc.TMXTiledMap = { /** * @method setObjectGroups * @param {const cocos2d::Vector&} */ setObjectGroups : function () {}, /** * @method getProperty * @return A value converted from C/C++ "cocos2d::Value" * @param {const std::string&} */ getProperty : function () {}, /** * @method setMapSize * @param {const cocos2d::Size&} */ setMapSize : function () {}, /** * @method getObjectGroup * @return A value converted from C/C++ "cocos2d::TMXObjectGroup*" * @param {const std::string&} */ getObjectGroup : function () {}, /** * @method getTileSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getTileSize : function () {}, /** * @method getMapSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getMapSize : function () {}, /** * @method getProperties * @return A value converted from C/C++ "cocos2d::ValueMap&" */ getProperties : function () {}, /** * @method getPropertiesForGID * @return A value converted from C/C++ "cocos2d::Value" * @param {int} */ getPropertiesForGID : function () {}, /** * @method setTileSize * @param {const cocos2d::Size&} */ setTileSize : function () {}, /** * @method setProperties * @param {const cocos2d::ValueMap&} */ setProperties : function () {}, /** * @method getLayer * @return A value converted from C/C++ "cocos2d::TMXLayer*" * @param {const std::string&} */ getLayer : function () {}, /** * @method getMapOrientation * @return A value converted from C/C++ "int" */ getMapOrientation : function () {}, /** * @method setMapOrientation * @param {int} */ setMapOrientation : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TMXTiledMap*" * @param {const std::string&} */ create : function () {}, /** * @method createWithXML * @return A value converted from C/C++ "cocos2d::TMXTiledMap*" * @param {const std::string&} * @param {const std::string&} */ createWithXML : function () {}, }; /** * @class TileMapAtlas */ cc.TileMapAtlas = { /** * @method initWithTileFile * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {const std::string&} * @param {int} * @param {int} */ initWithTileFile : function () {}, /** * @method releaseMap */ releaseMap : function () {}, /** * @method getTGAInfo * @return A value converted from C/C++ "cocos2d::sImageTGA*" */ getTGAInfo : function () {}, /** * @method getTileAt * @return A value converted from C/C++ "cocos2d::Color3B" * @param {const cocos2d::Point&} */ getTileAt : function () {}, /** * @method setTile * @param {const cocos2d::Color3B&} * @param {const cocos2d::Point&} */ setTile : function () {}, /** * @method setTGAInfo * @param {cocos2d::sImageTGA*} */ setTGAInfo : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TileMapAtlas*" * @param {const std::string&} * @param {const std::string&} * @param {int} * @param {int} */ create : function () {}, /** * @method TileMapAtlas * @constructor */ TileMapAtlas : function () {}, }; /** * @class Timer */ cc.Timer = { /** * @method getInterval * @return A value converted from C/C++ "float" */ getInterval : function () {}, /** * @method setInterval * @param {float} */ setInterval : function () {}, /** * @method initWithScriptHandler * @return A value converted from C/C++ "bool" * @param {int} * @param {float} */ initWithScriptHandler : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method getScriptHandler * @return A value converted from C/C++ "int" */ getScriptHandler : function () {}, /** * @method Timer * @constructor */ Timer : function () {}, }; /** * @class Scheduler */ cc.Scheduler = { /** * @method setTimeScale * @param {float} */ setTimeScale : function () {}, /** * @method performFunctionInCocosThread * @param {const std::function&} */ performFunctionInCocosThread : function () {}, /** * @method getTimeScale * @return A value converted from C/C++ "float" */ getTimeScale : function () {}, /** * @method Scheduler * @constructor */ Scheduler : function () {}, }; /** * @class Component */ cc.Component = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method setName * @param {const std::string&} */ setName : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method serialize * @return A value converted from C/C++ "bool" * @param {void*} */ serialize : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method getOwner * @return A value converted from C/C++ "cocos2d::Node*" */ getOwner : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setOwner * @param {cocos2d::Node*} */ setOwner : function () {}, /** * @method getName * @return A value converted from C/C++ "const std::string&" */ getName : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Component*" */ create : function () {}, }; /** * @class SimpleAudioEngine */ cc.AudioEngine = { /** * @method preloadBackgroundMusic * @param {const char*} */ preloadBackgroundMusic : function () {}, /** * @method stopBackgroundMusic */ stopBackgroundMusic : function () {}, /** * @method stopAllEffects */ stopAllEffects : function () {}, /** * @method getBackgroundMusicVolume * @return A value converted from C/C++ "float" */ getBackgroundMusicVolume : function () {}, /** * @method resumeBackgroundMusic */ resumeBackgroundMusic : function () {}, /** * @method setBackgroundMusicVolume * @param {float} */ setBackgroundMusicVolume : function () {}, /** * @method preloadEffect * @param {const char*} */ preloadEffect : function () {}, /** * @method isBackgroundMusicPlaying * @return A value converted from C/C++ "bool" */ isBackgroundMusicPlaying : function () {}, /** * @method getEffectsVolume * @return A value converted from C/C++ "float" */ getEffectsVolume : function () {}, /** * @method willPlayBackgroundMusic * @return A value converted from C/C++ "bool" */ willPlayBackgroundMusic : function () {}, /** * @method pauseEffect * @param {unsigned int} */ pauseEffect : function () {}, /** * @method playEffect * @return A value converted from C/C++ "unsigned int" * @param {const char*} * @param {bool} * @param {float} * @param {float} * @param {float} */ playEffect : function () {}, /** * @method rewindBackgroundMusic */ rewindBackgroundMusic : function () {}, /** * @method playBackgroundMusic * @param {const char*} * @param {bool} */ playBackgroundMusic : function () {}, /** * @method resumeAllEffects */ resumeAllEffects : function () {}, /** * @method setEffectsVolume * @param {float} */ setEffectsVolume : function () {}, /** * @method stopEffect * @param {unsigned int} */ stopEffect : function () {}, /** * @method pauseBackgroundMusic */ pauseBackgroundMusic : function () {}, /** * @method pauseAllEffects */ pauseAllEffects : function () {}, /** * @method unloadEffect * @param {const char*} */ unloadEffect : function () {}, /** * @method resumeEffect * @param {unsigned int} */ resumeEffect : function () {}, /** * @method end */ end : function () {}, /** * @method getInstance * @return A value converted from C/C++ "CocosDenshion::SimpleAudioEngine*" */ getInstance : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_builder_auto.cpp ================================================ #include "jsb_cocos2dx_builder_auto.hpp" #include "cocos2d_specifics.hpp" #include "CocosBuilder.h" template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedValue initializing(cx); JSBool isNewValid = JS_TRUE; JSObject* global = ScriptingCore::getInstance()->getGlobalObject(); isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && JSVAL_TO_BOOLEAN(initializing); if (isNewValid) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); return JS_TRUE; } JS_ReportError(cx, "Don't use `new cc.XXX`, please use `cc.XXX.create` instead! "); return JS_FALSE; } static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { return JS_FALSE; } static JSBool js_is_native_obj(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { vp.set(BOOLEAN_TO_JSVAL(JS_TRUE)); return JS_TRUE; } JSClass *jsb_cocosbuilder_CCBAnimationManager_class; JSObject *jsb_cocosbuilder_CCBAnimationManager_prototype; JSBool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode : Invalid Native Object"); if (argc == 2) { cocos2d::Node* arg0; cocos2d::Node* arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode : Error processing arguments"); cobj->moveAnimationsFromNode(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId : Error processing arguments"); cobj->setAutoPlaySequenceId(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames : Invalid Native Object"); if (argc == 0) { cocos2d::ValueVector& ret = cobj->getDocumentCallbackNames(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel : Invalid Native Object"); if (argc == 1) { cocosbuilder::CCBSequenceProperty* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequenceProperty*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel : Error processing arguments"); cocos2d::Object* ret = cobj->actionForSoundChannel(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Object*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setBaseValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setBaseValue : Invalid Native Object"); if (argc == 3) { cocos2d::Value arg0; cocos2d::Node* arg1; std::string arg2; ok &= jsval_to_ccvalue(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setBaseValue : Error processing arguments"); cobj->setBaseValue(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setBaseValue : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getDocumentOutletNodes(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getLastCompletedSequenceName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setRootNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setRootNode : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setRootNode : Error processing arguments"); cobj->setRootNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setRootNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration : Invalid Native Object"); if (argc == 2) { const char* arg0; double arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration : Error processing arguments"); cobj->runAnimationsForSequenceNamedTweenDuration(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName : Error processing arguments"); cobj->addDocumentOutletName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getSequences(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getSequences : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getSequences(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getSequences : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getRootContainerSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName : Error processing arguments"); cobj->setDocumentControllerName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setObject : Invalid Native Object"); if (argc == 3) { cocos2d::Object* arg0; cocos2d::Node* arg1; std::string arg2; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setObject : Error processing arguments"); cobj->setObject(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setObject : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getContainerSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getContainerSize : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getContainerSize : Error processing arguments"); const cocos2d::Size& ret = cobj->getContainerSize(arg0); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getContainerSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel : Invalid Native Object"); if (argc == 1) { cocosbuilder::CCBSequenceProperty* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequenceProperty*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel : Error processing arguments"); cocos2d::Object* ret = cobj->actionForCallbackChannel(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Object*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames : Invalid Native Object"); if (argc == 0) { cocos2d::ValueVector& ret = cobj->getDocumentOutletNames(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::EventType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents : Error processing arguments"); cobj->addDocumentCallbackControlEvents(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks : Invalid Native Object"); if (argc == 0) { cocos2d::ValueVector& ret = cobj->getKeyframeCallbacks(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents : Invalid Native Object"); if (argc == 0) { cocos2d::ValueVector& ret = cobj->getDocumentCallbackControlEvents(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize : Error processing arguments"); cobj->setRootContainerSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration : Invalid Native Object"); if (argc == 2) { int arg0; double arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration : Error processing arguments"); cobj->runAnimationsForSequenceIdTweenDuration(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getRunningSequenceName(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId : Invalid Native Object"); if (argc == 0) { int ret = cobj->getAutoPlaySequenceId(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName : Error processing arguments"); cobj->addDocumentCallbackName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getRootNode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getRootNode : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getRootNode(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getRootNode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode : Error processing arguments"); cobj->addDocumentOutletNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setDelegate : Invalid Native Object"); if (argc == 1) { cocosbuilder::CCBAnimationManagerDelegate* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBAnimationManagerDelegate*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setDelegate : Error processing arguments"); cobj->setDelegate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setDelegate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration : Error processing arguments"); double ret = cobj->getSequenceDuration(arg0); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode : Error processing arguments"); cobj->addDocumentCallbackNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getDelegate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getDelegate : Invalid Native Object"); if (argc == 0) { cocosbuilder::CCBAnimationManagerDelegate* ret = cobj->getDelegate(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocosbuilder::CCBAnimationManagerDelegate*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDelegate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed : Error processing arguments"); cobj->runAnimationsForSequenceNamed(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getSequenceId(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getSequenceId : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getSequenceId : Error processing arguments"); int ret = cobj->getSequenceId(arg0); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getSequenceId : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setCallFunc : Invalid Native Object"); if (argc == 2) { cocos2d::CallFunc* arg0; std::string arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::CallFunc*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setCallFunc : Error processing arguments"); cobj->setCallFunc(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setCallFunc : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getDocumentCallbackNodes(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_setSequences(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setSequences : Invalid Native Object"); if (argc == 1) { cocos2d::Vector arg0; ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_setSequences : Error processing arguments"); cobj->setSequences(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setSequences : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_debug(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_debug : Invalid Native Object"); if (argc == 0) { cobj->debug(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_debug : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getDocumentControllerName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBAnimationManager_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocosbuilder::CCBAnimationManager* cobj = new cocosbuilder::CCBAnimationManager(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocosbuilder::CCBAnimationManager"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocosbuilder_CCBAnimationManager_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CCBAnimationManager)", obj); } void js_register_cocos2dx_builder_CCBAnimationManager(JSContext *cx, JSObject *global) { jsb_cocosbuilder_CCBAnimationManager_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocosbuilder_CCBAnimationManager_class->name = "BuilderAnimationManager"; jsb_cocosbuilder_CCBAnimationManager_class->addProperty = JS_PropertyStub; jsb_cocosbuilder_CCBAnimationManager_class->delProperty = JS_DeletePropertyStub; jsb_cocosbuilder_CCBAnimationManager_class->getProperty = JS_PropertyStub; jsb_cocosbuilder_CCBAnimationManager_class->setProperty = JS_StrictPropertyStub; jsb_cocosbuilder_CCBAnimationManager_class->enumerate = JS_EnumerateStub; jsb_cocosbuilder_CCBAnimationManager_class->resolve = JS_ResolveStub; jsb_cocosbuilder_CCBAnimationManager_class->convert = JS_ConvertStub; jsb_cocosbuilder_CCBAnimationManager_class->finalize = js_cocosbuilder_CCBAnimationManager_finalize; jsb_cocosbuilder_CCBAnimationManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("moveAnimationsFromNode", js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAutoPlaySequenceId", js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDocumentCallbackNames", js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("actionForSoundChannel", js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBaseValue", js_cocos2dx_builder_CCBAnimationManager_setBaseValue, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDocumentOutletNodes", js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLastCompletedSequenceName", js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRootNode", js_cocos2dx_builder_CCBAnimationManager_setRootNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("runAnimationsForSequenceNamedTweenDuration", js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addDocumentOutletName", js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSequences", js_cocos2dx_builder_CCBAnimationManager_getSequences, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRootContainerSize", js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDocumentControllerName", js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setObject", js_cocos2dx_builder_CCBAnimationManager_setObject, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContainerSize", js_cocos2dx_builder_CCBAnimationManager_getContainerSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("actionForCallbackChannel", js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDocumentOutletNames", js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addDocumentCallbackControlEvents", js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_builder_CCBAnimationManager_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getKeyframeCallbacks", js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDocumentCallbackControlEvents", js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRootContainerSize", js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("runAnimationsForSequenceIdTweenDuration", js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRunningSequenceName", js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAutoPlaySequenceId", js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addDocumentCallbackName", js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRootNode", js_cocos2dx_builder_CCBAnimationManager_getRootNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addDocumentOutletNode", js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDelegate", js_cocos2dx_builder_CCBAnimationManager_setDelegate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSequenceDuration", js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addDocumentCallbackNode", js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDelegate", js_cocos2dx_builder_CCBAnimationManager_getDelegate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("runAnimationsForSequenceNamed", js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSequenceId", js_cocos2dx_builder_CCBAnimationManager_getSequenceId, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCallFunc", js_cocos2dx_builder_CCBAnimationManager_setCallFunc, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDocumentCallbackNodes", js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSequences", js_cocos2dx_builder_CCBAnimationManager_setSequences, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("debug", js_cocos2dx_builder_CCBAnimationManager_debug, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDocumentControllerName", js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocosbuilder_CCBAnimationManager_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocosbuilder_CCBAnimationManager_class, js_cocos2dx_builder_CCBAnimationManager_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "BuilderAnimationManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocosbuilder_CCBAnimationManager_class; p->proto = jsb_cocosbuilder_CCBAnimationManager_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocosbuilder_CCBReader_class; JSObject *jsb_cocosbuilder_CCBReader_prototype; JSBool js_cocos2dx_builder_CCBReader_getAnimationManager(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getAnimationManager : Invalid Native Object"); if (argc == 0) { cocosbuilder::CCBAnimationManager* ret = cobj->getAnimationManager(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocosbuilder::CCBAnimationManager*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getAnimationManager : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_setAnimationManager(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_setAnimationManager : Invalid Native Object"); if (argc == 1) { cocosbuilder::CCBAnimationManager* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBAnimationManager*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_setAnimationManager : Error processing arguments"); cobj->setAnimationManager(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_setAnimationManager : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_addOwnerOutletName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_addOwnerOutletName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_addOwnerOutletName : Error processing arguments"); cobj->addOwnerOutletName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_addOwnerOutletName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_getOwnerCallbackNames(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getOwnerCallbackNames : Invalid Native Object"); if (argc == 0) { cocos2d::ValueVector ret = cobj->getOwnerCallbackNames(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerCallbackNames : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::EventType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents : Error processing arguments"); cobj->addDocumentCallbackControlEvents(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_setCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_setCCBRootPath : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_setCCBRootPath : Error processing arguments"); cobj->setCCBRootPath(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_setCCBRootPath : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_addOwnerOutletNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_addOwnerOutletNode : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_addOwnerOutletNode : Error processing arguments"); cobj->addOwnerOutletNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_addOwnerOutletNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getOwnerCallbackNodes(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq : Invalid Native Object"); if (argc == 1) { cocosbuilder::CCBSequence* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequence*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq : Error processing arguments"); JSBool ret = cobj->readSoundKeyframesForSeq(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_getCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getCCBRootPath : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getCCBRootPath(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getCCBRootPath : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents : Invalid Native Object"); if (argc == 0) { cocos2d::ValueVector& ret = cobj->getOwnerCallbackControlEvents(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_getOwnerOutletNodes(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getOwnerOutletNodes : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getOwnerOutletNodes(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerOutletNodes : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_readUTF8(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_readUTF8 : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->readUTF8(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_readUTF8 : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::EventType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents : Error processing arguments"); cobj->addOwnerCallbackControlEvents(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_getOwnerOutletNames(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getOwnerOutletNames : Invalid Native Object"); if (argc == 0) { cocos2d::ValueVector ret = cobj->getOwnerOutletNames(); jsval jsret = JSVAL_NULL; jsret = ccvaluevector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerOutletNames : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq : Invalid Native Object"); if (argc == 1) { cocosbuilder::CCBSequence* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBSequence*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq : Error processing arguments"); JSBool ret = cobj->readCallbackKeyframesForSeq(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getAnimationManagersForNodes(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getNodesWithAnimationManagers(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_setResolutionScale(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_builder_CCBReader_setResolutionScale : Error processing arguments"); cocosbuilder::CCBReader::setResolutionScale(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_setResolutionScale : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocosbuilder::CCBReader* cobj = NULL; do { if (argc == 1) { cocosbuilder::CCBReader* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::CCBReader*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj = new cocosbuilder::CCBReader(arg0); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "cocosbuilder::CCBReader"); } } while(0); do { if (argc == 1) { cocosbuilder::NodeLoaderLibrary* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj = new cocosbuilder::CCBReader(arg0); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "cocosbuilder::CCBReader"); } } while(0); do { if (argc == 2) { cocosbuilder::NodeLoaderLibrary* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocosbuilder::CCBMemberVariableAssigner* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj = new cocosbuilder::CCBReader(arg0, arg1); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "cocosbuilder::CCBReader"); } } while(0); do { if (argc == 3) { cocosbuilder::NodeLoaderLibrary* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocosbuilder::CCBMemberVariableAssigner* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocosbuilder::CCBSelectorResolver* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocosbuilder::CCBSelectorResolver*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj = new cocosbuilder::CCBReader(arg0, arg1, arg2); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "cocosbuilder::CCBReader"); } } while(0); do { if (argc == 4) { cocosbuilder::NodeLoaderLibrary* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocosbuilder::NodeLoaderLibrary*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocosbuilder::CCBMemberVariableAssigner* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocosbuilder::CCBSelectorResolver* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocosbuilder::CCBSelectorResolver*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocosbuilder::NodeLoaderListener* arg3; do { if (!argv[3].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); proxy = jsb_get_js_proxy(tmpObj); arg3 = (cocosbuilder::NodeLoaderListener*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj = new cocosbuilder::CCBReader(arg0, arg1, arg2, arg3); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "cocosbuilder::CCBReader"); } } while(0); do { if (argc == 0) { cobj = new cocosbuilder::CCBReader(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "cocosbuilder::CCBReader"); } } while(0); if (cobj) { JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_constructor : wrong number of arguments"); return JS_FALSE; } void js_cocosbuilder_CCBReader_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CCBReader)", obj); } void js_register_cocos2dx_builder_CCBReader(JSContext *cx, JSObject *global) { jsb_cocosbuilder_CCBReader_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocosbuilder_CCBReader_class->name = "_Reader"; jsb_cocosbuilder_CCBReader_class->addProperty = JS_PropertyStub; jsb_cocosbuilder_CCBReader_class->delProperty = JS_DeletePropertyStub; jsb_cocosbuilder_CCBReader_class->getProperty = JS_PropertyStub; jsb_cocosbuilder_CCBReader_class->setProperty = JS_StrictPropertyStub; jsb_cocosbuilder_CCBReader_class->enumerate = JS_EnumerateStub; jsb_cocosbuilder_CCBReader_class->resolve = JS_ResolveStub; jsb_cocosbuilder_CCBReader_class->convert = JS_ConvertStub; jsb_cocosbuilder_CCBReader_class->finalize = js_cocosbuilder_CCBReader_finalize; jsb_cocosbuilder_CCBReader_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAnimationManager", js_cocos2dx_builder_CCBReader_getAnimationManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimationManager", js_cocos2dx_builder_CCBReader_setAnimationManager, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addOwnerOutletName", js_cocos2dx_builder_CCBReader_addOwnerOutletName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOwnerCallbackNames", js_cocos2dx_builder_CCBReader_getOwnerCallbackNames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addDocumentCallbackControlEvents", js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCCBRootPath", js_cocos2dx_builder_CCBReader_setCCBRootPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addOwnerOutletNode", js_cocos2dx_builder_CCBReader_addOwnerOutletNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOwnerCallbackNodes", js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("readSoundKeyframesForSeq", js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCCBRootPath", js_cocos2dx_builder_CCBReader_getCCBRootPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOwnerCallbackControlEvents", js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOwnerOutletNodes", js_cocos2dx_builder_CCBReader_getOwnerOutletNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("readUTF8", js_cocos2dx_builder_CCBReader_readUTF8, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addOwnerCallbackControlEvents", js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOwnerOutletNames", js_cocos2dx_builder_CCBReader_getOwnerOutletNames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("readCallbackKeyframesForSeq", js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnimationManagersForNodes", js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodesWithAnimationManagers", js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("setResolutionScale", js_cocos2dx_builder_CCBReader_setResolutionScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocosbuilder_CCBReader_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocosbuilder_CCBReader_class, js_cocos2dx_builder_CCBReader_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "_Reader", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocosbuilder_CCBReader_class; p->proto = jsb_cocosbuilder_CCBReader_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } void register_all_cocos2dx_builder(JSContext* cx, JSObject* obj) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; js_register_cocos2dx_builder_CCBAnimationManager(cx, obj); js_register_cocos2dx_builder_CCBReader(cx, obj); } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_builder_auto.hpp ================================================ #ifndef __cocos2dx_builder_h__ #define __cocos2dx_builder_h__ #include "jsapi.h" #include "jsfriendapi.h" extern JSClass *jsb_cocosbuilder_CCBAnimationManager_class; extern JSObject *jsb_cocosbuilder_CCBAnimationManager_prototype; JSBool js_cocos2dx_builder_CCBAnimationManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_builder_CCBAnimationManager_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_builder_CCBAnimationManager(JSContext *cx, JSObject *global); void register_all_cocos2dx_builder(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setBaseValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setRootNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getSequences(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getContainerSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getRootNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setDelegate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getDelegate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getSequenceId(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setCallFunc(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_setSequences(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_debug(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBAnimationManager_CCBAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocosbuilder_CCBReader_class; extern JSObject *jsb_cocosbuilder_CCBReader_prototype; JSBool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_builder_CCBReader_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_builder_CCBReader(JSContext *cx, JSObject *global); void register_all_cocos2dx_builder(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_builder_CCBReader_getAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_setAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_addOwnerOutletName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_getOwnerCallbackNames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_setCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_addOwnerOutletNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_getCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_getOwnerOutletNodes(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_readUTF8(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_getOwnerOutletNames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_setResolutionScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_builder_CCBReader_CCBReader(JSContext *cx, uint32_t argc, jsval *vp); #endif ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_builder_auto_api.js ================================================ /** * @module cocos2dx_builder */ var cc = cc || {}; /** * @class CCBAnimationManager */ cc.BuilderAnimationManager = { /** * @method moveAnimationsFromNode * @param {cocos2d::Node*} * @param {cocos2d::Node*} */ moveAnimationsFromNode : function () {}, /** * @method setAutoPlaySequenceId * @param {int} */ setAutoPlaySequenceId : function () {}, /** * @method getDocumentCallbackNames * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getDocumentCallbackNames : function () {}, /** * @method actionForSoundChannel * @return A value converted from C/C++ "cocos2d::Object*" * @param {cocosbuilder::CCBSequenceProperty*} */ actionForSoundChannel : function () {}, /** * @method setBaseValue * @param {const cocos2d::Value&} * @param {cocos2d::Node*} * @param {const std::string&} */ setBaseValue : function () {}, /** * @method getDocumentOutletNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getDocumentOutletNodes : function () {}, /** * @method getLastCompletedSequenceName * @return A value converted from C/C++ "std::string" */ getLastCompletedSequenceName : function () {}, /** * @method setRootNode * @param {cocos2d::Node*} */ setRootNode : function () {}, /** * @method runAnimationsForSequenceNamedTweenDuration * @param {const char*} * @param {float} */ runAnimationsForSequenceNamedTweenDuration : function () {}, /** * @method addDocumentOutletName * @param {std::string} */ addDocumentOutletName : function () {}, /** * @method getSequences * @return A value converted from C/C++ "cocos2d::Vector&" */ getSequences : function () {}, /** * @method getRootContainerSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getRootContainerSize : function () {}, /** * @method setDocumentControllerName * @param {const std::string&} */ setDocumentControllerName : function () {}, /** * @method setObject * @param {cocos2d::Object*} * @param {cocos2d::Node*} * @param {const std::string&} */ setObject : function () {}, /** * @method getContainerSize * @return A value converted from C/C++ "const cocos2d::Size&" * @param {cocos2d::Node*} */ getContainerSize : function () {}, /** * @method actionForCallbackChannel * @return A value converted from C/C++ "cocos2d::Object*" * @param {cocosbuilder::CCBSequenceProperty*} */ actionForCallbackChannel : function () {}, /** * @method getDocumentOutletNames * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getDocumentOutletNames : function () {}, /** * @method addDocumentCallbackControlEvents * @param {cocos2d::extension::Control::EventType} */ addDocumentCallbackControlEvents : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method getKeyframeCallbacks * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getKeyframeCallbacks : function () {}, /** * @method getDocumentCallbackControlEvents * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getDocumentCallbackControlEvents : function () {}, /** * @method setRootContainerSize * @param {const cocos2d::Size&} */ setRootContainerSize : function () {}, /** * @method runAnimationsForSequenceIdTweenDuration * @param {int} * @param {float} */ runAnimationsForSequenceIdTweenDuration : function () {}, /** * @method getRunningSequenceName * @return A value converted from C/C++ "const char*" */ getRunningSequenceName : function () {}, /** * @method getAutoPlaySequenceId * @return A value converted from C/C++ "int" */ getAutoPlaySequenceId : function () {}, /** * @method addDocumentCallbackName * @param {std::string} */ addDocumentCallbackName : function () {}, /** * @method getRootNode * @return A value converted from C/C++ "cocos2d::Node*" */ getRootNode : function () {}, /** * @method addDocumentOutletNode * @param {cocos2d::Node*} */ addDocumentOutletNode : function () {}, /** * @method setDelegate * @param {cocosbuilder::CCBAnimationManagerDelegate*} */ setDelegate : function () {}, /** * @method getSequenceDuration * @return A value converted from C/C++ "float" * @param {const char*} */ getSequenceDuration : function () {}, /** * @method addDocumentCallbackNode * @param {cocos2d::Node*} */ addDocumentCallbackNode : function () {}, /** * @method getDelegate * @return A value converted from C/C++ "cocosbuilder::CCBAnimationManagerDelegate*" */ getDelegate : function () {}, /** * @method runAnimationsForSequenceNamed * @param {const char*} */ runAnimationsForSequenceNamed : function () {}, /** * @method getSequenceId * @return A value converted from C/C++ "int" * @param {const char*} */ getSequenceId : function () {}, /** * @method setCallFunc * @param {cocos2d::CallFunc*} * @param {const std::string&} */ setCallFunc : function () {}, /** * @method getDocumentCallbackNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getDocumentCallbackNodes : function () {}, /** * @method setSequences * @param {const cocos2d::Vector&} */ setSequences : function () {}, /** * @method debug */ debug : function () {}, /** * @method getDocumentControllerName * @return A value converted from C/C++ "std::string" */ getDocumentControllerName : function () {}, /** * @method CCBAnimationManager * @constructor */ CCBAnimationManager : function () {}, }; /** * @class CCBReader */ cc._Reader = { /** * @method getAnimationManager * @return A value converted from C/C++ "cocosbuilder::CCBAnimationManager*" */ getAnimationManager : function () {}, /** * @method setAnimationManager * @param {cocosbuilder::CCBAnimationManager*} */ setAnimationManager : function () {}, /** * @method addOwnerOutletName * @param {std::string} */ addOwnerOutletName : function () {}, /** * @method getOwnerCallbackNames * @return A value converted from C/C++ "cocos2d::ValueVector" */ getOwnerCallbackNames : function () {}, /** * @method addDocumentCallbackControlEvents * @param {cocos2d::extension::Control::EventType} */ addDocumentCallbackControlEvents : function () {}, /** * @method setCCBRootPath * @param {const char*} */ setCCBRootPath : function () {}, /** * @method addOwnerOutletNode * @param {cocos2d::Node*} */ addOwnerOutletNode : function () {}, /** * @method getOwnerCallbackNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getOwnerCallbackNodes : function () {}, /** * @method readSoundKeyframesForSeq * @return A value converted from C/C++ "bool" * @param {cocosbuilder::CCBSequence*} */ readSoundKeyframesForSeq : function () {}, /** * @method getCCBRootPath * @return A value converted from C/C++ "const std::string&" */ getCCBRootPath : function () {}, /** * @method getOwnerCallbackControlEvents * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getOwnerCallbackControlEvents : function () {}, /** * @method getOwnerOutletNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getOwnerOutletNodes : function () {}, /** * @method readUTF8 * @return A value converted from C/C++ "std::string" */ readUTF8 : function () {}, /** * @method addOwnerCallbackControlEvents * @param {cocos2d::extension::Control::EventType} */ addOwnerCallbackControlEvents : function () {}, /** * @method getOwnerOutletNames * @return A value converted from C/C++ "cocos2d::ValueVector" */ getOwnerOutletNames : function () {}, /** * @method readCallbackKeyframesForSeq * @return A value converted from C/C++ "bool" * @param {cocosbuilder::CCBSequence*} */ readCallbackKeyframesForSeq : function () {}, /** * @method getAnimationManagersForNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getAnimationManagersForNodes : function () {}, /** * @method getNodesWithAnimationManagers * @return A value converted from C/C++ "cocos2d::Vector&" */ getNodesWithAnimationManagers : function () {}, /** * @method setResolutionScale * @param {float} */ setResolutionScale : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_extension_auto.cpp ================================================ #include "jsb_cocos2dx_extension_auto.hpp" #include "cocos2d_specifics.hpp" #include "cocos-ext.h" template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedValue initializing(cx); JSBool isNewValid = JS_TRUE; JSObject* global = ScriptingCore::getInstance()->getGlobalObject(); isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && JSVAL_TO_BOOLEAN(initializing); if (isNewValid) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); return JS_TRUE; } JS_ReportError(cx, "Don't use `new cc.XXX`, please use `cc.XXX.create` instead! "); return JS_FALSE; } static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { return JS_FALSE; } static JSBool js_is_native_obj(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { vp.set(BOOLEAN_TO_JSVAL(JS_TRUE)); return JS_TRUE; } JSClass *jsb_cocos2d_extension_Scale9Sprite_class; JSObject *jsb_cocos2d_extension_Scale9Sprite_prototype; JSBool js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets : Error processing arguments"); cocos2d::extension::Scale9Sprite* ret = cobj->resizableSpriteWithCapInsets(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_setInsetBottom(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setInsetBottom : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setInsetBottom : Error processing arguments"); cobj->setInsetBottom(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setInsetBottom : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::Scale9Sprite* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName : Invalid Native Object"); do { if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithSpriteFrameName(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithSpriteFrameName(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_setInsetTop(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setInsetTop : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setInsetTop : Error processing arguments"); cobj->setInsetTop(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setInsetTop : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setPreferredSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setPreferredSize : Error processing arguments"); cobj->setPreferredSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setSpriteFrame : Invalid Native Object"); if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setSpriteFrame : Error processing arguments"); cobj->setSpriteFrame(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_initWithBatchNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::Scale9Sprite* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_initWithBatchNode : Invalid Native Object"); do { if (argc == 3) { cocos2d::SpriteBatchNode* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteBatchNode*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg2; ok &= jsval_to_ccrect(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithBatchNode(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 4) { cocos2d::SpriteBatchNode* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteBatchNode*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool arg2; ok &= JS_ValueToBoolean(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg3; ok &= jsval_to_ccrect(cx, argv[3], &arg3); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithBatchNode(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_initWithBatchNode : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_getInsetBottom : Invalid Native Object"); if (argc == 0) { double ret = cobj->getInsetBottom(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getInsetBottom : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_getCapInsets : Invalid Native Object"); if (argc == 0) { cocos2d::Rect ret = cobj->getCapInsets(); jsval jsret = JSVAL_NULL; jsret = ccrect_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getCapInsets : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_updateWithBatchNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_updateWithBatchNode : Invalid Native Object"); if (argc == 4) { cocos2d::SpriteBatchNode* arg0; cocos2d::Rect arg1; JSBool arg2; cocos2d::Rect arg3; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteBatchNode*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccrect(cx, argv[1], &arg1); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); ok &= jsval_to_ccrect(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_updateWithBatchNode : Error processing arguments"); JSBool ret = cobj->updateWithBatchNode(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_updateWithBatchNode : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_getInsetRight : Invalid Native Object"); if (argc == 0) { double ret = cobj->getInsetRight(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getInsetRight : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_getOriginalSize : Invalid Native Object"); if (argc == 0) { cocos2d::Size ret = cobj->getOriginalSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getOriginalSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::Scale9Sprite* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_initWithFile : Invalid Native Object"); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithFile(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg2; ok &= jsval_to_ccrect(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithFile(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithFile(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithFile(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_initWithFile : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_getInsetTop(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_getInsetTop : Invalid Native Object"); if (argc == 0) { double ret = cobj->getInsetTop(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getInsetTop : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_setInsetLeft(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setInsetLeft : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setInsetLeft : Error processing arguments"); cobj->setInsetLeft(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setInsetLeft : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::Scale9Sprite* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame : Invalid Native Object"); do { if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithSpriteFrame(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithSpriteFrame(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_getPreferredSize : Invalid Native Object"); if (argc == 0) { cocos2d::Size ret = cobj->getPreferredSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setCapInsets : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setCapInsets : Error processing arguments"); cobj->setCapInsets(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_getInsetLeft(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_getInsetLeft : Invalid Native Object"); if (argc == 0) { double ret = cobj->getInsetLeft(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getInsetLeft : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_setInsetRight(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Scale9Sprite* cobj = (cocos2d::extension::Scale9Sprite *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setInsetRight : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Scale9Sprite_setInsetRight : Error processing arguments"); cobj->setInsetRight(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setInsetRight : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg2; ok &= jsval_to_ccrect(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrameName(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrameName(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrame(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrame(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_Scale9Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::Scale9Sprite* cobj = new cocos2d::extension::Scale9Sprite(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::Scale9Sprite"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_extension_Scale9Sprite_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Scale9Sprite)", obj); } void js_register_cocos2dx_extension_Scale9Sprite(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_Scale9Sprite_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_Scale9Sprite_class->name = "Scale9Sprite"; jsb_cocos2d_extension_Scale9Sprite_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_Scale9Sprite_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_Scale9Sprite_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_Scale9Sprite_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_Scale9Sprite_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_Scale9Sprite_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_Scale9Sprite_class->convert = JS_ConvertStub; jsb_cocos2d_extension_Scale9Sprite_class->finalize = js_cocos2d_extension_Scale9Sprite_finalize; jsb_cocos2d_extension_Scale9Sprite_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("resizableSpriteWithCapInsets", js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInsetBottom", js_cocos2dx_extension_Scale9Sprite_setInsetBottom, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithSpriteFrameName", js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInsetTop", js_cocos2dx_extension_Scale9Sprite_setInsetTop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_extension_Scale9Sprite_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPreferredSize", js_cocos2dx_extension_Scale9Sprite_setPreferredSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSpriteFrame", js_cocos2dx_extension_Scale9Sprite_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithBatchNode", js_cocos2dx_extension_Scale9Sprite_initWithBatchNode, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInsetBottom", js_cocos2dx_extension_Scale9Sprite_getInsetBottom, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCapInsets", js_cocos2dx_extension_Scale9Sprite_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateWithBatchNode", js_cocos2dx_extension_Scale9Sprite_updateWithBatchNode, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInsetRight", js_cocos2dx_extension_Scale9Sprite_getInsetRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOriginalSize", js_cocos2dx_extension_Scale9Sprite_getOriginalSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithFile", js_cocos2dx_extension_Scale9Sprite_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInsetTop", js_cocos2dx_extension_Scale9Sprite_getInsetTop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInsetLeft", js_cocos2dx_extension_Scale9Sprite_setInsetLeft, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithSpriteFrame", js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPreferredSize", js_cocos2dx_extension_Scale9Sprite_getPreferredSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_extension_Scale9Sprite_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInsetLeft", js_cocos2dx_extension_Scale9Sprite_getInsetLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInsetRight", js_cocos2dx_extension_Scale9Sprite_setInsetRight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_Scale9Sprite_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithSpriteFrameName", js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithSpriteFrame", js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_Scale9Sprite_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_extension_Scale9Sprite_class, js_cocos2dx_extension_Scale9Sprite_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Scale9Sprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_Scale9Sprite_class; p->proto = jsb_cocos2d_extension_Scale9Sprite_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_Control_class; JSObject *jsb_cocos2d_extension_Control_prototype; JSBool js_cocos2dx_extension_Control_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Control_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_getState(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_getState : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getState(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_getState : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_sendActionsForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_sendActionsForControlEvents : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::EventType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Control_sendActionsForControlEvents : Error processing arguments"); cobj->sendActionsForControlEvents(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_sendActionsForControlEvents : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_setSelected(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_setSelected : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Control_setSelected : Error processing arguments"); cobj->setSelected(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_setSelected : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_isEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_needsLayout(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_needsLayout : Invalid Native Object"); if (argc == 0) { cobj->needsLayout(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_needsLayout : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_hasVisibleParents(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_hasVisibleParents : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->hasVisibleParents(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_hasVisibleParents : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_isSelected(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_isSelected : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isSelected(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_isSelected : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_isTouchInside(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_isTouchInside : Invalid Native Object"); if (argc == 1) { cocos2d::Touch* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Control_isTouchInside : Error processing arguments"); JSBool ret = cobj->isTouchInside(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_isTouchInside : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_setHighlighted(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_setHighlighted : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Control_setHighlighted : Error processing arguments"); cobj->setHighlighted(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_setHighlighted : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_getTouchLocation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_getTouchLocation : Invalid Native Object"); if (argc == 1) { cocos2d::Touch* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_Control_getTouchLocation : Error processing arguments"); cocos2d::Point ret = cobj->getTouchLocation(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_getTouchLocation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_isHighlighted(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_Control_isHighlighted : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isHighlighted(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_isHighlighted : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_Control_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::Control* ret = cocos2d::extension::Control::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Control*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_Control_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Layer_prototype; void js_cocos2d_extension_Control_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Control)", obj); } void js_register_cocos2dx_extension_Control(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_Control_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_Control_class->name = "Control"; jsb_cocos2d_extension_Control_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_Control_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_Control_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_Control_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_Control_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_Control_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_Control_class->convert = JS_ConvertStub; jsb_cocos2d_extension_Control_class->finalize = js_cocos2d_extension_Control_finalize; jsb_cocos2d_extension_Control_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEnabled", js_cocos2dx_extension_Control_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getState", js_cocos2dx_extension_Control_getState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("sendActionsForControlEvents", js_cocos2dx_extension_Control_sendActionsForControlEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelected", js_cocos2dx_extension_Control_setSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isEnabled", js_cocos2dx_extension_Control_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("needsLayout", js_cocos2dx_extension_Control_needsLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hasVisibleParents", js_cocos2dx_extension_Control_hasVisibleParents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSelected", js_cocos2dx_extension_Control_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchInside", js_cocos2dx_extension_Control_isTouchInside, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHighlighted", js_cocos2dx_extension_Control_setHighlighted, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchLocation", js_cocos2dx_extension_Control_getTouchLocation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isHighlighted", js_cocos2dx_extension_Control_isHighlighted, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_Control_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_Control_prototype = JS_InitClass( cx, global, jsb_cocos2d_Layer_prototype, jsb_cocos2d_extension_Control_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Control", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_Control_class; p->proto = jsb_cocos2d_extension_Control_prototype; p->parentProto = jsb_cocos2d_Layer_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ControlButton_class; JSObject *jsb_cocos2d_extension_ControlButton_prototype; JSBool js_cocos2dx_extension_ControlButton_isPushed(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_isPushed : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isPushed(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_isPushed : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setSelected(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setSelected : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setSelected : Error processing arguments"); cobj->setSelected(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setSelected : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setTitleLabelForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleLabelForState : Invalid Native Object"); if (argc == 2) { cocos2d::Node* arg0; cocos2d::extension::Control::State arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleLabelForState : Error processing arguments"); cobj->setTitleLabelForState(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleLabelForState : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage : Error processing arguments"); cobj->setAdjustBackgroundImage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setHighlighted(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setHighlighted : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setHighlighted : Error processing arguments"); cobj->setHighlighted(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setHighlighted : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setZoomOnTouchDown : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setZoomOnTouchDown : Error processing arguments"); cobj->setZoomOnTouchDown(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setZoomOnTouchDown : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setTitleForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleForState : Invalid Native Object"); if (argc == 2) { std::string arg0; cocos2d::extension::Control::State arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleForState : Error processing arguments"); cobj->setTitleForState(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleForState : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setLabelAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setLabelAnchorPoint : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setLabelAnchorPoint : Error processing arguments"); cobj->setLabelAnchorPoint(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setLabelAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getLabelAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getLabelAnchorPoint : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getLabelAnchorPoint(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getLabelAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState : Error processing arguments"); double ret = cobj->getTitleTTFSizeForState(arg0); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setTitleTTFForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleTTFForState : Invalid Native Object"); if (argc == 2) { std::string arg0; cocos2d::extension::Control::State arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleTTFForState : Error processing arguments"); cobj->setTitleTTFForState(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleTTFForState : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState : Invalid Native Object"); if (argc == 2) { double arg0; cocos2d::extension::Control::State arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState : Error processing arguments"); cobj->setTitleTTFSizeForState(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setTitleLabel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleLabel : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleLabel : Error processing arguments"); cobj->setTitleLabel(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleLabel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setPreferredSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setPreferredSize : Error processing arguments"); cobj->setPreferredSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getCurrentTitleColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getCurrentTitleColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color3B& ret = cobj->getCurrentTitleColor(); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getCurrentTitleColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState : Error processing arguments"); cocos2d::extension::Scale9Sprite* ret = cobj->getBackgroundSpriteForState(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getHorizontalOrigin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getHorizontalOrigin : Invalid Native Object"); if (argc == 0) { int ret = cobj->getHorizontalOrigin(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getHorizontalOrigin : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_needsLayout(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_needsLayout : Invalid Native Object"); if (argc == 0) { cobj->needsLayout(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_needsLayout : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getCurrentTitle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::ControlButton* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getCurrentTitle : Invalid Native Object"); do { if (argc == 0) { std::string ret = cobj->getCurrentTitle(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { const std::string& ret = cobj->getCurrentTitle(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getCurrentTitle : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getScaleRatio(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getScaleRatio : Invalid Native Object"); if (argc == 0) { double ret = cobj->getScaleRatio(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getScaleRatio : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getTitleTTFForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleTTFForState : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleTTFForState : Error processing arguments"); const std::string& ret = cobj->getTitleTTFForState(arg0); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleTTFForState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getBackgroundSprite : Invalid Native Object"); if (argc == 0) { cocos2d::extension::Scale9Sprite* ret = cobj->getBackgroundSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::Scale9Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getTitleColorForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleColorForState : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleColorForState : Error processing arguments"); cocos2d::Color3B ret = cobj->getTitleColorForState(arg0); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleColorForState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setTitleColorForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleColorForState : Invalid Native Object"); if (argc == 2) { cocos2d::Color3B arg0; cocos2d::extension::Control::State arg1; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleColorForState : Error processing arguments"); cobj->setTitleColorForState(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleColorForState : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->doesAdjustBackgroundImage(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState : Invalid Native Object"); if (argc == 2) { cocos2d::SpriteFrame* arg0; cocos2d::extension::Control::State arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState : Error processing arguments"); cobj->setBackgroundSpriteFrameForState(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState : Invalid Native Object"); if (argc == 2) { cocos2d::extension::Scale9Sprite* arg0; cocos2d::extension::Control::State arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState : Error processing arguments"); cobj->setBackgroundSpriteForState(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setScaleRatio(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setScaleRatio : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setScaleRatio : Error processing arguments"); cobj->setScaleRatio(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setScaleRatio : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setBackgroundSprite : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Scale9Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setBackgroundSprite : Error processing arguments"); cobj->setBackgroundSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getTitleLabel(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleLabel : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getTitleLabel(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleLabel : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getPreferredSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getPreferredSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getVerticalMargin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getVerticalMargin : Invalid Native Object"); if (argc == 0) { int ret = cobj->getVerticalMargin(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getVerticalMargin : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getTitleLabelForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleLabelForState : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleLabelForState : Error processing arguments"); cocos2d::Node* ret = cobj->getTitleLabelForState(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleLabelForState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setMargins(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setMargins : Invalid Native Object"); if (argc == 2) { int arg0; int arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setMargins : Error processing arguments"); cobj->setMargins(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setMargins : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_setTitleBMFontForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleBMFontForState : Invalid Native Object"); if (argc == 2) { std::string arg0; cocos2d::extension::Control::State arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_setTitleBMFontForState : Error processing arguments"); cobj->setTitleBMFontForState(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleBMFontForState : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getTitleBMFontForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleBMFontForState : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleBMFontForState : Error processing arguments"); const std::string& ret = cobj->getTitleBMFontForState(arg0); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleBMFontForState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getZoomOnTouchDown : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getZoomOnTouchDown(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getZoomOnTouchDown : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_getTitleForState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleForState : Invalid Native Object"); if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlButton_getTitleForState : Error processing arguments"); std::string ret = cobj->getTitleForState(arg0); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleForState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocos2d::extension::Scale9Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlButton*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlButton*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::Scale9Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlButton*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlButton*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_Control_prototype; void js_cocos2d_extension_ControlButton_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ControlButton)", obj); } void js_register_cocos2dx_extension_ControlButton(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ControlButton_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ControlButton_class->name = "ControlButton"; jsb_cocos2d_extension_ControlButton_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlButton_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ControlButton_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlButton_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ControlButton_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ControlButton_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ControlButton_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ControlButton_class->finalize = js_cocos2d_extension_ControlButton_finalize; jsb_cocos2d_extension_ControlButton_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("isPushed", js_cocos2dx_extension_ControlButton_isPushed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelected", js_cocos2dx_extension_ControlButton_setSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleLabelForState", js_cocos2dx_extension_ControlButton_setTitleLabelForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAdjustBackgroundImage", js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHighlighted", js_cocos2dx_extension_ControlButton_setHighlighted, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setZoomOnTouchDown", js_cocos2dx_extension_ControlButton_setZoomOnTouchDown, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleForState", js_cocos2dx_extension_ControlButton_setTitleForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLabelAnchorPoint", js_cocos2dx_extension_ControlButton_setLabelAnchorPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLabelAnchorPoint", js_cocos2dx_extension_ControlButton_getLabelAnchorPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleTTFSizeForState", js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleTTFForState", js_cocos2dx_extension_ControlButton_setTitleTTFForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleTTFSizeForState", js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleLabel", js_cocos2dx_extension_ControlButton_setTitleLabel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPreferredSize", js_cocos2dx_extension_ControlButton_setPreferredSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentTitleColor", js_cocos2dx_extension_ControlButton_getCurrentTitleColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEnabled", js_cocos2dx_extension_ControlButton_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackgroundSpriteForState", js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHorizontalOrigin", js_cocos2dx_extension_ControlButton_getHorizontalOrigin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("needsLayout", js_cocos2dx_extension_ControlButton_needsLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentTitle", js_cocos2dx_extension_ControlButton_getCurrentTitle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScaleRatio", js_cocos2dx_extension_ControlButton_getScaleRatio, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleTTFForState", js_cocos2dx_extension_ControlButton_getTitleTTFForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackgroundSprite", js_cocos2dx_extension_ControlButton_getBackgroundSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleColorForState", js_cocos2dx_extension_ControlButton_getTitleColorForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleColorForState", js_cocos2dx_extension_ControlButton_setTitleColorForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("doesAdjustBackgroundImage", js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackgroundSpriteFrameForState", js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackgroundSpriteForState", js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScaleRatio", js_cocos2dx_extension_ControlButton_setScaleRatio, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackgroundSprite", js_cocos2dx_extension_ControlButton_setBackgroundSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleLabel", js_cocos2dx_extension_ControlButton_getTitleLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPreferredSize", js_cocos2dx_extension_ControlButton_getPreferredSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVerticalMargin", js_cocos2dx_extension_ControlButton_getVerticalMargin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleLabelForState", js_cocos2dx_extension_ControlButton_getTitleLabelForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMargins", js_cocos2dx_extension_ControlButton_setMargins, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleBMFontForState", js_cocos2dx_extension_ControlButton_setTitleBMFontForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleBMFontForState", js_cocos2dx_extension_ControlButton_getTitleBMFontForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomOnTouchDown", js_cocos2dx_extension_ControlButton_getZoomOnTouchDown, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleForState", js_cocos2dx_extension_ControlButton_getTitleForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ControlButton_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ControlButton_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_Control_prototype, jsb_cocos2d_extension_ControlButton_class, dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ControlButton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ControlButton_class; p->proto = jsb_cocos2d_extension_ControlButton_prototype; p->parentProto = jsb_cocos2d_extension_Control_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ControlHuePicker_class; JSObject *jsb_cocos2d_extension_ControlHuePicker_prototype; JSBool js_cocos2dx_extension_ControlHuePicker_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos : Invalid Native Object"); if (argc == 2) { cocos2d::Node* arg0; cocos2d::Point arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos : Error processing arguments"); JSBool ret = cobj->initWithTargetAndPos(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_setHue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setHue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setHue : Error processing arguments"); cobj->setHue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setHue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_getStartPos(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_getStartPos : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getStartPos(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getStartPos : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_getHue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_getHue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getHue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getHue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_getSlider(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_getSlider : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getSlider(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getSlider : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_setBackground(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setBackground : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setBackground : Error processing arguments"); cobj->setBackground(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setBackground : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_setHuePercentage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setHuePercentage : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setHuePercentage : Error processing arguments"); cobj->setHuePercentage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setHuePercentage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_getBackground : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getBackground(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getBackground : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_getHuePercentage(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_getHuePercentage : Invalid Native Object"); if (argc == 0) { double ret = cobj->getHuePercentage(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getHuePercentage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_setSlider(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setSlider : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_setSlider : Error processing arguments"); cobj->setSlider(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setSlider : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Node* arg0; cocos2d::Point arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlHuePicker_create : Error processing arguments"); cocos2d::extension::ControlHuePicker* ret = cocos2d::extension::ControlHuePicker::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlHuePicker*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlHuePicker_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ControlHuePicker* cobj = new cocos2d::extension::ControlHuePicker(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlHuePicker"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_Control_prototype; void js_cocos2d_extension_ControlHuePicker_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ControlHuePicker)", obj); } void js_register_cocos2dx_extension_ControlHuePicker(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ControlHuePicker_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ControlHuePicker_class->name = "ControlHuePicker"; jsb_cocos2d_extension_ControlHuePicker_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlHuePicker_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ControlHuePicker_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlHuePicker_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ControlHuePicker_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ControlHuePicker_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ControlHuePicker_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ControlHuePicker_class->finalize = js_cocos2d_extension_ControlHuePicker_finalize; jsb_cocos2d_extension_ControlHuePicker_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEnabled", js_cocos2dx_extension_ControlHuePicker_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTargetAndPos", js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHue", js_cocos2dx_extension_ControlHuePicker_setHue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartPos", js_cocos2dx_extension_ControlHuePicker_getStartPos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHue", js_cocos2dx_extension_ControlHuePicker_getHue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSlider", js_cocos2dx_extension_ControlHuePicker_getSlider, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackground", js_cocos2dx_extension_ControlHuePicker_setBackground, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHuePercentage", js_cocos2dx_extension_ControlHuePicker_setHuePercentage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackground", js_cocos2dx_extension_ControlHuePicker_getBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHuePercentage", js_cocos2dx_extension_ControlHuePicker_getHuePercentage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSlider", js_cocos2dx_extension_ControlHuePicker_setSlider, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ControlHuePicker_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ControlHuePicker_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_Control_prototype, jsb_cocos2d_extension_ControlHuePicker_class, js_cocos2dx_extension_ControlHuePicker_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ControlHuePicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ControlHuePicker_class; p->proto = jsb_cocos2d_extension_ControlHuePicker_prototype; p->parentProto = jsb_cocos2d_extension_Control_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class; JSObject *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype; JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getShadow(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos : Invalid Native Object"); if (argc == 2) { cocos2d::Node* arg0; cocos2d::Point arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos : Error processing arguments"); JSBool ret = cobj->initWithTargetAndPos(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getStartPos(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getOverlay(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getSlider(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getBackground(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation : Invalid Native Object"); if (argc == 0) { double ret = cobj->getSaturation(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness : Invalid Native Object"); if (argc == 0) { double ret = cobj->getBrightness(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Node* arg0; cocos2d::Point arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_create : Error processing arguments"); cocos2d::extension::ControlSaturationBrightnessPicker* ret = cocos2d::extension::ControlSaturationBrightnessPicker::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSaturationBrightnessPicker*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ControlSaturationBrightnessPicker* cobj = new cocos2d::extension::ControlSaturationBrightnessPicker(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlSaturationBrightnessPicker"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_Control_prototype; void js_cocos2d_extension_ControlSaturationBrightnessPicker_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ControlSaturationBrightnessPicker)", obj); } void js_register_cocos2dx_extension_ControlSaturationBrightnessPicker(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->name = "ControlSaturationBrightnessPicker"; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->finalize = js_cocos2d_extension_ControlSaturationBrightnessPicker_finalize; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getShadow", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTargetAndPos", js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartPos", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOverlay", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEnabled", js_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSlider", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackground", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSaturation", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBrightness", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ControlSaturationBrightnessPicker_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_Control_prototype, jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class, js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ControlSaturationBrightnessPicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class; p->proto = jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype; p->parentProto = jsb_cocos2d_extension_Control_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ControlColourPicker_class; JSObject *jsb_cocos2d_extension_ControlColourPicker_prototype; JSBool js_cocos2dx_extension_ControlColourPicker_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_getHuePicker(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_getHuePicker : Invalid Native Object"); if (argc == 0) { cocos2d::extension::ControlHuePicker* ret = cobj->getHuePicker(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlHuePicker*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_getHuePicker : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_setColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setColor : Error processing arguments"); cobj->setColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_setColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged : Invalid Native Object"); if (argc == 2) { cocos2d::Object* arg0; cocos2d::extension::Control::EventType arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged : Error processing arguments"); cobj->hueSliderValueChanged(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_getcolourPicker(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_getcolourPicker : Invalid Native Object"); if (argc == 0) { cocos2d::extension::ControlSaturationBrightnessPicker* ret = cobj->getcolourPicker(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSaturationBrightnessPicker*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_getcolourPicker : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_setBackground(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setBackground : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setBackground : Error processing arguments"); cobj->setBackground(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_setBackground : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_setcolourPicker(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setcolourPicker : Invalid Native Object"); if (argc == 1) { cocos2d::extension::ControlSaturationBrightnessPicker* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ControlSaturationBrightnessPicker*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setcolourPicker : Error processing arguments"); cobj->setcolourPicker(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_setcolourPicker : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged : Invalid Native Object"); if (argc == 2) { cocos2d::Object* arg0; cocos2d::extension::Control::EventType arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged : Error processing arguments"); cobj->colourSliderValueChanged(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_setHuePicker(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setHuePicker : Invalid Native Object"); if (argc == 1) { cocos2d::extension::ControlHuePicker* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ControlHuePicker*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_setHuePicker : Error processing arguments"); cobj->setHuePicker(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_setHuePicker : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlColourPicker_getBackground : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getBackground(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_getBackground : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ControlColourPicker* ret = cocos2d::extension::ControlColourPicker::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlColourPicker*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlColourPicker_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ControlColourPicker* cobj = new cocos2d::extension::ControlColourPicker(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlColourPicker"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_Control_prototype; void js_cocos2d_extension_ControlColourPicker_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ControlColourPicker)", obj); } void js_register_cocos2dx_extension_ControlColourPicker(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ControlColourPicker_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ControlColourPicker_class->name = "ControlColourPicker"; jsb_cocos2d_extension_ControlColourPicker_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlColourPicker_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ControlColourPicker_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlColourPicker_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ControlColourPicker_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ControlColourPicker_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ControlColourPicker_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ControlColourPicker_class->finalize = js_cocos2d_extension_ControlColourPicker_finalize; jsb_cocos2d_extension_ControlColourPicker_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEnabled", js_cocos2dx_extension_ControlColourPicker_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHuePicker", js_cocos2dx_extension_ControlColourPicker_getHuePicker, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setColor", js_cocos2dx_extension_ControlColourPicker_setColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hueSliderValueChanged", js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getcolourPicker", js_cocos2dx_extension_ControlColourPicker_getcolourPicker, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackground", js_cocos2dx_extension_ControlColourPicker_setBackground, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_extension_ControlColourPicker_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setcolourPicker", js_cocos2dx_extension_ControlColourPicker_setcolourPicker, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("colourSliderValueChanged", js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHuePicker", js_cocos2dx_extension_ControlColourPicker_setHuePicker, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackground", js_cocos2dx_extension_ControlColourPicker_getBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ControlColourPicker_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ControlColourPicker_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_Control_prototype, jsb_cocos2d_extension_ControlColourPicker_class, js_cocos2dx_extension_ControlColourPicker_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ControlColourPicker", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ControlColourPicker_class; p->proto = jsb_cocos2d_extension_ControlColourPicker_prototype; p->parentProto = jsb_cocos2d_extension_Control_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ControlPotentiometer_class; JSObject *jsb_cocos2d_extension_ControlPotentiometer_prototype; JSBool js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation : Error processing arguments"); cobj->setPreviousLocation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_setValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setValue : Error processing arguments"); cobj->setValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_getProgressTimer(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_getProgressTimer : Invalid Native Object"); if (argc == 0) { cocos2d::ProgressTimer* ret = cobj->getProgressTimer(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::ProgressTimer*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getProgressTimer : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_getMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_getMaximumValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMaximumValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : Invalid Native Object"); if (argc == 4) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::Point arg2; cocos2d::Point arg3; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); ok &= jsval_to_ccpoint(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : Error processing arguments"); double ret = cobj->angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan : Error processing arguments"); cobj->potentiometerBegan(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setMaximumValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setMaximumValue : Error processing arguments"); cobj->setMaximumValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_getMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_getMinimumValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMinimumValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_setThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setThumbSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setThumbSprite : Error processing arguments"); cobj->setThumbSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_getValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_getValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getPreviousLocation(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint : Invalid Native Object"); if (argc == 2) { cocos2d::Point arg0; cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint : Error processing arguments"); double ret = cobj->distanceBetweenPointAndPoint(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded : Error processing arguments"); cobj->potentiometerEnded(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_setProgressTimer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setProgressTimer : Invalid Native Object"); if (argc == 1) { cocos2d::ProgressTimer* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::ProgressTimer*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setProgressTimer : Error processing arguments"); cobj->setProgressTimer(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setProgressTimer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setMinimumValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_setMinimumValue : Error processing arguments"); cobj->setMinimumValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_getThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_getThumbSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getThumbSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite : Invalid Native Object"); if (argc == 3) { cocos2d::Sprite* arg0; cocos2d::ProgressTimer* arg1; cocos2d::Sprite* arg2; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::ProgressTimer*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite : Error processing arguments"); JSBool ret = cobj->initWithTrackSprite_ProgressTimer_ThumbSprite(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved : Error processing arguments"); cobj->potentiometerMoved(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { const char* arg0; const char* arg1; const char* arg2; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlPotentiometer_create : Error processing arguments"); cocos2d::extension::ControlPotentiometer* ret = cocos2d::extension::ControlPotentiometer::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlPotentiometer*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlPotentiometer_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ControlPotentiometer* cobj = new cocos2d::extension::ControlPotentiometer(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlPotentiometer"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_Control_prototype; void js_cocos2d_extension_ControlPotentiometer_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ControlPotentiometer)", obj); } void js_register_cocos2dx_extension_ControlPotentiometer(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ControlPotentiometer_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ControlPotentiometer_class->name = "ControlPotentiometer"; jsb_cocos2d_extension_ControlPotentiometer_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlPotentiometer_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ControlPotentiometer_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlPotentiometer_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ControlPotentiometer_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ControlPotentiometer_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ControlPotentiometer_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ControlPotentiometer_class->finalize = js_cocos2d_extension_ControlPotentiometer_finalize; jsb_cocos2d_extension_ControlPotentiometer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setPreviousLocation", js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setValue", js_cocos2dx_extension_ControlPotentiometer_setValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProgressTimer", js_cocos2dx_extension_ControlPotentiometer_getProgressTimer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaximumValue", js_cocos2dx_extension_ControlPotentiometer_getMaximumValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint", js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("potentiometerBegan", js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaximumValue", js_cocos2dx_extension_ControlPotentiometer_setMaximumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMinimumValue", js_cocos2dx_extension_ControlPotentiometer_getMinimumValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setThumbSprite", js_cocos2dx_extension_ControlPotentiometer_setThumbSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getValue", js_cocos2dx_extension_ControlPotentiometer_getValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPreviousLocation", js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("distanceBetweenPointAndPoint", js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("potentiometerEnded", js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProgressTimer", js_cocos2dx_extension_ControlPotentiometer_setProgressTimer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMinimumValue", js_cocos2dx_extension_ControlPotentiometer_setMinimumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getThumbSprite", js_cocos2dx_extension_ControlPotentiometer_getThumbSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTrackSprite_ProgressTimer_ThumbSprite", js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("potentiometerMoved", js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ControlPotentiometer_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ControlPotentiometer_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_Control_prototype, jsb_cocos2d_extension_ControlPotentiometer_class, js_cocos2dx_extension_ControlPotentiometer_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ControlPotentiometer", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ControlPotentiometer_class; p->proto = jsb_cocos2d_extension_ControlPotentiometer_prototype; p->parentProto = jsb_cocos2d_extension_Control_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ControlSlider_class; JSObject *jsb_cocos2d_extension_ControlSlider_prototype; JSBool js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getSelectedThumbSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_locationFromTouch(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_locationFromTouch : Invalid Native Object"); if (argc == 1) { cocos2d::Touch* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_locationFromTouch : Error processing arguments"); cocos2d::Point ret = cobj->locationFromTouch(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_locationFromTouch : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite : Error processing arguments"); cobj->setSelectedThumbSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setProgressSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setProgressSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setProgressSprite : Error processing arguments"); cobj->setProgressSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setProgressSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMaximumAllowedValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMinimumAllowedValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_getMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getMinimumValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMinimumValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setThumbSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setThumbSprite : Error processing arguments"); cobj->setThumbSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setMinimumValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setMinimumValue : Error processing arguments"); cobj->setMinimumValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue : Error processing arguments"); cobj->setMinimumAllowedValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setValue : Error processing arguments"); cobj->setValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setMaximumValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setMaximumValue : Error processing arguments"); cobj->setMaximumValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_needsLayout(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_needsLayout : Invalid Native Object"); if (argc == 0) { cobj->needsLayout(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_needsLayout : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_getBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getBackgroundSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getBackgroundSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::ControlSlider* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_initWithSprites : Invalid Native Object"); do { if (argc == 4) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg3; do { if (!argv[3].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); proxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithSprites(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 3) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithSprites(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_initWithSprites : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_getMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getMaximumValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getMaximumValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_isTouchInside(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_isTouchInside : Invalid Native Object"); if (argc == 1) { cocos2d::Touch* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_isTouchInside : Error processing arguments"); JSBool ret = cobj->isTouchInside(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_isTouchInside : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_getValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_getThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getThumbSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getThumbSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_getProgressSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_getProgressSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getProgressSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getProgressSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setBackgroundSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setBackgroundSprite : Error processing arguments"); cobj->setBackgroundSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue : Error processing arguments"); cobj->setMaximumAllowedValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 3) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSlider*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg2; std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSlider*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 4) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg2; std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg3; std::string arg3_tmp; ok &= jsval_to_std_string(cx, argv[3], &arg3_tmp); arg3 = arg3_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSlider*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 4) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg3; do { if (!argv[3].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); proxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSlider*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSlider_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ControlSlider* cobj = new cocos2d::extension::ControlSlider(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlSlider"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_Control_prototype; void js_cocos2d_extension_ControlSlider_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ControlSlider)", obj); } void js_register_cocos2dx_extension_ControlSlider(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ControlSlider_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ControlSlider_class->name = "ControlSlider"; jsb_cocos2d_extension_ControlSlider_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlSlider_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ControlSlider_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlSlider_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ControlSlider_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ControlSlider_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ControlSlider_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ControlSlider_class->finalize = js_cocos2d_extension_ControlSlider_finalize; jsb_cocos2d_extension_ControlSlider_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getSelectedThumbSprite", js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("locationFromTouch", js_cocos2dx_extension_ControlSlider_locationFromTouch, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelectedThumbSprite", js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProgressSprite", js_cocos2dx_extension_ControlSlider_setProgressSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaximumAllowedValue", js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMinimumAllowedValue", js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMinimumValue", js_cocos2dx_extension_ControlSlider_getMinimumValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setThumbSprite", js_cocos2dx_extension_ControlSlider_setThumbSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMinimumValue", js_cocos2dx_extension_ControlSlider_setMinimumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMinimumAllowedValue", js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEnabled", js_cocos2dx_extension_ControlSlider_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setValue", js_cocos2dx_extension_ControlSlider_setValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaximumValue", js_cocos2dx_extension_ControlSlider_setMaximumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("needsLayout", js_cocos2dx_extension_ControlSlider_needsLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackgroundSprite", js_cocos2dx_extension_ControlSlider_getBackgroundSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithSprites", js_cocos2dx_extension_ControlSlider_initWithSprites, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaximumValue", js_cocos2dx_extension_ControlSlider_getMaximumValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchInside", js_cocos2dx_extension_ControlSlider_isTouchInside, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getValue", js_cocos2dx_extension_ControlSlider_getValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getThumbSprite", js_cocos2dx_extension_ControlSlider_getThumbSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProgressSprite", js_cocos2dx_extension_ControlSlider_getProgressSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackgroundSprite", js_cocos2dx_extension_ControlSlider_setBackgroundSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaximumAllowedValue", js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ControlSlider_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ControlSlider_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_Control_prototype, jsb_cocos2d_extension_ControlSlider_class, js_cocos2dx_extension_ControlSlider_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ControlSlider", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ControlSlider_class; p->proto = jsb_cocos2d_extension_ControlSlider_prototype; p->parentProto = jsb_cocos2d_extension_Control_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ControlStepper_class; JSObject *jsb_cocos2d_extension_ControlStepper_prototype; JSBool js_cocos2dx_extension_ControlStepper_setMinusSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setMinusSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setMinusSprite : Error processing arguments"); cobj->setMinusSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setMinusSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_getMinusLabel(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_getMinusLabel : Invalid Native Object"); if (argc == 0) { cocos2d::LabelTTF* ret = cobj->getMinusLabel(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getMinusLabel : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setWraps(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setWraps : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setWraps : Error processing arguments"); cobj->setWraps(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setWraps : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_isContinuous(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_isContinuous : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isContinuous(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_isContinuous : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_getMinusSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_getMinusSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getMinusSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getMinusSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation : Error processing arguments"); cobj->updateLayoutUsingTouchLocation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent : Error processing arguments"); cobj->setValueWithSendingEvent(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_getPlusLabel(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_getPlusLabel : Invalid Native Object"); if (argc == 0) { cocos2d::LabelTTF* ret = cobj->getPlusLabel(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getPlusLabel : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_stopAutorepeat(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_stopAutorepeat : Invalid Native Object"); if (argc == 0) { cobj->stopAutorepeat(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_stopAutorepeat : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setMinimumValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setMinimumValue : Error processing arguments"); cobj->setMinimumValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_getPlusSprite(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_getPlusSprite : Invalid Native Object"); if (argc == 0) { cocos2d::Sprite* ret = cobj->getPlusSprite(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getPlusSprite : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setPlusSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setPlusSprite : Invalid Native Object"); if (argc == 1) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setPlusSprite : Error processing arguments"); cobj->setPlusSprite(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setPlusSprite : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setMinusLabel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setMinusLabel : Invalid Native Object"); if (argc == 1) { cocos2d::LabelTTF* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::LabelTTF*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setMinusLabel : Error processing arguments"); cobj->setMinusLabel(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setMinusLabel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setValue : Error processing arguments"); cobj->setValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setStepValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setStepValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setStepValue : Error processing arguments"); cobj->setStepValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setStepValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setMaximumValue : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setMaximumValue : Error processing arguments"); cobj->setMaximumValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_update(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_update : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_update : Error processing arguments"); cobj->update(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_update : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_startAutorepeat(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_startAutorepeat : Invalid Native Object"); if (argc == 0) { cobj->startAutorepeat(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_startAutorepeat : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite : Invalid Native Object"); if (argc == 2) { cocos2d::Sprite* arg0; cocos2d::Sprite* arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite : Error processing arguments"); JSBool ret = cobj->initWithMinusSpriteAndPlusSprite(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_getValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_getValue : Invalid Native Object"); if (argc == 0) { double ret = cobj->getValue(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_setPlusLabel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setPlusLabel : Invalid Native Object"); if (argc == 1) { cocos2d::LabelTTF* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::LabelTTF*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_setPlusLabel : Error processing arguments"); cobj->setPlusLabel(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setPlusLabel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Sprite* arg0; cocos2d::Sprite* arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlStepper_create : Error processing arguments"); cocos2d::extension::ControlStepper* ret = cocos2d::extension::ControlStepper::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlStepper*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlStepper_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ControlStepper* cobj = new cocos2d::extension::ControlStepper(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlStepper"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_Control_prototype; void js_cocos2d_extension_ControlStepper_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ControlStepper)", obj); } void js_register_cocos2dx_extension_ControlStepper(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ControlStepper_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ControlStepper_class->name = "ControlStepper"; jsb_cocos2d_extension_ControlStepper_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlStepper_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ControlStepper_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlStepper_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ControlStepper_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ControlStepper_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ControlStepper_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ControlStepper_class->finalize = js_cocos2d_extension_ControlStepper_finalize; jsb_cocos2d_extension_ControlStepper_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setMinusSprite", js_cocos2dx_extension_ControlStepper_setMinusSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMinusLabel", js_cocos2dx_extension_ControlStepper_getMinusLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setWraps", js_cocos2dx_extension_ControlStepper_setWraps, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isContinuous", js_cocos2dx_extension_ControlStepper_isContinuous, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMinusSprite", js_cocos2dx_extension_ControlStepper_getMinusSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateLayoutUsingTouchLocation", js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setValueWithSendingEvent", js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPlusLabel", js_cocos2dx_extension_ControlStepper_getPlusLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopAutorepeat", js_cocos2dx_extension_ControlStepper_stopAutorepeat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMinimumValue", js_cocos2dx_extension_ControlStepper_setMinimumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPlusSprite", js_cocos2dx_extension_ControlStepper_getPlusSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlusSprite", js_cocos2dx_extension_ControlStepper_setPlusSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMinusLabel", js_cocos2dx_extension_ControlStepper_setMinusLabel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setValue", js_cocos2dx_extension_ControlStepper_setValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStepValue", js_cocos2dx_extension_ControlStepper_setStepValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaximumValue", js_cocos2dx_extension_ControlStepper_setMaximumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", js_cocos2dx_extension_ControlStepper_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("startAutorepeat", js_cocos2dx_extension_ControlStepper_startAutorepeat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithMinusSpriteAndPlusSprite", js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getValue", js_cocos2dx_extension_ControlStepper_getValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlusLabel", js_cocos2dx_extension_ControlStepper_setPlusLabel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ControlStepper_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ControlStepper_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_Control_prototype, jsb_cocos2d_extension_ControlStepper_class, js_cocos2dx_extension_ControlStepper_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ControlStepper", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ControlStepper_class; p->proto = jsb_cocos2d_extension_ControlStepper_prototype; p->parentProto = jsb_cocos2d_extension_Control_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ControlSwitch_class; JSObject *jsb_cocos2d_extension_ControlSwitch_prototype; JSBool js_cocos2dx_extension_ControlSwitch_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSwitch* cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSwitch_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSwitch_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSwitch_setOn(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::ControlSwitch* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSwitch_setOn : Invalid Native Object"); do { if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setOn(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 2) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool arg1; ok &= JS_ValueToBoolean(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj->setOn(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_setOn : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSwitch_isOn(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSwitch* cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSwitch_isOn : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isOn(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_isOn : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::ControlSwitch* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSwitch_initWithMaskSprite : Invalid Native Object"); do { if (argc == 6) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg3; do { if (!argv[3].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); proxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelTTF* arg4; do { if (!argv[4].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[4]); proxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::LabelTTF*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelTTF* arg5; do { if (!argv[5].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[5]); proxy = jsb_get_js_proxy(tmpObj); arg5 = (cocos2d::LabelTTF*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg5, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithMaskSprite(arg0, arg1, arg2, arg3, arg4, arg5); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 4) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg3; do { if (!argv[3].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); proxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->initWithMaskSprite(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_initWithMaskSprite : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSwitch_hasMoved(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSwitch* cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSwitch_hasMoved : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->hasMoved(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_hasMoved : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSwitch_locationFromTouch(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlSwitch* cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ControlSwitch_locationFromTouch : Invalid Native Object"); if (argc == 1) { cocos2d::Touch* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Touch*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ControlSwitch_locationFromTouch : Error processing arguments"); cocos2d::Point ret = cobj->locationFromTouch(arg0); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_locationFromTouch : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 4) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg3; do { if (!argv[3].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); proxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlSwitch* ret = cocos2d::extension::ControlSwitch::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSwitch*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 6) { cocos2d::Sprite* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Sprite* arg3; do { if (!argv[3].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); proxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelTTF* arg4; do { if (!argv[4].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[4]); proxy = jsb_get_js_proxy(tmpObj); arg4 = (cocos2d::LabelTTF*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg4, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::LabelTTF* arg5; do { if (!argv[5].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[5]); proxy = jsb_get_js_proxy(tmpObj); arg5 = (cocos2d::LabelTTF*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg5, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ControlSwitch* ret = cocos2d::extension::ControlSwitch::create(arg0, arg1, arg2, arg3, arg4, arg5); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSwitch*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ControlSwitch_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ControlSwitch* cobj = new cocos2d::extension::ControlSwitch(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlSwitch"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_Control_prototype; void js_cocos2d_extension_ControlSwitch_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ControlSwitch)", obj); } void js_register_cocos2dx_extension_ControlSwitch(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ControlSwitch_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ControlSwitch_class->name = "ControlSwitch"; jsb_cocos2d_extension_ControlSwitch_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlSwitch_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ControlSwitch_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ControlSwitch_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ControlSwitch_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ControlSwitch_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ControlSwitch_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ControlSwitch_class->finalize = js_cocos2d_extension_ControlSwitch_finalize; jsb_cocos2d_extension_ControlSwitch_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setEnabled", js_cocos2dx_extension_ControlSwitch_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOn", js_cocos2dx_extension_ControlSwitch_setOn, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isOn", js_cocos2dx_extension_ControlSwitch_isOn, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithMaskSprite", js_cocos2dx_extension_ControlSwitch_initWithMaskSprite, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hasMoved", js_cocos2dx_extension_ControlSwitch_hasMoved, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("locationFromTouch", js_cocos2dx_extension_ControlSwitch_locationFromTouch, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ControlSwitch_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ControlSwitch_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_Control_prototype, jsb_cocos2d_extension_ControlSwitch_class, js_cocos2dx_extension_ControlSwitch_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ControlSwitch", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ControlSwitch_class; p->proto = jsb_cocos2d_extension_ControlSwitch_prototype; p->parentProto = jsb_cocos2d_extension_Control_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_ScrollView_class; JSObject *jsb_cocos2d_extension_ScrollView_prototype; JSBool js_cocos2dx_extension_ScrollView_isClippingToBounds(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_isClippingToBounds : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isClippingToBounds(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isClippingToBounds : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setContainer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setContainer : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setContainer : Error processing arguments"); cobj->setContainer(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setContainer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setContentOffsetInDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setContentOffsetInDuration : Invalid Native Object"); if (argc == 2) { cocos2d::Point arg0; double arg1; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setContentOffsetInDuration : Error processing arguments"); cobj->setContentOffsetInDuration(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setContentOffsetInDuration : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setZoomScaleInDuration(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setZoomScaleInDuration : Invalid Native Object"); if (argc == 2) { double arg0; double arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setZoomScaleInDuration : Error processing arguments"); cobj->setZoomScaleInDuration(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setZoomScaleInDuration : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setBounceable(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setBounceable : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setBounceable : Error processing arguments"); cobj->setBounceable(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setBounceable : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_getDirection(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_getDirection : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getDirection(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_getContainer(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_getContainer : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getContainer(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getContainer : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_getZoomScale : Invalid Native Object"); if (argc == 0) { double ret = cobj->getZoomScale(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_updateInset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_updateInset : Invalid Native Object"); if (argc == 0) { cobj->updateInset(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_updateInset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_initWithViewSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_initWithViewSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_initWithViewSize : Error processing arguments"); JSBool ret = cobj->initWithViewSize(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { cocos2d::Size arg0; cocos2d::Node* arg1; ok &= jsval_to_ccsize(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_initWithViewSize : Error processing arguments"); JSBool ret = cobj->initWithViewSize(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_initWithViewSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_pause(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_pause : Invalid Native Object"); if (argc == 1) { cocos2d::Object* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_pause : Error processing arguments"); cobj->pause(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_pause : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setDirection(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setDirection : Invalid Native Object"); if (argc == 1) { cocos2d::extension::ScrollView::Direction arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setDirection : Error processing arguments"); cobj->setDirection(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setContentOffset(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setContentOffset : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setContentOffset : Error processing arguments"); cobj->setContentOffset(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { cocos2d::Point arg0; JSBool arg1; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setContentOffset : Error processing arguments"); cobj->setContentOffset(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setContentOffset : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_isDragging(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_isDragging : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isDragging(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isDragging : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_isTouchEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isTouchEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_isBounceable(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_isBounceable : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isBounceable(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isBounceable : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setTouchEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setTouchEnabled : Error processing arguments"); cobj->setTouchEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_getContentOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_getContentOffset : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getContentOffset(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getContentOffset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_resume(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_resume : Invalid Native Object"); if (argc == 1) { cocos2d::Object* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_resume : Error processing arguments"); cobj->resume(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_resume : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setClippingToBounds(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setClippingToBounds : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setClippingToBounds : Error processing arguments"); cobj->setClippingToBounds(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setClippingToBounds : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setViewSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setViewSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setViewSize : Error processing arguments"); cobj->setViewSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setViewSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_getViewSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_getViewSize : Invalid Native Object"); if (argc == 0) { cocos2d::Size ret = cobj->getViewSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getViewSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_maxContainerOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_maxContainerOffset : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->maxContainerOffset(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_maxContainerOffset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_isTouchMoved(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_isTouchMoved : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isTouchMoved(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isTouchMoved : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_isNodeVisible(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_isNodeVisible : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_isNodeVisible : Error processing arguments"); JSBool ret = cobj->isNodeVisible(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isNodeVisible : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_minContainerOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_minContainerOffset : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->minContainerOffset(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_minContainerOffset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::extension::ScrollView* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_ScrollView_setZoomScale : Invalid Native Object"); do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool arg1; ok &= JS_ValueToBoolean(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj->setZoomScale(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setZoomScale(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setZoomScale : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 0) { cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ScrollView*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ScrollView*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Node* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::ScrollView*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::ScrollView* cobj = new cocos2d::extension::ScrollView(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ScrollView"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Layer_prototype; void js_cocos2d_extension_ScrollView_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ScrollView)", obj); } static JSBool js_cocos2d_extension_ScrollView_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::extension::ScrollView *nobj = cocos2d::extension::ScrollView::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ScrollView"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_extension_ScrollView(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_ScrollView_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_ScrollView_class->name = "ScrollView"; jsb_cocos2d_extension_ScrollView_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_ScrollView_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_ScrollView_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_ScrollView_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_ScrollView_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_ScrollView_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_ScrollView_class->convert = JS_ConvertStub; jsb_cocos2d_extension_ScrollView_class->finalize = js_cocos2d_extension_ScrollView_finalize; jsb_cocos2d_extension_ScrollView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("isClippingToBounds", js_cocos2dx_extension_ScrollView_isClippingToBounds, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setContainer", js_cocos2dx_extension_ScrollView_setContainer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setContentOffsetInDuration", js_cocos2dx_extension_ScrollView_setContentOffsetInDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setZoomScaleInDuration", js_cocos2dx_extension_ScrollView_setZoomScaleInDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBounceable", js_cocos2dx_extension_ScrollView_setBounceable, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDirection", js_cocos2dx_extension_ScrollView_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContainer", js_cocos2dx_extension_ScrollView_getContainer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomScale", js_cocos2dx_extension_ScrollView_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateInset", js_cocos2dx_extension_ScrollView_updateInset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithViewSize", js_cocos2dx_extension_ScrollView_initWithViewSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pause", js_cocos2dx_extension_ScrollView_pause, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDirection", js_cocos2dx_extension_ScrollView_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_extension_ScrollView_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setContentOffset", js_cocos2dx_extension_ScrollView_setContentOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isDragging", js_cocos2dx_extension_ScrollView_isDragging, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchEnabled", js_cocos2dx_extension_ScrollView_isTouchEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBounceable", js_cocos2dx_extension_ScrollView_isBounceable, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchEnabled", js_cocos2dx_extension_ScrollView_setTouchEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentOffset", js_cocos2dx_extension_ScrollView_getContentOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resume", js_cocos2dx_extension_ScrollView_resume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClippingToBounds", js_cocos2dx_extension_ScrollView_setClippingToBounds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setViewSize", js_cocos2dx_extension_ScrollView_setViewSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getViewSize", js_cocos2dx_extension_ScrollView_getViewSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("maxContainerOffset", js_cocos2dx_extension_ScrollView_maxContainerOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchMoved", js_cocos2dx_extension_ScrollView_isTouchMoved, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isNodeVisible", js_cocos2dx_extension_ScrollView_isNodeVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("minContainerOffset", js_cocos2dx_extension_ScrollView_minContainerOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setZoomScale", js_cocos2dx_extension_ScrollView_setZoomScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_extension_ScrollView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_ScrollView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_ScrollView_prototype = JS_InitClass( cx, global, jsb_cocos2d_Layer_prototype, jsb_cocos2d_extension_ScrollView_class, js_cocos2dx_extension_ScrollView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ScrollView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_ScrollView_class; p->proto = jsb_cocos2d_extension_ScrollView_prototype; p->parentProto = jsb_cocos2d_Layer_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_TableViewCell_class; JSObject *jsb_cocos2d_extension_TableViewCell_prototype; JSBool js_cocos2dx_extension_TableViewCell_reset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableViewCell* cobj = (cocos2d::extension::TableViewCell *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableViewCell_reset : Invalid Native Object"); if (argc == 0) { cobj->reset(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_reset : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_TableViewCell_getIdx(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableViewCell* cobj = (cocos2d::extension::TableViewCell *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableViewCell_getIdx : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getIdx(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_getIdx : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_TableViewCell_setIdx(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableViewCell* cobj = (cocos2d::extension::TableViewCell *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableViewCell_setIdx : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableViewCell_setIdx : Error processing arguments"); cobj->setIdx(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_setIdx : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableViewCell_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::TableViewCell* ret = cocos2d::extension::TableViewCell::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::TableViewCell*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_TableViewCell_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::TableViewCell* cobj = new cocos2d::extension::TableViewCell(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::TableViewCell"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_extension_TableViewCell_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TableViewCell)", obj); } static JSBool js_cocos2d_extension_TableViewCell_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::extension::TableViewCell *nobj = cocos2d::extension::TableViewCell::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::TableViewCell"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_extension_TableViewCell(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_TableViewCell_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_TableViewCell_class->name = "TableViewCell"; jsb_cocos2d_extension_TableViewCell_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_TableViewCell_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_TableViewCell_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_TableViewCell_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_TableViewCell_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_TableViewCell_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_TableViewCell_class->convert = JS_ConvertStub; jsb_cocos2d_extension_TableViewCell_class->finalize = js_cocos2d_extension_TableViewCell_finalize; jsb_cocos2d_extension_TableViewCell_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("reset", js_cocos2dx_extension_TableViewCell_reset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIdx", js_cocos2dx_extension_TableViewCell_getIdx, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setIdx", js_cocos2dx_extension_TableViewCell_setIdx, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_extension_TableViewCell_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_TableViewCell_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_TableViewCell_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_extension_TableViewCell_class, js_cocos2dx_extension_TableViewCell_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TableViewCell", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_TableViewCell_class; p->proto = jsb_cocos2d_extension_TableViewCell_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_TableView_class; JSObject *jsb_cocos2d_extension_TableView_prototype; JSBool js_cocos2dx_extension_TableView_updateCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_updateCellAtIndex : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_updateCellAtIndex : Error processing arguments"); cobj->updateCellAtIndex(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_updateCellAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_setVerticalFillOrder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_setVerticalFillOrder : Invalid Native Object"); if (argc == 1) { cocos2d::extension::TableView::VerticalFillOrder arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_setVerticalFillOrder : Error processing arguments"); cobj->setVerticalFillOrder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_setVerticalFillOrder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_scrollViewDidZoom(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_scrollViewDidZoom : Invalid Native Object"); if (argc == 1) { cocos2d::extension::ScrollView* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ScrollView*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_scrollViewDidZoom : Error processing arguments"); cobj->scrollViewDidZoom(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_scrollViewDidZoom : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView__updateContentSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView__updateContentSize : Invalid Native Object"); if (argc == 0) { cobj->_updateContentSize(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView__updateContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_getVerticalFillOrder(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_getVerticalFillOrder : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getVerticalFillOrder(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_getVerticalFillOrder : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_removeCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_removeCellAtIndex : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_removeCellAtIndex : Error processing arguments"); cobj->removeCellAtIndex(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_removeCellAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_initWithViewSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_initWithViewSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_initWithViewSize : Error processing arguments"); JSBool ret = cobj->initWithViewSize(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { cocos2d::Size arg0; cocos2d::Node* arg1; ok &= jsval_to_ccsize(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_initWithViewSize : Error processing arguments"); JSBool ret = cobj->initWithViewSize(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_initWithViewSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_scrollViewDidScroll(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_scrollViewDidScroll : Invalid Native Object"); if (argc == 1) { cocos2d::extension::ScrollView* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::ScrollView*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_scrollViewDidScroll : Error processing arguments"); cobj->scrollViewDidScroll(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_scrollViewDidScroll : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_reloadData(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_reloadData : Invalid Native Object"); if (argc == 0) { cobj->reloadData(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_reloadData : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_insertCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_insertCellAtIndex : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_insertCellAtIndex : Error processing arguments"); cobj->insertCellAtIndex(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_insertCellAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_cellAtIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_cellAtIndex : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_TableView_cellAtIndex : Error processing arguments"); cocos2d::extension::TableViewCell* ret = cobj->cellAtIndex(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::TableViewCell*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_cellAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_dequeueCell(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_TableView_dequeueCell : Invalid Native Object"); if (argc == 0) { cocos2d::extension::TableViewCell* ret = cobj->dequeueCell(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::TableViewCell*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_dequeueCell : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_TableView_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::TableView* cobj = new cocos2d::extension::TableView(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::TableView"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_TableView_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_ScrollView_prototype; void js_cocos2d_extension_TableView_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TableView)", obj); } static JSBool js_cocos2d_extension_TableView_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::extension::TableView *nobj = cocos2d::extension::TableView::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::TableView"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_extension_TableView(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_TableView_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_TableView_class->name = "TableView"; jsb_cocos2d_extension_TableView_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_TableView_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_TableView_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_TableView_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_TableView_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_TableView_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_TableView_class->convert = JS_ConvertStub; jsb_cocos2d_extension_TableView_class->finalize = js_cocos2d_extension_TableView_finalize; jsb_cocos2d_extension_TableView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("updateCellAtIndex", js_cocos2dx_extension_TableView_updateCellAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVerticalFillOrder", js_cocos2dx_extension_TableView_setVerticalFillOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollViewDidZoom", js_cocos2dx_extension_TableView_scrollViewDidZoom, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("_updateContentSize", js_cocos2dx_extension_TableView__updateContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVerticalFillOrder", js_cocos2dx_extension_TableView_getVerticalFillOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeCellAtIndex", js_cocos2dx_extension_TableView_removeCellAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithViewSize", js_cocos2dx_extension_TableView_initWithViewSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollViewDidScroll", js_cocos2dx_extension_TableView_scrollViewDidScroll, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reloadData", js_cocos2dx_extension_TableView_reloadData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("insertCellAtIndex", js_cocos2dx_extension_TableView_insertCellAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("cellAtIndex", js_cocos2dx_extension_TableView_cellAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("dequeueCell", js_cocos2dx_extension_TableView_dequeueCell, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_extension_TableView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_extension_TableView_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_ScrollView_prototype, jsb_cocos2d_extension_TableView_class, js_cocos2dx_extension_TableView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TableView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_TableView_class; p->proto = jsb_cocos2d_extension_TableView_prototype; p->parentProto = jsb_cocos2d_extension_ScrollView_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_EditBox_class; JSObject *jsb_cocos2d_extension_EditBox_prototype; JSBool js_cocos2dx_extension_EditBox_getText(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_getText : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getText(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_getText : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setPlaceholderFontName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceholderFontName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceholderFontName : Error processing arguments"); cobj->setPlaceholderFontName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setPlaceholderFontName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_getPlaceHolder : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getPlaceHolder(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_getPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setFontName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setFontName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setFontName : Error processing arguments"); cobj->setFontName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setFontName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setPlaceholderFontSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceholderFontSize : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceholderFontSize : Error processing arguments"); cobj->setPlaceholderFontSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setPlaceholderFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setInputMode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setInputMode : Invalid Native Object"); if (argc == 1) { cocos2d::extension::EditBox::InputMode arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setInputMode : Error processing arguments"); cobj->setInputMode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setInputMode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setPlaceholderFontColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceholderFontColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceholderFontColor : Error processing arguments"); cobj->setPlaceholderFontColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setPlaceholderFontColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setFontColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setFontColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setFontColor : Error processing arguments"); cobj->setFontColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setFontColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setPlaceholderFont(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceholderFont : Invalid Native Object"); if (argc == 2) { const char* arg0; int arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceholderFont : Error processing arguments"); cobj->setPlaceholderFont(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setPlaceholderFont : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setFontSize : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setFontSize : Error processing arguments"); cobj->setFontSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite : Invalid Native Object"); if (argc == 2) { cocos2d::Size arg0; cocos2d::extension::Scale9Sprite* arg1; ok &= jsval_to_ccsize(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite : Error processing arguments"); JSBool ret = cobj->initWithSizeAndBackgroundSprite(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceHolder : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setPlaceHolder : Error processing arguments"); cobj->setPlaceHolder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setReturnType(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setReturnType : Invalid Native Object"); if (argc == 1) { cocos2d::extension::EditBox::KeyboardReturnType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setReturnType : Error processing arguments"); cobj->setReturnType(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setReturnType : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setInputFlag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setInputFlag : Invalid Native Object"); if (argc == 1) { cocos2d::extension::EditBox::InputFlag arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setInputFlag : Error processing arguments"); cobj->setInputFlag(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setInputFlag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_getMaxLength : Invalid Native Object"); if (argc == 0) { int ret = cobj->getMaxLength(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_getMaxLength : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setText(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setText : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setText : Error processing arguments"); cobj->setText(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setText : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setMaxLength : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setMaxLength : Error processing arguments"); cobj->setMaxLength(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setMaxLength : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_setFont(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setFont : Invalid Native Object"); if (argc == 2) { const char* arg0; int arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_setFont : Error processing arguments"); cobj->setFont(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_setFont : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Size arg0; cocos2d::extension::Scale9Sprite* arg1; ok &= jsval_to_ccsize(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_create : Error processing arguments"); cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::EditBox*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 3) { cocos2d::Size arg0; cocos2d::extension::Scale9Sprite* arg1; cocos2d::extension::Scale9Sprite* arg2; ok &= jsval_to_ccsize(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_create : Error processing arguments"); cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::EditBox*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 4) { cocos2d::Size arg0; cocos2d::extension::Scale9Sprite* arg1; cocos2d::extension::Scale9Sprite* arg2; cocos2d::extension::Scale9Sprite* arg3; ok &= jsval_to_ccsize(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); do { if (!argv[3].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); proxy = jsb_get_js_proxy(tmpObj); arg3 = (cocos2d::extension::Scale9Sprite*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg3, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_EditBox_create : Error processing arguments"); cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::EditBox*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_EditBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::extension::EditBox* cobj = new cocos2d::extension::EditBox(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::EditBox"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_EditBox_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_extension_ControlButton_prototype; void js_cocos2d_extension_EditBox_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (EditBox)", obj); } void js_register_cocos2dx_extension_EditBox(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_EditBox_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_EditBox_class->name = "EditBox"; jsb_cocos2d_extension_EditBox_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_EditBox_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_EditBox_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_EditBox_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_EditBox_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_EditBox_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_EditBox_class->convert = JS_ConvertStub; jsb_cocos2d_extension_EditBox_class->finalize = js_cocos2d_extension_EditBox_finalize; jsb_cocos2d_extension_EditBox_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getText", js_cocos2dx_extension_EditBox_getText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlaceholderFontName", js_cocos2dx_extension_EditBox_setPlaceholderFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPlaceHolder", js_cocos2dx_extension_EditBox_getPlaceHolder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontName", js_cocos2dx_extension_EditBox_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlaceholderFontSize", js_cocos2dx_extension_EditBox_setPlaceholderFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInputMode", js_cocos2dx_extension_EditBox_setInputMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlaceholderFontColor", js_cocos2dx_extension_EditBox_setPlaceholderFontColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontColor", js_cocos2dx_extension_EditBox_setFontColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlaceholderFont", js_cocos2dx_extension_EditBox_setPlaceholderFont, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontSize", js_cocos2dx_extension_EditBox_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithSizeAndBackgroundSprite", js_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlaceHolder", js_cocos2dx_extension_EditBox_setPlaceHolder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setReturnType", js_cocos2dx_extension_EditBox_setReturnType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInputFlag", js_cocos2dx_extension_EditBox_setInputFlag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxLength", js_cocos2dx_extension_EditBox_getMaxLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setText", js_cocos2dx_extension_EditBox_setText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxLength", js_cocos2dx_extension_EditBox_setMaxLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFont", js_cocos2dx_extension_EditBox_setFont, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_EditBox_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_EditBox_prototype = JS_InitClass( cx, global, jsb_cocos2d_extension_ControlButton_prototype, jsb_cocos2d_extension_EditBox_class, js_cocos2dx_extension_EditBox_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "EditBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_EditBox_class; p->proto = jsb_cocos2d_extension_EditBox_prototype; p->parentProto = jsb_cocos2d_extension_ControlButton_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_extension_AssetsManager_class; JSObject *jsb_cocos2d_extension_AssetsManager_prototype; JSBool js_cocos2dx_extension_AssetsManager_setStoragePath(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_setStoragePath : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_setStoragePath : Error processing arguments"); cobj->setStoragePath(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_setStoragePath : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_setPackageUrl(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_setPackageUrl : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_setPackageUrl : Error processing arguments"); cobj->setPackageUrl(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_setPackageUrl : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_checkUpdate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_checkUpdate : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->checkUpdate(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_checkUpdate : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_getStoragePath(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_getStoragePath : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getStoragePath(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_getStoragePath : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_update(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_update : Invalid Native Object"); if (argc == 0) { cobj->update(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_update : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_setConnectionTimeout(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_setConnectionTimeout : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_setConnectionTimeout : Error processing arguments"); cobj->setConnectionTimeout(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_setConnectionTimeout : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_setVersionFileUrl(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_setVersionFileUrl : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_setVersionFileUrl : Error processing arguments"); cobj->setVersionFileUrl(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_setVersionFileUrl : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_getPackageUrl(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_getPackageUrl : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getPackageUrl(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_getPackageUrl : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_getConnectionTimeout(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_getConnectionTimeout : Invalid Native Object"); if (argc == 0) { unsigned int ret = cobj->getConnectionTimeout(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_getConnectionTimeout : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_getVersion(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_getVersion : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getVersion(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_getVersion : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_getVersionFileUrl(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_getVersionFileUrl : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getVersionFileUrl(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_getVersionFileUrl : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_deleteVersion(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_deleteVersion : Invalid Native Object"); if (argc == 0) { cobj->deleteVersion(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_deleteVersion : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 6) { const char* arg0; const char* arg1; const char* arg2; std::function arg3; std::function arg4; std::function arg5; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); do { std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[3])); auto lambda = [=](int larg0) -> void { jsval largv[1]; largv[0] = int32_to_jsval(cx, larg0); jsval rval; JSBool ok = func->invoke(1, &largv[0], rval); if (!ok && JS_IsExceptionPending(cx)) { JS_ReportPendingException(cx); } }; arg3 = lambda; } while(0) ; do { std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[4])); auto lambda = [=](int larg0) -> void { jsval largv[1]; largv[0] = int32_to_jsval(cx, larg0); jsval rval; JSBool ok = func->invoke(1, &largv[0], rval); if (!ok && JS_IsExceptionPending(cx)) { JS_ReportPendingException(cx); } }; arg4 = lambda; } while(0) ; do { std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[5])); auto lambda = [=]() -> void { jsval rval; JSBool ok = func->invoke(0, nullptr, rval); if (!ok && JS_IsExceptionPending(cx)) { JS_ReportPendingException(cx); } }; arg5 = lambda; } while(0) ; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_create : Error processing arguments"); cocos2d::extension::AssetsManager* ret = cocos2d::extension::AssetsManager::create(arg0, arg1, arg2, arg3, arg4, arg5); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::extension::AssetsManager*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_extension_AssetsManager_constructor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 0) { cocos2d::extension::AssetsManager* cobj = new cocos2d::extension::AssetsManager(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::AssetsManager"); return JS_TRUE; } if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_constructor : Error processing arguments"); cocos2d::extension::AssetsManager* cobj = new cocos2d::extension::AssetsManager(arg0); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::AssetsManager"); return JS_TRUE; } if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_constructor : Error processing arguments"); cocos2d::extension::AssetsManager* cobj = new cocos2d::extension::AssetsManager(arg0, arg1); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::AssetsManager"); return JS_TRUE; } if (argc == 3) { const char* arg0; const char* arg1; const char* arg2; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_extension_AssetsManager_constructor : Error processing arguments"); cocos2d::extension::AssetsManager* cobj = new cocos2d::extension::AssetsManager(arg0, arg1, arg2); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::AssetsManager"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_extension_AssetsManager_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (AssetsManager)", obj); } void js_register_cocos2dx_extension_AssetsManager(JSContext *cx, JSObject *global) { jsb_cocos2d_extension_AssetsManager_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_extension_AssetsManager_class->name = "AssetsManager"; jsb_cocos2d_extension_AssetsManager_class->addProperty = JS_PropertyStub; jsb_cocos2d_extension_AssetsManager_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_extension_AssetsManager_class->getProperty = JS_PropertyStub; jsb_cocos2d_extension_AssetsManager_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_extension_AssetsManager_class->enumerate = JS_EnumerateStub; jsb_cocos2d_extension_AssetsManager_class->resolve = JS_ResolveStub; jsb_cocos2d_extension_AssetsManager_class->convert = JS_ConvertStub; jsb_cocos2d_extension_AssetsManager_class->finalize = js_cocos2d_extension_AssetsManager_finalize; jsb_cocos2d_extension_AssetsManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setStoragePath", js_cocos2dx_extension_AssetsManager_setStoragePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPackageUrl", js_cocos2dx_extension_AssetsManager_setPackageUrl, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("checkUpdate", js_cocos2dx_extension_AssetsManager_checkUpdate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStoragePath", js_cocos2dx_extension_AssetsManager_getStoragePath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", js_cocos2dx_extension_AssetsManager_update, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setConnectionTimeout", js_cocos2dx_extension_AssetsManager_setConnectionTimeout, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVersionFileUrl", js_cocos2dx_extension_AssetsManager_setVersionFileUrl, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPackageUrl", js_cocos2dx_extension_AssetsManager_getPackageUrl, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getConnectionTimeout", js_cocos2dx_extension_AssetsManager_getConnectionTimeout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVersion", js_cocos2dx_extension_AssetsManager_getVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVersionFileUrl", js_cocos2dx_extension_AssetsManager_getVersionFileUrl, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("deleteVersion", js_cocos2dx_extension_AssetsManager_deleteVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_extension_AssetsManager_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_extension_AssetsManager_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_extension_AssetsManager_class, js_cocos2dx_extension_AssetsManager_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "AssetsManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_extension_AssetsManager_class; p->proto = jsb_cocos2d_extension_AssetsManager_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; js_register_cocos2dx_extension_Control(cx, obj); js_register_cocos2dx_extension_TableViewCell(cx, obj); js_register_cocos2dx_extension_Scale9Sprite(cx, obj); js_register_cocos2dx_extension_ControlSwitch(cx, obj); js_register_cocos2dx_extension_ScrollView(cx, obj); js_register_cocos2dx_extension_TableView(cx, obj); js_register_cocos2dx_extension_AssetsManager(cx, obj); js_register_cocos2dx_extension_ControlButton(cx, obj); js_register_cocos2dx_extension_EditBox(cx, obj); js_register_cocos2dx_extension_ControlSlider(cx, obj); js_register_cocos2dx_extension_ControlStepper(cx, obj); js_register_cocos2dx_extension_ControlSaturationBrightnessPicker(cx, obj); js_register_cocos2dx_extension_ControlColourPicker(cx, obj); js_register_cocos2dx_extension_ControlPotentiometer(cx, obj); js_register_cocos2dx_extension_ControlHuePicker(cx, obj); } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_extension_auto.hpp ================================================ #ifndef __cocos2dx_extension_h__ #define __cocos2dx_extension_h__ #include "jsapi.h" #include "jsfriendapi.h" extern JSClass *jsb_cocos2d_extension_Scale9Sprite_class; extern JSObject *jsb_cocos2d_extension_Scale9Sprite_prototype; JSBool js_cocos2dx_extension_Scale9Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_Scale9Sprite_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_Scale9Sprite(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_setInsetBottom(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_setInsetTop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_initWithBatchNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_updateWithBatchNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_getInsetTop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_setInsetLeft(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_getInsetLeft(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_setInsetRight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Scale9Sprite_Scale9Sprite(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_Control_class; extern JSObject *jsb_cocos2d_extension_Control_prototype; JSBool js_cocos2dx_extension_Control_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_Control_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_Control(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_Control_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_getState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_sendActionsForControlEvents(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_setSelected(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_needsLayout(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_hasVisibleParents(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_isSelected(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_isTouchInside(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_setHighlighted(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_getTouchLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_isHighlighted(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_Control_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ControlButton_class; extern JSObject *jsb_cocos2d_extension_ControlButton_prototype; JSBool js_cocos2dx_extension_ControlButton_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ControlButton_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ControlButton(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ControlButton_isPushed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setSelected(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setTitleLabelForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setHighlighted(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setTitleForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setLabelAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getLabelAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setTitleTTFForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setTitleLabel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getCurrentTitleColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getHorizontalOrigin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_needsLayout(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getCurrentTitle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getScaleRatio(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getTitleTTFForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getTitleColorForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setTitleColorForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setScaleRatio(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getTitleLabel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getVerticalMargin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getTitleLabelForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setMargins(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_setTitleBMFontForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getTitleBMFontForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_getTitleForState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ControlHuePicker_class; extern JSObject *jsb_cocos2d_extension_ControlHuePicker_prototype; JSBool js_cocos2dx_extension_ControlHuePicker_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ControlHuePicker_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ControlHuePicker(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ControlHuePicker_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_setHue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_getStartPos(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_getHue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_getSlider(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_setBackground(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_setHuePercentage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_getHuePercentage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_setSlider(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlHuePicker_ControlHuePicker(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class; extern JSObject *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype; JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ControlSaturationBrightnessPicker_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ControlSaturationBrightnessPicker(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSaturationBrightnessPicker_ControlSaturationBrightnessPicker(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ControlColourPicker_class; extern JSObject *jsb_cocos2d_extension_ControlColourPicker_prototype; JSBool js_cocos2dx_extension_ControlColourPicker_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ControlColourPicker_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ControlColourPicker(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ControlColourPicker_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_getHuePicker(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_setColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_getcolourPicker(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_setBackground(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_setcolourPicker(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_setHuePicker(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlColourPicker_ControlColourPicker(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ControlPotentiometer_class; extern JSObject *jsb_cocos2d_extension_ControlPotentiometer_prototype; JSBool js_cocos2dx_extension_ControlPotentiometer_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ControlPotentiometer_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ControlPotentiometer(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_setValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_getProgressTimer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_getMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_getMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_setThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_getValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_setProgressTimer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_getThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlPotentiometer_ControlPotentiometer(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ControlSlider_class; extern JSObject *jsb_cocos2d_extension_ControlSlider_prototype; JSBool js_cocos2dx_extension_ControlSlider_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ControlSlider_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ControlSlider(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_locationFromTouch(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setProgressSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_getMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_needsLayout(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_getBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_getMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_isTouchInside(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_getValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_getThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_getProgressSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSlider_ControlSlider(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ControlStepper_class; extern JSObject *jsb_cocos2d_extension_ControlStepper_prototype; JSBool js_cocos2dx_extension_ControlStepper_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ControlStepper_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ControlStepper(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ControlStepper_setMinusSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_getMinusLabel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setWraps(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_isContinuous(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_getMinusSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_getPlusLabel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_stopAutorepeat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_getPlusSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setPlusSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setMinusLabel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setStepValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_update(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_startAutorepeat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_getValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_setPlusLabel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlStepper_ControlStepper(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ControlSwitch_class; extern JSObject *jsb_cocos2d_extension_ControlSwitch_prototype; JSBool js_cocos2dx_extension_ControlSwitch_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ControlSwitch_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ControlSwitch(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ControlSwitch_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSwitch_setOn(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSwitch_isOn(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSwitch_hasMoved(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSwitch_locationFromTouch(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ControlSwitch_ControlSwitch(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_ScrollView_class; extern JSObject *jsb_cocos2d_extension_ScrollView_prototype; JSBool js_cocos2dx_extension_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_ScrollView_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_ScrollView(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_ScrollView_isClippingToBounds(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setContainer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setContentOffsetInDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setZoomScaleInDuration(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setBounceable(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_getDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_getContainer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_updateInset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_initWithViewSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_pause(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setContentOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_isDragging(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_isBounceable(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_getContentOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_resume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setClippingToBounds(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setViewSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_getViewSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_maxContainerOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_isTouchMoved(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_isNodeVisible(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_minContainerOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_ScrollView_ScrollView(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_TableViewCell_class; extern JSObject *jsb_cocos2d_extension_TableViewCell_prototype; JSBool js_cocos2dx_extension_TableViewCell_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_TableViewCell_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_TableViewCell(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_TableViewCell_reset(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableViewCell_getIdx(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableViewCell_setIdx(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableViewCell_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableViewCell_TableViewCell(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_TableView_class; extern JSObject *jsb_cocos2d_extension_TableView_prototype; JSBool js_cocos2dx_extension_TableView_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_TableView_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_TableView(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_TableView_updateCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_setVerticalFillOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_scrollViewDidZoom(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView__updateContentSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_getVerticalFillOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_removeCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_initWithViewSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_scrollViewDidScroll(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_reloadData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_insertCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_cellAtIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_dequeueCell(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_TableView_TableView(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_EditBox_class; extern JSObject *jsb_cocos2d_extension_EditBox_prototype; JSBool js_cocos2dx_extension_EditBox_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_EditBox_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_EditBox(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_EditBox_getText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setPlaceholderFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setPlaceholderFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setInputMode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setPlaceholderFontColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setFontColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setPlaceholderFont(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setReturnType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setInputFlag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_setFont(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_EditBox_EditBox(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_AssetsManager_class; extern JSObject *jsb_cocos2d_extension_AssetsManager_prototype; JSBool js_cocos2dx_extension_AssetsManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_extension_AssetsManager_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_extension_AssetsManager(JSContext *cx, JSObject *global); void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_extension_AssetsManager_setStoragePath(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_setPackageUrl(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_checkUpdate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_getStoragePath(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_update(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_setConnectionTimeout(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_setVersionFileUrl(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_getPackageUrl(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_getConnectionTimeout(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_getVersion(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_getVersionFileUrl(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_deleteVersion(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_extension_AssetsManager_AssetsManager(JSContext *cx, uint32_t argc, jsval *vp); #endif ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_extension_auto_api.js ================================================ /** * @module cocos2dx_extension */ var cc = cc || {}; /** * @class Scale9Sprite */ cc.Scale9Sprite = { /** * @method resizableSpriteWithCapInsets * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" * @param {const cocos2d::Rect&} */ resizableSpriteWithCapInsets : function () {}, /** * @method setInsetBottom * @param {float} */ setInsetBottom : function () {}, /** * @method setInsetTop * @param {float} */ setInsetTop : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setPreferredSize * @param {cocos2d::Size} */ setPreferredSize : function () {}, /** * @method setSpriteFrame * @param {cocos2d::SpriteFrame*} */ setSpriteFrame : function () {}, /** * @method getInsetBottom * @return A value converted from C/C++ "float" */ getInsetBottom : function () {}, /** * @method getCapInsets * @return A value converted from C/C++ "cocos2d::Rect" */ getCapInsets : function () {}, /** * @method updateWithBatchNode * @return A value converted from C/C++ "bool" * @param {cocos2d::SpriteBatchNode*} * @param {const cocos2d::Rect&} * @param {bool} * @param {const cocos2d::Rect&} */ updateWithBatchNode : function () {}, /** * @method getInsetRight * @return A value converted from C/C++ "float" */ getInsetRight : function () {}, /** * @method getOriginalSize * @return A value converted from C/C++ "cocos2d::Size" */ getOriginalSize : function () {}, /** * @method getInsetTop * @return A value converted from C/C++ "float" */ getInsetTop : function () {}, /** * @method setInsetLeft * @param {float} */ setInsetLeft : function () {}, /** * @method getPreferredSize * @return A value converted from C/C++ "cocos2d::Size" */ getPreferredSize : function () {}, /** * @method setCapInsets * @param {cocos2d::Rect} */ setCapInsets : function () {}, /** * @method getInsetLeft * @return A value converted from C/C++ "float" */ getInsetLeft : function () {}, /** * @method setInsetRight * @param {float} */ setInsetRight : function () {}, /** * @method Scale9Sprite * @constructor */ Scale9Sprite : function () {}, }; /** * @class Control */ cc.Control = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method getState * @return A value converted from C/C++ "cocos2d::extension::Control::State" */ getState : function () {}, /** * @method sendActionsForControlEvents * @param {cocos2d::extension::Control::EventType} */ sendActionsForControlEvents : function () {}, /** * @method setSelected * @param {bool} */ setSelected : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method needsLayout */ needsLayout : function () {}, /** * @method hasVisibleParents * @return A value converted from C/C++ "bool" */ hasVisibleParents : function () {}, /** * @method isSelected * @return A value converted from C/C++ "bool" */ isSelected : function () {}, /** * @method isTouchInside * @return A value converted from C/C++ "bool" * @param {cocos2d::Touch*} */ isTouchInside : function () {}, /** * @method setHighlighted * @param {bool} */ setHighlighted : function () {}, /** * @method getTouchLocation * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ getTouchLocation : function () {}, /** * @method isHighlighted * @return A value converted from C/C++ "bool" */ isHighlighted : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::Control*" */ create : function () {}, }; /** * @class ControlButton */ cc.ControlButton = { /** * @method isPushed * @return A value converted from C/C++ "bool" */ isPushed : function () {}, /** * @method setSelected * @param {bool} */ setSelected : function () {}, /** * @method setTitleLabelForState * @param {cocos2d::Node*} * @param {cocos2d::extension::Control::State} */ setTitleLabelForState : function () {}, /** * @method setAdjustBackgroundImage * @param {bool} */ setAdjustBackgroundImage : function () {}, /** * @method setHighlighted * @param {bool} */ setHighlighted : function () {}, /** * @method setZoomOnTouchDown * @param {bool} */ setZoomOnTouchDown : function () {}, /** * @method setTitleForState * @param {const std::string&} * @param {cocos2d::extension::Control::State} */ setTitleForState : function () {}, /** * @method setLabelAnchorPoint * @param {const cocos2d::Point&} */ setLabelAnchorPoint : function () {}, /** * @method getLabelAnchorPoint * @return A value converted from C/C++ "const cocos2d::Point&" */ getLabelAnchorPoint : function () {}, /** * @method getTitleTTFSizeForState * @return A value converted from C/C++ "float" * @param {cocos2d::extension::Control::State} */ getTitleTTFSizeForState : function () {}, /** * @method setTitleTTFForState * @param {const std::string&} * @param {cocos2d::extension::Control::State} */ setTitleTTFForState : function () {}, /** * @method setTitleTTFSizeForState * @param {float} * @param {cocos2d::extension::Control::State} */ setTitleTTFSizeForState : function () {}, /** * @method setTitleLabel * @param {cocos2d::Node*} */ setTitleLabel : function () {}, /** * @method setPreferredSize * @param {const cocos2d::Size&} */ setPreferredSize : function () {}, /** * @method getCurrentTitleColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getCurrentTitleColor : function () {}, /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method getBackgroundSpriteForState * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" * @param {cocos2d::extension::Control::State} */ getBackgroundSpriteForState : function () {}, /** * @method getHorizontalOrigin * @return A value converted from C/C++ "int" */ getHorizontalOrigin : function () {}, /** * @method needsLayout */ needsLayout : function () {}, /** * @method getScaleRatio * @return A value converted from C/C++ "float" */ getScaleRatio : function () {}, /** * @method getTitleTTFForState * @return A value converted from C/C++ "const std::string&" * @param {cocos2d::extension::Control::State} */ getTitleTTFForState : function () {}, /** * @method getBackgroundSprite * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" */ getBackgroundSprite : function () {}, /** * @method getTitleColorForState * @return A value converted from C/C++ "cocos2d::Color3B" * @param {cocos2d::extension::Control::State} */ getTitleColorForState : function () {}, /** * @method setTitleColorForState * @param {const cocos2d::Color3B&} * @param {cocos2d::extension::Control::State} */ setTitleColorForState : function () {}, /** * @method doesAdjustBackgroundImage * @return A value converted from C/C++ "bool" */ doesAdjustBackgroundImage : function () {}, /** * @method setBackgroundSpriteFrameForState * @param {cocos2d::SpriteFrame*} * @param {cocos2d::extension::Control::State} */ setBackgroundSpriteFrameForState : function () {}, /** * @method setBackgroundSpriteForState * @param {cocos2d::extension::Scale9Sprite*} * @param {cocos2d::extension::Control::State} */ setBackgroundSpriteForState : function () {}, /** * @method setScaleRatio * @param {float} */ setScaleRatio : function () {}, /** * @method setBackgroundSprite * @param {cocos2d::extension::Scale9Sprite*} */ setBackgroundSprite : function () {}, /** * @method getTitleLabel * @return A value converted from C/C++ "cocos2d::Node*" */ getTitleLabel : function () {}, /** * @method getPreferredSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getPreferredSize : function () {}, /** * @method getVerticalMargin * @return A value converted from C/C++ "int" */ getVerticalMargin : function () {}, /** * @method getTitleLabelForState * @return A value converted from C/C++ "cocos2d::Node*" * @param {cocos2d::extension::Control::State} */ getTitleLabelForState : function () {}, /** * @method setMargins * @param {int} * @param {int} */ setMargins : function () {}, /** * @method setTitleBMFontForState * @param {const std::string&} * @param {cocos2d::extension::Control::State} */ setTitleBMFontForState : function () {}, /** * @method getTitleBMFontForState * @return A value converted from C/C++ "const std::string&" * @param {cocos2d::extension::Control::State} */ getTitleBMFontForState : function () {}, /** * @method getZoomOnTouchDown * @return A value converted from C/C++ "bool" */ getZoomOnTouchDown : function () {}, /** * @method getTitleForState * @return A value converted from C/C++ "std::string" * @param {cocos2d::extension::Control::State} */ getTitleForState : function () {}, }; /** * @class ControlHuePicker */ cc.ControlHuePicker = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method initWithTargetAndPos * @return A value converted from C/C++ "bool" * @param {cocos2d::Node*} * @param {cocos2d::Point} */ initWithTargetAndPos : function () {}, /** * @method setHue * @param {float} */ setHue : function () {}, /** * @method getStartPos * @return A value converted from C/C++ "cocos2d::Point" */ getStartPos : function () {}, /** * @method getHue * @return A value converted from C/C++ "float" */ getHue : function () {}, /** * @method getSlider * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSlider : function () {}, /** * @method setBackground * @param {cocos2d::Sprite*} */ setBackground : function () {}, /** * @method setHuePercentage * @param {float} */ setHuePercentage : function () {}, /** * @method getBackground * @return A value converted from C/C++ "cocos2d::Sprite*" */ getBackground : function () {}, /** * @method getHuePercentage * @return A value converted from C/C++ "float" */ getHuePercentage : function () {}, /** * @method setSlider * @param {cocos2d::Sprite*} */ setSlider : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" * @param {cocos2d::Node*} * @param {cocos2d::Point} */ create : function () {}, /** * @method ControlHuePicker * @constructor */ ControlHuePicker : function () {}, }; /** * @class ControlSaturationBrightnessPicker */ cc.ControlSaturationBrightnessPicker = { /** * @method getShadow * @return A value converted from C/C++ "cocos2d::Sprite*" */ getShadow : function () {}, /** * @method initWithTargetAndPos * @return A value converted from C/C++ "bool" * @param {cocos2d::Node*} * @param {cocos2d::Point} */ initWithTargetAndPos : function () {}, /** * @method getStartPos * @return A value converted from C/C++ "cocos2d::Point" */ getStartPos : function () {}, /** * @method getOverlay * @return A value converted from C/C++ "cocos2d::Sprite*" */ getOverlay : function () {}, /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method getSlider * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSlider : function () {}, /** * @method getBackground * @return A value converted from C/C++ "cocos2d::Sprite*" */ getBackground : function () {}, /** * @method getSaturation * @return A value converted from C/C++ "float" */ getSaturation : function () {}, /** * @method getBrightness * @return A value converted from C/C++ "float" */ getBrightness : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" * @param {cocos2d::Node*} * @param {cocos2d::Point} */ create : function () {}, /** * @method ControlSaturationBrightnessPicker * @constructor */ ControlSaturationBrightnessPicker : function () {}, }; /** * @class ControlColourPicker */ cc.ControlColourPicker = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method getHuePicker * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" */ getHuePicker : function () {}, /** * @method setColor * @param {const cocos2d::Color3B&} */ setColor : function () {}, /** * @method hueSliderValueChanged * @param {cocos2d::Object*} * @param {cocos2d::extension::Control::EventType} */ hueSliderValueChanged : function () {}, /** * @method getcolourPicker * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" */ getcolourPicker : function () {}, /** * @method setBackground * @param {cocos2d::Sprite*} */ setBackground : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setcolourPicker * @param {cocos2d::extension::ControlSaturationBrightnessPicker*} */ setcolourPicker : function () {}, /** * @method colourSliderValueChanged * @param {cocos2d::Object*} * @param {cocos2d::extension::Control::EventType} */ colourSliderValueChanged : function () {}, /** * @method setHuePicker * @param {cocos2d::extension::ControlHuePicker*} */ setHuePicker : function () {}, /** * @method getBackground * @return A value converted from C/C++ "cocos2d::Sprite*" */ getBackground : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlColourPicker*" */ create : function () {}, /** * @method ControlColourPicker * @constructor */ ControlColourPicker : function () {}, }; /** * @class ControlPotentiometer */ cc.ControlPotentiometer = { /** * @method setPreviousLocation * @param {cocos2d::Point} */ setPreviousLocation : function () {}, /** * @method setValue * @param {float} */ setValue : function () {}, /** * @method getProgressTimer * @return A value converted from C/C++ "cocos2d::ProgressTimer*" */ getProgressTimer : function () {}, /** * @method getMaximumValue * @return A value converted from C/C++ "float" */ getMaximumValue : function () {}, /** * @method angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint * @return A value converted from C/C++ "float" * @param {cocos2d::Point} * @param {cocos2d::Point} * @param {cocos2d::Point} * @param {cocos2d::Point} */ angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : function () {}, /** * @method potentiometerBegan * @param {cocos2d::Point} */ potentiometerBegan : function () {}, /** * @method setMaximumValue * @param {float} */ setMaximumValue : function () {}, /** * @method getMinimumValue * @return A value converted from C/C++ "float" */ getMinimumValue : function () {}, /** * @method setThumbSprite * @param {cocos2d::Sprite*} */ setThumbSprite : function () {}, /** * @method getValue * @return A value converted from C/C++ "float" */ getValue : function () {}, /** * @method getPreviousLocation * @return A value converted from C/C++ "cocos2d::Point" */ getPreviousLocation : function () {}, /** * @method distanceBetweenPointAndPoint * @return A value converted from C/C++ "float" * @param {cocos2d::Point} * @param {cocos2d::Point} */ distanceBetweenPointAndPoint : function () {}, /** * @method potentiometerEnded * @param {cocos2d::Point} */ potentiometerEnded : function () {}, /** * @method setProgressTimer * @param {cocos2d::ProgressTimer*} */ setProgressTimer : function () {}, /** * @method setMinimumValue * @param {float} */ setMinimumValue : function () {}, /** * @method getThumbSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getThumbSprite : function () {}, /** * @method initWithTrackSprite_ProgressTimer_ThumbSprite * @return A value converted from C/C++ "bool" * @param {cocos2d::Sprite*} * @param {cocos2d::ProgressTimer*} * @param {cocos2d::Sprite*} */ initWithTrackSprite_ProgressTimer_ThumbSprite : function () {}, /** * @method potentiometerMoved * @param {cocos2d::Point} */ potentiometerMoved : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlPotentiometer*" * @param {const char*} * @param {const char*} * @param {const char*} */ create : function () {}, /** * @method ControlPotentiometer * @constructor */ ControlPotentiometer : function () {}, }; /** * @class ControlSlider */ cc.ControlSlider = { /** * @method getSelectedThumbSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSelectedThumbSprite : function () {}, /** * @method locationFromTouch * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ locationFromTouch : function () {}, /** * @method setSelectedThumbSprite * @param {cocos2d::Sprite*} */ setSelectedThumbSprite : function () {}, /** * @method setProgressSprite * @param {cocos2d::Sprite*} */ setProgressSprite : function () {}, /** * @method getMaximumAllowedValue * @return A value converted from C/C++ "float" */ getMaximumAllowedValue : function () {}, /** * @method getMinimumAllowedValue * @return A value converted from C/C++ "float" */ getMinimumAllowedValue : function () {}, /** * @method getMinimumValue * @return A value converted from C/C++ "float" */ getMinimumValue : function () {}, /** * @method setThumbSprite * @param {cocos2d::Sprite*} */ setThumbSprite : function () {}, /** * @method setMinimumValue * @param {float} */ setMinimumValue : function () {}, /** * @method setMinimumAllowedValue * @param {float} */ setMinimumAllowedValue : function () {}, /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method setValue * @param {float} */ setValue : function () {}, /** * @method setMaximumValue * @param {float} */ setMaximumValue : function () {}, /** * @method needsLayout */ needsLayout : function () {}, /** * @method getBackgroundSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getBackgroundSprite : function () {}, /** * @method getMaximumValue * @return A value converted from C/C++ "float" */ getMaximumValue : function () {}, /** * @method isTouchInside * @return A value converted from C/C++ "bool" * @param {cocos2d::Touch*} */ isTouchInside : function () {}, /** * @method getValue * @return A value converted from C/C++ "float" */ getValue : function () {}, /** * @method getThumbSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getThumbSprite : function () {}, /** * @method getProgressSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getProgressSprite : function () {}, /** * @method setBackgroundSprite * @param {cocos2d::Sprite*} */ setBackgroundSprite : function () {}, /** * @method setMaximumAllowedValue * @param {float} */ setMaximumAllowedValue : function () {}, /** * @method ControlSlider * @constructor */ ControlSlider : function () {}, }; /** * @class ControlStepper */ cc.ControlStepper = { /** * @method setMinusSprite * @param {cocos2d::Sprite*} */ setMinusSprite : function () {}, /** * @method getMinusLabel * @return A value converted from C/C++ "cocos2d::LabelTTF*" */ getMinusLabel : function () {}, /** * @method setWraps * @param {bool} */ setWraps : function () {}, /** * @method isContinuous * @return A value converted from C/C++ "bool" */ isContinuous : function () {}, /** * @method getMinusSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getMinusSprite : function () {}, /** * @method updateLayoutUsingTouchLocation * @param {cocos2d::Point} */ updateLayoutUsingTouchLocation : function () {}, /** * @method setValueWithSendingEvent * @param {double} * @param {bool} */ setValueWithSendingEvent : function () {}, /** * @method getPlusLabel * @return A value converted from C/C++ "cocos2d::LabelTTF*" */ getPlusLabel : function () {}, /** * @method stopAutorepeat */ stopAutorepeat : function () {}, /** * @method setMinimumValue * @param {double} */ setMinimumValue : function () {}, /** * @method getPlusSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getPlusSprite : function () {}, /** * @method setPlusSprite * @param {cocos2d::Sprite*} */ setPlusSprite : function () {}, /** * @method setMinusLabel * @param {cocos2d::LabelTTF*} */ setMinusLabel : function () {}, /** * @method setValue * @param {double} */ setValue : function () {}, /** * @method setStepValue * @param {double} */ setStepValue : function () {}, /** * @method setMaximumValue * @param {double} */ setMaximumValue : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method startAutorepeat */ startAutorepeat : function () {}, /** * @method initWithMinusSpriteAndPlusSprite * @return A value converted from C/C++ "bool" * @param {cocos2d::Sprite*} * @param {cocos2d::Sprite*} */ initWithMinusSpriteAndPlusSprite : function () {}, /** * @method getValue * @return A value converted from C/C++ "double" */ getValue : function () {}, /** * @method setPlusLabel * @param {cocos2d::LabelTTF*} */ setPlusLabel : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlStepper*" * @param {cocos2d::Sprite*} * @param {cocos2d::Sprite*} */ create : function () {}, /** * @method ControlStepper * @constructor */ ControlStepper : function () {}, }; /** * @class ControlSwitch */ cc.ControlSwitch = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method isOn * @return A value converted from C/C++ "bool" */ isOn : function () {}, /** * @method hasMoved * @return A value converted from C/C++ "bool" */ hasMoved : function () {}, /** * @method locationFromTouch * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ locationFromTouch : function () {}, /** * @method ControlSwitch * @constructor */ ControlSwitch : function () {}, }; /** * @class ScrollView */ cc.ScrollView = { /** * @method isClippingToBounds * @return A value converted from C/C++ "bool" */ isClippingToBounds : function () {}, /** * @method setContainer * @param {cocos2d::Node*} */ setContainer : function () {}, /** * @method setContentOffsetInDuration * @param {cocos2d::Point} * @param {float} */ setContentOffsetInDuration : function () {}, /** * @method setZoomScaleInDuration * @param {float} * @param {float} */ setZoomScaleInDuration : function () {}, /** * @method setBounceable * @param {bool} */ setBounceable : function () {}, /** * @method getDirection * @return A value converted from C/C++ "cocos2d::extension::ScrollView::Direction" */ getDirection : function () {}, /** * @method getContainer * @return A value converted from C/C++ "cocos2d::Node*" */ getContainer : function () {}, /** * @method getZoomScale * @return A value converted from C/C++ "float" */ getZoomScale : function () {}, /** * @method updateInset */ updateInset : function () {}, /** * @method initWithViewSize * @return A value converted from C/C++ "bool" * @param {cocos2d::Size} * @param {cocos2d::Node*} */ initWithViewSize : function () {}, /** * @method pause * @param {cocos2d::Object*} */ pause : function () {}, /** * @method setDirection * @param {cocos2d::extension::ScrollView::Direction} */ setDirection : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setContentOffset * @param {cocos2d::Point} * @param {bool} */ setContentOffset : function () {}, /** * @method isDragging * @return A value converted from C/C++ "bool" */ isDragging : function () {}, /** * @method isTouchEnabled * @return A value converted from C/C++ "bool" */ isTouchEnabled : function () {}, /** * @method isBounceable * @return A value converted from C/C++ "bool" */ isBounceable : function () {}, /** * @method setTouchEnabled * @param {bool} */ setTouchEnabled : function () {}, /** * @method getContentOffset * @return A value converted from C/C++ "cocos2d::Point" */ getContentOffset : function () {}, /** * @method resume * @param {cocos2d::Object*} */ resume : function () {}, /** * @method setClippingToBounds * @param {bool} */ setClippingToBounds : function () {}, /** * @method setViewSize * @param {cocos2d::Size} */ setViewSize : function () {}, /** * @method getViewSize * @return A value converted from C/C++ "cocos2d::Size" */ getViewSize : function () {}, /** * @method maxContainerOffset * @return A value converted from C/C++ "cocos2d::Point" */ maxContainerOffset : function () {}, /** * @method isTouchMoved * @return A value converted from C/C++ "bool" */ isTouchMoved : function () {}, /** * @method isNodeVisible * @return A value converted from C/C++ "bool" * @param {cocos2d::Node*} */ isNodeVisible : function () {}, /** * @method minContainerOffset * @return A value converted from C/C++ "cocos2d::Point" */ minContainerOffset : function () {}, /** * @method ScrollView * @constructor */ ScrollView : function () {}, }; /** * @class TableViewCell */ cc.TableViewCell = { /** * @method reset */ reset : function () {}, /** * @method getIdx * @return A value converted from C/C++ "ssize_t" */ getIdx : function () {}, /** * @method setIdx * @param {ssize_t} */ setIdx : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" */ create : function () {}, /** * @method TableViewCell * @constructor */ TableViewCell : function () {}, }; /** * @class TableView */ cc.TableView = { /** * @method updateCellAtIndex * @param {ssize_t} */ updateCellAtIndex : function () {}, /** * @method setVerticalFillOrder * @param {cocos2d::extension::TableView::VerticalFillOrder} */ setVerticalFillOrder : function () {}, /** * @method scrollViewDidZoom * @param {cocos2d::extension::ScrollView*} */ scrollViewDidZoom : function () {}, /** * @method _updateContentSize */ _updateContentSize : function () {}, /** * @method getVerticalFillOrder * @return A value converted from C/C++ "cocos2d::extension::TableView::VerticalFillOrder" */ getVerticalFillOrder : function () {}, /** * @method removeCellAtIndex * @param {ssize_t} */ removeCellAtIndex : function () {}, /** * @method initWithViewSize * @return A value converted from C/C++ "bool" * @param {cocos2d::Size} * @param {cocos2d::Node*} */ initWithViewSize : function () {}, /** * @method scrollViewDidScroll * @param {cocos2d::extension::ScrollView*} */ scrollViewDidScroll : function () {}, /** * @method reloadData */ reloadData : function () {}, /** * @method insertCellAtIndex * @param {ssize_t} */ insertCellAtIndex : function () {}, /** * @method cellAtIndex * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" * @param {ssize_t} */ cellAtIndex : function () {}, /** * @method dequeueCell * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" */ dequeueCell : function () {}, /** * @method TableView * @constructor */ TableView : function () {}, }; /** * @class EditBox */ cc.EditBox = { /** * @method getText * @return A value converted from C/C++ "const char*" */ getText : function () {}, /** * @method setPlaceholderFontName * @param {const char*} */ setPlaceholderFontName : function () {}, /** * @method getPlaceHolder * @return A value converted from C/C++ "const char*" */ getPlaceHolder : function () {}, /** * @method setFontName * @param {const char*} */ setFontName : function () {}, /** * @method setPlaceholderFontSize * @param {int} */ setPlaceholderFontSize : function () {}, /** * @method setInputMode * @param {cocos2d::extension::EditBox::InputMode} */ setInputMode : function () {}, /** * @method setPlaceholderFontColor * @param {const cocos2d::Color3B&} */ setPlaceholderFontColor : function () {}, /** * @method setFontColor * @param {const cocos2d::Color3B&} */ setFontColor : function () {}, /** * @method setPlaceholderFont * @param {const char*} * @param {int} */ setPlaceholderFont : function () {}, /** * @method setFontSize * @param {int} */ setFontSize : function () {}, /** * @method initWithSizeAndBackgroundSprite * @return A value converted from C/C++ "bool" * @param {const cocos2d::Size&} * @param {cocos2d::extension::Scale9Sprite*} */ initWithSizeAndBackgroundSprite : function () {}, /** * @method setPlaceHolder * @param {const char*} */ setPlaceHolder : function () {}, /** * @method setReturnType * @param {cocos2d::extension::EditBox::KeyboardReturnType} */ setReturnType : function () {}, /** * @method setInputFlag * @param {cocos2d::extension::EditBox::InputFlag} */ setInputFlag : function () {}, /** * @method getMaxLength * @return A value converted from C/C++ "int" */ getMaxLength : function () {}, /** * @method setText * @param {const char*} */ setText : function () {}, /** * @method setMaxLength * @param {int} */ setMaxLength : function () {}, /** * @method setFont * @param {const char*} * @param {int} */ setFont : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::EditBox*" * @param {const cocos2d::Size&} * @param {cocos2d::extension::Scale9Sprite*} * @param {cocos2d::extension::Scale9Sprite*} * @param {cocos2d::extension::Scale9Sprite*} */ create : function () {}, /** * @method EditBox * @constructor */ EditBox : function () {}, }; /** * @class AssetsManager */ cc.AssetsManager = { /** * @method setStoragePath * @param {const char*} */ setStoragePath : function () {}, /** * @method setPackageUrl * @param {const char*} */ setPackageUrl : function () {}, /** * @method checkUpdate * @return A value converted from C/C++ "bool" */ checkUpdate : function () {}, /** * @method getStoragePath * @return A value converted from C/C++ "const char*" */ getStoragePath : function () {}, /** * @method update */ update : function () {}, /** * @method setConnectionTimeout * @param {unsigned int} */ setConnectionTimeout : function () {}, /** * @method setVersionFileUrl * @param {const char*} */ setVersionFileUrl : function () {}, /** * @method getPackageUrl * @return A value converted from C/C++ "const char*" */ getPackageUrl : function () {}, /** * @method getConnectionTimeout * @return A value converted from C/C++ "unsigned int" */ getConnectionTimeout : function () {}, /** * @method getVersion * @return A value converted from C/C++ "std::string" */ getVersion : function () {}, /** * @method getVersionFileUrl * @return A value converted from C/C++ "const char*" */ getVersionFileUrl : function () {}, /** * @method deleteVersion */ deleteVersion : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::AssetsManager*" * @param {const char*} * @param {const char*} * @param {const char*} * @param {cocos2d::extension::AssetsManager::ErrorCallback} * @param {cocos2d::extension::AssetsManager::ProgressCallback} * @param {cocos2d::extension::AssetsManager::SuccessCallback} */ create : function () {}, /** * @method AssetsManager * @constructor */ AssetsManager : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_gui_auto.cpp ================================================ #include "jsb_cocos2dx_gui_auto.hpp" #include "cocos2d_specifics.hpp" #include "CocosGUI.h" template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedValue initializing(cx); JSBool isNewValid = JS_TRUE; JSObject* global = ScriptingCore::getInstance()->getGlobalObject(); isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && JSVAL_TO_BOOLEAN(initializing); if (isNewValid) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); return JS_TRUE; } JS_ReportError(cx, "Don't use `new cc.XXX`, please use `cc.XXX.create` instead! "); return JS_FALSE; } static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { return JS_FALSE; } static JSBool js_is_native_obj(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { vp.set(BOOLEAN_TO_JSVAL(JS_TRUE)); return JS_TRUE; } JSClass *jsb_cocos2d_gui_LayoutParameter_class; JSObject *jsb_cocos2d_gui_LayoutParameter_prototype; JSBool js_cocos2dx_gui_LayoutParameter_getLayoutType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LayoutParameter* cobj = (cocos2d::gui::LayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LayoutParameter_getLayoutType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getLayoutType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LayoutParameter_getLayoutType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_LayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::LayoutParameter* ret = cocos2d::gui::LayoutParameter::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::LayoutParameter*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LayoutParameter_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_LayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::LayoutParameter* cobj = new cocos2d::gui::LayoutParameter(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::LayoutParameter"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LayoutParameter_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2d_gui_LayoutParameter_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LayoutParameter)", obj); } void js_register_cocos2dx_gui_LayoutParameter(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_LayoutParameter_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_LayoutParameter_class->name = "LayoutParameter"; jsb_cocos2d_gui_LayoutParameter_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_LayoutParameter_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_LayoutParameter_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_LayoutParameter_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_LayoutParameter_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_LayoutParameter_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_LayoutParameter_class->convert = JS_ConvertStub; jsb_cocos2d_gui_LayoutParameter_class->finalize = js_cocos2d_gui_LayoutParameter_finalize; jsb_cocos2d_gui_LayoutParameter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getLayoutType", js_cocos2dx_gui_LayoutParameter_getLayoutType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_LayoutParameter_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_LayoutParameter_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_gui_LayoutParameter_class, js_cocos2dx_gui_LayoutParameter_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_LayoutParameter_class; p->proto = jsb_cocos2d_gui_LayoutParameter_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_LinearLayoutParameter_class; JSObject *jsb_cocos2d_gui_LinearLayoutParameter_prototype; JSBool js_cocos2dx_gui_LinearLayoutParameter_setGravity(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LinearLayoutParameter* cobj = (cocos2d::gui::LinearLayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LinearLayoutParameter_setGravity : Invalid Native Object"); if (argc == 1) { cocos2d::gui::LinearGravity arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_LinearLayoutParameter_setGravity : Error processing arguments"); cobj->setGravity(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LinearLayoutParameter_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_LinearLayoutParameter_getGravity(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LinearLayoutParameter* cobj = (cocos2d::gui::LinearLayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LinearLayoutParameter_getGravity : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getGravity(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LinearLayoutParameter_getGravity : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_LinearLayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::LinearLayoutParameter* ret = cocos2d::gui::LinearLayoutParameter::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::LinearLayoutParameter*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LinearLayoutParameter_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_LinearLayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::LinearLayoutParameter* cobj = new cocos2d::gui::LinearLayoutParameter(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::LinearLayoutParameter"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LinearLayoutParameter_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_LayoutParameter_prototype; void js_cocos2d_gui_LinearLayoutParameter_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LinearLayoutParameter)", obj); } void js_register_cocos2dx_gui_LinearLayoutParameter(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_LinearLayoutParameter_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_LinearLayoutParameter_class->name = "LinearLayoutParameter"; jsb_cocos2d_gui_LinearLayoutParameter_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_LinearLayoutParameter_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_LinearLayoutParameter_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_LinearLayoutParameter_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_LinearLayoutParameter_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_LinearLayoutParameter_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_LinearLayoutParameter_class->convert = JS_ConvertStub; jsb_cocos2d_gui_LinearLayoutParameter_class->finalize = js_cocos2d_gui_LinearLayoutParameter_finalize; jsb_cocos2d_gui_LinearLayoutParameter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setGravity", js_cocos2dx_gui_LinearLayoutParameter_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGravity", js_cocos2dx_gui_LinearLayoutParameter_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_LinearLayoutParameter_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_LinearLayoutParameter_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_LayoutParameter_prototype, jsb_cocos2d_gui_LinearLayoutParameter_class, js_cocos2dx_gui_LinearLayoutParameter_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LinearLayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_LinearLayoutParameter_class; p->proto = jsb_cocos2d_gui_LinearLayoutParameter_prototype; p->parentProto = jsb_cocos2d_gui_LayoutParameter_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_RelativeLayoutParameter_class; JSObject *jsb_cocos2d_gui_RelativeLayoutParameter_prototype; JSBool js_cocos2dx_gui_RelativeLayoutParameter_setAlign(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::RelativeLayoutParameter* cobj = (cocos2d::gui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_setAlign : Invalid Native Object"); if (argc == 1) { cocos2d::gui::RelativeAlign arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_setAlign : Error processing arguments"); cobj->setAlign(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_RelativeLayoutParameter_setAlign : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::RelativeLayoutParameter* cobj = (cocos2d::gui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName : Error processing arguments"); cobj->setRelativeToWidgetName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_RelativeLayoutParameter_getRelativeName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::RelativeLayoutParameter* cobj = (cocos2d::gui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_getRelativeName : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getRelativeName(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_RelativeLayoutParameter_getRelativeName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::RelativeLayoutParameter* cobj = (cocos2d::gui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getRelativeToWidgetName(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_RelativeLayoutParameter_setRelativeName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::RelativeLayoutParameter* cobj = (cocos2d::gui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_setRelativeName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_setRelativeName : Error processing arguments"); cobj->setRelativeName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_RelativeLayoutParameter_setRelativeName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_RelativeLayoutParameter_getAlign(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::RelativeLayoutParameter* cobj = (cocos2d::gui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_RelativeLayoutParameter_getAlign : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getAlign(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_RelativeLayoutParameter_getAlign : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_RelativeLayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::RelativeLayoutParameter* ret = cocos2d::gui::RelativeLayoutParameter::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::RelativeLayoutParameter*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_RelativeLayoutParameter_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_RelativeLayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::RelativeLayoutParameter* cobj = new cocos2d::gui::RelativeLayoutParameter(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::RelativeLayoutParameter"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_RelativeLayoutParameter_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_LayoutParameter_prototype; void js_cocos2d_gui_RelativeLayoutParameter_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (RelativeLayoutParameter)", obj); } void js_register_cocos2dx_gui_RelativeLayoutParameter(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_RelativeLayoutParameter_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_RelativeLayoutParameter_class->name = "RelativeLayoutParameter"; jsb_cocos2d_gui_RelativeLayoutParameter_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_RelativeLayoutParameter_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_RelativeLayoutParameter_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_RelativeLayoutParameter_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_RelativeLayoutParameter_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_RelativeLayoutParameter_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_RelativeLayoutParameter_class->convert = JS_ConvertStub; jsb_cocos2d_gui_RelativeLayoutParameter_class->finalize = js_cocos2d_gui_RelativeLayoutParameter_finalize; jsb_cocos2d_gui_RelativeLayoutParameter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setAlign", js_cocos2dx_gui_RelativeLayoutParameter_setAlign, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRelativeToWidgetName", js_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRelativeName", js_cocos2dx_gui_RelativeLayoutParameter_getRelativeName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRelativeToWidgetName", js_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRelativeName", js_cocos2dx_gui_RelativeLayoutParameter_setRelativeName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAlign", js_cocos2dx_gui_RelativeLayoutParameter_getAlign, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_RelativeLayoutParameter_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_RelativeLayoutParameter_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_LayoutParameter_prototype, jsb_cocos2d_gui_RelativeLayoutParameter_class, js_cocos2dx_gui_RelativeLayoutParameter_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "RelativeLayoutParameter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_RelativeLayoutParameter_class; p->proto = jsb_cocos2d_gui_RelativeLayoutParameter_prototype; p->parentProto = jsb_cocos2d_gui_LayoutParameter_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_Widget_class; JSObject *jsb_cocos2d_gui_Widget_prototype; JSBool js_cocos2dx_gui_Widget_getVirtualRenderer(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getVirtualRenderer : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getVirtualRenderer(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getVirtualRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setSizePercent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setSizePercent : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setSizePercent : Error processing arguments"); cobj->setSizePercent(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setSizePercent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setActionTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setActionTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setActionTag : Error processing arguments"); cobj->setActionTag(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setActionTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getNodeByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getNodeByTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getNodeByTag : Error processing arguments"); cocos2d::Node* ret = cobj->getNodeByTag(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getNodeByTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_isFlipY(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_isFlipY : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isFlipY(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_isFlipY : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getTouchEndPos(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getTouchEndPos : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getTouchEndPos(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getTouchEndPos : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setPositionPercent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setPositionPercent : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setPositionPercent : Error processing arguments"); cobj->setPositionPercent(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setPositionPercent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getNodes(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getNodes : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getNodes(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getNodes : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setPositionType(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setPositionType : Invalid Native Object"); if (argc == 1) { cocos2d::gui::PositionType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setPositionType : Error processing arguments"); cobj->setPositionType(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setPositionType : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getName : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getName(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isIgnoreContentAdaptWithSize(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_updateSizeAndPosition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_updateSizeAndPosition : Invalid Native Object"); if (argc == 0) { cobj->updateSizeAndPosition(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_updateSizeAndPosition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getBottomInParent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getBottomInParent : Invalid Native Object"); if (argc == 0) { double ret = cobj->getBottomInParent(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getBottomInParent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getActionTag(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getActionTag : Invalid Native Object"); if (argc == 0) { int ret = cobj->getActionTag(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getActionTag : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getLayoutParameter : Invalid Native Object"); if (argc == 1) { cocos2d::gui::LayoutParameterType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getLayoutParameter : Error processing arguments"); cocos2d::gui::LayoutParameter* ret = cobj->getLayoutParameter(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::LayoutParameter*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getLayoutParameter : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getPositionType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getPositionType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getPositionType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getPositionType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setName : Error processing arguments"); cobj->setName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getChildByName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getChildByName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getChildByName : Error processing arguments"); cocos2d::gui::Widget* ret = cobj->getChildByName(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getChildByName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_isEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_isFlipX(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_isFlipX : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isFlipX(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_isFlipX : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_removeNodeByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_removeNodeByTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_removeNodeByTag : Error processing arguments"); cobj->removeNodeByTag(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_removeNodeByTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_isTouchEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isTouchEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_isTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getContentSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getContentSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getContentSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getTouchStartPos(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getTouchStartPos : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getTouchStartPos(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getTouchStartPos : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_didNotSelectSelf : Invalid Native Object"); if (argc == 0) { cobj->didNotSelectSelf(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_didNotSelectSelf : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setFocused(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setFocused : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setFocused : Error processing arguments"); cobj->setFocused(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setFocused : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setTouchEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setTouchEnabled : Error processing arguments"); cobj->setTouchEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_clone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_clone : Invalid Native Object"); if (argc == 0) { cocos2d::gui::Widget* ret = cobj->clone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_clone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getTouchMovePos(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getTouchMovePos : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getTouchMovePos(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getTouchMovePos : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setEnabled : Error processing arguments"); cobj->setEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setBrightStyle(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setBrightStyle : Invalid Native Object"); if (argc == 1) { cocos2d::gui::BrightStyle arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setBrightStyle : Error processing arguments"); cobj->setBrightStyle(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setBrightStyle : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_addNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::gui::Widget* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_addNode : Invalid Native Object"); do { if (argc == 2) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cobj->addNode(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj->addNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 3) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); if (!ok) { ok = JS_TRUE; break; } cobj->addNode(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_gui_Widget_addNode : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setLayoutParameter : Invalid Native Object"); if (argc == 1) { cocos2d::gui::LayoutParameter* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::LayoutParameter*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setLayoutParameter : Error processing arguments"); cobj->setLayoutParameter(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setLayoutParameter : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setFlipY(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setFlipY : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setFlipY : Error processing arguments"); cobj->setFlipY(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setFlipY : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setFlipX(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setFlipX : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setFlipX : Error processing arguments"); cobj->setFlipX(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setFlipX : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getLeftInParent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getLeftInParent : Invalid Native Object"); if (argc == 0) { double ret = cobj->getLeftInParent(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getLeftInParent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_ignoreContentAdaptWithSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_ignoreContentAdaptWithSize : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_ignoreContentAdaptWithSize : Error processing arguments"); cobj->ignoreContentAdaptWithSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_ignoreContentAdaptWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_isBright(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_isBright : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isBright(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_isBright : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_clippingParentAreaContainPoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_clippingParentAreaContainPoint : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_clippingParentAreaContainPoint : Error processing arguments"); JSBool ret = cobj->clippingParentAreaContainPoint(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_clippingParentAreaContainPoint : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getSizePercent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getSizePercent : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getSizePercent(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getSizePercent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getTopInParent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getTopInParent : Invalid Native Object"); if (argc == 0) { double ret = cobj->getTopInParent(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getTopInParent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getWidgetType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getWidgetType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getWidgetType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getWidgetType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getRightInParent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getRightInParent : Invalid Native Object"); if (argc == 0) { double ret = cobj->getRightInParent(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getRightInParent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getSizeType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getSizeType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getSizeType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getSizeType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_removeNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_removeNode : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_removeNode : Error processing arguments"); cobj->removeNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_removeNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_removeAllNodes(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_removeAllNodes : Invalid Native Object"); if (argc == 0) { cobj->removeAllNodes(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_removeAllNodes : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getWorldPosition(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getWorldPosition : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getWorldPosition(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getWorldPosition : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_getPositionPercent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_getPositionPercent : Invalid Native Object"); if (argc == 0) { const cocos2d::Point& ret = cobj->getPositionPercent(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_getPositionPercent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_hitTest : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_hitTest : Error processing arguments"); JSBool ret = cobj->hitTest(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_hitTest : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_isFocused(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_isFocused : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isFocused(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_isFocused : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setSizeType(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setSizeType : Invalid Native Object"); if (argc == 1) { cocos2d::gui::SizeType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setSizeType : Error processing arguments"); cobj->setSizeType(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setSizeType : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_checkChildInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_checkChildInfo : Invalid Native Object"); if (argc == 3) { int arg0; cocos2d::gui::Widget* arg1; cocos2d::Point arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ccpoint(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_checkChildInfo : Error processing arguments"); cobj->checkChildInfo(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_checkChildInfo : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setSize : Error processing arguments"); cobj->setSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_setBright(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Widget* cobj = (cocos2d::gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setBright : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Widget_setBright : Error processing arguments"); cobj->setBright(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_setBright : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Widget* ret = cocos2d::gui::Widget::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Widget_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Widget* cobj = new cocos2d::gui::Widget(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::Widget"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Widget_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocos2d_gui_Widget_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Widget)", obj); } void js_register_cocos2dx_gui_Widget(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_Widget_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_Widget_class->name = "Widget"; jsb_cocos2d_gui_Widget_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_Widget_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_Widget_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_Widget_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_Widget_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_Widget_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_Widget_class->convert = JS_ConvertStub; jsb_cocos2d_gui_Widget_class->finalize = js_cocos2d_gui_Widget_finalize; jsb_cocos2d_gui_Widget_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getVirtualRenderer", js_cocos2dx_gui_Widget_getVirtualRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSizePercent", js_cocos2dx_gui_Widget_setSizePercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setActionTag", js_cocos2dx_gui_Widget_setActionTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeByTag", js_cocos2dx_gui_Widget_getNodeByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFlipY", js_cocos2dx_gui_Widget_isFlipY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchEndPos", js_cocos2dx_gui_Widget_getTouchEndPos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPositionPercent", js_cocos2dx_gui_Widget_setPositionPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodes", js_cocos2dx_gui_Widget_getNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPositionType", js_cocos2dx_gui_Widget_setPositionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_gui_Widget_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isIgnoreContentAdaptWithSize", js_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateSizeAndPosition", js_cocos2dx_gui_Widget_updateSizeAndPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBottomInParent", js_cocos2dx_gui_Widget_getBottomInParent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActionTag", js_cocos2dx_gui_Widget_getActionTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayoutParameter", js_cocos2dx_gui_Widget_getLayoutParameter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionType", js_cocos2dx_gui_Widget_getPositionType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setName", js_cocos2dx_gui_Widget_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getChildByName", js_cocos2dx_gui_Widget_getChildByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isEnabled", js_cocos2dx_gui_Widget_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFlipX", js_cocos2dx_gui_Widget_isFlipX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeNodeByTag", js_cocos2dx_gui_Widget_removeNodeByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchEnabled", js_cocos2dx_gui_Widget_isTouchEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentSize", js_cocos2dx_gui_Widget_getContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchStartPos", js_cocos2dx_gui_Widget_getTouchStartPos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("didNotSelectSelf", js_cocos2dx_gui_Widget_didNotSelectSelf, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFocused", js_cocos2dx_gui_Widget_setFocused, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchEnabled", js_cocos2dx_gui_Widget_setTouchEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clone", js_cocos2dx_gui_Widget_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchMovePos", js_cocos2dx_gui_Widget_getTouchMovePos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEnabled", js_cocos2dx_gui_Widget_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBrightStyle", js_cocos2dx_gui_Widget_setBrightStyle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addNode", js_cocos2dx_gui_Widget_addNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLayoutParameter", js_cocos2dx_gui_Widget_setLayoutParameter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFlipY", js_cocos2dx_gui_Widget_setFlipY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFlipX", js_cocos2dx_gui_Widget_setFlipX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLeftInParent", js_cocos2dx_gui_Widget_getLeftInParent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ignoreContentAdaptWithSize", js_cocos2dx_gui_Widget_ignoreContentAdaptWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBright", js_cocos2dx_gui_Widget_isBright, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clippingParentAreaContainPoint", js_cocos2dx_gui_Widget_clippingParentAreaContainPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSizePercent", js_cocos2dx_gui_Widget_getSizePercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTopInParent", js_cocos2dx_gui_Widget_getTopInParent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWidgetType", js_cocos2dx_gui_Widget_getWidgetType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSize", js_cocos2dx_gui_Widget_getSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRightInParent", js_cocos2dx_gui_Widget_getRightInParent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSizeType", js_cocos2dx_gui_Widget_getSizeType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeNode", js_cocos2dx_gui_Widget_removeNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllNodes", js_cocos2dx_gui_Widget_removeAllNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWorldPosition", js_cocos2dx_gui_Widget_getWorldPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionPercent", js_cocos2dx_gui_Widget_getPositionPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hitTest", js_cocos2dx_gui_Widget_hitTest, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFocused", js_cocos2dx_gui_Widget_isFocused, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSizeType", js_cocos2dx_gui_Widget_setSizeType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("checkChildInfo", js_cocos2dx_gui_Widget_checkChildInfo, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSize", js_cocos2dx_gui_Widget_setSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBright", js_cocos2dx_gui_Widget_setBright, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_Widget_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_Widget_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocos2d_gui_Widget_class, js_cocos2dx_gui_Widget_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Widget", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_Widget_class; p->proto = jsb_cocos2d_gui_Widget_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_Layout_class; JSObject *jsb_cocos2d_gui_Layout_prototype; JSBool js_cocos2dx_gui_Layout_setBackGroundColorVector(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundColorVector : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundColorVector : Error processing arguments"); cobj->setBackGroundColorVector(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setBackGroundColorVector : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_hitTest(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_hitTest : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_hitTest : Error processing arguments"); JSBool ret = cobj->hitTest(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_hitTest : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_getBackGroundImageTextureSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_getBackGroundImageTextureSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getBackGroundImageTextureSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_getBackGroundImageTextureSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_getLayoutType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_getLayoutType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getLayoutType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_getLayoutType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setClippingType(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setClippingType : Invalid Native Object"); if (argc == 1) { cocos2d::gui::LayoutClippingType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setClippingType : Error processing arguments"); cobj->setClippingType(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setClippingType : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setBackGroundColorType(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundColorType : Invalid Native Object"); if (argc == 1) { cocos2d::gui::LayoutBackGroundColorType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundColorType : Error processing arguments"); cobj->setBackGroundColorType(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setBackGroundColorType : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundImage : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundImage : Error processing arguments"); cobj->setBackGroundImage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundImage : Error processing arguments"); cobj->setBackGroundImage(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setBackGroundImage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setBackGroundColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::gui::Layout* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundColor : Invalid Native Object"); do { if (argc == 2) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocos2d::Color3B arg1; ok &= jsval_to_cccolor3b(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj->setBackGroundColor(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->setBackGroundColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_gui_Layout_setBackGroundColor : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_requestDoLayout(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_requestDoLayout : Invalid Native Object"); if (argc == 0) { cobj->requestDoLayout(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_requestDoLayout : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_isClippingEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_isClippingEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isClippingEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_isClippingEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setBackGroundColorOpacity(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundColorOpacity : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundColorOpacity : Error processing arguments"); cobj->setBackGroundColorOpacity(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setBackGroundColorOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setBackGroundImageCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundImageCapInsets : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundImageCapInsets : Error processing arguments"); cobj->setBackGroundImageCapInsets(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setBackGroundImageCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_removeBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_removeBackGroundImage : Invalid Native Object"); if (argc == 0) { cobj->removeBackGroundImage(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_removeBackGroundImage : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled : Error processing arguments"); cobj->setBackGroundImageScale9Enabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setClippingEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setClippingEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setClippingEnabled : Error processing arguments"); cobj->setClippingEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setClippingEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_setLayoutType(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Layout* cobj = (cocos2d::gui::Layout *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setLayoutType : Invalid Native Object"); if (argc == 1) { cocos2d::gui::LayoutType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Layout_setLayoutType : Error processing arguments"); cobj->setLayoutType(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_setLayoutType : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Layout* ret = cocos2d::gui::Layout::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Layout*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Layout_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Layout* cobj = new cocos2d::gui::Layout(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::Layout"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Layout_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_Layout_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Layout)", obj); } void js_register_cocos2dx_gui_Layout(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_Layout_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_Layout_class->name = "Layout"; jsb_cocos2d_gui_Layout_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_Layout_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_Layout_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_Layout_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_Layout_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_Layout_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_Layout_class->convert = JS_ConvertStub; jsb_cocos2d_gui_Layout_class->finalize = js_cocos2d_gui_Layout_finalize; jsb_cocos2d_gui_Layout_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setBackGroundColorVector", js_cocos2dx_gui_Layout_setBackGroundColorVector, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hitTest", js_cocos2dx_gui_Layout_hitTest, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackGroundImageTextureSize", js_cocos2dx_gui_Layout_getBackGroundImageTextureSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayoutType", js_cocos2dx_gui_Layout_getLayoutType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClippingType", js_cocos2dx_gui_Layout_setClippingType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackGroundColorType", js_cocos2dx_gui_Layout_setBackGroundColorType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackGroundImage", js_cocos2dx_gui_Layout_setBackGroundImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackGroundColor", js_cocos2dx_gui_Layout_setBackGroundColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestDoLayout", js_cocos2dx_gui_Layout_requestDoLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isClippingEnabled", js_cocos2dx_gui_Layout_isClippingEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackGroundColorOpacity", js_cocos2dx_gui_Layout_setBackGroundColorOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackGroundImageCapInsets", js_cocos2dx_gui_Layout_setBackGroundImageCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeBackGroundImage", js_cocos2dx_gui_Layout_removeBackGroundImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackGroundImageScale9Enabled", js_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClippingEnabled", js_cocos2dx_gui_Layout_setClippingEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLayoutType", js_cocos2dx_gui_Layout_setLayoutType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_Layout_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_Layout_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_Layout_class, js_cocos2dx_gui_Layout_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Layout", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_Layout_class; p->proto = jsb_cocos2d_gui_Layout_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_Button_class; JSObject *jsb_cocos2d_gui_Button_prototype; JSBool js_cocos2dx_gui_Button_getTitleText(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_getTitleText : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getTitleText(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_getTitleText : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_loadTextureNormal(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextureNormal : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextureNormal : Error processing arguments"); cobj->loadTextureNormal(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextureNormal : Error processing arguments"); cobj->loadTextureNormal(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_loadTextureNormal : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setCapInsetsNormalRenderer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setCapInsetsNormalRenderer : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setCapInsetsNormalRenderer : Error processing arguments"); cobj->setCapInsetsNormalRenderer(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setCapInsetsNormalRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setCapInsetsPressedRenderer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setCapInsetsPressedRenderer : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setCapInsetsPressedRenderer : Error processing arguments"); cobj->setCapInsetsPressedRenderer(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setCapInsetsPressedRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_loadTexturePressed(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTexturePressed : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTexturePressed : Error processing arguments"); cobj->loadTexturePressed(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTexturePressed : Error processing arguments"); cobj->loadTexturePressed(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_loadTexturePressed : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setTitleFontSize : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setTitleFontSize : Error processing arguments"); cobj->setTitleFontSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setTitleFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setCapInsetsDisabledRenderer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setCapInsetsDisabledRenderer : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setCapInsetsDisabledRenderer : Error processing arguments"); cobj->setCapInsetsDisabledRenderer(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setCapInsetsDisabledRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setTitleFontName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setTitleFontName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setTitleFontName : Error processing arguments"); cobj->setTitleFontName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setTitleFontName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_getTitleColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_getTitleColor : Invalid Native Object"); if (argc == 0) { const cocos2d::Color3B& ret = cobj->getTitleColor(); jsval jsret = JSVAL_NULL; jsret = cccolor3b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_getTitleColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_loadTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextureDisabled : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextureDisabled : Error processing arguments"); cobj->loadTextureDisabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextureDisabled : Error processing arguments"); cobj->loadTextureDisabled(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_loadTextureDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_getTitleFontName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_getTitleFontName : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getTitleFontName(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_getTitleFontName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setPressedActionEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setPressedActionEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setPressedActionEnabled : Error processing arguments"); cobj->setPressedActionEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setPressedActionEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setCapInsets : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setCapInsets : Error processing arguments"); cobj->setCapInsets(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setScale9Enabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setScale9Enabled : Error processing arguments"); cobj->setScale9Enabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_loadTextures(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextures : Invalid Native Object"); if (argc == 3) { const char* arg0; const char* arg1; const char* arg2; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextures : Error processing arguments"); cobj->loadTextures(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 4) { const char* arg0; const char* arg1; const char* arg2; cocos2d::gui::TextureResType arg3; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_loadTextures : Error processing arguments"); cobj->loadTextures(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_loadTextures : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_getTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_getTitleFontSize : Invalid Native Object"); if (argc == 0) { double ret = cobj->getTitleFontSize(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_getTitleFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setTitleText(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setTitleText : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setTitleText : Error processing arguments"); cobj->setTitleText(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setTitleText : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_setTitleColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Button* cobj = (cocos2d::gui::Button *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Button_setTitleColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color3B arg0; ok &= jsval_to_cccolor3b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Button_setTitleColor : Error processing arguments"); cobj->setTitleColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_setTitleColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Button* ret = cocos2d::gui::Button::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Button*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Button_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Button* cobj = new cocos2d::gui::Button(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::Button"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Button_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_Button_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Button)", obj); } void js_register_cocos2dx_gui_Button(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_Button_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_Button_class->name = "Button"; jsb_cocos2d_gui_Button_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_Button_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_Button_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_Button_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_Button_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_Button_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_Button_class->convert = JS_ConvertStub; jsb_cocos2d_gui_Button_class->finalize = js_cocos2d_gui_Button_finalize; jsb_cocos2d_gui_Button_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getTitleText", js_cocos2dx_gui_Button_getTitleText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureNormal", js_cocos2dx_gui_Button_loadTextureNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsetsNormalRenderer", js_cocos2dx_gui_Button_setCapInsetsNormalRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsetsPressedRenderer", js_cocos2dx_gui_Button_setCapInsetsPressedRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTexturePressed", js_cocos2dx_gui_Button_loadTexturePressed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleFontSize", js_cocos2dx_gui_Button_setTitleFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsetsDisabledRenderer", js_cocos2dx_gui_Button_setCapInsetsDisabledRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleFontName", js_cocos2dx_gui_Button_setTitleFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleColor", js_cocos2dx_gui_Button_getTitleColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureDisabled", js_cocos2dx_gui_Button_loadTextureDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleFontName", js_cocos2dx_gui_Button_getTitleFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPressedActionEnabled", js_cocos2dx_gui_Button_setPressedActionEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_gui_Button_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale9Enabled", js_cocos2dx_gui_Button_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextures", js_cocos2dx_gui_Button_loadTextures, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleFontSize", js_cocos2dx_gui_Button_getTitleFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleText", js_cocos2dx_gui_Button_setTitleText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTitleColor", js_cocos2dx_gui_Button_setTitleColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_Button_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_Button_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_Button_class, js_cocos2dx_gui_Button_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Button", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_Button_class; p->proto = jsb_cocos2d_gui_Button_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_CheckBox_class; JSObject *jsb_cocos2d_gui_CheckBox_prototype; JSBool js_cocos2dx_gui_CheckBox_getSelectedState(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::CheckBox* cobj = (cocos2d::gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_getSelectedState : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getSelectedState(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_getSelectedState : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::CheckBox* cobj = (cocos2d::gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected : Error processing arguments"); cobj->loadTextureBackGroundSelected(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected : Error processing arguments"); cobj->loadTextureBackGroundSelected(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::CheckBox* cobj = (cocos2d::gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled : Error processing arguments"); cobj->loadTextureBackGroundDisabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled : Error processing arguments"); cobj->loadTextureBackGroundDisabled(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_loadTextureFrontCross(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::CheckBox* cobj = (cocos2d::gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureFrontCross : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureFrontCross : Error processing arguments"); cobj->loadTextureFrontCross(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureFrontCross : Error processing arguments"); cobj->loadTextureFrontCross(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_loadTextureFrontCross : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_loadTextures(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::CheckBox* cobj = (cocos2d::gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextures : Invalid Native Object"); if (argc == 5) { const char* arg0; const char* arg1; const char* arg2; const char* arg3; const char* arg4; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); std::string arg3_tmp; ok &= jsval_to_std_string(cx, argv[3], &arg3_tmp); arg3 = arg3_tmp.c_str(); std::string arg4_tmp; ok &= jsval_to_std_string(cx, argv[4], &arg4_tmp); arg4 = arg4_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextures : Error processing arguments"); cobj->loadTextures(arg0, arg1, arg2, arg3, arg4); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 6) { const char* arg0; const char* arg1; const char* arg2; const char* arg3; const char* arg4; cocos2d::gui::TextureResType arg5; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); std::string arg3_tmp; ok &= jsval_to_std_string(cx, argv[3], &arg3_tmp); arg3 = arg3_tmp.c_str(); std::string arg4_tmp; ok &= jsval_to_std_string(cx, argv[4], &arg4_tmp); arg4 = arg4_tmp.c_str(); ok &= jsval_to_int32(cx, argv[5], (int32_t *)&arg5); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextures : Error processing arguments"); cobj->loadTextures(arg0, arg1, arg2, arg3, arg4, arg5); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_loadTextures : wrong number of arguments: %d, was expecting %d", argc, 5); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_loadTextureBackGround(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::CheckBox* cobj = (cocos2d::gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGround : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGround : Error processing arguments"); cobj->loadTextureBackGround(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureBackGround : Error processing arguments"); cobj->loadTextureBackGround(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_loadTextureBackGround : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_setSelectedState(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::CheckBox* cobj = (cocos2d::gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_setSelectedState : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_setSelectedState : Error processing arguments"); cobj->setSelectedState(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_setSelectedState : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::CheckBox* cobj = (cocos2d::gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled : Error processing arguments"); cobj->loadTextureFrontCrossDisabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled : Error processing arguments"); cobj->loadTextureFrontCrossDisabled(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::CheckBox* ret = cocos2d::gui::CheckBox::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::CheckBox*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_CheckBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::CheckBox* cobj = new cocos2d::gui::CheckBox(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::CheckBox"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_CheckBox_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_CheckBox_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (CheckBox)", obj); } void js_register_cocos2dx_gui_CheckBox(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_CheckBox_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_CheckBox_class->name = "CheckBox"; jsb_cocos2d_gui_CheckBox_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_CheckBox_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_CheckBox_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_CheckBox_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_CheckBox_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_CheckBox_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_CheckBox_class->convert = JS_ConvertStub; jsb_cocos2d_gui_CheckBox_class->finalize = js_cocos2d_gui_CheckBox_finalize; jsb_cocos2d_gui_CheckBox_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getSelectedState", js_cocos2dx_gui_CheckBox_getSelectedState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureBackGroundSelected", js_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureBackGroundDisabled", js_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureFrontCross", js_cocos2dx_gui_CheckBox_loadTextureFrontCross, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextures", js_cocos2dx_gui_CheckBox_loadTextures, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureBackGround", js_cocos2dx_gui_CheckBox_loadTextureBackGround, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSelectedState", js_cocos2dx_gui_CheckBox_setSelectedState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTextureFrontCrossDisabled", js_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_CheckBox_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_CheckBox_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_CheckBox_class, js_cocos2dx_gui_CheckBox_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "CheckBox", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_CheckBox_class; p->proto = jsb_cocos2d_gui_CheckBox_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_ImageView_class; JSObject *jsb_cocos2d_gui_ImageView_prototype; JSBool js_cocos2dx_gui_ImageView_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ImageView* cobj = (cocos2d::gui::ImageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_setTextureRect : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_setTextureRect : Error processing arguments"); cobj->setTextureRect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ImageView_setTextureRect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ImageView_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ImageView* cobj = (cocos2d::gui::ImageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_setCapInsets : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_setCapInsets : Error processing arguments"); cobj->setCapInsets(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ImageView_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ImageView_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ImageView* cobj = (cocos2d::gui::ImageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_setScale9Enabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_setScale9Enabled : Error processing arguments"); cobj->setScale9Enabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ImageView_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ImageView_loadTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ImageView* cobj = (cocos2d::gui::ImageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_loadTexture : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_loadTexture : Error processing arguments"); cobj->loadTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ImageView_loadTexture : Error processing arguments"); cobj->loadTexture(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ImageView_loadTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ImageView_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::ImageView* ret = cocos2d::gui::ImageView::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::ImageView*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ImageView_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_ImageView_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::ImageView* cobj = new cocos2d::gui::ImageView(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::ImageView"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ImageView_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_ImageView_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ImageView)", obj); } void js_register_cocos2dx_gui_ImageView(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_ImageView_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_ImageView_class->name = "ImageView"; jsb_cocos2d_gui_ImageView_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_ImageView_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_ImageView_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_ImageView_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_ImageView_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_ImageView_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_ImageView_class->convert = JS_ConvertStub; jsb_cocos2d_gui_ImageView_class->finalize = js_cocos2d_gui_ImageView_finalize; jsb_cocos2d_gui_ImageView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setTextureRect", js_cocos2dx_gui_ImageView_setTextureRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_gui_ImageView_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale9Enabled", js_cocos2dx_gui_ImageView_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTexture", js_cocos2dx_gui_ImageView_loadTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_ImageView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_ImageView_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_ImageView_class, js_cocos2dx_gui_ImageView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ImageView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_ImageView_class; p->proto = jsb_cocos2d_gui_ImageView_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_Text_class; JSObject *jsb_cocos2d_gui_Text_prototype; JSBool js_cocos2dx_gui_Text_getStringLength(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_getStringLength : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getStringLength(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_getStringLength : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_setFontName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_setFontName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Text_setFontName : Error processing arguments"); cobj->setFontName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_setFontName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_setTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_setTouchScaleChangeEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Text_setTouchScaleChangeEnabled : Error processing arguments"); cobj->setTouchScaleChangeEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_setTouchScaleChangeEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_getStringValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_getStringValue : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getStringValue(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_getStringValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_setText(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_setText : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Text_setText : Error processing arguments"); cobj->setText(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_setText : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_setTextVerticalAlignment : Invalid Native Object"); if (argc == 1) { cocos2d::TextVAlignment arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Text_setTextVerticalAlignment : Error processing arguments"); cobj->setTextVerticalAlignment(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_setTextVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_setFontSize : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Text_setFontSize : Error processing arguments"); cobj->setFontSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_isTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_isTouchScaleChangeEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isTouchScaleChangeEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_isTouchScaleChangeEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_setTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_setTextHorizontalAlignment : Invalid Native Object"); if (argc == 1) { cocos2d::TextHAlignment arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Text_setTextHorizontalAlignment : Error processing arguments"); cobj->setTextHorizontalAlignment(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_setTextHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Text* cobj = (cocos2d::gui::Text *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Text_setTextAreaSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Text_setTextAreaSize : Error processing arguments"); cobj->setTextAreaSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_setTextAreaSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Text* ret = cocos2d::gui::Text::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Text*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Text_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Text* cobj = new cocos2d::gui::Text(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::Text"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Text_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_Text_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Text)", obj); } void js_register_cocos2dx_gui_Text(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_Text_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_Text_class->name = "Text"; jsb_cocos2d_gui_Text_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_Text_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_Text_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_Text_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_Text_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_Text_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_Text_class->convert = JS_ConvertStub; jsb_cocos2d_gui_Text_class->finalize = js_cocos2d_gui_Text_finalize; jsb_cocos2d_gui_Text_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getStringLength", js_cocos2dx_gui_Text_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontName", js_cocos2dx_gui_Text_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchScaleChangeEnabled", js_cocos2dx_gui_Text_setTouchScaleChangeEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringValue", js_cocos2dx_gui_Text_getStringValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setText", js_cocos2dx_gui_Text_setText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextVerticalAlignment", js_cocos2dx_gui_Text_setTextVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontSize", js_cocos2dx_gui_Text_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchScaleChangeEnabled", js_cocos2dx_gui_Text_isTouchScaleChangeEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextHorizontalAlignment", js_cocos2dx_gui_Text_setTextHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextAreaSize", js_cocos2dx_gui_Text_setTextAreaSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_Text_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_Text_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_Text_class, js_cocos2dx_gui_Text_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Text", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_Text_class; p->proto = jsb_cocos2d_gui_Text_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_TextAtlas_class; JSObject *jsb_cocos2d_gui_TextAtlas_prototype; JSBool js_cocos2dx_gui_TextAtlas_setProperty(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextAtlas* cobj = (cocos2d::gui::TextAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextAtlas_setProperty : Invalid Native Object"); if (argc == 5) { std::string arg0; std::string arg1; int arg2; int arg3; std::string arg4; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); ok &= jsval_to_std_string(cx, argv[4], &arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextAtlas_setProperty : Error processing arguments"); cobj->setProperty(arg0, arg1, arg2, arg3, arg4); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextAtlas_setProperty : wrong number of arguments: %d, was expecting %d", argc, 5); return JS_FALSE; } JSBool js_cocos2dx_gui_TextAtlas_getStringValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextAtlas* cobj = (cocos2d::gui::TextAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextAtlas_getStringValue : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getStringValue(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextAtlas_getStringValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextAtlas_setStringValue(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextAtlas* cobj = (cocos2d::gui::TextAtlas *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextAtlas_setStringValue : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextAtlas_setStringValue : Error processing arguments"); cobj->setStringValue(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextAtlas_setStringValue : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextAtlas_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::TextAtlas* ret = cocos2d::gui::TextAtlas::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::TextAtlas*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextAtlas_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_TextAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::TextAtlas* cobj = new cocos2d::gui::TextAtlas(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::TextAtlas"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextAtlas_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_TextAtlas_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TextAtlas)", obj); } void js_register_cocos2dx_gui_TextAtlas(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_TextAtlas_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_TextAtlas_class->name = "TextAtlas"; jsb_cocos2d_gui_TextAtlas_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_TextAtlas_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_TextAtlas_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_TextAtlas_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_TextAtlas_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_TextAtlas_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_TextAtlas_class->convert = JS_ConvertStub; jsb_cocos2d_gui_TextAtlas_class->finalize = js_cocos2d_gui_TextAtlas_finalize; jsb_cocos2d_gui_TextAtlas_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setProperty", js_cocos2dx_gui_TextAtlas_setProperty, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringValue", js_cocos2dx_gui_TextAtlas_getStringValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStringValue", js_cocos2dx_gui_TextAtlas_setStringValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_TextAtlas_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_TextAtlas_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_TextAtlas_class, js_cocos2dx_gui_TextAtlas_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TextAtlas", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_TextAtlas_class; p->proto = jsb_cocos2d_gui_TextAtlas_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_LoadingBar_class; JSObject *jsb_cocos2d_gui_LoadingBar_prototype; JSBool js_cocos2dx_gui_LoadingBar_setPercent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LoadingBar* cobj = (cocos2d::gui::LoadingBar *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_setPercent : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_setPercent : Error processing arguments"); cobj->setPercent(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_setPercent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_LoadingBar_loadTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LoadingBar* cobj = (cocos2d::gui::LoadingBar *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_loadTexture : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_loadTexture : Error processing arguments"); cobj->loadTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_loadTexture : Error processing arguments"); cobj->loadTexture(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_loadTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_LoadingBar_setDirection(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LoadingBar* cobj = (cocos2d::gui::LoadingBar *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_setDirection : Invalid Native Object"); if (argc == 1) { cocos2d::gui::LoadingBarType arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_setDirection : Error processing arguments"); cobj->setDirection(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_LoadingBar_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LoadingBar* cobj = (cocos2d::gui::LoadingBar *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_setScale9Enabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_setScale9Enabled : Error processing arguments"); cobj->setScale9Enabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_LoadingBar_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LoadingBar* cobj = (cocos2d::gui::LoadingBar *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_setCapInsets : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_setCapInsets : Error processing arguments"); cobj->setCapInsets(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_LoadingBar_getDirection(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LoadingBar* cobj = (cocos2d::gui::LoadingBar *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_getDirection : Invalid Native Object"); if (argc == 0) { int ret = cobj->getDirection(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_LoadingBar_getPercent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::LoadingBar* cobj = (cocos2d::gui::LoadingBar *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_LoadingBar_getPercent : Invalid Native Object"); if (argc == 0) { int ret = cobj->getPercent(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_getPercent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_LoadingBar_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::LoadingBar* ret = cocos2d::gui::LoadingBar::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::LoadingBar*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_LoadingBar_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::LoadingBar* cobj = new cocos2d::gui::LoadingBar(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::LoadingBar"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_LoadingBar_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_LoadingBar_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LoadingBar)", obj); } void js_register_cocos2dx_gui_LoadingBar(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_LoadingBar_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_LoadingBar_class->name = "LoadingBar"; jsb_cocos2d_gui_LoadingBar_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_LoadingBar_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_LoadingBar_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_LoadingBar_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_LoadingBar_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_LoadingBar_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_LoadingBar_class->convert = JS_ConvertStub; jsb_cocos2d_gui_LoadingBar_class->finalize = js_cocos2d_gui_LoadingBar_finalize; jsb_cocos2d_gui_LoadingBar_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setPercent", js_cocos2dx_gui_LoadingBar_setPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadTexture", js_cocos2dx_gui_LoadingBar_loadTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDirection", js_cocos2dx_gui_LoadingBar_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale9Enabled", js_cocos2dx_gui_LoadingBar_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_gui_LoadingBar_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDirection", js_cocos2dx_gui_LoadingBar_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPercent", js_cocos2dx_gui_LoadingBar_getPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_LoadingBar_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_LoadingBar_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_LoadingBar_class, js_cocos2dx_gui_LoadingBar_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "LoadingBar", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_LoadingBar_class; p->proto = jsb_cocos2d_gui_LoadingBar_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_ScrollView_class; JSObject *jsb_cocos2d_gui_ScrollView_prototype; JSBool js_cocos2dx_gui_ScrollView_scrollToTop(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToTop : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToTop : Error processing arguments"); cobj->scrollToTop(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToTop : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToPercentHorizontal(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToPercentHorizontal : Invalid Native Object"); if (argc == 3) { double arg0; double arg1; JSBool arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToPercentHorizontal : Error processing arguments"); cobj->scrollToPercentHorizontal(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToPercentHorizontal : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_isInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_isInertiaScrollEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isInertiaScrollEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_isInertiaScrollEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToPercentBothDirection(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToPercentBothDirection : Invalid Native Object"); if (argc == 3) { cocos2d::Point arg0; double arg1; JSBool arg2; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToPercentBothDirection : Error processing arguments"); cobj->scrollToPercentBothDirection(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToPercentBothDirection : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_getDirection(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_getDirection : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getDirection(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToBottomLeft(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToBottomLeft : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToBottomLeft : Error processing arguments"); cobj->scrollToBottomLeft(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToBottomLeft : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_getInnerContainer(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_getInnerContainer : Invalid Native Object"); if (argc == 0) { cocos2d::gui::Layout* ret = cobj->getInnerContainer(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Layout*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_getInnerContainer : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToBottom(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToBottom : Invalid Native Object"); if (argc == 0) { cobj->jumpToBottom(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToBottom : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_setDirection(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_setDirection : Invalid Native Object"); if (argc == 1) { cocos2d::gui::SCROLLVIEW_DIR arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_setDirection : Error processing arguments"); cobj->setDirection(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToTopLeft(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToTopLeft : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToTopLeft : Error processing arguments"); cobj->scrollToTopLeft(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToTopLeft : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToTopRight(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToTopRight : Invalid Native Object"); if (argc == 0) { cobj->jumpToTopRight(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToTopRight : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToBottomLeft(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToBottomLeft : Invalid Native Object"); if (argc == 0) { cobj->jumpToBottomLeft(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToBottomLeft : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_setInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_setInnerContainerSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_setInnerContainerSize : Error processing arguments"); cobj->setInnerContainerSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_setInnerContainerSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_getInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_getInnerContainerSize : Invalid Native Object"); if (argc == 0) { const cocos2d::Size& ret = cobj->getInnerContainerSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_getInnerContainerSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_isBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_isBounceEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isBounceEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_isBounceEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToPercentVertical : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToPercentVertical : Error processing arguments"); cobj->jumpToPercentVertical(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToPercentVertical : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_setInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_setInertiaScrollEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_setInertiaScrollEnabled : Error processing arguments"); cobj->setInertiaScrollEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_setInertiaScrollEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToTopLeft(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToTopLeft : Invalid Native Object"); if (argc == 0) { cobj->jumpToTopLeft(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToTopLeft : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToPercentHorizontal(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToPercentHorizontal : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToPercentHorizontal : Error processing arguments"); cobj->jumpToPercentHorizontal(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToPercentHorizontal : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToBottomRight(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToBottomRight : Invalid Native Object"); if (argc == 0) { cobj->jumpToBottomRight(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToBottomRight : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_setBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_setBounceEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_setBounceEnabled : Error processing arguments"); cobj->setBounceEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_setBounceEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToTop(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToTop : Invalid Native Object"); if (argc == 0) { cobj->jumpToTop(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToTop : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToLeft(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToLeft : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToLeft : Error processing arguments"); cobj->scrollToLeft(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToLeft : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToPercentBothDirection(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToPercentBothDirection : Invalid Native Object"); if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToPercentBothDirection : Error processing arguments"); cobj->jumpToPercentBothDirection(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToPercentBothDirection : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToPercentVertical : Invalid Native Object"); if (argc == 3) { double arg0; double arg1; JSBool arg2; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToPercentVertical : Error processing arguments"); cobj->scrollToPercentVertical(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToPercentVertical : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToBottom(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToBottom : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToBottom : Error processing arguments"); cobj->scrollToBottom(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToBottom : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToBottomRight(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToBottomRight : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToBottomRight : Error processing arguments"); cobj->scrollToBottomRight(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToBottomRight : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToLeft(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToLeft : Invalid Native Object"); if (argc == 0) { cobj->jumpToLeft(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToLeft : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToRight(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToRight : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToRight : Error processing arguments"); cobj->scrollToRight(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToRight : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_jumpToRight(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_jumpToRight : Invalid Native Object"); if (argc == 0) { cobj->jumpToRight(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_jumpToRight : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_scrollToTopRight(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ScrollView* cobj = (cocos2d::gui::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToTopRight : Invalid Native Object"); if (argc == 2) { double arg0; JSBool arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ScrollView_scrollToTopRight : Error processing arguments"); cobj->scrollToTopRight(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_scrollToTopRight : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::ScrollView* ret = cocos2d::gui::ScrollView::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::ScrollView*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::ScrollView* cobj = new cocos2d::gui::ScrollView(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::ScrollView"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ScrollView_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Layout_prototype; void js_cocos2d_gui_ScrollView_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ScrollView)", obj); } void js_register_cocos2dx_gui_ScrollView(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_ScrollView_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_ScrollView_class->name = "ScrollView"; jsb_cocos2d_gui_ScrollView_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_ScrollView_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_ScrollView_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_ScrollView_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_ScrollView_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_ScrollView_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_ScrollView_class->convert = JS_ConvertStub; jsb_cocos2d_gui_ScrollView_class->finalize = js_cocos2d_gui_ScrollView_finalize; jsb_cocos2d_gui_ScrollView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("scrollToTop", js_cocos2dx_gui_ScrollView_scrollToTop, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToPercentHorizontal", js_cocos2dx_gui_ScrollView_scrollToPercentHorizontal, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isInertiaScrollEnabled", js_cocos2dx_gui_ScrollView_isInertiaScrollEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToPercentBothDirection", js_cocos2dx_gui_ScrollView_scrollToPercentBothDirection, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDirection", js_cocos2dx_gui_ScrollView_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToBottomLeft", js_cocos2dx_gui_ScrollView_scrollToBottomLeft, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInnerContainer", js_cocos2dx_gui_ScrollView_getInnerContainer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToBottom", js_cocos2dx_gui_ScrollView_jumpToBottom, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDirection", js_cocos2dx_gui_ScrollView_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToTopLeft", js_cocos2dx_gui_ScrollView_scrollToTopLeft, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToTopRight", js_cocos2dx_gui_ScrollView_jumpToTopRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToBottomLeft", js_cocos2dx_gui_ScrollView_jumpToBottomLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInnerContainerSize", js_cocos2dx_gui_ScrollView_setInnerContainerSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInnerContainerSize", js_cocos2dx_gui_ScrollView_getInnerContainerSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBounceEnabled", js_cocos2dx_gui_ScrollView_isBounceEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToPercentVertical", js_cocos2dx_gui_ScrollView_jumpToPercentVertical, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInertiaScrollEnabled", js_cocos2dx_gui_ScrollView_setInertiaScrollEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToTopLeft", js_cocos2dx_gui_ScrollView_jumpToTopLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToPercentHorizontal", js_cocos2dx_gui_ScrollView_jumpToPercentHorizontal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToBottomRight", js_cocos2dx_gui_ScrollView_jumpToBottomRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBounceEnabled", js_cocos2dx_gui_ScrollView_setBounceEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToTop", js_cocos2dx_gui_ScrollView_jumpToTop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToLeft", js_cocos2dx_gui_ScrollView_scrollToLeft, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToPercentBothDirection", js_cocos2dx_gui_ScrollView_jumpToPercentBothDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToPercentVertical", js_cocos2dx_gui_ScrollView_scrollToPercentVertical, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToBottom", js_cocos2dx_gui_ScrollView_scrollToBottom, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToBottomRight", js_cocos2dx_gui_ScrollView_scrollToBottomRight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToLeft", js_cocos2dx_gui_ScrollView_jumpToLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToRight", js_cocos2dx_gui_ScrollView_scrollToRight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("jumpToRight", js_cocos2dx_gui_ScrollView_jumpToRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToTopRight", js_cocos2dx_gui_ScrollView_scrollToTopRight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_ScrollView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_ScrollView_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Layout_prototype, jsb_cocos2d_gui_ScrollView_class, js_cocos2dx_gui_ScrollView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ScrollView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_ScrollView_class; p->proto = jsb_cocos2d_gui_ScrollView_prototype; p->parentProto = jsb_cocos2d_gui_Layout_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_ListView_class; JSObject *jsb_cocos2d_gui_ListView_prototype; JSBool js_cocos2dx_gui_ListView_getIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_getIndex : Invalid Native Object"); if (argc == 1) { cocos2d::gui::Widget* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_getIndex : Error processing arguments"); ssize_t ret = cobj->getIndex(arg0); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_getIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_removeAllItems(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_removeAllItems : Invalid Native Object"); if (argc == 0) { cobj->removeAllItems(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_removeAllItems : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_setGravity(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_setGravity : Invalid Native Object"); if (argc == 1) { cocos2d::gui::ListViewGravity arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_setGravity : Error processing arguments"); cobj->setGravity(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_pushBackCustomItem(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_pushBackCustomItem : Invalid Native Object"); if (argc == 1) { cocos2d::gui::Widget* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_pushBackCustomItem : Error processing arguments"); cobj->pushBackCustomItem(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_pushBackCustomItem : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_getItems(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_getItems : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getItems(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_getItems : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_removeItem(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_removeItem : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_removeItem : Error processing arguments"); cobj->removeItem(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_removeItem : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_getCurSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_getCurSelectedIndex : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getCurSelectedIndex(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_getCurSelectedIndex : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_insertDefaultItem(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_insertDefaultItem : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_insertDefaultItem : Error processing arguments"); cobj->insertDefaultItem(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_insertDefaultItem : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_setItemsMargin(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_setItemsMargin : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_setItemsMargin : Error processing arguments"); cobj->setItemsMargin(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_setItemsMargin : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_removeLastItem(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_removeLastItem : Invalid Native Object"); if (argc == 0) { cobj->removeLastItem(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_removeLastItem : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_getItem(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_getItem : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_getItem : Error processing arguments"); cocos2d::gui::Widget* ret = cobj->getItem(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_getItem : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_setItemModel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_setItemModel : Invalid Native Object"); if (argc == 1) { cocos2d::gui::Widget* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_setItemModel : Error processing arguments"); cobj->setItemModel(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_setItemModel : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_requestRefreshView(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_requestRefreshView : Invalid Native Object"); if (argc == 0) { cobj->requestRefreshView(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_requestRefreshView : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_pushBackDefaultItem(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_pushBackDefaultItem : Invalid Native Object"); if (argc == 0) { cobj->pushBackDefaultItem(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_pushBackDefaultItem : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_insertCustomItem(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::ListView* cobj = (cocos2d::gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_ListView_insertCustomItem : Invalid Native Object"); if (argc == 2) { cocos2d::gui::Widget* arg0; ssize_t arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ssize(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_ListView_insertCustomItem : Error processing arguments"); cobj->insertCustomItem(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_insertCustomItem : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::ListView* ret = cocos2d::gui::ListView::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::ListView*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_ListView_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::ListView* cobj = new cocos2d::gui::ListView(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::ListView"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_ListView_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_ScrollView_prototype; void js_cocos2d_gui_ListView_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ListView)", obj); } void js_register_cocos2dx_gui_ListView(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_ListView_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_ListView_class->name = "ListView"; jsb_cocos2d_gui_ListView_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_ListView_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_ListView_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_ListView_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_ListView_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_ListView_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_ListView_class->convert = JS_ConvertStub; jsb_cocos2d_gui_ListView_class->finalize = js_cocos2d_gui_ListView_finalize; jsb_cocos2d_gui_ListView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getIndex", js_cocos2dx_gui_ListView_getIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllItems", js_cocos2dx_gui_ListView_removeAllItems, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGravity", js_cocos2dx_gui_ListView_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pushBackCustomItem", js_cocos2dx_gui_ListView_pushBackCustomItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getItems", js_cocos2dx_gui_ListView_getItems, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeItem", js_cocos2dx_gui_ListView_removeItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurSelectedIndex", js_cocos2dx_gui_ListView_getCurSelectedIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("insertDefaultItem", js_cocos2dx_gui_ListView_insertDefaultItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setItemsMargin", js_cocos2dx_gui_ListView_setItemsMargin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeLastItem", js_cocos2dx_gui_ListView_removeLastItem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getItem", js_cocos2dx_gui_ListView_getItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setItemModel", js_cocos2dx_gui_ListView_setItemModel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestRefreshView", js_cocos2dx_gui_ListView_requestRefreshView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pushBackDefaultItem", js_cocos2dx_gui_ListView_pushBackDefaultItem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("insertCustomItem", js_cocos2dx_gui_ListView_insertCustomItem, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_ListView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_ListView_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_ScrollView_prototype, jsb_cocos2d_gui_ListView_class, js_cocos2dx_gui_ListView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ListView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_ListView_class; p->proto = jsb_cocos2d_gui_ListView_prototype; p->parentProto = jsb_cocos2d_gui_ScrollView_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_Slider_class; JSObject *jsb_cocos2d_gui_Slider_prototype; JSBool js_cocos2dx_gui_Slider_setPercent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setPercent : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setPercent : Error processing arguments"); cobj->setPercent(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_setPercent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_loadSlidBallTextureNormal(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextureNormal : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextureNormal : Error processing arguments"); cobj->loadSlidBallTextureNormal(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextureNormal : Error processing arguments"); cobj->loadSlidBallTextureNormal(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_loadSlidBallTextureNormal : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadBarTexture : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadBarTexture : Error processing arguments"); cobj->loadBarTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadBarTexture : Error processing arguments"); cobj->loadBarTexture(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_loadBarTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_loadProgressBarTexture(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadProgressBarTexture : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadProgressBarTexture : Error processing arguments"); cobj->loadProgressBarTexture(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadProgressBarTexture : Error processing arguments"); cobj->loadProgressBarTexture(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_loadProgressBarTexture : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextures : Invalid Native Object"); if (argc == 3) { const char* arg0; const char* arg1; const char* arg2; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextures : Error processing arguments"); cobj->loadSlidBallTextures(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 4) { const char* arg0; const char* arg1; const char* arg2; cocos2d::gui::TextureResType arg3; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= jsval_to_std_string(cx, argv[2], &arg2_tmp); arg2 = arg2_tmp.c_str(); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextures : Error processing arguments"); cobj->loadSlidBallTextures(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_loadSlidBallTextures : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer : Error processing arguments"); cobj->setCapInsetProgressBarRebderer(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setCapInsetsBarRenderer : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setCapInsetsBarRenderer : Error processing arguments"); cobj->setCapInsetsBarRenderer(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_setCapInsetsBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setScale9Enabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setScale9Enabled : Error processing arguments"); cobj->setScale9Enabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setCapInsets : Invalid Native Object"); if (argc == 1) { cocos2d::Rect arg0; ok &= jsval_to_ccrect(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_setCapInsets : Error processing arguments"); cobj->setCapInsets(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTexturePressed : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTexturePressed : Error processing arguments"); cobj->loadSlidBallTexturePressed(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTexturePressed : Error processing arguments"); cobj->loadSlidBallTexturePressed(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_loadSlidBallTexturePressed : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_loadSlidBallTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextureDisabled : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextureDisabled : Error processing arguments"); cobj->loadSlidBallTextureDisabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Slider_loadSlidBallTextureDisabled : Error processing arguments"); cobj->loadSlidBallTextureDisabled(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_loadSlidBallTextureDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_getPercent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::Slider* cobj = (cocos2d::gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_Slider_getPercent : Invalid Native Object"); if (argc == 0) { int ret = cobj->getPercent(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_getPercent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Slider* ret = cocos2d::gui::Slider::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Slider*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Slider_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::Slider* cobj = new cocos2d::gui::Slider(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::Slider"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Slider_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_Slider_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Slider)", obj); } void js_register_cocos2dx_gui_Slider(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_Slider_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_Slider_class->name = "Slider"; jsb_cocos2d_gui_Slider_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_Slider_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_Slider_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_Slider_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_Slider_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_Slider_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_Slider_class->convert = JS_ConvertStub; jsb_cocos2d_gui_Slider_class->finalize = js_cocos2d_gui_Slider_finalize; jsb_cocos2d_gui_Slider_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setPercent", js_cocos2dx_gui_Slider_setPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTextureNormal", js_cocos2dx_gui_Slider_loadSlidBallTextureNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadBarTexture", js_cocos2dx_gui_Slider_loadBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadProgressBarTexture", js_cocos2dx_gui_Slider_loadProgressBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTextures", js_cocos2dx_gui_Slider_loadSlidBallTextures, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsetProgressBarRebderer", js_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsetsBarRenderer", js_cocos2dx_gui_Slider_setCapInsetsBarRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale9Enabled", js_cocos2dx_gui_Slider_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_gui_Slider_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTexturePressed", js_cocos2dx_gui_Slider_loadSlidBallTexturePressed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTextureDisabled", js_cocos2dx_gui_Slider_loadSlidBallTextureDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPercent", js_cocos2dx_gui_Slider_getPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_Slider_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_Slider_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_Slider_class, js_cocos2dx_gui_Slider_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Slider", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_Slider_class; p->proto = jsb_cocos2d_gui_Slider_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_TextField_class; JSObject *jsb_cocos2d_gui_TextField_prototype; JSBool js_cocos2dx_gui_TextField_setAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setAttachWithIME : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setAttachWithIME : Error processing arguments"); cobj->setAttachWithIME(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setAttachWithIME : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_getStringValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_getStringValue : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getStringValue(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_getStringValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setPasswordStyleText(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setPasswordStyleText : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setPasswordStyleText : Error processing arguments"); cobj->setPasswordStyleText(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setPasswordStyleText : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_getAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_getAttachWithIME : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getAttachWithIME(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_getAttachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setFontName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setFontName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setFontName : Error processing arguments"); cobj->setFontName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setFontName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_getInsertText(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_getInsertText : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getInsertText(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_getInsertText : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setInsertText(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setInsertText : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setInsertText : Error processing arguments"); cobj->setInsertText(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setInsertText : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_getDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_getDetachWithIME : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getDetachWithIME(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_getDetachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_didNotSelectSelf : Invalid Native Object"); if (argc == 0) { cobj->didNotSelectSelf(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_didNotSelectSelf : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_attachWithIME(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_attachWithIME : Invalid Native Object"); if (argc == 0) { cobj->attachWithIME(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_attachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setPasswordEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setPasswordEnabled : Error processing arguments"); cobj->setPasswordEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setPasswordEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setMaxLengthEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setMaxLengthEnabled : Error processing arguments"); cobj->setMaxLengthEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setMaxLengthEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_getDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_getDeleteBackward : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getDeleteBackward(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_getDeleteBackward : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setFontSize : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setFontSize : Error processing arguments"); cobj->setFontSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setPlaceHolder : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setPlaceHolder : Error processing arguments"); cobj->setPlaceHolder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_isPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_isPasswordEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isPasswordEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_isPasswordEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_getMaxLength : Invalid Native Object"); if (argc == 0) { int ret = cobj->getMaxLength(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_getMaxLength : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_isMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_isMaxLengthEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isMaxLengthEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_isMaxLengthEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setDetachWithIME : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setDetachWithIME : Error processing arguments"); cobj->setDetachWithIME(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setDetachWithIME : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setText(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setText : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setText : Error processing arguments"); cobj->setText(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setText : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setMaxLength : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setMaxLength : Error processing arguments"); cobj->setMaxLength(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setMaxLength : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setTouchSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setTouchSize : Invalid Native Object"); if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setTouchSize : Error processing arguments"); cobj->setTouchSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setTouchSize : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_setDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextField* cobj = (cocos2d::gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setDeleteBackward : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextField_setDeleteBackward : Error processing arguments"); cobj->setDeleteBackward(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_setDeleteBackward : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::TextField* ret = cocos2d::gui::TextField::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::TextField*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_TextField_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::TextField* cobj = new cocos2d::gui::TextField(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::TextField"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextField_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_TextField_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TextField)", obj); } void js_register_cocos2dx_gui_TextField(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_TextField_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_TextField_class->name = "TextField"; jsb_cocos2d_gui_TextField_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_TextField_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_TextField_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_TextField_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_TextField_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_TextField_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_TextField_class->convert = JS_ConvertStub; jsb_cocos2d_gui_TextField_class->finalize = js_cocos2d_gui_TextField_finalize; jsb_cocos2d_gui_TextField_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setAttachWithIME", js_cocos2dx_gui_TextField_setAttachWithIME, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringValue", js_cocos2dx_gui_TextField_getStringValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPasswordStyleText", js_cocos2dx_gui_TextField_setPasswordStyleText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAttachWithIME", js_cocos2dx_gui_TextField_getAttachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontName", js_cocos2dx_gui_TextField_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInsertText", js_cocos2dx_gui_TextField_getInsertText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInsertText", js_cocos2dx_gui_TextField_setInsertText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDetachWithIME", js_cocos2dx_gui_TextField_getDetachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("didNotSelectSelf", js_cocos2dx_gui_TextField_didNotSelectSelf, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("attachWithIME", js_cocos2dx_gui_TextField_attachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPasswordEnabled", js_cocos2dx_gui_TextField_setPasswordEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxLengthEnabled", js_cocos2dx_gui_TextField_setMaxLengthEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDeleteBackward", js_cocos2dx_gui_TextField_getDeleteBackward, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontSize", js_cocos2dx_gui_TextField_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPlaceHolder", js_cocos2dx_gui_TextField_setPlaceHolder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPasswordEnabled", js_cocos2dx_gui_TextField_isPasswordEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxLength", js_cocos2dx_gui_TextField_getMaxLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isMaxLengthEnabled", js_cocos2dx_gui_TextField_isMaxLengthEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDetachWithIME", js_cocos2dx_gui_TextField_setDetachWithIME, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setText", js_cocos2dx_gui_TextField_setText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxLength", js_cocos2dx_gui_TextField_setMaxLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchSize", js_cocos2dx_gui_TextField_setTouchSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDeleteBackward", js_cocos2dx_gui_TextField_setDeleteBackward, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_TextField_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_TextField_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_TextField_class, js_cocos2dx_gui_TextField_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TextField", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_TextField_class; p->proto = jsb_cocos2d_gui_TextField_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_TextBMFont_class; JSObject *jsb_cocos2d_gui_TextBMFont_prototype; JSBool js_cocos2dx_gui_TextBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextBMFont* cobj = (cocos2d::gui::TextBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextBMFont_setFntFile : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextBMFont_setFntFile : Error processing arguments"); cobj->setFntFile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextBMFont_setFntFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextBMFont_getStringValue(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextBMFont* cobj = (cocos2d::gui::TextBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextBMFont_getStringValue : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getStringValue(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextBMFont_getStringValue : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_TextBMFont_setText(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::TextBMFont* cobj = (cocos2d::gui::TextBMFont *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_TextBMFont_setText : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_TextBMFont_setText : Error processing arguments"); cobj->setText(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextBMFont_setText : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_TextBMFont_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::TextBMFont* ret = cocos2d::gui::TextBMFont::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::TextBMFont*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextBMFont_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_TextBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::TextBMFont* cobj = new cocos2d::gui::TextBMFont(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::TextBMFont"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_TextBMFont_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Widget_prototype; void js_cocos2d_gui_TextBMFont_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (TextBMFont)", obj); } void js_register_cocos2dx_gui_TextBMFont(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_TextBMFont_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_TextBMFont_class->name = "TextBMFont"; jsb_cocos2d_gui_TextBMFont_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_TextBMFont_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_TextBMFont_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_TextBMFont_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_TextBMFont_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_TextBMFont_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_TextBMFont_class->convert = JS_ConvertStub; jsb_cocos2d_gui_TextBMFont_class->finalize = js_cocos2d_gui_TextBMFont_finalize; jsb_cocos2d_gui_TextBMFont_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setFntFile", js_cocos2dx_gui_TextBMFont_setFntFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringValue", js_cocos2dx_gui_TextBMFont_getStringValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setText", js_cocos2dx_gui_TextBMFont_setText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_TextBMFont_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_TextBMFont_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Widget_prototype, jsb_cocos2d_gui_TextBMFont_class, js_cocos2dx_gui_TextBMFont_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "TextBMFont", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_TextBMFont_class; p->proto = jsb_cocos2d_gui_TextBMFont_prototype; p->parentProto = jsb_cocos2d_gui_Widget_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_PageView_class; JSObject *jsb_cocos2d_gui_PageView_prototype; JSBool js_cocos2dx_gui_PageView_getCurPageIndex(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_getCurPageIndex : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getCurPageIndex(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_getCurPageIndex : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_addWidgetToPage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_addWidgetToPage : Invalid Native Object"); if (argc == 3) { cocos2d::gui::Widget* arg0; ssize_t arg1; JSBool arg2; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_ssize(cx, argv[1], &arg1); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_PageView_addWidgetToPage : Error processing arguments"); cobj->addWidgetToPage(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_addWidgetToPage : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_getPage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_getPage : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_PageView_getPage : Error processing arguments"); cocos2d::gui::Layout* ret = cobj->getPage(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Layout*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_getPage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_removePage : Invalid Native Object"); if (argc == 1) { cocos2d::gui::Layout* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Layout*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_PageView_removePage : Error processing arguments"); cobj->removePage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_removePage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_insertPage : Invalid Native Object"); if (argc == 2) { cocos2d::gui::Layout* arg0; int arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Layout*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_PageView_insertPage : Error processing arguments"); cobj->insertPage(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_insertPage : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_scrollToPage : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_PageView_scrollToPage : Error processing arguments"); cobj->scrollToPage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_scrollToPage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_removePageAtIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_removePageAtIndex : Invalid Native Object"); if (argc == 1) { ssize_t arg0; ok &= jsval_to_ssize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_PageView_removePageAtIndex : Error processing arguments"); cobj->removePageAtIndex(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_removePageAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_getPages(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_getPages : Invalid Native Object"); if (argc == 0) { cocos2d::Vector& ret = cobj->getPages(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_getPages : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_removeAllPages(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_removeAllPages : Invalid Native Object"); if (argc == 0) { cobj->removeAllPages(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_removeAllPages : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_addPage(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::gui::PageView* cobj = (cocos2d::gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_gui_PageView_addPage : Invalid Native Object"); if (argc == 1) { cocos2d::gui::Layout* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Layout*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_PageView_addPage : Error processing arguments"); cobj->addPage(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_addPage : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::PageView* ret = cocos2d::gui::PageView::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::PageView*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_PageView_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::gui::PageView* cobj = new cocos2d::gui::PageView(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::gui::PageView"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_PageView_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_gui_Layout_prototype; void js_cocos2d_gui_PageView_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PageView)", obj); } void js_register_cocos2dx_gui_PageView(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_PageView_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_PageView_class->name = "PageView"; jsb_cocos2d_gui_PageView_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_PageView_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_PageView_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_PageView_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_PageView_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_PageView_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_PageView_class->convert = JS_ConvertStub; jsb_cocos2d_gui_PageView_class->finalize = js_cocos2d_gui_PageView_finalize; jsb_cocos2d_gui_PageView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getCurPageIndex", js_cocos2dx_gui_PageView_getCurPageIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addWidgetToPage", js_cocos2dx_gui_PageView_addWidgetToPage, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPage", js_cocos2dx_gui_PageView_getPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removePage", js_cocos2dx_gui_PageView_removePage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("insertPage", js_cocos2dx_gui_PageView_insertPage, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("scrollToPage", js_cocos2dx_gui_PageView_scrollToPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removePageAtIndex", js_cocos2dx_gui_PageView_removePageAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPages", js_cocos2dx_gui_PageView_getPages, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllPages", js_cocos2dx_gui_PageView_removeAllPages, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addPage", js_cocos2dx_gui_PageView_addPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_gui_PageView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_PageView_prototype = JS_InitClass( cx, global, jsb_cocos2d_gui_Layout_prototype, jsb_cocos2d_gui_PageView_class, js_cocos2dx_gui_PageView_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "PageView", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_PageView_class; p->proto = jsb_cocos2d_gui_PageView_prototype; p->parentProto = jsb_cocos2d_gui_Layout_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_gui_Helper_class; JSObject *jsb_cocos2d_gui_Helper_prototype; JSBool js_cocos2dx_gui_Helper_seekActionWidgetByActionTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::gui::Widget* arg0; int arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Helper_seekActionWidgetByActionTag : Error processing arguments"); cocos2d::gui::Widget* ret = cocos2d::gui::Helper::seekActionWidgetByActionTag(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Helper_seekActionWidgetByActionTag : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Helper_seekWidgetByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::gui::Widget* arg0; int arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Helper_seekWidgetByTag : Error processing arguments"); cocos2d::gui::Widget* ret = cocos2d::gui::Helper::seekWidgetByTag(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Helper_seekWidgetByTag : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Helper_seekWidgetByRelativeName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::gui::Widget* arg0; const char* arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Helper_seekWidgetByRelativeName : Error processing arguments"); cocos2d::gui::Widget* ret = cocos2d::gui::Helper::seekWidgetByRelativeName(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Helper_seekWidgetByRelativeName : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_gui_Helper_seekWidgetByName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::gui::Widget* arg0; const char* arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::gui::Widget*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_gui_Helper_seekWidgetByName : Error processing arguments"); cocos2d::gui::Widget* ret = cocos2d::gui::Helper::seekWidgetByName(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_gui_Helper_seekWidgetByName : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_gui_Helper_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Helper)", obj); } void js_register_cocos2dx_gui_Helper(JSContext *cx, JSObject *global) { jsb_cocos2d_gui_Helper_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_gui_Helper_class->name = "Helper"; jsb_cocos2d_gui_Helper_class->addProperty = JS_PropertyStub; jsb_cocos2d_gui_Helper_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_gui_Helper_class->getProperty = JS_PropertyStub; jsb_cocos2d_gui_Helper_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_gui_Helper_class->enumerate = JS_EnumerateStub; jsb_cocos2d_gui_Helper_class->resolve = JS_ResolveStub; jsb_cocos2d_gui_Helper_class->convert = JS_ConvertStub; jsb_cocos2d_gui_Helper_class->finalize = js_cocos2d_gui_Helper_finalize; jsb_cocos2d_gui_Helper_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("seekActionWidgetByActionTag", js_cocos2dx_gui_Helper_seekActionWidgetByActionTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("seekWidgetByTag", js_cocos2dx_gui_Helper_seekWidgetByTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("seekWidgetByRelativeName", js_cocos2dx_gui_Helper_seekWidgetByRelativeName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("seekWidgetByName", js_cocos2dx_gui_Helper_seekWidgetByName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_gui_Helper_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_gui_Helper_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Helper", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_gui_Helper_class; p->proto = jsb_cocos2d_gui_Helper_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "ccui", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "ccui", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; js_register_cocos2dx_gui_Widget(cx, obj); js_register_cocos2dx_gui_Layout(cx, obj); js_register_cocos2dx_gui_PageView(cx, obj); js_register_cocos2dx_gui_CheckBox(cx, obj); js_register_cocos2dx_gui_Helper(cx, obj); js_register_cocos2dx_gui_Text(cx, obj); js_register_cocos2dx_gui_Button(cx, obj); js_register_cocos2dx_gui_LayoutParameter(cx, obj); js_register_cocos2dx_gui_LinearLayoutParameter(cx, obj); js_register_cocos2dx_gui_TextBMFont(cx, obj); js_register_cocos2dx_gui_ScrollView(cx, obj); js_register_cocos2dx_gui_LoadingBar(cx, obj); js_register_cocos2dx_gui_Slider(cx, obj); js_register_cocos2dx_gui_RelativeLayoutParameter(cx, obj); js_register_cocos2dx_gui_ImageView(cx, obj); js_register_cocos2dx_gui_TextAtlas(cx, obj); js_register_cocos2dx_gui_TextField(cx, obj); js_register_cocos2dx_gui_ListView(cx, obj); } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_gui_auto.hpp ================================================ #ifndef __cocos2dx_gui_h__ #define __cocos2dx_gui_h__ #include "jsapi.h" #include "jsfriendapi.h" extern JSClass *jsb_cocos2d_gui_LayoutParameter_class; extern JSObject *jsb_cocos2d_gui_LayoutParameter_prototype; JSBool js_cocos2dx_gui_LayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_LayoutParameter_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_LayoutParameter(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_LayoutParameter_getLayoutType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LayoutParameter_LayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_LinearLayoutParameter_class; extern JSObject *jsb_cocos2d_gui_LinearLayoutParameter_prototype; JSBool js_cocos2dx_gui_LinearLayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_LinearLayoutParameter_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_LinearLayoutParameter(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_LinearLayoutParameter_setGravity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LinearLayoutParameter_getGravity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LinearLayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LinearLayoutParameter_LinearLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_RelativeLayoutParameter_class; extern JSObject *jsb_cocos2d_gui_RelativeLayoutParameter_prototype; JSBool js_cocos2dx_gui_RelativeLayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_RelativeLayoutParameter_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_RelativeLayoutParameter(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_RelativeLayoutParameter_setAlign(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_RelativeLayoutParameter_getRelativeName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_RelativeLayoutParameter_setRelativeName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_RelativeLayoutParameter_getAlign(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_RelativeLayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_RelativeLayoutParameter_RelativeLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_Widget_class; extern JSObject *jsb_cocos2d_gui_Widget_prototype; JSBool js_cocos2dx_gui_Widget_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_Widget_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_Widget(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_Widget_getVirtualRenderer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setSizePercent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setActionTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getNodeByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_isFlipY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getTouchEndPos(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setPositionPercent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getNodes(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setPositionType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_updateSizeAndPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getBottomInParent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getActionTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getPositionType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getChildByName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_isFlipX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_removeNodeByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getContentSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getTouchStartPos(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setFocused(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_clone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getTouchMovePos(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setBrightStyle(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_addNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setFlipY(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setFlipX(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getLeftInParent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_ignoreContentAdaptWithSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_isBright(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_clippingParentAreaContainPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getSizePercent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getTopInParent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getWidgetType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getRightInParent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getSizeType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_removeNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_removeAllNodes(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getWorldPosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_getPositionPercent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_isFocused(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setSizeType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_checkChildInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_setBright(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Widget_Widget(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_Layout_class; extern JSObject *jsb_cocos2d_gui_Layout_prototype; JSBool js_cocos2dx_gui_Layout_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_Layout_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_Layout(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_Layout_setBackGroundColorVector(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_hitTest(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_getBackGroundImageTextureSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_getLayoutType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setClippingType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setBackGroundColorType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setBackGroundColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_requestDoLayout(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_isClippingEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setBackGroundColorOpacity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setBackGroundImageCapInsets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_removeBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setClippingEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_setLayoutType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Layout_Layout(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_Button_class; extern JSObject *jsb_cocos2d_gui_Button_prototype; JSBool js_cocos2dx_gui_Button_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_Button_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_Button(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_Button_getTitleText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_loadTextureNormal(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setCapInsetsNormalRenderer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setCapInsetsPressedRenderer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_loadTexturePressed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setCapInsetsDisabledRenderer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setTitleFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_getTitleColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_loadTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_getTitleFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setPressedActionEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_loadTextures(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_getTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setTitleText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_setTitleColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Button_Button(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_CheckBox_class; extern JSObject *jsb_cocos2d_gui_CheckBox_prototype; JSBool js_cocos2dx_gui_CheckBox_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_CheckBox_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_CheckBox(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_CheckBox_getSelectedState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_loadTextureFrontCross(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_loadTextures(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_loadTextureBackGround(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_setSelectedState(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_CheckBox_CheckBox(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_ImageView_class; extern JSObject *jsb_cocos2d_gui_ImageView_prototype; JSBool js_cocos2dx_gui_ImageView_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_ImageView_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_ImageView(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_ImageView_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ImageView_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ImageView_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ImageView_loadTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ImageView_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ImageView_ImageView(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_Text_class; extern JSObject *jsb_cocos2d_gui_Text_prototype; JSBool js_cocos2dx_gui_Text_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_Text_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_Text(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_Text_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_setFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_setTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_getStringValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_setText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_isTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_setTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Text_Text(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_TextAtlas_class; extern JSObject *jsb_cocos2d_gui_TextAtlas_prototype; JSBool js_cocos2dx_gui_TextAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_TextAtlas_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_TextAtlas(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_TextAtlas_setProperty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextAtlas_getStringValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextAtlas_setStringValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextAtlas_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextAtlas_TextAtlas(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_LoadingBar_class; extern JSObject *jsb_cocos2d_gui_LoadingBar_prototype; JSBool js_cocos2dx_gui_LoadingBar_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_LoadingBar_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_LoadingBar(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_LoadingBar_setPercent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LoadingBar_loadTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LoadingBar_setDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LoadingBar_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LoadingBar_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LoadingBar_getDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LoadingBar_getPercent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LoadingBar_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_LoadingBar_LoadingBar(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_ScrollView_class; extern JSObject *jsb_cocos2d_gui_ScrollView_prototype; JSBool js_cocos2dx_gui_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_ScrollView_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_ScrollView(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_ScrollView_scrollToTop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToPercentHorizontal(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_isInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToPercentBothDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_getDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToBottomLeft(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_getInnerContainer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToBottom(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_setDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToTopLeft(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToTopRight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToBottomLeft(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_setInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_getInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_isBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_setInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToTopLeft(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToPercentHorizontal(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToBottomRight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_setBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToTop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToLeft(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToPercentBothDirection(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToBottom(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToBottomRight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToLeft(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToRight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_jumpToRight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_scrollToTopRight(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ScrollView_ScrollView(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_ListView_class; extern JSObject *jsb_cocos2d_gui_ListView_prototype; JSBool js_cocos2dx_gui_ListView_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_ListView_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_ListView(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_ListView_getIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_removeAllItems(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_setGravity(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_pushBackCustomItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_getItems(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_removeItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_getCurSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_insertDefaultItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_setItemsMargin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_removeLastItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_getItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_setItemModel(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_requestRefreshView(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_pushBackDefaultItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_insertCustomItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_ListView_ListView(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_Slider_class; extern JSObject *jsb_cocos2d_gui_Slider_prototype; JSBool js_cocos2dx_gui_Slider_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_Slider_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_Slider(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_Slider_setPercent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_loadSlidBallTextureNormal(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_loadProgressBarTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_loadSlidBallTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_getPercent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Slider_Slider(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_TextField_class; extern JSObject *jsb_cocos2d_gui_TextField_prototype; JSBool js_cocos2dx_gui_TextField_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_TextField_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_TextField(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_TextField_setAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_getStringValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setPasswordStyleText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_getAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setFontName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_getInsertText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setInsertText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_getDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_attachWithIME(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_getDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_isPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_isMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setTouchSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_setDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextField_TextField(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_TextBMFont_class; extern JSObject *jsb_cocos2d_gui_TextBMFont_prototype; JSBool js_cocos2dx_gui_TextBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_TextBMFont_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_TextBMFont(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_TextBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextBMFont_getStringValue(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextBMFont_setText(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextBMFont_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_TextBMFont_TextBMFont(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_PageView_class; extern JSObject *jsb_cocos2d_gui_PageView_prototype; JSBool js_cocos2dx_gui_PageView_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_PageView_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_PageView(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_PageView_getCurPageIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_addWidgetToPage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_getPage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_removePageAtIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_getPages(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_removeAllPages(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_addPage(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_PageView_PageView(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_gui_Helper_class; extern JSObject *jsb_cocos2d_gui_Helper_prototype; JSBool js_cocos2dx_gui_Helper_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_gui_Helper_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_gui_Helper(JSContext *cx, JSObject *global); void register_all_cocos2dx_gui(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_gui_Helper_seekActionWidgetByActionTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Helper_seekWidgetByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Helper_seekWidgetByRelativeName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_gui_Helper_seekWidgetByName(JSContext *cx, uint32_t argc, jsval *vp); #endif ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_gui_auto_api.js ================================================ /** * @module cocos2dx_gui */ var ccui = ccui || {}; /** * @class LayoutParameter */ ccui.LayoutParameter = { /** * @method getLayoutType * @return A value converted from C/C++ "cocos2d::gui::LayoutParameterType" */ getLayoutType : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::LayoutParameter*" */ create : function () {}, /** * @method LayoutParameter * @constructor */ LayoutParameter : function () {}, }; /** * @class LinearLayoutParameter */ ccui.LinearLayoutParameter = { /** * @method setGravity * @param {cocos2d::gui::LinearGravity} */ setGravity : function () {}, /** * @method getGravity * @return A value converted from C/C++ "cocos2d::gui::LinearGravity" */ getGravity : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::LinearLayoutParameter*" */ create : function () {}, /** * @method LinearLayoutParameter * @constructor */ LinearLayoutParameter : function () {}, }; /** * @class RelativeLayoutParameter */ ccui.RelativeLayoutParameter = { /** * @method setAlign * @param {cocos2d::gui::RelativeAlign} */ setAlign : function () {}, /** * @method setRelativeToWidgetName * @param {const char*} */ setRelativeToWidgetName : function () {}, /** * @method getRelativeName * @return A value converted from C/C++ "const char*" */ getRelativeName : function () {}, /** * @method getRelativeToWidgetName * @return A value converted from C/C++ "const char*" */ getRelativeToWidgetName : function () {}, /** * @method setRelativeName * @param {const char*} */ setRelativeName : function () {}, /** * @method getAlign * @return A value converted from C/C++ "cocos2d::gui::RelativeAlign" */ getAlign : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::RelativeLayoutParameter*" */ create : function () {}, /** * @method RelativeLayoutParameter * @constructor */ RelativeLayoutParameter : function () {}, }; /** * @class Widget */ ccui.Widget = { /** * @method getVirtualRenderer * @return A value converted from C/C++ "cocos2d::Node*" */ getVirtualRenderer : function () {}, /** * @method setSizePercent * @param {const cocos2d::Point&} */ setSizePercent : function () {}, /** * @method setActionTag * @param {int} */ setActionTag : function () {}, /** * @method getNodeByTag * @return A value converted from C/C++ "cocos2d::Node*" * @param {int} */ getNodeByTag : function () {}, /** * @method isFlipY * @return A value converted from C/C++ "bool" */ isFlipY : function () {}, /** * @method getTouchEndPos * @return A value converted from C/C++ "const cocos2d::Point&" */ getTouchEndPos : function () {}, /** * @method setPositionPercent * @param {const cocos2d::Point&} */ setPositionPercent : function () {}, /** * @method getNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getNodes : function () {}, /** * @method setPositionType * @param {cocos2d::gui::PositionType} */ setPositionType : function () {}, /** * @method getName * @return A value converted from C/C++ "const char*" */ getName : function () {}, /** * @method isIgnoreContentAdaptWithSize * @return A value converted from C/C++ "bool" */ isIgnoreContentAdaptWithSize : function () {}, /** * @method updateSizeAndPosition */ updateSizeAndPosition : function () {}, /** * @method getBottomInParent * @return A value converted from C/C++ "float" */ getBottomInParent : function () {}, /** * @method getActionTag * @return A value converted from C/C++ "int" */ getActionTag : function () {}, /** * @method getLayoutParameter * @return A value converted from C/C++ "cocos2d::gui::LayoutParameter*" * @param {cocos2d::gui::LayoutParameterType} */ getLayoutParameter : function () {}, /** * @method getPositionType * @return A value converted from C/C++ "cocos2d::gui::PositionType" */ getPositionType : function () {}, /** * @method setName * @param {const char*} */ setName : function () {}, /** * @method getChildByName * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {const char*} */ getChildByName : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method isFlipX * @return A value converted from C/C++ "bool" */ isFlipX : function () {}, /** * @method removeNodeByTag * @param {int} */ removeNodeByTag : function () {}, /** * @method isTouchEnabled * @return A value converted from C/C++ "bool" */ isTouchEnabled : function () {}, /** * @method getContentSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getContentSize : function () {}, /** * @method getTouchStartPos * @return A value converted from C/C++ "const cocos2d::Point&" */ getTouchStartPos : function () {}, /** * @method didNotSelectSelf */ didNotSelectSelf : function () {}, /** * @method setFocused * @param {bool} */ setFocused : function () {}, /** * @method setTouchEnabled * @param {bool} */ setTouchEnabled : function () {}, /** * @method clone * @return A value converted from C/C++ "cocos2d::gui::Widget*" */ clone : function () {}, /** * @method getTouchMovePos * @return A value converted from C/C++ "const cocos2d::Point&" */ getTouchMovePos : function () {}, /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method setBrightStyle * @param {cocos2d::gui::BrightStyle} */ setBrightStyle : function () {}, /** * @method setLayoutParameter * @param {cocos2d::gui::LayoutParameter*} */ setLayoutParameter : function () {}, /** * @method setFlipY * @param {bool} */ setFlipY : function () {}, /** * @method setFlipX * @param {bool} */ setFlipX : function () {}, /** * @method getLeftInParent * @return A value converted from C/C++ "float" */ getLeftInParent : function () {}, /** * @method ignoreContentAdaptWithSize * @param {bool} */ ignoreContentAdaptWithSize : function () {}, /** * @method isBright * @return A value converted from C/C++ "bool" */ isBright : function () {}, /** * @method clippingParentAreaContainPoint * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} */ clippingParentAreaContainPoint : function () {}, /** * @method getSizePercent * @return A value converted from C/C++ "const cocos2d::Point&" */ getSizePercent : function () {}, /** * @method getTopInParent * @return A value converted from C/C++ "float" */ getTopInParent : function () {}, /** * @method getWidgetType * @return A value converted from C/C++ "cocos2d::gui::WidgetType" */ getWidgetType : function () {}, /** * @method getSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getSize : function () {}, /** * @method getRightInParent * @return A value converted from C/C++ "float" */ getRightInParent : function () {}, /** * @method getSizeType * @return A value converted from C/C++ "cocos2d::gui::SizeType" */ getSizeType : function () {}, /** * @method removeNode * @param {cocos2d::Node*} */ removeNode : function () {}, /** * @method removeAllNodes */ removeAllNodes : function () {}, /** * @method getWorldPosition * @return A value converted from C/C++ "cocos2d::Point" */ getWorldPosition : function () {}, /** * @method getPositionPercent * @return A value converted from C/C++ "const cocos2d::Point&" */ getPositionPercent : function () {}, /** * @method hitTest * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} */ hitTest : function () {}, /** * @method isFocused * @return A value converted from C/C++ "bool" */ isFocused : function () {}, /** * @method setSizeType * @param {cocos2d::gui::SizeType} */ setSizeType : function () {}, /** * @method checkChildInfo * @param {int} * @param {cocos2d::gui::Widget*} * @param {const cocos2d::Point&} */ checkChildInfo : function () {}, /** * @method setSize * @param {const cocos2d::Size&} */ setSize : function () {}, /** * @method setBright * @param {bool} */ setBright : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Widget*" */ create : function () {}, /** * @method Widget * @constructor */ Widget : function () {}, }; /** * @class Layout */ ccui.Layout = { /** * @method setBackGroundColorVector * @param {const cocos2d::Point&} */ setBackGroundColorVector : function () {}, /** * @method hitTest * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} */ hitTest : function () {}, /** * @method getBackGroundImageTextureSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getBackGroundImageTextureSize : function () {}, /** * @method getLayoutType * @return A value converted from C/C++ "cocos2d::gui::LayoutType" */ getLayoutType : function () {}, /** * @method setClippingType * @param {cocos2d::gui::LayoutClippingType} */ setClippingType : function () {}, /** * @method setBackGroundColorType * @param {cocos2d::gui::LayoutBackGroundColorType} */ setBackGroundColorType : function () {}, /** * @method setBackGroundImage * @param {const char*} * @param {cocos2d::gui::TextureResType} */ setBackGroundImage : function () {}, /** * @method requestDoLayout */ requestDoLayout : function () {}, /** * @method isClippingEnabled * @return A value converted from C/C++ "bool" */ isClippingEnabled : function () {}, /** * @method setBackGroundColorOpacity * @param {int} */ setBackGroundColorOpacity : function () {}, /** * @method setBackGroundImageCapInsets * @param {const cocos2d::Rect&} */ setBackGroundImageCapInsets : function () {}, /** * @method removeBackGroundImage */ removeBackGroundImage : function () {}, /** * @method setBackGroundImageScale9Enabled * @param {bool} */ setBackGroundImageScale9Enabled : function () {}, /** * @method setClippingEnabled * @param {bool} */ setClippingEnabled : function () {}, /** * @method setLayoutType * @param {cocos2d::gui::LayoutType} */ setLayoutType : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Layout*" */ create : function () {}, /** * @method Layout * @constructor */ Layout : function () {}, }; /** * @class Button */ ccui.Button = { /** * @method getTitleText * @return A value converted from C/C++ "const std::string&" */ getTitleText : function () {}, /** * @method loadTextureNormal * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureNormal : function () {}, /** * @method setCapInsetsNormalRenderer * @param {const cocos2d::Rect&} */ setCapInsetsNormalRenderer : function () {}, /** * @method setCapInsetsPressedRenderer * @param {const cocos2d::Rect&} */ setCapInsetsPressedRenderer : function () {}, /** * @method loadTexturePressed * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTexturePressed : function () {}, /** * @method setTitleFontSize * @param {float} */ setTitleFontSize : function () {}, /** * @method setCapInsetsDisabledRenderer * @param {const cocos2d::Rect&} */ setCapInsetsDisabledRenderer : function () {}, /** * @method setTitleFontName * @param {const char*} */ setTitleFontName : function () {}, /** * @method getTitleColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getTitleColor : function () {}, /** * @method loadTextureDisabled * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureDisabled : function () {}, /** * @method getTitleFontName * @return A value converted from C/C++ "const char*" */ getTitleFontName : function () {}, /** * @method setPressedActionEnabled * @param {bool} */ setPressedActionEnabled : function () {}, /** * @method setCapInsets * @param {const cocos2d::Rect&} */ setCapInsets : function () {}, /** * @method setScale9Enabled * @param {bool} */ setScale9Enabled : function () {}, /** * @method loadTextures * @param {const char*} * @param {const char*} * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextures : function () {}, /** * @method getTitleFontSize * @return A value converted from C/C++ "float" */ getTitleFontSize : function () {}, /** * @method setTitleText * @param {const std::string&} */ setTitleText : function () {}, /** * @method setTitleColor * @param {const cocos2d::Color3B&} */ setTitleColor : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Button*" */ create : function () {}, /** * @method Button * @constructor */ Button : function () {}, }; /** * @class CheckBox */ ccui.CheckBox = { /** * @method getSelectedState * @return A value converted from C/C++ "bool" */ getSelectedState : function () {}, /** * @method loadTextureBackGroundSelected * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureBackGroundSelected : function () {}, /** * @method loadTextureBackGroundDisabled * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureBackGroundDisabled : function () {}, /** * @method loadTextureFrontCross * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureFrontCross : function () {}, /** * @method loadTextures * @param {const char*} * @param {const char*} * @param {const char*} * @param {const char*} * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextures : function () {}, /** * @method loadTextureBackGround * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureBackGround : function () {}, /** * @method setSelectedState * @param {bool} */ setSelectedState : function () {}, /** * @method loadTextureFrontCrossDisabled * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureFrontCrossDisabled : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::CheckBox*" */ create : function () {}, /** * @method CheckBox * @constructor */ CheckBox : function () {}, }; /** * @class ImageView */ ccui.ImageView = { /** * @method setTextureRect * @param {const cocos2d::Rect&} */ setTextureRect : function () {}, /** * @method setCapInsets * @param {const cocos2d::Rect&} */ setCapInsets : function () {}, /** * @method setScale9Enabled * @param {bool} */ setScale9Enabled : function () {}, /** * @method loadTexture * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTexture : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::ImageView*" */ create : function () {}, /** * @method ImageView * @constructor */ ImageView : function () {}, }; /** * @class Text */ ccui.Text = { /** * @method getStringLength * @return A value converted from C/C++ "ssize_t" */ getStringLength : function () {}, /** * @method setFontName * @param {const std::string&} */ setFontName : function () {}, /** * @method setTouchScaleChangeEnabled * @param {bool} */ setTouchScaleChangeEnabled : function () {}, /** * @method getStringValue * @return A value converted from C/C++ "const std::string&" */ getStringValue : function () {}, /** * @method setText * @param {const std::string&} */ setText : function () {}, /** * @method setTextVerticalAlignment * @param {cocos2d::TextVAlignment} */ setTextVerticalAlignment : function () {}, /** * @method setFontSize * @param {int} */ setFontSize : function () {}, /** * @method isTouchScaleChangeEnabled * @return A value converted from C/C++ "bool" */ isTouchScaleChangeEnabled : function () {}, /** * @method setTextHorizontalAlignment * @param {cocos2d::TextHAlignment} */ setTextHorizontalAlignment : function () {}, /** * @method setTextAreaSize * @param {const cocos2d::Size&} */ setTextAreaSize : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Text*" */ create : function () {}, /** * @method Text * @constructor */ Text : function () {}, }; /** * @class TextAtlas */ ccui.TextAtlas = { /** * @method setProperty * @param {const std::string&} * @param {const std::string&} * @param {int} * @param {int} * @param {const std::string&} */ setProperty : function () {}, /** * @method getStringValue * @return A value converted from C/C++ "const std::string&" */ getStringValue : function () {}, /** * @method setStringValue * @param {const std::string&} */ setStringValue : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::TextAtlas*" */ create : function () {}, /** * @method TextAtlas * @constructor */ TextAtlas : function () {}, }; /** * @class LoadingBar */ ccui.LoadingBar = { /** * @method setPercent * @param {int} */ setPercent : function () {}, /** * @method loadTexture * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTexture : function () {}, /** * @method setDirection * @param {cocos2d::gui::LoadingBarType} */ setDirection : function () {}, /** * @method setScale9Enabled * @param {bool} */ setScale9Enabled : function () {}, /** * @method setCapInsets * @param {const cocos2d::Rect&} */ setCapInsets : function () {}, /** * @method getDirection * @return A value converted from C/C++ "int" */ getDirection : function () {}, /** * @method getPercent * @return A value converted from C/C++ "int" */ getPercent : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::LoadingBar*" */ create : function () {}, /** * @method LoadingBar * @constructor */ LoadingBar : function () {}, }; /** * @class ScrollView */ ccui.ScrollView = { /** * @method scrollToTop * @param {float} * @param {bool} */ scrollToTop : function () {}, /** * @method scrollToPercentHorizontal * @param {float} * @param {float} * @param {bool} */ scrollToPercentHorizontal : function () {}, /** * @method isInertiaScrollEnabled * @return A value converted from C/C++ "bool" */ isInertiaScrollEnabled : function () {}, /** * @method scrollToPercentBothDirection * @param {const cocos2d::Point&} * @param {float} * @param {bool} */ scrollToPercentBothDirection : function () {}, /** * @method getDirection * @return A value converted from C/C++ "cocos2d::gui::SCROLLVIEW_DIR" */ getDirection : function () {}, /** * @method scrollToBottomLeft * @param {float} * @param {bool} */ scrollToBottomLeft : function () {}, /** * @method getInnerContainer * @return A value converted from C/C++ "cocos2d::gui::Layout*" */ getInnerContainer : function () {}, /** * @method jumpToBottom */ jumpToBottom : function () {}, /** * @method setDirection * @param {cocos2d::gui::SCROLLVIEW_DIR} */ setDirection : function () {}, /** * @method scrollToTopLeft * @param {float} * @param {bool} */ scrollToTopLeft : function () {}, /** * @method jumpToTopRight */ jumpToTopRight : function () {}, /** * @method jumpToBottomLeft */ jumpToBottomLeft : function () {}, /** * @method setInnerContainerSize * @param {const cocos2d::Size&} */ setInnerContainerSize : function () {}, /** * @method getInnerContainerSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getInnerContainerSize : function () {}, /** * @method isBounceEnabled * @return A value converted from C/C++ "bool" */ isBounceEnabled : function () {}, /** * @method jumpToPercentVertical * @param {float} */ jumpToPercentVertical : function () {}, /** * @method setInertiaScrollEnabled * @param {bool} */ setInertiaScrollEnabled : function () {}, /** * @method jumpToTopLeft */ jumpToTopLeft : function () {}, /** * @method jumpToPercentHorizontal * @param {float} */ jumpToPercentHorizontal : function () {}, /** * @method jumpToBottomRight */ jumpToBottomRight : function () {}, /** * @method setBounceEnabled * @param {bool} */ setBounceEnabled : function () {}, /** * @method jumpToTop */ jumpToTop : function () {}, /** * @method scrollToLeft * @param {float} * @param {bool} */ scrollToLeft : function () {}, /** * @method jumpToPercentBothDirection * @param {const cocos2d::Point&} */ jumpToPercentBothDirection : function () {}, /** * @method scrollToPercentVertical * @param {float} * @param {float} * @param {bool} */ scrollToPercentVertical : function () {}, /** * @method scrollToBottom * @param {float} * @param {bool} */ scrollToBottom : function () {}, /** * @method scrollToBottomRight * @param {float} * @param {bool} */ scrollToBottomRight : function () {}, /** * @method jumpToLeft */ jumpToLeft : function () {}, /** * @method scrollToRight * @param {float} * @param {bool} */ scrollToRight : function () {}, /** * @method jumpToRight */ jumpToRight : function () {}, /** * @method scrollToTopRight * @param {float} * @param {bool} */ scrollToTopRight : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::ScrollView*" */ create : function () {}, /** * @method ScrollView * @constructor */ ScrollView : function () {}, }; /** * @class ListView */ ccui.ListView = { /** * @method getIndex * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::gui::Widget*} */ getIndex : function () {}, /** * @method removeAllItems */ removeAllItems : function () {}, /** * @method setGravity * @param {cocos2d::gui::ListViewGravity} */ setGravity : function () {}, /** * @method pushBackCustomItem * @param {cocos2d::gui::Widget*} */ pushBackCustomItem : function () {}, /** * @method getItems * @return A value converted from C/C++ "cocos2d::Vector&" */ getItems : function () {}, /** * @method removeItem * @param {ssize_t} */ removeItem : function () {}, /** * @method getCurSelectedIndex * @return A value converted from C/C++ "ssize_t" */ getCurSelectedIndex : function () {}, /** * @method insertDefaultItem * @param {ssize_t} */ insertDefaultItem : function () {}, /** * @method setItemsMargin * @param {float} */ setItemsMargin : function () {}, /** * @method removeLastItem */ removeLastItem : function () {}, /** * @method getItem * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {ssize_t} */ getItem : function () {}, /** * @method setItemModel * @param {cocos2d::gui::Widget*} */ setItemModel : function () {}, /** * @method requestRefreshView */ requestRefreshView : function () {}, /** * @method pushBackDefaultItem */ pushBackDefaultItem : function () {}, /** * @method insertCustomItem * @param {cocos2d::gui::Widget*} * @param {ssize_t} */ insertCustomItem : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::ListView*" */ create : function () {}, /** * @method ListView * @constructor */ ListView : function () {}, }; /** * @class Slider */ ccui.Slider = { /** * @method setPercent * @param {int} */ setPercent : function () {}, /** * @method loadSlidBallTextureNormal * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadSlidBallTextureNormal : function () {}, /** * @method loadBarTexture * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadBarTexture : function () {}, /** * @method loadProgressBarTexture * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadProgressBarTexture : function () {}, /** * @method loadSlidBallTextures * @param {const char*} * @param {const char*} * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadSlidBallTextures : function () {}, /** * @method setCapInsetProgressBarRebderer * @param {const cocos2d::Rect&} */ setCapInsetProgressBarRebderer : function () {}, /** * @method setCapInsetsBarRenderer * @param {const cocos2d::Rect&} */ setCapInsetsBarRenderer : function () {}, /** * @method setScale9Enabled * @param {bool} */ setScale9Enabled : function () {}, /** * @method setCapInsets * @param {const cocos2d::Rect&} */ setCapInsets : function () {}, /** * @method loadSlidBallTexturePressed * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadSlidBallTexturePressed : function () {}, /** * @method loadSlidBallTextureDisabled * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadSlidBallTextureDisabled : function () {}, /** * @method getPercent * @return A value converted from C/C++ "int" */ getPercent : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Slider*" */ create : function () {}, /** * @method Slider * @constructor */ Slider : function () {}, }; /** * @class TextField */ ccui.TextField = { /** * @method setAttachWithIME * @param {bool} */ setAttachWithIME : function () {}, /** * @method getStringValue * @return A value converted from C/C++ "const std::string&" */ getStringValue : function () {}, /** * @method setPasswordStyleText * @param {const char*} */ setPasswordStyleText : function () {}, /** * @method getAttachWithIME * @return A value converted from C/C++ "bool" */ getAttachWithIME : function () {}, /** * @method setFontName * @param {const std::string&} */ setFontName : function () {}, /** * @method getInsertText * @return A value converted from C/C++ "bool" */ getInsertText : function () {}, /** * @method setInsertText * @param {bool} */ setInsertText : function () {}, /** * @method getDetachWithIME * @return A value converted from C/C++ "bool" */ getDetachWithIME : function () {}, /** * @method didNotSelectSelf */ didNotSelectSelf : function () {}, /** * @method attachWithIME */ attachWithIME : function () {}, /** * @method setPasswordEnabled * @param {bool} */ setPasswordEnabled : function () {}, /** * @method setMaxLengthEnabled * @param {bool} */ setMaxLengthEnabled : function () {}, /** * @method getDeleteBackward * @return A value converted from C/C++ "bool" */ getDeleteBackward : function () {}, /** * @method setFontSize * @param {int} */ setFontSize : function () {}, /** * @method setPlaceHolder * @param {const std::string&} */ setPlaceHolder : function () {}, /** * @method isPasswordEnabled * @return A value converted from C/C++ "bool" */ isPasswordEnabled : function () {}, /** * @method getMaxLength * @return A value converted from C/C++ "int" */ getMaxLength : function () {}, /** * @method isMaxLengthEnabled * @return A value converted from C/C++ "bool" */ isMaxLengthEnabled : function () {}, /** * @method setDetachWithIME * @param {bool} */ setDetachWithIME : function () {}, /** * @method setText * @param {const std::string&} */ setText : function () {}, /** * @method setMaxLength * @param {int} */ setMaxLength : function () {}, /** * @method setTouchSize * @param {const cocos2d::Size&} */ setTouchSize : function () {}, /** * @method setDeleteBackward * @param {bool} */ setDeleteBackward : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::TextField*" */ create : function () {}, /** * @method TextField * @constructor */ TextField : function () {}, }; /** * @class TextBMFont */ ccui.TextBMFont = { /** * @method setFntFile * @param {const char*} */ setFntFile : function () {}, /** * @method getStringValue * @return A value converted from C/C++ "const char*" */ getStringValue : function () {}, /** * @method setText * @param {const char*} */ setText : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::TextBMFont*" */ create : function () {}, /** * @method TextBMFont * @constructor */ TextBMFont : function () {}, }; /** * @class PageView */ ccui.PageView = { /** * @method getCurPageIndex * @return A value converted from C/C++ "ssize_t" */ getCurPageIndex : function () {}, /** * @method addWidgetToPage * @param {cocos2d::gui::Widget*} * @param {ssize_t} * @param {bool} */ addWidgetToPage : function () {}, /** * @method getPage * @return A value converted from C/C++ "cocos2d::gui::Layout*" * @param {ssize_t} */ getPage : function () {}, /** * @method removePage * @param {cocos2d::gui::Layout*} */ removePage : function () {}, /** * @method insertPage * @param {cocos2d::gui::Layout*} * @param {int} */ insertPage : function () {}, /** * @method scrollToPage * @param {ssize_t} */ scrollToPage : function () {}, /** * @method removePageAtIndex * @param {ssize_t} */ removePageAtIndex : function () {}, /** * @method getPages * @return A value converted from C/C++ "cocos2d::Vector&" */ getPages : function () {}, /** * @method removeAllPages */ removeAllPages : function () {}, /** * @method addPage * @param {cocos2d::gui::Layout*} */ addPage : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::PageView*" */ create : function () {}, /** * @method PageView * @constructor */ PageView : function () {}, }; /** * @class Helper */ ccui.Helper = { /** * @method seekActionWidgetByActionTag * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {cocos2d::gui::Widget*} * @param {int} */ seekActionWidgetByActionTag : function () {}, /** * @method seekWidgetByTag * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {cocos2d::gui::Widget*} * @param {int} */ seekWidgetByTag : function () {}, /** * @method seekWidgetByRelativeName * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {cocos2d::gui::Widget*} * @param {const char*} */ seekWidgetByRelativeName : function () {}, /** * @method seekWidgetByName * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {cocos2d::gui::Widget*} * @param {const char*} */ seekWidgetByName : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_spine_auto.cpp ================================================ #include "jsb_cocos2dx_spine_auto.hpp" #include "cocos2d_specifics.hpp" #include "spine-cocos2dx.h" template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedValue initializing(cx); JSBool isNewValid = JS_TRUE; JSObject* global = ScriptingCore::getInstance()->getGlobalObject(); isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && JSVAL_TO_BOOLEAN(initializing); if (isNewValid) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); return JS_TRUE; } JS_ReportError(cx, "Don't use `new cc.XXX`, please use `cc.XXX.create` instead! "); return JS_FALSE; } static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { return JS_FALSE; } static JSBool js_is_native_obj(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { vp.set(BOOLEAN_TO_JSVAL(JS_TRUE)); return JS_TRUE; } JSClass *jsb_spine_Skeleton_class; JSObject *jsb_spine_Skeleton_prototype; JSBool js_cocos2dx_spine_Skeleton_setToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setToSetupPose : Invalid Native Object"); if (argc == 0) { cobj->setToSetupPose(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_setToSetupPose : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setBlendFunc : Invalid Native Object"); if (argc == 1) { cocos2d::BlendFunc arg0; #pragma warning NO CONVERSION TO NATIVE FOR BlendFunc; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setBlendFunc : Error processing arguments"); cobj->setBlendFunc(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_onDraw(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_onDraw : Invalid Native Object"); if (argc == 0) { cobj->onDraw(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_onDraw : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_setSlotsToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setSlotsToSetupPose : Invalid Native Object"); if (argc == 0) { cobj->setSlotsToSetupPose(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_setSlotsToSetupPose : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_getAttachment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_getAttachment : Invalid Native Object"); if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_getAttachment : Error processing arguments"); spAttachment* ret = cobj->getAttachment(arg0, arg1); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR spAttachment*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_getAttachment : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_setAttachment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setAttachment : Invalid Native Object"); if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setAttachment : Error processing arguments"); JSBool ret = cobj->setAttachment(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_setAttachment : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_getBlendFunc : Invalid Native Object"); if (argc == 0) { const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR BlendFunc; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_setSkin(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setSkin : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setSkin : Error processing arguments"); JSBool ret = cobj->setSkin(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_setSkin : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_findSlot(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_findSlot : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_findSlot : Error processing arguments"); spSlot* ret = cobj->findSlot(arg0); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR spSlot*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_findSlot : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_updateWorldTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_updateWorldTransform : Invalid Native Object"); if (argc == 0) { cobj->updateWorldTransform(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_updateWorldTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_setBonesToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_setBonesToSetupPose : Invalid Native Object"); if (argc == 0) { cobj->setBonesToSetupPose(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_setBonesToSetupPose : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_findBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::Skeleton* cobj = (spine::Skeleton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_findBone : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_Skeleton_findBone : Error processing arguments"); spBone* ret = cobj->findBone(arg0); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR spBone*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_findBone : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_createWithFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spine::Skeleton* ret = spine::Skeleton::createWithFile(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (spine::Skeleton*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } spine::Skeleton* ret = spine::Skeleton::createWithFile(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (spine::Skeleton*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spAtlas* arg1; #pragma warning NO CONVERSION TO NATIVE FOR spAtlas*; if (!ok) { ok = JS_TRUE; break; } spine::Skeleton* ret = spine::Skeleton::createWithFile(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (spine::Skeleton*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spAtlas* arg1; #pragma warning NO CONVERSION TO NATIVE FOR spAtlas*; if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } spine::Skeleton* ret = spine::Skeleton::createWithFile(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (spine::Skeleton*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_createWithFile : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_spine_Skeleton_constructor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; spine::Skeleton* cobj = NULL; do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spAtlas* arg1; #pragma warning NO CONVERSION TO NATIVE FOR spAtlas*; if (!ok) { ok = JS_TRUE; break; } cobj = new spine::Skeleton(arg0, arg1); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::Skeleton"); } } while(0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spAtlas* arg1; #pragma warning NO CONVERSION TO NATIVE FOR spAtlas*; if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cobj = new spine::Skeleton(arg0, arg1, arg2); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::Skeleton"); } } while(0); do { if (argc == 1) { spSkeletonData* arg0; #pragma warning NO CONVERSION TO NATIVE FOR spSkeletonData*; if (!ok) { ok = JS_TRUE; break; } cobj = new spine::Skeleton(arg0); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::Skeleton"); } } while(0); do { if (argc == 2) { spSkeletonData* arg0; #pragma warning NO CONVERSION TO NATIVE FOR spSkeletonData*; if (!ok) { ok = JS_TRUE; break; } JSBool arg1; ok &= JS_ValueToBoolean(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj = new spine::Skeleton(arg0, arg1); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::Skeleton"); } } while(0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cobj = new spine::Skeleton(arg0, arg1); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::Skeleton"); } } while(0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cobj = new spine::Skeleton(arg0, arg1, arg2); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::Skeleton"); } } while(0); if (cobj) { JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_Skeleton_constructor : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_spine_Skeleton_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Skeleton)", obj); } void js_register_cocos2dx_spine_Skeleton(JSContext *cx, JSObject *global) { jsb_spine_Skeleton_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_spine_Skeleton_class->name = "Skeleton"; jsb_spine_Skeleton_class->addProperty = JS_PropertyStub; jsb_spine_Skeleton_class->delProperty = JS_DeletePropertyStub; jsb_spine_Skeleton_class->getProperty = JS_PropertyStub; jsb_spine_Skeleton_class->setProperty = JS_StrictPropertyStub; jsb_spine_Skeleton_class->enumerate = JS_EnumerateStub; jsb_spine_Skeleton_class->resolve = JS_ResolveStub; jsb_spine_Skeleton_class->convert = JS_ConvertStub; jsb_spine_Skeleton_class->finalize = js_spine_Skeleton_finalize; jsb_spine_Skeleton_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setToSetupPose", js_cocos2dx_spine_Skeleton_setToSetupPose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBlendFunc", js_cocos2dx_spine_Skeleton_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onDraw", js_cocos2dx_spine_Skeleton_onDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSlotsToSetupPose", js_cocos2dx_spine_Skeleton_setSlotsToSetupPose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAttachment", js_cocos2dx_spine_Skeleton_getAttachment, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAttachment", js_cocos2dx_spine_Skeleton_setAttachment, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBlendFunc", js_cocos2dx_spine_Skeleton_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSkin", js_cocos2dx_spine_Skeleton_setSkin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("findSlot", js_cocos2dx_spine_Skeleton_findSlot, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateWorldTransform", js_cocos2dx_spine_Skeleton_updateWorldTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBonesToSetupPose", js_cocos2dx_spine_Skeleton_setBonesToSetupPose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("findBone", js_cocos2dx_spine_Skeleton_findBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("createWithFile", js_cocos2dx_spine_Skeleton_createWithFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_spine_Skeleton_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_spine_Skeleton_class, js_cocos2dx_spine_Skeleton_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Skeleton", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_spine_Skeleton_class; p->proto = jsb_spine_Skeleton_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_spine_SkeletonAnimation_class; JSObject *jsb_spine_SkeletonAnimation_prototype; JSBool js_cocos2dx_spine_SkeletonAnimation_addAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_addAnimation : Invalid Native Object"); if (argc == 3) { int arg0; const char* arg1; JSBool arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_addAnimation : Error processing arguments"); spTrackEntry* ret = cobj->addAnimation(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 4) { int arg0; const char* arg1; JSBool arg2; double arg3; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_addAnimation : Error processing arguments"); spTrackEntry* ret = cobj->addAnimation(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_addAnimation : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_getCurrent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_getCurrent : Invalid Native Object"); if (argc == 0) { spTrackEntry* ret = cobj->getCurrent(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_getCurrent : Error processing arguments"); spTrackEntry* ret = cobj->getCurrent(arg0); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_getCurrent : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData : Invalid Native Object"); if (argc == 1) { spAnimationStateData* arg0; #pragma warning NO CONVERSION TO NATIVE FOR spAnimationStateData*; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData : Error processing arguments"); cobj->setAnimationStateData(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_update(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_update : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_update : Error processing arguments"); cobj->update(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_update : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_setMix(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_setMix : Invalid Native Object"); if (argc == 3) { const char* arg0; const char* arg1; double arg2; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_setMix : Error processing arguments"); cobj->setMix(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setMix : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_setAnimation : Invalid Native Object"); if (argc == 3) { int arg0; const char* arg1; JSBool arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_setAnimation : Error processing arguments"); spTrackEntry* ret = cobj->setAnimation(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setAnimation : wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_clearTracks(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_clearTracks : Invalid Native Object"); if (argc == 0) { cobj->clearTracks(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_clearTracks : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_clearTrack(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_clearTrack : Invalid Native Object"); if (argc == 0) { cobj->clearTrack(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_clearTrack : Error processing arguments"); cobj->clearTrack(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_clearTrack : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent : Invalid Native Object"); if (argc == 4) { int arg0; spEventType arg1; spEvent* arg2; int arg3; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); #pragma warning NO CONVERSION TO NATIVE FOR spEvent*; ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent : Error processing arguments"); cobj->onAnimationStateEvent(arg0, arg1, arg2, arg3); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent : wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_createWithFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (spine::SkeletonAnimation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (spine::SkeletonAnimation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spAtlas* arg1; #pragma warning NO CONVERSION TO NATIVE FOR spAtlas*; if (!ok) { ok = JS_TRUE; break; } spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (spine::SkeletonAnimation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spAtlas* arg1; #pragma warning NO CONVERSION TO NATIVE FOR spAtlas*; if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (spine::SkeletonAnimation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_createWithFile : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; spine::SkeletonAnimation* cobj = NULL; do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spAtlas* arg1; #pragma warning NO CONVERSION TO NATIVE FOR spAtlas*; if (!ok) { ok = JS_TRUE; break; } cobj = new spine::SkeletonAnimation(arg0, arg1); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::SkeletonAnimation"); } } while(0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } spAtlas* arg1; #pragma warning NO CONVERSION TO NATIVE FOR spAtlas*; if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cobj = new spine::SkeletonAnimation(arg0, arg1, arg2); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::SkeletonAnimation"); } } while(0); do { if (argc == 1) { spSkeletonData* arg0; #pragma warning NO CONVERSION TO NATIVE FOR spSkeletonData*; if (!ok) { ok = JS_TRUE; break; } cobj = new spine::SkeletonAnimation(arg0); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::SkeletonAnimation"); } } while(0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cobj = new spine::SkeletonAnimation(arg0, arg1); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::SkeletonAnimation"); } } while(0); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } double arg2; ok &= JS_ValueToNumber(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cobj = new spine::SkeletonAnimation(arg0, arg1, arg2); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t* proxy = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &proxy->obj, "spine::SkeletonAnimation"); } } while(0); if (cobj) { JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_constructor : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_spine_Skeleton_prototype; void js_spine_SkeletonAnimation_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SkeletonAnimation)", obj); } void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JSObject *global) { jsb_spine_SkeletonAnimation_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_spine_SkeletonAnimation_class->name = "SkeletonAnimation"; jsb_spine_SkeletonAnimation_class->addProperty = JS_PropertyStub; jsb_spine_SkeletonAnimation_class->delProperty = JS_DeletePropertyStub; jsb_spine_SkeletonAnimation_class->getProperty = JS_PropertyStub; jsb_spine_SkeletonAnimation_class->setProperty = JS_StrictPropertyStub; jsb_spine_SkeletonAnimation_class->enumerate = JS_EnumerateStub; jsb_spine_SkeletonAnimation_class->resolve = JS_ResolveStub; jsb_spine_SkeletonAnimation_class->convert = JS_ConvertStub; jsb_spine_SkeletonAnimation_class->finalize = js_spine_SkeletonAnimation_finalize; jsb_spine_SkeletonAnimation_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("addAnimation", js_cocos2dx_spine_SkeletonAnimation_addAnimation, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrent", js_cocos2dx_spine_SkeletonAnimation_getCurrent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimationStateData", js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", js_cocos2dx_spine_SkeletonAnimation_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMix", js_cocos2dx_spine_SkeletonAnimation_setMix, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimation", js_cocos2dx_spine_SkeletonAnimation_setAnimation, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clearTracks", js_cocos2dx_spine_SkeletonAnimation_clearTracks, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clearTrack", js_cocos2dx_spine_SkeletonAnimation_clearTrack, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onAnimationStateEvent", js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("createWithFile", js_cocos2dx_spine_SkeletonAnimation_createWithFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_spine_SkeletonAnimation_prototype = JS_InitClass( cx, global, jsb_spine_Skeleton_prototype, jsb_spine_SkeletonAnimation_class, js_cocos2dx_spine_SkeletonAnimation_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SkeletonAnimation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_spine_SkeletonAnimation_class; p->proto = jsb_spine_SkeletonAnimation_prototype; p->parentProto = jsb_spine_Skeleton_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } void register_all_cocos2dx_spine(JSContext* cx, JSObject* obj) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "sp", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "sp", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; js_register_cocos2dx_spine_Skeleton(cx, obj); js_register_cocos2dx_spine_SkeletonAnimation(cx, obj); } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_spine_auto.hpp ================================================ #ifndef __cocos2dx_spine_h__ #define __cocos2dx_spine_h__ #include "jsapi.h" #include "jsfriendapi.h" extern JSClass *jsb_spine_Skeleton_class; extern JSObject *jsb_spine_Skeleton_prototype; JSBool js_cocos2dx_spine_Skeleton_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_spine_Skeleton_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_spine_Skeleton(JSContext *cx, JSObject *global); void register_all_cocos2dx_spine(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_spine_Skeleton_setToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_onDraw(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_setSlotsToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_getAttachment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_setAttachment(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_setSkin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_findSlot(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_updateWorldTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_setBonesToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_findBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_createWithFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_Skeleton_Skeleton(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_spine_SkeletonAnimation_class; extern JSObject *jsb_spine_SkeletonAnimation_prototype; JSBool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_spine_SkeletonAnimation_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JSObject *global); void register_all_cocos2dx_spine(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_spine_SkeletonAnimation_addAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_getCurrent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_setAnimationStateData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_update(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_setMix(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_setAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_clearTracks(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_clearTrack(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_createWithFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_spine_SkeletonAnimation_SkeletonAnimation(JSContext *cx, uint32_t argc, jsval *vp); #endif ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_spine_auto_api.js ================================================ /** * @module cocos2dx_spine */ var sp = sp || {}; /** * @class Skeleton */ sp.Skeleton = { /** * @method setToSetupPose */ setToSetupPose : function () {}, /** * @method setBlendFunc * @param {const cocos2d::BlendFunc&} */ setBlendFunc : function () {}, /** * @method onDraw */ onDraw : function () {}, /** * @method setSlotsToSetupPose */ setSlotsToSetupPose : function () {}, /** * @method getAttachment * @return A value converted from C/C++ "spAttachment*" * @param {const char*} * @param {const char*} */ getAttachment : function () {}, /** * @method setAttachment * @return A value converted from C/C++ "bool" * @param {const char*} * @param {const char*} */ setAttachment : function () {}, /** * @method getBlendFunc * @return A value converted from C/C++ "const cocos2d::BlendFunc&" */ getBlendFunc : function () {}, /** * @method setSkin * @return A value converted from C/C++ "bool" * @param {const char*} */ setSkin : function () {}, /** * @method findSlot * @return A value converted from C/C++ "spSlot*" * @param {const char*} */ findSlot : function () {}, /** * @method updateWorldTransform */ updateWorldTransform : function () {}, /** * @method setBonesToSetupPose */ setBonesToSetupPose : function () {}, /** * @method findBone * @return A value converted from C/C++ "spBone*" * @param {const char*} */ findBone : function () {}, }; /** * @class SkeletonAnimation */ sp.SkeletonAnimation = { /** * @method addAnimation * @return A value converted from C/C++ "spTrackEntry*" * @param {int} * @param {const char*} * @param {bool} * @param {float} */ addAnimation : function () {}, /** * @method getCurrent * @return A value converted from C/C++ "spTrackEntry*" */ getCurrent : function () {}, /** * @method setAnimationStateData * @param {spAnimationStateData*} */ setAnimationStateData : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method setMix * @param {const char*} * @param {const char*} * @param {float} */ setMix : function () {}, /** * @method setAnimation * @return A value converted from C/C++ "spTrackEntry*" * @param {int} * @param {const char*} * @param {bool} */ setAnimation : function () {}, /** * @method clearTracks */ clearTracks : function () {}, /** * @method clearTrack */ clearTrack : function () {}, /** * @method onAnimationStateEvent * @param {int} * @param {spEventType} * @param {spEvent*} * @param {int} */ onAnimationStateEvent : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_studio_auto.cpp ================================================ #include "jsb_cocos2dx_studio_auto.hpp" #include "cocos2d_specifics.hpp" #include "CocoStudio.h" template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedValue initializing(cx); JSBool isNewValid = JS_TRUE; JSObject* global = ScriptingCore::getInstance()->getGlobalObject(); isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && JSVAL_TO_BOOLEAN(initializing); if (isNewValid) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); return JS_TRUE; } JS_ReportError(cx, "Don't use `new cc.XXX`, please use `cc.XXX.create` instead! "); return JS_FALSE; } static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { return JS_FALSE; } static JSBool js_is_native_obj(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { vp.set(BOOLEAN_TO_JSVAL(JS_TRUE)); return JS_TRUE; } JSClass *jsb_cocostudio_ActionObject_class; JSObject *jsb_cocostudio_ActionObject_prototype; JSBool js_cocos2dx_studio_ActionObject_setCurrentTime(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_setCurrentTime : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_setCurrentTime : Error processing arguments"); cobj->setCurrentTime(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_setCurrentTime : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_pause(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_pause : Invalid Native Object"); if (argc == 0) { cobj->pause(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_pause : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_setName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_setName : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_setName : Error processing arguments"); cobj->setName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_setName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_setUnitTime(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_setUnitTime : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_setUnitTime : Error processing arguments"); cobj->setUnitTime(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_setUnitTime : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_getTotalTime(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_getTotalTime : Invalid Native Object"); if (argc == 0) { double ret = cobj->getTotalTime(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getTotalTime : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_getName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_getName : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getName(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_stop(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_stop : Invalid Native Object"); if (argc == 0) { cobj->stop(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_stop : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_play(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::ActionObject* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_play : Invalid Native Object"); do { if (argc == 1) { cocos2d::CallFunc* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::CallFunc*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cobj->play(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 0) { cobj->play(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_play : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_getCurrentTime(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_getCurrentTime : Invalid Native Object"); if (argc == 0) { double ret = cobj->getCurrentTime(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getCurrentTime : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_removeActionNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_removeActionNode : Invalid Native Object"); if (argc == 1) { cocostudio::ActionNode* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ActionNode*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_removeActionNode : Error processing arguments"); cobj->removeActionNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_removeActionNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_getLoop(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_getLoop : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getLoop(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getLoop : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_addActionNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_addActionNode : Invalid Native Object"); if (argc == 1) { cocostudio::ActionNode* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ActionNode*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_addActionNode : Error processing arguments"); cobj->addActionNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_addActionNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_getUnitTime(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_getUnitTime : Invalid Native Object"); if (argc == 0) { double ret = cobj->getUnitTime(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getUnitTime : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_isPlaying(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_isPlaying : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isPlaying(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_isPlaying : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_updateToFrameByTime(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_updateToFrameByTime : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_updateToFrameByTime : Error processing arguments"); cobj->updateToFrameByTime(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_updateToFrameByTime : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_setLoop(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_setLoop : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_setLoop : Error processing arguments"); cobj->setLoop(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_setLoop : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_simulationActionUpdate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_simulationActionUpdate : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionObject_simulationActionUpdate : Error processing arguments"); cobj->simulationActionUpdate(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_simulationActionUpdate : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionObject_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ActionObject* cobj = new cocostudio::ActionObject(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::ActionObject"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocostudio_ActionObject_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ActionObject)", obj); } void js_register_cocos2dx_studio_ActionObject(JSContext *cx, JSObject *global) { jsb_cocostudio_ActionObject_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ActionObject_class->name = "ActionObject"; jsb_cocostudio_ActionObject_class->addProperty = JS_PropertyStub; jsb_cocostudio_ActionObject_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ActionObject_class->getProperty = JS_PropertyStub; jsb_cocostudio_ActionObject_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ActionObject_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ActionObject_class->resolve = JS_ResolveStub; jsb_cocostudio_ActionObject_class->convert = JS_ConvertStub; jsb_cocostudio_ActionObject_class->finalize = js_cocostudio_ActionObject_finalize; jsb_cocostudio_ActionObject_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setCurrentTime", js_cocos2dx_studio_ActionObject_setCurrentTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pause", js_cocos2dx_studio_ActionObject_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setName", js_cocos2dx_studio_ActionObject_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUnitTime", js_cocos2dx_studio_ActionObject_setUnitTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTotalTime", js_cocos2dx_studio_ActionObject_getTotalTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_studio_ActionObject_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stop", js_cocos2dx_studio_ActionObject_stop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("play", js_cocos2dx_studio_ActionObject_play, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentTime", js_cocos2dx_studio_ActionObject_getCurrentTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeActionNode", js_cocos2dx_studio_ActionObject_removeActionNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLoop", js_cocos2dx_studio_ActionObject_getLoop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addActionNode", js_cocos2dx_studio_ActionObject_addActionNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUnitTime", js_cocos2dx_studio_ActionObject_getUnitTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPlaying", js_cocos2dx_studio_ActionObject_isPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateToFrameByTime", js_cocos2dx_studio_ActionObject_updateToFrameByTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLoop", js_cocos2dx_studio_ActionObject_setLoop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("simulationActionUpdate", js_cocos2dx_studio_ActionObject_simulationActionUpdate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocostudio_ActionObject_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_ActionObject_class, js_cocos2dx_studio_ActionObject_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ActionObject", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ActionObject_class; p->proto = jsb_cocostudio_ActionObject_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ActionManagerEx_class; JSObject *jsb_cocostudio_ActionManagerEx_prototype; JSBool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::ActionManagerEx* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionManagerEx_playActionByName : Invalid Native Object"); do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocos2d::CallFunc* arg2; do { if (!argv[2].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::CallFunc*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocostudio::ActionObject* ret = cobj->playActionByName(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ActionObject*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocostudio::ActionObject* ret = cobj->playActionByName(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ActionObject*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_playActionByName : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionManagerEx_getActionByName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionManagerEx* cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionManagerEx_getActionByName : Invalid Native Object"); if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ActionManagerEx_getActionByName : Error processing arguments"); cocostudio::ActionObject* ret = cobj->getActionByName(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ActionObject*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_getActionByName : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionManagerEx_releaseActions(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ActionManagerEx* cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ActionManagerEx_releaseActions : Invalid Native Object"); if (argc == 0) { cobj->releaseActions(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_releaseActions : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionManagerEx_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ActionManagerEx::destroyInstance(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_destroyInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ActionManagerEx_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ActionManagerEx* ret = cocostudio::ActionManagerEx::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ActionManagerEx*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocostudio_ActionManagerEx_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ActionManagerEx)", obj); } void js_register_cocos2dx_studio_ActionManagerEx(JSContext *cx, JSObject *global) { jsb_cocostudio_ActionManagerEx_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ActionManagerEx_class->name = "ActionManager"; jsb_cocostudio_ActionManagerEx_class->addProperty = JS_PropertyStub; jsb_cocostudio_ActionManagerEx_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ActionManagerEx_class->getProperty = JS_PropertyStub; jsb_cocostudio_ActionManagerEx_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ActionManagerEx_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ActionManagerEx_class->resolve = JS_ResolveStub; jsb_cocostudio_ActionManagerEx_class->convert = JS_ConvertStub; jsb_cocostudio_ActionManagerEx_class->finalize = js_cocostudio_ActionManagerEx_finalize; jsb_cocostudio_ActionManagerEx_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("playActionByName", js_cocos2dx_studio_ActionManagerEx_playActionByName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActionByName", js_cocos2dx_studio_ActionManagerEx_getActionByName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("releaseActions", js_cocos2dx_studio_ActionManagerEx_releaseActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("destroyInstance", js_cocos2dx_studio_ActionManagerEx_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_cocos2dx_studio_ActionManagerEx_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_ActionManagerEx_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_ActionManagerEx_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ActionManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ActionManagerEx_class; p->proto = jsb_cocostudio_ActionManagerEx_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_BaseData_class; JSObject *jsb_cocostudio_BaseData_prototype; JSBool js_cocos2dx_studio_BaseData_getColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::BaseData* cobj = (cocostudio::BaseData *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_BaseData_getColor : Invalid Native Object"); if (argc == 0) { cocos2d::Color4B ret = cobj->getColor(); jsval jsret = JSVAL_NULL; jsret = cccolor4b_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_BaseData_getColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_BaseData_setColor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::BaseData* cobj = (cocostudio::BaseData *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_BaseData_setColor : Invalid Native Object"); if (argc == 1) { cocos2d::Color4B arg0; ok &= jsval_to_cccolor4b(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_BaseData_setColor : Error processing arguments"); cobj->setColor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_BaseData_setColor : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_BaseData_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::BaseData* ret = cocostudio::BaseData::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::BaseData*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_BaseData_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_BaseData_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::BaseData* cobj = new cocostudio::BaseData(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::BaseData"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_BaseData_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocostudio_BaseData_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (BaseData)", obj); } void js_register_cocos2dx_studio_BaseData(JSContext *cx, JSObject *global) { jsb_cocostudio_BaseData_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_BaseData_class->name = "BaseData"; jsb_cocostudio_BaseData_class->addProperty = JS_PropertyStub; jsb_cocostudio_BaseData_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_BaseData_class->getProperty = JS_PropertyStub; jsb_cocostudio_BaseData_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_BaseData_class->enumerate = JS_EnumerateStub; jsb_cocostudio_BaseData_class->resolve = JS_ResolveStub; jsb_cocostudio_BaseData_class->convert = JS_ConvertStub; jsb_cocostudio_BaseData_class->finalize = js_cocostudio_BaseData_finalize; jsb_cocostudio_BaseData_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getColor", js_cocos2dx_studio_BaseData_getColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setColor", js_cocos2dx_studio_BaseData_setColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_BaseData_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_BaseData_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_BaseData_class, js_cocos2dx_studio_BaseData_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "BaseData", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_BaseData_class; p->proto = jsb_cocostudio_BaseData_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_Tween_class; JSObject *jsb_cocostudio_Tween_prototype; JSBool js_cocos2dx_studio_Tween_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Tween_getAnimation : Invalid Native Object"); if (argc == 0) { cocostudio::ArmatureAnimation* ret = cobj->getAnimation(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureAnimation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Tween_getAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Tween_gotoAndPause(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Tween_gotoAndPause : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Tween_gotoAndPause : Error processing arguments"); cobj->gotoAndPause(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Tween_gotoAndPause : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Tween_play(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Tween_play : Invalid Native Object"); if (argc == 5) { cocostudio::MovementBoneData* arg0; int arg1; int arg2; int arg3; int arg4; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::MovementBoneData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Tween_play : Error processing arguments"); cobj->play(arg0, arg1, arg2, arg3, arg4); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Tween_play : wrong number of arguments: %d, was expecting %d", argc, 5); return JS_FALSE; } JSBool js_cocos2dx_studio_Tween_gotoAndPlay(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Tween_gotoAndPlay : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Tween_gotoAndPlay : Error processing arguments"); cobj->gotoAndPlay(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Tween_gotoAndPlay : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Tween_init(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Tween_init : Invalid Native Object"); if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Tween_init : Error processing arguments"); JSBool ret = cobj->init(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Tween_init : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Tween_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Tween_setAnimation : Invalid Native Object"); if (argc == 1) { cocostudio::ArmatureAnimation* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureAnimation*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Tween_setAnimation : Error processing arguments"); cobj->setAnimation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Tween_setAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Tween_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Tween_create : Error processing arguments"); cocostudio::Tween* ret = cocostudio::Tween::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Tween*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Tween_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_Tween_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::Tween* cobj = new cocostudio::Tween(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::Tween"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Tween_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocostudio_Tween_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Tween)", obj); } void js_register_cocos2dx_studio_Tween(JSContext *cx, JSObject *global) { jsb_cocostudio_Tween_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_Tween_class->name = "Tween"; jsb_cocostudio_Tween_class->addProperty = JS_PropertyStub; jsb_cocostudio_Tween_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_Tween_class->getProperty = JS_PropertyStub; jsb_cocostudio_Tween_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_Tween_class->enumerate = JS_EnumerateStub; jsb_cocostudio_Tween_class->resolve = JS_ResolveStub; jsb_cocostudio_Tween_class->convert = JS_ConvertStub; jsb_cocostudio_Tween_class->finalize = js_cocostudio_Tween_finalize; jsb_cocostudio_Tween_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAnimation", js_cocos2dx_studio_Tween_getAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("gotoAndPause", js_cocos2dx_studio_Tween_gotoAndPause, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("play", js_cocos2dx_studio_Tween_play, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("gotoAndPlay", js_cocos2dx_studio_Tween_gotoAndPlay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_Tween_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimation", js_cocos2dx_studio_Tween_setAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_Tween_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_Tween_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_Tween_class, js_cocos2dx_studio_Tween_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Tween", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_Tween_class; p->proto = jsb_cocostudio_Tween_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ColliderFilter_class; JSObject *jsb_cocostudio_ColliderFilter_prototype; void js_cocostudio_ColliderFilter_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ColliderFilter)", obj); } void js_register_cocos2dx_studio_ColliderFilter(JSContext *cx, JSObject *global) { jsb_cocostudio_ColliderFilter_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ColliderFilter_class->name = "ColliderFilter"; jsb_cocostudio_ColliderFilter_class->addProperty = JS_PropertyStub; jsb_cocostudio_ColliderFilter_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ColliderFilter_class->getProperty = JS_PropertyStub; jsb_cocostudio_ColliderFilter_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ColliderFilter_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ColliderFilter_class->resolve = JS_ResolveStub; jsb_cocostudio_ColliderFilter_class->convert = JS_ConvertStub; jsb_cocostudio_ColliderFilter_class->finalize = js_cocostudio_ColliderFilter_finalize; jsb_cocostudio_ColliderFilter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocostudio_ColliderFilter_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_ColliderFilter_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ColliderFilter", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ColliderFilter_class; p->proto = jsb_cocostudio_ColliderFilter_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ColliderBody_class; JSObject *jsb_cocostudio_ColliderBody_prototype; void js_cocostudio_ColliderBody_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ColliderBody)", obj); } void js_register_cocos2dx_studio_ColliderBody(JSContext *cx, JSObject *global) { jsb_cocostudio_ColliderBody_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ColliderBody_class->name = "ColliderBody"; jsb_cocostudio_ColliderBody_class->addProperty = JS_PropertyStub; jsb_cocostudio_ColliderBody_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ColliderBody_class->getProperty = JS_PropertyStub; jsb_cocostudio_ColliderBody_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ColliderBody_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ColliderBody_class->resolve = JS_ResolveStub; jsb_cocostudio_ColliderBody_class->convert = JS_ConvertStub; jsb_cocostudio_ColliderBody_class->finalize = js_cocostudio_ColliderBody_finalize; jsb_cocostudio_ColliderBody_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocostudio_ColliderBody_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_ColliderBody_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ColliderBody", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ColliderBody_class; p->proto = jsb_cocostudio_ColliderBody_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ColliderDetector_class; JSObject *jsb_cocostudio_ColliderDetector_prototype; JSBool js_cocos2dx_studio_ColliderDetector_getBone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_getBone : Invalid Native Object"); if (argc == 0) { cocostudio::Bone* ret = cobj->getBone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_getBone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderDetector_getActive(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_getActive : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getActive(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_getActive : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderDetector_getColliderBodyList(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_getColliderBodyList : Invalid Native Object"); if (argc == 0) { const cocos2d::Vector& ret = cobj->getColliderBodyList(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_getColliderBodyList : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderDetector_updateTransform(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_updateTransform : Invalid Native Object"); if (argc == 1) { kmMat4 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmMat4; JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_updateTransform : Error processing arguments"); cobj->updateTransform(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_updateTransform : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderDetector_removeAll(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_removeAll : Invalid Native Object"); if (argc == 0) { cobj->removeAll(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_removeAll : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderDetector_init(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::ColliderDetector* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_init : Invalid Native Object"); do { if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->init(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_init : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderDetector_setActive(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_setActive : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_setActive : Error processing arguments"); cobj->setActive(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_setActive : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderDetector_setBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_setBone : Invalid Native Object"); if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ColliderDetector_setBone : Error processing arguments"); cobj->setBone(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_setBone : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderDetector_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocostudio::ColliderDetector* ret = cocostudio::ColliderDetector::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ColliderDetector*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocostudio::ColliderDetector* ret = cocostudio::ColliderDetector::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ColliderDetector*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_create : wrong number of arguments"); return JS_FALSE; } void js_cocostudio_ColliderDetector_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ColliderDetector)", obj); } void js_register_cocos2dx_studio_ColliderDetector(JSContext *cx, JSObject *global) { jsb_cocostudio_ColliderDetector_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ColliderDetector_class->name = "ColliderDetector"; jsb_cocostudio_ColliderDetector_class->addProperty = JS_PropertyStub; jsb_cocostudio_ColliderDetector_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ColliderDetector_class->getProperty = JS_PropertyStub; jsb_cocostudio_ColliderDetector_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ColliderDetector_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ColliderDetector_class->resolve = JS_ResolveStub; jsb_cocostudio_ColliderDetector_class->convert = JS_ConvertStub; jsb_cocostudio_ColliderDetector_class->finalize = js_cocostudio_ColliderDetector_finalize; jsb_cocostudio_ColliderDetector_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getBone", js_cocos2dx_studio_ColliderDetector_getBone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActive", js_cocos2dx_studio_ColliderDetector_getActive, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getColliderBodyList", js_cocos2dx_studio_ColliderDetector_getColliderBodyList, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateTransform", js_cocos2dx_studio_ColliderDetector_updateTransform, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAll", js_cocos2dx_studio_ColliderDetector_removeAll, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_ColliderDetector_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setActive", js_cocos2dx_studio_ColliderDetector_setActive, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBone", js_cocos2dx_studio_ColliderDetector_setBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_ColliderDetector_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_ColliderDetector_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_ColliderDetector_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ColliderDetector", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ColliderDetector_class; p->proto = jsb_cocostudio_ColliderDetector_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_DisplayManager_class; JSObject *jsb_cocostudio_DisplayManager_prototype; JSBool js_cocos2dx_studio_DisplayManager_getDisplayRenderNode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_getDisplayRenderNode : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getDisplayRenderNode(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getDisplayRenderNode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getAnchorPointInPoints(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getDisplayRenderNodeType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_removeDisplay(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_removeDisplay : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_removeDisplay : Error processing arguments"); cobj->removeDisplay(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_removeDisplay : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_setForceChangeDisplay(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_setForceChangeDisplay : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_setForceChangeDisplay : Error processing arguments"); cobj->setForceChangeDisplay(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_setForceChangeDisplay : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_init(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_init : Invalid Native Object"); if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_init : Error processing arguments"); JSBool ret = cobj->init(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_init : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_getContentSize(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_getContentSize : Invalid Native Object"); if (argc == 0) { cocos2d::Size ret = cobj->getContentSize(); jsval jsret = JSVAL_NULL; jsret = ccsize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_getBoundingBox : Invalid Native Object"); if (argc == 0) { cocos2d::Rect ret = cobj->getBoundingBox(); jsval jsret = JSVAL_NULL; jsret = ccrect_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getBoundingBox : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::DisplayManager* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_addDisplay : Invalid Native Object"); do { if (argc == 2) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cobj->addDisplay(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 2) { cocostudio::DisplayData* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DisplayData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cobj->addDisplay(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_addDisplay : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_containPoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::DisplayManager* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_containPoint : Invalid Native Object"); do { if (argc == 2) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->containPoint(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->containPoint(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_containPoint : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex : Invalid Native Object"); if (argc == 2) { int arg0; JSBool arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex : Error processing arguments"); cobj->changeDisplayWithIndex(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_changeDisplayWithName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_changeDisplayWithName : Invalid Native Object"); if (argc == 2) { std::string arg0; JSBool arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_changeDisplayWithName : Error processing arguments"); cobj->changeDisplayWithName(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_changeDisplayWithName : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_isForceChangeDisplay(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_isForceChangeDisplay : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isForceChangeDisplay(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_isForceChangeDisplay : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex : Invalid Native Object"); if (argc == 0) { int ret = cobj->getCurrentDisplayIndex(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_getAnchorPoint : Invalid Native Object"); if (argc == 0) { cocos2d::Point ret = cobj->getAnchorPoint(); jsval jsret = JSVAL_NULL; jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList : Invalid Native Object"); if (argc == 0) { const cocos2d::Vector& ret = cobj->getDecorativeDisplayList(); jsval jsret = JSVAL_NULL; jsret = ccvector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_isVisible(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_isVisible : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isVisible(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_isVisible : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_setVisible(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_setVisible : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_setVisible : Error processing arguments"); cobj->setVisible(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_setVisible : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_DisplayManager_create : Error processing arguments"); cocostudio::DisplayManager* ret = cocostudio::DisplayManager::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::DisplayManager*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_DisplayManager_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::DisplayManager* cobj = new cocostudio::DisplayManager(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::DisplayManager"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocostudio_DisplayManager_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (DisplayManager)", obj); } void js_register_cocos2dx_studio_DisplayManager(JSContext *cx, JSObject *global) { jsb_cocostudio_DisplayManager_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_DisplayManager_class->name = "DisplayManager"; jsb_cocostudio_DisplayManager_class->addProperty = JS_PropertyStub; jsb_cocostudio_DisplayManager_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_DisplayManager_class->getProperty = JS_PropertyStub; jsb_cocostudio_DisplayManager_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_DisplayManager_class->enumerate = JS_EnumerateStub; jsb_cocostudio_DisplayManager_class->resolve = JS_ResolveStub; jsb_cocostudio_DisplayManager_class->convert = JS_ConvertStub; jsb_cocostudio_DisplayManager_class->finalize = js_cocostudio_DisplayManager_finalize; jsb_cocostudio_DisplayManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getDisplayRenderNode", js_cocos2dx_studio_DisplayManager_getDisplayRenderNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnchorPointInPoints", js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisplayRenderNodeType", js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeDisplay", js_cocos2dx_studio_DisplayManager_removeDisplay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setForceChangeDisplay", js_cocos2dx_studio_DisplayManager_setForceChangeDisplay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_DisplayManager_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentSize", js_cocos2dx_studio_DisplayManager_getContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBoundingBox", js_cocos2dx_studio_DisplayManager_getBoundingBox, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addDisplay", js_cocos2dx_studio_DisplayManager_addDisplay, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("containPoint", js_cocos2dx_studio_DisplayManager_containPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("changeDisplayWithIndex", js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("changeDisplayWithName", js_cocos2dx_studio_DisplayManager_changeDisplayWithName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isForceChangeDisplay", js_cocos2dx_studio_DisplayManager_isForceChangeDisplay, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentDisplayIndex", js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnchorPoint", js_cocos2dx_studio_DisplayManager_getAnchorPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDecorativeDisplayList", js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isVisible", js_cocos2dx_studio_DisplayManager_isVisible, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVisible", js_cocos2dx_studio_DisplayManager_setVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_DisplayManager_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_DisplayManager_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_DisplayManager_class, js_cocos2dx_studio_DisplayManager_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "DisplayManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_DisplayManager_class; p->proto = jsb_cocostudio_DisplayManager_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_Bone_class; JSObject *jsb_cocostudio_Bone_prototype; JSBool js_cocos2dx_studio_Bone_isTransformDirty(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_isTransformDirty : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isTransformDirty(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_isTransformDirty : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_isIgnoreMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_isIgnoreMovementBoneData : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isIgnoreMovementBoneData(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_isIgnoreMovementBoneData : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_updateZOrder(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_updateZOrder : Invalid Native Object"); if (argc == 0) { cobj->updateZOrder(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_updateZOrder : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getDisplayRenderNode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getDisplayRenderNode : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getDisplayRenderNode(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getDisplayRenderNode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_isBlendDirty(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_isBlendDirty : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isBlendDirty(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_isBlendDirty : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_addChildBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_addChildBone : Invalid Native Object"); if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_addChildBone : Error processing arguments"); cobj->addChildBone(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_addChildBone : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getWorldInfo(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getWorldInfo : Invalid Native Object"); if (argc == 0) { cocostudio::BaseData* ret = cobj->getWorldInfo(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::BaseData*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getWorldInfo : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getTween(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getTween : Invalid Native Object"); if (argc == 0) { cocostudio::Tween* ret = cobj->getTween(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Tween*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getTween : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getParentBone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getParentBone : Invalid Native Object"); if (argc == 0) { cocostudio::Bone* ret = cobj->getParentBone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getParentBone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_updateColor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_updateColor : Invalid Native Object"); if (argc == 0) { cobj->updateColor(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_updateColor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getName : Invalid Native Object"); if (argc == 0) { const std::string ret = cobj->getName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_setTransformDirty(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setTransformDirty : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setTransformDirty : Error processing arguments"); cobj->setTransformDirty(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_setTransformDirty : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getDisplayRenderNodeType(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getDisplayRenderNodeType : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getDisplayRenderNodeType(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getDisplayRenderNodeType : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_removeDisplay(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_removeDisplay : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_removeDisplay : Error processing arguments"); cobj->removeDisplay(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_removeDisplay : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_setBoneData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setBoneData : Invalid Native Object"); if (argc == 1) { cocostudio::BoneData* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::BoneData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setBoneData : Error processing arguments"); cobj->setBoneData(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_setBoneData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_init(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::Bone* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_init : Invalid Native Object"); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->init(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_Bone_init : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_setParentBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setParentBone : Invalid Native Object"); if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setParentBone : Error processing arguments"); cobj->setParentBone(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_setParentBone : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::Bone* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_addDisplay : Invalid Native Object"); do { if (argc == 2) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cobj->addDisplay(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 2) { cocostudio::DisplayData* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::DisplayData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (!ok) { ok = JS_TRUE; break; } cobj->addDisplay(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_Bone_addDisplay : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_setIgnoreMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setIgnoreMovementBoneData : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setIgnoreMovementBoneData : Error processing arguments"); cobj->setIgnoreMovementBoneData(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_setIgnoreMovementBoneData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_setName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setName : Error processing arguments"); cobj->setName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_setName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_removeFromParent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_removeFromParent : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_removeFromParent : Error processing arguments"); cobj->removeFromParent(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_removeFromParent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getColliderDetector(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getColliderDetector : Invalid Native Object"); if (argc == 0) { cocostudio::ColliderDetector* ret = cobj->getColliderDetector(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ColliderDetector*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getColliderDetector : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getChildArmature(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getChildArmature : Invalid Native Object"); if (argc == 0) { cocostudio::Armature* ret = cobj->getChildArmature(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getChildArmature : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_changeDisplayWithIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_changeDisplayWithIndex : Invalid Native Object"); if (argc == 2) { int arg0; JSBool arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_changeDisplayWithIndex : Error processing arguments"); cobj->changeDisplayWithIndex(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_changeDisplayWithIndex : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_changeDisplayWithName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_changeDisplayWithName : Invalid Native Object"); if (argc == 2) { std::string arg0; JSBool arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_changeDisplayWithName : Error processing arguments"); cobj->changeDisplayWithName(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_changeDisplayWithName : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_setArmature(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setArmature : Invalid Native Object"); if (argc == 1) { cocostudio::Armature* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setArmature : Error processing arguments"); cobj->setArmature(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_setArmature : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_setBlendDirty(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setBlendDirty : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setBlendDirty : Error processing arguments"); cobj->setBlendDirty(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_setBlendDirty : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_removeChildBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_removeChildBone : Invalid Native Object"); if (argc == 2) { cocostudio::Bone* arg0; JSBool arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_removeChildBone : Error processing arguments"); cobj->removeChildBone(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_removeChildBone : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_setChildArmature(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setChildArmature : Invalid Native Object"); if (argc == 1) { cocostudio::Armature* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Bone_setChildArmature : Error processing arguments"); cobj->setChildArmature(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_setChildArmature : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getNodeToArmatureTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getNodeToArmatureTransform : Invalid Native Object"); if (argc == 0) { kmMat4 ret = cobj->getNodeToArmatureTransform(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getNodeToArmatureTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getDisplayManager(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getDisplayManager : Invalid Native Object"); if (argc == 0) { cocostudio::DisplayManager* ret = cobj->getDisplayManager(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::DisplayManager*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getDisplayManager : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_getArmature(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Bone_getArmature : Invalid Native Object"); if (argc == 0) { cocostudio::Armature* ret = cobj->getArmature(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_getArmature : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocostudio::Bone* ret = cocostudio::Bone::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocostudio::Bone* ret = cocostudio::Bone::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_studio_Bone_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_Bone_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::Bone* cobj = new cocostudio::Bone(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::Bone"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Bone_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocostudio_Bone_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Bone)", obj); } void js_register_cocos2dx_studio_Bone(JSContext *cx, JSObject *global) { jsb_cocostudio_Bone_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_Bone_class->name = "Bone"; jsb_cocostudio_Bone_class->addProperty = JS_PropertyStub; jsb_cocostudio_Bone_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_Bone_class->getProperty = JS_PropertyStub; jsb_cocostudio_Bone_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_Bone_class->enumerate = JS_EnumerateStub; jsb_cocostudio_Bone_class->resolve = JS_ResolveStub; jsb_cocostudio_Bone_class->convert = JS_ConvertStub; jsb_cocostudio_Bone_class->finalize = js_cocostudio_Bone_finalize; jsb_cocostudio_Bone_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("isTransformDirty", js_cocos2dx_studio_Bone_isTransformDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isIgnoreMovementBoneData", js_cocos2dx_studio_Bone_isIgnoreMovementBoneData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateZOrder", js_cocos2dx_studio_Bone_updateZOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisplayRenderNode", js_cocos2dx_studio_Bone_getDisplayRenderNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBlendDirty", js_cocos2dx_studio_Bone_isBlendDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addChildBone", js_cocos2dx_studio_Bone_addChildBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWorldInfo", js_cocos2dx_studio_Bone_getWorldInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTween", js_cocos2dx_studio_Bone_getTween, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParentBone", js_cocos2dx_studio_Bone_getParentBone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateColor", js_cocos2dx_studio_Bone_updateColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_studio_Bone_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTransformDirty", js_cocos2dx_studio_Bone_setTransformDirty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisplayRenderNodeType", js_cocos2dx_studio_Bone_getDisplayRenderNodeType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeDisplay", js_cocos2dx_studio_Bone_removeDisplay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBoneData", js_cocos2dx_studio_Bone_setBoneData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_Bone_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setParentBone", js_cocos2dx_studio_Bone_setParentBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addDisplay", js_cocos2dx_studio_Bone_addDisplay, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setIgnoreMovementBoneData", js_cocos2dx_studio_Bone_setIgnoreMovementBoneData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setName", js_cocos2dx_studio_Bone_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeFromParent", js_cocos2dx_studio_Bone_removeFromParent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getColliderDetector", js_cocos2dx_studio_Bone_getColliderDetector, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getChildArmature", js_cocos2dx_studio_Bone_getChildArmature, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("changeDisplayWithIndex", js_cocos2dx_studio_Bone_changeDisplayWithIndex, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("changeDisplayWithName", js_cocos2dx_studio_Bone_changeDisplayWithName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setArmature", js_cocos2dx_studio_Bone_setArmature, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBlendDirty", js_cocos2dx_studio_Bone_setBlendDirty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeChildBone", js_cocos2dx_studio_Bone_removeChildBone, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setChildArmature", js_cocos2dx_studio_Bone_setChildArmature, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeToArmatureTransform", js_cocos2dx_studio_Bone_getNodeToArmatureTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisplayManager", js_cocos2dx_studio_Bone_getDisplayManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getArmature", js_cocos2dx_studio_Bone_getArmature, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_Bone_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_Bone_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocostudio_Bone_class, js_cocos2dx_studio_Bone_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Bone", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_Bone_class; p->proto = jsb_cocostudio_Bone_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_BatchNode_class; JSObject *jsb_cocostudio_BatchNode_prototype; JSBool js_cocos2dx_studio_BatchNode_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::BatchNode* ret = cocostudio::BatchNode::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::BatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_BatchNode_create : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocostudio_BatchNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (BatchNode)", obj); } void js_register_cocos2dx_studio_BatchNode(JSContext *cx, JSObject *global) { jsb_cocostudio_BatchNode_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_BatchNode_class->name = "BatchNode"; jsb_cocostudio_BatchNode_class->addProperty = JS_PropertyStub; jsb_cocostudio_BatchNode_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_BatchNode_class->getProperty = JS_PropertyStub; jsb_cocostudio_BatchNode_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_BatchNode_class->enumerate = JS_EnumerateStub; jsb_cocostudio_BatchNode_class->resolve = JS_ResolveStub; jsb_cocostudio_BatchNode_class->convert = JS_ConvertStub; jsb_cocostudio_BatchNode_class->finalize = js_cocostudio_BatchNode_finalize; jsb_cocostudio_BatchNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_BatchNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_BatchNode_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocostudio_BatchNode_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "BatchNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_BatchNode_class; p->proto = jsb_cocostudio_BatchNode_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ArmatureAnimation_class; JSObject *jsb_cocostudio_ArmatureAnimation_prototype; JSBool js_cocos2dx_studio_ArmatureAnimation_getSpeedScale(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_getSpeedScale : Invalid Native Object"); if (argc == 0) { double ret = cobj->getSpeedScale(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_getSpeedScale : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_pause(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_pause : Invalid Native Object"); if (argc == 0) { cobj->pause(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_pause : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_setSpeedScale(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_setSpeedScale : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_setSpeedScale : Error processing arguments"); cobj->setSpeedScale(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_setSpeedScale : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_init(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_init : Invalid Native Object"); if (argc == 1) { cocostudio::Armature* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_init : Error processing arguments"); JSBool ret = cobj->init(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_init : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_playWithIndexes(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : Invalid Native Object"); if (argc == 1) { std::vector arg0; ok &= jsval_to_std_vector_int(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : Error processing arguments"); cobj->playWithIndexes(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { std::vector arg0; int arg1; ok &= jsval_to_std_vector_int(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : Error processing arguments"); cobj->playWithIndexes(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { std::vector arg0; int arg1; JSBool arg2; ok &= jsval_to_std_vector_int(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : Error processing arguments"); cobj->playWithIndexes(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_play(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_play : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_play : Error processing arguments"); cobj->play(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { std::string arg0; int arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_play : Error processing arguments"); cobj->play(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { std::string arg0; int arg1; int arg2; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_play : Error processing arguments"); cobj->play(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_play : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_gotoAndPause(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPause : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPause : Error processing arguments"); cobj->gotoAndPause(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPause : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_resume(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_resume : Invalid Native Object"); if (argc == 0) { cobj->resume(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_resume : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_stop(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_stop : Invalid Native Object"); if (argc == 0) { cobj->stop(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_stop : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_update(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_update : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_update : Error processing arguments"); cobj->update(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_update : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_playWithIndex(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : Error processing arguments"); cobj->playWithIndex(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { int arg0; int arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : Error processing arguments"); cobj->playWithIndex(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { int arg0; int arg1; int arg2; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : Error processing arguments"); cobj->playWithIndex(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getCurrentMovementID(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay : Error processing arguments"); cobj->gotoAndPlay(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_playWithNames(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : Invalid Native Object"); if (argc == 1) { std::vector arg0; ok &= jsval_to_std_vector_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : Error processing arguments"); cobj->playWithNames(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { std::vector arg0; int arg1; ok &= jsval_to_std_vector_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : Error processing arguments"); cobj->playWithNames(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { std::vector arg0; int arg1; JSBool arg2; ok &= jsval_to_std_vector_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); ok &= JS_ValueToBoolean(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : Error processing arguments"); cobj->playWithNames(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_getMovementCount(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_getMovementCount : Invalid Native Object"); if (argc == 0) { ssize_t ret = cobj->getMovementCount(); jsval jsret = JSVAL_NULL; jsret = ssize_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_getMovementCount : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocostudio::Armature* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Armature*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureAnimation_create : Error processing arguments"); cocostudio::ArmatureAnimation* ret = cocostudio::ArmatureAnimation::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureAnimation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ArmatureAnimation* cobj = new cocostudio::ArmatureAnimation(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::ArmatureAnimation"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocostudio_ArmatureAnimation_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ArmatureAnimation)", obj); } void js_register_cocos2dx_studio_ArmatureAnimation(JSContext *cx, JSObject *global) { jsb_cocostudio_ArmatureAnimation_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ArmatureAnimation_class->name = "ArmatureAnimation"; jsb_cocostudio_ArmatureAnimation_class->addProperty = JS_PropertyStub; jsb_cocostudio_ArmatureAnimation_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ArmatureAnimation_class->getProperty = JS_PropertyStub; jsb_cocostudio_ArmatureAnimation_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ArmatureAnimation_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ArmatureAnimation_class->resolve = JS_ResolveStub; jsb_cocostudio_ArmatureAnimation_class->convert = JS_ConvertStub; jsb_cocostudio_ArmatureAnimation_class->finalize = js_cocostudio_ArmatureAnimation_finalize; jsb_cocostudio_ArmatureAnimation_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getSpeedScale", js_cocos2dx_studio_ArmatureAnimation_getSpeedScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pause", js_cocos2dx_studio_ArmatureAnimation_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSpeedScale", js_cocos2dx_studio_ArmatureAnimation_setSpeedScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_ArmatureAnimation_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("playWithIndexes", js_cocos2dx_studio_ArmatureAnimation_playWithIndexes, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("play", js_cocos2dx_studio_ArmatureAnimation_play, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("gotoAndPause", js_cocos2dx_studio_ArmatureAnimation_gotoAndPause, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resume", js_cocos2dx_studio_ArmatureAnimation_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stop", js_cocos2dx_studio_ArmatureAnimation_stop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", js_cocos2dx_studio_ArmatureAnimation_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("playWithIndex", js_cocos2dx_studio_ArmatureAnimation_playWithIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentMovementID", js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("gotoAndPlay", js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("playWithNames", js_cocos2dx_studio_ArmatureAnimation_playWithNames, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMovementCount", js_cocos2dx_studio_ArmatureAnimation_getMovementCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_ArmatureAnimation_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_ArmatureAnimation_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_ArmatureAnimation_class, js_cocos2dx_studio_ArmatureAnimation_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ArmatureAnimation", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ArmatureAnimation_class; p->proto = jsb_cocostudio_ArmatureAnimation_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ArmatureDataManager_class; JSObject *jsb_cocostudio_ArmatureDataManager_prototype; JSBool js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas : Invalid Native Object"); if (argc == 0) { const cocos2d::Map& ret = cobj->getAnimationDatas(); jsval jsret = JSVAL_NULL; jsret = ccmap_string_key_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_removeAnimationData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_removeAnimationData : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_removeAnimationData : Error processing arguments"); cobj->removeAnimationData(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_removeAnimationData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_addArmatureData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addArmatureData : Invalid Native Object"); if (argc == 2) { std::string arg0; cocostudio::ArmatureData* arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::ArmatureData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addArmatureData : Error processing arguments"); cobj->addArmatureData(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { std::string arg0; cocostudio::ArmatureData* arg1; std::string arg2; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::ArmatureData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addArmatureData : Error processing arguments"); cobj->addArmatureData(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addArmatureData : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::ArmatureDataManager* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo : Invalid Native Object"); do { if (argc == 3) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } std::string arg1; ok &= jsval_to_std_string(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } std::string arg2; ok &= jsval_to_std_string(cx, argv[2], &arg2); if (!ok) { ok = JS_TRUE; break; } cobj->addArmatureFileInfo(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->addArmatureFileInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo : Error processing arguments"); cobj->removeArmatureFileInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_getTextureData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_getTextureData : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_getTextureData : Error processing arguments"); cocostudio::TextureData* ret = cobj->getTextureData(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::TextureData*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getTextureData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_getArmatureData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_getArmatureData : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_getArmatureData : Error processing arguments"); cocostudio::ArmatureData* ret = cobj->getArmatureData(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureData*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getArmatureData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_getAnimationData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_getAnimationData : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_getAnimationData : Error processing arguments"); cocostudio::AnimationData* ret = cobj->getAnimationData(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::AnimationData*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getAnimationData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_addAnimationData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addAnimationData : Invalid Native Object"); if (argc == 2) { std::string arg0; cocostudio::AnimationData* arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::AnimationData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addAnimationData : Error processing arguments"); cobj->addAnimationData(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { std::string arg0; cocostudio::AnimationData* arg1; std::string arg2; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::AnimationData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addAnimationData : Error processing arguments"); cobj->addAnimationData(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addAnimationData : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_init : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_init : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_removeArmatureData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureData : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureData : Error processing arguments"); cobj->removeArmatureData(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas : Invalid Native Object"); if (argc == 0) { const cocos2d::Map& ret = cobj->getArmatureDatas(); jsval jsret = JSVAL_NULL; jsret = ccmap_string_key_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_removeTextureData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_removeTextureData : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_removeTextureData : Error processing arguments"); cobj->removeTextureData(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_removeTextureData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_addTextureData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addTextureData : Invalid Native Object"); if (argc == 2) { std::string arg0; cocostudio::TextureData* arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addTextureData : Error processing arguments"); cobj->addTextureData(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { std::string arg0; cocostudio::TextureData* arg1; std::string arg2; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addTextureData : Error processing arguments"); cobj->addTextureData(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addTextureData : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isAutoLoadSpriteFile(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile : Invalid Native Object"); if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile : Error processing arguments"); cobj->addSpriteFrameFromFile(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 3) { std::string arg0; std::string arg1; std::string arg2; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= jsval_to_std_string(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile : Error processing arguments"); cobj->addSpriteFrameFromFile(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ArmatureDataManager::destroyInstance(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_destroyInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ArmatureDataManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ArmatureDataManager* ret = cocostudio::ArmatureDataManager::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureDataManager*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocostudio_ArmatureDataManager_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ArmatureDataManager)", obj); } void js_register_cocos2dx_studio_ArmatureDataManager(JSContext *cx, JSObject *global) { jsb_cocostudio_ArmatureDataManager_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ArmatureDataManager_class->name = "ArmatureDataManager"; jsb_cocostudio_ArmatureDataManager_class->addProperty = JS_PropertyStub; jsb_cocostudio_ArmatureDataManager_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ArmatureDataManager_class->getProperty = JS_PropertyStub; jsb_cocostudio_ArmatureDataManager_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ArmatureDataManager_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ArmatureDataManager_class->resolve = JS_ResolveStub; jsb_cocostudio_ArmatureDataManager_class->convert = JS_ConvertStub; jsb_cocostudio_ArmatureDataManager_class->finalize = js_cocostudio_ArmatureDataManager_finalize; jsb_cocostudio_ArmatureDataManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getAnimationDatas", js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAnimationData", js_cocos2dx_studio_ArmatureDataManager_removeAnimationData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addArmatureData", js_cocos2dx_studio_ArmatureDataManager_addArmatureData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addArmatureFileInfo", js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeArmatureFileInfo", js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureData", js_cocos2dx_studio_ArmatureDataManager_getTextureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getArmatureData", js_cocos2dx_studio_ArmatureDataManager_getArmatureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnimationData", js_cocos2dx_studio_ArmatureDataManager_getAnimationData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addAnimationData", js_cocos2dx_studio_ArmatureDataManager_addAnimationData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_ArmatureDataManager_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeArmatureData", js_cocos2dx_studio_ArmatureDataManager_removeArmatureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getArmatureDatas", js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeTextureData", js_cocos2dx_studio_ArmatureDataManager_removeTextureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addTextureData", js_cocos2dx_studio_ArmatureDataManager_addTextureData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isAutoLoadSpriteFile", js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addSpriteFrameFromFile", js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("destroyInstance", js_cocos2dx_studio_ArmatureDataManager_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_cocos2dx_studio_ArmatureDataManager_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_ArmatureDataManager_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_ArmatureDataManager_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ArmatureDataManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ArmatureDataManager_class; p->proto = jsb_cocostudio_ArmatureDataManager_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_Armature_class; JSObject *jsb_cocostudio_Armature_prototype; JSBool js_cocos2dx_studio_Armature_getBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getBone : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getBone : Error processing arguments"); cocostudio::Bone* ret = cobj->getBone(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBone : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_changeBoneParent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_changeBoneParent : Invalid Native Object"); if (argc == 2) { cocostudio::Bone* arg0; std::string arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_changeBoneParent : Error processing arguments"); cobj->changeBoneParent(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_changeBoneParent : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setAnimation : Invalid Native Object"); if (argc == 1) { cocostudio::ArmatureAnimation* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureAnimation*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setAnimation : Error processing arguments"); cobj->setAnimation(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_setAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getBoneAtPoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getBoneAtPoint : Invalid Native Object"); if (argc == 2) { double arg0; double arg1; ok &= JS_ValueToNumber(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getBoneAtPoint : Error processing arguments"); cocostudio::Bone* ret = cobj->getBoneAtPoint(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBoneAtPoint : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getArmatureTransformDirty(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getArmatureTransformDirty : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->getArmatureTransformDirty(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getArmatureTransformDirty : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_setVersion(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setVersion : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setVersion : Error processing arguments"); cobj->setVersion(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_setVersion : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_updateOffsetPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_updateOffsetPoint : Invalid Native Object"); if (argc == 0) { cobj->updateOffsetPoint(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_updateOffsetPoint : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getParentBone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getParentBone : Invalid Native Object"); if (argc == 0) { cocostudio::Bone* ret = cobj->getParentBone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getParentBone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_setArmatureData(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setArmatureData : Invalid Native Object"); if (argc == 1) { cocostudio::ArmatureData* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::ArmatureData*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setArmatureData : Error processing arguments"); cobj->setArmatureData(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_setArmatureData : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_removeBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_removeBone : Invalid Native Object"); if (argc == 2) { cocostudio::Bone* arg0; JSBool arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_removeBone : Error processing arguments"); cobj->removeBone(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_removeBone : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getBatchNode : Invalid Native Object"); if (argc == 0) { cocostudio::BatchNode* ret = cobj->getBatchNode(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::BatchNode*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBatchNode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getName : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_init(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::Armature* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_init : Invalid Native Object"); do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->init(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { JSBool ret = cobj->init(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocostudio::Bone* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } JSBool ret = cobj->init(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_Armature_init : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_setParentBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setParentBone : Invalid Native Object"); if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setParentBone : Error processing arguments"); cobj->setParentBone(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_setParentBone : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_drawContour(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_drawContour : Invalid Native Object"); if (argc == 0) { cobj->drawContour(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_drawContour : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setBatchNode : Invalid Native Object"); if (argc == 1) { cocostudio::BatchNode* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::BatchNode*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setBatchNode : Error processing arguments"); cobj->setBatchNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_setBatchNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_setName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_setName : Error processing arguments"); cobj->setName(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_setName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_addBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_addBone : Invalid Native Object"); if (argc == 2) { cocostudio::Bone* arg0; std::string arg1; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Armature_addBone : Error processing arguments"); cobj->addBone(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_addBone : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getArmatureData(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getArmatureData : Invalid Native Object"); if (argc == 0) { cocostudio::ArmatureData* ret = cobj->getArmatureData(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureData*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getArmatureData : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getVersion(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getVersion : Invalid Native Object"); if (argc == 0) { double ret = cobj->getVersion(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getVersion : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getAnimation : Invalid Native Object"); if (argc == 0) { cocostudio::ArmatureAnimation* ret = cobj->getAnimation(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureAnimation*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_getBoneDic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Armature_getBoneDic : Invalid Native Object"); if (argc == 0) { const cocos2d::Map& ret = cobj->getBoneDic(); jsval jsret = JSVAL_NULL; jsret = ccmap_string_key_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBoneDic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocostudio::Armature* ret = cocostudio::Armature::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocostudio::Armature* ret = cocostudio::Armature::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 2) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocostudio::Bone* arg1; do { if (!argv[1].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } cocostudio::Armature* ret = cocostudio::Armature::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_studio_Armature_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_Armature_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::Armature* cobj = new cocostudio::Armature(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::Armature"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Armature_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Node_prototype; void js_cocostudio_Armature_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Armature)", obj); } static JSBool js_cocostudio_Armature_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocostudio::Armature *nobj = cocostudio::Armature::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::Armature"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_studio_Armature(JSContext *cx, JSObject *global) { jsb_cocostudio_Armature_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_Armature_class->name = "Armature"; jsb_cocostudio_Armature_class->addProperty = JS_PropertyStub; jsb_cocostudio_Armature_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_Armature_class->getProperty = JS_PropertyStub; jsb_cocostudio_Armature_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_Armature_class->enumerate = JS_EnumerateStub; jsb_cocostudio_Armature_class->resolve = JS_ResolveStub; jsb_cocostudio_Armature_class->convert = JS_ConvertStub; jsb_cocostudio_Armature_class->finalize = js_cocostudio_Armature_finalize; jsb_cocostudio_Armature_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getBone", js_cocos2dx_studio_Armature_getBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("changeBoneParent", js_cocos2dx_studio_Armature_changeBoneParent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnimation", js_cocos2dx_studio_Armature_setAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBoneAtPoint", js_cocos2dx_studio_Armature_getBoneAtPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getArmatureTransformDirty", js_cocos2dx_studio_Armature_getArmatureTransformDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVersion", js_cocos2dx_studio_Armature_setVersion, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateOffsetPoint", js_cocos2dx_studio_Armature_updateOffsetPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParentBone", js_cocos2dx_studio_Armature_getParentBone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setArmatureData", js_cocos2dx_studio_Armature_setArmatureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeBone", js_cocos2dx_studio_Armature_removeBone, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBatchNode", js_cocos2dx_studio_Armature_getBatchNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_studio_Armature_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_Armature_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setParentBone", js_cocos2dx_studio_Armature_setParentBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawContour", js_cocos2dx_studio_Armature_drawContour, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBatchNode", js_cocos2dx_studio_Armature_setBatchNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setName", js_cocos2dx_studio_Armature_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addBone", js_cocos2dx_studio_Armature_addBone, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getArmatureData", js_cocos2dx_studio_Armature_getArmatureData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVersion", js_cocos2dx_studio_Armature_getVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnimation", js_cocos2dx_studio_Armature_getAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBoneDic", js_cocos2dx_studio_Armature_getBoneDic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocostudio_Armature_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_Armature_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_Armature_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, jsb_cocostudio_Armature_class, js_cocos2dx_studio_Armature_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Armature", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_Armature_class; p->proto = jsb_cocostudio_Armature_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_Skin_class; JSObject *jsb_cocostudio_Skin_prototype; JSBool js_cocos2dx_studio_Skin_getBone(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Skin_getBone : Invalid Native Object"); if (argc == 0) { cocostudio::Bone* ret = cobj->getBone(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_getBone : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_getNodeToWorldTransformAR(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Skin_getNodeToWorldTransformAR : Invalid Native Object"); if (argc == 0) { kmMat4 ret = cobj->getNodeToWorldTransformAR(); jsval jsret = JSVAL_NULL; #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_getNodeToWorldTransformAR : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Skin_initWithFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Skin_initWithFile : Error processing arguments"); JSBool ret = cobj->initWithFile(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_initWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_getDisplayName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Skin_getDisplayName : Invalid Native Object"); if (argc == 0) { const std::string& ret = cobj->getDisplayName(); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_getDisplayName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_updateArmatureTransform(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Skin_updateArmatureTransform : Invalid Native Object"); if (argc == 0) { cobj->updateArmatureTransform(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_updateArmatureTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Skin_initWithSpriteFrameName : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Skin_initWithSpriteFrameName : Error processing arguments"); JSBool ret = cobj->initWithSpriteFrameName(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_initWithSpriteFrameName : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_setBone(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_Skin_setBone : Invalid Native Object"); if (argc == 1) { cocostudio::Bone* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocostudio::Bone*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Skin_setBone : Error processing arguments"); cobj->setBone(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_setBone : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cocostudio::Skin* ret = cocostudio::Skin::create(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Skin*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocostudio::Skin* ret = cocostudio::Skin::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Skin*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_studio_Skin_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_Skin_createWithSpriteFrameName : Error processing arguments"); cocostudio::Skin* ret = cocostudio::Skin::createWithSpriteFrameName(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::Skin*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_createWithSpriteFrameName : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_Skin_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::Skin* cobj = new cocostudio::Skin(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::Skin"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_Skin_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Sprite_prototype; void js_cocostudio_Skin_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Skin)", obj); } void js_register_cocos2dx_studio_Skin(JSContext *cx, JSObject *global) { jsb_cocostudio_Skin_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_Skin_class->name = "Skin"; jsb_cocostudio_Skin_class->addProperty = JS_PropertyStub; jsb_cocostudio_Skin_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_Skin_class->getProperty = JS_PropertyStub; jsb_cocostudio_Skin_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_Skin_class->enumerate = JS_EnumerateStub; jsb_cocostudio_Skin_class->resolve = JS_ResolveStub; jsb_cocostudio_Skin_class->convert = JS_ConvertStub; jsb_cocostudio_Skin_class->finalize = js_cocostudio_Skin_finalize; jsb_cocostudio_Skin_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getBone", js_cocos2dx_studio_Skin_getBone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeToWorldTransformAR", js_cocos2dx_studio_Skin_getNodeToWorldTransformAR, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithFile", js_cocos2dx_studio_Skin_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDisplayName", js_cocos2dx_studio_Skin_getDisplayName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateArmatureTransform", js_cocos2dx_studio_Skin_updateArmatureTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithSpriteFrameName", js_cocos2dx_studio_Skin_initWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBone", js_cocos2dx_studio_Skin_setBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_Skin_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithSpriteFrameName", js_cocos2dx_studio_Skin_createWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_Skin_prototype = JS_InitClass( cx, global, jsb_cocos2d_Sprite_prototype, jsb_cocostudio_Skin_class, js_cocos2dx_studio_Skin_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "Skin", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_Skin_class; p->proto = jsb_cocostudio_Skin_prototype; p->parentProto = jsb_cocos2d_Sprite_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ComAttribute_class; JSObject *jsb_cocostudio_ComAttribute_prototype; JSBool js_cocos2dx_studio_ComAttribute_getFloat(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getFloat : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getFloat : Error processing arguments"); double ret = cobj->getFloat(arg0); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { std::string arg0; double arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getFloat : Error processing arguments"); double ret = cobj->getFloat(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_getFloat : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_getString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getString : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getString : Error processing arguments"); std::string ret = cobj->getString(arg0); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getString : Error processing arguments"); std::string ret = cobj->getString(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_getString : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_setFloat(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_setFloat : Invalid Native Object"); if (argc == 2) { std::string arg0; double arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_setFloat : Error processing arguments"); cobj->setFloat(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_setFloat : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_setString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_setString : Invalid Native Object"); if (argc == 2) { std::string arg0; std::string arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_std_string(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_setString : Error processing arguments"); cobj->setString(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_setString : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_getBool(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getBool : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getBool : Error processing arguments"); JSBool ret = cobj->getBool(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { std::string arg0; JSBool arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getBool : Error processing arguments"); JSBool ret = cobj->getBool(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_getBool : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_setInt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_setInt : Invalid Native Object"); if (argc == 2) { std::string arg0; int arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_setInt : Error processing arguments"); cobj->setInt(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_setInt : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_parse(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_parse : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_parse : Error processing arguments"); JSBool ret = cobj->parse(arg0); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_parse : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_getInt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getInt : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getInt : Error processing arguments"); int ret = cobj->getInt(arg0); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 2) { std::string arg0; int arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_getInt : Error processing arguments"); int ret = cobj->getInt(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_getInt : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_setBool(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_setBool : Invalid Native Object"); if (argc == 2) { std::string arg0; JSBool arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); ok &= JS_ValueToBoolean(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAttribute_setBool : Error processing arguments"); cobj->setBool(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_setBool : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ComAttribute* ret = cocostudio::ComAttribute::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ComAttribute*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAttribute_createInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Object* ret = cocostudio::ComAttribute::createInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Object*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_createInstance : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Component_prototype; void js_cocostudio_ComAttribute_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ComAttribute)", obj); } void js_register_cocos2dx_studio_ComAttribute(JSContext *cx, JSObject *global) { jsb_cocostudio_ComAttribute_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ComAttribute_class->name = "ComAttribute"; jsb_cocostudio_ComAttribute_class->addProperty = JS_PropertyStub; jsb_cocostudio_ComAttribute_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ComAttribute_class->getProperty = JS_PropertyStub; jsb_cocostudio_ComAttribute_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ComAttribute_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ComAttribute_class->resolve = JS_ResolveStub; jsb_cocostudio_ComAttribute_class->convert = JS_ConvertStub; jsb_cocostudio_ComAttribute_class->finalize = js_cocostudio_ComAttribute_finalize; jsb_cocostudio_ComAttribute_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getFloat", js_cocos2dx_studio_ComAttribute_getFloat, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_studio_ComAttribute_getString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFloat", js_cocos2dx_studio_ComAttribute_setFloat, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setString", js_cocos2dx_studio_ComAttribute_setString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBool", js_cocos2dx_studio_ComAttribute_getBool, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInt", js_cocos2dx_studio_ComAttribute_setInt, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("parse", js_cocos2dx_studio_ComAttribute_parse, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInt", js_cocos2dx_studio_ComAttribute_getInt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBool", js_cocos2dx_studio_ComAttribute_setBool, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_ComAttribute_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createInstance", js_cocos2dx_studio_ComAttribute_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_ComAttribute_prototype = JS_InitClass( cx, global, jsb_cocos2d_Component_prototype, jsb_cocostudio_ComAttribute_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ComAttribute", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ComAttribute_class; p->proto = jsb_cocostudio_ComAttribute_prototype; p->parentProto = jsb_cocos2d_Component_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ComAudio_class; JSObject *jsb_cocostudio_ComAudio_prototype; JSBool js_cocos2dx_studio_ComAudio_stopAllEffects(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_stopAllEffects : Invalid Native Object"); if (argc == 0) { cobj->stopAllEffects(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_stopAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_getEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_getEffectsVolume : Invalid Native Object"); if (argc == 0) { double ret = cobj->getEffectsVolume(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_getEffectsVolume : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_stopEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_stopEffect : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_stopEffect : Error processing arguments"); cobj->stopEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_stopEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume : Invalid Native Object"); if (argc == 0) { double ret = cobj->getBackgroundMusicVolume(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->willPlayBackgroundMusic(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume : Error processing arguments"); cobj->setBackgroundMusicVolume(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_end(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_end : Invalid Native Object"); if (argc == 0) { cobj->end(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_end : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_stopBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::ComAudio* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_stopBackgroundMusic : Invalid Native Object"); do { if (argc == 0) { cobj->stopBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); if (!ok) { ok = JS_TRUE; break; } cobj->stopBackgroundMusic(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_stopBackgroundMusic : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_pauseBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_pauseBackgroundMusic : Invalid Native Object"); if (argc == 0) { cobj->pauseBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_pauseBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isBackgroundMusicPlaying(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_isLoop(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_isLoop : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isLoop(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_isLoop : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_resumeAllEffects(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_resumeAllEffects : Invalid Native Object"); if (argc == 0) { cobj->resumeAllEffects(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_resumeAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_pauseAllEffects(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_pauseAllEffects : Invalid Native Object"); if (argc == 0) { cobj->pauseAllEffects(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_pauseAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_preloadBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_preloadBackgroundMusic : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_preloadBackgroundMusic : Error processing arguments"); cobj->preloadBackgroundMusic(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_preloadBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_playBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::ComAudio* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_playBackgroundMusic : Invalid Native Object"); do { if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cobj->playBackgroundMusic(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } JSBool arg1; ok &= JS_ValueToBoolean(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } cobj->playBackgroundMusic(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); do { if (argc == 0) { cobj->playBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_playBackgroundMusic : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_playEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocostudio::ComAudio* cobj = NULL; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_playEffect : Invalid Native Object"); do { if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } unsigned int ret = cobj->playEffect(arg0); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } JSBool arg1; ok &= JS_ValueToBoolean(cx, argv[1], &arg1); if (!ok) { ok = JS_TRUE; break; } unsigned int ret = cobj->playEffect(arg0, arg1); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); do { if (argc == 0) { unsigned int ret = cobj->playEffect(); jsval jsret = JSVAL_NULL; jsret = uint32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while(0); JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_playEffect : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_preloadEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_preloadEffect : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_preloadEffect : Error processing arguments"); cobj->preloadEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_preloadEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_setLoop(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_setLoop : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_setLoop : Error processing arguments"); cobj->setLoop(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_setLoop : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_unloadEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_unloadEffect : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_unloadEffect : Error processing arguments"); cobj->unloadEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_unloadEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_rewindBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_rewindBackgroundMusic : Invalid Native Object"); if (argc == 0) { cobj->rewindBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_rewindBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_pauseEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_pauseEffect : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_pauseEffect : Error processing arguments"); cobj->pauseEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_pauseEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_resumeBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_resumeBackgroundMusic : Invalid Native Object"); if (argc == 0) { cobj->resumeBackgroundMusic(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_resumeBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_setFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_setFile : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_setFile : Error processing arguments"); cobj->setFile(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_setFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_setEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_setEffectsVolume : Invalid Native Object"); if (argc == 1) { double arg0; ok &= JS_ValueToNumber(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_setEffectsVolume : Error processing arguments"); cobj->setEffectsVolume(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_setEffectsVolume : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_getFile(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_getFile : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getFile(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_getFile : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_resumeEffect(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_resumeEffect : Invalid Native Object"); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComAudio_resumeEffect : Error processing arguments"); cobj->resumeEffect(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_resumeEffect : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ComAudio* ret = cocostudio::ComAudio::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ComAudio*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ComAudio_createInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Object* ret = cocostudio::ComAudio::createInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Object*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_createInstance : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Component_prototype; void js_cocostudio_ComAudio_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ComAudio)", obj); } void js_register_cocos2dx_studio_ComAudio(JSContext *cx, JSObject *global) { jsb_cocostudio_ComAudio_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ComAudio_class->name = "ComAudio"; jsb_cocostudio_ComAudio_class->addProperty = JS_PropertyStub; jsb_cocostudio_ComAudio_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ComAudio_class->getProperty = JS_PropertyStub; jsb_cocostudio_ComAudio_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ComAudio_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ComAudio_class->resolve = JS_ResolveStub; jsb_cocostudio_ComAudio_class->convert = JS_ConvertStub; jsb_cocostudio_ComAudio_class->finalize = js_cocostudio_ComAudio_finalize; jsb_cocostudio_ComAudio_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("stopAllEffects", js_cocos2dx_studio_ComAudio_stopAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEffectsVolume", js_cocos2dx_studio_ComAudio_getEffectsVolume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopEffect", js_cocos2dx_studio_ComAudio_stopEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackgroundMusicVolume", js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("willPlayBackgroundMusic", js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBackgroundMusicVolume", js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("end", js_cocos2dx_studio_ComAudio_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopBackgroundMusic", js_cocos2dx_studio_ComAudio_stopBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pauseBackgroundMusic", js_cocos2dx_studio_ComAudio_pauseBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBackgroundMusicPlaying", js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isLoop", js_cocos2dx_studio_ComAudio_isLoop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resumeAllEffects", js_cocos2dx_studio_ComAudio_resumeAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pauseAllEffects", js_cocos2dx_studio_ComAudio_pauseAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("preloadBackgroundMusic", js_cocos2dx_studio_ComAudio_preloadBackgroundMusic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("playBackgroundMusic", js_cocos2dx_studio_ComAudio_playBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("playEffect", js_cocos2dx_studio_ComAudio_playEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("preloadEffect", js_cocos2dx_studio_ComAudio_preloadEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLoop", js_cocos2dx_studio_ComAudio_setLoop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("unloadEffect", js_cocos2dx_studio_ComAudio_unloadEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("rewindBackgroundMusic", js_cocos2dx_studio_ComAudio_rewindBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pauseEffect", js_cocos2dx_studio_ComAudio_pauseEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resumeBackgroundMusic", js_cocos2dx_studio_ComAudio_resumeBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFile", js_cocos2dx_studio_ComAudio_setFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEffectsVolume", js_cocos2dx_studio_ComAudio_setEffectsVolume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFile", js_cocos2dx_studio_ComAudio_getFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resumeEffect", js_cocos2dx_studio_ComAudio_resumeEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_ComAudio_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createInstance", js_cocos2dx_studio_ComAudio_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_ComAudio_prototype = JS_InitClass( cx, global, jsb_cocos2d_Component_prototype, jsb_cocostudio_ComAudio_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ComAudio", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ComAudio_class; p->proto = jsb_cocostudio_ComAudio_prototype; p->parentProto = jsb_cocos2d_Component_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_InputDelegate_class; JSObject *jsb_cocostudio_InputDelegate_prototype; JSBool js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isAccelerometerEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_setKeypadEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setKeypadEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setKeypadEnabled : Error processing arguments"); cobj->setKeypadEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setKeypadEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_getTouchMode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_getTouchMode : Invalid Native Object"); if (argc == 0) { int ret = (int)cobj->getTouchMode(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_getTouchMode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled : Error processing arguments"); cobj->setAccelerometerEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_isKeypadEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_isKeypadEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isKeypadEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_isKeypadEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_isTouchEnabled : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isTouchEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_isTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_setTouchPriority(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setTouchPriority : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setTouchPriority : Error processing arguments"); cobj->setTouchPriority(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setTouchPriority : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_getTouchPriority(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_getTouchPriority : Invalid Native Object"); if (argc == 0) { int ret = cobj->getTouchPriority(); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_getTouchPriority : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setTouchEnabled : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setTouchEnabled : Error processing arguments"); cobj->setTouchEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_InputDelegate_setTouchMode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setTouchMode : Invalid Native Object"); if (argc == 1) { cocos2d::Touch::DispatchMode arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_InputDelegate_setTouchMode : Error processing arguments"); cobj->setTouchMode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setTouchMode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } void js_cocostudio_InputDelegate_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (InputDelegate)", obj); } void js_register_cocos2dx_studio_InputDelegate(JSContext *cx, JSObject *global) { jsb_cocostudio_InputDelegate_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_InputDelegate_class->name = "InputDelegate"; jsb_cocostudio_InputDelegate_class->addProperty = JS_PropertyStub; jsb_cocostudio_InputDelegate_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_InputDelegate_class->getProperty = JS_PropertyStub; jsb_cocostudio_InputDelegate_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_InputDelegate_class->enumerate = JS_EnumerateStub; jsb_cocostudio_InputDelegate_class->resolve = JS_ResolveStub; jsb_cocostudio_InputDelegate_class->convert = JS_ConvertStub; jsb_cocostudio_InputDelegate_class->finalize = js_cocostudio_InputDelegate_finalize; jsb_cocostudio_InputDelegate_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("isAccelerometerEnabled", js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setKeypadEnabled", js_cocos2dx_studio_InputDelegate_setKeypadEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchMode", js_cocos2dx_studio_InputDelegate_getTouchMode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAccelerometerEnabled", js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isKeypadEnabled", js_cocos2dx_studio_InputDelegate_isKeypadEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchEnabled", js_cocos2dx_studio_InputDelegate_isTouchEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchPriority", js_cocos2dx_studio_InputDelegate_setTouchPriority, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchPriority", js_cocos2dx_studio_InputDelegate_getTouchPriority, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchEnabled", js_cocos2dx_studio_InputDelegate_setTouchEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchMode", js_cocos2dx_studio_InputDelegate_setTouchMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocostudio_InputDelegate_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_InputDelegate_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "InputDelegate", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_InputDelegate_class; p->proto = jsb_cocostudio_InputDelegate_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ComController_class; JSObject *jsb_cocostudio_ComController_prototype; JSBool js_cocos2dx_studio_ComController_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ComController* ret = cocostudio::ComController::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ComController*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComController_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ComController_createInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Object* ret = cocostudio::ComController::createInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Object*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComController_createInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ComController_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::ComController* cobj = new cocostudio::ComController(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t* p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::ComController"); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComController_constructor : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_Component_prototype; void js_cocostudio_ComController_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ComController)", obj); } static JSBool js_cocostudio_ComController_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocostudio::ComController *nobj = cocostudio::ComController::create(); js_proxy_t* p = jsb_new_proxy(nobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocostudio::ComController"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_cocos2dx_studio_ComController(JSContext *cx, JSObject *global) { jsb_cocostudio_ComController_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ComController_class->name = "ComController"; jsb_cocostudio_ComController_class->addProperty = JS_PropertyStub; jsb_cocostudio_ComController_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ComController_class->getProperty = JS_PropertyStub; jsb_cocostudio_ComController_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ComController_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ComController_class->resolve = JS_ResolveStub; jsb_cocostudio_ComController_class->convert = JS_ConvertStub; jsb_cocostudio_ComController_class->finalize = js_cocostudio_ComController_finalize; jsb_cocostudio_ComController_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("ctor", js_cocostudio_ComController_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_ComController_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createInstance", js_cocos2dx_studio_ComController_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_ComController_prototype = JS_InitClass( cx, global, jsb_cocos2d_Component_prototype, jsb_cocostudio_ComController_class, js_cocos2dx_studio_ComController_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ComController", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ComController_class; p->proto = jsb_cocostudio_ComController_prototype; p->parentProto = jsb_cocos2d_Component_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_ComRender_class; JSObject *jsb_cocostudio_ComRender_prototype; JSBool js_cocos2dx_studio_ComRender_setNode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComRender* cobj = (cocostudio::ComRender *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComRender_setNode : Invalid Native Object"); if (argc == 1) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_ComRender_setNode : Error processing arguments"); cobj->setNode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComRender_setNode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_ComRender_getNode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ComRender* cobj = (cocostudio::ComRender *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_ComRender_getNode : Invalid Native Object"); if (argc == 0) { cocos2d::Node* ret = cobj->getNode(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComRender_getNode : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_studio_ComRender_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; do { if (argc == 2) { cocos2d::Node* arg0; do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); if (!ok) { ok = JS_TRUE; break; } const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { ok = JS_TRUE; break; } cocostudio::ComRender* ret = cocostudio::ComRender::create(arg0, arg1); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ComRender*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); do { if (argc == 0) { cocostudio::ComRender* ret = cocostudio::ComRender::create(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::ComRender*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } } while (0); JS_ReportError(cx, "js_cocos2dx_studio_ComRender_create : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ComRender_createInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::Object* ret = cocostudio::ComRender::createInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Object*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_ComRender_createInstance : wrong number of arguments"); return JS_FALSE; } extern JSObject *jsb_cocos2d_Component_prototype; void js_cocostudio_ComRender_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ComRender)", obj); } void js_register_cocos2dx_studio_ComRender(JSContext *cx, JSObject *global) { jsb_cocostudio_ComRender_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_ComRender_class->name = "ComRender"; jsb_cocostudio_ComRender_class->addProperty = JS_PropertyStub; jsb_cocostudio_ComRender_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_ComRender_class->getProperty = JS_PropertyStub; jsb_cocostudio_ComRender_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_ComRender_class->enumerate = JS_EnumerateStub; jsb_cocostudio_ComRender_class->resolve = JS_ResolveStub; jsb_cocostudio_ComRender_class->convert = JS_ConvertStub; jsb_cocostudio_ComRender_class->finalize = js_cocostudio_ComRender_finalize; jsb_cocostudio_ComRender_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("setNode", js_cocos2dx_studio_ComRender_setNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNode", js_cocos2dx_studio_ComRender_getNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_studio_ComRender_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createInstance", js_cocos2dx_studio_ComRender_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_ComRender_prototype = JS_InitClass( cx, global, jsb_cocos2d_Component_prototype, jsb_cocostudio_ComRender_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ComRender", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_ComRender_class; p->proto = jsb_cocostudio_ComRender_prototype; p->parentProto = jsb_cocos2d_Component_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_GUIReader_class; JSObject *jsb_cocostudio_GUIReader_prototype; JSBool js_cocos2dx_studio_GUIReader_widgetFromJsonFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::GUIReader* cobj = (cocostudio::GUIReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_GUIReader_widgetFromJsonFile : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_GUIReader_widgetFromJsonFile : Error processing arguments"); cocos2d::gui::Widget* ret = cobj->widgetFromJsonFile(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::gui::Widget*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_GUIReader_widgetFromJsonFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_GUIReader_getVersionInteger(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::GUIReader* cobj = (cocostudio::GUIReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_GUIReader_getVersionInteger : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_GUIReader_getVersionInteger : Error processing arguments"); int ret = cobj->getVersionInteger(arg0); jsval jsret = JSVAL_NULL; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_GUIReader_getVersionInteger : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_GUIReader_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::GUIReader::destroyInstance(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_GUIReader_destroyInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_GUIReader_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::GUIReader* ret = cocostudio::GUIReader::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::GUIReader*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_GUIReader_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocostudio_GUIReader_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (GUIReader)", obj); } void js_register_cocos2dx_studio_GUIReader(JSContext *cx, JSObject *global) { jsb_cocostudio_GUIReader_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_GUIReader_class->name = "GUIReader"; jsb_cocostudio_GUIReader_class->addProperty = JS_PropertyStub; jsb_cocostudio_GUIReader_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_GUIReader_class->getProperty = JS_PropertyStub; jsb_cocostudio_GUIReader_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_GUIReader_class->enumerate = JS_EnumerateStub; jsb_cocostudio_GUIReader_class->resolve = JS_ResolveStub; jsb_cocostudio_GUIReader_class->convert = JS_ConvertStub; jsb_cocostudio_GUIReader_class->finalize = js_cocostudio_GUIReader_finalize; jsb_cocostudio_GUIReader_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("widgetFromJsonFile", js_cocos2dx_studio_GUIReader_widgetFromJsonFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVersionInteger", js_cocos2dx_studio_GUIReader_getVersionInteger, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("destroyInstance", js_cocos2dx_studio_GUIReader_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_cocos2dx_studio_GUIReader_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_GUIReader_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_GUIReader_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "GUIReader", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_GUIReader_class; p->proto = jsb_cocostudio_GUIReader_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocostudio_SceneReader_class; JSObject *jsb_cocostudio_SceneReader_prototype; JSBool js_cocos2dx_studio_SceneReader_createNodeWithSceneFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::SceneReader* cobj = (cocostudio::SceneReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_SceneReader_createNodeWithSceneFile : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_SceneReader_createNodeWithSceneFile : Error processing arguments"); cocos2d::Node* ret = cobj->createNodeWithSceneFile(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_SceneReader_createNodeWithSceneFile : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_SceneReader_getNodeByTag(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::SceneReader* cobj = (cocostudio::SceneReader *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_studio_SceneReader_getNodeByTag : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_studio_SceneReader_getNodeByTag : Error processing arguments"); cocos2d::Node* ret = cobj->getNodeByTag(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_SceneReader_getNodeByTag : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_studio_SceneReader_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::SceneReader::destroyInstance(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_SceneReader_destroyInstance : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_SceneReader_sceneReaderVersion(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { const char* ret = cocostudio::SceneReader::sceneReaderVersion(); jsval jsret = JSVAL_NULL; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_SceneReader_sceneReaderVersion : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_SceneReader_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocostudio::SceneReader* ret = cocostudio::SceneReader::getInstance(); jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocostudio::SceneReader*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_studio_SceneReader_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocostudio_SceneReader_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (SceneReader)", obj); } void js_register_cocos2dx_studio_SceneReader(JSContext *cx, JSObject *global) { jsb_cocostudio_SceneReader_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocostudio_SceneReader_class->name = "SceneReader"; jsb_cocostudio_SceneReader_class->addProperty = JS_PropertyStub; jsb_cocostudio_SceneReader_class->delProperty = JS_DeletePropertyStub; jsb_cocostudio_SceneReader_class->getProperty = JS_PropertyStub; jsb_cocostudio_SceneReader_class->setProperty = JS_StrictPropertyStub; jsb_cocostudio_SceneReader_class->enumerate = JS_EnumerateStub; jsb_cocostudio_SceneReader_class->resolve = JS_ResolveStub; jsb_cocostudio_SceneReader_class->convert = JS_ConvertStub; jsb_cocostudio_SceneReader_class->finalize = js_cocostudio_SceneReader_finalize; jsb_cocostudio_SceneReader_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("createNodeWithSceneFile", js_cocos2dx_studio_SceneReader_createNodeWithSceneFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeByTag", js_cocos2dx_studio_SceneReader_getNodeByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("destroyInstance", js_cocos2dx_studio_SceneReader_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("sceneReaderVersion", js_cocos2dx_studio_SceneReader_sceneReaderVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_cocos2dx_studio_SceneReader_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocostudio_SceneReader_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocostudio_SceneReader_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "SceneReader", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocostudio_SceneReader_class; p->proto = jsb_cocostudio_SceneReader_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "ccs", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "ccs", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; js_register_cocos2dx_studio_ColliderBody(cx, obj); js_register_cocos2dx_studio_Tween(cx, obj); js_register_cocos2dx_studio_SceneReader(cx, obj); js_register_cocos2dx_studio_ComAudio(cx, obj); js_register_cocos2dx_studio_ArmatureDataManager(cx, obj); js_register_cocos2dx_studio_InputDelegate(cx, obj); js_register_cocos2dx_studio_ComController(cx, obj); js_register_cocos2dx_studio_ColliderDetector(cx, obj); js_register_cocos2dx_studio_BatchNode(cx, obj); js_register_cocos2dx_studio_ActionObject(cx, obj); js_register_cocos2dx_studio_ComRender(cx, obj); js_register_cocos2dx_studio_DisplayManager(cx, obj); js_register_cocos2dx_studio_GUIReader(cx, obj); js_register_cocos2dx_studio_ArmatureAnimation(cx, obj); js_register_cocos2dx_studio_Armature(cx, obj); js_register_cocos2dx_studio_ActionManagerEx(cx, obj); js_register_cocos2dx_studio_Bone(cx, obj); js_register_cocos2dx_studio_ComAttribute(cx, obj); js_register_cocos2dx_studio_ColliderFilter(cx, obj); js_register_cocos2dx_studio_Skin(cx, obj); js_register_cocos2dx_studio_BaseData(cx, obj); } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_studio_auto.hpp ================================================ #ifndef __cocos2dx_studio_h__ #define __cocos2dx_studio_h__ #include "jsapi.h" #include "jsfriendapi.h" extern JSClass *jsb_cocostudio_ActionObject_class; extern JSObject *jsb_cocostudio_ActionObject_prototype; JSBool js_cocos2dx_studio_ActionObject_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ActionObject_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ActionObject(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ActionObject_setCurrentTime(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_pause(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_setName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_setUnitTime(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_getTotalTime(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_getName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_stop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_play(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_getCurrentTime(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_removeActionNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_getLoop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_addActionNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_getUnitTime(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_isPlaying(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_updateToFrameByTime(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_setLoop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_simulationActionUpdate(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionObject_ActionObject(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_ActionManagerEx_class; extern JSObject *jsb_cocostudio_ActionManagerEx_prototype; JSBool js_cocos2dx_studio_ActionManagerEx_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ActionManagerEx_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ActionManagerEx(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionManagerEx_getActionByName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionManagerEx_releaseActions(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionManagerEx_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ActionManagerEx_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_BaseData_class; extern JSObject *jsb_cocostudio_BaseData_prototype; JSBool js_cocos2dx_studio_BaseData_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_BaseData_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_BaseData(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_BaseData_getColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_BaseData_setColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_BaseData_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_BaseData_BaseData(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_Tween_class; extern JSObject *jsb_cocostudio_Tween_prototype; JSBool js_cocos2dx_studio_Tween_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_Tween_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_Tween(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_Tween_getAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Tween_gotoAndPause(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Tween_play(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Tween_gotoAndPlay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Tween_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Tween_setAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Tween_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Tween_Tween(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_ColliderFilter_class; extern JSObject *jsb_cocostudio_ColliderFilter_prototype; JSBool js_cocos2dx_studio_ColliderFilter_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ColliderFilter_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ColliderFilter(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocostudio_ColliderBody_class; extern JSObject *jsb_cocostudio_ColliderBody_prototype; JSBool js_cocos2dx_studio_ColliderBody_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ColliderBody_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ColliderBody(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); extern JSClass *jsb_cocostudio_ColliderDetector_class; extern JSObject *jsb_cocostudio_ColliderDetector_prototype; JSBool js_cocos2dx_studio_ColliderDetector_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ColliderDetector_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ColliderDetector(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ColliderDetector_getBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ColliderDetector_getActive(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ColliderDetector_getColliderBodyList(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ColliderDetector_updateTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ColliderDetector_removeAll(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ColliderDetector_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ColliderDetector_setActive(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ColliderDetector_setBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ColliderDetector_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_DisplayManager_class; extern JSObject *jsb_cocostudio_DisplayManager_prototype; JSBool js_cocos2dx_studio_DisplayManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_DisplayManager_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_DisplayManager(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_DisplayManager_getDisplayRenderNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_removeDisplay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_setForceChangeDisplay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_getContentSize(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_containPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_changeDisplayWithName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_isForceChangeDisplay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_isVisible(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_setVisible(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_DisplayManager_DisplayManager(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_Bone_class; extern JSObject *jsb_cocostudio_Bone_prototype; JSBool js_cocos2dx_studio_Bone_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_Bone_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_Bone(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_Bone_isTransformDirty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_isIgnoreMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_updateZOrder(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getDisplayRenderNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_isBlendDirty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_addChildBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getWorldInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getTween(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getParentBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_updateColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_setTransformDirty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getDisplayRenderNodeType(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_removeDisplay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_setBoneData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_setParentBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_setIgnoreMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_setName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_removeFromParent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getColliderDetector(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getChildArmature(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_changeDisplayWithIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_changeDisplayWithName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_setArmature(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_setBlendDirty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_removeChildBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_setChildArmature(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getNodeToArmatureTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getDisplayManager(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_getArmature(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Bone_Bone(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_BatchNode_class; extern JSObject *jsb_cocostudio_BatchNode_prototype; JSBool js_cocos2dx_studio_BatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_BatchNode_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_BatchNode(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_BatchNode_create(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_ArmatureAnimation_class; extern JSObject *jsb_cocostudio_ArmatureAnimation_prototype; JSBool js_cocos2dx_studio_ArmatureAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ArmatureAnimation_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ArmatureAnimation(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ArmatureAnimation_getSpeedScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_pause(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_setSpeedScale(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_playWithIndexes(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_play(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_gotoAndPause(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_resume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_stop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_update(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_playWithIndex(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_playWithNames(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_getMovementCount(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureAnimation_ArmatureAnimation(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_ArmatureDataManager_class; extern JSObject *jsb_cocostudio_ArmatureDataManager_prototype; JSBool js_cocos2dx_studio_ArmatureDataManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ArmatureDataManager_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ArmatureDataManager(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_removeAnimationData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_addArmatureData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_getTextureData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_getArmatureData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_getAnimationData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_addAnimationData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_removeArmatureData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_removeTextureData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_addTextureData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ArmatureDataManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_Armature_class; extern JSObject *jsb_cocostudio_Armature_prototype; JSBool js_cocos2dx_studio_Armature_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_Armature_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_Armature(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_Armature_getBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_changeBoneParent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_setAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getBoneAtPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getArmatureTransformDirty(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_setVersion(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_updateOffsetPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getParentBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_setArmatureData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_removeBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_init(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_setParentBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_drawContour(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_setName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_addBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getArmatureData(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getVersion(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getAnimation(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_getBoneDic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Armature_Armature(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_Skin_class; extern JSObject *jsb_cocostudio_Skin_prototype; JSBool js_cocos2dx_studio_Skin_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_Skin_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_Skin(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_Skin_getBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_getNodeToWorldTransformAR(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_getDisplayName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_updateArmatureTransform(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_setBone(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_Skin_Skin(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_ComAttribute_class; extern JSObject *jsb_cocostudio_ComAttribute_prototype; JSBool js_cocos2dx_studio_ComAttribute_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ComAttribute_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ComAttribute(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ComAttribute_getFloat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_getString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_setFloat(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_setString(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_getBool(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_setInt(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_parse(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_getInt(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_setBool(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAttribute_createInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_ComAudio_class; extern JSObject *jsb_cocostudio_ComAudio_prototype; JSBool js_cocos2dx_studio_ComAudio_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ComAudio_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ComAudio(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ComAudio_stopAllEffects(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_getEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_stopEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_end(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_stopBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_pauseBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_isLoop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_resumeAllEffects(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_pauseAllEffects(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_preloadBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_playBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_playEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_preloadEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_setLoop(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_unloadEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_rewindBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_pauseEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_resumeBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_setFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_setEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_getFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_resumeEffect(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComAudio_createInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_InputDelegate_class; extern JSObject *jsb_cocostudio_InputDelegate_prototype; JSBool js_cocos2dx_studio_InputDelegate_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_InputDelegate_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_InputDelegate(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_setKeypadEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_getTouchMode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_isKeypadEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_setTouchPriority(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_getTouchPriority(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_InputDelegate_setTouchMode(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_ComController_class; extern JSObject *jsb_cocostudio_ComController_prototype; JSBool js_cocos2dx_studio_ComController_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ComController_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ComController(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ComController_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComController_createInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComController_ComController(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_ComRender_class; extern JSObject *jsb_cocostudio_ComRender_prototype; JSBool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_ComRender_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ComRender(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_ComRender_setNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComRender_getNode(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComRender_create(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_ComRender_createInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_GUIReader_class; extern JSObject *jsb_cocostudio_GUIReader_prototype; JSBool js_cocos2dx_studio_GUIReader_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_GUIReader_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_GUIReader(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_GUIReader_widgetFromJsonFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_GUIReader_getVersionInteger(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_GUIReader_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_GUIReader_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocostudio_SceneReader_class; extern JSObject *jsb_cocostudio_SceneReader_prototype; JSBool js_cocos2dx_studio_SceneReader_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_studio_SceneReader_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_SceneReader(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); JSBool js_cocos2dx_studio_SceneReader_createNodeWithSceneFile(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_SceneReader_getNodeByTag(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_SceneReader_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_SceneReader_sceneReaderVersion(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_cocos2dx_studio_SceneReader_getInstance(JSContext *cx, uint32_t argc, jsval *vp); #endif ================================================ FILE: cocos2d/cocos/scripting/auto-generated/js-bindings/jsb_cocos2dx_studio_auto_api.js ================================================ /** * @module cocos2dx_studio */ var ccs = ccs || {}; /** * @class ActionObject */ ccs.ActionObject = { /** * @method setCurrentTime * @param {float} */ setCurrentTime : function () {}, /** * @method pause */ pause : function () {}, /** * @method setName * @param {const char*} */ setName : function () {}, /** * @method setUnitTime * @param {float} */ setUnitTime : function () {}, /** * @method getTotalTime * @return A value converted from C/C++ "float" */ getTotalTime : function () {}, /** * @method getName * @return A value converted from C/C++ "const char*" */ getName : function () {}, /** * @method stop */ stop : function () {}, /** * @method getCurrentTime * @return A value converted from C/C++ "float" */ getCurrentTime : function () {}, /** * @method removeActionNode * @param {cocostudio::ActionNode*} */ removeActionNode : function () {}, /** * @method getLoop * @return A value converted from C/C++ "bool" */ getLoop : function () {}, /** * @method addActionNode * @param {cocostudio::ActionNode*} */ addActionNode : function () {}, /** * @method getUnitTime * @return A value converted from C/C++ "float" */ getUnitTime : function () {}, /** * @method isPlaying * @return A value converted from C/C++ "bool" */ isPlaying : function () {}, /** * @method updateToFrameByTime * @param {float} */ updateToFrameByTime : function () {}, /** * @method setLoop * @param {bool} */ setLoop : function () {}, /** * @method simulationActionUpdate * @param {float} */ simulationActionUpdate : function () {}, /** * @method ActionObject * @constructor */ ActionObject : function () {}, }; /** * @class ActionManagerEx */ ccs.ActionManager = { /** * @method getActionByName * @return A value converted from C/C++ "cocostudio::ActionObject*" * @param {const char*} * @param {const char*} */ getActionByName : function () {}, /** * @method releaseActions */ releaseActions : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocostudio::ActionManagerEx*" */ getInstance : function () {}, }; /** * @class BaseData */ ccs.BaseData = { /** * @method getColor * @return A value converted from C/C++ "cocos2d::Color4B" */ getColor : function () {}, /** * @method setColor * @param {const cocos2d::Color4B&} */ setColor : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::BaseData*" */ create : function () {}, /** * @method BaseData * @constructor */ BaseData : function () {}, }; /** * @class Tween */ ccs.Tween = { /** * @method getAnimation * @return A value converted from C/C++ "cocostudio::ArmatureAnimation*" */ getAnimation : function () {}, /** * @method gotoAndPause * @param {int} */ gotoAndPause : function () {}, /** * @method play * @param {cocostudio::MovementBoneData*} * @param {int} * @param {int} * @param {int} * @param {int} */ play : function () {}, /** * @method gotoAndPlay * @param {int} */ gotoAndPlay : function () {}, /** * @method init * @return A value converted from C/C++ "bool" * @param {cocostudio::Bone*} */ init : function () {}, /** * @method setAnimation * @param {cocostudio::ArmatureAnimation*} */ setAnimation : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::Tween*" * @param {cocostudio::Bone*} */ create : function () {}, /** * @method Tween * @constructor */ Tween : function () {}, }; /** * @class ColliderFilter */ ccs.ColliderFilter = { }; /** * @class ColliderBody */ ccs.ColliderBody = { }; /** * @class ColliderDetector */ ccs.ColliderDetector = { /** * @method getBone * @return A value converted from C/C++ "cocostudio::Bone*" */ getBone : function () {}, /** * @method getActive * @return A value converted from C/C++ "bool" */ getActive : function () {}, /** * @method getColliderBodyList * @return A value converted from C/C++ "const cocos2d::Vector&" */ getColliderBodyList : function () {}, /** * @method updateTransform * @param {kmMat4&} */ updateTransform : function () {}, /** * @method removeAll */ removeAll : function () {}, /** * @method setActive * @param {bool} */ setActive : function () {}, /** * @method setBone * @param {cocostudio::Bone*} */ setBone : function () {}, }; /** * @class DisplayManager */ ccs.DisplayManager = { /** * @method getDisplayRenderNode * @return A value converted from C/C++ "cocos2d::Node*" */ getDisplayRenderNode : function () {}, /** * @method getAnchorPointInPoints * @return A value converted from C/C++ "cocos2d::Point" */ getAnchorPointInPoints : function () {}, /** * @method getDisplayRenderNodeType * @return A value converted from C/C++ "cocostudio::DisplayType" */ getDisplayRenderNodeType : function () {}, /** * @method removeDisplay * @param {int} */ removeDisplay : function () {}, /** * @method setForceChangeDisplay * @param {bool} */ setForceChangeDisplay : function () {}, /** * @method init * @return A value converted from C/C++ "bool" * @param {cocostudio::Bone*} */ init : function () {}, /** * @method getContentSize * @return A value converted from C/C++ "cocos2d::Size" */ getContentSize : function () {}, /** * @method getBoundingBox * @return A value converted from C/C++ "cocos2d::Rect" */ getBoundingBox : function () {}, /** * @method changeDisplayWithIndex * @param {int} * @param {bool} */ changeDisplayWithIndex : function () {}, /** * @method changeDisplayWithName * @param {const std::string&} * @param {bool} */ changeDisplayWithName : function () {}, /** * @method isForceChangeDisplay * @return A value converted from C/C++ "bool" */ isForceChangeDisplay : function () {}, /** * @method getCurrentDisplayIndex * @return A value converted from C/C++ "int" */ getCurrentDisplayIndex : function () {}, /** * @method getAnchorPoint * @return A value converted from C/C++ "cocos2d::Point" */ getAnchorPoint : function () {}, /** * @method getDecorativeDisplayList * @return A value converted from C/C++ "const cocos2d::Vector&" */ getDecorativeDisplayList : function () {}, /** * @method isVisible * @return A value converted from C/C++ "bool" */ isVisible : function () {}, /** * @method setVisible * @param {bool} */ setVisible : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::DisplayManager*" * @param {cocostudio::Bone*} */ create : function () {}, /** * @method DisplayManager * @constructor */ DisplayManager : function () {}, }; /** * @class Bone */ ccs.Bone = { /** * @method isTransformDirty * @return A value converted from C/C++ "bool" */ isTransformDirty : function () {}, /** * @method isIgnoreMovementBoneData * @return A value converted from C/C++ "bool" */ isIgnoreMovementBoneData : function () {}, /** * @method updateZOrder */ updateZOrder : function () {}, /** * @method getDisplayRenderNode * @return A value converted from C/C++ "cocos2d::Node*" */ getDisplayRenderNode : function () {}, /** * @method isBlendDirty * @return A value converted from C/C++ "bool" */ isBlendDirty : function () {}, /** * @method addChildBone * @param {cocostudio::Bone*} */ addChildBone : function () {}, /** * @method getWorldInfo * @return A value converted from C/C++ "cocostudio::BaseData*" */ getWorldInfo : function () {}, /** * @method getTween * @return A value converted from C/C++ "cocostudio::Tween*" */ getTween : function () {}, /** * @method getParentBone * @return A value converted from C/C++ "cocostudio::Bone*" */ getParentBone : function () {}, /** * @method updateColor */ updateColor : function () {}, /** * @method getName * @return A value converted from C/C++ "const std::string" */ getName : function () {}, /** * @method setTransformDirty * @param {bool} */ setTransformDirty : function () {}, /** * @method getDisplayRenderNodeType * @return A value converted from C/C++ "cocostudio::DisplayType" */ getDisplayRenderNodeType : function () {}, /** * @method removeDisplay * @param {int} */ removeDisplay : function () {}, /** * @method setBoneData * @param {cocostudio::BoneData*} */ setBoneData : function () {}, /** * @method setParentBone * @param {cocostudio::Bone*} */ setParentBone : function () {}, /** * @method setIgnoreMovementBoneData * @param {bool} */ setIgnoreMovementBoneData : function () {}, /** * @method setName * @param {const std::string&} */ setName : function () {}, /** * @method removeFromParent * @param {bool} */ removeFromParent : function () {}, /** * @method getColliderDetector * @return A value converted from C/C++ "cocostudio::ColliderDetector*" */ getColliderDetector : function () {}, /** * @method getChildArmature * @return A value converted from C/C++ "cocostudio::Armature*" */ getChildArmature : function () {}, /** * @method changeDisplayWithIndex * @param {int} * @param {bool} */ changeDisplayWithIndex : function () {}, /** * @method changeDisplayWithName * @param {const std::string&} * @param {bool} */ changeDisplayWithName : function () {}, /** * @method setArmature * @param {cocostudio::Armature*} */ setArmature : function () {}, /** * @method setBlendDirty * @param {bool} */ setBlendDirty : function () {}, /** * @method removeChildBone * @param {cocostudio::Bone*} * @param {bool} */ removeChildBone : function () {}, /** * @method setChildArmature * @param {cocostudio::Armature*} */ setChildArmature : function () {}, /** * @method getNodeToArmatureTransform * @return A value converted from C/C++ "kmMat4" */ getNodeToArmatureTransform : function () {}, /** * @method getDisplayManager * @return A value converted from C/C++ "cocostudio::DisplayManager*" */ getDisplayManager : function () {}, /** * @method getArmature * @return A value converted from C/C++ "cocostudio::Armature*" */ getArmature : function () {}, /** * @method Bone * @constructor */ Bone : function () {}, }; /** * @class BatchNode */ ccs.BatchNode = { /** * @method create * @return A value converted from C/C++ "cocostudio::BatchNode*" */ create : function () {}, }; /** * @class ArmatureAnimation */ ccs.ArmatureAnimation = { /** * @method getSpeedScale * @return A value converted from C/C++ "float" */ getSpeedScale : function () {}, /** * @method pause */ pause : function () {}, /** * @method setSpeedScale * @param {float} */ setSpeedScale : function () {}, /** * @method init * @return A value converted from C/C++ "bool" * @param {cocostudio::Armature*} */ init : function () {}, /** * @method playWithIndexes * @param {const std::vector >&} * @param {int} * @param {bool} */ playWithIndexes : function () {}, /** * @method play * @param {const std::string&} * @param {int} * @param {int} */ play : function () {}, /** * @method gotoAndPause * @param {int} */ gotoAndPause : function () {}, /** * @method resume */ resume : function () {}, /** * @method stop */ stop : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method playWithIndex * @param {int} * @param {int} * @param {int} */ playWithIndex : function () {}, /** * @method getCurrentMovementID * @return A value converted from C/C++ "std::string" */ getCurrentMovementID : function () {}, /** * @method gotoAndPlay * @param {int} */ gotoAndPlay : function () {}, /** * @method playWithNames * @param {const std::vector, std::allocator > >&} * @param {int} * @param {bool} */ playWithNames : function () {}, /** * @method getMovementCount * @return A value converted from C/C++ "ssize_t" */ getMovementCount : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::ArmatureAnimation*" * @param {cocostudio::Armature*} */ create : function () {}, /** * @method ArmatureAnimation * @constructor */ ArmatureAnimation : function () {}, }; /** * @class ArmatureDataManager */ ccs.ArmatureDataManager = { /** * @method getAnimationDatas * @return A value converted from C/C++ "const cocos2d::Map, cocostudio::AnimationData *>&" */ getAnimationDatas : function () {}, /** * @method removeAnimationData * @param {const std::string&} */ removeAnimationData : function () {}, /** * @method addArmatureData * @param {const std::string&} * @param {cocostudio::ArmatureData*} * @param {const std::string&} */ addArmatureData : function () {}, /** * @method removeArmatureFileInfo * @param {const std::string&} */ removeArmatureFileInfo : function () {}, /** * @method getTextureData * @return A value converted from C/C++ "cocostudio::TextureData*" * @param {const std::string&} */ getTextureData : function () {}, /** * @method getArmatureData * @return A value converted from C/C++ "cocostudio::ArmatureData*" * @param {const std::string&} */ getArmatureData : function () {}, /** * @method getAnimationData * @return A value converted from C/C++ "cocostudio::AnimationData*" * @param {const std::string&} */ getAnimationData : function () {}, /** * @method addAnimationData * @param {const std::string&} * @param {cocostudio::AnimationData*} * @param {const std::string&} */ addAnimationData : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method removeArmatureData * @param {const std::string&} */ removeArmatureData : function () {}, /** * @method getArmatureDatas * @return A value converted from C/C++ "const cocos2d::Map, cocostudio::ArmatureData *>&" */ getArmatureDatas : function () {}, /** * @method removeTextureData * @param {const std::string&} */ removeTextureData : function () {}, /** * @method addTextureData * @param {const std::string&} * @param {cocostudio::TextureData*} * @param {const std::string&} */ addTextureData : function () {}, /** * @method isAutoLoadSpriteFile * @return A value converted from C/C++ "bool" */ isAutoLoadSpriteFile : function () {}, /** * @method addSpriteFrameFromFile * @param {const std::string&} * @param {const std::string&} * @param {const std::string&} */ addSpriteFrameFromFile : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocostudio::ArmatureDataManager*" */ getInstance : function () {}, }; /** * @class Armature */ ccs.Armature = { /** * @method getBone * @return A value converted from C/C++ "cocostudio::Bone*" * @param {const std::string&} */ getBone : function () {}, /** * @method changeBoneParent * @param {cocostudio::Bone*} * @param {const std::string&} */ changeBoneParent : function () {}, /** * @method setAnimation * @param {cocostudio::ArmatureAnimation*} */ setAnimation : function () {}, /** * @method getBoneAtPoint * @return A value converted from C/C++ "cocostudio::Bone*" * @param {float} * @param {float} */ getBoneAtPoint : function () {}, /** * @method getArmatureTransformDirty * @return A value converted from C/C++ "bool" */ getArmatureTransformDirty : function () {}, /** * @method setVersion * @param {float} */ setVersion : function () {}, /** * @method updateOffsetPoint */ updateOffsetPoint : function () {}, /** * @method getParentBone * @return A value converted from C/C++ "cocostudio::Bone*" */ getParentBone : function () {}, /** * @method setArmatureData * @param {cocostudio::ArmatureData*} */ setArmatureData : function () {}, /** * @method removeBone * @param {cocostudio::Bone*} * @param {bool} */ removeBone : function () {}, /** * @method getBatchNode * @return A value converted from C/C++ "cocostudio::BatchNode*" */ getBatchNode : function () {}, /** * @method getName * @return A value converted from C/C++ "const std::string&" */ getName : function () {}, /** * @method setParentBone * @param {cocostudio::Bone*} */ setParentBone : function () {}, /** * @method drawContour */ drawContour : function () {}, /** * @method setBatchNode * @param {cocostudio::BatchNode*} */ setBatchNode : function () {}, /** * @method setName * @param {const std::string&} */ setName : function () {}, /** * @method addBone * @param {cocostudio::Bone*} * @param {const std::string&} */ addBone : function () {}, /** * @method getArmatureData * @return A value converted from C/C++ "cocostudio::ArmatureData*" */ getArmatureData : function () {}, /** * @method getVersion * @return A value converted from C/C++ "float" */ getVersion : function () {}, /** * @method getAnimation * @return A value converted from C/C++ "cocostudio::ArmatureAnimation*" */ getAnimation : function () {}, /** * @method getBoneDic * @return A value converted from C/C++ "const cocos2d::Map, cocostudio::Bone *>&" */ getBoneDic : function () {}, /** * @method Armature * @constructor */ Armature : function () {}, }; /** * @class Skin */ ccs.Skin = { /** * @method getBone * @return A value converted from C/C++ "cocostudio::Bone*" */ getBone : function () {}, /** * @method getNodeToWorldTransformAR * @return A value converted from C/C++ "kmMat4" */ getNodeToWorldTransformAR : function () {}, /** * @method initWithFile * @return A value converted from C/C++ "bool" * @param {const std::string&} */ initWithFile : function () {}, /** * @method getDisplayName * @return A value converted from C/C++ "const std::string&" */ getDisplayName : function () {}, /** * @method updateArmatureTransform */ updateArmatureTransform : function () {}, /** * @method initWithSpriteFrameName * @return A value converted from C/C++ "bool" * @param {const std::string&} */ initWithSpriteFrameName : function () {}, /** * @method setBone * @param {cocostudio::Bone*} */ setBone : function () {}, /** * @method createWithSpriteFrameName * @return A value converted from C/C++ "cocostudio::Skin*" * @param {const std::string&} */ createWithSpriteFrameName : function () {}, /** * @method Skin * @constructor */ Skin : function () {}, }; /** * @class ComAttribute */ ccs.ComAttribute = { /** * @method getFloat * @return A value converted from C/C++ "float" * @param {const std::string&} * @param {float} */ getFloat : function () {}, /** * @method getString * @return A value converted from C/C++ "std::string" * @param {const std::string&} * @param {const std::string&} */ getString : function () {}, /** * @method setFloat * @param {const std::string&} * @param {float} */ setFloat : function () {}, /** * @method setString * @param {const std::string&} * @param {const std::string&} */ setString : function () {}, /** * @method getBool * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {bool} */ getBool : function () {}, /** * @method setInt * @param {const std::string&} * @param {int} */ setInt : function () {}, /** * @method parse * @return A value converted from C/C++ "bool" * @param {const std::string&} */ parse : function () {}, /** * @method getInt * @return A value converted from C/C++ "int" * @param {const std::string&} * @param {int} */ getInt : function () {}, /** * @method setBool * @param {const std::string&} * @param {bool} */ setBool : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::ComAttribute*" */ create : function () {}, /** * @method createInstance * @return A value converted from C/C++ "cocos2d::Object*" */ createInstance : function () {}, }; /** * @class ComAudio */ ccs.ComAudio = { /** * @method stopAllEffects */ stopAllEffects : function () {}, /** * @method getEffectsVolume * @return A value converted from C/C++ "float" */ getEffectsVolume : function () {}, /** * @method stopEffect * @param {unsigned int} */ stopEffect : function () {}, /** * @method getBackgroundMusicVolume * @return A value converted from C/C++ "float" */ getBackgroundMusicVolume : function () {}, /** * @method willPlayBackgroundMusic * @return A value converted from C/C++ "bool" */ willPlayBackgroundMusic : function () {}, /** * @method setBackgroundMusicVolume * @param {float} */ setBackgroundMusicVolume : function () {}, /** * @method end */ end : function () {}, /** * @method pauseBackgroundMusic */ pauseBackgroundMusic : function () {}, /** * @method isBackgroundMusicPlaying * @return A value converted from C/C++ "bool" */ isBackgroundMusicPlaying : function () {}, /** * @method isLoop * @return A value converted from C/C++ "bool" */ isLoop : function () {}, /** * @method resumeAllEffects */ resumeAllEffects : function () {}, /** * @method pauseAllEffects */ pauseAllEffects : function () {}, /** * @method preloadBackgroundMusic * @param {const char*} */ preloadBackgroundMusic : function () {}, /** * @method preloadEffect * @param {const char*} */ preloadEffect : function () {}, /** * @method setLoop * @param {bool} */ setLoop : function () {}, /** * @method unloadEffect * @param {const char*} */ unloadEffect : function () {}, /** * @method rewindBackgroundMusic */ rewindBackgroundMusic : function () {}, /** * @method pauseEffect * @param {unsigned int} */ pauseEffect : function () {}, /** * @method resumeBackgroundMusic */ resumeBackgroundMusic : function () {}, /** * @method setFile * @param {const char*} */ setFile : function () {}, /** * @method setEffectsVolume * @param {float} */ setEffectsVolume : function () {}, /** * @method getFile * @return A value converted from C/C++ "const char*" */ getFile : function () {}, /** * @method resumeEffect * @param {unsigned int} */ resumeEffect : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::ComAudio*" */ create : function () {}, /** * @method createInstance * @return A value converted from C/C++ "cocos2d::Object*" */ createInstance : function () {}, }; /** * @class InputDelegate */ ccs.InputDelegate = { /** * @method isAccelerometerEnabled * @return A value converted from C/C++ "bool" */ isAccelerometerEnabled : function () {}, /** * @method setKeypadEnabled * @param {bool} */ setKeypadEnabled : function () {}, /** * @method getTouchMode * @return A value converted from C/C++ "cocos2d::Touch::DispatchMode" */ getTouchMode : function () {}, /** * @method setAccelerometerEnabled * @param {bool} */ setAccelerometerEnabled : function () {}, /** * @method isKeypadEnabled * @return A value converted from C/C++ "bool" */ isKeypadEnabled : function () {}, /** * @method isTouchEnabled * @return A value converted from C/C++ "bool" */ isTouchEnabled : function () {}, /** * @method setTouchPriority * @param {int} */ setTouchPriority : function () {}, /** * @method getTouchPriority * @return A value converted from C/C++ "int" */ getTouchPriority : function () {}, /** * @method setTouchEnabled * @param {bool} */ setTouchEnabled : function () {}, /** * @method setTouchMode * @param {cocos2d::Touch::DispatchMode} */ setTouchMode : function () {}, }; /** * @class ComController */ ccs.ComController = { /** * @method create * @return A value converted from C/C++ "cocostudio::ComController*" */ create : function () {}, /** * @method createInstance * @return A value converted from C/C++ "cocos2d::Object*" */ createInstance : function () {}, /** * @method ComController * @constructor */ ComController : function () {}, }; /** * @class ComRender */ ccs.ComRender = { /** * @method setNode * @param {cocos2d::Node*} */ setNode : function () {}, /** * @method getNode * @return A value converted from C/C++ "cocos2d::Node*" */ getNode : function () {}, /** * @method createInstance * @return A value converted from C/C++ "cocos2d::Object*" */ createInstance : function () {}, }; /** * @class GUIReader */ ccs.GUIReader = { /** * @method widgetFromJsonFile * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {const char*} */ widgetFromJsonFile : function () {}, /** * @method getVersionInteger * @return A value converted from C/C++ "int" * @param {const char*} */ getVersionInteger : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocostudio::GUIReader*" */ getInstance : function () {}, }; /** * @class SceneReader */ ccs.SceneReader = { /** * @method createNodeWithSceneFile * @return A value converted from C/C++ "cocos2d::Node*" * @param {const std::string&} */ createNodeWithSceneFile : function () {}, /** * @method getNodeByTag * @return A value converted from C/C++ "cocos2d::Node*" * @param {int} */ getNodeByTag : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method sceneReaderVersion * @return A value converted from C/C++ "const char*" */ sceneReaderVersion : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocostudio::SceneReader*" */ getInstance : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_auto.cpp ================================================ #include "lua_cocos2dx_auto.hpp" #include "cocos2d.h" #include "SimpleAudioEngine.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" int lua_cocos2dx_Object_getReferenceCount(lua_State* tolua_S) { int argc = 0; cocos2d::Object* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Object",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Object*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Object_getReferenceCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned int ret = cobj->getReferenceCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getReferenceCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Object_getReferenceCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Object_release(lua_State* tolua_S) { int argc = 0; cocos2d::Object* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Object",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Object*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Object_release'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->release(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "release",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Object_release'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Object_retain(lua_State* tolua_S) { int argc = 0; cocos2d::Object* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Object",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Object*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Object_retain'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->retain(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "retain",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Object_retain'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Object_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Object* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Object(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Object"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Object"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Object",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Object_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Object_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Object)"); return 0; } int lua_register_cocos2dx_Object(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Object"); tolua_cclass(tolua_S,"Object","cc.Object","",NULL); tolua_beginmodule(tolua_S,"Object"); tolua_function(tolua_S,"getReferenceCount",lua_cocos2dx_Object_getReferenceCount); tolua_function(tolua_S,"release",lua_cocos2dx_Object_release); tolua_function(tolua_S,"retain",lua_cocos2dx_Object_retain); tolua_function(tolua_S,"new",lua_cocos2dx_Object_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Object).name(); g_luaType[typeName] = "cc.Object"; g_typeCast["Object"] = "cc.Object"; return 1; } int lua_cocos2dx_Action_startWithTarget(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_startWithTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->startWithTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "startWithTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_startWithTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_setOriginalTarget(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_setOriginalTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setOriginalTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOriginalTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_setOriginalTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_clone(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_clone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Action* ret = cobj->clone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Action"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Action*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_clone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_getOriginalTarget(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_getOriginalTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getOriginalTarget(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOriginalTarget",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_getOriginalTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_stop(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_stop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stop(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stop",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_stop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_update(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_update'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->update(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "update",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_update'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_getTarget(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_getTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getTarget(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTarget",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_getTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_step(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_step'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->step(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "step",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_step'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_setTag(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_setTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setTag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_setTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_getTag(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_getTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getTag(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTag",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_getTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_setTarget(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_setTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_setTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_isDone(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_isDone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isDone(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isDone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_isDone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Action_reverse(lua_State* tolua_S) { int argc = 0; cocos2d::Action* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Action",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Action*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Action_reverse'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Action* ret = cobj->reverse(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Action"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Action*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reverse",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Action_reverse'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Action_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Action)"); return 0; } int lua_register_cocos2dx_Action(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Action"); tolua_cclass(tolua_S,"Action","cc.Action","cc.Object",NULL); tolua_beginmodule(tolua_S,"Action"); tolua_function(tolua_S,"startWithTarget",lua_cocos2dx_Action_startWithTarget); tolua_function(tolua_S,"setOriginalTarget",lua_cocos2dx_Action_setOriginalTarget); tolua_function(tolua_S,"clone",lua_cocos2dx_Action_clone); tolua_function(tolua_S,"getOriginalTarget",lua_cocos2dx_Action_getOriginalTarget); tolua_function(tolua_S,"stop",lua_cocos2dx_Action_stop); tolua_function(tolua_S,"update",lua_cocos2dx_Action_update); tolua_function(tolua_S,"getTarget",lua_cocos2dx_Action_getTarget); tolua_function(tolua_S,"step",lua_cocos2dx_Action_step); tolua_function(tolua_S,"setTag",lua_cocos2dx_Action_setTag); tolua_function(tolua_S,"getTag",lua_cocos2dx_Action_getTag); tolua_function(tolua_S,"setTarget",lua_cocos2dx_Action_setTarget); tolua_function(tolua_S,"isDone",lua_cocos2dx_Action_isDone); tolua_function(tolua_S,"reverse",lua_cocos2dx_Action_reverse); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Action).name(); g_luaType[typeName] = "cc.Action"; g_typeCast["Action"] = "cc.Action"; return 1; } int lua_cocos2dx_FiniteTimeAction_setDuration(lua_State* tolua_S) { int argc = 0; cocos2d::FiniteTimeAction* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FiniteTimeAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FiniteTimeAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FiniteTimeAction_setDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDuration(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDuration",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FiniteTimeAction_setDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FiniteTimeAction_getDuration(lua_State* tolua_S) { int argc = 0; cocos2d::FiniteTimeAction* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FiniteTimeAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FiniteTimeAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FiniteTimeAction_getDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDuration(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDuration",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FiniteTimeAction_getDuration'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FiniteTimeAction_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FiniteTimeAction)"); return 0; } int lua_register_cocos2dx_FiniteTimeAction(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FiniteTimeAction"); tolua_cclass(tolua_S,"FiniteTimeAction","cc.FiniteTimeAction","cc.Action",NULL); tolua_beginmodule(tolua_S,"FiniteTimeAction"); tolua_function(tolua_S,"setDuration",lua_cocos2dx_FiniteTimeAction_setDuration); tolua_function(tolua_S,"getDuration",lua_cocos2dx_FiniteTimeAction_getDuration); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FiniteTimeAction).name(); g_luaType[typeName] = "cc.FiniteTimeAction"; g_typeCast["FiniteTimeAction"] = "cc.FiniteTimeAction"; return 1; } int lua_cocos2dx_Speed_setInnerAction(lua_State* tolua_S) { int argc = 0; cocos2d::Speed* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Speed",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Speed*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Speed_setInnerAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setInnerAction(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInnerAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Speed_setInnerAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Speed_setSpeed(lua_State* tolua_S) { int argc = 0; cocos2d::Speed* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Speed",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Speed*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Speed_setSpeed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSpeed(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSpeed",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Speed_setSpeed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Speed_getInnerAction(lua_State* tolua_S) { int argc = 0; cocos2d::Speed* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Speed",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Speed*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Speed_getInnerAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->getInnerAction(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInnerAction",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Speed_getInnerAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Speed_getSpeed(lua_State* tolua_S) { int argc = 0; cocos2d::Speed* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Speed",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Speed*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Speed_getSpeed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSpeed(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSpeed",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Speed_getSpeed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Speed_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Speed",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::ActionInterval* arg0; double arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::Speed* ret = cocos2d::Speed::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Speed"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Speed*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Speed_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Speed_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Speed)"); return 0; } int lua_register_cocos2dx_Speed(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Speed"); tolua_cclass(tolua_S,"Speed","cc.Speed","cc.Action",NULL); tolua_beginmodule(tolua_S,"Speed"); tolua_function(tolua_S,"setInnerAction",lua_cocos2dx_Speed_setInnerAction); tolua_function(tolua_S,"setSpeed",lua_cocos2dx_Speed_setSpeed); tolua_function(tolua_S,"getInnerAction",lua_cocos2dx_Speed_getInnerAction); tolua_function(tolua_S,"getSpeed",lua_cocos2dx_Speed_getSpeed); tolua_function(tolua_S,"create", lua_cocos2dx_Speed_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Speed).name(); g_luaType[typeName] = "cc.Speed"; g_typeCast["Speed"] = "cc.Speed"; return 1; } int lua_cocos2dx_Follow_setBoudarySet(lua_State* tolua_S) { int argc = 0; cocos2d::Follow* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Follow",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Follow*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Follow_setBoudarySet'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBoudarySet(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBoudarySet",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_setBoudarySet'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Follow_isBoundarySet(lua_State* tolua_S) { int argc = 0; cocos2d::Follow* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Follow",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Follow*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Follow_isBoundarySet'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isBoundarySet(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isBoundarySet",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_isBoundarySet'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Follow_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Follow",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Follow* ret = cocos2d::Follow::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Follow"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Follow*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Node* arg0; cocos2d::Rect arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_rect(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::Follow* ret = cocos2d::Follow::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Follow"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Follow*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Follow_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Follow_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Follow)"); return 0; } int lua_register_cocos2dx_Follow(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Follow"); tolua_cclass(tolua_S,"Follow","cc.Follow","cc.Action",NULL); tolua_beginmodule(tolua_S,"Follow"); tolua_function(tolua_S,"setBoudarySet",lua_cocos2dx_Follow_setBoudarySet); tolua_function(tolua_S,"isBoundarySet",lua_cocos2dx_Follow_isBoundarySet); tolua_function(tolua_S,"create", lua_cocos2dx_Follow_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Follow).name(); g_luaType[typeName] = "cc.Follow"; g_typeCast["Follow"] = "cc.Follow"; return 1; } int lua_cocos2dx_GLProgram_getFragmentShaderLog(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getFragmentShaderLog'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getFragmentShaderLog(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFragmentShaderLog",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getFragmentShaderLog'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_addAttribute(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_addAttribute'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; unsigned int arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_uint32(tolua_S, 3,&arg1); if(!ok) return 0; cobj->addAttribute(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addAttribute",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_addAttribute'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; const float* arg1; unsigned int arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR float*; ok &= luaval_to_uint32(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setUniformLocationWithMatrix4fv(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix4fv",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_getUniformLocationForName(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getUniformLocationForName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; int ret = cobj->getUniformLocationForName(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUniformLocationForName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getUniformLocationForName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_use(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_use'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->use(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "use",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_use'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_getVertexShaderLog(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getVertexShaderLog'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getVertexShaderLog(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVertexShaderLog",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getVertexShaderLog'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_initWithVertexShaderByteArray(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_initWithVertexShaderByteArray'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if(!ok) return 0; bool ret = cobj->initWithVertexShaderByteArray(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithVertexShaderByteArray",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_initWithVertexShaderByteArray'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_initWithVertexShaderFilename(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_initWithVertexShaderFilename'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if(!ok) return 0; bool ret = cobj->initWithVertexShaderFilename(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithVertexShaderFilename",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_initWithVertexShaderFilename'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformsForBuiltins(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformsForBuiltins'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { kmMat4 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmMat4; if (!ok) { break; } cobj->setUniformsForBuiltins(arg0); return 0; } }while(0); ok = true; do{ if (argc == 0) { cobj->setUniformsForBuiltins(); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformsForBuiltins",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformsForBuiltins'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWith3i(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3i'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { int arg0; int arg1; int arg2; int arg3; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cobj->setUniformLocationWith3i(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith3i",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3i'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWith3iv(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3iv'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; int* arg1; unsigned int arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR int*; ok &= luaval_to_uint32(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setUniformLocationWith3iv(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith3iv",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3iv'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_updateUniforms(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_updateUniforms'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateUniforms(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateUniforms",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_updateUniforms'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWith4iv(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4iv'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; int* arg1; unsigned int arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR int*; ok &= luaval_to_uint32(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setUniformLocationWith4iv(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith4iv",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4iv'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; const float* arg1; unsigned int arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR float*; ok &= luaval_to_uint32(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setUniformLocationWithMatrix2fv(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix2fv",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_link(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_link'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->link(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "link",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_link'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWith2iv(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2iv'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; int* arg1; unsigned int arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR int*; ok &= luaval_to_uint32(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setUniformLocationWith2iv(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith2iv",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2iv'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; const float* arg1; unsigned int arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); #pragma warning NO CONVERSION TO NATIVE FOR float*; ok &= luaval_to_uint32(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setUniformLocationWithMatrix3fv(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix3fv",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_reset(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_reset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->reset(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_reset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWith4i(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4i'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 5) { int arg0; int arg1; int arg2; int arg3; int arg4; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if(!ok) return 0; cobj->setUniformLocationWith4i(arg0, arg1, arg2, arg3, arg4); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith4i",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4i'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWith1i(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith1i'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; int arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setUniformLocationWith1i(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith1i",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith1i'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_setUniformLocationWith2i(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2i'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; int arg1; int arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if(!ok) return 0; cobj->setUniformLocationWith2i(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith2i",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2i'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GLProgram_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::GLProgram* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::GLProgram(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.GLProgram"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.GLProgram"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "GLProgram",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_GLProgram_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (GLProgram)"); return 0; } int lua_register_cocos2dx_GLProgram(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.GLProgram"); tolua_cclass(tolua_S,"GLProgram","cc.GLProgram","cc.Object",NULL); tolua_beginmodule(tolua_S,"GLProgram"); tolua_function(tolua_S,"getFragmentShaderLog",lua_cocos2dx_GLProgram_getFragmentShaderLog); tolua_function(tolua_S,"addAttribute",lua_cocos2dx_GLProgram_addAttribute); tolua_function(tolua_S,"setUniformLocationWithMatrix4fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv); tolua_function(tolua_S,"getUniformLocationForName",lua_cocos2dx_GLProgram_getUniformLocationForName); tolua_function(tolua_S,"use",lua_cocos2dx_GLProgram_use); tolua_function(tolua_S,"getVertexShaderLog",lua_cocos2dx_GLProgram_getVertexShaderLog); tolua_function(tolua_S,"initWithString",lua_cocos2dx_GLProgram_initWithVertexShaderByteArray); tolua_function(tolua_S,"init",lua_cocos2dx_GLProgram_initWithVertexShaderFilename); tolua_function(tolua_S,"setUniformsForBuiltins",lua_cocos2dx_GLProgram_setUniformsForBuiltins); tolua_function(tolua_S,"setUniformLocationWith3i",lua_cocos2dx_GLProgram_setUniformLocationWith3i); tolua_function(tolua_S,"setUniformLocationWith3iv",lua_cocos2dx_GLProgram_setUniformLocationWith3iv); tolua_function(tolua_S,"updateUniforms",lua_cocos2dx_GLProgram_updateUniforms); tolua_function(tolua_S,"setUniformLocationWith4iv",lua_cocos2dx_GLProgram_setUniformLocationWith4iv); tolua_function(tolua_S,"setUniformLocationWithMatrix2fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv); tolua_function(tolua_S,"link",lua_cocos2dx_GLProgram_link); tolua_function(tolua_S,"setUniformLocationWith2iv",lua_cocos2dx_GLProgram_setUniformLocationWith2iv); tolua_function(tolua_S,"setUniformLocationWithMatrix3fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv); tolua_function(tolua_S,"reset",lua_cocos2dx_GLProgram_reset); tolua_function(tolua_S,"setUniformLocationWith4i",lua_cocos2dx_GLProgram_setUniformLocationWith4i); tolua_function(tolua_S,"setUniformLocationI32",lua_cocos2dx_GLProgram_setUniformLocationWith1i); tolua_function(tolua_S,"setUniformLocationWith2i",lua_cocos2dx_GLProgram_setUniformLocationWith2i); tolua_function(tolua_S,"new",lua_cocos2dx_GLProgram_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::GLProgram).name(); g_luaType[typeName] = "cc.GLProgram"; g_typeCast["GLProgram"] = "cc.GLProgram"; return 1; } int lua_cocos2dx_Touch_getPreviousLocationInView(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_getPreviousLocationInView'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getPreviousLocationInView(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPreviousLocationInView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_getPreviousLocationInView'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_getLocation(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_getLocation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getLocation(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLocation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_getLocation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_getDelta(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_getDelta'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getDelta(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDelta",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_getDelta'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_getStartLocationInView(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_getStartLocationInView'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getStartLocationInView(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartLocationInView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_getStartLocationInView'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_getStartLocation(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_getStartLocation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getStartLocation(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartLocation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_getStartLocation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_getID(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_getID'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getID(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getID",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_getID'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_setTouchInfo(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_setTouchInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; double arg1; double arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setTouchInfo(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTouchInfo",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_setTouchInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_getLocationInView(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_getLocationInView'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getLocationInView(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLocationInView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_getLocationInView'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_getPreviousLocation(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Touch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Touch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Touch_getPreviousLocation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getPreviousLocation(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPreviousLocation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_getPreviousLocation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Touch_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Touch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Touch(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Touch"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Touch"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Touch",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Touch_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Touch_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Touch)"); return 0; } int lua_register_cocos2dx_Touch(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Touch"); tolua_cclass(tolua_S,"Touch","cc.Touch","cc.Object",NULL); tolua_beginmodule(tolua_S,"Touch"); tolua_function(tolua_S,"getPreviousLocationInView",lua_cocos2dx_Touch_getPreviousLocationInView); tolua_function(tolua_S,"getLocation",lua_cocos2dx_Touch_getLocation); tolua_function(tolua_S,"getDelta",lua_cocos2dx_Touch_getDelta); tolua_function(tolua_S,"getStartLocationInView",lua_cocos2dx_Touch_getStartLocationInView); tolua_function(tolua_S,"getStartLocation",lua_cocos2dx_Touch_getStartLocation); tolua_function(tolua_S,"getId",lua_cocos2dx_Touch_getID); tolua_function(tolua_S,"setTouchInfo",lua_cocos2dx_Touch_setTouchInfo); tolua_function(tolua_S,"getLocationInView",lua_cocos2dx_Touch_getLocationInView); tolua_function(tolua_S,"getPreviousLocation",lua_cocos2dx_Touch_getPreviousLocation); tolua_function(tolua_S,"new",lua_cocos2dx_Touch_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Touch).name(); g_luaType[typeName] = "cc.Touch"; g_typeCast["Touch"] = "cc.Touch"; return 1; } int lua_cocos2dx_Event_isStopped(lua_State* tolua_S) { int argc = 0; cocos2d::Event* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_isStopped'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isStopped(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isStopped",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_isStopped'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Event_getType(lua_State* tolua_S) { int argc = 0; cocos2d::Event* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_getType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_getType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Event_getCurrentTarget(lua_State* tolua_S) { int argc = 0; cocos2d::Event* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_getCurrentTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getCurrentTarget(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentTarget",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_getCurrentTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Event_stopPropagation(lua_State* tolua_S) { int argc = 0; cocos2d::Event* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_stopPropagation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stopPropagation(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopPropagation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_stopPropagation'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Event_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Event)"); return 0; } int lua_register_cocos2dx_Event(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Event"); tolua_cclass(tolua_S,"Event","cc.Event","cc.Object",NULL); tolua_beginmodule(tolua_S,"Event"); tolua_function(tolua_S,"isStopped",lua_cocos2dx_Event_isStopped); tolua_function(tolua_S,"getType",lua_cocos2dx_Event_getType); tolua_function(tolua_S,"getCurrentTarget",lua_cocos2dx_Event_getCurrentTarget); tolua_function(tolua_S,"stopPropagation",lua_cocos2dx_Event_stopPropagation); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Event).name(); g_luaType[typeName] = "cc.Event"; g_typeCast["Event"] = "cc.Event"; return 1; } int lua_cocos2dx_EventTouch_getEventCode(lua_State* tolua_S) { int argc = 0; cocos2d::EventTouch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventTouch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventTouch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventTouch_getEventCode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getEventCode(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEventCode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventTouch_getEventCode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventTouch_setEventCode(lua_State* tolua_S) { int argc = 0; cocos2d::EventTouch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventTouch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventTouch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventTouch_setEventCode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::EventTouch::EventCode arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setEventCode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEventCode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventTouch_setEventCode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventTouch_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::EventTouch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::EventTouch(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventTouch"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.EventTouch"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EventTouch",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventTouch_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EventTouch_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventTouch)"); return 0; } int lua_register_cocos2dx_EventTouch(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventTouch"); tolua_cclass(tolua_S,"EventTouch","cc.EventTouch","cc.Event",NULL); tolua_beginmodule(tolua_S,"EventTouch"); tolua_function(tolua_S,"getEventCode",lua_cocos2dx_EventTouch_getEventCode); tolua_function(tolua_S,"setEventCode",lua_cocos2dx_EventTouch_setEventCode); tolua_function(tolua_S,"new",lua_cocos2dx_EventTouch_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventTouch).name(); g_luaType[typeName] = "cc.EventTouch"; g_typeCast["EventTouch"] = "cc.EventTouch"; return 1; } int lua_cocos2dx_EventKeyboard_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::EventKeyboard* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::EventKeyboard::KeyCode arg0; bool arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj = new cocos2d::EventKeyboard(arg0, arg1); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventKeyboard"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.EventKeyboard"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EventKeyboard",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventKeyboard_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EventKeyboard_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventKeyboard)"); return 0; } int lua_register_cocos2dx_EventKeyboard(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventKeyboard"); tolua_cclass(tolua_S,"EventKeyboard","cc.EventKeyboard","cc.Event",NULL); tolua_beginmodule(tolua_S,"EventKeyboard"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventKeyboard).name(); g_luaType[typeName] = "cc.EventKeyboard"; g_typeCast["EventKeyboard"] = "cc.EventKeyboard"; return 1; } int lua_cocos2dx_Texture2D_getShaderProgram(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getShaderProgram'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::GLProgram* ret = cobj->getShaderProgram(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GLProgram"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GLProgram*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShaderProgram",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getShaderProgram'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getMaxT(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getMaxT'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMaxT(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaxT",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getMaxT'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getStringForFormat(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getStringForFormat'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getStringForFormat(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringForFormat",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getStringForFormat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_initWithImage(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_initWithImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Image* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Image",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Image*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Texture2D::PixelFormat arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } bool ret = cobj->initWithImage(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Image* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Image",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Image*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool ret = cobj->initWithImage(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithImage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_initWithImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_setShaderProgram(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_setShaderProgram'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::GLProgram* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.GLProgram",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setShaderProgram(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setShaderProgram",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setShaderProgram'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getMaxS(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getMaxS'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMaxS(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaxS",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getMaxS'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_hasPremultipliedAlpha(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_hasPremultipliedAlpha'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->hasPremultipliedAlpha(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hasPremultipliedAlpha",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_hasPremultipliedAlpha'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_initWithMipmaps(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_initWithMipmaps'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 5) { cocos2d::_MipmapInfo* arg0; int arg1; cocos2d::Texture2D::PixelFormat arg2; int arg3; int arg4; #pragma warning NO CONVERSION TO NATIVE FOR _MipmapInfo*; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if(!ok) return 0; bool ret = cobj->initWithMipmaps(arg0, arg1, arg2, arg3, arg4); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithMipmaps",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_initWithMipmaps'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getPixelsHigh(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getPixelsHigh'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPixelsHigh(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPixelsHigh",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getPixelsHigh'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getBitsPerPixelForFormat(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getBitsPerPixelForFormat'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { cocos2d::Texture2D::PixelFormat arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } unsigned int ret = cobj->getBitsPerPixelForFormat(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { unsigned int ret = cobj->getBitsPerPixelForFormat(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBitsPerPixelForFormat",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getBitsPerPixelForFormat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getName(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned int ret = cobj->getName(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_initWithString(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_initWithString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::FontDefinition arg1; ok &= luaval_to_fontdefinition(tolua_S, 3, &arg1); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 4) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Size arg3; ok &= luaval_to_size(tolua_S, 5, &arg3); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 5) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Size arg3; ok &= luaval_to_size(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::TextHAlignment arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 6) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Size arg3; ok &= luaval_to_size(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::TextHAlignment arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } cocos2d::TextVAlignment arg5; ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4, arg5); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithString",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_initWithString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_setMaxT(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_setMaxT'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMaxT(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaxT",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setMaxT'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_drawInRect(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_drawInRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->drawInRect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawInRect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_drawInRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getContentSize(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getContentSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getContentSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContentSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getContentSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_setAliasTexParameters(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_setAliasTexParameters'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setAliasTexParameters(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAliasTexParameters",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setAliasTexParameters'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_setAntiAliasTexParameters(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_setAntiAliasTexParameters'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setAntiAliasTexParameters(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAntiAliasTexParameters",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setAntiAliasTexParameters'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_generateMipmap(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_generateMipmap'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->generateMipmap(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "generateMipmap",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_generateMipmap'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getDescription(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getDescription'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getDescription(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDescription",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getDescription'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getPixelFormat(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getPixelFormat'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getPixelFormat(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPixelFormat",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getPixelFormat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getContentSizeInPixels(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getContentSizeInPixels'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getContentSizeInPixels(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContentSizeInPixels",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getContentSizeInPixels'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getPixelsWide(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getPixelsWide'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPixelsWide(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPixelsWide",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getPixelsWide'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_drawAtPoint(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_drawAtPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->drawAtPoint(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawAtPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_drawAtPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_hasMipmaps(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_hasMipmaps'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->hasMipmaps(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hasMipmaps",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_hasMipmaps'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_setMaxS(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_setMaxS'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMaxS(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaxS",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setMaxS'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_setDefaultAlphaPixelFormat(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Texture2D::PixelFormat arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Texture2D::setDefaultAlphaPixelFormat(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "setDefaultAlphaPixelFormat",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setDefaultAlphaPixelFormat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_getDefaultAlphaPixelFormat(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; int ret = (int)cocos2d::Texture2D::getDefaultAlphaPixelFormat(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getDefaultAlphaPixelFormat",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getDefaultAlphaPixelFormat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Texture2D::PVRImagesHavePremultipliedAlpha(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "PVRImagesHavePremultipliedAlpha",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Texture2D_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Texture2D(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Texture2D"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Texture2D"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Texture2D",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Texture2D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Texture2D)"); return 0; } int lua_register_cocos2dx_Texture2D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Texture2D"); tolua_cclass(tolua_S,"Texture2D","cc.Texture2D","cc.Object",NULL); tolua_beginmodule(tolua_S,"Texture2D"); tolua_function(tolua_S,"getShaderProgram",lua_cocos2dx_Texture2D_getShaderProgram); tolua_function(tolua_S,"getMaxT",lua_cocos2dx_Texture2D_getMaxT); tolua_function(tolua_S,"getStringForFormat",lua_cocos2dx_Texture2D_getStringForFormat); tolua_function(tolua_S,"initWithImage",lua_cocos2dx_Texture2D_initWithImage); tolua_function(tolua_S,"setShaderProgram",lua_cocos2dx_Texture2D_setShaderProgram); tolua_function(tolua_S,"getMaxS",lua_cocos2dx_Texture2D_getMaxS); tolua_function(tolua_S,"hasPremultipliedAlpha",lua_cocos2dx_Texture2D_hasPremultipliedAlpha); tolua_function(tolua_S,"initWithMipmaps",lua_cocos2dx_Texture2D_initWithMipmaps); tolua_function(tolua_S,"getPixelsHigh",lua_cocos2dx_Texture2D_getPixelsHigh); tolua_function(tolua_S,"getBitsPerPixelForFormat",lua_cocos2dx_Texture2D_getBitsPerPixelForFormat); tolua_function(tolua_S,"getName",lua_cocos2dx_Texture2D_getName); tolua_function(tolua_S,"initWithString",lua_cocos2dx_Texture2D_initWithString); tolua_function(tolua_S,"setMaxT",lua_cocos2dx_Texture2D_setMaxT); tolua_function(tolua_S,"drawInRect",lua_cocos2dx_Texture2D_drawInRect); tolua_function(tolua_S,"getContentSize",lua_cocos2dx_Texture2D_getContentSize); tolua_function(tolua_S,"setAliasTexParameters",lua_cocos2dx_Texture2D_setAliasTexParameters); tolua_function(tolua_S,"setAntiAliasTexParameters",lua_cocos2dx_Texture2D_setAntiAliasTexParameters); tolua_function(tolua_S,"generateMipmap",lua_cocos2dx_Texture2D_generateMipmap); tolua_function(tolua_S,"getDescription",lua_cocos2dx_Texture2D_getDescription); tolua_function(tolua_S,"getPixelFormat",lua_cocos2dx_Texture2D_getPixelFormat); tolua_function(tolua_S,"getContentSizeInPixels",lua_cocos2dx_Texture2D_getContentSizeInPixels); tolua_function(tolua_S,"getPixelsWide",lua_cocos2dx_Texture2D_getPixelsWide); tolua_function(tolua_S,"drawAtPoint",lua_cocos2dx_Texture2D_drawAtPoint); tolua_function(tolua_S,"hasMipmaps",lua_cocos2dx_Texture2D_hasMipmaps); tolua_function(tolua_S,"setMaxS",lua_cocos2dx_Texture2D_setMaxS); tolua_function(tolua_S,"new",lua_cocos2dx_Texture2D_constructor); tolua_function(tolua_S,"setDefaultAlphaPixelFormat", lua_cocos2dx_Texture2D_setDefaultAlphaPixelFormat); tolua_function(tolua_S,"getDefaultAlphaPixelFormat", lua_cocos2dx_Texture2D_getDefaultAlphaPixelFormat); tolua_function(tolua_S,"PVRImagesHavePremultipliedAlpha", lua_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Texture2D).name(); g_luaType[typeName] = "cc.Texture2D"; g_typeCast["Texture2D"] = "cc.Texture2D"; return 1; } int lua_cocos2dx_EventListener_clone(lua_State* tolua_S) { int argc = 0; cocos2d::EventListener* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_clone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::EventListener* ret = cobj->clone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EventListener"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EventListener*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_clone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventListener_checkAvailable(lua_State* tolua_S) { int argc = 0; cocos2d::EventListener* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_checkAvailable'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->checkAvailable(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "checkAvailable",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_checkAvailable'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EventListener_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListener)"); return 0; } int lua_register_cocos2dx_EventListener(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListener"); tolua_cclass(tolua_S,"EventListener","cc.EventListener","cc.Object",NULL); tolua_beginmodule(tolua_S,"EventListener"); tolua_function(tolua_S,"clone",lua_cocos2dx_EventListener_clone); tolua_function(tolua_S,"checkAvailable",lua_cocos2dx_EventListener_checkAvailable); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListener).name(); g_luaType[typeName] = "cc.EventListener"; g_typeCast["EventListener"] = "cc.EventListener"; return 1; } int lua_cocos2dx_EventDispatcher_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::EventListener* arg0; cocos2d::Node* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.EventListener",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::EventListener*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addEventListenerWithSceneGraphPriority(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addEventListenerWithSceneGraphPriority",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::EventListener* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.EventListener",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::EventListener*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->addEventListenerWithFixedPriority(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addEventListenerWithFixedPriority",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_removeEventListener(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeEventListener'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::EventListener* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.EventListener",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::EventListener*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeEventListener(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeEventListener",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeEventListener'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_removeEventListeners(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeEventListeners'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::EventListener::Type arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->removeEventListeners(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeEventListeners",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeEventListeners'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_dispatchCustomEvent(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_dispatchCustomEvent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; void* arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); #pragma warning NO CONVERSION TO NATIVE FOR void*; if(!ok) return 0; cobj->dispatchCustomEvent(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "dispatchCustomEvent",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_dispatchCustomEvent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_setPriority(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_setPriority'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::EventListener* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.EventListener",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::EventListener*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setPriority(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPriority",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_setPriority'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_addCustomEventListener(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addCustomEventListener'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; std::function arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); do { // Lambda binding for lua is not supported. assert(false); } while(0) ; if(!ok) return 0; cocos2d::EventListenerCustom* ret = cobj->addCustomEventListener(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EventListenerCustom"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EventListenerCustom*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addCustomEventListener",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addCustomEventListener'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_dispatchEvent(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_dispatchEvent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Event* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Event",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Event*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->dispatchEvent(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "dispatchEvent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_dispatchEvent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_removeAllEventListeners(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeAllEventListeners'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllEventListeners(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllEventListeners",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeAllEventListeners'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_removeCustomEventListeners(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeCustomEventListeners'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeCustomEventListeners(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeCustomEventListeners",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeCustomEventListeners'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_isEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_isEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_isEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventDispatcher_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::EventDispatcher(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventDispatcher"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.EventDispatcher"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EventDispatcher",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EventDispatcher_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventDispatcher)"); return 0; } int lua_register_cocos2dx_EventDispatcher(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventDispatcher"); tolua_cclass(tolua_S,"EventDispatcher","cc.EventDispatcher","cc.Object",NULL); tolua_beginmodule(tolua_S,"EventDispatcher"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_EventDispatcher_setEnabled); tolua_function(tolua_S,"addEventListenerWithSceneGraphPriority",lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority); tolua_function(tolua_S,"addEventListenerWithFixedPriority",lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority); tolua_function(tolua_S,"removeEventListener",lua_cocos2dx_EventDispatcher_removeEventListener); tolua_function(tolua_S,"removeEventListeners",lua_cocos2dx_EventDispatcher_removeEventListeners); tolua_function(tolua_S,"dispatchCustomEvent",lua_cocos2dx_EventDispatcher_dispatchCustomEvent); tolua_function(tolua_S,"setPriority",lua_cocos2dx_EventDispatcher_setPriority); tolua_function(tolua_S,"addCustomEventListener",lua_cocos2dx_EventDispatcher_addCustomEventListener); tolua_function(tolua_S,"dispatchEvent",lua_cocos2dx_EventDispatcher_dispatchEvent); tolua_function(tolua_S,"removeAllEventListeners",lua_cocos2dx_EventDispatcher_removeAllEventListeners); tolua_function(tolua_S,"removeCustomEventListeners",lua_cocos2dx_EventDispatcher_removeCustomEventListeners); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_EventDispatcher_isEnabled); tolua_function(tolua_S,"new",lua_cocos2dx_EventDispatcher_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventDispatcher).name(); g_luaType[typeName] = "cc.EventDispatcher"; g_typeCast["EventDispatcher"] = "cc.EventDispatcher"; return 1; } int lua_cocos2dx_Node_addChild(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_addChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cobj->addChild(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj->addChild(arg0); return 0; } }while(0); ok = true; do{ if (argc == 3) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cobj->addChild(arg0, arg1, arg2); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addChild",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_addChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_removeComponent(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_removeComponent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->removeComponent(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeComponent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_removeComponent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setPhysicsBody(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setPhysicsBody'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::PhysicsBody* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setPhysicsBody(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPhysicsBody",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setPhysicsBody'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getShaderProgram(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getShaderProgram'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::GLProgram* ret = cobj->getShaderProgram(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GLProgram"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GLProgram*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::GLProgram* ret = cobj->getShaderProgram(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GLProgram"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GLProgram*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShaderProgram",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getShaderProgram'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getDescription(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getDescription'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getDescription(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDescription",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getDescription'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setOpacityModifyRGB(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setOpacityModifyRGB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setOpacityModifyRGB(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOpacityModifyRGB",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setOpacityModifyRGB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setCascadeOpacityEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setCascadeOpacityEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setCascadeOpacityEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCascadeOpacityEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setCascadeOpacityEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getChildren(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getChildren'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::Vector& ret = cobj->getChildren(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::Vector& ret = cobj->getChildren(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getChildren",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getChildren'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_pause(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_pause'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pause(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pause",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_pause'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_convertToWorldSpaceAR(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_convertToWorldSpaceAR'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->convertToWorldSpaceAR(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "convertToWorldSpaceAR",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_convertToWorldSpaceAR'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_isIgnoreAnchorPointForPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isIgnoreAnchorPointForPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isIgnoreAnchorPointForPosition(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isIgnoreAnchorPointForPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isIgnoreAnchorPointForPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_updateDisplayedOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_updateDisplayedOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { uint16_t arg0; ok &= luaval_to_uint16(tolua_S, 2,&arg0); if(!ok) return 0; cobj->updateDisplayedOpacity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateDisplayedOpacity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_updateDisplayedOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setRotation(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setRotation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setRotation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setScaleY(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setScaleY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScaleY(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScaleY",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setScaleY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setScaleX(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setScaleX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScaleX(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScaleX",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setScaleX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getColor(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color3B& ret = cobj->getColor(); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_removeAllComponents(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_removeAllComponents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllComponents(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllComponents",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_removeAllComponents'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node__setLocalZOrder(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node__setLocalZOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->_setLocalZOrder(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "_setLocalZOrder",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node__setLocalZOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getTag(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getTag(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTag",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getNodeToWorldAffineTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getNodeToWorldAffineTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::AffineTransform ret = cobj->getNodeToWorldAffineTransform(); affinetransform_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeToWorldAffineTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getNodeToWorldAffineTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getNodeToWorldTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getNodeToWorldTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; kmMat4 ret = cobj->getNodeToWorldTransform(); #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeToWorldTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getNodeToWorldTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_removeChild(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_removeChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeChild(arg0); return 0; } if (argc == 2) { cocos2d::Node* arg0; bool arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->removeChild(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeChild",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_removeChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_convertToWorldSpace(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_convertToWorldSpace'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->convertToWorldSpace(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "convertToWorldSpace",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_convertToWorldSpace'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getScene(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Scene* ret = cobj->getScene(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scene"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Scene*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScene",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getEventDispatcher(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getEventDispatcher'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::EventDispatcher* ret = cobj->getEventDispatcher(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EventDispatcher"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EventDispatcher*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEventDispatcher",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getEventDispatcher'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setSkewX(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setSkewX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSkewX(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSkewX",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setSkewX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setSkewY(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setSkewY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSkewY(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSkewY",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setSkewY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; uint16_t ret = cobj->getOpacity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOpacity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_convertTouchToNodeSpace(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_convertTouchToNodeSpace'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Touch* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Point ret = cobj->convertTouchToNodeSpace(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "convertTouchToNodeSpace",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_convertTouchToNodeSpace'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_removeAllChildrenWithCleanup(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_removeAllChildrenWithCleanup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if (!ok) { break; } cobj->removeAllChildrenWithCleanup(arg0); return 0; } }while(0); ok = true; do{ if (argc == 0) { cobj->removeAllChildren(); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllChildren",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_removeAllChildrenWithCleanup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getRotationX(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getRotationX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRotationX(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRotationX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getRotationX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getRotationY(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getRotationY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRotationY(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRotationY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getRotationY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getNodeToParentAffineTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getNodeToParentAffineTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::AffineTransform ret = cobj->getNodeToParentAffineTransform(); affinetransform_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeToParentAffineTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getNodeToParentAffineTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_isCascadeOpacityEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isCascadeOpacityEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isCascadeOpacityEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isCascadeOpacityEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isCascadeOpacityEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setParent(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setParent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setParent(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setParent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setParent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getNodeToParentTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getNodeToParentTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const kmMat4& ret = cobj->getNodeToParentTransform(); #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeToParentTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getNodeToParentTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_resume(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_resume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resume(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resume",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_resume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getPhysicsBody(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getPhysicsBody'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsBody* ret = cobj->getPhysicsBody(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPhysicsBody",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getPhysicsBody'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cobj->setPosition(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if (!ok) { break; } cobj->setPosition(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPosition",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_stopActionByTag(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_stopActionByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->stopActionByTag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopActionByTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_stopActionByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_reorderChild(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_reorderChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Node* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->reorderChild(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reorderChild",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_reorderChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_ignoreAnchorPointForPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_ignoreAnchorPointForPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->ignoreAnchorPointForPosition(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ignoreAnchorPointForPosition",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_ignoreAnchorPointForPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setColor(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setPositionY(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setPositionY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPositionY(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPositionY",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setPositionY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setPositionX(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setPositionX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPositionX(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPositionX",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setPositionX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setNodeToParentTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setNodeToParentTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { kmMat4 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmMat4; if(!ok) return 0; cobj->setNodeToParentTransform(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setNodeToParentTransform",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setNodeToParentTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getAnchorPoint(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getAnchorPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getAnchorPoint(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchorPoint",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getAnchorPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getNumberOfRunningActions(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getNumberOfRunningActions'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getNumberOfRunningActions(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNumberOfRunningActions",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getNumberOfRunningActions'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_updateTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_updateTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateTransform(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_updateTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_isVisible(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isVisible'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isVisible(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isVisible",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isVisible'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getChildrenCount(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getChildrenCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getChildrenCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getChildrenCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getChildrenCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_convertToNodeSpaceAR(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_convertToNodeSpaceAR'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->convertToNodeSpaceAR(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "convertToNodeSpaceAR",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_convertToNodeSpaceAR'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_addComponent(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_addComponent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Component* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Component",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Component*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->addComponent(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addComponent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_addComponent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_visit(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_visit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->visit(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "visit",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_visit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setShaderProgram(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setShaderProgram'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::GLProgram* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.GLProgram",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setShaderProgram(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setShaderProgram",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setShaderProgram'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getRotation(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getRotation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRotation(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRotation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getRotation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getAnchorPointInPoints(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getAnchorPointInPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getAnchorPointInPoints(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchorPointInPoints",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getAnchorPointInPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_runAction(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_runAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Action* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Action",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Action*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Action* ret = cobj->runAction(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Action"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Action*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "runAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_runAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_transform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_transform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->transform(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "transform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_transform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setVertexZ(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setVertexZ'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setVertexZ(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVertexZ",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setVertexZ'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setScheduler(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setScheduler'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Scheduler* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Scheduler",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Scheduler*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setScheduler(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScheduler",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setScheduler'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_stopAllActions(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_stopAllActions'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stopAllActions(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopAllActions",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_stopAllActions'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getSkewX(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getSkewX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSkewX(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSkewX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getSkewX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getSkewY(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getSkewY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSkewY(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSkewY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getSkewY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getDisplayedColor(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getDisplayedColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color3B& ret = cobj->getDisplayedColor(); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayedColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getDisplayedColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getActionByTag(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getActionByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Action* ret = cobj->getActionByTag(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Action"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Action*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getActionByTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getActionByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setRotationX(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setRotationX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotationX(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotationX",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setRotationX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setRotationY(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setRotationY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotationY(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotationY",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setRotationY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setAdditionalTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setAdditionalTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { kmMat4 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmMat4; if (!ok) { break; } cobj->setAdditionalTransform(arg0); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::AffineTransform arg0; ok &= luaval_to_affinetransform(tolua_S, 2, &arg0); if (!ok) { break; } cobj->setAdditionalTransform(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAdditionalTransform",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setAdditionalTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getDisplayedOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getDisplayedOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; uint16_t ret = cobj->getDisplayedOpacity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayedOpacity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getDisplayedOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getLocalZOrder(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getLocalZOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getLocalZOrder(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLocalZOrder",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getLocalZOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getScheduler(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getScheduler'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::Scheduler* ret = cobj->getScheduler(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scheduler"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Scheduler*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::Scheduler* ret = cobj->getScheduler(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scheduler"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Scheduler*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScheduler",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getScheduler'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getParentToNodeAffineTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getParentToNodeAffineTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::AffineTransform ret = cobj->getParentToNodeAffineTransform(); affinetransform_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParentToNodeAffineTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getParentToNodeAffineTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getOrderOfArrival(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getOrderOfArrival'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getOrderOfArrival(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOrderOfArrival",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getOrderOfArrival'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setActionManager(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setActionManager'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionManager* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionManager",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setActionManager(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setActionManager",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setActionManager'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_isRunning(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isRunning'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isRunning(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isRunning",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isRunning'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getParent(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getParent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::Node* ret = cobj->getParent(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::Node* ret = cobj->getParent(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getParent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getPositionY(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getPositionY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getPositionY(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPositionY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getPositionY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getPositionX(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getPositionX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getPositionX(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPositionX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getPositionX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_removeChildByTag(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_removeChildByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->removeChildByTag(arg0); return 0; } if (argc == 2) { int arg0; bool arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->removeChildByTag(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeChildByTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_removeChildByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_updateDisplayedColor(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_updateDisplayedColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->updateDisplayedColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateDisplayedColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_updateDisplayedColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setVisible(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setVisible'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setVisible(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVisible",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setVisible'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getParentToNodeTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getParentToNodeTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const kmMat4& ret = cobj->getParentToNodeTransform(); #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParentToNodeTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getParentToNodeTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getVertexZ(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getVertexZ'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getVertexZ(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVertexZ",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getVertexZ'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setGlobalZOrder(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setGlobalZOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setGlobalZOrder(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGlobalZOrder",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setGlobalZOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setScale(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cobj->setScale(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cobj->setScale(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScale",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getChildByTag(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getChildByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Node* ret = cobj->getChildByTag(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getChildByTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getChildByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setOrderOfArrival(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setOrderOfArrival'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setOrderOfArrival(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOrderOfArrival",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setOrderOfArrival'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getScaleY(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getScaleY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScaleY(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScaleY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getScaleY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getScaleX(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getScaleX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScaleX(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScaleX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getScaleX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setLocalZOrder(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setLocalZOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setLocalZOrder(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLocalZOrder",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setLocalZOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getWorldToNodeAffineTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getWorldToNodeAffineTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::AffineTransform ret = cobj->getWorldToNodeAffineTransform(); affinetransform_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWorldToNodeAffineTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getWorldToNodeAffineTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setCascadeColorEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setCascadeColorEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setCascadeColorEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCascadeColorEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setCascadeColorEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { uint16_t arg0; ok &= luaval_to_uint16(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setOpacity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOpacity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_cleanup(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_cleanup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->cleanup(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cleanup",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_cleanup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getComponent(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getComponent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Component* ret = cobj->getComponent(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Component"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Component*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getComponent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getComponent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getContentSize(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getContentSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getContentSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContentSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getContentSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getBoundingBox(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getBoundingBox'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Rect ret = cobj->getBoundingBox(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBoundingBox",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getBoundingBox'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_updatePhysicsTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_updatePhysicsTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->updatePhysicsTransform(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updatePhysicsTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_updatePhysicsTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setEventDispatcher(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setEventDispatcher'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::EventDispatcher* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.EventDispatcher",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setEventDispatcher(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEventDispatcher",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setEventDispatcher'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getGlobalZOrder(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getGlobalZOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getGlobalZOrder(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGlobalZOrder",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getGlobalZOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_draw(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_draw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->draw(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "draw",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_draw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_transformAncestors(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_transformAncestors'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->transformAncestors(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "transformAncestors",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_transformAncestors'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setUserObject(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setUserObject'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Object* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Object",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Object*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setUserObject(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUserObject",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setUserObject'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_removeFromParentAndCleanup(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_removeFromParentAndCleanup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if (!ok) { break; } cobj->removeFromParentAndCleanup(arg0); return 0; } }while(0); ok = true; do{ if (argc == 0) { cobj->removeFromParent(); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeFromParent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_removeFromParentAndCleanup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_convertTouchToNodeSpaceAR(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_convertTouchToNodeSpaceAR'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Touch* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Point ret = cobj->convertTouchToNodeSpaceAR(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "convertTouchToNodeSpaceAR",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_convertTouchToNodeSpaceAR'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_update(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_update'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->update(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "update",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_update'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_sortAllChildren(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_sortAllChildren'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->sortAllChildren(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "sortAllChildren",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_sortAllChildren'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getWorldToNodeTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getWorldToNodeTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; kmMat4 ret = cobj->getWorldToNodeTransform(); #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWorldToNodeTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getWorldToNodeTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getScale(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScale(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScale",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_convertToNodeSpace(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_convertToNodeSpace'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->convertToNodeSpace(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "convertToNodeSpace",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_convertToNodeSpace'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_setTag(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setTag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_isCascadeColorEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isCascadeColorEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isCascadeColorEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isCascadeColorEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isCascadeColorEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_isOpacityModifyRGB(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isOpacityModifyRGB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isOpacityModifyRGB(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isOpacityModifyRGB",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isOpacityModifyRGB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_stopAction(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_stopAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Action* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Action",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Action*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->stopAction(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_stopAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_getActionManager(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getActionManager'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::ActionManager* ret = cobj->getActionManager(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionManager"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionManager*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::ActionManager* ret = cobj->getActionManager(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionManager"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionManager*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getActionManager",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getActionManager'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Node_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cocos2d::Node::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Node_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Node)"); return 0; } int lua_register_cocos2dx_Node(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Node"); tolua_cclass(tolua_S,"Node","cc.Node","cc.Object",NULL); tolua_beginmodule(tolua_S,"Node"); tolua_function(tolua_S,"addChild",lua_cocos2dx_Node_addChild); tolua_function(tolua_S,"removeComponent",lua_cocos2dx_Node_removeComponent); tolua_function(tolua_S,"setPhysicsBody",lua_cocos2dx_Node_setPhysicsBody); tolua_function(tolua_S,"getShaderProgram",lua_cocos2dx_Node_getShaderProgram); tolua_function(tolua_S,"getDescription",lua_cocos2dx_Node_getDescription); tolua_function(tolua_S,"setOpacityModifyRGB",lua_cocos2dx_Node_setOpacityModifyRGB); tolua_function(tolua_S,"setCascadeOpacityEnabled",lua_cocos2dx_Node_setCascadeOpacityEnabled); tolua_function(tolua_S,"getChildren",lua_cocos2dx_Node_getChildren); tolua_function(tolua_S,"pause",lua_cocos2dx_Node_pause); tolua_function(tolua_S,"convertToWorldSpaceAR",lua_cocos2dx_Node_convertToWorldSpaceAR); tolua_function(tolua_S,"isIgnoreAnchorPointForPosition",lua_cocos2dx_Node_isIgnoreAnchorPointForPosition); tolua_function(tolua_S,"updateDisplayedOpacity",lua_cocos2dx_Node_updateDisplayedOpacity); tolua_function(tolua_S,"setRotation",lua_cocos2dx_Node_setRotation); tolua_function(tolua_S,"setScaleY",lua_cocos2dx_Node_setScaleY); tolua_function(tolua_S,"setScaleX",lua_cocos2dx_Node_setScaleX); tolua_function(tolua_S,"getColor",lua_cocos2dx_Node_getColor); tolua_function(tolua_S,"removeAllComponents",lua_cocos2dx_Node_removeAllComponents); tolua_function(tolua_S,"_setLocalZOrder",lua_cocos2dx_Node__setLocalZOrder); tolua_function(tolua_S,"getTag",lua_cocos2dx_Node_getTag); tolua_function(tolua_S,"getNodeToWorldAffineTransform",lua_cocos2dx_Node_getNodeToWorldAffineTransform); tolua_function(tolua_S,"getNodeToWorldTransform",lua_cocos2dx_Node_getNodeToWorldTransform); tolua_function(tolua_S,"removeChild",lua_cocos2dx_Node_removeChild); tolua_function(tolua_S,"convertToWorldSpace",lua_cocos2dx_Node_convertToWorldSpace); tolua_function(tolua_S,"getScene",lua_cocos2dx_Node_getScene); tolua_function(tolua_S,"getEventDispatcher",lua_cocos2dx_Node_getEventDispatcher); tolua_function(tolua_S,"setSkewX",lua_cocos2dx_Node_setSkewX); tolua_function(tolua_S,"setSkewY",lua_cocos2dx_Node_setSkewY); tolua_function(tolua_S,"getOpacity",lua_cocos2dx_Node_getOpacity); tolua_function(tolua_S,"convertTouchToNodeSpace",lua_cocos2dx_Node_convertTouchToNodeSpace); tolua_function(tolua_S,"removeAllChildren",lua_cocos2dx_Node_removeAllChildrenWithCleanup); tolua_function(tolua_S,"getRotationX",lua_cocos2dx_Node_getRotationX); tolua_function(tolua_S,"getRotationY",lua_cocos2dx_Node_getRotationY); tolua_function(tolua_S,"getNodeToParentAffineTransform",lua_cocos2dx_Node_getNodeToParentAffineTransform); tolua_function(tolua_S,"isCascadeOpacityEnabled",lua_cocos2dx_Node_isCascadeOpacityEnabled); tolua_function(tolua_S,"setParent",lua_cocos2dx_Node_setParent); tolua_function(tolua_S,"getNodeToParentTransform",lua_cocos2dx_Node_getNodeToParentTransform); tolua_function(tolua_S,"resume",lua_cocos2dx_Node_resume); tolua_function(tolua_S,"getPhysicsBody",lua_cocos2dx_Node_getPhysicsBody); tolua_function(tolua_S,"setPosition",lua_cocos2dx_Node_setPosition); tolua_function(tolua_S,"stopActionByTag",lua_cocos2dx_Node_stopActionByTag); tolua_function(tolua_S,"reorderChild",lua_cocos2dx_Node_reorderChild); tolua_function(tolua_S,"ignoreAnchorPointForPosition",lua_cocos2dx_Node_ignoreAnchorPointForPosition); tolua_function(tolua_S,"setColor",lua_cocos2dx_Node_setColor); tolua_function(tolua_S,"setPositionY",lua_cocos2dx_Node_setPositionY); tolua_function(tolua_S,"setPositionX",lua_cocos2dx_Node_setPositionX); tolua_function(tolua_S,"setNodeToParentTransform",lua_cocos2dx_Node_setNodeToParentTransform); tolua_function(tolua_S,"getAnchorPoint",lua_cocos2dx_Node_getAnchorPoint); tolua_function(tolua_S,"getNumberOfRunningActions",lua_cocos2dx_Node_getNumberOfRunningActions); tolua_function(tolua_S,"updateTransform",lua_cocos2dx_Node_updateTransform); tolua_function(tolua_S,"isVisible",lua_cocos2dx_Node_isVisible); tolua_function(tolua_S,"getChildrenCount",lua_cocos2dx_Node_getChildrenCount); tolua_function(tolua_S,"convertToNodeSpaceAR",lua_cocos2dx_Node_convertToNodeSpaceAR); tolua_function(tolua_S,"addComponent",lua_cocos2dx_Node_addComponent); tolua_function(tolua_S,"visit",lua_cocos2dx_Node_visit); tolua_function(tolua_S,"setShaderProgram",lua_cocos2dx_Node_setShaderProgram); tolua_function(tolua_S,"getRotation",lua_cocos2dx_Node_getRotation); tolua_function(tolua_S,"getAnchorPointInPoints",lua_cocos2dx_Node_getAnchorPointInPoints); tolua_function(tolua_S,"runAction",lua_cocos2dx_Node_runAction); tolua_function(tolua_S,"transform",lua_cocos2dx_Node_transform); tolua_function(tolua_S,"setVertexZ",lua_cocos2dx_Node_setVertexZ); tolua_function(tolua_S,"setScheduler",lua_cocos2dx_Node_setScheduler); tolua_function(tolua_S,"stopAllActions",lua_cocos2dx_Node_stopAllActions); tolua_function(tolua_S,"getSkewX",lua_cocos2dx_Node_getSkewX); tolua_function(tolua_S,"getSkewY",lua_cocos2dx_Node_getSkewY); tolua_function(tolua_S,"getDisplayedColor",lua_cocos2dx_Node_getDisplayedColor); tolua_function(tolua_S,"getActionByTag",lua_cocos2dx_Node_getActionByTag); tolua_function(tolua_S,"setRotationX",lua_cocos2dx_Node_setRotationX); tolua_function(tolua_S,"setRotationY",lua_cocos2dx_Node_setRotationY); tolua_function(tolua_S,"setAdditionalTransform",lua_cocos2dx_Node_setAdditionalTransform); tolua_function(tolua_S,"getDisplayedOpacity",lua_cocos2dx_Node_getDisplayedOpacity); tolua_function(tolua_S,"getLocalZOrder",lua_cocos2dx_Node_getLocalZOrder); tolua_function(tolua_S,"getScheduler",lua_cocos2dx_Node_getScheduler); tolua_function(tolua_S,"getParentToNodeAffineTransform",lua_cocos2dx_Node_getParentToNodeAffineTransform); tolua_function(tolua_S,"getOrderOfArrival",lua_cocos2dx_Node_getOrderOfArrival); tolua_function(tolua_S,"setActionManager",lua_cocos2dx_Node_setActionManager); tolua_function(tolua_S,"isRunning",lua_cocos2dx_Node_isRunning); tolua_function(tolua_S,"getParent",lua_cocos2dx_Node_getParent); tolua_function(tolua_S,"getPositionY",lua_cocos2dx_Node_getPositionY); tolua_function(tolua_S,"getPositionX",lua_cocos2dx_Node_getPositionX); tolua_function(tolua_S,"removeChildByTag",lua_cocos2dx_Node_removeChildByTag); tolua_function(tolua_S,"updateDisplayedColor",lua_cocos2dx_Node_updateDisplayedColor); tolua_function(tolua_S,"setVisible",lua_cocos2dx_Node_setVisible); tolua_function(tolua_S,"getParentToNodeTransform",lua_cocos2dx_Node_getParentToNodeTransform); tolua_function(tolua_S,"getVertexZ",lua_cocos2dx_Node_getVertexZ); tolua_function(tolua_S,"setGlobalZOrder",lua_cocos2dx_Node_setGlobalZOrder); tolua_function(tolua_S,"setScale",lua_cocos2dx_Node_setScale); tolua_function(tolua_S,"getChildByTag",lua_cocos2dx_Node_getChildByTag); tolua_function(tolua_S,"setOrderOfArrival",lua_cocos2dx_Node_setOrderOfArrival); tolua_function(tolua_S,"getScaleY",lua_cocos2dx_Node_getScaleY); tolua_function(tolua_S,"getScaleX",lua_cocos2dx_Node_getScaleX); tolua_function(tolua_S,"setLocalZOrder",lua_cocos2dx_Node_setLocalZOrder); tolua_function(tolua_S,"getWorldToNodeAffineTransform",lua_cocos2dx_Node_getWorldToNodeAffineTransform); tolua_function(tolua_S,"setCascadeColorEnabled",lua_cocos2dx_Node_setCascadeColorEnabled); tolua_function(tolua_S,"setOpacity",lua_cocos2dx_Node_setOpacity); tolua_function(tolua_S,"cleanup",lua_cocos2dx_Node_cleanup); tolua_function(tolua_S,"getComponent",lua_cocos2dx_Node_getComponent); tolua_function(tolua_S,"getContentSize",lua_cocos2dx_Node_getContentSize); tolua_function(tolua_S,"getBoundingBox",lua_cocos2dx_Node_getBoundingBox); tolua_function(tolua_S,"updatePhysicsTransform",lua_cocos2dx_Node_updatePhysicsTransform); tolua_function(tolua_S,"setEventDispatcher",lua_cocos2dx_Node_setEventDispatcher); tolua_function(tolua_S,"getGlobalZOrder",lua_cocos2dx_Node_getGlobalZOrder); tolua_function(tolua_S,"draw",lua_cocos2dx_Node_draw); tolua_function(tolua_S,"transformAncestors",lua_cocos2dx_Node_transformAncestors); tolua_function(tolua_S,"setUserObject",lua_cocos2dx_Node_setUserObject); tolua_function(tolua_S,"removeFromParent",lua_cocos2dx_Node_removeFromParentAndCleanup); tolua_function(tolua_S,"convertTouchToNodeSpaceAR",lua_cocos2dx_Node_convertTouchToNodeSpaceAR); tolua_function(tolua_S,"update",lua_cocos2dx_Node_update); tolua_function(tolua_S,"sortAllChildren",lua_cocos2dx_Node_sortAllChildren); tolua_function(tolua_S,"getWorldToNodeTransform",lua_cocos2dx_Node_getWorldToNodeTransform); tolua_function(tolua_S,"getScale",lua_cocos2dx_Node_getScale); tolua_function(tolua_S,"convertToNodeSpace",lua_cocos2dx_Node_convertToNodeSpace); tolua_function(tolua_S,"setTag",lua_cocos2dx_Node_setTag); tolua_function(tolua_S,"isCascadeColorEnabled",lua_cocos2dx_Node_isCascadeColorEnabled); tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_Node_isOpacityModifyRGB); tolua_function(tolua_S,"stopAction",lua_cocos2dx_Node_stopAction); tolua_function(tolua_S,"getActionManager",lua_cocos2dx_Node_getActionManager); tolua_function(tolua_S,"create", lua_cocos2dx_Node_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Node).name(); g_luaType[typeName] = "cc.Node"; g_typeCast["Node"] = "cc.Node"; return 1; } int lua_cocos2dx_SpriteFrame_clone(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_clone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::SpriteFrame* ret = cobj->clone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_clone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_setRotated(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_setRotated'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotated(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotated",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_setRotated'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_setTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTexture(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_setTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_initWithTexture(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_initWithTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 5) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Point arg3; ok &= luaval_to_point(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::Size arg4; ok &= luaval_to_size(tolua_S, 6, &arg4); if (!ok) { break; } bool ret = cobj->initWithTexture(arg0, arg1, arg2, arg3, arg4); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 2) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool ret = cobj->initWithTexture(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTexture",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_initWithTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_setRectInPixels(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_setRectInPixels'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setRectInPixels(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRectInPixels",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_setRectInPixels'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_getTexture(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Texture2D* ret = cobj->getTexture(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTexture",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_getRect(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Rect& ret = cobj->getRect(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRect",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_setOffsetInPixels(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_setOffsetInPixels'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setOffsetInPixels(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOffsetInPixels",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_setOffsetInPixels'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_getRectInPixels(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getRectInPixels'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Rect& ret = cobj->getRectInPixels(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRectInPixels",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getRectInPixels'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_setOriginalSize(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_setOriginalSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setOriginalSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOriginalSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_setOriginalSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_getOriginalSizeInPixels(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getOriginalSizeInPixels'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getOriginalSizeInPixels(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOriginalSizeInPixels",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getOriginalSizeInPixels'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_setOriginalSizeInPixels(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_setOriginalSizeInPixels'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setOriginalSizeInPixels(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOriginalSizeInPixels",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_setOriginalSizeInPixels'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_setOffset(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_setOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setOffset(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOffset",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_setOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_getOffset(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getOffset(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOffset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_isRotated(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_isRotated'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isRotated(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isRotated",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_isRotated'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_initWithTextureFilename(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_initWithTextureFilename'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 5) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Point arg3; ok &= luaval_to_point(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::Size arg4; ok &= luaval_to_size(tolua_S, 6, &arg4); if (!ok) { break; } bool ret = cobj->initWithTextureFilename(arg0, arg1, arg2, arg3, arg4); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool ret = cobj->initWithTextureFilename(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTextureFilename",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_initWithTextureFilename'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_setRect(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_setRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setRect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_setRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_getOffsetInPixels(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getOffsetInPixels'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getOffsetInPixels(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOffsetInPixels",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getOffsetInPixels'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_getOriginalSize(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getOriginalSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getOriginalSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOriginalSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getOriginalSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 5) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Point arg3; ok &= luaval_to_point(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::Size arg4; ok &= luaval_to_size(tolua_S, 6, &arg4); if (!ok) { break; } cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::create(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrame_createWithTexture(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 5) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Point arg3; ok &= luaval_to_point(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::Size arg4; ok &= luaval_to_size(tolua_S, 6, &arg4); if (!ok) { break; } cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::createWithTexture(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::createWithTexture(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "createWithTexture",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_createWithTexture'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_SpriteFrame_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SpriteFrame)"); return 0; } int lua_register_cocos2dx_SpriteFrame(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.SpriteFrame"); tolua_cclass(tolua_S,"SpriteFrame","cc.SpriteFrame","cc.Object",NULL); tolua_beginmodule(tolua_S,"SpriteFrame"); tolua_function(tolua_S,"clone",lua_cocos2dx_SpriteFrame_clone); tolua_function(tolua_S,"setRotated",lua_cocos2dx_SpriteFrame_setRotated); tolua_function(tolua_S,"setTexture",lua_cocos2dx_SpriteFrame_setTexture); tolua_function(tolua_S,"initWithTexture",lua_cocos2dx_SpriteFrame_initWithTexture); tolua_function(tolua_S,"setRectInPixels",lua_cocos2dx_SpriteFrame_setRectInPixels); tolua_function(tolua_S,"getTexture",lua_cocos2dx_SpriteFrame_getTexture); tolua_function(tolua_S,"getRect",lua_cocos2dx_SpriteFrame_getRect); tolua_function(tolua_S,"setOffsetInPixels",lua_cocos2dx_SpriteFrame_setOffsetInPixels); tolua_function(tolua_S,"getRectInPixels",lua_cocos2dx_SpriteFrame_getRectInPixels); tolua_function(tolua_S,"setOriginalSize",lua_cocos2dx_SpriteFrame_setOriginalSize); tolua_function(tolua_S,"getOriginalSizeInPixels",lua_cocos2dx_SpriteFrame_getOriginalSizeInPixels); tolua_function(tolua_S,"setOriginalSizeInPixels",lua_cocos2dx_SpriteFrame_setOriginalSizeInPixels); tolua_function(tolua_S,"setOffset",lua_cocos2dx_SpriteFrame_setOffset); tolua_function(tolua_S,"getOffset",lua_cocos2dx_SpriteFrame_getOffset); tolua_function(tolua_S,"isRotated",lua_cocos2dx_SpriteFrame_isRotated); tolua_function(tolua_S,"initWithTextureFilename",lua_cocos2dx_SpriteFrame_initWithTextureFilename); tolua_function(tolua_S,"setRect",lua_cocos2dx_SpriteFrame_setRect); tolua_function(tolua_S,"getOffsetInPixels",lua_cocos2dx_SpriteFrame_getOffsetInPixels); tolua_function(tolua_S,"getOriginalSize",lua_cocos2dx_SpriteFrame_getOriginalSize); tolua_function(tolua_S,"create", lua_cocos2dx_SpriteFrame_create); tolua_function(tolua_S,"createWithTexture", lua_cocos2dx_SpriteFrame_createWithTexture); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::SpriteFrame).name(); g_luaType[typeName] = "cc.SpriteFrame"; g_typeCast["SpriteFrame"] = "cc.SpriteFrame"; return 1; } int lua_cocos2dx_AnimationFrame_setSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationFrame_setSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setSpriteFrame(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationFrame_setSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationFrame_getUserInfo(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationFrame* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationFrame_getUserInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::ValueMap& ret = cobj->getUserInfo(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::ValueMap& ret = cobj->getUserInfo(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUserInfo",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationFrame_getUserInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationFrame_setDelayUnits(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationFrame_setDelayUnits'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDelayUnits(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDelayUnits",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationFrame_setDelayUnits'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationFrame_clone(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationFrame_clone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::AnimationFrame* ret = cobj->clone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.AnimationFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::AnimationFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationFrame_clone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationFrame_getSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationFrame_getSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::SpriteFrame* ret = cobj->getSpriteFrame(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSpriteFrame",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationFrame_getSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationFrame_getDelayUnits(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationFrame_getDelayUnits'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDelayUnits(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDelayUnits",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationFrame_getDelayUnits'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationFrame_setUserInfo(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationFrame* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationFrame",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationFrame*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationFrame_setUserInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueMap arg0; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setUserInfo(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUserInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationFrame_setUserInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationFrame_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.AnimationFrame",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { cocos2d::SpriteFrame* arg0; double arg1; cocos2d::ValueMap arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_ccvaluemap(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::AnimationFrame* ret = cocos2d::AnimationFrame::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.AnimationFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::AnimationFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationFrame_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_AnimationFrame_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (AnimationFrame)"); return 0; } int lua_register_cocos2dx_AnimationFrame(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.AnimationFrame"); tolua_cclass(tolua_S,"AnimationFrame","cc.AnimationFrame","cc.Object",NULL); tolua_beginmodule(tolua_S,"AnimationFrame"); tolua_function(tolua_S,"setSpriteFrame",lua_cocos2dx_AnimationFrame_setSpriteFrame); tolua_function(tolua_S,"getUserInfo",lua_cocos2dx_AnimationFrame_getUserInfo); tolua_function(tolua_S,"setDelayUnits",lua_cocos2dx_AnimationFrame_setDelayUnits); tolua_function(tolua_S,"clone",lua_cocos2dx_AnimationFrame_clone); tolua_function(tolua_S,"getSpriteFrame",lua_cocos2dx_AnimationFrame_getSpriteFrame); tolua_function(tolua_S,"getDelayUnits",lua_cocos2dx_AnimationFrame_getDelayUnits); tolua_function(tolua_S,"setUserInfo",lua_cocos2dx_AnimationFrame_setUserInfo); tolua_function(tolua_S,"create", lua_cocos2dx_AnimationFrame_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::AnimationFrame).name(); g_luaType[typeName] = "cc.AnimationFrame"; g_typeCast["AnimationFrame"] = "cc.AnimationFrame"; return 1; } int lua_cocos2dx_Animation_getLoops(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_getLoops'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned int ret = cobj->getLoops(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLoops",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_getLoops'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_addSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_addSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addSpriteFrame(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_addSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_setRestoreOriginalFrame(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_setRestoreOriginalFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRestoreOriginalFrame(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRestoreOriginalFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_setRestoreOriginalFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_clone(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_clone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Animation* ret = cobj->clone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_clone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_getDuration(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_getDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDuration(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDuration",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_getDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_setFrames(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_setFrames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setFrames(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFrames",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_setFrames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_getFrames(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_getFrames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Vector& ret = cobj->getFrames(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFrames",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_getFrames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_setLoops(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_setLoops'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLoops(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLoops",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_setLoops'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_setDelayPerUnit(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_setDelayPerUnit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDelayPerUnit(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDelayPerUnit",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_setDelayPerUnit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_addSpriteFrameWithFile(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_addSpriteFrameWithFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addSpriteFrameWithFile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSpriteFrameWithFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_addSpriteFrameWithFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_getTotalDelayUnits(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_getTotalDelayUnits'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getTotalDelayUnits(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTotalDelayUnits",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_getTotalDelayUnits'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_getDelayPerUnit(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_getDelayPerUnit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDelayPerUnit(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDelayPerUnit",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_getDelayPerUnit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_getRestoreOriginalFrame(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_getRestoreOriginalFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getRestoreOriginalFrame(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRestoreOriginalFrame",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_getRestoreOriginalFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_addSpriteFrameWithTexture(lua_State* tolua_S) { int argc = 0; cocos2d::Animation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animation_addSpriteFrameWithTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Texture2D* arg0; cocos2d::Rect arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_rect(tolua_S, 3, &arg1); if(!ok) return 0; cobj->addSpriteFrameWithTexture(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSpriteFrameWithTexture",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_addSpriteFrameWithTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::Animation* ret = cocos2d::Animation::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } unsigned int arg2; ok &= luaval_to_uint32(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Animation* ret = cocos2d::Animation::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::Animation* ret = cocos2d::Animation::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animation_createWithSpriteFrames(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Animation",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Animation* ret = cocos2d::Animation::createWithSpriteFrames(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Vector arg0; double arg1; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::Animation* ret = cocos2d::Animation::createWithSpriteFrames(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithSpriteFrames",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animation_createWithSpriteFrames'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Animation_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Animation)"); return 0; } int lua_register_cocos2dx_Animation(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Animation"); tolua_cclass(tolua_S,"Animation","cc.Animation","cc.Object",NULL); tolua_beginmodule(tolua_S,"Animation"); tolua_function(tolua_S,"getLoops",lua_cocos2dx_Animation_getLoops); tolua_function(tolua_S,"addSpriteFrame",lua_cocos2dx_Animation_addSpriteFrame); tolua_function(tolua_S,"setRestoreOriginalFrame",lua_cocos2dx_Animation_setRestoreOriginalFrame); tolua_function(tolua_S,"clone",lua_cocos2dx_Animation_clone); tolua_function(tolua_S,"getDuration",lua_cocos2dx_Animation_getDuration); tolua_function(tolua_S,"setFrames",lua_cocos2dx_Animation_setFrames); tolua_function(tolua_S,"getFrames",lua_cocos2dx_Animation_getFrames); tolua_function(tolua_S,"setLoops",lua_cocos2dx_Animation_setLoops); tolua_function(tolua_S,"setDelayPerUnit",lua_cocos2dx_Animation_setDelayPerUnit); tolua_function(tolua_S,"addSpriteFrameWithFile",lua_cocos2dx_Animation_addSpriteFrameWithFile); tolua_function(tolua_S,"getTotalDelayUnits",lua_cocos2dx_Animation_getTotalDelayUnits); tolua_function(tolua_S,"getDelayPerUnit",lua_cocos2dx_Animation_getDelayPerUnit); tolua_function(tolua_S,"getRestoreOriginalFrame",lua_cocos2dx_Animation_getRestoreOriginalFrame); tolua_function(tolua_S,"addSpriteFrameWithTexture",lua_cocos2dx_Animation_addSpriteFrameWithTexture); tolua_function(tolua_S,"create", lua_cocos2dx_Animation_create); tolua_function(tolua_S,"createWithSpriteFrames", lua_cocos2dx_Animation_createWithSpriteFrames); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Animation).name(); g_luaType[typeName] = "cc.Animation"; g_typeCast["Animation"] = "cc.Animation"; return 1; } int lua_cocos2dx_ActionInterval_getAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::ActionInterval* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionInterval",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionInterval_getAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitudeRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitudeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionInterval_getAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionInterval_setAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::ActionInterval* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionInterval",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionInterval_setAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitudeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitudeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionInterval_setAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionInterval_getElapsed(lua_State* tolua_S) { int argc = 0; cocos2d::ActionInterval* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionInterval",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionInterval_getElapsed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getElapsed(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getElapsed",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionInterval_getElapsed'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ActionInterval_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ActionInterval)"); return 0; } int lua_register_cocos2dx_ActionInterval(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ActionInterval"); tolua_cclass(tolua_S,"ActionInterval","cc.ActionInterval","cc.FiniteTimeAction",NULL); tolua_beginmodule(tolua_S,"ActionInterval"); tolua_function(tolua_S,"getAmplitudeRate",lua_cocos2dx_ActionInterval_getAmplitudeRate); tolua_function(tolua_S,"setAmplitudeRate",lua_cocos2dx_ActionInterval_setAmplitudeRate); tolua_function(tolua_S,"getElapsed",lua_cocos2dx_ActionInterval_getElapsed); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ActionInterval).name(); g_luaType[typeName] = "cc.ActionInterval"; g_typeCast["ActionInterval"] = "cc.ActionInterval"; return 1; } static int lua_cocos2dx_Sequence_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Sequence)"); return 0; } int lua_register_cocos2dx_Sequence(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Sequence"); tolua_cclass(tolua_S,"Sequence","cc.Sequence","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"Sequence"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Sequence).name(); g_luaType[typeName] = "cc.Sequence"; g_typeCast["Sequence"] = "cc.Sequence"; return 1; } int lua_cocos2dx_Repeat_setInnerAction(lua_State* tolua_S) { int argc = 0; cocos2d::Repeat* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Repeat",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Repeat*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Repeat_setInnerAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::FiniteTimeAction* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.FiniteTimeAction",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::FiniteTimeAction*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setInnerAction(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInnerAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Repeat_setInnerAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Repeat_getInnerAction(lua_State* tolua_S) { int argc = 0; cocos2d::Repeat* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Repeat",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Repeat*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Repeat_getInnerAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::FiniteTimeAction* ret = cobj->getInnerAction(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FiniteTimeAction"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FiniteTimeAction*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInnerAction",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Repeat_getInnerAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Repeat_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Repeat",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::FiniteTimeAction* arg0; unsigned int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.FiniteTimeAction",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::FiniteTimeAction*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_uint32(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::Repeat* ret = cocos2d::Repeat::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Repeat"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Repeat*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Repeat_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Repeat_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Repeat)"); return 0; } int lua_register_cocos2dx_Repeat(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Repeat"); tolua_cclass(tolua_S,"Repeat","cc.Repeat","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"Repeat"); tolua_function(tolua_S,"setInnerAction",lua_cocos2dx_Repeat_setInnerAction); tolua_function(tolua_S,"getInnerAction",lua_cocos2dx_Repeat_getInnerAction); tolua_function(tolua_S,"create", lua_cocos2dx_Repeat_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Repeat).name(); g_luaType[typeName] = "cc.Repeat"; g_typeCast["Repeat"] = "cc.Repeat"; return 1; } int lua_cocos2dx_RepeatForever_setInnerAction(lua_State* tolua_S) { int argc = 0; cocos2d::RepeatForever* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RepeatForever",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RepeatForever*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RepeatForever_setInnerAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setInnerAction(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInnerAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RepeatForever_setInnerAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RepeatForever_getInnerAction(lua_State* tolua_S) { int argc = 0; cocos2d::RepeatForever* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RepeatForever",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RepeatForever*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RepeatForever_getInnerAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->getInnerAction(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInnerAction",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RepeatForever_getInnerAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RepeatForever_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.RepeatForever",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::RepeatForever* ret = cocos2d::RepeatForever::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RepeatForever"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RepeatForever*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RepeatForever_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_RepeatForever_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (RepeatForever)"); return 0; } int lua_register_cocos2dx_RepeatForever(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.RepeatForever"); tolua_cclass(tolua_S,"RepeatForever","cc.RepeatForever","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"RepeatForever"); tolua_function(tolua_S,"setInnerAction",lua_cocos2dx_RepeatForever_setInnerAction); tolua_function(tolua_S,"getInnerAction",lua_cocos2dx_RepeatForever_getInnerAction); tolua_function(tolua_S,"create", lua_cocos2dx_RepeatForever_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::RepeatForever).name(); g_luaType[typeName] = "cc.RepeatForever"; g_typeCast["RepeatForever"] = "cc.RepeatForever"; return 1; } static int lua_cocos2dx_Spawn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Spawn)"); return 0; } int lua_register_cocos2dx_Spawn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Spawn"); tolua_cclass(tolua_S,"Spawn","cc.Spawn","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"Spawn"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Spawn).name(); g_luaType[typeName] = "cc.Spawn"; g_typeCast["Spawn"] = "cc.Spawn"; return 1; } int lua_cocos2dx_RotateTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.RotateTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::RotateTo* ret = cocos2d::RotateTo::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RotateTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RotateTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::RotateTo* ret = cocos2d::RotateTo::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RotateTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RotateTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RotateTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_RotateTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (RotateTo)"); return 0; } int lua_register_cocos2dx_RotateTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.RotateTo"); tolua_cclass(tolua_S,"RotateTo","cc.RotateTo","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"RotateTo"); tolua_function(tolua_S,"create", lua_cocos2dx_RotateTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::RotateTo).name(); g_luaType[typeName] = "cc.RotateTo"; g_typeCast["RotateTo"] = "cc.RotateTo"; return 1; } int lua_cocos2dx_RotateBy_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.RotateBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::RotateBy* ret = cocos2d::RotateBy::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RotateBy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RotateBy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::RotateBy* ret = cocos2d::RotateBy::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RotateBy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RotateBy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RotateBy_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_RotateBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (RotateBy)"); return 0; } int lua_register_cocos2dx_RotateBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.RotateBy"); tolua_cclass(tolua_S,"RotateBy","cc.RotateBy","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"RotateBy"); tolua_function(tolua_S,"create", lua_cocos2dx_RotateBy_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::RotateBy).name(); g_luaType[typeName] = "cc.RotateBy"; g_typeCast["RotateBy"] = "cc.RotateBy"; return 1; } int lua_cocos2dx_MoveBy_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.MoveBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Point arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::MoveBy* ret = cocos2d::MoveBy::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.MoveBy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::MoveBy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MoveBy_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MoveBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MoveBy)"); return 0; } int lua_register_cocos2dx_MoveBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MoveBy"); tolua_cclass(tolua_S,"MoveBy","cc.MoveBy","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"MoveBy"); tolua_function(tolua_S,"create", lua_cocos2dx_MoveBy_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MoveBy).name(); g_luaType[typeName] = "cc.MoveBy"; g_typeCast["MoveBy"] = "cc.MoveBy"; return 1; } int lua_cocos2dx_MoveTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.MoveTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Point arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::MoveTo* ret = cocos2d::MoveTo::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.MoveTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::MoveTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MoveTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MoveTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MoveTo)"); return 0; } int lua_register_cocos2dx_MoveTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MoveTo"); tolua_cclass(tolua_S,"MoveTo","cc.MoveTo","cc.MoveBy",NULL); tolua_beginmodule(tolua_S,"MoveTo"); tolua_function(tolua_S,"create", lua_cocos2dx_MoveTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MoveTo).name(); g_luaType[typeName] = "cc.MoveTo"; g_typeCast["MoveTo"] = "cc.MoveTo"; return 1; } int lua_cocos2dx_SkewTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SkewTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { double arg0; double arg1; double arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cocos2d::SkewTo* ret = cocos2d::SkewTo::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SkewTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SkewTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SkewTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_SkewTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SkewTo)"); return 0; } int lua_register_cocos2dx_SkewTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.SkewTo"); tolua_cclass(tolua_S,"SkewTo","cc.SkewTo","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"SkewTo"); tolua_function(tolua_S,"create", lua_cocos2dx_SkewTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::SkewTo).name(); g_luaType[typeName] = "cc.SkewTo"; g_typeCast["SkewTo"] = "cc.SkewTo"; return 1; } int lua_cocos2dx_SkewBy_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SkewBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { double arg0; double arg1; double arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cocos2d::SkewBy* ret = cocos2d::SkewBy::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SkewBy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SkewBy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SkewBy_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_SkewBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SkewBy)"); return 0; } int lua_register_cocos2dx_SkewBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.SkewBy"); tolua_cclass(tolua_S,"SkewBy","cc.SkewBy","cc.SkewTo",NULL); tolua_beginmodule(tolua_S,"SkewBy"); tolua_function(tolua_S,"create", lua_cocos2dx_SkewBy_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::SkewBy).name(); g_luaType[typeName] = "cc.SkewBy"; g_typeCast["SkewBy"] = "cc.SkewBy"; return 1; } int lua_cocos2dx_JumpBy_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.JumpBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Point arg1; double arg2; int arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cocos2d::JumpBy* ret = cocos2d::JumpBy::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.JumpBy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::JumpBy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_JumpBy_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_JumpBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (JumpBy)"); return 0; } int lua_register_cocos2dx_JumpBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.JumpBy"); tolua_cclass(tolua_S,"JumpBy","cc.JumpBy","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"JumpBy"); tolua_function(tolua_S,"create", lua_cocos2dx_JumpBy_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::JumpBy).name(); g_luaType[typeName] = "cc.JumpBy"; g_typeCast["JumpBy"] = "cc.JumpBy"; return 1; } int lua_cocos2dx_JumpTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.JumpTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Point arg1; double arg2; int arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cocos2d::JumpTo* ret = cocos2d::JumpTo::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.JumpTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::JumpTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_JumpTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_JumpTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (JumpTo)"); return 0; } int lua_register_cocos2dx_JumpTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.JumpTo"); tolua_cclass(tolua_S,"JumpTo","cc.JumpTo","cc.JumpBy",NULL); tolua_beginmodule(tolua_S,"JumpTo"); tolua_function(tolua_S,"create", lua_cocos2dx_JumpTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::JumpTo).name(); g_luaType[typeName] = "cc.JumpTo"; g_typeCast["JumpTo"] = "cc.JumpTo"; return 1; } static int lua_cocos2dx_BezierBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (BezierBy)"); return 0; } int lua_register_cocos2dx_BezierBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.BezierBy"); tolua_cclass(tolua_S,"BezierBy","cc.BezierBy","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"BezierBy"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::BezierBy).name(); g_luaType[typeName] = "cc.BezierBy"; g_typeCast["BezierBy"] = "cc.BezierBy"; return 1; } static int lua_cocos2dx_BezierTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (BezierTo)"); return 0; } int lua_register_cocos2dx_BezierTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.BezierTo"); tolua_cclass(tolua_S,"BezierTo","cc.BezierTo","cc.BezierBy",NULL); tolua_beginmodule(tolua_S,"BezierTo"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::BezierTo).name(); g_luaType[typeName] = "cc.BezierTo"; g_typeCast["BezierTo"] = "cc.BezierTo"; return 1; } int lua_cocos2dx_ScaleTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ScaleTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::ScaleTo* ret = cocos2d::ScaleTo::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ScaleTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ScaleTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::ScaleTo* ret = cocos2d::ScaleTo::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ScaleTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ScaleTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ScaleTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ScaleTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ScaleTo)"); return 0; } int lua_register_cocos2dx_ScaleTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ScaleTo"); tolua_cclass(tolua_S,"ScaleTo","cc.ScaleTo","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"ScaleTo"); tolua_function(tolua_S,"create", lua_cocos2dx_ScaleTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ScaleTo).name(); g_luaType[typeName] = "cc.ScaleTo"; g_typeCast["ScaleTo"] = "cc.ScaleTo"; return 1; } int lua_cocos2dx_ScaleBy_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ScaleBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::ScaleBy* ret = cocos2d::ScaleBy::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ScaleBy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ScaleBy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::ScaleBy* ret = cocos2d::ScaleBy::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ScaleBy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ScaleBy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ScaleBy_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ScaleBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ScaleBy)"); return 0; } int lua_register_cocos2dx_ScaleBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ScaleBy"); tolua_cclass(tolua_S,"ScaleBy","cc.ScaleBy","cc.ScaleTo",NULL); tolua_beginmodule(tolua_S,"ScaleBy"); tolua_function(tolua_S,"create", lua_cocos2dx_ScaleBy_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ScaleBy).name(); g_luaType[typeName] = "cc.ScaleBy"; g_typeCast["ScaleBy"] = "cc.ScaleBy"; return 1; } int lua_cocos2dx_Blink_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Blink",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; int arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cocos2d::Blink* ret = cocos2d::Blink::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Blink"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Blink*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Blink_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Blink_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Blink)"); return 0; } int lua_register_cocos2dx_Blink(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Blink"); tolua_cclass(tolua_S,"Blink","cc.Blink","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"Blink"); tolua_function(tolua_S,"create", lua_cocos2dx_Blink_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Blink).name(); g_luaType[typeName] = "cc.Blink"; g_typeCast["Blink"] = "cc.Blink"; return 1; } int lua_cocos2dx_FadeIn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FadeIn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::FadeIn* ret = cocos2d::FadeIn::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FadeIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FadeIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeIn_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FadeIn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FadeIn)"); return 0; } int lua_register_cocos2dx_FadeIn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FadeIn"); tolua_cclass(tolua_S,"FadeIn","cc.FadeIn","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"FadeIn"); tolua_function(tolua_S,"create", lua_cocos2dx_FadeIn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FadeIn).name(); g_luaType[typeName] = "cc.FadeIn"; g_typeCast["FadeIn"] = "cc.FadeIn"; return 1; } int lua_cocos2dx_FadeOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FadeOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::FadeOut* ret = cocos2d::FadeOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FadeOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FadeOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FadeOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FadeOut)"); return 0; } int lua_register_cocos2dx_FadeOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FadeOut"); tolua_cclass(tolua_S,"FadeOut","cc.FadeOut","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"FadeOut"); tolua_function(tolua_S,"create", lua_cocos2dx_FadeOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FadeOut).name(); g_luaType[typeName] = "cc.FadeOut"; g_typeCast["FadeOut"] = "cc.FadeOut"; return 1; } int lua_cocos2dx_FadeTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FadeTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; uint16_t arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_uint16(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::FadeTo* ret = cocos2d::FadeTo::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FadeTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FadeTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FadeTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FadeTo)"); return 0; } int lua_register_cocos2dx_FadeTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FadeTo"); tolua_cclass(tolua_S,"FadeTo","cc.FadeTo","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"FadeTo"); tolua_function(tolua_S,"create", lua_cocos2dx_FadeTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FadeTo).name(); g_luaType[typeName] = "cc.FadeTo"; g_typeCast["FadeTo"] = "cc.FadeTo"; return 1; } int lua_cocos2dx_TintTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TintTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; uint16_t arg1; uint16_t arg2; uint16_t arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_uint16(tolua_S, 3,&arg1); ok &= luaval_to_uint16(tolua_S, 4,&arg2); ok &= luaval_to_uint16(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::TintTo* ret = cocos2d::TintTo::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TintTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TintTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TintTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TintTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TintTo)"); return 0; } int lua_register_cocos2dx_TintTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TintTo"); tolua_cclass(tolua_S,"TintTo","cc.TintTo","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"TintTo"); tolua_function(tolua_S,"create", lua_cocos2dx_TintTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TintTo).name(); g_luaType[typeName] = "cc.TintTo"; g_typeCast["TintTo"] = "cc.TintTo"; return 1; } int lua_cocos2dx_TintBy_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TintBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,&arg1); ok &= luaval_to_int32(tolua_S, 4,&arg2); ok &= luaval_to_int32(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::TintBy* ret = cocos2d::TintBy::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TintBy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TintBy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TintBy_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TintBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TintBy)"); return 0; } int lua_register_cocos2dx_TintBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TintBy"); tolua_cclass(tolua_S,"TintBy","cc.TintBy","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"TintBy"); tolua_function(tolua_S,"create", lua_cocos2dx_TintBy_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TintBy).name(); g_luaType[typeName] = "cc.TintBy"; g_typeCast["TintBy"] = "cc.TintBy"; return 1; } int lua_cocos2dx_DelayTime_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.DelayTime",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::DelayTime* ret = cocos2d::DelayTime::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.DelayTime"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::DelayTime*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DelayTime_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_DelayTime_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (DelayTime)"); return 0; } int lua_register_cocos2dx_DelayTime(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.DelayTime"); tolua_cclass(tolua_S,"DelayTime","cc.DelayTime","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"DelayTime"); tolua_function(tolua_S,"create", lua_cocos2dx_DelayTime_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::DelayTime).name(); g_luaType[typeName] = "cc.DelayTime"; g_typeCast["DelayTime"] = "cc.DelayTime"; return 1; } int lua_cocos2dx_Animate_getAnimation(lua_State* tolua_S) { int argc = 0; cocos2d::Animate* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animate",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animate*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animate_getAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::Animation* ret = cobj->getAnimation(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::Animation* ret = cobj->getAnimation(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animate_getAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animate_setAnimation(lua_State* tolua_S) { int argc = 0; cocos2d::Animate* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Animate",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Animate*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Animate_setAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Animation* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Animation",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Animation*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setAnimation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animate_setAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Animate_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Animate",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Animation* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Animation",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Animation*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Animate* ret = cocos2d::Animate::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animate"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animate*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Animate_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Animate_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Animate)"); return 0; } int lua_register_cocos2dx_Animate(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Animate"); tolua_cclass(tolua_S,"Animate","cc.Animate","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"Animate"); tolua_function(tolua_S,"getAnimation",lua_cocos2dx_Animate_getAnimation); tolua_function(tolua_S,"setAnimation",lua_cocos2dx_Animate_setAnimation); tolua_function(tolua_S,"create", lua_cocos2dx_Animate_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Animate).name(); g_luaType[typeName] = "cc.Animate"; g_typeCast["Animate"] = "cc.Animate"; return 1; } int lua_cocos2dx_TargetedAction_getForcedTarget(lua_State* tolua_S) { int argc = 0; cocos2d::TargetedAction* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TargetedAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TargetedAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TargetedAction_getForcedTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::Node* ret = cobj->getForcedTarget(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::Node* ret = cobj->getForcedTarget(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getForcedTarget",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TargetedAction_getForcedTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TargetedAction_setForcedTarget(lua_State* tolua_S) { int argc = 0; cocos2d::TargetedAction* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TargetedAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TargetedAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TargetedAction_setForcedTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setForcedTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setForcedTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TargetedAction_setForcedTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TargetedAction_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TargetedAction",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::Node* arg0; cocos2d::FiniteTimeAction* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.FiniteTimeAction",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::FiniteTimeAction*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TargetedAction* ret = cocos2d::TargetedAction::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TargetedAction"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TargetedAction*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TargetedAction_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TargetedAction_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TargetedAction)"); return 0; } int lua_register_cocos2dx_TargetedAction(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TargetedAction"); tolua_cclass(tolua_S,"TargetedAction","cc.TargetedAction","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"TargetedAction"); tolua_function(tolua_S,"getForcedTarget",lua_cocos2dx_TargetedAction_getForcedTarget); tolua_function(tolua_S,"setForcedTarget",lua_cocos2dx_TargetedAction_setForcedTarget); tolua_function(tolua_S,"create", lua_cocos2dx_TargetedAction_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TargetedAction).name(); g_luaType[typeName] = "cc.TargetedAction"; g_typeCast["TargetedAction"] = "cc.TargetedAction"; return 1; } int lua_cocos2dx_ActionCamera_setEye(lua_State* tolua_S) { int argc = 0; cocos2d::ActionCamera* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionCamera_setEye'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cobj->setEye(arg0, arg1, arg2); return 0; } }while(0); ok = true; do{ if (argc == 1) { kmVec3 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmVec3; if (!ok) { break; } cobj->setEye(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEye",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionCamera_setEye'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionCamera_getEye(lua_State* tolua_S) { int argc = 0; cocos2d::ActionCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionCamera_getEye'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const kmVec3& ret = cobj->getEye(); #pragma warning NO CONVERSION FROM NATIVE FOR kmVec3; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEye",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionCamera_getEye'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionCamera_setUp(lua_State* tolua_S) { int argc = 0; cocos2d::ActionCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionCamera_setUp'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { kmVec3 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmVec3; if(!ok) return 0; cobj->setUp(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUp",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionCamera_setUp'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionCamera_getCenter(lua_State* tolua_S) { int argc = 0; cocos2d::ActionCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionCamera_getCenter'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const kmVec3& ret = cobj->getCenter(); #pragma warning NO CONVERSION FROM NATIVE FOR kmVec3; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCenter",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionCamera_getCenter'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionCamera_setCenter(lua_State* tolua_S) { int argc = 0; cocos2d::ActionCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionCamera_setCenter'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { kmVec3 arg0; #pragma warning NO CONVERSION TO NATIVE FOR kmVec3; if(!ok) return 0; cobj->setCenter(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCenter",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionCamera_setCenter'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionCamera_getUp(lua_State* tolua_S) { int argc = 0; cocos2d::ActionCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionCamera_getUp'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const kmVec3& ret = cobj->getUp(); #pragma warning NO CONVERSION FROM NATIVE FOR kmVec3; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUp",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionCamera_getUp'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionCamera_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::ActionCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::ActionCamera(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ActionCamera"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ActionCamera"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ActionCamera",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionCamera_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ActionCamera_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ActionCamera)"); return 0; } int lua_register_cocos2dx_ActionCamera(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ActionCamera"); tolua_cclass(tolua_S,"ActionCamera","cc.ActionCamera","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"ActionCamera"); tolua_function(tolua_S,"setEye",lua_cocos2dx_ActionCamera_setEye); tolua_function(tolua_S,"getEye",lua_cocos2dx_ActionCamera_getEye); tolua_function(tolua_S,"setUp",lua_cocos2dx_ActionCamera_setUp); tolua_function(tolua_S,"getCenter",lua_cocos2dx_ActionCamera_getCenter); tolua_function(tolua_S,"setCenter",lua_cocos2dx_ActionCamera_setCenter); tolua_function(tolua_S,"getUp",lua_cocos2dx_ActionCamera_getUp); tolua_function(tolua_S,"new",lua_cocos2dx_ActionCamera_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ActionCamera).name(); g_luaType[typeName] = "cc.ActionCamera"; g_typeCast["ActionCamera"] = "cc.ActionCamera"; return 1; } int lua_cocos2dx_OrbitCamera_sphericalRadius(lua_State* tolua_S) { int argc = 0; cocos2d::OrbitCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.OrbitCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::OrbitCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_OrbitCamera_sphericalRadius'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { float* arg0; float* arg1; float* arg2; #pragma warning NO CONVERSION TO NATIVE FOR float*; #pragma warning NO CONVERSION TO NATIVE FOR float*; #pragma warning NO CONVERSION TO NATIVE FOR float*; if(!ok) return 0; cobj->sphericalRadius(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "sphericalRadius",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_OrbitCamera_sphericalRadius'.",&tolua_err); #endif return 0; } int lua_cocos2dx_OrbitCamera_initWithDuration(lua_State* tolua_S) { int argc = 0; cocos2d::OrbitCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.OrbitCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::OrbitCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_OrbitCamera_initWithDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 7) { double arg0; double arg1; double arg2; double arg3; double arg4; double arg5; double arg6; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); ok &= luaval_to_number(tolua_S, 6,&arg4); ok &= luaval_to_number(tolua_S, 7,&arg5); ok &= luaval_to_number(tolua_S, 8,&arg6); if(!ok) return 0; bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3, arg4, arg5, arg6); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithDuration",argc, 7); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_OrbitCamera_initWithDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_OrbitCamera_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.OrbitCamera",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 7) { double arg0; double arg1; double arg2; double arg3; double arg4; double arg5; double arg6; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); ok &= luaval_to_number(tolua_S, 6,&arg4); ok &= luaval_to_number(tolua_S, 7,&arg5); ok &= luaval_to_number(tolua_S, 8,&arg6); if(!ok) return 0; cocos2d::OrbitCamera* ret = cocos2d::OrbitCamera::create(arg0, arg1, arg2, arg3, arg4, arg5, arg6); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.OrbitCamera"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::OrbitCamera*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 7); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_OrbitCamera_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_OrbitCamera_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::OrbitCamera* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::OrbitCamera(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.OrbitCamera"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.OrbitCamera"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "OrbitCamera",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_OrbitCamera_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_OrbitCamera_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (OrbitCamera)"); return 0; } int lua_register_cocos2dx_OrbitCamera(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.OrbitCamera"); tolua_cclass(tolua_S,"OrbitCamera","cc.OrbitCamera","cc.ActionCamera",NULL); tolua_beginmodule(tolua_S,"OrbitCamera"); tolua_function(tolua_S,"sphericalRadius",lua_cocos2dx_OrbitCamera_sphericalRadius); tolua_function(tolua_S,"initWithDuration",lua_cocos2dx_OrbitCamera_initWithDuration); tolua_function(tolua_S,"new",lua_cocos2dx_OrbitCamera_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_OrbitCamera_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::OrbitCamera).name(); g_luaType[typeName] = "cc.OrbitCamera"; g_typeCast["OrbitCamera"] = "cc.OrbitCamera"; return 1; } int lua_cocos2dx_ActionManager_getActionByTag(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_getActionByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; const cocos2d::Node* arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (const cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Action* ret = cobj->getActionByTag(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Action"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Action*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getActionByTag",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_getActionByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_removeActionByTag(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_removeActionByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; cocos2d::Node* arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeActionByTag(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeActionByTag",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_removeActionByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_removeAllActions(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_removeAllActions'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllActions(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllActions",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_removeAllActions'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_addAction(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_addAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::Action* arg0; cocos2d::Node* arg1; bool arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.Action",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Action*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cobj->addAction(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addAction",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_addAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_resumeTarget(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_resumeTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->resumeTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_resumeTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; ssize_t ret = cobj->getNumberOfRunningActionsInTarget(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNumberOfRunningActionsInTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_removeAllActionsFromTarget(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_removeAllActionsFromTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeAllActionsFromTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllActionsFromTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_removeAllActionsFromTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_resumeTargets(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_resumeTargets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->resumeTargets(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeTargets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_resumeTargets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_removeAction(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_removeAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Action* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Action",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Action*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeAction(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_removeAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_pauseTarget(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_pauseTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->pauseTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_pauseTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_pauseAllRunningActions(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionManager_pauseAllRunningActions'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector ret = cobj->pauseAllRunningActions(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseAllRunningActions",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_pauseAllRunningActions'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionManager_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::ActionManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::ActionManager(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ActionManager"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ActionManager"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ActionManager",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionManager_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ActionManager_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ActionManager)"); return 0; } int lua_register_cocos2dx_ActionManager(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ActionManager"); tolua_cclass(tolua_S,"ActionManager","cc.ActionManager","cc.Object",NULL); tolua_beginmodule(tolua_S,"ActionManager"); tolua_function(tolua_S,"getActionByTag",lua_cocos2dx_ActionManager_getActionByTag); tolua_function(tolua_S,"removeActionByTag",lua_cocos2dx_ActionManager_removeActionByTag); tolua_function(tolua_S,"removeAllActions",lua_cocos2dx_ActionManager_removeAllActions); tolua_function(tolua_S,"addAction",lua_cocos2dx_ActionManager_addAction); tolua_function(tolua_S,"resumeTarget",lua_cocos2dx_ActionManager_resumeTarget); tolua_function(tolua_S,"getNumberOfRunningActionsInTarget",lua_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget); tolua_function(tolua_S,"removeAllActionsFromTarget",lua_cocos2dx_ActionManager_removeAllActionsFromTarget); tolua_function(tolua_S,"resumeTargets",lua_cocos2dx_ActionManager_resumeTargets); tolua_function(tolua_S,"removeAction",lua_cocos2dx_ActionManager_removeAction); tolua_function(tolua_S,"pauseTarget",lua_cocos2dx_ActionManager_pauseTarget); tolua_function(tolua_S,"pauseAllRunningActions",lua_cocos2dx_ActionManager_pauseAllRunningActions); tolua_function(tolua_S,"new",lua_cocos2dx_ActionManager_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ActionManager).name(); g_luaType[typeName] = "cc.ActionManager"; g_typeCast["ActionManager"] = "cc.ActionManager"; return 1; } int lua_cocos2dx_ActionEase_getInnerAction(lua_State* tolua_S) { int argc = 0; cocos2d::ActionEase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionEase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionEase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionEase_getInnerAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->getInnerAction(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInnerAction",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionEase_getInnerAction'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ActionEase_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ActionEase)"); return 0; } int lua_register_cocos2dx_ActionEase(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ActionEase"); tolua_cclass(tolua_S,"ActionEase","cc.ActionEase","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"ActionEase"); tolua_function(tolua_S,"getInnerAction",lua_cocos2dx_ActionEase_getInnerAction); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ActionEase).name(); g_luaType[typeName] = "cc.ActionEase"; g_typeCast["ActionEase"] = "cc.ActionEase"; return 1; } int lua_cocos2dx_EaseRateAction_setRate(lua_State* tolua_S) { int argc = 0; cocos2d::EaseRateAction* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EaseRateAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EaseRateAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EaseRateAction_setRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseRateAction_setRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EaseRateAction_getRate(lua_State* tolua_S) { int argc = 0; cocos2d::EaseRateAction* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EaseRateAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EaseRateAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EaseRateAction_getRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseRateAction_getRate'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseRateAction_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseRateAction)"); return 0; } int lua_register_cocos2dx_EaseRateAction(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseRateAction"); tolua_cclass(tolua_S,"EaseRateAction","cc.EaseRateAction","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseRateAction"); tolua_function(tolua_S,"setRate",lua_cocos2dx_EaseRateAction_setRate); tolua_function(tolua_S,"getRate",lua_cocos2dx_EaseRateAction_getRate); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseRateAction).name(); g_luaType[typeName] = "cc.EaseRateAction"; g_typeCast["EaseRateAction"] = "cc.EaseRateAction"; return 1; } int lua_cocos2dx_EaseIn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseIn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::ActionInterval* arg0; double arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::EaseIn* ret = cocos2d::EaseIn::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseIn_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseIn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseIn)"); return 0; } int lua_register_cocos2dx_EaseIn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseIn"); tolua_cclass(tolua_S,"EaseIn","cc.EaseIn","cc.EaseRateAction",NULL); tolua_beginmodule(tolua_S,"EaseIn"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseIn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseIn).name(); g_luaType[typeName] = "cc.EaseIn"; g_typeCast["EaseIn"] = "cc.EaseIn"; return 1; } int lua_cocos2dx_EaseOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::ActionInterval* arg0; double arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::EaseOut* ret = cocos2d::EaseOut::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseOut)"); return 0; } int lua_register_cocos2dx_EaseOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseOut"); tolua_cclass(tolua_S,"EaseOut","cc.EaseOut","cc.EaseRateAction",NULL); tolua_beginmodule(tolua_S,"EaseOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseOut).name(); g_luaType[typeName] = "cc.EaseOut"; g_typeCast["EaseOut"] = "cc.EaseOut"; return 1; } int lua_cocos2dx_EaseInOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseInOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::ActionInterval* arg0; double arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::EaseInOut* ret = cocos2d::EaseInOut::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseInOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseInOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseInOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseInOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseInOut)"); return 0; } int lua_register_cocos2dx_EaseInOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseInOut"); tolua_cclass(tolua_S,"EaseInOut","cc.EaseInOut","cc.EaseRateAction",NULL); tolua_beginmodule(tolua_S,"EaseInOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseInOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseInOut).name(); g_luaType[typeName] = "cc.EaseInOut"; g_typeCast["EaseInOut"] = "cc.EaseInOut"; return 1; } int lua_cocos2dx_EaseExponentialIn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseExponentialIn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseExponentialIn* ret = cocos2d::EaseExponentialIn::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseExponentialIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseExponentialIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseExponentialIn_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseExponentialIn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseExponentialIn)"); return 0; } int lua_register_cocos2dx_EaseExponentialIn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseExponentialIn"); tolua_cclass(tolua_S,"EaseExponentialIn","cc.EaseExponentialIn","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseExponentialIn"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseExponentialIn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseExponentialIn).name(); g_luaType[typeName] = "cc.EaseExponentialIn"; g_typeCast["EaseExponentialIn"] = "cc.EaseExponentialIn"; return 1; } int lua_cocos2dx_EaseExponentialOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseExponentialOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseExponentialOut* ret = cocos2d::EaseExponentialOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseExponentialOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseExponentialOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseExponentialOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseExponentialOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseExponentialOut)"); return 0; } int lua_register_cocos2dx_EaseExponentialOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseExponentialOut"); tolua_cclass(tolua_S,"EaseExponentialOut","cc.EaseExponentialOut","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseExponentialOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseExponentialOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseExponentialOut).name(); g_luaType[typeName] = "cc.EaseExponentialOut"; g_typeCast["EaseExponentialOut"] = "cc.EaseExponentialOut"; return 1; } int lua_cocos2dx_EaseExponentialInOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseExponentialInOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseExponentialInOut* ret = cocos2d::EaseExponentialInOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseExponentialInOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseExponentialInOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseExponentialInOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseExponentialInOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseExponentialInOut)"); return 0; } int lua_register_cocos2dx_EaseExponentialInOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseExponentialInOut"); tolua_cclass(tolua_S,"EaseExponentialInOut","cc.EaseExponentialInOut","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseExponentialInOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseExponentialInOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseExponentialInOut).name(); g_luaType[typeName] = "cc.EaseExponentialInOut"; g_typeCast["EaseExponentialInOut"] = "cc.EaseExponentialInOut"; return 1; } int lua_cocos2dx_EaseSineIn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseSineIn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseSineIn* ret = cocos2d::EaseSineIn::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseSineIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseSineIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseSineIn_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseSineIn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseSineIn)"); return 0; } int lua_register_cocos2dx_EaseSineIn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseSineIn"); tolua_cclass(tolua_S,"EaseSineIn","cc.EaseSineIn","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseSineIn"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseSineIn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseSineIn).name(); g_luaType[typeName] = "cc.EaseSineIn"; g_typeCast["EaseSineIn"] = "cc.EaseSineIn"; return 1; } int lua_cocos2dx_EaseSineOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseSineOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseSineOut* ret = cocos2d::EaseSineOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseSineOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseSineOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseSineOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseSineOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseSineOut)"); return 0; } int lua_register_cocos2dx_EaseSineOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseSineOut"); tolua_cclass(tolua_S,"EaseSineOut","cc.EaseSineOut","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseSineOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseSineOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseSineOut).name(); g_luaType[typeName] = "cc.EaseSineOut"; g_typeCast["EaseSineOut"] = "cc.EaseSineOut"; return 1; } int lua_cocos2dx_EaseSineInOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseSineInOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseSineInOut* ret = cocos2d::EaseSineInOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseSineInOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseSineInOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseSineInOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseSineInOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseSineInOut)"); return 0; } int lua_register_cocos2dx_EaseSineInOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseSineInOut"); tolua_cclass(tolua_S,"EaseSineInOut","cc.EaseSineInOut","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseSineInOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseSineInOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseSineInOut).name(); g_luaType[typeName] = "cc.EaseSineInOut"; g_typeCast["EaseSineInOut"] = "cc.EaseSineInOut"; return 1; } int lua_cocos2dx_EaseElastic_setPeriod(lua_State* tolua_S) { int argc = 0; cocos2d::EaseElastic* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EaseElastic",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EaseElastic*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EaseElastic_setPeriod'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPeriod(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPeriod",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseElastic_setPeriod'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EaseElastic_getPeriod(lua_State* tolua_S) { int argc = 0; cocos2d::EaseElastic* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EaseElastic",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EaseElastic*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EaseElastic_getPeriod'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getPeriod(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPeriod",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseElastic_getPeriod'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseElastic_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseElastic)"); return 0; } int lua_register_cocos2dx_EaseElastic(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseElastic"); tolua_cclass(tolua_S,"EaseElastic","cc.EaseElastic","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseElastic"); tolua_function(tolua_S,"setPeriod",lua_cocos2dx_EaseElastic_setPeriod); tolua_function(tolua_S,"getPeriod",lua_cocos2dx_EaseElastic_getPeriod); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseElastic).name(); g_luaType[typeName] = "cc.EaseElastic"; g_typeCast["EaseElastic"] = "cc.EaseElastic"; return 1; } int lua_cocos2dx_EaseElasticIn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseElasticIn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::EaseElasticIn* ret = cocos2d::EaseElasticIn::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseElasticIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseElasticIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::EaseElasticIn* ret = cocos2d::EaseElasticIn::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseElasticIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseElasticIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseElasticIn_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseElasticIn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseElasticIn)"); return 0; } int lua_register_cocos2dx_EaseElasticIn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseElasticIn"); tolua_cclass(tolua_S,"EaseElasticIn","cc.EaseElasticIn","cc.EaseElastic",NULL); tolua_beginmodule(tolua_S,"EaseElasticIn"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseElasticIn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseElasticIn).name(); g_luaType[typeName] = "cc.EaseElasticIn"; g_typeCast["EaseElasticIn"] = "cc.EaseElasticIn"; return 1; } int lua_cocos2dx_EaseElasticOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseElasticOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::EaseElasticOut* ret = cocos2d::EaseElasticOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseElasticOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseElasticOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::EaseElasticOut* ret = cocos2d::EaseElasticOut::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseElasticOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseElasticOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseElasticOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseElasticOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseElasticOut)"); return 0; } int lua_register_cocos2dx_EaseElasticOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseElasticOut"); tolua_cclass(tolua_S,"EaseElasticOut","cc.EaseElasticOut","cc.EaseElastic",NULL); tolua_beginmodule(tolua_S,"EaseElasticOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseElasticOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseElasticOut).name(); g_luaType[typeName] = "cc.EaseElasticOut"; g_typeCast["EaseElasticOut"] = "cc.EaseElasticOut"; return 1; } int lua_cocos2dx_EaseElasticInOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseElasticInOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::EaseElasticInOut* ret = cocos2d::EaseElasticInOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseElasticInOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseElasticInOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::EaseElasticInOut* ret = cocos2d::EaseElasticInOut::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseElasticInOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseElasticInOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseElasticInOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseElasticInOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseElasticInOut)"); return 0; } int lua_register_cocos2dx_EaseElasticInOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseElasticInOut"); tolua_cclass(tolua_S,"EaseElasticInOut","cc.EaseElasticInOut","cc.EaseElastic",NULL); tolua_beginmodule(tolua_S,"EaseElasticInOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseElasticInOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseElasticInOut).name(); g_luaType[typeName] = "cc.EaseElasticInOut"; g_typeCast["EaseElasticInOut"] = "cc.EaseElasticInOut"; return 1; } int lua_cocos2dx_EaseBounce_bounceTime(lua_State* tolua_S) { int argc = 0; cocos2d::EaseBounce* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EaseBounce",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EaseBounce*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EaseBounce_bounceTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; double ret = cobj->bounceTime(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "bounceTime",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseBounce_bounceTime'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseBounce_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseBounce)"); return 0; } int lua_register_cocos2dx_EaseBounce(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseBounce"); tolua_cclass(tolua_S,"EaseBounce","cc.EaseBounce","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseBounce"); tolua_function(tolua_S,"bounceTime",lua_cocos2dx_EaseBounce_bounceTime); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseBounce).name(); g_luaType[typeName] = "cc.EaseBounce"; g_typeCast["EaseBounce"] = "cc.EaseBounce"; return 1; } int lua_cocos2dx_EaseBounceIn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseBounceIn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseBounceIn* ret = cocos2d::EaseBounceIn::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseBounceIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseBounceIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseBounceIn_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseBounceIn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseBounceIn)"); return 0; } int lua_register_cocos2dx_EaseBounceIn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseBounceIn"); tolua_cclass(tolua_S,"EaseBounceIn","cc.EaseBounceIn","cc.EaseBounce",NULL); tolua_beginmodule(tolua_S,"EaseBounceIn"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseBounceIn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseBounceIn).name(); g_luaType[typeName] = "cc.EaseBounceIn"; g_typeCast["EaseBounceIn"] = "cc.EaseBounceIn"; return 1; } int lua_cocos2dx_EaseBounceOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseBounceOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseBounceOut* ret = cocos2d::EaseBounceOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseBounceOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseBounceOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseBounceOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseBounceOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseBounceOut)"); return 0; } int lua_register_cocos2dx_EaseBounceOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseBounceOut"); tolua_cclass(tolua_S,"EaseBounceOut","cc.EaseBounceOut","cc.EaseBounce",NULL); tolua_beginmodule(tolua_S,"EaseBounceOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseBounceOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseBounceOut).name(); g_luaType[typeName] = "cc.EaseBounceOut"; g_typeCast["EaseBounceOut"] = "cc.EaseBounceOut"; return 1; } int lua_cocos2dx_EaseBounceInOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseBounceInOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseBounceInOut* ret = cocos2d::EaseBounceInOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseBounceInOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseBounceInOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseBounceInOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseBounceInOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseBounceInOut)"); return 0; } int lua_register_cocos2dx_EaseBounceInOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseBounceInOut"); tolua_cclass(tolua_S,"EaseBounceInOut","cc.EaseBounceInOut","cc.EaseBounce",NULL); tolua_beginmodule(tolua_S,"EaseBounceInOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseBounceInOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseBounceInOut).name(); g_luaType[typeName] = "cc.EaseBounceInOut"; g_typeCast["EaseBounceInOut"] = "cc.EaseBounceInOut"; return 1; } int lua_cocos2dx_EaseBackIn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseBackIn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseBackIn* ret = cocos2d::EaseBackIn::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseBackIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseBackIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseBackIn_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseBackIn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseBackIn)"); return 0; } int lua_register_cocos2dx_EaseBackIn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseBackIn"); tolua_cclass(tolua_S,"EaseBackIn","cc.EaseBackIn","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseBackIn"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseBackIn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseBackIn).name(); g_luaType[typeName] = "cc.EaseBackIn"; g_typeCast["EaseBackIn"] = "cc.EaseBackIn"; return 1; } int lua_cocos2dx_EaseBackOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseBackOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseBackOut* ret = cocos2d::EaseBackOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseBackOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseBackOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseBackOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseBackOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseBackOut)"); return 0; } int lua_register_cocos2dx_EaseBackOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseBackOut"); tolua_cclass(tolua_S,"EaseBackOut","cc.EaseBackOut","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseBackOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseBackOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseBackOut).name(); g_luaType[typeName] = "cc.EaseBackOut"; g_typeCast["EaseBackOut"] = "cc.EaseBackOut"; return 1; } int lua_cocos2dx_EaseBackInOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EaseBackInOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EaseBackInOut* ret = cocos2d::EaseBackInOut::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EaseBackInOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EaseBackInOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EaseBackInOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EaseBackInOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EaseBackInOut)"); return 0; } int lua_register_cocos2dx_EaseBackInOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EaseBackInOut"); tolua_cclass(tolua_S,"EaseBackInOut","cc.EaseBackInOut","cc.ActionEase",NULL); tolua_beginmodule(tolua_S,"EaseBackInOut"); tolua_function(tolua_S,"create", lua_cocos2dx_EaseBackInOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EaseBackInOut).name(); g_luaType[typeName] = "cc.EaseBackInOut"; g_typeCast["EaseBackInOut"] = "cc.EaseBackInOut"; return 1; } static int lua_cocos2dx_ActionInstant_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ActionInstant)"); return 0; } int lua_register_cocos2dx_ActionInstant(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ActionInstant"); tolua_cclass(tolua_S,"ActionInstant","cc.ActionInstant","cc.FiniteTimeAction",NULL); tolua_beginmodule(tolua_S,"ActionInstant"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ActionInstant).name(); g_luaType[typeName] = "cc.ActionInstant"; g_typeCast["ActionInstant"] = "cc.ActionInstant"; return 1; } int lua_cocos2dx_Show_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Show",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Show* ret = cocos2d::Show::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Show"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Show*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Show_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Show_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Show)"); return 0; } int lua_register_cocos2dx_Show(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Show"); tolua_cclass(tolua_S,"Show","cc.Show","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"Show"); tolua_function(tolua_S,"create", lua_cocos2dx_Show_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Show).name(); g_luaType[typeName] = "cc.Show"; g_typeCast["Show"] = "cc.Show"; return 1; } int lua_cocos2dx_Hide_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Hide",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Hide* ret = cocos2d::Hide::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Hide"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Hide*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Hide_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Hide_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Hide)"); return 0; } int lua_register_cocos2dx_Hide(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Hide"); tolua_cclass(tolua_S,"Hide","cc.Hide","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"Hide"); tolua_function(tolua_S,"create", lua_cocos2dx_Hide_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Hide).name(); g_luaType[typeName] = "cc.Hide"; g_typeCast["Hide"] = "cc.Hide"; return 1; } int lua_cocos2dx_ToggleVisibility_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ToggleVisibility",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ToggleVisibility* ret = cocos2d::ToggleVisibility::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ToggleVisibility"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ToggleVisibility*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ToggleVisibility_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ToggleVisibility_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ToggleVisibility)"); return 0; } int lua_register_cocos2dx_ToggleVisibility(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ToggleVisibility"); tolua_cclass(tolua_S,"ToggleVisibility","cc.ToggleVisibility","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"ToggleVisibility"); tolua_function(tolua_S,"create", lua_cocos2dx_ToggleVisibility_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ToggleVisibility).name(); g_luaType[typeName] = "cc.ToggleVisibility"; g_typeCast["ToggleVisibility"] = "cc.ToggleVisibility"; return 1; } int lua_cocos2dx_RemoveSelf_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.RemoveSelf",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::RemoveSelf* ret = cocos2d::RemoveSelf::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RemoveSelf"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RemoveSelf*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::RemoveSelf* ret = cocos2d::RemoveSelf::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RemoveSelf"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RemoveSelf*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RemoveSelf_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_RemoveSelf_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (RemoveSelf)"); return 0; } int lua_register_cocos2dx_RemoveSelf(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.RemoveSelf"); tolua_cclass(tolua_S,"RemoveSelf","cc.RemoveSelf","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"RemoveSelf"); tolua_function(tolua_S,"create", lua_cocos2dx_RemoveSelf_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::RemoveSelf).name(); g_luaType[typeName] = "cc.RemoveSelf"; g_typeCast["RemoveSelf"] = "cc.RemoveSelf"; return 1; } int lua_cocos2dx_FlipX_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FlipX",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::FlipX* ret = cocos2d::FlipX::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FlipX"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FlipX*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FlipX_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FlipX_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FlipX)"); return 0; } int lua_register_cocos2dx_FlipX(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FlipX"); tolua_cclass(tolua_S,"FlipX","cc.FlipX","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"FlipX"); tolua_function(tolua_S,"create", lua_cocos2dx_FlipX_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FlipX).name(); g_luaType[typeName] = "cc.FlipX"; g_typeCast["FlipX"] = "cc.FlipX"; return 1; } int lua_cocos2dx_FlipY_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FlipY",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::FlipY* ret = cocos2d::FlipY::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FlipY"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FlipY*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FlipY_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FlipY_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FlipY)"); return 0; } int lua_register_cocos2dx_FlipY(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FlipY"); tolua_cclass(tolua_S,"FlipY","cc.FlipY","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"FlipY"); tolua_function(tolua_S,"create", lua_cocos2dx_FlipY_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FlipY).name(); g_luaType[typeName] = "cc.FlipY"; g_typeCast["FlipY"] = "cc.FlipY"; return 1; } int lua_cocos2dx_Place_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Place",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Place* ret = cocos2d::Place::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Place"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Place*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Place_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Place_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Place)"); return 0; } int lua_register_cocos2dx_Place(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Place"); tolua_cclass(tolua_S,"Place","cc.Place","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"Place"); tolua_function(tolua_S,"create", lua_cocos2dx_Place_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Place).name(); g_luaType[typeName] = "cc.Place"; g_typeCast["Place"] = "cc.Place"; return 1; } int lua_cocos2dx_CallFunc_execute(lua_State* tolua_S) { int argc = 0; cocos2d::CallFunc* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CallFunc",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::CallFunc*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CallFunc_execute'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->execute(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "execute",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CallFunc_execute'.",&tolua_err); #endif return 0; } int lua_cocos2dx_CallFunc_getTargetCallback(lua_State* tolua_S) { int argc = 0; cocos2d::CallFunc* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CallFunc",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::CallFunc*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CallFunc_getTargetCallback'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Object* ret = cobj->getTargetCallback(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Object"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Object*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTargetCallback",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CallFunc_getTargetCallback'.",&tolua_err); #endif return 0; } int lua_cocos2dx_CallFunc_setTargetCallback(lua_State* tolua_S) { int argc = 0; cocos2d::CallFunc* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CallFunc",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::CallFunc*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CallFunc_setTargetCallback'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Object* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Object",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Object*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTargetCallback(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTargetCallback",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CallFunc_setTargetCallback'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_CallFunc_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (CallFunc)"); return 0; } int lua_register_cocos2dx_CallFunc(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.CallFunc"); tolua_cclass(tolua_S,"CallFunc","cc.CallFunc","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"CallFunc"); tolua_function(tolua_S,"execute",lua_cocos2dx_CallFunc_execute); tolua_function(tolua_S,"getTargetCallback",lua_cocos2dx_CallFunc_getTargetCallback); tolua_function(tolua_S,"setTargetCallback",lua_cocos2dx_CallFunc_setTargetCallback); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::CallFunc).name(); g_luaType[typeName] = "cc.CallFunc"; g_typeCast["CallFunc"] = "cc.CallFunc"; return 1; } int lua_cocos2dx_GridAction_getGrid(lua_State* tolua_S) { int argc = 0; cocos2d::GridAction* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridAction_getGrid'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::GridBase* ret = cobj->getGrid(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GridBase"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GridBase*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGrid",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridAction_getGrid'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_GridAction_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (GridAction)"); return 0; } int lua_register_cocos2dx_GridAction(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.GridAction"); tolua_cclass(tolua_S,"GridAction","cc.GridAction","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"GridAction"); tolua_function(tolua_S,"getGrid",lua_cocos2dx_GridAction_getGrid); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::GridAction).name(); g_luaType[typeName] = "cc.GridAction"; g_typeCast["GridAction"] = "cc.GridAction"; return 1; } int lua_cocos2dx_Grid3DAction_getGrid(lua_State* tolua_S) { int argc = 0; cocos2d::Grid3DAction* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Grid3DAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Grid3DAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Grid3DAction_getGrid'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::GridBase* ret = cobj->getGrid(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GridBase"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GridBase*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGrid",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Grid3DAction_getGrid'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Grid3DAction_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Grid3DAction)"); return 0; } int lua_register_cocos2dx_Grid3DAction(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Grid3DAction"); tolua_cclass(tolua_S,"Grid3DAction","cc.Grid3DAction","cc.GridAction",NULL); tolua_beginmodule(tolua_S,"Grid3DAction"); tolua_function(tolua_S,"getGrid",lua_cocos2dx_Grid3DAction_getGrid); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Grid3DAction).name(); g_luaType[typeName] = "cc.Grid3DAction"; g_typeCast["Grid3DAction"] = "cc.Grid3DAction"; return 1; } int lua_cocos2dx_TiledGrid3DAction_getGrid(lua_State* tolua_S) { int argc = 0; cocos2d::TiledGrid3DAction* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TiledGrid3DAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TiledGrid3DAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TiledGrid3DAction_getGrid'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::GridBase* ret = cobj->getGrid(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GridBase"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GridBase*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGrid",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TiledGrid3DAction_getGrid'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TiledGrid3DAction_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TiledGrid3DAction)"); return 0; } int lua_register_cocos2dx_TiledGrid3DAction(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TiledGrid3DAction"); tolua_cclass(tolua_S,"TiledGrid3DAction","cc.TiledGrid3DAction","cc.GridAction",NULL); tolua_beginmodule(tolua_S,"TiledGrid3DAction"); tolua_function(tolua_S,"getGrid",lua_cocos2dx_TiledGrid3DAction_getGrid); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TiledGrid3DAction).name(); g_luaType[typeName] = "cc.TiledGrid3DAction"; g_typeCast["TiledGrid3DAction"] = "cc.TiledGrid3DAction"; return 1; } int lua_cocos2dx_StopGrid_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.StopGrid",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::StopGrid* ret = cocos2d::StopGrid::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.StopGrid"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::StopGrid*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_StopGrid_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_StopGrid_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (StopGrid)"); return 0; } int lua_register_cocos2dx_StopGrid(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.StopGrid"); tolua_cclass(tolua_S,"StopGrid","cc.StopGrid","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"StopGrid"); tolua_function(tolua_S,"create", lua_cocos2dx_StopGrid_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::StopGrid).name(); g_luaType[typeName] = "cc.StopGrid"; g_typeCast["StopGrid"] = "cc.StopGrid"; return 1; } int lua_cocos2dx_ReuseGrid_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ReuseGrid",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ReuseGrid* ret = cocos2d::ReuseGrid::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ReuseGrid"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ReuseGrid*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ReuseGrid_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ReuseGrid_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ReuseGrid)"); return 0; } int lua_register_cocos2dx_ReuseGrid(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ReuseGrid"); tolua_cclass(tolua_S,"ReuseGrid","cc.ReuseGrid","cc.ActionInstant",NULL); tolua_beginmodule(tolua_S,"ReuseGrid"); tolua_function(tolua_S,"create", lua_cocos2dx_ReuseGrid_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ReuseGrid).name(); g_luaType[typeName] = "cc.ReuseGrid"; g_typeCast["ReuseGrid"] = "cc.ReuseGrid"; return 1; } int lua_cocos2dx_Waves3D_getAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Waves3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Waves3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Waves3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Waves3D_getAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitudeRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitudeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves3D_getAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves3D_setAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Waves3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Waves3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Waves3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Waves3D_setAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitude(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitude",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves3D_setAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves3D_setAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Waves3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Waves3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Waves3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Waves3D_setAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitudeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitudeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves3D_setAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves3D_getAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Waves3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Waves3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Waves3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Waves3D_getAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitude(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitude",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves3D_getAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Waves3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_uint32(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::Waves3D* ret = cocos2d::Waves3D::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Waves3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Waves3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Waves3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Waves3D)"); return 0; } int lua_register_cocos2dx_Waves3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Waves3D"); tolua_cclass(tolua_S,"Waves3D","cc.Waves3D","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"Waves3D"); tolua_function(tolua_S,"getAmplitudeRate",lua_cocos2dx_Waves3D_getAmplitudeRate); tolua_function(tolua_S,"setAmplitude",lua_cocos2dx_Waves3D_setAmplitude); tolua_function(tolua_S,"setAmplitudeRate",lua_cocos2dx_Waves3D_setAmplitudeRate); tolua_function(tolua_S,"getAmplitude",lua_cocos2dx_Waves3D_getAmplitude); tolua_function(tolua_S,"create", lua_cocos2dx_Waves3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Waves3D).name(); g_luaType[typeName] = "cc.Waves3D"; g_typeCast["Waves3D"] = "cc.Waves3D"; return 1; } int lua_cocos2dx_FlipX3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FlipX3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::FlipX3D* ret = cocos2d::FlipX3D::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FlipX3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FlipX3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FlipX3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FlipX3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FlipX3D)"); return 0; } int lua_register_cocos2dx_FlipX3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FlipX3D"); tolua_cclass(tolua_S,"FlipX3D","cc.FlipX3D","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"FlipX3D"); tolua_function(tolua_S,"create", lua_cocos2dx_FlipX3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FlipX3D).name(); g_luaType[typeName] = "cc.FlipX3D"; g_typeCast["FlipX3D"] = "cc.FlipX3D"; return 1; } int lua_cocos2dx_FlipY3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FlipY3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::FlipY3D* ret = cocos2d::FlipY3D::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FlipY3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FlipY3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FlipY3D_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FlipY3D_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::FlipY3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::FlipY3D(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.FlipY3D"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.FlipY3D"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "FlipY3D",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FlipY3D_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FlipY3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FlipY3D)"); return 0; } int lua_register_cocos2dx_FlipY3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FlipY3D"); tolua_cclass(tolua_S,"FlipY3D","cc.FlipY3D","cc.FlipX3D",NULL); tolua_beginmodule(tolua_S,"FlipY3D"); tolua_function(tolua_S,"create", lua_cocos2dx_FlipY3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FlipY3D).name(); g_luaType[typeName] = "cc.FlipY3D"; g_typeCast["FlipY3D"] = "cc.FlipY3D"; return 1; } int lua_cocos2dx_Lens3D_setPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Lens3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Lens3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Lens3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Lens3D_setPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPosition(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPosition",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Lens3D_setPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Lens3D_setConcave(lua_State* tolua_S) { int argc = 0; cocos2d::Lens3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Lens3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Lens3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Lens3D_setConcave'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setConcave(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setConcave",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Lens3D_setConcave'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Lens3D_setLensEffect(lua_State* tolua_S) { int argc = 0; cocos2d::Lens3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Lens3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Lens3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Lens3D_setLensEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLensEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLensEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Lens3D_setLensEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Lens3D_getPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Lens3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Lens3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Lens3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Lens3D_getPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getPosition(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Lens3D_getPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Lens3D_getLensEffect(lua_State* tolua_S) { int argc = 0; cocos2d::Lens3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Lens3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Lens3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Lens3D_getLensEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getLensEffect(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLensEffect",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Lens3D_getLensEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Lens3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Lens3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Size arg1; cocos2d::Point arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::Lens3D* ret = cocos2d::Lens3D::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Lens3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Lens3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Lens3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Lens3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Lens3D)"); return 0; } int lua_register_cocos2dx_Lens3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Lens3D"); tolua_cclass(tolua_S,"Lens3D","cc.Lens3D","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"Lens3D"); tolua_function(tolua_S,"setPosition",lua_cocos2dx_Lens3D_setPosition); tolua_function(tolua_S,"setConcave",lua_cocos2dx_Lens3D_setConcave); tolua_function(tolua_S,"setLensEffect",lua_cocos2dx_Lens3D_setLensEffect); tolua_function(tolua_S,"getPosition",lua_cocos2dx_Lens3D_getPosition); tolua_function(tolua_S,"getLensEffect",lua_cocos2dx_Lens3D_getLensEffect); tolua_function(tolua_S,"create", lua_cocos2dx_Lens3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Lens3D).name(); g_luaType[typeName] = "cc.Lens3D"; g_typeCast["Lens3D"] = "cc.Lens3D"; return 1; } int lua_cocos2dx_Ripple3D_setAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Ripple3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Ripple3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Ripple3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Ripple3D_setAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitudeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitudeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Ripple3D_setAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Ripple3D_getAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Ripple3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Ripple3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Ripple3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Ripple3D_getAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitudeRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitudeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Ripple3D_getAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Ripple3D_setAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Ripple3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Ripple3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Ripple3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Ripple3D_setAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitude(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitude",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Ripple3D_setAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Ripple3D_getAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Ripple3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Ripple3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Ripple3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Ripple3D_getAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitude(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitude",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Ripple3D_getAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Ripple3D_setPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Ripple3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Ripple3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Ripple3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Ripple3D_setPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPosition(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPosition",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Ripple3D_setPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Ripple3D_getPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Ripple3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Ripple3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Ripple3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Ripple3D_getPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getPosition(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Ripple3D_getPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Ripple3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Ripple3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 6) { double arg0; cocos2d::Size arg1; cocos2d::Point arg2; double arg3; unsigned int arg4; double arg5; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); ok &= luaval_to_uint32(tolua_S, 6,&arg4); ok &= luaval_to_number(tolua_S, 7,&arg5); if(!ok) return 0; cocos2d::Ripple3D* ret = cocos2d::Ripple3D::create(arg0, arg1, arg2, arg3, arg4, arg5); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Ripple3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Ripple3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 6); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Ripple3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Ripple3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Ripple3D)"); return 0; } int lua_register_cocos2dx_Ripple3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Ripple3D"); tolua_cclass(tolua_S,"Ripple3D","cc.Ripple3D","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"Ripple3D"); tolua_function(tolua_S,"setAmplitudeRate",lua_cocos2dx_Ripple3D_setAmplitudeRate); tolua_function(tolua_S,"getAmplitudeRate",lua_cocos2dx_Ripple3D_getAmplitudeRate); tolua_function(tolua_S,"setAmplitude",lua_cocos2dx_Ripple3D_setAmplitude); tolua_function(tolua_S,"getAmplitude",lua_cocos2dx_Ripple3D_getAmplitude); tolua_function(tolua_S,"setPosition",lua_cocos2dx_Ripple3D_setPosition); tolua_function(tolua_S,"getPosition",lua_cocos2dx_Ripple3D_getPosition); tolua_function(tolua_S,"create", lua_cocos2dx_Ripple3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Ripple3D).name(); g_luaType[typeName] = "cc.Ripple3D"; g_typeCast["Ripple3D"] = "cc.Ripple3D"; return 1; } int lua_cocos2dx_Shaky3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Shaky3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Size arg1; int arg2; bool arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_boolean(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::Shaky3D* ret = cocos2d::Shaky3D::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Shaky3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Shaky3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Shaky3D_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Shaky3D_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Shaky3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Shaky3D(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Shaky3D"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Shaky3D"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Shaky3D",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Shaky3D_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Shaky3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Shaky3D)"); return 0; } int lua_register_cocos2dx_Shaky3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Shaky3D"); tolua_cclass(tolua_S,"Shaky3D","cc.Shaky3D","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"Shaky3D"); tolua_function(tolua_S,"create", lua_cocos2dx_Shaky3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Shaky3D).name(); g_luaType[typeName] = "cc.Shaky3D"; g_typeCast["Shaky3D"] = "cc.Shaky3D"; return 1; } int lua_cocos2dx_Liquid_getAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Liquid* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Liquid",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Liquid*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Liquid_getAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitudeRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitudeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Liquid_getAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Liquid_setAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Liquid* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Liquid",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Liquid*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Liquid_setAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitude(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitude",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Liquid_setAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Liquid_getAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Liquid* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Liquid",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Liquid*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Liquid_getAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitude(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitude",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Liquid_getAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Liquid_setAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Liquid* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Liquid",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Liquid*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Liquid_setAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitudeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitudeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Liquid_setAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Liquid_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Liquid",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_uint32(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::Liquid* ret = cocos2d::Liquid::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Liquid"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Liquid*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Liquid_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Liquid_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Liquid* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Liquid(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Liquid"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Liquid"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Liquid",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Liquid_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Liquid_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Liquid)"); return 0; } int lua_register_cocos2dx_Liquid(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Liquid"); tolua_cclass(tolua_S,"Liquid","cc.Liquid","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"Liquid"); tolua_function(tolua_S,"getAmplitudeRate",lua_cocos2dx_Liquid_getAmplitudeRate); tolua_function(tolua_S,"setAmplitude",lua_cocos2dx_Liquid_setAmplitude); tolua_function(tolua_S,"getAmplitude",lua_cocos2dx_Liquid_getAmplitude); tolua_function(tolua_S,"setAmplitudeRate",lua_cocos2dx_Liquid_setAmplitudeRate); tolua_function(tolua_S,"new",lua_cocos2dx_Liquid_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_Liquid_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Liquid).name(); g_luaType[typeName] = "cc.Liquid"; g_typeCast["Liquid"] = "cc.Liquid"; return 1; } int lua_cocos2dx_Waves_getAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Waves* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Waves",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Waves*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Waves_getAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitudeRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitudeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves_getAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves_setAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Waves* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Waves",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Waves*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Waves_setAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitude(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitude",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves_setAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves_getAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Waves* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Waves",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Waves*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Waves_getAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitude(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitude",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves_getAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves_setAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Waves* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Waves",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Waves*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Waves_setAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitudeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitudeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves_setAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Waves",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 6) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; bool arg4; bool arg5; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_uint32(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); ok &= luaval_to_boolean(tolua_S, 6,&arg4); ok &= luaval_to_boolean(tolua_S, 7,&arg5); if(!ok) return 0; cocos2d::Waves* ret = cocos2d::Waves::create(arg0, arg1, arg2, arg3, arg4, arg5); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Waves"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Waves*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 6); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Waves_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Waves* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Waves(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Waves"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Waves"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Waves",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Waves_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Waves_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Waves)"); return 0; } int lua_register_cocos2dx_Waves(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Waves"); tolua_cclass(tolua_S,"Waves","cc.Waves","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"Waves"); tolua_function(tolua_S,"getAmplitudeRate",lua_cocos2dx_Waves_getAmplitudeRate); tolua_function(tolua_S,"setAmplitude",lua_cocos2dx_Waves_setAmplitude); tolua_function(tolua_S,"getAmplitude",lua_cocos2dx_Waves_getAmplitude); tolua_function(tolua_S,"setAmplitudeRate",lua_cocos2dx_Waves_setAmplitudeRate); tolua_function(tolua_S,"new",lua_cocos2dx_Waves_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_Waves_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Waves).name(); g_luaType[typeName] = "cc.Waves"; g_typeCast["Waves"] = "cc.Waves"; return 1; } int lua_cocos2dx_Twirl_setAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Twirl* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Twirl",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Twirl*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Twirl_setAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitudeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitudeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Twirl_setAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Twirl_getAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::Twirl* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Twirl",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Twirl*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Twirl_getAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitudeRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitudeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Twirl_getAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Twirl_setAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Twirl* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Twirl",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Twirl*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Twirl_setAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitude(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitude",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Twirl_setAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Twirl_getAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::Twirl* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Twirl",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Twirl*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Twirl_getAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitude(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitude",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Twirl_getAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Twirl_setPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Twirl* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Twirl",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Twirl*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Twirl_setPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPosition(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPosition",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Twirl_setPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Twirl_getPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Twirl* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Twirl",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Twirl*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Twirl_getPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getPosition(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Twirl_getPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Twirl_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Twirl",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 5) { double arg0; cocos2d::Size arg1; cocos2d::Point arg2; unsigned int arg3; double arg4; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_uint32(tolua_S, 5,&arg3); ok &= luaval_to_number(tolua_S, 6,&arg4); if(!ok) return 0; cocos2d::Twirl* ret = cocos2d::Twirl::create(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Twirl"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Twirl*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Twirl_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Twirl_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Twirl* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Twirl(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Twirl"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Twirl"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Twirl",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Twirl_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Twirl_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Twirl)"); return 0; } int lua_register_cocos2dx_Twirl(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Twirl"); tolua_cclass(tolua_S,"Twirl","cc.Twirl","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"Twirl"); tolua_function(tolua_S,"setAmplitudeRate",lua_cocos2dx_Twirl_setAmplitudeRate); tolua_function(tolua_S,"getAmplitudeRate",lua_cocos2dx_Twirl_getAmplitudeRate); tolua_function(tolua_S,"setAmplitude",lua_cocos2dx_Twirl_setAmplitude); tolua_function(tolua_S,"getAmplitude",lua_cocos2dx_Twirl_getAmplitude); tolua_function(tolua_S,"setPosition",lua_cocos2dx_Twirl_setPosition); tolua_function(tolua_S,"getPosition",lua_cocos2dx_Twirl_getPosition); tolua_function(tolua_S,"new",lua_cocos2dx_Twirl_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_Twirl_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Twirl).name(); g_luaType[typeName] = "cc.Twirl"; g_typeCast["Twirl"] = "cc.Twirl"; return 1; } int lua_cocos2dx_PageTurn3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PageTurn3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PageTurn3D* ret = cocos2d::PageTurn3D::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PageTurn3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PageTurn3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_PageTurn3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_PageTurn3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PageTurn3D)"); return 0; } int lua_register_cocos2dx_PageTurn3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PageTurn3D"); tolua_cclass(tolua_S,"PageTurn3D","cc.PageTurn3D","cc.Grid3DAction",NULL); tolua_beginmodule(tolua_S,"PageTurn3D"); tolua_function(tolua_S,"create", lua_cocos2dx_PageTurn3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PageTurn3D).name(); g_luaType[typeName] = "cc.PageTurn3D"; g_typeCast["PageTurn3D"] = "cc.PageTurn3D"; return 1; } int lua_cocos2dx_ProgressTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ProgressTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; double arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::ProgressTo* ret = cocos2d::ProgressTo::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ProgressTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ProgressTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ProgressTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProgressTo)"); return 0; } int lua_register_cocos2dx_ProgressTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ProgressTo"); tolua_cclass(tolua_S,"ProgressTo","cc.ProgressTo","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"ProgressTo"); tolua_function(tolua_S,"create", lua_cocos2dx_ProgressTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ProgressTo).name(); g_luaType[typeName] = "cc.ProgressTo"; g_typeCast["ProgressTo"] = "cc.ProgressTo"; return 1; } int lua_cocos2dx_ProgressFromTo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ProgressFromTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { double arg0; double arg1; double arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cocos2d::ProgressFromTo* ret = cocos2d::ProgressFromTo::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ProgressFromTo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ProgressFromTo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressFromTo_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ProgressFromTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProgressFromTo)"); return 0; } int lua_register_cocos2dx_ProgressFromTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ProgressFromTo"); tolua_cclass(tolua_S,"ProgressFromTo","cc.ProgressFromTo","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"ProgressFromTo"); tolua_function(tolua_S,"create", lua_cocos2dx_ProgressFromTo_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ProgressFromTo).name(); g_luaType[typeName] = "cc.ProgressFromTo"; g_typeCast["ProgressFromTo"] = "cc.ProgressFromTo"; return 1; } int lua_cocos2dx_ShakyTiles3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ShakyTiles3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Size arg1; int arg2; bool arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_boolean(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::ShakyTiles3D* ret = cocos2d::ShakyTiles3D::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ShakyTiles3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ShakyTiles3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShakyTiles3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ShakyTiles3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ShakyTiles3D)"); return 0; } int lua_register_cocos2dx_ShakyTiles3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ShakyTiles3D"); tolua_cclass(tolua_S,"ShakyTiles3D","cc.ShakyTiles3D","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"ShakyTiles3D"); tolua_function(tolua_S,"create", lua_cocos2dx_ShakyTiles3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ShakyTiles3D).name(); g_luaType[typeName] = "cc.ShakyTiles3D"; g_typeCast["ShakyTiles3D"] = "cc.ShakyTiles3D"; return 1; } int lua_cocos2dx_ShatteredTiles3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ShatteredTiles3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Size arg1; int arg2; bool arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_boolean(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::ShatteredTiles3D* ret = cocos2d::ShatteredTiles3D::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ShatteredTiles3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ShatteredTiles3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShatteredTiles3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ShatteredTiles3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ShatteredTiles3D)"); return 0; } int lua_register_cocos2dx_ShatteredTiles3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ShatteredTiles3D"); tolua_cclass(tolua_S,"ShatteredTiles3D","cc.ShatteredTiles3D","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"ShatteredTiles3D"); tolua_function(tolua_S,"create", lua_cocos2dx_ShatteredTiles3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ShatteredTiles3D).name(); g_luaType[typeName] = "cc.ShatteredTiles3D"; g_typeCast["ShatteredTiles3D"] = "cc.ShatteredTiles3D"; return 1; } int lua_cocos2dx_ShuffleTiles_placeTile(lua_State* tolua_S) { int argc = 0; cocos2d::ShuffleTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ShuffleTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ShuffleTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShuffleTiles_placeTile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Point arg0; cocos2d::Tile* arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); #pragma warning NO CONVERSION TO NATIVE FOR Tile*; if(!ok) return 0; cobj->placeTile(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "placeTile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShuffleTiles_placeTile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShuffleTiles_shuffle(lua_State* tolua_S) { int argc = 0; cocos2d::ShuffleTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ShuffleTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ShuffleTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShuffleTiles_shuffle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { unsigned int* arg0; unsigned int arg1; #pragma warning NO CONVERSION TO NATIVE FOR unsigned int*; ok &= luaval_to_uint32(tolua_S, 3,&arg1); if(!ok) return 0; cobj->shuffle(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "shuffle",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShuffleTiles_shuffle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShuffleTiles_getDelta(lua_State* tolua_S) { int argc = 0; cocos2d::ShuffleTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ShuffleTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ShuffleTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShuffleTiles_getDelta'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Size ret = cobj->getDelta(arg0); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDelta",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShuffleTiles_getDelta'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShuffleTiles_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ShuffleTiles",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { double arg0; cocos2d::Size arg1; unsigned int arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_uint32(tolua_S, 4,&arg2); if(!ok) return 0; cocos2d::ShuffleTiles* ret = cocos2d::ShuffleTiles::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ShuffleTiles"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ShuffleTiles*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShuffleTiles_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ShuffleTiles_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ShuffleTiles)"); return 0; } int lua_register_cocos2dx_ShuffleTiles(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ShuffleTiles"); tolua_cclass(tolua_S,"ShuffleTiles","cc.ShuffleTiles","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"ShuffleTiles"); tolua_function(tolua_S,"placeTile",lua_cocos2dx_ShuffleTiles_placeTile); tolua_function(tolua_S,"shuffle",lua_cocos2dx_ShuffleTiles_shuffle); tolua_function(tolua_S,"getDelta",lua_cocos2dx_ShuffleTiles_getDelta); tolua_function(tolua_S,"create", lua_cocos2dx_ShuffleTiles_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ShuffleTiles).name(); g_luaType[typeName] = "cc.ShuffleTiles"; g_typeCast["ShuffleTiles"] = "cc.ShuffleTiles"; return 1; } int lua_cocos2dx_FadeOutTRTiles_turnOnTile(lua_State* tolua_S) { int argc = 0; cocos2d::FadeOutTRTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FadeOutTRTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FadeOutTRTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FadeOutTRTiles_turnOnTile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->turnOnTile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "turnOnTile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutTRTiles_turnOnTile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FadeOutTRTiles_turnOffTile(lua_State* tolua_S) { int argc = 0; cocos2d::FadeOutTRTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FadeOutTRTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FadeOutTRTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FadeOutTRTiles_turnOffTile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->turnOffTile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "turnOffTile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutTRTiles_turnOffTile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FadeOutTRTiles_transformTile(lua_State* tolua_S) { int argc = 0; cocos2d::FadeOutTRTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FadeOutTRTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FadeOutTRTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FadeOutTRTiles_transformTile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Point arg0; double arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->transformTile(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "transformTile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutTRTiles_transformTile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FadeOutTRTiles_testFunc(lua_State* tolua_S) { int argc = 0; cocos2d::FadeOutTRTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FadeOutTRTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FadeOutTRTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FadeOutTRTiles_testFunc'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Size arg0; double arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; double ret = cobj->testFunc(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "testFunc",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutTRTiles_testFunc'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FadeOutTRTiles_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FadeOutTRTiles",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::FadeOutTRTiles* ret = cocos2d::FadeOutTRTiles::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FadeOutTRTiles"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FadeOutTRTiles*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutTRTiles_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FadeOutTRTiles_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FadeOutTRTiles)"); return 0; } int lua_register_cocos2dx_FadeOutTRTiles(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FadeOutTRTiles"); tolua_cclass(tolua_S,"FadeOutTRTiles","cc.FadeOutTRTiles","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"FadeOutTRTiles"); tolua_function(tolua_S,"turnOnTile",lua_cocos2dx_FadeOutTRTiles_turnOnTile); tolua_function(tolua_S,"turnOffTile",lua_cocos2dx_FadeOutTRTiles_turnOffTile); tolua_function(tolua_S,"transformTile",lua_cocos2dx_FadeOutTRTiles_transformTile); tolua_function(tolua_S,"testFunc",lua_cocos2dx_FadeOutTRTiles_testFunc); tolua_function(tolua_S,"create", lua_cocos2dx_FadeOutTRTiles_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FadeOutTRTiles).name(); g_luaType[typeName] = "cc.FadeOutTRTiles"; g_typeCast["FadeOutTRTiles"] = "cc.FadeOutTRTiles"; return 1; } int lua_cocos2dx_FadeOutBLTiles_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FadeOutBLTiles",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::FadeOutBLTiles* ret = cocos2d::FadeOutBLTiles::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FadeOutBLTiles"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FadeOutBLTiles*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutBLTiles_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FadeOutBLTiles_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FadeOutBLTiles)"); return 0; } int lua_register_cocos2dx_FadeOutBLTiles(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FadeOutBLTiles"); tolua_cclass(tolua_S,"FadeOutBLTiles","cc.FadeOutBLTiles","cc.FadeOutTRTiles",NULL); tolua_beginmodule(tolua_S,"FadeOutBLTiles"); tolua_function(tolua_S,"create", lua_cocos2dx_FadeOutBLTiles_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FadeOutBLTiles).name(); g_luaType[typeName] = "cc.FadeOutBLTiles"; g_typeCast["FadeOutBLTiles"] = "cc.FadeOutBLTiles"; return 1; } int lua_cocos2dx_FadeOutUpTiles_transformTile(lua_State* tolua_S) { int argc = 0; cocos2d::FadeOutUpTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FadeOutUpTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FadeOutUpTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FadeOutUpTiles_transformTile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Point arg0; double arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->transformTile(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "transformTile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutUpTiles_transformTile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FadeOutUpTiles_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FadeOutUpTiles",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::FadeOutUpTiles* ret = cocos2d::FadeOutUpTiles::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FadeOutUpTiles"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FadeOutUpTiles*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutUpTiles_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FadeOutUpTiles_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FadeOutUpTiles)"); return 0; } int lua_register_cocos2dx_FadeOutUpTiles(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FadeOutUpTiles"); tolua_cclass(tolua_S,"FadeOutUpTiles","cc.FadeOutUpTiles","cc.FadeOutTRTiles",NULL); tolua_beginmodule(tolua_S,"FadeOutUpTiles"); tolua_function(tolua_S,"transformTile",lua_cocos2dx_FadeOutUpTiles_transformTile); tolua_function(tolua_S,"create", lua_cocos2dx_FadeOutUpTiles_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FadeOutUpTiles).name(); g_luaType[typeName] = "cc.FadeOutUpTiles"; g_typeCast["FadeOutUpTiles"] = "cc.FadeOutUpTiles"; return 1; } int lua_cocos2dx_FadeOutDownTiles_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FadeOutDownTiles",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::FadeOutDownTiles* ret = cocos2d::FadeOutDownTiles::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FadeOutDownTiles"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FadeOutDownTiles*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FadeOutDownTiles_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FadeOutDownTiles_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FadeOutDownTiles)"); return 0; } int lua_register_cocos2dx_FadeOutDownTiles(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FadeOutDownTiles"); tolua_cclass(tolua_S,"FadeOutDownTiles","cc.FadeOutDownTiles","cc.FadeOutUpTiles",NULL); tolua_beginmodule(tolua_S,"FadeOutDownTiles"); tolua_function(tolua_S,"create", lua_cocos2dx_FadeOutDownTiles_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FadeOutDownTiles).name(); g_luaType[typeName] = "cc.FadeOutDownTiles"; g_typeCast["FadeOutDownTiles"] = "cc.FadeOutDownTiles"; return 1; } int lua_cocos2dx_TurnOffTiles_turnOnTile(lua_State* tolua_S) { int argc = 0; cocos2d::TurnOffTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TurnOffTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TurnOffTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TurnOffTiles_turnOnTile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->turnOnTile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "turnOnTile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TurnOffTiles_turnOnTile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TurnOffTiles_turnOffTile(lua_State* tolua_S) { int argc = 0; cocos2d::TurnOffTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TurnOffTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TurnOffTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TurnOffTiles_turnOffTile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->turnOffTile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "turnOffTile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TurnOffTiles_turnOffTile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TurnOffTiles_shuffle(lua_State* tolua_S) { int argc = 0; cocos2d::TurnOffTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TurnOffTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TurnOffTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TurnOffTiles_shuffle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { unsigned int* arg0; unsigned int arg1; #pragma warning NO CONVERSION TO NATIVE FOR unsigned int*; ok &= luaval_to_uint32(tolua_S, 3,&arg1); if(!ok) return 0; cobj->shuffle(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "shuffle",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TurnOffTiles_shuffle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TurnOffTiles_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TurnOffTiles",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Size arg1; ok &= luaval_to_size(tolua_S, 3, &arg1); if (!ok) { break; } unsigned int arg2; ok &= luaval_to_uint32(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::TurnOffTiles* ret = cocos2d::TurnOffTiles::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TurnOffTiles"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TurnOffTiles*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Size arg1; ok &= luaval_to_size(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::TurnOffTiles* ret = cocos2d::TurnOffTiles::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TurnOffTiles"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TurnOffTiles*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TurnOffTiles_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TurnOffTiles_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TurnOffTiles)"); return 0; } int lua_register_cocos2dx_TurnOffTiles(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TurnOffTiles"); tolua_cclass(tolua_S,"TurnOffTiles","cc.TurnOffTiles","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"TurnOffTiles"); tolua_function(tolua_S,"turnOnTile",lua_cocos2dx_TurnOffTiles_turnOnTile); tolua_function(tolua_S,"turnOffTile",lua_cocos2dx_TurnOffTiles_turnOffTile); tolua_function(tolua_S,"shuffle",lua_cocos2dx_TurnOffTiles_shuffle); tolua_function(tolua_S,"create", lua_cocos2dx_TurnOffTiles_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TurnOffTiles).name(); g_luaType[typeName] = "cc.TurnOffTiles"; g_typeCast["TurnOffTiles"] = "cc.TurnOffTiles"; return 1; } int lua_cocos2dx_WavesTiles3D_getAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::WavesTiles3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.WavesTiles3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::WavesTiles3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_WavesTiles3D_getAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitudeRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitudeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_WavesTiles3D_getAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_WavesTiles3D_setAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::WavesTiles3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.WavesTiles3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::WavesTiles3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_WavesTiles3D_setAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitude(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitude",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_WavesTiles3D_setAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_WavesTiles3D_setAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::WavesTiles3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.WavesTiles3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::WavesTiles3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_WavesTiles3D_setAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitudeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitudeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_WavesTiles3D_setAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_WavesTiles3D_getAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::WavesTiles3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.WavesTiles3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::WavesTiles3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_WavesTiles3D_getAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitude(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitude",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_WavesTiles3D_getAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_WavesTiles3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.WavesTiles3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_uint32(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::WavesTiles3D* ret = cocos2d::WavesTiles3D::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.WavesTiles3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::WavesTiles3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_WavesTiles3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_WavesTiles3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (WavesTiles3D)"); return 0; } int lua_register_cocos2dx_WavesTiles3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.WavesTiles3D"); tolua_cclass(tolua_S,"WavesTiles3D","cc.WavesTiles3D","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"WavesTiles3D"); tolua_function(tolua_S,"getAmplitudeRate",lua_cocos2dx_WavesTiles3D_getAmplitudeRate); tolua_function(tolua_S,"setAmplitude",lua_cocos2dx_WavesTiles3D_setAmplitude); tolua_function(tolua_S,"setAmplitudeRate",lua_cocos2dx_WavesTiles3D_setAmplitudeRate); tolua_function(tolua_S,"getAmplitude",lua_cocos2dx_WavesTiles3D_getAmplitude); tolua_function(tolua_S,"create", lua_cocos2dx_WavesTiles3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::WavesTiles3D).name(); g_luaType[typeName] = "cc.WavesTiles3D"; g_typeCast["WavesTiles3D"] = "cc.WavesTiles3D"; return 1; } int lua_cocos2dx_JumpTiles3D_getAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::JumpTiles3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.JumpTiles3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::JumpTiles3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_JumpTiles3D_getAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitudeRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitudeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_JumpTiles3D_getAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_JumpTiles3D_setAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::JumpTiles3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.JumpTiles3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::JumpTiles3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_JumpTiles3D_setAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitude(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitude",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_JumpTiles3D_setAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_JumpTiles3D_setAmplitudeRate(lua_State* tolua_S) { int argc = 0; cocos2d::JumpTiles3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.JumpTiles3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::JumpTiles3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_JumpTiles3D_setAmplitudeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAmplitudeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAmplitudeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_JumpTiles3D_setAmplitudeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_JumpTiles3D_getAmplitude(lua_State* tolua_S) { int argc = 0; cocos2d::JumpTiles3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.JumpTiles3D",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::JumpTiles3D*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_JumpTiles3D_getAmplitude'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAmplitude(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAmplitude",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_JumpTiles3D_getAmplitude'.",&tolua_err); #endif return 0; } int lua_cocos2dx_JumpTiles3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.JumpTiles3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; cocos2d::Size arg1; unsigned int arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_uint32(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::JumpTiles3D* ret = cocos2d::JumpTiles3D::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.JumpTiles3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::JumpTiles3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_JumpTiles3D_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_JumpTiles3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (JumpTiles3D)"); return 0; } int lua_register_cocos2dx_JumpTiles3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.JumpTiles3D"); tolua_cclass(tolua_S,"JumpTiles3D","cc.JumpTiles3D","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"JumpTiles3D"); tolua_function(tolua_S,"getAmplitudeRate",lua_cocos2dx_JumpTiles3D_getAmplitudeRate); tolua_function(tolua_S,"setAmplitude",lua_cocos2dx_JumpTiles3D_setAmplitude); tolua_function(tolua_S,"setAmplitudeRate",lua_cocos2dx_JumpTiles3D_setAmplitudeRate); tolua_function(tolua_S,"getAmplitude",lua_cocos2dx_JumpTiles3D_getAmplitude); tolua_function(tolua_S,"create", lua_cocos2dx_JumpTiles3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::JumpTiles3D).name(); g_luaType[typeName] = "cc.JumpTiles3D"; g_typeCast["JumpTiles3D"] = "cc.JumpTiles3D"; return 1; } int lua_cocos2dx_SplitRows_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SplitRows",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; unsigned int arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_uint32(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::SplitRows* ret = cocos2d::SplitRows::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SplitRows"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SplitRows*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SplitRows_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_SplitRows_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SplitRows)"); return 0; } int lua_register_cocos2dx_SplitRows(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.SplitRows"); tolua_cclass(tolua_S,"SplitRows","cc.SplitRows","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"SplitRows"); tolua_function(tolua_S,"create", lua_cocos2dx_SplitRows_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::SplitRows).name(); g_luaType[typeName] = "cc.SplitRows"; g_typeCast["SplitRows"] = "cc.SplitRows"; return 1; } int lua_cocos2dx_SplitCols_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SplitCols",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; unsigned int arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_uint32(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::SplitCols* ret = cocos2d::SplitCols::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SplitCols"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SplitCols*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SplitCols_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_SplitCols_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SplitCols)"); return 0; } int lua_register_cocos2dx_SplitCols(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.SplitCols"); tolua_cclass(tolua_S,"SplitCols","cc.SplitCols","cc.TiledGrid3DAction",NULL); tolua_beginmodule(tolua_S,"SplitCols"); tolua_function(tolua_S,"create", lua_cocos2dx_SplitCols_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::SplitCols).name(); g_luaType[typeName] = "cc.SplitCols"; g_typeCast["SplitCols"] = "cc.SplitCols"; return 1; } int lua_cocos2dx_ActionTween_initWithDuration(lua_State* tolua_S) { int argc = 0; cocos2d::ActionTween* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionTween",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionTween*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ActionTween_initWithDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { double arg0; std::string arg1; double arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithDuration",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionTween_initWithDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ActionTween_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ActionTween",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { double arg0; std::string arg1; double arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::ActionTween* ret = cocos2d::ActionTween::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionTween"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionTween*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ActionTween_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ActionTween_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ActionTween)"); return 0; } int lua_register_cocos2dx_ActionTween(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ActionTween"); tolua_cclass(tolua_S,"ActionTween","cc.ActionTween","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"ActionTween"); tolua_function(tolua_S,"initWithDuration",lua_cocos2dx_ActionTween_initWithDuration); tolua_function(tolua_S,"create", lua_cocos2dx_ActionTween_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ActionTween).name(); g_luaType[typeName] = "cc.ActionTween"; g_typeCast["ActionTween"] = "cc.ActionTween"; return 1; } int lua_cocos2dx_CardinalSplineTo_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::CardinalSplineTo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CardinalSplineTo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::CardinalSplineTo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CardinalSplineTo_getPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PointArray* ret = cobj->getPoints(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PointArray"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PointArray*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CardinalSplineTo_getPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_CardinalSplineTo_updatePosition(lua_State* tolua_S) { int argc = 0; cocos2d::CardinalSplineTo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CardinalSplineTo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::CardinalSplineTo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CardinalSplineTo_updatePosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->updatePosition(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updatePosition",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CardinalSplineTo_updatePosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_CardinalSplineTo_initWithDuration(lua_State* tolua_S) { int argc = 0; cocos2d::CardinalSplineTo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CardinalSplineTo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::CardinalSplineTo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CardinalSplineTo_initWithDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { double arg0; cocos2d::PointArray* arg1; double arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PointArray",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PointArray*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; bool ret = cobj->initWithDuration(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithDuration",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CardinalSplineTo_initWithDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_CardinalSplineTo_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::CardinalSplineTo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::CardinalSplineTo(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CardinalSplineTo"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CardinalSplineTo"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "CardinalSplineTo",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CardinalSplineTo_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_CardinalSplineTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (CardinalSplineTo)"); return 0; } int lua_register_cocos2dx_CardinalSplineTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.CardinalSplineTo"); tolua_cclass(tolua_S,"CardinalSplineTo","cc.CardinalSplineTo","cc.ActionInterval",NULL); tolua_beginmodule(tolua_S,"CardinalSplineTo"); tolua_function(tolua_S,"getPoints",lua_cocos2dx_CardinalSplineTo_getPoints); tolua_function(tolua_S,"updatePosition",lua_cocos2dx_CardinalSplineTo_updatePosition); tolua_function(tolua_S,"initWithDuration",lua_cocos2dx_CardinalSplineTo_initWithDuration); tolua_function(tolua_S,"new",lua_cocos2dx_CardinalSplineTo_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::CardinalSplineTo).name(); g_luaType[typeName] = "cc.CardinalSplineTo"; g_typeCast["CardinalSplineTo"] = "cc.CardinalSplineTo"; return 1; } int lua_cocos2dx_CardinalSplineBy_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::CardinalSplineBy* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::CardinalSplineBy(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CardinalSplineBy"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CardinalSplineBy"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "CardinalSplineBy",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CardinalSplineBy_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_CardinalSplineBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (CardinalSplineBy)"); return 0; } int lua_register_cocos2dx_CardinalSplineBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.CardinalSplineBy"); tolua_cclass(tolua_S,"CardinalSplineBy","cc.CardinalSplineBy","cc.CardinalSplineTo",NULL); tolua_beginmodule(tolua_S,"CardinalSplineBy"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::CardinalSplineBy).name(); g_luaType[typeName] = "cc.CardinalSplineBy"; g_typeCast["CardinalSplineBy"] = "cc.CardinalSplineBy"; return 1; } int lua_cocos2dx_CatmullRomTo_initWithDuration(lua_State* tolua_S) { int argc = 0; cocos2d::CatmullRomTo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CatmullRomTo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::CatmullRomTo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CatmullRomTo_initWithDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; cocos2d::PointArray* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PointArray",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PointArray*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->initWithDuration(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithDuration",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CatmullRomTo_initWithDuration'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_CatmullRomTo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (CatmullRomTo)"); return 0; } int lua_register_cocos2dx_CatmullRomTo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.CatmullRomTo"); tolua_cclass(tolua_S,"CatmullRomTo","cc.CatmullRomTo","cc.CardinalSplineTo",NULL); tolua_beginmodule(tolua_S,"CatmullRomTo"); tolua_function(tolua_S,"initWithDuration",lua_cocos2dx_CatmullRomTo_initWithDuration); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::CatmullRomTo).name(); g_luaType[typeName] = "cc.CatmullRomTo"; g_typeCast["CatmullRomTo"] = "cc.CatmullRomTo"; return 1; } int lua_cocos2dx_CatmullRomBy_initWithDuration(lua_State* tolua_S) { int argc = 0; cocos2d::CatmullRomBy* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CatmullRomBy",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::CatmullRomBy*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_CatmullRomBy_initWithDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; cocos2d::PointArray* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PointArray",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PointArray*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->initWithDuration(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithDuration",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CatmullRomBy_initWithDuration'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_CatmullRomBy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (CatmullRomBy)"); return 0; } int lua_register_cocos2dx_CatmullRomBy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.CatmullRomBy"); tolua_cclass(tolua_S,"CatmullRomBy","cc.CatmullRomBy","cc.CardinalSplineBy",NULL); tolua_beginmodule(tolua_S,"CatmullRomBy"); tolua_function(tolua_S,"initWithDuration",lua_cocos2dx_CatmullRomBy_initWithDuration); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::CatmullRomBy).name(); g_luaType[typeName] = "cc.CatmullRomBy"; g_typeCast["CatmullRomBy"] = "cc.CatmullRomBy"; return 1; } int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AtlasNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AtlasNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateAtlasValues(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateAtlasValues",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AtlasNode_getTexture(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AtlasNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AtlasNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_getTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Texture2D* ret = cobj->getTexture(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTexture",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_getTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AtlasNode_setTextureAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AtlasNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AtlasNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_setTextureAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextureAtlas* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.TextureAtlas",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::TextureAtlas*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTextureAtlas(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextureAtlas",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_setTextureAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AtlasNode_getTextureAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AtlasNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AtlasNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_getTextureAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TextureAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TextureAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureAtlas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_getTextureAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AtlasNode_getQuadsToDraw(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AtlasNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AtlasNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_getQuadsToDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getQuadsToDraw(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getQuadsToDraw",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_getQuadsToDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AtlasNode_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AtlasNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AtlasNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_setTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTexture(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_setTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AtlasNode_setQuadsToDraw(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AtlasNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AtlasNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_setQuadsToDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setQuadsToDraw(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setQuadsToDraw",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_setQuadsToDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AtlasNode_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.AtlasNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { std::string arg0; int arg1; int arg2; int arg3; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cocos2d::AtlasNode* ret = cocos2d::AtlasNode::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.AtlasNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::AtlasNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_AtlasNode_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (AtlasNode)"); return 0; } int lua_register_cocos2dx_AtlasNode(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.AtlasNode"); tolua_cclass(tolua_S,"AtlasNode","cc.AtlasNode","cc.Node",NULL); tolua_beginmodule(tolua_S,"AtlasNode"); tolua_function(tolua_S,"updateAtlasValues",lua_cocos2dx_AtlasNode_updateAtlasValues); tolua_function(tolua_S,"getTexture",lua_cocos2dx_AtlasNode_getTexture); tolua_function(tolua_S,"setTextureAtlas",lua_cocos2dx_AtlasNode_setTextureAtlas); tolua_function(tolua_S,"getTextureAtlas",lua_cocos2dx_AtlasNode_getTextureAtlas); tolua_function(tolua_S,"getQuadsToDraw",lua_cocos2dx_AtlasNode_getQuadsToDraw); tolua_function(tolua_S,"setTexture",lua_cocos2dx_AtlasNode_setTexture); tolua_function(tolua_S,"setQuadsToDraw",lua_cocos2dx_AtlasNode_setQuadsToDraw); tolua_function(tolua_S,"create", lua_cocos2dx_AtlasNode_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::AtlasNode).name(); g_luaType[typeName] = "cc.AtlasNode"; g_typeCast["AtlasNode"] = "cc.AtlasNode"; return 1; } int lua_cocos2dx_DrawNode_drawQuadraticBezier(lua_State* tolua_S) { int argc = 0; cocos2d::DrawNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DrawNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode_drawQuadraticBezier'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 5) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::Point arg2; unsigned int arg3; cocos2d::Color4F arg4; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_uint32(tolua_S, 5,&arg3); ok &=luaval_to_color4f(tolua_S, 6, &arg4); if(!ok) return 0; cobj->drawQuadraticBezier(arg0, arg1, arg2, arg3, arg4); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawQuadraticBezier",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DrawNode_drawQuadraticBezier'.",&tolua_err); #endif return 0; } int lua_cocos2dx_DrawNode_onDraw(lua_State* tolua_S) { int argc = 0; cocos2d::DrawNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DrawNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode_onDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->onDraw(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onDraw",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DrawNode_onDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_DrawNode_clear(lua_State* tolua_S) { int argc = 0; cocos2d::DrawNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DrawNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode_clear'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->clear(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clear",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DrawNode_clear'.",&tolua_err); #endif return 0; } int lua_cocos2dx_DrawNode_drawTriangle(lua_State* tolua_S) { int argc = 0; cocos2d::DrawNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DrawNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode_drawTriangle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::Point arg2; cocos2d::Color4F arg3; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &=luaval_to_color4f(tolua_S, 5, &arg3); if(!ok) return 0; cobj->drawTriangle(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawTriangle",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DrawNode_drawTriangle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_DrawNode_drawDot(lua_State* tolua_S) { int argc = 0; cocos2d::DrawNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DrawNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode_drawDot'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::Point arg0; double arg1; cocos2d::Color4F arg2; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &=luaval_to_color4f(tolua_S, 4, &arg2); if(!ok) return 0; cobj->drawDot(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawDot",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DrawNode_drawDot'.",&tolua_err); #endif return 0; } int lua_cocos2dx_DrawNode_drawCubicBezier(lua_State* tolua_S) { int argc = 0; cocos2d::DrawNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DrawNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode_drawCubicBezier'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 6) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::Point arg2; cocos2d::Point arg3; unsigned int arg4; cocos2d::Color4F arg5; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); ok &= luaval_to_uint32(tolua_S, 6,&arg4); ok &=luaval_to_color4f(tolua_S, 7, &arg5); if(!ok) return 0; cobj->drawCubicBezier(arg0, arg1, arg2, arg3, arg4, arg5); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawCubicBezier",argc, 6); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DrawNode_drawCubicBezier'.",&tolua_err); #endif return 0; } int lua_cocos2dx_DrawNode_drawSegment(lua_State* tolua_S) { int argc = 0; cocos2d::DrawNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DrawNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode_drawSegment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { cocos2d::Point arg0; cocos2d::Point arg1; double arg2; cocos2d::Color4F arg3; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &=luaval_to_color4f(tolua_S, 5, &arg3); if(!ok) return 0; cobj->drawSegment(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawSegment",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DrawNode_drawSegment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_DrawNode_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::DrawNode* ret = cocos2d::DrawNode::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.DrawNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::DrawNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_DrawNode_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_DrawNode_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (DrawNode)"); return 0; } int lua_register_cocos2dx_DrawNode(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.DrawNode"); tolua_cclass(tolua_S,"DrawNode","cc.DrawNode","cc.Node",NULL); tolua_beginmodule(tolua_S,"DrawNode"); tolua_function(tolua_S,"drawQuadraticBezier",lua_cocos2dx_DrawNode_drawQuadraticBezier); tolua_function(tolua_S,"onDraw",lua_cocos2dx_DrawNode_onDraw); tolua_function(tolua_S,"clear",lua_cocos2dx_DrawNode_clear); tolua_function(tolua_S,"drawTriangle",lua_cocos2dx_DrawNode_drawTriangle); tolua_function(tolua_S,"drawDot",lua_cocos2dx_DrawNode_drawDot); tolua_function(tolua_S,"drawCubicBezier",lua_cocos2dx_DrawNode_drawCubicBezier); tolua_function(tolua_S,"drawSegment",lua_cocos2dx_DrawNode_drawSegment); tolua_function(tolua_S,"create", lua_cocos2dx_DrawNode_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::DrawNode).name(); g_luaType[typeName] = "cc.DrawNode"; g_typeCast["DrawNode"] = "cc.DrawNode"; return 1; } int lua_cocos2dx_LabelAtlas_setString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelAtlas_setString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setString(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelAtlas_setString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelAtlas_initWithString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelAtlas* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelAtlas_initWithString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 5) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } int arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } int arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 5) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Texture2D* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } int arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } int arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithString",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelAtlas_initWithString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelAtlas_updateAtlasValues(lua_State* tolua_S) { int argc = 0; cocos2d::LabelAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelAtlas_updateAtlasValues'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateAtlasValues(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateAtlasValues",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelAtlas_updateAtlasValues'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelAtlas_getString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelAtlas_getString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getString(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getString",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelAtlas_getString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelAtlas_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.LabelAtlas",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 5) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } int arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } int arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelAtlas_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_LabelAtlas_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LabelAtlas)"); return 0; } int lua_register_cocos2dx_LabelAtlas(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.LabelAtlas"); tolua_cclass(tolua_S,"LabelAtlas","cc.LabelAtlas","cc.AtlasNode",NULL); tolua_beginmodule(tolua_S,"LabelAtlas"); tolua_function(tolua_S,"setString",lua_cocos2dx_LabelAtlas_setString); tolua_function(tolua_S,"initWithString",lua_cocos2dx_LabelAtlas_initWithString); tolua_function(tolua_S,"updateAtlasValues",lua_cocos2dx_LabelAtlas_updateAtlasValues); tolua_function(tolua_S,"getString",lua_cocos2dx_LabelAtlas_getString); tolua_function(tolua_S,"_create", lua_cocos2dx_LabelAtlas_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::LabelAtlas).name(); g_luaType[typeName] = "cc.LabelAtlas"; g_typeCast["LabelAtlas"] = "cc.LabelAtlas"; return 1; } int lua_cocos2dx_Director_pause(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_pause'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pause(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pause",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_pause'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setContentScaleFactor(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setContentScaleFactor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setContentScaleFactor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setContentScaleFactor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setContentScaleFactor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getContentScaleFactor(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getContentScaleFactor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getContentScaleFactor(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContentScaleFactor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getContentScaleFactor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getWinSizeInPixels(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getWinSizeInPixels'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getWinSizeInPixels(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWinSizeInPixels",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getWinSizeInPixels'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getDeltaTime(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getDeltaTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDeltaTime(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDeltaTime",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getDeltaTime'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setGLDefaultValues(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setGLDefaultValues'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setGLDefaultValues(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGLDefaultValues",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setGLDefaultValues'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setActionManager(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setActionManager'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionManager* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionManager",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionManager*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setActionManager(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setActionManager",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setActionManager'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setAlphaBlending(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setAlphaBlending'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAlphaBlending(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAlphaBlending",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setAlphaBlending'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_popToRootScene(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_popToRootScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->popToRootScene(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "popToRootScene",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_popToRootScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getNotificationNode(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getNotificationNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getNotificationNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNotificationNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getNotificationNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getWinSize(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getWinSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getWinSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWinSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getWinSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getTextureCache(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getTextureCache'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::TextureCache* ret = cobj->getTextureCache(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TextureCache"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TextureCache*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureCache",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getTextureCache'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_isSendCleanupToScene(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_isSendCleanupToScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isSendCleanupToScene(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isSendCleanupToScene",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_isSendCleanupToScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getVisibleOrigin(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getVisibleOrigin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getVisibleOrigin(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVisibleOrigin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getVisibleOrigin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_mainLoop(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_mainLoop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->mainLoop(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "mainLoop",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_mainLoop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setDepthTest(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setDepthTest'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDepthTest(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDepthTest",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setDepthTest'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getFrameRate(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getFrameRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getFrameRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFrameRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getFrameRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getSecondsPerFrame(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getSecondsPerFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSecondsPerFrame(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSecondsPerFrame",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getSecondsPerFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_convertToUI(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_convertToUI'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->convertToUI(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "convertToUI",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_convertToUI'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setDefaultValues(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setDefaultValues'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setDefaultValues(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDefaultValues",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setDefaultValues'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_init(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setScheduler(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setScheduler'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Scheduler* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Scheduler",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Scheduler*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setScheduler(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScheduler",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setScheduler'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_startAnimation(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_startAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->startAnimation(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "startAnimation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_startAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getRunningScene(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getRunningScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Scene* ret = cobj->getRunningScene(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scene"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Scene*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRunningScene",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getRunningScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setViewport(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setViewport'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setViewport(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setViewport",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setViewport'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_stopAnimation(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_stopAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stopAnimation(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopAnimation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_stopAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_popToSceneStackLevel(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_popToSceneStackLevel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->popToSceneStackLevel(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "popToSceneStackLevel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_popToSceneStackLevel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_resume(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_resume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resume(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resume",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_resume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_isNextDeltaTimeZero(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_isNextDeltaTimeZero'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isNextDeltaTimeZero(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isNextDeltaTimeZero",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_isNextDeltaTimeZero'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_end(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_end'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->end(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "end",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_end'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setOpenGLView(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setOpenGLView'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::EGLView* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.EGLView",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::EGLView*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setOpenGLView(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOpenGLView",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setOpenGLView'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_convertToGL(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_convertToGL'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->convertToGL(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "convertToGL",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_convertToGL'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_purgeCachedData(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_purgeCachedData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->purgeCachedData(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "purgeCachedData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_purgeCachedData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getTotalFrames(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getTotalFrames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned int ret = cobj->getTotalFrames(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTotalFrames",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getTotalFrames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_runWithScene(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_runWithScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Scene* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Scene",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Scene*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->runWithScene(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "runWithScene",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_runWithScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setNotificationNode(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setNotificationNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setNotificationNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setNotificationNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setNotificationNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_drawScene(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_drawScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->drawScene(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawScene",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_drawScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_popScene(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_popScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->popScene(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "popScene",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_popScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_isDisplayStats(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_isDisplayStats'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isDisplayStats(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isDisplayStats",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_isDisplayStats'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setProjection(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setProjection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Director::Projection arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setProjection(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProjection",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setProjection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getConsole(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getConsole'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Console* ret = cobj->getConsole(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Console"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Console*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getConsole",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getConsole'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getZEye(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getZEye'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getZEye(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getZEye",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getZEye'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setNextDeltaTimeZero(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setNextDeltaTimeZero'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setNextDeltaTimeZero(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setNextDeltaTimeZero",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setNextDeltaTimeZero'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getVisibleSize(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getVisibleSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getVisibleSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVisibleSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getVisibleSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getScheduler(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getScheduler'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Scheduler* ret = cobj->getScheduler(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scheduler"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Scheduler*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScheduler",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getScheduler'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_pushScene(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_pushScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Scene* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Scene",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Scene*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->pushScene(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pushScene",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_pushScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getAnimationInterval(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getAnimationInterval'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAnimationInterval(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimationInterval",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getAnimationInterval'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_isPaused(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_isPaused'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isPaused(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isPaused",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_isPaused'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setDisplayStats(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setDisplayStats'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDisplayStats(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDisplayStats",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setDisplayStats'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_replaceScene(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_replaceScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Scene* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Scene",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Scene*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->replaceScene(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "replaceScene",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_replaceScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_setAnimationInterval(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_setAnimationInterval'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAnimationInterval(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimationInterval",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_setAnimationInterval'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getActionManager(lua_State* tolua_S) { int argc = 0; cocos2d::Director* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Director*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Director_getActionManager'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionManager* ret = cobj->getActionManager(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionManager"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionManager*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getActionManager",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getActionManager'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Director_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Director",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Director* ret = cocos2d::Director::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Director"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Director*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Director_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Director_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Director)"); return 0; } int lua_register_cocos2dx_Director(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Director"); tolua_cclass(tolua_S,"Director","cc.Director","",NULL); tolua_beginmodule(tolua_S,"Director"); tolua_function(tolua_S,"pause",lua_cocos2dx_Director_pause); tolua_function(tolua_S,"setContentScaleFactor",lua_cocos2dx_Director_setContentScaleFactor); tolua_function(tolua_S,"getContentScaleFactor",lua_cocos2dx_Director_getContentScaleFactor); tolua_function(tolua_S,"getWinSizeInPixels",lua_cocos2dx_Director_getWinSizeInPixels); tolua_function(tolua_S,"getDeltaTime",lua_cocos2dx_Director_getDeltaTime); tolua_function(tolua_S,"setGLDefaultValues",lua_cocos2dx_Director_setGLDefaultValues); tolua_function(tolua_S,"setActionManager",lua_cocos2dx_Director_setActionManager); tolua_function(tolua_S,"setAlphaBlending",lua_cocos2dx_Director_setAlphaBlending); tolua_function(tolua_S,"popToRootScene",lua_cocos2dx_Director_popToRootScene); tolua_function(tolua_S,"getNotificationNode",lua_cocos2dx_Director_getNotificationNode); tolua_function(tolua_S,"getWinSize",lua_cocos2dx_Director_getWinSize); tolua_function(tolua_S,"getTextureCache",lua_cocos2dx_Director_getTextureCache); tolua_function(tolua_S,"isSendCleanupToScene",lua_cocos2dx_Director_isSendCleanupToScene); tolua_function(tolua_S,"getVisibleOrigin",lua_cocos2dx_Director_getVisibleOrigin); tolua_function(tolua_S,"mainLoop",lua_cocos2dx_Director_mainLoop); tolua_function(tolua_S,"setDepthTest",lua_cocos2dx_Director_setDepthTest); tolua_function(tolua_S,"getFrameRate",lua_cocos2dx_Director_getFrameRate); tolua_function(tolua_S,"getSecondsPerFrame",lua_cocos2dx_Director_getSecondsPerFrame); tolua_function(tolua_S,"convertToUI",lua_cocos2dx_Director_convertToUI); tolua_function(tolua_S,"setDefaultValues",lua_cocos2dx_Director_setDefaultValues); tolua_function(tolua_S,"init",lua_cocos2dx_Director_init); tolua_function(tolua_S,"setScheduler",lua_cocos2dx_Director_setScheduler); tolua_function(tolua_S,"startAnimation",lua_cocos2dx_Director_startAnimation); tolua_function(tolua_S,"getRunningScene",lua_cocos2dx_Director_getRunningScene); tolua_function(tolua_S,"setViewport",lua_cocos2dx_Director_setViewport); tolua_function(tolua_S,"stopAnimation",lua_cocos2dx_Director_stopAnimation); tolua_function(tolua_S,"popToSceneStackLevel",lua_cocos2dx_Director_popToSceneStackLevel); tolua_function(tolua_S,"resume",lua_cocos2dx_Director_resume); tolua_function(tolua_S,"isNextDeltaTimeZero",lua_cocos2dx_Director_isNextDeltaTimeZero); tolua_function(tolua_S,"endToLua",lua_cocos2dx_Director_end); tolua_function(tolua_S,"setOpenGLView",lua_cocos2dx_Director_setOpenGLView); tolua_function(tolua_S,"convertToGL",lua_cocos2dx_Director_convertToGL); tolua_function(tolua_S,"purgeCachedData",lua_cocos2dx_Director_purgeCachedData); tolua_function(tolua_S,"getTotalFrames",lua_cocos2dx_Director_getTotalFrames); tolua_function(tolua_S,"runWithScene",lua_cocos2dx_Director_runWithScene); tolua_function(tolua_S,"setNotificationNode",lua_cocos2dx_Director_setNotificationNode); tolua_function(tolua_S,"drawScene",lua_cocos2dx_Director_drawScene); tolua_function(tolua_S,"popScene",lua_cocos2dx_Director_popScene); tolua_function(tolua_S,"isDisplayStats",lua_cocos2dx_Director_isDisplayStats); tolua_function(tolua_S,"setProjection",lua_cocos2dx_Director_setProjection); tolua_function(tolua_S,"getConsole",lua_cocos2dx_Director_getConsole); tolua_function(tolua_S,"getZEye",lua_cocos2dx_Director_getZEye); tolua_function(tolua_S,"setNextDeltaTimeZero",lua_cocos2dx_Director_setNextDeltaTimeZero); tolua_function(tolua_S,"getVisibleSize",lua_cocos2dx_Director_getVisibleSize); tolua_function(tolua_S,"getScheduler",lua_cocos2dx_Director_getScheduler); tolua_function(tolua_S,"pushScene",lua_cocos2dx_Director_pushScene); tolua_function(tolua_S,"getAnimationInterval",lua_cocos2dx_Director_getAnimationInterval); tolua_function(tolua_S,"isPaused",lua_cocos2dx_Director_isPaused); tolua_function(tolua_S,"setDisplayStats",lua_cocos2dx_Director_setDisplayStats); tolua_function(tolua_S,"replaceScene",lua_cocos2dx_Director_replaceScene); tolua_function(tolua_S,"setAnimationInterval",lua_cocos2dx_Director_setAnimationInterval); tolua_function(tolua_S,"getActionManager",lua_cocos2dx_Director_getActionManager); tolua_function(tolua_S,"getInstance", lua_cocos2dx_Director_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Director).name(); g_luaType[typeName] = "cc.Director"; g_typeCast["Director"] = "cc.Director"; return 1; } int lua_cocos2dx_GridBase_setGridSize(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_setGridSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setGridSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGridSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_setGridSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_calculateVertexPoints(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_calculateVertexPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->calculateVertexPoints(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "calculateVertexPoints",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_calculateVertexPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_afterDraw(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_afterDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->afterDraw(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "afterDraw",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_afterDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_beforeDraw(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_beforeDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->beforeDraw(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "beforeDraw",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_beforeDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_isTextureFlipped(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_isTextureFlipped'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isTextureFlipped(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTextureFlipped",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_isTextureFlipped'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_getGridSize(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_getGridSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getGridSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGridSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_getGridSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_getStep(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_getStep'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getStep(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStep",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_getStep'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_set2DProjection(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_set2DProjection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->set2DProjection(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "set2DProjection",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_set2DProjection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_setStep(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_setStep'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setStep(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStep",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_setStep'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_setTextureFlipped(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_setTextureFlipped'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTextureFlipped(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextureFlipped",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_setTextureFlipped'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_blit(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_blit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->blit(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "blit",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_blit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_setActive(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_setActive'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setActive(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setActive",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_setActive'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_getReuseGrid(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_getReuseGrid'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getReuseGrid(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getReuseGrid",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_getReuseGrid'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_initWithSize(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_initWithSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } bool ret = cobj->initWithSize(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 3) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Texture2D* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } bool ret = cobj->initWithSize(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithSize",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_initWithSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_setReuseGrid(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_setReuseGrid'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setReuseGrid(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setReuseGrid",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_setReuseGrid'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_isActive(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_isActive'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isActive(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isActive",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_isActive'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_reuse(lua_State* tolua_S) { int argc = 0; cocos2d::GridBase* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridBase*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GridBase_reuse'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->reuse(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reuse",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_reuse'.",&tolua_err); #endif return 0; } int lua_cocos2dx_GridBase_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.GridBase",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::GridBase* ret = cocos2d::GridBase::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GridBase"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GridBase*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Texture2D* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::GridBase* ret = cocos2d::GridBase::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GridBase"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GridBase*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GridBase_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_GridBase_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (GridBase)"); return 0; } int lua_register_cocos2dx_GridBase(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.GridBase"); tolua_cclass(tolua_S,"GridBase","cc.GridBase","cc.Object",NULL); tolua_beginmodule(tolua_S,"GridBase"); tolua_function(tolua_S,"setGridSize",lua_cocos2dx_GridBase_setGridSize); tolua_function(tolua_S,"calculateVertexPoints",lua_cocos2dx_GridBase_calculateVertexPoints); tolua_function(tolua_S,"afterDraw",lua_cocos2dx_GridBase_afterDraw); tolua_function(tolua_S,"beforeDraw",lua_cocos2dx_GridBase_beforeDraw); tolua_function(tolua_S,"isTextureFlipped",lua_cocos2dx_GridBase_isTextureFlipped); tolua_function(tolua_S,"getGridSize",lua_cocos2dx_GridBase_getGridSize); tolua_function(tolua_S,"getStep",lua_cocos2dx_GridBase_getStep); tolua_function(tolua_S,"set2DProjection",lua_cocos2dx_GridBase_set2DProjection); tolua_function(tolua_S,"setStep",lua_cocos2dx_GridBase_setStep); tolua_function(tolua_S,"setTextureFlipped",lua_cocos2dx_GridBase_setTextureFlipped); tolua_function(tolua_S,"blit",lua_cocos2dx_GridBase_blit); tolua_function(tolua_S,"setActive",lua_cocos2dx_GridBase_setActive); tolua_function(tolua_S,"getReuseGrid",lua_cocos2dx_GridBase_getReuseGrid); tolua_function(tolua_S,"initWithSize",lua_cocos2dx_GridBase_initWithSize); tolua_function(tolua_S,"setReuseGrid",lua_cocos2dx_GridBase_setReuseGrid); tolua_function(tolua_S,"isActive",lua_cocos2dx_GridBase_isActive); tolua_function(tolua_S,"reuse",lua_cocos2dx_GridBase_reuse); tolua_function(tolua_S,"create", lua_cocos2dx_GridBase_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::GridBase).name(); g_luaType[typeName] = "cc.GridBase"; g_typeCast["GridBase"] = "cc.GridBase"; return 1; } int lua_cocos2dx_Grid3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Grid3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Grid3D* ret = cocos2d::Grid3D::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Grid3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Grid3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Texture2D* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Grid3D* ret = cocos2d::Grid3D::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Grid3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Grid3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Grid3D_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Grid3D_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Grid3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Grid3D(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Grid3D"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Grid3D"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Grid3D",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Grid3D_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Grid3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Grid3D)"); return 0; } int lua_register_cocos2dx_Grid3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Grid3D"); tolua_cclass(tolua_S,"Grid3D","cc.Grid3D","cc.GridBase",NULL); tolua_beginmodule(tolua_S,"Grid3D"); tolua_function(tolua_S,"create", lua_cocos2dx_Grid3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Grid3D).name(); g_luaType[typeName] = "cc.Grid3D"; g_typeCast["Grid3D"] = "cc.Grid3D"; return 1; } int lua_cocos2dx_TiledGrid3D_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TiledGrid3D",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::TiledGrid3D* ret = cocos2d::TiledGrid3D::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TiledGrid3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TiledGrid3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Texture2D* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::TiledGrid3D* ret = cocos2d::TiledGrid3D::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TiledGrid3D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TiledGrid3D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TiledGrid3D_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TiledGrid3D_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TiledGrid3D* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TiledGrid3D(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TiledGrid3D"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TiledGrid3D"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TiledGrid3D",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TiledGrid3D_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TiledGrid3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TiledGrid3D)"); return 0; } int lua_register_cocos2dx_TiledGrid3D(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TiledGrid3D"); tolua_cclass(tolua_S,"TiledGrid3D","cc.TiledGrid3D","cc.GridBase",NULL); tolua_beginmodule(tolua_S,"TiledGrid3D"); tolua_function(tolua_S,"create", lua_cocos2dx_TiledGrid3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TiledGrid3D).name(); g_luaType[typeName] = "cc.TiledGrid3D"; g_typeCast["TiledGrid3D"] = "cc.TiledGrid3D"; return 1; } int lua_cocos2dx_Sprite_setSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj->setSpriteFrame(arg0); return 0; } }while(0); ok = true; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cobj->setSpriteFrame(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj->setTexture(arg0); return 0; } }while(0); ok = true; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cobj->setTexture(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_getTexture(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_getTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Texture2D* ret = cobj->getTexture(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTexture",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_getTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setFlippedY(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setFlippedY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFlippedY(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFlippedY",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setFlippedY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setFlippedX(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setFlippedX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFlippedX(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFlippedX",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setFlippedX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_getBatchNode(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_getBatchNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::SpriteBatchNode* ret = cobj->getBatchNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBatchNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_getBatchNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_getOffsetPosition(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_getOffsetPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getOffsetPosition(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOffsetPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_getOffsetPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_removeAllChildrenWithCleanup(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_removeAllChildrenWithCleanup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeAllChildrenWithCleanup(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllChildrenWithCleanup",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_removeAllChildrenWithCleanup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_updateQuadVertices(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_updateQuadVertices'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateQuadVertices(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateQuadVertices",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_updateQuadVertices'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_updateTransform(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_updateTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateTransform(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_updateTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setTextureRect(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setTextureRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 3) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::Size arg2; ok &= luaval_to_size(tolua_S, 4, &arg2); if (!ok) { break; } cobj->setTextureRect(arg0, arg1, arg2); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if (!ok) { break; } cobj->setTextureRect(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextureRect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setTextureRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_isFrameDisplayed(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_isFrameDisplayed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->isFrameDisplayed(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFrameDisplayed",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_isFrameDisplayed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_getAtlasIndex(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_getAtlasIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getAtlasIndex(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAtlasIndex",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_getAtlasIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setBatchNode(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setBatchNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteBatchNode* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteBatchNode",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBatchNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBatchNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setBatchNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setDisplayFrameWithAnimationName(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setDisplayFrameWithAnimationName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; ssize_t arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_ssize(tolua_S, 3, &arg1); if(!ok) return 0; cobj->setDisplayFrameWithAnimationName(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDisplayFrameWithAnimationName",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setDisplayFrameWithAnimationName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setTextureAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setTextureAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextureAtlas* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.TextureAtlas",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::TextureAtlas*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTextureAtlas(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextureAtlas",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setTextureAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_getSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_getSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::SpriteFrame* ret = cobj->getSpriteFrame(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSpriteFrame",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_getSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_isDirty(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_isDirty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isDirty(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isDirty",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_isDirty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setAtlasIndex(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setAtlasIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setAtlasIndex(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAtlasIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setAtlasIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setDirty(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setDirty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDirty(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDirty",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setDirty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_isTextureRectRotated(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_isTextureRectRotated'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isTextureRectRotated(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTextureRectRotated",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_isTextureRectRotated'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_getTextureRect(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_getTextureRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Rect& ret = cobj->getTextureRect(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureRect",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_getTextureRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_getTextureAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_getTextureAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TextureAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TextureAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureAtlas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_getTextureAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_isFlippedX(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_isFlippedX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isFlippedX(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFlippedX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_isFlippedX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_isFlippedY(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_isFlippedY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isFlippedY(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFlippedY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_isFlippedY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_setVertexRect(lua_State* tolua_S) { int argc = 0; cocos2d::Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setVertexRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setVertexRect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVertexRect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setVertexRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::Sprite* ret = cocos2d::Sprite::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_createWithTexture(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "createWithTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_createWithSpriteFrameName(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrameName(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithSpriteFrameName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithSpriteFrameName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Sprite_createWithSpriteFrame(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrame(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithSpriteFrame'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Sprite_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Sprite)"); return 0; } int lua_register_cocos2dx_Sprite(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Sprite"); tolua_cclass(tolua_S,"Sprite","cc.Sprite","cc.Node",NULL); tolua_beginmodule(tolua_S,"Sprite"); tolua_function(tolua_S,"setSpriteFrame",lua_cocos2dx_Sprite_setSpriteFrame); tolua_function(tolua_S,"setTexture",lua_cocos2dx_Sprite_setTexture); tolua_function(tolua_S,"getTexture",lua_cocos2dx_Sprite_getTexture); tolua_function(tolua_S,"setFlippedY",lua_cocos2dx_Sprite_setFlippedY); tolua_function(tolua_S,"setFlippedX",lua_cocos2dx_Sprite_setFlippedX); tolua_function(tolua_S,"getBatchNode",lua_cocos2dx_Sprite_getBatchNode); tolua_function(tolua_S,"getOffsetPosition",lua_cocos2dx_Sprite_getOffsetPosition); tolua_function(tolua_S,"removeAllChildrenWithCleanup",lua_cocos2dx_Sprite_removeAllChildrenWithCleanup); tolua_function(tolua_S,"updateQuadVertices",lua_cocos2dx_Sprite_updateQuadVertices); tolua_function(tolua_S,"updateTransform",lua_cocos2dx_Sprite_updateTransform); tolua_function(tolua_S,"setTextureRect",lua_cocos2dx_Sprite_setTextureRect); tolua_function(tolua_S,"isFrameDisplayed",lua_cocos2dx_Sprite_isFrameDisplayed); tolua_function(tolua_S,"getAtlasIndex",lua_cocos2dx_Sprite_getAtlasIndex); tolua_function(tolua_S,"setBatchNode",lua_cocos2dx_Sprite_setBatchNode); tolua_function(tolua_S,"setDisplayFrameWithAnimationName",lua_cocos2dx_Sprite_setDisplayFrameWithAnimationName); tolua_function(tolua_S,"setTextureAtlas",lua_cocos2dx_Sprite_setTextureAtlas); tolua_function(tolua_S,"getSpriteFrame",lua_cocos2dx_Sprite_getSpriteFrame); tolua_function(tolua_S,"isDirty",lua_cocos2dx_Sprite_isDirty); tolua_function(tolua_S,"setAtlasIndex",lua_cocos2dx_Sprite_setAtlasIndex); tolua_function(tolua_S,"setDirty",lua_cocos2dx_Sprite_setDirty); tolua_function(tolua_S,"isTextureRectRotated",lua_cocos2dx_Sprite_isTextureRectRotated); tolua_function(tolua_S,"getTextureRect",lua_cocos2dx_Sprite_getTextureRect); tolua_function(tolua_S,"getTextureAtlas",lua_cocos2dx_Sprite_getTextureAtlas); tolua_function(tolua_S,"isFlippedX",lua_cocos2dx_Sprite_isFlippedX); tolua_function(tolua_S,"isFlippedY",lua_cocos2dx_Sprite_isFlippedY); tolua_function(tolua_S,"setVertexRect",lua_cocos2dx_Sprite_setVertexRect); tolua_function(tolua_S,"create", lua_cocos2dx_Sprite_create); tolua_function(tolua_S,"createWithTexture", lua_cocos2dx_Sprite_createWithTexture); tolua_function(tolua_S,"createWithSpriteFrameName", lua_cocos2dx_Sprite_createWithSpriteFrameName); tolua_function(tolua_S,"createWithSpriteFrame", lua_cocos2dx_Sprite_createWithSpriteFrame); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Sprite).name(); g_luaType[typeName] = "cc.Sprite"; g_typeCast["Sprite"] = "cc.Sprite"; return 1; } int lua_cocos2dx_LabelTTF_enableShadow(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_enableShadow'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::Size arg0; double arg1; double arg2; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cobj->enableShadow(arg0, arg1, arg2); return 0; } if (argc == 4) { cocos2d::Size arg0; double arg1; double arg2; bool arg3; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_boolean(tolua_S, 5,&arg3); if(!ok) return 0; cobj->enableShadow(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "enableShadow",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_enableShadow'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_setDimensions(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_setDimensions'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setDimensions(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDimensions",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_setDimensions'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_getFontSize(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_getFontSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getFontSize(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFontSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_getFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_getString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_getString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getString(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getString",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_getString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_setTextDefinition(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_setTextDefinition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::FontDefinition arg0; ok &= luaval_to_fontdefinition(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTextDefinition(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextDefinition",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_setTextDefinition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_setFontName(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_setFontName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFontName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_setFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_getHorizontalAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_getHorizontalAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getHorizontalAlignment(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getHorizontalAlignment",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_getHorizontalAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_initWithStringAndTextDefinition(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_initWithStringAndTextDefinition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; cocos2d::FontDefinition arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_fontdefinition(tolua_S, 3, &arg1); if(!ok) return 0; bool ret = cobj->initWithStringAndTextDefinition(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithStringAndTextDefinition",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_initWithStringAndTextDefinition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_setString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_setString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setString(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_setString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_initWithString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_initWithString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 5) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Size arg3; ok &= luaval_to_size(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::TextHAlignment arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 3) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 6) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Size arg3; ok &= luaval_to_size(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::TextHAlignment arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } cocos2d::TextVAlignment arg5; ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5); if (!ok) { break; } bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4, arg5); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithString",argc, 6); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_initWithString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_init(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_setFontFillColor(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_setFontFillColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setFontFillColor(arg0); return 0; } if (argc == 2) { cocos2d::Color3B arg0; bool arg1; ok &= luaval_to_color3b(tolua_S, 2, &arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setFontFillColor(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontFillColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_setFontFillColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_enableStroke(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_enableStroke'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Color3B arg0; double arg1; ok &= luaval_to_color3b(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->enableStroke(arg0, arg1); return 0; } if (argc == 3) { cocos2d::Color3B arg0; double arg1; bool arg2; ok &= luaval_to_color3b(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cobj->enableStroke(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "enableStroke",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_enableStroke'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_getDimensions(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_getDimensions'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getDimensions(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDimensions",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_getDimensions'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_setVerticalAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_setVerticalAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextVAlignment arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setVerticalAlignment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVerticalAlignment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_setVerticalAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_setFontSize(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_setFontSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFontSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_setFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_getVerticalAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_getVerticalAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getVerticalAlignment(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVerticalAlignment",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_getVerticalAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_getTextDefinition(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_getTextDefinition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::FontDefinition ret = cobj->getTextDefinition(); fontdefinition_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextDefinition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_getTextDefinition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_getFontName(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_getFontName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getFontName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFontName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_getFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_setHorizontalAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_setHorizontalAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextHAlignment arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setHorizontalAlignment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setHorizontalAlignment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_setHorizontalAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_disableShadow(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_disableShadow'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->disableShadow(); return 0; } if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->disableShadow(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "disableShadow",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_disableShadow'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_disableStroke(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelTTF_disableStroke'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->disableStroke(); return 0; } if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->disableStroke(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "disableStroke",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_disableStroke'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 5) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Size arg3; ok &= luaval_to_size(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::TextHAlignment arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelTTF"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelTTF*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelTTF"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelTTF*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 6) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Size arg3; ok &= luaval_to_size(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::TextHAlignment arg4; ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if (!ok) { break; } cocos2d::TextVAlignment arg5; ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5); if (!ok) { break; } cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2, arg3, arg4, arg5); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelTTF"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelTTF*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelTTF"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelTTF*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_createWithFontDefinition(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.LabelTTF",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { std::string arg0; cocos2d::FontDefinition arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_fontdefinition(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::LabelTTF* ret = cocos2d::LabelTTF::createWithFontDefinition(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelTTF"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelTTF*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithFontDefinition",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_createWithFontDefinition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelTTF_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::LabelTTF* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::LabelTTF(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.LabelTTF"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.LabelTTF"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "LabelTTF",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelTTF_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_LabelTTF_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LabelTTF)"); return 0; } int lua_register_cocos2dx_LabelTTF(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.LabelTTF"); tolua_cclass(tolua_S,"LabelTTF","cc.LabelTTF","cc.Sprite",NULL); tolua_beginmodule(tolua_S,"LabelTTF"); tolua_function(tolua_S,"enableShadow",lua_cocos2dx_LabelTTF_enableShadow); tolua_function(tolua_S,"setDimensions",lua_cocos2dx_LabelTTF_setDimensions); tolua_function(tolua_S,"getFontSize",lua_cocos2dx_LabelTTF_getFontSize); tolua_function(tolua_S,"getString",lua_cocos2dx_LabelTTF_getString); tolua_function(tolua_S,"setTextDefinition",lua_cocos2dx_LabelTTF_setTextDefinition); tolua_function(tolua_S,"setFontName",lua_cocos2dx_LabelTTF_setFontName); tolua_function(tolua_S,"getHorizontalAlignment",lua_cocos2dx_LabelTTF_getHorizontalAlignment); tolua_function(tolua_S,"initWithStringAndTextDefinition",lua_cocos2dx_LabelTTF_initWithStringAndTextDefinition); tolua_function(tolua_S,"setString",lua_cocos2dx_LabelTTF_setString); tolua_function(tolua_S,"initWithString",lua_cocos2dx_LabelTTF_initWithString); tolua_function(tolua_S,"init",lua_cocos2dx_LabelTTF_init); tolua_function(tolua_S,"setFontFillColor",lua_cocos2dx_LabelTTF_setFontFillColor); tolua_function(tolua_S,"enableStroke",lua_cocos2dx_LabelTTF_enableStroke); tolua_function(tolua_S,"getDimensions",lua_cocos2dx_LabelTTF_getDimensions); tolua_function(tolua_S,"setVerticalAlignment",lua_cocos2dx_LabelTTF_setVerticalAlignment); tolua_function(tolua_S,"setFontSize",lua_cocos2dx_LabelTTF_setFontSize); tolua_function(tolua_S,"getVerticalAlignment",lua_cocos2dx_LabelTTF_getVerticalAlignment); tolua_function(tolua_S,"getTextDefinition",lua_cocos2dx_LabelTTF_getTextDefinition); tolua_function(tolua_S,"getFontName",lua_cocos2dx_LabelTTF_getFontName); tolua_function(tolua_S,"setHorizontalAlignment",lua_cocos2dx_LabelTTF_setHorizontalAlignment); tolua_function(tolua_S,"disableShadow",lua_cocos2dx_LabelTTF_disableShadow); tolua_function(tolua_S,"disableStroke",lua_cocos2dx_LabelTTF_disableStroke); tolua_function(tolua_S,"new",lua_cocos2dx_LabelTTF_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_LabelTTF_create); tolua_function(tolua_S,"createWithFontDefinition", lua_cocos2dx_LabelTTF_createWithFontDefinition); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::LabelTTF).name(); g_luaType[typeName] = "cc.LabelTTF"; g_typeCast["LabelTTF"] = "cc.LabelTTF"; return 1; } int lua_cocos2dx_SpriteBatchNode_appendChild(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_appendChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->appendChild(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "appendChild",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_appendChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_reorderBatch(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_reorderBatch'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->reorderBatch(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reorderBatch",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_reorderBatch'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_initWithTexture(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_initWithTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Texture2D* arg0; ssize_t arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_ssize(tolua_S, 3, &arg1); if(!ok) return 0; bool ret = cobj->initWithTexture(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTexture",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_initWithTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; ssize_t ret = cobj->lowestAtlasIndexInChild(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "lowestAtlasIndexInChild",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_atlasIndexForChild(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_atlasIndexForChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Sprite* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; ssize_t ret = cobj->atlasIndexForChild(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "atlasIndexForChild",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_atlasIndexForChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_setTextureAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_setTextureAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextureAtlas* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.TextureAtlas",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::TextureAtlas*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTextureAtlas(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextureAtlas",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_setTextureAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_rebuildIndexInOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Sprite* arg0; ssize_t arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_ssize(tolua_S, 3, &arg1); if(!ok) return 0; ssize_t ret = cobj->rebuildIndexInOrder(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rebuildIndexInOrder",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_rebuildIndexInOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_increaseAtlasCapacity(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_increaseAtlasCapacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->increaseAtlasCapacity(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "increaseAtlasCapacity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_increaseAtlasCapacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_getTextureAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_getTextureAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TextureAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TextureAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureAtlas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_getTextureAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_init(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } ssize_t arg1; ok &= luaval_to_ssize(tolua_S, 3, &arg1); if (!ok) { break; } bool ret = cobj->initWithFile(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithFile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_setTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTexture(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_setTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_getTexture(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_getTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Texture2D* ret = cobj->getTexture(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTexture",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_getTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; ssize_t ret = cobj->highestAtlasIndexInChild(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "highestAtlasIndexInChild",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_removeChildAtIndex(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_removeChildAtIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { ssize_t arg0; bool arg1; ok &= luaval_to_ssize(tolua_S, 2, &arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->removeChildAtIndex(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeChildAtIndex",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_removeChildAtIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_removeAllChildrenWithCleanup(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_removeAllChildrenWithCleanup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeAllChildrenWithCleanup(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllChildrenWithCleanup",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_removeAllChildrenWithCleanup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeSpriteFromAtlas(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeSpriteFromAtlas",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { std::string arg0; ssize_t arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_ssize(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_createWithTexture(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::createWithTexture(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Texture2D* arg0; ssize_t arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_ssize(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::createWithTexture(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_createWithTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteBatchNode_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::SpriteBatchNode(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.SpriteBatchNode"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.SpriteBatchNode"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "SpriteBatchNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_SpriteBatchNode_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SpriteBatchNode)"); return 0; } int lua_register_cocos2dx_SpriteBatchNode(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.SpriteBatchNode"); tolua_cclass(tolua_S,"SpriteBatchNode","cc.SpriteBatchNode","cc.Node",NULL); tolua_beginmodule(tolua_S,"SpriteBatchNode"); tolua_function(tolua_S,"appendChild",lua_cocos2dx_SpriteBatchNode_appendChild); tolua_function(tolua_S,"reorderBatch",lua_cocos2dx_SpriteBatchNode_reorderBatch); tolua_function(tolua_S,"initWithTexture",lua_cocos2dx_SpriteBatchNode_initWithTexture); tolua_function(tolua_S,"lowestAtlasIndexInChild",lua_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild); tolua_function(tolua_S,"atlasIndexForChild",lua_cocos2dx_SpriteBatchNode_atlasIndexForChild); tolua_function(tolua_S,"setTextureAtlas",lua_cocos2dx_SpriteBatchNode_setTextureAtlas); tolua_function(tolua_S,"rebuildIndexInOrder",lua_cocos2dx_SpriteBatchNode_rebuildIndexInOrder); tolua_function(tolua_S,"increaseAtlasCapacity",lua_cocos2dx_SpriteBatchNode_increaseAtlasCapacity); tolua_function(tolua_S,"getTextureAtlas",lua_cocos2dx_SpriteBatchNode_getTextureAtlas); tolua_function(tolua_S,"init",lua_cocos2dx_SpriteBatchNode_init); tolua_function(tolua_S,"setTexture",lua_cocos2dx_SpriteBatchNode_setTexture); tolua_function(tolua_S,"getTexture",lua_cocos2dx_SpriteBatchNode_getTexture); tolua_function(tolua_S,"highestAtlasIndexInChild",lua_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild); tolua_function(tolua_S,"removeChildAtIndex",lua_cocos2dx_SpriteBatchNode_removeChildAtIndex); tolua_function(tolua_S,"removeAllChildrenWithCleanup",lua_cocos2dx_SpriteBatchNode_removeAllChildrenWithCleanup); tolua_function(tolua_S,"removeSpriteFromAtlas",lua_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas); tolua_function(tolua_S,"new",lua_cocos2dx_SpriteBatchNode_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_SpriteBatchNode_create); tolua_function(tolua_S,"createWithTexture", lua_cocos2dx_SpriteBatchNode_createWithTexture); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::SpriteBatchNode).name(); g_luaType[typeName] = "cc.SpriteBatchNode"; g_typeCast["SpriteBatchNode"] = "cc.SpriteBatchNode"; return 1; } int lua_cocos2dx_LabelBMFont_setLineBreakWithoutSpace(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setLineBreakWithoutSpace'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLineBreakWithoutSpace(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLineBreakWithoutSpace",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setLineBreakWithoutSpace'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setScaleY(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setScaleY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScaleY(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScaleY",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setScaleY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setScaleX(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setScaleX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScaleX(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScaleX",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setScaleX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_isOpacityModifyRGB(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_isOpacityModifyRGB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isOpacityModifyRGB(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isOpacityModifyRGB",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_isOpacityModifyRGB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_createFontChars(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_createFontChars'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->createFontChars(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "createFontChars",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_createFontChars'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_getString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_getString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getString(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getString",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_getString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } cobj->setString(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cobj->setString(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_initWithString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_initWithString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; bool ret = cobj->initWithString(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } if (argc == 3) { std::string arg0; std::string arg1; double arg2; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; bool ret = cobj->initWithString(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } if (argc == 4) { std::string arg0; std::string arg1; double arg2; cocos2d::TextHAlignment arg3; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; bool ret = cobj->initWithString(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } if (argc == 5) { std::string arg0; std::string arg1; double arg2; cocos2d::TextHAlignment arg3; cocos2d::Point arg4; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); ok &= luaval_to_point(tolua_S, 6, &arg4); if(!ok) return 0; bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithString",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_initWithString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setCString(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setCString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setCString(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setCString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setScale(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScale(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScale",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setOpacityModifyRGB(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setOpacityModifyRGB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setOpacityModifyRGB(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOpacityModifyRGB",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setOpacityModifyRGB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setFntFile(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setFntFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFntFile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFntFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setFntFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_init(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_getFntFile(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_getFntFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getFntFile(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFntFile",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_getFntFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_updateLabel(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_updateLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateLabel(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateLabel",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_updateLabel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextHAlignment arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setAlignment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAlignment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_setWidth(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LabelBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LabelBMFont_setWidth'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setWidth(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setWidth",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_setWidth'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_purgeCachedData(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::LabelBMFont::purgeCachedData(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "purgeCachedData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_purgeCachedData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.LabelBMFont",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 4) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::TextHAlignment arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelBMFont"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelBMFont*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 5) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::TextHAlignment arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } cocos2d::Point arg4; ok &= luaval_to_point(tolua_S, 6, &arg4); if (!ok) { break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelBMFont"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelBMFont*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelBMFont"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelBMFont*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelBMFont"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelBMFont*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelBMFont"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelBMFont*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LabelBMFont_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::LabelBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::LabelBMFont(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.LabelBMFont"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.LabelBMFont"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "LabelBMFont",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LabelBMFont_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_LabelBMFont_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LabelBMFont)"); return 0; } int lua_register_cocos2dx_LabelBMFont(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.LabelBMFont"); tolua_cclass(tolua_S,"LabelBMFont","cc.LabelBMFont","cc.SpriteBatchNode",NULL); tolua_beginmodule(tolua_S,"LabelBMFont"); tolua_function(tolua_S,"setLineBreakWithoutSpace",lua_cocos2dx_LabelBMFont_setLineBreakWithoutSpace); tolua_function(tolua_S,"setScaleY",lua_cocos2dx_LabelBMFont_setScaleY); tolua_function(tolua_S,"setScaleX",lua_cocos2dx_LabelBMFont_setScaleX); tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_LabelBMFont_isOpacityModifyRGB); tolua_function(tolua_S,"createFontChars",lua_cocos2dx_LabelBMFont_createFontChars); tolua_function(tolua_S,"getString",lua_cocos2dx_LabelBMFont_getString); tolua_function(tolua_S,"setString",lua_cocos2dx_LabelBMFont_setString); tolua_function(tolua_S,"initWithString",lua_cocos2dx_LabelBMFont_initWithString); tolua_function(tolua_S,"setCString",lua_cocos2dx_LabelBMFont_setCString); tolua_function(tolua_S,"setScale",lua_cocos2dx_LabelBMFont_setScale); tolua_function(tolua_S,"setOpacityModifyRGB",lua_cocos2dx_LabelBMFont_setOpacityModifyRGB); tolua_function(tolua_S,"setFntFile",lua_cocos2dx_LabelBMFont_setFntFile); tolua_function(tolua_S,"init",lua_cocos2dx_LabelBMFont_init); tolua_function(tolua_S,"getFntFile",lua_cocos2dx_LabelBMFont_getFntFile); tolua_function(tolua_S,"updateLabel",lua_cocos2dx_LabelBMFont_updateLabel); tolua_function(tolua_S,"setAlignment",lua_cocos2dx_LabelBMFont_setAlignment); tolua_function(tolua_S,"setWidth",lua_cocos2dx_LabelBMFont_setWidth); tolua_function(tolua_S,"new",lua_cocos2dx_LabelBMFont_constructor); tolua_function(tolua_S,"purgeCachedData", lua_cocos2dx_LabelBMFont_purgeCachedData); tolua_function(tolua_S,"create", lua_cocos2dx_LabelBMFont_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::LabelBMFont).name(); g_luaType[typeName] = "cc.LabelBMFont"; g_typeCast["LabelBMFont"] = "cc.LabelBMFont"; return 1; } int lua_cocos2dx_Label_getString(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getString(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getString",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_assignNewUTF16String(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_assignNewUTF16String'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned short* arg0; #pragma warning NO CONVERSION TO NATIVE FOR unsigned short*; if(!ok) return 0; cobj->assignNewUTF16String(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "assignNewUTF16String",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_assignNewUTF16String'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_setLabelEffect(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setLabelEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::LabelEffect arg0; cocos2d::Color3B arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_color3b(tolua_S, 3, &arg1); if(!ok) return 0; cobj->setLabelEffect(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLabelEffect",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setLabelEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getCommonLineHeight(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getCommonLineHeight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getCommonLineHeight(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCommonLineHeight",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getCommonLineHeight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_breakLineWithoutSpace(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_breakLineWithoutSpace'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->breakLineWithoutSpace(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "breakLineWithoutSpace",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_breakLineWithoutSpace'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_setWidth(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setWidth'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setWidth(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setWidth",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setWidth'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getMaxLineWidth(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getMaxLineWidth'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMaxLineWidth(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaxLineWidth",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getMaxLineWidth'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getScaleY(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getScaleY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScaleY(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScaleY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getScaleY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getScaleX(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getScaleX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScaleX(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScaleX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getScaleX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_setString(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setString(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getKernings(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getKernings'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int* ret = cobj->getKernings(); #pragma warning NO CONVERSION FROM NATIVE FOR int*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getKernings",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getKernings'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_setBMFontFilePath(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setBMFontFilePath'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->setBMFontFilePath(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBMFontFilePath",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setBMFontFilePath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_recordPlaceholderInfo(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_recordPlaceholderInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; bool ret = cobj->recordPlaceholderInfo(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "recordPlaceholderInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_recordPlaceholderInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getFontAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getFontAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::FontAtlas* ret = cobj->getFontAtlas(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FontAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FontAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFontAtlas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getFontAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_setLineBreakWithoutSpace(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setLineBreakWithoutSpace'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLineBreakWithoutSpace(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLineBreakWithoutSpace",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setLineBreakWithoutSpace'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getStringNumLines(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getStringNumLines'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getStringNumLines(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringNumLines",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getStringNumLines'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getUTF16String(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getUTF16String'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned short* ret = cobj->getUTF16String(); #pragma warning NO CONVERSION FROM NATIVE FOR unsigned short*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUTF16String",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getUTF16String'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getStringLenght(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getStringLenght'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getStringLenght(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringLenght",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getStringLenght'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_onDraw(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_onDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->onDraw(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onDraw",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_onDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_setCharMap(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setCharMap'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 4) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } int arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } bool ret = cobj->setCharMap(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 4) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } int arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } bool ret = cobj->setCharMap(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } bool ret = cobj->setCharMap(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCharMap",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setCharMap'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getLetter(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getLetter'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Sprite* ret = cobj->getLetter(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLetter",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getLetter'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_getTextAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getTextAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getTextAlignment(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextAlignment",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getTextAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_setAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_setAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextHAlignment arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setAlignment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAlignment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_setAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_recordLetterInfo(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_recordLetterInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::Point arg0; unsigned short arg1; int arg2; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_ushort(tolua_S, 3, &arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if(!ok) return 0; bool ret = cobj->recordLetterInfo(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "recordLetterInfo",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_recordLetterInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_createWithBMFont(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Label"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Label*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { std::string arg0; std::string arg1; cocos2d::TextHAlignment arg2; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if(!ok) return 0; cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Label"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Label*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { std::string arg0; std::string arg1; cocos2d::TextHAlignment arg2; int arg3; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Label"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Label*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithBMFont",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_createWithBMFont'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Label* ret = cocos2d::Label::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Label"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Label*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Label_createWithCharMap(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 4) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } int arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Label"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Label*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 4) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } int arg3; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if (!ok) { break; } cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Label"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Label*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Label"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Label*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "createWithCharMap",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_createWithCharMap'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Label_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Label)"); return 0; } int lua_register_cocos2dx_Label(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Label"); tolua_cclass(tolua_S,"Label","cc.Label","cc.SpriteBatchNode",NULL); tolua_beginmodule(tolua_S,"Label"); tolua_function(tolua_S,"getString",lua_cocos2dx_Label_getString); tolua_function(tolua_S,"assignNewUTF16String",lua_cocos2dx_Label_assignNewUTF16String); tolua_function(tolua_S,"setLabelEffect",lua_cocos2dx_Label_setLabelEffect); tolua_function(tolua_S,"getCommonLineHeight",lua_cocos2dx_Label_getCommonLineHeight); tolua_function(tolua_S,"breakLineWithoutSpace",lua_cocos2dx_Label_breakLineWithoutSpace); tolua_function(tolua_S,"setWidth",lua_cocos2dx_Label_setWidth); tolua_function(tolua_S,"getMaxLineWidth",lua_cocos2dx_Label_getMaxLineWidth); tolua_function(tolua_S,"getScaleY",lua_cocos2dx_Label_getScaleY); tolua_function(tolua_S,"getScaleX",lua_cocos2dx_Label_getScaleX); tolua_function(tolua_S,"setString",lua_cocos2dx_Label_setString); tolua_function(tolua_S,"getKernings",lua_cocos2dx_Label_getKernings); tolua_function(tolua_S,"setBMFontFilePath",lua_cocos2dx_Label_setBMFontFilePath); tolua_function(tolua_S,"recordPlaceholderInfo",lua_cocos2dx_Label_recordPlaceholderInfo); tolua_function(tolua_S,"getFontAtlas",lua_cocos2dx_Label_getFontAtlas); tolua_function(tolua_S,"setLineBreakWithoutSpace",lua_cocos2dx_Label_setLineBreakWithoutSpace); tolua_function(tolua_S,"getStringNumLines",lua_cocos2dx_Label_getStringNumLines); tolua_function(tolua_S,"getUTF16String",lua_cocos2dx_Label_getUTF16String); tolua_function(tolua_S,"getStringLenght",lua_cocos2dx_Label_getStringLenght); tolua_function(tolua_S,"onDraw",lua_cocos2dx_Label_onDraw); tolua_function(tolua_S,"setCharMap",lua_cocos2dx_Label_setCharMap); tolua_function(tolua_S,"getLetter",lua_cocos2dx_Label_getLetter); tolua_function(tolua_S,"getTextAlignment",lua_cocos2dx_Label_getTextAlignment); tolua_function(tolua_S,"setAlignment",lua_cocos2dx_Label_setAlignment); tolua_function(tolua_S,"recordLetterInfo",lua_cocos2dx_Label_recordLetterInfo); tolua_function(tolua_S,"createWithBMFont", lua_cocos2dx_Label_createWithBMFont); tolua_function(tolua_S,"create", lua_cocos2dx_Label_create); tolua_function(tolua_S,"createWithCharMap", lua_cocos2dx_Label_createWithCharMap); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Label).name(); g_luaType[typeName] = "cc.Label"; g_typeCast["Label"] = "cc.Label"; return 1; } int lua_cocos2dx_Layer_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Layer* ret = cocos2d::Layer::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Layer"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Layer*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Layer_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Layer_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Layer)"); return 0; } int lua_register_cocos2dx_Layer(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Layer"); tolua_cclass(tolua_S,"Layer","cc.Layer","cc.Node",NULL); tolua_beginmodule(tolua_S,"Layer"); tolua_function(tolua_S,"create", lua_cocos2dx_Layer_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Layer).name(); g_luaType[typeName] = "cc.Layer"; g_typeCast["Layer"] = "cc.Layer"; return 1; } int lua_cocos2dx_LayerColor_changeWidthAndHeight(lua_State* tolua_S) { int argc = 0; cocos2d::LayerColor* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerColor",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerColor*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerColor_changeWidthAndHeight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; double arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->changeWidthAndHeight(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "changeWidthAndHeight",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerColor_changeWidthAndHeight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerColor_onDraw(lua_State* tolua_S) { int argc = 0; cocos2d::LayerColor* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerColor",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerColor*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerColor_onDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->onDraw(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onDraw",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerColor_onDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerColor_changeWidth(lua_State* tolua_S) { int argc = 0; cocos2d::LayerColor* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerColor",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerColor*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerColor_changeWidth'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->changeWidth(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "changeWidth",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerColor_changeWidth'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerColor_changeHeight(lua_State* tolua_S) { int argc = 0; cocos2d::LayerColor* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerColor",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerColor*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerColor_changeHeight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->changeHeight(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "changeHeight",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerColor_changeHeight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerColor_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.LayerColor",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 3) { cocos2d::Color4B arg0; ok &=luaval_to_color4b(tolua_S, 2, &arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::LayerColor* ret = cocos2d::LayerColor::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LayerColor"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LayerColor*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::LayerColor* ret = cocos2d::LayerColor::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LayerColor"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LayerColor*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 1) { cocos2d::Color4B arg0; ok &=luaval_to_color4b(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::LayerColor* ret = cocos2d::LayerColor::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LayerColor"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LayerColor*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerColor_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_LayerColor_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LayerColor)"); return 0; } int lua_register_cocos2dx_LayerColor(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.LayerColor"); tolua_cclass(tolua_S,"LayerColor","cc.LayerColor","cc.Layer",NULL); tolua_beginmodule(tolua_S,"LayerColor"); tolua_function(tolua_S,"changeWidthAndHeight",lua_cocos2dx_LayerColor_changeWidthAndHeight); tolua_function(tolua_S,"onDraw",lua_cocos2dx_LayerColor_onDraw); tolua_function(tolua_S,"changeWidth",lua_cocos2dx_LayerColor_changeWidth); tolua_function(tolua_S,"changeHeight",lua_cocos2dx_LayerColor_changeHeight); tolua_function(tolua_S,"create", lua_cocos2dx_LayerColor_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::LayerColor).name(); g_luaType[typeName] = "cc.LayerColor"; g_typeCast["LayerColor"] = "cc.LayerColor"; return 1; } int lua_cocos2dx_LayerGradient_getStartColor(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_getStartColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color3B& ret = cobj->getStartColor(); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_getStartColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_isCompressedInterpolation(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_isCompressedInterpolation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isCompressedInterpolation(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isCompressedInterpolation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_isCompressedInterpolation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_getStartOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_getStartOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; uint16_t ret = cobj->getStartOpacity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartOpacity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_getStartOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_setVector(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_setVector'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setVector(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVector",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_setVector'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_setStartOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_setStartOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { uint16_t arg0; ok &= luaval_to_uint16(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStartOpacity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartOpacity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_setStartOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_setCompressedInterpolation(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_setCompressedInterpolation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setCompressedInterpolation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCompressedInterpolation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_setCompressedInterpolation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_setEndOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_setEndOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { uint16_t arg0; ok &= luaval_to_uint16(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEndOpacity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndOpacity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_setEndOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_getVector(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_getVector'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getVector(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVector",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_getVector'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_initWithColor(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_initWithColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Color4B arg0; ok &=luaval_to_color4b(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Color4B arg1; ok &=luaval_to_color4b(tolua_S, 3, &arg1); if (!ok) { break; } bool ret = cobj->initWithColor(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 3) { cocos2d::Color4B arg0; ok &=luaval_to_color4b(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Color4B arg1; ok &=luaval_to_color4b(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::Point arg2; ok &= luaval_to_point(tolua_S, 4, &arg2); if (!ok) { break; } bool ret = cobj->initWithColor(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithColor",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_initWithColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_setEndColor(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_setEndColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setEndColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_setEndColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_getEndColor(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_getEndColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color3B& ret = cobj->getEndColor(); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_getEndColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_getEndOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_getEndOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; uint16_t ret = cobj->getEndOpacity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndOpacity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_getEndOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_setStartColor(lua_State* tolua_S) { int argc = 0; cocos2d::LayerGradient* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerGradient*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerGradient_setStartColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setStartColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_setStartColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerGradient_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.LayerGradient",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { cocos2d::Color4B arg0; ok &=luaval_to_color4b(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Color4B arg1; ok &=luaval_to_color4b(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LayerGradient"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LayerGradient*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LayerGradient"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LayerGradient*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { cocos2d::Color4B arg0; ok &=luaval_to_color4b(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Color4B arg1; ok &=luaval_to_color4b(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::Point arg2; ok &= luaval_to_point(tolua_S, 4, &arg2); if (!ok) { break; } cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LayerGradient"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LayerGradient*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerGradient_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_LayerGradient_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LayerGradient)"); return 0; } int lua_register_cocos2dx_LayerGradient(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.LayerGradient"); tolua_cclass(tolua_S,"LayerGradient","cc.LayerGradient","cc.LayerColor",NULL); tolua_beginmodule(tolua_S,"LayerGradient"); tolua_function(tolua_S,"getStartColor",lua_cocos2dx_LayerGradient_getStartColor); tolua_function(tolua_S,"isCompressedInterpolation",lua_cocos2dx_LayerGradient_isCompressedInterpolation); tolua_function(tolua_S,"getStartOpacity",lua_cocos2dx_LayerGradient_getStartOpacity); tolua_function(tolua_S,"setVector",lua_cocos2dx_LayerGradient_setVector); tolua_function(tolua_S,"setStartOpacity",lua_cocos2dx_LayerGradient_setStartOpacity); tolua_function(tolua_S,"setCompressedInterpolation",lua_cocos2dx_LayerGradient_setCompressedInterpolation); tolua_function(tolua_S,"setEndOpacity",lua_cocos2dx_LayerGradient_setEndOpacity); tolua_function(tolua_S,"getVector",lua_cocos2dx_LayerGradient_getVector); tolua_function(tolua_S,"init",lua_cocos2dx_LayerGradient_initWithColor); tolua_function(tolua_S,"setEndColor",lua_cocos2dx_LayerGradient_setEndColor); tolua_function(tolua_S,"getEndColor",lua_cocos2dx_LayerGradient_getEndColor); tolua_function(tolua_S,"getEndOpacity",lua_cocos2dx_LayerGradient_getEndOpacity); tolua_function(tolua_S,"setStartColor",lua_cocos2dx_LayerGradient_setStartColor); tolua_function(tolua_S,"create", lua_cocos2dx_LayerGradient_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::LayerGradient).name(); g_luaType[typeName] = "cc.LayerGradient"; g_typeCast["LayerGradient"] = "cc.LayerGradient"; return 1; } int lua_cocos2dx_LayerMultiplex_switchToAndReleaseMe(lua_State* tolua_S) { int argc = 0; cocos2d::LayerMultiplex* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerMultiplex",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerMultiplex*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerMultiplex_switchToAndReleaseMe'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->switchToAndReleaseMe(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "switchToAndReleaseMe",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerMultiplex_switchToAndReleaseMe'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerMultiplex_addLayer(lua_State* tolua_S) { int argc = 0; cocos2d::LayerMultiplex* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerMultiplex",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerMultiplex*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerMultiplex_addLayer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Layer* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Layer",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Layer*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addLayer(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addLayer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerMultiplex_addLayer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_LayerMultiplex_switchTo(lua_State* tolua_S) { int argc = 0; cocos2d::LayerMultiplex* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.LayerMultiplex",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::LayerMultiplex*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_LayerMultiplex_switchTo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->switchTo(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "switchTo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_LayerMultiplex_switchTo'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_LayerMultiplex_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LayerMultiplex)"); return 0; } int lua_register_cocos2dx_LayerMultiplex(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.LayerMultiplex"); tolua_cclass(tolua_S,"LayerMultiplex","cc.LayerMultiplex","cc.Layer",NULL); tolua_beginmodule(tolua_S,"LayerMultiplex"); tolua_function(tolua_S,"switchToAndReleaseMe",lua_cocos2dx_LayerMultiplex_switchToAndReleaseMe); tolua_function(tolua_S,"addLayer",lua_cocos2dx_LayerMultiplex_addLayer); tolua_function(tolua_S,"switchTo",lua_cocos2dx_LayerMultiplex_switchTo); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::LayerMultiplex).name(); g_luaType[typeName] = "cc.LayerMultiplex"; g_typeCast["LayerMultiplex"] = "cc.LayerMultiplex"; return 1; } int lua_cocos2dx_Scene_getPhysicsWorld(lua_State* tolua_S) { int argc = 0; cocos2d::Scene* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scene",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Scene*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Scene_getPhysicsWorld'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsWorld* ret = cobj->getPhysicsWorld(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsWorld"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsWorld*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPhysicsWorld",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scene_getPhysicsWorld'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Scene_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Scene",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Scene* ret = cocos2d::Scene::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scene"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Scene*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scene_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Scene_createWithPhysics(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Scene",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Scene* ret = cocos2d::Scene::createWithPhysics(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scene"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Scene*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithPhysics",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scene_createWithPhysics'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Scene_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Scene)"); return 0; } int lua_register_cocos2dx_Scene(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Scene"); tolua_cclass(tolua_S,"Scene","cc.Scene","cc.Node",NULL); tolua_beginmodule(tolua_S,"Scene"); tolua_function(tolua_S,"getPhysicsWorld",lua_cocos2dx_Scene_getPhysicsWorld); tolua_function(tolua_S,"create", lua_cocos2dx_Scene_create); tolua_function(tolua_S,"createWithPhysics", lua_cocos2dx_Scene_createWithPhysics); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Scene).name(); g_luaType[typeName] = "cc.Scene"; g_typeCast["Scene"] = "cc.Scene"; return 1; } int lua_cocos2dx_TransitionEaseScene_easeActionWithAction(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionEaseScene* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionEaseScene",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionEaseScene*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionEaseScene_easeActionWithAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "easeActionWithAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionEaseScene_easeActionWithAction'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionEaseScene_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionEaseScene)"); return 0; } int lua_register_cocos2dx_TransitionEaseScene(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionEaseScene"); tolua_cclass(tolua_S,"TransitionEaseScene","cc.TransitionEaseScene","",NULL); tolua_beginmodule(tolua_S,"TransitionEaseScene"); tolua_function(tolua_S,"easeActionWithAction",lua_cocos2dx_TransitionEaseScene_easeActionWithAction); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionEaseScene).name(); g_luaType[typeName] = "cc.TransitionEaseScene"; g_typeCast["TransitionEaseScene"] = "cc.TransitionEaseScene"; return 1; } int lua_cocos2dx_TransitionScene_finish(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionScene* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionScene",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionScene*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionScene_finish'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->finish(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "finish",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionScene_finish'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionScene_hideOutShowIn(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionScene* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionScene",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionScene*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionScene_hideOutShowIn'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->hideOutShowIn(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hideOutShowIn",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionScene_hideOutShowIn'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionScene_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionScene",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionScene* ret = cocos2d::TransitionScene::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionScene"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionScene*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionScene_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionScene_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionScene)"); return 0; } int lua_register_cocos2dx_TransitionScene(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionScene"); tolua_cclass(tolua_S,"TransitionScene","cc.TransitionScene","cc.Scene",NULL); tolua_beginmodule(tolua_S,"TransitionScene"); tolua_function(tolua_S,"finish",lua_cocos2dx_TransitionScene_finish); tolua_function(tolua_S,"hideOutShowIn",lua_cocos2dx_TransitionScene_hideOutShowIn); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionScene_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionScene).name(); g_luaType[typeName] = "cc.TransitionScene"; g_typeCast["TransitionScene"] = "cc.TransitionScene"; return 1; } int lua_cocos2dx_TransitionSceneOriented_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionSceneOriented",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { double arg0; cocos2d::Scene* arg1; cocos2d::TransitionScene::Orientation arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if(!ok) return 0; cocos2d::TransitionSceneOriented* ret = cocos2d::TransitionSceneOriented::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionSceneOriented"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionSceneOriented*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSceneOriented_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionSceneOriented_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionSceneOriented)"); return 0; } int lua_register_cocos2dx_TransitionSceneOriented(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionSceneOriented"); tolua_cclass(tolua_S,"TransitionSceneOriented","cc.TransitionSceneOriented","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionSceneOriented"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionSceneOriented_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionSceneOriented).name(); g_luaType[typeName] = "cc.TransitionSceneOriented"; g_typeCast["TransitionSceneOriented"] = "cc.TransitionSceneOriented"; return 1; } int lua_cocos2dx_TransitionRotoZoom_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionRotoZoom",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionRotoZoom* ret = cocos2d::TransitionRotoZoom::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionRotoZoom"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionRotoZoom*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionRotoZoom_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionRotoZoom_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionRotoZoom)"); return 0; } int lua_register_cocos2dx_TransitionRotoZoom(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionRotoZoom"); tolua_cclass(tolua_S,"TransitionRotoZoom","cc.TransitionRotoZoom","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionRotoZoom"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionRotoZoom_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionRotoZoom).name(); g_luaType[typeName] = "cc.TransitionRotoZoom"; g_typeCast["TransitionRotoZoom"] = "cc.TransitionRotoZoom"; return 1; } int lua_cocos2dx_TransitionJumpZoom_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionJumpZoom",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionJumpZoom* ret = cocos2d::TransitionJumpZoom::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionJumpZoom"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionJumpZoom*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionJumpZoom_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionJumpZoom_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionJumpZoom)"); return 0; } int lua_register_cocos2dx_TransitionJumpZoom(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionJumpZoom"); tolua_cclass(tolua_S,"TransitionJumpZoom","cc.TransitionJumpZoom","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionJumpZoom"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionJumpZoom_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionJumpZoom).name(); g_luaType[typeName] = "cc.TransitionJumpZoom"; g_typeCast["TransitionJumpZoom"] = "cc.TransitionJumpZoom"; return 1; } int lua_cocos2dx_TransitionMoveInL_action(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionMoveInL* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionMoveInL",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionMoveInL*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionMoveInL_action'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->action(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "action",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionMoveInL_action'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionMoveInL_easeActionWithAction(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionMoveInL* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionMoveInL",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionMoveInL*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionMoveInL_easeActionWithAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "easeActionWithAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionMoveInL_easeActionWithAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionMoveInL_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionMoveInL",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionMoveInL* ret = cocos2d::TransitionMoveInL::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionMoveInL"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionMoveInL*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionMoveInL_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionMoveInL_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionMoveInL)"); return 0; } int lua_register_cocos2dx_TransitionMoveInL(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionMoveInL"); tolua_cclass(tolua_S,"TransitionMoveInL","cc.TransitionMoveInL","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionMoveInL"); tolua_function(tolua_S,"action",lua_cocos2dx_TransitionMoveInL_action); tolua_function(tolua_S,"easeActionWithAction",lua_cocos2dx_TransitionMoveInL_easeActionWithAction); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionMoveInL_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionMoveInL).name(); g_luaType[typeName] = "cc.TransitionMoveInL"; g_typeCast["TransitionMoveInL"] = "cc.TransitionMoveInL"; return 1; } int lua_cocos2dx_TransitionMoveInR_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionMoveInR",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionMoveInR* ret = cocos2d::TransitionMoveInR::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionMoveInR"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionMoveInR*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionMoveInR_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionMoveInR_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionMoveInR)"); return 0; } int lua_register_cocos2dx_TransitionMoveInR(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionMoveInR"); tolua_cclass(tolua_S,"TransitionMoveInR","cc.TransitionMoveInR","cc.TransitionMoveInL",NULL); tolua_beginmodule(tolua_S,"TransitionMoveInR"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionMoveInR_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionMoveInR).name(); g_luaType[typeName] = "cc.TransitionMoveInR"; g_typeCast["TransitionMoveInR"] = "cc.TransitionMoveInR"; return 1; } int lua_cocos2dx_TransitionMoveInT_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionMoveInT",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionMoveInT* ret = cocos2d::TransitionMoveInT::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionMoveInT"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionMoveInT*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionMoveInT_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionMoveInT_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionMoveInT)"); return 0; } int lua_register_cocos2dx_TransitionMoveInT(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionMoveInT"); tolua_cclass(tolua_S,"TransitionMoveInT","cc.TransitionMoveInT","cc.TransitionMoveInL",NULL); tolua_beginmodule(tolua_S,"TransitionMoveInT"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionMoveInT_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionMoveInT).name(); g_luaType[typeName] = "cc.TransitionMoveInT"; g_typeCast["TransitionMoveInT"] = "cc.TransitionMoveInT"; return 1; } int lua_cocos2dx_TransitionMoveInB_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionMoveInB",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionMoveInB* ret = cocos2d::TransitionMoveInB::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionMoveInB"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionMoveInB*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionMoveInB_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionMoveInB_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionMoveInB)"); return 0; } int lua_register_cocos2dx_TransitionMoveInB(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionMoveInB"); tolua_cclass(tolua_S,"TransitionMoveInB","cc.TransitionMoveInB","cc.TransitionMoveInL",NULL); tolua_beginmodule(tolua_S,"TransitionMoveInB"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionMoveInB_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionMoveInB).name(); g_luaType[typeName] = "cc.TransitionMoveInB"; g_typeCast["TransitionMoveInB"] = "cc.TransitionMoveInB"; return 1; } int lua_cocos2dx_TransitionSlideInL_action(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionSlideInL* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionSlideInL",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionSlideInL*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionSlideInL_action'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->action(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "action",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInL_action'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionSlideInL_easeActionWithAction(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionSlideInL* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionSlideInL",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionSlideInL*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionSlideInL_easeActionWithAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "easeActionWithAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInL_easeActionWithAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionSlideInL_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionSlideInL",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionSlideInL* ret = cocos2d::TransitionSlideInL::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionSlideInL"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionSlideInL*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInL_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionSlideInL_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionSlideInL)"); return 0; } int lua_register_cocos2dx_TransitionSlideInL(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionSlideInL"); tolua_cclass(tolua_S,"TransitionSlideInL","cc.TransitionSlideInL","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionSlideInL"); tolua_function(tolua_S,"action",lua_cocos2dx_TransitionSlideInL_action); tolua_function(tolua_S,"easeActionWithAction",lua_cocos2dx_TransitionSlideInL_easeActionWithAction); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionSlideInL_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionSlideInL).name(); g_luaType[typeName] = "cc.TransitionSlideInL"; g_typeCast["TransitionSlideInL"] = "cc.TransitionSlideInL"; return 1; } int lua_cocos2dx_TransitionSlideInR_action(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionSlideInR* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionSlideInR",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionSlideInR*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionSlideInR_action'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->action(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "action",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInR_action'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionSlideInR_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionSlideInR",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionSlideInR* ret = cocos2d::TransitionSlideInR::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionSlideInR"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionSlideInR*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInR_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionSlideInR_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionSlideInR)"); return 0; } int lua_register_cocos2dx_TransitionSlideInR(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionSlideInR"); tolua_cclass(tolua_S,"TransitionSlideInR","cc.TransitionSlideInR","cc.TransitionSlideInL",NULL); tolua_beginmodule(tolua_S,"TransitionSlideInR"); tolua_function(tolua_S,"action",lua_cocos2dx_TransitionSlideInR_action); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionSlideInR_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionSlideInR).name(); g_luaType[typeName] = "cc.TransitionSlideInR"; g_typeCast["TransitionSlideInR"] = "cc.TransitionSlideInR"; return 1; } int lua_cocos2dx_TransitionSlideInB_action(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionSlideInB* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionSlideInB",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionSlideInB*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionSlideInB_action'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->action(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "action",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInB_action'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionSlideInB_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionSlideInB",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionSlideInB* ret = cocos2d::TransitionSlideInB::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionSlideInB"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionSlideInB*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInB_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionSlideInB_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionSlideInB)"); return 0; } int lua_register_cocos2dx_TransitionSlideInB(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionSlideInB"); tolua_cclass(tolua_S,"TransitionSlideInB","cc.TransitionSlideInB","cc.TransitionSlideInL",NULL); tolua_beginmodule(tolua_S,"TransitionSlideInB"); tolua_function(tolua_S,"action",lua_cocos2dx_TransitionSlideInB_action); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionSlideInB_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionSlideInB).name(); g_luaType[typeName] = "cc.TransitionSlideInB"; g_typeCast["TransitionSlideInB"] = "cc.TransitionSlideInB"; return 1; } int lua_cocos2dx_TransitionSlideInT_action(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionSlideInT* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionSlideInT",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionSlideInT*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionSlideInT_action'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->action(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "action",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInT_action'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionSlideInT_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionSlideInT",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionSlideInT* ret = cocos2d::TransitionSlideInT::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionSlideInT"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionSlideInT*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSlideInT_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionSlideInT_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionSlideInT)"); return 0; } int lua_register_cocos2dx_TransitionSlideInT(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionSlideInT"); tolua_cclass(tolua_S,"TransitionSlideInT","cc.TransitionSlideInT","cc.TransitionSlideInL",NULL); tolua_beginmodule(tolua_S,"TransitionSlideInT"); tolua_function(tolua_S,"action",lua_cocos2dx_TransitionSlideInT_action); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionSlideInT_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionSlideInT).name(); g_luaType[typeName] = "cc.TransitionSlideInT"; g_typeCast["TransitionSlideInT"] = "cc.TransitionSlideInT"; return 1; } int lua_cocos2dx_TransitionShrinkGrow_easeActionWithAction(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionShrinkGrow* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionShrinkGrow",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionShrinkGrow*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionShrinkGrow_easeActionWithAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "easeActionWithAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionShrinkGrow_easeActionWithAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionShrinkGrow_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionShrinkGrow",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionShrinkGrow* ret = cocos2d::TransitionShrinkGrow::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionShrinkGrow"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionShrinkGrow*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionShrinkGrow_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionShrinkGrow_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionShrinkGrow)"); return 0; } int lua_register_cocos2dx_TransitionShrinkGrow(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionShrinkGrow"); tolua_cclass(tolua_S,"TransitionShrinkGrow","cc.TransitionShrinkGrow","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionShrinkGrow"); tolua_function(tolua_S,"easeActionWithAction",lua_cocos2dx_TransitionShrinkGrow_easeActionWithAction); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionShrinkGrow_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionShrinkGrow).name(); g_luaType[typeName] = "cc.TransitionShrinkGrow"; g_typeCast["TransitionShrinkGrow"] = "cc.TransitionShrinkGrow"; return 1; } int lua_cocos2dx_TransitionFlipX_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionFlipX",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionFlipX* ret = cocos2d::TransitionFlipX::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFlipX"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFlipX*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionScene::Orientation arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cocos2d::TransitionFlipX* ret = cocos2d::TransitionFlipX::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFlipX"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFlipX*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFlipX_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionFlipX_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionFlipX)"); return 0; } int lua_register_cocos2dx_TransitionFlipX(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionFlipX"); tolua_cclass(tolua_S,"TransitionFlipX","cc.TransitionFlipX","cc.TransitionSceneOriented",NULL); tolua_beginmodule(tolua_S,"TransitionFlipX"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionFlipX_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionFlipX).name(); g_luaType[typeName] = "cc.TransitionFlipX"; g_typeCast["TransitionFlipX"] = "cc.TransitionFlipX"; return 1; } int lua_cocos2dx_TransitionFlipY_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionFlipY",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionFlipY* ret = cocos2d::TransitionFlipY::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFlipY"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFlipY*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionScene::Orientation arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cocos2d::TransitionFlipY* ret = cocos2d::TransitionFlipY::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFlipY"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFlipY*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFlipY_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionFlipY_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionFlipY)"); return 0; } int lua_register_cocos2dx_TransitionFlipY(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionFlipY"); tolua_cclass(tolua_S,"TransitionFlipY","cc.TransitionFlipY","cc.TransitionSceneOriented",NULL); tolua_beginmodule(tolua_S,"TransitionFlipY"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionFlipY_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionFlipY).name(); g_luaType[typeName] = "cc.TransitionFlipY"; g_typeCast["TransitionFlipY"] = "cc.TransitionFlipY"; return 1; } int lua_cocos2dx_TransitionFlipAngular_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionFlipAngular",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionFlipAngular* ret = cocos2d::TransitionFlipAngular::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFlipAngular"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFlipAngular*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionScene::Orientation arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cocos2d::TransitionFlipAngular* ret = cocos2d::TransitionFlipAngular::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFlipAngular"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFlipAngular*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFlipAngular_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionFlipAngular_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionFlipAngular)"); return 0; } int lua_register_cocos2dx_TransitionFlipAngular(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionFlipAngular"); tolua_cclass(tolua_S,"TransitionFlipAngular","cc.TransitionFlipAngular","cc.TransitionSceneOriented",NULL); tolua_beginmodule(tolua_S,"TransitionFlipAngular"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionFlipAngular_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionFlipAngular).name(); g_luaType[typeName] = "cc.TransitionFlipAngular"; g_typeCast["TransitionFlipAngular"] = "cc.TransitionFlipAngular"; return 1; } int lua_cocos2dx_TransitionZoomFlipX_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionZoomFlipX",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionZoomFlipX* ret = cocos2d::TransitionZoomFlipX::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionZoomFlipX"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionZoomFlipX*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionScene::Orientation arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cocos2d::TransitionZoomFlipX* ret = cocos2d::TransitionZoomFlipX::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionZoomFlipX"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionZoomFlipX*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionZoomFlipX_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionZoomFlipX_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionZoomFlipX)"); return 0; } int lua_register_cocos2dx_TransitionZoomFlipX(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionZoomFlipX"); tolua_cclass(tolua_S,"TransitionZoomFlipX","cc.TransitionZoomFlipX","cc.TransitionSceneOriented",NULL); tolua_beginmodule(tolua_S,"TransitionZoomFlipX"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionZoomFlipX_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionZoomFlipX).name(); g_luaType[typeName] = "cc.TransitionZoomFlipX"; g_typeCast["TransitionZoomFlipX"] = "cc.TransitionZoomFlipX"; return 1; } int lua_cocos2dx_TransitionZoomFlipY_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionZoomFlipY",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionZoomFlipY* ret = cocos2d::TransitionZoomFlipY::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionZoomFlipY"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionZoomFlipY*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionScene::Orientation arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cocos2d::TransitionZoomFlipY* ret = cocos2d::TransitionZoomFlipY::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionZoomFlipY"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionZoomFlipY*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionZoomFlipY_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionZoomFlipY_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionZoomFlipY)"); return 0; } int lua_register_cocos2dx_TransitionZoomFlipY(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionZoomFlipY"); tolua_cclass(tolua_S,"TransitionZoomFlipY","cc.TransitionZoomFlipY","cc.TransitionSceneOriented",NULL); tolua_beginmodule(tolua_S,"TransitionZoomFlipY"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionZoomFlipY_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionZoomFlipY).name(); g_luaType[typeName] = "cc.TransitionZoomFlipY"; g_typeCast["TransitionZoomFlipY"] = "cc.TransitionZoomFlipY"; return 1; } int lua_cocos2dx_TransitionZoomFlipAngular_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionZoomFlipAngular",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionZoomFlipAngular* ret = cocos2d::TransitionZoomFlipAngular::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionZoomFlipAngular"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionZoomFlipAngular*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionScene::Orientation arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cocos2d::TransitionZoomFlipAngular* ret = cocos2d::TransitionZoomFlipAngular::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionZoomFlipAngular"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionZoomFlipAngular*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionZoomFlipAngular_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionZoomFlipAngular_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionZoomFlipAngular)"); return 0; } int lua_register_cocos2dx_TransitionZoomFlipAngular(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionZoomFlipAngular"); tolua_cclass(tolua_S,"TransitionZoomFlipAngular","cc.TransitionZoomFlipAngular","cc.TransitionSceneOriented",NULL); tolua_beginmodule(tolua_S,"TransitionZoomFlipAngular"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionZoomFlipAngular_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionZoomFlipAngular).name(); g_luaType[typeName] = "cc.TransitionZoomFlipAngular"; g_typeCast["TransitionZoomFlipAngular"] = "cc.TransitionZoomFlipAngular"; return 1; } int lua_cocos2dx_TransitionFade_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionFade",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::TransitionFade* ret = cocos2d::TransitionFade::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFade"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFade*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Scene* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Color3B arg2; ok &= luaval_to_color3b(tolua_S, 4, &arg2); if (!ok) { break; } cocos2d::TransitionFade* ret = cocos2d::TransitionFade::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFade"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFade*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFade_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionFade_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionFade)"); return 0; } int lua_register_cocos2dx_TransitionFade(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionFade"); tolua_cclass(tolua_S,"TransitionFade","cc.TransitionFade","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionFade"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionFade_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionFade).name(); g_luaType[typeName] = "cc.TransitionFade"; g_typeCast["TransitionFade"] = "cc.TransitionFade"; return 1; } int lua_cocos2dx_TransitionCrossFade_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionCrossFade",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionCrossFade* ret = cocos2d::TransitionCrossFade::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionCrossFade"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionCrossFade*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionCrossFade_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionCrossFade_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionCrossFade)"); return 0; } int lua_register_cocos2dx_TransitionCrossFade(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionCrossFade"); tolua_cclass(tolua_S,"TransitionCrossFade","cc.TransitionCrossFade","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionCrossFade"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionCrossFade_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionCrossFade).name(); g_luaType[typeName] = "cc.TransitionCrossFade"; g_typeCast["TransitionCrossFade"] = "cc.TransitionCrossFade"; return 1; } int lua_cocos2dx_TransitionTurnOffTiles_easeActionWithAction(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionTurnOffTiles* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionTurnOffTiles",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionTurnOffTiles*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionTurnOffTiles_easeActionWithAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "easeActionWithAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionTurnOffTiles_easeActionWithAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionTurnOffTiles_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionTurnOffTiles",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionTurnOffTiles* ret = cocos2d::TransitionTurnOffTiles::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionTurnOffTiles"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionTurnOffTiles*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionTurnOffTiles_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionTurnOffTiles_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionTurnOffTiles)"); return 0; } int lua_register_cocos2dx_TransitionTurnOffTiles(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionTurnOffTiles"); tolua_cclass(tolua_S,"TransitionTurnOffTiles","cc.TransitionTurnOffTiles","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionTurnOffTiles"); tolua_function(tolua_S,"easeActionWithAction",lua_cocos2dx_TransitionTurnOffTiles_easeActionWithAction); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionTurnOffTiles_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionTurnOffTiles).name(); g_luaType[typeName] = "cc.TransitionTurnOffTiles"; g_typeCast["TransitionTurnOffTiles"] = "cc.TransitionTurnOffTiles"; return 1; } int lua_cocos2dx_TransitionSplitCols_action(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionSplitCols* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionSplitCols",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionSplitCols*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionSplitCols_action'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->action(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "action",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSplitCols_action'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionSplitCols_easeActionWithAction(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionSplitCols* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionSplitCols",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionSplitCols*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionSplitCols_easeActionWithAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "easeActionWithAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSplitCols_easeActionWithAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionSplitCols_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionSplitCols",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionSplitCols* ret = cocos2d::TransitionSplitCols::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionSplitCols"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionSplitCols*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSplitCols_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionSplitCols_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionSplitCols)"); return 0; } int lua_register_cocos2dx_TransitionSplitCols(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionSplitCols"); tolua_cclass(tolua_S,"TransitionSplitCols","cc.TransitionSplitCols","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionSplitCols"); tolua_function(tolua_S,"action",lua_cocos2dx_TransitionSplitCols_action); tolua_function(tolua_S,"easeActionWithAction",lua_cocos2dx_TransitionSplitCols_easeActionWithAction); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionSplitCols_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionSplitCols).name(); g_luaType[typeName] = "cc.TransitionSplitCols"; g_typeCast["TransitionSplitCols"] = "cc.TransitionSplitCols"; return 1; } int lua_cocos2dx_TransitionSplitRows_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionSplitRows",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionSplitRows* ret = cocos2d::TransitionSplitRows::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionSplitRows"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionSplitRows*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionSplitRows_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionSplitRows_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionSplitRows)"); return 0; } int lua_register_cocos2dx_TransitionSplitRows(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionSplitRows"); tolua_cclass(tolua_S,"TransitionSplitRows","cc.TransitionSplitRows","cc.TransitionSplitCols",NULL); tolua_beginmodule(tolua_S,"TransitionSplitRows"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionSplitRows_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionSplitRows).name(); g_luaType[typeName] = "cc.TransitionSplitRows"; g_typeCast["TransitionSplitRows"] = "cc.TransitionSplitRows"; return 1; } int lua_cocos2dx_TransitionFadeTR_easeActionWithAction(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionFadeTR* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionFadeTR",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionFadeTR*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionFadeTR_easeActionWithAction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ActionInterval* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ActionInterval",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ActionInterval*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "easeActionWithAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFadeTR_easeActionWithAction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionFadeTR_actionWithSize(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionFadeTR* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionFadeTR",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionFadeTR*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionFadeTR_actionWithSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->actionWithSize(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "actionWithSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFadeTR_actionWithSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionFadeTR_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionFadeTR",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionFadeTR* ret = cocos2d::TransitionFadeTR::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFadeTR"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFadeTR*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFadeTR_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionFadeTR_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionFadeTR)"); return 0; } int lua_register_cocos2dx_TransitionFadeTR(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionFadeTR"); tolua_cclass(tolua_S,"TransitionFadeTR","cc.TransitionFadeTR","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionFadeTR"); tolua_function(tolua_S,"easeActionWithAction",lua_cocos2dx_TransitionFadeTR_easeActionWithAction); tolua_function(tolua_S,"actionWithSize",lua_cocos2dx_TransitionFadeTR_actionWithSize); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionFadeTR_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionFadeTR).name(); g_luaType[typeName] = "cc.TransitionFadeTR"; g_typeCast["TransitionFadeTR"] = "cc.TransitionFadeTR"; return 1; } int lua_cocos2dx_TransitionFadeBL_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionFadeBL",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionFadeBL* ret = cocos2d::TransitionFadeBL::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFadeBL"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFadeBL*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFadeBL_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionFadeBL_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionFadeBL)"); return 0; } int lua_register_cocos2dx_TransitionFadeBL(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionFadeBL"); tolua_cclass(tolua_S,"TransitionFadeBL","cc.TransitionFadeBL","cc.TransitionFadeTR",NULL); tolua_beginmodule(tolua_S,"TransitionFadeBL"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionFadeBL_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionFadeBL).name(); g_luaType[typeName] = "cc.TransitionFadeBL"; g_typeCast["TransitionFadeBL"] = "cc.TransitionFadeBL"; return 1; } int lua_cocos2dx_TransitionFadeUp_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionFadeUp",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionFadeUp* ret = cocos2d::TransitionFadeUp::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFadeUp"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFadeUp*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFadeUp_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionFadeUp_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionFadeUp)"); return 0; } int lua_register_cocos2dx_TransitionFadeUp(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionFadeUp"); tolua_cclass(tolua_S,"TransitionFadeUp","cc.TransitionFadeUp","cc.TransitionFadeTR",NULL); tolua_beginmodule(tolua_S,"TransitionFadeUp"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionFadeUp_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionFadeUp).name(); g_luaType[typeName] = "cc.TransitionFadeUp"; g_typeCast["TransitionFadeUp"] = "cc.TransitionFadeUp"; return 1; } int lua_cocos2dx_TransitionFadeDown_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionFadeDown",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionFadeDown* ret = cocos2d::TransitionFadeDown::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionFadeDown"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionFadeDown*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionFadeDown_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionFadeDown_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionFadeDown)"); return 0; } int lua_register_cocos2dx_TransitionFadeDown(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionFadeDown"); tolua_cclass(tolua_S,"TransitionFadeDown","cc.TransitionFadeDown","cc.TransitionFadeTR",NULL); tolua_beginmodule(tolua_S,"TransitionFadeDown"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionFadeDown_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionFadeDown).name(); g_luaType[typeName] = "cc.TransitionFadeDown"; g_typeCast["TransitionFadeDown"] = "cc.TransitionFadeDown"; return 1; } int lua_cocos2dx_TransitionPageTurn_actionWithSize(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionPageTurn* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionPageTurn",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionPageTurn*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionPageTurn_actionWithSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::ActionInterval* ret = cobj->actionWithSize(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ActionInterval"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ActionInterval*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "actionWithSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionPageTurn_actionWithSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionPageTurn_initWithDuration(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionPageTurn* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TransitionPageTurn",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TransitionPageTurn*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TransitionPageTurn_initWithDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { double arg0; cocos2d::Scene* arg1; bool arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; bool ret = cobj->initWithDuration(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithDuration",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionPageTurn_initWithDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionPageTurn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionPageTurn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { double arg0; cocos2d::Scene* arg1; bool arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cocos2d::TransitionPageTurn* ret = cocos2d::TransitionPageTurn::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionPageTurn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionPageTurn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionPageTurn_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionPageTurn_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionPageTurn* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TransitionPageTurn(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TransitionPageTurn"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TransitionPageTurn"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TransitionPageTurn",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionPageTurn_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionPageTurn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionPageTurn)"); return 0; } int lua_register_cocos2dx_TransitionPageTurn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionPageTurn"); tolua_cclass(tolua_S,"TransitionPageTurn","cc.TransitionPageTurn","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionPageTurn"); tolua_function(tolua_S,"actionWithSize",lua_cocos2dx_TransitionPageTurn_actionWithSize); tolua_function(tolua_S,"initWithDuration",lua_cocos2dx_TransitionPageTurn_initWithDuration); tolua_function(tolua_S,"new",lua_cocos2dx_TransitionPageTurn_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionPageTurn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionPageTurn).name(); g_luaType[typeName] = "cc.TransitionPageTurn"; g_typeCast["TransitionPageTurn"] = "cc.TransitionPageTurn"; return 1; } int lua_cocos2dx_TransitionProgress_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionProgress",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionProgress* ret = cocos2d::TransitionProgress::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionProgress"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionProgress*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionProgress_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TransitionProgress_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TransitionProgress* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TransitionProgress(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TransitionProgress"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TransitionProgress"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TransitionProgress",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionProgress_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionProgress_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionProgress)"); return 0; } int lua_register_cocos2dx_TransitionProgress(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionProgress"); tolua_cclass(tolua_S,"TransitionProgress","cc.TransitionProgress","cc.TransitionScene",NULL); tolua_beginmodule(tolua_S,"TransitionProgress"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionProgress_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionProgress).name(); g_luaType[typeName] = "cc.TransitionProgress"; g_typeCast["TransitionProgress"] = "cc.TransitionProgress"; return 1; } int lua_cocos2dx_TransitionProgressRadialCCW_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionProgressRadialCCW",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionProgressRadialCCW* ret = cocos2d::TransitionProgressRadialCCW::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionProgressRadialCCW"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionProgressRadialCCW*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionProgressRadialCCW_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionProgressRadialCCW_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionProgressRadialCCW)"); return 0; } int lua_register_cocos2dx_TransitionProgressRadialCCW(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionProgressRadialCCW"); tolua_cclass(tolua_S,"TransitionProgressRadialCCW","cc.TransitionProgressRadialCCW","cc.TransitionProgress",NULL); tolua_beginmodule(tolua_S,"TransitionProgressRadialCCW"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionProgressRadialCCW_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionProgressRadialCCW).name(); g_luaType[typeName] = "cc.TransitionProgressRadialCCW"; g_typeCast["TransitionProgressRadialCCW"] = "cc.TransitionProgressRadialCCW"; return 1; } int lua_cocos2dx_TransitionProgressRadialCW_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionProgressRadialCW",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionProgressRadialCW* ret = cocos2d::TransitionProgressRadialCW::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionProgressRadialCW"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionProgressRadialCW*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionProgressRadialCW_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionProgressRadialCW_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionProgressRadialCW)"); return 0; } int lua_register_cocos2dx_TransitionProgressRadialCW(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionProgressRadialCW"); tolua_cclass(tolua_S,"TransitionProgressRadialCW","cc.TransitionProgressRadialCW","cc.TransitionProgress",NULL); tolua_beginmodule(tolua_S,"TransitionProgressRadialCW"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionProgressRadialCW_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionProgressRadialCW).name(); g_luaType[typeName] = "cc.TransitionProgressRadialCW"; g_typeCast["TransitionProgressRadialCW"] = "cc.TransitionProgressRadialCW"; return 1; } int lua_cocos2dx_TransitionProgressHorizontal_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionProgressHorizontal",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionProgressHorizontal* ret = cocos2d::TransitionProgressHorizontal::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionProgressHorizontal"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionProgressHorizontal*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionProgressHorizontal_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionProgressHorizontal_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionProgressHorizontal)"); return 0; } int lua_register_cocos2dx_TransitionProgressHorizontal(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionProgressHorizontal"); tolua_cclass(tolua_S,"TransitionProgressHorizontal","cc.TransitionProgressHorizontal","cc.TransitionProgress",NULL); tolua_beginmodule(tolua_S,"TransitionProgressHorizontal"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionProgressHorizontal_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionProgressHorizontal).name(); g_luaType[typeName] = "cc.TransitionProgressHorizontal"; g_typeCast["TransitionProgressHorizontal"] = "cc.TransitionProgressHorizontal"; return 1; } int lua_cocos2dx_TransitionProgressVertical_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionProgressVertical",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionProgressVertical* ret = cocos2d::TransitionProgressVertical::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionProgressVertical"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionProgressVertical*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionProgressVertical_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionProgressVertical_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionProgressVertical)"); return 0; } int lua_register_cocos2dx_TransitionProgressVertical(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionProgressVertical"); tolua_cclass(tolua_S,"TransitionProgressVertical","cc.TransitionProgressVertical","cc.TransitionProgress",NULL); tolua_beginmodule(tolua_S,"TransitionProgressVertical"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionProgressVertical_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionProgressVertical).name(); g_luaType[typeName] = "cc.TransitionProgressVertical"; g_typeCast["TransitionProgressVertical"] = "cc.TransitionProgressVertical"; return 1; } int lua_cocos2dx_TransitionProgressInOut_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionProgressInOut",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionProgressInOut* ret = cocos2d::TransitionProgressInOut::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionProgressInOut"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionProgressInOut*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionProgressInOut_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionProgressInOut_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionProgressInOut)"); return 0; } int lua_register_cocos2dx_TransitionProgressInOut(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionProgressInOut"); tolua_cclass(tolua_S,"TransitionProgressInOut","cc.TransitionProgressInOut","cc.TransitionProgress",NULL); tolua_beginmodule(tolua_S,"TransitionProgressInOut"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionProgressInOut_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionProgressInOut).name(); g_luaType[typeName] = "cc.TransitionProgressInOut"; g_typeCast["TransitionProgressInOut"] = "cc.TransitionProgressInOut"; return 1; } int lua_cocos2dx_TransitionProgressOutIn_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TransitionProgressOutIn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Scene* arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scene",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Scene*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TransitionProgressOutIn* ret = cocos2d::TransitionProgressOutIn::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TransitionProgressOutIn"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TransitionProgressOutIn*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TransitionProgressOutIn_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TransitionProgressOutIn_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TransitionProgressOutIn)"); return 0; } int lua_register_cocos2dx_TransitionProgressOutIn(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TransitionProgressOutIn"); tolua_cclass(tolua_S,"TransitionProgressOutIn","cc.TransitionProgressOutIn","cc.TransitionProgress",NULL); tolua_beginmodule(tolua_S,"TransitionProgressOutIn"); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionProgressOutIn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionProgressOutIn).name(); g_luaType[typeName] = "cc.TransitionProgressOutIn"; g_typeCast["TransitionProgressOutIn"] = "cc.TransitionProgressOutIn"; return 1; } int lua_cocos2dx_MenuItem_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItem_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItem_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItem_activate(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItem_activate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->activate(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "activate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItem_activate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItem_isEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItem_isEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItem_isEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItem_selected(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItem_selected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->selected(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "selected",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItem_selected'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItem_isSelected(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItem_isSelected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isSelected(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isSelected",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItem_isSelected'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItem_unselected(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItem_unselected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->unselected(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "unselected",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItem_unselected'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItem_rect(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItem_rect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Rect ret = cobj->rect(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rect",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItem_rect'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MenuItem_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MenuItem)"); return 0; } int lua_register_cocos2dx_MenuItem(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MenuItem"); tolua_cclass(tolua_S,"MenuItem","cc.MenuItem","cc.Node",NULL); tolua_beginmodule(tolua_S,"MenuItem"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_MenuItem_setEnabled); tolua_function(tolua_S,"activate",lua_cocos2dx_MenuItem_activate); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_MenuItem_isEnabled); tolua_function(tolua_S,"selected",lua_cocos2dx_MenuItem_selected); tolua_function(tolua_S,"isSelected",lua_cocos2dx_MenuItem_isSelected); tolua_function(tolua_S,"unselected",lua_cocos2dx_MenuItem_unselected); tolua_function(tolua_S,"rect",lua_cocos2dx_MenuItem_rect); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MenuItem).name(); g_luaType[typeName] = "cc.MenuItem"; g_typeCast["MenuItem"] = "cc.MenuItem"; return 1; } int lua_cocos2dx_MenuItemLabel_getDisabledColor(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemLabel* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemLabel",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemLabel*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemLabel_getDisabledColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color3B& ret = cobj->getDisabledColor(); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisabledColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemLabel_getDisabledColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemLabel_setString(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemLabel* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemLabel",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemLabel*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemLabel_setString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setString(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemLabel_setString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemLabel_setLabel(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemLabel* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemLabel",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemLabel*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemLabel_setLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setLabel(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLabel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemLabel_setLabel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemLabel_setDisabledColor(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemLabel* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemLabel",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemLabel*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemLabel_setDisabledColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setDisabledColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDisabledColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemLabel_setDisabledColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemLabel_getLabel(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemLabel* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemLabel",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemLabel*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemLabel_getLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getLabel(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLabel",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemLabel_getLabel'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MenuItemLabel_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MenuItemLabel)"); return 0; } int lua_register_cocos2dx_MenuItemLabel(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MenuItemLabel"); tolua_cclass(tolua_S,"MenuItemLabel","cc.MenuItemLabel","cc.MenuItem",NULL); tolua_beginmodule(tolua_S,"MenuItemLabel"); tolua_function(tolua_S,"getDisabledColor",lua_cocos2dx_MenuItemLabel_getDisabledColor); tolua_function(tolua_S,"setString",lua_cocos2dx_MenuItemLabel_setString); tolua_function(tolua_S,"setLabel",lua_cocos2dx_MenuItemLabel_setLabel); tolua_function(tolua_S,"setDisabledColor",lua_cocos2dx_MenuItemLabel_setDisabledColor); tolua_function(tolua_S,"getLabel",lua_cocos2dx_MenuItemLabel_getLabel); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MenuItemLabel).name(); g_luaType[typeName] = "cc.MenuItemLabel"; g_typeCast["MenuItemLabel"] = "cc.MenuItemLabel"; return 1; } static int lua_cocos2dx_MenuItemAtlasFont_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MenuItemAtlasFont)"); return 0; } int lua_register_cocos2dx_MenuItemAtlasFont(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MenuItemAtlasFont"); tolua_cclass(tolua_S,"MenuItemAtlasFont","cc.MenuItemAtlasFont","cc.MenuItemLabel",NULL); tolua_beginmodule(tolua_S,"MenuItemAtlasFont"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MenuItemAtlasFont).name(); g_luaType[typeName] = "cc.MenuItemAtlasFont"; g_typeCast["MenuItemAtlasFont"] = "cc.MenuItemAtlasFont"; return 1; } int lua_cocos2dx_MenuItemFont_getFontSizeObj(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemFont_getFontSizeObj'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getFontSizeObj(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFontSizeObj",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemFont_getFontSizeObj'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemFont_getFontNameObj(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemFont_getFontNameObj'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getFontNameObj(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFontNameObj",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemFont_getFontNameObj'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemFont_setFontSizeObj(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemFont_setFontSizeObj'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setFontSizeObj(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontSizeObj",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemFont_setFontSizeObj'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemFont_setFontNameObj(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemFont_setFontNameObj'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFontNameObj(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontNameObj",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemFont_setFontNameObj'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemFont_setFontName(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::MenuItemFont::setFontName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "setFontName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemFont_setFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemFont_getFontSize(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; int ret = cocos2d::MenuItemFont::getFontSize(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getFontSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemFont_getFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemFont_getFontName(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cocos2d::MenuItemFont::getFontName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getFontName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemFont_getFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemFont_setFontSize(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::MenuItemFont::setFontSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "setFontSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemFont_setFontSize'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MenuItemFont_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MenuItemFont)"); return 0; } int lua_register_cocos2dx_MenuItemFont(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MenuItemFont"); tolua_cclass(tolua_S,"MenuItemFont","cc.MenuItemFont","cc.MenuItemLabel",NULL); tolua_beginmodule(tolua_S,"MenuItemFont"); tolua_function(tolua_S,"getFontSizeObj",lua_cocos2dx_MenuItemFont_getFontSizeObj); tolua_function(tolua_S,"getFontNameObj",lua_cocos2dx_MenuItemFont_getFontNameObj); tolua_function(tolua_S,"setFontSizeObj",lua_cocos2dx_MenuItemFont_setFontSizeObj); tolua_function(tolua_S,"setFontNameObj",lua_cocos2dx_MenuItemFont_setFontNameObj); tolua_function(tolua_S,"setFontName", lua_cocos2dx_MenuItemFont_setFontName); tolua_function(tolua_S,"getFontSize", lua_cocos2dx_MenuItemFont_getFontSize); tolua_function(tolua_S,"getFontName", lua_cocos2dx_MenuItemFont_getFontName); tolua_function(tolua_S,"setFontSize", lua_cocos2dx_MenuItemFont_setFontSize); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MenuItemFont).name(); g_luaType[typeName] = "cc.MenuItemFont"; g_typeCast["MenuItemFont"] = "cc.MenuItemFont"; return 1; } int lua_cocos2dx_MenuItemSprite_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemSprite_selected(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_selected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->selected(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "selected",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_selected'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemSprite_setNormalImage(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_setNormalImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setNormalImage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setNormalImage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_setNormalImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemSprite_setDisabledImage(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_setDisabledImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setDisabledImage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDisabledImage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_setDisabledImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemSprite_setSelectedImage(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_setSelectedImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setSelectedImage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSelectedImage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_setSelectedImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemSprite_getDisabledImage(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_getDisabledImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getDisabledImage(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisabledImage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_getDisabledImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemSprite_getSelectedImage(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_getSelectedImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getSelectedImage(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSelectedImage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_getSelectedImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemSprite_getNormalImage(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_getNormalImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getNormalImage(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNormalImage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_getNormalImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemSprite_unselected(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemSprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemSprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemSprite_unselected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->unselected(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "unselected",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemSprite_unselected'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MenuItemSprite_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MenuItemSprite)"); return 0; } int lua_register_cocos2dx_MenuItemSprite(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MenuItemSprite"); tolua_cclass(tolua_S,"MenuItemSprite","cc.MenuItemSprite","cc.MenuItem",NULL); tolua_beginmodule(tolua_S,"MenuItemSprite"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_MenuItemSprite_setEnabled); tolua_function(tolua_S,"selected",lua_cocos2dx_MenuItemSprite_selected); tolua_function(tolua_S,"setNormalImage",lua_cocos2dx_MenuItemSprite_setNormalImage); tolua_function(tolua_S,"setDisabledImage",lua_cocos2dx_MenuItemSprite_setDisabledImage); tolua_function(tolua_S,"setSelectedImage",lua_cocos2dx_MenuItemSprite_setSelectedImage); tolua_function(tolua_S,"getDisabledImage",lua_cocos2dx_MenuItemSprite_getDisabledImage); tolua_function(tolua_S,"getSelectedImage",lua_cocos2dx_MenuItemSprite_getSelectedImage); tolua_function(tolua_S,"getNormalImage",lua_cocos2dx_MenuItemSprite_getNormalImage); tolua_function(tolua_S,"unselected",lua_cocos2dx_MenuItemSprite_unselected); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MenuItemSprite).name(); g_luaType[typeName] = "cc.MenuItemSprite"; g_typeCast["MenuItemSprite"] = "cc.MenuItemSprite"; return 1; } int lua_cocos2dx_MenuItemImage_setDisabledSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemImage* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemImage",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemImage*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemImage_setDisabledSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setDisabledSpriteFrame(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDisabledSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemImage_setDisabledSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemImage_setSelectedSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemImage* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemImage",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemImage*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemImage_setSelectedSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setSelectedSpriteFrame(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSelectedSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemImage_setSelectedSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemImage_setNormalSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemImage* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemImage",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemImage*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemImage_setNormalSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setNormalSpriteFrame(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setNormalSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemImage_setNormalSpriteFrame'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MenuItemImage_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MenuItemImage)"); return 0; } int lua_register_cocos2dx_MenuItemImage(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MenuItemImage"); tolua_cclass(tolua_S,"MenuItemImage","cc.MenuItemImage","cc.MenuItemSprite",NULL); tolua_beginmodule(tolua_S,"MenuItemImage"); tolua_function(tolua_S,"setDisabledSpriteFrame",lua_cocos2dx_MenuItemImage_setDisabledSpriteFrame); tolua_function(tolua_S,"setSelectedSpriteFrame",lua_cocos2dx_MenuItemImage_setSelectedSpriteFrame); tolua_function(tolua_S,"setNormalSpriteFrame",lua_cocos2dx_MenuItemImage_setNormalSpriteFrame); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MenuItemImage).name(); g_luaType[typeName] = "cc.MenuItemImage"; g_typeCast["MenuItemImage"] = "cc.MenuItemImage"; return 1; } int lua_cocos2dx_MenuItemToggle_setSubItems(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemToggle* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemToggle",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemToggle*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemToggle_setSubItems'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setSubItems(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSubItems",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemToggle_setSubItems'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemToggle_getSelectedIndex(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemToggle* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemToggle",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemToggle*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemToggle_getSelectedIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned int ret = cobj->getSelectedIndex(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSelectedIndex",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemToggle_getSelectedIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemToggle_addSubItem(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemToggle* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemToggle",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemToggle*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemToggle_addSubItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::MenuItem* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.MenuItem",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::MenuItem*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addSubItem(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSubItem",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemToggle_addSubItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemToggle_getSelectedItem(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemToggle* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemToggle",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemToggle*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemToggle_getSelectedItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::MenuItem* ret = cobj->getSelectedItem(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.MenuItem"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::MenuItem*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSelectedItem",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemToggle_getSelectedItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MenuItemToggle_setSelectedIndex(lua_State* tolua_S) { int argc = 0; cocos2d::MenuItemToggle* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MenuItemToggle",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MenuItemToggle*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MenuItemToggle_setSelectedIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSelectedIndex(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSelectedIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MenuItemToggle_setSelectedIndex'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MenuItemToggle_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MenuItemToggle)"); return 0; } int lua_register_cocos2dx_MenuItemToggle(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MenuItemToggle"); tolua_cclass(tolua_S,"MenuItemToggle","cc.MenuItemToggle","cc.MenuItem",NULL); tolua_beginmodule(tolua_S,"MenuItemToggle"); tolua_function(tolua_S,"setSubItems",lua_cocos2dx_MenuItemToggle_setSubItems); tolua_function(tolua_S,"getSelectedIndex",lua_cocos2dx_MenuItemToggle_getSelectedIndex); tolua_function(tolua_S,"addSubItem",lua_cocos2dx_MenuItemToggle_addSubItem); tolua_function(tolua_S,"getSelectedItem",lua_cocos2dx_MenuItemToggle_getSelectedItem); tolua_function(tolua_S,"setSelectedIndex",lua_cocos2dx_MenuItemToggle_setSelectedIndex); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MenuItemToggle).name(); g_luaType[typeName] = "cc.MenuItemToggle"; g_typeCast["MenuItemToggle"] = "cc.MenuItemToggle"; return 1; } int lua_cocos2dx_Menu_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Menu* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Menu*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Menu_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Menu_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Menu_alignItemsVertically(lua_State* tolua_S) { int argc = 0; cocos2d::Menu* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Menu*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Menu_alignItemsVertically'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->alignItemsVertically(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "alignItemsVertically",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Menu_alignItemsVertically'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Menu_isEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Menu* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Menu*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Menu_isEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Menu_isEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Menu_alignItemsHorizontallyWithPadding(lua_State* tolua_S) { int argc = 0; cocos2d::Menu* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Menu*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Menu_alignItemsHorizontallyWithPadding'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->alignItemsHorizontallyWithPadding(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "alignItemsHorizontallyWithPadding",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Menu_alignItemsHorizontallyWithPadding'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Menu_alignItemsVerticallyWithPadding(lua_State* tolua_S) { int argc = 0; cocos2d::Menu* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Menu*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Menu_alignItemsVerticallyWithPadding'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->alignItemsVerticallyWithPadding(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "alignItemsVerticallyWithPadding",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Menu_alignItemsVerticallyWithPadding'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Menu_alignItemsHorizontally(lua_State* tolua_S) { int argc = 0; cocos2d::Menu* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Menu*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Menu_alignItemsHorizontally'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->alignItemsHorizontally(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "alignItemsHorizontally",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Menu_alignItemsHorizontally'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Menu_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Menu)"); return 0; } int lua_register_cocos2dx_Menu(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Menu"); tolua_cclass(tolua_S,"Menu","cc.Menu","cc.Layer",NULL); tolua_beginmodule(tolua_S,"Menu"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_Menu_setEnabled); tolua_function(tolua_S,"alignItemsVertically",lua_cocos2dx_Menu_alignItemsVertically); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_Menu_isEnabled); tolua_function(tolua_S,"alignItemsHorizontallyWithPadding",lua_cocos2dx_Menu_alignItemsHorizontallyWithPadding); tolua_function(tolua_S,"alignItemsVerticallyWithPadding",lua_cocos2dx_Menu_alignItemsVerticallyWithPadding); tolua_function(tolua_S,"alignItemsHorizontally",lua_cocos2dx_Menu_alignItemsHorizontally); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Menu).name(); g_luaType[typeName] = "cc.Menu"; g_typeCast["Menu"] = "cc.Menu"; return 1; } int lua_cocos2dx_ClippingNode_isInverted(lua_State* tolua_S) { int argc = 0; cocos2d::ClippingNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ClippingNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ClippingNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_isInverted'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isInverted(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isInverted",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_isInverted'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ClippingNode_setInverted(lua_State* tolua_S) { int argc = 0; cocos2d::ClippingNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ClippingNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ClippingNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_setInverted'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setInverted(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInverted",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_setInverted'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ClippingNode_setStencil(lua_State* tolua_S) { int argc = 0; cocos2d::ClippingNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ClippingNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ClippingNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_setStencil'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setStencil(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStencil",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_setStencil'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ClippingNode_getAlphaThreshold(lua_State* tolua_S) { int argc = 0; cocos2d::ClippingNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ClippingNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ClippingNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_getAlphaThreshold'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAlphaThreshold(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAlphaThreshold",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_getAlphaThreshold'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ClippingNode_getStencil(lua_State* tolua_S) { int argc = 0; cocos2d::ClippingNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ClippingNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ClippingNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_getStencil'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getStencil(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStencil",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_getStencil'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ClippingNode_setAlphaThreshold(lua_State* tolua_S) { int argc = 0; cocos2d::ClippingNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ClippingNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ClippingNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ClippingNode_setAlphaThreshold'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAlphaThreshold(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAlphaThreshold",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_setAlphaThreshold'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ClippingNode_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ClippingNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::ClippingNode* ret = cocos2d::ClippingNode::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ClippingNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ClippingNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::ClippingNode* ret = cocos2d::ClippingNode::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ClippingNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ClippingNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ClippingNode_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ClippingNode_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ClippingNode)"); return 0; } int lua_register_cocos2dx_ClippingNode(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ClippingNode"); tolua_cclass(tolua_S,"ClippingNode","cc.ClippingNode","cc.Node",NULL); tolua_beginmodule(tolua_S,"ClippingNode"); tolua_function(tolua_S,"isInverted",lua_cocos2dx_ClippingNode_isInverted); tolua_function(tolua_S,"setInverted",lua_cocos2dx_ClippingNode_setInverted); tolua_function(tolua_S,"setStencil",lua_cocos2dx_ClippingNode_setStencil); tolua_function(tolua_S,"getAlphaThreshold",lua_cocos2dx_ClippingNode_getAlphaThreshold); tolua_function(tolua_S,"getStencil",lua_cocos2dx_ClippingNode_getStencil); tolua_function(tolua_S,"setAlphaThreshold",lua_cocos2dx_ClippingNode_setAlphaThreshold); tolua_function(tolua_S,"create", lua_cocos2dx_ClippingNode_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ClippingNode).name(); g_luaType[typeName] = "cc.ClippingNode"; g_typeCast["ClippingNode"] = "cc.ClippingNode"; return 1; } int lua_cocos2dx_MotionStreak_reset(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MotionStreak*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_reset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->reset(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_reset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MotionStreak_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MotionStreak*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_setTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTexture(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_setTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MotionStreak_getTexture(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MotionStreak*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_getTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Texture2D* ret = cobj->getTexture(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTexture",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_getTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MotionStreak_tintWithColor(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MotionStreak*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_tintWithColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->tintWithColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "tintWithColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_tintWithColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MotionStreak_setStartingPositionInitialized(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MotionStreak*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_setStartingPositionInitialized'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStartingPositionInitialized(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartingPositionInitialized",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_setStartingPositionInitialized'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MotionStreak_isStartingPositionInitialized(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MotionStreak*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_isStartingPositionInitialized'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isStartingPositionInitialized(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isStartingPositionInitialized",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_isStartingPositionInitialized'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MotionStreak_isFastMode(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MotionStreak*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_isFastMode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isFastMode(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFastMode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_isFastMode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MotionStreak_setFastMode(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::MotionStreak*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_setFastMode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFastMode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFastMode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_setFastMode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_MotionStreak_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.MotionStreak",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 5) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Color3B arg3; ok &= luaval_to_color3b(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::Texture2D* arg4; do { if (!luaval_is_usertype(tolua_S,6,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg4 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,6,0); if (nullptr == arg4){ LUA_PRECONDITION( arg4, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::MotionStreak* ret = cocos2d::MotionStreak::create(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.MotionStreak"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::MotionStreak*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 5) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Color3B arg3; ok &= luaval_to_color3b(tolua_S, 5, &arg3); if (!ok) { break; } std::string arg4; ok &= luaval_to_std_string(tolua_S, 6,&arg4); if (!ok) { break; } cocos2d::MotionStreak* ret = cocos2d::MotionStreak::create(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.MotionStreak"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::MotionStreak*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_MotionStreak_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MotionStreak)"); return 0; } int lua_register_cocos2dx_MotionStreak(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.MotionStreak"); tolua_cclass(tolua_S,"MotionStreak","cc.MotionStreak","cc.Node",NULL); tolua_beginmodule(tolua_S,"MotionStreak"); tolua_function(tolua_S,"reset",lua_cocos2dx_MotionStreak_reset); tolua_function(tolua_S,"setTexture",lua_cocos2dx_MotionStreak_setTexture); tolua_function(tolua_S,"getTexture",lua_cocos2dx_MotionStreak_getTexture); tolua_function(tolua_S,"tintWithColor",lua_cocos2dx_MotionStreak_tintWithColor); tolua_function(tolua_S,"setStartingPositionInitialized",lua_cocos2dx_MotionStreak_setStartingPositionInitialized); tolua_function(tolua_S,"isStartingPositionInitialized",lua_cocos2dx_MotionStreak_isStartingPositionInitialized); tolua_function(tolua_S,"isFastMode",lua_cocos2dx_MotionStreak_isFastMode); tolua_function(tolua_S,"setFastMode",lua_cocos2dx_MotionStreak_setFastMode); tolua_function(tolua_S,"create", lua_cocos2dx_MotionStreak_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::MotionStreak).name(); g_luaType[typeName] = "cc.MotionStreak"; g_typeCast["MotionStreak"] = "cc.MotionStreak"; return 1; } int lua_cocos2dx_ProgressTimer_isReverseDirection(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_isReverseDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isReverseDirection(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isReverseDirection",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_isReverseDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_setBarChangeRate(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_setBarChangeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setBarChangeRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBarChangeRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_setBarChangeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_getPercentage(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_getPercentage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getPercentage(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPercentage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_getPercentage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_setSprite(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_setSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_setSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_getType(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_getType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_getType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_getSprite(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_getSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_getSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_setMidpoint(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_setMidpoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setMidpoint(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMidpoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_setMidpoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_getBarChangeRate(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_getBarChangeRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getBarChangeRate(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBarChangeRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_getBarChangeRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_setReverseDirection(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_setReverseDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if (!ok) { break; } cobj->setReverseDirection(arg0); return 0; } }while(0); ok = true; do{ if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if (!ok) { break; } cobj->setReverseProgress(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setReverseProgress",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_setReverseDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_getMidpoint(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_getMidpoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getMidpoint(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMidpoint",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_getMidpoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_setPercentage(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_setPercentage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPercentage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPercentage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_setPercentage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_setType(lua_State* tolua_S) { int argc = 0; cocos2d::ProgressTimer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ProgressTimer_setType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ProgressTimer::Type arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setType(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_setType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ProgressTimer_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ProgressTimer",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ProgressTimer* ret = cocos2d::ProgressTimer::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ProgressTimer"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ProgressTimer*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ProgressTimer_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ProgressTimer_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ProgressTimer)"); return 0; } int lua_register_cocos2dx_ProgressTimer(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ProgressTimer"); tolua_cclass(tolua_S,"ProgressTimer","cc.ProgressTimer","cc.Node",NULL); tolua_beginmodule(tolua_S,"ProgressTimer"); tolua_function(tolua_S,"isReverseDirection",lua_cocos2dx_ProgressTimer_isReverseDirection); tolua_function(tolua_S,"setBarChangeRate",lua_cocos2dx_ProgressTimer_setBarChangeRate); tolua_function(tolua_S,"getPercentage",lua_cocos2dx_ProgressTimer_getPercentage); tolua_function(tolua_S,"setSprite",lua_cocos2dx_ProgressTimer_setSprite); tolua_function(tolua_S,"getType",lua_cocos2dx_ProgressTimer_getType); tolua_function(tolua_S,"getSprite",lua_cocos2dx_ProgressTimer_getSprite); tolua_function(tolua_S,"setMidpoint",lua_cocos2dx_ProgressTimer_setMidpoint); tolua_function(tolua_S,"getBarChangeRate",lua_cocos2dx_ProgressTimer_getBarChangeRate); tolua_function(tolua_S,"setReverseDirection",lua_cocos2dx_ProgressTimer_setReverseDirection); tolua_function(tolua_S,"getMidpoint",lua_cocos2dx_ProgressTimer_getMidpoint); tolua_function(tolua_S,"setPercentage",lua_cocos2dx_ProgressTimer_setPercentage); tolua_function(tolua_S,"setType",lua_cocos2dx_ProgressTimer_setType); tolua_function(tolua_S,"create", lua_cocos2dx_ProgressTimer_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ProgressTimer).name(); g_luaType[typeName] = "cc.ProgressTimer"; g_typeCast["ProgressTimer"] = "cc.ProgressTimer"; return 1; } int lua_cocos2dx_Image_hasPremultipliedAlpha(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_hasPremultipliedAlpha'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->hasPremultipliedAlpha(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hasPremultipliedAlpha",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_hasPremultipliedAlpha'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getDataLen(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getDataLen'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getDataLen(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDataLen",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getDataLen'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_isCompressed(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_isCompressed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isCompressed(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isCompressed",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_isCompressed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getBitPerPixel(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getBitPerPixel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getBitPerPixel(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBitPerPixel",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getBitPerPixel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_hasAlpha(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_hasAlpha'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->hasAlpha(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hasAlpha",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_hasAlpha'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getHeight(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getHeight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getHeight(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getHeight",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getHeight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_initWithImageFile(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_initWithImageFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->initWithImageFile(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithImageFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_initWithImageFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getWidth(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getWidth'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getWidth(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWidth",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getWidth'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_isPremultipliedAlpha(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_isPremultipliedAlpha'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isPremultipliedAlpha(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isPremultipliedAlpha",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_isPremultipliedAlpha'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getFileType(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getFileType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getFileType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFileType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getFileType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_saveToFile(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_saveToFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->saveToFile(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } if (argc == 2) { std::string arg0; bool arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; bool ret = cobj->saveToFile(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "saveToFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_saveToFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getNumberOfMipmaps(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getNumberOfMipmaps'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getNumberOfMipmaps(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNumberOfMipmaps",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getNumberOfMipmaps'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getRenderFormat(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getRenderFormat'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getRenderFormat(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRenderFormat",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getRenderFormat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getData(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned char* ret = cobj->getData(); #pragma warning NO CONVERSION FROM NATIVE FOR unsigned char*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_getMipmaps(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getMipmaps'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::_MipmapInfo* ret = cobj->getMipmaps(); #pragma warning NO CONVERSION FROM NATIVE FOR _MipmapInfo*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMipmaps",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getMipmaps'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Image_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Image* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Image(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Image"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Image"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Image",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Image_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Image)"); return 0; } int lua_register_cocos2dx_Image(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Image"); tolua_cclass(tolua_S,"Image","cc.Image","cc.Object",NULL); tolua_beginmodule(tolua_S,"Image"); tolua_function(tolua_S,"hasPremultipliedAlpha",lua_cocos2dx_Image_hasPremultipliedAlpha); tolua_function(tolua_S,"getDataLen",lua_cocos2dx_Image_getDataLen); tolua_function(tolua_S,"isCompressed",lua_cocos2dx_Image_isCompressed); tolua_function(tolua_S,"getBitPerPixel",lua_cocos2dx_Image_getBitPerPixel); tolua_function(tolua_S,"hasAlpha",lua_cocos2dx_Image_hasAlpha); tolua_function(tolua_S,"getHeight",lua_cocos2dx_Image_getHeight); tolua_function(tolua_S,"initWithImageFile",lua_cocos2dx_Image_initWithImageFile); tolua_function(tolua_S,"getWidth",lua_cocos2dx_Image_getWidth); tolua_function(tolua_S,"isPremultipliedAlpha",lua_cocos2dx_Image_isPremultipliedAlpha); tolua_function(tolua_S,"getFileType",lua_cocos2dx_Image_getFileType); tolua_function(tolua_S,"saveToFile",lua_cocos2dx_Image_saveToFile); tolua_function(tolua_S,"getNumberOfMipmaps",lua_cocos2dx_Image_getNumberOfMipmaps); tolua_function(tolua_S,"getRenderFormat",lua_cocos2dx_Image_getRenderFormat); tolua_function(tolua_S,"getData",lua_cocos2dx_Image_getData); tolua_function(tolua_S,"getMipmaps",lua_cocos2dx_Image_getMipmaps); tolua_function(tolua_S,"new",lua_cocos2dx_Image_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Image).name(); g_luaType[typeName] = "cc.Image"; g_typeCast["Image"] = "cc.Image"; return 1; } int lua_cocos2dx_RenderTexture_clearStencil(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_clearStencil'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->clearStencil(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clearStencil",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_clearStencil'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_getClearDepth(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_getClearDepth'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getClearDepth(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getClearDepth",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_getClearDepth'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_getClearStencil(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_getClearStencil'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getClearStencil(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getClearStencil",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_getClearStencil'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_end(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_end'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->end(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "end",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_end'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_setClearStencil(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_setClearStencil'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setClearStencil(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setClearStencil",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_setClearStencil'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_setSprite(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_setSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_setSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_getSprite(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_getSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_getSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_isAutoDraw(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_isAutoDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isAutoDraw(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isAutoDraw",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_isAutoDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_setClearFlags(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_setClearFlags'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setClearFlags(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setClearFlags",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_setClearFlags'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_begin(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_begin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->begin(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "begin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_begin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_saveToFile(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_saveToFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Image::Format arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } bool ret = cobj->saveToFile(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } bool ret = cobj->saveToFile(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "saveToFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_saveToFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_setAutoDraw(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_setAutoDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAutoDraw(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAutoDraw",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_setAutoDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_setClearColor(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_setClearColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color4F arg0; ok &=luaval_to_color4f(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setClearColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setClearColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_setClearColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_endToLua(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_endToLua'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->endToLua(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "endToLua",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_endToLua'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_beginWithClear(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_beginWithClear'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 5) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } double arg3; ok &= luaval_to_number(tolua_S, 5,&arg3); if (!ok) { break; } double arg4; ok &= luaval_to_number(tolua_S, 6,&arg4); if (!ok) { break; } cobj->beginWithClear(arg0, arg1, arg2, arg3, arg4); return 0; } }while(0); ok = true; do{ if (argc == 4) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } double arg3; ok &= luaval_to_number(tolua_S, 5,&arg3); if (!ok) { break; } cobj->beginWithClear(arg0, arg1, arg2, arg3); return 0; } }while(0); ok = true; do{ if (argc == 6) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } double arg3; ok &= luaval_to_number(tolua_S, 5,&arg3); if (!ok) { break; } double arg4; ok &= luaval_to_number(tolua_S, 6,&arg4); if (!ok) { break; } int arg5; ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5); if (!ok) { break; } cobj->beginWithClear(arg0, arg1, arg2, arg3, arg4, arg5); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "beginWithClear",argc, 6); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_beginWithClear'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_clearDepth(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_clearDepth'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->clearDepth(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clearDepth",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_clearDepth'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_getClearColor(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_getClearColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color4F& ret = cobj->getClearColor(); color4f_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getClearColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_getClearColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_clear(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_clear'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { double arg0; double arg1; double arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cobj->clear(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clear",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_clear'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_getClearFlags(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_getClearFlags'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned int ret = cobj->getClearFlags(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getClearFlags",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_getClearFlags'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_newImage(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_newImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Image* ret = cobj->newImage(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Image"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Image*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Image* ret = cobj->newImage(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Image"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Image*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "newImage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_newImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_setClearDepth(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_setClearDepth'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setClearDepth(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setClearDepth",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_setClearDepth'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_initWithWidthAndHeight(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::RenderTexture*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_RenderTexture_initWithWidthAndHeight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 4) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cocos2d::Texture2D::PixelFormat arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } unsigned int arg3; ok &= luaval_to_uint32(tolua_S, 5,&arg3); if (!ok) { break; } bool ret = cobj->initWithWidthAndHeight(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 3) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cocos2d::Texture2D::PixelFormat arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } bool ret = cobj->initWithWidthAndHeight(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithWidthAndHeight",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_initWithWidthAndHeight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.RenderTexture",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 3) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cocos2d::Texture2D::PixelFormat arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RenderTexture"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RenderTexture*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 4) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cocos2d::Texture2D::PixelFormat arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } unsigned int arg3; ok &= luaval_to_uint32(tolua_S, 5,&arg3); if (!ok) { break; } cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RenderTexture"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RenderTexture*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.RenderTexture"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::RenderTexture*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_RenderTexture_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::RenderTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::RenderTexture(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.RenderTexture"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.RenderTexture"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "RenderTexture",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_RenderTexture_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_RenderTexture_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (RenderTexture)"); return 0; } int lua_register_cocos2dx_RenderTexture(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.RenderTexture"); tolua_cclass(tolua_S,"RenderTexture","cc.RenderTexture","cc.Node",NULL); tolua_beginmodule(tolua_S,"RenderTexture"); tolua_function(tolua_S,"clearStencil",lua_cocos2dx_RenderTexture_clearStencil); tolua_function(tolua_S,"getClearDepth",lua_cocos2dx_RenderTexture_getClearDepth); tolua_function(tolua_S,"getClearStencil",lua_cocos2dx_RenderTexture_getClearStencil); tolua_function(tolua_S,"end",lua_cocos2dx_RenderTexture_end); tolua_function(tolua_S,"setClearStencil",lua_cocos2dx_RenderTexture_setClearStencil); tolua_function(tolua_S,"setSprite",lua_cocos2dx_RenderTexture_setSprite); tolua_function(tolua_S,"getSprite",lua_cocos2dx_RenderTexture_getSprite); tolua_function(tolua_S,"isAutoDraw",lua_cocos2dx_RenderTexture_isAutoDraw); tolua_function(tolua_S,"setClearFlags",lua_cocos2dx_RenderTexture_setClearFlags); tolua_function(tolua_S,"begin",lua_cocos2dx_RenderTexture_begin); tolua_function(tolua_S,"saveToFile",lua_cocos2dx_RenderTexture_saveToFile); tolua_function(tolua_S,"setAutoDraw",lua_cocos2dx_RenderTexture_setAutoDraw); tolua_function(tolua_S,"setClearColor",lua_cocos2dx_RenderTexture_setClearColor); tolua_function(tolua_S,"endToLua",lua_cocos2dx_RenderTexture_endToLua); tolua_function(tolua_S,"beginWithClear",lua_cocos2dx_RenderTexture_beginWithClear); tolua_function(tolua_S,"clearDepth",lua_cocos2dx_RenderTexture_clearDepth); tolua_function(tolua_S,"getClearColor",lua_cocos2dx_RenderTexture_getClearColor); tolua_function(tolua_S,"clear",lua_cocos2dx_RenderTexture_clear); tolua_function(tolua_S,"getClearFlags",lua_cocos2dx_RenderTexture_getClearFlags); tolua_function(tolua_S,"newImage",lua_cocos2dx_RenderTexture_newImage); tolua_function(tolua_S,"setClearDepth",lua_cocos2dx_RenderTexture_setClearDepth); tolua_function(tolua_S,"initWithWidthAndHeight",lua_cocos2dx_RenderTexture_initWithWidthAndHeight); tolua_function(tolua_S,"new",lua_cocos2dx_RenderTexture_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_RenderTexture_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::RenderTexture).name(); g_luaType[typeName] = "cc.RenderTexture"; g_typeCast["RenderTexture"] = "cc.RenderTexture"; return 1; } int lua_cocos2dx_NodeGrid_setTarget(lua_State* tolua_S) { int argc = 0; cocos2d::NodeGrid* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.NodeGrid",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::NodeGrid*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_NodeGrid_setTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_NodeGrid_setTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_NodeGrid_getGrid(lua_State* tolua_S) { int argc = 0; cocos2d::NodeGrid* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.NodeGrid",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::NodeGrid*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_NodeGrid_getGrid'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::GridBase* ret = cobj->getGrid(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GridBase"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GridBase*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::GridBase* ret = cobj->getGrid(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GridBase"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GridBase*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGrid",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_NodeGrid_getGrid'.",&tolua_err); #endif return 0; } int lua_cocos2dx_NodeGrid_setGrid(lua_State* tolua_S) { int argc = 0; cocos2d::NodeGrid* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.NodeGrid",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::NodeGrid*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_NodeGrid_setGrid'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::GridBase* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.GridBase",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::GridBase*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setGrid(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGrid",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_NodeGrid_setGrid'.",&tolua_err); #endif return 0; } int lua_cocos2dx_NodeGrid_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.NodeGrid",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::NodeGrid* ret = cocos2d::NodeGrid::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.NodeGrid"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::NodeGrid*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_NodeGrid_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_NodeGrid_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (NodeGrid)"); return 0; } int lua_register_cocos2dx_NodeGrid(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.NodeGrid"); tolua_cclass(tolua_S,"NodeGrid","cc.NodeGrid","cc.Node",NULL); tolua_beginmodule(tolua_S,"NodeGrid"); tolua_function(tolua_S,"setTarget",lua_cocos2dx_NodeGrid_setTarget); tolua_function(tolua_S,"getGrid",lua_cocos2dx_NodeGrid_getGrid); tolua_function(tolua_S,"setGrid",lua_cocos2dx_NodeGrid_setGrid); tolua_function(tolua_S,"create", lua_cocos2dx_NodeGrid_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::NodeGrid).name(); g_luaType[typeName] = "cc.NodeGrid"; g_typeCast["NodeGrid"] = "cc.NodeGrid"; return 1; } int lua_cocos2dx_ParticleBatchNode_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_setTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTexture(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_setTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_disableParticle(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_disableParticle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->disableParticle(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "disableParticle",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_disableParticle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_getTexture(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_getTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Texture2D* ret = cobj->getTexture(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTexture",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_getTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_setTextureAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_setTextureAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextureAtlas* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.TextureAtlas",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::TextureAtlas*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTextureAtlas(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextureAtlas",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_setTextureAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeAllChildrenWithCleanup(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllChildrenWithCleanup",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_getTextureAtlas(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_getTextureAtlas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TextureAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TextureAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureAtlas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_getTextureAtlas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_insertChild(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_insertChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::ParticleSystem* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.ParticleSystem",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->insertChild(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "insertChild",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_insertChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_visit(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_visit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->visit(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "visit",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_visit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_removeChildAtIndex(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleBatchNode_removeChildAtIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; bool arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->removeChildAtIndex(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeChildAtIndex",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_removeChildAtIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { std::string arg0; int arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleBatchNode_createWithTexture(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleBatchNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::createWithTexture(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Texture2D* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::createWithTexture(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleBatchNode_createWithTexture'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleBatchNode_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleBatchNode)"); return 0; } int lua_register_cocos2dx_ParticleBatchNode(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleBatchNode"); tolua_cclass(tolua_S,"ParticleBatchNode","cc.ParticleBatchNode","cc.Node",NULL); tolua_beginmodule(tolua_S,"ParticleBatchNode"); tolua_function(tolua_S,"setTexture",lua_cocos2dx_ParticleBatchNode_setTexture); tolua_function(tolua_S,"disableParticle",lua_cocos2dx_ParticleBatchNode_disableParticle); tolua_function(tolua_S,"getTexture",lua_cocos2dx_ParticleBatchNode_getTexture); tolua_function(tolua_S,"setTextureAtlas",lua_cocos2dx_ParticleBatchNode_setTextureAtlas); tolua_function(tolua_S,"removeAllChildrenWithCleanup",lua_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup); tolua_function(tolua_S,"getTextureAtlas",lua_cocos2dx_ParticleBatchNode_getTextureAtlas); tolua_function(tolua_S,"insertChild",lua_cocos2dx_ParticleBatchNode_insertChild); tolua_function(tolua_S,"visit",lua_cocos2dx_ParticleBatchNode_visit); tolua_function(tolua_S,"removeChildAtIndex",lua_cocos2dx_ParticleBatchNode_removeChildAtIndex); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleBatchNode_create); tolua_function(tolua_S,"createWithTexture", lua_cocos2dx_ParticleBatchNode_createWithTexture); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleBatchNode).name(); g_luaType[typeName] = "cc.ParticleBatchNode"; g_typeCast["ParticleBatchNode"] = "cc.ParticleBatchNode"; return 1; } int lua_cocos2dx_ParticleSystem_getStartSizeVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getStartSizeVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getStartSizeVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartSizeVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getStartSizeVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getTexture(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Texture2D* ret = cobj->getTexture(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTexture",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_isFull(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_isFull'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isFull(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFull",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_isFull'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getBatchNode(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getBatchNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleBatchNode* ret = cobj->getBatchNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleBatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleBatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBatchNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getBatchNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getStartColor(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getStartColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color4F& ret = cobj->getStartColor(); color4f_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getStartColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getPositionType(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getPositionType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getPositionType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPositionType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getPositionType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setPosVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setPosVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPosVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPosVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setPosVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEndSpin(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEndSpin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEndSpin(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndSpin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEndSpin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setRotatePerSecondVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setRotatePerSecondVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotatePerSecondVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotatePerSecondVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setRotatePerSecondVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getStartSpinVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getStartSpinVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getStartSpinVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartSpinVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getStartSpinVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getRadialAccelVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getRadialAccelVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRadialAccelVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRadialAccelVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getRadialAccelVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEndSizeVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEndSizeVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEndSizeVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndSizeVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEndSizeVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setRotation(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setRotation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setRotation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setTangentialAccel(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setTangentialAccel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTangentialAccel(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTangentialAccel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setTangentialAccel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setScaleY(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setScaleY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScaleY(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScaleY",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setScaleY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setScaleX(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setScaleX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScaleX(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScaleX",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setScaleX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getRadialAccel(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getRadialAccel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRadialAccel(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRadialAccel",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getRadialAccel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setStartRadius(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setStartRadius'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStartRadius(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartRadius",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setStartRadius'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setRotatePerSecond(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setRotatePerSecond'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotatePerSecond(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotatePerSecond",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setRotatePerSecond'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEndSize(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEndSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEndSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEndSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getGravity(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getGravity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getGravity(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGravity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getGravity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getTangentialAccel(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getTangentialAccel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getTangentialAccel(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTangentialAccel",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getTangentialAccel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEndRadius(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEndRadius'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEndRadius(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndRadius",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEndRadius'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getSpeed(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getSpeed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSpeed(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSpeed",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getSpeed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getAngle(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getAngle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAngle(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAngle",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getAngle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEndColor(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEndColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color4F arg0; ok &=luaval_to_color4f(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setEndColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEndColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setStartSpin(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setStartSpin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStartSpin(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartSpin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setStartSpin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setDuration(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDuration(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDuration",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTexture(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getPosVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getPosVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getPosVar(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPosVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getPosVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_updateWithNoTime(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_updateWithNoTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateWithNoTime(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateWithNoTime",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_updateWithNoTime'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_isBlendAdditive(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_isBlendAdditive'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isBlendAdditive(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isBlendAdditive",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_isBlendAdditive'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getSpeedVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getSpeedVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSpeedVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSpeedVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getSpeedVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setPositionType(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setPositionType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ParticleSystem::PositionType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setPositionType(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPositionType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setPositionType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_stopSystem(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_stopSystem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stopSystem(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopSystem",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_stopSystem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getSourcePosition(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getSourcePosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getSourcePosition(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSourcePosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getSourcePosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setLifeVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setLifeVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLifeVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLifeVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setLifeVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setTotalParticles(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setTotalParticles'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setTotalParticles(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setTotalParticles'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEndColorVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEndColorVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color4F arg0; ok &=luaval_to_color4f(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setEndColorVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndColorVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEndColorVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_updateQuadWithParticle(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_updateQuadWithParticle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::sParticle* arg0; cocos2d::Point arg1; #pragma warning NO CONVERSION TO NATIVE FOR sParticle*; ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cobj->updateQuadWithParticle(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateQuadWithParticle",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_updateQuadWithParticle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getAtlasIndex(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getAtlasIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getAtlasIndex(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAtlasIndex",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getAtlasIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getStartSize(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getStartSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getStartSize(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getStartSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setStartSpinVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setStartSpinVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStartSpinVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartSpinVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setStartSpinVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_resetSystem(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_resetSystem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resetSystem(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resetSystem",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_resetSystem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setAtlasIndex(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setAtlasIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setAtlasIndex(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAtlasIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setAtlasIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setTangentialAccelVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setTangentialAccelVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTangentialAccelVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTangentialAccelVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setTangentialAccelVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEndRadiusVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEndRadiusVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEndRadiusVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndRadiusVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEndRadiusVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEndRadius(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEndRadius'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEndRadius(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndRadius",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEndRadius'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_isOpacityModifyRGB(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_isOpacityModifyRGB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isOpacityModifyRGB(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isOpacityModifyRGB",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_isOpacityModifyRGB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_isActive(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_isActive'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isActive(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isActive",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_isActive'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setRadialAccelVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setRadialAccelVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRadialAccelVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRadialAccelVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setRadialAccelVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setStartSize(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setStartSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStartSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setStartSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setSpeed(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setSpeed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSpeed(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSpeed",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setSpeed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getStartSpin(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getStartSpin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getStartSpin(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartSpin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getStartSpin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getRotatePerSecond(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getRotatePerSecond'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRotatePerSecond(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRotatePerSecond",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getRotatePerSecond'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_initParticle(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_initParticle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::sParticle* arg0; #pragma warning NO CONVERSION TO NATIVE FOR sParticle*; if(!ok) return 0; cobj->initParticle(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initParticle",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_initParticle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEmitterMode(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEmitterMode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ParticleSystem::Mode arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setEmitterMode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEmitterMode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEmitterMode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getDuration(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDuration(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDuration",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setSourcePosition(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setSourcePosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setSourcePosition(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSourcePosition",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setSourcePosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEndSpinVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEndSpinVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEndSpinVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndSpinVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEndSpinVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setBlendAdditive(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setBlendAdditive'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBlendAdditive(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBlendAdditive",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setBlendAdditive'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setLife(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setLife'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLife(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLife",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setLife'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setAngleVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setAngleVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAngleVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAngleVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setAngleVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setRotationIsDir(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setRotationIsDir'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotationIsDir(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotationIsDir",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setRotationIsDir'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEndSizeVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEndSizeVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEndSizeVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndSizeVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEndSizeVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setAngle(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setAngle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAngle(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAngle",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setAngle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setBatchNode(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setBatchNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ParticleBatchNode* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ParticleBatchNode",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ParticleBatchNode*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBatchNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBatchNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setBatchNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getTangentialAccelVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getTangentialAccelVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getTangentialAccelVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTangentialAccelVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getTangentialAccelVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEmitterMode(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEmitterMode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getEmitterMode(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEmitterMode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEmitterMode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEndSpinVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEndSpinVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEndSpinVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndSpinVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEndSpinVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getAngleVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getAngleVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAngleVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAngleVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getAngleVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setStartColor(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setStartColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color4F arg0; ok &=luaval_to_color4f(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setStartColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setStartColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getRotatePerSecondVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getRotatePerSecondVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRotatePerSecondVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRotatePerSecondVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getRotatePerSecondVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEndSize(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEndSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEndSize(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEndSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getLife(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getLife'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getLife(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLife",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getLife'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setSpeedVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setSpeedVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSpeedVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSpeedVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setSpeedVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setAutoRemoveOnFinish(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setAutoRemoveOnFinish'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAutoRemoveOnFinish(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAutoRemoveOnFinish",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setAutoRemoveOnFinish'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setGravity(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setGravity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setGravity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGravity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setGravity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_postStep(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_postStep'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->postStep(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "postStep",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_postStep'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEmissionRate(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEmissionRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEmissionRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEmissionRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEmissionRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEndColorVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEndColorVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color4F& ret = cobj->getEndColorVar(); color4f_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndColorVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEndColorVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getRotationIsDir(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getRotationIsDir'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getRotationIsDir(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRotationIsDir",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getRotationIsDir'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setScale(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScale(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScale",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEmissionRate(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEmissionRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEmissionRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEmissionRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEmissionRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEndColor(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEndColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color4F& ret = cobj->getEndColor(); color4f_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEndColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getLifeVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getLifeVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getLifeVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLifeVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getLifeVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setStartSizeVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setStartSizeVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStartSizeVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartSizeVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setStartSizeVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setOpacityModifyRGB(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setOpacityModifyRGB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setOpacityModifyRGB(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOpacityModifyRGB",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setOpacityModifyRGB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_addParticle(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_addParticle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->addParticle(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addParticle",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_addParticle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getStartRadius(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getStartRadius'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getStartRadius(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartRadius",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getStartRadius'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getParticleCount(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getParticleCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned int ret = cobj->getParticleCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParticleCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getParticleCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getStartRadiusVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getStartRadiusVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getStartRadiusVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartRadiusVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getStartRadiusVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setStartColorVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setStartColorVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color4F arg0; ok &=luaval_to_color4f(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setStartColorVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartColorVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setStartColorVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setEndSpin(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setEndSpin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEndSpin(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEndSpin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setEndSpin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setRadialAccel(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setRadialAccel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRadialAccel(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRadialAccel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setRadialAccel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_isAutoRemoveOnFinish(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_isAutoRemoveOnFinish'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isAutoRemoveOnFinish(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isAutoRemoveOnFinish",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_isAutoRemoveOnFinish'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getTotalParticles(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getTotalParticles'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getTotalParticles(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTotalParticles",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getTotalParticles'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_setStartRadiusVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_setStartRadiusVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStartRadiusVar(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStartRadiusVar",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_setStartRadiusVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getEndRadiusVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getEndRadiusVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEndRadiusVar(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEndRadiusVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getEndRadiusVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_getStartColorVar(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystem* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystem*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystem_getStartColorVar'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color4F& ret = cobj->getStartColorVar(); color4f_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartColorVar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_getStartColorVar'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::ParticleSystem* ret = cocos2d::ParticleSystem::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSystem"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSystem*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystem_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSystem",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleSystem* ret = cocos2d::ParticleSystem::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSystem"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSystem*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystem_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleSystem_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleSystem)"); return 0; } int lua_register_cocos2dx_ParticleSystem(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleSystem"); tolua_cclass(tolua_S,"ParticleSystem","cc.ParticleSystem","cc.Node",NULL); tolua_beginmodule(tolua_S,"ParticleSystem"); tolua_function(tolua_S,"getStartSizeVar",lua_cocos2dx_ParticleSystem_getStartSizeVar); tolua_function(tolua_S,"getTexture",lua_cocos2dx_ParticleSystem_getTexture); tolua_function(tolua_S,"isFull",lua_cocos2dx_ParticleSystem_isFull); tolua_function(tolua_S,"getBatchNode",lua_cocos2dx_ParticleSystem_getBatchNode); tolua_function(tolua_S,"getStartColor",lua_cocos2dx_ParticleSystem_getStartColor); tolua_function(tolua_S,"getPositionType",lua_cocos2dx_ParticleSystem_getPositionType); tolua_function(tolua_S,"setPosVar",lua_cocos2dx_ParticleSystem_setPosVar); tolua_function(tolua_S,"getEndSpin",lua_cocos2dx_ParticleSystem_getEndSpin); tolua_function(tolua_S,"setRotatePerSecondVar",lua_cocos2dx_ParticleSystem_setRotatePerSecondVar); tolua_function(tolua_S,"getStartSpinVar",lua_cocos2dx_ParticleSystem_getStartSpinVar); tolua_function(tolua_S,"getRadialAccelVar",lua_cocos2dx_ParticleSystem_getRadialAccelVar); tolua_function(tolua_S,"getEndSizeVar",lua_cocos2dx_ParticleSystem_getEndSizeVar); tolua_function(tolua_S,"setRotation",lua_cocos2dx_ParticleSystem_setRotation); tolua_function(tolua_S,"setTangentialAccel",lua_cocos2dx_ParticleSystem_setTangentialAccel); tolua_function(tolua_S,"setScaleY",lua_cocos2dx_ParticleSystem_setScaleY); tolua_function(tolua_S,"setScaleX",lua_cocos2dx_ParticleSystem_setScaleX); tolua_function(tolua_S,"getRadialAccel",lua_cocos2dx_ParticleSystem_getRadialAccel); tolua_function(tolua_S,"setStartRadius",lua_cocos2dx_ParticleSystem_setStartRadius); tolua_function(tolua_S,"setRotatePerSecond",lua_cocos2dx_ParticleSystem_setRotatePerSecond); tolua_function(tolua_S,"setEndSize",lua_cocos2dx_ParticleSystem_setEndSize); tolua_function(tolua_S,"getGravity",lua_cocos2dx_ParticleSystem_getGravity); tolua_function(tolua_S,"getTangentialAccel",lua_cocos2dx_ParticleSystem_getTangentialAccel); tolua_function(tolua_S,"setEndRadius",lua_cocos2dx_ParticleSystem_setEndRadius); tolua_function(tolua_S,"getSpeed",lua_cocos2dx_ParticleSystem_getSpeed); tolua_function(tolua_S,"getAngle",lua_cocos2dx_ParticleSystem_getAngle); tolua_function(tolua_S,"setEndColor",lua_cocos2dx_ParticleSystem_setEndColor); tolua_function(tolua_S,"setStartSpin",lua_cocos2dx_ParticleSystem_setStartSpin); tolua_function(tolua_S,"setDuration",lua_cocos2dx_ParticleSystem_setDuration); tolua_function(tolua_S,"setTexture",lua_cocos2dx_ParticleSystem_setTexture); tolua_function(tolua_S,"getPosVar",lua_cocos2dx_ParticleSystem_getPosVar); tolua_function(tolua_S,"updateWithNoTime",lua_cocos2dx_ParticleSystem_updateWithNoTime); tolua_function(tolua_S,"isBlendAdditive",lua_cocos2dx_ParticleSystem_isBlendAdditive); tolua_function(tolua_S,"getSpeedVar",lua_cocos2dx_ParticleSystem_getSpeedVar); tolua_function(tolua_S,"setPositionType",lua_cocos2dx_ParticleSystem_setPositionType); tolua_function(tolua_S,"stopSystem",lua_cocos2dx_ParticleSystem_stopSystem); tolua_function(tolua_S,"getSourcePosition",lua_cocos2dx_ParticleSystem_getSourcePosition); tolua_function(tolua_S,"setLifeVar",lua_cocos2dx_ParticleSystem_setLifeVar); tolua_function(tolua_S,"setTotalParticles",lua_cocos2dx_ParticleSystem_setTotalParticles); tolua_function(tolua_S,"setEndColorVar",lua_cocos2dx_ParticleSystem_setEndColorVar); tolua_function(tolua_S,"updateQuadWithParticle",lua_cocos2dx_ParticleSystem_updateQuadWithParticle); tolua_function(tolua_S,"getAtlasIndex",lua_cocos2dx_ParticleSystem_getAtlasIndex); tolua_function(tolua_S,"getStartSize",lua_cocos2dx_ParticleSystem_getStartSize); tolua_function(tolua_S,"setStartSpinVar",lua_cocos2dx_ParticleSystem_setStartSpinVar); tolua_function(tolua_S,"resetSystem",lua_cocos2dx_ParticleSystem_resetSystem); tolua_function(tolua_S,"setAtlasIndex",lua_cocos2dx_ParticleSystem_setAtlasIndex); tolua_function(tolua_S,"setTangentialAccelVar",lua_cocos2dx_ParticleSystem_setTangentialAccelVar); tolua_function(tolua_S,"setEndRadiusVar",lua_cocos2dx_ParticleSystem_setEndRadiusVar); tolua_function(tolua_S,"getEndRadius",lua_cocos2dx_ParticleSystem_getEndRadius); tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_ParticleSystem_isOpacityModifyRGB); tolua_function(tolua_S,"isActive",lua_cocos2dx_ParticleSystem_isActive); tolua_function(tolua_S,"setRadialAccelVar",lua_cocos2dx_ParticleSystem_setRadialAccelVar); tolua_function(tolua_S,"setStartSize",lua_cocos2dx_ParticleSystem_setStartSize); tolua_function(tolua_S,"setSpeed",lua_cocos2dx_ParticleSystem_setSpeed); tolua_function(tolua_S,"getStartSpin",lua_cocos2dx_ParticleSystem_getStartSpin); tolua_function(tolua_S,"getRotatePerSecond",lua_cocos2dx_ParticleSystem_getRotatePerSecond); tolua_function(tolua_S,"initParticle",lua_cocos2dx_ParticleSystem_initParticle); tolua_function(tolua_S,"setEmitterMode",lua_cocos2dx_ParticleSystem_setEmitterMode); tolua_function(tolua_S,"getDuration",lua_cocos2dx_ParticleSystem_getDuration); tolua_function(tolua_S,"setSourcePosition",lua_cocos2dx_ParticleSystem_setSourcePosition); tolua_function(tolua_S,"getEndSpinVar",lua_cocos2dx_ParticleSystem_getEndSpinVar); tolua_function(tolua_S,"setBlendAdditive",lua_cocos2dx_ParticleSystem_setBlendAdditive); tolua_function(tolua_S,"setLife",lua_cocos2dx_ParticleSystem_setLife); tolua_function(tolua_S,"setAngleVar",lua_cocos2dx_ParticleSystem_setAngleVar); tolua_function(tolua_S,"setRotationIsDir",lua_cocos2dx_ParticleSystem_setRotationIsDir); tolua_function(tolua_S,"setEndSizeVar",lua_cocos2dx_ParticleSystem_setEndSizeVar); tolua_function(tolua_S,"setAngle",lua_cocos2dx_ParticleSystem_setAngle); tolua_function(tolua_S,"setBatchNode",lua_cocos2dx_ParticleSystem_setBatchNode); tolua_function(tolua_S,"getTangentialAccelVar",lua_cocos2dx_ParticleSystem_getTangentialAccelVar); tolua_function(tolua_S,"getEmitterMode",lua_cocos2dx_ParticleSystem_getEmitterMode); tolua_function(tolua_S,"setEndSpinVar",lua_cocos2dx_ParticleSystem_setEndSpinVar); tolua_function(tolua_S,"getAngleVar",lua_cocos2dx_ParticleSystem_getAngleVar); tolua_function(tolua_S,"setStartColor",lua_cocos2dx_ParticleSystem_setStartColor); tolua_function(tolua_S,"getRotatePerSecondVar",lua_cocos2dx_ParticleSystem_getRotatePerSecondVar); tolua_function(tolua_S,"getEndSize",lua_cocos2dx_ParticleSystem_getEndSize); tolua_function(tolua_S,"getLife",lua_cocos2dx_ParticleSystem_getLife); tolua_function(tolua_S,"setSpeedVar",lua_cocos2dx_ParticleSystem_setSpeedVar); tolua_function(tolua_S,"setAutoRemoveOnFinish",lua_cocos2dx_ParticleSystem_setAutoRemoveOnFinish); tolua_function(tolua_S,"setGravity",lua_cocos2dx_ParticleSystem_setGravity); tolua_function(tolua_S,"postStep",lua_cocos2dx_ParticleSystem_postStep); tolua_function(tolua_S,"setEmissionRate",lua_cocos2dx_ParticleSystem_setEmissionRate); tolua_function(tolua_S,"getEndColorVar",lua_cocos2dx_ParticleSystem_getEndColorVar); tolua_function(tolua_S,"getRotationIsDir",lua_cocos2dx_ParticleSystem_getRotationIsDir); tolua_function(tolua_S,"setScale",lua_cocos2dx_ParticleSystem_setScale); tolua_function(tolua_S,"getEmissionRate",lua_cocos2dx_ParticleSystem_getEmissionRate); tolua_function(tolua_S,"getEndColor",lua_cocos2dx_ParticleSystem_getEndColor); tolua_function(tolua_S,"getLifeVar",lua_cocos2dx_ParticleSystem_getLifeVar); tolua_function(tolua_S,"setStartSizeVar",lua_cocos2dx_ParticleSystem_setStartSizeVar); tolua_function(tolua_S,"setOpacityModifyRGB",lua_cocos2dx_ParticleSystem_setOpacityModifyRGB); tolua_function(tolua_S,"addParticle",lua_cocos2dx_ParticleSystem_addParticle); tolua_function(tolua_S,"getStartRadius",lua_cocos2dx_ParticleSystem_getStartRadius); tolua_function(tolua_S,"getParticleCount",lua_cocos2dx_ParticleSystem_getParticleCount); tolua_function(tolua_S,"getStartRadiusVar",lua_cocos2dx_ParticleSystem_getStartRadiusVar); tolua_function(tolua_S,"setStartColorVar",lua_cocos2dx_ParticleSystem_setStartColorVar); tolua_function(tolua_S,"setEndSpin",lua_cocos2dx_ParticleSystem_setEndSpin); tolua_function(tolua_S,"setRadialAccel",lua_cocos2dx_ParticleSystem_setRadialAccel); tolua_function(tolua_S,"isAutoRemoveOnFinish",lua_cocos2dx_ParticleSystem_isAutoRemoveOnFinish); tolua_function(tolua_S,"getTotalParticles",lua_cocos2dx_ParticleSystem_getTotalParticles); tolua_function(tolua_S,"setStartRadiusVar",lua_cocos2dx_ParticleSystem_setStartRadiusVar); tolua_function(tolua_S,"getEndRadiusVar",lua_cocos2dx_ParticleSystem_getEndRadiusVar); tolua_function(tolua_S,"getStartColorVar",lua_cocos2dx_ParticleSystem_getStartColorVar); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleSystem_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleSystem_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleSystem).name(); g_luaType[typeName] = "cc.ParticleSystem"; g_typeCast["ParticleSystem"] = "cc.ParticleSystem"; return 1; } int lua_cocos2dx_ParticleSystemQuad_setDisplayFrame(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystemQuad* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystemQuad",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystemQuad*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystemQuad_setDisplayFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setDisplayFrame(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDisplayFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystemQuad_setDisplayFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystemQuad_setTextureWithRect(lua_State* tolua_S) { int argc = 0; cocos2d::ParticleSystemQuad* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystemQuad",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParticleSystemQuad*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParticleSystemQuad_setTextureWithRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Texture2D* arg0; cocos2d::Rect arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_rect(tolua_S, 3, &arg1); if(!ok) return 0; cobj->setTextureWithRect(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextureWithRect",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystemQuad_setTextureWithRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystemQuad_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSystemQuad",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSystemQuad"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSystemQuad*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSystemQuad"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSystemQuad*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystemQuad_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSystemQuad_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSystemQuad",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSystemQuad"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSystemQuad*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSystemQuad_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleSystemQuad_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleSystemQuad)"); return 0; } int lua_register_cocos2dx_ParticleSystemQuad(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleSystemQuad"); tolua_cclass(tolua_S,"ParticleSystemQuad","cc.ParticleSystemQuad","cc.ParticleSystem",NULL); tolua_beginmodule(tolua_S,"ParticleSystemQuad"); tolua_function(tolua_S,"setDisplayFrame",lua_cocos2dx_ParticleSystemQuad_setDisplayFrame); tolua_function(tolua_S,"setTextureWithRect",lua_cocos2dx_ParticleSystemQuad_setTextureWithRect); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleSystemQuad_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleSystemQuad_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleSystemQuad).name(); g_luaType[typeName] = "cc.ParticleSystemQuad"; g_typeCast["ParticleSystemQuad"] = "cc.ParticleSystemQuad"; return 1; } int lua_cocos2dx_ParticleFire_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleFire",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleFire* ret = cocos2d::ParticleFire::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleFire"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleFire*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleFire_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleFire_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleFire",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleFire* ret = cocos2d::ParticleFire::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleFire"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleFire*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleFire_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleFire_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleFire)"); return 0; } int lua_register_cocos2dx_ParticleFire(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleFire"); tolua_cclass(tolua_S,"ParticleFire","cc.ParticleFire","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleFire"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleFire_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleFire_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleFire).name(); g_luaType[typeName] = "cc.ParticleFire"; g_typeCast["ParticleFire"] = "cc.ParticleFire"; return 1; } int lua_cocos2dx_ParticleFireworks_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleFireworks",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleFireworks* ret = cocos2d::ParticleFireworks::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleFireworks"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleFireworks*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleFireworks_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleFireworks_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleFireworks",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleFireworks* ret = cocos2d::ParticleFireworks::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleFireworks"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleFireworks*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleFireworks_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleFireworks_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleFireworks)"); return 0; } int lua_register_cocos2dx_ParticleFireworks(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleFireworks"); tolua_cclass(tolua_S,"ParticleFireworks","cc.ParticleFireworks","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleFireworks"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleFireworks_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleFireworks_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleFireworks).name(); g_luaType[typeName] = "cc.ParticleFireworks"; g_typeCast["ParticleFireworks"] = "cc.ParticleFireworks"; return 1; } int lua_cocos2dx_ParticleSun_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSun",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleSun* ret = cocos2d::ParticleSun::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSun"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSun*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSun_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSun_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSun",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleSun* ret = cocos2d::ParticleSun::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSun"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSun*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSun_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleSun_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleSun)"); return 0; } int lua_register_cocos2dx_ParticleSun(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleSun"); tolua_cclass(tolua_S,"ParticleSun","cc.ParticleSun","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleSun"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleSun_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleSun_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleSun).name(); g_luaType[typeName] = "cc.ParticleSun"; g_typeCast["ParticleSun"] = "cc.ParticleSun"; return 1; } int lua_cocos2dx_ParticleGalaxy_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleGalaxy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleGalaxy* ret = cocos2d::ParticleGalaxy::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleGalaxy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleGalaxy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleGalaxy_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleGalaxy_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleGalaxy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleGalaxy* ret = cocos2d::ParticleGalaxy::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleGalaxy"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleGalaxy*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleGalaxy_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleGalaxy_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleGalaxy)"); return 0; } int lua_register_cocos2dx_ParticleGalaxy(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleGalaxy"); tolua_cclass(tolua_S,"ParticleGalaxy","cc.ParticleGalaxy","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleGalaxy"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleGalaxy_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleGalaxy_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleGalaxy).name(); g_luaType[typeName] = "cc.ParticleGalaxy"; g_typeCast["ParticleGalaxy"] = "cc.ParticleGalaxy"; return 1; } int lua_cocos2dx_ParticleFlower_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleFlower",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleFlower* ret = cocos2d::ParticleFlower::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleFlower"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleFlower*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleFlower_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleFlower_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleFlower",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleFlower* ret = cocos2d::ParticleFlower::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleFlower"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleFlower*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleFlower_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleFlower_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleFlower)"); return 0; } int lua_register_cocos2dx_ParticleFlower(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleFlower"); tolua_cclass(tolua_S,"ParticleFlower","cc.ParticleFlower","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleFlower"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleFlower_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleFlower_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleFlower).name(); g_luaType[typeName] = "cc.ParticleFlower"; g_typeCast["ParticleFlower"] = "cc.ParticleFlower"; return 1; } int lua_cocos2dx_ParticleMeteor_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleMeteor",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleMeteor* ret = cocos2d::ParticleMeteor::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleMeteor"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleMeteor*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleMeteor_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleMeteor_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleMeteor",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleMeteor* ret = cocos2d::ParticleMeteor::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleMeteor"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleMeteor*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleMeteor_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleMeteor_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleMeteor)"); return 0; } int lua_register_cocos2dx_ParticleMeteor(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleMeteor"); tolua_cclass(tolua_S,"ParticleMeteor","cc.ParticleMeteor","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleMeteor"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleMeteor_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleMeteor_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleMeteor).name(); g_luaType[typeName] = "cc.ParticleMeteor"; g_typeCast["ParticleMeteor"] = "cc.ParticleMeteor"; return 1; } int lua_cocos2dx_ParticleSpiral_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSpiral",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleSpiral* ret = cocos2d::ParticleSpiral::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSpiral"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSpiral*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSpiral_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSpiral_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSpiral",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleSpiral* ret = cocos2d::ParticleSpiral::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSpiral"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSpiral*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSpiral_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleSpiral_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleSpiral)"); return 0; } int lua_register_cocos2dx_ParticleSpiral(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleSpiral"); tolua_cclass(tolua_S,"ParticleSpiral","cc.ParticleSpiral","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleSpiral"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleSpiral_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleSpiral_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleSpiral).name(); g_luaType[typeName] = "cc.ParticleSpiral"; g_typeCast["ParticleSpiral"] = "cc.ParticleSpiral"; return 1; } int lua_cocos2dx_ParticleExplosion_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleExplosion",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleExplosion* ret = cocos2d::ParticleExplosion::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleExplosion"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleExplosion*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleExplosion_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleExplosion_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleExplosion",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleExplosion* ret = cocos2d::ParticleExplosion::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleExplosion"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleExplosion*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleExplosion_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleExplosion_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleExplosion)"); return 0; } int lua_register_cocos2dx_ParticleExplosion(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleExplosion"); tolua_cclass(tolua_S,"ParticleExplosion","cc.ParticleExplosion","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleExplosion"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleExplosion_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleExplosion_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleExplosion).name(); g_luaType[typeName] = "cc.ParticleExplosion"; g_typeCast["ParticleExplosion"] = "cc.ParticleExplosion"; return 1; } int lua_cocos2dx_ParticleSmoke_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSmoke",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleSmoke* ret = cocos2d::ParticleSmoke::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSmoke"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSmoke*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSmoke_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSmoke_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSmoke",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleSmoke* ret = cocos2d::ParticleSmoke::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSmoke"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSmoke*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSmoke_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleSmoke_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleSmoke)"); return 0; } int lua_register_cocos2dx_ParticleSmoke(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleSmoke"); tolua_cclass(tolua_S,"ParticleSmoke","cc.ParticleSmoke","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleSmoke"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleSmoke_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleSmoke_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleSmoke).name(); g_luaType[typeName] = "cc.ParticleSmoke"; g_typeCast["ParticleSmoke"] = "cc.ParticleSmoke"; return 1; } int lua_cocos2dx_ParticleSnow_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSnow",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleSnow* ret = cocos2d::ParticleSnow::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSnow"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSnow*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSnow_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleSnow_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleSnow",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleSnow* ret = cocos2d::ParticleSnow::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleSnow"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleSnow*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleSnow_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleSnow_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleSnow)"); return 0; } int lua_register_cocos2dx_ParticleSnow(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleSnow"); tolua_cclass(tolua_S,"ParticleSnow","cc.ParticleSnow","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleSnow"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleSnow_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleSnow_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleSnow).name(); g_luaType[typeName] = "cc.ParticleSnow"; g_typeCast["ParticleSnow"] = "cc.ParticleSnow"; return 1; } int lua_cocos2dx_ParticleRain_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleRain",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParticleRain* ret = cocos2d::ParticleRain::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleRain"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleRain*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleRain_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParticleRain_createWithTotalParticles(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParticleRain",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::ParticleRain* ret = cocos2d::ParticleRain::createWithTotalParticles(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParticleRain"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParticleRain*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithTotalParticles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParticleRain_createWithTotalParticles'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParticleRain_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleRain)"); return 0; } int lua_register_cocos2dx_ParticleRain(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParticleRain"); tolua_cclass(tolua_S,"ParticleRain","cc.ParticleRain","cc.ParticleSystemQuad",NULL); tolua_beginmodule(tolua_S,"ParticleRain"); tolua_function(tolua_S,"create", lua_cocos2dx_ParticleRain_create); tolua_function(tolua_S,"createWithTotalParticles", lua_cocos2dx_ParticleRain_createWithTotalParticles); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParticleRain).name(); g_luaType[typeName] = "cc.ParticleRain"; g_typeCast["ParticleRain"] = "cc.ParticleRain"; return 1; } static int lua_cocos2dx_EventListenerCustom_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerCustom)"); return 0; } int lua_register_cocos2dx_EventListenerCustom(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerCustom"); tolua_cclass(tolua_S,"EventListenerCustom","cc.EventListenerCustom","cc.EventListener",NULL); tolua_beginmodule(tolua_S,"EventListenerCustom"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerCustom).name(); g_luaType[typeName] = "cc.EventListenerCustom"; g_typeCast["EventListenerCustom"] = "cc.EventListenerCustom"; return 1; } int lua_cocos2dx_FileUtils_fullPathForFilename(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_fullPathForFilename'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; std::string ret = cobj->fullPathForFilename(arg0); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "fullPathForFilename",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_fullPathForFilename'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_getStringFromFile(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_getStringFromFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; std::string ret = cobj->getStringFromFile(arg0); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringFromFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_getStringFromFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_setFilenameLookupDictionary(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_setFilenameLookupDictionary'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueMap arg0; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setFilenameLookupDictionary(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFilenameLookupDictionary",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_setFilenameLookupDictionary'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_isAbsolutePath(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_isAbsolutePath'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->isAbsolutePath(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isAbsolutePath",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_isAbsolutePath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->loadFilenameLookupDictionaryFromFile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadFilenameLookupDictionaryFromFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_isPopupNotify(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_isPopupNotify'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isPopupNotify(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isPopupNotify",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_isPopupNotify'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_getValueVectorFromFile(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_getValueVectorFromFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::ValueVector ret = cobj->getValueVectorFromFile(arg0); ccvaluevector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getValueVectorFromFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_getValueVectorFromFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_writeToFile(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_writeToFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::ValueMap arg0; std::string arg1; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; bool ret = cobj->writeToFile(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "writeToFile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_writeToFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_getValueMapFromFile(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_getValueMapFromFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::ValueMap ret = cobj->getValueMapFromFile(arg0); ccvaluemap_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getValueMapFromFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_getValueMapFromFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_addSearchResolutionsOrder(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_addSearchResolutionsOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addSearchResolutionsOrder(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSearchResolutionsOrder",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_addSearchResolutionsOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_addSearchPath(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_addSearchPath'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addSearchPath(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSearchPath",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_addSearchPath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_isFileExist(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_isFileExist'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->isFileExist(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFileExist",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_isFileExist'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_purgeCachedEntries(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_purgeCachedEntries'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->purgeCachedEntries(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "purgeCachedEntries",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_purgeCachedEntries'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_fullPathFromRelativeFile(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_fullPathFromRelativeFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; std::string ret = cobj->fullPathFromRelativeFile(arg0, arg1); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "fullPathFromRelativeFile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_fullPathFromRelativeFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_setPopupNotify(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_setPopupNotify'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPopupNotify(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPopupNotify",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_setPopupNotify'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_getWritablePath(lua_State* tolua_S) { int argc = 0; cocos2d::FileUtils* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_getWritablePath'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getWritablePath(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWritablePath",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_getWritablePath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::FileUtils::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_FileUtils_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::FileUtils* ret = cocos2d::FileUtils::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.FileUtils"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::FileUtils*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_FileUtils_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FileUtils)"); return 0; } int lua_register_cocos2dx_FileUtils(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.FileUtils"); tolua_cclass(tolua_S,"FileUtils","cc.FileUtils","",NULL); tolua_beginmodule(tolua_S,"FileUtils"); tolua_function(tolua_S,"fullPathForFilename",lua_cocos2dx_FileUtils_fullPathForFilename); tolua_function(tolua_S,"getStringFromFile",lua_cocos2dx_FileUtils_getStringFromFile); tolua_function(tolua_S,"setFilenameLookupDictionary",lua_cocos2dx_FileUtils_setFilenameLookupDictionary); tolua_function(tolua_S,"isAbsolutePath",lua_cocos2dx_FileUtils_isAbsolutePath); tolua_function(tolua_S,"loadFilenameLookup",lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile); tolua_function(tolua_S,"isPopupNotify",lua_cocos2dx_FileUtils_isPopupNotify); tolua_function(tolua_S,"getValueVectorFromFile",lua_cocos2dx_FileUtils_getValueVectorFromFile); tolua_function(tolua_S,"writeToFile",lua_cocos2dx_FileUtils_writeToFile); tolua_function(tolua_S,"getValueMapFromFile",lua_cocos2dx_FileUtils_getValueMapFromFile); tolua_function(tolua_S,"addSearchResolutionsOrder",lua_cocos2dx_FileUtils_addSearchResolutionsOrder); tolua_function(tolua_S,"addSearchPath",lua_cocos2dx_FileUtils_addSearchPath); tolua_function(tolua_S,"isFileExist",lua_cocos2dx_FileUtils_isFileExist); tolua_function(tolua_S,"purgeCachedEntries",lua_cocos2dx_FileUtils_purgeCachedEntries); tolua_function(tolua_S,"fullPathFromRelativeFile",lua_cocos2dx_FileUtils_fullPathFromRelativeFile); tolua_function(tolua_S,"setPopupNotify",lua_cocos2dx_FileUtils_setPopupNotify); tolua_function(tolua_S,"getWritablePath",lua_cocos2dx_FileUtils_getWritablePath); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_FileUtils_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_FileUtils_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::FileUtils).name(); g_luaType[typeName] = "cc.FileUtils"; g_typeCast["FileUtils"] = "cc.FileUtils"; return 1; } int lua_cocos2dx_Application_getTargetPlatform(lua_State* tolua_S) { int argc = 0; cocos2d::Application* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_getTargetPlatform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getTargetPlatform(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTargetPlatform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_getTargetPlatform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Application_setAnimationInterval(lua_State* tolua_S) { int argc = 0; cocos2d::Application* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_setAnimationInterval'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAnimationInterval(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimationInterval",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_setAnimationInterval'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Application_getCurrentLanguage(lua_State* tolua_S) { int argc = 0; cocos2d::Application* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Application*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Application_getCurrentLanguage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getCurrentLanguage(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentLanguage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_getCurrentLanguage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Application_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Application",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Application* ret = cocos2d::Application::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Application"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Application*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Application_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Application_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Application)"); return 0; } int lua_register_cocos2dx_Application(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Application"); tolua_cclass(tolua_S,"Application","cc.Application","",NULL); tolua_beginmodule(tolua_S,"Application"); tolua_function(tolua_S,"getTargetPlatform",lua_cocos2dx_Application_getTargetPlatform); tolua_function(tolua_S,"setAnimationInterval",lua_cocos2dx_Application_setAnimationInterval); tolua_function(tolua_S,"getCurrentLanguage",lua_cocos2dx_Application_getCurrentLanguage); tolua_function(tolua_S,"getInstance", lua_cocos2dx_Application_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Application).name(); g_luaType[typeName] = "cc.Application"; g_typeCast["Application"] = "cc.Application"; return 1; } int lua_cocos2dx_EGLViewProtocol_setFrameSize(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_setFrameSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; double arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setFrameSize(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFrameSize",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_setFrameSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_swapBuffers(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_swapBuffers'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->swapBuffers(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "swapBuffers",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_swapBuffers'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getViewPortRect(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getViewPortRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Rect& ret = cobj->getViewPortRect(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getViewPortRect",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getViewPortRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_end(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_end'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->end(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "end",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_end'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_setViewName(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_setViewName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setViewName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setViewName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_setViewName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getScaleY(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getScaleY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScaleY(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScaleY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getScaleY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getScaleX(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getScaleX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScaleX(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScaleX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getScaleX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getVisibleOrigin(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getVisibleOrigin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getVisibleOrigin(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVisibleOrigin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getVisibleOrigin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getViewName(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getViewName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getViewName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getViewName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getViewName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getVisibleSize(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getVisibleSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getVisibleSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVisibleSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getVisibleSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_isScissorEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_isScissorEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isScissorEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isScissorEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_isScissorEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_setIMEKeyboardState(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_setIMEKeyboardState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setIMEKeyboardState(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setIMEKeyboardState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_setIMEKeyboardState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_setDesignResolutionSize(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_setDesignResolutionSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { double arg0; double arg1; ResolutionPolicy arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if(!ok) return 0; cobj->setDesignResolutionSize(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDesignResolutionSize",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_setDesignResolutionSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getDesignResolutionSize(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getDesignResolutionSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getDesignResolutionSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDesignResolutionSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getDesignResolutionSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_setViewPortInPoints(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_setViewPortInPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { double arg0; double arg1; double arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cobj->setViewPortInPoints(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setViewPortInPoints",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_setViewPortInPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_setScissorInPoints(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_setScissorInPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { double arg0; double arg1; double arg2; double arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cobj->setScissorInPoints(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScissorInPoints",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_setScissorInPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getFrameSize(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getFrameSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getFrameSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFrameSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getFrameSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_getScissorRect(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_getScissorRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Rect ret = cobj->getScissorRect(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScissorRect",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_getScissorRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_isOpenGLReady(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_isOpenGLReady'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isOpenGLReady(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isOpenGLReady",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_isOpenGLReady'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLViewProtocol_pollInputEvents(lua_State* tolua_S) { int argc = 0; cocos2d::EGLViewProtocol* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLViewProtocol",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLViewProtocol*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLViewProtocol_pollInputEvents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pollInputEvents(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pollInputEvents",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLViewProtocol_pollInputEvents'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EGLViewProtocol_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EGLViewProtocol)"); return 0; } int lua_register_cocos2dx_EGLViewProtocol(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EGLViewProtocol"); tolua_cclass(tolua_S,"EGLViewProtocol","cc.EGLViewProtocol","",NULL); tolua_beginmodule(tolua_S,"EGLViewProtocol"); tolua_function(tolua_S,"setFrameSize",lua_cocos2dx_EGLViewProtocol_setFrameSize); tolua_function(tolua_S,"swapBuffers",lua_cocos2dx_EGLViewProtocol_swapBuffers); tolua_function(tolua_S,"getViewPortRect",lua_cocos2dx_EGLViewProtocol_getViewPortRect); tolua_function(tolua_S,"end",lua_cocos2dx_EGLViewProtocol_end); tolua_function(tolua_S,"setViewName",lua_cocos2dx_EGLViewProtocol_setViewName); tolua_function(tolua_S,"getScaleY",lua_cocos2dx_EGLViewProtocol_getScaleY); tolua_function(tolua_S,"getScaleX",lua_cocos2dx_EGLViewProtocol_getScaleX); tolua_function(tolua_S,"getVisibleOrigin",lua_cocos2dx_EGLViewProtocol_getVisibleOrigin); tolua_function(tolua_S,"getViewName",lua_cocos2dx_EGLViewProtocol_getViewName); tolua_function(tolua_S,"getVisibleSize",lua_cocos2dx_EGLViewProtocol_getVisibleSize); tolua_function(tolua_S,"isScissorEnabled",lua_cocos2dx_EGLViewProtocol_isScissorEnabled); tolua_function(tolua_S,"setIMEKeyboardState",lua_cocos2dx_EGLViewProtocol_setIMEKeyboardState); tolua_function(tolua_S,"setDesignResolutionSize",lua_cocos2dx_EGLViewProtocol_setDesignResolutionSize); tolua_function(tolua_S,"getDesignResolutionSize",lua_cocos2dx_EGLViewProtocol_getDesignResolutionSize); tolua_function(tolua_S,"setViewPortInPoints",lua_cocos2dx_EGLViewProtocol_setViewPortInPoints); tolua_function(tolua_S,"setScissorInPoints",lua_cocos2dx_EGLViewProtocol_setScissorInPoints); tolua_function(tolua_S,"getFrameSize",lua_cocos2dx_EGLViewProtocol_getFrameSize); tolua_function(tolua_S,"getScissorRect",lua_cocos2dx_EGLViewProtocol_getScissorRect); tolua_function(tolua_S,"isOpenGLReady",lua_cocos2dx_EGLViewProtocol_isOpenGLReady); tolua_function(tolua_S,"pollInputEvents",lua_cocos2dx_EGLViewProtocol_pollInputEvents); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EGLViewProtocol).name(); g_luaType[typeName] = "cc.EGLViewProtocol"; g_typeCast["EGLViewProtocol"] = "cc.EGLViewProtocol"; return 1; } int lua_cocos2dx_EGLView_setIMEKeyboardState(lua_State* tolua_S) { int argc = 0; cocos2d::EGLView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLView_setIMEKeyboardState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setIMEKeyboardState(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setIMEKeyboardState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLView_setIMEKeyboardState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLView_isOpenGLReady(lua_State* tolua_S) { int argc = 0; cocos2d::EGLView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EGLView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EGLView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EGLView_isOpenGLReady'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isOpenGLReady(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isOpenGLReady",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLView_isOpenGLReady'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EGLView_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EGLView",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::EGLView* ret = cocos2d::EGLView::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EGLView"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EGLView*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EGLView_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EGLView_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EGLView)"); return 0; } int lua_register_cocos2dx_EGLView(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EGLView"); tolua_cclass(tolua_S,"EGLView","cc.EGLView","cc.EGLViewProtocol",NULL); tolua_beginmodule(tolua_S,"EGLView"); tolua_function(tolua_S,"setIMEKeyboardState",lua_cocos2dx_EGLView_setIMEKeyboardState); tolua_function(tolua_S,"isOpenGLReady",lua_cocos2dx_EGLView_isOpenGLReady); tolua_function(tolua_S,"getInstance", lua_cocos2dx_EGLView_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EGLView).name(); g_luaType[typeName] = "cc.EGLView"; g_typeCast["EGLView"] = "cc.EGLView"; return 1; } int lua_cocos2dx_ShaderCache_reloadDefaultShaders(lua_State* tolua_S) { int argc = 0; cocos2d::ShaderCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ShaderCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShaderCache_reloadDefaultShaders'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->reloadDefaultShaders(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reloadDefaultShaders",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_reloadDefaultShaders'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShaderCache_addProgram(lua_State* tolua_S) { int argc = 0; cocos2d::ShaderCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ShaderCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShaderCache_addProgram'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::GLProgram* arg0; std::string arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.GLProgram",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->addProgram(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addProgram",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_addProgram'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShaderCache_getProgram(lua_State* tolua_S) { int argc = 0; cocos2d::ShaderCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ShaderCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShaderCache_getProgram'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::GLProgram* ret = cobj->getProgram(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.GLProgram"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::GLProgram*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProgram",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_getProgram'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShaderCache_loadDefaultShaders(lua_State* tolua_S) { int argc = 0; cocos2d::ShaderCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ShaderCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShaderCache_loadDefaultShaders'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->loadDefaultShaders(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadDefaultShaders",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_loadDefaultShaders'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShaderCache_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ShaderCache::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShaderCache_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ShaderCache* ret = cocos2d::ShaderCache::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ShaderCache"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ShaderCache*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_getInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ShaderCache_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::ShaderCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::ShaderCache(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ShaderCache"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ShaderCache"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ShaderCache",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ShaderCache_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ShaderCache)"); return 0; } int lua_register_cocos2dx_ShaderCache(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ShaderCache"); tolua_cclass(tolua_S,"ShaderCache","cc.ShaderCache","cc.Object",NULL); tolua_beginmodule(tolua_S,"ShaderCache"); tolua_function(tolua_S,"reloadDefaultShaders",lua_cocos2dx_ShaderCache_reloadDefaultShaders); tolua_function(tolua_S,"addProgram",lua_cocos2dx_ShaderCache_addProgram); tolua_function(tolua_S,"getProgram",lua_cocos2dx_ShaderCache_getProgram); tolua_function(tolua_S,"loadDefaultShaders",lua_cocos2dx_ShaderCache_loadDefaultShaders); tolua_function(tolua_S,"new",lua_cocos2dx_ShaderCache_constructor); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_ShaderCache_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_ShaderCache_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ShaderCache).name(); g_luaType[typeName] = "cc.ShaderCache"; g_typeCast["ShaderCache"] = "cc.ShaderCache"; return 1; } int lua_cocos2dx_AnimationCache_getAnimation(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationCache_getAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Animation* ret = cobj->getAnimation(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Animation"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Animation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_getAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationCache_addAnimation(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationCache_addAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Animation* arg0; std::string arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Animation",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Animation*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->addAnimation(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addAnimation",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_addAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationCache_init(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationCache_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationCache_addAnimationsWithDictionary(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationCache_addAnimationsWithDictionary'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::ValueMap arg0; std::string arg1; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->addAnimationsWithDictionary(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addAnimationsWithDictionary",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_addAnimationsWithDictionary'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationCache_removeAnimation(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationCache_removeAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeAnimation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAnimation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_removeAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationCache_addAnimationsWithFile(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AnimationCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::AnimationCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AnimationCache_addAnimationsWithFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addAnimationsWithFile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addAnimationsWithFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_addAnimationsWithFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationCache_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.AnimationCache",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::AnimationCache::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationCache_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.AnimationCache",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::AnimationCache* ret = cocos2d::AnimationCache::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.AnimationCache"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::AnimationCache*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_getInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_AnimationCache_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::AnimationCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::AnimationCache(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.AnimationCache"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.AnimationCache"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "AnimationCache",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AnimationCache_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_AnimationCache_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (AnimationCache)"); return 0; } int lua_register_cocos2dx_AnimationCache(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.AnimationCache"); tolua_cclass(tolua_S,"AnimationCache","cc.AnimationCache","cc.Object",NULL); tolua_beginmodule(tolua_S,"AnimationCache"); tolua_function(tolua_S,"getAnimation",lua_cocos2dx_AnimationCache_getAnimation); tolua_function(tolua_S,"addAnimation",lua_cocos2dx_AnimationCache_addAnimation); tolua_function(tolua_S,"init",lua_cocos2dx_AnimationCache_init); tolua_function(tolua_S,"addAnimationsWithDictionary",lua_cocos2dx_AnimationCache_addAnimationsWithDictionary); tolua_function(tolua_S,"removeAnimation",lua_cocos2dx_AnimationCache_removeAnimation); tolua_function(tolua_S,"addAnimations",lua_cocos2dx_AnimationCache_addAnimationsWithFile); tolua_function(tolua_S,"new",lua_cocos2dx_AnimationCache_constructor); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_AnimationCache_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_AnimationCache_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::AnimationCache).name(); g_luaType[typeName] = "cc.AnimationCache"; g_typeCast["AnimationCache"] = "cc.AnimationCache"; return 1; } int lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } cobj->addSpriteFramesWithFile(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cobj->addSpriteFramesWithFile(arg0); return 0; } }while(0); ok = true; do{ if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Texture2D* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj->addSpriteFramesWithFile(arg0, arg1); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSpriteFramesWithFile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_addSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_addSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::SpriteFrame* arg0; std::string arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->addSpriteFrame(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSpriteFrame",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_addSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeUnusedSpriteFrames(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeUnusedSpriteFrames",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_getSpriteFrameByName(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_getSpriteFrameByName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::SpriteFrame* ret = cobj->getSpriteFrameByName(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrame"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrame*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSpriteFrameByName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_getSpriteFrameByName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeSpriteFramesFromFile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeSpriteFramesFromFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_init(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_removeSpriteFrames(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_removeSpriteFrames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeSpriteFrames(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeSpriteFrames",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_removeSpriteFrames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeSpriteFramesFromTexture(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeSpriteFramesFromTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_removeSpriteFrameByName(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrameCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteFrameCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrameCache_removeSpriteFrameByName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeSpriteFrameByName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeSpriteFrameByName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_removeSpriteFrameByName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::SpriteFrameCache::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SpriteFrameCache_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SpriteFrameCache",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::SpriteFrameCache* ret = cocos2d::SpriteFrameCache::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SpriteFrameCache"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::SpriteFrameCache*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrameCache_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_SpriteFrameCache_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SpriteFrameCache)"); return 0; } int lua_register_cocos2dx_SpriteFrameCache(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.SpriteFrameCache"); tolua_cclass(tolua_S,"SpriteFrameCache","cc.SpriteFrameCache","cc.Object",NULL); tolua_beginmodule(tolua_S,"SpriteFrameCache"); tolua_function(tolua_S,"addSpriteFrames",lua_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile); tolua_function(tolua_S,"addSpriteFrame",lua_cocos2dx_SpriteFrameCache_addSpriteFrame); tolua_function(tolua_S,"removeUnusedSpriteFrames",lua_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames); tolua_function(tolua_S,"getSpriteFrame",lua_cocos2dx_SpriteFrameCache_getSpriteFrameByName); tolua_function(tolua_S,"removeSpriteFramesFromFile",lua_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile); tolua_function(tolua_S,"init",lua_cocos2dx_SpriteFrameCache_init); tolua_function(tolua_S,"removeSpriteFrames",lua_cocos2dx_SpriteFrameCache_removeSpriteFrames); tolua_function(tolua_S,"removeSpriteFramesFromTexture",lua_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture); tolua_function(tolua_S,"removeSpriteFrameByName",lua_cocos2dx_SpriteFrameCache_removeSpriteFrameByName); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_SpriteFrameCache_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_SpriteFrameCache_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::SpriteFrameCache).name(); g_luaType[typeName] = "cc.SpriteFrameCache"; g_typeCast["SpriteFrameCache"] = "cc.SpriteFrameCache"; return 1; } int lua_cocos2dx_UserDefault_setIntegerForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_setIntegerForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; int arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setIntegerForKey(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setIntegerForKey",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_setIntegerForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_getFloatForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_getFloatForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double ret = cobj->getFloatForKey(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } double ret = cobj->getFloatForKey(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFloatForKey",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_getFloatForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_getBoolForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_getBoolForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } bool ret = cobj->getBoolForKey(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } bool ret = cobj->getBoolForKey(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBoolForKey",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_getBoolForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_setDoubleForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_setDoubleForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; double arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setDoubleForKey(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDoubleForKey",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_setDoubleForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_setFloatForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_setFloatForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; double arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setFloatForKey(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFloatForKey",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_setFloatForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_getStringForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_getStringForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } std::string ret = cobj->getStringForKey(arg0, arg1); tolua_pushcppstring(tolua_S,ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } std::string ret = cobj->getStringForKey(arg0); tolua_pushcppstring(tolua_S,ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringForKey",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_getStringForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_setStringForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_setStringForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; std::string arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setStringForKey(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStringForKey",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_setStringForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_flush(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_flush'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->flush(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "flush",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_flush'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_getIntegerForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_getIntegerForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } int ret = cobj->getIntegerForKey(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } int ret = cobj->getIntegerForKey(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getIntegerForKey",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_getIntegerForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_getDoubleForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_getDoubleForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } double ret = cobj->getDoubleForKey(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } double ret = cobj->getDoubleForKey(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDoubleForKey",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_getDoubleForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_setBoolForKey(lua_State* tolua_S) { int argc = 0; cocos2d::UserDefault* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::UserDefault*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_UserDefault_setBoolForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; bool arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setBoolForKey(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBoolForKey",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_setBoolForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::UserDefault::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_getXMLFilePath(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cocos2d::UserDefault::getXMLFilePath(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getXMLFilePath",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_getXMLFilePath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_UserDefault_isXMLFileExist(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; bool ret = cocos2d::UserDefault::isXMLFileExist(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "isXMLFileExist",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_UserDefault_isXMLFileExist'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_UserDefault_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (UserDefault)"); return 0; } int lua_register_cocos2dx_UserDefault(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.UserDefault"); tolua_cclass(tolua_S,"UserDefault","cc.UserDefault","",NULL); tolua_beginmodule(tolua_S,"UserDefault"); tolua_function(tolua_S,"setIntegerForKey",lua_cocos2dx_UserDefault_setIntegerForKey); tolua_function(tolua_S,"getFloatForKey",lua_cocos2dx_UserDefault_getFloatForKey); tolua_function(tolua_S,"getBoolForKey",lua_cocos2dx_UserDefault_getBoolForKey); tolua_function(tolua_S,"setDoubleForKey",lua_cocos2dx_UserDefault_setDoubleForKey); tolua_function(tolua_S,"setFloatForKey",lua_cocos2dx_UserDefault_setFloatForKey); tolua_function(tolua_S,"getStringForKey",lua_cocos2dx_UserDefault_getStringForKey); tolua_function(tolua_S,"setStringForKey",lua_cocos2dx_UserDefault_setStringForKey); tolua_function(tolua_S,"flush",lua_cocos2dx_UserDefault_flush); tolua_function(tolua_S,"getIntegerForKey",lua_cocos2dx_UserDefault_getIntegerForKey); tolua_function(tolua_S,"getDoubleForKey",lua_cocos2dx_UserDefault_getDoubleForKey); tolua_function(tolua_S,"setBoolForKey",lua_cocos2dx_UserDefault_setBoolForKey); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_UserDefault_destroyInstance); tolua_function(tolua_S,"getXMLFilePath", lua_cocos2dx_UserDefault_getXMLFilePath); tolua_function(tolua_S,"isXMLFileExist", lua_cocos2dx_UserDefault_isXMLFileExist); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::UserDefault).name(); g_luaType[typeName] = "cc.UserDefault"; g_typeCast["UserDefault"] = "cc.UserDefault"; return 1; } int lua_cocos2dx_TextureCache_removeTextureForKey(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_removeTextureForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeTextureForKey(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeTextureForKey",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_removeTextureForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_removeAllTextures(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_removeAllTextures'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllTextures(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllTextures",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_removeAllTextures'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_getDescription(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_getDescription'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getDescription(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDescription",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_getDescription'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_getCachedTextureInfo(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_getCachedTextureInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getCachedTextureInfo(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCachedTextureInfo",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_getCachedTextureInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_addImage(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_addImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Image* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Image",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Image*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::Texture2D* ret = cobj->addImage(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::Texture2D* ret = cobj->addImage(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addImage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_addImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_getTextureForKey(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_getTextureForKey'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Texture2D* ret = cobj->getTextureForKey(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Texture2D"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Texture2D*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureForKey",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_getTextureForKey'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_removeUnusedTextures(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_removeUnusedTextures'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeUnusedTextures(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeUnusedTextures",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_removeUnusedTextures'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_removeTexture(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_removeTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Texture2D* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Texture2D",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeTexture(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_removeTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_waitForQuit(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_waitForQuit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->waitForQuit(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "waitForQuit",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_waitForQuit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TextureCache_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TextureCache* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TextureCache(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TextureCache"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TextureCache"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TextureCache",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TextureCache_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TextureCache)"); return 0; } int lua_register_cocos2dx_TextureCache(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TextureCache"); tolua_cclass(tolua_S,"TextureCache","cc.TextureCache","cc.Object",NULL); tolua_beginmodule(tolua_S,"TextureCache"); tolua_function(tolua_S,"removeTextureForKey",lua_cocos2dx_TextureCache_removeTextureForKey); tolua_function(tolua_S,"removeAllTextures",lua_cocos2dx_TextureCache_removeAllTextures); tolua_function(tolua_S,"getDescription",lua_cocos2dx_TextureCache_getDescription); tolua_function(tolua_S,"getCachedTextureInfo",lua_cocos2dx_TextureCache_getCachedTextureInfo); tolua_function(tolua_S,"addImage",lua_cocos2dx_TextureCache_addImage); tolua_function(tolua_S,"getTextureForKey",lua_cocos2dx_TextureCache_getTextureForKey); tolua_function(tolua_S,"removeUnusedTextures",lua_cocos2dx_TextureCache_removeUnusedTextures); tolua_function(tolua_S,"removeTexture",lua_cocos2dx_TextureCache_removeTexture); tolua_function(tolua_S,"waitForQuit",lua_cocos2dx_TextureCache_waitForQuit); tolua_function(tolua_S,"new",lua_cocos2dx_TextureCache_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TextureCache).name(); g_luaType[typeName] = "cc.TextureCache"; g_typeCast["TextureCache"] = "cc.TextureCache"; return 1; } int lua_cocos2dx_ParallaxNode_getParallaxArray(lua_State* tolua_S) { int argc = 0; cocos2d::ParallaxNode* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParallaxNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParallaxNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParallaxNode_getParallaxArray'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { const cocos2d::_ccArray* ret = cobj->getParallaxArray(); #pragma warning NO CONVERSION FROM NATIVE FOR _ccArray*; return 1; } }while(0); ok = true; do{ if (argc == 0) { cocos2d::_ccArray* ret = cobj->getParallaxArray(); #pragma warning NO CONVERSION FROM NATIVE FOR _ccArray*; return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParallaxArray",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParallaxNode_getParallaxArray'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParallaxNode_addChild(lua_State* tolua_S) { int argc = 0; cocos2d::ParallaxNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParallaxNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParallaxNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParallaxNode_addChild'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { cocos2d::Node* arg0; int arg1; cocos2d::Point arg2; cocos2d::Point arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); if(!ok) return 0; cobj->addChild(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addChild",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParallaxNode_addChild'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup(lua_State* tolua_S) { int argc = 0; cocos2d::ParallaxNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParallaxNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParallaxNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeAllChildrenWithCleanup(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllChildrenWithCleanup",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParallaxNode_setParallaxArray(lua_State* tolua_S) { int argc = 0; cocos2d::ParallaxNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ParallaxNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ParallaxNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ParallaxNode_setParallaxArray'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::_ccArray* arg0; #pragma warning NO CONVERSION TO NATIVE FOR _ccArray*; if(!ok) return 0; cobj->setParallaxArray(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setParallaxArray",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParallaxNode_setParallaxArray'.",&tolua_err); #endif return 0; } int lua_cocos2dx_ParallaxNode_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ParallaxNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::ParallaxNode* ret = cocos2d::ParallaxNode::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ParallaxNode"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ParallaxNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ParallaxNode_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_ParallaxNode_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParallaxNode)"); return 0; } int lua_register_cocos2dx_ParallaxNode(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ParallaxNode"); tolua_cclass(tolua_S,"ParallaxNode","cc.ParallaxNode","cc.Node",NULL); tolua_beginmodule(tolua_S,"ParallaxNode"); tolua_function(tolua_S,"getParallaxArray",lua_cocos2dx_ParallaxNode_getParallaxArray); tolua_function(tolua_S,"addChild",lua_cocos2dx_ParallaxNode_addChild); tolua_function(tolua_S,"removeAllChildrenWithCleanup",lua_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup); tolua_function(tolua_S,"setParallaxArray",lua_cocos2dx_ParallaxNode_setParallaxArray); tolua_function(tolua_S,"create", lua_cocos2dx_ParallaxNode_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ParallaxNode).name(); g_luaType[typeName] = "cc.ParallaxNode"; g_typeCast["ParallaxNode"] = "cc.ParallaxNode"; return 1; } int lua_cocos2dx_TMXObjectGroup_setPositionOffset(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_setPositionOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPositionOffset(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPositionOffset",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_setPositionOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_getProperty(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_getProperty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Value ret = cobj->getProperty(arg0); ccvalue_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProperty",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_getProperty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_getPositionOffset(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_getPositionOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getPositionOffset(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPositionOffset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_getPositionOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_getObject(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_getObject'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::ValueMap ret = cobj->getObject(arg0); ccvaluemap_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getObject",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_getObject'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_getObjects(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_getObjects'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::ValueVector& ret = cobj->getObjects(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::ValueVector& ret = cobj->getObjects(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getObjects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_getObjects'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_setGroupName(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_setGroupName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setGroupName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGroupName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_setGroupName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_getProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_getProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::ValueMap& ret = cobj->getProperties(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::ValueMap& ret = cobj->getProperties(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProperties",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_getProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_getGroupName(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_getGroupName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getGroupName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGroupName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_getGroupName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_setProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_setProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueMap arg0; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setProperties(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProperties",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_setProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_setObjects(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXObjectGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXObjectGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXObjectGroup_setObjects'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueVector arg0; ok &= luaval_to_ccvaluevector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setObjects(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setObjects",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_setObjects'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXObjectGroup_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TMXObjectGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TMXObjectGroup(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TMXObjectGroup"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TMXObjectGroup"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TMXObjectGroup",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXObjectGroup_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TMXObjectGroup_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TMXObjectGroup)"); return 0; } int lua_register_cocos2dx_TMXObjectGroup(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TMXObjectGroup"); tolua_cclass(tolua_S,"TMXObjectGroup","cc.TMXObjectGroup","cc.Object",NULL); tolua_beginmodule(tolua_S,"TMXObjectGroup"); tolua_function(tolua_S,"setPositionOffset",lua_cocos2dx_TMXObjectGroup_setPositionOffset); tolua_function(tolua_S,"getProperty",lua_cocos2dx_TMXObjectGroup_getProperty); tolua_function(tolua_S,"getPositionOffset",lua_cocos2dx_TMXObjectGroup_getPositionOffset); tolua_function(tolua_S,"getObject",lua_cocos2dx_TMXObjectGroup_getObject); tolua_function(tolua_S,"getObjects",lua_cocos2dx_TMXObjectGroup_getObjects); tolua_function(tolua_S,"setGroupName",lua_cocos2dx_TMXObjectGroup_setGroupName); tolua_function(tolua_S,"getProperties",lua_cocos2dx_TMXObjectGroup_getProperties); tolua_function(tolua_S,"getGroupName",lua_cocos2dx_TMXObjectGroup_getGroupName); tolua_function(tolua_S,"setProperties",lua_cocos2dx_TMXObjectGroup_setProperties); tolua_function(tolua_S,"setObjects",lua_cocos2dx_TMXObjectGroup_setObjects); tolua_function(tolua_S,"new",lua_cocos2dx_TMXObjectGroup_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXObjectGroup).name(); g_luaType[typeName] = "cc.TMXObjectGroup"; g_typeCast["TMXObjectGroup"] = "cc.TMXObjectGroup"; return 1; } int lua_cocos2dx_TMXLayerInfo_setProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayerInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayerInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayerInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayerInfo_setProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueMap arg0; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setProperties(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProperties",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayerInfo_setProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayerInfo_getProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayerInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayerInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayerInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayerInfo_getProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueMap& ret = cobj->getProperties(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProperties",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayerInfo_getProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayerInfo_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayerInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TMXLayerInfo(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TMXLayerInfo"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TMXLayerInfo"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TMXLayerInfo",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayerInfo_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TMXLayerInfo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TMXLayerInfo)"); return 0; } int lua_register_cocos2dx_TMXLayerInfo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TMXLayerInfo"); tolua_cclass(tolua_S,"TMXLayerInfo","cc.TMXLayerInfo","cc.Object",NULL); tolua_beginmodule(tolua_S,"TMXLayerInfo"); tolua_function(tolua_S,"setProperties",lua_cocos2dx_TMXLayerInfo_setProperties); tolua_function(tolua_S,"getProperties",lua_cocos2dx_TMXLayerInfo_getProperties); tolua_function(tolua_S,"new",lua_cocos2dx_TMXLayerInfo_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXLayerInfo).name(); g_luaType[typeName] = "cc.TMXLayerInfo"; g_typeCast["TMXLayerInfo"] = "cc.TMXLayerInfo"; return 1; } int lua_cocos2dx_TMXTilesetInfo_rectForGID(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTilesetInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTilesetInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTilesetInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTilesetInfo_rectForGID'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Rect ret = cobj->rectForGID(arg0); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rectForGID",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTilesetInfo_rectForGID'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTilesetInfo_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTilesetInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TMXTilesetInfo(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TMXTilesetInfo"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TMXTilesetInfo"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TMXTilesetInfo",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTilesetInfo_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TMXTilesetInfo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TMXTilesetInfo)"); return 0; } int lua_register_cocos2dx_TMXTilesetInfo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TMXTilesetInfo"); tolua_cclass(tolua_S,"TMXTilesetInfo","cc.TMXTilesetInfo","cc.Object",NULL); tolua_beginmodule(tolua_S,"TMXTilesetInfo"); tolua_function(tolua_S,"rectForGID",lua_cocos2dx_TMXTilesetInfo_rectForGID); tolua_function(tolua_S,"new",lua_cocos2dx_TMXTilesetInfo_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXTilesetInfo).name(); g_luaType[typeName] = "cc.TMXTilesetInfo"; g_typeCast["TMXTilesetInfo"] = "cc.TMXTilesetInfo"; return 1; } int lua_cocos2dx_TMXMapInfo_setObjectGroups(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setObjectGroups'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setObjectGroups(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setObjectGroups",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setObjectGroups'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setTileSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setTileSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTileSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTileSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setTileSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_initWithTMXFile(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->initWithTMXFile(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTMXFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getOrientation(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getOrientation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getOrientation(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOrientation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getOrientation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_isStoringCharacters(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_isStoringCharacters'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isStoringCharacters(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isStoringCharacters",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_isStoringCharacters'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setLayers(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setLayers'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setLayers(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLayers",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setLayers'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_parseXMLFile(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_parseXMLFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->parseXMLFile(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "parseXMLFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_parseXMLFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getParentElement(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getParentElement'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getParentElement(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParentElement",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getParentElement'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setTMXFileName(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setTMXFileName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTMXFileName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTMXFileName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setTMXFileName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_parseXMLString(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_parseXMLString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->parseXMLString(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "parseXMLString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_parseXMLString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getLayers(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getLayers'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::Vector& ret = cobj->getLayers(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::Vector& ret = cobj->getLayers(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayers",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getLayers'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getTilesets(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getTilesets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::Vector& ret = cobj->getTilesets(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::Vector& ret = cobj->getTilesets(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTilesets",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getTilesets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getParentGID(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getParentGID'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getParentGID(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParentGID",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getParentGID'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setParentElement(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setParentElement'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setParentElement(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setParentElement",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setParentElement'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_initWithXML(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_initWithXML'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; bool ret = cobj->initWithXML(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithXML",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_initWithXML'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setParentGID(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setParentGID'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setParentGID(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setParentGID",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setParentGID'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getLayerAttribs(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getLayerAttribs'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getLayerAttribs(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayerAttribs",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getLayerAttribs'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getTileSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getTileSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getTileSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getTileSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getTileProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getTileProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueMapIntKey& ret = cobj->getTileProperties(); ccvaluemapintkey_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileProperties",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getTileProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getObjectGroups(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getObjectGroups'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::Vector& ret = cobj->getObjectGroups(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::Vector& ret = cobj->getObjectGroups(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getObjectGroups",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getObjectGroups'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getTMXFileName(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getTMXFileName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getTMXFileName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTMXFileName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getTMXFileName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setCurrentString(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setCurrentString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setCurrentString(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCurrentString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setCurrentString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueMap arg0; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setProperties(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProperties",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setOrientation(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setOrientation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setOrientation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOrientation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setOrientation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setTileProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setTileProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueMapIntKey arg0; ok &= luaval_to_ccvaluemapintkey(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTileProperties(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTileProperties",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setTileProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setMapSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setMapSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setMapSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMapSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setMapSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setStoringCharacters(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setStoringCharacters'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStoringCharacters(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStoringCharacters",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setStoringCharacters'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getMapSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getMapSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getMapSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMapSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getMapSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setTilesets(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setTilesets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTilesets(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTilesets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setTilesets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::ValueMap& ret = cobj->getProperties(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::ValueMap& ret = cobj->getProperties(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProperties",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_getCurrentString(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getCurrentString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getCurrentString(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentString",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getCurrentString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_setLayerAttribs(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_setLayerAttribs'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setLayerAttribs(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLayerAttribs",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_setLayerAttribs'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::TMXMapInfo* ret = cocos2d::TMXMapInfo::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TMXMapInfo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TMXMapInfo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_createWithXML(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::TMXMapInfo* ret = cocos2d::TMXMapInfo::createWithXML(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TMXMapInfo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TMXMapInfo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithXML",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_createWithXML'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXMapInfo_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TMXMapInfo(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TMXMapInfo"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TMXMapInfo"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TMXMapInfo",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TMXMapInfo_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TMXMapInfo)"); return 0; } int lua_register_cocos2dx_TMXMapInfo(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TMXMapInfo"); tolua_cclass(tolua_S,"TMXMapInfo","cc.TMXMapInfo","",NULL); tolua_beginmodule(tolua_S,"TMXMapInfo"); tolua_function(tolua_S,"setObjectGroups",lua_cocos2dx_TMXMapInfo_setObjectGroups); tolua_function(tolua_S,"setTileSize",lua_cocos2dx_TMXMapInfo_setTileSize); tolua_function(tolua_S,"initWithTMXFile",lua_cocos2dx_TMXMapInfo_initWithTMXFile); tolua_function(tolua_S,"getOrientation",lua_cocos2dx_TMXMapInfo_getOrientation); tolua_function(tolua_S,"isStoringCharacters",lua_cocos2dx_TMXMapInfo_isStoringCharacters); tolua_function(tolua_S,"setLayers",lua_cocos2dx_TMXMapInfo_setLayers); tolua_function(tolua_S,"parseXMLFile",lua_cocos2dx_TMXMapInfo_parseXMLFile); tolua_function(tolua_S,"getParentElement",lua_cocos2dx_TMXMapInfo_getParentElement); tolua_function(tolua_S,"setTMXFileName",lua_cocos2dx_TMXMapInfo_setTMXFileName); tolua_function(tolua_S,"parseXMLString",lua_cocos2dx_TMXMapInfo_parseXMLString); tolua_function(tolua_S,"getLayers",lua_cocos2dx_TMXMapInfo_getLayers); tolua_function(tolua_S,"getTilesets",lua_cocos2dx_TMXMapInfo_getTilesets); tolua_function(tolua_S,"getParentGID",lua_cocos2dx_TMXMapInfo_getParentGID); tolua_function(tolua_S,"setParentElement",lua_cocos2dx_TMXMapInfo_setParentElement); tolua_function(tolua_S,"initWithXML",lua_cocos2dx_TMXMapInfo_initWithXML); tolua_function(tolua_S,"setParentGID",lua_cocos2dx_TMXMapInfo_setParentGID); tolua_function(tolua_S,"getLayerAttribs",lua_cocos2dx_TMXMapInfo_getLayerAttribs); tolua_function(tolua_S,"getTileSize",lua_cocos2dx_TMXMapInfo_getTileSize); tolua_function(tolua_S,"getTileProperties",lua_cocos2dx_TMXMapInfo_getTileProperties); tolua_function(tolua_S,"getObjectGroups",lua_cocos2dx_TMXMapInfo_getObjectGroups); tolua_function(tolua_S,"getTMXFileName",lua_cocos2dx_TMXMapInfo_getTMXFileName); tolua_function(tolua_S,"setCurrentString",lua_cocos2dx_TMXMapInfo_setCurrentString); tolua_function(tolua_S,"setProperties",lua_cocos2dx_TMXMapInfo_setProperties); tolua_function(tolua_S,"setOrientation",lua_cocos2dx_TMXMapInfo_setOrientation); tolua_function(tolua_S,"setTileProperties",lua_cocos2dx_TMXMapInfo_setTileProperties); tolua_function(tolua_S,"setMapSize",lua_cocos2dx_TMXMapInfo_setMapSize); tolua_function(tolua_S,"setStoringCharacters",lua_cocos2dx_TMXMapInfo_setStoringCharacters); tolua_function(tolua_S,"getMapSize",lua_cocos2dx_TMXMapInfo_getMapSize); tolua_function(tolua_S,"setTilesets",lua_cocos2dx_TMXMapInfo_setTilesets); tolua_function(tolua_S,"getProperties",lua_cocos2dx_TMXMapInfo_getProperties); tolua_function(tolua_S,"getCurrentString",lua_cocos2dx_TMXMapInfo_getCurrentString); tolua_function(tolua_S,"setLayerAttribs",lua_cocos2dx_TMXMapInfo_setLayerAttribs); tolua_function(tolua_S,"new",lua_cocos2dx_TMXMapInfo_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TMXMapInfo_create); tolua_function(tolua_S,"createWithXML", lua_cocos2dx_TMXMapInfo_createWithXML); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXMapInfo).name(); g_luaType[typeName] = "cc.TMXMapInfo"; g_typeCast["TMXMapInfo"] = "cc.TMXMapInfo"; return 1; } int lua_cocos2dx_TMXLayer_getTileGIDAt(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getTileGIDAt'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; int ret = cobj->getTileGIDAt(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 2) { cocos2d::Point arg0; cocos2d::ccTMXTileFlags_* arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); #pragma warning NO CONVERSION TO NATIVE FOR ccTMXTileFlags_*; if(!ok) return 0; int ret = cobj->getTileGIDAt(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileGIDAt",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getTileGIDAt'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getPositionAt(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getPositionAt'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->getPositionAt(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPositionAt",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getPositionAt'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setLayerOrientation(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setLayerOrientation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setLayerOrientation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLayerOrientation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setLayerOrientation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_releaseMap(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_releaseMap'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->releaseMap(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "releaseMap",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_releaseMap'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setTiles(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setTiles'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int* arg0; #pragma warning NO CONVERSION TO NATIVE FOR int*; if(!ok) return 0; cobj->setTiles(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTiles",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setTiles'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getLayerSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getLayerSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getLayerSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayerSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getLayerSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setMapTileSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setMapTileSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setMapTileSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMapTileSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setMapTileSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getLayerOrientation(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getLayerOrientation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getLayerOrientation(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayerOrientation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getLayerOrientation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueMap arg0; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setProperties(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProperties",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setLayerName(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setLayerName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLayerName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLayerName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setLayerName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_removeTileAt(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_removeTileAt'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->removeTileAt(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeTileAt",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_removeTileAt'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_initWithTilesetInfo(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_initWithTilesetInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::TMXTilesetInfo* arg0; cocos2d::TMXLayerInfo* arg1; cocos2d::TMXMapInfo* arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.TMXTilesetInfo",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::TMXTilesetInfo*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.TMXLayerInfo",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::TMXLayerInfo*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,4,"cc.TMXMapInfo",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->initWithTilesetInfo(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTilesetInfo",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_initWithTilesetInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setupTiles(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setupTiles'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setupTiles(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setupTiles",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setupTiles'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setTileGID(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setTileGID'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 3) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } cocos2d::Point arg1; ok &= luaval_to_point(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::ccTMXTileFlags_ arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cobj->setTileGID(arg0, arg1, arg2); return 0; } }while(0); ok = true; do{ if (argc == 2) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } cocos2d::Point arg1; ok &= luaval_to_point(tolua_S, 3, &arg1); if (!ok) { break; } cobj->setTileGID(arg0, arg1); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTileGID",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setTileGID'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getMapTileSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getMapTileSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getMapTileSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMapTileSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getMapTileSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getProperty(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getProperty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Value ret = cobj->getProperty(arg0); ccvalue_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProperty",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getProperty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setLayerSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setLayerSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setLayerSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLayerSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setLayerSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getLayerName(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getLayerName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getLayerName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayerName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getLayerName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_setTileSet(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_setTileSet'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TMXTilesetInfo* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.TMXTilesetInfo",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::TMXTilesetInfo*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTileSet(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTileSet",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_setTileSet'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getTileSet(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getTileSet'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::TMXTilesetInfo* ret = cobj->getTileSet(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TMXTilesetInfo"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TMXTilesetInfo*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileSet",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getTileSet'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::ValueMap& ret = cobj->getProperties(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::ValueMap& ret = cobj->getProperties(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProperties",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_getTileAt(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXLayer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXLayer_getTileAt'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Sprite* ret = cobj->getTileAt(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileAt",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_getTileAt'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TMXLayer",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { cocos2d::TMXTilesetInfo* arg0; cocos2d::TMXLayerInfo* arg1; cocos2d::TMXMapInfo* arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.TMXTilesetInfo",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::TMXTilesetInfo*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.TMXLayerInfo",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::TMXLayerInfo*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,4,"cc.TMXMapInfo",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::TMXLayer* ret = cocos2d::TMXLayer::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TMXLayer"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TMXLayer*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXLayer_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TMXLayer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TMXLayer(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TMXLayer"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TMXLayer"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TMXLayer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXLayer_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TMXLayer_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TMXLayer)"); return 0; } int lua_register_cocos2dx_TMXLayer(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TMXLayer"); tolua_cclass(tolua_S,"TMXLayer","cc.TMXLayer","cc.SpriteBatchNode",NULL); tolua_beginmodule(tolua_S,"TMXLayer"); tolua_function(tolua_S,"getTileGIDAt",lua_cocos2dx_TMXLayer_getTileGIDAt); tolua_function(tolua_S,"getPositionAt",lua_cocos2dx_TMXLayer_getPositionAt); tolua_function(tolua_S,"setLayerOrientation",lua_cocos2dx_TMXLayer_setLayerOrientation); tolua_function(tolua_S,"releaseMap",lua_cocos2dx_TMXLayer_releaseMap); tolua_function(tolua_S,"setTiles",lua_cocos2dx_TMXLayer_setTiles); tolua_function(tolua_S,"getLayerSize",lua_cocos2dx_TMXLayer_getLayerSize); tolua_function(tolua_S,"setMapTileSize",lua_cocos2dx_TMXLayer_setMapTileSize); tolua_function(tolua_S,"getLayerOrientation",lua_cocos2dx_TMXLayer_getLayerOrientation); tolua_function(tolua_S,"setProperties",lua_cocos2dx_TMXLayer_setProperties); tolua_function(tolua_S,"setLayerName",lua_cocos2dx_TMXLayer_setLayerName); tolua_function(tolua_S,"removeTileAt",lua_cocos2dx_TMXLayer_removeTileAt); tolua_function(tolua_S,"initWithTilesetInfo",lua_cocos2dx_TMXLayer_initWithTilesetInfo); tolua_function(tolua_S,"setupTiles",lua_cocos2dx_TMXLayer_setupTiles); tolua_function(tolua_S,"setTileGID",lua_cocos2dx_TMXLayer_setTileGID); tolua_function(tolua_S,"getMapTileSize",lua_cocos2dx_TMXLayer_getMapTileSize); tolua_function(tolua_S,"getProperty",lua_cocos2dx_TMXLayer_getProperty); tolua_function(tolua_S,"setLayerSize",lua_cocos2dx_TMXLayer_setLayerSize); tolua_function(tolua_S,"getLayerName",lua_cocos2dx_TMXLayer_getLayerName); tolua_function(tolua_S,"setTileSet",lua_cocos2dx_TMXLayer_setTileSet); tolua_function(tolua_S,"getTileSet",lua_cocos2dx_TMXLayer_getTileSet); tolua_function(tolua_S,"getProperties",lua_cocos2dx_TMXLayer_getProperties); tolua_function(tolua_S,"getTileAt",lua_cocos2dx_TMXLayer_getTileAt); tolua_function(tolua_S,"new",lua_cocos2dx_TMXLayer_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TMXLayer_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXLayer).name(); g_luaType[typeName] = "cc.TMXLayer"; g_typeCast["TMXLayer"] = "cc.TMXLayer"; return 1; } int lua_cocos2dx_TMXTiledMap_setObjectGroups(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_setObjectGroups'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setObjectGroups(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setObjectGroups",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_setObjectGroups'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getProperty(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getProperty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Value ret = cobj->getProperty(arg0); ccvalue_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProperty",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getProperty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_setMapSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_setMapSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setMapSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMapSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_setMapSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getObjectGroup(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getObjectGroup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::TMXObjectGroup* ret = cobj->getObjectGroup(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TMXObjectGroup"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TMXObjectGroup*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getObjectGroup",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getObjectGroup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getObjectGroups(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getObjectGroups'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cocos2d::Vector& ret = cobj->getObjectGroups(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const cocos2d::Vector& ret = cobj->getObjectGroups(); ccvector_to_luaval(tolua_S, ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getObjectGroups",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getObjectGroups'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getTileSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getTileSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getTileSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getTileSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getMapSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getMapSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getMapSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMapSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getMapSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueMap& ret = cobj->getProperties(); ccvaluemap_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProperties",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getPropertiesForGID(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getPropertiesForGID'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Value ret = cobj->getPropertiesForGID(arg0); ccvalue_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPropertiesForGID",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getPropertiesForGID'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_setTileSize(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_setTileSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTileSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTileSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_setTileSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_setProperties(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_setProperties'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ValueMap arg0; ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setProperties(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProperties",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_setProperties'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getLayer(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getLayer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::TMXLayer* ret = cobj->getLayer(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TMXLayer"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TMXLayer*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getLayer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_getMapOrientation(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_getMapOrientation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getMapOrientation(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMapOrientation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_getMapOrientation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_setMapOrientation(lua_State* tolua_S) { int argc = 0; cocos2d::TMXTiledMap* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TMXTiledMap*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXTiledMap_setMapOrientation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setMapOrientation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMapOrientation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_setMapOrientation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::TMXTiledMap* ret = cocos2d::TMXTiledMap::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TMXTiledMap"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TMXTiledMap*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TMXTiledMap_createWithXML(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TMXTiledMap",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::TMXTiledMap* ret = cocos2d::TMXTiledMap::createWithXML(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TMXTiledMap"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TMXTiledMap*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithXML",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXTiledMap_createWithXML'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TMXTiledMap_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TMXTiledMap)"); return 0; } int lua_register_cocos2dx_TMXTiledMap(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TMXTiledMap"); tolua_cclass(tolua_S,"TMXTiledMap","cc.TMXTiledMap","cc.Node",NULL); tolua_beginmodule(tolua_S,"TMXTiledMap"); tolua_function(tolua_S,"setObjectGroups",lua_cocos2dx_TMXTiledMap_setObjectGroups); tolua_function(tolua_S,"getProperty",lua_cocos2dx_TMXTiledMap_getProperty); tolua_function(tolua_S,"setMapSize",lua_cocos2dx_TMXTiledMap_setMapSize); tolua_function(tolua_S,"getObjectGroup",lua_cocos2dx_TMXTiledMap_getObjectGroup); tolua_function(tolua_S,"getObjectGroups",lua_cocos2dx_TMXTiledMap_getObjectGroups); tolua_function(tolua_S,"getTileSize",lua_cocos2dx_TMXTiledMap_getTileSize); tolua_function(tolua_S,"getMapSize",lua_cocos2dx_TMXTiledMap_getMapSize); tolua_function(tolua_S,"getProperties",lua_cocos2dx_TMXTiledMap_getProperties); tolua_function(tolua_S,"getPropertiesForGID",lua_cocos2dx_TMXTiledMap_getPropertiesForGID); tolua_function(tolua_S,"setTileSize",lua_cocos2dx_TMXTiledMap_setTileSize); tolua_function(tolua_S,"setProperties",lua_cocos2dx_TMXTiledMap_setProperties); tolua_function(tolua_S,"getLayer",lua_cocos2dx_TMXTiledMap_getLayer); tolua_function(tolua_S,"getMapOrientation",lua_cocos2dx_TMXTiledMap_getMapOrientation); tolua_function(tolua_S,"setMapOrientation",lua_cocos2dx_TMXTiledMap_setMapOrientation); tolua_function(tolua_S,"create", lua_cocos2dx_TMXTiledMap_create); tolua_function(tolua_S,"createWithXML", lua_cocos2dx_TMXTiledMap_createWithXML); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXTiledMap).name(); g_luaType[typeName] = "cc.TMXTiledMap"; g_typeCast["TMXTiledMap"] = "cc.TMXTiledMap"; return 1; } int lua_cocos2dx_TileMapAtlas_initWithTileFile(lua_State* tolua_S) { int argc = 0; cocos2d::TileMapAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TileMapAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TileMapAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TileMapAtlas_initWithTileFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { std::string arg0; std::string arg1; int arg2; int arg3; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; bool ret = cobj->initWithTileFile(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTileFile",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TileMapAtlas_initWithTileFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TileMapAtlas_releaseMap(lua_State* tolua_S) { int argc = 0; cocos2d::TileMapAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TileMapAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TileMapAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TileMapAtlas_releaseMap'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->releaseMap(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "releaseMap",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TileMapAtlas_releaseMap'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TileMapAtlas_getTGAInfo(lua_State* tolua_S) { int argc = 0; cocos2d::TileMapAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TileMapAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TileMapAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TileMapAtlas_getTGAInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::sImageTGA* ret = cobj->getTGAInfo(); #pragma warning NO CONVERSION FROM NATIVE FOR sImageTGA*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTGAInfo",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TileMapAtlas_getTGAInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TileMapAtlas_getTileAt(lua_State* tolua_S) { int argc = 0; cocos2d::TileMapAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TileMapAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TileMapAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TileMapAtlas_getTileAt'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Color3B ret = cobj->getTileAt(arg0); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileAt",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TileMapAtlas_getTileAt'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TileMapAtlas_setTile(lua_State* tolua_S) { int argc = 0; cocos2d::TileMapAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TileMapAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TileMapAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TileMapAtlas_setTile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Color3B arg0; cocos2d::Point arg1; ok &= luaval_to_color3b(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cobj->setTile(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TileMapAtlas_setTile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TileMapAtlas_setTGAInfo(lua_State* tolua_S) { int argc = 0; cocos2d::TileMapAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TileMapAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::TileMapAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TileMapAtlas_setTGAInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::sImageTGA* arg0; #pragma warning NO CONVERSION TO NATIVE FOR sImageTGA*; if(!ok) return 0; cobj->setTGAInfo(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTGAInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TileMapAtlas_setTGAInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TileMapAtlas_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TileMapAtlas",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { std::string arg0; std::string arg1; int arg2; int arg3; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cocos2d::TileMapAtlas* ret = cocos2d::TileMapAtlas::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TileMapAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::TileMapAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TileMapAtlas_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_TileMapAtlas_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::TileMapAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::TileMapAtlas(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TileMapAtlas"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TileMapAtlas"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TileMapAtlas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TileMapAtlas_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_TileMapAtlas_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TileMapAtlas)"); return 0; } int lua_register_cocos2dx_TileMapAtlas(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TileMapAtlas"); tolua_cclass(tolua_S,"TileMapAtlas","cc.TileMapAtlas","cc.AtlasNode",NULL); tolua_beginmodule(tolua_S,"TileMapAtlas"); tolua_function(tolua_S,"initWithTileFile",lua_cocos2dx_TileMapAtlas_initWithTileFile); tolua_function(tolua_S,"releaseMap",lua_cocos2dx_TileMapAtlas_releaseMap); tolua_function(tolua_S,"getTGAInfo",lua_cocos2dx_TileMapAtlas_getTGAInfo); tolua_function(tolua_S,"getTileAt",lua_cocos2dx_TileMapAtlas_getTileAt); tolua_function(tolua_S,"setTile",lua_cocos2dx_TileMapAtlas_setTile); tolua_function(tolua_S,"setTGAInfo",lua_cocos2dx_TileMapAtlas_setTGAInfo); tolua_function(tolua_S,"new",lua_cocos2dx_TileMapAtlas_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TileMapAtlas_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TileMapAtlas).name(); g_luaType[typeName] = "cc.TileMapAtlas"; g_typeCast["TileMapAtlas"] = "cc.TileMapAtlas"; return 1; } int lua_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches(lua_State* tolua_S) { int argc = 0; cocos2d::EventListenerTouchOneByOne* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventListenerTouchOneByOne",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventListenerTouchOneByOne*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSwallowTouches(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSwallowTouches",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EventListenerTouchOneByOne_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerTouchOneByOne)"); return 0; } int lua_register_cocos2dx_EventListenerTouchOneByOne(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerTouchOneByOne"); tolua_cclass(tolua_S,"EventListenerTouchOneByOne","cc.EventListenerTouchOneByOne","cc.EventListener",NULL); tolua_beginmodule(tolua_S,"EventListenerTouchOneByOne"); tolua_function(tolua_S,"setSwallowTouches",lua_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerTouchOneByOne).name(); g_luaType[typeName] = "cc.EventListenerTouchOneByOne"; g_typeCast["EventListenerTouchOneByOne"] = "cc.EventListenerTouchOneByOne"; return 1; } static int lua_cocos2dx_EventListenerTouchAllAtOnce_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerTouchAllAtOnce)"); return 0; } int lua_register_cocos2dx_EventListenerTouchAllAtOnce(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerTouchAllAtOnce"); tolua_cclass(tolua_S,"EventListenerTouchAllAtOnce","cc.EventListenerTouchAllAtOnce","cc.EventListener",NULL); tolua_beginmodule(tolua_S,"EventListenerTouchAllAtOnce"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerTouchAllAtOnce).name(); g_luaType[typeName] = "cc.EventListenerTouchAllAtOnce"; g_typeCast["EventListenerTouchAllAtOnce"] = "cc.EventListenerTouchAllAtOnce"; return 1; } static int lua_cocos2dx_EventListenerKeyboard_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerKeyboard)"); return 0; } int lua_register_cocos2dx_EventListenerKeyboard(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerKeyboard"); tolua_cclass(tolua_S,"EventListenerKeyboard","cc.EventListenerKeyboard","cc.EventListener",NULL); tolua_beginmodule(tolua_S,"EventListenerKeyboard"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerKeyboard).name(); g_luaType[typeName] = "cc.EventListenerKeyboard"; g_typeCast["EventListenerKeyboard"] = "cc.EventListenerKeyboard"; return 1; } int lua_cocos2dx_EventMouse_getMouseButton(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getMouseButton'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getMouseButton(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMouseButton",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getMouseButton'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventMouse_setScrollData(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_setScrollData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; double arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setScrollData(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScrollData",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_setScrollData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventMouse_setMouseButton(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_setMouseButton'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setMouseButton(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMouseButton",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_setMouseButton'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventMouse_getScrollY(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getScrollY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScrollY(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScrollY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getScrollY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventMouse_getScrollX(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getScrollX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScrollX(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScrollX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getScrollX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventMouse_getCursorX(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getCursorX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getCursorX(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCursorX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getCursorX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventMouse_getCursorY(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getCursorY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getCursorY(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCursorY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getCursorY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventMouse_setCursorPosition(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_setCursorPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; double arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setCursorPosition(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCursorPosition",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_setCursorPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventMouse_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::EventMouse* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::EventMouse::MouseEventType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj = new cocos2d::EventMouse(arg0); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventMouse"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.EventMouse"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EventMouse",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EventMouse_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventMouse)"); return 0; } int lua_register_cocos2dx_EventMouse(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventMouse"); tolua_cclass(tolua_S,"EventMouse","cc.EventMouse","cc.Event",NULL); tolua_beginmodule(tolua_S,"EventMouse"); tolua_function(tolua_S,"getMouseButton",lua_cocos2dx_EventMouse_getMouseButton); tolua_function(tolua_S,"setScrollData",lua_cocos2dx_EventMouse_setScrollData); tolua_function(tolua_S,"setMouseButton",lua_cocos2dx_EventMouse_setMouseButton); tolua_function(tolua_S,"getScrollY",lua_cocos2dx_EventMouse_getScrollY); tolua_function(tolua_S,"getScrollX",lua_cocos2dx_EventMouse_getScrollX); tolua_function(tolua_S,"getCursorX",lua_cocos2dx_EventMouse_getCursorX); tolua_function(tolua_S,"getCursorY",lua_cocos2dx_EventMouse_getCursorY); tolua_function(tolua_S,"setCursorPosition",lua_cocos2dx_EventMouse_setCursorPosition); tolua_function(tolua_S,"new",lua_cocos2dx_EventMouse_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventMouse).name(); g_luaType[typeName] = "cc.EventMouse"; g_typeCast["EventMouse"] = "cc.EventMouse"; return 1; } static int lua_cocos2dx_EventListenerMouse_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerMouse)"); return 0; } int lua_register_cocos2dx_EventListenerMouse(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerMouse"); tolua_cclass(tolua_S,"EventListenerMouse","cc.EventListenerMouse","cc.EventListener",NULL); tolua_beginmodule(tolua_S,"EventListenerMouse"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerMouse).name(); g_luaType[typeName] = "cc.EventListenerMouse"; g_typeCast["EventListenerMouse"] = "cc.EventListenerMouse"; return 1; } static int lua_cocos2dx_EventAcceleration_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventAcceleration)"); return 0; } int lua_register_cocos2dx_EventAcceleration(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventAcceleration"); tolua_cclass(tolua_S,"EventAcceleration","cc.EventAcceleration","cc.Event",NULL); tolua_beginmodule(tolua_S,"EventAcceleration"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventAcceleration).name(); g_luaType[typeName] = "cc.EventAcceleration"; g_typeCast["EventAcceleration"] = "cc.EventAcceleration"; return 1; } static int lua_cocos2dx_EventListenerAcceleration_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerAcceleration)"); return 0; } int lua_register_cocos2dx_EventListenerAcceleration(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerAcceleration"); tolua_cclass(tolua_S,"EventListenerAcceleration","cc.EventListenerAcceleration","cc.EventListener",NULL); tolua_beginmodule(tolua_S,"EventListenerAcceleration"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerAcceleration).name(); g_luaType[typeName] = "cc.EventListenerAcceleration"; g_typeCast["EventListenerAcceleration"] = "cc.EventListenerAcceleration"; return 1; } int lua_cocos2dx_EventCustom_getEventName(lua_State* tolua_S) { int argc = 0; cocos2d::EventCustom* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventCustom",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventCustom*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventCustom_getEventName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getEventName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEventName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventCustom_getEventName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventCustom_setUserData(lua_State* tolua_S) { int argc = 0; cocos2d::EventCustom* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventCustom",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventCustom*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventCustom_setUserData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { void* arg0; #pragma warning NO CONVERSION TO NATIVE FOR void*; if(!ok) return 0; cobj->setUserData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUserData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventCustom_setUserData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventCustom_getUserData(lua_State* tolua_S) { int argc = 0; cocos2d::EventCustom* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventCustom",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventCustom*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventCustom_getUserData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; void* ret = cobj->getUserData(); #pragma warning NO CONVERSION FROM NATIVE FOR void*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUserData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventCustom_getUserData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_EventCustom_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::EventCustom* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj = new cocos2d::EventCustom(arg0); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventCustom"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.EventCustom"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EventCustom",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventCustom_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_EventCustom_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventCustom)"); return 0; } int lua_register_cocos2dx_EventCustom(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventCustom"); tolua_cclass(tolua_S,"EventCustom","cc.EventCustom","cc.Event",NULL); tolua_beginmodule(tolua_S,"EventCustom"); tolua_function(tolua_S,"getEventName",lua_cocos2dx_EventCustom_getEventName); tolua_function(tolua_S,"setUserData",lua_cocos2dx_EventCustom_setUserData); tolua_function(tolua_S,"getUserData",lua_cocos2dx_EventCustom_getUserData); tolua_function(tolua_S,"new",lua_cocos2dx_EventCustom_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventCustom).name(); g_luaType[typeName] = "cc.EventCustom"; g_typeCast["EventCustom"] = "cc.EventCustom"; return 1; } int lua_cocos2dx_Timer_getInterval(lua_State* tolua_S) { int argc = 0; cocos2d::Timer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Timer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Timer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Timer_getInterval'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getInterval(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInterval",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Timer_getInterval'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Timer_setInterval(lua_State* tolua_S) { int argc = 0; cocos2d::Timer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Timer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Timer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Timer_setInterval'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setInterval(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInterval",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Timer_setInterval'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Timer_initWithScriptHandler(lua_State* tolua_S) { int argc = 0; cocos2d::Timer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Timer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Timer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Timer_initWithScriptHandler'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; double arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; bool ret = cobj->initWithScriptHandler(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithScriptHandler",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Timer_initWithScriptHandler'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Timer_update(lua_State* tolua_S) { int argc = 0; cocos2d::Timer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Timer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Timer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Timer_update'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->update(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "update",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Timer_update'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Timer_getScriptHandler(lua_State* tolua_S) { int argc = 0; cocos2d::Timer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Timer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Timer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Timer_getScriptHandler'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getScriptHandler(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScriptHandler",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Timer_getScriptHandler'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Timer_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Timer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Timer(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Timer"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Timer"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Timer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Timer_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Timer_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Timer)"); return 0; } int lua_register_cocos2dx_Timer(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Timer"); tolua_cclass(tolua_S,"Timer","cc.Timer","cc.Object",NULL); tolua_beginmodule(tolua_S,"Timer"); tolua_function(tolua_S,"getInterval",lua_cocos2dx_Timer_getInterval); tolua_function(tolua_S,"setInterval",lua_cocos2dx_Timer_setInterval); tolua_function(tolua_S,"initWithScriptHandler",lua_cocos2dx_Timer_initWithScriptHandler); tolua_function(tolua_S,"update",lua_cocos2dx_Timer_update); tolua_function(tolua_S,"getScriptHandler",lua_cocos2dx_Timer_getScriptHandler); tolua_function(tolua_S,"new",lua_cocos2dx_Timer_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Timer).name(); g_luaType[typeName] = "cc.Timer"; g_typeCast["Timer"] = "cc.Timer"; return 1; } int lua_cocos2dx_Scheduler_setTimeScale(lua_State* tolua_S) { int argc = 0; cocos2d::Scheduler* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scheduler",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Scheduler*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Scheduler_setTimeScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTimeScale(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTimeScale",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scheduler_setTimeScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Scheduler_performFunctionInCocosThread(lua_State* tolua_S) { int argc = 0; cocos2d::Scheduler* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scheduler",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Scheduler*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Scheduler_performFunctionInCocosThread'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::function arg0; do { // Lambda binding for lua is not supported. assert(false); } while(0) ; if(!ok) return 0; cobj->performFunctionInCocosThread(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "performFunctionInCocosThread",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scheduler_performFunctionInCocosThread'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Scheduler_getTimeScale(lua_State* tolua_S) { int argc = 0; cocos2d::Scheduler* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scheduler",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Scheduler*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Scheduler_getTimeScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getTimeScale(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTimeScale",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scheduler_getTimeScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Scheduler_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::Scheduler* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::Scheduler(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Scheduler"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Scheduler"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Scheduler",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scheduler_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Scheduler_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Scheduler)"); return 0; } int lua_register_cocos2dx_Scheduler(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Scheduler"); tolua_cclass(tolua_S,"Scheduler","cc.Scheduler","cc.Object",NULL); tolua_beginmodule(tolua_S,"Scheduler"); tolua_function(tolua_S,"setTimeScale",lua_cocos2dx_Scheduler_setTimeScale); tolua_function(tolua_S,"performFunctionInCocosThread",lua_cocos2dx_Scheduler_performFunctionInCocosThread); tolua_function(tolua_S,"getTimeScale",lua_cocos2dx_Scheduler_getTimeScale); tolua_function(tolua_S,"new",lua_cocos2dx_Scheduler_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Scheduler).name(); g_luaType[typeName] = "cc.Scheduler"; g_typeCast["Scheduler"] = "cc.Scheduler"; return 1; } int lua_cocos2dx_Component_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_setName(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_isEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_isEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_isEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_serialize(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_serialize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { void* arg0; #pragma warning NO CONVERSION TO NATIVE FOR void*; if(!ok) return 0; bool ret = cobj->serialize(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "serialize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_serialize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_update(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_update'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->update(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "update",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_update'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_getOwner(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_getOwner'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getOwner(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOwner",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_getOwner'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_init(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_setOwner(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setOwner'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setOwner(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOwner",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setOwner'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_getName(lua_State* tolua_S) { int argc = 0; cocos2d::Component* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_getName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_getName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_Component_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Component* ret = cocos2d::Component::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Component"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Component*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Component_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Component)"); return 0; } int lua_register_cocos2dx_Component(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Component"); tolua_cclass(tolua_S,"Component","cc.Component","cc.Object",NULL); tolua_beginmodule(tolua_S,"Component"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_Component_setEnabled); tolua_function(tolua_S,"setName",lua_cocos2dx_Component_setName); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_Component_isEnabled); tolua_function(tolua_S,"serialize",lua_cocos2dx_Component_serialize); tolua_function(tolua_S,"update",lua_cocos2dx_Component_update); tolua_function(tolua_S,"getOwner",lua_cocos2dx_Component_getOwner); tolua_function(tolua_S,"init",lua_cocos2dx_Component_init); tolua_function(tolua_S,"setOwner",lua_cocos2dx_Component_setOwner); tolua_function(tolua_S,"getName",lua_cocos2dx_Component_getName); tolua_function(tolua_S,"create", lua_cocos2dx_Component_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Component).name(); g_luaType[typeName] = "cc.Component"; g_typeCast["Component"] = "cc.Component"; return 1; } int lua_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->preloadBackgroundMusic(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "preloadBackgroundMusic",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_stopBackgroundMusic(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_stopBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stopBackgroundMusic(); return 0; } if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->stopBackgroundMusic(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_stopBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_stopAllEffects(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_stopAllEffects'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stopAllEffects(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopAllEffects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_stopAllEffects'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getBackgroundMusicVolume(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackgroundMusicVolume",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resumeBackgroundMusic(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBackgroundMusicVolume(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackgroundMusicVolume",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_preloadEffect(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_preloadEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->preloadEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "preloadEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_preloadEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isBackgroundMusicPlaying(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isBackgroundMusicPlaying",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_getEffectsVolume(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_getEffectsVolume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEffectsVolume(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEffectsVolume",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_getEffectsVolume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->willPlayBackgroundMusic(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "willPlayBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_pauseEffect(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_pauseEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->pauseEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_pauseEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_playEffect(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_playEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; unsigned int ret = cobj->playEffect(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 2) { const char* arg0; bool arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; unsigned int ret = cobj->playEffect(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 3) { const char* arg0; bool arg1; double arg2; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; unsigned int ret = cobj->playEffect(arg0, arg1, arg2); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 4) { const char* arg0; bool arg1; double arg2; double arg3; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; unsigned int ret = cobj->playEffect(arg0, arg1, arg2, arg3); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 5) { const char* arg0; bool arg1; double arg2; double arg3; double arg4; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 3,&arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); ok &= luaval_to_number(tolua_S, 6,&arg4); if(!ok) return 0; unsigned int ret = cobj->playEffect(arg0, arg1, arg2, arg3, arg4); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "playEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_playEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->rewindBackgroundMusic(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rewindBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_playBackgroundMusic(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_playBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->playBackgroundMusic(arg0); return 0; } if (argc == 2) { const char* arg0; bool arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->playBackgroundMusic(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "playBackgroundMusic",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_playBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_resumeAllEffects(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_resumeAllEffects'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resumeAllEffects(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeAllEffects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_resumeAllEffects'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_setEffectsVolume(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_setEffectsVolume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEffectsVolume(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEffectsVolume",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_setEffectsVolume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_stopEffect(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_stopEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->stopEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_stopEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pauseBackgroundMusic(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_pauseAllEffects(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_pauseAllEffects'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pauseAllEffects(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseAllEffects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_pauseAllEffects'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_unloadEffect(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_unloadEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->unloadEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "unloadEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_unloadEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_resumeEffect(lua_State* tolua_S) { int argc = 0; CocosDenshion::SimpleAudioEngine* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif cobj = (CocosDenshion::SimpleAudioEngine*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SimpleAudioEngine_resumeEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->resumeEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_resumeEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_end(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; CocosDenshion::SimpleAudioEngine::end(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "end",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_end'.",&tolua_err); #endif return 0; } int lua_cocos2dx_SimpleAudioEngine_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.SimpleAudioEngine",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; CocosDenshion::SimpleAudioEngine* ret = CocosDenshion::SimpleAudioEngine::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.SimpleAudioEngine"; } cocos2d::Object *dynObject = dynamic_cast((CocosDenshion::SimpleAudioEngine*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SimpleAudioEngine_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_SimpleAudioEngine_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SimpleAudioEngine)"); return 0; } int lua_register_cocos2dx_SimpleAudioEngine(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.SimpleAudioEngine"); tolua_cclass(tolua_S,"SimpleAudioEngine","cc.SimpleAudioEngine","",NULL); tolua_beginmodule(tolua_S,"SimpleAudioEngine"); tolua_function(tolua_S,"preloadMusic",lua_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic); tolua_function(tolua_S,"stopMusic",lua_cocos2dx_SimpleAudioEngine_stopBackgroundMusic); tolua_function(tolua_S,"stopAllEffects",lua_cocos2dx_SimpleAudioEngine_stopAllEffects); tolua_function(tolua_S,"getMusicVolume",lua_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume); tolua_function(tolua_S,"resumeMusic",lua_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic); tolua_function(tolua_S,"setMusicVolume",lua_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume); tolua_function(tolua_S,"preloadEffect",lua_cocos2dx_SimpleAudioEngine_preloadEffect); tolua_function(tolua_S,"isMusicPlaying",lua_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying); tolua_function(tolua_S,"getEffectsVolume",lua_cocos2dx_SimpleAudioEngine_getEffectsVolume); tolua_function(tolua_S,"willPlayMusic",lua_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic); tolua_function(tolua_S,"pauseEffect",lua_cocos2dx_SimpleAudioEngine_pauseEffect); tolua_function(tolua_S,"playEffect",lua_cocos2dx_SimpleAudioEngine_playEffect); tolua_function(tolua_S,"rewindMusic",lua_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic); tolua_function(tolua_S,"playMusic",lua_cocos2dx_SimpleAudioEngine_playBackgroundMusic); tolua_function(tolua_S,"resumeAllEffects",lua_cocos2dx_SimpleAudioEngine_resumeAllEffects); tolua_function(tolua_S,"setEffectsVolume",lua_cocos2dx_SimpleAudioEngine_setEffectsVolume); tolua_function(tolua_S,"stopEffect",lua_cocos2dx_SimpleAudioEngine_stopEffect); tolua_function(tolua_S,"pauseMusic",lua_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic); tolua_function(tolua_S,"pauseAllEffects",lua_cocos2dx_SimpleAudioEngine_pauseAllEffects); tolua_function(tolua_S,"unloadEffect",lua_cocos2dx_SimpleAudioEngine_unloadEffect); tolua_function(tolua_S,"resumeEffect",lua_cocos2dx_SimpleAudioEngine_resumeEffect); tolua_function(tolua_S,"end", lua_cocos2dx_SimpleAudioEngine_end); tolua_function(tolua_S,"getInstance", lua_cocos2dx_SimpleAudioEngine_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(CocosDenshion::SimpleAudioEngine).name(); g_luaType[typeName] = "cc.SimpleAudioEngine"; g_typeCast["SimpleAudioEngine"] = "cc.SimpleAudioEngine"; return 1; } TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,"cc",0); tolua_beginmodule(tolua_S,"cc"); lua_register_cocos2dx_Object(tolua_S); lua_register_cocos2dx_Action(tolua_S); lua_register_cocos2dx_FiniteTimeAction(tolua_S); lua_register_cocos2dx_ActionInstant(tolua_S); lua_register_cocos2dx_Hide(tolua_S); lua_register_cocos2dx_Node(tolua_S); lua_register_cocos2dx_Scene(tolua_S); lua_register_cocos2dx_TransitionScene(tolua_S); lua_register_cocos2dx_TransitionEaseScene(tolua_S); lua_register_cocos2dx_TransitionMoveInL(tolua_S); lua_register_cocos2dx_TransitionMoveInB(tolua_S); lua_register_cocos2dx_AtlasNode(tolua_S); lua_register_cocos2dx_TileMapAtlas(tolua_S); lua_register_cocos2dx_TransitionMoveInT(tolua_S); lua_register_cocos2dx_TMXTilesetInfo(tolua_S); lua_register_cocos2dx_TransitionMoveInR(tolua_S); lua_register_cocos2dx_ParticleSystem(tolua_S); lua_register_cocos2dx_ParticleSystemQuad(tolua_S); lua_register_cocos2dx_ParticleSnow(tolua_S); lua_register_cocos2dx_AnimationCache(tolua_S); lua_register_cocos2dx_ActionInterval(tolua_S); lua_register_cocos2dx_ActionCamera(tolua_S); lua_register_cocos2dx_ProgressFromTo(tolua_S); lua_register_cocos2dx_EventListener(tolua_S); lua_register_cocos2dx_EventListenerMouse(tolua_S); lua_register_cocos2dx_MoveBy(tolua_S); lua_register_cocos2dx_MoveTo(tolua_S); lua_register_cocos2dx_JumpBy(tolua_S); lua_register_cocos2dx_EventListenerKeyboard(tolua_S); lua_register_cocos2dx_TransitionRotoZoom(tolua_S); lua_register_cocos2dx_Director(tolua_S); lua_register_cocos2dx_Texture2D(tolua_S); lua_register_cocos2dx_ActionEase(tolua_S); lua_register_cocos2dx_EaseElastic(tolua_S); lua_register_cocos2dx_EaseElasticOut(tolua_S); lua_register_cocos2dx_EaseBackOut(tolua_S); lua_register_cocos2dx_TransitionSceneOriented(tolua_S); lua_register_cocos2dx_TransitionFlipX(tolua_S); lua_register_cocos2dx_Event(tolua_S); lua_register_cocos2dx_EventAcceleration(tolua_S); lua_register_cocos2dx_Spawn(tolua_S); lua_register_cocos2dx_ParticleBatchNode(tolua_S); lua_register_cocos2dx_SimpleAudioEngine(tolua_S); lua_register_cocos2dx_SkewTo(tolua_S); lua_register_cocos2dx_SkewBy(tolua_S); lua_register_cocos2dx_TransitionProgress(tolua_S); lua_register_cocos2dx_TransitionProgressVertical(tolua_S); lua_register_cocos2dx_Layer(tolua_S); lua_register_cocos2dx_TMXTiledMap(tolua_S); lua_register_cocos2dx_GridAction(tolua_S); lua_register_cocos2dx_Grid3DAction(tolua_S); lua_register_cocos2dx_FadeIn(tolua_S); lua_register_cocos2dx_EventListenerCustom(tolua_S); lua_register_cocos2dx_FlipX3D(tolua_S); lua_register_cocos2dx_FlipY3D(tolua_S); lua_register_cocos2dx_EaseSineInOut(tolua_S); lua_register_cocos2dx_TransitionFlipAngular(tolua_S); lua_register_cocos2dx_EGLViewProtocol(tolua_S); lua_register_cocos2dx_EGLView(tolua_S); lua_register_cocos2dx_EaseElasticInOut(tolua_S); lua_register_cocos2dx_EaseBounce(tolua_S); lua_register_cocos2dx_Show(tolua_S); lua_register_cocos2dx_FadeOut(tolua_S); lua_register_cocos2dx_CallFunc(tolua_S); lua_register_cocos2dx_EventMouse(tolua_S); lua_register_cocos2dx_Waves3D(tolua_S); lua_register_cocos2dx_ParticleFireworks(tolua_S); lua_register_cocos2dx_MenuItem(tolua_S); lua_register_cocos2dx_MenuItemSprite(tolua_S); lua_register_cocos2dx_MenuItemImage(tolua_S); lua_register_cocos2dx_ParticleFire(tolua_S); lua_register_cocos2dx_TransitionZoomFlipAngular(tolua_S); lua_register_cocos2dx_EaseRateAction(tolua_S); lua_register_cocos2dx_EaseIn(tolua_S); lua_register_cocos2dx_EaseExponentialInOut(tolua_S); lua_register_cocos2dx_EaseBackInOut(tolua_S); lua_register_cocos2dx_EaseExponentialOut(tolua_S); lua_register_cocos2dx_SpriteBatchNode(tolua_S); lua_register_cocos2dx_Label(tolua_S); lua_register_cocos2dx_Application(tolua_S); lua_register_cocos2dx_DelayTime(tolua_S); lua_register_cocos2dx_LabelAtlas(tolua_S); lua_register_cocos2dx_LabelBMFont(tolua_S); lua_register_cocos2dx_TransitionFadeTR(tolua_S); lua_register_cocos2dx_TransitionFadeBL(tolua_S); lua_register_cocos2dx_EaseElasticIn(tolua_S); lua_register_cocos2dx_ParticleSpiral(tolua_S); lua_register_cocos2dx_TiledGrid3DAction(tolua_S); lua_register_cocos2dx_FadeOutTRTiles(tolua_S); lua_register_cocos2dx_FadeOutUpTiles(tolua_S); lua_register_cocos2dx_FadeOutDownTiles(tolua_S); lua_register_cocos2dx_TextureCache(tolua_S); lua_register_cocos2dx_ActionTween(tolua_S); lua_register_cocos2dx_TransitionFadeDown(tolua_S); lua_register_cocos2dx_ParticleSun(tolua_S); lua_register_cocos2dx_TransitionProgressHorizontal(tolua_S); lua_register_cocos2dx_TMXObjectGroup(tolua_S); lua_register_cocos2dx_TMXLayer(tolua_S); lua_register_cocos2dx_FlipX(tolua_S); lua_register_cocos2dx_FlipY(tolua_S); lua_register_cocos2dx_EventKeyboard(tolua_S); lua_register_cocos2dx_TransitionSplitCols(tolua_S); lua_register_cocos2dx_Timer(tolua_S); lua_register_cocos2dx_FadeTo(tolua_S); lua_register_cocos2dx_Repeat(tolua_S); lua_register_cocos2dx_Place(tolua_S); lua_register_cocos2dx_EventListenerAcceleration(tolua_S); lua_register_cocos2dx_GLProgram(tolua_S); lua_register_cocos2dx_EaseBounceOut(tolua_S); lua_register_cocos2dx_RenderTexture(tolua_S); lua_register_cocos2dx_TintBy(tolua_S); lua_register_cocos2dx_TransitionShrinkGrow(tolua_S); lua_register_cocos2dx_Sprite(tolua_S); lua_register_cocos2dx_LabelTTF(tolua_S); lua_register_cocos2dx_ClippingNode(tolua_S); lua_register_cocos2dx_ParticleFlower(tolua_S); lua_register_cocos2dx_ParticleSmoke(tolua_S); lua_register_cocos2dx_Image(tolua_S); lua_register_cocos2dx_LayerMultiplex(tolua_S); lua_register_cocos2dx_Blink(tolua_S); lua_register_cocos2dx_ShaderCache(tolua_S); lua_register_cocos2dx_JumpTo(tolua_S); lua_register_cocos2dx_ParticleExplosion(tolua_S); lua_register_cocos2dx_TransitionJumpZoom(tolua_S); lua_register_cocos2dx_Touch(tolua_S); lua_register_cocos2dx_AnimationFrame(tolua_S); lua_register_cocos2dx_NodeGrid(tolua_S); lua_register_cocos2dx_TMXLayerInfo(tolua_S); lua_register_cocos2dx_EaseBounceIn(tolua_S); lua_register_cocos2dx_GridBase(tolua_S); lua_register_cocos2dx_TiledGrid3D(tolua_S); lua_register_cocos2dx_ParticleGalaxy(tolua_S); lua_register_cocos2dx_Twirl(tolua_S); lua_register_cocos2dx_MenuItemLabel(tolua_S); lua_register_cocos2dx_LayerColor(tolua_S); lua_register_cocos2dx_FadeOutBLTiles(tolua_S); lua_register_cocos2dx_LayerGradient(tolua_S); lua_register_cocos2dx_TargetedAction(tolua_S); lua_register_cocos2dx_RepeatForever(tolua_S); lua_register_cocos2dx_CardinalSplineTo(tolua_S); lua_register_cocos2dx_CardinalSplineBy(tolua_S); lua_register_cocos2dx_TransitionFlipY(tolua_S); lua_register_cocos2dx_TurnOffTiles(tolua_S); lua_register_cocos2dx_TintTo(tolua_S); lua_register_cocos2dx_CatmullRomTo(tolua_S); lua_register_cocos2dx_ToggleVisibility(tolua_S); lua_register_cocos2dx_DrawNode(tolua_S); lua_register_cocos2dx_TransitionTurnOffTiles(tolua_S); lua_register_cocos2dx_RotateTo(tolua_S); lua_register_cocos2dx_TransitionSplitRows(tolua_S); lua_register_cocos2dx_TransitionProgressRadialCCW(tolua_S); lua_register_cocos2dx_ScaleTo(tolua_S); lua_register_cocos2dx_TransitionPageTurn(tolua_S); lua_register_cocos2dx_BezierBy(tolua_S); lua_register_cocos2dx_BezierTo(tolua_S); lua_register_cocos2dx_Menu(tolua_S); lua_register_cocos2dx_SpriteFrame(tolua_S); lua_register_cocos2dx_ActionManager(tolua_S); lua_register_cocos2dx_TransitionFade(tolua_S); lua_register_cocos2dx_TransitionZoomFlipX(tolua_S); lua_register_cocos2dx_EventListenerTouchAllAtOnce(tolua_S); lua_register_cocos2dx_SpriteFrameCache(tolua_S); lua_register_cocos2dx_TransitionCrossFade(tolua_S); lua_register_cocos2dx_Ripple3D(tolua_S); lua_register_cocos2dx_Lens3D(tolua_S); lua_register_cocos2dx_TransitionSlideInL(tolua_S); lua_register_cocos2dx_TransitionSlideInT(tolua_S); lua_register_cocos2dx_StopGrid(tolua_S); lua_register_cocos2dx_ShakyTiles3D(tolua_S); lua_register_cocos2dx_PageTurn3D(tolua_S); lua_register_cocos2dx_Grid3D(tolua_S); lua_register_cocos2dx_TransitionProgressInOut(tolua_S); lua_register_cocos2dx_EaseBackIn(tolua_S); lua_register_cocos2dx_SplitRows(tolua_S); lua_register_cocos2dx_Follow(tolua_S); lua_register_cocos2dx_Animate(tolua_S); lua_register_cocos2dx_ShuffleTiles(tolua_S); lua_register_cocos2dx_ProgressTimer(tolua_S); lua_register_cocos2dx_ParticleMeteor(tolua_S); lua_register_cocos2dx_EaseInOut(tolua_S); lua_register_cocos2dx_TransitionZoomFlipY(tolua_S); lua_register_cocos2dx_ScaleBy(tolua_S); lua_register_cocos2dx_EventTouch(tolua_S); lua_register_cocos2dx_Animation(tolua_S); lua_register_cocos2dx_TMXMapInfo(tolua_S); lua_register_cocos2dx_EaseExponentialIn(tolua_S); lua_register_cocos2dx_ReuseGrid(tolua_S); lua_register_cocos2dx_EventDispatcher(tolua_S); lua_register_cocos2dx_MenuItemAtlasFont(tolua_S); lua_register_cocos2dx_Liquid(tolua_S); lua_register_cocos2dx_OrbitCamera(tolua_S); lua_register_cocos2dx_EventCustom(tolua_S); lua_register_cocos2dx_Component(tolua_S); lua_register_cocos2dx_EventListenerTouchOneByOne(tolua_S); lua_register_cocos2dx_ParticleRain(tolua_S); lua_register_cocos2dx_Waves(tolua_S); lua_register_cocos2dx_EaseOut(tolua_S); lua_register_cocos2dx_MenuItemFont(tolua_S); lua_register_cocos2dx_TransitionFadeUp(tolua_S); lua_register_cocos2dx_EaseSineOut(tolua_S); lua_register_cocos2dx_JumpTiles3D(tolua_S); lua_register_cocos2dx_MenuItemToggle(tolua_S); lua_register_cocos2dx_RemoveSelf(tolua_S); lua_register_cocos2dx_SplitCols(tolua_S); lua_register_cocos2dx_MotionStreak(tolua_S); lua_register_cocos2dx_RotateBy(tolua_S); lua_register_cocos2dx_FileUtils(tolua_S); lua_register_cocos2dx_ProgressTo(tolua_S); lua_register_cocos2dx_TransitionProgressOutIn(tolua_S); lua_register_cocos2dx_CatmullRomBy(tolua_S); lua_register_cocos2dx_Sequence(tolua_S); lua_register_cocos2dx_Shaky3D(tolua_S); lua_register_cocos2dx_TransitionProgressRadialCW(tolua_S); lua_register_cocos2dx_EaseBounceInOut(tolua_S); lua_register_cocos2dx_TransitionSlideInR(tolua_S); lua_register_cocos2dx_ParallaxNode(tolua_S); lua_register_cocos2dx_Scheduler(tolua_S); lua_register_cocos2dx_UserDefault(tolua_S); lua_register_cocos2dx_EaseSineIn(tolua_S); lua_register_cocos2dx_WavesTiles3D(tolua_S); lua_register_cocos2dx_TransitionSlideInB(tolua_S); lua_register_cocos2dx_Speed(tolua_S); lua_register_cocos2dx_ShatteredTiles3D(tolua_S); tolua_endmodule(tolua_S); return 1; } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_auto.hpp ================================================ #ifndef __cocos2dx_h__ #define __cocos2dx_h__ #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif int register_all_cocos2dx(lua_State* tolua_S); #endif // __cocos2dx_h__ ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_auto_api.js ================================================ /** * @module cocos2dx */ var cc = cc || {}; /** * @class Object */ cc.Object = { /** * @method getReferenceCount * @return A value converted from C/C++ "unsigned int" */ getReferenceCount : function () {}, /** * @method release */ release : function () {}, /** * @method retain */ retain : function () {}, /** * @method Object * @constructor */ Object : function () {}, }; /** * @class Action */ cc.Action = { /** * @method startWithTarget * @param {cocos2d::Node*} */ startWithTarget : function () {}, /** * @method setOriginalTarget * @param {cocos2d::Node*} */ setOriginalTarget : function () {}, /** * @method clone * @return A value converted from C/C++ "cocos2d::Action*" */ clone : function () {}, /** * @method getOriginalTarget * @return A value converted from C/C++ "cocos2d::Node*" */ getOriginalTarget : function () {}, /** * @method stop */ stop : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method getTarget * @return A value converted from C/C++ "cocos2d::Node*" */ getTarget : function () {}, /** * @method step * @param {float} */ step : function () {}, /** * @method setTag * @param {int} */ setTag : function () {}, /** * @method getTag * @return A value converted from C/C++ "int" */ getTag : function () {}, /** * @method setTarget * @param {cocos2d::Node*} */ setTarget : function () {}, /** * @method isDone * @return A value converted from C/C++ "bool" */ isDone : function () {}, /** * @method reverse * @return A value converted from C/C++ "cocos2d::Action*" */ reverse : function () {}, }; /** * @class FiniteTimeAction */ cc.FiniteTimeAction = { /** * @method setDuration * @param {float} */ setDuration : function () {}, /** * @method getDuration * @return A value converted from C/C++ "float" */ getDuration : function () {}, }; /** * @class Speed */ cc.Speed = { /** * @method setInnerAction * @param {cocos2d::ActionInterval*} */ setInnerAction : function () {}, /** * @method setSpeed * @param {float} */ setSpeed : function () {}, /** * @method getInnerAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ getInnerAction : function () {}, /** * @method getSpeed * @return A value converted from C/C++ "float" */ getSpeed : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Speed*" * @param {cocos2d::ActionInterval*} * @param {float} */ create : function () {}, }; /** * @class Follow */ cc.Follow = { /** * @method setBoudarySet * @param {bool} */ setBoudarySet : function () {}, /** * @method isBoundarySet * @return A value converted from C/C++ "bool" */ isBoundarySet : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Follow*" * @param {cocos2d::Node*} * @param {const cocos2d::Rect&} */ create : function () {}, }; /** * @class GLProgram */ cc.GLProgram = { /** * @method getFragmentShaderLog * @return A value converted from C/C++ "std::string" */ getFragmentShaderLog : function () {}, /** * @method addAttribute * @param {const char*} * @param {GLuint} */ addAttribute : function () {}, /** * @method setUniformLocationWithMatrix4fv * @param {GLint} * @param {const GLfloat*} * @param {unsigned int} */ setUniformLocationWithMatrix4fv : function () {}, /** * @method getUniformLocationForName * @return A value converted from C/C++ "GLint" * @param {const char*} */ getUniformLocationForName : function () {}, /** * @method use */ use : function () {}, /** * @method getVertexShaderLog * @return A value converted from C/C++ "std::string" */ getVertexShaderLog : function () {}, /** * @method initWithVertexShaderByteArray * @return A value converted from C/C++ "bool" * @param {const GLchar*} * @param {const GLchar*} */ initWithVertexShaderByteArray : function () {}, /** * @method initWithVertexShaderFilename * @return A value converted from C/C++ "bool" * @param {const char*} * @param {const char*} */ initWithVertexShaderFilename : function () {}, /** * @method setUniformLocationWith3i * @param {GLint} * @param {GLint} * @param {GLint} * @param {GLint} */ setUniformLocationWith3i : function () {}, /** * @method setUniformLocationWith3iv * @param {GLint} * @param {GLint*} * @param {unsigned int} */ setUniformLocationWith3iv : function () {}, /** * @method updateUniforms */ updateUniforms : function () {}, /** * @method setUniformLocationWith4iv * @param {GLint} * @param {GLint*} * @param {unsigned int} */ setUniformLocationWith4iv : function () {}, /** * @method setUniformLocationWithMatrix2fv * @param {GLint} * @param {const GLfloat*} * @param {unsigned int} */ setUniformLocationWithMatrix2fv : function () {}, /** * @method link * @return A value converted from C/C++ "bool" */ link : function () {}, /** * @method setUniformLocationWith2iv * @param {GLint} * @param {GLint*} * @param {unsigned int} */ setUniformLocationWith2iv : function () {}, /** * @method setUniformLocationWithMatrix3fv * @param {GLint} * @param {const GLfloat*} * @param {unsigned int} */ setUniformLocationWithMatrix3fv : function () {}, /** * @method reset */ reset : function () {}, /** * @method setUniformLocationWith4i * @param {GLint} * @param {GLint} * @param {GLint} * @param {GLint} * @param {GLint} */ setUniformLocationWith4i : function () {}, /** * @method setUniformLocationWith1i * @param {GLint} * @param {GLint} */ setUniformLocationWith1i : function () {}, /** * @method setUniformLocationWith2i * @param {GLint} * @param {GLint} * @param {GLint} */ setUniformLocationWith2i : function () {}, /** * @method GLProgram * @constructor */ GLProgram : function () {}, }; /** * @class Touch */ cc.Touch = { /** * @method getPreviousLocationInView * @return A value converted from C/C++ "cocos2d::Point" */ getPreviousLocationInView : function () {}, /** * @method getLocation * @return A value converted from C/C++ "cocos2d::Point" */ getLocation : function () {}, /** * @method getDelta * @return A value converted from C/C++ "cocos2d::Point" */ getDelta : function () {}, /** * @method getStartLocationInView * @return A value converted from C/C++ "cocos2d::Point" */ getStartLocationInView : function () {}, /** * @method getStartLocation * @return A value converted from C/C++ "cocos2d::Point" */ getStartLocation : function () {}, /** * @method getID * @return A value converted from C/C++ "int" */ getID : function () {}, /** * @method setTouchInfo * @param {int} * @param {float} * @param {float} */ setTouchInfo : function () {}, /** * @method getLocationInView * @return A value converted from C/C++ "cocos2d::Point" */ getLocationInView : function () {}, /** * @method getPreviousLocation * @return A value converted from C/C++ "cocos2d::Point" */ getPreviousLocation : function () {}, /** * @method Touch * @constructor */ Touch : function () {}, }; /** * @class Event */ cc.Event = { /** * @method isStopped * @return A value converted from C/C++ "bool" */ isStopped : function () {}, /** * @method getType * @return A value converted from C/C++ "cocos2d::Event::Type" */ getType : function () {}, /** * @method getCurrentTarget * @return A value converted from C/C++ "cocos2d::Node*" */ getCurrentTarget : function () {}, /** * @method stopPropagation */ stopPropagation : function () {}, }; /** * @class EventTouch */ cc.EventTouch = { /** * @method getEventCode * @return A value converted from C/C++ "cocos2d::EventTouch::EventCode" */ getEventCode : function () {}, /** * @method setEventCode * @param {cocos2d::EventTouch::EventCode} */ setEventCode : function () {}, /** * @method EventTouch * @constructor */ EventTouch : function () {}, }; /** * @class EventKeyboard */ cc.EventKeyboard = { /** * @method EventKeyboard * @constructor * @param {cocos2d::EventKeyboard::KeyCode} * @param {bool} */ EventKeyboard : function () {}, }; /** * @class Texture2D */ cc.Texture2D = { /** * @method getShaderProgram * @return A value converted from C/C++ "cocos2d::GLProgram*" */ getShaderProgram : function () {}, /** * @method getMaxT * @return A value converted from C/C++ "GLfloat" */ getMaxT : function () {}, /** * @method getStringForFormat * @return A value converted from C/C++ "const char*" */ getStringForFormat : function () {}, /** * @method setShaderProgram * @param {cocos2d::GLProgram*} */ setShaderProgram : function () {}, /** * @method getMaxS * @return A value converted from C/C++ "GLfloat" */ getMaxS : function () {}, /** * @method hasPremultipliedAlpha * @return A value converted from C/C++ "bool" */ hasPremultipliedAlpha : function () {}, /** * @method initWithMipmaps * @return A value converted from C/C++ "bool" * @param {cocos2d::MipmapInfo*} * @param {int} * @param {cocos2d::Texture2D::PixelFormat} * @param {int} * @param {int} */ initWithMipmaps : function () {}, /** * @method getPixelsHigh * @return A value converted from C/C++ "int" */ getPixelsHigh : function () {}, /** * @method getName * @return A value converted from C/C++ "GLuint" */ getName : function () {}, /** * @method setMaxT * @param {GLfloat} */ setMaxT : function () {}, /** * @method drawInRect * @param {const cocos2d::Rect&} */ drawInRect : function () {}, /** * @method getContentSize * @return A value converted from C/C++ "cocos2d::Size" */ getContentSize : function () {}, /** * @method setAliasTexParameters */ setAliasTexParameters : function () {}, /** * @method setAntiAliasTexParameters */ setAntiAliasTexParameters : function () {}, /** * @method generateMipmap */ generateMipmap : function () {}, /** * @method getDescription * @return A value converted from C/C++ "std::string" */ getDescription : function () {}, /** * @method getPixelFormat * @return A value converted from C/C++ "cocos2d::Texture2D::PixelFormat" */ getPixelFormat : function () {}, /** * @method getContentSizeInPixels * @return A value converted from C/C++ "const cocos2d::Size&" */ getContentSizeInPixels : function () {}, /** * @method getPixelsWide * @return A value converted from C/C++ "int" */ getPixelsWide : function () {}, /** * @method drawAtPoint * @param {const cocos2d::Point&} */ drawAtPoint : function () {}, /** * @method hasMipmaps * @return A value converted from C/C++ "bool" */ hasMipmaps : function () {}, /** * @method setMaxS * @param {GLfloat} */ setMaxS : function () {}, /** * @method setDefaultAlphaPixelFormat * @param {cocos2d::Texture2D::PixelFormat} */ setDefaultAlphaPixelFormat : function () {}, /** * @method getDefaultAlphaPixelFormat * @return A value converted from C/C++ "cocos2d::Texture2D::PixelFormat" */ getDefaultAlphaPixelFormat : function () {}, /** * @method PVRImagesHavePremultipliedAlpha * @param {bool} */ PVRImagesHavePremultipliedAlpha : function () {}, /** * @method Texture2D * @constructor */ Texture2D : function () {}, }; /** * @class EventListener */ cc.EventListener = { /** * @method clone * @return A value converted from C/C++ "cocos2d::EventListener*" */ clone : function () {}, /** * @method checkAvailable * @return A value converted from C/C++ "bool" */ checkAvailable : function () {}, }; /** * @class EventDispatcher */ cc.EventDispatcher = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method addEventListenerWithSceneGraphPriority * @param {cocos2d::EventListener*} * @param {cocos2d::Node*} */ addEventListenerWithSceneGraphPriority : function () {}, /** * @method addEventListenerWithFixedPriority * @param {cocos2d::EventListener*} * @param {int} */ addEventListenerWithFixedPriority : function () {}, /** * @method removeEventListener * @param {cocos2d::EventListener*} */ removeEventListener : function () {}, /** * @method removeEventListeners * @param {cocos2d::EventListener::Type} */ removeEventListeners : function () {}, /** * @method dispatchCustomEvent * @param {const std::string&} * @param {void*} */ dispatchCustomEvent : function () {}, /** * @method setPriority * @param {cocos2d::EventListener*} * @param {int} */ setPriority : function () {}, /** * @method addCustomEventListener * @return A value converted from C/C++ "cocos2d::EventListenerCustom*" * @param {const std::string&} * @param {std::function} */ addCustomEventListener : function () {}, /** * @method dispatchEvent * @param {cocos2d::Event*} */ dispatchEvent : function () {}, /** * @method removeAllEventListeners */ removeAllEventListeners : function () {}, /** * @method removeCustomEventListeners * @param {const std::string&} */ removeCustomEventListeners : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method EventDispatcher * @constructor */ EventDispatcher : function () {}, }; /** * @class Node */ cc.Node = { /** * @method removeComponent * @return A value converted from C/C++ "bool" * @param {const std::string&} */ removeComponent : function () {}, /** * @method setPhysicsBody * @param {cocos2d::PhysicsBody*} */ setPhysicsBody : function () {}, /** * @method getDescription * @return A value converted from C/C++ "std::string" */ getDescription : function () {}, /** * @method setOpacityModifyRGB * @param {bool} */ setOpacityModifyRGB : function () {}, /** * @method setCascadeOpacityEnabled * @param {bool} */ setCascadeOpacityEnabled : function () {}, /** * @method pause */ pause : function () {}, /** * @method convertToWorldSpaceAR * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToWorldSpaceAR : function () {}, /** * @method isIgnoreAnchorPointForPosition * @return A value converted from C/C++ "bool" */ isIgnoreAnchorPointForPosition : function () {}, /** * @method updateDisplayedOpacity * @param {GLubyte} */ updateDisplayedOpacity : function () {}, /** * @method setRotation * @param {float} */ setRotation : function () {}, /** * @method setScaleY * @param {float} */ setScaleY : function () {}, /** * @method setScaleX * @param {float} */ setScaleX : function () {}, /** * @method getColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getColor : function () {}, /** * @method removeAllComponents */ removeAllComponents : function () {}, /** * @method _setLocalZOrder * @param {int} */ _setLocalZOrder : function () {}, /** * @method getTag * @return A value converted from C/C++ "int" */ getTag : function () {}, /** * @method getNodeToWorldAffineTransform * @return A value converted from C/C++ "cocos2d::AffineTransform" */ getNodeToWorldAffineTransform : function () {}, /** * @method getNodeToWorldTransform * @return A value converted from C/C++ "kmMat4" */ getNodeToWorldTransform : function () {}, /** * @method removeChild * @param {cocos2d::Node*} * @param {bool} */ removeChild : function () {}, /** * @method convertToWorldSpace * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToWorldSpace : function () {}, /** * @method getScene * @return A value converted from C/C++ "cocos2d::Scene*" */ getScene : function () {}, /** * @method getEventDispatcher * @return A value converted from C/C++ "cocos2d::EventDispatcher*" */ getEventDispatcher : function () {}, /** * @method setSkewX * @param {float} */ setSkewX : function () {}, /** * @method setSkewY * @param {float} */ setSkewY : function () {}, /** * @method getOpacity * @return A value converted from C/C++ "GLubyte" */ getOpacity : function () {}, /** * @method convertTouchToNodeSpace * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ convertTouchToNodeSpace : function () {}, /** * @method getRotationX * @return A value converted from C/C++ "float" */ getRotationX : function () {}, /** * @method getRotationY * @return A value converted from C/C++ "float" */ getRotationY : function () {}, /** * @method getNodeToParentAffineTransform * @return A value converted from C/C++ "cocos2d::AffineTransform" */ getNodeToParentAffineTransform : function () {}, /** * @method isCascadeOpacityEnabled * @return A value converted from C/C++ "bool" */ isCascadeOpacityEnabled : function () {}, /** * @method setParent * @param {cocos2d::Node*} */ setParent : function () {}, /** * @method getNodeToParentTransform * @return A value converted from C/C++ "const kmMat4&" */ getNodeToParentTransform : function () {}, /** * @method resume */ resume : function () {}, /** * @method getPhysicsBody * @return A value converted from C/C++ "cocos2d::PhysicsBody*" */ getPhysicsBody : function () {}, /** * @method stopActionByTag * @param {int} */ stopActionByTag : function () {}, /** * @method reorderChild * @param {cocos2d::Node*} * @param {int} */ reorderChild : function () {}, /** * @method ignoreAnchorPointForPosition * @param {bool} */ ignoreAnchorPointForPosition : function () {}, /** * @method setColor * @param {const cocos2d::Color3B&} */ setColor : function () {}, /** * @method setPositionY * @param {float} */ setPositionY : function () {}, /** * @method setPositionX * @param {float} */ setPositionX : function () {}, /** * @method setNodeToParentTransform * @param {const kmMat4&} */ setNodeToParentTransform : function () {}, /** * @method getAnchorPoint * @return A value converted from C/C++ "const cocos2d::Point&" */ getAnchorPoint : function () {}, /** * @method getNumberOfRunningActions * @return A value converted from C/C++ "ssize_t" */ getNumberOfRunningActions : function () {}, /** * @method updateTransform */ updateTransform : function () {}, /** * @method isVisible * @return A value converted from C/C++ "bool" */ isVisible : function () {}, /** * @method getChildrenCount * @return A value converted from C/C++ "ssize_t" */ getChildrenCount : function () {}, /** * @method convertToNodeSpaceAR * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToNodeSpaceAR : function () {}, /** * @method addComponent * @return A value converted from C/C++ "bool" * @param {cocos2d::Component*} */ addComponent : function () {}, /** * @method visit */ visit : function () {}, /** * @method setShaderProgram * @param {cocos2d::GLProgram*} */ setShaderProgram : function () {}, /** * @method getRotation * @return A value converted from C/C++ "float" */ getRotation : function () {}, /** * @method getAnchorPointInPoints * @return A value converted from C/C++ "const cocos2d::Point&" */ getAnchorPointInPoints : function () {}, /** * @method runAction * @return A value converted from C/C++ "cocos2d::Action*" * @param {cocos2d::Action*} */ runAction : function () {}, /** * @method transform */ transform : function () {}, /** * @method setVertexZ * @param {float} */ setVertexZ : function () {}, /** * @method setScheduler * @param {cocos2d::Scheduler*} */ setScheduler : function () {}, /** * @method stopAllActions */ stopAllActions : function () {}, /** * @method getSkewX * @return A value converted from C/C++ "float" */ getSkewX : function () {}, /** * @method getSkewY * @return A value converted from C/C++ "float" */ getSkewY : function () {}, /** * @method getDisplayedColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getDisplayedColor : function () {}, /** * @method getActionByTag * @return A value converted from C/C++ "cocos2d::Action*" * @param {int} */ getActionByTag : function () {}, /** * @method setRotationX * @param {float} */ setRotationX : function () {}, /** * @method setRotationY * @param {float} */ setRotationY : function () {}, /** * @method getDisplayedOpacity * @return A value converted from C/C++ "GLubyte" */ getDisplayedOpacity : function () {}, /** * @method getLocalZOrder * @return A value converted from C/C++ "int" */ getLocalZOrder : function () {}, /** * @method getParentToNodeAffineTransform * @return A value converted from C/C++ "cocos2d::AffineTransform" */ getParentToNodeAffineTransform : function () {}, /** * @method getOrderOfArrival * @return A value converted from C/C++ "int" */ getOrderOfArrival : function () {}, /** * @method setActionManager * @param {cocos2d::ActionManager*} */ setActionManager : function () {}, /** * @method isRunning * @return A value converted from C/C++ "bool" */ isRunning : function () {}, /** * @method getPositionY * @return A value converted from C/C++ "float" */ getPositionY : function () {}, /** * @method getPositionX * @return A value converted from C/C++ "float" */ getPositionX : function () {}, /** * @method removeChildByTag * @param {int} * @param {bool} */ removeChildByTag : function () {}, /** * @method updateDisplayedColor * @param {const cocos2d::Color3B&} */ updateDisplayedColor : function () {}, /** * @method setVisible * @param {bool} */ setVisible : function () {}, /** * @method getParentToNodeTransform * @return A value converted from C/C++ "const kmMat4&" */ getParentToNodeTransform : function () {}, /** * @method getVertexZ * @return A value converted from C/C++ "float" */ getVertexZ : function () {}, /** * @method setGlobalZOrder * @param {float} */ setGlobalZOrder : function () {}, /** * @method getChildByTag * @return A value converted from C/C++ "cocos2d::Node*" * @param {int} */ getChildByTag : function () {}, /** * @method setOrderOfArrival * @param {int} */ setOrderOfArrival : function () {}, /** * @method getScaleY * @return A value converted from C/C++ "float" */ getScaleY : function () {}, /** * @method getScaleX * @return A value converted from C/C++ "float" */ getScaleX : function () {}, /** * @method setLocalZOrder * @param {int} */ setLocalZOrder : function () {}, /** * @method getWorldToNodeAffineTransform * @return A value converted from C/C++ "cocos2d::AffineTransform" */ getWorldToNodeAffineTransform : function () {}, /** * @method setCascadeColorEnabled * @param {bool} */ setCascadeColorEnabled : function () {}, /** * @method setOpacity * @param {GLubyte} */ setOpacity : function () {}, /** * @method cleanup */ cleanup : function () {}, /** * @method getComponent * @return A value converted from C/C++ "cocos2d::Component*" * @param {const std::string&} */ getComponent : function () {}, /** * @method getContentSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getContentSize : function () {}, /** * @method getBoundingBox * @return A value converted from C/C++ "cocos2d::Rect" */ getBoundingBox : function () {}, /** * @method updatePhysicsTransform * @return A value converted from C/C++ "bool" */ updatePhysicsTransform : function () {}, /** * @method setEventDispatcher * @param {cocos2d::EventDispatcher*} */ setEventDispatcher : function () {}, /** * @method getGlobalZOrder * @return A value converted from C/C++ "float" */ getGlobalZOrder : function () {}, /** * @method draw */ draw : function () {}, /** * @method transformAncestors */ transformAncestors : function () {}, /** * @method setUserObject * @param {cocos2d::Object*} */ setUserObject : function () {}, /** * @method convertTouchToNodeSpaceAR * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ convertTouchToNodeSpaceAR : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method sortAllChildren */ sortAllChildren : function () {}, /** * @method getWorldToNodeTransform * @return A value converted from C/C++ "kmMat4" */ getWorldToNodeTransform : function () {}, /** * @method getScale * @return A value converted from C/C++ "float" */ getScale : function () {}, /** * @method convertToNodeSpace * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToNodeSpace : function () {}, /** * @method setTag * @param {int} */ setTag : function () {}, /** * @method isCascadeColorEnabled * @return A value converted from C/C++ "bool" */ isCascadeColorEnabled : function () {}, /** * @method isOpacityModifyRGB * @return A value converted from C/C++ "bool" */ isOpacityModifyRGB : function () {}, /** * @method stopAction * @param {cocos2d::Action*} */ stopAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Node*" */ create : function () {}, }; /** * @class SpriteFrame */ cc.SpriteFrame = { /** * @method clone * @return A value converted from C/C++ "cocos2d::SpriteFrame*" */ clone : function () {}, /** * @method setRotated * @param {bool} */ setRotated : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method setRectInPixels * @param {const cocos2d::Rect&} */ setRectInPixels : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method getRect * @return A value converted from C/C++ "const cocos2d::Rect&" */ getRect : function () {}, /** * @method setOffsetInPixels * @param {const cocos2d::Point&} */ setOffsetInPixels : function () {}, /** * @method getRectInPixels * @return A value converted from C/C++ "const cocos2d::Rect&" */ getRectInPixels : function () {}, /** * @method setOriginalSize * @param {const cocos2d::Size&} */ setOriginalSize : function () {}, /** * @method getOriginalSizeInPixels * @return A value converted from C/C++ "const cocos2d::Size&" */ getOriginalSizeInPixels : function () {}, /** * @method setOriginalSizeInPixels * @param {const cocos2d::Size&} */ setOriginalSizeInPixels : function () {}, /** * @method setOffset * @param {const cocos2d::Point&} */ setOffset : function () {}, /** * @method getOffset * @return A value converted from C/C++ "const cocos2d::Point&" */ getOffset : function () {}, /** * @method isRotated * @return A value converted from C/C++ "bool" */ isRotated : function () {}, /** * @method setRect * @param {const cocos2d::Rect&} */ setRect : function () {}, /** * @method getOffsetInPixels * @return A value converted from C/C++ "const cocos2d::Point&" */ getOffsetInPixels : function () {}, /** * @method getOriginalSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getOriginalSize : function () {}, }; /** * @class AnimationFrame */ cc.AnimationFrame = { /** * @method setSpriteFrame * @param {cocos2d::SpriteFrame*} */ setSpriteFrame : function () {}, /** * @method setDelayUnits * @param {float} */ setDelayUnits : function () {}, /** * @method clone * @return A value converted from C/C++ "cocos2d::AnimationFrame*" */ clone : function () {}, /** * @method getSpriteFrame * @return A value converted from C/C++ "cocos2d::SpriteFrame*" */ getSpriteFrame : function () {}, /** * @method getDelayUnits * @return A value converted from C/C++ "float" */ getDelayUnits : function () {}, /** * @method setUserInfo * @param {const cocos2d::ValueMap&} */ setUserInfo : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::AnimationFrame*" * @param {cocos2d::SpriteFrame*} * @param {float} * @param {const cocos2d::ValueMap&} */ create : function () {}, }; /** * @class Animation */ cc.Animation = { /** * @method getLoops * @return A value converted from C/C++ "unsigned int" */ getLoops : function () {}, /** * @method addSpriteFrame * @param {cocos2d::SpriteFrame*} */ addSpriteFrame : function () {}, /** * @method setRestoreOriginalFrame * @param {bool} */ setRestoreOriginalFrame : function () {}, /** * @method clone * @return A value converted from C/C++ "cocos2d::Animation*" */ clone : function () {}, /** * @method getDuration * @return A value converted from C/C++ "float" */ getDuration : function () {}, /** * @method setFrames * @param {const cocos2d::Vector&} */ setFrames : function () {}, /** * @method getFrames * @return A value converted from C/C++ "const cocos2d::Vector&" */ getFrames : function () {}, /** * @method setLoops * @param {unsigned int} */ setLoops : function () {}, /** * @method setDelayPerUnit * @param {float} */ setDelayPerUnit : function () {}, /** * @method addSpriteFrameWithFile * @param {const std::string&} */ addSpriteFrameWithFile : function () {}, /** * @method getTotalDelayUnits * @return A value converted from C/C++ "float" */ getTotalDelayUnits : function () {}, /** * @method getDelayPerUnit * @return A value converted from C/C++ "float" */ getDelayPerUnit : function () {}, /** * @method getRestoreOriginalFrame * @return A value converted from C/C++ "bool" */ getRestoreOriginalFrame : function () {}, /** * @method addSpriteFrameWithTexture * @param {cocos2d::Texture2D*} * @param {const cocos2d::Rect&} */ addSpriteFrameWithTexture : function () {}, /** * @method createWithSpriteFrames * @return A value converted from C/C++ "cocos2d::Animation*" * @param {const cocos2d::Vector&} * @param {float} */ createWithSpriteFrames : function () {}, }; /** * @class ActionInterval */ cc.ActionInterval = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getElapsed * @return A value converted from C/C++ "float" */ getElapsed : function () {}, }; /** * @class Sequence */ cc.Sequence = { }; /** * @class Repeat */ cc.Repeat = { /** * @method setInnerAction * @param {cocos2d::FiniteTimeAction*} */ setInnerAction : function () {}, /** * @method getInnerAction * @return A value converted from C/C++ "cocos2d::FiniteTimeAction*" */ getInnerAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Repeat*" * @param {cocos2d::FiniteTimeAction*} * @param {unsigned int} */ create : function () {}, }; /** * @class RepeatForever */ cc.RepeatForever = { /** * @method setInnerAction * @param {cocos2d::ActionInterval*} */ setInnerAction : function () {}, /** * @method getInnerAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ getInnerAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::RepeatForever*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class Spawn */ cc.Spawn = { }; /** * @class RotateTo */ cc.RotateTo = { }; /** * @class RotateBy */ cc.RotateBy = { }; /** * @class MoveBy */ cc.MoveBy = { /** * @method create * @return A value converted from C/C++ "cocos2d::MoveBy*" * @param {float} * @param {const cocos2d::Point&} */ create : function () {}, }; /** * @class MoveTo */ cc.MoveTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::MoveTo*" * @param {float} * @param {const cocos2d::Point&} */ create : function () {}, }; /** * @class SkewTo */ cc.SkewTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::SkewTo*" * @param {float} * @param {float} * @param {float} */ create : function () {}, }; /** * @class SkewBy */ cc.SkewBy = { /** * @method create * @return A value converted from C/C++ "cocos2d::SkewBy*" * @param {float} * @param {float} * @param {float} */ create : function () {}, }; /** * @class JumpBy */ cc.JumpBy = { /** * @method create * @return A value converted from C/C++ "cocos2d::JumpBy*" * @param {float} * @param {const cocos2d::Point&} * @param {float} * @param {int} */ create : function () {}, }; /** * @class JumpTo */ cc.JumpTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::JumpTo*" * @param {float} * @param {const cocos2d::Point&} * @param {float} * @param {int} */ create : function () {}, }; /** * @class BezierBy */ cc.BezierBy = { }; /** * @class BezierTo */ cc.BezierTo = { }; /** * @class ScaleTo */ cc.ScaleTo = { }; /** * @class ScaleBy */ cc.ScaleBy = { }; /** * @class Blink */ cc.Blink = { /** * @method create * @return A value converted from C/C++ "cocos2d::Blink*" * @param {float} * @param {int} */ create : function () {}, }; /** * @class FadeIn */ cc.FadeIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeIn*" * @param {float} */ create : function () {}, }; /** * @class FadeOut */ cc.FadeOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOut*" * @param {float} */ create : function () {}, }; /** * @class FadeTo */ cc.FadeTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeTo*" * @param {float} * @param {GLubyte} */ create : function () {}, }; /** * @class TintTo */ cc.TintTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::TintTo*" * @param {float} * @param {GLubyte} * @param {GLubyte} * @param {GLubyte} */ create : function () {}, }; /** * @class TintBy */ cc.TintBy = { /** * @method create * @return A value converted from C/C++ "cocos2d::TintBy*" * @param {float} * @param {GLshort} * @param {GLshort} * @param {GLshort} */ create : function () {}, }; /** * @class DelayTime */ cc.DelayTime = { /** * @method create * @return A value converted from C/C++ "cocos2d::DelayTime*" * @param {float} */ create : function () {}, }; /** * @class Animate */ cc.Animate = { /** * @method setAnimation * @param {cocos2d::Animation*} */ setAnimation : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Animate*" * @param {cocos2d::Animation*} */ create : function () {}, }; /** * @class TargetedAction */ cc.TargetedAction = { /** * @method setForcedTarget * @param {cocos2d::Node*} */ setForcedTarget : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TargetedAction*" * @param {cocos2d::Node*} * @param {cocos2d::FiniteTimeAction*} */ create : function () {}, }; /** * @class ActionCamera */ cc.ActionCamera = { /** * @method getEye * @return A value converted from C/C++ "const kmVec3&" */ getEye : function () {}, /** * @method setUp * @param {const kmVec3&} */ setUp : function () {}, /** * @method getCenter * @return A value converted from C/C++ "const kmVec3&" */ getCenter : function () {}, /** * @method setCenter * @param {const kmVec3&} */ setCenter : function () {}, /** * @method getUp * @return A value converted from C/C++ "const kmVec3&" */ getUp : function () {}, /** * @method ActionCamera * @constructor */ ActionCamera : function () {}, }; /** * @class OrbitCamera */ cc.OrbitCamera = { /** * @method sphericalRadius * @param {float*} * @param {float*} * @param {float*} */ sphericalRadius : function () {}, /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} */ initWithDuration : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::OrbitCamera*" * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} * @param {float} */ create : function () {}, /** * @method OrbitCamera * @constructor */ OrbitCamera : function () {}, }; /** * @class ActionManager */ cc.ActionManager = { /** * @method getActionByTag * @return A value converted from C/C++ "cocos2d::Action*" * @param {int} * @param {const cocos2d::Node*} */ getActionByTag : function () {}, /** * @method removeActionByTag * @param {int} * @param {cocos2d::Node*} */ removeActionByTag : function () {}, /** * @method removeAllActions */ removeAllActions : function () {}, /** * @method addAction * @param {cocos2d::Action*} * @param {cocos2d::Node*} * @param {bool} */ addAction : function () {}, /** * @method resumeTarget * @param {cocos2d::Node*} */ resumeTarget : function () {}, /** * @method getNumberOfRunningActionsInTarget * @return A value converted from C/C++ "ssize_t" * @param {const cocos2d::Node*} */ getNumberOfRunningActionsInTarget : function () {}, /** * @method removeAllActionsFromTarget * @param {cocos2d::Node*} */ removeAllActionsFromTarget : function () {}, /** * @method resumeTargets * @param {const cocos2d::Vector&} */ resumeTargets : function () {}, /** * @method removeAction * @param {cocos2d::Action*} */ removeAction : function () {}, /** * @method pauseTarget * @param {cocos2d::Node*} */ pauseTarget : function () {}, /** * @method pauseAllRunningActions * @return A value converted from C/C++ "cocos2d::Vector" */ pauseAllRunningActions : function () {}, /** * @method ActionManager * @constructor */ ActionManager : function () {}, }; /** * @class ActionEase */ cc.ActionEase = { /** * @method getInnerAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ getInnerAction : function () {}, }; /** * @class EaseRateAction */ cc.EaseRateAction = { /** * @method setRate * @param {float} */ setRate : function () {}, /** * @method getRate * @return A value converted from C/C++ "float" */ getRate : function () {}, }; /** * @class EaseIn */ cc.EaseIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseIn*" * @param {cocos2d::ActionInterval*} * @param {float} */ create : function () {}, }; /** * @class EaseOut */ cc.EaseOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseOut*" * @param {cocos2d::ActionInterval*} * @param {float} */ create : function () {}, }; /** * @class EaseInOut */ cc.EaseInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseInOut*" * @param {cocos2d::ActionInterval*} * @param {float} */ create : function () {}, }; /** * @class EaseExponentialIn */ cc.EaseExponentialIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseExponentialIn*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseExponentialOut */ cc.EaseExponentialOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseExponentialOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseExponentialInOut */ cc.EaseExponentialInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseExponentialInOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseSineIn */ cc.EaseSineIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseSineIn*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseSineOut */ cc.EaseSineOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseSineOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseSineInOut */ cc.EaseSineInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseSineInOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseElastic */ cc.EaseElastic = { /** * @method setPeriod * @param {float} */ setPeriod : function () {}, /** * @method getPeriod * @return A value converted from C/C++ "float" */ getPeriod : function () {}, }; /** * @class EaseElasticIn */ cc.EaseElasticIn = { }; /** * @class EaseElasticOut */ cc.EaseElasticOut = { }; /** * @class EaseElasticInOut */ cc.EaseElasticInOut = { }; /** * @class EaseBounce */ cc.EaseBounce = { /** * @method bounceTime * @return A value converted from C/C++ "float" * @param {float} */ bounceTime : function () {}, }; /** * @class EaseBounceIn */ cc.EaseBounceIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBounceIn*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBounceOut */ cc.EaseBounceOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBounceOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBounceInOut */ cc.EaseBounceInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBounceInOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBackIn */ cc.EaseBackIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBackIn*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBackOut */ cc.EaseBackOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBackOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class EaseBackInOut */ cc.EaseBackInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::EaseBackInOut*" * @param {cocos2d::ActionInterval*} */ create : function () {}, }; /** * @class ActionInstant */ cc.ActionInstant = { }; /** * @class Show */ cc.Show = { /** * @method create * @return A value converted from C/C++ "cocos2d::Show*" */ create : function () {}, }; /** * @class Hide */ cc.Hide = { /** * @method create * @return A value converted from C/C++ "cocos2d::Hide*" */ create : function () {}, }; /** * @class ToggleVisibility */ cc.ToggleVisibility = { /** * @method create * @return A value converted from C/C++ "cocos2d::ToggleVisibility*" */ create : function () {}, }; /** * @class RemoveSelf */ cc.RemoveSelf = { /** * @method create * @return A value converted from C/C++ "cocos2d::RemoveSelf*" */ create : function () {}, }; /** * @class FlipX */ cc.FlipX = { /** * @method create * @return A value converted from C/C++ "cocos2d::FlipX*" * @param {bool} */ create : function () {}, }; /** * @class FlipY */ cc.FlipY = { /** * @method create * @return A value converted from C/C++ "cocos2d::FlipY*" * @param {bool} */ create : function () {}, }; /** * @class Place */ cc.Place = { /** * @method create * @return A value converted from C/C++ "cocos2d::Place*" * @param {const cocos2d::Point&} */ create : function () {}, }; /** * @class CallFunc */ cc.CallFunc = { /** * @method execute */ execute : function () {}, /** * @method getTargetCallback * @return A value converted from C/C++ "cocos2d::Object*" */ getTargetCallback : function () {}, /** * @method setTargetCallback * @param {cocos2d::Object*} */ setTargetCallback : function () {}, }; /** * @class GridAction */ cc.GridAction = { /** * @method getGrid * @return A value converted from C/C++ "cocos2d::GridBase*" */ getGrid : function () {}, }; /** * @class Grid3DAction */ cc.Grid3DAction = { /** * @method getGrid * @return A value converted from C/C++ "cocos2d::GridBase*" */ getGrid : function () {}, }; /** * @class TiledGrid3DAction */ cc.TiledGrid3DAction = { /** * @method getGrid * @return A value converted from C/C++ "cocos2d::GridBase*" */ getGrid : function () {}, }; /** * @class StopGrid */ cc.StopGrid = { /** * @method create * @return A value converted from C/C++ "cocos2d::StopGrid*" */ create : function () {}, }; /** * @class ReuseGrid */ cc.ReuseGrid = { /** * @method create * @return A value converted from C/C++ "cocos2d::ReuseGrid*" * @param {int} */ create : function () {}, }; /** * @class Waves3D */ cc.Waves3D = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Waves3D*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} */ create : function () {}, }; /** * @class FlipX3D */ cc.FlipX3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::FlipX3D*" * @param {float} */ create : function () {}, }; /** * @class FlipY3D */ cc.FlipY3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::FlipY3D*" * @param {float} */ create : function () {}, /** * @method FlipY3D * @constructor */ FlipY3D : function () {}, }; /** * @class Lens3D */ cc.Lens3D = { /** * @method setPosition * @param {const cocos2d::Point&} */ setPosition : function () {}, /** * @method setConcave * @param {bool} */ setConcave : function () {}, /** * @method setLensEffect * @param {float} */ setLensEffect : function () {}, /** * @method getPosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getPosition : function () {}, /** * @method getLensEffect * @return A value converted from C/C++ "float" */ getLensEffect : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Lens3D*" * @param {float} * @param {const cocos2d::Size&} * @param {const cocos2d::Point&} * @param {float} */ create : function () {}, }; /** * @class Ripple3D */ cc.Ripple3D = { /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method setPosition * @param {const cocos2d::Point&} */ setPosition : function () {}, /** * @method getPosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getPosition : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Ripple3D*" * @param {float} * @param {const cocos2d::Size&} * @param {const cocos2d::Point&} * @param {float} * @param {unsigned int} * @param {float} */ create : function () {}, }; /** * @class Shaky3D */ cc.Shaky3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::Shaky3D*" * @param {float} * @param {const cocos2d::Size&} * @param {int} * @param {bool} */ create : function () {}, /** * @method Shaky3D * @constructor */ Shaky3D : function () {}, }; /** * @class Liquid */ cc.Liquid = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Liquid*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} */ create : function () {}, /** * @method Liquid * @constructor */ Liquid : function () {}, }; /** * @class Waves */ cc.Waves = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Waves*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} * @param {bool} * @param {bool} */ create : function () {}, /** * @method Waves * @constructor */ Waves : function () {}, }; /** * @class Twirl */ cc.Twirl = { /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method setPosition * @param {const cocos2d::Point&} */ setPosition : function () {}, /** * @method getPosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getPosition : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Twirl*" * @param {float} * @param {const cocos2d::Size&} * @param {cocos2d::Point} * @param {unsigned int} * @param {float} */ create : function () {}, /** * @method Twirl * @constructor */ Twirl : function () {}, }; /** * @class PageTurn3D */ cc.PageTurn3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::PageTurn3D*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class ProgressTo */ cc.ProgressTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::ProgressTo*" * @param {float} * @param {float} */ create : function () {}, }; /** * @class ProgressFromTo */ cc.ProgressFromTo = { /** * @method create * @return A value converted from C/C++ "cocos2d::ProgressFromTo*" * @param {float} * @param {float} * @param {float} */ create : function () {}, }; /** * @class ShakyTiles3D */ cc.ShakyTiles3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::ShakyTiles3D*" * @param {float} * @param {const cocos2d::Size&} * @param {int} * @param {bool} */ create : function () {}, }; /** * @class ShatteredTiles3D */ cc.ShatteredTiles3D = { /** * @method create * @return A value converted from C/C++ "cocos2d::ShatteredTiles3D*" * @param {float} * @param {const cocos2d::Size&} * @param {int} * @param {bool} */ create : function () {}, }; /** * @class ShuffleTiles */ cc.ShuffleTiles = { /** * @method placeTile * @param {const cocos2d::Point&} * @param {cocos2d::Tile*} */ placeTile : function () {}, /** * @method shuffle * @param {unsigned int*} * @param {unsigned int} */ shuffle : function () {}, /** * @method getDelta * @return A value converted from C/C++ "cocos2d::Size" * @param {const cocos2d::Size&} */ getDelta : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ShuffleTiles*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} */ create : function () {}, }; /** * @class FadeOutTRTiles */ cc.FadeOutTRTiles = { /** * @method turnOnTile * @param {const cocos2d::Point&} */ turnOnTile : function () {}, /** * @method turnOffTile * @param {const cocos2d::Point&} */ turnOffTile : function () {}, /** * @method transformTile * @param {const cocos2d::Point&} * @param {float} */ transformTile : function () {}, /** * @method testFunc * @return A value converted from C/C++ "float" * @param {const cocos2d::Size&} * @param {float} */ testFunc : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOutTRTiles*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class FadeOutBLTiles */ cc.FadeOutBLTiles = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOutBLTiles*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class FadeOutUpTiles */ cc.FadeOutUpTiles = { /** * @method transformTile * @param {const cocos2d::Point&} * @param {float} */ transformTile : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOutUpTiles*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class FadeOutDownTiles */ cc.FadeOutDownTiles = { /** * @method create * @return A value converted from C/C++ "cocos2d::FadeOutDownTiles*" * @param {float} * @param {const cocos2d::Size&} */ create : function () {}, }; /** * @class TurnOffTiles */ cc.TurnOffTiles = { /** * @method turnOnTile * @param {const cocos2d::Point&} */ turnOnTile : function () {}, /** * @method turnOffTile * @param {const cocos2d::Point&} */ turnOffTile : function () {}, /** * @method shuffle * @param {unsigned int*} * @param {unsigned int} */ shuffle : function () {}, }; /** * @class WavesTiles3D */ cc.WavesTiles3D = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::WavesTiles3D*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} */ create : function () {}, }; /** * @class JumpTiles3D */ cc.JumpTiles3D = { /** * @method getAmplitudeRate * @return A value converted from C/C++ "float" */ getAmplitudeRate : function () {}, /** * @method setAmplitude * @param {float} */ setAmplitude : function () {}, /** * @method setAmplitudeRate * @param {float} */ setAmplitudeRate : function () {}, /** * @method getAmplitude * @return A value converted from C/C++ "float" */ getAmplitude : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::JumpTiles3D*" * @param {float} * @param {const cocos2d::Size&} * @param {unsigned int} * @param {float} */ create : function () {}, }; /** * @class SplitRows */ cc.SplitRows = { /** * @method create * @return A value converted from C/C++ "cocos2d::SplitRows*" * @param {float} * @param {unsigned int} */ create : function () {}, }; /** * @class SplitCols */ cc.SplitCols = { /** * @method create * @return A value converted from C/C++ "cocos2d::SplitCols*" * @param {float} * @param {unsigned int} */ create : function () {}, }; /** * @class ActionTween */ cc.ActionTween = { /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {const std::string&} * @param {float} * @param {float} */ initWithDuration : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ActionTween*" * @param {float} * @param {const std::string&} * @param {float} * @param {float} */ create : function () {}, }; /** * @class CardinalSplineTo */ cc.CardinalSplineTo = { /** * @method getPoints * @return A value converted from C/C++ "cocos2d::PointArray*" */ getPoints : function () {}, /** * @method updatePosition * @param {cocos2d::Point&} */ updatePosition : function () {}, /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {cocos2d::PointArray*} * @param {float} */ initWithDuration : function () {}, /** * @method CardinalSplineTo * @constructor */ CardinalSplineTo : function () {}, }; /** * @class CardinalSplineBy */ cc.CardinalSplineBy = { /** * @method CardinalSplineBy * @constructor */ CardinalSplineBy : function () {}, }; /** * @class CatmullRomTo */ cc.CatmullRomTo = { /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {cocos2d::PointArray*} */ initWithDuration : function () {}, }; /** * @class CatmullRomBy */ cc.CatmullRomBy = { /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {cocos2d::PointArray*} */ initWithDuration : function () {}, }; /** * @class AtlasNode */ cc.AtlasNode = { /** * @method updateAtlasValues */ updateAtlasValues : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method setTextureAtlas * @param {cocos2d::TextureAtlas*} */ setTextureAtlas : function () {}, /** * @method getTextureAtlas * @return A value converted from C/C++ "cocos2d::TextureAtlas*" */ getTextureAtlas : function () {}, /** * @method getQuadsToDraw * @return A value converted from C/C++ "ssize_t" */ getQuadsToDraw : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method setQuadsToDraw * @param {ssize_t} */ setQuadsToDraw : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::AtlasNode*" * @param {const std::string&} * @param {int} * @param {int} * @param {int} */ create : function () {}, }; /** * @class DrawNode */ cc.DrawNode = { /** * @method drawQuadraticBezier * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {unsigned int} * @param {const cocos2d::Color4F&} */ drawQuadraticBezier : function () {}, /** * @method onDraw */ onDraw : function () {}, /** * @method clear */ clear : function () {}, /** * @method drawTriangle * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Color4F&} */ drawTriangle : function () {}, /** * @method drawDot * @param {const cocos2d::Point&} * @param {float} * @param {const cocos2d::Color4F&} */ drawDot : function () {}, /** * @method drawCubicBezier * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {unsigned int} * @param {const cocos2d::Color4F&} */ drawCubicBezier : function () {}, /** * @method drawSegment * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {float} * @param {const cocos2d::Color4F&} */ drawSegment : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::DrawNode*" */ create : function () {}, }; /** * @class LabelAtlas */ cc.LabelAtlas = { /** * @method setString * @param {const std::string&} */ setString : function () {}, /** * @method updateAtlasValues */ updateAtlasValues : function () {}, /** * @method getString * @return A value converted from C/C++ "const std::string&" */ getString : function () {}, }; /** * @class Director */ cc.Director = { /** * @method pause */ pause : function () {}, /** * @method setContentScaleFactor * @param {float} */ setContentScaleFactor : function () {}, /** * @method getContentScaleFactor * @return A value converted from C/C++ "float" */ getContentScaleFactor : function () {}, /** * @method getWinSizeInPixels * @return A value converted from C/C++ "cocos2d::Size" */ getWinSizeInPixels : function () {}, /** * @method getDeltaTime * @return A value converted from C/C++ "float" */ getDeltaTime : function () {}, /** * @method setGLDefaultValues */ setGLDefaultValues : function () {}, /** * @method setActionManager * @param {cocos2d::ActionManager*} */ setActionManager : function () {}, /** * @method setAlphaBlending * @param {bool} */ setAlphaBlending : function () {}, /** * @method popToRootScene */ popToRootScene : function () {}, /** * @method getNotificationNode * @return A value converted from C/C++ "cocos2d::Node*" */ getNotificationNode : function () {}, /** * @method getWinSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getWinSize : function () {}, /** * @method getTextureCache * @return A value converted from C/C++ "cocos2d::TextureCache*" */ getTextureCache : function () {}, /** * @method isSendCleanupToScene * @return A value converted from C/C++ "bool" */ isSendCleanupToScene : function () {}, /** * @method getVisibleOrigin * @return A value converted from C/C++ "cocos2d::Point" */ getVisibleOrigin : function () {}, /** * @method mainLoop */ mainLoop : function () {}, /** * @method setDepthTest * @param {bool} */ setDepthTest : function () {}, /** * @method getFrameRate * @return A value converted from C/C++ "float" */ getFrameRate : function () {}, /** * @method getSecondsPerFrame * @return A value converted from C/C++ "float" */ getSecondsPerFrame : function () {}, /** * @method convertToUI * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToUI : function () {}, /** * @method setDefaultValues */ setDefaultValues : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setScheduler * @param {cocos2d::Scheduler*} */ setScheduler : function () {}, /** * @method startAnimation */ startAnimation : function () {}, /** * @method getRunningScene * @return A value converted from C/C++ "cocos2d::Scene*" */ getRunningScene : function () {}, /** * @method setViewport */ setViewport : function () {}, /** * @method stopAnimation */ stopAnimation : function () {}, /** * @method popToSceneStackLevel * @param {int} */ popToSceneStackLevel : function () {}, /** * @method resume */ resume : function () {}, /** * @method isNextDeltaTimeZero * @return A value converted from C/C++ "bool" */ isNextDeltaTimeZero : function () {}, /** * @method end */ end : function () {}, /** * @method setOpenGLView * @param {cocos2d::EGLView*} */ setOpenGLView : function () {}, /** * @method convertToGL * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ convertToGL : function () {}, /** * @method purgeCachedData */ purgeCachedData : function () {}, /** * @method getTotalFrames * @return A value converted from C/C++ "unsigned int" */ getTotalFrames : function () {}, /** * @method runWithScene * @param {cocos2d::Scene*} */ runWithScene : function () {}, /** * @method setNotificationNode * @param {cocos2d::Node*} */ setNotificationNode : function () {}, /** * @method drawScene */ drawScene : function () {}, /** * @method popScene */ popScene : function () {}, /** * @method isDisplayStats * @return A value converted from C/C++ "bool" */ isDisplayStats : function () {}, /** * @method setProjection * @param {cocos2d::Director::Projection} */ setProjection : function () {}, /** * @method getConsole * @return A value converted from C/C++ "cocos2d::Console*" */ getConsole : function () {}, /** * @method getZEye * @return A value converted from C/C++ "float" */ getZEye : function () {}, /** * @method setNextDeltaTimeZero * @param {bool} */ setNextDeltaTimeZero : function () {}, /** * @method getVisibleSize * @return A value converted from C/C++ "cocos2d::Size" */ getVisibleSize : function () {}, /** * @method getScheduler * @return A value converted from C/C++ "cocos2d::Scheduler*" */ getScheduler : function () {}, /** * @method pushScene * @param {cocos2d::Scene*} */ pushScene : function () {}, /** * @method getAnimationInterval * @return A value converted from C/C++ "double" */ getAnimationInterval : function () {}, /** * @method isPaused * @return A value converted from C/C++ "bool" */ isPaused : function () {}, /** * @method setDisplayStats * @param {bool} */ setDisplayStats : function () {}, /** * @method replaceScene * @param {cocos2d::Scene*} */ replaceScene : function () {}, /** * @method setAnimationInterval * @param {double} */ setAnimationInterval : function () {}, /** * @method getActionManager * @return A value converted from C/C++ "cocos2d::ActionManager*" */ getActionManager : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::Director*" */ getInstance : function () {}, }; /** * @class GridBase */ cc.GridBase = { /** * @method setGridSize * @param {const cocos2d::Size&} */ setGridSize : function () {}, /** * @method calculateVertexPoints */ calculateVertexPoints : function () {}, /** * @method afterDraw * @param {cocos2d::Node*} */ afterDraw : function () {}, /** * @method beforeDraw */ beforeDraw : function () {}, /** * @method isTextureFlipped * @return A value converted from C/C++ "bool" */ isTextureFlipped : function () {}, /** * @method getGridSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getGridSize : function () {}, /** * @method getStep * @return A value converted from C/C++ "const cocos2d::Point&" */ getStep : function () {}, /** * @method set2DProjection */ set2DProjection : function () {}, /** * @method setStep * @param {const cocos2d::Point&} */ setStep : function () {}, /** * @method setTextureFlipped * @param {bool} */ setTextureFlipped : function () {}, /** * @method blit */ blit : function () {}, /** * @method setActive * @param {bool} */ setActive : function () {}, /** * @method getReuseGrid * @return A value converted from C/C++ "int" */ getReuseGrid : function () {}, /** * @method setReuseGrid * @param {int} */ setReuseGrid : function () {}, /** * @method isActive * @return A value converted from C/C++ "bool" */ isActive : function () {}, /** * @method reuse */ reuse : function () {}, }; /** * @class Grid3D */ cc.Grid3D = { /** * @method Grid3D * @constructor */ Grid3D : function () {}, }; /** * @class TiledGrid3D */ cc.TiledGrid3D = { /** * @method TiledGrid3D * @constructor */ TiledGrid3D : function () {}, }; /** * @class Sprite */ cc.Sprite = { /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method setFlippedY * @param {bool} */ setFlippedY : function () {}, /** * @method setFlippedX * @param {bool} */ setFlippedX : function () {}, /** * @method getBatchNode * @return A value converted from C/C++ "cocos2d::SpriteBatchNode*" */ getBatchNode : function () {}, /** * @method getOffsetPosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getOffsetPosition : function () {}, /** * @method removeAllChildrenWithCleanup * @param {bool} */ removeAllChildrenWithCleanup : function () {}, /** * @method updateQuadVertices */ updateQuadVertices : function () {}, /** * @method updateTransform */ updateTransform : function () {}, /** * @method isFrameDisplayed * @return A value converted from C/C++ "bool" * @param {cocos2d::SpriteFrame*} */ isFrameDisplayed : function () {}, /** * @method getAtlasIndex * @return A value converted from C/C++ "ssize_t" */ getAtlasIndex : function () {}, /** * @method setBatchNode * @param {cocos2d::SpriteBatchNode*} */ setBatchNode : function () {}, /** * @method setDisplayFrameWithAnimationName * @param {const std::string&} * @param {ssize_t} */ setDisplayFrameWithAnimationName : function () {}, /** * @method setTextureAtlas * @param {cocos2d::TextureAtlas*} */ setTextureAtlas : function () {}, /** * @method getSpriteFrame * @return A value converted from C/C++ "cocos2d::SpriteFrame*" */ getSpriteFrame : function () {}, /** * @method isDirty * @return A value converted from C/C++ "bool" */ isDirty : function () {}, /** * @method setAtlasIndex * @param {ssize_t} */ setAtlasIndex : function () {}, /** * @method setDirty * @param {bool} */ setDirty : function () {}, /** * @method isTextureRectRotated * @return A value converted from C/C++ "bool" */ isTextureRectRotated : function () {}, /** * @method getTextureRect * @return A value converted from C/C++ "const cocos2d::Rect&" */ getTextureRect : function () {}, /** * @method getTextureAtlas * @return A value converted from C/C++ "cocos2d::TextureAtlas*" */ getTextureAtlas : function () {}, /** * @method isFlippedX * @return A value converted from C/C++ "bool" */ isFlippedX : function () {}, /** * @method isFlippedY * @return A value converted from C/C++ "bool" */ isFlippedY : function () {}, /** * @method setVertexRect * @param {const cocos2d::Rect&} */ setVertexRect : function () {}, /** * @method createWithSpriteFrameName * @return A value converted from C/C++ "cocos2d::Sprite*" * @param {const std::string&} */ createWithSpriteFrameName : function () {}, /** * @method createWithSpriteFrame * @return A value converted from C/C++ "cocos2d::Sprite*" * @param {cocos2d::SpriteFrame*} */ createWithSpriteFrame : function () {}, }; /** * @class LabelTTF */ cc.LabelTTF = { /** * @method enableShadow * @param {const cocos2d::Size&} * @param {float} * @param {float} * @param {bool} */ enableShadow : function () {}, /** * @method setDimensions * @param {const cocos2d::Size&} */ setDimensions : function () {}, /** * @method getFontSize * @return A value converted from C/C++ "float" */ getFontSize : function () {}, /** * @method getString * @return A value converted from C/C++ "const std::string&" */ getString : function () {}, /** * @method setTextDefinition * @param {const cocos2d::FontDefinition&} */ setTextDefinition : function () {}, /** * @method setFontName * @param {const std::string&} */ setFontName : function () {}, /** * @method getHorizontalAlignment * @return A value converted from C/C++ "cocos2d::TextHAlignment" */ getHorizontalAlignment : function () {}, /** * @method initWithStringAndTextDefinition * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {cocos2d::FontDefinition&} */ initWithStringAndTextDefinition : function () {}, /** * @method setString * @param {const std::string&} */ setString : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setFontFillColor * @param {const cocos2d::Color3B&} * @param {bool} */ setFontFillColor : function () {}, /** * @method enableStroke * @param {const cocos2d::Color3B&} * @param {float} * @param {bool} */ enableStroke : function () {}, /** * @method getDimensions * @return A value converted from C/C++ "const cocos2d::Size&" */ getDimensions : function () {}, /** * @method setVerticalAlignment * @param {cocos2d::TextVAlignment} */ setVerticalAlignment : function () {}, /** * @method setFontSize * @param {float} */ setFontSize : function () {}, /** * @method getVerticalAlignment * @return A value converted from C/C++ "cocos2d::TextVAlignment" */ getVerticalAlignment : function () {}, /** * @method getTextDefinition * @return A value converted from C/C++ "cocos2d::FontDefinition" */ getTextDefinition : function () {}, /** * @method getFontName * @return A value converted from C/C++ "const std::string&" */ getFontName : function () {}, /** * @method setHorizontalAlignment * @param {cocos2d::TextHAlignment} */ setHorizontalAlignment : function () {}, /** * @method disableShadow */ disableShadow : function () {}, /** * @method disableStroke */ disableStroke : function () {}, /** * @method createWithFontDefinition * @return A value converted from C/C++ "cocos2d::LabelTTF*" * @param {const std::string&} * @param {cocos2d::FontDefinition&} */ createWithFontDefinition : function () {}, /** * @method LabelTTF * @constructor */ LabelTTF : function () {}, }; /** * @class SpriteBatchNode */ cc.SpriteBatchNode = { /** * @method appendChild * @param {cocos2d::Sprite*} */ appendChild : function () {}, /** * @method reorderBatch * @param {bool} */ reorderBatch : function () {}, /** * @method initWithTexture * @return A value converted from C/C++ "bool" * @param {cocos2d::Texture2D*} * @param {ssize_t} */ initWithTexture : function () {}, /** * @method lowestAtlasIndexInChild * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::Sprite*} */ lowestAtlasIndexInChild : function () {}, /** * @method atlasIndexForChild * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::Sprite*} * @param {int} */ atlasIndexForChild : function () {}, /** * @method setTextureAtlas * @param {cocos2d::TextureAtlas*} */ setTextureAtlas : function () {}, /** * @method rebuildIndexInOrder * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::Sprite*} * @param {ssize_t} */ rebuildIndexInOrder : function () {}, /** * @method increaseAtlasCapacity */ increaseAtlasCapacity : function () {}, /** * @method getTextureAtlas * @return A value converted from C/C++ "cocos2d::TextureAtlas*" */ getTextureAtlas : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method highestAtlasIndexInChild * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::Sprite*} */ highestAtlasIndexInChild : function () {}, /** * @method removeChildAtIndex * @param {ssize_t} * @param {bool} */ removeChildAtIndex : function () {}, /** * @method removeAllChildrenWithCleanup * @param {bool} */ removeAllChildrenWithCleanup : function () {}, /** * @method removeSpriteFromAtlas * @param {cocos2d::Sprite*} */ removeSpriteFromAtlas : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::SpriteBatchNode*" * @param {const std::string&} * @param {ssize_t} */ create : function () {}, /** * @method createWithTexture * @return A value converted from C/C++ "cocos2d::SpriteBatchNode*" * @param {cocos2d::Texture2D*} * @param {ssize_t} */ createWithTexture : function () {}, /** * @method SpriteBatchNode * @constructor */ SpriteBatchNode : function () {}, }; /** * @class LabelBMFont */ cc.LabelBMFont = { /** * @method setLineBreakWithoutSpace * @param {bool} */ setLineBreakWithoutSpace : function () {}, /** * @method setScaleY * @param {float} */ setScaleY : function () {}, /** * @method setScaleX * @param {float} */ setScaleX : function () {}, /** * @method isOpacityModifyRGB * @return A value converted from C/C++ "bool" */ isOpacityModifyRGB : function () {}, /** * @method createFontChars */ createFontChars : function () {}, /** * @method getString * @return A value converted from C/C++ "const std::string&" */ getString : function () {}, /** * @method initWithString * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {const std::string&} * @param {float} * @param {cocos2d::TextHAlignment} * @param {cocos2d::Point} */ initWithString : function () {}, /** * @method setCString * @param {const char*} */ setCString : function () {}, /** * @method setScale * @param {float} */ setScale : function () {}, /** * @method setOpacityModifyRGB * @param {bool} */ setOpacityModifyRGB : function () {}, /** * @method setFntFile * @param {const std::string&} */ setFntFile : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method getFntFile * @return A value converted from C/C++ "const std::string&" */ getFntFile : function () {}, /** * @method updateLabel */ updateLabel : function () {}, /** * @method setAlignment * @param {cocos2d::TextHAlignment} */ setAlignment : function () {}, /** * @method setWidth * @param {float} */ setWidth : function () {}, /** * @method purgeCachedData */ purgeCachedData : function () {}, /** * @method LabelBMFont * @constructor */ LabelBMFont : function () {}, }; /** * @class Label */ cc.Label = { /** * @method getString * @return A value converted from C/C++ "const std::string&" */ getString : function () {}, /** * @method assignNewUTF16String * @param {unsigned short*} */ assignNewUTF16String : function () {}, /** * @method setLabelEffect * @param {cocos2d::LabelEffect} * @param {const cocos2d::Color3B&} */ setLabelEffect : function () {}, /** * @method getCommonLineHeight * @return A value converted from C/C++ "int" */ getCommonLineHeight : function () {}, /** * @method breakLineWithoutSpace * @return A value converted from C/C++ "bool" */ breakLineWithoutSpace : function () {}, /** * @method setWidth * @param {float} */ setWidth : function () {}, /** * @method getMaxLineWidth * @return A value converted from C/C++ "float" */ getMaxLineWidth : function () {}, /** * @method getScaleY * @return A value converted from C/C++ "float" */ getScaleY : function () {}, /** * @method getScaleX * @return A value converted from C/C++ "float" */ getScaleX : function () {}, /** * @method setString * @param {const std::string&} */ setString : function () {}, /** * @method getKernings * @return A value converted from C/C++ "int*" */ getKernings : function () {}, /** * @method setBMFontFilePath * @return A value converted from C/C++ "bool" * @param {const std::string&} */ setBMFontFilePath : function () {}, /** * @method recordPlaceholderInfo * @return A value converted from C/C++ "bool" * @param {int} */ recordPlaceholderInfo : function () {}, /** * @method getFontAtlas * @return A value converted from C/C++ "cocos2d::FontAtlas*" */ getFontAtlas : function () {}, /** * @method setLineBreakWithoutSpace * @param {bool} */ setLineBreakWithoutSpace : function () {}, /** * @method getStringNumLines * @return A value converted from C/C++ "int" */ getStringNumLines : function () {}, /** * @method getUTF16String * @return A value converted from C/C++ "unsigned short*" */ getUTF16String : function () {}, /** * @method getStringLenght * @return A value converted from C/C++ "int" */ getStringLenght : function () {}, /** * @method onDraw */ onDraw : function () {}, /** * @method getLetter * @return A value converted from C/C++ "cocos2d::Sprite*" * @param {int} */ getLetter : function () {}, /** * @method getTextAlignment * @return A value converted from C/C++ "cocos2d::TextHAlignment" */ getTextAlignment : function () {}, /** * @method setAlignment * @param {cocos2d::TextHAlignment} */ setAlignment : function () {}, /** * @method recordLetterInfo * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} * @param {unsigned short} * @param {int} */ recordLetterInfo : function () {}, /** * @method createWithBMFont * @return A value converted from C/C++ "cocos2d::Label*" * @param {const std::string&} * @param {const std::string&} * @param {const cocos2d::TextHAlignment&} * @param {int} */ createWithBMFont : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Label*" */ create : function () {}, }; /** * @class Layer */ cc.Layer = { /** * @method create * @return A value converted from C/C++ "cocos2d::Layer*" */ create : function () {}, }; /** * @class LayerColor */ cc.LayerColor = { /** * @method changeWidthAndHeight * @param {GLfloat} * @param {GLfloat} */ changeWidthAndHeight : function () {}, /** * @method onDraw */ onDraw : function () {}, /** * @method changeWidth * @param {GLfloat} */ changeWidth : function () {}, /** * @method changeHeight * @param {GLfloat} */ changeHeight : function () {}, }; /** * @class LayerGradient */ cc.LayerGradient = { /** * @method getStartColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getStartColor : function () {}, /** * @method isCompressedInterpolation * @return A value converted from C/C++ "bool" */ isCompressedInterpolation : function () {}, /** * @method getStartOpacity * @return A value converted from C/C++ "GLubyte" */ getStartOpacity : function () {}, /** * @method setVector * @param {const cocos2d::Point&} */ setVector : function () {}, /** * @method setStartOpacity * @param {GLubyte} */ setStartOpacity : function () {}, /** * @method setCompressedInterpolation * @param {bool} */ setCompressedInterpolation : function () {}, /** * @method setEndOpacity * @param {GLubyte} */ setEndOpacity : function () {}, /** * @method getVector * @return A value converted from C/C++ "const cocos2d::Point&" */ getVector : function () {}, /** * @method setEndColor * @param {const cocos2d::Color3B&} */ setEndColor : function () {}, /** * @method getEndColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getEndColor : function () {}, /** * @method getEndOpacity * @return A value converted from C/C++ "GLubyte" */ getEndOpacity : function () {}, /** * @method setStartColor * @param {const cocos2d::Color3B&} */ setStartColor : function () {}, }; /** * @class LayerMultiplex */ cc.LayerMultiplex = { /** * @method switchToAndReleaseMe * @param {int} */ switchToAndReleaseMe : function () {}, /** * @method addLayer * @param {cocos2d::Layer*} */ addLayer : function () {}, /** * @method switchTo * @param {int} */ switchTo : function () {}, }; /** * @class Scene */ cc.Scene = { /** * @method getPhysicsWorld * @return A value converted from C/C++ "cocos2d::PhysicsWorld*" */ getPhysicsWorld : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Scene*" */ create : function () {}, /** * @method createWithPhysics * @return A value converted from C/C++ "cocos2d::Scene*" */ createWithPhysics : function () {}, }; /** * @class TransitionEaseScene */ cc.TransitionEaseScene = { /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, }; /** * @class TransitionScene */ cc.TransitionScene = { /** * @method finish */ finish : function () {}, /** * @method hideOutShowIn */ hideOutShowIn : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionScene*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSceneOriented */ cc.TransitionSceneOriented = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSceneOriented*" * @param {float} * @param {cocos2d::Scene*} * @param {cocos2d::TransitionScene::Orientation} */ create : function () {}, }; /** * @class TransitionRotoZoom */ cc.TransitionRotoZoom = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionRotoZoom*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionJumpZoom */ cc.TransitionJumpZoom = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionJumpZoom*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionMoveInL */ cc.TransitionMoveInL = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionMoveInL*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionMoveInR */ cc.TransitionMoveInR = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionMoveInR*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionMoveInT */ cc.TransitionMoveInT = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionMoveInT*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionMoveInB */ cc.TransitionMoveInB = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionMoveInB*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSlideInL */ cc.TransitionSlideInL = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSlideInL*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSlideInR */ cc.TransitionSlideInR = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSlideInR*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSlideInB */ cc.TransitionSlideInB = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSlideInB*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSlideInT */ cc.TransitionSlideInT = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSlideInT*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionShrinkGrow */ cc.TransitionShrinkGrow = { /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionShrinkGrow*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFlipX */ cc.TransitionFlipX = { }; /** * @class TransitionFlipY */ cc.TransitionFlipY = { }; /** * @class TransitionFlipAngular */ cc.TransitionFlipAngular = { }; /** * @class TransitionZoomFlipX */ cc.TransitionZoomFlipX = { }; /** * @class TransitionZoomFlipY */ cc.TransitionZoomFlipY = { }; /** * @class TransitionZoomFlipAngular */ cc.TransitionZoomFlipAngular = { }; /** * @class TransitionFade */ cc.TransitionFade = { }; /** * @class TransitionCrossFade */ cc.TransitionCrossFade = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionCrossFade*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionTurnOffTiles */ cc.TransitionTurnOffTiles = { /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionTurnOffTiles*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSplitCols */ cc.TransitionSplitCols = { /** * @method action * @return A value converted from C/C++ "cocos2d::ActionInterval*" */ action : function () {}, /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSplitCols*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionSplitRows */ cc.TransitionSplitRows = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionSplitRows*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFadeTR */ cc.TransitionFadeTR = { /** * @method easeActionWithAction * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {cocos2d::ActionInterval*} */ easeActionWithAction : function () {}, /** * @method actionWithSize * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {const cocos2d::Size&} */ actionWithSize : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionFadeTR*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFadeBL */ cc.TransitionFadeBL = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionFadeBL*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFadeUp */ cc.TransitionFadeUp = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionFadeUp*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionFadeDown */ cc.TransitionFadeDown = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionFadeDown*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionPageTurn */ cc.TransitionPageTurn = { /** * @method actionWithSize * @return A value converted from C/C++ "cocos2d::ActionInterval*" * @param {const cocos2d::Size&} */ actionWithSize : function () {}, /** * @method initWithDuration * @return A value converted from C/C++ "bool" * @param {float} * @param {cocos2d::Scene*} * @param {bool} */ initWithDuration : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionPageTurn*" * @param {float} * @param {cocos2d::Scene*} * @param {bool} */ create : function () {}, /** * @method TransitionPageTurn * @constructor */ TransitionPageTurn : function () {}, }; /** * @class TransitionProgress */ cc.TransitionProgress = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgress*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, /** * @method TransitionProgress * @constructor */ TransitionProgress : function () {}, }; /** * @class TransitionProgressRadialCCW */ cc.TransitionProgressRadialCCW = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressRadialCCW*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressRadialCW */ cc.TransitionProgressRadialCW = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressRadialCW*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressHorizontal */ cc.TransitionProgressHorizontal = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressHorizontal*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressVertical */ cc.TransitionProgressVertical = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressVertical*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressInOut */ cc.TransitionProgressInOut = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressInOut*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class TransitionProgressOutIn */ cc.TransitionProgressOutIn = { /** * @method create * @return A value converted from C/C++ "cocos2d::TransitionProgressOutIn*" * @param {float} * @param {cocos2d::Scene*} */ create : function () {}, }; /** * @class MenuItem */ cc.MenuItem = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method activate */ activate : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method selected */ selected : function () {}, /** * @method isSelected * @return A value converted from C/C++ "bool" */ isSelected : function () {}, /** * @method unselected */ unselected : function () {}, /** * @method rect * @return A value converted from C/C++ "cocos2d::Rect" */ rect : function () {}, }; /** * @class MenuItemLabel */ cc.MenuItemLabel = { /** * @method getDisabledColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getDisabledColor : function () {}, /** * @method setString * @param {const std::string&} */ setString : function () {}, /** * @method setLabel * @param {cocos2d::Node*} */ setLabel : function () {}, /** * @method setDisabledColor * @param {const cocos2d::Color3B&} */ setDisabledColor : function () {}, /** * @method getLabel * @return A value converted from C/C++ "cocos2d::Node*" */ getLabel : function () {}, }; /** * @class MenuItemAtlasFont */ cc.MenuItemAtlasFont = { }; /** * @class MenuItemFont */ cc.MenuItemFont = { /** * @method getFontSizeObj * @return A value converted from C/C++ "int" */ getFontSizeObj : function () {}, /** * @method getFontNameObj * @return A value converted from C/C++ "const std::string&" */ getFontNameObj : function () {}, /** * @method setFontSizeObj * @param {int} */ setFontSizeObj : function () {}, /** * @method setFontNameObj * @param {const std::string&} */ setFontNameObj : function () {}, /** * @method setFontName * @param {const std::string&} */ setFontName : function () {}, /** * @method getFontSize * @return A value converted from C/C++ "int" */ getFontSize : function () {}, /** * @method getFontName * @return A value converted from C/C++ "const std::string&" */ getFontName : function () {}, /** * @method setFontSize * @param {int} */ setFontSize : function () {}, }; /** * @class MenuItemSprite */ cc.MenuItemSprite = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method selected */ selected : function () {}, /** * @method setNormalImage * @param {cocos2d::Node*} */ setNormalImage : function () {}, /** * @method setDisabledImage * @param {cocos2d::Node*} */ setDisabledImage : function () {}, /** * @method setSelectedImage * @param {cocos2d::Node*} */ setSelectedImage : function () {}, /** * @method getDisabledImage * @return A value converted from C/C++ "cocos2d::Node*" */ getDisabledImage : function () {}, /** * @method getSelectedImage * @return A value converted from C/C++ "cocos2d::Node*" */ getSelectedImage : function () {}, /** * @method getNormalImage * @return A value converted from C/C++ "cocos2d::Node*" */ getNormalImage : function () {}, /** * @method unselected */ unselected : function () {}, }; /** * @class MenuItemImage */ cc.MenuItemImage = { /** * @method setDisabledSpriteFrame * @param {cocos2d::SpriteFrame*} */ setDisabledSpriteFrame : function () {}, /** * @method setSelectedSpriteFrame * @param {cocos2d::SpriteFrame*} */ setSelectedSpriteFrame : function () {}, /** * @method setNormalSpriteFrame * @param {cocos2d::SpriteFrame*} */ setNormalSpriteFrame : function () {}, }; /** * @class MenuItemToggle */ cc.MenuItemToggle = { /** * @method setSubItems * @param {const cocos2d::Vector&} */ setSubItems : function () {}, /** * @method getSelectedIndex * @return A value converted from C/C++ "unsigned int" */ getSelectedIndex : function () {}, /** * @method addSubItem * @param {cocos2d::MenuItem*} */ addSubItem : function () {}, /** * @method getSelectedItem * @return A value converted from C/C++ "cocos2d::MenuItem*" */ getSelectedItem : function () {}, /** * @method setSelectedIndex * @param {unsigned int} */ setSelectedIndex : function () {}, }; /** * @class Menu */ cc.Menu = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method alignItemsVertically */ alignItemsVertically : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method alignItemsHorizontallyWithPadding * @param {float} */ alignItemsHorizontallyWithPadding : function () {}, /** * @method alignItemsVerticallyWithPadding * @param {float} */ alignItemsVerticallyWithPadding : function () {}, /** * @method alignItemsHorizontally */ alignItemsHorizontally : function () {}, }; /** * @class ClippingNode */ cc.ClippingNode = { /** * @method isInverted * @return A value converted from C/C++ "bool" */ isInverted : function () {}, /** * @method setInverted * @param {bool} */ setInverted : function () {}, /** * @method setStencil * @param {cocos2d::Node*} */ setStencil : function () {}, /** * @method getAlphaThreshold * @return A value converted from C/C++ "GLfloat" */ getAlphaThreshold : function () {}, /** * @method getStencil * @return A value converted from C/C++ "cocos2d::Node*" */ getStencil : function () {}, /** * @method setAlphaThreshold * @param {GLfloat} */ setAlphaThreshold : function () {}, }; /** * @class MotionStreak */ cc.MotionStreak = { /** * @method reset */ reset : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method tintWithColor * @param {const cocos2d::Color3B&} */ tintWithColor : function () {}, /** * @method setStartingPositionInitialized * @param {bool} */ setStartingPositionInitialized : function () {}, /** * @method isStartingPositionInitialized * @return A value converted from C/C++ "bool" */ isStartingPositionInitialized : function () {}, /** * @method isFastMode * @return A value converted from C/C++ "bool" */ isFastMode : function () {}, /** * @method setFastMode * @param {bool} */ setFastMode : function () {}, }; /** * @class ProgressTimer */ cc.ProgressTimer = { /** * @method isReverseDirection * @return A value converted from C/C++ "bool" */ isReverseDirection : function () {}, /** * @method setBarChangeRate * @param {const cocos2d::Point&} */ setBarChangeRate : function () {}, /** * @method getPercentage * @return A value converted from C/C++ "float" */ getPercentage : function () {}, /** * @method setSprite * @param {cocos2d::Sprite*} */ setSprite : function () {}, /** * @method getType * @return A value converted from C/C++ "cocos2d::ProgressTimer::Type" */ getType : function () {}, /** * @method getSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSprite : function () {}, /** * @method setMidpoint * @param {const cocos2d::Point&} */ setMidpoint : function () {}, /** * @method getBarChangeRate * @return A value converted from C/C++ "cocos2d::Point" */ getBarChangeRate : function () {}, /** * @method getMidpoint * @return A value converted from C/C++ "cocos2d::Point" */ getMidpoint : function () {}, /** * @method setPercentage * @param {float} */ setPercentage : function () {}, /** * @method setType * @param {cocos2d::ProgressTimer::Type} */ setType : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ProgressTimer*" * @param {cocos2d::Sprite*} */ create : function () {}, }; /** * @class Image */ cc.Image = { /** * @method hasPremultipliedAlpha * @return A value converted from C/C++ "bool" */ hasPremultipliedAlpha : function () {}, /** * @method getDataLen * @return A value converted from C/C++ "ssize_t" */ getDataLen : function () {}, /** * @method isCompressed * @return A value converted from C/C++ "bool" */ isCompressed : function () {}, /** * @method getBitPerPixel * @return A value converted from C/C++ "int" */ getBitPerPixel : function () {}, /** * @method hasAlpha * @return A value converted from C/C++ "bool" */ hasAlpha : function () {}, /** * @method getHeight * @return A value converted from C/C++ "int" */ getHeight : function () {}, /** * @method initWithImageFile * @return A value converted from C/C++ "bool" * @param {const std::string&} */ initWithImageFile : function () {}, /** * @method getWidth * @return A value converted from C/C++ "int" */ getWidth : function () {}, /** * @method isPremultipliedAlpha * @return A value converted from C/C++ "bool" */ isPremultipliedAlpha : function () {}, /** * @method getFileType * @return A value converted from C/C++ "cocos2d::Image::Format" */ getFileType : function () {}, /** * @method saveToFile * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {bool} */ saveToFile : function () {}, /** * @method getNumberOfMipmaps * @return A value converted from C/C++ "int" */ getNumberOfMipmaps : function () {}, /** * @method getRenderFormat * @return A value converted from C/C++ "cocos2d::Texture2D::PixelFormat" */ getRenderFormat : function () {}, /** * @method getData * @return A value converted from C/C++ "unsigned char*" */ getData : function () {}, /** * @method getMipmaps * @return A value converted from C/C++ "cocos2d::MipmapInfo*" */ getMipmaps : function () {}, /** * @method Image * @constructor */ Image : function () {}, }; /** * @class RenderTexture */ cc.RenderTexture = { /** * @method clearStencil * @param {int} */ clearStencil : function () {}, /** * @method getClearDepth * @return A value converted from C/C++ "float" */ getClearDepth : function () {}, /** * @method getClearStencil * @return A value converted from C/C++ "int" */ getClearStencil : function () {}, /** * @method end */ end : function () {}, /** * @method setClearStencil * @param {int} */ setClearStencil : function () {}, /** * @method setSprite * @param {cocos2d::Sprite*} */ setSprite : function () {}, /** * @method getSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSprite : function () {}, /** * @method isAutoDraw * @return A value converted from C/C++ "bool" */ isAutoDraw : function () {}, /** * @method setClearFlags * @param {unsigned int} */ setClearFlags : function () {}, /** * @method begin */ begin : function () {}, /** * @method setAutoDraw * @param {bool} */ setAutoDraw : function () {}, /** * @method setClearColor * @param {const cocos2d::Color4F&} */ setClearColor : function () {}, /** * @method endToLua */ endToLua : function () {}, /** * @method clearDepth * @param {float} */ clearDepth : function () {}, /** * @method getClearColor * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getClearColor : function () {}, /** * @method clear * @param {float} * @param {float} * @param {float} * @param {float} */ clear : function () {}, /** * @method getClearFlags * @return A value converted from C/C++ "unsigned int" */ getClearFlags : function () {}, /** * @method newImage * @return A value converted from C/C++ "cocos2d::Image*" */ newImage : function () {}, /** * @method setClearDepth * @param {float} */ setClearDepth : function () {}, /** * @method RenderTexture * @constructor */ RenderTexture : function () {}, }; /** * @class NodeGrid */ cc.NodeGrid = { /** * @method setTarget * @param {cocos2d::Node*} */ setTarget : function () {}, /** * @method setGrid * @param {cocos2d::GridBase*} */ setGrid : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::NodeGrid*" */ create : function () {}, }; /** * @class ParticleBatchNode */ cc.ParticleBatchNode = { /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method disableParticle * @param {int} */ disableParticle : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method setTextureAtlas * @param {cocos2d::TextureAtlas*} */ setTextureAtlas : function () {}, /** * @method removeAllChildrenWithCleanup * @param {bool} */ removeAllChildrenWithCleanup : function () {}, /** * @method getTextureAtlas * @return A value converted from C/C++ "cocos2d::TextureAtlas*" */ getTextureAtlas : function () {}, /** * @method insertChild * @param {cocos2d::ParticleSystem*} * @param {int} */ insertChild : function () {}, /** * @method visit */ visit : function () {}, /** * @method removeChildAtIndex * @param {int} * @param {bool} */ removeChildAtIndex : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleBatchNode*" * @param {const std::string&} * @param {int} */ create : function () {}, /** * @method createWithTexture * @return A value converted from C/C++ "cocos2d::ParticleBatchNode*" * @param {cocos2d::Texture2D*} * @param {int} */ createWithTexture : function () {}, }; /** * @class ParticleSystem */ cc.ParticleSystem = { /** * @method getStartSizeVar * @return A value converted from C/C++ "float" */ getStartSizeVar : function () {}, /** * @method getTexture * @return A value converted from C/C++ "cocos2d::Texture2D*" */ getTexture : function () {}, /** * @method isFull * @return A value converted from C/C++ "bool" */ isFull : function () {}, /** * @method getBatchNode * @return A value converted from C/C++ "cocos2d::ParticleBatchNode*" */ getBatchNode : function () {}, /** * @method getStartColor * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getStartColor : function () {}, /** * @method getPositionType * @return A value converted from C/C++ "cocos2d::ParticleSystem::PositionType" */ getPositionType : function () {}, /** * @method setPosVar * @param {const cocos2d::Point&} */ setPosVar : function () {}, /** * @method getEndSpin * @return A value converted from C/C++ "float" */ getEndSpin : function () {}, /** * @method setRotatePerSecondVar * @param {float} */ setRotatePerSecondVar : function () {}, /** * @method getStartSpinVar * @return A value converted from C/C++ "float" */ getStartSpinVar : function () {}, /** * @method getRadialAccelVar * @return A value converted from C/C++ "float" */ getRadialAccelVar : function () {}, /** * @method getEndSizeVar * @return A value converted from C/C++ "float" */ getEndSizeVar : function () {}, /** * @method setRotation * @param {float} */ setRotation : function () {}, /** * @method setTangentialAccel * @param {float} */ setTangentialAccel : function () {}, /** * @method setScaleY * @param {float} */ setScaleY : function () {}, /** * @method setScaleX * @param {float} */ setScaleX : function () {}, /** * @method getRadialAccel * @return A value converted from C/C++ "float" */ getRadialAccel : function () {}, /** * @method setStartRadius * @param {float} */ setStartRadius : function () {}, /** * @method setRotatePerSecond * @param {float} */ setRotatePerSecond : function () {}, /** * @method setEndSize * @param {float} */ setEndSize : function () {}, /** * @method getGravity * @return A value converted from C/C++ "const cocos2d::Point&" */ getGravity : function () {}, /** * @method getTangentialAccel * @return A value converted from C/C++ "float" */ getTangentialAccel : function () {}, /** * @method setEndRadius * @param {float} */ setEndRadius : function () {}, /** * @method getSpeed * @return A value converted from C/C++ "float" */ getSpeed : function () {}, /** * @method getAngle * @return A value converted from C/C++ "float" */ getAngle : function () {}, /** * @method setEndColor * @param {const cocos2d::Color4F&} */ setEndColor : function () {}, /** * @method setStartSpin * @param {float} */ setStartSpin : function () {}, /** * @method setDuration * @param {float} */ setDuration : function () {}, /** * @method setTexture * @param {cocos2d::Texture2D*} */ setTexture : function () {}, /** * @method getPosVar * @return A value converted from C/C++ "const cocos2d::Point&" */ getPosVar : function () {}, /** * @method updateWithNoTime */ updateWithNoTime : function () {}, /** * @method isBlendAdditive * @return A value converted from C/C++ "bool" */ isBlendAdditive : function () {}, /** * @method getSpeedVar * @return A value converted from C/C++ "float" */ getSpeedVar : function () {}, /** * @method setPositionType * @param {cocos2d::ParticleSystem::PositionType} */ setPositionType : function () {}, /** * @method stopSystem */ stopSystem : function () {}, /** * @method getSourcePosition * @return A value converted from C/C++ "const cocos2d::Point&" */ getSourcePosition : function () {}, /** * @method setLifeVar * @param {float} */ setLifeVar : function () {}, /** * @method setTotalParticles * @param {int} */ setTotalParticles : function () {}, /** * @method setEndColorVar * @param {const cocos2d::Color4F&} */ setEndColorVar : function () {}, /** * @method updateQuadWithParticle * @param {cocos2d::tParticle*} * @param {const cocos2d::Point&} */ updateQuadWithParticle : function () {}, /** * @method getAtlasIndex * @return A value converted from C/C++ "int" */ getAtlasIndex : function () {}, /** * @method getStartSize * @return A value converted from C/C++ "float" */ getStartSize : function () {}, /** * @method setStartSpinVar * @param {float} */ setStartSpinVar : function () {}, /** * @method resetSystem */ resetSystem : function () {}, /** * @method setAtlasIndex * @param {int} */ setAtlasIndex : function () {}, /** * @method setTangentialAccelVar * @param {float} */ setTangentialAccelVar : function () {}, /** * @method setEndRadiusVar * @param {float} */ setEndRadiusVar : function () {}, /** * @method getEndRadius * @return A value converted from C/C++ "float" */ getEndRadius : function () {}, /** * @method isOpacityModifyRGB * @return A value converted from C/C++ "bool" */ isOpacityModifyRGB : function () {}, /** * @method isActive * @return A value converted from C/C++ "bool" */ isActive : function () {}, /** * @method setRadialAccelVar * @param {float} */ setRadialAccelVar : function () {}, /** * @method setStartSize * @param {float} */ setStartSize : function () {}, /** * @method setSpeed * @param {float} */ setSpeed : function () {}, /** * @method getStartSpin * @return A value converted from C/C++ "float" */ getStartSpin : function () {}, /** * @method getRotatePerSecond * @return A value converted from C/C++ "float" */ getRotatePerSecond : function () {}, /** * @method initParticle * @param {cocos2d::tParticle*} */ initParticle : function () {}, /** * @method setEmitterMode * @param {cocos2d::ParticleSystem::Mode} */ setEmitterMode : function () {}, /** * @method getDuration * @return A value converted from C/C++ "float" */ getDuration : function () {}, /** * @method setSourcePosition * @param {const cocos2d::Point&} */ setSourcePosition : function () {}, /** * @method getEndSpinVar * @return A value converted from C/C++ "float" */ getEndSpinVar : function () {}, /** * @method setBlendAdditive * @param {bool} */ setBlendAdditive : function () {}, /** * @method setLife * @param {float} */ setLife : function () {}, /** * @method setAngleVar * @param {float} */ setAngleVar : function () {}, /** * @method setRotationIsDir * @param {bool} */ setRotationIsDir : function () {}, /** * @method setEndSizeVar * @param {float} */ setEndSizeVar : function () {}, /** * @method setAngle * @param {float} */ setAngle : function () {}, /** * @method setBatchNode * @param {cocos2d::ParticleBatchNode*} */ setBatchNode : function () {}, /** * @method getTangentialAccelVar * @return A value converted from C/C++ "float" */ getTangentialAccelVar : function () {}, /** * @method getEmitterMode * @return A value converted from C/C++ "cocos2d::ParticleSystem::Mode" */ getEmitterMode : function () {}, /** * @method setEndSpinVar * @param {float} */ setEndSpinVar : function () {}, /** * @method getAngleVar * @return A value converted from C/C++ "float" */ getAngleVar : function () {}, /** * @method setStartColor * @param {const cocos2d::Color4F&} */ setStartColor : function () {}, /** * @method getRotatePerSecondVar * @return A value converted from C/C++ "float" */ getRotatePerSecondVar : function () {}, /** * @method getEndSize * @return A value converted from C/C++ "float" */ getEndSize : function () {}, /** * @method getLife * @return A value converted from C/C++ "float" */ getLife : function () {}, /** * @method setSpeedVar * @param {float} */ setSpeedVar : function () {}, /** * @method setAutoRemoveOnFinish * @param {bool} */ setAutoRemoveOnFinish : function () {}, /** * @method setGravity * @param {const cocos2d::Point&} */ setGravity : function () {}, /** * @method postStep */ postStep : function () {}, /** * @method setEmissionRate * @param {float} */ setEmissionRate : function () {}, /** * @method getEndColorVar * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getEndColorVar : function () {}, /** * @method getRotationIsDir * @return A value converted from C/C++ "bool" */ getRotationIsDir : function () {}, /** * @method setScale * @param {float} */ setScale : function () {}, /** * @method getEmissionRate * @return A value converted from C/C++ "float" */ getEmissionRate : function () {}, /** * @method getEndColor * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getEndColor : function () {}, /** * @method getLifeVar * @return A value converted from C/C++ "float" */ getLifeVar : function () {}, /** * @method setStartSizeVar * @param {float} */ setStartSizeVar : function () {}, /** * @method setOpacityModifyRGB * @param {bool} */ setOpacityModifyRGB : function () {}, /** * @method addParticle * @return A value converted from C/C++ "bool" */ addParticle : function () {}, /** * @method getStartRadius * @return A value converted from C/C++ "float" */ getStartRadius : function () {}, /** * @method getParticleCount * @return A value converted from C/C++ "unsigned int" */ getParticleCount : function () {}, /** * @method getStartRadiusVar * @return A value converted from C/C++ "float" */ getStartRadiusVar : function () {}, /** * @method setStartColorVar * @param {const cocos2d::Color4F&} */ setStartColorVar : function () {}, /** * @method setEndSpin * @param {float} */ setEndSpin : function () {}, /** * @method setRadialAccel * @param {float} */ setRadialAccel : function () {}, /** * @method isAutoRemoveOnFinish * @return A value converted from C/C++ "bool" */ isAutoRemoveOnFinish : function () {}, /** * @method getTotalParticles * @return A value converted from C/C++ "int" */ getTotalParticles : function () {}, /** * @method setStartRadiusVar * @param {float} */ setStartRadiusVar : function () {}, /** * @method getEndRadiusVar * @return A value converted from C/C++ "float" */ getEndRadiusVar : function () {}, /** * @method getStartColorVar * @return A value converted from C/C++ "const cocos2d::Color4F&" */ getStartColorVar : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSystem*" * @param {const std::string&} */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSystem*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSystemQuad */ cc.ParticleSystem = { /** * @method setDisplayFrame * @param {cocos2d::SpriteFrame*} */ setDisplayFrame : function () {}, /** * @method setTextureWithRect * @param {cocos2d::Texture2D*} * @param {const cocos2d::Rect&} */ setTextureWithRect : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSystemQuad*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleFire */ cc.ParticleFire = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleFire*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleFire*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleFireworks */ cc.ParticleFireworks = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleFireworks*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleFireworks*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSun */ cc.ParticleSun = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSun*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSun*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleGalaxy */ cc.ParticleGalaxy = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleGalaxy*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleGalaxy*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleFlower */ cc.ParticleFlower = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleFlower*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleFlower*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleMeteor */ cc.ParticleMeteor = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleMeteor*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleMeteor*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSpiral */ cc.ParticleSpiral = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSpiral*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSpiral*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleExplosion */ cc.ParticleExplosion = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleExplosion*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleExplosion*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSmoke */ cc.ParticleSmoke = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSmoke*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSmoke*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleSnow */ cc.ParticleSnow = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleSnow*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleSnow*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class ParticleRain */ cc.ParticleRain = { /** * @method create * @return A value converted from C/C++ "cocos2d::ParticleRain*" */ create : function () {}, /** * @method createWithTotalParticles * @return A value converted from C/C++ "cocos2d::ParticleRain*" * @param {int} */ createWithTotalParticles : function () {}, }; /** * @class EventListenerCustom */ cc.EventListenerCustom = { }; /** * @class FileUtils */ cc.FileUtils = { /** * @method fullPathForFilename * @return A value converted from C/C++ "std::string" * @param {const std::string&} */ fullPathForFilename : function () {}, /** * @method getStringFromFile * @return A value converted from C/C++ "std::string" * @param {const std::string&} */ getStringFromFile : function () {}, /** * @method setFilenameLookupDictionary * @param {const cocos2d::ValueMap&} */ setFilenameLookupDictionary : function () {}, /** * @method isAbsolutePath * @return A value converted from C/C++ "bool" * @param {const std::string&} */ isAbsolutePath : function () {}, /** * @method loadFilenameLookupDictionaryFromFile * @param {const std::string&} */ loadFilenameLookupDictionaryFromFile : function () {}, /** * @method isPopupNotify * @return A value converted from C/C++ "bool" */ isPopupNotify : function () {}, /** * @method getValueVectorFromFile * @return A value converted from C/C++ "cocos2d::ValueVector" * @param {const std::string&} */ getValueVectorFromFile : function () {}, /** * @method writeToFile * @return A value converted from C/C++ "bool" * @param {cocos2d::ValueMap&} * @param {const std::string&} */ writeToFile : function () {}, /** * @method getValueMapFromFile * @return A value converted from C/C++ "cocos2d::ValueMap" * @param {const std::string&} */ getValueMapFromFile : function () {}, /** * @method addSearchResolutionsOrder * @param {const std::string&} */ addSearchResolutionsOrder : function () {}, /** * @method addSearchPath * @param {const std::string&} */ addSearchPath : function () {}, /** * @method isFileExist * @return A value converted from C/C++ "bool" * @param {const std::string&} */ isFileExist : function () {}, /** * @method purgeCachedEntries */ purgeCachedEntries : function () {}, /** * @method fullPathFromRelativeFile * @return A value converted from C/C++ "std::string" * @param {const std::string&} * @param {const std::string&} */ fullPathFromRelativeFile : function () {}, /** * @method setPopupNotify * @param {bool} */ setPopupNotify : function () {}, /** * @method getWritablePath * @return A value converted from C/C++ "std::string" */ getWritablePath : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::FileUtils*" */ getInstance : function () {}, }; /** * @class Application */ cc.Application = { /** * @method getTargetPlatform * @return A value converted from C/C++ "cocos2d::ApplicationProtocol::Platform" */ getTargetPlatform : function () {}, /** * @method setAnimationInterval * @param {double} */ setAnimationInterval : function () {}, /** * @method getCurrentLanguage * @return A value converted from C/C++ "cocos2d::LanguageType" */ getCurrentLanguage : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::Application*" */ getInstance : function () {}, }; /** * @class EGLViewProtocol */ cc.EGLViewProtocol = { /** * @method setFrameSize * @param {float} * @param {float} */ setFrameSize : function () {}, /** * @method swapBuffers */ swapBuffers : function () {}, /** * @method getViewPortRect * @return A value converted from C/C++ "const cocos2d::Rect&" */ getViewPortRect : function () {}, /** * @method end */ end : function () {}, /** * @method setViewName * @param {const std::string&} */ setViewName : function () {}, /** * @method getScaleY * @return A value converted from C/C++ "float" */ getScaleY : function () {}, /** * @method getScaleX * @return A value converted from C/C++ "float" */ getScaleX : function () {}, /** * @method getVisibleOrigin * @return A value converted from C/C++ "cocos2d::Point" */ getVisibleOrigin : function () {}, /** * @method getViewName * @return A value converted from C/C++ "const std::string&" */ getViewName : function () {}, /** * @method getVisibleSize * @return A value converted from C/C++ "cocos2d::Size" */ getVisibleSize : function () {}, /** * @method isScissorEnabled * @return A value converted from C/C++ "bool" */ isScissorEnabled : function () {}, /** * @method setIMEKeyboardState * @param {bool} */ setIMEKeyboardState : function () {}, /** * @method setDesignResolutionSize * @param {float} * @param {float} * @param {ResolutionPolicy} */ setDesignResolutionSize : function () {}, /** * @method getDesignResolutionSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getDesignResolutionSize : function () {}, /** * @method setViewPortInPoints * @param {float} * @param {float} * @param {float} * @param {float} */ setViewPortInPoints : function () {}, /** * @method setScissorInPoints * @param {float} * @param {float} * @param {float} * @param {float} */ setScissorInPoints : function () {}, /** * @method getFrameSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getFrameSize : function () {}, /** * @method getScissorRect * @return A value converted from C/C++ "cocos2d::Rect" */ getScissorRect : function () {}, /** * @method isOpenGLReady * @return A value converted from C/C++ "bool" */ isOpenGLReady : function () {}, /** * @method pollInputEvents */ pollInputEvents : function () {}, }; /** * @class EGLView */ cc.EGLView = { /** * @method setIMEKeyboardState * @param {bool} */ setIMEKeyboardState : function () {}, /** * @method isOpenGLReady * @return A value converted from C/C++ "bool" */ isOpenGLReady : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::EGLView*" */ getInstance : function () {}, }; /** * @class ShaderCache */ cc.ShaderCache = { /** * @method reloadDefaultShaders */ reloadDefaultShaders : function () {}, /** * @method addProgram * @param {cocos2d::GLProgram*} * @param {const std::string&} */ addProgram : function () {}, /** * @method getProgram * @return A value converted from C/C++ "cocos2d::GLProgram*" * @param {const std::string&} */ getProgram : function () {}, /** * @method loadDefaultShaders */ loadDefaultShaders : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::ShaderCache*" */ getInstance : function () {}, /** * @method ShaderCache * @constructor */ ShaderCache : function () {}, }; /** * @class AnimationCache */ cc.AnimationCache = { /** * @method getAnimation * @return A value converted from C/C++ "cocos2d::Animation*" * @param {const std::string&} */ getAnimation : function () {}, /** * @method addAnimation * @param {cocos2d::Animation*} * @param {const std::string&} */ addAnimation : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method addAnimationsWithDictionary * @param {const cocos2d::ValueMap&} * @param {const std::string&} */ addAnimationsWithDictionary : function () {}, /** * @method removeAnimation * @param {const std::string&} */ removeAnimation : function () {}, /** * @method addAnimationsWithFile * @param {const std::string&} */ addAnimationsWithFile : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::AnimationCache*" */ getInstance : function () {}, /** * @method AnimationCache * @constructor */ AnimationCache : function () {}, }; /** * @class SpriteFrameCache */ cc.SpriteFrameCache = { /** * @method addSpriteFrame * @param {cocos2d::SpriteFrame*} * @param {const std::string&} */ addSpriteFrame : function () {}, /** * @method removeUnusedSpriteFrames */ removeUnusedSpriteFrames : function () {}, /** * @method getSpriteFrameByName * @return A value converted from C/C++ "cocos2d::SpriteFrame*" * @param {const std::string&} */ getSpriteFrameByName : function () {}, /** * @method removeSpriteFramesFromFile * @param {const std::string&} */ removeSpriteFramesFromFile : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method removeSpriteFrames */ removeSpriteFrames : function () {}, /** * @method removeSpriteFramesFromTexture * @param {cocos2d::Texture2D*} */ removeSpriteFramesFromTexture : function () {}, /** * @method removeSpriteFrameByName * @param {const std::string&} */ removeSpriteFrameByName : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::SpriteFrameCache*" */ getInstance : function () {}, }; /** * @class UserDefault */ cc.UserDefault = { /** * @method setIntegerForKey * @param {const char*} * @param {int} */ setIntegerForKey : function () {}, /** * @method setDoubleForKey * @param {const char*} * @param {double} */ setDoubleForKey : function () {}, /** * @method setFloatForKey * @param {const char*} * @param {float} */ setFloatForKey : function () {}, /** * @method setStringForKey * @param {const char*} * @param {const std::string&} */ setStringForKey : function () {}, /** * @method flush */ flush : function () {}, /** * @method setBoolForKey * @param {const char*} * @param {bool} */ setBoolForKey : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getXMLFilePath * @return A value converted from C/C++ "const std::string&" */ getXMLFilePath : function () {}, /** * @method isXMLFileExist * @return A value converted from C/C++ "bool" */ isXMLFileExist : function () {}, }; /** * @class TextureCache */ cc.TextureCache = { /** * @method removeTextureForKey * @param {const std::string&} */ removeTextureForKey : function () {}, /** * @method removeAllTextures */ removeAllTextures : function () {}, /** * @method getDescription * @return A value converted from C/C++ "std::string" */ getDescription : function () {}, /** * @method getCachedTextureInfo * @return A value converted from C/C++ "std::string" */ getCachedTextureInfo : function () {}, /** * @method getTextureForKey * @return A value converted from C/C++ "cocos2d::Texture2D*" * @param {const std::string&} */ getTextureForKey : function () {}, /** * @method removeUnusedTextures */ removeUnusedTextures : function () {}, /** * @method removeTexture * @param {cocos2d::Texture2D*} */ removeTexture : function () {}, /** * @method waitForQuit */ waitForQuit : function () {}, /** * @method TextureCache * @constructor */ TextureCache : function () {}, }; /** * @class ParallaxNode */ cc.ParallaxNode = { /** * @method addChild * @param {cocos2d::Node*} * @param {int} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} */ addChild : function () {}, /** * @method removeAllChildrenWithCleanup * @param {bool} */ removeAllChildrenWithCleanup : function () {}, /** * @method setParallaxArray * @param {cocos2d::_ccArray*} */ setParallaxArray : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::ParallaxNode*" */ create : function () {}, }; /** * @class TMXObjectGroup */ cc.TMXObjectGroup = { /** * @method setPositionOffset * @param {const cocos2d::Point&} */ setPositionOffset : function () {}, /** * @method getProperty * @return A value converted from C/C++ "cocos2d::Value" * @param {const std::string&} */ getProperty : function () {}, /** * @method getPositionOffset * @return A value converted from C/C++ "const cocos2d::Point&" */ getPositionOffset : function () {}, /** * @method getObject * @return A value converted from C/C++ "cocos2d::ValueMap" * @param {const std::string&} */ getObject : function () {}, /** * @method setGroupName * @param {const std::string&} */ setGroupName : function () {}, /** * @method getGroupName * @return A value converted from C/C++ "const std::string&" */ getGroupName : function () {}, /** * @method setProperties * @param {const cocos2d::ValueMap&} */ setProperties : function () {}, /** * @method setObjects * @param {const cocos2d::ValueVector&} */ setObjects : function () {}, /** * @method TMXObjectGroup * @constructor */ TMXObjectGroup : function () {}, }; /** * @class TMXLayerInfo */ cc.TMXLayerInfo = { /** * @method setProperties * @param {cocos2d::ValueMap} */ setProperties : function () {}, /** * @method getProperties * @return A value converted from C/C++ "cocos2d::ValueMap&" */ getProperties : function () {}, /** * @method TMXLayerInfo * @constructor */ TMXLayerInfo : function () {}, }; /** * @class TMXTilesetInfo */ cc.TMXTilesetInfo = { /** * @method rectForGID * @return A value converted from C/C++ "cocos2d::Rect" * @param {int} */ rectForGID : function () {}, /** * @method TMXTilesetInfo * @constructor */ TMXTilesetInfo : function () {}, }; /** * @class TMXMapInfo */ cc.TMXMapInfo = { /** * @method setObjectGroups * @param {const cocos2d::Vector&} */ setObjectGroups : function () {}, /** * @method setTileSize * @param {const cocos2d::Size&} */ setTileSize : function () {}, /** * @method initWithTMXFile * @return A value converted from C/C++ "bool" * @param {const std::string&} */ initWithTMXFile : function () {}, /** * @method getOrientation * @return A value converted from C/C++ "int" */ getOrientation : function () {}, /** * @method isStoringCharacters * @return A value converted from C/C++ "bool" */ isStoringCharacters : function () {}, /** * @method setLayers * @param {const cocos2d::Vector&} */ setLayers : function () {}, /** * @method parseXMLFile * @return A value converted from C/C++ "bool" * @param {const std::string&} */ parseXMLFile : function () {}, /** * @method getParentElement * @return A value converted from C/C++ "int" */ getParentElement : function () {}, /** * @method setTMXFileName * @param {const std::string&} */ setTMXFileName : function () {}, /** * @method parseXMLString * @return A value converted from C/C++ "bool" * @param {const std::string&} */ parseXMLString : function () {}, /** * @method getParentGID * @return A value converted from C/C++ "int" */ getParentGID : function () {}, /** * @method setParentElement * @param {int} */ setParentElement : function () {}, /** * @method initWithXML * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {const std::string&} */ initWithXML : function () {}, /** * @method setParentGID * @param {int} */ setParentGID : function () {}, /** * @method getLayerAttribs * @return A value converted from C/C++ "int" */ getLayerAttribs : function () {}, /** * @method getTileSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getTileSize : function () {}, /** * @method getTileProperties * @return A value converted from C/C++ "cocos2d::ValueMapIntKey&" */ getTileProperties : function () {}, /** * @method getTMXFileName * @return A value converted from C/C++ "const std::string&" */ getTMXFileName : function () {}, /** * @method setCurrentString * @param {const std::string&} */ setCurrentString : function () {}, /** * @method setProperties * @param {const cocos2d::ValueMap&} */ setProperties : function () {}, /** * @method setOrientation * @param {int} */ setOrientation : function () {}, /** * @method setTileProperties * @param {const cocos2d::ValueMapIntKey&} */ setTileProperties : function () {}, /** * @method setMapSize * @param {const cocos2d::Size&} */ setMapSize : function () {}, /** * @method setStoringCharacters * @param {bool} */ setStoringCharacters : function () {}, /** * @method getMapSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getMapSize : function () {}, /** * @method setTilesets * @param {const cocos2d::Vector&} */ setTilesets : function () {}, /** * @method getCurrentString * @return A value converted from C/C++ "const std::string&" */ getCurrentString : function () {}, /** * @method setLayerAttribs * @param {int} */ setLayerAttribs : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TMXMapInfo*" * @param {const std::string&} */ create : function () {}, /** * @method createWithXML * @return A value converted from C/C++ "cocos2d::TMXMapInfo*" * @param {const std::string&} * @param {const std::string&} */ createWithXML : function () {}, /** * @method TMXMapInfo * @constructor */ TMXMapInfo : function () {}, }; /** * @class TMXLayer */ cc.TMXLayer = { /** * @method getTileGIDAt * @return A value converted from C/C++ "int" * @param {const cocos2d::Point&} * @param {cocos2d::ccTMXTileFlags*} */ getTileGIDAt : function () {}, /** * @method getPositionAt * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ getPositionAt : function () {}, /** * @method setLayerOrientation * @param {int} */ setLayerOrientation : function () {}, /** * @method releaseMap */ releaseMap : function () {}, /** * @method setTiles * @param {int*} */ setTiles : function () {}, /** * @method getLayerSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getLayerSize : function () {}, /** * @method setMapTileSize * @param {const cocos2d::Size&} */ setMapTileSize : function () {}, /** * @method getLayerOrientation * @return A value converted from C/C++ "int" */ getLayerOrientation : function () {}, /** * @method setProperties * @param {const cocos2d::ValueMap&} */ setProperties : function () {}, /** * @method setLayerName * @param {const std::string&} */ setLayerName : function () {}, /** * @method removeTileAt * @param {const cocos2d::Point&} */ removeTileAt : function () {}, /** * @method initWithTilesetInfo * @return A value converted from C/C++ "bool" * @param {cocos2d::TMXTilesetInfo*} * @param {cocos2d::TMXLayerInfo*} * @param {cocos2d::TMXMapInfo*} */ initWithTilesetInfo : function () {}, /** * @method setupTiles */ setupTiles : function () {}, /** * @method getMapTileSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getMapTileSize : function () {}, /** * @method getProperty * @return A value converted from C/C++ "cocos2d::Value" * @param {const std::string&} */ getProperty : function () {}, /** * @method setLayerSize * @param {const cocos2d::Size&} */ setLayerSize : function () {}, /** * @method getLayerName * @return A value converted from C/C++ "const std::string&" */ getLayerName : function () {}, /** * @method setTileSet * @param {cocos2d::TMXTilesetInfo*} */ setTileSet : function () {}, /** * @method getTileSet * @return A value converted from C/C++ "cocos2d::TMXTilesetInfo*" */ getTileSet : function () {}, /** * @method getTileAt * @return A value converted from C/C++ "cocos2d::Sprite*" * @param {const cocos2d::Point&} */ getTileAt : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TMXLayer*" * @param {cocos2d::TMXTilesetInfo*} * @param {cocos2d::TMXLayerInfo*} * @param {cocos2d::TMXMapInfo*} */ create : function () {}, /** * @method TMXLayer * @constructor */ TMXLayer : function () {}, }; /** * @class TMXTiledMap */ cc.TMXTiledMap = { /** * @method setObjectGroups * @param {const cocos2d::Vector&} */ setObjectGroups : function () {}, /** * @method getProperty * @return A value converted from C/C++ "cocos2d::Value" * @param {const std::string&} */ getProperty : function () {}, /** * @method setMapSize * @param {const cocos2d::Size&} */ setMapSize : function () {}, /** * @method getObjectGroup * @return A value converted from C/C++ "cocos2d::TMXObjectGroup*" * @param {const std::string&} */ getObjectGroup : function () {}, /** * @method getTileSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getTileSize : function () {}, /** * @method getMapSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getMapSize : function () {}, /** * @method getProperties * @return A value converted from C/C++ "cocos2d::ValueMap&" */ getProperties : function () {}, /** * @method getPropertiesForGID * @return A value converted from C/C++ "cocos2d::Value" * @param {int} */ getPropertiesForGID : function () {}, /** * @method setTileSize * @param {const cocos2d::Size&} */ setTileSize : function () {}, /** * @method setProperties * @param {const cocos2d::ValueMap&} */ setProperties : function () {}, /** * @method getLayer * @return A value converted from C/C++ "cocos2d::TMXLayer*" * @param {const std::string&} */ getLayer : function () {}, /** * @method getMapOrientation * @return A value converted from C/C++ "int" */ getMapOrientation : function () {}, /** * @method setMapOrientation * @param {int} */ setMapOrientation : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TMXTiledMap*" * @param {const std::string&} */ create : function () {}, /** * @method createWithXML * @return A value converted from C/C++ "cocos2d::TMXTiledMap*" * @param {const std::string&} * @param {const std::string&} */ createWithXML : function () {}, }; /** * @class TileMapAtlas */ cc.TileMapAtlas = { /** * @method initWithTileFile * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {const std::string&} * @param {int} * @param {int} */ initWithTileFile : function () {}, /** * @method releaseMap */ releaseMap : function () {}, /** * @method getTGAInfo * @return A value converted from C/C++ "cocos2d::sImageTGA*" */ getTGAInfo : function () {}, /** * @method getTileAt * @return A value converted from C/C++ "cocos2d::Color3B" * @param {const cocos2d::Point&} */ getTileAt : function () {}, /** * @method setTile * @param {const cocos2d::Color3B&} * @param {const cocos2d::Point&} */ setTile : function () {}, /** * @method setTGAInfo * @param {cocos2d::sImageTGA*} */ setTGAInfo : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::TileMapAtlas*" * @param {const std::string&} * @param {const std::string&} * @param {int} * @param {int} */ create : function () {}, /** * @method TileMapAtlas * @constructor */ TileMapAtlas : function () {}, }; /** * @class EventListenerTouchOneByOne */ cc.EventListenerTouchOneByOne = { /** * @method setSwallowTouches * @param {bool} */ setSwallowTouches : function () {}, }; /** * @class EventListenerTouchAllAtOnce */ cc.EventListenerTouchAllAtOnce = { }; /** * @class EventListenerKeyboard */ cc.EventListenerKeyboard = { }; /** * @class EventMouse */ cc.EventMouse = { /** * @method getMouseButton * @return A value converted from C/C++ "int" */ getMouseButton : function () {}, /** * @method setScrollData * @param {float} * @param {float} */ setScrollData : function () {}, /** * @method setMouseButton * @param {int} */ setMouseButton : function () {}, /** * @method getScrollY * @return A value converted from C/C++ "float" */ getScrollY : function () {}, /** * @method getScrollX * @return A value converted from C/C++ "float" */ getScrollX : function () {}, /** * @method getCursorX * @return A value converted from C/C++ "float" */ getCursorX : function () {}, /** * @method getCursorY * @return A value converted from C/C++ "float" */ getCursorY : function () {}, /** * @method setCursorPosition * @param {float} * @param {float} */ setCursorPosition : function () {}, /** * @method EventMouse * @constructor * @param {cocos2d::EventMouse::MouseEventType} */ EventMouse : function () {}, }; /** * @class EventListenerMouse */ cc.EventListenerMouse = { }; /** * @class EventAcceleration */ cc.EventAcceleration = { }; /** * @class EventListenerAcceleration */ cc.EventListenerAcceleration = { }; /** * @class EventCustom */ cc.EventCustom = { /** * @method getEventName * @return A value converted from C/C++ "const std::string&" */ getEventName : function () {}, /** * @method setUserData * @param {void*} */ setUserData : function () {}, /** * @method getUserData * @return A value converted from C/C++ "void*" */ getUserData : function () {}, /** * @method EventCustom * @constructor * @param {const std::string&} */ EventCustom : function () {}, }; /** * @class Timer */ cc.Timer = { /** * @method getInterval * @return A value converted from C/C++ "float" */ getInterval : function () {}, /** * @method setInterval * @param {float} */ setInterval : function () {}, /** * @method initWithScriptHandler * @return A value converted from C/C++ "bool" * @param {int} * @param {float} */ initWithScriptHandler : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method getScriptHandler * @return A value converted from C/C++ "int" */ getScriptHandler : function () {}, /** * @method Timer * @constructor */ Timer : function () {}, }; /** * @class Scheduler */ cc.Scheduler = { /** * @method setTimeScale * @param {float} */ setTimeScale : function () {}, /** * @method performFunctionInCocosThread * @param {const std::function&} */ performFunctionInCocosThread : function () {}, /** * @method getTimeScale * @return A value converted from C/C++ "float" */ getTimeScale : function () {}, /** * @method Scheduler * @constructor */ Scheduler : function () {}, }; /** * @class Component */ cc.Component = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method setName * @param {const std::string&} */ setName : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method serialize * @return A value converted from C/C++ "bool" * @param {void*} */ serialize : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method getOwner * @return A value converted from C/C++ "cocos2d::Node*" */ getOwner : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setOwner * @param {cocos2d::Node*} */ setOwner : function () {}, /** * @method getName * @return A value converted from C/C++ "const std::string&" */ getName : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::Component*" */ create : function () {}, }; /** * @class SimpleAudioEngine */ cc.AudioEngine = { /** * @method preloadBackgroundMusic * @param {const char*} */ preloadBackgroundMusic : function () {}, /** * @method stopBackgroundMusic */ stopBackgroundMusic : function () {}, /** * @method stopAllEffects */ stopAllEffects : function () {}, /** * @method getBackgroundMusicVolume * @return A value converted from C/C++ "float" */ getBackgroundMusicVolume : function () {}, /** * @method resumeBackgroundMusic */ resumeBackgroundMusic : function () {}, /** * @method setBackgroundMusicVolume * @param {float} */ setBackgroundMusicVolume : function () {}, /** * @method preloadEffect * @param {const char*} */ preloadEffect : function () {}, /** * @method isBackgroundMusicPlaying * @return A value converted from C/C++ "bool" */ isBackgroundMusicPlaying : function () {}, /** * @method getEffectsVolume * @return A value converted from C/C++ "float" */ getEffectsVolume : function () {}, /** * @method willPlayBackgroundMusic * @return A value converted from C/C++ "bool" */ willPlayBackgroundMusic : function () {}, /** * @method pauseEffect * @param {unsigned int} */ pauseEffect : function () {}, /** * @method playEffect * @return A value converted from C/C++ "unsigned int" * @param {const char*} * @param {bool} * @param {float} * @param {float} * @param {float} */ playEffect : function () {}, /** * @method rewindBackgroundMusic */ rewindBackgroundMusic : function () {}, /** * @method playBackgroundMusic * @param {const char*} * @param {bool} */ playBackgroundMusic : function () {}, /** * @method resumeAllEffects */ resumeAllEffects : function () {}, /** * @method setEffectsVolume * @param {float} */ setEffectsVolume : function () {}, /** * @method stopEffect * @param {unsigned int} */ stopEffect : function () {}, /** * @method pauseBackgroundMusic */ pauseBackgroundMusic : function () {}, /** * @method pauseAllEffects */ pauseAllEffects : function () {}, /** * @method unloadEffect * @param {const char*} */ unloadEffect : function () {}, /** * @method resumeEffect * @param {unsigned int} */ resumeEffect : function () {}, /** * @method end */ end : function () {}, /** * @method getInstance * @return A value converted from C/C++ "CocosDenshion::SimpleAudioEngine*" */ getInstance : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp ================================================ #include "lua_cocos2dx_extension_auto.hpp" #include "cocos-ext.h" #include "CocosBuilder.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" int lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::extension::Scale9Sprite* ret = cobj->resizableSpriteWithCapInsets(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resizableSpriteWithCapInsets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_setInsetBottom(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetBottom'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setInsetBottom(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInsetBottom",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetBottom'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } bool ret = cobj->initWithSpriteFrameName(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool ret = cobj->initWithSpriteFrameName(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithSpriteFrameName",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_setInsetTop(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetTop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setInsetTop(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInsetTop",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetTop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_init(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_setPreferredSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setPreferredSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPreferredSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPreferredSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setPreferredSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_setSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setSpriteFrame(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_initWithBatchNode(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_initWithBatchNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 3) { cocos2d::SpriteBatchNode* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteBatchNode",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::Rect arg2; ok &= luaval_to_rect(tolua_S, 4, &arg2); if (!ok) { break; } bool ret = cobj->initWithBatchNode(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 4) { cocos2d::SpriteBatchNode* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteBatchNode",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::Rect arg3; ok &= luaval_to_rect(tolua_S, 5, &arg3); if (!ok) { break; } bool ret = cobj->initWithBatchNode(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithBatchNode",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_initWithBatchNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_getInsetBottom(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetBottom'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getInsetBottom(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInsetBottom",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetBottom'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_getCapInsets(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getCapInsets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Rect ret = cobj->getCapInsets(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCapInsets",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getCapInsets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_updateWithBatchNode(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_updateWithBatchNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { cocos2d::SpriteBatchNode* arg0; cocos2d::Rect arg1; bool arg2; cocos2d::Rect arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteBatchNode",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_rect(tolua_S, 3, &arg1); ok &= luaval_to_boolean(tolua_S, 4,&arg2); ok &= luaval_to_rect(tolua_S, 5, &arg3); if(!ok) return 0; bool ret = cobj->updateWithBatchNode(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateWithBatchNode",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_updateWithBatchNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_getInsetRight(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetRight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getInsetRight(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInsetRight",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetRight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_getOriginalSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getOriginalSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getOriginalSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOriginalSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getOriginalSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_initWithFile(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_initWithFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool ret = cobj->initWithFile(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::Rect arg2; ok &= luaval_to_rect(tolua_S, 4, &arg2); if (!ok) { break; } bool ret = cobj->initWithFile(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 2) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } bool ret = cobj->initWithFile(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } bool ret = cobj->initWithFile(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_initWithFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_getInsetTop(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetTop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getInsetTop(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInsetTop",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetTop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_setInsetLeft(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetLeft'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setInsetLeft(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInsetLeft",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetLeft'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool ret = cobj->initWithSpriteFrame(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 2) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } bool ret = cobj->initWithSpriteFrame(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithSpriteFrame",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_getPreferredSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getPreferredSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getPreferredSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPreferredSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getPreferredSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_setCapInsets(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setCapInsets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsets(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setCapInsets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_getInsetLeft(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetLeft'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getInsetLeft(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInsetLeft",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetLeft'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_setInsetRight(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetRight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setInsetRight(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInsetRight",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetRight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::Rect arg2; ok &= luaval_to_rect(tolua_S, 4, &arg2); if (!ok) { break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrameName(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrameName(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "createWithSpriteFrameName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Rect arg1; ok &= luaval_to_rect(tolua_S, 3, &arg1); if (!ok) { break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrame(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 1) { cocos2d::SpriteFrame* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrame(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "createWithSpriteFrame",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Scale9Sprite_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Scale9Sprite* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::Scale9Sprite(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Scale9Sprite"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.Scale9Sprite"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Scale9Sprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_Scale9Sprite_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Scale9Sprite)"); return 0; } int lua_register_cocos2dx_extension_Scale9Sprite(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Scale9Sprite"); tolua_cclass(tolua_S,"Scale9Sprite","cc.Scale9Sprite","cc.Node",NULL); tolua_beginmodule(tolua_S,"Scale9Sprite"); tolua_function(tolua_S,"resizableSpriteWithCapInsets",lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets); tolua_function(tolua_S,"setInsetBottom",lua_cocos2dx_extension_Scale9Sprite_setInsetBottom); tolua_function(tolua_S,"initWithSpriteFrameName",lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName); tolua_function(tolua_S,"setInsetTop",lua_cocos2dx_extension_Scale9Sprite_setInsetTop); tolua_function(tolua_S,"init",lua_cocos2dx_extension_Scale9Sprite_init); tolua_function(tolua_S,"setPreferredSize",lua_cocos2dx_extension_Scale9Sprite_setPreferredSize); tolua_function(tolua_S,"setSpriteFrame",lua_cocos2dx_extension_Scale9Sprite_setSpriteFrame); tolua_function(tolua_S,"initWithBatchNode",lua_cocos2dx_extension_Scale9Sprite_initWithBatchNode); tolua_function(tolua_S,"getInsetBottom",lua_cocos2dx_extension_Scale9Sprite_getInsetBottom); tolua_function(tolua_S,"getCapInsets",lua_cocos2dx_extension_Scale9Sprite_getCapInsets); tolua_function(tolua_S,"updateWithBatchNode",lua_cocos2dx_extension_Scale9Sprite_updateWithBatchNode); tolua_function(tolua_S,"getInsetRight",lua_cocos2dx_extension_Scale9Sprite_getInsetRight); tolua_function(tolua_S,"getOriginalSize",lua_cocos2dx_extension_Scale9Sprite_getOriginalSize); tolua_function(tolua_S,"initWithFile",lua_cocos2dx_extension_Scale9Sprite_initWithFile); tolua_function(tolua_S,"getInsetTop",lua_cocos2dx_extension_Scale9Sprite_getInsetTop); tolua_function(tolua_S,"setInsetLeft",lua_cocos2dx_extension_Scale9Sprite_setInsetLeft); tolua_function(tolua_S,"initWithSpriteFrame",lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame); tolua_function(tolua_S,"getPreferredSize",lua_cocos2dx_extension_Scale9Sprite_getPreferredSize); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_extension_Scale9Sprite_setCapInsets); tolua_function(tolua_S,"getInsetLeft",lua_cocos2dx_extension_Scale9Sprite_getInsetLeft); tolua_function(tolua_S,"setInsetRight",lua_cocos2dx_extension_Scale9Sprite_setInsetRight); tolua_function(tolua_S,"new",lua_cocos2dx_extension_Scale9Sprite_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_Scale9Sprite_create); tolua_function(tolua_S,"createWithSpriteFrameName", lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName); tolua_function(tolua_S,"createWithSpriteFrame", lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::Scale9Sprite).name(); g_luaType[typeName] = "cc.Scale9Sprite"; g_typeCast["Scale9Sprite"] = "cc.Scale9Sprite"; return 1; } int lua_cocos2dx_extension_Control_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_onTouchMoved(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_onTouchMoved'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Touch* arg0; cocos2d::Event* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Event",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Event*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->onTouchMoved(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onTouchMoved",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_onTouchMoved'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_getState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_getState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getState(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getState",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_getState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_onTouchEnded(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_onTouchEnded'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Touch* arg0; cocos2d::Event* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Event",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Event*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->onTouchEnded(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onTouchEnded",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_onTouchEnded'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_sendActionsForControlEvents(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_sendActionsForControlEvents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::EventType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->sendActionsForControlEvents(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "sendActionsForControlEvents",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_sendActionsForControlEvents'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_setSelected(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_setSelected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSelected(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSelected",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_setSelected'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_isEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_isEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_isEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_onTouchCancelled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_onTouchCancelled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Touch* arg0; cocos2d::Event* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Event",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Event*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->onTouchCancelled(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onTouchCancelled",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_onTouchCancelled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_needsLayout(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_needsLayout'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->needsLayout(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "needsLayout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_needsLayout'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_onTouchBegan(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_onTouchBegan'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Touch* arg0; cocos2d::Event* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Event",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Event*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->onTouchBegan(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onTouchBegan",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_onTouchBegan'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_hasVisibleParents(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_hasVisibleParents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->hasVisibleParents(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hasVisibleParents",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_hasVisibleParents'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_isSelected(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_isSelected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isSelected(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isSelected",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_isSelected'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_isTouchInside(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_isTouchInside'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Touch* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->isTouchInside(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTouchInside",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_isTouchInside'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_setHighlighted(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_setHighlighted'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setHighlighted(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setHighlighted",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_setHighlighted'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_getTouchLocation(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_getTouchLocation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Touch* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Point ret = cobj->getTouchLocation(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchLocation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_getTouchLocation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_isHighlighted(lua_State* tolua_S) { int argc = 0; cocos2d::extension::Control* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::Control*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Control_isHighlighted'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isHighlighted(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isHighlighted",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_isHighlighted'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_Control_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::extension::Control* ret = cocos2d::extension::Control::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Control"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Control*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Control_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_Control_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Control)"); return 0; } int lua_register_cocos2dx_extension_Control(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.Control"); tolua_cclass(tolua_S,"Control","cc.Control","cc.Layer",NULL); tolua_beginmodule(tolua_S,"Control"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_Control_setEnabled); tolua_function(tolua_S,"onTouchMoved",lua_cocos2dx_extension_Control_onTouchMoved); tolua_function(tolua_S,"getState",lua_cocos2dx_extension_Control_getState); tolua_function(tolua_S,"onTouchEnded",lua_cocos2dx_extension_Control_onTouchEnded); tolua_function(tolua_S,"sendActionsForControlEvents",lua_cocos2dx_extension_Control_sendActionsForControlEvents); tolua_function(tolua_S,"setSelected",lua_cocos2dx_extension_Control_setSelected); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_extension_Control_isEnabled); tolua_function(tolua_S,"onTouchCancelled",lua_cocos2dx_extension_Control_onTouchCancelled); tolua_function(tolua_S,"needsLayout",lua_cocos2dx_extension_Control_needsLayout); tolua_function(tolua_S,"onTouchBegan",lua_cocos2dx_extension_Control_onTouchBegan); tolua_function(tolua_S,"hasVisibleParents",lua_cocos2dx_extension_Control_hasVisibleParents); tolua_function(tolua_S,"isSelected",lua_cocos2dx_extension_Control_isSelected); tolua_function(tolua_S,"isTouchInside",lua_cocos2dx_extension_Control_isTouchInside); tolua_function(tolua_S,"setHighlighted",lua_cocos2dx_extension_Control_setHighlighted); tolua_function(tolua_S,"getTouchLocation",lua_cocos2dx_extension_Control_getTouchLocation); tolua_function(tolua_S,"isHighlighted",lua_cocos2dx_extension_Control_isHighlighted); tolua_function(tolua_S,"create", lua_cocos2dx_extension_Control_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::Control).name(); g_luaType[typeName] = "cc.Control"; g_typeCast["Control"] = "cc.Control"; return 1; } int lua_cocos2dx_extension_ControlButton_isPushed(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_isPushed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isPushed(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isPushed",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_isPushed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setSelected(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setSelected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSelected(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSelected",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setSelected'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setTitleLabelForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setTitleLabelForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Node* arg0; cocos2d::extension::Control::State arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setTitleLabelForState(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleLabelForState",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setTitleLabelForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setAdjustBackgroundImage(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setAdjustBackgroundImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAdjustBackgroundImage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAdjustBackgroundImage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setAdjustBackgroundImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setHighlighted(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setHighlighted'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setHighlighted(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setHighlighted",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setHighlighted'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setZoomOnTouchDown(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setZoomOnTouchDown'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setZoomOnTouchDown(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setZoomOnTouchDown",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setZoomOnTouchDown'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setTitleForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setTitleForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; cocos2d::extension::Control::State arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setTitleForState(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleForState",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setTitleForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setLabelAnchorPoint(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setLabelAnchorPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setLabelAnchorPoint(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLabelAnchorPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setLabelAnchorPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getLabelAnchorPoint(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getLabelAnchorPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getLabelAnchorPoint(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLabelAnchorPoint",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getLabelAnchorPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getTitleTTFSizeForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getTitleTTFSizeForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; double ret = cobj->getTitleTTFSizeForState(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleTTFSizeForState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getTitleTTFSizeForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setTitleTTFForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setTitleTTFForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; cocos2d::extension::Control::State arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setTitleTTFForState(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleTTFForState",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setTitleTTFForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setTitleTTFSizeForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setTitleTTFSizeForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; cocos2d::extension::Control::State arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setTitleTTFSizeForState(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleTTFSizeForState",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setTitleTTFSizeForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setTitleLabel(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setTitleLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setTitleLabel(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleLabel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setTitleLabel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setPreferredSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setPreferredSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPreferredSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPreferredSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setPreferredSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getCurrentTitleColor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getCurrentTitleColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color3B& ret = cobj->getCurrentTitleColor(); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentTitleColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getCurrentTitleColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getBackgroundSpriteForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getBackgroundSpriteForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::extension::Scale9Sprite* ret = cobj->getBackgroundSpriteForState(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackgroundSpriteForState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getBackgroundSpriteForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getHorizontalOrigin(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getHorizontalOrigin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getHorizontalOrigin(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getHorizontalOrigin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getHorizontalOrigin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_needsLayout(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_needsLayout'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->needsLayout(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "needsLayout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_needsLayout'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getCurrentTitle(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getCurrentTitle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { std::string ret = cobj->getCurrentTitle(); tolua_pushcppstring(tolua_S,ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { const std::string& ret = cobj->getCurrentTitle(); tolua_pushcppstring(tolua_S,ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentTitle",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getCurrentTitle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getScaleRatio(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getScaleRatio'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getScaleRatio(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScaleRatio",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getScaleRatio'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getTitleTTFForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getTitleTTFForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; const std::string& ret = cobj->getTitleTTFForState(arg0); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleTTFForState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getTitleTTFForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getBackgroundSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getBackgroundSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::extension::Scale9Sprite* ret = cobj->getBackgroundSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scale9Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::Scale9Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackgroundSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getBackgroundSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getTitleColorForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getTitleColorForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Color3B ret = cobj->getTitleColorForState(arg0); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleColorForState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getTitleColorForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setTitleColorForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setTitleColorForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Color3B arg0; cocos2d::extension::Control::State arg1; ok &= luaval_to_color3b(tolua_S, 2, &arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setTitleColorForState(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleColorForState",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setTitleColorForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->doesAdjustBackgroundImage(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "doesAdjustBackgroundImage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::SpriteFrame* arg0; cocos2d::extension::Control::State arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.SpriteFrame",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setBackgroundSpriteFrameForState(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackgroundSpriteFrameForState",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setBackgroundSpriteForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setBackgroundSpriteForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::extension::Scale9Sprite* arg0; cocos2d::extension::Control::State arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setBackgroundSpriteForState(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackgroundSpriteForState",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setBackgroundSpriteForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setScaleRatio(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setScaleRatio'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScaleRatio(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScaleRatio",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setScaleRatio'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setBackgroundSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setBackgroundSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Scale9Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBackgroundSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackgroundSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setBackgroundSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getTitleLabel(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getTitleLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getTitleLabel(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleLabel",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getTitleLabel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getPreferredSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getPreferredSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getPreferredSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPreferredSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getPreferredSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getVerticalMargin(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getVerticalMargin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getVerticalMargin(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVerticalMargin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getVerticalMargin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getTitleLabelForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getTitleLabelForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Node* ret = cobj->getTitleLabelForState(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleLabelForState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getTitleLabelForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setMargins(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setMargins'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; int arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setMargins(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMargins",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setMargins'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_setTitleBMFontForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_setTitleBMFontForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; cocos2d::extension::Control::State arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setTitleBMFontForState(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleBMFontForState",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_setTitleBMFontForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getTitleBMFontForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getTitleBMFontForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; const std::string& ret = cobj->getTitleBMFontForState(arg0); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleBMFontForState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getTitleBMFontForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getZoomOnTouchDown(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getZoomOnTouchDown'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getZoomOnTouchDown(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getZoomOnTouchDown",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getZoomOnTouchDown'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_getTitleForState(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlButton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlButton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlButton_getTitleForState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::State arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; std::string ret = cobj->getTitleForState(arg0); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleForState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_getTitleForState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlButton_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ControlButton",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { cocos2d::extension::Scale9Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlButton"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlButton*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlButton"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlButton*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::Scale9Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlButton"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlButton*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlButton"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlButton*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlButton_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ControlButton_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ControlButton)"); return 0; } int lua_register_cocos2dx_extension_ControlButton(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ControlButton"); tolua_cclass(tolua_S,"ControlButton","cc.ControlButton","cc.Control",NULL); tolua_beginmodule(tolua_S,"ControlButton"); tolua_function(tolua_S,"isPushed",lua_cocos2dx_extension_ControlButton_isPushed); tolua_function(tolua_S,"setSelected",lua_cocos2dx_extension_ControlButton_setSelected); tolua_function(tolua_S,"setTitleLabelForState",lua_cocos2dx_extension_ControlButton_setTitleLabelForState); tolua_function(tolua_S,"setAdjustBackgroundImage",lua_cocos2dx_extension_ControlButton_setAdjustBackgroundImage); tolua_function(tolua_S,"setHighlighted",lua_cocos2dx_extension_ControlButton_setHighlighted); tolua_function(tolua_S,"setZoomOnTouchDown",lua_cocos2dx_extension_ControlButton_setZoomOnTouchDown); tolua_function(tolua_S,"setTitleForState",lua_cocos2dx_extension_ControlButton_setTitleForState); tolua_function(tolua_S,"setLabelAnchorPoint",lua_cocos2dx_extension_ControlButton_setLabelAnchorPoint); tolua_function(tolua_S,"getLabelAnchorPoint",lua_cocos2dx_extension_ControlButton_getLabelAnchorPoint); tolua_function(tolua_S,"getTitleTTFSizeForState",lua_cocos2dx_extension_ControlButton_getTitleTTFSizeForState); tolua_function(tolua_S,"setTitleTTFForState",lua_cocos2dx_extension_ControlButton_setTitleTTFForState); tolua_function(tolua_S,"setTitleTTFSizeForState",lua_cocos2dx_extension_ControlButton_setTitleTTFSizeForState); tolua_function(tolua_S,"setTitleLabel",lua_cocos2dx_extension_ControlButton_setTitleLabel); tolua_function(tolua_S,"setPreferredSize",lua_cocos2dx_extension_ControlButton_setPreferredSize); tolua_function(tolua_S,"getCurrentTitleColor",lua_cocos2dx_extension_ControlButton_getCurrentTitleColor); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlButton_setEnabled); tolua_function(tolua_S,"getBackgroundSpriteForState",lua_cocos2dx_extension_ControlButton_getBackgroundSpriteForState); tolua_function(tolua_S,"getHorizontalOrigin",lua_cocos2dx_extension_ControlButton_getHorizontalOrigin); tolua_function(tolua_S,"needsLayout",lua_cocos2dx_extension_ControlButton_needsLayout); tolua_function(tolua_S,"getCurrentTitle",lua_cocos2dx_extension_ControlButton_getCurrentTitle); tolua_function(tolua_S,"getScaleRatio",lua_cocos2dx_extension_ControlButton_getScaleRatio); tolua_function(tolua_S,"getTitleTTFForState",lua_cocos2dx_extension_ControlButton_getTitleTTFForState); tolua_function(tolua_S,"getBackgroundSprite",lua_cocos2dx_extension_ControlButton_getBackgroundSprite); tolua_function(tolua_S,"getTitleColorForState",lua_cocos2dx_extension_ControlButton_getTitleColorForState); tolua_function(tolua_S,"setTitleColorForState",lua_cocos2dx_extension_ControlButton_setTitleColorForState); tolua_function(tolua_S,"doesAdjustBackgroundImage",lua_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage); tolua_function(tolua_S,"setBackgroundSpriteFrameForState",lua_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState); tolua_function(tolua_S,"setBackgroundSpriteForState",lua_cocos2dx_extension_ControlButton_setBackgroundSpriteForState); tolua_function(tolua_S,"setScaleRatio",lua_cocos2dx_extension_ControlButton_setScaleRatio); tolua_function(tolua_S,"setBackgroundSprite",lua_cocos2dx_extension_ControlButton_setBackgroundSprite); tolua_function(tolua_S,"getTitleLabel",lua_cocos2dx_extension_ControlButton_getTitleLabel); tolua_function(tolua_S,"getPreferredSize",lua_cocos2dx_extension_ControlButton_getPreferredSize); tolua_function(tolua_S,"getVerticalMargin",lua_cocos2dx_extension_ControlButton_getVerticalMargin); tolua_function(tolua_S,"getTitleLabelForState",lua_cocos2dx_extension_ControlButton_getTitleLabelForState); tolua_function(tolua_S,"setMargins",lua_cocos2dx_extension_ControlButton_setMargins); tolua_function(tolua_S,"setTitleBMFontForState",lua_cocos2dx_extension_ControlButton_setTitleBMFontForState); tolua_function(tolua_S,"getTitleBMFontForState",lua_cocos2dx_extension_ControlButton_getTitleBMFontForState); tolua_function(tolua_S,"getZoomOnTouchDown",lua_cocos2dx_extension_ControlButton_getZoomOnTouchDown); tolua_function(tolua_S,"getTitleForState",lua_cocos2dx_extension_ControlButton_getTitleForState); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlButton_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlButton).name(); g_luaType[typeName] = "cc.ControlButton"; g_typeCast["ControlButton"] = "cc.ControlButton"; return 1; } int lua_cocos2dx_extension_ControlHuePicker_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Node* arg0; cocos2d::Point arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; bool ret = cobj->initWithTargetAndPos(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTargetAndPos",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_setHue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_setHue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setHue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setHue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_setHue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_getStartPos(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_getStartPos'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getStartPos(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartPos",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_getStartPos'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_getHue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_getHue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getHue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getHue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_getHue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_getSlider(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_getSlider'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getSlider(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSlider",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_getSlider'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_setBackground(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_setBackground'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBackground(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackground",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_setBackground'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_setHuePercentage(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_setHuePercentage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setHuePercentage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setHuePercentage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_setHuePercentage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_getBackground(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_getBackground'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getBackground(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackground",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_getBackground'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_getHuePercentage(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_getHuePercentage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getHuePercentage(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getHuePercentage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_getHuePercentage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_setSlider(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlHuePicker_setSlider'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setSlider(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSlider",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_setSlider'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ControlHuePicker",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::Node* arg0; cocos2d::Point arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::extension::ControlHuePicker* ret = cocos2d::extension::ControlHuePicker::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlHuePicker"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlHuePicker*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlHuePicker_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlHuePicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::ControlHuePicker(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ControlHuePicker"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ControlHuePicker"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ControlHuePicker",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlHuePicker_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ControlHuePicker_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ControlHuePicker)"); return 0; } int lua_register_cocos2dx_extension_ControlHuePicker(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ControlHuePicker"); tolua_cclass(tolua_S,"ControlHuePicker","cc.ControlHuePicker","cc.Control",NULL); tolua_beginmodule(tolua_S,"ControlHuePicker"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlHuePicker_setEnabled); tolua_function(tolua_S,"initWithTargetAndPos",lua_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos); tolua_function(tolua_S,"setHue",lua_cocos2dx_extension_ControlHuePicker_setHue); tolua_function(tolua_S,"getStartPos",lua_cocos2dx_extension_ControlHuePicker_getStartPos); tolua_function(tolua_S,"getHue",lua_cocos2dx_extension_ControlHuePicker_getHue); tolua_function(tolua_S,"getSlider",lua_cocos2dx_extension_ControlHuePicker_getSlider); tolua_function(tolua_S,"setBackground",lua_cocos2dx_extension_ControlHuePicker_setBackground); tolua_function(tolua_S,"setHuePercentage",lua_cocos2dx_extension_ControlHuePicker_setHuePercentage); tolua_function(tolua_S,"getBackground",lua_cocos2dx_extension_ControlHuePicker_getBackground); tolua_function(tolua_S,"getHuePercentage",lua_cocos2dx_extension_ControlHuePicker_getHuePercentage); tolua_function(tolua_S,"setSlider",lua_cocos2dx_extension_ControlHuePicker_setSlider); tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlHuePicker_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlHuePicker_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlHuePicker).name(); g_luaType[typeName] = "cc.ControlHuePicker"; g_typeCast["ControlHuePicker"] = "cc.ControlHuePicker"; return 1; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getShadow(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShadow",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Node* arg0; cocos2d::Point arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; bool ret = cobj->initWithTargetAndPos(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTargetAndPos",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getStartPos(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStartPos",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getOverlay(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOverlay",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getSlider(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSlider",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getBackground(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackground",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSaturation(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSaturation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getBrightness(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBrightness",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ControlSaturationBrightnessPicker",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::Node* arg0; cocos2d::Point arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::extension::ControlSaturationBrightnessPicker* ret = cocos2d::extension::ControlSaturationBrightnessPicker::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlSaturationBrightnessPicker"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlSaturationBrightnessPicker*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSaturationBrightnessPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::ControlSaturationBrightnessPicker(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ControlSaturationBrightnessPicker"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ControlSaturationBrightnessPicker"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ControlSaturationBrightnessPicker",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ControlSaturationBrightnessPicker_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ControlSaturationBrightnessPicker)"); return 0; } int lua_register_cocos2dx_extension_ControlSaturationBrightnessPicker(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ControlSaturationBrightnessPicker"); tolua_cclass(tolua_S,"ControlSaturationBrightnessPicker","cc.ControlSaturationBrightnessPicker","cc.Control",NULL); tolua_beginmodule(tolua_S,"ControlSaturationBrightnessPicker"); tolua_function(tolua_S,"getShadow",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow); tolua_function(tolua_S,"initWithTargetAndPos",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos); tolua_function(tolua_S,"getStartPos",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos); tolua_function(tolua_S,"getOverlay",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_setEnabled); tolua_function(tolua_S,"getSlider",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider); tolua_function(tolua_S,"getBackground",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground); tolua_function(tolua_S,"getSaturation",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation); tolua_function(tolua_S,"getBrightness",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness); tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlSaturationBrightnessPicker_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlSaturationBrightnessPicker).name(); g_luaType[typeName] = "cc.ControlSaturationBrightnessPicker"; g_typeCast["ControlSaturationBrightnessPicker"] = "cc.ControlSaturationBrightnessPicker"; return 1; } int lua_cocos2dx_extension_ControlColourPicker_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_getHuePicker(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_getHuePicker'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::extension::ControlHuePicker* ret = cobj->getHuePicker(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlHuePicker"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlHuePicker*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getHuePicker",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_getHuePicker'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_setColor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_setColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_setColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Object* arg0; cocos2d::extension::Control::EventType arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Object",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Object*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->hueSliderValueChanged(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hueSliderValueChanged",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_getcolourPicker(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_getcolourPicker'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::extension::ControlSaturationBrightnessPicker* ret = cobj->getcolourPicker(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlSaturationBrightnessPicker"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlSaturationBrightnessPicker*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getcolourPicker",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_getcolourPicker'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_setBackground(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_setBackground'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBackground(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackground",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_setBackground'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_init(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_setcolourPicker(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_setcolourPicker'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::ControlSaturationBrightnessPicker* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ControlSaturationBrightnessPicker",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::extension::ControlSaturationBrightnessPicker*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setcolourPicker(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setcolourPicker",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_setcolourPicker'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Object* arg0; cocos2d::extension::Control::EventType arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Object",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Object*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->colourSliderValueChanged(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "colourSliderValueChanged",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_setHuePicker(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_setHuePicker'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::ControlHuePicker* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ControlHuePicker",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::extension::ControlHuePicker*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setHuePicker(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setHuePicker",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_setHuePicker'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_getBackground(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlColourPicker*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlColourPicker_getBackground'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getBackground(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackground",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_getBackground'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ControlColourPicker",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::extension::ControlColourPicker* ret = cocos2d::extension::ControlColourPicker::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlColourPicker"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlColourPicker*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlColourPicker_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlColourPicker* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::ControlColourPicker(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ControlColourPicker"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ControlColourPicker"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ControlColourPicker",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlColourPicker_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ControlColourPicker_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ControlColourPicker)"); return 0; } int lua_register_cocos2dx_extension_ControlColourPicker(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ControlColourPicker"); tolua_cclass(tolua_S,"ControlColourPicker","cc.ControlColourPicker","cc.Control",NULL); tolua_beginmodule(tolua_S,"ControlColourPicker"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlColourPicker_setEnabled); tolua_function(tolua_S,"getHuePicker",lua_cocos2dx_extension_ControlColourPicker_getHuePicker); tolua_function(tolua_S,"setColor",lua_cocos2dx_extension_ControlColourPicker_setColor); tolua_function(tolua_S,"hueSliderValueChanged",lua_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged); tolua_function(tolua_S,"getcolourPicker",lua_cocos2dx_extension_ControlColourPicker_getcolourPicker); tolua_function(tolua_S,"setBackground",lua_cocos2dx_extension_ControlColourPicker_setBackground); tolua_function(tolua_S,"init",lua_cocos2dx_extension_ControlColourPicker_init); tolua_function(tolua_S,"setcolourPicker",lua_cocos2dx_extension_ControlColourPicker_setcolourPicker); tolua_function(tolua_S,"colourSliderValueChanged",lua_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged); tolua_function(tolua_S,"setHuePicker",lua_cocos2dx_extension_ControlColourPicker_setHuePicker); tolua_function(tolua_S,"getBackground",lua_cocos2dx_extension_ControlColourPicker_getBackground); tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlColourPicker_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlColourPicker_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlColourPicker).name(); g_luaType[typeName] = "cc.ControlColourPicker"; g_typeCast["ControlColourPicker"] = "cc.ControlColourPicker"; return 1; } int lua_cocos2dx_extension_ControlPotentiometer_setPreviousLocation(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_setPreviousLocation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPreviousLocation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPreviousLocation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_setPreviousLocation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_setValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_setValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_setValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_getProgressTimer(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_getProgressTimer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ProgressTimer* ret = cobj->getProgressTimer(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ProgressTimer"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::ProgressTimer*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProgressTimer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_getProgressTimer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_getMaximumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_getMaximumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMaximumValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaximumValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_getMaximumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::Point arg2; cocos2d::Point arg3; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); if(!ok) return 0; double ret = cobj->angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(arg0, arg1, arg2, arg3); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_potentiometerBegan(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_potentiometerBegan'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->potentiometerBegan(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "potentiometerBegan",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_potentiometerBegan'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_setMaximumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_setMaximumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMaximumValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaximumValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_setMaximumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_getMinimumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_getMinimumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMinimumValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMinimumValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_getMinimumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_setThumbSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_setThumbSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setThumbSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setThumbSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_setThumbSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_getValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_getValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_getValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_getPreviousLocation(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_getPreviousLocation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getPreviousLocation(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPreviousLocation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_getPreviousLocation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Point arg0; cocos2d::Point arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; double ret = cobj->distanceBetweenPointAndPoint(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "distanceBetweenPointAndPoint",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_potentiometerEnded(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_potentiometerEnded'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->potentiometerEnded(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "potentiometerEnded",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_potentiometerEnded'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_setProgressTimer(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_setProgressTimer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::ProgressTimer* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ProgressTimer",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setProgressTimer(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProgressTimer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_setProgressTimer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_setMinimumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_setMinimumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMinimumValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMinimumValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_setMinimumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_getThumbSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_getThumbSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getThumbSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getThumbSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_getThumbSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::Sprite* arg0; cocos2d::ProgressTimer* arg1; cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.ProgressTimer",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::ProgressTimer*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->initWithTrackSprite_ProgressTimer_ThumbSprite(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTrackSprite_ProgressTimer_ThumbSprite",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_potentiometerMoved(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlPotentiometer*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlPotentiometer_potentiometerMoved'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->potentiometerMoved(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "potentiometerMoved",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_potentiometerMoved'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ControlPotentiometer",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { const char* arg0; const char* arg1; const char* arg2; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); if(!ok) return 0; cocos2d::extension::ControlPotentiometer* ret = cocos2d::extension::ControlPotentiometer::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlPotentiometer"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlPotentiometer*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlPotentiometer_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlPotentiometer* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::ControlPotentiometer(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ControlPotentiometer"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ControlPotentiometer"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ControlPotentiometer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlPotentiometer_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ControlPotentiometer_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ControlPotentiometer)"); return 0; } int lua_register_cocos2dx_extension_ControlPotentiometer(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ControlPotentiometer"); tolua_cclass(tolua_S,"ControlPotentiometer","cc.ControlPotentiometer","cc.Control",NULL); tolua_beginmodule(tolua_S,"ControlPotentiometer"); tolua_function(tolua_S,"setPreviousLocation",lua_cocos2dx_extension_ControlPotentiometer_setPreviousLocation); tolua_function(tolua_S,"setValue",lua_cocos2dx_extension_ControlPotentiometer_setValue); tolua_function(tolua_S,"getProgressTimer",lua_cocos2dx_extension_ControlPotentiometer_getProgressTimer); tolua_function(tolua_S,"getMaximumValue",lua_cocos2dx_extension_ControlPotentiometer_getMaximumValue); tolua_function(tolua_S,"angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint",lua_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint); tolua_function(tolua_S,"potentiometerBegan",lua_cocos2dx_extension_ControlPotentiometer_potentiometerBegan); tolua_function(tolua_S,"setMaximumValue",lua_cocos2dx_extension_ControlPotentiometer_setMaximumValue); tolua_function(tolua_S,"getMinimumValue",lua_cocos2dx_extension_ControlPotentiometer_getMinimumValue); tolua_function(tolua_S,"setThumbSprite",lua_cocos2dx_extension_ControlPotentiometer_setThumbSprite); tolua_function(tolua_S,"getValue",lua_cocos2dx_extension_ControlPotentiometer_getValue); tolua_function(tolua_S,"getPreviousLocation",lua_cocos2dx_extension_ControlPotentiometer_getPreviousLocation); tolua_function(tolua_S,"distanceBetweenPointAndPoint",lua_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint); tolua_function(tolua_S,"potentiometerEnded",lua_cocos2dx_extension_ControlPotentiometer_potentiometerEnded); tolua_function(tolua_S,"setProgressTimer",lua_cocos2dx_extension_ControlPotentiometer_setProgressTimer); tolua_function(tolua_S,"setMinimumValue",lua_cocos2dx_extension_ControlPotentiometer_setMinimumValue); tolua_function(tolua_S,"getThumbSprite",lua_cocos2dx_extension_ControlPotentiometer_getThumbSprite); tolua_function(tolua_S,"initWithTrackSprite_ProgressTimer_ThumbSprite",lua_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite); tolua_function(tolua_S,"potentiometerMoved",lua_cocos2dx_extension_ControlPotentiometer_potentiometerMoved); tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlPotentiometer_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlPotentiometer_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlPotentiometer).name(); g_luaType[typeName] = "cc.ControlPotentiometer"; g_typeCast["ControlPotentiometer"] = "cc.ControlPotentiometer"; return 1; } int lua_cocos2dx_extension_ControlSlider_getSelectedThumbSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getSelectedThumbSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getSelectedThumbSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSelectedThumbSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getSelectedThumbSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_locationFromTouch(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_locationFromTouch'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Touch* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Point ret = cobj->locationFromTouch(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "locationFromTouch",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_locationFromTouch'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setSelectedThumbSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setSelectedThumbSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setSelectedThumbSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSelectedThumbSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setSelectedThumbSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setProgressSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setProgressSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setProgressSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProgressSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setProgressSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_getMaximumAllowedValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getMaximumAllowedValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMaximumAllowedValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaximumAllowedValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getMaximumAllowedValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_getMinimumAllowedValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getMinimumAllowedValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMinimumAllowedValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMinimumAllowedValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getMinimumAllowedValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_getMinimumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getMinimumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMinimumValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMinimumValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getMinimumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setThumbSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setThumbSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setThumbSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setThumbSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setThumbSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setMinimumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setMinimumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMinimumValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMinimumValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setMinimumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setMinimumAllowedValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setMinimumAllowedValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMinimumAllowedValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMinimumAllowedValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setMinimumAllowedValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setMaximumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setMaximumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMaximumValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaximumValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setMaximumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_needsLayout(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_needsLayout'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->needsLayout(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "needsLayout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_needsLayout'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_getBackgroundSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getBackgroundSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getBackgroundSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackgroundSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getBackgroundSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_initWithSprites(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_initWithSprites'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 4) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg3; do { if (!luaval_is_usertype(tolua_S,5,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg3 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,5,0); if (nullptr == arg3){ LUA_PRECONDITION( arg3, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool ret = cobj->initWithSprites(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 3) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool ret = cobj->initWithSprites(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithSprites",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_initWithSprites'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_getMaximumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getMaximumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMaximumValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaximumValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getMaximumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_isTouchInside(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_isTouchInside'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Touch* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->isTouchInside(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTouchInside",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_isTouchInside'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_getValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_getThumbSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getThumbSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getThumbSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getThumbSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getThumbSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_getProgressSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_getProgressSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getProgressSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProgressSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_getProgressSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setBackgroundSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setBackgroundSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBackgroundSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackgroundSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setBackgroundSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_setMaximumAllowedValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSlider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSlider_setMaximumAllowedValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMaximumAllowedValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaximumAllowedValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_setMaximumAllowedValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ControlSlider",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 3) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlSlider"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlSlider*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } const char* arg2; std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); if (!ok) { break; } cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlSlider"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlSlider*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 4) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } const char* arg2; std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); if (!ok) { break; } const char* arg3; std::string arg3_tmp; ok &= luaval_to_std_string(tolua_S, 5, &arg3_tmp); arg3 = arg3_tmp.c_str(); if (!ok) { break; } cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlSlider"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlSlider*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 4) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg3; do { if (!luaval_is_usertype(tolua_S,5,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg3 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,5,0); if (nullptr == arg3){ LUA_PRECONDITION( arg3, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlSlider"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlSlider*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSlider_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSlider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::ControlSlider(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ControlSlider"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ControlSlider"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ControlSlider",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSlider_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ControlSlider_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ControlSlider)"); return 0; } int lua_register_cocos2dx_extension_ControlSlider(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ControlSlider"); tolua_cclass(tolua_S,"ControlSlider","cc.ControlSlider","cc.Control",NULL); tolua_beginmodule(tolua_S,"ControlSlider"); tolua_function(tolua_S,"getSelectedThumbSprite",lua_cocos2dx_extension_ControlSlider_getSelectedThumbSprite); tolua_function(tolua_S,"locationFromTouch",lua_cocos2dx_extension_ControlSlider_locationFromTouch); tolua_function(tolua_S,"setSelectedThumbSprite",lua_cocos2dx_extension_ControlSlider_setSelectedThumbSprite); tolua_function(tolua_S,"setProgressSprite",lua_cocos2dx_extension_ControlSlider_setProgressSprite); tolua_function(tolua_S,"getMaximumAllowedValue",lua_cocos2dx_extension_ControlSlider_getMaximumAllowedValue); tolua_function(tolua_S,"getMinimumAllowedValue",lua_cocos2dx_extension_ControlSlider_getMinimumAllowedValue); tolua_function(tolua_S,"getMinimumValue",lua_cocos2dx_extension_ControlSlider_getMinimumValue); tolua_function(tolua_S,"setThumbSprite",lua_cocos2dx_extension_ControlSlider_setThumbSprite); tolua_function(tolua_S,"setMinimumValue",lua_cocos2dx_extension_ControlSlider_setMinimumValue); tolua_function(tolua_S,"setMinimumAllowedValue",lua_cocos2dx_extension_ControlSlider_setMinimumAllowedValue); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlSlider_setEnabled); tolua_function(tolua_S,"setValue",lua_cocos2dx_extension_ControlSlider_setValue); tolua_function(tolua_S,"setMaximumValue",lua_cocos2dx_extension_ControlSlider_setMaximumValue); tolua_function(tolua_S,"needsLayout",lua_cocos2dx_extension_ControlSlider_needsLayout); tolua_function(tolua_S,"getBackgroundSprite",lua_cocos2dx_extension_ControlSlider_getBackgroundSprite); tolua_function(tolua_S,"initWithSprites",lua_cocos2dx_extension_ControlSlider_initWithSprites); tolua_function(tolua_S,"getMaximumValue",lua_cocos2dx_extension_ControlSlider_getMaximumValue); tolua_function(tolua_S,"isTouchInside",lua_cocos2dx_extension_ControlSlider_isTouchInside); tolua_function(tolua_S,"getValue",lua_cocos2dx_extension_ControlSlider_getValue); tolua_function(tolua_S,"getThumbSprite",lua_cocos2dx_extension_ControlSlider_getThumbSprite); tolua_function(tolua_S,"getProgressSprite",lua_cocos2dx_extension_ControlSlider_getProgressSprite); tolua_function(tolua_S,"setBackgroundSprite",lua_cocos2dx_extension_ControlSlider_setBackgroundSprite); tolua_function(tolua_S,"setMaximumAllowedValue",lua_cocos2dx_extension_ControlSlider_setMaximumAllowedValue); tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSlider_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlSlider_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlSlider).name(); g_luaType[typeName] = "cc.ControlSlider"; g_typeCast["ControlSlider"] = "cc.ControlSlider"; return 1; } int lua_cocos2dx_extension_ControlStepper_setMinusSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setMinusSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setMinusSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMinusSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setMinusSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_getMinusLabel(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_getMinusLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::LabelTTF* ret = cobj->getMinusLabel(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelTTF"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelTTF*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMinusLabel",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_getMinusLabel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setWraps(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setWraps'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setWraps(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setWraps",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setWraps'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_isContinuous(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_isContinuous'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isContinuous(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isContinuous",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_isContinuous'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_getMinusSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_getMinusSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getMinusSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMinusSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_getMinusSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->updateLayoutUsingTouchLocation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateLayoutUsingTouchLocation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setValueWithSendingEvent(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setValueWithSendingEvent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setValueWithSendingEvent(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setValueWithSendingEvent",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setValueWithSendingEvent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_getPlusLabel(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_getPlusLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::LabelTTF* ret = cobj->getPlusLabel(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.LabelTTF"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::LabelTTF*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPlusLabel",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_getPlusLabel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_stopAutorepeat(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_stopAutorepeat'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stopAutorepeat(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopAutorepeat",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_stopAutorepeat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setMinimumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setMinimumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMinimumValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMinimumValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setMinimumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_getPlusSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_getPlusSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Sprite* ret = cobj->getPlusSprite(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Sprite"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Sprite*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPlusSprite",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_getPlusSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setPlusSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setPlusSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setPlusSprite(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPlusSprite",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setPlusSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setMinusLabel(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setMinusLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::LabelTTF* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.LabelTTF",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setMinusLabel(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMinusLabel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setMinusLabel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setStepValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setStepValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStepValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStepValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setStepValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setMaximumValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setMaximumValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMaximumValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaximumValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setMaximumValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_update(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_update'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->update(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "update",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_update'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_startAutorepeat(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_startAutorepeat'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->startAutorepeat(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "startAutorepeat",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_startAutorepeat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Sprite* arg0; cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->initWithMinusSpriteAndPlusSprite(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithMinusSpriteAndPlusSprite",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_getValue(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_getValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getValue(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_getValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_setPlusLabel(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlStepper*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlStepper_setPlusLabel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::LabelTTF* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.LabelTTF",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setPlusLabel(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPlusLabel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_setPlusLabel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ControlStepper",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::Sprite* arg0; cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::extension::ControlStepper* ret = cocos2d::extension::ControlStepper::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlStepper"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlStepper*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlStepper_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlStepper* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::ControlStepper(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ControlStepper"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ControlStepper"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ControlStepper",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlStepper_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ControlStepper_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ControlStepper)"); return 0; } int lua_register_cocos2dx_extension_ControlStepper(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ControlStepper"); tolua_cclass(tolua_S,"ControlStepper","cc.ControlStepper","cc.Control",NULL); tolua_beginmodule(tolua_S,"ControlStepper"); tolua_function(tolua_S,"setMinusSprite",lua_cocos2dx_extension_ControlStepper_setMinusSprite); tolua_function(tolua_S,"getMinusLabel",lua_cocos2dx_extension_ControlStepper_getMinusLabel); tolua_function(tolua_S,"setWraps",lua_cocos2dx_extension_ControlStepper_setWraps); tolua_function(tolua_S,"isContinuous",lua_cocos2dx_extension_ControlStepper_isContinuous); tolua_function(tolua_S,"getMinusSprite",lua_cocos2dx_extension_ControlStepper_getMinusSprite); tolua_function(tolua_S,"updateLayoutUsingTouchLocation",lua_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation); tolua_function(tolua_S,"setValueWithSendingEvent",lua_cocos2dx_extension_ControlStepper_setValueWithSendingEvent); tolua_function(tolua_S,"getPlusLabel",lua_cocos2dx_extension_ControlStepper_getPlusLabel); tolua_function(tolua_S,"stopAutorepeat",lua_cocos2dx_extension_ControlStepper_stopAutorepeat); tolua_function(tolua_S,"setMinimumValue",lua_cocos2dx_extension_ControlStepper_setMinimumValue); tolua_function(tolua_S,"getPlusSprite",lua_cocos2dx_extension_ControlStepper_getPlusSprite); tolua_function(tolua_S,"setPlusSprite",lua_cocos2dx_extension_ControlStepper_setPlusSprite); tolua_function(tolua_S,"setMinusLabel",lua_cocos2dx_extension_ControlStepper_setMinusLabel); tolua_function(tolua_S,"setValue",lua_cocos2dx_extension_ControlStepper_setValue); tolua_function(tolua_S,"setStepValue",lua_cocos2dx_extension_ControlStepper_setStepValue); tolua_function(tolua_S,"setMaximumValue",lua_cocos2dx_extension_ControlStepper_setMaximumValue); tolua_function(tolua_S,"update",lua_cocos2dx_extension_ControlStepper_update); tolua_function(tolua_S,"startAutorepeat",lua_cocos2dx_extension_ControlStepper_startAutorepeat); tolua_function(tolua_S,"initWithMinusSpriteAndPlusSprite",lua_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite); tolua_function(tolua_S,"getValue",lua_cocos2dx_extension_ControlStepper_getValue); tolua_function(tolua_S,"setPlusLabel",lua_cocos2dx_extension_ControlStepper_setPlusLabel); tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlStepper_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlStepper_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlStepper).name(); g_luaType[typeName] = "cc.ControlStepper"; g_typeCast["ControlStepper"] = "cc.ControlStepper"; return 1; } int lua_cocos2dx_extension_ControlSwitch_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSwitch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSwitch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSwitch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSwitch_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSwitch_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSwitch_setOn(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSwitch* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSwitch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSwitch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSwitch_setOn'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if (!ok) { break; } cobj->setOn(arg0); return 0; } }while(0); ok = true; do{ if (argc == 2) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } cobj->setOn(arg0, arg1); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOn",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSwitch_setOn'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSwitch_isOn(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSwitch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSwitch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSwitch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSwitch_isOn'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isOn(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isOn",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSwitch_isOn'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSwitch_initWithMaskSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSwitch* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSwitch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSwitch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSwitch_initWithMaskSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 6) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg3; do { if (!luaval_is_usertype(tolua_S,5,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg3 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,5,0); if (nullptr == arg3){ LUA_PRECONDITION( arg3, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::LabelTTF* arg4; do { if (!luaval_is_usertype(tolua_S,6,"cc.LabelTTF",0)){ ok = false; break; } if (ok){ arg4 = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,6,0); if (nullptr == arg4){ LUA_PRECONDITION( arg4, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::LabelTTF* arg5; do { if (!luaval_is_usertype(tolua_S,7,"cc.LabelTTF",0)){ ok = false; break; } if (ok){ arg5 = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,7,0); if (nullptr == arg5){ LUA_PRECONDITION( arg5, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool ret = cobj->initWithMaskSprite(arg0, arg1, arg2, arg3, arg4, arg5); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 4) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg3; do { if (!luaval_is_usertype(tolua_S,5,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg3 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,5,0); if (nullptr == arg3){ LUA_PRECONDITION( arg3, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool ret = cobj->initWithMaskSprite(arg0, arg1, arg2, arg3); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithMaskSprite",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSwitch_initWithMaskSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSwitch_hasMoved(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSwitch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSwitch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSwitch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSwitch_hasMoved'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->hasMoved(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hasMoved",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSwitch_hasMoved'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSwitch_locationFromTouch(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSwitch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ControlSwitch",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ControlSwitch*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ControlSwitch_locationFromTouch'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Touch* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Point ret = cobj->locationFromTouch(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "locationFromTouch",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSwitch_locationFromTouch'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSwitch_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ControlSwitch",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 4) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg3; do { if (!luaval_is_usertype(tolua_S,5,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg3 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,5,0); if (nullptr == arg3){ LUA_PRECONDITION( arg3, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::ControlSwitch* ret = cocos2d::extension::ControlSwitch::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlSwitch"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlSwitch*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 6) { cocos2d::Sprite* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Sprite* arg3; do { if (!luaval_is_usertype(tolua_S,5,"cc.Sprite",0)){ ok = false; break; } if (ok){ arg3 = (cocos2d::Sprite*)tolua_tousertype(tolua_S,5,0); if (nullptr == arg3){ LUA_PRECONDITION( arg3, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::LabelTTF* arg4; do { if (!luaval_is_usertype(tolua_S,6,"cc.LabelTTF",0)){ ok = false; break; } if (ok){ arg4 = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,6,0); if (nullptr == arg4){ LUA_PRECONDITION( arg4, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::LabelTTF* arg5; do { if (!luaval_is_usertype(tolua_S,7,"cc.LabelTTF",0)){ ok = false; break; } if (ok){ arg5 = (cocos2d::LabelTTF*)tolua_tousertype(tolua_S,7,0); if (nullptr == arg5){ LUA_PRECONDITION( arg5, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::ControlSwitch* ret = cocos2d::extension::ControlSwitch::create(arg0, arg1, arg2, arg3, arg4, arg5); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ControlSwitch"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ControlSwitch*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 6); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSwitch_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ControlSwitch_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ControlSwitch* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::ControlSwitch(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ControlSwitch"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ControlSwitch"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ControlSwitch",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ControlSwitch_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ControlSwitch_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ControlSwitch)"); return 0; } int lua_register_cocos2dx_extension_ControlSwitch(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ControlSwitch"); tolua_cclass(tolua_S,"ControlSwitch","cc.ControlSwitch","cc.Control",NULL); tolua_beginmodule(tolua_S,"ControlSwitch"); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlSwitch_setEnabled); tolua_function(tolua_S,"setOn",lua_cocos2dx_extension_ControlSwitch_setOn); tolua_function(tolua_S,"isOn",lua_cocos2dx_extension_ControlSwitch_isOn); tolua_function(tolua_S,"initWithMaskSprite",lua_cocos2dx_extension_ControlSwitch_initWithMaskSprite); tolua_function(tolua_S,"hasMoved",lua_cocos2dx_extension_ControlSwitch_hasMoved); tolua_function(tolua_S,"locationFromTouch",lua_cocos2dx_extension_ControlSwitch_locationFromTouch); tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSwitch_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlSwitch_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlSwitch).name(); g_luaType[typeName] = "cc.ControlSwitch"; g_typeCast["ControlSwitch"] = "cc.ControlSwitch"; return 1; } int lua_cocos2dx_extension_ScrollView_isClippingToBounds(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_isClippingToBounds'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isClippingToBounds(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isClippingToBounds",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_isClippingToBounds'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setContainer(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setContainer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setContainer(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setContainer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setContainer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_onTouchEnded(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_onTouchEnded'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Touch* arg0; cocos2d::Event* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Event",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Event*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->onTouchEnded(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onTouchEnded",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_onTouchEnded'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setContentOffsetInDuration(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setContentOffsetInDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Point arg0; double arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setContentOffsetInDuration(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setContentOffsetInDuration",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setContentOffsetInDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setZoomScaleInDuration(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setZoomScaleInDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; double arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setZoomScaleInDuration(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setZoomScaleInDuration",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setZoomScaleInDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setBounceable(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setBounceable'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBounceable(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBounceable",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setBounceable'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_getDirection(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_getDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getDirection(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDirection",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_getDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_getContainer(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_getContainer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getContainer(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContainer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_getContainer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_getZoomScale(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_getZoomScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getZoomScale(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getZoomScale",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_getZoomScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_updateInset(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_updateInset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateInset(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateInset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_updateInset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_initWithViewSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_initWithViewSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; bool ret = cobj->initWithViewSize(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } if (argc == 2) { cocos2d::Size arg0; cocos2d::Node* arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->initWithViewSize(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithViewSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_initWithViewSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_pause(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_pause'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Object* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Object",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Object*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->pause(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pause",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_pause'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setDirection(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::ScrollView::Direction arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setDirection(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDirection",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_init(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setContentOffset(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setContentOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setContentOffset(arg0); return 0; } if (argc == 2) { cocos2d::Point arg0; bool arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setContentOffset(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setContentOffset",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setContentOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_isDragging(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_isDragging'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isDragging(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isDragging",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_isDragging'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_isTouchEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_isTouchEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isTouchEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTouchEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_isTouchEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_isBounceable(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_isBounceable'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isBounceable(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isBounceable",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_isBounceable'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setTouchEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setTouchEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTouchEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTouchEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setTouchEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_onTouchMoved(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_onTouchMoved'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Touch* arg0; cocos2d::Event* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Event",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Event*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->onTouchMoved(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onTouchMoved",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_onTouchMoved'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_getContentOffset(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_getContentOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getContentOffset(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContentOffset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_getContentOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_resume(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_resume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Object* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Object",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Object*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->resume(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resume",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_resume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setClippingToBounds(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setClippingToBounds'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setClippingToBounds(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setClippingToBounds",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setClippingToBounds'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setViewSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setViewSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setViewSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setViewSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setViewSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_onTouchCancelled(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_onTouchCancelled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Touch* arg0; cocos2d::Event* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Event",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Event*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->onTouchCancelled(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onTouchCancelled",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_onTouchCancelled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_getViewSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_getViewSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getViewSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getViewSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_getViewSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_maxContainerOffset(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_maxContainerOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->maxContainerOffset(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "maxContainerOffset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_maxContainerOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_onTouchBegan(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_onTouchBegan'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Touch* arg0; cocos2d::Event* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Touch",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Touch*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Event",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Event*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->onTouchBegan(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onTouchBegan",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_onTouchBegan'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_isTouchMoved(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_isTouchMoved'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isTouchMoved(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTouchMoved",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_isTouchMoved'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_isNodeVisible(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_isNodeVisible'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->isNodeVisible(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isNodeVisible",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_isNodeVisible'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_minContainerOffset(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_minContainerOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->minContainerOffset(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "minContainerOffset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_minContainerOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_setZoomScale(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ScrollView_setZoomScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } cobj->setZoomScale(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cobj->setZoomScale(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setZoomScale",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_setZoomScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 0) { cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ScrollView"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ScrollView*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ScrollView"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ScrollView*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Node* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.ScrollView"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::ScrollView*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_ScrollView_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::ScrollView(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ScrollView"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.ScrollView"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ScrollView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ScrollView_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_ScrollView_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ScrollView)"); return 0; } int lua_register_cocos2dx_extension_ScrollView(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.ScrollView"); tolua_cclass(tolua_S,"ScrollView","cc.ScrollView","cc.Layer",NULL); tolua_beginmodule(tolua_S,"ScrollView"); tolua_function(tolua_S,"isClippingToBounds",lua_cocos2dx_extension_ScrollView_isClippingToBounds); tolua_function(tolua_S,"setContainer",lua_cocos2dx_extension_ScrollView_setContainer); tolua_function(tolua_S,"onTouchEnded",lua_cocos2dx_extension_ScrollView_onTouchEnded); tolua_function(tolua_S,"setContentOffsetInDuration",lua_cocos2dx_extension_ScrollView_setContentOffsetInDuration); tolua_function(tolua_S,"setZoomScaleInDuration",lua_cocos2dx_extension_ScrollView_setZoomScaleInDuration); tolua_function(tolua_S,"setBounceable",lua_cocos2dx_extension_ScrollView_setBounceable); tolua_function(tolua_S,"getDirection",lua_cocos2dx_extension_ScrollView_getDirection); tolua_function(tolua_S,"getContainer",lua_cocos2dx_extension_ScrollView_getContainer); tolua_function(tolua_S,"getZoomScale",lua_cocos2dx_extension_ScrollView_getZoomScale); tolua_function(tolua_S,"updateInset",lua_cocos2dx_extension_ScrollView_updateInset); tolua_function(tolua_S,"initWithViewSize",lua_cocos2dx_extension_ScrollView_initWithViewSize); tolua_function(tolua_S,"pause",lua_cocos2dx_extension_ScrollView_pause); tolua_function(tolua_S,"setDirection",lua_cocos2dx_extension_ScrollView_setDirection); tolua_function(tolua_S,"init",lua_cocos2dx_extension_ScrollView_init); tolua_function(tolua_S,"setContentOffset",lua_cocos2dx_extension_ScrollView_setContentOffset); tolua_function(tolua_S,"isDragging",lua_cocos2dx_extension_ScrollView_isDragging); tolua_function(tolua_S,"isTouchEnabled",lua_cocos2dx_extension_ScrollView_isTouchEnabled); tolua_function(tolua_S,"isBounceable",lua_cocos2dx_extension_ScrollView_isBounceable); tolua_function(tolua_S,"setTouchEnabled",lua_cocos2dx_extension_ScrollView_setTouchEnabled); tolua_function(tolua_S,"onTouchMoved",lua_cocos2dx_extension_ScrollView_onTouchMoved); tolua_function(tolua_S,"getContentOffset",lua_cocos2dx_extension_ScrollView_getContentOffset); tolua_function(tolua_S,"resume",lua_cocos2dx_extension_ScrollView_resume); tolua_function(tolua_S,"setClippingToBounds",lua_cocos2dx_extension_ScrollView_setClippingToBounds); tolua_function(tolua_S,"setViewSize",lua_cocos2dx_extension_ScrollView_setViewSize); tolua_function(tolua_S,"onTouchCancelled",lua_cocos2dx_extension_ScrollView_onTouchCancelled); tolua_function(tolua_S,"getViewSize",lua_cocos2dx_extension_ScrollView_getViewSize); tolua_function(tolua_S,"maxContainerOffset",lua_cocos2dx_extension_ScrollView_maxContainerOffset); tolua_function(tolua_S,"onTouchBegan",lua_cocos2dx_extension_ScrollView_onTouchBegan); tolua_function(tolua_S,"isTouchMoved",lua_cocos2dx_extension_ScrollView_isTouchMoved); tolua_function(tolua_S,"isNodeVisible",lua_cocos2dx_extension_ScrollView_isNodeVisible); tolua_function(tolua_S,"minContainerOffset",lua_cocos2dx_extension_ScrollView_minContainerOffset); tolua_function(tolua_S,"setZoomScale",lua_cocos2dx_extension_ScrollView_setZoomScale); tolua_function(tolua_S,"new",lua_cocos2dx_extension_ScrollView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ScrollView_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ScrollView).name(); g_luaType[typeName] = "cc.ScrollView"; g_typeCast["ScrollView"] = "cc.ScrollView"; return 1; } int lua_cocos2dx_extension_TableViewCell_reset(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableViewCell* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableViewCell",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableViewCell*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableViewCell_reset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->reset(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableViewCell_reset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableViewCell_getIdx(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableViewCell* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableViewCell",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableViewCell*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableViewCell_getIdx'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getIdx(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getIdx",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableViewCell_getIdx'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableViewCell_setIdx(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableViewCell* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableViewCell",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableViewCell*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableViewCell_setIdx'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setIdx(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setIdx",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableViewCell_setIdx'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableViewCell_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.TableViewCell",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::extension::TableViewCell* ret = cocos2d::extension::TableViewCell::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TableViewCell"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::TableViewCell*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableViewCell_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableViewCell_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableViewCell* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::TableViewCell(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TableViewCell"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TableViewCell"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TableViewCell",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableViewCell_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_TableViewCell_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TableViewCell)"); return 0; } int lua_register_cocos2dx_extension_TableViewCell(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TableViewCell"); tolua_cclass(tolua_S,"TableViewCell","cc.TableViewCell","cc.Node",NULL); tolua_beginmodule(tolua_S,"TableViewCell"); tolua_function(tolua_S,"reset",lua_cocos2dx_extension_TableViewCell_reset); tolua_function(tolua_S,"getIdx",lua_cocos2dx_extension_TableViewCell_getIdx); tolua_function(tolua_S,"setIdx",lua_cocos2dx_extension_TableViewCell_setIdx); tolua_function(tolua_S,"new",lua_cocos2dx_extension_TableViewCell_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_TableViewCell_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::TableViewCell).name(); g_luaType[typeName] = "cc.TableViewCell"; g_typeCast["TableViewCell"] = "cc.TableViewCell"; return 1; } int lua_cocos2dx_extension_TableView_updateCellAtIndex(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_updateCellAtIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->updateCellAtIndex(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateCellAtIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_updateCellAtIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_setVerticalFillOrder(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_setVerticalFillOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::TableView::VerticalFillOrder arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setVerticalFillOrder(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVerticalFillOrder",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_setVerticalFillOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_scrollViewDidZoom(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_scrollViewDidZoom'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::ScrollView* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ScrollView",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->scrollViewDidZoom(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollViewDidZoom",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_scrollViewDidZoom'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView__updateContentSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView__updateContentSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->_updateContentSize(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "_updateContentSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView__updateContentSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_getVerticalFillOrder(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_getVerticalFillOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getVerticalFillOrder(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVerticalFillOrder",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_getVerticalFillOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_removeCellAtIndex(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_removeCellAtIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->removeCellAtIndex(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeCellAtIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_removeCellAtIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_initWithViewSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_initWithViewSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; bool ret = cobj->initWithViewSize(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } if (argc == 2) { cocos2d::Size arg0; cocos2d::Node* arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->initWithViewSize(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithViewSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_initWithViewSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_scrollViewDidScroll(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_scrollViewDidScroll'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::ScrollView* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.ScrollView",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::extension::ScrollView*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->scrollViewDidScroll(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollViewDidScroll",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_scrollViewDidScroll'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_reloadData(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_reloadData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->reloadData(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reloadData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_reloadData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_insertCellAtIndex(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_insertCellAtIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->insertCellAtIndex(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "insertCellAtIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_insertCellAtIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_cellAtIndex(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_cellAtIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::extension::TableViewCell* ret = cobj->cellAtIndex(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TableViewCell"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::TableViewCell*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cellAtIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_cellAtIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_dequeueCell(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::TableView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_TableView_dequeueCell'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::extension::TableViewCell* ret = cobj->dequeueCell(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.TableViewCell"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::TableViewCell*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "dequeueCell",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_dequeueCell'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_TableView_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::TableView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::TableView(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.TableView"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.TableView"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TableView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_TableView_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_TableView_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TableView)"); return 0; } int lua_register_cocos2dx_extension_TableView(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.TableView"); tolua_cclass(tolua_S,"TableView","cc.TableView","cc.ScrollView",NULL); tolua_beginmodule(tolua_S,"TableView"); tolua_function(tolua_S,"updateCellAtIndex",lua_cocos2dx_extension_TableView_updateCellAtIndex); tolua_function(tolua_S,"setVerticalFillOrder",lua_cocos2dx_extension_TableView_setVerticalFillOrder); tolua_function(tolua_S,"scrollViewDidZoom",lua_cocos2dx_extension_TableView_scrollViewDidZoom); tolua_function(tolua_S,"_updateContentSize",lua_cocos2dx_extension_TableView__updateContentSize); tolua_function(tolua_S,"getVerticalFillOrder",lua_cocos2dx_extension_TableView_getVerticalFillOrder); tolua_function(tolua_S,"removeCellAtIndex",lua_cocos2dx_extension_TableView_removeCellAtIndex); tolua_function(tolua_S,"initWithViewSize",lua_cocos2dx_extension_TableView_initWithViewSize); tolua_function(tolua_S,"scrollViewDidScroll",lua_cocos2dx_extension_TableView_scrollViewDidScroll); tolua_function(tolua_S,"reloadData",lua_cocos2dx_extension_TableView_reloadData); tolua_function(tolua_S,"insertCellAtIndex",lua_cocos2dx_extension_TableView_insertCellAtIndex); tolua_function(tolua_S,"cellAtIndex",lua_cocos2dx_extension_TableView_cellAtIndex); tolua_function(tolua_S,"dequeueCell",lua_cocos2dx_extension_TableView_dequeueCell); tolua_function(tolua_S,"new",lua_cocos2dx_extension_TableView_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::TableView).name(); g_luaType[typeName] = "cc.TableView"; g_typeCast["TableView"] = "cc.TableView"; return 1; } int lua_cocos2dx_extension_EditBox_getText(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_getText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getText(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getText",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_getText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setPlaceholderFontName(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setPlaceholderFontName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPlaceholderFontName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_getPlaceHolder(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_getPlaceHolder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getPlaceHolder(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPlaceHolder",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_getPlaceHolder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setFontName(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setFontName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setFontName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setPlaceholderFontSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setPlaceholderFontSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPlaceholderFontSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setInputMode(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setInputMode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::EditBox::InputMode arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setInputMode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInputMode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setInputMode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setPlaceholderFontColor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPlaceholderFontColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPlaceholderFontColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setFontColor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setFontColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setFontColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setFontColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setPlaceholderFont(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFont'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; int arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setPlaceholderFont(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPlaceholderFont",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFont'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setFontSize(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setFontSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setFontSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Size arg0; cocos2d::extension::Scale9Sprite* arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->initWithSizeAndBackgroundSprite(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithSizeAndBackgroundSprite",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setPlaceHolder(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceHolder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setPlaceHolder(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPlaceHolder",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceHolder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setReturnType(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setReturnType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::EditBox::KeyboardReturnType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setReturnType(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setReturnType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setReturnType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setInputFlag(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setInputFlag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::EditBox::InputFlag arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setInputFlag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInputFlag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setInputFlag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_getMaxLength(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_getMaxLength'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getMaxLength(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaxLength",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_getMaxLength'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setText(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setText(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setText",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setMaxLength(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setMaxLength'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setMaxLength(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaxLength",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setMaxLength'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_setFont(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setFont'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; int arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setFont(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFont",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setFont'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::Size arg0; cocos2d::extension::Scale9Sprite* arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EditBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::EditBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Size arg0; cocos2d::extension::Scale9Sprite* arg1; cocos2d::extension::Scale9Sprite* arg2; ok &= luaval_to_size(tolua_S, 2, &arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,4,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EditBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::EditBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { cocos2d::Size arg0; cocos2d::extension::Scale9Sprite* arg1; cocos2d::extension::Scale9Sprite* arg2; cocos2d::extension::Scale9Sprite* arg3; ok &= luaval_to_size(tolua_S, 2, &arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,4,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,5,"cc.Scale9Sprite",0)){ ok = false; break; } if (ok){ arg3 = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,5,0); if (nullptr == arg3){ LUA_PRECONDITION( arg3, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EditBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::EditBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_EditBox_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::EditBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::EditBox(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EditBox"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.EditBox"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EditBox",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_EditBox_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EditBox)"); return 0; } int lua_register_cocos2dx_extension_EditBox(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EditBox"); tolua_cclass(tolua_S,"EditBox","cc.EditBox","cc.ControlButton",NULL); tolua_beginmodule(tolua_S,"EditBox"); tolua_function(tolua_S,"getText",lua_cocos2dx_extension_EditBox_getText); tolua_function(tolua_S,"setPlaceholderFontName",lua_cocos2dx_extension_EditBox_setPlaceholderFontName); tolua_function(tolua_S,"getPlaceHolder",lua_cocos2dx_extension_EditBox_getPlaceHolder); tolua_function(tolua_S,"setFontName",lua_cocos2dx_extension_EditBox_setFontName); tolua_function(tolua_S,"setPlaceholderFontSize",lua_cocos2dx_extension_EditBox_setPlaceholderFontSize); tolua_function(tolua_S,"setInputMode",lua_cocos2dx_extension_EditBox_setInputMode); tolua_function(tolua_S,"setPlaceholderFontColor",lua_cocos2dx_extension_EditBox_setPlaceholderFontColor); tolua_function(tolua_S,"setFontColor",lua_cocos2dx_extension_EditBox_setFontColor); tolua_function(tolua_S,"setPlaceholderFont",lua_cocos2dx_extension_EditBox_setPlaceholderFont); tolua_function(tolua_S,"setFontSize",lua_cocos2dx_extension_EditBox_setFontSize); tolua_function(tolua_S,"initWithSizeAndBackgroundSprite",lua_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite); tolua_function(tolua_S,"setPlaceHolder",lua_cocos2dx_extension_EditBox_setPlaceHolder); tolua_function(tolua_S,"setReturnType",lua_cocos2dx_extension_EditBox_setReturnType); tolua_function(tolua_S,"setInputFlag",lua_cocos2dx_extension_EditBox_setInputFlag); tolua_function(tolua_S,"getMaxLength",lua_cocos2dx_extension_EditBox_getMaxLength); tolua_function(tolua_S,"setText",lua_cocos2dx_extension_EditBox_setText); tolua_function(tolua_S,"setMaxLength",lua_cocos2dx_extension_EditBox_setMaxLength); tolua_function(tolua_S,"setFont",lua_cocos2dx_extension_EditBox_setFont); tolua_function(tolua_S,"new",lua_cocos2dx_extension_EditBox_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_EditBox_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::EditBox).name(); g_luaType[typeName] = "cc.EditBox"; g_typeCast["EditBox"] = "cc.EditBox"; return 1; } int lua_cocos2dx_extension_AssetsManager_setStoragePath(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_setStoragePath'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setStoragePath(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStoragePath",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_setStoragePath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_setPackageUrl(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_setPackageUrl'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setPackageUrl(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPackageUrl",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_setPackageUrl'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_checkUpdate(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_checkUpdate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->checkUpdate(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "checkUpdate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_checkUpdate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_getStoragePath(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_getStoragePath'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getStoragePath(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStoragePath",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_getStoragePath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_update(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_update'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->update(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "update",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_update'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_setConnectionTimeout(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_setConnectionTimeout'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setConnectionTimeout(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setConnectionTimeout",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_setConnectionTimeout'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_setVersionFileUrl(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_setVersionFileUrl'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setVersionFileUrl(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVersionFileUrl",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_setVersionFileUrl'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_getPackageUrl(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_getPackageUrl'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getPackageUrl(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPackageUrl",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_getPackageUrl'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_getConnectionTimeout(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_getConnectionTimeout'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; unsigned int ret = cobj->getConnectionTimeout(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getConnectionTimeout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_getConnectionTimeout'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_getVersion(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_getVersion'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getVersion(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVersion",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_getVersion'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_getVersionFileUrl(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_getVersionFileUrl'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getVersionFileUrl(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVersionFileUrl",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_getVersionFileUrl'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_deleteVersion(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::extension::AssetsManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_AssetsManager_deleteVersion'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->deleteVersion(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "deleteVersion",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_deleteVersion'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 6) { const char* arg0; const char* arg1; const char* arg2; std::function arg3; std::function arg4; std::function arg5; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); do { // Lambda binding for lua is not supported. assert(false); } while(0) ; do { // Lambda binding for lua is not supported. assert(false); } while(0) ; do { // Lambda binding for lua is not supported. assert(false); } while(0) ; if(!ok) return 0; cocos2d::extension::AssetsManager* ret = cocos2d::extension::AssetsManager::create(arg0, arg1, arg2, arg3, arg4, arg5); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.AssetsManager"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::extension::AssetsManager*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 6); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_AssetsManager_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::extension::AssetsManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::extension::AssetsManager(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.AssetsManager"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.AssetsManager"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj = new cocos2d::extension::AssetsManager(arg0); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.AssetsManager"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.AssetsManager"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if(!ok) return 0; cobj = new cocos2d::extension::AssetsManager(arg0, arg1); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.AssetsManager"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.AssetsManager"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } if (argc == 3) { const char* arg0; const char* arg1; const char* arg2; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); if(!ok) return 0; cobj = new cocos2d::extension::AssetsManager(arg0, arg1, arg2); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.AssetsManager"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.AssetsManager"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "AssetsManager",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_AssetsManager_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_AssetsManager_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (AssetsManager)"); return 0; } int lua_register_cocos2dx_extension_AssetsManager(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.AssetsManager"); tolua_cclass(tolua_S,"AssetsManager","cc.AssetsManager","cc.Node",NULL); tolua_beginmodule(tolua_S,"AssetsManager"); tolua_function(tolua_S,"setStoragePath",lua_cocos2dx_extension_AssetsManager_setStoragePath); tolua_function(tolua_S,"setPackageUrl",lua_cocos2dx_extension_AssetsManager_setPackageUrl); tolua_function(tolua_S,"checkUpdate",lua_cocos2dx_extension_AssetsManager_checkUpdate); tolua_function(tolua_S,"getStoragePath",lua_cocos2dx_extension_AssetsManager_getStoragePath); tolua_function(tolua_S,"update",lua_cocos2dx_extension_AssetsManager_update); tolua_function(tolua_S,"setConnectionTimeout",lua_cocos2dx_extension_AssetsManager_setConnectionTimeout); tolua_function(tolua_S,"setVersionFileUrl",lua_cocos2dx_extension_AssetsManager_setVersionFileUrl); tolua_function(tolua_S,"getPackageUrl",lua_cocos2dx_extension_AssetsManager_getPackageUrl); tolua_function(tolua_S,"getConnectionTimeout",lua_cocos2dx_extension_AssetsManager_getConnectionTimeout); tolua_function(tolua_S,"getVersion",lua_cocos2dx_extension_AssetsManager_getVersion); tolua_function(tolua_S,"getVersionFileUrl",lua_cocos2dx_extension_AssetsManager_getVersionFileUrl); tolua_function(tolua_S,"deleteVersion",lua_cocos2dx_extension_AssetsManager_deleteVersion); tolua_function(tolua_S,"new",lua_cocos2dx_extension_AssetsManager_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_AssetsManager_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::AssetsManager).name(); g_luaType[typeName] = "cc.AssetsManager"; g_typeCast["AssetsManager"] = "cc.AssetsManager"; return 1; } int lua_cocos2dx_extension_CCBAnimationManager_moveAnimationsFromNode(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_moveAnimationsFromNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::Node* arg0; cocos2d::Node* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->moveAnimationsFromNode(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "moveAnimationsFromNode",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_moveAnimationsFromNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_setAutoPlaySequenceId(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_setAutoPlaySequenceId'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setAutoPlaySequenceId(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAutoPlaySequenceId",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_setAutoPlaySequenceId'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNames(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueVector& ret = cobj->getDocumentCallbackNames(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDocumentCallbackNames",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_actionForSoundChannel(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_actionForSoundChannel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocosbuilder::CCBSequenceProperty* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.CCBSequenceProperty",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::CCBSequenceProperty*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Object* ret = cobj->actionForSoundChannel(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Object"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Object*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "actionForSoundChannel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_actionForSoundChannel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_setBaseValue(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_setBaseValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::Value arg0; cocos2d::Node* arg1; std::string arg2; ok &= luaval_to_ccvalue(tolua_S, 2, &arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setBaseValue(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBaseValue",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_setBaseValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getDocumentOutletNodes(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentOutletNodes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getDocumentOutletNodes(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDocumentOutletNodes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentOutletNodes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getLastCompletedSequenceName(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getLastCompletedSequenceName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getLastCompletedSequenceName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLastCompletedSequenceName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getLastCompletedSequenceName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_setRootNode(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_setRootNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setRootNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRootNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_setRootNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; double arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->runAnimationsForSequenceNamedTweenDuration(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "runAnimationsForSequenceNamedTweenDuration",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_addDocumentOutletName(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentOutletName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addDocumentOutletName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDocumentOutletName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentOutletName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getSequences(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getSequences'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getSequences(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSequences",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getSequences'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getRootContainerSize(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getRootContainerSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getRootContainerSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRootContainerSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getRootContainerSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_setDocumentControllerName(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_setDocumentControllerName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDocumentControllerName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDocumentControllerName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_setDocumentControllerName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_setObject(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_setObject'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::Object* arg0; cocos2d::Node* arg1; std::string arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.Object",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Object*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Node",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::Node*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setObject(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setObject",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_setObject'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getContainerSize(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getContainerSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; const cocos2d::Size& ret = cobj->getContainerSize(arg0); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContainerSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getContainerSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_actionForCallbackChannel(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_actionForCallbackChannel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocosbuilder::CCBSequenceProperty* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.CCBSequenceProperty",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::CCBSequenceProperty*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::Object* ret = cobj->actionForCallbackChannel(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Object"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Object*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "actionForCallbackChannel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_actionForCallbackChannel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getDocumentOutletNames(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentOutletNames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueVector& ret = cobj->getDocumentOutletNames(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDocumentOutletNames",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentOutletNames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackControlEvents(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackControlEvents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::EventType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->addDocumentCallbackControlEvents(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDocumentCallbackControlEvents",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackControlEvents'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_init(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getKeyframeCallbacks(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getKeyframeCallbacks'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueVector& ret = cobj->getKeyframeCallbacks(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getKeyframeCallbacks",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getKeyframeCallbacks'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackControlEvents(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackControlEvents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueVector& ret = cobj->getDocumentCallbackControlEvents(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDocumentCallbackControlEvents",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackControlEvents'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_setRootContainerSize(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_setRootContainerSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setRootContainerSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRootContainerSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_setRootContainerSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; double arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->runAnimationsForSequenceIdTweenDuration(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "runAnimationsForSequenceIdTweenDuration",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getRunningSequenceName(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getRunningSequenceName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getRunningSequenceName(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRunningSequenceName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getRunningSequenceName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getAutoPlaySequenceId(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getAutoPlaySequenceId'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getAutoPlaySequenceId(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAutoPlaySequenceId",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getAutoPlaySequenceId'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackName(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addDocumentCallbackName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDocumentCallbackName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getRootNode(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getRootNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getRootNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRootNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getRootNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_addDocumentOutletNode(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentOutletNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addDocumentOutletNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDocumentOutletNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentOutletNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getSequenceDuration(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getSequenceDuration'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; double ret = cobj->getSequenceDuration(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSequenceDuration",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getSequenceDuration'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackNode(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addDocumentCallbackNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDocumentCallbackNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceNamed(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceNamed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->runAnimationsForSequenceNamed(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "runAnimationsForSequenceNamed",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceNamed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getSequenceId(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getSequenceId'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; int ret = cobj->getSequenceId(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSequenceId",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getSequenceId'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNodes(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNodes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getDocumentCallbackNodes(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDocumentCallbackNodes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNodes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_setSequences(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_setSequences'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Vector arg0; ok &= luaval_to_ccvector(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setSequences(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSequences",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_setSequences'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_debug(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_debug'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->debug(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "debug",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_debug'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_getDocumentControllerName(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentControllerName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getDocumentControllerName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDocumentControllerName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_getDocumentControllerName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBAnimationManager_constructor(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBAnimationManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocosbuilder::CCBAnimationManager(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CCBAnimationManager"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CCBAnimationManager"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "CCBAnimationManager",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBAnimationManager_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_CCBAnimationManager_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (CCBAnimationManager)"); return 0; } int lua_register_cocos2dx_extension_CCBAnimationManager(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.CCBAnimationManager"); tolua_cclass(tolua_S,"CCBAnimationManager","cc.CCBAnimationManager","",NULL); tolua_beginmodule(tolua_S,"CCBAnimationManager"); tolua_function(tolua_S,"moveAnimationsFromNode",lua_cocos2dx_extension_CCBAnimationManager_moveAnimationsFromNode); tolua_function(tolua_S,"setAutoPlaySequenceId",lua_cocos2dx_extension_CCBAnimationManager_setAutoPlaySequenceId); tolua_function(tolua_S,"getDocumentCallbackNames",lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNames); tolua_function(tolua_S,"actionForSoundChannel",lua_cocos2dx_extension_CCBAnimationManager_actionForSoundChannel); tolua_function(tolua_S,"setBaseValue",lua_cocos2dx_extension_CCBAnimationManager_setBaseValue); tolua_function(tolua_S,"getDocumentOutletNodes",lua_cocos2dx_extension_CCBAnimationManager_getDocumentOutletNodes); tolua_function(tolua_S,"getLastCompletedSequenceName",lua_cocos2dx_extension_CCBAnimationManager_getLastCompletedSequenceName); tolua_function(tolua_S,"setRootNode",lua_cocos2dx_extension_CCBAnimationManager_setRootNode); tolua_function(tolua_S,"runAnimationsForSequenceNamedTweenDuration",lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration); tolua_function(tolua_S,"addDocumentOutletName",lua_cocos2dx_extension_CCBAnimationManager_addDocumentOutletName); tolua_function(tolua_S,"getSequences",lua_cocos2dx_extension_CCBAnimationManager_getSequences); tolua_function(tolua_S,"getRootContainerSize",lua_cocos2dx_extension_CCBAnimationManager_getRootContainerSize); tolua_function(tolua_S,"setDocumentControllerName",lua_cocos2dx_extension_CCBAnimationManager_setDocumentControllerName); tolua_function(tolua_S,"setObject",lua_cocos2dx_extension_CCBAnimationManager_setObject); tolua_function(tolua_S,"getContainerSize",lua_cocos2dx_extension_CCBAnimationManager_getContainerSize); tolua_function(tolua_S,"actionForCallbackChannel",lua_cocos2dx_extension_CCBAnimationManager_actionForCallbackChannel); tolua_function(tolua_S,"getDocumentOutletNames",lua_cocos2dx_extension_CCBAnimationManager_getDocumentOutletNames); tolua_function(tolua_S,"addDocumentCallbackControlEvents",lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackControlEvents); tolua_function(tolua_S,"init",lua_cocos2dx_extension_CCBAnimationManager_init); tolua_function(tolua_S,"getKeyframeCallbacks",lua_cocos2dx_extension_CCBAnimationManager_getKeyframeCallbacks); tolua_function(tolua_S,"getDocumentCallbackControlEvents",lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackControlEvents); tolua_function(tolua_S,"setRootContainerSize",lua_cocos2dx_extension_CCBAnimationManager_setRootContainerSize); tolua_function(tolua_S,"runAnimationsForSequenceIdTweenDuration",lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration); tolua_function(tolua_S,"getRunningSequenceName",lua_cocos2dx_extension_CCBAnimationManager_getRunningSequenceName); tolua_function(tolua_S,"getAutoPlaySequenceId",lua_cocos2dx_extension_CCBAnimationManager_getAutoPlaySequenceId); tolua_function(tolua_S,"addDocumentCallbackName",lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackName); tolua_function(tolua_S,"getRootNode",lua_cocos2dx_extension_CCBAnimationManager_getRootNode); tolua_function(tolua_S,"addDocumentOutletNode",lua_cocos2dx_extension_CCBAnimationManager_addDocumentOutletNode); tolua_function(tolua_S,"getSequenceDuration",lua_cocos2dx_extension_CCBAnimationManager_getSequenceDuration); tolua_function(tolua_S,"addDocumentCallbackNode",lua_cocos2dx_extension_CCBAnimationManager_addDocumentCallbackNode); tolua_function(tolua_S,"runAnimationsForSequenceNamed",lua_cocos2dx_extension_CCBAnimationManager_runAnimationsForSequenceNamed); tolua_function(tolua_S,"getSequenceId",lua_cocos2dx_extension_CCBAnimationManager_getSequenceId); tolua_function(tolua_S,"getDocumentCallbackNodes",lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNodes); tolua_function(tolua_S,"setSequences",lua_cocos2dx_extension_CCBAnimationManager_setSequences); tolua_function(tolua_S,"debug",lua_cocos2dx_extension_CCBAnimationManager_debug); tolua_function(tolua_S,"getDocumentControllerName",lua_cocos2dx_extension_CCBAnimationManager_getDocumentControllerName); tolua_function(tolua_S,"new",lua_cocos2dx_extension_CCBAnimationManager_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocosbuilder::CCBAnimationManager).name(); g_luaType[typeName] = "cc.CCBAnimationManager"; g_typeCast["CCBAnimationManager"] = "cc.CCBAnimationManager"; return 1; } int lua_cocos2dx_extension_CCBReader_addOwnerOutletName(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_addOwnerOutletName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addOwnerOutletName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addOwnerOutletName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_addOwnerOutletName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getOwnerCallbackNames(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getOwnerCallbackNames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueVector ret = cobj->getOwnerCallbackNames(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOwnerCallbackNames",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getOwnerCallbackNames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_addDocumentCallbackControlEvents(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_addDocumentCallbackControlEvents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::EventType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->addDocumentCallbackControlEvents(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDocumentCallbackControlEvents",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_addDocumentCallbackControlEvents'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_setCCBRootPath(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_setCCBRootPath'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setCCBRootPath(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCCBRootPath",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_setCCBRootPath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_addOwnerOutletNode(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_addOwnerOutletNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addOwnerOutletNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addOwnerOutletNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_addOwnerOutletNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getOwnerCallbackNodes(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getOwnerCallbackNodes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getOwnerCallbackNodes(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOwnerCallbackNodes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getOwnerCallbackNodes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_readSoundKeyframesForSeq(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_readSoundKeyframesForSeq'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocosbuilder::CCBSequence* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.CCBSequence",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::CCBSequence*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->readSoundKeyframesForSeq(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "readSoundKeyframesForSeq",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_readSoundKeyframesForSeq'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getCCBRootPath(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getCCBRootPath'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getCCBRootPath(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCCBRootPath",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getCCBRootPath'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getOwnerCallbackControlEvents(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getOwnerCallbackControlEvents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueVector& ret = cobj->getOwnerCallbackControlEvents(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOwnerCallbackControlEvents",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getOwnerCallbackControlEvents'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getOwnerOutletNodes(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getOwnerOutletNodes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getOwnerOutletNodes(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOwnerOutletNodes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getOwnerOutletNodes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_readUTF8(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_readUTF8'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->readUTF8(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "readUTF8",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_readUTF8'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_addOwnerCallbackControlEvents(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_addOwnerCallbackControlEvents'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::extension::Control::EventType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->addOwnerCallbackControlEvents(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addOwnerCallbackControlEvents",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_addOwnerCallbackControlEvents'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getOwnerOutletNames(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getOwnerOutletNames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::ValueVector ret = cobj->getOwnerOutletNames(); ccvaluevector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOwnerOutletNames",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getOwnerOutletNames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_setAnimationManager(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_setAnimationManager'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocosbuilder::CCBAnimationManager* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.CCBAnimationManager",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::CCBAnimationManager*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setAnimationManager(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimationManager",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_setAnimationManager'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_readCallbackKeyframesForSeq(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_readCallbackKeyframesForSeq'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocosbuilder::CCBSequence* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.CCBSequence",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::CCBSequence*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->readCallbackKeyframesForSeq(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "readCallbackKeyframesForSeq",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_readCallbackKeyframesForSeq'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getAnimationManagersForNodes(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getAnimationManagersForNodes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getAnimationManagersForNodes(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimationManagersForNodes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getAnimationManagersForNodes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getNodesWithAnimationManagers(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getNodesWithAnimationManagers'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getNodesWithAnimationManagers(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodesWithAnimationManagers",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getNodesWithAnimationManagers'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_getAnimationManager(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_CCBReader_getAnimationManager'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocosbuilder::CCBAnimationManager* ret = cobj->getAnimationManager(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.CCBAnimationManager"; } cocos2d::Object *dynObject = dynamic_cast((cocosbuilder::CCBAnimationManager*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimationManager",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_getAnimationManager'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_setResolutionScale(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cocosbuilder::CCBReader::setResolutionScale(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "setResolutionScale",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_setResolutionScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_extension_CCBReader_constructor(lua_State* tolua_S) { int argc = 0; cocosbuilder::CCBReader* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { cocosbuilder::CCBReader* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.CCBReader",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::CCBReader*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj = new cocosbuilder::CCBReader(arg0); cocos2d::Object* dynObject = dynamic_cast(cobj); if (NULL != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CCBReader"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CCBReader"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } }while(0); ok = true; do{ if (argc == 1) { cocosbuilder::NodeLoaderLibrary* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.NodeLoaderLibrary",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::NodeLoaderLibrary*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj = new cocosbuilder::CCBReader(arg0); cocos2d::Object* dynObject = dynamic_cast(cobj); if (NULL != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CCBReader"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CCBReader"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } }while(0); ok = true; do{ if (argc == 2) { cocosbuilder::NodeLoaderLibrary* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.NodeLoaderLibrary",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::NodeLoaderLibrary*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocosbuilder::CCBMemberVariableAssigner* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.CCBMemberVariableAssigner",0)){ ok = false; break; } if (ok){ arg1 = (cocosbuilder::CCBMemberVariableAssigner*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj = new cocosbuilder::CCBReader(arg0, arg1); cocos2d::Object* dynObject = dynamic_cast(cobj); if (NULL != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CCBReader"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CCBReader"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } }while(0); ok = true; do{ if (argc == 3) { cocosbuilder::NodeLoaderLibrary* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.NodeLoaderLibrary",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::NodeLoaderLibrary*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocosbuilder::CCBMemberVariableAssigner* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.CCBMemberVariableAssigner",0)){ ok = false; break; } if (ok){ arg1 = (cocosbuilder::CCBMemberVariableAssigner*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocosbuilder::CCBSelectorResolver* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.CCBSelectorResolver",0)){ ok = false; break; } if (ok){ arg2 = (cocosbuilder::CCBSelectorResolver*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj = new cocosbuilder::CCBReader(arg0, arg1, arg2); cocos2d::Object* dynObject = dynamic_cast(cobj); if (NULL != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CCBReader"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CCBReader"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } }while(0); ok = true; do{ if (argc == 4) { cocosbuilder::NodeLoaderLibrary* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.NodeLoaderLibrary",0)){ ok = false; break; } if (ok){ arg0 = (cocosbuilder::NodeLoaderLibrary*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocosbuilder::CCBMemberVariableAssigner* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.CCBMemberVariableAssigner",0)){ ok = false; break; } if (ok){ arg1 = (cocosbuilder::CCBMemberVariableAssigner*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocosbuilder::CCBSelectorResolver* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.CCBSelectorResolver",0)){ ok = false; break; } if (ok){ arg2 = (cocosbuilder::CCBSelectorResolver*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocosbuilder::NodeLoaderListener* arg3; do { if (!luaval_is_usertype(tolua_S,5,"cc.NodeLoaderListener",0)){ ok = false; break; } if (ok){ arg3 = (cocosbuilder::NodeLoaderListener*)tolua_tousertype(tolua_S,5,0); if (nullptr == arg3){ LUA_PRECONDITION( arg3, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj = new cocosbuilder::CCBReader(arg0, arg1, arg2, arg3); cocos2d::Object* dynObject = dynamic_cast(cobj); if (NULL != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CCBReader"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CCBReader"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } }while(0); ok = true; do{ if (argc == 0) { cobj = new cocosbuilder::CCBReader(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (NULL != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.CCBReader"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"cc.CCBReader"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "CCBReader",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_CCBReader_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_extension_CCBReader_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (CCBReader)"); return 0; } int lua_register_cocos2dx_extension_CCBReader(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.CCBReader"); tolua_cclass(tolua_S,"CCBReader","cc.CCBReader","",NULL); tolua_beginmodule(tolua_S,"CCBReader"); tolua_function(tolua_S,"addOwnerOutletName",lua_cocos2dx_extension_CCBReader_addOwnerOutletName); tolua_function(tolua_S,"getOwnerCallbackNames",lua_cocos2dx_extension_CCBReader_getOwnerCallbackNames); tolua_function(tolua_S,"addDocumentCallbackControlEvents",lua_cocos2dx_extension_CCBReader_addDocumentCallbackControlEvents); tolua_function(tolua_S,"setCCBRootPath",lua_cocos2dx_extension_CCBReader_setCCBRootPath); tolua_function(tolua_S,"addOwnerOutletNode",lua_cocos2dx_extension_CCBReader_addOwnerOutletNode); tolua_function(tolua_S,"getOwnerCallbackNodes",lua_cocos2dx_extension_CCBReader_getOwnerCallbackNodes); tolua_function(tolua_S,"readSoundKeyframesForSeq",lua_cocos2dx_extension_CCBReader_readSoundKeyframesForSeq); tolua_function(tolua_S,"getCCBRootPath",lua_cocos2dx_extension_CCBReader_getCCBRootPath); tolua_function(tolua_S,"getOwnerCallbackControlEvents",lua_cocos2dx_extension_CCBReader_getOwnerCallbackControlEvents); tolua_function(tolua_S,"getOwnerOutletNodes",lua_cocos2dx_extension_CCBReader_getOwnerOutletNodes); tolua_function(tolua_S,"readUTF8",lua_cocos2dx_extension_CCBReader_readUTF8); tolua_function(tolua_S,"addOwnerCallbackControlEvents",lua_cocos2dx_extension_CCBReader_addOwnerCallbackControlEvents); tolua_function(tolua_S,"getOwnerOutletNames",lua_cocos2dx_extension_CCBReader_getOwnerOutletNames); tolua_function(tolua_S,"setActionManager",lua_cocos2dx_extension_CCBReader_setAnimationManager); tolua_function(tolua_S,"readCallbackKeyframesForSeq",lua_cocos2dx_extension_CCBReader_readCallbackKeyframesForSeq); tolua_function(tolua_S,"getAnimationManagersForNodes",lua_cocos2dx_extension_CCBReader_getAnimationManagersForNodes); tolua_function(tolua_S,"getNodesWithAnimationManagers",lua_cocos2dx_extension_CCBReader_getNodesWithAnimationManagers); tolua_function(tolua_S,"getActionManager",lua_cocos2dx_extension_CCBReader_getAnimationManager); tolua_function(tolua_S,"new",lua_cocos2dx_extension_CCBReader_constructor); tolua_function(tolua_S,"setResolutionScale", lua_cocos2dx_extension_CCBReader_setResolutionScale); tolua_endmodule(tolua_S); std::string typeName = typeid(cocosbuilder::CCBReader).name(); g_luaType[typeName] = "cc.CCBReader"; g_typeCast["CCBReader"] = "cc.CCBReader"; return 1; } TOLUA_API int register_all_cocos2dx_extension(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,"cc",0); tolua_beginmodule(tolua_S,"cc"); lua_register_cocos2dx_extension_Control(tolua_S); lua_register_cocos2dx_extension_TableViewCell(tolua_S); lua_register_cocos2dx_extension_Scale9Sprite(tolua_S); lua_register_cocos2dx_extension_ControlSwitch(tolua_S); lua_register_cocos2dx_extension_ScrollView(tolua_S); lua_register_cocos2dx_extension_TableView(tolua_S); lua_register_cocos2dx_extension_AssetsManager(tolua_S); lua_register_cocos2dx_extension_ControlButton(tolua_S); lua_register_cocos2dx_extension_EditBox(tolua_S); lua_register_cocos2dx_extension_ControlSlider(tolua_S); lua_register_cocos2dx_extension_ControlStepper(tolua_S); lua_register_cocos2dx_extension_CCBReader(tolua_S); lua_register_cocos2dx_extension_ControlSaturationBrightnessPicker(tolua_S); lua_register_cocos2dx_extension_ControlColourPicker(tolua_S); lua_register_cocos2dx_extension_ControlPotentiometer(tolua_S); lua_register_cocos2dx_extension_CCBAnimationManager(tolua_S); lua_register_cocos2dx_extension_ControlHuePicker(tolua_S); tolua_endmodule(tolua_S); return 1; } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_extension_auto.hpp ================================================ #ifndef __cocos2dx_extension_h__ #define __cocos2dx_extension_h__ #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif int register_all_cocos2dx_extension(lua_State* tolua_S); #endif // __cocos2dx_extension_h__ ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_extension_auto_api.js ================================================ /** * @module cocos2dx_extension */ var cc = cc || {}; /** * @class Scale9Sprite */ cc.Scale9Sprite = { /** * @method resizableSpriteWithCapInsets * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" * @param {const cocos2d::Rect&} */ resizableSpriteWithCapInsets : function () {}, /** * @method setInsetBottom * @param {float} */ setInsetBottom : function () {}, /** * @method setInsetTop * @param {float} */ setInsetTop : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setPreferredSize * @param {cocos2d::Size} */ setPreferredSize : function () {}, /** * @method setSpriteFrame * @param {cocos2d::SpriteFrame*} */ setSpriteFrame : function () {}, /** * @method getInsetBottom * @return A value converted from C/C++ "float" */ getInsetBottom : function () {}, /** * @method getCapInsets * @return A value converted from C/C++ "cocos2d::Rect" */ getCapInsets : function () {}, /** * @method updateWithBatchNode * @return A value converted from C/C++ "bool" * @param {cocos2d::SpriteBatchNode*} * @param {const cocos2d::Rect&} * @param {bool} * @param {const cocos2d::Rect&} */ updateWithBatchNode : function () {}, /** * @method getInsetRight * @return A value converted from C/C++ "float" */ getInsetRight : function () {}, /** * @method getOriginalSize * @return A value converted from C/C++ "cocos2d::Size" */ getOriginalSize : function () {}, /** * @method getInsetTop * @return A value converted from C/C++ "float" */ getInsetTop : function () {}, /** * @method setInsetLeft * @param {float} */ setInsetLeft : function () {}, /** * @method getPreferredSize * @return A value converted from C/C++ "cocos2d::Size" */ getPreferredSize : function () {}, /** * @method setCapInsets * @param {cocos2d::Rect} */ setCapInsets : function () {}, /** * @method getInsetLeft * @return A value converted from C/C++ "float" */ getInsetLeft : function () {}, /** * @method setInsetRight * @param {float} */ setInsetRight : function () {}, /** * @method Scale9Sprite * @constructor */ Scale9Sprite : function () {}, }; /** * @class Control */ cc.Control = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method onTouchMoved * @param {cocos2d::Touch*} * @param {cocos2d::Event*} */ onTouchMoved : function () {}, /** * @method getState * @return A value converted from C/C++ "cocos2d::extension::Control::State" */ getState : function () {}, /** * @method onTouchEnded * @param {cocos2d::Touch*} * @param {cocos2d::Event*} */ onTouchEnded : function () {}, /** * @method sendActionsForControlEvents * @param {cocos2d::extension::Control::EventType} */ sendActionsForControlEvents : function () {}, /** * @method setSelected * @param {bool} */ setSelected : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method onTouchCancelled * @param {cocos2d::Touch*} * @param {cocos2d::Event*} */ onTouchCancelled : function () {}, /** * @method needsLayout */ needsLayout : function () {}, /** * @method onTouchBegan * @return A value converted from C/C++ "bool" * @param {cocos2d::Touch*} * @param {cocos2d::Event*} */ onTouchBegan : function () {}, /** * @method hasVisibleParents * @return A value converted from C/C++ "bool" */ hasVisibleParents : function () {}, /** * @method isSelected * @return A value converted from C/C++ "bool" */ isSelected : function () {}, /** * @method isTouchInside * @return A value converted from C/C++ "bool" * @param {cocos2d::Touch*} */ isTouchInside : function () {}, /** * @method setHighlighted * @param {bool} */ setHighlighted : function () {}, /** * @method getTouchLocation * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ getTouchLocation : function () {}, /** * @method isHighlighted * @return A value converted from C/C++ "bool" */ isHighlighted : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::Control*" */ create : function () {}, }; /** * @class ControlButton */ cc.ControlButton = { /** * @method isPushed * @return A value converted from C/C++ "bool" */ isPushed : function () {}, /** * @method setSelected * @param {bool} */ setSelected : function () {}, /** * @method setTitleLabelForState * @param {cocos2d::Node*} * @param {cocos2d::extension::Control::State} */ setTitleLabelForState : function () {}, /** * @method setAdjustBackgroundImage * @param {bool} */ setAdjustBackgroundImage : function () {}, /** * @method setHighlighted * @param {bool} */ setHighlighted : function () {}, /** * @method setZoomOnTouchDown * @param {bool} */ setZoomOnTouchDown : function () {}, /** * @method setTitleForState * @param {const std::string&} * @param {cocos2d::extension::Control::State} */ setTitleForState : function () {}, /** * @method setLabelAnchorPoint * @param {const cocos2d::Point&} */ setLabelAnchorPoint : function () {}, /** * @method getLabelAnchorPoint * @return A value converted from C/C++ "const cocos2d::Point&" */ getLabelAnchorPoint : function () {}, /** * @method getTitleTTFSizeForState * @return A value converted from C/C++ "float" * @param {cocos2d::extension::Control::State} */ getTitleTTFSizeForState : function () {}, /** * @method setTitleTTFForState * @param {const std::string&} * @param {cocos2d::extension::Control::State} */ setTitleTTFForState : function () {}, /** * @method setTitleTTFSizeForState * @param {float} * @param {cocos2d::extension::Control::State} */ setTitleTTFSizeForState : function () {}, /** * @method setTitleLabel * @param {cocos2d::Node*} */ setTitleLabel : function () {}, /** * @method setPreferredSize * @param {const cocos2d::Size&} */ setPreferredSize : function () {}, /** * @method getCurrentTitleColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getCurrentTitleColor : function () {}, /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method getBackgroundSpriteForState * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" * @param {cocos2d::extension::Control::State} */ getBackgroundSpriteForState : function () {}, /** * @method getHorizontalOrigin * @return A value converted from C/C++ "int" */ getHorizontalOrigin : function () {}, /** * @method needsLayout */ needsLayout : function () {}, /** * @method getScaleRatio * @return A value converted from C/C++ "float" */ getScaleRatio : function () {}, /** * @method getTitleTTFForState * @return A value converted from C/C++ "const std::string&" * @param {cocos2d::extension::Control::State} */ getTitleTTFForState : function () {}, /** * @method getBackgroundSprite * @return A value converted from C/C++ "cocos2d::extension::Scale9Sprite*" */ getBackgroundSprite : function () {}, /** * @method getTitleColorForState * @return A value converted from C/C++ "cocos2d::Color3B" * @param {cocos2d::extension::Control::State} */ getTitleColorForState : function () {}, /** * @method setTitleColorForState * @param {const cocos2d::Color3B&} * @param {cocos2d::extension::Control::State} */ setTitleColorForState : function () {}, /** * @method doesAdjustBackgroundImage * @return A value converted from C/C++ "bool" */ doesAdjustBackgroundImage : function () {}, /** * @method setBackgroundSpriteFrameForState * @param {cocos2d::SpriteFrame*} * @param {cocos2d::extension::Control::State} */ setBackgroundSpriteFrameForState : function () {}, /** * @method setBackgroundSpriteForState * @param {cocos2d::extension::Scale9Sprite*} * @param {cocos2d::extension::Control::State} */ setBackgroundSpriteForState : function () {}, /** * @method setScaleRatio * @param {float} */ setScaleRatio : function () {}, /** * @method setBackgroundSprite * @param {cocos2d::extension::Scale9Sprite*} */ setBackgroundSprite : function () {}, /** * @method getTitleLabel * @return A value converted from C/C++ "cocos2d::Node*" */ getTitleLabel : function () {}, /** * @method getPreferredSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getPreferredSize : function () {}, /** * @method getVerticalMargin * @return A value converted from C/C++ "int" */ getVerticalMargin : function () {}, /** * @method getTitleLabelForState * @return A value converted from C/C++ "cocos2d::Node*" * @param {cocos2d::extension::Control::State} */ getTitleLabelForState : function () {}, /** * @method setMargins * @param {int} * @param {int} */ setMargins : function () {}, /** * @method setTitleBMFontForState * @param {const std::string&} * @param {cocos2d::extension::Control::State} */ setTitleBMFontForState : function () {}, /** * @method getTitleBMFontForState * @return A value converted from C/C++ "const std::string&" * @param {cocos2d::extension::Control::State} */ getTitleBMFontForState : function () {}, /** * @method getZoomOnTouchDown * @return A value converted from C/C++ "bool" */ getZoomOnTouchDown : function () {}, /** * @method getTitleForState * @return A value converted from C/C++ "std::string" * @param {cocos2d::extension::Control::State} */ getTitleForState : function () {}, }; /** * @class ControlHuePicker */ cc.ControlHuePicker = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method initWithTargetAndPos * @return A value converted from C/C++ "bool" * @param {cocos2d::Node*} * @param {cocos2d::Point} */ initWithTargetAndPos : function () {}, /** * @method setHue * @param {float} */ setHue : function () {}, /** * @method getStartPos * @return A value converted from C/C++ "cocos2d::Point" */ getStartPos : function () {}, /** * @method getHue * @return A value converted from C/C++ "float" */ getHue : function () {}, /** * @method getSlider * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSlider : function () {}, /** * @method setBackground * @param {cocos2d::Sprite*} */ setBackground : function () {}, /** * @method setHuePercentage * @param {float} */ setHuePercentage : function () {}, /** * @method getBackground * @return A value converted from C/C++ "cocos2d::Sprite*" */ getBackground : function () {}, /** * @method getHuePercentage * @return A value converted from C/C++ "float" */ getHuePercentage : function () {}, /** * @method setSlider * @param {cocos2d::Sprite*} */ setSlider : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" * @param {cocos2d::Node*} * @param {cocos2d::Point} */ create : function () {}, /** * @method ControlHuePicker * @constructor */ ControlHuePicker : function () {}, }; /** * @class ControlSaturationBrightnessPicker */ cc.ControlSaturationBrightnessPicker = { /** * @method getShadow * @return A value converted from C/C++ "cocos2d::Sprite*" */ getShadow : function () {}, /** * @method initWithTargetAndPos * @return A value converted from C/C++ "bool" * @param {cocos2d::Node*} * @param {cocos2d::Point} */ initWithTargetAndPos : function () {}, /** * @method getStartPos * @return A value converted from C/C++ "cocos2d::Point" */ getStartPos : function () {}, /** * @method getOverlay * @return A value converted from C/C++ "cocos2d::Sprite*" */ getOverlay : function () {}, /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method getSlider * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSlider : function () {}, /** * @method getBackground * @return A value converted from C/C++ "cocos2d::Sprite*" */ getBackground : function () {}, /** * @method getSaturation * @return A value converted from C/C++ "float" */ getSaturation : function () {}, /** * @method getBrightness * @return A value converted from C/C++ "float" */ getBrightness : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" * @param {cocos2d::Node*} * @param {cocos2d::Point} */ create : function () {}, /** * @method ControlSaturationBrightnessPicker * @constructor */ ControlSaturationBrightnessPicker : function () {}, }; /** * @class ControlColourPicker */ cc.ControlColourPicker = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method getHuePicker * @return A value converted from C/C++ "cocos2d::extension::ControlHuePicker*" */ getHuePicker : function () {}, /** * @method setColor * @param {const cocos2d::Color3B&} */ setColor : function () {}, /** * @method hueSliderValueChanged * @param {cocos2d::Object*} * @param {cocos2d::extension::Control::EventType} */ hueSliderValueChanged : function () {}, /** * @method getcolourPicker * @return A value converted from C/C++ "cocos2d::extension::ControlSaturationBrightnessPicker*" */ getcolourPicker : function () {}, /** * @method setBackground * @param {cocos2d::Sprite*} */ setBackground : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setcolourPicker * @param {cocos2d::extension::ControlSaturationBrightnessPicker*} */ setcolourPicker : function () {}, /** * @method colourSliderValueChanged * @param {cocos2d::Object*} * @param {cocos2d::extension::Control::EventType} */ colourSliderValueChanged : function () {}, /** * @method setHuePicker * @param {cocos2d::extension::ControlHuePicker*} */ setHuePicker : function () {}, /** * @method getBackground * @return A value converted from C/C++ "cocos2d::Sprite*" */ getBackground : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlColourPicker*" */ create : function () {}, /** * @method ControlColourPicker * @constructor */ ControlColourPicker : function () {}, }; /** * @class ControlPotentiometer */ cc.ControlPotentiometer = { /** * @method setPreviousLocation * @param {cocos2d::Point} */ setPreviousLocation : function () {}, /** * @method setValue * @param {float} */ setValue : function () {}, /** * @method getProgressTimer * @return A value converted from C/C++ "cocos2d::ProgressTimer*" */ getProgressTimer : function () {}, /** * @method getMaximumValue * @return A value converted from C/C++ "float" */ getMaximumValue : function () {}, /** * @method angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint * @return A value converted from C/C++ "float" * @param {cocos2d::Point} * @param {cocos2d::Point} * @param {cocos2d::Point} * @param {cocos2d::Point} */ angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : function () {}, /** * @method potentiometerBegan * @param {cocos2d::Point} */ potentiometerBegan : function () {}, /** * @method setMaximumValue * @param {float} */ setMaximumValue : function () {}, /** * @method getMinimumValue * @return A value converted from C/C++ "float" */ getMinimumValue : function () {}, /** * @method setThumbSprite * @param {cocos2d::Sprite*} */ setThumbSprite : function () {}, /** * @method getValue * @return A value converted from C/C++ "float" */ getValue : function () {}, /** * @method getPreviousLocation * @return A value converted from C/C++ "cocos2d::Point" */ getPreviousLocation : function () {}, /** * @method distanceBetweenPointAndPoint * @return A value converted from C/C++ "float" * @param {cocos2d::Point} * @param {cocos2d::Point} */ distanceBetweenPointAndPoint : function () {}, /** * @method potentiometerEnded * @param {cocos2d::Point} */ potentiometerEnded : function () {}, /** * @method setProgressTimer * @param {cocos2d::ProgressTimer*} */ setProgressTimer : function () {}, /** * @method setMinimumValue * @param {float} */ setMinimumValue : function () {}, /** * @method getThumbSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getThumbSprite : function () {}, /** * @method initWithTrackSprite_ProgressTimer_ThumbSprite * @return A value converted from C/C++ "bool" * @param {cocos2d::Sprite*} * @param {cocos2d::ProgressTimer*} * @param {cocos2d::Sprite*} */ initWithTrackSprite_ProgressTimer_ThumbSprite : function () {}, /** * @method potentiometerMoved * @param {cocos2d::Point} */ potentiometerMoved : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlPotentiometer*" * @param {const char*} * @param {const char*} * @param {const char*} */ create : function () {}, /** * @method ControlPotentiometer * @constructor */ ControlPotentiometer : function () {}, }; /** * @class ControlSlider */ cc.ControlSlider = { /** * @method getSelectedThumbSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getSelectedThumbSprite : function () {}, /** * @method locationFromTouch * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ locationFromTouch : function () {}, /** * @method setSelectedThumbSprite * @param {cocos2d::Sprite*} */ setSelectedThumbSprite : function () {}, /** * @method setProgressSprite * @param {cocos2d::Sprite*} */ setProgressSprite : function () {}, /** * @method getMaximumAllowedValue * @return A value converted from C/C++ "float" */ getMaximumAllowedValue : function () {}, /** * @method getMinimumAllowedValue * @return A value converted from C/C++ "float" */ getMinimumAllowedValue : function () {}, /** * @method getMinimumValue * @return A value converted from C/C++ "float" */ getMinimumValue : function () {}, /** * @method setThumbSprite * @param {cocos2d::Sprite*} */ setThumbSprite : function () {}, /** * @method setMinimumValue * @param {float} */ setMinimumValue : function () {}, /** * @method setMinimumAllowedValue * @param {float} */ setMinimumAllowedValue : function () {}, /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method setValue * @param {float} */ setValue : function () {}, /** * @method setMaximumValue * @param {float} */ setMaximumValue : function () {}, /** * @method needsLayout */ needsLayout : function () {}, /** * @method getBackgroundSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getBackgroundSprite : function () {}, /** * @method getMaximumValue * @return A value converted from C/C++ "float" */ getMaximumValue : function () {}, /** * @method isTouchInside * @return A value converted from C/C++ "bool" * @param {cocos2d::Touch*} */ isTouchInside : function () {}, /** * @method getValue * @return A value converted from C/C++ "float" */ getValue : function () {}, /** * @method getThumbSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getThumbSprite : function () {}, /** * @method getProgressSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getProgressSprite : function () {}, /** * @method setBackgroundSprite * @param {cocos2d::Sprite*} */ setBackgroundSprite : function () {}, /** * @method setMaximumAllowedValue * @param {float} */ setMaximumAllowedValue : function () {}, /** * @method ControlSlider * @constructor */ ControlSlider : function () {}, }; /** * @class ControlStepper */ cc.ControlStepper = { /** * @method setMinusSprite * @param {cocos2d::Sprite*} */ setMinusSprite : function () {}, /** * @method getMinusLabel * @return A value converted from C/C++ "cocos2d::LabelTTF*" */ getMinusLabel : function () {}, /** * @method setWraps * @param {bool} */ setWraps : function () {}, /** * @method isContinuous * @return A value converted from C/C++ "bool" */ isContinuous : function () {}, /** * @method getMinusSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getMinusSprite : function () {}, /** * @method updateLayoutUsingTouchLocation * @param {cocos2d::Point} */ updateLayoutUsingTouchLocation : function () {}, /** * @method setValueWithSendingEvent * @param {double} * @param {bool} */ setValueWithSendingEvent : function () {}, /** * @method getPlusLabel * @return A value converted from C/C++ "cocos2d::LabelTTF*" */ getPlusLabel : function () {}, /** * @method stopAutorepeat */ stopAutorepeat : function () {}, /** * @method setMinimumValue * @param {double} */ setMinimumValue : function () {}, /** * @method getPlusSprite * @return A value converted from C/C++ "cocos2d::Sprite*" */ getPlusSprite : function () {}, /** * @method setPlusSprite * @param {cocos2d::Sprite*} */ setPlusSprite : function () {}, /** * @method setMinusLabel * @param {cocos2d::LabelTTF*} */ setMinusLabel : function () {}, /** * @method setValue * @param {double} */ setValue : function () {}, /** * @method setStepValue * @param {double} */ setStepValue : function () {}, /** * @method setMaximumValue * @param {double} */ setMaximumValue : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method startAutorepeat */ startAutorepeat : function () {}, /** * @method initWithMinusSpriteAndPlusSprite * @return A value converted from C/C++ "bool" * @param {cocos2d::Sprite*} * @param {cocos2d::Sprite*} */ initWithMinusSpriteAndPlusSprite : function () {}, /** * @method getValue * @return A value converted from C/C++ "double" */ getValue : function () {}, /** * @method setPlusLabel * @param {cocos2d::LabelTTF*} */ setPlusLabel : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::ControlStepper*" * @param {cocos2d::Sprite*} * @param {cocos2d::Sprite*} */ create : function () {}, /** * @method ControlStepper * @constructor */ ControlStepper : function () {}, }; /** * @class ControlSwitch */ cc.ControlSwitch = { /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method isOn * @return A value converted from C/C++ "bool" */ isOn : function () {}, /** * @method hasMoved * @return A value converted from C/C++ "bool" */ hasMoved : function () {}, /** * @method locationFromTouch * @return A value converted from C/C++ "cocos2d::Point" * @param {cocos2d::Touch*} */ locationFromTouch : function () {}, /** * @method ControlSwitch * @constructor */ ControlSwitch : function () {}, }; /** * @class ScrollView */ cc.ScrollView = { /** * @method isClippingToBounds * @return A value converted from C/C++ "bool" */ isClippingToBounds : function () {}, /** * @method setContainer * @param {cocos2d::Node*} */ setContainer : function () {}, /** * @method onTouchEnded * @param {cocos2d::Touch*} * @param {cocos2d::Event*} */ onTouchEnded : function () {}, /** * @method setContentOffsetInDuration * @param {cocos2d::Point} * @param {float} */ setContentOffsetInDuration : function () {}, /** * @method setZoomScaleInDuration * @param {float} * @param {float} */ setZoomScaleInDuration : function () {}, /** * @method setBounceable * @param {bool} */ setBounceable : function () {}, /** * @method getDirection * @return A value converted from C/C++ "cocos2d::extension::ScrollView::Direction" */ getDirection : function () {}, /** * @method getContainer * @return A value converted from C/C++ "cocos2d::Node*" */ getContainer : function () {}, /** * @method getZoomScale * @return A value converted from C/C++ "float" */ getZoomScale : function () {}, /** * @method updateInset */ updateInset : function () {}, /** * @method initWithViewSize * @return A value converted from C/C++ "bool" * @param {cocos2d::Size} * @param {cocos2d::Node*} */ initWithViewSize : function () {}, /** * @method pause * @param {cocos2d::Object*} */ pause : function () {}, /** * @method setDirection * @param {cocos2d::extension::ScrollView::Direction} */ setDirection : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method setContentOffset * @param {cocos2d::Point} * @param {bool} */ setContentOffset : function () {}, /** * @method isDragging * @return A value converted from C/C++ "bool" */ isDragging : function () {}, /** * @method isTouchEnabled * @return A value converted from C/C++ "bool" */ isTouchEnabled : function () {}, /** * @method isBounceable * @return A value converted from C/C++ "bool" */ isBounceable : function () {}, /** * @method setTouchEnabled * @param {bool} */ setTouchEnabled : function () {}, /** * @method onTouchMoved * @param {cocos2d::Touch*} * @param {cocos2d::Event*} */ onTouchMoved : function () {}, /** * @method getContentOffset * @return A value converted from C/C++ "cocos2d::Point" */ getContentOffset : function () {}, /** * @method resume * @param {cocos2d::Object*} */ resume : function () {}, /** * @method setClippingToBounds * @param {bool} */ setClippingToBounds : function () {}, /** * @method setViewSize * @param {cocos2d::Size} */ setViewSize : function () {}, /** * @method onTouchCancelled * @param {cocos2d::Touch*} * @param {cocos2d::Event*} */ onTouchCancelled : function () {}, /** * @method getViewSize * @return A value converted from C/C++ "cocos2d::Size" */ getViewSize : function () {}, /** * @method maxContainerOffset * @return A value converted from C/C++ "cocos2d::Point" */ maxContainerOffset : function () {}, /** * @method onTouchBegan * @return A value converted from C/C++ "bool" * @param {cocos2d::Touch*} * @param {cocos2d::Event*} */ onTouchBegan : function () {}, /** * @method isTouchMoved * @return A value converted from C/C++ "bool" */ isTouchMoved : function () {}, /** * @method isNodeVisible * @return A value converted from C/C++ "bool" * @param {cocos2d::Node*} */ isNodeVisible : function () {}, /** * @method minContainerOffset * @return A value converted from C/C++ "cocos2d::Point" */ minContainerOffset : function () {}, /** * @method ScrollView * @constructor */ ScrollView : function () {}, }; /** * @class TableViewCell */ cc.TableViewCell = { /** * @method reset */ reset : function () {}, /** * @method getIdx * @return A value converted from C/C++ "ssize_t" */ getIdx : function () {}, /** * @method setIdx * @param {ssize_t} */ setIdx : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" */ create : function () {}, /** * @method TableViewCell * @constructor */ TableViewCell : function () {}, }; /** * @class TableView */ cc.TableView = { /** * @method updateCellAtIndex * @param {ssize_t} */ updateCellAtIndex : function () {}, /** * @method setVerticalFillOrder * @param {cocos2d::extension::TableView::VerticalFillOrder} */ setVerticalFillOrder : function () {}, /** * @method scrollViewDidZoom * @param {cocos2d::extension::ScrollView*} */ scrollViewDidZoom : function () {}, /** * @method _updateContentSize */ _updateContentSize : function () {}, /** * @method getVerticalFillOrder * @return A value converted from C/C++ "cocos2d::extension::TableView::VerticalFillOrder" */ getVerticalFillOrder : function () {}, /** * @method removeCellAtIndex * @param {ssize_t} */ removeCellAtIndex : function () {}, /** * @method initWithViewSize * @return A value converted from C/C++ "bool" * @param {cocos2d::Size} * @param {cocos2d::Node*} */ initWithViewSize : function () {}, /** * @method scrollViewDidScroll * @param {cocos2d::extension::ScrollView*} */ scrollViewDidScroll : function () {}, /** * @method reloadData */ reloadData : function () {}, /** * @method insertCellAtIndex * @param {ssize_t} */ insertCellAtIndex : function () {}, /** * @method cellAtIndex * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" * @param {ssize_t} */ cellAtIndex : function () {}, /** * @method dequeueCell * @return A value converted from C/C++ "cocos2d::extension::TableViewCell*" */ dequeueCell : function () {}, /** * @method TableView * @constructor */ TableView : function () {}, }; /** * @class EditBox */ cc.EditBox = { /** * @method getText * @return A value converted from C/C++ "const char*" */ getText : function () {}, /** * @method setPlaceholderFontName * @param {const char*} */ setPlaceholderFontName : function () {}, /** * @method getPlaceHolder * @return A value converted from C/C++ "const char*" */ getPlaceHolder : function () {}, /** * @method setFontName * @param {const char*} */ setFontName : function () {}, /** * @method setPlaceholderFontSize * @param {int} */ setPlaceholderFontSize : function () {}, /** * @method setInputMode * @param {cocos2d::extension::EditBox::InputMode} */ setInputMode : function () {}, /** * @method setPlaceholderFontColor * @param {const cocos2d::Color3B&} */ setPlaceholderFontColor : function () {}, /** * @method setFontColor * @param {const cocos2d::Color3B&} */ setFontColor : function () {}, /** * @method setPlaceholderFont * @param {const char*} * @param {int} */ setPlaceholderFont : function () {}, /** * @method setFontSize * @param {int} */ setFontSize : function () {}, /** * @method initWithSizeAndBackgroundSprite * @return A value converted from C/C++ "bool" * @param {const cocos2d::Size&} * @param {cocos2d::extension::Scale9Sprite*} */ initWithSizeAndBackgroundSprite : function () {}, /** * @method setPlaceHolder * @param {const char*} */ setPlaceHolder : function () {}, /** * @method setReturnType * @param {cocos2d::extension::EditBox::KeyboardReturnType} */ setReturnType : function () {}, /** * @method setInputFlag * @param {cocos2d::extension::EditBox::InputFlag} */ setInputFlag : function () {}, /** * @method getMaxLength * @return A value converted from C/C++ "int" */ getMaxLength : function () {}, /** * @method setText * @param {const char*} */ setText : function () {}, /** * @method setMaxLength * @param {int} */ setMaxLength : function () {}, /** * @method setFont * @param {const char*} * @param {int} */ setFont : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::EditBox*" * @param {const cocos2d::Size&} * @param {cocos2d::extension::Scale9Sprite*} * @param {cocos2d::extension::Scale9Sprite*} * @param {cocos2d::extension::Scale9Sprite*} */ create : function () {}, /** * @method EditBox * @constructor */ EditBox : function () {}, }; /** * @class AssetsManager */ cc.AssetsManager = { /** * @method setStoragePath * @param {const char*} */ setStoragePath : function () {}, /** * @method setPackageUrl * @param {const char*} */ setPackageUrl : function () {}, /** * @method checkUpdate * @return A value converted from C/C++ "bool" */ checkUpdate : function () {}, /** * @method getStoragePath * @return A value converted from C/C++ "const char*" */ getStoragePath : function () {}, /** * @method update */ update : function () {}, /** * @method setConnectionTimeout * @param {unsigned int} */ setConnectionTimeout : function () {}, /** * @method setVersionFileUrl * @param {const char*} */ setVersionFileUrl : function () {}, /** * @method getPackageUrl * @return A value converted from C/C++ "const char*" */ getPackageUrl : function () {}, /** * @method getConnectionTimeout * @return A value converted from C/C++ "unsigned int" */ getConnectionTimeout : function () {}, /** * @method getVersion * @return A value converted from C/C++ "std::string" */ getVersion : function () {}, /** * @method getVersionFileUrl * @return A value converted from C/C++ "const char*" */ getVersionFileUrl : function () {}, /** * @method deleteVersion */ deleteVersion : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::extension::AssetsManager*" * @param {const char*} * @param {const char*} * @param {const char*} * @param {cocos2d::extension::AssetsManager::ErrorCallback} * @param {cocos2d::extension::AssetsManager::ProgressCallback} * @param {cocos2d::extension::AssetsManager::SuccessCallback} */ create : function () {}, /** * @method AssetsManager * @constructor */ AssetsManager : function () {}, }; /** * @class CCBAnimationManager */ cc.AnimationManager = { /** * @method moveAnimationsFromNode * @param {cocos2d::Node*} * @param {cocos2d::Node*} */ moveAnimationsFromNode : function () {}, /** * @method setAutoPlaySequenceId * @param {int} */ setAutoPlaySequenceId : function () {}, /** * @method getDocumentCallbackNames * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getDocumentCallbackNames : function () {}, /** * @method actionForSoundChannel * @return A value converted from C/C++ "cocos2d::Object*" * @param {cocosbuilder::CCBSequenceProperty*} */ actionForSoundChannel : function () {}, /** * @method setBaseValue * @param {const cocos2d::Value&} * @param {cocos2d::Node*} * @param {const std::string&} */ setBaseValue : function () {}, /** * @method getDocumentOutletNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getDocumentOutletNodes : function () {}, /** * @method getLastCompletedSequenceName * @return A value converted from C/C++ "std::string" */ getLastCompletedSequenceName : function () {}, /** * @method setRootNode * @param {cocos2d::Node*} */ setRootNode : function () {}, /** * @method runAnimationsForSequenceNamedTweenDuration * @param {const char*} * @param {float} */ runAnimationsForSequenceNamedTweenDuration : function () {}, /** * @method addDocumentOutletName * @param {std::string} */ addDocumentOutletName : function () {}, /** * @method getSequences * @return A value converted from C/C++ "cocos2d::Vector&" */ getSequences : function () {}, /** * @method getRootContainerSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getRootContainerSize : function () {}, /** * @method setDocumentControllerName * @param {const std::string&} */ setDocumentControllerName : function () {}, /** * @method setObject * @param {cocos2d::Object*} * @param {cocos2d::Node*} * @param {const std::string&} */ setObject : function () {}, /** * @method getContainerSize * @return A value converted from C/C++ "const cocos2d::Size&" * @param {cocos2d::Node*} */ getContainerSize : function () {}, /** * @method actionForCallbackChannel * @return A value converted from C/C++ "cocos2d::Object*" * @param {cocosbuilder::CCBSequenceProperty*} */ actionForCallbackChannel : function () {}, /** * @method getDocumentOutletNames * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getDocumentOutletNames : function () {}, /** * @method addDocumentCallbackControlEvents * @param {cocos2d::extension::Control::EventType} */ addDocumentCallbackControlEvents : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method getKeyframeCallbacks * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getKeyframeCallbacks : function () {}, /** * @method getDocumentCallbackControlEvents * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getDocumentCallbackControlEvents : function () {}, /** * @method setRootContainerSize * @param {const cocos2d::Size&} */ setRootContainerSize : function () {}, /** * @method runAnimationsForSequenceIdTweenDuration * @param {int} * @param {float} */ runAnimationsForSequenceIdTweenDuration : function () {}, /** * @method getRunningSequenceName * @return A value converted from C/C++ "const char*" */ getRunningSequenceName : function () {}, /** * @method getAutoPlaySequenceId * @return A value converted from C/C++ "int" */ getAutoPlaySequenceId : function () {}, /** * @method addDocumentCallbackName * @param {std::string} */ addDocumentCallbackName : function () {}, /** * @method getRootNode * @return A value converted from C/C++ "cocos2d::Node*" */ getRootNode : function () {}, /** * @method addDocumentOutletNode * @param {cocos2d::Node*} */ addDocumentOutletNode : function () {}, /** * @method getSequenceDuration * @return A value converted from C/C++ "float" * @param {const char*} */ getSequenceDuration : function () {}, /** * @method addDocumentCallbackNode * @param {cocos2d::Node*} */ addDocumentCallbackNode : function () {}, /** * @method runAnimationsForSequenceNamed * @param {const char*} */ runAnimationsForSequenceNamed : function () {}, /** * @method getSequenceId * @return A value converted from C/C++ "int" * @param {const char*} */ getSequenceId : function () {}, /** * @method getDocumentCallbackNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getDocumentCallbackNodes : function () {}, /** * @method setSequences * @param {const cocos2d::Vector&} */ setSequences : function () {}, /** * @method debug */ debug : function () {}, /** * @method getDocumentControllerName * @return A value converted from C/C++ "std::string" */ getDocumentControllerName : function () {}, /** * @method CCBAnimationManager * @constructor */ CCBAnimationManager : function () {}, }; /** * @class CCBReader */ cc._Reader = { /** * @method addOwnerOutletName * @param {std::string} */ addOwnerOutletName : function () {}, /** * @method getOwnerCallbackNames * @return A value converted from C/C++ "cocos2d::ValueVector" */ getOwnerCallbackNames : function () {}, /** * @method addDocumentCallbackControlEvents * @param {cocos2d::extension::Control::EventType} */ addDocumentCallbackControlEvents : function () {}, /** * @method setCCBRootPath * @param {const char*} */ setCCBRootPath : function () {}, /** * @method addOwnerOutletNode * @param {cocos2d::Node*} */ addOwnerOutletNode : function () {}, /** * @method getOwnerCallbackNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getOwnerCallbackNodes : function () {}, /** * @method readSoundKeyframesForSeq * @return A value converted from C/C++ "bool" * @param {cocosbuilder::CCBSequence*} */ readSoundKeyframesForSeq : function () {}, /** * @method getCCBRootPath * @return A value converted from C/C++ "const std::string&" */ getCCBRootPath : function () {}, /** * @method getOwnerCallbackControlEvents * @return A value converted from C/C++ "cocos2d::ValueVector&" */ getOwnerCallbackControlEvents : function () {}, /** * @method getOwnerOutletNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getOwnerOutletNodes : function () {}, /** * @method readUTF8 * @return A value converted from C/C++ "std::string" */ readUTF8 : function () {}, /** * @method addOwnerCallbackControlEvents * @param {cocos2d::extension::Control::EventType} */ addOwnerCallbackControlEvents : function () {}, /** * @method getOwnerOutletNames * @return A value converted from C/C++ "cocos2d::ValueVector" */ getOwnerOutletNames : function () {}, /** * @method setAnimationManager * @param {cocosbuilder::CCBAnimationManager*} */ setAnimationManager : function () {}, /** * @method readCallbackKeyframesForSeq * @return A value converted from C/C++ "bool" * @param {cocosbuilder::CCBSequence*} */ readCallbackKeyframesForSeq : function () {}, /** * @method getAnimationManagersForNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getAnimationManagersForNodes : function () {}, /** * @method getNodesWithAnimationManagers * @return A value converted from C/C++ "cocos2d::Vector&" */ getNodesWithAnimationManagers : function () {}, /** * @method getAnimationManager * @return A value converted from C/C++ "cocosbuilder::CCBAnimationManager*" */ getAnimationManager : function () {}, /** * @method setResolutionScale * @param {float} */ setResolutionScale : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_gui_auto.cpp ================================================ #include "lua_cocos2dx_gui_auto.hpp" #include "CocosGUI.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" int lua_cocos2dx_gui_LayoutParameter_getLayoutType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LayoutParameter_getLayoutType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getLayoutType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayoutType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LayoutParameter_getLayoutType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LayoutParameter_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::LayoutParameter* ret = cocos2d::gui::LayoutParameter::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.LayoutParameter"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::LayoutParameter*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LayoutParameter_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LayoutParameter_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::LayoutParameter(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.LayoutParameter"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.LayoutParameter"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "LayoutParameter",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LayoutParameter_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_LayoutParameter_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LayoutParameter)"); return 0; } int lua_register_cocos2dx_gui_LayoutParameter(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.LayoutParameter"); tolua_cclass(tolua_S,"LayoutParameter","ccui.LayoutParameter","",NULL); tolua_beginmodule(tolua_S,"LayoutParameter"); tolua_function(tolua_S,"getLayoutType",lua_cocos2dx_gui_LayoutParameter_getLayoutType); tolua_function(tolua_S,"new",lua_cocos2dx_gui_LayoutParameter_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_LayoutParameter_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::LayoutParameter).name(); g_luaType[typeName] = "ccui.LayoutParameter"; g_typeCast["LayoutParameter"] = "ccui.LayoutParameter"; return 1; } int lua_cocos2dx_gui_LinearLayoutParameter_setGravity(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LinearLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LinearLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LinearLayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LinearLayoutParameter_setGravity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::LinearGravity arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setGravity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGravity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LinearLayoutParameter_setGravity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LinearLayoutParameter_getGravity(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LinearLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LinearLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LinearLayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LinearLayoutParameter_getGravity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getGravity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGravity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LinearLayoutParameter_getGravity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LinearLayoutParameter_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.LinearLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::LinearLayoutParameter* ret = cocos2d::gui::LinearLayoutParameter::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.LinearLayoutParameter"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::LinearLayoutParameter*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LinearLayoutParameter_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LinearLayoutParameter_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LinearLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::LinearLayoutParameter(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.LinearLayoutParameter"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.LinearLayoutParameter"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "LinearLayoutParameter",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LinearLayoutParameter_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_LinearLayoutParameter_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LinearLayoutParameter)"); return 0; } int lua_register_cocos2dx_gui_LinearLayoutParameter(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.LinearLayoutParameter"); tolua_cclass(tolua_S,"LinearLayoutParameter","ccui.LinearLayoutParameter","ccui.LayoutParameter",NULL); tolua_beginmodule(tolua_S,"LinearLayoutParameter"); tolua_function(tolua_S,"setGravity",lua_cocos2dx_gui_LinearLayoutParameter_setGravity); tolua_function(tolua_S,"getGravity",lua_cocos2dx_gui_LinearLayoutParameter_getGravity); tolua_function(tolua_S,"new",lua_cocos2dx_gui_LinearLayoutParameter_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_LinearLayoutParameter_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::LinearLayoutParameter).name(); g_luaType[typeName] = "ccui.LinearLayoutParameter"; g_typeCast["LinearLayoutParameter"] = "ccui.LinearLayoutParameter"; return 1; } int lua_cocos2dx_gui_RelativeLayoutParameter_setAlign(lua_State* tolua_S) { int argc = 0; cocos2d::gui::RelativeLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.RelativeLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::RelativeLayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_RelativeLayoutParameter_setAlign'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::RelativeAlign arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setAlign(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAlign",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_RelativeLayoutParameter_setAlign'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::RelativeLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.RelativeLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::RelativeLayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setRelativeToWidgetName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRelativeToWidgetName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_RelativeLayoutParameter_getRelativeName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::RelativeLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.RelativeLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::RelativeLayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_RelativeLayoutParameter_getRelativeName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getRelativeName(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRelativeName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_RelativeLayoutParameter_getRelativeName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::RelativeLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.RelativeLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::RelativeLayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getRelativeToWidgetName(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRelativeToWidgetName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_RelativeLayoutParameter_setRelativeName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::RelativeLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.RelativeLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::RelativeLayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_RelativeLayoutParameter_setRelativeName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setRelativeName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRelativeName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_RelativeLayoutParameter_setRelativeName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_RelativeLayoutParameter_getAlign(lua_State* tolua_S) { int argc = 0; cocos2d::gui::RelativeLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.RelativeLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::RelativeLayoutParameter*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_RelativeLayoutParameter_getAlign'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getAlign(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAlign",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_RelativeLayoutParameter_getAlign'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_RelativeLayoutParameter_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.RelativeLayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::RelativeLayoutParameter* ret = cocos2d::gui::RelativeLayoutParameter::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.RelativeLayoutParameter"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::RelativeLayoutParameter*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_RelativeLayoutParameter_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_RelativeLayoutParameter_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::RelativeLayoutParameter* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::RelativeLayoutParameter(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.RelativeLayoutParameter"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.RelativeLayoutParameter"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "RelativeLayoutParameter",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_RelativeLayoutParameter_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_RelativeLayoutParameter_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (RelativeLayoutParameter)"); return 0; } int lua_register_cocos2dx_gui_RelativeLayoutParameter(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.RelativeLayoutParameter"); tolua_cclass(tolua_S,"RelativeLayoutParameter","ccui.RelativeLayoutParameter","ccui.LayoutParameter",NULL); tolua_beginmodule(tolua_S,"RelativeLayoutParameter"); tolua_function(tolua_S,"setAlign",lua_cocos2dx_gui_RelativeLayoutParameter_setAlign); tolua_function(tolua_S,"setRelativeToWidgetName",lua_cocos2dx_gui_RelativeLayoutParameter_setRelativeToWidgetName); tolua_function(tolua_S,"getRelativeName",lua_cocos2dx_gui_RelativeLayoutParameter_getRelativeName); tolua_function(tolua_S,"getRelativeToWidgetName",lua_cocos2dx_gui_RelativeLayoutParameter_getRelativeToWidgetName); tolua_function(tolua_S,"setRelativeName",lua_cocos2dx_gui_RelativeLayoutParameter_setRelativeName); tolua_function(tolua_S,"getAlign",lua_cocos2dx_gui_RelativeLayoutParameter_getAlign); tolua_function(tolua_S,"new",lua_cocos2dx_gui_RelativeLayoutParameter_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_RelativeLayoutParameter_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::RelativeLayoutParameter).name(); g_luaType[typeName] = "ccui.RelativeLayoutParameter"; g_typeCast["RelativeLayoutParameter"] = "ccui.RelativeLayoutParameter"; return 1; } int lua_cocos2dx_gui_Widget_getVirtualRenderer(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getVirtualRenderer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getVirtualRenderer(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVirtualRenderer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getVirtualRenderer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setSizePercent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setSizePercent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setSizePercent(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSizePercent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setSizePercent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setActionTag(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setActionTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setActionTag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setActionTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setActionTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getNodeByTag(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getNodeByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Node* ret = cobj->getNodeByTag(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeByTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getNodeByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_isFlipY(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_isFlipY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isFlipY(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFlipY",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_isFlipY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getTouchEndPos(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getTouchEndPos'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getTouchEndPos(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchEndPos",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getTouchEndPos'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setPositionPercent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setPositionPercent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setPositionPercent(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPositionPercent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setPositionPercent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getNodes(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getNodes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getNodes(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getNodes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setPositionType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setPositionType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::PositionType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setPositionType(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPositionType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setPositionType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getName(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isIgnoreContentAdaptWithSize(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isIgnoreContentAdaptWithSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_updateSizeAndPosition(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_updateSizeAndPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateSizeAndPosition(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateSizeAndPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_updateSizeAndPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getBottomInParent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getBottomInParent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getBottomInParent(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBottomInParent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getBottomInParent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getActionTag(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getActionTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getActionTag(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getActionTag",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getActionTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getLayoutParameter(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getLayoutParameter'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::LayoutParameterType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::gui::LayoutParameter* ret = cobj->getLayoutParameter(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.LayoutParameter"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::LayoutParameter*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayoutParameter",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getLayoutParameter'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getPositionType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getPositionType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getPositionType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPositionType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getPositionType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getChildByName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getChildByName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cocos2d::gui::Widget* ret = cobj->getChildByName(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getChildByName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getChildByName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_isEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_isEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_isEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_isFlipX(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_isFlipX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isFlipX(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFlipX",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_isFlipX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_removeNodeByTag(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_removeNodeByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->removeNodeByTag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeNodeByTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_removeNodeByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_isTouchEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_isTouchEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isTouchEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTouchEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_isTouchEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getContentSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getContentSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getContentSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContentSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getContentSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getTouchStartPos(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getTouchStartPos'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getTouchStartPos(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchStartPos",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getTouchStartPos'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_didNotSelectSelf(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_didNotSelectSelf'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->didNotSelectSelf(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "didNotSelectSelf",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_didNotSelectSelf'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setFocused(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setFocused'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFocused(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFocused",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setFocused'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setTouchEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setTouchEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTouchEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTouchEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setTouchEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_clone(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_clone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::Widget* ret = cobj->clone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_clone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getTouchMovePos(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getTouchMovePos'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getTouchMovePos(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchMovePos",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getTouchMovePos'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setBrightStyle(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setBrightStyle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::BrightStyle arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setBrightStyle(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBrightStyle",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setBrightStyle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_addNode(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_addNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cobj->addNode(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj->addNode(arg0); return 0; } }while(0); ok = true; do{ if (argc == 3) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } int arg2; ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if (!ok) { break; } cobj->addNode(arg0, arg1, arg2); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addNode",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_addNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setLayoutParameter(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setLayoutParameter'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::LayoutParameter* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccui.LayoutParameter",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::LayoutParameter*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setLayoutParameter(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLayoutParameter",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setLayoutParameter'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setFlipY(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setFlipY'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFlipY(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFlipY",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setFlipY'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setFlipX(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setFlipX'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFlipX(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFlipX",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setFlipX'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getLeftInParent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getLeftInParent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getLeftInParent(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLeftInParent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getLeftInParent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_ignoreContentAdaptWithSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_ignoreContentAdaptWithSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->ignoreContentAdaptWithSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ignoreContentAdaptWithSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_ignoreContentAdaptWithSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_isBright(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_isBright'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isBright(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isBright",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_isBright'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_clippingParentAreaContainPoint(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_clippingParentAreaContainPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; bool ret = cobj->clippingParentAreaContainPoint(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clippingParentAreaContainPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_clippingParentAreaContainPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getSizePercent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getSizePercent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getSizePercent(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSizePercent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getSizePercent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getTopInParent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getTopInParent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getTopInParent(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTopInParent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getTopInParent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getWidgetType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getWidgetType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getWidgetType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWidgetType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getWidgetType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getRightInParent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getRightInParent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRightInParent(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRightInParent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getRightInParent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getSizeType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getSizeType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getSizeType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSizeType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getSizeType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_removeNode(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_removeNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_removeNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_removeAllNodes(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_removeAllNodes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllNodes(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllNodes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_removeAllNodes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getWorldPosition(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getWorldPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getWorldPosition(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWorldPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getWorldPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_getPositionPercent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_getPositionPercent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Point& ret = cobj->getPositionPercent(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPositionPercent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_getPositionPercent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_hitTest(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_hitTest'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; bool ret = cobj->hitTest(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hitTest",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_hitTest'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_isFocused(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_isFocused'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isFocused(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isFocused",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_isFocused'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setSizeType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setSizeType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::SizeType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setSizeType(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSizeType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setSizeType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_checkChildInfo(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_checkChildInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; cocos2d::gui::Widget* arg1; cocos2d::Point arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); do { if (!luaval_is_usertype(tolua_S,3,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; cobj->checkChildInfo(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "checkChildInfo",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_checkChildInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_setBright(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Widget_setBright'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBright(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBright",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_setBright'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::Widget* ret = cocos2d::gui::Widget::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Widget_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Widget* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::Widget(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.Widget"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.Widget"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Widget",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Widget_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_Widget_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Widget)"); return 0; } int lua_register_cocos2dx_gui_Widget(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.Widget"); tolua_cclass(tolua_S,"Widget","ccui.Widget","cc.Node",NULL); tolua_beginmodule(tolua_S,"Widget"); tolua_function(tolua_S,"getVirtualRenderer",lua_cocos2dx_gui_Widget_getVirtualRenderer); tolua_function(tolua_S,"setSizePercent",lua_cocos2dx_gui_Widget_setSizePercent); tolua_function(tolua_S,"setActionTag",lua_cocos2dx_gui_Widget_setActionTag); tolua_function(tolua_S,"getNodeByTag",lua_cocos2dx_gui_Widget_getNodeByTag); tolua_function(tolua_S,"isFlipY",lua_cocos2dx_gui_Widget_isFlipY); tolua_function(tolua_S,"getTouchEndPos",lua_cocos2dx_gui_Widget_getTouchEndPos); tolua_function(tolua_S,"setPositionPercent",lua_cocos2dx_gui_Widget_setPositionPercent); tolua_function(tolua_S,"getNodes",lua_cocos2dx_gui_Widget_getNodes); tolua_function(tolua_S,"setPositionType",lua_cocos2dx_gui_Widget_setPositionType); tolua_function(tolua_S,"getName",lua_cocos2dx_gui_Widget_getName); tolua_function(tolua_S,"isIgnoreContentAdaptWithSize",lua_cocos2dx_gui_Widget_isIgnoreContentAdaptWithSize); tolua_function(tolua_S,"updateSizeAndPosition",lua_cocos2dx_gui_Widget_updateSizeAndPosition); tolua_function(tolua_S,"getBottomInParent",lua_cocos2dx_gui_Widget_getBottomInParent); tolua_function(tolua_S,"getActionTag",lua_cocos2dx_gui_Widget_getActionTag); tolua_function(tolua_S,"getLayoutParameter",lua_cocos2dx_gui_Widget_getLayoutParameter); tolua_function(tolua_S,"getPositionType",lua_cocos2dx_gui_Widget_getPositionType); tolua_function(tolua_S,"setName",lua_cocos2dx_gui_Widget_setName); tolua_function(tolua_S,"getChildByName",lua_cocos2dx_gui_Widget_getChildByName); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_gui_Widget_isEnabled); tolua_function(tolua_S,"isFlipX",lua_cocos2dx_gui_Widget_isFlipX); tolua_function(tolua_S,"removeNodeByTag",lua_cocos2dx_gui_Widget_removeNodeByTag); tolua_function(tolua_S,"isTouchEnabled",lua_cocos2dx_gui_Widget_isTouchEnabled); tolua_function(tolua_S,"getContentSize",lua_cocos2dx_gui_Widget_getContentSize); tolua_function(tolua_S,"getTouchStartPos",lua_cocos2dx_gui_Widget_getTouchStartPos); tolua_function(tolua_S,"didNotSelectSelf",lua_cocos2dx_gui_Widget_didNotSelectSelf); tolua_function(tolua_S,"setFocused",lua_cocos2dx_gui_Widget_setFocused); tolua_function(tolua_S,"setTouchEnabled",lua_cocos2dx_gui_Widget_setTouchEnabled); tolua_function(tolua_S,"clone",lua_cocos2dx_gui_Widget_clone); tolua_function(tolua_S,"getTouchMovePos",lua_cocos2dx_gui_Widget_getTouchMovePos); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_gui_Widget_setEnabled); tolua_function(tolua_S,"setBrightStyle",lua_cocos2dx_gui_Widget_setBrightStyle); tolua_function(tolua_S,"addNode",lua_cocos2dx_gui_Widget_addNode); tolua_function(tolua_S,"setLayoutParameter",lua_cocos2dx_gui_Widget_setLayoutParameter); tolua_function(tolua_S,"setFlipY",lua_cocos2dx_gui_Widget_setFlipY); tolua_function(tolua_S,"setFlipX",lua_cocos2dx_gui_Widget_setFlipX); tolua_function(tolua_S,"getLeftInParent",lua_cocos2dx_gui_Widget_getLeftInParent); tolua_function(tolua_S,"ignoreContentAdaptWithSize",lua_cocos2dx_gui_Widget_ignoreContentAdaptWithSize); tolua_function(tolua_S,"isBright",lua_cocos2dx_gui_Widget_isBright); tolua_function(tolua_S,"clippingParentAreaContainPoint",lua_cocos2dx_gui_Widget_clippingParentAreaContainPoint); tolua_function(tolua_S,"getSizePercent",lua_cocos2dx_gui_Widget_getSizePercent); tolua_function(tolua_S,"getTopInParent",lua_cocos2dx_gui_Widget_getTopInParent); tolua_function(tolua_S,"getWidgetType",lua_cocos2dx_gui_Widget_getWidgetType); tolua_function(tolua_S,"getSize",lua_cocos2dx_gui_Widget_getSize); tolua_function(tolua_S,"getRightInParent",lua_cocos2dx_gui_Widget_getRightInParent); tolua_function(tolua_S,"getSizeType",lua_cocos2dx_gui_Widget_getSizeType); tolua_function(tolua_S,"removeNode",lua_cocos2dx_gui_Widget_removeNode); tolua_function(tolua_S,"removeAllNodes",lua_cocos2dx_gui_Widget_removeAllNodes); tolua_function(tolua_S,"getWorldPosition",lua_cocos2dx_gui_Widget_getWorldPosition); tolua_function(tolua_S,"getPositionPercent",lua_cocos2dx_gui_Widget_getPositionPercent); tolua_function(tolua_S,"hitTest",lua_cocos2dx_gui_Widget_hitTest); tolua_function(tolua_S,"isFocused",lua_cocos2dx_gui_Widget_isFocused); tolua_function(tolua_S,"setSizeType",lua_cocos2dx_gui_Widget_setSizeType); tolua_function(tolua_S,"checkChildInfo",lua_cocos2dx_gui_Widget_checkChildInfo); tolua_function(tolua_S,"setSize",lua_cocos2dx_gui_Widget_setSize); tolua_function(tolua_S,"setBright",lua_cocos2dx_gui_Widget_setBright); tolua_function(tolua_S,"new",lua_cocos2dx_gui_Widget_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_Widget_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::Widget).name(); g_luaType[typeName] = "ccui.Widget"; g_typeCast["Widget"] = "ccui.Widget"; return 1; } int lua_cocos2dx_gui_Layout_setBackGroundColorVector(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setBackGroundColorVector'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setBackGroundColorVector(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackGroundColorVector",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setBackGroundColorVector'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_hitTest(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_hitTest'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; bool ret = cobj->hitTest(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hitTest",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_hitTest'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_getBackGroundImageTextureSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_getBackGroundImageTextureSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getBackGroundImageTextureSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackGroundImageTextureSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_getBackGroundImageTextureSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_getLayoutType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_getLayoutType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getLayoutType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayoutType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_getLayoutType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setClippingType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setClippingType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::LayoutClippingType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setClippingType(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setClippingType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setClippingType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setBackGroundColorType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setBackGroundColorType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::LayoutBackGroundColorType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setBackGroundColorType(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackGroundColorType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setBackGroundColorType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setBackGroundImage(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setBackGroundImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setBackGroundImage(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setBackGroundImage(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackGroundImage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setBackGroundImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setBackGroundColor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setBackGroundColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Color3B arg1; ok &= luaval_to_color3b(tolua_S, 3, &arg1); if (!ok) { break; } cobj->setBackGroundColor(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if (!ok) { break; } cobj->setBackGroundColor(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackGroundColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setBackGroundColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_requestDoLayout(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_requestDoLayout'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->requestDoLayout(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "requestDoLayout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_requestDoLayout'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_isClippingEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_isClippingEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isClippingEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isClippingEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_isClippingEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setBackGroundColorOpacity(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setBackGroundColorOpacity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setBackGroundColorOpacity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackGroundColorOpacity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setBackGroundColorOpacity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setBackGroundImageCapInsets(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setBackGroundImageCapInsets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setBackGroundImageCapInsets(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackGroundImageCapInsets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setBackGroundImageCapInsets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_removeBackGroundImage(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_removeBackGroundImage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeBackGroundImage(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeBackGroundImage",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_removeBackGroundImage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBackGroundImageScale9Enabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackGroundImageScale9Enabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setClippingEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setClippingEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setClippingEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setClippingEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setClippingEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_setLayoutType(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Layout_setLayoutType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::LayoutType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setLayoutType(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLayoutType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_setLayoutType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Layout",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::Layout* ret = cocos2d::gui::Layout::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Layout"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Layout*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Layout_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Layout* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::Layout(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.Layout"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.Layout"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Layout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Layout_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_Layout_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Layout)"); return 0; } int lua_register_cocos2dx_gui_Layout(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.Layout"); tolua_cclass(tolua_S,"Layout","ccui.Layout","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"Layout"); tolua_function(tolua_S,"setBackGroundColorVector",lua_cocos2dx_gui_Layout_setBackGroundColorVector); tolua_function(tolua_S,"hitTest",lua_cocos2dx_gui_Layout_hitTest); tolua_function(tolua_S,"getBackGroundImageTextureSize",lua_cocos2dx_gui_Layout_getBackGroundImageTextureSize); tolua_function(tolua_S,"getLayoutType",lua_cocos2dx_gui_Layout_getLayoutType); tolua_function(tolua_S,"setClippingType",lua_cocos2dx_gui_Layout_setClippingType); tolua_function(tolua_S,"setBackGroundColorType",lua_cocos2dx_gui_Layout_setBackGroundColorType); tolua_function(tolua_S,"setBackGroundImage",lua_cocos2dx_gui_Layout_setBackGroundImage); tolua_function(tolua_S,"setBackGroundColor",lua_cocos2dx_gui_Layout_setBackGroundColor); tolua_function(tolua_S,"requestDoLayout",lua_cocos2dx_gui_Layout_requestDoLayout); tolua_function(tolua_S,"isClippingEnabled",lua_cocos2dx_gui_Layout_isClippingEnabled); tolua_function(tolua_S,"setBackGroundColorOpacity",lua_cocos2dx_gui_Layout_setBackGroundColorOpacity); tolua_function(tolua_S,"setBackGroundImageCapInsets",lua_cocos2dx_gui_Layout_setBackGroundImageCapInsets); tolua_function(tolua_S,"removeBackGroundImage",lua_cocos2dx_gui_Layout_removeBackGroundImage); tolua_function(tolua_S,"setBackGroundImageScale9Enabled",lua_cocos2dx_gui_Layout_setBackGroundImageScale9Enabled); tolua_function(tolua_S,"setClippingEnabled",lua_cocos2dx_gui_Layout_setClippingEnabled); tolua_function(tolua_S,"setLayoutType",lua_cocos2dx_gui_Layout_setLayoutType); tolua_function(tolua_S,"new",lua_cocos2dx_gui_Layout_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_Layout_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::Layout).name(); g_luaType[typeName] = "ccui.Layout"; g_typeCast["Layout"] = "ccui.Layout"; return 1; } int lua_cocos2dx_gui_Button_getTitleText(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_getTitleText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getTitleText(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleText",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_getTitleText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_loadTextureNormal(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_loadTextureNormal'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTextureNormal(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTextureNormal(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextureNormal",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_loadTextureNormal'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setCapInsetsNormalRenderer(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setCapInsetsNormalRenderer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsetsNormalRenderer(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsetsNormalRenderer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setCapInsetsNormalRenderer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setCapInsetsPressedRenderer(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setCapInsetsPressedRenderer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsetsPressedRenderer(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsetsPressedRenderer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setCapInsetsPressedRenderer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_loadTexturePressed(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_loadTexturePressed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTexturePressed(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTexturePressed(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTexturePressed",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_loadTexturePressed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setTitleFontSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setTitleFontSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTitleFontSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleFontSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setTitleFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setCapInsetsDisabledRenderer(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setCapInsetsDisabledRenderer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsetsDisabledRenderer(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsetsDisabledRenderer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setCapInsetsDisabledRenderer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setTitleFontName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setTitleFontName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setTitleFontName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleFontName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setTitleFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_getTitleColor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_getTitleColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Color3B& ret = cobj->getTitleColor(); color3b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_getTitleColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_loadTextureDisabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_loadTextureDisabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTextureDisabled(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTextureDisabled(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextureDisabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_loadTextureDisabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_getTitleFontName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_getTitleFontName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getTitleFontName(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleFontName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_getTitleFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setPressedActionEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setPressedActionEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPressedActionEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPressedActionEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setPressedActionEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setCapInsets(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setCapInsets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsets(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setCapInsets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setScale9Enabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setScale9Enabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScale9Enabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScale9Enabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setScale9Enabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_loadTextures(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_loadTextures'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { const char* arg0; const char* arg1; const char* arg2; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); if(!ok) return 0; cobj->loadTextures(arg0, arg1, arg2); return 0; } if (argc == 4) { const char* arg0; const char* arg1; const char* arg2; cocos2d::gui::TextureResType arg3; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cobj->loadTextures(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextures",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_loadTextures'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_getTitleFontSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_getTitleFontSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getTitleFontSize(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTitleFontSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_getTitleFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setTitleText(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setTitleText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTitleText(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleText",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setTitleText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_setTitleColor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Button*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Button_setTitleColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color3B arg0; ok &= luaval_to_color3b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTitleColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTitleColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_setTitleColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::Button* ret = cocos2d::gui::Button::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Button"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Button*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Button_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Button* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::Button(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.Button"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.Button"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Button",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Button_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_Button_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Button)"); return 0; } int lua_register_cocos2dx_gui_Button(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.Button"); tolua_cclass(tolua_S,"Button","ccui.Button","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"Button"); tolua_function(tolua_S,"getTitleText",lua_cocos2dx_gui_Button_getTitleText); tolua_function(tolua_S,"loadTextureNormal",lua_cocos2dx_gui_Button_loadTextureNormal); tolua_function(tolua_S,"setCapInsetsNormalRenderer",lua_cocos2dx_gui_Button_setCapInsetsNormalRenderer); tolua_function(tolua_S,"setCapInsetsPressedRenderer",lua_cocos2dx_gui_Button_setCapInsetsPressedRenderer); tolua_function(tolua_S,"loadTexturePressed",lua_cocos2dx_gui_Button_loadTexturePressed); tolua_function(tolua_S,"setTitleFontSize",lua_cocos2dx_gui_Button_setTitleFontSize); tolua_function(tolua_S,"setCapInsetsDisabledRenderer",lua_cocos2dx_gui_Button_setCapInsetsDisabledRenderer); tolua_function(tolua_S,"setTitleFontName",lua_cocos2dx_gui_Button_setTitleFontName); tolua_function(tolua_S,"getTitleColor",lua_cocos2dx_gui_Button_getTitleColor); tolua_function(tolua_S,"loadTextureDisabled",lua_cocos2dx_gui_Button_loadTextureDisabled); tolua_function(tolua_S,"getTitleFontName",lua_cocos2dx_gui_Button_getTitleFontName); tolua_function(tolua_S,"setPressedActionEnabled",lua_cocos2dx_gui_Button_setPressedActionEnabled); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_gui_Button_setCapInsets); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_gui_Button_setScale9Enabled); tolua_function(tolua_S,"loadTextures",lua_cocos2dx_gui_Button_loadTextures); tolua_function(tolua_S,"getTitleFontSize",lua_cocos2dx_gui_Button_getTitleFontSize); tolua_function(tolua_S,"setTitleText",lua_cocos2dx_gui_Button_setTitleText); tolua_function(tolua_S,"setTitleColor",lua_cocos2dx_gui_Button_setTitleColor); tolua_function(tolua_S,"new",lua_cocos2dx_gui_Button_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_Button_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::Button).name(); g_luaType[typeName] = "ccui.Button"; g_typeCast["Button"] = "ccui.Button"; return 1; } int lua_cocos2dx_gui_CheckBox_getSelectedState(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::CheckBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_CheckBox_getSelectedState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getSelectedState(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSelectedState",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_getSelectedState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::CheckBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTextureBackGroundSelected(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTextureBackGroundSelected(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextureBackGroundSelected",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::CheckBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTextureBackGroundDisabled(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTextureBackGroundDisabled(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextureBackGroundDisabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_loadTextureFrontCross(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::CheckBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_CheckBox_loadTextureFrontCross'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTextureFrontCross(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTextureFrontCross(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextureFrontCross",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_loadTextureFrontCross'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_loadTextures(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::CheckBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_CheckBox_loadTextures'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 5) { const char* arg0; const char* arg1; const char* arg2; const char* arg3; const char* arg4; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); std::string arg3_tmp; ok &= luaval_to_std_string(tolua_S, 5, &arg3_tmp); arg3 = arg3_tmp.c_str(); std::string arg4_tmp; ok &= luaval_to_std_string(tolua_S, 6, &arg4_tmp); arg4 = arg4_tmp.c_str(); if(!ok) return 0; cobj->loadTextures(arg0, arg1, arg2, arg3, arg4); return 0; } if (argc == 6) { const char* arg0; const char* arg1; const char* arg2; const char* arg3; const char* arg4; cocos2d::gui::TextureResType arg5; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); std::string arg3_tmp; ok &= luaval_to_std_string(tolua_S, 5, &arg3_tmp); arg3 = arg3_tmp.c_str(); std::string arg4_tmp; ok &= luaval_to_std_string(tolua_S, 6, &arg4_tmp); arg4 = arg4_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5); if(!ok) return 0; cobj->loadTextures(arg0, arg1, arg2, arg3, arg4, arg5); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextures",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_loadTextures'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_loadTextureBackGround(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::CheckBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_CheckBox_loadTextureBackGround'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTextureBackGround(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTextureBackGround(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextureBackGround",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_loadTextureBackGround'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_setSelectedState(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::CheckBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_CheckBox_setSelectedState'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSelectedState(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSelectedState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_setSelectedState'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::CheckBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTextureFrontCrossDisabled(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTextureFrontCrossDisabled(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTextureFrontCrossDisabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::CheckBox* ret = cocos2d::gui::CheckBox::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.CheckBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::CheckBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_CheckBox_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::CheckBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::CheckBox(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.CheckBox"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.CheckBox"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "CheckBox",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_CheckBox_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_CheckBox_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (CheckBox)"); return 0; } int lua_register_cocos2dx_gui_CheckBox(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.CheckBox"); tolua_cclass(tolua_S,"CheckBox","ccui.CheckBox","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"CheckBox"); tolua_function(tolua_S,"getSelectedState",lua_cocos2dx_gui_CheckBox_getSelectedState); tolua_function(tolua_S,"loadTextureBackGroundSelected",lua_cocos2dx_gui_CheckBox_loadTextureBackGroundSelected); tolua_function(tolua_S,"loadTextureBackGroundDisabled",lua_cocos2dx_gui_CheckBox_loadTextureBackGroundDisabled); tolua_function(tolua_S,"loadTextureFrontCross",lua_cocos2dx_gui_CheckBox_loadTextureFrontCross); tolua_function(tolua_S,"loadTextures",lua_cocos2dx_gui_CheckBox_loadTextures); tolua_function(tolua_S,"loadTextureBackGround",lua_cocos2dx_gui_CheckBox_loadTextureBackGround); tolua_function(tolua_S,"setSelectedState",lua_cocos2dx_gui_CheckBox_setSelectedState); tolua_function(tolua_S,"loadTextureFrontCrossDisabled",lua_cocos2dx_gui_CheckBox_loadTextureFrontCrossDisabled); tolua_function(tolua_S,"new",lua_cocos2dx_gui_CheckBox_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_CheckBox_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::CheckBox).name(); g_luaType[typeName] = "ccui.CheckBox"; g_typeCast["CheckBox"] = "ccui.CheckBox"; return 1; } int lua_cocos2dx_gui_ImageView_setTextureRect(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ImageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ImageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ImageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ImageView_setTextureRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTextureRect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextureRect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ImageView_setTextureRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ImageView_setCapInsets(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ImageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ImageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ImageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ImageView_setCapInsets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsets(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ImageView_setCapInsets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ImageView_setScale9Enabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ImageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ImageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ImageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ImageView_setScale9Enabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScale9Enabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScale9Enabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ImageView_setScale9Enabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ImageView_loadTexture(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ImageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ImageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ImageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ImageView_loadTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTexture(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTexture(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ImageView_loadTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ImageView_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.ImageView",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::ImageView* ret = cocos2d::gui::ImageView::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.ImageView"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::ImageView*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ImageView_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ImageView_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ImageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::ImageView(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.ImageView"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.ImageView"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ImageView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ImageView_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_ImageView_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ImageView)"); return 0; } int lua_register_cocos2dx_gui_ImageView(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.ImageView"); tolua_cclass(tolua_S,"ImageView","ccui.ImageView","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"ImageView"); tolua_function(tolua_S,"setTextureRect",lua_cocos2dx_gui_ImageView_setTextureRect); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_gui_ImageView_setCapInsets); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_gui_ImageView_setScale9Enabled); tolua_function(tolua_S,"loadTexture",lua_cocos2dx_gui_ImageView_loadTexture); tolua_function(tolua_S,"new",lua_cocos2dx_gui_ImageView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_ImageView_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::ImageView).name(); g_luaType[typeName] = "ccui.ImageView"; g_typeCast["ImageView"] = "ccui.ImageView"; return 1; } int lua_cocos2dx_gui_Text_getStringLength(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_getStringLength'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getStringLength(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringLength",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_getStringLength'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_setFontName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_setFontName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFontName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_setFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_setTouchScaleChangeEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_setTouchScaleChangeEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTouchScaleChangeEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTouchScaleChangeEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_setTouchScaleChangeEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_getStringValue(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_getStringValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getStringValue(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_getStringValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_setText(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_setText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setText(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setText",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_setText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_setTextVerticalAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_setTextVerticalAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextVAlignment arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setTextVerticalAlignment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextVerticalAlignment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_setTextVerticalAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_setFontSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_setFontSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setFontSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_setFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_isTouchScaleChangeEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_isTouchScaleChangeEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isTouchScaleChangeEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTouchScaleChangeEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_isTouchScaleChangeEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_setTextHorizontalAlignment(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_setTextHorizontalAlignment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::TextHAlignment arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setTextHorizontalAlignment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextHorizontalAlignment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_setTextHorizontalAlignment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_setTextAreaSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Text*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Text_setTextAreaSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTextAreaSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTextAreaSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_setTextAreaSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::Text* ret = cocos2d::gui::Text::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Text"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Text*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Text_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Text* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::Text(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.Text"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.Text"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Text",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Text_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_Text_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Text)"); return 0; } int lua_register_cocos2dx_gui_Text(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.Text"); tolua_cclass(tolua_S,"Text","ccui.Text","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"Text"); tolua_function(tolua_S,"getStringLength",lua_cocos2dx_gui_Text_getStringLength); tolua_function(tolua_S,"setFontName",lua_cocos2dx_gui_Text_setFontName); tolua_function(tolua_S,"setTouchScaleChangeEnabled",lua_cocos2dx_gui_Text_setTouchScaleChangeEnabled); tolua_function(tolua_S,"getStringValue",lua_cocos2dx_gui_Text_getStringValue); tolua_function(tolua_S,"setText",lua_cocos2dx_gui_Text_setText); tolua_function(tolua_S,"setTextVerticalAlignment",lua_cocos2dx_gui_Text_setTextVerticalAlignment); tolua_function(tolua_S,"setFontSize",lua_cocos2dx_gui_Text_setFontSize); tolua_function(tolua_S,"isTouchScaleChangeEnabled",lua_cocos2dx_gui_Text_isTouchScaleChangeEnabled); tolua_function(tolua_S,"setTextHorizontalAlignment",lua_cocos2dx_gui_Text_setTextHorizontalAlignment); tolua_function(tolua_S,"setTextAreaSize",lua_cocos2dx_gui_Text_setTextAreaSize); tolua_function(tolua_S,"new",lua_cocos2dx_gui_Text_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_Text_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::Text).name(); g_luaType[typeName] = "ccui.Text"; g_typeCast["Text"] = "ccui.Text"; return 1; } int lua_cocos2dx_gui_TextAtlas_setProperty(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextAtlas_setProperty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 5) { std::string arg0; std::string arg1; int arg2; int arg3; std::string arg4; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); ok &= luaval_to_std_string(tolua_S, 6,&arg4); if(!ok) return 0; cobj->setProperty(arg0, arg1, arg2, arg3, arg4); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setProperty",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextAtlas_setProperty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextAtlas_getStringValue(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextAtlas_getStringValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getStringValue(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextAtlas_getStringValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextAtlas_setStringValue(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextAtlas",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextAtlas*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextAtlas_setStringValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStringValue(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStringValue",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextAtlas_setStringValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextAtlas_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.TextAtlas",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::TextAtlas* ret = cocos2d::gui::TextAtlas::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.TextAtlas"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::TextAtlas*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextAtlas_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextAtlas_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextAtlas* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::TextAtlas(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.TextAtlas"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.TextAtlas"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TextAtlas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextAtlas_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_TextAtlas_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TextAtlas)"); return 0; } int lua_register_cocos2dx_gui_TextAtlas(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.TextAtlas"); tolua_cclass(tolua_S,"TextAtlas","ccui.TextAtlas","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"TextAtlas"); tolua_function(tolua_S,"setProperty",lua_cocos2dx_gui_TextAtlas_setProperty); tolua_function(tolua_S,"getStringValue",lua_cocos2dx_gui_TextAtlas_getStringValue); tolua_function(tolua_S,"setStringValue",lua_cocos2dx_gui_TextAtlas_setStringValue); tolua_function(tolua_S,"new",lua_cocos2dx_gui_TextAtlas_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_TextAtlas_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::TextAtlas).name(); g_luaType[typeName] = "ccui.TextAtlas"; g_typeCast["TextAtlas"] = "ccui.TextAtlas"; return 1; } int lua_cocos2dx_gui_LoadingBar_setPercent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LoadingBar* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LoadingBar*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LoadingBar_setPercent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setPercent(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPercent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_setPercent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LoadingBar_loadTexture(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LoadingBar* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LoadingBar*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LoadingBar_loadTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadTexture(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadTexture(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_loadTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LoadingBar_setDirection(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LoadingBar* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LoadingBar*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LoadingBar_setDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::LoadingBarType arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setDirection(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDirection",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_setDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LoadingBar_setScale9Enabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LoadingBar* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LoadingBar*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LoadingBar_setScale9Enabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScale9Enabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScale9Enabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_setScale9Enabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LoadingBar_setCapInsets(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LoadingBar* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LoadingBar*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LoadingBar_setCapInsets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsets(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_setCapInsets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LoadingBar_getDirection(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LoadingBar* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LoadingBar*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LoadingBar_getDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getDirection(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDirection",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_getDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LoadingBar_getPercent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LoadingBar* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::LoadingBar*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_LoadingBar_getPercent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPercent(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPercent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_getPercent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LoadingBar_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.LoadingBar",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::LoadingBar* ret = cocos2d::gui::LoadingBar::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.LoadingBar"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::LoadingBar*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_LoadingBar_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::LoadingBar* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::LoadingBar(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.LoadingBar"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.LoadingBar"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "LoadingBar",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_LoadingBar_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_LoadingBar_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (LoadingBar)"); return 0; } int lua_register_cocos2dx_gui_LoadingBar(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.LoadingBar"); tolua_cclass(tolua_S,"LoadingBar","ccui.LoadingBar","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"LoadingBar"); tolua_function(tolua_S,"setPercent",lua_cocos2dx_gui_LoadingBar_setPercent); tolua_function(tolua_S,"loadTexture",lua_cocos2dx_gui_LoadingBar_loadTexture); tolua_function(tolua_S,"setDirection",lua_cocos2dx_gui_LoadingBar_setDirection); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_gui_LoadingBar_setScale9Enabled); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_gui_LoadingBar_setCapInsets); tolua_function(tolua_S,"getDirection",lua_cocos2dx_gui_LoadingBar_getDirection); tolua_function(tolua_S,"getPercent",lua_cocos2dx_gui_LoadingBar_getPercent); tolua_function(tolua_S,"new",lua_cocos2dx_gui_LoadingBar_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_LoadingBar_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::LoadingBar).name(); g_luaType[typeName] = "ccui.LoadingBar"; g_typeCast["LoadingBar"] = "ccui.LoadingBar"; return 1; } int lua_cocos2dx_gui_ScrollView_scrollToTop(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToTop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->scrollToTop(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToTop",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToTop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToPercentHorizontal(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToPercentHorizontal'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { double arg0; double arg1; bool arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cobj->scrollToPercentHorizontal(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToPercentHorizontal",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToPercentHorizontal'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_isInertiaScrollEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_isInertiaScrollEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isInertiaScrollEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isInertiaScrollEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_isInertiaScrollEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToPercentBothDirection(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToPercentBothDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::Point arg0; double arg1; bool arg2; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cobj->scrollToPercentBothDirection(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToPercentBothDirection",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToPercentBothDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_getDirection(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_getDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getDirection(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDirection",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_getDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToBottomLeft(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToBottomLeft'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->scrollToBottomLeft(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToBottomLeft",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToBottomLeft'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_getInnerContainer(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_getInnerContainer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::Layout* ret = cobj->getInnerContainer(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Layout"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Layout*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInnerContainer",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_getInnerContainer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToBottom(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToBottom'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->jumpToBottom(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToBottom",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToBottom'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_setDirection(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_setDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::SCROLLVIEW_DIR arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setDirection(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDirection",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_setDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToTopLeft(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToTopLeft'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->scrollToTopLeft(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToTopLeft",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToTopLeft'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToTopRight(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToTopRight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->jumpToTopRight(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToTopRight",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToTopRight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToBottomLeft(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToBottomLeft'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->jumpToBottomLeft(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToBottomLeft",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToBottomLeft'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_setInnerContainerSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_setInnerContainerSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setInnerContainerSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInnerContainerSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_setInnerContainerSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_getInnerContainerSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_getInnerContainerSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Size& ret = cobj->getInnerContainerSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInnerContainerSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_getInnerContainerSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_isBounceEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_isBounceEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isBounceEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isBounceEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_isBounceEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToPercentVertical(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToPercentVertical'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->jumpToPercentVertical(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToPercentVertical",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToPercentVertical'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_setInertiaScrollEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_setInertiaScrollEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setInertiaScrollEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInertiaScrollEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_setInertiaScrollEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToTopLeft(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToTopLeft'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->jumpToTopLeft(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToTopLeft",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToTopLeft'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToPercentHorizontal(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToPercentHorizontal'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->jumpToPercentHorizontal(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToPercentHorizontal",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToPercentHorizontal'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToBottomRight(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToBottomRight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->jumpToBottomRight(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToBottomRight",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToBottomRight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_setBounceEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_setBounceEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBounceEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBounceEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_setBounceEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToTop(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToTop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->jumpToTop(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToTop",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToTop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToLeft(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToLeft'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->scrollToLeft(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToLeft",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToLeft'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToPercentBothDirection(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToPercentBothDirection'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->jumpToPercentBothDirection(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToPercentBothDirection",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToPercentBothDirection'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToPercentVertical(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToPercentVertical'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { double arg0; double arg1; bool arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cobj->scrollToPercentVertical(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToPercentVertical",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToPercentVertical'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToBottom(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToBottom'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->scrollToBottom(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToBottom",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToBottom'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToBottomRight(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToBottomRight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->scrollToBottomRight(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToBottomRight",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToBottomRight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToLeft(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToLeft'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->jumpToLeft(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToLeft",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToLeft'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToRight(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToRight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->scrollToRight(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToRight",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToRight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_jumpToRight(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_jumpToRight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->jumpToRight(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "jumpToRight",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_jumpToRight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_scrollToTopRight(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ScrollView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ScrollView_scrollToTopRight'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; bool arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->scrollToTopRight(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToTopRight",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_scrollToTopRight'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::ScrollView* ret = cocos2d::gui::ScrollView::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.ScrollView"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::ScrollView*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ScrollView_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ScrollView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::ScrollView(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.ScrollView"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.ScrollView"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ScrollView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ScrollView_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_ScrollView_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ScrollView)"); return 0; } int lua_register_cocos2dx_gui_ScrollView(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.ScrollView"); tolua_cclass(tolua_S,"ScrollView","ccui.ScrollView","ccui.Layout",NULL); tolua_beginmodule(tolua_S,"ScrollView"); tolua_function(tolua_S,"scrollToTop",lua_cocos2dx_gui_ScrollView_scrollToTop); tolua_function(tolua_S,"scrollToPercentHorizontal",lua_cocos2dx_gui_ScrollView_scrollToPercentHorizontal); tolua_function(tolua_S,"isInertiaScrollEnabled",lua_cocos2dx_gui_ScrollView_isInertiaScrollEnabled); tolua_function(tolua_S,"scrollToPercentBothDirection",lua_cocos2dx_gui_ScrollView_scrollToPercentBothDirection); tolua_function(tolua_S,"getDirection",lua_cocos2dx_gui_ScrollView_getDirection); tolua_function(tolua_S,"scrollToBottomLeft",lua_cocos2dx_gui_ScrollView_scrollToBottomLeft); tolua_function(tolua_S,"getInnerContainer",lua_cocos2dx_gui_ScrollView_getInnerContainer); tolua_function(tolua_S,"jumpToBottom",lua_cocos2dx_gui_ScrollView_jumpToBottom); tolua_function(tolua_S,"setDirection",lua_cocos2dx_gui_ScrollView_setDirection); tolua_function(tolua_S,"scrollToTopLeft",lua_cocos2dx_gui_ScrollView_scrollToTopLeft); tolua_function(tolua_S,"jumpToTopRight",lua_cocos2dx_gui_ScrollView_jumpToTopRight); tolua_function(tolua_S,"jumpToBottomLeft",lua_cocos2dx_gui_ScrollView_jumpToBottomLeft); tolua_function(tolua_S,"setInnerContainerSize",lua_cocos2dx_gui_ScrollView_setInnerContainerSize); tolua_function(tolua_S,"getInnerContainerSize",lua_cocos2dx_gui_ScrollView_getInnerContainerSize); tolua_function(tolua_S,"isBounceEnabled",lua_cocos2dx_gui_ScrollView_isBounceEnabled); tolua_function(tolua_S,"jumpToPercentVertical",lua_cocos2dx_gui_ScrollView_jumpToPercentVertical); tolua_function(tolua_S,"setInertiaScrollEnabled",lua_cocos2dx_gui_ScrollView_setInertiaScrollEnabled); tolua_function(tolua_S,"jumpToTopLeft",lua_cocos2dx_gui_ScrollView_jumpToTopLeft); tolua_function(tolua_S,"jumpToPercentHorizontal",lua_cocos2dx_gui_ScrollView_jumpToPercentHorizontal); tolua_function(tolua_S,"jumpToBottomRight",lua_cocos2dx_gui_ScrollView_jumpToBottomRight); tolua_function(tolua_S,"setBounceEnabled",lua_cocos2dx_gui_ScrollView_setBounceEnabled); tolua_function(tolua_S,"jumpToTop",lua_cocos2dx_gui_ScrollView_jumpToTop); tolua_function(tolua_S,"scrollToLeft",lua_cocos2dx_gui_ScrollView_scrollToLeft); tolua_function(tolua_S,"jumpToPercentBothDirection",lua_cocos2dx_gui_ScrollView_jumpToPercentBothDirection); tolua_function(tolua_S,"scrollToPercentVertical",lua_cocos2dx_gui_ScrollView_scrollToPercentVertical); tolua_function(tolua_S,"scrollToBottom",lua_cocos2dx_gui_ScrollView_scrollToBottom); tolua_function(tolua_S,"scrollToBottomRight",lua_cocos2dx_gui_ScrollView_scrollToBottomRight); tolua_function(tolua_S,"jumpToLeft",lua_cocos2dx_gui_ScrollView_jumpToLeft); tolua_function(tolua_S,"scrollToRight",lua_cocos2dx_gui_ScrollView_scrollToRight); tolua_function(tolua_S,"jumpToRight",lua_cocos2dx_gui_ScrollView_jumpToRight); tolua_function(tolua_S,"scrollToTopRight",lua_cocos2dx_gui_ScrollView_scrollToTopRight); tolua_function(tolua_S,"new",lua_cocos2dx_gui_ScrollView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_ScrollView_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::ScrollView).name(); g_luaType[typeName] = "ccui.ScrollView"; g_typeCast["ScrollView"] = "ccui.ScrollView"; return 1; } int lua_cocos2dx_gui_ListView_getIndex(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_getIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::Widget* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; ssize_t ret = cobj->getIndex(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_getIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_removeAllItems(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_removeAllItems'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllItems(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllItems",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_removeAllItems'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_setGravity(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_setGravity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::ListViewGravity arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setGravity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGravity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_setGravity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_pushBackCustomItem(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_pushBackCustomItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::Widget* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->pushBackCustomItem(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pushBackCustomItem",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_pushBackCustomItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_getItems(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_getItems'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getItems(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getItems",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_getItems'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_removeItem(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_removeItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->removeItem(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeItem",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_removeItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_getCurSelectedIndex(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_getCurSelectedIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getCurSelectedIndex(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurSelectedIndex",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_getCurSelectedIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_insertDefaultItem(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_insertDefaultItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->insertDefaultItem(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "insertDefaultItem",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_insertDefaultItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_setItemsMargin(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_setItemsMargin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setItemsMargin(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setItemsMargin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_setItemsMargin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_removeLastItem(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_removeLastItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeLastItem(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeLastItem",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_removeLastItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_getItem(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_getItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::gui::Widget* ret = cobj->getItem(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getItem",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_getItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_setItemModel(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_setItemModel'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::Widget* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setItemModel(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setItemModel",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_setItemModel'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_requestRefreshView(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_requestRefreshView'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->requestRefreshView(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "requestRefreshView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_requestRefreshView'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_pushBackDefaultItem(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_pushBackDefaultItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pushBackDefaultItem(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pushBackDefaultItem",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_pushBackDefaultItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_insertCustomItem(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::ListView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_ListView_insertCustomItem'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::gui::Widget* arg0; ssize_t arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_ssize(tolua_S, 3, &arg1); if(!ok) return 0; cobj->insertCustomItem(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "insertCustomItem",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_insertCustomItem'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::ListView* ret = cocos2d::gui::ListView::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.ListView"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::ListView*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_ListView_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::ListView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::ListView(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.ListView"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.ListView"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ListView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_ListView_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_ListView_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ListView)"); return 0; } int lua_register_cocos2dx_gui_ListView(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.ListView"); tolua_cclass(tolua_S,"ListView","ccui.ListView","ccui.ScrollView",NULL); tolua_beginmodule(tolua_S,"ListView"); tolua_function(tolua_S,"getIndex",lua_cocos2dx_gui_ListView_getIndex); tolua_function(tolua_S,"removeAllItems",lua_cocos2dx_gui_ListView_removeAllItems); tolua_function(tolua_S,"setGravity",lua_cocos2dx_gui_ListView_setGravity); tolua_function(tolua_S,"pushBackCustomItem",lua_cocos2dx_gui_ListView_pushBackCustomItem); tolua_function(tolua_S,"getItems",lua_cocos2dx_gui_ListView_getItems); tolua_function(tolua_S,"removeItem",lua_cocos2dx_gui_ListView_removeItem); tolua_function(tolua_S,"getCurSelectedIndex",lua_cocos2dx_gui_ListView_getCurSelectedIndex); tolua_function(tolua_S,"insertDefaultItem",lua_cocos2dx_gui_ListView_insertDefaultItem); tolua_function(tolua_S,"setItemsMargin",lua_cocos2dx_gui_ListView_setItemsMargin); tolua_function(tolua_S,"removeLastItem",lua_cocos2dx_gui_ListView_removeLastItem); tolua_function(tolua_S,"getItem",lua_cocos2dx_gui_ListView_getItem); tolua_function(tolua_S,"setItemModel",lua_cocos2dx_gui_ListView_setItemModel); tolua_function(tolua_S,"requestRefreshView",lua_cocos2dx_gui_ListView_requestRefreshView); tolua_function(tolua_S,"pushBackDefaultItem",lua_cocos2dx_gui_ListView_pushBackDefaultItem); tolua_function(tolua_S,"insertCustomItem",lua_cocos2dx_gui_ListView_insertCustomItem); tolua_function(tolua_S,"new",lua_cocos2dx_gui_ListView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_ListView_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::ListView).name(); g_luaType[typeName] = "ccui.ListView"; g_typeCast["ListView"] = "ccui.ListView"; return 1; } int lua_cocos2dx_gui_Slider_setPercent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_setPercent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setPercent(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPercent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_setPercent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_loadSlidBallTextureNormal(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_loadSlidBallTextureNormal'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadSlidBallTextureNormal(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadSlidBallTextureNormal(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadSlidBallTextureNormal",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_loadSlidBallTextureNormal'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_loadBarTexture(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_loadBarTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadBarTexture(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadBarTexture(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadBarTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_loadBarTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_loadProgressBarTexture(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_loadProgressBarTexture'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadProgressBarTexture(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadProgressBarTexture(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadProgressBarTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_loadProgressBarTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_loadSlidBallTextures(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_loadSlidBallTextures'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { const char* arg0; const char* arg1; const char* arg2; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); if(!ok) return 0; cobj->loadSlidBallTextures(arg0, arg1, arg2); return 0; } if (argc == 4) { const char* arg0; const char* arg1; const char* arg2; cocos2d::gui::TextureResType arg3; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp); arg2 = arg2_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cobj->loadSlidBallTextures(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadSlidBallTextures",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_loadSlidBallTextures'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsetProgressBarRebderer(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsetProgressBarRebderer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_setCapInsetsBarRenderer(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_setCapInsetsBarRenderer'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsetsBarRenderer(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsetsBarRenderer",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_setCapInsetsBarRenderer'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_setScale9Enabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_setScale9Enabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setScale9Enabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setScale9Enabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_setScale9Enabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_setCapInsets(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_setCapInsets'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Rect arg0; ok &= luaval_to_rect(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setCapInsets(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCapInsets",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_setCapInsets'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_loadSlidBallTexturePressed(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_loadSlidBallTexturePressed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadSlidBallTexturePressed(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadSlidBallTexturePressed(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadSlidBallTexturePressed",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_loadSlidBallTexturePressed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_loadSlidBallTextureDisabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_loadSlidBallTextureDisabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->loadSlidBallTextureDisabled(arg0); return 0; } if (argc == 2) { const char* arg0; cocos2d::gui::TextureResType arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->loadSlidBallTextureDisabled(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadSlidBallTextureDisabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_loadSlidBallTextureDisabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_getPercent(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::Slider*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_Slider_getPercent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPercent(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPercent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_getPercent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::Slider* ret = cocos2d::gui::Slider::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Slider"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Slider*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Slider_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::Slider* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::Slider(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.Slider"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.Slider"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Slider",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Slider_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_Slider_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Slider)"); return 0; } int lua_register_cocos2dx_gui_Slider(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.Slider"); tolua_cclass(tolua_S,"Slider","ccui.Slider","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"Slider"); tolua_function(tolua_S,"setPercent",lua_cocos2dx_gui_Slider_setPercent); tolua_function(tolua_S,"loadSlidBallTextureNormal",lua_cocos2dx_gui_Slider_loadSlidBallTextureNormal); tolua_function(tolua_S,"loadBarTexture",lua_cocos2dx_gui_Slider_loadBarTexture); tolua_function(tolua_S,"loadProgressBarTexture",lua_cocos2dx_gui_Slider_loadProgressBarTexture); tolua_function(tolua_S,"loadSlidBallTextures",lua_cocos2dx_gui_Slider_loadSlidBallTextures); tolua_function(tolua_S,"setCapInsetProgressBarRebderer",lua_cocos2dx_gui_Slider_setCapInsetProgressBarRebderer); tolua_function(tolua_S,"setCapInsetsBarRenderer",lua_cocos2dx_gui_Slider_setCapInsetsBarRenderer); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_gui_Slider_setScale9Enabled); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_gui_Slider_setCapInsets); tolua_function(tolua_S,"loadSlidBallTexturePressed",lua_cocos2dx_gui_Slider_loadSlidBallTexturePressed); tolua_function(tolua_S,"loadSlidBallTextureDisabled",lua_cocos2dx_gui_Slider_loadSlidBallTextureDisabled); tolua_function(tolua_S,"getPercent",lua_cocos2dx_gui_Slider_getPercent); tolua_function(tolua_S,"new",lua_cocos2dx_gui_Slider_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_Slider_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::Slider).name(); g_luaType[typeName] = "ccui.Slider"; g_typeCast["Slider"] = "ccui.Slider"; return 1; } int lua_cocos2dx_gui_TextField_setAttachWithIME(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setAttachWithIME'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAttachWithIME(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAttachWithIME",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setAttachWithIME'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_getStringValue(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_getStringValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getStringValue(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_getStringValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setPasswordStyleText(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setPasswordStyleText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setPasswordStyleText(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPasswordStyleText",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setPasswordStyleText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_getAttachWithIME(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_getAttachWithIME'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getAttachWithIME(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAttachWithIME",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_getAttachWithIME'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setFontName(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setFontName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFontName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setFontName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_getInsertText(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_getInsertText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getInsertText(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInsertText",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_getInsertText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setInsertText(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setInsertText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setInsertText(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInsertText",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setInsertText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_getDetachWithIME(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_getDetachWithIME'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getDetachWithIME(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDetachWithIME",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_getDetachWithIME'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_didNotSelectSelf(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_didNotSelectSelf'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->didNotSelectSelf(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "didNotSelectSelf",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_didNotSelectSelf'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_attachWithIME(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_attachWithIME'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->attachWithIME(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "attachWithIME",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_attachWithIME'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setPasswordEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setPasswordEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPasswordEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPasswordEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setPasswordEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setMaxLengthEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setMaxLengthEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMaxLengthEnabled(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaxLengthEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setMaxLengthEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_getDeleteBackward(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_getDeleteBackward'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getDeleteBackward(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDeleteBackward",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_getDeleteBackward'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setFontSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setFontSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setFontSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFontSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setFontSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setPlaceHolder(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setPlaceHolder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPlaceHolder(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPlaceHolder",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setPlaceHolder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_isPasswordEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_isPasswordEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isPasswordEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isPasswordEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_isPasswordEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_getMaxLength(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_getMaxLength'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getMaxLength(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaxLength",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_getMaxLength'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_isMaxLengthEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_isMaxLengthEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isMaxLengthEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isMaxLengthEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_isMaxLengthEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setDetachWithIME(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setDetachWithIME'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDetachWithIME(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDetachWithIME",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setDetachWithIME'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setText(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setText(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setText",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setMaxLength(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setMaxLength'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setMaxLength(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaxLength",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setMaxLength'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setTouchSize(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setTouchSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setTouchSize(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTouchSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setTouchSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_setDeleteBackward(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextField*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextField_setDeleteBackward'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDeleteBackward(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDeleteBackward",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_setDeleteBackward'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::TextField* ret = cocos2d::gui::TextField::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.TextField"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::TextField*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextField_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextField* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::TextField(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.TextField"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.TextField"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TextField",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextField_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_TextField_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TextField)"); return 0; } int lua_register_cocos2dx_gui_TextField(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.TextField"); tolua_cclass(tolua_S,"TextField","ccui.TextField","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"TextField"); tolua_function(tolua_S,"setAttachWithIME",lua_cocos2dx_gui_TextField_setAttachWithIME); tolua_function(tolua_S,"getStringValue",lua_cocos2dx_gui_TextField_getStringValue); tolua_function(tolua_S,"setPasswordStyleText",lua_cocos2dx_gui_TextField_setPasswordStyleText); tolua_function(tolua_S,"getAttachWithIME",lua_cocos2dx_gui_TextField_getAttachWithIME); tolua_function(tolua_S,"setFontName",lua_cocos2dx_gui_TextField_setFontName); tolua_function(tolua_S,"getInsertText",lua_cocos2dx_gui_TextField_getInsertText); tolua_function(tolua_S,"setInsertText",lua_cocos2dx_gui_TextField_setInsertText); tolua_function(tolua_S,"getDetachWithIME",lua_cocos2dx_gui_TextField_getDetachWithIME); tolua_function(tolua_S,"didNotSelectSelf",lua_cocos2dx_gui_TextField_didNotSelectSelf); tolua_function(tolua_S,"attachWithIME",lua_cocos2dx_gui_TextField_attachWithIME); tolua_function(tolua_S,"setPasswordEnabled",lua_cocos2dx_gui_TextField_setPasswordEnabled); tolua_function(tolua_S,"setMaxLengthEnabled",lua_cocos2dx_gui_TextField_setMaxLengthEnabled); tolua_function(tolua_S,"getDeleteBackward",lua_cocos2dx_gui_TextField_getDeleteBackward); tolua_function(tolua_S,"setFontSize",lua_cocos2dx_gui_TextField_setFontSize); tolua_function(tolua_S,"setPlaceHolder",lua_cocos2dx_gui_TextField_setPlaceHolder); tolua_function(tolua_S,"isPasswordEnabled",lua_cocos2dx_gui_TextField_isPasswordEnabled); tolua_function(tolua_S,"getMaxLength",lua_cocos2dx_gui_TextField_getMaxLength); tolua_function(tolua_S,"isMaxLengthEnabled",lua_cocos2dx_gui_TextField_isMaxLengthEnabled); tolua_function(tolua_S,"setDetachWithIME",lua_cocos2dx_gui_TextField_setDetachWithIME); tolua_function(tolua_S,"setText",lua_cocos2dx_gui_TextField_setText); tolua_function(tolua_S,"setMaxLength",lua_cocos2dx_gui_TextField_setMaxLength); tolua_function(tolua_S,"setTouchSize",lua_cocos2dx_gui_TextField_setTouchSize); tolua_function(tolua_S,"setDeleteBackward",lua_cocos2dx_gui_TextField_setDeleteBackward); tolua_function(tolua_S,"new",lua_cocos2dx_gui_TextField_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_TextField_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::TextField).name(); g_luaType[typeName] = "ccui.TextField"; g_typeCast["TextField"] = "ccui.TextField"; return 1; } int lua_cocos2dx_gui_TextBMFont_setFntFile(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextBMFont_setFntFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setFntFile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFntFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextBMFont_setFntFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextBMFont_getStringValue(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextBMFont_getStringValue'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getStringValue(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringValue",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextBMFont_getStringValue'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextBMFont_setText(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.TextBMFont",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::TextBMFont*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_TextBMFont_setText'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setText(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setText",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextBMFont_setText'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextBMFont_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.TextBMFont",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::TextBMFont* ret = cocos2d::gui::TextBMFont::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.TextBMFont"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::TextBMFont*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextBMFont_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_TextBMFont_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::TextBMFont* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::TextBMFont(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.TextBMFont"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.TextBMFont"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TextBMFont",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_TextBMFont_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_TextBMFont_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TextBMFont)"); return 0; } int lua_register_cocos2dx_gui_TextBMFont(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.TextBMFont"); tolua_cclass(tolua_S,"TextBMFont","ccui.TextBMFont","ccui.Widget",NULL); tolua_beginmodule(tolua_S,"TextBMFont"); tolua_function(tolua_S,"setFntFile",lua_cocos2dx_gui_TextBMFont_setFntFile); tolua_function(tolua_S,"getStringValue",lua_cocos2dx_gui_TextBMFont_getStringValue); tolua_function(tolua_S,"setText",lua_cocos2dx_gui_TextBMFont_setText); tolua_function(tolua_S,"new",lua_cocos2dx_gui_TextBMFont_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_TextBMFont_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::TextBMFont).name(); g_luaType[typeName] = "ccui.TextBMFont"; g_typeCast["TextBMFont"] = "ccui.TextBMFont"; return 1; } int lua_cocos2dx_gui_PageView_getCurPageIndex(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_getCurPageIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getCurPageIndex(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurPageIndex",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_getCurPageIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_addWidgetToPage(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_addWidgetToPage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { cocos2d::gui::Widget* arg0; ssize_t arg1; bool arg2; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_ssize(tolua_S, 3, &arg1); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cobj->addWidgetToPage(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addWidgetToPage",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_addWidgetToPage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_getPage(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_getPage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::gui::Layout* ret = cobj->getPage(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Layout"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Layout*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_getPage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_removePage(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_removePage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::Layout* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Layout",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removePage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removePage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_removePage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_insertPage(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_insertPage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::gui::Layout* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Layout",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->insertPage(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "insertPage",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_insertPage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_scrollToPage(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_scrollToPage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->scrollToPage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "scrollToPage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_scrollToPage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_removePageAtIndex(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_removePageAtIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { ssize_t arg0; ok &= luaval_to_ssize(tolua_S, 2, &arg0); if(!ok) return 0; cobj->removePageAtIndex(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removePageAtIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_removePageAtIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_getPages(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_getPages'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Vector& ret = cobj->getPages(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPages",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_getPages'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_removeAllPages(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_removeAllPages'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllPages(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllPages",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_removeAllPages'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_addPage(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::gui::PageView*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_gui_PageView_addPage'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::gui::Layout* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Layout",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Layout*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addPage(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addPage",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_addPage'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::gui::PageView* ret = cocos2d::gui::PageView::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.PageView"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::PageView*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_PageView_constructor(lua_State* tolua_S) { int argc = 0; cocos2d::gui::PageView* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocos2d::gui::PageView(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccui.PageView"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccui.PageView"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "PageView",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_PageView_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_PageView_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PageView)"); return 0; } int lua_register_cocos2dx_gui_PageView(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.PageView"); tolua_cclass(tolua_S,"PageView","ccui.PageView","ccui.Layout",NULL); tolua_beginmodule(tolua_S,"PageView"); tolua_function(tolua_S,"getCurPageIndex",lua_cocos2dx_gui_PageView_getCurPageIndex); tolua_function(tolua_S,"addWidgetToPage",lua_cocos2dx_gui_PageView_addWidgetToPage); tolua_function(tolua_S,"getPage",lua_cocos2dx_gui_PageView_getPage); tolua_function(tolua_S,"removePage",lua_cocos2dx_gui_PageView_removePage); tolua_function(tolua_S,"insertPage",lua_cocos2dx_gui_PageView_insertPage); tolua_function(tolua_S,"scrollToPage",lua_cocos2dx_gui_PageView_scrollToPage); tolua_function(tolua_S,"removePageAtIndex",lua_cocos2dx_gui_PageView_removePageAtIndex); tolua_function(tolua_S,"getPages",lua_cocos2dx_gui_PageView_getPages); tolua_function(tolua_S,"removeAllPages",lua_cocos2dx_gui_PageView_removeAllPages); tolua_function(tolua_S,"addPage",lua_cocos2dx_gui_PageView_addPage); tolua_function(tolua_S,"new",lua_cocos2dx_gui_PageView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_gui_PageView_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::PageView).name(); g_luaType[typeName] = "ccui.PageView"; g_typeCast["PageView"] = "ccui.PageView"; return 1; } int lua_cocos2dx_gui_Helper_seekActionWidgetByActionTag(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Helper",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::gui::Widget* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cocos2d::gui::Widget* ret = cocos2d::gui::Helper::seekActionWidgetByActionTag(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "seekActionWidgetByActionTag",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Helper_seekActionWidgetByActionTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Helper_seekWidgetByTag(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Helper",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::gui::Widget* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cocos2d::gui::Widget* ret = cocos2d::gui::Helper::seekWidgetByTag(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "seekWidgetByTag",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Helper_seekWidgetByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Helper_seekWidgetByRelativeName(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Helper",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::gui::Widget* arg0; const char* arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if(!ok) return 0; cocos2d::gui::Widget* ret = cocos2d::gui::Helper::seekWidgetByRelativeName(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "seekWidgetByRelativeName",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Helper_seekWidgetByRelativeName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_gui_Helper_seekWidgetByName(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccui.Helper",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::gui::Widget* arg0; const char* arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccui.Widget",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::gui::Widget*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if(!ok) return 0; cocos2d::gui::Widget* ret = cocos2d::gui::Helper::seekWidgetByName(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "seekWidgetByName",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_gui_Helper_seekWidgetByName'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_gui_Helper_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Helper)"); return 0; } int lua_register_cocos2dx_gui_Helper(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccui.Helper"); tolua_cclass(tolua_S,"Helper","ccui.Helper","",NULL); tolua_beginmodule(tolua_S,"Helper"); tolua_function(tolua_S,"seekActionWidgetByActionTag", lua_cocos2dx_gui_Helper_seekActionWidgetByActionTag); tolua_function(tolua_S,"seekWidgetByTag", lua_cocos2dx_gui_Helper_seekWidgetByTag); tolua_function(tolua_S,"seekWidgetByRelativeName", lua_cocos2dx_gui_Helper_seekWidgetByRelativeName); tolua_function(tolua_S,"seekWidgetByName", lua_cocos2dx_gui_Helper_seekWidgetByName); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::gui::Helper).name(); g_luaType[typeName] = "ccui.Helper"; g_typeCast["Helper"] = "ccui.Helper"; return 1; } TOLUA_API int register_all_cocos2dx_gui(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,"ccui",0); tolua_beginmodule(tolua_S,"ccui"); lua_register_cocos2dx_gui_Widget(tolua_S); lua_register_cocos2dx_gui_Layout(tolua_S); lua_register_cocos2dx_gui_PageView(tolua_S); lua_register_cocos2dx_gui_CheckBox(tolua_S); lua_register_cocos2dx_gui_Helper(tolua_S); lua_register_cocos2dx_gui_Text(tolua_S); lua_register_cocos2dx_gui_Button(tolua_S); lua_register_cocos2dx_gui_LayoutParameter(tolua_S); lua_register_cocos2dx_gui_LinearLayoutParameter(tolua_S); lua_register_cocos2dx_gui_TextBMFont(tolua_S); lua_register_cocos2dx_gui_ScrollView(tolua_S); lua_register_cocos2dx_gui_LoadingBar(tolua_S); lua_register_cocos2dx_gui_Slider(tolua_S); lua_register_cocos2dx_gui_RelativeLayoutParameter(tolua_S); lua_register_cocos2dx_gui_ImageView(tolua_S); lua_register_cocos2dx_gui_TextAtlas(tolua_S); lua_register_cocos2dx_gui_TextField(tolua_S); lua_register_cocos2dx_gui_ListView(tolua_S); tolua_endmodule(tolua_S); return 1; } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_gui_auto.hpp ================================================ #ifndef __cocos2dx_gui_h__ #define __cocos2dx_gui_h__ #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif int register_all_cocos2dx_gui(lua_State* tolua_S); #endif // __cocos2dx_gui_h__ ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_gui_auto_api.js ================================================ /** * @module cocos2dx_gui */ var ccui = ccui || {}; /** * @class LayoutParameter */ ccui.LayoutParameter = { /** * @method getLayoutType * @return A value converted from C/C++ "cocos2d::gui::LayoutParameterType" */ getLayoutType : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::LayoutParameter*" */ create : function () {}, /** * @method LayoutParameter * @constructor */ LayoutParameter : function () {}, }; /** * @class LinearLayoutParameter */ ccui.LinearLayoutParameter = { /** * @method setGravity * @param {cocos2d::gui::LinearGravity} */ setGravity : function () {}, /** * @method getGravity * @return A value converted from C/C++ "cocos2d::gui::LinearGravity" */ getGravity : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::LinearLayoutParameter*" */ create : function () {}, /** * @method LinearLayoutParameter * @constructor */ LinearLayoutParameter : function () {}, }; /** * @class RelativeLayoutParameter */ ccui.RelativeLayoutParameter = { /** * @method setAlign * @param {cocos2d::gui::RelativeAlign} */ setAlign : function () {}, /** * @method setRelativeToWidgetName * @param {const char*} */ setRelativeToWidgetName : function () {}, /** * @method getRelativeName * @return A value converted from C/C++ "const char*" */ getRelativeName : function () {}, /** * @method getRelativeToWidgetName * @return A value converted from C/C++ "const char*" */ getRelativeToWidgetName : function () {}, /** * @method setRelativeName * @param {const char*} */ setRelativeName : function () {}, /** * @method getAlign * @return A value converted from C/C++ "cocos2d::gui::RelativeAlign" */ getAlign : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::RelativeLayoutParameter*" */ create : function () {}, /** * @method RelativeLayoutParameter * @constructor */ RelativeLayoutParameter : function () {}, }; /** * @class Widget */ ccui.Widget = { /** * @method getVirtualRenderer * @return A value converted from C/C++ "cocos2d::Node*" */ getVirtualRenderer : function () {}, /** * @method setSizePercent * @param {const cocos2d::Point&} */ setSizePercent : function () {}, /** * @method setActionTag * @param {int} */ setActionTag : function () {}, /** * @method getNodeByTag * @return A value converted from C/C++ "cocos2d::Node*" * @param {int} */ getNodeByTag : function () {}, /** * @method isFlipY * @return A value converted from C/C++ "bool" */ isFlipY : function () {}, /** * @method getTouchEndPos * @return A value converted from C/C++ "const cocos2d::Point&" */ getTouchEndPos : function () {}, /** * @method setPositionPercent * @param {const cocos2d::Point&} */ setPositionPercent : function () {}, /** * @method getNodes * @return A value converted from C/C++ "cocos2d::Vector&" */ getNodes : function () {}, /** * @method setPositionType * @param {cocos2d::gui::PositionType} */ setPositionType : function () {}, /** * @method getName * @return A value converted from C/C++ "const char*" */ getName : function () {}, /** * @method isIgnoreContentAdaptWithSize * @return A value converted from C/C++ "bool" */ isIgnoreContentAdaptWithSize : function () {}, /** * @method updateSizeAndPosition */ updateSizeAndPosition : function () {}, /** * @method getBottomInParent * @return A value converted from C/C++ "float" */ getBottomInParent : function () {}, /** * @method getActionTag * @return A value converted from C/C++ "int" */ getActionTag : function () {}, /** * @method getLayoutParameter * @return A value converted from C/C++ "cocos2d::gui::LayoutParameter*" * @param {cocos2d::gui::LayoutParameterType} */ getLayoutParameter : function () {}, /** * @method getPositionType * @return A value converted from C/C++ "cocos2d::gui::PositionType" */ getPositionType : function () {}, /** * @method setName * @param {const char*} */ setName : function () {}, /** * @method getChildByName * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {const char*} */ getChildByName : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method isFlipX * @return A value converted from C/C++ "bool" */ isFlipX : function () {}, /** * @method removeNodeByTag * @param {int} */ removeNodeByTag : function () {}, /** * @method isTouchEnabled * @return A value converted from C/C++ "bool" */ isTouchEnabled : function () {}, /** * @method getContentSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getContentSize : function () {}, /** * @method getTouchStartPos * @return A value converted from C/C++ "const cocos2d::Point&" */ getTouchStartPos : function () {}, /** * @method didNotSelectSelf */ didNotSelectSelf : function () {}, /** * @method setFocused * @param {bool} */ setFocused : function () {}, /** * @method setTouchEnabled * @param {bool} */ setTouchEnabled : function () {}, /** * @method clone * @return A value converted from C/C++ "cocos2d::gui::Widget*" */ clone : function () {}, /** * @method getTouchMovePos * @return A value converted from C/C++ "const cocos2d::Point&" */ getTouchMovePos : function () {}, /** * @method setEnabled * @param {bool} */ setEnabled : function () {}, /** * @method setBrightStyle * @param {cocos2d::gui::BrightStyle} */ setBrightStyle : function () {}, /** * @method setLayoutParameter * @param {cocos2d::gui::LayoutParameter*} */ setLayoutParameter : function () {}, /** * @method setFlipY * @param {bool} */ setFlipY : function () {}, /** * @method setFlipX * @param {bool} */ setFlipX : function () {}, /** * @method getLeftInParent * @return A value converted from C/C++ "float" */ getLeftInParent : function () {}, /** * @method ignoreContentAdaptWithSize * @param {bool} */ ignoreContentAdaptWithSize : function () {}, /** * @method isBright * @return A value converted from C/C++ "bool" */ isBright : function () {}, /** * @method clippingParentAreaContainPoint * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} */ clippingParentAreaContainPoint : function () {}, /** * @method getSizePercent * @return A value converted from C/C++ "const cocos2d::Point&" */ getSizePercent : function () {}, /** * @method getTopInParent * @return A value converted from C/C++ "float" */ getTopInParent : function () {}, /** * @method getWidgetType * @return A value converted from C/C++ "cocos2d::gui::WidgetType" */ getWidgetType : function () {}, /** * @method getSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getSize : function () {}, /** * @method getRightInParent * @return A value converted from C/C++ "float" */ getRightInParent : function () {}, /** * @method getSizeType * @return A value converted from C/C++ "cocos2d::gui::SizeType" */ getSizeType : function () {}, /** * @method removeNode * @param {cocos2d::Node*} */ removeNode : function () {}, /** * @method removeAllNodes */ removeAllNodes : function () {}, /** * @method getWorldPosition * @return A value converted from C/C++ "cocos2d::Point" */ getWorldPosition : function () {}, /** * @method getPositionPercent * @return A value converted from C/C++ "const cocos2d::Point&" */ getPositionPercent : function () {}, /** * @method hitTest * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} */ hitTest : function () {}, /** * @method isFocused * @return A value converted from C/C++ "bool" */ isFocused : function () {}, /** * @method setSizeType * @param {cocos2d::gui::SizeType} */ setSizeType : function () {}, /** * @method checkChildInfo * @param {int} * @param {cocos2d::gui::Widget*} * @param {const cocos2d::Point&} */ checkChildInfo : function () {}, /** * @method setSize * @param {const cocos2d::Size&} */ setSize : function () {}, /** * @method setBright * @param {bool} */ setBright : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Widget*" */ create : function () {}, /** * @method Widget * @constructor */ Widget : function () {}, }; /** * @class Layout */ ccui.Layout = { /** * @method setBackGroundColorVector * @param {const cocos2d::Point&} */ setBackGroundColorVector : function () {}, /** * @method hitTest * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} */ hitTest : function () {}, /** * @method getBackGroundImageTextureSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getBackGroundImageTextureSize : function () {}, /** * @method getLayoutType * @return A value converted from C/C++ "cocos2d::gui::LayoutType" */ getLayoutType : function () {}, /** * @method setClippingType * @param {cocos2d::gui::LayoutClippingType} */ setClippingType : function () {}, /** * @method setBackGroundColorType * @param {cocos2d::gui::LayoutBackGroundColorType} */ setBackGroundColorType : function () {}, /** * @method setBackGroundImage * @param {const char*} * @param {cocos2d::gui::TextureResType} */ setBackGroundImage : function () {}, /** * @method requestDoLayout */ requestDoLayout : function () {}, /** * @method isClippingEnabled * @return A value converted from C/C++ "bool" */ isClippingEnabled : function () {}, /** * @method setBackGroundColorOpacity * @param {int} */ setBackGroundColorOpacity : function () {}, /** * @method setBackGroundImageCapInsets * @param {const cocos2d::Rect&} */ setBackGroundImageCapInsets : function () {}, /** * @method removeBackGroundImage */ removeBackGroundImage : function () {}, /** * @method setBackGroundImageScale9Enabled * @param {bool} */ setBackGroundImageScale9Enabled : function () {}, /** * @method setClippingEnabled * @param {bool} */ setClippingEnabled : function () {}, /** * @method setLayoutType * @param {cocos2d::gui::LayoutType} */ setLayoutType : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Layout*" */ create : function () {}, /** * @method Layout * @constructor */ Layout : function () {}, }; /** * @class Button */ ccui.Button = { /** * @method getTitleText * @return A value converted from C/C++ "const std::string&" */ getTitleText : function () {}, /** * @method loadTextureNormal * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureNormal : function () {}, /** * @method setCapInsetsNormalRenderer * @param {const cocos2d::Rect&} */ setCapInsetsNormalRenderer : function () {}, /** * @method setCapInsetsPressedRenderer * @param {const cocos2d::Rect&} */ setCapInsetsPressedRenderer : function () {}, /** * @method loadTexturePressed * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTexturePressed : function () {}, /** * @method setTitleFontSize * @param {float} */ setTitleFontSize : function () {}, /** * @method setCapInsetsDisabledRenderer * @param {const cocos2d::Rect&} */ setCapInsetsDisabledRenderer : function () {}, /** * @method setTitleFontName * @param {const char*} */ setTitleFontName : function () {}, /** * @method getTitleColor * @return A value converted from C/C++ "const cocos2d::Color3B&" */ getTitleColor : function () {}, /** * @method loadTextureDisabled * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureDisabled : function () {}, /** * @method getTitleFontName * @return A value converted from C/C++ "const char*" */ getTitleFontName : function () {}, /** * @method setPressedActionEnabled * @param {bool} */ setPressedActionEnabled : function () {}, /** * @method setCapInsets * @param {const cocos2d::Rect&} */ setCapInsets : function () {}, /** * @method setScale9Enabled * @param {bool} */ setScale9Enabled : function () {}, /** * @method loadTextures * @param {const char*} * @param {const char*} * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextures : function () {}, /** * @method getTitleFontSize * @return A value converted from C/C++ "float" */ getTitleFontSize : function () {}, /** * @method setTitleText * @param {const std::string&} */ setTitleText : function () {}, /** * @method setTitleColor * @param {const cocos2d::Color3B&} */ setTitleColor : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Button*" */ create : function () {}, /** * @method Button * @constructor */ Button : function () {}, }; /** * @class CheckBox */ ccui.CheckBox = { /** * @method getSelectedState * @return A value converted from C/C++ "bool" */ getSelectedState : function () {}, /** * @method loadTextureBackGroundSelected * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureBackGroundSelected : function () {}, /** * @method loadTextureBackGroundDisabled * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureBackGroundDisabled : function () {}, /** * @method loadTextureFrontCross * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureFrontCross : function () {}, /** * @method loadTextures * @param {const char*} * @param {const char*} * @param {const char*} * @param {const char*} * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextures : function () {}, /** * @method loadTextureBackGround * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureBackGround : function () {}, /** * @method setSelectedState * @param {bool} */ setSelectedState : function () {}, /** * @method loadTextureFrontCrossDisabled * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTextureFrontCrossDisabled : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::CheckBox*" */ create : function () {}, /** * @method CheckBox * @constructor */ CheckBox : function () {}, }; /** * @class ImageView */ ccui.ImageView = { /** * @method setTextureRect * @param {const cocos2d::Rect&} */ setTextureRect : function () {}, /** * @method setCapInsets * @param {const cocos2d::Rect&} */ setCapInsets : function () {}, /** * @method setScale9Enabled * @param {bool} */ setScale9Enabled : function () {}, /** * @method loadTexture * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTexture : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::ImageView*" */ create : function () {}, /** * @method ImageView * @constructor */ ImageView : function () {}, }; /** * @class Text */ ccui.Text = { /** * @method getStringLength * @return A value converted from C/C++ "ssize_t" */ getStringLength : function () {}, /** * @method setFontName * @param {const std::string&} */ setFontName : function () {}, /** * @method setTouchScaleChangeEnabled * @param {bool} */ setTouchScaleChangeEnabled : function () {}, /** * @method getStringValue * @return A value converted from C/C++ "const std::string&" */ getStringValue : function () {}, /** * @method setText * @param {const std::string&} */ setText : function () {}, /** * @method setTextVerticalAlignment * @param {cocos2d::TextVAlignment} */ setTextVerticalAlignment : function () {}, /** * @method setFontSize * @param {int} */ setFontSize : function () {}, /** * @method isTouchScaleChangeEnabled * @return A value converted from C/C++ "bool" */ isTouchScaleChangeEnabled : function () {}, /** * @method setTextHorizontalAlignment * @param {cocos2d::TextHAlignment} */ setTextHorizontalAlignment : function () {}, /** * @method setTextAreaSize * @param {const cocos2d::Size&} */ setTextAreaSize : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Text*" */ create : function () {}, /** * @method Text * @constructor */ Text : function () {}, }; /** * @class TextAtlas */ ccui.TextAtlas = { /** * @method setProperty * @param {const std::string&} * @param {const std::string&} * @param {int} * @param {int} * @param {const std::string&} */ setProperty : function () {}, /** * @method getStringValue * @return A value converted from C/C++ "const std::string&" */ getStringValue : function () {}, /** * @method setStringValue * @param {const std::string&} */ setStringValue : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::TextAtlas*" */ create : function () {}, /** * @method TextAtlas * @constructor */ TextAtlas : function () {}, }; /** * @class LoadingBar */ ccui.LoadingBar = { /** * @method setPercent * @param {int} */ setPercent : function () {}, /** * @method loadTexture * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadTexture : function () {}, /** * @method setDirection * @param {cocos2d::gui::LoadingBarType} */ setDirection : function () {}, /** * @method setScale9Enabled * @param {bool} */ setScale9Enabled : function () {}, /** * @method setCapInsets * @param {const cocos2d::Rect&} */ setCapInsets : function () {}, /** * @method getDirection * @return A value converted from C/C++ "int" */ getDirection : function () {}, /** * @method getPercent * @return A value converted from C/C++ "int" */ getPercent : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::LoadingBar*" */ create : function () {}, /** * @method LoadingBar * @constructor */ LoadingBar : function () {}, }; /** * @class ScrollView */ ccui.ScrollView = { /** * @method scrollToTop * @param {float} * @param {bool} */ scrollToTop : function () {}, /** * @method scrollToPercentHorizontal * @param {float} * @param {float} * @param {bool} */ scrollToPercentHorizontal : function () {}, /** * @method isInertiaScrollEnabled * @return A value converted from C/C++ "bool" */ isInertiaScrollEnabled : function () {}, /** * @method scrollToPercentBothDirection * @param {const cocos2d::Point&} * @param {float} * @param {bool} */ scrollToPercentBothDirection : function () {}, /** * @method getDirection * @return A value converted from C/C++ "cocos2d::gui::SCROLLVIEW_DIR" */ getDirection : function () {}, /** * @method scrollToBottomLeft * @param {float} * @param {bool} */ scrollToBottomLeft : function () {}, /** * @method getInnerContainer * @return A value converted from C/C++ "cocos2d::gui::Layout*" */ getInnerContainer : function () {}, /** * @method jumpToBottom */ jumpToBottom : function () {}, /** * @method setDirection * @param {cocos2d::gui::SCROLLVIEW_DIR} */ setDirection : function () {}, /** * @method scrollToTopLeft * @param {float} * @param {bool} */ scrollToTopLeft : function () {}, /** * @method jumpToTopRight */ jumpToTopRight : function () {}, /** * @method jumpToBottomLeft */ jumpToBottomLeft : function () {}, /** * @method setInnerContainerSize * @param {const cocos2d::Size&} */ setInnerContainerSize : function () {}, /** * @method getInnerContainerSize * @return A value converted from C/C++ "const cocos2d::Size&" */ getInnerContainerSize : function () {}, /** * @method isBounceEnabled * @return A value converted from C/C++ "bool" */ isBounceEnabled : function () {}, /** * @method jumpToPercentVertical * @param {float} */ jumpToPercentVertical : function () {}, /** * @method setInertiaScrollEnabled * @param {bool} */ setInertiaScrollEnabled : function () {}, /** * @method jumpToTopLeft */ jumpToTopLeft : function () {}, /** * @method jumpToPercentHorizontal * @param {float} */ jumpToPercentHorizontal : function () {}, /** * @method jumpToBottomRight */ jumpToBottomRight : function () {}, /** * @method setBounceEnabled * @param {bool} */ setBounceEnabled : function () {}, /** * @method jumpToTop */ jumpToTop : function () {}, /** * @method scrollToLeft * @param {float} * @param {bool} */ scrollToLeft : function () {}, /** * @method jumpToPercentBothDirection * @param {const cocos2d::Point&} */ jumpToPercentBothDirection : function () {}, /** * @method scrollToPercentVertical * @param {float} * @param {float} * @param {bool} */ scrollToPercentVertical : function () {}, /** * @method scrollToBottom * @param {float} * @param {bool} */ scrollToBottom : function () {}, /** * @method scrollToBottomRight * @param {float} * @param {bool} */ scrollToBottomRight : function () {}, /** * @method jumpToLeft */ jumpToLeft : function () {}, /** * @method scrollToRight * @param {float} * @param {bool} */ scrollToRight : function () {}, /** * @method jumpToRight */ jumpToRight : function () {}, /** * @method scrollToTopRight * @param {float} * @param {bool} */ scrollToTopRight : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::ScrollView*" */ create : function () {}, /** * @method ScrollView * @constructor */ ScrollView : function () {}, }; /** * @class ListView */ ccui.ListView = { /** * @method getIndex * @return A value converted from C/C++ "ssize_t" * @param {cocos2d::gui::Widget*} */ getIndex : function () {}, /** * @method removeAllItems */ removeAllItems : function () {}, /** * @method setGravity * @param {cocos2d::gui::ListViewGravity} */ setGravity : function () {}, /** * @method pushBackCustomItem * @param {cocos2d::gui::Widget*} */ pushBackCustomItem : function () {}, /** * @method getItems * @return A value converted from C/C++ "cocos2d::Vector&" */ getItems : function () {}, /** * @method removeItem * @param {ssize_t} */ removeItem : function () {}, /** * @method getCurSelectedIndex * @return A value converted from C/C++ "ssize_t" */ getCurSelectedIndex : function () {}, /** * @method insertDefaultItem * @param {ssize_t} */ insertDefaultItem : function () {}, /** * @method setItemsMargin * @param {float} */ setItemsMargin : function () {}, /** * @method removeLastItem */ removeLastItem : function () {}, /** * @method getItem * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {ssize_t} */ getItem : function () {}, /** * @method setItemModel * @param {cocos2d::gui::Widget*} */ setItemModel : function () {}, /** * @method requestRefreshView */ requestRefreshView : function () {}, /** * @method pushBackDefaultItem */ pushBackDefaultItem : function () {}, /** * @method insertCustomItem * @param {cocos2d::gui::Widget*} * @param {ssize_t} */ insertCustomItem : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::ListView*" */ create : function () {}, /** * @method ListView * @constructor */ ListView : function () {}, }; /** * @class Slider */ ccui.Slider = { /** * @method setPercent * @param {int} */ setPercent : function () {}, /** * @method loadSlidBallTextureNormal * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadSlidBallTextureNormal : function () {}, /** * @method loadBarTexture * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadBarTexture : function () {}, /** * @method loadProgressBarTexture * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadProgressBarTexture : function () {}, /** * @method loadSlidBallTextures * @param {const char*} * @param {const char*} * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadSlidBallTextures : function () {}, /** * @method setCapInsetProgressBarRebderer * @param {const cocos2d::Rect&} */ setCapInsetProgressBarRebderer : function () {}, /** * @method setCapInsetsBarRenderer * @param {const cocos2d::Rect&} */ setCapInsetsBarRenderer : function () {}, /** * @method setScale9Enabled * @param {bool} */ setScale9Enabled : function () {}, /** * @method setCapInsets * @param {const cocos2d::Rect&} */ setCapInsets : function () {}, /** * @method loadSlidBallTexturePressed * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadSlidBallTexturePressed : function () {}, /** * @method loadSlidBallTextureDisabled * @param {const char*} * @param {cocos2d::gui::TextureResType} */ loadSlidBallTextureDisabled : function () {}, /** * @method getPercent * @return A value converted from C/C++ "int" */ getPercent : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::Slider*" */ create : function () {}, /** * @method Slider * @constructor */ Slider : function () {}, }; /** * @class TextField */ ccui.TextField = { /** * @method setAttachWithIME * @param {bool} */ setAttachWithIME : function () {}, /** * @method getStringValue * @return A value converted from C/C++ "const std::string&" */ getStringValue : function () {}, /** * @method setPasswordStyleText * @param {const char*} */ setPasswordStyleText : function () {}, /** * @method getAttachWithIME * @return A value converted from C/C++ "bool" */ getAttachWithIME : function () {}, /** * @method setFontName * @param {const std::string&} */ setFontName : function () {}, /** * @method getInsertText * @return A value converted from C/C++ "bool" */ getInsertText : function () {}, /** * @method setInsertText * @param {bool} */ setInsertText : function () {}, /** * @method getDetachWithIME * @return A value converted from C/C++ "bool" */ getDetachWithIME : function () {}, /** * @method didNotSelectSelf */ didNotSelectSelf : function () {}, /** * @method attachWithIME */ attachWithIME : function () {}, /** * @method setPasswordEnabled * @param {bool} */ setPasswordEnabled : function () {}, /** * @method setMaxLengthEnabled * @param {bool} */ setMaxLengthEnabled : function () {}, /** * @method getDeleteBackward * @return A value converted from C/C++ "bool" */ getDeleteBackward : function () {}, /** * @method setFontSize * @param {int} */ setFontSize : function () {}, /** * @method setPlaceHolder * @param {const std::string&} */ setPlaceHolder : function () {}, /** * @method isPasswordEnabled * @return A value converted from C/C++ "bool" */ isPasswordEnabled : function () {}, /** * @method getMaxLength * @return A value converted from C/C++ "int" */ getMaxLength : function () {}, /** * @method isMaxLengthEnabled * @return A value converted from C/C++ "bool" */ isMaxLengthEnabled : function () {}, /** * @method setDetachWithIME * @param {bool} */ setDetachWithIME : function () {}, /** * @method setText * @param {const std::string&} */ setText : function () {}, /** * @method setMaxLength * @param {int} */ setMaxLength : function () {}, /** * @method setTouchSize * @param {const cocos2d::Size&} */ setTouchSize : function () {}, /** * @method setDeleteBackward * @param {bool} */ setDeleteBackward : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::TextField*" */ create : function () {}, /** * @method TextField * @constructor */ TextField : function () {}, }; /** * @class TextBMFont */ ccui.TextBMFont = { /** * @method setFntFile * @param {const char*} */ setFntFile : function () {}, /** * @method getStringValue * @return A value converted from C/C++ "const char*" */ getStringValue : function () {}, /** * @method setText * @param {const char*} */ setText : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::TextBMFont*" */ create : function () {}, /** * @method TextBMFont * @constructor */ TextBMFont : function () {}, }; /** * @class PageView */ ccui.PageView = { /** * @method getCurPageIndex * @return A value converted from C/C++ "ssize_t" */ getCurPageIndex : function () {}, /** * @method addWidgetToPage * @param {cocos2d::gui::Widget*} * @param {ssize_t} * @param {bool} */ addWidgetToPage : function () {}, /** * @method getPage * @return A value converted from C/C++ "cocos2d::gui::Layout*" * @param {ssize_t} */ getPage : function () {}, /** * @method removePage * @param {cocos2d::gui::Layout*} */ removePage : function () {}, /** * @method insertPage * @param {cocos2d::gui::Layout*} * @param {int} */ insertPage : function () {}, /** * @method scrollToPage * @param {ssize_t} */ scrollToPage : function () {}, /** * @method removePageAtIndex * @param {ssize_t} */ removePageAtIndex : function () {}, /** * @method getPages * @return A value converted from C/C++ "cocos2d::Vector&" */ getPages : function () {}, /** * @method removeAllPages */ removeAllPages : function () {}, /** * @method addPage * @param {cocos2d::gui::Layout*} */ addPage : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::gui::PageView*" */ create : function () {}, /** * @method PageView * @constructor */ PageView : function () {}, }; /** * @class Helper */ ccui.Helper = { /** * @method seekActionWidgetByActionTag * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {cocos2d::gui::Widget*} * @param {int} */ seekActionWidgetByActionTag : function () {}, /** * @method seekWidgetByTag * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {cocos2d::gui::Widget*} * @param {int} */ seekWidgetByTag : function () {}, /** * @method seekWidgetByRelativeName * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {cocos2d::gui::Widget*} * @param {const char*} */ seekWidgetByRelativeName : function () {}, /** * @method seekWidgetByName * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {cocos2d::gui::Widget*} * @param {const char*} */ seekWidgetByName : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_physics_auto.cpp ================================================ #include "lua_cocos2dx_physics_auto.hpp" #include "cocos2d.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" int lua_cocos2dx_physics_PhysicsShape_getFriction(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getFriction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getFriction(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFriction",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getFriction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setGroup(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setGroup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setGroup(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGroup",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setGroup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setDensity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setDensity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDensity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDensity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setDensity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getMass(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getMass'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMass(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMass",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getMass'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getMaterial(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getMaterial'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::PhysicsMaterial& ret = cobj->getMaterial(); physics_material_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaterial",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getMaterial'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getCollisionBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getCollisionBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getCollisionBitmask(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCollisionBitmask",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getCollisionBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getArea(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getArea'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getArea(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getArea",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getArea'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setCategoryBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setCategoryBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setCategoryBitmask(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCategoryBitmask",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setCategoryBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getGroup(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getGroup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getGroup(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGroup",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getGroup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setMoment(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setMoment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMoment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMoment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setMoment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_containsPoint(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_containsPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; bool ret = cobj->containsPoint(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "containsPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_containsPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getCategoryBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getCategoryBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getCategoryBitmask(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCategoryBitmask",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getCategoryBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getType(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getContactTestBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getContactTestBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getContactTestBitmask(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContactTestBitmask",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getContactTestBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getCenter(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getCenter'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getCenter(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCenter",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getCenter'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getDensity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getDensity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDensity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDensity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getDensity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setMass(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setMass'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMass(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMass",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setMass'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getTag(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getTag(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTag",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_calculateDefaultMoment(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_calculateDefaultMoment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->calculateDefaultMoment(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "calculateDefaultMoment",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_calculateDefaultMoment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setCollisionBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setCollisionBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setCollisionBitmask(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCollisionBitmask",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setCollisionBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getMoment(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getMoment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMoment(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMoment",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getMoment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getOffset(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getOffset'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getOffset(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOffset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getOffset'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getRestitution(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getRestitution'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRestitution(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRestitution",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getRestitution'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setFriction(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setFriction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFriction(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFriction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setFriction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setMaterial(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setMaterial'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::PhysicsMaterial arg0; ok &= luaval_to_physics_material(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setMaterial(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaterial",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setMaterial'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setTag(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setTag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setContactTestBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setContactTestBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setContactTestBitmask(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setContactTestBitmask",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setContactTestBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_setRestitution(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_setRestitution'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRestitution(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRestitution",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_setRestitution'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getBody(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShape* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShape_getBody'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsBody* ret = cobj->getBody(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBody",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getBody'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsShape_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsShape)"); return 0; } int lua_register_cocos2dx_physics_PhysicsShape(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsShape"); tolua_cclass(tolua_S,"PhysicsShape","cc.PhysicsShape","cc.Object",NULL); tolua_beginmodule(tolua_S,"PhysicsShape"); tolua_function(tolua_S,"getFriction",lua_cocos2dx_physics_PhysicsShape_getFriction); tolua_function(tolua_S,"setGroup",lua_cocos2dx_physics_PhysicsShape_setGroup); tolua_function(tolua_S,"setDensity",lua_cocos2dx_physics_PhysicsShape_setDensity); tolua_function(tolua_S,"getMass",lua_cocos2dx_physics_PhysicsShape_getMass); tolua_function(tolua_S,"getMaterial",lua_cocos2dx_physics_PhysicsShape_getMaterial); tolua_function(tolua_S,"getCollisionBitmask",lua_cocos2dx_physics_PhysicsShape_getCollisionBitmask); tolua_function(tolua_S,"getArea",lua_cocos2dx_physics_PhysicsShape_getArea); tolua_function(tolua_S,"setCategoryBitmask",lua_cocos2dx_physics_PhysicsShape_setCategoryBitmask); tolua_function(tolua_S,"getGroup",lua_cocos2dx_physics_PhysicsShape_getGroup); tolua_function(tolua_S,"setMoment",lua_cocos2dx_physics_PhysicsShape_setMoment); tolua_function(tolua_S,"containsPoint",lua_cocos2dx_physics_PhysicsShape_containsPoint); tolua_function(tolua_S,"getCategoryBitmask",lua_cocos2dx_physics_PhysicsShape_getCategoryBitmask); tolua_function(tolua_S,"getType",lua_cocos2dx_physics_PhysicsShape_getType); tolua_function(tolua_S,"getContactTestBitmask",lua_cocos2dx_physics_PhysicsShape_getContactTestBitmask); tolua_function(tolua_S,"getCenter",lua_cocos2dx_physics_PhysicsShape_getCenter); tolua_function(tolua_S,"getDensity",lua_cocos2dx_physics_PhysicsShape_getDensity); tolua_function(tolua_S,"setMass",lua_cocos2dx_physics_PhysicsShape_setMass); tolua_function(tolua_S,"getTag",lua_cocos2dx_physics_PhysicsShape_getTag); tolua_function(tolua_S,"calculateDefaultMoment",lua_cocos2dx_physics_PhysicsShape_calculateDefaultMoment); tolua_function(tolua_S,"setCollisionBitmask",lua_cocos2dx_physics_PhysicsShape_setCollisionBitmask); tolua_function(tolua_S,"getMoment",lua_cocos2dx_physics_PhysicsShape_getMoment); tolua_function(tolua_S,"getOffset",lua_cocos2dx_physics_PhysicsShape_getOffset); tolua_function(tolua_S,"getRestitution",lua_cocos2dx_physics_PhysicsShape_getRestitution); tolua_function(tolua_S,"setFriction",lua_cocos2dx_physics_PhysicsShape_setFriction); tolua_function(tolua_S,"setMaterial",lua_cocos2dx_physics_PhysicsShape_setMaterial); tolua_function(tolua_S,"setTag",lua_cocos2dx_physics_PhysicsShape_setTag); tolua_function(tolua_S,"setContactTestBitmask",lua_cocos2dx_physics_PhysicsShape_setContactTestBitmask); tolua_function(tolua_S,"setRestitution",lua_cocos2dx_physics_PhysicsShape_setRestitution); tolua_function(tolua_S,"getBody",lua_cocos2dx_physics_PhysicsShape_getBody); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsShape).name(); g_luaType[typeName] = "cc.PhysicsShape"; g_typeCast["PhysicsShape"] = "cc.PhysicsShape"; return 1; } int lua_cocos2dx_physics_PhysicsShapeCircle_getRadius(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeCircle* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeCircle",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeCircle*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeCircle_getRadius'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRadius(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRadius",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeCircle_getRadius'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeCircle_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeCircle",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::PhysicsShapeCircle* ret = cocos2d::PhysicsShapeCircle::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeCircle"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeCircle*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { double arg0; cocos2d::PhysicsMaterial arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PhysicsShapeCircle* ret = cocos2d::PhysicsShapeCircle::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeCircle"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeCircle*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { double arg0; cocos2d::PhysicsMaterial arg1; cocos2d::Point arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsShapeCircle* ret = cocos2d::PhysicsShapeCircle::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeCircle"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeCircle*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeCircle_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeCircle_calculateArea(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeCircle",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; double ret = cocos2d::PhysicsShapeCircle::calculateArea(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "calculateArea",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeCircle_calculateArea'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeCircle_calculateMoment(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeCircle",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; double arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; double ret = cocos2d::PhysicsShapeCircle::calculateMoment(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 3) { double arg0; double arg1; cocos2d::Point arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; double ret = cocos2d::PhysicsShapeCircle::calculateMoment(arg0, arg1, arg2); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "calculateMoment",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeCircle_calculateMoment'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsShapeCircle_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsShapeCircle)"); return 0; } int lua_register_cocos2dx_physics_PhysicsShapeCircle(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsShapeCircle"); tolua_cclass(tolua_S,"PhysicsShapeCircle","cc.PhysicsShapeCircle","cc.PhysicsShape",NULL); tolua_beginmodule(tolua_S,"PhysicsShapeCircle"); tolua_function(tolua_S,"getRadius",lua_cocos2dx_physics_PhysicsShapeCircle_getRadius); tolua_function(tolua_S,"create", lua_cocos2dx_physics_PhysicsShapeCircle_create); tolua_function(tolua_S,"calculateArea", lua_cocos2dx_physics_PhysicsShapeCircle_calculateArea); tolua_function(tolua_S,"calculateMoment", lua_cocos2dx_physics_PhysicsShapeCircle_calculateMoment); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsShapeCircle).name(); g_luaType[typeName] = "cc.PhysicsShapeCircle"; g_typeCast["PhysicsShapeCircle"] = "cc.PhysicsShapeCircle"; return 1; } int lua_cocos2dx_physics_PhysicsShapeBox_getPointsCount(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeBox_getPointsCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPointsCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPointsCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeBox_getPointsCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeBox_getSize(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeBox_getSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeBox_getSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeBox_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::PhysicsShapeBox* ret = cocos2d::PhysicsShapeBox::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PhysicsShapeBox* ret = cocos2d::PhysicsShapeBox::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; cocos2d::Point arg2; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsShapeBox* ret = cocos2d::PhysicsShapeBox::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeBox_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeBox_calculateArea(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; double ret = cocos2d::PhysicsShapeBox::calculateArea(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "calculateArea",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeBox_calculateArea'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeBox_calculateMoment(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double arg0; cocos2d::Size arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); if(!ok) return 0; double ret = cocos2d::PhysicsShapeBox::calculateMoment(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 3) { double arg0; cocos2d::Size arg1; cocos2d::Point arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_size(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; double ret = cocos2d::PhysicsShapeBox::calculateMoment(arg0, arg1, arg2); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "calculateMoment",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeBox_calculateMoment'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsShapeBox_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsShapeBox)"); return 0; } int lua_register_cocos2dx_physics_PhysicsShapeBox(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsShapeBox"); tolua_cclass(tolua_S,"PhysicsShapeBox","cc.PhysicsShapeBox","cc.PhysicsShape",NULL); tolua_beginmodule(tolua_S,"PhysicsShapeBox"); tolua_function(tolua_S,"getPointsCount",lua_cocos2dx_physics_PhysicsShapeBox_getPointsCount); tolua_function(tolua_S,"getSize",lua_cocos2dx_physics_PhysicsShapeBox_getSize); tolua_function(tolua_S,"create", lua_cocos2dx_physics_PhysicsShapeBox_create); tolua_function(tolua_S,"calculateArea", lua_cocos2dx_physics_PhysicsShapeBox_calculateArea); tolua_function(tolua_S,"calculateMoment", lua_cocos2dx_physics_PhysicsShapeBox_calculateMoment); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsShapeBox).name(); g_luaType[typeName] = "cc.PhysicsShapeBox"; g_typeCast["PhysicsShapeBox"] = "cc.PhysicsShapeBox"; return 1; } int lua_cocos2dx_physics_PhysicsShapePolygon_getPointsCount(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapePolygon* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapePolygon*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapePolygon_getPointsCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPointsCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPointsCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapePolygon_getPointsCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapePolygon_getPoint(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapePolygon* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapePolygon*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapePolygon_getPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Point ret = cobj->getPoint(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapePolygon_getPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapePolygon_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { const cocos2d::Point* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cocos2d::PhysicsShapePolygon* ret = cocos2d::PhysicsShapePolygon::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapePolygon"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapePolygon*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { const cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsShapePolygon* ret = cocos2d::PhysicsShapePolygon::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapePolygon"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapePolygon*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { const cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; cocos2d::Point arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); if(!ok) return 0; cocos2d::PhysicsShapePolygon* ret = cocos2d::PhysicsShapePolygon::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapePolygon"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapePolygon*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapePolygon_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapePolygon_calculateArea(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { const cocos2d::Point* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; double ret = cocos2d::PhysicsShapePolygon::calculateArea(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "calculateArea",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapePolygon_calculateArea'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapePolygon_calculateMoment(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { double arg0; const cocos2d::Point* arg1; int arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Point",0)){ ok = false; break; } if (ok){ arg1 = (const cocos2d::Point*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if(!ok) return 0; double ret = cocos2d::PhysicsShapePolygon::calculateMoment(arg0, arg1, arg2); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 4) { double arg0; const cocos2d::Point* arg1; int arg2; cocos2d::Point arg3; ok &= luaval_to_number(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"cc.Point",0)){ ok = false; break; } if (ok){ arg1 = (const cocos2d::Point*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); if(!ok) return 0; double ret = cocos2d::PhysicsShapePolygon::calculateMoment(arg0, arg1, arg2, arg3); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "calculateMoment",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapePolygon_calculateMoment'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsShapePolygon_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsShapePolygon)"); return 0; } int lua_register_cocos2dx_physics_PhysicsShapePolygon(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsShapePolygon"); tolua_cclass(tolua_S,"PhysicsShapePolygon","cc.PhysicsShapePolygon","cc.PhysicsShape",NULL); tolua_beginmodule(tolua_S,"PhysicsShapePolygon"); tolua_function(tolua_S,"getPointsCount",lua_cocos2dx_physics_PhysicsShapePolygon_getPointsCount); tolua_function(tolua_S,"getPoint",lua_cocos2dx_physics_PhysicsShapePolygon_getPoint); tolua_function(tolua_S,"create", lua_cocos2dx_physics_PhysicsShapePolygon_create); tolua_function(tolua_S,"calculateArea", lua_cocos2dx_physics_PhysicsShapePolygon_calculateArea); tolua_function(tolua_S,"calculateMoment", lua_cocos2dx_physics_PhysicsShapePolygon_calculateMoment); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsShapePolygon).name(); g_luaType[typeName] = "cc.PhysicsShapePolygon"; g_typeCast["PhysicsShapePolygon"] = "cc.PhysicsShapePolygon"; return 1; } int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointB(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgeSegment* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeSegment",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgeSegment*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getPointB(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPointB",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointA(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgeSegment* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeSegment",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgeSegment*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointA'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getPointA(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPointA",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointA'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeEdgeSegment",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::Point arg0; cocos2d::Point arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PhysicsShapeEdgeSegment* ret = cocos2d::PhysicsShapeEdgeSegment::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeSegment"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeSegment*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::PhysicsMaterial arg2; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsShapeEdgeSegment* ret = cocos2d::PhysicsShapeEdgeSegment::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeSegment"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeSegment*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::PhysicsMaterial arg2; double arg3; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::PhysicsShapeEdgeSegment* ret = cocos2d::PhysicsShapeEdgeSegment::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeSegment"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeSegment*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeSegment_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsShapeEdgeSegment_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsShapeEdgeSegment)"); return 0; } int lua_register_cocos2dx_physics_PhysicsShapeEdgeSegment(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsShapeEdgeSegment"); tolua_cclass(tolua_S,"PhysicsShapeEdgeSegment","cc.PhysicsShapeEdgeSegment","cc.PhysicsShape",NULL); tolua_beginmodule(tolua_S,"PhysicsShapeEdgeSegment"); tolua_function(tolua_S,"getPointB",lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointB); tolua_function(tolua_S,"getPointA",lua_cocos2dx_physics_PhysicsShapeEdgeSegment_getPointA); tolua_function(tolua_S,"create", lua_cocos2dx_physics_PhysicsShapeEdgeSegment_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsShapeEdgeSegment).name(); g_luaType[typeName] = "cc.PhysicsShapeEdgeSegment"; g_typeCast["PhysicsShapeEdgeSegment"] = "cc.PhysicsShapeEdgeSegment"; return 1; } int lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPointsCount(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgeBox* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgeBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPointsCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPointsCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPointsCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPointsCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeEdgeBox_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeEdgeBox",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::PhysicsShapeEdgeBox* ret = cocos2d::PhysicsShapeEdgeBox::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PhysicsShapeEdgeBox* ret = cocos2d::PhysicsShapeEdgeBox::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; double arg2; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cocos2d::PhysicsShapeEdgeBox* ret = cocos2d::PhysicsShapeEdgeBox::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; double arg2; cocos2d::Point arg3; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); if(!ok) return 0; cocos2d::PhysicsShapeEdgeBox* ret = cocos2d::PhysicsShapeEdgeBox::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeBox"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeBox*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeBox_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsShapeEdgeBox_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsShapeEdgeBox)"); return 0; } int lua_register_cocos2dx_physics_PhysicsShapeEdgeBox(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsShapeEdgeBox"); tolua_cclass(tolua_S,"PhysicsShapeEdgeBox","cc.PhysicsShapeEdgeBox","cc.PhysicsShape",NULL); tolua_beginmodule(tolua_S,"PhysicsShapeEdgeBox"); tolua_function(tolua_S,"getPointsCount",lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPointsCount); tolua_function(tolua_S,"create", lua_cocos2dx_physics_PhysicsShapeEdgeBox_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsShapeEdgeBox).name(); g_luaType[typeName] = "cc.PhysicsShapeEdgeBox"; g_typeCast["PhysicsShapeEdgeBox"] = "cc.PhysicsShapeEdgeBox"; return 1; } int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPointsCount(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgePolygon* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgePolygon",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgePolygon*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPointsCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPointsCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPointsCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPointsCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeEdgePolygon",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { const cocos2d::Point* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cocos2d::PhysicsShapeEdgePolygon* ret = cocos2d::PhysicsShapeEdgePolygon::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgePolygon"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgePolygon*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { const cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsShapeEdgePolygon* ret = cocos2d::PhysicsShapeEdgePolygon::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgePolygon"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgePolygon*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { const cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; double arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::PhysicsShapeEdgePolygon* ret = cocos2d::PhysicsShapeEdgePolygon::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgePolygon"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgePolygon*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgePolygon_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsShapeEdgePolygon)"); return 0; } int lua_register_cocos2dx_physics_PhysicsShapeEdgePolygon(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsShapeEdgePolygon"); tolua_cclass(tolua_S,"PhysicsShapeEdgePolygon","cc.PhysicsShapeEdgePolygon","cc.PhysicsShape",NULL); tolua_beginmodule(tolua_S,"PhysicsShapeEdgePolygon"); tolua_function(tolua_S,"getPointsCount",lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPointsCount); tolua_function(tolua_S,"create", lua_cocos2dx_physics_PhysicsShapeEdgePolygon_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsShapeEdgePolygon).name(); g_luaType[typeName] = "cc.PhysicsShapeEdgePolygon"; g_typeCast["PhysicsShapeEdgePolygon"] = "cc.PhysicsShapeEdgePolygon"; return 1; } int lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPointsCount(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgeChain* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeChain",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgeChain*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPointsCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getPointsCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPointsCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPointsCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeEdgeChain_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShapeEdgeChain",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { const cocos2d::Point* arg0; int arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cocos2d::PhysicsShapeEdgeChain* ret = cocos2d::PhysicsShapeEdgeChain::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeChain"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeChain*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { const cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsShapeEdgeChain* ret = cocos2d::PhysicsShapeEdgeChain::create(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeChain"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeChain*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { const cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; double arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.Point",0)){ ok = false; break; } if (ok){ arg0 = (const cocos2d::Point*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::PhysicsShapeEdgeChain* ret = cocos2d::PhysicsShapeEdgeChain::create(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShapeEdgeChain"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShapeEdgeChain*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeChain_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsShapeEdgeChain_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsShapeEdgeChain)"); return 0; } int lua_register_cocos2dx_physics_PhysicsShapeEdgeChain(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsShapeEdgeChain"); tolua_cclass(tolua_S,"PhysicsShapeEdgeChain","cc.PhysicsShapeEdgeChain","cc.PhysicsShape",NULL); tolua_beginmodule(tolua_S,"PhysicsShapeEdgeChain"); tolua_function(tolua_S,"getPointsCount",lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPointsCount); tolua_function(tolua_S,"create", lua_cocos2dx_physics_PhysicsShapeEdgeChain_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsShapeEdgeChain).name(); g_luaType[typeName] = "cc.PhysicsShapeEdgeChain"; g_typeCast["PhysicsShapeEdgeChain"] = "cc.PhysicsShapeEdgeChain"; return 1; } int lua_cocos2dx_physics_PhysicsBody_isGravityEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_isGravityEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isGravityEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isGravityEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_isGravityEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_resetForces(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_resetForces'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resetForces(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resetForces",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_resetForces'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getVelocityLimit(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getVelocityLimit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getVelocityLimit(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVelocityLimit",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getVelocityLimit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setGroup(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setGroup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setGroup(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGroup",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setGroup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getMass(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getMass'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMass(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMass",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getMass'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getCollisionBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getCollisionBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getCollisionBitmask(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCollisionBitmask",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getCollisionBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getRotation(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getRotation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRotation(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRotation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getRotation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_isResting(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_isResting'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isResting(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isResting",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_isResting'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_applyImpulse(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_applyImpulse'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Point arg1; ok &= luaval_to_point(tolua_S, 3, &arg1); if (!ok) { break; } cobj->applyImpulse(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if (!ok) { break; } cobj->applyImpulse(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "applyImpulse",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_applyImpulse'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_applyForce(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_applyForce'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if (!ok) { break; } cocos2d::Point arg1; ok &= luaval_to_point(tolua_S, 3, &arg1); if (!ok) { break; } cobj->applyForce(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if (!ok) { break; } cobj->applyForce(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "applyForce",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_applyForce'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_addShape(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_addShape'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::PhysicsShape* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::PhysicsShape* ret = cobj->addShape(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShape*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::PhysicsShape* arg0; bool arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cocos2d::PhysicsShape* ret = cobj->addShape(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShape*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addShape",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_addShape'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_applyTorque(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_applyTorque'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->applyTorque(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "applyTorque",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_applyTorque'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getAngularVelocityLimit(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getAngularVelocityLimit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAngularVelocityLimit(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAngularVelocityLimit",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getAngularVelocityLimit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setAngularVelocityLimit(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setAngularVelocityLimit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAngularVelocityLimit(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAngularVelocityLimit",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setAngularVelocityLimit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getVelocity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getVelocity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getVelocity(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVelocity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getVelocity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getLinearDamping(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getLinearDamping'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getLinearDamping(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLinearDamping",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getLinearDamping'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_removeAllShapes(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_removeAllShapes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllShapes(); return 0; } if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeAllShapes(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllShapes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_removeAllShapes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setAngularDamping(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setAngularDamping'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAngularDamping(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAngularDamping",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setAngularDamping'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setVelocityLimit(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setVelocityLimit'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setVelocityLimit(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVelocityLimit",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setVelocityLimit'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setEnable(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setEnable'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnable(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnable",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setEnable'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setCategoryBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setCategoryBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setCategoryBitmask(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCategoryBitmask",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setCategoryBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getWorld(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getWorld'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsWorld* ret = cobj->getWorld(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsWorld"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsWorld*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWorld",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getWorld'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getAngularVelocity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getAngularVelocity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAngularVelocity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAngularVelocity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getAngularVelocity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getPosition(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getPosition'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getPosition(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getPosition'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setGravityEnable(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setGravityEnable'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setGravityEnable(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGravityEnable",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setGravityEnable'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getGroup(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getGroup'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getGroup(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGroup",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getGroup'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setMoment(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setMoment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMoment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMoment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setMoment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getTag(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getTag(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTag",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_local2World(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_local2World'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->local2World(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "local2World",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_local2World'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getCategoryBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getCategoryBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getCategoryBitmask(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCategoryBitmask",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getCategoryBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getMoment(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getMoment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; double ret = cobj->getMoment(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMoment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getMoment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getFirstShape(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getFirstShape'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsShape* ret = cobj->getFirstShape(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShape*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFirstShape",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getFirstShape'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getShapes(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getShapes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Vector& ret = cobj->getShapes(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShapes",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getShapes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getContactTestBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getContactTestBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getContactTestBitmask(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContactTestBitmask",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getContactTestBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setAngularVelocity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setAngularVelocity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAngularVelocity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAngularVelocity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setAngularVelocity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_world2Local(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_world2Local'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->world2Local(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "world2Local",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_world2Local'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_isEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_isEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_isEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_removeShape(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_removeShape'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } cobj->removeShape(arg0); return 0; } }while(0); ok = true; do{ if (argc == 2) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } cobj->removeShape(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::PhysicsShape* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj->removeShape(arg0); return 0; } }while(0); ok = true; do{ if (argc == 2) { cocos2d::PhysicsShape* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } cobj->removeShape(arg0, arg1); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeShape",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_removeShape'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setMass(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setMass'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMass(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMass",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setMass'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_addMoment(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_addMoment'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addMoment(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addMoment",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_addMoment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setVelocity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setVelocity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setVelocity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVelocity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setVelocity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setLinearDamping(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setLinearDamping'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLinearDamping(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLinearDamping",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setLinearDamping'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setCollisionBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setCollisionBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setCollisionBitmask(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCollisionBitmask",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setCollisionBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setDynamic(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setDynamic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDynamic(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDynamic",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setDynamic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setRotationEnable(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setRotationEnable'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRotationEnable(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRotationEnable",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setRotationEnable'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getAngularDamping(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getAngularDamping'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAngularDamping(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAngularDamping",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getAngularDamping'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getVelocityAtLocalPoint(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getVelocityAtLocalPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->getVelocityAtLocalPoint(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVelocityAtLocalPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getVelocityAtLocalPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_isRotationEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_isRotationEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isRotationEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isRotationEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_isRotationEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_addMass(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_addMass'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->addMass(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addMass",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_addMass'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getShape(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getShape'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::PhysicsShape* ret = cobj->getShape(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShape*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShape",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getShape'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setTag(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setTag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getVelocityAtWorldPoint(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getVelocityAtWorldPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Point ret = cobj->getVelocityAtWorldPoint(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVelocityAtWorldPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getVelocityAtWorldPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_setContactTestBitmask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_setContactTestBitmask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setContactTestBitmask(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setContactTestBitmask",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_setContactTestBitmask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_removeFromWorld(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_removeFromWorld'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeFromWorld(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeFromWorld",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_removeFromWorld'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_isDynamic(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_isDynamic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isDynamic(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isDynamic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_isDynamic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_getNode(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_createBox(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createBox(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createBox(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; cocos2d::Point arg2; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createBox(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createBox",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createBox'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_createEdgeSegment(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::Point arg0; cocos2d::Point arg1; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeSegment(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::PhysicsMaterial arg2; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeSegment(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { cocos2d::Point arg0; cocos2d::Point arg1; cocos2d::PhysicsMaterial arg2; double arg3; ok &= luaval_to_point(tolua_S, 2, &arg0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_physics_material(tolua_S, 4, &arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeSegment(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgeSegment",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createEdgeSegment'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_createEdgeBox(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Size arg0; ok &= luaval_to_size(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeBox(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeBox(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; double arg2; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeBox(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 4) { cocos2d::Size arg0; cocos2d::PhysicsMaterial arg1; double arg2; cocos2d::Point arg3; ok &= luaval_to_size(tolua_S, 2, &arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeBox(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgeBox",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createEdgeBox'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_createCircle(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createCircle(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { double arg0; cocos2d::PhysicsMaterial arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createCircle(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { double arg0; cocos2d::PhysicsMaterial arg1; cocos2d::Point arg2; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_physics_material(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createCircle(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createCircle",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createCircle'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsBody_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsBody)"); return 0; } int lua_register_cocos2dx_physics_PhysicsBody(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsBody"); tolua_cclass(tolua_S,"PhysicsBody","cc.PhysicsBody","cc.Object",NULL); tolua_beginmodule(tolua_S,"PhysicsBody"); tolua_function(tolua_S,"isGravityEnabled",lua_cocos2dx_physics_PhysicsBody_isGravityEnabled); tolua_function(tolua_S,"resetForces",lua_cocos2dx_physics_PhysicsBody_resetForces); tolua_function(tolua_S,"getVelocityLimit",lua_cocos2dx_physics_PhysicsBody_getVelocityLimit); tolua_function(tolua_S,"setGroup",lua_cocos2dx_physics_PhysicsBody_setGroup); tolua_function(tolua_S,"getMass",lua_cocos2dx_physics_PhysicsBody_getMass); tolua_function(tolua_S,"getCollisionBitmask",lua_cocos2dx_physics_PhysicsBody_getCollisionBitmask); tolua_function(tolua_S,"getRotation",lua_cocos2dx_physics_PhysicsBody_getRotation); tolua_function(tolua_S,"isResting",lua_cocos2dx_physics_PhysicsBody_isResting); tolua_function(tolua_S,"applyImpulse",lua_cocos2dx_physics_PhysicsBody_applyImpulse); tolua_function(tolua_S,"applyForce",lua_cocos2dx_physics_PhysicsBody_applyForce); tolua_function(tolua_S,"addShape",lua_cocos2dx_physics_PhysicsBody_addShape); tolua_function(tolua_S,"applyTorque",lua_cocos2dx_physics_PhysicsBody_applyTorque); tolua_function(tolua_S,"getAngularVelocityLimit",lua_cocos2dx_physics_PhysicsBody_getAngularVelocityLimit); tolua_function(tolua_S,"setAngularVelocityLimit",lua_cocos2dx_physics_PhysicsBody_setAngularVelocityLimit); tolua_function(tolua_S,"getVelocity",lua_cocos2dx_physics_PhysicsBody_getVelocity); tolua_function(tolua_S,"getLinearDamping",lua_cocos2dx_physics_PhysicsBody_getLinearDamping); tolua_function(tolua_S,"removeAllShapes",lua_cocos2dx_physics_PhysicsBody_removeAllShapes); tolua_function(tolua_S,"setAngularDamping",lua_cocos2dx_physics_PhysicsBody_setAngularDamping); tolua_function(tolua_S,"setVelocityLimit",lua_cocos2dx_physics_PhysicsBody_setVelocityLimit); tolua_function(tolua_S,"setEnable",lua_cocos2dx_physics_PhysicsBody_setEnable); tolua_function(tolua_S,"setCategoryBitmask",lua_cocos2dx_physics_PhysicsBody_setCategoryBitmask); tolua_function(tolua_S,"getWorld",lua_cocos2dx_physics_PhysicsBody_getWorld); tolua_function(tolua_S,"getAngularVelocity",lua_cocos2dx_physics_PhysicsBody_getAngularVelocity); tolua_function(tolua_S,"getPosition",lua_cocos2dx_physics_PhysicsBody_getPosition); tolua_function(tolua_S,"setGravityEnable",lua_cocos2dx_physics_PhysicsBody_setGravityEnable); tolua_function(tolua_S,"getGroup",lua_cocos2dx_physics_PhysicsBody_getGroup); tolua_function(tolua_S,"setMoment",lua_cocos2dx_physics_PhysicsBody_setMoment); tolua_function(tolua_S,"getTag",lua_cocos2dx_physics_PhysicsBody_getTag); tolua_function(tolua_S,"local2World",lua_cocos2dx_physics_PhysicsBody_local2World); tolua_function(tolua_S,"getCategoryBitmask",lua_cocos2dx_physics_PhysicsBody_getCategoryBitmask); tolua_function(tolua_S,"getMoment",lua_cocos2dx_physics_PhysicsBody_getMoment); tolua_function(tolua_S,"getFirstShape",lua_cocos2dx_physics_PhysicsBody_getFirstShape); tolua_function(tolua_S,"getShapes",lua_cocos2dx_physics_PhysicsBody_getShapes); tolua_function(tolua_S,"getContactTestBitmask",lua_cocos2dx_physics_PhysicsBody_getContactTestBitmask); tolua_function(tolua_S,"setAngularVelocity",lua_cocos2dx_physics_PhysicsBody_setAngularVelocity); tolua_function(tolua_S,"world2Local",lua_cocos2dx_physics_PhysicsBody_world2Local); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_physics_PhysicsBody_isEnabled); tolua_function(tolua_S,"removeShape",lua_cocos2dx_physics_PhysicsBody_removeShape); tolua_function(tolua_S,"setMass",lua_cocos2dx_physics_PhysicsBody_setMass); tolua_function(tolua_S,"addMoment",lua_cocos2dx_physics_PhysicsBody_addMoment); tolua_function(tolua_S,"setVelocity",lua_cocos2dx_physics_PhysicsBody_setVelocity); tolua_function(tolua_S,"setLinearDamping",lua_cocos2dx_physics_PhysicsBody_setLinearDamping); tolua_function(tolua_S,"setCollisionBitmask",lua_cocos2dx_physics_PhysicsBody_setCollisionBitmask); tolua_function(tolua_S,"setDynamic",lua_cocos2dx_physics_PhysicsBody_setDynamic); tolua_function(tolua_S,"setRotationEnable",lua_cocos2dx_physics_PhysicsBody_setRotationEnable); tolua_function(tolua_S,"getAngularDamping",lua_cocos2dx_physics_PhysicsBody_getAngularDamping); tolua_function(tolua_S,"getVelocityAtLocalPoint",lua_cocos2dx_physics_PhysicsBody_getVelocityAtLocalPoint); tolua_function(tolua_S,"isRotationEnabled",lua_cocos2dx_physics_PhysicsBody_isRotationEnabled); tolua_function(tolua_S,"addMass",lua_cocos2dx_physics_PhysicsBody_addMass); tolua_function(tolua_S,"getShape",lua_cocos2dx_physics_PhysicsBody_getShape); tolua_function(tolua_S,"setTag",lua_cocos2dx_physics_PhysicsBody_setTag); tolua_function(tolua_S,"getVelocityAtWorldPoint",lua_cocos2dx_physics_PhysicsBody_getVelocityAtWorldPoint); tolua_function(tolua_S,"setContactTestBitmask",lua_cocos2dx_physics_PhysicsBody_setContactTestBitmask); tolua_function(tolua_S,"removeFromWorld",lua_cocos2dx_physics_PhysicsBody_removeFromWorld); tolua_function(tolua_S,"isDynamic",lua_cocos2dx_physics_PhysicsBody_isDynamic); tolua_function(tolua_S,"getNode",lua_cocos2dx_physics_PhysicsBody_getNode); tolua_function(tolua_S,"createBox", lua_cocos2dx_physics_PhysicsBody_createBox); tolua_function(tolua_S,"createEdgeSegment", lua_cocos2dx_physics_PhysicsBody_createEdgeSegment); tolua_function(tolua_S,"create", lua_cocos2dx_physics_PhysicsBody_create); tolua_function(tolua_S,"createEdgeBox", lua_cocos2dx_physics_PhysicsBody_createEdgeBox); tolua_function(tolua_S,"createCircle", lua_cocos2dx_physics_PhysicsBody_createCircle); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsBody).name(); g_luaType[typeName] = "cc.PhysicsBody"; g_typeCast["PhysicsBody"] = "cc.PhysicsBody"; return 1; } int lua_cocos2dx_physics_PhysicsWorld_getGravity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getGravity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getGravity(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGravity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getGravity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_getAllBodies(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getAllBodies'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Vector& ret = cobj->getAllBodies(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAllBodies",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getAllBodies'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_setGravity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_setGravity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setGravity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGravity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_setGravity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_getSpeed(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getSpeed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSpeed(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSpeed",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getSpeed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_removeBody(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_removeBody'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if (!ok) { break; } cobj->removeBody(arg0); return 0; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::PhysicsBody* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj->removeBody(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeBody",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_removeBody'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_removeJoint(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_removeJoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::PhysicsJoint* arg0; bool arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsJoint",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->removeJoint(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeJoint",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_removeJoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_getUpdateRate(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getUpdateRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getUpdateRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUpdateRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getUpdateRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_setSpeed(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_setSpeed'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSpeed(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSpeed",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_setSpeed'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_getShapes(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getShapes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::Vector ret = cobj->getShapes(arg0); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShapes",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getShapes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_removeAllJoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_removeAllJoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeAllJoints(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllJoints",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_removeAllJoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_getShape(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getShape'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cocos2d::PhysicsShape* ret = cobj->getShape(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShape*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShape",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getShape'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_removeAllBodies(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_removeAllBodies'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeAllBodies(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllBodies",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_removeAllBodies'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_getDebugDrawMask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getDebugDrawMask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getDebugDrawMask(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDebugDrawMask",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getDebugDrawMask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_setDebugDrawMask(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_setDebugDrawMask'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setDebugDrawMask(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDebugDrawMask",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_setDebugDrawMask'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_getBody(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getBody'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::PhysicsBody* ret = cobj->getBody(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBody",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getBody'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_setUpdateRate(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_setUpdateRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setUpdateRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUpdateRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_setUpdateRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_addJoint(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_addJoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::PhysicsJoint* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsJoint",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addJoint(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addJoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_addJoint'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsWorld_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsWorld)"); return 0; } int lua_register_cocos2dx_physics_PhysicsWorld(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsWorld"); tolua_cclass(tolua_S,"PhysicsWorld","cc.PhysicsWorld","",NULL); tolua_beginmodule(tolua_S,"PhysicsWorld"); tolua_function(tolua_S,"getGravity",lua_cocos2dx_physics_PhysicsWorld_getGravity); tolua_function(tolua_S,"getAllBodies",lua_cocos2dx_physics_PhysicsWorld_getAllBodies); tolua_function(tolua_S,"setGravity",lua_cocos2dx_physics_PhysicsWorld_setGravity); tolua_function(tolua_S,"getSpeed",lua_cocos2dx_physics_PhysicsWorld_getSpeed); tolua_function(tolua_S,"removeBody",lua_cocos2dx_physics_PhysicsWorld_removeBody); tolua_function(tolua_S,"removeJoint",lua_cocos2dx_physics_PhysicsWorld_removeJoint); tolua_function(tolua_S,"getUpdateRate",lua_cocos2dx_physics_PhysicsWorld_getUpdateRate); tolua_function(tolua_S,"setSpeed",lua_cocos2dx_physics_PhysicsWorld_setSpeed); tolua_function(tolua_S,"getShapes",lua_cocos2dx_physics_PhysicsWorld_getShapes); tolua_function(tolua_S,"removeAllJoints",lua_cocos2dx_physics_PhysicsWorld_removeAllJoints); tolua_function(tolua_S,"getShape",lua_cocos2dx_physics_PhysicsWorld_getShape); tolua_function(tolua_S,"removeAllBodies",lua_cocos2dx_physics_PhysicsWorld_removeAllBodies); tolua_function(tolua_S,"getDebugDrawMask",lua_cocos2dx_physics_PhysicsWorld_getDebugDrawMask); tolua_function(tolua_S,"setDebugDrawMask",lua_cocos2dx_physics_PhysicsWorld_setDebugDrawMask); tolua_function(tolua_S,"getBody",lua_cocos2dx_physics_PhysicsWorld_getBody); tolua_function(tolua_S,"setUpdateRate",lua_cocos2dx_physics_PhysicsWorld_setUpdateRate); tolua_function(tolua_S,"addJoint",lua_cocos2dx_physics_PhysicsWorld_addJoint); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsWorld).name(); g_luaType[typeName] = "cc.PhysicsWorld"; g_typeCast["PhysicsWorld"] = "cc.PhysicsWorld"; return 1; } static int lua_cocos2dx_physics_PhysicsDebugDraw_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsDebugDraw)"); return 0; } int lua_register_cocos2dx_physics_PhysicsDebugDraw(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsDebugDraw"); tolua_cclass(tolua_S,"PhysicsDebugDraw","cc.PhysicsDebugDraw","",NULL); tolua_beginmodule(tolua_S,"PhysicsDebugDraw"); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsDebugDraw).name(); g_luaType[typeName] = "cc.PhysicsDebugDraw"; g_typeCast["PhysicsDebugDraw"] = "cc.PhysicsDebugDraw"; return 1; } int lua_cocos2dx_physics_PhysicsContact_getContactData(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContact* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContact",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContact*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContact_getContactData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::PhysicsContactData* ret = cobj->getContactData(); physics_contactdata_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContactData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContact_getContactData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContact_getEventCode(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContact* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContact",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContact*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContact_getEventCode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getEventCode(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEventCode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContact_getEventCode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContact_getShapeA(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContact* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContact",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContact*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContact_getShapeA'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsShape* ret = cobj->getShapeA(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShape*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShapeA",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContact_getShapeA'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContact_getShapeB(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContact* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContact",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContact*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContact_getShapeB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsShape* ret = cobj->getShapeB(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsShape*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShapeB",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContact_getShapeB'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsContact_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsContact)"); return 0; } int lua_register_cocos2dx_physics_PhysicsContact(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsContact"); tolua_cclass(tolua_S,"PhysicsContact","cc.PhysicsContact","cc.Event",NULL); tolua_beginmodule(tolua_S,"PhysicsContact"); tolua_function(tolua_S,"getContactData",lua_cocos2dx_physics_PhysicsContact_getContactData); tolua_function(tolua_S,"getEventCode",lua_cocos2dx_physics_PhysicsContact_getEventCode); tolua_function(tolua_S,"getShapeA",lua_cocos2dx_physics_PhysicsContact_getShapeA); tolua_function(tolua_S,"getShapeB",lua_cocos2dx_physics_PhysicsContact_getShapeB); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsContact).name(); g_luaType[typeName] = "cc.PhysicsContact"; g_typeCast["PhysicsContact"] = "cc.PhysicsContact"; return 1; } int lua_cocos2dx_physics_PhysicsContactPreSolve_getFriction(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPreSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPreSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPreSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_getFriction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getFriction(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFriction",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_getFriction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContactPreSolve_getElasticity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPreSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPreSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPreSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_getElasticity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getElasticity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getElasticity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_getElasticity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContactPreSolve_setElasticity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPreSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPreSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPreSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_setElasticity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setElasticity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setElasticity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_setElasticity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContactPreSolve_setFriction(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPreSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPreSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPreSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_setFriction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setFriction(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFriction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_setFriction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContactPreSolve_ignore(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPreSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPreSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPreSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_ignore'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->ignore(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ignore",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_ignore'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContactPreSolve_getSurfaceVelocity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPreSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPreSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPreSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_getSurfaceVelocity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getSurfaceVelocity(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSurfaceVelocity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_getSurfaceVelocity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContactPreSolve_setSurfaceVelocity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPreSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPreSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPreSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_setSurfaceVelocity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setSurfaceVelocity(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSurfaceVelocity",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPreSolve_setSurfaceVelocity'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsContactPreSolve_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsContactPreSolve)"); return 0; } int lua_register_cocos2dx_physics_PhysicsContactPreSolve(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsContactPreSolve"); tolua_cclass(tolua_S,"PhysicsContactPreSolve","cc.PhysicsContactPreSolve","",NULL); tolua_beginmodule(tolua_S,"PhysicsContactPreSolve"); tolua_function(tolua_S,"getFriction",lua_cocos2dx_physics_PhysicsContactPreSolve_getFriction); tolua_function(tolua_S,"getElasticity",lua_cocos2dx_physics_PhysicsContactPreSolve_getElasticity); tolua_function(tolua_S,"setElasticity",lua_cocos2dx_physics_PhysicsContactPreSolve_setElasticity); tolua_function(tolua_S,"setFriction",lua_cocos2dx_physics_PhysicsContactPreSolve_setFriction); tolua_function(tolua_S,"ignore",lua_cocos2dx_physics_PhysicsContactPreSolve_ignore); tolua_function(tolua_S,"getSurfaceVelocity",lua_cocos2dx_physics_PhysicsContactPreSolve_getSurfaceVelocity); tolua_function(tolua_S,"setSurfaceVelocity",lua_cocos2dx_physics_PhysicsContactPreSolve_setSurfaceVelocity); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsContactPreSolve).name(); g_luaType[typeName] = "cc.PhysicsContactPreSolve"; g_typeCast["PhysicsContactPreSolve"] = "cc.PhysicsContactPreSolve"; return 1; } int lua_cocos2dx_physics_PhysicsContactPostSolve_getFriction(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPostSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPostSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPostSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPostSolve_getFriction'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getFriction(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFriction",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPostSolve_getFriction'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContactPostSolve_getSurfaceVelocity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPostSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPostSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPostSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPostSolve_getSurfaceVelocity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getSurfaceVelocity(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSurfaceVelocity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPostSolve_getSurfaceVelocity'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsContactPostSolve_getElasticity(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsContactPostSolve* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsContactPostSolve",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsContactPostSolve*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsContactPostSolve_getElasticity'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getElasticity(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getElasticity",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsContactPostSolve_getElasticity'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsContactPostSolve_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsContactPostSolve)"); return 0; } int lua_register_cocos2dx_physics_PhysicsContactPostSolve(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsContactPostSolve"); tolua_cclass(tolua_S,"PhysicsContactPostSolve","cc.PhysicsContactPostSolve","",NULL); tolua_beginmodule(tolua_S,"PhysicsContactPostSolve"); tolua_function(tolua_S,"getFriction",lua_cocos2dx_physics_PhysicsContactPostSolve_getFriction); tolua_function(tolua_S,"getSurfaceVelocity",lua_cocos2dx_physics_PhysicsContactPostSolve_getSurfaceVelocity); tolua_function(tolua_S,"getElasticity",lua_cocos2dx_physics_PhysicsContactPostSolve_getElasticity); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsContactPostSolve).name(); g_luaType[typeName] = "cc.PhysicsContactPostSolve"; g_typeCast["PhysicsContactPostSolve"] = "cc.PhysicsContactPostSolve"; return 1; } int lua_cocos2dx_physics_EventListenerPhysicsContact_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EventListenerPhysicsContact",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::EventListenerPhysicsContact* ret = cocos2d::EventListenerPhysicsContact::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EventListenerPhysicsContact"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EventListenerPhysicsContact*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_EventListenerPhysicsContact_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_EventListenerPhysicsContact_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerPhysicsContact)"); return 0; } int lua_register_cocos2dx_physics_EventListenerPhysicsContact(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerPhysicsContact"); tolua_cclass(tolua_S,"EventListenerPhysicsContact","cc.EventListenerPhysicsContact","cc.EventListenerCustom",NULL); tolua_beginmodule(tolua_S,"EventListenerPhysicsContact"); tolua_function(tolua_S,"create", lua_cocos2dx_physics_EventListenerPhysicsContact_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerPhysicsContact).name(); g_luaType[typeName] = "cc.EventListenerPhysicsContact"; g_typeCast["EventListenerPhysicsContact"] = "cc.EventListenerPhysicsContact"; return 1; } int lua_cocos2dx_physics_EventListenerPhysicsContactWithBodies_hitTest(lua_State* tolua_S) { int argc = 0; cocos2d::EventListenerPhysicsContactWithBodies* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventListenerPhysicsContactWithBodies",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventListenerPhysicsContactWithBodies*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithBodies_hitTest'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::PhysicsShape* arg0; cocos2d::PhysicsShape* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->hitTest(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hitTest",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithBodies_hitTest'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_EventListenerPhysicsContactWithBodies_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EventListenerPhysicsContactWithBodies",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EventListenerPhysicsContactWithBodies* ret = cocos2d::EventListenerPhysicsContactWithBodies::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EventListenerPhysicsContactWithBodies"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EventListenerPhysicsContactWithBodies*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithBodies_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_EventListenerPhysicsContactWithBodies_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerPhysicsContactWithBodies)"); return 0; } int lua_register_cocos2dx_physics_EventListenerPhysicsContactWithBodies(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerPhysicsContactWithBodies"); tolua_cclass(tolua_S,"EventListenerPhysicsContactWithBodies","cc.EventListenerPhysicsContactWithBodies","cc.EventListenerPhysicsContact",NULL); tolua_beginmodule(tolua_S,"EventListenerPhysicsContactWithBodies"); tolua_function(tolua_S,"hitTest",lua_cocos2dx_physics_EventListenerPhysicsContactWithBodies_hitTest); tolua_function(tolua_S,"create", lua_cocos2dx_physics_EventListenerPhysicsContactWithBodies_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerPhysicsContactWithBodies).name(); g_luaType[typeName] = "cc.EventListenerPhysicsContactWithBodies"; g_typeCast["EventListenerPhysicsContactWithBodies"] = "cc.EventListenerPhysicsContactWithBodies"; return 1; } int lua_cocos2dx_physics_EventListenerPhysicsContactWithShapes_hitTest(lua_State* tolua_S) { int argc = 0; cocos2d::EventListenerPhysicsContactWithShapes* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventListenerPhysicsContactWithShapes",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventListenerPhysicsContactWithShapes*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithShapes_hitTest'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::PhysicsShape* arg0; cocos2d::PhysicsShape* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->hitTest(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hitTest",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithShapes_hitTest'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_EventListenerPhysicsContactWithShapes_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EventListenerPhysicsContactWithShapes",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { cocos2d::PhysicsShape* arg0; cocos2d::PhysicsShape* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::EventListenerPhysicsContactWithShapes* ret = cocos2d::EventListenerPhysicsContactWithShapes::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EventListenerPhysicsContactWithShapes"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EventListenerPhysicsContactWithShapes*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithShapes_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_EventListenerPhysicsContactWithShapes_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerPhysicsContactWithShapes)"); return 0; } int lua_register_cocos2dx_physics_EventListenerPhysicsContactWithShapes(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerPhysicsContactWithShapes"); tolua_cclass(tolua_S,"EventListenerPhysicsContactWithShapes","cc.EventListenerPhysicsContactWithShapes","cc.EventListenerPhysicsContact",NULL); tolua_beginmodule(tolua_S,"EventListenerPhysicsContactWithShapes"); tolua_function(tolua_S,"hitTest",lua_cocos2dx_physics_EventListenerPhysicsContactWithShapes_hitTest); tolua_function(tolua_S,"create", lua_cocos2dx_physics_EventListenerPhysicsContactWithShapes_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerPhysicsContactWithShapes).name(); g_luaType[typeName] = "cc.EventListenerPhysicsContactWithShapes"; g_typeCast["EventListenerPhysicsContactWithShapes"] = "cc.EventListenerPhysicsContactWithShapes"; return 1; } int lua_cocos2dx_physics_EventListenerPhysicsContactWithGroup_hitTest(lua_State* tolua_S) { int argc = 0; cocos2d::EventListenerPhysicsContactWithGroup* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.EventListenerPhysicsContactWithGroup",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::EventListenerPhysicsContactWithGroup*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithGroup_hitTest'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocos2d::PhysicsShape* arg0; cocos2d::PhysicsShape* arg1; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsShape",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsShape*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->hitTest(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "hitTest",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithGroup_hitTest'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_EventListenerPhysicsContactWithGroup_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.EventListenerPhysicsContactWithGroup",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::EventListenerPhysicsContactWithGroup* ret = cocos2d::EventListenerPhysicsContactWithGroup::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.EventListenerPhysicsContactWithGroup"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::EventListenerPhysicsContactWithGroup*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_EventListenerPhysicsContactWithGroup_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_EventListenerPhysicsContactWithGroup_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (EventListenerPhysicsContactWithGroup)"); return 0; } int lua_register_cocos2dx_physics_EventListenerPhysicsContactWithGroup(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.EventListenerPhysicsContactWithGroup"); tolua_cclass(tolua_S,"EventListenerPhysicsContactWithGroup","cc.EventListenerPhysicsContactWithGroup","cc.EventListenerPhysicsContact",NULL); tolua_beginmodule(tolua_S,"EventListenerPhysicsContactWithGroup"); tolua_function(tolua_S,"hitTest",lua_cocos2dx_physics_EventListenerPhysicsContactWithGroup_hitTest); tolua_function(tolua_S,"create", lua_cocos2dx_physics_EventListenerPhysicsContactWithGroup_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventListenerPhysicsContactWithGroup).name(); g_luaType[typeName] = "cc.EventListenerPhysicsContactWithGroup"; g_typeCast["EventListenerPhysicsContactWithGroup"] = "cc.EventListenerPhysicsContactWithGroup"; return 1; } int lua_cocos2dx_physics_PhysicsJoint_getBodyA(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_getBodyA'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsBody* ret = cobj->getBodyA(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBodyA",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_getBodyA'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_getBodyB(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_getBodyB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsBody* ret = cobj->getBodyB(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBodyB",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_getBodyB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_getMaxForce(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_getMaxForce'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMaxForce(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMaxForce",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_getMaxForce'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_setMaxForce(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_setMaxForce'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMaxForce(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMaxForce",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_setMaxForce'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_isEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_isEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_isEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_setEnable(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_setEnable'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEnable(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnable",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_setEnable'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_setCollisionEnable(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_setCollisionEnable'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setCollisionEnable(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCollisionEnable",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_setCollisionEnable'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_getWorld(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_getWorld'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::PhysicsWorld* ret = cobj->getWorld(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsWorld"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsWorld*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWorld",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_getWorld'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_setTag(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_setTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->setTag(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_setTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_removeFormWorld(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_removeFormWorld'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->removeFormWorld(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeFormWorld",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_removeFormWorld'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_isCollisionEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_isCollisionEnabled'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isCollisionEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isCollisionEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_isCollisionEnabled'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_getTag(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJoint* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJoint_getTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getTag(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTag",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_getTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJoint_destroy(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJoint",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::PhysicsJoint* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsJoint",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsJoint*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocos2d::PhysicsJoint::destroy(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroy",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJoint_destroy'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJoint_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJoint)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJoint(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJoint"); tolua_cclass(tolua_S,"PhysicsJoint","cc.PhysicsJoint","",NULL); tolua_beginmodule(tolua_S,"PhysicsJoint"); tolua_function(tolua_S,"getBodyA",lua_cocos2dx_physics_PhysicsJoint_getBodyA); tolua_function(tolua_S,"getBodyB",lua_cocos2dx_physics_PhysicsJoint_getBodyB); tolua_function(tolua_S,"getMaxForce",lua_cocos2dx_physics_PhysicsJoint_getMaxForce); tolua_function(tolua_S,"setMaxForce",lua_cocos2dx_physics_PhysicsJoint_setMaxForce); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_physics_PhysicsJoint_isEnabled); tolua_function(tolua_S,"setEnable",lua_cocos2dx_physics_PhysicsJoint_setEnable); tolua_function(tolua_S,"setCollisionEnable",lua_cocos2dx_physics_PhysicsJoint_setCollisionEnable); tolua_function(tolua_S,"getWorld",lua_cocos2dx_physics_PhysicsJoint_getWorld); tolua_function(tolua_S,"setTag",lua_cocos2dx_physics_PhysicsJoint_setTag); tolua_function(tolua_S,"removeFormWorld",lua_cocos2dx_physics_PhysicsJoint_removeFormWorld); tolua_function(tolua_S,"isCollisionEnabled",lua_cocos2dx_physics_PhysicsJoint_isCollisionEnabled); tolua_function(tolua_S,"getTag",lua_cocos2dx_physics_PhysicsJoint_getTag); tolua_function(tolua_S,"destroy", lua_cocos2dx_physics_PhysicsJoint_destroy); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJoint).name(); g_luaType[typeName] = "cc.PhysicsJoint"; g_typeCast["PhysicsJoint"] = "cc.PhysicsJoint"; return 1; } int lua_cocos2dx_physics_PhysicsJointFixed_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointFixed",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; cocos2d::Point arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsJointFixed* ret = cocos2d::PhysicsJointFixed::construct(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointFixed"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointFixed*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointFixed_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointFixed_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointFixed)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointFixed(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointFixed"); tolua_cclass(tolua_S,"PhysicsJointFixed","cc.PhysicsJointFixed","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointFixed"); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointFixed_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointFixed).name(); g_luaType[typeName] = "cc.PhysicsJointFixed"; g_typeCast["PhysicsJointFixed"] = "cc.PhysicsJointFixed"; return 1; } int lua_cocos2dx_physics_PhysicsJointLimit_setAnchr2(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointLimit_setAnchr2'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setAnchr2(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnchr2",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_setAnchr2'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointLimit_setAnchr1(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointLimit_setAnchr1'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setAnchr1(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnchr1",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_setAnchr1'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointLimit_setMax(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointLimit_setMax'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMax(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMax",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_setMax'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointLimit_getAnchr2(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointLimit_getAnchr2'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getAnchr2(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchr2",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_getAnchr2'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointLimit_getAnchr1(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointLimit_getAnchr1'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getAnchr1(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchr1",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_getAnchr1'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointLimit_getMin(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointLimit_getMin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMin(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_getMin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointLimit_getMax(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointLimit_getMax'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMax(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMax",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_getMax'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointLimit_setMin(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointLimit_setMin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMin(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_setMin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointLimit_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointLimit",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 6) { cocos2d::PhysicsBody* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::PhysicsBody* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Point arg2; ok &= luaval_to_point(tolua_S, 4, &arg2); if (!ok) { break; } cocos2d::Point arg3; ok &= luaval_to_point(tolua_S, 5, &arg3); if (!ok) { break; } double arg4; ok &= luaval_to_number(tolua_S, 6,&arg4); if (!ok) { break; } double arg5; ok &= luaval_to_number(tolua_S, 7,&arg5); if (!ok) { break; } cocos2d::PhysicsJointLimit* ret = cocos2d::PhysicsJointLimit::construct(arg0, arg1, arg2, arg3, arg4, arg5); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointLimit"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointLimit*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 4) { cocos2d::PhysicsBody* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::PhysicsBody* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::Point arg2; ok &= luaval_to_point(tolua_S, 4, &arg2); if (!ok) { break; } cocos2d::Point arg3; ok &= luaval_to_point(tolua_S, 5, &arg3); if (!ok) { break; } cocos2d::PhysicsJointLimit* ret = cocos2d::PhysicsJointLimit::construct(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointLimit"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointLimit*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "construct",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointLimit_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointLimit_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointLimit)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointLimit(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointLimit"); tolua_cclass(tolua_S,"PhysicsJointLimit","cc.PhysicsJointLimit","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointLimit"); tolua_function(tolua_S,"setAnchr2",lua_cocos2dx_physics_PhysicsJointLimit_setAnchr2); tolua_function(tolua_S,"setAnchr1",lua_cocos2dx_physics_PhysicsJointLimit_setAnchr1); tolua_function(tolua_S,"setMax",lua_cocos2dx_physics_PhysicsJointLimit_setMax); tolua_function(tolua_S,"getAnchr2",lua_cocos2dx_physics_PhysicsJointLimit_getAnchr2); tolua_function(tolua_S,"getAnchr1",lua_cocos2dx_physics_PhysicsJointLimit_getAnchr1); tolua_function(tolua_S,"getMin",lua_cocos2dx_physics_PhysicsJointLimit_getMin); tolua_function(tolua_S,"getMax",lua_cocos2dx_physics_PhysicsJointLimit_getMax); tolua_function(tolua_S,"setMin",lua_cocos2dx_physics_PhysicsJointLimit_setMin); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointLimit_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointLimit).name(); g_luaType[typeName] = "cc.PhysicsJointLimit"; g_typeCast["PhysicsJointLimit"] = "cc.PhysicsJointLimit"; return 1; } int lua_cocos2dx_physics_PhysicsJointPin_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointPin",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; cocos2d::Point arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; cocos2d::PhysicsJointPin* ret = cocos2d::PhysicsJointPin::construct(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointPin"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointPin*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointPin_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointPin_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointPin)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointPin(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointPin"); tolua_cclass(tolua_S,"PhysicsJointPin","cc.PhysicsJointPin","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointPin"); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointPin_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointPin).name(); g_luaType[typeName] = "cc.PhysicsJointPin"; g_typeCast["PhysicsJointPin"] = "cc.PhysicsJointPin"; return 1; } int lua_cocos2dx_physics_PhysicsJointDistance_setDistance(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointDistance* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointDistance",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointDistance*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointDistance_setDistance'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDistance(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDistance",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointDistance_setDistance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointDistance_getDistance(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointDistance* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointDistance",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointDistance*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointDistance_getDistance'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDistance(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDistance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointDistance_getDistance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointDistance_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointDistance",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; cocos2d::Point arg2; cocos2d::Point arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); if(!ok) return 0; cocos2d::PhysicsJointDistance* ret = cocos2d::PhysicsJointDistance::construct(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointDistance"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointDistance*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointDistance_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointDistance_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointDistance)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointDistance(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointDistance"); tolua_cclass(tolua_S,"PhysicsJointDistance","cc.PhysicsJointDistance","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointDistance"); tolua_function(tolua_S,"setDistance",lua_cocos2dx_physics_PhysicsJointDistance_setDistance); tolua_function(tolua_S,"getDistance",lua_cocos2dx_physics_PhysicsJointDistance_getDistance); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointDistance_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointDistance).name(); g_luaType[typeName] = "cc.PhysicsJointDistance"; g_typeCast["PhysicsJointDistance"] = "cc.PhysicsJointDistance"; return 1; } int lua_cocos2dx_physics_PhysicsJointSpring_setAnchr2(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_setAnchr2'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setAnchr2(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnchr2",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_setAnchr2'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_setAnchr1(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_setAnchr1'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setAnchr1(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnchr1",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_setAnchr1'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_getDamping(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_getDamping'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDamping(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDamping",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_getDamping'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_setStiffness(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_setStiffness'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStiffness(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStiffness",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_setStiffness'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_getRestLength(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_getRestLength'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRestLength(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRestLength",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_getRestLength'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_getAnchr2(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_getAnchr2'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getAnchr2(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchr2",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_getAnchr2'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_getAnchr1(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_getAnchr1'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getAnchr1(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchr1",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_getAnchr1'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_getStiffness(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_getStiffness'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getStiffness(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStiffness",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_getStiffness'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_setRestLength(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_setRestLength'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRestLength(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRestLength",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_setRestLength'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_setDamping(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointSpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointSpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointSpring_setDamping'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDamping(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDamping",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_setDamping'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointSpring_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointSpring",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 6) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; cocos2d::Point arg2; cocos2d::Point arg3; double arg4; double arg5; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); ok &= luaval_to_number(tolua_S, 6,&arg4); ok &= luaval_to_number(tolua_S, 7,&arg5); if(!ok) return 0; cocos2d::PhysicsJointSpring* ret = cocos2d::PhysicsJointSpring::construct(arg0, arg1, arg2, arg3, arg4, arg5); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointSpring"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointSpring*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 6); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointSpring_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointSpring_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointSpring)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointSpring(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointSpring"); tolua_cclass(tolua_S,"PhysicsJointSpring","cc.PhysicsJointSpring","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointSpring"); tolua_function(tolua_S,"setAnchr2",lua_cocos2dx_physics_PhysicsJointSpring_setAnchr2); tolua_function(tolua_S,"setAnchr1",lua_cocos2dx_physics_PhysicsJointSpring_setAnchr1); tolua_function(tolua_S,"getDamping",lua_cocos2dx_physics_PhysicsJointSpring_getDamping); tolua_function(tolua_S,"setStiffness",lua_cocos2dx_physics_PhysicsJointSpring_setStiffness); tolua_function(tolua_S,"getRestLength",lua_cocos2dx_physics_PhysicsJointSpring_getRestLength); tolua_function(tolua_S,"getAnchr2",lua_cocos2dx_physics_PhysicsJointSpring_getAnchr2); tolua_function(tolua_S,"getAnchr1",lua_cocos2dx_physics_PhysicsJointSpring_getAnchr1); tolua_function(tolua_S,"getStiffness",lua_cocos2dx_physics_PhysicsJointSpring_getStiffness); tolua_function(tolua_S,"setRestLength",lua_cocos2dx_physics_PhysicsJointSpring_setRestLength); tolua_function(tolua_S,"setDamping",lua_cocos2dx_physics_PhysicsJointSpring_setDamping); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointSpring_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointSpring).name(); g_luaType[typeName] = "cc.PhysicsJointSpring"; g_typeCast["PhysicsJointSpring"] = "cc.PhysicsJointSpring"; return 1; } int lua_cocos2dx_physics_PhysicsJointGroove_setAnchr2(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGroove* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGroove",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGroove*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGroove_setAnchr2'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setAnchr2(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnchr2",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGroove_setAnchr2'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGroove_setGrooveA(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGroove* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGroove",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGroove*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGroove_setGrooveA'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setGrooveA(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGrooveA",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGroove_setGrooveA'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGroove_setGrooveB(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGroove* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGroove",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGroove*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGroove_setGrooveB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setGrooveB(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGrooveB",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGroove_setGrooveB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGroove_getGrooveA(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGroove* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGroove",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGroove*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGroove_getGrooveA'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getGrooveA(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGrooveA",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGroove_getGrooveA'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGroove_getGrooveB(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGroove* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGroove",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGroove*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGroove_getGrooveB'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getGrooveB(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGrooveB",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGroove_getGrooveB'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGroove_getAnchr2(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGroove* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGroove",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGroove*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGroove_getAnchr2'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getAnchr2(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchr2",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGroove_getAnchr2'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGroove_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointGroove",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 5) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; cocos2d::Point arg2; cocos2d::Point arg3; cocos2d::Point arg4; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_point(tolua_S, 4, &arg2); ok &= luaval_to_point(tolua_S, 5, &arg3); ok &= luaval_to_point(tolua_S, 6, &arg4); if(!ok) return 0; cocos2d::PhysicsJointGroove* ret = cocos2d::PhysicsJointGroove::construct(arg0, arg1, arg2, arg3, arg4); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointGroove"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointGroove*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGroove_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointGroove_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointGroove)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointGroove(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointGroove"); tolua_cclass(tolua_S,"PhysicsJointGroove","cc.PhysicsJointGroove","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointGroove"); tolua_function(tolua_S,"setAnchr2",lua_cocos2dx_physics_PhysicsJointGroove_setAnchr2); tolua_function(tolua_S,"setGrooveA",lua_cocos2dx_physics_PhysicsJointGroove_setGrooveA); tolua_function(tolua_S,"setGrooveB",lua_cocos2dx_physics_PhysicsJointGroove_setGrooveB); tolua_function(tolua_S,"getGrooveA",lua_cocos2dx_physics_PhysicsJointGroove_getGrooveA); tolua_function(tolua_S,"getGrooveB",lua_cocos2dx_physics_PhysicsJointGroove_getGrooveB); tolua_function(tolua_S,"getAnchr2",lua_cocos2dx_physics_PhysicsJointGroove_getAnchr2); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointGroove_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointGroove).name(); g_luaType[typeName] = "cc.PhysicsJointGroove"; g_typeCast["PhysicsJointGroove"] = "cc.PhysicsJointGroove"; return 1; } int lua_cocos2dx_physics_PhysicsJointRotarySpring_getDamping(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotarySpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotarySpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotarySpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_getDamping'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getDamping(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDamping",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_getDamping'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotarySpring_setRestAngle(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotarySpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotarySpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotarySpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_setRestAngle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRestAngle(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRestAngle",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_setRestAngle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotarySpring_getStiffness(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotarySpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotarySpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotarySpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_getStiffness'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getStiffness(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStiffness",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_getStiffness'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotarySpring_setStiffness(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotarySpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotarySpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotarySpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_setStiffness'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setStiffness(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setStiffness",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_setStiffness'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotarySpring_setDamping(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotarySpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotarySpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotarySpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_setDamping'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setDamping(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setDamping",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_setDamping'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotarySpring_getRestAngle(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotarySpring* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotarySpring",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotarySpring*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_getRestAngle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRestAngle(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRestAngle",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_getRestAngle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotarySpring_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointRotarySpring",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; double arg2; double arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::PhysicsJointRotarySpring* ret = cocos2d::PhysicsJointRotarySpring::construct(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointRotarySpring"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointRotarySpring*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotarySpring_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointRotarySpring_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointRotarySpring)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointRotarySpring(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointRotarySpring"); tolua_cclass(tolua_S,"PhysicsJointRotarySpring","cc.PhysicsJointRotarySpring","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointRotarySpring"); tolua_function(tolua_S,"getDamping",lua_cocos2dx_physics_PhysicsJointRotarySpring_getDamping); tolua_function(tolua_S,"setRestAngle",lua_cocos2dx_physics_PhysicsJointRotarySpring_setRestAngle); tolua_function(tolua_S,"getStiffness",lua_cocos2dx_physics_PhysicsJointRotarySpring_getStiffness); tolua_function(tolua_S,"setStiffness",lua_cocos2dx_physics_PhysicsJointRotarySpring_setStiffness); tolua_function(tolua_S,"setDamping",lua_cocos2dx_physics_PhysicsJointRotarySpring_setDamping); tolua_function(tolua_S,"getRestAngle",lua_cocos2dx_physics_PhysicsJointRotarySpring_getRestAngle); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointRotarySpring_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointRotarySpring).name(); g_luaType[typeName] = "cc.PhysicsJointRotarySpring"; g_typeCast["PhysicsJointRotarySpring"] = "cc.PhysicsJointRotarySpring"; return 1; } int lua_cocos2dx_physics_PhysicsJointRotaryLimit_getMax(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotaryLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotaryLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotaryLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_getMax'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMax(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMax",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_getMax'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotaryLimit_setMin(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotaryLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotaryLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotaryLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_setMin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMin(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_setMin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotaryLimit_setMax(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotaryLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotaryLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotaryLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_setMax'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setMax(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMax",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_setMax'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotaryLimit_getMin(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRotaryLimit* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRotaryLimit",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRotaryLimit*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_getMin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getMin(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_getMin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRotaryLimit_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointRotaryLimit",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { cocos2d::PhysicsBody* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::PhysicsBody* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::PhysicsJointRotaryLimit* ret = cocos2d::PhysicsJointRotaryLimit::construct(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointRotaryLimit"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointRotaryLimit*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 4) { cocos2d::PhysicsBody* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocos2d::PhysicsBody* arg1; do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } double arg2; ok &= luaval_to_number(tolua_S, 4,&arg2); if (!ok) { break; } double arg3; ok &= luaval_to_number(tolua_S, 5,&arg3); if (!ok) { break; } cocos2d::PhysicsJointRotaryLimit* ret = cocos2d::PhysicsJointRotaryLimit::construct(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointRotaryLimit"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointRotaryLimit*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "construct",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRotaryLimit_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointRotaryLimit_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointRotaryLimit)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointRotaryLimit(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointRotaryLimit"); tolua_cclass(tolua_S,"PhysicsJointRotaryLimit","cc.PhysicsJointRotaryLimit","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointRotaryLimit"); tolua_function(tolua_S,"getMax",lua_cocos2dx_physics_PhysicsJointRotaryLimit_getMax); tolua_function(tolua_S,"setMin",lua_cocos2dx_physics_PhysicsJointRotaryLimit_setMin); tolua_function(tolua_S,"setMax",lua_cocos2dx_physics_PhysicsJointRotaryLimit_setMax); tolua_function(tolua_S,"getMin",lua_cocos2dx_physics_PhysicsJointRotaryLimit_getMin); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointRotaryLimit_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointRotaryLimit).name(); g_luaType[typeName] = "cc.PhysicsJointRotaryLimit"; g_typeCast["PhysicsJointRotaryLimit"] = "cc.PhysicsJointRotaryLimit"; return 1; } int lua_cocos2dx_physics_PhysicsJointRatchet_getAngle(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRatchet* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRatchet",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRatchet*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRatchet_getAngle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getAngle(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAngle",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRatchet_getAngle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRatchet_setAngle(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRatchet* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRatchet",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRatchet*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRatchet_setAngle'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setAngle(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAngle",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRatchet_setAngle'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRatchet_setPhase(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRatchet* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRatchet",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRatchet*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRatchet_setPhase'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPhase(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPhase",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRatchet_setPhase'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRatchet_getPhase(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRatchet* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRatchet",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRatchet*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRatchet_getPhase'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getPhase(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPhase",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRatchet_getPhase'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRatchet_setRatchet(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRatchet* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRatchet",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRatchet*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRatchet_setRatchet'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRatchet(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRatchet",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRatchet_setRatchet'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRatchet_getRatchet(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointRatchet* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointRatchet",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointRatchet*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointRatchet_getRatchet'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRatchet(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRatchet",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRatchet_getRatchet'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointRatchet_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointRatchet",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; double arg2; double arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::PhysicsJointRatchet* ret = cocos2d::PhysicsJointRatchet::construct(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointRatchet"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointRatchet*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointRatchet_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointRatchet_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointRatchet)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointRatchet(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointRatchet"); tolua_cclass(tolua_S,"PhysicsJointRatchet","cc.PhysicsJointRatchet","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointRatchet"); tolua_function(tolua_S,"getAngle",lua_cocos2dx_physics_PhysicsJointRatchet_getAngle); tolua_function(tolua_S,"setAngle",lua_cocos2dx_physics_PhysicsJointRatchet_setAngle); tolua_function(tolua_S,"setPhase",lua_cocos2dx_physics_PhysicsJointRatchet_setPhase); tolua_function(tolua_S,"getPhase",lua_cocos2dx_physics_PhysicsJointRatchet_getPhase); tolua_function(tolua_S,"setRatchet",lua_cocos2dx_physics_PhysicsJointRatchet_setRatchet); tolua_function(tolua_S,"getRatchet",lua_cocos2dx_physics_PhysicsJointRatchet_getRatchet); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointRatchet_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointRatchet).name(); g_luaType[typeName] = "cc.PhysicsJointRatchet"; g_typeCast["PhysicsJointRatchet"] = "cc.PhysicsJointRatchet"; return 1; } int lua_cocos2dx_physics_PhysicsJointGear_setRatio(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGear* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGear",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGear*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGear_setRatio'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRatio(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRatio",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGear_setRatio'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGear_getPhase(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGear* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGear",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGear*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGear_getPhase'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getPhase(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPhase",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGear_getPhase'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGear_setPhase(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGear* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGear",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGear*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGear_setPhase'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setPhase(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPhase",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGear_setPhase'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGear_getRatio(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointGear* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointGear",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointGear*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointGear_getRatio'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRatio(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRatio",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGear_getRatio'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointGear_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointGear",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 4) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; double arg2; double arg3; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; cocos2d::PhysicsJointGear* ret = cocos2d::PhysicsJointGear::construct(arg0, arg1, arg2, arg3); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointGear"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointGear*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointGear_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointGear_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointGear)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointGear(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointGear"); tolua_cclass(tolua_S,"PhysicsJointGear","cc.PhysicsJointGear","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointGear"); tolua_function(tolua_S,"setRatio",lua_cocos2dx_physics_PhysicsJointGear_setRatio); tolua_function(tolua_S,"getPhase",lua_cocos2dx_physics_PhysicsJointGear_getPhase); tolua_function(tolua_S,"setPhase",lua_cocos2dx_physics_PhysicsJointGear_setPhase); tolua_function(tolua_S,"getRatio",lua_cocos2dx_physics_PhysicsJointGear_getRatio); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointGear_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointGear).name(); g_luaType[typeName] = "cc.PhysicsJointGear"; g_typeCast["PhysicsJointGear"] = "cc.PhysicsJointGear"; return 1; } int lua_cocos2dx_physics_PhysicsJointMotor_setRate(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointMotor* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointMotor",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointMotor*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointMotor_setRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setRate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setRate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointMotor_setRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointMotor_getRate(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsJointMotor* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsJointMotor",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsJointMotor*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsJointMotor_getRate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getRate(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getRate",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointMotor_getRate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsJointMotor_construct(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsJointMotor",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { cocos2d::PhysicsBody* arg0; cocos2d::PhysicsBody* arg1; double arg2; do { if (!luaval_is_usertype(tolua_S,2,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); do { if (!luaval_is_usertype(tolua_S,3,"cc.PhysicsBody",0)){ ok = false; break; } if (ok){ arg1 = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cocos2d::PhysicsJointMotor* ret = cocos2d::PhysicsJointMotor::construct(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsJointMotor"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsJointMotor*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "construct",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsJointMotor_construct'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_physics_PhysicsJointMotor_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (PhysicsJointMotor)"); return 0; } int lua_register_cocos2dx_physics_PhysicsJointMotor(lua_State* tolua_S) { tolua_usertype(tolua_S,"cc.PhysicsJointMotor"); tolua_cclass(tolua_S,"PhysicsJointMotor","cc.PhysicsJointMotor","cc.PhysicsJoint",NULL); tolua_beginmodule(tolua_S,"PhysicsJointMotor"); tolua_function(tolua_S,"setRate",lua_cocos2dx_physics_PhysicsJointMotor_setRate); tolua_function(tolua_S,"getRate",lua_cocos2dx_physics_PhysicsJointMotor_getRate); tolua_function(tolua_S,"construct", lua_cocos2dx_physics_PhysicsJointMotor_construct); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::PhysicsJointMotor).name(); g_luaType[typeName] = "cc.PhysicsJointMotor"; g_typeCast["PhysicsJointMotor"] = "cc.PhysicsJointMotor"; return 1; } TOLUA_API int register_all_cocos2dx_physics(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,"cc",0); tolua_beginmodule(tolua_S,"cc"); lua_register_cocos2dx_physics_PhysicsBody(tolua_S); lua_register_cocos2dx_physics_PhysicsWorld(tolua_S); lua_register_cocos2dx_physics_PhysicsJoint(tolua_S); lua_register_cocos2dx_physics_PhysicsJointLimit(tolua_S); lua_register_cocos2dx_physics_PhysicsJointFixed(tolua_S); lua_register_cocos2dx_physics_EventListenerPhysicsContact(tolua_S); lua_register_cocos2dx_physics_EventListenerPhysicsContactWithGroup(tolua_S); lua_register_cocos2dx_physics_PhysicsShape(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeBox(tolua_S); lua_register_cocos2dx_physics_PhysicsJointMotor(tolua_S); lua_register_cocos2dx_physics_PhysicsJointDistance(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeCircle(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeEdgePolygon(tolua_S); lua_register_cocos2dx_physics_PhysicsJointPin(tolua_S); lua_register_cocos2dx_physics_PhysicsContactPreSolve(tolua_S); lua_register_cocos2dx_physics_PhysicsDebugDraw(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeEdgeChain(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeEdgeSegment(tolua_S); lua_register_cocos2dx_physics_PhysicsJointGear(tolua_S); lua_register_cocos2dx_physics_PhysicsContact(tolua_S); lua_register_cocos2dx_physics_PhysicsShapePolygon(tolua_S); lua_register_cocos2dx_physics_EventListenerPhysicsContactWithBodies(tolua_S); lua_register_cocos2dx_physics_PhysicsJointRotarySpring(tolua_S); lua_register_cocos2dx_physics_PhysicsContactPostSolve(tolua_S); lua_register_cocos2dx_physics_PhysicsJointGroove(tolua_S); lua_register_cocos2dx_physics_PhysicsShapeEdgeBox(tolua_S); lua_register_cocos2dx_physics_PhysicsJointRotaryLimit(tolua_S); lua_register_cocos2dx_physics_PhysicsJointRatchet(tolua_S); lua_register_cocos2dx_physics_PhysicsJointSpring(tolua_S); lua_register_cocos2dx_physics_EventListenerPhysicsContactWithShapes(tolua_S); tolua_endmodule(tolua_S); return 1; } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_physics_auto.hpp ================================================ #ifndef __cocos2dx_physics_h__ #define __cocos2dx_physics_h__ #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif int register_all_cocos2dx_physics(lua_State* tolua_S); #endif // __cocos2dx_physics_h__ ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_physics_auto_api.js ================================================ /** * @module cocos2dx_physics */ var cc = cc || {}; /** * @class PhysicsShape */ cc.PhysicsShape = { /** * @method getFriction * @return A value converted from C/C++ "float" */ getFriction : function () {}, /** * @method setGroup * @param {int} */ setGroup : function () {}, /** * @method setDensity * @param {float} */ setDensity : function () {}, /** * @method getMass * @return A value converted from C/C++ "float" */ getMass : function () {}, /** * @method getMaterial * @return A value converted from C/C++ "const cocos2d::PhysicsMaterial&" */ getMaterial : function () {}, /** * @method getCollisionBitmask * @return A value converted from C/C++ "int" */ getCollisionBitmask : function () {}, /** * @method getArea * @return A value converted from C/C++ "float" */ getArea : function () {}, /** * @method setCategoryBitmask * @param {int} */ setCategoryBitmask : function () {}, /** * @method getGroup * @return A value converted from C/C++ "int" */ getGroup : function () {}, /** * @method setMoment * @param {float} */ setMoment : function () {}, /** * @method containsPoint * @return A value converted from C/C++ "bool" * @param {const cocos2d::Point&} */ containsPoint : function () {}, /** * @method getCategoryBitmask * @return A value converted from C/C++ "int" */ getCategoryBitmask : function () {}, /** * @method getType * @return A value converted from C/C++ "cocos2d::PhysicsShape::Type" */ getType : function () {}, /** * @method getContactTestBitmask * @return A value converted from C/C++ "int" */ getContactTestBitmask : function () {}, /** * @method getCenter * @return A value converted from C/C++ "cocos2d::Point" */ getCenter : function () {}, /** * @method getDensity * @return A value converted from C/C++ "float" */ getDensity : function () {}, /** * @method setMass * @param {float} */ setMass : function () {}, /** * @method getTag * @return A value converted from C/C++ "int" */ getTag : function () {}, /** * @method calculateDefaultMoment * @return A value converted from C/C++ "float" */ calculateDefaultMoment : function () {}, /** * @method setCollisionBitmask * @param {int} */ setCollisionBitmask : function () {}, /** * @method getMoment * @return A value converted from C/C++ "float" */ getMoment : function () {}, /** * @method getOffset * @return A value converted from C/C++ "cocos2d::Point" */ getOffset : function () {}, /** * @method getRestitution * @return A value converted from C/C++ "float" */ getRestitution : function () {}, /** * @method setFriction * @param {float} */ setFriction : function () {}, /** * @method setMaterial * @param {const cocos2d::PhysicsMaterial&} */ setMaterial : function () {}, /** * @method setTag * @param {int} */ setTag : function () {}, /** * @method setContactTestBitmask * @param {int} */ setContactTestBitmask : function () {}, /** * @method setRestitution * @param {float} */ setRestitution : function () {}, /** * @method getBody * @return A value converted from C/C++ "cocos2d::PhysicsBody*" */ getBody : function () {}, }; /** * @class PhysicsShapeCircle */ cc.PhysicsShapeCircle = { /** * @method getRadius * @return A value converted from C/C++ "float" */ getRadius : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::PhysicsShapeCircle*" * @param {float} * @param {const cocos2d::PhysicsMaterial&} * @param {const cocos2d::Point&} */ create : function () {}, /** * @method calculateArea * @return A value converted from C/C++ "float" * @param {float} */ calculateArea : function () {}, /** * @method calculateMoment * @return A value converted from C/C++ "float" * @param {float} * @param {float} * @param {const cocos2d::Point&} */ calculateMoment : function () {}, }; /** * @class PhysicsShapeBox */ cc.PhysicsShapeBox = { /** * @method getPointsCount * @return A value converted from C/C++ "int" */ getPointsCount : function () {}, /** * @method getSize * @return A value converted from C/C++ "cocos2d::Size" */ getSize : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::PhysicsShapeBox*" * @param {const cocos2d::Size&} * @param {const cocos2d::PhysicsMaterial&} * @param {const cocos2d::Point&} */ create : function () {}, /** * @method calculateArea * @return A value converted from C/C++ "float" * @param {const cocos2d::Size&} */ calculateArea : function () {}, /** * @method calculateMoment * @return A value converted from C/C++ "float" * @param {float} * @param {const cocos2d::Size&} * @param {const cocos2d::Point&} */ calculateMoment : function () {}, }; /** * @class PhysicsShapePolygon */ cc.PhysicsShapePolygon = { /** * @method getPointsCount * @return A value converted from C/C++ "int" */ getPointsCount : function () {}, /** * @method getPoint * @return A value converted from C/C++ "cocos2d::Point" * @param {int} */ getPoint : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::PhysicsShapePolygon*" * @param {const cocos2d::Point*} * @param {int} * @param {const cocos2d::PhysicsMaterial&} * @param {const cocos2d::Point&} */ create : function () {}, /** * @method calculateArea * @return A value converted from C/C++ "float" * @param {const cocos2d::Point*} * @param {int} */ calculateArea : function () {}, /** * @method calculateMoment * @return A value converted from C/C++ "float" * @param {float} * @param {const cocos2d::Point*} * @param {int} * @param {const cocos2d::Point&} */ calculateMoment : function () {}, }; /** * @class PhysicsShapeEdgeSegment */ cc.PhysicsShapeEdgeSegment = { /** * @method getPointB * @return A value converted from C/C++ "cocos2d::Point" */ getPointB : function () {}, /** * @method getPointA * @return A value converted from C/C++ "cocos2d::Point" */ getPointA : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::PhysicsShapeEdgeSegment*" * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::PhysicsMaterial&} * @param {float} */ create : function () {}, }; /** * @class PhysicsShapeEdgeBox */ cc.PhysicsShapeEdgeBox = { /** * @method getPointsCount * @return A value converted from C/C++ "int" */ getPointsCount : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::PhysicsShapeEdgeBox*" * @param {const cocos2d::Size&} * @param {const cocos2d::PhysicsMaterial&} * @param {float} * @param {const cocos2d::Point&} */ create : function () {}, }; /** * @class PhysicsShapeEdgePolygon */ cc.PhysicsShapeEdgePolygon = { /** * @method getPointsCount * @return A value converted from C/C++ "int" */ getPointsCount : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::PhysicsShapeEdgePolygon*" * @param {const cocos2d::Point*} * @param {int} * @param {const cocos2d::PhysicsMaterial&} * @param {float} */ create : function () {}, }; /** * @class PhysicsShapeEdgeChain */ cc.PhysicsShapeEdgeChain = { /** * @method getPointsCount * @return A value converted from C/C++ "int" */ getPointsCount : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::PhysicsShapeEdgeChain*" * @param {const cocos2d::Point*} * @param {int} * @param {const cocos2d::PhysicsMaterial&} * @param {float} */ create : function () {}, }; /** * @class PhysicsBody */ cc.PhysicsBody = { /** * @method isGravityEnabled * @return A value converted from C/C++ "bool" */ isGravityEnabled : function () {}, /** * @method resetForces */ resetForces : function () {}, /** * @method getVelocityLimit * @return A value converted from C/C++ "float" */ getVelocityLimit : function () {}, /** * @method setGroup * @param {int} */ setGroup : function () {}, /** * @method getMass * @return A value converted from C/C++ "float" */ getMass : function () {}, /** * @method getCollisionBitmask * @return A value converted from C/C++ "int" */ getCollisionBitmask : function () {}, /** * @method getRotation * @return A value converted from C/C++ "float" */ getRotation : function () {}, /** * @method isResting * @return A value converted from C/C++ "bool" */ isResting : function () {}, /** * @method addShape * @return A value converted from C/C++ "cocos2d::PhysicsShape*" * @param {cocos2d::PhysicsShape*} * @param {bool} */ addShape : function () {}, /** * @method applyTorque * @param {float} */ applyTorque : function () {}, /** * @method getAngularVelocityLimit * @return A value converted from C/C++ "float" */ getAngularVelocityLimit : function () {}, /** * @method setAngularVelocityLimit * @param {float} */ setAngularVelocityLimit : function () {}, /** * @method getVelocity * @return A value converted from C/C++ "cocos2d::Point" */ getVelocity : function () {}, /** * @method getLinearDamping * @return A value converted from C/C++ "float" */ getLinearDamping : function () {}, /** * @method removeAllShapes */ removeAllShapes : function () {}, /** * @method setAngularDamping * @param {float} */ setAngularDamping : function () {}, /** * @method setVelocityLimit * @param {float} */ setVelocityLimit : function () {}, /** * @method setEnable * @param {bool} */ setEnable : function () {}, /** * @method setCategoryBitmask * @param {int} */ setCategoryBitmask : function () {}, /** * @method getWorld * @return A value converted from C/C++ "cocos2d::PhysicsWorld*" */ getWorld : function () {}, /** * @method getAngularVelocity * @return A value converted from C/C++ "float" */ getAngularVelocity : function () {}, /** * @method getPosition * @return A value converted from C/C++ "cocos2d::Point" */ getPosition : function () {}, /** * @method setGravityEnable * @param {bool} */ setGravityEnable : function () {}, /** * @method getGroup * @return A value converted from C/C++ "int" */ getGroup : function () {}, /** * @method setMoment * @param {float} */ setMoment : function () {}, /** * @method getTag * @return A value converted from C/C++ "int" */ getTag : function () {}, /** * @method local2World * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ local2World : function () {}, /** * @method getCategoryBitmask * @return A value converted from C/C++ "int" */ getCategoryBitmask : function () {}, /** * @method getMoment * @return A value converted from C/C++ "float" * @param {float} */ getMoment : function () {}, /** * @method getFirstShape * @return A value converted from C/C++ "cocos2d::PhysicsShape*" */ getFirstShape : function () {}, /** * @method getShapes * @return A value converted from C/C++ "const cocos2d::Vector&" */ getShapes : function () {}, /** * @method getContactTestBitmask * @return A value converted from C/C++ "int" */ getContactTestBitmask : function () {}, /** * @method setAngularVelocity * @param {float} */ setAngularVelocity : function () {}, /** * @method world2Local * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ world2Local : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method setMass * @param {float} */ setMass : function () {}, /** * @method addMoment * @param {float} */ addMoment : function () {}, /** * @method setVelocity * @param {const cocos2d::Vect&} */ setVelocity : function () {}, /** * @method setLinearDamping * @param {float} */ setLinearDamping : function () {}, /** * @method setCollisionBitmask * @param {int} */ setCollisionBitmask : function () {}, /** * @method setDynamic * @param {bool} */ setDynamic : function () {}, /** * @method setRotationEnable * @param {bool} */ setRotationEnable : function () {}, /** * @method getAngularDamping * @return A value converted from C/C++ "float" */ getAngularDamping : function () {}, /** * @method getVelocityAtLocalPoint * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ getVelocityAtLocalPoint : function () {}, /** * @method isRotationEnabled * @return A value converted from C/C++ "bool" */ isRotationEnabled : function () {}, /** * @method addMass * @param {float} */ addMass : function () {}, /** * @method getShape * @return A value converted from C/C++ "cocos2d::PhysicsShape*" * @param {int} */ getShape : function () {}, /** * @method setTag * @param {int} */ setTag : function () {}, /** * @method getVelocityAtWorldPoint * @return A value converted from C/C++ "cocos2d::Point" * @param {const cocos2d::Point&} */ getVelocityAtWorldPoint : function () {}, /** * @method setContactTestBitmask * @param {int} */ setContactTestBitmask : function () {}, /** * @method removeFromWorld */ removeFromWorld : function () {}, /** * @method isDynamic * @return A value converted from C/C++ "bool" */ isDynamic : function () {}, /** * @method getNode * @return A value converted from C/C++ "cocos2d::Node*" */ getNode : function () {}, /** * @method createBox * @return A value converted from C/C++ "cocos2d::PhysicsBody*" * @param {const cocos2d::Size&} * @param {const cocos2d::PhysicsMaterial&} * @param {const cocos2d::Point&} */ createBox : function () {}, /** * @method createEdgeSegment * @return A value converted from C/C++ "cocos2d::PhysicsBody*" * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::PhysicsMaterial&} * @param {float} */ createEdgeSegment : function () {}, /** * @method createEdgeBox * @return A value converted from C/C++ "cocos2d::PhysicsBody*" * @param {const cocos2d::Size&} * @param {const cocos2d::PhysicsMaterial&} * @param {float} * @param {const cocos2d::Point&} */ createEdgeBox : function () {}, /** * @method createCircle * @return A value converted from C/C++ "cocos2d::PhysicsBody*" * @param {float} * @param {const cocos2d::PhysicsMaterial&} * @param {const cocos2d::Point&} */ createCircle : function () {}, }; /** * @class PhysicsWorld */ cc.PhysicsWorld = { /** * @method getGravity * @return A value converted from C/C++ "cocos2d::Vect" */ getGravity : function () {}, /** * @method getAllBodies * @return A value converted from C/C++ "const cocos2d::Vector&" */ getAllBodies : function () {}, /** * @method setGravity * @param {const cocos2d::Vect&} */ setGravity : function () {}, /** * @method getSpeed * @return A value converted from C/C++ "float" */ getSpeed : function () {}, /** * @method removeJoint * @param {cocos2d::PhysicsJoint*} * @param {bool} */ removeJoint : function () {}, /** * @method getUpdateRate * @return A value converted from C/C++ "int" */ getUpdateRate : function () {}, /** * @method setSpeed * @param {float} */ setSpeed : function () {}, /** * @method getShapes * @return A value converted from C/C++ "cocos2d::Vector" * @param {const cocos2d::Point&} */ getShapes : function () {}, /** * @method removeAllJoints * @param {bool} */ removeAllJoints : function () {}, /** * @method getShape * @return A value converted from C/C++ "cocos2d::PhysicsShape*" * @param {const cocos2d::Point&} */ getShape : function () {}, /** * @method removeAllBodies */ removeAllBodies : function () {}, /** * @method getDebugDrawMask * @return A value converted from C/C++ "int" */ getDebugDrawMask : function () {}, /** * @method setDebugDrawMask * @param {int} */ setDebugDrawMask : function () {}, /** * @method getBody * @return A value converted from C/C++ "cocos2d::PhysicsBody*" * @param {int} */ getBody : function () {}, /** * @method setUpdateRate * @param {int} */ setUpdateRate : function () {}, /** * @method addJoint * @param {cocos2d::PhysicsJoint*} */ addJoint : function () {}, }; /** * @class PhysicsDebugDraw */ cc.PhysicsDebugDraw = { }; /** * @class PhysicsContact */ cc.PhysicsContact = { /** * @method getContactData * @return A value converted from C/C++ "const cocos2d::PhysicsContactData*" */ getContactData : function () {}, /** * @method getEventCode * @return A value converted from C/C++ "cocos2d::PhysicsContact::EventCode" */ getEventCode : function () {}, /** * @method getShapeA * @return A value converted from C/C++ "cocos2d::PhysicsShape*" */ getShapeA : function () {}, /** * @method getShapeB * @return A value converted from C/C++ "cocos2d::PhysicsShape*" */ getShapeB : function () {}, }; /** * @class PhysicsContactPreSolve */ cc.PhysicsContactPreSolve = { /** * @method getFriction * @return A value converted from C/C++ "float" */ getFriction : function () {}, /** * @method getElasticity * @return A value converted from C/C++ "float" */ getElasticity : function () {}, /** * @method setElasticity * @param {float} */ setElasticity : function () {}, /** * @method setFriction * @param {float} */ setFriction : function () {}, /** * @method ignore */ ignore : function () {}, /** * @method getSurfaceVelocity * @return A value converted from C/C++ "cocos2d::Point" */ getSurfaceVelocity : function () {}, /** * @method setSurfaceVelocity * @param {const cocos2d::Vect&} */ setSurfaceVelocity : function () {}, }; /** * @class PhysicsContactPostSolve */ cc.PhysicsContactPostSolve = { /** * @method getFriction * @return A value converted from C/C++ "float" */ getFriction : function () {}, /** * @method getSurfaceVelocity * @return A value converted from C/C++ "cocos2d::Point" */ getSurfaceVelocity : function () {}, /** * @method getElasticity * @return A value converted from C/C++ "float" */ getElasticity : function () {}, }; /** * @class EventListenerPhysicsContact */ cc.EventListenerPhysicsContact = { /** * @method create * @return A value converted from C/C++ "cocos2d::EventListenerPhysicsContact*" */ create : function () {}, }; /** * @class EventListenerPhysicsContactWithBodies */ cc.EventListenerPhysicsContactWithBodies = { /** * @method hitTest * @return A value converted from C/C++ "bool" * @param {cocos2d::PhysicsShape*} * @param {cocos2d::PhysicsShape*} */ hitTest : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::EventListenerPhysicsContactWithBodies*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} */ create : function () {}, }; /** * @class EventListenerPhysicsContactWithShapes */ cc.EventListenerPhysicsContactWithShapes = { /** * @method hitTest * @return A value converted from C/C++ "bool" * @param {cocos2d::PhysicsShape*} * @param {cocos2d::PhysicsShape*} */ hitTest : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::EventListenerPhysicsContactWithShapes*" * @param {cocos2d::PhysicsShape*} * @param {cocos2d::PhysicsShape*} */ create : function () {}, }; /** * @class EventListenerPhysicsContactWithGroup */ cc.EventListenerPhysicsContactWithGroup = { /** * @method hitTest * @return A value converted from C/C++ "bool" * @param {cocos2d::PhysicsShape*} * @param {cocos2d::PhysicsShape*} */ hitTest : function () {}, /** * @method create * @return A value converted from C/C++ "cocos2d::EventListenerPhysicsContactWithGroup*" * @param {int} */ create : function () {}, }; /** * @class PhysicsJoint */ cc.PhysicsJoint = { /** * @method getBodyA * @return A value converted from C/C++ "cocos2d::PhysicsBody*" */ getBodyA : function () {}, /** * @method getBodyB * @return A value converted from C/C++ "cocos2d::PhysicsBody*" */ getBodyB : function () {}, /** * @method getMaxForce * @return A value converted from C/C++ "float" */ getMaxForce : function () {}, /** * @method setMaxForce * @param {float} */ setMaxForce : function () {}, /** * @method isEnabled * @return A value converted from C/C++ "bool" */ isEnabled : function () {}, /** * @method setEnable * @param {bool} */ setEnable : function () {}, /** * @method setCollisionEnable * @param {bool} */ setCollisionEnable : function () {}, /** * @method getWorld * @return A value converted from C/C++ "cocos2d::PhysicsWorld*" */ getWorld : function () {}, /** * @method setTag * @param {int} */ setTag : function () {}, /** * @method removeFormWorld */ removeFormWorld : function () {}, /** * @method isCollisionEnabled * @return A value converted from C/C++ "bool" */ isCollisionEnabled : function () {}, /** * @method getTag * @return A value converted from C/C++ "int" */ getTag : function () {}, /** * @method destroy * @param {cocos2d::PhysicsJoint*} */ destroy : function () {}, }; /** * @class PhysicsJointFixed */ cc.PhysicsJointFixed = { /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointFixed*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {const cocos2d::Point&} */ construct : function () {}, }; /** * @class PhysicsJointLimit */ cc.PhysicsJointLimit = { /** * @method setAnchr2 * @param {const cocos2d::Point&} */ setAnchr2 : function () {}, /** * @method setAnchr1 * @param {const cocos2d::Point&} */ setAnchr1 : function () {}, /** * @method setMax * @param {float} */ setMax : function () {}, /** * @method getAnchr2 * @return A value converted from C/C++ "cocos2d::Point" */ getAnchr2 : function () {}, /** * @method getAnchr1 * @return A value converted from C/C++ "cocos2d::Point" */ getAnchr1 : function () {}, /** * @method getMin * @return A value converted from C/C++ "float" */ getMin : function () {}, /** * @method getMax * @return A value converted from C/C++ "float" */ getMax : function () {}, /** * @method setMin * @param {float} */ setMin : function () {}, }; /** * @class PhysicsJointPin */ cc.PhysicsJointPin = { /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointPin*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {const cocos2d::Point&} */ construct : function () {}, }; /** * @class PhysicsJointDistance */ cc.PhysicsJointDistance = { /** * @method setDistance * @param {float} */ setDistance : function () {}, /** * @method getDistance * @return A value converted from C/C++ "float" */ getDistance : function () {}, /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointDistance*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} */ construct : function () {}, }; /** * @class PhysicsJointSpring */ cc.PhysicsJointSpring = { /** * @method setAnchr2 * @param {const cocos2d::Point&} */ setAnchr2 : function () {}, /** * @method setAnchr1 * @param {const cocos2d::Point&} */ setAnchr1 : function () {}, /** * @method getDamping * @return A value converted from C/C++ "float" */ getDamping : function () {}, /** * @method setStiffness * @param {float} */ setStiffness : function () {}, /** * @method getRestLength * @return A value converted from C/C++ "float" */ getRestLength : function () {}, /** * @method getAnchr2 * @return A value converted from C/C++ "cocos2d::Point" */ getAnchr2 : function () {}, /** * @method getAnchr1 * @return A value converted from C/C++ "cocos2d::Point" */ getAnchr1 : function () {}, /** * @method getStiffness * @return A value converted from C/C++ "float" */ getStiffness : function () {}, /** * @method setRestLength * @param {float} */ setRestLength : function () {}, /** * @method setDamping * @param {float} */ setDamping : function () {}, /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointSpring*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {float} * @param {float} */ construct : function () {}, }; /** * @class PhysicsJointGroove */ cc.PhysicsJointGroove = { /** * @method setAnchr2 * @param {const cocos2d::Point&} */ setAnchr2 : function () {}, /** * @method setGrooveA * @param {const cocos2d::Point&} */ setGrooveA : function () {}, /** * @method setGrooveB * @param {const cocos2d::Point&} */ setGrooveB : function () {}, /** * @method getGrooveA * @return A value converted from C/C++ "cocos2d::Point" */ getGrooveA : function () {}, /** * @method getGrooveB * @return A value converted from C/C++ "cocos2d::Point" */ getGrooveB : function () {}, /** * @method getAnchr2 * @return A value converted from C/C++ "cocos2d::Point" */ getAnchr2 : function () {}, /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointGroove*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} * @param {const cocos2d::Point&} */ construct : function () {}, }; /** * @class PhysicsJointRotarySpring */ cc.PhysicsJointRotarySpring = { /** * @method getDamping * @return A value converted from C/C++ "float" */ getDamping : function () {}, /** * @method setRestAngle * @param {float} */ setRestAngle : function () {}, /** * @method getStiffness * @return A value converted from C/C++ "float" */ getStiffness : function () {}, /** * @method setStiffness * @param {float} */ setStiffness : function () {}, /** * @method setDamping * @param {float} */ setDamping : function () {}, /** * @method getRestAngle * @return A value converted from C/C++ "float" */ getRestAngle : function () {}, /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointRotarySpring*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {float} * @param {float} */ construct : function () {}, }; /** * @class PhysicsJointRotaryLimit */ cc.PhysicsJointRotaryLimit = { /** * @method getMax * @return A value converted from C/C++ "float" */ getMax : function () {}, /** * @method setMin * @param {float} */ setMin : function () {}, /** * @method setMax * @param {float} */ setMax : function () {}, /** * @method getMin * @return A value converted from C/C++ "float" */ getMin : function () {}, }; /** * @class PhysicsJointRatchet */ cc.PhysicsJointRatchet = { /** * @method getAngle * @return A value converted from C/C++ "float" */ getAngle : function () {}, /** * @method setAngle * @param {float} */ setAngle : function () {}, /** * @method setPhase * @param {float} */ setPhase : function () {}, /** * @method getPhase * @return A value converted from C/C++ "float" */ getPhase : function () {}, /** * @method setRatchet * @param {float} */ setRatchet : function () {}, /** * @method getRatchet * @return A value converted from C/C++ "float" */ getRatchet : function () {}, /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointRatchet*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {float} * @param {float} */ construct : function () {}, }; /** * @class PhysicsJointGear */ cc.PhysicsJointGear = { /** * @method setRatio * @param {float} */ setRatio : function () {}, /** * @method getPhase * @return A value converted from C/C++ "float" */ getPhase : function () {}, /** * @method setPhase * @param {float} */ setPhase : function () {}, /** * @method getRatio * @return A value converted from C/C++ "float" */ getRatio : function () {}, /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointGear*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {float} * @param {float} */ construct : function () {}, }; /** * @class PhysicsJointMotor */ cc.PhysicsJointMotor = { /** * @method setRate * @param {float} */ setRate : function () {}, /** * @method getRate * @return A value converted from C/C++ "float" */ getRate : function () {}, /** * @method construct * @return A value converted from C/C++ "cocos2d::PhysicsJointMotor*" * @param {cocos2d::PhysicsBody*} * @param {cocos2d::PhysicsBody*} * @param {float} */ construct : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_spine_auto.cpp ================================================ #include "lua_cocos2dx_spine_auto.hpp" #include "spine-cocos2dx.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" int lua_cocos2dx_spine_Skeleton_setToSetupPose(lua_State* tolua_S) { int argc = 0; spine::Skeleton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.Skeleton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::Skeleton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setToSetupPose'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setToSetupPose(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setToSetupPose",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_Skeleton_setToSetupPose'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_Skeleton_setBlendFunc(lua_State* tolua_S) { int argc = 0; spine::Skeleton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.Skeleton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::Skeleton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBlendFunc'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::BlendFunc arg0; #pragma warning NO CONVERSION TO NATIVE FOR BlendFunc; if(!ok) return 0; cobj->setBlendFunc(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBlendFunc",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_Skeleton_setBlendFunc'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_Skeleton_onDraw(lua_State* tolua_S) { int argc = 0; spine::Skeleton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.Skeleton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::Skeleton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_onDraw'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->onDraw(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onDraw",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_Skeleton_onDraw'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose(lua_State* tolua_S) { int argc = 0; spine::Skeleton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.Skeleton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::Skeleton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setSlotsToSetupPose(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSlotsToSetupPose",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_Skeleton_getBlendFunc(lua_State* tolua_S) { int argc = 0; spine::Skeleton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.Skeleton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::Skeleton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_getBlendFunc'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); #pragma warning NO CONVERSION FROM NATIVE FOR BlendFunc; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBlendFunc",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_Skeleton_getBlendFunc'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_Skeleton_setSkin(lua_State* tolua_S) { int argc = 0; spine::Skeleton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.Skeleton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::Skeleton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSkin'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; bool ret = cobj->setSkin(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSkin",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_Skeleton_setSkin'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_Skeleton_setBonesToSetupPose(lua_State* tolua_S) { int argc = 0; spine::Skeleton* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.Skeleton",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::Skeleton*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBonesToSetupPose'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->setBonesToSetupPose(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBonesToSetupPose",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_Skeleton_setBonesToSetupPose'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_spine_Skeleton_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Skeleton)"); return 0; } int lua_register_cocos2dx_spine_Skeleton(lua_State* tolua_S) { tolua_usertype(tolua_S,"sp.Skeleton"); tolua_cclass(tolua_S,"Skeleton","sp.Skeleton","cc.Node",NULL); tolua_beginmodule(tolua_S,"Skeleton"); tolua_function(tolua_S,"setToSetupPose",lua_cocos2dx_spine_Skeleton_setToSetupPose); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_spine_Skeleton_setBlendFunc); tolua_function(tolua_S,"onDraw",lua_cocos2dx_spine_Skeleton_onDraw); tolua_function(tolua_S,"setSlotsToSetupPose",lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose); tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_spine_Skeleton_getBlendFunc); tolua_function(tolua_S,"setSkin",lua_cocos2dx_spine_Skeleton_setSkin); tolua_function(tolua_S,"setBonesToSetupPose",lua_cocos2dx_spine_Skeleton_setBonesToSetupPose); tolua_endmodule(tolua_S); std::string typeName = typeid(spine::Skeleton).name(); g_luaType[typeName] = "sp.Skeleton"; g_typeCast["Skeleton"] = "sp.Skeleton"; return 1; } int lua_cocos2dx_spine_SkeletonAnimation_addAnimation(lua_State* tolua_S) { int argc = 0; spine::SkeletonAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_addAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; const char* arg1; bool arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; spTrackEntry* ret = cobj->addAnimation(arg0, arg1, arg2); #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; return 1; } if (argc == 4) { int arg0; const char* arg1; bool arg2; double arg3; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 4,&arg2); ok &= luaval_to_number(tolua_S, 5,&arg3); if(!ok) return 0; spTrackEntry* ret = cobj->addAnimation(arg0, arg1, arg2, arg3); #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addAnimation",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_addAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_SkeletonAnimation_getCurrent(lua_State* tolua_S) { int argc = 0; spine::SkeletonAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_getCurrent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; spTrackEntry* ret = cobj->getCurrent(); #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; return 1; } if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; spTrackEntry* ret = cobj->getCurrent(arg0); #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_getCurrent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_SkeletonAnimation_setMix(lua_State* tolua_S) { int argc = 0; spine::SkeletonAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setMix'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { const char* arg0; const char* arg1; double arg2; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); ok &= luaval_to_number(tolua_S, 4,&arg2); if(!ok) return 0; cobj->setMix(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setMix",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_setMix'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_SkeletonAnimation_setAnimation(lua_State* tolua_S) { int argc = 0; spine::SkeletonAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { int arg0; const char* arg1; bool arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; spTrackEntry* ret = cobj->setAnimation(arg0, arg1, arg2); #pragma warning NO CONVERSION FROM NATIVE FOR spTrackEntry*; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimation",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_setAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_SkeletonAnimation_clearTracks(lua_State* tolua_S) { int argc = 0; spine::SkeletonAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTracks'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->clearTracks(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clearTracks",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTracks'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_SkeletonAnimation_clearTrack(lua_State* tolua_S) { int argc = 0; spine::SkeletonAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTrack'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->clearTrack(); return 0; } if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->clearTrack(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clearTrack",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTrack'.",&tolua_err); #endif return 0; } int lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(lua_State* tolua_S) { int argc = 0; spine::SkeletonAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 4) { int arg0; spEventType arg1; spEvent* arg2; int arg3; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); #pragma warning NO CONVERSION TO NATIVE FOR spEvent*; ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; cobj->onAnimationStateEvent(arg0, arg1, arg2, arg3); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onAnimationStateEvent",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_spine_SkeletonAnimation_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SkeletonAnimation)"); return 0; } int lua_register_cocos2dx_spine_SkeletonAnimation(lua_State* tolua_S) { tolua_usertype(tolua_S,"sp.SkeletonAnimation"); tolua_cclass(tolua_S,"SkeletonAnimation","sp.SkeletonAnimation","sp.Skeleton",NULL); tolua_beginmodule(tolua_S,"SkeletonAnimation"); tolua_function(tolua_S,"addAnimation",lua_cocos2dx_spine_SkeletonAnimation_addAnimation); tolua_function(tolua_S,"getCurrent",lua_cocos2dx_spine_SkeletonAnimation_getCurrent); tolua_function(tolua_S,"setMix",lua_cocos2dx_spine_SkeletonAnimation_setMix); tolua_function(tolua_S,"setAnimation",lua_cocos2dx_spine_SkeletonAnimation_setAnimation); tolua_function(tolua_S,"clearTracks",lua_cocos2dx_spine_SkeletonAnimation_clearTracks); tolua_function(tolua_S,"clearTrack",lua_cocos2dx_spine_SkeletonAnimation_clearTrack); tolua_function(tolua_S,"onAnimationStateEvent",lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent); tolua_endmodule(tolua_S); std::string typeName = typeid(spine::SkeletonAnimation).name(); g_luaType[typeName] = "sp.SkeletonAnimation"; g_typeCast["SkeletonAnimation"] = "sp.SkeletonAnimation"; return 1; } TOLUA_API int register_all_cocos2dx_spine(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,"sp",0); tolua_beginmodule(tolua_S,"sp"); lua_register_cocos2dx_spine_Skeleton(tolua_S); lua_register_cocos2dx_spine_SkeletonAnimation(tolua_S); tolua_endmodule(tolua_S); return 1; } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_spine_auto.hpp ================================================ #ifndef __cocos2dx_spine_h__ #define __cocos2dx_spine_h__ #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif int register_all_cocos2dx_spine(lua_State* tolua_S); #endif // __cocos2dx_spine_h__ ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_spine_auto_api.js ================================================ /** * @module cocos2dx_spine */ var sp = sp || {}; /** * @class Skeleton */ sp.Skeleton = { /** * @method setToSetupPose */ setToSetupPose : function () {}, /** * @method setBlendFunc * @param {const cocos2d::BlendFunc&} */ setBlendFunc : function () {}, /** * @method onDraw */ onDraw : function () {}, /** * @method setSlotsToSetupPose */ setSlotsToSetupPose : function () {}, /** * @method getBlendFunc * @return A value converted from C/C++ "const cocos2d::BlendFunc&" */ getBlendFunc : function () {}, /** * @method setSkin * @return A value converted from C/C++ "bool" * @param {const char*} */ setSkin : function () {}, /** * @method setBonesToSetupPose */ setBonesToSetupPose : function () {}, }; /** * @class SkeletonAnimation */ sp.SkeletonAnimation = { /** * @method addAnimation * @return A value converted from C/C++ "spTrackEntry*" * @param {int} * @param {const char*} * @param {bool} * @param {float} */ addAnimation : function () {}, /** * @method getCurrent * @return A value converted from C/C++ "spTrackEntry*" */ getCurrent : function () {}, /** * @method setMix * @param {const char*} * @param {const char*} * @param {float} */ setMix : function () {}, /** * @method setAnimation * @return A value converted from C/C++ "spTrackEntry*" * @param {int} * @param {const char*} * @param {bool} */ setAnimation : function () {}, /** * @method clearTracks */ clearTracks : function () {}, /** * @method clearTrack */ clearTrack : function () {}, /** * @method onAnimationStateEvent * @param {int} * @param {spEventType} * @param {spEvent*} * @param {int} */ onAnimationStateEvent : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp ================================================ #include "lua_cocos2dx_studio_auto.hpp" #include "CocoStudio.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" int lua_cocos2dx_studio_ActionObject_setCurrentTime(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_setCurrentTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setCurrentTime(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setCurrentTime",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_setCurrentTime'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_pause(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_pause'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pause(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pause",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_pause'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_setName(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_setName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_setName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_setUnitTime(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_setUnitTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setUnitTime(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUnitTime",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_setUnitTime'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_getTotalTime(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_getTotalTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getTotalTime(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTotalTime",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_getTotalTime'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_getName(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_getName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getName(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_getName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_stop(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_stop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stop(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stop",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_stop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_play(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_play'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { cocos2d::CallFunc* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.CallFunc",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::CallFunc*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cobj->play(arg0); return 0; } }while(0); ok = true; do{ if (argc == 0) { cobj->play(); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "play",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_play'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_getCurrentTime(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_getCurrentTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getCurrentTime(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentTime",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_getCurrentTime'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_removeActionNode(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_removeActionNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::ActionNode* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.ActionNode",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::ActionNode*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->removeActionNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeActionNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_removeActionNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_getLoop(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_getLoop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getLoop(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLoop",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_getLoop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_addActionNode(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_addActionNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::ActionNode* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.ActionNode",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::ActionNode*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addActionNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addActionNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_addActionNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_getUnitTime(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_getUnitTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getUnitTime(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUnitTime",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_getUnitTime'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_isPlaying(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_isPlaying'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isPlaying(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isPlaying",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_isPlaying'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_updateToFrameByTime(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_updateToFrameByTime'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->updateToFrameByTime(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateToFrameByTime",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_updateToFrameByTime'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_setLoop(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_setLoop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLoop(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLoop",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_setLoop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_simulationActionUpdate(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionObject",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionObject*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionObject_simulationActionUpdate'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->simulationActionUpdate(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "simulationActionUpdate",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_simulationActionUpdate'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionObject_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::ActionObject* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::ActionObject(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.ActionObject"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.ActionObject"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ActionObject",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionObject_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ActionObject_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ActionObject)"); return 0; } int lua_register_cocos2dx_studio_ActionObject(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ActionObject"); tolua_cclass(tolua_S,"ActionObject","ccs.ActionObject","",NULL); tolua_beginmodule(tolua_S,"ActionObject"); tolua_function(tolua_S,"setCurrentTime",lua_cocos2dx_studio_ActionObject_setCurrentTime); tolua_function(tolua_S,"pause",lua_cocos2dx_studio_ActionObject_pause); tolua_function(tolua_S,"setName",lua_cocos2dx_studio_ActionObject_setName); tolua_function(tolua_S,"setUnitTime",lua_cocos2dx_studio_ActionObject_setUnitTime); tolua_function(tolua_S,"getTotalTime",lua_cocos2dx_studio_ActionObject_getTotalTime); tolua_function(tolua_S,"getName",lua_cocos2dx_studio_ActionObject_getName); tolua_function(tolua_S,"stop",lua_cocos2dx_studio_ActionObject_stop); tolua_function(tolua_S,"play",lua_cocos2dx_studio_ActionObject_play); tolua_function(tolua_S,"getCurrentTime",lua_cocos2dx_studio_ActionObject_getCurrentTime); tolua_function(tolua_S,"removeActionNode",lua_cocos2dx_studio_ActionObject_removeActionNode); tolua_function(tolua_S,"getLoop",lua_cocos2dx_studio_ActionObject_getLoop); tolua_function(tolua_S,"addActionNode",lua_cocos2dx_studio_ActionObject_addActionNode); tolua_function(tolua_S,"getUnitTime",lua_cocos2dx_studio_ActionObject_getUnitTime); tolua_function(tolua_S,"isPlaying",lua_cocos2dx_studio_ActionObject_isPlaying); tolua_function(tolua_S,"updateToFrameByTime",lua_cocos2dx_studio_ActionObject_updateToFrameByTime); tolua_function(tolua_S,"setLoop",lua_cocos2dx_studio_ActionObject_setLoop); tolua_function(tolua_S,"simulationActionUpdate",lua_cocos2dx_studio_ActionObject_simulationActionUpdate); tolua_function(tolua_S,"new",lua_cocos2dx_studio_ActionObject_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ActionObject).name(); g_luaType[typeName] = "ccs.ActionObject"; g_typeCast["ActionObject"] = "ccs.ActionObject"; return 1; } int lua_cocos2dx_studio_ActionManagerEx_playActionByName(lua_State* tolua_S) { int argc = 0; cocostudio::ActionManagerEx* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionManagerEx",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionManagerEx*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionManagerEx_playActionByName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } cocos2d::CallFunc* arg2; do { if (!luaval_is_usertype(tolua_S,4,"cc.CallFunc",0)){ ok = false; break; } if (ok){ arg2 = (cocos2d::CallFunc*)tolua_tousertype(tolua_S,4,0); if (nullptr == arg2){ LUA_PRECONDITION( arg2, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocostudio::ActionObject* ret = cobj->playActionByName(arg0, arg1, arg2); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ActionObject"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ActionObject*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } cocostudio::ActionObject* ret = cobj->playActionByName(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ActionObject"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ActionObject*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "playActionByName",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionManagerEx_playActionByName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionManagerEx_getActionByName(lua_State* tolua_S) { int argc = 0; cocostudio::ActionManagerEx* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionManagerEx",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionManagerEx*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionManagerEx_getActionByName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if(!ok) return 0; cocostudio::ActionObject* ret = cobj->getActionByName(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ActionObject"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ActionObject*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getActionByName",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionManagerEx_getActionByName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionManagerEx_releaseActions(lua_State* tolua_S) { int argc = 0; cocostudio::ActionManagerEx* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ActionManagerEx",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ActionManagerEx*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ActionManagerEx_releaseActions'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->releaseActions(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "releaseActions",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionManagerEx_releaseActions'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionManagerEx_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ActionManagerEx",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ActionManagerEx::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionManagerEx_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ActionManagerEx_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ActionManagerEx",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ActionManagerEx* ret = cocostudio::ActionManagerEx::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ActionManagerEx"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ActionManagerEx*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ActionManagerEx_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ActionManagerEx_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ActionManagerEx)"); return 0; } int lua_register_cocos2dx_studio_ActionManagerEx(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ActionManagerEx"); tolua_cclass(tolua_S,"ActionManagerEx","ccs.ActionManagerEx","",NULL); tolua_beginmodule(tolua_S,"ActionManagerEx"); tolua_function(tolua_S,"playActionByName",lua_cocos2dx_studio_ActionManagerEx_playActionByName); tolua_function(tolua_S,"getActionByName",lua_cocos2dx_studio_ActionManagerEx_getActionByName); tolua_function(tolua_S,"releaseActions",lua_cocos2dx_studio_ActionManagerEx_releaseActions); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_studio_ActionManagerEx_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_studio_ActionManagerEx_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ActionManagerEx).name(); g_luaType[typeName] = "ccs.ActionManagerEx"; g_typeCast["ActionManagerEx"] = "ccs.ActionManagerEx"; return 1; } int lua_cocos2dx_studio_BaseData_getColor(lua_State* tolua_S) { int argc = 0; cocostudio::BaseData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.BaseData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::BaseData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_BaseData_getColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Color4B ret = cobj->getColor(); color4b_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BaseData_getColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_BaseData_setColor(lua_State* tolua_S) { int argc = 0; cocostudio::BaseData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.BaseData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::BaseData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_BaseData_setColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Color4B arg0; ok &=luaval_to_color4b(tolua_S, 2, &arg0); if(!ok) return 0; cobj->setColor(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setColor",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BaseData_setColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_BaseData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.BaseData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::BaseData* ret = cocostudio::BaseData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.BaseData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::BaseData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BaseData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_BaseData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::BaseData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::BaseData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.BaseData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.BaseData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "BaseData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BaseData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_BaseData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (BaseData)"); return 0; } int lua_register_cocos2dx_studio_BaseData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.BaseData"); tolua_cclass(tolua_S,"BaseData","ccs.BaseData","",NULL); tolua_beginmodule(tolua_S,"BaseData"); tolua_function(tolua_S,"getColor",lua_cocos2dx_studio_BaseData_getColor); tolua_function(tolua_S,"setColor",lua_cocos2dx_studio_BaseData_setColor); tolua_function(tolua_S,"new",lua_cocos2dx_studio_BaseData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_BaseData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::BaseData).name(); g_luaType[typeName] = "ccs.BaseData"; g_typeCast["BaseData"] = "ccs.BaseData"; return 1; } int lua_cocos2dx_studio_DisplayData_copy(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayData_copy'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::DisplayData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.DisplayData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::DisplayData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->copy(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "copy",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayData_copy'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayData_changeDisplayToTexture(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.DisplayData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; const std::string ret = cocostudio::DisplayData::changeDisplayToTexture(arg0); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "changeDisplayToTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayData_changeDisplayToTexture'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.DisplayData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::DisplayData* ret = cocostudio::DisplayData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.DisplayData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::DisplayData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::DisplayData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.DisplayData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.DisplayData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "DisplayData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_DisplayData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (DisplayData)"); return 0; } int lua_register_cocos2dx_studio_DisplayData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.DisplayData"); tolua_cclass(tolua_S,"DisplayData","ccs.DisplayData","",NULL); tolua_beginmodule(tolua_S,"DisplayData"); tolua_function(tolua_S,"copy",lua_cocos2dx_studio_DisplayData_copy); tolua_function(tolua_S,"new",lua_cocos2dx_studio_DisplayData_constructor); tolua_function(tolua_S,"changeDisplayToTexture", lua_cocos2dx_studio_DisplayData_changeDisplayToTexture); tolua_function(tolua_S,"create", lua_cocos2dx_studio_DisplayData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::DisplayData).name(); g_luaType[typeName] = "ccs.DisplayData"; g_typeCast["DisplayData"] = "ccs.DisplayData"; return 1; } int lua_cocos2dx_studio_SpriteDisplayData_copy(lua_State* tolua_S) { int argc = 0; cocostudio::SpriteDisplayData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.SpriteDisplayData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::SpriteDisplayData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_SpriteDisplayData_copy'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::DisplayData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.DisplayData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::DisplayData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->copy(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "copy",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SpriteDisplayData_copy'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_SpriteDisplayData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.SpriteDisplayData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::SpriteDisplayData* ret = cocostudio::SpriteDisplayData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.SpriteDisplayData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::SpriteDisplayData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SpriteDisplayData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_SpriteDisplayData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::SpriteDisplayData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::SpriteDisplayData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.SpriteDisplayData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.SpriteDisplayData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "SpriteDisplayData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SpriteDisplayData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_SpriteDisplayData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SpriteDisplayData)"); return 0; } int lua_register_cocos2dx_studio_SpriteDisplayData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.SpriteDisplayData"); tolua_cclass(tolua_S,"SpriteDisplayData","ccs.SpriteDisplayData","ccs.DisplayData",NULL); tolua_beginmodule(tolua_S,"SpriteDisplayData"); tolua_function(tolua_S,"copy",lua_cocos2dx_studio_SpriteDisplayData_copy); tolua_function(tolua_S,"new",lua_cocos2dx_studio_SpriteDisplayData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_SpriteDisplayData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::SpriteDisplayData).name(); g_luaType[typeName] = "ccs.SpriteDisplayData"; g_typeCast["SpriteDisplayData"] = "ccs.SpriteDisplayData"; return 1; } int lua_cocos2dx_studio_ArmatureDisplayData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ArmatureDisplayData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ArmatureDisplayData* ret = cocostudio::ArmatureDisplayData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ArmatureDisplayData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ArmatureDisplayData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDisplayData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDisplayData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDisplayData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::ArmatureDisplayData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.ArmatureDisplayData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.ArmatureDisplayData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ArmatureDisplayData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDisplayData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ArmatureDisplayData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ArmatureDisplayData)"); return 0; } int lua_register_cocos2dx_studio_ArmatureDisplayData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ArmatureDisplayData"); tolua_cclass(tolua_S,"ArmatureDisplayData","ccs.ArmatureDisplayData","ccs.DisplayData",NULL); tolua_beginmodule(tolua_S,"ArmatureDisplayData"); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ArmatureDisplayData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ArmatureDisplayData).name(); g_luaType[typeName] = "ccs.ArmatureDisplayData"; g_typeCast["ArmatureDisplayData"] = "ccs.ArmatureDisplayData"; return 1; } int lua_cocos2dx_studio_ParticleDisplayData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ParticleDisplayData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ParticleDisplayData* ret = cocostudio::ParticleDisplayData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ParticleDisplayData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ParticleDisplayData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ParticleDisplayData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ParticleDisplayData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::ParticleDisplayData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::ParticleDisplayData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.ParticleDisplayData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.ParticleDisplayData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ParticleDisplayData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ParticleDisplayData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ParticleDisplayData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ParticleDisplayData)"); return 0; } int lua_register_cocos2dx_studio_ParticleDisplayData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ParticleDisplayData"); tolua_cclass(tolua_S,"ParticleDisplayData","ccs.ParticleDisplayData","ccs.DisplayData",NULL); tolua_beginmodule(tolua_S,"ParticleDisplayData"); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ParticleDisplayData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ParticleDisplayData).name(); g_luaType[typeName] = "ccs.ParticleDisplayData"; g_typeCast["ParticleDisplayData"] = "ccs.ParticleDisplayData"; return 1; } int lua_cocos2dx_studio_BoneData_getDisplayData(lua_State* tolua_S) { int argc = 0; cocostudio::BoneData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.BoneData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::BoneData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_BoneData_getDisplayData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocostudio::DisplayData* ret = cobj->getDisplayData(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.DisplayData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::DisplayData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BoneData_getDisplayData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_BoneData_init(lua_State* tolua_S) { int argc = 0; cocostudio::BoneData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.BoneData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::BoneData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_BoneData_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BoneData_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_BoneData_addDisplayData(lua_State* tolua_S) { int argc = 0; cocostudio::BoneData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.BoneData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::BoneData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_BoneData_addDisplayData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::DisplayData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.DisplayData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::DisplayData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addDisplayData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDisplayData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BoneData_addDisplayData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_BoneData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.BoneData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::BoneData* ret = cocostudio::BoneData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.BoneData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::BoneData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BoneData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_BoneData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::BoneData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::BoneData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.BoneData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.BoneData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "BoneData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BoneData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_BoneData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (BoneData)"); return 0; } int lua_register_cocos2dx_studio_BoneData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.BoneData"); tolua_cclass(tolua_S,"BoneData","ccs.BoneData","ccs.BaseData",NULL); tolua_beginmodule(tolua_S,"BoneData"); tolua_function(tolua_S,"getDisplayData",lua_cocos2dx_studio_BoneData_getDisplayData); tolua_function(tolua_S,"init",lua_cocos2dx_studio_BoneData_init); tolua_function(tolua_S,"addDisplayData",lua_cocos2dx_studio_BoneData_addDisplayData); tolua_function(tolua_S,"new",lua_cocos2dx_studio_BoneData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_BoneData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::BoneData).name(); g_luaType[typeName] = "ccs.BoneData"; g_typeCast["BoneData"] = "ccs.BoneData"; return 1; } int lua_cocos2dx_studio_ArmatureData_addBoneData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureData_addBoneData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::BoneData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.BoneData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::BoneData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addBoneData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addBoneData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureData_addBoneData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureData_init(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureData_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureData_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureData_getBoneData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureData_getBoneData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocostudio::BoneData* ret = cobj->getBoneData(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.BoneData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::BoneData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBoneData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureData_getBoneData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ArmatureData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ArmatureData* ret = cocostudio::ArmatureData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ArmatureData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ArmatureData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::ArmatureData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.ArmatureData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.ArmatureData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ArmatureData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ArmatureData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ArmatureData)"); return 0; } int lua_register_cocos2dx_studio_ArmatureData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ArmatureData"); tolua_cclass(tolua_S,"ArmatureData","ccs.ArmatureData","",NULL); tolua_beginmodule(tolua_S,"ArmatureData"); tolua_function(tolua_S,"addBoneData",lua_cocos2dx_studio_ArmatureData_addBoneData); tolua_function(tolua_S,"init",lua_cocos2dx_studio_ArmatureData_init); tolua_function(tolua_S,"getBoneData",lua_cocos2dx_studio_ArmatureData_getBoneData); tolua_function(tolua_S,"new",lua_cocos2dx_studio_ArmatureData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ArmatureData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ArmatureData).name(); g_luaType[typeName] = "ccs.ArmatureData"; g_typeCast["ArmatureData"] = "ccs.ArmatureData"; return 1; } int lua_cocos2dx_studio_FrameData_copy(lua_State* tolua_S) { int argc = 0; cocostudio::FrameData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.FrameData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::FrameData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_FrameData_copy'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const cocostudio::BaseData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.BaseData",0)){ ok = false; break; } if (ok){ arg0 = (const cocostudio::BaseData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->copy(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "copy",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_FrameData_copy'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_FrameData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.FrameData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::FrameData* ret = cocostudio::FrameData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.FrameData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::FrameData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_FrameData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_FrameData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::FrameData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::FrameData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.FrameData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.FrameData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "FrameData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_FrameData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_FrameData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (FrameData)"); return 0; } int lua_register_cocos2dx_studio_FrameData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.FrameData"); tolua_cclass(tolua_S,"FrameData","ccs.FrameData","ccs.BaseData",NULL); tolua_beginmodule(tolua_S,"FrameData"); tolua_function(tolua_S,"copy",lua_cocos2dx_studio_FrameData_copy); tolua_function(tolua_S,"new",lua_cocos2dx_studio_FrameData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_FrameData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::FrameData).name(); g_luaType[typeName] = "ccs.FrameData"; g_typeCast["FrameData"] = "ccs.FrameData"; return 1; } int lua_cocos2dx_studio_MovementBoneData_init(lua_State* tolua_S) { int argc = 0; cocostudio::MovementBoneData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.MovementBoneData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::MovementBoneData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_MovementBoneData_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementBoneData_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_MovementBoneData_getFrameData(lua_State* tolua_S) { int argc = 0; cocostudio::MovementBoneData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.MovementBoneData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::MovementBoneData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_MovementBoneData_getFrameData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocostudio::FrameData* ret = cobj->getFrameData(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.FrameData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::FrameData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFrameData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementBoneData_getFrameData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_MovementBoneData_addFrameData(lua_State* tolua_S) { int argc = 0; cocostudio::MovementBoneData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.MovementBoneData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::MovementBoneData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_MovementBoneData_addFrameData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::FrameData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.FrameData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::FrameData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addFrameData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addFrameData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementBoneData_addFrameData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_MovementBoneData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.MovementBoneData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::MovementBoneData* ret = cocostudio::MovementBoneData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.MovementBoneData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::MovementBoneData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementBoneData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_MovementBoneData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::MovementBoneData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::MovementBoneData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.MovementBoneData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.MovementBoneData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "MovementBoneData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementBoneData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_MovementBoneData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MovementBoneData)"); return 0; } int lua_register_cocos2dx_studio_MovementBoneData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.MovementBoneData"); tolua_cclass(tolua_S,"MovementBoneData","ccs.MovementBoneData","",NULL); tolua_beginmodule(tolua_S,"MovementBoneData"); tolua_function(tolua_S,"init",lua_cocos2dx_studio_MovementBoneData_init); tolua_function(tolua_S,"getFrameData",lua_cocos2dx_studio_MovementBoneData_getFrameData); tolua_function(tolua_S,"addFrameData",lua_cocos2dx_studio_MovementBoneData_addFrameData); tolua_function(tolua_S,"new",lua_cocos2dx_studio_MovementBoneData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_MovementBoneData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::MovementBoneData).name(); g_luaType[typeName] = "ccs.MovementBoneData"; g_typeCast["MovementBoneData"] = "ccs.MovementBoneData"; return 1; } int lua_cocos2dx_studio_MovementData_getMovementBoneData(lua_State* tolua_S) { int argc = 0; cocostudio::MovementData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.MovementData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::MovementData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_MovementData_getMovementBoneData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocostudio::MovementBoneData* ret = cobj->getMovementBoneData(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.MovementBoneData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::MovementBoneData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMovementBoneData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementData_getMovementBoneData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_MovementData_addMovementBoneData(lua_State* tolua_S) { int argc = 0; cocostudio::MovementData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.MovementData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::MovementData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_MovementData_addMovementBoneData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::MovementBoneData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.MovementBoneData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::MovementBoneData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addMovementBoneData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addMovementBoneData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementData_addMovementBoneData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_MovementData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.MovementData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::MovementData* ret = cocostudio::MovementData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.MovementData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::MovementData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_MovementData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::MovementData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::MovementData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.MovementData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.MovementData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "MovementData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_MovementData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_MovementData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (MovementData)"); return 0; } int lua_register_cocos2dx_studio_MovementData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.MovementData"); tolua_cclass(tolua_S,"MovementData","ccs.MovementData","",NULL); tolua_beginmodule(tolua_S,"MovementData"); tolua_function(tolua_S,"getMovementBoneData",lua_cocos2dx_studio_MovementData_getMovementBoneData); tolua_function(tolua_S,"addMovementBoneData",lua_cocos2dx_studio_MovementData_addMovementBoneData); tolua_function(tolua_S,"new",lua_cocos2dx_studio_MovementData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_MovementData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::MovementData).name(); g_luaType[typeName] = "ccs.MovementData"; g_typeCast["MovementData"] = "ccs.MovementData"; return 1; } int lua_cocos2dx_studio_AnimationData_getMovement(lua_State* tolua_S) { int argc = 0; cocostudio::AnimationData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.AnimationData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::AnimationData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_AnimationData_getMovement'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocostudio::MovementData* ret = cobj->getMovement(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.MovementData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::MovementData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMovement",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_AnimationData_getMovement'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_AnimationData_getMovementCount(lua_State* tolua_S) { int argc = 0; cocostudio::AnimationData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.AnimationData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::AnimationData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_AnimationData_getMovementCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getMovementCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMovementCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_AnimationData_getMovementCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_AnimationData_addMovement(lua_State* tolua_S) { int argc = 0; cocostudio::AnimationData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.AnimationData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::AnimationData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_AnimationData_addMovement'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::MovementData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.MovementData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::MovementData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addMovement(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addMovement",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_AnimationData_addMovement'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_AnimationData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.AnimationData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::AnimationData* ret = cocostudio::AnimationData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.AnimationData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::AnimationData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_AnimationData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_AnimationData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::AnimationData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::AnimationData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.AnimationData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.AnimationData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "AnimationData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_AnimationData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_AnimationData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (AnimationData)"); return 0; } int lua_register_cocos2dx_studio_AnimationData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.AnimationData"); tolua_cclass(tolua_S,"AnimationData","ccs.AnimationData","",NULL); tolua_beginmodule(tolua_S,"AnimationData"); tolua_function(tolua_S,"getMovement",lua_cocos2dx_studio_AnimationData_getMovement); tolua_function(tolua_S,"getMovementCount",lua_cocos2dx_studio_AnimationData_getMovementCount); tolua_function(tolua_S,"addMovement",lua_cocos2dx_studio_AnimationData_addMovement); tolua_function(tolua_S,"new",lua_cocos2dx_studio_AnimationData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_AnimationData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::AnimationData).name(); g_luaType[typeName] = "ccs.AnimationData"; g_typeCast["AnimationData"] = "ccs.AnimationData"; return 1; } int lua_cocos2dx_studio_ContourData_init(lua_State* tolua_S) { int argc = 0; cocostudio::ContourData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ContourData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ContourData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ContourData_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ContourData_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ContourData_addVertex(lua_State* tolua_S) { int argc = 0; cocostudio::ContourData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ContourData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ContourData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ContourData_addVertex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if(!ok) return 0; cobj->addVertex(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addVertex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ContourData_addVertex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ContourData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ContourData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ContourData* ret = cocostudio::ContourData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ContourData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ContourData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ContourData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ContourData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::ContourData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::ContourData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.ContourData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.ContourData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ContourData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ContourData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ContourData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ContourData)"); return 0; } int lua_register_cocos2dx_studio_ContourData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ContourData"); tolua_cclass(tolua_S,"ContourData","ccs.ContourData","",NULL); tolua_beginmodule(tolua_S,"ContourData"); tolua_function(tolua_S,"init",lua_cocos2dx_studio_ContourData_init); tolua_function(tolua_S,"addVertex",lua_cocos2dx_studio_ContourData_addVertex); tolua_function(tolua_S,"new",lua_cocos2dx_studio_ContourData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ContourData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ContourData).name(); g_luaType[typeName] = "ccs.ContourData"; g_typeCast["ContourData"] = "ccs.ContourData"; return 1; } int lua_cocos2dx_studio_TextureData_getContourData(lua_State* tolua_S) { int argc = 0; cocostudio::TextureData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.TextureData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::TextureData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_TextureData_getContourData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocostudio::ContourData* ret = cobj->getContourData(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ContourData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ContourData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContourData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_TextureData_getContourData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_TextureData_init(lua_State* tolua_S) { int argc = 0; cocostudio::TextureData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.TextureData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::TextureData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_TextureData_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_TextureData_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_TextureData_addContourData(lua_State* tolua_S) { int argc = 0; cocostudio::TextureData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.TextureData",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::TextureData*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_TextureData_addContourData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::ContourData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.ContourData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::ContourData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addContourData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addContourData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_TextureData_addContourData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_TextureData_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.TextureData",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::TextureData* ret = cocostudio::TextureData::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.TextureData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::TextureData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_TextureData_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_TextureData_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::TextureData* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::TextureData(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.TextureData"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.TextureData"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "TextureData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_TextureData_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_TextureData_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (TextureData)"); return 0; } int lua_register_cocos2dx_studio_TextureData(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.TextureData"); tolua_cclass(tolua_S,"TextureData","ccs.TextureData","",NULL); tolua_beginmodule(tolua_S,"TextureData"); tolua_function(tolua_S,"getContourData",lua_cocos2dx_studio_TextureData_getContourData); tolua_function(tolua_S,"init",lua_cocos2dx_studio_TextureData_init); tolua_function(tolua_S,"addContourData",lua_cocos2dx_studio_TextureData_addContourData); tolua_function(tolua_S,"new",lua_cocos2dx_studio_TextureData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_TextureData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::TextureData).name(); g_luaType[typeName] = "ccs.TextureData"; g_typeCast["TextureData"] = "ccs.TextureData"; return 1; } int lua_cocos2dx_studio_Tween_getAnimation(lua_State* tolua_S) { int argc = 0; cocostudio::Tween* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Tween",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Tween*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Tween_getAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::ArmatureAnimation* ret = cobj->getAnimation(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ArmatureAnimation"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ArmatureAnimation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Tween_getAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Tween_gotoAndPause(lua_State* tolua_S) { int argc = 0; cocostudio::Tween* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Tween",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Tween*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Tween_gotoAndPause'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->gotoAndPause(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "gotoAndPause",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Tween_gotoAndPause'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Tween_play(lua_State* tolua_S) { int argc = 0; cocostudio::Tween* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Tween",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Tween*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Tween_play'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 5) { cocostudio::MovementBoneData* arg0; int arg1; int arg2; int arg3; int arg4; do { if (!luaval_is_usertype(tolua_S,2,"ccs.MovementBoneData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::MovementBoneData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); if(!ok) return 0; cobj->play(arg0, arg1, arg2, arg3, arg4); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "play",argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Tween_play'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Tween_gotoAndPlay(lua_State* tolua_S) { int argc = 0; cocostudio::Tween* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Tween",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Tween*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Tween_gotoAndPlay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->gotoAndPlay(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "gotoAndPlay",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Tween_gotoAndPlay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Tween_init(lua_State* tolua_S) { int argc = 0; cocostudio::Tween* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Tween",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Tween*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Tween_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Bone* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->init(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Tween_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Tween_setAnimation(lua_State* tolua_S) { int argc = 0; cocostudio::Tween* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Tween",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Tween*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Tween_setAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::ArmatureAnimation* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.ArmatureAnimation",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setAnimation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Tween_setAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Tween_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.Tween",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocostudio::Bone* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocostudio::Tween* ret = cocostudio::Tween::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Tween"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Tween*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Tween_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Tween_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::Tween* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::Tween(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.Tween"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.Tween"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Tween",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Tween_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_Tween_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Tween)"); return 0; } int lua_register_cocos2dx_studio_Tween(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.Tween"); tolua_cclass(tolua_S,"Tween","ccs.Tween","",NULL); tolua_beginmodule(tolua_S,"Tween"); tolua_function(tolua_S,"getAnimation",lua_cocos2dx_studio_Tween_getAnimation); tolua_function(tolua_S,"gotoAndPause",lua_cocos2dx_studio_Tween_gotoAndPause); tolua_function(tolua_S,"play",lua_cocos2dx_studio_Tween_play); tolua_function(tolua_S,"gotoAndPlay",lua_cocos2dx_studio_Tween_gotoAndPlay); tolua_function(tolua_S,"init",lua_cocos2dx_studio_Tween_init); tolua_function(tolua_S,"setAnimation",lua_cocos2dx_studio_Tween_setAnimation); tolua_function(tolua_S,"new",lua_cocos2dx_studio_Tween_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_Tween_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::Tween).name(); g_luaType[typeName] = "ccs.Tween"; g_typeCast["Tween"] = "ccs.Tween"; return 1; } int lua_cocos2dx_studio_DisplayManager_getDisplayRenderNode(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_getDisplayRenderNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getDisplayRenderNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayRenderNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_getDisplayRenderNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_getAnchorPointInPoints(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_getAnchorPointInPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getAnchorPointInPoints(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchorPointInPoints",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_getAnchorPointInPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getDisplayRenderNodeType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayRenderNodeType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_removeDisplay(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_removeDisplay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->removeDisplay(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeDisplay",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_removeDisplay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_setForceChangeDisplay(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_setForceChangeDisplay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setForceChangeDisplay(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setForceChangeDisplay",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_setForceChangeDisplay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_init(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Bone* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->init(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_getContentSize(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_getContentSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Size ret = cobj->getContentSize(); size_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getContentSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_getContentSize'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_getBoundingBox(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_getBoundingBox'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Rect ret = cobj->getBoundingBox(); rect_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBoundingBox",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_getBoundingBox'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_addDisplay(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_addDisplay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cobj->addDisplay(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 2) { cocostudio::DisplayData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.DisplayData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::DisplayData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cobj->addDisplay(arg0, arg1); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDisplay",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_addDisplay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_containPoint(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_containPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if (!ok) { break; } double arg1; ok &= luaval_to_number(tolua_S, 3,&arg1); if (!ok) { break; } bool ret = cobj->containPoint(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 1) { cocos2d::Point arg0; ok &= luaval_to_point(tolua_S, 2, &arg0); if (!ok) { break; } bool ret = cobj->containPoint(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "containPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_containPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_changeDisplayWithIndex(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_changeDisplayWithIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; bool arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->changeDisplayWithIndex(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "changeDisplayWithIndex",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_changeDisplayWithIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_changeDisplayWithName(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_changeDisplayWithName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; bool arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->changeDisplayWithName(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "changeDisplayWithName",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_changeDisplayWithName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_isForceChangeDisplay(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_isForceChangeDisplay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isForceChangeDisplay(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isForceChangeDisplay",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_isForceChangeDisplay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = cobj->getCurrentDisplayIndex(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentDisplayIndex",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_getAnchorPoint(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_getAnchorPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Point ret = cobj->getAnchorPoint(); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnchorPoint",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_getAnchorPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_getDecorativeDisplayList(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_getDecorativeDisplayList'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Vector& ret = cobj->getDecorativeDisplayList(); ccvector_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDecorativeDisplayList",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_getDecorativeDisplayList'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_isVisible(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_isVisible'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isVisible(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isVisible",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_isVisible'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_setVisible(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::DisplayManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_DisplayManager_setVisible'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setVisible(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVisible",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_setVisible'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.DisplayManager",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocostudio::Bone* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocostudio::DisplayManager* ret = cocostudio::DisplayManager::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.DisplayManager"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::DisplayManager*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_DisplayManager_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::DisplayManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::DisplayManager(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.DisplayManager"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.DisplayManager"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "DisplayManager",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_DisplayManager_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_DisplayManager_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (DisplayManager)"); return 0; } int lua_register_cocos2dx_studio_DisplayManager(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.DisplayManager"); tolua_cclass(tolua_S,"DisplayManager","ccs.DisplayManager","",NULL); tolua_beginmodule(tolua_S,"DisplayManager"); tolua_function(tolua_S,"getDisplayRenderNode",lua_cocos2dx_studio_DisplayManager_getDisplayRenderNode); tolua_function(tolua_S,"getAnchorPointInPoints",lua_cocos2dx_studio_DisplayManager_getAnchorPointInPoints); tolua_function(tolua_S,"getDisplayRenderNodeType",lua_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType); tolua_function(tolua_S,"removeDisplay",lua_cocos2dx_studio_DisplayManager_removeDisplay); tolua_function(tolua_S,"setForceChangeDisplay",lua_cocos2dx_studio_DisplayManager_setForceChangeDisplay); tolua_function(tolua_S,"init",lua_cocos2dx_studio_DisplayManager_init); tolua_function(tolua_S,"getContentSize",lua_cocos2dx_studio_DisplayManager_getContentSize); tolua_function(tolua_S,"getBoundingBox",lua_cocos2dx_studio_DisplayManager_getBoundingBox); tolua_function(tolua_S,"addDisplay",lua_cocos2dx_studio_DisplayManager_addDisplay); tolua_function(tolua_S,"containPoint",lua_cocos2dx_studio_DisplayManager_containPoint); tolua_function(tolua_S,"changeDisplayWithIndex",lua_cocos2dx_studio_DisplayManager_changeDisplayWithIndex); tolua_function(tolua_S,"changeDisplayWithName",lua_cocos2dx_studio_DisplayManager_changeDisplayWithName); tolua_function(tolua_S,"isForceChangeDisplay",lua_cocos2dx_studio_DisplayManager_isForceChangeDisplay); tolua_function(tolua_S,"getCurrentDisplayIndex",lua_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex); tolua_function(tolua_S,"getAnchorPoint",lua_cocos2dx_studio_DisplayManager_getAnchorPoint); tolua_function(tolua_S,"getDecorativeDisplayList",lua_cocos2dx_studio_DisplayManager_getDecorativeDisplayList); tolua_function(tolua_S,"isVisible",lua_cocos2dx_studio_DisplayManager_isVisible); tolua_function(tolua_S,"setVisible",lua_cocos2dx_studio_DisplayManager_setVisible); tolua_function(tolua_S,"new",lua_cocos2dx_studio_DisplayManager_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_DisplayManager_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::DisplayManager).name(); g_luaType[typeName] = "ccs.DisplayManager"; g_typeCast["DisplayManager"] = "ccs.DisplayManager"; return 1; } int lua_cocos2dx_studio_Bone_isTransformDirty(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_isTransformDirty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isTransformDirty(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isTransformDirty",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_isTransformDirty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_isIgnoreMovementBoneData(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_isIgnoreMovementBoneData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isIgnoreMovementBoneData(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isIgnoreMovementBoneData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_isIgnoreMovementBoneData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_updateZOrder(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_updateZOrder'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateZOrder(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateZOrder",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_updateZOrder'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getDisplayRenderNode(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getDisplayRenderNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getDisplayRenderNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayRenderNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getDisplayRenderNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_isBlendDirty(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_isBlendDirty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isBlendDirty(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isBlendDirty",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_isBlendDirty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_addChildBone(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_addChildBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Bone* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addChildBone(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addChildBone",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_addChildBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getWorldInfo(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getWorldInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::BaseData* ret = cobj->getWorldInfo(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.BaseData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::BaseData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWorldInfo",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getWorldInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getTween(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getTween'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::Tween* ret = cobj->getTween(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Tween"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Tween*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTween",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getTween'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getParentBone(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getParentBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::Bone* ret = cobj->getParentBone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Bone"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Bone*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParentBone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getParentBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_updateColor(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_updateColor'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateColor(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateColor",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_updateColor'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getName(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string ret = cobj->getName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_setTransformDirty(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_setTransformDirty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setTransformDirty(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTransformDirty",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_setTransformDirty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getDisplayRenderNodeType(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getDisplayRenderNodeType'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; int ret = (int)cobj->getDisplayRenderNodeType(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayRenderNodeType",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getDisplayRenderNodeType'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_removeDisplay(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_removeDisplay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->removeDisplay(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeDisplay",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_removeDisplay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_setBoneData(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_setBoneData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::BoneData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.BoneData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::BoneData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBoneData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBoneData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_setBoneData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_init(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } bool ret = cobj->init(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_setParentBone(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_setParentBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Bone* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setParentBone(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setParentBone",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_setParentBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_addDisplay(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_addDisplay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 2) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cobj->addDisplay(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 2) { cocostudio::DisplayData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.DisplayData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::DisplayData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } int arg1; ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if (!ok) { break; } cobj->addDisplay(arg0, arg1); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addDisplay",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_addDisplay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_setName(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_setName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_setName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_removeFromParent(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_removeFromParent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeFromParent(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeFromParent",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_removeFromParent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getColliderDetector(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getColliderDetector'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::ColliderDetector* ret = cobj->getColliderDetector(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ColliderDetector"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ColliderDetector*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getColliderDetector",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getColliderDetector'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getChildArmature(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getChildArmature'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::Armature* ret = cobj->getChildArmature(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Armature"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Armature*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getChildArmature",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getChildArmature'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getTweenData(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getTweenData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::FrameData* ret = cobj->getTweenData(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.FrameData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::FrameData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTweenData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getTweenData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_changeDisplayWithIndex(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_changeDisplayWithIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { int arg0; bool arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->changeDisplayWithIndex(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "changeDisplayWithIndex",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_changeDisplayWithIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_changeDisplayWithName(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_changeDisplayWithName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; bool arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->changeDisplayWithName(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "changeDisplayWithName",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_changeDisplayWithName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_setArmature(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_setArmature'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Armature* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Armature",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Armature*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setArmature(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setArmature",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_setArmature'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_setBlendDirty(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_setBlendDirty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBlendDirty(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBlendDirty",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_setBlendDirty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_removeChildBone(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_removeChildBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocostudio::Bone* arg0; bool arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->removeChildBone(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeChildBone",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_removeChildBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_setChildArmature(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_setChildArmature'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Armature* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Armature",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Armature*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setChildArmature(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setChildArmature",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_setChildArmature'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getNodeToArmatureTransform(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getNodeToArmatureTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; kmMat4 ret = cobj->getNodeToArmatureTransform(); #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeToArmatureTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getNodeToArmatureTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getDisplayManager(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getDisplayManager'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::DisplayManager* ret = cobj->getDisplayManager(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.DisplayManager"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::DisplayManager*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayManager",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getDisplayManager'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getArmature(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getArmature'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::Armature* ret = cobj->getArmature(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Armature"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Armature*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getArmature",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getArmature'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_getBoneData(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getBoneData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::BoneData* ret = cobj->getBoneData(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.BoneData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::BoneData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBoneData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getBoneData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocostudio::Bone* ret = cocostudio::Bone::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Bone"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Bone*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocostudio::Bone* ret = cocostudio::Bone::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Bone"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Bone*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Bone_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::Bone* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::Bone(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.Bone"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.Bone"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Bone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_Bone_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Bone)"); return 0; } int lua_register_cocos2dx_studio_Bone(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.Bone"); tolua_cclass(tolua_S,"Bone","ccs.Bone","cc.Node",NULL); tolua_beginmodule(tolua_S,"Bone"); tolua_function(tolua_S,"isTransformDirty",lua_cocos2dx_studio_Bone_isTransformDirty); tolua_function(tolua_S,"isIgnoreMovementBoneData",lua_cocos2dx_studio_Bone_isIgnoreMovementBoneData); tolua_function(tolua_S,"updateZOrder",lua_cocos2dx_studio_Bone_updateZOrder); tolua_function(tolua_S,"getDisplayRenderNode",lua_cocos2dx_studio_Bone_getDisplayRenderNode); tolua_function(tolua_S,"isBlendDirty",lua_cocos2dx_studio_Bone_isBlendDirty); tolua_function(tolua_S,"addChildBone",lua_cocos2dx_studio_Bone_addChildBone); tolua_function(tolua_S,"getWorldInfo",lua_cocos2dx_studio_Bone_getWorldInfo); tolua_function(tolua_S,"getTween",lua_cocos2dx_studio_Bone_getTween); tolua_function(tolua_S,"getParentBone",lua_cocos2dx_studio_Bone_getParentBone); tolua_function(tolua_S,"updateColor",lua_cocos2dx_studio_Bone_updateColor); tolua_function(tolua_S,"getName",lua_cocos2dx_studio_Bone_getName); tolua_function(tolua_S,"setTransformDirty",lua_cocos2dx_studio_Bone_setTransformDirty); tolua_function(tolua_S,"getDisplayRenderNodeType",lua_cocos2dx_studio_Bone_getDisplayRenderNodeType); tolua_function(tolua_S,"removeDisplay",lua_cocos2dx_studio_Bone_removeDisplay); tolua_function(tolua_S,"setBoneData",lua_cocos2dx_studio_Bone_setBoneData); tolua_function(tolua_S,"init",lua_cocos2dx_studio_Bone_init); tolua_function(tolua_S,"setParentBone",lua_cocos2dx_studio_Bone_setParentBone); tolua_function(tolua_S,"addDisplay",lua_cocos2dx_studio_Bone_addDisplay); tolua_function(tolua_S,"setName",lua_cocos2dx_studio_Bone_setName); tolua_function(tolua_S,"removeFromParent",lua_cocos2dx_studio_Bone_removeFromParent); tolua_function(tolua_S,"getColliderDetector",lua_cocos2dx_studio_Bone_getColliderDetector); tolua_function(tolua_S,"getChildArmature",lua_cocos2dx_studio_Bone_getChildArmature); tolua_function(tolua_S,"getTweenData",lua_cocos2dx_studio_Bone_getTweenData); tolua_function(tolua_S,"changeDisplayWithIndex",lua_cocos2dx_studio_Bone_changeDisplayWithIndex); tolua_function(tolua_S,"changeDisplayWithName",lua_cocos2dx_studio_Bone_changeDisplayWithName); tolua_function(tolua_S,"setArmature",lua_cocos2dx_studio_Bone_setArmature); tolua_function(tolua_S,"setBlendDirty",lua_cocos2dx_studio_Bone_setBlendDirty); tolua_function(tolua_S,"removeChildBone",lua_cocos2dx_studio_Bone_removeChildBone); tolua_function(tolua_S,"setChildArmature",lua_cocos2dx_studio_Bone_setChildArmature); tolua_function(tolua_S,"getNodeToArmatureTransform",lua_cocos2dx_studio_Bone_getNodeToArmatureTransform); tolua_function(tolua_S,"getDisplayManager",lua_cocos2dx_studio_Bone_getDisplayManager); tolua_function(tolua_S,"getArmature",lua_cocos2dx_studio_Bone_getArmature); tolua_function(tolua_S,"getBoneData",lua_cocos2dx_studio_Bone_getBoneData); tolua_function(tolua_S,"new",lua_cocos2dx_studio_Bone_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_Bone_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::Bone).name(); g_luaType[typeName] = "ccs.Bone"; g_typeCast["Bone"] = "ccs.Bone"; return 1; } int lua_cocos2dx_studio_BatchNode_init(lua_State* tolua_S) { int argc = 0; cocostudio::BatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.BatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::BatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_BatchNode_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BatchNode_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_BatchNode_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.BatchNode",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::BatchNode* ret = cocostudio::BatchNode::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.BatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::BatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_BatchNode_create'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_BatchNode_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (BatchNode)"); return 0; } int lua_register_cocos2dx_studio_BatchNode(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.BatchNode"); tolua_cclass(tolua_S,"BatchNode","ccs.BatchNode","cc.Node",NULL); tolua_beginmodule(tolua_S,"BatchNode"); tolua_function(tolua_S,"init",lua_cocos2dx_studio_BatchNode_init); tolua_function(tolua_S,"create", lua_cocos2dx_studio_BatchNode_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::BatchNode).name(); g_luaType[typeName] = "ccs.BatchNode"; g_typeCast["BatchNode"] = "ccs.BatchNode"; return 1; } int lua_cocos2dx_studio_ArmatureAnimation_getSpeedScale(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_getSpeedScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getSpeedScale(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSpeedScale",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_getSpeedScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_pause(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_pause'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pause(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pause",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_pause'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_setSpeedScale(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_setSpeedScale'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setSpeedScale(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSpeedScale",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_setSpeedScale'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_init(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Armature* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Armature",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Armature*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; bool ret = cobj->init(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_playWithIndexes(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_playWithIndexes'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::vector arg0; ok &= luaval_to_std_vector_int(tolua_S, 2, &arg0); if(!ok) return 0; cobj->playWithIndexes(arg0); return 0; } if (argc == 2) { std::vector arg0; int arg1; ok &= luaval_to_std_vector_int(tolua_S, 2, &arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->playWithIndexes(arg0, arg1); return 0; } if (argc == 3) { std::vector arg0; int arg1; bool arg2; ok &= luaval_to_std_vector_int(tolua_S, 2, &arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cobj->playWithIndexes(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "playWithIndexes",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_playWithIndexes'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_play(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_play'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->play(arg0); return 0; } if (argc == 2) { std::string arg0; int arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->play(arg0, arg1); return 0; } if (argc == 3) { std::string arg0; int arg1; int arg2; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if(!ok) return 0; cobj->play(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "play",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_play'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_gotoAndPause(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_gotoAndPause'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->gotoAndPause(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "gotoAndPause",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_gotoAndPause'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_resume(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_resume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resume(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resume",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_resume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_stop(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_stop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stop(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stop",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_stop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_update(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_update'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->update(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "update",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_update'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_getAnimationData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_getAnimationData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::AnimationData* ret = cobj->getAnimationData(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.AnimationData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::AnimationData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimationData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_getAnimationData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_playWithIndex(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_playWithIndex'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->playWithIndex(arg0); return 0; } if (argc == 2) { int arg0; int arg1; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->playWithIndex(arg0, arg1); return 0; } if (argc == 3) { int arg0; int arg1; int arg2; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); if(!ok) return 0; cobj->playWithIndex(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "playWithIndex",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_playWithIndex'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::string ret = cobj->getCurrentMovementID(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentMovementID",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_setAnimationData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_setAnimationData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::AnimationData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.AnimationData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::AnimationData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setAnimationData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimationData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_setAnimationData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_gotoAndPlay(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_gotoAndPlay'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cobj->gotoAndPlay(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "gotoAndPlay",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_gotoAndPlay'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_playWithNames(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_playWithNames'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::vector arg0; ok &= luaval_to_std_vector_string(tolua_S, 2, &arg0); if(!ok) return 0; cobj->playWithNames(arg0); return 0; } if (argc == 2) { std::vector arg0; int arg1; ok &= luaval_to_std_vector_string(tolua_S, 2, &arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->playWithNames(arg0, arg1); return 0; } if (argc == 3) { std::vector arg0; int arg1; bool arg2; ok &= luaval_to_std_vector_string(tolua_S, 2, &arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); ok &= luaval_to_boolean(tolua_S, 4,&arg2); if(!ok) return 0; cobj->playWithNames(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "playWithNames",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_playWithNames'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_getMovementCount(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureAnimation_getMovementCount'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; ssize_t ret = cobj->getMovementCount(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getMovementCount",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_getMovementCount'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocostudio::Armature* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Armature",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Armature*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cocostudio::ArmatureAnimation* ret = cocostudio::ArmatureAnimation::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ArmatureAnimation"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ArmatureAnimation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureAnimation_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureAnimation* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::ArmatureAnimation(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.ArmatureAnimation"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.ArmatureAnimation"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ArmatureAnimation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureAnimation_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ArmatureAnimation_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ArmatureAnimation)"); return 0; } int lua_register_cocos2dx_studio_ArmatureAnimation(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ArmatureAnimation"); tolua_cclass(tolua_S,"ArmatureAnimation","ccs.ArmatureAnimation","",NULL); tolua_beginmodule(tolua_S,"ArmatureAnimation"); tolua_function(tolua_S,"getSpeedScale",lua_cocos2dx_studio_ArmatureAnimation_getSpeedScale); tolua_function(tolua_S,"pause",lua_cocos2dx_studio_ArmatureAnimation_pause); tolua_function(tolua_S,"setSpeedScale",lua_cocos2dx_studio_ArmatureAnimation_setSpeedScale); tolua_function(tolua_S,"init",lua_cocos2dx_studio_ArmatureAnimation_init); tolua_function(tolua_S,"playWithIndexes",lua_cocos2dx_studio_ArmatureAnimation_playWithIndexes); tolua_function(tolua_S,"play",lua_cocos2dx_studio_ArmatureAnimation_play); tolua_function(tolua_S,"gotoAndPause",lua_cocos2dx_studio_ArmatureAnimation_gotoAndPause); tolua_function(tolua_S,"resume",lua_cocos2dx_studio_ArmatureAnimation_resume); tolua_function(tolua_S,"stop",lua_cocos2dx_studio_ArmatureAnimation_stop); tolua_function(tolua_S,"update",lua_cocos2dx_studio_ArmatureAnimation_update); tolua_function(tolua_S,"getAnimationData",lua_cocos2dx_studio_ArmatureAnimation_getAnimationData); tolua_function(tolua_S,"playWithIndex",lua_cocos2dx_studio_ArmatureAnimation_playWithIndex); tolua_function(tolua_S,"getCurrentMovementID",lua_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID); tolua_function(tolua_S,"setAnimationData",lua_cocos2dx_studio_ArmatureAnimation_setAnimationData); tolua_function(tolua_S,"gotoAndPlay",lua_cocos2dx_studio_ArmatureAnimation_gotoAndPlay); tolua_function(tolua_S,"playWithNames",lua_cocos2dx_studio_ArmatureAnimation_playWithNames); tolua_function(tolua_S,"getMovementCount",lua_cocos2dx_studio_ArmatureAnimation_getMovementCount); tolua_function(tolua_S,"new",lua_cocos2dx_studio_ArmatureAnimation_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ArmatureAnimation_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ArmatureAnimation).name(); g_luaType[typeName] = "ccs.ArmatureAnimation"; g_typeCast["ArmatureAnimation"] = "ccs.ArmatureAnimation"; return 1; } int lua_cocos2dx_studio_ArmatureDataManager_getAnimationDatas(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_getAnimationDatas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Map& ret = cobj->getAnimationDatas(); ccmap_string_key_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimationDatas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_getAnimationDatas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_removeAnimationData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_removeAnimationData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeAnimationData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAnimationData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_removeAnimationData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_addArmatureData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_addArmatureData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; cocostudio::ArmatureData* arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"ccs.ArmatureData",0)){ ok = false; break; } if (ok){ arg1 = (cocostudio::ArmatureData*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addArmatureData(arg0, arg1); return 0; } if (argc == 3) { std::string arg0; cocostudio::ArmatureData* arg1; std::string arg2; ok &= luaval_to_std_string(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"ccs.ArmatureData",0)){ ok = false; break; } if (ok){ arg1 = (cocostudio::ArmatureData*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 4,&arg2); if(!ok) return 0; cobj->addArmatureData(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addArmatureData",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_addArmatureData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 3) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3,&arg1); if (!ok) { break; } std::string arg2; ok &= luaval_to_std_string(tolua_S, 4,&arg2); if (!ok) { break; } cobj->addArmatureFileInfo(arg0, arg1, arg2); return 0; } }while(0); ok = true; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cobj->addArmatureFileInfo(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addArmatureFileInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeArmatureFileInfo(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeArmatureFileInfo",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_getTextureDatas(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_getTextureDatas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Map& ret = cobj->getTextureDatas(); ccmap_string_key_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureDatas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_getTextureDatas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_getTextureData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_getTextureData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocostudio::TextureData* ret = cobj->getTextureData(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.TextureData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::TextureData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTextureData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_getTextureData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_getArmatureData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_getArmatureData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocostudio::ArmatureData* ret = cobj->getArmatureData(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ArmatureData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ArmatureData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getArmatureData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_getArmatureData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_getAnimationData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_getAnimationData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocostudio::AnimationData* ret = cobj->getAnimationData(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.AnimationData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::AnimationData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimationData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_getAnimationData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_addAnimationData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_addAnimationData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; cocostudio::AnimationData* arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"ccs.AnimationData",0)){ ok = false; break; } if (ok){ arg1 = (cocostudio::AnimationData*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addAnimationData(arg0, arg1); return 0; } if (argc == 3) { std::string arg0; cocostudio::AnimationData* arg1; std::string arg2; ok &= luaval_to_std_string(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"ccs.AnimationData",0)){ ok = false; break; } if (ok){ arg1 = (cocostudio::AnimationData*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 4,&arg2); if(!ok) return 0; cobj->addAnimationData(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addAnimationData",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_addAnimationData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_init(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_removeArmatureData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_removeArmatureData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeArmatureData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeArmatureData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_removeArmatureData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_getArmatureDatas(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_getArmatureDatas'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Map& ret = cobj->getArmatureDatas(); ccmap_string_key_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getArmatureDatas",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_getArmatureDatas'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_removeTextureData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_removeTextureData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->removeTextureData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeTextureData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_removeTextureData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_addTextureData(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_addTextureData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; cocostudio::TextureData* arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"ccs.TextureData",0)){ ok = false; break; } if (ok){ arg1 = (cocostudio::TextureData*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->addTextureData(arg0, arg1); return 0; } if (argc == 3) { std::string arg0; cocostudio::TextureData* arg1; std::string arg2; ok &= luaval_to_std_string(tolua_S, 2,&arg0); do { if (!luaval_is_usertype(tolua_S,3,"ccs.TextureData",0)){ ok = false; break; } if (ok){ arg1 = (cocostudio::TextureData*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 4,&arg2); if(!ok) return 0; cobj->addTextureData(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addTextureData",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_addTextureData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isAutoLoadSpriteFile(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isAutoLoadSpriteFile",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile(lua_State* tolua_S) { int argc = 0; cocostudio::ArmatureDataManager* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ArmatureDataManager*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->addSpriteFrameFromFile(arg0, arg1); return 0; } if (argc == 3) { std::string arg0; std::string arg1; std::string arg2; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); ok &= luaval_to_std_string(tolua_S, 4,&arg2); if(!ok) return 0; cobj->addSpriteFrameFromFile(arg0, arg1, arg2); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSpriteFrameFromFile",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ArmatureDataManager::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ArmatureDataManager_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ArmatureDataManager* ret = cocostudio::ArmatureDataManager::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ArmatureDataManager"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ArmatureDataManager*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ArmatureDataManager_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ArmatureDataManager_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ArmatureDataManager)"); return 0; } int lua_register_cocos2dx_studio_ArmatureDataManager(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ArmatureDataManager"); tolua_cclass(tolua_S,"ArmatureDataManager","ccs.ArmatureDataManager","",NULL); tolua_beginmodule(tolua_S,"ArmatureDataManager"); tolua_function(tolua_S,"getAnimationDatas",lua_cocos2dx_studio_ArmatureDataManager_getAnimationDatas); tolua_function(tolua_S,"removeAnimationData",lua_cocos2dx_studio_ArmatureDataManager_removeAnimationData); tolua_function(tolua_S,"addArmatureData",lua_cocos2dx_studio_ArmatureDataManager_addArmatureData); tolua_function(tolua_S,"addArmatureFileInfo",lua_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo); tolua_function(tolua_S,"removeArmatureFileInfo",lua_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo); tolua_function(tolua_S,"getTextureDatas",lua_cocos2dx_studio_ArmatureDataManager_getTextureDatas); tolua_function(tolua_S,"getTextureData",lua_cocos2dx_studio_ArmatureDataManager_getTextureData); tolua_function(tolua_S,"getArmatureData",lua_cocos2dx_studio_ArmatureDataManager_getArmatureData); tolua_function(tolua_S,"getAnimationData",lua_cocos2dx_studio_ArmatureDataManager_getAnimationData); tolua_function(tolua_S,"addAnimationData",lua_cocos2dx_studio_ArmatureDataManager_addAnimationData); tolua_function(tolua_S,"init",lua_cocos2dx_studio_ArmatureDataManager_init); tolua_function(tolua_S,"removeArmatureData",lua_cocos2dx_studio_ArmatureDataManager_removeArmatureData); tolua_function(tolua_S,"getArmatureDatas",lua_cocos2dx_studio_ArmatureDataManager_getArmatureDatas); tolua_function(tolua_S,"removeTextureData",lua_cocos2dx_studio_ArmatureDataManager_removeTextureData); tolua_function(tolua_S,"addTextureData",lua_cocos2dx_studio_ArmatureDataManager_addTextureData); tolua_function(tolua_S,"isAutoLoadSpriteFile",lua_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile); tolua_function(tolua_S,"addSpriteFrameFromFile",lua_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_studio_ArmatureDataManager_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_studio_ArmatureDataManager_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ArmatureDataManager).name(); g_luaType[typeName] = "ccs.ArmatureDataManager"; g_typeCast["ArmatureDataManager"] = "ccs.ArmatureDataManager"; return 1; } int lua_cocos2dx_studio_Armature_getBone(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocostudio::Bone* ret = cobj->getBone(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Bone"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Bone*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBone",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_changeBoneParent(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_changeBoneParent'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocostudio::Bone* arg0; std::string arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->changeBoneParent(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "changeBoneParent",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_changeBoneParent'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_setAnimation(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::ArmatureAnimation* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.ArmatureAnimation",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setAnimation(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimation",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getBoneAtPoint(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getBoneAtPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { double arg0; double arg1; ok &= luaval_to_number(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cocostudio::Bone* ret = cobj->getBoneAtPoint(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Bone"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Bone*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBoneAtPoint",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getBoneAtPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getArmatureTransformDirty(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getArmatureTransformDirty'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->getArmatureTransformDirty(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getArmatureTransformDirty",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getArmatureTransformDirty'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_setVersion(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setVersion'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setVersion(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVersion",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setVersion'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_updateOffsetPoint(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_updateOffsetPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateOffsetPoint(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateOffsetPoint",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_updateOffsetPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getParentBone(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getParentBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::Bone* ret = cobj->getParentBone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Bone"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Bone*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParentBone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getParentBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_setArmatureData(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setArmatureData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::ArmatureData* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.ArmatureData",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::ArmatureData*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setArmatureData(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setArmatureData",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setArmatureData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_removeBone(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_removeBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocostudio::Bone* arg0; bool arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->removeBone(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeBone",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_removeBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getBatchNode(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getBatchNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::BatchNode* ret = cobj->getBatchNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.BatchNode"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::BatchNode*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBatchNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getBatchNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getName(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_init(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_init'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } bool ret = cobj->init(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { bool ret = cobj->init(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; do{ if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocostudio::Bone* arg1; do { if (!luaval_is_usertype(tolua_S,3,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg1 = (cocostudio::Bone*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } bool ret = cobj->init(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "init",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_init'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_setParentBone(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setParentBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Bone* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setParentBone(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setParentBone",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setParentBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_drawContour(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_drawContour'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->drawContour(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "drawContour",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_drawContour'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_setBatchNode(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setBatchNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::BatchNode* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.BatchNode",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::BatchNode*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBatchNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBatchNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setBatchNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_setName(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setName(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_addBone(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_addBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { cocostudio::Bone* arg0; std::string arg1; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->addBone(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addBone",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_addBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getArmatureData(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getArmatureData'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::ArmatureData* ret = cobj->getArmatureData(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ArmatureData"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ArmatureData*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getArmatureData",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getArmatureData'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getVersion(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getVersion'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getVersion(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVersion",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getVersion'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getAnimation(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getAnimation'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::ArmatureAnimation* ret = cobj->getAnimation(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ArmatureAnimation"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ArmatureAnimation*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAnimation",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getAnimation'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_getBoneDic(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getBoneDic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const cocos2d::Map& ret = cobj->getBoneDic(); ccmap_string_key_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBoneDic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getBoneDic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocostudio::Armature* ret = cocostudio::Armature::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Armature"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Armature*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocostudio::Armature* ret = cocostudio::Armature::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Armature"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Armature*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 2) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocostudio::Bone* arg1; do { if (!luaval_is_usertype(tolua_S,3,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg1 = (cocostudio::Bone*)tolua_tousertype(tolua_S,3,0); if (nullptr == arg1){ LUA_PRECONDITION( arg1, "Invalid Native Object"); }}} while (0); if (!ok) { break; } cocostudio::Armature* ret = cocostudio::Armature::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Armature"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Armature*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Armature_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::Armature* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::Armature(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.Armature"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.Armature"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Armature",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_Armature_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Armature)"); return 0; } int lua_register_cocos2dx_studio_Armature(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.Armature"); tolua_cclass(tolua_S,"Armature","ccs.Armature","cc.Node",NULL); tolua_beginmodule(tolua_S,"Armature"); tolua_function(tolua_S,"getBone",lua_cocos2dx_studio_Armature_getBone); tolua_function(tolua_S,"changeBoneParent",lua_cocos2dx_studio_Armature_changeBoneParent); tolua_function(tolua_S,"setAnimation",lua_cocos2dx_studio_Armature_setAnimation); tolua_function(tolua_S,"getBoneAtPoint",lua_cocos2dx_studio_Armature_getBoneAtPoint); tolua_function(tolua_S,"getArmatureTransformDirty",lua_cocos2dx_studio_Armature_getArmatureTransformDirty); tolua_function(tolua_S,"setVersion",lua_cocos2dx_studio_Armature_setVersion); tolua_function(tolua_S,"updateOffsetPoint",lua_cocos2dx_studio_Armature_updateOffsetPoint); tolua_function(tolua_S,"getParentBone",lua_cocos2dx_studio_Armature_getParentBone); tolua_function(tolua_S,"setArmatureData",lua_cocos2dx_studio_Armature_setArmatureData); tolua_function(tolua_S,"removeBone",lua_cocos2dx_studio_Armature_removeBone); tolua_function(tolua_S,"getBatchNode",lua_cocos2dx_studio_Armature_getBatchNode); tolua_function(tolua_S,"getName",lua_cocos2dx_studio_Armature_getName); tolua_function(tolua_S,"init",lua_cocos2dx_studio_Armature_init); tolua_function(tolua_S,"setParentBone",lua_cocos2dx_studio_Armature_setParentBone); tolua_function(tolua_S,"drawContour",lua_cocos2dx_studio_Armature_drawContour); tolua_function(tolua_S,"setBatchNode",lua_cocos2dx_studio_Armature_setBatchNode); tolua_function(tolua_S,"setName",lua_cocos2dx_studio_Armature_setName); tolua_function(tolua_S,"addBone",lua_cocos2dx_studio_Armature_addBone); tolua_function(tolua_S,"getArmatureData",lua_cocos2dx_studio_Armature_getArmatureData); tolua_function(tolua_S,"getVersion",lua_cocos2dx_studio_Armature_getVersion); tolua_function(tolua_S,"getAnimation",lua_cocos2dx_studio_Armature_getAnimation); tolua_function(tolua_S,"getBoneDic",lua_cocos2dx_studio_Armature_getBoneDic); tolua_function(tolua_S,"new",lua_cocos2dx_studio_Armature_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_Armature_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::Armature).name(); g_luaType[typeName] = "ccs.Armature"; g_typeCast["Armature"] = "ccs.Armature"; return 1; } int lua_cocos2dx_studio_Skin_getBone(lua_State* tolua_S) { int argc = 0; cocostudio::Skin* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Skin*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Skin_getBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocostudio::Bone* ret = cobj->getBone(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Bone"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Bone*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_getBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_getNodeToWorldTransformAR(lua_State* tolua_S) { int argc = 0; cocostudio::Skin* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Skin*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Skin_getNodeToWorldTransformAR'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; kmMat4 ret = cobj->getNodeToWorldTransformAR(); #pragma warning NO CONVERSION FROM NATIVE FOR kmMat4; return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeToWorldTransformAR",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_getNodeToWorldTransformAR'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_initWithFile(lua_State* tolua_S) { int argc = 0; cocostudio::Skin* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Skin*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Skin_initWithFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->initWithFile(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_initWithFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_getDisplayName(lua_State* tolua_S) { int argc = 0; cocostudio::Skin* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Skin*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Skin_getDisplayName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const std::string& ret = cobj->getDisplayName(); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDisplayName",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_getDisplayName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_updateArmatureTransform(lua_State* tolua_S) { int argc = 0; cocostudio::Skin* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Skin*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Skin_updateArmatureTransform'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->updateArmatureTransform(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateArmatureTransform",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_updateArmatureTransform'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_initWithSpriteFrameName(lua_State* tolua_S) { int argc = 0; cocostudio::Skin* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Skin*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Skin_initWithSpriteFrameName'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->initWithSpriteFrameName(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithSpriteFrameName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_initWithSpriteFrameName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_setBone(lua_State* tolua_S) { int argc = 0; cocostudio::Skin* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::Skin*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Skin_setBone'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocostudio::Bone* arg0; do { if (!luaval_is_usertype(tolua_S,2,"ccs.Bone",0)){ ok = false; break; } if (ok){ arg0 = (cocostudio::Bone*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setBone(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBone",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_setBone'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if (!ok) { break; } cocostudio::Skin* ret = cocostudio::Skin::create(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Skin"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Skin*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocostudio::Skin* ret = cocostudio::Skin::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Skin"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Skin*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_createWithSpriteFrameName(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.Skin",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocostudio::Skin* ret = cocostudio::Skin::createWithSpriteFrameName(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.Skin"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::Skin*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithSpriteFrameName",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_createWithSpriteFrameName'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_Skin_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::Skin* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::Skin(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.Skin"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.Skin"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "Skin",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Skin_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_Skin_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Skin)"); return 0; } int lua_register_cocos2dx_studio_Skin(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.Skin"); tolua_cclass(tolua_S,"Skin","ccs.Skin","cc.Sprite",NULL); tolua_beginmodule(tolua_S,"Skin"); tolua_function(tolua_S,"getBone",lua_cocos2dx_studio_Skin_getBone); tolua_function(tolua_S,"getNodeToWorldTransformAR",lua_cocos2dx_studio_Skin_getNodeToWorldTransformAR); tolua_function(tolua_S,"initWithFile",lua_cocos2dx_studio_Skin_initWithFile); tolua_function(tolua_S,"getDisplayName",lua_cocos2dx_studio_Skin_getDisplayName); tolua_function(tolua_S,"updateArmatureTransform",lua_cocos2dx_studio_Skin_updateArmatureTransform); tolua_function(tolua_S,"initWithSpriteFrameName",lua_cocos2dx_studio_Skin_initWithSpriteFrameName); tolua_function(tolua_S,"setBone",lua_cocos2dx_studio_Skin_setBone); tolua_function(tolua_S,"new",lua_cocos2dx_studio_Skin_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_Skin_create); tolua_function(tolua_S,"createWithSpriteFrameName", lua_cocos2dx_studio_Skin_createWithSpriteFrameName); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::Skin).name(); g_luaType[typeName] = "ccs.Skin"; g_typeCast["Skin"] = "ccs.Skin"; return 1; } int lua_cocos2dx_studio_ComAttribute_getFloat(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_getFloat'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; double ret = cobj->getFloat(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 2) { std::string arg0; double arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; double ret = cobj->getFloat(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFloat",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_getFloat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_getString(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_getString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; std::string ret = cobj->getString(arg0); tolua_pushcppstring(tolua_S,ret); return 1; } if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; std::string ret = cobj->getString(arg0, arg1); tolua_pushcppstring(tolua_S,ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getString",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_getString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_setFloat(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_setFloat'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; double arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_number(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setFloat(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFloat",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_setFloat'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_setString(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_setString'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; std::string arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setString(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setString",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_setString'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_getBool(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_getBool'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->getBool(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } if (argc == 2) { std::string arg0; bool arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; bool ret = cobj->getBool(arg0, arg1); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBool",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_getBool'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_setInt(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_setInt'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; int arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; cobj->setInt(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInt",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_setInt'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_parse(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_parse'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; bool ret = cobj->parse(arg0); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "parse",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_parse'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_getInt(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_getInt'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; int ret = cobj->getInt(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } if (argc == 2) { std::string arg0; int arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); if(!ok) return 0; int ret = cobj->getInt(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInt",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_getInt'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_setBool(lua_State* tolua_S) { int argc = 0; cocostudio::ComAttribute* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAttribute*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAttribute_setBool'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::string arg0; bool arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_boolean(tolua_S, 3,&arg1); if(!ok) return 0; cobj->setBool(arg0, arg1); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBool",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_setBool'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ComAttribute* ret = cocostudio::ComAttribute::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ComAttribute"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ComAttribute*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAttribute_createInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ComAttribute",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Object* ret = cocostudio::ComAttribute::createInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Object"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Object*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAttribute_createInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ComAttribute_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ComAttribute)"); return 0; } int lua_register_cocos2dx_studio_ComAttribute(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ComAttribute"); tolua_cclass(tolua_S,"ComAttribute","ccs.ComAttribute","cc.Component",NULL); tolua_beginmodule(tolua_S,"ComAttribute"); tolua_function(tolua_S,"getFloat",lua_cocos2dx_studio_ComAttribute_getFloat); tolua_function(tolua_S,"getString",lua_cocos2dx_studio_ComAttribute_getString); tolua_function(tolua_S,"setFloat",lua_cocos2dx_studio_ComAttribute_setFloat); tolua_function(tolua_S,"setString",lua_cocos2dx_studio_ComAttribute_setString); tolua_function(tolua_S,"getBool",lua_cocos2dx_studio_ComAttribute_getBool); tolua_function(tolua_S,"setInt",lua_cocos2dx_studio_ComAttribute_setInt); tolua_function(tolua_S,"parse",lua_cocos2dx_studio_ComAttribute_parse); tolua_function(tolua_S,"getInt",lua_cocos2dx_studio_ComAttribute_getInt); tolua_function(tolua_S,"setBool",lua_cocos2dx_studio_ComAttribute_setBool); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ComAttribute_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_studio_ComAttribute_createInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ComAttribute).name(); g_luaType[typeName] = "ccs.ComAttribute"; g_typeCast["ComAttribute"] = "ccs.ComAttribute"; return 1; } int lua_cocos2dx_studio_ComAudio_stopAllEffects(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_stopAllEffects'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->stopAllEffects(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopAllEffects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_stopAllEffects'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_getEffectsVolume(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_getEffectsVolume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getEffectsVolume(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getEffectsVolume",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_getEffectsVolume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_stopEffect(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_stopEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->stopEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_stopEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_getBackgroundMusicVolume(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_getBackgroundMusicVolume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; double ret = cobj->getBackgroundMusicVolume(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getBackgroundMusicVolume",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_getBackgroundMusicVolume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_willPlayBackgroundMusic(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_willPlayBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->willPlayBackgroundMusic(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "willPlayBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_willPlayBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_setBackgroundMusicVolume(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_setBackgroundMusicVolume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setBackgroundMusicVolume(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setBackgroundMusicVolume",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_setBackgroundMusicVolume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_end(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_end'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->end(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "end",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_end'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_stopBackgroundMusic(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_stopBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { cobj->stopBackgroundMusic(); return 0; } }while(0); ok = true; do{ if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if (!ok) { break; } cobj->stopBackgroundMusic(arg0); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopBackgroundMusic",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_stopBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_pauseBackgroundMusic(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_pauseBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pauseBackgroundMusic(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_pauseBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isBackgroundMusicPlaying(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isBackgroundMusicPlaying",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_isLoop(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_isLoop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; bool ret = cobj->isLoop(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isLoop",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_isLoop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_resumeAllEffects(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_resumeAllEffects'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resumeAllEffects(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeAllEffects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_resumeAllEffects'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_pauseAllEffects(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_pauseAllEffects'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->pauseAllEffects(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseAllEffects",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_pauseAllEffects'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_preloadBackgroundMusic(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_preloadBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->preloadBackgroundMusic(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "preloadBackgroundMusic",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_preloadBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_playBackgroundMusic(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_playBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } cobj->playBackgroundMusic(arg0); return 0; } }while(0); ok = true; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } cobj->playBackgroundMusic(arg0, arg1); return 0; } }while(0); ok = true; do{ if (argc == 0) { cobj->playBackgroundMusic(); return 0; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "playBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_playBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_playEffect(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_playEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; do{ if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } unsigned int ret = cobj->playEffect(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; do{ if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (!ok) { break; } bool arg1; ok &= luaval_to_boolean(tolua_S, 3,&arg1); if (!ok) { break; } unsigned int ret = cobj->playEffect(arg0, arg1); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; do{ if (argc == 0) { unsigned int ret = cobj->playEffect(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } }while(0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "playEffect",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_playEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_preloadEffect(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_preloadEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->preloadEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "preloadEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_preloadEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_setLoop(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_setLoop'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { bool arg0; ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setLoop(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setLoop",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_setLoop'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_unloadEffect(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_unloadEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->unloadEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "unloadEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_unloadEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_rewindBackgroundMusic(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_rewindBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->rewindBackgroundMusic(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rewindBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_rewindBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_pauseEffect(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_pauseEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->pauseEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_pauseEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_resumeBackgroundMusic(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_resumeBackgroundMusic'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj->resumeBackgroundMusic(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeBackgroundMusic",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_resumeBackgroundMusic'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_setFile(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_setFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cobj->setFile(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_setFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_setEffectsVolume(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_setEffectsVolume'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { double arg0; ok &= luaval_to_number(tolua_S, 2,&arg0); if(!ok) return 0; cobj->setEffectsVolume(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEffectsVolume",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_setEffectsVolume'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_getFile(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_getFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getFile(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFile",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_getFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_resumeEffect(lua_State* tolua_S) { int argc = 0; cocostudio::ComAudio* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComAudio*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComAudio_resumeEffect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { unsigned int arg0; ok &= luaval_to_uint32(tolua_S, 2,&arg0); if(!ok) return 0; cobj->resumeEffect(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeEffect",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_resumeEffect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ComAudio* ret = cocostudio::ComAudio::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ComAudio"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ComAudio*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComAudio_createInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ComAudio",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Object* ret = cocostudio::ComAudio::createInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Object"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Object*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComAudio_createInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ComAudio_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ComAudio)"); return 0; } int lua_register_cocos2dx_studio_ComAudio(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ComAudio"); tolua_cclass(tolua_S,"ComAudio","ccs.ComAudio","cc.Component",NULL); tolua_beginmodule(tolua_S,"ComAudio"); tolua_function(tolua_S,"stopAllEffects",lua_cocos2dx_studio_ComAudio_stopAllEffects); tolua_function(tolua_S,"getEffectsVolume",lua_cocos2dx_studio_ComAudio_getEffectsVolume); tolua_function(tolua_S,"stopEffect",lua_cocos2dx_studio_ComAudio_stopEffect); tolua_function(tolua_S,"getBackgroundMusicVolume",lua_cocos2dx_studio_ComAudio_getBackgroundMusicVolume); tolua_function(tolua_S,"willPlayBackgroundMusic",lua_cocos2dx_studio_ComAudio_willPlayBackgroundMusic); tolua_function(tolua_S,"setBackgroundMusicVolume",lua_cocos2dx_studio_ComAudio_setBackgroundMusicVolume); tolua_function(tolua_S,"end",lua_cocos2dx_studio_ComAudio_end); tolua_function(tolua_S,"stopBackgroundMusic",lua_cocos2dx_studio_ComAudio_stopBackgroundMusic); tolua_function(tolua_S,"pauseBackgroundMusic",lua_cocos2dx_studio_ComAudio_pauseBackgroundMusic); tolua_function(tolua_S,"isBackgroundMusicPlaying",lua_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying); tolua_function(tolua_S,"isLoop",lua_cocos2dx_studio_ComAudio_isLoop); tolua_function(tolua_S,"resumeAllEffects",lua_cocos2dx_studio_ComAudio_resumeAllEffects); tolua_function(tolua_S,"pauseAllEffects",lua_cocos2dx_studio_ComAudio_pauseAllEffects); tolua_function(tolua_S,"preloadBackgroundMusic",lua_cocos2dx_studio_ComAudio_preloadBackgroundMusic); tolua_function(tolua_S,"playBackgroundMusic",lua_cocos2dx_studio_ComAudio_playBackgroundMusic); tolua_function(tolua_S,"playEffect",lua_cocos2dx_studio_ComAudio_playEffect); tolua_function(tolua_S,"preloadEffect",lua_cocos2dx_studio_ComAudio_preloadEffect); tolua_function(tolua_S,"setLoop",lua_cocos2dx_studio_ComAudio_setLoop); tolua_function(tolua_S,"unloadEffect",lua_cocos2dx_studio_ComAudio_unloadEffect); tolua_function(tolua_S,"rewindBackgroundMusic",lua_cocos2dx_studio_ComAudio_rewindBackgroundMusic); tolua_function(tolua_S,"pauseEffect",lua_cocos2dx_studio_ComAudio_pauseEffect); tolua_function(tolua_S,"resumeBackgroundMusic",lua_cocos2dx_studio_ComAudio_resumeBackgroundMusic); tolua_function(tolua_S,"setFile",lua_cocos2dx_studio_ComAudio_setFile); tolua_function(tolua_S,"setEffectsVolume",lua_cocos2dx_studio_ComAudio_setEffectsVolume); tolua_function(tolua_S,"getFile",lua_cocos2dx_studio_ComAudio_getFile); tolua_function(tolua_S,"resumeEffect",lua_cocos2dx_studio_ComAudio_resumeEffect); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ComAudio_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_studio_ComAudio_createInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ComAudio).name(); g_luaType[typeName] = "ccs.ComAudio"; g_typeCast["ComAudio"] = "ccs.ComAudio"; return 1; } int lua_cocos2dx_studio_ComController_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ComController",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::ComController* ret = cocostudio::ComController::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ComController"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ComController*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComController_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComController_createInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ComController",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Object* ret = cocostudio::ComController::createInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Object"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Object*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComController_createInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComController_constructor(lua_State* tolua_S) { int argc = 0; cocostudio::ComController* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cobj = new cocostudio::ComController(); cocos2d::Object* dynObject = dynamic_cast(cobj); if (nullptr != dynObject) { dynObject->autorelease(); int ID = (int)dynObject->_ID ; int* luaID = &dynObject->_luaID ; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"ccs.ComController"); } else { tolua_pushusertype(tolua_S,(void*)cobj,"ccs.ComController"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ComController",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComController_constructor'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ComController_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ComController)"); return 0; } int lua_register_cocos2dx_studio_ComController(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ComController"); tolua_cclass(tolua_S,"ComController","ccs.ComController","cc.Component",NULL); tolua_beginmodule(tolua_S,"ComController"); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ComController_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_studio_ComController_createInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ComController).name(); g_luaType[typeName] = "ccs.ComController"; g_typeCast["ComController"] = "ccs.ComController"; return 1; } int lua_cocos2dx_studio_ComRender_setNode(lua_State* tolua_S) { int argc = 0; cocostudio::ComRender* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComRender",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComRender*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComRender_setNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if(!ok) return 0; cobj->setNode(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setNode",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComRender_setNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComRender_getNode(lua_State* tolua_S) { int argc = 0; cocostudio::ComRender* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.ComRender",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::ComRender*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_ComRender_getNode'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Node* ret = cobj->getNode(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNode",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComRender_getNode'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComRender_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ComRender",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S)-1; do { if (argc == 2) { cocos2d::Node* arg0; do { if (!luaval_is_usertype(tolua_S,2,"cc.Node",0)){ ok = false; break; } if (ok){ arg0 = (cocos2d::Node*)tolua_tousertype(tolua_S,2,0); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }}} while (0); if (!ok) { break; } const char* arg1; std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); if (!ok) { break; } cocostudio::ComRender* ret = cocostudio::ComRender::create(arg0, arg1); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ComRender"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ComRender*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; do { if (argc == 0) { cocostudio::ComRender* ret = cocostudio::ComRender::create(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.ComRender"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::ComRender*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } } while (0); ok = true; CCLOG("%s has wrong number of arguments: %d, was expecting %d", "create",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComRender_create'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_ComRender_createInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.ComRender",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocos2d::Object* ret = cocostudio::ComRender::createInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Object"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Object*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_ComRender_createInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_ComRender_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (ComRender)"); return 0; } int lua_register_cocos2dx_studio_ComRender(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.ComRender"); tolua_cclass(tolua_S,"ComRender","ccs.ComRender","cc.Component",NULL); tolua_beginmodule(tolua_S,"ComRender"); tolua_function(tolua_S,"setNode",lua_cocos2dx_studio_ComRender_setNode); tolua_function(tolua_S,"getNode",lua_cocos2dx_studio_ComRender_getNode); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ComRender_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_studio_ComRender_createInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ComRender).name(); g_luaType[typeName] = "ccs.ComRender"; g_typeCast["ComRender"] = "ccs.ComRender"; return 1; } int lua_cocos2dx_studio_GUIReader_widgetFromJsonFile(lua_State* tolua_S) { int argc = 0; cocostudio::GUIReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.GUIReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::GUIReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_GUIReader_widgetFromJsonFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; cocos2d::gui::Widget* ret = cobj->widgetFromJsonFile(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccui.Widget"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::gui::Widget*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "widgetFromJsonFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_GUIReader_widgetFromJsonFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_GUIReader_getVersionInteger(lua_State* tolua_S) { int argc = 0; cocostudio::GUIReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.GUIReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::GUIReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_GUIReader_getVersionInteger'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if(!ok) return 0; int ret = cobj->getVersionInteger(arg0); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVersionInteger",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_GUIReader_getVersionInteger'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_GUIReader_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.GUIReader",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::GUIReader::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_GUIReader_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_GUIReader_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.GUIReader",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::GUIReader* ret = cocostudio::GUIReader::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.GUIReader"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::GUIReader*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_GUIReader_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_GUIReader_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (GUIReader)"); return 0; } int lua_register_cocos2dx_studio_GUIReader(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.GUIReader"); tolua_cclass(tolua_S,"GUIReader","ccs.GUIReader","",NULL); tolua_beginmodule(tolua_S,"GUIReader"); tolua_function(tolua_S,"widgetFromJsonFile",lua_cocos2dx_studio_GUIReader_widgetFromJsonFile); tolua_function(tolua_S,"getVersionInteger",lua_cocos2dx_studio_GUIReader_getVersionInteger); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_studio_GUIReader_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_studio_GUIReader_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::GUIReader).name(); g_luaType[typeName] = "ccs.GUIReader"; g_typeCast["GUIReader"] = "ccs.GUIReader"; return 1; } int lua_cocos2dx_studio_SceneReader_setTarget(lua_State* tolua_S) { int argc = 0; cocostudio::SceneReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.SceneReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::SceneReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_SceneReader_setTarget'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::function arg0; do { // Lambda binding for lua is not supported. assert(false); } while(0) ; if(!ok) return 0; cobj->setTarget(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTarget",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SceneReader_setTarget'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_SceneReader_createNodeWithSceneFile(lua_State* tolua_S) { int argc = 0; cocostudio::SceneReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.SceneReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::SceneReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_SceneReader_createNodeWithSceneFile'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2,&arg0); if(!ok) return 0; cocos2d::Node* ret = cobj->createNodeWithSceneFile(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "createNodeWithSceneFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SceneReader_createNodeWithSceneFile'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_SceneReader_getNodeByTag(lua_State* tolua_S) { int argc = 0; cocostudio::SceneReader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ccs.SceneReader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocostudio::SceneReader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_SceneReader_getNodeByTag'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 1) { int arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); if(!ok) return 0; cocos2d::Node* ret = cobj->getNodeByTag(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Node"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::Node*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeByTag",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SceneReader_getNodeByTag'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_SceneReader_destroyInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.SceneReader",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::SceneReader::destroyInstance(); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SceneReader_destroyInstance'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_SceneReader_sceneReaderVersion(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.SceneReader",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; const char* ret = cocostudio::SceneReader::sceneReaderVersion(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "sceneReaderVersion",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SceneReader_sceneReaderVersion'.",&tolua_err); #endif return 0; } int lua_cocos2dx_studio_SceneReader_getInstance(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"ccs.SceneReader",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if(!ok) return 0; cocostudio::SceneReader* ret = cocostudio::SceneReader::getInstance(); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "ccs.SceneReader"; } cocos2d::Object *dynObject = dynamic_cast((cocostudio::SceneReader*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_SceneReader_getInstance'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_studio_SceneReader_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (SceneReader)"); return 0; } int lua_register_cocos2dx_studio_SceneReader(lua_State* tolua_S) { tolua_usertype(tolua_S,"ccs.SceneReader"); tolua_cclass(tolua_S,"SceneReader","ccs.SceneReader","",NULL); tolua_beginmodule(tolua_S,"SceneReader"); tolua_function(tolua_S,"setTarget",lua_cocos2dx_studio_SceneReader_setTarget); tolua_function(tolua_S,"createNodeWithSceneFile",lua_cocos2dx_studio_SceneReader_createNodeWithSceneFile); tolua_function(tolua_S,"getNodeByTag",lua_cocos2dx_studio_SceneReader_getNodeByTag); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_studio_SceneReader_destroyInstance); tolua_function(tolua_S,"sceneReaderVersion", lua_cocos2dx_studio_SceneReader_sceneReaderVersion); tolua_function(tolua_S,"getInstance", lua_cocos2dx_studio_SceneReader_getInstance); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::SceneReader).name(); g_luaType[typeName] = "ccs.SceneReader"; g_typeCast["SceneReader"] = "ccs.SceneReader"; return 1; } TOLUA_API int register_all_cocos2dx_studio(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,"ccs",0); tolua_beginmodule(tolua_S,"ccs"); lua_register_cocos2dx_studio_Tween(tolua_S); lua_register_cocos2dx_studio_ContourData(tolua_S); lua_register_cocos2dx_studio_SceneReader(tolua_S); lua_register_cocos2dx_studio_ComAudio(tolua_S); lua_register_cocos2dx_studio_DisplayData(tolua_S); lua_register_cocos2dx_studio_ArmatureDisplayData(tolua_S); lua_register_cocos2dx_studio_MovementData(tolua_S); lua_register_cocos2dx_studio_ArmatureDataManager(tolua_S); lua_register_cocos2dx_studio_ArmatureData(tolua_S); lua_register_cocos2dx_studio_BaseData(tolua_S); lua_register_cocos2dx_studio_FrameData(tolua_S); lua_register_cocos2dx_studio_ComController(tolua_S); lua_register_cocos2dx_studio_BoneData(tolua_S); lua_register_cocos2dx_studio_ComRender(tolua_S); lua_register_cocos2dx_studio_ParticleDisplayData(tolua_S); lua_register_cocos2dx_studio_BatchNode(tolua_S); lua_register_cocos2dx_studio_ActionObject(tolua_S); lua_register_cocos2dx_studio_Skin(tolua_S); lua_register_cocos2dx_studio_MovementBoneData(tolua_S); lua_register_cocos2dx_studio_DisplayManager(tolua_S); lua_register_cocos2dx_studio_GUIReader(tolua_S); lua_register_cocos2dx_studio_ArmatureAnimation(tolua_S); lua_register_cocos2dx_studio_Armature(tolua_S); lua_register_cocos2dx_studio_SpriteDisplayData(tolua_S); lua_register_cocos2dx_studio_ActionManagerEx(tolua_S); lua_register_cocos2dx_studio_Bone(tolua_S); lua_register_cocos2dx_studio_ComAttribute(tolua_S); lua_register_cocos2dx_studio_TextureData(tolua_S); lua_register_cocos2dx_studio_AnimationData(tolua_S); tolua_endmodule(tolua_S); return 1; } ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_studio_auto.hpp ================================================ #ifndef __cocos2dx_studio_h__ #define __cocos2dx_studio_h__ #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif int register_all_cocos2dx_studio(lua_State* tolua_S); #endif // __cocos2dx_studio_h__ ================================================ FILE: cocos2d/cocos/scripting/auto-generated/lua-bindings/lua_cocos2dx_studio_auto_api.js ================================================ /** * @module cocos2dx_studio */ var ccs = ccs || {}; /** * @class ActionObject */ ccs.ActionObject = { /** * @method setCurrentTime * @param {float} */ setCurrentTime : function () {}, /** * @method pause */ pause : function () {}, /** * @method setName * @param {const char*} */ setName : function () {}, /** * @method setUnitTime * @param {float} */ setUnitTime : function () {}, /** * @method getTotalTime * @return A value converted from C/C++ "float" */ getTotalTime : function () {}, /** * @method getName * @return A value converted from C/C++ "const char*" */ getName : function () {}, /** * @method stop */ stop : function () {}, /** * @method getCurrentTime * @return A value converted from C/C++ "float" */ getCurrentTime : function () {}, /** * @method removeActionNode * @param {cocostudio::ActionNode*} */ removeActionNode : function () {}, /** * @method getLoop * @return A value converted from C/C++ "bool" */ getLoop : function () {}, /** * @method addActionNode * @param {cocostudio::ActionNode*} */ addActionNode : function () {}, /** * @method getUnitTime * @return A value converted from C/C++ "float" */ getUnitTime : function () {}, /** * @method isPlaying * @return A value converted from C/C++ "bool" */ isPlaying : function () {}, /** * @method updateToFrameByTime * @param {float} */ updateToFrameByTime : function () {}, /** * @method setLoop * @param {bool} */ setLoop : function () {}, /** * @method simulationActionUpdate * @param {float} */ simulationActionUpdate : function () {}, /** * @method ActionObject * @constructor */ ActionObject : function () {}, }; /** * @class ActionManagerEx */ ccs.ActionManagerEx = { /** * @method getActionByName * @return A value converted from C/C++ "cocostudio::ActionObject*" * @param {const char*} * @param {const char*} */ getActionByName : function () {}, /** * @method releaseActions */ releaseActions : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocostudio::ActionManagerEx*" */ getInstance : function () {}, }; /** * @class BaseData */ ccs.BaseData = { /** * @method getColor * @return A value converted from C/C++ "cocos2d::Color4B" */ getColor : function () {}, /** * @method setColor * @param {const cocos2d::Color4B&} */ setColor : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::BaseData*" */ create : function () {}, /** * @method BaseData * @constructor */ BaseData : function () {}, }; /** * @class DisplayData */ ccs.DisplayData = { /** * @method copy * @param {cocostudio::DisplayData*} */ copy : function () {}, /** * @method changeDisplayToTexture * @return A value converted from C/C++ "const std::string" * @param {const std::string&} */ changeDisplayToTexture : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::DisplayData*" */ create : function () {}, /** * @method DisplayData * @constructor */ DisplayData : function () {}, }; /** * @class SpriteDisplayData */ ccs.SpriteDisplayData = { /** * @method copy * @param {cocostudio::DisplayData*} */ copy : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::SpriteDisplayData*" */ create : function () {}, /** * @method SpriteDisplayData * @constructor */ SpriteDisplayData : function () {}, }; /** * @class ArmatureDisplayData */ ccs.ArmatureDisplayData = { /** * @method create * @return A value converted from C/C++ "cocostudio::ArmatureDisplayData*" */ create : function () {}, /** * @method ArmatureDisplayData * @constructor */ ArmatureDisplayData : function () {}, }; /** * @class ParticleDisplayData */ ccs.ParticleDisplayData = { /** * @method create * @return A value converted from C/C++ "cocostudio::ParticleDisplayData*" */ create : function () {}, /** * @method ParticleDisplayData * @constructor */ ParticleDisplayData : function () {}, }; /** * @class BoneData */ ccs.BoneData = { /** * @method getDisplayData * @return A value converted from C/C++ "cocostudio::DisplayData*" * @param {int} */ getDisplayData : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method addDisplayData * @param {cocostudio::DisplayData*} */ addDisplayData : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::BoneData*" */ create : function () {}, /** * @method BoneData * @constructor */ BoneData : function () {}, }; /** * @class ArmatureData */ ccs.ArmatureData = { /** * @method addBoneData * @param {cocostudio::BoneData*} */ addBoneData : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method getBoneData * @return A value converted from C/C++ "cocostudio::BoneData*" * @param {const std::string&} */ getBoneData : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::ArmatureData*" */ create : function () {}, /** * @method ArmatureData * @constructor */ ArmatureData : function () {}, }; /** * @class FrameData */ ccs.FrameData = { /** * @method copy * @param {const cocostudio::BaseData*} */ copy : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::FrameData*" */ create : function () {}, /** * @method FrameData * @constructor */ FrameData : function () {}, }; /** * @class MovementBoneData */ ccs.MovementBoneData = { /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method getFrameData * @return A value converted from C/C++ "cocostudio::FrameData*" * @param {int} */ getFrameData : function () {}, /** * @method addFrameData * @param {cocostudio::FrameData*} */ addFrameData : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::MovementBoneData*" */ create : function () {}, /** * @method MovementBoneData * @constructor */ MovementBoneData : function () {}, }; /** * @class MovementData */ ccs.MovementData = { /** * @method getMovementBoneData * @return A value converted from C/C++ "cocostudio::MovementBoneData*" * @param {const std::string&} */ getMovementBoneData : function () {}, /** * @method addMovementBoneData * @param {cocostudio::MovementBoneData*} */ addMovementBoneData : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::MovementData*" */ create : function () {}, /** * @method MovementData * @constructor */ MovementData : function () {}, }; /** * @class AnimationData */ ccs.AnimationData = { /** * @method getMovement * @return A value converted from C/C++ "cocostudio::MovementData*" * @param {const std::string&} */ getMovement : function () {}, /** * @method getMovementCount * @return A value converted from C/C++ "ssize_t" */ getMovementCount : function () {}, /** * @method addMovement * @param {cocostudio::MovementData*} */ addMovement : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::AnimationData*" */ create : function () {}, /** * @method AnimationData * @constructor */ AnimationData : function () {}, }; /** * @class ContourData */ ccs.ContourData = { /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method addVertex * @param {cocos2d::Point&} */ addVertex : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::ContourData*" */ create : function () {}, /** * @method ContourData * @constructor */ ContourData : function () {}, }; /** * @class TextureData */ ccs.TextureData = { /** * @method getContourData * @return A value converted from C/C++ "cocostudio::ContourData*" * @param {int} */ getContourData : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method addContourData * @param {cocostudio::ContourData*} */ addContourData : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::TextureData*" */ create : function () {}, /** * @method TextureData * @constructor */ TextureData : function () {}, }; /** * @class Tween */ ccs.Tween = { /** * @method getAnimation * @return A value converted from C/C++ "cocostudio::ArmatureAnimation*" */ getAnimation : function () {}, /** * @method gotoAndPause * @param {int} */ gotoAndPause : function () {}, /** * @method play * @param {cocostudio::MovementBoneData*} * @param {int} * @param {int} * @param {int} * @param {int} */ play : function () {}, /** * @method gotoAndPlay * @param {int} */ gotoAndPlay : function () {}, /** * @method init * @return A value converted from C/C++ "bool" * @param {cocostudio::Bone*} */ init : function () {}, /** * @method setAnimation * @param {cocostudio::ArmatureAnimation*} */ setAnimation : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::Tween*" * @param {cocostudio::Bone*} */ create : function () {}, /** * @method Tween * @constructor */ Tween : function () {}, }; /** * @class DisplayManager */ ccs.DisplayManager = { /** * @method getDisplayRenderNode * @return A value converted from C/C++ "cocos2d::Node*" */ getDisplayRenderNode : function () {}, /** * @method getAnchorPointInPoints * @return A value converted from C/C++ "cocos2d::Point" */ getAnchorPointInPoints : function () {}, /** * @method getDisplayRenderNodeType * @return A value converted from C/C++ "cocostudio::DisplayType" */ getDisplayRenderNodeType : function () {}, /** * @method removeDisplay * @param {int} */ removeDisplay : function () {}, /** * @method setForceChangeDisplay * @param {bool} */ setForceChangeDisplay : function () {}, /** * @method init * @return A value converted from C/C++ "bool" * @param {cocostudio::Bone*} */ init : function () {}, /** * @method getContentSize * @return A value converted from C/C++ "cocos2d::Size" */ getContentSize : function () {}, /** * @method getBoundingBox * @return A value converted from C/C++ "cocos2d::Rect" */ getBoundingBox : function () {}, /** * @method changeDisplayWithIndex * @param {int} * @param {bool} */ changeDisplayWithIndex : function () {}, /** * @method changeDisplayWithName * @param {const std::string&} * @param {bool} */ changeDisplayWithName : function () {}, /** * @method isForceChangeDisplay * @return A value converted from C/C++ "bool" */ isForceChangeDisplay : function () {}, /** * @method getCurrentDisplayIndex * @return A value converted from C/C++ "int" */ getCurrentDisplayIndex : function () {}, /** * @method getAnchorPoint * @return A value converted from C/C++ "cocos2d::Point" */ getAnchorPoint : function () {}, /** * @method getDecorativeDisplayList * @return A value converted from C/C++ "const cocos2d::Vector&" */ getDecorativeDisplayList : function () {}, /** * @method isVisible * @return A value converted from C/C++ "bool" */ isVisible : function () {}, /** * @method setVisible * @param {bool} */ setVisible : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::DisplayManager*" * @param {cocostudio::Bone*} */ create : function () {}, /** * @method DisplayManager * @constructor */ DisplayManager : function () {}, }; /** * @class Bone */ ccs.Bone = { /** * @method isTransformDirty * @return A value converted from C/C++ "bool" */ isTransformDirty : function () {}, /** * @method isIgnoreMovementBoneData * @return A value converted from C/C++ "bool" */ isIgnoreMovementBoneData : function () {}, /** * @method updateZOrder */ updateZOrder : function () {}, /** * @method getDisplayRenderNode * @return A value converted from C/C++ "cocos2d::Node*" */ getDisplayRenderNode : function () {}, /** * @method isBlendDirty * @return A value converted from C/C++ "bool" */ isBlendDirty : function () {}, /** * @method addChildBone * @param {cocostudio::Bone*} */ addChildBone : function () {}, /** * @method getWorldInfo * @return A value converted from C/C++ "cocostudio::BaseData*" */ getWorldInfo : function () {}, /** * @method getTween * @return A value converted from C/C++ "cocostudio::Tween*" */ getTween : function () {}, /** * @method getParentBone * @return A value converted from C/C++ "cocostudio::Bone*" */ getParentBone : function () {}, /** * @method updateColor */ updateColor : function () {}, /** * @method getName * @return A value converted from C/C++ "const std::string" */ getName : function () {}, /** * @method setTransformDirty * @param {bool} */ setTransformDirty : function () {}, /** * @method getDisplayRenderNodeType * @return A value converted from C/C++ "cocostudio::DisplayType" */ getDisplayRenderNodeType : function () {}, /** * @method removeDisplay * @param {int} */ removeDisplay : function () {}, /** * @method setBoneData * @param {cocostudio::BoneData*} */ setBoneData : function () {}, /** * @method setParentBone * @param {cocostudio::Bone*} */ setParentBone : function () {}, /** * @method setName * @param {const std::string&} */ setName : function () {}, /** * @method removeFromParent * @param {bool} */ removeFromParent : function () {}, /** * @method getColliderDetector * @return A value converted from C/C++ "cocostudio::ColliderDetector*" */ getColliderDetector : function () {}, /** * @method getChildArmature * @return A value converted from C/C++ "cocostudio::Armature*" */ getChildArmature : function () {}, /** * @method getTweenData * @return A value converted from C/C++ "cocostudio::FrameData*" */ getTweenData : function () {}, /** * @method changeDisplayWithIndex * @param {int} * @param {bool} */ changeDisplayWithIndex : function () {}, /** * @method changeDisplayWithName * @param {const std::string&} * @param {bool} */ changeDisplayWithName : function () {}, /** * @method setArmature * @param {cocostudio::Armature*} */ setArmature : function () {}, /** * @method setBlendDirty * @param {bool} */ setBlendDirty : function () {}, /** * @method removeChildBone * @param {cocostudio::Bone*} * @param {bool} */ removeChildBone : function () {}, /** * @method setChildArmature * @param {cocostudio::Armature*} */ setChildArmature : function () {}, /** * @method getNodeToArmatureTransform * @return A value converted from C/C++ "kmMat4" */ getNodeToArmatureTransform : function () {}, /** * @method getDisplayManager * @return A value converted from C/C++ "cocostudio::DisplayManager*" */ getDisplayManager : function () {}, /** * @method getArmature * @return A value converted from C/C++ "cocostudio::Armature*" */ getArmature : function () {}, /** * @method getBoneData * @return A value converted from C/C++ "cocostudio::BoneData*" */ getBoneData : function () {}, /** * @method Bone * @constructor */ Bone : function () {}, }; /** * @class BatchNode */ ccs.BatchNode = { /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::BatchNode*" */ create : function () {}, }; /** * @class ArmatureAnimation */ ccs.ArmatureAnimation = { /** * @method getSpeedScale * @return A value converted from C/C++ "float" */ getSpeedScale : function () {}, /** * @method pause */ pause : function () {}, /** * @method setSpeedScale * @param {float} */ setSpeedScale : function () {}, /** * @method init * @return A value converted from C/C++ "bool" * @param {cocostudio::Armature*} */ init : function () {}, /** * @method playWithIndexes * @param {const std::vector >&} * @param {int} * @param {bool} */ playWithIndexes : function () {}, /** * @method play * @param {const std::string&} * @param {int} * @param {int} */ play : function () {}, /** * @method gotoAndPause * @param {int} */ gotoAndPause : function () {}, /** * @method resume */ resume : function () {}, /** * @method stop */ stop : function () {}, /** * @method update * @param {float} */ update : function () {}, /** * @method getAnimationData * @return A value converted from C/C++ "cocostudio::AnimationData*" */ getAnimationData : function () {}, /** * @method playWithIndex * @param {int} * @param {int} * @param {int} */ playWithIndex : function () {}, /** * @method getCurrentMovementID * @return A value converted from C/C++ "std::string" */ getCurrentMovementID : function () {}, /** * @method setAnimationData * @param {cocostudio::AnimationData*} */ setAnimationData : function () {}, /** * @method gotoAndPlay * @param {int} */ gotoAndPlay : function () {}, /** * @method playWithNames * @param {const std::vector, std::allocator > >&} * @param {int} * @param {bool} */ playWithNames : function () {}, /** * @method getMovementCount * @return A value converted from C/C++ "ssize_t" */ getMovementCount : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::ArmatureAnimation*" * @param {cocostudio::Armature*} */ create : function () {}, /** * @method ArmatureAnimation * @constructor */ ArmatureAnimation : function () {}, }; /** * @class ArmatureDataManager */ ccs.ArmatureDataManager = { /** * @method getAnimationDatas * @return A value converted from C/C++ "const cocos2d::Map, cocostudio::AnimationData *>&" */ getAnimationDatas : function () {}, /** * @method removeAnimationData * @param {const std::string&} */ removeAnimationData : function () {}, /** * @method addArmatureData * @param {const std::string&} * @param {cocostudio::ArmatureData*} * @param {const std::string&} */ addArmatureData : function () {}, /** * @method removeArmatureFileInfo * @param {const std::string&} */ removeArmatureFileInfo : function () {}, /** * @method getTextureDatas * @return A value converted from C/C++ "const cocos2d::Map, cocostudio::TextureData *>&" */ getTextureDatas : function () {}, /** * @method getTextureData * @return A value converted from C/C++ "cocostudio::TextureData*" * @param {const std::string&} */ getTextureData : function () {}, /** * @method getArmatureData * @return A value converted from C/C++ "cocostudio::ArmatureData*" * @param {const std::string&} */ getArmatureData : function () {}, /** * @method getAnimationData * @return A value converted from C/C++ "cocostudio::AnimationData*" * @param {const std::string&} */ getAnimationData : function () {}, /** * @method addAnimationData * @param {const std::string&} * @param {cocostudio::AnimationData*} * @param {const std::string&} */ addAnimationData : function () {}, /** * @method init * @return A value converted from C/C++ "bool" */ init : function () {}, /** * @method removeArmatureData * @param {const std::string&} */ removeArmatureData : function () {}, /** * @method getArmatureDatas * @return A value converted from C/C++ "const cocos2d::Map, cocostudio::ArmatureData *>&" */ getArmatureDatas : function () {}, /** * @method removeTextureData * @param {const std::string&} */ removeTextureData : function () {}, /** * @method addTextureData * @param {const std::string&} * @param {cocostudio::TextureData*} * @param {const std::string&} */ addTextureData : function () {}, /** * @method isAutoLoadSpriteFile * @return A value converted from C/C++ "bool" */ isAutoLoadSpriteFile : function () {}, /** * @method addSpriteFrameFromFile * @param {const std::string&} * @param {const std::string&} * @param {const std::string&} */ addSpriteFrameFromFile : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocostudio::ArmatureDataManager*" */ getInstance : function () {}, }; /** * @class Armature */ ccs.Armature = { /** * @method getBone * @return A value converted from C/C++ "cocostudio::Bone*" * @param {const std::string&} */ getBone : function () {}, /** * @method changeBoneParent * @param {cocostudio::Bone*} * @param {const std::string&} */ changeBoneParent : function () {}, /** * @method setAnimation * @param {cocostudio::ArmatureAnimation*} */ setAnimation : function () {}, /** * @method getBoneAtPoint * @return A value converted from C/C++ "cocostudio::Bone*" * @param {float} * @param {float} */ getBoneAtPoint : function () {}, /** * @method getArmatureTransformDirty * @return A value converted from C/C++ "bool" */ getArmatureTransformDirty : function () {}, /** * @method setVersion * @param {float} */ setVersion : function () {}, /** * @method updateOffsetPoint */ updateOffsetPoint : function () {}, /** * @method getParentBone * @return A value converted from C/C++ "cocostudio::Bone*" */ getParentBone : function () {}, /** * @method setArmatureData * @param {cocostudio::ArmatureData*} */ setArmatureData : function () {}, /** * @method removeBone * @param {cocostudio::Bone*} * @param {bool} */ removeBone : function () {}, /** * @method getBatchNode * @return A value converted from C/C++ "cocostudio::BatchNode*" */ getBatchNode : function () {}, /** * @method getName * @return A value converted from C/C++ "const std::string&" */ getName : function () {}, /** * @method setParentBone * @param {cocostudio::Bone*} */ setParentBone : function () {}, /** * @method drawContour */ drawContour : function () {}, /** * @method setBatchNode * @param {cocostudio::BatchNode*} */ setBatchNode : function () {}, /** * @method setName * @param {const std::string&} */ setName : function () {}, /** * @method addBone * @param {cocostudio::Bone*} * @param {const std::string&} */ addBone : function () {}, /** * @method getArmatureData * @return A value converted from C/C++ "cocostudio::ArmatureData*" */ getArmatureData : function () {}, /** * @method getVersion * @return A value converted from C/C++ "float" */ getVersion : function () {}, /** * @method getAnimation * @return A value converted from C/C++ "cocostudio::ArmatureAnimation*" */ getAnimation : function () {}, /** * @method getBoneDic * @return A value converted from C/C++ "const cocos2d::Map, cocostudio::Bone *>&" */ getBoneDic : function () {}, /** * @method Armature * @constructor */ Armature : function () {}, }; /** * @class Skin */ ccs.Skin = { /** * @method getBone * @return A value converted from C/C++ "cocostudio::Bone*" */ getBone : function () {}, /** * @method getNodeToWorldTransformAR * @return A value converted from C/C++ "kmMat4" */ getNodeToWorldTransformAR : function () {}, /** * @method initWithFile * @return A value converted from C/C++ "bool" * @param {const std::string&} */ initWithFile : function () {}, /** * @method getDisplayName * @return A value converted from C/C++ "const std::string&" */ getDisplayName : function () {}, /** * @method updateArmatureTransform */ updateArmatureTransform : function () {}, /** * @method initWithSpriteFrameName * @return A value converted from C/C++ "bool" * @param {const std::string&} */ initWithSpriteFrameName : function () {}, /** * @method setBone * @param {cocostudio::Bone*} */ setBone : function () {}, /** * @method createWithSpriteFrameName * @return A value converted from C/C++ "cocostudio::Skin*" * @param {const std::string&} */ createWithSpriteFrameName : function () {}, /** * @method Skin * @constructor */ Skin : function () {}, }; /** * @class ComAttribute */ ccs.ComAttribute = { /** * @method getFloat * @return A value converted from C/C++ "float" * @param {const std::string&} * @param {float} */ getFloat : function () {}, /** * @method getString * @return A value converted from C/C++ "std::string" * @param {const std::string&} * @param {const std::string&} */ getString : function () {}, /** * @method setFloat * @param {const std::string&} * @param {float} */ setFloat : function () {}, /** * @method setString * @param {const std::string&} * @param {const std::string&} */ setString : function () {}, /** * @method getBool * @return A value converted from C/C++ "bool" * @param {const std::string&} * @param {bool} */ getBool : function () {}, /** * @method setInt * @param {const std::string&} * @param {int} */ setInt : function () {}, /** * @method parse * @return A value converted from C/C++ "bool" * @param {const std::string&} */ parse : function () {}, /** * @method getInt * @return A value converted from C/C++ "int" * @param {const std::string&} * @param {int} */ getInt : function () {}, /** * @method setBool * @param {const std::string&} * @param {bool} */ setBool : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::ComAttribute*" */ create : function () {}, /** * @method createInstance * @return A value converted from C/C++ "cocos2d::Object*" */ createInstance : function () {}, }; /** * @class ComAudio */ ccs.ComAudio = { /** * @method stopAllEffects */ stopAllEffects : function () {}, /** * @method getEffectsVolume * @return A value converted from C/C++ "float" */ getEffectsVolume : function () {}, /** * @method stopEffect * @param {unsigned int} */ stopEffect : function () {}, /** * @method getBackgroundMusicVolume * @return A value converted from C/C++ "float" */ getBackgroundMusicVolume : function () {}, /** * @method willPlayBackgroundMusic * @return A value converted from C/C++ "bool" */ willPlayBackgroundMusic : function () {}, /** * @method setBackgroundMusicVolume * @param {float} */ setBackgroundMusicVolume : function () {}, /** * @method end */ end : function () {}, /** * @method pauseBackgroundMusic */ pauseBackgroundMusic : function () {}, /** * @method isBackgroundMusicPlaying * @return A value converted from C/C++ "bool" */ isBackgroundMusicPlaying : function () {}, /** * @method isLoop * @return A value converted from C/C++ "bool" */ isLoop : function () {}, /** * @method resumeAllEffects */ resumeAllEffects : function () {}, /** * @method pauseAllEffects */ pauseAllEffects : function () {}, /** * @method preloadBackgroundMusic * @param {const char*} */ preloadBackgroundMusic : function () {}, /** * @method preloadEffect * @param {const char*} */ preloadEffect : function () {}, /** * @method setLoop * @param {bool} */ setLoop : function () {}, /** * @method unloadEffect * @param {const char*} */ unloadEffect : function () {}, /** * @method rewindBackgroundMusic */ rewindBackgroundMusic : function () {}, /** * @method pauseEffect * @param {unsigned int} */ pauseEffect : function () {}, /** * @method resumeBackgroundMusic */ resumeBackgroundMusic : function () {}, /** * @method setFile * @param {const char*} */ setFile : function () {}, /** * @method setEffectsVolume * @param {float} */ setEffectsVolume : function () {}, /** * @method getFile * @return A value converted from C/C++ "const char*" */ getFile : function () {}, /** * @method resumeEffect * @param {unsigned int} */ resumeEffect : function () {}, /** * @method create * @return A value converted from C/C++ "cocostudio::ComAudio*" */ create : function () {}, /** * @method createInstance * @return A value converted from C/C++ "cocos2d::Object*" */ createInstance : function () {}, }; /** * @class ComController */ ccs.ComController = { /** * @method create * @return A value converted from C/C++ "cocostudio::ComController*" */ create : function () {}, /** * @method createInstance * @return A value converted from C/C++ "cocos2d::Object*" */ createInstance : function () {}, /** * @method ComController * @constructor */ ComController : function () {}, }; /** * @class ComRender */ ccs.ComRender = { /** * @method setNode * @param {cocos2d::Node*} */ setNode : function () {}, /** * @method getNode * @return A value converted from C/C++ "cocos2d::Node*" */ getNode : function () {}, /** * @method createInstance * @return A value converted from C/C++ "cocos2d::Object*" */ createInstance : function () {}, }; /** * @class GUIReader */ ccs.GUIReader = { /** * @method widgetFromJsonFile * @return A value converted from C/C++ "cocos2d::gui::Widget*" * @param {const char*} */ widgetFromJsonFile : function () {}, /** * @method getVersionInteger * @return A value converted from C/C++ "int" * @param {const char*} */ getVersionInteger : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocostudio::GUIReader*" */ getInstance : function () {}, }; /** * @class SceneReader */ ccs.SceneReader = { /** * @method setTarget * @param {const std::function&} */ setTarget : function () {}, /** * @method createNodeWithSceneFile * @return A value converted from C/C++ "cocos2d::Node*" * @param {const std::string&} */ createNodeWithSceneFile : function () {}, /** * @method getNodeByTag * @return A value converted from C/C++ "cocos2d::Node*" * @param {int} */ getNodeByTag : function () {}, /** * @method destroyInstance */ destroyInstance : function () {}, /** * @method sceneReaderVersion * @return A value converted from C/C++ "const char*" */ sceneReaderVersion : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocostudio::SceneReader*" */ getInstance : function () {}, }; ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos_jsb_static LOCAL_MODULE_FILENAME := libcocos2dxjsb LOCAL_SRC_FILES := ScriptingCore.cpp \ cocos2d_specifics.cpp \ js_manual_conversions.cpp \ js_bindings_core.cpp \ js_bindings_opengl.cpp \ jsb_opengl_functions.cpp \ jsb_opengl_manual.cpp \ jsb_opengl_registration.cpp \ ../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../audio/include \ $(LOCAL_PATH)/../../../storage \ $(LOCAL_PATH)/../../auto-generated/js-bindings \ $(LOCAL_PATH)/../../../../extensions \ $(LOCAL_PATH)/../../../editor-support/spine \ $(LOCAL_PATH)/../../../editor-support LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../auto-generated/js-bindings \ $(LOCAL_PATH)/../../../audio/include LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,2d) $(call import-module,audio/android) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/ScriptingCore.cpp ================================================ // // ScriptingCore.cpp // testmonkey // // Created by Rolando Abarca on 3/14/12. // Copyright (c) 2012 Zynga Inc. All rights reserved. // #include #include #include #include #include #include #include #include "ScriptingCore.h" #include "jsdbgapi.h" #include "cocos2d.h" #include "local-storage/LocalStorage.h" #include "cocos2d_specifics.hpp" #include "js_bindings_config.h" // for debug socket #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include #include #else #include #include #include #endif #include #ifdef ANDROID #include #include #include #endif #ifdef ANDROID #define LOG_TAG "ScriptingCore.cpp" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #else #define LOGD(...) js_log(__VA_ARGS__) #endif #include "js_bindings_config.h" #if COCOS2D_DEBUG #define TRACE_DEBUGGER_SERVER(...) CCLOG(__VA_ARGS__) #else #define TRACE_DEBUGGER_SERVER(...) #endif // #if DEBUG #define BYTE_CODE_FILE_EXT ".jsc" using namespace cocos2d; static std::string inData; static std::string outData; static std::vector g_queue; static std::mutex g_qMutex; static std::mutex g_rwMutex; static int clientSocket = -1; static uint32_t s_nestedLoopLevel = 0; // server entry point for the bg thread static void serverEntryPoint(void); js_proxy_t *_native_js_global_ht = NULL; js_proxy_t *_js_native_global_ht = NULL; std::unordered_map _js_global_type_map; static char *_js_log_buf = NULL; static std::vector registrationList; // name ~> JSScript map static std::unordered_map filename_script; // port ~> socket map static std::unordered_map ports_sockets; // name ~> globals static std::unordered_map globals; static void ReportException(JSContext *cx) { if (JS_IsExceptionPending(cx)) { if (!JS_ReportPendingException(cx)) { JS_ClearPendingException(cx); } } } static void executeJSFunctionFromReservedSpot(JSContext *cx, JSObject *obj, jsval &dataVal, jsval &retval) { jsval func = JS_GetReservedSlot(obj, 0); if (func == JSVAL_VOID) { return; } jsval thisObj = JS_GetReservedSlot(obj, 1); JSAutoCompartment ac(cx, obj); if (thisObj == JSVAL_VOID) { JS_CallFunctionValue(cx, obj, func, 1, &dataVal, &retval); } else { assert(!JSVAL_IS_PRIMITIVE(thisObj)); JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(thisObj), func, 1, &dataVal, &retval); } } static void getTouchesFuncName(EventTouch::EventCode eventCode, std::string &funcName) { switch(eventCode) { case EventTouch::EventCode::BEGAN: funcName = "onTouchesBegan"; break; case EventTouch::EventCode::ENDED: funcName = "onTouchesEnded"; break; case EventTouch::EventCode::MOVED: funcName = "onTouchesMoved"; break; case EventTouch::EventCode::CANCELLED: funcName = "onTouchesCancelled"; break; } } static void getTouchFuncName(EventTouch::EventCode eventCode, std::string &funcName) { switch(eventCode) { case EventTouch::EventCode::BEGAN: funcName = "onTouchBegan"; break; case EventTouch::EventCode::ENDED: funcName = "onTouchEnded"; break; case EventTouch::EventCode::MOVED: funcName = "onTouchMoved"; break; case EventTouch::EventCode::CANCELLED: funcName = "onTouchCancelled"; break; } } static void rootObject(JSContext *cx, JSObject *obj) { JS_AddNamedObjectRoot(cx, &obj, "unnamed"); } static void unRootObject(JSContext *cx, JSObject *obj) { JS_RemoveObjectRoot(cx, &obj); } static void getJSTouchObject(JSContext *cx, Touch *x, jsval &jsret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, x); jsret = OBJECT_TO_JSVAL(proxy->obj); } static void removeJSTouchObject(JSContext *cx, Touch *x, jsval &jsret) { js_proxy_t* nproxy; js_proxy_t* jsproxy; void *ptr = (void*)x; nproxy = jsb_get_native_proxy(ptr); if (nproxy) { jsproxy = jsb_get_js_proxy(nproxy->obj); JS_RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(nproxy, jsproxy); } } void ScriptingCore::executeJSFunctionWithThisObj(jsval thisObj, jsval callback, uint32_t argc/* = 0*/, jsval* vp/* = NULL*/, jsval* retVal/* = NULL*/) { if (callback != JSVAL_VOID || thisObj != JSVAL_VOID) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET // Very important: The last parameter 'retVal' passed to 'JS_CallFunctionValue' should not be a NULL pointer. // If it's a NULL pointer, crash will be triggered in 'JS_CallFunctionValue'. To find out the reason of this crash is very difficult. // So we have to check the availability of 'retVal'. if (retVal) { JS_CallFunctionValue(_cx, JSVAL_TO_OBJECT(thisObj), callback, argc, vp, retVal); } else { jsval jsRet; JS_CallFunctionValue(_cx, JSVAL_TO_OBJECT(thisObj), callback, argc, vp, &jsRet); } } } void js_log(const char *format, ...) { if (_js_log_buf == NULL) { _js_log_buf = (char *)calloc(sizeof(char), MAX_LOG_LENGTH+1); _js_log_buf[MAX_LOG_LENGTH] = '\0'; } va_list vl; va_start(vl, format); int len = vsnprintf(_js_log_buf, MAX_LOG_LENGTH, format, vl); va_end(vl); if (len > 0) { CCLOG("JS: %s\n", _js_log_buf); } } #define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES 1 JSBool JSBCore_platform(JSContext *cx, uint32_t argc, jsval *vp) { if (argc!=0) { JS_ReportError(cx, "Invalid number of arguments in __getPlatform"); return JS_FALSE; } JSString * platform; // config.deviceType: Device Type // 'mobile' for any kind of mobile devices, 'desktop' for PCs, 'browser' for Web Browsers // #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) // platform = JS_InternString(_cx, "desktop"); // #else platform = JS_InternString(cx, "mobile"); // #endif jsval ret = STRING_TO_JSVAL(platform); JS_SET_RVAL(cx, vp, ret); return JS_TRUE; }; JSBool JSBCore_version(JSContext *cx, uint32_t argc, jsval *vp) { if (argc!=0) { JS_ReportError(cx, "Invalid number of arguments in __getVersion"); return JS_FALSE; } char version[256]; snprintf(version, sizeof(version)-1, "%s", cocos2dVersion()); JSString * js_version = JS_InternString(cx, version); jsval ret = STRING_TO_JSVAL(js_version); JS_SET_RVAL(cx, vp, ret); return JS_TRUE; }; JSBool JSBCore_os(JSContext *cx, uint32_t argc, jsval *vp) { if (argc!=0) { JS_ReportError(cx, "Invalid number of arguments in __getOS"); return JS_FALSE; } JSString * os; // osx, ios, android, windows, linux, etc.. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) os = JS_InternString(cx, "ios"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) os = JS_InternString(cx, "android"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) os = JS_InternString(cx, "windows"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) os = JS_InternString(cx, "marmalade"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) os = JS_InternString(cx, "linux"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_BADA) os = JS_InternString(cx, "bada"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY) os = JS_InternString(cx, "blackberry"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) os = JS_InternString(cx, "osx"); #else os = JS_InternString(cx, "unknown"); #endif jsval ret = STRING_TO_JSVAL(os); JS_SET_RVAL(cx, vp, ret); return JS_TRUE; }; JSBool JSB_core_restartVM(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments in executeScript"); ScriptingCore::getInstance()->reset(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; }; void registerDefaultClasses(JSContext* cx, JSObject* global) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, global, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, global, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } // // Javascript controller (__jsc__) // JSObject *jsc = JS_NewObject(cx, NULL, NULL, NULL); JS::RootedValue jscVal(cx); jscVal = OBJECT_TO_JSVAL(jsc); JS_SetProperty(cx, global, "__jsc__", jscVal); JS_DefineFunction(cx, jsc, "garbageCollect", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, jsc, "dumpRoot", ScriptingCore::dumpRoot, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, jsc, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, jsc, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, jsc, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); // register some global functions JS_DefineFunction(cx, global, "require", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getPlatform", JSBCore_platform, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getOS", JSBCore_os, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getVersion", JSBCore_version, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__restartVM", JSB_core_restartVM, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); } static void sc_finalize(JSFreeOp *freeOp, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (global class)", obj); } static JSClass global_class = { "global", JSCLASS_GLOBAL_FLAGS, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, sc_finalize, JSCLASS_NO_OPTIONAL_MEMBERS }; ScriptingCore::ScriptingCore() : _rt(nullptr) , _cx(nullptr) , _global(nullptr) , _debugGlobal(nullptr) { // set utf8 strings internally (we don't need utf16) // XXX: Removed in SpiderMonkey 19.0 //JS_SetCStringsAreUTF8(); this->addRegisterCallback(registerDefaultClasses); this->_runLoop = new SimpleRunLoop(); } void ScriptingCore::string_report(jsval val) { if (JSVAL_IS_NULL(val)) { LOGD("val : (JSVAL_IS_NULL(val)"); // return 1; } else if ((JSVAL_IS_BOOLEAN(val)) && (JS_FALSE == (JSVAL_TO_BOOLEAN(val)))) { LOGD("val : (return value is JS_FALSE"); // return 1; } else if (JSVAL_IS_STRING(val)) { JSString *str = JS_ValueToString(this->getGlobalContext(), val); if (NULL == str) { LOGD("val : return string is NULL"); } else { JSStringWrapper wrapper(str); LOGD("val : return string =\n%s\n", wrapper.get()); } } else if (JSVAL_IS_NUMBER(val)) { double number; if (JS_FALSE == JS_ValueToNumber(this->getGlobalContext(), val, &number)) { LOGD("val : return number could not be converted"); } else { LOGD("val : return number =\n%f", number); } } } JSBool ScriptingCore::evalString(const char *string, jsval *outVal, const char *filename, JSContext* cx, JSObject* global) { if (cx == NULL) cx = _cx; if (global == NULL) global = _global; JSAutoCompartment ac(cx, global); JSScript* script = JS_CompileScript(cx, global, string, strlen(string), filename, 1); if (script) { JSBool evaluatedOK = JS_ExecuteScript(cx, global, script, outVal); if (JS_FALSE == evaluatedOK) { fprintf(stderr, "(evaluatedOK == JS_FALSE)\n"); } return evaluatedOK; } return JS_FALSE; } void ScriptingCore::start() { // for now just this this->createGlobalContext(); } void ScriptingCore::addRegisterCallback(sc_register_sth callback) { registrationList.push_back(callback); } void ScriptingCore::removeAllRoots(JSContext *cx) { js_proxy_t *current, *tmp; HASH_ITER(hh, _js_native_global_ht, current, tmp) { JS_RemoveObjectRoot(cx, ¤t->obj); HASH_DEL(_js_native_global_ht, current); free(current); } HASH_ITER(hh, _native_js_global_ht, current, tmp) { HASH_DEL(_native_js_global_ht, current); free(current); } HASH_CLEAR(hh, _js_native_global_ht); HASH_CLEAR(hh, _native_js_global_ht); } static JSPrincipals shellTrustedPrincipals = { 1 }; static JSBool CheckObjectAccess(JSContext *cx, js::HandleObject obj, js::HandleId id, JSAccessMode mode, js::MutableHandleValue vp) { return JS_TRUE; } static JSSecurityCallbacks securityCallbacks = { CheckObjectAccess, NULL }; void ScriptingCore::createGlobalContext() { if (this->_cx && this->_rt) { ScriptingCore::removeAllRoots(this->_cx); JS_DestroyContext(this->_cx); JS_DestroyRuntime(this->_rt); this->_cx = NULL; this->_rt = NULL; } // Start the engine. Added in SpiderMonkey v25 if (!JS_Init()) return; // Removed from Spidermonkey 19. //JS_SetCStringsAreUTF8(); this->_rt = JS_NewRuntime(8L * 1024L * 1024L, JS_USE_HELPER_THREADS); JS_SetGCParameter(_rt, JSGC_MAX_BYTES, 0xffffffff); JS_SetTrustedPrincipals(_rt, &shellTrustedPrincipals); JS_SetSecurityCallbacks(_rt, &securityCallbacks); JS_SetNativeStackQuota(_rt, JSB_MAX_STACK_QUOTA); this->_cx = JS_NewContext(_rt, 8192); JS_SetOptions(this->_cx, JSOPTION_TYPE_INFERENCE); // JS_SetVersion(this->_cx, JSVERSION_LATEST); // Only disable METHODJIT on iOS. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) // JS_SetOptions(this->_cx, JS_GetOptions(this->_cx) & ~JSOPTION_METHODJIT); // JS_SetOptions(this->_cx, JS_GetOptions(this->_cx) & ~JSOPTION_METHODJIT_ALWAYS); #endif JS_SetErrorReporter(this->_cx, ScriptingCore::reportError); #if defined(JS_GC_ZEAL) && defined(DEBUG) //JS_SetGCZeal(this->_cx, 2, JS_DEFAULT_ZEAL_FREQ); #endif this->_global = NewGlobalObject(_cx); JSAutoCompartment ac(_cx, _global); js::SetDefaultObjectForContext(_cx, _global); for (std::vector::iterator it = registrationList.begin(); it != registrationList.end(); it++) { sc_register_sth callback = *it; callback(this->_cx, this->_global); } } static std::string RemoveFileExt(const std::string& filePath) { size_t pos = filePath.rfind('.'); if (0 < pos) { return filePath.substr(0, pos); } else { return filePath; } } JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* cx) { if (!path) { return false; } cocos2d::FileUtils *futil = cocos2d::FileUtils::getInstance(); if (global == NULL) { global = _global; } if (cx == NULL) { cx = _cx; } JSAutoCompartment ac(cx, global); js::RootedScript script(cx); js::RootedObject obj(cx, global); // a) check jsc file first std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT; Data data = futil->getDataFromFile(byteCodePath); if (!data.isNull()) { script = JS_DecodeScript(cx, data.getBytes(), static_cast(data.getSize()), nullptr, nullptr); } // b) no jsc file, check js file if (!script) { /* Clear any pending exception from previous failed decoding. */ ReportException(cx); std::string fullPath = futil->fullPathForFilename(path); JS::CompileOptions options(cx); options.setUTF8(true).setFileAndLine(fullPath.c_str(), 1); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) std::string jsFileContent = futil->getStringFromFile(fullPath); if (!jsFileContent.empty()) { script = JS::Compile(cx, obj, options, jsFileContent.c_str(), jsFileContent.size()); } #else script = JS::Compile(cx, obj, options, fullPath.c_str()); #endif } JSBool evaluatedOK = false; if (script) { jsval rval; filename_script[path] = script; evaluatedOK = JS_ExecuteScript(cx, global, script, &rval); if (JS_FALSE == evaluatedOK) { cocos2d::log("(evaluatedOK == JS_FALSE)"); JS_ReportPendingException(cx); } } return evaluatedOK; } void ScriptingCore::reset() { cleanup(); start(); } ScriptingCore::~ScriptingCore() { cleanup(); } void ScriptingCore::cleanup() { localStorageFree(); removeAllRoots(_cx); if (_cx) { JS_DestroyContext(_cx); _cx = NULL; } if (_rt) { JS_DestroyRuntime(_rt); _rt = NULL; } JS_ShutDown(); if (_js_log_buf) { free(_js_log_buf); _js_log_buf = NULL; } for (auto iter = _js_global_type_map.begin(); iter != _js_global_type_map.end(); ++iter) { free(iter->second->jsclass); free(iter->second); } _js_global_type_map.clear(); } void ScriptingCore::reportError(JSContext *cx, const char *message, JSErrorReport *report) { js_log("%s:%u:%s\n", report->filename ? report->filename : "", (unsigned int) report->lineno, message); }; JSBool ScriptingCore::log(JSContext* cx, uint32_t argc, jsval *vp) { if (argc > 0) { JSString *string = NULL; JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); if (string) { JSStringWrapper wrapper(string); js_log("%s", wrapper.get()); } } return JS_TRUE; } void ScriptingCore::removeScriptObjectByObject(Object* pObj) { js_proxy_t* nproxy; js_proxy_t* jsproxy; void *ptr = (void*)pObj; nproxy = jsb_get_native_proxy(ptr); if (nproxy) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); jsproxy = jsb_get_js_proxy(nproxy->obj); JS_RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(nproxy, jsproxy); } } JSBool ScriptingCore::setReservedSpot(uint32_t i, JSObject *obj, jsval value) { JS_SetReservedSlot(obj, i, value); return JS_TRUE; } JSBool ScriptingCore::executeScript(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { jsval* argv = JS_ARGV(cx, vp); JSString* str = JS_ValueToString(cx, argv[0]); JSStringWrapper path(str); JSBool res = false; if (argc == 2 && argv[1].isString()) { JSString* globalName = JSVAL_TO_STRING(argv[1]); JSStringWrapper name(globalName); // js::RootedObject* rootedGlobal = globals[name]; JSObject* debugObj = ScriptingCore::getInstance()->getDebugGlobal(); if (debugObj) { res = ScriptingCore::getInstance()->runScript(path.get(), debugObj); } else { JS_ReportError(cx, "Invalid global object: %s", name.get()); return JS_FALSE; } } else { JSObject* glob = JS::CurrentGlobalOrNull(cx); res = ScriptingCore::getInstance()->runScript(path.get(), glob); } return res; } return JS_TRUE; } JSBool ScriptingCore::forceGC(JSContext *cx, uint32_t argc, jsval *vp) { JSRuntime *rt = JS_GetRuntime(cx); JS_GC(rt); return JS_TRUE; } //static void dumpNamedRoot(const char *name, void *addr, JSGCRootType type, void *data) //{ // CCLOG("Root: '%s' at %p", name, addr); //} JSBool ScriptingCore::dumpRoot(JSContext *cx, uint32_t argc, jsval *vp) { // JS_DumpNamedRoots is only available on DEBUG versions of SpiderMonkey. // Mac and Simulator versions were compiled with DEBUG. #if COCOS2D_DEBUG // JSContext *_cx = ScriptingCore::getInstance()->getGlobalContext(); // JSRuntime *rt = JS_GetRuntime(_cx); // JS_DumpNamedRoots(rt, dumpNamedRoot, NULL); // JS_DumpHeap(rt, stdout, NULL, JSTRACE_OBJECT, NULL, 2, NULL); #endif return JS_TRUE; } JSBool ScriptingCore::addRootJS(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 1) { JSObject *o = NULL; if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { if (JS_AddNamedObjectRoot(cx, &o, "from-js") == JS_FALSE) { LOGD("something went wrong when setting an object to the root"); } } return JS_TRUE; } return JS_FALSE; } JSBool ScriptingCore::removeRootJS(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 1) { JSObject *o = NULL; if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { JS_RemoveObjectRoot(cx, &o); } return JS_TRUE; } return JS_FALSE; } void ScriptingCore::pauseSchedulesAndActions(js_proxy_t* p) { Array * arr = JSScheduleWrapper::getTargetForJSObject(p->obj); if (! arr) return; Node* node = (Node*)p->ptr; for(unsigned int i = 0; i < arr->count(); ++i) { if (arr->getObjectAtIndex(i)) { node->getScheduler()->pauseTarget(arr->getObjectAtIndex(i)); } } } void ScriptingCore::resumeSchedulesAndActions(js_proxy_t* p) { Array * arr = JSScheduleWrapper::getTargetForJSObject(p->obj); if (!arr) return; Node* node = (Node*)p->ptr; for(unsigned int i = 0; i < arr->count(); ++i) { if (!arr->getObjectAtIndex(i)) continue; node->getScheduler()->resumeTarget(arr->getObjectAtIndex(i)); } } void ScriptingCore::cleanupSchedulesAndActions(js_proxy_t* p) { Array* arr = JSScheduleWrapper::getTargetForJSObject(p->obj); if (arr) { Scheduler* pScheduler = Director::getInstance()->getScheduler(); Object* pObj = NULL; CCARRAY_FOREACH(arr, pObj) { pScheduler->unscheduleAllForTarget(pObj); } JSScheduleWrapper::removeAllTargetsForJSObject(p->obj); } } int ScriptingCore::handleNodeEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value) return 0; Node* node = static_cast(basicScriptData->nativeObject); int action = *((int*)(basicScriptData->value)); js_proxy_t * p = jsb_get_native_proxy(node); if (!p) return 0; jsval retval; jsval dataVal = INT_TO_JSVAL(1); if (action == kNodeOnEnter) { executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnter", 1, &dataVal, &retval); resumeSchedulesAndActions(p); } else if (action == kNodeOnExit) { executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExit", 1, &dataVal, &retval); pauseSchedulesAndActions(p); } else if (action == kNodeOnEnterTransitionDidFinish) { executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnterTransitionDidFinish", 1, &dataVal, &retval); } else if (action == kNodeOnExitTransitionDidStart) { executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExitTransitionDidStart", 1, &dataVal, &retval); } else if (action == kNodeOnCleanup) { cleanupSchedulesAndActions(p); } return 1; } int ScriptingCore::handleMenuClickedEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (NULL == basicScriptData->nativeObject) return 0; MenuItem* menuItem = static_cast(basicScriptData->nativeObject); js_proxy_t * p = jsb_get_native_proxy(menuItem); if (!p) return 0; jsval retval; jsval dataVal; js_proxy_t *proxy = jsb_get_native_proxy(menuItem); dataVal = (proxy ? OBJECT_TO_JSVAL(proxy->obj) : JSVAL_NULL); executeJSFunctionFromReservedSpot(this->_cx, p->obj, dataVal, retval); return 1; } int ScriptingCore::handleTouchesEvent(void* data) { if (NULL == data) return 0; TouchesScriptData* touchesScriptData = static_cast(data); if (NULL == touchesScriptData->nativeObject || touchesScriptData->touches.empty()) return 0; Layer* pLayer = static_cast(touchesScriptData->nativeObject); EventTouch::EventCode eventType = touchesScriptData->actionType; const std::vector& touches = touchesScriptData->touches; std::string funcName = ""; getTouchesFuncName(eventType, funcName); JSObject *jsretArr = JS_NewArrayObject(this->_cx, 0, NULL); JS_AddNamedObjectRoot(this->_cx, &jsretArr, "touchArray"); int count = 0; for (auto& touch : touches) { jsval jsret; getJSTouchObject(this->_cx, touch, jsret); if (!JS_SetElement(this->_cx, jsretArr, count, &jsret)) { break; } ++count; } executeFunctionWithObjectData(pLayer, funcName.c_str(), jsretArr); JS_RemoveObjectRoot(this->_cx, &jsretArr); for (auto& touch : touches) { jsval jsret; removeJSTouchObject(this->_cx, touch, jsret); } return 1; } int ScriptingCore::handleTouchEvent(void* data) { if (NULL == data) return 0; TouchScriptData* touchScriptData = static_cast(data); if (NULL == touchScriptData->nativeObject || NULL == touchScriptData->touch) return 0; Layer* pLayer = static_cast(touchScriptData->nativeObject); EventTouch::EventCode eventType = touchScriptData->actionType; Touch *pTouch = touchScriptData->touch; std::string funcName = ""; getTouchFuncName(eventType, funcName); jsval jsret; getJSTouchObject(this->getGlobalContext(), pTouch, jsret); JSObject *jsObj = JSVAL_TO_OBJECT(jsret); bool retval = executeFunctionWithObjectData(pLayer, funcName.c_str(), jsObj); removeJSTouchObject(this->getGlobalContext(), pTouch, jsret); return retval; } bool ScriptingCore::executeFunctionWithObjectData(Node *self, const char *name, JSObject *obj) { js_proxy_t * p = jsb_get_native_proxy(self); if (!p) return false; jsval retval; jsval dataVal = OBJECT_TO_JSVAL(obj); executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), name, 1, &dataVal, &retval); if (JSVAL_IS_NULL(retval)) { return false; } else if (JSVAL_IS_BOOLEAN(retval)) { return JSVAL_TO_BOOLEAN(retval); } return false; } JSBool ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc /* = 0 */, jsval *vp /* = NULL */, jsval* retVal /* = NULL */) { JSBool bRet = JS_FALSE; JSBool hasAction; JSContext* cx = this->_cx; JS::RootedValue temp_retval(cx); JSObject* obj = JSVAL_TO_OBJECT(owner); do { JSAutoCompartment ac(cx, obj); if (JS_HasProperty(cx, obj, name, &hasAction) && hasAction) { if (!JS_GetProperty(cx, obj, name, &temp_retval)) { break; } if (temp_retval == JSVAL_VOID) { break; } if (retVal) { bRet = JS_CallFunctionName(cx, obj, name, argc, vp, retVal); } else { jsval jsret; bRet = JS_CallFunctionName(cx, obj, name, argc, vp, &jsret); } } }while(0); return bRet; } int ScriptingCore::handleAccelerometerEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value) return 0; Acceleration* accelerationValue = static_cast(basicScriptData->value); Layer* layer = static_cast(basicScriptData->nativeObject); jsval value = ccacceleration_to_jsval(this->getGlobalContext(), *accelerationValue); JS_AddValueRoot(this->getGlobalContext(), &value); executeFunctionWithObjectData(layer, "onAccelerometer", JSVAL_TO_OBJECT(value)); JS_RemoveValueRoot(this->getGlobalContext(), &value); return 1; } int ScriptingCore::handleKeypadEvent(void* data) { if (NULL == data) return 0; KeypadScriptData* keypadScriptData = static_cast(data); if (NULL == keypadScriptData->nativeObject) return 0; EventKeyboard::KeyCode action = keypadScriptData->actionType; js_proxy_t * p = jsb_get_native_proxy(keypadScriptData->nativeObject); if (p) { JSBool ret = JS_FALSE; switch(action) { case EventKeyboard::KeyCode::KEY_BACKSPACE: ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onBackClicked"); if (!ret) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "backClicked"); if (ret) { CCLOG("backClicked will be deprecated, please use onBackClicked instead."); } } break; case EventKeyboard::KeyCode::KEY_MENU: ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onMenuClicked"); if (!ret) { ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "menuClicked"); if (ret) { CCLOG("menuClicked will be deprecated, please use onMenuClicked instead."); } } break; default: break; } return 1; } return 0; } int ScriptingCore::executeCustomTouchesEvent(EventTouch::EventCode eventType, const std::vector& touches, JSObject *obj) { jsval retval; std::string funcName; getTouchesFuncName(eventType, funcName); JSObject *jsretArr = JS_NewArrayObject(this->_cx, 0, NULL); JS_AddNamedObjectRoot(this->_cx, &jsretArr, "touchArray"); int count = 0; for (auto& touch : touches) { jsval jsret; getJSTouchObject(this->_cx, touch, jsret); if (!JS_SetElement(this->_cx, jsretArr, count, &jsret)) { break; } ++count; } jsval jsretArrVal = OBJECT_TO_JSVAL(jsretArr); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsretArrVal, &retval); JS_RemoveObjectRoot(this->_cx, &jsretArr); for (auto& touch : touches) { jsval jsret; removeJSTouchObject(this->_cx, touch, jsret); } return 1; } int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, Touch *pTouch, JSObject *obj) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval retval; std::string funcName; getTouchFuncName(eventType, funcName); jsval jsTouch; getJSTouchObject(this->_cx, pTouch, jsTouch); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval); // Remove touch object from global hash table and unroot it. removeJSTouchObject(this->_cx, pTouch, jsTouch); return 1; } int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, Touch *pTouch, JSObject *obj, jsval &retval) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET std::string funcName; getTouchFuncName(eventType, funcName); jsval jsTouch; getJSTouchObject(this->_cx, pTouch, jsTouch); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval); // Remove touch object from global hash table and unroot it. removeJSTouchObject(this->_cx, pTouch, jsTouch); return 1; } int ScriptingCore::sendEvent(ScriptEvent* evt) { if (NULL == evt) return 0; JSAutoCompartment ac(_cx, _global); switch (evt->type) { case kNodeEvent: { return handleNodeEvent(evt->data); } break; case kMenuClickedEvent: { return handleMenuClickedEvent(evt->data); } break; case kTouchEvent: { return handleTouchEvent(evt->data); } break; case kTouchesEvent: { return handleTouchesEvent(evt->data); } break; case kKeypadEvent: { return handleKeypadEvent(evt->data); } break; case kAccelerometerEvent: { return handleAccelerometerEvent(evt->data); } break; default: break; } return 0; } bool ScriptingCore::parseConfig(ConfigType type, const std::string &str) { jsval args[2]; args[0] = int32_to_jsval(_cx, static_cast(type)); args[1] = std_string_to_jsval(_cx, str); return (JS_TRUE == executeFunctionWithOwner(OBJECT_TO_JSVAL(_global), "__onParseConfig", 2, args)); } #pragma mark - Debug void SimpleRunLoop::update(float dt) { g_qMutex.lock(); size_t size = g_queue.size(); g_qMutex.unlock(); while (size > 0) { g_qMutex.lock(); auto first = g_queue.begin(); std::string str = *first; g_queue.erase(first); size = g_queue.size(); g_qMutex.unlock(); ScriptingCore::getInstance()->debugProcessInput(str); } } void ScriptingCore::debugProcessInput(const std::string& str) { JSAutoCompartment ac(_cx, _debugGlobal); JSString* jsstr = JS_NewStringCopyZ(_cx, str.c_str()); jsval argv = STRING_TO_JSVAL(jsstr); jsval outval; JS_CallFunctionName(_cx, _debugGlobal, "processInput", 1, &argv, &outval); } static bool NS_ProcessNextEvent() { g_qMutex.lock(); size_t size = g_queue.size(); g_qMutex.unlock(); while (size > 0) { g_qMutex.lock(); auto first = g_queue.begin(); std::string str = *first; g_queue.erase(first); size = g_queue.size(); g_qMutex.unlock(); ScriptingCore::getInstance()->debugProcessInput(str); } // std::this_thread::yield(); std::this_thread::sleep_for(std::chrono::milliseconds(10)); return true; } JSBool JSBDebug_enterNestedEventLoop(JSContext* cx, unsigned argc, jsval* vp) { enum { NS_OK = 0, NS_ERROR_UNEXPECTED }; #define NS_SUCCEEDED(v) ((v) == NS_OK) int rv = NS_OK; uint32_t nestLevel = ++s_nestedLoopLevel; while (NS_SUCCEEDED(rv) && s_nestedLoopLevel >= nestLevel) { if (!NS_ProcessNextEvent()) rv = NS_ERROR_UNEXPECTED; } CCASSERT(s_nestedLoopLevel <= nestLevel, "nested event didn't unwind properly"); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return JS_TRUE; } JSBool JSBDebug_exitNestedEventLoop(JSContext* cx, unsigned argc, jsval* vp) { if (s_nestedLoopLevel > 0) { --s_nestedLoopLevel; } else { JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(0)); return JS_TRUE; } JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return JS_TRUE; } JSBool JSBDebug_getEventLoopNestLevel(JSContext* cx, unsigned argc, jsval* vp) { JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); return JS_TRUE; } //#pragma mark - Debugger static void _clientSocketWriteAndClearString(std::string& s) { ::send(clientSocket, s.c_str(), s.length(), 0); s.clear(); } static void processInput(const std::string& data) { std::lock_guard lk(g_qMutex); g_queue.push_back(data); } static void clearBuffers() { std::lock_guard lk(g_rwMutex); // only process input if there's something and we're not locked if (inData.length() > 0) { processInput(inData); inData.clear(); } if (outData.length() > 0) { _clientSocketWriteAndClearString(outData); } } static void serverEntryPoint(void) { // start a server, accept the connection and keep reading data from it struct addrinfo hints, *result = nullptr, *rp = nullptr; int s = 0; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_INET; // IPv4 hints.ai_socktype = SOCK_STREAM; // TCP stream sockets hints.ai_flags = AI_PASSIVE; // fill in my IP for me std::stringstream portstr; portstr << JSB_DEBUGGER_PORT; int err = 0; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) WSADATA wsaData; err = WSAStartup(MAKEWORD(2, 2),&wsaData); #endif if ((err = getaddrinfo(NULL, portstr.str().c_str(), &hints, &result)) != 0) { LOGD("getaddrinfo error : %s\n", gai_strerror(err)); } for (rp = result; rp != NULL; rp = rp->ai_next) { if ((s = socket(rp->ai_family, rp->ai_socktype, 0)) < 0) { continue; } int optval = 1; if ((setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(optval))) < 0) { close(s); TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_REUSEADDR"); return; } #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) if ((setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval))) < 0) { close(s); TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_NOSIGPIPE"); return; } #endif //(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) if ((::bind(s, rp->ai_addr, rp->ai_addrlen)) == 0) { break; } close(s); s = -1; } if (s < 0 || rp == NULL) { TRACE_DEBUGGER_SERVER("debug server : error creating/binding socket"); return; } freeaddrinfo(result); listen(s, 1); while (true) { clientSocket = accept(s, NULL, NULL); if (clientSocket < 0) { TRACE_DEBUGGER_SERVER("debug server : error on accept"); return; } else { // read/write data TRACE_DEBUGGER_SERVER("debug server : client connected"); inData = "connected"; // process any input, send any output clearBuffers(); char buf[1024] = {0}; int readBytes = 0; while ((readBytes = ::recv(clientSocket, buf, sizeof(buf), 0)) > 0) { buf[readBytes] = '\0'; // TRACE_DEBUGGER_SERVER("debug server : received command >%s", buf); // no other thread is using this inData.append(buf); // process any input, send any output clearBuffers(); } // while(read) close(clientSocket); } } // while(true) } JSBool JSBDebug_BufferWrite(JSContext* cx, unsigned argc, jsval* vp) { if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); JSStringWrapper strWrapper(argv[0]); // this is safe because we're already inside a lock (from clearBuffers) outData.append(strWrapper.get()); _clientSocketWriteAndClearString(outData); } return JS_TRUE; } void ScriptingCore::enableDebugger() { if (_debugGlobal == NULL) { JSAutoCompartment ac0(_cx, _global); JS_SetDebugMode(_cx, JS_TRUE); _debugGlobal = NewGlobalObject(_cx, true); // Adds the debugger object to root, otherwise it may be collected by GC. JS_AddObjectRoot(_cx, &_debugGlobal); JS_WrapObject(_cx, &_debugGlobal); JSAutoCompartment ac(_cx, _debugGlobal); // these are used in the debug program JS_DefineFunction(_cx, _debugGlobal, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(_cx, _debugGlobal, "_bufferWrite", JSBDebug_BufferWrite, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(_cx, _debugGlobal, "_enterNestedEventLoop", JSBDebug_enterNestedEventLoop, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(_cx, _debugGlobal, "_exitNestedEventLoop", JSBDebug_exitNestedEventLoop, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(_cx, _debugGlobal, "_getEventLoopNestLevel", JSBDebug_getEventLoopNestLevel, 0, JSPROP_READONLY | JSPROP_PERMANENT); runScript("jsb_debugger.js", _debugGlobal); // prepare the debugger jsval argv = OBJECT_TO_JSVAL(_global); jsval outval; JSBool ok = JS_CallFunctionName(_cx, _debugGlobal, "_prepareDebugger", 1, &argv, &outval); if (!ok) { JS_ReportPendingException(_cx); } // start bg thread auto t = std::thread(&serverEntryPoint); t.detach(); Scheduler* scheduler = Director::getInstance()->getScheduler(); scheduler->scheduleUpdateForTarget(this->_runLoop, 0, false); } } JSObject* NewGlobalObject(JSContext* cx, bool debug) { JS::CompartmentOptions options; options.setVersion(JSVERSION_LATEST); JS::RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, NULL, JS::DontFireOnNewGlobalHook, options)); if (!glob) { return NULL; } JSAutoCompartment ac(cx, glob); JSBool ok = JS_TRUE; ok = JS_InitStandardClasses(cx, glob); if (ok) JS_InitReflect(cx, glob); if (ok && debug) ok = JS_DefineDebuggerObject(cx, glob); if (!ok) return NULL; JS_FireOnNewGlobalObject(cx, glob); return glob; } JSBool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value) { JSClass *klass = JS_GetClass(obj); unsigned int slots = JSCLASS_RESERVED_SLOTS(klass); if ( idx >= slots ) return JS_FALSE; JS_SetReservedSlot(obj, idx, value); return JS_TRUE; } JSBool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret) { JSClass *klass = JS_GetClass(obj); unsigned int slots = JSCLASS_RESERVED_SLOTS(klass); if ( idx >= slots ) return JS_FALSE; ret = JS_GetReservedSlot(obj, idx); return JS_TRUE; } js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj) { js_proxy_t* p = nullptr; JS_NEW_PROXY(p, nativeObj, jsObj); return p; } js_proxy_t* jsb_get_native_proxy(void* nativeObj) { js_proxy_t* p = nullptr; JS_GET_PROXY(p, nativeObj); return p; } js_proxy_t* jsb_get_js_proxy(JSObject* jsObj) { js_proxy_t* p = nullptr; JS_GET_NATIVE_PROXY(p, jsObj); return p; } void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy) { JS_REMOVE_PROXY(nativeProxy, jsProxy); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/ScriptingCore.h ================================================ // // ScriptingCore.h // testmonkey // // Created by Rolando Abarca on 3/14/12. // Copyright (c) 2012 Zynga Inc. All rights reserved. // #ifndef __SCRIPTING_CORE_H__ #define __SCRIPTING_CORE_H__ #include #include #include "cocos2d.h" #include "js_bindings_config.h" #include "js_bindings_core.h" #include "jsapi.h" #include "jsfriendapi.h" #include "spidermonkey_specifics.h" #include "js_manual_conversions.h" void js_log(const char *format, ...); typedef void (*sc_register_sth)(JSContext* cx, JSObject* global); void registerDefaultClasses(JSContext* cx, JSObject* global); class SimpleRunLoop : public cocos2d::Object { public: void update(float d); }; class ScriptingCore : public cocos2d::ScriptEngineProtocol { JSRuntime *_rt; JSContext *_cx; JSObject *_global; JSObject *_debugGlobal; SimpleRunLoop* _runLoop; ScriptingCore(); public: ~ScriptingCore(); static ScriptingCore *getInstance() { static ScriptingCore* pInstance = NULL; if (pInstance == NULL) { pInstance = new ScriptingCore(); } return pInstance; }; virtual cocos2d::ccScriptType getScriptType() { return cocos2d::kScriptTypeJavascript; }; /** @brief Remove Object from lua state @param object to remove */ virtual void removeScriptObjectByObject(cocos2d::Object* pObj); /** @brief Execute script code contained in the given string. @param codes holding the valid script code that should be executed. @return 0 if the string is excuted correctly. @return other if the string is excuted wrongly. */ virtual int executeString(const char* codes) { return 0; } void pauseSchedulesAndActions(js_proxy_t* p); void resumeSchedulesAndActions(js_proxy_t* p); void cleanupSchedulesAndActions(js_proxy_t* p); /** @brief Execute a script file. @param filename String object holding the filename of the script file that is to be executed */ virtual int executeScriptFile(const char* filename) { return 0; } /** @brief Execute a scripted global function. @brief The function should not take any parameters and should return an integer. @param functionName String object holding the name of the function, in the global script environment, that is to be executed. @return The integer value returned from the script function. */ virtual int executeGlobalFunction(const char* functionName) { return 0; } virtual int sendEvent(cocos2d::ScriptEvent* message) override; virtual bool parseConfig(ConfigType type, const std::string& str) override; virtual bool handleAssert(const char *msg) { return false; } bool executeFunctionWithObjectData(cocos2d::Node *self, const char *name, JSObject *obj); JSBool executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc = 0, jsval* vp = NULL, jsval* retVal = NULL); void executeJSFunctionWithThisObj(jsval thisObj, jsval callback, uint32_t argc = 0, jsval* vp = NULL, jsval* retVal = NULL); /** * will eval the specified string * @param string The string with the javascript code to be evaluated * @param outVal The jsval that will hold the return value of the evaluation. * Can be NULL. */ JSBool evalString(const char *string, jsval *outVal, const char *filename = NULL, JSContext* cx = NULL, JSObject* global = NULL); /** * will run the specified string * @param string The path of the script to be run */ JSBool runScript(const char *path, JSObject* global = NULL, JSContext* cx = NULL); /** * initialize everything */ void start(); /** * cleanup everything */ void cleanup(); /** * cleanup everything then initialize everything */ void reset(); /** * will add the register_sth callback to the list of functions that need to be called * after the creation of the context */ void addRegisterCallback(sc_register_sth callback); /** * Will create a new context. If one is already there, it will destroy the old context * and create a new one. */ void createGlobalContext(); static void removeAllRoots(JSContext *cx); int executeCustomTouchEvent(cocos2d::EventTouch::EventCode eventType, cocos2d::Touch *pTouch, JSObject *obj, jsval &retval); int executeCustomTouchEvent(cocos2d::EventTouch::EventCode eventType, cocos2d::Touch *pTouch, JSObject *obj); int executeCustomTouchesEvent(cocos2d::EventTouch::EventCode eventType, const std::vector& touches, JSObject *obj); /** * @return the global context */ JSContext* getGlobalContext() { return _cx; }; /** * @param cx * @param message * @param report */ static void reportError(JSContext *cx, const char *message, JSErrorReport *report); /** * Log something using CCLog * @param cx * @param argc * @param vp */ static JSBool log(JSContext *cx, uint32_t argc, jsval *vp); JSBool setReservedSpot(uint32_t i, JSObject *obj, jsval value); /** * run a script from script :) */ static JSBool executeScript(JSContext *cx, uint32_t argc, jsval *vp); /** * Force a cycle of GC * @param cx * @param argc * @param vp */ static JSBool forceGC(JSContext *cx, uint32_t argc, jsval *vp); static JSBool dumpRoot(JSContext *cx, uint32_t argc, jsval *vp); static JSBool addRootJS(JSContext *cx, uint32_t argc, jsval *vp); static JSBool removeRootJS(JSContext *cx, uint32_t argc, jsval *vp); /** * enable the debug environment */ void debugProcessInput(const std::string& str); void enableDebugger(); JSObject* getDebugGlobal() { return _debugGlobal; } JSObject* getGlobalObject() { return _global; } private: void string_report(jsval val); int handleTouchesEvent(void* data); int handleTouchEvent(void* data); int handleNodeEvent(void* data); int handleMenuClickedEvent(void* data); int handleAccelerometerEvent(void* data); int handleKeypadEvent(void* data); }; JSObject* NewGlobalObject(JSContext* cx, bool debug = false); JSBool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value); JSBool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret); js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj); js_proxy_t* jsb_get_native_proxy(void* nativeObj); js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy); #endif /* __SCRIPTING_CORE_H__ */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := jsb_chipmunk_static LOCAL_MODULE_FILENAME := libcocos2dxjsbchipmunk LOCAL_SRC_FILES := js_bindings_chipmunk_manual.cpp \ js_bindings_chipmunk_functions.cpp \ js_bindings_chipmunk_auto_classes.cpp \ js_bindings_chipmunk_registration.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../../.. LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,scripting/javascript/bindings) $(call import-module,extensions) $(call import-module,chipmunk) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 * Script version: v0.3 */ #include "js_bindings_config.h" #ifdef JSB_INCLUDE_CHIPMUNK #include "js_bindings_chipmunk_manual.h" #include "jsfriendapi.h" #include "js_bindings_config.h" #include "js_manual_conversions.h" #include "js_bindings_chipmunk_functions.h" /* * cpConstraint */ #pragma mark - cpConstraint JSClass* JSB_cpConstraint_class = NULL; JSObject* JSB_cpConstraint_object = NULL; // Constructor JSBool JSB_cpConstraint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); JSB_PRECONDITION2(false, cx, JS_TRUE, "No constructor"); return JS_TRUE; } // Destructor void JSB_cpConstraint_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpConstraint), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpConstraint)", jsthis); } } // Arguments: // Ret value: void JSBool JSB_cpConstraint_activateBodies(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpConstraintActivateBodies((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpConstraint_destroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpConstraintDestroy((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: cpBody* JSBool JSB_cpConstraint_getA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpBody* ret_val; ret_val = cpConstraintGetA((cpConstraint*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpBody* JSBool JSB_cpConstraint_getB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpBody* ret_val; ret_val = cpConstraintGetB((cpConstraint*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpConstraint_getErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpFloat ret_val; ret_val = cpConstraintGetErrorBias((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpConstraint_getImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpFloat ret_val; ret_val = cpConstraintGetImpulse((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpConstraint_getMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpFloat ret_val; ret_val = cpConstraintGetMaxBias((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpConstraint_getMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpFloat ret_val; ret_val = cpConstraintGetMaxForce((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpSpace* JSBool JSB_cpConstraint_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; cpSpace* ret_val; ret_val = cpConstraintGetSpace((cpConstraint*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpSpace_object, JSB_cpSpace_class, "cpSpace" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpConstraint_setErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintSetErrorBias((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpConstraint_setMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintSetMaxBias((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpConstraint_setMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpConstraint* arg0 = (cpConstraint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintSetMaxForce((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpConstraint_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpConstraint_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpConstraint_class->name = name; JSB_cpConstraint_class->addProperty = JS_PropertyStub; JSB_cpConstraint_class->delProperty = JS_DeletePropertyStub; JSB_cpConstraint_class->getProperty = JS_PropertyStub; JSB_cpConstraint_class->setProperty = JS_StrictPropertyStub; JSB_cpConstraint_class->enumerate = JS_EnumerateStub; JSB_cpConstraint_class->resolve = JS_ResolveStub; JSB_cpConstraint_class->convert = JS_ConvertStub; JSB_cpConstraint_class->finalize = JSB_cpConstraint_finalize; JSB_cpConstraint_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("activateBodies", JSB_cpConstraint_activateBodies, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("destroy", JSB_cpConstraint_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getA", JSB_cpConstraint_getA, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getB", JSB_cpConstraint_getB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getErrorBias", JSB_cpConstraint_getErrorBias, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getImpulse", JSB_cpConstraint_getImpulse, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxBias", JSB_cpConstraint_getMaxBias, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxForce", JSB_cpConstraint_getMaxForce, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpace", JSB_cpConstraint_getSpace, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setErrorBias", JSB_cpConstraint_setErrorBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxBias", JSB_cpConstraint_setMaxBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxForce", JSB_cpConstraint_setMaxForce, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpConstraint_object = JS_InitClass(cx, globalObj, JSB_cpBase_object, JSB_cpConstraint_class, JSB_cpConstraint_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpGrooveJoint */ #pragma mark - cpGrooveJoint JSClass* JSB_cpGrooveJoint_class = NULL; JSObject* JSB_cpGrooveJoint_object = NULL; // Arguments: cpBody*, cpBody*, cpVect, cpVect, cpVect // Constructor JSBool JSB_cpGrooveJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==5, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpGrooveJoint_class, JSB_cpGrooveJoint_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; cpVect arg4; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpGrooveJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpVect)arg4 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpGrooveJoint_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpGrooveJoint), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpGrooveJoint)", jsthis); } } // Arguments: // Ret value: cpVect JSBool JSB_cpGrooveJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; cpVect ret_val; ret_val = cpGrooveJointGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpGrooveJoint_getGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; cpVect ret_val; ret_val = cpGrooveJointGetGrooveA((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpGrooveJoint_getGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; cpVect ret_val; ret_val = cpGrooveJointGetGrooveB((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpGrooveJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGrooveJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpGrooveJoint_setGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGrooveJointSetGrooveA((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpGrooveJoint_setGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGrooveJointSetGrooveB((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpGrooveJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpGrooveJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpGrooveJoint_class->name = name; JSB_cpGrooveJoint_class->addProperty = JS_PropertyStub; JSB_cpGrooveJoint_class->delProperty = JS_DeletePropertyStub; JSB_cpGrooveJoint_class->getProperty = JS_PropertyStub; JSB_cpGrooveJoint_class->setProperty = JS_StrictPropertyStub; JSB_cpGrooveJoint_class->enumerate = JS_EnumerateStub; JSB_cpGrooveJoint_class->resolve = JS_ResolveStub; JSB_cpGrooveJoint_class->convert = JS_ConvertStub; JSB_cpGrooveJoint_class->finalize = JSB_cpGrooveJoint_finalize; JSB_cpGrooveJoint_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getAnchr2", JSB_cpGrooveJoint_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGrooveA", JSB_cpGrooveJoint_getGrooveA, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGrooveB", JSB_cpGrooveJoint_getGrooveB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr2", JSB_cpGrooveJoint_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGrooveA", JSB_cpGrooveJoint_setGrooveA, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGrooveB", JSB_cpGrooveJoint_setGrooveB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpGrooveJoint_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpGrooveJoint_class, JSB_cpGrooveJoint_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpSimpleMotor */ #pragma mark - cpSimpleMotor JSClass* JSB_cpSimpleMotor_class = NULL; JSObject* JSB_cpSimpleMotor_object = NULL; // Arguments: cpBody*, cpBody*, cpFloat // Constructor JSBool JSB_cpSimpleMotor_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpSimpleMotor_class, JSB_cpSimpleMotor_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpSimpleMotorNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpSimpleMotor_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpSimpleMotor), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpSimpleMotor)", jsthis); } } // Arguments: // Ret value: cpFloat JSBool JSB_cpSimpleMotor_getRate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSimpleMotor* arg0 = (cpSimpleMotor*) proxy->handle; cpFloat ret_val; ret_val = cpSimpleMotorGetRate((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSimpleMotor_setRate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSimpleMotor* arg0 = (cpSimpleMotor*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSimpleMotorSetRate((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpSimpleMotor_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpSimpleMotor_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpSimpleMotor_class->name = name; JSB_cpSimpleMotor_class->addProperty = JS_PropertyStub; JSB_cpSimpleMotor_class->delProperty = JS_DeletePropertyStub; JSB_cpSimpleMotor_class->getProperty = JS_PropertyStub; JSB_cpSimpleMotor_class->setProperty = JS_StrictPropertyStub; JSB_cpSimpleMotor_class->enumerate = JS_EnumerateStub; JSB_cpSimpleMotor_class->resolve = JS_ResolveStub; JSB_cpSimpleMotor_class->convert = JS_ConvertStub; JSB_cpSimpleMotor_class->finalize = JSB_cpSimpleMotor_finalize; JSB_cpSimpleMotor_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getRate", JSB_cpSimpleMotor_getRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRate", JSB_cpSimpleMotor_setRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpSimpleMotor_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpSimpleMotor_class, JSB_cpSimpleMotor_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpPivotJoint */ #pragma mark - cpPivotJoint JSClass* JSB_cpPivotJoint_class = NULL; JSObject* JSB_cpPivotJoint_object = NULL; // Arguments: cpBody*, cpBody*, cpVect // Constructor JSBool JSB_cpPivotJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4 || argc==3, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpPivotJoint_class, JSB_cpPivotJoint_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; void *ret_val; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); if(argc == 4) { ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); ret_val = cpPivotJointNew2((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2, (cpVect)arg3 ); } else { JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); ret_val = cpPivotJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2); } jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpPivotJoint_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpPivotJoint), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpPivotJoint)", jsthis); } } // Arguments: // Ret value: cpVect JSBool JSB_cpPivotJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; cpVect ret_val; ret_val = cpPivotJointGetAnchr1((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpPivotJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; cpVect ret_val; ret_val = cpPivotJointGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpPivotJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPivotJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpPivotJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPivotJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpPivotJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpPivotJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpPivotJoint_class->name = name; JSB_cpPivotJoint_class->addProperty = JS_PropertyStub; JSB_cpPivotJoint_class->delProperty = JS_DeletePropertyStub; JSB_cpPivotJoint_class->getProperty = JS_PropertyStub; JSB_cpPivotJoint_class->setProperty = JS_StrictPropertyStub; JSB_cpPivotJoint_class->enumerate = JS_EnumerateStub; JSB_cpPivotJoint_class->resolve = JS_ResolveStub; JSB_cpPivotJoint_class->convert = JS_ConvertStub; JSB_cpPivotJoint_class->finalize = JSB_cpPivotJoint_finalize; JSB_cpPivotJoint_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getAnchr1", JSB_cpPivotJoint_getAnchr1, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnchr2", JSB_cpPivotJoint_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr1", JSB_cpPivotJoint_setAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr2", JSB_cpPivotJoint_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpPivotJoint_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpPivotJoint_class, JSB_cpPivotJoint_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpPinJoint */ #pragma mark - cpPinJoint JSClass* JSB_cpPinJoint_class = NULL; JSObject* JSB_cpPinJoint_object = NULL; // Arguments: cpBody*, cpBody*, cpVect, cpVect // Constructor JSBool JSB_cpPinJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpPinJoint_class, JSB_cpPinJoint_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpPinJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpPinJoint_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpPinJoint), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpPinJoint)", jsthis); } } // Arguments: // Ret value: cpVect JSBool JSB_cpPinJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; cpVect ret_val; ret_val = cpPinJointGetAnchr1((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpPinJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; cpVect ret_val; ret_val = cpPinJointGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpPinJoint_getDist(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; cpFloat ret_val; ret_val = cpPinJointGetDist((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpPinJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPinJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpPinJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPinJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpPinJoint_setDist(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPinJointSetDist((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpPinJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpPinJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpPinJoint_class->name = name; JSB_cpPinJoint_class->addProperty = JS_PropertyStub; JSB_cpPinJoint_class->delProperty = JS_DeletePropertyStub; JSB_cpPinJoint_class->getProperty = JS_PropertyStub; JSB_cpPinJoint_class->setProperty = JS_StrictPropertyStub; JSB_cpPinJoint_class->enumerate = JS_EnumerateStub; JSB_cpPinJoint_class->resolve = JS_ResolveStub; JSB_cpPinJoint_class->convert = JS_ConvertStub; JSB_cpPinJoint_class->finalize = JSB_cpPinJoint_finalize; JSB_cpPinJoint_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getAnchr1", JSB_cpPinJoint_getAnchr1, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnchr2", JSB_cpPinJoint_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDist", JSB_cpPinJoint_getDist, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr1", JSB_cpPinJoint_setAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr2", JSB_cpPinJoint_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDist", JSB_cpPinJoint_setDist, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpPinJoint_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpPinJoint_class, JSB_cpPinJoint_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpSlideJoint */ #pragma mark - cpSlideJoint JSClass* JSB_cpSlideJoint_class = NULL; JSObject* JSB_cpSlideJoint_object = NULL; // Arguments: cpBody*, cpBody*, cpVect, cpVect, cpFloat, cpFloat // Constructor JSBool JSB_cpSlideJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==6, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpSlideJoint_class, JSB_cpSlideJoint_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; double arg4; double arg5; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg4 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg5 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpSlideJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpFloat)arg4 , (cpFloat)arg5 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpSlideJoint_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpSlideJoint), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpSlideJoint)", jsthis); } } // Arguments: // Ret value: cpVect JSBool JSB_cpSlideJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; cpVect ret_val; ret_val = cpSlideJointGetAnchr1((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpSlideJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; cpVect ret_val; ret_val = cpSlideJointGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSlideJoint_getMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; cpFloat ret_val; ret_val = cpSlideJointGetMax((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSlideJoint_getMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; cpFloat ret_val; ret_val = cpSlideJointGetMin((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpSlideJoint_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSlideJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpSlideJoint_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSlideJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSlideJoint_setMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSlideJointSetMax((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSlideJoint_setMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSlideJointSetMin((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpSlideJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpSlideJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpSlideJoint_class->name = name; JSB_cpSlideJoint_class->addProperty = JS_PropertyStub; JSB_cpSlideJoint_class->delProperty = JS_DeletePropertyStub; JSB_cpSlideJoint_class->getProperty = JS_PropertyStub; JSB_cpSlideJoint_class->setProperty = JS_StrictPropertyStub; JSB_cpSlideJoint_class->enumerate = JS_EnumerateStub; JSB_cpSlideJoint_class->resolve = JS_ResolveStub; JSB_cpSlideJoint_class->convert = JS_ConvertStub; JSB_cpSlideJoint_class->finalize = JSB_cpSlideJoint_finalize; JSB_cpSlideJoint_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getAnchr1", JSB_cpSlideJoint_getAnchr1, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnchr2", JSB_cpSlideJoint_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMax", JSB_cpSlideJoint_getMax, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMin", JSB_cpSlideJoint_getMin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr1", JSB_cpSlideJoint_setAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr2", JSB_cpSlideJoint_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMax", JSB_cpSlideJoint_setMax, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMin", JSB_cpSlideJoint_setMin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpSlideJoint_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpSlideJoint_class, JSB_cpSlideJoint_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpGearJoint */ #pragma mark - cpGearJoint JSClass* JSB_cpGearJoint_class = NULL; JSObject* JSB_cpGearJoint_object = NULL; // Arguments: cpBody*, cpBody*, cpFloat, cpFloat // Constructor JSBool JSB_cpGearJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpGearJoint_class, JSB_cpGearJoint_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; double arg3; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpGearJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpGearJoint_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpGearJoint), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpGearJoint)", jsthis); } } // Arguments: // Ret value: cpFloat JSBool JSB_cpGearJoint_getPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; cpFloat ret_val; ret_val = cpGearJointGetPhase((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpGearJoint_getRatio(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; cpFloat ret_val; ret_val = cpGearJointGetRatio((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpGearJoint_setPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGearJointSetPhase((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpGearJoint_setRatio(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGearJointSetRatio((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpGearJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpGearJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpGearJoint_class->name = name; JSB_cpGearJoint_class->addProperty = JS_PropertyStub; JSB_cpGearJoint_class->delProperty = JS_DeletePropertyStub; JSB_cpGearJoint_class->getProperty = JS_PropertyStub; JSB_cpGearJoint_class->setProperty = JS_StrictPropertyStub; JSB_cpGearJoint_class->enumerate = JS_EnumerateStub; JSB_cpGearJoint_class->resolve = JS_ResolveStub; JSB_cpGearJoint_class->convert = JS_ConvertStub; JSB_cpGearJoint_class->finalize = JSB_cpGearJoint_finalize; JSB_cpGearJoint_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getPhase", JSB_cpGearJoint_getPhase, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRatio", JSB_cpGearJoint_getRatio, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPhase", JSB_cpGearJoint_setPhase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRatio", JSB_cpGearJoint_setRatio, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpGearJoint_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpGearJoint_class, JSB_cpGearJoint_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpDampedRotarySpring */ #pragma mark - cpDampedRotarySpring JSClass* JSB_cpDampedRotarySpring_class = NULL; JSObject* JSB_cpDampedRotarySpring_object = NULL; // Arguments: cpBody*, cpBody*, cpFloat, cpFloat, cpFloat // Constructor JSBool JSB_cpDampedRotarySpring_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==5, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpDampedRotarySpring_class, JSB_cpDampedRotarySpring_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; double arg3; double arg4; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpDampedRotarySpringNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 , (cpFloat)arg4 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpDampedRotarySpring_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpDampedRotarySpring), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpDampedRotarySpring)", jsthis); } } // Arguments: // Ret value: cpFloat JSBool JSB_cpDampedRotarySpring_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; cpFloat ret_val; ret_val = cpDampedRotarySpringGetDamping((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpDampedRotarySpring_getRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; cpFloat ret_val; ret_val = cpDampedRotarySpringGetRestAngle((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpDampedRotarySpring_getStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; cpFloat ret_val; ret_val = cpDampedRotarySpringGetStiffness((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpDampedRotarySpring_setDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedRotarySpringSetDamping((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpDampedRotarySpring_setRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedRotarySpringSetRestAngle((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpDampedRotarySpring_setStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedRotarySpringSetStiffness((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpDampedRotarySpring_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpDampedRotarySpring_class->name = name; JSB_cpDampedRotarySpring_class->addProperty = JS_PropertyStub; JSB_cpDampedRotarySpring_class->delProperty = JS_DeletePropertyStub; JSB_cpDampedRotarySpring_class->getProperty = JS_PropertyStub; JSB_cpDampedRotarySpring_class->setProperty = JS_StrictPropertyStub; JSB_cpDampedRotarySpring_class->enumerate = JS_EnumerateStub; JSB_cpDampedRotarySpring_class->resolve = JS_ResolveStub; JSB_cpDampedRotarySpring_class->convert = JS_ConvertStub; JSB_cpDampedRotarySpring_class->finalize = JSB_cpDampedRotarySpring_finalize; JSB_cpDampedRotarySpring_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getDamping", JSB_cpDampedRotarySpring_getDamping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRestAngle", JSB_cpDampedRotarySpring_getRestAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStiffness", JSB_cpDampedRotarySpring_getStiffness, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDamping", JSB_cpDampedRotarySpring_setDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRestAngle", JSB_cpDampedRotarySpring_setRestAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStiffness", JSB_cpDampedRotarySpring_setStiffness, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpDampedRotarySpring_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpDampedRotarySpring_class, JSB_cpDampedRotarySpring_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpDampedSpring */ #pragma mark - cpDampedSpring JSClass* JSB_cpDampedSpring_class = NULL; JSObject* JSB_cpDampedSpring_object = NULL; // Arguments: cpBody*, cpBody*, cpVect, cpVect, cpFloat, cpFloat, cpFloat // Constructor JSBool JSB_cpDampedSpring_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==7, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpDampedSpring_class, JSB_cpDampedSpring_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; double arg4; double arg5; double arg6; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg4 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg5 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg6 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpDampedSpringNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpFloat)arg4 , (cpFloat)arg5 , (cpFloat)arg6 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpDampedSpring_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpDampedSpring), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpDampedSpring)", jsthis); } } // Arguments: // Ret value: cpVect JSBool JSB_cpDampedSpring_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpVect ret_val; ret_val = cpDampedSpringGetAnchr1((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpDampedSpring_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpVect ret_val; ret_val = cpDampedSpringGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpDampedSpring_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpFloat ret_val; ret_val = cpDampedSpringGetDamping((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpDampedSpring_getRestLength(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpFloat ret_val; ret_val = cpDampedSpringGetRestLength((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpDampedSpring_getStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; cpFloat ret_val; ret_val = cpDampedSpringGetStiffness((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpDampedSpring_setAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpDampedSpring_setAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpDampedSpring_setDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetDamping((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpDampedSpring_setRestLength(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetRestLength((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpDampedSpring_setStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetStiffness((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpDampedSpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpDampedSpring_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpDampedSpring_class->name = name; JSB_cpDampedSpring_class->addProperty = JS_PropertyStub; JSB_cpDampedSpring_class->delProperty = JS_DeletePropertyStub; JSB_cpDampedSpring_class->getProperty = JS_PropertyStub; JSB_cpDampedSpring_class->setProperty = JS_StrictPropertyStub; JSB_cpDampedSpring_class->enumerate = JS_EnumerateStub; JSB_cpDampedSpring_class->resolve = JS_ResolveStub; JSB_cpDampedSpring_class->convert = JS_ConvertStub; JSB_cpDampedSpring_class->finalize = JSB_cpDampedSpring_finalize; JSB_cpDampedSpring_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getAnchr1", JSB_cpDampedSpring_getAnchr1, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnchr2", JSB_cpDampedSpring_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDamping", JSB_cpDampedSpring_getDamping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRestLength", JSB_cpDampedSpring_getRestLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStiffness", JSB_cpDampedSpring_getStiffness, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr1", JSB_cpDampedSpring_setAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAnchr2", JSB_cpDampedSpring_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDamping", JSB_cpDampedSpring_setDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRestLength", JSB_cpDampedSpring_setRestLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStiffness", JSB_cpDampedSpring_setStiffness, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpDampedSpring_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpDampedSpring_class, JSB_cpDampedSpring_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpRatchetJoint */ #pragma mark - cpRatchetJoint JSClass* JSB_cpRatchetJoint_class = NULL; JSObject* JSB_cpRatchetJoint_object = NULL; // Arguments: cpBody*, cpBody*, cpFloat, cpFloat // Constructor JSBool JSB_cpRatchetJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpRatchetJoint_class, JSB_cpRatchetJoint_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; double arg3; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpRatchetJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpRatchetJoint_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpRatchetJoint), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpRatchetJoint)", jsthis); } } // Arguments: // Ret value: cpFloat JSBool JSB_cpRatchetJoint_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; cpFloat ret_val; ret_val = cpRatchetJointGetAngle((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpRatchetJoint_getPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; cpFloat ret_val; ret_val = cpRatchetJointGetPhase((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpRatchetJoint_getRatchet(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; cpFloat ret_val; ret_val = cpRatchetJointGetRatchet((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpRatchetJoint_setAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRatchetJointSetAngle((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpRatchetJoint_setPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRatchetJointSetPhase((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpRatchetJoint_setRatchet(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRatchetJointSetRatchet((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpRatchetJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpRatchetJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpRatchetJoint_class->name = name; JSB_cpRatchetJoint_class->addProperty = JS_PropertyStub; JSB_cpRatchetJoint_class->delProperty = JS_DeletePropertyStub; JSB_cpRatchetJoint_class->getProperty = JS_PropertyStub; JSB_cpRatchetJoint_class->setProperty = JS_StrictPropertyStub; JSB_cpRatchetJoint_class->enumerate = JS_EnumerateStub; JSB_cpRatchetJoint_class->resolve = JS_ResolveStub; JSB_cpRatchetJoint_class->convert = JS_ConvertStub; JSB_cpRatchetJoint_class->finalize = JSB_cpRatchetJoint_finalize; JSB_cpRatchetJoint_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getAngle", JSB_cpRatchetJoint_getAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPhase", JSB_cpRatchetJoint_getPhase, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRatchet", JSB_cpRatchetJoint_getRatchet, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAngle", JSB_cpRatchetJoint_setAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPhase", JSB_cpRatchetJoint_setPhase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRatchet", JSB_cpRatchetJoint_setRatchet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpRatchetJoint_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpRatchetJoint_class, JSB_cpRatchetJoint_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpRotaryLimitJoint */ #pragma mark - cpRotaryLimitJoint JSClass* JSB_cpRotaryLimitJoint_class = NULL; JSObject* JSB_cpRotaryLimitJoint_object = NULL; // Arguments: cpBody*, cpBody*, cpFloat, cpFloat // Constructor JSBool JSB_cpRotaryLimitJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpRotaryLimitJoint_class, JSB_cpRotaryLimitJoint_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; double arg3; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpRotaryLimitJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpRotaryLimitJoint_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpRotaryLimitJoint), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpConstraintFree( (cpConstraint*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpRotaryLimitJoint)", jsthis); } } // Arguments: // Ret value: cpFloat JSBool JSB_cpRotaryLimitJoint_getMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; cpFloat ret_val; ret_val = cpRotaryLimitJointGetMax((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpRotaryLimitJoint_getMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; cpFloat ret_val; ret_val = cpRotaryLimitJointGetMin((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpRotaryLimitJoint_setMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRotaryLimitJointSetMax((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpRotaryLimitJoint_setMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRotaryLimitJointSetMin((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpRotaryLimitJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpRotaryLimitJoint_class->name = name; JSB_cpRotaryLimitJoint_class->addProperty = JS_PropertyStub; JSB_cpRotaryLimitJoint_class->delProperty = JS_DeletePropertyStub; JSB_cpRotaryLimitJoint_class->getProperty = JS_PropertyStub; JSB_cpRotaryLimitJoint_class->setProperty = JS_StrictPropertyStub; JSB_cpRotaryLimitJoint_class->enumerate = JS_EnumerateStub; JSB_cpRotaryLimitJoint_class->resolve = JS_ResolveStub; JSB_cpRotaryLimitJoint_class->convert = JS_ConvertStub; JSB_cpRotaryLimitJoint_class->finalize = JSB_cpRotaryLimitJoint_finalize; JSB_cpRotaryLimitJoint_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getMax", JSB_cpRotaryLimitJoint_getMax, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMin", JSB_cpRotaryLimitJoint_getMin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMax", JSB_cpRotaryLimitJoint_setMax, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMin", JSB_cpRotaryLimitJoint_setMin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpRotaryLimitJoint_object = JS_InitClass(cx, globalObj, JSB_cpConstraint_object, JSB_cpRotaryLimitJoint_class, JSB_cpRotaryLimitJoint_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpArbiter */ #pragma mark - cpArbiter JSClass* JSB_cpArbiter_class = NULL; JSObject* JSB_cpArbiter_object = NULL; // Constructor JSBool JSB_cpArbiter_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); JSB_PRECONDITION2(false, cx, JS_TRUE, "No constructor"); return JS_TRUE; } // Destructor void JSB_cpArbiter_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpArbiter), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) // No destructor found: ( (None*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpArbiter)", jsthis); } } // Arguments: // Ret value: int JSBool JSB_cpArbiter_getCount(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; int ret_val; ret_val = cpArbiterGetCount((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: int // Ret value: cpFloat JSBool JSB_cpArbiter_getDepth(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpArbiterGetDepth((cpArbiter*)arg0 , (int)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpArbiter_getElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpFloat ret_val; ret_val = cpArbiterGetElasticity((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpArbiter_getFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpFloat ret_val; ret_val = cpArbiterGetFriction((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: int // Ret value: cpVect JSBool JSB_cpArbiter_getNormal(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpArbiterGetNormal((cpArbiter*)arg0 , (int)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: int // Ret value: cpVect JSBool JSB_cpArbiter_getPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpArbiterGetPoint((cpArbiter*)arg0 , (int)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpArbiter_getSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpVect ret_val; ret_val = cpArbiterGetSurfaceVelocity((cpArbiter*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpArbiter_ignore(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpArbiterIgnore((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: cpBool JSBool JSB_cpArbiter_isFirstContact(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpBool ret_val; ret_val = cpArbiterIsFirstContact((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpArbiter_setElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpArbiterSetElasticity((cpArbiter*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpArbiter_setFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpArbiterSetFriction((cpArbiter*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpArbiter_setSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpArbiterSetSurfaceVelocity((cpArbiter*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpArbiter_totalImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpVect ret_val; ret_val = cpArbiterTotalImpulse((cpArbiter*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpArbiter_totalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpVect ret_val; ret_val = cpArbiterTotalImpulseWithFriction((cpArbiter*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpArbiter_totalKE(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpArbiter* arg0 = (cpArbiter*) proxy->handle; cpFloat ret_val; ret_val = cpArbiterTotalKE((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } void JSB_cpArbiter_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpArbiter_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpArbiter_class->name = name; JSB_cpArbiter_class->addProperty = JS_PropertyStub; JSB_cpArbiter_class->delProperty = JS_DeletePropertyStub; JSB_cpArbiter_class->getProperty = JS_PropertyStub; JSB_cpArbiter_class->setProperty = JS_StrictPropertyStub; JSB_cpArbiter_class->enumerate = JS_EnumerateStub; JSB_cpArbiter_class->resolve = JS_ResolveStub; JSB_cpArbiter_class->convert = JS_ConvertStub; JSB_cpArbiter_class->finalize = JSB_cpArbiter_finalize; JSB_cpArbiter_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getCount", JSB_cpArbiter_getCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDepth", JSB_cpArbiter_getDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getElasticity", JSB_cpArbiter_getElasticity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFriction", JSB_cpArbiter_getFriction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNormal", JSB_cpArbiter_getNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPoint", JSB_cpArbiter_getPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSurfaceVelocity", JSB_cpArbiter_getSurfaceVelocity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ignore", JSB_cpArbiter_ignore, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFirstContact", JSB_cpArbiter_isFirstContact, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setElasticity", JSB_cpArbiter_setElasticity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFriction", JSB_cpArbiter_setFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSurfaceVelocity", JSB_cpArbiter_setSurfaceVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("totalImpulse", JSB_cpArbiter_totalImpulse, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("totalImpulseWithFriction", JSB_cpArbiter_totalImpulseWithFriction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("totalKE", JSB_cpArbiter_totalKE, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getShapes", JSB_cpArbiter_getShapes, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBodies", JSB_cpArbiter_getBodies, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpArbiter_object = JS_InitClass(cx, globalObj, JSB_cpBase_object, JSB_cpArbiter_class, JSB_cpArbiter_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpSpace */ #pragma mark - cpSpace JSClass* JSB_cpSpace_class = NULL; JSObject* JSB_cpSpace_object = NULL; // Arguments: // Constructor JSBool JSB_cpSpace_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpSpace_class, JSB_cpSpace_object, NULL); void* ret_val = cpSpaceNew( ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Arguments: cpShape* // Ret value: void JSBool JSB_cpSpace_activateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceActivateShapesTouchingShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpBool JSBool JSB_cpSpace_containsBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpSpaceContainsBody((cpSpace*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpBool JSBool JSB_cpSpace_containsConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpSpaceContainsConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpBool JSBool JSB_cpSpace_containsShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpSpaceContainsShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpSpace_destroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpSpaceDestroy((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSpace_getCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val; ret_val = cpSpaceGetCollisionBias((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpTimestamp JSBool JSB_cpSpace_getCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpTimestamp ret_val; ret_val = cpSpaceGetCollisionPersistence((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSpace_getCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val; ret_val = cpSpaceGetCollisionSlop((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSpace_getCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val; ret_val = cpSpaceGetCurrentTimeStep((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSpace_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val; ret_val = cpSpaceGetDamping((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpBool JSBool JSB_cpSpace_getEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpBool ret_val; ret_val = cpSpaceGetEnableContactGraph((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpSpace_getGravity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpVect ret_val; ret_val = cpSpaceGetGravity((cpSpace*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSpace_getIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val; ret_val = cpSpaceGetIdleSpeedThreshold((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: int JSBool JSB_cpSpace_getIterations(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; int ret_val; ret_val = cpSpaceGetIterations((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSpace_getSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpFloat ret_val; ret_val = cpSpaceGetSleepTimeThreshold((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpBody* JSBool JSB_cpSpace_getStaticBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpBody* ret_val; ret_val = cpSpaceGetStaticBody((cpSpace*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpSpace* JSBool JSB_cpSpace_init(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpSpace* ret_val; ret_val = cpSpaceInit((cpSpace*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpSpace_object, JSB_cpSpace_class, "cpSpace" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpBool JSBool JSB_cpSpace_isLocked(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpBool ret_val; ret_val = cpSpaceIsLocked((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpVect, cpLayers, cpGroup // Ret value: cpShape* JSBool JSB_cpSpace_pointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; uint32_t arg2; cpGroup arg3; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_uint( cx, *argvp++, (unsigned int*) &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShape* ret_val; ret_val = cpSpacePointQueryFirst((cpSpace*)arg0 , (cpVect)arg1 , (cpLayers)arg2 , (cpGroup)arg3 ); if(ret_val) { jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpShape_object, JSB_cpShape_class, "cpShape" ); JS_SET_RVAL(cx, vp, ret_jsval); } else { JS_SET_RVAL(cx, vp, JSVAL_NULL); } return JS_TRUE; } // Arguments: cpShape* // Ret value: void JSBool JSB_cpSpace_reindexShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceReindexShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody* // Ret value: void JSBool JSB_cpSpace_reindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceReindexShapesForBody((cpSpace*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpSpace_reindexStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; cpSpaceReindexStatic((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSpace_setCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetCollisionBias((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpTimestamp // Ret value: void JSBool JSB_cpSpace_setCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetCollisionPersistence((cpSpace*)arg0 , (cpTimestamp)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSpace_setCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetCollisionSlop((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSpace_setDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetDamping((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBool // Ret value: void JSBool JSB_cpSpace_setEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetEnableContactGraph((cpSpace*)arg0 , (cpBool)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpSpace_setGravity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetGravity((cpSpace*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSpace_setIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetIdleSpeedThreshold((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: int // Ret value: void JSBool JSB_cpSpace_setIterations(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetIterations((cpSpace*)arg0 , (int)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSpace_setSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetSleepTimeThreshold((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpSpace_step(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceStep((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat, int // Ret value: void JSBool JSB_cpSpace_useSpatialHash(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; int32_t arg2; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceUseSpatialHash((cpSpace*)arg0 , (cpFloat)arg1 , (int)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpSpace_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpSpace_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpSpace_class->name = name; JSB_cpSpace_class->addProperty = JS_PropertyStub; JSB_cpSpace_class->delProperty = JS_DeletePropertyStub; JSB_cpSpace_class->getProperty = JS_PropertyStub; JSB_cpSpace_class->setProperty = JS_StrictPropertyStub; JSB_cpSpace_class->enumerate = JS_EnumerateStub; JSB_cpSpace_class->resolve = JS_ResolveStub; JSB_cpSpace_class->convert = JS_ConvertStub; JSB_cpSpace_class->finalize = JSB_cpSpace_finalize; JSB_cpSpace_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("activateShapesTouchingShape", JSB_cpSpace_activateShapesTouchingShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("containsBody", JSB_cpSpace_containsBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("containsConstraint", JSB_cpSpace_containsConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("containsShape", JSB_cpSpace_containsShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("destroy", JSB_cpSpace_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCollisionBias", JSB_cpSpace_getCollisionBias, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCollisionPersistence", JSB_cpSpace_getCollisionPersistence, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCollisionSlop", JSB_cpSpace_getCollisionSlop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentTimeStep", JSB_cpSpace_getCurrentTimeStep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDamping", JSB_cpSpace_getDamping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEnableContactGraph", JSB_cpSpace_getEnableContactGraph, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGravity", JSB_cpSpace_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIdleSpeedThreshold", JSB_cpSpace_getIdleSpeedThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIterations", JSB_cpSpace_getIterations, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSleepTimeThreshold", JSB_cpSpace_getSleepTimeThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStaticBody", JSB_cpSpace_getStaticBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", JSB_cpSpace_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isLocked", JSB_cpSpace_isLocked, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pointQueryFirst", JSB_cpSpace_pointQueryFirst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reindexShape", JSB_cpSpace_reindexShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reindexShapesForBody", JSB_cpSpace_reindexShapesForBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reindexStatic", JSB_cpSpace_reindexStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCollisionBias", JSB_cpSpace_setCollisionBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCollisionPersistence", JSB_cpSpace_setCollisionPersistence, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCollisionSlop", JSB_cpSpace_setCollisionSlop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDamping", JSB_cpSpace_setDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEnableContactGraph", JSB_cpSpace_setEnableContactGraph, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGravity", JSB_cpSpace_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setIdleSpeedThreshold", JSB_cpSpace_setIdleSpeedThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setIterations", JSB_cpSpace_setIterations, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSleepTimeThreshold", JSB_cpSpace_setSleepTimeThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("step", JSB_cpSpace_step, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("useSpatialHash", JSB_cpSpace_useSpatialHash, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addShape", JSB_cpSpace_addShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addCollisionHandler", JSB_cpSpace_addCollisionHandler, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addStaticShape", JSB_cpSpace_addStaticShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeConstraint", JSB_cpSpace_removeConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeBody", JSB_cpSpace_removeBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeCollisionHandler", JSB_cpSpace_removeCollisionHandler, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeStaticShape", JSB_cpSpace_removeStaticShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addConstraint", JSB_cpSpace_addConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addBody", JSB_cpSpace_addBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeShape", JSB_cpSpace_removeShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpSpace_object = JS_InitClass(cx, globalObj, JSB_cpBase_object, JSB_cpSpace_class, JSB_cpSpace_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpBody */ #pragma mark - cpBody JSClass* JSB_cpBody_class = NULL; JSObject* JSB_cpBody_object = NULL; // Destructor void JSB_cpBody_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpBody), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpBodyFree( (cpBody*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpBody)", jsthis); } } // Arguments: // Ret value: void JSBool JSB_cpBody_activate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBodyActivate((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape* // Ret value: void JSBool JSB_cpBody_activateStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyActivateStatic((cpBody*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: void JSBool JSB_cpBody_applyForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; cpVect arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyApplyForce((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: void JSBool JSB_cpBody_applyImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; cpVect arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyApplyImpulse((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpBody_destroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBodyDestroy((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpBody_getAngVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val; ret_val = cpBodyGetAngVel((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpBody_getAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val; ret_val = cpBodyGetAngVelLimit((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpBody_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val; ret_val = cpBodyGetAngle((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpBody_getForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpVect ret_val; ret_val = cpBodyGetForce((cpBody*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpBody_getMass(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val; ret_val = cpBodyGetMass((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpBody_getMoment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val; ret_val = cpBodyGetMoment((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpBody_getPos(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpVect ret_val; ret_val = cpBodyGetPos((cpBody*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpBody_getRot(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpVect ret_val; ret_val = cpBodyGetRot((cpBody*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpSpace* JSBool JSB_cpBody_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpSpace* ret_val; ret_val = cpBodyGetSpace((cpBody*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpSpace_object, JSB_cpSpace_class, "cpSpace" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpBody_getTorque(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val; ret_val = cpBodyGetTorque((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpBody_getVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpVect ret_val; ret_val = cpBodyGetVel((cpBody*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpBody_getVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyGetVelAtLocalPoint((cpBody*)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpBody_getVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyGetVelAtWorldPoint((cpBody*)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpBody_getVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val; ret_val = cpBodyGetVelLimit((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat // Ret value: cpBody* JSBool JSB_cpBody_init(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; double arg2; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpBodyInit((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpBody* JSBool JSB_cpBody_initStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBody* ret_val; ret_val = cpBodyInitStatic((cpBody*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpBool JSBool JSB_cpBody_isRogue(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBool ret_val; ret_val = cpBodyIsRogue((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpBool JSBool JSB_cpBody_isSleeping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBool ret_val; ret_val = cpBodyIsSleeping((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpBool JSBool JSB_cpBody_isStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBool ret_val; ret_val = cpBodyIsStatic((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpBody_kineticEnergy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpFloat ret_val; ret_val = cpBodyKineticEnergy((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpBody_local2World(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyLocal2World((cpBody*)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpBody_resetForces(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBodyResetForces((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpBody_setAngVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetAngVel((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpBody_setAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetAngVelLimit((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpBody_setAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetAngle((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpBody_setForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetForce((cpBody*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpBody_setMass(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetMass((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpBody_setMoment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetMoment((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpBody_setPos(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetPos((cpBody*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpBody_setTorque(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetTorque((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpBody_setVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetVel((cpBody*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpBody_setVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetVelLimit((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpBody_sleep(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; cpBodySleep((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody* // Ret value: void JSBool JSB_cpBody_sleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySleepWithGroup((cpBody*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpBody_updatePosition(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyUpdatePosition((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect, cpFloat, cpFloat // Ret value: void JSBool JSB_cpBody_updateVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; double arg2; double arg3; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyUpdateVelocity((cpBody*)arg0 , (cpVect)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpBody_world2Local(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpBody* arg0 = (cpBody*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyWorld2Local((cpBody*)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } void JSB_cpBody_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpBody_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpBody_class->name = name; JSB_cpBody_class->addProperty = JS_PropertyStub; JSB_cpBody_class->delProperty = JS_DeletePropertyStub; JSB_cpBody_class->getProperty = JS_PropertyStub; JSB_cpBody_class->setProperty = JS_StrictPropertyStub; JSB_cpBody_class->enumerate = JS_EnumerateStub; JSB_cpBody_class->resolve = JS_ResolveStub; JSB_cpBody_class->convert = JS_ConvertStub; JSB_cpBody_class->finalize = JSB_cpBody_finalize; JSB_cpBody_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("activate", JSB_cpBody_activate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("activateStatic", JSB_cpBody_activateStatic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("applyForce", JSB_cpBody_applyForce, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("applyImpulse", JSB_cpBody_applyImpulse, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("destroy", JSB_cpBody_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAngVel", JSB_cpBody_getAngVel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAngVelLimit", JSB_cpBody_getAngVelLimit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAngle", JSB_cpBody_getAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getForce", JSB_cpBody_getForce, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMass", JSB_cpBody_getMass, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMoment", JSB_cpBody_getMoment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPos", JSB_cpBody_getPos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRot", JSB_cpBody_getRot, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpace", JSB_cpBody_getSpace, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTorque", JSB_cpBody_getTorque, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVel", JSB_cpBody_getVel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVelAtLocalPoint", JSB_cpBody_getVelAtLocalPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVelAtWorldPoint", JSB_cpBody_getVelAtWorldPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVelLimit", JSB_cpBody_getVelLimit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", JSB_cpBody_init, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initStatic", JSB_cpBody_initStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isRogue", JSB_cpBody_isRogue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSleeping", JSB_cpBody_isSleeping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isStatic", JSB_cpBody_isStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("kineticEnergy", JSB_cpBody_kineticEnergy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("local2World", JSB_cpBody_local2World, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resetForces", JSB_cpBody_resetForces, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAngVel", JSB_cpBody_setAngVel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAngVelLimit", JSB_cpBody_setAngVelLimit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAngle", JSB_cpBody_setAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setForce", JSB_cpBody_setForce, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMass", JSB_cpBody_setMass, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMoment", JSB_cpBody_setMoment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPos", JSB_cpBody_setPos, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTorque", JSB_cpBody_setTorque, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVel", JSB_cpBody_setVel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setVelLimit", JSB_cpBody_setVelLimit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("sleep", JSB_cpBody_sleep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("sleepWithGroup", JSB_cpBody_sleepWithGroup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updatePosition", JSB_cpBody_updatePosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateVelocity", JSB_cpBody_updateVelocity, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("world2Local", JSB_cpBody_world2Local, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUserData", JSB_cpBody_setUserData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUserData", JSB_cpBody_getUserData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpBody_object = JS_InitClass(cx, globalObj, JSB_cpBase_object, JSB_cpBody_class, JSB_cpBody_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpShape */ #pragma mark - cpShape JSClass* JSB_cpShape_class = NULL; JSObject* JSB_cpShape_object = NULL; // Constructor JSBool JSB_cpShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); JSB_PRECONDITION2(false, cx, JS_TRUE, "No constructor"); return JS_TRUE; } // Destructor void JSB_cpShape_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpShape), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpShapeFree( (cpShape*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpShape)", jsthis); } } // Arguments: // Ret value: cpBB JSBool JSB_cpShape_cacheBB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpBB ret_val; ret_val = cpShapeCacheBB((cpShape*)arg0 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpShape_destroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpShapeDestroy((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: cpBB JSBool JSB_cpShape_getBB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpBB ret_val; ret_val = cpShapeGetBB((cpShape*)arg0 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpBody* JSBool JSB_cpShape_getBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpBody* ret_val; ret_val = cpShapeGetBody((cpShape*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpCollisionType JSBool JSB_cpShape_getCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpCollisionType ret_val; ret_val = cpShapeGetCollisionType((cpShape*)arg0 ); jsval ret_jsval = uint32_to_jsval( cx, (cpCollisionType)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpShape_getElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpFloat ret_val; ret_val = cpShapeGetElasticity((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpShape_getFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpFloat ret_val; ret_val = cpShapeGetFriction((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpGroup JSBool JSB_cpShape_getGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpGroup ret_val; ret_val = cpShapeGetGroup((cpShape*)arg0 ); jsval ret_jsval = uint32_to_jsval( cx, (cpGroup)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpLayers JSBool JSB_cpShape_getLayers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpLayers ret_val; ret_val = cpShapeGetLayers((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpBool JSBool JSB_cpShape_getSensor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpBool ret_val; ret_val = cpShapeGetSensor((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpSpace* JSBool JSB_cpShape_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpSpace* ret_val; ret_val = cpShapeGetSpace((cpShape*)arg0 ); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpSpace_object, JSB_cpSpace_class, "cpSpace" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpShape_getSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; cpVect ret_val; ret_val = cpShapeGetSurfaceVelocity((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpBool JSBool JSB_cpShape_pointQuery(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpShapePointQuery((cpShape*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: void JSBool JSB_cpShape_setBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg1; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetBody((cpShape*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpCollisionType // Ret value: void JSBool JSB_cpShape_setCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpCollisionType arg1; ok &= jsval_to_uint( cx, *argvp++, (unsigned int*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetCollisionType((cpShape*)arg0 , (cpCollisionType)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpShape_setElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetElasticity((cpShape*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: void JSBool JSB_cpShape_setFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetFriction((cpShape*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpGroup // Ret value: void JSBool JSB_cpShape_setGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpGroup arg1; ok &= jsval_to_uint( cx, *argvp++, (unsigned int*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetGroup((cpShape*)arg0 , (cpGroup)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpLayers // Ret value: void JSBool JSB_cpShape_setLayers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetLayers((cpShape*)arg0 , (cpLayers)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBool // Ret value: void JSBool JSB_cpShape_setSensor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetSensor((cpShape*)arg0 , (cpBool)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect // Ret value: void JSBool JSB_cpShape_setSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetSurfaceVelocity((cpShape*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpBB JSBool JSB_cpShape_update(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpShape* arg0 = (cpShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; cpVect arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBB ret_val; ret_val = cpShapeUpdate((cpShape*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } void JSB_cpShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpShape_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpShape_class->name = name; JSB_cpShape_class->addProperty = JS_PropertyStub; JSB_cpShape_class->delProperty = JS_DeletePropertyStub; JSB_cpShape_class->getProperty = JS_PropertyStub; JSB_cpShape_class->setProperty = JS_StrictPropertyStub; JSB_cpShape_class->enumerate = JS_EnumerateStub; JSB_cpShape_class->resolve = JS_ResolveStub; JSB_cpShape_class->convert = JS_ConvertStub; JSB_cpShape_class->finalize = JSB_cpShape_finalize; JSB_cpShape_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("cacheBB", JSB_cpShape_cacheBB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("destroy", JSB_cpShape_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBB", JSB_cpShape_getBB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBody", JSB_cpShape_getBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCollisionType", JSB_cpShape_getCollisionType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getElasticity", JSB_cpShape_getElasticity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFriction", JSB_cpShape_getFriction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getGroup", JSB_cpShape_getGroup, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayers", JSB_cpShape_getLayers, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSensor", JSB_cpShape_getSensor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpace", JSB_cpShape_getSpace, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSurfaceVelocity", JSB_cpShape_getSurfaceVelocity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pointQuery", JSB_cpShape_pointQuery, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBody", JSB_cpShape_setBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCollisionType", JSB_cpShape_setCollisionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setElasticity", JSB_cpShape_setElasticity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFriction", JSB_cpShape_setFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGroup", JSB_cpShape_setGroup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLayers", JSB_cpShape_setLayers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSensor", JSB_cpShape_setSensor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSurfaceVelocity", JSB_cpShape_setSurfaceVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", JSB_cpShape_update, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpShape_object = JS_InitClass(cx, globalObj, JSB_cpBase_object, JSB_cpShape_class, JSB_cpShape_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpCircleShape */ #pragma mark - cpCircleShape JSClass* JSB_cpCircleShape_class = NULL; JSObject* JSB_cpCircleShape_object = NULL; // Arguments: cpBody*, cpFloat, cpVect // Constructor JSBool JSB_cpCircleShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpCircleShape_class, JSB_cpCircleShape_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; cpVect arg2; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpCircleShapeNew((cpBody*)arg0 , (cpFloat)arg1 , (cpVect)arg2 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpCircleShape_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpCircleShape), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpShapeFree( (cpShape*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpCircleShape)", jsthis); } } // Arguments: // Ret value: cpVect JSBool JSB_cpCircleShape_getOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpCircleShape* arg0 = (cpCircleShape*) proxy->handle; cpVect ret_val; ret_val = cpCircleShapeGetOffset((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpCircleShape_getRadius(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpCircleShape* arg0 = (cpCircleShape*) proxy->handle; cpFloat ret_val; ret_val = cpCircleShapeGetRadius((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } void JSB_cpCircleShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpCircleShape_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpCircleShape_class->name = name; JSB_cpCircleShape_class->addProperty = JS_PropertyStub; JSB_cpCircleShape_class->delProperty = JS_DeletePropertyStub; JSB_cpCircleShape_class->getProperty = JS_PropertyStub; JSB_cpCircleShape_class->setProperty = JS_StrictPropertyStub; JSB_cpCircleShape_class->enumerate = JS_EnumerateStub; JSB_cpCircleShape_class->resolve = JS_ResolveStub; JSB_cpCircleShape_class->convert = JS_ConvertStub; JSB_cpCircleShape_class->finalize = JSB_cpCircleShape_finalize; JSB_cpCircleShape_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getOffset", JSB_cpCircleShape_getOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRadius", JSB_cpCircleShape_getRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpCircleShape_object = JS_InitClass(cx, globalObj, JSB_cpShape_object, JSB_cpCircleShape_class, JSB_cpCircleShape_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpSegmentShape */ #pragma mark - cpSegmentShape JSClass* JSB_cpSegmentShape_class = NULL; JSObject* JSB_cpSegmentShape_object = NULL; // Arguments: cpBody*, cpVect, cpVect, cpFloat // Constructor JSBool JSB_cpSegmentShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==4, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentShape_class, JSB_cpSegmentShape_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; cpVect arg2; double arg3; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg0, NULL ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); void* ret_val = cpSegmentShapeNew((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 , (cpFloat)arg3 ); jsb_set_jsobject_for_proxy(jsobj, ret_val); jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpSegmentShape_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpSegmentShape), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpShapeFree( (cpShape*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpSegmentShape)", jsthis); } } // Arguments: // Ret value: cpVect JSBool JSB_cpSegmentShape_getA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; cpVect ret_val; ret_val = cpSegmentShapeGetA((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpSegmentShape_getB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; cpVect ret_val; ret_val = cpSegmentShapeGetB((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpVect JSBool JSB_cpSegmentShape_getNormal(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; cpVect ret_val; ret_val = cpSegmentShapeGetNormal((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpFloat JSBool JSB_cpSegmentShape_getRadius(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; cpFloat ret_val; ret_val = cpSegmentShapeGetRadius((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: void JSBool JSB_cpSegmentShape_setNeighbors(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg1; cpVect arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSegmentShapeSetNeighbors((cpShape*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpSegmentShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpSegmentShape_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpSegmentShape_class->name = name; JSB_cpSegmentShape_class->addProperty = JS_PropertyStub; JSB_cpSegmentShape_class->delProperty = JS_DeletePropertyStub; JSB_cpSegmentShape_class->getProperty = JS_PropertyStub; JSB_cpSegmentShape_class->setProperty = JS_StrictPropertyStub; JSB_cpSegmentShape_class->enumerate = JS_EnumerateStub; JSB_cpSegmentShape_class->resolve = JS_ResolveStub; JSB_cpSegmentShape_class->convert = JS_ConvertStub; JSB_cpSegmentShape_class->finalize = JSB_cpSegmentShape_finalize; JSB_cpSegmentShape_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getA", JSB_cpSegmentShape_getA, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getB", JSB_cpSegmentShape_getB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNormal", JSB_cpSegmentShape_getNormal, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRadius", JSB_cpSegmentShape_getRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setNeighbors", JSB_cpSegmentShape_setNeighbors, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpSegmentShape_object = JS_InitClass(cx, globalObj, JSB_cpShape_object, JSB_cpSegmentShape_class, JSB_cpSegmentShape_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } /* * cpPolyShape */ #pragma mark - cpPolyShape JSClass* JSB_cpPolyShape_class = NULL; JSObject* JSB_cpPolyShape_object = NULL; // Destructor void JSB_cpPolyShape_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpPolyShape), handle: %p", jsthis, proxy->handle); jsb_del_jsobject_for_proxy(proxy->handle); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpShapeFree( (cpShape*)proxy->handle); jsb_del_c_proxy_for_jsobject(jsthis); } else { CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpPolyShape)", jsthis); } } // Arguments: // Ret value: int JSBool JSB_cpPolyShape_getNumVerts(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPolyShape* arg0 = (cpPolyShape*) proxy->handle; int ret_val; ret_val = cpPolyShapeGetNumVerts((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: int // Ret value: cpVect JSBool JSB_cpPolyShape_getVert(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpPolyShape* arg0 = (cpPolyShape*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpPolyShapeGetVert((cpShape*)arg0 , (int)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } void JSB_cpPolyShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpPolyShape_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpPolyShape_class->name = name; JSB_cpPolyShape_class->addProperty = JS_PropertyStub; JSB_cpPolyShape_class->delProperty = JS_DeletePropertyStub; JSB_cpPolyShape_class->getProperty = JS_PropertyStub; JSB_cpPolyShape_class->setProperty = JS_StrictPropertyStub; JSB_cpPolyShape_class->enumerate = JS_EnumerateStub; JSB_cpPolyShape_class->resolve = JS_ResolveStub; JSB_cpPolyShape_class->convert = JS_ConvertStub; JSB_cpPolyShape_class->finalize = JSB_cpPolyShape_finalize; JSB_cpPolyShape_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getNumVerts", JSB_cpPolyShape_getNumVerts, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVert", JSB_cpPolyShape_getVert, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpPolyShape_object = JS_InitClass(cx, globalObj, JSB_cpShape_object, JSB_cpPolyShape_class, JSB_cpPolyShape_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } #endif // JSB_INCLUDE_CHIPMUNK ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.h ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 * Script version: v0.3 */ #include "js_bindings_config.h" #ifdef JSB_INCLUDE_CHIPMUNK #include "js_bindings_chipmunk_manual.h" extern JSObject *JSB_cpConstraint_object; extern JSClass *JSB_cpConstraint_class; void JSB_cpConstraint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpGrooveJoint_object; extern JSClass *JSB_cpGrooveJoint_class; void JSB_cpGrooveJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpSimpleMotor_object; extern JSClass *JSB_cpSimpleMotor_class; void JSB_cpSimpleMotor_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpPivotJoint_object; extern JSClass *JSB_cpPivotJoint_class; void JSB_cpPivotJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpPinJoint_object; extern JSClass *JSB_cpPinJoint_class; void JSB_cpPinJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpSlideJoint_object; extern JSClass *JSB_cpSlideJoint_class; void JSB_cpSlideJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpGearJoint_object; extern JSClass *JSB_cpGearJoint_class; void JSB_cpGearJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpDampedRotarySpring_object; extern JSClass *JSB_cpDampedRotarySpring_class; void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpDampedSpring_object; extern JSClass *JSB_cpDampedSpring_class; void JSB_cpDampedSpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpRatchetJoint_object; extern JSClass *JSB_cpRatchetJoint_class; void JSB_cpRatchetJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpRotaryLimitJoint_object; extern JSClass *JSB_cpRotaryLimitJoint_class; void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpArbiter_object; extern JSClass *JSB_cpArbiter_class; void JSB_cpArbiter_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpSpace_object; extern JSClass *JSB_cpSpace_class; void JSB_cpSpace_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpBody_object; extern JSClass *JSB_cpBody_class; void JSB_cpBody_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpShape_object; extern JSClass *JSB_cpShape_class; void JSB_cpShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpCircleShape_object; extern JSClass *JSB_cpCircleShape_class; void JSB_cpCircleShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpSegmentShape_object; extern JSClass *JSB_cpSegmentShape_class; void JSB_cpSegmentShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); extern JSObject *JSB_cpPolyShape_object; extern JSClass *JSB_cpPolyShape_class; void JSB_cpPolyShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); #endif // JSB_INCLUDE_CHIPMUNK ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes_registration.h ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 * Script version: v0.3 */ #include "js_bindings_config.h" #ifdef JSB_INCLUDE_CHIPMUNK JSB_cpConstraint_createClass(cx, chipmunk, "Constraint"); JSB_cpGrooveJoint_createClass(cx, chipmunk, "GrooveJoint"); JSB_cpSimpleMotor_createClass(cx, chipmunk, "SimpleMotor"); JSB_cpPivotJoint_createClass(cx, chipmunk, "PivotJoint"); JSB_cpPinJoint_createClass(cx, chipmunk, "PinJoint"); JSB_cpSlideJoint_createClass(cx, chipmunk, "SlideJoint"); JSB_cpGearJoint_createClass(cx, chipmunk, "GearJoint"); JSB_cpDampedRotarySpring_createClass(cx, chipmunk, "DampedRotarySpring"); JSB_cpDampedSpring_createClass(cx, chipmunk, "DampedSpring"); JSB_cpRatchetJoint_createClass(cx, chipmunk, "RatchetJoint"); JSB_cpRotaryLimitJoint_createClass(cx, chipmunk, "RotaryLimitJoint"); JSB_cpArbiter_createClass(cx, chipmunk, "Arbiter"); JSB_cpSpace_createClass(cx, chipmunk, "Space"); JSB_cpBody_createClass(cx, chipmunk, "Body"); JSB_cpShape_createClass(cx, chipmunk, "Shape"); JSB_cpCircleShape_createClass(cx, chipmunk, "CircleShape"); JSB_cpSegmentShape_createClass(cx, chipmunk, "SegmentShape"); JSB_cpPolyShape_createClass(cx, chipmunk, "PolyShape"); #endif // JSB_INCLUDE_CHIPMUNK ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 * Script version: v0.3 */ #include "js_bindings_config.h" #ifdef JSB_INCLUDE_CHIPMUNK #include "js_bindings_chipmunk_manual.h" #include "jsfriendapi.h" #include "js_bindings_config.h" #include "js_manual_conversions.h" #include "js_bindings_chipmunk_functions.h" // Arguments: cpArbiter* // Ret value: int JSBool JSB_cpArbiterGetCount(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); int ret_val; ret_val = cpArbiterGetCount((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpArbiter*, int // Ret value: cpFloat JSBool JSB_cpArbiterGetDepth(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; int32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpArbiterGetDepth((cpArbiter*)arg0 , (int)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpArbiter* // Ret value: cpFloat JSBool JSB_cpArbiterGetElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpArbiterGetElasticity((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpArbiter* // Ret value: cpFloat JSBool JSB_cpArbiterGetFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpArbiterGetFriction((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpArbiter*, int // Ret value: cpVect JSBool JSB_cpArbiterGetNormal(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; int32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpArbiterGetNormal((cpArbiter*)arg0 , (int)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpArbiter*, int // Ret value: cpVect JSBool JSB_cpArbiterGetPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; int32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpArbiterGetPoint((cpArbiter*)arg0 , (int)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpArbiter* // Ret value: cpVect JSBool JSB_cpArbiterGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpArbiterGetSurfaceVelocity((cpArbiter*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpArbiter* // Ret value: void JSBool JSB_cpArbiterIgnore(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpArbiterIgnore((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpArbiter* // Ret value: cpBool JSBool JSB_cpArbiterIsFirstContact(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpArbiterIsFirstContact((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpArbiter*, cpFloat // Ret value: void JSBool JSB_cpArbiterSetElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpArbiterSetElasticity((cpArbiter*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpArbiter*, cpFloat // Ret value: void JSBool JSB_cpArbiterSetFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpArbiterSetFriction((cpArbiter*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpArbiter*, cpVect // Ret value: void JSBool JSB_cpArbiterSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpArbiterSetSurfaceVelocity((cpArbiter*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpArbiter* // Ret value: cpVect JSBool JSB_cpArbiterTotalImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpArbiterTotalImpulse((cpArbiter*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpArbiter* // Ret value: cpVect JSBool JSB_cpArbiterTotalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpArbiterTotalImpulseWithFriction((cpArbiter*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpArbiter* // Ret value: cpFloat JSBool JSB_cpArbiterTotalKE(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpArbiter* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpArbiterTotalKE((cpArbiter*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat // Ret value: cpFloat JSBool JSB_cpAreaForCircle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpAreaForCircle((cpFloat)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect, cpFloat // Ret value: cpFloat JSBool JSB_cpAreaForSegment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; double arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpAreaForSegment((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBB // Ret value: cpFloat JSBool JSB_cpBBArea(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBBArea((cpBB)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBB, cpVect // Ret value: cpVect JSBool JSB_cpBBClampVect(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpVect arg1; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBBClampVect((cpBB)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBB, cpBB // Ret value: cpBool JSBool JSB_cpBBContainsBB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpBB arg1; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpBBContainsBB((cpBB)arg0 , (cpBB)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpBB, cpVect // Ret value: cpBool JSBool JSB_cpBBContainsVect(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpVect arg1; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpBBContainsVect((cpBB)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpBB, cpVect // Ret value: cpBB JSBool JSB_cpBBExpand(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpVect arg1; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBB ret_val; ret_val = cpBBExpand((cpBB)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBB, cpBB // Ret value: cpBool JSBool JSB_cpBBIntersects(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpBB arg1; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpBBIntersects((cpBB)arg0 , (cpBB)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpBB, cpVect, cpVect // Ret value: cpBool JSBool JSB_cpBBIntersectsSegment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpVect arg1; cpVect arg2; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpBBIntersectsSegment((cpBB)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpBB, cpBB // Ret value: cpBB JSBool JSB_cpBBMerge(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpBB arg1; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBB ret_val; ret_val = cpBBMerge((cpBB)arg0 , (cpBB)arg1 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBB, cpBB // Ret value: cpFloat JSBool JSB_cpBBMergedArea(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpBB arg1; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBBMergedArea((cpBB)arg0 , (cpBB)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat, cpFloat, cpFloat // Ret value: cpBB JSBool JSB_cpBBNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; double arg2; double arg3; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBB ret_val; ret_val = cpBBNew((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpFloat // Ret value: cpBB JSBool JSB_cpBBNewForCircle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; double arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBB ret_val; ret_val = cpBBNewForCircle((cpVect)arg0 , (cpFloat)arg1 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBB, cpVect, cpVect // Ret value: cpFloat JSBool JSB_cpBBSegmentQuery(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpVect arg1; cpVect arg2; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBBSegmentQuery((cpBB)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBB, cpVect // Ret value: cpVect JSBool JSB_cpBBWrapVect(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBB arg0; cpVect arg1; ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBBWrapVect((cpBB)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: void JSBool JSB_cpBodyActivate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyActivate((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpShape* // Ret value: void JSBool JSB_cpBodyActivateStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpShape* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyActivateStatic((cpBody*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpVect, cpVect // Ret value: void JSBool JSB_cpBodyApplyForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; cpVect arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyApplyForce((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpVect, cpVect // Ret value: void JSBool JSB_cpBodyApplyImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; cpVect arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyApplyImpulse((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody* // Ret value: void JSBool JSB_cpBodyDestroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyDestroy((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody* // Ret value: void JSBool JSB_cpBodyFree(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyFree((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpFloat JSBool JSB_cpBodyGetAngVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBodyGetAngVel((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpFloat JSBool JSB_cpBodyGetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBodyGetAngVelLimit((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpFloat JSBool JSB_cpBodyGetAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBodyGetAngle((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpVect JSBool JSB_cpBodyGetForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyGetForce((cpBody*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpFloat JSBool JSB_cpBodyGetMass(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBodyGetMass((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpFloat JSBool JSB_cpBodyGetMoment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBodyGetMoment((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpVect JSBool JSB_cpBodyGetPos(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyGetPos((cpBody*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpVect JSBool JSB_cpBodyGetRot(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyGetRot((cpBody*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpSpace* JSBool JSB_cpBodyGetSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpace* ret_val; ret_val = cpBodyGetSpace((cpBody*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpFloat JSBool JSB_cpBodyGetTorque(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBodyGetTorque((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpVect JSBool JSB_cpBodyGetVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyGetVel((cpBody*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody*, cpVect // Ret value: cpVect JSBool JSB_cpBodyGetVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyGetVelAtLocalPoint((cpBody*)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody*, cpVect // Ret value: cpVect JSBool JSB_cpBodyGetVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyGetVelAtWorldPoint((cpBody*)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpFloat JSBool JSB_cpBodyGetVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBodyGetVelLimit((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpFloat, cpFloat // Ret value: cpBody* JSBool JSB_cpBodyInit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; double arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpBodyInit((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpBody* JSBool JSB_cpBodyInitStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpBodyInitStatic((cpBody*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpBool JSBool JSB_cpBodyIsRogue(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpBodyIsRogue((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpBool JSBool JSB_cpBodyIsSleeping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpBodyIsSleeping((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpBool JSBool JSB_cpBodyIsStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpBodyIsStatic((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: cpFloat JSBool JSB_cpBodyKineticEnergy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpBodyKineticEnergy((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpVect // Ret value: cpVect JSBool JSB_cpBodyLocal2World(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyLocal2World((cpBody*)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpFloat, cpFloat // Ret value: cpBody* JSBool JSB_cpBodyNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpBodyNew((cpFloat)arg0 , (cpFloat)arg1 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: cpBody* JSBool JSB_cpBodyNewStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); cpBody* ret_val; ret_val = cpBodyNewStatic( ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody* // Ret value: void JSBool JSB_cpBodyResetForces(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyResetForces((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpFloat // Ret value: void JSBool JSB_cpBodySetAngVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetAngVel((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpFloat // Ret value: void JSBool JSB_cpBodySetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetAngVelLimit((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpFloat // Ret value: void JSBool JSB_cpBodySetAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetAngle((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpVect // Ret value: void JSBool JSB_cpBodySetForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetForce((cpBody*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpFloat // Ret value: void JSBool JSB_cpBodySetMass(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetMass((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpFloat // Ret value: void JSBool JSB_cpBodySetMoment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetMoment((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpVect // Ret value: void JSBool JSB_cpBodySetPos(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetPos((cpBody*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpFloat // Ret value: void JSBool JSB_cpBodySetTorque(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetTorque((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpVect // Ret value: void JSBool JSB_cpBodySetVel(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetVel((cpBody*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpFloat // Ret value: void JSBool JSB_cpBodySetVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySetVelLimit((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody* // Ret value: void JSBool JSB_cpBodySleep(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySleep((cpBody*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpBody* // Ret value: void JSBool JSB_cpBodySleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodySleepWithGroup((cpBody*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpFloat // Ret value: void JSBool JSB_cpBodyUpdatePosition(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyUpdatePosition((cpBody*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpVect, cpFloat, cpFloat // Ret value: void JSBool JSB_cpBodyUpdateVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; double arg2; double arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBodyUpdateVelocity((cpBody*)arg0 , (cpVect)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpBody*, cpVect // Ret value: cpVect JSBool JSB_cpBodyWorld2Local(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpBodyWorld2Local((cpBody*)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody*, cpFloat, cpFloat // Ret value: cpShape* JSBool JSB_cpBoxShapeNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; double arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShape* ret_val; ret_val = cpBoxShapeNew((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody*, cpBB // Ret value: cpShape* JSBool JSB_cpBoxShapeNew2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBB arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShape* ret_val; ret_val = cpBoxShapeNew2((cpBody*)arg0 , (cpBB)arg1 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpVect JSBool JSB_cpCircleShapeGetOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpCircleShapeGetOffset((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpFloat JSBool JSB_cpCircleShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpCircleShapeGetRadius((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpFloat, cpVect // Ret value: cpShape* JSBool JSB_cpCircleShapeNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; double arg1; cpVect arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShape* ret_val; ret_val = cpCircleShapeNew((cpBody*)arg0 , (cpFloat)arg1 , (cpVect)arg2 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: void JSBool JSB_cpConstraintActivateBodies(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintActivateBodies((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: void JSBool JSB_cpConstraintDestroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintDestroy((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: void JSBool JSB_cpConstraintFree(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintFree((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpBody* JSBool JSB_cpConstraintGetA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpConstraintGetA((cpConstraint*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpBody* JSBool JSB_cpConstraintGetB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpConstraintGetB((cpConstraint*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpConstraintGetErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpConstraintGetErrorBias((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpConstraintGetImpulse(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpConstraintGetImpulse((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpConstraintGetMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpConstraintGetMaxBias((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpConstraintGetMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpConstraintGetMaxForce((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpSpace* JSBool JSB_cpConstraintGetSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpace* ret_val; ret_val = cpConstraintGetSpace((cpConstraint*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpConstraintSetErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintSetErrorBias((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpConstraintSetMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintSetMaxBias((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpConstraintSetMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraintSetMaxForce((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpDampedRotarySpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpDampedRotarySpringGetDamping((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpDampedRotarySpringGetRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpDampedRotarySpringGetRestAngle((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpDampedRotarySpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpDampedRotarySpringGetStiffness((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpFloat, cpFloat, cpFloat // Ret value: cpConstraint* JSBool JSB_cpDampedRotarySpringNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; double arg3; double arg4; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpDampedRotarySpringNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 , (cpFloat)arg4 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpDampedRotarySpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedRotarySpringSetDamping((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpDampedRotarySpringSetRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedRotarySpringSetRestAngle((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpDampedRotarySpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedRotarySpringSetStiffness((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpDampedSpringGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpDampedSpringGetAnchr1((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpDampedSpringGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpDampedSpringGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpDampedSpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpDampedSpringGetDamping((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpDampedSpringGetRestLength(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpDampedSpringGetRestLength((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpDampedSpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpDampedSpringGetStiffness((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpVect, cpVect, cpFloat, cpFloat, cpFloat // Ret value: cpConstraint* JSBool JSB_cpDampedSpringNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 7, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; double arg4; double arg5; double arg6; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg4 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg5 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg6 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpDampedSpringNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpFloat)arg4 , (cpFloat)arg5 , (cpFloat)arg6 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpDampedSpringSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpDampedSpringSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpDampedSpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetDamping((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpDampedSpringSetRestLength(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetRestLength((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpDampedSpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpDampedSpringSetStiffness((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpGearJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpGearJointGetPhase((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpGearJointGetRatio(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpGearJointGetRatio((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpFloat, cpFloat // Ret value: cpConstraint* JSBool JSB_cpGearJointNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; double arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpGearJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpGearJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGearJointSetPhase((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpGearJointSetRatio(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGearJointSetRatio((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpGrooveJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpGrooveJointGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpGrooveJointGetGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpGrooveJointGetGrooveA((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpGrooveJointGetGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpGrooveJointGetGrooveB((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpVect, cpVect, cpVect // Ret value: cpConstraint* JSBool JSB_cpGrooveJointNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; cpVect arg4; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpGrooveJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpVect)arg4 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpGrooveJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGrooveJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpGrooveJointSetGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGrooveJointSetGrooveA((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpGrooveJointSetGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGrooveJointSetGrooveB((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpInitChipmunk(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); cpInitChipmunk( ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat, cpFloat, cpFloat // Ret value: cpFloat JSBool JSB_cpMomentForBox(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; double arg2; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpMomentForBox((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpBB // Ret value: cpFloat JSBool JSB_cpMomentForBox2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; cpBB arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= jsval_to_cpBB( cx, *argvp++, (cpBB*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpMomentForBox2((cpFloat)arg0 , (cpBB)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat, cpFloat, cpVect // Ret value: cpFloat JSBool JSB_cpMomentForCircle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; double arg2; cpVect arg3; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpMomentForCircle((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 , (cpVect)arg3 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpVect, cpVect // Ret value: cpFloat JSBool JSB_cpMomentForSegment(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; cpVect arg1; cpVect arg2; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpMomentForSegment((cpFloat)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpPinJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpPinJointGetAnchr1((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpPinJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpPinJointGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpPinJointGetDist(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpPinJointGetDist((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpVect, cpVect // Ret value: cpConstraint* JSBool JSB_cpPinJointNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpPinJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpPinJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPinJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpPinJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPinJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpPinJointSetDist(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPinJointSetDist((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpPivotJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpPivotJointGetAnchr1((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpPivotJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpPivotJointGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpVect // Ret value: cpConstraint* JSBool JSB_cpPivotJointNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3 || argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); if(argc == 4) { ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); } JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; if(argc == 4) { ret_val = cpPivotJointNew2((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 ); } else { ret_val = cpPivotJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 ); } jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpVect, cpVect // Ret value: cpConstraint* JSBool JSB_cpPivotJointNew2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpPivotJointNew2((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpPivotJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPivotJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpPivotJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpPivotJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape* // Ret value: int JSBool JSB_cpPolyShapeGetNumVerts(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); int ret_val; ret_val = cpPolyShapeGetNumVerts((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpShape*, int // Ret value: cpVect JSBool JSB_cpPolyShapeGetVert(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; int32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpPolyShapeGetVert((cpShape*)arg0 , (int)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpRatchetJointGetAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpRatchetJointGetAngle((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpRatchetJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpRatchetJointGetPhase((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpRatchetJointGetRatchet(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpRatchetJointGetRatchet((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpFloat, cpFloat // Ret value: cpConstraint* JSBool JSB_cpRatchetJointNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; double arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpRatchetJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpRatchetJointSetAngle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRatchetJointSetAngle((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpRatchetJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRatchetJointSetPhase((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpRatchetJointSetRatchet(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRatchetJointSetRatchet((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_cpResetShapeIdCounter(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); cpResetShapeIdCounter( ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpRotaryLimitJointGetMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpRotaryLimitJointGetMax((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpRotaryLimitJointGetMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpRotaryLimitJointGetMin((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpFloat, cpFloat // Ret value: cpConstraint* JSBool JSB_cpRotaryLimitJointNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; double arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpRotaryLimitJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpRotaryLimitJointSetMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRotaryLimitJointSetMax((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpRotaryLimitJointSetMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpRotaryLimitJointSetMin((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpVect JSBool JSB_cpSegmentShapeGetA(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpSegmentShapeGetA((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpVect JSBool JSB_cpSegmentShapeGetB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpSegmentShapeGetB((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpVect JSBool JSB_cpSegmentShapeGetNormal(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpSegmentShapeGetNormal((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpFloat JSBool JSB_cpSegmentShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSegmentShapeGetRadius((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpVect, cpVect, cpFloat // Ret value: cpShape* JSBool JSB_cpSegmentShapeNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpVect arg1; cpVect arg2; double arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShape* ret_val; ret_val = cpSegmentShapeNew((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 , (cpFloat)arg3 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape*, cpVect, cpVect // Ret value: void JSBool JSB_cpSegmentShapeSetNeighbors(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; cpVect arg1; cpVect arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSegmentShapeSetNeighbors((cpShape*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpBB JSBool JSB_cpShapeCacheBB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBB ret_val; ret_val = cpShapeCacheBB((cpShape*)arg0 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: void JSBool JSB_cpShapeDestroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeDestroy((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape* // Ret value: void JSBool JSB_cpShapeFree(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeFree((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpBB JSBool JSB_cpShapeGetBB(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBB ret_val; ret_val = cpShapeGetBB((cpShape*)arg0 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpBody* JSBool JSB_cpShapeGetBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpShapeGetBody((cpShape*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpCollisionType JSBool JSB_cpShapeGetCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpCollisionType ret_val; ret_val = cpShapeGetCollisionType((cpShape*)arg0 ); jsval ret_jsval = uint32_to_jsval( cx, (cpCollisionType)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpFloat JSBool JSB_cpShapeGetElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpShapeGetElasticity((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpFloat JSBool JSB_cpShapeGetFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpShapeGetFriction((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpGroup JSBool JSB_cpShapeGetGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpGroup ret_val; ret_val = cpShapeGetGroup((cpShape*)arg0 ); jsval ret_jsval = uint32_to_jsval( cx, (cpGroup)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpLayers JSBool JSB_cpShapeGetLayers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpLayers ret_val; ret_val = cpShapeGetLayers((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpBool JSBool JSB_cpShapeGetSensor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpShapeGetSensor((cpShape*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpSpace* JSBool JSB_cpShapeGetSpace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpace* ret_val; ret_val = cpShapeGetSpace((cpShape*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpVect JSBool JSB_cpShapeGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpShapeGetSurfaceVelocity((cpShape*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpShape*, cpVect // Ret value: cpBool JSBool JSB_cpShapePointQuery(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpShapePointQuery((cpShape*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpShape*, cpBody* // Ret value: void JSBool JSB_cpShapeSetBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; cpBody* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetBody((cpShape*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape*, cpCollisionType // Ret value: void JSBool JSB_cpShapeSetCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; cpCollisionType arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_uint( cx, *argvp++, (unsigned int*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetCollisionType((cpShape*)arg0 , (cpCollisionType)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape*, cpFloat // Ret value: void JSBool JSB_cpShapeSetElasticity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetElasticity((cpShape*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape*, cpFloat // Ret value: void JSBool JSB_cpShapeSetFriction(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetFriction((cpShape*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape*, cpGroup // Ret value: void JSBool JSB_cpShapeSetGroup(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; cpGroup arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_uint( cx, *argvp++, (unsigned int*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetGroup((cpShape*)arg0 , (cpGroup)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape*, cpLayers // Ret value: void JSBool JSB_cpShapeSetLayers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; uint32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetLayers((cpShape*)arg0 , (cpLayers)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape*, cpBool // Ret value: void JSBool JSB_cpShapeSetSensor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; int32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetSensor((cpShape*)arg0 , (cpBool)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape*, cpVect // Ret value: void JSBool JSB_cpShapeSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShapeSetSurfaceVelocity((cpShape*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape*, cpVect, cpVect // Ret value: cpBB JSBool JSB_cpShapeUpdate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg0; cpVect arg1; cpVect arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBB ret_val; ret_val = cpShapeUpdate((cpShape*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpSimpleMotorGetRate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSimpleMotorGetRate((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpFloat // Ret value: cpConstraint* JSBool JSB_cpSimpleMotorNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; double arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpSimpleMotorNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpSimpleMotorSetRate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSimpleMotorSetRate((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpSlideJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpSlideJointGetAnchr1((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpVect JSBool JSB_cpSlideJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpSlideJointGetAnchr2((cpConstraint*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpSlideJointGetMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSlideJointGetMax((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpFloat JSBool JSB_cpSlideJointGetMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSlideJointGetMin((cpConstraint*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody*, cpBody*, cpVect, cpVect, cpFloat, cpFloat // Ret value: cpConstraint* JSBool JSB_cpSlideJointNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 6, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; double arg4; double arg5; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg2 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg3 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg4 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg5 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpSlideJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpFloat)arg4 , (cpFloat)arg5 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpSlideJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSlideJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpVect // Ret value: void JSBool JSB_cpSlideJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSlideJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpSlideJointSetMax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSlideJointSetMax((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint*, cpFloat // Ret value: void JSBool JSB_cpSlideJointSetMin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSlideJointSetMin((cpConstraint*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpShape* // Ret value: void JSBool JSB_cpSpaceActivateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpShape* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceActivateShapesTouchingShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpBody* // Ret value: cpBody* JSBool JSB_cpSpaceAddBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpBody* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpSpaceAddBody((cpSpace*)arg0 , (cpBody*)arg1 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpSpace*, cpConstraint* // Ret value: cpConstraint* JSBool JSB_cpSpaceAddConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpConstraint* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpConstraint* ret_val; ret_val = cpSpaceAddConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpSpace*, cpShape* // Ret value: cpShape* JSBool JSB_cpSpaceAddShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpShape* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShape* ret_val; ret_val = cpSpaceAddShape((cpSpace*)arg0 , (cpShape*)arg1 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpSpace*, cpShape* // Ret value: cpShape* JSBool JSB_cpSpaceAddStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpShape* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShape* ret_val; ret_val = cpSpaceAddStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpSpace*, cpBody* // Ret value: cpBool JSBool JSB_cpSpaceContainsBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpBody* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpSpaceContainsBody((cpSpace*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpSpace*, cpConstraint* // Ret value: cpBool JSBool JSB_cpSpaceContainsConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpConstraint* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpSpaceContainsConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpSpace*, cpShape* // Ret value: cpBool JSBool JSB_cpSpaceContainsShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpShape* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpSpaceContainsShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: void JSBool JSB_cpSpaceDestroy(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceDestroy((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace* // Ret value: void JSBool JSB_cpSpaceFree(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceFree((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpFloat JSBool JSB_cpSpaceGetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSpaceGetCollisionBias((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpTimestamp JSBool JSB_cpSpaceGetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpTimestamp ret_val; ret_val = cpSpaceGetCollisionPersistence((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpFloat JSBool JSB_cpSpaceGetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSpaceGetCollisionSlop((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpFloat JSBool JSB_cpSpaceGetCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSpaceGetCurrentTimeStep((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpFloat JSBool JSB_cpSpaceGetDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSpaceGetDamping((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpBool JSBool JSB_cpSpaceGetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpSpaceGetEnableContactGraph((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpVect JSBool JSB_cpSpaceGetGravity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpSpaceGetGravity((cpSpace*)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpFloat JSBool JSB_cpSpaceGetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSpaceGetIdleSpeedThreshold((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: int JSBool JSB_cpSpaceGetIterations(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); int ret_val; ret_val = cpSpaceGetIterations((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpFloat JSBool JSB_cpSpaceGetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpSpaceGetSleepTimeThreshold((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpBody* JSBool JSB_cpSpaceGetStaticBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBody* ret_val; ret_val = cpSpaceGetStaticBody((cpSpace*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpSpace* JSBool JSB_cpSpaceInit(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpace* ret_val; ret_val = cpSpaceInit((cpSpace*)arg0 ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpSpace* // Ret value: cpBool JSBool JSB_cpSpaceIsLocked(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpSpaceIsLocked((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: cpSpace* JSBool JSB_cpSpaceNew(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); cpSpace* ret_val; ret_val = cpSpaceNew( ); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpSpace*, cpVect, cpLayers, cpGroup // Ret value: cpShape* JSBool JSB_cpSpacePointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpVect arg1; uint32_t arg2; cpGroup arg3; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_uint( cx, *argvp++, (unsigned int*) &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpShape* ret_val; ret_val = cpSpacePointQueryFirst((cpSpace*)arg0 , (cpVect)arg1 , (cpLayers)arg2 , (cpGroup)arg3 ); if(ret_val) { jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); } else { JS_SET_RVAL(cx, vp, JSVAL_NULL); } return JS_TRUE; } // Arguments: cpSpace*, cpShape* // Ret value: void JSBool JSB_cpSpaceReindexShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpShape* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceReindexShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpBody* // Ret value: void JSBool JSB_cpSpaceReindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpBody* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceReindexShapesForBody((cpSpace*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace* // Ret value: void JSBool JSB_cpSpaceReindexStatic(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceReindexStatic((cpSpace*)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpBody* // Ret value: void JSBool JSB_cpSpaceRemoveBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpBody* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceRemoveBody((cpSpace*)arg0 , (cpBody*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpConstraint* // Ret value: void JSBool JSB_cpSpaceRemoveConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpConstraint* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceRemoveConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpShape* // Ret value: void JSBool JSB_cpSpaceRemoveShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpShape* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceRemoveShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpShape* // Ret value: void JSBool JSB_cpSpaceRemoveStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpShape* arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceRemoveStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpFloat // Ret value: void JSBool JSB_cpSpaceSetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetCollisionBias((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpTimestamp // Ret value: void JSBool JSB_cpSpaceSetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; uint32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetCollisionPersistence((cpSpace*)arg0 , (cpTimestamp)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpFloat // Ret value: void JSBool JSB_cpSpaceSetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetCollisionSlop((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpFloat // Ret value: void JSBool JSB_cpSpaceSetDamping(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetDamping((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpBool // Ret value: void JSBool JSB_cpSpaceSetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; int32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetEnableContactGraph((cpSpace*)arg0 , (cpBool)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpVect // Ret value: void JSBool JSB_cpSpaceSetGravity(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; cpVect arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetGravity((cpSpace*)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpFloat // Ret value: void JSBool JSB_cpSpaceSetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetIdleSpeedThreshold((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, int // Ret value: void JSBool JSB_cpSpaceSetIterations(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; int32_t arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetIterations((cpSpace*)arg0 , (int)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpFloat // Ret value: void JSBool JSB_cpSpaceSetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceSetSleepTimeThreshold((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpFloat // Ret value: void JSBool JSB_cpSpaceStep(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; double arg1; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceStep((cpSpace*)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpSpace*, cpFloat, int // Ret value: void JSBool JSB_cpSpaceUseSpatialHash(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; double arg1; int32_t arg2; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpSpaceUseSpatialHash((cpSpace*)arg0 , (cpFloat)arg1 , (int)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpFloat // Ret value: cpFloat JSBool JSB_cpfabs(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpfabs((cpFloat)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat, cpFloat // Ret value: cpFloat JSBool JSB_cpfclamp(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; double arg2; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpfclamp((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat // Ret value: cpFloat JSBool JSB_cpfclamp01(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpfclamp01((cpFloat)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat, cpFloat // Ret value: cpFloat JSBool JSB_cpflerp(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; double arg2; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpflerp((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat, cpFloat // Ret value: cpFloat JSBool JSB_cpflerpconst(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; double arg2; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpflerpconst((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat // Ret value: cpFloat JSBool JSB_cpfmax(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpfmax((cpFloat)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpFloat, cpFloat // Ret value: cpFloat JSBool JSB_cpfmin(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; double arg1; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpfmin((cpFloat)arg0 , (cpFloat)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpVect JSBool JSB_cpvadd(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvadd((cpVect)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpFloat // Ret value: cpVect JSBool JSB_cpvclamp(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; double arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvclamp((cpVect)arg0 , (cpFloat)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpFloat JSBool JSB_cpvcross(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpvcross((cpVect)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpFloat JSBool JSB_cpvdist(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpvdist((cpVect)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpFloat JSBool JSB_cpvdistsq(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpvdistsq((cpVect)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpFloat JSBool JSB_cpvdot(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpvdot((cpVect)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpBool JSBool JSB_cpveql(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpveql((cpVect)arg0 , (cpVect)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpFloat // Ret value: cpVect JSBool JSB_cpvforangle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double arg0; ok &= JS_ValueToNumber( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvforangle((cpFloat)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpFloat JSBool JSB_cpvlength(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpvlength((cpVect)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect // Ret value: cpFloat JSBool JSB_cpvlengthsq(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpvlengthsq((cpVect)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect, cpFloat // Ret value: cpVect JSBool JSB_cpvlerp(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; double arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvlerp((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpVect, cpFloat // Ret value: cpVect JSBool JSB_cpvlerpconst(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; double arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvlerpconst((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpFloat // Ret value: cpVect JSBool JSB_cpvmult(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; double arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvmult((cpVect)arg0 , (cpFloat)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpVect, cpFloat // Ret value: cpBool JSBool JSB_cpvnear(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; double arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpBool ret_val; ret_val = cpvnear((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpvneg(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvneg((cpVect)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpvnormalize(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvnormalize((cpVect)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpvnormalize_safe(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvnormalize_safe((cpVect)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpvperp(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvperp((cpVect)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpVect JSBool JSB_cpvproject(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvproject((cpVect)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpVect JSBool JSB_cpvrotate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvrotate((cpVect)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpVect JSBool JSB_cpvrperp(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvrperp((cpVect)arg0 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpVect, cpFloat // Ret value: cpVect JSBool JSB_cpvslerp(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; double arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvslerp((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpVect, cpFloat // Ret value: cpVect JSBool JSB_cpvslerpconst(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; double arg2; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); ok &= JS_ValueToNumber( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvslerpconst((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpVect JSBool JSB_cpvsub(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvsub((cpVect)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: cpVect // Ret value: cpFloat JSBool JSB_cpvtoangle(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpFloat ret_val; ret_val = cpvtoangle((cpVect)arg0 ); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpVect, cpVect // Ret value: cpVect JSBool JSB_cpvunrotate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect arg0; cpVect arg1; ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg0 ); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cpVect ret_val; ret_val = cpvunrotate((cpVect)arg0 , (cpVect)arg1 ); jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } #endif // JSB_INCLUDE_CHIPMUNK ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.h ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 * Script version: v0.3 */ #include "js_bindings_config.h" #ifdef JSB_INCLUDE_CHIPMUNK #include "js_bindings_chipmunk_manual.h" #ifdef __cplusplus extern "C" { #endif JSBool JSB_cpArbiterGetCount(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterGetDepth(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterGetElasticity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterGetFriction(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterGetNormal(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterGetPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterIgnore(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterIsFirstContact(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterSetElasticity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterSetFriction(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterTotalImpulse(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterTotalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterTotalKE(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpAreaForCircle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpAreaForSegment(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBArea(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBClampVect(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBContainsBB(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBContainsVect(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBExpand(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBIntersects(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBIntersectsSegment(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBMerge(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBMergedArea(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBNewForCircle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBSegmentQuery(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBBWrapVect(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyActivate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyActivateStatic(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyApplyForce(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyApplyImpulse(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyDestroy(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyFree(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetAngVel(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetAngle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetForce(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetMass(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetMoment(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetPos(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetRot(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetTorque(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetVel(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetVelLimit(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyInit(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyInitStatic(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyIsRogue(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyIsSleeping(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyIsStatic(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyKineticEnergy(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyLocal2World(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyNewStatic(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyResetForces(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetAngVel(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetAngle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetForce(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetMass(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetMoment(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetPos(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetTorque(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetVel(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetVelLimit(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySleep(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyUpdatePosition(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyUpdateVelocity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyWorld2Local(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBoxShapeNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBoxShapeNew2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpCircleShapeGetOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpCircleShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpCircleShapeNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintActivateBodies(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintDestroy(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintFree(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintGetA(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintGetB(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintGetErrorBias(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintGetImpulse(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintGetMaxBias(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintGetMaxForce(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintGetSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintSetErrorBias(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintSetMaxBias(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpConstraintSetMaxForce(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedRotarySpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedRotarySpringGetRestAngle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedRotarySpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedRotarySpringNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedRotarySpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedRotarySpringSetRestAngle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedRotarySpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringGetRestLength(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringSetRestLength(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpDampedSpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGearJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGearJointGetRatio(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGearJointNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGearJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGearJointSetRatio(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGrooveJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGrooveJointGetGrooveA(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGrooveJointGetGrooveB(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGrooveJointNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGrooveJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGrooveJointSetGrooveA(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpGrooveJointSetGrooveB(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpInitChipmunk(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpMomentForBox(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpMomentForBox2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpMomentForCircle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpMomentForSegment(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPinJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPinJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPinJointGetDist(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPinJointNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPinJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPinJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPinJointSetDist(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPivotJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPivotJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPivotJointNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPivotJointNew2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPivotJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPivotJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPolyShapeGetNumVerts(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpPolyShapeGetVert(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRatchetJointGetAngle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRatchetJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRatchetJointGetRatchet(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRatchetJointNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRatchetJointSetAngle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRatchetJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRatchetJointSetRatchet(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpResetShapeIdCounter(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRotaryLimitJointGetMax(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRotaryLimitJointGetMin(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRotaryLimitJointNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRotaryLimitJointSetMax(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRotaryLimitJointSetMin(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSegmentShapeGetA(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSegmentShapeGetB(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSegmentShapeGetNormal(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSegmentShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSegmentShapeNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSegmentShapeSetNeighbors(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeCacheBB(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeDestroy(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeFree(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetBB(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetCollisionType(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetElasticity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetFriction(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetGroup(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetLayers(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetSensor(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetSpace(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapePointQuery(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeSetBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeSetCollisionType(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeSetElasticity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeSetFriction(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeSetGroup(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeSetLayers(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeSetSensor(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpShapeUpdate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSimpleMotorGetRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSimpleMotorNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSimpleMotorSetRate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointGetMax(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointGetMin(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointSetMax(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSlideJointSetMin(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceActivateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceAddBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceAddConstraint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceAddShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceAddStaticShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceContainsBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceContainsConstraint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceContainsShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceDestroy(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceFree(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetDamping(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetGravity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetIterations(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceGetStaticBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceInit(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceIsLocked(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceNew(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpacePointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceReindexShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceReindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceReindexStatic(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceRemoveBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceRemoveConstraint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceRemoveShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceRemoveStaticShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetDamping(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetGravity(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetIterations(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceSetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceStep(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceUseSpatialHash(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpfabs(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpfclamp(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpfclamp01(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpflerp(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpflerpconst(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpfmax(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpfmin(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvadd(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvclamp(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvcross(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvdist(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvdistsq(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvdot(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpveql(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvforangle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvlength(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvlengthsq(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvlerp(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvlerpconst(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvmult(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvnear(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvneg(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvnormalize(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvnormalize_safe(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvperp(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvproject(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvrotate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvrperp(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvslerp(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvslerpconst(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvsub(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvtoangle(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpvunrotate(JSContext *cx, uint32_t argc, jsval *vp); #ifdef __cplusplus } #endif #endif // JSB_INCLUDE_CHIPMUNK ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions_registration.h ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-10-18 * Script version: v0.3 */ #include "js_bindings_config.h" #ifdef JSB_INCLUDE_CHIPMUNK #include "js_bindings_chipmunk_manual.h" JS_DefineFunction(cx, chipmunk, "arbiterGetCount", JSB_cpArbiterGetCount, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetDepth", JSB_cpArbiterGetDepth, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetElasticity", JSB_cpArbiterGetElasticity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetFriction", JSB_cpArbiterGetFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetNormal", JSB_cpArbiterGetNormal, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetPoint", JSB_cpArbiterGetPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetSurfaceVelocity", JSB_cpArbiterGetSurfaceVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterIgnore", JSB_cpArbiterIgnore, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterIsFirstContact", JSB_cpArbiterIsFirstContact, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterSetElasticity", JSB_cpArbiterSetElasticity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterSetFriction", JSB_cpArbiterSetFriction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterSetSurfaceVelocity", JSB_cpArbiterSetSurfaceVelocity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterTotalImpulse", JSB_cpArbiterTotalImpulse, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterTotalImpulseWithFriction", JSB_cpArbiterTotalImpulseWithFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterTotalKE", JSB_cpArbiterTotalKE, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "areaForCircle", JSB_cpAreaForCircle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "areaForSegment", JSB_cpAreaForSegment, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBArea", JSB_cpBBArea, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBClampVect", JSB_cpBBClampVect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBContainsBB", JSB_cpBBContainsBB, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBContainsVect", JSB_cpBBContainsVect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBExpand", JSB_cpBBExpand, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBIntersects", JSB_cpBBIntersects, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBIntersectsSegment", JSB_cpBBIntersectsSegment, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBMerge", JSB_cpBBMerge, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBMergedArea", JSB_cpBBMergedArea, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBNew", JSB_cpBBNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBNewForCircle", JSB_cpBBNewForCircle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBSegmentQuery", JSB_cpBBSegmentQuery, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bBWrapVect", JSB_cpBBWrapVect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyActivate", JSB_cpBodyActivate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyActivateStatic", JSB_cpBodyActivateStatic, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyApplyForce", JSB_cpBodyApplyForce, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyApplyImpulse", JSB_cpBodyApplyImpulse, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyDestroy", JSB_cpBodyDestroy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyFree", JSB_cpBodyFree, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetAngVel", JSB_cpBodyGetAngVel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetAngVelLimit", JSB_cpBodyGetAngVelLimit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetAngle", JSB_cpBodyGetAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetForce", JSB_cpBodyGetForce, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetMass", JSB_cpBodyGetMass, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetMoment", JSB_cpBodyGetMoment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetPos", JSB_cpBodyGetPos, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetRot", JSB_cpBodyGetRot, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetSpace", JSB_cpBodyGetSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetTorque", JSB_cpBodyGetTorque, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetVel", JSB_cpBodyGetVel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetVelAtLocalPoint", JSB_cpBodyGetVelAtLocalPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetVelAtWorldPoint", JSB_cpBodyGetVelAtWorldPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetVelLimit", JSB_cpBodyGetVelLimit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyInit", JSB_cpBodyInit, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyInitStatic", JSB_cpBodyInitStatic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyIsRogue", JSB_cpBodyIsRogue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyIsSleeping", JSB_cpBodyIsSleeping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyIsStatic", JSB_cpBodyIsStatic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyKineticEnergy", JSB_cpBodyKineticEnergy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyLocal2World", JSB_cpBodyLocal2World, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyNew", JSB_cpBodyNew, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyNewStatic", JSB_cpBodyNewStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyResetForces", JSB_cpBodyResetForces, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetAngVel", JSB_cpBodySetAngVel, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetAngVelLimit", JSB_cpBodySetAngVelLimit, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetAngle", JSB_cpBodySetAngle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetForce", JSB_cpBodySetForce, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetMass", JSB_cpBodySetMass, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetMoment", JSB_cpBodySetMoment, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetPos", JSB_cpBodySetPos, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetTorque", JSB_cpBodySetTorque, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetVel", JSB_cpBodySetVel, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetVelLimit", JSB_cpBodySetVelLimit, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySleep", JSB_cpBodySleep, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySleepWithGroup", JSB_cpBodySleepWithGroup, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyUpdatePosition", JSB_cpBodyUpdatePosition, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyUpdateVelocity", JSB_cpBodyUpdateVelocity, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyWorld2Local", JSB_cpBodyWorld2Local, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "boxShapeNew", JSB_cpBoxShapeNew, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "boxShapeNew2", JSB_cpBoxShapeNew2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "circleShapeGetOffset", JSB_cpCircleShapeGetOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "circleShapeGetRadius", JSB_cpCircleShapeGetRadius, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "circleShapeNew", JSB_cpCircleShapeNew, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintActivateBodies", JSB_cpConstraintActivateBodies, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintDestroy", JSB_cpConstraintDestroy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintFree", JSB_cpConstraintFree, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintGetA", JSB_cpConstraintGetA, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintGetB", JSB_cpConstraintGetB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintGetErrorBias", JSB_cpConstraintGetErrorBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintGetImpulse", JSB_cpConstraintGetImpulse, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintGetMaxBias", JSB_cpConstraintGetMaxBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintGetMaxForce", JSB_cpConstraintGetMaxForce, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintGetSpace", JSB_cpConstraintGetSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintSetErrorBias", JSB_cpConstraintSetErrorBias, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintSetMaxBias", JSB_cpConstraintSetMaxBias, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "constraintSetMaxForce", JSB_cpConstraintSetMaxForce, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedRotarySpringGetDamping", JSB_cpDampedRotarySpringGetDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedRotarySpringGetRestAngle", JSB_cpDampedRotarySpringGetRestAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedRotarySpringGetStiffness", JSB_cpDampedRotarySpringGetStiffness, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedRotarySpringNew", JSB_cpDampedRotarySpringNew, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedRotarySpringSetDamping", JSB_cpDampedRotarySpringSetDamping, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedRotarySpringSetRestAngle", JSB_cpDampedRotarySpringSetRestAngle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedRotarySpringSetStiffness", JSB_cpDampedRotarySpringSetStiffness, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringGetAnchr1", JSB_cpDampedSpringGetAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringGetAnchr2", JSB_cpDampedSpringGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringGetDamping", JSB_cpDampedSpringGetDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringGetRestLength", JSB_cpDampedSpringGetRestLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringGetStiffness", JSB_cpDampedSpringGetStiffness, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringNew", JSB_cpDampedSpringNew, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringSetAnchr1", JSB_cpDampedSpringSetAnchr1, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringSetAnchr2", JSB_cpDampedSpringSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringSetDamping", JSB_cpDampedSpringSetDamping, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringSetRestLength", JSB_cpDampedSpringSetRestLength, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "dampedSpringSetStiffness", JSB_cpDampedSpringSetStiffness, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "gearJointGetPhase", JSB_cpGearJointGetPhase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "gearJointGetRatio", JSB_cpGearJointGetRatio, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "gearJointNew", JSB_cpGearJointNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "gearJointSetPhase", JSB_cpGearJointSetPhase, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "gearJointSetRatio", JSB_cpGearJointSetRatio, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "grooveJointGetAnchr2", JSB_cpGrooveJointGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "grooveJointGetGrooveA", JSB_cpGrooveJointGetGrooveA, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "grooveJointGetGrooveB", JSB_cpGrooveJointGetGrooveB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "grooveJointNew", JSB_cpGrooveJointNew, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "grooveJointSetAnchr2", JSB_cpGrooveJointSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "grooveJointSetGrooveA", JSB_cpGrooveJointSetGrooveA, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "grooveJointSetGrooveB", JSB_cpGrooveJointSetGrooveB, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "initChipmunk", JSB_cpInitChipmunk, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "momentForBox", JSB_cpMomentForBox, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "momentForBox2", JSB_cpMomentForBox2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "momentForCircle", JSB_cpMomentForCircle, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "momentForSegment", JSB_cpMomentForSegment, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pinJointGetAnchr1", JSB_cpPinJointGetAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pinJointGetAnchr2", JSB_cpPinJointGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pinJointGetDist", JSB_cpPinJointGetDist, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pinJointNew", JSB_cpPinJointNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pinJointSetAnchr1", JSB_cpPinJointSetAnchr1, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pinJointSetAnchr2", JSB_cpPinJointSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pinJointSetDist", JSB_cpPinJointSetDist, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pivotJointGetAnchr1", JSB_cpPivotJointGetAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pivotJointGetAnchr2", JSB_cpPivotJointGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pivotJointNew", JSB_cpPivotJointNew, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pivotJointNew2", JSB_cpPivotJointNew2, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pivotJointSetAnchr1", JSB_cpPivotJointSetAnchr1, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "pivotJointSetAnchr2", JSB_cpPivotJointSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "polyShapeGetNumVerts", JSB_cpPolyShapeGetNumVerts, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "polyShapeGetVert", JSB_cpPolyShapeGetVert, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "ratchetJointGetAngle", JSB_cpRatchetJointGetAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "ratchetJointGetPhase", JSB_cpRatchetJointGetPhase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "ratchetJointGetRatchet", JSB_cpRatchetJointGetRatchet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "ratchetJointNew", JSB_cpRatchetJointNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "ratchetJointSetAngle", JSB_cpRatchetJointSetAngle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "ratchetJointSetPhase", JSB_cpRatchetJointSetPhase, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "ratchetJointSetRatchet", JSB_cpRatchetJointSetRatchet, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "resetShapeIdCounter", JSB_cpResetShapeIdCounter, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "rotaryLimitJointGetMax", JSB_cpRotaryLimitJointGetMax, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "rotaryLimitJointGetMin", JSB_cpRotaryLimitJointGetMin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "rotaryLimitJointNew", JSB_cpRotaryLimitJointNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "rotaryLimitJointSetMax", JSB_cpRotaryLimitJointSetMax, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "rotaryLimitJointSetMin", JSB_cpRotaryLimitJointSetMin, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "segmentShapeGetA", JSB_cpSegmentShapeGetA, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "segmentShapeGetB", JSB_cpSegmentShapeGetB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "segmentShapeGetNormal", JSB_cpSegmentShapeGetNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "segmentShapeGetRadius", JSB_cpSegmentShapeGetRadius, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "segmentShapeNew", JSB_cpSegmentShapeNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "segmentShapeSetNeighbors", JSB_cpSegmentShapeSetNeighbors, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeCacheBB", JSB_cpShapeCacheBB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeDestroy", JSB_cpShapeDestroy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeFree", JSB_cpShapeFree, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetBB", JSB_cpShapeGetBB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetBody", JSB_cpShapeGetBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetCollisionType", JSB_cpShapeGetCollisionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetElasticity", JSB_cpShapeGetElasticity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetFriction", JSB_cpShapeGetFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetGroup", JSB_cpShapeGetGroup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetLayers", JSB_cpShapeGetLayers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetSensor", JSB_cpShapeGetSensor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetSpace", JSB_cpShapeGetSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeGetSurfaceVelocity", JSB_cpShapeGetSurfaceVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapePointQuery", JSB_cpShapePointQuery, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeSetBody", JSB_cpShapeSetBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeSetCollisionType", JSB_cpShapeSetCollisionType, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeSetElasticity", JSB_cpShapeSetElasticity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeSetFriction", JSB_cpShapeSetFriction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeSetGroup", JSB_cpShapeSetGroup, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeSetLayers", JSB_cpShapeSetLayers, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeSetSensor", JSB_cpShapeSetSensor, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeSetSurfaceVelocity", JSB_cpShapeSetSurfaceVelocity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "shapeUpdate", JSB_cpShapeUpdate, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "simpleMotorGetRate", JSB_cpSimpleMotorGetRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "simpleMotorNew", JSB_cpSimpleMotorNew, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "simpleMotorSetRate", JSB_cpSimpleMotorSetRate, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointGetAnchr1", JSB_cpSlideJointGetAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointGetAnchr2", JSB_cpSlideJointGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointGetMax", JSB_cpSlideJointGetMax, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointGetMin", JSB_cpSlideJointGetMin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointNew", JSB_cpSlideJointNew, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointSetAnchr1", JSB_cpSlideJointSetAnchr1, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointSetAnchr2", JSB_cpSlideJointSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointSetMax", JSB_cpSlideJointSetMax, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "slideJointSetMin", JSB_cpSlideJointSetMin, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceActivateShapesTouchingShape", JSB_cpSpaceActivateShapesTouchingShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceAddBody", JSB_cpSpaceAddBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceAddConstraint", JSB_cpSpaceAddConstraint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceAddShape", JSB_cpSpaceAddShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceAddStaticShape", JSB_cpSpaceAddStaticShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceContainsBody", JSB_cpSpaceContainsBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceContainsConstraint", JSB_cpSpaceContainsConstraint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceContainsShape", JSB_cpSpaceContainsShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceDestroy", JSB_cpSpaceDestroy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceFree", JSB_cpSpaceFree, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetCollisionBias", JSB_cpSpaceGetCollisionBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetCollisionPersistence", JSB_cpSpaceGetCollisionPersistence, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetCollisionSlop", JSB_cpSpaceGetCollisionSlop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetCurrentTimeStep", JSB_cpSpaceGetCurrentTimeStep, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetDamping", JSB_cpSpaceGetDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetEnableContactGraph", JSB_cpSpaceGetEnableContactGraph, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetGravity", JSB_cpSpaceGetGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetIdleSpeedThreshold", JSB_cpSpaceGetIdleSpeedThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetIterations", JSB_cpSpaceGetIterations, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetSleepTimeThreshold", JSB_cpSpaceGetSleepTimeThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceGetStaticBody", JSB_cpSpaceGetStaticBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceInit", JSB_cpSpaceInit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceIsLocked", JSB_cpSpaceIsLocked, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceNew", JSB_cpSpaceNew, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spacePointQueryFirst", JSB_cpSpacePointQueryFirst, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceReindexShape", JSB_cpSpaceReindexShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceReindexShapesForBody", JSB_cpSpaceReindexShapesForBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceReindexStatic", JSB_cpSpaceReindexStatic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceRemoveBody", JSB_cpSpaceRemoveBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceRemoveConstraint", JSB_cpSpaceRemoveConstraint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceRemoveShape", JSB_cpSpaceRemoveShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceRemoveStaticShape", JSB_cpSpaceRemoveStaticShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetCollisionBias", JSB_cpSpaceSetCollisionBias, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetCollisionPersistence", JSB_cpSpaceSetCollisionPersistence, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetCollisionSlop", JSB_cpSpaceSetCollisionSlop, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetDamping", JSB_cpSpaceSetDamping, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetEnableContactGraph", JSB_cpSpaceSetEnableContactGraph, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetGravity", JSB_cpSpaceSetGravity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetIdleSpeedThreshold", JSB_cpSpaceSetIdleSpeedThreshold, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetIterations", JSB_cpSpaceSetIterations, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceSetSleepTimeThreshold", JSB_cpSpaceSetSleepTimeThreshold, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceStep", JSB_cpSpaceStep, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceUseSpatialHash", JSB_cpSpaceUseSpatialHash, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "fabs", JSB_cpfabs, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "fclamp", JSB_cpfclamp, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "fclamp01", JSB_cpfclamp01, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "flerp", JSB_cpflerp, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "flerpconst", JSB_cpflerpconst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "fmax", JSB_cpfmax, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "fmin", JSB_cpfmin, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vadd", JSB_cpvadd, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vclamp", JSB_cpvclamp, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vcross", JSB_cpvcross, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vdist", JSB_cpvdist, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vdistsq", JSB_cpvdistsq, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vdot", JSB_cpvdot, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "veql", JSB_cpveql, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vforangle", JSB_cpvforangle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vlength", JSB_cpvlength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vlengthsq", JSB_cpvlengthsq, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vlerp", JSB_cpvlerp, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vlerpconst", JSB_cpvlerpconst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vmult", JSB_cpvmult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vnear", JSB_cpvnear, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vneg", JSB_cpvneg, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vnormalize", JSB_cpvnormalize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vnormalize_safe", JSB_cpvnormalize_safe, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vperp", JSB_cpvperp, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vproject", JSB_cpvproject, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vrotate", JSB_cpvrotate, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vrperp", JSB_cpvrperp, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vslerp", JSB_cpvslerp, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vslerpconst", JSB_cpvslerpconst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vsub", JSB_cpvsub, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vtoangle", JSB_cpvtoangle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "vunrotate", JSB_cpvunrotate, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); #endif // JSB_INCLUDE_CHIPMUNK ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 "extensions/cocos-ext.h" #include "js_bindings_config.h" #ifdef JSB_INCLUDE_CHIPMUNK #include "jsapi.h" #include "jsfriendapi.h" #include "js_bindings_chipmunk_manual.h" #include "js_manual_conversions.h" USING_NS_CC_EXT; // Function declarations void static freeSpaceChildren(cpSpace *space); template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { TypeTest t; T* cobj = new T(); cobj->autorelease(); js_type_class_t *p; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); p = typeMapIter->second; CCASSERT(p, "The value is null."); JSObject *_tmp = JS_NewObject(cx, p->jsclass, p->proto, p->parentProto); js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); JS_AddObjectRoot(cx, &pp->obj); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); return JS_TRUE; } #pragma mark - convertions /* * PhysicsSprite */ #pragma mark - PhysicsSprite JSClass* JSPROXY_CCPhysicsSprite_class = NULL; JSObject* JSPROXY_CCPhysicsSprite_object = NULL; // Constructor // Destructor void JSPROXY_CCPhysicsSprite_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsSprite)", obj); } // Arguments: // Ret value: cpBody* (N/A) JSBool JSPROXY_CCPhysicsSprite_getCPBody(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) cpBody* ret_val; ret_val = real->getCPBody(); jsval ret_jsval = c_class_to_jsval( cx, ret_val, JSB_cpBody_object, JSB_cpBody_class, "cpBody" ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } // Arguments: // Ret value: BOOL (b) JSBool JSPROXY_CCPhysicsSprite_ignoreBodyRotation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) bool ret_val; ret_val = real->isIgnoreBodyRotation(); JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret_val)); return JS_TRUE; } // Arguments: cpBody* // Ret value: void (None) JSBool JSPROXY_CCPhysicsSprite_setCPBody_(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); if( ! ok ) return JS_FALSE; real->setCPBody((cpBody*)arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: BOOL // Ret value: void (None) JSBool JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; JSBool arg0; ok &= JS_ValueToBoolean( cx, *argvp++, &arg0 ); if( ! ok ) return JS_FALSE; real->setIgnoreBodyRotation((bool)arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } /* * PhysicsDebugNode */ //#pragma mark - PhysicsDebugNode JSClass* JSB_CCPhysicsDebugNode_class = NULL; JSObject* JSB_CCPhysicsDebugNode_object = NULL; extern JSObject *js_cocos2dx_CCDrawNode_prototype; // Constructor // Destructor void JSB_CCPhysicsDebugNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsDebugNode)", obj); } // Arguments: cpSpace* // Ret value: PhysicsDebugNode* (o) JSBool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); PhysicsDebugNode* ret = PhysicsDebugNode::create(arg0); jsval jsret; do { if (ret) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS_AddNamedObjectRoot(cx, &p->obj, "CCDebugNode"); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } // Arguments: cpSpace* // Ret value: void (None) JSBool JSB_CCPhysicsDebugNode_setSpace_(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(jsthis); PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpSpace* arg0; ok &= jsval_to_opaque( cx, *argvp++, (void**)&arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); real->setSpace(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: cpSpace* (N/A) JSBool JSB_CCPhysicsDebugNode_space(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(jsthis); PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, real) JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); cpSpace* ret_val; ret_val = real->getSpace(); jsval ret_jsval = opaque_to_jsval( cx, ret_val ); JS_SET_RVAL(cx, vp, ret_jsval); return JS_TRUE; } void JSB_CCPhysicsDebugNode_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_CCPhysicsDebugNode_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_CCPhysicsDebugNode_class->name = name; JSB_CCPhysicsDebugNode_class->addProperty = JS_PropertyStub; JSB_CCPhysicsDebugNode_class->delProperty = JS_DeletePropertyStub; JSB_CCPhysicsDebugNode_class->getProperty = JS_PropertyStub; JSB_CCPhysicsDebugNode_class->setProperty = JS_StrictPropertyStub; JSB_CCPhysicsDebugNode_class->enumerate = JS_EnumerateStub; JSB_CCPhysicsDebugNode_class->resolve = JS_ResolveStub; JSB_CCPhysicsDebugNode_class->convert = JS_ConvertStub; JSB_CCPhysicsDebugNode_class->finalize = JSB_CCPhysicsDebugNode_finalize; JSB_CCPhysicsDebugNode_class->flags = 0; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("_setSpace", JSB_CCPhysicsDebugNode_setSpace_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSpace", JSB_CCPhysicsDebugNode_space, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("_create", JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; TypeTest t1; js_type_class_t *typeClass = nullptr; std::string typeName = t1.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, typeClass->proto, JSB_CCPhysicsDebugNode_class, dummy_constructor, 0,properties,funcs,NULL,st_funcs); TypeTest t; js_type_class_t *p; typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = JSB_CCPhysicsDebugNode_class; p->proto = JSB_CCPhysicsDebugNode_object; p->parentProto = typeClass->proto; _js_global_type_map.insert(std::make_pair(typeName, p)); } } // Arguments: NSString*, CGRect // Ret value: PhysicsSprite* (o) JSBool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); cocos2d::Rect arg1; ok &= jsval_to_ccrect(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); PhysicsSprite* ret = PhysicsSprite::create(arg0, arg1); jsval jsret; do { if (ret) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); PhysicsSprite* ret = PhysicsSprite::create(arg0); jsval jsret; do { if (ret) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } return JS_FALSE; } // Arguments: SpriteFrame* // Ret value: PhysicsSprite* (o) JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); cocos2d::SpriteFrame* arg0; if (argc >= 1) { do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg0) } while (0); } PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrame(arg0); jsval jsret; do { if (ret) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } // Arguments: NSString* // Ret value: PhysicsSprite* (o) JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; const char* arg0; std::string arg0_tmp; if (argc == 1) { ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrameName(arg0); jsval jsret; do { if (ret) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JSObject* globalObj) { JSPROXY_CCPhysicsSprite_class = (JSClass *)calloc(1, sizeof(JSClass)); JSPROXY_CCPhysicsSprite_class->name = "PhysicsSprite"; JSPROXY_CCPhysicsSprite_class->addProperty = JS_PropertyStub; JSPROXY_CCPhysicsSprite_class->delProperty = JS_DeletePropertyStub; JSPROXY_CCPhysicsSprite_class->getProperty = JS_PropertyStub; JSPROXY_CCPhysicsSprite_class->setProperty = JS_StrictPropertyStub; JSPROXY_CCPhysicsSprite_class->enumerate = JS_EnumerateStub; JSPROXY_CCPhysicsSprite_class->resolve = JS_ResolveStub; JSPROXY_CCPhysicsSprite_class->convert = JS_ConvertStub; JSPROXY_CCPhysicsSprite_class->finalize = JSPROXY_CCPhysicsSprite_finalize; JSPROXY_CCPhysicsSprite_class->flags = 0; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getCPBody", JSPROXY_CCPhysicsSprite_getCPBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIgnoreBodyRotation", JSPROXY_CCPhysicsSprite_ignoreBodyRotation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("_setCPBody", JSPROXY_CCPhysicsSprite_setCPBody_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setIgnoreBodyRotation", JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithSpriteFrame", JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("createWithSpriteFrameName", JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; TypeTest t1; js_type_class_t *typeClass = nullptr; std::string typeName = t1.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, typeClass->proto, JSPROXY_CCPhysicsSprite_class, dummy_constructor, 0,properties,funcs,NULL,st_funcs); TypeTest t; js_type_class_t *p; typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = JSPROXY_CCPhysicsSprite_class; p->proto = JSPROXY_CCPhysicsSprite_object; p->parentProto = typeClass->proto; _js_global_type_map.insert(std::make_pair(typeName, p)); } } void register_CCPhysicsSprite(JSContext *cx, JSObject *obj) { JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; JSPROXY_CCPhysicsSprite_createClass(cx, obj); } void register_CCPhysicsDebugNode(JSContext *cx, JSObject *obj) { JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; JSB_CCPhysicsDebugNode_createClass(cx, obj, "PhysicsDebugNode"); } JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ) { JSObject *jsobj; JSBool ok = JS_ValueToObject( cx, vp, &jsobj ); JSB_PRECONDITION( ok, "Error converting value to object"); JSB_PRECONDITION( jsobj, "Not a valid JS object"); JS::RootedValue vall(cx); JS::RootedValue valb(cx); JS::RootedValue valr(cx); JS::RootedValue valt(cx); ok = JS_TRUE; ok &= JS_GetProperty(cx, jsobj, "l", &vall); ok &= JS_GetProperty(cx, jsobj, "b", &valb); ok &= JS_GetProperty(cx, jsobj, "r", &valr); ok &= JS_GetProperty(cx, jsobj, "t", &valt); JSB_PRECONDITION( ok, "Error obtaining point properties"); double l, b, r, t; ok &= JS_ValueToNumber(cx, vall, &l); ok &= JS_ValueToNumber(cx, valb, &b); ok &= JS_ValueToNumber(cx, valr, &r); ok &= JS_ValueToNumber(cx, valt, &t); JSB_PRECONDITION( ok, "Error converting value to numbers"); ret->l = l; ret->b = b; ret->r = r; ret->t = t; return JS_TRUE; } jsval cpBB_to_jsval(JSContext *cx, cpBB bb ) { JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); if (!object) return JSVAL_VOID; if (!JS_DefineProperty(cx, object, "l", DOUBLE_TO_JSVAL(bb.l), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "b", DOUBLE_TO_JSVAL(bb.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "r", DOUBLE_TO_JSVAL(bb.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "t", DOUBLE_TO_JSVAL(bb.t), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) return JSVAL_VOID; return OBJECT_TO_JSVAL(object); } // In order to be compatible with Chipmunk-JS API, // this function expect to receive an array of numbers, and not an array of vects // OK: [1,2, 3,4, 5,6] <- expected // BAD: [{x:1, y:2}, {x:3,y:4}, {x:5, y:6}] <- not expected JSBool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts) { // Parsing sequence JSObject *jsobj; JSBool ok = JS_ValueToObject( cx, vp, &jsobj ); JSB_PRECONDITION( ok, "Error converting value to object"); JSB_PRECONDITION( jsobj && JS_IsArrayObject( cx, jsobj), "Object must be an array"); uint32_t len; JS_GetArrayLength(cx, jsobj, &len); JSB_PRECONDITION( len%2==0, "Array lenght should be even"); cpVect *array = (cpVect*)malloc( sizeof(cpVect) * len/2); for( uint32_t i=0; i< len;i++ ) { jsval valarg; JS_GetElement(cx, jsobj, i, &valarg); double value; ok = JS_ValueToNumber(cx, valarg, &value); JSB_PRECONDITION( ok, "Error converting value to nsobject"); if(i%2==0) array[i/2].x = value; else array[i/2].y = value; } *numVerts = len/2; *verts = array; return JS_TRUE; } #pragma mark - Collision Handler struct collision_handler { cpCollisionType typeA; cpCollisionType typeB; JSObject *begin; JSObject *pre; JSObject *post; JSObject *separate; JSObject *jsthis; JSContext *cx; // "owner" of the collision handler // Needed when the space goes out of scope, it will remove all the allocated collision handlers for him. cpSpace *space; unsigned long hash_key; unsigned int is_oo; // Objected oriented API ? UT_hash_handle hh; }; // hash struct collision_handler* collision_handler_hash = NULL; // helper pair static unsigned long pair_ints( unsigned long A, unsigned long B ) { // order is not important unsigned long k1 = MIN(A, B ); unsigned long k2 = MAX(A, B ); return (k1 + k2) * (k1 + k2 + 1) /2 + k2; } static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data) { struct collision_handler *handler = (struct collision_handler*) data; jsval args[2]; if( handler->is_oo ) { args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); } else { args[0] = opaque_to_jsval( handler->cx, arb); args[1] = opaque_to_jsval( handler->cx, space ); } JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval rval; JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->begin), 2, args, &rval); JSB_PRECONDITION2(ok, handler->cx, cpFalse, "Error calling collision callback: begin"); if( JSVAL_IS_BOOLEAN(rval) ) { JSBool ret = JSVAL_TO_BOOLEAN(rval); return (cpBool)ret; } return cpTrue; } static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data) { struct collision_handler *handler = (struct collision_handler*) data; jsval args[2]; if( handler->is_oo ) { args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); } else { args[0] = opaque_to_jsval( handler->cx, arb); args[1] = opaque_to_jsval( handler->cx, space ); } JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval rval; JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->pre), 2, args, &rval); JSB_PRECONDITION2(ok, handler->cx, JS_FALSE, "Error calling collision callback: pre"); if( JSVAL_IS_BOOLEAN(rval) ) { JSBool ret = JSVAL_TO_BOOLEAN(rval); return (cpBool)ret; } return cpTrue; } static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data) { struct collision_handler *handler = (struct collision_handler*) data; jsval args[2]; if( handler->is_oo ) { args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); } else { args[0] = opaque_to_jsval( handler->cx, arb); args[1] = opaque_to_jsval( handler->cx, space ); } JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval ignore; JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->post), 2, args, &ignore); JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Post"); } static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data) { struct collision_handler *handler = (struct collision_handler*) data; jsval args[2]; if( handler->is_oo ) { args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); args[1] = c_class_to_jsval(handler->cx, space, JSB_cpSpace_object, JSB_cpSpace_class, "cpArbiter"); } else { args[0] = opaque_to_jsval( handler->cx, arb); args[1] = opaque_to_jsval( handler->cx, space ); } JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET jsval ignore; JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->separate), 2, args, &ignore); JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Separate");} #pragma mark - cpSpace #pragma mark constructor / destructor void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *jsthis) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); if( proxy ) { CCLOGINFO("jsbindings: finalizing JS object %p (cpSpace), handle: %p", jsthis, proxy->handle); // space cpSpace *space = (cpSpace*) proxy->handle; // Remove collision handlers, since the user might have forgotten to manually remove them struct collision_handler *current, *tmp; HASH_ITER(hh, collision_handler_hash, current, tmp) { if( current->space == space ) { JSContext *cx = current->cx; // unroot it if( current->begin ) { JS_RemoveObjectRoot(cx, ¤t->begin); } if( current->pre ) JS_RemoveObjectRoot(cx, ¤t->pre); if( current->post ) JS_RemoveObjectRoot(cx, ¤t->post); if( current->separate ) JS_RemoveObjectRoot(cx, ¤t->separate); HASH_DEL(collision_handler_hash,current); /* delete; users advances to next */ free(current); /* optional- if you want to free */ } } // Free Space Children freeSpaceChildren(space); jsb_del_jsobject_for_proxy(space); if(proxy->flags == JSB_C_FLAG_CALL_FREE) cpSpaceFree(space); jsb_del_c_proxy_for_jsobject(jsthis); } } #pragma mark addCollisionHandler static JSBool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space, unsigned int is_oo) { struct collision_handler *handler = (struct collision_handler*) malloc( sizeof(*handler) ); JSB_PRECONDITION(handler, "Error allocating memory"); JSBool ok = JS_TRUE; // args ok &= jsval_to_int(cx, *argvp++, (int32_t*) &handler->typeA ); ok &= jsval_to_int(cx, *argvp++, (int32_t*) &handler->typeB ); // this is no longer passed, so "this" is going to be "this". // ok &= JS_ValueToObject(cx, *argvp++, &handler->jsthis ); handler->jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); handler->begin = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; argvp++; handler->pre = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; argvp++; handler->post = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; argvp++; handler->separate = !JSVAL_IS_NULL(*argvp) ? JSVAL_TO_OBJECT(*argvp) : NULL; argvp++; JSB_PRECONDITION(ok, "Error parsing arguments"); // Object Oriented API ? handler->is_oo = is_oo; // owner of the collision handler handler->space = space; // Root it if( handler->begin ) JS_AddNamedObjectRoot(cx, &handler->begin, "begin collision_handler"); if( handler->pre ) JS_AddNamedObjectRoot(cx, &handler->pre, "pre collision_handler"); if( handler->post ) JS_AddNamedObjectRoot(cx, &handler->post, "post collision_handler"); if( handler->separate ) JS_AddNamedObjectRoot(cx, &handler->separate, "separate collision_handler"); handler->cx = cx; cpSpaceAddCollisionHandler(space, handler->typeA, handler->typeB, !handler->begin ? NULL : &myCollisionBegin, !handler->pre ? NULL : &myCollisionPre, !handler->post ? NULL : &myCollisionPost, !handler->separate ? NULL : &myCollisionSeparate, handler ); // // Already added ? If so, remove it. // Then add new entry // struct collision_handler *hashElement = NULL; unsigned long paired_key = pair_ints(handler->typeA, handler->typeB ); HASH_FIND_INT(collision_handler_hash, &paired_key, hashElement); if( hashElement ) { HASH_DEL( collision_handler_hash, hashElement ); free( hashElement ); } handler->hash_key = paired_key; HASH_ADD_INT( collision_handler_hash, hash_key, handler ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSBool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==7, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); // args cpSpace *space; JSBool ok = jsval_to_opaque( cx, *argvp++, (void**)&space); JSB_PRECONDITION(ok, "Error parsing arguments"); return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, space, 0); } // method JSBool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==6, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; return __jsb_cpSpace_addCollisionHandler(cx, vp, JS_ARGV(cx,vp), (cpSpace*)handle, 1); } #pragma mark removeCollisionHandler static JSBool __jsb_cpSpace_removeCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space) { JSBool ok = JS_TRUE; cpCollisionType typeA; cpCollisionType typeB; ok &= jsval_to_int(cx, *argvp++, (int32_t*) &typeA ); ok &= jsval_to_int(cx, *argvp++, (int32_t*) &typeB ); JSB_PRECONDITION(ok, "Error parsing arguments"); cpSpaceRemoveCollisionHandler(space, typeA, typeB ); // Remove it struct collision_handler *hashElement = NULL; unsigned long key = pair_ints(typeA, typeB ); HASH_FIND_INT(collision_handler_hash, &key, hashElement); if( hashElement ) { // unroot it if( hashElement->begin ) JS_RemoveObjectRoot(cx, &hashElement->begin); if( hashElement->pre ) JS_RemoveObjectRoot(cx, &hashElement->pre); if( hashElement->post ) JS_RemoveObjectRoot(cx, &hashElement->post); if( hashElement->separate ) JS_RemoveObjectRoot(cx, &hashElement->separate); HASH_DEL( collision_handler_hash, hashElement ); free( hashElement ); } JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Free function JSBool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); cpSpace* space; JSBool ok = jsval_to_opaque( cx, *argvp++, (void**)&space); JSB_PRECONDITION(ok, "Error parsing arguments"); return __jsb_cpSpace_removeCollisionHandler(cx, vp, argvp, space); } // method JSBool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; return __jsb_cpSpace_removeCollisionHandler(cx, vp, JS_ARGV(cx,vp), (cpSpace*)handle); } #pragma mark Add functios. Root JSObjects // Arguments: cpBody* // Ret value: cpBody* JSBool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg1; jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); JSB_PRECONDITION(ok, "Error processing arguments"); cpSpaceAddBody((cpSpace*)arg0 , (cpBody*)arg1 ); // Root it: JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpBody"); // addBody returns the same object that was added, so return it without conversions JS_SET_RVAL(cx, vp, retval); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: cpConstraint* JSBool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg1; jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); JSB_PRECONDITION(ok, "Error processing arguments"); cpSpaceAddConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); // Root it: JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpConstraint"); // addConstraint returns the same object that was added, so return it without conversions JS_SET_RVAL(cx, vp, retval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpShape* JSBool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg1; jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); JSB_PRECONDITION(ok, "Error processing arguments"); cpSpaceAddShape((cpSpace*)arg0 , (cpShape*)arg1 ); // Root it: JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpShape"); // addShape returns the same object that was added, so return it without conversions JS_SET_RVAL(cx, vp, retval); return JS_TRUE; } // Arguments: cpShape* // Ret value: cpShape* JSBool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg1; jsval retval = *argvp; struct jsb_c_proxy_s *retproxy; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); JSB_PRECONDITION(ok, "Error processing arguments"); cpSpaceAddStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); // Root it: JS_AddNamedObjectRoot(cx, &retproxy->jsobj, "cpShape (static)"); // addStaticShape returns the same object that was added, so return it without conversions JS_SET_RVAL(cx, vp, retval); return JS_TRUE; } #pragma mark Remove functios. Untoot JSObjects // Arguments: cpBody* // Ret value: void JSBool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* arg1; struct jsb_c_proxy_s *retproxy; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); JSB_PRECONDITION(ok, "Error processing arguments"); cpSpaceRemoveBody((cpSpace*)arg0 , (cpBody*)arg1 ); JS_RemoveObjectRoot(cx, &retproxy->jsobj); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpConstraint* // Ret value: void JSBool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpConstraint* arg1; struct jsb_c_proxy_s *retproxy; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); JSB_PRECONDITION(ok, "Error processing arguments"); cpSpaceRemoveConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); JS_RemoveObjectRoot(cx, &retproxy->jsobj); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape* // Ret value: void JSBool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg1; struct jsb_c_proxy_s *retproxy; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); JSB_PRECONDITION(ok, "Error processing arguments"); cpSpaceRemoveShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_RemoveObjectRoot(cx, &retproxy->jsobj); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: cpShape* // Ret value: void JSBool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); cpSpace* arg0 = (cpSpace*) proxy->handle; jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpShape* arg1; struct jsb_c_proxy_s *retproxy; ok &= jsval_to_c_class( cx, *argvp++, (void**)&arg1, &retproxy ); JSB_PRECONDITION(ok, "Error processing arguments"); cpSpaceRemoveStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); JS_RemoveObjectRoot(cx, &retproxy->jsobj); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } #pragma mark - Arbiter #pragma mark getBodies static JSBool __jsb_cpArbiter_getBodies(JSContext *cx, jsval *vp, jsval *argvp, cpArbiter *arbiter, unsigned int is_oo) { cpBody *bodyA; cpBody *bodyB; cpArbiterGetBodies(arbiter, &bodyA, &bodyB); jsval valA, valB; if( is_oo ) { valA = c_class_to_jsval(cx, bodyA, JSB_cpBody_object, JSB_cpBody_class, "cpArbiter"); valB = c_class_to_jsval(cx, bodyB, JSB_cpBody_object, JSB_cpBody_class, "cpArbiter"); } else { valA = opaque_to_jsval(cx, bodyA); valB = opaque_to_jsval(cx, bodyB); } JSObject *jsobj = JS_NewArrayObject(cx, 2, NULL); JS_SetElement(cx, jsobj, 0, &valA); JS_SetElement(cx, jsobj, 1, &valB); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Free function JSBool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); cpArbiter* arbiter; if( ! jsval_to_opaque( cx, *argvp++, (void**)&arbiter ) ) return JS_FALSE; return __jsb_cpArbiter_getBodies(cx, vp, argvp, arbiter, 0); } // Method JSBool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); JSB_PRECONDITION( proxy, "Invalid private object"); void *handle = proxy->handle; return __jsb_cpArbiter_getBodies(cx, vp, JS_ARGV(cx,vp), (cpArbiter*)handle, 1); } #pragma mark getShapes static JSBool __jsb_cpArbiter_getShapes(JSContext *cx, jsval *vp, jsval *argvp, cpArbiter *arbiter, unsigned int is_oo) { cpShape *shapeA; cpShape *shapeB; cpArbiterGetShapes(arbiter, &shapeA, &shapeB); jsval valA, valB; if( is_oo ) { valA = c_class_to_jsval(cx, shapeA, JSB_cpShape_object, JSB_cpShape_class, "cpShape"); valB = c_class_to_jsval(cx, shapeB, JSB_cpShape_object, JSB_cpShape_class, "cpShape"); } else { valA = opaque_to_jsval(cx, shapeA); valB = opaque_to_jsval(cx, shapeB); } JSObject *jsobj = JS_NewArrayObject(cx, 2, NULL); JS_SetElement(cx, jsobj, 0, &valA); JS_SetElement(cx, jsobj, 1, &valB); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // function JSBool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); cpArbiter* arbiter; if( ! jsval_to_opaque( cx, *argvp++, (void**) &arbiter ) ) return JS_FALSE; return __jsb_cpArbiter_getShapes(cx, vp, argvp, arbiter, 0); } // method JSBool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; return __jsb_cpArbiter_getShapes(cx, vp, JS_ARGV(cx,vp), (cpArbiter*)handle, 1); } #pragma mark - Body #pragma mark constructor // Manually added to identify static vs dynamic bodies JSBool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpBody_class, JSB_cpBody_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; double m; double i; ok &= JS_ValueToNumber( cx, *argvp++, &m ); ok &= JS_ValueToNumber( cx, *argvp++, &i ); JSB_PRECONDITION(ok, "Error processing arguments"); cpBody *ret_body = NULL; if( m == INFINITY && i == INFINITY) { ret_body = cpBodyNewStatic(); // XXX: Hack. IT WILL LEAK "rogue" objects., But at least it prevents a crash. // The thing is that "rogue" bodies needs to be freed after the its shape, and I am not sure // how to do it in a "js" way. jsb_set_c_proxy_for_jsobject(jsobj, ret_body, JSB_C_FLAG_DO_NOT_CALL_FREE); } else { ret_body = cpBodyNew((cpFloat)m , (cpFloat)i ); jsb_set_c_proxy_for_jsobject(jsobj, ret_body, JSB_C_FLAG_CALL_FREE); } jsb_set_jsobject_for_proxy(jsobj, ret_body); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } #pragma mark getUserData static JSBool __jsb_cpBody_getUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body) { JSObject *data = (JSObject*) cpBodyGetUserData(body); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(data)); return JS_TRUE; } // free function JSBool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); cpBody *body; if( ! jsval_to_opaque( cx, *argvp++, (void**) &body ) ) return JS_FALSE; return __jsb_cpBody_getUserData(cx, vp, argvp, body); } // method JSBool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; return __jsb_cpBody_getUserData(cx, vp, JS_ARGV(cx,vp), (cpBody*)handle); } #pragma mark setUserData static JSBool __jsb_cpBody_setUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body) { JSObject *jsobj; JSBool ok = JS_ValueToObject(cx, *argvp++, &jsobj); JSB_PRECONDITION(ok, "Error parsing arguments"); cpBodySetUserData(body, jsobj); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // free function JSBool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==2, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); cpBody *body; JSBool ok = jsval_to_opaque( cx, *argvp++, (void**) &body ); JSB_PRECONDITION(ok, "Error parsing arguments"); return __jsb_cpBody_setUserData(cx, vp, argvp, body); } // method JSBool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; return __jsb_cpBody_setUserData(cx, vp, JS_ARGV(cx,vp), (cpBody*)handle); } #pragma mark - Poly related // cpFloat cpAreaForPoly(const int numVerts, const cpVect *verts); JSBool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect *verts; int numVerts; ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing array"); cpFloat area = cpAreaForPoly(numVerts, verts); free(verts); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(area)); return JS_TRUE; } // cpFloat cpMomentForPoly(cpFloat m, int numVerts, const cpVect *verts, cpVect offset); JSBool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect *verts; cpVect offset; int numVerts; double m; ok &= JS_ValueToNumber(cx, *argvp++, &m); ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &offset ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing args"); cpFloat moment = cpMomentForPoly((cpFloat)m, numVerts, verts, offset); free(verts); JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(moment)); return JS_TRUE; } // cpVect cpCentroidForPoly(const int numVerts, const cpVect *verts); JSBool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpVect *verts; int numVerts; ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing args"); cpVect centroid = cpCentroidForPoly(numVerts, verts); free(verts); JS_SET_RVAL(cx, vp, cpVect_to_jsval(cx, (cpVect)centroid)); return JS_TRUE; } // void cpRecenterPoly(const int numVerts, cpVect *verts); JSBool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp) { CCASSERT(false, "NOT IMPLEMENTED"); return JS_FALSE; } #pragma mark - Object Oriented Chipmunk /* * Chipmunk Base Object */ JSClass* JSB_cpBase_class = NULL; JSObject* JSB_cpBase_object = NULL; // Constructor JSBool JSB_cpBase_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc==1, cx, JS_FALSE, "Invalid arguments. Expecting 1"); JSObject *jsobj = JS_NewObject(cx, JSB_cpBase_class, JSB_cpBase_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; void *handle = NULL; ok = jsval_to_opaque(cx, *argvp++, &handle); JSB_PRECONDITION(ok, "Error converting arguments for JSB_cpBase_constructor"); jsb_set_c_proxy_for_jsobject(jsobj, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); jsb_set_jsobject_for_proxy(jsobj, handle); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } // Destructor void JSB_cpBase_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (cpBase)", obj); // should not delete the handle since it was manually added } JSBool JSB_cpBase_getHandle(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); JSB_PRECONDITION2(argc==0, cx, JS_FALSE, "Invalid number of arguments"); struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); void *handle = proxy->handle; jsval ret_val = opaque_to_jsval(cx, handle); JS_SET_RVAL(cx, vp, ret_val); return JS_TRUE; } JSBool JSB_cpBase_setHandle(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSB_PRECONDITION( jsthis, "Invalid jsthis object"); JSB_PRECONDITION2(argc==1, cx, JS_FALSE, "Invalid number of arguments"); jsval *argvp = JS_ARGV(cx,vp); void *handle; JSBool ok = jsval_to_opaque(cx, *argvp++, &handle); JSB_PRECONDITION( ok, "Invalid parsing arguments"); jsb_set_c_proxy_for_jsobject(jsthis, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); jsb_set_jsobject_for_proxy(jsthis, handle); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void JSB_cpBase_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpBase_class = (JSClass *)calloc(1, sizeof(JSClass)); JSB_cpBase_class->name = name; JSB_cpBase_class->addProperty = JS_PropertyStub; JSB_cpBase_class->delProperty = JS_DeletePropertyStub; JSB_cpBase_class->getProperty = JS_PropertyStub; JSB_cpBase_class->setProperty = JS_StrictPropertyStub; JSB_cpBase_class->enumerate = JS_EnumerateStub; JSB_cpBase_class->resolve = JS_ResolveStub; JSB_cpBase_class->convert = JS_ConvertStub; JSB_cpBase_class->finalize = JSB_cpBase_finalize; JSB_cpBase_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("getHandle", JSB_cpBase_getHandle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHandle", JSB_cpBase_setHandle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; JSB_cpBase_object = JS_InitClass(cx, globalObj, NULL, JSB_cpBase_class, JSB_cpBase_constructor,0,properties,funcs,NULL,st_funcs); JSBool found; JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } // Manual "methods" // Constructor JSBool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==3, cx, JS_FALSE, "Invalid number of arguments"); JSObject *jsobj = JS_NewObject(cx, JSB_cpPolyShape_class, JSB_cpPolyShape_object, NULL); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; cpBody* body; cpVect *verts; cpVect offset; int numVerts; ok &= jsval_to_c_class( cx, *argvp++, (void**)&body, NULL ); ok &= jsval_to_array_of_cpvect( cx, *argvp++, &verts, &numVerts); ok &= jsval_to_cpVect( cx, *argvp++, (cpVect*) &offset ); JSB_PRECONDITION(ok, "Error processing arguments"); cpShape *shape = cpPolyShapeNew(body, numVerts, verts, offset); jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE); jsb_set_jsobject_for_proxy(jsobj, shape); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); free(verts); return JS_TRUE; } #pragma mark Space Free functions // // When the space is removed, it should all remove its children. But not "free" them. // "free" will be performed by the JS Garbage Collector // // Functions copied & pasted from ChipmunkDemo.c // https://github.com/slembcke/Chipmunk-Physics/blob/master/Demo/ChipmunkDemo.c#L89 // static void unroot_jsobject_from_handle(void *handle) { JSObject *jsobj = jsb_get_jsobject_for_proxy(handle); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsobj); // HACK context from global JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &proxy->jsobj); } static void shapeFreeWrap(cpSpace *space, cpShape *shape, void *unused){ cpSpaceRemoveShape(space, shape); unroot_jsobject_from_handle(shape); // cpShapeFree(shape); } static void postShapeFree(cpShape *shape, cpSpace *space){ cpSpaceAddPostStepCallback(space, (cpPostStepFunc)shapeFreeWrap, shape, NULL); } static void constraintFreeWrap(cpSpace *space, cpConstraint *constraint, void *unused){ cpSpaceRemoveConstraint(space, constraint); unroot_jsobject_from_handle(constraint); // cpConstraintFree(constraint); } static void postConstraintFree(cpConstraint *constraint, cpSpace *space){ cpSpaceAddPostStepCallback(space, (cpPostStepFunc)constraintFreeWrap, constraint, NULL); } static void bodyFreeWrap(cpSpace *space, cpBody *body, void *unused){ cpSpaceRemoveBody(space, body); unroot_jsobject_from_handle(body); // cpBodyFree(body); } static void postBodyFree(cpBody *body, cpSpace *space){ cpSpaceAddPostStepCallback(space, (cpPostStepFunc)bodyFreeWrap, body, NULL); } // Safe and future proof way to remove and free all objects that have been added to the space. void static freeSpaceChildren(cpSpace *space) { // Must remove these BEFORE freeing the body or you will access dangling pointers. cpSpaceEachShape(space, (cpSpaceShapeIteratorFunc)postShapeFree, space); cpSpaceEachConstraint(space, (cpSpaceConstraintIteratorFunc)postConstraintFree, space); cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)postBodyFree, space); } #endif // JSB_INCLUDE_CHIPMUNK ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 __js_bindings_chipmunk_manual #define __js_bindings_chipmunk_manual #include "js_bindings_config.h" #include "js_manual_conversions.h" #include "ScriptingCore.h" #ifdef JSB_INCLUDE_CHIPMUNK #include "chipmunk.h" #include "jsapi.h" #include "js_bindings_chipmunk_auto_classes.h" // Free Functions JSBool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp); // poly related JSBool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp); // "Methods" from the OO API JSBool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); // manually wrapped for rooting/unrooting purposes JSBool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp); // convertions jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); JSBool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); JSBool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts); // requires cocos2d #define cpVect_to_jsval CGPoint_to_jsval #define jsval_to_cpVect jsval_to_CGPoint // Object Oriented Chipmunk void JSB_cpBase_createClass(JSContext* cx, JSObject* globalObj, const char * name ); extern JSObject* JSB_cpBase_object; extern JSClass* JSB_cpBase_class; extern void register_CCPhysicsSprite(JSContext *cx, JSObject *obj); extern void register_CCPhysicsDebugNode(JSContext *cx, JSObject *obj); // Manual constructor / destructors JSBool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp); void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *obj); #endif // JSB_INCLUDE_CHIPMUNK #endif // __js_bindings_chipmunk_manual ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.cpp ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 JSB_INCLUDE_CHIPMUNK #define JSB_INCLUDE_CHIPMUNK #endif #include "js_bindings_config.h" #include "ScriptingCore.h" // chipmunk #include "js_bindings_chipmunk_auto_classes.h" #include "js_bindings_chipmunk_functions.h" #include "js_bindings_chipmunk_manual.h" void jsb_register_chipmunk(JSContext* cx, JSObject *object) { // // Chipmunk // JSObject *chipmunk = JS_NewObject(cx, NULL, NULL, NULL); JS::RootedValue chipmunkVal(cx); chipmunkVal = OBJECT_TO_JSVAL(chipmunk); JS_SetProperty(cx, object, "cp", chipmunkVal); JSB_cpBase_createClass(cx, chipmunk, "Base"); // manual base class registration #include "js_bindings_chipmunk_auto_classes_registration.h" #include "js_bindings_chipmunk_functions_registration.h" // manual JS_DefineFunction(cx, chipmunk, "spaceAddCollisionHandler", JSB_cpSpaceAddCollisionHandler, 8, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceRemoveCollisionHandler", JSB_cpSpaceRemoveCollisionHandler, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetBodies", JSB_cpArbiterGetBodies, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetShapes", JSB_cpArbiterGetShapes, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetUserData", JSB_cpBodyGetUserData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodySetUserData", JSB_cpBodySetUserData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "areaForPoly", JSB_cpAreaForPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "momentForPoly", JSB_cpMomentForPoly, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "centroidForPoly", JSB_cpCentroidForPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "recenterPoly", JSB_cpRecenterPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); register_CCPhysicsSprite(cx, object); register_CCPhysicsDebugNode(cx, object); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_registration.h ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 __JSB_CHIPMUNK_REGISTRATION #define __JSB_CHIPMUNK_REGISTRATION void jsb_register_chipmunk( JSContext *globalC, JSObject *globalO); #endif // __JSB_CHIPMUNK_REGISTRATION ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj ================================================  Debug Win32 Release Win32 {21070E58-EEC6-4E16-8B4F-6D083DF55790} Win32Proj libJSBindingForChipmunk StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false Windows true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/chipmunk/libJSBindingForChipmunk.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx manual manual manual manual manual manual manual manual manual manual ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp ================================================ #include "cocos2d.h" #include "cocos2d_specifics.hpp" #include #include "js_bindings_config.h" #include "jsb_cocos2dx_auto.hpp" using namespace cocos2d; schedFunc_proxy_t *_schedFunc_target_ht = NULL; schedTarget_proxy_t *_schedObj_target_ht = NULL; JSTouchDelegate::TouchDelegateMap JSTouchDelegate::sTouchDelegateMap; JSTouchDelegate::JSTouchDelegate() : _obj(nullptr) , _needUnroot(false) , _touchListenerAllAtOnce(nullptr) , _touchListenerOneByOne(nullptr) { } JSTouchDelegate::~JSTouchDelegate() { CCLOGINFO("In the destructor of JSTouchDelegate."); } void JSTouchDelegate::setDelegateForJSObject(JSObject* pJSObj, JSTouchDelegate* pDelegate) { CCASSERT(sTouchDelegateMap.find(pJSObj) == sTouchDelegateMap.end(), ""); sTouchDelegateMap.insert(TouchDelegatePair(pJSObj, pDelegate)); } JSTouchDelegate* JSTouchDelegate::getDelegateForJSObject(JSObject* pJSObj) { JSTouchDelegate* pRet = NULL; TouchDelegateMap::iterator iter = sTouchDelegateMap.find(pJSObj); if (iter != sTouchDelegateMap.end()) { pRet = iter->second; } return pRet; } void JSTouchDelegate::removeDelegateForJSObject(JSObject* pJSObj) { TouchDelegateMap::iterator iter = sTouchDelegateMap.find(pJSObj); CCASSERT(iter != sTouchDelegateMap.end(), ""); sTouchDelegateMap.erase(pJSObj); } void JSTouchDelegate::setJSObject(JSObject *obj) { _obj = obj; js_proxy_t *p = jsb_get_js_proxy(_obj); if (!p) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddNamedObjectRoot(cx, &_obj, "JSB_TouchDelegateTarget, target"); _needUnroot = true; } } void JSTouchDelegate::registerStandardDelegate(int priority) { auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->removeEventListener(_touchListenerAllAtOnce); auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = CC_CALLBACK_2(JSTouchDelegate::onTouchesBegan, this); listener->onTouchesMoved = CC_CALLBACK_2(JSTouchDelegate::onTouchesMoved, this); listener->onTouchesEnded = CC_CALLBACK_2(JSTouchDelegate::onTouchesEnded, this); listener->onTouchesCancelled = CC_CALLBACK_2(JSTouchDelegate::onTouchesCancelled, this); dispatcher->addEventListenerWithFixedPriority(listener, priority); _touchListenerAllAtOnce = listener; } void JSTouchDelegate::registerTargetedDelegate(int priority, bool swallowsTouches) { auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->removeEventListener(_touchListenerOneByOne); auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(swallowsTouches); listener->onTouchBegan = CC_CALLBACK_2(JSTouchDelegate::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(JSTouchDelegate::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(JSTouchDelegate::onTouchEnded, this); listener->onTouchCancelled = CC_CALLBACK_2(JSTouchDelegate::onTouchCancelled, this); dispatcher->addEventListenerWithFixedPriority(listener, priority); _touchListenerOneByOne = listener; } void JSTouchDelegate::unregisterTouchDelegate() { if (_needUnroot) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &_obj); } auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->removeEventListener(_touchListenerAllAtOnce); dispatcher->removeEventListener(_touchListenerOneByOne); this->release(); } bool JSTouchDelegate::onTouchBegan(Touch *touch, Event *event) { CC_UNUSED_PARAM(event); jsval retval; bool bRet = false; ScriptingCore::getInstance()->executeCustomTouchEvent(EventTouch::EventCode::BEGAN, touch, _obj, retval); if(JSVAL_IS_BOOLEAN(retval)) { bRet = JSVAL_TO_BOOLEAN(retval); } return bRet; }; // optional void JSTouchDelegate::onTouchMoved(Touch *touch, Event *event) { CC_UNUSED_PARAM(event); ScriptingCore::getInstance()->executeCustomTouchEvent(EventTouch::EventCode::MOVED, touch, _obj); } void JSTouchDelegate::onTouchEnded(Touch *touch, Event *event) { CC_UNUSED_PARAM(event); ScriptingCore::getInstance()->executeCustomTouchEvent(EventTouch::EventCode::ENDED, touch, _obj); } void JSTouchDelegate::onTouchCancelled(Touch *touch, Event *event) { CC_UNUSED_PARAM(event); ScriptingCore::getInstance()->executeCustomTouchEvent(EventTouch::EventCode::CANCELLED, touch, _obj); } // optional void JSTouchDelegate::onTouchesBegan(const std::vector& touches, Event *event) { CC_UNUSED_PARAM(event); ScriptingCore::getInstance()->executeCustomTouchesEvent(EventTouch::EventCode::BEGAN, touches, _obj); } void JSTouchDelegate::onTouchesMoved(const std::vector& touches, Event *event) { CC_UNUSED_PARAM(event); ScriptingCore::getInstance()->executeCustomTouchesEvent(EventTouch::EventCode::MOVED, touches, _obj); } void JSTouchDelegate::onTouchesEnded(const std::vector& touches, Event *event) { CC_UNUSED_PARAM(event); ScriptingCore::getInstance()->executeCustomTouchesEvent(EventTouch::EventCode::ENDED, touches, _obj); } void JSTouchDelegate::onTouchesCancelled(const std::vector& touches, Event *event) { CC_UNUSED_PARAM(event); ScriptingCore::getInstance()->executeCustomTouchesEvent(EventTouch::EventCode::CANCELLED, touches, _obj); } static void addCallBackAndThis(JSObject *obj, jsval callback, jsval &thisObj) { if(callback != JSVAL_VOID) { ScriptingCore::getInstance()->setReservedSpot(0, obj, callback); } if(thisObj != JSVAL_VOID) { ScriptingCore::getInstance()->setReservedSpot(1, obj, thisObj); } } template JSObject* bind_menu_item(JSContext *cx, T* nativeObj, jsval callback, jsval thisObj) { js_proxy_t *p = jsb_get_native_proxy(nativeObj); if (p) { addCallBackAndThis(p->obj, callback, thisObj); return p->obj; } else { js_type_class_t *classType = js_get_type_from_native(nativeObj); assert(classType); JSObject *tmp = JS_NewObject(cx, classType->jsclass, classType->proto, classType->parentProto); // bind nativeObj <-> JSObject js_proxy_t *proxy = jsb_new_proxy(nativeObj, tmp); JS_AddNamedObjectRoot(cx, &proxy->obj, typeid(*nativeObj).name()); addCallBackAndThis(tmp, callback, thisObj); return tmp; } } JSBool js_cocos2dx_CCMenu_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); if (argc > 0) { Vector items; uint32_t i = 0; while (i < argc) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); proxy = jsb_get_js_proxy(tmpObj); cocos2d::MenuItem *item = (cocos2d::MenuItem*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) items.pushBack(item); i++; } cocos2d::Menu* ret = cocos2d::Menu::createWithArray(items); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 0) { cocos2d::Menu* ret = cocos2d::Menu::create(); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_CCSequence_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); if (argc > 0) { Vector array; if (argc == 1 && JS_IsArrayObject(cx, JSVAL_TO_OBJECT(argv[0]))) { JSBool ok = JS_TRUE; ok &= jsval_to_ccvector(cx, argv[0], &array); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); } else { uint32_t i = 0; while (i < argc) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); proxy = jsb_get_js_proxy(tmpObj); cocos2d::FiniteTimeAction *item = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) array.pushBack(item); i++; } } cocos2d::FiniteTimeAction* ret = cocos2d::Sequence::create(array); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_CCSpawn_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); if (argc > 0) { Vector array; if (argc == 1 && JS_IsArrayObject(cx, JSVAL_TO_OBJECT(argv[0]))) { JSBool ok = JS_TRUE; ok &= jsval_to_ccvector(cx, argv[0], &array); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); } else { uint32_t i = 0; while (i < argc) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); proxy = jsb_get_js_proxy(tmpObj); cocos2d::FiniteTimeAction *item = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) array.pushBack(item); i++; } } cocos2d::FiniteTimeAction* ret = cocos2d::Spawn::create(array); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_CCMenuItem_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { jsval *argv = JS_ARGV(cx, vp); cocos2d::MenuItem* ret = cocos2d::MenuItem::create(); JSObject *obj = bind_menu_item(cx, ret, argv[0], argc == 2? argv[1] : JSVAL_VOID); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } // "create" in JS // cc.MenuItemSprite.create( normalSprite, selectedSprite, [disabledSprite], [callback_fn], [this] JSBool js_cocos2dx_CCMenuItemSprite_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 2 && argc <= 5) { jsval *argv = JS_ARGV(cx, vp); js_proxy_t *proxy; JSObject *tmpObj; tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); cocos2d::Node* arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg0); tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); cocos2d::Node* arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1); int last = 2; JSBool thirdArgIsCallback = JS_FALSE; jsval jsCallback = JSVAL_VOID; jsval jsThis = JSVAL_VOID; cocos2d::Node* arg2 = NULL; if (argc >= 3) { tmpObj = JSVAL_TO_OBJECT(argv[2]); thirdArgIsCallback = JS_ObjectIsFunction(cx, tmpObj); if (!thirdArgIsCallback) { proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg2); last = 3; } } cocos2d::MenuItemSprite* ret = cocos2d::MenuItemSprite::create(arg0, arg1, arg2); if (argc >= 3) { if (thirdArgIsCallback) { //cc.MenuItemSprite.create( normalSprite, selectedSprite, callback_fn, [this] ) jsCallback = argv[last++]; if (argc == 4) { jsThis = argv[last]; } } else { //cc.MenuItemSprite.create( normalSprite, selectedSprite, disabledSprite, callback_fn, [this] ) if (argc >= 4) { jsCallback = argv[last++]; if (argc == 5) { jsThis = argv[last]; } } } } JSObject *obj = bind_menu_item(cx, ret, jsCallback, jsThis); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments. Expecting: 2 <= args <= 5"); return JS_FALSE; } // "create" in JS // cc.MenuItemImage.create( normalImage, selectedImage, [disabledImage], callback_fn, [this] JSBool js_cocos2dx_CCMenuItemImage_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 2 && argc <= 5) { jsval *argv = JS_ARGV(cx, vp); JSStringWrapper arg0(argv[0]); JSStringWrapper arg1(argv[1]); JSStringWrapper arg2; bool thirdArgIsString = true; jsval jsCallback = JSVAL_VOID; jsval jsThis = JSVAL_VOID; int last = 2; if (argc >= 3) { thirdArgIsString = argv[2].isString(); if (thirdArgIsString) { arg2.set(argv[2], cx); last = 3; } } cocos2d::MenuItemImage* ret = cocos2d::MenuItemImage::create(arg0.get(), arg1.get(), std::string(arg2.get())); if (argc >= 3) { if (!thirdArgIsString) { //cc.MenuItemImage.create( normalImage, selectedImage, callback_fn, [this] ) jsCallback = argv[last++]; if (argc == 4) { jsThis = argv[last]; } } else { //cc.MenuItemImage.create( normalImage, selectedImage, disabledImage, callback_fn, [this] ) if (argc >= 4) { jsCallback = argv[last++]; if (argc == 5) { jsThis = argv[last]; } } } } JSObject *obj = bind_menu_item(cx, ret, jsCallback, jsThis); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments. Expecting: 2 <= args <= 5"); return JS_FALSE; } // "create" in JS: // cc.MenuItemLabel.create( label, callback_fn, [this] ); JSBool js_cocos2dx_CCMenuItemLabel_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1 && argc <= 3) { jsval *argv = JS_ARGV(cx, vp); js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); cocos2d::Node* arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg0) cocos2d::MenuItemLabel* ret = cocos2d::MenuItemLabel::create(arg0); JSObject *obj = bind_menu_item(cx, ret, (argc >= 2 ? argv[1] : JSVAL_VOID), (argc == 3 ? argv[2] : JSVAL_VOID) ); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d or %d or %d", argc, 1, 2, 3); return JS_FALSE; } JSBool js_cocos2dx_CCMenuItemAtlasFont_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 5) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); JSStringWrapper arg0(argv[0]); JSStringWrapper arg1(argv[1]); int arg2; ok &= jsval_to_int32(cx, argv[2], &arg2); int arg3; ok &= jsval_to_int32(cx, argv[3], &arg3); int arg4; ok &= jsval_to_int32(cx, argv[4], &arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::MenuItemAtlasFont* ret = cocos2d::MenuItemAtlasFont::create(arg0.get(), arg1.get(), arg2, arg3, arg4); JSObject *obj = bind_menu_item(cx, ret, (argc >= 6 ? argv[5] : JSVAL_VOID), (argc == 7 ? argv[6] : JSVAL_VOID)); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } // "create" in JS // cc.MenuItemFont.create( string, callback_fn, [this] ); JSBool js_cocos2dx_CCMenuItemFont_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1 && argc <= 3) { jsval *argv = JS_ARGV(cx, vp); JSStringWrapper arg0(argv[0]); cocos2d::MenuItemFont* ret = cocos2d::MenuItemFont::create(arg0.get()); JSObject *obj = bind_menu_item(cx, ret, (argc >= 2 ? argv[1] : JSVAL_VOID), (argc == 3 ? argv[2] : JSVAL_VOID)); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d or %d or %d", argc, 1, 2, 3); return JS_FALSE; } JSBool js_cocos2dx_CCMenuItemToggle_create(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { jsval *argv = JS_ARGV(cx, vp); cocos2d::MenuItemToggle* ret = cocos2d::MenuItemToggle::create(); for (uint32_t i=0; i < argc; i++) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); proxy = jsb_get_js_proxy(tmpObj); cocos2d::MenuItem* item = (cocos2d::MenuItem*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) ret->addSubItem(item); } ret->setSelectedIndex(0); jsval jsret; if (ret) { js_proxy_t *proxy = jsb_get_native_proxy(ret); if (proxy) { jsret = OBJECT_TO_JSVAL(proxy->obj); } else { // create a new js obj of that class proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } // "setCallback" in JS // item.setCallback( callback_fn, [this]); template JSBool js_cocos2dx_setCallback(JSContext *cx, uint32_t argc, jsval *vp) { if(argc == 1 || argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); jsval jsThis = JSVAL_VOID; jsval jsFunc = argv[0]; if (jsFunc.isUndefined()) { JS_ReportError(cx, "The callback function is undefined."); return JS_FALSE; } if (argc == 2) { jsThis = argv[1]; } js_proxy_t *proxy = jsb_get_js_proxy(obj); T* item = (T*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, item) bind_menu_item(cx, item, jsFunc, jsThis); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d or %d", argc, 1, 2); return JS_FALSE; } JSBool js_cocos2dx_CCMenuItem_setCallback(JSContext *cx, uint32_t argc, jsval *vp) { return js_cocos2dx_setCallback(cx, argc, vp); } JSBool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc <= 3) { cocos2d::Animation* ret = nullptr; double arg1 = 0.0f; if (argc == 2) { Vector arg0; if (argc > 0) { ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); } ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); ret = cocos2d::Animation::createWithSpriteFrames(arg0, arg1); } else if (argc == 3) { Vector arg0; if (argc > 0) { ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); } unsigned int loops; ok &= JS_ValueToNumber(cx, argv[1], &arg1); ok &= jsval_to_uint32(cx, argv[2], &loops); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); ret = cocos2d::Animation::create(arg0, arg1, loops); } else if (argc == 1) { Vector arg0; if (argc > 0) { ok &= jsval_to_ccvector(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); } ret = cocos2d::Animation::createWithSpriteFrames(arg0); } else if (argc == 0) { ret = cocos2d::Animation::create(); } jsval jsret; if (ret) { js_proxy_t *proxy = jsb_get_native_proxy(ret); if (proxy) { jsret = OBJECT_TO_JSVAL(proxy->obj); } else { // create a new js obj of that class proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_CCLayerMultiplex_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); Vector arg0; JSBool ok = JS_TRUE; ok &= jsvals_variadic_to_ccvector(cx, argv, argc, &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::LayerMultiplex* ret = cocos2d::LayerMultiplex::createWithArray(arg0); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JSBool js_cocos2dx_JSTouchDelegate_registerStandardDelegate(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 1 || argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSObject* jsobj = NULL; JSTouchDelegate *touch = new JSTouchDelegate(); int priority = 1; if (argc == 2) { priority = JSVAL_TO_INT(argv[1]); } touch->registerStandardDelegate(priority); jsobj = JSVAL_TO_OBJECT(argv[0]); touch->setJSObject(jsobj); JSTouchDelegate::setDelegateForJSObject(jsobj, touch); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_JSTouchDelegate_registerTargetedDelegate(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 3) { jsval *argv = JS_ARGV(cx, vp); JSObject* jsobj = NULL; JSTouchDelegate *touch = new JSTouchDelegate(); touch->registerTargetedDelegate(JSVAL_TO_INT(argv[0]), JSVAL_TO_BOOLEAN(argv[1])); jsobj = JSVAL_TO_OBJECT(argv[2]); touch->setJSObject(jsobj); JSTouchDelegate::setDelegateForJSObject(jsobj, touch); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_JSTouchDelegate_unregisterTouchDelegate(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 1) { jsval *argv = JS_ARGV(cx, vp); JSObject* jsobj = JSVAL_TO_OBJECT(argv[0]); JSTouchDelegate* pDelegate = JSTouchDelegate::getDelegateForJSObject(jsobj); if (pDelegate) { pDelegate->unregisterTouchDelegate(); JSTouchDelegate::removeDelegateForJSObject(jsobj); } return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_swap_native_object(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 2) { // get the native object from the second object to the first object jsval *argv = JS_ARGV(cx, vp); JSObject *one = JSVAL_TO_OBJECT(argv[0]); JSObject *two = JSVAL_TO_OBJECT(argv[1]); js_proxy_t *jsproxy = jsb_get_js_proxy(two); void *ptrTwo = (jsproxy ? jsproxy->ptr : NULL); if (jsproxy) { js_proxy_t *nproxy = jsb_get_native_proxy(ptrTwo); if (nproxy) { JS_RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(nproxy, jsproxy); jsproxy = jsb_new_proxy(ptrTwo, one); JS_AddNamedObjectRoot(cx, &jsproxy->obj, typeid(*((Object*)jsproxy->ptr)).name()); } } } return JS_TRUE; } JSObject* getObjectFromNamespace(JSContext* cx, JSObject *ns, const char *name) { JS::RootedValue out(cx); JSBool ok = JS_TRUE; if (JS_GetProperty(cx, ns, name, &out) == JS_TRUE) { JSObject *obj; ok &= JS_ValueToObject(cx, out, &obj); JSB_PRECONDITION2(ok, cx, NULL, "Error processing arguments"); } return NULL; } jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string) { jsval out; if (JS_EvaluateScript(cx, thisObj, string, strlen(string), "(string)", 1, &out) == JS_TRUE) { return out; } return JSVAL_VOID; } JSBool js_platform(JSContext *cx, uint32_t argc, jsval *vp) { JSString *str = JS_NewStringCopyZ(cx, "mobile"); jsval out = STRING_TO_JSVAL(str); JS_SET_RVAL(cx, vp, out); return JS_TRUE; } JSCallbackWrapper::JSCallbackWrapper() : _jsCallback(JSVAL_VOID), _jsThisObj(JSVAL_VOID), _extraData(JSVAL_VOID) { } JSCallbackWrapper::~JSCallbackWrapper() { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveValueRoot(cx, &_jsCallback); } void JSCallbackWrapper::setJSCallbackFunc(jsval func) { _jsCallback = func; JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); // Root the callback function. JS_AddNamedValueRoot(cx, &_jsCallback, "JSCallbackWrapper_callback_func"); } void JSCallbackWrapper::setJSCallbackThis(jsval thisObj) { _jsThisObj = thisObj; } void JSCallbackWrapper::setJSExtraData(jsval data) { _extraData = data; } const jsval& JSCallbackWrapper::getJSCallbackFunc() const { return _jsCallback; } const jsval& JSCallbackWrapper::getJSCallbackThis() const { return _jsThisObj; } const jsval& JSCallbackWrapper::getJSExtraData() const { return _extraData; } // cc.CallFunc.create( func, this, [data]) // cc.CallFunc.create( func ) static JSBool js_callFunc(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1 && argc <= 3) { jsval *argv = JS_ARGV(cx, vp); std::shared_ptr tmpCobj(new JSCallbackWrapper()); tmpCobj->setJSCallbackFunc(argv[0]); if(argc >= 2) { tmpCobj->setJSCallbackThis(argv[1]); } if(argc == 3) { tmpCobj->setJSExtraData(argv[2]); } CallFuncN *ret = CallFuncN::create([=](Node* sender){ const jsval& jsvalThis = tmpCobj->getJSCallbackThis(); const jsval& jsvalCallback = tmpCobj->getJSCallbackFunc(); const jsval& jsvalExtraData = tmpCobj->getJSExtraData(); bool hasExtraData = !JSVAL_IS_VOID(jsvalExtraData); JSObject* thisObj = JSVAL_IS_VOID(jsvalThis) ? nullptr : JSVAL_TO_OBJECT(jsvalThis); JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET js_proxy_t *proxy = js_get_or_create_proxy(cx, sender); jsval retval; if(jsvalCallback != JSVAL_VOID) { if (hasExtraData) { jsval valArr[2]; valArr[0] = OBJECT_TO_JSVAL(proxy->obj); valArr[1] = jsvalExtraData; JS_AddValueRoot(cx, valArr); JS_CallFunctionValue(cx, thisObj, jsvalCallback, 2, valArr, &retval); JS_RemoveValueRoot(cx, valArr); } else { jsval senderVal = OBJECT_TO_JSVAL(proxy->obj); JS_AddValueRoot(cx, &senderVal); JS_CallFunctionValue(cx, thisObj, jsvalCallback, 1, &senderVal, &retval); JS_RemoveValueRoot(cx, &senderVal); } } // I think the JSCallFuncWrapper isn't needed. // Since an action will be run by a cc.Node, it will be released at the Node::cleanup. // By James Chen // JSCallFuncWrapper::setTargetForNativeNode(node, (JSCallFuncWrapper *)this); }); js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(proxy->obj)); JS_SetReservedSlot(proxy->obj, 0, argv[0]); if(argc > 1) { JS_SetReservedSlot(proxy->obj, 1, argv[1]); } // if(argc == 3) { // JS_SetReservedSlot(proxy->obj, 2, argv[2]); // } // test->execute(); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } JSScheduleWrapper::~JSScheduleWrapper() { if (_pPureJSTarget) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &_pPureJSTarget); } } void JSScheduleWrapper::setTargetForSchedule(jsval sched, JSScheduleWrapper *target) { do { JSObject* jsfunc = JSVAL_TO_OBJECT(sched); Array* targetArray = getTargetForSchedule(sched); if (NULL == targetArray) { targetArray = new Array(); targetArray->init(); schedFunc_proxy_t *p = (schedFunc_proxy_t *)malloc(sizeof(schedFunc_proxy_t)); assert(p); p->jsfuncObj = jsfunc; p->targets = targetArray; HASH_ADD_PTR(_schedFunc_target_ht, jsfuncObj, p); } CCASSERT(!targetArray->containsObject(target), "The target was already added."); targetArray->addObject(target); } while(0); } Array * JSScheduleWrapper::getTargetForSchedule(jsval sched) { schedFunc_proxy_t *t = NULL; JSObject *o = JSVAL_TO_OBJECT(sched); HASH_FIND_PTR(_schedFunc_target_ht, &o, t); return t != NULL ? t->targets : NULL; } void JSScheduleWrapper::setTargetForJSObject(JSObject* jsTargetObj, JSScheduleWrapper *target) { Array* targetArray = getTargetForJSObject(jsTargetObj); if (NULL == targetArray) { targetArray = new Array(); targetArray->init(); schedTarget_proxy_t *p = (schedTarget_proxy_t *)malloc(sizeof(schedTarget_proxy_t)); assert(p); p->jsTargetObj = jsTargetObj; p->targets = targetArray; HASH_ADD_PTR(_schedObj_target_ht, jsTargetObj, p); } CCASSERT(!targetArray->containsObject(target), "The target was already added."); targetArray->addObject(target); } Array * JSScheduleWrapper::getTargetForJSObject(JSObject* jsTargetObj) { schedTarget_proxy_t *t = NULL; HASH_FIND_PTR(_schedObj_target_ht, &jsTargetObj, t); return t != NULL ? t->targets : NULL; } void JSScheduleWrapper::removeAllTargets() { CCLOGINFO("removeAllTargets begin"); dump(); { schedFunc_proxy_t *current, *tmp; HASH_ITER(hh, _schedFunc_target_ht, current, tmp) { current->targets->removeAllObjects(); current->targets->release(); HASH_DEL(_schedFunc_target_ht, current); free(current); } } { schedTarget_proxy_t *current, *tmp; HASH_ITER(hh, _schedObj_target_ht, current, tmp) { current->targets->removeAllObjects(); current->targets->release(); HASH_DEL(_schedObj_target_ht, current); free(current); } } dump(); CCLOGINFO("removeAllTargets end"); } void JSScheduleWrapper::removeAllTargetsForMinPriority(int minPriority) { CCLOGINFO("removeAllTargetsForPriority begin"); dump(); { schedFunc_proxy_t *current, *tmp; HASH_ITER(hh, _schedFunc_target_ht, current, tmp) { std::vector objectsNeedToBeReleased; Array* targets = current->targets; Object* pObj = NULL; CCARRAY_FOREACH(targets, pObj) { JSScheduleWrapper* wrapper = static_cast(pObj); bool isUpdateSchedule = wrapper->isUpdateSchedule(); if (!isUpdateSchedule || (isUpdateSchedule && wrapper->getPriority() >= minPriority)) { objectsNeedToBeReleased.push_back(pObj); } } std::vector::iterator iter = objectsNeedToBeReleased.begin(); for (; iter != objectsNeedToBeReleased.end(); ++iter) { targets->removeObject(*iter, true); } if (targets->count() == 0) { HASH_DEL(_schedFunc_target_ht, current); targets->release(); free(current); } } } { schedTarget_proxy_t *current, *tmp; HASH_ITER(hh, _schedObj_target_ht, current, tmp) { std::vector objectsNeedToBeReleased; Array* targets = current->targets; Object* pObj = NULL; CCARRAY_FOREACH(targets, pObj) { JSScheduleWrapper* wrapper = static_cast(pObj); bool isUpdateSchedule = wrapper->isUpdateSchedule(); if (!isUpdateSchedule || (isUpdateSchedule && wrapper->getPriority() >= minPriority)) { CCLOG("isUpdateSchedule2:%d", isUpdateSchedule); objectsNeedToBeReleased.push_back(pObj); } } auto iter = objectsNeedToBeReleased.begin(); for (; iter != objectsNeedToBeReleased.end(); ++iter) { targets->removeObject(*iter, true); } if (targets->count() == 0) { HASH_DEL(_schedObj_target_ht, current); targets->release(); free(current); } } } dump(); CCLOGINFO("removeAllTargetsForPriority end"); } void JSScheduleWrapper::removeAllTargetsForJSObject(JSObject* jsTargetObj) { CCLOGINFO("removeAllTargetsForNatiaveNode begin"); dump(); Array* removeNativeTargets = NULL; schedTarget_proxy_t *t = NULL; HASH_FIND_PTR(_schedObj_target_ht, &jsTargetObj, t); if (t != NULL) { removeNativeTargets = t->targets; HASH_DEL(_schedObj_target_ht, t); } if (removeNativeTargets == NULL) return; schedFunc_proxy_t *current, *tmp; HASH_ITER(hh, _schedFunc_target_ht, current, tmp) { std::vector objectsNeedToBeReleased; Array* targets = current->targets; Object* pObj = NULL; CCARRAY_FOREACH(targets, pObj) { if (removeNativeTargets->containsObject(pObj)) { objectsNeedToBeReleased.push_back(pObj); } } auto iter = objectsNeedToBeReleased.begin(); for (; iter != objectsNeedToBeReleased.end(); ++iter) { targets->removeObject(*iter, true); } if (targets->count() == 0) { HASH_DEL(_schedFunc_target_ht, current); targets->release(); free(current); } } removeNativeTargets->removeAllObjects(); removeNativeTargets->release(); free(t); dump(); CCLOGINFO("removeAllTargetsForNatiaveNode end"); } void JSScheduleWrapper::removeTargetForJSObject(JSObject* jsTargetObj, JSScheduleWrapper* target) { CCLOGINFO("removeTargetForJSObject begin"); dump(); schedTarget_proxy_t *t = NULL; HASH_FIND_PTR(_schedObj_target_ht, &jsTargetObj, t); if (t != NULL) { t->targets->removeObject(target); if (t->targets->count() == 0) { t->targets->release(); HASH_DEL(_schedObj_target_ht, t); free(t); } } schedFunc_proxy_t *current, *tmp, *removed=NULL; HASH_ITER(hh, _schedFunc_target_ht, current, tmp) { Array* targets = current->targets; Object* pObj = NULL; CCARRAY_FOREACH(targets, pObj) { JSScheduleWrapper* pOneTarget = static_cast(pObj); if (pOneTarget == target) { removed = current; break; } } if (removed) break; } if (removed) { removed->targets->removeObject(target); if (removed->targets->count() == 0) { removed->targets->release(); HASH_DEL(_schedFunc_target_ht, removed); free(removed); } } dump(); CCLOGINFO("removeTargetForJSObject end"); } void JSScheduleWrapper::dump() { #if COCOS2D_DEBUG > 1 CCLOG("\n---------JSScheduleWrapper dump begin--------------\n"); CCLOG("target hash count = %d, func hash count = %d", HASH_COUNT(_schedObj_target_ht), HASH_COUNT(_schedFunc_target_ht)); schedTarget_proxy_t *current, *tmp; int nativeTargetsCount = 0; HASH_ITER(hh, _schedObj_target_ht, current, tmp) { Object* pObj = NULL; CCARRAY_FOREACH(current->targets, pObj) { CCLOG("js target ( %p ), native target[%d]=( %p )", current->jsTargetObj, nativeTargetsCount, pObj); nativeTargetsCount++; } } CCLOG("\n-----------------------------\n"); schedFunc_proxy_t *current_func, *tmp_func; int jsfuncTargetCount = 0; HASH_ITER(hh, _schedFunc_target_ht, current_func, tmp_func) { Object* pObj = NULL; CCARRAY_FOREACH(current_func->targets, pObj) { CCLOG("js func ( %p ), native target[%d]=( %p )", current_func->jsfuncObj, jsfuncTargetCount, pObj); jsfuncTargetCount++; } } CCASSERT(nativeTargetsCount == jsfuncTargetCount, ""); CCLOG("\n---------JSScheduleWrapper dump end--------------\n"); #endif } void JSScheduleWrapper::scheduleFunc(float dt) { jsval retval = JSVAL_NULL; jsval data = DOUBLE_TO_JSVAL(dt); JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSBool ok = JS_AddValueRoot(cx, &data); if (!ok) { CCLOG("scheduleFunc: Root value fails."); return; } JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET if(!_jsCallback.isNullOrUndefined()) { if (!_jsThisObj.isNullOrUndefined()) { JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(_jsThisObj), _jsCallback, 1, &data, &retval); } else { JS_CallFunctionValue(cx, NULL, _jsCallback, 1, &data, &retval); } } JS_RemoveValueRoot(cx, &data); } void JSScheduleWrapper::update(float dt) { jsval data = DOUBLE_TO_JSVAL(dt); JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSBool ok = JS_AddValueRoot(cx, &data); if (!ok) { CCLOG("scheduleFunc: Root value fails."); return; } ScriptingCore::getInstance()->executeFunctionWithOwner(_jsThisObj, "update", 1, &data); JS_RemoveValueRoot(cx, &data); } Object* JSScheduleWrapper::getTarget() { return _pTarget; } void JSScheduleWrapper::setTarget(Object* pTarget) { _pTarget = pTarget; } void JSScheduleWrapper::setPureJSTarget(JSObject* pPureJSTarget) { CCASSERT(_pPureJSTarget == NULL, "The pure js target has been set"); JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); _pPureJSTarget = pPureJSTarget; JS_AddNamedObjectRoot(cx, &_pPureJSTarget, "Pure JS target"); } JSObject* JSScheduleWrapper::getPureJSTarget() { return _pPureJSTarget; } void JSScheduleWrapper::setPriority(int priority) { _priority = priority; } int JSScheduleWrapper::getPriority() { return _priority; } void JSScheduleWrapper::setUpdateSchedule(bool isUpdateSchedule) { _isUpdateSchedule = isUpdateSchedule; } bool JSScheduleWrapper::isUpdateSchedule() { return _isUpdateSchedule; } JSBool js_CCNode_unschedule(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 1) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node *node = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2(node, cx, JS_FALSE, "Invalid Native Object"); Scheduler *sched = node->getScheduler(); Array* targetArray = JSScheduleWrapper::getTargetForSchedule(argv[0]); CCLOGINFO("unschedule target number: %d", targetArray->count()); Object* tmp = NULL; CCARRAY_FOREACH(targetArray, tmp) { JSScheduleWrapper* target = static_cast(tmp); if (node == target->getTarget()) { sched->unscheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), target); JSScheduleWrapper::removeTargetForJSObject(obj, target); break; } } JS_SET_RVAL(cx, vp, JSVAL_VOID); } return JS_TRUE; } JSBool js_cocos2dx_CCNode_unscheduleAllSelectors(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 0) { cobj->unscheduleAllSelectors(); Array *arr = JSScheduleWrapper::getTargetForJSObject(obj); // If there aren't any targets, just return true. // Otherwise, the for loop will break immediately. // It will lead to logic errors. // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. if(! arr) return JS_TRUE; JSScheduleWrapper* wrapper = NULL; for(unsigned int i = 0; i < arr->count(); ++i) { wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); if(wrapper) { cobj->getScheduler()->unscheduleAllForTarget(wrapper); } } JSScheduleWrapper::removeAllTargetsForJSObject(obj); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_CCNode_scheduleOnce(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node *node = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); Scheduler *sched = node->getScheduler(); JSScheduleWrapper *tmpCobj = NULL; // // delay // double delay; if( argc >= 2 ) { ok &= JS_ValueToNumber(cx, argv[1], &delay ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); } bool bFound = false; Array* pTargetArr = JSScheduleWrapper::getTargetForJSObject(obj); Object* pObj = NULL; CCARRAY_FOREACH(pTargetArr, pObj) { JSScheduleWrapper* pTarget = static_cast(pObj); if (argv[0] == pTarget->getJSCallbackFunc()) { tmpCobj = pTarget; bFound = true; break; } } if (!bFound) { tmpCobj = new JSScheduleWrapper(); tmpCobj->autorelease(); tmpCobj->setJSCallbackThis(OBJECT_TO_JSVAL(obj)); tmpCobj->setJSCallbackFunc(argv[0]); tmpCobj->setTarget(node); JSScheduleWrapper::setTargetForSchedule(argv[0], tmpCobj); JSScheduleWrapper::setTargetForJSObject(obj, tmpCobj); } if(argc == 1) { sched->scheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, 0, 0, 0.0f, !node->isRunning()); } else { sched->scheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, 0, 0, delay, !node->isRunning()); } /* We shouldn't set the js callback function to reserved slot, since the target object may execute more than one schedule. Therefore, previous js callback function will be replaced by the current one. For example: this.scheduleOnce(function() { temporary function 1 }, 0.5); this.scheduleOnce(function() { temporary function 2 }, 0.5); In this case, the temporary function 1 will be removed from reserved slot 0. And temporary function 2 will be set to reserved slot 0 of this object. If gc is triggered before the 'JSScheduleWrapper::scheduleFunc' is invoked, crash will happen. You could simply reproduce it by adding '__jsc__.garbageCollect();' after scheduleOnce. [Solution] Because one schedule corresponds to one JSScheduleWrapper, we root the js callback function in JSScheduleWrapper::setJSCallbackFunc and unroot it at the destructor of JSScheduleWrapper. */ //jsb_set_reserved_slot(proxy->obj, 0, argv[0]); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node *node = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); Scheduler *sched = node->getScheduler(); JSScheduleWrapper *tmpCobj = NULL; double interval = 0.0; if( argc >= 2 ) { ok &= JS_ValueToNumber(cx, argv[1], &interval ); } // // repeat // double repeat = 0.0; if( argc >= 3 ) { ok &= JS_ValueToNumber(cx, argv[2], &repeat ); } // // delay // double delay = 0.0; if( argc >= 4 ) { ok &= JS_ValueToNumber(cx, argv[3], &delay ); } JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); bool bFound = false; Array* pTargetArr = JSScheduleWrapper::getTargetForJSObject(obj); Object* pObj = NULL; CCARRAY_FOREACH(pTargetArr, pObj) { JSScheduleWrapper* pTarget = static_cast(pObj); if (argv[0] == pTarget->getJSCallbackFunc()) { tmpCobj = pTarget; bFound = true; break; } } if (!bFound) { tmpCobj = new JSScheduleWrapper(); tmpCobj->autorelease(); tmpCobj->setJSCallbackThis(OBJECT_TO_JSVAL(obj)); tmpCobj->setJSCallbackFunc(argv[0]); tmpCobj->setTarget(node); JSScheduleWrapper::setTargetForSchedule(argv[0], tmpCobj); JSScheduleWrapper::setTargetForJSObject(obj, tmpCobj); } if(argc == 1) { sched->scheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, 0, !node->isRunning()); } if(argc == 2) { sched->scheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, interval, !node->isRunning()); } if(argc == 3) { sched->scheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, interval, (unsigned int)repeat, 0, !node->isRunning()); } if (argc == 4) { sched->scheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, interval, (unsigned int)repeat, delay, !node->isRunning()); } // I comment next line with the same reason in the js_CCNode_scheduleOnce. //jsb_set_reserved_slot(proxy->obj, 0, argv[0]); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_CCNode_scheduleUpdateWithPriority(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { int arg0 = 0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); JSBool isFoundUpdate = JS_FALSE; ok = JS_HasProperty(cx, obj, "update", &isFoundUpdate); JS::RootedValue jsUpdateFunc(cx); if (ok && isFoundUpdate) { ok = JS_GetProperty(cx, obj, "update", &jsUpdateFunc); } // if no 'update' property, return JS_TRUE directly. if (!ok) { JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSScheduleWrapper* tmpCobj = NULL; bool bFound = false; Array* pTargetArr = JSScheduleWrapper::getTargetForJSObject(obj); Object* pObj = NULL; CCARRAY_FOREACH(pTargetArr, pObj) { JSScheduleWrapper* pTarget = static_cast(pObj); if (jsUpdateFunc == pTarget->getJSCallbackFunc()) { tmpCobj = pTarget; bFound = true; break; } } if (!bFound) { tmpCobj = new JSScheduleWrapper(); tmpCobj->autorelease(); tmpCobj->setJSCallbackThis(OBJECT_TO_JSVAL(obj)); tmpCobj->setJSCallbackFunc(jsUpdateFunc); tmpCobj->setTarget(cobj); tmpCobj->setUpdateSchedule(true); JSScheduleWrapper::setTargetForSchedule(jsUpdateFunc, tmpCobj); JSScheduleWrapper::setTargetForJSObject(obj, tmpCobj); } tmpCobj->setPriority(arg0); cobj->getScheduler()->scheduleUpdateForTarget(tmpCobj, arg0, !cobj->isRunning()); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCNode_unscheduleUpdate(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 0) { cobj->unscheduleUpdate(); do { JSObject *tmpObj = obj; Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); // If there aren't any targets, just return true. // Otherwise, the for loop will break immediately. // It will lead to logic errors. // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. if(! arr) return JS_TRUE; JSScheduleWrapper* wrapper = NULL; for(unsigned int i = 0; i < arr->count(); ++i) { wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); if(wrapper && wrapper->isUpdateSchedule()) { cobj->getScheduler()->unscheduleUpdateForTarget(wrapper); CCASSERT(OBJECT_TO_JSVAL(tmpObj) == wrapper->getJSCallbackThis(), "Wrong target object."); JSScheduleWrapper::removeTargetForJSObject(tmpObj, wrapper); break; } } } while (0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CCNode_scheduleUpdate(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { JSBool isFoundUpdate = JS_FALSE; ok = JS_HasProperty(cx, obj, "update", &isFoundUpdate); JS::RootedValue jsUpdateFunc(cx); if (ok && isFoundUpdate) { ok = JS_GetProperty(cx, obj, "update", &jsUpdateFunc); } // if no 'update' property, return JS_TRUE directly. if (!ok) { JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSScheduleWrapper* tmpCobj = NULL; bool bFound = false; Array* pTargetArr = JSScheduleWrapper::getTargetForJSObject(obj); Object* pObj = NULL; CCARRAY_FOREACH(pTargetArr, pObj) { JSScheduleWrapper* pTarget = static_cast(pObj); if (jsUpdateFunc == pTarget->getJSCallbackFunc()) { tmpCobj = pTarget; bFound = true; break; } } if (!bFound) { tmpCobj = new JSScheduleWrapper(); tmpCobj->autorelease(); tmpCobj->setJSCallbackThis(OBJECT_TO_JSVAL(obj)); tmpCobj->setJSCallbackFunc(jsUpdateFunc); tmpCobj->setTarget(cobj); tmpCobj->setUpdateSchedule(true); JSScheduleWrapper::setTargetForSchedule(jsUpdateFunc, tmpCobj); JSScheduleWrapper::setTargetForJSObject(obj, tmpCobj); } cobj->getScheduler()->scheduleUpdateForTarget(tmpCobj, 0, !cobj->isRunning()); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCScheduler_unscheduleAllSelectorsForTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { do { JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); // If there aren't any targets, just return true. // Otherwise, the for loop will break immediately. // It will lead to logic errors. // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. if(! arr) return JS_TRUE; JSScheduleWrapper* wrapper = NULL; for(unsigned int i = 0; i < arr->count(); ++i) { wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); if(wrapper) { cobj->unscheduleAllForTarget(wrapper); } } JSScheduleWrapper::removeAllTargetsForJSObject(tmpObj); } while (0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_CCScheduler_scheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSScheduleWrapper *tmpCObj = NULL; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); bool isPureJSTarget = proxy ? false : true; JSBool isFoundUpdate = JS_FALSE; ok = JS_HasProperty(cx, tmpObj, "update", &isFoundUpdate); JS::RootedValue jsUpdateFunc(cx); if (ok && isFoundUpdate) { ok = JS_GetProperty(cx, tmpObj, "update", &jsUpdateFunc); } // if no 'update' property, return JS_TRUE directly. if (!ok) { JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } int arg1 = 0; if (argc >= 2) { ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); } JSBool paused = JS_FALSE; if( argc >= 3 ) { ok &= JS_ValueToBoolean(cx, argv[2], &paused); } JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); bool bFound = false; Array* pTargetArr = JSScheduleWrapper::getTargetForJSObject(tmpObj); Object* pObj = NULL; CCARRAY_FOREACH(pTargetArr, pObj) { JSScheduleWrapper* pTarget = static_cast(pObj); if (jsUpdateFunc == pTarget->getJSCallbackFunc()) { tmpCObj = pTarget; bFound = true; break; } } if (!bFound) { tmpCObj = new JSScheduleWrapper(); tmpCObj->autorelease(); tmpCObj->setJSCallbackThis(argv[0]); tmpCObj->setJSCallbackFunc(jsUpdateFunc); tmpCObj->setUpdateSchedule(true); if (isPureJSTarget) { tmpCObj->setPureJSTarget(tmpObj); } JSScheduleWrapper::setTargetForSchedule(jsUpdateFunc, tmpCObj); JSScheduleWrapper::setTargetForJSObject(tmpObj, tmpCObj); } tmpCObj->setPriority(arg1); sched->scheduleUpdateForTarget(tmpCObj, arg1, paused); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_CCScheduler_unscheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { do { JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); // If there aren't any targets, just return true. // Otherwise, the for loop will break immediately. // It will lead to logic errors. // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. if(! arr) return JS_TRUE; JSScheduleWrapper* wrapper = NULL; for(unsigned int i = 0; i < arr->count(); ++i) { wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); if(wrapper && wrapper->isUpdateSchedule()) { cobj->unscheduleUpdateForTarget(wrapper); CCASSERT(argv[0] == wrapper->getJSCallbackThis(), "Wrong target object."); JSScheduleWrapper::removeTargetForJSObject(tmpObj, wrapper); break; } } } while (0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 2) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSScheduleWrapper *tmpCObj = NULL; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); bool isPureJSTarget = proxy ? false : true; double interval = 0; if( argc >= 3 ) { ok &= JS_ValueToNumber(cx, argv[2], &interval ); } // // repeat // double repeat = kRepeatForever; if( argc >= 4 ) { ok &= JS_ValueToNumber(cx, argv[3], &repeat ); } // // delay // double delay = 0; if( argc >= 5 ) { ok &= JS_ValueToNumber(cx, argv[4], &delay ); } JSBool paused = JS_FALSE; if( argc >= 6 ) { ok &= JS_ValueToBoolean(cx, argv[5], &paused); } JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); bool bFound = false; Array* pTargetArr = JSScheduleWrapper::getTargetForJSObject(tmpObj); Object* pObj = NULL; CCARRAY_FOREACH(pTargetArr, pObj) { JSScheduleWrapper* pTarget = static_cast(pObj); if (argv[1] == pTarget->getJSCallbackFunc()) { tmpCObj = pTarget; bFound = true; break; } } if (!bFound) { tmpCObj = new JSScheduleWrapper(); tmpCObj->autorelease(); tmpCObj->setJSCallbackThis(argv[0]); tmpCObj->setJSCallbackFunc(argv[1]); if (isPureJSTarget) { tmpCObj->setPureJSTarget(tmpObj); } JSScheduleWrapper::setTargetForSchedule(argv[1], tmpCObj); JSScheduleWrapper::setTargetForJSObject(tmpObj, tmpCObj); } sched->scheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCObj, interval, repeat, delay, paused); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_CCScheduler_unscheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 2) { do { JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); // If there aren't any targets, just return true. // Otherwise, the for loop will break immediately. // It will lead to logic errors. // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. if(! arr) return JS_TRUE; JSScheduleWrapper* wrapper = NULL; for(unsigned int i = 0; i < arr->count(); ++i) { wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); if(wrapper && wrapper->getJSCallbackFunc() == argv[1]) { cobj->unscheduleSelector(schedule_selector(JSScheduleWrapper::scheduleFunc), wrapper); JSScheduleWrapper::removeTargetForJSObject(tmpObj, wrapper); break; } } } while (0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCScheduler_unscheduleAll(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { cobj->unscheduleAll(); JSScheduleWrapper::removeAllTargets(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCScheduler_unscheduleAllCallbacksWithMinPriority(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->unscheduleAllWithMinPriority(arg0); JSScheduleWrapper::removeAllTargetsForMinPriority(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCScheduler_pauseTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); if (argc == 1) { do { JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); if(! arr) return JS_TRUE; for(unsigned int i = 0; i < arr->count(); ++i) { if(arr->getObjectAtIndex(i)) { sched->pauseTarget(arr->getObjectAtIndex(i)); } } } while (0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCScheduler_resumeTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); if (argc == 1) { do { JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); if(! arr) return JS_TRUE; for(unsigned int i = 0; i < arr->count(); ++i) { if(arr->getObjectAtIndex(i)) { sched->resumeTarget(arr->getObjectAtIndex(i)); } } } while (0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCScheduler_isTargetPaused(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { JSBool ret = JS_FALSE; do { JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); if(! arr) return JS_TRUE; for(unsigned int i = 0; i < arr->count(); ++i) { if(arr->getObjectAtIndex(i)) { ret = cobj->isTargetPaused(arr->getObjectAtIndex(i)) ? JS_TRUE : JS_FALSE; // break directly since all targets have the same `pause` status. break; } } } while (0); JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_doNothing(JSContext *cx, uint32_t argc, jsval *vp) { return JS_TRUE; } JSBool js_forceGC(JSContext *cx, uint32_t argc, jsval *vp) { JSRuntime *rt = JS_GetRuntime(cx); JS_GC(rt); return JS_TRUE; } JSBool js_cocos2dx_retain(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *thisObj = JS_THIS_OBJECT(cx, vp); if (thisObj) { js_proxy_t *proxy = jsb_get_js_proxy(thisObj); if (proxy) { ((Object *)proxy->ptr)->retain(); return JS_TRUE; } } JS_ReportError(cx, "Invalid Native Object."); return JS_FALSE; } JSBool js_cocos2dx_release(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *thisObj = JS_THIS_OBJECT(cx, vp); if (thisObj) { js_proxy_t *proxy = jsb_get_js_proxy(thisObj); if (proxy) { ((Object *)proxy->ptr)->release(); return JS_TRUE; } } JS_ReportError(cx, "Invalid Native Object."); return JS_FALSE; } JSBool js_cocos2dx_CCNode_setPosition(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); JSBool ok = JS_TRUE; js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setPosition(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { double x; ok &= JS_ValueToNumber(cx, argv[0], &x ); double y; ok &= JS_ValueToNumber(cx, argv[1], &y ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setPosition(Point(x,y)); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCNode_setContentSize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); JSBool ok = JS_TRUE; js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { cocos2d::Size arg0; ok &= jsval_to_ccsize(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setContentSize(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { double width; ok &= JS_ValueToNumber(cx, argv[0], &width ); double height; ok &= JS_ValueToNumber(cx, argv[1], &height ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setContentSize(Size(width,height)); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCNode_setAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); JSBool ok = JS_TRUE; js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setAnchorPoint(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { double x; ok &= JS_ValueToNumber(cx, argv[0], &x ); double y; ok &= JS_ValueToNumber(cx, argv[1], &y ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setAnchorPoint(Point(x,y)); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCTMXLayer_tileFlagsAt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj; JSBool ok = JS_TRUE; cocos2d::TMXLayer* cobj; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::ccTMXTileFlags flags = kTMXTileHorizontalFlag; jsval jsret; jsret = UINT_TO_JSVAL((uint32_t)flags); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_CCTMXLayer_getTiles(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { int* ret = cobj->getTiles(); Size size = cobj->getLayerSize(); int count = size.width * size.height; JSObject* array = JS_NewInt32Array(cx, count); if (NULL == array) { JS_ReportError(cx, "Can't allocate enough memory."); return JS_FALSE; } int32_t* bufdata = (int32_t*)JS_GetArrayBufferViewData(array); memcpy(bufdata, ret, count*sizeof(int32_t)); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(array)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } template JSBool js_BezierActions_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); if (argc == 2) { double t; if( ! JS_ValueToNumber(cx, argv[0], &t) ) { return JS_FALSE; } int num; Point *arr; jsval_to_ccarray_of_CCPoint(cx, argv[1], &arr, &num); ccBezierConfig config; config.controlPoint_1 = arr[0]; config.controlPoint_2 = arr[1]; config.endPosition = arr[2]; T* ret = T::create(t, config); free(arr); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } template JSBool js_CardinalSplineActions_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { double dur; ok &= JS_ValueToNumber(cx, argv[0], &dur); int num; Point *arr; ok &= jsval_to_ccarray_of_CCPoint(cx, argv[1], &arr, &num); double ten; ok &= JS_ValueToNumber(cx, argv[2], &ten); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); PointArray *points = PointArray::create(num); for( int i=0; i < num;i++) { points->addControlPoint(arr[i]); } T *ret = T::create(dur, points, ten); free(arr); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } template JSBool js_CatmullRomActions_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { double dur; ok &= JS_ValueToNumber(cx, argv[0], &dur); int num; Point *arr; ok &= jsval_to_ccarray_of_CCPoint(cx, argv[1], &arr, &num); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); PointArray *points = PointArray::create(num); for( int i=0; i < num;i++) { points->addControlPoint(arr[i]); } T *ret = T::create(dur, points); free(arr); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool JSB_CCBezierBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { return js_BezierActions_create(cx, argc, vp); } JSBool JSB_CCBezierTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { return js_BezierActions_create(cx, argc, vp); } JSBool JSB_CCCardinalSplineBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { return js_CardinalSplineActions_create(cx, argc, vp); } JSBool JSB_CCCardinalSplineTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { return js_CardinalSplineActions_create(cx, argc, vp); } JSBool JSB_CCCatmullRomBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { return js_CatmullRomActions_create(cx, argc, vp); } JSBool JSB_CCCatmullRomTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { return js_CatmullRomActions_create(cx, argc, vp); } JSBool js_cocos2dx_ccGLEnableVertexAttribs(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc == 1) { unsigned int arg0; ok &= jsval_to_uint32(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GL::enableVertexAttribs(arg0); JS_SET_RVAL(cx, vp, JSVAL_NULL); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpAdd(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0 + arg1; jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpDistanceSQ(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); float ret = arg0.getDistanceSq(arg1); jsval jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpDistance(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); float ret = arg0.getDistance(arg1); jsval jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpClamp(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); cocos2d::Point arg2; ok &= jsval_to_ccpoint(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0.getClampPoint(arg1, arg2); jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpLengthSQ(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); float ret = arg0.getLengthSq(); jsval jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpLength(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); float ret = arg0.getLength(); jsval jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpNeg(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = -arg0; jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpSub(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0 - arg1; jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpMult(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0 * arg1; jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpMidpoint(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0.getMidpoint(arg1); jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ccpDot(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); float ret = arg0.dot(arg1); jsval jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ccpCross(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); float ret = arg0.cross(arg1); jsval jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ccpPerp(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0.getPerp(); jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpRPerp(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0.getRPerp(); jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_ccpProject(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0.project(arg1); jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ccpRotate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 2) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); cocos2d::Point arg1; ok &= jsval_to_ccpoint(cx, argv[1], &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0.rotate(arg1); jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_ccpNormalize(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 1) { cocos2d::Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Point ret = arg0.normalize(); jsval jsret = ccpoint_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } // setBlendFunc template JSBool js_cocos2dx_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj; T* cobj; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (T*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 2) { GLenum src, dst; jsval_to_int32(cx, argv[0], (int32_t*)&src); jsval_to_int32(cx, argv[1], (int32_t*)&dst); BlendFunc blendFunc = {src, dst}; cobj->setBlendFunc(blendFunc); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_cocos2dx_CCSprite_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { return js_cocos2dx_setBlendFunc(cx, argc, vp); } JSBool js_cocos2dx_CCSpriteBatchNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { return js_cocos2dx_setBlendFunc(cx, argc, vp); } // JSBool js_cocos2dx_CCMotionStreak_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) // { // return js_cocos2dx_setBlendFunc(cx, argc, vp); // } JSBool js_cocos2dx_CCAtlasNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { return js_cocos2dx_setBlendFunc(cx, argc, vp); } JSBool js_cocos2dx_CCParticleBatchNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { return js_cocos2dx_setBlendFunc(cx, argc, vp); } JSBool js_cocos2dx_CCLayerColor_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { return js_cocos2dx_setBlendFunc(cx, argc, vp); } JSBool js_cocos2dx_CCParticleSystem_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { return js_cocos2dx_setBlendFunc(cx, argc, vp); } JSBool js_cocos2dx_CCDrawNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { return js_cocos2dx_setBlendFunc(cx, argc, vp); } JSBool js_cocos2dx_CCTexture2D_setTexParameters(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Texture2D* cobj = (Texture2D*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 4) { jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; GLuint arg0, arg1, arg2, arg3; ok &= jsval_to_uint32(cx, *argvp++, &arg0); ok &= jsval_to_uint32(cx, *argvp++, &arg1); ok &= jsval_to_uint32(cx, *argvp++, &arg2); ok &= jsval_to_uint32(cx, *argvp++, &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Texture2D::TexParams param = { arg0, arg1, arg2, arg3 }; cobj->setTexParameters(param); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } JSBool js_cocos2dx_CCMenu_alignItemsInRows(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSBool ok = JS_TRUE; js_proxy_t *proxy = jsb_get_js_proxy(jsthis); Menu* cobj = (Menu*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) jsval *argvp = JS_ARGV(cx,vp); ValueVector items; ok &= jsvals_variadic_to_ccvaluevector(cx, argvp, argc, &items); if (ok) { cobj->alignItemsInRowsWithArray(items); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "Error in js_cocos2dx_CCMenu_alignItemsInRows"); return JS_FALSE; } JSBool js_cocos2dx_CCMenu_alignItemsInColumns(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); JSBool ok = JS_TRUE; js_proxy_t *proxy = jsb_get_js_proxy(jsthis); Menu* cobj = (Menu*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) jsval *argvp = JS_ARGV(cx,vp); ValueVector items; ok &= jsvals_variadic_to_ccvaluevector(cx, argvp, argc, &items); if (ok) { cobj->alignItemsInColumnsWithArray(items); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "Error in js_cocos2dx_CCMenu_alignItemsInColumns"); return JS_FALSE; } // FIXME: These are only for v2.x JSB compatibility JSBool js_cocos2dx_CCLayer_setTouchPriority(JSContext *cx, uint32_t argc, jsval *vp) { return JS_TRUE; } static int executeScriptTouchHandler(Layer* layer, EventTouch::EventCode eventType, Touch* touch) { TouchScriptData data(eventType, layer, touch); ScriptEvent event(kTouchEvent, &data); return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } static int executeScriptTouchesHandler(Layer* layer, EventTouch::EventCode eventType, const std::vector& touches) { TouchesScriptData data(eventType, layer, touches); ScriptEvent event(kTouchesEvent, &data); return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } static void setTouchEnabledForLayer(Layer* layer, bool enabled) { auto dict = static_cast(layer->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); layer->setUserObject(dict); } dict->setObject(Bool::create(enabled), "touchEnabled"); auto touchListenerAllAtOnce = static_cast(dict->objectForKey("touchListenerAllAtOnce")); auto touchListenerOneByOne = static_cast(dict->objectForKey("touchListenerOneByOne")); auto touchMode = static_cast(dict->objectForKey("touchMode")); auto swallowTouches = static_cast(dict->objectForKey("swallowTouches")); auto dispatcher = layer->getEventDispatcher(); if (touchListenerAllAtOnce != nullptr || touchListenerOneByOne != nullptr) { dispatcher->removeEventListener(touchListenerAllAtOnce); dispatcher->removeEventListener(touchListenerOneByOne); dict->removeObjectForKey("touchListenerAllAtOnce"); dict->removeObjectForKey("touchListenerOneByOne"); touchListenerAllAtOnce = nullptr; touchListenerOneByOne = nullptr; } if (enabled) { if (touchMode == nullptr || touchMode->getValue() == (int)Touch::DispatchMode::ALL_AT_ONCE) { auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = [layer](const std::vector& touches, Event* event){ executeScriptTouchesHandler(layer, EventTouch::EventCode::BEGAN, touches); }; listener->onTouchesMoved = [layer](const std::vector& touches, Event* event){ executeScriptTouchesHandler(layer, EventTouch::EventCode::MOVED, touches); }; listener->onTouchesEnded = [layer](const std::vector& touches, Event* event){ executeScriptTouchesHandler(layer, EventTouch::EventCode::ENDED, touches); }; listener->onTouchesCancelled = [layer](const std::vector& touches, Event* event){ executeScriptTouchesHandler(layer, EventTouch::EventCode::CANCELLED, touches); }; dispatcher->addEventListenerWithSceneGraphPriority(listener, layer); dict->setObject(listener, "touchListenerAllAtOnce"); } else { auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(swallowTouches ? swallowTouches->getValue() : false); listener->onTouchBegan = [layer](Touch* touch, Event* event) -> bool{ return executeScriptTouchHandler(layer, EventTouch::EventCode::BEGAN, touch) == 0 ? false : true; }; listener->onTouchMoved = [layer](Touch* touch, Event* event){ executeScriptTouchHandler(layer, EventTouch::EventCode::MOVED, touch); }; listener->onTouchEnded = [layer](Touch* touch, Event* event){ executeScriptTouchHandler(layer, EventTouch::EventCode::ENDED, touch); }; listener->onTouchCancelled = [layer](Touch* touch, Event* event){ executeScriptTouchHandler(layer, EventTouch::EventCode::CANCELLED, touch); }; dispatcher->addEventListenerWithSceneGraphPriority(listener, layer); dict->setObject(listener, "touchListenerOneByOne"); } } } JSBool js_cocos2dx_CCLayer_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); bool enabled = JSVAL_TO_BOOLEAN(argv[0]); setTouchEnabledForLayer(cobj, enabled); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 0) { JSBool ret = JS_FALSE; auto dict = static_cast(cobj->getUserObject()); if (dict != nullptr) { Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); ret = enabled ? enabled->getValue() : JS_FALSE; } JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_setTouchMode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); int32_t mode = 0; jsval_to_int32(cx, argv[0], &mode); Integer* touchModeObj = nullptr; auto dict = static_cast(cobj->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); cobj->setUserObject(dict); } touchModeObj = static_cast(dict->objectForKey("touchMode")); int32_t touchMode = touchModeObj ? touchModeObj->getValue() : 0; if (touchMode != mode) { dict->setObject(Integer::create(mode), "touchMode"); Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); if (enabled && enabled->getValue()) { setTouchEnabledForLayer(cobj, false); setTouchEnabledForLayer(cobj, true); } } JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_getTouchMode(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 0) { int32_t ret = 0; auto dict = static_cast(cobj->getUserObject()); if (dict != nullptr) { Integer* mode = static_cast(dict->objectForKey("touchMode")); ret = mode ? mode->getValue() : 0; } JS_SET_RVAL(cx, vp, INT_TO_JSVAL(ret)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_setSwallowsTouches(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); bool swallowsTouches = JSVAL_TO_BOOLEAN(argv[0]); Bool* swallowsTouchesObj = nullptr; auto dict = static_cast(cobj->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); cobj->setUserObject(dict); } swallowsTouchesObj = static_cast(dict->objectForKey("swallowTouches")); bool oldSwallowsTouches = swallowsTouchesObj ? swallowsTouchesObj->getValue() : false; if (oldSwallowsTouches != swallowsTouches) { dict->setObject(Integer::create(swallowsTouches), "swallowTouches"); Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); if (enabled && enabled->getValue()) { setTouchEnabledForLayer(cobj, false); setTouchEnabledForLayer(cobj, true); } } JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_isSwallowsTouches(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 0) { JSBool ret = JS_FALSE; auto dict = static_cast(cobj->getUserObject()); if (dict != nullptr) { Bool* swallowTouches = static_cast(dict->objectForKey("swallowTouches")); ret = swallowTouches ? swallowTouches->getValue() : JS_FALSE; } JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_setKeyboardEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); bool enabled = JSVAL_TO_BOOLEAN(argv[0]); auto dict = static_cast(cobj->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); cobj->setUserObject(dict); } dict->setObject(Bool::create(enabled), "keyboardEnabled"); auto keyboardListener = static_cast(dict->objectForKey("keyboardListener")); auto dispatcher = cobj->getEventDispatcher(); dispatcher->removeEventListener(keyboardListener); if (enabled) { auto listener = EventListenerKeyboard::create(); listener->onKeyPressed = [cobj](EventKeyboard::KeyCode keyCode, Event* event){ }; listener->onKeyReleased = [cobj](EventKeyboard::KeyCode keyCode, Event* event){ KeypadScriptData data(keyCode, cobj); ScriptEvent scriptEvent(kKeypadEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); }; dispatcher->addEventListenerWithSceneGraphPriority(listener, cobj); dict->setObject(listener, "keyboardListener"); } JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_isKeyboardEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 0) { JSBool ret = JS_FALSE; auto dict = static_cast(cobj->getUserObject()); if (dict != nullptr) { Bool* enabled = static_cast(dict->objectForKey("keyboardEnabled")); ret = enabled ? enabled->getValue() : JS_FALSE; } JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_setAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); bool enabled = JSVAL_TO_BOOLEAN(argv[0]); auto dict = static_cast(cobj->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); cobj->setUserObject(dict); } dict->setObject(Bool::create(enabled), "accelerometerEnabled"); auto accListener = static_cast(dict->objectForKey("accListener")); auto dispatcher = cobj->getEventDispatcher(); dispatcher->removeEventListener(accListener); Device::setAccelerometerEnabled(enabled); if (enabled) { auto listener = EventListenerAcceleration::create([cobj](Acceleration* acc, Event* event){ BasicScriptData data(cobj,(void*)acc); ScriptEvent accEvent(kAccelerometerEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&accEvent); }); dispatcher->addEventListenerWithSceneGraphPriority(listener, cobj); dict->setObject(listener, "accListener"); } JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_isAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 0) { JSBool ret = JS_FALSE; auto dict = static_cast(cobj->getUserObject()); if (dict != nullptr) { Bool* enabled = static_cast(dict->objectForKey("accelerometerEnabled")); ret = enabled ? enabled->getValue() : JS_FALSE; } JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CCLayer_setAccelerometerInterval(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); Layer* cobj = (Layer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { jsval* argv = JS_ARGV(cx, vp); double interval = 0.0; JS_ValueToNumber(cx, argv[0], &interval); Device::setAccelerometerInterval(interval); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } // TMXLayer JSBool js_cocos2dx_CCTMXLayer_getTileFlagsAt(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj; TMXLayer* cobj; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (TMXLayer*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 1) { ccTMXTileFlags flags; Point arg0; ok &= jsval_to_ccpoint(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->getTileGIDAt(arg0, &flags); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)flags)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } //#pragma mark - DrawNode // Arguments: Array of points, fill color (Color4F), width(float), border color (Color4F) // Ret value: void JSBool js_cocos2dx_CCDrawNode_drawPolygon(JSContext *cx, uint32_t argc, jsval *vp) { JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); DrawNode* cobj = (DrawNode*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if ( argc == 4) { jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; JSObject *argArray = NULL; Color4F argFillColor = Color4F(0.0f, 0.0f, 0.0f, 0.0f); double argWidth = 0.0; Color4F argBorderColor = Color4F(0.0f, 0.0f, 0.0f, 0.0f); // Points ok &= JS_ValueToObject(cx, *argvp++, &argArray); JSB_PRECONDITION2( (argArray && JS_IsArrayObject(cx, argArray)) , cx, JS_FALSE, "Vertex should be anArray object"); // Color 4F ok &= jsval_to_cccolor4f(cx, *argvp++, &argFillColor); // Width ok &= JS_ValueToNumber( cx, *argvp++, &argWidth ); // Color Border (4F) ok &= jsval_to_cccolor4f(cx, *argvp++, &argBorderColor); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error parsing arguments"); { uint32_t l; if( ! JS_GetArrayLength(cx, argArray, &l) ) return JS_FALSE; Point* verts = new Point[ l ]; Point p; for( uint32_t i=0; idrawPolygon(verts, l, argFillColor, argWidth, argBorderColor); CC_SAFE_DELETE_ARRAY(verts); } JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 4); return JS_FALSE; } static JSBool jsval_to_string_vector(JSContext* cx, jsval v, std::vector& ret) { JSObject *jsobj; JSBool ok = JS_ValueToObject( cx, v, &jsobj ); JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error converting value to object"); JSB_PRECONDITION2( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); uint32_t len = 0; JS_GetArrayLength(cx, jsobj, &len); for (uint32_t i=0; i < len; i++) { jsval elt; if (JS_GetElement(cx, jsobj, i, &elt)) { if (JSVAL_IS_STRING(elt)) { JSStringWrapper str(JSVAL_TO_STRING(elt)); ret.push_back(str.get()); } } } return JS_TRUE; } static jsval string_vector_to_jsval(JSContext* cx, const std::vector& arr) { JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); int i = 0; for(std::vector::const_iterator iter = arr.begin(); iter != arr.end(); ++iter, ++i) { jsval arrElement = c_string_to_jsval(cx, iter->c_str()); if(!JS_SetElement(cx, jsretArr, i, &arrElement)) { break; } } return OBJECT_TO_JSVAL(jsretArr); } JSBool js_cocos2dx_CCFileUtils_setSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { std::vector arg0; ok &= jsval_to_string_vector(cx, argv[0], arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setSearchResolutionsOrder(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCFileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { std::vector arg0; ok &= jsval_to_string_vector(cx, argv[0], arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setSearchPaths(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCFileUtils_getSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { std::vector ret = cobj->getSearchPaths(); jsval jsret; jsret = string_vector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_CCFileUtils_getByteArrayFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); Data data = cobj->getDataFromFile(arg0); do { if (!data.isNull()) { uint32_t size = static_cast(data.getSize()); JSObject* array = JS_NewUint8Array(cx, size); if (nullptr == array) break; uint8_t* bufdata = (uint8_t*)JS_GetArrayBufferViewData(array); memcpy(bufdata, data.getBytes(), size*sizeof(uint8_t)); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(array)); return JS_TRUE; } } while(false); JS_ReportError(cx, "get file(%s) data fails", arg0.c_str()); return JS_FALSE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } JSBool js_cocos2dx_CCFileUtils_getSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { std::vector ret = cobj->getSearchResolutionsOrder(); jsval jsret; jsret = string_vector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } static JSBool js_cocos2dx_FileUtils_createDictionaryWithContentsOfFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::ValueMap ret = FileUtils::getInstance()->getValueMapFromFile(arg0.c_str()); jsval jsret; jsret = ccvaluemap_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_cocos2dx_CCGLProgram_setUniformLocationWith4f(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); int arg0; double arg1; double arg2; double arg3; double arg4; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); ok &= JS_ValueToNumber(cx, argv[1], &arg1); if(argc == 2) { JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setUniformLocationWith1f(arg0, arg1); } if (argc == 3) { ok &= JS_ValueToNumber(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setUniformLocationWith2f(arg0, arg1, arg2); } if(argc == 4) { ok &= JS_ValueToNumber(cx, argv[3], &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setUniformLocationWith3f(arg0, arg1, arg2, arg3); } if(argc == 5) { ok &= JS_ValueToNumber(cx, argv[4], &arg4); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setUniformLocationWith4f(arg0, arg1, arg2, arg3, arg4); } JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 5); return JS_FALSE; } JSBool js_cocos2dx_CCGLProgram_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if(argc != 2) { JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } const char *arg0, *arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); GLProgram* ret = new GLProgram(); ret->autorelease(); ret->initWithVertexShaderFilename(arg0, arg1); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JSBool js_cocos2dx_CCGLProgram_createWithString(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if(argc != 2) { JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } const char *arg0, *arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); GLProgram* ret = new GLProgram(); ret->initWithVertexShaderByteArray(arg0, arg1); jsval jsret; do { if (ret) { js_proxy_t *p = jsb_get_native_proxy(ret); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JSBool js_cocos2dx_CCGLProgram_getProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { GLuint ret = cobj->getProgram(); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } #define js_cocos2dx_CCCamera_getXYZ(funcName) \ JSBool ok = JS_TRUE; \ JSObject *obj = JS_THIS_OBJECT(cx, vp); \ js_proxy_t *proxy = jsb_get_js_proxy(obj); \ cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); \ JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); \ if (argc == 0) { \ float x; \ float y; \ float z; \ cobj->funcName(&x, &y, &z); \ JSObject* tmp = JS_NewObject(cx, NULL, NULL, NULL); \ \ do \ { \ if (NULL == tmp) break; \ \ ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && \ JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && \ JS_DefineProperty(cx, tmp, "z", DOUBLE_TO_JSVAL(z), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); \ \ if (ok) { \ JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); \ return JS_TRUE; \ } \ } while (false); \ \ JS_SET_RVAL(cx, vp, JSVAL_NULL); \ return JS_TRUE; \ } \ \ JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); \ return JS_FALSE; JSBool js_cocos2dx_SpriteBatchNode_getDescendants(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_SpriteBatchNode_getDescendants : Invalid Native Object"); if (argc == 0) { std::vector ret = cobj->getDescendants(); JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); size_t vSize = ret.size(); jsval jsret; for (size_t i = 0; i < vSize; i++) { proxy = js_get_or_create_proxy(cx, ret[i]); jsret = OBJECT_TO_JSVAL(proxy->obj); JS_SetElement(cx, jsretArr, static_cast(i), &jsret); } JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsretArr)); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_getDescendants : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_NodeGrid_setGrid(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::NodeGrid* cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_NodeGrid_setGrid : Invalid Native Object"); if (argc == 1) { cocos2d::GridBase* arg0; do { if(argv[0].isNull()) { arg0 = nullptr; break;} if (!argv[0].isObject()) { ok = JS_FALSE; break; } JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::GridBase*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_NodeGrid_setGrid : Error processing arguments"); cobj->setGrid(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_NodeGrid_setGrid : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } // cc.SAXParser.getInstance() JSBool js_SAXParser_getInstance(JSContext *cx, unsigned argc, JS::Value *vp) { __JSSAXDelegator* delegator = __JSSAXDelegator::getInstance(); SAXParser* parser = delegator->getParser(); jsval jsret; if (parser) { js_proxy_t *p = jsb_get_native_proxy(parser); if (p) { jsret = OBJECT_TO_JSVAL(p->obj); } else { // create a new js obj of that class js_proxy_t *proxy = js_get_or_create_proxy(cx, parser); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } // cc.SAXParser.getInstance().parse(filepath) JSBool js_SAXParser_parse(JSContext *cx, unsigned argc, JS::Value *vp) { __JSSAXDelegator* delegator = __JSSAXDelegator::getInstance(); JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); std::string parsedStr = delegator->parse(arg0); jsval strVal = std_string_to_jsval(cx, parsedStr); // create a new js obj of the parsed string JS::RootedValue outVal(cx); ok = JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), static_cast(parsedStr.size()), &outVal); if (ok) JS_SET_RVAL(cx, vp, outVal); else { JS_SET_RVAL(cx, vp, JSVAL_NULL); JS_ReportError(cx, "js_SAXParser_parse : parse error"); } return JS_TRUE; } JS_ReportError(cx, "js_SAXParser_parse : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } // cc.SAXParser.getInstance().preloadPlist(filepath) JSBool js_SAXParser_preloadPlist(JSContext *cx, unsigned argc, JS::Value *vp) { __JSSAXDelegator* delegator = __JSSAXDelegator::getInstance(); JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); ok &= delegator->preloadPlist(arg0); if(!ok) JS_ReportError(cx, "js_SAXParser_preloadPlist : file not found %d", &arg0, 1); return JS_TRUE; } JS_ReportError(cx, "js_SAXParser_parse : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } // cc.SAXParser.getInstance().unloadPlist(filepath) JSBool js_SAXParser_unloadPlist(JSContext *cx, unsigned argc, JS::Value *vp) { return JS_TRUE; } // cc.SAXParser.getInstance().getList(key) JSBool js_SAXParser_getList(JSContext *cx, unsigned argc, JS::Value *vp) { __JSSAXDelegator* delegator = __JSSAXDelegator::getInstance(); JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); std::string value = delegator->getList(arg0); jsval ret = std_string_to_jsval(cx, value); JS_SET_RVAL(cx, vp, ret); return JS_TRUE; } JS_ReportError(cx, "js_SAXParser_parse : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } cocos2d::SAXParser* __JSSAXDelegator::getParser() { return &_parser; } std::string __JSSAXDelegator::parse(const std::string& path) { _result.clear(); SAXParser parser; if (false != parser.init("UTF-8") ) { parser.setDelegator(this); parser.parse(FileUtils::getInstance()->fullPathForFilename(path).c_str()); } return _result; } __JSSAXDelegator::~__JSSAXDelegator(){ CCLOGINFO("deallocing __JSSAXDelegator: %p", this); } void __JSSAXDelegator::startElement(void *ctx, const char *name, const char **atts) { _isStoringCharacters = true; _currentValue.clear(); std::string elementName = (char*)name; int end = (int)_result.size() - 1; if(end >= 0 && _result[end] != '{' && _result[end] != '[' && _result[end] != ':') { _result += ","; } if (elementName == "dict") { _result += "{"; } else if (elementName == "array") { _result += "["; } } void __JSSAXDelegator::endElement(void *ctx, const char *name) { _isStoringCharacters = false; std::string elementName = (char*)name; if (elementName == "dict") { _result += "}"; } else if (elementName == "array") { _result += "]"; } else if (elementName == "key") { _result += "\"" + _currentValue + "\":"; } else if (elementName == "string") { _result += "\"" + _currentValue + "\""; } else if (elementName == "false" || elementName == "true") { _result += elementName; } else if (elementName == "real" || elementName == "integer") { _result += _currentValue; } } void __JSSAXDelegator::textHandler(void *ctx, const char *ch, int len) { CC_UNUSED_PARAM(ctx); std::string text((char*)ch, 0, len); if (_isStoringCharacters) { _currentValue += text; } } JSBool jsval_to_TTFConfig(JSContext *cx, jsval v, TTFConfig* ret) { JSObject *tmp; JS::RootedValue js_fontFilePath(cx); JS::RootedValue js_fontSize(cx); JS::RootedValue js_glyphs(cx); JS::RootedValue js_customGlyphs(cx); JS::RootedValue js_distanceFieldEnable(cx); std::string fontFilePath,customGlyphs; double fontSize, glyphs; JSBool distanceFieldEnable; JSBool ok = v.isObject() && JS_ValueToObject(cx, v, &tmp) && JS_GetProperty(cx, tmp, "fontFilePath", &js_fontFilePath) && JS_GetProperty(cx, tmp, "fontSize", &js_fontSize) && JS_GetProperty(cx, tmp, "glyphs", &js_glyphs) && JS_GetProperty(cx, tmp, "customGlyphs", &js_customGlyphs) && JS_GetProperty(cx, tmp, "distanceFieldEnable", &js_distanceFieldEnable) && JS_ValueToNumber(cx, js_fontSize, &fontSize) && JS_ValueToNumber(cx, js_glyphs, &glyphs) && JS_ValueToBoolean(cx,js_distanceFieldEnable,&distanceFieldEnable) && jsval_to_std_string(cx,js_fontFilePath,&ret->fontFilePath) && jsval_to_std_string(cx,js_customGlyphs,&customGlyphs); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); ret->fontSize = (int)fontSize; ret->glyphs = GlyphCollection((int)glyphs); ret->distanceFieldEnabled = distanceFieldEnable; if(ret->glyphs == GlyphCollection::CUSTOM && customGlyphs.length() > 0) ret->customGlyphs = customGlyphs.c_str(); else ret->customGlyphs = nullptr; return JS_TRUE; } JSBool js_cocos2dx_Label_createWithTTF(JSContext *cx, uint32_t argc, jsval *vp) { if (argc < 2) return JS_FALSE; jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; TTFConfig ttfConfig(""); std::string text; ok &= jsval_to_TTFConfig(cx, argv[0], &ttfConfig); ok &= jsval_to_std_string(cx, argv[1], &text); cocos2d::Label* ret = nullptr; if (argc == 2) { JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_createWithTTF : Error processing arguments"); ret = cocos2d::Label::createWithTTF(ttfConfig, text); jsval jsret = JSVAL_NULL; if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 3) { int arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_createWithTTF : Error processing arguments"); TextHAlignment alignment = TextHAlignment(arg2); cocos2d::Label* ret = cocos2d::Label::createWithTTF(ttfConfig, text, alignment); jsval jsret = JSVAL_NULL; if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 4) { int arg2,arg3; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_createWithTTF : Error processing arguments"); TextHAlignment alignment = TextHAlignment(arg2); cocos2d::Label* ret = cocos2d::Label::createWithTTF(ttfConfig, text, alignment, arg3); jsval jsret = JSVAL_NULL; if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_createWithTTF : wrong number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_Label_setTTFConfig(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_cocos2dx_Label_setTTFConfig : Invalid Native Object"); if (argc == 1) { TTFConfig ttfConfig(""); do { if (!argv[0].isObject()) { ok = JS_FALSE; break; } ok &= jsval_to_TTFConfig(cx, argv[0], &ttfConfig); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_cocos2dx_Label_setTTFConfig : Error processing arguments"); cobj->setTTFConfig(ttfConfig); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_cocos2dx_Label_setTTFConfig : wrong number of arguments"); return JS_FALSE; } void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, global, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, global, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } JS_DefineFunction(cx, global, "__associateObjWithNative", js_cocos2dx_swap_native_object, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getPlatform", js_platform, 0, JSPROP_READONLY | JSPROP_PERMANENT); JSObject *tmpObj; JS_DefineFunction(cx, jsb_cocos2d_Label_prototype, "createWithTTF", js_cocos2dx_Label_createWithTTF, 4, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Label_prototype, "setTTFConfig", js_cocos2dx_Label_setTTFConfig, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_NodeGrid_prototype, "setGrid", js_cocos2dx_NodeGrid_setGrid, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_GLProgram_prototype, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_GLProgram_prototype, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "onExit", js_doNothing, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "onEnter", js_doNothing, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "onEnterTransitionDidFinish", js_doNothing, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "onExitTransitionDidStart", js_doNothing, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "init", js_doNothing, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "schedule", js_CCNode_schedule, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "scheduleOnce", js_CCNode_scheduleOnce, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "scheduleUpdateWithPriority", js_cocos2dx_CCNode_scheduleUpdateWithPriority, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "unscheduleUpdate", js_cocos2dx_CCNode_unscheduleUpdate, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "scheduleUpdate", js_cocos2dx_CCNode_scheduleUpdate, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "unschedule", js_CCNode_unschedule, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "unscheduleAllCallbacks", js_cocos2dx_CCNode_unscheduleAllSelectors, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "setPosition", js_cocos2dx_CCNode_setPosition, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "setContentSize", js_cocos2dx_CCNode_setContentSize, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "setAnchorPoint", js_cocos2dx_CCNode_setAnchorPoint, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_GLProgram_prototype, "setUniformLocationF32", js_cocos2dx_CCGLProgram_setUniformLocationWith4f, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_GLProgram_prototype, "getProgram", js_cocos2dx_CCGLProgram_getProgram, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "resumeTarget", js_cocos2dx_CCScheduler_resumeTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "pauseTarget", js_cocos2dx_CCScheduler_pauseTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "scheduleUpdateForTarget", js_CCScheduler_scheduleUpdateForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "unscheduleUpdateForTarget", js_CCScheduler_unscheduleUpdateForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "scheduleCallbackForTarget", js_CCScheduler_schedule, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "unscheduleCallbackForTarget", js_CCScheduler_unscheduleCallbackForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "unscheduleAllCallbacksForTarget", js_cocos2dx_CCScheduler_unscheduleAllSelectorsForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "unscheduleAllCallbacks", js_cocos2dx_CCScheduler_unscheduleAll, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "unscheduleAllCallbacksWithMinPriority", js_cocos2dx_CCScheduler_unscheduleAllCallbacksWithMinPriority, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "isTargetPaused", js_cocos2dx_CCScheduler_isTargetPaused, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_TMXLayer_prototype, "getTileFlagsAt", js_cocos2dx_CCTMXLayer_getTileFlagsAt, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_DrawNode_prototype, "drawPoly", js_cocos2dx_CCDrawNode_drawPolygon, 4, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_DrawNode_prototype, "setBlendFunc", js_cocos2dx_CCDrawNode_setBlendFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Texture2D_prototype, "setTexParameters", js_cocos2dx_CCTexture2D_setTexParameters, 4, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Menu_prototype, "alignItemsInRows", js_cocos2dx_CCMenu_alignItemsInRows, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Menu_prototype, "alignItemsInColumns", js_cocos2dx_CCMenu_alignItemsInColumns, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "setTouchPriority", js_cocos2dx_CCLayer_setTouchPriority, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "setTouchEnabled", js_cocos2dx_CCLayer_setTouchEnabled, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "isTouchEnabled", js_cocos2dx_CCLayer_isTouchEnabled, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "setKeyboardEnabled", js_cocos2dx_CCLayer_setKeyboardEnabled, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "isKeyboardEnabled", js_cocos2dx_CCLayer_isKeyboardEnabled, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "setTouchMode", js_cocos2dx_CCLayer_setTouchMode, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "getTouchMode", js_cocos2dx_CCLayer_getTouchMode, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "setSwallowsTouches", js_cocos2dx_CCLayer_setSwallowsTouches, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "isSwallowsTouches", js_cocos2dx_CCLayer_isSwallowsTouches, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "setAccelerometerEnabled", js_cocos2dx_CCLayer_setAccelerometerEnabled, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "isAccelerometerEnabled", js_cocos2dx_CCLayer_isAccelerometerEnabled, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Layer_prototype, "setAccelerometerInterval", js_cocos2dx_CCLayer_setAccelerometerInterval, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "setSearchResolutionsOrder", js_cocos2dx_CCFileUtils_setSearchResolutionsOrder, 1, JSPROP_PERMANENT ); JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "setSearchPaths", js_cocos2dx_CCFileUtils_setSearchPaths, 1, JSPROP_PERMANENT ); JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "getSearchPaths", js_cocos2dx_CCFileUtils_getSearchPaths, 0, JSPROP_PERMANENT ); JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "getSearchResolutionsOrder", js_cocos2dx_CCFileUtils_getSearchResolutionsOrder, 0, JSPROP_PERMANENT ); JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "createDictionaryWithContentsOfFile", js_cocos2dx_FileUtils_createDictionaryWithContentsOfFile, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "getByteArrayFromFile", js_cocos2dx_CCFileUtils_getByteArrayFromFile, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.BezierBy; })()")); JS_DefineFunction(cx, tmpObj, "create", JSB_CCBezierBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.BezierTo; })()")); JS_DefineFunction(cx, tmpObj, "create", JSB_CCBezierTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CardinalSplineBy; })()")); JS_DefineFunction(cx, tmpObj, "create", JSB_CCCardinalSplineBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CardinalSplineTo; })()")); JS_DefineFunction(cx, tmpObj, "create", JSB_CCCardinalSplineTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CatmullRomBy; })()")); JS_DefineFunction(cx, tmpObj, "create", JSB_CCCatmullRomBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CatmullRomTo; })()")); JS_DefineFunction(cx, tmpObj, "create", JSB_CCCatmullRomTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Sprite_prototype, "setBlendFunc", js_cocos2dx_CCSprite_setBlendFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_SpriteBatchNode_prototype, "setBlendFunc", js_cocos2dx_CCSpriteBatchNode_setBlendFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_SpriteBatchNode_prototype, "getDescendants", js_cocos2dx_SpriteBatchNode_getDescendants, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); //JS_DefineFunction(cx, jsb_cocos2d_MotionStreak_prototype, "setBlendFunc", js_cocos2dx_CCMotionStreak_setBlendFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_AtlasNode_prototype, "setBlendFunc", js_cocos2dx_CCAtlasNode_setBlendFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_ParticleBatchNode_prototype, "setBlendFunc", js_cocos2dx_CCParticleBatchNode_setBlendFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_LayerColor_prototype, "setBlendFunc", js_cocos2dx_CCLayerColor_setBlendFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_ParticleSystem_prototype, "setBlendFunc", js_cocos2dx_CCParticleSystem_setBlendFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Action_prototype, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Action_prototype, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Animation_prototype, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Animation_prototype, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_SpriteFrame_prototype, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_SpriteFrame_prototype, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_MenuItem_prototype, "setCallback", js_cocos2dx_CCMenuItem_setCallback, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_TMXLayer_prototype, "getTileFlagsAt", js_cocos2dx_CCTMXLayer_tileFlagsAt, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_TMXLayer_prototype, "getTiles", js_cocos2dx_CCTMXLayer_getTiles, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.Menu; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenu_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItem; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItem_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItemSprite; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemSprite_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItemImage; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemImage_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItemLabel; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemLabel_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItemAtlasFont; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemAtlasFont_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItemFont; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemFont_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.MenuItemToggle; })()")); JS_DefineFunction(cx, tmpObj, "_create", js_cocos2dx_CCMenuItemToggle_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.Sequence; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCSequence_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.Spawn; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCSpawn_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.Animation; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCAnimation_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.LayerMultiplex; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCLayerMultiplex_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "registerTargetedDelegate", js_cocos2dx_JSTouchDelegate_registerTargetedDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "registerStandardDelegate", js_cocos2dx_JSTouchDelegate_registerStandardDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "unregisterTouchDelegate", js_cocos2dx_JSTouchDelegate_unregisterTouchDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.CallFunc; })()")); JS_DefineFunction(cx, tmpObj, "create", js_callFunc, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.SAXParser; })()")); JS_DefineFunction(cx, tmpObj, "getInstance", js_SAXParser_getInstance, 0, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.SAXParser.getInstance(); })()")); JS_DefineFunction(cx, tmpObj, "parse", js_SAXParser_parse, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "preloadPlist", js_SAXParser_preloadPlist, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "unloadPlist", js_SAXParser_unloadPlist, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "getList", js_SAXParser_getList, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.GLProgram; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCGLProgram_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "createWithString", js_cocos2dx_CCGLProgram_createWithString, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return this; })()")); JS_DefineFunction(cx, tmpObj, "garbageCollect", js_forceGC, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "glEnableVertexAttribs", js_cocos2dx_ccGLEnableVertexAttribs, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pAdd", js_cocos2dx_ccpAdd, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pDistanceSQ", js_cocos2dx_ccpDistanceSQ, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pDistance", js_cocos2dx_ccpDistance, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pSub", js_cocos2dx_ccpSub, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pNeg", js_cocos2dx_ccpNeg, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pMult", js_cocos2dx_ccpMult, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pMidpoint", js_cocos2dx_ccpMidpoint, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pDot", js_cocos2dx_ccpDot, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pCross", js_cocos2dx_ccpCross, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pPerp", js_cocos2dx_ccpPerp, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pRPerp", js_cocos2dx_ccpRPerp, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pProject", js_cocos2dx_ccpProject, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pRotate", js_cocos2dx_ccpRotate, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pNormalize", js_cocos2dx_ccpNormalize, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pClamp", js_cocos2dx_ccpClamp, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pLengthSQ", js_cocos2dx_ccpLengthSQ, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ns, "pLength", js_cocos2dx_ccpLength, 1, JSPROP_READONLY | JSPROP_PERMANENT); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp ================================================ #ifndef __JS_COCOS2D_X_SPECIFICS_H__ #define __JS_COCOS2D_X_SPECIFICS_H__ #include "jsapi.h" #include "ScriptingCore.h" #include "platform/CCSAXParser.h" class JSScheduleWrapper; // JSScheduleWrapper* --> Array* since one js function may correspond to many targets. // To debug this, you could refer to JSScheduleWrapper::dump function. // It will prove that i'm right. :) typedef struct jsScheduleFunc_proxy { JSObject* jsfuncObj; cocos2d::Array* targets; UT_hash_handle hh; } schedFunc_proxy_t; typedef struct jsScheduleTarget_proxy { JSObject* jsTargetObj; cocos2d::Array* targets; UT_hash_handle hh; } schedTarget_proxy_t; typedef struct jsCallFuncTarget_proxy { void * ptr; cocos2d::Array *obj; UT_hash_handle hh; } callfuncTarget_proxy_t; extern schedFunc_proxy_t *_schedFunc_target_ht; extern schedTarget_proxy_t *_schedObj_target_ht; extern callfuncTarget_proxy_t *_callfuncTarget_native_ht; /** * You don't need to manage the returned pointer. They live for the whole life of * the app. */ template inline js_type_class_t *js_get_type_from_native(T* native_obj) { bool found = false; std::string typeName = typeid(*native_obj).name(); auto typeProxyIter = _js_global_type_map.find(typeName); if (typeProxyIter == _js_global_type_map.end()) { typeName = typeid(T).name(); typeProxyIter = _js_global_type_map.find(typeName); if (typeProxyIter != _js_global_type_map.end()) { found = true; } } else { found = true; } return found ? typeProxyIter->second : nullptr; } /** * The returned pointer should be deleted using jsb_remove_proxy. Most of the * time you do that in the C++ destructor. */ template inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) { js_proxy_t *proxy; HASH_FIND_PTR(_native_js_global_ht, &native_obj, proxy); if (!proxy) { js_type_class_t *typeProxy = js_get_type_from_native(native_obj); // Return NULL if can't find its type rather than making an assert. // assert(typeProxy); if (!typeProxy) { CCLOGINFO("Could not find the type of native object."); return NULL; } JSObject* js_obj = JS_NewObject(cx, typeProxy->jsclass, typeProxy->proto, typeProxy->parentProto); proxy = jsb_new_proxy(native_obj, js_obj); #ifdef DEBUG JS_AddNamedObjectRoot(cx, &proxy->obj, typeid(*native_obj).name()); #else JS_AddObjectRoot(cx, &proxy->obj); #endif return proxy; } else { return proxy; } return NULL; } jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string); void register_cocos2dx_js_extensions(JSContext* cx, JSObject* obj); class JSCallbackWrapper: public cocos2d::Object { public: JSCallbackWrapper(); virtual ~JSCallbackWrapper(); void setJSCallbackFunc(jsval obj); void setJSCallbackThis(jsval thisObj); void setJSExtraData(jsval data); const jsval& getJSCallbackFunc() const; const jsval& getJSCallbackThis() const; const jsval& getJSExtraData() const; protected: jsval _jsCallback; jsval _jsThisObj; jsval _extraData; }; class JSScheduleWrapper: public JSCallbackWrapper { public: JSScheduleWrapper() : _pTarget(NULL), _pPureJSTarget(NULL), _priority(0), _isUpdateSchedule(false) {} virtual ~JSScheduleWrapper(); static void setTargetForSchedule(jsval sched, JSScheduleWrapper *target); static cocos2d::Array * getTargetForSchedule(jsval sched); static void setTargetForJSObject(JSObject* jsTargetObj, JSScheduleWrapper *target); static cocos2d::Array * getTargetForJSObject(JSObject* jsTargetObj); // Remove all targets. static void removeAllTargets(); // Remove all targets for priority. static void removeAllTargetsForMinPriority(int minPriority); // Remove all targets by js object from hash table(_schedFunc_target_ht and _schedObj_target_ht). static void removeAllTargetsForJSObject(JSObject* jsTargetObj); // Remove the target by js object and the wrapper for native schedule. static void removeTargetForJSObject(JSObject* jsTargetObj, JSScheduleWrapper* target); static void dump(); void pause(); void scheduleFunc(float dt); virtual void update(float dt); Object* getTarget(); void setTarget(Object* pTarget); void setPureJSTarget(JSObject* jstarget); JSObject* getPureJSTarget(); void setPriority(int priority); int getPriority(); void setUpdateSchedule(bool isUpdateSchedule); bool isUpdateSchedule(); protected: Object* _pTarget; JSObject* _pPureJSTarget; int _priority; bool _isUpdateSchedule; }; class JSTouchDelegate: public cocos2d::Object { public: JSTouchDelegate(); ~JSTouchDelegate(); // Set the touch delegate to map by using the key (pJSObj). static void setDelegateForJSObject(JSObject* pJSObj, JSTouchDelegate* pDelegate); // Get the touch delegate by the key (pJSObj). static JSTouchDelegate* getDelegateForJSObject(JSObject* pJSObj); // Remove the delegate by the key (pJSObj). static void removeDelegateForJSObject(JSObject* pJSObj); void setJSObject(JSObject *obj); void registerStandardDelegate(int priority); void registerTargetedDelegate(int priority, bool swallowsTouches); // unregister touch delegate. // Normally, developer should invoke cc.unregisterTouchDelegate() in when the scene exits. // So this function need to be binded. void unregisterTouchDelegate(); bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event); void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event); void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event); void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event); // optional void onTouchesBegan(const std::vector& touches, cocos2d::Event *event); void onTouchesMoved(const std::vector& touches, cocos2d::Event *event); void onTouchesEnded(const std::vector& touches, cocos2d::Event *event); void onTouchesCancelled(const std::vector& touches, cocos2d::Event *event); private: JSObject* _obj; typedef std::unordered_map TouchDelegateMap; typedef std::pair TouchDelegatePair; static TouchDelegateMap sTouchDelegateMap; bool _needUnroot; cocos2d::EventListenerTouchOneByOne* _touchListenerOneByOne; cocos2d::EventListenerTouchAllAtOnce* _touchListenerAllAtOnce; }; class CC_DLL __JSSAXDelegator: public cocos2d::SAXDelegator { public: static __JSSAXDelegator* getInstance() { static __JSSAXDelegator* pInstance = NULL; if (pInstance == NULL) { pInstance = new __JSSAXDelegator(); } return pInstance; }; ~__JSSAXDelegator(); cocos2d::SAXParser* getParser(); std::string parse(const std::string& path); bool preloadPlist(const std::string& path) { return true; } std::string getList(const std::string& path) { return path; } // implement pure virtual methods of SAXDelegator void startElement(void *ctx, const char *name, const char **atts); void endElement(void *ctx, const char *name); void textHandler(void *ctx, const char *ch, int len); private: cocos2d::SAXParser _parser; JSObject* _obj; std::string _result; bool _isStoringCharacters; std::string _currentValue; }; #endif ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocosbuilder/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := jsb_builder_static LOCAL_MODULE_FILENAME := libcocos2dxjsbbuilder LOCAL_SRC_FILES := js_bindings_ccbreader.cpp \ ../../../auto-generated/js-bindings/jsb_cocos2dx_builder_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../../editor-support/cocosbuilder LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,scripting/javascript/bindings) $(call import-module,editor-support/cocosbuilder) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocosbuilder/cocosbuilder_specifics.hpp ================================================ #ifndef __JS_COCOSBUILDER_SPECIFICS_H__ #define __JS_COCOSBUILDER_SPECIFICS_H__ #include "../cocos2d_specifics.hpp" class JSCCBAnimationWrapper: public JSCallbackWrapper { public: JSCCBAnimationWrapper() {} virtual ~JSCCBAnimationWrapper() {} void animationCompleteCallback() { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); jsval retval = JSVAL_NULL; if(!JSVAL_IS_VOID(_jsCallback) && !JSVAL_IS_VOID(_jsThisObj)) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(_jsThisObj), _jsCallback, 0, NULL, &retval); } } }; #endif ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.cpp ================================================ // // js_bindings_ccbreader.cpp // watermelon // // Created by Rohan Kuruvilla on 14/08/2012. // // #include "js_bindings_ccbreader.h" #include "ScriptingCore.h" #include "js_bindings_config.h" USING_NS_CC; USING_NS_CC_EXT; using namespace cocosbuilder; static void removeSelector(std::string &str) { size_t found; found = str.find(":"); while (found!=std::string::npos){ str.replace(found, found+1, ""); found = str.find(":"); } } SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName) { this->callBackProp = pSelectorName; removeSelector(this->callBackProp); return menu_selector(CCBScriptCallbackProxy::menuItemCallback); } Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { this->callBackProp = pSelectorName; removeSelector(this->callBackProp); return cccontrol_selector(CCBScriptCallbackProxy::controlCallback); } bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(Object * pTarget, const char * pMemberVariableName, Node * pNode) { return true; } void CCBScriptCallbackProxy::onNodeLoaded(Node * pNode, NodeLoader * pNodeLoader) {} CCBSelectorResolver * CCBScriptCallbackProxy::createNew() { CCBScriptCallbackProxy * ret = new CCBScriptCallbackProxy(); ret->setJSOwner(this->owner); return dynamic_cast(ret); } void CCBScriptCallbackProxy::menuItemCallback(Object *pSender) { ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); } void CCBScriptCallbackProxy::controlCallback(Object *pSender, Control::EventType event) { ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str() ); } void CCBScriptCallbackProxy::setCallbackProperty(const char *prop) { callBackProp = prop; } void CCBScriptCallbackProxy::setJSOwner(jsval ownr) { owner = ownr; } jsval CCBScriptCallbackProxy::getJSOwner() { return owner; } JSBool js_cocos2dx_CCBAnimationManager_animationCompleteCallback(JSContext *cx, uint32_t argc, jsval *vp) { if (argc >= 1) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocosbuilder::CCBAnimationManager *node = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); JSCCBAnimationWrapper *tmpCobj = new JSCCBAnimationWrapper(); tmpCobj->autorelease(); tmpCobj->setJSCallbackThis(argv[0]); if(argc >= 2) { tmpCobj->setJSCallbackFunc(argv[1]); } node->setAnimationCompletedCallback(tmpCobj, callfunc_selector(JSCCBAnimationWrapper::animationCompleteCallback)); JS_SetReservedSlot(proxy->obj, 0, argv[0]); JS_SetReservedSlot(proxy->obj, 1, argv[1]); return JS_TRUE; } return JS_FALSE; } JSBool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj; cocosbuilder::CCBReader* cobj; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); cocos2d::Object* arg1; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1) } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0, arg1); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); cocos2d::Object* arg1; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1) } while (0); cocos2d::Size arg2; ok &= jsval_to_ccsize(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0, arg1, arg2); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } return JS_FALSE; } JSBool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj; cocosbuilder::CCBReader* cobj; obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, cobj) if (argc == 2) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); cocos2d::Object* arg1; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1) } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0, arg1); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } if (argc == 3) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); cocos2d::Object* arg1; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); proxy = jsb_get_js_proxy(tmpObj); arg1 = (cocos2d::Object*)(proxy ? proxy->ptr : NULL); TEST_NATIVE_OBJECT(cx, arg1) } while (0); cocos2d::Size arg2; ok &= jsval_to_ccsize(cx, argv[2], &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0, arg1, arg2); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } return JS_FALSE; } JSBool js_CocosBuilder_create(JSContext *cx, uint32_t argc, jsval *vp) { NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::getInstance(); ccNodeLoaderLibrary->registerNodeLoader("", JSLayerLoader::loader()); CCBReader * ret = new CCBReader(ccNodeLoaderLibrary); ret->autorelease(); jsval jsret; if (ret) { js_proxy_t *proxy = jsb_get_native_proxy(ret); if (proxy) { jsret = OBJECT_TO_JSVAL(proxy->obj); } else { // create a new js obj of that class proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } } else { jsret = JSVAL_NULL; } JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } extern JSObject* jsb_cocosbuilder_CCBReader_prototype; extern JSObject* jsb_cocosbuilder_CCBAnimationManager_prototype; void register_CCBuilderReader(JSContext *cx, JSObject *obj) { JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "cc", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "cc", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, obj, "(function () { return cc._Reader; })()")); JS_DefineFunction(cx, tmpObj, "create", js_CocosBuilder_create, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, tmpObj, "loadScene", js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocosbuilder_CCBReader_prototype, "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocosbuilder_CCBAnimationManager_prototype, "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocosbuilder/js_bindings_ccbreader.h ================================================ // // js_bindings_ccbreader.h // watermelon // // Created by Rohan Kuruvilla on 14/08/2012. // // #ifndef __JS_BINDINGS_CCBREADER_H__ #define __JS_BINDINGS_CCBREADER_H__ #include "jsapi.h" #include "cocosbuilder_specifics.hpp" #include "cocosbuilder/CocosBuilder.h" class CCBScriptCallbackProxy: public cocos2d::Layer , public cocosbuilder::CCBSelectorResolver , public cocosbuilder::CCBMemberVariableAssigner { std::string callBackProp; jsval owner; public: CCBScriptCallbackProxy () {} virtual ~CCBScriptCallbackProxy() {} CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); virtual void onNodeLoaded(cocos2d::Node * pNode, cocosbuilder::NodeLoader * pNodeLoader); virtual CCBSelectorResolver * createNew(); void menuItemCallback(Object *pSender); void controlCallback(Object *pSender, cocos2d::extension::Control::EventType event); void setCallbackProperty(const char *prop); void setJSOwner(jsval ownr); jsval getJSOwner(); }; class JSLayerLoader : public cocosbuilder::LayerLoader { public: CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(JSLayerLoader, loader); protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBScriptCallbackProxy); }; void register_CCBuilderReader(JSContext *cx, JSObject *global); JSBool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp); #endif /* __JS_BINDINGS_CCBREADER_H__ */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj ================================================  Debug Win32 Release Win32 {F9DA0FC1-651B-457B-962E-A4D61CEBF5FD} Win32Proj libJSBindingForBuilder StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false Windows true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocosbuilder/libJSBindingForBuilder.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx generated manual generated manual manual generated ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocostudio/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := jsb_studio_static LOCAL_MODULE_FILENAME := libcocos2dxjsbstudio LOCAL_SRC_FILES := jsb_cocos2dx_studio_manual.cpp \ ../../../auto-generated/js-bindings/jsb_cocos2dx_studio_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../../../extensions \ $(LOCAL_PATH)/../../../../editor-support/cocostudio LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,scripting/javascript/bindings) $(call import-module,editor-support/cocostudio) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp ================================================ // // jsb_cocos2dx_studio_manual.h // // Created by LinWenhai on 20/10/13. // // #include "jsb_cocos2dx_studio_manual.h" #include "ScriptingCore.h" #include "cocos2d_specifics.hpp" #include "cocostudio/CocoStudio.h" class JSArmatureWrapper: public JSCallbackWrapper { public: JSArmatureWrapper(); virtual ~JSArmatureWrapper(); virtual void setJSCallbackThis(jsval thisObj); void movementCallbackFunc(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID); void frameCallbackFunc(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); void addArmatureFileInfoAsyncCallbackFunc(float percent); private: bool m_bNeedUnroot; }; JSArmatureWrapper::JSArmatureWrapper() : m_bNeedUnroot(false) { } JSArmatureWrapper::~JSArmatureWrapper() { if (m_bNeedUnroot) { JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj); JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &thisObj); } } void JSArmatureWrapper::setJSCallbackThis(jsval _jsThisObj) { JSCallbackWrapper::setJSCallbackThis(_jsThisObj); JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj); js_proxy *p = jsb_get_js_proxy(thisObj); if (!p) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddObjectRoot(cx, &thisObj); m_bNeedUnroot = true; } } void JSArmatureWrapper::movementCallbackFunc(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); js_proxy_t *proxy = js_get_or_create_proxy(cx, armature); jsval retval; if (_jsCallback != JSVAL_VOID) { int movementEventType = (int)movementType; jsval movementVal = INT_TO_JSVAL(movementEventType); jsval idVal = std_string_to_jsval(cx, movementID); jsval valArr[3]; valArr[0] = OBJECT_TO_JSVAL(proxy->obj); valArr[1] = movementVal; valArr[2] = idVal; JS_AddValueRoot(cx, valArr); JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS_CallFunctionValue(cx, thisObj, _jsCallback, 3, valArr, &retval); JS_RemoveValueRoot(cx, valArr); } } void JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc(float percent) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); jsval retval; if (_jsCallback != JSVAL_VOID) { jsval percentVal = DOUBLE_TO_JSVAL(percent); JS_AddValueRoot(cx, &percentVal); JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS_CallFunctionValue(cx, thisObj, _jsCallback, 1, &percentVal, &retval); JS_RemoveValueRoot(cx, &percentVal); } } void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); js_proxy_t *proxy = js_get_or_create_proxy(cx, bone); jsval retval; if (_jsCallback != JSVAL_VOID) { jsval nameVal = std_string_to_jsval(cx, evt); jsval originIndexVal = INT_TO_JSVAL(originFrameIndex); jsval currentIndexVal = INT_TO_JSVAL(currentFrameIndex); jsval valArr[4]; valArr[0] = OBJECT_TO_JSVAL(proxy->obj); valArr[1] = nameVal; valArr[2] = originIndexVal; valArr[3] = currentIndexVal; JS_AddValueRoot(cx, valArr); JS_CallFunctionValue(cx, thisObj, _jsCallback, 4, valArr, &retval); JS_RemoveValueRoot(cx, valArr); } } static JSBool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); cobj->setUserObject(tmpObj); tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); cobj->setMovementEventCallFunc(CC_CALLBACK_0(JSArmatureWrapper::movementCallbackFunc, tmpObj, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); cobj->setUserObject(tmpObj); tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); cobj->setFrameEventCallFunc(CC_CALLBACK_0(JSArmatureWrapper::frameCallbackFunc, tmpObj, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 3) { jsval *argv = JS_ARGV(cx, vp); JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); tmpObj->autorelease(); tmpObj->setJSCallbackFunc(argv[1]); tmpObj->setJSCallbackThis(argv[2]); std::string ret; jsval_to_std_string(cx, argv[0], &ret); cobj->addArmatureFileInfoAsync(ret.c_str(), tmpObj, schedule_selector(JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc)); return JS_TRUE; } if(argc == 5){ jsval *argv = JS_ARGV(cx, vp); JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); tmpObj->autorelease(); tmpObj->setJSCallbackFunc(argv[3]); tmpObj->setJSCallbackThis(argv[4]); std::string imagePath; jsval_to_std_string(cx ,argv[0] , &imagePath); std::string plistPath; jsval_to_std_string(cx ,argv[1] , &plistPath); std::string configFilePath; jsval_to_std_string(cx ,argv[2] , &configFilePath); cobj->addArmatureFileInfoAsync(imagePath.c_str(), plistPath.c_str(), configFilePath.c_str(), tmpObj, schedule_selector(JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } JSBool js_cocos2dx_studio_ColliderBody_getCalculatedVertexList(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::ColliderBody* cobj = (cocostudio::ColliderBody *)(proxy ? proxy->ptr : nullptr); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { const std::vector& ret = cobj->getCalculatedVertexList(); JSObject *jsretArr = JS_NewArrayObject(cx, 0, nullptr); jsval jsret; //CCObject* obj; int i = 0; for(std::vector::const_iterator it = ret.begin(); it != ret.end(); it++) { const cocos2d::Point& point = *it; JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) break; JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(point.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(point.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); jsval jsTmp = OBJECT_TO_JSVAL(tmp); if(!ok || !JS_SetElement(cx, jsretArr, i, &jsTmp)) { break; } ++i; } jsret = OBJECT_TO_JSVAL(jsretArr); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject* jsb_cocostudio_ArmatureAnimation_prototype; extern JSObject* jsb_cocostudio_ArmatureDataManager_prototype; extern JSObject* jsb_cocostudio_ColliderBody_prototype; void register_all_cocos2dx_studio_manual(JSContext* cx, JSObject* global) { JS_DefineFunction(cx, jsb_cocostudio_ColliderBody_prototype, "getCalculatedVertexList", js_cocos2dx_studio_ColliderBody_getCalculatedVertexList, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocostudio_ArmatureAnimation_prototype, "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocostudio_ArmatureAnimation_prototype, "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocostudio_ArmatureDataManager_prototype, "addArmatureFileInfoAsync", jsb_Animation_addArmatureFileInfoAsyncCallFunc, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.h ================================================ // // jsb_cocos2dx_studio_manual.h // // Created by LinWenhai on 20/10/13. // // #ifndef __jsb_cocos2dx_studio_manual__ #define __jsb_cocos2dx_studio_manual__ #include "jsapi.h" #include "jsfriendapi.h" void register_all_cocos2dx_studio_manual(JSContext* cx, JSObject* global); #endif /* defined(__jsb_cocos2dx_studio_manual__) */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj ================================================  Debug Win32 Release Win32 {79D34511-E54E-410A-8BBA-EF175AD6C695} Win32Proj libJSBindingForStudio StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false Windows true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/cocostudio/libJSBindingForStudio.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx generated manual generated manual generated ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/extension/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := jsb_extension_static LOCAL_MODULE_FILENAME := libcocos2dxjsbextension LOCAL_SRC_FILES := jsb_cocos2dx_extension_manual.cpp \ ../../../auto-generated/js-bindings/jsb_cocos2dx_extension_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../../../extensions LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../../../ LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,scripting/javascript/bindings) $(call import-module,extensions) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp ================================================ // // jsb_cocos2d_extension_manual.cpp // // Created by James Chen on 3/11/13. // // #include "jsb_cocos2dx_extension_manual.h" #include "extensions/cocos-ext.h" #include "ScriptingCore.h" #include "cocos2d_specifics.hpp" USING_NS_CC; USING_NS_CC_EXT; class JSB_ScrollViewDelegate : public Object , public ScrollViewDelegate { public: JSB_ScrollViewDelegate() : _JSDelegate(NULL) , _needUnroot(false) {} virtual ~JSB_ScrollViewDelegate() { if (_needUnroot) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &_JSDelegate); } } virtual void scrollViewDidScroll(ScrollView* view) override { js_proxy_t * p = jsb_get_native_proxy(view); if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidScroll", 1, &arg, NULL); } virtual void scrollViewDidZoom(ScrollView* view) override { js_proxy_t * p = jsb_get_native_proxy(view); if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidZoom", 1, &arg, NULL); } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; // Check whether the js delegate is a pure js object. js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); if (!p) { _needUnroot = true; JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); } } private: JSObject* _JSDelegate; bool _needUnroot; }; static JSBool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setUserObject(nativeDelegate); cobj->setDelegate(nativeDelegate); nativeDelegate->release(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } #define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource" #define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" class JSB_TableViewDelegate : public Object , public TableViewDelegate { public: JSB_TableViewDelegate() : _JSDelegate(NULL) , _needUnroot(false) {} virtual ~JSB_TableViewDelegate() { if (_needUnroot) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &_JSDelegate); } } virtual void scrollViewDidScroll(ScrollView* view) override { callJSDelegate(view, "scrollViewDidScroll"); } virtual void scrollViewDidZoom(ScrollView* view) override { callJSDelegate(view, "scrollViewDidZoom"); } virtual void tableCellTouched(TableView* table, TableViewCell* cell) override { callJSDelegate(table, cell, "tableCellTouched"); } virtual void tableCellHighlight(TableView* table, TableViewCell* cell) override { callJSDelegate(table, cell, "tableCellHighlight"); } virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) override { callJSDelegate(table, cell, "tableCellUnhighlight"); } virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) override { callJSDelegate(table, cell, "tableCellWillRecycle"); } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; // Check whether the js delegate is a pure js object. js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); if (!p) { _needUnroot = true; JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); } } private: void callJSDelegate(ScrollView* view, std::string jsFunctionName) { js_proxy_t * p = jsb_get_native_proxy(view); if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 1, &arg, NULL); } void callJSDelegate(TableView* table, TableViewCell* cell, std::string jsFunctionName) { js_proxy_t * p = jsb_get_native_proxy(table); if (!p) return; js_proxy_t * pCellProxy = jsb_get_native_proxy(cell); if (!pCellProxy) return; jsval args[2]; args[0] = OBJECT_TO_JSVAL(p->obj); args[1] = OBJECT_TO_JSVAL(pCellProxy->obj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 2, args, NULL); } JSObject* _JSDelegate; bool _needUnroot; }; static JSBool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); JSB_TableViewDelegate* nativeDelegate = new JSB_TableViewDelegate(); nativeDelegate->setJSDelegate(jsDelegate); Dictionary* userDict = static_cast(cobj->getUserObject()); if (NULL == userDict) { userDict = new Dictionary(); cobj->setUserObject(userDict); userDict->release(); } userDict->setObject(nativeDelegate, KEY_TABLEVIEW_DELEGATE); cobj->setDelegate(nativeDelegate); nativeDelegate->release(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } class JSB_TableViewDataSource : public Object , public TableViewDataSource { public: JSB_TableViewDataSource() : _JSTableViewDataSource(NULL) , _needUnroot(false) {} virtual ~JSB_TableViewDataSource() { if (_needUnroot) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &_JSTableViewDataSource); } } virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) override { jsval ret; bool ok = callJSDelegate(table, idx, "tableCellSizeForIndex", ret); if (!ok) { ok = callJSDelegate(table, "cellSizeForTable", ret); } if (ok) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); Size size; JSBool isSucceed = jsval_to_ccsize(cx, ret, &size); if (isSucceed) return size; } return Size::ZERO; } virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) override { jsval ret; bool ok = callJSDelegate(table, idx, "tableCellAtIndex", ret); if (ok) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); cocos2d::extension::TableViewCell* arg0; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(ret); proxy = jsb_get_js_proxy(tmpObj); arg0 = (cocos2d::extension::TableViewCell*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, NULL, "Invalid Native Object"); } while (0); return arg0; } return NULL; } virtual ssize_t numberOfCellsInTableView(TableView *table) override { jsval ret; bool ok = callJSDelegate(table, "numberOfCellsInTableView", ret); if (ok) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); ssize_t count = 0; JSBool isSucceed = jsval_to_ssize(cx, ret, &count); if (isSucceed) return count; } return 0; } void setTableViewDataSource(JSObject* pJSSource) { _JSTableViewDataSource = pJSSource; // Check whether the js delegate is a pure js object. js_proxy_t* p = jsb_get_js_proxy(_JSTableViewDataSource); if (!p) { _needUnroot = true; JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddNamedObjectRoot(cx, &_JSTableViewDataSource, "TableViewDataSource"); } } private: bool callJSDelegate(TableView* table, std::string jsFunctionName, jsval& retVal) { js_proxy_t * p = jsb_get_native_proxy(table); if (!p) return false; JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JSBool hasAction; JS::RootedValue temp_retval(cx); jsval dataVal = OBJECT_TO_JSVAL(p->obj); JSObject* obj = _JSTableViewDataSource; JSAutoCompartment ac(cx, obj); if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) { if(!JS_GetProperty(cx, obj, jsFunctionName.c_str(), &temp_retval)) { return false; } if(temp_retval == JSVAL_VOID) { return false; } JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), 1, &dataVal, &retVal); return true; } return false; } bool callJSDelegate(TableView* table, ssize_t idx, std::string jsFunctionName, jsval& retVal) { js_proxy_t * p = jsb_get_native_proxy(table); if (!p) return false; JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JSBool hasAction; JS::RootedValue temp_retval(cx); jsval dataVal[2]; dataVal[0] = OBJECT_TO_JSVAL(p->obj); dataVal[1] = ssize_to_jsval(cx,idx); JSObject* obj = _JSTableViewDataSource; JSAutoCompartment ac(cx, obj); if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) { if(!JS_GetProperty(cx, obj, jsFunctionName.c_str(), &temp_retval)) { return false; } if(temp_retval == JSVAL_VOID) { return false; } JSBool ret = JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), 2, dataVal, &retVal); return ret == JS_TRUE ? true : false; } return false; } private: JSObject* _JSTableViewDataSource; bool _needUnroot; }; static JSBool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); Dictionary* userDict = static_cast(cobj->getUserObject()); if (NULL == userDict) { userDict = new Dictionary(); cobj->setUserObject(userDict); userDict->release(); } userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); cobj->setDataSource(pNativeSource); pNativeSource->release(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3 || argc == 2) { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, argv[1], &arg1); cocos2d::extension::TableView* ret = NULL; ret = new TableView(); ret->autorelease(); ret->setDataSource(pNativeSource); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); if (argc == 2) { ret->initWithViewSize(arg1); } else { cocos2d::Node* arg2; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); ret->initWithViewSize(arg1, arg2); } ret->reloadData(); Dictionary* userDict = new Dictionary(); userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); ret->setUserObject(userDict); userDict->release(); pNativeSource->release(); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } class JSB_EditBoxDelegate : public Object , public EditBoxDelegate { public: JSB_EditBoxDelegate() : _JSDelegate(NULL) , _needUnroot(false) {} virtual ~JSB_EditBoxDelegate() { if (_needUnroot) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &_JSDelegate); } } virtual void editBoxEditingDidBegin(EditBox* editBox) override { js_proxy_t * p = jsb_get_native_proxy(editBox); if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidBegin", 1, &arg, NULL); } virtual void editBoxEditingDidEnd(EditBox* editBox) override { js_proxy_t * p = jsb_get_native_proxy(editBox); if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidEnd", 1, &arg, NULL); } virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) override { js_proxy_t * p = jsb_get_native_proxy(editBox); if (!p) return; jsval dataVal[2]; dataVal[0] = OBJECT_TO_JSVAL(p->obj); std::string arg1 = text; dataVal[1] = std_string_to_jsval(ScriptingCore::getInstance()->getGlobalContext(), arg1); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxTextChanged", 2, dataVal, NULL); } virtual void editBoxReturn(EditBox* editBox) override { js_proxy_t * p = jsb_get_native_proxy(editBox); if (!p) return; jsval arg = OBJECT_TO_JSVAL(p->obj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxReturn", 1, &arg, NULL); } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; // Check whether the js delegate is a pure js object. js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); if (!p) { _needUnroot = true; JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); } } private: JSObject* _JSDelegate; bool _needUnroot; }; static JSBool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::EditBox* cobj = (cocos2d::extension::EditBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); JSB_EditBoxDelegate* nativeDelegate = new JSB_EditBoxDelegate(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setUserObject(nativeDelegate); cobj->setDelegate(nativeDelegate); nativeDelegate->release(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } class JSB_ControlButtonTarget : public Object { public: JSB_ControlButtonTarget() : _jsFunc(nullptr), _type(Control::EventType::TOUCH_DOWN), _jsTarget(nullptr), _needUnroot(false) {} virtual ~JSB_ControlButtonTarget() { CCLOGINFO("In the destruction of JSB_ControlButtonTarget ..."); JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); if (_needUnroot) { JS_RemoveObjectRoot(cx, &_jsTarget); } JS_RemoveObjectRoot(cx, &_jsFunc); for (auto iter = _jsNativeTargetMap.begin(); iter != _jsNativeTargetMap.end(); ++iter) { if (this == iter->second) { _jsNativeTargetMap.erase(iter); break; } } } virtual void onEvent(Object *controlButton, Control::EventType event) { js_proxy_t * p; JS_GET_PROXY(p, controlButton); if (!p) { log("Failed to get proxy for control button"); return; } jsval dataVal[2]; dataVal[0] = OBJECT_TO_JSVAL(p->obj); int arg1 = (int)event; dataVal[1] = INT_TO_JSVAL(arg1); jsval jsRet; ScriptingCore::getInstance()->executeJSFunctionWithThisObj(OBJECT_TO_JSVAL(_jsTarget), OBJECT_TO_JSVAL(_jsFunc), 2, dataVal, &jsRet); } void setJSTarget(JSObject* pJSTarget) { _jsTarget = pJSTarget; js_proxy_t* p = jsb_get_js_proxy(_jsTarget); if (!p) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddNamedObjectRoot(cx, &_jsTarget, "JSB_ControlButtonTarget, target"); _needUnroot = true; } } void setJSAction(JSObject* jsFunc) { _jsFunc = jsFunc; JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddNamedObjectRoot(cx, &_jsFunc, "JSB_ControlButtonTarget, func"); } void setEventType(Control::EventType type) { _type = type; } public: static std::multimap _jsNativeTargetMap; JSObject* _jsFunc; Control::EventType _type; private: JSObject* _jsTarget; bool _needUnroot; }; std::multimap JSB_ControlButtonTarget::_jsNativeTargetMap; static JSBool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); JSBool ok = JS_TRUE; if (argc == 3) { JSObject* jsDelegate = JSVAL_TO_OBJECT(argv[0]); JSObject* jsFunc = JSVAL_TO_OBJECT(argv[1]); Control::EventType arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing control event"); // Check whether the target already exists. auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(jsDelegate); for (auto it = range.first; it != range.second; ++it) { if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) { // Return true directly. JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } } // save the delegate JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget(); nativeDelegate->setJSTarget(jsDelegate); nativeDelegate->setJSAction(jsFunc); nativeDelegate->setEventType(arg2); Array* nativeDelegateArray = static_cast(cobj->getUserObject()); if (nullptr == nativeDelegateArray) { nativeDelegateArray = new Array(); nativeDelegateArray->init(); cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2 nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1 } nativeDelegateArray->addObject(nativeDelegate); // The reference of nativeDelegate is added to 2 nativeDelegate->release(); // Release nativeDelegate to make the reference to 1 cobj->addTargetWithActionForControlEvents(nativeDelegate, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2); JSB_ControlButtonTarget::_jsNativeTargetMap.insert(std::make_pair(jsDelegate, nativeDelegate)); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } static JSBool js_cocos2dx_CCControl_removeTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); JSBool ok = JS_TRUE; if (argc == 3) { Control::EventType arg2; ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing control event"); obj = JSVAL_TO_OBJECT(argv[0]); JSObject* jsFunc = JSVAL_TO_OBJECT(argv[1]); JSB_ControlButtonTarget* nativeTargetToRemoved = nullptr; auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(obj); for (auto it = range.first; it != range.second; ++it) { if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) { nativeTargetToRemoved = it->second; JSB_ControlButtonTarget::_jsNativeTargetMap.erase(it); break; } } cobj->removeTargetWithActionForControlEvents(nativeTargetToRemoved, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); return JS_FALSE; } extern JSObject* jsb_cocos2d_extension_ScrollView_prototype; extern JSObject* jsb_cocos2d_extension_TableView_prototype; extern JSObject* jsb_cocos2d_extension_EditBox_prototype; extern JSObject* jsb_cocos2d_extension_Control_prototype; void register_all_cocos2dx_extension_manual(JSContext* cx, JSObject* global) { JS_DefineFunction(cx, jsb_cocos2d_extension_ScrollView_prototype, "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_extension_TableView_prototype, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_extension_TableView_prototype, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_extension_EditBox_prototype, "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_extension_Control_prototype, "addTargetWithActionForControlEvents", js_cocos2dx_CCControl_addTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_extension_Control_prototype, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.TableView; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.h ================================================ // // jsb_cocos2d_extension_manual.h // // Created by James Chen on 3/11/13. // // #ifndef __jsb_cocos2dx_extension_manual__ #define __jsb_cocos2dx_extension_manual__ #include "jsapi.h" #include "jsfriendapi.h" void register_all_cocos2dx_extension_manual(JSContext* cx, JSObject* global); #endif /* defined(__jsb_cocos2dx_extension_manual__) */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj ================================================  Debug Win32 Release Win32 {625F7391-9A91-48A1-8CFC-79508C822637} Win32Proj libJSBindingForExtension StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\network;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false Windows true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\network;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/extension/libJSBindingForExtension.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx generated manual generated manual generated ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/gui/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := jsb_gui_static LOCAL_MODULE_FILENAME := libcocos2dxjsbgui LOCAL_SRC_FILES := jsb_cocos2dx_gui_manual.cpp \ ../../../auto-generated/js-bindings/jsb_cocos2dx_gui_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../../../extensions \ $(LOCAL_PATH)/../../../../gui LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_gui_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,scripting/javascript/bindings) $(call import-module,gui) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp ================================================ // // jsb_cocos2dx_gui_manual.h // // Created by LinWenhai on 17/11/13. // // #include "jsb_cocos2dx_gui_manual.h" #include "ScriptingCore.h" #include "cocos2d_specifics.hpp" #include "gui/CocosGUI.h" using namespace cocos2d; using namespace cocos2d::gui; class JSStudioEventListenerWrapper: public JSCallbackWrapper { public: JSStudioEventListenerWrapper(); virtual ~JSStudioEventListenerWrapper(); virtual void setJSCallbackThis(jsval thisObj); virtual void eventCallbackFunc(Object*,int); private: bool m_bNeedUnroot; }; JSStudioEventListenerWrapper::JSStudioEventListenerWrapper() : m_bNeedUnroot(false) { } JSStudioEventListenerWrapper::~JSStudioEventListenerWrapper() { if (m_bNeedUnroot) { JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj); JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS_RemoveObjectRoot(cx, &thisObj); } } void JSStudioEventListenerWrapper::setJSCallbackThis(jsval jsThisObj) { JSCallbackWrapper::setJSCallbackThis(jsThisObj); JSObject *thisObj = JSVAL_TO_OBJECT(jsThisObj); js_proxy *p = jsb_get_js_proxy(thisObj); if (!p) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS_AddObjectRoot(cx, &thisObj); m_bNeedUnroot = true; } } void JSStudioEventListenerWrapper::eventCallbackFunc(Object* sender,int eventType) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); js_proxy_t *proxy = js_get_or_create_proxy(cx, sender); jsval retval; if (_jsCallback != JSVAL_VOID) { jsval touchVal = INT_TO_JSVAL(eventType); jsval valArr[2]; valArr[0] = OBJECT_TO_JSVAL(proxy->obj); valArr[1] = touchVal; JS_AddValueRoot(cx, valArr); JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS_CallFunctionValue(cx, thisObj, _jsCallback, 2, valArr, &retval); JS_RemoveValueRoot(cx, valArr); } } static JSBool js_cocos2dx_UIWidget_addTouchEventListener(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); gui::Widget* cobj = (gui::Widget *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); cobj->setUserObject(tmpObj); tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); cobj->addTouchEventListener(tmpObj, toucheventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_UICheckBox_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); gui::CheckBox* cobj = (gui::CheckBox *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); cobj->setUserObject(tmpObj); tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); cobj->addEventListenerCheckBox(tmpObj, checkboxselectedeventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_UISlider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); gui::Slider* cobj = (gui::Slider *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); cobj->setUserObject(tmpObj); tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); cobj->addEventListenerSlider(tmpObj, sliderpercentchangedselector(JSStudioEventListenerWrapper::eventCallbackFunc)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_UITextField_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); gui::TextField* cobj = (gui::TextField *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); cobj->setUserObject(tmpObj); tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); cobj->addEventListenerTextField(tmpObj, textfieldeventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_UIPageView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); gui::PageView* cobj = (gui::PageView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); cobj->setUserObject(tmpObj); tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); cobj->addEventListenerPageView(tmpObj, pagevieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_UIListView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); gui::ListView* cobj = (gui::ListView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 2) { jsval *argv = JS_ARGV(cx, vp); JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); cobj->setUserObject(tmpObj); tmpObj->release(); tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); cobj->addEventListenerListView(tmpObj, listvieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); gui::LayoutParameter* cobj = (gui::LayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { jsval *argv = JS_ARGV(cx, vp); JSObject *tmp; JS::RootedValue jsleft(cx), jstop(cx),jsright(cx),jsbottom(cx); double left, top,right,bottom; JSBool ok = argv[0].isObject() && JS_ValueToObject(cx, argv[0], &tmp) && JS_GetProperty(cx, tmp, "left", &jsleft) && JS_GetProperty(cx, tmp, "top", &jstop) && JS_GetProperty(cx, tmp, "right", &jsright) && JS_GetProperty(cx, tmp, "bottom", &jsbottom) && JS_ValueToNumber(cx, jsleft, &left) && JS_ValueToNumber(cx, jstop, &top) && JS_ValueToNumber(cx, jsright, &right) && JS_ValueToNumber(cx, jsbottom, &bottom); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); cobj->setMargin(gui::Margin(left,top,right,bottom)); return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } static JSBool js_cocos2dx_LayoutParameter_getMargin(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); gui::LayoutParameter* cobj = (gui::LayoutParameter *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JS_FALSE; gui::Margin margin = cobj->getMargin(); JSBool ok = JS_DefineProperty(cx, tmp, "left", DOUBLE_TO_JSVAL(margin.left), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "top", DOUBLE_TO_JSVAL(margin.top), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "right", DOUBLE_TO_JSVAL(margin.right), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "bottom", DOUBLE_TO_JSVAL(margin.bottom), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); } else { return JS_FALSE; } return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); return JS_FALSE; } extern JSObject* jsb_cocos2d_gui_Widget_prototype; extern JSObject* jsb_cocos2d_gui_CheckBox_prototype; extern JSObject* jsb_cocos2d_gui_Slider_prototype; extern JSObject* jsb_cocos2d_gui_TextField_prototype; extern JSObject* jsb_cocos2d_gui_LayoutParameter_prototype; extern JSObject* jsb_cocos2d_gui_PageView_prototype; extern JSObject* jsb_cocos2d_gui_ListView_prototype; void register_all_cocos2dx_gui_manual(JSContext* cx, JSObject* global) { JS_DefineFunction(cx, jsb_cocos2d_gui_Widget_prototype, "addTouchEventListener", js_cocos2dx_UIWidget_addTouchEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_gui_CheckBox_prototype, "addEventListenerCheckBox", js_cocos2dx_UICheckBox_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_gui_Slider_prototype, "addEventListenerSlider", js_cocos2dx_UISlider_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_gui_TextField_prototype, "addEventListenerTextField", js_cocos2dx_UITextField_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_gui_PageView_prototype, "addEventListenerPageView", js_cocos2dx_UIPageView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_gui_ListView_prototype, "addEventListenerListView", js_cocos2dx_UIListView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_gui_LayoutParameter_prototype, "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_gui_LayoutParameter_prototype, "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.h ================================================ // // jsb_cocos2dx_gui_manual.h // // Created by LinWenhai on 17/11/13. // // #ifndef __jsb_cocos2dx_gui_manual__ #define __jsb_cocos2dx_gui_manual__ #include "jsapi.h" #include "jsfriendapi.h" void register_all_cocos2dx_gui_manual(JSContext* cx, JSObject* global); #endif /* defined(__jsb_cocos2dx_gui_manual__) */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj ================================================  Debug Win32 Release Win32 {9A844C88-97E8-4E2D-B09A-E138C67D338B} Win32Proj libJSBindingForGui StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false Windows true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/gui/libJSBindingForGui.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx generated manual generated manual generated ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/js_bindings_config.h ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 __JS_BINDINGS_CONFIG_H #define __JS_BINDINGS_CONFIG_H /** @def JSB_ASSERT_ON_FAIL Whether or not to assert when the arguments or conversions are incorrect. It is recommened to turn it off in Release mode. */ #ifndef JSB_ASSERT_ON_FAIL #define JSB_ASSERT_ON_FAIL 0 #endif #if JSB_ASSERT_ON_FAIL #define JSB_PRECONDITION( condition, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) #define JSB_PRECONDITION2( condition, context, ret_value, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) #define ASSERT( condition, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) #else #define JSB_PRECONDITION( condition, ...) do { \ if( ! (condition) ) { \ cocos2d::log("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ cocos2d::log(__VA_ARGS__); \ JSContext* globalContext = ScriptingCore::getInstance()->getGlobalContext(); \ if( ! JS_IsExceptionPending( globalContext ) ) { \ JS_ReportError( globalContext, __VA_ARGS__ ); \ } \ return JS_FALSE; \ } \ } while(0) #define JSB_PRECONDITION2( condition, context, ret_value, ...) do { \ if( ! (condition) ) { \ cocos2d::log("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ cocos2d::log(__VA_ARGS__); \ if( ! JS_IsExceptionPending( context ) ) { \ JS_ReportError( context, __VA_ARGS__ ); \ } \ return ret_value; \ } \ } while(0) #define ASSERT( condition, error_msg) do { \ if( ! (condition) ) { \ CCLOG("jsb: ERROR in %s: %s\n", __FUNCTION__, error_msg); \ return false; \ } \ } while(0) #endif #define JSB_PRECONDITION3( condition, context, ret_value, ...) do { \ if( ! (condition) ) return (ret_value); \ } while(0) /** @def JSB_REPRESENT_LONGLONG_AS_STR When JSB_REPRESENT_LONGLONG_AS_STR is defined, the long long will be represented as JS strings. Otherwise they will be represented as an array of two intengers. It is needed to to use an special representation since there are no 64-bit integers in JS. Representing the long long as string could be a bit slower, but it is easier to debug from JS. Enabled by default. */ #ifndef JSB_REPRESENT_LONGLONG_AS_STR #define JSB_REPRESENT_LONGLONG_AS_STR 1 #endif // JSB_REPRESENT_LONGLONG_AS_STR /** @def JSB_INCLUDE_NS Whether or not it should include JS bindings for basic NS* / Cocoa / CocoaTouch objects. It should be enabled in order to support bindings for any objective-c projects. Not needed for pure C projects. Enabled by default. */ #ifndef JSB_INCLUDE_NS #define JSB_INCLUDE_NS 1 #endif // JSB_INCLUDE_NS /** @def JSB_INCLUDE_COCOS2D Whether or not it should include JS bindings for cocos2d. */ #ifndef JSB_INCLUDE_COCOS2D #define JSB_INCLUDE_COCOS2D 1 #include "cocos2d.h" #if defined(__CC_PLATFORM_IOS) #define JSB_INCLUDE_COCOS2D_IOS 1 #elif defined(__CC_PLATFORM_MAC) #define JSB_INCLUDE_COCOS2D_MAC 1 #endif #endif // JSB_INCLUDE_COCOS2D /** @def JSB_INCLUDE_CHIPMUNK Whether or not it should include JS bindings for Chipmunk */ #ifndef JSB_INCLUDE_CHIPMUNK #define JSB_INCLUDE_CHIPMUNK 1 #endif // JSB_INCLUDE_CHIPMUNK /** @def JSB_INCLUDE_COCOSBUILDERREADER Whether or not it should include JS bindings for CocosBuilder Reader */ #ifndef JSB_INCLUDE_COCOSBUILDERREADER #define JSB_INCLUDE_COCOSBUILDERREADER 1 #endif // JSB_INCLUDE_COCOSBUILDERREADER /** @def JSB_INCLUDE_COCOSDENSHION Whether or not it should include bindings for CocosDenshion (sound engine) */ #ifndef JSB_INCLUDE_COCOSDENSHION #define JSB_INCLUDE_COCOSDENSHION 1 #endif // JSB_INCLUDE_COCOSDENSHION #if JSB_ENABLE_DEBUGGER #define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) \ JSAutoCompartment ac(cx, obj) #else #define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) #endif #define JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET \ JSAutoCompartment __jsb_ac(ScriptingCore::getInstance()->getGlobalContext(), ScriptingCore::getInstance()->getGlobalObject()); /** * @def JSB_DEBUGGER_PORT * The port number, where the client will be listening on */ #define JSB_DEBUGGER_PORT 5086 /** @def JSB_INCLUDE_SYSTEM Whether or not it should include bindings for system components like LocalStorage */ #ifndef JSB_INCLUDE_SYSTEM #define JSB_INCLUDE_SYSTEM 1 #endif // JSB_INCLUDE_SYSTEM /** @def JSB_INCLUDE_OPENGL Whether or not it should include bindings for WebGL / OpenGL ES 2.0 */ #ifndef JSB_INCLUDE_OPENGL #define JSB_INCLUDE_OPENGL 1 #endif // JSB_INCLUDE_OPENGL /** @def JSB_INCLUDE_XMLHTTP Whether or not it should include bindings for XmlHttpRequest */ #ifndef JSB_INCLUDE_XMLHTTP #define JSB_INCLUDE_XMLHTTP 1 #endif // JSB_INCLUDE_XMLHTTP #ifndef JSB_MAX_STACK_QUOTA #define JSB_MAX_STACK_QUOTA 500000 #endif // JSB_MAX_STACK_QUOTA #endif // __JS_BINDINGS_CONFIG_H ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/js_bindings_core.cpp ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 "js_bindings_config.h" #include "js_bindings_core.h" // cocos2d + chipmunk registration files #include "chipmunk/js_bindings_chipmunk_registration.h" //#pragma mark - Hash using namespace cocos2d; typedef struct _hashJSObject { JSObject *jsObject; void *proxy; UT_hash_handle hh; } tHashJSObject; static tHashJSObject *hash = NULL; static tHashJSObject *reverse_hash = NULL; //#pragma mark JSBCore - Helper free functions static void reportError(JSContext *cx, const char *message, JSErrorReport *report) { fprintf(stderr, "%s:%u:%s\n", report->filename ? report->filename : "", (unsigned int) report->lineno, message); }; // Hash of JSObject -> proxy void* jsb_get_proxy_for_jsobject(JSObject *obj) { tHashJSObject *element = NULL; HASH_FIND_PTR(hash, &obj, element); if( element ) return element->proxy; return NULL; } void jsb_set_proxy_for_jsobject(void *proxy, JSObject *obj) { CCASSERT( !jsb_get_proxy_for_jsobject(obj), "Already added. abort"); // printf("Setting proxy for: %p - %p (%s)\n", obj, proxy, [[proxy description] UTF8String] ); tHashJSObject *element = (tHashJSObject*) malloc( sizeof( *element ) ); // XXX: Do not retain it here. // [proxy retain]; element->proxy = proxy; element->jsObject = obj; HASH_ADD_PTR( hash, jsObject, element ); } void jsb_del_proxy_for_jsobject(JSObject *obj) { tHashJSObject *element = NULL; HASH_FIND_PTR(hash, &obj, element); if( element ) { HASH_DEL(hash, element); free(element); } } //#pragma mark Proxy -> JSObject // Reverse hash: Proxy -> JSObject JSObject* jsb_get_jsobject_for_proxy(void *proxy) { tHashJSObject *element = NULL; HASH_FIND_PTR(reverse_hash, &proxy, element); if( element ) return element->jsObject; return NULL; } void jsb_set_jsobject_for_proxy(JSObject *jsobj, void* proxy) { CCASSERT( !jsb_get_jsobject_for_proxy(proxy), "Already added. abort"); tHashJSObject *element = (tHashJSObject*) malloc( sizeof( *element ) ); element->proxy = proxy; element->jsObject = jsobj; HASH_ADD_PTR( reverse_hash, proxy, element ); } void jsb_del_jsobject_for_proxy(void* proxy) { tHashJSObject *element = NULL; HASH_FIND_PTR(reverse_hash, &proxy, element); if( element ) { HASH_DEL(reverse_hash, element); free(element); } } //#pragma mark //#pragma mark "C" proxy functions struct jsb_c_proxy_s* jsb_get_c_proxy_for_jsobject( JSObject *jsobj ) { struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s *) JS_GetPrivate(jsobj); return proxy; } void jsb_del_c_proxy_for_jsobject( JSObject *jsobj ) { struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s *) JS_GetPrivate(jsobj); CCASSERT(proxy, "Invalid proxy for JSObject"); JS_SetPrivate(jsobj, NULL); free(proxy); } void jsb_set_c_proxy_for_jsobject( JSObject *jsobj, void *handle, unsigned long flags) { struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s*) malloc(sizeof(*proxy)); CCASSERT(proxy, "No memory for proxy"); proxy->handle = handle; proxy->flags = flags; proxy->jsobj = jsobj; JS_SetPrivate(jsobj, proxy); } //#pragma mark Do Nothing - Callbacks JSBool JSB_do_nothing(JSContext *cx, uint32_t argc, jsval *vp) { JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/js_bindings_core.h ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 __JS_BINDINGS_CORE_H__ #define __JS_BINDINGS_CORE_H__ #include "jsapi.h" #include "jsfriendapi.h" #include "cocos2d.h" #include "chipmunk.h" #include "SimpleAudioEngine.h" #ifdef __cplusplus extern "C" { #endif enum { JSB_C_FLAG_CALL_FREE = 0, JSB_C_FLAG_DO_NOT_CALL_FREE =1, }; // structure used by "Object Oriented Functions". // handle is a pointer to the native object // flags: flags for the object struct jsb_c_proxy_s { unsigned long flags; // Should it be removed at "destructor" time, or not ? void *handle; // native object, like cpSpace, cpBody, etc. JSObject *jsobj; // JS Object. Needed for rooting / unrooting }; // Functions for setting / removing / getting the proxy used by the "C" Object Oriented API. Think of Chipmunk classes struct jsb_c_proxy_s* jsb_get_c_proxy_for_jsobject( JSObject *jsobj ); void jsb_del_c_proxy_for_jsobject( JSObject *jsobj ); void jsb_set_c_proxy_for_jsobject( JSObject *jsobj, void *handle, unsigned long flags); // JSObject -> proxy /** gets a proxy for a given JSObject */ void* jsb_get_proxy_for_jsobject(JSObject *jsobj); /** sets a proxy for a given JSObject */ void jsb_set_proxy_for_jsobject(void* proxy, JSObject *jsobj); /** dels a proxy for a given JSObject */ void jsb_del_proxy_for_jsobject(JSObject *jsobj); // reverse: proxy -> JSObject /** gets a JSObject for a given proxy */ JSObject* jsb_get_jsobject_for_proxy(void *proxy); /** sets a JSObject for a given proxy */ void jsb_set_jsobject_for_proxy(JSObject *jsobj, void* proxy); /** delts a JSObject for a given proxy */ void jsb_del_jsobject_for_proxy(void* proxy); // needed for callbacks. It does nothing. JSBool JSB_do_nothing(JSContext *cx, uint32_t argc, jsval *vp); #ifdef __cplusplus } #endif #endif /* __JS_BINDINGS_CORE_H__ */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp ================================================ #include "js_bindings_opengl.h" void GLNode::draw() { js_proxy_t* proxy = NULL; JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); proxy = js_get_or_create_proxy(cx, this); if( proxy ) { JSObject *jsObj = proxy->obj; if (jsObj) { JSBool found; JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JS_HasProperty(cx, jsObj, "draw", &found); if (found == JS_TRUE) { JS::RootedValue rval(cx); JS::RootedValue fval(cx); jsval *argv = NULL; unsigned argc=0; JS_GetProperty(cx, jsObj, "draw", &fval); JS_CallFunctionValue(cx, jsObj, fval, argc, argv, rval.address()); } } } } JSClass *js_cocos2dx_GLNode_class; JSObject *js_cocos2dx_GLNode_prototype; JSBool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { GLNode* cobj = new GLNode(); cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t *p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::GLNode"); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } void js_cocos2dx_GLNode_finalize(JSFreeOp *fop, JSObject *obj) { } static JSBool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); GLNode *nobj = new GLNode(); js_proxy_t* p = jsb_new_proxy(nobj, obj); nobj->autorelease(); JS_AddNamedObjectRoot(cx, &p->obj, "GLNode"); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSBool js_cocos2dx_GLNode_create(JSContext *cx, uint32_t argc, jsval *vp) { GLNode* ret = new GLNode(); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } extern JSObject* jsb_cocos2d_Node_prototype; void js_register_cocos2dx_GLNode(JSContext *cx, JSObject *global) { js_cocos2dx_GLNode_class = (JSClass *)calloc(1, sizeof(JSClass)); js_cocos2dx_GLNode_class->name = "GLNode"; js_cocos2dx_GLNode_class->addProperty = JS_PropertyStub; js_cocos2dx_GLNode_class->delProperty = JS_DeletePropertyStub; js_cocos2dx_GLNode_class->getProperty = JS_PropertyStub; js_cocos2dx_GLNode_class->setProperty = JS_StrictPropertyStub; js_cocos2dx_GLNode_class->enumerate = JS_EnumerateStub; js_cocos2dx_GLNode_class->resolve = JS_ResolveStub; js_cocos2dx_GLNode_class->convert = JS_ConvertStub; js_cocos2dx_GLNode_class->finalize = js_cocos2dx_GLNode_finalize; js_cocos2dx_GLNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("ctor", js_cocos2dx_GLNode_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("create", js_cocos2dx_GLNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; js_cocos2dx_GLNode_prototype = JS_InitClass( cx, global, jsb_cocos2d_Node_prototype, js_cocos2dx_GLNode_class, js_cocos2dx_GLNode_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "GLNode", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = js_cocos2dx_GLNode_class; p->proto = js_cocos2dx_GLNode_prototype; p->parentProto = jsb_cocos2d_Node_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/js_bindings_opengl.h ================================================ #include "cocos2d.h" #include "ScriptingCore.h" #include "cocos2d_specifics.hpp" class GLNode : public cocos2d::Node { public: void draw(); }; void js_register_cocos2dx_GLNode(JSContext *cx, JSObject *global); ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/js_manual_conversions.cpp ================================================ // // Created by Rohan Kuruvilla // Copyright (c) 2012 Zynga Inc. All rights reserved. // #include "jsapi.h" #include "jsfriendapi.h" #include "ScriptingCore.h" #include "js_bindings_config.h" #include "js_manual_conversions.h" #include "cocos2d_specifics.hpp" USING_NS_CC; // JSStringWrapper JSStringWrapper::JSStringWrapper() : _buffer(nullptr) { } JSStringWrapper::JSStringWrapper(JSString* str, JSContext* cx/* = NULL*/) : _buffer(nullptr) { set(str, cx); } JSStringWrapper::JSStringWrapper(jsval val, JSContext* cx/* = NULL*/) : _buffer(nullptr) { set(val, cx); } JSStringWrapper::~JSStringWrapper() { CC_SAFE_DELETE_ARRAY(_buffer); } void JSStringWrapper::set(jsval val, JSContext* cx) { if (val.isString()) { this->set(val.toString(), cx); } else { CC_SAFE_DELETE_ARRAY(_buffer); } } void JSStringWrapper::set(JSString* str, JSContext* cx) { CC_SAFE_DELETE_ARRAY(_buffer); if (!cx) { cx = ScriptingCore::getInstance()->getGlobalContext(); } // JS_EncodeString isn't supported in SpiderMonkey ff19.0. //buffer = JS_EncodeString(cx, string); unsigned short* pStrUTF16 = (unsigned short*)JS_GetStringCharsZ(cx, str); _buffer = cc_utf16_to_utf8(pStrUTF16, -1, NULL, NULL); } const char* JSStringWrapper::get() { return _buffer ? _buffer : ""; } // JSFunctionWrapper JSFunctionWrapper::JSFunctionWrapper(JSContext* cx, JSObject *jsthis, jsval fval) : _cx(cx) , _jsthis(jsthis) , _fval(fval) { JS_AddNamedValueRoot(cx, &this->_fval, "JSFunctionWrapper"); JS_AddNamedObjectRoot(cx, &this->_jsthis, "JSFunctionWrapper"); } JSFunctionWrapper::~JSFunctionWrapper() { JS_RemoveValueRoot(this->_cx, &this->_fval); JS_RemoveObjectRoot(this->_cx, &this->_jsthis); } JSBool JSFunctionWrapper::invoke(unsigned int argc, jsval *argv, jsval &rval) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET return JS_CallFunctionValue(this->_cx, this->_jsthis, this->_fval, argc, argv, &rval); } static Color3B getColorFromJSObject(JSContext *cx, JSObject *colorObject) { JS::RootedValue jsr(cx); Color3B out; JS_GetProperty(cx, colorObject, "r", &jsr); double fontR = 0.0; JS_ValueToNumber(cx, jsr, &fontR); JS_GetProperty(cx, colorObject, "g", &jsr); double fontG = 0.0; JS_ValueToNumber(cx, jsr, &fontG); JS_GetProperty(cx, colorObject, "b", &jsr); double fontB = 0.0; JS_ValueToNumber(cx, jsr, &fontB); // the out out.r = (unsigned char)fontR; out.g = (unsigned char)fontG; out.b = (unsigned char)fontB; return out; } static Size getSizeFromJSObject(JSContext *cx, JSObject *sizeObject) { JS::RootedValue jsr(cx); Size out; JS_GetProperty(cx, sizeObject, "width", &jsr); double width = 0.0; JS_ValueToNumber(cx, jsr, &width); JS_GetProperty(cx, sizeObject, "height", &jsr); double height = 0.0; JS_ValueToNumber(cx, jsr, &height); // the out out.width = width; out.height = height; return out; } JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **r) { #ifdef __LP64__ // begin JSObject *tmp_arg; 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"); 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; if( ! jsval_to_int32(cx, vp, &ret ) ) return JS_FALSE; #endif *r = (void*)ret; return JS_TRUE; } JSBool jsval_to_int( JSContext *cx, jsval vp, int *ret ) { // Since this is called to cast uint64 to uint32, // it is needed to initialize the value to 0 first #ifdef __LP64__ long *tmp = (long*)ret; *tmp = 0; #endif return jsval_to_int32(cx, vp, (int32_t*)ret); } jsval opaque_to_jsval( JSContext *cx, void *opaque ) { #ifdef __LP64__ uint64_t number = (uint64_t)opaque; 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); #else assert(sizeof(int)==4); int32_t number = (int32_t) opaque; return INT_TO_JSVAL(number); #endif } jsval c_class_to_jsval( JSContext *cx, void* handle, JSObject* object, JSClass *klass, const char* class_name) { JSObject *jsobj; jsobj = jsb_get_jsobject_for_proxy(handle); if( !jsobj ) { jsobj = JS_NewObject(cx, klass, object, NULL); CCASSERT(jsobj, "Invalid object"); jsb_set_c_proxy_for_jsobject(jsobj, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); jsb_set_jsobject_for_proxy(jsobj, handle); } return OBJECT_TO_JSVAL(jsobj); } JSBool jsval_to_c_class( JSContext *cx, jsval vp, void **out_native, struct jsb_c_proxy_s **out_proxy) { JSObject *jsobj; JSBool ok = JS_ValueToObject(cx, vp, &jsobj); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error converting jsval to object"); struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsobj); *out_native = proxy->handle; if( out_proxy ) *out_proxy = proxy; return JS_TRUE; } JSBool jsval_to_uint( JSContext *cx, jsval vp, unsigned int *ret ) { // Since this is called to cast uint64 to uint32, // it is needed to initialize the value to 0 first #ifdef __LP64__ long *tmp = (long*)ret; *tmp = 0; #endif return jsval_to_int32(cx, vp, (int32_t*)ret); } jsval long_to_jsval( JSContext *cx, long number ) { #ifdef __LP64__ assert( sizeof(long)==8); char chr[128]; snprintf(chr, sizeof(chr)-1, "%ld", number); JSString *ret_obj = JS_NewStringCopyZ(cx, chr); return STRING_TO_JSVAL(ret_obj); #else CCASSERT( sizeof(int)==4, "Error!"); return INT_TO_JSVAL(number); #endif } jsval ulong_to_jsval( JSContext *cx, unsigned long number ) { #ifdef __LP64__ assert( sizeof(unsigned long)==8); char chr[128]; snprintf(chr, sizeof(chr)-1, "%lu", number); JSString *ret_obj = JS_NewStringCopyZ(cx, chr); return STRING_TO_JSVAL(ret_obj); #else CCASSERT( sizeof(int)==4, "Error!"); return UINT_TO_JSVAL(number); #endif } jsval longlong_to_jsval( JSContext *cx, long long number ) { #if JSB_REPRESENT_LONGLONG_AS_STR char chr[128]; snprintf(chr, sizeof(chr)-1, "%lld", number); JSString *ret_obj = JS_NewStringCopyZ(cx, chr); return STRING_TO_JSVAL(ret_obj); #else CCASSERT( sizeof(long long)==8, "Error!"); JSObject *typedArray = JS_NewUint32Array( cx, 2 ); uint32_t *buffer = (uint32_t*)JS_GetArrayBufferViewData(typedArray, cx); buffer[0] = number >> 32; buffer[1] = number & 0xffffffff; return OBJECT_TO_JSVAL(typedArray); #endif } JSBool jsval_to_charptr( JSContext *cx, jsval vp, const char **ret ) { JSString *jsstr = JS_ValueToString( cx, vp ); JSB_PRECONDITION2( jsstr, cx, JS_FALSE, "invalid string" ); // root it vp = STRING_TO_JSVAL(jsstr); JSStringWrapper strWrapper(jsstr); // XXX: It is converted to String and then back to char* to autorelease the created object. String *tmp = String::create(strWrapper.get()); JSB_PRECONDITION2( tmp, cx, JS_FALSE, "Error creating string from UTF8"); *ret = tmp->getCString(); return JS_TRUE; } jsval charptr_to_jsval( JSContext *cx, const char *str) { return c_string_to_jsval(cx, str); } JSBool JSB_jsval_typedarray_to_dataptr( JSContext *cx, jsval vp, GLsizei *count, void **data, JSArrayBufferViewType t) { JSObject *jsobj; JSBool ok = JS_ValueToObject( cx, vp, &jsobj ); JSB_PRECONDITION2( ok && jsobj, cx, JS_FALSE, "Error converting value to object"); // WebGL supports TypedArray and sequences for some of its APIs. So when converting a TypedArray, we should // also check for a possible non-Typed Array JS object, like a JS Array. if( JS_IsTypedArrayObject( jsobj ) ) { *count = JS_GetTypedArrayLength(jsobj); JSArrayBufferViewType type = JS_GetArrayBufferViewType(jsobj); JSB_PRECONDITION2(t==type, cx, JS_FALSE, "TypedArray type different than expected type"); switch (t) { case js::ArrayBufferView::TYPE_INT8: case js::ArrayBufferView::TYPE_UINT8: *data = JS_GetUint8ArrayData(jsobj); break; case js::ArrayBufferView::TYPE_INT16: case js::ArrayBufferView::TYPE_UINT16: *data = JS_GetUint16ArrayData(jsobj); break; case js::ArrayBufferView::TYPE_INT32: case js::ArrayBufferView::TYPE_UINT32: *data = JS_GetUint32ArrayData(jsobj); break; case js::ArrayBufferView::TYPE_FLOAT32: *data = JS_GetFloat32ArrayData(jsobj); break; default: JSB_PRECONDITION2(false, cx, JS_FALSE, "Unsupported typedarray type"); break; } } else if( JS_IsArrayObject(cx, jsobj)) { // Slow... avoid it. Use TypedArray instead, but the spec says that it can receive // Sequence<> as well. uint32_t length; JS_GetArrayLength(cx, jsobj, &length); for( uint32_t i=0; ix = (float)x; ret->y = (float)y; return JS_TRUE; } JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, Acceleration* ret) { JSObject *tmp; JS::RootedValue jsx(cx); JS::RootedValue jsy(cx); JS::RootedValue jsz(cx); JS::RootedValue jstimestamp(cx); double x, y, timestamp, z; JSBool ok = v.isObject() && JS_ValueToObject(cx, v, &tmp) && JS_GetProperty(cx, tmp, "x", &jsx) && JS_GetProperty(cx, tmp, "y", &jsy) && JS_GetProperty(cx, tmp, "z", &jsz) && JS_GetProperty(cx, tmp, "timestamp", &jstimestamp) && JS_ValueToNumber(cx, jsx, &x) && JS_ValueToNumber(cx, jsy, &y) && JS_ValueToNumber(cx, jsz, &z) && JS_ValueToNumber(cx, jstimestamp, ×tamp); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); ret->x = x; ret->y = y; ret->z = z; ret->timestamp = timestamp; return JS_TRUE; } JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, Array** ret) { JSBool ok = JS_TRUE; Array* pArray = Array::create(); for( int i=0; i < argc; i++ ) { double num = 0.0; // optimization: JS_ValueToNumber is expensive. And can convert an string like "12" to a number if ( JSVAL_IS_NUMBER(*vp)) { ok &= JS_ValueToNumber(cx, *vp, &num ); if (!ok) { break; } pArray->addObject(Integer::create((int)num)); } else if (JSVAL_IS_STRING(*vp)) { JSStringWrapper str(JSVAL_TO_STRING(*vp), cx); pArray->addObject(String::create(str.get())); } else { js_proxy_t* p; JSObject* obj = JSVAL_TO_OBJECT(*vp); p = jsb_get_js_proxy(obj); if (p) { pArray->addObject((Object*)p->ptr); } } // next vp++; } *ret = pArray; JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); return ok; } JSBool jsvals_variadic_to_ccvaluevector( JSContext *cx, jsval *vp, int argc, cocos2d::ValueVector* ret) { for (int i = 0; i < argc; i++) { jsval value = *vp; if (value.isObject()) { JSObject* jsobj = JSVAL_TO_OBJECT(value); CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); if (!JS_IsArrayObject(cx, jsobj)) { // It's a normal js object. ValueMap dictVal; JSBool ok = jsval_to_ccvaluemap(cx, value, &dictVal); if (ok) { ret->push_back(Value(dictVal)); } } else { // It's a js array object. ValueVector arrVal; JSBool ok = jsval_to_ccvaluevector(cx, value, &arrVal); if (ok) { ret->push_back(Value(arrVal)); } } } else if (JSVAL_IS_STRING(value)) { JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); ret->push_back(Value(valueWapper.get())); } else if (JSVAL_IS_NUMBER(value)) { double number = 0.0; JSBool ok = JS_ValueToNumber(cx, value, &number); if (ok) { ret->push_back(Value(number)); } } else if (JSVAL_IS_BOOLEAN(value)) { JSBool boolVal = JS_FALSE; JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); if (ok) { ret->push_back(Value(boolVal)); } } else { CCASSERT(false, "not supported type"); } // next vp++; } return JS_TRUE; } JSBool jsval_to_ccrect(JSContext *cx, jsval v, Rect* ret) { JSObject *tmp; JS::RootedValue jsx(cx); JS::RootedValue jsy(cx); JS::RootedValue jswidth(cx); JS::RootedValue jsheight(cx); double x, y, width, height; JSBool ok = v.isObject() && JS_ValueToObject(cx, v, &tmp) && JS_GetProperty(cx, tmp, "x", &jsx) && JS_GetProperty(cx, tmp, "y", &jsy) && JS_GetProperty(cx, tmp, "width", &jswidth) && JS_GetProperty(cx, tmp, "height", &jsheight) && JS_ValueToNumber(cx, jsx, &x) && JS_ValueToNumber(cx, jsy, &y) && JS_ValueToNumber(cx, jswidth, &width) && JS_ValueToNumber(cx, jsheight, &height); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); ret->origin.x = x; ret->origin.y = y; ret->size.width = width; ret->size.height = height; return JS_TRUE; } JSBool jsval_to_ccsize(JSContext *cx, jsval v, Size* ret) { JSObject *tmp; JS::RootedValue jsw(cx); JS::RootedValue jsh(cx); double w, h; JSBool ok = v.isObject() && JS_ValueToObject(cx, v, &tmp) && JS_GetProperty(cx, tmp, "width", &jsw) && JS_GetProperty(cx, tmp, "height", &jsh) && JS_ValueToNumber(cx, jsw, &w) && JS_ValueToNumber(cx, jsh, &h); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); ret->width = w; ret->height = h; return JS_TRUE; } JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, Color4B* ret) { JSObject *tmp; JS::RootedValue jsr(cx); JS::RootedValue jsg(cx); JS::RootedValue jsb(cx); JS::RootedValue jsa(cx); double r, g, b, a; JSBool ok = v.isObject() && JS_ValueToObject(cx, v, &tmp) && JS_GetProperty(cx, tmp, "r", &jsr) && JS_GetProperty(cx, tmp, "g", &jsg) && JS_GetProperty(cx, tmp, "b", &jsb) && JS_GetProperty(cx, tmp, "a", &jsa) && JS_ValueToNumber(cx, jsr, &r) && JS_ValueToNumber(cx, jsg, &g) && JS_ValueToNumber(cx, jsb, &b) && JS_ValueToNumber(cx, jsa, &a); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); ret->r = r; ret->g = g; ret->b = b; ret->a = a; return JS_TRUE; } JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, Color4F* ret) { JSObject *tmp; JS::RootedValue jsr(cx); JS::RootedValue jsg(cx); JS::RootedValue jsb(cx); JS::RootedValue jsa(cx); double r, g, b, a; JSBool ok = v.isObject() && JS_ValueToObject(cx, v, &tmp) && JS_GetProperty(cx, tmp, "r", &jsr) && JS_GetProperty(cx, tmp, "g", &jsg) && JS_GetProperty(cx, tmp, "b", &jsb) && JS_GetProperty(cx, tmp, "a", &jsa) && JS_ValueToNumber(cx, jsr, &r) && JS_ValueToNumber(cx, jsg, &g) && JS_ValueToNumber(cx, jsb, &b) && JS_ValueToNumber(cx, jsa, &a); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); ret->r = r; ret->g = g; ret->b = b; ret->a = a; return JS_TRUE; } JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, Color3B* ret) { JSObject *tmp; JS::RootedValue jsr(cx); JS::RootedValue jsg(cx); JS::RootedValue jsb(cx); double r, g, b; JSBool ok = v.isObject() && JS_ValueToObject(cx, v, &tmp) && JS_GetProperty(cx, tmp, "r", &jsr) && JS_GetProperty(cx, tmp, "g", &jsg) && JS_GetProperty(cx, tmp, "b", &jsb) && JS_ValueToNumber(cx, jsr, &r) && JS_ValueToNumber(cx, jsg, &g) && JS_ValueToNumber(cx, jsb, &b); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); ret->r = r; ret->g = g; ret->b = b; return JS_TRUE; } JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, Point **points, int *numPoints) { // Parsing sequence JSObject *jsobj; JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); uint32_t len; JS_GetArrayLength(cx, jsobj, &len); Point *array = (Point*)malloc( sizeof(Point) * len); for( uint32_t i=0; i< len;i++ ) { jsval valarg; JS_GetElement(cx, jsobj, i, &valarg); ok = jsval_to_ccpoint(cx, valarg, &array[i]); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); } *numPoints = len; *points = array; return JS_TRUE; } JSBool jsval_to_ccarray(JSContext* cx, jsval v, __Array** ret) { JSObject *jsobj; JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); uint32_t len = 0; JS_GetArrayLength(cx, jsobj, &len); __Array* arr = __Array::createWithCapacity(len); for (uint32_t i=0; i < len; i++) { jsval value; if (JS_GetElement(cx, jsobj, i, &value)) { if (value.isObject()) { js_proxy_t *proxy; JSObject *tmp = JSVAL_TO_OBJECT(value); proxy = jsb_get_js_proxy(tmp); cocos2d::Object* cobj = (cocos2d::Object *)(proxy ? proxy->ptr : NULL); // Don't test it. //TEST_NATIVE_OBJECT(cx, cobj) if (cobj) { // It's a native js object. arr->addObject(cobj); } else if (!JS_IsArrayObject(cx, tmp)){ // It's a normal js object. __Dictionary* dictVal = NULL; JSBool ok = jsval_to_ccdictionary(cx, value, &dictVal); if (ok) { arr->addObject(dictVal); } } else { // It's a js array object. __Array* arrVal = NULL; JSBool ok = jsval_to_ccarray(cx, value, &arrVal); if (ok) { arr->addObject(arrVal); } } } else if (JSVAL_IS_STRING(value)) { JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); arr->addObject(String::create(valueWapper.get())); // CCLOG("iterate array: value = %s", valueWapper.get().c_str()); } else if (JSVAL_IS_NUMBER(value)) { double number = 0.0; JSBool ok = JS_ValueToNumber(cx, value, &number); if (ok) { arr->addObject(Double::create(number)); // CCLOG("iterate array: value = %lf", number); } } else if (JSVAL_IS_BOOLEAN(value)) { JSBool boolVal = JS_FALSE; JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); if (ok) { arr->addObject(Bool::create(boolVal)); // CCLOG("iterate object: value = %d", boolVal); } } else { CCASSERT(false, "not supported type"); } } } *ret = arr; return JS_TRUE; } JSBool jsval_to_ccvalue(JSContext* cx, jsval v, cocos2d::Value* ret) { if (v.isObject()) { JSObject* jsobj = JSVAL_TO_OBJECT(v); CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); if (!JS_IsArrayObject(cx, jsobj)) { // It's a normal js object. ValueMap dictVal; JSBool ok = jsval_to_ccvaluemap(cx, v, &dictVal); if (ok) { *ret = Value(dictVal); } } else { // It's a js array object. ValueVector arrVal; JSBool ok = jsval_to_ccvaluevector(cx, v, &arrVal); if (ok) { *ret = Value(arrVal); } } } else if (JSVAL_IS_STRING(v)) { JSStringWrapper valueWapper(JSVAL_TO_STRING(v), cx); *ret = Value(valueWapper.get()); } else if (JSVAL_IS_NUMBER(v)) { double number = 0.0; JSBool ok = JS_ValueToNumber(cx, v, &number); if (ok) { *ret = Value(number); } } else if (JSVAL_IS_BOOLEAN(v)) { JSBool boolVal = JS_FALSE; JSBool ok = JS_ValueToBoolean(cx, v, &boolVal); if (ok) { *ret = Value(boolVal); } } else { CCASSERT(false, "not supported type"); } return JS_TRUE; } JSBool jsval_to_ccvaluemap(JSContext* cx, jsval v, cocos2d::ValueMap* ret) { if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) { return JS_TRUE; } JSObject* tmp = JSVAL_TO_OBJECT(v); if (!tmp) { CCLOG("%s", "jsval_to_ccvaluemap: the jsval is not an object."); return JS_FALSE; } JSObject* it = JS_NewPropertyIterator(cx, tmp); ValueMap& dict = *ret; while (true) { jsid idp; jsval key; if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key)) { return JS_FALSE; // error } if (key == JSVAL_VOID) { break; // end of iteration } if (!JSVAL_IS_STRING(key)) { continue; // ignore integer properties } JSStringWrapper keyWrapper(JSVAL_TO_STRING(key), cx); JS::RootedValue value(cx); JS_GetPropertyById(cx, tmp, idp, &value); if (value.isObject()) { JSObject* jsobj = JSVAL_TO_OBJECT(value); CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); if (!JS_IsArrayObject(cx, jsobj)) { // It's a normal js object. ValueMap dictVal; JSBool ok = jsval_to_ccvaluemap(cx, value, &dictVal); if (ok) { dict[keyWrapper.get()] = Value(dictVal); } } else { // It's a js array object. ValueVector arrVal; JSBool ok = jsval_to_ccvaluevector(cx, value, &arrVal); if (ok) { dict[keyWrapper.get()] = Value(arrVal); } } } else if (JSVAL_IS_STRING(value)) { JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); dict[keyWrapper.get()] = Value(valueWapper.get()); // CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str()); } else if (JSVAL_IS_NUMBER(value)) { double number = 0.0; JSBool ok = JS_ValueToNumber(cx, value, &number); if (ok) { dict[keyWrapper.get()] = Value(number); // CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number); } } else if (JSVAL_IS_BOOLEAN(value)) { JSBool boolVal = JS_FALSE; JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); if (ok) { dict[keyWrapper.get()] = Value(boolVal); // CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal); } } else { CCASSERT(false, "not supported type"); } } return JS_TRUE; } JSBool jsval_to_ccvaluemapintkey(JSContext* cx, jsval v, cocos2d::ValueMapIntKey* ret) { if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) { return JS_TRUE; } JSObject* tmp = JSVAL_TO_OBJECT(v); if (!tmp) { CCLOG("%s", "jsval_to_ccvaluemap: the jsval is not an object."); return JS_FALSE; } JSObject* it = JS_NewPropertyIterator(cx, tmp); ValueMapIntKey& dict = *ret; while (true) { jsid idp; jsval key; if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key)) { return JS_FALSE; // error } if (key == JSVAL_VOID) { break; // end of iteration } if (!JSVAL_IS_STRING(key)) { continue; // ignore integer properties } int keyVal = JSVAL_TO_INT(key); JS::RootedValue value(cx); JS_GetPropertyById(cx, tmp, idp, &value); if (value.isObject()) { JSObject* jsobj = JSVAL_TO_OBJECT(value); CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); if (!JS_IsArrayObject(cx, jsobj)) { // It's a normal js object. ValueMap dictVal; JSBool ok = jsval_to_ccvaluemap(cx, value, &dictVal); if (ok) { dict[keyVal] = Value(dictVal); } } else { // It's a js array object. ValueVector arrVal; JSBool ok = jsval_to_ccvaluevector(cx, value, &arrVal); if (ok) { dict[keyVal] = Value(arrVal); } } } else if (JSVAL_IS_STRING(value)) { JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); dict[keyVal] = Value(valueWapper.get()); } else if (JSVAL_IS_NUMBER(value)) { double number = 0.0; JSBool ok = JS_ValueToNumber(cx, value, &number); if (ok) { dict[keyVal] = Value(number); } } else if (JSVAL_IS_BOOLEAN(value)) { JSBool boolVal = JS_FALSE; JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); if (ok) { dict[keyVal] = Value(boolVal); } } else { CCASSERT(false, "not supported type"); } } return JS_TRUE; } JSBool jsval_to_ccvaluevector(JSContext* cx, jsval v, cocos2d::ValueVector* ret) { JSObject *jsobj; JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); uint32_t len = 0; JS_GetArrayLength(cx, jsobj, &len); for (uint32_t i=0; i < len; i++) { jsval value; if (JS_GetElement(cx, jsobj, i, &value)) { if (value.isObject()) { JSObject* jsobj = JSVAL_TO_OBJECT(value); CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); if (!JS_IsArrayObject(cx, jsobj)) { // It's a normal js object. ValueMap dictVal; JSBool ok = jsval_to_ccvaluemap(cx, value, &dictVal); if (ok) { ret->push_back(Value(dictVal)); } } else { // It's a js array object. ValueVector arrVal; JSBool ok = jsval_to_ccvaluevector(cx, value, &arrVal); if (ok) { ret->push_back(Value(arrVal)); } } } else if (JSVAL_IS_STRING(value)) { JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); ret->push_back(Value(valueWapper.get())); } else if (JSVAL_IS_NUMBER(value)) { double number = 0.0; JSBool ok = JS_ValueToNumber(cx, value, &number); if (ok) { ret->push_back(Value(number)); } } else if (JSVAL_IS_BOOLEAN(value)) { JSBool boolVal = JS_FALSE; JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); if (ok) { ret->push_back(Value(boolVal)); } } else { CCASSERT(false, "not supported type"); } } } return JS_TRUE; } JSBool jsval_to_ssize( JSContext *cx, jsval vp, ssize_t* size) { JSBool ret = JS_FALSE; int32_t sizeInt32 = 0; ret = jsval_to_int32(cx, vp, &sizeInt32); *size = sizeInt32; return ret; } JSBool jsval_to_std_vector_string( JSContext *cx, jsval vp, std::vector* ret) { JSObject *jsobj; JSBool ok = vp.isObject() && JS_ValueToObject( cx, vp, &jsobj ); JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); uint32_t len = 0; JS_GetArrayLength(cx, jsobj, &len); for (uint32_t i=0; i < len; i++) { jsval value; if (JS_GetElement(cx, jsobj, i, &value)) { if (JSVAL_IS_STRING(value)) { JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); ret->push_back(valueWapper.get()); } else { JS_ReportError(cx, "not supported type in array"); return JS_FALSE; } } } return JS_TRUE; } JSBool jsval_to_std_vector_int( JSContext *cx, jsval vp, std::vector* ret) { JSObject *jsobj; JSBool ok = vp.isObject() && JS_ValueToObject( cx, vp, &jsobj ); JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); uint32_t len = 0; JS_GetArrayLength(cx, jsobj, &len); for (uint32_t i=0; i < len; i++) { jsval value; if (JS_GetElement(cx, jsobj, i, &value)) { if (JSVAL_IS_NUMBER(value)) { double number = 0.0; JSBool ok = JS_ValueToNumber(cx, value, &number); if (ok) { ret->push_back(static_cast(number)); } } else { JS_ReportError(cx, "not supported type in array"); return JS_FALSE; } } } return JS_TRUE; } // native --> jsval jsval ccarray_to_jsval(JSContext* cx, __Array *arr) { JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); Object* obj; int i = 0; CCARRAY_FOREACH(arr, obj) { jsval arrElement; //First, check whether object is associated with js object. js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); if (jsproxy) { arrElement = OBJECT_TO_JSVAL(jsproxy->obj); } else { __String* strVal = NULL; __Dictionary* dictVal = NULL; __Array* arrVal = NULL; __Double* doubleVal = NULL; __Bool* boolVal = NULL; __Float* floatVal = NULL; __Integer* intVal = NULL; if ((strVal = dynamic_cast(obj))) { arrElement = c_string_to_jsval(cx, strVal->getCString()); } else if ((dictVal = dynamic_cast(obj))) { arrElement = ccdictionary_to_jsval(cx, dictVal); } else if ((arrVal = dynamic_cast(obj))) { arrElement = ccarray_to_jsval(cx, arrVal); } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); } else if ((floatVal = dynamic_cast<__Float*>(obj))) { arrElement = DOUBLE_TO_JSVAL(floatVal->getValue()); } else if ((intVal = dynamic_cast<__Integer*>(obj))) { arrElement = INT_TO_JSVAL(intVal->getValue()); } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); } else { CCASSERT(false, "the type isn't suppored."); } } if (!JS_SetElement(cx, jsretArr, i, &arrElement)) { break; } ++i; } return OBJECT_TO_JSVAL(jsretArr); } jsval ccdictionary_to_jsval(JSContext* cx, __Dictionary* dict) { JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); DictElement* pElement = NULL; CCDICT_FOREACH(dict, pElement) { JS::RootedValue dictElement(cx); Object* obj = pElement->getObject(); //First, check whether object is associated with js object. js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); if (jsproxy) { dictElement = OBJECT_TO_JSVAL(jsproxy->obj); } else { __String* strVal = NULL; __Dictionary* dictVal = NULL; __Array* arrVal = NULL; __Double* doubleVal = NULL; __Bool* boolVal = NULL; __Float* floatVal = NULL; __Integer* intVal = NULL; if ((strVal = dynamic_cast(obj))) { dictElement = c_string_to_jsval(cx, strVal->getCString()); } else if ((dictVal = dynamic_cast<__Dictionary*>(obj))) { dictElement = ccdictionary_to_jsval(cx, dictVal); } else if ((arrVal = dynamic_cast<__Array*>(obj))) { dictElement = ccarray_to_jsval(cx, arrVal); } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { dictElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); } else if ((floatVal = dynamic_cast<__Float*>(obj))) { dictElement = DOUBLE_TO_JSVAL(floatVal->getValue()); } else if ((intVal = dynamic_cast<__Integer*>(obj))) { dictElement = INT_TO_JSVAL(intVal->getValue()); } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { dictElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); } else { CCASSERT(false, "the type isn't suppored."); } } const char* key = pElement->getStrKey(); if (key && strlen(key) > 0) { JS_SetProperty(cx, jsRet, key, dictElement); } } return OBJECT_TO_JSVAL(jsRet); } JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, __Dictionary** ret) { if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) { *ret = NULL; return JS_TRUE; } JSObject* tmp = JSVAL_TO_OBJECT(v); if (!tmp) { CCLOG("%s", "jsval_to_ccdictionary: the jsval is not an object."); return JS_FALSE; } JSObject* it = JS_NewPropertyIterator(cx, tmp); __Dictionary* dict = NULL; while (true) { jsid idp; jsval key; if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key)) { return JS_FALSE; // error } if (key == JSVAL_VOID) { break; // end of iteration } if (!JSVAL_IS_STRING(key)) { continue; // ignore integer properties } JSStringWrapper keyWrapper(JSVAL_TO_STRING(key), cx); if (!dict) { dict = __Dictionary::create(); } JS::RootedValue value(cx); JS_GetPropertyById(cx, tmp, idp, &value); if (value.isObject()) { js_proxy_t *proxy; tmp = JSVAL_TO_OBJECT(value); proxy = jsb_get_js_proxy(tmp); cocos2d::Object* cobj = (cocos2d::Object *)(proxy ? proxy->ptr : NULL); // Don't test it. //TEST_NATIVE_OBJECT(cx, cobj) if (cobj) { // It's a native <-> js glue object. dict->setObject(cobj, keyWrapper.get()); } else if (!JS_IsArrayObject(cx, tmp)){ // It's a normal js object. __Dictionary* dictVal = NULL; JSBool ok = jsval_to_ccdictionary(cx, value, &dictVal); if (ok) { dict->setObject(dictVal, keyWrapper.get()); } } else { // It's a js array object. __Array* arrVal = NULL; JSBool ok = jsval_to_ccarray(cx, value, &arrVal); if (ok) { dict->setObject(arrVal, keyWrapper.get()); } } } else if (JSVAL_IS_STRING(value)) { JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); dict->setObject(String::create(valueWapper.get()), keyWrapper.get()); // CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str()); } else if (JSVAL_IS_NUMBER(value)) { double number = 0.0; JSBool ok = JS_ValueToNumber(cx, value, &number); if (ok) { dict->setObject(Double::create(number), keyWrapper.get()); // CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number); } } else if (JSVAL_IS_BOOLEAN(value)) { JSBool boolVal = JS_FALSE; JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); if (ok) { dict->setObject(Bool::create(boolVal), keyWrapper.get()); // CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal); } } else { CCASSERT(false, "not supported type"); } } *ret = dict; return JS_TRUE; } JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, AffineTransform* ret) { JSObject *tmp; JS::RootedValue jsa(cx); JS::RootedValue jsb(cx); JS::RootedValue jsc(cx); JS::RootedValue jsd(cx); JS::RootedValue jstx(cx); JS::RootedValue jsty(cx); double a, b, c, d, tx, ty; JSBool ok = JS_ValueToObject(cx, v, &tmp) && JS_GetProperty(cx, tmp, "a", &jsa) && JS_GetProperty(cx, tmp, "b", &jsb) && JS_GetProperty(cx, tmp, "c", &jsc) && JS_GetProperty(cx, tmp, "d", &jsd) && JS_GetProperty(cx, tmp, "tx", &jstx) && JS_GetProperty(cx, tmp, "ty", &jsty) && JS_ValueToNumber(cx, jsa, &a) && JS_ValueToNumber(cx, jsb, &b) && JS_ValueToNumber(cx, jsc, &c) && JS_ValueToNumber(cx, jsd, &d) && JS_ValueToNumber(cx, jstx, &tx) && JS_ValueToNumber(cx, jsty, &ty); JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); *ret = AffineTransformMake(a, b, c, d, tx, ty); return JS_TRUE; } // From native type to jsval jsval int32_to_jsval( JSContext *cx, int32_t number ) { return INT_TO_JSVAL(number); } jsval uint32_to_jsval( JSContext *cx, uint32_t number ) { return UINT_TO_JSVAL(number); } jsval ushort_to_jsval( JSContext *cx, unsigned short number ) { return UINT_TO_JSVAL(number); } jsval std_string_to_jsval(JSContext* cx, const std::string& v) { return c_string_to_jsval(cx, v.c_str(), v.size()); } jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length /* = -1 */) { if (v == NULL) { return JSVAL_NULL; } JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET if (0 == length) { auto emptyStr = JS_NewStringCopyZ(cx, ""); return STRING_TO_JSVAL(emptyStr); } jsval ret = JSVAL_NULL; int utf16_size = 0; jschar* strUTF16 = (jschar*)cc_utf8_to_utf16(v, length, &utf16_size); if (strUTF16 && utf16_size > 0) { JSString* str = JS_NewUCStringCopyN(cx, strUTF16, utf16_size); if (str) { ret = STRING_TO_JSVAL(str); } delete[] strUTF16; } return ret; } jsval ccpoint_to_jsval(JSContext* cx, const Point& v) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } jsval ccacceleration_to_jsval(JSContext* cx, const Acceleration& v) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "z", DOUBLE_TO_JSVAL(v.z), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "timestamp", DOUBLE_TO_JSVAL(v.timestamp), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } jsval ccrect_to_jsval(JSContext* cx, const Rect& v) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.origin.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.origin.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "width", DOUBLE_TO_JSVAL(v.size.width), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "height", DOUBLE_TO_JSVAL(v.size.height), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } jsval ccsize_to_jsval(JSContext* cx, const Size& v) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "width", DOUBLE_TO_JSVAL(v.width), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "height", DOUBLE_TO_JSVAL(v.height), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } jsval cccolor4b_to_jsval(JSContext* cx, const Color4B& v) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "a", INT_TO_JSVAL(v.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } jsval cccolor4f_to_jsval(JSContext* cx, const Color4F& v) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "r", DOUBLE_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "g", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(v.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } jsval cccolor3b_to_jsval(JSContext* cx, const Color3B& v) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } jsval ccaffinetransform_to_jsval(JSContext* cx, const AffineTransform& t) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(t.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(t.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "c", DOUBLE_TO_JSVAL(t.c), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "d", DOUBLE_TO_JSVAL(t.d), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "tx", DOUBLE_TO_JSVAL(t.tx), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "ty", DOUBLE_TO_JSVAL(t.ty), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } jsval FontDefinition_to_jsval(JSContext* cx, const FontDefinition& t) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; JSBool ok = JS_TRUE; ok &= JS_DefineProperty(cx, tmp, "fontName", std_string_to_jsval(cx, t._fontName), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "fontSize", int32_to_jsval(cx, t._fontSize), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "fontAlignmentH", int32_to_jsval(cx, (int32_t)t._alignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "fontAlignmentV", int32_to_jsval(cx, (int32_t)t._vertAlignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "fontFillColor", cccolor3b_to_jsval(cx, t._fontFillColor), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "fontDimensions", ccsize_to_jsval(cx, t._dimensions), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); // Shadow ok &= JS_DefineProperty(cx, tmp, "shadowEnabled", BOOLEAN_TO_JSVAL(t._shadow._shadowEnabled), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "shadowOffset", ccsize_to_jsval(cx, t._shadow._shadowOffset), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "shadowBlur", DOUBLE_TO_JSVAL(t._shadow._shadowBlur), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "shadowOpacity", DOUBLE_TO_JSVAL(t._shadow._shadowOpacity), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); // Stroke ok &= JS_DefineProperty(cx, tmp, "strokeEnabled", BOOLEAN_TO_JSVAL(t._stroke._strokeEnabled), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "strokeColor", cccolor3b_to_jsval(cx, t._stroke._strokeColor), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "strokeSize", DOUBLE_TO_JSVAL(t._stroke._strokeSize), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } return JSVAL_NULL; } JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) { JSObject *jsobj; if (!JS_ValueToObject( cx, vp, &jsobj ) ) return JS_FALSE; JSB_PRECONDITION( jsobj, "Not a valid JS object"); // defaul values const char * defautlFontName = "Arial"; const int defaultFontSize = 32; TextHAlignment defaultTextAlignment = TextHAlignment::LEFT; TextVAlignment defaultTextVAlignment = TextVAlignment::TOP; // by default shadow and stroke are off out->_shadow._shadowEnabled = false; out->_stroke._strokeEnabled = false; // white text by default out->_fontFillColor = Color3B::WHITE; // font name JS::RootedValue jsr(cx); JS_GetProperty(cx, jsobj, "fontName", &jsr); JS_ValueToString(cx, jsr); JSStringWrapper wrapper(jsr); const char* fontName = wrapper.get(); if (fontName && strlen(fontName) > 0) { out->_fontName = fontName; } else { out->_fontName = defautlFontName; } // font size JSBool hasProperty; JS_HasProperty(cx, jsobj, "fontSize", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "fontSize", &jsr); double fontSize = 0.0; JS_ValueToNumber(cx, jsr, &fontSize); out->_fontSize = fontSize; } else { out->_fontSize = defaultFontSize; } // font alignment horizontal JS_HasProperty(cx, jsobj, "fontAlignmentH", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "fontAlignmentH", &jsr); double fontAlign = 0.0; JS_ValueToNumber(cx, jsr, &fontAlign); out->_alignment = (TextHAlignment)(int)fontAlign; } else { out->_alignment = defaultTextAlignment; } // font alignment vertical JS_HasProperty(cx, jsobj, "fontAlignmentV", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "fontAlignmentV", &jsr); double fontAlign = 0.0; JS_ValueToNumber(cx, jsr, &fontAlign); out->_vertAlignment = (TextVAlignment)(int)fontAlign; } else { out->_vertAlignment = defaultTextVAlignment; } // font fill color JS_HasProperty(cx, jsobj, "fontFillColor", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "fontFillColor", &jsr); JSObject *jsobjColor; if (!JS_ValueToObject( cx, jsr, &jsobjColor ) ) return JS_FALSE; out->_fontFillColor = getColorFromJSObject(cx, jsobjColor); } // font rendering box dimensions JS_HasProperty(cx, jsobj, "fontDimensions", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "fontDimensions", &jsr); JSObject *jsobjSize; if (!JS_ValueToObject( cx, jsr, &jsobjSize ) ) return JS_FALSE; out->_dimensions = getSizeFromJSObject(cx, jsobjSize); } // shadow JS_HasProperty(cx, jsobj, "shadowEnabled", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "shadowEnabled", &jsr); out->_shadow._shadowEnabled = ToBoolean(jsr); if ( out->_shadow._shadowEnabled ) { // default shadow values out->_shadow._shadowOffset = Size(5, 5); out->_shadow._shadowBlur = 1; out->_shadow._shadowOpacity = 1; // shado offset JS_HasProperty(cx, jsobj, "shadowOffset", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "shadowOffset", &jsr); JSObject *jsobjShadowOffset; if (!JS_ValueToObject( cx, jsr, &jsobjShadowOffset ) ) return JS_FALSE; out->_shadow._shadowOffset = getSizeFromJSObject(cx, jsobjShadowOffset); } // shadow blur JS_HasProperty(cx, jsobj, "shadowBlur", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "shadowBlur", &jsr); double shadowBlur = 0.0; JS_ValueToNumber(cx, jsr, &shadowBlur); out->_shadow._shadowBlur = shadowBlur; } // shadow intensity JS_HasProperty(cx, jsobj, "shadowOpacity", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "shadowOpacity", &jsr); double shadowOpacity = 0.0; JS_ValueToNumber(cx, jsr, &shadowOpacity); out->_shadow._shadowOpacity = shadowOpacity; } } } // stroke JS_HasProperty(cx, jsobj, "strokeEnabled", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "strokeEnabled", &jsr); out->_stroke._strokeEnabled = ToBoolean(jsr); if ( out->_stroke._strokeEnabled ) { // default stroke values out->_stroke._strokeSize = 1; out->_stroke._strokeColor = Color3B::BLUE; // stroke color JS_HasProperty(cx, jsobj, "strokeColor", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "strokeColor", &jsr); JSObject *jsobjStrokeColor; if (!JS_ValueToObject( cx, jsr, &jsobjStrokeColor ) ) return JS_FALSE; out->_stroke._strokeColor = getColorFromJSObject(cx, jsobjStrokeColor); } // stroke size JS_HasProperty(cx, jsobj, "strokeSize", &hasProperty); if ( hasProperty ) { JS_GetProperty(cx, jsobj, "strokeSize", &jsr); double strokeSize = 0.0; JS_ValueToNumber(cx, jsr, &strokeSize); out->_stroke._strokeSize = strokeSize; } } } // we are done here return JS_TRUE; } #define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES JSBool jsval_to_CCPoint( JSContext *cx, jsval vp, Point *ret ) { #ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES JSObject *jsobj; if( ! JS_ValueToObject( cx, vp, &jsobj ) ) return JS_FALSE; JSB_PRECONDITION( jsobj, "Not a valid JS object"); JS::RootedValue valx(cx); JS::RootedValue valy(cx); JSBool ok = JS_TRUE; ok &= JS_GetProperty(cx, jsobj, "x", &valx); ok &= JS_GetProperty(cx, jsobj, "y", &valy); if( ! ok ) return JS_FALSE; double x, y; ok &= JS_ValueToNumber(cx, valx, &x); ok &= JS_ValueToNumber(cx, valy, &y); if( ! ok ) return JS_FALSE; ret->x = x; ret->y = y; return JS_TRUE; #else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES JSObject *tmp_arg; if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) return JS_FALSE; JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); *ret = *(Point*)JS_GetArrayBufferViewData( tmp_arg, cx ); return JS_TRUE; #endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES } JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *ret ) { #ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES JSObject *jsobj; if( ! JS_ValueToObject( cx, vp, &jsobj ) ) return JS_FALSE; JSB_PRECONDITION( jsobj, "Not a valid JS object"); JS::RootedValue valx(cx); JS::RootedValue valy(cx); JSBool ok = JS_TRUE; ok &= JS_GetProperty(cx, jsobj, "x", &valx); ok &= JS_GetProperty(cx, jsobj, "y", &valy); if( ! ok ) return JS_FALSE; double x, y; ok &= JS_ValueToNumber(cx, valx, &x); ok &= JS_ValueToNumber(cx, valy, &y); if( ! ok ) return JS_FALSE; ret->x = x; ret->y = y; return JS_TRUE; #else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES JSObject *tmp_arg; if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) return JS_FALSE; JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); *ret = *(cpVect*)JS_GetArrayBufferViewData( tmp_arg, cx ); return JS_TRUE; #endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES } jsval CGPoint_to_jsval( JSContext *cx, cpVect p) { #ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); if (!object) return JSVAL_VOID; if (!JS_DefineProperty(cx, object, "x", DOUBLE_TO_JSVAL(p.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "y", DOUBLE_TO_JSVAL(p.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) return JSVAL_VOID; return OBJECT_TO_JSVAL(object); #else // JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES #ifdef __LP64__ JSObject *typedArray = JS_NewFloat64Array( cx, 2 ); #else JSObject *typedArray = JS_NewFloat32Array( cx, 2 ); #endif cpVect *buffer = (cpVect*)JS_GetArrayBufferViewData(typedArray, cx ); *buffer = p; return OBJECT_TO_JSVAL(typedArray); #endif // ! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES } jsval ccvalue_to_jsval(JSContext* cx, const cocos2d::Value& v) { jsval ret = JSVAL_NULL; const Value& obj = v; switch (obj.getType()) { case Value::Type::BOOLEAN: ret = BOOLEAN_TO_JSVAL(obj.asBool()); break; case Value::Type::FLOAT: case Value::Type::DOUBLE: ret = DOUBLE_TO_JSVAL(obj.asDouble()); break; case Value::Type::INTEGER: ret = INT_TO_JSVAL(obj.asInt()); break; case Value::Type::STRING: ret = std_string_to_jsval(cx, obj.asString()); break; case Value::Type::VECTOR: ret = ccvaluevector_to_jsval(cx, obj.asValueVector()); break; case Value::Type::MAP: ret = ccvaluemap_to_jsval(cx, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: ret = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); break; default: break; } return ret; } jsval ccvaluemap_to_jsval(JSContext* cx, const cocos2d::ValueMap& v) { JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); for (auto iter = v.begin(); iter != v.end(); ++iter) { JS::RootedValue dictElement(cx); std::string key = iter->first; const Value& obj = iter->second; switch (obj.getType()) { case Value::Type::BOOLEAN: dictElement = BOOLEAN_TO_JSVAL(obj.asBool()); break; case Value::Type::FLOAT: case Value::Type::DOUBLE: dictElement = DOUBLE_TO_JSVAL(obj.asDouble()); break; case Value::Type::INTEGER: dictElement = INT_TO_JSVAL(obj.asInt()); break; case Value::Type::STRING: dictElement = std_string_to_jsval(cx, obj.asString()); break; case Value::Type::VECTOR: dictElement = ccvaluevector_to_jsval(cx, obj.asValueVector()); break; case Value::Type::MAP: dictElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: dictElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); break; default: break; } if (!key.empty()) { JS_SetProperty(cx, jsRet, key.c_str(), dictElement); } } return OBJECT_TO_JSVAL(jsRet); } jsval ccvaluemapintkey_to_jsval(JSContext* cx, const cocos2d::ValueMapIntKey& v) { JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); for (auto iter = v.begin(); iter != v.end(); ++iter) { JS::RootedValue dictElement(cx); std::stringstream keyss; keyss << iter->first; std::string key = keyss.str(); const Value& obj = iter->second; switch (obj.getType()) { case Value::Type::BOOLEAN: dictElement = BOOLEAN_TO_JSVAL(obj.asBool()); break; case Value::Type::FLOAT: case Value::Type::DOUBLE: dictElement = DOUBLE_TO_JSVAL(obj.asDouble()); break; case Value::Type::INTEGER: dictElement = INT_TO_JSVAL(obj.asInt()); break; case Value::Type::STRING: dictElement = std_string_to_jsval(cx, obj.asString()); break; case Value::Type::VECTOR: dictElement = ccvaluevector_to_jsval(cx, obj.asValueVector()); break; case Value::Type::MAP: dictElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: dictElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); break; default: break; } if (!key.empty()) { JS_SetProperty(cx, jsRet, key.c_str(), dictElement); } } return OBJECT_TO_JSVAL(jsRet); } jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v) { JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); int i = 0; for (const auto& obj : v) { jsval arrElement; switch (obj.getType()) { case Value::Type::BOOLEAN: arrElement = BOOLEAN_TO_JSVAL(obj.asBool()); break; case Value::Type::FLOAT: case Value::Type::DOUBLE: arrElement = DOUBLE_TO_JSVAL(obj.asDouble()); break; case Value::Type::INTEGER: arrElement = INT_TO_JSVAL(obj.asInt()); break; case Value::Type::STRING: arrElement = std_string_to_jsval(cx, obj.asString()); break; case Value::Type::VECTOR: arrElement = ccvaluevector_to_jsval(cx, obj.asValueVector()); break; case Value::Type::MAP: arrElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: arrElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); break; default: break; } if (!JS_SetElement(cx, jsretArr, i, &arrElement)) { break; } ++i; } return OBJECT_TO_JSVAL(jsretArr); } jsval ssize_to_jsval(JSContext *cx, ssize_t v) { CCASSERT(v < INT_MAX, "The size should not bigger than 32 bit (int32_t)."); return int32_to_jsval(cx, static_cast(v)); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/js_manual_conversions.h ================================================ // // Created by Rohan Kuruvilla // Copyright (c) 2012 Zynga Inc. All rights reserved. // #ifndef __JS_MANUAL_CONVERSIONS_H__ #define __JS_MANUAL_CONVERSIONS_H__ #include "jsapi.h" #include "js_bindings_core.h" #include "js_bindings_config.h" #include "cocos2d.h" #include "spidermonkey_specifics.h" // just a simple utility to avoid mem leaking when using JSString class JSStringWrapper { public: JSStringWrapper(); JSStringWrapper(JSString* str, JSContext* cx = NULL); JSStringWrapper(jsval val, JSContext* cx = NULL); ~JSStringWrapper(); void set(jsval val, JSContext* cx); void set(JSString* str, JSContext* cx); const char* get(); private: const char* _buffer; private: CC_DISALLOW_COPY_AND_ASSIGN(JSStringWrapper); }; // wraps a function and "this" object class JSFunctionWrapper { public: JSFunctionWrapper(JSContext* cx, JSObject *jsthis, jsval fval); ~JSFunctionWrapper(); JSBool invoke(unsigned int argc, jsval *argv, jsval &rval); private: JSContext *_cx; JSObject *_jsthis; jsval _fval; private: CC_DISALLOW_COPY_AND_ASSIGN(JSFunctionWrapper); }; JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **out ); JSBool jsval_to_int( JSContext *cx, jsval vp, int *out); JSBool jsval_to_uint( JSContext *cx, jsval vp, unsigned int *out); JSBool jsval_to_c_class( JSContext *cx, jsval vp, void **out_native, struct jsb_c_proxy_s **out_proxy); /** converts a jsval (JS string) into a char */ JSBool jsval_to_charptr( JSContext *cx, jsval vp, const char **out); jsval opaque_to_jsval( JSContext *cx, void* opaque); jsval c_class_to_jsval( JSContext *cx, void* handle, JSObject* object, JSClass *klass, const char* class_name); /* Converts a char ptr into a jsval (using JS string) */ jsval charptr_to_jsval( JSContext *cx, const char *str); JSBool JSB_jsval_typedarray_to_dataptr( JSContext *cx, jsval vp, GLsizei *count, void **data, JSArrayBufferViewType t); JSBool JSB_get_arraybufferview_dataptr( JSContext *cx, jsval vp, GLsizei *count, GLvoid **data ); // some utility functions // to native JSBool jsval_to_ushort( JSContext *cx, jsval vp, unsigned short *ret ); JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *ret ); JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *ret ); JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *ret ); JSBool jsval_to_long( JSContext *cx, jsval vp, long *out); JSBool jsval_to_ulong( JSContext *cx, jsval vp, unsigned long *out); JSBool jsval_to_long_long(JSContext *cx, jsval v, long long* ret); JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret); JSBool jsval_to_ccpoint(JSContext *cx, jsval v, cocos2d::Point* ret); JSBool jsval_to_ccrect(JSContext *cx, jsval v, cocos2d::Rect* ret); JSBool jsval_to_ccsize(JSContext *cx, jsval v, cocos2d::Size* ret); JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, cocos2d::Color4B* ret); JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, cocos2d::Color4F* ret); JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, cocos2d::Color3B* ret); JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, cocos2d::Point **points, int *numPoints); JSBool jsval_to_ccarray(JSContext* cx, jsval v, cocos2d::__Array** ret); JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, cocos2d::__Dictionary** ret); JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, cocos2d::Acceleration* ret); JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, cocos2d::__Array** ret); // forward declaration js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); template JSBool jsvals_variadic_to_ccvector( JSContext *cx, jsval *vp, int argc, cocos2d::Vector* ret) { JSBool ok = JS_TRUE; for (int i = 0; i < argc; i++) { js_proxy_t* p; JSObject* obj = JSVAL_TO_OBJECT(*vp); p = jsb_get_js_proxy(obj); CCASSERT(p, "Native object not found!"); if (p) { ret->pushBack((T)p->ptr); } // next vp++; } JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); return ok; } JSBool jsvals_variadic_to_ccvaluevector( JSContext *cx, jsval *vp, int argc, cocos2d::ValueVector* ret); JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, cocos2d::AffineTransform* ret); JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, cocos2d::FontDefinition* ret ); template JSBool jsval_to_ccvector(JSContext* cx, jsval v, cocos2d::Vector* ret) { JSObject *jsobj; JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); uint32_t len = 0; JS_GetArrayLength(cx, jsobj, &len); for (uint32_t i=0; i < len; i++) { jsval value; if (JS_GetElement(cx, jsobj, i, &value)) { CCASSERT(value.isObject(), "the element in Vector isn't a native object."); js_proxy_t *proxy; JSObject *tmp = JSVAL_TO_OBJECT(value); proxy = jsb_get_js_proxy(tmp); T cobj = (T)(proxy ? proxy->ptr : nullptr); if (cobj) { ret->pushBack(cobj); } } } return JS_TRUE; } JSBool jsval_to_ccvalue(JSContext* cx, jsval v, cocos2d::Value* ret); JSBool jsval_to_ccvaluemap(JSContext* cx, jsval v, cocos2d::ValueMap* ret); JSBool jsval_to_ccvaluemapintkey(JSContext* cx, jsval v, cocos2d::ValueMapIntKey* ret); JSBool jsval_to_ccvaluevector(JSContext* cx, jsval v, cocos2d::ValueVector* ret); JSBool jsval_to_ssize( JSContext *cx, jsval vp, ssize_t* ret); JSBool jsval_to_std_vector_string( JSContext *cx, jsval vp, std::vector* ret); JSBool jsval_to_std_vector_int( JSContext *cx, jsval vp, std::vector* ret); template JSBool jsval_to_ccmap_string_key(JSContext *cx, jsval v, cocos2d::Map* ret) { if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) { return JS_TRUE; } JSObject* tmp = JSVAL_TO_OBJECT(v); if (!tmp) { CCLOG("%s", "jsval_to_ccvaluemap: the jsval is not an object."); return JS_FALSE; } JSObject* it = JS_NewPropertyIterator(cx, tmp); while (true) { jsid idp; jsval key; if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key)) { return JS_FALSE; // error } if (key == JSVAL_VOID) { break; // end of iteration } if (!JSVAL_IS_STRING(key)) { continue; // ignore integer properties } JSStringWrapper keyWrapper(JSVAL_TO_STRING(key), cx); JS::RootedValue value(cx); JS_GetPropertyById(cx, tmp, idp, &value); if (value.isObject()) { js_proxy_t *proxy = nullptr; JSObject* jsobj = JSVAL_TO_OBJECT(value); proxy = jsb_get_js_proxy(jsobj); CCASSERT(proxy, "Native object should be added!"); T cobj = (T)(proxy ? proxy->ptr : nullptr); ret->insert(keyWrapper.get(), cobj); } else { CCASSERT(false, "not supported type"); } } return JS_TRUE; } // from native jsval int32_to_jsval( JSContext *cx, int32_t l); jsval uint32_to_jsval( JSContext *cx, uint32_t number ); jsval ushort_to_jsval( JSContext *cx, unsigned short number ); jsval long_to_jsval( JSContext *cx, long number ); jsval ulong_to_jsval(JSContext* cx, unsigned long v); jsval long_long_to_jsval(JSContext* cx, long long v); jsval std_string_to_jsval(JSContext* cx, const std::string& v); jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length = -1); jsval ccpoint_to_jsval(JSContext* cx, const cocos2d::Point& v); jsval ccrect_to_jsval(JSContext* cx, const cocos2d::Rect& v); jsval ccsize_to_jsval(JSContext* cx, const cocos2d::Size& v); jsval cccolor4b_to_jsval(JSContext* cx, const cocos2d::Color4B& v); jsval cccolor4f_to_jsval(JSContext* cx, const cocos2d::Color4F& v); jsval cccolor3b_to_jsval(JSContext* cx, const cocos2d::Color3B& v); jsval ccdictionary_to_jsval(JSContext* cx, cocos2d::__Dictionary *dict); jsval ccarray_to_jsval(JSContext* cx, cocos2d::__Array *arr); jsval ccacceleration_to_jsval(JSContext* cx, const cocos2d::Acceleration& v); jsval ccaffinetransform_to_jsval(JSContext* cx, const cocos2d::AffineTransform& t); jsval FontDefinition_to_jsval(JSContext* cx, const cocos2d::FontDefinition& t); JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *out ); jsval CGPoint_to_jsval( JSContext *cx, cpVect p ); #define cpVect_to_jsval CGPoint_to_jsval #define jsval_to_cpVect jsval_to_CGPoint template js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj); template jsval ccvector_to_jsval(JSContext* cx, const cocos2d::Vector& v) { JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); int i = 0; for (const auto& obj : v) { jsval arrElement; //First, check whether object is associated with js object. js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); if (jsproxy) { arrElement = OBJECT_TO_JSVAL(jsproxy->obj); } if (!JS_SetElement(cx, jsretArr, i, &arrElement)) { break; } ++i; } return OBJECT_TO_JSVAL(jsretArr); } template jsval ccmap_string_key_to_jsval(JSContext* cx, const cocos2d::Map& v) { JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); for (auto iter = v.begin(); iter != v.end(); ++iter) { JS::RootedValue element(cx); std::string key = iter->first; T obj = iter->second; //First, check whether object is associated with js object. js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); if (jsproxy) { element = OBJECT_TO_JSVAL(jsproxy->obj); } if (!key.empty()) { JS_SetProperty(cx, jsRet, key.c_str(), element); } } return OBJECT_TO_JSVAL(jsRet); } jsval ccvalue_to_jsval(JSContext* cx, const cocos2d::Value& v); jsval ccvaluemap_to_jsval(JSContext* cx, const cocos2d::ValueMap& v); jsval ccvaluemapintkey_to_jsval(JSContext* cx, const cocos2d::ValueMapIntKey& v); jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v); jsval ssize_to_jsval(JSContext *cx, ssize_t v); #endif /* __JS_MANUAL_CONVERSIONS_H__ */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/jsb_helper.h ================================================ #ifndef __XMLHTTPHELPER_H__ #define __XMLHTTPHELPER_H__ #include #include #include #include "jsapi.h" //#pragma mark - Helpful Macros #define JS_BINDED_CLASS_GLUE(klass) \ static JSClass js_class; \ static JSObject* js_proto; \ static JSObject* js_parent; \ static void _js_register(JSContext* cx, JSObject* global); #define JS_BINDED_CLASS_GLUE_IMPL(klass) \ JSClass klass::js_class = {}; \ JSObject* klass::js_proto = NULL; \ JSObject* klass::js_parent = NULL; \ #define JS_BINDED_FUNC(klass, name) \ JSBool name(JSContext *cx, unsigned argc, jsval *vp) #define JS_BINDED_CONSTRUCTOR(klass) \ static JSBool _js_constructor(JSContext *cx, unsigned argc, jsval *vp) #define JS_BINDED_CONSTRUCTOR_IMPL(klass) \ JSBool klass::_js_constructor(JSContext *cx, unsigned argc, jsval *vp) #define JS_BINDED_FUNC_IMPL(klass, name) \ static JSBool klass##_func_##name(JSContext *cx, unsigned argc, jsval *vp) { \ JSObject* thisObj = JS_THIS_OBJECT(cx, vp); \ klass* obj = (klass*)JS_GetPrivate(thisObj); \ if (obj) { \ return obj->name(cx, argc, vp); \ } \ JS_ReportError(cx, "Invalid object call for function %s", #name); \ return JS_FALSE; \ } \ JSBool klass::name(JSContext *cx, unsigned argc, jsval *vp) #define JS_WRAP_OBJECT_IN_VAL(klass, cobj, out) \ do { \ JSObject *obj = JS_NewObject(cx, &klass::js_class, klass::js_proto, klass::js_parent); \ if (obj) { \ JS_SetPrivate(obj, cobj); \ out = OBJECT_TO_JSVAL(obj); \ } \ } while(0) \ #define JS_BINDED_FUNC_FOR_DEF(klass, name) \ JS_FN(#name, klass##_func_##name, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT) #define JS_BINDED_PROP_GET(klass, propName) \ JSBool _js_get_##propName(JSContext *cx, JS::HandleId id, JS::MutableHandleValue vp) #define JS_BINDED_PROP_GET_IMPL(klass, propName) \ static JSBool _js_get_##klass##_##propName(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { \ klass* cobj = (klass*)JS_GetPrivate(obj); \ if (cobj) { \ return cobj->_js_get_##propName(cx, id, vp); \ } \ JS_ReportError(cx, "Invalid getter call for property %s", #propName); \ return JS_FALSE; \ } \ JSBool klass::_js_get_##propName(JSContext *cx, JS::HandleId id, JS::MutableHandleValue vp) #define JS_BINDED_PROP_SET(klass, propName) \ JSBool _js_set_##propName(JSContext *cx, JS::HandleId id, JSBool strict, JS::MutableHandleValue vp) #define JS_BINDED_PROP_SET_IMPL(klass, propName) \ static JSBool _js_set_##klass##_##propName(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool strict, JS::MutableHandleValue vp) { \ klass* cobj = (klass*)JS_GetPrivate(obj); \ if (cobj) { \ return cobj->_js_set_##propName(cx, id, strict, vp); \ } \ JS_ReportError(cx, "Invalid setter call for property %s", #propName); \ return JS_FALSE; \ } \ JSBool klass::_js_set_##propName(JSContext *cx, JS::HandleId id, JSBool strict, JS::MutableHandleValue vp) #define JS_BINDED_PROP_ACCESSOR(klass, propName) \ JS_BINDED_PROP_GET(klass, propName); \ JS_BINDED_PROP_SET(klass, propName); #define JS_BINDED_PROP_DEF_GETTER(klass, propName) \ {#propName, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(_js_get_##klass##_##propName), NULL} #define JS_BINDED_PROP_DEF_ACCESSOR(klass, propName) \ {#propName, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(_js_get_##klass##_##propName), JSOP_WRAPPER(_js_set_##klass##_##propName)} #define JS_CREATE_UINT_WRAPPED(valOut, propName, val) \ do { \ JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); \ jsval propVal = UINT_TO_JSVAL(val); \ JS_SetProperty(cx, jsobj, "__" propName, &propVal); \ valOut = OBJECT_TO_JSVAL(jsobj); \ } while(0) #define JS_GET_UINT_WRAPPED(inVal, propName, out) \ do { \ if (inVal.isObject()) {\ JSObject* jsobj = JSVAL_TO_OBJECT(inVal); \ jsval outVal; \ JS_GetProperty(cx, jsobj, "__" propName, &outVal); \ JS_ValueToECMAUint32(cx, outVal, &out); \ } else { \ int32_t tmp; \ JS_ValueToInt32(cx, inVal, &tmp); \ out = (uint32_t)tmp; \ } \ } while (0) #endif /* __XMLHTTPHELPER_H__ */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/jsb_opengl_functions.cpp ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_jsb.py -c opengl_jsb.ini" on 2013-03-05 * Script version: v0.6 */ #include "js_bindings_config.h" #ifdef JSB_INCLUDE_OPENGL #include "jsb_opengl_manual.h" #include "jsfriendapi.h" //#include "jsb_config.h" #include "js_bindings_core.h" #include "js_manual_conversions.h" #include "jsb_opengl_functions.h" // Arguments: GLenum // Ret value: void JSBool JSB_glActiveTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glActiveTexture((GLenum)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, GLuint // Ret value: void JSBool JSB_glAttachShader(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glAttachShader((GLuint)arg0 , (GLuint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, GLuint, char* // Ret value: void JSBool JSB_glBindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; const char* arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_charptr(cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindAttribLocation((GLuint)arg0 , (GLuint)arg1 , (char*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLuint // Ret value: void JSBool JSB_glBindBuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindBuffer((GLenum)arg0 , (GLuint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLuint // Ret value: void JSBool JSB_glBindFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindFramebuffer((GLenum)arg0 , (GLuint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLuint // Ret value: void JSBool JSB_glBindRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindRenderbuffer((GLenum)arg0 , (GLuint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLuint // Ret value: void JSBool JSB_glBindTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindTexture((GLenum)arg0 , (GLuint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLclampf, GLclampf, GLclampf, GLclampf // Ret value: void JSBool JSB_glBlendColor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum // Ret value: void JSBool JSB_glBlendEquation(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendEquation((GLenum)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum // Ret value: void JSBool JSB_glBlendEquationSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendEquationSeparate((GLenum)arg0 , (GLenum)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum // Ret value: void JSBool JSB_glBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendFunc((GLenum)arg0 , (GLenum)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLenum, GLenum // Ret value: void JSBool JSB_glBlendFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, ArrayBufferView, GLenum // Ret value: void JSBool JSB_glBufferData(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; uint32_t arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg1); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBufferData((GLenum)arg0 , count, (GLvoid*)arg1 , (GLenum)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLintptr, ArrayBufferView // Ret value: void JSBool JSB_glBufferSubData(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBufferSubData((GLenum)arg0 , (GLintptr)arg1 , count, (GLvoid*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum // Ret value: GLenum JSBool JSB_glCheckFramebufferStatus(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLenum ret_val; ret_val = glCheckFramebufferStatus((GLenum)arg0 ); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); return JS_TRUE; } // Arguments: GLbitfield // Ret value: void JSBool JSB_glClear(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glClear((GLbitfield)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLclampf, GLclampf, GLclampf, GLclampf // Ret value: void JSBool JSB_glClearColor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glClearColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLclampf // Ret value: void JSBool JSB_glClearDepthf(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glClearDepthf((GLclampf)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint // Ret value: void JSBool JSB_glClearStencil(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glClearStencil((GLint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLboolean, GLboolean, GLboolean, GLboolean // Ret value: void JSBool JSB_glColorMask(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint16_t arg0; uint16_t arg1; uint16_t arg2; uint16_t arg3; ok &= jsval_to_uint16( cx, *argvp++, &arg0 ); ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); ok &= jsval_to_uint16( cx, *argvp++, &arg2 ); ok &= jsval_to_uint16( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glColorMask((GLboolean)arg0 , (GLboolean)arg1 , (GLboolean)arg2 , (GLboolean)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glCompileShader(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCompileShader((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, ArrayBufferView // Ret value: void JSBool JSB_glCompressedTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 8, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; void* arg7; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); ok &= jsval_to_int32( cx, *argvp++, &arg5 ); ok &= jsval_to_int32( cx, *argvp++, &arg6 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg7); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCompressedTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLvoid*)arg7 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, ArrayBufferView // Ret value: void JSBool JSB_glCompressedTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 9, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; int32_t arg7; void* arg8; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); ok &= jsval_to_int32( cx, *argvp++, &arg5 ); ok &= jsval_to_uint32( cx, *argvp++, &arg6 ); ok &= jsval_to_int32( cx, *argvp++, &arg7 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCompressedTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLsizei)arg7 , (GLvoid*)arg8 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint // Ret value: void JSBool JSB_glCopyTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 8, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); ok &= jsval_to_int32( cx, *argvp++, &arg5 ); ok &= jsval_to_int32( cx, *argvp++, &arg6 ); ok &= jsval_to_int32( cx, *argvp++, &arg7 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCopyTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLint)arg3 , (GLint)arg4 , (GLsizei)arg5 , (GLsizei)arg6 , (GLint)arg7 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei // Ret value: void JSBool JSB_glCopyTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 8, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); ok &= jsval_to_int32( cx, *argvp++, &arg5 ); ok &= jsval_to_int32( cx, *argvp++, &arg6 ); ok &= jsval_to_int32( cx, *argvp++, &arg7 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCopyTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLsizei)arg7 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: GLuint JSBool JSB_glCreateProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); GLuint ret_val; ret_val = glCreateProgram( ); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); return JS_TRUE; } // Arguments: GLenum // Ret value: GLuint JSBool JSB_glCreateShader(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLuint ret_val; ret_val = glCreateShader((GLenum)arg0 ); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); return JS_TRUE; } // Arguments: GLenum // Ret value: void JSBool JSB_glCullFace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCullFace((GLenum)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDeleteProgram((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glDeleteShader(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDeleteShader((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum // Ret value: void JSBool JSB_glDepthFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDepthFunc((GLenum)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLboolean // Ret value: void JSBool JSB_glDepthMask(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint16_t arg0; ok &= jsval_to_uint16( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDepthMask((GLboolean)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLclampf, GLclampf // Ret value: void JSBool JSB_glDepthRangef(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDepthRangef((GLclampf)arg0 , (GLclampf)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, GLuint // Ret value: void JSBool JSB_glDetachShader(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDetachShader((GLuint)arg0 , (GLuint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum // Ret value: void JSBool JSB_glDisable(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDisable((GLenum)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glDisableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDisableVertexAttribArray((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint, GLsizei // Ret value: void JSBool JSB_glDrawArrays(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDrawArrays((GLenum)arg0 , (GLint)arg1 , (GLsizei)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLsizei, GLenum, ArrayBufferView // Ret value: void JSBool JSB_glDrawElements(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; void* arg3; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDrawElements((GLenum)arg0 , (GLsizei)arg1 , (GLenum)arg2 , (GLvoid*)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum // Ret value: void JSBool JSB_glEnable(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glEnable((GLenum)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glEnableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glEnableVertexAttribArray((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_glFinish(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); glFinish( ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_glFlush(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); glFlush( ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLenum, GLuint // Ret value: void JSBool JSB_glFramebufferRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glFramebufferRenderbuffer((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLenum, GLuint, GLint // Ret value: void JSBool JSB_glFramebufferTexture2D(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; int32_t arg4; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glFramebufferTexture2D((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 , (GLint)arg4 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum // Ret value: void JSBool JSB_glFrontFace(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glFrontFace((GLenum)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum // Ret value: void JSBool JSB_glGenerateMipmap(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glGenerateMipmap((GLenum)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, char* // Ret value: int JSBool JSB_glGetAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; const char* arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_charptr( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); int ret_val; ret_val = glGetAttribLocation((GLuint)arg0 , (char*)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: // Ret value: GLenum JSBool JSB_glGetError(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); GLenum ret_val; ret_val = glGetError( ); JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); return JS_TRUE; } // Arguments: GLuint, char* // Ret value: int JSBool JSB_glGetUniformLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; const char* arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_charptr( cx, *argvp++, &arg1 ); printf("%s ", arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); int ret_val; ret_val = glGetUniformLocation((GLuint)arg0 , (char*)arg1 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: GLenum, GLenum // Ret value: void JSBool JSB_glHint(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glHint((GLenum)arg0 , (GLenum)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: GLboolean JSBool JSB_glIsBuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; ret_val = glIsBuffer((GLuint)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: GLenum // Ret value: GLboolean JSBool JSB_glIsEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; ret_val = glIsEnabled((GLenum)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: GLuint // Ret value: GLboolean JSBool JSB_glIsFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; ret_val = glIsFramebuffer((GLuint)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: GLuint // Ret value: GLboolean JSBool JSB_glIsProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; ret_val = glIsProgram((GLuint)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: GLuint // Ret value: GLboolean JSBool JSB_glIsRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; ret_val = glIsRenderbuffer((GLuint)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: GLuint // Ret value: GLboolean JSBool JSB_glIsShader(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; ret_val = glIsShader((GLuint)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: GLuint // Ret value: GLboolean JSBool JSB_glIsTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; ret_val = glIsTexture((GLuint)arg0 ); JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); return JS_TRUE; } // Arguments: GLfloat // Ret value: void JSBool JSB_glLineWidth(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glLineWidth((GLfloat)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glLinkProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glLinkProgram((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint // Ret value: void JSBool JSB_glPixelStorei(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glPixelStorei((GLenum)arg0 , (GLint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLfloat, GLfloat // Ret value: void JSBool JSB_glPolygonOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glPolygonOffset((GLfloat)arg0 , (GLfloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView // Ret value: void JSBool JSB_glReadPixels(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 7, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; uint32_t arg4; uint32_t arg5; void* arg6; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_uint32( cx, *argvp++, &arg4 ); ok &= jsval_to_uint32( cx, *argvp++, &arg5 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg6); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glReadPixels((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 , (GLenum)arg4 , (GLenum)arg5 , (GLvoid*)arg6 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: // Ret value: void JSBool JSB_glReleaseShaderCompiler(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); glReleaseShaderCompiler( ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLsizei, GLsizei // Ret value: void JSBool JSB_glRenderbufferStorage(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; int32_t arg2; int32_t arg3; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glRenderbufferStorage((GLenum)arg0 , (GLenum)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLclampf, GLboolean // Ret value: void JSBool JSB_glSampleCoverage(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; uint16_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glSampleCoverage((GLclampf)arg0 , (GLboolean)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLint, GLsizei, GLsizei // Ret value: void JSBool JSB_glScissor(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glScissor((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint, GLuint // Ret value: void JSBool JSB_glStencilFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilFunc((GLenum)arg0 , (GLint)arg1 , (GLuint)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLint, GLuint // Ret value: void JSBool JSB_glStencilFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; int32_t arg2; uint32_t arg3; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 , (GLuint)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glStencilMask(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilMask((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLuint // Ret value: void JSBool JSB_glStencilMaskSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilMaskSeparate((GLenum)arg0 , (GLuint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLenum // Ret value: void JSBool JSB_glStencilOp(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilOp((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLenum, GLenum // Ret value: void JSBool JSB_glStencilOpSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilOpSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, ArrayBufferView // Ret value: void JSBool JSB_glTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 9, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); ok &= jsval_to_int32( cx, *argvp++, &arg5 ); ok &= jsval_to_uint32( cx, *argvp++, &arg6 ); ok &= jsval_to_uint32( cx, *argvp++, &arg7 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLfloat // Ret value: void JSBool JSB_glTexParameterf(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; int32_t arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glTexParameterf((GLenum)arg0 , (GLenum)arg1 , (GLfloat)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLenum, GLint // Ret value: void JSBool JSB_glTexParameteri(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; int32_t arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glTexParameteri((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView // Ret value: void JSBool JSB_glTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 9, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); ok &= jsval_to_int32( cx, *argvp++, &arg5 ); ok &= jsval_to_uint32( cx, *argvp++, &arg6 ); ok &= jsval_to_uint32( cx, *argvp++, &arg7 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLfloat // Ret value: void JSBool JSB_glUniform1f(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform1f((GLint)arg0 , (GLfloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLsizei, TypedArray/Sequence // Ret value: void JSBool JSB_glUniform1fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform1fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLint // Ret value: void JSBool JSB_glUniform1i(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform1i((GLint)arg0 , (GLint)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLsizei, TypedArray/Sequence // Ret value: void JSBool JSB_glUniform1iv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform1iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLfloat, GLfloat // Ret value: void JSBool JSB_glUniform2f(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform2f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLsizei, TypedArray/Sequence // Ret value: void JSBool JSB_glUniform2fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform2fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLint, GLint // Ret value: void JSBool JSB_glUniform2i(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform2i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLsizei, TypedArray/Sequence // Ret value: void JSBool JSB_glUniform2iv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform2iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLfloat, GLfloat, GLfloat // Ret value: void JSBool JSB_glUniform3f(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform3f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLsizei, TypedArray/Sequence // Ret value: void JSBool JSB_glUniform3fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform3fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLint, GLint, GLint // Ret value: void JSBool JSB_glUniform3i(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform3i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLsizei, TypedArray/Sequence // Ret value: void JSBool JSB_glUniform3iv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform3iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLfloat, GLfloat, GLfloat, GLfloat // Ret value: void JSBool JSB_glUniform4f(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform4f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLsizei, TypedArray/Sequence // Ret value: void JSBool JSB_glUniform4fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform4fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLint, GLint, GLint, GLint // Ret value: void JSBool JSB_glUniform4i(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform4i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLsizei, TypedArray/Sequence // Ret value: void JSBool JSB_glUniform4iv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform4iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLboolean, TypedArray/Sequence // Ret value: void JSBool JSB_glUniformMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; uint16_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniformMatrix2fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLboolean, TypedArray/Sequence // Ret value: void JSBool JSB_glUniformMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; uint16_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniformMatrix3fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLboolean, TypedArray/Sequence // Ret value: void JSBool JSB_glUniformMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; uint16_t arg1; void* arg2; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniformMatrix4fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glUseProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUseProgram((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint // Ret value: void JSBool JSB_glValidateProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glValidateProgram((GLuint)arg0 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, GLfloat // Ret value: void JSBool JSB_glVertexAttrib1f(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib1f((GLuint)arg0 , (GLfloat)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, TypedArray/Sequence // Ret value: void JSBool JSB_glVertexAttrib1fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib1fv((GLuint)arg0 , (GLfloat*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, GLfloat, GLfloat // Ret value: void JSBool JSB_glVertexAttrib2f(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib2f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, TypedArray/Sequence // Ret value: void JSBool JSB_glVertexAttrib2fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib2fv((GLuint)arg0 , (GLfloat*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, GLfloat, GLfloat, GLfloat // Ret value: void JSBool JSB_glVertexAttrib3f(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib3f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, TypedArray/Sequence // Ret value: void JSBool JSB_glVertexAttrib3fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib3fv((GLuint)arg0 , (GLfloat*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, GLfloat, GLfloat, GLfloat, GLfloat // Ret value: void JSBool JSB_glVertexAttrib4f(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib4f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, TypedArray/Sequence // Ret value: void JSBool JSB_glVertexAttrib4fv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib4fv((GLuint)arg0 , (GLfloat*)arg1 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLuint, GLint, GLenum, GLboolean, GLsizei, GLvoid* // Ret value: void JSBool JSB_glVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 6, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; uint16_t arg3; int32_t arg4; int32_t arg5; ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); ok &= jsval_to_uint16( cx, *argvp++, &arg3 ); ok &= jsval_to_int32( cx, *argvp++, &arg4 ); ok &= jsval_to_int32( cx, *argvp++, &arg5 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttribPointer((GLuint)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLboolean)arg3 , (GLsizei)arg4 , (GLvoid*)arg5 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: GLint, GLint, GLsizei, GLsizei // Ret value: void JSBool JSB_glViewport(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; ok &= jsval_to_int32( cx, *argvp++, &arg0 ); ok &= jsval_to_int32( cx, *argvp++, &arg1 ); ok &= jsval_to_int32( cx, *argvp++, &arg2 ); ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glViewport((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } #endif // JSB_INCLUDE_OPENGL ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/jsb_opengl_functions.h ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_jsb.py -c opengl_jsb.ini" on 2013-03-05 * Script version: v0.6 */ #include "js_bindings_config.h" #ifdef JSB_INCLUDE_OPENGL #include "jsb_opengl_manual.h" extern "C" { JSBool JSB_glActiveTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glAttachShader(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBindBuffer(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBindFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBindRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBindTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBlendColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBlendEquation(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBlendEquationSeparate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBlendFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBufferData(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glBufferSubData(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCheckFramebufferStatus(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glClear(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glClearColor(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glClearDepthf(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glClearStencil(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glColorMask(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCompileShader(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCompressedTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCompressedTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCopyTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCopyTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCreateProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCreateShader(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glCullFace(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDeleteBuffers(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDeleteFramebuffers(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDeleteRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDeleteShader(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDeleteTextures(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDepthFunc(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDepthMask(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDepthRangef(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDetachShader(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDisable(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDisableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDrawArrays(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glDrawElements(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glEnable(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glEnableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glFinish(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glFlush(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glFramebufferRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glFramebufferTexture2D(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glFrontFace(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGenBuffers(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGenFramebuffers(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGenRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGenTextures(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGenerateMipmap(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetError(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetProgramiv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetShaderiv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetTexParameterfv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetUniformLocation(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glHint(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glIsBuffer(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glIsEnabled(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glIsFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glIsProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glIsRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glIsShader(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glIsTexture(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glLineWidth(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glLinkProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glPixelStorei(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glPolygonOffset(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glReadPixels(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glReleaseShaderCompiler(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glRenderbufferStorage(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glSampleCoverage(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glScissor(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glShaderSource(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glStencilFunc(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glStencilFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glStencilMask(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glStencilMaskSeparate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glStencilOp(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glStencilOpSeparate(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glTexParameterf(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glTexParameteri(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform1f(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform1fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform1i(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform1iv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform2f(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform2fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform2i(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform2iv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform3f(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform3fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform3i(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform3iv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform4f(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform4fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform4i(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniform4iv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniformMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniformMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUniformMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glUseProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glValidateProgram(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttrib1f(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttrib1fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttrib2f(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttrib2fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttrib3f(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttrib3fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttrib4f(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttrib4fv(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_glViewport(JSContext *cx, uint32_t argc, jsval *vp); } #endif // JSB_INCLUDE_OPENGL ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/jsb_opengl_manual.cpp ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2013 Zynga Inc. * * 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 "js_bindings_config.h" #ifdef JSB_INCLUDE_OPENGL #include "jsapi.h" #include "jsfriendapi.h" #include "jsb_opengl_manual.h" #include "js_manual_conversions.h" #include "js_bindings_core.h" #include "jsb_opengl_functions.h" // Helper functions that link "glGenXXXs" (OpenGL ES 2.0 spec), with "gl.createXXX" (WebGL spec) JSBool JSB_glGenTextures(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); GLuint texture; glGenTextures(1, &texture); JS_SET_RVAL(cx, vp, INT_TO_JSVAL(texture)); return JS_TRUE; } JSBool JSB_glGenBuffers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); GLuint buffer; glGenBuffers(1, &buffer); JS_SET_RVAL(cx, vp, INT_TO_JSVAL(buffer)); return JS_TRUE; } JSBool JSB_glGenRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); GLuint renderbuffers; glGenRenderbuffers(1, &renderbuffers); JS_SET_RVAL(cx, vp, INT_TO_JSVAL(renderbuffers)); return JS_TRUE; } JSBool JSB_glGenFramebuffers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); GLuint framebuffers; glGenFramebuffers(1, &framebuffers); JS_SET_RVAL(cx, vp, INT_TO_JSVAL(framebuffers)); return JS_TRUE; } JSBool JSB_glDeleteTextures(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDeleteTextures(1, &arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSBool JSB_glDeleteBuffers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDeleteBuffers(1, &arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSBool JSB_glDeleteRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDeleteRenderbuffers(1, &arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSBool JSB_glDeleteFramebuffers(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDeleteFramebuffers(1, &arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSBool JSB_glShaderSource(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; const char *arg1; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); ok &= jsval_to_charptr(cx, *argvp++, &arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glShaderSource(arg0, 1, &arg1, NULL); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JSBool JSB_glGetShaderiv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0, arg1; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); ok &= jsval_to_uint( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLint ret; glGetShaderiv(arg0, arg1, &ret); JS_SET_RVAL(cx, vp, INT_TO_JSVAL(ret)); return JS_TRUE; } JSBool JSB_glGetProgramiv(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0, arg1; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); ok &= jsval_to_uint( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLint ret; glGetProgramiv(arg0, arg1, &ret); JS_SET_RVAL(cx, vp, INT_TO_JSVAL(ret)); return JS_TRUE; } JSBool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLsizei length; glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length); GLchar* src = new GLchar[length]; glGetProgramInfoLog(arg0, length, NULL, src); JS_SET_RVAL(cx, vp, charptr_to_jsval(cx, src)); CC_SAFE_DELETE_ARRAY(src); return JS_TRUE; } // DOMString? getShaderInfoLog(WebGLShader? shader); JSBool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLsizei length; glGetShaderiv(arg0, GL_INFO_LOG_LENGTH, &length); GLchar* src = new GLchar[length]; glGetShaderInfoLog(arg0, length, NULL, src); JS_SET_RVAL(cx, vp, charptr_to_jsval(cx, src)); CC_SAFE_DELETE_ARRAY(src); return JS_TRUE; } // DOMString? getShaderSource(WebGLShader? shader); JSBool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLsizei length; glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length); GLchar* src = new GLchar[length]; glGetShaderSource(arg0, length, NULL, src); JS_SET_RVAL(cx, vp, charptr_to_jsval(cx, src)); CC_SAFE_DELETE_ARRAY(src); return JS_TRUE; } // interface WebGLActiveInfo { // readonly attribute GLint size; // readonly attribute GLenum type; // readonly attribute DOMString name; // WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index); JSBool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0, arg1; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); ok &= jsval_to_uint( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLsizei length; glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); GLchar* buffer = new GLchar[length]; GLint size = -1; GLenum type = -1; glGetActiveAttrib(arg0, arg1, length, NULL, &size, &type, buffer); jsval retval = JSVAL_VOID; JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error creating JS Object"); if (!JS_DefineProperty(cx, object, "size", INT_TO_JSVAL(size), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "type", INT_TO_JSVAL(type), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "name", charptr_to_jsval(cx, buffer), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) return JS_FALSE; retval = OBJECT_TO_JSVAL(object); JS_SET_RVAL(cx, vp, retval); CC_SAFE_DELETE_ARRAY(buffer); return JS_TRUE; } // interface WebGLActiveInfo { // readonly attribute GLint size; // readonly attribute GLenum type; // readonly attribute DOMString name; // }; // WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index); JSBool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0, arg1; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); ok &= jsval_to_uint( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLsizei length; glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); GLchar* buffer = new GLchar[length]; GLint size = -1; GLenum type = -1; glGetActiveUniform(arg0, arg1, length, NULL, &size, &type, buffer); jsval retval = JSVAL_VOID; JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error creating JS Object"); if (!JS_DefineProperty(cx, object, "size", INT_TO_JSVAL(size), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "type", INT_TO_JSVAL(type), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || !JS_DefineProperty(cx, object, "name", charptr_to_jsval(cx, buffer), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) return JS_FALSE; retval = OBJECT_TO_JSVAL(object); JS_SET_RVAL(cx, vp, retval); CC_SAFE_DELETE_ARRAY(buffer); return JS_TRUE; } // sequence? getAttachedShaders(WebGLProgram? program); JSBool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; uint32_t arg0; ok &= jsval_to_uint( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLsizei length; glGetProgramiv(arg0, GL_ATTACHED_SHADERS, &length); GLuint* buffer = new GLuint[length]; memset(buffer, 0, length * sizeof(GLuint)); //Fix bug 2448, it seems that glGetAttachedShaders will crash if we send NULL to the third parameter (eg Windows), same as in lua binding GLsizei realShaderCount = 0; glGetAttachedShaders(arg0, length, &realShaderCount, buffer); JSObject *jsobj = JS_NewArrayObject(cx, length, NULL); JSB_PRECONDITION2(jsobj, cx, JS_FALSE, "Error creating JS Object"); for( int i=0; i? getSupportedExtensions(); JSBool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); const GLubyte *extensions = glGetString(GL_EXTENSIONS); JSObject *jsobj = JS_NewArrayObject(cx, 0, NULL); JSB_PRECONDITION2(jsobj, cx, JS_FALSE, "Error creating JS Object"); // copy, to be able to add '\0' size_t len = strlen((char*)extensions); GLubyte* copy = new GLubyte[len+1]; strncpy((char*)copy, (const char*)extensions, len ); int start_extension=0; int element=0; for( int i=0; i #include "jsapi.h" #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) // compatible with iOS #define glClearDepthf glClearDepth #define glDepthRangef glDepthRange #define glReleaseShaderCompiler() #endif // __MAC_OS_X_VERSION_MAX_ALLOWED // forward declaration of new functions JSBool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp); #endif // JSB_INCLUDE_OPENGL #endif // __jsb_opengl_manual ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/jsb_opengl_registration.cpp ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 "js_bindings_config.h" #include "js_bindings_core.h" #include "jsfriendapi.h" #include "jsb_opengl_manual.h" #include "js_bindings_opengl.h" //#include "jsb_opengl_functions_registration.h" // system #include "jsb_opengl_functions.h" void JSB_register_opengl(JSContext *_cx, JSObject *object) { // // gl // JSObject *opengl = JS_NewObject(_cx, NULL, NULL, NULL); JS::RootedValue openglVal(_cx); openglVal = OBJECT_TO_JSVAL(opengl); JS_SetProperty(_cx, object, "gl", openglVal); JS::RootedValue nsval(_cx); JSObject *ccns; JS_GetProperty(_cx, object, "cc", &nsval); if (nsval == JSVAL_VOID) { ccns = JS_NewObject(_cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ccns); JS_SetProperty(_cx, object, "cc", nsval); } else { JS_ValueToObject(_cx, nsval, &ccns); } js_register_cocos2dx_GLNode(_cx, ccns); // New WebGL functions, not present on OpenGL ES 2.0 JS_DefineFunction(_cx, opengl, "getSupportedExtensions", JSB_glGetSupportedExtensions, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "activeTexture", JSB_glActiveTexture, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_attachShader", JSB_glAttachShader, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_bindAttribLocation", JSB_glBindAttribLocation, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_bindBuffer", JSB_glBindBuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_bindFramebuffer", JSB_glBindFramebuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_bindRenderbuffer", JSB_glBindRenderbuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_bindTexture", JSB_glBindTexture, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "blendColor", JSB_glBlendColor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "blendEquation", JSB_glBlendEquation, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "blendEquationSeparate", JSB_glBlendEquationSeparate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "blendFunc", JSB_glBlendFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "blendFuncSeparate", JSB_glBlendFuncSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "bufferData", JSB_glBufferData, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "bufferSubData", JSB_glBufferSubData, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "checkFramebufferStatus", JSB_glCheckFramebufferStatus, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "clear", JSB_glClear, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "clearColor", JSB_glClearColor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "clearDepthf", JSB_glClearDepthf, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "clearStencil", JSB_glClearStencil, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "colorMask", JSB_glColorMask, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_compileShader", JSB_glCompileShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "compressedTexImage2D", JSB_glCompressedTexImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "compressedTexSubImage2D", JSB_glCompressedTexSubImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "copyTexImage2D", JSB_glCopyTexImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "copyTexSubImage2D", JSB_glCopyTexSubImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_createProgram", JSB_glCreateProgram, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_createShader", JSB_glCreateShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "cullFace", JSB_glCullFace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_deleteBuffer", JSB_glDeleteBuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_deleteFramebuffer", JSB_glDeleteFramebuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_deleteProgram", JSB_glDeleteProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_deleteRenderbuffer", JSB_glDeleteRenderbuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_deleteShader", JSB_glDeleteShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_deleteTexture", JSB_glDeleteTextures, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "depthFunc", JSB_glDepthFunc, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "depthMask", JSB_glDepthMask, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "depthRangef", JSB_glDepthRangef, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "detachShader", JSB_glDetachShader, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "disable", JSB_glDisable, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "disableVertexAttribArray", JSB_glDisableVertexAttribArray, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "drawArrays", JSB_glDrawArrays, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "drawElements", JSB_glDrawElements, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "enable", JSB_glEnable, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "enableVertexAttribArray", JSB_glEnableVertexAttribArray, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "finish", JSB_glFinish, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "flush", JSB_glFlush, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "framebufferRenderbuffer", JSB_glFramebufferRenderbuffer, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "framebufferTexture2D", JSB_glFramebufferTexture2D, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "frontFace", JSB_glFrontFace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_createBuffer", JSB_glGenBuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_createFramebuffer", JSB_glGenFramebuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_createRenderbuffer", JSB_glGenRenderbuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_createTexture", JSB_glGenTextures, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "generateMipmap", JSB_glGenerateMipmap, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getActiveAttrib", JSB_glGetActiveAttrib, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getActiveUniform", JSB_glGetActiveUniform, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getAttachedShaders", JSB_glGetAttachedShaders, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getAttribLocation", JSB_glGetAttribLocation, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "getError", JSB_glGetError, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getProgramInfoLog", JSB_glGetProgramInfoLog, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getProgramParameter", JSB_glGetProgramiv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getShaderInfoLog", JSB_glGetShaderInfoLog, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getShaderSource", JSB_glGetShaderSource, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getShaderParameter", JSB_glGetShaderiv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "getTexParameter", JSB_glGetTexParameterfv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getUniformLocation", JSB_glGetUniformLocation, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_getUniform", JSB_glGetUniformfv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "hint", JSB_glHint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "isBuffer", JSB_glIsBuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "isEnabled", JSB_glIsEnabled, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "isFramebuffer", JSB_glIsFramebuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "isProgram", JSB_glIsProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "isRenderbuffer", JSB_glIsRenderbuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "isShader", JSB_glIsShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "isTexture", JSB_glIsTexture, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "lineWidth", JSB_glLineWidth, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_linkProgram", JSB_glLinkProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "pixelStorei", JSB_glPixelStorei, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "polygonOffset", JSB_glPolygonOffset, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "readPixels", JSB_glReadPixels, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "releaseShaderCompiler", JSB_glReleaseShaderCompiler, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "renderbufferStorage", JSB_glRenderbufferStorage, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "sampleCoverage", JSB_glSampleCoverage, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "scissor", JSB_glScissor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_shaderSource", JSB_glShaderSource, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "stencilFunc", JSB_glStencilFunc, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "stencilFuncSeparate", JSB_glStencilFuncSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "stencilMask", JSB_glStencilMask, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "stencilMaskSeparate", JSB_glStencilMaskSeparate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "stencilOp", JSB_glStencilOp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "stencilOpSeparate", JSB_glStencilOpSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_texImage2D", JSB_glTexImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "texParameterf", JSB_glTexParameterf, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "texParameteri", JSB_glTexParameteri, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_texSubImage2D", JSB_glTexSubImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform1f", JSB_glUniform1f, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform1fv", JSB_glUniform1fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform1i", JSB_glUniform1i, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform1iv", JSB_glUniform1iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform2f", JSB_glUniform2f, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform2fv", JSB_glUniform2fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform2i", JSB_glUniform2i, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform2iv", JSB_glUniform2iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform3f", JSB_glUniform3f, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform3fv", JSB_glUniform3fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform3i", JSB_glUniform3i, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform3iv", JSB_glUniform3iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform4f", JSB_glUniform4f, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform4fv", JSB_glUniform4fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform4i", JSB_glUniform4i, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniform4iv", JSB_glUniform4iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniformMatrix2fv", JSB_glUniformMatrix2fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniformMatrix3fv", JSB_glUniformMatrix3fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "uniformMatrix4fv", JSB_glUniformMatrix4fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_useProgram", JSB_glUseProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "_validateProgram", JSB_glValidateProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttrib1f", JSB_glVertexAttrib1f, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttrib1fv", JSB_glVertexAttrib1fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttrib2f", JSB_glVertexAttrib2f, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttrib2fv", JSB_glVertexAttrib2fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttrib3f", JSB_glVertexAttrib3f, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttrib3fv", JSB_glVertexAttrib3fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttrib4f", JSB_glVertexAttrib4f, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttrib4fv", JSB_glVertexAttrib4fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "vertexAttribPointer", JSB_glVertexAttribPointer, 6, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, opengl, "viewport", JSB_glViewport, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/jsb_opengl_registration.h ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 __JSB_OPENGL_REGISTRATION #define __JSB_OPENGL_REGISTRATION #include "jsb_opengl_functions.h" void JSB_register_opengl( JSContext *globalC, JSObject *globalO); #endif // __JSB_OPENGL_REGISTRATION ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/localstorage/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := jsb_localstorage_static LOCAL_MODULE_FILENAME := libcocos2dxjsblocalstorage LOCAL_SRC_FILES := js_bindings_system_functions.cpp \ js_bindings_system_registration.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../../../extensions LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_localstorage_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,scripting/javascript/bindings) $(call import-module,storage/local-storage) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.cpp ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 * Script version: v0.5 */ #include "cocos2d.h" #include "js_bindings_config.h" //#ifdef JSB_INCLUDE_SYSTEM #include "local-storage/LocalStorage.h" #include "jsfriendapi.h" #include "js_bindings_config.h" #include "js_bindings_core.h" #include "js_manual_conversions.h" #include "js_bindings_system_functions.h" #include "ScriptingCore.h" USING_NS_CC; // Arguments: char* // Ret value: const char* JSBool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; std::string arg0; ok &= jsval_to_std_string( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); std::string ret_val; ret_val = localStorageGetItem(arg0); jsval ret_jsval = std_string_to_jsval(cx, ret_val); JS_SET_RVAL(cx, vp, ret_jsval ); return JS_TRUE; } // Arguments: char* // Ret value: void JSBool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; std::string arg0; ok &= jsval_to_std_string( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); localStorageRemoveItem(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } // Arguments: char*, char* // Ret value: void JSBool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); jsval *argvp = JS_ARGV(cx,vp); JSBool ok = JS_TRUE; std::string arg0; std::string arg1; ok &= jsval_to_std_string( cx, *argvp++, &arg0 ); ok &= jsval_to_std_string( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); localStorageSetItem(arg0 , arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } //#endif // JSB_INCLUDE_SYSTEM ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions.h ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 * Script version: v0.5 */ #include "js_bindings_config.h" //#ifdef JSB_INCLUDE_SYSTEM //#include "LocalStorage.h" #ifdef __cplusplus extern "C" { #endif JSBool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp); JSBool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp); #ifdef __cplusplus } #endif //#endif // JSB_INCLUDE_SYSTEM ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_functions_registration.h ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 * Script version: v0.5 */ #include "../js_bindings_config.h" //#ifdef JSB_INCLUDE_SYSTEM //#include "LocalStorage.h" JS_DefineFunction(_cx, system, "getItem", JSB_localStorageGetItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, system, "removeItem", JSB_localStorageRemoveItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(_cx, system, "setItem", JSB_localStorageSetItem, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); //#endif // JSB_INCLUDE_SYSTEM ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.cpp ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 "js_bindings_config.h" #include "js_bindings_core.h" #include "local-storage/LocalStorage.h" #include "cocos2d.h" // system #include "js_bindings_system_functions.h" void jsb_register_system( JSContext *_cx, JSObject *object) { // // sys // JSObject *sys = JS_NewObject(_cx, NULL, NULL, NULL); JS::RootedValue systemVal(_cx); systemVal = OBJECT_TO_JSVAL(sys); JS_SetProperty(_cx, object, "sys", systemVal); // sys.localStorage JSObject *ls = JS_NewObject(_cx, NULL, NULL, NULL); JS::RootedValue lsVal(_cx); lsVal = OBJECT_TO_JSVAL(ls); JS_SetProperty(_cx, sys, "localStorage", lsVal); // sys.localStorage functions JSObject *system = ls; #include "js_bindings_system_functions_registration.h" // Init DB with full path //NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; //NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"]; std::string strFilePath = cocos2d::FileUtils::getInstance()->getWritablePath(); strFilePath += "/jsb.sqlite"; localStorageInit(strFilePath.c_str()); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/localstorage/js_bindings_system_registration.h ================================================ /* * JS Bindings: https://github.com/zynga/jsbindings * * Copyright (c) 2012 Zynga Inc. * * 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 __JSB_SYSTEM_REGISTRATION #define __JSB_SYSTEM_REGISTRATION void jsb_register_system( JSContext *globalC, JSObject *globalO); #endif // __JSB_CHIPMUNK_REGISTRATION ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj ================================================  Debug Win32 Release Win32 {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE} Win32Proj libJSBindingForLocalStorage StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\spidermonkey\include\win32;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false Windows true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\spidermonkey\include\win32;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/localstorage/libJSBindingForLocalStorage.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx manual manual manual manual manual ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/network/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := jsb_network_static LOCAL_MODULE_FILENAME := libcocos2dxjsbnetwork LOCAL_SRC_FILES := XMLHTTPRequest.cpp \ jsb_websocket.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static LOCAL_WHOLE_STATIC_LIBRARIES += websockets_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,scripting/javascript/bindings) $(call import-module,network) $(call import-module,websockets/prebuilt/android) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp ================================================ // // XMLHTTPRequest.cpp // XMLHttpRequest // // Created by Zynga 2013 // // Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.cpp // Copyright (c) 2012 Rolando Abarca. All rights reserved. // // 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 "XMLHTTPRequest.h" #include using namespace std; //#pragma mark - MinXmlHttpRequest /** * @brief Implementation for header retrieving. * @param header */ void MinXmlHttpRequest::_gotHeader(string header) { // Get Header and Set StatusText // Split String into Tokens char * cstr = new char [header.length()+1]; // check for colon. unsigned found_header_field = header.find_first_of(":"); if (found_header_field != std::string::npos) { // Found a header field. string http_field; string http_value; http_field = header.substr(0,found_header_field); http_value = header.substr(found_header_field+1, header.length()); // Get rid of all \n if (!http_value.empty() && http_value[http_value.size() - 1] == '\n') { http_value.erase(http_value.size() - 1); } _httpHeader[http_field] = http_value; } else { // Seems like we have the response Code! Parse it and check for it. char * pch; strcpy(cstr, header.c_str()); pch = strtok(cstr," "); while (pch != NULL) { stringstream ss; string val; ss << pch; val = ss.str(); unsigned found_http = val.find("HTTP"); // Check for HTTP Header to set statusText if (found_http != std::string::npos) { stringstream mystream; // Get Response Status pch = strtok (NULL, " "); mystream << pch; pch = strtok (NULL, " "); mystream << " " << pch; _statusText = mystream.str(); } pch = strtok (NULL, " "); } } CC_SAFE_DELETE_ARRAY(cstr); } /** * @brief Set Request header for next call. * @param field Name of the Header to be set. * @param value Value of the Headerfield */ void MinXmlHttpRequest::_setRequestHeader(const char* field, const char* value) { stringstream header_s; stringstream value_s; string header; auto iter = _requestHeader.find(field); // Concatenate values when header exists. if (iter != _requestHeader.end()) { value_s << iter->second << "," << value; } else { value_s << value; } _requestHeader[field] = value_s.str(); } /** * @brief If headers has been set, pass them to curl. * */ void MinXmlHttpRequest::_setHttpRequestHeader() { std::vector header; for (auto it = _requestHeader.begin(); it != _requestHeader.end(); ++it) { const char* first = it->first.c_str(); const char* second = it->second.c_str(); size_t len = sizeof(char) * (strlen(first) + 3 + strlen(second)); char* test = (char*) malloc(len); memset(test, 0,len); strcpy(test, first); strcpy(test + strlen(first) , ": "); strcpy(test + strlen(first) + 2, second); header.push_back(test); free(test); } if (!header.empty()) { _httpRequest->setHeaders(header); } } /** * @brief Callback for HTTPRequest. Handles the response and invokes Callback. * @param sender Object which initialized callback * @param respone Response object */ void MinXmlHttpRequest::handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response) { if (0 != strlen(response->getHttpRequest()->getTag())) { CCLOG("%s completed", response->getHttpRequest()->getTag()); } long statusCode = response->getResponseCode(); char statusString[64] = {0}; sprintf(statusString, "HTTP Status Code: %ld, tag = %s", statusCode, response->getHttpRequest()->getTag()); if (!response->isSucceed()) { CCLOG("Response failed, error buffer: %s", response->getErrorBuffer()); } // set header std::vector *headers = response->getResponseHeader(); char* concatHeader = (char*) malloc(headers->size() + 1); std::string header(headers->begin(), headers->end()); strcpy(concatHeader, header.c_str()); std::istringstream stream(concatHeader); std::string line; while(std::getline(stream, line)) { _gotHeader(line); } /** get the response data **/ std::vector *buffer = response->getResponseData(); if (statusCode == 200) { //Succeeded _status = 200; _readyState = DONE; _dataSize = static_cast(buffer->size()); CC_SAFE_FREE(_data); _data = (char*) malloc(_dataSize + 1); _data[_dataSize] = '\0'; memcpy((void*)_data, (const void*)buffer->data(), _dataSize); } else { _status = 0; } // Free Memory. free((void*) concatHeader); js_proxy_t * p; void* ptr = (void*)this; p = jsb_get_native_proxy(ptr); if(p) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); if (_onreadystateCallback) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET //JS_IsExceptionPending(cx) && JS_ReportPendingException(cx); jsval fval = OBJECT_TO_JSVAL(_onreadystateCallback); jsval out; JS_CallFunctionValue(cx, NULL, fval, 0, NULL, &out); } } } /** * @brief Send out request and fire callback when done. * @param cx Javascript context */ void MinXmlHttpRequest::_sendRequest(JSContext *cx) { _httpRequest->setResponseCallback(this, httpresponse_selector(MinXmlHttpRequest::handle_requestResponse)); cocos2d::network::HttpClient::getInstance()->send(_httpRequest); _httpRequest->release(); } /** * @brief Constructor initializes cchttprequest and stuff * */ MinXmlHttpRequest::MinXmlHttpRequest() : _onreadystateCallback(nullptr) , _isNetwork(true) , _data(nullptr) { _httpHeader.clear(); _requestHeader.clear(); _withCredentialsValue = true; _cx = ScriptingCore::getInstance()->getGlobalContext(); _httpRequest = new cocos2d::network::HttpRequest(); } /** * @brief Destructor cleans up _httpRequest and stuff * */ MinXmlHttpRequest::~MinXmlHttpRequest() { _httpHeader.clear(); _requestHeader.clear(); if (_onreadystateCallback != NULL) { JS_RemoveObjectRoot(_cx, &_onreadystateCallback); } if (_httpRequest) { // We don't need to release _httpRequest here since it will be released in the http callback. // _httpRequest->release(); } CC_SAFE_FREE(_data); } /** * @brief Initialize Object and needed properties. * */ JS_BINDED_CLASS_GLUE_IMPL(MinXmlHttpRequest); /** * @brief Implementation for the Javascript Constructor * */ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) { MinXmlHttpRequest* req = new MinXmlHttpRequest(); req->autorelease(); js_proxy_t *p; jsval out; JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, MinXmlHttpRequest::js_proto, MinXmlHttpRequest::js_parent); if (obj) { JS_SetPrivate(obj, req); out = OBJECT_TO_JSVAL(obj); } JS_SET_RVAL(cx, vp, out); p =jsb_new_proxy(req, obj); JS_AddNamedObjectRoot(cx, &p->obj, "XMLHttpRequest"); return JS_TRUE; } /** * @brief get Callback function for Javascript * */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, onreadystatechange) { if (_onreadystateCallback) { JSString *tmpstr = JS_NewStringCopyZ(cx, "1"); JS::RootedValue tmpval(cx); tmpval = STRING_TO_JSVAL(tmpstr); JS_SetProperty(cx, _onreadystateCallback, "readyState", tmpval); jsval out = OBJECT_TO_JSVAL(_onreadystateCallback); vp.set(out); } else { vp.set(JSVAL_NULL); } return JS_TRUE; } /** * @brief Set Callback function coming from Javascript * * */ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, onreadystatechange) { jsval callback = vp.get(); if (callback != JSVAL_NULL) { _onreadystateCallback = JSVAL_TO_OBJECT(callback); JS_AddNamedObjectRoot(cx, &_onreadystateCallback, "onreadystateCallback"); } return JS_TRUE; } /** * @brief upload getter - TODO * * Placeholder for further implementations!! */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, upload) { vp.set(JSVAL_NULL); return JS_TRUE; } /** * @brief upload setter - TODO * * Placeholder for further implementations */ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, upload) { vp.set(JSVAL_NULL); return JS_TRUE; } /** * @brief timeout getter - TODO * * Placeholder for further implementations */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, timeout) { vp.set(INT_TO_JSVAL(_timeout)); return JS_TRUE; } /** * @brief timeout setter - TODO * * Placeholder for further implementations */ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, timeout) { jsval timeout_ms = vp.get(); _timeout = JSVAL_TO_INT(timeout_ms); //curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT_MS, timeout); return JS_TRUE; } /** * @brief get response type for actual XHR * * */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseType) { JSString* str = JS_NewStringCopyN(cx, "", 0); vp.set(STRING_TO_JSVAL(str)); return JS_TRUE; } /** * @brief responseXML getter - TODO * * Placeholder for further implementation. */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseXML) { vp.set(JSVAL_NULL); return JS_TRUE; } /** * @brief set response type for actual XHR * * */ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, responseType) { jsval type = vp.get(); if (type.isString()) { JSString* str = type.toString(); JSBool equal; JS_StringEqualsAscii(cx, str, "text", &equal); if (equal) { _responseType = ResponseType::STRING; return JS_TRUE; } JS_StringEqualsAscii(cx, str, "arraybuffer", &equal); if (equal) { _responseType = ResponseType::ARRAY_BUFFER; return JS_TRUE; } JS_StringEqualsAscii(cx, str, "json", &equal); if (equal) { _responseType = ResponseType::JSON; return JS_TRUE; } // ignore the rest of the response types for now return JS_TRUE; } JS_ReportError(cx, "Invalid response type"); return JS_FALSE; } /** * @brief get readyState for actual XHR * * */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, readyState) { vp.set(INT_TO_JSVAL(_readyState)); return JS_TRUE; } /** * @brief get status for actual XHR * * */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status) { vp.set(INT_TO_JSVAL(_status)); return JS_TRUE; } /** * @brief get statusText for actual XHR * * */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, statusText) { jsval strVal = std_string_to_jsval(cx, _statusText); if (strVal != JSVAL_NULL) { vp.set(strVal); return JS_TRUE; } else { JS_ReportError(cx, "Error trying to create JSString from data"); return JS_FALSE; } } /** * @brief get value of withCredentials property. * */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, withCredentials) { vp.set(BOOLEAN_TO_JSVAL(_withCredentialsValue)); return JS_TRUE; } /** * withCredentials - set value of withCredentials property. * */ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, withCredentials) { jsval credential = vp.get(); if (credential != JSVAL_NULL) { _withCredentialsValue = JSVAL_TO_BOOLEAN(credential); } return JS_TRUE; } /** * @brief get (raw) responseText * */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseText) { if (_data) { jsval strVal = std_string_to_jsval(cx, _data); if (strVal != JSVAL_NULL) { vp.set(strVal); return JS_TRUE; } } CCLOGERROR("ResponseText was empty, probably there is a network error!"); // Return an empty string vp.set(std_string_to_jsval(cx, "")); return JS_TRUE; } /** * @brief get response of latest XHR * */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response) { if (_responseType == ResponseType::JSON) { JS::RootedValue outVal(cx); jsval strVal = std_string_to_jsval(cx, _data); if (JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), _dataSize, &outVal)) { vp.set(outVal); return JS_TRUE; } } else if (_responseType == ResponseType::ARRAY_BUFFER) { JSObject* tmp = JS_NewArrayBuffer(cx, _dataSize); uint8_t* tmpData = JS_GetArrayBufferData(tmp); memcpy((void*)tmpData, (const void*)_data, _dataSize); jsval outVal = OBJECT_TO_JSVAL(tmp); vp.set(outVal); return JS_TRUE; } // by default, return text return _js_get_responseText(cx, id, vp); } /** * @brief initialize new xhr. * */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) { if (argc >= 2) { jsval* argv = JS_ARGV(cx, vp); const char* method; const char* urlstr; JSBool async = true; JSString* jsMethod = JS_ValueToString(cx, argv[0]); JSString* jsURL = JS_ValueToString(cx, argv[1]); if (argc > 2) { JS_ValueToBoolean(cx, argv[2], &async); } JSStringWrapper w1(jsMethod); JSStringWrapper w2(jsURL); method = w1.get(); urlstr = w2.get(); _url = urlstr; _meth = method; _readyState = 1; _isAsync = async; if (_url.length() > 5 && _url.compare(_url.length() - 5, 5, ".json") == 0) { _responseType = ResponseType::JSON; } if (_meth.compare("post") == 0 || _meth.compare("POST") == 0) { _httpRequest->setRequestType(cocos2d::network::HttpRequest::Type::POST); } else { _httpRequest->setRequestType(cocos2d::network::HttpRequest::Type::GET); } _httpRequest->setUrl(_url.c_str()); _isNetwork = true; _readyState = OPENED; return JS_TRUE; } JS_ReportError(cx, "invalid call: %s", __FUNCTION__); return JS_FALSE; } /** * @brief send xhr * */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, send) { JSString *str = NULL; std::string data; // Clean up header map. New request, new headers! _httpHeader.clear(); if (argc == 1) { if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &str)) { return JS_FALSE; } JSStringWrapper strWrap(str); data = strWrap.get(); } if (data.length() > 0 && (_meth.compare("post") == 0 || _meth.compare("POST") == 0)) { _httpRequest->setRequestData(data.c_str(), data.length()); } _setHttpRequestHeader(); _sendRequest(cx); return JS_TRUE; } /** * @brief abort function Placeholder! * */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, abort) { return JS_TRUE; } /** * @brief Get all response headers as a string * */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getAllResponseHeaders) { stringstream responseheaders; string responseheader; for (auto it = _httpHeader.begin(); it != _httpHeader.end(); ++it) { responseheaders << it->first << ": " << it->second << "\n"; } responseheader = responseheaders.str(); jsval strVal = std_string_to_jsval(cx, responseheader); if (strVal != JSVAL_NULL) { JS_SET_RVAL(cx, vp, strVal); return JS_TRUE; } else { JS_ReportError(cx, "Error trying to create JSString from data"); return JS_FALSE; } return JS_TRUE; } /** * @brief Get all response headers as a string * */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) { JSString *header_value; if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &header_value)) { return JS_FALSE; }; std::string data; JSStringWrapper strWrap(header_value); data = strWrap.get(); stringstream streamdata; streamdata << data; string value = streamdata.str(); auto iter = _httpHeader.find(value); if (iter != _httpHeader.end()) { jsval js_ret_val = std_string_to_jsval(cx, iter->second); JS_SET_RVAL(cx, vp, js_ret_val); return JS_TRUE; } else { JS_SET_RVAL(cx, vp, JSVAL_NULL); return JS_TRUE; } } /** * @brief Set the given Fields to request Header. * * */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, setRequestHeader) { if (argc >= 2) { jsval* argv = JS_ARGV(cx, vp); const char* field; const char* value; JSString* jsField = JS_ValueToString(cx, argv[0]); JSString* jsValue = JS_ValueToString(cx, argv[1]); JSStringWrapper w1(jsField); JSStringWrapper w2(jsValue); field = w1.get(); value = w2.get(); // Populate the request_header map. _setRequestHeader(field, value); return JS_TRUE; } return JS_FALSE; } /** * @brief overrideMimeType function - TODO! * * Just a placeholder for further implementations. */ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, overrideMimeType) { return JS_TRUE; } /** * @brief destructor for Javascript * */ static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) { CCLOG("basic_object_finalize %p ...", obj); } /** * @brief Register XMLHttpRequest to be usable in JS and add properties and Mehtods. * @param cx Global Spidermonkey JS Context. * @param global Global Spidermonkey Javascript object. */ void MinXmlHttpRequest::_js_register(JSContext *cx, JSObject *global) { JSClass js_class = { "XMLHttpRequest", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, basic_object_finalize, JSCLASS_NO_OPTIONAL_MEMBERS }; MinXmlHttpRequest::js_class = js_class; static JSPropertySpec props[] = { JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onreadystatechange), JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, responseType), JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, withCredentials), JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, readyState), JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, status), JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, statusText), JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, responseText), JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, responseXML), JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, response), {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, open), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, abort), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, send), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, setRequestHeader), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getAllResponseHeaders), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, overrideMimeType), JS_FS_END }; MinXmlHttpRequest::js_parent = NULL; MinXmlHttpRequest::js_proto = JS_InitClass(cx, global, NULL, &MinXmlHttpRequest::js_class , MinXmlHttpRequest::_js_constructor, 0, props, funcs, NULL, NULL); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h ================================================ // // XMLHTTPRequest.h // XMLHttpRequest // // Created by Zynga 2013 // // Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.h // Copyright (c) 2012 Rolando Abarca. All rights reserved. // // 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 __FAKE_XMLHTTPREQUEST_H__ #define __FAKE_XMLHTTPREQUEST_H__ #include "network/HttpClient.h" #include "js_bindings_config.h" #include "ScriptingCore.h" #include "jstypes.h" #include "jsapi.h" #include "jsfriendapi.h" #include "jsb_helper.h" class MinXmlHttpRequest : public cocos2d::Object { public: enum class ResponseType { STRING, ARRAY_BUFFER, BLOB, DOCUMENT, JSON }; // Ready States (http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest) static const unsigned short UNSENT = 0; static const unsigned short OPENED = 1; static const unsigned short HEADERS_RECEIVED = 2; static const unsigned short LOADING = 3; static const unsigned short DONE = 4; MinXmlHttpRequest(); ~MinXmlHttpRequest(); JS_BINDED_CLASS_GLUE(MinXmlHttpRequest); JS_BINDED_CONSTRUCTOR(MinXmlHttpRequest); JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onreadystatechange); JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, responseType); JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, withCredentials); JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, upload); JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, timeout); JS_BINDED_PROP_GET(MinXmlHttpRequest, readyState); JS_BINDED_PROP_GET(MinXmlHttpRequest, status); JS_BINDED_PROP_GET(MinXmlHttpRequest, statusText); JS_BINDED_PROP_GET(MinXmlHttpRequest, responseText); JS_BINDED_PROP_GET(MinXmlHttpRequest, response); JS_BINDED_PROP_GET(MinXmlHttpRequest, responseXML); JS_BINDED_FUNC(MinXmlHttpRequest, open); JS_BINDED_FUNC(MinXmlHttpRequest, send); JS_BINDED_FUNC(MinXmlHttpRequest, abort); JS_BINDED_FUNC(MinXmlHttpRequest, getAllResponseHeaders); JS_BINDED_FUNC(MinXmlHttpRequest, getResponseHeader); JS_BINDED_FUNC(MinXmlHttpRequest, setRequestHeader); JS_BINDED_FUNC(MinXmlHttpRequest, overrideMimeType); void handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response); private: void _gotHeader(std::string header); void _setRequestHeader(const char* field, const char* value); void _setHttpRequestHeader(); void _sendRequest(JSContext *cx); std::string _url; JSContext* _cx; std::string _meth; std::string _type; char* _data; uint32_t _dataSize; JSObject* _onreadystateCallback; int _readyState; int _status; std::string _statusText; ResponseType _responseType; unsigned _timeout; bool _isAsync; cocos2d::network::HttpRequest* _httpRequest; bool _isNetwork; bool _withCredentialsValue; std::unordered_map _httpHeader; std::unordered_map _requestHeader; }; #endif ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/network/jsb_websocket.cpp ================================================ /**************************************************************************** Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 James Chen 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 "jsb_websocket.h" #include "cocos2d.h" #include "network/WebSocket.h" #include "spidermonkey_specifics.h" #include "ScriptingCore.h" #include "cocos2d_specifics.hpp" using namespace cocos2d::network; /* [Constructor(in DOMString url, in optional DOMString protocols)] [Constructor(in DOMString url, in optional DOMString[] protocols)] interface WebSocket { readonly attribute DOMString url; // ready state const unsigned short CONNECTING = 0; const unsigned short OPEN = 1; const unsigned short CLOSING = 2; const unsigned short CLOSED = 3; readonly attribute unsigned short readyState; readonly attribute unsigned long bufferedAmount; // networking attribute Function onopen; attribute Function onmessage; attribute Function onerror; attribute Function onclose; readonly attribute DOMString protocol; void send(in DOMString data); void close(); }; WebSocket implements EventTarget; */ class JSB_WebSocketDelegate : public WebSocket::Delegate { public: virtual void onOpen(WebSocket* ws) { js_proxy_t * p = jsb_get_native_proxy(ws); if (!p) return; JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); JS::RootedValue vp(cx); vp = c_string_to_jsval(cx, "open"); JS_SetProperty(cx, jsobj, "type", vp); jsval args = OBJECT_TO_JSVAL(jsobj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onopen", 1, &args); } virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) { js_proxy_t * p = jsb_get_native_proxy(ws); if (!p) return; JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); JS::RootedValue vp(cx); vp = c_string_to_jsval(cx, "message"); JS_SetProperty(cx, jsobj, "type", vp); jsval args = OBJECT_TO_JSVAL(jsobj); if (data.isBinary) {// data is binary JSObject* buffer = JS_NewArrayBuffer(cx, data.len); uint8_t* bufdata = JS_GetArrayBufferData(buffer); memcpy((void*)bufdata, (void*)data.bytes, data.len); JS::RootedValue dataVal(cx); dataVal = OBJECT_TO_JSVAL(buffer); JS_SetProperty(cx, jsobj, "data", dataVal); } else {// data is string JS::RootedValue dataVal(cx); dataVal = c_string_to_jsval(cx, data.bytes); JS_SetProperty(cx, jsobj, "data", dataVal); } ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onmessage", 1, &args); } virtual void onClose(WebSocket* ws) { js_proxy_t * p = jsb_get_native_proxy(ws); if (!p) return; JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); JS::RootedValue vp(cx); vp = c_string_to_jsval(cx, "close"); JS_SetProperty(cx, jsobj, "type", vp); jsval args = OBJECT_TO_JSVAL(jsobj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onclose", 1, &args); js_proxy_t* jsproxy = jsb_get_js_proxy(p->obj); JS_RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(p, jsproxy); CC_SAFE_DELETE(ws); } virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error) { js_proxy_t * p = jsb_get_native_proxy(ws); if (!p) return; JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); JS::RootedValue vp(cx); vp = c_string_to_jsval(cx, "error"); JS_SetProperty(cx, jsobj, "type", vp); jsval args = OBJECT_TO_JSVAL(jsobj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onerror", 1, &args); } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; } private: JSObject* _JSDelegate; }; JSClass *js_cocos2dx_websocket_class; JSObject *js_cocos2dx_websocket_prototype; void js_cocos2dx_WebSocket_finalize(JSFreeOp *fop, JSObject *obj) { CCLOG("jsbindings: finalizing JS object %p (WebSocket)", obj); } JSBool js_cocos2dx_extension_WebSocket_send(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if(argc == 1){ do { if (JSVAL_IS_STRING(argv[0])) { std::string data; jsval_to_std_string(cx, argv[0], &data); cobj->send(data); break; } if (argv[0].isObject()) { uint8_t *bufdata = NULL; uint32_t len = 0; JSObject* jsobj = JSVAL_TO_OBJECT(argv[0]); if (JS_IsArrayBufferObject(jsobj)) { bufdata = JS_GetArrayBufferData(jsobj); len = JS_GetArrayBufferByteLength(jsobj); } else if (JS_IsArrayBufferViewObject(jsobj)) { bufdata = (uint8_t*)JS_GetArrayBufferViewData(jsobj); len = JS_GetArrayBufferViewByteLength(jsobj); } if (bufdata && len > 0) { cobj->send(bufdata, len); break; } } JS_ReportError(cx, "data type to be sent is unsupported."); } while (0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_TRUE; } JSBool js_cocos2dx_extension_WebSocket_close(JSContext *cx, uint32_t argc, jsval *vp){ JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if(argc == 0){ cobj->close(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); if (argc == 1 || argc == 2) { std::string url; do { JSBool ok = jsval_to_std_string(cx, argv[0], &url); JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); } while (0); JSObject *obj = JS_NewObject(cx, js_cocos2dx_websocket_class, js_cocos2dx_websocket_prototype, NULL); WebSocket* cobj = new WebSocket(); JSB_WebSocketDelegate* delegate = new JSB_WebSocketDelegate(); delegate->setJSDelegate(obj); if (argc == 2) { std::vector protocols; if (JSVAL_IS_STRING(argv[1])) { std::string protocol; do { JSBool ok = jsval_to_std_string(cx, argv[1], &protocol); JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); } while (0); protocols.push_back(protocol); } else if (argv[1].isObject()) { JSBool ok = JS_TRUE; JSObject* arg2 = JSVAL_TO_OBJECT(argv[1]); JSB_PRECONDITION(JS_IsArrayObject( cx, arg2 ), "Object must be an array"); uint32_t len = 0; JS_GetArrayLength(cx, arg2, &len); for( uint32_t i=0; i< len;i++ ) { jsval valarg; JS_GetElement(cx, arg2, i, &valarg); std::string protocol; do { ok = jsval_to_std_string(cx, valarg, &protocol); JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error processing arguments"); } while (0); protocols.push_back(protocol); } } cobj->init(*delegate, url, &protocols); } else { cobj->init(*delegate, url); } JS_DefineProperty(cx, obj, "URL", argv[0] , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); //protocol not support yet (always return "") JS_DefineProperty(cx, obj, "protocol", c_string_to_jsval(cx, "") , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); // link the native object with the javascript object js_proxy_t *p = jsb_new_proxy(cobj, obj); JS_AddNamedObjectRoot(cx, &p->obj, "WebSocket"); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } static JSBool js_cocos2dx_extension_WebSocket_get_readyState(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { JSObject* jsobj = obj.get(); js_proxy_t *proxy = jsb_get_js_proxy(jsobj); WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (cobj) { vp.set(INT_TO_JSVAL((int)cobj->getReadyState())); return JS_TRUE; } else { JS_ReportError(cx, "Error: WebSocket instance is invalid."); return JS_FALSE; } } void register_jsb_websocket(JSContext *cx, JSObject *global) { js_cocos2dx_websocket_class = (JSClass *)calloc(1, sizeof(JSClass)); js_cocos2dx_websocket_class->name = "WebSocket"; js_cocos2dx_websocket_class->addProperty = JS_PropertyStub; js_cocos2dx_websocket_class->delProperty = JS_DeletePropertyStub; js_cocos2dx_websocket_class->getProperty = JS_PropertyStub; js_cocos2dx_websocket_class->setProperty = JS_StrictPropertyStub; js_cocos2dx_websocket_class->enumerate = JS_EnumerateStub; js_cocos2dx_websocket_class->resolve = JS_ResolveStub; js_cocos2dx_websocket_class->convert = JS_ConvertStub; js_cocos2dx_websocket_class->finalize = js_cocos2dx_WebSocket_finalize; js_cocos2dx_websocket_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {"readyState", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_cocos2dx_extension_WebSocket_get_readyState), NULL}, {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { JS_FN("send",js_cocos2dx_extension_WebSocket_send, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("close",js_cocos2dx_extension_WebSocket_close, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FS_END }; js_cocos2dx_websocket_prototype = JS_InitClass( cx, global, NULL, js_cocos2dx_websocket_class, js_cocos2dx_extension_WebSocket_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); JSObject* jsclassObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return WebSocket; })()")); JS_DefineProperty(cx, jsclassObj, "CONNECTING", INT_TO_JSVAL((int)WebSocket::State::CONNECTING) , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); JS_DefineProperty(cx, jsclassObj, "OPEN", INT_TO_JSVAL((int)WebSocket::State::OPEN) , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); JS_DefineProperty(cx, jsclassObj, "CLOSING", INT_TO_JSVAL((int)WebSocket::State::CLOSING) , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); JS_DefineProperty(cx, jsclassObj, "CLOSED", INT_TO_JSVAL((int)WebSocket::State::CLOSED) , NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "WebSocket", JSPROP_ENUMERATE | JSPROP_READONLY, &found); } ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/network/jsb_websocket.h ================================================ /**************************************************************************** Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 James Chen 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 __jsb_websocket__ #define __jsb_websocket__ #include "jsapi.h" #include "jsfriendapi.h" void register_jsb_websocket(JSContext* cx, JSObject* global); #endif /* defined(__jsb_websocket__) */ ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj ================================================  Debug Win32 Release Win32 {3BEC13F5-E227-4D80-BC77-1C857F83BCFC} Win32Proj libJSBindingForNetwork StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\network;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\websockets\include\win32;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false Windows true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\network;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\websockets\include\win32;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/network/libJSBindingForNetwork.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx manual manual manual manual ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj ================================================  Debug Win32 Release Win32 {39379840-825A-45A0-B363-C09FFEF864BD} Win32Proj libJSBinding StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false Windows true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)" ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {e19c6b81-737e-46ca-a683-a6d1db50a29c} manual manual manual manual manual manual manual manual generated manual manual manual manual manual manual manual manual manual manual manual generated generated js js js js js js js js ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/spidermonkey_specifics.h ================================================ #ifndef __SPIDERMONKEY_SPECIFICS_H__ #define __SPIDERMONKEY_SPECIFICS_H__ #include "jsapi.h" #include "uthash.h" #include typedef struct js_proxy { void *ptr; JSObject *obj; UT_hash_handle hh; } js_proxy_t; extern js_proxy_t *_native_js_global_ht; extern js_proxy_t *_js_native_global_ht; typedef struct js_type_class { JSClass *jsclass; JSObject *proto; JSObject *parentProto; } js_type_class_t; extern std::unordered_map _js_global_type_map; template< typename DERIVED > class TypeTest { public: static const char* s_name() { // return id unique for DERIVED // ALWAYS VALID BUT STRING, NOT INT - BUT VALID AND CROSS-PLATFORM/CROSS-VERSION COMPATBLE // AS FAR AS YOU KEEP THE CLASS NAME return typeid( DERIVED ).name(); } }; #define JS_NEW_PROXY(p, native_obj, js_obj) \ do { \ p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ assert(p); \ js_proxy_t* native_obj##js_obj##tmp = NULL; \ HASH_FIND_PTR(_native_js_global_ht, &native_obj, native_obj##js_obj##tmp); \ assert(!native_obj##js_obj##tmp); \ p->ptr = native_obj; \ p->obj = js_obj; \ HASH_ADD_PTR(_native_js_global_ht, ptr, p); \ p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ assert(p); \ native_obj##js_obj##tmp = NULL; \ HASH_FIND_PTR(_js_native_global_ht, &js_obj, native_obj##js_obj##tmp); \ assert(!native_obj##js_obj##tmp); \ p->ptr = native_obj; \ p->obj = js_obj; \ HASH_ADD_PTR(_js_native_global_ht, obj, p); \ } while(0) \ #define JS_GET_PROXY(p, native_obj) \ do { \ HASH_FIND_PTR(_native_js_global_ht, &native_obj, p); \ } while (0) #define JS_GET_NATIVE_PROXY(p, js_obj) \ do { \ HASH_FIND_PTR(_js_native_global_ht, &js_obj, p); \ } while (0) #define JS_REMOVE_PROXY(nproxy, jsproxy) \ do { \ if (nproxy) { HASH_DEL(_native_js_global_ht, nproxy); free(nproxy); } \ if (jsproxy) { HASH_DEL(_js_native_global_ht, jsproxy); free(jsproxy); } \ } while (0) #define TEST_NATIVE_OBJECT(cx, native_obj) \ if (!native_obj) { \ JS_ReportError(cx, "Invalid Native Object"); \ return JS_FALSE; \ } #endif ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/spine/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := jsb_spine_static LOCAL_MODULE_FILENAME := libcocos2dxjsbspine LOCAL_SRC_FILES := ../../../auto-generated/js-bindings/jsb_cocos2dx_spine_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../../editor-support/spine LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += spine_static include $(BUILD_STATIC_LIBRARY) $(call import-module,spidermonkey/prebuilt/android) $(call import-module,scripting/javascript/bindings) $(call import-module,editor-support/spine) ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj ================================================  Debug Win32 Release Win32 {E78CDC6B-F37D-48D2-AD91-1DB549497E32} Win32Proj libJSBindingForSpine StaticLibrary true Unicode v100 v110 v110_xp StaticLibrary false Unicode v100 v110 v110_xp $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false OldStyle Windows true Level3 MaxSpeed true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true Windows true true true ================================================ FILE: cocos2d/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj.filters ================================================  {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx generated generated generated ================================================ FILE: cocos2d/cocos/scripting/javascript/script/debugger/DevToolsUtils.js ================================================ /* 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/. */ "use strict"; function utf16to8(str) { var out, i, len, c; out = ""; len = str.length; for(i = 0; i < len; i++) { c = str.charCodeAt(i); if ((c >= 0x0001) && (c <= 0x007F)) { out += str.charAt(i); } else if (c > 0x07FF) { out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); } else { out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); } } return out; } function utf8to16(str) { var out, i, len, c; var char2, char3; out = ""; len = str.length; i = 0; while(i < len) { c = str.charCodeAt(i++); switch(c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: // 0xxxxxxx out += str.charAt(i-1); break; case 12: case 13: // 110x xxxx 10xx xxxx char2 = str.charCodeAt(i++); out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); break; case 14: // 1110 xxxx 10xx xxxx 10xx xxxx char2 = str.charCodeAt(i++); char3 = str.charCodeAt(i++); out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)); break; } } return out; } var dump = function(msg) { log(msg); }; /* General utilities used throughout devtools. */ /* Turn the error e into a string, without fail. */ this.safeErrorString = function safeErrorString(aError) { try { var s = aError.toString(); if (typeof s === "string") return s; } catch (ee) { } return ""; } /** * Report that |aWho| threw an exception, |aException|. */ this.reportException = function reportException(aWho, aException) { let msg = aWho + " threw an exception: " + safeErrorString(aException); if (aException.stack) { msg += "\nCall stack:\n" + aException.stack; } dump(msg + "\n"); // if (Components.utils.reportError) { // /* // * Note that the xpcshell test harness registers an observer for // * console messages, so when we're running tests, this will cause // * the test to quit. // */ // Components.utils.reportError(msg); // } } /** * Given a handler function that may throw, return an infallible handler * function that calls the fallible handler, and logs any exceptions it * throws. * * @param aHandler function * A handler function, which may throw. * @param aName string * A name for aHandler, for use in error messages. If omitted, we use * aHandler.name. * * (SpiderMonkey does generate good names for anonymous functions, but we * don't have a way to get at them from JavaScript at the moment.) */ this.makeInfallible = function makeInfallible(aHandler, aName) { if (!aName) aName = aHandler.name; return function (/* arguments */) { try { return aHandler.apply(this, arguments); } catch (ex) { let who = "Handler function"; if (aName) { who += " " + aName; } reportException(who, ex); } } } ================================================ FILE: cocos2d/cocos/scripting/javascript/script/debugger/README.md ================================================ Remote Debugging By Using FireFox ================================= Requirement ----------- * Firefox: From v24 How To Use ---------- ### Prepare ### Please refer to https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging . ### Enable Debugger Support For Your JSB Project ### ``` bool AppDelegate::applicationDidFinishLaunching() { ... ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(JSB_register_opengl); sc->start(); #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) sc->enableDebugger(); // Enable debugger here #endif ... } ``` Run your game. ### Open Firefox And Follow The Step As Follows ### ![pic 1](https://lh5.googleusercontent.com/-HoxLGBdV2J0/UlZ7ZoFUjyI/AAAAAAAAADM/68GDaCQ1vP0/s0-I/Firefox-Remote-Debug01.jpg) ![pic 2](https://lh6.googleusercontent.com/-7FDIHAYsKAY/UlZ7Yf8W-pI/AAAAAAAAAFQ/joG0AymnuBk/s0-I/Firefox-Remote-Debug02.jpg) ![pic 3](https://lh4.googleusercontent.com/-idvnMRGcGy8/UlZ7Wj6DDuI/AAAAAAAAAC0/L9IVyHLNqeQ/s0-I/Firefox-Remote-Debug04.jpg) ![pic 4](https://lh6.googleusercontent.com/-YuZj7JGAtFE/UlZ9DDGDczI/AAAAAAAAAEQ/D2qIedjP5FU/s0-I/Firefox-Remote-Debug04.png.png) ![pic 5](https://lh3.googleusercontent.com/-cdIcNa3jT5c/UlZ9uapf3OI/AAAAAAAAAEg/MGq3vLHsauw/s0-I/Firefox-Remote-Debug05.png) ![pic 6](https://lh5.googleusercontent.com/-T79-o5ylJKI/UlZ_JJQe3MI/AAAAAAAAAE8/F63fSVxlJKs/s0-I/Firefox-Remote-Debug06.png) ================================================ FILE: cocos2d/cocos/scripting/javascript/script/debugger/actors/root.js ================================================ /* -*- tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* 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/. */ "use strict"; /* Root actor for the remote debugging protocol. */ /** * Methods shared between RootActor and BrowserTabActor. */ /** * Populate |this._extraActors| as specified by |aFactories|, reusing whatever * actors are already there. Add all actors in the final extra actors table to * |aPool|. * * The root actor and the tab actor use this to instantiate actors that other * parts of the browser have specified with DebuggerServer.addTabActor antd * DebuggerServer.addGlobalActor. * * @param aFactories * An object whose own property names are the names of properties to add to * some reply packet (say, a tab actor grip or the "listTabs" response * form), and whose own property values are actor constructor functions, as * documented for addTabActor and addGlobalActor. * * @param this * The BrowserRootActor or BrowserTabActor with which the new actors will * be associated. It should support whatever API the |aFactories| * constructor functions might be interested in, as it is passed to them. * For the sake of CommonCreateExtraActors itself, it should have at least * the following properties: * * - _extraActors * An object whose own property names are factory table (and packet) * property names, and whose values are no-argument actor constructors, * of the sort that one can add to an ActorPool. * * - conn * The DebuggerServerConnection in which the new actors will participate. * * - actorID * The actor's name, for use as the new actors' parentID. */ function CommonCreateExtraActors(aFactories, aPool) { // Walk over global actors added by extensions. for (let name in aFactories) { let actor = this._extraActors[name]; if (!actor) { actor = aFactories[name].bind(null, this.conn, this); actor.prototype = aFactories[name].prototype; actor.parentID = this.actorID; this._extraActors[name] = actor; } aPool.addActor(actor); } } /** * Append the extra actors in |this._extraActors|, constructed by a prior call * to CommonCreateExtraActors, to |aObject|. * * @param aObject * The object to which the extra actors should be added, under the * property names given in the |aFactories| table passed to * CommonCreateExtraActors. * * @param this * The BrowserRootActor or BrowserTabActor whose |_extraActors| table we * should use; see above. */ function CommonAppendExtraActors(aObject) { for (let name in this._extraActors) { let actor = this._extraActors[name]; aObject[name] = actor.actorID; } } /** * Create a remote debugging protocol root actor. * * @param aConnection * The DebuggerServerConnection whose root actor we are constructing. * * @param aParameters * The properties of |aParameters| provide backing objects for the root * actor's requests; if a given property is omitted from |aParameters|, the * root actor won't implement the corresponding requests or notifications. * Supported properties: * * - tabList: a live list (see below) of tab actors. If present, the * new root actor supports the 'listTabs' request, providing the live * list's elements as its tab actors, and sending 'tabListChanged' * notifications when the live list's contents change. One actor in * this list must have a true '.selected' property. * * - globalActorFactories: an object |A| describing further actors to * attach to the 'listTabs' reply. This is the type accumulated by * DebuggerServer.addGlobalActor. For each own property |P| of |A|, * the root actor adds a property named |P| to the 'listTabs' * reply whose value is the name of an actor constructed by * |A[P]|. * * - onShutdown: a function to call when the root actor is disconnected. * * Instance properties: * * - applicationType: the string the root actor will include as the * "applicationType" property in the greeting packet. By default, this * is "browser". * * Live lists: * * A "live list", as used for the |tabList|, is an object that presents a * list of actors, and also notifies its clients of changes to the list. A * live list's interface is two properties: * * - iterator: a method that returns an iterator. A for-of loop will call * this method to obtain an iterator for the loop, so if LL is * a live list, one can simply write 'for (i of LL) ...'. * * - onListChanged: a handler called, with no arguments, when the set of * values the iterator would produce has changed since the last * time 'iterator' was called. This may only be set to null or a * callable value (one for which the typeof operator returns * 'function'). (Note that the live list will not call the * onListChanged handler until the list has been iterated over * once; if nobody's seen the list in the first place, nobody * should care if its contents have changed!) * * When the list changes, the list implementation should ensure that any * actors yielded in previous iterations whose referents (tabs) still exist * get yielded again in subsequent iterations. If the underlying referent * is the same, the same actor should be presented for it. * * The root actor registers an 'onListChanged' handler on the appropriate * list when it may need to send the client 'tabListChanged' notifications, * and is careful to remove the handler whenever it does not need to send * such notifications (including when it is disconnected). This means that * live list implementations can use the state of the handler property (set * or null) to install and remove observers and event listeners. * * Note that, as the only way for the root actor to see the members of the * live list is to begin an iteration over the list, the live list need not * actually produce any actors until they are reached in the course of * iteration: alliterative lazy live lists. */ function RootActor(aConnection, aParameters) { this.conn = aConnection; this._parameters = aParameters; this._onTabListChanged = this.onTabListChanged.bind(this); this._extraActors = {}; } RootActor.prototype = { constructor: RootActor, applicationType: "browser", /** * Return a 'hello' packet as specified by the Remote Debugging Protocol. */ sayHello: function() { return { from: this.actorID, applicationType: this.applicationType, /* This is not in the spec, but it's used by tests. */ testConnectionPrefix: this.conn.prefix, traits: { sources: true } }; }, /** * This is true for the root actor only, used by some child actors */ get isRootActor() true, /** * The (chrome) window, for use by child actors */ get window() Services.wm.getMostRecentWindow(DebuggerServer.chromeWindowType), /** * Disconnects the actor from the browser window. */ disconnect: function() { /* Tell the live lists we aren't watching any more. */ if (this._parameters.tabList) { this._parameters.tabList.onListChanged = null; } if (typeof this._parameters.onShutdown === 'function') { this._parameters.onShutdown(); } this._extraActors = null; }, /* The 'listTabs' request and the 'tabListChanged' notification. */ /** * Handles the listTabs request. The actors will survive until at least * the next listTabs request. */ onListTabs: function() { let tabList = this._parameters.tabList; if (!tabList) { return { from: this.actorID, error: "noTabs", message: "This root actor has no browser tabs." }; } /* * Walk the tab list, accumulating the array of tab actors for the * reply, and moving all the actors to a new ActorPool. We'll * replace the old tab actor pool with the one we build here, thus * retiring any actors that didn't get listed again, and preparing any * new actors to receive packets. */ let newActorPool = new ActorPool(this.conn); let tabActorList = []; let selected; for (let tabActor of tabList) { if (tabActor.selected) { selected = tabActorList.length; } tabActor.parentID = this.actorID; newActorPool.addActor(tabActor); tabActorList.push(tabActor); } /* DebuggerServer.addGlobalActor support: create actors. */ this._createExtraActors(this._parameters.globalActorFactories, newActorPool); /* * Drop the old actorID -> actor map. Actors that still mattered were * added to the new map; others will go away. */ if (this._tabActorPool) { this.conn.removeActorPool(this._tabActorPool); } this._tabActorPool = newActorPool; this.conn.addActorPool(this._tabActorPool); let reply = { "from": this.actorID, "selected": selected || 0, "tabs": [actor.grip() for (actor of tabActorList)], }; /* DebuggerServer.addGlobalActor support: name actors in 'listTabs' reply. */ this._appendExtraActors(reply); /* * Now that we're actually going to report the contents of tabList to * the client, we're responsible for letting the client know if it * changes. */ tabList.onListChanged = this._onTabListChanged; return reply; }, onTabListChanged: function () { this.conn.send({ from: this.actorID, type:"tabListChanged" }); /* It's a one-shot notification; no need to watch any more. */ this._parameters.tabList.onListChanged = null; }, /* This is not in the spec, but it's used by tests. */ onEcho: function (aRequest) { /* * Request packets are frozen. Copy aRequest, so that * DebuggerServerConnection.onPacket can attach a 'from' property. */ return JSON.parse(JSON.stringify(aRequest)); }, /* Support for DebuggerServer.addGlobalActor. */ _createExtraActors: CommonCreateExtraActors, _appendExtraActors: CommonAppendExtraActors, /* ThreadActor hooks. */ /** * Prepare to enter a nested event loop by disabling debuggee events. */ preNest: function() { // Disable events in all open windows. let e = windowMediator.getEnumerator(null); while (e.hasMoreElements()) { let win = e.getNext(); let windowUtils = win.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindowUtils); windowUtils.suppressEventHandling(true); windowUtils.suspendTimeouts(); } }, /** * Prepare to exit a nested event loop by enabling debuggee events. */ postNest: function(aNestData) { // Enable events in all open windows. let e = windowMediator.getEnumerator(null); while (e.hasMoreElements()) { let win = e.getNext(); let windowUtils = win.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindowUtils); windowUtils.resumeTimeouts(); windowUtils.suppressEventHandling(false); } }, /* ChromeDebuggerActor hooks. */ /** * Add the specified actor to the default actor pool connection, in order to * keep it alive as long as the server is. This is used by breakpoints in the * thread and chrome debugger actors. * * @param actor aActor * The actor object. */ addToParentPool: function(aActor) { this.conn.addActor(aActor); }, /** * Remove the specified actor from the default actor pool. * * @param BreakpointActor aActor * The actor object. */ removeFromParentPool: function(aActor) { this.conn.removeActor(aActor); } } RootActor.prototype.requestTypes = { "listTabs": RootActor.prototype.onListTabs, "echo": RootActor.prototype.onEcho }; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/debugger/actors/script.js ================================================ /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; js-indent-level: 2; -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* 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/. */ "use strict"; /** * BreakpointStore objects keep track of all breakpoints that get set so that we * can reset them when the same script is introduced to the thread again (such * as after a refresh). */ function BreakpointStore() { // If we have a whole-line breakpoint set at LINE in URL, then // // this._wholeLineBreakpoints[URL][LINE] // // is an object // // { url, line[, actor] } // // where the `actor` property is optional. this._wholeLineBreakpoints = Object.create(null); // If we have a breakpoint set at LINE, COLUMN in URL, then // // this._breakpoints[URL][LINE][COLUMN] // // is an object // // { url, line[, actor] } // // where the `actor` property is optional. this._breakpoints = Object.create(null); } BreakpointStore.prototype = { /** * Add a breakpoint to the breakpoint store. * * @param Object aBreakpoint * The breakpoint to be added (not copied). It is an object with the * following properties: * - url * - line * - column (optional; omission implies that the breakpoint is for * the whole line) * - actor (optional) */ addBreakpoint: function BS_addBreakpoint(aBreakpoint) { let { url, line, column } = aBreakpoint; if (column != null) { if (!this._breakpoints[url]) { this._breakpoints[url] = []; } if (!this._breakpoints[url][line]) { this._breakpoints[url][line] = []; } this._breakpoints[url][line][column] = aBreakpoint; } else { // Add a breakpoint that breaks on the whole line. if (!this._wholeLineBreakpoints[url]) { this._wholeLineBreakpoints[url] = []; } this._wholeLineBreakpoints[url][line] = aBreakpoint; } }, /** * Remove a breakpoint from the breakpoint store. * * @param Object aBreakpoint * The breakpoint to be removed. It is an object with the following * properties: * - url * - line * - column (optional) */ removeBreakpoint: function BS_removeBreakpoint({ url, line, column }) { if (column != null) { if (this._breakpoints[url]) { if (this._breakpoints[url][line]) { delete this._breakpoints[url][line][column]; // If this was the last breakpoint on this line, delete the line from // `this._breakpoints[url]` as well. Otherwise `_iterLines` will yield // this line even though we no longer have breakpoints on // it. Furthermore, we use Object.keys() instead of just checking // `this._breakpoints[url].length` directly, because deleting // properties from sparse arrays doesn't update the `length` property // like adding them does. if (Object.keys(this._breakpoints[url][line]).length === 0) { delete this._breakpoints[url][line]; } } } } else { if (this._wholeLineBreakpoints[url]) { delete this._wholeLineBreakpoints[url][line]; } } }, /** * Get a breakpoint from the breakpoint store. Will throw an error if the * breakpoint is not found. * * @param Object aLocation * The location of the breakpoint you are retrieving. It is an object * with the following properties: * - url * - line * - column (optional) */ getBreakpoint: function BS_getBreakpoint(aLocation) { let { url, line, column } = aLocation; dbg_assert(url != null); dbg_assert(line != null); var foundBreakpoint = this.hasBreakpoint(aLocation); if (foundBreakpoint == null) { throw new Error("No breakpoint at url = " + url + ", line = " + line + ", column = " + column); } return foundBreakpoint; }, /** * Checks if the breakpoint store has a requested breakpoint. * * @param Object aLocation * The location of the breakpoint you are retrieving. It is an object * with the following properties: * - url * - line * - column (optional) * @returns The stored breakpoint if it exists, null otherwise. */ hasBreakpoint: function BS_hasBreakpoint(aLocation) { let { url, line, column } = aLocation; dbg_assert(url != null); dbg_assert(line != null); for (let bp of this.findBreakpoints(aLocation)) { // We will get whole line breakpoints before individual columns, so just // return the first one and if they didn't specify a column then they will // get the whole line breakpoint, and otherwise we will find the correct // one. return bp; } return null; }, /** * Iterate over the breakpoints in this breakpoint store. You can optionally * provide search parameters to filter the set of breakpoints down to those * that match your parameters. * * @param Object aSearchParams * Optional. An object with the following properties: * - url * - line (optional; requires the url property) * - column (optional; requires the line property) */ findBreakpoints: function BS_findBreakpoints(aSearchParams={}) { if (aSearchParams.column != null) { dbg_assert(aSearchParams.line != null); } if (aSearchParams.line != null) { dbg_assert(aSearchParams.url != null); } for (let url of this._iterUrls(aSearchParams.url)) { for (let line of this._iterLines(url, aSearchParams.line)) { // Always yield whole line breakpoints first. See comment in // |BreakpointStore.prototype.hasBreakpoint|. if (aSearchParams.column == null && this._wholeLineBreakpoints[url] && this._wholeLineBreakpoints[url][line]) { yield this._wholeLineBreakpoints[url][line]; } for (let column of this._iterColumns(url, line, aSearchParams.column)) { yield this._breakpoints[url][line][column]; } } } }, _iterUrls: function BS__iterUrls(aUrl) { if (aUrl) { if (this._breakpoints[aUrl] || this._wholeLineBreakpoints[aUrl]) { yield aUrl; } } else { for (let url of Object.keys(this._wholeLineBreakpoints)) { yield url; } for (let url of Object.keys(this._breakpoints)) { if (url in this._wholeLineBreakpoints) { continue; } yield url; } } }, _iterLines: function BS__iterLines(aUrl, aLine) { if (aLine != null) { if ((this._wholeLineBreakpoints[aUrl] && this._wholeLineBreakpoints[aUrl][aLine]) || (this._breakpoints[aUrl] && this._breakpoints[aUrl][aLine])) { yield aLine; } } else { const wholeLines = this._wholeLineBreakpoints[aUrl] ? Object.keys(this._wholeLineBreakpoints[aUrl]) : []; const columnLines = this._breakpoints[aUrl] ? Object.keys(this._breakpoints[aUrl]) : []; const lines = wholeLines.concat(columnLines).sort(); let lastLine; for (let line of lines) { if (line === lastLine) { continue; } yield line; lastLine = line; } } }, _iterColumns: function BS__iterColumns(aUrl, aLine, aColumn) { if (!this._breakpoints[aUrl] || !this._breakpoints[aUrl][aLine]) { return; } if (aColumn != null) { if (this._breakpoints[aUrl][aLine][aColumn]) { yield aColumn; } } else { for (let column in this._breakpoints[aUrl][aLine]) { yield column; } } }, }; /** * Manages pushing event loops and automatically pops and exits them in the * correct order as they are resolved. * * @param nsIJSInspector inspector * The underlying JS inspector we use to enter and exit nested event * loops. * @param Object hooks * An object with the following properties: * - url: The URL string of the debuggee we are spinning an event loop * for. * - preNest: function called before entering a nested event loop * - postNest: function called after exiting a nested event loop * @param ThreadActor thread * The thread actor instance that owns this EventLoopStack. */ function EventLoopStack({ inspector, thread, hooks }) { this._inspector = inspector; this._hooks = hooks; this._thread = thread; } EventLoopStack.prototype = { /** * The number of nested event loops on the stack. */ get size() { return this._inspector.eventLoopNestLevel(); }, /** * The URL of the debuggee who pushed the event loop on top of the stack. */ get lastPausedUrl() { let url = null; if (this.size > 0) { try { url = this._inspector.lastNestRequestor.url } catch (e) { // The tab's URL getter may throw if the tab is destroyed by the time // this code runs, but we don't really care at this point. dumpn(e); } } return url; }, /** * Push a new nested event loop onto the stack. * * @returns EventLoop */ push: function () { return new EventLoop({ inspector: this._inspector, thread: this._thread, hooks: this._hooks }); } }; /** * An object that represents a nested event loop. It is used as the nest * requestor with nsIJSInspector instances. * * @param nsIJSInspector inspector * The JS Inspector that runs nested event loops. * @param ThreadActor thread * The thread actor that is creating this nested event loop. * @param Object hooks * The same hooks object passed into EventLoopStack during its * initialization. */ function EventLoop({ inspector, thread, hooks }) { this._inspector = inspector; this._thread = thread; this._hooks = hooks; this.enter = this.enter.bind(this); this.resolve = this.resolve.bind(this); } EventLoop.prototype = { entered: false, resolved: false, get url() { return this._hooks.url; }, /** * Enter this nested event loop. */ enter: function () { let nestData = this._hooks.preNest ? this._hooks.preNest() : null; this.entered = true; this._inspector.enterNestedEventLoop(this); // Keep exiting nested event loops while the last requestor is resolved. // James commented. // if (this._inspector.eventLoopNestLevel() > 0) { // const { resolved } = this._inspector.lastNestRequestor; // if (resolved) { // this._inspector.exitNestedEventLoop(); // } // } dbg_assert(this._thread.state === "running", "Should be in the running state"); if (this._hooks.postNest) { this._hooks.postNest(nestData); } }, /** * Resolve this nested event loop. * * @returns boolean * True if we exited this nested event loop because it was on top of * the stack, false if there is another nested event loop above this * one that hasn't resolved yet. */ resolve: function () { if (!this.entered) { throw new Error("Can't resolve an event loop before it has been entered!"); } if (this.resolved) { throw new Error("Already resolved this nested event loop!"); } this.resolved = true; // James commented. if (this === this._inspector.lastNestRequestor) { this._inspector.exitNestedEventLoop(); return true; } return false; }, }; /** * JSD2 actors. */ /** * Creates a ThreadActor. * * ThreadActors manage a JSInspector object and manage execution/inspection * of debuggees. * * @param aHooks object * An object with preNest and postNest methods for calling when entering * and exiting a nested event loop, addToParentPool and * removeFromParentPool methods for handling the lifetime of actors that * will outlive the thread, like breakpoints. * @param aGlobal object [optional] * An optional (for content debugging only) reference to the content * window. */ function ThreadActor(aHooks, aGlobal) { this._state = "detached"; this._frameActors = []; this._environmentActors = []; this._hooks = aHooks; this.global = aGlobal; this._nestedEventLoops = new EventLoopStack({ inspector: DebuggerServer.xpcInspector, hooks: aHooks, thread: this }); // A map of actorID -> actor for breakpoints created and managed by the server. this._hiddenBreakpoints = new Map(); this.findGlobals = this.globalManager.findGlobals.bind(this); this.onNewGlobal = this.globalManager.onNewGlobal.bind(this); this.onNewSource = this.onNewSource.bind(this); this._allEventsListener = this._allEventsListener.bind(this); this._options = { useSourceMaps: false }; } /** * The breakpoint store must be shared across instances of ThreadActor so that * page reloads don't blow away all of our breakpoints. */ ThreadActor.breakpointStore = new BreakpointStore(); ThreadActor.prototype = { actorPrefix: "context", get state() { return this._state; }, get attached() this.state == "attached" || this.state == "running" || this.state == "paused", get breakpointStore() { return ThreadActor.breakpointStore; }, get threadLifetimePool() { if (!this._threadLifetimePool) { this._threadLifetimePool = new ActorPool(this.conn); this.conn.addActorPool(this._threadLifetimePool); this._threadLifetimePool.objectActors = new WeakMap(); } return this._threadLifetimePool; }, get sources() { if (!this._sources) { this._sources = new ThreadSources(this, this._options.useSourceMaps, this._allowSource, this.onNewSource); } return this._sources; }, /** * Keep track of all of the nested event loops we use to pause the debuggee * when we hit a breakpoint/debugger statement/etc in one place so we can * resolve them when we get resume packets. We have more than one (and keep * them in a stack) because we can pause within client evals. */ _threadPauseEventLoops: null, _pushThreadPause: function TA__pushThreadPause() { if (!this._threadPauseEventLoops) { this._threadPauseEventLoops = []; } const eventLoop = this._nestedEventLoops.push(); this._threadPauseEventLoops.push(eventLoop); eventLoop.enter(); }, _popThreadPause: function TA__popThreadPause() { const eventLoop = this._threadPauseEventLoops.pop(); dbg_assert(eventLoop, "Should have an event loop."); eventLoop.resolve(); }, clearDebuggees: function TA_clearDebuggees() { if (this.dbg) { this.dbg.removeAllDebuggees(); } this.conn.removeActorPool(this._threadLifetimePool || undefined); this._threadLifetimePool = null; this._sources = null; }, /** * Add a debuggee global to the Debugger object. * * @returns the Debugger.Object that corresponds to the global. */ addDebuggee: function TA_addDebuggee(aGlobal) { let globalDebugObject; try { globalDebugObject = this.dbg.addDebuggee(aGlobal); } catch (e) { // Ignore attempts to add the debugger's compartment as a debuggee. dumpn("Ignoring request to add the debugger's compartment as a debuggee"); } return globalDebugObject; }, /** * Initialize the Debugger. */ _initDebugger: function TA__initDebugger() { this.dbg = new Debugger(); this.dbg.uncaughtExceptionHook = this.uncaughtExceptionHook.bind(this); this.dbg.onDebuggerStatement = this.onDebuggerStatement.bind(this); this.dbg.onNewScript = this.onNewScript.bind(this); this.dbg.onNewGlobalObject = this.globalManager.onNewGlobal.bind(this); // Keep the debugger disabled until a client attaches. this.dbg.enabled = this._state != "detached"; }, /** * Remove a debuggee global from the JSInspector. */ removeDebugee: function TA_removeDebuggee(aGlobal) { try { this.dbg.removeDebuggee(aGlobal); } catch(ex) { // XXX: This debuggee has code currently executing on the stack, // we need to save this for later. } }, /** * Add the provided window and all windows in its frame tree as debuggees. * * @returns the Debugger.Object that corresponds to the window. */ _addDebuggees: function TA__addDebuggees(aWindow) { let globalDebugObject = this.addDebuggee(aWindow); let frames = aWindow.frames; if (frames) { for (let i = 0; i < frames.length; i++) { this._addDebuggees(frames[i]); } } return globalDebugObject; }, /** * An object that will be used by ThreadActors to tailor their behavior * depending on the debugging context being required (chrome or content). */ globalManager: { findGlobals: function TA_findGlobals() { this.globalDebugObject = this._addDebuggees(this.global); }, /** * A function that the engine calls when a new global object has been * created. * * @param aGlobal Debugger.Object * The new global object that was created. */ onNewGlobal: function TA_onNewGlobal(aGlobal) { // Content debugging only cares about new globals in the contant window, // like iframe children. if (aGlobal.hostAnnotations && aGlobal.hostAnnotations.type == "document" && aGlobal.hostAnnotations.element === this.global) { this.addDebuggee(aGlobal); // Notify the client. this.conn.send({ from: this.actorID, type: "newGlobal", // TODO: after bug 801084 lands see if we need to JSONify this. hostAnnotations: aGlobal.hostAnnotations }); } } }, disconnect: function TA_disconnect() { dumpn("in ThreadActor.prototype.disconnect"); if (this._state == "paused") { this.onResume(); } this._state = "exited"; this.clearDebuggees(); if (!this.dbg) { return; } this.dbg.enabled = false; this.dbg = null; }, /** * Disconnect the debugger and put the actor in the exited state. */ exit: function TA_exit() { this.disconnect(); }, // Request handlers onAttach: function TA_onAttach(aRequest) { if (this.state === "exited") { return { type: "exited" }; } if (this.state !== "detached") { return { error: "wrongState" }; } this._state = "attached"; update(this._options, aRequest.options || {}); if (!this.dbg) { this._initDebugger(); } this.findGlobals(); this.dbg.enabled = true; try { // Put ourselves in the paused state. let packet = this._paused(); if (!packet) { return { error: "notAttached" }; } packet.why = { type: "attached" }; this._restoreBreakpoints(); // Send the response to the attach request now (rather than // returning it), because we're going to start a nested event loop // here. this.conn.send(packet); // Start a nested event loop. this._pushThreadPause(); // We already sent a response to this request, don't send one // now. return null; } catch (e) { reportError(e); return { error: "notAttached", message: e.toString() }; } }, onDetach: function TA_onDetach(aRequest) { this.disconnect(); dumpn("ThreadActor.prototype.onDetach: returning 'detached' packet"); return { type: "detached" }; }, onReconfigure: function TA_onReconfigure(aRequest) { if (this.state == "exited") { return { error: "wrongState" }; } update(this._options, aRequest.options || {}); // Clear existing sources, so they can be recreated on next access. this._sources = null; return {}; }, /** * Pause the debuggee, by entering a nested event loop, and return a 'paused' * packet to the client. * * @param Debugger.Frame aFrame * The newest debuggee frame in the stack. * @param object aReason * An object with a 'type' property containing the reason for the pause. * @param function onPacket * Hook to modify the packet before it is sent. Feel free to return a * promise. */ _pauseAndRespond: function TA__pauseAndRespond(aFrame, aReason, onPacket=function (k) { return k; }) { try { let packet = this._paused(aFrame); if (!packet) { return undefined; } packet.why = aReason; let { url, line, column } = packet.frame.where; this.sources.getOriginalLocation(url, line, column).then(aOrigPosition => { packet.frame.where = aOrigPosition; resolve(onPacket(packet)) .then(null, error => { reportError(error); return { error: "unknownError", message: error.message + "\n" + error.stack }; }) .then(packet => { this.conn.send(packet) }); }); this._pushThreadPause(); } catch(e) { reportError(e, "Got an exception during TA__pauseAndRespond: "); } return undefined; }, /** * Handle a protocol request to resume execution of the debuggee. */ onResume: function TA_onResume(aRequest) { if (this._state !== "paused") { return { error: "wrongState", message: "Can't resume when debuggee isn't paused. Current state is '" + this._state + "'" }; } // In case of multiple nested event loops (due to multiple debuggers open in // different tabs or multiple debugger clients connected to the same tab) // only allow resumption in a LIFO order. // James commented // if (this._nestedEventLoops.size && this._nestedEventLoops.lastPausedUrl // && this._nestedEventLoops.lastPausedUrl !== this._hooks.url) { // return { // error: "wrongOrder", // message: "trying to resume in the wrong order.", // lastPausedUrl: this._nestedEventLoops.lastPausedUrl // }; // } if (aRequest && aRequest.forceCompletion) { // TODO: remove this when Debugger.Frame.prototype.pop is implemented in // bug 736733. if (typeof this.frame.pop != "function") { return { error: "notImplemented", message: "forced completion is not yet implemented." }; } this.dbg.getNewestFrame().pop(aRequest.completionValue); let packet = this._resumed(); this._popThreadPause(); return { type: "resumeLimit", frameFinished: aRequest.forceCompletion }; } if (aRequest && aRequest.resumeLimit) { // Bind these methods because some of the hooks are called with 'this' // set to the current frame. let pauseAndRespond = (aFrame, onPacket=function (k) k) => { this._pauseAndRespond(aFrame, { type: "resumeLimit" }, onPacket); }; let createValueGrip = this.createValueGrip.bind(this); let startFrame = this.youngestFrame; let startLine; if (this.youngestFrame.script) { let offset = this.youngestFrame.offset; startLine = this.youngestFrame.script.getOffsetLine(offset); } // Define the JS hook functions for stepping. let onEnterFrame = aFrame => { let { url } = this.synchronize(this.sources.getOriginalLocation( aFrame.script.url, aFrame.script.getOffsetLine(aFrame.offset), getOffsetColumn(aFrame.offset, aFrame.script))); return this.sources.isBlackBoxed(url) ? undefined : pauseAndRespond(aFrame); }; let thread = this; let onPop = function TA_onPop(aCompletion) { // onPop is called with 'this' set to the current frame. let { url } = thread.synchronize(thread.sources.getOriginalLocation( this.script.url, this.script.getOffsetLine(this.offset), getOffsetColumn(this.offset, this.script))); if (thread.sources.isBlackBoxed(url)) { return undefined; } // Note that we're popping this frame; we need to watch for // subsequent step events on its caller. this.reportedPop = true; return pauseAndRespond(this, aPacket => { aPacket.why.frameFinished = {}; if (!aCompletion) { aPacket.why.frameFinished.terminated = true; } else if (aCompletion.hasOwnProperty("return")) { aPacket.why.frameFinished.return = createValueGrip(aCompletion.return); } else if (aCompletion.hasOwnProperty("yield")) { aPacket.why.frameFinished.return = createValueGrip(aCompletion.yield); } else { aPacket.why.frameFinished.throw = createValueGrip(aCompletion.throw); } return aPacket; }); }; let onStep = function TA_onStep() { // onStep is called with 'this' set to the current frame. let { url } = thread.synchronize(thread.sources.getOriginalLocation( this.script.url, this.script.getOffsetLine(this.offset), getOffsetColumn(this.offset, this.script))); if (thread.sources.isBlackBoxed(url)) { return undefined; } // If we've changed frame or line, then report that. if (this !== startFrame || (this.script && this.script.getOffsetLine(this.offset) != startLine)) { return pauseAndRespond(this); } // Otherwise, let execution continue. return undefined; }; let steppingType = aRequest.resumeLimit.type; if (["step", "next", "finish"].indexOf(steppingType) == -1) { return { error: "badParameterType", message: "Unknown resumeLimit type" }; } // Make sure there is still a frame on the stack if we are to continue // stepping. let stepFrame = this._getNextStepFrame(startFrame); if (stepFrame) { switch (steppingType) { case "step": this.dbg.onEnterFrame = onEnterFrame; // Fall through. case "next": stepFrame.onStep = onStep; stepFrame.onPop = onPop; break; case "finish": stepFrame.onPop = onPop; } } } else { // Clear any previous stepping hooks on a plain resumption. let frame = this.youngestFrame; while (frame) { frame.onStep = undefined; frame.onPop = undefined; frame = frame.older; } } if (aRequest) { this._options.pauseOnExceptions = aRequest.pauseOnExceptions; this.maybePauseOnExceptions(); // Break-on-DOMEvents is only supported in content debugging. let events = aRequest.pauseOnDOMEvents; if (this.global && events && (events == "*" || (Array.isArray(events) && events.length))) { //James: Skip Dom event. // this._pauseOnDOMEvents = events; // let els = Cc["@mozilla.org/eventlistenerservice;1"] // .getService(Ci.nsIEventListenerService); // els.addListenerForAllEvents(this.global, this._allEventsListener, true); } } let packet = this._resumed(); this._popThreadPause(); return packet; }, /** * Spin up a nested event loop so we can synchronously resolve a promise. * * @param aPromise * The promise we want to resolve. * @returns The promise's resolution. */ synchronize: function(aPromise) { let needNest = true; let eventLoop; let returnVal; aPromise .then((aResolvedVal) => { needNest = false; returnVal = aResolvedVal; }) .then(null, (aError) => { reportError(aError, "Error inside synchronize:"); }) .then(() => { if (eventLoop) { eventLoop.resolve(); } }); if (needNest) { eventLoop = this._nestedEventLoops.push(); eventLoop.enter(); } return returnVal; }, /** * Set the debugging hook to pause on exceptions if configured to do so. */ maybePauseOnExceptions: function() { if (this._options.pauseOnExceptions) { this.dbg.onExceptionUnwind = this.onExceptionUnwind.bind(this); } }, /** * A listener that gets called for every event fired on the page, when a list * of interesting events was provided with the pauseOnDOMEvents property. It * is used to set server-managed breakpoints on any existing event listeners * for those events. * * @param Event event * The event that was fired. */ _allEventsListener: function(event) { if (this._pauseOnDOMEvents == "*" || this._pauseOnDOMEvents.indexOf(event.type) != -1) { for (let listener of this._getAllEventListeners(event.target)) { if (event.type == listener.type || this._pauseOnDOMEvents == "*") { this._breakOnEnter(listener.script); } } } }, /** * Return an array containing all the event listeners attached to the * specified event target and its ancestors in the event target chain. * * @param EventTarget eventTarget * The target the event was dispatched on. * @returns Array */ _getAllEventListeners: function(eventTarget) { let els = Cc["@mozilla.org/eventlistenerservice;1"] .getService(Ci.nsIEventListenerService); let targets = els.getEventTargetChainFor(eventTarget); let listeners = []; for (let target of targets) { let handlers = els.getListenerInfoFor(target); for (let handler of handlers) { // Null is returned for all-events handlers, and native event listeners // don't provide any listenerObject, which makes them not that useful to // a JS debugger. if (!handler || !handler.listenerObject || !handler.type) continue; // Create a listener-like object suitable for our purposes. let l = Object.create(null); l.type = handler.type; let listener = handler.listenerObject; l.script = this.globalDebugObject.makeDebuggeeValue(listener).script; // Chrome listeners won't be converted to debuggee values, since their // compartment is not added as a debuggee. if (!l.script) continue; listeners.push(l); } } return listeners; }, /** * Set a breakpoint on the first bytecode offset in the provided script. */ _breakOnEnter: function(script) { let offsets = script.getAllOffsets(); for (let line = 0, n = offsets.length; line < n; line++) { if (offsets[line]) { let location = { url: script.url, line: line }; let resp = this._createAndStoreBreakpoint(location); dbg_assert(!resp.actualLocation, "No actualLocation should be returned"); if (resp.error) { reportError(new Error("Unable to set breakpoint on event listener")); return; } let bp = this.breakpointStore.getBreakpoint(location); let bpActor = bp.actor; dbg_assert(bp, "Breakpoint must exist"); dbg_assert(bpActor, "Breakpoint actor must be created"); this._hiddenBreakpoints.set(bpActor.actorID, bpActor); break; } } }, /** * Helper method that returns the next frame when stepping. */ _getNextStepFrame: function TA__getNextStepFrame(aFrame) { let stepFrame = aFrame.reportedPop ? aFrame.older : aFrame; if (!stepFrame || !stepFrame.script) { stepFrame = null; } return stepFrame; }, onClientEvaluate: function TA_onClientEvaluate(aRequest) { if (this.state !== "paused") { return { error: "wrongState", message: "Debuggee must be paused to evaluate code." }; }; let frame = this._requestFrame(aRequest.frame); if (!frame) { return { error: "unknownFrame", message: "Evaluation frame not found" }; } if (!frame.environment) { return { error: "notDebuggee", message: "cannot access the environment of this frame." }; }; // We'll clobber the youngest frame if the eval causes a pause, so // save our frame now to be restored after eval returns. // XXX: or we could just start using dbg.getNewestFrame() now that it // works as expected. let youngest = this.youngestFrame; // Put ourselves back in the running state and inform the client. let resumedPacket = this._resumed(); this.conn.send(resumedPacket); // Run the expression. // XXX: test syntax errors let completion = frame.eval(aRequest.expression); // Put ourselves back in the pause state. let packet = this._paused(youngest); packet.why = { type: "clientEvaluated", frameFinished: this.createProtocolCompletionValue(completion) }; // Return back to our previous pause's event loop. return packet; }, onFrames: function TA_onFrames(aRequest) { if (this.state !== "paused") { return { error: "wrongState", message: "Stack frames are only available while the debuggee is paused."}; } let start = aRequest.start ? aRequest.start : 0; let count = aRequest.count; // Find the starting frame... let frame = this.youngestFrame; let i = 0; while (frame && (i < start)) { frame = frame.older; i++; } // Return request.count frames, or all remaining // frames if count is not defined. let frames = []; let promises = []; for (; frame && (!count || i < (start + count)); i++, frame=frame.older) { let form = this._createFrameActor(frame).form(); form.depth = i; frames.push(form); let { url, line, column } = form.where; let promise = this.sources.getOriginalLocation(url, line, column) .then((aOrigLocation) => { form.where = aOrigLocation; let source = this.sources.source(form.where.url); if (source) { form.source = source.form(); } }); promises.push(promise); } return all(promises).then(function () { return { frames: frames }; }); }, onReleaseMany: function TA_onReleaseMany(aRequest) { if (!aRequest.actors) { return { error: "missingParameter", message: "no actors were specified" }; } let res; for each (let actorID in aRequest.actors) { let actor = this.threadLifetimePool.get(actorID); if (!actor) { if (!res) { res = { error: "notReleasable", message: "Only thread-lifetime actors can be released." }; } continue; } actor.onRelease(); } return res ? res : {}; }, /** * Handle a protocol request to set a breakpoint. */ onSetBreakpoint: function TA_onSetBreakpoint(aRequest) { if (this.state !== "paused") { return { error: "wrongState", message: "Breakpoints can only be set while the debuggee is paused."}; } let { url: originalSource, line: originalLine, column: originalColumn } = aRequest.location; let locationPromise = this.sources.getGeneratedLocation(originalSource, originalLine, originalColumn); return locationPromise.then(({url, line, column}) => { if (line == null || line < 0 || this.dbg.findScripts({ url: url }).length == 0) { return { error: "noScript" }; } let response = this._createAndStoreBreakpoint({ url: url, line: line, column: column }); // If the original location of our generated location is different from // the original location we attempted to set the breakpoint on, we will // need to know so that we can set actualLocation on the response. let originalLocation = this.sources.getOriginalLocation(url, line, column); return all([response, originalLocation]) .then(([aResponse, {url, line}]) => { if (aResponse.actualLocation) { let actualOrigLocation = this.sources.getOriginalLocation( aResponse.actualLocation.url, aResponse.actualLocation.line, aResponse.actualLocation.column); return actualOrigLocation.then(function ({ url, line, column }) { if (url !== originalSource || line !== originalLine || column !== originalColumn) { aResponse.actualLocation = { url: url, line: line, column: column }; } return aResponse; }); } if (url !== originalSource || line !== originalLine) { aResponse.actualLocation = { url: url, line: line }; } return aResponse; }); }); }, /** * Create a breakpoint at the specified location and store it in the * cache. Takes ownership of `aLocation`. * * @param Object aLocation * An object of the form { url, line[, column] } */ _createAndStoreBreakpoint: function (aLocation) { // Add the breakpoint to the store for later reuse, in case it belongs to a // script that hasn't appeared yet. this.breakpointStore.addBreakpoint(aLocation); return this._setBreakpoint(aLocation); }, /** * Set a breakpoint using the jsdbg2 API. If the line on which the breakpoint * is being set contains no code, then the breakpoint will slide down to the * next line that has runnable code. In this case the server breakpoint cache * will be updated, so callers that iterate over the breakpoint cache should * take that into account. * * @param object aLocation * The location of the breakpoint (in the generated source, if source * mapping). */ _setBreakpoint: function TA__setBreakpoint(aLocation) { let actor; let storedBp = this.breakpointStore.getBreakpoint(aLocation); if (storedBp.actor) { actor = storedBp.actor; } else { storedBp.actor = actor = new BreakpointActor(this, { url: aLocation.url, line: aLocation.line, column: aLocation.column }); this._hooks.addToParentPool(actor); } // Find all scripts matching the given location let scripts = this.dbg.findScripts(aLocation); if (scripts.length == 0) { return { error: "noScript", actor: actor.actorID }; } /** * For each script, if the given line has at least one entry point, set a * breakpoint on the bytecode offets for each of them. */ // Debugger.Script -> array of offset mappings let scriptsAndOffsetMappings = new Map(); for (let script of scripts) { this._findClosestOffsetMappings(aLocation, script, scriptsAndOffsetMappings); } if (scriptsAndOffsetMappings.size > 0) { for (let [script, mappings] of scriptsAndOffsetMappings) { for (let offsetMapping of mappings) { script.setBreakpoint(offsetMapping.offset, actor); } actor.addScript(script, this); } return { actor: actor.actorID }; } /** * If we get here, no breakpoint was set. This is because the given line * has no entry points, for example because it is empty. As a fallback * strategy, we try to set the breakpoint on the smallest line greater * than or equal to the given line that as at least one entry point. */ // Find all innermost scripts matching the given location let scripts = this.dbg.findScripts({ url: aLocation.url, line: aLocation.line, innermost: true }); /** * For each innermost script, look for the smallest line greater than or * equal to the given line that has one or more entry points. If found, set * a breakpoint on the bytecode offset for each of its entry points. */ let actualLocation; let found = false; for (let script of scripts) { let offsets = script.getAllOffsets(); for (let line = aLocation.line; line < offsets.length; ++line) { if (offsets[line]) { for (let offset of offsets[line]) { script.setBreakpoint(offset, actor); } actor.addScript(script, this); if (!actualLocation) { actualLocation = { url: aLocation.url, line: line, column: 0 }; } found = true; break; } } } if (found) { let existingBp = this.breakpointStore.hasBreakpoint(actualLocation); if (existingBp && existingBp.actor) { /** * We already have a breakpoint actor for the actual location, so * actor we created earlier is now redundant. Delete it, update the * breakpoint store, and return the actor for the actual location. */ actor.onDelete(); this.breakpointStore.removeBreakpoint(aLocation); return { actor: existingBp.actor.actorID, actualLocation: actualLocation }; } else { /** * We don't have a breakpoint actor for the actual location yet. * Instead or creating a new actor, reuse the actor we created earlier, * and update the breakpoint store. */ actor.location = actualLocation; this.breakpointStore.addBreakpoint({ actor: actor, url: actualLocation.url, line: actualLocation.line, column: actualLocation.column }); this.breakpointStore.removeBreakpoint(aLocation); return { actor: actor.actorID, actualLocation: actualLocation }; } } /** * If we get here, no line matching the given line was found, so just * fail epically. */ return { error: "noCodeAtLineColumn", actor: actor.actorID }; }, /** * Find all of the offset mappings associated with `aScript` that are closest * to `aTargetLocation`. If new offset mappings are found that are closer to * `aTargetOffset` than the existing offset mappings inside * `aScriptsAndOffsetMappings`, we empty that map and only consider the * closest offset mappings. If there is no column in `aTargetLocation`, we add * all offset mappings that are on the given line. * * @param Object aTargetLocation * An object of the form { url, line[, column] }. * @param Debugger.Script aScript * The script in which we are searching for offsets. * @param Map aScriptsAndOffsetMappings * A Map object which maps Debugger.Script instances to arrays of * offset mappings. This is an out param. */ _findClosestOffsetMappings: function TA__findClosestOffsetMappings(aTargetLocation, aScript, aScriptsAndOffsetMappings) { let offsetMappings = aScript.getAllColumnOffsets() .filter(({ lineNumber }) => lineNumber === aTargetLocation.line); // If we are given a column, we will try and break only at that location, // otherwise we will break anytime we get on that line. if (aTargetLocation.column == null) { if (offsetMappings.length) { aScriptsAndOffsetMappings.set(aScript, offsetMappings); } return; } // Attempt to find the current closest offset distance from the target // location by grabbing any offset mapping in the map by doing one iteration // and then breaking (they all have the same distance from the target // location). let closestDistance = Infinity; if (aScriptsAndOffsetMappings.size) { for (let mappings of aScriptsAndOffsetMappings.values()) { closestDistance = Math.abs(aTargetLocation.column - mappings[0].columnNumber); break; } } for (let mapping of offsetMappings) { let currentDistance = Math.abs(aTargetLocation.column - mapping.columnNumber); if (currentDistance > closestDistance) { continue; } else if (currentDistance < closestDistance) { closestDistance = currentDistance; aScriptsAndOffsetMappings.clear(); aScriptsAndOffsetMappings.set(aScript, [mapping]); } else { if (!aScriptsAndOffsetMappings.has(aScript)) { aScriptsAndOffsetMappings.set(aScript, []); } aScriptsAndOffsetMappings.get(aScript).push(mapping); } } }, /** * Get the script and source lists from the debugger. * * TODO bug 637572: we should be dealing with sources directly, not inferring * them through scripts. */ _discoverSources: function TA__discoverSources() { // Only get one script per url. let scriptsByUrl = {}; for (let s of this.dbg.findScripts()) { scriptsByUrl[s.url] = s; } return all([this.sources.sourcesForScript(scriptsByUrl[s]) for (s of Object.keys(scriptsByUrl))]); }, onSources: function TA_onSources(aRequest) { return this._discoverSources().then(() => { return { sources: [s.form() for (s of this.sources.iter())] }; }); }, /** * Disassociate all breakpoint actors from their scripts and clear the * breakpoint handlers. This method can be used when the thread actor intends * to keep the breakpoint store, but needs to clear any actual breakpoints, * e.g. due to a page navigation. This way the breakpoint actors' script * caches won't hold on to the Debugger.Script objects leaking memory. */ disableAllBreakpoints: function () { for (let bp of this.breakpointStore.findBreakpoints()) { if (bp.actor) { bp.actor.removeScripts(); } } }, /** * Handle a protocol request to pause the debuggee. */ onInterrupt: function TA_onInterrupt(aRequest) { if (this.state == "exited") { return { type: "exited" }; } else if (this.state == "paused") { // TODO: return the actual reason for the existing pause. return { type: "paused", why: { type: "alreadyPaused" } }; } else if (this.state != "running") { return { error: "wrongState", message: "Received interrupt request in " + this.state + " state." }; } try { // Put ourselves in the paused state. let packet = this._paused(); if (!packet) { return { error: "notInterrupted" }; } packet.why = { type: "interrupted" }; // Send the response to the interrupt request now (rather than // returning it), because we're going to start a nested event loop // here. this.conn.send(packet); // Start a nested event loop. this._pushThreadPause(); // We already sent a response to this request, don't send one // now. return null; } catch (e) { reportError(e); return { error: "notInterrupted", message: e.toString() }; } }, /** * Handle a protocol request to retrieve all the event listeners on the page. */ onEventListeners: function TA_onEventListeners(aRequest) { // This request is only supported in content debugging. if (!this.global) { return { error: "notImplemented", message: "eventListeners request is only supported in content debugging" } } let els = Cc["@mozilla.org/eventlistenerservice;1"] .getService(Ci.nsIEventListenerService); let nodes = this.global.document.getElementsByTagName("*"); nodes = [this.global].concat([].slice.call(nodes)); let listeners = []; for (let node of nodes) { let handlers = els.getListenerInfoFor(node); for (let handler of handlers) { // Create a form object for serializing the listener via the protocol. let listenerForm = Object.create(null); let listener = handler.listenerObject; // Native event listeners don't provide any listenerObject and are not // that useful to a JS debugger. if (!listener) { continue; } // There will be no tagName if the event listener is set on the window. let selector = node.tagName ? findCssSelector(node) : "window"; let nodeDO = this.globalDebugObject.makeDebuggeeValue(node); listenerForm.node = { selector: selector, object: this.createValueGrip(nodeDO) }; listenerForm.type = handler.type; listenerForm.capturing = handler.capturing; listenerForm.allowsUntrusted = handler.allowsUntrusted; listenerForm.inSystemEventGroup = handler.inSystemEventGroup; listenerForm.isEventHandler = !!node["on" + listenerForm.type]; // Get the Debugger.Object for the listener object. let listenerDO = this.globalDebugObject.makeDebuggeeValue(listener); listenerForm.function = this.createValueGrip(listenerDO); listeners.push(listenerForm); } } return { listeners: listeners }; }, /** * Return the Debug.Frame for a frame mentioned by the protocol. */ _requestFrame: function TA_requestFrame(aFrameID) { if (!aFrameID) { return this.youngestFrame; } if (this._framePool.has(aFrameID)) { return this._framePool.get(aFrameID).frame; } return undefined; }, _paused: function TA__paused(aFrame) { // We don't handle nested pauses correctly. Don't try - if we're // paused, just continue running whatever code triggered the pause. // We don't want to actually have nested pauses (although we // have nested event loops). If code runs in the debuggee during // a pause, it should cause the actor to resume (dropping // pause-lifetime actors etc) and then repause when complete. if (this.state === "paused") { return undefined; } // Clear stepping hooks. this.dbg.onEnterFrame = undefined; this.dbg.onExceptionUnwind = undefined; if (aFrame) { aFrame.onStep = undefined; aFrame.onPop = undefined; } // Clear DOM event breakpoints. // XPCShell tests don't use actual DOM windows for globals and cause // removeListenerForAllEvents to throw. if (this.global && !this.global.toString().contains("Sandbox")) { //James: Skip Dom Event. // let els = Cc["@mozilla.org/eventlistenerservice;1"] // .getService(Ci.nsIEventListenerService); // els.removeListenerForAllEvents(this.global, this._allEventsListener, true); for (let [,bp] of this._hiddenBreakpoints) { bp.onDelete(); } this._hiddenBreakpoints.clear(); } this._state = "paused"; // Save the pause frame (if any) as the youngest frame for // stack viewing. this.youngestFrame = aFrame; // Create the actor pool that will hold the pause actor and its // children. dbg_assert(!this._pausePool, "No pause pool should exist yet"); this._pausePool = new ActorPool(this.conn); this.conn.addActorPool(this._pausePool); // Give children of the pause pool a quick link back to the // thread... this._pausePool.threadActor = this; // Create the pause actor itself... dbg_assert(!this._pauseActor, "No pause actor should exist yet"); this._pauseActor = new PauseActor(this._pausePool); this._pausePool.addActor(this._pauseActor); // Update the list of frames. let poppedFrames = this._updateFrames(); // Send off the paused packet and spin an event loop. let packet = { from: this.actorID, type: "paused", actor: this._pauseActor.actorID }; if (aFrame) { packet.frame = this._createFrameActor(aFrame).form(); } if (poppedFrames) { packet.poppedFrames = poppedFrames; } return packet; }, _resumed: function TA_resumed() { this._state = "running"; // Drop the actors in the pause actor pool. this.conn.removeActorPool(this._pausePool); this._pausePool = null; this._pauseActor = null; this.youngestFrame = null; return { from: this.actorID, type: "resumed" }; }, /** * Expire frame actors for frames that have been popped. * * @returns A list of actor IDs whose frames have been popped. */ _updateFrames: function TA_updateFrames() { let popped = []; // Create the actor pool that will hold the still-living frames. let framePool = new ActorPool(this.conn); let frameList = []; for each (let frameActor in this._frameActors) { if (frameActor.frame.live) { framePool.addActor(frameActor); frameList.push(frameActor); } else { popped.push(frameActor.actorID); } } // Remove the old frame actor pool, this will expire // any actors that weren't added to the new pool. if (this._framePool) { this.conn.removeActorPool(this._framePool); } this._frameActors = frameList; this._framePool = framePool; this.conn.addActorPool(framePool); return popped; }, _createFrameActor: function TA_createFrameActor(aFrame) { if (aFrame.actor) { return aFrame.actor; } let actor = new FrameActor(aFrame, this); this._frameActors.push(actor); this._framePool.addActor(actor); aFrame.actor = actor; return actor; }, /** * Create and return an environment actor that corresponds to the provided * Debugger.Environment. * @param Debugger.Environment aEnvironment * The lexical environment we want to extract. * @param object aPool * The pool where the newly-created actor will be placed. * @return The EnvironmentActor for aEnvironment or undefined for host * functions or functions scoped to a non-debuggee global. */ createEnvironmentActor: function TA_createEnvironmentActor(aEnvironment, aPool) { if (!aEnvironment) { return undefined; } if (aEnvironment.actor) { return aEnvironment.actor; } let actor = new EnvironmentActor(aEnvironment, this); this._environmentActors.push(actor); aPool.addActor(actor); aEnvironment.actor = actor; return actor; }, /** * Create a grip for the given debuggee value. If the value is an * object, will create an actor with the given lifetime. */ createValueGrip: function TA_createValueGrip(aValue, aPool=false) { if (!aPool) { aPool = this._pausePool; } let type = typeof(aValue); if (type === "string" && this._stringIsLong(aValue)) { return this.longStringGrip(aValue, aPool); } if (type === "boolean" || type === "string" || type === "number") { return aValue; } if (aValue === null) { return { type: "null" }; } if (aValue === undefined) { return { type: "undefined" } } if (typeof(aValue) === "object") { return this.objectGrip(aValue, aPool); } dbg_assert(false, "Failed to provide a grip for: " + aValue); return null; }, /** * Return a protocol completion value representing the given * Debugger-provided completion value. */ createProtocolCompletionValue: function TA_createProtocolCompletionValue(aCompletion) { let protoValue = {}; if ("return" in aCompletion) { protoValue.return = this.createValueGrip(aCompletion.return); } else if ("yield" in aCompletion) { protoValue.return = this.createValueGrip(aCompletion.yield); } else if ("throw" in aCompletion) { protoValue.throw = this.createValueGrip(aCompletion.throw); } else { protoValue.terminated = true; } return protoValue; }, /** * Create a grip for the given debuggee object. * * @param aValue Debugger.Object * The debuggee object value. * @param aPool ActorPool * The actor pool where the new object actor will be added. */ objectGrip: function TA_objectGrip(aValue, aPool) { if (!aPool.objectActors) { aPool.objectActors = new WeakMap(); } if (aPool.objectActors.has(aValue)) { return aPool.objectActors.get(aValue).grip(); } else if (this.threadLifetimePool.objectActors.has(aValue)) { return this.threadLifetimePool.objectActors.get(aValue).grip(); } let actor = new PauseScopedObjectActor(aValue, this); aPool.addActor(actor); aPool.objectActors.set(aValue, actor); return actor.grip(); }, /** * Create a grip for the given debuggee object with a pause lifetime. * * @param aValue Debugger.Object * The debuggee object value. */ pauseObjectGrip: function TA_pauseObjectGrip(aValue) { if (!this._pausePool) { throw "Object grip requested while not paused."; } return this.objectGrip(aValue, this._pausePool); }, /** * Extend the lifetime of the provided object actor to thread lifetime. * * @param aActor object * The object actor. */ threadObjectGrip: function TA_threadObjectGrip(aActor) { // We want to reuse the existing actor ID, so we just remove it from the // current pool's weak map and then let pool.addActor do the rest. aActor.registeredPool.objectActors.delete(aActor.obj); this.threadLifetimePool.addActor(aActor); this.threadLifetimePool.objectActors.set(aActor.obj, aActor); }, /** * Handle a protocol request to promote multiple pause-lifetime grips to * thread-lifetime grips. * * @param aRequest object * The protocol request object. */ onThreadGrips: function OA_onThreadGrips(aRequest) { if (this.state != "paused") { return { error: "wrongState" }; } if (!aRequest.actors) { return { error: "missingParameter", message: "no actors were specified" }; } for (let actorID of aRequest.actors) { let actor = this._pausePool.get(actorID); if (actor) { this.threadObjectGrip(actor); } } return {}; }, /** * Create a grip for the given string. * * @param aString String * The string we are creating a grip for. * @param aPool ActorPool * The actor pool where the new actor will be added. */ longStringGrip: function TA_longStringGrip(aString, aPool) { if (!aPool.longStringActors) { aPool.longStringActors = {}; } if (aPool.longStringActors.hasOwnProperty(aString)) { return aPool.longStringActors[aString].grip(); } let actor = new LongStringActor(aString, this); aPool.addActor(actor); aPool.longStringActors[aString] = actor; return actor.grip(); }, /** * Create a long string grip that is scoped to a pause. * * @param aString String * The string we are creating a grip for. */ pauseLongStringGrip: function TA_pauseLongStringGrip (aString) { return this.longStringGrip(aString, this._pausePool); }, /** * Create a long string grip that is scoped to a thread. * * @param aString String * The string we are creating a grip for. */ threadLongStringGrip: function TA_pauseLongStringGrip (aString) { return this.longStringGrip(aString, this._threadLifetimePool); }, /** * Returns true if the string is long enough to use a LongStringActor instead * of passing the value directly over the protocol. * * @param aString String * The string we are checking the length of. */ _stringIsLong: function TA__stringIsLong(aString) { return aString.length >= DebuggerServer.LONG_STRING_LENGTH; }, // JS Debugger API hooks. /** * A function that the engine calls when a call to a debug event hook, * breakpoint handler, watchpoint handler, or similar function throws some * exception. * * @param aException exception * The exception that was thrown in the debugger code. */ uncaughtExceptionHook: function TA_uncaughtExceptionHook(aException) { dumpn("Got an exception: " + aException.message + "\n" + aException.stack); }, /** * A function that the engine calls when a debugger statement has been * executed in the specified frame. * * @param aFrame Debugger.Frame * The stack frame that contained the debugger statement. */ onDebuggerStatement: function TA_onDebuggerStatement(aFrame) { // Don't pause if we are currently stepping (in or over) or the frame is // black-boxed. let { url } = this.synchronize(this.sources.getOriginalLocation( aFrame.script.url, aFrame.script.getOffsetLine(aFrame.offset), getOffsetColumn(aFrame.offset, aFrame.script))); return this.sources.isBlackBoxed(url) || aFrame.onStep ? undefined : this._pauseAndRespond(aFrame, { type: "debuggerStatement" }); }, /** * A function that the engine calls when an exception has been thrown and has * propagated to the specified frame. * * @param aFrame Debugger.Frame * The youngest remaining stack frame. * @param aValue object * The exception that was thrown. */ onExceptionUnwind: function TA_onExceptionUnwind(aFrame, aValue) { let { url } = this.synchronize(this.sources.getOriginalLocation( aFrame.script.url, aFrame.script.getOffsetLine(aFrame.offset), getOffsetColumn(aFrame.offset, aFrame.script))); if (this.sources.isBlackBoxed(url)) { return undefined; } try { let packet = this._paused(aFrame); if (!packet) { return undefined; } packet.why = { type: "exception", exception: this.createValueGrip(aValue) }; this.conn.send(packet); this._pushThreadPause(); } catch(e) { reportError(e, "Got an exception during TA_onExceptionUnwind: "); } return undefined; }, /** * A function that the engine calls when a new script has been loaded into the * scope of the specified debuggee global. * * @param aScript Debugger.Script * The source script that has been loaded into a debuggee compartment. * @param aGlobal Debugger.Object * A Debugger.Object instance whose referent is the global object. */ onNewScript: function TA_onNewScript(aScript, aGlobal) { this._addScript(aScript); this.sources.sourcesForScript(aScript); }, onNewSource: function TA_onNewSource(aSource) { this.conn.send({ from: this.actorID, type: "newSource", source: aSource.form() }); }, /** * Check if scripts from the provided source URL are allowed to be stored in * the cache. * * @param aSourceUrl String * The url of the script's source that will be stored. * @returns true, if the script can be added, false otherwise. */ _allowSource: function TA__allowSource(aSourceUrl) { // Ignore anything we don't have a URL for (eval scripts, for example). if (!aSourceUrl) return false; // Ignore XBL bindings for content debugging. if (aSourceUrl.indexOf("chrome://") == 0) { return false; } // Ignore about:* pages for content debugging. if (aSourceUrl.indexOf("about:") == 0) { return false; } return true; }, /** * Restore any pre-existing breakpoints to the scripts that we have access to. */ _restoreBreakpoints: function TA__restoreBreakpoints() { for (let s of this.dbg.findScripts()) { this._addScript(s); } }, /** * Add the provided script to the server cache. * * @param aScript Debugger.Script * The source script that will be stored. * @returns true, if the script was added; false otherwise. */ _addScript: function TA__addScript(aScript) { if (!this._allowSource(aScript.url)) { return false; } // Set any stored breakpoints. let endLine = aScript.startLine + aScript.lineCount - 1; for (let bp of this.breakpointStore.findBreakpoints({ url: aScript.url })) { // Only consider breakpoints that are not already associated with // scripts, and limit search to the line numbers contained in the new // script. if (!bp.actor.scripts.length && bp.line >= aScript.startLine && bp.line <= endLine) { this._setBreakpoint(bp); } } return true; }, }; ThreadActor.prototype.requestTypes = { "attach": ThreadActor.prototype.onAttach, "detach": ThreadActor.prototype.onDetach, "reconfigure": ThreadActor.prototype.onReconfigure, "resume": ThreadActor.prototype.onResume, "clientEvaluate": ThreadActor.prototype.onClientEvaluate, "frames": ThreadActor.prototype.onFrames, "interrupt": ThreadActor.prototype.onInterrupt, "eventListeners": ThreadActor.prototype.onEventListeners, "releaseMany": ThreadActor.prototype.onReleaseMany, "setBreakpoint": ThreadActor.prototype.onSetBreakpoint, "sources": ThreadActor.prototype.onSources, "threadGrips": ThreadActor.prototype.onThreadGrips }; /** * Creates a PauseActor. * * PauseActors exist for the lifetime of a given debuggee pause. Used to * scope pause-lifetime grips. * * @param ActorPool aPool * The actor pool created for this pause. */ function PauseActor(aPool) { this.pool = aPool; } PauseActor.prototype = { actorPrefix: "pause" }; /** * A base actor for any actors that should only respond receive messages in the * paused state. Subclasses may expose a `threadActor` which is used to help * determine when we are in a paused state. Subclasses should set their own * "constructor" property if they want better error messages. You should never * instantiate a PauseScopedActor directly, only through subclasses. */ function PauseScopedActor() { } /** * A function decorator for creating methods to handle protocol messages that * should only be received while in the paused state. * * @param aMethod Function * The function we are decorating. */ PauseScopedActor.withPaused = function PSA_withPaused(aMethod) { return function () { if (this.isPaused()) { return aMethod.apply(this, arguments); } else { return this._wrongState(); } }; }; PauseScopedActor.prototype = { /** * Returns true if we are in the paused state. */ isPaused: function PSA_isPaused() { // When there is not a ThreadActor available (like in the webconsole) we // have to be optimistic and assume that we are paused so that we can // respond to requests. return this.threadActor ? this.threadActor.state === "paused" : true; }, /** * Returns the wrongState response packet for this actor. */ _wrongState: function PSA_wrongState() { return { error: "wrongState", message: this.constructor.name + " actors can only be accessed while the thread is paused." }; } }; /** * A SourceActor provides information about the source of a script. * * @param aUrl String * The url of the source we are representing. * @param aThreadActor ThreadActor * The current thread actor. * @param aSourceMap SourceMapConsumer * Optional. The source map that introduced this source, if available. */ function SourceActor(aUrl, aThreadActor, aSourceMap=null) { this._threadActor = aThreadActor; this._url = aUrl; this._sourceMap = aSourceMap; } SourceActor.prototype = { constructor: SourceActor, actorPrefix: "source", get threadActor() this._threadActor, get url() this._url, form: function SA_form() { return { actor: this.actorID, url: this._url, isBlackBoxed: this.threadActor.sources.isBlackBoxed(this.url) // TODO bug 637572: introductionScript }; }, disconnect: function LSA_disconnect() { if (this.registeredPool && this.registeredPool.sourceActors) { delete this.registeredPool.sourceActors[this.actorID]; } }, /** * Handler for the "source" packet. */ onSource: function SA_onSource(aRequest) { let sourceContent = null; if (this._sourceMap) { sourceContent = this._sourceMap.sourceContentFor(this._url); } if (sourceContent) { return { from: this.actorID, source: this.threadActor.createValueGrip( sourceContent, this.threadActor.threadLifetimePool) }; } // XXX bug 865252: Don't load from the cache if this is a source mapped // source because we can't guarantee that the cache has the most up to date // content for this source like we can if it isn't source mapped. return fetch(this._url, { loadFromCache: !this._sourceMap }) .then((aSource) => { return this.threadActor.createValueGrip( aSource, this.threadActor.threadLifetimePool); }) .then((aSourceGrip) => { return { from: this.actorID, source: aSourceGrip }; }, (aError) => { reportError(aError, "Got an exception during SA_onSource: "); return { "from": this.actorID, "error": "loadSourceError", "message": "Could not load the source for " + this._url + "." }; }); }, /** * Handler for the "blackbox" packet. */ onBlackBox: function SA_onBlackBox(aRequest) { this.threadActor.sources.blackBox(this.url); let packet = { from: this.actorID }; if (this.threadActor.state == "paused" && this.threadActor.youngestFrame && this.threadActor.youngestFrame.script.url == this.url) { packet.pausedInSource = true; } return packet; }, /** * Handler for the "unblackbox" packet. */ onUnblackBox: function SA_onUnblackBox(aRequest) { this.threadActor.sources.unblackBox(this.url); return { from: this.actorID }; } }; SourceActor.prototype.requestTypes = { "source": SourceActor.prototype.onSource, "blackbox": SourceActor.prototype.onBlackBox, "unblackbox": SourceActor.prototype.onUnblackBox }; /** * Creates an actor for the specified object. * * @param aObj Debugger.Object * The debuggee object. * @param aThreadActor ThreadActor * The parent thread actor for this object. */ function ObjectActor(aObj, aThreadActor) { this.obj = aObj; this.threadActor = aThreadActor; } ObjectActor.prototype = { actorPrefix: "obj", /** * Returns a grip for this actor for returning in a protocol message. */ grip: function OA_grip() { let g = { "type": "object", "class": this.obj.class, "actor": this.actorID, "extensible": this.obj.isExtensible(), "frozen": this.obj.isFrozen(), "sealed": this.obj.isSealed() }; // Add additional properties for functions. if (this.obj.class === "Function") { if (this.obj.name) { g.name = this.obj.name; } else if (this.obj.displayName) { g.displayName = this.obj.displayName; } // Check if the developer has added a de-facto standard displayName // property for us to use. let desc = this.obj.getOwnPropertyDescriptor("displayName"); if (desc && desc.value && typeof desc.value == "string") { g.userDisplayName = this.threadActor.createValueGrip(desc.value); } // Add source location information. if (this.obj.script) { g.url = this.obj.script.url; g.line = this.obj.script.startLine; } } return g; }, /** * Releases this actor from the pool. */ release: function OA_release() { if (this.registeredPool.objectActors) { this.registeredPool.objectActors.delete(this.obj); } this.registeredPool.removeActor(this); }, /** * Handle a protocol request to provide the names of the properties defined on * the object and not its prototype. * * @param aRequest object * The protocol request object. */ onOwnPropertyNames: function OA_onOwnPropertyNames(aRequest) { return { from: this.actorID, ownPropertyNames: this.obj.getOwnPropertyNames() }; }, /** * Handle a protocol request to provide the prototype and own properties of * the object. * * @param aRequest object * The protocol request object. */ onPrototypeAndProperties: function OA_onPrototypeAndProperties(aRequest) { let ownProperties = Object.create(null); let names; try { names = this.obj.getOwnPropertyNames(); } catch (ex) { // The above can throw if this.obj points to a dead object. // TODO: we should use Cu.isDeadWrapper() - see bug 885800. return { from: this.actorID, prototype: this.threadActor.createValueGrip(null), ownProperties: ownProperties, safeGetterValues: Object.create(null) }; } for (let name of names) { ownProperties[name] = this._propertyDescriptor(name); } return { from: this.actorID, prototype: this.threadActor.createValueGrip(this.obj.proto), ownProperties: ownProperties, safeGetterValues: this._findSafeGetterValues(ownProperties) }; }, /** * Find the safe getter values for the current Debugger.Object, |this.obj|. * * @private * @param object aOwnProperties * The object that holds the list of known ownProperties for * |this.obj|. * @return object * An object that maps property names to safe getter descriptors as * defined by the remote debugging protocol. */ _findSafeGetterValues: function OA__findSafeGetterValues(aOwnProperties) { let safeGetterValues = Object.create(null); let obj = this.obj; let level = 0; while (obj) { let getters = this._findSafeGetters(obj); for (let name of getters) { // Avoid overwriting properties from prototypes closer to this.obj. Also // avoid providing safeGetterValues from prototypes if property |name| // is already defined as an own property. if (name in safeGetterValues || (obj != this.obj && name in aOwnProperties)) { continue; } let desc = null, getter = null; try { desc = obj.getOwnPropertyDescriptor(name); getter = desc.get; } catch (ex) { // The above can throw if the cache becomes stale. } if (!getter) { obj._safeGetters = null; continue; } let result = getter.call(this.obj); if (result && !("throw" in result)) { let getterValue = undefined; if ("return" in result) { getterValue = result.return; } else if ("yield" in result) { getterValue = result.yield; } // WebIDL attributes specified with the LenientThis extended attribute // return undefined and should be ignored. if (getterValue !== undefined) { safeGetterValues[name] = { getterValue: this.threadActor.createValueGrip(getterValue), getterPrototypeLevel: level, enumerable: desc.enumerable, writable: level == 0 ? desc.writable : true, }; } } } obj = obj.proto; level++; } return safeGetterValues; }, /** * Find the safe getters for a given Debugger.Object. Safe getters are native * getters which are safe to execute. * * @private * @param Debugger.Object aObject * The Debugger.Object where you want to find safe getters. * @return Set * A Set of names of safe getters. This result is cached for each * Debugger.Object. */ _findSafeGetters: function OA__findSafeGetters(aObject) { if (aObject._safeGetters) { return aObject._safeGetters; } let getters = new Set(); for (let name of aObject.getOwnPropertyNames()) { let desc = null; try { desc = aObject.getOwnPropertyDescriptor(name); } catch (e) { // Calling getOwnPropertyDescriptor on wrapped native prototypes is not // allowed (bug 560072). } if (!desc || desc.value !== undefined || !("get" in desc)) { continue; } let fn = desc.get; if (fn && fn.callable && fn.class == "Function" && fn.script === undefined) { getters.add(name); } } aObject._safeGetters = getters; return getters; }, /** * Handle a protocol request to provide the prototype of the object. * * @param aRequest object * The protocol request object. */ onPrototype: function OA_onPrototype(aRequest) { return { from: this.actorID, prototype: this.threadActor.createValueGrip(this.obj.proto) }; }, /** * Handle a protocol request to provide the property descriptor of the * object's specified property. * * @param aRequest object * The protocol request object. */ onProperty: function OA_onProperty(aRequest) { if (!aRequest.name) { return { error: "missingParameter", message: "no property name was specified" }; } return { from: this.actorID, descriptor: this._propertyDescriptor(aRequest.name) }; }, /** * Handle a protocol request to provide the display string for the object. * * @param aRequest object * The protocol request object. */ onDisplayString: function OA_onDisplayString(aRequest) { let toString; try { // Attempt to locate the object's "toString" method. let obj = this.obj; do { let desc = obj.getOwnPropertyDescriptor("toString"); if (desc) { toString = desc.value; break; } } while ((obj = obj.proto)) } catch (e) { dumpn(e); } let result = null; if (toString && toString.callable) { // If a toString method was found then call it on the object. let ret = toString.call(this.obj).return; if (typeof ret == "string") { // Only use the result if it was a returned string. result = ret; } } return { from: this.actorID, displayString: this.threadActor.createValueGrip(result) }; }, /** * A helper method that creates a property descriptor for the provided object, * properly formatted for sending in a protocol response. * * @param string aName * The property that the descriptor is generated for. */ _propertyDescriptor: function OA_propertyDescriptor(aName) { let desc; try { desc = this.obj.getOwnPropertyDescriptor(aName); } catch (e) { // Calling getOwnPropertyDescriptor on wrapped native prototypes is not // allowed (bug 560072). Inform the user with a bogus, but hopefully // explanatory, descriptor. return { configurable: false, writable: false, enumerable: false, value: e.name }; } if (!desc) { return undefined; } let retval = { configurable: desc.configurable, enumerable: desc.enumerable }; if ("value" in desc) { retval.writable = desc.writable; retval.value = this.threadActor.createValueGrip(desc.value); } else { if ("get" in desc) { retval.get = this.threadActor.createValueGrip(desc.get); } if ("set" in desc) { retval.set = this.threadActor.createValueGrip(desc.set); } } return retval; }, /** * Handle a protocol request to provide the source code of a function. * * @param aRequest object * The protocol request object. */ onDecompile: function OA_onDecompile(aRequest) { if (this.obj.class !== "Function") { return { error: "objectNotFunction", message: "decompile request is only valid for object grips " + "with a 'Function' class." }; } return { from: this.actorID, decompiledCode: this.obj.decompile(!!aRequest.pretty) }; }, /** * Handle a protocol request to provide the parameters of a function. * * @param aRequest object * The protocol request object. */ onParameterNames: function OA_onParameterNames(aRequest) { if (this.obj.class !== "Function") { return { error: "objectNotFunction", message: "'parameterNames' request is only valid for object " + "grips with a 'Function' class." }; } return { parameterNames: this.obj.parameterNames }; }, /** * Handle a protocol request to release a thread-lifetime grip. * * @param aRequest object * The protocol request object. */ onRelease: function OA_onRelease(aRequest) { this.release(); return {}; }, }; ObjectActor.prototype.requestTypes = { "parameterNames": ObjectActor.prototype.onParameterNames, "prototypeAndProperties": ObjectActor.prototype.onPrototypeAndProperties, "prototype": ObjectActor.prototype.onPrototype, "property": ObjectActor.prototype.onProperty, "displayString": ObjectActor.prototype.onDisplayString, "ownPropertyNames": ObjectActor.prototype.onOwnPropertyNames, "decompile": ObjectActor.prototype.onDecompile, "release": ObjectActor.prototype.onRelease, }; /** * Creates a pause-scoped actor for the specified object. * @see ObjectActor */ function PauseScopedObjectActor() { ObjectActor.apply(this, arguments); } PauseScopedObjectActor.prototype = Object.create(PauseScopedActor.prototype); update(PauseScopedObjectActor.prototype, ObjectActor.prototype); update(PauseScopedObjectActor.prototype, { constructor: PauseScopedObjectActor, onOwnPropertyNames: PauseScopedActor.withPaused(ObjectActor.prototype.onOwnPropertyNames), onPrototypeAndProperties: PauseScopedActor.withPaused(ObjectActor.prototype.onPrototypeAndProperties), onPrototype: PauseScopedActor.withPaused(ObjectActor.prototype.onPrototype), onProperty: PauseScopedActor.withPaused(ObjectActor.prototype.onProperty), onDecompile: PauseScopedActor.withPaused(ObjectActor.prototype.onDecompile), onDisplayString: PauseScopedActor.withPaused(ObjectActor.prototype.onDisplayString), onParameterNames: PauseScopedActor.withPaused(ObjectActor.prototype.onParameterNames), /** * Handle a protocol request to provide the lexical scope of a function. * * @param aRequest object * The protocol request object. */ onScope: PauseScopedActor.withPaused(function OA_onScope(aRequest) { if (this.obj.class !== "Function") { return { error: "objectNotFunction", message: "scope request is only valid for object grips with a" + " 'Function' class." }; } let envActor = this.threadActor.createEnvironmentActor(this.obj.environment, this.registeredPool); if (!envActor) { return { error: "notDebuggee", message: "cannot access the environment of this function." }; } return { from: this.actorID, scope: envActor.form() }; }), /** * Handle a protocol request to promote a pause-lifetime grip to a * thread-lifetime grip. * * @param aRequest object * The protocol request object. */ onThreadGrip: PauseScopedActor.withPaused(function OA_onThreadGrip(aRequest) { this.threadActor.threadObjectGrip(this); return {}; }), /** * Handle a protocol request to release a thread-lifetime grip. * * @param aRequest object * The protocol request object. */ onRelease: PauseScopedActor.withPaused(function OA_onRelease(aRequest) { if (this.registeredPool !== this.threadActor.threadLifetimePool) { return { error: "notReleasable", message: "Only thread-lifetime actors can be released." }; } this.release(); return {}; }), }); update(PauseScopedObjectActor.prototype.requestTypes, { "scope": PauseScopedObjectActor.prototype.onScope, "threadGrip": PauseScopedObjectActor.prototype.onThreadGrip, }); /** * Creates an actor for the specied "very long" string. "Very long" is specified * at the server's discretion. * * @param aString String * The string. */ function LongStringActor(aString) { this.string = aString; this.stringLength = aString.length; } LongStringActor.prototype = { actorPrefix: "longString", disconnect: function LSA_disconnect() { // Because longStringActors is not a weak map, we won't automatically leave // it so we need to manually leave on disconnect so that we don't leak // memory. if (this.registeredPool && this.registeredPool.longStringActors) { delete this.registeredPool.longStringActors[this.actorID]; } }, /** * Returns a grip for this actor for returning in a protocol message. */ grip: function LSA_grip() { return { "type": "longString", "initial": this.string.substring( 0, DebuggerServer.LONG_STRING_INITIAL_LENGTH), "length": this.stringLength, "actor": this.actorID }; }, /** * Handle a request to extract part of this actor's string. * * @param aRequest object * The protocol request object. */ onSubstring: function LSA_onSubString(aRequest) { return { "from": this.actorID, "substring": this.string.substring(aRequest.start, aRequest.end) }; }, /** * Handle a request to release this LongStringActor instance. */ onRelease: function LSA_onRelease() { // TODO: also check if registeredPool === threadActor.threadLifetimePool // when the web console moves aray from manually releasing pause-scoped // actors. if (this.registeredPool.longStringActors) { delete this.registeredPool.longStringActors[this.actorID]; } this.registeredPool.removeActor(this); return {}; }, }; LongStringActor.prototype.requestTypes = { "substring": LongStringActor.prototype.onSubstring, "release": LongStringActor.prototype.onRelease }; /** * Creates an actor for the specified stack frame. * * @param aFrame Debugger.Frame * The debuggee frame. * @param aThreadActor ThreadActor * The parent thread actor for this frame. */ function FrameActor(aFrame, aThreadActor) { this.frame = aFrame; this.threadActor = aThreadActor; } FrameActor.prototype = { actorPrefix: "frame", /** * A pool that contains frame-lifetime objects, like the environment. */ _frameLifetimePool: null, get frameLifetimePool() { if (!this._frameLifetimePool) { this._frameLifetimePool = new ActorPool(this.conn); this.conn.addActorPool(this._frameLifetimePool); } return this._frameLifetimePool; }, /** * Finalization handler that is called when the actor is being evicted from * the pool. */ disconnect: function FA_disconnect() { this.conn.removeActorPool(this._frameLifetimePool); this._frameLifetimePool = null; }, /** * Returns a frame form for use in a protocol message. */ form: function FA_form() { let form = { actor: this.actorID, type: this.frame.type }; if (this.frame.type === "call") { form.callee = this.threadActor.createValueGrip(this.frame.callee); } if (this.frame.environment) { let envActor = this.threadActor .createEnvironmentActor(this.frame.environment, this.frameLifetimePool); form.environment = envActor.form(); } form.this = this.threadActor.createValueGrip(this.frame.this); form.arguments = this._args(); if (this.frame.script) { form.where = { url: this.frame.script.url, line: this.frame.script.getOffsetLine(this.frame.offset), column: getOffsetColumn(this.frame.offset, this.frame.script) }; } if (!this.frame.older) { form.oldest = true; } return form; }, _args: function FA__args() { if (!this.frame.arguments) { return []; } return [this.threadActor.createValueGrip(arg) for each (arg in this.frame.arguments)]; }, /** * Handle a protocol request to pop this frame from the stack. * * @param aRequest object * The protocol request object. */ onPop: function FA_onPop(aRequest) { // TODO: remove this when Debugger.Frame.prototype.pop is implemented if (typeof this.frame.pop != "function") { return { error: "notImplemented", message: "Popping frames is not yet implemented." }; } while (this.frame != this.threadActor.dbg.getNewestFrame()) { this.threadActor.dbg.getNewestFrame().pop(); } this.frame.pop(aRequest.completionValue); // TODO: return the watches property when frame pop watch actors are // implemented. return { from: this.actorID }; } }; FrameActor.prototype.requestTypes = { "pop": FrameActor.prototype.onPop, }; /** * Creates a BreakpointActor. BreakpointActors exist for the lifetime of their * containing thread and are responsible for deleting breakpoints, handling * breakpoint hits and associating breakpoints with scripts. * * @param ThreadActor aThreadActor * The parent thread actor that contains this breakpoint. * @param object aLocation * The location of the breakpoint as specified in the protocol. */ function BreakpointActor(aThreadActor, aLocation) { this.scripts = []; this.threadActor = aThreadActor; this.location = aLocation; } BreakpointActor.prototype = { actorPrefix: "breakpoint", /** * Called when this same breakpoint is added to another Debugger.Script * instance, in the case of a page reload. * * @param aScript Debugger.Script * The new source script on which the breakpoint has been set. * @param ThreadActor aThreadActor * The parent thread actor that contains this breakpoint. */ addScript: function BA_addScript(aScript, aThreadActor) { this.threadActor = aThreadActor; this.scripts.push(aScript); }, /** * Remove the breakpoints from associated scripts and clear the script cache. */ removeScripts: function () { for (let script of this.scripts) { script.clearBreakpoint(this); } this.scripts = []; }, /** * A function that the engine calls when a breakpoint has been hit. * * @param aFrame Debugger.Frame * The stack frame that contained the breakpoint. */ hit: function BA_hit(aFrame) { // Don't pause if we are currently stepping (in or over) or the frame is // black-boxed. let { url } = this.threadActor.synchronize( this.threadActor.sources.getOriginalLocation( this.location.url, this.location.line, this.location.column)); if (this.threadActor.sources.isBlackBoxed(url) || aFrame.onStep) { return undefined; } let reason = {}; if (this.threadActor._hiddenBreakpoints.has(this.actorID)) { reason.type = "pauseOnDOMEvents"; } else { reason.type = "breakpoint"; // TODO: add the rest of the breakpoints on that line (bug 676602). reason.actors = [ this.actorID ]; } return this.threadActor._pauseAndRespond(aFrame, reason); }, /** * Handle a protocol request to remove this breakpoint. * * @param aRequest object * The protocol request object. */ onDelete: function BA_onDelete(aRequest) { // Remove from the breakpoint store. this.threadActor.breakpointStore.removeBreakpoint(this.location); this.threadActor._hooks.removeFromParentPool(this); // Remove the actual breakpoint from the associated scripts. this.removeScripts(); return { from: this.actorID }; } }; BreakpointActor.prototype.requestTypes = { "delete": BreakpointActor.prototype.onDelete }; /** * Creates an EnvironmentActor. EnvironmentActors are responsible for listing * the bindings introduced by a lexical environment and assigning new values to * those identifier bindings. * * @param Debugger.Environment aEnvironment * The lexical environment that will be used to create the actor. * @param ThreadActor aThreadActor * The parent thread actor that contains this environment. */ function EnvironmentActor(aEnvironment, aThreadActor) { this.obj = aEnvironment; this.threadActor = aThreadActor; } EnvironmentActor.prototype = { actorPrefix: "environment", /** * Return an environment form for use in a protocol message. */ form: function EA_form() { let form = { actor: this.actorID }; // What is this environment's type? if (this.obj.type == "declarative") { form.type = this.obj.callee ? "function" : "block"; } else { form.type = this.obj.type; } // Does this environment have a parent? if (this.obj.parent) { form.parent = (this.threadActor .createEnvironmentActor(this.obj.parent, this.registeredPool) .form()); } // Does this environment reflect the properties of an object as variables? if (this.obj.type == "object" || this.obj.type == "with") { form.object = this.threadActor.createValueGrip(this.obj.object); } // Is this the environment created for a function call? if (this.obj.callee) { form.function = this.threadActor.createValueGrip(this.obj.callee); } // Shall we list this environment's bindings? if (this.obj.type == "declarative") { form.bindings = this._bindings(); } return form; }, /** * Return the identifier bindings object as required by the remote protocol * specification. */ _bindings: function EA_bindings() { let bindings = { arguments: [], variables: {} }; // TODO: this part should be removed in favor of the commented-out part // below when getVariableDescriptor lands (bug 725815). if (typeof this.obj.getVariable != "function") { //if (typeof this.obj.getVariableDescriptor != "function") { return bindings; } let parameterNames; if (this.obj.callee) { parameterNames = this.obj.callee.parameterNames; } for each (let name in parameterNames) { let arg = {}; // TODO: this part should be removed in favor of the commented-out part // below when getVariableDescriptor lands (bug 725815). let desc = { value: this.obj.getVariable(name), configurable: false, writable: true, enumerable: true }; // let desc = this.obj.getVariableDescriptor(name); let descForm = { enumerable: true, configurable: desc.configurable }; if ("value" in desc) { descForm.value = this.threadActor.createValueGrip(desc.value); descForm.writable = desc.writable; } else { descForm.get = this.threadActor.createValueGrip(desc.get); descForm.set = this.threadActor.createValueGrip(desc.set); } arg[name] = descForm; bindings.arguments.push(arg); } for each (let name in this.obj.names()) { if (bindings.arguments.some(function exists(element) { return !!element[name]; })) { continue; } // TODO: this part should be removed in favor of the commented-out part // below when getVariableDescriptor lands. let desc = { configurable: false, writable: true, enumerable: true }; try { desc.value = this.obj.getVariable(name); } catch (e) { // Avoid "Debugger scope is not live" errors for |arguments|, introduced // in bug 746601. if (name != "arguments") { throw e; } } //let desc = this.obj.getVariableDescriptor(name); let descForm = { enumerable: true, configurable: desc.configurable }; if ("value" in desc) { descForm.value = this.threadActor.createValueGrip(desc.value); descForm.writable = desc.writable; } else { descForm.get = this.threadActor.createValueGrip(desc.get); descForm.set = this.threadActor.createValueGrip(desc.set); } bindings.variables[name] = descForm; } return bindings; }, /** * Handle a protocol request to change the value of a variable bound in this * lexical environment. * * @param aRequest object * The protocol request object. */ onAssign: function EA_onAssign(aRequest) { // TODO: enable the commented-out part when getVariableDescriptor lands // (bug 725815). /*let desc = this.obj.getVariableDescriptor(aRequest.name); if (!desc.writable) { return { error: "immutableBinding", message: "Changing the value of an immutable binding is not " + "allowed" }; }*/ try { this.obj.setVariable(aRequest.name, aRequest.value); } catch (e) { if (e instanceof Debugger.DebuggeeWouldRun) { return { error: "threadWouldRun", cause: e.cause ? e.cause : "setter", message: "Assigning a value would cause the debuggee to run" }; } // This should never happen, so let it complain loudly if it does. throw e; } return { from: this.actorID }; }, /** * Handle a protocol request to fully enumerate the bindings introduced by the * lexical environment. * * @param aRequest object * The protocol request object. */ onBindings: function EA_onBindings(aRequest) { return { from: this.actorID, bindings: this._bindings() }; } }; EnvironmentActor.prototype.requestTypes = { "assign": EnvironmentActor.prototype.onAssign, "bindings": EnvironmentActor.prototype.onBindings }; /** * Override the toString method in order to get more meaningful script output * for debugging the debugger. */ Debugger.Script.prototype.toString = function() { let output = ""; if (this.url) { output += this.url; } if (typeof this.startLine != "undefined") { output += ":" + this.startLine; if (this.lineCount && this.lineCount > 1) { output += "-" + (this.startLine + this.lineCount - 1); } } if (this.strictMode) { output += ":strict"; } return output; }; /** * Helper property for quickly getting to the line number a stack frame is * currently paused at. */ Object.defineProperty(Debugger.Frame.prototype, "line", { configurable: true, get: function() { if (this.script) { return this.script.getOffsetLine(this.offset); } else { return null; } } }); /** * Creates an actor for handling chrome debugging. ChromeDebuggerActor is a * thin wrapper over ThreadActor, slightly changing some of its behavior. * * @param aConnection object * The DebuggerServerConnection with which this ChromeDebuggerActor * is associated. (Currently unused, but required to make this * constructor usable with addGlobalActor.) * * @param aHooks object * An object with preNest and postNest methods for calling when entering * and exiting a nested event loop and also addToParentPool and * removeFromParentPool methods for handling the lifetime of actors that * will outlive the thread, like breakpoints. */ function ChromeDebuggerActor(aConnection, aHooks) { ThreadActor.call(this, aHooks); } ChromeDebuggerActor.prototype = Object.create(ThreadActor.prototype); update(ChromeDebuggerActor.prototype, { constructor: ChromeDebuggerActor, // A constant prefix that will be used to form the actor ID by the server. actorPrefix: "chromeDebugger", /** * Override the eligibility check for scripts and sources to make sure every * script and source with a URL is stored when debugging chrome. */ _allowSource: function(aSourceURL) !!aSourceURL, /** * An object that will be used by ThreadActors to tailor their behavior * depending on the debugging context being required (chrome or content). * The methods that this object provides must be bound to the ThreadActor * before use. */ globalManager: { findGlobals: function CDA_findGlobals() { // Add every global known to the debugger as debuggee. this.dbg.addAllGlobalsAsDebuggees(); }, /** * A function that the engine calls when a new global object has been * created. * * @param aGlobal Debugger.Object * The new global object that was created. */ onNewGlobal: function CDA_onNewGlobal(aGlobal) { this.addDebuggee(aGlobal); // Notify the client. this.conn.send({ from: this.actorID, type: "newGlobal", // TODO: after bug 801084 lands see if we need to JSONify this. hostAnnotations: aGlobal.hostAnnotations }); } } }); /** * Manages the sources for a thread. Handles source maps, locations in the * sources, etc for ThreadActors. */ function ThreadSources(aThreadActor, aUseSourceMaps, aAllowPredicate, aOnNewSource) { this._thread = aThreadActor; this._useSourceMaps = aUseSourceMaps; this._allow = aAllowPredicate; this._onNewSource = aOnNewSource; // source map URL --> promise of SourceMapConsumer this._sourceMaps = Object.create(null); // generated source url --> promise of SourceMapConsumer this._sourceMapsByGeneratedSource = Object.create(null); // original source url --> promise of SourceMapConsumer this._sourceMapsByOriginalSource = Object.create(null); // source url --> SourceActor this._sourceActors = Object.create(null); // original url --> generated url this._generatedUrlsByOriginalUrl = Object.create(null); } /** * Must be a class property because it needs to persist across reloads, same as * the breakpoint store. */ ThreadSources._blackBoxedSources = new Set(); ThreadSources.prototype = { /** * Return the source actor representing |aURL|, creating one if none * exists already. Returns null if |aURL| is not allowed by the 'allow' * predicate. * * Right now this takes a URL, but in the future it should * take a Debugger.Source. See bug 637572. * * @param String aURL * The source URL. * @param optional SourceMapConsumer aSourceMap * The source map that introduced this source, if any. * @returns a SourceActor representing the source at aURL or null. */ source: function TS_source(aURL, aSourceMap=null) { if (!this._allow(aURL)) { return null; } if (aURL in this._sourceActors) { return this._sourceActors[aURL]; } let actor = new SourceActor(aURL, this._thread, aSourceMap); this._thread.threadLifetimePool.addActor(actor); this._sourceActors[aURL] = actor; try { this._onNewSource(actor); } catch (e) { reportError(e); } return actor; }, /** * Return a promise of an array of source actors representing all the * sources of |aScript|. * * If source map handling is enabled and |aScript| has a source map, then * use it to find all of |aScript|'s *original* sources; return a promise * of an array of source actors for those. */ sourcesForScript: function TS_sourcesForScript(aScript) { if (!this._useSourceMaps || !aScript.sourceMapURL) { return resolve([this.source(aScript.url)].filter(isNotNull)); } return this.sourceMap(aScript) .then((aSourceMap) => { return [ this.source(s, aSourceMap) for (s of aSourceMap.sources) ]; }) .then(null, (e) => { reportError(e); delete this._sourceMaps[this._normalize(aScript.sourceMapURL, aScript.url)]; delete this._sourceMapsByGeneratedSource[aScript.url]; return [this.source(aScript.url)]; }) .then(function (aSources) { return aSources.filter(isNotNull); }); }, /** * Return a promise of a SourceMapConsumer for the source map for * |aScript|; if we already have such a promise extant, return that. * |aScript| must have a non-null sourceMapURL. */ sourceMap: function TS_sourceMap(aScript) { if (aScript.url in this._sourceMapsByGeneratedSource) { return this._sourceMapsByGeneratedSource[aScript.url]; } dbg_assert(aScript.sourceMapURL, "Script should have a sourceMapURL"); let sourceMapURL = this._normalize(aScript.sourceMapURL, aScript.url); let map = this._fetchSourceMap(sourceMapURL, aScript.url) .then((aSourceMap) => { for (let s of aSourceMap.sources) { this._generatedUrlsByOriginalUrl[s] = aScript.url; this._sourceMapsByOriginalSource[s] = resolve(aSourceMap); } return aSourceMap; }); this._sourceMapsByGeneratedSource[aScript.url] = map; return map; }, /** * Return a promise of a SourceMapConsumer for the source map located at * |aAbsSourceMapURL|, which must be absolute. If there is already such a * promise extant, return it. * * @param string aAbsSourceMapURL * The source map URL, in absolute form, not relative. * @param string aScriptURL * When the source map URL is a data URI, there is no sourceRoot on the * source map, and the source map's sources are relative, we resolve * them from aScriptURL. */ _fetchSourceMap: function TS__fetchSourceMap(aAbsSourceMapURL, aScriptURL) { if (aAbsSourceMapURL in this._sourceMaps) { return this._sourceMaps[aAbsSourceMapURL]; } let promise = fetch(aAbsSourceMapURL).then(rawSourceMap => { let map = new SourceMapConsumer(rawSourceMap); this._setSourceMapRoot(map, aAbsSourceMapURL, aScriptURL); return map; }); this._sourceMaps[aAbsSourceMapURL] = promise; return promise; }, /** * Sets the source map's sourceRoot to be relative to the source map url. */ _setSourceMapRoot: function TS__setSourceMapRoot(aSourceMap, aAbsSourceMapURL, aScriptURL) { const base = this._dirname( aAbsSourceMapURL.indexOf("data:") === 0 ? aScriptURL : aAbsSourceMapURL); aSourceMap.sourceRoot = aSourceMap.sourceRoot ? this._normalize(aSourceMap.sourceRoot, base) : base; }, _dirname: function TS__dirname(aPath) { return Services.io.newURI( ".", null, Services.io.newURI(aPath, null, null)).spec; }, /** * Returns a promise of the location in the original source if the source is * source mapped, otherwise a promise of the same location. */ getOriginalLocation: function TS_getOriginalLocation(aSourceUrl, aLine, aColumn) { if (aSourceUrl in this._sourceMapsByGeneratedSource) { return this._sourceMapsByGeneratedSource[aSourceUrl] .then(function (aSourceMap) { let { source, line, column } = aSourceMap.originalPositionFor({ line: aLine, column: aColumn }); return { url: source, line: line, column: column }; }); } // No source map return resolve({ url: aSourceUrl, line: aLine, column: aColumn }); }, /** * Returns a promise of the location in the generated source corresponding to * the original source and line given. * * When we pass a script S representing generated code to |sourceMap|, * above, that returns a promise P. The process of resolving P populates * the tables this function uses; thus, it won't know that S's original * source URLs map to S until P is resolved. */ getGeneratedLocation: function TS_getGeneratedLocation(aSourceUrl, aLine, aColumn) { if (aSourceUrl in this._sourceMapsByOriginalSource) { return this._sourceMapsByOriginalSource[aSourceUrl] .then((aSourceMap) => { let { line, column } = aSourceMap.generatedPositionFor({ source: aSourceUrl, line: aLine, column: aColumn == null ? Infinity : aColumn }); return { url: this._generatedUrlsByOriginalUrl[aSourceUrl], line: line, column: column }; }); } // No source map return resolve({ url: aSourceUrl, line: aLine, column: aColumn }); }, /** * Returns true if URL for the given source is black boxed. * * @param aURL String * The URL of the source which we are checking whether it is black * boxed or not. */ isBlackBoxed: function TS_isBlackBoxed(aURL) { return ThreadSources._blackBoxedSources.has(aURL); }, /** * Add the given source URL to the set of sources that are black boxed. If the * thread is currently paused and we are black boxing the yougest frame's * source, this will force a step. * * @param aURL String * The URL of the source which we are black boxing. */ blackBox: function TS_blackBox(aURL) { ThreadSources._blackBoxedSources.add(aURL); }, /** * Remove the given source URL to the set of sources that are black boxed. * * @param aURL String * The URL of the source which we are no longer black boxing. */ unblackBox: function TS_unblackBox(aURL) { ThreadSources._blackBoxedSources.delete(aURL); }, /** * Normalize multiple relative paths towards the base paths on the right. */ _normalize: function TS__normalize(...aURLs) { dbg_assert(aURLs.length > 1, "Should have more than 1 URL"); let base = Services.io.newURI(aURLs.pop(), null, null); let url; while ((url = aURLs.pop())) { base = Services.io.newURI(url, null, base); } return base.spec; }, iter: function TS_iter() { for (let url in this._sourceActors) { yield this._sourceActors[url]; } } }; // Utility functions. // TODO bug 863089: use Debugger.Script.prototype.getOffsetColumn when it is // implemented. function getOffsetColumn(aOffset, aScript) { let bestOffsetMapping = null; for (let offsetMapping of aScript.getAllColumnOffsets()) { if (!bestOffsetMapping || (offsetMapping.offset <= aOffset && offsetMapping.offset > bestOffsetMapping.offset)) { bestOffsetMapping = offsetMapping; } } if (!bestOffsetMapping) { // XXX: Try not to completely break the experience of using the debugger for // the user by assuming column 0. Simultaneously, report the error so that // there is a paper trail if the assumption is bad and the debugging // experience becomes wonky. reportError(new Error("Could not find a column for offset " + aOffset + " in the script " + aScript)); return 0; } return bestOffsetMapping.columnNumber; } /** * Utility function for updating an object with the properties of another * object. * * @param aTarget Object * The object being updated. * @param aNewAttrs Object * The new attributes being set on the target. */ function update(aTarget, aNewAttrs) { for (let key in aNewAttrs) { let desc = Object.getOwnPropertyDescriptor(aNewAttrs, key); if (desc) { Object.defineProperty(aTarget, key, desc); } } } /** * Returns true if its argument is not null. */ function isNotNull(aThing) { return aThing !== null; } /** * Performs a request to load the desired URL and returns a promise. * * @param aURL String * The URL we will request. * @returns Promise * A promise of the document at that URL, as a string. * * XXX: It may be better to use nsITraceableChannel to get to the sources * without relying on caching when we can (not for eval, etc.): * http://www.softwareishard.com/blog/firebug/nsitraceablechannel-intercept-http-traffic/ */ function fetch(aURL, aOptions={ loadFromCache: true }) { let deferred = defer(); let scheme; let url = aURL.split(" -> ").pop(); let charset; let filePath = url; // try { // scheme = Services.io.extractScheme(url); // } catch (e) { // In the xpcshell tests, the script url is the absolute path of the test // file, which will make a malformed URI error be thrown. Add the file // scheme prefix ourselves. url = "file://" + url; // scheme = Services.io.extractScheme(url); // } scheme = "file"; switch (scheme) { case "file": case "chrome": case "resource": try { // NetUtil.asyncFetch(url, function onFetch(aStream, aStatus) { // if (!Components.isSuccessCode(aStatus)) { // deferred.reject("Request failed: " + url); // return; // } let cc = globalDebuggee.cc; let fileUtils = cc.FileUtils.getInstance(); let source = fileUtils.getStringFromFile(filePath);//NetUtil.readInputStreamToString(aStream, aStream.available()); if (!source) { deferred.reject("Request failed: " + url); } else { deferred.resolve(source); } // aStream.close(); // }); } catch (ex) { deferred.reject("Request failed: " + url); } break; default: let channel; try { channel = Services.io.newChannel(url, null, null); } catch (e if e.name == "NS_ERROR_UNKNOWN_PROTOCOL") { // On Windows xpcshell tests, c:/foo/bar can pass as a valid URL, but // newChannel won't be able to handle it. url = "file:///" + url; channel = Services.io.newChannel(url, null, null); } let chunks = []; let streamListener = { onStartRequest: function(aRequest, aContext, aStatusCode) { if (!Components.isSuccessCode(aStatusCode)) { deferred.reject(new Error("Request failed: " + url)); } }, onDataAvailable: function(aRequest, aContext, aStream, aOffset, aCount) { chunks.push(NetUtil.readInputStreamToString(aStream, aCount)); }, onStopRequest: function(aRequest, aContext, aStatusCode) { if (!Components.isSuccessCode(aStatusCode)) { deferred.reject(new Error("Request failed: " + url)); return; } charset = channel.contentCharset; deferred.resolve(chunks.join("")); } }; channel.loadFlags = aOptions.loadFromCache ? channel.LOAD_FROM_CACHE : channel.LOAD_BYPASS_CACHE; channel.asyncOpen(streamListener, null); break; } return deferred.promise.then(function (source) { return convertToUnicode(source, charset); }); } /** * Convert a given string, encoded in a given character set, to unicode. * * @param string aString * A string. * @param string aCharset * A character set. */ function convertToUnicode(aString, aCharset=null) { // Decoding primitives. // James: return aString directly. // let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] // .createInstance(Ci.nsIScriptableUnicodeConverter); // try { // converter.charset = aCharset || "UTF-8"; // return converter.ConvertToUnicode(aString); // } catch(e) { return aString; // } } /** * Report the given error in the error console and to stdout. * * @param Error aError * The error object you wish to report. * @param String aPrefix * An optional prefix for the reported error message. */ function reportError(aError, aPrefix="") { dbg_assert(aError instanceof Error, "Must pass Error objects to reportError"); let msg = aPrefix + aError.message + ":\n" + aError.stack; //Cu.reportError(msg); dumpn(msg); } // The following are copied here verbatim from css-logic.js, until we create a // server-friendly helper module. /** * Find a unique CSS selector for a given element * @returns a string such that ele.ownerDocument.querySelector(reply) === ele * and ele.ownerDocument.querySelectorAll(reply).length === 1 */ function findCssSelector(ele) { var document = ele.ownerDocument; if (ele.id && document.getElementById(ele.id) === ele) { return '#' + ele.id; } // Inherently unique by tag name var tagName = ele.tagName.toLowerCase(); if (tagName === 'html') { return 'html'; } if (tagName === 'head') { return 'head'; } if (tagName === 'body') { return 'body'; } if (ele.parentNode == null) { console.log('danger: ' + tagName); } // We might be able to find a unique class name var selector, index, matches; if (ele.classList.length > 0) { for (var i = 0; i < ele.classList.length; i++) { // Is this className unique by itself? selector = '.' + ele.classList.item(i); matches = document.querySelectorAll(selector); if (matches.length === 1) { return selector; } // Maybe it's unique with a tag name? selector = tagName + selector; matches = document.querySelectorAll(selector); if (matches.length === 1) { return selector; } // Maybe it's unique using a tag name and nth-child index = positionInNodeList(ele, ele.parentNode.children) + 1; selector = selector + ':nth-child(' + index + ')'; matches = document.querySelectorAll(selector); if (matches.length === 1) { return selector; } } } // So we can be unique w.r.t. our parent, and use recursion index = positionInNodeList(ele, ele.parentNode.children) + 1; selector = findCssSelector(ele.parentNode) + ' > ' + tagName + ':nth-child(' + index + ')'; return selector; }; /** * Find the position of [element] in [nodeList]. * @returns an index of the match, or -1 if there is no match */ function positionInNodeList(element, nodeList) { for (var i = 0; i < nodeList.length; i++) { if (element === nodeList[i]) { return i; } } return -1; } ================================================ FILE: cocos2d/cocos/scripting/javascript/script/debugger/core/promise.js ================================================ /* vim:set ts=2 sw=2 sts=2 expandtab */ /*jshint undef: true es5: true node: true browser: true devel: true forin: true latedef: false */ /*global define: true, Cu: true, __URI__: true */ //;(function(id, factory) { // Module boilerplate :( // if (typeof(define) === 'function') { // RequireJS // define(factory); // } else if (typeof(require) === 'function') { // CommonJS // factory.call(this, require, exports, module); // } else if (String(this).indexOf('BackstagePass') >= 0) { // JSM // this[factory.name] = {}; // try { // this.console = this['Components'].utils // .import('resource://gre/modules/devtools/Console.jsm', {}).console; // } // catch (ex) { // // Avoid failures on different toolkit configurations. // } // factory(function require(uri) { // var imports = {}; // this['Components'].utils.import(uri, imports); // return imports; // }, this[factory.name], { uri: __URI__, id: id }); // this.EXPORTED_SYMBOLS = [factory.name]; // } else { // Browser or alike // var globals = this; // factory(function require(id) { // return globals[id]; // }, (globals[id] = {}), { uri: document.location.href + '#' + id, id: id }); // } //}).call(this, 'promise/core', function Promise(require, exports, module) { 'use strict'; var exports = exports || {}; //module.metadata = { // "stability": "unstable" //}; /** * Internal utility: Wraps given `value` into simplified promise, successfully * fulfilled to a given `value`. Note the result is not a complete promise * implementation, as its method `then` does not returns anything. */ function fulfilled(value) { return { then: function then(fulfill) { fulfill(value); } }; } /** * Internal utility: Wraps given input into simplified promise, pre-rejected * with a given `reason`. Note the result is not a complete promise * implementation, as its method `then` does not returns anything. */ function rejected(reason) { return { then: function then(fulfill, reject) { reject(reason); } }; } /** * Internal utility: Returns `true` if given `value` is a promise. Value is * assumed to be a promise if it implements method `then`. */ function isPromise(value) { return value && typeof(value.then) === 'function'; } /** * Creates deferred object containing fresh promise & methods to either resolve * or reject it. The result is an object with the following properties: * - `promise` Eventual value representation implementing CommonJS [Promises/A] * (http://wiki.commonjs.org/wiki/Promises/A) API. * - `resolve` Single shot function that resolves enclosed `promise` with a * given `value`. * - `reject` Single shot function that rejects enclosed `promise` with a given * `reason`. * * An optional `prototype` argument is used as a prototype of the returned * `promise` allowing one to implement additional API. If prototype is not * passed then it falls back to `Object.prototype`. * * ## Example * * function fetchURI(uri, type) { * var deferred = defer(); * var request = new XMLHttpRequest(); * request.open("GET", uri, true); * request.responseType = type; * request.onload = function onload() { * deferred.resolve(request.response); * } * request.onerror = function(event) { * deferred.reject(event); * } * request.send(); * * return deferred.promise; * } */ function defer(prototype) { // Define FIFO queue of observer pairs. Once promise is resolved & all queued // observers are forwarded to `result` and variable is set to `null`. var observers = []; // Promise `result`, which will be assigned a resolution value once promise // is resolved. Note that result will always be assigned promise (or alike) // object to take care of propagation through promise chains. If result is // `null` promise is not resolved yet. var result = null; prototype = (prototype || prototype === null) ? prototype : Object.prototype; // Create an object implementing promise API. var promise = Object.create(prototype, { then: { value: function then(onFulfill, onError) { var deferred = defer(prototype); function resolve(value) { // If `onFulfill` handler is provided resolve `deferred.promise` with // result of invoking it with a resolution value. If handler is not // provided propagate value through. try { deferred.resolve(onFulfill ? onFulfill(value) : value); } // `onFulfill` may throw exception in which case resulting promise // is rejected with thrown exception. catch(error) { if (exports._reportErrors && typeof(console) === 'object') console.error(error); // Note: Following is equivalent of `deferred.reject(error)`, // we use this shortcut to reduce a stack. deferred.resolve(rejected(error)); } } function reject(reason) { try { if (onError) deferred.resolve(onError(reason)); else deferred.resolve(rejected(reason)); } catch(error) { if (exports._reportErrors && typeof(console) === 'object') console.error(error); deferred.resolve(rejected(error)); } } // If enclosed promise (`this.promise`) observers queue is still alive // enqueue a new observer pair into it. Note that this does not // necessary means that promise is pending, it may already be resolved, // but we still have to queue observers to guarantee an order of // propagation. if (observers) { observers.push({ resolve: resolve, reject: reject }); } // Otherwise just forward observer pair right to a `result` promise. else { result.then(resolve, reject); } return deferred.promise; }} }) var deferred = { promise: promise, /** * Resolves associated `promise` to a given `value`, unless it's already * resolved or rejected. Note that resolved promise is not necessary a * successfully fulfilled. Promise may be resolved with a promise `value` * in which case `value` promise's fulfillment / rejection will propagate * up to a promise resolved with `value`. */ resolve: function resolve(value) { if (!result) { // Store resolution `value` in a `result` as a promise, so that all // the subsequent handlers can be simply forwarded to it. Since // `result` will be a promise all the value / error propagation will // be uniformly taken care of. result = isPromise(value) ? value : fulfilled(value); // Forward already registered observers to a `result` promise in the // order they were registered. Note that we intentionally dequeue // observer at a time until queue is exhausted. This makes sure that // handlers registered as side effect of observer forwarding are // queued instead of being invoked immediately, guaranteeing FIFO // order. while (observers.length) { var observer = observers.shift(); result.then(observer.resolve, observer.reject); } // Once `observers` queue is exhausted we `null`-ify it, so that // new handlers are forwarded straight to the `result`. observers = null; } }, /** * Rejects associated `promise` with a given `reason`, unless it's already * resolved / rejected. This is just a (better performing) convenience * shortcut for `deferred.resolve(reject(reason))`. */ reject: function reject(reason) { // Note that if promise is resolved that does not necessary means that it // is successfully fulfilled. Resolution value may be a promise in which // case its result propagates. In other words if promise `a` is resolved // with promise `b`, `a` is either fulfilled or rejected depending // on weather `b` is fulfilled or rejected. Here `deferred.promise` is // resolved with a promise pre-rejected with a given `reason`, there for // `deferred.promise` is rejected with a given `reason`. This may feel // little awkward first, but doing it this way greatly simplifies // propagation through promise chains. deferred.resolve(rejected(reason)); } }; return deferred; } exports.defer = defer; /** * Returns a promise resolved to a given `value`. Optionally a second * `prototype` argument may be provided to be used as a prototype for the * returned promise. */ function resolve(value, prototype) { var deferred = defer(prototype); deferred.resolve(value); return deferred.promise; } exports.resolve = resolve; /** * Returns a promise rejected with a given `reason`. Optionally a second * `prototype` argument may be provided to be used as a prototype for the * returned promise. */ function reject(reason, prototype) { var deferred = defer(prototype); deferred.reject(reason); return deferred.promise; } exports.reject = reject; var promised = (function() { // Note: Define shortcuts and utility functions here in order to avoid // slower property accesses and unnecessary closure creations on each // call of this popular function. var call = Function.call; var concat = Array.prototype.concat; // Utility function that does following: // execute([ f, self, args...]) => f.apply(self, args) function execute(args) { return call.apply(call, args) } // Utility function that takes promise of `a` array and maybe promise `b` // as arguments and returns promise for `a.concat(b)`. function promisedConcat(promises, unknown) { return promises.then(function(values) { return resolve(unknown).then(function(value) { return values.concat([ value ]); }); }); } return function promised(f, prototype) { /** Returns a wrapped `f`, which when called returns a promise that resolves to `f(...)` passing all the given arguments to it, which by the way may be promises. Optionally second `prototype` argument may be provided to be used a prototype for a returned promise. ## Example var promise = promised(Array)(1, promise(2), promise(3)) promise.then(console.log) // => [ 1, 2, 3 ] **/ return function promised() { // create array of [ f, this, args... ] return concat.apply([ f, this ], arguments). // reduce it via `promisedConcat` to get promised array of fulfillments reduce(promisedConcat, resolve([], prototype)). // finally map that to promise of `f.apply(this, args...)` then(execute); }; } })(); exports.promised = promised; // var all = promised(Array); exports.all = all; // //}); ================================================ FILE: cocos2d/cocos/scripting/javascript/script/debugger/main.js ================================================ /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* 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/. */ "use strict"; /** * Toolkit glue for the remote debugging protocol, loaded into the * debugging global. */ /* const Ci = Components.interfaces; const Cc = Components.classes; const CC = Components.Constructor; const Cu = Components.utils; const Cr = Components.results; const DBG_STRINGS_URI = "chrome://global/locale/devtools/debugger.properties"; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); let wantLogging = Services.prefs.getBoolPref("devtools.debugger.log"); Cu.import("resource://gre/modules/jsdebugger.jsm"); addDebuggerToGlobal(this); loadSubScript.call(this, "resource://gre/modules/commonjs/sdk/core/promise.js"); Cu.import("resource://gre/modules/devtools/SourceMap.jsm"); loadSubScript.call(this, "resource://gre/modules/devtools/DevToolsUtils.js"); */ let wantLogging = true; let debuggerServer = null; function dumpn(str) { if (wantLogging) { log("DBG-SERVER: " + str + "\n"); } } function dbg_assert(cond, e) { if (!cond) { log("assert >>>> " + cond.toString()); return e; } } function XPCInspector() { this.exitNestedEventLoop = _exitNestedEventLoop; this.enterNestedEventLoop = _enterNestedEventLoop; this.eventLoopNestLevel = _getEventLoopNestLevel; } //loadSubScript.call(this, "resource://gre/modules/devtools/server/transport.js"); // XPCOM constructors // const ServerSocket = CC("@mozilla.org/network/server-socket;1", // "nsIServerSocket", // "initSpecialConnection"); function ServerSocket(aPort, flags, c){ this.asyncListen = function(server){ log("asyncListen...."); debuggerServer = server; }; }; var gRegisteredModules = Object.create(null); /** * The ModuleAPI object is passed to modules loaded using the * DebuggerServer.registerModule() API. Modules can use this * object to register actor factories. * Factories registered through the module API will be removed * when the module is unregistered or when the server is * destroyed. */ function ModuleAPI() { let activeTabActors = new Set(); let activeGlobalActors = new Set(); return { // See DebuggerServer.addGlobalActor for a description. addGlobalActor: function(factory, name) { DebuggerServer.addGlobalActor(factory, name); activeGlobalActors.add(factory); }, // See DebuggerServer.removeGlobalActor for a description. removeGlobalActor: function(factory) { DebuggerServer.removeGlobalActor(factory); activeGlobalActors.delete(factory); }, // See DebuggerServer.addTabActor for a description. addTabActor: function(factory, name) { DebuggerServer.addTabActor(factory, name); activeTabActors.add(factory); }, // See DebuggerServer.removeTabActor for a description. removeTabActor: function(factory) { DebuggerServer.removeTabActor(factory); activeTabActors.delete(factory); }, // Destroy the module API object, unregistering any // factories registered by the module. destroy: function() { for (let factory of activeTabActors) { DebuggerServer.removeTabActor(factory); } activeTabActors = null; for (let factory of activeGlobalActors) { DebuggerServer.removeGlobalActor(factory); } activeGlobalActors = null; } } }; /*** * Public API */ var DebuggerServer = { _listener: null, _initialized: false, _transportInitialized: false, xpcInspector: null, _transport: null, // James added // Number of currently open TCP connections. _socketConnections: 0, // Map of global actor names to actor constructors provided by extensions. globalActorFactories: {}, // Map of tab actor names to actor constructors provided by extensions. tabActorFactories: {}, LONG_STRING_LENGTH: 10000, LONG_STRING_INITIAL_LENGTH: 1000, LONG_STRING_READ_LENGTH: 1000, /** * A handler function that prompts the user to accept or decline the incoming * connection. */ _allowConnection: null, /** * The windowtype of the chrome window to use for actors that use the global * window (i.e the global style editor). Set this to your main window type, * for example "navigator:browser". */ chromeWindowType: null, /** * Prompt the user to accept or decline the incoming connection. This is the * default implementation that products embedding the debugger server may * choose to override. * * @return true if the connection should be permitted, false otherwise */ _defaultAllowConnection: function DS__defaultAllowConnection() { // let title = L10N.getStr("remoteIncomingPromptTitle"); // let msg = L10N.getStr("remoteIncomingPromptMessage"); // let disableButton = L10N.getStr("remoteIncomingPromptDisable"); // let prompt = Services.prompt; // let flags = prompt.BUTTON_POS_0 * prompt.BUTTON_TITLE_OK + // prompt.BUTTON_POS_1 * prompt.BUTTON_TITLE_CANCEL + // prompt.BUTTON_POS_2 * prompt.BUTTON_TITLE_IS_STRING + // prompt.BUTTON_POS_1_DEFAULT; // let result = prompt.confirmEx(null, title, msg, flags, null, null, // disableButton, null, { value: false }); // if (result == 0) { // return true; // } // if (result == 2) { // DebuggerServer.closeListener(true); // Services.prefs.setBoolPref("devtools.debugger.remote-enabled", false); // } // return false; return true; }, /** * Initialize the debugger server. * * @param function aAllowConnectionCallback * The embedder-provider callback, that decides whether an incoming * remote protocol conection should be allowed or refused. */ init: function DS_init(aAllowConnectionCallback) { if (this.initialized) { return; } this.xpcInspector = new XPCInspector();//Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector); this.initTransport(aAllowConnectionCallback); this.addActors("resource://gre/modules/devtools/server/actors/root.js"); this._initialized = true; }, /** * Initialize the debugger server's transport variables. This can be * in place of init() for cases where the jsdebugger isn't needed. * * @param function aAllowConnectionCallback * The embedder-provider callback, that decides whether an incoming * remote protocol conection should be allowed or refused. */ initTransport: function DS_initTransport(aAllowConnectionCallback) { if (this._transportInitialized) { return; } this._connections = {}; this._nextConnID = 0; this._transportInitialized = true; this._allowConnection = aAllowConnectionCallback ? aAllowConnectionCallback : this._defaultAllowConnection; }, get initialized() this._initialized, /** * Performs cleanup tasks before shutting down the debugger server. Such tasks * include clearing any actor constructors added at runtime. This method * should be called whenever a debugger server is no longer useful, to avoid * memory leaks. After this method returns, the debugger server must be * initialized again before use. */ destroy: function DS_destroy() { if (!this._initialized) { return; } for (let connID of Object.getOwnPropertyNames(this._connections)) { this._connections[connID].close(); } for (let id of Object.getOwnPropertyNames(gRegisteredModules)) { let mod = gRegisteredModules[id]; mod.module.unregister(mod.api); } gRegisteredModules = {}; this.closeListener(); this.globalActorFactories = {}; this.tabActorFactories = {}; delete this._allowConnection; this._transportInitialized = false; this._initialized = false; dumpn("Debugger server is shut down."); }, /** * Load a subscript into the debugging global. * * @param aURL string A url that will be loaded as a subscript into the * debugging global. The user must load at least one script * that implements a createRootActor() function to create the * server's root actor. */ addActors: function DS_addActors(aURL) { //loadSubScript.call(this, aURL); }, /** * Register a CommonJS module with the debugger server. * @param id string * The ID of a CommonJS module. This module must export * 'register' and 'unregister' functions. */ registerModule: function(id) { if (id in gRegisteredModules) { throw new Error("Tried to register a module twice: " + id + "\n"); } let moduleAPI = ModuleAPI(); let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let mod = devtools.require(id); mod.register(moduleAPI); gRegisteredModules[id] = { module: mod, api: moduleAPI }; }, /** * Returns true if a module id has been registered. */ isModuleRegistered: function(id) { return (id in gRegisteredModules); }, /** * Unregister a previously-loaded CommonJS module from the debugger server. */ unregisterModule: function(id) { let mod = gRegisteredModules[id]; if (!mod) { throw new Error("Tried to unregister a module that was not previously registered."); } mod.module.unregister(mod.api); mod.api.destroy(); delete gRegisteredModules[id]; }, /** * Install Firefox-specific actors. */ addBrowserActors: function DS_addBrowserActors() { this.chromeWindowType = "navigator:browser"; this.addActors("resource://gre/modules/devtools/server/actors/webbrowser.js"); this.addActors("resource://gre/modules/devtools/server/actors/script.js"); this.addGlobalActor(this.ChromeDebuggerActor, "chromeDebugger"); this.addActors("resource://gre/modules/devtools/server/actors/webconsole.js"); this.addActors("resource://gre/modules/devtools/server/actors/gcli.js"); if ("nsIProfiler" in Ci) this.addActors("resource://gre/modules/devtools/server/actors/profiler.js"); this.addActors("resource://gre/modules/devtools/server/actors/styleeditor.js"); this.addActors("resource://gre/modules/devtools/server/actors/webapps.js"); this.registerModule("devtools/server/actors/inspector"); this.registerModule("devtools/server/actors/tracer"); }, /** * Install tab actors in documents loaded in content childs */ addChildActors: function () { // In case of apps being loaded in parent process, DebuggerServer is already // initialized and browser actors are already loaded, // but childtab.js hasn't been loaded yet. if (!("BrowserTabActor" in this)) { this.addActors("resource://gre/modules/devtools/server/actors/webbrowser.js"); this.addActors("resource://gre/modules/devtools/server/actors/script.js"); this.addActors("resource://gre/modules/devtools/server/actors/webconsole.js"); this.addActors("resource://gre/modules/devtools/server/actors/gcli.js"); this.addActors("resource://gre/modules/devtools/server/actors/styleeditor.js"); this.registerModule("devtools/server/actors/inspector"); } if (!("ContentTabActor" in DebuggerServer)) { this.addActors("resource://gre/modules/devtools/server/actors/childtab.js"); } }, /** * Listens on the given port for remote debugger connections. * * @param aPort int * The port to listen on. */ openListener: function DS_openListener(aPort) { // if (!Services.prefs.getBoolPref("devtools.debugger.remote-enabled")) { // return false; // } this._checkInit(); // Return early if the server is already listening. if (this._listener) { return true; } // let flags = Ci.nsIServerSocket.KeepWhenOffline; // A preference setting can force binding on the loopback interface. // if (Services.prefs.getBoolPref("devtools.debugger.force-local")) { // flags |= Ci.nsIServerSocket.LoopbackOnly; // } let flags = 0; try { let socket = new ServerSocket(aPort, flags, 4); socket.asyncListen(this); this._listener = socket; } catch (e) { dumpn("Could not start debugging listener on port " + aPort + ": " + e); throw "Cr.NS_ERROR_NOT_AVAILABLE"; } this._socketConnections++; return true; }, /** * Close a previously-opened TCP listener. * * @param aForce boolean [optional] * If set to true, then the socket will be closed, regardless of the * number of open connections. */ closeListener: function DS_closeListener(aForce) { if (!this._listener || this._socketConnections == 0) { return false; } // Only close the listener when the last connection is closed, or if the // aForce flag is passed. if (--this._socketConnections == 0 || aForce) { this._listener.close(); this._listener = null; this._socketConnections = 0; } return true; }, /** * Creates a new connection to the local debugger speaking over a fake * transport. This connection results in straightforward calls to the onPacket * handlers of each side. * * @param aPrefix string [optional] * If given, all actors in this connection will have names starting * with |aPrefix + ':'|. * @returns a client-side DebuggerTransport for communicating with * the newly-created connection. */ connectPipe: function DS_connectPipe(aPrefix) { this._checkInit(); let serverTransport = new LocalDebuggerTransport; let clientTransport = new LocalDebuggerTransport(serverTransport); serverTransport.other = clientTransport; let connection = this._onConnection(serverTransport, aPrefix); // I'm putting this here because I trust you. // // There are times, when using a local connection, when you're going // to be tempted to just get direct access to the server. Resist that // temptation! If you succumb to that temptation, you will make the // fine developers that work on Fennec and Firefox OS sad. They're // professionals, they'll try to act like they understand, but deep // down you'll know that you hurt them. // // This reference allows you to give in to that temptation. There are // times this makes sense: tests, for example, and while porting a // previously local-only codebase to the remote protocol. // // But every time you use this, you will feel the shame of having // used a property that starts with a '_'. clientTransport._serverConnection = connection; return clientTransport; }, /** * In a content child process, create a new connection that exchanges * nsIMessageSender messages with our parent process. * * @param aPrefix * The prefix we should use in our nsIMessageSender message names and * actor names. This connection will use messages named * "debug::packet", and all its actors will have names * beginning with ":". */ connectToParent: function(aPrefix, aMessageManager) { this._checkInit(); let transport = new ChildDebuggerTransport(aMessageManager, aPrefix); return this._onConnection(transport, aPrefix, true); }, // nsIServerSocketListener implementation onSocketAccepted: makeInfallible(function DS_onSocketAccepted(aSocket, aTransport) { if (!this._allowConnection()) { return; } dumpn("New debugging connection on " + aTransport.host + ":" + aTransport.port); let input = aTransport.openInputStream(0, 0, 0); let output = aTransport.openOutputStream(0, 0, 0); let transport = new DebuggerTransport(input, output); DebuggerServer._onConnection(transport); }, "DebuggerServer.onSocketAccepted"), onStopListening: function DS_onStopListening(aSocket, status) { dumpn("onStopListening, status: " + status); }, /** * Raises an exception if the server has not been properly initialized. */ _checkInit: function DS_checkInit() { if (!this._transportInitialized) { throw "DebuggerServer has not been initialized."; } if (!this.createRootActor) { throw "Use DebuggerServer.addActors() to add a root actor implementation."; } }, /** * Create a new debugger connection for the given transport. Called after * connectPipe(), from connectToParent, or from an incoming socket * connection handler. * * If present, |aForwardingPrefix| is a forwarding prefix that a parent * server is using to recognizes messages intended for this server. Ensure * that all our actors have names beginning with |aForwardingPrefix + ':'|. * In particular, the root actor's name will be |aForwardingPrefix + ':root'|. */ _onConnection: function DS_onConnection(aTransport, aForwardingPrefix, aNoRootActor = false) { let connID; this._transport = aTransport; if (aForwardingPrefix) { connID = aForwardingPrefix + ":"; } else { connID = "conn" + this._nextConnID++ + '.'; } let conn = new DebuggerServerConnection(connID, aTransport); this._connections[connID] = conn; // Create a root actor for the connection and send the hello packet. if (!aNoRootActor) { conn.rootActor = this.createRootActor(conn); if (aForwardingPrefix) conn.rootActor.actorID = aForwardingPrefix + ":root"; else conn.rootActor.actorID = "root"; conn.addActor(conn.rootActor); aTransport.send(conn.rootActor.sayHello()); } aTransport.ready(); return conn; }, /** * Remove the connection from the debugging server. */ _connectionClosed: function DS_connectionClosed(aConnection) { delete this._connections[aConnection.prefix]; }, // DebuggerServer extension API. /** * Registers handlers for new tab-scoped request types defined dynamically. * This is used for example by add-ons to augment the functionality of the tab * actor. Note that the name or actorPrefix of the request type is not allowed * to clash with existing protocol packet properties, like 'title', 'url' or * 'actor', since that would break the protocol. * * @param aFunction function * The constructor function for this request type. This expects to be * called as a constructor (i.e. with 'new'), and passed two * arguments: the DebuggerServerConnection, and the BrowserTabActor * with which it will be associated. * * @param aName string [optional] * The name of the new request type. If this is not present, the * actorPrefix property of the constructor prototype is used. */ addTabActor: function DS_addTabActor(aFunction, aName) { let name = aName ? aName : aFunction.prototype.actorPrefix; if (["title", "url", "actor"].indexOf(name) != -1) { throw Error(name + " is not allowed"); } if (DebuggerServer.tabActorFactories.hasOwnProperty(name)) { throw Error(name + " already exists"); } DebuggerServer.tabActorFactories[name] = aFunction; }, /** * Unregisters the handler for the specified tab-scoped request type. * This may be used for example by add-ons when shutting down or upgrading. * * @param aFunction function * The constructor function for this request type. */ removeTabActor: function DS_removeTabActor(aFunction) { for (let name in DebuggerServer.tabActorFactories) { let handler = DebuggerServer.tabActorFactories[name]; if (handler.name == aFunction.name) { delete DebuggerServer.tabActorFactories[name]; } } }, /** * Registers handlers for new browser-scoped request types defined * dynamically. This is used for example by add-ons to augment the * functionality of the root actor. Note that the name or actorPrefix of the * request type is not allowed to clash with existing protocol packet * properties, like 'from', 'tabs' or 'selected', since that would break the * protocol. * * @param aFunction function * The constructor function for this request type. This expects to be * called as a constructor (i.e. with 'new'), and passed two * arguments: the DebuggerServerConnection, and the BrowserRootActor * with which it will be associated. * * @param aName string [optional] * The name of the new request type. If this is not present, the * actorPrefix property of the constructor prototype is used. */ addGlobalActor: function DS_addGlobalActor(aFunction, aName) { let name = aName ? aName : aFunction.prototype.actorPrefix; if (["from", "tabs", "selected"].indexOf(name) != -1) { throw Error(name + " is not allowed"); } if (DebuggerServer.globalActorFactories.hasOwnProperty(name)) { throw Error(name + " already exists"); } DebuggerServer.globalActorFactories[name] = aFunction; }, /** * Unregisters the handler for the specified browser-scoped request type. * This may be used for example by add-ons when shutting down or upgrading. * * @param aFunction function * The constructor function for this request type. */ removeGlobalActor: function DS_removeGlobalActor(aFunction) { for (let name in DebuggerServer.globalActorFactories) { let handler = DebuggerServer.globalActorFactories[name]; if (handler.name == aFunction.name) { delete DebuggerServer.globalActorFactories[name]; } } } }; /** * Construct an ActorPool. * * ActorPools are actorID -> actor mapping and storage. These are * used to accumulate and quickly dispose of groups of actors that * share a lifetime. */ function ActorPool(aConnection) { this.conn = aConnection; this._cleanups = {}; this._actors = {}; } ActorPool.prototype = { /** * Add an actor to the actor pool. If the actor doesn't have an ID, * allocate one from the connection. * * @param aActor object * The actor implementation. If the object has a * 'disconnect' property, it will be called when the actor * pool is cleaned up. */ addActor: function AP_addActor(aActor) { aActor.conn = this.conn; if (!aActor.actorID) { let prefix = aActor.actorPrefix; if (typeof aActor == "function") { prefix = aActor.prototype.actorPrefix; } aActor.actorID = this.conn.allocID(prefix || undefined); } if (aActor.registeredPool) { aActor.registeredPool.removeActor(aActor); } aActor.registeredPool = this; this._actors[aActor.actorID] = aActor; if (aActor.disconnect) { this._cleanups[aActor.actorID] = aActor; } }, get: function AP_get(aActorID) { return this._actors[aActorID]; }, has: function AP_has(aActorID) { return aActorID in this._actors; }, /** * Returns true if the pool is empty. */ isEmpty: function AP_isEmpty() { return Object.keys(this._actors).length == 0; }, /** * Remove an actor from the actor pool. */ removeActor: function AP_remove(aActor) { delete this._actors[aActor.actorID]; delete this._cleanups[aActor.actorID]; }, /** * Match the api expected by the protocol library. */ unmanage: function(aActor) { return this.removeActor(aActor); }, /** * Run all actor cleanups. */ cleanup: function AP_cleanup() { for each (let actor in this._cleanups) { actor.disconnect(); } this._cleanups = {}; } } /** * Creates a DebuggerServerConnection. * * Represents a connection to this debugging global from a client. * Manages a set of actors and actor pools, allocates actor ids, and * handles incoming requests. * * @param aPrefix string * All actor IDs created by this connection should be prefixed * with aPrefix. * @param aTransport transport * Packet transport for the debugging protocol. */ function DebuggerServerConnection(aPrefix, aTransport) { this._prefix = aPrefix; this._transport = aTransport; this._transport.hooks = this; this._nextID = 1; this._actorPool = new ActorPool(this); this._extraPools = []; /* * We can forward packets to other servers, if the actors on that server * all use a distinct prefix on their names. This is a map from prefixes * to transports: it maps a prefix P to a transport T if T conveys * packets to the server whose actors' names all begin with P + ":". */ this._forwardingPrefixes = new Map; } DebuggerServerConnection.prototype = { _prefix: null, get prefix() { return this._prefix }, _transport: null, get transport() { return this._transport }, close: function() { this._transport.close(); }, send: function DSC_send(aPacket) { this.transport.send(aPacket); }, allocID: function DSC_allocID(aPrefix) { return this.prefix + (aPrefix || '') + this._nextID++; }, /** * Add a map of actor IDs to the connection. */ addActorPool: function DSC_addActorPool(aActorPool) { this._extraPools.push(aActorPool); }, /** * Remove a previously-added pool of actors to the connection. * * @param ActorPool aActorPool * The ActorPool instance you want to remove. * @param boolean aCleanup * True if you want to disconnect each actor from the pool, false * otherwise. */ removeActorPool: function DSC_removeActorPool(aActorPool, aCleanup) { let index = this._extraPools.lastIndexOf(aActorPool); if (index > -1) { let pool = this._extraPools.splice(index, 1); if (aCleanup) { pool.map(function(p) { p.cleanup(); }); } } }, /** * Add an actor to the default actor pool for this connection. */ addActor: function DSC_addActor(aActor) { this._actorPool.addActor(aActor); }, /** * Remove an actor to the default actor pool for this connection. */ removeActor: function DSC_removeActor(aActor) { this._actorPool.removeActor(aActor); }, /** * Match the api expected by the protocol library. */ unmanage: function(aActor) { return this.removeActor(aActor); }, /** * Look up an actor implementation for an actorID. Will search * all the actor pools registered with the connection. * * @param aActorID string * Actor ID to look up. */ getActor: function DSC_getActor(aActorID) { let pool = this.poolFor(aActorID); if (pool) { return pool.get(aActorID); } if (aActorID === "root") { return this.rootActor; } return null; }, poolFor: function DSC_actorPool(aActorID) { if (this._actorPool && this._actorPool.has(aActorID)) { return this._actorPool; } for (let pool of this._extraPools) { if (pool.has(aActorID)) { return pool; } } return null; }, _unknownError: function DSC__unknownError(aPrefix, aError) { let errorString = safeErrorString(aError); errorString += "\n" + aError.stack; // Cu.reportError(errorString); dumpn(errorString); return { error: "unknownError", message: (aPrefix + "': " + errorString) }; }, /* Forwarding packets to other transports based on actor name prefixes. */ /* * Arrange to forward packets to another server. This is how we * forward debugging connections to child processes. * * If we receive a packet for an actor whose name begins with |aPrefix| * followed by ':', then we will forward that packet to |aTransport|. * * This overrides any prior forwarding for |aPrefix|. * * @param aPrefix string * The actor name prefix, not including the ':'. * @param aTransport object * A packet transport to which we should forward packets to actors * whose names begin with |(aPrefix + ':').| */ setForwarding: function(aPrefix, aTransport) { this._forwardingPrefixes.set(aPrefix, aTransport); }, /* * Stop forwarding messages to actors whose names begin with * |aPrefix+':'|. Such messages will now elicit 'noSuchActor' errors. */ cancelForwarding: function(aPrefix) { this._forwardingPrefixes.delete(aPrefix); }, // Transport hooks. /** * Called by DebuggerTransport to dispatch incoming packets as appropriate. * * @param aPacket object * The incoming packet. */ onPacket: function DSC_onPacket(aPacket) { // If the actor's name begins with a prefix we've been asked to // forward, do so. // // Note that the presence of a prefix alone doesn't indicate that // forwarding is needed: in DebuggerServerConnection instances in child // processes, every actor has a prefixed name. if (this._forwardingPrefixes.size > 0) { let colon = aPacket.to.indexOf(':'); if (colon >= 0) { let forwardTo = this._forwardingPrefixes.get(aPacket.to.substring(0, colon)); if (forwardTo) { forwardTo.send(aPacket); return; } } } let actor = this.getActor(aPacket.to); if (!actor) { this.transport.send({ from: aPacket.to ? aPacket.to : "root", error: "noSuchActor" }); return; } // Dyamically-loaded actors have to be created lazily. if (typeof actor == "function") { let instance; try { instance = new actor(); } catch (e) { this.transport.send(this._unknownError( "Error occurred while creating actor '" + actor.name, e)); } instance.parentID = actor.parentID; // We want the newly-constructed actor to completely replace the factory // actor. Reusing the existing actor ID will make sure ActorPool.addActor // does the right thing. instance.actorID = actor.actorID; actor.registeredPool.addActor(instance); actor = instance; } var ret = null; // Dispatch the request to the actor. if (actor.requestTypes && actor.requestTypes[aPacket.type]) { try { this.currentPacket = aPacket; ret = actor.requestTypes[aPacket.type].bind(actor)(aPacket, this); } catch(e) { this.transport.send(this._unknownError( "error occurred while processing '" + aPacket.type, e)); } finally { delete this.currentPacket; } } else { ret = { error: "unrecognizedPacketType", message: ('Actor "' + actor.actorID + '" does not recognize the packet type "' + aPacket.type + '"') }; } if (!ret) { // This should become an error once we've converted every user // of this to promises in bug 794078. return; } resolve(ret) .then(function (aResponse) { if (!aResponse.from) { aResponse.from = aPacket.to; } return aResponse; }) .then(this.transport.send.bind(this.transport)) .then(null, (e) => { return this._unknownError( "error occurred while processing '" + aPacket.type, e); }); }, /** * Called by DebuggerTransport when the underlying stream is closed. * * @param aStatus nsresult * The status code that corresponds to the reason for closing * the stream. */ onClosed: function DSC_onClosed(aStatus) { dumpn("Cleaning up connection."); this._actorPool.cleanup(); this._actorPool = null; this._extraPools.map(function(p) { p.cleanup(); }); this._extraPools = null; DebuggerServer._connectionClosed(this); }, /* * Debugging helper for inspecting the state of the actor pools. */ _dumpPools: function DSC_dumpPools() { dumpn("/-------------------- dumping pools:"); if (this._actorPool) { dumpn("--------------------- actorPool actors: " + uneval(Object.keys(this._actorPool._actors))); } for each (let pool in this._extraPools) dumpn("--------------------- extraPool actors: " + uneval(Object.keys(pool._actors))); }, /* * Debugging helper for inspecting the state of an actor pool. */ _dumpPool: function DSC_dumpPools(aPool) { dumpn("/-------------------- dumping pool:"); dumpn("--------------------- actorPool actors: " + uneval(Object.keys(aPool._actors))); } }; /** * Localization convenience methods. */ // let L10N = { // /** // * L10N shortcut function. // * // * @param string aName // * @return string // */ // getStr: function L10N_getStr(aName) { // return this.stringBundle.GetStringFromName(aName); // } // }; // XPCOMUtils.defineLazyGetter(L10N, "stringBundle", function() { // return Services.strings.createBundle(DBG_STRINGS_URI); // }); ================================================ FILE: cocos2d/cocos/scripting/javascript/script/debugger/transport.js ================================================ /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ /* 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/. */ "use strict"; // Components.utils.import("resource://gre/modules/NetUtil.jsm"); /** * An adapter that handles data transfers between the debugger client and * server. It can work with both nsIPipe and nsIServerSocket transports so * long as the properly created input and output streams are specified. * (However, for intra-process connections, LocalDebuggerTransport, below, * is more efficient than using an nsIPipe pair with DebuggerTransport.) * * @param aInput nsIInputStream * The input stream. * @param aOutput nsIAsyncOutputStream * The output stream. * * Given a DebuggerTransport instance dt: * 1) Set dt.hooks to a packet handler object (described below). * 2) Call dt.ready() to begin watching for input packets. * 3) Call dt.send() to send packets as you please, and handle incoming * packets passed to hook.onPacket. * 4) Call dt.close() to close the connection, and disengage from the event * loop. * * A packet handler is an object with two methods: * * - onPacket(packet) - called when we have received a complete packet. * |Packet| is the parsed form of the packet --- a JavaScript value, not * a JSON-syntax string. * * - onClosed(status) - called when the connection is closed. |Status| is * an nsresult, of the sort passed to nsIRequestObserver. * * Data is transferred as a JSON packet serialized into a string, with the * string length prepended to the packet, followed by a colon * ([length]:[packet]). The contents of the JSON packet are specified in * the Remote Debugging Protocol specification. */ this.DebuggerTransport = function DebuggerTransport(aInput, aOutput) { this._input = aInput; this._output = aOutput; this._converter = null;//Cc["@mozilla.org/intl/scriptableunicodeconverter"] // .createInstance(Ci.nsIScriptableUnicodeConverter); // this._converter.charset = "UTF-8"; this._outgoing = ""; this._incoming = ""; this.hooks = null; } DebuggerTransport.prototype = { /** * Transmit a packet. * * This method returns immediately, without waiting for the entire * packet to be transmitted, registering event handlers as needed to * transmit the entire packet. Packets are transmitted in the order * they are passed to this method. */ send: function DT_send(aPacket) { // TODO (bug 709088): remove pretty printing when the protocol is done. let data = JSON.stringify(aPacket, null, 2); // data = this._converter.ConvertFromUnicode(data); let data_for_len = utf16to8(data); this._outgoing = data_for_len.length + ':' + data; this._flushOutgoing(); }, /** * Close the transport. */ close: function DT_close() { this._input.close(); this._output.close(); }, /** * Flush the outgoing stream. */ _flushOutgoing: function DT_flushOutgoing() { if (this._outgoing.length > 0) { // var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(); // this._output.asyncWait(this, 0, 0, threadManager.currentThread); log("outgoing: " + this._outgoing);//.substring(0, 200)); _bufferWrite(this._outgoing); } }, onOutputStreamReady: makeInfallible(function DT_onOutputStreamReady(aStream) { let written = 0; try { written = aStream.write(this._outgoing, this._outgoing.length); } catch(e if e.result == Components.results.NS_BASE_STREAM_CLOSED) { dumpn("Connection closed."); this.close(); return; } this._outgoing = this._outgoing.slice(written); this._flushOutgoing(); }, "DebuggerTransport.prototype.onOutputStreamReady"), /** * Initialize the input stream for reading. Once this method has been * called, we watch for packets on the input stream, and pass them to * this.hook.onPacket. */ ready: function DT_ready() { // let pump = Cc["@mozilla.org/network/input-stream-pump;1"] // .createInstance(Ci.nsIInputStreamPump); // pump.init(this._input, -1, -1, 0, 0, false); // pump.asyncRead(this, null); }, // nsIStreamListener onStartRequest: makeInfallible(function DT_onStartRequest(aRequest, aContext) {}, "DebuggerTransport.prototype.onStartRequest"), onStopRequest: makeInfallible(function DT_onStopRequest(aRequest, aContext, aStatus) { this.close(); if (this.hooks) { this.hooks.onClosed(aStatus); this.hooks = null; } }, "DebuggerTransport.prototype.onStopRequest"), onDataAvailable: makeInfallible(function DT_onDataAvailable (incoming) // makeInfallible(function DT_onDataAvailable(aRequest, aContext, // aStream, aOffset, aCount) { this._incoming = incoming;//+= NetUtil.readInputStreamToString(aStream, // aStream.available()); while (this._processIncoming()) {}; }, "DebuggerTransport.prototype.onDataAvailable"), /** * Process incoming packets. Returns true if a packet has been received, either * if it was properly parsed or not. Returns false if the incoming stream does * not contain a full packet yet. After a proper packet is parsed, the dispatch * handler DebuggerTransport.hooks.onPacket is called with the packet as a * parameter. */ _processIncoming: function DT__processIncoming() { // Well this is ugly. let sep = this._incoming.indexOf(':'); if (sep < 0) { return false; } let count = parseInt(this._incoming.substring(0, sep)); if (this._incoming.length - (sep + 1) < count) { // Don't have a complete request yet. return false; } // We have a complete request, pluck it out of the data and parse it. this._incoming = this._incoming.substring(sep + 1); let packet = this._incoming.substring(0, count); this._incoming = this._incoming.substring(count); try { // packet = this._converter.ConvertToUnicode(packet); packet = utf8to16(packet); var parsed = JSON.parse(packet); } catch(e) { let msg = "Error parsing incoming packet: " + packet + " (" + e + " - " + e.stack + ")"; // if (Cu.reportError) { // Cu.reportError(msg); // } dump(msg + "\n"); return true; } dumpn("Got: " + packet); let self = this; // Services.tm.currentThread.dispatch(makeInfallible(function() { self.hooks.onPacket(parsed); // }, "DebuggerTransport instance's this.hooks.onPacket"), 0); return true; } } /** * An adapter that handles data transfers between the debugger client and * server when they both run in the same process. It presents the same API as * DebuggerTransport, but instead of transmitting serialized messages across a * connection it merely calls the packet dispatcher of the other side. * * @param aOther LocalDebuggerTransport * The other endpoint for this debugger connection. * * @see DebuggerTransport */ this.LocalDebuggerTransport = function LocalDebuggerTransport(aOther) { this.other = aOther; this.hooks = null; /* * A packet number, shared between this and this.other. This isn't used * by the protocol at all, but it makes the packet traces a lot easier to * follow. */ this._serial = this.other ? this.other._serial : { count: 0 }; } LocalDebuggerTransport.prototype = { /** * Transmit a message by directly calling the onPacket handler of the other * endpoint. */ send: function LDT_send(aPacket) { let serial = this._serial.count++; if (wantLogging) { /* Check 'from' first, as 'echo' packets have both. */ if (aPacket.from) { dumpn("Packet " + serial + " sent from " + uneval(aPacket.from)); } else if (aPacket.to) { dumpn("Packet " + serial + " sent to " + uneval(aPacket.to)); } } this._deepFreeze(aPacket); let other = this.other; if (other) { Services.tm.currentThread.dispatch(makeInfallible(function() { // Avoid the cost of JSON.stringify() when logging is disabled. if (wantLogging) { dumpn("Received packet " + serial + ": " + JSON.stringify(aPacket, null, 2)); } if (other.hooks) { other.hooks.onPacket(aPacket); } }, "LocalDebuggerTransport instance's this.other.hooks.onPacket"), 0); } }, /** * Close the transport. */ close: function LDT_close() { if (this.other) { // Remove the reference to the other endpoint before calling close(), to // avoid infinite recursion. let other = this.other; delete this.other; other.close(); } if (this.hooks) { try { this.hooks.onClosed(); } catch(ex) { Components.utils.reportError(ex); } this.hooks = null; } }, /** * An empty method for emulating the DebuggerTransport API. */ ready: function LDT_ready() {}, /** * Helper function that makes an object fully immutable. */ _deepFreeze: function LDT_deepFreeze(aObject) { Object.freeze(aObject); for (let prop in aObject) { // Freeze the properties that are objects, not on the prototype, and not // already frozen. Note that this might leave an unfrozen reference // somewhere in the object if there is an already frozen object containing // an unfrozen object. if (aObject.hasOwnProperty(prop) && typeof aObject === "object" && !Object.isFrozen(aObject)) { this._deepFreeze(o[prop]); } } } }; /** * A transport for the debugging protocol that uses nsIMessageSenders to * exchange packets with servers running in child processes. * * In the parent process, |aSender| should be the nsIMessageSender for the * child process. In a child process, |aSender| should be the child process * message manager, which sends packets to the parent. * * aPrefix is a string included in the message names, to distinguish * multiple servers running in the same child process. * * This transport exchanges messages named 'debug::packet', where * is |aPrefix|, whose data is the protocol packet. */ function ChildDebuggerTransport(aSender, aPrefix) { this._sender = aSender.QueryInterface(Components.interfaces.nsIMessageSender); this._messageName = "debug:" + aPrefix + ":packet"; } /* * To avoid confusion, we use 'message' to mean something that * nsIMessageSender conveys, and 'packet' to mean a remote debugging * protocol packet. */ ChildDebuggerTransport.prototype = { constructor: ChildDebuggerTransport, hooks: null, ready: function () { this._sender.addMessageListener(this._messageName, this); }, close: function () { this._sender.removeMessageListener(this._messageName, this); this.hooks.onClosed(); }, receiveMessage: function ({data}) { this.hooks.onPacket(data); }, send: function (packet) { this._sender.sendAsyncMessage(this._messageName, packet); } }; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb.js ================================================ // // Javascript Bindigns helper file // // DO NOT ALTER THE ORDER require('jsb_cocos2d_constants.js'); require('jsb_cocos2d.js'); require('jsb_cocos2d_extension.js'); require('jsb_cocos2d_studio.js'); require('jsb_cocos2d_gui.js'); require('jsb_chipmunk_constants.js'); require('jsb_chipmunk.js'); require('jsb_opengl_constants.js'); require('jsb_opengl.js'); require('jsb_cocosbuilder.js'); require('jsb_sys.js'); require('jsb_deprecated.js'); ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_chipmunk.js ================================================ // // Chipmunk defines // var cp = cp || {}; cp.v = cc.p; cp._v = cc._p; cp.vzero = cp.v(0,0); // Vector: Compatibility with Chipmunk-JS cp.v.add = cp.vadd; cp.v.clamp = cp.vclamp; cp.v.cross = cp.vcross; cp.v.dist = cp.vdist; cp.v.distsq = cp.vdistsq; cp.v.dot = cp.vdot; cp.v.eql = cp.veql; cp.v.forangle = cp.vforangle; cp.v.len = cp.vlength; cp.v.lengthsq = cp.vlengthsq; cp.v.lerp = cp.vlerp; cp.v.lerpconst = cp.vlerpconst; cp.v.mult = cp.vmult; cp.v.near = cp.vnear; cp.v.neg = cp.vneg; cp.v.normalize = cp.vnormalize; cp.v.normalize_safe = cp.vnormalize_safe; cp.v.perp = cp.vperp; cp.v.project = cp.vproject; cp.v.rotate = cp.vrotate; cp.v.rperp = cp.vrperp; cp.v.slerp = cp.vslerp; cp.v.slerpconst = cp.vslerpconst; cp.v.sub = cp.vsub; cp.v.toangle = cp.vtoangle; cp.v.unrotate = cp.vunrotate; // XXX: renaming functions should be supported in JSB cp.clamp01 = cp.fclamp01; /// Initialize an offset box shaped polygon shape. cp.BoxShape2 = function(body, box) { var verts = [ box.l, box.b, box.l, box.t, box.r, box.t, box.r, box.b ]; return new cp.PolyShape(body, verts, cp.vzero); }; /// Initialize a box shaped polygon shape. cp.BoxShape = function(body, width, height) { var hw = width/2; var hh = height/2; return cp.BoxShape2(body, new cp.BB(-hw, -hh, hw, hh)); }; /// Initialize an static body cp.StaticBody = function() { return new cp.Body(Infinity, Infinity); }; // "Bounding Box" compatibility with Chipmunk-JS cp.BB = function(l, b, r, t) { return {l:l, b:b, r:r, t:t}; }; // helper function to create a BB cp.bb = function(l, b, r, t) { return new cp.BB(l, b, r, t); }; // // Some properties // // "handle" needed in some cases Object.defineProperties(cp.Base.prototype, { "handle" : { get : function(){ return this.getHandle(); }, enumerable : true, configurable : true } }); // Properties, for Chipmunk-JS compatibility // Space properties Object.defineProperties(cp.Space.prototype, { "gravity" : { get : function(){ return this.getGravity(); }, set : function(newValue){ this.setGravity(newValue); }, enumerable : true, configurable : true }, "iterations" : { get : function(){ return this.getIterations(); }, set : function(newValue){ this.setIterations(newValue); }, enumerable : true, configurable : true }, "damping" : { get : function(){ return this.getDamping(); }, set : function(newValue){ this.setDamping(newValue); }, enumerable : true, configurable : true }, "staticBody" : { get : function(){ return this.getStaticBody(); }, enumerable : true, configurable : true }, "idleSpeedThreshold" : { get : function(){ return this.getIdleSpeedThreshold(); }, set : function(newValue){ this.setIdleSpeedThreshold(newValue); }, enumerable : true, configurable : true }, "sleepTimeThreshold": { get : function(){ return this.getSleepTimeThreshold(); }, set : function(newValue){ this.setSleepTimeThreshold(newValue); }, enumerable : true, configurable : true }, "collisionSlop": { get : function(){ return this.getCollisionSlop(); }, set : function(newValue){ this.setCollisionSlop(newValue); }, enumerable : true, configurable : true }, "collisionBias": { get : function(){ return this.getCollisionBias(); }, set : function(newValue){ this.setCollisionBias(newValue); }, enumerable : true, configurable : true }, "collisionPersistence": { get : function(){ return this.getCollisionPersistence(); }, set : function(newValue){ this.setCollisionPersistence(newValue); }, enumerable : true, configurable : true }, "enableContactGraph": { get : function(){ return this.getEnableContactGraph(); }, set : function(newValue){ this.setEnableContactGraph(newValue); }, enumerable : true, configurable : true } }); // Body properties Object.defineProperties(cp.Body.prototype, { "a" : { get : function(){ return this.getAngle(); }, set : function(newValue){ this.setAngle(newValue); }, enumerable : true, configurable : true }, "w" : { get : function(){ return this.getAngVel(); }, set : function(newValue){ this.setAngVel(newValue); }, enumerable : true, configurable : true }, "p" : { get : function(){ return this.getPos(); }, set : function(newValue){ this.setPos(newValue); }, enumerable : true, configurable : true }, "v" : { get : function(){ return this.getVel(); }, set : function(newValue){ this.setVel(newValue); }, enumerable : true, configurable : true }, "i" : { get : function(){ return this.getMoment(); }, set : function(newValue){ this.setMoment(newValue); }, enumerable : true, configurable : true } }); // Shape properties Object.defineProperties(cp.Shape.prototype, { "body" : { get : function(){ return this.getBody(); }, set : function(newValue){ this.setBody(newValue); }, enumerable : true, configurable : true }, "group" : { get : function(){ return this.getGroup(); }, set : function(newValue){ this.setGroup(newValue); }, enumerable : true, configurable : true }, "collision_type" : { get : function(){ return this.getCollisionType(); }, enumerable : true, configurable : true } }); // Constraint properties Object.defineProperties(cp.Constraint.prototype, { "maxForce" : { get : function(){ return this.getMaxForce(); }, set : function(newValue){ this.setMaxForce(newValue); }, enumerable : true, configurable : true } }); // PinJoint properties Object.defineProperties(cp.PinJoint.prototype, { "anchr1" : { get : function(){ return this.getAnchr1(); }, set : function(newValue){ this.setAnchr1(newValue); }, enumerable : true, configurable : true }, "anchr2" : { get : function(){ return this.getAnchr2(); }, set : function(newValue){ this.setAnchr2(newValue); }, enumerable : true, configurable : true } }); ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_chipmunk_constants.js ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_jsb.py -c chipmunk_jsb.ini" on 2013-03-05 * Script version: v0.6 */ var cp = cp || {}; cp.ALLOW_PRIVATE_ACCESS = 0x1; cp.ALL_LAYERS = 0xffffffff; cp.BUFFER_BYTES = 0x8000; cp.CIRCLE_SHAPE = 0x0; cp.HASH_COEF = 0xc75f71e1; cp.MAX_CONTACTS_PER_ARBITER = 0x4; cp.NO_GROUP = 0x0; cp.NUM_SHAPES = 0x3; cp.POLY_SHAPE = 0x2; cp.SEGMENT_SHAPE = 0x1; cp.USE_CGPOINTS = 0x1; cp.USE_DOUBLES = 0x0; cp.VERSION_MAJOR = 0x6; cp.VERSION_MINOR = 0x1; cp.VERSION_RELEASE = 0x1; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_cocos2d.js ================================================ // // cocos2d constants // var cc = cc || {}; cc.TARGET_PLATFORM = { WINDOWS:0, LINUX:1, MACOS:2, ANDROID:3, IPHONE:4, IPAD:5, BLACKBERRY:6, NACL:7, EMSCRIPTEN:8, MOBILE_BROWSER:100, PC_BROWSER:101 }; cc.RESOLUTION_POLICY = { // The entire application is visible in the specified area without trying to preserve the original aspect ratio. // Distortion can occur, and the application may appear stretched or compressed. EXACT_FIT:0, // The entire application fills the specified area, without distortion but possibly with some cropping, // while maintaining the original aspect ratio of the application. NO_BORDER:1, // The entire application is visible in the specified area without distortion while maintaining the original // aspect ratio of the application. Borders can appear on two sides of the application. SHOW_ALL:2, // The application takes the height of the design resolution size and modifies the width of the internal // canvas so that it fits the aspect ratio of the device // no distortion will occur however you must make sure your application works on different // aspect ratios FIXED_HEIGHT:3, // The application takes the width of the design resolution size and modifies the height of the internal // canvas so that it fits the aspect ratio of the device // no distortion will occur however you must make sure your application works on different // aspect ratios FIXED_WIDTH:4, UNKNOWN:5 }; cc.LANGUAGE_ENGLISH = 0; cc.LANGUAGE_CHINESE = 1; cc.LANGUAGE_FRENCH = 2; cc.LANGUAGE_ITALIAN = 3; cc.LANGUAGE_GERMAN = 4; cc.LANGUAGE_SPANISH = 5; cc.LANGUAGE_RUSSIAN = 6; cc.LANGUAGE_KOREAN = 7; cc.LANGUAGE_JAPANESE = 8; cc.LANGUAGE_HUNGARIAN = 9; cc.LANGUAGE_PORTUGUESE = 10; cc.LANGUAGE_ARABIC = 11; cc.DIRECTOR_PROJECTION_2D = 0; cc.DIRECTOR_PROJECTION_3D = 1; cc.TEXTURE_PIXELFORMAT_RGBA8888 = 0; cc.TEXTURE_PIXELFORMAT_RGB888 = 1; cc.TEXTURE_PIXELFORMAT_RGB565 = 2; cc.TEXTURE_PIXELFORMAT_A8 = 3; cc.TEXTURE_PIXELFORMAT_I8 = 4; cc.TEXTURE_PIXELFORMAT_AI88 = 5; cc.TEXTURE_PIXELFORMAT_RGBA4444 = 6; cc.TEXTURE_PIXELFORMAT_RGB5A1 = 7; cc.TEXTURE_PIXELFORMAT_PVRTC4 = 8; cc.TEXTURE_PIXELFORMAT_PVRTC4 = 9; cc.TEXTURE_PIXELFORMAT_DEFAULT = cc.TEXTURE_PIXELFORMAT_RGBA8888; cc.TEXT_ALIGNMENT_LEFT = 0; cc.TEXT_ALIGNMENT_CENTER = 1; cc.TEXT_ALIGNMENT_RIGHT = 2; cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0; cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1; cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2; cc.IMAGE_FORMAT_JPEG = 0; cc.IMAGE_FORMAT_PNG = 0; cc.PROGRESS_TIMER_TYPE_RADIAL = 0; cc.PROGRESS_TIMER_TYPE_BAR = 1; cc.PARTICLE_TYPE_FREE = 0; cc.PARTICLE_TYPE_RELATIVE = 1; cc.PARTICLE_TYPE_GROUPED = 2; cc.PARTICLE_DURATION_INFINITY = -1; cc.PARTICLE_MODE_GRAVITY = 0; cc.PARTICLE_MODE_RADIUS = 1; cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1; cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1; cc.TOUCH_ALL_AT_ONCE = 0; cc.TOUCH_ONE_BY_ONE = 1; cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000; cc.TMX_TILE_VERTICAL_FLAG = 0x40000000; cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000; cc.TRANSITION_ORIENTATION_LEFT_OVER = 0; cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1; cc.TRANSITION_ORIENTATION_UP_OVER = 0; cc.TRANSITION_ORIENTATION_DOWN_OVER = 1; cc.RED = {r:255, g:0, b:0}; cc.GREEN = {r:0, g:255, b:0}; cc.BLUE = {r:0, g:0, b:255}; cc.BLACK = {r:0, g:0, b:0}; cc.WHITE = {r:255, g:255, b:255}; cc.YELLOW = {r:255, g:255, b:0}; cc.POINT_ZERO = {x:0, y:0}; // XXX: This definition is different than cocos2d-html5 // cc.REPEAT_FOREVER = - 1; // We can't assign -1 to cc.REPEAT_FOREVER, since it will be a very big double value after // converting it to double by JS_ValueToNumber on android. // Then cast it to unsigned int, the value will be 0. The schedule will not be able to work. // I don't know why this occurs only on android. // So instead of passing -1 to it, I assign it with max value of unsigned int in c++. cc.REPEAT_FOREVER = 0xffffffff; cc.MENU_STATE_WAITING = 0; cc.MENU_STATE_TRACKING_TOUCH = 1; cc.MENU_HANDLER_PRIORITY = -128; cc.DEFAULT_PADDING = 5; // reusable objects cc._reuse_p = [ {x:0, y:0}, {x:0,y:0}, {x:0,y:0}, {x:0,y:0} ]; cc._reuse_p_index = 0; cc._reuse_size = {width:0, height:0}; cc._reuse_rect = {x:0, y:0, width:0, height:0}; cc._reuse_color3b = {r:255, g:255, b:255 }; cc._reuse_color4b = {r:255, g:255, b:255, a:255 }; cc.log = cc._cocosplayerLog || cc.log || log; // // Color 3B // cc.c3b = function( r, g, b ) { switch (arguments.length) { case 0: return {r:0, g:0, b:0 }; case 1: if (r && r instanceof cc.c3b) { return {r:r.r, g:r.g, b:r.b }; } else { return {r:0, g:0, b:0 }; } case 3: return {r:r, g:g, b:b }; default: throw "unknown argument type"; break; } }; cc.integerToColor3B = function (intValue) { intValue = intValue || 0; var offset = 0xff; var retColor = {r:0, g:0, b:0 }; retColor.r = intValue & (offset); retColor.g = (intValue >> 8) & offset; retColor.b = (intValue >> 16) & offset; return retColor; }; cc._c3b = function( r, g, b ) { cc._reuse_color3b.r = r; cc._reuse_color3b.g = g; cc._reuse_color3b.b = b; return cc._reuse_color3b; }; cc.c3BEqual = function(color1, color2){ return color1.r === color2.r && color1.g === color2.g && color1.b === color2.b; }; cc.white = function () { return cc.c3b(255, 255, 255); }; cc.yellow = function () { return cc.c3b(255, 255, 0); }; cc.blue = function () { return cc.c3b(0, 0, 255); }; cc.green = function () { return cc.c3b(0, 255, 0); }; cc.red = function () { return cc.c3b(255, 0, 0); }; cc.magenta = function () { return cc.c3b(255, 0, 255); }; cc.black = function () { return cc.c3b(0, 0, 0); }; cc.orange = function () { return cc.c3b(255, 127, 0); }; cc.gray = function () { return cc.c3b(166, 166, 166); }; // // Color 4B // cc.c4b = function( r, g, b, a ) { return {r:r, g:g, b:b, a:a }; }; cc._c4b = function( r, g, b, a ) { cc._reuse_color4b.r = r; cc._reuse_color4b.g = g; cc._reuse_color4b.b = b; cc._reuse_color4b.a = a; return cc._reuse_color4b; }; // compatibility cc.c4 = cc.c4b; cc._c4 = cc._c4b; /** * convert Color3B to a string of color for style. * e.g. Color3B(255,6,255) to : "#ff06ff" * @param clr * @return {String} */ cc.convertColor3BtoHexString = function (clr) { var hR = clr.r.toString(16); var hG = clr.g.toString(16); var hB = clr.b.toString(16); var stClr = "#" + (clr.r < 16 ? ("0" + hR) : hR) + (clr.g < 16 ? ("0" + hG) : hG) + (clr.b < 16 ? ("0" + hB) : hB); return stClr; }; // // Color 4F // cc.c4f = function( r, g, b, a ) { return {r:r, g:g, b:b, a:a }; }; cc.c4FFromccc3B = function (c) { return cc.c4f(c.r / 255.0, c.g / 255.0, c.b / 255.0, 1.0); }; cc.c4FFromccc4B = function (c) { return cc.c4f(c.r / 255.0, c.g / 255.0, c.b / 255.0, c.a / 255.0); }; cc.c4BFromccc4F = function (c) { return cc.c4f(0 | (c.r * 255), 0 | (c.g * 255), 0 | (c.b * 255), 0 | (c.a * 255)); }; cc.c4FEqual = function (a, b) { return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; }; // // Point // cc.p = function( x, y ) { return {x:x, y:y}; }; cc._p = function( x, y ) { if( cc._reuse_p_index == cc._reuse_p.length ) cc._reuse_p_index = 0; var p = cc._reuse_p[ cc._reuse_p_index]; cc._reuse_p_index++; p.x = x; p.y = y; return p; }; cc.pointEqualToPoint = function (point1, point2) { return ((point1.x == point2.x) && (point1.y == point2.y)); }; cc.PointZero = function () { return cc.p(0, 0); }; // // Grid // cc._g = function( x, y ) { cc._reuse_grid.x = x; cc._reuse_grid.y = y; return cc._reuse_grid; }; // // Size // cc.size = function(w,h) { return {width:w, height:h}; }; cc._size = function(w,h) { cc._reuse_size.width = w; cc._reuse_size.height = h; return cc._reuse_size; }; cc.sizeEqualToSize = function (size1, size2) { return ((size1.width == size2.width) && (size1.height == size2.height)); }; cc.SizeZero = function () { return cc.size(0, 0); }; /** * create a cc.rect object * @param {Number|cc.point|cc.rect} [x] a Number value as x or a cc.point object as origin or a cc.rect clone object * @param {Number|cc.size} [y] x1 a Number value as y or a cc.size object as size * @param {Number} [w] * @param {Number} [h] * @return {Object} a cc.rect object */ cc.rect = function(x,y,w,h) { var argLen = arguments.length; if (argLen === 0) return { x: 0, y: 0, width: 0, height: 0 }; if (argLen === 1) return { x: x.x, y: x.y, width: x.width, height: x.height }; if (argLen === 2) return { x: x.x, y: x.y, width: y.width, height: y.height }; if (argLen === 4) return { x: x, y: y, width: w, height: h }; throw "unknown argument type"; }; cc._rect = function(x,y,w,h) { cc._reuse_rect.x = x; cc._reuse_rect.y = y; cc._reuse_rect.width = w; cc._reuse_rect.height = h; return cc._reuse_rect; }; cc.rectEqualToRect = function (rect1, rect2) { return ( rect1.x==rect2.x && rect1.y==rect2.y && rect1.width==rect2.width && rect1.height==rect2.height); }; cc.rectContainsRect = function (rect1, rect2) { if ((rect1.x >= rect2.x) || (rect1.y >= rect2.y) || ( rect1.x + rect1.width <= rect2.x + rect2.width) || ( rect1.y + rect1.height <= rect2.y + rect2.height)) return false; return true; }; cc.rectGetMaxX = function (rect) { return (rect.x + rect.width); }; cc.rectGetMidX = function (rect) { return (rect.x + rect.width / 2.0); }; cc.rectGetMinX = function (rect) { return rect.x; }; cc.rectGetMaxY = function (rect) { return(rect.y + rect.height); }; cc.rectGetMidY = function (rect) { return rect.y + rect.height / 2.0; }; cc.rectGetMinY = function (rect) { return rect.y; }; cc.rectContainsPoint = function (rect, point) { var ret = false; if (point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height) { ret = true; } return ret; }; cc.rectIntersectsRect = function( rectA, rectB ) { var bool = ! ( rectA.x > rectB.x + rectB.width || rectA.x + rectA.width < rectB.x || rectA.y > rectB.y +rectB.height || rectA.y + rectA.height < rectB.y ); return bool; }; cc.rectUnion = function (rectA, rectB) { var rect = cc.rect(0, 0, 0, 0); rect.x = Math.min(rectA.x, rectB.x); rect.y = Math.min(rectA.y, rectB.y); rect.width = Math.max(rectA.x + rectA.width, rectB.x + rectB.width) - rect.x; rect.height = Math.max(rectA.y + rectA.height, rectB.y + rectB.height) - rect.y; return rect; }; cc.rectIntersection = function (rectA, rectB) { var intersection = cc.rect( Math.max(rectA.x, rectB.x), Math.max(rectA.y, rectB.y), 0, 0); intersection.width = Math.min(rectA.x+rectA.width, rectB.x+rectB.width) - intersection.x; intersection.height = Math.min(rectA.y+rectA.height, rectB.y+rectB.height) - intersection.y; return intersection; }; cc.RectZero = function () { return cc.rect(0, 0, 0, 0); }; // // Array: for cocos2d-html5 compatibility // /** * Returns index of first occurence of object, -1 if value not found. * @function * @param {Array} arr Source Array * @param {*} findObj find object * @return {Number} index of first occurence of value */ cc.ArrayGetIndexOfObject = function (arr, findObj) { for (var i = 0; i < arr.length; i++) { if (arr[i] == findObj) return i; } return -1; }; /** * Returns a Boolean value that indicates whether value is present in the array. * @function * @param {Array} arr * @param {*} findObj * @return {Boolean} */ cc.ArrayContainsObject = function (arr, findObj) { return cc.ArrayGetIndexOfObject(arr, findObj) != -1; }; cc.ArrayRemoveObject = function (arr, delObj) { for (var i = 0; i < arr.length; i++) { if (arr[i] == delObj) { arr.splice(i, 1); } } }; // // Helpers // cc.dump = function(obj) { for( var i in obj ) cc.log( i + " = " + obj[i] ); }; // dump config info, but only in debug mode var sys = sys || undefined; cc.dumpConfig = function() { if (sys) { cc.dump(sys); cc.dump(sys.capabilities); } }; // // Bindings Overrides // // MenuItemToggle cc.MenuItemToggle.create = function( /* var args */) { var n = arguments.length; if (typeof arguments[n-2] === 'function' || typeof arguments[n-1] === 'function') { var args = Array.prototype.slice.call(arguments); var obj = null; if( typeof arguments[n-2] === 'function' ) obj = args.pop(); var func = args.pop(); // create it with arguments, var item = cc.MenuItemToggle._create.apply(this, args); // then set the callback if( obj !== null ) item.setCallback(func, obj); else item.setCallback(func); return item; } else { return cc.MenuItemToggle._create.apply(this, arguments); } }; // LabelAtlas cc.LabelAtlas.create = function( a,b,c,d,e ) { var n = arguments.length; if ( n == 5) { return cc.LabelAtlas._create(a,b,c,d,e.charCodeAt(0)); } else { return cc.LabelAtlas._create.apply(this, arguments); } }; cc.LayerMultiplex.create = cc.LayerMultiplex.createWithArray; /** * Associates a base class with a native superclass * @function * @param {object} jsobj subclass * @param {object} klass superclass */ cc.associateWithNative = function( jsobj, superclass_or_instance ) {}; // // JSB supports 2 official ways to create subclasses // // 1) Google "subclasses" borrowed from closure library // This is the recommended way to do it // cc.inherits = function (childCtor, parentCtor) { /** @constructor */ function tempCtor() {}; tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; childCtor.prototype = new tempCtor(); childCtor.prototype.constructor = childCtor; // Copy "static" method, but doesn't generate subclasses. // for( var i in parentCtor ) { // childCtor[ i ] = parentCtor[ i ]; // } }; cc.base = function(me, opt_methodName, var_args) { var caller = arguments.callee.caller; if (caller.superClass_) { // This is a constructor. Call the superclass constructor. ret = caller.superClass_.constructor.apply( me, Array.prototype.slice.call(arguments, 1)); return ret; } var args = Array.prototype.slice.call(arguments, 2); var foundCaller = false; for (var ctor = me.constructor; ctor; ctor = ctor.superClass_ && ctor.superClass_.constructor) { if (ctor.prototype[opt_methodName] === caller) { foundCaller = true; } else if (foundCaller) { return ctor.prototype[opt_methodName].apply(me, args); } } // If we did not find the caller in the prototype chain, // then one of two things happened: // 1) The caller is an instance method. // 2) This method was not called by the right caller. if (me[opt_methodName] === caller) { return me.constructor.prototype[opt_methodName].apply(me, args); } else { throw Error( 'cc.base called from a method of one name ' + 'to a method of a different name'); } }; // // 2) Using "extend" subclassing // Simple JavaScript Inheritance By John Resig http://ejohn.org/ // cc.Class = function(){}; cc.Class.extend = function (prop) { var _super = this.prototype; // Instantiate a base class (but only create the instance, // don't run the init constructor) initializing = true; var prototype = new this(); initializing = false; fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; // Copy the properties over onto the new prototype for (var name in prop) { // Check if we're overwriting an existing function prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function (name, fn) { return function () { var tmp = this._super; // Add a new ._super() method that is the same method // but on the super-class this._super = _super[name]; // The method only need to be bound temporarily, so we // remove it when we're done executing var ret = fn.apply(this, arguments); this._super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } // The dummy class constructor function Class() { // All construction is actually done in the init method if (!initializing) { if (!this.ctor) { if (this.__nativeObj) cc.log("No ctor function found! Please check whether `classes_need_extend` section in `ini` file like which in `tools/tojs/cocos2dx.ini`"); } else { this.ctor.apply(this, arguments); } } } // Populate our constructed prototype object Class.prototype = prototype; // Enforce the constructor to be what we expect Class.prototype.constructor = Class; // And make this class extendable Class.extend = arguments.callee; return Class; }; cc.Node.extend = cc.Class.extend; cc.Layer.extend = cc.Class.extend; cc.LayerGradient.extend = cc.Class.extend; cc.LayerColor.extend = cc.Class.extend; cc.Sprite.extend = cc.Class.extend; cc.MenuItemFont.extend = cc.Class.extend; cc.Scene.extend = cc.Class.extend; cc.DrawNode.extend = cc.Class.extend; // Cocos2d-html5 supports multi scene resources preloading. // This is a compatible function for JSB. cc.Loader = cc.Class.extend({ initWith:function (resources, selector, target) { if (selector) { this._selector = selector; this._target = target; } this._selector.call(this._target); } }); cc.Loader.preload = function (resources, selector, target) { if (!this._instance) { this._instance = new cc.Loader(); } this._instance.initWith(resources, selector, target); return this._instance; }; cc.LoaderScene = cc.Loader; var ConfigType = { NONE: 0, COCOSTUDIO: 1 }; var __onParseConfig = function(type, str) { if (type === ConfigType.COCOSTUDIO) { ccs.TriggerMng.getInstance().parse(JSON.parse(str)); } }; cc.VisibleRect = { _topLeft:cc.p(0,0), _topRight:cc.p(0,0), _top:cc.p(0,0), _bottomLeft:cc.p(0,0), _bottomRight:cc.p(0,0), _bottom:cc.p(0,0), _center:cc.p(0,0), _left:cc.p(0,0), _right:cc.p(0,0), _width:0, _height:0, _isInitialized: false, init:function(){ var director = cc.Director.getInstance(); var origin = director.getVisibleOrigin(); var size = director.getVisibleSize(); this._width = size.width; this._height = size.height; var x = origin.x; var y = origin.y; var w = this._width; var h = this._height; var left = origin.x; var right = origin.x + size.width; var middle = origin.x + size.width/2; //top this._top.y = this._topLeft.y = this._topRight.y = y + h; this._topLeft.x = left; this._top.x = middle; this._topRight.x = right; //bottom this._bottom.y = this._bottomRight.y = this._bottomLeft.y = y; this._bottomLeft.x = left this._bottom.x = middle; this._bottomRight.x = right; //center this._right.y = this._left.y = this._center.y = y + h/2; this._center.x = middle; //left this._left.x = left; //right this._right.x = right; }, lazyInit: function(){ if (!this._isInitialized) { this.init(); this._isInitialized = true; } }, getWidth:function(){ this.lazyInit(); return this._width; }, getHeight:function(){ this.lazyInit(); return this._height; }, topLeft:function(){ this.lazyInit(); return this._topLeft; }, topRight:function(){ this.lazyInit(); return this._topRight; }, top:function(){ this.lazyInit(); return this._top; }, bottomLeft:function(){ this.lazyInit(); return this._bottomLeft; }, bottomRight:function(){ this.lazyInit(); return this._bottomRight; }, bottom:function(){ this.lazyInit(); return this._bottom; }, center:function(){ this.lazyInit(); return this._center; }, left:function(){ this.lazyInit(); return this._left; }, right:function(){ this.lazyInit(); return this._right; } }; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_constants.js ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-03-10 * Script version: v0.6 */ var cc = cc || {}; cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff; cc.TMX_ORIENTATION_HEX = 0x1; cc.TMX_ORIENTATION_ISO = 0x2; cc.TMX_ORIENTATION_ORTHO = 0x0; cc.Z_COMPRESSION_BZIP2 = 0x1; cc.Z_COMPRESSION_GZIP = 0x2; cc.Z_COMPRESSION_NONE = 0x3; cc.Z_COMPRESSION_ZLIB = 0x0; cc.BLEND_DST = 0x303; cc.BLEND_SRC = 0x1; cc.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0; cc.DIRECTOR_MAC_THREAD = 0x0; cc.DIRECTOR_STATS_INTERVAL = 0.1; cc.ENABLE_BOX2_D_INTEGRATION = 0x0; cc.ENABLE_DEPRECATED = 0x1; cc.ENABLE_GL_STATE_CACHE = 0x1; cc.ENABLE_PROFILERS = 0x0; cc.ENABLE_STACKABLE_ACTIONS = 0x1; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0; cc.GL_ALL = 0x0; cc.LABELATLAS_DEBUG_DRAW = 0x0; cc.LABELBMFONT_DEBUG_DRAW = 0x0; cc.MAC_USE_DISPLAY_LINK_THREAD = 0x0; cc.MAC_USE_MAIN_THREAD = 0x2; cc.MAC_USE_OWN_THREAD = 0x1; cc.NODE_RENDER_SUBPIXEL = 0x1; cc.PVRMIPMAP_MAX = 0x10; cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1; cc.SPRITE_DEBUG_DRAW = 0x0; cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0; cc.TEXTURE_ATLAS_USE_VAO = 0x1; cc.USE_L_A88_LABELS = 0x1; cc.ACTION_TAG_INVALID = -1; cc.DEVICE_MAC = 0x6; cc.DEVICE_MAC_RETINA_DISPLAY = 0x7; cc.DEVICEI_PAD = 0x4; cc.DEVICEI_PAD_RETINA_DISPLAY = 0x5; cc.DEVICEI_PHONE = 0x0; cc.DEVICEI_PHONE5 = 0x2; cc.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3; cc.DEVICEI_PHONE_RETINA_DISPLAY = 0x1; cc.DIRECTOR_PROJECTION2_D = 0x0; cc.DIRECTOR_PROJECTION3_D = 0x1; cc.DIRECTOR_PROJECTION_CUSTOM = 0x2; cc.DIRECTOR_PROJECTION_DEFAULT = 0x1; cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1; cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0; cc.FLIPED_ALL = 0xe0000000; cc.FLIPPED_MASK = 0x1fffffff; cc.IMAGE_FORMAT_JPEG = 0x0; cc.IMAGE_FORMAT_PNG = 0x1; cc.ITEM_SIZE = 0x20; cc.LABEL_AUTOMATIC_WIDTH = -1; cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1; cc.LINE_BREAK_MODE_CLIP = 0x2; cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3; cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5; cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4; cc.LINE_BREAK_MODE_WORD_WRAP = 0x0; cc.MAC_VERSION_10_6 = 0xa060000; cc.MAC_VERSION_10_7 = 0xa070000; cc.MAC_VERSION_10_8 = 0xa080000; cc.MENU_HANDLER_PRIORITY = -128; cc.MENU_STATE_TRACKING_TOUCH = 0x1; cc.MENU_STATE_WAITING = 0x0; cc.NODE_TAG_INVALID = -1; cc.PARTICLE_DURATION_INFINITY = -1; cc.PARTICLE_MODE_GRAVITY = 0x0; cc.PARTICLE_MODE_RADIUS = 0x1; cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1; cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1; cc.POSITION_TYPE_FREE = 0x0; cc.POSITION_TYPE_GROUPED = 0x2; cc.POSITION_TYPE_RELATIVE = 0x1; cc.PRIORITY_NON_SYSTEM_MIN = -2147483647; cc.PRIORITY_SYSTEM = -2147483648; cc.PROGRESS_TIMER_TYPE_BAR = 0x1; cc.PROGRESS_TIMER_TYPE_RADIAL = 0x0; cc.REPEAT_FOREVER = 0xfffffffe; cc.RESOLUTION_MAC = 0x1; cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2; cc.RESOLUTION_UNKNOWN = 0x0; cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000; cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000; cc.TMX_TILE_VERTICAL_FLAG = 0x40000000; cc.TEXT_ALIGNMENT_CENTER = 0x1; cc.TEXT_ALIGNMENT_LEFT = 0x0; cc.TEXT_ALIGNMENT_RIGHT = 0x2; cc.TEXTURE_2D_PIXEL_FORMAT_A8 = 0x3; cc.TEXTURE_2D_PIXEL_FORMAT_AI88 = 0x5; cc.TEXTURE_2D_PIXEL_FORMAT_DEFAULT = 0x0; cc.TEXTURE_2D_PIXEL_FORMAT_I8 = 0x4; cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC2 = 0x9; cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC4 = 0x8; cc.TEXTURE_2D_PIXEL_FORMAT_RGB565 = 0x2; cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1 = 0x7; cc.TEXTURE_2D_PIXEL_FORMAT_RGB888 = 0x1; cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444 = 0x6; cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888 = 0x0; cc.TOUCHES_ALL_AT_ONCE = 0x0; cc.TOUCHES_ONE_BY_ONE = 0x1; cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1; cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0; cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1; cc.TRANSITION_ORIENTATION_UP_OVER = 0x0; cc.UNIFORM_COS_TIME = 0x5; cc.UNIFORM_MV_MATRIX = 0x1; cc.UNIFORM_MVP_MATRIX = 0x2; cc.UNIFORM_P_MATRIX = 0x0; cc.UNIFORM_RANDOM01 = 0x6; cc.UNIFORM_SAMPLER = 0x7; cc.UNIFORM_SIN_TIME = 0x4; cc.UNIFORM_TIME = 0x3; cc.UNIFORM_MAX = 0x8; cc.VERTEX_ATTRIB_FLAG_COLOR = 0x2; cc.VERTEX_ATTRIB_FLAG_NONE = 0x0; cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7; cc.VERTEX_ATTRIB_FLAG_POSITION = 0x1; cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4; cc.VERTEX_ATTRIB_COLOR = 0x1; cc.VERTEX_ATTRIB_MAX = 0x3; cc.VERTEX_ATTRIB_POSITION = 0x0; cc.VERTEX_ATTRIB_TEX_COORDS = 0x2; cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2; cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1; cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0; cc.OS_VERSION_4_0 = 0x4000000; cc.OS_VERSION_4_0_1 = 0x4000100; cc.OS_VERSION_4_1 = 0x4010000; cc.OS_VERSION_4_2 = 0x4020000; cc.OS_VERSION_4_2_1 = 0x4020100; cc.OS_VERSION_4_3 = 0x4030000; cc.OS_VERSION_4_3_1 = 0x4030100; cc.OS_VERSION_4_3_2 = 0x4030200; cc.OS_VERSION_4_3_3 = 0x4030300; cc.OS_VERSION_4_3_4 = 0x4030400; cc.OS_VERSION_4_3_5 = 0x4030500; cc.OS_VERSION_5_0 = 0x5000000; cc.OS_VERSION_5_0_1 = 0x5000100; cc.OS_VERSION_5_1_0 = 0x5010000; cc.OS_VERSION_6_0_0 = 0x6000000; cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification'; cc.CHIPMUNK_IMPORT = 'chipmunk.h'; cc.ATTRIBUTE_NAME_COLOR = 'a_color'; cc.ATTRIBUTE_NAME_POSITION = 'a_position'; cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord'; cc.SHADER_POSITION_COLOR = 'ShaderPositionColor'; cc.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor'; cc.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture'; cc.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color'; cc.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor'; cc.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest'; cc.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor'; cc.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor'; cc.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue'; cc.UNIFORM_COS_TIME_S = 'CC_CosTime'; cc.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix'; cc.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix'; cc.UNIFORM_P_MATRIX_S = 'CC_PMatrix'; cc.UNIFORM_RANDOM01_S = 'CC_Random01'; cc.UNIFORM_SAMPLER_S = 'CC_Texture0'; cc.UNIFORM_SIN_TIME_S = 'CC_SinTime'; cc.UNIFORM_TIME_S = 'CC_Time'; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_extension.js ================================================ // // cocos2d constants // // This helper file should be required after jsb_cocos2d.js // var cc = cc || {}; cc.SCROLLVIEW_DIRECTION_NONE = -1; cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0; cc.SCROLLVIEW_DIRECTION_VERTICAL = 1; cc.SCROLLVIEW_DIRECTION_BOTH = 2; cc.TABLEVIEW_FILL_TOPDOWN = 0; cc.TABLEVIEW_FILL_BOTTOMUP = 1; /** * @constant * @type Number */ cc.KEYBOARD_RETURNTYPE_DEFAULT = 0; /** * @constant * @type Number */ cc.KEYBOARD_RETURNTYPE_DONE = 1; /** * @constant * @type Number */ cc.KEYBOARD_RETURNTYPE_SEND = 2; /** * @constant * @type Number */ cc.KEYBOARD_RETURNTYPE_SEARCH = 3; /** * @constant * @type Number */ cc.KEYBOARD_RETURNTYPE_GO = 4; /** * The EditBox::InputMode defines the type of text that the user is allowed * to enter. * @constant * @type Number */ cc.EDITBOX_INPUT_MODE_ANY = 0; /** * The user is allowed to enter an e-mail address. * @constant * @type Number */ cc.EDITBOX_INPUT_MODE_EMAILADDR = 1; /** * The user is allowed to enter an integer value. * @constant * @type Number */ cc.EDITBOX_INPUT_MODE_NUMERIC = 2; /** * The user is allowed to enter a phone number. * @constant * @type Number */ cc.EDITBOX_INPUT_MODE_PHONENUMBER = 3; /** * The user is allowed to enter a URL. * @constant * @type Number */ cc.EDITBOX_INPUT_MODE_URL = 4; /** * The user is allowed to enter a real number value. * This extends kEditBoxInputModeNumeric by allowing a decimal point. * @constant * @type Number */ cc.EDITBOX_INPUT_MODE_DECIMAL = 5; /** * The user is allowed to enter any text, except for line breaks. * @constant * @type Number */ cc.EDITBOX_INPUT_MODE_SINGLELINE = 6; /** * Indicates that the text entered is confidential data that should be * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. * @constant * @type Number */ cc.EDITBOX_INPUT_FLAG_PASSWORD = 0; /** * Indicates that the text entered is sensitive data that the * implementation must never store into a dictionary or table for use * in predictive, auto-completing, or other accelerated input schemes. * A credit card number is an example of sensitive data. * @constant * @type Number */ cc.EDITBOX_INPUT_FLAG_SENSITIVE = 1; /** * This flag is a hint to the implementation that during text editing, * the initial letter of each word should be capitalized. * @constant * @type Number */ cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2; /** * This flag is a hint to the implementation that during text editing, * the initial letter of each sentence should be capitalized. * @constant * @type Number */ cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3; /** * Capitalize all characters automatically. * @constant * @type Number */ cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4; cc.CONTROL_EVENT_TOTAL_NUMBER = 9; cc.CONTROL_EVENT_TOUCH_DOWN = 1 << 0; // A touch-down event in the control. cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE = 1 << 1; // An event where a finger is dragged inside the bounds of the control. cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE = 1 << 2; // An event where a finger is dragged just outside the bounds of the control. cc.CONTROL_EVENT_TOUCH_DRAG_ENTER = 1 << 3; // An event where a finger is dragged into the bounds of the control. cc.CONTROL_EVENT_TOUCH_DRAG_EXIT = 1 << 4; // An event where a finger is dragged from within a control to outside its bounds. cc.CONTROL_EVENT_TOUCH_UP_INSIDE = 1 << 5; // A touch-up event in the control where the finger is inside the bounds of the control. cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE = 1 << 6; // A touch-up event in the control where the finger is outside the bounds of the control. cc.CONTROL_EVENT_TOUCH_CANCEL = 1 << 7; // A system event canceling the current touches for the control. cc.CONTROL_EVENT_VALUECHANGED = 1 << 8; // A touch dragging or otherwise manipulating a control; causing it to emit a series of different values. cc.CONTROL_STATE_NORMAL = 1 << 0; // The normal; or default state of a control梩hat is; enabled but neither selected nor highlighted. cc.CONTROL_STATE_HIGHLIGHTED = 1 << 1; // Highlighted state of a control. A control enters this state when a touch down; drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property. cc.CONTROL_STATE_DISABLED = 1 << 2; // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property. cc.CONTROL_STATE_SELECTED = 1 << 3; // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property. cc.CONTROL_STATE_INITIAL = 1 << 3; // PhysicsDebugNode cc.PhysicsDebugNode.create = function( space ) { var s = space; if( space.handle !== undefined ) s = space.handle; return cc.PhysicsDebugNode._create( s ); }; cc.PhysicsDebugNode.prototype.setSpace = function( space ) { var s = space; if( space.handle !== undefined ) s = space.handle; return this._setSpace( s ); }; // PhysicsSprite cc.PhysicsSprite.prototype.setBody = function( body ) { var b = body; if( body.handle !== undefined ) b = body.handle; return this._setCPBody( b ); }; cc.PhysicsSprite.prototype.getBody = function() { return this.getCPBody(); }; cc.ScrollView.extend = cc.Class.extend; cc.TableView.extend = cc.Class.extend; cc.TableViewCell.extend = cc.Class.extend; cc.GLNode.extend = cc.Class.extend; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_gui.js ================================================ // // cocos2d gui constants // // This helper file should be required after jsb_cocos2d.js // var ccui = ccui || {}; ccui.BrightStyle = { none: -1, normal: 0, highlight: 1 }; ccui.WidgetType = { widget: 0, //control container: 1 //container }; ccui.TextureResType = { local: 0, plist: 1 }; ccui.TouchEventType = { began: 0, moved: 1, ended: 2, canceled: 3 }; ccui.SizeType = { absolute: 0, percent: 1 }; ccui.PositionType = { absolute: 0, percent: 1 }; ccui.CheckBoxEventType = { selected: 0, unselected: 1 }; ccui.TextFiledEventType = { attach_with_me: 0, detach_with_ime: 1, insert_text: 2, delete_backward: 3 }; ccui.LayoutBackGroundColorType = { none: 0, solid: 1, gradient: 2 }; ccui.LayoutType = { absolute: 0, linearVertical: 1, linearHorizontal: 2, relative: 3 }; ccui.LayoutParameterType = { none: 0, linear: 1, relative: 2 }; ccui.LinearGravity = { none: 0, left: 1, top: 2, right: 3, bottom: 4, centerVertical: 5, centerHorizontal: 6 }; ccui.RelativeAlign = { alignNone: 0, alignParentTopLeft: 1, alignParentTopCenterHorizontal: 2, alignParentTopRight: 3, alignParentLeftCenterVertical: 4, centerInParent: 5, alignParentRightCenterVertical: 6, alignParentLeftBottom: 7, alignParentBottomCenterHorizontal: 8, alignParentRightBottom: 9, locationAboveLeftAlign: 10, locationAboveCenter: 11, locationAboveRightAlign: 12, locationLeftOfTopAlign: 13, locationLeftOfCenter: 14, locationLeftOfBottomAlign: 15, locationRightOfTopAlign: 16, locationRightOfCenter: 17, locationRightOfBottomAlign: 18, locationBelowLeftAlign: 19, locationBelowCenter: 20, locationBelowRightAlign: 21 }; ccui.SliderEventType = {percent_changed: 0}; ccui.LoadingBarType = { left: 0, right: 1}; ccui.ScrollViewDir = { none: 0, vertical: 1, horizontal: 2, both: 3 }; ccui.ScrollviewEventType = { scrollToTop: 0, scrollToBottom: 1, scrollToLeft: 2, scrollToRight: 3, scrolling: 4, bounceTop: 5, bounceBottom: 6, bounceLeft: 7, bounceRight: 8 }; ccui.ListViewEventType = { init_child: 0, update_child: 1 }; ccui.ListViewGravity = { left: 0, right: 1, centerHorizontal: 2, top: 3, bottom: 4, centerVertical: 5 }; ccui.PageViewEventType = { turning: 0 }; ccui.PVTouchDir = { touchLeft: 0, touchRight: 1 }; ccui.Margin = cc.Class.extend({ left: 0, top: 0, right: 0, bottom: 0, ctor: function () { if (arguments.length == 1) { var uiMargin = arguments[0]; this.left = uiMargin.left; this.top = uiMargin.top; this.right = uiMargin.right; this.bottom = uiMargin.bottom; } if (arguments.length == 4) { this.left = arguments[0]; this.top = arguments[1]; this.right = arguments[2]; this.bottom = arguments[3]; } }, setMargin: function (l, t, r, b) { this.left = l; this.top = t; this.right = r; this.bottom = b; }, equals: function (target) { return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom); } }); ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_studio.js ================================================ // // cocos2d studio constants // // This helper file should be required after jsb_cocos2d.js // var ccs = ccs || {}; ccs.Class = ccs.Class || cc.Class || {}; //movement event type ccs.MovementEventType = { start: 0, complete: 1, loopComplete: 2 }; // Armature if(ccs.Armature){ ccs.Armature.prototype.setBody = function( body ) { var b = body; if( body.handle !== undefined ) b = body.handle; return this._setCPBody( b ); }; ccs.ComController.extend = cc.Class.extend; ccs.Armature.extend = cc.Class.extend; } ccs.sendEvent = function (event) { var triggerObjArr = ccs.TriggerMng.getInstance().get(event); if (triggerObjArr == null) { return; } for (var i = 0; i < triggerObjArr.length; i++) { var triObj = triggerObjArr[i]; if (triObj != null && triObj.detect()) { triObj.done(); } } }; ccs.ObjectFactory = ccs.Class.extend({ _typeMap: null, ctor: function () { this._typeMap = {}; }, destroyInstance: function () { this._sharedFactory = null; }, createObject: function (className) { var o = null; var t = this._typeMap[className]; if (t) { o = new t._fun(); } return o; }, registerType: function (t) { this._typeMap[t._className] = t; } }); ccs.ObjectFactory._sharedFactory = null; ccs.ObjectFactory.getInstance = function () { if (!this._sharedFactory) { this._sharedFactory = new ccs.ObjectFactory(); } return this._sharedFactory; }; ccs.TInfo = ccs.Class.extend({ _className: "", _fun: null, /** * * @param {String|ccs.TInfo}c * @param {Function}f */ ctor: function (c, f) { if (f) { this._className = c; this._fun = f; }else{ this._className = c._className; this._fun = c._fun; } ccs.ObjectFactory.getInstance().registerType(this); } }); ccs.registerTriggerClass = function(className, createFunc) { new ccs.TInfo(className, createFunc); } ccs.BaseTriggerCondition = ccs.Class.extend({ init: function () { return true; }, detect: function () { return true; }, serialize: function (jsonVal) { }, removeAll: function () { } }); ccs.BaseTriggerAction = ccs.Class.extend({ init: function () { return true; }, done: function () { }, serialize: function (jsonVal) { }, removeAll: function () { } }); ccs.TriggerObj = ccs.Class.extend({ _cons: null, _acts: null, _id: 0, _enable: true, _vInt: null, ctor: function () { this._id = 0; this._enable = true; }, init: function () { this._cons = []; this._acts = []; this._vInt = []; return true; }, detect: function () { if (!this._enable || this._cons.length == 0) { return true; } var ret = true; var obj = null; for (var i = 0; i < this._cons.length; i++) { obj = this._cons[i]; if (obj && obj.detect) { ret = ret && obj.detect(); } } return ret; }, done: function () { if (!this._enable || this._acts.length == 0) { return; } var obj; for (var i = 0; i < this._acts.length; i++) { obj = this._acts[i]; if (obj && obj.done) { obj.done(); } } }, removeAll: function () { var obj = null; for (var i = 0; i < this._cons.length; i++) { obj = this._cons[i]; if (obj) obj.removeAll(); } this._cons = []; for (var i = 0; i < this._acts.length; i++) { obj = this._acts[i]; if (obj) obj.removeAll(); } this._acts = []; }, serialize: function (jsonVal) { this._id = jsonVal["id"] || 0; var conditions = jsonVal["conditions"] || []; for (var i = 0; i < conditions.length; i++) { var subDict = conditions[i]; var classname = subDict["classname"]; if (!classname) { continue; } var con = ccs.ObjectFactory.getInstance().createObject(classname); if (!con) { cc.log("class named classname(" + classname + ") can not implement!"); } con.serialize(subDict); con.init(); this._cons.push(con); } var actions = jsonVal["actions"] || []; for (var i = 0; i < actions.length; i++) { var subDict = actions[i]; var classname = subDict["classname"]; if (!classname) { continue; } var act = ccs.ObjectFactory.getInstance().createObject(classname); if (!act) { cc.log("class named classname(" + classname + ") can not implement!"); } act.serialize(subDict); act.init(); this._acts.push(act); } var events = jsonVal["events"] || []; for (var i = 0; i < events.length; i++) { var subDict = events[i]; var event = subDict["id"]; if (event < 0) { continue; } this._vInt.push(event); } }, getId: function () { return this._id; }, setEnable: function (enable) { this._enable = enable; }, getEvents: function () { return this._vInt; } }); ccs.TriggerObj.create = function() { var ret = new ccs.TriggerObj(); if (ret.init()) return ret; return null; } ccs.TriggerMng = ccs.Class.extend({ _eventTriggers: null, _triggerObjs: null, _movementDispatches: null, ctor: function () { this._eventTriggers = {}; this._triggerObjs = {}; this._movementDispatches = []; }, destroyInstance: function () { this.removeAll(); this._instance = null; }, parse: function (root) { var triggers = root;//["Triggers"]; for (var i = 0; i < triggers.length; ++i) { var subDict = triggers[i]; var triggerObj = ccs.TriggerObj.create(); triggerObj.serialize(subDict); var events = triggerObj.getEvents(); for (var j = 0; j < events.length; j++) { var event = events[j]; this.add(event, triggerObj); } this._triggerObjs[triggerObj.getId()] = triggerObj; } }, get: function (event) { return this._eventTriggers[event]; }, getTriggerObj: function (id) { return this._triggerObjs[id]; }, add: function (event, triggerObj) { var eventTriggers = this._eventTriggers[event]; if (!eventTriggers) { eventTriggers = []; } if (!cc.ArrayContainsObject(eventTriggers, triggerObj)) { eventTriggers.push(triggerObj); this._eventTriggers[event] = eventTriggers; } }, removeAll: function () { for (var key in this._eventTriggers) { var triObjArr = this._eventTriggers[key]; for (var j = 0; j < triObjArr.length; j++) { var obj = triObjArr[j]; obj.removeAll(); } } this._eventTriggers = {}; }, remove: function (event, Obj) { if (Obj) { return this._removeObj(event, Obj); } var bRet = false; do { var triObjects = this._eventTriggers[event]; if (!triObjects) break; for (var i = 0; i < triObjects.length; i++) { var triObject = triObjects[i]; if (triObject) { triObject.removeAll(); } } delete this._eventTriggers[event]; bRet = true; } while (0); return bRet; }, _removeObj: function (event, Obj) { var bRet = false; do { var triObjects = this._eventTriggers[event]; if (!triObjects) break; for (var i = 0; i < triObjects.length; i++) { var triObject = triObjects[i]; if (triObject && triObject == Obj) { triObject.removeAll(); triObjects.splice(i, 1); break; } } bRet = true; } while (0); return bRet; }, removeTriggerObj: function (id) { var obj = this.getTriggerObj(id); if (!obj) { return false; } var events = obj.getEvents(); for (var i = 0; i < events.length; i++) { var event = events[i]; this.remove(event, obj); } return true; }, isEmpty: function () { return !this._eventTriggers || this._eventTriggers.length <= 0; }, addArmatureMovementCallBack: function (armature, callFunc, target) { if (armature == null || target == null || callFunc == null) { return; } var locAmd, hasADD = false; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; if (locAmd && locAmd[0] == armature) { locAmd.addAnimationEventCallBack(callFunc, target); hasADD = true; } } if (!hasADD) { var newAmd = new ccs.ArmatureMovementDispatcher(); armature.getAnimation().setMovementEventCallFunc(newAmd.animationEvent, newAmd); newAmd.addAnimationEventCallBack(callFunc, target); this._movementDispatches.push([armature, newAmd]); } }, removeArmatureMovementCallBack: function (armature, target, callFunc) { if (armature == null || target == null || callFunc == null) { return; } var locAmd; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; if (locAmd && locAmd[0] == armature) { locAmd.removeAnimationEventCallBack(callFunc, target); } } }, removeArmatureAllMovementCallBack: function (armature) { if (armature == null) { return; } var locAmd; for (var i = 0; i < this._movementDispatches.length; i++) { locAmd = this._movementDispatches[i]; if (locAmd && locAmd[0] == armature) { this._movementDispatches.splice(i, 1); break; } } }, removeAllArmatureMovementCallBack: function () { this._movementDispatches = []; } }); ccs.TriggerMng.triggerMngVersion = function () { return "1.2.0.0"; }; ccs.TriggerMng._instance = null; ccs.TriggerMng.getInstance = function () { if (null == this._instance) { this._instance = new ccs.TriggerMng(); } return this._instance; }; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_cocosbuilder.js ================================================ // // CocosBuilder definitions // cc.BuilderReader = cc.BuilderReader || {}; cc.BuilderReader._resourcePath = ""; var _ccbGlobalContext = this; cc.BuilderReader.setResourcePath = function (rootPath) { cc.BuilderReader._resourcePath = rootPath; }; cc.BuilderReader.load = function(file, owner, parentSize) { // Load the node graph using the correct function var reader = cc._Reader.create(); reader.setCCBRootPath(cc.BuilderReader._resourcePath); var node; if (parentSize) { node = reader.load(file, null, parentSize); } else { node = reader.load(file); } // Assign owner callbacks & member variables if (owner) { // Callbacks var ownerCallbackNames = reader.getOwnerCallbackNames(); var ownerCallbackNodes = reader.getOwnerCallbackNodes(); for (var i = 0; i < ownerCallbackNames.length; i++) { var callbackName = ownerCallbackNames[i]; var callbackNode = ownerCallbackNodes[i]; if (owner[callbackName] === undefined) { cc.log("Warning: " + "owner." + callbackName + " is undefined."); } else { if(callbackNode instanceof cc.ControlButton) { var ownerCallbackControlEvents = reader.getOwnerCallbackControlEvents(); callbackNode.addTargetWithActionForControlEvents(owner, owner[callbackName], ownerCallbackControlEvents[i]); } else { callbackNode.setCallback(owner[callbackName], owner); } } } // Variables var ownerOutletNames = reader.getOwnerOutletNames(); var ownerOutletNodes = reader.getOwnerOutletNodes(); for (var i = 0; i < ownerOutletNames.length; i++) { var outletName = ownerOutletNames[i]; var outletNode = ownerOutletNodes[i]; owner[outletName] = outletNode; } } var nodesWithAnimationManagers = reader.getNodesWithAnimationManagers(); var animationManagersForNodes = reader.getAnimationManagersForNodes(); // Attach animation managers to nodes and assign root node callbacks and member variables for (var i = 0; i < nodesWithAnimationManagers.length; i++) { var innerNode = nodesWithAnimationManagers[i]; var animationManager = animationManagersForNodes[i]; innerNode.animationManager = animationManager; var documentControllerName = animationManager.getDocumentControllerName(); if (!documentControllerName) continue; // Create a document controller var controller = new _ccbGlobalContext[documentControllerName](); controller.controllerName = documentControllerName; innerNode.controller = controller; controller.rootNode = innerNode; // Callbacks var documentCallbackNames = animationManager.getDocumentCallbackNames(); var documentCallbackNodes = animationManager.getDocumentCallbackNodes(); for (var j = 0; j < documentCallbackNames.length; j++) { var callbackName = documentCallbackNames[j]; var callbackNode = documentCallbackNodes[j]; if (controller[callbackName] === undefined) { cc.log("Warning: " + documentControllerName + "." + callbackName + " is undefined."); } else { if(callbackNode instanceof cc.ControlButton) { var documentCallbackControlEvents = animationManager.getDocumentCallbackControlEvents(); callbackNode.addTargetWithActionForControlEvents(controller, controller[callbackName], documentCallbackControlEvents[j]); } else { callbackNode.setCallback(controller[callbackName], controller); } } } // Variables var documentOutletNames = animationManager.getDocumentOutletNames(); var documentOutletNodes = animationManager.getDocumentOutletNodes(); for (var j = 0; j < documentOutletNames.length; j++) { var outletName = documentOutletNames[j]; var outletNode = documentOutletNodes[j]; controller[outletName] = outletNode; } if (typeof(controller.onDidLoadFromCCB) == "function") { controller.onDidLoadFromCCB(); } // Setup timeline callbacks var keyframeCallbacks = animationManager.getKeyframeCallbacks(); for (var j = 0; j < keyframeCallbacks.length; j++) { var callbackSplit = keyframeCallbacks[j].split(":"); var callbackType = callbackSplit[0]; var callbackName = callbackSplit[1]; if (callbackType == 1) // Document callback { var callfunc = cc.CallFunc.create(controller[callbackName], controller); animationManager.setCallFunc(callfunc, keyframeCallbacks[j]); } else if (callbackType == 2 && owner) // Owner callback { var callfunc = cc.CallFunc.create(owner[callbackName], owner); animationManager.setCallFunc(callfunc, keyframeCallbacks[j]); } } // Start animation var autoPlaySeqId = animationManager.getAutoPlaySequenceId(); if (autoPlaySeqId != -1) { animationManager.runAnimationsForSequenceIdTweenDuration(autoPlaySeqId, 0); } } return node; }; cc.BuilderReader.loadAsScene = function(file, owner, parentSize) { var node = cc.BuilderReader.load(file, owner, parentSize); var scene = cc.Scene.create(); scene.addChild( node ); return scene; }; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_debugger.js ================================================ require('debugger/DevToolsUtils.js', "debug"); require('debugger/core/promise.js', "debug"); require('debugger/transport.js', "debug"); require('debugger/actors/root.js', "debug"); require('debugger/actors/script.js', "debug"); require('debugger/main.js', "debug"); var globalDebuggee = null; function TestTabActor(aConnection, aGlobal) { this.conn = aConnection; this._global = aGlobal; this._threadActor = new ThreadActor(this, this._global); this.conn.addActor(this._threadActor); this._attached = false; } TestTabActor.prototype = { constructor: TestTabActor, actorPrefix: "TestTabActor", grip: function() { return { actor: this.actorID, title: "Hello Cocos2d-X JSB", url: "http://cocos2d-x.org" }; }, onAttach: function(aRequest) { this._attached = true; return { type: "tabAttached", threadActor: this._threadActor.actorID }; }, onDetach: function(aRequest) { if (!this._attached) { return { "error":"wrongState" }; } return { type: "detached" }; }, // Hooks for use by TestTabActors. addToParentPool: function(aActor) { this.conn.addActor(aActor); }, removeFromParentPool: function(aActor) { this.conn.removeActor(aActor); } }; TestTabActor.prototype.requestTypes = { "attach": TestTabActor.prototype.onAttach, "detach": TestTabActor.prototype.onDetach }; function TestTabList(aConnection) { this.conn = aConnection; // An array of actors for each global added with // DebuggerServer.addTestGlobal. this._tabActors = []; // A pool mapping those actors' names to the actors. this._tabActorPool = new ActorPool(aConnection); // for (let global of gTestGlobals) { let actor = new TestTabActor(aConnection, globalDebuggee); actor.selected = false; this._tabActors.push(actor); this._tabActorPool.addActor(actor); // } if (this._tabActors.length > 0) { this._tabActors[0].selected = true; } aConnection.addActorPool(this._tabActorPool); } TestTabList.prototype = { constructor: TestTabList, iterator: function() { for (let actor of this._tabActors) { yield actor; } } }; this.processInput = function (inputstr) { if (!inputstr) { return; } if (inputstr === "connected") { DebuggerServer.createRootActor = (conn => { return new RootActor(conn, { tabList: new TestTabList(conn) }); }); DebuggerServer.init(() => true); DebuggerServer.openListener(5086); if (debuggerServer && debuggerServer.onSocketAccepted) { var aTransport = { host: "127.0.0.1", port: 5086, openInputStream: function() { return { close: function(){} }; }, openOutputStream: function() { return { close: function(){}, write: function(){}, asyncWait: function(){} }; }, }; debuggerServer.onSocketAccepted(null, aTransport); } return; } if (DebuggerServer && DebuggerServer._transport && DebuggerServer._transport.onDataAvailable) { DebuggerServer._transport.onDataAvailable(inputstr); } }; this._prepareDebugger = function (global) { globalDebuggee = global; }; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_deprecated.js ================================================ // Deprecated functions var cc = cc || {}; (function() { var logW = function(old_name, new_name) { cc.log("\n********** \n"+old_name +" was deprecated, please use "+ new_name +" instead.\n**********"); }; // Deprecated static functions cc.AnimationCache.purgeSharedAnimationCache = function() { logW("cc.AnimationCache.purgeSharedAnimationCache", "cc.AnimationCache.destroyInstance"); cc.AnimationCache.destroyInstance(); }; cc.TextureCache.getInstance = function() { return cc.Director.getInstance().getTextureCache(); }; // Deprecated member functions cc.Action.prototype.copy = function() { logW("cc.Action.copy", "cc.Action.clone"); return cc.Action.prototype.clone.apply(this, arguments); }; cc.Animation.prototype.copy = function() { logW("cc.Animation.copy", "cc.Animation.clone"); return cc.Animation.prototype.clone.apply(this, arguments); }; cc.Node.prototype.nodeToWorldTransform = function() { logW("cc.Node.nodeToWorldTransform", "cc.Node.getNodeToWorldTransform"); return cc.Node.prototype.getNodeToWorldTransform.apply(this, arguments); }; cc.Node.prototype.nodeToParentTransform = function() { logW("cc.Node.nodeToParentTransform", "cc.Node.getNodeToParentTransform"); return cc.Node.prototype.getNodeToParentTransform.apply(this, arguments); }; cc.Node.prototype.worldToNodeTransform = function() { logW("cc.Node.worldToNodeTransform", "cc.Node.getWorldToNodeTransform"); return cc.Node.prototype.getWorldToNodeTransform.apply(this, arguments); }; cc.Node.prototype.parentToNodeTransform = function() { logW("cc.Node.parentToNodeTransform", "cc.Node.getParentToNodeTransform"); return cc.Node.prototype.getParentToNodeTransform.apply(this, arguments); }; cc.Node.prototype.numberOfRunningActions = function() { logW("cc.Node.numberOfRunningActions", "cc.Node.getNumberOfRunningActions"); return cc.Node.prototype.getNumberOfRunningActions.apply(this, arguments); }; cc.Node.prototype.numberOfRunningActionsInTarget = function() { logW("cc.Node.numberOfRunningActionsInTarget", "cc.Node.getNumberOfRunningActionsInTarget"); return cc.Node.prototype.getNumberOfRunningActionsInTarget.apply(this, arguments); }; cc.TMXTiledMap.prototype.propertiesForGID = function() { logW("cc.TMXTiledMap.propertiesForGID", "cc.TMXTiledMap.getPropertiesForGID"); return cc.TMXTiledMap.prototype.getPropertiesForGID.apply(this, arguments); }; cc.Menu.prototype.setHandlerPriority = function() { cc.log("cc.Menu.setHandlerPriority was deprecated, 3.0 uses new event dispatcher to dispatch touch event based on draw order, so setHandlerPriority is not needed now."); }; cc.Layer.prototype.setKeypadEnabled = function() { logW("cc.Layer.setKeypadEnabled", "cc.Layer.setKeyboardEnabled"); return cc.Layer.prototype.setKeyboardEnabled.apply(this, arguments); }; cc.Layer.prototype.isKeypadEnabled = function() { logW("cc.Layer.isKeypadEnabled", "cc.Layer.isKeyboardEnabled"); return cc.Layer.prototype.isKeyboardEnabled.apply(this, arguments); }; cc.registerTargettedDelegate = function() { logW("cc.registerTargettedDelegate", "cc.registerTargetedDelegate"); return cc.registerTargetedDelegate.apply(this, arguments); }; })(); ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_opengl.js ================================================ /* OpenGL ES 2.0 / WebGL helper functions */ /* * According to the WebGL specification ( For further info see:s http://www.khronos.org/registry/webgl/specs/latest/webgl.idl ), * the API should work with objects like WebGLTexture, WebGLBuffer, WebGLRenderBuffer, WebGLFramebuffer, WebGLProgram, WebGLShader. * OpenGL ES 2.0 doesn't have "objects" concepts: Instead it uses ids (GLints). So, these objects are emulated in this thin wrapper. */ var gl = gl || {}; // // Create functions // gl.createTexture = function() { // Returns a "WebGLTexture" object var ret = gl._createTexture(); return { texture_id:ret }; }; gl.createBuffer = function() { // Returns a "WebGLBuffer" object var ret = gl._createBuffer(); return { buffer_id:ret }; }; gl.createRenderbuffer = function() { // Returns a "WebGLRenderBuffer" object var ret = gl._createRenderuffer(); return { renderbuffer_id:ret}; }; gl.createFramebuffer = function() { // Returns a "WebGLFramebuffer" object var ret = gl._createFramebuffer(); return {framebuffer_id:ret}; }; gl.createProgram = function() { // Returns a "WebGLProgram" object var ret = gl._createProgram(); return {program_id:ret}; }; gl.createShader = function(shaderType) { // Returns a "WebGLShader" object var ret = gl._createShader(shaderType); return {shader_id:ret}; }; // // Delete Functions // gl.deleteTexture = function(texture) { var texture_id = texture.texture_id; // Accept numbers too. eg: gl.deleteTexture(0) if( typeof texture === 'number' ) texture_id = texture; gl._deleteTexture(texture_id); }; gl.deleteBuffer = function(bufer) { var buffer_id = buffer.buffer_id; // Accept numbers too. eg: gl.deleteBuffer(0) if( typeof buffer === 'number' ) buffer_id = buffer; gl._deleteBuffer(buffer_id); }; gl.deleteRenderbuffer = function(bufer) { var buffer_id = buffer.renderbuffer_id; // Accept numbers too. eg: gl.deleteRenderbuffer(0) if( typeof buffer === 'number' ) buffer_id = buffer; gl._deleteRenderbuffer(renderbuffer_id); }; gl.deleteFramebuffer = function(bufer) { var buffer_id = buffer.framebuffer_id; // Accept numbers too. eg: gl.deleteFramebuffer(0) if( typeof buffer === 'number' ) buffer_id = buffer; gl._deleteFramebuffer(buffer_id); }; gl.deleteProgram = function(program) { var program_id = program.program_id; // Accept numbers too. eg: gl.deleteShader(0) if( typeof program === 'number' ) program_id = program; gl._deleteProgram(program_id); }; gl.deleteShader = function(shader) { var shader_id = shader.shader_id; // Accept numbers too. eg: gl.deleteShader(0) if( typeof shader === 'number' ) shader_id = shader; gl._deleteShader(shader_id); }; // // Bind Related // // void bindTexture(GLenum target, WebGLTexture? texture); gl.bindTexture = function(target, texture) { var texture_id; // Accept numbers too. eg: gl.bindTexture(0) if( typeof texture === 'number' ) texture_id = texture; else if( texture === null ) texture_id = 0; else texture_id = texture.texture_id; gl._bindTexture( target, texture_id ); }; // void bindBuffer(GLenum target, WebGLBuffer? buffer); gl.bindBuffer = function(target, buffer) { var buffer_id; // Accept numbers too. eg: gl.bindBuffer(0) if( typeof buffer === 'number' ) buffer_id = buffer; else if( buffer === null ) buffer_id = 0; else buffer_id = buffer.buffer_id; gl._bindBuffer(target, buffer_id); }; // void bindRenderbuffer(GLenum target, WebGLRenderbuffer? renderbuffer); gl.bindRenderBuffer = function(target, buffer) { var buffer_id; // Accept numbers too. eg: gl.bindRenderbuffer(0) if( typeof buffer === 'number' ) buffer_id = buffer; else if( buffer === null ) buffer_id = 0; else buffer_id = buffer.buffer_id; gl._bindRenderbuffer(target, buffer_id); }; // void bindFramebuffer(GLenum target, WebGLFramebuffer? framebuffer); gl.bindFramebuffer = function(target, buffer) { var buffer_id; // Accept numbers too. eg: gl.bindFramebuffer(0) if( typeof buffer === 'number' ) buffer_id = buffer; else if( buffer === null ) buffer_id = 0; else buffer_id = buffer.buffer_id; gl._bindFramebuffer(target, buffer_id); }; // // Uniform related // // any getUniform(WebGLProgram? program, WebGLUniformLocation? location); gl.getUniform = function(program, location) { var program_id; var location_id; // Accept numbers too. eg: gl.bindFramebuffer(0) if( typeof program === 'number' ) program_id = program; else program_id = program.program_id; if( typeof location === 'number' ) location_id = location; else location_id = location.location_id; return gl._getUniform(program_id, location_id); }; // gl.uniformMatrix2fv = function(location, bool, matrix) { // gl._uniformMatrix2fv(program.program_id, bool, matrix); // }; // gl.uniformMatrix3fv = function(program, bool, matrix) { // gl._uniformMatrix3fv(program.program_id, bool, matrix); // }; // gl.uniformMatrix4fv = function(program, bool, matrix) { // gl._uniformMatrix4fv(program.program_id, bool, matrix); // }; // // Shader related // // void compileShader(WebGLShader? shader); gl.compileShader = function(shader) { gl._compileShader( shader.shader_id); }; // void shaderSource(WebGLShader? shader, DOMString source); gl.shaderSource = function(shader, source) { gl._shaderSource(shader.shader_id, source); }; // any getShaderParameter(WebGLShader? shader, GLenum pname); gl.getShaderParameter = function(shader, e) { return gl._getShaderParameter(shader.shader_id,e); }; // DOMString? getShaderInfoLog(WebGLShader? shader); gl.getShaderInfoLog = function(shader) { return gl._getShaderInfoLog(shader.shader_id); }; // // program related // // void attachShader(WebGLProgram? program, WebGLShader? shader); gl.attachShader = function(program, shader) { var program_id = program.program_id; // Accept numbers too. eg: gl.attachShader(17) if( typeof program === 'number' ) program_id = program; gl._attachShader(program_id, shader.shader_id); }; // void linkProgram(WebGLProgram? program); gl.linkProgram = function(program) { var program_id = program.program_id; // Accept numbers too. eg: gl.linkProgram(17) if( typeof program === 'number' ) program_id = program; gl._linkProgram(program_id); }; // any getProgramParameter(WebGLProgram? program, GLenum pname); gl.getProgramParameter = function(program, e) { var program_id = program.program_id; // Accept numbers too. eg: gl.getProgramParameter(17) if( typeof program === 'number' ) program_id = program; return gl._getProgramParameter(program_id, e); }; // void useProgram(WebGLProgram? program); gl.useProgram = function(program) { var program_id; // Accept numbers too. eg: gl.useProgram(17) if( typeof program === 'number' ) program_id = program; else program_id = program.program_id; gl._useProgram (program_id); }; // [WebGLHandlesContextLoss] GLint getAttribLocation(WebGLProgram? program, DOMString name); gl.getAttribLocation = function(program, name) { var program_id = program.program_id; // Accept numbers too. eg: gl.getAttribLocation(17) if( typeof program === 'number' ) program_id = program; return gl._getAttribLocation(program_id, name); }; // WebGLUniformLocation? getUniformLocation(WebGLProgram? program, DOMString name); gl.getUniformLocation = function(program, name) { var program_id = program.program_id; // Accept numbers too. eg: gl.getUniformLocation(17) if( typeof program === 'number' ) program_id = program; // XXX: it should return an object, not an integer return gl._getUniformLocation(program_id,name); }; // WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index); gl.getActiveAttrib = function(program, index) { var program_id = program.program_id; // Accept numbers too. eg: gl.getActiveAttrib(17) if( typeof program === 'number' ) program_id = program; return gl._getActiveAttrib(program_id, index); }; // WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index); gl.getActiveUniform = function(program, index) { var program_id = program.program_id; // Accept numbers too. eg: gl.getActiveUniform(17) if( typeof program === 'number' ) program_id = program; return gl._getActiveUniform(program_id, index); }; // sequence? getAttachedShaders(WebGLProgram? program); gl.getAttachedShaders = function(program) { var program_id = program.program_id; // Accept numbers too. eg: gl.getAttachedShaders(17) if( typeof program === 'number' ) program_id = program; return gl._getAttachedShaders(program_id); }; // // Texture functions // // XXX: Currently only the 1st one is supported // void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels); // void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, ImageData? pixels); // void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException // void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException // void texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException gl.texImage2D = function() { if( arguments.length != 9) throw "texImage2D: Unsupported number of parameters:" + arguments.length; gl._texImage2D.apply(this, arguments); }; // XXX: Currently only the 1st one is supported // void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView? pixels); // void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, ImageData? pixels); // void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException // void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException // void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException gl.texSubImage2D = function() { if( arguments.length != 9) throw "texImage2D: Unsupported number of parameters"; gl._texSubImage2D.apply(this, arguments); }; // // Extensions // // From the WebGL spec: // Returns an object if, and only if, name is an ASCII case-insensitive match [HTML] for one of the names returned from getSupportedExtensions; // otherwise, returns null. The object returned from getExtension contains any constants or functions provided by the extension. // A returned object may have no constants or functions if the extension does not define any, but a unique object must still be returned. // That object is used to indicate that the extension has been enabled. // XXX: The returned object must return the functions and constants. gl.getExtension = function(extension) { var extensions = gl.getSupportedExtensions(); if( extensions.indexOf(extension) > -1 ) return {}; return null; }; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_opengl_constants.js ================================================ /* * AUTOGENERATED FILE. DO NOT EDIT IT * Generated by "generate_jsb.py -c opengl_jsb.ini" on 2013-03-18 * Script version: v0.6 */ var gl = gl || {}; gl.GCCSO_SHADER_BINARY_FJ = 0x9260; gl._3DC_XY_AMD = 0x87fa; gl._3DC_X_AMD = 0x87f9; gl.ACTIVE_ATTRIBUTES = 0x8b89; gl.ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8b8a; gl.ACTIVE_PROGRAM_EXT = 0x8259; gl.ACTIVE_TEXTURE = 0x84e0; gl.ACTIVE_UNIFORMS = 0x8b86; gl.ACTIVE_UNIFORM_MAX_LENGTH = 0x8b87; gl.ALIASED_LINE_WIDTH_RANGE = 0x846e; gl.ALIASED_POINT_SIZE_RANGE = 0x846d; gl.ALL_COMPLETED_NV = 0x84f2; gl.ALL_SHADER_BITS_EXT = 0xffffffff; gl.ALPHA = 0x1906; gl.ALPHA16F_EXT = 0x881c; gl.ALPHA32F_EXT = 0x8816; gl.ALPHA8_EXT = 0x803c; gl.ALPHA8_OES = 0x803c; gl.ALPHA_BITS = 0xd55; gl.ALPHA_TEST_FUNC_QCOM = 0xbc1; gl.ALPHA_TEST_QCOM = 0xbc0; gl.ALPHA_TEST_REF_QCOM = 0xbc2; gl.ALREADY_SIGNALED_APPLE = 0x911a; gl.ALWAYS = 0x207; gl.AMD_compressed_3DC_texture = 0x1; gl.AMD_compressed_ATC_texture = 0x1; gl.AMD_performance_monitor = 0x1; gl.AMD_program_binary_Z400 = 0x1; gl.ANGLE_depth_texture = 0x1; gl.ANGLE_framebuffer_blit = 0x1; gl.ANGLE_framebuffer_multisample = 0x1; gl.ANGLE_instanced_arrays = 0x1; gl.ANGLE_pack_reverse_row_order = 0x1; gl.ANGLE_program_binary = 0x1; gl.ANGLE_texture_compression_dxt3 = 0x1; gl.ANGLE_texture_compression_dxt5 = 0x1; gl.ANGLE_texture_usage = 0x1; gl.ANGLE_translated_shader_source = 0x1; gl.ANY_SAMPLES_PASSED_CONSERVATIVE_EXT = 0x8d6a; gl.ANY_SAMPLES_PASSED_EXT = 0x8c2f; gl.APPLE_copy_texture_levels = 0x1; gl.APPLE_framebuffer_multisample = 0x1; gl.APPLE_rgb_422 = 0x1; gl.APPLE_sync = 0x1; gl.APPLE_texture_format_BGRA8888 = 0x1; gl.APPLE_texture_max_level = 0x1; gl.ARM_mali_program_binary = 0x1; gl.ARM_mali_shader_binary = 0x1; gl.ARM_rgba8 = 0x1; gl.ARRAY_BUFFER = 0x8892; gl.ARRAY_BUFFER_BINDING = 0x8894; gl.ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8c93; gl.ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87ee; gl.ATC_RGB_AMD = 0x8c92; gl.ATTACHED_SHADERS = 0x8b85; gl.BACK = 0x405; gl.BGRA8_EXT = 0x93a1; gl.BGRA_EXT = 0x80e1; gl.BGRA_IMG = 0x80e1; gl.BINNING_CONTROL_HINT_QCOM = 0x8fb0; gl.BLEND = 0xbe2; gl.BLEND_COLOR = 0x8005; gl.BLEND_DST_ALPHA = 0x80ca; gl.BLEND_DST_RGB = 0x80c8; gl.BLEND_EQUATION = 0x8009; gl.BLEND_EQUATION_ALPHA = 0x883d; gl.BLEND_EQUATION_RGB = 0x8009; gl.BLEND_SRC_ALPHA = 0x80cb; gl.BLEND_SRC_RGB = 0x80c9; gl.BLUE_BITS = 0xd54; gl.BOOL = 0x8b56; gl.BOOL_VEC2 = 0x8b57; gl.BOOL_VEC3 = 0x8b58; gl.BOOL_VEC4 = 0x8b59; gl.BUFFER = 0x82e0; gl.BUFFER_ACCESS_OES = 0x88bb; gl.BUFFER_MAPPED_OES = 0x88bc; gl.BUFFER_MAP_POINTER_OES = 0x88bd; gl.BUFFER_OBJECT_EXT = 0x9151; gl.BUFFER_SIZE = 0x8764; gl.BUFFER_USAGE = 0x8765; gl.BYTE = 0x1400; gl.CCW = 0x901; gl.CLAMP_TO_BORDER_NV = 0x812d; gl.CLAMP_TO_EDGE = 0x812f; gl.COLOR_ATTACHMENT0 = 0x8ce0; gl.COLOR_ATTACHMENT0_NV = 0x8ce0; gl.COLOR_ATTACHMENT10_NV = 0x8cea; gl.COLOR_ATTACHMENT11_NV = 0x8ceb; gl.COLOR_ATTACHMENT12_NV = 0x8cec; gl.COLOR_ATTACHMENT13_NV = 0x8ced; gl.COLOR_ATTACHMENT14_NV = 0x8cee; gl.COLOR_ATTACHMENT15_NV = 0x8cef; gl.COLOR_ATTACHMENT1_NV = 0x8ce1; gl.COLOR_ATTACHMENT2_NV = 0x8ce2; gl.COLOR_ATTACHMENT3_NV = 0x8ce3; gl.COLOR_ATTACHMENT4_NV = 0x8ce4; gl.COLOR_ATTACHMENT5_NV = 0x8ce5; gl.COLOR_ATTACHMENT6_NV = 0x8ce6; gl.COLOR_ATTACHMENT7_NV = 0x8ce7; gl.COLOR_ATTACHMENT8_NV = 0x8ce8; gl.COLOR_ATTACHMENT9_NV = 0x8ce9; gl.COLOR_ATTACHMENT_EXT = 0x90f0; gl.COLOR_BUFFER_BIT = 0x4000; gl.COLOR_BUFFER_BIT0_QCOM = 0x1; gl.COLOR_BUFFER_BIT1_QCOM = 0x2; gl.COLOR_BUFFER_BIT2_QCOM = 0x4; gl.COLOR_BUFFER_BIT3_QCOM = 0x8; gl.COLOR_BUFFER_BIT4_QCOM = 0x10; gl.COLOR_BUFFER_BIT5_QCOM = 0x20; gl.COLOR_BUFFER_BIT6_QCOM = 0x40; gl.COLOR_BUFFER_BIT7_QCOM = 0x80; gl.COLOR_CLEAR_VALUE = 0xc22; gl.COLOR_EXT = 0x1800; gl.COLOR_WRITEMASK = 0xc23; gl.COMPARE_REF_TO_TEXTURE_EXT = 0x884e; gl.COMPILE_STATUS = 0x8b81; gl.COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93bb; gl.COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93b8; gl.COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93b9; gl.COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93ba; gl.COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93bc; gl.COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93bd; gl.COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93b0; gl.COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93b1; gl.COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93b2; gl.COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93b3; gl.COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93b4; gl.COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93b5; gl.COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93b6; gl.COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93b7; gl.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8c03; gl.COMPRESSED_RGBA_PVRTC_2BPPV2_IMG = 0x9137; gl.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8c02; gl.COMPRESSED_RGBA_PVRTC_4BPPV2_IMG = 0x9138; gl.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83f1; gl.COMPRESSED_RGBA_S3TC_DXT3_ANGLE = 0x83f2; gl.COMPRESSED_RGBA_S3TC_DXT5_ANGLE = 0x83f3; gl.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8c01; gl.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8c00; gl.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83f0; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93db; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93d8; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93d9; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93da; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93dc; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93dd; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93d0; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93d1; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93d2; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93d3; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93d4; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93d5; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93d6; gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93d7; gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV = 0x8c4d; gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV = 0x8c4e; gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV = 0x8c4f; gl.COMPRESSED_SRGB_S3TC_DXT1_NV = 0x8c4c; gl.COMPRESSED_TEXTURE_FORMATS = 0x86a3; gl.CONDITION_SATISFIED_APPLE = 0x911c; gl.CONSTANT_ALPHA = 0x8003; gl.CONSTANT_COLOR = 0x8001; gl.CONTEXT_FLAG_DEBUG_BIT = 0x2; gl.CONTEXT_ROBUST_ACCESS_EXT = 0x90f3; gl.COUNTER_RANGE_AMD = 0x8bc1; gl.COUNTER_TYPE_AMD = 0x8bc0; gl.COVERAGE_ALL_FRAGMENTS_NV = 0x8ed5; gl.COVERAGE_ATTACHMENT_NV = 0x8ed2; gl.COVERAGE_AUTOMATIC_NV = 0x8ed7; gl.COVERAGE_BUFFERS_NV = 0x8ed3; gl.COVERAGE_BUFFER_BIT_NV = 0x8000; gl.COVERAGE_COMPONENT4_NV = 0x8ed1; gl.COVERAGE_COMPONENT_NV = 0x8ed0; gl.COVERAGE_EDGE_FRAGMENTS_NV = 0x8ed6; gl.COVERAGE_SAMPLES_NV = 0x8ed4; gl.CPU_OPTIMIZED_QCOM = 0x8fb1; gl.CULL_FACE = 0xb44; gl.CULL_FACE_MODE = 0xb45; gl.CURRENT_PROGRAM = 0x8b8d; gl.CURRENT_QUERY_EXT = 0x8865; gl.CURRENT_VERTEX_ATTRIB = 0x8626; gl.CW = 0x900; gl.DEBUG_CALLBACK_FUNCTION = 0x8244; gl.DEBUG_CALLBACK_USER_PARAM = 0x8245; gl.DEBUG_GROUP_STACK_DEPTH = 0x826d; gl.DEBUG_LOGGED_MESSAGES = 0x9145; gl.DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243; gl.DEBUG_OUTPUT = 0x92e0; gl.DEBUG_OUTPUT_SYNCHRONOUS = 0x8242; gl.DEBUG_SEVERITY_HIGH = 0x9146; gl.DEBUG_SEVERITY_LOW = 0x9148; gl.DEBUG_SEVERITY_MEDIUM = 0x9147; gl.DEBUG_SEVERITY_NOTIFICATION = 0x826b; gl.DEBUG_SOURCE_API = 0x8246; gl.DEBUG_SOURCE_APPLICATION = 0x824a; gl.DEBUG_SOURCE_OTHER = 0x824b; gl.DEBUG_SOURCE_SHADER_COMPILER = 0x8248; gl.DEBUG_SOURCE_THIRD_PARTY = 0x8249; gl.DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247; gl.DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824d; gl.DEBUG_TYPE_ERROR = 0x824c; gl.DEBUG_TYPE_MARKER = 0x8268; gl.DEBUG_TYPE_OTHER = 0x8251; gl.DEBUG_TYPE_PERFORMANCE = 0x8250; gl.DEBUG_TYPE_POP_GROUP = 0x826a; gl.DEBUG_TYPE_PORTABILITY = 0x824f; gl.DEBUG_TYPE_PUSH_GROUP = 0x8269; gl.DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824e; gl.DECR = 0x1e03; gl.DECR_WRAP = 0x8508; gl.DELETE_STATUS = 0x8b80; gl.DEPTH24_STENCIL8_OES = 0x88f0; gl.DEPTH_ATTACHMENT = 0x8d00; gl.DEPTH_BITS = 0xd56; gl.DEPTH_BUFFER_BIT = 0x100; gl.DEPTH_BUFFER_BIT0_QCOM = 0x100; gl.DEPTH_BUFFER_BIT1_QCOM = 0x200; gl.DEPTH_BUFFER_BIT2_QCOM = 0x400; gl.DEPTH_BUFFER_BIT3_QCOM = 0x800; gl.DEPTH_BUFFER_BIT4_QCOM = 0x1000; gl.DEPTH_BUFFER_BIT5_QCOM = 0x2000; gl.DEPTH_BUFFER_BIT6_QCOM = 0x4000; gl.DEPTH_BUFFER_BIT7_QCOM = 0x8000; gl.DEPTH_CLEAR_VALUE = 0xb73; gl.DEPTH_COMPONENT = 0x1902; gl.DEPTH_COMPONENT16 = 0x81a5; gl.DEPTH_COMPONENT16_NONLINEAR_NV = 0x8e2c; gl.DEPTH_COMPONENT16_OES = 0x81a5; gl.DEPTH_COMPONENT24_OES = 0x81a6; gl.DEPTH_COMPONENT32_OES = 0x81a7; gl.DEPTH_EXT = 0x1801; gl.DEPTH_FUNC = 0xb74; gl.DEPTH_RANGE = 0xb70; gl.DEPTH_STENCIL_OES = 0x84f9; gl.DEPTH_TEST = 0xb71; gl.DEPTH_WRITEMASK = 0xb72; gl.DITHER = 0xbd0; gl.DMP_shader_binary = 0x1; gl.DONT_CARE = 0x1100; gl.DRAW_BUFFER0_NV = 0x8825; gl.DRAW_BUFFER10_NV = 0x882f; gl.DRAW_BUFFER11_NV = 0x8830; gl.DRAW_BUFFER12_NV = 0x8831; gl.DRAW_BUFFER13_NV = 0x8832; gl.DRAW_BUFFER14_NV = 0x8833; gl.DRAW_BUFFER15_NV = 0x8834; gl.DRAW_BUFFER1_NV = 0x8826; gl.DRAW_BUFFER2_NV = 0x8827; gl.DRAW_BUFFER3_NV = 0x8828; gl.DRAW_BUFFER4_NV = 0x8829; gl.DRAW_BUFFER5_NV = 0x882a; gl.DRAW_BUFFER6_NV = 0x882b; gl.DRAW_BUFFER7_NV = 0x882c; gl.DRAW_BUFFER8_NV = 0x882d; gl.DRAW_BUFFER9_NV = 0x882e; gl.DRAW_BUFFER_EXT = 0xc01; gl.DRAW_FRAMEBUFFER_ANGLE = 0x8ca9; gl.DRAW_FRAMEBUFFER_APPLE = 0x8ca9; gl.DRAW_FRAMEBUFFER_BINDING_ANGLE = 0x8ca6; gl.DRAW_FRAMEBUFFER_BINDING_APPLE = 0x8ca6; gl.DRAW_FRAMEBUFFER_BINDING_NV = 0x8ca6; gl.DRAW_FRAMEBUFFER_NV = 0x8ca9; gl.DST_ALPHA = 0x304; gl.DST_COLOR = 0x306; gl.DYNAMIC_DRAW = 0x88e8; gl.ELEMENT_ARRAY_BUFFER = 0x8893; gl.ELEMENT_ARRAY_BUFFER_BINDING = 0x8895; gl.EQUAL = 0x202; gl.ES_VERSION_2_0 = 0x1; gl.ETC1_RGB8_OES = 0x8d64; gl.ETC1_SRGB8_NV = 0x88ee; gl.EXTENSIONS = 0x1f03; gl.EXT_blend_minmax = 0x1; gl.EXT_color_buffer_half_float = 0x1; gl.EXT_debug_label = 0x1; gl.EXT_debug_marker = 0x1; gl.EXT_discard_framebuffer = 0x1; gl.EXT_map_buffer_range = 0x1; gl.EXT_multi_draw_arrays = 0x1; gl.EXT_multisampled_render_to_texture = 0x1; gl.EXT_multiview_draw_buffers = 0x1; gl.EXT_occlusion_query_boolean = 0x1; gl.EXT_read_format_bgra = 0x1; gl.EXT_robustness = 0x1; gl.EXT_sRGB = 0x1; gl.EXT_separate_shader_objects = 0x1; gl.EXT_shader_framebuffer_fetch = 0x1; gl.EXT_shader_texture_lod = 0x1; gl.EXT_shadow_samplers = 0x1; gl.EXT_texture_compression_dxt1 = 0x1; gl.EXT_texture_filter_anisotropic = 0x1; gl.EXT_texture_format_BGRA8888 = 0x1; gl.EXT_texture_rg = 0x1; gl.EXT_texture_storage = 0x1; gl.EXT_texture_type_2_10_10_10_REV = 0x1; gl.EXT_unpack_subimage = 0x1; gl.FALSE = 0x0; gl.FASTEST = 0x1101; gl.FENCE_CONDITION_NV = 0x84f4; gl.FENCE_STATUS_NV = 0x84f3; gl.FIXED = 0x140c; gl.FJ_shader_binary_GCCSO = 0x1; gl.FLOAT = 0x1406; gl.FLOAT_MAT2 = 0x8b5a; gl.FLOAT_MAT3 = 0x8b5b; gl.FLOAT_MAT4 = 0x8b5c; gl.FLOAT_VEC2 = 0x8b50; gl.FLOAT_VEC3 = 0x8b51; gl.FLOAT_VEC4 = 0x8b52; gl.FRAGMENT_SHADER = 0x8b30; gl.FRAGMENT_SHADER_BIT_EXT = 0x2; gl.FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8b8b; gl.FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT = 0x8a52; gl.FRAMEBUFFER = 0x8d40; gl.FRAMEBUFFER_ATTACHMENT_ANGLE = 0x93a3; gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT = 0x8210; gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT = 0x8211; gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8cd1; gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8cd0; gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES = 0x8cd4; gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8cd3; gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8cd2; gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT = 0x8d6c; gl.FRAMEBUFFER_BINDING = 0x8ca6; gl.FRAMEBUFFER_COMPLETE = 0x8cd5; gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8cd6; gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8cd9; gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8cd7; gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE = 0x8d56; gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE = 0x8d56; gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT = 0x8d56; gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG = 0x9134; gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV = 0x8d56; gl.FRAMEBUFFER_UNDEFINED_OES = 0x8219; gl.FRAMEBUFFER_UNSUPPORTED = 0x8cdd; gl.FRONT = 0x404; gl.FRONT_AND_BACK = 0x408; gl.FRONT_FACE = 0xb46; gl.FUNC_ADD = 0x8006; gl.FUNC_REVERSE_SUBTRACT = 0x800b; gl.FUNC_SUBTRACT = 0x800a; gl.GENERATE_MIPMAP_HINT = 0x8192; gl.GEQUAL = 0x206; gl.GPU_OPTIMIZED_QCOM = 0x8fb2; gl.GREATER = 0x204; gl.GREEN_BITS = 0xd53; gl.GUILTY_CONTEXT_RESET_EXT = 0x8253; gl.HALF_FLOAT_OES = 0x8d61; gl.HIGH_FLOAT = 0x8df2; gl.HIGH_INT = 0x8df5; gl.IMG_multisampled_render_to_texture = 0x1; gl.IMG_program_binary = 0x1; gl.IMG_read_format = 0x1; gl.IMG_shader_binary = 0x1; gl.IMG_texture_compression_pvrtc = 0x1; gl.IMG_texture_compression_pvrtc2 = 0x1; gl.IMPLEMENTATION_COLOR_READ_FORMAT = 0x8b9b; gl.IMPLEMENTATION_COLOR_READ_TYPE = 0x8b9a; gl.INCR = 0x1e02; gl.INCR_WRAP = 0x8507; gl.INFO_LOG_LENGTH = 0x8b84; gl.INNOCENT_CONTEXT_RESET_EXT = 0x8254; gl.INT = 0x1404; gl.INT_10_10_10_2_OES = 0x8df7; gl.INT_VEC2 = 0x8b53; gl.INT_VEC3 = 0x8b54; gl.INT_VEC4 = 0x8b55; gl.INVALID_ENUM = 0x500; gl.INVALID_FRAMEBUFFER_OPERATION = 0x506; gl.INVALID_OPERATION = 0x502; gl.INVALID_VALUE = 0x501; gl.INVERT = 0x150a; gl.KEEP = 0x1e00; gl.KHR_debug = 0x1; gl.KHR_texture_compression_astc_ldr = 0x1; gl.LEQUAL = 0x203; gl.LESS = 0x201; gl.LINEAR = 0x2601; gl.LINEAR_MIPMAP_LINEAR = 0x2703; gl.LINEAR_MIPMAP_NEAREST = 0x2701; gl.LINES = 0x1; gl.LINE_LOOP = 0x2; gl.LINE_STRIP = 0x3; gl.LINE_WIDTH = 0xb21; gl.LINK_STATUS = 0x8b82; gl.LOSE_CONTEXT_ON_RESET_EXT = 0x8252; gl.LOW_FLOAT = 0x8df0; gl.LOW_INT = 0x8df3; gl.LUMINANCE = 0x1909; gl.LUMINANCE16F_EXT = 0x881e; gl.LUMINANCE32F_EXT = 0x8818; gl.LUMINANCE4_ALPHA4_OES = 0x8043; gl.LUMINANCE8_ALPHA8_EXT = 0x8045; gl.LUMINANCE8_ALPHA8_OES = 0x8045; gl.LUMINANCE8_EXT = 0x8040; gl.LUMINANCE8_OES = 0x8040; gl.LUMINANCE_ALPHA = 0x190a; gl.LUMINANCE_ALPHA16F_EXT = 0x881f; gl.LUMINANCE_ALPHA32F_EXT = 0x8819; gl.MALI_PROGRAM_BINARY_ARM = 0x8f61; gl.MALI_SHADER_BINARY_ARM = 0x8f60; gl.MAP_FLUSH_EXPLICIT_BIT_EXT = 0x10; gl.MAP_INVALIDATE_BUFFER_BIT_EXT = 0x8; gl.MAP_INVALIDATE_RANGE_BIT_EXT = 0x4; gl.MAP_READ_BIT_EXT = 0x1; gl.MAP_UNSYNCHRONIZED_BIT_EXT = 0x20; gl.MAP_WRITE_BIT_EXT = 0x2; gl.MAX_3D_TEXTURE_SIZE_OES = 0x8073; gl.MAX_COLOR_ATTACHMENTS_NV = 0x8cdf; gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8b4d; gl.MAX_CUBE_MAP_TEXTURE_SIZE = 0x851c; gl.MAX_DEBUG_GROUP_STACK_DEPTH = 0x826c; gl.MAX_DEBUG_LOGGED_MESSAGES = 0x9144; gl.MAX_DEBUG_MESSAGE_LENGTH = 0x9143; gl.MAX_DRAW_BUFFERS_NV = 0x8824; gl.MAX_EXT = 0x8008; gl.MAX_FRAGMENT_UNIFORM_VECTORS = 0x8dfd; gl.MAX_LABEL_LENGTH = 0x82e8; gl.MAX_MULTIVIEW_BUFFERS_EXT = 0x90f2; gl.MAX_RENDERBUFFER_SIZE = 0x84e8; gl.MAX_SAMPLES_ANGLE = 0x8d57; gl.MAX_SAMPLES_APPLE = 0x8d57; gl.MAX_SAMPLES_EXT = 0x8d57; gl.MAX_SAMPLES_IMG = 0x9135; gl.MAX_SAMPLES_NV = 0x8d57; gl.MAX_SERVER_WAIT_TIMEOUT_APPLE = 0x9111; gl.MAX_TEXTURE_IMAGE_UNITS = 0x8872; gl.MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84ff; gl.MAX_TEXTURE_SIZE = 0xd33; gl.MAX_VARYING_VECTORS = 0x8dfc; gl.MAX_VERTEX_ATTRIBS = 0x8869; gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8b4c; gl.MAX_VERTEX_UNIFORM_VECTORS = 0x8dfb; gl.MAX_VIEWPORT_DIMS = 0xd3a; gl.MEDIUM_FLOAT = 0x8df1; gl.MEDIUM_INT = 0x8df4; gl.MIN_EXT = 0x8007; gl.MIRRORED_REPEAT = 0x8370; gl.MULTISAMPLE_BUFFER_BIT0_QCOM = 0x1000000; gl.MULTISAMPLE_BUFFER_BIT1_QCOM = 0x2000000; gl.MULTISAMPLE_BUFFER_BIT2_QCOM = 0x4000000; gl.MULTISAMPLE_BUFFER_BIT3_QCOM = 0x8000000; gl.MULTISAMPLE_BUFFER_BIT4_QCOM = 0x10000000; gl.MULTISAMPLE_BUFFER_BIT5_QCOM = 0x20000000; gl.MULTISAMPLE_BUFFER_BIT6_QCOM = 0x40000000; gl.MULTISAMPLE_BUFFER_BIT7_QCOM = 0x80000000; gl.MULTIVIEW_EXT = 0x90f1; gl.NEAREST = 0x2600; gl.NEAREST_MIPMAP_LINEAR = 0x2702; gl.NEAREST_MIPMAP_NEAREST = 0x2700; gl.NEVER = 0x200; gl.NICEST = 0x1102; gl.NONE = 0x0; gl.NOTEQUAL = 0x205; gl.NO_ERROR = 0x0; gl.NO_RESET_NOTIFICATION_EXT = 0x8261; gl.NUM_COMPRESSED_TEXTURE_FORMATS = 0x86a2; gl.NUM_PROGRAM_BINARY_FORMATS_OES = 0x87fe; gl.NUM_SHADER_BINARY_FORMATS = 0x8df9; gl.NV_coverage_sample = 0x1; gl.NV_depth_nonlinear = 0x1; gl.NV_draw_buffers = 0x1; gl.NV_draw_instanced = 0x1; gl.NV_fbo_color_attachments = 0x1; gl.NV_fence = 0x1; gl.NV_framebuffer_blit = 0x1; gl.NV_framebuffer_multisample = 0x1; gl.NV_generate_mipmap_sRGB = 0x1; gl.NV_instanced_arrays = 0x1; gl.NV_read_buffer = 0x1; gl.NV_read_buffer_front = 0x1; gl.NV_read_depth = 0x1; gl.NV_read_depth_stencil = 0x1; gl.NV_read_stencil = 0x1; gl.NV_sRGB_formats = 0x1; gl.NV_shadow_samplers_array = 0x1; gl.NV_shadow_samplers_cube = 0x1; gl.NV_texture_border_clamp = 0x1; gl.NV_texture_compression_s3tc_update = 0x1; gl.NV_texture_npot_2D_mipmap = 0x1; gl.OBJECT_TYPE_APPLE = 0x9112; gl.OES_EGL_image = 0x1; gl.OES_EGL_image_external = 0x1; gl.OES_compressed_ETC1_RGB8_texture = 0x1; gl.OES_compressed_paletted_texture = 0x1; gl.OES_depth24 = 0x1; gl.OES_depth32 = 0x1; gl.OES_depth_texture = 0x1; gl.OES_element_index_uint = 0x1; gl.OES_fbo_render_mipmap = 0x1; gl.OES_fragment_precision_high = 0x1; gl.OES_get_program_binary = 0x1; gl.OES_mapbuffer = 0x1; gl.OES_packed_depth_stencil = 0x1; gl.OES_required_internalformat = 0x1; gl.OES_rgb8_rgba8 = 0x1; gl.OES_standard_derivatives = 0x1; gl.OES_stencil1 = 0x1; gl.OES_stencil4 = 0x1; gl.OES_surfaceless_context = 0x1; gl.OES_texture_3D = 0x1; gl.OES_texture_float = 0x1; gl.OES_texture_float_linear = 0x1; gl.OES_texture_half_float = 0x1; gl.OES_texture_half_float_linear = 0x1; gl.OES_texture_npot = 0x1; gl.OES_vertex_array_object = 0x1; gl.OES_vertex_half_float = 0x1; gl.OES_vertex_type_10_10_10_2 = 0x1; gl.ONE = 0x1; gl.ONE_MINUS_CONSTANT_ALPHA = 0x8004; gl.ONE_MINUS_CONSTANT_COLOR = 0x8002; gl.ONE_MINUS_DST_ALPHA = 0x305; gl.ONE_MINUS_DST_COLOR = 0x307; gl.ONE_MINUS_SRC_ALPHA = 0x303; gl.ONE_MINUS_SRC_COLOR = 0x301; gl.OUT_OF_MEMORY = 0x505; gl.PACK_ALIGNMENT = 0xd05; gl.PACK_REVERSE_ROW_ORDER_ANGLE = 0x93a4; gl.PALETTE4_R5_G6_B5_OES = 0x8b92; gl.PALETTE4_RGB5_A1_OES = 0x8b94; gl.PALETTE4_RGB8_OES = 0x8b90; gl.PALETTE4_RGBA4_OES = 0x8b93; gl.PALETTE4_RGBA8_OES = 0x8b91; gl.PALETTE8_R5_G6_B5_OES = 0x8b97; gl.PALETTE8_RGB5_A1_OES = 0x8b99; gl.PALETTE8_RGB8_OES = 0x8b95; gl.PALETTE8_RGBA4_OES = 0x8b98; gl.PALETTE8_RGBA8_OES = 0x8b96; gl.PERCENTAGE_AMD = 0x8bc3; gl.PERFMON_GLOBAL_MODE_QCOM = 0x8fa0; gl.PERFMON_RESULT_AMD = 0x8bc6; gl.PERFMON_RESULT_AVAILABLE_AMD = 0x8bc4; gl.PERFMON_RESULT_SIZE_AMD = 0x8bc5; gl.POINTS = 0x0; gl.POLYGON_OFFSET_FACTOR = 0x8038; gl.POLYGON_OFFSET_FILL = 0x8037; gl.POLYGON_OFFSET_UNITS = 0x2a00; gl.PROGRAM = 0x82e2; gl.PROGRAM_BINARY_ANGLE = 0x93a6; gl.PROGRAM_BINARY_FORMATS_OES = 0x87ff; gl.PROGRAM_BINARY_LENGTH_OES = 0x8741; gl.PROGRAM_OBJECT_EXT = 0x8b40; gl.PROGRAM_PIPELINE_BINDING_EXT = 0x825a; gl.PROGRAM_PIPELINE_OBJECT_EXT = 0x8a4f; gl.PROGRAM_SEPARABLE_EXT = 0x8258; gl.QCOM_alpha_test = 0x1; gl.QCOM_binning_control = 0x1; gl.QCOM_driver_control = 0x1; gl.QCOM_extended_get = 0x1; gl.QCOM_extended_get2 = 0x1; gl.QCOM_perfmon_global_mode = 0x1; gl.QCOM_tiled_rendering = 0x1; gl.QCOM_writeonly_rendering = 0x1; gl.QUERY = 0x82e3; gl.QUERY_OBJECT_EXT = 0x9153; gl.QUERY_RESULT_AVAILABLE_EXT = 0x8867; gl.QUERY_RESULT_EXT = 0x8866; gl.R16F_EXT = 0x822d; gl.R32F_EXT = 0x822e; gl.R8_EXT = 0x8229; gl.READ_BUFFER_EXT = 0xc02; gl.READ_BUFFER_NV = 0xc02; gl.READ_FRAMEBUFFER_ANGLE = 0x8ca8; gl.READ_FRAMEBUFFER_APPLE = 0x8ca8; gl.READ_FRAMEBUFFER_BINDING_ANGLE = 0x8caa; gl.READ_FRAMEBUFFER_BINDING_APPLE = 0x8caa; gl.READ_FRAMEBUFFER_BINDING_NV = 0x8caa; gl.READ_FRAMEBUFFER_NV = 0x8ca8; gl.RED_BITS = 0xd52; gl.RED_EXT = 0x1903; gl.RENDERBUFFER = 0x8d41; gl.RENDERBUFFER_ALPHA_SIZE = 0x8d53; gl.RENDERBUFFER_BINDING = 0x8ca7; gl.RENDERBUFFER_BLUE_SIZE = 0x8d52; gl.RENDERBUFFER_DEPTH_SIZE = 0x8d54; gl.RENDERBUFFER_GREEN_SIZE = 0x8d51; gl.RENDERBUFFER_HEIGHT = 0x8d43; gl.RENDERBUFFER_INTERNAL_FORMAT = 0x8d44; gl.RENDERBUFFER_RED_SIZE = 0x8d50; gl.RENDERBUFFER_SAMPLES_ANGLE = 0x8cab; gl.RENDERBUFFER_SAMPLES_APPLE = 0x8cab; gl.RENDERBUFFER_SAMPLES_EXT = 0x8cab; gl.RENDERBUFFER_SAMPLES_IMG = 0x9133; gl.RENDERBUFFER_SAMPLES_NV = 0x8cab; gl.RENDERBUFFER_STENCIL_SIZE = 0x8d55; gl.RENDERBUFFER_WIDTH = 0x8d42; gl.RENDERER = 0x1f01; gl.RENDER_DIRECT_TO_FRAMEBUFFER_QCOM = 0x8fb3; gl.REPEAT = 0x2901; gl.REPLACE = 0x1e01; gl.REQUIRED_TEXTURE_IMAGE_UNITS_OES = 0x8d68; gl.RESET_NOTIFICATION_STRATEGY_EXT = 0x8256; gl.RG16F_EXT = 0x822f; gl.RG32F_EXT = 0x8230; gl.RG8_EXT = 0x822b; gl.RGB = 0x1907; gl.RGB10_A2_EXT = 0x8059; gl.RGB10_EXT = 0x8052; gl.RGB16F_EXT = 0x881b; gl.RGB32F_EXT = 0x8815; gl.RGB565 = 0x8d62; gl.RGB565_OES = 0x8d62; gl.RGB5_A1 = 0x8057; gl.RGB5_A1_OES = 0x8057; gl.RGB8_OES = 0x8051; gl.RGBA = 0x1908; gl.RGBA16F_EXT = 0x881a; gl.RGBA32F_EXT = 0x8814; gl.RGBA4 = 0x8056; gl.RGBA4_OES = 0x8056; gl.RGBA8_OES = 0x8058; gl.RGB_422_APPLE = 0x8a1f; gl.RG_EXT = 0x8227; gl.SAMPLER = 0x82e6; gl.SAMPLER_2D = 0x8b5e; gl.SAMPLER_2D_ARRAY_SHADOW_NV = 0x8dc4; gl.SAMPLER_2D_SHADOW_EXT = 0x8b62; gl.SAMPLER_3D_OES = 0x8b5f; gl.SAMPLER_CUBE = 0x8b60; gl.SAMPLER_CUBE_SHADOW_NV = 0x8dc5; gl.SAMPLER_EXTERNAL_OES = 0x8d66; gl.SAMPLES = 0x80a9; gl.SAMPLE_ALPHA_TO_COVERAGE = 0x809e; gl.SAMPLE_BUFFERS = 0x80a8; gl.SAMPLE_COVERAGE = 0x80a0; gl.SAMPLE_COVERAGE_INVERT = 0x80ab; gl.SAMPLE_COVERAGE_VALUE = 0x80aa; gl.SCISSOR_BOX = 0xc10; gl.SCISSOR_TEST = 0xc11; gl.SGX_BINARY_IMG = 0x8c0a; gl.SGX_PROGRAM_BINARY_IMG = 0x9130; gl.SHADER = 0x82e1; gl.SHADER_BINARY_DMP = 0x9250; gl.SHADER_BINARY_FORMATS = 0x8df8; gl.SHADER_BINARY_VIV = 0x8fc4; gl.SHADER_COMPILER = 0x8dfa; gl.SHADER_OBJECT_EXT = 0x8b48; gl.SHADER_SOURCE_LENGTH = 0x8b88; gl.SHADER_TYPE = 0x8b4f; gl.SHADING_LANGUAGE_VERSION = 0x8b8c; gl.SHORT = 0x1402; gl.SIGNALED_APPLE = 0x9119; gl.SLUMINANCE8_ALPHA8_NV = 0x8c45; gl.SLUMINANCE8_NV = 0x8c47; gl.SLUMINANCE_ALPHA_NV = 0x8c44; gl.SLUMINANCE_NV = 0x8c46; gl.SRC_ALPHA = 0x302; gl.SRC_ALPHA_SATURATE = 0x308; gl.SRC_COLOR = 0x300; gl.SRGB8_ALPHA8_EXT = 0x8c43; gl.SRGB8_NV = 0x8c41; gl.SRGB_ALPHA_EXT = 0x8c42; gl.SRGB_EXT = 0x8c40; gl.STACK_OVERFLOW = 0x503; gl.STACK_UNDERFLOW = 0x504; gl.STATE_RESTORE = 0x8bdc; gl.STATIC_DRAW = 0x88e4; gl.STENCIL_ATTACHMENT = 0x8d20; gl.STENCIL_BACK_FAIL = 0x8801; gl.STENCIL_BACK_FUNC = 0x8800; gl.STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802; gl.STENCIL_BACK_PASS_DEPTH_PASS = 0x8803; gl.STENCIL_BACK_REF = 0x8ca3; gl.STENCIL_BACK_VALUE_MASK = 0x8ca4; gl.STENCIL_BACK_WRITEMASK = 0x8ca5; gl.STENCIL_BITS = 0xd57; gl.STENCIL_BUFFER_BIT = 0x400; gl.STENCIL_BUFFER_BIT0_QCOM = 0x10000; gl.STENCIL_BUFFER_BIT1_QCOM = 0x20000; gl.STENCIL_BUFFER_BIT2_QCOM = 0x40000; gl.STENCIL_BUFFER_BIT3_QCOM = 0x80000; gl.STENCIL_BUFFER_BIT4_QCOM = 0x100000; gl.STENCIL_BUFFER_BIT5_QCOM = 0x200000; gl.STENCIL_BUFFER_BIT6_QCOM = 0x400000; gl.STENCIL_BUFFER_BIT7_QCOM = 0x800000; gl.STENCIL_CLEAR_VALUE = 0xb91; gl.STENCIL_EXT = 0x1802; gl.STENCIL_FAIL = 0xb94; gl.STENCIL_FUNC = 0xb92; gl.STENCIL_INDEX1_OES = 0x8d46; gl.STENCIL_INDEX4_OES = 0x8d47; gl.STENCIL_INDEX8 = 0x8d48; gl.STENCIL_PASS_DEPTH_FAIL = 0xb95; gl.STENCIL_PASS_DEPTH_PASS = 0xb96; gl.STENCIL_REF = 0xb97; gl.STENCIL_TEST = 0xb90; gl.STENCIL_VALUE_MASK = 0xb93; gl.STENCIL_WRITEMASK = 0xb98; gl.STREAM_DRAW = 0x88e0; gl.SUBPIXEL_BITS = 0xd50; gl.SYNC_CONDITION_APPLE = 0x9113; gl.SYNC_FENCE_APPLE = 0x9116; gl.SYNC_FLAGS_APPLE = 0x9115; gl.SYNC_FLUSH_COMMANDS_BIT_APPLE = 0x1; gl.SYNC_GPU_COMMANDS_COMPLETE_APPLE = 0x9117; gl.SYNC_OBJECT_APPLE = 0x8a53; gl.SYNC_STATUS_APPLE = 0x9114; gl.TEXTURE = 0x1702; gl.TEXTURE0 = 0x84c0; gl.TEXTURE1 = 0x84c1; gl.TEXTURE10 = 0x84ca; gl.TEXTURE11 = 0x84cb; gl.TEXTURE12 = 0x84cc; gl.TEXTURE13 = 0x84cd; gl.TEXTURE14 = 0x84ce; gl.TEXTURE15 = 0x84cf; gl.TEXTURE16 = 0x84d0; gl.TEXTURE17 = 0x84d1; gl.TEXTURE18 = 0x84d2; gl.TEXTURE19 = 0x84d3; gl.TEXTURE2 = 0x84c2; gl.TEXTURE20 = 0x84d4; gl.TEXTURE21 = 0x84d5; gl.TEXTURE22 = 0x84d6; gl.TEXTURE23 = 0x84d7; gl.TEXTURE24 = 0x84d8; gl.TEXTURE25 = 0x84d9; gl.TEXTURE26 = 0x84da; gl.TEXTURE27 = 0x84db; gl.TEXTURE28 = 0x84dc; gl.TEXTURE29 = 0x84dd; gl.TEXTURE3 = 0x84c3; gl.TEXTURE30 = 0x84de; gl.TEXTURE31 = 0x84df; gl.TEXTURE4 = 0x84c4; gl.TEXTURE5 = 0x84c5; gl.TEXTURE6 = 0x84c6; gl.TEXTURE7 = 0x84c7; gl.TEXTURE8 = 0x84c8; gl.TEXTURE9 = 0x84c9; gl.TEXTURE_2D = 0xde1; gl.TEXTURE_3D_OES = 0x806f; gl.TEXTURE_BINDING_2D = 0x8069; gl.TEXTURE_BINDING_3D_OES = 0x806a; gl.TEXTURE_BINDING_CUBE_MAP = 0x8514; gl.TEXTURE_BINDING_EXTERNAL_OES = 0x8d67; gl.TEXTURE_BORDER_COLOR_NV = 0x1004; gl.TEXTURE_COMPARE_FUNC_EXT = 0x884d; gl.TEXTURE_COMPARE_MODE_EXT = 0x884c; gl.TEXTURE_CUBE_MAP = 0x8513; gl.TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516; gl.TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; gl.TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851a; gl.TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; gl.TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517; gl.TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; gl.TEXTURE_DEPTH_QCOM = 0x8bd4; gl.TEXTURE_EXTERNAL_OES = 0x8d65; gl.TEXTURE_FORMAT_QCOM = 0x8bd6; gl.TEXTURE_HEIGHT_QCOM = 0x8bd3; gl.TEXTURE_IMAGE_VALID_QCOM = 0x8bd8; gl.TEXTURE_IMMUTABLE_FORMAT_EXT = 0x912f; gl.TEXTURE_INTERNAL_FORMAT_QCOM = 0x8bd5; gl.TEXTURE_MAG_FILTER = 0x2800; gl.TEXTURE_MAX_ANISOTROPY_EXT = 0x84fe; gl.TEXTURE_MAX_LEVEL_APPLE = 0x813d; gl.TEXTURE_MIN_FILTER = 0x2801; gl.TEXTURE_NUM_LEVELS_QCOM = 0x8bd9; gl.TEXTURE_OBJECT_VALID_QCOM = 0x8bdb; gl.TEXTURE_SAMPLES_IMG = 0x9136; gl.TEXTURE_TARGET_QCOM = 0x8bda; gl.TEXTURE_TYPE_QCOM = 0x8bd7; gl.TEXTURE_USAGE_ANGLE = 0x93a2; gl.TEXTURE_WIDTH_QCOM = 0x8bd2; gl.TEXTURE_WRAP_R_OES = 0x8072; gl.TEXTURE_WRAP_S = 0x2802; gl.TEXTURE_WRAP_T = 0x2803; gl.TIMEOUT_EXPIRED_APPLE = 0x911b; gl.TIMEOUT_IGNORED_APPLE = 0xffffffffffffffff; gl.TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93a0; gl.TRIANGLES = 0x4; gl.TRIANGLE_FAN = 0x6; gl.TRIANGLE_STRIP = 0x5; gl.TRUE = 0x1; gl.UNKNOWN_CONTEXT_RESET_EXT = 0x8255; gl.UNPACK_ALIGNMENT = 0xcf5; gl.UNPACK_ROW_LENGTH = 0xcf2; gl.UNPACK_SKIP_PIXELS = 0xcf4; gl.UNPACK_SKIP_ROWS = 0xcf3; gl.UNSIGNALED_APPLE = 0x9118; gl.UNSIGNED_BYTE = 0x1401; gl.UNSIGNED_INT = 0x1405; gl.UNSIGNED_INT64_AMD = 0x8bc2; gl.UNSIGNED_INT_10_10_10_2_OES = 0x8df6; gl.UNSIGNED_INT_24_8_OES = 0x84fa; gl.UNSIGNED_INT_2_10_10_10_REV_EXT = 0x8368; gl.UNSIGNED_NORMALIZED_EXT = 0x8c17; gl.UNSIGNED_SHORT = 0x1403; gl.UNSIGNED_SHORT_1_5_5_5_REV_EXT = 0x8366; gl.UNSIGNED_SHORT_4_4_4_4 = 0x8033; gl.UNSIGNED_SHORT_4_4_4_4_REV_EXT = 0x8365; gl.UNSIGNED_SHORT_4_4_4_4_REV_IMG = 0x8365; gl.UNSIGNED_SHORT_5_5_5_1 = 0x8034; gl.UNSIGNED_SHORT_5_6_5 = 0x8363; gl.UNSIGNED_SHORT_8_8_APPLE = 0x85ba; gl.UNSIGNED_SHORT_8_8_REV_APPLE = 0x85bb; gl.VALIDATE_STATUS = 0x8b83; gl.VENDOR = 0x1f00; gl.VERSION = 0x1f02; gl.VERTEX_ARRAY_BINDING_OES = 0x85b5; gl.VERTEX_ARRAY_OBJECT_EXT = 0x9154; gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889f; gl.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88fe; gl.VERTEX_ATTRIB_ARRAY_DIVISOR_NV = 0x88fe; gl.VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622; gl.VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886a; gl.VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; gl.VERTEX_ATTRIB_ARRAY_SIZE = 0x8623; gl.VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624; gl.VERTEX_ATTRIB_ARRAY_TYPE = 0x8625; gl.VERTEX_SHADER = 0x8b31; gl.VERTEX_SHADER_BIT_EXT = 0x1; gl.VIEWPORT = 0xba2; gl.VIV_shader_binary = 0x1; gl.WAIT_FAILED_APPLE = 0x911d; gl.WRITEONLY_RENDERING_QCOM = 0x8823; gl.WRITE_ONLY_OES = 0x88b9; gl.Z400_BINARY_AMD = 0x8740; gl.ZERO = 0x0; ================================================ FILE: cocos2d/cocos/scripting/javascript/script/jsb_sys.js ================================================ // // sys properties // var sys = sys || {}; Object.defineProperties(sys, { "capabilities" : { get : function(){ var capabilities = {"opengl":true}; if( sys.platform == 'mobile' ) { capabilities["accelerometer"] = true; capabilities["touches"] = true; } else { // desktop capabilities["keyboard"] = true; capabilities["mouse"] = true; } return capabilities; }, enumerable : true, configurable : true }, "os" : { get : function(){ return __getOS(); }, enumerable : true, configurable : true }, "platform" : { get : function(){ return __getPlatform(); }, enumerable : true, configurable : true }, "version" : { get : function(){ return __getVersion(); }, enumerable : true, configurable : true } }); // Forces the garbage collector sys.garbageCollect = function() { __jsc__.garbageCollect(); }; // Dumps rooted objects sys.dumpRoot = function() { __jsc__.dumpRoot(); }; // restarts the JS VM sys.restartVM = function() { __restartVM(); }; ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/.cproject ================================================ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/.project ================================================ liblua org.eclipse.cdt.managedbuilder.core.genmakebuilder clean,full,incremental, org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder full,incremental, org.eclipse.cdt.core.cnature org.eclipse.cdt.core.ccnature org.eclipse.cdt.managedbuilder.core.managedBuildNature org.eclipse.cdt.managedbuilder.core.ScannerConfigNature lua 2 PARENT-1-PROJECT_LOC/lua tolua 2 PARENT-1-PROJECT_LOC/tolua ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos_lua_static LOCAL_MODULE_FILENAME := liblua LOCAL_SRC_FILES := CCLuaBridge.cpp \ CCLuaEngine.cpp \ CCLuaStack.cpp \ CCLuaValue.cpp \ Cocos2dxLuaLoader.cpp \ CCBProxy.cpp \ Lua_web_socket.cpp \ LuaOpengl.cpp \ LuaScriptHandlerMgr.cpp \ LuaBasicConversions.cpp \ LuaSkeletonAnimation.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_gui_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_spine_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_physics_auto.cpp \ lua_cocos2dx_manual.cpp \ lua_cocos2dx_extension_manual.cpp \ lua_cocos2dx_coco_studio_manual.cpp \ lua_cocos2dx_gui_manual.cpp \ lua_cocos2dx_spine_manual.cpp \ lua_cocos2dx_physics_manual.cpp \ lua_cocos2dx_deprecated.cpp \ lua_xml_http_request.cpp \ platform/android/CCLuaJavaBridge.cpp \ platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge.cpp \ ../../../../external/lua/tolua/tolua_event.c \ ../../../../external/lua/tolua/tolua_is.c \ ../../../../external/lua/tolua/tolua_map.c \ ../../../../external/lua/tolua/tolua_push.c \ ../../../../external/lua/tolua/tolua_to.c \ tolua_fix.c \ socket/auxiliar.c \ socket/luasocket_buffer.c \ socket/except.c \ socket/inet.c \ socket/luasocket_io.c \ socket/luasocket.c \ socket/mime.c \ socket/options.c \ socket/select.c \ socket/serial.c \ socket/socket_scripts.c \ socket/tcp.c \ socket/timeout.c \ socket/udp.c \ socket/unix.c \ socket/usocket.c \ lua_extensions.c LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../external/lua/tolua \ $(LOCAL_PATH)/../../auto-generated/lua-bindings \ $(LOCAL_PATH)/platform/android \ $(LOCAL_PATH)/platform/android/jni \ $(LOCAL_PATH)/../../../../extensions \ $(LOCAL_PATH)/../../../editor-support/cocosbuilder \ $(LOCAL_PATH)/../../../editor-support/cocostudio \ $(LOCAL_PATH)/../../../editor-support/spine \ $(LOCAL_PATH)/../../../gui LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES := luajit_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += websockets_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static LOCAL_WHOLE_STATIC_LIBRARIES += spine_static LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi include $(BUILD_STATIC_LIBRARY) $(call import-module,lua/luajit/prebuilt/android) $(call import-module,extensions) $(call import-module,2d) $(call import-module,websockets/prebuilt/android) $(call import-module,network) $(call import-module,editor-support/cocostudio) $(call import-module,editor-support/cocosbuilder) $(call import-module,editor-support/spine) ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCBProxy.cpp ================================================ /**************************************************************************** Copyright (c) 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 "CCBProxy.h" #include "LuaScriptHandlerMgr.h" CCBReader* CCBProxy::createCCBReader() { NodeLoaderLibrary *ccNodeLoaderLibrary = NodeLoaderLibrary::getInstance(); CCBReader * pCCBReader = new CCBReader(ccNodeLoaderLibrary); pCCBReader->autorelease(); return pCCBReader; } Node* CCBProxy::readCCBFromFile(const char *pszFileName,CCBReader* pCCBReader,bool bSetOwner) { if (NULL == pCCBReader || NULL == pszFileName || 0 == strlen(pszFileName)) { return NULL; } Node *pNode = NULL; if (bSetOwner) { pNode = pCCBReader->readNodeGraphFromFile(pszFileName,this); } else { pNode = pCCBReader->readNodeGraphFromFile(pszFileName); } return pNode; } const char* CCBProxy::getNodeTypeName(Node* pNode) { if (NULL == pNode) { return NULL; } if (NULL != dynamic_cast(pNode)) { return "cc.LabelTTF"; } if (NULL != dynamic_cast(pNode)) { return "cc.LabelBMFont"; } if (NULL != dynamic_cast(pNode)) { return "cc.Sprite"; } if (NULL != dynamic_cast(pNode)) { return "cc.ControlButton"; } if (NULL != dynamic_cast(pNode)) { return "cc.LayerGradient"; } if (NULL != dynamic_cast(pNode)) { return "cc.LayerColor"; } if (NULL != dynamic_cast(pNode)) { return "cc.LayerGradient"; } if (NULL != dynamic_cast(pNode)) { return "cc.Menu"; } if (NULL != dynamic_cast(pNode)) { return "cc.MenuItemAtlasFont"; } if (NULL != dynamic_cast(pNode)) { return "cc.MenuItemFont"; } if (NULL != dynamic_cast(pNode)) { return "cc.MenuItemLabel"; } if (NULL != dynamic_cast(pNode)) { return "cc.MenuItemImage"; } if (NULL != dynamic_cast(pNode)) { return "cc.MenuItemToggle"; } if (NULL != dynamic_cast(pNode)) { return "cc.MenuItemSprite"; } if (NULL != dynamic_cast(pNode)) { return "cc.MenuItem"; } if (NULL != dynamic_cast(pNode)) { return "cc.Layer"; } if (NULL != dynamic_cast(pNode)) { return "cc.String"; } if (NULL != dynamic_cast(pNode)) { return "cc.ParticleSystemQuad"; } return "No Support"; } void CCBProxy::setCallback(Node* node,int handle, int controlEvents) { if (nullptr == node) { return; } if (nullptr != dynamic_cast(node)) { MenuItem *menuItem = dynamic_cast(node); if (nullptr != menuItem) { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)menuItem, handle, ScriptHandlerMgr::HandlerType::MENU_CLICKED); } } else if (NULL != dynamic_cast(node)) { Control* control = dynamic_cast(node); if (nullptr != control) { for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlEvents & (1 << i))) { ScriptHandlerMgr::HandlerType handlerType = ScriptHandlerMgr::HandlerType((int)ScriptHandlerMgr::HandlerType::CONTROL_TOUCH_DOWN + i); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)control, handle, handlerType); } } } } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCBProxy.h ================================================ #ifndef __CCBPROXY_H_ #define __CCBPROXY_H_ #include "cocos2d.h" #include "CCLuaEngine.h" #include "SimpleAudioEngine.h" #include "extensions/cocos-ext.h" #include "cocosbuilder/CocosBuilder.h" USING_NS_CC; USING_NS_CC_EXT; using namespace cocosbuilder; class CCBProxy : public Layer{ public: CCBProxy() { } virtual ~ CCBProxy(){ } CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBProxy, create); CCBReader* createCCBReader(); Node* readCCBFromFile(const char *pszFileName,CCBReader* pCCBReader,bool bSetOwner = false); const char* getNodeTypeName(Node* pNode); void setCallback(Node* node,int handle, int controlEvents = 0); }; class CCBLayerLoader:public LayerLoader{ public: CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBLayerLoader, loader); }; #endif // __CCBPROXY_H_ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCLuaBridge.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCLuaBridge.h" NS_CC_BEGIN lua_State *LuaBridge::s_luaState = NULL; int LuaBridge::s_newFunctionId = 0; LuaStack *LuaBridge::getStack(void) { return LuaEngine::getInstance()->getLuaStack(); } int LuaBridge::pushLuaFunctionById(int functionId) { lua_State *L = s_luaState; int top = lua_gettop(L); /* L: */ lua_pushstring(L, LUA_BRIDGE_REGISTRY_FUNCTION); /* L: key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f_id */ if (!lua_istable(L, -1)) { lua_pop(L, 1); return 0; } lua_pushnil(L); /* L: f_id nil */ while (lua_next(L, -2) != 0) /* L: f_id f id */ { int value = lua_tonumber(L, -1); lua_pop(L, 1); /* L: f_id f */ if (value == functionId) { return -1; } } /* L: f_id */ lua_settop(L, top); return 0; } int LuaBridge::retainLuaFunctionById(int functionId) { lua_State *L = s_luaState; lua_pushstring(L, LUA_BRIDGE_REGISTRY_RETAIN); /* L: key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: id_r */ if (!lua_istable(L, -1)) { lua_pop(L, 1); return 0; } // get counter lua_pushinteger(L, functionId); /* L: id_r id */ lua_rawget(L, -2); /* L: id_r r */ if (lua_type(L, -1) != LUA_TNUMBER) { lua_pop(L, 2); return 0; } // increase counter int retainCount = lua_tonumber(L, -1); retainCount++; lua_pop(L, 1); /* L: id_r */ lua_pushinteger(L, functionId); /* L: id_r id */ lua_pushinteger(L, retainCount); /* L: id_r id r */ lua_rawset(L, -3); /* id_r[id] = r, L: id_r */ lua_pop(L, 1); CCLOG("CCLuaBridge::retainLuaFunctionById(%d) - retain count = %d", functionId, retainCount); return retainCount; } int LuaBridge::releaseLuaFunctionById(int functionId) { lua_State *L = s_luaState; /* L: */ lua_pushstring(L, LUA_BRIDGE_REGISTRY_FUNCTION); /* L: key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f_id */ if (!lua_istable(L, -1)) { lua_pop(L, 1); CCLOG("CCLuaBridge::releaseLuaFunctionById() - LUA_BRIDGE_REGISTRY_FUNCTION not exists"); return 0; } lua_pushstring(L, LUA_BRIDGE_REGISTRY_RETAIN); /* L: f_id key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f_id id_r */ if (!lua_istable(L, -1)) { lua_pop(L, 2); CCLOG("CCLuaBridge::releaseLuaFunctionById() - LUA_BRIDGE_REGISTRY_RETAIN not exists"); return 0; } lua_pushinteger(L, functionId); /* L: f_id id_r id */ lua_rawget(L, -2); /* L: f_id id_r r */ if (lua_type(L, -1) != LUA_TNUMBER) { lua_pop(L, 3); CCLOG("CCLuaBridge::releaseLuaFunctionById() - function id %d not found", functionId); return 0; } int retainCount = lua_tonumber(L, -1); retainCount--; if (retainCount > 0) { // update counter lua_pop(L, 1); /* L: f_id id_r */ lua_pushinteger(L, functionId); /* L: f_id id_r id */ lua_pushinteger(L, retainCount); /* L: f_id id_r id r */ lua_rawset(L, -3); /* id_r[id] = r, L: f_id id_r */ lua_pop(L, 2); CCLOG("CCLuaBridge::releaseLuaFunctionById() - function id %d retain count = %d", functionId, retainCount); return retainCount; } // remove lua function reference lua_pop(L, 1); /* L: f_id id_r */ lua_pushinteger(L, functionId); /* L: f_id id_r id */ lua_pushnil(L); /* L: f_id id_r id nil */ lua_rawset(L, -3); /* id_r[id] = nil, L: f_id id_r */ lua_pop(L, 1); /* L: f_id */ lua_pushnil(L); /* L: f_id nil */ while (lua_next(L, -2) != 0) /* L: f_id f id */ { int value = lua_tonumber(L, -1); lua_pop(L, 1); /* L: f_id f */ if (value == functionId) { lua_pushnil(L); /* L: f_id f nil */ lua_rawset(L, -3); /* f_id[f] = nil, L: f_id */ break; } } /* L: f_id */ lua_pop(L, 1); CCLOG("CCLuaBridge::releaseLuaFunctionById() - function id %d released", functionId); return 0; } int LuaBridge::retainLuaFunction(lua_State *L, int functionIndex, int *retainCountReturn) { /* L: f ... */ lua_pushstring(L, LUA_BRIDGE_REGISTRY_FUNCTION); /* L: f ... key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f ... f_id */ if (!lua_istable(L, -1)) { lua_pop(L, 1); lua_newtable(L); lua_pushstring(L, LUA_BRIDGE_REGISTRY_FUNCTION); lua_pushvalue(L, -2); lua_rawset(L, LUA_REGISTRYINDEX); } lua_pushstring(L, LUA_BRIDGE_REGISTRY_RETAIN); /* L: f ... f_id key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f ... f_id id_r */ if (!lua_istable(L, -1)) { lua_pop(L, 1); lua_newtable(L); lua_pushstring(L, LUA_BRIDGE_REGISTRY_RETAIN); lua_pushvalue(L, -2); lua_rawset(L, LUA_REGISTRYINDEX); } // get function id lua_pushvalue(L, functionIndex - 2); /* L: f ... f_id id_r f */ lua_rawget(L, -3); /* L: f ... f_id id_r id */ int functionId; if (lua_type(L, -1) != LUA_TNUMBER) { // first retain, create new id lua_pop(L, 1); /* L: f ... f_id id_r */ s_newFunctionId++; functionId = s_newFunctionId; lua_pushvalue(L, functionIndex - 2); /* L: f ... f_id id_r f */ lua_pushinteger(L, functionId); /* L: f ... f_id id_r f id */ lua_rawset(L, -4); /* f_id[f] = id, L: f ... f_id id_r */ lua_pushinteger(L, functionId); /* L: f ... f_id id_r id */ } else { functionId = lua_tonumber(L, -1); } // get function retain lua_pushvalue(L, -1); /* L: f ... f_id id_r id id */ lua_rawget(L, -3); /* L: f ... f_id id_r id r */ int retainCount = 1; if (lua_type(L, -1) != LUA_TNUMBER) { // first retain, set retain count = 1 lua_pop(L, 1); lua_pushinteger(L, retainCount); } else { // add retain count retainCount = lua_tonumber(L, -1); retainCount++; lua_pop(L, 1); lua_pushinteger(L, retainCount); } lua_rawset(L, -3); /* id_r[id] = r, L: f ... f_id id_r */ lua_pop(L, 2); /* L: f ... */ if (retainCountReturn) *retainCountReturn = retainCount; return functionId; } NS_CC_END ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCLuaBridge.h ================================================ /**************************************************************************** Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __LUA_BRIDGE_H_ #define __LUA_BRIDGE_H_ #include #include #include "CCLuaEngine.h" extern "C" { #include "lua.h" } using namespace std; NS_CC_BEGIN typedef enum { kLuaBridgeErrorOk = 0, kLuaBridgeErrorInvalidParameters = -1, kLuaBridgeErrorClassNotFound = -2, kLuaBridgeErrorMethodNotFound = -3, kLuaBridgeErrorExceptionOccurred = -4, kLuaBridgeErrorMethodSignature = -5, kLuaBridgeErrorJavaVMError = -6, } LuaBridgeError; #define LUA_BRIDGE_REGISTRY_FUNCTION "lua_bridge_function_id" // table[function] = id #define LUA_BRIDGE_REGISTRY_RETAIN "lua_bridge_function_id_retain" // table[id] = retain count class LuaBridge { public: static LuaStack *getStack(void); static int pushLuaFunctionById(int functionId); static int retainLuaFunctionById(int functionId); static int releaseLuaFunctionById(int functionId); protected: static int retainLuaFunction(lua_State *L, int functionIndex, int *retainCountReturn); static lua_State *s_luaState; static int s_newFunctionId; }; NS_CC_END #endif // __LUA_BRIDGE_H_ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCLuaEngine.cpp ================================================ /**************************************************************************** Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCLuaEngine.h" #include "tolua_fix.h" #include "cocos2d.h" #include "CCArray.h" #include "CCScheduler.h" #include "extensions/GUI/CCControlExtension/CCControl.h" #include "LuaOpengl.h" #include "lua_cocos2dx_manual.hpp" #include "lua_cocos2dx_extension_manual.h" #include "lua_cocos2dx_coco_studio_manual.hpp" #include "lua_cocos2dx_gui_manual.hpp" NS_CC_BEGIN LuaEngine* LuaEngine::_defaultEngine = NULL; LuaEngine* LuaEngine::getInstance(void) { if (!_defaultEngine) { _defaultEngine = new LuaEngine(); _defaultEngine->init(); } return _defaultEngine; } LuaEngine::~LuaEngine(void) { CC_SAFE_RELEASE(_stack); _defaultEngine = NULL; } bool LuaEngine::init(void) { _stack = LuaStack::create(); _stack->retain(); executeScriptFile("DeprecatedEnum.lua"); executeScriptFile("DeprecatedClass.lua"); executeScriptFile("Deprecated.lua"); return true; } void LuaEngine::addSearchPath(const char* path) { _stack->addSearchPath(path); } void LuaEngine::addLuaLoader(lua_CFunction func) { _stack->addLuaLoader(func); } void LuaEngine::removeScriptObjectByObject(Object* pObj) { _stack->removeScriptObjectByObject(pObj); ScriptHandlerMgr::getInstance()->removeObjectAllHandlers(pObj); } void LuaEngine::removeScriptHandler(int nHandler) { _stack->removeScriptHandler(nHandler); } int LuaEngine::executeString(const char *codes) { int ret = _stack->executeString(codes); _stack->clean(); return ret; } int LuaEngine::executeScriptFile(const char* filename) { int ret = _stack->executeScriptFile(filename); _stack->clean(); return ret; } int LuaEngine::executeGlobalFunction(const char* functionName) { int ret = _stack->executeGlobalFunction(functionName); _stack->clean(); return ret; } int LuaEngine::executeNodeEvent(Node* pNode, int nAction) { return 0; } int LuaEngine::executeMenuItemEvent(MenuItem* pMenuItem) { return 0; } int LuaEngine::executeNotificationEvent(NotificationCenter* pNotificationCenter, const char* pszName) { int nHandler = pNotificationCenter->getObserverHandlerByName(pszName); if (!nHandler) return 0; _stack->pushString(pszName); int ret = _stack->executeFunctionByHandler(nHandler, 1); _stack->clean(); return ret; } int LuaEngine::executeCallFuncActionEvent(CallFunc* pAction, Object* pTarget/* = NULL*/) { return 0; } int LuaEngine::executeSchedule(int nHandler, float dt, Node* pNode/* = NULL*/) { if (!nHandler) return 0; _stack->pushFloat(dt); int ret = _stack->executeFunctionByHandler(nHandler, 1); _stack->clean(); return ret; } int LuaEngine::executeLayerTouchEvent(Layer* pLayer, int eventType, Touch *pTouch) { return 0; } int LuaEngine::executeLayerTouchesEvent(Layer* pLayer, int eventType, Set *pTouches) { return 0; } int LuaEngine::executeLayerKeypadEvent(Layer* pLayer, int eventType) { return 0; } int LuaEngine::executeAccelerometerEvent(Layer* pLayer, Acceleration* pAccelerationValue) { return 0; } int LuaEngine::executeEvent(int nHandler, const char* pEventName, Object* pEventSource /* = NULL*/, const char* pEventSourceClassName /* = NULL*/) { _stack->pushString(pEventName); if (pEventSource) { _stack->pushObject(pEventSource, pEventSourceClassName ? pEventSourceClassName : "cc.Object"); } int ret = _stack->executeFunctionByHandler(nHandler, pEventSource ? 2 : 1); _stack->clean(); return ret; } bool LuaEngine::handleAssert(const char *msg) { bool ret = _stack->handleAssert(msg); _stack->clean(); return ret; } int LuaEngine::reallocateScriptHandler(int nHandler) { int nRet = _stack->reallocateScriptHandler(nHandler); _stack->clean(); return nRet; } bool LuaEngine::parseConfig(ConfigType type, const std::string& str) { lua_getglobal(_stack->getLuaState(), "__onParseConfig"); if (!lua_isfunction(_stack->getLuaState(), -1)) { CCLOG("[LUA ERROR] name '%s' does not represent a Lua function", "__onParseConfig"); lua_pop(_stack->getLuaState(), 1); return false; } _stack->pushInt((int)type); _stack->pushString(str.c_str()); return _stack->executeFunction(2); } int LuaEngine::sendEvent(ScriptEvent* evt) { if (NULL == evt) return 0; switch (evt->type) { case kNodeEvent: { return handleNodeEvent(evt->data); } break; case kMenuClickedEvent: { return handleMenuClickedEvent(evt->data); } break; case kCallFuncEvent: { return handleCallFuncActionEvent(evt->data); } break; case kScheduleEvent: { return handleScheduler(evt->data); } break; case kTouchEvent: { return handleTouchEvent(evt->data); } break; case kTouchesEvent: { return handleTouchesEvent(evt->data); } break; case kKeypadEvent: { return handleKeypadEvent(evt->data); } break; case kAccelerometerEvent: { return handleAccelerometerEvent(evt->data); } break; case kCommonEvent: { return handleCommonEvent(evt->data); } break; case kControlEvent: { return handlerControlEvent(evt->data); } break; default: break; } return 0; } int LuaEngine::handleNodeEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = (BasicScriptData*)data; if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::HandlerType::NODE); if (0 == handler) return 0; int action = *((int*)(basicScriptData->value)); switch (action) { case kNodeOnEnter: _stack->pushString("enter"); break; case kNodeOnExit: _stack->pushString("exit"); break; case kNodeOnEnterTransitionDidFinish: _stack->pushString("enterTransitionFinish"); break; case kNodeOnExitTransitionDidStart: _stack->pushString("exitTransitionStart"); break; case kNodeOnCleanup: _stack->pushString("cleanup"); break; default: return 0; } int ret = _stack->executeFunctionByHandler(handler, 1); _stack->clean(); return ret; } int LuaEngine::handleMenuClickedEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = (BasicScriptData*)data; if (NULL == basicScriptData->nativeObject) return 0; MenuItem* menuItem = static_cast(basicScriptData->nativeObject); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(menuItem, ScriptHandlerMgr::HandlerType::MENU_CLICKED); if (0 == handler) return 0; _stack->pushInt(menuItem->getTag()); _stack->pushObject(menuItem, "cc.MenuItem"); int ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return ret; } int LuaEngine::handleCallFuncActionEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (NULL == basicScriptData->nativeObject) return 0; int handler =ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::HandlerType::CALLFUNC); if (0 == handler) return 0; Object* target = static_cast(basicScriptData->value); if (NULL != target) { _stack->pushObject(target, "cc.Node"); } int ret = _stack->executeFunctionByHandler(handler, target ? 1 : 0); _stack->clean(); return ret; } int LuaEngine::handleScheduler(void* data) { if (NULL == data) return 0; SchedulerScriptData* schedulerInfo = static_cast(data); _stack->pushFloat(schedulerInfo->elapse); int ret = _stack->executeFunctionByHandler(schedulerInfo->handler, 1); _stack->clean(); return ret; } int LuaEngine::handleKeypadEvent(void* data) { if (NULL == data) return 0; KeypadScriptData* keypadScriptData = static_cast(data); if (NULL == keypadScriptData->nativeObject) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(keypadScriptData->nativeObject, ScriptHandlerMgr::HandlerType::KEYPAD); if (0 == handler) return 0; EventKeyboard::KeyCode action = keypadScriptData->actionType; switch(action) { case EventKeyboard::KeyCode::KEY_BACKSPACE: _stack->pushString("backClicked"); break; case EventKeyboard::KeyCode::KEY_MENU: _stack->pushString("menuClicked"); break; default: break; } int ret = _stack->executeFunctionByHandler(handler, 1); _stack->clean(); return ret; } int LuaEngine::handleAccelerometerEvent(void* data) { if (NULL == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::HandlerType::ACCELEROMETER); if (0 == handler) return 0; Acceleration* accelerationValue = static_cast(basicScriptData->value); _stack->pushFloat(accelerationValue->x); _stack->pushFloat(accelerationValue->y); _stack->pushFloat(accelerationValue->z); _stack->pushFloat(accelerationValue->timestamp); int ret = _stack->executeFunctionByHandler(handler, 4); _stack->clean(); return ret; } int LuaEngine::handleCommonEvent(void* data) { if (NULL == data) return 0; CommonScriptData* commonInfo = static_cast(data); if (NULL == commonInfo->eventName || 0 == commonInfo->handler) return 0; _stack->pushString(commonInfo->eventName); if (NULL != commonInfo->eventSource) { if (NULL != commonInfo->eventSourceClassName && strlen(commonInfo->eventSourceClassName) > 0) { _stack->pushObject(commonInfo->eventSource, commonInfo->eventSourceClassName); } else { _stack->pushObject(commonInfo->eventSource, "cc.Object"); } } int ret = _stack->executeFunctionByHandler(commonInfo->handler, commonInfo->eventSource ? 2 : 1); _stack->clean(); return ret; } int LuaEngine::handleTouchEvent(void* data) { if (NULL == data) return 0; TouchScriptData* touchScriptData = static_cast(data); if (NULL == touchScriptData->nativeObject || NULL == touchScriptData->touch) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)touchScriptData->nativeObject, ScriptHandlerMgr::HandlerType::TOUCHES); if (0 == handler) return 0; switch (touchScriptData->actionType) { case EventTouch::EventCode::BEGAN: _stack->pushString("began"); break; case EventTouch::EventCode::MOVED: _stack->pushString("moved"); break; case EventTouch::EventCode::ENDED: _stack->pushString("ended"); break; case EventTouch::EventCode::CANCELLED: _stack->pushString("cancelled"); break; default: return 0; } int ret = 0; Touch* touch = touchScriptData->touch; if (NULL != touch) { const Point pt = Director::getInstance()->convertToGL(touch->getLocationInView()); _stack->pushFloat(pt.x); _stack->pushFloat(pt.y); ret = _stack->executeFunctionByHandler(handler, 3); } _stack->clean(); return ret; } int LuaEngine::handleTouchesEvent(void* data) { if (NULL == data) return 0; TouchesScriptData* touchesScriptData = static_cast(data); if (NULL == touchesScriptData->nativeObject || touchesScriptData->touches.size() == 0) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)touchesScriptData->nativeObject, ScriptHandlerMgr::HandlerType::TOUCHES); if (0 == handler) return 0; switch (touchesScriptData->actionType) { case EventTouch::EventCode::BEGAN: _stack->pushString("began"); break; case EventTouch::EventCode::MOVED: _stack->pushString("moved"); break; case EventTouch::EventCode::ENDED: _stack->pushString("ended"); break; case EventTouch::EventCode::CANCELLED: _stack->pushString("cancelled"); break; default: return 0; } Director* pDirector = Director::getInstance(); lua_State *L = _stack->getLuaState(); int ret = 0; lua_newtable(L); int i = 1; for (auto& touch : touchesScriptData->touches) { Point pt = pDirector->convertToGL(touch->getLocationInView()); lua_pushnumber(L, pt.x); lua_rawseti(L, -2, i++); lua_pushnumber(L, pt.y); lua_rawseti(L, -2, i++); lua_pushinteger(L, touch->getID()); lua_rawseti(L, -2, i++); } ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return ret; } int LuaEngine::handlerControlEvent(void* data) { if ( NULL == data ) return 0; BasicScriptData* basicScriptData = static_cast(data); if (NULL == basicScriptData->nativeObject) return 0; int controlEvents = *((int*)(basicScriptData->value)); int handler = 0; int ret = 0; for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlEvents & (1 << i))) { ScriptHandlerMgr::HandlerType controlHandler = ScriptHandlerMgr::HandlerType((int)ScriptHandlerMgr::HandlerType::CONTROL_TOUCH_DOWN + i); handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, controlHandler); if (0 != handler) { _stack->pushObject((Object*)basicScriptData->nativeObject, "cc.Object"); _stack->pushInt(controlEvents); ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); } } } return ret; } int LuaEngine::handleEventAcc(void* data) { if (nullptr == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::HandlerType::EVENT_ACC); if (0 == handler) return 0; lua_State* L = _stack->getLuaState(); LuaEventAccelerationData* eventListennerAcc = static_cast(basicScriptData->value); toluafix_pushusertype_ccobject(L, eventListennerAcc->event->_ID, &(eventListennerAcc->event->_luaID), (void*)(eventListennerAcc->event),"cc.Event"); Acceleration* accleration = static_cast(eventListennerAcc->acc); lua_pushnumber(L,accleration->x); lua_pushnumber(L,accleration->y); lua_pushnumber(L,accleration->z); lua_pushnumber(L,accleration->timestamp); int ret = _stack->executeFunctionByHandler(handler, 5); _stack->clean(); return ret; } int LuaEngine::handleEventKeyboard(ScriptHandlerMgr::HandlerType type, void* data) { if (nullptr == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value) return 0; LuaEventKeyboarData* keyboardData = static_cast(basicScriptData->value); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, type); if (0 == handler) return 0; lua_State* L = _stack->getLuaState(); lua_pushinteger(L, keyboardData->keyCode); toluafix_pushusertype_ccobject(L, keyboardData->event->_ID, &(keyboardData->event->_luaID), (void*)(keyboardData->event),"cc.Event"); int ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return ret; } int LuaEngine::handleEventTouch(ScriptHandlerMgr::HandlerType type, void* data) { if (nullptr == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value) return 0; LuaEventTouchData* touchData = static_cast(basicScriptData->value); if (nullptr == touchData->touch || nullptr == touchData->event) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, type); if (0 == handler) return 0; int ret = 0; Touch* touch = touchData->touch; if (NULL != touch) { _stack->pushObject(touchData->touch, "cc.Touch"); _stack->pushObject(touchData->event, "cc.Event"); ret = _stack->executeFunctionByHandler(handler, 2); } _stack->clean(); return ret; } int LuaEngine::handleEventTouches(ScriptHandlerMgr::HandlerType type,void* data) { if (nullptr == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value) return 0; LuaEventTouchesData * touchesData = static_cast(basicScriptData->value); if (nullptr == touchesData->event || touchesData->touches.size() == 0) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)basicScriptData->nativeObject, type); if (0 == handler) return 0; lua_State *L = _stack->getLuaState(); int ret = 0; lua_newtable(L); int i = 1; for (auto& touch : touchesData->touches) { _stack->pushInt(i); _stack->pushObject(touch, "cc.Touch"); lua_rawset(L, -3); ++i; } _stack->pushObject(touchesData->event, "cc.Event"); ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return ret; } int LuaEngine::handleEventMouse(ScriptHandlerMgr::HandlerType type, void* data) { if (nullptr == data) return 0; BasicScriptData* basicScriptData = static_cast(data); if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value) return 0; LuaEventMouseData * mouseData = static_cast(basicScriptData->value); if (nullptr == mouseData->event ) return 0; int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)basicScriptData->nativeObject, type); if (0 == handler) return 0; _stack->pushObject(mouseData->event, "cc.Event"); int ret = _stack->executeFunctionByHandler(handler, 1); _stack->clean(); return ret; } int LuaEngine::handleEvenCustom(void* data) { if (nullptr == data) return 0; BasicScriptData * basicData = static_cast(data); if (NULL == basicData->nativeObject || nullptr == basicData->value ) return 0; EventCustom* eventCustom = static_cast(basicData->value); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)basicData->nativeObject, ScriptHandlerMgr::HandlerType::EVENT_CUSTIOM); if (0 == handler) return 0; lua_State* L = _stack->getLuaState(); toluafix_pushusertype_ccobject(L, eventCustom->_ID, &(eventCustom->_luaID), (void*)(eventCustom),"cc.EventCustom"); int ret = _stack->executeFunctionByHandler(handler, 1); _stack->clean(); return ret; } int LuaEngine::handleEvent(ScriptHandlerMgr::HandlerType type,void* data) { switch (type) { case ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL: case ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM: case ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED: case ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT: case ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT: case ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE: { return handleTableViewEvent(type, data); } break; case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS: case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR: case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS: { return handleAssetsManagerEvent(type, data); } break; case ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER: { return handleStudioEventListener(type, data); } break; case ScriptHandlerMgr::HandlerType::ARMATURE_EVENT: { return handleArmatureWrapper(type, data); } break; case ScriptHandlerMgr::HandlerType::EVENT_ACC: { return handleEventAcc(data); } break; case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_PRESSED: case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_RELEASED: { return handleEventKeyboard(type,data); } break; case ScriptHandlerMgr::HandlerType::EVENT_CUSTIOM: { return handleEvenCustom(data); } break; case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_BEGAN: case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_MOVED: case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_ENDED: case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_CANCELLED: { return handleEventTouch(type, data); } break; case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_BEGAN: case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_MOVED: case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_ENDED: case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_CANCELLED: { return handleEventTouches(type, data); } break; case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_DOWN: case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_UP: case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_MOVE: case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_SCROLL: { return handleEventMouse(type, data); } break; default: break; } return 0; } int LuaEngine::handleEvent(ScriptHandlerMgr::HandlerType type, void* data, int numResults, const std::function& func) { switch (type) { case ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX: case ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX: case ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS: { return handleTableViewEvent(type, data, numResults,func); } break; default: break; } return 0; } int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data) { if (nullptr == data) return 0; BasicScriptData* eventData = static_cast(data); if (nullptr == eventData->nativeObject || nullptr == eventData->value) return 0; LuaTableViewEventData* tableViewData = static_cast(eventData->value); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type); if (0 == handler) return 0; Object* obj = static_cast(eventData->nativeObject); if (nullptr == obj) return 0; int ret = 0; switch (type) { case ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL: case ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM: { toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView"); ret = _stack->executeFunctionByHandler(handler, 1); } break; case ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED: case ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT: case ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT: case ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE: { Object* cellObject = static_cast(tableViewData->value); if (nullptr == cellObject) { break; } toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView"); toluafix_pushusertype_ccobject(_stack->getLuaState(), cellObject->_ID, &(cellObject->_luaID), (void*)(cellObject),"cc.TableViewCell"); ret = _stack->executeFunctionByHandler(handler, 2); } break; default: break; } return ret; } int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType handlerType,void* data, int numResults, const std::function& func) { if (nullptr == data || numResults <= 0) return 0; BasicScriptData* eventData = static_cast(data); if (nullptr == eventData->nativeObject || nullptr == eventData->value) return 0; LuaTableViewEventData* tableViewData = static_cast(eventData->value); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, handlerType); if (0 == handler) return 0; Object* obj = static_cast(eventData->nativeObject); if (nullptr == obj) return 0; int ret = 0; switch (handlerType) { case ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX: { toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView"); _stack->pushLong(*((ssize_t*)tableViewData->value)); ret = _stack->executeFunction(handler, 2, 2, func); } break; case ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX: { toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView"); _stack->pushLong(*((ssize_t*)tableViewData->value)); ret = _stack->executeFunction(handler, 2, 1, func); } break; case ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS: { toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView"); ret = _stack->executeFunction(handler, 1, 1, func); } break; default: break; } return ret; } int LuaEngine::handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data) { if (nullptr == data) return 0; BasicScriptData* eventData = static_cast(data); if (nullptr == eventData->nativeObject || nullptr == eventData->value) return 0; LuaAssetsManagerEventData* assetsManagerData = static_cast(eventData->value); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type); if (0 == handler) return 0; int ret = 0; switch (type) { case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS: case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR: { _stack->pushInt(assetsManagerData->value); ret = _stack->executeFunctionByHandler(handler, 1); } break; case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS: { ret = _stack->executeFunctionByHandler(handler, 0); } break; default: break; } return ret; } int LuaEngine::handleStudioEventListener(ScriptHandlerMgr::HandlerType type,void* data) { if (nullptr == data) return 0; BasicScriptData* eventData = static_cast(data); if (nullptr == eventData->nativeObject || nullptr == eventData->value) return 0; LuaStudioEventListenerData* listenerData = static_cast(eventData->value); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); if (0 == handler) return 0; _stack->pushObject(listenerData->objTarget, "cc.Object"); _stack->pushInt(listenerData->eventType); _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return 0; } int LuaEngine::handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* data) { if (nullptr == data) return 0; BasicScriptData* eventData = static_cast(data); if (nullptr == eventData->nativeObject || nullptr == eventData->value) return 0; LuaArmatureWrapperEventData* wrapperData = static_cast(eventData->value); int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); if (0 == handler) return 0; switch (wrapperData->eventType) { case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT: { LuaArmatureMovementEventData* movementData = static_cast(wrapperData->eventData); _stack->pushObject(movementData->objTarget, "ccs.Armature"); _stack->pushInt(movementData->movementType); _stack->pushString(movementData->movementID.c_str()); _stack->executeFunctionByHandler(handler, 3); } break; case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT: { LuaArmatureFrameEventData* frameData = static_cast(wrapperData->eventData); _stack->pushObject(frameData->objTarget, "ccs.Bone"); _stack->pushString(frameData->frameEventName.c_str()); _stack->pushInt(frameData->originFrameIndex); _stack->pushInt(frameData->currentFrameIndex); _stack->executeFunctionByHandler(handler, 4); } break; case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FILE_ASYNC: { _stack->pushFloat(*(float*)wrapperData->eventData); _stack->executeFunctionByHandler(handler, 1); } break; default: break; } _stack->clean(); return 0; } NS_CC_END ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCLuaEngine.h ================================================ /**************************************************************************** Copyright (c) 2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_LUA_ENGINE_H__ #define __CC_LUA_ENGINE_H__ extern "C" { #include "lua.h" } #include "cocos2d.h" #include "CCScriptSupport.h" #include "CCLuaStack.h" #include "CCLuaValue.h" #include "LuaScriptHandlerMgr.h" NS_CC_BEGIN // Lua support for cocos2d-x class LuaEngine : public ScriptEngineProtocol { public: static LuaEngine* getInstance(void); CC_DEPRECATED_ATTRIBUTE static LuaEngine* defaultEngine(void) { return LuaEngine::getInstance(); } virtual ~LuaEngine(void); virtual ccScriptType getScriptType() { return kScriptTypeLua; }; LuaStack *getLuaStack(void) { return _stack; } /** @brief Add a path to find lua files in @param path to be added to the Lua path */ virtual void addSearchPath(const char* path); /** @brief Add lua loader, now it is used on android */ virtual void addLuaLoader(lua_CFunction func); /** @brief Remove Object from lua state @param object to remove */ virtual void removeScriptObjectByObject(Object* object); /** @brief Remove Lua function reference */ virtual void removeScriptHandler(int nHandler); /** @brief Reallocate Lua function reference */ virtual int reallocateScriptHandler(int nHandler); /** @brief Execute script code contained in the given string. @param codes holding the valid script code that should be executed. @return 0 if the string is excuted correctly. @return other if the string is excuted wrongly. */ virtual int executeString(const char* codes); /** @brief Execute a script file. @param filename String object holding the filename of the script file that is to be executed */ virtual int executeScriptFile(const char* filename); /** @brief Execute a scripted global function. @brief The function should not take any parameters and should return an integer. @param functionName String object holding the name of the function, in the global script environment, that is to be executed. @return The integer value returned from the script function. */ virtual int executeGlobalFunction(const char* functionName); virtual int executeNodeEvent(Node* pNode, int nAction); virtual int executeMenuItemEvent(MenuItem* pMenuItem); virtual int executeNotificationEvent(NotificationCenter* pNotificationCenter, const char* pszName); virtual int executeCallFuncActionEvent(CallFunc* pAction, Object* pTarget = NULL); virtual int executeSchedule(int nHandler, float dt, Node* pNode = NULL); virtual int executeLayerTouchesEvent(Layer* pLayer, int eventType, Set *pTouches); virtual int executeLayerTouchEvent(Layer* pLayer, int eventType, Touch *pTouch); virtual int executeLayerKeypadEvent(Layer* pLayer, int eventType); /** execute a accelerometer event */ virtual int executeAccelerometerEvent(Layer* pLayer, Acceleration* pAccelerationValue); virtual int executeEvent(int nHandler, const char* pEventName, Object* pEventSource = NULL, const char* pEventSourceClassName = NULL); virtual bool handleAssert(const char *msg); virtual bool parseConfig(ConfigType type, const std::string& str) override; virtual int sendEvent(ScriptEvent* message) override; virtual int handleEvent(ScriptHandlerMgr::HandlerType type,void* data); virtual int handleEvent(ScriptHandlerMgr::HandlerType type, void* data, int numResults, const std::function& func); private: LuaEngine(void) : _stack(NULL) { } bool init(void); int handleNodeEvent(void* data); int handleMenuClickedEvent(void* data); int handleCallFuncActionEvent(void* data); int handleScheduler(void* data); int handleKeypadEvent(void* data); int handleAccelerometerEvent(void* data); int handleCommonEvent(void* data); int handleTouchEvent(void* data); int handleTouchesEvent(void* data); int handlerControlEvent(void* data); int handleEvenCustom(void* data); int handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data); int handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data); int handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data, int numResults, const std::function& func); int handleStudioEventListener(ScriptHandlerMgr::HandlerType type,void* data); int handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* data); int handleEventAcc(void* data); int handleEventKeyboard(ScriptHandlerMgr::HandlerType type,void* data); int handleEventTouch(ScriptHandlerMgr::HandlerType type, void* data); int handleEventTouches(ScriptHandlerMgr::HandlerType type, void* data); int handleEventMouse(ScriptHandlerMgr::HandlerType type, void* data); private: static LuaEngine* _defaultEngine; LuaStack *_stack; }; NS_CC_END #endif // __CC_LUA_ENGINE_H__ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCLuaStack.cpp ================================================ /**************************************************************************** Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCLuaStack.h" extern "C" { #include "lua.h" #include "tolua++.h" #include "lualib.h" #include "lauxlib.h" #include "tolua_fix.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #include "lua_extensions.h" #endif } #include "Cocos2dxLuaLoader.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #include "platform/ios/CCLuaObjcBridge.h" #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/CCLuaJavaBridge.h" #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "Lua_web_socket.h" #endif #include "LuaOpengl.h" #include "LuaScriptHandlerMgr.h" #include "lua_cocos2dx_auto.hpp" #include "lua_cocos2dx_extension_auto.hpp" #include "lua_cocos2dx_manual.hpp" #include "LuaBasicConversions.h" #include "lua_cocos2dx_extension_manual.h" #include "lua_cocos2dx_deprecated.h" #include "lua_xml_http_request.h" #include "lua_cocos2dx_studio_auto.hpp" #include "lua_cocos2dx_coco_studio_manual.hpp" #include "lua_cocos2dx_spine_auto.hpp" #include "lua_cocos2dx_spine_manual.hpp" #include "lua_cocos2dx_physics_auto.hpp" #include "lua_cocos2dx_physics_manual.hpp" #include "lua_cocos2dx_gui_auto.hpp" #include "lua_cocos2dx_gui_manual.hpp" namespace { int lua_print(lua_State * luastate) { int nargs = lua_gettop(luastate); std::string t; for (int i=1; i <= nargs; i++) { if (lua_istable(luastate, i)) t += "table"; else if (lua_isnone(luastate, i)) t += "none"; else if (lua_isnil(luastate, i)) t += "nil"; else if (lua_isboolean(luastate, i)) { if (lua_toboolean(luastate, i) != 0) t += "true"; else t += "false"; } else if (lua_isfunction(luastate, i)) t += "function"; else if (lua_islightuserdata(luastate, i)) t += "lightuserdata"; else if (lua_isthread(luastate, i)) t += "thread"; else { const char * str = lua_tostring(luastate, i); if (str) t += lua_tostring(luastate, i); else t += lua_typename(luastate, lua_type(luastate, i)); } if (i!=nargs) t += "\t"; } CCLOG("[LUA-print] %s", t.c_str()); return 0; } } // namespace { NS_CC_BEGIN LuaStack::~LuaStack() { if (nullptr != _state) { lua_close(_state); } } LuaStack *LuaStack::create(void) { LuaStack *stack = new LuaStack(); stack->init(); stack->autorelease(); return stack; } LuaStack *LuaStack::attach(lua_State *L) { LuaStack *stack = new LuaStack(); stack->initWithLuaState(L); stack->autorelease(); return stack; } bool LuaStack::init(void) { _state = lua_open(); luaL_openlibs(_state); toluafix_open(_state); // Register our version of the global "print" function const luaL_reg global_functions [] = { {"print", lua_print}, {NULL, NULL} }; luaL_register(_state, "_G", global_functions); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) luaopen_lua_extensions(_state); #endif g_luaType.clear(); register_all_cocos2dx(_state); register_all_cocos2dx_extension(_state); register_all_cocos2dx_deprecated(_state); register_cocos2dx_extension_CCBProxy(_state); tolua_opengl_open(_state); register_all_cocos2dx_gui(_state); register_all_cocos2dx_studio(_state); register_all_cocos2dx_manual(_state); register_all_cocos2dx_extension_manual(_state); register_all_cocos2dx_manual_deprecated(_state); register_all_cocos2dx_coco_studio_manual(_state); register_all_cocos2dx_gui_manual(_state); register_all_cocos2dx_spine(_state); register_all_cocos2dx_spine_manual(_state); register_glnode_manual(_state); #if CC_USE_PHYSICS register_all_cocos2dx_physics(_state); register_all_cocos2dx_physics_manual(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) LuaJavaBridge::luaopen_luaj(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) tolua_web_socket_open(_state); register_web_socket_manual(_state); #endif register_xml_http_request(_state); tolua_script_handler_mgr_open(_state); // add cocos2dx loader addLuaLoader(cocos2dx_lua_loader); return true; } bool LuaStack::initWithLuaState(lua_State *L) { _state = L; return true; } void LuaStack::addSearchPath(const char* path) { lua_getglobal(_state, "package"); /* L: package */ lua_getfield(_state, -1, "path"); /* get package.path, L: package path */ const char* cur_path = lua_tostring(_state, -1); lua_pushfstring(_state, "%s;%s/?.lua", cur_path, path); /* L: package path newpath */ lua_setfield(_state, -3, "path"); /* package.path = newpath, L: package path */ lua_pop(_state, 2); /* L: - */ } void LuaStack::addLuaLoader(lua_CFunction func) { if (!func) return; // stack content after the invoking of the function // get loader table lua_getglobal(_state, "package"); /* L: package */ lua_getfield(_state, -1, "loaders"); /* L: package, loaders */ // insert loader into index 2 lua_pushcfunction(_state, func); /* L: package, loaders, func */ for (int i = lua_objlen(_state, -2) + 1; i > 2; --i) { lua_rawgeti(_state, -2, i - 1); /* L: package, loaders, func, function */ // we call lua_rawgeti, so the loader table now is at -3 lua_rawseti(_state, -3, i); /* L: package, loaders, func */ } lua_rawseti(_state, -2, 2); /* L: package, loaders */ // set loaders into package lua_setfield(_state, -2, "loaders"); /* L: package */ lua_pop(_state, 1); } void LuaStack::removeScriptObjectByObject(Object* pObj) { toluafix_remove_ccobject_by_refid(_state, pObj->_luaID); } void LuaStack::removeScriptHandler(int nHandler) { toluafix_remove_function_by_refid(_state, nHandler); } int LuaStack::executeString(const char *codes) { luaL_loadstring(_state, codes); return executeFunction(0); } int LuaStack::executeScriptFile(const char* filename) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) std::string code("require \""); code.append(filename); code.append("\""); return executeString(code.c_str()); #else std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename); ++_callFromLua; int nRet = luaL_dofile(_state, fullPath.c_str()); --_callFromLua; CC_ASSERT(_callFromLua >= 0); // lua_gc(_state, LUA_GCCOLLECT, 0); if (nRet != 0) { CCLOG("[LUA ERROR] %s", lua_tostring(_state, -1)); lua_pop(_state, 1); return nRet; } return 0; #endif } int LuaStack::executeGlobalFunction(const char* functionName) { lua_getglobal(_state, functionName); /* query function by name, stack: function */ if (!lua_isfunction(_state, -1)) { CCLOG("[LUA ERROR] name '%s' does not represent a Lua function", functionName); lua_pop(_state, 1); return 0; } return executeFunction(0); } void LuaStack::clean(void) { lua_settop(_state, 0); } void LuaStack::pushInt(int intValue) { lua_pushinteger(_state, intValue); } void LuaStack::pushFloat(float floatValue) { lua_pushnumber(_state, floatValue); } void LuaStack::pushLong(long longValue) { lua_pushnumber(_state, longValue); } void LuaStack::pushBoolean(bool boolValue) { lua_pushboolean(_state, boolValue); } void LuaStack::pushString(const char* stringValue) { lua_pushstring(_state, stringValue); } void LuaStack::pushString(const char* stringValue, int length) { lua_pushlstring(_state, stringValue, length); } void LuaStack::pushNil(void) { lua_pushnil(_state); } void LuaStack::pushObject(Object* objectValue, const char* typeName) { toluafix_pushusertype_ccobject(_state, objectValue->_ID, &objectValue->_luaID, objectValue, typeName); } void LuaStack::pushLuaValue(const LuaValue& value) { const LuaValueType type = value.getType(); if (type == LuaValueTypeInt) { return pushInt(value.intValue()); } else if (type == LuaValueTypeFloat) { return pushFloat(value.floatValue()); } else if (type == LuaValueTypeBoolean) { return pushBoolean(value.booleanValue()); } else if (type == LuaValueTypeString) { return pushString(value.stringValue().c_str()); } else if (type == LuaValueTypeDict) { pushLuaValueDict(value.dictValue()); } else if (type == LuaValueTypeArray) { pushLuaValueArray(value.arrayValue()); } else if (type == LuaValueTypeObject) { pushObject(value.ccobjectValue(), value.getObjectTypename().c_str()); } } void LuaStack::pushLuaValueDict(const LuaValueDict& dict) { lua_newtable(_state); /* L: table */ for (LuaValueDictIterator it = dict.begin(); it != dict.end(); ++it) { lua_pushstring(_state, it->first.c_str()); /* L: table key */ pushLuaValue(it->second); /* L: table key value */ lua_rawset(_state, -3); /* table.key = value, L: table */ } } void LuaStack::pushLuaValueArray(const LuaValueArray& array) { lua_newtable(_state); /* L: table */ int index = 1; for (LuaValueArrayIterator it = array.begin(); it != array.end(); ++it) { pushLuaValue(*it); /* L: table value */ lua_rawseti(_state, -2, index); /* table[index] = value, L: table */ ++index; } } bool LuaStack::pushFunctionByHandler(int nHandler) { toluafix_get_function_by_refid(_state, nHandler); /* L: ... func */ if (!lua_isfunction(_state, -1)) { CCLOG("[LUA ERROR] function refid '%d' does not reference a Lua function", nHandler); lua_pop(_state, 1); return false; } return true; } int LuaStack::executeFunction(int numArgs) { int functionIndex = -(numArgs + 1); if (!lua_isfunction(_state, functionIndex)) { CCLOG("value at stack [%d] is not function", functionIndex); lua_pop(_state, numArgs + 1); // remove function and arguments return 0; } int traceback = 0; lua_getglobal(_state, "__G__TRACKBACK__"); /* L: ... func arg1 arg2 ... G */ if (!lua_isfunction(_state, -1)) { lua_pop(_state, 1); /* L: ... func arg1 arg2 ... */ } else { lua_insert(_state, functionIndex - 1); /* L: ... G func arg1 arg2 ... */ traceback = functionIndex - 1; } int error = 0; ++_callFromLua; error = lua_pcall(_state, numArgs, 1, traceback); /* L: ... [G] ret */ --_callFromLua; if (error) { if (traceback == 0) { CCLOG("[LUA ERROR] %s", lua_tostring(_state, - 1)); /* L: ... error */ lua_pop(_state, 1); // remove error message from stack } else /* L: ... G error */ { lua_pop(_state, 2); // remove __G__TRACKBACK__ and error message from stack } return 0; } // get return value int ret = 0; if (lua_isnumber(_state, -1)) { ret = lua_tointeger(_state, -1); } else if (lua_isboolean(_state, -1)) { ret = lua_toboolean(_state, -1); } // remove return value from stack lua_pop(_state, 1); /* L: ... [G] */ if (traceback) { lua_pop(_state, 1); // remove __G__TRACKBACK__ from stack /* L: ... */ } return ret; } int LuaStack::executeFunctionByHandler(int nHandler, int numArgs) { int ret = 0; if (pushFunctionByHandler(nHandler)) /* L: ... arg1 arg2 ... func */ { if (numArgs > 0) { lua_insert(_state, -(numArgs + 1)); /* L: ... func arg1 arg2 ... */ } ret = executeFunction(numArgs); } lua_settop(_state, 0); return ret; } bool LuaStack::handleAssert(const char *msg) { if (_callFromLua == 0) return false; lua_pushfstring(_state, "ASSERT FAILED ON LUA EXECUTE: %s", msg ? msg : "unknown"); lua_error(_state); return true; } int LuaStack::reallocateScriptHandler(int nHandler) { LUA_FUNCTION nNewHandle = -1; if (pushFunctionByHandler(nHandler)) { nNewHandle = toluafix_ref_function(_state,lua_gettop(_state),0); } /* toluafix_get_function_by_refid(_state,nNewHandle); if (!lua_isfunction(_state, -1)) { CCLOG("Error!"); } lua_settop(_state, 0); */ return nNewHandle; } int LuaStack::executeFunctionReturnArray(int handler,int numArgs,int numResults,Array& resultArray) { if (pushFunctionByHandler(handler)) /* L: ... arg1 arg2 ... func */ { if (numArgs > 0) { lua_insert(_state, -(numArgs + 1)); /* L: ... func arg1 arg2 ... */ int functionIndex = -(numArgs + 1); if (!lua_isfunction(_state, functionIndex)) { CCLOG("value at stack [%d] is not function", functionIndex); lua_pop(_state, numArgs + 1); // remove function and arguments return 0; } int traceback = 0; lua_getglobal(_state, "__G__TRACKBACK__"); /* L: ... func arg1 arg2 ... G */ if (!lua_isfunction(_state, -1)) { lua_pop(_state, 1); /* L: ... func arg1 arg2 ... */ } else { lua_insert(_state, functionIndex - 1); /* L: ... G func arg1 arg2 ... */ traceback = functionIndex - 1; } int error = 0; ++_callFromLua; error = lua_pcall(_state, numArgs, numResults, traceback); /* L: ... [G] ret1 ret2 ... retResults*/ --_callFromLua; if (error) { if (traceback == 0) { CCLOG("[LUA ERROR] %s", lua_tostring(_state, - 1)); /* L: ... error */ lua_pop(_state, 1); // remove error message from stack } else /* L: ... G error */ { lua_pop(_state, 2); // remove __G__TRACKBACK__ and error message from stack } return 0; } // get return value,don't pass LUA_MULTRET to numResults, if (numResults <= 0) return 0; for (int i = 0 ; i < numResults; i++) { if (lua_type(_state, -1) == LUA_TBOOLEAN) { bool value = lua_toboolean(_state, -1); resultArray.addObject(Bool::create(value)) ; }else if (lua_type(_state, -1) == LUA_TNUMBER) { double value = lua_tonumber(_state, -1); resultArray.addObject(Double::create(value)); }else if (lua_type(_state, -1) == LUA_TSTRING) { const char* value = lua_tostring(_state, -1); resultArray.addObject(String::create(value)); }else{ resultArray.addObject(static_cast(tolua_tousertype(_state, -1, NULL))); } // remove return value from stack lua_pop(_state, 1); /* L: ... [G] ret1 ret2 ... ret*/ } /* L: ... [G]*/ if (traceback) { lua_pop(_state, 1); // remove __G__TRACKBACK__ from stack /* L: ... */ } } } lua_settop(_state, 0); return 1; } int LuaStack::executeFunction(int handler, int numArgs, int numResults, const std::function& func) { if (pushFunctionByHandler(handler)) /* L: ... arg1 arg2 ... func */ { if (numArgs > 0) { lua_insert(_state, -(numArgs + 1)); /* L: ... func arg1 arg2 ... */ } int functionIndex = -(numArgs + 1); if (!lua_isfunction(_state, functionIndex)) { CCLOG("value at stack [%d] is not function", functionIndex); lua_pop(_state, numArgs + 1); // remove function and arguments return 0; } int traceCallback = 0; lua_getglobal(_state, "__G__TRACKBACK__"); /* L: ... func arg1 arg2 ... G */ if (!lua_isfunction(_state, -1)) { lua_pop(_state, 1); /* L: ... func arg1 arg2 ... */ } else { lua_insert(_state, functionIndex - 1); /* L: ... G func arg1 arg2 ... */ traceCallback = functionIndex - 1; } int error = 0; ++_callFromLua; error = lua_pcall(_state, numArgs, numResults, traceCallback); /* L: ... [G] ret1 ret2 ... retResults*/ --_callFromLua; if (error) { if (traceCallback == 0) { CCLOG("[LUA ERROR] %s", lua_tostring(_state, - 1)); /* L: ... error */ lua_pop(_state, 1); // remove error message from stack } else /* L: ... G error */ { lua_pop(_state, 2); // remove __G__TRACKBACK__ and error message from stack } return 0; } // get return value,don't pass LUA_MULTRET to numResults, do { if (numResults <= 0 || nullptr == func) break; func(_state, numResults); } while (0); if (traceCallback) { lua_pop(_state, 1); // remove __G__TRACKBACK__ from stack /* L: ... */ } } return 1; } NS_CC_END ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCLuaStack.h ================================================ /**************************************************************************** Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_LUA_STACK_H_ #define __CC_LUA_STACK_H_ extern "C" { #include "lua.h" } #include "cocos2d.h" #include "CCLuaValue.h" NS_CC_BEGIN class LuaStack : public Object { public: static LuaStack *create(void); static LuaStack *attach(lua_State *L); virtual ~LuaStack(); /** @brief Method used to get a pointer to the lua_State that the script module is attached to. @return A pointer to the lua_State that the script module is attached to. */ lua_State* getLuaState(void) { return _state; } /** @brief Add a path to find lua files in @param path to be added to the Lua path */ virtual void addSearchPath(const char* path); /** @brief Add lua loader, now it is used on android */ virtual void addLuaLoader(lua_CFunction func); /** @brief Remove Object from lua state @param object The object to be removed. */ virtual void removeScriptObjectByObject(Object* object); /** @brief Remove Lua function reference */ virtual void removeScriptHandler(int nHandler); /** @brief Remove Lua function reference */ virtual int reallocateScriptHandler(int nHandler); /** @brief Execute script code contained in the given string. @param codes holding the valid script code that should be executed. @return 0 if the string is excuted correctly. @return other if the string is excuted wrongly. */ virtual int executeString(const char* codes); /** @brief Execute a script file. @param filename String object holding the filename of the script file that is to be executed */ virtual int executeScriptFile(const char* filename); /** @brief Execute a scripted global function. @brief The function should not take any parameters and should return an integer. @param functionName String object holding the name of the function, in the global script environment, that is to be executed. @return The integer value returned from the script function. */ virtual int executeGlobalFunction(const char* functionName); virtual void clean(void); virtual void pushInt(int intValue); virtual void pushFloat(float floatValue); virtual void pushLong(long longValue); virtual void pushBoolean(bool boolValue); virtual void pushString(const char* stringValue); virtual void pushString(const char* stringValue, int length); virtual void pushNil(void); virtual void pushObject(Object* objectValue, const char* typeName); virtual void pushLuaValue(const LuaValue& value); virtual void pushLuaValueDict(const LuaValueDict& dict); virtual void pushLuaValueArray(const LuaValueArray& array); virtual bool pushFunctionByHandler(int nHandler); virtual int executeFunction(int numArgs); virtual int executeFunctionByHandler(int nHandler, int numArgs); virtual int executeFunctionReturnArray(int handler,int numArgs,int numResults,Array& resultArray); virtual int executeFunction(int handler, int numArgs, int numResults, const std::function& func); virtual bool handleAssert(const char *msg); protected: LuaStack(void) : _state(NULL) , _callFromLua(0) { } bool init(void); bool initWithLuaState(lua_State *L); lua_State *_state; int _callFromLua; }; NS_CC_END #endif // __CC_LUA_STACK_H_ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCLuaValue.cpp ================================================ /**************************************************************************** Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCLuaValue.h" NS_CC_BEGIN const LuaValue LuaValue::intValue(const int intValue) { LuaValue value; value._type = LuaValueTypeInt; value._field.intValue = intValue; return value; } const LuaValue LuaValue::floatValue(const float floatValue) { LuaValue value; value._type = LuaValueTypeFloat; value._field.floatValue = floatValue; return value; } const LuaValue LuaValue::booleanValue(const bool booleanValue) { LuaValue value; value._type = LuaValueTypeBoolean; value._field.booleanValue = booleanValue; return value; } const LuaValue LuaValue::stringValue(const char* stringValue) { LuaValue value; value._type = LuaValueTypeString; value._field.stringValue = new std::string(stringValue ? stringValue : ""); return value; } const LuaValue LuaValue::stringValue(const std::string& stringValue) { LuaValue value; value._type = LuaValueTypeString; value._field.stringValue = new std::string(stringValue); return value; } const LuaValue LuaValue::dictValue(const LuaValueDict& dictValue) { LuaValue value; value._type = LuaValueTypeDict; value._field.dictValue = new LuaValueDict(dictValue); return value; } const LuaValue LuaValue::arrayValue(const LuaValueArray& arrayValue) { LuaValue value; value._type = LuaValueTypeArray; value._field.arrayValue = new LuaValueArray(arrayValue); return value; } const LuaValue LuaValue::ccobjectValue(Object* ccobjectValue, const char* objectTypename) { LuaValue value; value._type = LuaValueTypeObject; value._field.ccobjectValue = ccobjectValue; ccobjectValue->retain(); value._ccobjectType = new std::string(objectTypename); return value; } const LuaValue LuaValue::ccobjectValue(Object* ccobjectValue, const std::string& objectTypename) { return LuaValue::ccobjectValue(ccobjectValue, objectTypename.c_str()); } LuaValue::LuaValue(const LuaValue& rhs) { copy(rhs); } LuaValue& LuaValue::operator=(const LuaValue& rhs) { if (this != &rhs) copy(rhs); return *this; } LuaValue::~LuaValue(void) { if (_type == LuaValueTypeString) { delete _field.stringValue; } else if (_type == LuaValueTypeDict) { delete _field.dictValue; } else if (_type == LuaValueTypeArray) { delete _field.arrayValue; } else if (_type == LuaValueTypeObject) { _field.ccobjectValue->release(); delete _ccobjectType; } } void LuaValue::copy(const LuaValue& rhs) { memcpy(&_field, &rhs._field, sizeof(_field)); _type = rhs._type; if (_type == LuaValueTypeString) { _field.stringValue = new std::string(*rhs._field.stringValue); } else if (_type == LuaValueTypeDict) { _field.dictValue = new LuaValueDict(*rhs._field.dictValue); } else if (_type == LuaValueTypeArray) { _field.arrayValue = new LuaValueArray(*rhs._field.arrayValue); } else if (_type == LuaValueTypeObject) { _field.ccobjectValue = rhs._field.ccobjectValue; _field.ccobjectValue->retain(); _ccobjectType = new std::string(*rhs._ccobjectType); } } NS_CC_END ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/CCLuaValue.h ================================================ /**************************************************************************** Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __CC_LUA_VALUE_H_ #define __CC_LUA_VALUE_H_ #include #include #include extern "C" { #include "lua.h" } #include "ccTypes.h" #include "CCObject.h" #if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY using std::memset; using std::memcpy; #endif NS_CC_BEGIN typedef int LUA_FUNCTION; typedef int LUA_TABLE; typedef int LUA_STRING; class LuaValue; typedef std::map LuaValueDict; typedef LuaValueDict::const_iterator LuaValueDictIterator; typedef std::list LuaValueArray; typedef LuaValueArray::const_iterator LuaValueArrayIterator; typedef enum { LuaValueTypeInt, LuaValueTypeFloat, LuaValueTypeBoolean, LuaValueTypeString, LuaValueTypeDict, LuaValueTypeArray, LuaValueTypeObject } LuaValueType; typedef union { int intValue; float floatValue; bool booleanValue; std::string* stringValue; LuaValueDict* dictValue; LuaValueArray* arrayValue; Object* ccobjectValue; } LuaValueField; class LuaValue { public: static const LuaValue intValue(const int intValue); static const LuaValue floatValue(const float floatValue); static const LuaValue booleanValue(const bool booleanValue); static const LuaValue stringValue(const char* stringValue); static const LuaValue stringValue(const std::string& stringValue); static const LuaValue dictValue(const LuaValueDict& dictValue); static const LuaValue arrayValue(const LuaValueArray& arrayValue); static const LuaValue ccobjectValue(Object* ccobjectValue, const char* objectTypename); static const LuaValue ccobjectValue(Object* ccobjectValue, const std::string& objectTypename); LuaValue(void) : _type(LuaValueTypeInt) , _ccobjectType(NULL) { memset(&_field, 0, sizeof(_field)); } LuaValue(const LuaValue& rhs); LuaValue& operator=(const LuaValue& rhs); ~LuaValue(void); const LuaValueType getType(void) const { return _type; } const std::string& getObjectTypename(void) const { return *_ccobjectType; } int intValue(void) const { return _field.intValue; } float floatValue(void) const { return _field.floatValue; } bool booleanValue(void) const { return _field.booleanValue; } const std::string& stringValue(void) const { return *_field.stringValue; } const LuaValueDict& dictValue(void) const { return *_field.dictValue; } const LuaValueArray& arrayValue(void) const { return *_field.arrayValue; } Object* ccobjectValue(void) const { return _field.ccobjectValue; } private: LuaValueField _field; LuaValueType _type; std::string* _ccobjectType; void copy(const LuaValue& rhs); }; NS_CC_END #endif // __CC_LUA_VALUE_H_ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp ================================================ /**************************************************************************** Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "Cocos2dxLuaLoader.h" #include #include using namespace cocos2d; extern "C" { int cocos2dx_lua_loader(lua_State *L) { std::string filename(luaL_checkstring(L, 1)); size_t pos = filename.rfind(".lua"); if (pos != std::string::npos) { filename = filename.substr(0, pos); } pos = filename.find_first_of("."); while (pos != std::string::npos) { filename.replace(pos, 1, "/"); pos = filename.find_first_of("."); } filename.append(".lua"); Data data = FileUtils::getInstance()->getDataFromFile(filename); if (!data.isNull()) { if (luaL_loadbuffer(L, (char*)data.getBytes(), data.getSize(), filename.c_str()) != 0) { luaL_error(L, "error loading module %s from file %s :\n\t%s", lua_tostring(L, 1), filename.c_str(), lua_tostring(L, -1)); } } else { log("can not get file data of %s", filename.c_str()); } return 1; } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.h ================================================ /**************************************************************************** Copyright (c) 2011-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __COCOS2DX_LUA_LOADER_H__ #define __COCOS2DX_LUA_LOADER_H__ #include "cocos2d.h" extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" extern int cocos2dx_lua_loader(lua_State *L); } #endif // __COCOS2DX_LUA_LOADER_H__ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/LuaBasicConversions.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "LuaBasicConversions.h" #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif std::unordered_map g_luaType; std::unordered_map g_typeCast; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err) { if (NULL == L || NULL == err || NULL == msg || 0 == strlen(msg)) return; if (msg[0] == '#') { const char* expected = err->type; const char* provided = tolua_typename(L,err->index); if (msg[1]=='f') { int narg = err->index; if (err->array) CCLOG("%s\n argument #%d is array of '%s'; array of '%s' expected.\n",msg+2,narg,provided,expected); else CCLOG("%s\n argument #%d is '%s'; '%s' expected.\n",msg+2,narg,provided,expected); } else if (msg[1]=='v') { if (err->array) CCLOG("%s\n value is array of '%s'; array of '%s' expected.\n",msg+2,provided,expected); else CCLOG("%s\n value is '%s'; '%s' expected.\n",msg+2,provided,expected); } } } #endif #ifdef __cplusplus extern "C" { #endif extern int lua_isusertype (lua_State* L, int lo, const char* type); #ifdef __cplusplus } #endif bool luaval_is_usertype(lua_State* L,int lo,const char* type, int def) { if (def && lua_gettop(L)=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = (unsigned short)tolua_tonumber(L, lo, 0); } return ok; } bool luaval_to_int32(lua_State* L,int lo,int* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_isnumber(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = (int)tolua_tonumber(L, lo, 0); } return ok; } bool luaval_to_uint32(lua_State* L, int lo, unsigned int* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_isnumber(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = (unsigned int)tolua_tonumber(L, lo, 0); } return ok; } bool luaval_to_uint16(lua_State* L,int lo,uint16_t* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_isnumber(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = (unsigned char)tolua_tonumber(L, lo, 0); } return ok; } bool luaval_to_boolean(lua_State* L,int lo,bool* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_isboolean(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = (bool)tolua_toboolean(L, lo, 0); } return ok; } bool luaval_to_number(lua_State* L,int lo,double* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_isnumber(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = tolua_tonumber(L, lo, 0); } return ok; } bool luaval_to_long_long(lua_State* L,int lo,long long* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_isnumber(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = (long long)tolua_tonumber(L, lo, 0); } return ok; } bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_iscppstring(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = tolua_tocppstring(L,lo,NULL); } return ok; } bool luaval_to_point(lua_State* L,int lo,Point* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { lua_pushstring(L, "x"); lua_gettable(L, lo); outValue->x = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "y"); lua_gettable(L, lo); outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); lua_pop(L, 1); } return ok; } bool luaval_to_physics_material(lua_State* L,int lo,PhysicsMaterial* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { lua_pushstring(L, "density"); lua_gettable(L, lo); outValue->density = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "restitution"); lua_gettable(L, lo); outValue->restitution = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); lua_pop(L, 1); lua_pushstring(L, "friction"); lua_gettable(L, lo); outValue->friction = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); lua_pop(L, 1); } return ok; } bool luaval_to_ssize(lua_State* L,int lo, ssize_t* outValue) { return luaval_to_long(L, lo, reinterpret_cast(outValue)); } bool luaval_to_long(lua_State* L,int lo, long* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_isnumber(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = (long)tolua_tonumber(L, lo, 0); } return ok; } bool luaval_to_ulong(lua_State* L,int lo, unsigned long* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_isnumber(L,lo,0,&tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { *outValue = (unsigned long)tolua_tonumber(L, lo, 0); } return ok; } bool luaval_to_size(lua_State* L,int lo,Size* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { lua_pushstring(L, "width"); /* L: paramStack key */ lua_gettable(L,lo);/* L: paramStack paramStack[lo][key] */ outValue->width = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1);/* L: paramStack*/ lua_pushstring(L, "height"); lua_gettable(L,lo); outValue->height = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); } return ok; } bool luaval_to_rect(lua_State* L,int lo,Rect* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { lua_pushstring(L, "x"); lua_gettable(L,lo); outValue->origin.x = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "y"); lua_gettable(L,lo); outValue->origin.y = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "width"); lua_gettable(L,lo); outValue->size.width = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "height"); lua_gettable(L,lo); outValue->size.height = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); } return ok; } bool luaval_to_color4b(lua_State* L,int lo,Color4B* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if(ok) { lua_pushstring(L, "r"); lua_gettable(L,lo); outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "g"); lua_gettable(L,lo); outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "b"); lua_gettable(L,lo); outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "a"); lua_gettable(L,lo); outValue->a = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); } return ok; } bool luaval_to_color4f(lua_State* L,int lo,Color4F* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { lua_pushstring(L, "r"); lua_gettable(L,lo); outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "g"); lua_gettable(L,lo); outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "b"); lua_gettable(L,lo); outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "a"); lua_gettable(L,lo); outValue->a = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); } return ok; } bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { lua_pushstring(L, "r"); lua_gettable(L,lo); outValue->r = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "g"); lua_gettable(L,lo); outValue->g = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "b"); lua_gettable(L,lo); outValue->b = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); } return ok; } bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { lua_pushstring(L, "a"); lua_gettable(L,lo); outValue->a = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "b"); lua_gettable(L,lo); outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "c"); lua_gettable(L,lo); outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "d"); lua_gettable(L,lo); outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "tx"); lua_gettable(L,lo); outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "ty"); lua_gettable(L,lo); outValue->b = lua_isnil(L,-1) ? 0 : (float)lua_tonumber(L,-1); lua_pop(L,1); } return ok; } bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue ) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); ok = false; #endif } if (ok) { // defaul values const char * defautlFontName = "Arial"; const int defaultFontSize = 32; TextHAlignment defaultTextAlignment = TextHAlignment::LEFT; TextVAlignment defaultTextVAlignment = TextVAlignment::TOP; // by default shadow and stroke are off outValue->_shadow._shadowEnabled = false; outValue->_stroke._strokeEnabled = false; // white text by default outValue->_fontFillColor = Color3B::WHITE; lua_pushstring(L, "fontName"); lua_gettable(L,lo); outValue->_fontName = tolua_tocppstring(L,lo,defautlFontName); lua_pop(L,1); lua_pushstring(L, "fontSize"); lua_gettable(L,lo); outValue->_fontSize = lua_isnil(L,-1) ? defaultFontSize : (int)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "fontAlignmentH"); lua_gettable(L,lo); outValue->_alignment = lua_isnil(L,-1) ? defaultTextAlignment : (TextHAlignment)(int)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "fontAlignmentV"); lua_gettable(L,lo); outValue->_vertAlignment = lua_isnil(L,-1) ? defaultTextVAlignment : (TextVAlignment)(int)lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "fontFillColor"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { luaval_to_color3b(L, -1, &outValue->_fontFillColor); } lua_pop(L,1); lua_pushstring(L, "fontDimensions"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { luaval_to_size(L, -1, &outValue->_dimensions); } lua_pop(L,1); lua_pushstring(L, "shadowEnabled"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { luaval_to_boolean(L, -1, &outValue->_shadow._shadowEnabled); if (outValue->_shadow._shadowEnabled) { // default shadow values outValue->_shadow._shadowOffset = Size(5, 5); outValue->_shadow._shadowBlur = 1; outValue->_shadow._shadowOpacity = 1; } lua_pushstring(L, "shadowOffset"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { luaval_to_size(L, -1, &outValue->_shadow._shadowOffset); } lua_pop(L,1); lua_pushstring(L, "shadowBlur"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { outValue->_shadow._shadowBlur = (float)lua_tonumber(L,-1); } lua_pop(L,1); lua_pushstring(L, "shadowOpacity"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { outValue->_shadow._shadowOpacity = lua_tonumber(L,-1); } lua_pop(L,1); } lua_pop(L,1); lua_pushstring(L, "strokeEnabled"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { luaval_to_boolean(L, -1, &outValue->_stroke._strokeEnabled); if (outValue->_stroke._strokeEnabled) { // default stroke values outValue->_stroke._strokeSize = 1; outValue->_stroke._strokeColor = Color3B::BLUE; lua_pushstring(L, "strokeColor"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { luaval_to_color3b(L, -1, &outValue->_stroke._strokeColor); } lua_pop(L,1); lua_pushstring(L, "strokeSize"); lua_gettable(L,lo); if (!lua_isnil(L,-1)) { outValue->_stroke._strokeSize = (float)lua_tonumber(L,-1); } lua_pop(L,1); } } lua_pop(L,1); } return ok; } bool luaval_to_array(lua_State* L,int lo, Array** outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { size_t len = lua_objlen(L, lo); if (len > 0) { Array* arr = Array::createWithCapacity(len); if (NULL == arr) return false; for (int i = 0; i < len; i++) { lua_pushnumber(L,i + 1); lua_gettable(L,lo); if (lua_isnil(L,-1)) { lua_pop(L, 1); continue; } if (lua_isuserdata(L, -1)) { Object* obj = static_cast(tolua_tousertype(L, -1, NULL) ); if (NULL != obj) { arr->addObject(obj); } } else if(lua_istable(L, -1)) { lua_pushnumber(L,1); lua_gettable(L,-2); if (lua_isnil(L, -1) ) { lua_pop(L,1); Dictionary* dictVal = NULL; if (luaval_to_dictionary(L,-1,&dictVal)) { arr->addObject(dictVal); } } else { lua_pop(L,1); Array* arrVal = NULL; if(luaval_to_array(L, -1, &arrVal)) { arr->addObject(arrVal); } } } else if(lua_isstring(L, -1)) { std::string stringValue = ""; if(luaval_to_std_string(L, -1, &stringValue) ) { arr->addObject(String::create(stringValue)); } } else if(lua_isboolean(L, -1)) { bool boolVal = false; if (luaval_to_boolean(L, -1, &boolVal)) { arr->addObject(Bool::create(boolVal)); } } else if(lua_isnumber(L, -1)) { arr->addObject(Double::create(tolua_tonumber(L, -1, 0))); } else { CCASSERT(false, "not supported type"); } lua_pop(L, 1); } *outValue = arr; } } return ok; } bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue) { if (NULL == L || NULL == outValue) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { std::string stringKey = ""; std::string stringValue = ""; bool boolVal = false; Dictionary* dict = NULL; lua_pushnil(L); /* L: lotable ..... nil */ while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */ { if (!lua_isstring(L, -2)) { lua_pop(L, 1); continue; } if (NULL == dict) { dict = Dictionary::create(); } if(luaval_to_std_string(L, -2, &stringKey)) { if (lua_isuserdata(L, -1)) { Object* obj = static_cast(tolua_tousertype(L, -1, NULL) ); if (NULL != obj) { //get the key to string dict->setObject(obj, stringKey); } } else if(lua_istable(L, -1)) { lua_pushnumber(L,1); lua_gettable(L,-2); if (lua_isnil(L, -1) ) { lua_pop(L,1); Dictionary* dictVal = NULL; if (luaval_to_dictionary(L,-1,&dictVal)) { dict->setObject(dictVal,stringKey); } } else { lua_pop(L,1); Array* arrVal = NULL; if(luaval_to_array(L, -1, &arrVal)) { dict->setObject(arrVal,stringKey); } } } else if(lua_isstring(L, -1)) { if(luaval_to_std_string(L, -1, &stringValue)) { dict->setObject(String::create(stringValue), stringKey); } } else if(lua_isboolean(L, -1)) { if (luaval_to_boolean(L, -1, &boolVal)) { dict->setObject(Bool::create(boolVal),stringKey); } } else if(lua_isnumber(L, -1)) { dict->setObject(Double::create(tolua_tonumber(L, -1, 0)),stringKey); } else { CCASSERT(false, "not supported type"); } } lua_pop(L, 1); /* L: lotable ..... key */ } /* L: lotable ..... */ } return ok; } bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints) { if (NULL == L) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { size_t len = lua_objlen(L, lo); if (len > 0) { Point* array = (Point*)malloc(sizeof(Point) * len); if (NULL == array) return false; for (uint32_t i = 0; i < len; ++i) { lua_pushnumber(L,i + 1); lua_gettable(L,lo); if (!tolua_istable(L,-1, 0, &tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif lua_pop(L, 1); free(array); return false; } ok &= luaval_to_point(L, lua_gettop(L), &array[i]); if (!ok) { lua_pop(L, 1); free(array); return false; } lua_pop(L, 1); } *numPoints = len; *points = array; } } return ok; } bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret) { if (nullptr == L || argc == 0 ) return false; bool ok = true; Array* array = Array::create(); for (int i = 0; i < argc; i++) { double num = 0.0; if (lua_isnumber(L, i + 2)) { ok &= luaval_to_number(L, i + 2, &num); if (!ok) break; array->addObject(Integer::create((int)num)); } else if (lua_isstring(L, i + 2)) { std::string str = lua_tostring(L, i + 2); array->addObject(String::create(str)); } else if (lua_isuserdata(L, i + 2)) { tolua_Error err; if (!tolua_isusertype(L, i + 2, "cc.Object", 0, &err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&err); #endif ok = false; break; } Object* obj = static_cast(tolua_tousertype(L, i + 2, nullptr)); array->addObject(obj); } } *ret = array; return ok; } bool luavals_variadic_to_ccvaluevector(lua_State* L, int argc, cocos2d::ValueVector* ret) { if (nullptr == L || argc == 0 ) return false; for (int i = 0; i < argc; i++) { if(lua_istable(L, i + 2)) { lua_pushnumber(L, 1); lua_gettable(L, i + 2); if (lua_isnil(L, -1) ) { lua_pop(L,1); ValueMap dictVal; if (luaval_to_ccvaluemap(L, i + 2, &dictVal)) { ret->push_back(Value(dictVal)); } } else { lua_pop(L,1); ValueVector arrVal; if(luaval_to_ccvaluevector(L, i + 2, &arrVal)) { ret->push_back(Value(arrVal)); } } } else if(lua_isstring(L, i + 2)) { std::string stringValue = ""; if(luaval_to_std_string(L, i + 2, &stringValue) ) { ret->push_back(Value(stringValue)); } } else if(lua_isboolean(L, i + 2)) { bool boolVal = false; if (luaval_to_boolean(L, i + 2, &boolVal)) { ret->push_back(Value(boolVal)); } } else if(lua_isnumber(L, i + 2)) { ret->push_back(Value(tolua_tonumber(L, i + 2, 0))); } else { CCASSERT(false, "not supported type"); } } return true; } bool luaval_to_ccvalue(lua_State* L, int lo, cocos2d::Value* ret) { if ( nullptr == L || nullptr == ret) return false; bool ok = true; tolua_Error tolua_err; if (tolua_istable(L, lo, 0, &tolua_err)) { lua_pushnumber(L,1); lua_gettable(L,lo); if (lua_isnil(L, -1) ) /** if table[1] = nil,we don't think it is a pure array */ { lua_pop(L,1); ValueMap dictVal; if (luaval_to_ccvaluemap(L, lo, &dictVal)) { *ret = Value(dictVal); } } else { lua_pop(L,1); ValueVector arrVal; if (luaval_to_ccvaluevector(L, lo, &arrVal)) { *ret = Value(arrVal); } } } else if (tolua_isstring(L, lo, 0, &tolua_err)) { std::string stringValue = ""; if (luaval_to_std_string(L, lo, &stringValue)) { *ret = Value(stringValue); } } else if (tolua_isboolean(L, lo, 0, &tolua_err)) { bool boolVal = false; if (luaval_to_boolean(L, lo, &boolVal)) { *ret = Value(boolVal); } } else if (tolua_isnumber(L, lo, 0, &tolua_err)) { *ret = Value(tolua_tonumber(L, lo, 0)); } return ok; } bool luaval_to_ccvaluemap(lua_State* L, int lo, cocos2d::ValueMap* ret) { if ( nullptr == L || nullptr == ret) return false; tolua_Error tolua_err; bool ok = true; if (!tolua_istable(L, lo, 0, &tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { std::string stringKey = ""; std::string stringValue = ""; bool boolVal = false; ValueMap& dict = *ret; lua_pushnil(L); /* first key L: lotable ..... nil */ while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */ { if (!lua_isstring(L, -2)) { lua_pop(L, 1); /* removes 'value'; keep 'key' for next iteration*/ continue; } if(luaval_to_std_string(L, -2, &stringKey)) { if(lua_istable(L, -1)) { lua_pushnumber(L,1); lua_gettable(L,-2); if (lua_isnil(L, -1) ) /** if table[1] = nil,we don't think it is a pure array */ { lua_pop(L,1); ValueMap dictVal; if (luaval_to_ccvaluemap(L, -1, &dictVal)) { dict[stringKey] = Value(dictVal); } } else { lua_pop(L,1); ValueVector arrVal; if (luaval_to_ccvaluevector(L, -1, &arrVal)) { dict[stringKey] = Value(arrVal); } } } else if(lua_isstring(L, -1)) { if(luaval_to_std_string(L, -1, &stringValue)) { dict[stringKey] = Value(stringValue); } } else if(lua_isboolean(L, -1)) { if (luaval_to_boolean(L, -1, &boolVal)) { dict[stringKey] = Value(boolVal); } } else if(lua_isnumber(L, -1)) { dict[stringKey] = Value(tolua_tonumber(L, -1, 0)); } else { CCASSERT(false, "not supported type"); } } lua_pop(L, 1); /* L: lotable ..... key */ } } return ok; } bool luaval_to_ccvaluemapintkey(lua_State* L, int lo, cocos2d::ValueMapIntKey* ret) { if (nullptr == L || nullptr == ret) return false; tolua_Error tolua_err; bool ok = true; if (!tolua_istable(L, lo, 0, &tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { std::string stringKey = ""; std::string stringValue = ""; int intKey = 0; bool boolVal = false; ValueMapIntKey& dict = *ret; lua_pushnil(L); /* first key L: lotable ..... nil */ while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */ { if (!lua_isstring(L, -2)) { lua_pop(L, 1); /* removes 'value'; keep 'key' for next iteration*/ continue; } if(luaval_to_std_string(L, -2, &stringKey)) { intKey = atoi(stringKey.c_str()); if(lua_istable(L, -1)) { lua_pushnumber(L,1); lua_gettable(L,-2); if (lua_isnil(L, -1) ) /** if table[1] = nil,we don't think it is a pure array */ { lua_pop(L,1); ValueMap dictVal; if (luaval_to_ccvaluemap(L, -1, &dictVal)) { dict[intKey] = Value(dictVal); } } else { lua_pop(L,1); ValueVector arrVal; if (luaval_to_ccvaluevector(L, -1, &arrVal)) { dict[intKey] = Value(arrVal); } } } else if(lua_isstring(L, -1)) { if(luaval_to_std_string(L, -1, &stringValue)) { dict[intKey] = Value(stringValue); } } else if(lua_isboolean(L, -1)) { if (luaval_to_boolean(L, -1, &boolVal)) { dict[intKey] = Value(boolVal); } } else if(lua_isnumber(L, -1)) { dict[intKey] = Value(tolua_tonumber(L, -1, 0)); } else { CCASSERT(false, "not supported type"); } } lua_pop(L, 1); /* L: lotable ..... key */ } } return ok; } bool luaval_to_ccvaluevector(lua_State* L, int lo, cocos2d::ValueVector* ret) { if (nullptr == L || nullptr == ret) return false; tolua_Error tolua_err; bool ok = true; if (!tolua_istable(L, lo, 0, &tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { size_t len = lua_objlen(L, lo); for (int i = 0; i < len; i++) { lua_pushnumber(L,i + 1); lua_gettable(L,lo); if (lua_isnil(L,-1)) { lua_pop(L, 1); continue; } if(lua_istable(L, -1)) { lua_pushnumber(L,1); lua_gettable(L,-2); if (lua_isnil(L, -1) ) { lua_pop(L,1); ValueMap dictVal; if (luaval_to_ccvaluemap(L, -1, &dictVal)) { ret->push_back(Value(dictVal)); } } else { lua_pop(L,1); ValueVector arrVal; if(luaval_to_ccvaluevector(L, -1, &arrVal)) { ret->push_back(Value(arrVal)); } } } else if(lua_isstring(L, -1)) { std::string stringValue = ""; if(luaval_to_std_string(L, -1, &stringValue) ) { ret->push_back(Value(stringValue)); } } else if(lua_isboolean(L, -1)) { bool boolVal = false; if (luaval_to_boolean(L, -1, &boolVal)) { ret->push_back(Value(boolVal)); } } else if(lua_isnumber(L, -1)) { ret->push_back(Value(tolua_tonumber(L, -1, 0))); } else { CCASSERT(false, "not supported type"); } lua_pop(L, 1); } } return ok; } bool luaval_to_std_vector_string(lua_State* L, int lo, std::vector* ret) { if (nullptr == L || nullptr == ret || lua_gettop(L) < lo) return false; tolua_Error tolua_err; bool ok = true; if (!tolua_istable(L, lo, 0, &tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { size_t len = lua_objlen(L, lo); std::string value = ""; for (int i = 0; i < len; i++) { lua_pushnumber(L, i + 1); lua_gettable(L,lo); if(lua_isstring(L, -1)) { ok = luaval_to_std_string(L, -1, &value); if(ok) ret->push_back(value); } else { CCASSERT(false, "string type is needed"); } lua_pop(L, 1); } } return ok; } bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector* ret) { if (nullptr == L || nullptr == ret || lua_gettop(L) < lo) return false; tolua_Error tolua_err; bool ok = true; if (!tolua_istable(L, lo, 0, &tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { size_t len = lua_objlen(L, lo); for (int i = 0; i < len; i++) { lua_pushnumber(L, i + 1); lua_gettable(L,lo); if(lua_isnumber(L, -1)) { ret->push_back((int)tolua_tonumber(L, -1, 0)); } else { CCASSERT(false, "int type is needed"); } lua_pop(L, 1); } } return ok; } void points_to_luaval(lua_State* L,const Point* pt, int count) { if (NULL == L) return; lua_newtable(L); for (int i = 1; i <= count; ++i) { lua_pushnumber(L, i); point_to_luaval(L, pt[i-1]); lua_rawset(L, -3); } } void point_to_luaval(lua_State* L,const Point& pt) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "x"); /* L: table key */ lua_pushnumber(L, (lua_Number) pt.x); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "y"); /* L: table key */ lua_pushnumber(L, (lua_Number) pt.y); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void physics_material_to_luaval(lua_State* L,const PhysicsMaterial& pm) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "density"); /* L: table key */ lua_pushnumber(L, (lua_Number) pm.density); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "restitution"); /* L: table key */ lua_pushnumber(L, (lua_Number) pm.restitution); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "friction"); /* L: table key */ lua_pushnumber(L, (lua_Number) pm.friction); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo& info) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "shape"); /* L: table key */ PhysicsShape* shape = info.shape; if (shape == nullptr) { lua_pushnil(L); }else { std::string hashName = typeid(*shape).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "PhysicsShape"; } int ID = (int)(shape->_ID); int* luaID = &(shape->_luaID); toluafix_pushusertype_ccobject(L, ID, luaID, (void*)shape,className.c_str()); } lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "start"); /* L: table key */ point_to_luaval(L, info.start); lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "ended"); /* L: table key */ point_to_luaval(L, info.end); lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "contact"); /* L: table key */ point_to_luaval(L, info.contact); lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "normal"); /* L: table key */ point_to_luaval(L, info.normal); lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "fraction"); /* L: table key */ lua_pushnumber(L, (lua_Number) info.fraction); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void physics_contactdata_to_luaval(lua_State* L, const PhysicsContactData* data) { if (nullptr == L || nullptr == data) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "points"); points_to_luaval(L, data->points, data->count); lua_rawset(L, -3); lua_pushstring(L, "normal"); point_to_luaval(L, data->normal); lua_rawset(L, -3); lua_pushstring(L, "POINT_MAX"); lua_pushnumber(L, data->POINT_MAX); lua_rawset(L, -3); } void size_to_luaval(lua_State* L,const Size& sz) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "width"); /* L: table key */ lua_pushnumber(L, (lua_Number) sz.width); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "height"); /* L: table key */ lua_pushnumber(L, (lua_Number) sz.height); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void rect_to_luaval(lua_State* L,const Rect& rt) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "x"); /* L: table key */ lua_pushnumber(L, (lua_Number) rt.origin.x); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "y"); /* L: table key */ lua_pushnumber(L, (lua_Number) rt.origin.y); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "width"); /* L: table key */ lua_pushnumber(L, (lua_Number) rt.size.width); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "height"); /* L: table key */ lua_pushnumber(L, (lua_Number) rt.size.height); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void color4b_to_luaval(lua_State* L,const Color4B& cc) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "r"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.r); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "g"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.g); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "b"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.b); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "a"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.a); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void color4f_to_luaval(lua_State* L,const Color4F& cc) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "r"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.r); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "g"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.g); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "b"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.b); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "a"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.a); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void color3b_to_luaval(lua_State* L,const Color3B& cc) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "r"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.r); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "g"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.g); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "b"); /* L: table key */ lua_pushnumber(L, (lua_Number) cc.b); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValue) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "a"); /* L: table key */ lua_pushnumber(L, (lua_Number) inValue.a); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "b"); /* L: table key */ lua_pushnumber(L, (lua_Number) inValue.b); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "c"); /* L: table key */ lua_pushnumber(L, (lua_Number) inValue.c); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "d"); /* L: table key */ lua_pushnumber(L, (lua_Number) inValue.d); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "tx"); /* L: table key */ lua_pushnumber(L, (lua_Number) inValue.d); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "ty"); /* L: table key */ lua_pushnumber(L, (lua_Number) inValue.d); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "fontName"); /* L: table key */ tolua_pushcppstring(L, inValue._fontName); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "fontSize"); /* L: table key */ lua_pushnumber(L,(lua_Number)inValue._fontSize); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "fontAlignmentH"); /* L: table key */ lua_pushnumber(L, (lua_Number) inValue._alignment); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "fontAlignmentV"); /* L: table key */ lua_pushnumber(L, (lua_Number) inValue._vertAlignment); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "fontFillColor"); /* L: table key */ color3b_to_luaval(L, inValue._fontFillColor); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "fontDimensions"); /* L: table key */ size_to_luaval(L, inValue._dimensions); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ //Shadow lua_pushstring(L, "shadowEnabled"); /* L: table key */ lua_pushboolean(L, inValue._shadow._shadowEnabled); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "shadowOffset"); /* L: table key */ size_to_luaval(L, inValue._shadow._shadowOffset); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "shadowBlur"); /* L: table key */ lua_pushnumber(L, (lua_Number)inValue._shadow._shadowBlur); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "shadowOpacity"); /* L: table key */ lua_pushnumber(L, (lua_Number)inValue._shadow._shadowOpacity); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ //Stroke lua_pushstring(L, "shadowEnabled"); /* L: table key */ lua_pushboolean(L, inValue._stroke._strokeEnabled); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "strokeColor"); /* L: table key */ color3b_to_luaval(L, inValue._stroke._strokeColor); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "strokeSize"); /* L: table key */ lua_pushnumber(L, (lua_Number)inValue._stroke._strokeSize); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ } void array_to_luaval(lua_State* L,Array* inValue) { lua_newtable(L); if (nullptr == L || nullptr == inValue) return; Object* obj = nullptr; std::string className = ""; String* strVal = nullptr; Dictionary* dictVal = nullptr; Array* arrVal = nullptr; Double* doubleVal = nullptr; Bool* boolVal = nullptr; Float* floatVal = nullptr; Integer* intVal = nullptr; int indexTable = 1; CCARRAY_FOREACH(inValue, obj) { if (nullptr == obj) continue; std::string typeName = typeid(*obj).name(); auto iter = g_luaType.find(typeName); if (g_luaType.end() != iter) { className = iter->second; if (nullptr != dynamic_cast(obj)) { lua_pushnumber(L, (lua_Number)indexTable); int ID = (obj) ? (int)obj->_ID : -1; int* luaID = (obj) ? &obj->_luaID : NULL; toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,className.c_str()); lua_rawset(L, -3); obj->retain(); ++indexTable; } } else if((strVal = dynamic_cast(obj))) { lua_pushnumber(L, (lua_Number)indexTable); lua_pushstring(L, strVal->getCString()); lua_rawset(L, -3); ++indexTable; } else if ((dictVal = dynamic_cast(obj))) { dictionary_to_luaval(L, dictVal); } else if ((arrVal = dynamic_cast(obj))) { array_to_luaval(L, arrVal); } else if ((doubleVal = dynamic_cast(obj))) { lua_pushnumber(L, (lua_Number)indexTable); lua_pushnumber(L, (lua_Number)doubleVal->getValue()); lua_rawset(L, -3); ++indexTable; } else if ((floatVal = dynamic_cast(obj))) { lua_pushnumber(L, (lua_Number)indexTable); lua_pushnumber(L, (lua_Number)floatVal->getValue()); lua_rawset(L, -3); ++indexTable; } else if ((intVal = dynamic_cast(obj))) { lua_pushnumber(L, (lua_Number)indexTable); lua_pushinteger(L, (lua_Integer)intVal->getValue()); lua_rawset(L, -3); ++indexTable; } else if ((boolVal = dynamic_cast(obj))) { lua_pushnumber(L, (lua_Number)indexTable); lua_pushboolean(L, boolVal->getValue()); lua_rawset(L, -3); ++indexTable; } else { CCASSERT(false, "the type isn't suppored."); } } } void dictionary_to_luaval(lua_State* L, Dictionary* dict) { lua_newtable(L); if (nullptr == L || nullptr == dict) return; DictElement* element = nullptr; std::string className = ""; String* strVal = nullptr; Dictionary* dictVal = nullptr; Array* arrVal = nullptr; Double* doubleVal = nullptr; Bool* boolVal = nullptr; Float* floatVal = nullptr; Integer* intVal = nullptr; CCDICT_FOREACH(dict, element) { if (NULL == element) continue; std::string typeName = typeid(element->getObject()).name(); auto iter = g_luaType.find(typeName); if (g_luaType.end() != iter) { className = iter->second; if ( nullptr != dynamic_cast(element->getObject())) { lua_pushstring(L, element->getStrKey()); int ID = (element->getObject()) ? (int)element->getObject()->_ID : -1; int* luaID = (element->getObject()) ? &(element->getObject()->_luaID) : NULL; toluafix_pushusertype_ccobject(L, ID, luaID, (void*)element->getObject(),className.c_str()); lua_rawset(L, -3); element->getObject()->retain(); } } else if((strVal = dynamic_cast(element->getObject()))) { lua_pushstring(L, element->getStrKey()); lua_pushstring(L, strVal->getCString()); lua_rawset(L, -3); } else if ((dictVal = dynamic_cast(element->getObject()))) { dictionary_to_luaval(L, dictVal); } else if ((arrVal = dynamic_cast(element->getObject()))) { array_to_luaval(L, arrVal); } else if ((doubleVal = dynamic_cast(element->getObject()))) { lua_pushstring(L, element->getStrKey()); lua_pushnumber(L, (lua_Number)doubleVal->getValue()); lua_rawset(L, -3); } else if ((floatVal = dynamic_cast(element->getObject()))) { lua_pushstring(L, element->getStrKey()); lua_pushnumber(L, (lua_Number)floatVal->getValue()); lua_rawset(L, -3); } else if ((intVal = dynamic_cast(element->getObject()))) { lua_pushstring(L, element->getStrKey()); lua_pushinteger(L, (lua_Integer)intVal->getValue()); lua_rawset(L, -3); } else if ((boolVal = dynamic_cast(element->getObject()))) { lua_pushstring(L, element->getStrKey()); lua_pushboolean(L, boolVal->getValue()); lua_rawset(L, -3); } else { CCASSERT(false, "the type isn't suppored."); } } } void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue) { const Value& obj = inValue; switch (obj.getType()) { case Value::Type::BOOLEAN: lua_pushboolean(L, obj.asBool()); break; case Value::Type::FLOAT: case Value::Type::DOUBLE: lua_pushnumber(L, obj.asDouble()); break; case Value::Type::INTEGER: lua_pushinteger(L, obj.asInt()); break; case Value::Type::STRING: lua_pushstring(L, obj.asString().c_str()); break; case Value::Type::VECTOR: ccvaluevector_to_luaval(L, obj.asValueVector()); break; case Value::Type::MAP: ccvaluemap_to_luaval(L, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: ccvaluemapintkey_to_luaval(L, obj.asIntKeyMap()); break; default: break; } } void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue) { lua_newtable(L); if (nullptr == L) return; for (auto iter = inValue.begin(); iter != inValue.end(); ++iter) { std::string key = iter->first; const Value& obj = iter->second; switch (obj.getType()) { case Value::Type::BOOLEAN: { lua_pushstring(L, key.c_str()); lua_pushboolean(L, obj.asBool()); lua_rawset(L, -3); } break; case Value::Type::FLOAT: case Value::Type::DOUBLE: { lua_pushstring(L, key.c_str()); lua_pushnumber(L, obj.asDouble()); lua_rawset(L, -3); } break; case Value::Type::INTEGER: { lua_pushstring(L, key.c_str()); lua_pushinteger(L, obj.asInt()); lua_rawset(L, -3); } break; case Value::Type::STRING: { lua_pushstring(L, key.c_str()); lua_pushstring(L, obj.asString().c_str()); lua_rawset(L, -3); } break; case Value::Type::VECTOR: { lua_pushstring(L, key.c_str()); ccvaluevector_to_luaval(L, obj.asValueVector()); lua_rawset(L, -3); } break; case Value::Type::MAP: { lua_pushstring(L, key.c_str()); ccvaluemap_to_luaval(L, obj.asValueMap()); lua_rawset(L, -3); } break; case Value::Type::INT_KEY_MAP: { lua_pushstring(L, key.c_str()); ccvaluemapintkey_to_luaval(L, obj.asIntKeyMap()); lua_rawset(L, -3); } break; default: break; } } } void ccvaluemapintkey_to_luaval(lua_State* L, const cocos2d::ValueMapIntKey& inValue) { lua_newtable(L); if (nullptr == L) return; for (auto iter = inValue.begin(); iter != inValue.end(); ++iter) { std::stringstream keyss; keyss << iter->first; std::string key = keyss.str(); const Value& obj = iter->second; switch (obj.getType()) { case Value::Type::BOOLEAN: { lua_pushstring(L, key.c_str()); lua_pushboolean(L, obj.asBool()); lua_rawset(L, -3); } break; case Value::Type::FLOAT: case Value::Type::DOUBLE: { lua_pushstring(L, key.c_str()); lua_pushnumber(L, obj.asDouble()); lua_rawset(L, -3); } break; case Value::Type::INTEGER: { lua_pushstring(L, key.c_str()); lua_pushinteger(L, obj.asInt()); lua_rawset(L, -3); } break; case Value::Type::STRING: { lua_pushstring(L, key.c_str()); lua_pushstring(L, obj.asString().c_str()); lua_rawset(L, -3); } break; case Value::Type::VECTOR: { lua_pushstring(L, key.c_str()); ccvaluevector_to_luaval(L, obj.asValueVector()); lua_rawset(L, -3); } break; case Value::Type::MAP: { lua_pushstring(L, key.c_str()); ccvaluemap_to_luaval(L, obj.asValueMap()); lua_rawset(L, -3); } break; case Value::Type::INT_KEY_MAP: { lua_pushstring(L, key.c_str()); ccvaluemapintkey_to_luaval(L, obj.asIntKeyMap()); lua_rawset(L, -3); } break; default: break; } } } void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue) { lua_newtable(L); if (nullptr == L) return; int index = 1; for (const auto& obj : inValue) { switch (obj.getType()) { case Value::Type::BOOLEAN: { lua_pushnumber(L, (lua_Number)index); lua_pushboolean(L, obj.asBool()); lua_rawset(L, -3); ++index; } break; case Value::Type::FLOAT: case Value::Type::DOUBLE: { lua_pushnumber(L, (lua_Number)index); lua_pushnumber(L, obj.asDouble()); lua_rawset(L, -3); ++index; } break; case Value::Type::INTEGER: { lua_pushnumber(L, (lua_Number)index); lua_pushnumber(L, obj.asInt()); lua_rawset(L, -3); ++index; } break; case Value::Type::STRING: { lua_pushnumber(L, (lua_Number)index); lua_pushstring(L, obj.asString().c_str()); lua_rawset(L, -3); ++index; } break; case Value::Type::VECTOR: { lua_pushnumber(L, (lua_Number)index); ccvaluevector_to_luaval(L, obj.asValueVector()); lua_rawset(L, -3); ++index; } break; case Value::Type::MAP: { lua_pushnumber(L, (lua_Number)index); ccvaluemap_to_luaval(L, obj.asValueMap()); lua_rawset(L, -3); ++index; } break; case Value::Type::INT_KEY_MAP: { lua_pushnumber(L, (lua_Number)index); ccvaluemapintkey_to_luaval(L, obj.asIntKeyMap()); lua_rawset(L, -3); ++index; } break; default: break; } } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/LuaBasicConversions.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ #define __COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ extern "C" { #include "lua.h" #include "tolua++.h" #include "tolua_fix.h" } #include "cocos2d.h" using namespace cocos2d; extern std::unordered_map g_luaType; extern std::unordered_map g_typeCast; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err); #endif #define LUA_PRECONDITION( condition, ...) if( ! (condition) ) { \ cocos2d::log("lua: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ cocos2d::log(__VA_ARGS__); \ } \ extern bool luaval_is_usertype(lua_State* L,int lo,const char* type, int def); // to native extern bool luaval_to_ushort(lua_State* L, int lo, unsigned short* outValue); extern bool luaval_to_int32(lua_State* L,int lo,int* outValue); extern bool luaval_to_uint32(lua_State* L, int lo, unsigned int* outValue); extern bool luaval_to_uint16(lua_State* L,int lo,uint16_t* outValue); extern bool luaval_to_boolean(lua_State* L,int lo,bool* outValue); extern bool luaval_to_number(lua_State* L,int lo,double* outValue); extern bool luaval_to_long_long(lua_State* L,int lo,long long* outValue); extern bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue); extern bool luaval_to_long(lua_State* L,int lo, long* outValue); extern bool luaval_to_ssize(lua_State* L,int lo, ssize_t* outValue); extern bool luaval_to_point(lua_State* L,int lo,Point* outValue); extern bool luaval_to_size(lua_State* L,int lo,Size* outValue); extern bool luaval_to_rect(lua_State* L,int lo,Rect* outValue); extern bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue); extern bool luaval_to_color4b(lua_State* L,int lo,Color4B* outValue); extern bool luaval_to_color4f(lua_State* L,int lo,Color4F* outValue); extern bool luaval_to_physics_material(lua_State* L,int lo, cocos2d::PhysicsMaterial* outValue); extern bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outValue); extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue ); extern bool luaval_to_array(lua_State* L,int lo, Array** outValue); extern bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue); extern bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints); extern bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret); extern bool luavals_variadic_to_ccvaluevector(lua_State* L, int argc, cocos2d::ValueVector* ret); template bool luavals_variadic_to_ccvector( lua_State* L, int argc, cocos2d::Vector* ret) { if (nullptr == L || argc == 0 ) return false; bool ok = true; for (int i = 0; i < argc; i++) { if (lua_isuserdata(L, i + 2)) { tolua_Error err; //Undo check if (!tolua_isusertype(L, i + 2, "cc.Object", 0, &err)) { ok = false; break; } T obj = static_cast(tolua_tousertype(L, i + 2, nullptr)); ret->pushBack(obj); } } return ok; } template bool luaval_to_ccvector(lua_State* L, int lo , cocos2d::Vector* ret) { if (nullptr == L || nullptr == ret) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) ok = false; if (ok) { size_t len = lua_objlen(L, lo); for (int i = 0; i < len; i++) { lua_pushnumber(L, i + 1); lua_gettable(L, lo); if (lua_isnil(L, -1) || !lua_isuserdata(L, -1)) { lua_pop(L, 1); continue; } T cobj = static_cast(tolua_tousertype(L, -1, NULL) ); if (NULL != cobj) ret->pushBack(cobj); lua_pop(L, 1); } } return ok; } bool luaval_to_std_vector_string(lua_State* L, int lo, std::vector* ret); bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector* ret); template bool luaval_to_ccmap_string_key(lua_State* L, int lo, cocos2d::Map* ret) { if(nullptr == L || nullptr == ret || lua_gettop(L) < lo) return false; tolua_Error tolua_err; bool ok = true; if (!tolua_istable(L, lo, 0, &tolua_err)) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { std::string stringKey = ""; lua_pushnil(L); /* first key L: lotable ..... nil */ while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */ { if (!lua_isstring(L, -2)) { lua_pop(L, 1); /* removes 'value'; keep 'key' for next iteration*/ continue; } if (lua_isnil(L, -1) || !lua_isuserdata(L, -1)) { lua_pop(L, 1); continue; } luaval_to_std_string(L, -2, &stringKey); T obj = static_cast(tolua_tousertype(L, -1, NULL) ); if (nullptr != obj) ret->insert(stringKey, obj); lua_pop(L, 1); /* L: lotable ..... key */ } } return ok; } extern bool luaval_to_ccvalue(lua_State* L, int lo, cocos2d::Value* ret); extern bool luaval_to_ccvaluemap(lua_State* L, int lo, cocos2d::ValueMap* ret); extern bool luaval_to_ccvaluemapintkey(lua_State* L, int lo, cocos2d::ValueMapIntKey* ret); extern bool luaval_to_ccvaluevector(lua_State* L, int lo, cocos2d::ValueVector* ret); // from native extern void point_to_luaval(lua_State* L,const Point& pt); extern void points_to_luaval(lua_State* L,const Point* pt, int count); extern void size_to_luaval(lua_State* L,const Size& sz); extern void rect_to_luaval(lua_State* L,const Rect& rt); extern void color3b_to_luaval(lua_State* L,const Color3B& cc); extern void color4b_to_luaval(lua_State* L,const Color4B& cc); extern void color4f_to_luaval(lua_State* L,const Color4F& cc); extern void physics_material_to_luaval(lua_State* L,const PhysicsMaterial& pm); extern void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo& info); extern void physics_contactdata_to_luaval(lua_State* L, const PhysicsContactData* data); extern void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValue); extern void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue); extern void array_to_luaval(lua_State* L,Array* inValue); extern void dictionary_to_luaval(lua_State* L, Dictionary* dict); template void ccvector_to_luaval(lua_State* L,const cocos2d::Vector& inValue) { lua_newtable(L); if (nullptr == L) return; int indexTable = 1; for (const auto& obj : inValue) { if (nullptr == obj) continue; if (nullptr != dynamic_cast(obj)) { std::string typeName = typeid(*obj).name(); auto iter = g_luaType.find(typeName); if (g_luaType.end() != iter) { lua_pushnumber(L, (lua_Number)indexTable); int ID = (obj) ? (int)obj->_ID : -1; int* luaID = (obj) ? &obj->_luaID : NULL; toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,iter->second.c_str()); lua_rawset(L, -3); obj->retain(); ++indexTable; } } } } template void ccmap_string_key_to_luaval(lua_State* L, const cocos2d::Map& v) { lua_newtable(L); if(nullptr == L) return; for (auto iter = v.begin(); iter != v.end(); ++iter) { std::string key = iter->first; T obj = iter->second; if (nullptr != dynamic_cast(obj)) { std::string name = typeid(*obj).name(); auto typeIter = g_luaType.find(name); if (g_luaType.end() != typeIter) { lua_pushstring(L, name.c_str()); int ID = (obj) ? (int)obj->_ID : -1; int* luaID = (obj) ? &obj->_luaID : NULL; toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,typeIter->second.c_str()); lua_rawset(L, -3); } } } } void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue); void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue); void ccvaluemapintkey_to_luaval(lua_State* L, const cocos2d::ValueMapIntKey& inValue); void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue); #endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/LuaOpengl.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include #include #include "LuaOpengl.h" #include "cocos2d.h" #include "extensions/cocos-ext.h" #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" #include "LuaScriptHandlerMgr.h" #include "LuaBasicConversions.h" using namespace cocos2d; using namespace cocos2d::extension; void GLNode::draw() { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::GL_NODE_DRAW); if (0 != handler) { CommonScriptData data(handler,""); ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } } /* function to release collected object via destructor */ static void tolua_reg_gl_type(lua_State* tolua_S) { tolua_usertype(tolua_S, "cc.GLNode"); } static int tolua_collect_GLNode (lua_State* tolua_S) { GLNode *self = (GLNode*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } /* method: create of class GLNode */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_GLNode_create00 static int tolua_Cocos2d_GLNode_create00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"cc.GLNode",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { GLNode *glNode = new GLNode(); if (NULL != glNode) { glNode->autorelease(); int nID = (int)glNode->_ID; int* pLuaID = &glNode->_luaID; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)glNode,"cc.GLNode"); //tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } else { return 0; } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setShaderProgram of class GLNode */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_GLNode_setShaderProgram00 static int tolua_Cocos2d_GLNode_setShaderProgram00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cc.GLNode",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"cc.GLProgram",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { GLNode* self = (GLNode*) tolua_tousertype(tolua_S,1,0); GLProgram* pShaderProgram = ((GLProgram*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShaderProgram'", NULL); #endif if(NULL != self) self->setShaderProgram(pShaderProgram); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setShaderProgram'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetSupportedExtensions*/ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetSupportedExtensions00 static int tolua_Cocos2d_glGetSupportedExtensions00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isnoobj(tolua_S,1,&tolua_err)) goto tolua_lerror; else #endif { const GLubyte* extensions = glGetString(GL_EXTENSIONS); size_t len = strlen((const char*)extensions); GLubyte* copy = new GLubyte[len+1]; strncpy((char*)copy, (const char*)extensions, len ); int start_extension=0; LuaValueArray array; for (unsigned int i=0; i < len+1; i++) { if( copy[i]==' ' || copy[i]==',' || i == len ) { copy[i] = 0; LuaValue value = LuaValue::stringValue((const char*)©[start_extension]); array.push_back(value); start_extension = i+1; i++; } } lua_newtable(tolua_S); /* L: table */ int index = 1; for (LuaValueArrayIterator it = array.begin(); it != array.end(); ++it) { lua_pushstring(tolua_S, (*it).stringValue().c_str()); /* L: table value */ lua_rawseti(tolua_S, -2, index); /* table[index] = value, L: table */ ++index; } CC_SAFE_DELETE_ARRAY(copy); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetSupportedExtensions'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glActiveTexture */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glActiveTexture00 static int tolua_Cocos2d_glActiveTexture00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isnumber(tolua_S,1, 0, &tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { unsigned int activeTexture = (unsigned int)tolua_tonumber(tolua_S,1,0); glActiveTexture((GLenum)activeTexture); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glActiveTexture'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glAttachShader */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glAttachShader00 static int tolua_Cocos2d_glAttachShader00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { unsigned int program = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int shader = (unsigned int)tolua_tonumber(tolua_S,2,0); glAttachShader ((GLuint)program,(GLuint) shader); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glAttachShader'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBindAttribLocation */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBindAttribLocation00 static int tolua_Cocos2d_glBindAttribLocation00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isstring(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int program = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int index = (unsigned int)tolua_tonumber(tolua_S,2,0); const char* name = (const char*)tolua_tostring(tolua_S, 3, ""); glBindAttribLocation ((GLuint)program,(GLuint) index,name); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBindAttribLocation'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBindBuffer */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBindBuffer00 static int tolua_Cocos2d_glBindBuffer00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int buffer = (unsigned int)tolua_tonumber(tolua_S,2,0); glBindBuffer((GLenum)target,(GLuint)buffer); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBindBuffer'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: glBindFramebuffer of class GLNode */ /* #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBindFramebuffer00 static int tolua_Cocos2d_glBindFramebuffer00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"GLNode",0,&tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,2,0); unsigned int framebuffer = (unsigned int)tolua_tonumber(tolua_S,3,0); glBindFramebuffer((GLenum)target,(GLuint)framebuffer); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBindFramebuffer'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE */ /* function: glBindRenderbuffer */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBindRenderbuffer00 static int tolua_Cocos2d_glBindRenderbuffer00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int renderbuffer = (unsigned int)tolua_tonumber(tolua_S,2,0); glBindRenderbuffer((GLenum)target,(GLuint)renderbuffer); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBindRenderbuffer'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBindTexture */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBindTexture00 static int tolua_Cocos2d_glBindTexture00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int texture = (unsigned int)tolua_tonumber(tolua_S,2,0); glBindTexture((GLenum)target,(GLuint)texture); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBindTexture'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBlendColor */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBlendColor00 static int tolua_Cocos2d_glBlendColor00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int red = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int green = (unsigned int)tolua_tonumber(tolua_S,2,0); unsigned int blue = (unsigned int)tolua_tonumber(tolua_S,3,0); unsigned int alpha = (unsigned int)tolua_tonumber(tolua_S,4,0); glBlendColor((GLclampf)red , (GLclampf)green , (GLclampf)blue , (GLclampf)alpha ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBlendColor'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBlendEquation */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBlendEquation00 static int tolua_Cocos2d_glBlendEquation00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int mode = (unsigned int)tolua_tonumber(tolua_S,1,0); glBlendEquation((GLenum)mode); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBlendEquation'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBlendEquationSeparate */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBlendEquationSeparate00 static int tolua_Cocos2d_glBlendEquationSeparate00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int modeRGB = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int modeAlpha = (unsigned int)tolua_tonumber(tolua_S,2,0); glBlendEquationSeparate((GLenum)modeRGB , (GLenum)modeAlpha ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBlendEquationSeparate'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBlendFunc */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBlendFunc00 static int tolua_Cocos2d_glBlendFunc00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int sfactor = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int dfactor = (unsigned int)tolua_tonumber(tolua_S,2,0); glBlendFunc((GLenum)sfactor , (GLenum)dfactor); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBlendFunc'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBlendFuncSeparate */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBlendFuncSeparate00 static int tolua_Cocos2d_glBlendFuncSeparate00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int srcRGB = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int dstRGB = (unsigned int)tolua_tonumber(tolua_S,2,0); unsigned int srcAlpha = (unsigned int)tolua_tonumber(tolua_S,3,0); unsigned int dstAlpha = (unsigned int)tolua_tonumber(tolua_S,4,0); glBlendFuncSeparate((GLenum)srcRGB , (GLenum)dstRGB , (GLenum)srcAlpha , (GLenum)dstAlpha ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBlendFuncSeparate'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBufferData */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBufferData00 static int tolua_Cocos2d_glBufferData00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2, 0,&tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); long length = (long)tolua_tonumber(tolua_S,2,0); float* floatArray = new float[length]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= length; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 3, i, 0); } unsigned int usage = (unsigned int)tolua_tonumber(tolua_S,4,0); long lengthInByte = length * sizeof(float); glBufferData((GLenum)target , (GLsizeiptr)lengthInByte, (GLvoid*)floatArray , (GLenum)usage); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBufferData'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glBufferSubData */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glBufferSubData00 static int tolua_Cocos2d_glBufferSubData00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2, 0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); long offset = (long)tolua_tonumber(tolua_S,2,0); long length = (long)tolua_tonumber(tolua_S,3,0); float* floatArray = new float[length]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= length; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 4, i, 0); } long lengthInByte = length * sizeof(float); long offsetInByte = offset * sizeof(float); glBufferSubData((GLenum)target,(GLintptr)offsetInByte,(GLsizei)lengthInByte,(GLvoid*)floatArray); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glBufferData'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCheckFramebufferStatus */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCheckFramebufferStatus00 static int tolua_Cocos2d_glCheckFramebufferStatus00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int retVal = glCheckFramebufferStatus((GLenum)target); tolua_pushnumber(tolua_S,retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCheckFramebufferStatus'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glClear */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glClear00 static int tolua_Cocos2d_glClear00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int mask = (unsigned int)tolua_tonumber(tolua_S,1,0); glClear((GLbitfield)mask); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glClear'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glClearColor */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glClearColor00 static int tolua_Cocos2d_glClearColor00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int red = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int green = (unsigned int)tolua_tonumber(tolua_S,2,0); unsigned int blue = (unsigned int)tolua_tonumber(tolua_S,3,0); unsigned int alpha = (unsigned int)tolua_tonumber(tolua_S,4,0); glClearColor((GLclampf)red , (GLclampf)green , (GLclampf)blue , (GLclampf)alpha); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glClearColor'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glClearDepthf */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glClearDepthf00 static int tolua_Cocos2d_glClearDepthf00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int depth = (unsigned int)tolua_tonumber(tolua_S,1,0); glClearDepthf((GLclampf)depth ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glClearDepthf'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glClearStencil */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glClearStencil00 static int tolua_Cocos2d_glClearStencil00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int stencil = (unsigned int)tolua_tonumber(tolua_S,1,0); glClearStencil((GLint)stencil ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glClearStencil'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glColorMask */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glColorMask00 static int tolua_Cocos2d_glColorMask00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned char red = (unsigned char)tolua_tonumber(tolua_S,1,0); unsigned char green = (unsigned char)tolua_tonumber(tolua_S,2,0); unsigned char blue = (unsigned char)tolua_tonumber(tolua_S,3,0); unsigned char alpha = (unsigned char)tolua_tonumber(tolua_S,4,0); glColorMask((GLboolean)red , (GLboolean)green , (GLboolean)blue , (GLboolean)alpha); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glColorMask'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCompileShader */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCompileShader00 static int tolua_Cocos2d_glCompileShader00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int shader = (unsigned int)tolua_tonumber(tolua_S,1,0); glCompileShader((GLuint)shader ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCompileShader'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCompressedTexImage2D */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCompressedTexImage2D00 static int tolua_Cocos2d_glCompressedTexImage2D00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2, 0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S,5, 0,&tolua_err) || !tolua_isnumber(tolua_S, 6, 0, &tolua_err) || !tolua_isnumber(tolua_S, 7, 0, &tolua_err) || !tolua_isnumber(tolua_S, 8, 0, &tolua_err) || !tolua_istable(tolua_S, 9, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 10, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); int level = (int)tolua_tonumber(tolua_S,2,0); unsigned int internalformat = (unsigned int)tolua_tonumber(tolua_S,3,0); int width = (int)tolua_tonumber(tolua_S, 4, 0); int height = (int)tolua_tonumber(tolua_S, 5, 0); int border = (int)tolua_tonumber(tolua_S, 6, 0); int imageSize = (int)tolua_tonumber(tolua_S, 7, 0); long length = (long)tolua_tonumber(tolua_S,8,0); float* floatArray = new float[length]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= length; i++) { floatArray[i - 1] = (float)tolua_tofieldnumber(tolua_S, 9, i, 0); } glCompressedTexImage2D((GLenum)target , (GLint)level , (GLenum)internalformat , (GLsizei)width , (GLsizei)height , (GLint)border , (GLsizei)imageSize , (GLvoid*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCompressedTexImage2D'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCompressedTexSubImage2D */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCompressedTexSubImage2D00 static int tolua_Cocos2d_glCompressedTexSubImage2D00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2, 0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S,5, 0,&tolua_err) || !tolua_isnumber(tolua_S, 6, 0, &tolua_err) || !tolua_isnumber(tolua_S, 7, 0, &tolua_err) || !tolua_isnumber(tolua_S, 8, 0, &tolua_err) || !tolua_isnumber(tolua_S, 9, 0, &tolua_err) || !tolua_istable(tolua_S, 10, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 11, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); int level = (int)tolua_tonumber(tolua_S,2,0); int xoffset = (int)tolua_tonumber(tolua_S, 3, 0); int yoffset = (int)tolua_tonumber(tolua_S, 4, 0); int width = (int)tolua_tonumber(tolua_S, 5, 0); int height = (int)tolua_tonumber(tolua_S, 6, 0); unsigned int format = (unsigned int)tolua_tonumber(tolua_S,7,0); int imageSize = (int)tolua_tonumber(tolua_S, 8, 0); long length = (long)tolua_tonumber(tolua_S,9,0); float* floatArray = new float[length]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= length; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 10, i, 0); } glCompressedTexSubImage2D((GLenum)target , (GLint)level , (GLint)xoffset , (GLint)yoffset , (GLsizei)width , (GLsizei)height , (GLenum)format , (GLsizei)imageSize , (GLvoid*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCompressedTexSubImage2D'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCopyTexImage2D */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCopyTexImage2D00 static int tolua_Cocos2d_glCopyTexImage2D00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S,5, 0,&tolua_err) || !tolua_isnumber(tolua_S, 6, 0, &tolua_err) || !tolua_isnumber(tolua_S, 7, 0, &tolua_err) || !tolua_isnumber(tolua_S, 8, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 9, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); int level = (int)tolua_tonumber(tolua_S,2,0); unsigned int internalformat = (unsigned int)tolua_tonumber(tolua_S, 3, 0); int x = (int)tolua_tonumber(tolua_S, 4, 0); int y = (int)tolua_tonumber(tolua_S, 5, 0); int width = (int)tolua_tonumber(tolua_S, 6, 0); int height = (int)tolua_tonumber(tolua_S,7,0); int border = (int)tolua_tonumber(tolua_S, 8, 0); glCopyTexImage2D((GLenum)target , (GLint)level , (GLenum)internalformat , (GLint)x , (GLint)y , (GLsizei)width , (GLsizei)height , (GLint)border ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCopyTexImage2D'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCopyTexSubImage2D */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCopyTexSubImage2D00 static int tolua_Cocos2d_glCopyTexSubImage2D00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2, 0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S,5, 0,&tolua_err) || !tolua_isnumber(tolua_S, 6, 0, &tolua_err) || !tolua_isnumber(tolua_S, 7, 0, &tolua_err) || !tolua_isnumber(tolua_S, 8, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 9, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S,1,0); int level = (int)tolua_tonumber(tolua_S,2,0); int xoffset = (int)tolua_tonumber(tolua_S, 3, 0); int yoffset = (int)tolua_tonumber(tolua_S, 4, 0); int x = (int)tolua_tonumber(tolua_S, 5, 0); int y = (int)tolua_tonumber(tolua_S, 6, 0); int width = (int)tolua_tonumber(tolua_S, 7, 0); int height = (int)tolua_tonumber(tolua_S,8,0); glCopyTexSubImage2D((GLenum)target , (GLint)level , (GLint)xoffset ,(GLint)yoffset , (GLint)x , (GLint)y , (GLsizei)width , (GLsizei)height); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCopyTexSubImage2D'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCreateProgram */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCreateProgram00 static int tolua_Cocos2d_glCreateProgram00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isnoobj(tolua_S, 1, &tolua_err)) goto tolua_lerror; else #endif { int retVal = glCreateProgram(); tolua_pushnumber(tolua_S,retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCreateProgram'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCreateShader */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCreateShader00 static int tolua_Cocos2d_glCreateShader00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int type = (unsigned int)tolua_tonumber(tolua_S,1,0); int retVal = glCreateShader((GLenum)type ); tolua_pushnumber(tolua_S,retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCreateShader'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glCullFace */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glCullFace00 static int tolua_Cocos2d_glCullFace00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int mode = (unsigned int)tolua_tonumber(tolua_S,1,0); glCullFace((GLenum)mode ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glCullFace'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDeleteBuffers */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDeleteBuffers00 static int tolua_Cocos2d_glDeleteBuffers00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int buffers = (unsigned int)tolua_tonumber(tolua_S,1,0); glDeleteBuffers(1,&buffers ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDeleteBuffers'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDeleteFramebuffers */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDeleteFramebuffers00 static int tolua_Cocos2d_glDeleteFramebuffers00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int framebuffers = (unsigned int)tolua_tonumber(tolua_S,1,0); glDeleteBuffers(1,&framebuffers ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDeleteFramebuffers'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDeleteProgram */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDeleteProgram00 static int tolua_Cocos2d_glDeleteProgram00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int program = (unsigned int)tolua_tonumber(tolua_S,1,0); glDeleteProgram((GLuint)program); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDeleteProgram'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDeleteRenderbuffers */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDeleteRenderbuffers00 static int tolua_Cocos2d_glDeleteRenderbuffers00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int renderbuffers = (unsigned int)tolua_tonumber(tolua_S,1,0); glDeleteRenderbuffers(1,&renderbuffers); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDeleteRenderbuffers'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDeleteShader */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDeleteShader00 static int tolua_Cocos2d_glDeleteShader00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int shader = (unsigned int)tolua_tonumber(tolua_S,1,0); glDeleteShader((GLuint)shader ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDeleteShader'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDeleteTextures */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDeleteTextures00 static int tolua_Cocos2d_glDeleteTextures00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int textures = (unsigned int)tolua_tonumber(tolua_S,1,0); glDeleteTextures(1,&textures ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDeleteTextures'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDepthFunc */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDepthFunc00 static int tolua_Cocos2d_glDepthFunc00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int func = (unsigned int)tolua_tonumber(tolua_S,1,0); glDepthFunc((GLenum)func); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDepthFunc'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDepthMask */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDepthMask00 static int tolua_Cocos2d_glDepthMask00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned char flag = (unsigned char)tolua_tonumber(tolua_S,1,0); glDepthMask((GLboolean)flag ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDepthMask'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDepthRangef */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDepthRangef00 static int tolua_Cocos2d_glDepthRangef00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { int zNear = (int)tolua_tonumber(tolua_S,1,0); int zFar = (int)tolua_tonumber(tolua_S,2,0); glDepthRangef((GLclampf)zNear , (GLclampf)zFar ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDepthRangef'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDetachShader */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDetachShader00 static int tolua_Cocos2d_glDetachShader00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int program = (unsigned int)tolua_tonumber(tolua_S,1,0); unsigned int shader = (unsigned int)tolua_tonumber(tolua_S,2,0); glDetachShader((GLuint)program , (GLuint)shader ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDetachShader'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDisable */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDisable00 static int tolua_Cocos2d_glDisable00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int cap = (unsigned int)tolua_tonumber(tolua_S,1,0); glDisable((GLenum)cap ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDisable'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDisableVertexAttribArray */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDisableVertexAttribArray00 static int tolua_Cocos2d_glDisableVertexAttribArray00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int index = (unsigned int)tolua_tonumber(tolua_S,1,0); glDisableVertexAttribArray((GLuint)index ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDisableVertexAttribArray'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDrawArrays */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDrawArrays00 static int tolua_Cocos2d_glDrawArrays00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int mode = (unsigned int)tolua_tonumber(tolua_S,1,0); int first = (unsigned int)tolua_tonumber(tolua_S,2,0); int count = (unsigned int)tolua_tonumber(tolua_S,3,0); glDrawArrays((GLenum)mode , (GLint)first , (GLsizei)count ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDrawArrays'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glDrawElements */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glDrawElements00 static int tolua_Cocos2d_glDrawElements00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_istable(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); unsigned int arg2 = (unsigned int)tolua_tonumber(tolua_S, 3, 0); unsigned int arg3 = (unsigned int)tolua_tonumber(tolua_S, 4, 0); if (GL_UNSIGNED_BYTE == arg2) { unsigned char* unit8Array = new unsigned char[arg3]; if (NULL == unit8Array) { return 0; } for (unsigned int i = 1; i <= arg3; i++) { unit8Array[i-1] = (unsigned char)tolua_tofieldnumber(tolua_S, 5, i, 0); } glDrawElements((GLenum)arg0 , (GLsizei)arg1 , (GLenum)arg2 , (GLvoid*)unit8Array); CC_SAFE_DELETE_ARRAY(unit8Array); } else if(GL_UNSIGNED_SHORT == arg2) { unsigned short* shortArray = new unsigned short[arg3]; if (NULL == shortArray) { return 0; } for (unsigned int i = 1; i <= arg3; i++) { shortArray[i-1] = (unsigned short)tolua_tofieldnumber(tolua_S, 5, i, 0); } glDrawElements((GLenum)arg0 , (GLsizei)arg1 , (GLenum)arg2 , (GLvoid*)shortArray); CC_SAFE_DELETE_ARRAY(shortArray); } else if(GL_UNSIGNED_INT == arg2) { unsigned int* intArray = new unsigned int[arg3]; if (NULL == intArray) { return 0; } for (unsigned int i = 1; i <= arg3; i++) { intArray[i-1] = (unsigned int)tolua_tofieldnumber(tolua_S, 5, i, 0); } glDrawElements((GLenum)arg0 , (GLsizei)arg1 , (GLenum)arg2 , (GLvoid*)intArray); CC_SAFE_DELETE_ARRAY(intArray); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glDrawElements'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glEnable */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glEnable00 static int tolua_Cocos2d_glEnable00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int cap = (unsigned int)tolua_tonumber(tolua_S,1,0); glEnable((GLenum)cap); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glEnable'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glEnableVertexAttribArray */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glEnableVertexAttribArray00 static int tolua_Cocos2d_glEnableVertexAttribArray00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int index = (unsigned int)tolua_tonumber(tolua_S,1,0); glEnableVertexAttribArray((GLuint)index); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glEnableVertexAttribArray'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glFinish */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glFinish00 static int tolua_Cocos2d_glFinish00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S, 1, &tolua_err) ) goto tolua_lerror; else #endif { glFinish(); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glFinish'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glFlush */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glFlush00 static int tolua_Cocos2d_glFlush00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S, 1, &tolua_err) ) goto tolua_lerror; else #endif { glFlush(); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glFlush'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glFramebufferRenderbuffer */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glFramebufferRenderbuffer00 static int tolua_Cocos2d_glFramebufferRenderbuffer00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int attachment = (unsigned int)tolua_tonumber(tolua_S, 2, 0); unsigned int renderbuffertarget = (unsigned int)tolua_tonumber(tolua_S, 3, 0); unsigned int renderbuffer = (unsigned int)tolua_tonumber(tolua_S, 4, 0); glFramebufferRenderbuffer((GLenum)target , (GLenum)attachment , (GLenum)renderbuffertarget , (GLuint)renderbuffer ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glFramebufferRenderbuffer'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glFramebufferTexture2D */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glFramebufferTexture2D00 static int tolua_Cocos2d_glFramebufferTexture2D00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 6, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int attachment = (unsigned int)tolua_tonumber(tolua_S, 2, 0); unsigned int textarget = (unsigned int)tolua_tonumber(tolua_S, 3, 0); unsigned int texture = (unsigned int)tolua_tonumber(tolua_S, 4, 0); int level = (int)tolua_tonumber(tolua_S, 5, 0); glFramebufferTexture2D((GLenum)target , (GLenum)attachment , (GLenum)textarget , (GLuint)texture,(GLuint)level ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glFramebufferTexture2D'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glFrontFace */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glFrontFace00 static int tolua_Cocos2d_glFrontFace00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int mode = (unsigned int)tolua_tonumber(tolua_S, 1, 0); glFrontFace((GLenum)mode); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glFrontFace'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGenBuffers */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGenBuffers00 static int tolua_Cocos2d_glGenBuffers00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S, 1, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int buffer = 0; glGenBuffers(1, &buffer); tolua_pushnumber(tolua_S, buffer); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGenBuffers'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGenFramebuffers */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGenFramebuffers00 static int tolua_Cocos2d_glGenFramebuffers00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int framebuffer = (unsigned int)tolua_tonumber(tolua_S, 1, 0); glGenFramebuffers(1, &framebuffer); tolua_pushnumber(tolua_S, framebuffer); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGenFramebuffers'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGenRenderbuffers */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGenRenderbuffers00 static int tolua_Cocos2d_glGenRenderbuffers00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int renderbuffer = (unsigned int)tolua_tonumber(tolua_S, 1, 0); glGenRenderbuffers(1, &renderbuffer); tolua_pushnumber(tolua_S, renderbuffer); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGenRenderbuffers'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGenTextures */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGenTextures00 static int tolua_Cocos2d_glGenTextures00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S, 1, &tolua_err) ) goto tolua_lerror; else #endif { GLuint texture; glGenTextures(1, &texture); tolua_pushnumber(tolua_S, texture); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGenTextures'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGenerateMipmap */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGenerateMipmap00 static int tolua_Cocos2d_glGenerateMipmap00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int target = (unsigned int)tolua_tonumber(tolua_S, 1, 0); glGenerateMipmap((GLenum)target ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGenerateMipmap'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetActiveAttrib */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetActiveAttrib00 static int tolua_Cocos2d_glGetActiveAttrib00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); GLsizei length; glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); GLchar* buffer = new GLchar[length]; GLint size = -1; GLenum type = -1; glGetActiveAttrib(arg0, arg1, length, NULL, &size, &type, buffer); lua_pushnumber(tolua_S, size); lua_pushnumber(tolua_S, type); //may check std::string name = buffer; lua_pushstring(tolua_S, name.c_str()); CC_SAFE_DELETE_ARRAY(buffer); } return 3; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetActiveAttrib'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetActiveUniform */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetActiveUniform00 static int tolua_Cocos2d_glGetActiveUniform00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); GLsizei length; glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); GLchar* buffer = new GLchar[length]; GLint size = -1; GLenum type = -1; glGetActiveUniform(arg0, arg1, length, NULL, &size, &type, buffer); lua_pushnumber(tolua_S, size); lua_pushnumber(tolua_S, type); //may check std::string name = buffer; lua_pushstring(tolua_S, name.c_str()); CC_SAFE_DELETE_ARRAY(buffer); } return 3; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetActiveUniform'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetAttachedShaders */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetAttachedShaders00 static int tolua_Cocos2d_glGetAttachedShaders00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); GLsizei length; glGetProgramiv(arg0, GL_ATTACHED_SHADERS, &length); GLuint* buffer = new GLuint[length]; memset(buffer, 0, length * sizeof(GLuint)); //Fix bug 2448, it seems that glGetAttachedShaders will crash if we send NULL to the third parameter (eg Windows), same as in JS binding GLsizei realShaderCount = 0; glGetAttachedShaders(arg0, length, &realShaderCount, buffer); lua_newtable(tolua_S); /* L: table */ int index = 1; for (int i = 0; i < length; i++) { lua_pushnumber(tolua_S, buffer[i]); /* L: table value */ lua_rawseti(tolua_S, -2, index); /* table[index] = value, L: table */ ++index; } CC_SAFE_DELETE_ARRAY(buffer); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetAttachedShaders'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetAttribLocation */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetAttribLocation00 static int tolua_Cocos2d_glGetAttribLocation00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isstring(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int program = (unsigned int)tolua_tonumber(tolua_S, 1, 0); const char* name = (const char*)tolua_tostring(tolua_S, 2, ""); int retVal = glGetAttribLocation((GLuint)program , name ); lua_pushnumber(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetAttribLocation'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetError */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetError00 static int tolua_Cocos2d_glGetError00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S, 1, &tolua_err) ) goto tolua_lerror; else #endif { int retVal = glGetError(); lua_pushnumber(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetAttribLocation'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetProgramInfoLog */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetProgramInfoLog00 static int tolua_Cocos2d_glGetProgramInfoLog00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); GLsizei length; glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length); GLchar* src = new GLchar[length]; glGetProgramInfoLog(arg0, length, NULL, src); lua_pushstring(tolua_S, src); CC_SAFE_DELETE_ARRAY(src); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetProgramInfoLog'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetProgramiv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetProgramiv00 static int tolua_Cocos2d_glGetProgramiv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); GLint ret; glGetProgramiv(arg0, arg1, &ret); lua_pushnumber(tolua_S, ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetProgramiv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetShaderInfoLog */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetShaderInfoLog00 static int tolua_Cocos2d_glGetShaderInfoLog00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); GLsizei length; glGetShaderiv(arg0, GL_INFO_LOG_LENGTH, &length); GLchar* src = new GLchar[length]; glGetShaderInfoLog(arg0, length, NULL, src); lua_pushstring(tolua_S, src); CC_SAFE_DELETE_ARRAY(src); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetShaderInfoLog'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetShaderSource */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetShaderSource00 static int tolua_Cocos2d_glGetShaderSource00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); GLsizei length; glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length); GLchar* src = new GLchar[length]; glGetShaderSource(arg0, length, NULL, src); lua_pushstring(tolua_S, src); CC_SAFE_DELETE_ARRAY(src); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetShaderSource'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetShaderiv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetShaderiv00 static int tolua_Cocos2d_glGetShaderiv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); GLint ret; glGetShaderiv(arg0, arg1, &ret); lua_pushnumber(tolua_S, ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetShaderiv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetTexParameterfv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetTexParameterfv00 static int tolua_Cocos2d_glGetTexParameterfv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); GLfloat param; glGetTexParameterfv(arg0, arg1, ¶m); lua_pushnumber(tolua_S, param); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetTexParameterfv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetUniformLocation */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetUniformLocation00 static int tolua_Cocos2d_glGetUniformLocation00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isstring(tolua_S, 2,0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); const char* arg1 = tolua_tostring(tolua_S, 2, ""); int retVal = glGetUniformLocation((GLuint)arg0 , arg1 ); lua_pushnumber(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetUniformLocation'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glGetUniformfv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glGetUniformfv00 static int tolua_Cocos2d_glGetUniformfv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1,0,&tolua_err) || !tolua_isnumber(tolua_S, 2,0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); GLsizei length; glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); GLchar* namebuffer = new GLchar[length]; GLint size = -1; GLenum type = -1; glGetActiveUniform(arg0, arg1, length, NULL, &size, &type, namebuffer); CC_SAFE_DELETE_ARRAY(namebuffer); int usize = 0; int utype = 0; switch(type) { // float case GL_FLOAT: usize = 1; utype = GL_FLOAT; break; case GL_FLOAT_MAT2: usize = 2 * 2; utype = GL_FLOAT; break; case GL_FLOAT_MAT3: usize = 3 * 3; utype = GL_FLOAT; break; case GL_FLOAT_MAT4: usize = 4 * 4; utype = GL_FLOAT; break; case GL_FLOAT_VEC2: usize = 2; utype = GL_FLOAT; break; case GL_FLOAT_VEC3: usize = 3; utype = GL_FLOAT; break; case GL_FLOAT_VEC4: usize = 4; utype = GL_FLOAT; break; // int case GL_INT: usize = 1; utype = GL_INT; break; case GL_INT_VEC2: usize = 1; utype = GL_INT; break; case GL_INT_VEC3: usize = 1; utype = GL_INT; break; case GL_INT_VEC4: usize = 1; utype = GL_INT; break; default: #ifndef TOLUA_RELEASE tolua_error(tolua_S,"#ferror in function 'glGetUniformfv'.",&tolua_err); return 0; #endif break; } if( utype == GL_FLOAT) { GLfloat* param = new GLfloat[usize]; glGetUniformfv(arg0, arg1, param); lua_newtable(tolua_S); /* L: table */ int index = 1; for (int i = 0; i < usize; i++) { lua_pushnumber(tolua_S, param[i]); /* L: table value */ lua_rawseti(tolua_S, -2, index); /* table[index] = value, L: table */ ++index; } CC_SAFE_DELETE_ARRAY(param); } else if( utype == GL_INT ) { GLint* param = new GLint[usize]; glGetUniformiv(arg0, arg1, param); lua_newtable(tolua_S); /* L: table */ int index = 1; for (int i = 0; i < usize; i++) { lua_pushnumber(tolua_S, param[i]); /* L: table value */ lua_rawseti(tolua_S, -2, index); /* table[index] = value, L: table */ ++index; } CC_SAFE_DELETE_ARRAY(param); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glGetUniformfv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glHint */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glHint00 static int tolua_Cocos2d_glHint00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); glHint((GLenum)arg0 , (GLenum)arg1 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glHint'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glIsBuffer */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glIsBuffer00 static int tolua_Cocos2d_glIsBuffer00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); bool retVal = glIsBuffer((GLuint)arg0 ); lua_pushboolean(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glIsBuffer'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glIsEnabled */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glIsEnabled00 static int tolua_Cocos2d_glIsEnabled00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); bool retVal = glIsEnabled((GLenum)arg0 ); lua_pushboolean(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glIsEnabled'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glIsFramebuffer */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glIsFramebuffer00 static int tolua_Cocos2d_glIsFramebuffer00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); bool retVal = glIsFramebuffer((GLuint)arg0 ); lua_pushboolean(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glIsFramebuffer'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glIsProgram */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glIsProgram00 static int tolua_Cocos2d_glIsProgram00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); bool retVal = glIsProgram((GLuint)arg0 ); lua_pushboolean(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glIsProgram'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glIsRenderbuffer */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glIsRenderbuffer00 static int tolua_Cocos2d_glIsRenderbuffer00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); bool retVal = glIsRenderbuffer((GLuint)arg0 ); lua_pushboolean(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glIsRenderbuffer'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glIsShader */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glIsShader00 static int tolua_Cocos2d_glIsShader00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); bool retVal = glIsShader((GLuint)arg0 ); lua_pushboolean(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glIsShader'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glIsTexture */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glIsTexture00 static int tolua_Cocos2d_glIsTexture00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); bool retVal = glIsTexture((GLuint)arg0 ); lua_pushboolean(tolua_S, retVal); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glIsTexture'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glLineWidth */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glLineWidth00 static int tolua_Cocos2d_glLineWidth00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { float arg0 = (float)tolua_tonumber(tolua_S, 1, 0); glLineWidth((GLfloat)arg0 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glLineWidth'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glLinkProgram */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glLinkProgram00 static int tolua_Cocos2d_glLinkProgram00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); glLinkProgram((GLuint)arg0 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glLinkProgram'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glPixelStorei */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glPixelStorei00 static int tolua_Cocos2d_glPixelStorei00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); glPixelStorei((GLenum)arg0 , (GLint)arg1 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glPixelStorei'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glPolygonOffset */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glPolygonOffset00 static int tolua_Cocos2d_glPolygonOffset00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); glPolygonOffset((GLfloat)arg0 , (GLfloat)arg1 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glPolygonOffset'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glReadPixels */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glReadPixels00 static int tolua_Cocos2d_glReadPixels00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnumber(tolua_S,7, 0, &tolua_err) || !tolua_isnoobj(tolua_S,8, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); unsigned int arg4 = (unsigned int)tolua_tonumber(tolua_S, 5, 0); unsigned int arg5 = (unsigned int)tolua_tonumber(tolua_S, 6, 0); long length = (long)tolua_tonumber(tolua_S,7,0); unsigned char* unit8Array = new unsigned char[length]; if (NULL == unit8Array) { return 0; } for (int i = 0; i < length; i++) { unit8Array[i] = 0; } glReadPixels((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 , (GLenum)arg4 , (GLenum)arg5 , (GLvoid*)unit8Array); lua_newtable(tolua_S); /* L: table */ int index = 1; for (int i = 0; i < length; i++) { lua_pushnumber(tolua_S, unit8Array[i]); /* L: unit8 value */ lua_rawseti(tolua_S, -2, index); /* table[index] = value, L: table */ ++index; } CC_SAFE_DELETE_ARRAY(unit8Array); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glReadPixels'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glReleaseShaderCompiler */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glReleaseShaderCompiler00 static int tolua_Cocos2d_glReleaseShaderCompiler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S, 1, &tolua_err) ) goto tolua_lerror; else #endif { glReleaseShaderCompiler( ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glReleaseShaderCompiler'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glRenderbufferStorage */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glRenderbufferStorage00 static int tolua_Cocos2d_glRenderbufferStorage00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); glRenderbufferStorage((GLenum)arg0 , (GLenum)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glRenderbufferStorage'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glSampleCoverage */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glSampleCoverage00 static int tolua_Cocos2d_glSampleCoverage00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0); glSampleCoverage((GLclampf)arg0 , (GLboolean)arg1 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glSampleCoverage'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glScissor */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glScissor00 static int tolua_Cocos2d_glScissor00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); glScissor((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glScissor'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glShaderSource */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glShaderSource00 static int tolua_Cocos2d_glShaderSource00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isstring(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); const char* arg1 = tolua_tostring(tolua_S, 2, ""); glShaderSource(arg0, 1, &arg1, NULL); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glShaderSource'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glStencilFunc */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glStencilFunc00 static int tolua_Cocos2d_glStencilFunc00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); unsigned int arg2 = (unsigned int)tolua_tonumber(tolua_S, 3, 0); glStencilFunc((GLenum)arg0 , (GLint)arg1 , (GLuint)arg2 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glStencilFunc'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glStencilFuncSeparate */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glStencilFuncSeparate00 static int tolua_Cocos2d_glStencilFuncSeparate00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); unsigned int arg3 = (unsigned int)tolua_tonumber(tolua_S, 4, 0); glStencilFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 , (GLuint)arg3 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glStencilFuncSeparate'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glStencilMask */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glStencilMask00 static int tolua_Cocos2d_glStencilMask00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); glStencilMask((GLuint)arg0); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glStencilMask'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glStencilMaskSeparate */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glStencilMaskSeparate00 static int tolua_Cocos2d_glStencilMaskSeparate00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); glStencilMaskSeparate((GLenum)arg0 , (GLuint)arg1 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glStencilMaskSeparate'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glStencilOp */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glStencilOp00 static int tolua_Cocos2d_glStencilOp00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); unsigned int arg2 = (unsigned int)tolua_tonumber(tolua_S, 3, 0); glStencilOp((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glStencilOp'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glStencilOpSeparate */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glStencilOpSeparate00 static int tolua_Cocos2d_glStencilOpSeparate00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); unsigned int arg2 = (unsigned int)tolua_tonumber(tolua_S, 3, 0); unsigned int arg3 = (unsigned int)tolua_tonumber(tolua_S, 4, 0); glStencilOpSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glStencilOpSeparate'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glTexImage2D */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glTexImage2D00 static int tolua_Cocos2d_glTexImage2D00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || !tolua_isnumber(tolua_S, 6, 0, &tolua_err) || !tolua_isnumber(tolua_S, 7, 0, &tolua_err) || !tolua_isnumber(tolua_S, 8, 0, &tolua_err) || !tolua_isnumber(tolua_S, 9, 0, &tolua_err) || !tolua_istable(tolua_S, 10, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 11, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); int arg4 = (int)tolua_tonumber(tolua_S, 5, 0); int arg5 = (int)tolua_tonumber(tolua_S, 6, 0); unsigned int arg6 = (unsigned int)tolua_tonumber(tolua_S, 7, 0); unsigned int arg7 = (unsigned int)tolua_tonumber(tolua_S, 8, 0); unsigned int arg8 = (unsigned int)tolua_tonumber(tolua_S, 9, 0); unsigned char* unit8Array = new unsigned char[arg8]; if (NULL == unit8Array) { return 0; } for (unsigned int i = 1; i <= arg8; i++) { unit8Array[i-1] = (unsigned char)tolua_tofieldnumber(tolua_S, 10, i, 0); } glTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)unit8Array); // lua_newtable(tolua_S); /* L: table */ // int index = 1; // for (int i = 0; i < arg8; i++) // { // lua_pushnumber(tolua_S, unit8Array[i]); /* L: unit8 value */ // lua_rawseti(tolua_S, -2, index); /* table[index] = value, L: table */ // ++index; // } CC_SAFE_DELETE_ARRAY(unit8Array); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glTexImage2D'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glTexParameterf */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glTexParameterf00 static int tolua_Cocos2d_glTexParameterf00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); glTexParameterf((GLenum)arg0 , (GLenum)arg1 , (GLfloat)arg2 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glTexParameterf'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glTexParameteri */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glTexParameteri00 static int tolua_Cocos2d_glTexParameteri00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); glTexParameteri((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glTexParameteri'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glTexSubImage2D */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glTexSubImage2D00 static int tolua_Cocos2d_glTexSubImage2D00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || !tolua_isnumber(tolua_S, 6, 0, &tolua_err) || !tolua_isnumber(tolua_S, 7, 0, &tolua_err) || !tolua_isnumber(tolua_S, 8, 0, &tolua_err) || !tolua_isnumber(tolua_S, 9, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 10, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); int arg4 = (int)tolua_tonumber(tolua_S, 5, 0); int arg5 = (int)tolua_tonumber(tolua_S, 6, 0); unsigned int arg6 = (unsigned int)tolua_tonumber(tolua_S, 7, 0); unsigned int arg7 = (unsigned int)tolua_tonumber(tolua_S, 8, 0); unsigned int arg8 = (unsigned int)tolua_tonumber(tolua_S, 9, 0); unsigned char* unit8Array = new unsigned char[arg8]; if (NULL == unit8Array) { return 0; } for (unsigned int i = 0; i < arg8; i++) { unit8Array[i] = 0; } glTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)unit8Array ); lua_newtable(tolua_S); /* L: table */ int index = 1; for (unsigned int i = 0; i < arg8; i++) { lua_pushnumber(tolua_S, unit8Array[i]); /* L: unit8 value */ lua_rawseti(tolua_S, -2, index); /* table[index] = value, L: table */ ++index; } CC_SAFE_DELETE_ARRAY(unit8Array); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glTexSubImage2D'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform1f */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform1f00 static int tolua_Cocos2d_glUniform1f00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); glUniform1f((GLint)arg0 , (GLfloat)arg1 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform1f'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform1fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform1fv00 static int tolua_Cocos2d_glUniform1fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); float* floatArray = new float[arg2]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg2; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniform1fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform1fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform1i */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform1i00 static int tolua_Cocos2d_glUniform1i00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); glUniform1i((GLint)arg0 , (GLint)arg1 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform1i'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform1iv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform1iv00 static int tolua_Cocos2d_glUniform1iv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int* intArray = new int[arg2]; if (NULL == intArray) { return 0; } for (int i = 1; i <= arg2; i++) { intArray[i-1] = (int)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniform1iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)intArray ); CC_SAFE_DELETE_ARRAY(intArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform1fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform2f */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform2f00 static int tolua_Cocos2d_glUniform2f00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); glUniform2f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform2f'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform2fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform2fv00 static int tolua_Cocos2d_glUniform2fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); float* floatArray = new float[arg2]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg2; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniform1fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform2fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform2i */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform2i00 static int tolua_Cocos2d_glUniform2i00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); glUniform2i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform2i'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform2iv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform2iv00 static int tolua_Cocos2d_glUniform2iv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int* intArray = new int[arg2]; if (NULL == intArray) { return 0; } for (int i = 1; i <= arg2; i++) { intArray[i-1] = (int)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniform2iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)intArray ); CC_SAFE_DELETE_ARRAY(intArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform2iv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform3f */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform3f00 static int tolua_Cocos2d_glUniform3f00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); glUniform3f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform4f'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform3fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform3fv00 static int tolua_Cocos2d_glUniform3fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); float* floatArray = new float[arg2]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg2; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniform1fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform3fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform3i */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform3i00 static int tolua_Cocos2d_glUniform3i00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); glUniform3i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform3i'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform3iv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform3iv00 static int tolua_Cocos2d_glUniform3iv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int* intArray = new int[arg2]; if (NULL == intArray) { return 0; } for (int i = 1; i <= arg2; i++) { intArray[i-1] = (int)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniform3iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)intArray ); CC_SAFE_DELETE_ARRAY(intArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform3iv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform4f */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform4f00 static int tolua_Cocos2d_glUniform4f00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 6, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); int arg4 = (int)tolua_tonumber(tolua_S, 5, 0); glUniform4f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform4f'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform4fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform4fv00 static int tolua_Cocos2d_glUniform4fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); float* floatArray = new float[arg2]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg2; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniform4fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform4fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform4i */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform4i00 static int tolua_Cocos2d_glUniform4i00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 6, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); int arg4 = (int)tolua_tonumber(tolua_S, 5, 0); glUniform4i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform4i'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniform4iv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniform4iv00 static int tolua_Cocos2d_glUniform4iv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int* intArray = new int[arg2]; if (NULL == intArray) { return 0; } for (int i = 1; i <= arg2; i++) { intArray[i-1] = (int)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniform4iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)intArray ); CC_SAFE_DELETE_ARRAY(intArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniform4iv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniformMatrix2fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniformMatrix2fv00 static int tolua_Cocos2d_glUniformMatrix2fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); float* floatArray = new float[arg2]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg2; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniformMatrix2fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniformMatrix2fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniformMatrix3fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniformMatrix3fv00 static int tolua_Cocos2d_glUniformMatrix3fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); unsigned short arg1 = (unsigned short)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); float* floatArray = new float[arg2]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg2; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniformMatrix3fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniformMatrix3fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUniformMatrix4fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUniformMatrix4fv00 static int tolua_Cocos2d_glUniformMatrix4fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isboolean(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); bool arg1 = (bool)tolua_toboolean(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); float* floatArray = new float[arg2]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg2; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 4, i, 0); } glUniformMatrix4fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUniformMatrix4fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glUseProgram */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glUseProgram00 static int tolua_Cocos2d_glUseProgram00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); glUseProgram((GLuint)arg0 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glUseProgram'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glValidateProgram */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glValidateProgram00 static int tolua_Cocos2d_glValidateProgram00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); glValidateProgram((GLuint)arg0 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glValidateProgram'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttrib1f */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttrib1f00 static int tolua_Cocos2d_glVertexAttrib1f00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); glVertexAttrib1f((GLuint)arg0 , (GLfloat)arg1 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttrib1f'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttrib1fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttrib1fvf00 static int tolua_Cocos2d_glVertexAttrib1fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); float* floatArray = new float[arg1]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg1; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 3, i, 0); } glVertexAttrib1fv((GLuint)arg0 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttrib1fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttrib2f */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttrib2f00 static int tolua_Cocos2d_glVertexAttrib2f00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); glVertexAttrib2f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttrib2f'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttrib2fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttrib2fv00 static int tolua_Cocos2d_glVertexAttrib2fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); float* floatArray = new float[arg1]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg1; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 3, i, 0); } glVertexAttrib2fv((GLuint)arg0 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttrib2fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttrib3f */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttrib3f00 static int tolua_Cocos2d_glVertexAttrib3f00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); glVertexAttrib3f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttrib3f'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttrib3fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttrib3fv00 static int tolua_Cocos2d_glVertexAttrib3fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); float* floatArray = new float[arg1]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg1; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 3, i, 0); } glVertexAttrib3fv((GLuint)arg0 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttrib3fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttrib4f */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttrib4f00 static int tolua_Cocos2d_glVertexAttrib4f00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 6, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); int arg4 = (int)tolua_tonumber(tolua_S, 5, 0); glVertexAttrib4f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttrib4f'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttrib4fv */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttrib4fv00 static int tolua_Cocos2d_glVertexAttrib4fv00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 4, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); float* floatArray = new float[arg1]; if (NULL == floatArray) { return 0; } for (int i = 1; i <= arg1; i++) { floatArray[i-1] = (float)tolua_tofieldnumber(tolua_S, 3, i, 0); } glVertexAttrib4fv((GLuint)arg0 , (GLfloat*)floatArray ); CC_SAFE_DELETE_ARRAY(floatArray); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttrib4fv'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glVertexAttribPointer */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glVertexAttribPointer00 static int tolua_Cocos2d_glVertexAttribPointer00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isboolean(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || !tolua_isnumber(tolua_S, 6, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 7, &tolua_err) ) goto tolua_lerror; else #endif { unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); unsigned int arg2 = (unsigned int)tolua_tonumber(tolua_S, 3, 0); bool arg3 = tolua_toboolean(tolua_S, 4, 0); int arg4 = (int)tolua_tonumber(tolua_S, 5, 0); //int arg5 = (int)tolua_tonumber(tolua_S, 7, 0); glVertexAttribPointer((GLuint)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLboolean)arg3 , (GLsizei)arg4 , (GLvoid*)NULL); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glVertexAttribPointer'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glViewport */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glViewport00 static int tolua_Cocos2d_glViewport00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 5, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); int arg1 = (int)tolua_tonumber(tolua_S, 2, 0); int arg2 = (int)tolua_tonumber(tolua_S, 3, 0); int arg3 = (int)tolua_tonumber(tolua_S, 4, 0); glViewport((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glViewport'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: glEnableVertexAttribs */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_glEnableVertexAttribs00 static int tolua_Cocos2d_glEnableVertexAttribs00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err) ) goto tolua_lerror; else #endif { int arg0 = (int)tolua_tonumber(tolua_S, 1, 0); GL::enableVertexAttribs(arg0); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'glEnableVertexAttribs'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: DrawPoint in the DrawPrimitives namespace */ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_ccDrawPoint00 static int tolua_cocos2d_DrawPrimitives_drawPoint00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_istable(tolua_S,1,0, &tolua_err) || !tolua_isnoobj(tolua_S,2, &tolua_err) ) goto tolua_lerror; else #endif { Point point; if(luaval_to_point(tolua_S, 1, &point)) { DrawPrimitives::drawPoint(point); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawPoint'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawPoints in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_DrawPoints00 static int tolua_cocos2d_DrawPrimitives_drawPoints00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { unsigned int numberOfPoints = ((unsigned int) tolua_tonumber(tolua_S,2,0)); if (numberOfPoints > 0) { Point* points = new Point[numberOfPoints]; if (NULL == points) return 0; for (int i = 0; i < numberOfPoints; i++) { lua_pushnumber(tolua_S,i + 1); lua_gettable(tolua_S,1); if (!tolua_istable(tolua_S,-1, 0, &tolua_err)) { CC_SAFE_DELETE_ARRAY(points); goto tolua_lerror; } if(!luaval_to_point(tolua_S, lua_gettop(tolua_S), &points[i])) { lua_pop(tolua_S, 1); CC_SAFE_DELETE_ARRAY(points); return 0; } lua_pop(tolua_S, 1); } DrawPrimitives::drawPoints(points, numberOfPoints); CC_SAFE_DELETE_ARRAY(points); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawPoints'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawLine in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawLine00 static int tolua_cocos2d_DrawPrimitives_drawLine00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0,&tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { Point origin; if (!luaval_to_point(tolua_S, 1, &origin)) return 0; Point destination; if (!luaval_to_point(tolua_S, 2, &destination)) return 0; DrawPrimitives::drawLine(origin,destination); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawLine'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawRect in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawRect00 static int tolua_cocos2d_DrawPrimitives_drawRect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0,&tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { Point origin; if (!luaval_to_point(tolua_S, 1, &origin)) return 0; Point destination; if (!luaval_to_point(tolua_S, 2, &destination)) return 0; DrawPrimitives::drawRect(origin,destination); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawRect'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawSolidRect in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_Cocos2d_DrawPrimitives_drawSolidRect00 static int tolua_cocos2d_DrawPrimitives_drawSolidRect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0, &tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Point origin; if (!luaval_to_point(tolua_S, 1, &origin)) return 0; Point destination; if (!luaval_to_point(tolua_S, 2, &destination)) return 0; Color4F color; if (!luaval_to_color4f(tolua_S, 3, &color)) return 0; DrawPrimitives::drawSolidRect(origin,destination,color); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawSolidRect'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawPoly in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawPoly00 static int tolua_cocos2d_DrawPrimitives_drawPoly00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isboolean(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { unsigned int numOfVertices = ((unsigned int) tolua_tonumber(tolua_S,2,0)); bool closePolygon = ((bool) tolua_toboolean(tolua_S,3,0)); if (numOfVertices > 0) { Point* points = new Point[numOfVertices]; if (NULL == points) return 0; for (int i = 0; i < numOfVertices; i++) { lua_pushnumber(tolua_S,i + 1); lua_gettable(tolua_S,1); if (!tolua_istable(tolua_S,-1, 0, &tolua_err)) { CC_SAFE_DELETE_ARRAY(points); goto tolua_lerror; } if(!luaval_to_point(tolua_S, lua_gettop(tolua_S), &points[i])) { lua_pop(tolua_S, 1); CC_SAFE_DELETE_ARRAY(points); return 0; } lua_pop(tolua_S, 1); } DrawPrimitives::drawPoly(points,numOfVertices,closePolygon); CC_SAFE_DELETE_ARRAY(points); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'ccDrawPoly'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawSolidPoly in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawSolidPoly00 static int tolua_cocos2d_DrawPrimitives_drawSolidPoly00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { unsigned int numberOfPoints = ((unsigned int) tolua_tonumber(tolua_S,2,0)); if (numberOfPoints > 0) { Point* points = new Point[numberOfPoints]; if (NULL == points) return 0; for (int i = 0; i < numberOfPoints; i++) { lua_pushnumber(tolua_S,i + 1); lua_gettable(tolua_S,1); if (!tolua_istable(tolua_S,-1, 0, &tolua_err)) { CC_SAFE_DELETE_ARRAY(points); goto tolua_lerror; } if(!luaval_to_point(tolua_S, lua_gettop(tolua_S), &points[i])) { lua_pop(tolua_S, 1); CC_SAFE_DELETE_ARRAY(points); return 0; } lua_pop(tolua_S, 1); } Color4F color; if (!luaval_to_color4f(tolua_S, 3, &color)) { CC_SAFE_DELETE_ARRAY(points); return 0; } DrawPrimitives::drawSolidPoly(points,numberOfPoints,color); CC_SAFE_DELETE_ARRAY(points); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawSolidPoly'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawCircle in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawCircle00 static int tolua_cocos2d_DrawPrimitives_drawCircle00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isboolean(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,1,&tolua_err) || !tolua_isnumber(tolua_S,7,1,&tolua_err) || !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else #endif { Point center; if (!luaval_to_point(tolua_S, 1, ¢er)) return 0; float radius = ((float) tolua_tonumber(tolua_S,2,0)); float angle = ((float) tolua_tonumber(tolua_S,3,0)); unsigned int segments = ((unsigned int) tolua_tonumber(tolua_S,4,0)); bool drawLineToCenter = ((bool) tolua_toboolean(tolua_S,5,0)); float xScale = ((float) tolua_tonumber(tolua_S,6,1.0f)); float yScale = ((float) tolua_tonumber(tolua_S,7,1.0f)); DrawPrimitives::drawCircle(center,radius,angle,segments,drawLineToCenter,xScale,yScale); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawCircle'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawSolidCircle in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawSolidCircle00 static int tolua_cocos2d_DrawPrimitives_drawSolidCircle00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,1,&tolua_err) || !tolua_isnumber(tolua_S,6,1,&tolua_err) || !tolua_isnoobj(tolua_S,7,&tolua_err) ) goto tolua_lerror; else #endif { Point center; if (!luaval_to_point(tolua_S, 1, ¢er)) return 0; float radius = ((float) tolua_tonumber(tolua_S,2,0)); float angle = ((float) tolua_tonumber(tolua_S,3,0)); unsigned int segments = ((unsigned int) tolua_tonumber(tolua_S,4,0)); float scaleX = ((float) tolua_tonumber(tolua_S,5,1.0f)); float scaleY = ((float) tolua_tonumber(tolua_S,6,1.0f)); DrawPrimitives::drawSolidCircle(center,radius,angle,segments,scaleX,scaleY); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawSolidCircle'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawQuadBezier in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawQuadBezier00 static int tolua_cocos2d_DrawPrimitives_drawQuadBezier00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0, &tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S,4, 0, &tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { Point origin; if (!luaval_to_point(tolua_S, 1, &origin)) return 0; Point control; if (!luaval_to_point(tolua_S, 2, &control)) return 0; Point destination; if (!luaval_to_point(tolua_S, 3, &destination)) return 0; unsigned int segments = ((unsigned int) tolua_tonumber(tolua_S,4,0)); DrawPrimitives::drawQuadBezier(origin,control,destination,segments); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawQuadBezier'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawCubicBezier in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawCubicBezier00 static int tolua_cocos2d_DrawPrimitives_drawCubicBezier00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0, &tolua_err) || !tolua_istable(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S,5, 0, &tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else #endif { Point origin; if (!luaval_to_point(tolua_S, 1, &origin)) return 0; Point control1; if (!luaval_to_point(tolua_S, 2, &control1)) return 0; Point control2; if (!luaval_to_point(tolua_S, 3, &control2)) return 0; Point destination; if (!luaval_to_point(tolua_S, 4, &destination)) return 0; unsigned int segments = ((unsigned int) tolua_tonumber(tolua_S,5,0)); DrawPrimitives::drawCubicBezier(origin,control1,control2,destination,segments); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawCubicBezier'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawCatmullRom in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawCatmullRom00 int tolua_cocos2d_DrawPrimitives_drawCatmullRom00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { int num = 0; Point *arr = NULL; if (!luaval_to_array_of_Point(tolua_S, 1, &arr, &num)) return 0; PointArray* points = PointArray::create(num); if (NULL == points) { free(arr); return 0; } for( int i = 0; i < num; i++) { points->addControlPoint(arr[i]); } free(arr); unsigned int segments = ((unsigned int) tolua_tonumber(tolua_S,2,0)); DrawPrimitives::drawCatmullRom(points,segments); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawCatmullRom'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawCardinalSpline in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawCardinalSpline00 int tolua_cocos2d_DrawPrimitives_drawCardinalSpline00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { int num = 0; Point *arr = NULL; if (!luaval_to_array_of_Point(tolua_S, 1, &arr, &num)) return 0; PointArray* config = PointArray::create(num); if (NULL == config) { free(arr); return 0; } for( int i = 0; i < num; i++) { config->addControlPoint(arr[i]); } free(arr); float tension = ((float) tolua_tonumber(tolua_S,2,0)); unsigned int segments = ((unsigned int) tolua_tonumber(tolua_S,3,0)); DrawPrimitives::drawCardinalSpline(config,tension,segments); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawCardinalSpline'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawColor4B in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawColor4B00 static int tolua_cocos2d_DrawPrimitives_drawColor4B00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { unsigned char r = (( unsigned char) tolua_tonumber(tolua_S,1,0)); unsigned char g = (( unsigned char) tolua_tonumber(tolua_S,2,0)); unsigned char b = (( unsigned char) tolua_tonumber(tolua_S,3,0)); unsigned char a = (( unsigned char) tolua_tonumber(tolua_S,4,0)); DrawPrimitives::setDrawColor4B(r,g,b,a); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawColor4B'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: drawColor4F in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_drawColor4F00 static int tolua_cocos2d_DrawPrimitives_drawColor4F00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { unsigned char r = (( unsigned char) tolua_tonumber(tolua_S,1,0)); unsigned char g = (( unsigned char) tolua_tonumber(tolua_S,2,0)); unsigned char b = (( unsigned char) tolua_tonumber(tolua_S,3,0)); unsigned char a = (( unsigned char) tolua_tonumber(tolua_S,4,0)); DrawPrimitives::setDrawColor4F(r,g,b,a); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawColor4F'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: setPointSize in the DrawPrimitives namespace*/ #ifndef TOLUA_DISABLE_tolua_cocos2d_DrawPrimitives_setPointSize00 static int tolua_cocos2d_DrawPrimitives_setPointSize00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { float pointSize = (( float) tolua_tonumber(tolua_S,1,0)); DrawPrimitives::setPointSize(pointSize); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setPointSize'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE TOLUA_API int tolua_opengl_open(lua_State* tolua_S) { tolua_open(tolua_S); tolua_reg_gl_type(tolua_S); tolua_module(tolua_S,"cc",0); tolua_beginmodule(tolua_S,"cc"); tolua_cclass(tolua_S,"GLNode","cc.GLNode","cc.Node",tolua_collect_GLNode); tolua_beginmodule(tolua_S,"GLNode"); tolua_function(tolua_S, "create", tolua_Cocos2d_GLNode_create00); tolua_function(tolua_S, "setShaderProgram", tolua_Cocos2d_GLNode_setShaderProgram00); tolua_endmodule(tolua_S); tolua_module(tolua_S, "DrawPrimitives", 0); tolua_beginmodule(tolua_S,"DrawPrimitives"); tolua_function(tolua_S,"drawPoint",tolua_cocos2d_DrawPrimitives_drawPoint00); tolua_function(tolua_S,"drawPoints",tolua_cocos2d_DrawPrimitives_drawPoints00); tolua_function(tolua_S,"drawLine",tolua_cocos2d_DrawPrimitives_drawLine00); tolua_function(tolua_S,"drawRect",tolua_cocos2d_DrawPrimitives_drawRect00); tolua_function(tolua_S,"drawSolidRect",tolua_cocos2d_DrawPrimitives_drawSolidRect00); tolua_function(tolua_S,"drawPoly",tolua_cocos2d_DrawPrimitives_drawPoly00); tolua_function(tolua_S,"drawSolidPoly",tolua_cocos2d_DrawPrimitives_drawSolidPoly00); tolua_function(tolua_S,"drawCircle",tolua_cocos2d_DrawPrimitives_drawCircle00); tolua_function(tolua_S,"drawSolidCircle",tolua_cocos2d_DrawPrimitives_drawSolidCircle00); tolua_function(tolua_S,"drawQuadBezier",tolua_cocos2d_DrawPrimitives_drawQuadBezier00); tolua_function(tolua_S,"drawCubicBezier",tolua_cocos2d_DrawPrimitives_drawCubicBezier00); tolua_function(tolua_S,"drawCatmullRom",tolua_cocos2d_DrawPrimitives_drawCatmullRom00); tolua_function(tolua_S,"drawCardinalSpline",tolua_cocos2d_DrawPrimitives_drawCardinalSpline00); tolua_function(tolua_S,"drawColor4B",tolua_cocos2d_DrawPrimitives_drawColor4B00); tolua_function(tolua_S,"drawColor4F",tolua_cocos2d_DrawPrimitives_drawColor4F00); tolua_function(tolua_S,"setPointSize",tolua_cocos2d_DrawPrimitives_setPointSize00); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); tolua_module(tolua_S, "gl", 0); tolua_beginmodule(tolua_S,"gl"); tolua_function(tolua_S, "getSupportedExtensions", tolua_Cocos2d_glGetSupportedExtensions00); tolua_function(tolua_S, "activeTexture", tolua_Cocos2d_glActiveTexture00); tolua_function(tolua_S, "_attachShader", tolua_Cocos2d_glAttachShader00); tolua_function(tolua_S, "_bindAttribLocation", tolua_Cocos2d_glBindAttribLocation00); tolua_function(tolua_S, "_bindBuffer", tolua_Cocos2d_glBindBuffer00); tolua_function(tolua_S, "_bindFramebuffer", tolua_Cocos2d_glBindBuffer00); tolua_function(tolua_S, "_bindRenderbuffer", tolua_Cocos2d_glBindRenderbuffer00); tolua_function(tolua_S, "_bindTexture", tolua_Cocos2d_glBindTexture00); tolua_function(tolua_S, "blendColor", tolua_Cocos2d_glBlendColor00); tolua_function(tolua_S, "blendEquation", tolua_Cocos2d_glBlendEquation00); tolua_function(tolua_S, "blendEquationSeparate", tolua_Cocos2d_glBlendEquationSeparate00); tolua_function(tolua_S, "blendFunc", tolua_Cocos2d_glBlendFunc00); tolua_function(tolua_S, "blendFuncSeparate", tolua_Cocos2d_glBlendFuncSeparate00); tolua_function(tolua_S, "bufferData", tolua_Cocos2d_glBufferData00); tolua_function(tolua_S, "bufferSubData", tolua_Cocos2d_glBufferSubData00); tolua_function(tolua_S, "checkFramebufferStatus", tolua_Cocos2d_glCheckFramebufferStatus00); tolua_function(tolua_S, "clear", tolua_Cocos2d_glClear00); tolua_function(tolua_S, "clearColor", tolua_Cocos2d_glClearColor00); tolua_function(tolua_S, "clearDepthf", tolua_Cocos2d_glClearDepthf00); tolua_function(tolua_S, "clearStencil", tolua_Cocos2d_glClearStencil00); tolua_function(tolua_S, "colorMask", tolua_Cocos2d_glColorMask00); tolua_function(tolua_S, "_compileShader", tolua_Cocos2d_glCompileShader00); tolua_function(tolua_S, "compressedTexImage2D", tolua_Cocos2d_glCompressedTexImage2D00); tolua_function(tolua_S, "compressedTexSubImage2D", tolua_Cocos2d_glCompressedTexSubImage2D00); tolua_function(tolua_S, "copyTexImage2D", tolua_Cocos2d_glCopyTexImage2D00); tolua_function(tolua_S, "copyTexSubImage2D", tolua_Cocos2d_glCopyTexSubImage2D00); tolua_function(tolua_S, "_createProgram", tolua_Cocos2d_glCreateProgram00); tolua_function(tolua_S, "_createShader", tolua_Cocos2d_glCreateShader00); tolua_function(tolua_S, "cullFace", tolua_Cocos2d_glCullFace00); tolua_function(tolua_S, "_deleteBuffer", tolua_Cocos2d_glDeleteBuffers00); tolua_function(tolua_S, "_deleteFramebuffer", tolua_Cocos2d_glDeleteFramebuffers00); tolua_function(tolua_S, "_deleteProgram", tolua_Cocos2d_glDeleteProgram00); tolua_function(tolua_S, "_deleteRenderbuffer", tolua_Cocos2d_glDeleteRenderbuffers00); tolua_function(tolua_S, "_deleteShader", tolua_Cocos2d_glDeleteShader00); tolua_function(tolua_S, "_deleteTexture", tolua_Cocos2d_glDeleteTextures00); tolua_function(tolua_S, "depthFunc", tolua_Cocos2d_glDepthFunc00); tolua_function(tolua_S, "depthMask", tolua_Cocos2d_glDepthMask00); tolua_function(tolua_S, "depthRangef", tolua_Cocos2d_glDepthRangef00); tolua_function(tolua_S, "detachShader", tolua_Cocos2d_glDetachShader00); tolua_function(tolua_S, "disable", tolua_Cocos2d_glDisable00); tolua_function(tolua_S, "disableVertexAttribArray", tolua_Cocos2d_glDisableVertexAttribArray00); tolua_function(tolua_S, "drawArrays", tolua_Cocos2d_glDrawArrays00); tolua_function(tolua_S, "drawElements", tolua_Cocos2d_glDrawElements00); tolua_function(tolua_S, "enable", tolua_Cocos2d_glEnable00); tolua_function(tolua_S, "enableVertexAttribArray", tolua_Cocos2d_glEnableVertexAttribArray00); tolua_function(tolua_S, "finish", tolua_Cocos2d_glFinish00); tolua_function(tolua_S, "flush", tolua_Cocos2d_glFlush00); tolua_function(tolua_S, "framebufferRenderbuffer", tolua_Cocos2d_glFramebufferRenderbuffer00); tolua_function(tolua_S, "framebufferTexture2D", tolua_Cocos2d_glFramebufferTexture2D00); tolua_function(tolua_S, "frontFace", tolua_Cocos2d_glFrontFace00); tolua_function(tolua_S, "_createBuffer", tolua_Cocos2d_glGenBuffers00); tolua_function(tolua_S, "_createFramebuffer", tolua_Cocos2d_glGenFramebuffers00); tolua_function(tolua_S, "_createRenderbuffer", tolua_Cocos2d_glGenRenderbuffers00); tolua_function(tolua_S, "_createTexture", tolua_Cocos2d_glGenTextures00); tolua_function(tolua_S, "generateMipmap", tolua_Cocos2d_glGenerateMipmap00); tolua_function(tolua_S, "_getActiveAttrib", tolua_Cocos2d_glGetActiveAttrib00); tolua_function(tolua_S, "_getActiveUniform", tolua_Cocos2d_glGetActiveUniform00); tolua_function(tolua_S, "_getAttachedShaders", tolua_Cocos2d_glGetAttachedShaders00); tolua_function(tolua_S, "_getAttribLocation", tolua_Cocos2d_glGetAttribLocation00); tolua_function(tolua_S, "getError", tolua_Cocos2d_glGetError00); tolua_function(tolua_S, "_getProgramInfoLog", tolua_Cocos2d_glGetProgramInfoLog00); tolua_function(tolua_S, "_getProgramParameter", tolua_Cocos2d_glGetProgramiv00); tolua_function(tolua_S, "_getShaderInfoLog", tolua_Cocos2d_glGetShaderInfoLog00); tolua_function(tolua_S, "_getShaderSource", tolua_Cocos2d_glGetShaderSource00); tolua_function(tolua_S, "_getShaderParameter", tolua_Cocos2d_glGetShaderiv00); tolua_function(tolua_S, "getTexParameter", tolua_Cocos2d_glGetTexParameterfv00); tolua_function(tolua_S, "_getUniformLocation", tolua_Cocos2d_glGetUniformLocation00); tolua_function(tolua_S, "_getUniform", tolua_Cocos2d_glGetUniformfv00); tolua_function(tolua_S, "hint", tolua_Cocos2d_glHint00); tolua_function(tolua_S, "isBuffer",tolua_Cocos2d_glIsBuffer00); tolua_function(tolua_S, "isEnabled", tolua_Cocos2d_glIsEnabled00); tolua_function(tolua_S, "isFramebuffer", tolua_Cocos2d_glIsFramebuffer00); tolua_function(tolua_S, "isProgram", tolua_Cocos2d_glIsProgram00); tolua_function(tolua_S, "isRenderbuffer", tolua_Cocos2d_glIsRenderbuffer00); tolua_function(tolua_S, "isShader", tolua_Cocos2d_glIsShader00); tolua_function(tolua_S, "isTexture", tolua_Cocos2d_glIsTexture00); tolua_function(tolua_S, "lineWidth", tolua_Cocos2d_glLineWidth00); tolua_function(tolua_S, "_linkProgram", tolua_Cocos2d_glLinkProgram00); tolua_function(tolua_S, "pixelStorei", tolua_Cocos2d_glPixelStorei00); tolua_function(tolua_S, "polygonOffset", tolua_Cocos2d_glPolygonOffset00); tolua_function(tolua_S, "readPixels", tolua_Cocos2d_glReadPixels00); tolua_function(tolua_S, "releaseShaderCompiler", tolua_Cocos2d_glReleaseShaderCompiler00); tolua_function(tolua_S, "renderbufferStorage", tolua_Cocos2d_glRenderbufferStorage00); tolua_function(tolua_S, "sampleCoverage", tolua_Cocos2d_glSampleCoverage00); tolua_function(tolua_S, "scissor", tolua_Cocos2d_glScissor00); tolua_function(tolua_S, "_shaderSource", tolua_Cocos2d_glShaderSource00); tolua_function(tolua_S, "stencilFunc", tolua_Cocos2d_glStencilFunc00); tolua_function(tolua_S, "stencilFuncSeparate", tolua_Cocos2d_glStencilFuncSeparate00); tolua_function(tolua_S, "stencilMask", tolua_Cocos2d_glStencilMask00); tolua_function(tolua_S, "stencilMaskSeparate", tolua_Cocos2d_glStencilMaskSeparate00); tolua_function(tolua_S, "stencilOp", tolua_Cocos2d_glStencilOp00); tolua_function(tolua_S, "stencilOpSeparate", tolua_Cocos2d_glStencilOpSeparate00); tolua_function(tolua_S, "_texImage2D", tolua_Cocos2d_glTexImage2D00); tolua_function(tolua_S, "texParameterf", tolua_Cocos2d_glTexParameterf00); tolua_function(tolua_S, "texParameteri", tolua_Cocos2d_glTexParameteri00); tolua_function(tolua_S, "_texSubImage2D", tolua_Cocos2d_glTexSubImage2D00); tolua_function(tolua_S, "uniform1f", tolua_Cocos2d_glUniform1f00); tolua_function(tolua_S, "uniform1fv", tolua_Cocos2d_glUniform1fv00); tolua_function(tolua_S, "uniform1i", tolua_Cocos2d_glUniform1i00); tolua_function(tolua_S, "uniform1iv", tolua_Cocos2d_glUniform1iv00); tolua_function(tolua_S, "uniform2f", tolua_Cocos2d_glUniform2f00); tolua_function(tolua_S, "uniform2fv", tolua_Cocos2d_glUniform2fv00); tolua_function(tolua_S, "uniform2i", tolua_Cocos2d_glUniform2i00); tolua_function(tolua_S, "uniform2iv", tolua_Cocos2d_glUniform2iv00); tolua_function(tolua_S, "uniform3f", tolua_Cocos2d_glUniform3f00); tolua_function(tolua_S, "uniform3fv", tolua_Cocos2d_glUniform3fv00); tolua_function(tolua_S, "uniform3i", tolua_Cocos2d_glUniform3i00); tolua_function(tolua_S, "uniform3iv", tolua_Cocos2d_glUniform3iv00); tolua_function(tolua_S, "uniform4f", tolua_Cocos2d_glUniform4f00); tolua_function(tolua_S, "uniform4fv", tolua_Cocos2d_glUniform4fv00); tolua_function(tolua_S, "uniform4i", tolua_Cocos2d_glUniform4i00); tolua_function(tolua_S, "uniform4iv", tolua_Cocos2d_glUniform4iv00); tolua_function(tolua_S, "uniformMatrix2fv", tolua_Cocos2d_glUniformMatrix2fv00); tolua_function(tolua_S, "uniformMatrix3fv", tolua_Cocos2d_glUniformMatrix3fv00); tolua_function(tolua_S, "uniformMatrix4fv", tolua_Cocos2d_glUniformMatrix4fv00); tolua_function(tolua_S, "_useProgram", tolua_Cocos2d_glUseProgram00); tolua_function(tolua_S, "_validateProgram", tolua_Cocos2d_glValidateProgram00); tolua_function(tolua_S, "vertexAttrib1f", tolua_Cocos2d_glVertexAttrib1f00); tolua_function(tolua_S, "vertexAttrib1fv", tolua_Cocos2d_glVertexAttrib1fv00); tolua_function(tolua_S, "vertexAttrib2f", tolua_Cocos2d_glVertexAttrib2f00); tolua_function(tolua_S, "vertexAttrib2fv", tolua_Cocos2d_glVertexAttrib2fv00); tolua_function(tolua_S, "vertexAttrib3f", tolua_Cocos2d_glVertexAttrib3f00); tolua_function(tolua_S, "vertexAttrib3fv", tolua_Cocos2d_glVertexAttrib3fv00); tolua_function(tolua_S, "vertexAttrib4f", tolua_Cocos2d_glVertexAttrib4f00); tolua_function(tolua_S, "vertexAttrib4fv", tolua_Cocos2d_glVertexAttrib4fv00); tolua_function(tolua_S, "vertexAttribPointer", tolua_Cocos2d_glVertexAttribPointer00); tolua_function(tolua_S, "viewport", tolua_Cocos2d_glViewport00); tolua_function(tolua_S, "glEnableVertexAttribs", tolua_Cocos2d_glEnableVertexAttribs00); tolua_endmodule(tolua_S); return 1; } static int tolua_Cocos2d_GLNode_registerScriptDrawHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.GLNode",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err)) goto tolua_lerror; else #endif { GLNode* glNode = (GLNode*) tolua_tousertype(tolua_S,1,0); LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)glNode, handler, ScriptHandlerMgr::HandlerType::GL_NODE_DRAW); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptDrawHandler'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.GLNode",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err)) goto tolua_lerror; else #endif { GLNode* glNode = (GLNode*)tolua_tousertype(tolua_S,1,0); ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)glNode,ScriptHandlerMgr::HandlerType::GL_NODE_DRAW); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptDrawHandler'.",&tolua_err); return 0; #endif } int register_glnode_manual(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; lua_pushstring(tolua_S,"cc.GLNode"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"registerScriptDrawHandler"); lua_pushcfunction(tolua_S,tolua_Cocos2d_GLNode_registerScriptDrawHandler00); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"unregisterScriptDrawHandler"); lua_pushcfunction(tolua_S,tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); return 1; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/LuaOpengl.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __LUA_OPENGL_H__ #define __LUA_OPENGL_H__ #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include "CCNode.h" class GLNode:public cocos2d::Node { virtual void draw() override; }; TOLUA_API int tolua_opengl_open(lua_State* tolua_S); TOLUA_API int register_glnode_manual(lua_State* tolua_S); #endif //__LUA_OPENGL_H__ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include #include #include "LuaScriptHandlerMgr.h" #include "cocos2d.h" #include "extensions/cocos-ext.h" #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" #include "Lua_web_socket.h" #include "LuaOpengl.h" using namespace cocos2d; using namespace cocos2d::extension; NS_CC_BEGIN ScheduleHandlerDelegate* ScheduleHandlerDelegate::create() { ScheduleHandlerDelegate *ret = new ScheduleHandlerDelegate(); if (NULL != ret ) { ret->autorelease(); return ret; } else { CC_SAFE_DELETE(ret); return NULL; } } void ScheduleHandlerDelegate::scheduleFunc(float elapse) { } void ScheduleHandlerDelegate::update(float elapse) { } LuaCallFunc * LuaCallFunc::create(const std::function& func) { auto ret = new LuaCallFunc(); if (ret && ret->initWithFunction(func) ) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return NULL; } void LuaCallFunc::execute() { if (_functionLua) { _functionLua((void*)this,_target); } else { CallFuncN::execute(); } } bool LuaCallFunc::initWithFunction(const std::function &func) { _functionLua = func; return true; } LuaCallFunc* LuaCallFunc::clone() const { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::CALLFUNC); if (0 == handler) return NULL; auto ret = new LuaCallFunc(); if( _functionLua ) { ret->initWithFunction(_functionLua); } ret->autorelease(); int newscriptHandler = cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)ret, newscriptHandler, ScriptHandlerMgr::HandlerType::CALLFUNC); return ret; } ScriptHandlerMgr* ScriptHandlerMgr::_scriptHandlerMgr = NULL; ScriptHandlerMgr::ScriptHandlerMgr() { } ScriptHandlerMgr::~ScriptHandlerMgr() { CC_SAFE_DELETE(_scriptHandlerMgr); } ScriptHandlerMgr* ScriptHandlerMgr::getInstance() { if (NULL == _scriptHandlerMgr) { _scriptHandlerMgr = new ScriptHandlerMgr(); _scriptHandlerMgr->init(); } return _scriptHandlerMgr; } void ScriptHandlerMgr::init() { _mapObjectHandlers.clear(); } void ScriptHandlerMgr::addObjectHandler(void* object,int handler,ScriptHandlerMgr::HandlerType handlerType) { if (NULL == object) return; //may be not need removeObjectHandler(object,handlerType); auto iter = _mapObjectHandlers.find(object); VecHandlerPairs vecHandlers; vecHandlers.clear(); if (_mapObjectHandlers.end() != iter) { vecHandlers = iter->second; } HandlerPair eventHanler = std::make_pair(handlerType, handler); vecHandlers.push_back(eventHanler); _mapObjectHandlers[object] = vecHandlers; } void ScriptHandlerMgr::removeObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType) { if (NULL == object || _mapObjectHandlers.empty()) return; auto iterMap = _mapObjectHandlers.find(object); if (_mapObjectHandlers.end() == iterMap) return; if (iterMap->second.empty()) return; auto iterVec = iterMap->second.begin(); bool exist = false; for (; iterVec != iterMap->second.end(); ++iterVec) { if (iterVec->first == handlerType) { exist = true; break; } } if (exist) { LuaEngine::getInstance()->removeScriptHandler(iterVec->second); iterMap->second.erase(iterVec); } } int ScriptHandlerMgr::getObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType) { if (NULL == object || _mapObjectHandlers.empty() ) return 0; auto iter = _mapObjectHandlers.find(object); if (_mapObjectHandlers.end() != iter) { auto iterVec = (iter->second).begin(); for (; iterVec != (iter->second).end(); iterVec++) { if (iterVec->first == handlerType) { return iterVec->second; } } } return 0; } void ScriptHandlerMgr::removeObjectAllHandlers(void* object) { if (NULL == object || _mapObjectHandlers.empty()) return; auto iter = _mapObjectHandlers.find(object); if (_mapObjectHandlers.end() != iter) { if (!iter->second.empty()) { auto iterVec = iter->second.begin(); for (; iterVec != iter->second.end(); ++iterVec) { LuaEngine::getInstance()->removeScriptHandler(iterVec->second); } (iter->second).clear(); } _mapObjectHandlers.erase(iter); } } NS_CC_END static void tolua_reg_script_handler_mgr_type(lua_State* tolua_S) { tolua_usertype(tolua_S, "ScheduleHandlerDelegate"); tolua_usertype(tolua_S, "ScriptHandlerMgr"); } /* method: getInstance of class ScriptHandlerMgr */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_ScriptHandlerMgr_getInstance00 static int tolua_Cocos2d_ScriptHandlerMgr_getInstance00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { ScriptHandlerMgr* tolua_ret = (ScriptHandlerMgr*) ScriptHandlerMgr::getInstance(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"ScriptHandlerMgr"); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getInstance'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: registerScriptHandler of class ScriptHandlerMgr */ static int tolua_Cocos2d_ScriptHandlerMgr_registerScriptHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) || !tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) || !toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { cocos2d::ScriptHandlerMgr* scriptHanlderMgr = static_cast(tolua_tousertype(tolua_S,1,0)); #ifndef TOLUA_RELEASE if (nullptr == scriptHanlderMgr) { tolua_error(tolua_S,"invalid 'scriptHanlderMgr' in function 'tolua_Cocos2d_ScriptHandlerMgr_registerScriptHandler00'\n", NULL); return 0; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,3,0); ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType)(int)tolua_tonumber(tolua_S, 4, 0); scriptHanlderMgr->addObjectHandler(tolua_tousertype(tolua_S, 2, 0), handler,handlerType); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } /* method: unregisterScriptHandler of class ScriptHandlerMgr */ static int tolua_Cocos2d_ScriptHandlerMgr_unregisterScriptHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) || !tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { cocos2d::ScriptHandlerMgr* scriptHanlderMgr = static_cast(tolua_tousertype(tolua_S,1,0)); #ifndef TOLUA_RELEASE if (nullptr == scriptHanlderMgr) { tolua_error(tolua_S,"invalid 'scriptHanlderMgr' in function 'tolua_Cocos2d_ScriptHandlerMgr_unregisterScriptHandler00'\n", NULL); return 0; } #endif ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType)(int)tolua_tonumber(tolua_S, 3, 0); scriptHanlderMgr->removeObjectHandler(tolua_tousertype(tolua_S, 2, 0), handlerType); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); return 0; #endif } /* method: removeObjectAllHandlers of class ScriptHandlerMgr */ static int tolua_Cocos2d_ScriptHandlerMgr_removeObjectAllHandlers00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) || !tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { cocos2d::ScriptHandlerMgr* scriptHanlderMgr = static_cast(tolua_tousertype(tolua_S,1,0)); #ifndef TOLUA_RELEASE if (nullptr == scriptHanlderMgr) { tolua_error(tolua_S,"invalid 'scriptHanlderMgr' in function 'tolua_Cocos2d_ScriptHandlerMgr_removeObjectAllHandlers00'\n", NULL); return 0; } #endif scriptHanlderMgr->removeObjectAllHandlers(tolua_tousertype(tolua_S, 2, 0)); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeObjectAllHandlers'.",&tolua_err); return 0; #endif } TOLUA_API int tolua_script_handler_mgr_open(lua_State* tolua_S) { tolua_open(tolua_S); tolua_reg_script_handler_mgr_type(tolua_S); tolua_module(tolua_S, NULL,0); tolua_beginmodule(tolua_S, NULL); tolua_cclass(tolua_S,"ScriptHandlerMgr","ScriptHandlerMgr","",NULL); tolua_beginmodule(tolua_S, "ScriptHandlerMgr"); tolua_function(tolua_S, "getInstance", tolua_Cocos2d_ScriptHandlerMgr_getInstance00); tolua_function(tolua_S, "registerScriptHandler", tolua_Cocos2d_ScriptHandlerMgr_registerScriptHandler00); tolua_function(tolua_S, "unregisterScriptHandler", tolua_Cocos2d_ScriptHandlerMgr_unregisterScriptHandler00); tolua_function(tolua_S, "removeObjectAllHandlers", tolua_Cocos2d_ScriptHandlerMgr_removeObjectAllHandlers00); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); return 1; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __LUA_SCRIPT_HANDLER_MGR_H__ #define __LUA_SCRIPT_HANDLER_MGR_H__ extern "C" { #include "tolua++.h" } #include "CCObject.h" #include "ccMacros.h" #include "CCActionInstant.h" #include #include NS_CC_BEGIN class ScheduleHandlerDelegate; typedef std::vector VecShedule; typedef std::map MapNodeSchedules; class ScheduleHandlerDelegate:public cocos2d::Object { public: ScheduleHandlerDelegate():_isUpdateSchedule(false) {} virtual ~ScheduleHandlerDelegate() {} static ScheduleHandlerDelegate* create(); void scheduleFunc(float elapse); virtual void update(float elapse); void setUpdateSchedule(bool isUpdateSchedule){ _isUpdateSchedule = isUpdateSchedule; } bool isUpdateSchedule(){ return _isUpdateSchedule; } private: bool _isUpdateSchedule; }; class LuaCallFunc:public cocos2d::CallFuncN { public: LuaCallFunc():_functionLua(nullptr) {} virtual ~LuaCallFunc() {} static LuaCallFunc* create(const std::function& func); bool initWithFunction(const std::function& func); virtual LuaCallFunc* clone() const; virtual void execute() override; protected: /** */ std::function _functionLua; }; class ScriptHandlerMgr { public: enum class HandlerType: int { NODE = 0, MENU_CLICKED, CALLFUNC, SCHEDULE, TOUCHES, KEYPAD, ACCELEROMETER, CONTROL_TOUCH_DOWN, CONTROL_TOUCH_DRAG_INSIDE, CONTROL_TOUCH_DRAG_OUTSIDE, CONTROL_TOUCH_DRAG_ENTER, CONTROL_TOUCH_DRAG_EXIT, CONTROL_TOUCH_UP_INSIDE, CONTROL_TOUCH_UP_OUTSIDE, CONTROL_TOUCH_UP_CANCEL, CONTROL_VALUE_CHANGED, WEBSOCKET_OPEN, WEBSOCKET_MESSAGE, WEBSOCKET_CLOSE, WEBSOCKET_ERROR, GL_NODE_DRAW, SCROLLVIEW_SCROLL, SCROLLVIEW_ZOOM, TABLECELL_TOUCHED, TABLECELL_HIGHLIGHT, TABLECELL_UNHIGHLIGHT, TABLECELL_WILL_RECYCLE, TABLECELL_SIZE_FOR_INDEX, TABLECELL_AT_INDEX, TABLEVIEW_NUMS_OF_CELLS, XMLHTTPREQUEST_READY_STATE_CHANGE, ASSETSMANAGER_PROGRESS, ASSETSMANAGER_SUCCESS, ASSETSMANAGER_ERROR, STUDIO_EVENT_LISTENER, ARMATURE_EVENT, EVENT_ACC, EVENT_CUSTIOM, EVENT_KEYBOARD_PRESSED, EVENT_KEYBOARD_RELEASED, EVENT_TOUCH_BEGAN, EVENT_TOUCH_MOVED, EVENT_TOUCH_ENDED, EVENT_TOUCH_CANCELLED, EVENT_TOUCHES_BEGAN, EVENT_TOUCHES_MOVED, EVENT_TOUCHES_ENDED, EVENT_TOUCHES_CANCELLED, EVENT_MOUSE_DOWN, EVENT_MOUSE_UP, EVENT_MOUSE_MOVE, EVENT_MOUSE_SCROLL, EVENT_SPINE, EVENT_PHYSICS_CONTACT_BEGIN, EVENT_PHYSICS_CONTACT_PRESOLVE, EVENT_PHYSICS_CONTACT_POSTSOLVE, EVENT_PHYSICS_CONTACT_SEPERATE, }; typedef int Handler; typedef std::pair HandlerPair; typedef std::vector VecHandlerPairs; typedef std::map MapObjectHandlers; ScriptHandlerMgr(void); virtual ~ScriptHandlerMgr(void); static ScriptHandlerMgr* getInstance(void); void addObjectHandler(void* object,int handler,ScriptHandlerMgr::HandlerType handlerType); void removeObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType); int getObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType); void removeObjectAllHandlers(void* object); private: void init(void); static ScriptHandlerMgr* _scriptHandlerMgr; MapObjectHandlers _mapObjectHandlers; }; NS_CC_END TOLUA_API int tolua_script_handler_mgr_open(lua_State* tolua_S); #endif //__LUA_SCRIPT_HANDLER_MGR_H__ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/LuaSkeletonAnimation.cpp ================================================ /**************************************************************************** Copyright (c) 2013 Edward Zhou Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "LuaSkeletonAnimation.h" #include "cocos2d.h" #include "LuaScriptHandlerMgr.h" #include "CCLuaStack.h" #include "CCLuaEngine.h" using namespace spine; USING_NS_CC; static int SendSpineEventToLua(int nHandler, spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) { if (nHandler <= 0) { return 0; } if (NULL == ScriptEngineManager::getInstance()->getScriptEngine()) { return 0; } LuaStack *pStack = LuaEngine::getInstance()->getLuaStack(); if (NULL == pStack) { return 0; } lua_State *tolua_s = pStack->getLuaState(); if (NULL == tolua_s) { return 0; } int nRet = 0; spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex); std::string animationName = (entry && entry->animation) ? entry->animation->name : ""; std::string eventType = ""; switch (type) { case ANIMATION_START: eventType = "start"; break; case ANIMATION_END: eventType = "end"; break; case ANIMATION_COMPLETE: eventType = "complete"; break; case ANIMATION_EVENT: eventType = "event"; break; } LuaValueDict spineEvent; spineEvent.insert(spineEvent.end(), LuaValueDict::value_type("type", LuaValue::stringValue(eventType))); spineEvent.insert(spineEvent.end(), LuaValueDict::value_type("trackIndex", LuaValue::intValue(trackIndex))); spineEvent.insert(spineEvent.end(), LuaValueDict::value_type("animation", LuaValue::stringValue(animationName))); spineEvent.insert(spineEvent.end(), LuaValueDict::value_type("loopCount", LuaValue::intValue(loopCount))); if (NULL != event) { LuaValueDict eventData; eventData.insert(eventData.end(), LuaValueDict::value_type("name", LuaValue::stringValue(event->data->name))); eventData.insert(eventData.end(), LuaValueDict::value_type("intValue", LuaValue::intValue(event->intValue))); eventData.insert(eventData.end(), LuaValueDict::value_type("floatValue", LuaValue::floatValue(event->floatValue))); eventData.insert(eventData.end(), LuaValueDict::value_type("stringValue", LuaValue::stringValue(event->stringValue))); spineEvent.insert(spineEvent.end(), LuaValueDict::value_type("eventData", LuaValue::dictValue(eventData))); } pStack->pushLuaValueDict(spineEvent); nRet = pStack->executeFunctionByHandler(nHandler, 1); pStack->clean(); return nRet; } LuaSkeletonAnimation::LuaSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale) : spine::SkeletonAnimation(skeletonDataFile, atlasFile, scale) { this->setAnimationListener(this, animationStateEvent_selector(LuaSkeletonAnimation::animationStateEvent)); } LuaSkeletonAnimation::~LuaSkeletonAnimation() { ScriptHandlerMgr::getInstance()->removeObjectAllHandlers((void*)this); } LuaSkeletonAnimation* LuaSkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) { LuaSkeletonAnimation* node = new LuaSkeletonAnimation(skeletonDataFile, atlasFile, scale); node->autorelease(); return node; } void LuaSkeletonAnimation::animationStateEvent (spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) { int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_SPINE); if (0 != nHandler) { SendSpineEventToLua(nHandler, node, trackIndex, type, event, loopCount); } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/LuaSkeletonAnimation.h ================================================ /**************************************************************************** Copyright (c) 2013 Edward Zhou Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef LUASKELETONANIMATION_H_ #define LUASKELETONANIMATION_H_ #include "spine-cocos2dx.h" class LuaSkeletonAnimation: public spine::SkeletonAnimation { private: void animationStateEvent (spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount); public: static LuaSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1); LuaSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 1); virtual ~LuaSkeletonAnimation(); }; #endif /* LUASKELETONANIMATION_H_ */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/Lua_web_socket.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include #include #include "Lua_web_socket.h" #include "cocos2d.h" #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" #include "LuaScriptHandlerMgr.h" using namespace cocos2d; static int SendBinaryMessageToLua(int nHandler,const unsigned char* pTable,int nLength) { if (NULL == pTable || nHandler <= 0) { return 0; } if (NULL == ScriptEngineManager::getInstance()->getScriptEngine()) { return 0; } LuaStack *pStack = LuaEngine::getInstance()->getLuaStack(); if (NULL == pStack) { return 0; } lua_State *tolua_s = pStack->getLuaState(); if (NULL == tolua_s) { return 0; } int nRet = 0; LuaValueArray array; for (int i = 0 ; i < nLength; i++) { LuaValue value = LuaValue::intValue(pTable[i]); array.push_back(value); } pStack->pushLuaValueArray(array); nRet = pStack->executeFunctionByHandler(nHandler, 1); pStack->clean(); return nRet; } LuaWebSocket::~LuaWebSocket() { ScriptHandlerMgr::getInstance()->removeObjectAllHandlers((void*)this); } void LuaWebSocket::onOpen(WebSocket* ws) { LuaWebSocket* luaWs = dynamic_cast(ws); if (NULL != luaWs) { int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_OPEN); if (0 != nHandler) { CommonScriptData data(nHandler,""); ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } } } void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data) { LuaWebSocket* luaWs = dynamic_cast(ws); if (NULL != luaWs) { if (data.isBinary) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); if (0 != handler) { SendBinaryMessageToLua(handler, (const unsigned char*)data.bytes, data.len); } } else{ int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); if (0 != handler) { LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); if (nullptr != stack) { stack->pushString(data.bytes,data.len); stack->executeFunctionByHandler(handler, 1); } } } } } void LuaWebSocket::onClose(WebSocket* ws) { LuaWebSocket* luaWs = dynamic_cast(ws); if (NULL != luaWs) { int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_CLOSE); if (0 != nHandler) { CommonScriptData data(nHandler,""); ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } } } void LuaWebSocket::onError(WebSocket* ws, const WebSocket::ErrorCode& error) { LuaWebSocket* luaWs = dynamic_cast(ws); if (NULL != luaWs) { int nHandler = 0;//luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerError); if (0 != nHandler) { CommonScriptData data(nHandler,""); ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } } } #ifdef __cplusplus static int tolua_collect_WebSocket (lua_State* tolua_S) { LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } #endif /* function to release collected object via destructor */ static void tolua_reg_Web_Socket_type(lua_State* tolua_S) { tolua_usertype(tolua_S, "cc.WebSocket"); } /* method: create of class WebSocket */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_create00 static int tolua_Cocos2d_WebSocket_create00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* urlName = ((const char*) tolua_tostring(tolua_S,2,0)); LuaWebSocket *wSocket = new LuaWebSocket(); wSocket->init(*wSocket, urlName); tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: createByAProtocol of class WebSocket */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_createByAProtocol00 static int tolua_Cocos2d_WebSocket_createByAProtocol00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isstring(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const char *urlName = ((const char*) tolua_tostring(tolua_S,2,0)); const char *protocol = ((const char*) tolua_tostring(tolua_S,3,0)); std::vector protocols; protocols.push_back(protocol); LuaWebSocket *wSocket = new LuaWebSocket(); wSocket->init(*wSocket, urlName,&protocols); tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createByAProtocol'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: createByAProtocol of class WebSocket */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_createByProtocolArray00 static int tolua_Cocos2d_WebSocket_createByProtocolArray00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isusertable(tolua_S,3,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const char *urlName = ((const char*) tolua_tostring(tolua_S,2,0)); Array* protocolArray = ((Array*) tolua_tousertype(tolua_S,3,0)); std::vector protocols; if (NULL != protocolArray) { Object* pObj = NULL; CCARRAY_FOREACH(protocolArray, pObj) { String* pStr = static_cast(pObj); if (NULL != pStr) { protocols.push_back(pStr->getCString()); } } } LuaWebSocket *wSocket = new LuaWebSocket(); wSocket->init(*wSocket, urlName,&protocols); tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createByProtocolArray'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getReadyState of class WebSocket */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_getReadyState00 static int tolua_Cocos2d_WebSocket_getReadyState00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { LuaWebSocket *self = (LuaWebSocket*)tolua_tousertype(tolua_S,1,0); int tolua_ret = -1; if (NULL != self) { tolua_ret = (int)self->getReadyState(); } tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getReadyState'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: close of class WebSocket */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_close00 static int tolua_Cocos2d_WebSocket_close00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { self->close(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getReadyState'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: sendString of class WebSocket */ #ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_sendString00 static int tolua_Cocos2d_WebSocket_sendString00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S, 1, "cc.WebSocket", 0, &tolua_err) || !tolua_isstring(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) goto tolua_lerror; else #endif { LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); size_t size = 0; const char* data = (const char*) lua_tolstring(tolua_S, 2, &size); if ( NULL == data) return 0; if (strlen(data) != size) { self->send((const unsigned char*)data, size); } else { self->send(data); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'sendString'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){ tolua_open(tolua_S); tolua_reg_Web_Socket_type(tolua_S); tolua_module(tolua_S,"cc",0); tolua_beginmodule(tolua_S,"cc"); #ifdef __cplusplus tolua_cclass(tolua_S,"WebSocket","cc.WebSocket","",tolua_collect_WebSocket); #else tolua_cclass(tolua_S,"WebSocket","cc.WebSocket","",NULL); #endif tolua_beginmodule(tolua_S,"WebSocket"); tolua_function(tolua_S, "create", tolua_Cocos2d_WebSocket_create00); tolua_function(tolua_S, "createByAProtocol", tolua_Cocos2d_WebSocket_createByAProtocol00); tolua_function(tolua_S, "createByProtocolArray", tolua_Cocos2d_WebSocket_createByProtocolArray00); tolua_function(tolua_S, "getReadyState", tolua_Cocos2d_WebSocket_getReadyState00); tolua_function(tolua_S, "close", tolua_Cocos2d_WebSocket_close00); tolua_function(tolua_S, "sendString", tolua_Cocos2d_WebSocket_sendString00); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); return 1; } int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { int handler = ( toluafix_ref_function(tolua_S,2,0)); ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType)((int)tolua_tonumber(tolua_S,3,0) + (int)ScriptHandlerMgr::HandlerType::WEBSOCKET_OPEN); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType)((int)tolua_tonumber(tolua_S,2,0) + (int)ScriptHandlerMgr::HandlerType::WEBSOCKET_OPEN); ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); return 0; #endif } TOLUA_API int register_web_socket_manual(lua_State* tolua_S) { if (nullptr == tolua_S) return 0 ; lua_pushstring(tolua_S,"cc.WebSocket"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"registerScriptHandler"); lua_pushcfunction(tolua_S,tolua_Cocos2d_WebSocket_registerScriptHandler00); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"unregisterScriptHandler"); lua_pushcfunction(tolua_S,tolua_Cocos2d_WebSocket_unregisterScriptHandler00); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); return 1; } #endif//(CC_TARGET_PLATFORM == CC_PLATFORM_IOS ... ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/Lua_web_socket.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __LUA_WEB_SOCKET_H__ #define __LUA_WEB_SOCKET_H__ #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include "network/WebSocket.h" class LuaWebSocket: public cocos2d::network::WebSocket,public cocos2d::network::WebSocket::Delegate { public: virtual ~LuaWebSocket(); virtual void onOpen(WebSocket* ws) override; virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) override; virtual void onClose(WebSocket* ws) override; virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error) override; enum WebSocketScriptHandlerType { kWebSocketScriptHandlerOpen, kWebSocketScriptHandlerMessage, kWebSocketScriptHandlerClose, kWebSocketScriptHandlerError, }; }; TOLUA_API int tolua_web_socket_open(lua_State* tolua_S); TOLUA_API int register_web_socket_manual(lua_State* tolua_S); #endif //(CC_TARGET_PLATFORM == CC_PLATFORM_IOS ... #endif //__LUA_WEB_SOCKET_H__ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/liblua.vcxproj ================================================  Debug Win32 Release Win32 {DDC3E27F-004D-4DD4-9DD3-931A013D2159} liblua Win32Proj StaticLibrary Unicode v100 v110 v110_xp StaticLibrary Unicode v100 v110 v110_xp <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ AllRules.ruleset AllRules.ruleset $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) Disabled $(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\gui;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL Level3 OldStyle 4800;4267;4251;4244;%(DisableSpecificWarnings) true %(AdditionalLibraryDirectories) if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$(OutDir)" MaxSpeed true $(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\gui;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true Level3 ProgramDatabase 4800;4267;4251;4244;%(DisableSpecificWarnings) true libcocos2d.lib;%(AdditionalLibraryDirectories) if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$(OutDir)" ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/liblua.vcxproj.filters ================================================  {243d29bc-c49a-4d05-8e2f-2c2f5858928a} {bbe428ed-e8e5-4e3c-80c9-0e586814b884} {948e219e-763e-41d0-bc8d-6421dba8ad70} {b7025611-420a-4414-b567-f7496eec5f57} {19f563f0-e0ff-4500-890b-1755841d4ddb} {8815bb6e-fc9c-4cbf-b190-8b47169ed71f} cocos2dx_support\generated cocos2dx_support\generated tolua tolua tolua tolua tolua cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support\generated cocos2dx_support cocos2dx_support\generated cocos2dx_support cocos2dx_support cocos2dx_support\generated cocos2dx_support cocos2dx_support cocos2dx_support\generated cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support cocos2dx_support\generated cocos2dx_support\generated luajit\include luajit\include luajit\include luajit\include tolua tolua cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support cocos2dx_support\generated cocos2dx_support cocos2dx_support\generated cocos2dx_support cocos2dx_support cocos2dx_support\generated cocos2dx_support cocos2dx_support cocos2dx_support\generated cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support\socket cocos2dx_support cocos2dx_support\generated cocos2dx_support\generated cocos2dx_support\generated cocos2dx_support\generated cocos2dx_support\generated ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "lua_cocos2dx_coco_studio_manual.hpp" #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include "cocos2d.h" #include "LuaBasicConversions.h" #include "LuaScriptHandlerMgr.h" #include "CCLuaValue.h" #include "CocoStudio.h" #include "CCLuaEngine.h" using namespace cocostudio; class LuaArmatureWrapper:public Object { public: LuaArmatureWrapper(); virtual ~LuaArmatureWrapper(); virtual void addArmatureFileInfoAsyncCallback(float percent); }; LuaArmatureWrapper::LuaArmatureWrapper() { } LuaArmatureWrapper::~LuaArmatureWrapper() { } void LuaArmatureWrapper::addArmatureFileInfoAsyncCallback(float percent) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); if (0 != handler) { LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FILE_ASYNC , (void*)&percent); BasicScriptData data(this,(void*)&wrapperData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); } } static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L) { if (nullptr == L) return 0; int argc = 0; ArmatureAnimation* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); Vector vec; vec.pushBack(wrapper); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); self->setMovementEventCallFunc([=](Armature *armature, MovementEventType movementType, const std::string& movementID){ int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)vec.at(0), ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); if (0 != handler) { std::string strMovementID = movementID; LuaArmatureMovementEventData movementData(armature,(int)movementType, strMovementID); LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT , (void*)&movementData); BasicScriptData data((void*)vec.at(0),(void*)&wrapperData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); } }); return 0; } CCLOG("'setMovementEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setMovementEventCallFunc'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L) { if (nullptr == L) return 0; int argc = 0; ArmatureAnimation* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); Vector vec; vec.pushBack(wrapper); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); self->setFrameEventCallFunc([=](Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex){ int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)vec.at(0), ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); if (0 != handler) { std::string strFrameEventName(frameEventName); LuaArmatureFrameEventData frameData(bone,frameEventName,originFrameIndex,currentFrameIndex); LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT , (void*)&frameData); BasicScriptData data((void*)vec.at(0),(void*)&wrapperData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); } }); return 0; } CCLOG("'setFrameEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 1); #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setFrameEventCallFunc'.",&tolua_err); return 0; #endif } static void extendArmatureAnimation(lua_State* L) { lua_pushstring(L, "ccs.ArmatureAnimation"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "setMovementEventCallFunc", lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc); tolua_function(L, "setFrameEventCallFunc", lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc); } lua_pop(L, 1); } static int lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua_State* L) { if (nullptr == L) return 0 ; int argc = 0; ArmatureDataManager* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(L, 2, 0, &tolua_err) || !toluafix_isfunction(L,3,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif const char* configFilePath = tolua_tostring(L, 2, ""); LUA_FUNCTION handler = ( toluafix_ref_function(L, 3, 0)); LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); self->addArmatureFileInfoAsync(configFilePath, wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback)); return 0; } else if (4 == argc) { #if COCOS2D_DEBUG >= 1 if ( !tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err) || !tolua_isstring(L, 4, 0, &tolua_err) || !toluafix_isfunction(L,5,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif const char* imagePath = tolua_tostring(L, 2, ""); const char* plistPath = tolua_tostring(L, 3, ""); const char* configFilePath = tolua_tostring(L, 4, ""); LUA_FUNCTION handler = ( toluafix_ref_function(L,5,0)); LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); self->addArmatureFileInfoAsync(imagePath, plistPath,configFilePath,wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback)); return 0; } CCLOG("'addArmatureFileInfoAsync' function of ArmatureDataManager has wrong number of arguments: %d, was expecting %d\n", argc, 1); #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addArmatureFileInfoAsync'.",&tolua_err); return 0; #endif } static void extendArmatureDataManager(lua_State* L) { lua_pushstring(L, "ccs.ArmatureDataManager"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "addArmatureFileInfoAsync", lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc); } lua_pop(L, 1); } static int lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData(lua_State* L) { if (nullptr == L) return 0; int argc = 0; cocostudio::Bone* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif bool ignore = (bool)tolua_toboolean(L, 2, 0); self->setIgnoreMovementBoneData(ignore); return 0; } CCLOG("'setIgnoreMovementBoneData' function of Bone has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setIgnoreMovementBoneData'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData(lua_State* L) { if (nullptr == L) return 0; int argc = 0; cocostudio::Bone* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { tolua_pushboolean(L, self->getIgnoreMovementBoneData()); return 1; } CCLOG("'getIgnoreMovementBoneData' function of Bone has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'getIgnoreMovementBoneData'.",&tolua_err); return 0; #endif } static void extendBone(lua_State* L) { lua_pushstring(L, "ccs.Bone"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "setIgnoreMovementBoneData", lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData); tolua_function(L, "getIgnoreMovementBoneData", lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData); } lua_pop(L, 1); } int register_all_cocos2dx_coco_studio_manual(lua_State* L) { if (nullptr == L) return 0; extendArmatureAnimation(L); extendArmatureDataManager(L); extendBone(L); return 0; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H #define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include "CCObject.h" TOLUA_API int register_all_cocos2dx_coco_studio_manual(lua_State* L); struct LuaArmatureWrapperEventData { enum class LuaArmatureWrapperEventType { MOVEMENT_EVENT, FRAME_EVENT, FILE_ASYNC, }; LuaArmatureWrapperEventType eventType; void* eventData; LuaArmatureWrapperEventData(LuaArmatureWrapperEventType _eventType, void* _eventData):eventType(_eventType),eventData(_eventData) { } }; struct LuaArmatureMovementEventData { cocos2d::Object* objTarget; int movementType; std::string movementID; LuaArmatureMovementEventData(cocos2d::Object* _objTarget, int _movementType,const std::string& _movementID):objTarget(_objTarget),movementType(_movementType),movementID(_movementID) { } }; struct LuaArmatureFrameEventData { cocos2d::Object* objTarget; std::string frameEventName; int originFrameIndex; int currentFrameIndex; LuaArmatureFrameEventData( cocos2d::Object* _objTarget, const std::string& _frameEventName, int _originFrameIndex, int _currentFrameIndex):objTarget(_objTarget), frameEventName(_frameEventName),originFrameIndex(_originFrameIndex), currentFrameIndex(_currentFrameIndex) { } }; #endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "lua_cocos2dx_deprecated.h" #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include "cocos2d.h" #include "LuaBasicConversions.h" #include "LuaScriptHandlerMgr.h" #include "CCLuaValue.h" #include "cocos-ext.h" USING_NS_CC; USING_NS_CC_EXT; template bool array_to_vector_t_deprecated(Array& array,Vector& vec) { if ( 0 == array.count() ) return false; vec.clear(); for (int i = 0; i < array.count() ; i++) { T obj = dynamic_cast(array.getObjectAtIndex(i)); if (nullptr != obj) vec.pushBack(obj); } return true; } bool array_to_valuevector_deprecated(Array& array,ValueVector& valueVec) { if (0 == array.count()) return false; valueVec.clear(); String* strVal = nullptr; Double* doubleVal = nullptr; Bool* boolVal = nullptr; Float* floatVal = nullptr; Integer* intVal = nullptr; for (int i = 0; i < array.count(); i++) { if( (strVal = dynamic_cast(array.getObjectAtIndex(i)))) { valueVec.push_back(Value(strVal->getCString())); } else if ((doubleVal = dynamic_cast(array.getObjectAtIndex(i)))) { valueVec.push_back(Value(doubleVal->getValue())); } else if ((floatVal = dynamic_cast(array.getObjectAtIndex(i)))) { valueVec.push_back(Value(floatVal->getValue())); } else if ((intVal = dynamic_cast(array.getObjectAtIndex(i)))) { valueVec.push_back(Value(intVal->getValue())); } else if ((boolVal = dynamic_cast(array.getObjectAtIndex(i)))) { valueVec.push_back(Value(boolVal->getValue())); } else { CCASSERT(false, "the type isn't suppored."); } } return true; } #define deprecatedClassTip(className) CCLOG("%s will be not binded in lua,please use the lua's table instead",className) #define deprecatedFunctionTip(oldFun,newFun) CCLOG("%s was deprecated please use %s instead ",oldFun, newFun) static int tolua_Cocos2d_CCPoint_new00(lua_State* tolua_S) { deprecatedClassTip("CCPoint"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCPoint",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Point tolua_ret; point_to_luaval(tolua_S, tolua_ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCPoint_new00_local(lua_State* tolua_S) { deprecatedClassTip("CCPoint"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCPoint",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Point tolua_ret; point_to_luaval(tolua_S, tolua_ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCPoint_new01(lua_State* tolua_S) { deprecatedClassTip("CCPoint"); tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCPoint",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); Point tolua_ret(x,y); point_to_luaval(tolua_S, tolua_ret); } return 1; tolua_lerror: return tolua_Cocos2d_CCPoint_new00(tolua_S); } static int tolua_Cocos2d_CCPoint_new01_local(lua_State* tolua_S) { deprecatedClassTip("CCPoint"); tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCPoint",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); Point tolua_ret(x,y); point_to_luaval(tolua_S, tolua_ret); } return 1; tolua_lerror: return tolua_Cocos2d_CCPoint_new00_local(tolua_S); } static int tolua_collect_CCPoint (lua_State* tolua_S) { Point* self = (Point*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } static int register_cocos2dx_deprecated_Point(lua_State* tolua_S) { tolua_usertype(tolua_S,"CCPoint"); #ifdef __cplusplus tolua_cclass(tolua_S,"CCPoint","CCPoint","",tolua_collect_CCPoint); #else tolua_cclass(tolua_S,"CCPoint","CCPoint","",NULL); #endif tolua_beginmodule(tolua_S,"CCPoint"); tolua_function(tolua_S,"new",tolua_Cocos2d_CCPoint_new00); tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCPoint_new00_local); tolua_function(tolua_S,".call",tolua_Cocos2d_CCPoint_new00_local); tolua_function(tolua_S,"new",tolua_Cocos2d_CCPoint_new01); tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCPoint_new01_local); tolua_function(tolua_S,".call",tolua_Cocos2d_CCPoint_new01_local); tolua_endmodule(tolua_S); return 1; } static int tolua_Cocos2d_CCRect_new00(lua_State* tolua_S) { deprecatedClassTip("CCRect"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCRect",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Rect tolua_ret; rect_to_luaval(tolua_S, tolua_ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCRect_new00_local(lua_State* tolua_S) { deprecatedClassTip("CCRect"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCRect",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Rect tolua_ret; rect_to_luaval(tolua_S, tolua_ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCRect_new01(lua_State* tolua_S) { deprecatedClassTip("CCRect"); tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCRect",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float width = ((float) tolua_tonumber(tolua_S,4,0)); float height = ((float) tolua_tonumber(tolua_S,5,0)); Rect tolua_ret(x, y, width, height); rect_to_luaval(tolua_S, tolua_ret); } return 1; tolua_lerror: return tolua_Cocos2d_CCRect_new00(tolua_S); } static int tolua_Cocos2d_CCRect_new01_local(lua_State* tolua_S) { deprecatedClassTip("CCRect"); tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCRect",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float width = ((float) tolua_tonumber(tolua_S,4,0)); float height = ((float) tolua_tonumber(tolua_S,5,0)); Rect tolua_ret(x, y, width, height); rect_to_luaval(tolua_S, tolua_ret); } return 1; tolua_lerror: return tolua_Cocos2d_CCRect_new00_local(tolua_S); } static int register_cocos2dx_deprecated_Rect(lua_State* tolua_S) { tolua_usertype(tolua_S,"CCRect"); tolua_cclass(tolua_S,"CCRect","CCRect","",NULL); tolua_beginmodule(tolua_S,"CCRect"); tolua_function(tolua_S,"new",tolua_Cocos2d_CCRect_new00); tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCRect_new00_local); tolua_function(tolua_S,".call",tolua_Cocos2d_CCRect_new00_local); tolua_function(tolua_S,"new",tolua_Cocos2d_CCRect_new01); tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCRect_new01_local); tolua_function(tolua_S,".call",tolua_Cocos2d_CCRect_new01_local); tolua_endmodule(tolua_S); return 1; } static int tolua_Cocos2d_CCSize_new00(lua_State* tolua_S) { deprecatedClassTip("CCSize"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCSize",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Size tolua_ret; size_to_luaval(tolua_S, tolua_ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCSize_new00_local(lua_State* tolua_S) { deprecatedClassTip("CCSize"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCSize",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Size tolua_ret; size_to_luaval(tolua_S, tolua_ret); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCSize_new01(lua_State* tolua_S) { deprecatedClassTip("CCSize"); tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCSize",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { float width = ((float) tolua_tonumber(tolua_S,2,0)); float height = ((float) tolua_tonumber(tolua_S,3,0)); Size tolua_ret(width, height); size_to_luaval(tolua_S, tolua_ret); } return 1; tolua_lerror: return tolua_Cocos2d_CCSize_new00(tolua_S); } static int tolua_Cocos2d_CCSize_new01_local(lua_State* tolua_S) { deprecatedClassTip("CCSize"); tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCSize",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { float width = ((float) tolua_tonumber(tolua_S,2,0)); float height = ((float) tolua_tonumber(tolua_S,3,0)); Size tolua_ret(width, height); size_to_luaval(tolua_S, tolua_ret); } return 1; tolua_lerror: return tolua_Cocos2d_CCSize_new00_local(tolua_S); } static int register_cocos2dx_deprecated_Size(lua_State* tolua_S) { tolua_usertype(tolua_S,"CCSize"); tolua_cclass(tolua_S,"CCSize","CCSize","",NULL); tolua_beginmodule(tolua_S,"CCSize"); tolua_function(tolua_S,"new",tolua_Cocos2d_CCSize_new00); tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCSize_new00_local); tolua_function(tolua_S,".call",tolua_Cocos2d_CCSize_new00_local); tolua_function(tolua_S,"new",tolua_Cocos2d_CCSize_new01); tolua_function(tolua_S,"new_local",tolua_Cocos2d_CCSize_new01_local); tolua_function(tolua_S,".call",tolua_Cocos2d_CCSize_new01_local); tolua_endmodule(tolua_S); return 1; } static int tolua_Cocos2d_CCArray_create00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { Array* tolua_ret = (Array*) Array::create(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_createWithObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Object* pObject = ((Object*) tolua_tousertype(tolua_S,2,0)); { Array* tolua_ret = (Array*) Array::createWithObject(pObject); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_createWithArray00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* otherArray = ((Array*) tolua_tousertype(tolua_S,2,0)); { Array* tolua_ret = (Array*) Array::createWithArray(otherArray); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithArray'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_createWithCapacity00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { unsigned int capacity = ((unsigned int) tolua_tonumber(tolua_S,2,0)); { Array* tolua_ret = (Array*) Array::createWithCapacity(capacity); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithCapacity'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_createWithContentsOfFile00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* pFileName = ((const char*) tolua_tostring(tolua_S,2,0)); { Array* tolua_ret = (Array*) Array::createWithContentsOfFile(pFileName); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCArray"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithContentsOfFile'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_count00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'count'", NULL); #endif { unsigned int tolua_ret = (unsigned int) self->count(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'count'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_capacity00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'capacity'", NULL); #endif { unsigned int tolua_ret = (unsigned int) self->capacity(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'capacity'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_indexOfObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'indexOfObject'", NULL); #endif { unsigned int tolua_ret = (unsigned int) self->getIndexOfObject(object); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'indexOfObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_objectAtIndex00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'objectAtIndex'", NULL); #endif { Object* tolua_ret = (Object*) self->getObjectAtIndex(index); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'objectAtIndex'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_lastObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'lastObject'", NULL); #endif { Object* tolua_ret = (Object*) self->getLastObject(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lastObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_randomObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'randomObject'", NULL); #endif { Object* tolua_ret = (Object*) self->getRandomObject(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Object"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'randomObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_isEqualToArray00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Array* pOtherArray = ((Array*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEqualToArray'", NULL); #endif { bool tolua_ret = (bool) self->isEqualToArray(pOtherArray); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isEqualToArray'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_containsObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'containsObject'", NULL); #endif { bool tolua_ret = (bool) self->containsObject(object); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'containsObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_addObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addObject'", NULL); #endif { self->addObject(object); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'addObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_addObjectsFromArray00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Array* otherArray = ((Array*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addObjectsFromArray'", NULL); #endif { self->addObjectsFromArray(otherArray); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'addObjectsFromArray'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_insertObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertObject'", NULL); #endif { self->insertObject(object,index); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'insertObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_removeLastObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isboolean(tolua_S,2,1,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); bool bReleaseObj = ((bool) tolua_toboolean(tolua_S,2,true)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeLastObject'", NULL); #endif { self->removeLastObject(bReleaseObj); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeLastObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_removeObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || !tolua_isboolean(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); bool bReleaseObj = ((bool) tolua_toboolean(tolua_S,3,true)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeObject'", NULL); #endif { self->removeObject(object,bReleaseObj); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_removeObjectAtIndex00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isboolean(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,2,0)); bool bReleaseObj = ((bool) tolua_toboolean(tolua_S,3,true)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeObjectAtIndex'", NULL); #endif { self->removeObjectAtIndex(index,bReleaseObj); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeObjectAtIndex'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_removeObjectsInArray00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Array* otherArray = ((Array*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeObjectsInArray'", NULL); #endif { self->removeObjectsInArray(otherArray); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeObjectsInArray'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_removeAllObjects00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeAllObjects'", NULL); #endif { self->removeAllObjects(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeAllObjects'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_fastRemoveObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Object* object = ((Object*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fastRemoveObject'", NULL); #endif { self->fastRemoveObject(object); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'fastRemoveObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_fastRemoveObjectAtIndex00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); unsigned int index = ((unsigned int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'fastRemoveObjectAtIndex'", NULL); #endif { self->fastRemoveObjectAtIndex(index); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'fastRemoveObjectAtIndex'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_exchangeObject00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"Object",0,&tolua_err) || !tolua_isusertype(tolua_S,3,"Object",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); Object* object1 = ((Object*) tolua_tousertype(tolua_S,2,0)); Object* object2 = ((Object*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'exchangeObject'", NULL); #endif { self->exchangeObject(object1,object2); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'exchangeObject'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_exchangeObjectAtIndex00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); unsigned int index1 = ((unsigned int) tolua_tonumber(tolua_S,2,0)); unsigned int index2 = ((unsigned int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'exchangeObjectAtIndex'", NULL); #endif { self->exchangeObjectAtIndex(index1,index2); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'exchangeObjectAtIndex'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_reverseObjects00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'reverseObjects'", NULL); #endif { self->reverseObjects(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'reverseObjects'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_reduceMemoryFootprint00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'reduceMemoryFootprint'", NULL); #endif { self->reduceMemoryFootprint(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'reduceMemoryFootprint'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCArray_replaceObjectAtIndex00(lua_State* tolua_S) { deprecatedClassTip("CCArray"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCArray",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isusertype(tolua_S,3,"Object",0,&tolua_err) || !tolua_isboolean(tolua_S,4,1,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { Array* self = (Array*) tolua_tousertype(tolua_S,1,0); unsigned int uIndex = ((unsigned int) tolua_tonumber(tolua_S,2,0)); Object* pObject = ((Object*) tolua_tousertype(tolua_S,3,0)); bool bReleaseObject = ((bool) tolua_toboolean(tolua_S,4,true)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'replaceObjectAtIndex'", NULL); #endif { self->replaceObjectAtIndex(uIndex,pObject,bReleaseObject); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'replaceObjectAtIndex'.",&tolua_err); return 0; #endif } static int register_cocos2dx_deprecated_Array(lua_State* tolua_S) { tolua_usertype(tolua_S, "CCArray"); tolua_cclass(tolua_S,"CCArray","CCArray","CCObject",NULL); tolua_beginmodule(tolua_S,"CCArray"); tolua_function(tolua_S,"create",tolua_Cocos2d_CCArray_create00); tolua_function(tolua_S,"createWithObject",tolua_Cocos2d_CCArray_createWithObject00); tolua_function(tolua_S,"createWithArray",tolua_Cocos2d_CCArray_createWithArray00); tolua_function(tolua_S,"createWithCapacity",tolua_Cocos2d_CCArray_createWithCapacity00); tolua_function(tolua_S,"createWithContentsOfFile",tolua_Cocos2d_CCArray_createWithContentsOfFile00); tolua_function(tolua_S,"count",tolua_Cocos2d_CCArray_count00); tolua_function(tolua_S,"capacity",tolua_Cocos2d_CCArray_capacity00); tolua_function(tolua_S,"indexOfObject",tolua_Cocos2d_CCArray_indexOfObject00); tolua_function(tolua_S,"objectAtIndex",tolua_Cocos2d_CCArray_objectAtIndex00); tolua_function(tolua_S,"lastObject",tolua_Cocos2d_CCArray_lastObject00); tolua_function(tolua_S,"randomObject",tolua_Cocos2d_CCArray_randomObject00); tolua_function(tolua_S,"isEqualToArray",tolua_Cocos2d_CCArray_isEqualToArray00); tolua_function(tolua_S,"containsObject",tolua_Cocos2d_CCArray_containsObject00); tolua_function(tolua_S,"addObject",tolua_Cocos2d_CCArray_addObject00); tolua_function(tolua_S,"addObjectsFromArray",tolua_Cocos2d_CCArray_addObjectsFromArray00); tolua_function(tolua_S,"insertObject",tolua_Cocos2d_CCArray_insertObject00); tolua_function(tolua_S,"removeLastObject",tolua_Cocos2d_CCArray_removeLastObject00); tolua_function(tolua_S,"removeObject",tolua_Cocos2d_CCArray_removeObject00); tolua_function(tolua_S,"removeObjectAtIndex",tolua_Cocos2d_CCArray_removeObjectAtIndex00); tolua_function(tolua_S,"removeObjectsInArray",tolua_Cocos2d_CCArray_removeObjectsInArray00); tolua_function(tolua_S,"removeAllObjects",tolua_Cocos2d_CCArray_removeAllObjects00); tolua_function(tolua_S,"fastRemoveObject",tolua_Cocos2d_CCArray_fastRemoveObject00); tolua_function(tolua_S,"fastRemoveObjectAtIndex",tolua_Cocos2d_CCArray_fastRemoveObjectAtIndex00); tolua_function(tolua_S,"exchangeObject",tolua_Cocos2d_CCArray_exchangeObject00); tolua_function(tolua_S,"exchangeObjectAtIndex",tolua_Cocos2d_CCArray_exchangeObjectAtIndex00); tolua_function(tolua_S,"reverseObjects",tolua_Cocos2d_CCArray_reverseObjects00); tolua_function(tolua_S,"reduceMemoryFootprint",tolua_Cocos2d_CCArray_reduceMemoryFootprint00); tolua_function(tolua_S,"replaceObjectAtIndex",tolua_Cocos2d_CCArray_replaceObjectAtIndex00); tolua_endmodule(tolua_S); return 1; } static int tolua_cocos2d_kmGLPushMatrix00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S,1,&tolua_err) ) goto tolua_lerror; else #endif { kmGLPushMatrix(); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'kmGLPushMatrix'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_kmGLTranslatef00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { float x = ((float) tolua_tonumber(tolua_S,1,0)); float y = ((float) tolua_tonumber(tolua_S,2,0)); float z = ((float) tolua_tonumber(tolua_S,3,0)); { kmGLTranslatef(x,y,z); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'kmGLTranslatef'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_kmGLPopMatrix00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S,1,&tolua_err) ) goto tolua_lerror; else #endif { { kmGLPopMatrix(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'kmGLPopMatrix'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_intValue00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const String* self = (const String*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'intValue'", NULL); #endif { int tolua_ret = (int) self->intValue(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'intValue'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_uintValue00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const String* self = (const String*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'uintValue'", NULL); #endif { unsigned int tolua_ret = (unsigned int) self->uintValue(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'uintValue'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_floatValue00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const String* self = (const String*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'floatValue'", NULL); #endif { float tolua_ret = (float) self->floatValue(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'floatValue'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_doubleValue00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const String* self = (const String*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'doubleValue'", NULL); #endif { double tolua_ret = (double) self->doubleValue(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'doubleValue'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_boolValue00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const String* self = (const String*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'boolValue'", NULL); #endif { bool tolua_ret = (bool) self->boolValue(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'boolValue'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_getCString00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const String* self = (const String*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCString'", NULL); #endif { const char* tolua_ret = (const char*) self->getCString(); tolua_pushstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getCString'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_length00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { const String* self = (const String*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'length'", NULL); #endif { unsigned int tolua_ret = (unsigned int) self->length(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'length'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_compare00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"const CCString",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const String* self = (const String*) tolua_tousertype(tolua_S,1,0); const char* str = ((const char*) tolua_tostring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'compare'", NULL); #endif { int tolua_ret = (int) self->compare(str); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'compare'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_isEqual00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"CCString",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"const CCObject",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { String* self = (String*) tolua_tousertype(tolua_S,1,0); const Object* pObject = ((const Object*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isEqual'", NULL); #endif { bool tolua_ret = (bool) self->isEqual(pObject); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isEqual'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_create00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCString",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* pStr = ((const char*) tolua_tostring(tolua_S,2,0)); { String* tolua_ret = (String*) String::create(pStr); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCString"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_createWithData00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCString",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { unsigned char* pData = ((unsigned char*) tolua_tostring(tolua_S,2,0)); unsigned long nLen = ((unsigned long) tolua_tonumber(tolua_S,3,0)); { String* tolua_ret = (String*) String::createWithData(pData,nLen); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCString"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithData'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCString_createWithContentsOfFile00(lua_State* tolua_S) { deprecatedClassTip("CCString"); #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CCString",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* pszFileName = ((const char*) tolua_tostring(tolua_S,2,0)); { String* tolua_ret = (String*) String::createWithContentsOfFile(pszFileName); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCString"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithContentsOfFile'.",&tolua_err); return 0; #endif } static int register_cocos2dx_deprecated_String(lua_State* tolua_S) { tolua_usertype(tolua_S, "CCString"); tolua_cclass(tolua_S,"CCString","CCString","Object",NULL); tolua_beginmodule(tolua_S,"CCString"); tolua_function(tolua_S,"intValue",tolua_Cocos2d_CCString_intValue00); tolua_function(tolua_S,"uintValue",tolua_Cocos2d_CCString_uintValue00); tolua_function(tolua_S,"floatValue",tolua_Cocos2d_CCString_floatValue00); tolua_function(tolua_S,"doubleValue",tolua_Cocos2d_CCString_doubleValue00); tolua_function(tolua_S,"boolValue",tolua_Cocos2d_CCString_boolValue00); tolua_function(tolua_S,"getCString",tolua_Cocos2d_CCString_getCString00); tolua_function(tolua_S,"length",tolua_Cocos2d_CCString_length00); tolua_function(tolua_S,"compare",tolua_Cocos2d_CCString_compare00); tolua_function(tolua_S,"isEqual",tolua_Cocos2d_CCString_isEqual00); tolua_function(tolua_S,"create",tolua_Cocos2d_CCString_create00); tolua_function(tolua_S,"createWithData",tolua_Cocos2d_CCString_createWithData00); tolua_function(tolua_S,"createWithContentsOfFile",tolua_Cocos2d_CCString_createWithContentsOfFile00); tolua_endmodule(tolua_S); return 1; } int register_all_cocos2dx_deprecated(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S,NULL,0); tolua_beginmodule(tolua_S,NULL); register_cocos2dx_deprecated_Point(tolua_S); register_cocos2dx_deprecated_Rect(tolua_S); register_cocos2dx_deprecated_Size(tolua_S); register_cocos2dx_deprecated_Array(tolua_S); register_cocos2dx_deprecated_String(tolua_S); tolua_function(tolua_S,"kmGLPushMatrix",tolua_cocos2d_kmGLPushMatrix00); tolua_function(tolua_S,"kmGLTranslatef",tolua_cocos2d_kmGLTranslatef00); tolua_function(tolua_S,"kmGLPopMatrix",tolua_cocos2d_kmGLPopMatrix00); tolua_endmodule(tolua_S); return 0; } extern int lua_cocos2dx_Animation_createWithSpriteFrames(lua_State* tolua_S); static int tolua_cocos2d_Animation_createWithSpriteFrames_deprecated00(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Animation",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { Array* arrayOfSpriteFrameNames = ((Array*) tolua_tousertype(tolua_S,2,0)); Vector vec; array_to_vector_t_deprecated(*arrayOfSpriteFrameNames, vec); float delay = ((float) tolua_tonumber(tolua_S,3,0)); cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(vec,delay); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation"); } return 1; tolua_lerror: return lua_cocos2dx_Animation_createWithSpriteFrames(tolua_S); } static int tolua_cocos2d_Animation_createWithSpriteFrames_deprecated01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Animation",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { Array* arrayOfSpriteFrameNames = ((Array*) tolua_tousertype(tolua_S,2,0)); Vector vec; array_to_vector_t_deprecated(*arrayOfSpriteFrameNames, vec); cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(vec); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation"); } return 1; tolua_lerror: return tolua_cocos2d_Animation_createWithSpriteFrames_deprecated00(tolua_S); } static void extendAnimationDeprecated(lua_State* tolua_S) { lua_pushstring(tolua_S,"Animation"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"createWithSpriteFrames"); lua_pushcfunction(tolua_S,tolua_cocos2d_Animation_createWithSpriteFrames_deprecated00); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"createWithSpriteFrames"); lua_pushcfunction(tolua_S,tolua_cocos2d_Animation_createWithSpriteFrames_deprecated01); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static int tolua_cocos2d_Sequence_createWithTwoActions(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Sequence",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"FiniteTimeAction",0,&tolua_err) || !tolua_isusertype(tolua_S,3,"FiniteTimeAction",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { FiniteTimeAction* pActionOne = ((FiniteTimeAction*) tolua_tousertype(tolua_S,2,0)); FiniteTimeAction* pActionTwo = ((FiniteTimeAction*) tolua_tousertype(tolua_S,3,0)); { Sequence* tolua_ret = (Sequence*) Sequence::createWithTwoActions(pActionOne,pActionTwo); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithTwoActions'.",&tolua_err); return 0; #endif } extern int tolua_cocos2d_Sequence_create(lua_State* tolua_S); static int tolua_Cocos2d_Sequence_create_deprecated00(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Sequence",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { Array* actions = ((Array*) tolua_tousertype(tolua_S,2,0)); Vector vec; array_to_vector_t_deprecated(*actions, vec); Sequence* tolua_ret = (Sequence*) Sequence::create(vec); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence"); } return 1; tolua_lerror: return tolua_cocos2d_Sequence_create(tolua_S); } static int extendSequenceDeprecated(lua_State* tolua_S) { lua_pushstring(tolua_S,"Sequence"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "createWithTwoActions",tolua_cocos2d_Sequence_createWithTwoActions); tolua_function(tolua_S, "create", tolua_Cocos2d_Sequence_create_deprecated00); } lua_pop(tolua_S, 1); return 1; } #ifdef __cplusplus extern "C" { #endif extern int tolua_bnd_cast(lua_State* tolua_S); #ifdef __cplusplus } #endif static int tolua_bnd_cast_deprecated00(lua_State* tolua_S) { void* v = nullptr; std::string strValue = ""; strValue = tolua_tostring(tolua_S,2,NULL); int pos = strValue.find("CC"); if (pos == 0 && std::string::npos == strValue.find("CCBAnimationManager") && std::string::npos == strValue.find("CCString") && std::string::npos == strValue.find("CCPoint") && std::string::npos == strValue.find("CCRect") && std::string::npos == strValue.find("CCSize") && std::string::npos == strValue.find("CCArray")) { strValue = strValue.substr(2); if (lua_islightuserdata(tolua_S, 1)) { v = tolua_touserdata(tolua_S, 1, NULL); } else { v = tolua_tousertype(tolua_S, 1, 0); }; if (v && !strValue.empty()) tolua_pushusertype(tolua_S,v,strValue.c_str()); else lua_pushnil(tolua_S); return 1; } else { std::string castName = tolua_tostring(tolua_S,2,NULL); auto iter = g_typeCast.find(castName); if (iter != g_typeCast.end() ) { CCLOG("Cast name %s doesn't include modular name which it belongs to,please add the modular name",iter->first.c_str()); tolua_pushstring(tolua_S, iter->second.c_str()); lua_insert(tolua_S, 2); lua_pop(tolua_S, 1); } return tolua_bnd_cast(tolua_S); } } static int extendToluaDeprecated(lua_State* tolua_S) { lua_getglobal(tolua_S, "_G"); if (lua_istable(tolua_S,-1))//stack:...,_G, { lua_pushstring(tolua_S,"tolua");//stack:_G,keyValue lua_gettable(tolua_S, -2);//stack:_G,toluaModule if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "cast", tolua_bnd_cast_deprecated00); } lua_pop(tolua_S, 1);//statck:_G } lua_pop(tolua_S, 1);//statck:... return 1; } static int tolua_cocos2d_Spawn_createWithTwoActions_deprcated00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Spawn",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"FiniteTimeAction",0,&tolua_err) || !tolua_isusertype(tolua_S,3,"FiniteTimeAction",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { FiniteTimeAction* pAction1 = ((FiniteTimeAction*) tolua_tousertype(tolua_S,2,0)); FiniteTimeAction* pAction2 = ((FiniteTimeAction*) tolua_tousertype(tolua_S,3,0)); { Spawn* tolua_ret = (Spawn*) Spawn::createWithTwoActions(pAction1,pAction2); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Spawn"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithTwoActions'.",&tolua_err); return 0; #endif } static int extendSpawnDeprecated(lua_State* tolua_S) { lua_pushstring(tolua_S,"Spawn"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "createWithTwoActions", tolua_cocos2d_Spawn_createWithTwoActions_deprcated00); } lua_pop(tolua_S, 1); return 1; } static int tolua_cocos2d_Menu_createWithArray00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Menu",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* arrayOfItems = ((Array*) tolua_tousertype(tolua_S,2,0)); Vector vec; array_to_vector_t_deprecated(*arrayOfItems, vec); Menu* tolua_ret = (Menu*) Menu::createWithArray(vec); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu"); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithArray'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Menu_alignItemsInColumnsWithArray00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Menu* self = (Menu*) tolua_tousertype(tolua_S,1,0); Array* rows = ((Array*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'alignItemsInColumnsWithArray'", NULL); #endif ValueVector valueVector; array_to_valuevector_deprecated(*rows, valueVector); self->alignItemsInColumnsWithArray(valueVector); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'alignItemsInColumnsWithArray'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Menu_alignItemsInRowsWithArray00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Menu",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Menu* self = (Menu*) tolua_tousertype(tolua_S,1,0); Array* columns = ((Array*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'alignItemsInRowsWithArray'", NULL); #endif ValueVector valueVector; array_to_valuevector_deprecated(*columns, valueVector); self->alignItemsInRowsWithArray(valueVector); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'alignItemsInRowsWithArray'.",&tolua_err); return 0; #endif } static int extendMenuDeprecated(lua_State* tolua_S) { lua_pushstring(tolua_S,"Menu"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "createWithArray", tolua_cocos2d_Menu_createWithArray00); tolua_function(tolua_S, "alignItemsInColumnsWithArray", tolua_cocos2d_Menu_alignItemsInColumnsWithArray00); tolua_function(tolua_S, "alignItemsInRowsWithArray", tolua_cocos2d_Menu_alignItemsInRowsWithArray00); } lua_pop(tolua_S, 1); return 1; } static int tolua_cocos2d_LayerMultiplex_createWithArray00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"LayerMultiplex",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Array* arrayOfLayers = ((Array*) tolua_tousertype(tolua_S,2,0)); Vector vec; array_to_vector_t_deprecated(*arrayOfLayers, vec); LayerMultiplex* tolua_ret = (LayerMultiplex*) LayerMultiplex::createWithArray(vec); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"LayerMultiplex"); } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createWithArray'.",&tolua_err); return 0; #endif } static int extendLayerMultiplexDeprecated(lua_State* tolua_S) { lua_pushstring(tolua_S,"LayerMultiplex"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "createWithArray", tolua_cocos2d_LayerMultiplex_createWithArray00); } lua_pop(tolua_S, 1); return 1; } int register_all_cocos2dx_manual_deprecated(lua_State* tolua_S) { if (NULL == tolua_S) return 0; extendAnimationDeprecated(tolua_S); extendSequenceDeprecated(tolua_S); extendToluaDeprecated(tolua_S); extendMenuDeprecated(tolua_S); extendLayerMultiplexDeprecated(tolua_S); return 0; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_DEPRECATED_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_DEPRECATED_H #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif TOLUA_API int register_all_cocos2dx_deprecated(lua_State* tolua_S); TOLUA_API int register_all_cocos2dx_manual_deprecated(lua_State* tolua_S); #endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_DEPRECATED_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "lua_cocos2dx_extension_manual.h" #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include "cocos2d.h" #include "LuaBasicConversions.h" #include "CCLuaValue.h" #include "cocos-ext.h" #include "CCBProxy.h" #include "cocostudio/CocoStudio.h" USING_NS_CC; USING_NS_CC_EXT; using namespace cocostudio; class LuaScrollViewDelegate:public Object, public ScrollViewDelegate { public: virtual ~LuaScrollViewDelegate() {} virtual void scrollViewDidScroll(ScrollView* view) override { if (nullptr != view) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); if (0 != handler) { CommonScriptData data(handler,""); ScriptEvent event(kCommonEvent,(void*)&data); LuaEngine::getInstance()->sendEvent(&event); } } } virtual void scrollViewDidZoom(ScrollView* view) override { if (nullptr != view) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM); if (0 != handler) { CommonScriptData data(handler,""); ScriptEvent event(kCommonEvent,(void*)&data); LuaEngine::getInstance()->sendEvent(&event); } } } }; static int tolua_cocos2dx_ScrollView_setDelegate(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; ScrollView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif self = (ScrollView*) tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_ScrollView_setDelegate'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { LuaScrollViewDelegate* delegate = new LuaScrollViewDelegate(); if (nullptr == delegate) return 0; self->setUserObject(delegate); self->setDelegate(delegate); delegate->release(); return 0; } CCLOG("'setDelegate' function of ScrollView wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setDelegate'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_ScrollView_registerScriptHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; ScrollView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_registerScriptHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(tolua_S,3,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); return 0; } CCLOG("'registerScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_ScrollView_unregisterScriptHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; ScrollView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_unregisterScriptHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) goto tolua_lerror; #endif ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(tolua_S,2,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); return 0; } CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); return 0; #endif } static void extendScrollView(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.ScrollView"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setDelegate"); lua_pushcfunction(tolua_S,tolua_cocos2dx_ScrollView_setDelegate ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"registerScriptHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_registerScriptHandler ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"unregisterScriptHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_unregisterScriptHandler ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static int tolua_cocos2d_Control_registerControlEventHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Control* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Control_registerControlEventHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); int controlevent = (int)tolua_tonumber(tolua_S,3,0); for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlevent & (1 << i))) { ScriptHandlerMgr::HandlerType handlerevent = ScriptHandlerMgr::HandlerType((int)ScriptHandlerMgr::HandlerType::CONTROL_TOUCH_DOWN + i); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerevent); } } return 0; } CCLOG("'registerControlEventHandler' function of Control has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerControlEventHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_control_unregisterControlEventHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Control* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_control_unregisterControlEventHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) goto tolua_lerror; #endif int controlevent = (int)tolua_tonumber(tolua_S,2,0); for (int i = 0; i < kControlEventTotalNumber; i++) { if ((controlevent & (1 << i))) { ScriptHandlerMgr::HandlerType handlerevent = ScriptHandlerMgr::HandlerType((int)ScriptHandlerMgr::HandlerType::CONTROL_TOUCH_DOWN + i); ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerevent); break; } } return 0; } CCLOG("'unregisterControlEventHandler' function of Control has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterControlEventHandler'.",&tolua_err); return 0; #endif } static void extendControl(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.Control"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"registerControlEventHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_Control_registerControlEventHandler ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"unregisterControlEventHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_control_unregisterControlEventHandler ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; EditBox* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); self->registerScriptEditBoxHandler(handler); return 0; } CCLOG("'registerScriptEditBoxHandler' function of EditBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptEditBoxHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; EditBox* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { self->unregisterScriptEditBoxHandler(); return 0; } CCLOG("'unregisterScriptEditBoxHandler' function of EditBox has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptEditBoxHandler'.",&tolua_err); return 0; #endif } static void extendEditBox(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.EditBox"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"registerScriptEditBoxHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_EditBox_registerScriptEditBoxHandler ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"unregisterScriptEditBoxHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static int tolua_cocos2d_CCBProxy_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { CCBProxy* tolua_ret = (CCBProxy*)CCBProxy::create(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int *pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CCBProxy"); return 1; } CCLOG("'create' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_CCBProxy_createCCBReader(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; CCBProxy* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_createCCBReader'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { CCBReader* tolua_ret = (CCBReader*) self->createCCBReader(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CCBReader"); return 1; } CCLOG("'createCCBReader' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'createCCBReader'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_CCBProxy_readCCBFromFile(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; CCBProxy* self = nullptr; const char* ccbFilePath = nullptr; CCBReader* ccbReader = nullptr; bool setOwner = false; Node* tolua_ret = nullptr; int ID = 0; int* luaID = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_readCCBFromFile'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (2 == argc || 3 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(tolua_S, 2, 0, &tolua_err)|| !tolua_isusertype(tolua_S,3,"cc.CCBReader",0,&tolua_err)|| !tolua_isboolean(tolua_S,4,1,&tolua_err ) ) goto tolua_lerror; #endif ccbFilePath = ((const char*) tolua_tostring(tolua_S,2,0)); ccbReader = ((CCBReader*) tolua_tousertype(tolua_S,3,0)); setOwner = (bool) tolua_toboolean(tolua_S,4,-1); tolua_ret = (Node*) self->readCCBFromFile(ccbFilePath, ccbReader, setOwner); ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node"); return 1; } CCLOG("'readCCBFromFile' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'readCCBFromFile'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_CCBProxy_getNodeTypeName(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; CCBProxy* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_getNodeTypeName'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif Node* node = static_cast(tolua_tousertype(tolua_S,2,0)); const char* tolua_ret = (const char*)self->getNodeTypeName(node); tolua_pushstring(tolua_S,(const char*)tolua_ret); return 1; } CCLOG("'getNodeTypeName' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getNodeTypeName'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_CCBProxy_setCallback(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; CCBProxy* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_setCallback'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if ( argc >= 2 && argc <= 3 ) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,2,"cc.Node",0,&tolua_err) || !toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 1, &tolua_err) ) goto tolua_lerror; #endif Node* node = ((Node*)tolua_tousertype(tolua_S,2,0)); LUA_FUNCTION funID = ( toluafix_ref_function(tolua_S,3,0)); int controlEvents = (int)tolua_tonumber(tolua_S, 4, 1); self->setCallback(node, funID, controlEvents); return 0; } CCLOG("'setCallback' function of CCBProxy has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setCallback'.",&tolua_err); return 0; #endif } int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S) { tolua_module(tolua_S,"cc",0); tolua_beginmodule(tolua_S,"cc"); tolua_usertype(tolua_S,"cc.CCBProxy"); tolua_cclass(tolua_S,"CCBProxy","cc.CCBProxy","cc.Layer",NULL); tolua_beginmodule(tolua_S,"CCBProxy"); tolua_function(tolua_S, "create", tolua_cocos2d_CCBProxy_create); tolua_function(tolua_S, "createCCBReader", tolua_cocos2d_CCBProxy_createCCBReader); tolua_function(tolua_S, "readCCBFromFile", tolua_cocos2d_CCBProxy_readCCBFromFile); tolua_function(tolua_S, "getNodeTypeName", tolua_cocos2d_CCBProxy_getNodeTypeName); tolua_function(tolua_S, "setCallback", tolua_cocos2d_CCBProxy_setCallback); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); std::string typeName = typeid(CCBProxy).name(); g_luaType[typeName] = "cc.CCBProxy"; return 1; } static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; CCBReader* self = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBReader_load'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc >= 1 && argc <= 3) { const char* fileName = nullptr; std::string fileName_tmp = ""; ok &= luaval_to_std_string(tolua_S, 2, &fileName_tmp); fileName = fileName_tmp.c_str(); if (!ok) return 0; if (1 == argc) { Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node"); return 1; } #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, 3, "cc.Object", 0, &tolua_err)) goto tolua_lerror; #endif Object* owner = static_cast(tolua_tousertype(tolua_S, 3, 0)); //In lua owner always define in lua script by table, so owner is always nullptr if (2 == argc) { Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName,owner); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node"); return 1; } Size size; ok &= luaval_to_size(tolua_S, 4, &size); if (!ok) return 0; Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName,owner,size); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node"); return 1; } CCLOG("'load' function of CCBReader has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'load'.",&tolua_err); return 0; #endif } static void extendCCBReader(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.CCBReader"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"load"); lua_pushcfunction(tolua_S,tolua_cocos2d_CCBReader_load ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static int tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; CCBAnimationManager* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,2, "cc.CallFunc", 0, &tolua_err) || !tolua_isstring(tolua_S, 3, 0, &tolua_err) ) goto tolua_lerror; #endif CallFunc* pCallFunc = static_cast(tolua_tousertype(tolua_S,2,0)); const char* keyframeCallback = ((const char*) tolua_tostring(tolua_S,3,0)); std::string strKey = ""; if (NULL != keyframeCallback) { strKey = keyframeCallback; } self->setCallFunc(pCallFunc, strKey); return 0; } CCLOG("'setCallFuncForLuaCallbackNamed' function of CCBAnimationManager has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setCallFuncForLuaCallbackNamed'.",&tolua_err); return 0; #endif } static void extendCCBAnimationManager(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.CCBAnimationManager"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setCallFuncForLuaCallbackNamed"); lua_pushcfunction(tolua_S,tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } class LuaAssetsManagerDelegateProtocol:public Object, public AssetsManagerDelegateProtocol { public: virtual ~LuaAssetsManagerDelegateProtocol() {} virtual void onProgress(int percent) override { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS); if (0 != handler) { LuaAssetsManagerEventData eventData(percent); BasicScriptData data((void*)this,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS, (void*)&data); } } virtual void onSuccess() override { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS); if (0 != handler) { LuaAssetsManagerEventData eventData; BasicScriptData data((void*)this,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS, (void*)&data); } } virtual void onError(AssetsManager::ErrorCode errorCode) override { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR); if (0 != handler) { LuaAssetsManagerEventData eventData((int)errorCode); BasicScriptData data((void*)this,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR, (void*)&data); } } }; static int lua_cocos2dx_AssetsManager_setDelegate(lua_State* L) { if (nullptr == L) return 0; int argc = 0; AssetsManager* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif self = (AssetsManager*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_AssetsManager_setDelegate'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err) || !tolua_isnumber(L, 3, 0, &tolua_err) ) { goto tolua_lerror; } #endif LuaAssetsManagerDelegateProtocol* delegate = dynamic_cast( self->getDelegate()); if (nullptr == delegate) { delegate = new LuaAssetsManagerDelegateProtocol(); if (nullptr == delegate) return 0; self->setUserObject(delegate); self->setDelegate(delegate); delegate->release(); } LUA_FUNCTION handler = toluafix_ref_function(L, 2, 0); ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)delegate, handler, handlerType); return 0; } CCLOG("'setDelegate' function of AssetsManager has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setDelegate'.",&tolua_err); return 0; #endif } static void extendAssetsManager(lua_State* L) { lua_pushstring(L, "cc.AssetsManager"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "setDelegate", lua_cocos2dx_AssetsManager_setDelegate); } lua_pop(L, 1); } #define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource" #define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" class LUA_TableViewDelegate:public Object, public TableViewDelegate { public: LUA_TableViewDelegate(){} virtual ~LUA_TableViewDelegate(){} virtual void scrollViewDidScroll(ScrollView* view) override { if (nullptr != view) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); if (0 != handler) { LuaTableViewEventData eventData; BasicScriptData data(view,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL, (void*)&data); } } } virtual void scrollViewDidZoom(ScrollView* view) override { if (nullptr != view) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM); if (0 != handler) { LuaTableViewEventData eventData; BasicScriptData data(view,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM, (void*)&data); } } } virtual void tableCellTouched(TableView* table, TableViewCell* cell) override { if (nullptr != table && nullptr != cell) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED); if (0 != handler) { LuaTableViewEventData eventData(cell); BasicScriptData data(table,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED,(void*)&data); } } } virtual void tableCellHighlight(TableView* table, TableViewCell* cell) override { if (nullptr != table && nullptr != cell) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT); if (0 != handler) { LuaTableViewEventData eventData(cell); BasicScriptData data(table,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT,(void*)&data); } } } virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) override { if (nullptr != table && nullptr != cell) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT); if (0 != handler) { LuaTableViewEventData eventData(cell); BasicScriptData data(table,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT,(void*)&data); } } } virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) override { if (nullptr != table && nullptr != cell) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE); if (0 != handler) { LuaTableViewEventData eventData(cell); BasicScriptData data(table,&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE,(void*)&data); } } } }; static int lua_cocos2dx_TableView_setDelegate(lua_State* L) { if (nullptr == L) return 0; int argc = 0; TableView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif self = (TableView*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDelegate'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { LUA_TableViewDelegate* delegate = new LUA_TableViewDelegate(); if (nullptr == delegate) return 0; Dictionary* userDict = static_cast(self->getUserObject()); if (nullptr == userDict) { userDict = new Dictionary(); if (NULL == userDict) return 0; self->setUserObject(userDict); userDict->release(); } userDict->setObject(delegate, KEY_TABLEVIEW_DELEGATE); self->setDelegate(delegate); delegate->release(); return 0; } CCLOG("'setDelegate' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setDelegate'.",&tolua_err); return 0; #endif } class LUA_TableViewDataSource:public Object,public TableViewDataSource { public: LUA_TableViewDataSource(){} virtual ~LUA_TableViewDataSource(){} virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) override { if (nullptr != table ) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX); if (0 != handler) { LuaTableViewEventData eventData(&idx); BasicScriptData data(table,&eventData); float width = 0.0; float height = 0.0; LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX, (void*)&data,2,[&](lua_State* L,int numReturn){ CCASSERT(numReturn == 2, "tableCellSizeForIndex return count error"); ValueVector vec; width = (float)tolua_tonumber(L, -1, 0); lua_pop(L, 1); height = (float)tolua_tonumber(L, -1, 0); lua_pop(L, 1); }); return Size(width, height); } } return Size::ZERO; } virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) override { if (nullptr != table ) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX); if (0 != handler) { LuaTableViewEventData eventData(&idx); BasicScriptData data(table,&eventData); TableViewCell* viewCell = nullptr; LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX, (void*)&data, 1, [&](lua_State* L, int numReturn){ CCASSERT(numReturn == 1, "tableCellAtIndex return count error"); viewCell = static_cast(tolua_tousertype(L, -1, nullptr)); lua_pop(L, 1); }); return viewCell; } } return NULL; } virtual ssize_t numberOfCellsInTableView(TableView *table) override { if (nullptr != table ) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS); if (0 != handler) { LuaTableViewEventData eventData; BasicScriptData data(table,&eventData); ssize_t counts = 0; LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS, (void*)&data,1, [&](lua_State* L, int numReturn){ CCASSERT(numReturn == 1, "numberOfCellsInTableView return count error"); counts = (ssize_t)tolua_tonumber(L, -1, 0); lua_pop(L, 1); }); return counts; } } return 0; } }; static int lua_cocos2dx_TableView_setDataSource(lua_State* L) { if (nullptr == L) return 0; int argc = 0; TableView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif self = (TableView*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDataSource'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource(); if (nullptr == dataSource) return 0; Dictionary* userDict = static_cast(self->getUserObject()); if (nullptr == userDict) { userDict = new Dictionary(); if (NULL == userDict) return 0; self->setUserObject(userDict); userDict->release(); } userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE); self->setDataSource(dataSource); dataSource->release(); return 0; } CCLOG("'setDataSource' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setDataSource'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_TableView_create(lua_State* L) { if (nullptr == L) return 0; int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(L) - 1; if (2 == argc || 1 == argc) { LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource(); Size size; ok &= luaval_to_size(L, 2, &size); TableView* ret = nullptr; if (1 == argc) { ret = TableView::create(dataSource, size); } else { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(L,3,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif Node* node = static_cast(tolua_tousertype(L, 3, nullptr)); ret = TableView::create(dataSource, size, node); } if (nullptr == ret) return 0; ret->reloadData(); Dictionary* userDict = new Dictionary(); userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE); ret->setUserObject(userDict); userDict->release(); dataSource->release(); int nID = (int)ret->_ID; int* pLuaID = &ret->_luaID; toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)ret,"cc.TableView"); return 1; } CCLOG("'create' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int lua_cocos2d_TableView_registerScriptHandler(lua_State* L) { if (NULL == L) return 0; int argc = 0; TableView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_TableView_registerScriptHandler'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(L, 3, 0, &tolua_err) ) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); return 0; } CCLOG("'registerScriptHandler' function of TableView has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } static int lua_cocos2d_TableView_unregisterScriptHandler(lua_State* L) { if (NULL == L) return 0; int argc = 0; TableView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2d_TableView_unregisterScriptHandler'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,2,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); return 0; } CCLOG("'unregisterScriptHandler' function of TableView has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); return 0; #endif } static void extendTableView(lua_State* L) { lua_pushstring(L, "cc.TableView"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "setDelegate", lua_cocos2dx_TableView_setDelegate); tolua_function(L, "setDataSource", lua_cocos2dx_TableView_setDataSource); tolua_function(L, "create", lua_cocos2dx_TableView_create); tolua_function(L, "registerScriptHandler", lua_cocos2d_TableView_registerScriptHandler); tolua_function(L, "unregisterScriptHandler", lua_cocos2d_TableView_unregisterScriptHandler); } lua_pop(L, 1); } int register_all_cocos2dx_extension_manual(lua_State* tolua_S) { extendControl(tolua_S); extendEditBox(tolua_S); extendCCBReader(tolua_S); extendCCBAnimationManager(tolua_S); extendAssetsManager(tolua_S); extendScrollView(tolua_S); extendTableView(tolua_S); return 0; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include "LuaScriptHandlerMgr.h" TOLUA_API int register_all_cocos2dx_extension_manual(lua_State* tolua_S); TOLUA_API int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S); struct LuaAssetsManagerEventData { int value; LuaAssetsManagerEventData(int _value = 0):value(_value) { } }; struct LuaTableViewEventData { void* value; // Constructor LuaTableViewEventData(void* _value = nullptr) :value(_value) { } }; #endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "lua_cocos2dx_gui_manual.hpp" #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include "cocos2d.h" #include "LuaBasicConversions.h" #include "LuaScriptHandlerMgr.h" #include "CCLuaValue.h" #include "CocosGUI.h" #include "CCLuaEngine.h" using namespace gui; class LuaCocoStudioEventListener:public Object { public: LuaCocoStudioEventListener(); virtual ~LuaCocoStudioEventListener(); static LuaCocoStudioEventListener* create(); virtual void eventCallbackFunc(Object* sender,int eventType); }; LuaCocoStudioEventListener::LuaCocoStudioEventListener() { } LuaCocoStudioEventListener::~LuaCocoStudioEventListener() { } LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() { LuaCocoStudioEventListener* listener = new LuaCocoStudioEventListener(); if (nullptr == listener) return nullptr; listener->autorelease(); return listener; } void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); if (0 != handler) { LuaStudioEventListenerData eventData(sender,eventType); BasicScriptData data(this,(void*)&eventData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER, (void*)&data); } } static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Widget* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Widget_addTouchEventListener'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); self->setUserObject(listener); self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } CCLOG("'addTouchEventListener' function of Widget has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addTouchEventListener'.",&tolua_err); return 0; #endif } static void extendWidget(lua_State* L) { lua_pushstring(L, "ccui.Widget"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "addTouchEventListener", lua_cocos2dx_Widget_addTouchEventListener); } lua_pop(L, 1); } static int lua_cocos2dx_CheckBox_addEventListenerCheckBox(lua_State* L) { if (nullptr == L) return 0; int argc = 0; CheckBox* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_CheckBox_addEventListenerCheckBox'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); self->setUserObject(listener); self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } CCLOG("'addEventListenerCheckBox' function of CheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addEventListenerCheckBox'.",&tolua_err); return 0; #endif } static void extendCheckBox(lua_State* L) { lua_pushstring(L, "ccui.CheckBox"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "addEventListenerCheckBox", lua_cocos2dx_CheckBox_addEventListenerCheckBox); } lua_pop(L, 1); } static int lua_cocos2dx_Slider_addEventListenerSlider(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Slider* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Slider_addEventListenerSlider'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) { goto tolua_lerror; } #endif LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); self->setUserObject(listener); self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } CCLOG("'addEventListenerSlider' function of Slider has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addEventListenerSlider'.",&tolua_err); return 0; #endif } static void extendSlider(lua_State* L) { lua_pushstring(L, "ccui.Slider"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "addEventListenerSlider", lua_cocos2dx_Slider_addEventListenerSlider); } lua_pop(L, 1); } static int lua_cocos2dx_TextField_addEventListenerTextField(lua_State* L) { if (nullptr == L) return 0; int argc = 0; TextField* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TextField_addEventListenerTextField'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); self->setUserObject(listener); self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } CCLOG("'addEventListenerTextField' function of TextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addEventListenerTextField'.",&tolua_err); return 0; #endif } static void extendTextField(lua_State* L) { lua_pushstring(L, "ccui.TextField"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "addEventListenerTextField", lua_cocos2dx_TextField_addEventListenerTextField); } lua_pop(L, 1); } static int lua_cocos2dx_PageView_addEventListenerPageView(lua_State* L) { if (nullptr == L) return 0; int argc = 0; PageView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_PageView_addEventListenerPageView'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) { goto tolua_lerror; } #endif LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); self->setUserObject(listener); self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } CCLOG("'addEventListenerPageView' function of PageView has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addEventListenerPageView'.",&tolua_err); return 0; #endif } static void extendPageView(lua_State* L) { lua_pushstring(L, "ccui.PageView"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "addEventListenerPageView", lua_cocos2dx_PageView_addEventListenerPageView); } lua_pop(L, 1); } static int lua_cocos2dx_ListView_addEventListenerListView(lua_State* L) { if (nullptr == L) return 0; int argc = 0; ListView* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addEventListenerListView'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); if (nullptr == listern) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); self->setUserObject(listern); self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } CCLOG("'addEventListenerListView' function of ListView has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addEventListenerListView'.",&tolua_err); return 0; #endif } static void extendListView(lua_State* L) { lua_pushstring(L, "ccui.ListView"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "addEventListenerListView", lua_cocos2dx_ListView_addEventListenerListView); } lua_pop(L, 1); } static int lua_cocos2dx_LayoutParameter_setMargin(lua_State* L) { if (nullptr == L) return 0; int argc = 0; LayoutParameter* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_setMargin'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_istable(L, 2, 0, &tolua_err)) { goto tolua_lerror; } #endif Margin margin; lua_pushstring(L, "left"); lua_gettable(L,2); margin.left = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "top"); lua_gettable(L,2); margin.top = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "right"); lua_gettable(L,2); margin.right = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "bottom"); lua_gettable(L,2); margin.bottom = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); lua_pop(L,1); self->setMargin(margin); return 0; } CCLOG("'setMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setMargin'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_LayoutParameter_getMargin(lua_State* L) { if (nullptr == L) return 0; int argc = 0; LayoutParameter* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_getMargin'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { Margin margin = self->getMargin(); lua_newtable(L); lua_pushstring(L, "left"); lua_pushnumber(L, (lua_Number) margin.left); lua_rawset(L, -3); lua_pushstring(L, "top"); lua_pushnumber(L, (lua_Number) margin.top); lua_rawset(L, -3); lua_pushstring(L, "right"); lua_pushnumber(L, (lua_Number) margin.right); lua_rawset(L, -3); lua_pushstring(L, "bottom"); lua_pushnumber(L, (lua_Number) margin.bottom); lua_rawset(L, -3); return 1; } CCLOG("'getMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'getMargin'.",&tolua_err); return 0; #endif } static void extendLayoutParameter(lua_State* L) { lua_pushstring(L, "ccui.LayoutParameter"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "setMargin", lua_cocos2dx_LayoutParameter_setMargin); tolua_function(L, "getMargin", lua_cocos2dx_LayoutParameter_getMargin); } lua_pop(L, 1); } int register_all_cocos2dx_gui_manual(lua_State* L) { if (nullptr == L) return 0; extendWidget(L); extendCheckBox(L); extendSlider(L); extendTextField(L); extendPageView(L); extendListView(L); extendLayoutParameter(L); return 0; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.hpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H #define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include "CCObject.h" TOLUA_API int register_all_cocos2dx_gui_manual(lua_State* L); struct LuaStudioEventListenerData { cocos2d::Object* objTarget; int eventType; LuaStudioEventListenerData(cocos2d::Object* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType) { } }; #endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "lua_cocos2dx_manual.hpp" #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include "LuaBasicConversions.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.MenuItemImage",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; do { if (argc == 0) { MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create(); //Uncheck int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.MenuItemImage"); return 1; } } while (0); do { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isstring(tolua_S,3,0,&tolua_err)) { ok = false; } #endif if (!ok) { ok = true; break; } const std::string normalImage = ((const std::string) tolua_tocppstring(tolua_S,2,0)); const std::string selectedImage = ((const std::string) tolua_tocppstring(tolua_S,3,0)); MenuItemImage* tolua_ret = (MenuItemImage*) MenuItemImage::create(normalImage,selectedImage); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.MenuItemImage"); return 1; } while (0); do { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isstring(tolua_S,3,0,&tolua_err) || !tolua_isstring(tolua_S,4,0,&tolua_err) ) { goto tolua_lerror; break; } #endif const std::string normalImage = ((const std::string) tolua_tocppstring(tolua_S,2,0)); const std::string selectedImage = ((const std::string) tolua_tocppstring(tolua_S,3,0)); const std::string disabledImage = ((const std::string) tolua_tocppstring(tolua_S,4,0)); MenuItemImage* tolua_ret = (MenuItemImage*) MenuItemImage::create(normalImage,selectedImage,disabledImage); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.MenuItemImage"); return 1; } while (0); CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_MenuItemImage_create'.\n",&tolua_err); #endif return 0; } static int tolua_cocos2d_MenuItemLabel_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.MenuItemLabel",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if(1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,2,"cc.Node",0,&tolua_err) ) { goto tolua_lerror; } #endif Node* label = ((Node*) tolua_tousertype(tolua_S,2,0)); MenuItemLabel* tolua_ret = (MenuItemLabel*) MenuItemLabel::create(label); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.MenuItemLabel"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_MenuItemFont_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.MenuItemFont",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if(1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(tolua_S, 2, 0, &tolua_err)) { goto tolua_lerror; } #endif const std::string value = ((const std::string) tolua_tocppstring(tolua_S,2,0)); MenuItemFont* tolua_ret = (MenuItemFont*) MenuItemFont::create(value); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.MenuItemFont"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_MenuItemSprite_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.MenuItemSprite",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if(argc >= 2 && argc <= 3) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,2,"cc.Node",0,&tolua_err) || !tolua_isusertype(tolua_S,3,"cc.Node",0,&tolua_err) ) { goto tolua_lerror; } if (3 == argc && !tolua_isusertype(tolua_S,4,"cc.Node",0,&tolua_err)) { goto tolua_lerror; } #endif Node* normalSprite = ((Node*) tolua_tousertype(tolua_S,2,0)); Node* selectedSprite = ((Node*) tolua_tousertype(tolua_S,3,0)); Node* disabledSprite = NULL; if (3 == argc) { disabledSprite = (Node*) tolua_tousertype(tolua_S,4,0); } MenuItemSprite* tolua_ret = (MenuItemSprite*) MenuItemSprite::create(normalSprite,selectedSprite,disabledSprite); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.MenuItemSprite"); return 1; } CCLOG("create has wrong number of arguments: %d, was expecting %d\n", argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Menu_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc > 0 ) { Vector items; uint32_t i = 1; while (i <= argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, 1 + i, "cc.MenuItem", 0, &tolua_err)) goto tolua_lerror; #endif cocos2d::MenuItem* item = static_cast(tolua_tousertype(tolua_S, 1 + i, NULL)); if (NULL != item) { items.pushBack(item); ++i; } } cocos2d::Menu* tolua_ret = cocos2d::Menu::createWithArray(items); //UnCheck int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Menu"); return 1; } else if(argc == 0) { cocos2d::Menu* tolua_ret = cocos2d::Menu::create(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Menu"); return 1; } CCLOG("create wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Menu_create'.\n",&tolua_err); #endif return 0; } static int tolua_cocos2dx_Menu_alignItemsInRows(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; Menu* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_Menu_alignItemsInRows'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc > 0) { ValueVector items; if (luavals_variadic_to_ccvaluevector(tolua_S, argc, &items)) { self->alignItemsInRowsWithArray(items); } return 0; } CCLOG("'alignItemsInRows' has wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInRows: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'alignItemsInRows'.\n",&tolua_err); #endif return 0; } static int tolua_cocos2dx_Menu_alignItemsInColumns(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; Menu* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Menu",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Menu_alignItemsInColumns'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc > 0) { ValueVector items; if (luavals_variadic_to_ccvaluevector(tolua_S, argc, &items)) { self->alignItemsInColumnsWithArray(items); } return 0; } CCLOG("'alignItemsInColumns' has wrong number of arguments in tolua_cocos2dx_Menu_alignItemsInColumns: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'alignItemsInColumns'.\n",&tolua_err); #endif return 0; } static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.MenuItemToggle",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if(argc >= 1) { MenuItemToggle* tolua_ret = MenuItemToggle::create(); if (NULL == tolua_ret) { return 0; } for (uint32_t i = 0; i < argc; ++i) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, i + 2,"cc.MenuItem",0,&tolua_err) ) { goto tolua_lerror; } #endif MenuItem* item = static_cast(tolua_tousertype(tolua_S, i + 2,0)); tolua_ret->addSubItem(item); } tolua_ret->setSelectedIndex(0); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.MenuItemToggle"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; MenuItem* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)cobj, handler, ScriptHandlerMgr::HandlerType::MENU_CLICKED); return 0; } CCLOG("'registerScriptTapHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptTapHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; MenuItem* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.MenuItem",0,&tolua_err)) goto tolua_lerror; #endif cobj = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)cobj, ScriptHandlerMgr::HandlerType::MENU_CLICKED); return 0; } CCLOG("'unregisterScriptTapHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptTapHandler'.",&tolua_err); return 0; #endif } static int executeScriptTouchHandler(Layer* layer, EventTouch::EventCode eventType, Touch* touch) { TouchScriptData data(eventType, layer, touch); ScriptEvent event(kTouchEvent, &data); return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } static int executeScriptTouchesHandler(Layer* layer, EventTouch::EventCode eventType, const std::vector& touches) { TouchesScriptData data(eventType, layer, touches); ScriptEvent event(kTouchesEvent, &data); return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } static void setTouchEnabledForLayer(Layer* layer, bool enabled) { if (nullptr == layer) return; auto dict = static_cast(layer->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); layer->setUserObject(dict); } dict->setObject(Bool::create(enabled), "touchEnabled"); auto touchListenerAllAtOnce = static_cast(dict->objectForKey("touchListenerAllAtOnce")); auto touchListenerOneByOne = static_cast(dict->objectForKey("touchListenerOneByOne")); auto touchMode = static_cast(dict->objectForKey("touchMode")); auto swallowTouches = static_cast(dict->objectForKey("swallowTouches")); auto priority = static_cast(dict->objectForKey("priority")); auto dispatcher = layer->getEventDispatcher(); if (nullptr != dispatcher && (touchListenerAllAtOnce != nullptr || touchListenerOneByOne != nullptr)) { dispatcher->removeEventListener(touchListenerAllAtOnce); dispatcher->removeEventListener(touchListenerOneByOne); dict->removeObjectForKey("touchListenerAllAtOnce"); dict->removeObjectForKey("touchListenerOneByOne"); touchListenerAllAtOnce = nullptr; touchListenerOneByOne = nullptr; } if (enabled) { if (touchMode == nullptr || touchMode->getValue() == (int)Touch::DispatchMode::ALL_AT_ONCE) { auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = [layer](const std::vector& touches, Event* event){ executeScriptTouchesHandler(layer, EventTouch::EventCode::BEGAN, touches); }; listener->onTouchesMoved = [layer](const std::vector& touches, Event* event){ executeScriptTouchesHandler(layer, EventTouch::EventCode::MOVED, touches); }; listener->onTouchesEnded = [layer](const std::vector& touches, Event* event){ executeScriptTouchesHandler(layer, EventTouch::EventCode::ENDED, touches); }; listener->onTouchesCancelled = [layer](const std::vector& touches, Event* event){ executeScriptTouchesHandler(layer, EventTouch::EventCode::CANCELLED, touches); }; if (nullptr != priority && 0 != priority->getValue()) { dispatcher->addEventListenerWithFixedPriority(listener, priority->getValue()); } else { dispatcher->addEventListenerWithSceneGraphPriority(listener, layer); } dict->setObject(listener, "touchListenerAllAtOnce"); } else { auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(swallowTouches ? swallowTouches->getValue() : false); listener->onTouchBegan = [layer](Touch* touch, Event* event) -> bool{ return executeScriptTouchHandler(layer, EventTouch::EventCode::BEGAN, touch) == 0 ? false : true; }; listener->onTouchMoved = [layer](Touch* touch, Event* event){ executeScriptTouchHandler(layer, EventTouch::EventCode::MOVED, touch); }; listener->onTouchEnded = [layer](Touch* touch, Event* event){ executeScriptTouchHandler(layer, EventTouch::EventCode::ENDED, touch); }; listener->onTouchCancelled = [layer](Touch* touch, Event* event){ executeScriptTouchHandler(layer, EventTouch::EventCode::CANCELLED, touch); }; if (nullptr != priority && 0 != priority->getValue()) { dispatcher->addEventListenerWithFixedPriority(listener, priority->getValue()); } else { dispatcher->addEventListenerWithSceneGraphPriority(listener, layer); } dict->setObject(listener, "touchListenerOneByOne"); } } } //Only for v2.x lua compatibility static int lua_cocos2dx_Layer_setTouchPriority(lua_State* L) { return 0; } static int lua_cocos2dx_Layer_setTouchEnabled(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_setTouchEnabled'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(L, 2, 0, &tolua_err)) { goto tolua_lerror; } #endif bool enabled = tolua_toboolean(L, 2, 0); setTouchEnabledForLayer(self, enabled); return 0; } CCLOG("'setTouchEnabled' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setTouchEnabled'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_isTouchEnabled(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_isTouchEnabled'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { auto dict = static_cast(self->getUserObject()); if (dict != nullptr) { Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); bool ret = enabled ? enabled->getValue() : false; tolua_pushboolean(L, ret); return 1; } return 0; } CCLOG("'isTouchEnabled' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'isTouchEnabled'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_setTouchMode(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_setTouchMode'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(L, 2, 0, &tolua_err)) { goto tolua_lerror; } #endif int32_t mode = (int32_t)tolua_tonumber(L, 2, 0); auto dict = static_cast(self->getUserObject()); if ( nullptr == dict) { dict = Dictionary::create(); self->setUserObject(dict); } Integer* touchModeObj = static_cast(dict->objectForKey("touchMode")); int32_t touchMode = touchModeObj ? touchModeObj->getValue() : 0; if (touchMode != mode) { dict->setObject(Integer::create(mode), "touchMode"); Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); if (enabled && enabled->getValue()) { setTouchEnabledForLayer(self, false); setTouchEnabledForLayer(self, true); } } return 0; } CCLOG("'setTouchMode' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setTouchMode'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_getTouchMode(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_getTouchMode'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { int32_t ret = 0; auto dict = static_cast(self->getUserObject()); if (dict != nullptr) { Integer* mode = static_cast(dict->objectForKey("touchMode")); ret = mode ? mode->getValue() : 0; tolua_pushnumber(L, (lua_Number)ret); return 1; } return 0; } CCLOG("'getTouchMode' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'getTouchMode'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_setSwallowsTouches(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_setSwallowsTouches'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif bool swallowsTouches = tolua_toboolean(L, 2, 0); Bool* swallowsTouchesObj = nullptr; auto dict = static_cast(self->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); self->setUserObject(dict); } swallowsTouchesObj = static_cast(dict->objectForKey("swallowTouches")); bool oldSwallowsTouches = swallowsTouchesObj ? swallowsTouchesObj->getValue() : false; if (oldSwallowsTouches != swallowsTouches) { dict->setObject(Integer::create(swallowsTouches), "swallowTouches"); Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); if (enabled && enabled->getValue()) { setTouchEnabledForLayer(self, false); setTouchEnabledForLayer(self, true); } } return 0; } CCLOG("'setSwallowsTouches' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setSwallowsTouches'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_isSwallowsTouches(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_isSwallowsTouches'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { auto dict = static_cast(self->getUserObject()); if (dict != nullptr) { Bool* swallowTouches = static_cast(dict->objectForKey("swallowTouches")); bool ret = swallowTouches ? swallowTouches->getValue() : false; lua_pushboolean(L, ret); return 1; } return 0; } CCLOG("'isSwallowsTouches' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'isSwallowsTouches'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_setKeyboardEnabled(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_setKeyboardEnabled'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif bool enabled = tolua_toboolean(L, 2, 0); auto dict = static_cast(self->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); self->setUserObject(dict); } dict->setObject(Bool::create(enabled), "keyboardEnabled"); auto keyboardListener = static_cast(dict->objectForKey("keyboardListener")); auto dispatcher = self->getEventDispatcher(); dispatcher->removeEventListener(keyboardListener); if (enabled) { auto listener = EventListenerKeyboard::create(); listener->onKeyPressed = [self](EventKeyboard::KeyCode keyCode, Event* event){ }; listener->onKeyReleased = [self](EventKeyboard::KeyCode keyCode, Event* event){ KeypadScriptData data(keyCode, self); ScriptEvent scriptEvent(kKeypadEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); }; CCLOG("come in the keyboardEnable"); dispatcher->addEventListenerWithSceneGraphPriority(listener, self); dict->setObject(listener, "keyboardListener"); } return 0; } CCLOG("'setKeyboardEnabled' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setKeyboardEnabled'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_isKeyboardEnabled(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_isKeyboardEnabled'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { auto dict = static_cast(self->getUserObject()); if (dict != nullptr) { Bool* enabled = static_cast(dict->objectForKey("keyboardEnabled")); bool ret = enabled ? enabled->getValue() : false; tolua_pushboolean(L, ret); return 1; } return 0; } CCLOG("'isKeyboardEnabled' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'isKeyboardEnabled'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_setAccelerometerEnabled(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_setAccelerometerEnabled'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif bool enabled = tolua_toboolean(L, 2, 0); auto dict = static_cast(self->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); self->setUserObject(dict); } dict->setObject(Bool::create(enabled), "accelerometerEnabled"); auto accListener = static_cast(dict->objectForKey("accListener")); auto dispatcher = self->getEventDispatcher(); dispatcher->removeEventListener(accListener); Device::setAccelerometerEnabled(enabled); if (enabled) { auto listener = EventListenerAcceleration::create([self](Acceleration* acc, Event* event){ BasicScriptData data(self,(void*)acc); ScriptEvent accEvent(kAccelerometerEvent,&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&accEvent); }); dispatcher->addEventListenerWithSceneGraphPriority(listener, self); dict->setObject(listener, "accListener"); } return 0; } CCLOG("'setAccelerometerEnabled' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setAccelerometerEnabled'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_isAccelerometerEnabled(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_isAccelerometerEnabled'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { auto dict = static_cast(self->getUserObject()); if (dict != nullptr) { Bool* enabled = static_cast(dict->objectForKey("accelerometerEnabled")); bool ret = enabled ? enabled->getValue() : false; tolua_pushboolean(L, ret); return 1; } return 0; } CCLOG("'isAccelerometerEnabled' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'isAccelerometerEnabled'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Layer_setAccelerometerInterval(lua_State* L) { if (nullptr == L) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Layer_setAccelerometerInterval'\n", NULL); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif double interval = tolua_tonumber(L, 2, 0); Device::setAccelerometerEnabled(interval); return 0; } CCLOG("'setAccelerometerInterval' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setAccelerometerInterval'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Layer_registerScriptTouchHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptTouchHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc >=1 && argc <= 4) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); bool isMultiTouches = false; int priority = 0; bool swallowTouches = true; if (argc >= 2) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(tolua_S,3,0,&tolua_err)) { goto tolua_lerror; } #endif isMultiTouches = (bool)tolua_toboolean(tolua_S,3,false); } if (argc >= 3) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S,4,0,&tolua_err)) { goto tolua_lerror; } #endif priority = (int)tolua_tonumber(tolua_S,4,0); } if (argc == 4) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(tolua_S,5,0,&tolua_err)) { goto tolua_lerror; } #endif swallowTouches = (bool)tolua_toboolean(tolua_S,5,true); } Touch::DispatchMode touchesMode = Touch::DispatchMode::ALL_AT_ONCE; if (!isMultiTouches) touchesMode = Touch::DispatchMode::ONE_BY_ONE; auto dict = static_cast(self->getUserObject()); if (dict == nullptr) { dict = Dictionary::create(); self->setUserObject(dict); } auto touchModeValue = static_cast(dict->objectForKey("touchMode")); auto swallowTouchesValue = static_cast(dict->objectForKey("swallowTouches")); auto priorityValue = static_cast(dict->objectForKey("priority")); //touch model int32_t mode = touchModeValue?touchModeValue->getValue() : 0; if (mode != (int)touchesMode) { dict->setObject(Integer::create((int)touchesMode), "touchMode"); Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); if (enabled && enabled->getValue()) { setTouchEnabledForLayer(self, false); setTouchEnabledForLayer(self, true); } } int oldPriorityValue = priorityValue?priorityValue->getValue() : 0; if (priority != oldPriorityValue) { dict->setObject(Integer::create(priority), "priority"); Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); if (enabled && enabled->getValue()) { setTouchEnabledForLayer(self, false); setTouchEnabledForLayer(self, true); } } //swallowsTouches Obj bool oldSwallowTouchesValue = swallowTouchesValue?swallowTouchesValue->getValue():false; if (oldSwallowTouchesValue != swallowTouches) { dict->setObject(Integer::create(swallowTouches), "swallowTouches"); Bool* enabled = static_cast(dict->objectForKey("touchEnabled")); if (enabled && enabled->getValue()) { setTouchEnabledForLayer(self, false); setTouchEnabledForLayer(self, true); } } ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::TOUCHES); return 0; } CCLOG("'registerScriptTouchHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptTouchHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Layer_unregisterScriptTouchHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptTouchHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { auto dict = static_cast(self->getUserObject()); if (dict != nullptr) { auto touchListenerAllAtOnce = static_cast(dict->objectForKey("touchListenerAllAtOnce")); auto touchListenerOneByOne = static_cast(dict->objectForKey("touchListenerOneByOne")); auto dispatcher = self->getEventDispatcher(); if (nullptr != dispatcher) { dispatcher->removeEventListener(touchListenerAllAtOnce); dispatcher->removeEventListener(touchListenerOneByOne); } } ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::HandlerType::TOUCHES); return 0; } CCLOG("'unregisterScriptTouchHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptTapHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptKeypadHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::KEYPAD); return 0; } CCLOG("'registerScriptKeypadHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptKeypadHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptKeypadHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { auto dict = static_cast(self->getUserObject()); if (dict != nullptr) { auto keyboardListener = static_cast(dict->objectForKey("keyboardListener")); auto dispatcher = self->getEventDispatcher(); if (dispatcher != nullptr) { dispatcher->removeEventListener(keyboardListener); } } ScriptHandlerMgr::getInstance()->removeObjectHandler(self, ScriptHandlerMgr::HandlerType::KEYPAD); return 0; } CCLOG("'unregisterScriptKeypadHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptKeypadHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptAccelerateHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::ACCELEROMETER); return 0; } CCLOG("'registerScriptAccelerateHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptAccelerateHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; Layer* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Layer",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptAccelerateHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { auto dict = static_cast(self->getUserObject()); if (dict != nullptr) { auto accListener = static_cast(dict->objectForKey("accListener")); auto dispatcher = self->getEventDispatcher(); if (dispatcher != nullptr) { dispatcher->removeEventListener(accListener); } } ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::HandlerType::ACCELEROMETER); return 0; } CCLOG("'unregisterScriptAccelerateHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptAccelerateHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Scheduler* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Scheduler",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (3 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isboolean(tolua_S,4,0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); float interval = (float) tolua_tonumber(tolua_S,3,0); bool paused = (bool) tolua_toboolean(tolua_S,4,0); unsigned int tolua_ret = (unsigned int) self->scheduleScriptFunc(handler,interval,paused); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); return 1; } CCLOG("'scheduleScriptFunc' has wrong number of arguments: %d, was expecting %d\n", argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'scheduleScriptFunc'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Scheduler_unscheduleScriptEntry(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Scheduler* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Scheduler",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Scheduler_unscheduleScriptEntry'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) { goto tolua_lerror; } #endif unsigned int scheduleScriptEntryID = ((unsigned int) tolua_tonumber(tolua_S,2,0)); self->unscheduleScriptEntry(scheduleScriptEntryID); return 0; } CCLOG("'unscheduleScriptEntry' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unscheduleScriptEntry'.",&tolua_err); return 0; #endif } int tolua_cocos2d_Sequence_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; tolua_Error tolua_err; #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Sequence",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if(argc > 0) { Vector array; if (1 == argc && tolua_istable(tolua_S, 2, 0, &tolua_err)) { luaval_to_ccvector(tolua_S, 2, &array); } else { uint32_t i = 1; while (i <= argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, 1 + i, "cc.FiniteTimeAction", 0, &tolua_err)) goto tolua_lerror; #endif cocos2d::FiniteTimeAction* item = static_cast(tolua_tousertype(tolua_S, 1 + i, NULL)); if (NULL != item) { array.pushBack(item); ++i; } } } cocos2d::Sequence* tolua_ret = cocos2d::Sequence::create(array); //issue 2433 uncheck int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Sequence"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_CallFunc_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.CallFunc",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1 || argc == 2) { #if COCOS2D_DEBUG >= 1 if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) goto tolua_lerror; #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); bool hasExtraData = false; int ref = 0; if (argc == 2) { #if COCOS2D_DEBUG >= 1 if(!tolua_istable(tolua_S, 3, 0, &tolua_err)) goto tolua_lerror; #endif lua_pushvalue(tolua_S, 3); ref = luaL_ref(tolua_S, LUA_REGISTRYINDEX); hasExtraData = true; } LuaCallFunc* tolua_ret = new LuaCallFunc(); tolua_ret->initWithFunction([=](void* self,Node* target){ int callbackHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)tolua_ret, ScriptHandlerMgr::HandlerType::CALLFUNC); if (0 != callbackHandler) { LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); int argNums = 1; if (nullptr != target) { stack->pushObject(target, "cc.Node"); } else { stack->pushNil(); } if (hasExtraData) { lua_rawgeti(tolua_S, LUA_REGISTRYINDEX,ref); if (lua_istable(tolua_S, -1)) { argNums += 1; } else { lua_pop(tolua_S, 1); } } stack->executeFunctionByHandler(callbackHandler, argNums); if (hasExtraData) { luaL_unref(tolua_S, LUA_REGISTRYINDEX,ref); } stack->clean(); } }); tolua_ret->autorelease(); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)tolua_ret, handler, ScriptHandlerMgr::HandlerType::CALLFUNC); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CallFunc"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Node_registerScriptHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Node* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_registerScriptHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { #if COCOS2D_DEBUG >= 1 if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) goto tolua_lerror; #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::NODE); return 0; } CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Node_unregisterScriptHandler(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Node* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_unregisterScriptHandler'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::HandlerType::NODE); return 0; } CCLOG("'unregisterScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Node* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { #if COCOS2D_DEBUG >= 1 if(!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) goto tolua_lerror; #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); int priority = 0; if (luaval_to_int32(tolua_S, 3, &priority)) { self->scheduleUpdateWithPriorityLua(handler,priority); } return 0; } CCLOG("'scheduleUpdateWithPriorityLua' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'scheduleUpdateWithPriorityLua'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Node_unscheduleUpdate(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Node* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_unscheduleUpdate'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { self->unscheduleUpdate(); return 0; } CCLOG("'unscheduleUpdate' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unscheduleUpdate'.",&tolua_err); return 0; #endif } int tolua_cocos2d_Node_setContentSize(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setContentSize'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (1 == argc) { cocos2d::Size size; ok &= luaval_to_size(tolua_S, 2, &size); if (!ok) return 0; cobj->setContentSize(size); return 0; } else if(2 == argc) { double width; ok &= luaval_to_number(tolua_S, 2,&width); if (!ok) return 0; double height; ok &= luaval_to_number(tolua_S, 3,&height); if (!ok) return 0; cobj->setContentSize(Size(width, height)); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setContentSize",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setContentSize'.",&tolua_err); #endif return 0; } int tolua_cocos2d_Node_setAnchorPoint(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = NULL; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setAnchorPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (1 == argc) { cocos2d::Point pt; ok &= luaval_to_point(tolua_S, 2, &pt); if (!ok) return 0; cobj->setAnchorPoint(pt); return 0; } else if(2 == argc) { double x; ok &= luaval_to_number(tolua_S, 2,&x); if (!ok) return 0; double y; ok &= luaval_to_number(tolua_S, 3,&y); if (!ok) return 0; cobj->setAnchorPoint(Point(x,y)); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnchorPoint",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setAnchorPoint'.",&tolua_err); #endif return 0; } static int tolua_cocos2d_Node_getPosition(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; Node* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Node_getPosition'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc >= 0 && argc <= 2) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S,2,1,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) ) goto tolua_lerror; #endif float x = (float) tolua_tonumber(tolua_S,2,0); float y = (float) tolua_tonumber(tolua_S,3,0); self->getPosition(&x,&y); tolua_pushnumber(tolua_S,(lua_Number)x); tolua_pushnumber(tolua_S,(lua_Number)y); return 2; } CCLOG("'getPosition' function in Node has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getPosition'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_Spawn_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; tolua_Error tolua_err; #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.Spawn",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc > 0) { Vector array; uint32_t i = 1; if (1 == argc && tolua_istable(tolua_S, 2, 0, &tolua_err)) { luaval_to_ccvector(tolua_S, 2, &array); } else { while (i <= argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, 1 + i, "cc.FiniteTimeAction", 0, &tolua_err)) goto tolua_lerror; #endif cocos2d::FiniteTimeAction* item = static_cast(tolua_tousertype(tolua_S, 1 + i, NULL)); if (NULL != item) { array.pushBack(item); ++i; } } } cocos2d::Spawn * tolua_ret = cocos2d::Spawn::create(array); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Spawn"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } int lua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.CardinalSplineBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 3) { double dur = 0.0; ok &= luaval_to_number(tolua_S, 2, &dur); if (!ok) return false; int num = 0; Point *arr = NULL; ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); if (!ok) return false; double ten = 0.0; ok &= luaval_to_number(tolua_S, 4, &ten); if (!ok) return false; if (num > 0) { PointArray* points = PointArray::create(num); if (NULL == points) { free(arr); return 0; } for( int i = 0; i < num; i++) { points->addControlPoint(arr[i]); } free(arr); CardinalSplineBy* tolua_ret = CardinalSplineBy::create(dur, points, ten); if (NULL != tolua_ret) { int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CardinalSplineBy"); return 1; } } } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } int tolua_cocos2d_CatmullRomBy_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.CatmullRomBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double dur = 0.0; ok &= luaval_to_number(tolua_S, 2, &dur); if (!ok) return false; int num = 0; Point *arr = NULL; ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); if (!ok) return false; if (num > 0) { PointArray* points = PointArray::create(num); if (NULL == points) { free(arr); return 0; } for( int i = 0; i < num; i++) { points->addControlPoint(arr[i]); } free(arr); CatmullRomBy* tolua_ret = CatmullRomBy::create(dur, points); if (NULL != tolua_ret) { int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CatmullRomBy"); return 1; } } } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } int tolua_cocos2d_CatmullRomTo_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.CatmullRomTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double dur = 0.0; ok &= luaval_to_number(tolua_S, 2, &dur); if (!ok) return false; int num = 0; Point *arr = NULL; ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); if (!ok) return false; if (num > 0) { PointArray* points = PointArray::create(num); if (NULL == points) { free(arr); return 0; } for( int i = 0; i < num; i++) { points->addControlPoint(arr[i]); } free(arr); CatmullRomTo* tolua_ret = CatmullRomTo::create(dur, points); if (NULL != tolua_ret) { int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CatmullRomTo"); return 1; } } } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } int tolua_cocos2d_BezierBy_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.BezierBy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double t = 0.0; ok &= luaval_to_number(tolua_S, 2, &t); if (!ok) return false; int num = 0; Point *arr = NULL; ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); if (!ok) return false; if (num < 3) { free(arr); return false; } ccBezierConfig config; config.controlPoint_1 = arr[0]; config.controlPoint_2 = arr[1]; config.endPosition = arr[2]; free(arr); BezierBy* tolua_ret = BezierBy::create(t, config); if (NULL != tolua_ret) { int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.BezierBy"); return 1; } } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } int tolua_cocos2d_BezierTo_create(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.BezierTo",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { double t = 0.0; ok &= luaval_to_number(tolua_S, 2, &t); if (!ok) return false; int num = 0; Point *arr = NULL; ok &= luaval_to_array_of_Point(tolua_S, 3, &arr, &num); if (!ok) return false; if (num < 3) { free(arr); return false; } ccBezierConfig config; config.controlPoint_1 = arr[0]; config.controlPoint_2 = arr[1]; config.endPosition = arr[2]; free(arr); BezierTo* tolua_ret = BezierTo::create(t, config); if (NULL != tolua_ret) { int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.BezierTo"); return 1; } } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_DrawNode_drawPolygon(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; DrawNode* self = nullptr; tolua_Error tolua_err; #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_DrawNode_drawPolygon'\n", NULL); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (5 == argc) { #if COCOS2D_DEBUG >= 1 if( !tolua_istable(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_istable(tolua_S, 4, 0,&tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) || !tolua_istable(tolua_S,6, 0,&tolua_err) ) { goto tolua_lerror; } #endif size_t size = lua_tonumber(tolua_S, 3); if ( size > 0 ) { Point* points = new Point[size]; if (NULL == points) return 0; for (int i = 0; i < size; i++) { lua_pushnumber(tolua_S,i + 1); lua_gettable(tolua_S,2); if (!tolua_istable(tolua_S,-1, 0, &tolua_err)) { CC_SAFE_DELETE_ARRAY(points); #if COCOS2D_DEBUG >= 1 goto tolua_lerror; #endif } if(!luaval_to_point(tolua_S, lua_gettop(tolua_S), &points[i])) { lua_pop(tolua_S, 1); CC_SAFE_DELETE_ARRAY(points); return 0; } lua_pop(tolua_S, 1); } Color4F fillColor; if (!luaval_to_color4f(tolua_S, 4, &fillColor)) { CC_SAFE_DELETE_ARRAY(points); return 0; } float borderWidth = (float)tolua_tonumber(tolua_S, 5, 0); Color4F borderColor; if (!luaval_to_color4f(tolua_S, 6, &borderColor)) { CC_SAFE_DELETE_ARRAY(points); return 0; } self->drawPolygon(points, size, fillColor, borderWidth, borderColor); CC_SAFE_DELETE_ARRAY(points); return 0; } } CCLOG("'drawPolygon' has wrong number of arguments: %d, was expecting %d\n", argc, 5); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawPolygon'.",&tolua_err); return 0; #endif } // setBlendFunc template static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S,const char* className) { if (NULL == tolua_S || NULL == className || strlen(className) == 0) return 0; int argc = 0; T* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,className,0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); argc = lua_gettop(tolua_S) - 1; if (2 == argc) { GLenum src, dst; if (!luaval_to_int32(tolua_S, 2, (int32_t*)&src)) return 0; if (!luaval_to_int32(tolua_S, 3, (int32_t*)&dst)) return 0; BlendFunc blendFunc = {src, dst}; self->setBlendFunc(blendFunc); return 0; } CCLOG("'setBlendFunc' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setBlendFunc'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_Sprite_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.Sprite"); } static int tolua_cocos2dx_SpriteBatchNode_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.SpriteBatchNode"); } static int tolua_cocos2dx_MotionStreak_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.MotionStreak"); } static int tolua_cocos2dx_AtlasNode_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.AtlasNode"); } static int tolua_cocos2dx_ParticleBatchNode_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.ParticleBatchNode"); } static int tolua_cocos2dx_LayerColor_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.LayerColor"); } static int tolua_cocos2dx_ParticleSystem_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.ParticleSystem"); } static int tolua_cocos2dx_DrawNode_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"cc.DrawNode"); } static int tolua_cocos2dx_LayerMultiplex_create(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; Vector arg0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S, 1, "cc.LayerMultiplex", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc > 0) { if (luavals_variadic_to_ccvector(tolua_S, argc, &arg0)) { LayerMultiplex* tolua_ret = LayerMultiplex::createWithArray(arg0); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.LayerMultiplex"); return 1; } else { CCLOG("error in tolua_cocos2dx_LayerMultiplex_create \n"); return 0; } } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_FileUtils_getStringFromFile(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; FileUtils* self = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_FileUtils_getStringFromFile'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (1 == argc) { const char* arg0; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); if (ok) { std::string fullPathName = FileUtils::getInstance()->fullPathForFilename(arg0); String* contentsOfFile = String::createWithContentsOfFile(fullPathName.c_str()); if (nullptr != contentsOfFile) { const char* tolua_ret = contentsOfFile->getCString(); tolua_pushstring(tolua_S, tolua_ret); } return 1; } } CCLOG("'getStringFromFile' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getStringFromFile'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_UserDefault_getInstance(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.UserDefault",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if(0 == argc) { UserDefault* tolua_ret = (UserDefault*) UserDefault::getInstance(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"cc.UserDefault"); return 1; } CCLOG("'getInstance' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getInstance'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_GLProgram_create(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; bool ok = false; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if(2 == argc) { const char *arg0, *arg1; std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); GLProgram* tolua_ret = new GLProgram(); if (nullptr == tolua_ret) return 0; tolua_ret->autorelease(); tolua_ret->initWithVertexShaderFilename(arg0, arg1); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.GLProgram"); return 1; } CCLOG("'create' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_GLProgram_getProgram(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; GLProgram* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif self = (GLProgram*) tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_GLProgram_getProgram'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (0 == argc) { unsigned const int tolua_ret = ( unsigned const int) self->getProgram(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); return 1; } CCLOG("'getProgram' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getProgram'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_GLProgram_setUniformLocationF32(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; GLProgram* self = nullptr; int location = 0; double f1 = 0.0; double f2 = 0.0; double f3 = 0.0; double f4 = 0.0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; #endif self = (GLProgram*) tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_GLProgram_getProgram'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc >= 2 && argc <= 5) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err)) { goto tolua_lerror; } #endif location = (int) tolua_tonumber(tolua_S,2,0); f1 = (float) tolua_tonumber(tolua_S,3,0); if (2 == argc) { self->setUniformLocationWith1f(location,f1); return 0; } if (argc >= 3) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S,4,0,&tolua_err)) goto tolua_lerror; #endif f2 = (float) tolua_tonumber(tolua_S,3,0); if (3 == argc) { self->setUniformLocationWith2f(location, f1, f2); return 0; } } if (argc >= 4) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S,5,0,&tolua_err)) goto tolua_lerror; #endif f3 = (float) tolua_tonumber(tolua_S,3,0); if (4 == argc) { self->setUniformLocationWith3f(location, f1, f2, f3); return 0; } } if (argc == 5) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S,6,0,&tolua_err)) goto tolua_lerror; #endif f4 = (float) tolua_tonumber(tolua_S,3,0); if (4 == argc) { self->setUniformLocationWith4f(location, f1, f2, f3, f4); return 0; } } } CCLOG("'setUniformLocationF32' function of GLProgram wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setUniformLocationF32'.",&tolua_err); return 0; #endif } static void extendGLProgram(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.GLProgram"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2dx_GLProgram_create ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"getProgram"); lua_pushcfunction(tolua_S,tolua_cocos2d_GLProgram_getProgram ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"setUniformLocationF32"); lua_pushcfunction(tolua_S,tolua_cocos2dx_GLProgram_setUniformLocationF32 ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static int tolua_cocos2dx_Texture2D_setTexParameters(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; Texture2D* self = nullptr; GLuint arg1 = 0; GLuint arg2 = 0; GLuint arg3 = 0; GLuint arg4 = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; #endif self = (Texture2D*) tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Texture2D_setTexParameters'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (4 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err)) { goto tolua_lerror; } #endif arg1 = (GLuint)tolua_tonumber(tolua_S, 2, 0); arg2 = (GLuint)tolua_tonumber(tolua_S, 3, 0); arg3 = (GLuint)tolua_tonumber(tolua_S, 4, 0); arg4 = (GLuint)tolua_tonumber(tolua_S, 5, 0); Texture2D::TexParams param = { arg1, arg2, arg3, arg4 }; self->setTexParameters(param); return 0; } CCLOG("'setTexParameters' function of Texture2D wrong number of arguments: %d, was expecting %d\n", argc,4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setTexParameters'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_SpriteBatchNode_getDescendants(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; cocos2d::SpriteBatchNode* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2dx_SpriteBatchNode_getDescendants'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; std::vector ret = cobj->getDescendants(); lua_newtable(tolua_S); if (ret.empty()) return 1; auto iter = ret.begin(); int indexTable = 1; for (; iter != ret.end(); ++iter) { if (nullptr == *iter) continue; lua_pushnumber(tolua_S, (lua_Number)indexTable); toluafix_pushusertype_ccobject(tolua_S, (*iter)->_ID, &((*iter)->_luaID), (void*)(*iter),"cc.Sprite"); lua_rawset(tolua_S, -3); (*iter)->retain(); ++indexTable; } return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDescendants",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_getDescendants'.",&tolua_err); #endif return 0; } static void extendTexture2D(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.Texture2D"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setTexParameters"); lua_pushcfunction(tolua_S,tolua_cocos2dx_Texture2D_setTexParameters ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendMenuItem(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.MenuItem"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"registerScriptTapHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItem_registerScriptTapHandler); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "unregisterScriptTapHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItem_unregisterScriptTapHandler); lua_rawset(tolua_S, -3); } lua_pop(tolua_S, 1); } static void extendMenuItemImage(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.MenuItemImage"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemImage_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendMenuItemLabel(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.MenuItemLabel"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemLabel_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendMenuItemFont(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.MenuItemFont"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemFont_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendMenuItemSprite(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.MenuItemSprite"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemSprite_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendMenuItemToggle(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.MenuItemToggle"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_MenuItemToggle_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendMenu(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.Menu"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S, -1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_Menu_create); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"alignItemsInRows"); lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInRows); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"alignItemsInColumns"); lua_pushcfunction(tolua_S,tolua_cocos2dx_Menu_alignItemsInColumns); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendNode(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.Node"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"registerScriptHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_Node_registerScriptHandler); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"unregisterScriptHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unregisterScriptHandler); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S,"scheduleUpdateWithPriorityLua"); lua_pushcfunction(tolua_S,tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S,"unscheduleUpdate"); lua_pushcfunction(tolua_S,tolua_cocos2d_Node_unscheduleUpdate); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S,"getPosition"); lua_pushcfunction(tolua_S,tolua_cocos2d_Node_getPosition); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S, "setContentSize"); lua_pushcfunction(tolua_S, tolua_cocos2d_Node_setContentSize); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S, "setAnchorPoint"); lua_pushcfunction(tolua_S, tolua_cocos2d_Node_setAnchorPoint); lua_rawset(tolua_S, -3); } lua_pop(tolua_S, 1); } static void extendLayer(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.Layer"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"registerScriptTouchHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_registerScriptTouchHandler); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "unregisterScriptTouchHandler"); lua_pushcfunction(tolua_S,tolua_cocos2d_Layer_unregisterScriptTouchHandler); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S, "registerScriptKeypadHandler"); lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptKeypadHandler); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S, "unregisterScriptKeypadHandler"); lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptKeypadHandler); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S, "registerScriptAccelerateHandler"); lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptAccelerateHandler); lua_rawset(tolua_S, -3); lua_pushstring(tolua_S, "unregisterScriptAccelerateHandler"); lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptAccelerateHandler); lua_rawset(tolua_S, -3); tolua_function(tolua_S, "setTouchEnabled", lua_cocos2dx_Layer_setTouchEnabled); tolua_function(tolua_S, "isTouchEnabled", lua_cocos2dx_Layer_isTouchEnabled); tolua_function(tolua_S, "setTouchMode", lua_cocos2dx_Layer_setTouchMode); tolua_function(tolua_S, "getTouchMode", lua_cocos2dx_Layer_getTouchMode); tolua_function(tolua_S, "setSwallowsTouches", lua_cocos2dx_Layer_setSwallowsTouches); tolua_function(tolua_S, "isSwallowsTouches", lua_cocos2dx_Layer_isSwallowsTouches); tolua_function(tolua_S, "setKeyboardEnabled", lua_cocos2dx_Layer_setKeyboardEnabled); tolua_function(tolua_S, "isKeyboardEnabled", lua_cocos2dx_Layer_isKeyboardEnabled); tolua_function(tolua_S, "setAccelerometerEnabled", lua_cocos2dx_Layer_setAccelerometerEnabled); tolua_function(tolua_S, "isAccelerometerEnabled", lua_cocos2dx_Layer_isAccelerometerEnabled); tolua_function(tolua_S, "setAccelerometerInterval", lua_cocos2dx_Layer_setAccelerometerInterval); } lua_pop(tolua_S, 1); } static void extendScheduler(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.Scheduler"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"scheduleScriptFunc"); lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_scheduleScriptFunc); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "unscheduleScriptEntry"); lua_pushcfunction(tolua_S,tolua_cocos2d_Scheduler_unscheduleScriptEntry); lua_rawset(tolua_S, -3); } lua_pop(tolua_S, 1); } static void extendSequence(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.Sequence"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_Sequence_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendCallFunc(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.CallFunc"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_CallFunc_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendSpawn(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.Spawn"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_Spawn_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendCardinalSplineBy(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.CardinalSplineBy"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,lua_cocos2d_CardinalSplineBy_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendCatmullRomBy(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.CatmullRomBy"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomBy_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendCatmullRomTo(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.CatmullRomTo"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_CatmullRomTo_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendBezierBy(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.BezierBy"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_BezierBy_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendBezierTo(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.BezierTo"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2d_BezierTo_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendDrawNode(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.DrawNode"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"drawPolygon"); lua_pushcfunction(tolua_S,tolua_cocos2d_DrawNode_drawPolygon); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"setBlendFunc"); lua_pushcfunction(tolua_S,tolua_cocos2dx_DrawNode_setBlendFunc); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendSprite(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.Sprite"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setBlendFunc"); lua_pushcfunction(tolua_S,tolua_cocos2dx_Sprite_setBlendFunc); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendLayerColor(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.LayerColor"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setBlendFunc"); lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerColor_setBlendFunc); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendLayerMultiplex(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.LayerMultiplex"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"create"); lua_pushcfunction(tolua_S,tolua_cocos2dx_LayerMultiplex_create); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendParticleSystem(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.ParticleSystem"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setBlendFunc"); lua_pushcfunction(tolua_S,tolua_cocos2dx_ParticleSystem_setBlendFunc); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendFileUtils(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.FileUtils"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getStringFromFile"); lua_pushcfunction(tolua_S,tolua_cocos2dx_FileUtils_getStringFromFile ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendUserDefault(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.UserDefault"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getInstance"); lua_pushcfunction(tolua_S,tolua_cocos2dx_UserDefault_getInstance ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendSpriteBatchNode(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.SpriteBatchNode"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getDescendants"); lua_pushcfunction(tolua_S,tolua_cocos2dx_SpriteBatchNode_getDescendants ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"setBlendFunc"); lua_pushcfunction(tolua_S,tolua_cocos2dx_SpriteBatchNode_setBlendFunc); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendMotionStreak(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.MotionStreak"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setBlendFunc"); lua_pushcfunction(tolua_S,tolua_cocos2dx_MotionStreak_setBlendFunc); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendAtlasNode(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.AtlasNode"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setBlendFunc"); lua_pushcfunction(tolua_S,tolua_cocos2dx_AtlasNode_setBlendFunc); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } static void extendParticleBatchNode(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.ParticleBatchNode"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"setBlendFunc"); lua_pushcfunction(tolua_S,tolua_cocos2dx_ParticleBatchNode_setBlendFunc); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); } NS_CC_BEGIN EventListenerAcceleration* LuaEventListenerAcceleration::create() { EventListenerAcceleration* eventAcceleration = new EventListenerAcceleration(); if (nullptr == eventAcceleration) return nullptr; if ( eventAcceleration->init([=](Acceleration* acc, Event* event){ LuaEventAccelerationData listenerData((void*)acc,event); BasicScriptData data(eventAcceleration,(void*)&listenerData); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::EVENT_ACC, (void*)&data); })) { eventAcceleration->autorelease(); } else { CC_SAFE_DELETE(eventAcceleration); } return eventAcceleration; } EventListenerCustom* LuaEventListenerCustom::create(const std::string& eventName) { EventListenerCustom* eventCustom = new EventListenerCustom(); if (nullptr == eventCustom) return nullptr; if ( eventCustom->init(eventName, [=](EventCustom* event){ BasicScriptData data((void*)eventCustom,(void*)event); LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::EVENT_CUSTIOM, (void*)&data ); })) { eventCustom->autorelease(); } else { CC_SAFE_DELETE(eventCustom); } return eventCustom; } NS_CC_END static int tolua_cocos2dx_LuaEventListenerAcceleration_create(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S, 1, "cc.EventListenerAcceleration", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); cocos2d::EventListenerAcceleration* tolua_ret = cocos2d::LuaEventListenerAcceleration::create(); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)tolua_ret, handler, ScriptHandlerMgr::HandlerType::EVENT_ACC); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerAcceleration"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2d_LuaEventListenerCustom_create(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S, 1, "cc.EventListenerCustom", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(tolua_S,2,0,&tolua_err) || !toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif const std::string eventName = ((const std::string) tolua_tocppstring(tolua_S,2,0)); LUA_FUNCTION handler = toluafix_ref_function(tolua_S,3,0); cocos2d::EventListenerCustom* tolua_ret = LuaEventListenerCustom::create(eventName); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)tolua_ret, handler, ScriptHandlerMgr::HandlerType::EVENT_CUSTIOM); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerCustom"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static void extendEventListenerCustom(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.EventListenerCustom"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "create",tolua_cocos2d_LuaEventListenerCustom_create); } lua_pop(tolua_S, 1); } static void extendEventListenerAcceleration(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.EventListenerAcceleration"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "create",tolua_cocos2dx_LuaEventListenerAcceleration_create); } lua_pop(tolua_S, 1); } static int tolua_cocos2dx_EventListenerKeyboard_create(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S, 1, "cc.EventListenerKeyboard", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { cocos2d::EventListenerKeyboard* tolua_ret = cocos2d::EventListenerKeyboard::create(); if(nullptr == tolua_ret) return 0; int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerKeyboard"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_EventListenerKeyboard_registerScriptHandler(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; EventListenerKeyboard* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerKeyboard", 0, &tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerKeyboard_registerScriptHandler'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::HandlerType type = static_cast((int)tolua_tonumber(tolua_S, 3, 0)); switch (type) { case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_PRESSED: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onKeyPressed = [=](EventKeyboard::KeyCode keyCode, Event* event){ LuaEventKeyboarData listenerData((int)keyCode, event); BasicScriptData data((void*)self,(void*)&listenerData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; } break; case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_RELEASED: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onKeyReleased = [=](EventKeyboard::KeyCode keyCode, Event* event){ LuaEventKeyboarData listenerData((int)keyCode, event); BasicScriptData data((void*)self,(void*)&listenerData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; } break; default: break; } return 0; } CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } static void extendEventListenerKeyboard(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.EventListenerKeyboard"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "create",tolua_cocos2dx_EventListenerKeyboard_create); tolua_function(tolua_S, "registerScriptHandler", tolua_cocos2dx_EventListenerKeyboard_registerScriptHandler); } lua_pop(tolua_S, 1); } static int tolua_cocos2dx_EventListenerTouchOneByOne_create(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S, 1, "cc.EventListenerTouchOneByOne", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { cocos2d::EventListenerTouchOneByOne* tolua_ret = cocos2d::EventListenerTouchOneByOne::create(); if(nullptr == tolua_ret) return 0; int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerTouchOneByOne"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_EventListenerTouchOneByOne_registerScriptHandler(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; EventListenerTouchOneByOne* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerTouchOneByOne", 0, &tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerTouchOneByOne_registerScriptHandler'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::HandlerType type = static_cast((int)tolua_tonumber(tolua_S, 3, 0)); switch (type) { case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_BEGAN: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onTouchBegan = [=](Touch* touch, Event* event){ LuaEventTouchData touchData(touch, event); BasicScriptData data((void*)self,(void*)&touchData); return LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; } break; case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_MOVED: { self->onTouchMoved = [=](Touch* touch, Event* event){ LuaEventTouchData touchData(touch, event); BasicScriptData data((void*)self,(void*)&touchData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_ENDED: { self->onTouchEnded = [=](Touch* touch, Event* event){ LuaEventTouchData touchData(touch, event); BasicScriptData data((void*)self,(void*)&touchData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_CANCELLED: { self->onTouchCancelled = [=](Touch* touch, Event* event){ LuaEventTouchData touchData(touch, event); BasicScriptData data((void*)self,(void*)&touchData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; default: break; } return 0; } CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } static void extendEventListenerTouchOneByOne(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.EventListenerTouchOneByOne"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "create", tolua_cocos2dx_EventListenerTouchOneByOne_create); tolua_function(tolua_S, "registerScriptHandler", tolua_cocos2dx_EventListenerTouchOneByOne_registerScriptHandler); } lua_pop(tolua_S, 1); } static int tolua_cocos2dx_EventListenerTouchAllAtOnce_create(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S, 1, "cc.EventListenerTouchAllAtOnce", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { cocos2d::EventListenerTouchAllAtOnce* tolua_ret = cocos2d::EventListenerTouchAllAtOnce::create(); if(nullptr == tolua_ret) return 0; int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerTouchAllAtOnce"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_EventListenerTouchAllAtOnce_registerScriptHandler(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; EventListenerTouchAllAtOnce* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerTouchAllAtOnce", 0, &tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerTouchAllAtOnce_registerScriptHandler'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::HandlerType type = static_cast((int)tolua_tonumber(tolua_S, 3, 0)); switch (type) { case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_BEGAN: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onTouchesBegan = [=](const std::vector& touches, Event* event){ LuaEventTouchesData touchesData(touches, event); BasicScriptData data((void*)self,(void*)&touchesData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; } break; case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_MOVED: { self->onTouchesMoved = [=](const std::vector& touches, Event* event){ LuaEventTouchesData touchesData(touches, event); BasicScriptData data((void*)self,(void*)&touchesData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_ENDED: { self->onTouchesEnded = [=](const std::vector& touches, Event* event){ LuaEventTouchesData touchesData(touches, event); BasicScriptData data((void*)self,(void*)&touchesData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_CANCELLED: { self->onTouchesCancelled = [=](const std::vector& touches, Event* event){ LuaEventTouchesData touchesData(touches, event); BasicScriptData data((void*)self,(void*)&touchesData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; default: break; } return 0; } CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } static void extendEventListenerTouchAllAtOnce(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.EventListenerTouchAllAtOnce"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "create", tolua_cocos2dx_EventListenerTouchAllAtOnce_create); tolua_function(tolua_S, "registerScriptHandler", tolua_cocos2dx_EventListenerTouchAllAtOnce_registerScriptHandler); } lua_pop(tolua_S, 1); } static int tolua_cocos2dx_EventListenerMouse_create(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(tolua_S, 1, "cc.EventListenerMouse", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::EventListenerMouse* tolua_ret = cocos2d::EventListenerMouse::create(); if(nullptr == tolua_ret) return 0; int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerMouse"); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err); return 0; #endif } static int tolua_cocos2dx_EventListenerMouse_registerScriptHandler(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; EventListenerMouse* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerMouse", 0, &tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerMouse_registerScriptHandler'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::HandlerType type = static_cast((int)tolua_tonumber(tolua_S, 3, 0) ) ; switch (type) { case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_DOWN: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onMouseDown = [=](Event* event){ LuaEventMouseData mouseData(event); BasicScriptData data((void*)self,(void*)&mouseData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; } break; case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_UP: { self->onMouseUp = [=](Event* event){ LuaEventMouseData mouseData(event); BasicScriptData data((void*)self,(void*)&mouseData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_MOVE: { self->onMouseMove = [=](Event* event){ LuaEventMouseData mouseData(event); BasicScriptData data((void*)self,(void*)&mouseData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_SCROLL: { self->onMouseScroll = [=](Event* event){ LuaEventMouseData mouseData(event); BasicScriptData data((void*)self,(void*)&mouseData); LuaEngine::getInstance()->handleEvent(type, (void*)&data); }; ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); } break; default: break; } return 0; } CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } static void extendEventListenerMouse(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.EventListenerMouse"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "create", tolua_cocos2dx_EventListenerMouse_create); tolua_function(tolua_S, "registerScriptHandler", tolua_cocos2dx_EventListenerMouse_registerScriptHandler); } lua_pop(tolua_S, 1); } static int tolua_cocos2dx_ActionCamera_reverse(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; cocos2d::ActionCamera* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.ActionCamera",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::ActionCamera*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2dx_ActionCamera_reverse'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { cocos2d::ActionCamera* reverse = cobj->reverse(); toluafix_pushusertype_ccobject(tolua_S, reverse->_ID, &(reverse->_luaID), (void*)(reverse),"cc.ActionCamera"); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reverse",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'tolua_cocos2dx_ActionCamera_reverse'.",&tolua_err); #endif return 0; } static void extendActionCamera(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.ActionCamera"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "reverse", tolua_cocos2dx_ActionCamera_reverse); } lua_pop(tolua_S, 1); } static int tolua_cocos2dx_GridAction_reverse(lua_State* tolua_S) { if (NULL == tolua_S) return 0; int argc = 0; cocos2d::GridAction* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.GridAction",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::GridAction*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2dx_GridAction_reverse'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { cocos2d::GridAction* reverse = cobj->reverse(); toluafix_pushusertype_ccobject(tolua_S, reverse->_ID, &(reverse->_luaID), (void*)(reverse),"cc.GridAction"); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reverse",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'tolua_cocos2dx_GridAction_reverse'.",&tolua_err); #endif return 0; } static void extendGridAction(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.GridAction"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "reverse", tolua_cocos2dx_GridAction_reverse); } lua_pop(tolua_S, 1); } static bool luaval_to_TTFConfig(lua_State* L,int lo, TTFConfig* ret) { if (nullptr == ret) return false; bool ok = true; tolua_Error tolua_err; if (!tolua_istable(L, lo, 0, &tolua_err) ) { #if COCOS2D_DEBUG >=1 luaval_to_native_err(L,"#ferror:",&tolua_err); #endif ok = false; } if (ok) { lua_pushstring(L, "fontFilePath"); /* L: paramStack key */ lua_gettable(L,lo); /* L: paramStack paramStack[lo][key] */ ret->fontFilePath = lua_isstring(L, -1)? lua_tostring(L, -1) : ""; lua_pop(L,1); /* L: paramStack*/ lua_pushstring(L, "fontSize"); lua_gettable(L,lo); ret->fontSize = lua_isnumber(L, -1)?(int)lua_tointeger(L, -1) : 0; lua_pop(L,1); lua_pushstring(L, "glyphs"); lua_gettable(L, lo); ret->glyphs = lua_isnumber(L, -1)?static_cast(lua_tointeger(L, -1)) : GlyphCollection::NEHE; lua_pop(L, 1); lua_pushstring(L, "customGlyphs"); lua_gettable(L, lo); ret->customGlyphs = lua_isstring(L, -1)?lua_tostring(L, -1) : ""; lua_pop(L, 1); lua_pushstring(L, "distanceFieldEnabled"); lua_gettable(L, lo); ret->distanceFieldEnabled = lua_isboolean(L, -1)?lua_toboolean(L, -1) : false; lua_pop(L, 1); return true; } return false; } static int lua_cocos2dx_Label_createWithTTF00(lua_State* L) { if (nullptr == L) return 0; int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(L,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(L) - 1; if (argc >= 2 && argc <= 4) { #if COCOS2D_DEBUG >= 1 if (!tolua_istable(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err) || !tolua_isnumber(L, 4, 1, &tolua_err) || !tolua_isnumber(L, 5, 1, &tolua_err) ) { goto tolua_lerror; } #endif TTFConfig ttfConfig(""); std::string text = ""; ok &= luaval_to_TTFConfig(L, 2, &ttfConfig); if (!ok) return 0; ok &= luaval_to_std_string(L, 3, &text); if (!ok) return 0; int alignment = tolua_tonumber(L, 4, 1); int lineSize = tolua_tonumber(L, 5, 0); cocos2d::Label* ret = cocos2d::Label::createWithTTF(ttfConfig, text, static_cast(alignment), lineSize); int ID = ret ? (int)(ret->_ID) : -1; int* luaID = ret ? &(ret->_luaID) : nullptr; toluafix_pushusertype_ccobject(L,ID, luaID, (void*)ret,"cc.Label"); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_Label_createWithTTF'.",&tolua_err); #endif return 0; } static int lua_cocos2dx_Label_setTTFConfig(lua_State* L) { if (nullptr == L) return 0; int argc = 0; cocos2d::Label* self = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L, 1, 0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Label_setTTFConfig'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if(1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_istable(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif TTFConfig ttfConfig(""); ok &= luaval_to_TTFConfig(L, 2, &ttfConfig); if (!ok) return 0; self->setTTFConfig(ttfConfig); return 1; } CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setTTFConfig'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_Label_createWithTTF01(lua_State* L) { if (nullptr == L) return 0; tolua_Error tolua_err; if (!tolua_isusertable(L, 1, "cc.Label", 0, &tolua_err) || !tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err) || !tolua_isnumber(L, 4, 0, &tolua_err) || !tolua_isnumber(L, 5, 1, &tolua_err) || !tolua_isnumber(L, 6, 1, &tolua_err) || !tolua_isnumber(L, 7, 1, &tolua_err) || !tolua_isstring(L, 8, 1, &tolua_err) || !tolua_isboolean(L, 9, 1, &tolua_err) ) goto tolua_lerror; else { CCLOG("The createWithTTF(text, ...) was deprecated,please use create createWithTTF(ttfConfig, ...) instead"); std::string text = tolua_tostring(L, 2, ""); std::string fontFilePath = tolua_tostring(L, 3, ""); int fontSize = (int)tolua_tonumber(L, 4, 0); int lineSize = (int)tolua_tonumber(L, 5, 0); TextHAlignment alignment = static_cast((int)tolua_tonumber(L, 6, 1)); GlyphCollection glyphs = static_cast((int)tolua_tonumber(L, 7, 1)); const char* customGlyphs = tolua_tostring(L, 8, ""); bool useDistanceField = tolua_toboolean(L, 9, false); TTFConfig ttfConfig(fontFilePath.c_str(), fontSize, glyphs, customGlyphs, useDistanceField); cocos2d::Label* ret = cocos2d::Label::createWithTTF(ttfConfig, text,alignment, lineSize); int ID = ret ? (int)(ret->_ID) : -1; int* luaID = ret ? &(ret->_luaID) : nullptr; toluafix_pushusertype_ccobject(L,ID, luaID, (void*)ret,"cc.Label"); return 1; } tolua_lerror: return lua_cocos2dx_Label_createWithTTF00(L); } static void extendLabel(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.Label"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "createWithTTF", lua_cocos2dx_Label_createWithTTF00); tolua_function(tolua_S, "setTTFConfig", lua_cocos2dx_Label_setTTFConfig); tolua_function(tolua_S, "createWithTTF", lua_cocos2dx_Label_createWithTTF01); } lua_pop(tolua_S, 1); } int register_all_cocos2dx_manual(lua_State* tolua_S) { if (NULL == tolua_S) return 0; extendNode(tolua_S); extendLayer(tolua_S); extendMenuItem(tolua_S); extendMenuItemImage(tolua_S); extendMenuItemLabel(tolua_S); extendMenuItemFont(tolua_S); extendMenuItemSprite(tolua_S); extendMenuItemToggle(tolua_S); extendMenu(tolua_S); extendScheduler(tolua_S); extendSequence(tolua_S); extendCallFunc(tolua_S); extendSpawn(tolua_S); extendCardinalSplineBy(tolua_S); extendCatmullRomBy(tolua_S); extendCatmullRomTo(tolua_S); extendBezierBy(tolua_S); extendBezierTo(tolua_S); extendDrawNode(tolua_S); extendSprite(tolua_S); extendLayerColor(tolua_S); extendLayerMultiplex(tolua_S); extendParticleSystem(tolua_S); extendFileUtils(tolua_S); extendUserDefault(tolua_S); extendGLProgram(tolua_S); extendTexture2D(tolua_S); extendSpriteBatchNode(tolua_S); extendEventListenerKeyboard(tolua_S); extendEventListenerTouchOneByOne(tolua_S); extendEventListenerTouchAllAtOnce(tolua_S); extendEventListenerMouse(tolua_S); extendEventListenerCustom(tolua_S); extendEventListenerAcceleration(tolua_S); extendActionCamera(tolua_S); extendGridAction(tolua_S); extendMotionStreak(tolua_S); extendAtlasNode(tolua_S); extendParticleBatchNode(tolua_S); extendLabel(tolua_S); return 0; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_manual.hpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_MANUAL_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_MANUAL_H #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include "cocos2d.h" #include "LuaScriptHandlerMgr.h" NS_CC_BEGIN class LuaEventListenerCustom { public: static EventListenerCustom* create(const std::string& eventName); }; class LuaEventListenerAcceleration { public: static EventListenerAcceleration* create(); }; NS_CC_END USING_NS_CC; TOLUA_API int register_all_cocos2dx_manual(lua_State* tolua_S); TOLUA_API int register_cocos2dx_event_releated(lua_State* tolua_S); struct LuaEventAccelerationData { void* acc; Event* event; LuaEventAccelerationData(void* inAcc,Event* inEvent) :acc(inAcc),event(inEvent) { } }; struct LuaEventKeyboarData { int keyCode; Event* event; LuaEventKeyboarData(int inKeyCode,Event* inEvent) :keyCode(inKeyCode),event(inEvent) { } }; struct LuaEventTouchData { Touch* touch; Event* event; LuaEventTouchData(Touch* inTouch, Event* inEvent) :touch(inTouch), event(inEvent) { } }; struct LuaEventTouchesData { std::vector touches; Event* event; LuaEventTouchesData(std::vector inTouches, Event* inEvent) :touches(inTouches), event(inEvent) { } }; struct LuaEventMouseData { Event* event; LuaEventMouseData(Event* inEvent) :event(inEvent) { } }; #endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_MANUAL_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp ================================================ #include "lua_cocos2dx_manual.hpp" #if CC_USE_PHYSICS #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include "LuaBasicConversions.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" #ifndef CC_SAFE_FREE #define CC_SAFE_FREE(p) { if(p) free(p); p = nullptr; } #endif int lua_cocos2dx_physics_PhysicsBody_getJoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsBody* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getJoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { do { if(!ok) return 0; auto& ret = cobj->getJoints(); lua_newtable(tolua_S); if (ret.empty()) return 1; auto iter = ret.begin(); int indexTable = 1; for (; iter != ret.end(); ++iter) { if (nullptr == *iter) continue; std::string hashName = typeid(*iter).name(); auto name = g_luaType.find(hashName); std::string className = ""; if(name != g_luaType.end()){ className = name->second.c_str(); } else { className = "cc.PhysicsJoint"; } lua_pushnumber(tolua_S, (lua_Number)indexTable); tolua_pushusertype(tolua_S,(void*)(*iter), className.c_str()); lua_rawset(tolua_S, -3); ++indexTable; } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getJoints",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getJoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getScene'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; cocos2d::Scene& ret = cobj->getScene(); do { std::string hashName = typeid(ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.Scene"; } int ID = (int)(ret._ID); int* luaID = &(ret._luaID); toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)(&ret),className.c_str()); }while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScene",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getScene'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_rayCast'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 3) { std::function arg0; cocos2d::Point arg1; cocos2d::Point arg2; LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0); do { arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, const cocos2d::PhysicsRayCastInfo &info, void * data) -> bool { std::string hashName = typeid(&world).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsWorld"; } tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); physics_raycastinfo_to_luaval(tolua_S, info); return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); }; } while(0); ok &= luaval_to_point(tolua_S, 3, &arg1); ok &= luaval_to_point(tolua_S, 4, &arg2); if(!ok) return 0; cobj->rayCast(arg0, arg1, arg2, nullptr); toluafix_remove_function_by_refid(tolua_S, handler); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rayCast",argc, 4); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_rayCast'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_queryRect'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::function arg0; cocos2d::Rect arg1; LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0); do { arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool { std::string hashName = typeid(&world).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsWorld"; } tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); hashName = typeid(&shape).name(); iter = g_luaType.find(hashName); className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str()); return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); }; } while(0); ok &= luaval_to_rect(tolua_S, 3, &arg1); if(!ok) return 0; cobj->queryRect(arg0, arg1, nullptr); toluafix_remove_function_by_refid(tolua_S, handler); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "queryRect",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_queryRect'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsWorld* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_queryPoint'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 2) { std::function arg0; cocos2d::Point arg1; LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0); do { arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool { std::string hashName = typeid(&world).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsWorld"; } tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); hashName = typeid(&shape).name(); iter = g_luaType.find(hashName); className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsShape"; } toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str()); return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); }; assert(false); } while(0) ; ok &= luaval_to_point(tolua_S, 3, &arg1); if(!ok) return 0; cobj->queryPoint(arg0, arg1, nullptr); toluafix_remove_function_by_refid(tolua_S, handler); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "queryPoint",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_queryPoint'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Point* arg0 = nullptr; int arg1 = 0; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Point* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); ok &= luaval_to_physics_material(tolua_S, 3, &arg2); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1, arg2); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Point* arg0; int arg1 = 0; cocos2d::PhysicsMaterial arg2; cocos2d::Point arg3; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); ok &= luaval_to_physics_material(tolua_S, 3, &arg2); ok &= luaval_to_point(tolua_S, 4, &arg3); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1, arg2, arg3); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createPolygon",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createPolygon'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Point* arg0; int arg1; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); ok &= luaval_to_physics_material(tolua_S, 3, &arg2); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1, arg2); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; double arg3; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); ok &= luaval_to_physics_material(tolua_S, 3, &arg2); ok &= luaval_to_number(tolua_S, 4,&arg3); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1, arg2, arg3); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgePolygon",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createEdgePolygon'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Point* arg0; int arg1; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 2) { cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); ok &= luaval_to_physics_material(tolua_S, 3, &arg2); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1, arg2); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } if (argc == 3) { cocos2d::Point* arg0; int arg1; cocos2d::PhysicsMaterial arg2; double arg3; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); ok &= luaval_to_physics_material(tolua_S, 3, &arg2); ok &= luaval_to_number(tolua_S, 4,&arg3); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1, arg2, arg3); CC_SAFE_FREE(arg0); do { if (NULL != ret){ std::string hashName = typeid(*ret).name(); auto iter = g_luaType.find(hashName); std::string className = ""; if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { int ID = ret ? (int)(dynObject->_ID) : -1; int* luaID = ret ? &(dynObject->_luaID) : NULL; toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); } else { tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); }} else { lua_pushnil(tolua_S); } } while (0); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgeChain",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createEdgeChain'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_recenterPoints(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Point* arg0; int arg1 = 0; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsShape::recenterPoints(arg0, arg1); points_to_luaval(tolua_S, arg0, arg1); CC_SAFE_FREE(arg0); return 0; } if (argc == 2) { cocos2d::Point* arg0; int arg1 = 0; cocos2d::Point arg2; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); ok &= luaval_to_point(tolua_S, 3, &arg2); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::PhysicsShape::recenterPoints(arg0, arg1, arg2); points_to_luaval(tolua_S, arg0, arg1); CC_SAFE_FREE(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "recenterPoints",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_recenterPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShape_getPolyonCenter(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { cocos2d::Point* arg0; int arg1 = 0; do { ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); if (nullptr == arg0){ LUA_PRECONDITION( arg0, "Invalid Native Object"); }} while (0); if(!ok) { CC_SAFE_FREE(arg0); return 0; } cocos2d::Point ret = cocos2d::PhysicsShape::getPolyonCenter(arg0, arg1); CC_SAFE_FREE(arg0); point_to_luaval(tolua_S, ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getPolyonCenter",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getPolyonCenter'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeBox_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeBox* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeBox_getPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { cocos2d::Point arg0[4]; cobj->getPoints(arg0); points_to_luaval(tolua_S, arg0, 4); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeBox_getPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapePolygon_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapePolygon* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapePolygon*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapePolygon_getPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { int count = cobj->getPointsCount(); cocos2d::Point* arg0 = new cocos2d::Point[count]; cobj->getPoints(arg0); points_to_luaval(tolua_S, arg0, count); CC_SAFE_FREE(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapePolygon_getPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgeBox* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgeBox*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { int count = cobj->getPointsCount(); cocos2d::Point* arg0 = new cocos2d::Point[count]; cobj->getPoints(arg0); points_to_luaval(tolua_S, arg0, count); CC_SAFE_FREE(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgePolygon* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgePolygon",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgePolygon*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { int count = cobj->getPointsCount(); cocos2d::Point* arg0 = new cocos2d::Point[count]; cobj->getPoints(arg0); points_to_luaval(tolua_S, arg0, count); CC_SAFE_FREE(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints'.",&tolua_err); #endif return 0; } int lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgeChain* cobj = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeChain",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgeChain*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints'", NULL); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { int count = cobj->getPointsCount(); cocos2d::Point* arg0 = new cocos2d::Point[count]; cobj->getPoints(arg0); points_to_luaval(tolua_S, arg0, count); CC_SAFE_FREE(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints'.",&tolua_err); #endif return 0; } static int tolua_cocos2dx_EventListenerPhysicsContact_registerScriptHandler(lua_State* tolua_S) { if (nullptr == tolua_S) return 0; int argc = 0; EventListenerPhysicsContact* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerPhysicsContact", 0, &tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerPhysicsContact_registerScriptHandler'\n", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 2) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0); ScriptHandlerMgr::HandlerType type = static_cast((int)tolua_tonumber(tolua_S, 3, 0)); switch (type) { case ScriptHandlerMgr::HandlerType::EVENT_PHYSICS_CONTACT_BEGIN: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onContactBegin = [handler](EventCustom* event, const PhysicsContact& contact) -> bool{ LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); stack->pushObject(event, "cc.EventCustom"); stack->pushObject(const_cast(&contact), "cc.PhysicsContact"); bool ret = stack->executeFunctionByHandler(handler, 2); stack->clean(); return ret; }; } break; case ScriptHandlerMgr::HandlerType::EVENT_PHYSICS_CONTACT_PRESOLVE: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onContactPreSolve = [handler](EventCustom* event, const PhysicsContact& contact, const PhysicsContactPreSolve& solve) -> bool{ LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); stack->pushObject(event, "cc.EventCustom"); stack->pushObject(const_cast(&contact), "cc.PhysicsContact"); tolua_pushusertype(stack->getLuaState(), const_cast(&solve), "cc.PhysicsContactPreSolve"); bool ret = stack->executeFunctionByHandler(handler, 3); stack->clean(); return ret; }; } break; case ScriptHandlerMgr::HandlerType::EVENT_PHYSICS_CONTACT_POSTSOLVE: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onContactPostSolve = [handler](EventCustom* event, const PhysicsContact& contact, const PhysicsContactPostSolve& solve){ LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); stack->pushObject(event, "cc.EventCustom"); stack->pushObject(const_cast(&contact), "cc.PhysicsContact"); tolua_pushusertype(stack->getLuaState(), const_cast(&solve), "cc.PhysicsContactPostSolve"); stack->executeFunctionByHandler(handler, 3); stack->clean(); }; } break; case ScriptHandlerMgr::HandlerType::EVENT_PHYSICS_CONTACT_SEPERATE: { ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type); self->onContactSeperate = [handler](EventCustom* event, const PhysicsContact& contact){ LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); stack->pushObject(event, "cc.EventCustom"); stack->pushObject(const_cast(&contact), "cc.PhysicsContact"); stack->executeFunctionByHandler(handler, 2); stack->clean(); }; } break; default: break; } return 0; } CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); return 0; #endif } int register_all_cocos2dx_physics_manual(lua_State* tolua_S) { lua_pushstring(tolua_S, "cc.PhysicsBody"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getJoints"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_getJoints ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"createPolygon"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_createPolygon ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"createEdgeChain"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_createEdgeChain ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"createEdgePolygon"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_createEdgePolygon ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); lua_pushstring(tolua_S, "cc.PhysicsShape"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"recenterPoints"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShape_recenterPoints ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"getPolyonCenter"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShape_getPolyonCenter ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); lua_pushstring(tolua_S, "cc.PhysicsShapeBox"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getPoints"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapeBox_getPoints ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); lua_pushstring(tolua_S, "cc.PhysicsShapeEdgeBox"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getPoints"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); lua_pushstring(tolua_S, "cc.PhysicsShapePolygon"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getPoints"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapePolygon_getPoints ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); lua_pushstring(tolua_S, "cc.PhysicsShapeEdgePolygon"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getPoints"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints ); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); lua_pushstring(tolua_S, "cc.PhysicsShapeEdgeChain"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getPoints"); lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); lua_pushstring(tolua_S, "cc.PhysicsWorld"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { lua_pushstring(tolua_S,"getScene"); lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_getScene ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"queryPoint"); lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_queryPoint ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"queryRect"); lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_queryRect ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S,"rayCast"); lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_rayCast ); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "DEBUGDRAW_NONE"); lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_NONE); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "DEBUGDRAW_SHAPE"); lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_SHAPE); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "DEBUGDRAW_JOINT"); lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_JOINT); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "DEBUGDRAW_CONTACT"); lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_CONTACT); lua_rawset(tolua_S,-3); lua_pushstring(tolua_S, "DEBUGDRAW_ALL"); lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_ALL); lua_rawset(tolua_S,-3); } lua_pop(tolua_S, 1); lua_pushstring(tolua_S, "cc.EventListenerPhysicsContact"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { tolua_function(tolua_S, "registerScriptHandler", tolua_cocos2dx_EventListenerPhysicsContact_registerScriptHandler); } lua_pop(tolua_S, 1); tolua_constant(tolua_S, "PHYSICS_INFINITY", PHYSICS_INFINITY); return 0; } #endif ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.hpp ================================================ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H #if CC_USE_PHYSICS #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include "cocos2d.h" #include "LuaScriptHandlerMgr.h" int register_all_cocos2dx_physics_manual(lua_State* tolua_S); #endif // CC_USE_PHYSICS #endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "lua_cocos2dx_spine_manual.hpp" #ifdef __cplusplus extern "C" { #endif #include "tolua_fix.h" #ifdef __cplusplus } #endif #include "cocos2d.h" #include "LuaBasicConversions.h" #include "LuaScriptHandlerMgr.h" #include "CCLuaValue.h" #include "spine.h" #include "spine-cocos2dx.h" #include "LuaSkeletonAnimation.h" using namespace spine; // setBlendFunc template static int tolua_cocos2dx_setBlendFunc(lua_State* tolua_S,const char* className) { if (NULL == tolua_S || NULL == className || strlen(className) == 0) return 0; int argc = 0; T* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,className,0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); argc = lua_gettop(tolua_S) - 1; if (2 == argc) { GLenum src, dst; if (!luaval_to_int32(tolua_S, 2, (int32_t*)&src)) return 0; if (!luaval_to_int32(tolua_S, 3, (int32_t*)&dst)) return 0; BlendFunc blendFunc = {src, dst}; self->setBlendFunc(blendFunc); return 0; } CCLOG("'setBlendFunc' has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setBlendFunc'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L) { if (nullptr == L) return 0 ; int argc = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertable(L,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(L) - 1; if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3 ,0, &tolua_err)) { goto tolua_lerror; } #endif const char* skeletonDataFile = tolua_tostring(L, 2, ""); const char* atlasFile = tolua_tostring(L, 3, "");; auto tolua_ret = LuaSkeletonAnimation::createWithFile(skeletonDataFile, atlasFile); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"sp.SkeletonAnimation"); return 1; } else if (3 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3 ,0, &tolua_err) || !tolua_isnumber(L, 4 ,0, &tolua_err)) { goto tolua_lerror; } #endif const char* skeletonDataFile = tolua_tostring(L, 2, ""); const char* atlasFile = tolua_tostring(L, 3, ""); LUA_NUMBER scale = tolua_tonumber(L, 4, 1); auto tolua_ret = LuaSkeletonAnimation::createWithFile(skeletonDataFile, atlasFile, scale); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"sp.SkeletonAnimation"); return 1; } CCLOG("'createWithFile' function of SkeletonAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 2); #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'createWithFile'.",&tolua_err); return 0; #endif } int tolua_Cocos2d_CCSkeletonAnimation_registerSpineEventHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { int handler = ( toluafix_ref_function(tolua_S,2,0)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::EVENT_SPINE); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'registerSpineEventHandler'.",&tolua_err); return 0; #endif } int tolua_Cocos2d_CCSkeletonAnimation_unregisterSpineEventHandler00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::HandlerType::EVENT_SPINE); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCSkeletonAnimation_setTimeScale00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { LUA_NUMBER scale = tolua_tonumber(tolua_S, 2, 1); self->timeScale = scale; } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setTimeScale'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCSkeletonAnimation_setDebugSlots00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { bool debugSlots = tolua_toboolean(tolua_S, 2, 1); self->debugSlots = debugSlots; } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setDebugSlots'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCSkeletonAnimation_setDebugBones00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { bool debugBones = tolua_toboolean(tolua_S, 2, 1); self->debugBones = debugBones; } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setDebugBones'.",&tolua_err); return 0; #endif } static int tolua_Cocos2d_CCSkeletonAnimation_setPremultipliedAlpha00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0); if (NULL != self ) { bool premultipliedAlpha = tolua_toboolean(tolua_S, 2, 1); self->premultipliedAlpha = premultipliedAlpha; } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setPremultipliedAlpha'.",&tolua_err); return 0; #endif } static int tolua_spine_SkeletoneAnimation_setBlendFunc(lua_State* tolua_S) { return tolua_cocos2dx_setBlendFunc(tolua_S,"sp.SkeletonAnimation"); } static void extendCCSkeletonAnimation(lua_State* L) { lua_pushstring(L, "sp.SkeletonAnimation"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "create", lua_cocos2dx_CCSkeletonAnimation_createWithFile); tolua_function(L, "registerSpineEventHandler", tolua_Cocos2d_CCSkeletonAnimation_registerSpineEventHandler00); tolua_function(L, "unregisterSpineEventHandler", tolua_Cocos2d_CCSkeletonAnimation_unregisterSpineEventHandler00); tolua_function(L, "setBlendFunc", tolua_spine_SkeletoneAnimation_setBlendFunc); tolua_function(L, "setTimeScale", tolua_Cocos2d_CCSkeletonAnimation_setTimeScale00); tolua_function(L, "setDebugSlots", tolua_Cocos2d_CCSkeletonAnimation_setDebugSlots00); tolua_function(L, "setDebugBones", tolua_Cocos2d_CCSkeletonAnimation_setDebugBones00); tolua_function(L, "setPremultipliedAlpha", tolua_Cocos2d_CCSkeletonAnimation_setPremultipliedAlpha00); } lua_pop(L, 1); } int register_all_cocos2dx_spine_manual(lua_State* L) { if (nullptr == L) return 0; extendCCSkeletonAnimation(L); return 0; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_SPINE_MANUAL_H #define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_SPINE_MANUAL_H #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include "CCObject.h" TOLUA_API int register_all_cocos2dx_spine_manual(lua_State* L); #endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_SPINE_MANUAL_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_extensions.c ================================================ #include "lua_extensions.h" #if __cplusplus extern "C" { #endif // socket #include "socket/luasocket.h" #include "socket/mime.h" #include "socket/socket_scripts.h" static luaL_Reg luax_exts[] = { {"socket.core", luaopen_socket_core}, {"mime.core", luaopen_mime_core}, {NULL, NULL} }; void luaopen_lua_extensions(lua_State *L) { // load extensions luaL_Reg* lib = luax_exts; lua_getglobal(L, "package"); lua_getfield(L, -1, "preload"); for (; lib->func; lib++) { lua_pushcfunction(L, lib->func); lua_setfield(L, -2, lib->name); } lua_pop(L, 2); // load extensions script luaopen_socket_scripts(L); } #if __cplusplus } // extern "C" #endif ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_extensions.h ================================================ #ifndef __LUA_EXTRA_H_ #define __LUA_EXTRA_H_ #if defined(_USRDLL) #define LUA_EXTENSIONS_DLL __declspec(dllexport) #else /* use a DLL library */ #define LUA_EXTENSIONS_DLL #endif #if __cplusplus extern "C" { #endif #include "lauxlib.h" void LUA_EXTENSIONS_DLL luaopen_lua_extensions(lua_State *L); #if __cplusplus } #endif #endif /* __LUA_EXTRA_H_ */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_xml_http_request.cpp ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "lua_xml_http_request.h" extern "C" { #include "tolua_fix.h" } #include #include "CCLuaStack.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" #include "LuaScriptHandlerMgr.h" using namespace cocos2d; using namespace std; LuaMinXmlHttpRequest::LuaMinXmlHttpRequest():_isNetwork(true) { _httpHeader.clear(); _requestHeader.clear(); _withCredentialsValue = true; _httpRequest = new network::HttpRequest(); } LuaMinXmlHttpRequest::~LuaMinXmlHttpRequest() { _httpHeader.clear(); _requestHeader.clear(); } /** * @brief Implementation for header retrieving. * @param header */ void LuaMinXmlHttpRequest::_gotHeader(string header) { // Get Header and Set StatusText // Split String into Tokens char * cstr = new char [header.length()+1]; // check for colon. unsigned found_header_field = header.find_first_of(":"); if (found_header_field != std::string::npos) { // Found a header field. string http_field; string http_value; http_field = header.substr(0,found_header_field); http_value = header.substr(found_header_field+1, header.length()); // Get rid of all \n if (!http_value.empty() && http_value[http_value.size() - 1] == '\n') { http_value.erase(http_value.size() - 1); } _httpHeader[http_field] = http_value; } else { // Seems like we have the response Code! Parse it and check for it. char * pch; strcpy(cstr, header.c_str()); pch = strtok(cstr," "); while (pch != NULL) { stringstream ss; string val; ss << pch; val = ss.str(); unsigned found_http = val.find("HTTP"); // Check for HTTP Header to set statusText if (found_http != std::string::npos) { stringstream mystream; // Get Response Status pch = strtok (NULL, " "); mystream << pch; pch = strtok (NULL, " "); mystream << " " << pch; _statusText = mystream.str(); } pch = strtok (NULL, " "); } } CC_SAFE_DELETE_ARRAY(cstr); } /** * @brief Set Request header for next call. * @param field Name of the Header to be set. * @param value Value of the Headerfield */ void LuaMinXmlHttpRequest::setRequestHeader(const char* field, const char* value) { stringstream header_s; stringstream value_s; string header; map::iterator iter = _requestHeader.find(field); // Concatenate values when header exists. if (iter != _requestHeader.end()) { value_s << iter->second << "," << value; } else { value_s << value; } _requestHeader[field] = value_s.str(); } /** * @brief If headers has been set, pass them to curl. * */ void LuaMinXmlHttpRequest::_setHttpRequestHeader() { std::vector header; for (auto it = _requestHeader.begin(); it != _requestHeader.end(); ++it) { const char* first = it->first.c_str(); const char* second = it->second.c_str(); size_t len = sizeof(char) * (strlen(first) + 3 + strlen(second)); char* test = (char*) malloc(len); memset(test, 0,len); strcpy(test, first); strcpy(test + strlen(first) , ": "); strcpy(test + strlen(first) + 2, second); header.push_back(test); free(test); } if (!header.empty()) { _httpRequest->setHeaders(header); } } /** * @brief Send out request and fire callback when done. */ void LuaMinXmlHttpRequest::_sendRequest() { _httpRequest->setResponseCallback(this, httpresponse_selector(LuaMinXmlHttpRequest::handle_requestResponse)); network::HttpClient::getInstance()->send(_httpRequest); _httpRequest->release(); } /** * @brief Callback for HTTPRequest. Handles the response and invokes Callback. * @param sender Object which initialized callback * @param respone Response object * @js NA */ void LuaMinXmlHttpRequest::handle_requestResponse(network::HttpClient *sender, network::HttpResponse *response) { if (0 != strlen(response->getHttpRequest()->getTag())) { CCLOG("%s completed", response->getHttpRequest()->getTag()); } int statusCode = response->getResponseCode(); char statusString[64] = {}; sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag()); if (!response->isSucceed()) { CCLOG("response failed"); CCLOG("error buffer: %s", response->getErrorBuffer()); return; } // set header std::vector *headers = response->getResponseHeader(); char* concatHeader = (char*) malloc(headers->size() + 1); std::string header(headers->begin(), headers->end()); strcpy(concatHeader, header.c_str()); std::istringstream stream(concatHeader); std::string line; while(std::getline(stream, line)) { _gotHeader(line); } /** get the response data **/ std::vector *buffer = response->getResponseData(); char* concatenated = (char*) malloc(buffer->size() + 1); std::string s2(buffer->begin(), buffer->end()); strcpy(concatenated, s2.c_str()); if (statusCode == 200) { //Succeeded _status = 200; _readyState = DONE; _data << concatenated; _dataSize = buffer->size(); } else { _status = 0; } // Free Memory. free((void*) concatHeader); free((void*) concatenated); // call back lua function --TODO int handler = cocos2d::ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, cocos2d::ScriptHandlerMgr::HandlerType::XMLHTTPREQUEST_READY_STATE_CHANGE ); if (0 != handler) { cocos2d::CommonScriptData data(handler,""); cocos2d::ScriptEvent event(cocos2d::ScriptEventType::kCommonEvent,(void*)&data); cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } } void LuaMinXmlHttpRequest::getByteData(unsigned char* byteData) { _data.read((char*)byteData, _dataSize); } /* function to regType */ static void lua_reg_xml_http_request(lua_State* L) { tolua_usertype(L, "cc.XMLHttpRequest"); } static int lua_collect_xml_http_request (lua_State* L) { LuaMinXmlHttpRequest* self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); Mtolua_delete(self); return 0; } static int lua_cocos2dx_XMLHttpRequest_constructor(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif argc = lua_gettop(L)-1; if (argc == 0) { self = new LuaMinXmlHttpRequest(); self->autorelease(); int ID = self? (int)self->_ID : -1; int* luaID = self? &self->_luaID : NULL; toluafix_pushusertype_ccobject(L, ID, luaID, (void*)self, "cc.XMLHttpRequest"); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "XMLHttpRequest",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_constructor'.",&tolua_err); return 0; #endif } static int lua_get_XMLHttpRequest_responseType(lua_State* L) { LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_get_XMLHttpRequest_responseType'\n", nullptr); return 0; } #endif tolua_pushnumber(L, (lua_Number)self->getResponseType()); return 1; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_get_XMLHttpRequest_responseType'.",&tolua_err); return 0; #endif } static int lua_set_XMLHttpRequest_responseType(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_set_XMLHttpRequest_responseType'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif int responseType = (int)tolua_tonumber(L,2,0); self->setResponseType((LuaMinXmlHttpRequest::ResponseType)responseType); return 0; } CCLOG("'setResponseType' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_set_XMLHttpRequest_responseType'.",&tolua_err); return 0; #endif } static int lua_get_XMLHttpRequest_withCredentials(lua_State* L) { LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_get_XMLHttpRequest_withCredentials'\n", nullptr); return 0; } #endif tolua_pushboolean(L, self->getWithCredentialsValue()); return 1; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_get_XMLHttpRequest_withCredentials'.",&tolua_err); return 0; #endif } static int lua_set_XMLHttpRequest_withCredentials(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_set_XMLHttpRequest_withCredentials'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif self->setWithCredentialsValue((bool)tolua_toboolean(L, 2, 0)); return 0; } CCLOG("'setWithCredentials' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_set_XMLHttpRequest_withCredentials'.",&tolua_err); return 0; #endif } static int lua_get_XMLHttpRequest_timeout(lua_State* L) { LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_get_XMLHttpRequest_timeout'\n", nullptr); return 0; } #endif tolua_pushnumber(L, (lua_Number)self->getTimeout()); return 1; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_get_XMLHttpRequest_timeout'.",&tolua_err); return 0; #endif } static int lua_set_XMLHttpRequest_timeout(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_set_XMLHttpRequest_timeout'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isnumber(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif self->setTimeout((unsigned)tolua_tonumber(L, 2, 0)); return 0; } CCLOG("'setTimeout' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_set_XMLHttpRequest_timeout'.",&tolua_err); return 0; #endif } static int lua_get_XMLHttpRequest_readyState(lua_State* L) { LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_get_XMLHttpRequest_readyState'\n", nullptr); return 0; } #endif lua_pushinteger(L, (lua_Integer)self->getReadyState()); return 1; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_get_XMLHttpRequest_readyState'.",&tolua_err); return 0; #endif } static int lua_get_XMLHttpRequest_status(lua_State* L) { LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_get_XMLHttpRequest_status'\n", nullptr); return 0; } #endif lua_pushinteger(L, (lua_Integer)self->getStatus()); return 1; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_get_XMLHttpRequest_status'.",&tolua_err); return 0; #endif } static int lua_get_XMLHttpRequest_statusText(lua_State* L) { LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_get_XMLHttpRequest_statusText'\n", nullptr); return 0; } #endif lua_pushstring(L, self->getStatusText().c_str()); return 1; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_get_XMLHttpRequest_statusText'.",&tolua_err); return 0; #endif } static int lua_get_XMLHttpRequest_responseText(lua_State* L) { LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_get_XMLHttpRequest_responseText'\n", nullptr); return 0; } #endif lua_pushstring(L, self->getDataStr().c_str()); return 1; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_get_XMLHttpRequest_responseText'.",&tolua_err); return 0; #endif } static int lua_get_XMLHttpRequest_response(lua_State* L) { LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_get_XMLHttpRequest_response'\n", nullptr); return 0; } #endif if (self->getResponseType() == LuaMinXmlHttpRequest::ResponseType::JSON) { lua_pushstring(L, self->getDataStr().c_str()); return 1; } else if(self->getResponseType() == LuaMinXmlHttpRequest::ResponseType::ARRAY_BUFFER) { LuaStack *pStack = LuaEngine::getInstance()->getLuaStack(); if (NULL == pStack) { return 0; } lua_State *tolua_s = pStack->getLuaState(); if (NULL == tolua_s) { return 0; } int nRet = 0; LuaValueArray array; uint8_t* tmpData = new uint8_t[self->getDataSize()]; if (nullptr == tmpData) { return 0; } self->getByteData(tmpData); for (int i = 0 ; i < self->getDataSize(); i++) { LuaValue value = LuaValue::intValue(tmpData[i]); array.push_back(value); } pStack->pushLuaValueArray(array); CC_SAFE_DELETE_ARRAY(tmpData); return 1; } else { lua_pushstring(L, self->getDataStr().c_str()); return 1; } #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_get_XMLHttpRequest_response'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_XMLHttpRequest_open(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_XMLHttpRequest_open'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if ( argc >= 2) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err)) goto tolua_lerror; #endif std::string method = tolua_tostring(L, 2, ""); std::string url = tolua_tostring(L, 3, ""); bool async = true; if (argc > 2) { #if COCOS2D_DEBUG >= 1 if (!tolua_isboolean(L, 4, 0, &tolua_err) ) goto tolua_lerror; #endif async = tolua_toboolean(L, 4, 0); } self->setUrl(url); self->setMethod(method); self->setReadyState(1); self->setAsync(async); if (url.length() > 5 && url.compare(url.length() - 5, 5, ".json") == 0 ) { self->setResponseType(LuaMinXmlHttpRequest::ResponseType::JSON); } if (nullptr != self->getHttpRequest()) { if (method.compare("post") == 0 || method.compare("POST") == 0) { self->getHttpRequest()->setRequestType(network::HttpRequest::Type::POST); } else { self->getHttpRequest()->setRequestType(network::HttpRequest::Type::GET); } self->getHttpRequest()->setUrl(url.c_str()); } self->setIsNetWork(true); self->setReadyState(LuaMinXmlHttpRequest::OPENED); return 0; } CCLOG("'open' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_open'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_XMLHttpRequest_send(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; //std::string data = ""; const char* data = NULL; size_t size = 0; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_XMLHttpRequest_send'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if ( 1 == argc ) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(L, 2, 0, &tolua_err)) goto tolua_lerror; #endif //data = tolua_tostring(L, 2, ""); data = (const char*) lua_tolstring(L, 2, &size); } if (size > 0 && (self->getMethod().compare("post") == 0 || self->getMethod().compare("POST") == 0) && nullptr != self->getHttpRequest()) { self->getHttpRequest()->setRequestData(data,size); } self->_setHttpRequestHeader(); self->_sendRequest(); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_send'.",&tolua_err); return 0; #endif } /** * @brief abort function Placeholder! */ static int lua_cocos2dx_XMLHttpRequest_abort(lua_State* L) { return 0; } static int lua_cocos2dx_XMLHttpRequest_setRequestHeader(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; const char* field = ""; const char* value = ""; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_XMLHttpRequest_setRequestHeader'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if ( 2 == argc ) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err) ) goto tolua_lerror; #endif field = tolua_tostring(L, 2, ""); value = tolua_tostring(L, 3, ""); self->setRequestHeader(field, value); return 0; } CCLOG("'setRequestHeader' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_setRequestHeader'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_XMLHttpRequest_getAllResponseHeaders(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; stringstream responseheaders; string responseheader = ""; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_XMLHttpRequest_getAllResponseHeaders'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if ( 0 == argc ) { map httpHeader = self->getHttpHeader(); for (auto it = httpHeader.begin(); it != httpHeader.end(); ++it) { responseheaders << it->first << ": "<< it->second << "\n"; } responseheader = responseheaders.str(); tolua_pushstring(L, responseheader.c_str()); return 1; } CCLOG("'getAllResponseHeaders' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_getAllResponseHeaders'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_XMLHttpRequest_getResponseHeader(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; string responseheader = ""; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_XMLHttpRequest_getAllResponseHeaders'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if ( 1 == argc ) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(L, 2, 0, &tolua_err) ) goto tolua_lerror; #endif responseheader = tolua_tostring(L, 2, ""); stringstream streamData; streamData << responseheader; string value = streamData.str(); auto iter = self->getHttpHeader().find(value); if (iter != self->getHttpHeader().end()) { tolua_pushstring(L, (iter->second).c_str()); return 1; } } CCLOG("'getResponseHeader' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_getAllResponseHeaders'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_XMLHttpRequest_registerScriptHandler(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; string responseheader = ""; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_XMLHttpRequest_registerScriptHandler'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if (1 == argc) { #if COCOS2D_DEBUG >= 1 if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) goto tolua_lerror; #endif int handler = ( toluafix_ref_function(L,2,0)); cocos2d::ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, cocos2d::ScriptHandlerMgr::HandlerType::XMLHTTPREQUEST_READY_STATE_CHANGE); return 0; } CCLOG("'registerScriptHandler' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_registerScriptHandler'.",&tolua_err); return 0; #endif } static int lua_cocos2dx_XMLHttpRequest_unregisterScriptHandler(lua_State* L) { int argc = 0; LuaMinXmlHttpRequest* self = nullptr; string responseheader = ""; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_XMLHttpRequest_unregisterScriptHandler'\n", nullptr); return 0; } #endif argc = lua_gettop(L) - 1; if (0 == argc) { cocos2d::ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, cocos2d::ScriptHandlerMgr::HandlerType::XMLHTTPREQUEST_READY_STATE_CHANGE); return 0; } CCLOG("'unregisterScriptHandler' function of XMLHttpRequest wrong number of arguments: %d, was expecting %d\n", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_unregisterScriptHandler'.",&tolua_err); return 0; #endif } TOLUA_API int register_xml_http_request(lua_State* L) { tolua_open(L); lua_reg_xml_http_request(L); tolua_module(L,"cc",0); tolua_beginmodule(L,"cc"); tolua_cclass(L,"XMLHttpRequest","cc.XMLHttpRequest","cc.Object",lua_collect_xml_http_request); tolua_beginmodule(L,"XMLHttpRequest"); tolua_variable(L, "responseType", lua_get_XMLHttpRequest_responseType, lua_set_XMLHttpRequest_responseType); tolua_variable(L, "withCredentials", lua_get_XMLHttpRequest_withCredentials, lua_set_XMLHttpRequest_withCredentials); tolua_variable(L, "timeout", lua_get_XMLHttpRequest_timeout, lua_set_XMLHttpRequest_timeout); tolua_variable(L, "readyState", lua_get_XMLHttpRequest_readyState, nullptr); tolua_variable(L, "status",lua_get_XMLHttpRequest_status,nullptr); tolua_variable(L, "statusText", lua_get_XMLHttpRequest_statusText, nullptr); tolua_variable(L, "responseText", lua_get_XMLHttpRequest_responseText, nullptr); tolua_variable(L, "response", lua_get_XMLHttpRequest_response, nullptr); tolua_function(L, "new", lua_cocos2dx_XMLHttpRequest_constructor); tolua_function(L, "open", lua_cocos2dx_XMLHttpRequest_open); tolua_function(L, "send", lua_cocos2dx_XMLHttpRequest_send); tolua_function(L, "abort", lua_cocos2dx_XMLHttpRequest_abort); tolua_function(L, "setRequestHeader", lua_cocos2dx_XMLHttpRequest_setRequestHeader); tolua_function(L, "getAllResponseHeaders", lua_cocos2dx_XMLHttpRequest_getAllResponseHeaders); tolua_function(L, "getResponseHeader", lua_cocos2dx_XMLHttpRequest_getResponseHeader); tolua_function(L, "registerScriptHandler", lua_cocos2dx_XMLHttpRequest_registerScriptHandler); tolua_function(L, "unregisterScriptHandler", lua_cocos2dx_XMLHttpRequest_unregisterScriptHandler); tolua_endmodule(L); tolua_endmodule(L); return 1; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/lua_xml_http_request.h ================================================ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __COCOS_SCRIPTING_LUA_BINDINGS_LUA_XML_HTTP_REQUEST_H__ #define __COCOS_SCRIPTING_LUA_BINDINGS_LUA_XML_HTTP_REQUEST_H__ #ifdef __cplusplus extern "C" { #endif #include "tolua++.h" #ifdef __cplusplus } #endif #include #include #include "network/HttpClient.h" class LuaMinXmlHttpRequest : public cocos2d::Object { public: enum class ResponseType { STRING, ARRAY_BUFFER, BLOB, DOCUMENT, JSON }; // Ready States (http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest) static const unsigned short UNSENT = 0; static const unsigned short OPENED = 1; static const unsigned short HEADERS_RECEIVED = 2; static const unsigned short LOADING = 3; static const unsigned short DONE = 4; LuaMinXmlHttpRequest(); ~LuaMinXmlHttpRequest(); void handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response); inline void setResponseType(ResponseType type) { _responseType = type; } inline ResponseType getResponseType() {return _responseType; } inline void setWithCredentialsValue(bool value) { _withCredentialsValue = value; } inline bool getWithCredentialsValue() {return _withCredentialsValue; } inline void setTimeout(unsigned timeOut) {_timeout = timeOut; } inline unsigned getTimeout() { return _timeout;} inline void setReadyState(int readyState) { _readyState = readyState; } inline int getReadyState() { return _readyState ;} inline cocos2d::network::HttpRequest* getHttpRequest() { return _httpRequest; } inline int getStatus() { return _status; } inline std::string getStatusText() { return _statusText ;} inline std::string getUrl(){return _url;} inline void setUrl(std::string url) { _url = url ;} inline std::string getMethod(){return _meth;} inline void setMethod(std::string meth) { _meth = meth ; } inline void setAsync(bool isAsync){ _isAsync = isAsync; } inline void setIsNetWork(bool isNetWork) {_isNetwork = isNetWork; } void _setHttpRequestHeader(); void _sendRequest(); void setRequestHeader(const char* field, const char* value); std::map getHttpHeader() { return _httpHeader ;} void getByteData(unsigned char* byteData); inline std::string getDataStr() { return _data.str(); } inline size_t getDataSize() { return _dataSize; } private: void _gotHeader(std::string header); std::string _url; std::string _meth; std::string _type; std::stringstream _data; size_t _dataSize; int _readyState; int _status; std::string _statusText; ResponseType _responseType; unsigned _timeout; bool _isAsync; cocos2d::network::HttpRequest* _httpRequest; bool _isNetwork; bool _withCredentialsValue; std::map _httpHeader; std::map _requestHeader; }; TOLUA_API int register_xml_http_request(lua_State* L); #endif //#ifndef __COCOS_SCRIPTING_LUA_BINDINGS_LUA_XML_HTTP_REQUEST_H__ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/platform/android/CCLuaJavaBridge.cpp ================================================ #include "CCLuaJavaBridge.h" #include "platform/android/jni/JniHelper.h" #include #define LOG_TAG "luajc" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) extern "C" { #include "tolua_fix.h" } LuaJavaBridge::CallInfo::~CallInfo(void) { if (m_returnType == TypeString && m_ret.stringValue) { delete m_ret.stringValue; } } bool LuaJavaBridge::CallInfo::execute(void) { switch (m_returnType) { case TypeVoid: m_env->CallStaticVoidMethod(m_classID, m_methodID); break; case TypeInteger: m_ret.intValue = m_env->CallStaticIntMethod(m_classID, m_methodID); break; case TypeFloat: m_ret.floatValue = m_env->CallStaticFloatMethod(m_classID, m_methodID); break; case TypeBoolean: m_ret.boolValue = m_env->CallStaticBooleanMethod(m_classID, m_methodID); break; case TypeString: m_retjs = (jstring)m_env->CallStaticObjectMethod(m_classID, m_methodID); const char *stringBuff = m_env->GetStringUTFChars(m_retjs, 0); m_ret.stringValue = new string(stringBuff); m_env->ReleaseStringUTFChars(m_retjs, stringBuff); break; } if (m_env->ExceptionCheck() == JNI_TRUE) { m_env->ExceptionDescribe(); m_env->ExceptionClear(); m_error = LUAJ_ERR_EXCEPTION_OCCURRED; return false; } return true; } bool LuaJavaBridge::CallInfo::executeWithArgs(jvalue *args) { switch (m_returnType) { case TypeVoid: m_env->CallStaticVoidMethodA(m_classID, m_methodID, args); break; case TypeInteger: m_ret.intValue = m_env->CallStaticIntMethodA(m_classID, m_methodID, args); break; case TypeFloat: m_ret.floatValue = m_env->CallStaticFloatMethodA(m_classID, m_methodID, args); break; case TypeBoolean: m_ret.boolValue = m_env->CallStaticBooleanMethodA(m_classID, m_methodID, args); break; case TypeString: m_retjs = (jstring)m_env->CallStaticObjectMethodA(m_classID, m_methodID, args); const char *stringBuff = m_env->GetStringUTFChars(m_retjs, 0); m_ret.stringValue = new string(stringBuff); m_env->ReleaseStringUTFChars(m_retjs, stringBuff); break; } if (m_env->ExceptionCheck() == JNI_TRUE) { m_env->ExceptionDescribe(); m_env->ExceptionClear(); m_error = LUAJ_ERR_EXCEPTION_OCCURRED; return false; } return true; } int LuaJavaBridge::CallInfo::pushReturnValue(lua_State *L) { if (m_error != LUAJ_ERR_OK) { lua_pushinteger(L, m_error); return 1; } switch (m_returnType) { case TypeInteger: lua_pushinteger(L, m_ret.intValue); return 1; case TypeFloat: lua_pushnumber(L, m_ret.floatValue); return 1; case TypeBoolean: lua_pushboolean(L, m_ret.boolValue); return 1; case TypeString: lua_pushstring(L, m_ret.stringValue->c_str()); return 1; } return 0; } bool LuaJavaBridge::CallInfo::validateMethodSig(void) { size_t len = m_methodSig.length(); if (len < 3 || m_methodSig[0] != '(') // min sig is "()V" { m_error = LUAJ_ERR_INVALID_SIGNATURES; return false; } size_t pos = 1; while (pos < len && m_methodSig[pos] != ')') { LuaJavaBridge::ValueType type = checkType(m_methodSig, &pos); if (type == TypeInvalid) return false; m_argumentsCount++; m_argumentsType.push_back(type); pos++; } if (pos >= len || m_methodSig[pos] != ')') { m_error = LUAJ_ERR_INVALID_SIGNATURES; return false; } pos++; m_returnType = checkType(m_methodSig, &pos); return true; } LuaJavaBridge::ValueType LuaJavaBridge::CallInfo::checkType(const string& sig, size_t *pos) { switch (sig[*pos]) { case 'I': return TypeInteger; case 'F': return TypeFloat; case 'Z': return TypeBoolean; case 'V': return TypeVoid; case 'L': size_t pos2 = sig.find_first_of(';', *pos + 1); if (pos2 == string::npos) { m_error = LUAJ_ERR_INVALID_SIGNATURES; return TypeInvalid; } const string t = sig.substr(*pos, pos2 - *pos + 1); if (t.compare("Ljava/lang/String;") == 0) { *pos = pos2; return TypeString; } else if (t.compare("Ljava/util/Vector;") == 0) { *pos = pos2; return TypeVector; } else { m_error = LUAJ_ERR_TYPE_NOT_SUPPORT; return TypeInvalid; } } m_error = LUAJ_ERR_TYPE_NOT_SUPPORT; return TypeInvalid; } bool LuaJavaBridge::CallInfo::getMethodInfo(void) { m_methodID = 0; m_env = 0; JavaVM* jvm = cocos2d::JniHelper::getJavaVM(); jint ret = jvm->GetEnv((void**)&m_env, JNI_VERSION_1_4); switch (ret) { case JNI_OK: break; case JNI_EDETACHED : if (jvm->AttachCurrentThread(&m_env, NULL) < 0) { LOGD("%s", "Failed to get the environment using AttachCurrentThread()"); m_error = LUAJ_ERR_VM_THREAD_DETACHED; return false; } break; case JNI_EVERSION : default : LOGD("%s", "Failed to get the environment using GetEnv()"); m_error = LUAJ_ERR_VM_FAILURE; return false; } jstring _jstrClassName = m_env->NewStringUTF(m_className.c_str()); m_classID = (jclass) m_env->CallObjectMethod(cocos2d::JniHelper::classloader, cocos2d::JniHelper::loadclassMethod_methodID, _jstrClassName); if (NULL == m_classID) { LOGD("Classloader failed to find class of %s", m_className.c_str()); } m_env->DeleteLocalRef(_jstrClassName); m_methodID = m_env->GetStaticMethodID(m_classID, m_methodName.c_str(), m_methodSig.c_str()); if (!m_methodID) { m_env->ExceptionClear(); LOGD("Failed to find method id of %s.%s %s", m_className.c_str(), m_methodName.c_str(), m_methodSig.c_str()); m_error = LUAJ_ERR_METHOD_NOT_FOUND; return false; } return true; } /* ---------------------------------------- */ lua_State *LuaJavaBridge::s_luaState = NULL; int LuaJavaBridge::s_newFunctionId = 0; void LuaJavaBridge::luaopen_luaj(lua_State *L) { s_luaState = L; lua_newtable(L); lua_pushstring(L, "callStaticMethod"); lua_pushcfunction(L, LuaJavaBridge::callJavaStaticMethod); lua_rawset(L, -3); lua_setglobal(L, "LuaJavaBridge"); } /* args: const char *className const char *methodName LUA_TABLE args const char *sig */ int LuaJavaBridge::callJavaStaticMethod(lua_State *L) { if (!lua_isstring(L, -4) || !lua_isstring(L, -3) || !lua_istable(L, -2) || !lua_isstring(L, -1)) { lua_pushboolean(L, 0); lua_pushinteger(L, LUAJ_ERR_INVALID_SIGNATURES); return 2; } LOGD("%s", "LuaJavaBridge::callJavaStaticMethod(lua_State *L)"); const char *className = lua_tostring(L, -4); const char *methodName = lua_tostring(L, -3); const char *methodSig = lua_tostring(L, -1); CallInfo call(className, methodName, methodSig); // check args lua_pop(L, 1); /* L: args */ int count = fetchArrayElements(L, -1); /* L: args e1 e2 e3 e4 ... */ jvalue *args = NULL; if (count > 0) { args = new jvalue[count]; for (int i = 0; i < count; ++i) { int index = -count + i; switch (call.argumentTypeAtIndex(i)) { case TypeInteger: if (lua_isfunction(L, index)) { args[i].i = retainLuaFunction(L, index, NULL); } else { args[i].i = (int)lua_tonumber(L, index); } break; case TypeFloat: args[i].f = lua_tonumber(L, index); break; case TypeBoolean: args[i].z = lua_toboolean(L, index) != 0 ? JNI_TRUE : JNI_FALSE; break; case TypeString: default: args[i].l = call.getEnv()->NewStringUTF(lua_tostring(L, index)); break; } } lua_pop(L, count); /* L: args */ } bool success = args ? call.executeWithArgs(args) : call.execute(); if (args) delete []args; if (!success) { LOGD("LuaJavaBridge::callJavaStaticMethod(\"%s\", \"%s\", args, \"%s\") EXECUTE FAILURE, ERROR CODE: %d", className, methodName, methodSig, call.getErrorCode()); lua_pushboolean(L, 0); lua_pushinteger(L, call.getErrorCode()); return 2; } LOGD("LuaJavaBridge::callJavaStaticMethod(\"%s\", \"%s\", args, \"%s\") SUCCESS", className, methodName, methodSig); lua_pushboolean(L, 1); return 1 + call.pushReturnValue(L); } // increase lua function refernece counter, return counter int LuaJavaBridge::retainLuaFunctionById(int functionId) { lua_State *L = s_luaState; lua_pushstring(L, LUAJ_REGISTRY_RETAIN); /* L: key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: id_r */ if (!lua_istable(L, -1)) { lua_pop(L, 1); return 0; } // get counter lua_pushinteger(L, functionId); /* L: id_r id */ lua_rawget(L, -2); /* L: id_r r */ if (lua_type(L, -1) != LUA_TNUMBER) { lua_pop(L, 2); return 0; } // increase counter int retainCount = lua_tonumber(L, -1); retainCount++; lua_pop(L, 1); /* L: id_r */ lua_pushinteger(L, functionId); /* L: id_r id */ lua_pushinteger(L, retainCount); /* L: id_r id r */ lua_rawset(L, -3); /* id_r[id] = r, L: id_r */ lua_pop(L, 1); LOGD("luajretainLuaFunctionById(%d) - retain count = %d", functionId, retainCount); return retainCount; } // decrease lua function reference counter, return counter int LuaJavaBridge::releaseLuaFunctionById(int functionId) { lua_State *L = s_luaState; /* L: */ lua_pushstring(L, LUAJ_REGISTRY_FUNCTION); /* L: key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f_id */ if (!lua_istable(L, -1)) { lua_pop(L, 1); LOGD("%s", "luajreleaseLuaFunctionById() - LUAJ_REGISTRY_FUNCTION not exists"); return 0; } lua_pushstring(L, LUAJ_REGISTRY_RETAIN); /* L: f_id key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f_id id_r */ if (!lua_istable(L, -1)) { lua_pop(L, 2); LOGD("%s", "luajreleaseLuaFunctionById() - LUAJ_REGISTRY_RETAIN not exists"); return 0; } lua_pushinteger(L, functionId); /* L: f_id id_r id */ lua_rawget(L, -2); /* L: f_id id_r r */ if (lua_type(L, -1) != LUA_TNUMBER) { lua_pop(L, 3); LOGD("luajreleaseLuaFunctionById() - function id %d not found", functionId); return 0; } int retainCount = lua_tonumber(L, -1); retainCount--; if (retainCount > 0) { // update counter lua_pop(L, 1); /* L: f_id id_r */ lua_pushinteger(L, functionId); /* L: f_id id_r id */ lua_pushinteger(L, retainCount); /* L: f_id id_r id r */ lua_rawset(L, -3); /* id_r[id] = r, L: f_id id_r */ lua_pop(L, 2); LOGD("luajreleaseLuaFunctionById() - function id %d retain count = %d", functionId, retainCount); return retainCount; } // remove lua function reference lua_pop(L, 1); /* L: f_id id_r */ lua_pushinteger(L, functionId); /* L: f_id id_r id */ lua_pushnil(L); /* L: f_id id_r id nil */ lua_rawset(L, -3); /* id_r[id] = nil, L: f_id id_r */ lua_pop(L, 1); /* L: f_id */ lua_pushnil(L); /* L: f_id nil */ while (lua_next(L, -2) != 0) /* L: f_id f id */ { int value = lua_tonumber(L, -1); lua_pop(L, 1); /* L: f_id f */ if (value == functionId) { lua_pushnil(L); /* L: f_id f nil */ lua_rawset(L, -3); /* f_id[f] = nil, L: f_id */ break; } } /* L: f_id */ lua_pop(L, 1); LOGD("luajreleaseLuaFunctionById() - function id %d released", functionId); return 0; } int LuaJavaBridge::callLuaFunctionById(int functionId, const char *arg) { lua_State *L = s_luaState; int top = lua_gettop(L); /* L: */ lua_pushstring(L, LUAJ_REGISTRY_FUNCTION); /* L: key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f_id */ if (!lua_istable(L, -1)) { lua_pop(L, 1); return -1; } lua_pushnil(L); /* L: f_id nil */ while (lua_next(L, -2) != 0) /* L: f_id f id */ { int value = lua_tonumber(L, -1); lua_pop(L, 1); /* L: f_id f */ if (value == functionId) { lua_pushstring(L, arg); /* L: f_id f arg */ int ok = lua_pcall(L, 1, 1, 0); /* L: f_id ret|err */ int ret; if (ok == 0) { ret = lua_tonumber(L, -1); } else { ret = -ok; } lua_settop(L, top); return ret; } } /* L: f_id */ lua_settop(L, top); return -1; } // call lua global function int LuaJavaBridge::callLuaGlobalFunction(const char *functionName, const char *arg) { lua_State *L = s_luaState; int ret = -1; int top = lua_gettop(L); lua_getglobal(L, functionName); if (lua_isfunction(L, -1)) { lua_pushstring(L, arg); int ok = lua_pcall(L, 1, 1, 0); if (ok == 0) { ret = lua_tonumber(L, -1); } else { ret = -ok; } } lua_settop(L, top); return ret; } // ---------------------------------------- // increase lua function reference counter, return functionId int LuaJavaBridge::retainLuaFunction(lua_State *L, int functionIndex, int *retainCountReturn) { /* L: f ... */ lua_pushstring(L, LUAJ_REGISTRY_FUNCTION); /* L: f ... key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f ... f_id */ if (!lua_istable(L, -1)) { lua_pop(L, 1); lua_newtable(L); lua_pushstring(L, LUAJ_REGISTRY_FUNCTION); lua_pushvalue(L, -2); lua_rawset(L, LUA_REGISTRYINDEX); } lua_pushstring(L, LUAJ_REGISTRY_RETAIN); /* L: f ... f_id key */ lua_rawget(L, LUA_REGISTRYINDEX); /* L: f ... f_id id_r */ if (!lua_istable(L, -1)) { lua_pop(L, 1); lua_newtable(L); lua_pushstring(L, LUAJ_REGISTRY_RETAIN); lua_pushvalue(L, -2); lua_rawset(L, LUA_REGISTRYINDEX); } // get function id lua_pushvalue(L, functionIndex - 2); /* L: f ... f_id id_r f */ lua_rawget(L, -3); /* L: f ... f_id id_r id */ int functionId; if (lua_type(L, -1) != LUA_TNUMBER) { // first retain, create new id lua_pop(L, 1); /* L: f ... f_id id_r */ s_newFunctionId++; functionId = s_newFunctionId; lua_pushvalue(L, functionIndex - 2); /* L: f ... f_id id_r f */ lua_pushinteger(L, functionId); /* L: f ... f_id id_r f id */ lua_rawset(L, -4); /* f_id[f] = id, L: f ... f_id id_r */ lua_pushinteger(L, functionId); /* L: f ... f_id id_r id */ } else { functionId = lua_tonumber(L, -1); } // get function retain lua_pushvalue(L, -1); /* L: f ... f_id id_r id id */ lua_rawget(L, -3); /* L: f ... f_id id_r id r */ int retainCount = 1; if (lua_type(L, -1) != LUA_TNUMBER) { // first retain, set retain count = 1 lua_pop(L, 1); lua_pushinteger(L, retainCount); } else { // add retain count retainCount = lua_tonumber(L, -1); retainCount++; lua_pop(L, 1); lua_pushinteger(L, retainCount); } lua_rawset(L, -3); /* id_r[id] = r, L: f ... f_id id_r */ lua_pop(L, 2); /* L: f ... */ if (retainCountReturn) *retainCountReturn = retainCount; return functionId; } int LuaJavaBridge::fetchArrayElements(lua_State *L, int index) { int count = 0; do { lua_rawgeti(L, index - count, count + 1); if (lua_isnil(L, -1)) { lua_pop(L, 1); break; } ++count; } while (1); return count; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/platform/android/CCLuaJavaBridge.h ================================================ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_PLATFORM_ANDROID_LUA_JAVA_BRIDGE_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_PLATFORM_ANDROID_LUA_JAVA_BRIDGE_H #include #include #include #include "cocos2d.h" using namespace std; extern "C" { #include "lua.h" } using namespace cocos2d; #define LUAJ_ERR_OK 0 #define LUAJ_ERR_TYPE_NOT_SUPPORT (-1) #define LUAJ_ERR_INVALID_SIGNATURES (-2) #define LUAJ_ERR_METHOD_NOT_FOUND (-3) #define LUAJ_ERR_EXCEPTION_OCCURRED (-4) #define LUAJ_ERR_VM_THREAD_DETACHED (-5) #define LUAJ_ERR_VM_FAILURE (-6) #define LUAJ_REGISTRY_FUNCTION "luaj_function_id" // table[function] = id #define LUAJ_REGISTRY_RETAIN "luaj_function_id_retain" // table[id] = retain count class LuaJavaBridge { public: static void luaopen_luaj(lua_State *L); static int retainLuaFunctionById(int functionId); static int releaseLuaFunctionById(int functionId); static int callLuaFunctionById(int functionId, const char *arg); static int callLuaGlobalFunction(const char *functionName, const char *arg); private: typedef enum { TypeInvalid = -1, TypeVoid = 0, TypeInteger = 1, TypeFloat = 2, TypeBoolean = 3, TypeString = 4, TypeVector = 5, TypeFunction= 6, } ValueType; typedef vector ValueTypes; typedef union { int intValue; float floatValue; int boolValue; string *stringValue; } ReturnValue; class CallInfo { public: CallInfo(const char *className, const char *methodName, const char *methodSig) : m_valid(false) , m_error(LUAJ_ERR_OK) , m_className(className) , m_methodName(methodName) , m_methodSig(methodSig) , m_returnType(TypeVoid) , m_argumentsCount(0) , m_retjs(NULL) , m_env(NULL) , m_classID(NULL) , m_methodID(NULL) { memset(&m_ret, 0, sizeof(m_ret)); m_valid = validateMethodSig() && getMethodInfo(); } ~CallInfo(void); bool isValid(void) { return m_valid; } int getErrorCode(void) { return m_error; } JNIEnv *getEnv(void) { return m_env; } int argumentTypeAtIndex(size_t index) { return m_argumentsType.at(index); } bool execute(void); bool executeWithArgs(jvalue *args); int pushReturnValue(lua_State *L); private: bool m_valid; int m_error; string m_className; string m_methodName; string m_methodSig; int m_argumentsCount; ValueTypes m_argumentsType; ValueType m_returnType; ReturnValue m_ret; jstring m_retjs; JNIEnv *m_env; jclass m_classID; jmethodID m_methodID; bool validateMethodSig(void); bool getMethodInfo(void); ValueType checkType(const string& sig, size_t *pos); }; static int callJavaStaticMethod(lua_State *L); static int retainLuaFunction(lua_State *L, int functionIndex, int *retainCountReturn); static int getMethodInfo(CallInfo *call, const char *className, const char *methodName, const char *paramCode); static int fetchArrayElements(lua_State *L, int index); static int callAndPushReturnValue(lua_State *L, CallInfo *call, jvalue *args); static lua_State *s_luaState; static int s_newFunctionId; }; #endif //COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_PLATFORM_ANDROID_LUA_JAVA_BRIDGE_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge.cpp ================================================ #include "Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge.h" #include #include "CCLuaJavaBridge.h" #define LOG_TAG "Cocos2dxLuaJavaBridge_java" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) extern "C" { JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaFunctionWithString (JNIEnv *env, jclass cls, jint functionId, jstring value) { const char *value_ = env->GetStringUTFChars(value, 0); int ret = LuaJavaBridge::callLuaFunctionById(functionId, value_); env->ReleaseStringUTFChars(value, value_); return ret; } JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaGlobalFunctionWithString (JNIEnv *env, jclass cls, jstring luaFunctionName, jstring value) { const char *luaFunctionName_ = env->GetStringUTFChars(luaFunctionName, 0); const char *value_ = env->GetStringUTFChars(value, 0); int ret = LuaJavaBridge::callLuaGlobalFunction(luaFunctionName_, value_); env->ReleaseStringUTFChars(luaFunctionName, luaFunctionName_); env->ReleaseStringUTFChars(value, value_); return ret; } JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_retainLuaFunction (JNIEnv *env, jclass cls, jint luaFunctionId) { return LuaJavaBridge::retainLuaFunctionById(luaFunctionId); } JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_releaseLuaFunction (JNIEnv *env, jclass cls, jint luaFunctionId) { return LuaJavaBridge::releaseLuaFunctionById(luaFunctionId); } } // extern "C" ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge.h ================================================ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_PLATFORM_ANDROID_JNI_JAVA_ORG_COCOS2DX_LIB_COCOS2DX_LUA_JAVA_BRIDEG_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_PLATFORM_ANDROID_JNI_JAVA_ORG_COCOS2DX_LIB_COCOS2DX_LUA_JAVA_BRIDEG_H #include extern "C" { /* * Class: Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge * Method: callLuaFunctionWithString * Signature: (ILjava/lang/String;)I */ JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaFunctionWithString (JNIEnv *, jclass, jint, jstring); /* * Class: Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge * Method: callLuaGlobalFunctionWithString * Signature: (Ljava/lang/String;Ljava/lang/String;)I */ JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaGlobalFunctionWithString (JNIEnv *env, jclass, jstring, jstring); /* * Class: Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge * Method: retainLuaFunction * Signature: (I)I */ JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_retainLuaFunction (JNIEnv *env, jclass, jint); /* * Class: Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge * Method: releaseLuaFunction * Signature: (I)I */ JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_releaseLuaFunction (JNIEnv *env, jclass, jint); } // extern "C" #endif // COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_PLATFORM_ANDROID_JNI_JAVA_ORG_COCOS2DX_LIB_COCOS2DX_LUA_JAVA_BRIDEG_H ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/platform/ios/CCLuaObjcBridge.h ================================================ #ifndef __LUA_OBJC_BRIDGE_H_ #define __LUA_OBJC_BRIDGE_H_ #include "CCLuaBridge.h" NS_CC_BEGIN class LuaObjcBridge : public LuaBridge { public: static void luaopen_luaoc(lua_State *L); protected: static int callObjcStaticMethod(lua_State *L); static void pushValue(lua_State *L, void *val); }; NS_CC_END #endif // __LUA_OBJC_BRIDGE_H_ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/platform/ios/CCLuaObjcBridge.mm ================================================ #include "CCLuaObjcBridge.h" NS_CC_BEGIN void LuaObjcBridge::luaopen_luaoc(lua_State *L) { s_luaState = L; lua_newtable(L); lua_pushstring(L, "callStaticMethod"); lua_pushcfunction(L, LuaObjcBridge::callObjcStaticMethod); lua_rawset(L, -3); lua_setglobal(L, "LuaObjcBridge"); } /** className methodName args */ int LuaObjcBridge::callObjcStaticMethod(lua_State *L) { if (lua_gettop(L) != 3 || !lua_isstring(L, -3) || !lua_isstring(L, -2)) { lua_pushboolean(L, 0); lua_pushinteger(L, kLuaBridgeErrorInvalidParameters); return 2; } const char *className = lua_tostring(L, -3); const char *methodName = lua_tostring(L, -2); if (!className || !methodName) { lua_pushboolean(L, 0); lua_pushinteger(L, kLuaBridgeErrorInvalidParameters); return 2; } Class targetClass = NSClassFromString([NSString stringWithCString:className encoding:NSUTF8StringEncoding]); if (!targetClass) { lua_pushboolean(L, 0); lua_pushinteger(L, kLuaBridgeErrorClassNotFound); return 2; } SEL methodSel; bool hasArguments = lua_istable(L, -1); if (hasArguments) { NSString *methodName_ = [NSString stringWithCString:methodName encoding:NSUTF8StringEncoding]; methodName_ = [NSString stringWithFormat:@"%@:", methodName_]; methodSel = NSSelectorFromString(methodName_); } else { methodSel = NSSelectorFromString([NSString stringWithCString:methodName encoding:NSUTF8StringEncoding]); } if (methodSel == (SEL)0) { lua_pushboolean(L, 0); lua_pushinteger(L, kLuaBridgeErrorMethodNotFound); return 2; } NSMethodSignature *methodSig = [targetClass methodSignatureForSelector:(SEL)methodSel]; if (methodSig == nil) { lua_pushboolean(L, 0); lua_pushinteger(L, kLuaBridgeErrorMethodSignature); return 2; } @try { NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig]; [invocation setTarget:targetClass]; [invocation setSelector:methodSel]; NSUInteger returnLength = [methodSig methodReturnLength]; const char *returnType = [methodSig methodReturnType]; if (hasArguments) { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; lua_pushnil(L); while (lua_next(L, -2)) { NSString *key = [NSString stringWithCString:lua_tostring(L, -2) encoding:NSUTF8StringEncoding]; switch (lua_type(L, -1)) { case LUA_TNUMBER: [dict setObject:[NSNumber numberWithFloat:lua_tonumber(L, -1)] forKey:key]; break; case LUA_TBOOLEAN: [dict setObject:[NSNumber numberWithBool:lua_toboolean(L, -1)] forKey:key]; break; case LUA_TSTRING: [dict setObject:[NSString stringWithCString:lua_tostring(L, -1) encoding:NSUTF8StringEncoding] forKey:key]; break; case LUA_TFUNCTION: int functionId = retainLuaFunction(L, -1, NULL); [dict setObject:[NSNumber numberWithInt:functionId] forKey:key]; break; } lua_pop(L, 1); } [invocation setArgument:&dict atIndex:2]; [invocation invoke]; } else { [invocation invoke]; } lua_pushboolean(L, 1); if (returnLength > 0) { if (strcmp(returnType, "@") == 0) { id ret; [invocation getReturnValue:&ret]; pushValue(L, ret); } else if (strcmp(returnType, "c") == 0) // BOOL { char ret; [invocation getReturnValue:&ret]; lua_pushboolean(L, ret); } else if (strcmp(returnType, "i") == 0) // int { int ret; [invocation getReturnValue:&ret]; lua_pushinteger(L, ret); } else if (strcmp(returnType, "f") == 0) // float { float ret; [invocation getReturnValue:&ret]; lua_pushnumber(L, ret); } else { NSLog(@"not support return type = %s", returnType); lua_pushnil(L); } } else { lua_pushnil(L); } return 2; } @catch (NSException *exception) { NSLog(@"EXCEPTION THROW: %@", exception); lua_pushboolean(L, 0); lua_pushinteger(L, kLuaBridgeErrorExceptionOccurred); return 2; } } void LuaObjcBridge::pushValue(lua_State *L, void *val) { id oval = (id)val; if (oval == nil) { lua_pushnil(L); } else if ([oval isKindOfClass:[NSNumber class]]) { NSNumber *number = (NSNumber *)oval; const char *numberType = [number objCType]; if (strcmp(numberType, @encode(BOOL)) == 0) { lua_pushboolean(L, [number boolValue]); } else if (strcmp(numberType, @encode(int)) == 0) { lua_pushinteger(L, [number intValue]); } else { lua_pushnumber(L, [number floatValue]); } } else if ([oval isKindOfClass:[NSString class]]) { lua_pushstring(L, [oval cStringUsingEncoding:NSUTF8StringEncoding]); } else if ([oval isKindOfClass:[NSDictionary class]]) { lua_newtable(L); for (id key in oval) { const char *key_ = [[NSString stringWithFormat:@"%@", key] cStringUsingEncoding:NSUTF8StringEncoding]; lua_pushstring(L, key_); pushValue(L, [oval objectForKey:key]); lua_rawset(L, -3); } return; } else { lua_pushstring(L, [[NSString stringWithFormat:@"%@", oval] cStringUsingEncoding:NSUTF8StringEncoding]); } } NS_CC_END ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/auxiliar.c ================================================ /*=========================================================================*\ * Auxiliar routines for class hierarchy manipulation * LuaSocket toolkit \*=========================================================================*/ #include #include #include "auxiliar.h" /*=========================================================================*\ * Exported functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Initializes the module \*-------------------------------------------------------------------------*/ int auxiliar_open(lua_State *L) { (void) L; return 0; } /*-------------------------------------------------------------------------*\ * Creates a new class with given methods * Methods whose names start with __ are passed directly to the metatable. \*-------------------------------------------------------------------------*/ void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) { luaL_newmetatable(L, classname); /* mt */ /* create __index table to place methods */ lua_pushstring(L, "__index"); /* mt,"__index" */ lua_newtable(L); /* mt,"__index",it */ /* put class name into class metatable */ lua_pushstring(L, "class"); /* mt,"__index",it,"class" */ lua_pushstring(L, classname); /* mt,"__index",it,"class",classname */ lua_rawset(L, -3); /* mt,"__index",it */ /* pass all methods that start with _ to the metatable, and all others * to the index table */ for (; func->name; func++) { /* mt,"__index",it */ lua_pushstring(L, func->name); lua_pushcfunction(L, func->func); lua_rawset(L, func->name[0] == '_' ? -5: -3); } lua_rawset(L, -3); /* mt */ lua_pop(L, 1); } /*-------------------------------------------------------------------------*\ * Prints the value of a class in a nice way \*-------------------------------------------------------------------------*/ int auxiliar_tostring(lua_State *L) { char buf[32]; if (!lua_getmetatable(L, 1)) goto error; lua_pushstring(L, "__index"); lua_gettable(L, -2); if (!lua_istable(L, -1)) goto error; lua_pushstring(L, "class"); lua_gettable(L, -2); if (!lua_isstring(L, -1)) goto error; sprintf(buf, "%p", lua_touserdata(L, 1)); lua_pushfstring(L, "%s: %s", lua_tostring(L, -1), buf); return 1; error: lua_pushstring(L, "invalid object passed to 'auxiliar.c:__tostring'"); lua_error(L); return 1; } /*-------------------------------------------------------------------------*\ * Insert class into group \*-------------------------------------------------------------------------*/ void auxiliar_add2group(lua_State *L, const char *classname, const char *groupname) { luaL_getmetatable(L, classname); lua_pushstring(L, groupname); lua_pushboolean(L, 1); lua_rawset(L, -3); lua_pop(L, 1); } /*-------------------------------------------------------------------------*\ * Make sure argument is a boolean \*-------------------------------------------------------------------------*/ int auxiliar_checkboolean(lua_State *L, int objidx) { if (!lua_isboolean(L, objidx)) auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); return lua_toboolean(L, objidx); } /*-------------------------------------------------------------------------*\ * Return userdata pointer if object belongs to a given class, abort with * error otherwise \*-------------------------------------------------------------------------*/ void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) { void *data = auxiliar_getclassudata(L, classname, objidx); if (!data) { char msg[45]; sprintf(msg, "%.35s expected", classname); luaL_argerror(L, objidx, msg); } return data; } /*-------------------------------------------------------------------------*\ * Return userdata pointer if object belongs to a given group, abort with * error otherwise \*-------------------------------------------------------------------------*/ void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) { void *data = auxiliar_getgroupudata(L, groupname, objidx); if (!data) { char msg[45]; sprintf(msg, "%.35s expected", groupname); luaL_argerror(L, objidx, msg); } return data; } /*-------------------------------------------------------------------------*\ * Set object class \*-------------------------------------------------------------------------*/ void auxiliar_setclass(lua_State *L, const char *classname, int objidx) { luaL_getmetatable(L, classname); if (objidx < 0) objidx--; lua_setmetatable(L, objidx); } /*-------------------------------------------------------------------------*\ * Get a userdata pointer if object belongs to a given group. Return NULL * otherwise \*-------------------------------------------------------------------------*/ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { if (!lua_getmetatable(L, objidx)) return NULL; lua_pushstring(L, groupname); lua_rawget(L, -2); if (lua_isnil(L, -1)) { lua_pop(L, 2); return NULL; } else { lua_pop(L, 2); return lua_touserdata(L, objidx); } } /*-------------------------------------------------------------------------*\ * Get a userdata pointer if object belongs to a given class. Return NULL * otherwise \*-------------------------------------------------------------------------*/ void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { return luaL_checkudata(L, objidx, classname); } /*-------------------------------------------------------------------------*\ * Throws error when argument does not have correct type. * Used to be part of lauxlib in Lua 5.1, was dropped from 5.2. \*-------------------------------------------------------------------------*/ int auxiliar_typeerror (lua_State *L, int narg, const char *tname) { const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, luaL_typename(L, narg)); return luaL_argerror(L, narg, msg); } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/auxiliar.h ================================================ #ifndef AUXILIAR_H #define AUXILIAR_H /*=========================================================================*\ * Auxiliar routines for class hierarchy manipulation * LuaSocket toolkit (but completely independent of other LuaSocket modules) * * A LuaSocket class is a name associated with Lua metatables. A LuaSocket * group is a name associated with a class. A class can belong to any number * of groups. This module provides the functionality to: * * - create new classes * - add classes to groups * - set the class of objects * - check if an object belongs to a given class or group * - get the userdata associated to objects * - print objects in a pretty way * * LuaSocket class names follow the convention {}. Modules * can define any number of classes and groups. The module tcp.c, for * example, defines the classes tcp{master}, tcp{client} and tcp{server} and * the groups tcp{client,server} and tcp{any}. Module functions can then * perform type-checking on their arguments by either class or group. * * LuaSocket metatables define the __index metamethod as being a table. This * table has one field for each method supported by the class, and a field * "class" with the class name. * * The mapping from class name to the corresponding metatable and the * reverse mapping are done using lauxlib. \*=========================================================================*/ #include "lua.h" #include "lauxlib.h" int auxiliar_open(lua_State *L); void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func); void auxiliar_add2group(lua_State *L, const char *classname, const char *group); void auxiliar_setclass(lua_State *L, const char *classname, int objidx); void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx); void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx); void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx); void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx); int auxiliar_checkboolean(lua_State *L, int objidx); int auxiliar_tostring(lua_State *L); int auxiliar_typeerror(lua_State *L, int narg, const char *tname); #endif /* AUXILIAR_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/except.c ================================================ /*=========================================================================*\ * Simple exception support * LuaSocket toolkit \*=========================================================================*/ #include #include "lua.h" #include "lauxlib.h" #include "except.h" /*=========================================================================*\ * Internal function prototypes. \*=========================================================================*/ static int global_protect(lua_State *L); static int global_newtry(lua_State *L); static int protected_(lua_State *L); static int finalize(lua_State *L); static int do_nothing(lua_State *L); /* except functions */ static luaL_Reg func[] = { {"newtry", global_newtry}, {"protect", global_protect}, {NULL, NULL} }; /*-------------------------------------------------------------------------*\ * Try factory \*-------------------------------------------------------------------------*/ static void wrap(lua_State *L) { lua_newtable(L); lua_pushnumber(L, 1); lua_pushvalue(L, -3); lua_settable(L, -3); lua_insert(L, -2); lua_pop(L, 1); } static int finalize(lua_State *L) { if (!lua_toboolean(L, 1)) { lua_pushvalue(L, lua_upvalueindex(1)); lua_pcall(L, 0, 0, 0); lua_settop(L, 2); wrap(L); lua_error(L); return 0; } else return lua_gettop(L); } static int do_nothing(lua_State *L) { (void) L; return 0; } static int global_newtry(lua_State *L) { lua_settop(L, 1); if (lua_isnil(L, 1)) lua_pushcfunction(L, do_nothing); lua_pushcclosure(L, finalize, 1); return 1; } /*-------------------------------------------------------------------------*\ * Protect factory \*-------------------------------------------------------------------------*/ static int unwrap(lua_State *L) { if (lua_istable(L, -1)) { lua_pushnumber(L, 1); lua_gettable(L, -2); lua_pushnil(L); lua_insert(L, -2); return 1; } else return 0; } static int protected_(lua_State *L) { lua_pushvalue(L, lua_upvalueindex(1)); lua_insert(L, 1); if (lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0) != 0) { if (unwrap(L)) return 2; else lua_error(L); return 0; } else return lua_gettop(L); } static int global_protect(lua_State *L) { lua_pushcclosure(L, protected_, 1); return 1; } /*-------------------------------------------------------------------------*\ * Init module \*-------------------------------------------------------------------------*/ int except_open(lua_State *L) { luaL_openlib(L, NULL, func, 0); return 0; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/except.h ================================================ #ifndef EXCEPT_H #define EXCEPT_H /*=========================================================================*\ * Exception control * LuaSocket toolkit (but completely independent from other modules) * * This provides support for simple exceptions in Lua. During the * development of the HTTP/FTP/SMTP support, it became aparent that * error checking was taking a substantial amount of the coding. These * function greatly simplify the task of checking errors. * * The main idea is that functions should return nil as its first return * value when it finds an error, and return an error message (or value) * following nil. In case of success, as long as the first value is not nil, * the other values don't matter. * * The idea is to nest function calls with the "try" function. This function * checks the first value, and calls "error" on the second if the first is * nil. Otherwise, it returns all values it received. * * The protect function returns a new function that behaves exactly like the * function it receives, but the new function doesn't throw exceptions: it * returns nil followed by the error message instead. * * With these two function, it's easy to write functions that throw * exceptions on error, but that don't interrupt the user script. \*=========================================================================*/ #include "lua.h" int except_open(lua_State *L); #endif ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/inet.c ================================================ /*=========================================================================*\ * Internet domain functions * LuaSocket toolkit \*=========================================================================*/ #include #include #include "lua.h" #include "lauxlib.h" #include "inet.h" /*=========================================================================*\ * Internal function prototypes. \*=========================================================================*/ static int inet_global_toip(lua_State *L); static int inet_global_getaddrinfo(lua_State *L); static int inet_global_tohostname(lua_State *L); static int inet_global_getnameinfo(lua_State *L); static void inet_pushresolved(lua_State *L, struct hostent *hp); static int inet_global_gethostname(lua_State *L); /* DNS functions */ static luaL_Reg func[] = { { "toip", inet_global_toip}, { "getaddrinfo", inet_global_getaddrinfo}, { "tohostname", inet_global_tohostname}, { "getnameinfo", inet_global_getnameinfo}, { "gethostname", inet_global_gethostname}, { NULL, NULL} }; #ifdef _WINDOWS_ /****luodx patch for windows xp start**/ char* win32xp_inet_ntop(int family, PVOID src, char* dest, size_t length) { char* result = inet_ntoa(*(IN_ADDR*)src); if (result != NULL){ strcpy(dest, result); } return result; } int win32xp_inet_pton(int family, const char* string, PVOID dest) { return inet_aton(string, (IN_ADDR*)dest); } /****luodx patch for windows xp end**/ #endif /*=========================================================================*\ * Exported functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int inet_open(lua_State *L) { lua_pushstring(L, "dns"); lua_newtable(L); luaL_openlib(L, NULL, func, 0); lua_settable(L, -3); return 0; } /*=========================================================================*\ * Global Lua functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Returns all information provided by the resolver given a host name * or ip address \*-------------------------------------------------------------------------*/ static int inet_gethost(const char *address, struct hostent **hp) { struct in_addr addr; if (inet_aton(address, &addr)) return socket_gethostbyaddr((char *) &addr, sizeof(addr), hp); else return socket_gethostbyname(address, hp); } /*-------------------------------------------------------------------------*\ * Returns all information provided by the resolver given a host name * or ip address \*-------------------------------------------------------------------------*/ static int inet_global_tohostname(lua_State *L) { const char *address = luaL_checkstring(L, 1); struct hostent *hp = NULL; int err = inet_gethost(address, &hp); if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, socket_hoststrerror(err)); return 2; } lua_pushstring(L, hp->h_name); inet_pushresolved(L, hp); return 2; } static int inet_global_getnameinfo(lua_State *L) { int i, ret; char host[1024]; char serv[32]; struct addrinfo hints; struct addrinfo *resolved, *iter; const char *node = luaL_optstring(L, 1, NULL); const char *service = luaL_optstring(L, 2, NULL); if (!(node || service)) luaL_error(L, "You have to specify a hostname, a service, or both"); memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; hints.ai_family = PF_UNSPEC; /* getaddrinfo must get a node and a service argument */ ret = getaddrinfo(node ? node : "127.0.0.1", service ? service : "7", &hints, &resolved); if (ret != 0) { lua_pushnil(L); lua_pushstring(L, socket_gaistrerror(ret)); return 2; } lua_newtable(L); for (i = 1, iter = resolved; iter; i++, iter = iter->ai_next) { getnameinfo(iter->ai_addr, (socklen_t) iter->ai_addrlen, host, node ? (socklen_t) sizeof(host) : 0, serv, service ? (socklen_t) sizeof(serv) : 0, 0); if (node) { lua_pushnumber(L, i); lua_pushstring(L, host); lua_settable(L, -3); } } freeaddrinfo(resolved); if (service) { lua_pushstring(L, serv); return 2; } else { return 1; } } /*-------------------------------------------------------------------------*\ * Returns all information provided by the resolver given a host name * or ip address \*-------------------------------------------------------------------------*/ static int inet_global_toip(lua_State *L) { const char *address = luaL_checkstring(L, 1); struct hostent *hp = NULL; int err = inet_gethost(address, &hp); if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, socket_hoststrerror(err)); return 2; } lua_pushstring(L, inet_ntoa(*((struct in_addr *) hp->h_addr))); inet_pushresolved(L, hp); return 2; } int inet_optfamily(lua_State* L, int narg, const char* def) { static const char* optname[] = { "unspec", "inet", "inet6", NULL }; static int optvalue[] = { PF_UNSPEC, PF_INET, PF_INET6, 0 }; return optvalue[luaL_checkoption(L, narg, def, optname)]; } int inet_optsocktype(lua_State* L, int narg, const char* def) { static const char* optname[] = { "stream", "dgram", NULL }; static int optvalue[] = { SOCK_STREAM, SOCK_DGRAM, 0 }; return optvalue[luaL_checkoption(L, narg, def, optname)]; } static int inet_global_getaddrinfo(lua_State *L) { const char *hostname = luaL_checkstring(L, 1); struct addrinfo *iterator = NULL, *resolved = NULL; struct addrinfo hints; int i = 1, ret = 0; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; hints.ai_family = PF_UNSPEC; ret = getaddrinfo(hostname, NULL, &hints, &resolved); if (ret != 0) { lua_pushnil(L); lua_pushstring(L, socket_gaistrerror(ret)); return 2; } lua_newtable(L); for (iterator = resolved; iterator; iterator = iterator->ai_next) { char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; getnameinfo(iterator->ai_addr, (socklen_t) iterator->ai_addrlen, hbuf, (socklen_t) sizeof(hbuf), sbuf, 0, NI_NUMERICHOST); lua_pushnumber(L, i); lua_newtable(L); switch (iterator->ai_family) { case AF_INET: lua_pushliteral(L, "family"); lua_pushliteral(L, "inet"); lua_settable(L, -3); break; case AF_INET6: lua_pushliteral(L, "family"); lua_pushliteral(L, "inet6"); lua_settable(L, -3); break;; } lua_pushliteral(L, "addr"); lua_pushstring(L, hbuf); lua_settable(L, -3); lua_settable(L, -3); i++; } freeaddrinfo(resolved); return 1; } /*-------------------------------------------------------------------------*\ * Gets the host name \*-------------------------------------------------------------------------*/ static int inet_global_gethostname(lua_State *L) { char name[257]; name[256] = '\0'; if (gethostname(name, 256) < 0) { lua_pushnil(L); lua_pushstring(L, socket_strerror(errno)); return 2; } else { lua_pushstring(L, name); return 1; } } /*=========================================================================*\ * Lua methods \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Retrieves socket peer name \*-------------------------------------------------------------------------*/ int inet_meth_getpeername(lua_State *L, p_socket ps, int family) { switch (family) { case PF_INET: { struct sockaddr_in peer; socklen_t peer_len = sizeof(peer); char name[INET_ADDRSTRLEN]; if (getpeername(*ps, (SA *) &peer, &peer_len) < 0) { lua_pushnil(L); lua_pushstring(L, socket_strerror(errno)); return 2; } else { my_inet_ntop(family, &peer.sin_addr, name, sizeof(name)); lua_pushstring(L, name); lua_pushnumber(L, ntohs(peer.sin_port)); lua_pushliteral(L, "inet"); return 3; } } case PF_INET6: { struct sockaddr_in6 peer; socklen_t peer_len = sizeof(peer); char name[INET6_ADDRSTRLEN]; if (getpeername(*ps, (SA *) &peer, &peer_len) < 0) { lua_pushnil(L); lua_pushstring(L, socket_strerror(errno)); return 2; } else { my_inet_ntop(family, &peer.sin6_addr, name, sizeof(name)); lua_pushstring(L, name); lua_pushnumber(L, ntohs(peer.sin6_port)); lua_pushliteral(L, "inet6"); return 3; } } default: lua_pushnil(L); lua_pushfstring(L, "unknown family %d", family); return 2; } } /*-------------------------------------------------------------------------*\ * Retrieves socket local name \*-------------------------------------------------------------------------*/ int inet_meth_getsockname(lua_State *L, p_socket ps, int family) { switch (family) { case PF_INET: { struct sockaddr_in local; socklen_t local_len = sizeof(local); char name[INET_ADDRSTRLEN]; if (getsockname(*ps, (SA *) &local, &local_len) < 0) { lua_pushnil(L); lua_pushstring(L, socket_strerror(errno)); return 2; } else { my_inet_ntop(family, &local.sin_addr, name, sizeof(name)); lua_pushstring(L, name); lua_pushnumber(L, ntohs(local.sin_port)); lua_pushliteral(L, "inet"); return 3; } } case PF_INET6: { struct sockaddr_in6 local; socklen_t local_len = sizeof(local); char name[INET6_ADDRSTRLEN]; if (getsockname(*ps, (SA *) &local, &local_len) < 0) { lua_pushnil(L); lua_pushstring(L, socket_strerror(errno)); return 2; } else { my_inet_ntop(family, &local.sin6_addr, name, sizeof(name)); lua_pushstring(L, name); lua_pushnumber(L, ntohs(local.sin6_port)); lua_pushliteral(L, "inet6"); return 3; } } default: lua_pushnil(L); lua_pushfstring(L, "unknown family %d", family); return 2; } } /*=========================================================================*\ * Internal functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Passes all resolver information to Lua as a table \*-------------------------------------------------------------------------*/ static void inet_pushresolved(lua_State *L, struct hostent *hp) { char **alias; struct in_addr **addr; int i, resolved; lua_newtable(L); resolved = lua_gettop(L); lua_pushstring(L, "name"); lua_pushstring(L, hp->h_name); lua_settable(L, resolved); lua_pushstring(L, "ip"); lua_pushstring(L, "alias"); i = 1; alias = hp->h_aliases; lua_newtable(L); if (alias) { while (*alias) { lua_pushnumber(L, i); lua_pushstring(L, *alias); lua_settable(L, -3); i++; alias++; } } lua_settable(L, resolved); i = 1; lua_newtable(L); addr = (struct in_addr **) hp->h_addr_list; if (addr) { while (*addr) { lua_pushnumber(L, i); lua_pushstring(L, inet_ntoa(**addr)); lua_settable(L, -3); i++; addr++; } } lua_settable(L, resolved); } /*-------------------------------------------------------------------------*\ * Tries to create a new inet socket \*-------------------------------------------------------------------------*/ const char *inet_trycreate(p_socket ps, int family, int type) { return socket_strerror(socket_create(ps, family, type, 0)); } /*-------------------------------------------------------------------------*\ * "Disconnects" a DGRAM socket \*-------------------------------------------------------------------------*/ const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm) { switch (family) { case PF_INET: { struct sockaddr_in sin; memset((char *) &sin, 0, sizeof(sin)); sin.sin_family = AF_UNSPEC; sin.sin_addr.s_addr = INADDR_ANY; return socket_strerror(socket_connect(ps, (SA *) &sin, sizeof(sin), tm)); } case PF_INET6: { struct sockaddr_in6 sin6; struct in6_addr addrany = IN6ADDR_ANY_INIT; memset((char *) &sin6, 0, sizeof(sin6)); sin6.sin6_family = AF_UNSPEC; fprintf(stderr, "disconnecting\n"); sin6.sin6_addr = addrany; return socket_strerror(socket_connect(ps, (SA *) &sin6, sizeof(sin6), tm)); } } return NULL; } /*-------------------------------------------------------------------------*\ * Tries to connect to remote address (address, port) \*-------------------------------------------------------------------------*/ const char *inet_tryconnect(p_socket ps, const char *address, const char *serv, p_timeout tm, struct addrinfo *connecthints) { struct addrinfo *iterator = NULL, *resolved = NULL; const char *err = NULL; /* try resolving */ err = socket_gaistrerror(getaddrinfo(address, serv, connecthints, &resolved)); if (err != NULL) { if (resolved) freeaddrinfo(resolved); return err; } for (iterator = resolved; iterator; iterator = iterator->ai_next) { timeout_markstart(tm); /* try connecting to remote address */ err = socket_strerror(socket_connect(ps, (SA *) iterator->ai_addr, (socklen_t) iterator->ai_addrlen, tm)); /* if success, break out of loop */ if (err == NULL) break; } freeaddrinfo(resolved); /* here, if err is set, we failed */ return err; } /*-------------------------------------------------------------------------*\ * Tries to accept a socket \*-------------------------------------------------------------------------*/ const char *inet_tryaccept(p_socket server, int family, p_socket client, p_timeout tm) { socklen_t len; t_sockaddr_storage addr; if (family == PF_INET6) { len = sizeof(struct sockaddr_in6); } else { len = sizeof(struct sockaddr_in); } return socket_strerror(socket_accept(server, client, (SA *) &addr, &len, tm)); } /*-------------------------------------------------------------------------*\ * Tries to bind socket to (address, port) \*-------------------------------------------------------------------------*/ const char *inet_trybind(p_socket ps, const char *address, const char *serv, struct addrinfo *bindhints) { struct addrinfo *iterator = NULL, *resolved = NULL; const char *err = NULL; t_socket sock = *ps; /* try resolving */ err = socket_gaistrerror(getaddrinfo(address, serv, bindhints, &resolved)); if (err) { if (resolved) freeaddrinfo(resolved); return err; } /* iterate over resolved addresses until one is good */ for (iterator = resolved; iterator; iterator = iterator->ai_next) { if(sock == SOCKET_INVALID) { err = socket_strerror(socket_create(&sock, iterator->ai_family, iterator->ai_socktype, iterator->ai_protocol)); if(err) continue; } /* try binding to local address */ err = socket_strerror(socket_bind(&sock, (SA *) iterator->ai_addr, (socklen_t) iterator->ai_addrlen)); /* keep trying unless bind succeeded */ if (err) { if(sock != *ps) socket_destroy(&sock); } else { /* remember what we connected to, particularly the family */ *bindhints = *iterator; break; } } /* cleanup and return error */ freeaddrinfo(resolved); *ps = sock; return err; } /*-------------------------------------------------------------------------*\ * Some systems do not provide this so that we provide our own. It's not * marvelously fast, but it works just fine. \*-------------------------------------------------------------------------*/ #ifdef INET_ATON int inet_aton(const char *cp, struct in_addr *inp) { unsigned int a = 0, b = 0, c = 0, d = 0; int n = 0, r; unsigned long int addr = 0; r = sscanf(cp, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n); if (r == 0 || n == 0) return 0; cp += n; if (*cp) return 0; if (a > 255 || b > 255 || c > 255 || d > 255) return 0; if (inp) { addr += a; addr <<= 8; addr += b; addr <<= 8; addr += c; addr <<= 8; addr += d; inp->s_addr = htonl(addr); } return 1; } #endif ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/inet.h ================================================ #ifndef INET_H #define INET_H /*=========================================================================*\ * Internet domain functions * LuaSocket toolkit * * This module implements the creation and connection of internet domain * sockets, on top of the socket.h interface, and the interface of with the * resolver. * * The function inet_aton is provided for the platforms where it is not * available. The module also implements the interface of the internet * getpeername and getsockname functions as seen by Lua programs. * * The Lua functions toip and tohostname are also implemented here. \*=========================================================================*/ #include "lua.h" #include "socket.h" #include "timeout.h" #ifdef _WIN32 #define INET_ATON #endif int inet_open(lua_State *L); const char *inet_trycreate(p_socket ps, int family, int type); const char *inet_tryconnect(p_socket ps, const char *address, const char *serv, p_timeout tm, struct addrinfo *connecthints); const char *inet_trybind(p_socket ps, const char *address, const char *serv, struct addrinfo *bindhints); const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm); const char *inet_tryaccept(p_socket server, int family, p_socket client, p_timeout tm); int inet_meth_getpeername(lua_State *L, p_socket ps, int family); int inet_meth_getsockname(lua_State *L, p_socket ps, int family); int inet_optfamily(lua_State* L, int narg, const char* def); int inet_optsocktype(lua_State* L, int narg, const char* def); #ifdef INET_ATON int inet_aton(const char *cp, struct in_addr *inp); #endif #ifndef _WINDOWS_ #define my_inet_ntop(a,b,c,d) inet_ntop(a,b,c,d) #define my_inet_pton(a,b,c) inet_pton(a,b,c) #else int win32xp_inet_pton(int family, const char* string, PVOID dest); char* win32xp_inet_ntop(int family, PVOID src, char* dest, size_t length); #define my_inet_ntop(a,b,c,d) win32xp_inet_ntop(a,b,c,d) #define my_inet_pton(a,b,c) win32xp_inet_pton(a,b,c) #endif #endif /* INET_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/luasocket.c ================================================ /*=========================================================================*\ * LuaSocket toolkit * Networking support for the Lua language * Diego Nehab * 26/11/1999 * * This library is part of an effort to progressively increase the network * connectivity of the Lua language. The Lua interface to networking * functions follows the Sockets API closely, trying to simplify all tasks * involved in setting up both client and server connections. The provided * IO routines, however, follow the Lua style, being very similar to the * standard Lua read and write functions. \*=========================================================================*/ /*=========================================================================*\ * Standard include files \*=========================================================================*/ #include "lua.h" #include "lauxlib.h" #if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501) #include "compat-5.1.h" #endif /*=========================================================================*\ * LuaSocket includes \*=========================================================================*/ #include "luasocket.h" #include "auxiliar.h" #include "except.h" #include "timeout.h" #include "luasocket_buffer.h" #include "inet.h" #include "tcp.h" #include "udp.h" #include "select.h" /*-------------------------------------------------------------------------*\ * Internal function prototypes \*-------------------------------------------------------------------------*/ static int global_skip(lua_State *L); static int global_unload(lua_State *L); static int base_open(lua_State *L); /*-------------------------------------------------------------------------*\ * Modules and functions \*-------------------------------------------------------------------------*/ static const luaL_Reg mod[] = { {"auxiliar", auxiliar_open}, {"except", except_open}, {"timeout", timeout_open}, {"buffer", buffer_open}, {"inet", inet_open}, {"tcp", tcp_open}, {"udp", udp_open}, {"select", select_open}, {NULL, NULL} }; static luaL_Reg func[] = { {"skip", global_skip}, {"__unload", global_unload}, {NULL, NULL} }; /*-------------------------------------------------------------------------*\ * Skip a few arguments \*-------------------------------------------------------------------------*/ static int global_skip(lua_State *L) { int amount = luaL_checkint(L, 1); int ret = lua_gettop(L) - amount - 1; return ret >= 0 ? ret : 0; } /*-------------------------------------------------------------------------*\ * Unloads the library \*-------------------------------------------------------------------------*/ static int global_unload(lua_State *L) { (void) L; socket_close(); return 0; } /*-------------------------------------------------------------------------*\ * Setup basic stuff. \*-------------------------------------------------------------------------*/ static int base_open(lua_State *L) { if (socket_open()) { /* export functions (and leave namespace table on top of stack) */ luaL_openlib(L, "socket", func, 0); #ifdef LUASOCKET_DEBUG lua_pushstring(L, "_DEBUG"); lua_pushboolean(L, 1); lua_rawset(L, -3); #endif /* make version string available to scripts */ lua_pushstring(L, "_VERSION"); lua_pushstring(L, LUASOCKET_VERSION); lua_rawset(L, -3); return 1; } else { lua_pushstring(L, "unable to initialize library"); lua_error(L); return 0; } } /*-------------------------------------------------------------------------*\ * Initializes all library modules. \*-------------------------------------------------------------------------*/ LUASOCKET_API int luaopen_socket_core(lua_State *L) { int i; base_open(L); for (i = 0; mod[i].name; i++) mod[i].func(L); return 1; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/luasocket.h ================================================ #ifndef LUASOCKET_H #define LUASOCKET_H /*=========================================================================*\ * LuaSocket toolkit * Networking support for the Lua language * Diego Nehab * 9/11/1999 \*=========================================================================*/ #include "lua.h" /*-------------------------------------------------------------------------*\ * Current socket library version \*-------------------------------------------------------------------------*/ #define LUASOCKET_VERSION "LuaSocket 2.1-rc1" #define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2012 Diego Nehab" #define LUASOCKET_AUTHORS "Diego Nehab" /*-------------------------------------------------------------------------*\ * This macro prefixes all exported API functions \*-------------------------------------------------------------------------*/ #ifndef LUASOCKET_API #define LUASOCKET_API extern #endif #if LUA_VERSION_NUM > 501 & !( defined LUA_COMPAT_MODULE) # error Lua 5.2 requires LUA_COMPAT_MODULE defined for luaL_openlib #endif /*-------------------------------------------------------------------------*\ * Initializes the library. \*-------------------------------------------------------------------------*/ LUASOCKET_API int luaopen_socket_core(lua_State *L); #endif /* LUASOCKET_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/luasocket_buffer.c ================================================ /*=========================================================================*\ * Input/Output interface for Lua programs * LuaSocket toolkit \*=========================================================================*/ #include "lua.h" #include "lauxlib.h" #include "luasocket_buffer.h" /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ static int recvraw(p_buffer buf, size_t wanted, luaL_Buffer *b); static int recvline(p_buffer buf, luaL_Buffer *b); static int recvall(p_buffer buf, luaL_Buffer *b); static int buffer_get(p_buffer buf, const char **data, size_t *count); static void buffer_skip(p_buffer buf, size_t count); static int sendraw(p_buffer buf, const char *data, size_t count, size_t *sent); /* min and max macros */ #ifndef MIN #define MIN(x, y) ((x) < (y) ? x : y) #endif #ifndef MAX #define MAX(x, y) ((x) > (y) ? x : y) #endif /*=========================================================================*\ * Exported functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int buffer_open(lua_State *L) { (void) L; return 0; } /*-------------------------------------------------------------------------*\ * Initializes C structure \*-------------------------------------------------------------------------*/ void buffer_init(p_buffer buf, p_io io, p_timeout tm) { buf->first = buf->last = 0; buf->io = io; buf->tm = tm; buf->received = buf->sent = 0; buf->birthday = timeout_gettime(); } /*-------------------------------------------------------------------------*\ * object:getstats() interface \*-------------------------------------------------------------------------*/ int buffer_meth_getstats(lua_State *L, p_buffer buf) { lua_pushnumber(L, (lua_Number) buf->received); lua_pushnumber(L, (lua_Number) buf->sent); lua_pushnumber(L, timeout_gettime() - buf->birthday); return 3; } /*-------------------------------------------------------------------------*\ * object:setstats() interface \*-------------------------------------------------------------------------*/ int buffer_meth_setstats(lua_State *L, p_buffer buf) { buf->received = (long) luaL_optnumber(L, 2, (lua_Number) buf->received); buf->sent = (long) luaL_optnumber(L, 3, (lua_Number) buf->sent); if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * object:send() interface \*-------------------------------------------------------------------------*/ int buffer_meth_send(lua_State *L, p_buffer buf) { int top = lua_gettop(L); int err = IO_DONE; size_t size = 0, sent = 0; const char *data = luaL_checklstring(L, 2, &size); long start = (long) luaL_optnumber(L, 3, 1); long end = (long) luaL_optnumber(L, 4, -1); #ifdef LUASOCKET_DEBUG p_timeout tm = timeout_markstart(buf->tm); #endif if (start < 0) start = (long) (size+start+1); if (end < 0) end = (long) (size+end+1); if (start < 1) start = (long) 1; if (end > (long) size) end = (long) size; if (start <= end) err = sendraw(buf, data+start-1, end-start+1, &sent); /* check if there was an error */ if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, buf->io->error(buf->io->ctx, err)); lua_pushnumber(L, (lua_Number) (sent+start-1)); } else { lua_pushnumber(L, (lua_Number) (sent+start-1)); lua_pushnil(L); lua_pushnil(L); } #ifdef LUASOCKET_DEBUG /* push time elapsed during operation as the last return value */ lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm)); #endif return lua_gettop(L) - top; } /*-------------------------------------------------------------------------*\ * object:receive() interface \*-------------------------------------------------------------------------*/ int buffer_meth_receive(lua_State *L, p_buffer buf) { int err = IO_DONE, top = lua_gettop(L); luaL_Buffer b; size_t size; const char *part = luaL_optlstring(L, 3, "", &size); #ifdef LUASOCKET_DEBUG p_timeout tm = timeout_markstart(buf->tm); #endif /* initialize buffer with optional extra prefix * (useful for concatenating previous partial results) */ luaL_buffinit(L, &b); luaL_addlstring(&b, part, size); /* receive new patterns */ if (!lua_isnumber(L, 2)) { const char *p= luaL_optstring(L, 2, "*l"); if (p[0] == '*' && p[1] == 'l') err = recvline(buf, &b); else if (p[0] == '*' && p[1] == 'a') err = recvall(buf, &b); else luaL_argcheck(L, 0, 2, "invalid receive pattern"); /* get a fixed number of bytes (minus what was already partially * received) */ } else { double n = lua_tonumber(L, 2); size_t wanted = (size_t) n; luaL_argcheck(L, n >= 0, 2, "invalid receive pattern"); if (size == 0 || wanted > size) err = recvraw(buf, wanted-size, &b); } /* check if there was an error */ if (err != IO_DONE) { /* we can't push anyting in the stack before pushing the * contents of the buffer. this is the reason for the complication */ luaL_pushresult(&b); lua_pushstring(L, buf->io->error(buf->io->ctx, err)); lua_pushvalue(L, -2); lua_pushnil(L); lua_replace(L, -4); } else { luaL_pushresult(&b); lua_pushnil(L); lua_pushnil(L); } #ifdef LUASOCKET_DEBUG /* push time elapsed during operation as the last return value */ lua_pushnumber(L, timeout_gettime() - timeout_getstart(tm)); #endif return lua_gettop(L) - top; } /*-------------------------------------------------------------------------*\ * Determines if there is any data in the read buffer \*-------------------------------------------------------------------------*/ int buffer_isempty(p_buffer buf) { return buf->first >= buf->last; } /*=========================================================================*\ * Internal functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Sends a block of data (unbuffered) \*-------------------------------------------------------------------------*/ #define STEPSIZE 8192 static int sendraw(p_buffer buf, const char *data, size_t count, size_t *sent) { p_io io = buf->io; p_timeout tm = buf->tm; size_t total = 0; int err = IO_DONE; while (total < count && err == IO_DONE) { size_t done = 0; size_t step = (count-total <= STEPSIZE)? count-total: STEPSIZE; err = io->send(io->ctx, data+total, step, &done, tm); total += done; } *sent = total; buf->sent += total; return err; } /*-------------------------------------------------------------------------*\ * Reads a fixed number of bytes (buffered) \*-------------------------------------------------------------------------*/ static int recvraw(p_buffer buf, size_t wanted, luaL_Buffer *b) { int err = IO_DONE; size_t total = 0; while (err == IO_DONE) { size_t count; const char *data; err = buffer_get(buf, &data, &count); count = MIN(count, wanted - total); luaL_addlstring(b, data, count); buffer_skip(buf, count); total += count; if (total >= wanted) break; } return err; } /*-------------------------------------------------------------------------*\ * Reads everything until the connection is closed (buffered) \*-------------------------------------------------------------------------*/ static int recvall(p_buffer buf, luaL_Buffer *b) { int err = IO_DONE; size_t total = 0; while (err == IO_DONE) { const char *data; size_t count; err = buffer_get(buf, &data, &count); total += count; luaL_addlstring(b, data, count); buffer_skip(buf, count); } if (err == IO_CLOSED) { if (total > 0) return IO_DONE; else return IO_CLOSED; } else return err; } /*-------------------------------------------------------------------------*\ * Reads a line terminated by a CR LF pair or just by a LF. The CR and LF * are not returned by the function and are discarded from the buffer \*-------------------------------------------------------------------------*/ static int recvline(p_buffer buf, luaL_Buffer *b) { int err = IO_DONE; while (err == IO_DONE) { size_t count, pos; const char *data; err = buffer_get(buf, &data, &count); pos = 0; while (pos < count && data[pos] != '\n') { /* we ignore all \r's */ if (data[pos] != '\r') luaL_addchar(b, data[pos]); pos++; } if (pos < count) { /* found '\n' */ buffer_skip(buf, pos+1); /* skip '\n' too */ break; /* we are done */ } else /* reached the end of the buffer */ buffer_skip(buf, pos); } return err; } /*-------------------------------------------------------------------------*\ * Skips a given number of bytes from read buffer. No data is read from the * transport layer \*-------------------------------------------------------------------------*/ static void buffer_skip(p_buffer buf, size_t count) { buf->received += count; buf->first += count; if (buffer_isempty(buf)) buf->first = buf->last = 0; } /*-------------------------------------------------------------------------*\ * Return any data available in buffer, or get more data from transport layer * if buffer is empty \*-------------------------------------------------------------------------*/ static int buffer_get(p_buffer buf, const char **data, size_t *count) { int err = IO_DONE; p_io io = buf->io; p_timeout tm = buf->tm; if (buffer_isempty(buf)) { size_t got; err = io->recv(io->ctx, buf->data, BUF_SIZE, &got, tm); buf->first = 0; buf->last = got; } *count = buf->last - buf->first; *data = buf->data + buf->first; return err; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/luasocket_buffer.h ================================================ #ifndef BUF_H #define BUF_H /*=========================================================================*\ * Input/Output interface for Lua programs * LuaSocket toolkit * * Line patterns require buffering. Reading one character at a time involves * too many system calls and is very slow. This module implements the * LuaSocket interface for input/output on connected objects, as seen by * Lua programs. * * Input is buffered. Output is *not* buffered because there was no simple * way of making sure the buffered output data would ever be sent. * * The module is built on top of the I/O abstraction defined in io.h and the * timeout management is done with the timeout.h interface. \*=========================================================================*/ #include "lua.h" #include "luasocket_io.h" #include "timeout.h" /* buffer size in bytes */ #define BUF_SIZE 8192 /* buffer control structure */ typedef struct t_buffer_ { double birthday; /* throttle support info: creation time, */ size_t sent, received; /* bytes sent, and bytes received */ p_io io; /* IO driver used for this buffer */ p_timeout tm; /* timeout management for this buffer */ size_t first, last; /* index of first and last bytes of stored data */ char data[BUF_SIZE]; /* storage space for buffer data */ } t_buffer; typedef t_buffer *p_buffer; int buffer_open(lua_State *L); void buffer_init(p_buffer buf, p_io io, p_timeout tm); int buffer_meth_send(lua_State *L, p_buffer buf); int buffer_meth_receive(lua_State *L, p_buffer buf); int buffer_meth_getstats(lua_State *L, p_buffer buf); int buffer_meth_setstats(lua_State *L, p_buffer buf); int buffer_isempty(p_buffer buf); #endif /* BUF_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/luasocket_io.c ================================================ /*=========================================================================*\ * Input/Output abstraction * LuaSocket toolkit \*=========================================================================*/ #include "luasocket_io.h" /*=========================================================================*\ * Exported functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Initializes C structure \*-------------------------------------------------------------------------*/ void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) { io->send = send; io->recv = recv; io->error = error; io->ctx = ctx; } /*-------------------------------------------------------------------------*\ * I/O error strings \*-------------------------------------------------------------------------*/ const char *io_strerror(int err) { switch (err) { case IO_DONE: return NULL; case IO_CLOSED: return "closed"; case IO_TIMEOUT: return "timeout"; default: return "unknown error"; } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/luasocket_io.h ================================================ #ifndef IO_H #define IO_H /*=========================================================================*\ * Input/Output abstraction * LuaSocket toolkit * * This module defines the interface that LuaSocket expects from the * transport layer for streamed input/output. The idea is that if any * transport implements this interface, then the buffer.c functions * automatically work on it. * * The module socket.h implements this interface, and thus the module tcp.h * is very simple. \*=========================================================================*/ #include #include "lua.h" #include "timeout.h" /* IO error codes */ enum { IO_DONE = 0, /* operation completed successfully */ IO_TIMEOUT = -1, /* operation timed out */ IO_CLOSED = -2, /* the connection has been closed */ IO_UNKNOWN = -3 }; /* interface to error message function */ typedef const char *(*p_error) ( void *ctx, /* context needed by send */ int err /* error code */ ); /* interface to send function */ typedef int (*p_send) ( void *ctx, /* context needed by send */ const char *data, /* pointer to buffer with data to send */ size_t count, /* number of bytes to send from buffer */ size_t *sent, /* number of bytes sent uppon return */ p_timeout tm /* timeout control */ ); /* interface to recv function */ typedef int (*p_recv) ( void *ctx, /* context needed by recv */ char *data, /* pointer to buffer where data will be writen */ size_t count, /* number of bytes to receive into buffer */ size_t *got, /* number of bytes received uppon return */ p_timeout tm /* timeout control */ ); /* IO driver definition */ typedef struct t_io_ { void *ctx; /* context needed by send/recv */ p_send send; /* send function pointer */ p_recv recv; /* receive function pointer */ p_error error; /* strerror function */ } t_io; typedef t_io *p_io; void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx); const char *io_strerror(int err); #endif /* IO_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/mime.c ================================================ /*=========================================================================*\ * MIME support functions * LuaSocket toolkit \*=========================================================================*/ #include #include "lua.h" #include "lauxlib.h" #if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501) #include "compat-5.1.h" #endif #include "mime.h" /*=========================================================================*\ * Don't want to trust escape character constants \*=========================================================================*/ typedef unsigned char UC; static const char CRLF[] = "\r\n"; static const char EQCRLF[] = "=\r\n"; /*=========================================================================*\ * Internal function prototypes. \*=========================================================================*/ static int mime_global_wrp(lua_State *L); static int mime_global_b64(lua_State *L); static int mime_global_unb64(lua_State *L); static int mime_global_qp(lua_State *L); static int mime_global_unqp(lua_State *L); static int mime_global_qpwrp(lua_State *L); static int mime_global_eol(lua_State *L); static int mime_global_dot(lua_State *L); static size_t dot(int c, size_t state, luaL_Buffer *buffer); static void b64setup(UC *base); static size_t b64encode(UC c, UC *input, size_t size, luaL_Buffer *buffer); static size_t b64pad(const UC *input, size_t size, luaL_Buffer *buffer); static size_t b64decode(UC c, UC *input, size_t size, luaL_Buffer *buffer); static void qpsetup(UC *class, UC *unbase); static void qpquote(UC c, luaL_Buffer *buffer); static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer); static size_t qpencode(UC c, UC *input, size_t size, const char *marker, luaL_Buffer *buffer); static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer); /* code support functions */ static luaL_Reg func[] = { { "dot", mime_global_dot }, { "b64", mime_global_b64 }, { "eol", mime_global_eol }, { "qp", mime_global_qp }, { "qpwrp", mime_global_qpwrp }, { "unb64", mime_global_unb64 }, { "unqp", mime_global_unqp }, { "wrp", mime_global_wrp }, { NULL, NULL } }; /*-------------------------------------------------------------------------*\ * Quoted-printable globals \*-------------------------------------------------------------------------*/ static UC qpclass[256]; static UC qpbase[] = "0123456789ABCDEF"; static UC qpunbase[256]; enum {QP_PLAIN, QP_QUOTED, QP_CR, QP_IF_LAST}; /*-------------------------------------------------------------------------*\ * Base64 globals \*-------------------------------------------------------------------------*/ static const UC b64base[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static UC b64unbase[256]; /*=========================================================================*\ * Exported functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ MIME_API int luaopen_mime_core(lua_State *L) { luaL_openlib(L, "mime", func, 0); /* make version string available to scripts */ lua_pushstring(L, "_VERSION"); lua_pushstring(L, MIME_VERSION); lua_rawset(L, -3); /* initialize lookup tables */ qpsetup(qpclass, qpunbase); b64setup(b64unbase); return 1; } /*=========================================================================*\ * Global Lua functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Incrementaly breaks a string into lines. The string can have CRLF breaks. * A, n = wrp(l, B, length) * A is a copy of B, broken into lines of at most 'length' bytes. * 'l' is how many bytes are left for the first line of B. * 'n' is the number of bytes left in the last line of A. \*-------------------------------------------------------------------------*/ static int mime_global_wrp(lua_State *L) { size_t size = 0; int left = (int) luaL_checknumber(L, 1); const UC *input = (UC *) luaL_optlstring(L, 2, NULL, &size); const UC *last = input + size; int length = (int) luaL_optnumber(L, 3, 76); luaL_Buffer buffer; /* end of input black-hole */ if (!input) { /* if last line has not been terminated, add a line break */ if (left < length) lua_pushstring(L, CRLF); /* otherwise, we are done */ else lua_pushnil(L); lua_pushnumber(L, length); return 2; } luaL_buffinit(L, &buffer); while (input < last) { switch (*input) { case '\r': break; case '\n': luaL_addstring(&buffer, CRLF); left = length; break; default: if (left <= 0) { left = length; luaL_addstring(&buffer, CRLF); } luaL_addchar(&buffer, *input); left--; break; } input++; } luaL_pushresult(&buffer); lua_pushnumber(L, left); return 2; } /*-------------------------------------------------------------------------*\ * Fill base64 decode map. \*-------------------------------------------------------------------------*/ static void b64setup(UC *unbase) { int i; for (i = 0; i <= 255; i++) unbase[i] = (UC) 255; for (i = 0; i < 64; i++) unbase[b64base[i]] = (UC) i; unbase['='] = 0; } /*-------------------------------------------------------------------------*\ * Acumulates bytes in input buffer until 3 bytes are available. * Translate the 3 bytes into Base64 form and append to buffer. * Returns new number of bytes in buffer. \*-------------------------------------------------------------------------*/ static size_t b64encode(UC c, UC *input, size_t size, luaL_Buffer *buffer) { input[size++] = c; if (size == 3) { UC code[4]; unsigned long value = 0; value += input[0]; value <<= 8; value += input[1]; value <<= 8; value += input[2]; code[3] = b64base[value & 0x3f]; value >>= 6; code[2] = b64base[value & 0x3f]; value >>= 6; code[1] = b64base[value & 0x3f]; value >>= 6; code[0] = b64base[value]; luaL_addlstring(buffer, (char *) code, 4); size = 0; } return size; } /*-------------------------------------------------------------------------*\ * Encodes the Base64 last 1 or 2 bytes and adds padding '=' * Result, if any, is appended to buffer. * Returns 0. \*-------------------------------------------------------------------------*/ static size_t b64pad(const UC *input, size_t size, luaL_Buffer *buffer) { unsigned long value = 0; UC code[4] = {'=', '=', '=', '='}; switch (size) { case 1: value = input[0] << 4; code[1] = b64base[value & 0x3f]; value >>= 6; code[0] = b64base[value]; luaL_addlstring(buffer, (char *) code, 4); break; case 2: value = input[0]; value <<= 8; value |= input[1]; value <<= 2; code[2] = b64base[value & 0x3f]; value >>= 6; code[1] = b64base[value & 0x3f]; value >>= 6; code[0] = b64base[value]; luaL_addlstring(buffer, (char *) code, 4); break; default: break; } return 0; } /*-------------------------------------------------------------------------*\ * Acumulates bytes in input buffer until 4 bytes are available. * Translate the 4 bytes from Base64 form and append to buffer. * Returns new number of bytes in buffer. \*-------------------------------------------------------------------------*/ static size_t b64decode(UC c, UC *input, size_t size, luaL_Buffer *buffer) { /* ignore invalid characters */ if (b64unbase[c] > 64) return size; input[size++] = c; /* decode atom */ if (size == 4) { UC decoded[3]; int valid, value = 0; value = b64unbase[input[0]]; value <<= 6; value |= b64unbase[input[1]]; value <<= 6; value |= b64unbase[input[2]]; value <<= 6; value |= b64unbase[input[3]]; decoded[2] = (UC) (value & 0xff); value >>= 8; decoded[1] = (UC) (value & 0xff); value >>= 8; decoded[0] = (UC) value; /* take care of paddding */ valid = (input[2] == '=') ? 1 : (input[3] == '=') ? 2 : 3; luaL_addlstring(buffer, (char *) decoded, valid); return 0; /* need more data */ } else return size; } /*-------------------------------------------------------------------------*\ * Incrementally applies the Base64 transfer content encoding to a string * A, B = b64(C, D) * A is the encoded version of the largest prefix of C .. D that is * divisible by 3. B has the remaining bytes of C .. D, *without* encoding. * The easiest thing would be to concatenate the two strings and * encode the result, but we can't afford that or Lua would dupplicate * every chunk we received. \*-------------------------------------------------------------------------*/ static int mime_global_b64(lua_State *L) { UC atom[3]; size_t isize = 0, asize = 0; const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); const UC *last = input + isize; luaL_Buffer buffer; /* end-of-input blackhole */ if (!input) { lua_pushnil(L); lua_pushnil(L); return 2; } /* make sure we don't confuse buffer stuff with arguments */ lua_settop(L, 2); /* process first part of the input */ luaL_buffinit(L, &buffer); while (input < last) asize = b64encode(*input++, atom, asize, &buffer); input = (UC *) luaL_optlstring(L, 2, NULL, &isize); /* if second part is nil, we are done */ if (!input) { size_t osize = 0; asize = b64pad(atom, asize, &buffer); luaL_pushresult(&buffer); /* if the output is empty and the input is nil, return nil */ lua_tolstring(L, -1, &osize); if (osize == 0) lua_pushnil(L); lua_pushnil(L); return 2; } /* otherwise process the second part */ last = input + isize; while (input < last) asize = b64encode(*input++, atom, asize, &buffer); luaL_pushresult(&buffer); lua_pushlstring(L, (char *) atom, asize); return 2; } /*-------------------------------------------------------------------------*\ * Incrementally removes the Base64 transfer content encoding from a string * A, B = b64(C, D) * A is the encoded version of the largest prefix of C .. D that is * divisible by 4. B has the remaining bytes of C .. D, *without* encoding. \*-------------------------------------------------------------------------*/ static int mime_global_unb64(lua_State *L) { UC atom[4]; size_t isize = 0, asize = 0; const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); const UC *last = input + isize; luaL_Buffer buffer; /* end-of-input blackhole */ if (!input) { lua_pushnil(L); lua_pushnil(L); return 2; } /* make sure we don't confuse buffer stuff with arguments */ lua_settop(L, 2); /* process first part of the input */ luaL_buffinit(L, &buffer); while (input < last) asize = b64decode(*input++, atom, asize, &buffer); input = (UC *) luaL_optlstring(L, 2, NULL, &isize); /* if second is nil, we are done */ if (!input) { size_t osize = 0; luaL_pushresult(&buffer); /* if the output is empty and the input is nil, return nil */ lua_tolstring(L, -1, &osize); if (osize == 0) lua_pushnil(L); lua_pushnil(L); return 2; } /* otherwise, process the rest of the input */ last = input + isize; while (input < last) asize = b64decode(*input++, atom, asize, &buffer); luaL_pushresult(&buffer); lua_pushlstring(L, (char *) atom, asize); return 2; } /*-------------------------------------------------------------------------*\ * Quoted-printable encoding scheme * all (except CRLF in text) can be =XX * CLRL in not text must be =XX=XX * 33 through 60 inclusive can be plain * 62 through 126 inclusive can be plain * 9 and 32 can be plain, unless in the end of a line, where must be =XX * encoded lines must be no longer than 76 not counting CRLF * soft line-break are =CRLF * To encode one byte, we need to see the next two. * Worst case is when we see a space, and wonder if a CRLF is comming \*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*\ * Split quoted-printable characters into classes * Precompute reverse map for encoding \*-------------------------------------------------------------------------*/ static void qpsetup(UC *cl, UC *unbase) { int i; for (i = 0; i < 256; i++) cl[i] = QP_QUOTED; for (i = 33; i <= 60; i++) cl[i] = QP_PLAIN; for (i = 62; i <= 126; i++) cl[i] = QP_PLAIN; cl['\t'] = QP_IF_LAST; cl[' '] = QP_IF_LAST; cl['\r'] = QP_CR; for (i = 0; i < 256; i++) unbase[i] = 255; unbase['0'] = 0; unbase['1'] = 1; unbase['2'] = 2; unbase['3'] = 3; unbase['4'] = 4; unbase['5'] = 5; unbase['6'] = 6; unbase['7'] = 7; unbase['8'] = 8; unbase['9'] = 9; unbase['A'] = 10; unbase['a'] = 10; unbase['B'] = 11; unbase['b'] = 11; unbase['C'] = 12; unbase['c'] = 12; unbase['D'] = 13; unbase['d'] = 13; unbase['E'] = 14; unbase['e'] = 14; unbase['F'] = 15; unbase['f'] = 15; } /*-------------------------------------------------------------------------*\ * Output one character in form =XX \*-------------------------------------------------------------------------*/ static void qpquote(UC c, luaL_Buffer *buffer) { luaL_addchar(buffer, '='); luaL_addchar(buffer, qpbase[c >> 4]); luaL_addchar(buffer, qpbase[c & 0x0F]); } /*-------------------------------------------------------------------------*\ * Accumulate characters until we are sure about how to deal with them. * Once we are sure, output to the buffer, in the correct form. \*-------------------------------------------------------------------------*/ static size_t qpencode(UC c, UC *input, size_t size, const char *marker, luaL_Buffer *buffer) { input[size++] = c; /* deal with all characters we can have */ while (size > 0) { switch (qpclass[input[0]]) { /* might be the CR of a CRLF sequence */ case QP_CR: if (size < 2) return size; if (input[1] == '\n') { luaL_addstring(buffer, marker); return 0; } else qpquote(input[0], buffer); break; /* might be a space and that has to be quoted if last in line */ case QP_IF_LAST: if (size < 3) return size; /* if it is the last, quote it and we are done */ if (input[1] == '\r' && input[2] == '\n') { qpquote(input[0], buffer); luaL_addstring(buffer, marker); return 0; } else luaL_addchar(buffer, input[0]); break; /* might have to be quoted always */ case QP_QUOTED: qpquote(input[0], buffer); break; /* might never have to be quoted */ default: luaL_addchar(buffer, input[0]); break; } input[0] = input[1]; input[1] = input[2]; size--; } return 0; } /*-------------------------------------------------------------------------*\ * Deal with the final characters \*-------------------------------------------------------------------------*/ static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer) { size_t i; for (i = 0; i < size; i++) { if (qpclass[input[i]] == QP_PLAIN) luaL_addchar(buffer, input[i]); else qpquote(input[i], buffer); } if (size > 0) luaL_addstring(buffer, EQCRLF); return 0; } /*-------------------------------------------------------------------------*\ * Incrementally converts a string to quoted-printable * A, B = qp(C, D, marker) * Marker is the text to be used to replace CRLF sequences found in A. * A is the encoded version of the largest prefix of C .. D that * can be encoded without doubts. * B has the remaining bytes of C .. D, *without* encoding. \*-------------------------------------------------------------------------*/ static int mime_global_qp(lua_State *L) { size_t asize = 0, isize = 0; UC atom[3]; const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); const UC *last = input + isize; const char *marker = luaL_optstring(L, 3, CRLF); luaL_Buffer buffer; /* end-of-input blackhole */ if (!input) { lua_pushnil(L); lua_pushnil(L); return 2; } /* make sure we don't confuse buffer stuff with arguments */ lua_settop(L, 3); /* process first part of input */ luaL_buffinit(L, &buffer); while (input < last) asize = qpencode(*input++, atom, asize, marker, &buffer); input = (UC *) luaL_optlstring(L, 2, NULL, &isize); /* if second part is nil, we are done */ if (!input) { asize = qppad(atom, asize, &buffer); luaL_pushresult(&buffer); if (!(*lua_tostring(L, -1))) lua_pushnil(L); lua_pushnil(L); return 2; } /* otherwise process rest of input */ last = input + isize; while (input < last) asize = qpencode(*input++, atom, asize, marker, &buffer); luaL_pushresult(&buffer); lua_pushlstring(L, (char *) atom, asize); return 2; } /*-------------------------------------------------------------------------*\ * Accumulate characters until we are sure about how to deal with them. * Once we are sure, output the to the buffer, in the correct form. \*-------------------------------------------------------------------------*/ static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) { int d; input[size++] = c; /* deal with all characters we can deal */ switch (input[0]) { /* if we have an escape character */ case '=': if (size < 3) return size; /* eliminate soft line break */ if (input[1] == '\r' && input[2] == '\n') return 0; /* decode quoted representation */ c = qpunbase[input[1]]; d = qpunbase[input[2]]; /* if it is an invalid, do not decode */ if (c > 15 || d > 15) luaL_addlstring(buffer, (char *)input, 3); else luaL_addchar(buffer, (char) ((c << 4) + d)); return 0; case '\r': if (size < 2) return size; if (input[1] == '\n') luaL_addlstring(buffer, (char *)input, 2); return 0; default: if (input[0] == '\t' || (input[0] > 31 && input[0] < 127)) luaL_addchar(buffer, input[0]); return 0; } } /*-------------------------------------------------------------------------*\ * Incrementally decodes a string in quoted-printable * A, B = qp(C, D) * A is the decoded version of the largest prefix of C .. D that * can be decoded without doubts. * B has the remaining bytes of C .. D, *without* decoding. \*-------------------------------------------------------------------------*/ static int mime_global_unqp(lua_State *L) { size_t asize = 0, isize = 0; UC atom[3]; const UC *input = (UC *) luaL_optlstring(L, 1, NULL, &isize); const UC *last = input + isize; luaL_Buffer buffer; /* end-of-input blackhole */ if (!input) { lua_pushnil(L); lua_pushnil(L); return 2; } /* make sure we don't confuse buffer stuff with arguments */ lua_settop(L, 2); /* process first part of input */ luaL_buffinit(L, &buffer); while (input < last) asize = qpdecode(*input++, atom, asize, &buffer); input = (UC *) luaL_optlstring(L, 2, NULL, &isize); /* if second part is nil, we are done */ if (!input) { luaL_pushresult(&buffer); if (!(*lua_tostring(L, -1))) lua_pushnil(L); lua_pushnil(L); return 2; } /* otherwise process rest of input */ last = input + isize; while (input < last) asize = qpdecode(*input++, atom, asize, &buffer); luaL_pushresult(&buffer); lua_pushlstring(L, (char *) atom, asize); return 2; } /*-------------------------------------------------------------------------*\ * Incrementally breaks a quoted-printed string into lines * A, n = qpwrp(l, B, length) * A is a copy of B, broken into lines of at most 'length' bytes. * 'l' is how many bytes are left for the first line of B. * 'n' is the number of bytes left in the last line of A. * There are two complications: lines can't be broken in the middle * of an encoded =XX, and there might be line breaks already \*-------------------------------------------------------------------------*/ static int mime_global_qpwrp(lua_State *L) { size_t size = 0; int left = (int) luaL_checknumber(L, 1); const UC *input = (UC *) luaL_optlstring(L, 2, NULL, &size); const UC *last = input + size; int length = (int) luaL_optnumber(L, 3, 76); luaL_Buffer buffer; /* end-of-input blackhole */ if (!input) { if (left < length) lua_pushstring(L, EQCRLF); else lua_pushnil(L); lua_pushnumber(L, length); return 2; } /* process all input */ luaL_buffinit(L, &buffer); while (input < last) { switch (*input) { case '\r': break; case '\n': left = length; luaL_addstring(&buffer, CRLF); break; case '=': if (left <= 3) { left = length; luaL_addstring(&buffer, EQCRLF); } luaL_addchar(&buffer, *input); left--; break; default: if (left <= 1) { left = length; luaL_addstring(&buffer, EQCRLF); } luaL_addchar(&buffer, *input); left--; break; } input++; } luaL_pushresult(&buffer); lua_pushnumber(L, left); return 2; } /*-------------------------------------------------------------------------*\ * Here is what we do: \n, and \r are considered candidates for line * break. We issue *one* new line marker if any of them is seen alone, or * followed by a different one. That is, \n\n and \r\r will issue two * end of line markers each, but \r\n, \n\r etc will only issue *one* * marker. This covers Mac OS, Mac OS X, VMS, Unix and DOS, as well as * probably other more obscure conventions. * * c is the current character being processed * last is the previous character \*-------------------------------------------------------------------------*/ #define eolcandidate(c) (c == '\r' || c == '\n') static int eolprocess(int c, int last, const char *marker, luaL_Buffer *buffer) { if (eolcandidate(c)) { if (eolcandidate(last)) { if (c == last) luaL_addstring(buffer, marker); return 0; } else { luaL_addstring(buffer, marker); return c; } } else { luaL_addchar(buffer, (char) c); return 0; } } /*-------------------------------------------------------------------------*\ * Converts a string to uniform EOL convention. * A, n = eol(o, B, marker) * A is the converted version of the largest prefix of B that can be * converted unambiguously. 'o' is the context returned by the previous * call. 'n' is the new context. \*-------------------------------------------------------------------------*/ static int mime_global_eol(lua_State *L) { int ctx = luaL_checkint(L, 1); size_t isize = 0; const char *input = luaL_optlstring(L, 2, NULL, &isize); const char *last = input + isize; const char *marker = luaL_optstring(L, 3, CRLF); luaL_Buffer buffer; luaL_buffinit(L, &buffer); /* end of input blackhole */ if (!input) { lua_pushnil(L); lua_pushnumber(L, 0); return 2; } /* process all input */ while (input < last) ctx = eolprocess(*input++, ctx, marker, &buffer); luaL_pushresult(&buffer); lua_pushnumber(L, ctx); return 2; } /*-------------------------------------------------------------------------*\ * Takes one byte and stuff it if needed. \*-------------------------------------------------------------------------*/ static size_t dot(int c, size_t state, luaL_Buffer *buffer) { luaL_addchar(buffer, (char) c); switch (c) { case '\r': return 1; case '\n': return (state == 1)? 2: 0; case '.': if (state == 2) luaL_addchar(buffer, '.'); default: return 0; } } /*-------------------------------------------------------------------------*\ * Incrementally applies smtp stuffing to a string * A, n = dot(l, D) \*-------------------------------------------------------------------------*/ static int mime_global_dot(lua_State *L) { size_t isize = 0, state = (size_t) luaL_checknumber(L, 1); const char *input = luaL_optlstring(L, 2, NULL, &isize); const char *last = input + isize; luaL_Buffer buffer; /* end-of-input blackhole */ if (!input) { lua_pushnil(L); lua_pushnumber(L, 2); return 2; } /* process all input */ luaL_buffinit(L, &buffer); while (input < last) state = dot(*input++, state, &buffer); luaL_pushresult(&buffer); lua_pushnumber(L, (lua_Number) state); return 2; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/mime.h ================================================ #ifndef MIME_H #define MIME_H /*=========================================================================*\ * Core MIME support * LuaSocket toolkit * * This module provides functions to implement transfer content encodings * and formatting conforming to RFC 2045. It is used by mime.lua, which * provide a higher level interface to this functionality. \*=========================================================================*/ #include "lua.h" /*-------------------------------------------------------------------------*\ * Current MIME library version \*-------------------------------------------------------------------------*/ #define MIME_VERSION "MIME 1.0.3-rc1" #define MIME_COPYRIGHT "Copyright (C) 2004-2012 Diego Nehab" #define MIME_AUTHORS "Diego Nehab" /*-------------------------------------------------------------------------*\ * This macro prefixes all exported API functions \*-------------------------------------------------------------------------*/ #ifndef MIME_API #define MIME_API extern #endif MIME_API int luaopen_mime_core(lua_State *L); #endif /* MIME_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/options.c ================================================ /*=========================================================================*\ * Common option interface * LuaSocket toolkit \*=========================================================================*/ #include #include "lauxlib.h" #include "auxiliar.h" #include "options.h" #include "inet.h" /*=========================================================================*\ * Internal functions prototypes \*=========================================================================*/ static int opt_setmembership(lua_State *L, p_socket ps, int level, int name); static int opt_setboolean(lua_State *L, p_socket ps, int level, int name); static int opt_getboolean(lua_State *L, p_socket ps, int level, int name); static int opt_set(lua_State *L, p_socket ps, int level, int name, void *val, int len); static int opt_get(lua_State *L, p_socket ps, int level, int name, void *val, int* len); /*=========================================================================*\ * Exported functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Calls appropriate option handler \*-------------------------------------------------------------------------*/ int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps) { const char *name = luaL_checkstring(L, 2); /* obj, name, ... */ while (opt->name && strcmp(name, opt->name)) opt++; if (!opt->func) { char msg[45]; sprintf(msg, "unsupported option `%.35s'", name); luaL_argerror(L, 2, msg); } return opt->func(L, ps); } int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps) { const char *name = luaL_checkstring(L, 2); /* obj, name, ... */ while (opt->name && strcmp(name, opt->name)) opt++; if (!opt->func) { char msg[45]; sprintf(msg, "unsupported option `%.35s'", name); luaL_argerror(L, 2, msg); } return opt->func(L, ps); } /* enables reuse of local address */ int opt_set_reuseaddr(lua_State *L, p_socket ps) { return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEADDR); } int opt_get_reuseaddr(lua_State *L, p_socket ps) { return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEADDR); } /* enables reuse of local port */ int opt_set_reuseport(lua_State *L, p_socket ps) { return opt_setboolean(L, ps, SOL_SOCKET, SO_REUSEPORT); } int opt_get_reuseport(lua_State *L, p_socket ps) { return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEPORT); } /* disables the Naggle algorithm */ int opt_set_tcp_nodelay(lua_State *L, p_socket ps) { return opt_setboolean(L, ps, IPPROTO_TCP, TCP_NODELAY); } int opt_get_tcp_nodelay(lua_State *L, p_socket ps) { return opt_getboolean(L, ps, IPPROTO_TCP, TCP_NODELAY); } int opt_set_keepalive(lua_State *L, p_socket ps) { return opt_setboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE); } int opt_get_keepalive(lua_State *L, p_socket ps) { return opt_getboolean(L, ps, SOL_SOCKET, SO_KEEPALIVE); } int opt_set_dontroute(lua_State *L, p_socket ps) { return opt_setboolean(L, ps, SOL_SOCKET, SO_DONTROUTE); } int opt_set_broadcast(lua_State *L, p_socket ps) { return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST); } int opt_set_ip_multicast_loop(lua_State *L, p_socket ps) { return opt_setboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP); } int opt_get_ip_multicast_loop(lua_State *L, p_socket ps) { return opt_getboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP); } int opt_set_linger(lua_State *L, p_socket ps) { struct linger li; /* obj, name, table */ if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE)); lua_pushstring(L, "on"); lua_gettable(L, 3); if (!lua_isboolean(L, -1)) luaL_argerror(L, 3, "boolean 'on' field expected"); li.l_onoff = (u_short) lua_toboolean(L, -1); lua_pushstring(L, "timeout"); lua_gettable(L, 3); if (!lua_isnumber(L, -1)) luaL_argerror(L, 3, "number 'timeout' field expected"); li.l_linger = (u_short) lua_tonumber(L, -1); return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li)); } int opt_get_linger(lua_State *L, p_socket ps) { struct linger li; /* obj, name */ int len = sizeof(li); int err = opt_get(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, &len); if (err) return err; lua_newtable(L); lua_pushboolean(L, li.l_onoff); lua_setfield(L, -2, "on"); lua_pushinteger(L, li.l_linger); lua_setfield(L, -2, "timeout"); return 1; } int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps) { int val = (int) luaL_checknumber(L, 3); /* obj, name, int */ return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &val, sizeof(val)); } int opt_set_ip_multicast_if(lua_State *L, p_socket ps) { const char *address = luaL_checkstring(L, 3); /* obj, name, ip */ struct in_addr val; val.s_addr = htonl(INADDR_ANY); if (strcmp(address, "*") && !inet_aton(address, &val)) luaL_argerror(L, 3, "ip expected"); return opt_set(L, ps, IPPROTO_IP, IP_MULTICAST_IF, (char *) &val, sizeof(val)); } int opt_get_ip_multicast_if(lua_State *L, p_socket ps) { struct in_addr val; socklen_t len = sizeof(val); if (getsockopt(*ps, IPPROTO_IP, IP_MULTICAST_IF, (char *) &val, &len) < 0) { lua_pushnil(L); lua_pushstring(L, "getsockopt failed"); return 2; } lua_pushstring(L, inet_ntoa(val)); return 1; } int opt_set_ip_add_membership(lua_State *L, p_socket ps) { return opt_setmembership(L, ps, IPPROTO_IP, IP_ADD_MEMBERSHIP); } int opt_set_ip_drop_membersip(lua_State *L, p_socket ps) { return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP); } int opt_set_ip6_v6only(lua_State *L, p_socket ps) { return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY); } /*=========================================================================*\ * Auxiliar functions \*=========================================================================*/ static int opt_setmembership(lua_State *L, p_socket ps, int level, int name) { struct ip_mreq val; /* obj, name, table */ if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE)); lua_pushstring(L, "multiaddr"); lua_gettable(L, 3); if (!lua_isstring(L, -1)) luaL_argerror(L, 3, "string 'multiaddr' field expected"); if (!inet_aton(lua_tostring(L, -1), &val.imr_multiaddr)) luaL_argerror(L, 3, "invalid 'multiaddr' ip address"); lua_pushstring(L, "interface"); lua_gettable(L, 3); if (!lua_isstring(L, -1)) luaL_argerror(L, 3, "string 'interface' field expected"); val.imr_interface.s_addr = htonl(INADDR_ANY); if (strcmp(lua_tostring(L, -1), "*") && !inet_aton(lua_tostring(L, -1), &val.imr_interface)) luaL_argerror(L, 3, "invalid 'interface' ip address"); return opt_set(L, ps, level, name, (char *) &val, sizeof(val)); } static int opt_get(lua_State *L, p_socket ps, int level, int name, void *val, int* len) { socklen_t socklen = *len; if (getsockopt(*ps, level, name, (char *) val, &socklen) < 0) { lua_pushnil(L); lua_pushstring(L, "getsockopt failed"); return 2; } *len = socklen; return 0; } static int opt_set(lua_State *L, p_socket ps, int level, int name, void *val, int len) { if (setsockopt(*ps, level, name, (char *) val, len) < 0) { lua_pushnil(L); lua_pushstring(L, "setsockopt failed"); return 2; } lua_pushnumber(L, 1); return 1; } static int opt_getboolean(lua_State *L, p_socket ps, int level, int name) { int val = 0; int len = sizeof(val); int err = opt_get(L, ps, level, name, (char *) &val, &len); if (err) return err; lua_pushboolean(L, val); return 1; } static int opt_setboolean(lua_State *L, p_socket ps, int level, int name) { int val = auxiliar_checkboolean(L, 3); /* obj, name, bool */ return opt_set(L, ps, level, name, (char *) &val, sizeof(val)); } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/options.h ================================================ #ifndef OPTIONS_H #define OPTIONS_H /*=========================================================================*\ * Common option interface * LuaSocket toolkit * * This module provides a common interface to socket options, used mainly by * modules UDP and TCP. \*=========================================================================*/ #include "lua.h" #include "socket.h" /* option registry */ typedef struct t_opt { const char *name; int (*func)(lua_State *L, p_socket ps); } t_opt; typedef t_opt *p_opt; /* supported options for setoption */ int opt_set_dontroute(lua_State *L, p_socket ps); int opt_set_broadcast(lua_State *L, p_socket ps); int opt_set_reuseaddr(lua_State *L, p_socket ps); int opt_set_tcp_nodelay(lua_State *L, p_socket ps); int opt_set_keepalive(lua_State *L, p_socket ps); int opt_set_linger(lua_State *L, p_socket ps); int opt_set_reuseaddr(lua_State *L, p_socket ps); int opt_set_reuseport(lua_State *L, p_socket ps); int opt_set_ip_multicast_if(lua_State *L, p_socket ps); int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps); int opt_set_ip_multicast_loop(lua_State *L, p_socket ps); int opt_set_ip_add_membership(lua_State *L, p_socket ps); int opt_set_ip_drop_membersip(lua_State *L, p_socket ps); int opt_set_ip6_v6only(lua_State *L, p_socket ps); /* supported options for getoption */ int opt_get_reuseaddr(lua_State *L, p_socket ps); int opt_get_tcp_nodelay(lua_State *L, p_socket ps); int opt_get_keepalive(lua_State *L, p_socket ps); int opt_get_linger(lua_State *L, p_socket ps); int opt_get_reuseaddr(lua_State *L, p_socket ps); int opt_get_ip_multicast_loop(lua_State *L, p_socket ps); int opt_get_ip_multicast_if(lua_State *L, p_socket ps); /* invokes the appropriate option handler */ int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps); #endif ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/select.c ================================================ /*=========================================================================*\ * Select implementation * LuaSocket toolkit \*=========================================================================*/ #include #include "lua.h" #include "lauxlib.h" #include "socket.h" #include "timeout.h" #include "select.h" /*=========================================================================*\ * Internal function prototypes. \*=========================================================================*/ static t_socket getfd(lua_State *L); static int dirty(lua_State *L); static void collect_fd(lua_State *L, int tab, int itab, fd_set *set, t_socket *max_fd); static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set); static void return_fd(lua_State *L, fd_set *set, t_socket max_fd, int itab, int tab, int start); static void make_assoc(lua_State *L, int tab); static int global_select(lua_State *L); /* functions in library namespace */ static luaL_Reg func[] = { {"select", global_select}, {NULL, NULL} }; /*=========================================================================*\ * Exported functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int select_open(lua_State *L) { lua_pushstring(L, "_SETSIZE"); lua_pushnumber(L, FD_SETSIZE); lua_rawset(L, -3); luaL_openlib(L, NULL, func, 0); return 0; } /*=========================================================================*\ * Global Lua functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Waits for a set of sockets until a condition is met or timeout. \*-------------------------------------------------------------------------*/ static int global_select(lua_State *L) { int rtab, wtab, itab, ret, ndirty; t_socket max_fd = SOCKET_INVALID; fd_set rset, wset; t_timeout tm; double t = luaL_optnumber(L, 3, -1); FD_ZERO(&rset); FD_ZERO(&wset); lua_settop(L, 3); lua_newtable(L); itab = lua_gettop(L); lua_newtable(L); rtab = lua_gettop(L); lua_newtable(L); wtab = lua_gettop(L); collect_fd(L, 1, itab, &rset, &max_fd); collect_fd(L, 2, itab, &wset, &max_fd); ndirty = check_dirty(L, 1, rtab, &rset); t = ndirty > 0? 0.0: t; timeout_init(&tm, t, -1); timeout_markstart(&tm); ret = socket_select(max_fd+1, &rset, &wset, NULL, &tm); if (ret > 0 || ndirty > 0) { return_fd(L, &rset, max_fd+1, itab, rtab, ndirty); return_fd(L, &wset, max_fd+1, itab, wtab, 0); make_assoc(L, rtab); make_assoc(L, wtab); return 2; } else if (ret == 0) { lua_pushstring(L, "timeout"); return 3; } else { luaL_error(L, "select failed"); return 3; } } /*=========================================================================*\ * Internal functions \*=========================================================================*/ static t_socket getfd(lua_State *L) { t_socket fd = SOCKET_INVALID; lua_pushstring(L, "getfd"); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { lua_pushvalue(L, -2); lua_call(L, 1, 1); if (lua_isnumber(L, -1)) { double numfd = lua_tonumber(L, -1); fd = (numfd >= 0.0)? (t_socket) numfd: SOCKET_INVALID; } } lua_pop(L, 1); return fd; } static int dirty(lua_State *L) { int is = 0; lua_pushstring(L, "dirty"); lua_gettable(L, -2); if (!lua_isnil(L, -1)) { lua_pushvalue(L, -2); lua_call(L, 1, 1); is = lua_toboolean(L, -1); } lua_pop(L, 1); return is; } static void collect_fd(lua_State *L, int tab, int itab, fd_set *set, t_socket *max_fd) { int i = 1, n = 0; /* nil is the same as an empty table */ if (lua_isnil(L, tab)) return; /* otherwise we need it to be a table */ luaL_checktype(L, tab, LUA_TTABLE); for ( ;; ) { t_socket fd; lua_pushnumber(L, i); lua_gettable(L, tab); if (lua_isnil(L, -1)) { lua_pop(L, 1); break; } /* getfd figures out if this is a socket */ fd = getfd(L); if (fd != SOCKET_INVALID) { /* make sure we don't overflow the fd_set */ #ifdef _WIN32 if (n >= FD_SETSIZE) luaL_argerror(L, tab, "too many sockets"); #else if (fd >= FD_SETSIZE) luaL_argerror(L, tab, "descriptor too large for set size"); #endif FD_SET(fd, set); n++; /* keep track of the largest descriptor so far */ if (*max_fd == SOCKET_INVALID || *max_fd < fd) *max_fd = fd; /* make sure we can map back from descriptor to the object */ lua_pushnumber(L, (lua_Number) fd); lua_pushvalue(L, -2); lua_settable(L, itab); } lua_pop(L, 1); i = i + 1; } } static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) { int ndirty = 0, i = 1; if (lua_isnil(L, tab)) return 0; for ( ;; ) { t_socket fd; lua_pushnumber(L, i); lua_gettable(L, tab); if (lua_isnil(L, -1)) { lua_pop(L, 1); break; } fd = getfd(L); if (fd != SOCKET_INVALID && dirty(L)) { lua_pushnumber(L, ++ndirty); lua_pushvalue(L, -2); lua_settable(L, dtab); FD_CLR(fd, set); } lua_pop(L, 1); i = i + 1; } return ndirty; } static void return_fd(lua_State *L, fd_set *set, t_socket max_fd, int itab, int tab, int start) { t_socket fd; for (fd = 0; fd < max_fd; fd++) { if (FD_ISSET(fd, set)) { lua_pushnumber(L, ++start); lua_pushnumber(L, (lua_Number) fd); lua_gettable(L, itab); lua_settable(L, tab); } } } static void make_assoc(lua_State *L, int tab) { int i = 1, atab; lua_newtable(L); atab = lua_gettop(L); for ( ;; ) { lua_pushnumber(L, i); lua_gettable(L, tab); if (!lua_isnil(L, -1)) { lua_pushnumber(L, i); lua_pushvalue(L, -2); lua_settable(L, atab); lua_pushnumber(L, i); lua_settable(L, atab); } else { lua_pop(L, 1); break; } i = i+1; } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/select.h ================================================ #ifndef SELECT_H #define SELECT_H /*=========================================================================*\ * Select implementation * LuaSocket toolkit * * Each object that can be passed to the select function has to export * method getfd() which returns the descriptor to be passed to the * underlying select function. Another method, dirty(), should return * true if there is data ready for reading (required for buffered input). \*=========================================================================*/ int select_open(lua_State *L); #endif /* SELECT_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/serial.c ================================================ /*=========================================================================*\ * Serial stream * LuaSocket toolkit \*=========================================================================*/ #include #include "lua.h" #include "lauxlib.h" #include "auxiliar.h" #include "socket.h" #include "options.h" #include "unix.h" #include /* Reuses userdata definition from unix.h, since it is useful for all stream-like objects. If we stored the serial path for use in error messages or userdata printing, we might need our own userdata definition. Group usage is semi-inherited from unix.c, but unnecessary since we have only one object type. */ /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ static int global_create(lua_State *L); static int meth_send(lua_State *L); static int meth_receive(lua_State *L); static int meth_close(lua_State *L); static int meth_settimeout(lua_State *L); static int meth_getfd(lua_State *L); static int meth_setfd(lua_State *L); static int meth_dirty(lua_State *L); static int meth_getstats(lua_State *L); static int meth_setstats(lua_State *L); /* serial object methods */ static luaL_Reg serial_methods[] = { {"__gc", meth_close}, {"__tostring", auxiliar_tostring}, {"close", meth_close}, {"dirty", meth_dirty}, {"getfd", meth_getfd}, {"getstats", meth_getstats}, {"setstats", meth_setstats}, {"receive", meth_receive}, {"send", meth_send}, {"setfd", meth_setfd}, {"settimeout", meth_settimeout}, {NULL, NULL} }; /* our socket creation function */ static luaL_Reg func[] = { {"serial", global_create}, {NULL, NULL} }; /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ LUASOCKET_API int luaopen_socket_serial(lua_State *L) { /* create classes */ auxiliar_newclass(L, "serial{client}", serial_methods); /* create class groups */ auxiliar_add2group(L, "serial{client}", "serial{any}"); /* make sure the function ends up in the package table */ luaL_openlib(L, "socket", func, 0); /* return the function instead of the 'socket' table */ lua_pushstring(L, "serial"); lua_gettable(L, -2); return 1; } /*=========================================================================*\ * Lua methods \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Just call buffered IO methods \*-------------------------------------------------------------------------*/ static int meth_send(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); return buffer_meth_send(L, &un->buf); } static int meth_receive(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); return buffer_meth_receive(L, &un->buf); } static int meth_getstats(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); return buffer_meth_getstats(L, &un->buf); } static int meth_setstats(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); return buffer_meth_setstats(L, &un->buf); } /*-------------------------------------------------------------------------*\ * Select support methods \*-------------------------------------------------------------------------*/ static int meth_getfd(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); lua_pushnumber(L, (int) un->sock); return 1; } /* this is very dangerous, but can be handy for those that are brave enough */ static int meth_setfd(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); un->sock = (t_socket) luaL_checknumber(L, 2); return 0; } static int meth_dirty(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); lua_pushboolean(L, !buffer_isempty(&un->buf)); return 1; } /*-------------------------------------------------------------------------*\ * Closes socket used by object \*-------------------------------------------------------------------------*/ static int meth_close(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); socket_destroy(&un->sock); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Just call tm methods \*-------------------------------------------------------------------------*/ static int meth_settimeout(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); return timeout_meth_settimeout(L, &un->tm); } /*=========================================================================*\ * Library functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Creates a serial object \*-------------------------------------------------------------------------*/ static int global_create(lua_State *L) { const char* path = luaL_checkstring(L, 1); /* allocate unix object */ p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix)); /* open serial device */ t_socket sock = open(path, O_NOCTTY|O_RDWR); /*printf("open %s on %d\n", path, sock);*/ if (sock < 0) { lua_pushnil(L); lua_pushstring(L, socket_strerror(errno)); lua_pushnumber(L, errno); return 3; } /* set its type as client object */ auxiliar_setclass(L, "serial{client}", -1); /* initialize remaining structure fields */ socket_setnonblocking(&sock); un->sock = sock; io_init(&un->io, (p_send) socket_write, (p_recv) socket_read, (p_error) socket_ioerror, &un->sock); timeout_init(&un->tm, -1, -1); buffer_init(&un->buf, &un->io, &un->tm); return 1; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/socket.h ================================================ #ifndef SOCKET_H #define SOCKET_H /*=========================================================================*\ * Socket compatibilization module * LuaSocket toolkit * * BSD Sockets and WinSock are similar, but there are a few irritating * differences. Also, not all *nix platforms behave the same. This module * (and the associated usocket.h and wsocket.h) factor these differences and * creates a interface compatible with the io.h module. \*=========================================================================*/ #include "luasocket_io.h" /*=========================================================================*\ * Platform specific compatibilization \*=========================================================================*/ #ifdef _WIN32 #include "wsocket.h" #else #include "usocket.h" #endif /*=========================================================================*\ * The connect and accept functions accept a timeout and their * implementations are somewhat complicated. We chose to move * the timeout control into this module for these functions in * order to simplify the modules that use them. \*=========================================================================*/ #include "timeout.h" /* we are lazy... */ typedef struct sockaddr SA; /*=========================================================================*\ * Functions bellow implement a comfortable platform independent * interface to sockets \*=========================================================================*/ int socket_open(void); int socket_close(void); void socket_destroy(p_socket ps); void socket_shutdown(p_socket ps, int how); int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, SA *addr, socklen_t addr_len, p_timeout tm); int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, SA *addr, socklen_t *addr_len, p_timeout tm); void socket_setnonblocking(p_socket ps); void socket_setblocking(p_socket ps); int socket_waitfd(p_socket ps, int sw, p_timeout tm); int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_timeout tm); int socket_connect(p_socket ps, SA *addr, socklen_t addr_len, p_timeout tm); int socket_create(p_socket ps, int domain, int type, int protocol); int socket_bind(p_socket ps, SA *addr, socklen_t addr_len); int socket_listen(p_socket ps, int backlog); int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *addr_len, p_timeout tm); const char *socket_hoststrerror(int err); const char *socket_gaistrerror(int err); const char *socket_strerror(int err); /* these are perfect to use with the io abstraction module and the buffered input module */ int socket_send(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm); int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm); int socket_write(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm); int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm); const char *socket_ioerror(p_socket ps, int err); int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp); int socket_gethostbyname(const char *addr, struct hostent **hp); #endif /* SOCKET_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/socket_scripts.c ================================================ /* socket_scripts.c */ #include "lua.h" #include "lauxlib.h" #include "socket_scripts.h" /* ltn12, ltn12.lua */ static const char lua_m_ltn12[] = { 0x1b,0x4c,0x4a,0x01,0x02,0x31,0x00,0x01,0x06,0x03,0x00,0x00,0x09,0x29,0x01,0x00, 0x00,0x2b,0x02,0x01,0x00,0x2b,0x03,0x00,0x00,0x10,0x04,0x00,0x00,0x2b,0x05,0x02, 0x00,0x3e,0x02,0x04,0x03,0x2c,0x00,0x03,0x00,0x10,0x01,0x02,0x00,0x48,0x01,0x02, 0x00,0x01,0x80,0x00,0xc0,0x02,0xc0,0x2d,0x01,0x03,0x05,0x01,0x02,0x00,0x07,0x2b, 0x03,0x00,0x00,0x37,0x03,0x00,0x03,0x10,0x04,0x00,0x00,0x3e,0x03,0x02,0x01,0x31, 0x03,0x01,0x00,0x30,0x00,0x00,0x80,0x48,0x03,0x02,0x00,0x02,0xc0,0x00,0x0b,0x61, 0x73,0x73,0x65,0x72,0x74,0xcd,0x02,0x00,0x01,0x03,0x06,0x03,0x01,0x44,0x0d,0x01, 0x00,0x00,0x54,0x01,0x01,0x80,0x2b,0x01,0x00,0x00,0x2c,0x00,0x01,0x00,0x51,0x01, 0x3e,0x80,0x2b,0x01,0x01,0x00,0x2b,0x02,0x02,0x00,0x05,0x01,0x02,0x00,0x54,0x01, 0x1a,0x80,0x2b,0x01,0x03,0x00,0x2b,0x02,0x01,0x00,0x36,0x01,0x02,0x01,0x10,0x02, 0x00,0x00,0x3e,0x01,0x02,0x02,0x10,0x00,0x01,0x00,0x06,0x00,0x00,0x00,0x54,0x01, 0x04,0x80,0x2b,0x01,0x02,0x00,0x2b,0x02,0x04,0x00,0x05,0x01,0x02,0x00,0x54,0x01, 0x02,0x80,0x48,0x00,0x02,0x00,0x54,0x01,0xed,0x7f,0x0f,0x00,0x00,0x00,0x54,0x01, 0x04,0x80,0x2b,0x01,0x01,0x00,0x14,0x01,0x00,0x01,0x2c,0x01,0x01,0x00,0x54,0x01, 0xe7,0x7f,0x2b,0x01,0x02,0x00,0x14,0x01,0x00,0x01,0x2c,0x02,0x01,0x00,0x2b,0x01, 0x02,0x00,0x2c,0x01,0x01,0x00,0x54,0x01,0xe1,0x7f,0x2b,0x01,0x03,0x00,0x2b,0x02, 0x01,0x00,0x36,0x01,0x02,0x01,0x0c,0x02,0x00,0x00,0x54,0x02,0x01,0x80,0x25,0x02, 0x00,0x00,0x3e,0x01,0x02,0x02,0x10,0x00,0x01,0x00,0x07,0x00,0x00,0x00,0x54,0x01, 0x05,0x80,0x2b,0x01,0x01,0x00,0x15,0x01,0x00,0x01,0x2c,0x01,0x01,0x00,0x2b,0x00, 0x00,0x00,0x54,0x01,0xd2,0x7f,0x0f,0x00,0x00,0x00,0x54,0x01,0x0a,0x80,0x2b,0x01, 0x01,0x00,0x2b,0x02,0x04,0x00,0x05,0x01,0x02,0x00,0x54,0x01,0x02,0x80,0x48,0x00, 0x02,0x00,0x54,0x01,0xca,0x7f,0x2b,0x01,0x01,0x00,0x14,0x01,0x00,0x01,0x2c,0x01, 0x01,0x00,0x54,0x01,0xc6,0x7f,0x2b,0x01,0x05,0x00,0x37,0x01,0x01,0x01,0x25,0x02, 0x02,0x00,0x3e,0x01,0x02,0x01,0x54,0x01,0xc1,0x7f,0x47,0x00,0x01,0x00,0x04,0x80, 0x03,0x80,0x02,0x80,0x00,0xc0,0x01,0xc0,0x00,0x00,0x26,0x66,0x69,0x6c,0x74,0x65, 0x72,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x65,0x64,0x20,0x69,0x6e,0x61,0x70,0x70, 0x72,0x6f,0x70,0x72,0x69,0x61,0x74,0x65,0x20,0x6e,0x69,0x6c,0x0a,0x65,0x72,0x72, 0x6f,0x72,0x05,0x02,0x4e,0x03,0x00,0x06,0x01,0x04,0x01,0x0d,0x32,0x00,0x03,0x00, 0x43,0x01,0x00,0x00,0x3c,0x01,0x00,0x00,0x34,0x01,0x00,0x00,0x25,0x02,0x01,0x00, 0x43,0x03,0x00,0x00,0x3d,0x01,0x01,0x02,0x27,0x02,0x01,0x00,0x27,0x03,0x01,0x00, 0x25,0x04,0x02,0x00,0x31,0x05,0x03,0x00,0x30,0x00,0x00,0x80,0x48,0x05,0x02,0x00, 0x02,0xc0,0x00,0x05,0x06,0x23,0x0b,0x73,0x65,0x6c,0x65,0x63,0x74,0x03,0x80,0x80, 0xc0,0x99,0x04,0x0f,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x29,0x00,0x00,0x00,0x48, 0x00,0x02,0x00,0x11,0x00,0x00,0x01,0x01,0x00,0x00,0x02,0x2b,0x00,0x00,0x00,0x48, 0x00,0x02,0x00,0x08,0xc0,0x15,0x00,0x00,0x02,0x01,0x00,0x00,0x03,0x29,0x00,0x00, 0x00,0x2b,0x01,0x00,0x00,0x46,0x00,0x03,0x00,0x00,0xc0,0x14,0x01,0x01,0x02,0x00, 0x01,0x00,0x03,0x31,0x01,0x00,0x00,0x30,0x00,0x00,0x80,0x48,0x01,0x02,0x00,0x00, 0x54,0x00,0x00,0x03,0x02,0x03,0x00,0x0d,0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00, 0x37,0x00,0x00,0x00,0x2b,0x02,0x01,0x00,0x37,0x02,0x01,0x02,0x3e,0x00,0x03,0x02, 0x0e,0x00,0x00,0x00,0x54,0x01,0x04,0x80,0x2b,0x01,0x00,0x00,0x10,0x02,0x01,0x00, 0x37,0x01,0x02,0x01,0x3e,0x01,0x02,0x01,0x48,0x00,0x02,0x00,0x00,0xc0,0x00,0x00, 0x0a,0x63,0x6c,0x6f,0x73,0x65,0x0e,0x42,0x4c,0x4f,0x43,0x4b,0x53,0x49,0x5a,0x45, 0x09,0x72,0x65,0x61,0x64,0x62,0x01,0x02,0x04,0x02,0x03,0x00,0x0f,0x0f,0x00,0x00, 0x00,0x54,0x02,0x04,0x80,0x31,0x02,0x00,0x00,0x30,0x00,0x00,0x80,0x48,0x02,0x02, 0x00,0x54,0x02,0x07,0x80,0x2b,0x02,0x01,0x00,0x37,0x02,0x01,0x02,0x0c,0x03,0x01, 0x00,0x54,0x03,0x01,0x80,0x25,0x03,0x02,0x00,0x30,0x00,0x00,0x80,0x40,0x02,0x02, 0x00,0x30,0x00,0x00,0x80,0x47,0x00,0x01,0x00,0x03,0xc0,0x05,0xc0,0x18,0x75,0x6e, 0x61,0x62,0x6c,0x65,0x20,0x74,0x6f,0x20,0x6f,0x70,0x65,0x6e,0x20,0x66,0x69,0x6c, 0x65,0x0a,0x65,0x72,0x72,0x6f,0x72,0x00,0x41,0x00,0x00,0x04,0x01,0x00,0x00,0x0e, 0x2b,0x00,0x00,0x00,0x3e,0x00,0x01,0x03,0x0c,0x02,0x01,0x00,0x54,0x02,0x01,0x80, 0x2b,0x02,0x00,0x00,0x2c,0x00,0x02,0x00,0x0e,0x00,0x00,0x00,0x54,0x02,0x04,0x80, 0x29,0x02,0x00,0x00,0x10,0x03,0x01,0x00,0x46,0x02,0x03,0x00,0x54,0x02,0x01,0x80, 0x48,0x00,0x02,0x00,0x47,0x00,0x01,0x00,0x00,0x80,0x2d,0x01,0x01,0x03,0x01,0x02, 0x00,0x07,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x10,0x02,0x00,0x00,0x3e,0x01, 0x02,0x01,0x31,0x01,0x01,0x00,0x30,0x00,0x00,0x80,0x48,0x01,0x02,0x00,0x02,0xc0, 0x00,0x0b,0x61,0x73,0x73,0x65,0x72,0x74,0x77,0x00,0x00,0x05,0x04,0x03,0x01,0x16, 0x2b,0x00,0x00,0x00,0x37,0x00,0x00,0x00,0x2b,0x01,0x01,0x00,0x2b,0x02,0x02,0x00, 0x2b,0x03,0x02,0x00,0x2b,0x04,0x03,0x00,0x37,0x04,0x01,0x04,0x1e,0x03,0x04,0x03, 0x15,0x03,0x00,0x03,0x3e,0x00,0x04,0x02,0x2b,0x01,0x02,0x00,0x2b,0x02,0x03,0x00, 0x37,0x02,0x01,0x02,0x1e,0x01,0x02,0x01,0x2c,0x02,0x01,0x00,0x06,0x00,0x02,0x00, 0x54,0x01,0x02,0x80,0x48,0x00,0x02,0x00,0x54,0x01,0x02,0x80,0x29,0x01,0x00,0x00, 0x48,0x01,0x02,0x00,0x47,0x00,0x01,0x00,0x00,0x00,0x00,0xc0,0x01,0x80,0x01,0x00, 0x05,0x0e,0x42,0x4c,0x4f,0x43,0x4b,0x53,0x49,0x5a,0x45,0x08,0x73,0x75,0x62,0x02, 0x48,0x01,0x01,0x03,0x03,0x02,0x00,0x0d,0x0f,0x00,0x00,0x00,0x54,0x01,0x05,0x80, 0x27,0x01,0x01,0x00,0x31,0x02,0x00,0x00,0x30,0x00,0x00,0x80,0x48,0x02,0x02,0x00, 0x30,0x01,0x04,0x80,0x2b,0x01,0x02,0x00,0x37,0x01,0x01,0x01,0x30,0x00,0x00,0x80, 0x40,0x01,0x01,0x00,0x30,0x00,0x00,0x80,0x47,0x00,0x01,0x00,0x00,0xc0,0x03,0xc0, 0x05,0xc0,0x0a,0x65,0x6d,0x70,0x74,0x79,0x00,0x6b,0x00,0x01,0x04,0x03,0x02,0x00, 0x14,0x0e,0x00,0x00,0x00,0x54,0x01,0x0c,0x80,0x2b,0x01,0x00,0x00,0x37,0x01,0x00, 0x01,0x2b,0x02,0x01,0x00,0x3e,0x01,0x02,0x02,0x10,0x00,0x01,0x00,0x0e,0x00,0x00, 0x00,0x54,0x01,0x03,0x80,0x2b,0x01,0x02,0x00,0x40,0x01,0x01,0x00,0x54,0x01,0x07, 0x80,0x48,0x00,0x02,0x00,0x54,0x01,0x05,0x80,0x2b,0x01,0x00,0x00,0x37,0x01,0x01, 0x01,0x2b,0x02,0x01,0x00,0x10,0x03,0x00,0x00,0x3e,0x01,0x03,0x01,0x47,0x00,0x01, 0x00,0x01,0x00,0x01,0xc0,0x00,0xc0,0x0b,0x69,0x6e,0x73,0x65,0x72,0x74,0x0b,0x72, 0x65,0x6d,0x6f,0x76,0x65,0x33,0x01,0x01,0x03,0x02,0x02,0x00,0x08,0x2b,0x01,0x00, 0x00,0x37,0x01,0x00,0x01,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x01,0x32,0x01,0x00, 0x00,0x31,0x02,0x01,0x00,0x30,0x00,0x00,0x80,0x48,0x02,0x02,0x00,0x02,0xc0,0x01, 0xc0,0x00,0x0b,0x61,0x73,0x73,0x65,0x72,0x74,0xc9,0x03,0x00,0x00,0x03,0x07,0x07, 0x00,0x56,0x2b,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x54,0x00,0x05,0x80,0x2b,0x00, 0x01,0x00,0x37,0x00,0x00,0x00,0x25,0x01,0x01,0x00,0x27,0x02,0x02,0x00,0x3e,0x00, 0x03,0x01,0x51,0x00,0x4c,0x80,0x2b,0x00,0x02,0x00,0x07,0x00,0x02,0x00,0x54,0x00, 0x27,0x80,0x2b,0x00,0x05,0x00,0x3e,0x00,0x01,0x03,0x2c,0x04,0x01,0x00,0x2c,0x03, 0x00,0x00,0x2b,0x00,0x04,0x00,0x0f,0x00,0x00,0x00,0x54,0x01,0x03,0x80,0x29,0x00, 0x00,0x00,0x2b,0x01,0x04,0x00,0x46,0x00,0x03,0x00,0x2b,0x00,0x06,0x00,0x2b,0x01, 0x03,0x00,0x3e,0x00,0x02,0x02,0x2c,0x00,0x00,0x00,0x2b,0x00,0x00,0x00,0x0e,0x00, 0x00,0x00,0x54,0x00,0x0b,0x80,0x2b,0x00,0x03,0x00,0x0f,0x00,0x00,0x00,0x54,0x01, 0x05,0x80,0x2b,0x00,0x01,0x00,0x37,0x00,0x00,0x00,0x25,0x01,0x03,0x00,0x3e,0x00, 0x02,0x01,0x54,0x00,0xe3,0x7f,0x29,0x00,0x00,0x00,0x48,0x00,0x02,0x00,0x54,0x00, 0xe0,0x7f,0x2b,0x00,0x00,0x00,0x06,0x00,0x04,0x00,0x54,0x00,0xdd,0x7f,0x2d,0x02, 0x05,0x00,0x2b,0x00,0x03,0x00,0x0f,0x00,0x00,0x00,0x54,0x01,0x01,0x80,0x2d,0x03, 0x04,0x00,0x2b,0x00,0x00,0x00,0x48,0x00,0x02,0x00,0x54,0x00,0xd5,0x7f,0x2b,0x00, 0x06,0x00,0x2b,0x01,0x03,0x00,0x3e,0x00,0x02,0x02,0x2c,0x00,0x00,0x00,0x2b,0x00, 0x00,0x00,0x07,0x00,0x04,0x00,0x54,0x00,0x0a,0x80,0x2b,0x00,0x03,0x00,0x07,0x00, 0x04,0x00,0x54,0x00,0x02,0x80,0x2d,0x02,0x02,0x00,0x54,0x00,0xc9,0x7f,0x2b,0x00, 0x01,0x00,0x37,0x00,0x00,0x00,0x25,0x01,0x06,0x00,0x3e,0x00,0x02,0x01,0x54,0x00, 0xc4,0x7f,0x2b,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x54,0x00,0x0b,0x80,0x2b,0x00, 0x03,0x00,0x0f,0x00,0x00,0x00,0x54,0x01,0x05,0x80,0x2b,0x00,0x01,0x00,0x37,0x00, 0x00,0x00,0x25,0x01,0x03,0x00,0x3e,0x00,0x02,0x01,0x54,0x00,0xb9,0x7f,0x29,0x00, 0x00,0x00,0x48,0x00,0x02,0x00,0x54,0x00,0xb6,0x7f,0x2b,0x00,0x00,0x00,0x48,0x00, 0x02,0x00,0x54,0x00,0xb3,0x7f,0x47,0x00,0x01,0x00,0x03,0x80,0x01,0x00,0x04,0x80, 0x02,0x80,0x05,0x80,0x00,0xc0,0x01,0x80,0x17,0x66,0x69,0x6c,0x74,0x65,0x72,0x20, 0x72,0x65,0x74,0x75,0x72,0x6e,0x65,0x64,0x20,0x22,0x22,0x0b,0x65,0x61,0x74,0x69, 0x6e,0x67,0x05,0x26,0x66,0x69,0x6c,0x74,0x65,0x72,0x20,0x72,0x65,0x74,0x75,0x72, 0x6e,0x65,0x64,0x20,0x69,0x6e,0x61,0x70,0x70,0x72,0x6f,0x70,0x72,0x69,0x61,0x74, 0x65,0x20,0x6e,0x69,0x6c,0x0c,0x66,0x65,0x65,0x64,0x69,0x6e,0x67,0x15,0x73,0x6f, 0x75,0x72,0x63,0x65,0x20,0x69,0x73,0x20,0x65,0x6d,0x70,0x74,0x79,0x21,0x0a,0x65, 0x72,0x72,0x6f,0x72,0x7a,0x03,0x02,0x07,0x02,0x05,0x00,0x16,0x43,0x02,0x02,0x02, 0x0f,0x00,0x02,0x00,0x54,0x03,0x06,0x80,0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02, 0x10,0x03,0x01,0x00,0x43,0x04,0x02,0x00,0x3d,0x02,0x01,0x02,0x10,0x01,0x02,0x00, 0x2b,0x02,0x01,0x00,0x37,0x02,0x01,0x02,0x0d,0x03,0x00,0x00,0x54,0x03,0x01,0x80, 0x10,0x03,0x01,0x00,0x3e,0x02,0x02,0x01,0x25,0x02,0x02,0x00,0x25,0x03,0x02,0x00, 0x25,0x04,0x03,0x00,0x29,0x05,0x00,0x00,0x31,0x06,0x04,0x00,0x30,0x00,0x00,0x80, 0x48,0x06,0x02,0x00,0x04,0xc0,0x02,0xc0,0x00,0x0c,0x66,0x65,0x65,0x64,0x69,0x6e, 0x67,0x05,0x0b,0x61,0x73,0x73,0x65,0x72,0x74,0x0a,0x63,0x68,0x61,0x69,0x6e,0x6c, 0x00,0x00,0x05,0x03,0x01,0x00,0x16,0x2b,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x54, 0x01,0x12,0x80,0x51,0x00,0x11,0x80,0x2b,0x00,0x00,0x00,0x3e,0x00,0x01,0x03,0x0f, 0x00,0x00,0x00,0x54,0x02,0x01,0x80,0x48,0x00,0x02,0x00,0x0f,0x00,0x01,0x00,0x54, 0x02,0x03,0x80,0x29,0x02,0x00,0x00,0x10,0x03,0x01,0x00,0x46,0x02,0x03,0x00,0x2b, 0x02,0x01,0x00,0x37,0x02,0x00,0x02,0x2b,0x03,0x02,0x00,0x27,0x04,0x01,0x00,0x3e, 0x02,0x03,0x02,0x2c,0x00,0x02,0x00,0x54,0x00,0xeb,0x7f,0x47,0x00,0x01,0x00,0x01, 0x80,0x00,0x00,0x00,0xc0,0x0b,0x72,0x65,0x6d,0x6f,0x76,0x65,0x43,0x03,0x00,0x04, 0x01,0x02,0x01,0x0b,0x32,0x00,0x03,0x00,0x43,0x01,0x00,0x00,0x3c,0x01,0x00,0x00, 0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x10,0x02,0x00,0x00,0x27,0x03,0x01,0x00, 0x3e,0x01,0x03,0x02,0x31,0x02,0x01,0x00,0x30,0x00,0x00,0x80,0x48,0x02,0x02,0x00, 0x01,0xc0,0x00,0x0b,0x72,0x65,0x6d,0x6f,0x76,0x65,0x03,0x80,0x80,0xc0,0x99,0x04, 0x36,0x00,0x02,0x05,0x02,0x01,0x00,0x09,0x0f,0x00,0x00,0x00,0x54,0x02,0x05,0x80, 0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02,0x2b,0x03,0x01,0x00,0x10,0x04,0x00,0x00, 0x3e,0x02,0x03,0x01,0x27,0x02,0x01,0x00,0x48,0x02,0x02,0x00,0x00,0x00,0x00,0x80, 0x0b,0x69,0x6e,0x73,0x65,0x72,0x74,0x2a,0x01,0x01,0x04,0x01,0x01,0x00,0x08,0x0e, 0x00,0x00,0x00,0x54,0x01,0x01,0x80,0x32,0x00,0x00,0x00,0x31,0x01,0x00,0x00,0x10, 0x02,0x01,0x00,0x10,0x03,0x00,0x00,0x30,0x00,0x00,0x80,0x46,0x02,0x03,0x00,0x01, 0xc0,0x00,0x45,0x00,0x02,0x06,0x01,0x00,0x00,0x0f,0x2b,0x02,0x00,0x00,0x10,0x03, 0x00,0x00,0x10,0x04,0x01,0x00,0x3e,0x02,0x03,0x03,0x0e,0x00,0x02,0x00,0x54,0x04, 0x03,0x80,0x29,0x04,0x00,0x00,0x10,0x05,0x03,0x00,0x46,0x04,0x03,0x00,0x0c,0x04, 0x03,0x00,0x54,0x04,0x01,0x80,0x2b,0x04,0x00,0x00,0x2c,0x00,0x04,0x00,0x27,0x04, 0x01,0x00,0x48,0x04,0x02,0x00,0x00,0x80,0x2d,0x01,0x01,0x03,0x01,0x02,0x00,0x07, 0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x01, 0x31,0x01,0x01,0x00,0x30,0x00,0x00,0x80,0x48,0x01,0x02,0x00,0x02,0xc0,0x00,0x0b, 0x61,0x73,0x73,0x65,0x72,0x74,0x51,0x00,0x02,0x05,0x01,0x02,0x00,0x0f,0x0e,0x00, 0x00,0x00,0x54,0x02,0x07,0x80,0x2b,0x02,0x00,0x00,0x10,0x03,0x02,0x00,0x37,0x02, 0x00,0x02,0x3e,0x02,0x02,0x01,0x27,0x02,0x01,0x00,0x48,0x02,0x02,0x00,0x54,0x02, 0x05,0x80,0x2b,0x02,0x00,0x00,0x10,0x03,0x02,0x00,0x37,0x02,0x01,0x02,0x10,0x04, 0x00,0x00,0x40,0x02,0x03,0x00,0x47,0x00,0x01,0x00,0x00,0xc0,0x0a,0x77,0x72,0x69, 0x74,0x65,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x60,0x01,0x02,0x04,0x01,0x03,0x00,0x0f, 0x0f,0x00,0x00,0x00,0x54,0x02,0x04,0x80,0x31,0x02,0x00,0x00,0x30,0x00,0x00,0x80, 0x48,0x02,0x02,0x00,0x54,0x02,0x07,0x80,0x2b,0x02,0x00,0x00,0x37,0x02,0x01,0x02, 0x0c,0x03,0x01,0x00,0x54,0x03,0x01,0x80,0x25,0x03,0x02,0x00,0x30,0x00,0x00,0x80, 0x40,0x02,0x02,0x00,0x30,0x00,0x00,0x80,0x47,0x00,0x01,0x00,0x06,0xc0,0x18,0x75, 0x6e,0x61,0x62,0x6c,0x65,0x20,0x74,0x6f,0x20,0x6f,0x70,0x65,0x6e,0x20,0x66,0x69, 0x6c,0x65,0x0a,0x65,0x72,0x72,0x6f,0x72,0x00,0x0f,0x00,0x00,0x01,0x00,0x00,0x00, 0x02,0x27,0x00,0x01,0x00,0x48,0x00,0x02,0x00,0x11,0x00,0x00,0x01,0x01,0x00,0x00, 0x02,0x2b,0x00,0x00,0x00,0x48,0x00,0x02,0x00,0x09,0xc0,0x15,0x00,0x00,0x02,0x01, 0x00,0x00,0x03,0x29,0x00,0x00,0x00,0x2b,0x01,0x00,0x00,0x46,0x00,0x03,0x00,0x00, 0xc0,0x14,0x01,0x01,0x02,0x00,0x01,0x00,0x03,0x31,0x01,0x00,0x00,0x30,0x00,0x00, 0x80,0x48,0x01,0x02,0x00,0x00,0x88,0x01,0x00,0x02,0x08,0x02,0x01,0x00,0x1f,0x06, 0x00,0x00,0x00,0x54,0x02,0x1a,0x80,0x2b,0x02,0x00,0x00,0x10,0x03,0x00,0x00,0x3e, 0x02,0x02,0x02,0x0d,0x03,0x00,0x00,0x54,0x03,0x01,0x80,0x25,0x03,0x00,0x00,0x51, 0x04,0x12,0x80,0x2b,0x04,0x01,0x00,0x10,0x05,0x02,0x00,0x10,0x06,0x01,0x00,0x3e, 0x04,0x03,0x03,0x0e,0x00,0x04,0x00,0x54,0x06,0x03,0x80,0x29,0x06,0x00,0x00,0x10, 0x07,0x05,0x00,0x46,0x06,0x03,0x00,0x05,0x02,0x03,0x00,0x54,0x06,0x02,0x80,0x27, 0x06,0x01,0x00,0x48,0x06,0x02,0x00,0x2b,0x06,0x00,0x00,0x10,0x07,0x03,0x00,0x3e, 0x06,0x02,0x02,0x10,0x02,0x06,0x00,0x54,0x04,0xed,0x7f,0x54,0x02,0x02,0x80,0x27, 0x02,0x01,0x00,0x48,0x02,0x02,0x00,0x47,0x00,0x01,0x00,0x00,0x80,0x01,0x80,0x05, 0xa7,0x01,0x03,0x02,0x06,0x03,0x05,0x01,0x1e,0x43,0x02,0x02,0x02,0x0f,0x00,0x02, 0x00,0x54,0x03,0x12,0x80,0x32,0x02,0x04,0x00,0x3b,0x00,0x01,0x02,0x3b,0x01,0x02, 0x02,0x43,0x03,0x02,0x00,0x3c,0x03,0x00,0x00,0x2b,0x03,0x00,0x00,0x37,0x03,0x00, 0x03,0x10,0x04,0x02,0x00,0x13,0x05,0x02,0x00,0x3e,0x03,0x03,0x02,0x10,0x01,0x03, 0x00,0x2b,0x03,0x01,0x00,0x37,0x03,0x01,0x03,0x34,0x04,0x02,0x00,0x10,0x05,0x02, 0x00,0x3e,0x04,0x02,0x00,0x3d,0x03,0x00,0x02,0x10,0x00,0x03,0x00,0x2b,0x02,0x02, 0x00,0x37,0x02,0x03,0x02,0x0d,0x03,0x00,0x00,0x54,0x03,0x01,0x80,0x10,0x03,0x01, 0x00,0x3e,0x02,0x02,0x01,0x31,0x02,0x04,0x00,0x30,0x00,0x00,0x80,0x48,0x02,0x02, 0x00,0x01,0xc0,0x04,0xc0,0x02,0xc0,0x00,0x0b,0x61,0x73,0x73,0x65,0x72,0x74,0x0b, 0x75,0x6e,0x70,0x61,0x63,0x6b,0x0a,0x63,0x68,0x61,0x69,0x6e,0x0b,0x72,0x65,0x6d, 0x6f,0x76,0x65,0x07,0x80,0x80,0xc0,0x99,0x04,0x53,0x00,0x02,0x08,0x00,0x00,0x00, 0x13,0x10,0x02,0x00,0x00,0x3e,0x02,0x01,0x03,0x10,0x04,0x01,0x00,0x10,0x05,0x02, 0x00,0x10,0x06,0x03,0x00,0x3e,0x04,0x03,0x03,0x0f,0x00,0x02,0x00,0x54,0x06,0x05, 0x80,0x0f,0x00,0x04,0x00,0x54,0x06,0x03,0x80,0x27,0x06,0x01,0x00,0x48,0x06,0x02, 0x00,0x54,0x06,0x05,0x80,0x29,0x06,0x00,0x00,0x0c,0x07,0x03,0x00,0x54,0x07,0x01, 0x80,0x10,0x07,0x05,0x00,0x46,0x06,0x03,0x00,0x47,0x00,0x01,0x00,0x83,0x01,0x00, 0x03,0x07,0x02,0x02,0x00,0x1b,0x2b,0x03,0x00,0x00,0x37,0x03,0x00,0x03,0x0d,0x04, 0x00,0x00,0x54,0x04,0x01,0x80,0x10,0x04,0x01,0x00,0x3e,0x03,0x02,0x01,0x0e,0x00, 0x02,0x00,0x54,0x03,0x02,0x80,0x2b,0x03,0x01,0x00,0x37,0x02,0x01,0x03,0x51,0x03, 0x0f,0x80,0x10,0x03,0x02,0x00,0x10,0x04,0x00,0x00,0x10,0x05,0x01,0x00,0x3e,0x03, 0x03,0x03,0x0e,0x00,0x03,0x00,0x54,0x05,0xf9,0x7f,0x0f,0x00,0x04,0x00,0x54,0x05, 0x04,0x80,0x29,0x05,0x00,0x00,0x10,0x06,0x04,0x00,0x46,0x05,0x03,0x00,0x54,0x05, 0xf3,0x7f,0x27,0x05,0x01,0x00,0x48,0x05,0x02,0x00,0x54,0x03,0xf0,0x7f,0x47,0x00, 0x01,0x00,0x02,0xc0,0x07,0xc0,0x09,0x73,0x74,0x65,0x70,0x0b,0x61,0x73,0x73,0x65, 0x72,0x74,0xb6,0x03,0x03,0x00,0x0b,0x00,0x2c,0x00,0x40,0x34,0x00,0x00,0x00,0x25, 0x01,0x01,0x00,0x3e,0x00,0x02,0x02,0x34,0x01,0x00,0x00,0x25,0x02,0x02,0x00,0x3e, 0x01,0x02,0x02,0x34,0x02,0x03,0x00,0x32,0x03,0x00,0x00,0x34,0x04,0x04,0x00,0x0f, 0x00,0x04,0x00,0x54,0x05,0x01,0x80,0x35,0x03,0x05,0x00,0x32,0x04,0x00,0x00,0x32, 0x05,0x00,0x00,0x32,0x06,0x00,0x00,0x32,0x07,0x00,0x00,0x3a,0x04,0x06,0x03,0x3a, 0x05,0x07,0x03,0x3a,0x06,0x08,0x03,0x3a,0x07,0x09,0x03,0x27,0x08,0x00,0x08,0x3a, 0x08,0x0a,0x03,0x25,0x08,0x0c,0x00,0x3a,0x08,0x0b,0x03,0x31,0x08,0x0e,0x00,0x3a, 0x08,0x0d,0x04,0x31,0x08,0x10,0x00,0x3a,0x08,0x0f,0x04,0x31,0x08,0x11,0x00,0x31, 0x09,0x13,0x00,0x3a,0x09,0x12,0x05,0x31,0x09,0x15,0x00,0x3a,0x09,0x14,0x05,0x31, 0x09,0x17,0x00,0x3a,0x09,0x16,0x05,0x31,0x09,0x19,0x00,0x3a,0x09,0x18,0x05,0x31, 0x09,0x1a,0x00,0x3a,0x09,0x01,0x05,0x31,0x09,0x1c,0x00,0x3a,0x09,0x1b,0x05,0x31, 0x09,0x1d,0x00,0x3a,0x09,0x0f,0x05,0x31,0x09,0x1f,0x00,0x3a,0x09,0x1e,0x05,0x31, 0x09,0x20,0x00,0x3a,0x09,0x02,0x06,0x31,0x09,0x21,0x00,0x3a,0x09,0x18,0x06,0x31, 0x09,0x22,0x00,0x3a,0x09,0x16,0x06,0x31,0x09,0x23,0x00,0x31,0x0a,0x25,0x00,0x3a, 0x0a,0x24,0x06,0x31,0x0a,0x26,0x00,0x3a,0x0a,0x14,0x06,0x31,0x0a,0x27,0x00,0x3a, 0x0a,0x0f,0x06,0x31,0x0a,0x29,0x00,0x3a,0x0a,0x28,0x07,0x31,0x0a,0x2b,0x00,0x3a, 0x0a,0x2a,0x07,0x30,0x00,0x00,0x80,0x48,0x03,0x02,0x00,0x00,0x08,0x61,0x6c,0x6c, 0x00,0x09,0x73,0x74,0x65,0x70,0x00,0x00,0x00,0x09,0x6e,0x75,0x6c,0x6c,0x00,0x00, 0x00,0x00,0x00,0x08,0x63,0x61,0x74,0x00,0x00,0x0b,0x72,0x65,0x77,0x69,0x6e,0x64, 0x00,0x00,0x0d,0x73,0x69,0x6d,0x70,0x6c,0x69,0x66,0x79,0x00,0x09,0x66,0x69,0x6c, 0x65,0x00,0x0a,0x65,0x72,0x72,0x6f,0x72,0x00,0x0a,0x65,0x6d,0x70,0x74,0x79,0x00, 0x00,0x0a,0x63,0x68,0x61,0x69,0x6e,0x00,0x0a,0x63,0x79,0x63,0x6c,0x65,0x10,0x4c, 0x54,0x4e,0x31,0x32,0x20,0x31,0x2e,0x30,0x2e,0x33,0x0d,0x5f,0x56,0x45,0x52,0x53, 0x49,0x4f,0x4e,0x0e,0x42,0x4c,0x4f,0x43,0x4b,0x53,0x49,0x5a,0x45,0x09,0x70,0x75, 0x6d,0x70,0x09,0x73,0x69,0x6e,0x6b,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0x0b,0x66, 0x69,0x6c,0x74,0x65,0x72,0x0a,0x6c,0x74,0x6e,0x31,0x32,0x0b,0x6d,0x6f,0x64,0x75, 0x6c,0x65,0x07,0x5f,0x47,0x0a,0x74,0x61,0x62,0x6c,0x65,0x0b,0x73,0x74,0x72,0x69, 0x6e,0x67,0x0c,0x72,0x65,0x71,0x75,0x69,0x72,0x65,0x00, }; /* mime, mime.lua */ static const char lua_m_mime[] = { 0x1b,0x4c,0x4a,0x01,0x02,0xce,0x01,0x00,0x03,0x08,0x02,0x08,0x00,0x23,0x2b,0x03, 0x00,0x00,0x37,0x03,0x00,0x03,0x10,0x04,0x00,0x00,0x3e,0x03,0x02,0x02,0x06,0x03, 0x01,0x00,0x54,0x03,0x05,0x80,0x25,0x03,0x02,0x00,0x10,0x04,0x00,0x00,0x10,0x02, 0x01,0x00,0x10,0x01,0x04,0x00,0x10,0x00,0x03,0x00,0x2b,0x03,0x01,0x00,0x0c,0x04, 0x00,0x00,0x54,0x04,0x01,0x80,0x25,0x04,0x03,0x00,0x36,0x03,0x04,0x03,0x0e,0x00, 0x03,0x00,0x54,0x04,0x0c,0x80,0x2b,0x04,0x00,0x00,0x37,0x04,0x04,0x04,0x25,0x05, 0x05,0x00,0x2b,0x06,0x00,0x00,0x37,0x06,0x06,0x06,0x10,0x07,0x00,0x00,0x3e,0x06, 0x02,0x02,0x25,0x07,0x07,0x00,0x24,0x05,0x07,0x05,0x27,0x06,0x03,0x00,0x3e,0x04, 0x03,0x01,0x54,0x04,0x04,0x80,0x10,0x04,0x03,0x00,0x10,0x05,0x01,0x00,0x10,0x06, 0x02,0x00,0x40,0x04,0x03,0x00,0x47,0x00,0x01,0x00,0x00,0x00,0x00,0xc0,0x06,0x29, 0x0d,0x74,0x6f,0x73,0x74,0x72,0x69,0x6e,0x67,0x12,0x75,0x6e,0x6b,0x6e,0x6f,0x77, 0x6e,0x20,0x6b,0x65,0x79,0x20,0x28,0x0a,0x65,0x72,0x72,0x6f,0x72,0x08,0x6e,0x69, 0x6c,0x0c,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67, 0x09,0x74,0x79,0x70,0x65,0x16,0x01,0x01,0x02,0x01,0x01,0x00,0x03,0x31,0x01,0x00, 0x00,0x30,0x00,0x00,0x80,0x48,0x01,0x02,0x00,0x00,0xc0,0x00,0x39,0x00,0x00,0x03, 0x02,0x04,0x00,0x07,0x2b,0x00,0x00,0x00,0x37,0x00,0x00,0x00,0x37,0x00,0x01,0x00, 0x2b,0x01,0x01,0x00,0x37,0x01,0x02,0x01,0x25,0x02,0x03,0x00,0x40,0x00,0x03,0x00, 0x01,0xc0,0x05,0xc0,0x05,0x08,0x62,0x36,0x34,0x0a,0x63,0x79,0x63,0x6c,0x65,0x0b, 0x66,0x69,0x6c,0x74,0x65,0x72,0x5d,0x00,0x01,0x05,0x02,0x07,0x00,0x0c,0x2b,0x01, 0x00,0x00,0x37,0x01,0x00,0x01,0x37,0x01,0x01,0x01,0x2b,0x02,0x01,0x00,0x37,0x02, 0x02,0x02,0x25,0x03,0x03,0x00,0x07,0x00,0x04,0x00,0x54,0x04,0x02,0x80,0x25,0x04, 0x05,0x00,0x54,0x05,0x01,0x80,0x25,0x04,0x06,0x00,0x40,0x01,0x04,0x00,0x01,0xc0, 0x05,0xc0,0x07,0x0d,0x0a,0x0b,0x3d,0x30,0x44,0x3d,0x30,0x41,0x0b,0x62,0x69,0x6e, 0x61,0x72,0x79,0x05,0x07,0x71,0x70,0x0a,0x63,0x79,0x63,0x6c,0x65,0x0b,0x66,0x69, 0x6c,0x74,0x65,0x72,0x3b,0x00,0x00,0x03,0x02,0x04,0x00,0x07,0x2b,0x00,0x00,0x00, 0x37,0x00,0x00,0x00,0x37,0x00,0x01,0x00,0x2b,0x01,0x01,0x00,0x37,0x01,0x02,0x01, 0x25,0x02,0x03,0x00,0x40,0x00,0x03,0x00,0x01,0xc0,0x05,0xc0,0x05,0x0a,0x75,0x6e, 0x62,0x36,0x34,0x0a,0x63,0x79,0x63,0x6c,0x65,0x0b,0x66,0x69,0x6c,0x74,0x65,0x72, 0x3a,0x00,0x00,0x03,0x02,0x04,0x00,0x07,0x2b,0x00,0x00,0x00,0x37,0x00,0x00,0x00, 0x37,0x00,0x01,0x00,0x2b,0x01,0x01,0x00,0x37,0x01,0x02,0x01,0x25,0x02,0x03,0x00, 0x40,0x00,0x03,0x00,0x01,0xc0,0x05,0xc0,0x05,0x09,0x75,0x6e,0x71,0x70,0x0a,0x63, 0x79,0x63,0x6c,0x65,0x0b,0x66,0x69,0x6c,0x74,0x65,0x72,0x51,0x00,0x01,0x03,0x01, 0x04,0x00,0x0f,0x0f,0x00,0x00,0x00,0x54,0x01,0x0a,0x80,0x07,0x00,0x00,0x00,0x54, 0x01,0x03,0x80,0x25,0x01,0x01,0x00,0x48,0x01,0x02,0x00,0x54,0x01,0x07,0x80,0x2b, 0x01,0x00,0x00,0x37,0x01,0x02,0x01,0x10,0x02,0x00,0x00,0x40,0x01,0x02,0x00,0x54, 0x01,0x02,0x80,0x25,0x01,0x03,0x00,0x48,0x01,0x02,0x00,0x47,0x00,0x01,0x00,0x04, 0xc0,0x08,0x6e,0x69,0x6c,0x08,0x6c,0x65,0x6e,0x07,0x27,0x27,0x05,0x48,0x00,0x01, 0x05,0x02,0x03,0x00,0x0b,0x0e,0x00,0x00,0x00,0x54,0x01,0x01,0x80,0x27,0x00,0x4c, 0x00,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x37,0x01,0x01,0x01,0x2b,0x02,0x01, 0x00,0x37,0x02,0x02,0x02,0x10,0x03,0x00,0x00,0x10,0x04,0x00,0x00,0x40,0x01,0x04, 0x00,0x01,0xc0,0x05,0xc0,0x08,0x77,0x72,0x70,0x0a,0x63,0x79,0x63,0x6c,0x65,0x0b, 0x66,0x69,0x6c,0x74,0x65,0x72,0x3e,0x00,0x00,0x04,0x02,0x03,0x00,0x08,0x2b,0x00, 0x00,0x00,0x37,0x00,0x00,0x00,0x37,0x00,0x01,0x00,0x2b,0x01,0x01,0x00,0x37,0x01, 0x02,0x01,0x27,0x02,0x4c,0x00,0x27,0x03,0x4c,0x00,0x40,0x00,0x04,0x00,0x01,0xc0, 0x05,0xc0,0x0a,0x71,0x70,0x77,0x72,0x70,0x0a,0x63,0x79,0x63,0x6c,0x65,0x0b,0x66, 0x69,0x6c,0x74,0x65,0x72,0x3c,0x00,0x01,0x05,0x02,0x03,0x00,0x08,0x2b,0x01,0x00, 0x00,0x37,0x01,0x00,0x01,0x37,0x01,0x01,0x01,0x2b,0x02,0x01,0x00,0x37,0x02,0x02, 0x02,0x27,0x03,0x00,0x00,0x10,0x04,0x00,0x00,0x40,0x01,0x04,0x00,0x01,0xc0,0x05, 0xc0,0x08,0x65,0x6f,0x6c,0x0a,0x63,0x79,0x63,0x6c,0x65,0x0b,0x66,0x69,0x6c,0x74, 0x65,0x72,0x38,0x00,0x00,0x03,0x02,0x03,0x00,0x07,0x2b,0x00,0x00,0x00,0x37,0x00, 0x00,0x00,0x37,0x00,0x01,0x00,0x2b,0x01,0x01,0x00,0x37,0x01,0x02,0x01,0x27,0x02, 0x02,0x00,0x40,0x00,0x03,0x00,0x01,0xc0,0x05,0xc0,0x08,0x64,0x6f,0x74,0x0a,0x63, 0x79,0x63,0x6c,0x65,0x0b,0x66,0x69,0x6c,0x74,0x65,0x72,0xf4,0x02,0x03,0x00,0x0d, 0x00,0x1c,0x00,0x38,0x34,0x00,0x00,0x00,0x34,0x01,0x01,0x00,0x25,0x02,0x02,0x00, 0x3e,0x01,0x02,0x02,0x34,0x02,0x01,0x00,0x25,0x03,0x03,0x00,0x3e,0x02,0x02,0x02, 0x34,0x03,0x01,0x00,0x25,0x04,0x04,0x00,0x3e,0x03,0x02,0x02,0x34,0x04,0x01,0x00, 0x25,0x05,0x05,0x00,0x3e,0x04,0x02,0x02,0x10,0x05,0x02,0x00,0x32,0x06,0x00,0x00, 0x32,0x07,0x00,0x00,0x32,0x08,0x00,0x00,0x3a,0x06,0x06,0x05,0x3a,0x07,0x07,0x05, 0x3a,0x08,0x08,0x05,0x31,0x09,0x09,0x00,0x31,0x0a,0x0b,0x00,0x3a,0x0a,0x0a,0x06, 0x31,0x0a,0x0d,0x00,0x3a,0x0a,0x0c,0x06,0x31,0x0a,0x0e,0x00,0x3a,0x0a,0x0a,0x07, 0x31,0x0a,0x0f,0x00,0x3a,0x0a,0x0c,0x07,0x31,0x0a,0x10,0x00,0x31,0x0b,0x12,0x00, 0x3a,0x0b,0x11,0x08,0x37,0x0b,0x11,0x08,0x3a,0x0b,0x0a,0x08,0x37,0x0b,0x11,0x08, 0x3a,0x0b,0x13,0x08,0x31,0x0b,0x14,0x00,0x3a,0x0b,0x0c,0x08,0x10,0x0b,0x09,0x00, 0x10,0x0c,0x06,0x00,0x3e,0x0b,0x02,0x02,0x3a,0x0b,0x15,0x05,0x10,0x0b,0x09,0x00, 0x10,0x0c,0x07,0x00,0x3e,0x0b,0x02,0x02,0x3a,0x0b,0x16,0x05,0x10,0x0b,0x09,0x00, 0x10,0x0c,0x08,0x00,0x3e,0x0b,0x02,0x02,0x3a,0x0b,0x17,0x05,0x31,0x0b,0x19,0x00, 0x3a,0x0b,0x18,0x05,0x31,0x0b,0x1b,0x00,0x3a,0x0b,0x1a,0x05,0x30,0x00,0x00,0x80, 0x48,0x05,0x02,0x00,0x00,0x0a,0x73,0x74,0x75,0x66,0x66,0x00,0x0e,0x6e,0x6f,0x72, 0x6d,0x61,0x6c,0x69,0x7a,0x65,0x09,0x77,0x72,0x61,0x70,0x0b,0x64,0x65,0x63,0x6f, 0x64,0x65,0x0b,0x65,0x6e,0x63,0x6f,0x64,0x65,0x00,0x0c,0x64,0x65,0x66,0x61,0x75, 0x6c,0x74,0x00,0x09,0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x00,0x15,0x71,0x75,0x6f, 0x74,0x65,0x64,0x2d,0x70,0x72,0x69,0x6e,0x74,0x61,0x62,0x6c,0x65,0x00,0x0b,0x62, 0x61,0x73,0x65,0x36,0x34,0x00,0x0a,0x77,0x72,0x61,0x70,0x74,0x0c,0x64,0x65,0x63, 0x6f,0x64,0x65,0x74,0x0c,0x65,0x6e,0x63,0x6f,0x64,0x65,0x74,0x0b,0x73,0x74,0x72, 0x69,0x6e,0x67,0x07,0x69,0x6f,0x0e,0x6d,0x69,0x6d,0x65,0x2e,0x63,0x6f,0x72,0x65, 0x0a,0x6c,0x74,0x6e,0x31,0x32,0x0c,0x72,0x65,0x71,0x75,0x69,0x72,0x65,0x07,0x5f, 0x47,0x00, }; /* socket.ftp, socket/ftp.lua */ static const char lua_m_socket_ftp[] = { 0x1b,0x4c,0x4a,0x01,0x02,0x23,0x00,0x00,0x02,0x01,0x01,0x00,0x05,0x2b,0x00,0x00, 0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x3e,0x00,0x02,0x01,0x47,0x00,0x01, 0x00,0x04,0xc0,0x0a,0x63,0x6c,0x6f,0x73,0x65,0xb1,0x01,0x01,0x03,0x09,0x05,0x09, 0x00,0x1b,0x2b,0x03,0x00,0x00,0x37,0x03,0x00,0x03,0x2b,0x04,0x01,0x00,0x37,0x04, 0x01,0x04,0x10,0x05,0x00,0x00,0x0c,0x06,0x01,0x00,0x54,0x06,0x02,0x80,0x2b,0x06, 0x02,0x00,0x37,0x06,0x02,0x06,0x2b,0x07,0x02,0x00,0x37,0x07,0x03,0x07,0x10,0x08, 0x02,0x00,0x3e,0x04,0x05,0x00,0x3d,0x03,0x00,0x02,0x2b,0x04,0x03,0x00,0x37,0x04, 0x04,0x04,0x33,0x05,0x05,0x00,0x3a,0x03,0x06,0x05,0x2b,0x06,0x04,0x00,0x3e,0x04, 0x03,0x02,0x2b,0x05,0x00,0x00,0x37,0x05,0x07,0x05,0x31,0x06,0x08,0x00,0x3e,0x05, 0x02,0x02,0x3a,0x05,0x00,0x04,0x30,0x00,0x00,0x80,0x48,0x04,0x02,0x00,0x04,0xc0, 0x06,0xc0,0x08,0xc0,0x00,0xc0,0x09,0xc0,0x00,0x0b,0x6e,0x65,0x77,0x74,0x72,0x79, 0x07,0x74,0x70,0x01,0x00,0x00,0x11,0x73,0x65,0x74,0x6d,0x65,0x74,0x61,0x74,0x61, 0x62,0x6c,0x65,0x0c,0x54,0x49,0x4d,0x45,0x4f,0x55,0x54,0x09,0x50,0x4f,0x52,0x54, 0x0c,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x08,0x74,0x72,0x79,0x93,0x01,0x00,0x01, 0x05,0x01,0x06,0x00,0x18,0x37,0x01,0x00,0x00,0x37,0x02,0x01,0x00,0x10,0x03,0x02, 0x00,0x37,0x02,0x02,0x02,0x2b,0x04,0x00,0x00,0x37,0x04,0x03,0x04,0x3e,0x02,0x03, 0x00,0x3d,0x01,0x00,0x01,0x37,0x01,0x00,0x00,0x37,0x02,0x01,0x00,0x10,0x03,0x02, 0x00,0x37,0x02,0x05,0x02,0x3e,0x02,0x02,0x00,0x3d,0x01,0x00,0x02,0x3a,0x01,0x04, 0x00,0x37,0x01,0x00,0x00,0x37,0x02,0x04,0x00,0x10,0x03,0x02,0x00,0x37,0x02,0x02, 0x02,0x2b,0x04,0x00,0x00,0x37,0x04,0x03,0x04,0x3e,0x02,0x03,0x00,0x3d,0x01,0x00, 0x01,0x47,0x00,0x01,0x00,0x08,0xc0,0x0b,0x61,0x63,0x63,0x65,0x70,0x74,0x09,0x64, 0x61,0x74,0x61,0x0c,0x54,0x49,0x4d,0x45,0x4f,0x55,0x54,0x0f,0x73,0x65,0x74,0x74, 0x69,0x6d,0x65,0x6f,0x75,0x74,0x0b,0x73,0x65,0x72,0x76,0x65,0x72,0x08,0x74,0x72, 0x79,0xa5,0x01,0x00,0x01,0x06,0x02,0x09,0x00,0x19,0x37,0x01,0x01,0x00,0x2b,0x02, 0x00,0x00,0x37,0x02,0x02,0x02,0x3e,0x02,0x01,0x00,0x3d,0x01,0x00,0x02,0x3a,0x01, 0x00,0x00,0x37,0x01,0x01,0x00,0x37,0x02,0x00,0x00,0x10,0x03,0x02,0x00,0x37,0x02, 0x03,0x02,0x2b,0x04,0x01,0x00,0x37,0x04,0x04,0x04,0x3e,0x02,0x03,0x00,0x3d,0x01, 0x00,0x01,0x37,0x01,0x01,0x00,0x37,0x02,0x00,0x00,0x10,0x03,0x02,0x00,0x37,0x02, 0x05,0x02,0x37,0x04,0x06,0x00,0x37,0x04,0x07,0x04,0x37,0x05,0x06,0x00,0x37,0x05, 0x08,0x05,0x3e,0x02,0x04,0x00,0x3d,0x01,0x00,0x01,0x47,0x00,0x01,0x00,0x04,0xc0, 0x08,0xc0,0x09,0x70,0x6f,0x72,0x74,0x07,0x69,0x70,0x0a,0x70,0x61,0x73,0x76,0x74, 0x0c,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x0c,0x54,0x49,0x4d,0x45,0x4f,0x55,0x54, 0x0f,0x73,0x65,0x74,0x74,0x69,0x6d,0x65,0x6f,0x75,0x74,0x08,0x74,0x63,0x70,0x08, 0x74,0x72,0x79,0x09,0x64,0x61,0x74,0x61,0xe7,0x01,0x00,0x03,0x0a,0x01,0x0a,0x01, 0x28,0x37,0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x02, 0x04,0x25,0x06,0x03,0x00,0x0c,0x07,0x01,0x00,0x54,0x07,0x02,0x80,0x2b,0x07,0x00, 0x00,0x37,0x07,0x04,0x07,0x3e,0x04,0x04,0x00,0x3d,0x03,0x00,0x01,0x37,0x03,0x00, 0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x05,0x04,0x33,0x06,0x06, 0x00,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x03,0x09,0x03,0x00,0x00,0x54,0x05,0x12, 0x80,0x37,0x05,0x00,0x00,0x37,0x06,0x01,0x00,0x10,0x07,0x06,0x00,0x37,0x06,0x02, 0x06,0x25,0x08,0x07,0x00,0x0c,0x09,0x02,0x00,0x54,0x09,0x02,0x80,0x2b,0x09,0x00, 0x00,0x37,0x09,0x08,0x09,0x3e,0x06,0x04,0x00,0x3d,0x05,0x00,0x01,0x37,0x05,0x00, 0x00,0x37,0x06,0x01,0x00,0x10,0x07,0x06,0x00,0x37,0x06,0x05,0x06,0x25,0x08,0x09, 0x00,0x3e,0x06,0x03,0x00,0x3d,0x05,0x00,0x01,0x27,0x05,0x01,0x00,0x48,0x05,0x02, 0x00,0x08,0xc0,0x08,0x32,0x2e,0x2e,0x0d,0x50,0x41,0x53,0x53,0x57,0x4f,0x52,0x44, 0x09,0x70,0x61,0x73,0x73,0x01,0x03,0x00,0x00,0x08,0x32,0x2e,0x2e,0x03,0xcb,0x02, 0x0a,0x63,0x68,0x65,0x63,0x6b,0x09,0x55,0x53,0x45,0x52,0x09,0x75,0x73,0x65,0x72, 0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x96, 0x05,0x97,0x03,0x00,0x01,0x11,0x02,0x11,0x01,0x42,0x37,0x01,0x00,0x00,0x37,0x02, 0x01,0x00,0x10,0x03,0x02,0x00,0x37,0x02,0x02,0x02,0x25,0x04,0x03,0x00,0x3e,0x02, 0x03,0x00,0x3d,0x01,0x00,0x01,0x37,0x01,0x00,0x00,0x37,0x02,0x01,0x00,0x10,0x03, 0x02,0x00,0x37,0x02,0x04,0x02,0x25,0x04,0x05,0x00,0x3e,0x02,0x03,0x00,0x3d,0x01, 0x00,0x03,0x25,0x03,0x06,0x00,0x2b,0x04,0x00,0x00,0x37,0x04,0x07,0x04,0x27,0x05, 0x02,0x00,0x2b,0x06,0x01,0x00,0x37,0x06,0x08,0x06,0x10,0x07,0x02,0x00,0x10,0x08, 0x03,0x00,0x3e,0x06,0x03,0x00,0x3d,0x04,0x01,0x07,0x37,0x0a,0x00,0x00,0x0d,0x0b, 0x04,0x00,0x54,0x0b,0x09,0x80,0x0d,0x0b,0x05,0x00,0x54,0x0b,0x07,0x80,0x0d,0x0b, 0x06,0x00,0x54,0x0b,0x05,0x80,0x0d,0x0b,0x07,0x00,0x54,0x0b,0x03,0x80,0x0d,0x0b, 0x08,0x00,0x54,0x0b,0x01,0x80,0x10,0x0b,0x09,0x00,0x10,0x0c,0x02,0x00,0x3e,0x0a, 0x03,0x01,0x33,0x0a,0x0c,0x00,0x2b,0x0b,0x01,0x00,0x37,0x0b,0x0a,0x0b,0x25,0x0c, 0x0b,0x00,0x10,0x0d,0x04,0x00,0x10,0x0e,0x05,0x00,0x10,0x0f,0x06,0x00,0x10,0x10, 0x07,0x00,0x3e,0x0b,0x06,0x02,0x3a,0x0b,0x0d,0x0a,0x16,0x0b,0x00,0x08,0x1e,0x0b, 0x09,0x0b,0x3a,0x0b,0x0e,0x0a,0x3a,0x0a,0x09,0x00,0x37,0x0a,0x0f,0x00,0x0f,0x00, 0x0a,0x00,0x54,0x0b,0x06,0x80,0x37,0x0a,0x0f,0x00,0x10,0x0b,0x0a,0x00,0x37,0x0a, 0x10,0x0a,0x3e,0x0a,0x02,0x01,0x29,0x0a,0x00,0x00,0x3a,0x0a,0x0f,0x00,0x37,0x0a, 0x09,0x00,0x37,0x0a,0x0d,0x0a,0x37,0x0b,0x09,0x00,0x37,0x0b,0x0e,0x0b,0x46,0x0a, 0x03,0x00,0x04,0xc0,0x02,0xc0,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x0b,0x73,0x65,0x72, 0x76,0x65,0x72,0x09,0x70,0x6f,0x72,0x74,0x07,0x69,0x70,0x01,0x00,0x00,0x10,0x25, 0x64,0x2e,0x25,0x64,0x2e,0x25,0x64,0x2e,0x25,0x64,0x0b,0x66,0x6f,0x72,0x6d,0x61, 0x74,0x0a,0x70,0x61,0x73,0x76,0x74,0x09,0x66,0x69,0x6e,0x64,0x09,0x73,0x6b,0x69, 0x70,0x2d,0x28,0x25,0x64,0x2b,0x29,0x25,0x44,0x28,0x25,0x64,0x2b,0x29,0x25,0x44, 0x28,0x25,0x64,0x2b,0x29,0x25,0x44,0x28,0x25,0x64,0x2b,0x29,0x25,0x44,0x28,0x25, 0x64,0x2b,0x29,0x25,0x44,0x28,0x25,0x64,0x2b,0x29,0x08,0x32,0x2e,0x2e,0x0a,0x63, 0x68,0x65,0x63,0x6b,0x09,0x70,0x61,0x73,0x76,0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e, 0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x80,0x04,0xb5,0x03,0x00,0x03,0x0b,0x04, 0x13,0x01,0x4b,0x29,0x03,0x00,0x00,0x3a,0x03,0x00,0x00,0x0e,0x00,0x01,0x00,0x54, 0x03,0x23,0x80,0x37,0x03,0x01,0x00,0x37,0x04,0x02,0x00,0x10,0x05,0x04,0x00,0x37, 0x04,0x03,0x04,0x3e,0x04,0x02,0x02,0x10,0x05,0x04,0x00,0x37,0x04,0x04,0x04,0x3e, 0x04,0x02,0x00,0x3d,0x03,0x00,0x03,0x10,0x02,0x04,0x00,0x10,0x01,0x03,0x00,0x37, 0x03,0x01,0x00,0x2b,0x04,0x00,0x00,0x37,0x04,0x06,0x04,0x10,0x05,0x01,0x00,0x27, 0x06,0x00,0x00,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x02,0x3a,0x03,0x05,0x00,0x37, 0x03,0x01,0x00,0x37,0x04,0x05,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x04,0x04,0x3e, 0x04,0x02,0x00,0x3d,0x03,0x00,0x03,0x10,0x02,0x04,0x00,0x10,0x01,0x03,0x00,0x37, 0x03,0x01,0x00,0x37,0x04,0x05,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x07,0x04,0x2b, 0x06,0x01,0x00,0x37,0x06,0x08,0x06,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x01,0x2b, 0x03,0x02,0x00,0x37,0x03,0x09,0x03,0x10,0x04,0x02,0x00,0x27,0x05,0x00,0x01,0x3e, 0x03,0x03,0x02,0x1f,0x04,0x03,0x02,0x17,0x04,0x00,0x04,0x2b,0x05,0x03,0x00,0x37, 0x05,0x0a,0x05,0x2b,0x06,0x03,0x00,0x37,0x06,0x0b,0x06,0x25,0x07,0x0c,0x00,0x10, 0x08,0x01,0x00,0x10,0x09,0x04,0x00,0x10,0x0a,0x03,0x00,0x3e,0x06,0x05,0x02,0x25, 0x07,0x0d,0x00,0x25,0x08,0x0e,0x00,0x3e,0x05,0x04,0x02,0x37,0x06,0x01,0x00,0x37, 0x07,0x02,0x00,0x10,0x08,0x07,0x00,0x37,0x07,0x0f,0x07,0x25,0x09,0x10,0x00,0x10, 0x0a,0x05,0x00,0x3e,0x07,0x04,0x00,0x3d,0x06,0x00,0x01,0x37,0x06,0x01,0x00,0x37, 0x07,0x02,0x00,0x10,0x08,0x07,0x00,0x37,0x07,0x11,0x07,0x25,0x09,0x12,0x00,0x3e, 0x07,0x03,0x00,0x3d,0x06,0x00,0x01,0x27,0x06,0x01,0x00,0x48,0x06,0x02,0x00,0x04, 0xc0,0x08,0xc0,0x03,0xc0,0x02,0xc0,0x08,0x32,0x2e,0x2e,0x0a,0x63,0x68,0x65,0x63, 0x6b,0x09,0x70,0x6f,0x72,0x74,0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x06,0x2c, 0x07,0x25,0x2e,0x0d,0x25,0x73,0x2c,0x25,0x64,0x2c,0x25,0x64,0x0b,0x66,0x6f,0x72, 0x6d,0x61,0x74,0x09,0x67,0x73,0x75,0x62,0x08,0x6d,0x6f,0x64,0x0c,0x54,0x49,0x4d, 0x45,0x4f,0x55,0x54,0x0f,0x73,0x65,0x74,0x74,0x69,0x6d,0x65,0x6f,0x75,0x74,0x09, 0x62,0x69,0x6e,0x64,0x0b,0x73,0x65,0x72,0x76,0x65,0x72,0x10,0x67,0x65,0x74,0x73, 0x6f,0x63,0x6b,0x6e,0x61,0x6d,0x65,0x0f,0x67,0x65,0x74,0x63,0x6f,0x6e,0x74,0x72, 0x6f,0x6c,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x0a,0x70,0x61,0x73,0x76,0x74,0x80, 0x04,0x8b,0x01,0x00,0x02,0x07,0x06,0x05,0x00,0x18,0x2b,0x02,0x00,0x00,0x37,0x02, 0x00,0x02,0x2b,0x03,0x01,0x00,0x29,0x04,0x00,0x00,0x27,0x05,0x00,0x00,0x3e,0x02, 0x04,0x02,0x2b,0x03,0x02,0x00,0x36,0x03,0x03,0x02,0x0f,0x00,0x03,0x00,0x54,0x04, 0x0a,0x80,0x2b,0x03,0x04,0x00,0x37,0x03,0x01,0x03,0x2b,0x04,0x04,0x00,0x37,0x04, 0x02,0x04,0x10,0x05,0x04,0x00,0x37,0x04,0x03,0x04,0x25,0x06,0x04,0x00,0x3e,0x04, 0x03,0x00,0x3d,0x03,0x00,0x02,0x2c,0x03,0x03,0x00,0x2b,0x03,0x05,0x00,0x10,0x04, 0x00,0x00,0x10,0x05,0x01,0x00,0x40,0x03,0x03,0x00,0x03,0x00,0x07,0xc0,0x04,0x00, 0x04,0x80,0x00,0xc0,0x06,0xc0,0x08,0x32,0x2e,0x2e,0x0a,0x63,0x68,0x65,0x63,0x6b, 0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x0b,0x73,0x65,0x6c,0x65,0x63,0x74,0xa6,0x05, 0x01,0x02,0x0f,0x05,0x20,0x00,0x6f,0x37,0x02,0x00,0x00,0x37,0x03,0x01,0x00,0x0e, 0x00,0x03,0x00,0x54,0x04,0x01,0x80,0x37,0x03,0x02,0x00,0x25,0x04,0x03,0x00,0x3e, 0x02,0x03,0x01,0x37,0x02,0x01,0x00,0x0f,0x00,0x02,0x00,0x54,0x03,0x03,0x80,0x10, 0x03,0x00,0x00,0x37,0x02,0x04,0x00,0x3e,0x02,0x02,0x01,0x37,0x02,0x05,0x01,0x0e, 0x00,0x02,0x00,0x54,0x03,0x0c,0x80,0x2b,0x02,0x00,0x00,0x37,0x02,0x06,0x02,0x2b, 0x03,0x01,0x00,0x37,0x03,0x07,0x03,0x37,0x04,0x08,0x01,0x0e,0x00,0x04,0x00,0x54, 0x05,0x01,0x80,0x25,0x04,0x09,0x00,0x25,0x05,0x0a,0x00,0x25,0x06,0x09,0x00,0x3e, 0x03,0x04,0x00,0x3d,0x02,0x00,0x02,0x07,0x02,0x09,0x00,0x54,0x03,0x01,0x80,0x29, 0x02,0x00,0x00,0x37,0x03,0x0b,0x01,0x0e,0x00,0x03,0x00,0x54,0x04,0x01,0x80,0x25, 0x03,0x0c,0x00,0x37,0x04,0x00,0x00,0x37,0x05,0x0d,0x00,0x10,0x06,0x05,0x00,0x37, 0x05,0x0b,0x05,0x10,0x07,0x03,0x00,0x10,0x08,0x02,0x00,0x3e,0x05,0x04,0x00,0x3d, 0x04,0x00,0x01,0x37,0x04,0x00,0x00,0x37,0x05,0x0d,0x00,0x10,0x06,0x05,0x00,0x37, 0x05,0x0e,0x05,0x33,0x07,0x0f,0x00,0x3e,0x05,0x03,0x00,0x3d,0x04,0x00,0x03,0x37, 0x06,0x01,0x00,0x0e,0x00,0x06,0x00,0x54,0x06,0x03,0x80,0x10,0x07,0x00,0x00,0x37, 0x06,0x10,0x00,0x3e,0x06,0x02,0x01,0x37,0x06,0x11,0x01,0x0e,0x00,0x06,0x00,0x54, 0x07,0x03,0x80,0x2b,0x06,0x02,0x00,0x37,0x06,0x12,0x06,0x37,0x06,0x11,0x06,0x32, 0x07,0x03,0x00,0x37,0x08,0x0d,0x00,0x37,0x08,0x13,0x08,0x3b,0x08,0x01,0x07,0x31, 0x08,0x14,0x00,0x2b,0x09,0x03,0x00,0x37,0x09,0x15,0x09,0x25,0x0a,0x16,0x00,0x37, 0x0b,0x17,0x00,0x3e,0x09,0x03,0x02,0x37,0x0a,0x00,0x00,0x2b,0x0b,0x02,0x00,0x37, 0x0b,0x12,0x0b,0x37,0x0b,0x18,0x0b,0x37,0x0c,0x19,0x01,0x10,0x0d,0x09,0x00,0x10, 0x0e,0x08,0x00,0x3e,0x0b,0x04,0x00,0x3d,0x0a,0x00,0x01,0x2b,0x0a,0x01,0x00,0x37, 0x0a,0x1a,0x0a,0x10,0x0b,0x04,0x00,0x25,0x0c,0x1b,0x00,0x3e,0x0a,0x03,0x02,0x0f, 0x00,0x0a,0x00,0x54,0x0b,0x07,0x80,0x37,0x0a,0x00,0x00,0x37,0x0b,0x0d,0x00,0x10, 0x0c,0x0b,0x00,0x37,0x0b,0x0e,0x0b,0x25,0x0d,0x1c,0x00,0x3e,0x0b,0x03,0x00,0x3d, 0x0a,0x00,0x01,0x37,0x0a,0x17,0x00,0x10,0x0b,0x0a,0x00,0x37,0x0a,0x1d,0x0a,0x3e, 0x0a,0x02,0x01,0x2b,0x0a,0x03,0x00,0x37,0x0a,0x1e,0x0a,0x27,0x0b,0x01,0x00,0x37, 0x0c,0x17,0x00,0x10,0x0d,0x0c,0x00,0x37,0x0c,0x1f,0x0c,0x3e,0x0c,0x02,0x00,0x3d, 0x0a,0x01,0x02,0x29,0x0b,0x00,0x00,0x3a,0x0b,0x17,0x00,0x30,0x00,0x00,0x80,0x48, 0x0a,0x02,0x00,0x05,0xc0,0x02,0xc0,0x07,0xc0,0x04,0xc0,0x06,0xc0,0x0d,0x67,0x65, 0x74,0x73,0x74,0x61,0x74,0x73,0x09,0x73,0x6b,0x69,0x70,0x0a,0x63,0x6c,0x6f,0x73, 0x65,0x08,0x32,0x2e,0x2e,0x08,0x31,0x2e,0x2e,0x09,0x66,0x69,0x6e,0x64,0x0b,0x73, 0x6f,0x75,0x72,0x63,0x65,0x08,0x61,0x6c,0x6c,0x09,0x64,0x61,0x74,0x61,0x14,0x63, 0x6c,0x6f,0x73,0x65,0x2d,0x77,0x68,0x65,0x6e,0x2d,0x64,0x6f,0x6e,0x65,0x09,0x73, 0x69,0x6e,0x6b,0x00,0x06,0x63,0x09,0x70,0x75,0x6d,0x70,0x09,0x73,0x74,0x65,0x70, 0x10,0x70,0x6f,0x72,0x74,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x01,0x03,0x00,0x00, 0x08,0x32,0x2e,0x2e,0x08,0x31,0x2e,0x2e,0x0a,0x63,0x68,0x65,0x63,0x6b,0x07,0x74, 0x70,0x09,0x73,0x74,0x6f,0x72,0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x0a,0x5e, 0x5b,0x2f,0x5c,0x5d,0x05,0x09,0x70,0x61,0x74,0x68,0x09,0x67,0x73,0x75,0x62,0x0d, 0x75,0x6e,0x65,0x73,0x63,0x61,0x70,0x65,0x0d,0x61,0x72,0x67,0x75,0x6d,0x65,0x6e, 0x74,0x10,0x70,0x61,0x73,0x76,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x1c,0x6e,0x65, 0x65,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x6f,0x72,0x20,0x70,0x61,0x73,0x76,0x20, 0x66,0x69,0x72,0x73,0x74,0x0b,0x73,0x65,0x72,0x76,0x65,0x72,0x0a,0x70,0x61,0x73, 0x76,0x74,0x08,0x74,0x72,0x79,0x88,0x05,0x00,0x02,0x0d,0x04,0x1c,0x00,0x6d,0x37, 0x02,0x00,0x00,0x37,0x03,0x01,0x00,0x0e,0x00,0x03,0x00,0x54,0x04,0x01,0x80,0x37, 0x03,0x02,0x00,0x25,0x04,0x03,0x00,0x3e,0x02,0x03,0x01,0x37,0x02,0x01,0x00,0x0f, 0x00,0x02,0x00,0x54,0x03,0x03,0x80,0x10,0x03,0x00,0x00,0x37,0x02,0x04,0x00,0x3e, 0x02,0x02,0x01,0x37,0x02,0x05,0x01,0x0e,0x00,0x02,0x00,0x54,0x03,0x0c,0x80,0x2b, 0x02,0x00,0x00,0x37,0x02,0x06,0x02,0x2b,0x03,0x01,0x00,0x37,0x03,0x07,0x03,0x37, 0x04,0x08,0x01,0x0e,0x00,0x04,0x00,0x54,0x05,0x01,0x80,0x25,0x04,0x09,0x00,0x25, 0x05,0x0a,0x00,0x25,0x06,0x09,0x00,0x3e,0x03,0x04,0x00,0x3d,0x02,0x00,0x02,0x07, 0x02,0x09,0x00,0x54,0x03,0x01,0x80,0x29,0x02,0x00,0x00,0x37,0x03,0x0b,0x01,0x0e, 0x00,0x03,0x00,0x54,0x04,0x01,0x80,0x25,0x03,0x0c,0x00,0x37,0x04,0x00,0x00,0x37, 0x05,0x0d,0x00,0x10,0x06,0x05,0x00,0x37,0x05,0x0b,0x05,0x10,0x07,0x03,0x00,0x10, 0x08,0x02,0x00,0x3e,0x05,0x04,0x00,0x3d,0x04,0x00,0x01,0x37,0x04,0x00,0x00,0x37, 0x05,0x0d,0x00,0x10,0x06,0x05,0x00,0x37,0x05,0x0e,0x05,0x33,0x07,0x0f,0x00,0x3e, 0x05,0x03,0x00,0x3d,0x04,0x00,0x03,0x27,0x06,0xc8,0x00,0x03,0x06,0x04,0x00,0x54, 0x06,0x08,0x80,0x27,0x06,0x2b,0x01,0x03,0x04,0x06,0x00,0x54,0x06,0x05,0x80,0x37, 0x06,0x10,0x01,0x10,0x07,0x05,0x00,0x3e,0x06,0x02,0x01,0x27,0x06,0x01,0x00,0x48, 0x06,0x02,0x00,0x37,0x06,0x01,0x00,0x0e,0x00,0x06,0x00,0x54,0x06,0x03,0x80,0x10, 0x07,0x00,0x00,0x37,0x06,0x11,0x00,0x3e,0x06,0x02,0x01,0x2b,0x06,0x02,0x00,0x37, 0x06,0x12,0x06,0x25,0x07,0x13,0x00,0x37,0x08,0x14,0x00,0x3e,0x06,0x03,0x02,0x37, 0x07,0x15,0x01,0x0e,0x00,0x07,0x00,0x54,0x08,0x03,0x80,0x2b,0x07,0x03,0x00,0x37, 0x07,0x16,0x07,0x37,0x07,0x15,0x07,0x37,0x08,0x00,0x00,0x2b,0x09,0x03,0x00,0x37, 0x09,0x16,0x09,0x37,0x09,0x17,0x09,0x10,0x0a,0x06,0x00,0x37,0x0b,0x10,0x01,0x10, 0x0c,0x07,0x00,0x3e,0x09,0x04,0x00,0x3d,0x08,0x00,0x01,0x2b,0x08,0x01,0x00,0x37, 0x08,0x18,0x08,0x10,0x09,0x04,0x00,0x25,0x0a,0x19,0x00,0x3e,0x08,0x03,0x02,0x0f, 0x00,0x08,0x00,0x54,0x09,0x07,0x80,0x37,0x08,0x00,0x00,0x37,0x09,0x0d,0x00,0x10, 0x0a,0x09,0x00,0x37,0x09,0x0e,0x09,0x25,0x0b,0x1a,0x00,0x3e,0x09,0x03,0x00,0x3d, 0x08,0x00,0x01,0x37,0x08,0x14,0x00,0x10,0x09,0x08,0x00,0x37,0x08,0x1b,0x08,0x3e, 0x08,0x02,0x01,0x29,0x08,0x00,0x00,0x3a,0x08,0x14,0x00,0x27,0x08,0x01,0x00,0x48, 0x08,0x02,0x00,0x05,0xc0,0x02,0xc0,0x04,0xc0,0x07,0xc0,0x0a,0x63,0x6c,0x6f,0x73, 0x65,0x08,0x32,0x2e,0x2e,0x08,0x31,0x2e,0x2e,0x09,0x66,0x69,0x6e,0x64,0x08,0x61, 0x6c,0x6c,0x09,0x70,0x75,0x6d,0x70,0x09,0x73,0x74,0x65,0x70,0x09,0x64,0x61,0x74, 0x61,0x11,0x75,0x6e,0x74,0x69,0x6c,0x2d,0x63,0x6c,0x6f,0x73,0x65,0x64,0x0b,0x73, 0x6f,0x75,0x72,0x63,0x65,0x10,0x70,0x6f,0x72,0x74,0x63,0x6f,0x6e,0x6e,0x65,0x63, 0x74,0x09,0x73,0x69,0x6e,0x6b,0x01,0x03,0x00,0x00,0x08,0x31,0x2e,0x2e,0x08,0x32, 0x2e,0x2e,0x0a,0x63,0x68,0x65,0x63,0x6b,0x07,0x74,0x70,0x09,0x72,0x65,0x74,0x72, 0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x0a,0x5e,0x5b,0x2f,0x5c,0x5d,0x05,0x09, 0x70,0x61,0x74,0x68,0x09,0x67,0x73,0x75,0x62,0x0d,0x75,0x6e,0x65,0x73,0x63,0x61, 0x70,0x65,0x0d,0x61,0x72,0x67,0x75,0x6d,0x65,0x6e,0x74,0x10,0x70,0x61,0x73,0x76, 0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x1c,0x6e,0x65,0x65,0x64,0x20,0x70,0x6f,0x72, 0x74,0x20,0x6f,0x72,0x20,0x70,0x61,0x73,0x76,0x20,0x66,0x69,0x72,0x73,0x74,0x0b, 0x73,0x65,0x72,0x76,0x65,0x72,0x0a,0x70,0x61,0x73,0x76,0x74,0x08,0x74,0x72,0x79, 0x64,0x00,0x02,0x07,0x00,0x05,0x00,0x11,0x37,0x02,0x00,0x00,0x37,0x03,0x01,0x00, 0x10,0x04,0x03,0x00,0x37,0x03,0x02,0x03,0x25,0x05,0x03,0x00,0x10,0x06,0x01,0x00, 0x3e,0x03,0x04,0x00,0x3d,0x02,0x00,0x01,0x37,0x02,0x00,0x00,0x37,0x03,0x01,0x00, 0x10,0x04,0x03,0x00,0x37,0x03,0x04,0x03,0x27,0x05,0xfa,0x00,0x3e,0x03,0x03,0x00, 0x3d,0x02,0x00,0x01,0x27,0x02,0x01,0x00,0x48,0x02,0x02,0x00,0x0a,0x63,0x68,0x65, 0x63,0x6b,0x08,0x63,0x77,0x64,0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x07,0x74, 0x70,0x08,0x74,0x72,0x79,0x65,0x00,0x02,0x07,0x00,0x05,0x00,0x11,0x37,0x02,0x00, 0x00,0x37,0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x02,0x03,0x25,0x05,0x03, 0x00,0x10,0x06,0x01,0x00,0x3e,0x03,0x04,0x00,0x3d,0x02,0x00,0x01,0x37,0x02,0x00, 0x00,0x37,0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x04,0x03,0x27,0x05,0xc8, 0x00,0x3e,0x03,0x03,0x00,0x3d,0x02,0x00,0x01,0x27,0x02,0x01,0x00,0x48,0x02,0x02, 0x00,0x0a,0x63,0x68,0x65,0x63,0x6b,0x09,0x74,0x79,0x70,0x65,0x0c,0x63,0x6f,0x6d, 0x6d,0x61,0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x8b,0x01,0x00,0x01,0x06, 0x01,0x07,0x00,0x17,0x37,0x01,0x00,0x00,0x37,0x02,0x01,0x00,0x10,0x03,0x02,0x00, 0x37,0x02,0x02,0x02,0x33,0x04,0x03,0x00,0x3e,0x02,0x03,0x00,0x3d,0x01,0x00,0x02, 0x2b,0x02,0x00,0x00,0x37,0x02,0x04,0x02,0x10,0x03,0x01,0x00,0x25,0x04,0x05,0x00, 0x3e,0x02,0x03,0x02,0x0f,0x00,0x02,0x00,0x54,0x03,0x07,0x80,0x37,0x02,0x00,0x00, 0x37,0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x02,0x03,0x25,0x05,0x06,0x00, 0x3e,0x03,0x03,0x00,0x3d,0x02,0x00,0x01,0x27,0x02,0x01,0x00,0x48,0x02,0x02,0x00, 0x02,0xc0,0x08,0x32,0x2e,0x2e,0x08,0x31,0x2e,0x2e,0x09,0x66,0x69,0x6e,0x64,0x01, 0x03,0x00,0x00,0x08,0x31,0x2e,0x2e,0x08,0x32,0x2e,0x2e,0x0a,0x63,0x68,0x65,0x63, 0x6b,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x65,0x00,0x01,0x05,0x00,0x06,0x00,0x10, 0x37,0x01,0x00,0x00,0x37,0x02,0x01,0x00,0x10,0x03,0x02,0x00,0x37,0x02,0x02,0x02, 0x25,0x04,0x03,0x00,0x3e,0x02,0x03,0x00,0x3d,0x01,0x00,0x01,0x37,0x01,0x00,0x00, 0x37,0x02,0x01,0x00,0x10,0x03,0x02,0x00,0x37,0x02,0x04,0x02,0x25,0x04,0x05,0x00, 0x3e,0x02,0x03,0x00,0x3d,0x01,0x00,0x01,0x27,0x01,0x01,0x00,0x48,0x01,0x02,0x00, 0x08,0x32,0x2e,0x2e,0x0a,0x63,0x68,0x65,0x63,0x6b,0x09,0x71,0x75,0x69,0x74,0x0c, 0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x64,0x00, 0x01,0x03,0x00,0x04,0x00,0x12,0x37,0x01,0x00,0x00,0x0f,0x00,0x01,0x00,0x54,0x02, 0x04,0x80,0x37,0x01,0x00,0x00,0x10,0x02,0x01,0x00,0x37,0x01,0x01,0x01,0x3e,0x01, 0x02,0x01,0x37,0x01,0x02,0x00,0x0f,0x00,0x01,0x00,0x54,0x02,0x04,0x80,0x37,0x01, 0x02,0x00,0x10,0x02,0x01,0x00,0x37,0x01,0x01,0x01,0x3e,0x01,0x02,0x01,0x37,0x01, 0x03,0x00,0x10,0x02,0x01,0x00,0x37,0x01,0x01,0x01,0x40,0x01,0x02,0x00,0x07,0x74, 0x70,0x0b,0x73,0x65,0x72,0x76,0x65,0x72,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x09,0x64, 0x61,0x74,0x61,0x67,0x00,0x01,0x08,0x02,0x03,0x00,0x13,0x37,0x01,0x00,0x00,0x0f, 0x00,0x01,0x00,0x54,0x02,0x0e,0x80,0x2b,0x01,0x00,0x00,0x37,0x01,0x01,0x01,0x37, 0x02,0x00,0x00,0x3e,0x01,0x02,0x02,0x2b,0x02,0x01,0x00,0x37,0x02,0x02,0x02,0x10, 0x03,0x00,0x00,0x3e,0x02,0x02,0x04,0x54,0x05,0x01,0x80,0x39,0x06,0x05,0x01,0x41, 0x05,0x03,0x03,0x4e,0x05,0xfd,0x7f,0x48,0x01,0x02,0x00,0x54,0x01,0x01,0x80,0x48, 0x00,0x02,0x00,0x47,0x00,0x01,0x00,0x05,0xc0,0x00,0xc0,0x0a,0x70,0x61,0x69,0x72, 0x73,0x0a,0x70,0x61,0x72,0x73,0x65,0x08,0x75,0x72,0x6c,0x9c,0x02,0x00,0x01,0x06, 0x03,0x0f,0x00,0x2c,0x2b,0x01,0x00,0x00,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x02, 0x10,0x00,0x01,0x00,0x2b,0x01,0x01,0x00,0x37,0x01,0x00,0x01,0x37,0x02,0x01,0x00, 0x25,0x03,0x02,0x00,0x3e,0x01,0x03,0x01,0x2b,0x01,0x02,0x00,0x37,0x01,0x03,0x01, 0x37,0x02,0x01,0x00,0x37,0x03,0x04,0x00,0x37,0x04,0x05,0x00,0x3e,0x01,0x04,0x02, 0x10,0x03,0x01,0x00,0x37,0x02,0x06,0x01,0x3e,0x02,0x02,0x01,0x10,0x03,0x01,0x00, 0x37,0x02,0x07,0x01,0x37,0x04,0x08,0x00,0x37,0x05,0x09,0x00,0x3e,0x02,0x04,0x01, 0x37,0x02,0x0a,0x00,0x0f,0x00,0x02,0x00,0x54,0x03,0x04,0x80,0x10,0x03,0x01,0x00, 0x37,0x02,0x0a,0x01,0x37,0x04,0x0a,0x00,0x3e,0x02,0x03,0x01,0x10,0x03,0x01,0x00, 0x37,0x02,0x0b,0x01,0x3e,0x02,0x02,0x01,0x10,0x03,0x01,0x00,0x37,0x02,0x0c,0x01, 0x10,0x04,0x00,0x00,0x3e,0x02,0x03,0x02,0x10,0x04,0x01,0x00,0x37,0x03,0x0d,0x01, 0x3e,0x03,0x02,0x01,0x10,0x04,0x01,0x00,0x37,0x03,0x0e,0x01,0x3e,0x03,0x02,0x01, 0x48,0x02,0x02,0x00,0x0a,0xc0,0x04,0xc0,0x08,0xc0,0x0a,0x63,0x6c,0x6f,0x73,0x65, 0x09,0x71,0x75,0x69,0x74,0x09,0x73,0x65,0x6e,0x64,0x09,0x70,0x61,0x73,0x76,0x09, 0x74,0x79,0x70,0x65,0x0d,0x70,0x61,0x73,0x73,0x77,0x6f,0x72,0x64,0x09,0x75,0x73, 0x65,0x72,0x0a,0x6c,0x6f,0x67,0x69,0x6e,0x0a,0x67,0x72,0x65,0x65,0x74,0x0b,0x63, 0x72,0x65,0x61,0x74,0x65,0x09,0x70,0x6f,0x72,0x74,0x09,0x6f,0x70,0x65,0x6e,0x15, 0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x20,0x68,0x6f,0x73,0x74,0x6e,0x61,0x6d,0x65, 0x09,0x68,0x6f,0x73,0x74,0x08,0x74,0x72,0x79,0xe3,0x02,0x00,0x01,0x08,0x04,0x10, 0x00,0x39,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x2b,0x02,0x01,0x00,0x37,0x02, 0x01,0x02,0x10,0x03,0x00,0x00,0x2b,0x04,0x02,0x00,0x3e,0x02,0x03,0x00,0x3d,0x01, 0x00,0x02,0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02,0x37,0x03,0x02,0x01,0x06,0x03, 0x03,0x00,0x54,0x03,0x02,0x80,0x29,0x03,0x01,0x00,0x54,0x04,0x01,0x80,0x29,0x03, 0x02,0x00,0x25,0x04,0x04,0x00,0x37,0x05,0x02,0x01,0x25,0x06,0x05,0x00,0x24,0x04, 0x06,0x04,0x3e,0x02,0x03,0x01,0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02,0x37,0x03, 0x06,0x01,0x25,0x04,0x07,0x00,0x3e,0x02,0x03,0x01,0x25,0x02,0x08,0x00,0x37,0x03, 0x09,0x01,0x0f,0x00,0x03,0x00,0x54,0x04,0x1a,0x80,0x2b,0x03,0x00,0x00,0x37,0x03, 0x0b,0x03,0x27,0x04,0x02,0x00,0x2b,0x05,0x03,0x00,0x37,0x05,0x0c,0x05,0x37,0x06, 0x09,0x01,0x10,0x07,0x02,0x00,0x3e,0x05,0x03,0x00,0x3d,0x03,0x01,0x02,0x3a,0x03, 0x0a,0x01,0x2b,0x03,0x00,0x00,0x37,0x03,0x00,0x03,0x37,0x04,0x0a,0x01,0x06,0x04, 0x0d,0x00,0x54,0x04,0x05,0x80,0x37,0x04,0x0a,0x01,0x06,0x04,0x0e,0x00,0x54,0x04, 0x02,0x80,0x29,0x04,0x01,0x00,0x54,0x05,0x01,0x80,0x29,0x04,0x02,0x00,0x25,0x05, 0x0f,0x00,0x37,0x06,0x0a,0x01,0x25,0x07,0x05,0x00,0x24,0x05,0x07,0x05,0x3e,0x03, 0x03,0x01,0x48,0x01,0x02,0x00,0x04,0xc0,0x05,0xc0,0x0c,0xc0,0x02,0xc0,0x13,0x69, 0x6e,0x76,0x61,0x6c,0x69,0x64,0x20,0x74,0x79,0x70,0x65,0x20,0x27,0x06,0x69,0x06, 0x61,0x09,0x66,0x69,0x6e,0x64,0x09,0x73,0x6b,0x69,0x70,0x09,0x74,0x79,0x70,0x65, 0x0b,0x70,0x61,0x72,0x61,0x6d,0x73,0x0f,0x5e,0x74,0x79,0x70,0x65,0x3d,0x28,0x2e, 0x29,0x24,0x15,0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x20,0x68,0x6f,0x73,0x74,0x6e, 0x61,0x6d,0x65,0x09,0x68,0x6f,0x73,0x74,0x06,0x27,0x13,0x77,0x72,0x6f,0x6e,0x67, 0x20,0x73,0x63,0x68,0x65,0x6d,0x65,0x20,0x27,0x08,0x66,0x74,0x70,0x0b,0x73,0x63, 0x68,0x65,0x6d,0x65,0x0a,0x70,0x61,0x72,0x73,0x65,0x08,0x74,0x72,0x79,0x4b,0x00, 0x02,0x05,0x03,0x02,0x00,0x0c,0x2b,0x02,0x00,0x00,0x10,0x03,0x00,0x00,0x3e,0x02, 0x02,0x02,0x2b,0x03,0x01,0x00,0x37,0x03,0x00,0x03,0x37,0x03,0x01,0x03,0x10,0x04, 0x01,0x00,0x3e,0x03,0x02,0x02,0x3a,0x03,0x00,0x02,0x2b,0x03,0x02,0x00,0x10,0x04, 0x02,0x00,0x40,0x03,0x02,0x00,0x0d,0xc0,0x07,0xc0,0x0b,0xc0,0x0b,0x73,0x74,0x72, 0x69,0x6e,0x67,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0x55,0x00,0x02,0x05,0x03,0x02, 0x00,0x0f,0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02,0x10,0x03,0x00,0x00,0x3e,0x02, 0x02,0x02,0x07,0x02,0x01,0x00,0x54,0x02,0x05,0x80,0x2b,0x02,0x01,0x00,0x10,0x03, 0x00,0x00,0x10,0x04,0x01,0x00,0x40,0x02,0x03,0x00,0x54,0x02,0x03,0x80,0x2b,0x02, 0x02,0x00,0x10,0x03,0x00,0x00,0x40,0x02,0x02,0x00,0x47,0x00,0x01,0x00,0x00,0xc0, 0x0e,0xc0,0x0b,0xc0,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0x09,0x74,0x79,0x70,0x65, 0x9b,0x02,0x00,0x01,0x06,0x03,0x0f,0x00,0x2b,0x2b,0x01,0x00,0x00,0x10,0x02,0x00, 0x00,0x3e,0x01,0x02,0x02,0x10,0x00,0x01,0x00,0x2b,0x01,0x01,0x00,0x37,0x01,0x00, 0x01,0x37,0x02,0x01,0x00,0x25,0x03,0x02,0x00,0x3e,0x01,0x03,0x01,0x2b,0x01,0x02, 0x00,0x37,0x01,0x03,0x01,0x37,0x02,0x01,0x00,0x37,0x03,0x04,0x00,0x37,0x04,0x05, 0x00,0x3e,0x01,0x04,0x02,0x10,0x03,0x01,0x00,0x37,0x02,0x06,0x01,0x3e,0x02,0x02, 0x01,0x10,0x03,0x01,0x00,0x37,0x02,0x07,0x01,0x37,0x04,0x08,0x00,0x37,0x05,0x09, 0x00,0x3e,0x02,0x04,0x01,0x37,0x02,0x0a,0x00,0x0f,0x00,0x02,0x00,0x54,0x03,0x04, 0x80,0x10,0x03,0x01,0x00,0x37,0x02,0x0a,0x01,0x37,0x04,0x0a,0x00,0x3e,0x02,0x03, 0x01,0x10,0x03,0x01,0x00,0x37,0x02,0x0b,0x01,0x3e,0x02,0x02,0x01,0x10,0x03,0x01, 0x00,0x37,0x02,0x0c,0x01,0x10,0x04,0x00,0x00,0x3e,0x02,0x03,0x01,0x10,0x03,0x01, 0x00,0x37,0x02,0x0d,0x01,0x3e,0x02,0x02,0x01,0x10,0x03,0x01,0x00,0x37,0x02,0x0e, 0x01,0x40,0x02,0x02,0x00,0x0a,0xc0,0x04,0xc0,0x08,0xc0,0x0a,0x63,0x6c,0x6f,0x73, 0x65,0x09,0x71,0x75,0x69,0x74,0x0c,0x72,0x65,0x63,0x65,0x69,0x76,0x65,0x09,0x70, 0x61,0x73,0x76,0x09,0x74,0x79,0x70,0x65,0x0d,0x70,0x61,0x73,0x73,0x77,0x6f,0x72, 0x64,0x09,0x75,0x73,0x65,0x72,0x0a,0x6c,0x6f,0x67,0x69,0x6e,0x0a,0x67,0x72,0x65, 0x65,0x74,0x0b,0x63,0x72,0x65,0x61,0x74,0x65,0x09,0x70,0x6f,0x72,0x74,0x09,0x6f, 0x70,0x65,0x6e,0x15,0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x20,0x68,0x6f,0x73,0x74, 0x6e,0x61,0x6d,0x65,0x09,0x68,0x6f,0x73,0x74,0x08,0x74,0x72,0x79,0x65,0x00,0x01, 0x05,0x04,0x03,0x00,0x11,0x2b,0x01,0x00,0x00,0x10,0x02,0x00,0x00,0x3e,0x01,0x02, 0x02,0x32,0x02,0x00,0x00,0x2b,0x03,0x01,0x00,0x37,0x03,0x00,0x03,0x37,0x03,0x01, 0x03,0x10,0x04,0x02,0x00,0x3e,0x03,0x02,0x02,0x3a,0x03,0x00,0x01,0x2b,0x03,0x02, 0x00,0x10,0x04,0x01,0x00,0x3e,0x03,0x02,0x01,0x2b,0x03,0x03,0x00,0x37,0x03,0x02, 0x03,0x10,0x04,0x02,0x00,0x40,0x03,0x02,0x00,0x0d,0xc0,0x07,0xc0,0x0f,0xc0,0x01, 0xc0,0x0b,0x63,0x6f,0x6e,0x63,0x61,0x74,0x0a,0x74,0x61,0x62,0x6c,0x65,0x09,0x73, 0x69,0x6e,0x6b,0xd1,0x02,0x00,0x01,0x07,0x02,0x11,0x00,0x33,0x2b,0x01,0x00,0x00, 0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x02,0x10,0x00,0x01,0x00,0x2b,0x01,0x01,0x00, 0x37,0x01,0x00,0x01,0x37,0x02,0x01,0x00,0x25,0x03,0x02,0x00,0x3e,0x01,0x03,0x01, 0x2b,0x01,0x01,0x00,0x37,0x01,0x00,0x01,0x37,0x02,0x03,0x00,0x25,0x03,0x04,0x00, 0x3e,0x01,0x03,0x01,0x34,0x01,0x05,0x00,0x37,0x02,0x01,0x00,0x37,0x03,0x06,0x00, 0x37,0x04,0x07,0x00,0x3e,0x01,0x04,0x02,0x10,0x03,0x01,0x00,0x37,0x02,0x08,0x01, 0x3e,0x02,0x02,0x01,0x10,0x03,0x01,0x00,0x37,0x02,0x09,0x01,0x37,0x04,0x0a,0x00, 0x37,0x05,0x0b,0x00,0x3e,0x02,0x04,0x01,0x37,0x02,0x00,0x01,0x37,0x03,0x0c,0x01, 0x10,0x04,0x03,0x00,0x37,0x03,0x03,0x03,0x37,0x05,0x03,0x00,0x37,0x06,0x0d,0x00, 0x3e,0x03,0x04,0x00,0x3d,0x02,0x00,0x01,0x37,0x02,0x0e,0x00,0x0f,0x00,0x02,0x00, 0x54,0x03,0x07,0x80,0x37,0x02,0x00,0x01,0x37,0x03,0x0c,0x01,0x10,0x04,0x03,0x00, 0x37,0x03,0x0e,0x03,0x37,0x05,0x0e,0x00,0x3e,0x03,0x03,0x00,0x3d,0x02,0x00,0x01, 0x10,0x03,0x01,0x00,0x37,0x02,0x0f,0x01,0x3e,0x02,0x02,0x01,0x10,0x03,0x01,0x00, 0x37,0x02,0x10,0x01,0x40,0x02,0x02,0x00,0x0a,0xc0,0x04,0xc0,0x0a,0x63,0x6c,0x6f, 0x73,0x65,0x09,0x71,0x75,0x69,0x74,0x0a,0x63,0x68,0x65,0x63,0x6b,0x0d,0x61,0x72, 0x67,0x75,0x6d,0x65,0x6e,0x74,0x07,0x74,0x70,0x0d,0x70,0x61,0x73,0x73,0x77,0x6f, 0x72,0x64,0x09,0x75,0x73,0x65,0x72,0x0a,0x6c,0x6f,0x67,0x69,0x6e,0x0a,0x67,0x72, 0x65,0x65,0x74,0x0b,0x63,0x72,0x65,0x61,0x74,0x65,0x09,0x70,0x6f,0x72,0x74,0x09, 0x6f,0x70,0x65,0x6e,0x14,0x6d,0x69,0x73,0x73,0x69,0x6e,0x67,0x20,0x63,0x6f,0x6d, 0x6d,0x61,0x6e,0x64,0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x15,0x6d,0x69,0x73, 0x73,0x69,0x6e,0x67,0x20,0x68,0x6f,0x73,0x74,0x6e,0x61,0x6d,0x65,0x09,0x68,0x6f, 0x73,0x74,0x08,0x74,0x72,0x79,0x51,0x00,0x01,0x03,0x03,0x02,0x00,0x0e,0x2b,0x01, 0x00,0x00,0x37,0x01,0x00,0x01,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x02,0x07,0x01, 0x01,0x00,0x54,0x01,0x04,0x80,0x2b,0x01,0x01,0x00,0x10,0x02,0x00,0x00,0x40,0x01, 0x02,0x00,0x54,0x01,0x03,0x80,0x2b,0x01,0x02,0x00,0x10,0x02,0x00,0x00,0x40,0x01, 0x02,0x00,0x47,0x00,0x01,0x00,0x00,0xc0,0x10,0xc0,0x0f,0xc0,0x0b,0x73,0x74,0x72, 0x69,0x6e,0x67,0x09,0x74,0x79,0x70,0x65,0x9b,0x05,0x03,0x00,0x13,0x00,0x39,0x00, 0x5f,0x34,0x00,0x00,0x00,0x34,0x01,0x01,0x00,0x25,0x02,0x02,0x00,0x3e,0x01,0x02, 0x02,0x34,0x02,0x01,0x00,0x25,0x03,0x03,0x00,0x3e,0x02,0x02,0x02,0x34,0x03,0x01, 0x00,0x25,0x04,0x04,0x00,0x3e,0x03,0x02,0x02,0x34,0x04,0x01,0x00,0x25,0x05,0x05, 0x00,0x3e,0x04,0x02,0x02,0x34,0x05,0x01,0x00,0x25,0x06,0x06,0x00,0x3e,0x05,0x02, 0x02,0x34,0x06,0x01,0x00,0x25,0x07,0x07,0x00,0x3e,0x06,0x02,0x02,0x34,0x07,0x01, 0x00,0x25,0x08,0x08,0x00,0x3e,0x07,0x02,0x02,0x32,0x08,0x00,0x00,0x3a,0x08,0x09, 0x04,0x37,0x08,0x09,0x04,0x27,0x09,0x3c,0x00,0x3a,0x09,0x0a,0x08,0x27,0x09,0x15, 0x00,0x3a,0x09,0x0b,0x08,0x25,0x09,0x09,0x00,0x3a,0x09,0x0c,0x08,0x25,0x09,0x0e, 0x00,0x3a,0x09,0x0d,0x08,0x33,0x09,0x0f,0x00,0x32,0x0a,0x00,0x00,0x3a,0x0a,0x10, 0x09,0x31,0x0a,0x12,0x00,0x3a,0x0a,0x11,0x08,0x37,0x0a,0x10,0x09,0x31,0x0b,0x14, 0x00,0x3a,0x0b,0x13,0x0a,0x37,0x0a,0x10,0x09,0x31,0x0b,0x16,0x00,0x3a,0x0b,0x15, 0x0a,0x37,0x0a,0x10,0x09,0x31,0x0b,0x18,0x00,0x3a,0x0b,0x17,0x0a,0x37,0x0a,0x10, 0x09,0x31,0x0b,0x1a,0x00,0x3a,0x0b,0x19,0x0a,0x37,0x0a,0x10,0x09,0x31,0x0b,0x1c, 0x00,0x3a,0x0b,0x1b,0x0a,0x37,0x0a,0x10,0x09,0x31,0x0b,0x1e,0x00,0x3a,0x0b,0x1d, 0x0a,0x37,0x0a,0x10,0x09,0x31,0x0b,0x20,0x00,0x3a,0x0b,0x1f,0x0a,0x37,0x0a,0x10, 0x09,0x31,0x0b,0x22,0x00,0x3a,0x0b,0x21,0x0a,0x37,0x0a,0x10,0x09,0x31,0x0b,0x24, 0x00,0x3a,0x0b,0x23,0x0a,0x37,0x0a,0x10,0x09,0x31,0x0b,0x26,0x00,0x3a,0x0b,0x25, 0x0a,0x37,0x0a,0x10,0x09,0x31,0x0b,0x28,0x00,0x3a,0x0b,0x27,0x0a,0x37,0x0a,0x10, 0x09,0x31,0x0b,0x2a,0x00,0x3a,0x0b,0x29,0x0a,0x31,0x0a,0x2b,0x00,0x31,0x0b,0x2c, 0x00,0x33,0x0c,0x2d,0x00,0x31,0x0d,0x2e,0x00,0x31,0x0e,0x2f,0x00,0x37,0x0f,0x31, 0x04,0x31,0x10,0x32,0x00,0x3e,0x0f,0x02,0x02,0x3a,0x0f,0x30,0x08,0x31,0x0f,0x33, 0x00,0x31,0x10,0x34,0x00,0x37,0x11,0x31,0x04,0x31,0x12,0x36,0x00,0x3e,0x11,0x02, 0x02,0x3a,0x11,0x35,0x08,0x37,0x11,0x31,0x04,0x31,0x12,0x38,0x00,0x3e,0x11,0x02, 0x02,0x3a,0x11,0x37,0x08,0x30,0x00,0x00,0x80,0x48,0x08,0x02,0x00,0x00,0x08,0x67, 0x65,0x74,0x00,0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x00,0x00,0x00,0x0c,0x70, 0x72,0x6f,0x74,0x65,0x63,0x74,0x08,0x70,0x75,0x74,0x00,0x00,0x01,0x00,0x02,0x0b, 0x73,0x63,0x68,0x65,0x6d,0x65,0x08,0x66,0x74,0x70,0x09,0x70,0x61,0x74,0x68,0x06, 0x2f,0x00,0x00,0x00,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x00,0x09,0x71,0x75,0x69,0x74, 0x00,0x0a,0x67,0x72,0x65,0x65,0x74,0x00,0x09,0x74,0x79,0x70,0x65,0x00,0x08,0x63, 0x77,0x64,0x00,0x0c,0x72,0x65,0x63,0x65,0x69,0x76,0x65,0x00,0x09,0x73,0x65,0x6e, 0x64,0x00,0x09,0x70,0x6f,0x72,0x74,0x00,0x09,0x70,0x61,0x73,0x76,0x00,0x0a,0x6c, 0x6f,0x67,0x69,0x6e,0x00,0x10,0x70,0x61,0x73,0x76,0x63,0x6f,0x6e,0x6e,0x65,0x63, 0x74,0x00,0x10,0x70,0x6f,0x72,0x74,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x00,0x09, 0x6f,0x70,0x65,0x6e,0x0c,0x5f,0x5f,0x69,0x6e,0x64,0x65,0x78,0x01,0x00,0x00,0x1c, 0x61,0x6e,0x6f,0x6e,0x79,0x6d,0x6f,0x75,0x73,0x40,0x61,0x6e,0x6f,0x6e,0x79,0x6d, 0x6f,0x75,0x73,0x2e,0x6f,0x72,0x67,0x0d,0x50,0x41,0x53,0x53,0x57,0x4f,0x52,0x44, 0x09,0x55,0x53,0x45,0x52,0x09,0x50,0x4f,0x52,0x54,0x0c,0x54,0x49,0x4d,0x45,0x4f, 0x55,0x54,0x08,0x66,0x74,0x70,0x0a,0x6c,0x74,0x6e,0x31,0x32,0x0e,0x73,0x6f,0x63, 0x6b,0x65,0x74,0x2e,0x74,0x70,0x0f,0x73,0x6f,0x63,0x6b,0x65,0x74,0x2e,0x75,0x72, 0x6c,0x0b,0x73,0x6f,0x63,0x6b,0x65,0x74,0x09,0x6d,0x61,0x74,0x68,0x0b,0x73,0x74, 0x72,0x69,0x6e,0x67,0x0a,0x74,0x61,0x62,0x6c,0x65,0x0c,0x72,0x65,0x71,0x75,0x69, 0x72,0x65,0x07,0x5f,0x47,0x00, }; /* socket.headers, socket/headers.lua */ static const char lua_m_socket_headers[] = { 0x1b,0x4c,0x4a,0x01,0x02,0xc5,0x11,0x02,0x00,0x03,0x00,0x05,0x00,0x09,0x34,0x00, 0x00,0x00,0x25,0x01,0x01,0x00,0x3e,0x00,0x02,0x02,0x32,0x01,0x00,0x00,0x3a,0x01, 0x02,0x00,0x37,0x01,0x02,0x00,0x33,0x02,0x04,0x00,0x3a,0x02,0x03,0x01,0x48,0x01, 0x02,0x00,0x01,0x00,0x5b,0x16,0x6c,0x61,0x73,0x74,0x2d,0x61,0x74,0x74,0x65,0x6d, 0x70,0x74,0x2d,0x64,0x61,0x74,0x65,0x16,0x4c,0x61,0x73,0x74,0x2d,0x41,0x74,0x74, 0x65,0x6d,0x70,0x74,0x2d,0x44,0x61,0x74,0x65,0x0d,0x72,0x65,0x63,0x65,0x69,0x76, 0x65,0x64,0x0d,0x52,0x65,0x63,0x65,0x69,0x76,0x65,0x64,0x11,0x6d,0x69,0x6d,0x65, 0x2d,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x11,0x4d,0x49,0x4d,0x45,0x2d,0x56,0x65, 0x72,0x73,0x69,0x6f,0x6e,0x0d,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x0d,0x4c, 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x0b,0x61,0x63,0x63,0x65,0x70,0x74,0x0b,0x41, 0x63,0x63,0x65,0x70,0x74,0x08,0x62,0x63,0x63,0x08,0x42,0x63,0x63,0x0f,0x72,0x65, 0x6d,0x6f,0x74,0x65,0x2d,0x6d,0x74,0x61,0x0f,0x52,0x65,0x6d,0x6f,0x74,0x65,0x2d, 0x4d,0x54,0x41,0x0b,0x70,0x72,0x61,0x67,0x6d,0x61,0x0b,0x50,0x72,0x61,0x67,0x6d, 0x61,0x0c,0x72,0x65,0x66,0x65,0x72,0x65,0x72,0x0c,0x52,0x65,0x66,0x65,0x72,0x65, 0x72,0x0b,0x63,0x6f,0x6f,0x6b,0x69,0x65,0x0b,0x43,0x6f,0x6f,0x6b,0x69,0x65,0x19, 0x6f,0x72,0x69,0x67,0x69,0x6e,0x61,0x6c,0x2d,0x65,0x6e,0x76,0x65,0x6c,0x6f,0x70, 0x65,0x2d,0x69,0x64,0x19,0x4f,0x72,0x69,0x67,0x69,0x6e,0x61,0x6c,0x2d,0x45,0x6e, 0x76,0x65,0x6c,0x6f,0x70,0x65,0x2d,0x49,0x44,0x10,0x72,0x65,0x74,0x72,0x79,0x2d, 0x61,0x66,0x74,0x65,0x72,0x10,0x52,0x65,0x74,0x72,0x79,0x2d,0x41,0x66,0x74,0x65, 0x72,0x09,0x66,0x72,0x6f,0x6d,0x09,0x46,0x72,0x6f,0x6d,0x12,0x61,0x75,0x74,0x68, 0x6f,0x72,0x69,0x7a,0x61,0x74,0x69,0x6f,0x6e,0x12,0x41,0x75,0x74,0x68,0x6f,0x72, 0x69,0x7a,0x61,0x74,0x69,0x6f,0x6e,0x12,0x63,0x61,0x63,0x68,0x65,0x2d,0x63,0x6f, 0x6e,0x74,0x72,0x6f,0x6c,0x12,0x43,0x61,0x63,0x68,0x65,0x2d,0x43,0x6f,0x6e,0x74, 0x72,0x6f,0x6c,0x1e,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x72,0x61,0x6e, 0x73,0x66,0x65,0x72,0x2d,0x65,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x1e,0x43,0x6f, 0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x72,0x61,0x6e,0x73,0x66,0x65,0x72,0x2d,0x45, 0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x0d,0x6b,0x65,0x79,0x77,0x6f,0x72,0x64,0x73, 0x0d,0x4b,0x65,0x79,0x77,0x6f,0x72,0x64,0x73,0x10,0x72,0x65,0x74,0x75,0x72,0x6e, 0x2d,0x70,0x61,0x74,0x68,0x10,0x52,0x65,0x74,0x75,0x72,0x6e,0x2d,0x50,0x61,0x74, 0x68,0x15,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x6c,0x6f,0x63,0x61,0x74,0x69, 0x6f,0x6e,0x15,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x4c,0x6f,0x63,0x61,0x74, 0x69,0x6f,0x6e,0x16,0x69,0x66,0x2d,0x6d,0x6f,0x64,0x69,0x66,0x69,0x65,0x64,0x2d, 0x73,0x69,0x6e,0x63,0x65,0x16,0x49,0x66,0x2d,0x4d,0x6f,0x64,0x69,0x66,0x69,0x65, 0x64,0x2d,0x53,0x69,0x6e,0x63,0x65,0x1a,0x73,0x6d,0x74,0x70,0x2d,0x72,0x65,0x6d, 0x6f,0x74,0x65,0x2d,0x72,0x65,0x63,0x69,0x70,0x69,0x65,0x6e,0x74,0x1a,0x53,0x4d, 0x54,0x50,0x2d,0x52,0x65,0x6d,0x6f,0x74,0x65,0x2d,0x52,0x65,0x63,0x69,0x70,0x69, 0x65,0x6e,0x74,0x14,0x61,0x63,0x63,0x65,0x70,0x74,0x2d,0x65,0x6e,0x63,0x6f,0x64, 0x69,0x6e,0x67,0x14,0x41,0x63,0x63,0x65,0x70,0x74,0x2d,0x45,0x6e,0x63,0x6f,0x64, 0x69,0x6e,0x67,0x10,0x72,0x65,0x73,0x65,0x6e,0x74,0x2d,0x66,0x72,0x6f,0x6d,0x10, 0x52,0x65,0x73,0x65,0x6e,0x74,0x2d,0x46,0x72,0x6f,0x6d,0x12,0x72,0x65,0x73,0x65, 0x6e,0x74,0x2d,0x73,0x65,0x6e,0x64,0x65,0x72,0x12,0x52,0x65,0x73,0x65,0x6e,0x74, 0x2d,0x53,0x65,0x6e,0x64,0x65,0x72,0x11,0x6d,0x61,0x78,0x2d,0x66,0x6f,0x72,0x77, 0x61,0x72,0x64,0x73,0x11,0x4d,0x61,0x78,0x2d,0x46,0x6f,0x72,0x77,0x61,0x72,0x64, 0x73,0x18,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x64,0x65,0x73,0x63,0x72,0x69, 0x70,0x74,0x69,0x6f,0x6e,0x18,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x44,0x65, 0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x16,0x72,0x65,0x73,0x65,0x6e,0x74, 0x2d,0x6d,0x65,0x73,0x73,0x61,0x67,0x65,0x2d,0x69,0x64,0x16,0x52,0x65,0x73,0x65, 0x6e,0x74,0x2d,0x4d,0x65,0x73,0x73,0x61,0x67,0x65,0x2d,0x49,0x44,0x12,0x72,0x65, 0x70,0x6f,0x72,0x74,0x69,0x6e,0x67,0x2d,0x6d,0x74,0x61,0x12,0x52,0x65,0x70,0x6f, 0x72,0x74,0x69,0x6e,0x67,0x2d,0x4d,0x54,0x41,0x0c,0x65,0x78,0x70,0x69,0x72,0x65, 0x73,0x0c,0x45,0x78,0x70,0x69,0x72,0x65,0x73,0x16,0x74,0x72,0x61,0x6e,0x73,0x66, 0x65,0x72,0x2d,0x65,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x16,0x54,0x72,0x61,0x6e, 0x73,0x66,0x65,0x72,0x2d,0x45,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x0f,0x72,0x65, 0x66,0x65,0x72,0x65,0x6e,0x63,0x65,0x73,0x0f,0x52,0x65,0x66,0x65,0x72,0x65,0x6e, 0x63,0x65,0x73,0x0b,0x73,0x65,0x6e,0x64,0x65,0x72,0x0b,0x53,0x65,0x6e,0x64,0x65, 0x72,0x15,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x65,0x6e,0x63,0x6f,0x64,0x69, 0x6e,0x67,0x15,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x45,0x6e,0x63,0x6f,0x64, 0x69,0x6e,0x67,0x0c,0x73,0x75,0x62,0x6a,0x65,0x63,0x74,0x0c,0x53,0x75,0x62,0x6a, 0x65,0x63,0x74,0x08,0x61,0x67,0x65,0x08,0x41,0x67,0x65,0x07,0x74,0x65,0x07,0x54, 0x45,0x07,0x74,0x6f,0x07,0x54,0x6f,0x12,0x6c,0x61,0x73,0x74,0x2d,0x6d,0x6f,0x64, 0x69,0x66,0x69,0x65,0x64,0x12,0x4c,0x61,0x73,0x74,0x2d,0x4d,0x6f,0x64,0x69,0x66, 0x69,0x65,0x64,0x13,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x6c,0x65,0x6e,0x67, 0x74,0x68,0x13,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x4c,0x65,0x6e,0x67,0x74, 0x68,0x07,0x63,0x63,0x07,0x43,0x63,0x15,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d, 0x6c,0x61,0x6e,0x67,0x75,0x61,0x67,0x65,0x15,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74, 0x2d,0x4c,0x61,0x6e,0x67,0x75,0x61,0x67,0x65,0x0f,0x75,0x73,0x65,0x72,0x2d,0x61, 0x67,0x65,0x6e,0x74,0x0f,0x55,0x73,0x65,0x72,0x2d,0x41,0x67,0x65,0x6e,0x74,0x09, 0x76,0x61,0x72,0x79,0x09,0x56,0x61,0x72,0x79,0x11,0x61,0x72,0x72,0x69,0x76,0x61, 0x6c,0x2d,0x64,0x61,0x74,0x65,0x11,0x41,0x72,0x72,0x69,0x76,0x61,0x6c,0x2d,0x44, 0x61,0x74,0x65,0x0f,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x69,0x6f,0x6e,0x0f,0x43, 0x6f,0x6e,0x6e,0x65,0x63,0x74,0x69,0x6f,0x6e,0x18,0x63,0x6f,0x6e,0x74,0x65,0x6e, 0x74,0x2d,0x64,0x69,0x73,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x18,0x43,0x6f, 0x6e,0x74,0x65,0x6e,0x74,0x2d,0x44,0x69,0x73,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, 0x6e,0x12,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x72,0x61,0x6e,0x67,0x65,0x12, 0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x52,0x61,0x6e,0x67,0x65,0x0c,0x77,0x61, 0x72,0x6e,0x69,0x6e,0x67,0x0c,0x57,0x61,0x72,0x6e,0x69,0x6e,0x67,0x15,0x77,0x69, 0x6c,0x6c,0x2d,0x72,0x65,0x74,0x72,0x79,0x2d,0x75,0x6e,0x74,0x69,0x6c,0x15,0x57, 0x69,0x6c,0x6c,0x2d,0x52,0x65,0x74,0x72,0x79,0x2d,0x55,0x6e,0x74,0x69,0x6c,0x13, 0x61,0x63,0x63,0x65,0x70,0x74,0x2d,0x63,0x68,0x61,0x72,0x73,0x65,0x74,0x13,0x41, 0x63,0x63,0x65,0x70,0x74,0x2d,0x43,0x68,0x61,0x72,0x73,0x65,0x74,0x12,0x69,0x66, 0x2d,0x6e,0x6f,0x6e,0x65,0x2d,0x6d,0x61,0x74,0x63,0x68,0x12,0x49,0x66,0x2d,0x4e, 0x6f,0x6e,0x65,0x2d,0x4d,0x61,0x74,0x63,0x68,0x0d,0x78,0x2d,0x6d,0x61,0x69,0x6c, 0x65,0x72,0x0d,0x58,0x2d,0x4d,0x61,0x69,0x6c,0x65,0x72,0x0c,0x75,0x70,0x67,0x72, 0x61,0x64,0x65,0x0c,0x55,0x70,0x67,0x72,0x61,0x64,0x65,0x0c,0x74,0x72,0x61,0x69, 0x6c,0x65,0x72,0x0c,0x54,0x72,0x61,0x69,0x6c,0x65,0x72,0x0d,0x69,0x66,0x2d,0x6d, 0x61,0x74,0x63,0x68,0x0d,0x49,0x66,0x2d,0x4d,0x61,0x74,0x63,0x68,0x09,0x65,0x74, 0x61,0x67,0x09,0x45,0x54,0x61,0x67,0x15,0x77,0x77,0x77,0x2d,0x61,0x75,0x74,0x68, 0x65,0x6e,0x74,0x69,0x63,0x61,0x74,0x65,0x15,0x57,0x57,0x57,0x2d,0x41,0x75,0x74, 0x68,0x65,0x6e,0x74,0x69,0x63,0x61,0x74,0x65,0x09,0x64,0x61,0x74,0x65,0x09,0x44, 0x61,0x74,0x65,0x14,0x64,0x69,0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x2d,0x63, 0x6f,0x64,0x65,0x14,0x44,0x69,0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x2d,0x43, 0x6f,0x64,0x65,0x16,0x72,0x65,0x63,0x65,0x69,0x76,0x65,0x64,0x2d,0x66,0x72,0x6f, 0x6d,0x2d,0x6d,0x74,0x61,0x16,0x52,0x65,0x63,0x65,0x69,0x76,0x65,0x64,0x2d,0x46, 0x72,0x6f,0x6d,0x2d,0x4d,0x54,0x41,0x0b,0x73,0x74,0x61,0x74,0x75,0x73,0x0b,0x53, 0x74,0x61,0x74,0x75,0x73,0x14,0x61,0x63,0x63,0x65,0x70,0x74,0x2d,0x6c,0x61,0x6e, 0x67,0x75,0x61,0x67,0x65,0x14,0x41,0x63,0x63,0x65,0x70,0x74,0x2d,0x4c,0x61,0x6e, 0x67,0x75,0x61,0x67,0x65,0x17,0x6f,0x72,0x69,0x67,0x69,0x6e,0x61,0x6c,0x2d,0x72, 0x65,0x63,0x69,0x70,0x69,0x65,0x6e,0x74,0x17,0x4f,0x72,0x69,0x67,0x69,0x6e,0x61, 0x6c,0x2d,0x52,0x65,0x63,0x69,0x70,0x69,0x65,0x6e,0x74,0x0d,0x63,0x6f,0x6d,0x6d, 0x65,0x6e,0x74,0x73,0x0d,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x73,0x0a,0x72,0x61, 0x6e,0x67,0x65,0x0a,0x52,0x61,0x6e,0x67,0x65,0x0b,0x65,0x78,0x70,0x65,0x63,0x74, 0x0b,0x45,0x78,0x70,0x65,0x63,0x74,0x12,0x61,0x63,0x63,0x65,0x70,0x74,0x2d,0x72, 0x61,0x6e,0x67,0x65,0x73,0x12,0x41,0x63,0x63,0x65,0x70,0x74,0x2d,0x52,0x61,0x6e, 0x67,0x65,0x73,0x0f,0x72,0x65,0x73,0x65,0x6e,0x74,0x2d,0x62,0x63,0x63,0x0f,0x52, 0x65,0x73,0x65,0x6e,0x74,0x2d,0x42,0x63,0x63,0x0f,0x6d,0x65,0x73,0x73,0x61,0x67, 0x65,0x2d,0x69,0x64,0x0f,0x4d,0x65,0x73,0x73,0x61,0x67,0x65,0x2d,0x49,0x44,0x18, 0x69,0x66,0x2d,0x75,0x6e,0x6d,0x6f,0x64,0x69,0x66,0x69,0x65,0x64,0x2d,0x73,0x69, 0x6e,0x63,0x65,0x18,0x49,0x66,0x2d,0x55,0x6e,0x6d,0x6f,0x64,0x69,0x66,0x69,0x65, 0x64,0x2d,0x53,0x69,0x6e,0x63,0x65,0x0f,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d, 0x69,0x64,0x0f,0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x49,0x44,0x14,0x72,0x65, 0x73,0x65,0x6e,0x74,0x2d,0x72,0x65,0x70,0x6c,0x79,0x2d,0x74,0x6f,0x14,0x52,0x65, 0x73,0x65,0x6e,0x74,0x2d,0x52,0x65,0x70,0x6c,0x79,0x2d,0x54,0x6f,0x10,0x63,0x6f, 0x6e,0x74,0x65,0x6e,0x74,0x2d,0x6d,0x64,0x35,0x10,0x43,0x6f,0x6e,0x74,0x65,0x6e, 0x74,0x2d,0x4d,0x44,0x35,0x0d,0x72,0x65,0x70,0x6c,0x79,0x2d,0x74,0x6f,0x0d,0x52, 0x65,0x70,0x6c,0x79,0x2d,0x54,0x6f,0x0d,0x69,0x66,0x2d,0x72,0x61,0x6e,0x67,0x65, 0x0d,0x49,0x66,0x2d,0x52,0x61,0x6e,0x67,0x65,0x10,0x64,0x73,0x6e,0x2d,0x67,0x61, 0x74,0x65,0x77,0x61,0x79,0x10,0x44,0x53,0x4e,0x2d,0x47,0x61,0x74,0x65,0x77,0x61, 0x79,0x08,0x76,0x69,0x61,0x08,0x56,0x69,0x61,0x0a,0x61,0x6c,0x6c,0x6f,0x77,0x0a, 0x41,0x6c,0x6c,0x6f,0x77,0x10,0x72,0x65,0x73,0x65,0x6e,0x74,0x2d,0x64,0x61,0x74, 0x65,0x10,0x52,0x65,0x73,0x65,0x6e,0x74,0x2d,0x44,0x61,0x74,0x65,0x14,0x66,0x69, 0x6e,0x61,0x6c,0x2d,0x72,0x65,0x63,0x69,0x70,0x69,0x65,0x6e,0x74,0x14,0x46,0x69, 0x6e,0x61,0x6c,0x2d,0x52,0x65,0x63,0x69,0x70,0x69,0x65,0x6e,0x74,0x11,0x63,0x6f, 0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x11,0x43,0x6f,0x6e,0x74,0x65, 0x6e,0x74,0x2d,0x54,0x79,0x70,0x65,0x0b,0x61,0x63,0x74,0x69,0x6f,0x6e,0x0b,0x41, 0x63,0x74,0x69,0x6f,0x6e,0x17,0x70,0x72,0x6f,0x78,0x79,0x2d,0x61,0x75,0x74,0x68, 0x65,0x6e,0x74,0x69,0x63,0x61,0x74,0x65,0x17,0x50,0x72,0x6f,0x78,0x79,0x2d,0x41, 0x75,0x74,0x68,0x65,0x6e,0x74,0x69,0x63,0x61,0x74,0x65,0x10,0x69,0x6e,0x2d,0x72, 0x65,0x70,0x6c,0x79,0x2d,0x74,0x6f,0x10,0x49,0x6e,0x2d,0x52,0x65,0x70,0x6c,0x79, 0x2d,0x54,0x6f,0x0e,0x72,0x65,0x73,0x65,0x6e,0x74,0x2d,0x63,0x63,0x0e,0x52,0x65, 0x73,0x65,0x6e,0x74,0x2d,0x43,0x63,0x09,0x68,0x6f,0x73,0x74,0x09,0x48,0x6f,0x73, 0x74,0x18,0x70,0x72,0x6f,0x78,0x79,0x2d,0x61,0x75,0x74,0x68,0x6f,0x72,0x69,0x7a, 0x61,0x74,0x69,0x6f,0x6e,0x18,0x50,0x72,0x6f,0x78,0x79,0x2d,0x41,0x75,0x74,0x68, 0x6f,0x72,0x69,0x7a,0x61,0x74,0x69,0x6f,0x6e,0x18,0x61,0x6c,0x74,0x65,0x72,0x6e, 0x61,0x74,0x65,0x2d,0x72,0x65,0x63,0x69,0x70,0x69,0x65,0x6e,0x74,0x18,0x41,0x6c, 0x74,0x65,0x72,0x6e,0x61,0x74,0x65,0x2d,0x52,0x65,0x63,0x69,0x70,0x69,0x65,0x6e, 0x74,0x0e,0x72,0x65,0x73,0x65,0x6e,0x74,0x2d,0x74,0x6f,0x0e,0x52,0x65,0x73,0x65, 0x6e,0x74,0x2d,0x54,0x6f,0x11,0x66,0x69,0x6e,0x61,0x6c,0x2d,0x6c,0x6f,0x67,0x2d, 0x69,0x64,0x11,0x46,0x69,0x6e,0x61,0x6c,0x2d,0x4c,0x6f,0x67,0x2d,0x49,0x44,0x0b, 0x73,0x65,0x72,0x76,0x65,0x72,0x0b,0x53,0x65,0x72,0x76,0x65,0x72,0x0c,0x63,0x61, 0x6e,0x6f,0x6e,0x69,0x63,0x0c,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x0b,0x73,0x6f, 0x63,0x6b,0x65,0x74,0x0c,0x72,0x65,0x71,0x75,0x69,0x72,0x65,0x00, }; /* socket.http, socket/http.lua */ static const char lua_m_socket_http[] = { 0x1b,0x4c,0x4a,0x01,0x02,0x9f,0x03,0x00,0x02,0x0b,0x02,0x09,0x00,0x53,0x2a,0x02, 0x05,0x00,0x0e,0x00,0x01,0x00,0x54,0x06,0x01,0x80,0x32,0x01,0x00,0x00,0x10,0x07, 0x00,0x00,0x37,0x06,0x00,0x00,0x3e,0x06,0x02,0x03,0x10,0x05,0x07,0x00,0x10,0x02, 0x06,0x00,0x0f,0x00,0x05,0x00,0x54,0x06,0x03,0x80,0x29,0x06,0x00,0x00,0x10,0x07, 0x05,0x00,0x46,0x06,0x03,0x00,0x06,0x02,0x01,0x00,0x54,0x06,0x42,0x80,0x51,0x06, 0x41,0x80,0x2b,0x06,0x00,0x00,0x37,0x06,0x02,0x06,0x27,0x07,0x02,0x00,0x2b,0x08, 0x01,0x00,0x37,0x08,0x03,0x08,0x10,0x09,0x02,0x00,0x25,0x0a,0x04,0x00,0x3e,0x08, 0x03,0x00,0x3d,0x06,0x01,0x03,0x10,0x04,0x07,0x00,0x10,0x03,0x06,0x00,0x0f,0x00, 0x03,0x00,0x54,0x06,0x02,0x80,0x0e,0x00,0x04,0x00,0x54,0x06,0x03,0x80,0x29,0x06, 0x00,0x00,0x25,0x07,0x05,0x00,0x46,0x06,0x03,0x00,0x2b,0x06,0x01,0x00,0x37,0x06, 0x06,0x06,0x10,0x07,0x03,0x00,0x3e,0x06,0x02,0x02,0x10,0x03,0x06,0x00,0x10,0x07, 0x00,0x00,0x37,0x06,0x00,0x00,0x3e,0x06,0x02,0x03,0x10,0x05,0x07,0x00,0x10,0x02, 0x06,0x00,0x0f,0x00,0x05,0x00,0x54,0x06,0x03,0x80,0x29,0x06,0x00,0x00,0x10,0x07, 0x05,0x00,0x46,0x06,0x03,0x00,0x2b,0x06,0x01,0x00,0x37,0x06,0x03,0x06,0x10,0x07, 0x02,0x00,0x25,0x08,0x07,0x00,0x3e,0x06,0x03,0x02,0x0f,0x00,0x06,0x00,0x54,0x07, 0x0e,0x80,0x51,0x06,0x0d,0x80,0x10,0x06,0x04,0x00,0x10,0x07,0x02,0x00,0x24,0x04, 0x07,0x06,0x10,0x07,0x00,0x00,0x37,0x06,0x00,0x00,0x3e,0x06,0x02,0x02,0x10,0x02, 0x06,0x00,0x0f,0x00,0x05,0x00,0x54,0x06,0xef,0x7f,0x29,0x06,0x00,0x00,0x10,0x07, 0x05,0x00,0x46,0x06,0x03,0x00,0x54,0x06,0xeb,0x7f,0x36,0x06,0x03,0x01,0x0f,0x00, 0x06,0x00,0x54,0x07,0x06,0x80,0x36,0x06,0x03,0x01,0x25,0x07,0x08,0x00,0x10,0x08, 0x04,0x00,0x24,0x06,0x08,0x06,0x39,0x06,0x03,0x01,0x54,0x06,0xbe,0x7f,0x39,0x04, 0x03,0x01,0x54,0x06,0xbc,0x7f,0x48,0x01,0x02,0x00,0x00,0xc0,0x04,0xc0,0x07,0x2c, 0x20,0x08,0x5e,0x25,0x73,0x0a,0x6c,0x6f,0x77,0x65,0x72,0x1e,0x6d,0x61,0x6c,0x66, 0x6f,0x72,0x6d,0x65,0x64,0x20,0x72,0x65,0x70,0x6f,0x6e,0x73,0x65,0x20,0x68,0x65, 0x61,0x64,0x65,0x72,0x73,0x12,0x5e,0x28,0x2e,0x2d,0x29,0x3a,0x25,0x73,0x2a,0x28, 0x2e,0x2a,0x29,0x09,0x66,0x69,0x6e,0x64,0x09,0x73,0x6b,0x69,0x70,0x05,0x0c,0x72, 0x65,0x63,0x65,0x69,0x76,0x65,0x1f,0x00,0x00,0x02,0x01,0x01,0x00,0x04,0x2b,0x00, 0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00,0x02,0x00,0x00,0xc0, 0x0a,0x67,0x65,0x74,0x66,0x64,0x1f,0x00,0x00,0x02,0x01,0x01,0x00,0x04,0x2b,0x00, 0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00,0x02,0x00,0x00,0xc0, 0x0a,0x64,0x69,0x72,0x74,0x79,0x9b,0x02,0x00,0x00,0x08,0x05,0x06,0x00,0x37,0x2b, 0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x3e,0x00,0x02,0x03,0x0f, 0x00,0x01,0x00,0x54,0x02,0x03,0x80,0x29,0x02,0x00,0x00,0x10,0x03,0x01,0x00,0x46, 0x02,0x03,0x00,0x2b,0x02,0x01,0x00,0x37,0x02,0x01,0x02,0x2b,0x03,0x02,0x00,0x37, 0x03,0x02,0x03,0x10,0x04,0x00,0x00,0x25,0x05,0x03,0x00,0x25,0x06,0x04,0x00,0x3e, 0x03,0x04,0x02,0x27,0x04,0x10,0x00,0x3e,0x02,0x03,0x02,0x0e,0x00,0x02,0x00,0x54, 0x03,0x03,0x80,0x29,0x03,0x00,0x00,0x25,0x04,0x05,0x00,0x46,0x03,0x03,0x00,0x27, 0x03,0x00,0x00,0x01,0x03,0x02,0x00,0x54,0x03,0x0f,0x80,0x2b,0x03,0x00,0x00,0x10, 0x04,0x03,0x00,0x37,0x03,0x00,0x03,0x10,0x05,0x02,0x00,0x3e,0x03,0x03,0x04,0x0f, 0x00,0x03,0x00,0x54,0x06,0x04,0x80,0x2b,0x06,0x00,0x00,0x10,0x07,0x06,0x00,0x37, 0x06,0x00,0x06,0x3e,0x06,0x02,0x01,0x10,0x06,0x03,0x00,0x10,0x07,0x04,0x00,0x46, 0x06,0x03,0x00,0x54,0x03,0x0c,0x80,0x2b,0x03,0x04,0x00,0x2b,0x04,0x00,0x00,0x2b, 0x05,0x03,0x00,0x3e,0x03,0x03,0x03,0x10,0x01,0x04,0x00,0x2c,0x03,0x03,0x00,0x2b, 0x03,0x03,0x00,0x0e,0x00,0x03,0x00,0x54,0x03,0x03,0x80,0x29,0x03,0x00,0x00,0x10, 0x04,0x01,0x00,0x46,0x03,0x03,0x00,0x47,0x00,0x01,0x00,0x00,0xc0,0x00,0x00,0x01, 0x00,0x01,0x80,0x02,0x00,0x17,0x69,0x6e,0x76,0x61,0x6c,0x69,0x64,0x20,0x63,0x68, 0x75,0x6e,0x6b,0x20,0x73,0x69,0x7a,0x65,0x05,0x08,0x3b,0x2e,0x2a,0x09,0x67,0x73, 0x75,0x62,0x0d,0x74,0x6f,0x6e,0x75,0x6d,0x62,0x65,0x72,0x0c,0x72,0x65,0x63,0x65, 0x69,0x76,0x65,0x66,0x01,0x02,0x06,0x03,0x09,0x00,0x0c,0x2b,0x02,0x00,0x00,0x37, 0x02,0x00,0x02,0x33,0x03,0x02,0x00,0x31,0x04,0x01,0x00,0x3a,0x04,0x03,0x03,0x31, 0x04,0x04,0x00,0x3a,0x04,0x05,0x03,0x33,0x04,0x07,0x00,0x31,0x05,0x06,0x00,0x3a, 0x05,0x08,0x04,0x30,0x00,0x00,0x80,0x40,0x02,0x03,0x00,0x06,0xc0,0x04,0xc0,0x09, 0xc0,0x0b,0x5f,0x5f,0x63,0x61,0x6c,0x6c,0x01,0x00,0x00,0x00,0x0a,0x64,0x69,0x72, 0x74,0x79,0x00,0x0a,0x67,0x65,0x74,0x66,0x64,0x01,0x00,0x00,0x00,0x11,0x73,0x65, 0x74,0x6d,0x65,0x74,0x61,0x74,0x61,0x62,0x6c,0x65,0x1f,0x00,0x00,0x02,0x01,0x01, 0x00,0x04,0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00, 0x02,0x00,0x00,0xc0,0x0a,0x67,0x65,0x74,0x66,0x64,0x1f,0x00,0x00,0x02,0x01,0x01, 0x00,0x04,0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00, 0x02,0x00,0x00,0xc0,0x0a,0x64,0x69,0x72,0x74,0x79,0x85,0x01,0x00,0x03,0x09,0x02, 0x06,0x00,0x17,0x0e,0x00,0x01,0x00,0x54,0x03,0x05,0x80,0x2b,0x03,0x00,0x00,0x10, 0x04,0x03,0x00,0x37,0x03,0x00,0x03,0x25,0x05,0x01,0x00,0x40,0x03,0x03,0x00,0x2b, 0x03,0x01,0x00,0x37,0x03,0x02,0x03,0x25,0x04,0x03,0x00,0x2b,0x05,0x01,0x00,0x37, 0x05,0x04,0x05,0x10,0x06,0x01,0x00,0x3e,0x05,0x02,0x00,0x3d,0x03,0x01,0x02,0x2b, 0x04,0x00,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x00,0x04,0x10,0x06,0x03,0x00,0x10, 0x07,0x01,0x00,0x25,0x08,0x05,0x00,0x24,0x06,0x08,0x06,0x40,0x04,0x03,0x00,0x00, 0xc0,0x01,0x00,0x07,0x0d,0x0a,0x08,0x6c,0x65,0x6e,0x09,0x25,0x58,0x0d,0x0a,0x0b, 0x66,0x6f,0x72,0x6d,0x61,0x74,0x0a,0x30,0x0d,0x0a,0x0d,0x0a,0x09,0x73,0x65,0x6e, 0x64,0x64,0x01,0x01,0x05,0x02,0x09,0x00,0x0c,0x2b,0x01,0x00,0x00,0x37,0x01,0x00, 0x01,0x33,0x02,0x02,0x00,0x31,0x03,0x01,0x00,0x3a,0x03,0x03,0x02,0x31,0x03,0x04, 0x00,0x3a,0x03,0x05,0x02,0x33,0x03,0x07,0x00,0x31,0x04,0x06,0x00,0x3a,0x04,0x08, 0x03,0x30,0x00,0x00,0x80,0x40,0x01,0x03,0x00,0x06,0xc0,0x04,0xc0,0x0b,0x5f,0x5f, 0x63,0x61,0x6c,0x6c,0x01,0x00,0x00,0x00,0x0a,0x64,0x69,0x72,0x74,0x79,0x00,0x0a, 0x67,0x65,0x74,0x66,0x64,0x01,0x00,0x00,0x00,0x11,0x73,0x65,0x74,0x6d,0x65,0x74, 0x61,0x74,0x61,0x62,0x6c,0x65,0x23,0x00,0x00,0x02,0x01,0x01,0x00,0x05,0x2b,0x00, 0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x3e,0x00,0x02,0x01,0x47,0x00, 0x01,0x00,0x04,0xc0,0x0a,0x63,0x6c,0x6f,0x73,0x65,0xe9,0x01,0x01,0x03,0x0a,0x04, 0x0b,0x00,0x26,0x2b,0x03,0x00,0x00,0x37,0x03,0x00,0x03,0x0c,0x04,0x02,0x00,0x54, 0x04,0x02,0x80,0x2b,0x04,0x00,0x00,0x37,0x04,0x01,0x04,0x3e,0x04,0x01,0x00,0x3d, 0x03,0x00,0x02,0x2b,0x04,0x01,0x00,0x37,0x04,0x02,0x04,0x33,0x05,0x03,0x00,0x3a, 0x03,0x04,0x05,0x2b,0x06,0x02,0x00,0x3e,0x04,0x03,0x02,0x2b,0x05,0x00,0x00,0x37, 0x05,0x05,0x05,0x31,0x06,0x06,0x00,0x3e,0x05,0x02,0x02,0x3a,0x05,0x00,0x04,0x37, 0x05,0x00,0x04,0x10,0x07,0x03,0x00,0x37,0x06,0x07,0x03,0x2b,0x08,0x03,0x00,0x37, 0x08,0x08,0x08,0x3e,0x06,0x03,0x00,0x3d,0x05,0x00,0x01,0x37,0x05,0x00,0x04,0x10, 0x07,0x03,0x00,0x37,0x06,0x09,0x03,0x10,0x08,0x00,0x00,0x0c,0x09,0x01,0x00,0x54, 0x09,0x02,0x80,0x2b,0x09,0x03,0x00,0x37,0x09,0x0a,0x09,0x3e,0x06,0x04,0x00,0x3d, 0x05,0x00,0x01,0x30,0x00,0x00,0x80,0x48,0x04,0x02,0x00,0x00,0xc0,0x06,0xc0,0x0a, 0xc0,0x08,0xc0,0x09,0x50,0x4f,0x52,0x54,0x0c,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74, 0x0c,0x54,0x49,0x4d,0x45,0x4f,0x55,0x54,0x0f,0x73,0x65,0x74,0x74,0x69,0x6d,0x65, 0x6f,0x75,0x74,0x00,0x0b,0x6e,0x65,0x77,0x74,0x72,0x79,0x06,0x63,0x01,0x00,0x00, 0x11,0x73,0x65,0x74,0x6d,0x65,0x74,0x61,0x74,0x61,0x62,0x6c,0x65,0x08,0x74,0x63, 0x70,0x08,0x74,0x72,0x79,0x6c,0x00,0x03,0x08,0x01,0x06,0x00,0x0f,0x2b,0x03,0x00, 0x00,0x37,0x03,0x00,0x03,0x25,0x04,0x01,0x00,0x0c,0x05,0x01,0x00,0x54,0x05,0x01, 0x80,0x25,0x05,0x02,0x00,0x10,0x06,0x02,0x00,0x3e,0x03,0x04,0x02,0x37,0x04,0x03, 0x00,0x37,0x05,0x04,0x00,0x10,0x06,0x05,0x00,0x37,0x05,0x05,0x05,0x10,0x07,0x03, 0x00,0x3e,0x05,0x03,0x00,0x3f,0x04,0x00,0x00,0x04,0xc0,0x09,0x73,0x65,0x6e,0x64, 0x06,0x63,0x08,0x74,0x72,0x79,0x08,0x47,0x45,0x54,0x15,0x25,0x73,0x20,0x25,0x73, 0x20,0x48,0x54,0x54,0x50,0x2f,0x31,0x2e,0x31,0x0d,0x0a,0x0b,0x66,0x6f,0x72,0x6d, 0x61,0x74,0x9a,0x01,0x00,0x02,0x0e,0x02,0x07,0x00,0x1c,0x2b,0x02,0x00,0x00,0x37, 0x02,0x00,0x02,0x25,0x03,0x01,0x00,0x2b,0x04,0x01,0x00,0x37,0x04,0x02,0x04,0x10, 0x05,0x01,0x00,0x3e,0x04,0x02,0x04,0x54,0x07,0x09,0x80,0x36,0x09,0x07,0x02,0x0e, 0x00,0x09,0x00,0x54,0x0a,0x01,0x80,0x10,0x09,0x07,0x00,0x25,0x0a,0x03,0x00,0x10, 0x0b,0x08,0x00,0x25,0x0c,0x01,0x00,0x10,0x0d,0x03,0x00,0x24,0x03,0x0d,0x09,0x41, 0x07,0x03,0x03,0x4e,0x07,0xf5,0x7f,0x37,0x04,0x04,0x00,0x37,0x05,0x05,0x00,0x10, 0x06,0x05,0x00,0x37,0x05,0x06,0x05,0x10,0x07,0x03,0x00,0x3e,0x05,0x03,0x00,0x3d, 0x04,0x00,0x01,0x27,0x04,0x01,0x00,0x48,0x04,0x02,0x00,0x05,0xc0,0x06,0xc0,0x09, 0x73,0x65,0x6e,0x64,0x06,0x63,0x08,0x74,0x72,0x79,0x07,0x3a,0x20,0x0a,0x70,0x61, 0x69,0x72,0x73,0x07,0x0d,0x0a,0x0c,0x63,0x61,0x6e,0x6f,0x6e,0x69,0x63,0xcf,0x01, 0x00,0x04,0x0b,0x02,0x0b,0x00,0x1e,0x0e,0x00,0x02,0x00,0x54,0x04,0x05,0x80,0x2b, 0x04,0x00,0x00,0x37,0x04,0x00,0x04,0x37,0x04,0x01,0x04,0x3e,0x04,0x01,0x02,0x10, 0x02,0x04,0x00,0x0e,0x00,0x03,0x00,0x54,0x04,0x03,0x80,0x2b,0x04,0x00,0x00,0x37, 0x04,0x02,0x04,0x37,0x03,0x03,0x04,0x25,0x04,0x04,0x00,0x37,0x05,0x05,0x01,0x0f, 0x00,0x05,0x00,0x54,0x06,0x01,0x80,0x25,0x04,0x06,0x00,0x37,0x05,0x07,0x00,0x2b, 0x06,0x00,0x00,0x37,0x06,0x02,0x06,0x37,0x06,0x08,0x06,0x10,0x07,0x02,0x00,0x2b, 0x08,0x01,0x00,0x37,0x08,0x09,0x08,0x10,0x09,0x04,0x00,0x37,0x0a,0x0a,0x00,0x3e, 0x08,0x03,0x02,0x10,0x09,0x03,0x00,0x3e,0x06,0x04,0x00,0x3f,0x05,0x00,0x00,0x02, 0xc0,0x00,0xc0,0x06,0x63,0x09,0x73,0x69,0x6e,0x6b,0x08,0x61,0x6c,0x6c,0x08,0x74, 0x72,0x79,0x0e,0x6b,0x65,0x65,0x70,0x2d,0x6f,0x70,0x65,0x6e,0x13,0x63,0x6f,0x6e, 0x74,0x65,0x6e,0x74,0x2d,0x6c,0x65,0x6e,0x67,0x74,0x68,0x11,0x68,0x74,0x74,0x70, 0x2d,0x63,0x68,0x75,0x6e,0x6b,0x65,0x64,0x09,0x73,0x74,0x65,0x70,0x09,0x70,0x75, 0x6d,0x70,0x0a,0x65,0x6d,0x70,0x74,0x79,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0xe2, 0x01,0x00,0x01,0x07,0x03,0x09,0x00,0x25,0x37,0x01,0x00,0x00,0x37,0x02,0x01,0x00, 0x10,0x03,0x02,0x00,0x37,0x02,0x02,0x02,0x27,0x04,0x05,0x00,0x3e,0x02,0x03,0x00, 0x3d,0x01,0x00,0x02,0x06,0x01,0x03,0x00,0x54,0x02,0x03,0x80,0x29,0x02,0x00,0x00, 0x10,0x03,0x01,0x00,0x46,0x02,0x03,0x00,0x37,0x02,0x00,0x00,0x37,0x03,0x01,0x00, 0x10,0x04,0x03,0x00,0x37,0x03,0x02,0x03,0x25,0x05,0x04,0x00,0x10,0x06,0x01,0x00, 0x3e,0x03,0x04,0x00,0x3d,0x02,0x00,0x02,0x10,0x01,0x02,0x00,0x2b,0x02,0x00,0x00, 0x37,0x02,0x05,0x02,0x27,0x03,0x02,0x00,0x2b,0x04,0x01,0x00,0x37,0x04,0x06,0x04, 0x10,0x05,0x01,0x00,0x25,0x06,0x07,0x00,0x3e,0x04,0x03,0x00,0x3d,0x02,0x01,0x02, 0x37,0x03,0x00,0x00,0x2b,0x04,0x02,0x00,0x37,0x04,0x08,0x04,0x10,0x05,0x02,0x00, 0x3e,0x04,0x02,0x02,0x10,0x05,0x01,0x00,0x40,0x03,0x03,0x00,0x00,0xc0,0x04,0xc0, 0x06,0xc0,0x0d,0x74,0x6f,0x6e,0x75,0x6d,0x62,0x65,0x72,0x1b,0x48,0x54,0x54,0x50, 0x2f,0x25,0x64,0x2a,0x25,0x2e,0x25,0x64,0x2a,0x20,0x28,0x25,0x64,0x25,0x64,0x25, 0x64,0x29,0x09,0x66,0x69,0x6e,0x64,0x09,0x73,0x6b,0x69,0x70,0x07,0x2a,0x6c,0x0a, 0x48,0x54,0x54,0x50,0x2f,0x0c,0x72,0x65,0x63,0x65,0x69,0x76,0x65,0x06,0x63,0x08, 0x74,0x72,0x79,0x23,0x00,0x01,0x04,0x01,0x02,0x00,0x05,0x37,0x01,0x00,0x00,0x2b, 0x02,0x00,0x00,0x37,0x03,0x01,0x00,0x3e,0x02,0x02,0x00,0x3f,0x01,0x00,0x00,0x09, 0xc0,0x06,0x63,0x08,0x74,0x72,0x79,0xb8,0x02,0x00,0x04,0x0d,0x03,0x0f,0x00,0x2d, 0x0e,0x00,0x02,0x00,0x54,0x04,0x05,0x80,0x2b,0x04,0x00,0x00,0x37,0x04,0x00,0x04, 0x37,0x04,0x01,0x04,0x3e,0x04,0x01,0x02,0x10,0x02,0x04,0x00,0x0e,0x00,0x03,0x00, 0x54,0x04,0x03,0x80,0x2b,0x04,0x00,0x00,0x37,0x04,0x02,0x04,0x37,0x03,0x03,0x04, 0x2b,0x04,0x01,0x00,0x37,0x04,0x04,0x04,0x37,0x05,0x05,0x01,0x3e,0x04,0x02,0x02, 0x37,0x05,0x06,0x01,0x25,0x06,0x07,0x00,0x0f,0x00,0x05,0x00,0x54,0x07,0x04,0x80, 0x06,0x05,0x08,0x00,0x54,0x07,0x02,0x80,0x25,0x06,0x09,0x00,0x54,0x07,0x07,0x80, 0x2b,0x07,0x01,0x00,0x37,0x07,0x04,0x07,0x37,0x08,0x05,0x01,0x3e,0x07,0x02,0x02, 0x0f,0x00,0x07,0x00,0x54,0x08,0x01,0x80,0x25,0x06,0x0a,0x00,0x37,0x07,0x0b,0x00, 0x2b,0x08,0x00,0x00,0x37,0x08,0x02,0x08,0x37,0x08,0x0c,0x08,0x2b,0x09,0x02,0x00, 0x37,0x09,0x0d,0x09,0x10,0x0a,0x06,0x00,0x37,0x0b,0x0e,0x00,0x10,0x0c,0x04,0x00, 0x3e,0x09,0x04,0x02,0x10,0x0a,0x02,0x00,0x10,0x0b,0x03,0x00,0x3e,0x08,0x04,0x00, 0x3f,0x07,0x00,0x00,0x02,0xc0,0x06,0xc0,0x00,0xc0,0x06,0x63,0x0b,0x73,0x6f,0x75, 0x72,0x63,0x65,0x08,0x61,0x6c,0x6c,0x08,0x74,0x72,0x79,0x0e,0x62,0x79,0x2d,0x6c, 0x65,0x6e,0x67,0x74,0x68,0x11,0x68,0x74,0x74,0x70,0x2d,0x63,0x68,0x75,0x6e,0x6b, 0x65,0x64,0x0d,0x69,0x64,0x65,0x6e,0x74,0x69,0x74,0x79,0x0c,0x64,0x65,0x66,0x61, 0x75,0x6c,0x74,0x16,0x74,0x72,0x61,0x6e,0x73,0x66,0x65,0x72,0x2d,0x65,0x6e,0x63, 0x6f,0x64,0x69,0x6e,0x67,0x13,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x6c,0x65, 0x6e,0x67,0x74,0x68,0x0d,0x74,0x6f,0x6e,0x75,0x6d,0x62,0x65,0x72,0x09,0x73,0x74, 0x65,0x70,0x09,0x70,0x75,0x6d,0x70,0x09,0x6e,0x75,0x6c,0x6c,0x09,0x73,0x69,0x6e, 0x6b,0x89,0x01,0x00,0x04,0x0a,0x02,0x07,0x00,0x15,0x2b,0x04,0x00,0x00,0x37,0x04, 0x00,0x04,0x37,0x04,0x01,0x04,0x2b,0x05,0x01,0x00,0x37,0x05,0x00,0x05,0x25,0x06, 0x02,0x00,0x37,0x07,0x03,0x00,0x3e,0x05,0x03,0x00,0x3d,0x04,0x00,0x02,0x10,0x05, 0x04,0x00,0x10,0x06,0x01,0x00,0x3e,0x05,0x02,0x01,0x37,0x05,0x04,0x00,0x2b,0x06, 0x00,0x00,0x37,0x06,0x05,0x06,0x37,0x06,0x06,0x06,0x10,0x07,0x04,0x00,0x10,0x08, 0x02,0x00,0x10,0x09,0x03,0x00,0x3e,0x06,0x04,0x00,0x3f,0x05,0x00,0x00,0x02,0xc0, 0x00,0xc0,0x08,0x61,0x6c,0x6c,0x09,0x70,0x75,0x6d,0x70,0x08,0x74,0x72,0x79,0x06, 0x63,0x11,0x75,0x6e,0x74,0x69,0x6c,0x2d,0x63,0x6c,0x6f,0x73,0x65,0x64,0x0b,0x72, 0x65,0x77,0x69,0x6e,0x64,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0x1f,0x00,0x01,0x03, 0x00,0x02,0x00,0x04,0x37,0x01,0x00,0x00,0x10,0x02,0x01,0x00,0x37,0x01,0x01,0x01, 0x40,0x01,0x02,0x00,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x06,0x63,0xbc,0x01,0x00,0x01, 0x06,0x03,0x0a,0x00,0x1a,0x10,0x01,0x00,0x00,0x37,0x02,0x00,0x00,0x0e,0x00,0x02, 0x00,0x54,0x02,0x12,0x80,0x2b,0x02,0x00,0x00,0x37,0x02,0x01,0x02,0x0e,0x00,0x02, 0x00,0x54,0x02,0x0e,0x80,0x33,0x02,0x05,0x00,0x2b,0x03,0x01,0x00,0x37,0x03,0x02, 0x03,0x37,0x04,0x03,0x00,0x25,0x05,0x04,0x00,0x3e,0x03,0x03,0x02,0x3a,0x03,0x03, 0x02,0x37,0x03,0x06,0x00,0x3a,0x03,0x06,0x02,0x37,0x03,0x07,0x00,0x3a,0x03,0x07, 0x02,0x37,0x03,0x08,0x00,0x3a,0x03,0x08,0x02,0x10,0x01,0x02,0x00,0x2b,0x02,0x02, 0x00,0x37,0x02,0x09,0x02,0x10,0x03,0x01,0x00,0x40,0x02,0x02,0x00,0x08,0xc0,0x00, 0xc0,0x01,0xc0,0x0a,0x62,0x75,0x69,0x6c,0x64,0x0d,0x66,0x72,0x61,0x67,0x6d,0x65, 0x6e,0x74,0x0a,0x71,0x75,0x65,0x72,0x79,0x0b,0x70,0x61,0x72,0x61,0x6d,0x73,0x01, 0x00,0x00,0x17,0x69,0x6e,0x76,0x61,0x6c,0x69,0x64,0x20,0x70,0x61,0x74,0x68,0x20, 0x27,0x6e,0x69,0x6c,0x27,0x09,0x70,0x61,0x74,0x68,0x08,0x74,0x72,0x79,0x0a,0x50, 0x52,0x4f,0x58,0x59,0x0a,0x70,0x72,0x6f,0x78,0x79,0x83,0x01,0x00,0x01,0x04,0x02, 0x05,0x00,0x17,0x37,0x01,0x00,0x00,0x0e,0x00,0x01,0x00,0x54,0x02,0x02,0x80,0x2b, 0x01,0x00,0x00,0x37,0x01,0x01,0x01,0x0f,0x00,0x01,0x00,0x54,0x02,0x0c,0x80,0x2b, 0x02,0x01,0x00,0x37,0x02,0x02,0x02,0x10,0x03,0x01,0x00,0x3e,0x02,0x02,0x02,0x10, 0x01,0x02,0x00,0x37,0x02,0x03,0x01,0x37,0x03,0x04,0x01,0x0e,0x00,0x03,0x00,0x54, 0x04,0x01,0x80,0x27,0x03,0x38,0x0c,0x46,0x02,0x03,0x00,0x54,0x02,0x03,0x80,0x37, 0x02,0x03,0x00,0x37,0x03,0x04,0x00,0x46,0x02,0x03,0x00,0x47,0x00,0x01,0x00,0x08, 0xc0,0x01,0xc0,0x09,0x70,0x6f,0x72,0x74,0x09,0x68,0x6f,0x73,0x74,0x0a,0x70,0x61, 0x72,0x73,0x65,0x0a,0x50,0x52,0x4f,0x58,0x59,0x0a,0x70,0x72,0x6f,0x78,0x79,0xc3, 0x02,0x00,0x01,0x0a,0x04,0x0e,0x00,0x2d,0x37,0x01,0x00,0x00,0x37,0x02,0x01,0x00, 0x0f,0x00,0x02,0x00,0x54,0x03,0x04,0x80,0x10,0x02,0x01,0x00,0x25,0x03,0x02,0x00, 0x37,0x04,0x01,0x00,0x24,0x01,0x04,0x02,0x33,0x02,0x04,0x00,0x2b,0x03,0x00,0x00, 0x37,0x03,0x03,0x03,0x3a,0x03,0x05,0x02,0x3a,0x01,0x00,0x02,0x37,0x03,0x06,0x00, 0x0f,0x00,0x03,0x00,0x54,0x04,0x0d,0x80,0x37,0x03,0x07,0x00,0x0f,0x00,0x03,0x00, 0x54,0x04,0x0a,0x80,0x25,0x03,0x09,0x00,0x2b,0x04,0x01,0x00,0x37,0x04,0x0a,0x04, 0x37,0x05,0x06,0x00,0x25,0x06,0x02,0x00,0x37,0x07,0x07,0x00,0x24,0x05,0x07,0x05, 0x3e,0x04,0x02,0x02,0x24,0x03,0x04,0x03,0x3a,0x03,0x08,0x02,0x2b,0x03,0x02,0x00, 0x37,0x03,0x0b,0x03,0x37,0x04,0x0c,0x00,0x0e,0x00,0x04,0x00,0x54,0x05,0x01,0x80, 0x10,0x04,0x02,0x00,0x3e,0x03,0x02,0x04,0x54,0x06,0x05,0x80,0x2b,0x08,0x03,0x00, 0x37,0x08,0x0d,0x08,0x10,0x09,0x06,0x00,0x3e,0x08,0x02,0x02,0x39,0x07,0x08,0x02, 0x41,0x06,0x03,0x03,0x4e,0x06,0xf9,0x7f,0x48,0x02,0x02,0x00,0x08,0xc0,0x03,0xc0, 0x06,0xc0,0x04,0xc0,0x0a,0x6c,0x6f,0x77,0x65,0x72,0x0c,0x68,0x65,0x61,0x64,0x65, 0x72,0x73,0x0a,0x70,0x61,0x69,0x72,0x73,0x08,0x62,0x36,0x34,0x0b,0x42,0x61,0x73, 0x69,0x63,0x20,0x12,0x61,0x75,0x74,0x68,0x6f,0x72,0x69,0x7a,0x61,0x74,0x69,0x6f, 0x6e,0x0d,0x70,0x61,0x73,0x73,0x77,0x6f,0x72,0x64,0x09,0x75,0x73,0x65,0x72,0x0f, 0x75,0x73,0x65,0x72,0x2d,0x61,0x67,0x65,0x6e,0x74,0x01,0x00,0x02,0x07,0x74,0x65, 0x0d,0x74,0x72,0x61,0x69,0x6c,0x65,0x72,0x73,0x0f,0x63,0x6f,0x6e,0x6e,0x65,0x63, 0x74,0x69,0x6f,0x6e,0x0e,0x63,0x6c,0x6f,0x73,0x65,0x2c,0x20,0x54,0x45,0x0e,0x55, 0x53,0x45,0x52,0x41,0x47,0x45,0x4e,0x54,0x06,0x3a,0x09,0x70,0x6f,0x72,0x74,0x09, 0x68,0x6f,0x73,0x74,0xca,0x02,0x00,0x01,0x08,0x07,0x0c,0x00,0x3c,0x37,0x01,0x00, 0x00,0x0f,0x00,0x01,0x00,0x54,0x02,0x07,0x80,0x2b,0x01,0x00,0x00,0x37,0x01,0x01, 0x01,0x37,0x02,0x00,0x00,0x2b,0x03,0x01,0x00,0x3e,0x01,0x03,0x02,0x0e,0x00,0x01, 0x00,0x54,0x02,0x01,0x80,0x32,0x01,0x00,0x00,0x2b,0x02,0x02,0x00,0x37,0x02,0x02, 0x02,0x10,0x03,0x00,0x00,0x3e,0x02,0x02,0x04,0x54,0x05,0x01,0x80,0x39,0x06,0x05, 0x01,0x41,0x05,0x03,0x03,0x4e,0x05,0xfd,0x7f,0x37,0x02,0x03,0x01,0x07,0x02,0x04, 0x00,0x54,0x02,0x02,0x80,0x27,0x02,0x50,0x00,0x3a,0x02,0x03,0x01,0x2b,0x02,0x03, 0x00,0x37,0x02,0x05,0x02,0x37,0x03,0x06,0x01,0x0f,0x00,0x03,0x00,0x54,0x04,0x06, 0x80,0x37,0x03,0x06,0x01,0x07,0x03,0x04,0x00,0x54,0x03,0x02,0x80,0x29,0x03,0x01, 0x00,0x54,0x04,0x01,0x80,0x29,0x03,0x02,0x00,0x25,0x04,0x07,0x00,0x2b,0x05,0x02, 0x00,0x37,0x05,0x08,0x05,0x37,0x06,0x06,0x01,0x3e,0x05,0x02,0x02,0x25,0x06,0x09, 0x00,0x24,0x04,0x06,0x04,0x3e,0x02,0x03,0x01,0x37,0x02,0x0a,0x00,0x0e,0x00,0x02, 0x00,0x54,0x03,0x03,0x80,0x2b,0x02,0x04,0x00,0x10,0x03,0x01,0x00,0x3e,0x02,0x02, 0x02,0x3a,0x02,0x0a,0x01,0x2b,0x02,0x05,0x00,0x10,0x03,0x01,0x00,0x3e,0x02,0x02, 0x03,0x3a,0x03,0x03,0x01,0x3a,0x02,0x06,0x01,0x2b,0x02,0x06,0x00,0x10,0x03,0x01, 0x00,0x3e,0x02,0x02,0x02,0x3a,0x02,0x0b,0x01,0x48,0x01,0x02,0x00,0x01,0xc0,0x0e, 0xc0,0x06,0xc0,0x00,0xc0,0x0b,0xc0,0x0c,0xc0,0x0d,0xc0,0x0c,0x68,0x65,0x61,0x64, 0x65,0x72,0x73,0x08,0x75,0x72,0x69,0x06,0x27,0x0d,0x74,0x6f,0x73,0x74,0x72,0x69, 0x6e,0x67,0x13,0x69,0x6e,0x76,0x61,0x6c,0x69,0x64,0x20,0x68,0x6f,0x73,0x74,0x20, 0x27,0x09,0x68,0x6f,0x73,0x74,0x08,0x74,0x72,0x79,0x05,0x09,0x70,0x6f,0x72,0x74, 0x0a,0x70,0x61,0x69,0x72,0x73,0x0a,0x70,0x61,0x72,0x73,0x65,0x08,0x75,0x72,0x6c, 0xef,0x01,0x00,0x03,0x07,0x01,0x09,0x04,0x2a,0x37,0x03,0x00,0x02,0x0f,0x00,0x03, 0x00,0x54,0x04,0x26,0x80,0x2b,0x03,0x00,0x00,0x37,0x03,0x01,0x03,0x37,0x04,0x00, 0x02,0x25,0x05,0x02,0x00,0x25,0x06,0x03,0x00,0x3e,0x03,0x04,0x02,0x06,0x03,0x03, 0x00,0x54,0x03,0x1b,0x80,0x37,0x03,0x04,0x00,0x0a,0x03,0x01,0x00,0x54,0x03,0x18, 0x80,0x08,0x01,0x00,0x00,0x54,0x03,0x06,0x80,0x08,0x01,0x01,0x00,0x54,0x03,0x04, 0x80,0x08,0x01,0x02,0x00,0x54,0x03,0x02,0x80,0x09,0x01,0x03,0x00,0x54,0x03,0x10, 0x80,0x37,0x03,0x05,0x00,0x0f,0x00,0x03,0x00,0x54,0x03,0x06,0x80,0x37,0x03,0x05, 0x00,0x06,0x03,0x06,0x00,0x54,0x03,0x03,0x80,0x37,0x03,0x05,0x00,0x07,0x03,0x07, 0x00,0x54,0x03,0x07,0x80,0x37,0x03,0x08,0x00,0x0f,0x00,0x03,0x00,0x54,0x03,0x06, 0x80,0x37,0x03,0x08,0x00,0x27,0x04,0x05,0x00,0x00,0x03,0x04,0x00,0x54,0x03,0x02, 0x80,0x29,0x03,0x01,0x00,0x54,0x04,0x01,0x80,0x29,0x03,0x02,0x00,0x48,0x03,0x02, 0x00,0x04,0xc0,0x0f,0x6e,0x72,0x65,0x64,0x69,0x72,0x65,0x63,0x74,0x73,0x09,0x48, 0x45,0x41,0x44,0x08,0x47,0x45,0x54,0x0b,0x6d,0x65,0x74,0x68,0x6f,0x64,0x0d,0x72, 0x65,0x64,0x69,0x72,0x65,0x63,0x74,0x05,0x07,0x25,0x73,0x09,0x67,0x73,0x75,0x62, 0x0d,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0xda,0x04,0xdc,0x04,0xde,0x04,0xe6, 0x04,0x6b,0x00,0x02,0x03,0x00,0x02,0x02,0x15,0x37,0x02,0x00,0x00,0x07,0x02,0x01, 0x00,0x54,0x02,0x02,0x80,0x29,0x02,0x00,0x00,0x48,0x02,0x02,0x00,0x08,0x01,0x00, 0x00,0x54,0x02,0x02,0x80,0x09,0x01,0x01,0x00,0x54,0x02,0x02,0x80,0x29,0x02,0x00, 0x00,0x48,0x02,0x02,0x00,0x27,0x02,0x64,0x00,0x03,0x02,0x01,0x00,0x54,0x02,0x05, 0x80,0x27,0x02,0xc8,0x00,0x01,0x01,0x02,0x00,0x54,0x02,0x02,0x80,0x29,0x02,0x00, 0x00,0x48,0x02,0x02,0x00,0x27,0x02,0x01,0x00,0x48,0x02,0x02,0x00,0x09,0x48,0x45, 0x41,0x44,0x0b,0x6d,0x65,0x74,0x68,0x6f,0x64,0x98,0x03,0xe0,0x04,0xe9,0x01,0x00, 0x02,0x0a,0x02,0x0a,0x01,0x26,0x2b,0x02,0x00,0x00,0x33,0x03,0x02,0x00,0x2b,0x04, 0x01,0x00,0x37,0x04,0x00,0x04,0x37,0x05,0x01,0x00,0x10,0x06,0x01,0x00,0x3e,0x04, 0x03,0x02,0x3a,0x04,0x01,0x03,0x37,0x04,0x03,0x00,0x3a,0x04,0x03,0x03,0x37,0x04, 0x04,0x00,0x3a,0x04,0x04,0x03,0x37,0x04,0x05,0x00,0x3a,0x04,0x05,0x03,0x37,0x04, 0x06,0x00,0x3a,0x04,0x06,0x03,0x37,0x04,0x07,0x00,0x0e,0x00,0x04,0x00,0x54,0x05, 0x01,0x80,0x27,0x04,0x00,0x00,0x14,0x04,0x00,0x04,0x3a,0x04,0x07,0x03,0x37,0x04, 0x08,0x00,0x3a,0x04,0x08,0x03,0x3e,0x02,0x02,0x05,0x0e,0x00,0x04,0x00,0x54,0x06, 0x01,0x80,0x32,0x04,0x00,0x00,0x37,0x06,0x09,0x04,0x0e,0x00,0x06,0x00,0x54,0x07, 0x01,0x80,0x10,0x06,0x01,0x00,0x3a,0x06,0x09,0x04,0x10,0x06,0x02,0x00,0x10,0x07, 0x03,0x00,0x10,0x08,0x04,0x00,0x10,0x09,0x05,0x00,0x46,0x06,0x05,0x00,0x12,0x80, 0x01,0xc0,0x0d,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x0b,0x63,0x72,0x65,0x61, 0x74,0x65,0x0f,0x6e,0x72,0x65,0x64,0x69,0x72,0x65,0x63,0x74,0x73,0x0a,0x70,0x72, 0x6f,0x78,0x79,0x0c,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x09,0x73,0x69,0x6e,0x6b, 0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0x01,0x00,0x00,0x08,0x75,0x72,0x6c,0x0d,0x61, 0x62,0x73,0x6f,0x6c,0x75,0x74,0x65,0x02,0xbc,0x04,0x00,0x01,0x0b,0x05,0x13,0x01, 0x60,0x2b,0x01,0x00,0x00,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x02,0x2b,0x02,0x01, 0x00,0x37,0x02,0x00,0x02,0x37,0x03,0x01,0x01,0x37,0x04,0x02,0x01,0x37,0x05,0x03, 0x01,0x3e,0x02,0x04,0x02,0x10,0x04,0x02,0x00,0x37,0x03,0x04,0x02,0x37,0x05,0x05, 0x01,0x37,0x06,0x06,0x01,0x3e,0x03,0x04,0x01,0x10,0x04,0x02,0x00,0x37,0x03,0x07, 0x02,0x37,0x05,0x08,0x01,0x3e,0x03,0x03,0x01,0x37,0x03,0x09,0x01,0x0f,0x00,0x03, 0x00,0x54,0x04,0x06,0x80,0x10,0x04,0x02,0x00,0x37,0x03,0x0a,0x02,0x37,0x05,0x08, 0x01,0x37,0x06,0x09,0x01,0x37,0x07,0x0b,0x01,0x3e,0x03,0x05,0x01,0x10,0x04,0x02, 0x00,0x37,0x03,0x0c,0x02,0x3e,0x03,0x02,0x03,0x0e,0x00,0x03,0x00,0x54,0x05,0x09, 0x80,0x10,0x06,0x02,0x00,0x37,0x05,0x0d,0x02,0x10,0x07,0x04,0x00,0x37,0x08,0x0e, 0x01,0x37,0x09,0x0b,0x01,0x3e,0x05,0x05,0x01,0x27,0x05,0x01,0x00,0x27,0x06,0xc8, 0x00,0x46,0x05,0x03,0x00,0x29,0x05,0x00,0x00,0x09,0x03,0x00,0x00,0x54,0x06,0x0b, 0x80,0x51,0x06,0x0a,0x80,0x10,0x07,0x02,0x00,0x37,0x06,0x0f,0x02,0x3e,0x06,0x02, 0x02,0x10,0x05,0x06,0x00,0x10,0x07,0x02,0x00,0x37,0x06,0x0c,0x02,0x3e,0x06,0x02, 0x03,0x10,0x04,0x07,0x00,0x10,0x03,0x06,0x00,0x54,0x06,0xf3,0x7f,0x10,0x07,0x02, 0x00,0x37,0x06,0x0f,0x02,0x3e,0x06,0x02,0x02,0x10,0x05,0x06,0x00,0x2b,0x06,0x02, 0x00,0x10,0x07,0x01,0x00,0x10,0x08,0x03,0x00,0x10,0x09,0x05,0x00,0x3e,0x06,0x04, 0x02,0x0f,0x00,0x06,0x00,0x54,0x07,0x0a,0x80,0x37,0x06,0x09,0x01,0x0e,0x00,0x06, 0x00,0x54,0x06,0x07,0x80,0x10,0x07,0x02,0x00,0x37,0x06,0x10,0x02,0x3e,0x06,0x02, 0x01,0x2b,0x06,0x03,0x00,0x10,0x07,0x00,0x00,0x37,0x08,0x11,0x05,0x40,0x06,0x03, 0x00,0x2b,0x06,0x04,0x00,0x10,0x07,0x01,0x00,0x10,0x08,0x03,0x00,0x3e,0x06,0x03, 0x02,0x0f,0x00,0x06,0x00,0x54,0x07,0x06,0x80,0x10,0x07,0x02,0x00,0x37,0x06,0x12, 0x02,0x10,0x08,0x05,0x00,0x37,0x09,0x0e,0x01,0x37,0x0a,0x0b,0x01,0x3e,0x06,0x05, 0x01,0x10,0x07,0x02,0x00,0x37,0x06,0x10,0x02,0x3e,0x06,0x02,0x01,0x27,0x06,0x01, 0x00,0x10,0x07,0x03,0x00,0x10,0x08,0x05,0x00,0x10,0x09,0x04,0x00,0x46,0x06,0x05, 0x00,0x0f,0xc0,0x08,0xc0,0x10,0xc0,0x13,0x80,0x11,0xc0,0x10,0x72,0x65,0x63,0x65, 0x69,0x76,0x65,0x62,0x6f,0x64,0x79,0x0d,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e, 0x0a,0x63,0x6c,0x6f,0x73,0x65,0x13,0x72,0x65,0x63,0x65,0x69,0x76,0x65,0x68,0x65, 0x61,0x64,0x65,0x72,0x73,0x09,0x73,0x69,0x6e,0x6b,0x12,0x72,0x65,0x63,0x65,0x69, 0x76,0x65,0x30,0x39,0x62,0x6f,0x64,0x79,0x16,0x72,0x65,0x63,0x65,0x69,0x76,0x65, 0x73,0x74,0x61,0x74,0x75,0x73,0x6c,0x69,0x6e,0x65,0x09,0x73,0x74,0x65,0x70,0x0d, 0x73,0x65,0x6e,0x64,0x62,0x6f,0x64,0x79,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0x0c, 0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x10,0x73,0x65,0x6e,0x64,0x68,0x65,0x61,0x64, 0x65,0x72,0x73,0x08,0x75,0x72,0x69,0x0b,0x6d,0x65,0x74,0x68,0x6f,0x64,0x14,0x73, 0x65,0x6e,0x64,0x72,0x65,0x71,0x75,0x65,0x73,0x74,0x6c,0x69,0x6e,0x65,0x0b,0x63, 0x72,0x65,0x61,0x74,0x65,0x09,0x70,0x6f,0x72,0x74,0x09,0x68,0x6f,0x73,0x74,0x09, 0x6f,0x70,0x65,0x6e,0xc8,0x01,0xba,0x02,0x00,0x02,0x0b,0x05,0x0e,0x00,0x29,0x32, 0x02,0x00,0x00,0x33,0x03,0x00,0x00,0x3a,0x00,0x01,0x03,0x2b,0x04,0x00,0x00,0x37, 0x04,0x02,0x04,0x37,0x04,0x03,0x04,0x10,0x05,0x02,0x00,0x3e,0x04,0x02,0x02,0x3a, 0x04,0x02,0x03,0x0f,0x00,0x01,0x00,0x54,0x04,0x0f,0x80,0x2b,0x04,0x00,0x00,0x37, 0x04,0x04,0x04,0x37,0x04,0x05,0x04,0x10,0x05,0x01,0x00,0x3e,0x04,0x02,0x02,0x3a, 0x04,0x04,0x03,0x33,0x04,0x08,0x00,0x2b,0x05,0x01,0x00,0x37,0x05,0x07,0x05,0x10, 0x06,0x01,0x00,0x3e,0x05,0x02,0x02,0x3a,0x05,0x09,0x04,0x3a,0x04,0x06,0x03,0x25, 0x04,0x0b,0x00,0x3a,0x04,0x0a,0x03,0x2b,0x04,0x02,0x00,0x37,0x04,0x0c,0x04,0x27, 0x05,0x01,0x00,0x2b,0x06,0x03,0x00,0x10,0x07,0x03,0x00,0x3e,0x06,0x02,0x00,0x3d, 0x04,0x01,0x04,0x2b,0x07,0x04,0x00,0x37,0x07,0x0d,0x07,0x10,0x08,0x02,0x00,0x3e, 0x07,0x02,0x02,0x10,0x08,0x04,0x00,0x10,0x09,0x05,0x00,0x10,0x0a,0x06,0x00,0x46, 0x07,0x05,0x00,0x02,0xc0,0x04,0xc0,0x00,0xc0,0x12,0x80,0x07,0xc0,0x0b,0x63,0x6f, 0x6e,0x63,0x61,0x74,0x09,0x73,0x6b,0x69,0x70,0x09,0x50,0x4f,0x53,0x54,0x0b,0x6d, 0x65,0x74,0x68,0x6f,0x64,0x13,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x6c,0x65, 0x6e,0x67,0x74,0x68,0x01,0x00,0x01,0x11,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d, 0x74,0x79,0x70,0x65,0x26,0x61,0x70,0x70,0x6c,0x69,0x63,0x61,0x74,0x69,0x6f,0x6e, 0x2f,0x78,0x2d,0x77,0x77,0x77,0x2d,0x66,0x6f,0x72,0x6d,0x2d,0x75,0x72,0x6c,0x65, 0x6e,0x63,0x6f,0x64,0x65,0x64,0x08,0x6c,0x65,0x6e,0x0c,0x68,0x65,0x61,0x64,0x65, 0x72,0x73,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65, 0x0a,0x74,0x61,0x62,0x6c,0x65,0x09,0x73,0x69,0x6e,0x6b,0x08,0x75,0x72,0x6c,0x01, 0x00,0x00,0x55,0x00,0x02,0x05,0x03,0x02,0x00,0x0f,0x2b,0x02,0x00,0x00,0x37,0x02, 0x00,0x02,0x10,0x03,0x00,0x00,0x3e,0x02,0x02,0x02,0x07,0x02,0x01,0x00,0x54,0x02, 0x05,0x80,0x2b,0x02,0x01,0x00,0x10,0x03,0x00,0x00,0x10,0x04,0x01,0x00,0x40,0x02, 0x03,0x00,0x54,0x02,0x03,0x80,0x2b,0x02,0x02,0x00,0x10,0x03,0x00,0x00,0x40,0x02, 0x02,0x00,0x47,0x00,0x01,0x00,0x06,0xc0,0x14,0xc0,0x12,0x80,0x0b,0x73,0x74,0x72, 0x69,0x6e,0x67,0x09,0x74,0x79,0x70,0x65,0xa0,0x05,0x03,0x00,0x17,0x00,0x36,0x00, 0x56,0x34,0x00,0x00,0x00,0x25,0x01,0x01,0x00,0x3e,0x00,0x02,0x02,0x34,0x01,0x00, 0x00,0x25,0x02,0x02,0x00,0x3e,0x01,0x02,0x02,0x34,0x02,0x00,0x00,0x25,0x03,0x03, 0x00,0x3e,0x02,0x02,0x02,0x34,0x03,0x00,0x00,0x25,0x04,0x04,0x00,0x3e,0x03,0x02, 0x02,0x34,0x04,0x00,0x00,0x25,0x05,0x05,0x00,0x3e,0x04,0x02,0x02,0x34,0x05,0x00, 0x00,0x25,0x06,0x06,0x00,0x3e,0x05,0x02,0x02,0x34,0x06,0x07,0x00,0x34,0x07,0x00, 0x00,0x25,0x08,0x08,0x00,0x3e,0x07,0x02,0x02,0x32,0x08,0x00,0x00,0x3a,0x08,0x09, 0x00,0x37,0x08,0x09,0x00,0x27,0x09,0x3c,0x00,0x3a,0x09,0x0a,0x08,0x27,0x09,0x50, 0x00,0x3a,0x09,0x0b,0x08,0x37,0x09,0x0d,0x00,0x3a,0x09,0x0c,0x08,0x31,0x09,0x0e, 0x00,0x37,0x0a,0x0f,0x00,0x31,0x0b,0x11,0x00,0x3a,0x0b,0x10,0x0a,0x37,0x0a,0x12, 0x00,0x31,0x0b,0x13,0x00,0x3a,0x0b,0x10,0x0a,0x33,0x0a,0x14,0x00,0x32,0x0b,0x00, 0x00,0x3a,0x0b,0x15,0x0a,0x31,0x0b,0x17,0x00,0x3a,0x0b,0x16,0x08,0x37,0x0b,0x15, 0x0a,0x31,0x0c,0x19,0x00,0x3a,0x0c,0x18,0x0b,0x37,0x0b,0x15,0x0a,0x31,0x0c,0x1b, 0x00,0x3a,0x0c,0x1a,0x0b,0x37,0x0b,0x15,0x0a,0x31,0x0c,0x1d,0x00,0x3a,0x0c,0x1c, 0x0b,0x37,0x0b,0x15,0x0a,0x31,0x0c,0x1f,0x00,0x3a,0x0c,0x1e,0x0b,0x37,0x0b,0x15, 0x0a,0x31,0x0c,0x21,0x00,0x3a,0x0c,0x20,0x0b,0x37,0x0b,0x15,0x0a,0x31,0x0c,0x23, 0x00,0x3a,0x0c,0x22,0x0b,0x37,0x0b,0x15,0x0a,0x31,0x0c,0x25,0x00,0x3a,0x0c,0x24, 0x0b,0x37,0x0b,0x15,0x0a,0x31,0x0c,0x27,0x00,0x3a,0x0c,0x26,0x0b,0x31,0x0b,0x28, 0x00,0x31,0x0c,0x29,0x00,0x31,0x0d,0x2a,0x00,0x33,0x0e,0x2b,0x00,0x37,0x0f,0x0b, 0x08,0x3a,0x0f,0x2c,0x0e,0x31,0x0f,0x2d,0x00,0x31,0x10,0x2e,0x00,0x31,0x11,0x2f, 0x00,0x2a,0x12,0x13,0x00,0x31,0x13,0x30,0x00,0x31,0x12,0x31,0x00,0x31,0x14,0x32, 0x00,0x37,0x15,0x34,0x00,0x31,0x16,0x35,0x00,0x3e,0x15,0x02,0x02,0x3a,0x15,0x33, 0x08,0x30,0x00,0x00,0x80,0x48,0x08,0x02,0x00,0x00,0x0c,0x70,0x72,0x6f,0x74,0x65, 0x63,0x74,0x0c,0x72,0x65,0x71,0x75,0x65,0x73,0x74,0x00,0x00,0x00,0x00,0x00,0x00, 0x09,0x70,0x6f,0x72,0x74,0x01,0x00,0x03,0x0b,0x73,0x63,0x68,0x65,0x6d,0x65,0x09, 0x68,0x74,0x74,0x70,0x09,0x70,0x61,0x74,0x68,0x06,0x2f,0x09,0x68,0x6f,0x73,0x74, 0x05,0x00,0x00,0x00,0x00,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x00,0x12,0x72,0x65,0x63, 0x65,0x69,0x76,0x65,0x30,0x39,0x62,0x6f,0x64,0x79,0x00,0x10,0x72,0x65,0x63,0x65, 0x69,0x76,0x65,0x62,0x6f,0x64,0x79,0x00,0x13,0x72,0x65,0x63,0x65,0x69,0x76,0x65, 0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x00,0x16,0x72,0x65,0x63,0x65,0x69,0x76,0x65, 0x73,0x74,0x61,0x74,0x75,0x73,0x6c,0x69,0x6e,0x65,0x00,0x0d,0x73,0x65,0x6e,0x64, 0x62,0x6f,0x64,0x79,0x00,0x10,0x73,0x65,0x6e,0x64,0x68,0x65,0x61,0x64,0x65,0x72, 0x73,0x00,0x14,0x73,0x65,0x6e,0x64,0x72,0x65,0x71,0x75,0x65,0x73,0x74,0x6c,0x69, 0x6e,0x65,0x00,0x09,0x6f,0x70,0x65,0x6e,0x0c,0x5f,0x5f,0x69,0x6e,0x64,0x65,0x78, 0x01,0x00,0x00,0x00,0x0a,0x73,0x69,0x6e,0x6b,0x74,0x00,0x11,0x68,0x74,0x74,0x70, 0x2d,0x63,0x68,0x75,0x6e,0x6b,0x65,0x64,0x0c,0x73,0x6f,0x75,0x72,0x63,0x65,0x74, 0x00,0x0d,0x5f,0x56,0x45,0x52,0x53,0x49,0x4f,0x4e,0x0e,0x55,0x53,0x45,0x52,0x41, 0x47,0x45,0x4e,0x54,0x09,0x50,0x4f,0x52,0x54,0x0c,0x54,0x49,0x4d,0x45,0x4f,0x55, 0x54,0x09,0x68,0x74,0x74,0x70,0x0a,0x74,0x61,0x62,0x6c,0x65,0x07,0x5f,0x47,0x13, 0x73,0x6f,0x63,0x6b,0x65,0x74,0x2e,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x0b,0x73, 0x74,0x72,0x69,0x6e,0x67,0x09,0x6d,0x69,0x6d,0x65,0x0a,0x6c,0x74,0x6e,0x31,0x32, 0x0f,0x73,0x6f,0x63,0x6b,0x65,0x74,0x2e,0x75,0x72,0x6c,0x0b,0x73,0x6f,0x63,0x6b, 0x65,0x74,0x0c,0x72,0x65,0x71,0x75,0x69,0x72,0x65,0x00, }; /* socket.mbox, socket/mbox.lua */ static const char lua_m_socket_mbox[] = { 0x1b,0x4c,0x4a,0x01,0x02,0x1d,0x00,0x01,0x02,0x01,0x01,0x00,0x03,0x2b,0x01,0x00, 0x00,0x3a,0x00,0x00,0x01,0x47,0x00,0x01,0x00,0x01,0xc0,0x0c,0x68,0x65,0x61,0x64, 0x65,0x72,0x73,0x1a,0x00,0x01,0x02,0x01,0x01,0x00,0x03,0x2b,0x01,0x00,0x00,0x3a, 0x00,0x00,0x01,0x47,0x00,0x01,0x00,0x01,0xc0,0x09,0x62,0x6f,0x64,0x79,0x1a,0x00, 0x01,0x02,0x01,0x01,0x00,0x03,0x2b,0x01,0x00,0x00,0x3a,0x00,0x00,0x01,0x47,0x00, 0x01,0x00,0x01,0xc0,0x09,0x62,0x6f,0x64,0x79,0xfa,0x01,0x01,0x01,0x06,0x00,0x0d, 0x00,0x2e,0x32,0x01,0x00,0x00,0x34,0x02,0x00,0x00,0x37,0x02,0x01,0x02,0x10,0x03, 0x00,0x00,0x25,0x04,0x02,0x00,0x25,0x05,0x03,0x00,0x3e,0x02,0x04,0x02,0x10,0x00, 0x02,0x00,0x34,0x02,0x00,0x00,0x37,0x02,0x01,0x02,0x10,0x03,0x00,0x00,0x25,0x04, 0x04,0x00,0x31,0x05,0x05,0x00,0x3e,0x02,0x04,0x01,0x34,0x02,0x00,0x00,0x37,0x02, 0x01,0x02,0x10,0x03,0x00,0x00,0x25,0x04,0x06,0x00,0x31,0x05,0x07,0x00,0x3e,0x02, 0x04,0x01,0x37,0x02,0x08,0x01,0x0e,0x00,0x02,0x00,0x54,0x02,0x06,0x80,0x34,0x02, 0x00,0x00,0x37,0x02,0x01,0x02,0x10,0x03,0x00,0x00,0x25,0x04,0x09,0x00,0x31,0x05, 0x0a,0x00,0x3e,0x02,0x04,0x01,0x37,0x02,0x0b,0x01,0x0e,0x00,0x02,0x00,0x54,0x02, 0x04,0x80,0x37,0x02,0x08,0x01,0x0e,0x00,0x02,0x00,0x54,0x02,0x01,0x80,0x3a,0x00, 0x0b,0x01,0x37,0x02,0x0b,0x01,0x0e,0x00,0x02,0x00,0x54,0x03,0x01,0x80,0x25,0x02, 0x0c,0x00,0x37,0x03,0x08,0x01,0x0e,0x00,0x03,0x00,0x54,0x04,0x01,0x80,0x25,0x03, 0x0c,0x00,0x30,0x00,0x00,0x80,0x46,0x02,0x03,0x00,0x05,0x0c,0x68,0x65,0x61,0x64, 0x65,0x72,0x73,0x00,0x0b,0x5e,0x0a,0x28,0x2e,0x2a,0x29,0x09,0x62,0x6f,0x64,0x79, 0x00,0x0e,0x5e,0x2e,0x2d,0x0a,0x0a,0x28,0x2e,0x2a,0x29,0x00,0x0c,0x5e,0x28,0x2e, 0x2d,0x0a,0x29,0x0a,0x06,0x0a,0x07,0x0d,0x0a,0x09,0x67,0x73,0x75,0x62,0x0b,0x73, 0x74,0x72,0x69,0x6e,0x67,0x2e,0x00,0x01,0x04,0x01,0x02,0x00,0x06,0x34,0x01,0x00, 0x00,0x37,0x01,0x01,0x01,0x2b,0x02,0x00,0x00,0x10,0x03,0x00,0x00,0x3e,0x01,0x03, 0x01,0x47,0x00,0x01,0x00,0x01,0xc0,0x0b,0x69,0x6e,0x73,0x65,0x72,0x74,0x0a,0x74, 0x61,0x62,0x6c,0x65,0x8e,0x01,0x01,0x01,0x06,0x00,0x08,0x00,0x19,0x32,0x01,0x00, 0x00,0x34,0x02,0x00,0x00,0x37,0x02,0x01,0x02,0x10,0x03,0x00,0x00,0x25,0x04,0x02, 0x00,0x25,0x05,0x03,0x00,0x3e,0x02,0x04,0x02,0x10,0x00,0x02,0x00,0x34,0x02,0x00, 0x00,0x37,0x02,0x01,0x02,0x10,0x03,0x00,0x00,0x25,0x04,0x04,0x00,0x25,0x05,0x05, 0x00,0x3e,0x02,0x04,0x02,0x10,0x00,0x02,0x00,0x34,0x02,0x00,0x00,0x37,0x02,0x01, 0x02,0x25,0x03,0x03,0x00,0x10,0x04,0x00,0x00,0x24,0x03,0x04,0x03,0x25,0x04,0x06, 0x00,0x31,0x05,0x07,0x00,0x3e,0x02,0x04,0x01,0x30,0x00,0x00,0x80,0x48,0x01,0x02, 0x00,0x00,0x0d,0x0a,0x28,0x5b,0x5e,0x0a,0x5d,0x2b,0x29,0x06,0x20,0x0a,0x0a,0x5b, 0x20,0x5d,0x2b,0x06,0x0a,0x07,0x0d,0x0a,0x09,0x67,0x73,0x75,0x62,0x0b,0x73,0x74, 0x72,0x69,0x6e,0x67,0x8e,0x01,0x00,0x01,0x07,0x00,0x08,0x00,0x16,0x34,0x01,0x00, 0x00,0x37,0x01,0x01,0x01,0x10,0x02,0x00,0x00,0x25,0x03,0x02,0x00,0x25,0x04,0x03, 0x00,0x3e,0x01,0x04,0x02,0x10,0x00,0x01,0x00,0x34,0x01,0x00,0x00,0x37,0x01,0x01, 0x01,0x10,0x02,0x00,0x00,0x25,0x03,0x04,0x00,0x25,0x04,0x05,0x00,0x3e,0x01,0x04, 0x02,0x10,0x00,0x01,0x00,0x34,0x01,0x00,0x00,0x37,0x01,0x06,0x01,0x10,0x02,0x00, 0x00,0x25,0x03,0x07,0x00,0x3e,0x01,0x03,0x05,0x10,0x05,0x03,0x00,0x10,0x06,0x04, 0x00,0x46,0x05,0x03,0x00,0x16,0x28,0x5b,0x5e,0x25,0x73,0x3a,0x5d,0x2d,0x29,0x3a, 0x25,0x73,0x2a,0x28,0x2e,0x2a,0x29,0x09,0x66,0x69,0x6e,0x64,0x05,0x07,0x0a,0x2b, 0x06,0x20,0x0a,0x0a,0x5b,0x20,0x5d,0x2b,0x09,0x67,0x73,0x75,0x62,0x0b,0x73,0x74, 0x72,0x69,0x6e,0x67,0xb4,0x01,0x00,0x01,0x0c,0x01,0x05,0x00,0x20,0x2b,0x01,0x00, 0x00,0x37,0x01,0x00,0x01,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x02,0x32,0x02,0x00, 0x00,0x27,0x03,0x01,0x00,0x13,0x04,0x01,0x00,0x27,0x05,0x01,0x00,0x49,0x03,0x16, 0x80,0x2b,0x07,0x00,0x00,0x37,0x07,0x01,0x07,0x36,0x08,0x06,0x01,0x3e,0x07,0x02, 0x03,0x0f,0x00,0x07,0x00,0x54,0x09,0x0f,0x80,0x34,0x09,0x02,0x00,0x37,0x09,0x03, 0x09,0x10,0x0a,0x07,0x00,0x3e,0x09,0x02,0x02,0x10,0x07,0x09,0x00,0x36,0x09,0x07, 0x02,0x0f,0x00,0x09,0x00,0x54,0x0a,0x06,0x80,0x36,0x09,0x07,0x02,0x25,0x0a,0x04, 0x00,0x10,0x0b,0x08,0x00,0x24,0x09,0x0b,0x09,0x39,0x09,0x07,0x02,0x54,0x09,0x01, 0x80,0x39,0x08,0x07,0x02,0x4b,0x03,0xea,0x7f,0x48,0x02,0x02,0x00,0x00,0xc0,0x07, 0x2c,0x20,0x0a,0x6c,0x6f,0x77,0x65,0x72,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0x11, 0x70,0x61,0x72,0x73,0x65,0x5f,0x68,0x65,0x61,0x64,0x65,0x72,0x12,0x73,0x70,0x6c, 0x69,0x74,0x5f,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0xc2,0x01,0x00,0x01,0x09,0x00, 0x07,0x00,0x22,0x34,0x01,0x00,0x00,0x37,0x01,0x01,0x01,0x10,0x02,0x00,0x00,0x25, 0x03,0x02,0x00,0x3e,0x01,0x03,0x05,0x0e,0x00,0x04,0x00,0x54,0x05,0x08,0x80,0x34, 0x05,0x00,0x00,0x37,0x05,0x01,0x05,0x10,0x06,0x00,0x00,0x25,0x07,0x03,0x00,0x3e, 0x05,0x03,0x04,0x10,0x04,0x07,0x00,0x10,0x02,0x06,0x00,0x10,0x01,0x05,0x00,0x0e, 0x00,0x03,0x00,0x54,0x05,0x01,0x80,0x25,0x03,0x04,0x00,0x0e,0x00,0x04,0x00,0x54, 0x05,0x01,0x80,0x25,0x04,0x04,0x00,0x07,0x03,0x04,0x00,0x54,0x05,0x01,0x80,0x10, 0x03,0x04,0x00,0x34,0x05,0x00,0x00,0x37,0x05,0x05,0x05,0x10,0x06,0x03,0x00,0x25, 0x07,0x06,0x00,0x25,0x08,0x04,0x00,0x3e,0x05,0x04,0x02,0x10,0x03,0x05,0x00,0x10, 0x05,0x03,0x00,0x10,0x06,0x04,0x00,0x46,0x05,0x03,0x00,0x06,0x22,0x09,0x67,0x73, 0x75,0x62,0x05,0x0f,0x25,0x73,0x2a,0x28,0x2e,0x2b,0x29,0x25,0x73,0x2a,0x18,0x5e, 0x25,0x73,0x2a,0x28,0x2e,0x2d,0x29,0x25,0x73,0x2a,0x25,0x3c,0x28,0x2e,0x2d,0x29, 0x25,0x3e,0x09,0x66,0x69,0x6e,0x64,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0xe8,0x01, 0x00,0x01,0x08,0x00,0x0b,0x01,0x28,0x32,0x01,0x00,0x00,0x35,0x01,0x00,0x00,0x34, 0x01,0x01,0x00,0x37,0x01,0x02,0x01,0x10,0x02,0x00,0x00,0x25,0x03,0x03,0x00,0x25, 0x04,0x04,0x00,0x3e,0x01,0x04,0x02,0x25,0x02,0x05,0x00,0x24,0x00,0x02,0x01,0x27, 0x01,0x01,0x00,0x27,0x02,0x01,0x00,0x27,0x03,0x01,0x00,0x51,0x04,0x18,0x80,0x34, 0x04,0x01,0x00,0x37,0x04,0x06,0x04,0x10,0x05,0x00,0x00,0x25,0x06,0x07,0x00,0x10, 0x07,0x03,0x00,0x3e,0x04,0x04,0x03,0x10,0x01,0x05,0x00,0x10,0x02,0x04,0x00,0x0e, 0x00,0x02,0x00,0x54,0x04,0x01,0x80,0x54,0x04,0x0d,0x80,0x34,0x04,0x01,0x00,0x37, 0x04,0x08,0x04,0x10,0x05,0x00,0x00,0x10,0x06,0x03,0x00,0x15,0x07,0x00,0x02,0x3e, 0x04,0x04,0x02,0x34,0x05,0x09,0x00,0x37,0x05,0x0a,0x05,0x34,0x06,0x00,0x00,0x10, 0x07,0x04,0x00,0x3e,0x05,0x03,0x01,0x14,0x03,0x00,0x01,0x54,0x04,0xe7,0x7f,0x34, 0x04,0x00,0x00,0x48,0x04,0x02,0x00,0x0b,0x69,0x6e,0x73,0x65,0x72,0x74,0x0a,0x74, 0x61,0x62,0x6c,0x65,0x08,0x73,0x75,0x62,0x0f,0x0a,0x0a,0x46,0x72,0x6f,0x6d,0x20, 0x2e,0x2d,0x0a,0x09,0x66,0x69,0x6e,0x64,0x0d,0x0a,0x0a,0x46,0x72,0x6f,0x6d,0x20, 0x0a,0x06,0x0a,0x07,0x0d,0x0a,0x09,0x67,0x73,0x75,0x62,0x0b,0x73,0x74,0x72,0x69, 0x6e,0x67,0x09,0x6d,0x62,0x6f,0x78,0x02,0x5e,0x00,0x01,0x08,0x01,0x02,0x00,0x0f, 0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x02, 0x27,0x02,0x01,0x00,0x13,0x03,0x01,0x00,0x27,0x04,0x01,0x00,0x49,0x02,0x06,0x80, 0x2b,0x06,0x00,0x00,0x37,0x06,0x01,0x06,0x36,0x07,0x05,0x01,0x3e,0x06,0x02,0x02, 0x39,0x06,0x05,0x01,0x4b,0x02,0xfa,0x7f,0x48,0x01,0x02,0x00,0x00,0xc0,0x12,0x70, 0x61,0x72,0x73,0x65,0x5f,0x6d,0x65,0x73,0x73,0x61,0x67,0x65,0x0f,0x73,0x70,0x6c, 0x69,0x74,0x5f,0x6d,0x62,0x6f,0x78,0x66,0x00,0x01,0x04,0x01,0x04,0x00,0x0d,0x32, 0x01,0x00,0x00,0x2b,0x02,0x00,0x00,0x37,0x02,0x02,0x02,0x10,0x03,0x00,0x00,0x3e, 0x02,0x02,0x03,0x3a,0x03,0x01,0x01,0x3a,0x02,0x00,0x01,0x2b,0x02,0x00,0x00,0x37, 0x02,0x03,0x02,0x37,0x03,0x00,0x01,0x3e,0x02,0x02,0x02,0x3a,0x02,0x00,0x01,0x48, 0x01,0x02,0x00,0x00,0xc0,0x12,0x70,0x61,0x72,0x73,0x65,0x5f,0x68,0x65,0x61,0x64, 0x65,0x72,0x73,0x12,0x73,0x70,0x6c,0x69,0x74,0x5f,0x6d,0x65,0x73,0x73,0x61,0x67, 0x65,0x09,0x62,0x6f,0x64,0x79,0x0c,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0xd8,0x01, 0x03,0x00,0x02,0x00,0x12,0x00,0x17,0x32,0x00,0x00,0x00,0x34,0x01,0x00,0x00,0x0f, 0x00,0x01,0x00,0x54,0x02,0x01,0x80,0x35,0x00,0x01,0x00,0x31,0x01,0x03,0x00,0x3a, 0x01,0x02,0x00,0x31,0x01,0x05,0x00,0x3a,0x01,0x04,0x00,0x31,0x01,0x07,0x00,0x3a, 0x01,0x06,0x00,0x31,0x01,0x09,0x00,0x3a,0x01,0x08,0x00,0x31,0x01,0x0b,0x00,0x3a, 0x01,0x0a,0x00,0x31,0x01,0x0d,0x00,0x3a,0x01,0x0c,0x00,0x31,0x01,0x0f,0x00,0x3a, 0x01,0x0e,0x00,0x31,0x01,0x11,0x00,0x3a,0x01,0x10,0x00,0x30,0x00,0x00,0x80,0x48, 0x00,0x02,0x00,0x00,0x12,0x70,0x61,0x72,0x73,0x65,0x5f,0x6d,0x65,0x73,0x73,0x61, 0x67,0x65,0x00,0x0a,0x70,0x61,0x72,0x73,0x65,0x00,0x0f,0x73,0x70,0x6c,0x69,0x74, 0x5f,0x6d,0x62,0x6f,0x78,0x00,0x0f,0x70,0x61,0x72,0x73,0x65,0x5f,0x66,0x72,0x6f, 0x6d,0x00,0x12,0x70,0x61,0x72,0x73,0x65,0x5f,0x68,0x65,0x61,0x64,0x65,0x72,0x73, 0x00,0x11,0x70,0x61,0x72,0x73,0x65,0x5f,0x68,0x65,0x61,0x64,0x65,0x72,0x00,0x12, 0x73,0x70,0x6c,0x69,0x74,0x5f,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x00,0x12,0x73, 0x70,0x6c,0x69,0x74,0x5f,0x6d,0x65,0x73,0x73,0x61,0x67,0x65,0x09,0x6d,0x62,0x6f, 0x78,0x0b,0x6d,0x6f,0x64,0x75,0x6c,0x65,0x00, }; /* socket.smtp, socket/smtp.lua */ static const char lua_m_socket_smtp[] = { 0x1b,0x4c,0x4a,0x01,0x02,0xa9,0x01,0x00,0x02,0x08,0x02,0x08,0x00,0x1d,0x37,0x02, 0x00,0x00,0x37,0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x02,0x03,0x25,0x05, 0x03,0x00,0x3e,0x03,0x03,0x00,0x3d,0x02,0x00,0x01,0x37,0x02,0x00,0x00,0x37,0x03, 0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x04,0x03,0x25,0x05,0x05,0x00,0x0c,0x06, 0x01,0x00,0x54,0x06,0x02,0x80,0x2b,0x06,0x00,0x00,0x37,0x06,0x06,0x06,0x3e,0x03, 0x04,0x00,0x3d,0x02,0x00,0x01,0x2b,0x02,0x01,0x00,0x37,0x02,0x07,0x02,0x27,0x03, 0x01,0x00,0x37,0x04,0x00,0x00,0x37,0x05,0x01,0x00,0x10,0x06,0x05,0x00,0x37,0x05, 0x02,0x05,0x25,0x07,0x03,0x00,0x3e,0x05,0x03,0x00,0x3d,0x04,0x00,0x00,0x3f,0x02, 0x01,0x00,0x0a,0xc0,0x05,0xc0,0x09,0x73,0x6b,0x69,0x70,0x0b,0x44,0x4f,0x4d,0x41, 0x49,0x4e,0x09,0x45,0x48,0x4c,0x4f,0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x08, 0x32,0x2e,0x2e,0x0a,0x63,0x68,0x65,0x63,0x6b,0x07,0x74,0x70,0x08,0x74,0x72,0x79, 0x6f,0x00,0x02,0x08,0x00,0x07,0x00,0x11,0x37,0x02,0x00,0x00,0x37,0x03,0x01,0x00, 0x10,0x04,0x03,0x00,0x37,0x03,0x02,0x03,0x25,0x05,0x03,0x00,0x25,0x06,0x04,0x00, 0x10,0x07,0x01,0x00,0x24,0x06,0x07,0x06,0x3e,0x03,0x04,0x00,0x3d,0x02,0x00,0x01, 0x37,0x02,0x00,0x00,0x37,0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x05,0x03, 0x25,0x05,0x06,0x00,0x3e,0x03,0x03,0x00,0x3f,0x02,0x00,0x00,0x08,0x32,0x2e,0x2e, 0x0a,0x63,0x68,0x65,0x63,0x6b,0x0a,0x46,0x52,0x4f,0x4d,0x3a,0x09,0x4d,0x41,0x49, 0x4c,0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79, 0x6d,0x00,0x02,0x08,0x00,0x07,0x00,0x11,0x37,0x02,0x00,0x00,0x37,0x03,0x01,0x00, 0x10,0x04,0x03,0x00,0x37,0x03,0x02,0x03,0x25,0x05,0x03,0x00,0x25,0x06,0x04,0x00, 0x10,0x07,0x01,0x00,0x24,0x06,0x07,0x06,0x3e,0x03,0x04,0x00,0x3d,0x02,0x00,0x01, 0x37,0x02,0x00,0x00,0x37,0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x05,0x03, 0x25,0x05,0x06,0x00,0x3e,0x03,0x03,0x00,0x3f,0x02,0x00,0x00,0x08,0x32,0x2e,0x2e, 0x0a,0x63,0x68,0x65,0x63,0x6b,0x08,0x54,0x4f,0x3a,0x09,0x52,0x43,0x50,0x54,0x0c, 0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0xcb,0x01, 0x00,0x03,0x08,0x00,0x0a,0x00,0x24,0x37,0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10, 0x05,0x04,0x00,0x37,0x04,0x02,0x04,0x25,0x06,0x03,0x00,0x3e,0x04,0x03,0x00,0x3d, 0x03,0x00,0x01,0x37,0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37, 0x04,0x04,0x04,0x25,0x06,0x05,0x00,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x01,0x37, 0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x06,0x04,0x10, 0x06,0x01,0x00,0x10,0x07,0x02,0x00,0x3e,0x04,0x04,0x00,0x3d,0x03,0x00,0x01,0x37, 0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x07,0x04,0x25, 0x06,0x08,0x00,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x01,0x37,0x03,0x00,0x00,0x37, 0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x04,0x04,0x25,0x06,0x09,0x00,0x3e, 0x04,0x03,0x00,0x3f,0x03,0x00,0x00,0x08,0x32,0x2e,0x2e,0x0a,0x0d,0x0a,0x2e,0x0d, 0x0a,0x09,0x73,0x65,0x6e,0x64,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0x08,0x33,0x2e, 0x2e,0x0a,0x63,0x68,0x65,0x63,0x6b,0x09,0x44,0x41,0x54,0x41,0x0c,0x63,0x6f,0x6d, 0x6d,0x61,0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x5d,0x00,0x01,0x05,0x00, 0x06,0x00,0x0e,0x37,0x01,0x00,0x00,0x37,0x02,0x01,0x00,0x10,0x03,0x02,0x00,0x37, 0x02,0x02,0x02,0x25,0x04,0x03,0x00,0x3e,0x02,0x03,0x00,0x3d,0x01,0x00,0x01,0x37, 0x01,0x00,0x00,0x37,0x02,0x01,0x00,0x10,0x03,0x02,0x00,0x37,0x02,0x04,0x02,0x25, 0x04,0x05,0x00,0x3e,0x02,0x03,0x00,0x3f,0x01,0x00,0x00,0x08,0x32,0x2e,0x2e,0x0a, 0x63,0x68,0x65,0x63,0x6b,0x09,0x51,0x55,0x49,0x54,0x0c,0x63,0x6f,0x6d,0x6d,0x61, 0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x20,0x00,0x01,0x03,0x00,0x02,0x00, 0x04,0x37,0x01,0x00,0x00,0x10,0x02,0x01,0x00,0x37,0x01,0x01,0x01,0x40,0x01,0x02, 0x00,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x07,0x74,0x70,0x91,0x02,0x00,0x03,0x08,0x01, 0x0b,0x00,0x35,0x37,0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37, 0x04,0x02,0x04,0x25,0x06,0x03,0x00,0x25,0x07,0x04,0x00,0x3e,0x04,0x04,0x00,0x3d, 0x03,0x00,0x01,0x37,0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37, 0x04,0x05,0x04,0x25,0x06,0x06,0x00,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x01,0x37, 0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x07,0x04,0x2b, 0x06,0x00,0x00,0x37,0x06,0x08,0x06,0x10,0x07,0x01,0x00,0x3e,0x06,0x02,0x02,0x25, 0x07,0x09,0x00,0x24,0x06,0x07,0x06,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x01,0x37, 0x03,0x00,0x00,0x37,0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x05,0x04,0x25, 0x06,0x06,0x00,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x01,0x37,0x03,0x00,0x00,0x37, 0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x07,0x04,0x2b,0x06,0x00,0x00,0x37, 0x06,0x08,0x06,0x10,0x07,0x02,0x00,0x3e,0x06,0x02,0x02,0x25,0x07,0x09,0x00,0x24, 0x06,0x07,0x06,0x3e,0x04,0x03,0x00,0x3d,0x03,0x00,0x01,0x37,0x03,0x00,0x00,0x37, 0x04,0x01,0x00,0x10,0x05,0x04,0x00,0x37,0x04,0x05,0x04,0x25,0x06,0x0a,0x00,0x3e, 0x04,0x03,0x00,0x3f,0x03,0x00,0x00,0x09,0xc0,0x08,0x32,0x2e,0x2e,0x07,0x0d,0x0a, 0x08,0x62,0x36,0x34,0x09,0x73,0x65,0x6e,0x64,0x08,0x33,0x2e,0x2e,0x0a,0x63,0x68, 0x65,0x63,0x6b,0x0a,0x4c,0x4f,0x47,0x49,0x4e,0x09,0x41,0x55,0x54,0x48,0x0c,0x63, 0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x98,0x01,0x00, 0x03,0x09,0x01,0x09,0x00,0x19,0x25,0x03,0x00,0x00,0x2b,0x04,0x00,0x00,0x37,0x04, 0x01,0x04,0x25,0x05,0x02,0x00,0x10,0x06,0x01,0x00,0x25,0x07,0x02,0x00,0x10,0x08, 0x02,0x00,0x24,0x05,0x08,0x05,0x3e,0x04,0x02,0x02,0x24,0x03,0x04,0x03,0x37,0x04, 0x03,0x00,0x37,0x05,0x04,0x00,0x10,0x06,0x05,0x00,0x37,0x05,0x05,0x05,0x25,0x07, 0x06,0x00,0x10,0x08,0x03,0x00,0x3e,0x05,0x04,0x00,0x3d,0x04,0x00,0x01,0x37,0x04, 0x03,0x00,0x37,0x05,0x04,0x00,0x10,0x06,0x05,0x00,0x37,0x05,0x07,0x05,0x25,0x07, 0x08,0x00,0x3e,0x05,0x03,0x00,0x3f,0x04,0x00,0x00,0x09,0xc0,0x08,0x32,0x2e,0x2e, 0x0a,0x63,0x68,0x65,0x63,0x6b,0x09,0x41,0x55,0x54,0x48,0x0c,0x63,0x6f,0x6d,0x6d, 0x61,0x6e,0x64,0x07,0x74,0x70,0x08,0x74,0x72,0x79,0x06,0x00,0x08,0x62,0x36,0x34, 0x0b,0x50,0x4c,0x41,0x49,0x4e,0x20,0xed,0x01,0x00,0x04,0x08,0x01,0x07,0x00,0x25, 0x0f,0x00,0x01,0x00,0x54,0x04,0x02,0x80,0x0e,0x00,0x02,0x00,0x54,0x04,0x02,0x80, 0x27,0x04,0x01,0x00,0x48,0x04,0x02,0x00,0x2b,0x04,0x00,0x00,0x37,0x04,0x00,0x04, 0x10,0x05,0x03,0x00,0x25,0x06,0x01,0x00,0x3e,0x04,0x03,0x02,0x0f,0x00,0x04,0x00, 0x54,0x05,0x06,0x80,0x10,0x05,0x00,0x00,0x37,0x04,0x02,0x00,0x10,0x06,0x01,0x00, 0x10,0x07,0x02,0x00,0x40,0x04,0x04,0x00,0x54,0x04,0x11,0x80,0x2b,0x04,0x00,0x00, 0x37,0x04,0x00,0x04,0x10,0x05,0x03,0x00,0x25,0x06,0x03,0x00,0x3e,0x04,0x03,0x02, 0x0f,0x00,0x04,0x00,0x54,0x05,0x06,0x80,0x10,0x05,0x00,0x00,0x37,0x04,0x04,0x00, 0x10,0x06,0x01,0x00,0x10,0x07,0x02,0x00,0x40,0x04,0x04,0x00,0x54,0x04,0x04,0x80, 0x37,0x04,0x05,0x00,0x29,0x05,0x00,0x00,0x25,0x06,0x06,0x00,0x3e,0x04,0x03,0x01, 0x47,0x00,0x01,0x00,0x02,0xc0,0x21,0x61,0x75,0x74,0x68,0x65,0x6e,0x74,0x69,0x63, 0x61,0x74,0x69,0x6f,0x6e,0x20,0x6e,0x6f,0x74,0x20,0x73,0x75,0x70,0x70,0x6f,0x72, 0x74,0x65,0x64,0x08,0x74,0x72,0x79,0x0a,0x70,0x6c,0x61,0x69,0x6e,0x13,0x41,0x55, 0x54,0x48,0x5b,0x5e,0x0a,0x5d,0x2b,0x50,0x4c,0x41,0x49,0x4e,0x0a,0x6c,0x6f,0x67, 0x69,0x6e,0x13,0x41,0x55,0x54,0x48,0x5b,0x5e,0x0a,0x5d,0x2b,0x4c,0x4f,0x47,0x49, 0x4e,0x09,0x66,0x69,0x6e,0x64,0xe7,0x01,0x00,0x02,0x0a,0x03,0x0b,0x00,0x27,0x10, 0x03,0x00,0x00,0x37,0x02,0x00,0x00,0x37,0x04,0x01,0x01,0x3e,0x02,0x03,0x01,0x2b, 0x02,0x00,0x00,0x37,0x02,0x02,0x02,0x37,0x03,0x03,0x01,0x3e,0x02,0x02,0x02,0x07, 0x02,0x04,0x00,0x54,0x02,0x0c,0x80,0x2b,0x02,0x00,0x00,0x37,0x02,0x05,0x02,0x37, 0x03,0x03,0x01,0x3e,0x02,0x02,0x04,0x54,0x05,0x04,0x80,0x10,0x08,0x00,0x00,0x37, 0x07,0x03,0x00,0x10,0x09,0x06,0x00,0x3e,0x07,0x03,0x01,0x41,0x05,0x03,0x03,0x4e, 0x05,0xfa,0x7f,0x54,0x02,0x04,0x80,0x10,0x03,0x00,0x00,0x37,0x02,0x03,0x00,0x37, 0x04,0x03,0x01,0x3e,0x02,0x03,0x01,0x10,0x03,0x00,0x00,0x37,0x02,0x06,0x00,0x2b, 0x04,0x01,0x00,0x37,0x04,0x07,0x04,0x37,0x04,0x08,0x04,0x37,0x05,0x07,0x01,0x2b, 0x06,0x02,0x00,0x37,0x06,0x09,0x06,0x3e,0x06,0x01,0x00,0x3d,0x04,0x01,0x02,0x37, 0x05,0x0a,0x01,0x3e,0x02,0x04,0x01,0x47,0x00,0x01,0x00,0x00,0xc0,0x07,0xc0,0x09, 0xc0,0x09,0x73,0x74,0x65,0x70,0x0a,0x73,0x74,0x75,0x66,0x66,0x0a,0x63,0x68,0x61, 0x69,0x6e,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0x09,0x64,0x61,0x74,0x61,0x0b,0x69, 0x70,0x61,0x69,0x72,0x73,0x0a,0x74,0x61,0x62,0x6c,0x65,0x09,0x72,0x63,0x70,0x74, 0x09,0x74,0x79,0x70,0x65,0x09,0x66,0x72,0x6f,0x6d,0x09,0x6d,0x61,0x69,0x6c,0x23, 0x00,0x00,0x02,0x01,0x01,0x00,0x05,0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37, 0x00,0x00,0x00,0x3e,0x00,0x02,0x01,0x47,0x00,0x01,0x00,0x04,0xc0,0x0a,0x63,0x6c, 0x6f,0x73,0x65,0xc4,0x01,0x01,0x03,0x09,0x05,0x0a,0x00,0x1e,0x2b,0x03,0x00,0x00, 0x37,0x03,0x00,0x03,0x2b,0x04,0x01,0x00,0x37,0x04,0x01,0x04,0x0c,0x05,0x00,0x00, 0x54,0x05,0x02,0x80,0x2b,0x05,0x02,0x00,0x37,0x05,0x02,0x05,0x0c,0x06,0x01,0x00, 0x54,0x06,0x02,0x80,0x2b,0x06,0x02,0x00,0x37,0x06,0x03,0x06,0x2b,0x07,0x02,0x00, 0x37,0x07,0x04,0x07,0x10,0x08,0x02,0x00,0x3e,0x04,0x05,0x00,0x3d,0x03,0x00,0x02, 0x2b,0x04,0x03,0x00,0x37,0x04,0x05,0x04,0x33,0x05,0x06,0x00,0x3a,0x03,0x07,0x05, 0x2b,0x06,0x04,0x00,0x3e,0x04,0x03,0x02,0x2b,0x05,0x00,0x00,0x37,0x05,0x08,0x05, 0x31,0x06,0x09,0x00,0x3e,0x05,0x02,0x02,0x3a,0x05,0x00,0x04,0x30,0x00,0x00,0x80, 0x48,0x04,0x02,0x00,0x05,0xc0,0x06,0xc0,0x0a,0xc0,0x00,0xc0,0x0b,0xc0,0x00,0x0b, 0x6e,0x65,0x77,0x74,0x72,0x79,0x07,0x74,0x70,0x01,0x00,0x00,0x11,0x73,0x65,0x74, 0x6d,0x65,0x74,0x61,0x74,0x61,0x62,0x6c,0x65,0x0c,0x54,0x49,0x4d,0x45,0x4f,0x55, 0x54,0x09,0x50,0x4f,0x52,0x54,0x0b,0x53,0x45,0x52,0x56,0x45,0x52,0x0c,0x63,0x6f, 0x6e,0x6e,0x65,0x63,0x74,0x08,0x74,0x72,0x79,0x57,0x00,0x01,0x09,0x02,0x02,0x00, 0x10,0x32,0x01,0x00,0x00,0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02,0x0c,0x03,0x00, 0x00,0x54,0x03,0x01,0x80,0x10,0x03,0x01,0x00,0x3e,0x02,0x02,0x04,0x54,0x05,0x05, 0x80,0x2b,0x07,0x01,0x00,0x37,0x07,0x01,0x07,0x10,0x08,0x05,0x00,0x3e,0x07,0x02, 0x02,0x39,0x06,0x07,0x01,0x41,0x05,0x03,0x03,0x4e,0x05,0xf9,0x7f,0x48,0x01,0x02, 0x00,0x00,0xc0,0x02,0xc0,0x0a,0x6c,0x6f,0x77,0x65,0x72,0x0a,0x70,0x61,0x69,0x72, 0x73,0x84,0x01,0x00,0x00,0x06,0x04,0x05,0x02,0x11,0x2b,0x00,0x00,0x00,0x14,0x00, 0x00,0x00,0x2c,0x00,0x00,0x00,0x2b,0x00,0x01,0x00,0x37,0x00,0x00,0x00,0x25,0x01, 0x01,0x00,0x2b,0x02,0x02,0x00,0x37,0x02,0x02,0x02,0x25,0x03,0x03,0x00,0x3e,0x02, 0x02,0x02,0x2b,0x03,0x03,0x00,0x37,0x03,0x04,0x03,0x27,0x04,0x00,0x00,0x28,0x05, 0x01,0x00,0x3e,0x03,0x03,0x02,0x2b,0x04,0x00,0x00,0x40,0x00,0x05,0x00,0x0d,0x80, 0x02,0xc0,0x04,0xc0,0x03,0xc0,0x0b,0x72,0x61,0x6e,0x64,0x6f,0x6d,0x11,0x25,0x64, 0x25,0x6d,0x25,0x59,0x25,0x48,0x25,0x4d,0x25,0x53,0x09,0x64,0x61,0x74,0x65,0x11, 0x25,0x73,0x25,0x30,0x35,0x64,0x3d,0x3d,0x25,0x30,0x35,0x75,0x0b,0x66,0x6f,0x72, 0x6d,0x61,0x74,0x02,0xbe,0x9a,0x0c,0x87,0x01,0x00,0x01,0x0d,0x03,0x05,0x00,0x18, 0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x25,0x02,0x01,0x00,0x2b,0x03,0x01,0x00, 0x37,0x03,0x02,0x03,0x10,0x04,0x00,0x00,0x3e,0x03,0x02,0x04,0x54,0x06,0x09,0x80, 0x36,0x08,0x06,0x01,0x0e,0x00,0x08,0x00,0x54,0x09,0x01,0x80,0x10,0x08,0x06,0x00, 0x25,0x09,0x03,0x00,0x10,0x0a,0x07,0x00,0x25,0x0b,0x01,0x00,0x10,0x0c,0x02,0x00, 0x24,0x02,0x0c,0x08,0x41,0x06,0x03,0x03,0x4e,0x06,0xf5,0x7f,0x2b,0x03,0x02,0x00, 0x37,0x03,0x04,0x03,0x10,0x04,0x02,0x00,0x3e,0x03,0x02,0x01,0x47,0x00,0x01,0x00, 0x08,0xc0,0x00,0xc0,0x01,0xc0,0x0a,0x79,0x69,0x65,0x6c,0x64,0x07,0x3a,0x20,0x0a, 0x70,0x61,0x69,0x72,0x73,0x07,0x0d,0x0a,0x0c,0x63,0x61,0x6e,0x6f,0x6e,0x69,0x63, 0x9e,0x03,0x00,0x01,0x0c,0x06,0x0d,0x00,0x49,0x2b,0x01,0x00,0x00,0x3e,0x01,0x01, 0x02,0x2b,0x02,0x01,0x00,0x37,0x03,0x00,0x00,0x0e,0x00,0x03,0x00,0x54,0x04,0x01, 0x80,0x32,0x03,0x00,0x00,0x3e,0x02,0x02,0x02,0x37,0x03,0x01,0x02,0x0e,0x00,0x03, 0x00,0x54,0x04,0x01,0x80,0x25,0x03,0x02,0x00,0x3a,0x03,0x01,0x02,0x37,0x03,0x01, 0x02,0x25,0x04,0x03,0x00,0x10,0x05,0x01,0x00,0x25,0x06,0x04,0x00,0x24,0x03,0x06, 0x03,0x3a,0x03,0x01,0x02,0x2b,0x03,0x02,0x00,0x10,0x04,0x02,0x00,0x3e,0x03,0x02, 0x01,0x37,0x03,0x05,0x00,0x37,0x03,0x06,0x03,0x0f,0x00,0x03,0x00,0x54,0x04,0x09, 0x80,0x2b,0x03,0x03,0x00,0x37,0x03,0x07,0x03,0x37,0x04,0x05,0x00,0x37,0x04,0x06, 0x04,0x3e,0x03,0x02,0x01,0x2b,0x03,0x03,0x00,0x37,0x03,0x07,0x03,0x25,0x04,0x08, 0x00,0x3e,0x03,0x02,0x01,0x2b,0x03,0x04,0x00,0x37,0x03,0x09,0x03,0x37,0x04,0x05, 0x00,0x3e,0x03,0x02,0x04,0x54,0x06,0x0a,0x80,0x2b,0x08,0x03,0x00,0x37,0x08,0x07, 0x08,0x25,0x09,0x0a,0x00,0x10,0x0a,0x01,0x00,0x25,0x0b,0x08,0x00,0x24,0x09,0x0b, 0x09,0x3e,0x08,0x02,0x01,0x2b,0x08,0x05,0x00,0x10,0x09,0x07,0x00,0x3e,0x08,0x02, 0x01,0x41,0x06,0x03,0x03,0x4e,0x06,0xf4,0x7f,0x2b,0x03,0x03,0x00,0x37,0x03,0x07, 0x03,0x25,0x04,0x0a,0x00,0x10,0x05,0x01,0x00,0x25,0x06,0x0b,0x00,0x24,0x04,0x06, 0x04,0x3e,0x03,0x02,0x01,0x37,0x03,0x05,0x00,0x37,0x03,0x0c,0x03,0x0f,0x00,0x03, 0x00,0x54,0x04,0x09,0x80,0x2b,0x03,0x03,0x00,0x37,0x03,0x07,0x03,0x37,0x04,0x05, 0x00,0x37,0x04,0x0c,0x04,0x3e,0x03,0x02,0x01,0x2b,0x03,0x03,0x00,0x37,0x03,0x07, 0x03,0x25,0x04,0x08,0x00,0x3e,0x03,0x02,0x01,0x47,0x00,0x01,0x00,0x0e,0xc0,0x0c, 0xc0,0x10,0xc0,0x01,0xc0,0x00,0xc0,0x0f,0x80,0x0d,0x65,0x70,0x69,0x6c,0x6f,0x67, 0x75,0x65,0x0b,0x2d,0x2d,0x0d,0x0a,0x0d,0x0a,0x09,0x0d,0x0a,0x2d,0x2d,0x0b,0x69, 0x70,0x61,0x69,0x72,0x73,0x07,0x0d,0x0a,0x0a,0x79,0x69,0x65,0x6c,0x64,0x0d,0x70, 0x72,0x65,0x61,0x6d,0x62,0x6c,0x65,0x09,0x62,0x6f,0x64,0x79,0x06,0x22,0x11,0x3b, 0x20,0x62,0x6f,0x75,0x6e,0x64,0x61,0x72,0x79,0x3d,0x22,0x14,0x6d,0x75,0x6c,0x74, 0x69,0x70,0x61,0x72,0x74,0x2f,0x6d,0x69,0x78,0x65,0x64,0x11,0x63,0x6f,0x6e,0x74, 0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x0c,0x68,0x65,0x61,0x64,0x65,0x72,0x73, 0xda,0x01,0x00,0x01,0x07,0x03,0x05,0x00,0x23,0x2b,0x01,0x00,0x00,0x37,0x02,0x00, 0x00,0x0e,0x00,0x02,0x00,0x54,0x03,0x01,0x80,0x32,0x02,0x00,0x00,0x3e,0x01,0x02, 0x02,0x37,0x02,0x01,0x01,0x0e,0x00,0x02,0x00,0x54,0x03,0x01,0x80,0x25,0x02,0x02, 0x00,0x3a,0x02,0x01,0x01,0x2b,0x02,0x01,0x00,0x10,0x03,0x01,0x00,0x3e,0x02,0x02, 0x01,0x51,0x02,0x13,0x80,0x37,0x02,0x03,0x00,0x3e,0x02,0x01,0x03,0x0f,0x00,0x03, 0x00,0x54,0x04,0x06,0x80,0x2b,0x04,0x02,0x00,0x37,0x04,0x04,0x04,0x29,0x05,0x00, 0x00,0x10,0x06,0x03,0x00,0x3e,0x04,0x03,0x01,0x54,0x04,0xf5,0x7f,0x0f,0x00,0x02, 0x00,0x54,0x04,0x07,0x80,0x2b,0x04,0x02,0x00,0x37,0x04,0x04,0x04,0x10,0x05,0x02, 0x00,0x3e,0x04,0x02,0x01,0x54,0x04,0xee,0x7f,0x54,0x02,0x01,0x80,0x54,0x02,0xec, 0x7f,0x47,0x00,0x01,0x00,0x0c,0xc0,0x10,0xc0,0x01,0xc0,0x0a,0x79,0x69,0x65,0x6c, 0x64,0x09,0x62,0x6f,0x64,0x79,0x25,0x74,0x65,0x78,0x74,0x2f,0x70,0x6c,0x61,0x69, 0x6e,0x3b,0x20,0x63,0x68,0x61,0x72,0x73,0x65,0x74,0x3d,0x22,0x69,0x73,0x6f,0x2d, 0x38,0x38,0x35,0x39,0x2d,0x31,0x22,0x11,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d, 0x74,0x79,0x70,0x65,0x0c,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x9a,0x01,0x00,0x01, 0x04,0x03,0x05,0x00,0x13,0x2b,0x01,0x00,0x00,0x37,0x02,0x00,0x00,0x0e,0x00,0x02, 0x00,0x54,0x03,0x01,0x80,0x32,0x02,0x00,0x00,0x3e,0x01,0x02,0x02,0x37,0x02,0x01, 0x01,0x0e,0x00,0x02,0x00,0x54,0x03,0x01,0x80,0x25,0x02,0x02,0x00,0x3a,0x02,0x01, 0x01,0x2b,0x02,0x01,0x00,0x10,0x03,0x01,0x00,0x3e,0x02,0x02,0x01,0x2b,0x02,0x02, 0x00,0x37,0x02,0x03,0x02,0x37,0x03,0x04,0x00,0x3e,0x02,0x02,0x01,0x47,0x00,0x01, 0x00,0x0c,0xc0,0x10,0xc0,0x01,0xc0,0x09,0x62,0x6f,0x64,0x79,0x0a,0x79,0x69,0x65, 0x6c,0x64,0x25,0x74,0x65,0x78,0x74,0x2f,0x70,0x6c,0x61,0x69,0x6e,0x3b,0x20,0x63, 0x68,0x61,0x72,0x73,0x65,0x74,0x3d,0x22,0x69,0x73,0x6f,0x2d,0x38,0x38,0x35,0x39, 0x2d,0x31,0x22,0x11,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65, 0x0c,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x88,0x01,0x00,0x01,0x03,0x04,0x04,0x00, 0x18,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x37,0x02,0x01,0x00,0x3e,0x01,0x02, 0x02,0x07,0x01,0x02,0x00,0x54,0x01,0x04,0x80,0x2b,0x01,0x01,0x00,0x10,0x02,0x00, 0x00,0x3e,0x01,0x02,0x01,0x54,0x01,0x0d,0x80,0x2b,0x01,0x00,0x00,0x37,0x01,0x00, 0x01,0x37,0x02,0x01,0x00,0x3e,0x01,0x02,0x02,0x07,0x01,0x03,0x00,0x54,0x01,0x04, 0x80,0x2b,0x01,0x02,0x00,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x01,0x54,0x01,0x03, 0x80,0x2b,0x01,0x03,0x00,0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x01,0x47,0x00,0x01, 0x00,0x00,0xc0,0x11,0xc0,0x12,0xc0,0x13,0xc0,0x0d,0x66,0x75,0x6e,0x63,0x74,0x69, 0x6f,0x6e,0x0a,0x74,0x61,0x62,0x6c,0x65,0x09,0x62,0x6f,0x64,0x79,0x09,0x74,0x79, 0x70,0x65,0xc9,0x01,0x00,0x01,0x04,0x04,0x09,0x00,0x1a,0x2b,0x01,0x00,0x00,0x37, 0x02,0x00,0x00,0x3e,0x01,0x02,0x02,0x37,0x02,0x01,0x01,0x0e,0x00,0x02,0x00,0x54, 0x03,0x0a,0x80,0x2b,0x02,0x01,0x00,0x37,0x02,0x01,0x02,0x25,0x03,0x02,0x00,0x3e, 0x02,0x02,0x02,0x37,0x03,0x03,0x00,0x0e,0x00,0x03,0x00,0x54,0x04,0x02,0x80,0x2b, 0x03,0x02,0x00,0x37,0x03,0x04,0x03,0x24,0x02,0x03,0x02,0x3a,0x02,0x01,0x01,0x37, 0x02,0x05,0x01,0x0e,0x00,0x02,0x00,0x54,0x03,0x02,0x80,0x2b,0x02,0x03,0x00,0x37, 0x02,0x06,0x02,0x3a,0x02,0x05,0x01,0x25,0x02,0x08,0x00,0x3a,0x02,0x07,0x01,0x48, 0x01,0x02,0x00,0x0c,0xc0,0x04,0xc0,0x0a,0xc0,0x05,0xc0,0x08,0x31,0x2e,0x30,0x11, 0x6d,0x69,0x6d,0x65,0x2d,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x0d,0x5f,0x56,0x45, 0x52,0x53,0x49,0x4f,0x4e,0x0d,0x78,0x2d,0x6d,0x61,0x69,0x6c,0x65,0x72,0x09,0x5a, 0x4f,0x4e,0x45,0x09,0x7a,0x6f,0x6e,0x65,0x1c,0x21,0x25,0x61,0x2c,0x20,0x25,0x64, 0x20,0x25,0x62,0x20,0x25,0x59,0x20,0x25,0x48,0x3a,0x25,0x4d,0x3a,0x25,0x53,0x20, 0x09,0x64,0x61,0x74,0x65,0x0c,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0x1b,0x00,0x00, 0x02,0x02,0x00,0x00,0x04,0x2b,0x00,0x00,0x00,0x2b,0x01,0x01,0x00,0x3e,0x00,0x02, 0x01,0x47,0x00,0x01,0x00,0x02,0x00,0x00,0xc0,0x4a,0x00,0x00,0x05,0x02,0x01,0x00, 0x0e,0x2b,0x00,0x00,0x00,0x37,0x00,0x00,0x00,0x2b,0x01,0x01,0x00,0x3e,0x00,0x02, 0x04,0x0f,0x00,0x00,0x00,0x54,0x03,0x04,0x80,0x10,0x03,0x01,0x00,0x10,0x04,0x02, 0x00,0x46,0x03,0x03,0x00,0x54,0x03,0x03,0x80,0x29,0x03,0x00,0x00,0x10,0x04,0x01, 0x00,0x46,0x03,0x03,0x00,0x47,0x00,0x01,0x00,0x01,0x00,0x01,0xc0,0x0b,0x72,0x65, 0x73,0x75,0x6d,0x65,0x4a,0x01,0x01,0x03,0x03,0x04,0x00,0x0b,0x2b,0x01,0x00,0x00, 0x10,0x02,0x00,0x00,0x3e,0x01,0x02,0x02,0x3a,0x01,0x00,0x00,0x2b,0x01,0x01,0x00, 0x37,0x01,0x01,0x01,0x31,0x02,0x02,0x00,0x3e,0x01,0x02,0x02,0x31,0x02,0x03,0x00, 0x30,0x00,0x00,0x80,0x48,0x02,0x02,0x00,0x14,0xc0,0x01,0xc0,0x0f,0x80,0x00,0x00, 0x0b,0x63,0x72,0x65,0x61,0x74,0x65,0x0c,0x68,0x65,0x61,0x64,0x65,0x72,0x73,0xb9, 0x01,0x00,0x01,0x08,0x01,0x0c,0x00,0x1a,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01, 0x37,0x02,0x01,0x00,0x37,0x03,0x02,0x00,0x37,0x04,0x03,0x00,0x3e,0x01,0x04,0x02, 0x10,0x03,0x01,0x00,0x37,0x02,0x04,0x01,0x37,0x04,0x05,0x00,0x3e,0x02,0x03,0x02, 0x10,0x04,0x01,0x00,0x37,0x03,0x06,0x01,0x37,0x05,0x07,0x00,0x37,0x06,0x08,0x00, 0x10,0x07,0x02,0x00,0x3e,0x03,0x05,0x01,0x10,0x04,0x01,0x00,0x37,0x03,0x09,0x01, 0x10,0x05,0x00,0x00,0x3e,0x03,0x03,0x01,0x10,0x04,0x01,0x00,0x37,0x03,0x0a,0x01, 0x3e,0x03,0x02,0x01,0x10,0x04,0x01,0x00,0x37,0x03,0x0b,0x01,0x40,0x03,0x02,0x00, 0x0a,0xc0,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x09,0x71,0x75,0x69,0x74,0x09,0x73,0x65, 0x6e,0x64,0x0d,0x70,0x61,0x73,0x73,0x77,0x6f,0x72,0x64,0x09,0x75,0x73,0x65,0x72, 0x09,0x61,0x75,0x74,0x68,0x0b,0x64,0x6f,0x6d,0x61,0x69,0x6e,0x0a,0x67,0x72,0x65, 0x65,0x74,0x0b,0x63,0x72,0x65,0x61,0x74,0x65,0x09,0x70,0x6f,0x72,0x74,0x0b,0x73, 0x65,0x72,0x76,0x65,0x72,0x09,0x6f,0x70,0x65,0x6e,0x95,0x05,0x03,0x00,0x17,0x00, 0x39,0x00,0x63,0x34,0x00,0x00,0x00,0x34,0x01,0x01,0x00,0x25,0x02,0x02,0x00,0x3e, 0x01,0x02,0x02,0x34,0x02,0x01,0x00,0x25,0x03,0x03,0x00,0x3e,0x02,0x02,0x02,0x34, 0x03,0x01,0x00,0x25,0x04,0x04,0x00,0x3e,0x03,0x02,0x02,0x34,0x04,0x01,0x00,0x25, 0x05,0x05,0x00,0x3e,0x04,0x02,0x02,0x34,0x05,0x01,0x00,0x25,0x06,0x06,0x00,0x3e, 0x05,0x02,0x02,0x34,0x06,0x01,0x00,0x25,0x07,0x07,0x00,0x3e,0x06,0x02,0x02,0x34, 0x07,0x01,0x00,0x25,0x08,0x08,0x00,0x3e,0x07,0x02,0x02,0x34,0x08,0x01,0x00,0x25, 0x09,0x09,0x00,0x3e,0x08,0x02,0x02,0x34,0x09,0x01,0x00,0x25,0x0a,0x0a,0x00,0x3e, 0x09,0x02,0x02,0x32,0x0a,0x00,0x00,0x3a,0x0a,0x0b,0x05,0x37,0x0a,0x0b,0x05,0x27, 0x0b,0x3c,0x00,0x3a,0x0b,0x0c,0x0a,0x25,0x0b,0x0e,0x00,0x3a,0x0b,0x0d,0x0a,0x27, 0x0b,0x19,0x00,0x3a,0x0b,0x0f,0x0a,0x37,0x0b,0x11,0x04,0x25,0x0c,0x12,0x00,0x3e, 0x0b,0x02,0x02,0x0e,0x00,0x0b,0x00,0x54,0x0c,0x01,0x80,0x25,0x0b,0x0e,0x00,0x3a, 0x0b,0x10,0x0a,0x25,0x0b,0x14,0x00,0x3a,0x0b,0x13,0x0a,0x33,0x0b,0x15,0x00,0x32, 0x0c,0x00,0x00,0x3a,0x0c,0x16,0x0b,0x37,0x0c,0x16,0x0b,0x31,0x0d,0x18,0x00,0x3a, 0x0d,0x17,0x0c,0x37,0x0c,0x16,0x0b,0x31,0x0d,0x1a,0x00,0x3a,0x0d,0x19,0x0c,0x37, 0x0c,0x16,0x0b,0x31,0x0d,0x1c,0x00,0x3a,0x0d,0x1b,0x0c,0x37,0x0c,0x16,0x0b,0x31, 0x0d,0x1e,0x00,0x3a,0x0d,0x1d,0x0c,0x37,0x0c,0x16,0x0b,0x31,0x0d,0x20,0x00,0x3a, 0x0d,0x1f,0x0c,0x37,0x0c,0x16,0x0b,0x31,0x0d,0x22,0x00,0x3a,0x0d,0x21,0x0c,0x37, 0x0c,0x16,0x0b,0x31,0x0d,0x24,0x00,0x3a,0x0d,0x23,0x0c,0x37,0x0c,0x16,0x0b,0x31, 0x0d,0x26,0x00,0x3a,0x0d,0x25,0x0c,0x37,0x0c,0x16,0x0b,0x31,0x0d,0x28,0x00,0x3a, 0x0d,0x27,0x0c,0x37,0x0c,0x16,0x0b,0x31,0x0d,0x2a,0x00,0x3a,0x0d,0x29,0x0c,0x31, 0x0c,0x2c,0x00,0x3a,0x0c,0x2b,0x0a,0x31,0x0c,0x2d,0x00,0x27,0x0d,0x00,0x00,0x31, 0x0e,0x2e,0x00,0x29,0x0f,0x00,0x00,0x31,0x10,0x2f,0x00,0x31,0x11,0x30,0x00,0x31, 0x12,0x31,0x00,0x31,0x13,0x32,0x00,0x31,0x0f,0x33,0x00,0x31,0x14,0x34,0x00,0x31, 0x15,0x36,0x00,0x3a,0x15,0x35,0x0a,0x37,0x15,0x37,0x05,0x31,0x16,0x38,0x00,0x3e, 0x15,0x02,0x02,0x3a,0x15,0x29,0x0a,0x30,0x00,0x00,0x80,0x48,0x0a,0x02,0x00,0x00, 0x0c,0x70,0x72,0x6f,0x74,0x65,0x63,0x74,0x00,0x0c,0x6d,0x65,0x73,0x73,0x61,0x67, 0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x6f,0x70,0x65,0x6e,0x00, 0x09,0x73,0x65,0x6e,0x64,0x00,0x09,0x61,0x75,0x74,0x68,0x00,0x0a,0x70,0x6c,0x61, 0x69,0x6e,0x00,0x0a,0x6c,0x6f,0x67,0x69,0x6e,0x00,0x0a,0x63,0x6c,0x6f,0x73,0x65, 0x00,0x09,0x71,0x75,0x69,0x74,0x00,0x09,0x64,0x61,0x74,0x61,0x00,0x09,0x72,0x63, 0x70,0x74,0x00,0x09,0x6d,0x61,0x69,0x6c,0x00,0x0a,0x67,0x72,0x65,0x65,0x74,0x0c, 0x5f,0x5f,0x69,0x6e,0x64,0x65,0x78,0x01,0x00,0x00,0x0a,0x2d,0x30,0x30,0x30,0x30, 0x09,0x5a,0x4f,0x4e,0x45,0x10,0x53,0x45,0x52,0x56,0x45,0x52,0x5f,0x4e,0x41,0x4d, 0x45,0x0b,0x67,0x65,0x74,0x65,0x6e,0x76,0x0b,0x44,0x4f,0x4d,0x41,0x49,0x4e,0x09, 0x50,0x4f,0x52,0x54,0x0e,0x6c,0x6f,0x63,0x61,0x6c,0x68,0x6f,0x73,0x74,0x0b,0x53, 0x45,0x52,0x56,0x45,0x52,0x0c,0x54,0x49,0x4d,0x45,0x4f,0x55,0x54,0x09,0x73,0x6d, 0x74,0x70,0x09,0x6d,0x69,0x6d,0x65,0x13,0x73,0x6f,0x63,0x6b,0x65,0x74,0x2e,0x68, 0x65,0x61,0x64,0x65,0x72,0x73,0x0a,0x6c,0x74,0x6e,0x31,0x32,0x0e,0x73,0x6f,0x63, 0x6b,0x65,0x74,0x2e,0x74,0x70,0x0b,0x73,0x6f,0x63,0x6b,0x65,0x74,0x07,0x6f,0x73, 0x09,0x6d,0x61,0x74,0x68,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0x0e,0x63,0x6f,0x72, 0x6f,0x75,0x74,0x69,0x6e,0x65,0x0c,0x72,0x65,0x71,0x75,0x69,0x72,0x65,0x07,0x5f, 0x47,0x00, }; /* socket.tp, socket/tp.lua */ static const char lua_m_socket_tp[] = { 0x1b,0x4c,0x4a,0x01,0x02,0xba,0x02,0x00,0x01,0x0c,0x02,0x08,0x00,0x3d,0x2a,0x01, 0x03,0x00,0x10,0x05,0x00,0x00,0x37,0x04,0x00,0x00,0x3e,0x04,0x02,0x03,0x10,0x06, 0x04,0x00,0x0f,0x00,0x05,0x00,0x54,0x07,0x03,0x80,0x29,0x07,0x00,0x00,0x10,0x08, 0x05,0x00,0x46,0x07,0x03,0x00,0x2b,0x07,0x00,0x00,0x37,0x07,0x01,0x07,0x27,0x08, 0x02,0x00,0x2b,0x09,0x01,0x00,0x37,0x09,0x02,0x09,0x10,0x0a,0x04,0x00,0x25,0x0b, 0x03,0x00,0x3e,0x09,0x03,0x00,0x3d,0x07,0x01,0x03,0x10,0x03,0x08,0x00,0x10,0x01, 0x07,0x00,0x0e,0x00,0x01,0x00,0x54,0x07,0x03,0x80,0x29,0x07,0x00,0x00,0x25,0x08, 0x04,0x00,0x46,0x07,0x03,0x00,0x07,0x03,0x05,0x00,0x54,0x07,0x1e,0x80,0x51,0x07, 0x1d,0x80,0x10,0x08,0x00,0x00,0x37,0x07,0x00,0x00,0x3e,0x07,0x02,0x03,0x10,0x05, 0x08,0x00,0x10,0x04,0x07,0x00,0x0f,0x00,0x05,0x00,0x54,0x07,0x03,0x80,0x29,0x07, 0x00,0x00,0x10,0x08,0x05,0x00,0x46,0x07,0x03,0x00,0x2b,0x07,0x00,0x00,0x37,0x07, 0x01,0x07,0x27,0x08,0x02,0x00,0x2b,0x09,0x01,0x00,0x37,0x09,0x02,0x09,0x10,0x0a, 0x04,0x00,0x25,0x0b,0x03,0x00,0x3e,0x09,0x03,0x00,0x3d,0x07,0x01,0x03,0x10,0x03, 0x08,0x00,0x10,0x02,0x07,0x00,0x10,0x07,0x06,0x00,0x25,0x08,0x06,0x00,0x10,0x09, 0x04,0x00,0x24,0x06,0x09,0x07,0x05,0x01,0x02,0x00,0x54,0x07,0xe4,0x7f,0x07,0x03, 0x07,0x00,0x54,0x07,0xe2,0x7f,0x10,0x07,0x01,0x00,0x10,0x08,0x06,0x00,0x46,0x07, 0x03,0x00,0x02,0xc0,0x01,0xc0,0x06,0x20,0x06,0x0a,0x06,0x2d,0x19,0x69,0x6e,0x76, 0x61,0x6c,0x69,0x64,0x20,0x73,0x65,0x72,0x76,0x65,0x72,0x20,0x72,0x65,0x70,0x6c, 0x79,0x12,0x5e,0x28,0x25,0x64,0x25,0x64,0x25,0x64,0x29,0x28,0x2e,0x3f,0x29,0x09, 0x66,0x69,0x6e,0x64,0x09,0x73,0x6b,0x69,0x70,0x0c,0x72,0x65,0x63,0x65,0x69,0x76, 0x65,0xd0,0x02,0x00,0x02,0x0c,0x03,0x07,0x00,0x46,0x2b,0x02,0x00,0x00,0x37,0x03, 0x00,0x00,0x3e,0x02,0x02,0x03,0x0e,0x00,0x02,0x00,0x54,0x04,0x03,0x80,0x29,0x04, 0x00,0x00,0x10,0x05,0x03,0x00,0x46,0x04,0x03,0x00,0x2b,0x04,0x01,0x00,0x37,0x04, 0x01,0x04,0x10,0x05,0x01,0x00,0x3e,0x04,0x02,0x02,0x06,0x04,0x02,0x00,0x54,0x04, 0x30,0x80,0x2b,0x04,0x01,0x00,0x37,0x04,0x01,0x04,0x10,0x05,0x01,0x00,0x3e,0x04, 0x02,0x02,0x07,0x04,0x03,0x00,0x54,0x04,0x18,0x80,0x2b,0x04,0x01,0x00,0x37,0x04, 0x04,0x04,0x10,0x05,0x01,0x00,0x3e,0x04,0x02,0x04,0x54,0x07,0x0d,0x80,0x2b,0x09, 0x02,0x00,0x37,0x09,0x05,0x09,0x10,0x0a,0x02,0x00,0x10,0x0b,0x08,0x00,0x3e,0x09, 0x03,0x02,0x0f,0x00,0x09,0x00,0x54,0x0a,0x06,0x80,0x2b,0x09,0x01,0x00,0x37,0x09, 0x06,0x09,0x10,0x0a,0x02,0x00,0x3e,0x09,0x02,0x02,0x10,0x0a,0x03,0x00,0x46,0x09, 0x03,0x00,0x41,0x07,0x03,0x03,0x4e,0x07,0xf1,0x7f,0x29,0x04,0x00,0x00,0x10,0x05, 0x03,0x00,0x46,0x04,0x03,0x00,0x54,0x04,0x19,0x80,0x2b,0x04,0x02,0x00,0x37,0x04, 0x05,0x04,0x10,0x05,0x02,0x00,0x10,0x06,0x01,0x00,0x3e,0x04,0x03,0x02,0x0f,0x00, 0x04,0x00,0x54,0x05,0x07,0x80,0x2b,0x04,0x01,0x00,0x37,0x04,0x06,0x04,0x10,0x05, 0x02,0x00,0x3e,0x04,0x02,0x02,0x10,0x05,0x03,0x00,0x46,0x04,0x03,0x00,0x54,0x04, 0x0b,0x80,0x29,0x04,0x00,0x00,0x10,0x05,0x03,0x00,0x46,0x04,0x03,0x00,0x54,0x04, 0x07,0x80,0x10,0x04,0x01,0x00,0x2b,0x05,0x01,0x00,0x37,0x05,0x06,0x05,0x10,0x06, 0x02,0x00,0x3e,0x05,0x02,0x02,0x10,0x06,0x03,0x00,0x40,0x04,0x03,0x00,0x47,0x00, 0x01,0x00,0x05,0xc0,0x00,0xc0,0x01,0xc0,0x0d,0x74,0x6f,0x6e,0x75,0x6d,0x62,0x65, 0x72,0x09,0x66,0x69,0x6e,0x64,0x0b,0x69,0x70,0x61,0x69,0x72,0x73,0x0a,0x74,0x61, 0x62,0x6c,0x65,0x0d,0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x09,0x74,0x79,0x70, 0x65,0x06,0x63,0x7f,0x00,0x03,0x09,0x01,0x05,0x00,0x19,0x2b,0x03,0x00,0x00,0x37, 0x03,0x00,0x03,0x10,0x04,0x01,0x00,0x3e,0x03,0x02,0x02,0x10,0x01,0x03,0x00,0x0f, 0x00,0x02,0x00,0x54,0x03,0x0a,0x80,0x37,0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37, 0x03,0x02,0x03,0x10,0x05,0x01,0x00,0x25,0x06,0x03,0x00,0x10,0x07,0x02,0x00,0x25, 0x08,0x04,0x00,0x24,0x05,0x08,0x05,0x40,0x03,0x03,0x00,0x54,0x03,0x07,0x80,0x37, 0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x02,0x03,0x10,0x05,0x01,0x00,0x25, 0x06,0x04,0x00,0x24,0x05,0x06,0x05,0x40,0x03,0x03,0x00,0x47,0x00,0x01,0x00,0x01, 0xc0,0x07,0x0d,0x0a,0x06,0x20,0x09,0x73,0x65,0x6e,0x64,0x06,0x63,0x0a,0x75,0x70, 0x70,0x65,0x72,0x35,0x00,0x03,0x08,0x00,0x02,0x00,0x09,0x34,0x03,0x00,0x00,0x10, 0x04,0x03,0x00,0x37,0x03,0x01,0x03,0x10,0x05,0x02,0x00,0x3e,0x03,0x03,0x03,0x10, 0x05,0x01,0x00,0x10,0x06,0x03,0x00,0x10,0x07,0x04,0x00,0x40,0x05,0x03,0x00,0x0c, 0x72,0x65,0x63,0x65,0x69,0x76,0x65,0x06,0x63,0x22,0x00,0x02,0x05,0x00,0x02,0x00, 0x05,0x37,0x02,0x00,0x00,0x10,0x03,0x02,0x00,0x37,0x02,0x01,0x02,0x10,0x04,0x01, 0x00,0x40,0x02,0x03,0x00,0x09,0x73,0x65,0x6e,0x64,0x06,0x63,0x25,0x00,0x02,0x05, 0x00,0x02,0x00,0x05,0x37,0x02,0x00,0x00,0x10,0x03,0x02,0x00,0x37,0x02,0x01,0x02, 0x10,0x04,0x01,0x00,0x40,0x02,0x03,0x00,0x0c,0x72,0x65,0x63,0x65,0x69,0x76,0x65, 0x06,0x63,0x1f,0x00,0x01,0x03,0x00,0x02,0x00,0x04,0x37,0x01,0x00,0x00,0x10,0x02, 0x01,0x00,0x37,0x01,0x01,0x01,0x40,0x01,0x02,0x00,0x0a,0x67,0x65,0x74,0x66,0x64, 0x06,0x63,0x1f,0x00,0x01,0x03,0x00,0x02,0x00,0x04,0x37,0x01,0x00,0x00,0x10,0x02, 0x01,0x00,0x37,0x01,0x01,0x01,0x40,0x01,0x02,0x00,0x0a,0x64,0x69,0x72,0x74,0x79, 0x06,0x63,0x11,0x00,0x01,0x02,0x00,0x01,0x00,0x02,0x37,0x01,0x00,0x00,0x48,0x01, 0x02,0x00,0x06,0x63,0x76,0x00,0x03,0x08,0x02,0x06,0x00,0x13,0x2b,0x03,0x00,0x00, 0x37,0x03,0x00,0x03,0x25,0x04,0x01,0x00,0x37,0x05,0x02,0x00,0x3e,0x03,0x03,0x02, 0x2b,0x04,0x01,0x00,0x37,0x04,0x03,0x04,0x37,0x04,0x04,0x04,0x10,0x05,0x01,0x00, 0x10,0x06,0x03,0x00,0x0c,0x07,0x02,0x00,0x54,0x07,0x03,0x80,0x2b,0x07,0x01,0x00, 0x37,0x07,0x03,0x07,0x37,0x07,0x05,0x07,0x3e,0x04,0x04,0x03,0x10,0x06,0x04,0x00, 0x10,0x07,0x05,0x00,0x46,0x06,0x03,0x00,0x02,0xc0,0x03,0xc0,0x09,0x73,0x74,0x65, 0x70,0x08,0x61,0x6c,0x6c,0x09,0x70,0x75,0x6d,0x70,0x06,0x63,0x0e,0x6b,0x65,0x65, 0x70,0x2d,0x6f,0x70,0x65,0x6e,0x09,0x73,0x69,0x6e,0x6b,0x27,0x00,0x01,0x03,0x00, 0x02,0x00,0x06,0x37,0x01,0x00,0x00,0x10,0x02,0x01,0x00,0x37,0x01,0x01,0x01,0x3e, 0x01,0x02,0x01,0x27,0x01,0x01,0x00,0x48,0x01,0x02,0x00,0x0a,0x63,0x6c,0x6f,0x73, 0x65,0x06,0x63,0xd6,0x01,0x00,0x04,0x0b,0x04,0x08,0x00,0x24,0x0c,0x04,0x03,0x00, 0x54,0x04,0x02,0x80,0x2b,0x04,0x00,0x00,0x37,0x04,0x00,0x04,0x3e,0x04,0x01,0x03, 0x0e,0x00,0x04,0x00,0x54,0x06,0x03,0x80,0x29,0x06,0x00,0x00,0x10,0x07,0x05,0x00, 0x46,0x06,0x03,0x00,0x10,0x07,0x04,0x00,0x37,0x06,0x01,0x04,0x0c,0x08,0x02,0x00, 0x54,0x08,0x02,0x80,0x2b,0x08,0x01,0x00,0x37,0x08,0x02,0x08,0x3e,0x06,0x03,0x01, 0x10,0x07,0x04,0x00,0x37,0x06,0x03,0x04,0x10,0x08,0x00,0x00,0x10,0x09,0x01,0x00, 0x3e,0x06,0x04,0x03,0x0e,0x00,0x06,0x00,0x54,0x08,0x06,0x80,0x10,0x09,0x04,0x00, 0x37,0x08,0x04,0x04,0x3e,0x08,0x02,0x01,0x29,0x08,0x00,0x00,0x10,0x09,0x07,0x00, 0x46,0x08,0x03,0x00,0x2b,0x08,0x02,0x00,0x37,0x08,0x05,0x08,0x33,0x09,0x06,0x00, 0x3a,0x04,0x07,0x09,0x2b,0x0a,0x03,0x00,0x40,0x08,0x03,0x00,0x02,0xc0,0x04,0xc0, 0x00,0xc0,0x06,0xc0,0x06,0x63,0x01,0x00,0x00,0x11,0x73,0x65,0x74,0x6d,0x65,0x74, 0x61,0x74,0x61,0x62,0x6c,0x65,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x0c,0x63,0x6f,0x6e, 0x6e,0x65,0x63,0x74,0x0c,0x54,0x49,0x4d,0x45,0x4f,0x55,0x54,0x0f,0x73,0x65,0x74, 0x74,0x69,0x6d,0x65,0x6f,0x75,0x74,0x08,0x74,0x63,0x70,0xe8,0x02,0x03,0x00,0x09, 0x00,0x20,0x00,0x35,0x34,0x00,0x00,0x00,0x34,0x01,0x01,0x00,0x25,0x02,0x02,0x00, 0x3e,0x01,0x02,0x02,0x34,0x02,0x01,0x00,0x25,0x03,0x03,0x00,0x3e,0x02,0x02,0x02, 0x34,0x03,0x01,0x00,0x25,0x04,0x04,0x00,0x3e,0x03,0x02,0x02,0x32,0x04,0x00,0x00, 0x3a,0x04,0x05,0x02,0x37,0x04,0x05,0x02,0x27,0x05,0x3c,0x00,0x3a,0x05,0x06,0x04, 0x31,0x05,0x07,0x00,0x33,0x06,0x08,0x00,0x32,0x07,0x00,0x00,0x3a,0x07,0x09,0x06, 0x37,0x07,0x09,0x06,0x31,0x08,0x0b,0x00,0x3a,0x08,0x0a,0x07,0x37,0x07,0x09,0x06, 0x31,0x08,0x0d,0x00,0x3a,0x08,0x0c,0x07,0x37,0x07,0x09,0x06,0x31,0x08,0x0f,0x00, 0x3a,0x08,0x0e,0x07,0x37,0x07,0x09,0x06,0x31,0x08,0x11,0x00,0x3a,0x08,0x10,0x07, 0x37,0x07,0x09,0x06,0x31,0x08,0x13,0x00,0x3a,0x08,0x12,0x07,0x37,0x07,0x09,0x06, 0x31,0x08,0x15,0x00,0x3a,0x08,0x14,0x07,0x37,0x07,0x09,0x06,0x31,0x08,0x17,0x00, 0x3a,0x08,0x16,0x07,0x37,0x07,0x09,0x06,0x31,0x08,0x19,0x00,0x3a,0x08,0x18,0x07, 0x37,0x07,0x09,0x06,0x31,0x08,0x1b,0x00,0x3a,0x08,0x1a,0x07,0x37,0x07,0x09,0x06, 0x31,0x08,0x1d,0x00,0x3a,0x08,0x1c,0x07,0x31,0x07,0x1f,0x00,0x3a,0x07,0x1e,0x04, 0x30,0x00,0x00,0x80,0x48,0x04,0x02,0x00,0x00,0x0c,0x63,0x6f,0x6e,0x6e,0x65,0x63, 0x74,0x00,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x00,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65, 0x00,0x0f,0x67,0x65,0x74,0x63,0x6f,0x6e,0x74,0x72,0x6f,0x6c,0x00,0x0a,0x64,0x69, 0x72,0x74,0x79,0x00,0x0a,0x67,0x65,0x74,0x66,0x64,0x00,0x0c,0x72,0x65,0x63,0x65, 0x69,0x76,0x65,0x00,0x09,0x73,0x65,0x6e,0x64,0x00,0x09,0x73,0x69,0x6e,0x6b,0x00, 0x0c,0x63,0x6f,0x6d,0x6d,0x61,0x6e,0x64,0x00,0x0a,0x63,0x68,0x65,0x63,0x6b,0x0c, 0x5f,0x5f,0x69,0x6e,0x64,0x65,0x78,0x01,0x00,0x00,0x00,0x0c,0x54,0x49,0x4d,0x45, 0x4f,0x55,0x54,0x07,0x74,0x70,0x0a,0x6c,0x74,0x6e,0x31,0x32,0x0b,0x73,0x6f,0x63, 0x6b,0x65,0x74,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0x0c,0x72,0x65,0x71,0x75,0x69, 0x72,0x65,0x07,0x5f,0x47,0x00, }; /* socket.url, socket/url.lua */ static const char lua_m_socket_url[] = { 0x1b,0x4c,0x4a,0x01,0x02,0x3c,0x00,0x01,0x05,0x01,0x03,0x00,0x08,0x2b,0x01,0x00, 0x00,0x37,0x01,0x00,0x01,0x25,0x02,0x01,0x00,0x2b,0x03,0x00,0x00,0x37,0x03,0x02, 0x03,0x10,0x04,0x00,0x00,0x3e,0x03,0x02,0x00,0x3f,0x01,0x01,0x00,0x00,0x00,0x09, 0x62,0x79,0x74,0x65,0x0b,0x25,0x25,0x25,0x30,0x32,0x78,0x0b,0x66,0x6f,0x72,0x6d, 0x61,0x74,0x3f,0x01,0x01,0x05,0x01,0x03,0x00,0x08,0x2b,0x01,0x00,0x00,0x37,0x01, 0x00,0x01,0x10,0x02,0x00,0x00,0x25,0x03,0x01,0x00,0x31,0x04,0x02,0x00,0x3e,0x01, 0x04,0x02,0x30,0x00,0x00,0x80,0x48,0x01,0x02,0x00,0x00,0xc0,0x00,0x14,0x28,0x5b, 0x5e,0x41,0x2d,0x5a,0x61,0x2d,0x7a,0x30,0x2d,0x39,0x5f,0x5d,0x29,0x09,0x67,0x73, 0x75,0x62,0x40,0x00,0x01,0x09,0x01,0x01,0x00,0x0c,0x32,0x01,0x00,0x00,0x2b,0x02, 0x00,0x00,0x37,0x02,0x00,0x02,0x10,0x03,0x00,0x00,0x3e,0x02,0x02,0x04,0x54,0x05, 0x03,0x80,0x36,0x07,0x05,0x00,0x27,0x08,0x01,0x00,0x39,0x08,0x07,0x01,0x41,0x05, 0x03,0x03,0x4e,0x05,0xfb,0x7f,0x48,0x01,0x02,0x00,0x01,0xc0,0x0b,0x69,0x70,0x61, 0x69,0x72,0x73,0x5a,0x00,0x01,0x05,0x02,0x03,0x00,0x0f,0x2b,0x01,0x00,0x00,0x36, 0x01,0x00,0x01,0x0f,0x00,0x01,0x00,0x54,0x02,0x02,0x80,0x48,0x00,0x02,0x00,0x54, 0x01,0x08,0x80,0x2b,0x01,0x01,0x00,0x37,0x01,0x00,0x01,0x25,0x02,0x01,0x00,0x2b, 0x03,0x01,0x00,0x37,0x03,0x02,0x03,0x10,0x04,0x00,0x00,0x3e,0x03,0x02,0x00,0x3f, 0x01,0x01,0x00,0x47,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x09,0x62,0x79,0x74,0x65, 0x0b,0x25,0x25,0x25,0x30,0x32,0x78,0x0b,0x66,0x6f,0x72,0x6d,0x61,0x74,0x3d,0x01, 0x01,0x05,0x02,0x03,0x00,0x07,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x10,0x02, 0x00,0x00,0x25,0x03,0x01,0x00,0x31,0x04,0x02,0x00,0x30,0x00,0x00,0x80,0x40,0x01, 0x04,0x00,0x00,0xc0,0x06,0xc0,0x00,0x14,0x28,0x5b,0x5e,0x41,0x2d,0x5a,0x61,0x2d, 0x7a,0x30,0x2d,0x39,0x5f,0x5d,0x29,0x09,0x67,0x73,0x75,0x62,0x39,0x00,0x01,0x05, 0x02,0x02,0x00,0x08,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x2b,0x02,0x01,0x00, 0x37,0x02,0x01,0x02,0x10,0x03,0x00,0x00,0x27,0x04,0x10,0x00,0x3e,0x02,0x03,0x00, 0x3f,0x01,0x00,0x00,0x00,0x00,0x01,0x00,0x0d,0x74,0x6f,0x6e,0x75,0x6d,0x62,0x65, 0x72,0x09,0x63,0x68,0x61,0x72,0x3a,0x01,0x01,0x05,0x02,0x03,0x00,0x08,0x2b,0x01, 0x00,0x00,0x37,0x01,0x00,0x01,0x10,0x02,0x00,0x00,0x25,0x03,0x01,0x00,0x31,0x04, 0x02,0x00,0x3e,0x01,0x04,0x02,0x30,0x00,0x00,0x80,0x48,0x01,0x02,0x00,0x00,0xc0, 0x01,0xc0,0x00,0x0d,0x25,0x25,0x28,0x25,0x78,0x25,0x78,0x29,0x09,0x67,0x73,0x75, 0x62,0x27,0x00,0x01,0x02,0x00,0x02,0x00,0x07,0x06,0x00,0x00,0x00,0x54,0x01,0x02, 0x80,0x48,0x00,0x02,0x00,0x54,0x01,0x02,0x80,0x25,0x01,0x01,0x00,0x48,0x01,0x02, 0x00,0x47,0x00,0x01,0x00,0x05,0x07,0x2e,0x2f,0x2b,0x00,0x01,0x02,0x00,0x02,0x00, 0x07,0x06,0x00,0x00,0x00,0x54,0x01,0x03,0x80,0x25,0x01,0x01,0x00,0x48,0x01,0x02, 0x00,0x54,0x01,0x01,0x80,0x48,0x00,0x02,0x00,0x47,0x00,0x01,0x00,0x05,0x0b,0x2e, 0x2e,0x2f,0x2e,0x2e,0x2f,0x2a,0x00,0x01,0x02,0x00,0x02,0x00,0x07,0x06,0x00,0x00, 0x00,0x54,0x01,0x03,0x80,0x25,0x01,0x01,0x00,0x48,0x01,0x02,0x00,0x54,0x01,0x01, 0x80,0x48,0x00,0x02,0x00,0x47,0x00,0x01,0x00,0x05,0x0a,0x2e,0x2e,0x2f,0x2e,0x2e, 0xa7,0x02,0x01,0x02,0x08,0x01,0x0c,0x00,0x37,0x2b,0x02,0x00,0x00,0x37,0x02,0x00, 0x02,0x10,0x03,0x01,0x00,0x27,0x04,0x01,0x00,0x27,0x05,0x01,0x00,0x3e,0x02,0x04, 0x02,0x07,0x02,0x01,0x00,0x54,0x02,0x01,0x80,0x30,0x00,0x2d,0x80,0x2b,0x02,0x00, 0x00,0x37,0x02,0x02,0x02,0x10,0x03,0x00,0x00,0x25,0x04,0x03,0x00,0x25,0x05,0x04, 0x00,0x3e,0x02,0x04,0x02,0x10,0x03,0x02,0x00,0x10,0x04,0x01,0x00,0x24,0x02,0x04, 0x03,0x2b,0x03,0x00,0x00,0x37,0x03,0x02,0x03,0x10,0x04,0x02,0x00,0x25,0x05,0x05, 0x00,0x31,0x06,0x06,0x00,0x3e,0x03,0x04,0x02,0x10,0x02,0x03,0x00,0x2b,0x03,0x00, 0x00,0x37,0x03,0x02,0x03,0x10,0x04,0x02,0x00,0x25,0x05,0x07,0x00,0x25,0x06,0x01, 0x00,0x3e,0x03,0x04,0x02,0x10,0x02,0x03,0x00,0x29,0x03,0x00,0x00,0x04,0x03,0x02, 0x00,0x54,0x04,0x0a,0x80,0x51,0x04,0x09,0x80,0x10,0x03,0x02,0x00,0x2b,0x04,0x00, 0x00,0x37,0x04,0x02,0x04,0x10,0x05,0x03,0x00,0x25,0x06,0x08,0x00,0x31,0x07,0x09, 0x00,0x3e,0x04,0x04,0x02,0x10,0x02,0x04,0x00,0x54,0x04,0xf4,0x7f,0x2b,0x04,0x00, 0x00,0x37,0x04,0x02,0x04,0x10,0x05,0x03,0x00,0x25,0x06,0x0a,0x00,0x31,0x07,0x0b, 0x00,0x3e,0x04,0x04,0x02,0x10,0x02,0x04,0x00,0x30,0x00,0x00,0x80,0x48,0x02,0x02, 0x00,0x48,0x01,0x02,0x00,0x00,0xc0,0x00,0x12,0x28,0x5b,0x5e,0x2f,0x5d,0x2a,0x2f, 0x25,0x2e,0x25,0x2e,0x29,0x24,0x00,0x12,0x28,0x5b,0x5e,0x2f,0x5d,0x2a,0x2f,0x25, 0x2e,0x25,0x2e,0x2f,0x29,0x09,0x2f,0x25,0x2e,0x24,0x00,0x0f,0x28,0x5b,0x5e,0x2f, 0x5d,0x2a,0x25,0x2e,0x2f,0x29,0x05,0x0b,0x5b,0x5e,0x2f,0x5d,0x2a,0x24,0x09,0x67, 0x73,0x75,0x62,0x06,0x2f,0x08,0x73,0x75,0x62,0x23,0x00,0x01,0x02,0x01,0x02,0x00, 0x04,0x2b,0x01,0x00,0x00,0x3a,0x00,0x00,0x01,0x25,0x01,0x01,0x00,0x48,0x01,0x02, 0x00,0x02,0xc0,0x05,0x0d,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x21,0x00,0x01, 0x02,0x01,0x02,0x00,0x04,0x2b,0x01,0x00,0x00,0x3a,0x00,0x00,0x01,0x25,0x01,0x01, 0x00,0x48,0x01,0x02,0x00,0x02,0xc0,0x05,0x0b,0x73,0x63,0x68,0x65,0x6d,0x65,0x24, 0x00,0x01,0x02,0x01,0x02,0x00,0x04,0x2b,0x01,0x00,0x00,0x3a,0x00,0x00,0x01,0x25, 0x01,0x01,0x00,0x48,0x01,0x02,0x00,0x02,0xc0,0x05,0x0e,0x61,0x75,0x74,0x68,0x6f, 0x72,0x69,0x74,0x79,0x20,0x00,0x01,0x02,0x01,0x02,0x00,0x04,0x2b,0x01,0x00,0x00, 0x3a,0x00,0x00,0x01,0x25,0x01,0x01,0x00,0x48,0x01,0x02,0x00,0x02,0xc0,0x05,0x0a, 0x71,0x75,0x65,0x72,0x79,0x21,0x00,0x01,0x02,0x01,0x02,0x00,0x04,0x2b,0x01,0x00, 0x00,0x3a,0x00,0x00,0x01,0x25,0x01,0x01,0x00,0x48,0x01,0x02,0x00,0x02,0xc0,0x05, 0x0b,0x70,0x61,0x72,0x61,0x6d,0x73,0x23,0x00,0x01,0x02,0x01,0x02,0x00,0x04,0x2b, 0x01,0x00,0x00,0x3a,0x00,0x00,0x01,0x25,0x01,0x01,0x00,0x48,0x01,0x02,0x00,0x02, 0xc0,0x05,0x0d,0x75,0x73,0x65,0x72,0x69,0x6e,0x66,0x6f,0x1f,0x00,0x01,0x02,0x01, 0x02,0x00,0x04,0x2b,0x01,0x00,0x00,0x3a,0x00,0x00,0x01,0x25,0x01,0x01,0x00,0x48, 0x01,0x02,0x00,0x02,0xc0,0x05,0x09,0x70,0x6f,0x72,0x74,0x23,0x00,0x01,0x02,0x01, 0x02,0x00,0x04,0x2b,0x01,0x00,0x00,0x3a,0x00,0x00,0x01,0x25,0x01,0x01,0x00,0x48, 0x01,0x02,0x00,0x02,0xc0,0x05,0x0d,0x70,0x61,0x73,0x73,0x77,0x6f,0x72,0x64,0xcb, 0x04,0x01,0x02,0x09,0x02,0x1b,0x00,0x66,0x32,0x02,0x00,0x00,0x2b,0x03,0x00,0x00, 0x37,0x03,0x00,0x03,0x0c,0x04,0x01,0x00,0x54,0x04,0x01,0x80,0x10,0x04,0x02,0x00, 0x3e,0x03,0x02,0x04,0x54,0x06,0x01,0x80,0x39,0x07,0x06,0x02,0x41,0x06,0x03,0x03, 0x4e,0x06,0xfd,0x7f,0x0f,0x00,0x00,0x00,0x54,0x03,0x02,0x80,0x07,0x00,0x01,0x00, 0x54,0x03,0x03,0x80,0x29,0x03,0x00,0x00,0x25,0x04,0x02,0x00,0x30,0x00,0x53,0x80, 0x2b,0x03,0x01,0x00,0x37,0x03,0x03,0x03,0x10,0x04,0x00,0x00,0x25,0x05,0x04,0x00, 0x31,0x06,0x05,0x00,0x3e,0x03,0x04,0x02,0x10,0x00,0x03,0x00,0x2b,0x03,0x01,0x00, 0x37,0x03,0x03,0x03,0x10,0x04,0x00,0x00,0x25,0x05,0x06,0x00,0x31,0x06,0x07,0x00, 0x3e,0x03,0x04,0x02,0x10,0x00,0x03,0x00,0x2b,0x03,0x01,0x00,0x37,0x03,0x03,0x03, 0x10,0x04,0x00,0x00,0x25,0x05,0x08,0x00,0x31,0x06,0x09,0x00,0x3e,0x03,0x04,0x02, 0x10,0x00,0x03,0x00,0x2b,0x03,0x01,0x00,0x37,0x03,0x03,0x03,0x10,0x04,0x00,0x00, 0x25,0x05,0x0a,0x00,0x31,0x06,0x0b,0x00,0x3e,0x03,0x04,0x02,0x10,0x00,0x03,0x00, 0x2b,0x03,0x01,0x00,0x37,0x03,0x03,0x03,0x10,0x04,0x00,0x00,0x25,0x05,0x0c,0x00, 0x31,0x06,0x0d,0x00,0x3e,0x03,0x04,0x02,0x10,0x00,0x03,0x00,0x06,0x00,0x01,0x00, 0x54,0x03,0x01,0x80,0x3a,0x00,0x0e,0x02,0x37,0x03,0x0f,0x02,0x0e,0x00,0x03,0x00, 0x54,0x04,0x02,0x80,0x30,0x00,0x00,0x80,0x48,0x02,0x02,0x00,0x2b,0x04,0x01,0x00, 0x37,0x04,0x03,0x04,0x10,0x05,0x03,0x00,0x25,0x06,0x10,0x00,0x31,0x07,0x11,0x00, 0x3e,0x04,0x04,0x02,0x10,0x03,0x04,0x00,0x2b,0x04,0x01,0x00,0x37,0x04,0x03,0x04, 0x10,0x05,0x03,0x00,0x25,0x06,0x12,0x00,0x31,0x07,0x13,0x00,0x3e,0x04,0x04,0x02, 0x10,0x03,0x04,0x00,0x06,0x03,0x01,0x00,0x54,0x04,0x09,0x80,0x2b,0x04,0x01,0x00, 0x37,0x04,0x15,0x04,0x10,0x05,0x03,0x00,0x25,0x06,0x16,0x00,0x3e,0x04,0x03,0x02, 0x0e,0x00,0x04,0x00,0x54,0x05,0x01,0x80,0x10,0x04,0x03,0x00,0x3a,0x04,0x14,0x02, 0x37,0x04,0x17,0x02,0x0e,0x00,0x04,0x00,0x54,0x05,0x02,0x80,0x30,0x00,0x00,0x80, 0x48,0x02,0x02,0x00,0x2b,0x05,0x01,0x00,0x37,0x05,0x03,0x05,0x10,0x06,0x04,0x00, 0x25,0x07,0x18,0x00,0x31,0x08,0x19,0x00,0x3e,0x05,0x04,0x02,0x10,0x04,0x05,0x00, 0x3a,0x04,0x1a,0x02,0x30,0x00,0x00,0x80,0x48,0x02,0x02,0x00,0x46,0x03,0x03,0x00, 0x01,0xc0,0x00,0xc0,0x09,0x75,0x73,0x65,0x72,0x00,0x0e,0x3a,0x28,0x5b,0x5e,0x3a, 0x5d,0x2a,0x29,0x24,0x0d,0x75,0x73,0x65,0x72,0x69,0x6e,0x66,0x6f,0x0f,0x5e,0x25, 0x5b,0x28,0x2e,0x2b,0x29,0x25,0x5d,0x24,0x0a,0x6d,0x61,0x74,0x63,0x68,0x09,0x68, 0x6f,0x73,0x74,0x00,0x10,0x3a,0x28,0x5b,0x5e,0x3a,0x25,0x5d,0x5d,0x2a,0x29,0x24, 0x00,0x0e,0x5e,0x28,0x5b,0x5e,0x40,0x5d,0x2a,0x29,0x40,0x0e,0x61,0x75,0x74,0x68, 0x6f,0x72,0x69,0x74,0x79,0x09,0x70,0x61,0x74,0x68,0x00,0x0b,0x25,0x3b,0x28,0x2e, 0x2a,0x29,0x00,0x0b,0x25,0x3f,0x28,0x2e,0x2a,0x29,0x00,0x0f,0x5e,0x2f,0x2f,0x28, 0x5b,0x5e,0x2f,0x5d,0x2a,0x29,0x00,0x19,0x5e,0x28,0x5b,0x25,0x77,0x5d,0x5b,0x25, 0x77,0x25,0x2b,0x25,0x2d,0x25,0x2e,0x5d,0x2a,0x29,0x25,0x3a,0x00,0x0b,0x23,0x28, 0x2e,0x2a,0x29,0x24,0x09,0x67,0x73,0x75,0x62,0x10,0x69,0x6e,0x76,0x61,0x6c,0x69, 0x64,0x20,0x75,0x72,0x6c,0x05,0x0a,0x70,0x61,0x69,0x72,0x73,0xe1,0x03,0x00,0x01, 0x08,0x02,0x17,0x00,0x57,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x37,0x02,0x01, 0x00,0x0e,0x00,0x02,0x00,0x54,0x03,0x01,0x80,0x25,0x02,0x02,0x00,0x3e,0x01,0x02, 0x02,0x2b,0x02,0x00,0x00,0x37,0x02,0x03,0x02,0x10,0x03,0x01,0x00,0x3e,0x02,0x02, 0x02,0x37,0x03,0x04,0x00,0x0f,0x00,0x03,0x00,0x54,0x04,0x04,0x80,0x10,0x03,0x02, 0x00,0x25,0x04,0x05,0x00,0x37,0x05,0x04,0x00,0x24,0x02,0x05,0x03,0x37,0x03,0x06, 0x00,0x0f,0x00,0x03,0x00,0x54,0x04,0x04,0x80,0x10,0x03,0x02,0x00,0x25,0x04,0x07, 0x00,0x37,0x05,0x06,0x00,0x24,0x02,0x05,0x03,0x37,0x03,0x08,0x00,0x37,0x04,0x09, 0x00,0x0f,0x00,0x04,0x00,0x54,0x05,0x25,0x80,0x37,0x03,0x09,0x00,0x2b,0x04,0x01, 0x00,0x37,0x04,0x0a,0x04,0x10,0x05,0x03,0x00,0x25,0x06,0x0b,0x00,0x3e,0x04,0x03, 0x02,0x0f,0x00,0x04,0x00,0x54,0x05,0x04,0x80,0x25,0x04,0x0c,0x00,0x10,0x05,0x03, 0x00,0x25,0x06,0x0d,0x00,0x24,0x03,0x06,0x04,0x37,0x04,0x0e,0x00,0x0f,0x00,0x04, 0x00,0x54,0x05,0x04,0x80,0x10,0x04,0x03,0x00,0x25,0x05,0x0b,0x00,0x37,0x06,0x0e, 0x00,0x24,0x03,0x06,0x04,0x37,0x04,0x0f,0x00,0x37,0x05,0x10,0x00,0x0f,0x00,0x05, 0x00,0x54,0x06,0x08,0x80,0x37,0x04,0x10,0x00,0x37,0x05,0x11,0x00,0x0f,0x00,0x05, 0x00,0x54,0x06,0x04,0x80,0x10,0x05,0x04,0x00,0x25,0x06,0x0b,0x00,0x37,0x07,0x11, 0x00,0x24,0x04,0x07,0x05,0x0f,0x00,0x04,0x00,0x54,0x05,0x04,0x80,0x10,0x05,0x04, 0x00,0x25,0x06,0x12,0x00,0x10,0x07,0x03,0x00,0x24,0x03,0x07,0x05,0x0f,0x00,0x03, 0x00,0x54,0x04,0x04,0x80,0x25,0x04,0x13,0x00,0x10,0x05,0x03,0x00,0x10,0x06,0x02, 0x00,0x24,0x02,0x06,0x04,0x37,0x04,0x14,0x00,0x0f,0x00,0x04,0x00,0x54,0x05,0x04, 0x80,0x37,0x04,0x14,0x00,0x25,0x05,0x0b,0x00,0x10,0x06,0x02,0x00,0x24,0x02,0x06, 0x04,0x37,0x04,0x15,0x00,0x0f,0x00,0x04,0x00,0x54,0x05,0x04,0x80,0x10,0x04,0x02, 0x00,0x25,0x05,0x16,0x00,0x37,0x06,0x15,0x00,0x24,0x02,0x06,0x04,0x48,0x02,0x02, 0x00,0x04,0xc0,0x00,0xc0,0x06,0x23,0x0d,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74, 0x0b,0x73,0x63,0x68,0x65,0x6d,0x65,0x07,0x2f,0x2f,0x06,0x40,0x0d,0x70,0x61,0x73, 0x73,0x77,0x6f,0x72,0x64,0x09,0x75,0x73,0x65,0x72,0x0d,0x75,0x73,0x65,0x72,0x69, 0x6e,0x66,0x6f,0x09,0x70,0x6f,0x72,0x74,0x06,0x5d,0x06,0x5b,0x06,0x3a,0x09,0x66, 0x69,0x6e,0x64,0x09,0x68,0x6f,0x73,0x74,0x0e,0x61,0x75,0x74,0x68,0x6f,0x72,0x69, 0x74,0x79,0x06,0x3f,0x0a,0x71,0x75,0x65,0x72,0x79,0x06,0x3b,0x0b,0x70,0x61,0x72, 0x61,0x6d,0x73,0x0f,0x62,0x75,0x69,0x6c,0x64,0x5f,0x70,0x61,0x74,0x68,0x05,0x09, 0x70,0x61,0x74,0x68,0x0f,0x70,0x61,0x72,0x73,0x65,0x5f,0x70,0x61,0x74,0x68,0x8c, 0x03,0x00,0x02,0x06,0x03,0x0b,0x00,0x4e,0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02, 0x10,0x03,0x00,0x00,0x3e,0x02,0x02,0x02,0x07,0x02,0x01,0x00,0x54,0x02,0x07,0x80, 0x35,0x00,0x02,0x00,0x2b,0x02,0x01,0x00,0x37,0x02,0x03,0x02,0x34,0x03,0x02,0x00, 0x3e,0x02,0x02,0x02,0x10,0x00,0x02,0x00,0x54,0x02,0x05,0x80,0x2b,0x02,0x01,0x00, 0x37,0x02,0x04,0x02,0x10,0x03,0x00,0x00,0x3e,0x02,0x02,0x02,0x35,0x02,0x02,0x00, 0x2b,0x02,0x01,0x00,0x37,0x02,0x04,0x02,0x10,0x03,0x01,0x00,0x3e,0x02,0x02,0x02, 0x34,0x03,0x02,0x00,0x0e,0x00,0x03,0x00,0x54,0x03,0x02,0x80,0x48,0x01,0x02,0x00, 0x54,0x03,0x32,0x80,0x0e,0x00,0x02,0x00,0x54,0x03,0x02,0x80,0x48,0x00,0x02,0x00, 0x54,0x03,0x2e,0x80,0x37,0x03,0x05,0x02,0x0f,0x00,0x03,0x00,0x54,0x04,0x02,0x80, 0x48,0x01,0x02,0x00,0x54,0x03,0x29,0x80,0x34,0x03,0x02,0x00,0x37,0x03,0x05,0x03, 0x3a,0x03,0x05,0x02,0x37,0x03,0x06,0x02,0x0e,0x00,0x03,0x00,0x54,0x03,0x1f,0x80, 0x34,0x03,0x02,0x00,0x37,0x03,0x06,0x03,0x3a,0x03,0x06,0x02,0x37,0x03,0x07,0x02, 0x0e,0x00,0x03,0x00,0x54,0x03,0x10,0x80,0x34,0x03,0x02,0x00,0x37,0x03,0x07,0x03, 0x3a,0x03,0x07,0x02,0x37,0x03,0x08,0x02,0x0e,0x00,0x03,0x00,0x54,0x03,0x13,0x80, 0x34,0x03,0x02,0x00,0x37,0x03,0x08,0x03,0x3a,0x03,0x08,0x02,0x37,0x03,0x09,0x02, 0x0e,0x00,0x03,0x00,0x54,0x03,0x0d,0x80,0x34,0x03,0x02,0x00,0x37,0x03,0x09,0x03, 0x3a,0x03,0x09,0x02,0x54,0x03,0x09,0x80,0x2b,0x03,0x02,0x00,0x34,0x04,0x02,0x00, 0x37,0x04,0x07,0x04,0x0e,0x00,0x04,0x00,0x54,0x05,0x01,0x80,0x25,0x04,0x0a,0x00, 0x37,0x05,0x07,0x02,0x3e,0x03,0x03,0x02,0x3a,0x03,0x07,0x02,0x2b,0x03,0x01,0x00, 0x37,0x03,0x03,0x03,0x10,0x04,0x02,0x00,0x40,0x03,0x02,0x00,0x47,0x00,0x01,0x00, 0x01,0xc0,0x04,0xc0,0x08,0xc0,0x05,0x0a,0x71,0x75,0x65,0x72,0x79,0x0b,0x70,0x61, 0x72,0x61,0x6d,0x73,0x09,0x70,0x61,0x74,0x68,0x0e,0x61,0x75,0x74,0x68,0x6f,0x72, 0x69,0x74,0x79,0x0b,0x73,0x63,0x68,0x65,0x6d,0x65,0x0a,0x70,0x61,0x72,0x73,0x65, 0x0a,0x62,0x75,0x69,0x6c,0x64,0x10,0x62,0x61,0x73,0x65,0x5f,0x70,0x61,0x72,0x73, 0x65,0x64,0x0a,0x74,0x61,0x62,0x6c,0x65,0x09,0x74,0x79,0x70,0x65,0x2a,0x00,0x01, 0x04,0x02,0x01,0x00,0x06,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x2b,0x02,0x01, 0x00,0x10,0x03,0x00,0x00,0x3e,0x01,0x03,0x01,0x47,0x00,0x01,0x00,0x01,0x00,0x01, 0xc0,0x0b,0x69,0x6e,0x73,0x65,0x72,0x74,0xec,0x01,0x01,0x01,0x08,0x03,0x09,0x00, 0x2a,0x32,0x01,0x00,0x00,0x0e,0x00,0x00,0x00,0x54,0x02,0x01,0x80,0x25,0x00,0x00, 0x00,0x2b,0x02,0x00,0x00,0x37,0x02,0x01,0x02,0x10,0x03,0x00,0x00,0x25,0x04,0x02, 0x00,0x31,0x05,0x03,0x00,0x3e,0x02,0x04,0x01,0x27,0x02,0x01,0x00,0x13,0x03,0x01, 0x00,0x27,0x04,0x01,0x00,0x49,0x02,0x06,0x80,0x2b,0x06,0x02,0x00,0x37,0x06,0x04, 0x06,0x36,0x07,0x05,0x01,0x3e,0x06,0x02,0x02,0x39,0x06,0x05,0x01,0x4b,0x02,0xfa, 0x7f,0x2b,0x02,0x00,0x00,0x37,0x02,0x05,0x02,0x10,0x03,0x00,0x00,0x27,0x04,0x01, 0x00,0x27,0x05,0x01,0x00,0x3e,0x02,0x04,0x02,0x07,0x02,0x06,0x00,0x54,0x02,0x02, 0x80,0x27,0x02,0x01,0x00,0x3a,0x02,0x07,0x01,0x2b,0x02,0x00,0x00,0x37,0x02,0x05, 0x02,0x10,0x03,0x00,0x00,0x27,0x04,0xff,0xff,0x27,0x05,0xff,0xff,0x3e,0x02,0x04, 0x02,0x07,0x02,0x06,0x00,0x54,0x02,0x02,0x80,0x27,0x02,0x01,0x00,0x3a,0x02,0x08, 0x01,0x30,0x00,0x00,0x80,0x48,0x01,0x02,0x00,0x00,0xc0,0x02,0xc0,0x04,0xc0,0x11, 0x69,0x73,0x5f,0x64,0x69,0x72,0x65,0x63,0x74,0x6f,0x72,0x79,0x10,0x69,0x73,0x5f, 0x61,0x62,0x73,0x6f,0x6c,0x75,0x74,0x65,0x06,0x2f,0x08,0x73,0x75,0x62,0x0d,0x75, 0x6e,0x65,0x73,0x63,0x61,0x70,0x65,0x00,0x0c,0x28,0x5b,0x5e,0x2f,0x5d,0x2b,0x29, 0x09,0x67,0x73,0x75,0x62,0x05,0x9e,0x02,0x00,0x02,0x0b,0x01,0x04,0x01,0x3e,0x25, 0x02,0x00,0x00,0x13,0x03,0x00,0x00,0x0f,0x00,0x01,0x00,0x54,0x04,0x18,0x80,0x27, 0x04,0x01,0x00,0x15,0x05,0x00,0x03,0x27,0x06,0x01,0x00,0x49,0x04,0x07,0x80,0x10, 0x08,0x02,0x00,0x36,0x09,0x07,0x00,0x24,0x02,0x09,0x08,0x10,0x08,0x02,0x00,0x25, 0x09,0x01,0x00,0x24,0x02,0x09,0x08,0x4b,0x04,0xf9,0x7f,0x27,0x04,0x00,0x00,0x01, 0x04,0x03,0x00,0x54,0x04,0x25,0x80,0x10,0x04,0x02,0x00,0x36,0x05,0x03,0x00,0x24, 0x02,0x05,0x04,0x37,0x04,0x02,0x00,0x0f,0x00,0x04,0x00,0x54,0x05,0x1f,0x80,0x10, 0x04,0x02,0x00,0x25,0x05,0x01,0x00,0x24,0x02,0x05,0x04,0x54,0x04,0x1b,0x80,0x27, 0x04,0x01,0x00,0x15,0x05,0x00,0x03,0x27,0x06,0x01,0x00,0x49,0x04,0x09,0x80,0x10, 0x08,0x02,0x00,0x2b,0x09,0x00,0x00,0x36,0x0a,0x07,0x00,0x3e,0x09,0x02,0x02,0x24, 0x02,0x09,0x08,0x10,0x08,0x02,0x00,0x25,0x09,0x01,0x00,0x24,0x02,0x09,0x08,0x4b, 0x04,0xf7,0x7f,0x27,0x04,0x00,0x00,0x01,0x04,0x03,0x00,0x54,0x04,0x0b,0x80,0x10, 0x04,0x02,0x00,0x2b,0x05,0x00,0x00,0x36,0x06,0x03,0x00,0x3e,0x05,0x02,0x02,0x24, 0x02,0x05,0x04,0x37,0x04,0x02,0x00,0x0f,0x00,0x04,0x00,0x54,0x05,0x03,0x80,0x10, 0x04,0x02,0x00,0x25,0x05,0x01,0x00,0x24,0x02,0x05,0x04,0x37,0x04,0x03,0x00,0x0f, 0x00,0x04,0x00,0x54,0x05,0x03,0x80,0x25,0x04,0x01,0x00,0x10,0x05,0x02,0x00,0x24, 0x02,0x05,0x04,0x48,0x02,0x02,0x00,0x07,0xc0,0x10,0x69,0x73,0x5f,0x61,0x62,0x73, 0x6f,0x6c,0x75,0x74,0x65,0x11,0x69,0x73,0x5f,0x64,0x69,0x72,0x65,0x63,0x74,0x6f, 0x72,0x79,0x06,0x2f,0x05,0x02,0xba,0x02,0x03,0x00,0x0a,0x00,0x1a,0x00,0x25,0x34, 0x00,0x00,0x00,0x25,0x01,0x01,0x00,0x3e,0x00,0x02,0x02,0x34,0x01,0x02,0x00,0x34, 0x02,0x00,0x00,0x25,0x03,0x03,0x00,0x3e,0x02,0x02,0x02,0x34,0x03,0x00,0x00,0x25, 0x04,0x04,0x00,0x3e,0x03,0x02,0x02,0x32,0x04,0x00,0x00,0x3a,0x04,0x05,0x03,0x37, 0x04,0x05,0x03,0x25,0x05,0x07,0x00,0x3a,0x05,0x06,0x04,0x31,0x05,0x09,0x00,0x3a, 0x05,0x08,0x04,0x31,0x05,0x0a,0x00,0x10,0x06,0x05,0x00,0x33,0x07,0x0b,0x00,0x3e, 0x06,0x02,0x02,0x31,0x07,0x0c,0x00,0x31,0x08,0x0e,0x00,0x3a,0x08,0x0d,0x04,0x31, 0x08,0x0f,0x00,0x31,0x09,0x11,0x00,0x3a,0x09,0x10,0x04,0x31,0x09,0x13,0x00,0x3a, 0x09,0x12,0x04,0x31,0x09,0x15,0x00,0x3a,0x09,0x14,0x04,0x31,0x09,0x17,0x00,0x3a, 0x09,0x16,0x04,0x31,0x09,0x19,0x00,0x3a,0x09,0x18,0x04,0x30,0x00,0x00,0x80,0x48, 0x04,0x02,0x00,0x00,0x0f,0x62,0x75,0x69,0x6c,0x64,0x5f,0x70,0x61,0x74,0x68,0x00, 0x0f,0x70,0x61,0x72,0x73,0x65,0x5f,0x70,0x61,0x74,0x68,0x00,0x0d,0x61,0x62,0x73, 0x6f,0x6c,0x75,0x74,0x65,0x00,0x0a,0x62,0x75,0x69,0x6c,0x64,0x00,0x0a,0x70,0x61, 0x72,0x73,0x65,0x00,0x00,0x0d,0x75,0x6e,0x65,0x73,0x63,0x61,0x70,0x65,0x00,0x01, 0x11,0x00,0x00,0x06,0x2d,0x06,0x5f,0x06,0x2e,0x06,0x21,0x06,0x7e,0x06,0x2a,0x06, 0x27,0x06,0x28,0x06,0x29,0x06,0x3a,0x06,0x40,0x06,0x26,0x06,0x3d,0x06,0x2b,0x06, 0x24,0x06,0x2c,0x00,0x00,0x0b,0x65,0x73,0x63,0x61,0x70,0x65,0x0e,0x55,0x52,0x4c, 0x20,0x31,0x2e,0x30,0x2e,0x33,0x0d,0x5f,0x56,0x45,0x52,0x53,0x49,0x4f,0x4e,0x08, 0x75,0x72,0x6c,0x0b,0x73,0x6f,0x63,0x6b,0x65,0x74,0x0a,0x74,0x61,0x62,0x6c,0x65, 0x07,0x5f,0x47,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0x0c,0x72,0x65,0x71,0x75,0x69, 0x72,0x65,0x00, }; /* socket, socket.lua */ static const char lua_m_socket[] = { 0x1b,0x4c,0x4a,0x01,0x02,0x36,0x00,0x04,0x0a,0x01,0x02,0x00,0x08,0x2b,0x04,0x00, 0x00,0x37,0x04,0x00,0x04,0x10,0x05,0x00,0x00,0x10,0x06,0x01,0x00,0x10,0x07,0x02, 0x00,0x10,0x08,0x03,0x00,0x25,0x09,0x01,0x00,0x40,0x04,0x06,0x00,0x03,0xc0,0x09, 0x69,0x6e,0x65,0x74,0x0c,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x37,0x00,0x04,0x0a, 0x01,0x02,0x00,0x08,0x2b,0x04,0x00,0x00,0x37,0x04,0x00,0x04,0x10,0x05,0x00,0x00, 0x10,0x06,0x01,0x00,0x10,0x07,0x02,0x00,0x10,0x08,0x03,0x00,0x25,0x09,0x01,0x00, 0x40,0x04,0x06,0x00,0x03,0xc0,0x0a,0x69,0x6e,0x65,0x74,0x36,0x0c,0x63,0x6f,0x6e, 0x6e,0x65,0x63,0x74,0xab,0x03,0x00,0x03,0x10,0x02,0x10,0x00,0x4b,0x07,0x00,0x00, 0x00,0x54,0x03,0x01,0x80,0x25,0x00,0x01,0x00,0x2b,0x03,0x00,0x00,0x37,0x03,0x02, 0x03,0x37,0x03,0x03,0x03,0x10,0x04,0x00,0x00,0x3e,0x03,0x02,0x03,0x0e,0x00,0x03, 0x00,0x54,0x05,0x03,0x80,0x29,0x05,0x00,0x00,0x10,0x06,0x04,0x00,0x46,0x05,0x03, 0x00,0x2a,0x05,0x06,0x00,0x25,0x04,0x04,0x00,0x2b,0x07,0x01,0x00,0x37,0x07,0x05, 0x07,0x10,0x08,0x03,0x00,0x3e,0x07,0x02,0x04,0x54,0x0a,0x32,0x80,0x37,0x0c,0x06, 0x0b,0x07,0x0c,0x07,0x00,0x54,0x0c,0x06,0x80,0x2b,0x0c,0x00,0x00,0x37,0x0c,0x08, 0x0c,0x3e,0x0c,0x01,0x03,0x10,0x04,0x0d,0x00,0x10,0x05,0x0c,0x00,0x54,0x0c,0x05, 0x80,0x2b,0x0c,0x00,0x00,0x37,0x0c,0x09,0x0c,0x3e,0x0c,0x01,0x03,0x10,0x04,0x0d, 0x00,0x10,0x05,0x0c,0x00,0x0e,0x00,0x05,0x00,0x54,0x0c,0x03,0x80,0x29,0x0c,0x00, 0x00,0x10,0x0d,0x04,0x00,0x46,0x0c,0x03,0x00,0x10,0x0d,0x05,0x00,0x37,0x0c,0x0a, 0x05,0x25,0x0e,0x0b,0x00,0x29,0x0f,0x02,0x00,0x3e,0x0c,0x04,0x01,0x10,0x0d,0x05, 0x00,0x37,0x0c,0x0c,0x05,0x37,0x0e,0x0d,0x0b,0x10,0x0f,0x01,0x00,0x3e,0x0c,0x04, 0x03,0x10,0x04,0x0d,0x00,0x10,0x06,0x0c,0x00,0x0e,0x00,0x06,0x00,0x54,0x0c,0x04, 0x80,0x10,0x0d,0x05,0x00,0x37,0x0c,0x0e,0x05,0x3e,0x0c,0x02,0x01,0x54,0x0c,0x0d, 0x80,0x10,0x0d,0x05,0x00,0x37,0x0c,0x0f,0x05,0x10,0x0e,0x02,0x00,0x3e,0x0c,0x03, 0x03,0x10,0x04,0x0d,0x00,0x10,0x06,0x0c,0x00,0x0e,0x00,0x06,0x00,0x54,0x0c,0x04, 0x80,0x10,0x0d,0x05,0x00,0x37,0x0c,0x0e,0x05,0x3e,0x0c,0x02,0x01,0x54,0x0c,0x01, 0x80,0x48,0x05,0x02,0x00,0x41,0x0a,0x03,0x03,0x4e,0x0a,0xcc,0x7f,0x29,0x07,0x00, 0x00,0x10,0x08,0x04,0x00,0x46,0x07,0x03,0x00,0x03,0xc0,0x00,0xc0,0x0b,0x6c,0x69, 0x73,0x74,0x65,0x6e,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x09,0x61,0x64,0x64,0x72,0x09, 0x62,0x69,0x6e,0x64,0x0e,0x72,0x65,0x75,0x73,0x65,0x61,0x64,0x64,0x72,0x0e,0x73, 0x65,0x74,0x6f,0x70,0x74,0x69,0x6f,0x6e,0x09,0x74,0x63,0x70,0x36,0x08,0x74,0x63, 0x70,0x09,0x69,0x6e,0x65,0x74,0x0b,0x66,0x61,0x6d,0x69,0x6c,0x79,0x0b,0x69,0x70, 0x61,0x69,0x72,0x73,0x17,0x6e,0x6f,0x20,0x69,0x6e,0x66,0x6f,0x20,0x6f,0x6e,0x20, 0x61,0x64,0x64,0x72,0x65,0x73,0x73,0x10,0x67,0x65,0x74,0x61,0x64,0x64,0x72,0x69, 0x6e,0x66,0x6f,0x08,0x64,0x6e,0x73,0x0c,0x30,0x2e,0x30,0x2e,0x30,0x2e,0x30,0x06, 0x2a,0xce,0x01,0x00,0x03,0x08,0x02,0x08,0x00,0x23,0x2b,0x03,0x00,0x00,0x37,0x03, 0x00,0x03,0x10,0x04,0x00,0x00,0x3e,0x03,0x02,0x02,0x06,0x03,0x01,0x00,0x54,0x03, 0x05,0x80,0x25,0x03,0x02,0x00,0x10,0x04,0x00,0x00,0x10,0x02,0x01,0x00,0x10,0x01, 0x04,0x00,0x10,0x00,0x03,0x00,0x2b,0x03,0x01,0x00,0x0c,0x04,0x00,0x00,0x54,0x04, 0x01,0x80,0x25,0x04,0x03,0x00,0x36,0x03,0x04,0x03,0x0e,0x00,0x03,0x00,0x54,0x04, 0x0c,0x80,0x2b,0x04,0x00,0x00,0x37,0x04,0x04,0x04,0x25,0x05,0x05,0x00,0x2b,0x06, 0x00,0x00,0x37,0x06,0x06,0x06,0x10,0x07,0x00,0x00,0x3e,0x06,0x02,0x02,0x25,0x07, 0x07,0x00,0x24,0x05,0x07,0x05,0x27,0x06,0x03,0x00,0x3e,0x04,0x03,0x01,0x54,0x04, 0x04,0x80,0x10,0x04,0x03,0x00,0x10,0x05,0x01,0x00,0x10,0x06,0x02,0x00,0x40,0x04, 0x03,0x00,0x47,0x00,0x01,0x00,0x00,0x00,0x00,0xc0,0x06,0x29,0x0d,0x74,0x6f,0x73, 0x74,0x72,0x69,0x6e,0x67,0x12,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x6e,0x20,0x6b,0x65, 0x79,0x20,0x28,0x0a,0x65,0x72,0x72,0x6f,0x72,0x08,0x6e,0x69,0x6c,0x0c,0x64,0x65, 0x66,0x61,0x75,0x6c,0x74,0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0x09,0x74,0x79,0x70, 0x65,0x16,0x01,0x01,0x02,0x01,0x01,0x00,0x03,0x31,0x01,0x00,0x00,0x30,0x00,0x00, 0x80,0x48,0x01,0x02,0x00,0x00,0xc0,0x00,0x1f,0x00,0x00,0x02,0x01,0x01,0x00,0x04, 0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00,0x02,0x00, 0x00,0xc0,0x0a,0x67,0x65,0x74,0x66,0x64,0x1f,0x00,0x00,0x02,0x01,0x01,0x00,0x04, 0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00,0x02,0x00, 0x00,0xc0,0x0a,0x64,0x69,0x72,0x74,0x79,0x50,0x00,0x03,0x06,0x01,0x02,0x00,0x0f, 0x0e,0x00,0x01,0x00,0x54,0x03,0x07,0x80,0x2b,0x03,0x00,0x00,0x10,0x04,0x03,0x00, 0x37,0x03,0x00,0x03,0x3e,0x03,0x02,0x01,0x27,0x03,0x01,0x00,0x48,0x03,0x02,0x00, 0x54,0x03,0x05,0x80,0x2b,0x03,0x00,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x01,0x03, 0x10,0x05,0x01,0x00,0x40,0x03,0x03,0x00,0x47,0x00,0x01,0x00,0x00,0xc0,0x09,0x73, 0x65,0x6e,0x64,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x62,0x01,0x01,0x05,0x01,0x09,0x00, 0x0c,0x2b,0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x33,0x02,0x02,0x00,0x31,0x03,0x01, 0x00,0x3a,0x03,0x03,0x02,0x31,0x03,0x04,0x00,0x3a,0x03,0x05,0x02,0x33,0x03,0x07, 0x00,0x31,0x04,0x06,0x00,0x3a,0x04,0x08,0x03,0x30,0x00,0x00,0x80,0x40,0x01,0x03, 0x00,0x00,0xc0,0x0b,0x5f,0x5f,0x63,0x61,0x6c,0x6c,0x01,0x00,0x00,0x00,0x0a,0x64, 0x69,0x72,0x74,0x79,0x00,0x0a,0x67,0x65,0x74,0x66,0x64,0x01,0x00,0x00,0x00,0x11, 0x73,0x65,0x74,0x6d,0x65,0x74,0x61,0x74,0x61,0x62,0x6c,0x65,0x1f,0x00,0x00,0x02, 0x01,0x01,0x00,0x04,0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00, 0x40,0x00,0x02,0x00,0x00,0xc0,0x0a,0x67,0x65,0x74,0x66,0x64,0x1f,0x00,0x00,0x02, 0x01,0x01,0x00,0x04,0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00, 0x40,0x00,0x02,0x00,0x00,0xc0,0x0a,0x64,0x69,0x72,0x74,0x79,0x3a,0x00,0x03,0x06, 0x01,0x01,0x00,0x0b,0x0f,0x00,0x01,0x00,0x54,0x03,0x06,0x80,0x2b,0x03,0x00,0x00, 0x10,0x04,0x03,0x00,0x37,0x03,0x00,0x03,0x10,0x05,0x01,0x00,0x40,0x03,0x03,0x00, 0x54,0x03,0x02,0x80,0x27,0x03,0x01,0x00,0x48,0x03,0x02,0x00,0x47,0x00,0x01,0x00, 0x00,0xc0,0x09,0x73,0x65,0x6e,0x64,0x62,0x01,0x01,0x05,0x01,0x09,0x00,0x0c,0x2b, 0x01,0x00,0x00,0x37,0x01,0x00,0x01,0x33,0x02,0x02,0x00,0x31,0x03,0x01,0x00,0x3a, 0x03,0x03,0x02,0x31,0x03,0x04,0x00,0x3a,0x03,0x05,0x02,0x33,0x03,0x07,0x00,0x31, 0x04,0x06,0x00,0x3a,0x04,0x08,0x03,0x30,0x00,0x00,0x80,0x40,0x01,0x03,0x00,0x00, 0xc0,0x0b,0x5f,0x5f,0x63,0x61,0x6c,0x6c,0x01,0x00,0x00,0x00,0x0a,0x64,0x69,0x72, 0x74,0x79,0x00,0x0a,0x67,0x65,0x74,0x66,0x64,0x01,0x00,0x00,0x00,0x11,0x73,0x65, 0x74,0x6d,0x65,0x74,0x61,0x74,0x61,0x62,0x6c,0x65,0x1f,0x00,0x00,0x02,0x01,0x01, 0x00,0x04,0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00, 0x02,0x00,0x00,0xc0,0x0a,0x67,0x65,0x74,0x66,0x64,0x1f,0x00,0x00,0x02,0x01,0x01, 0x00,0x04,0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00, 0x02,0x00,0x00,0xc0,0x0a,0x64,0x69,0x72,0x74,0x79,0xa3,0x01,0x00,0x00,0x06,0x05, 0x04,0x00,0x1e,0x2b,0x00,0x00,0x00,0x27,0x01,0x00,0x00,0x03,0x00,0x01,0x00,0x54, 0x00,0x02,0x80,0x29,0x00,0x00,0x00,0x48,0x00,0x02,0x00,0x2b,0x00,0x01,0x00,0x37, 0x00,0x00,0x00,0x2b,0x01,0x02,0x00,0x37,0x01,0x01,0x01,0x2b,0x02,0x00,0x00,0x3e, 0x00,0x03,0x02,0x2b,0x01,0x03,0x00,0x10,0x02,0x01,0x00,0x37,0x01,0x02,0x01,0x10, 0x03,0x00,0x00,0x3e,0x01,0x03,0x03,0x0f,0x00,0x02,0x00,0x54,0x03,0x03,0x80,0x29, 0x03,0x00,0x00,0x10,0x04,0x02,0x00,0x46,0x03,0x03,0x00,0x2b,0x03,0x00,0x00,0x2b, 0x04,0x04,0x00,0x37,0x04,0x03,0x04,0x10,0x05,0x01,0x00,0x3e,0x04,0x02,0x02,0x1f, 0x03,0x04,0x03,0x2c,0x00,0x03,0x00,0x48,0x01,0x02,0x00,0x01,0x80,0x01,0x00,0x02, 0x00,0x00,0xc0,0x03,0x00,0x08,0x6c,0x65,0x6e,0x0c,0x72,0x65,0x63,0x65,0x69,0x76, 0x65,0x0e,0x42,0x4c,0x4f,0x43,0x4b,0x53,0x49,0x5a,0x45,0x08,0x6d,0x69,0x6e,0x68, 0x01,0x02,0x06,0x04,0x09,0x00,0x0c,0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02,0x33, 0x03,0x02,0x00,0x31,0x04,0x01,0x00,0x3a,0x04,0x03,0x03,0x31,0x04,0x04,0x00,0x3a, 0x04,0x05,0x03,0x33,0x04,0x07,0x00,0x31,0x05,0x06,0x00,0x3a,0x05,0x08,0x04,0x30, 0x00,0x00,0x80,0x40,0x02,0x03,0x00,0x00,0xc0,0x02,0xc0,0x03,0xc0,0x01,0xc0,0x0b, 0x5f,0x5f,0x63,0x61,0x6c,0x6c,0x01,0x00,0x00,0x00,0x0a,0x64,0x69,0x72,0x74,0x79, 0x00,0x0a,0x67,0x65,0x74,0x66,0x64,0x01,0x00,0x00,0x00,0x11,0x73,0x65,0x74,0x6d, 0x65,0x74,0x61,0x74,0x61,0x62,0x6c,0x65,0x1f,0x00,0x00,0x02,0x01,0x01,0x00,0x04, 0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00,0x02,0x00, 0x00,0xc0,0x0a,0x67,0x65,0x74,0x66,0x64,0x1f,0x00,0x00,0x02,0x01,0x01,0x00,0x04, 0x2b,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x40,0x00,0x02,0x00, 0x00,0xc0,0x0a,0x64,0x69,0x72,0x74,0x79,0x9d,0x01,0x00,0x00,0x05,0x03,0x04,0x01, 0x1c,0x2b,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,0x54,0x01,0x02,0x80,0x29,0x00,0x00, 0x00,0x48,0x00,0x02,0x00,0x2b,0x00,0x01,0x00,0x10,0x01,0x00,0x00,0x37,0x00,0x00, 0x00,0x2b,0x02,0x02,0x00,0x37,0x02,0x01,0x02,0x3e,0x00,0x03,0x04,0x0e,0x00,0x01, 0x00,0x54,0x03,0x02,0x80,0x48,0x00,0x02,0x00,0x54,0x03,0x0c,0x80,0x07,0x01,0x02, 0x00,0x54,0x03,0x07,0x80,0x2b,0x03,0x01,0x00,0x10,0x04,0x03,0x00,0x37,0x03,0x03, 0x03,0x3e,0x03,0x02,0x01,0x2e,0x00,0x00,0x00,0x48,0x02,0x02,0x00,0x54,0x03,0x03, 0x80,0x29,0x03,0x00,0x00,0x10,0x04,0x01,0x00,0x46,0x03,0x03,0x00,0x47,0x00,0x01, 0x00,0x01,0x80,0x00,0xc0,0x01,0x00,0x0a,0x63,0x6c,0x6f,0x73,0x65,0x0b,0x63,0x6c, 0x6f,0x73,0x65,0x64,0x0e,0x42,0x4c,0x4f,0x43,0x4b,0x53,0x49,0x5a,0x45,0x0c,0x72, 0x65,0x63,0x65,0x69,0x76,0x65,0x02,0x68,0x01,0x01,0x06,0x02,0x09,0x00,0x0d,0x29, 0x01,0x00,0x00,0x2b,0x02,0x00,0x00,0x37,0x02,0x00,0x02,0x33,0x03,0x02,0x00,0x31, 0x04,0x01,0x00,0x3a,0x04,0x03,0x03,0x31,0x04,0x04,0x00,0x3a,0x04,0x05,0x03,0x33, 0x04,0x07,0x00,0x31,0x05,0x06,0x00,0x3a,0x05,0x08,0x04,0x30,0x00,0x00,0x80,0x40, 0x02,0x03,0x00,0x00,0xc0,0x03,0xc0,0x0b,0x5f,0x5f,0x63,0x61,0x6c,0x6c,0x01,0x00, 0x00,0x00,0x0a,0x64,0x69,0x72,0x74,0x79,0x00,0x0a,0x67,0x65,0x74,0x66,0x64,0x01, 0x00,0x00,0x00,0x11,0x73,0x65,0x74,0x6d,0x65,0x74,0x61,0x74,0x61,0x62,0x6c,0x65, 0x80,0x03,0x03,0x00,0x09,0x00,0x1d,0x00,0x32,0x34,0x00,0x00,0x00,0x34,0x01,0x01, 0x00,0x25,0x02,0x02,0x00,0x3e,0x01,0x02,0x02,0x34,0x02,0x01,0x00,0x25,0x03,0x03, 0x00,0x3e,0x02,0x02,0x02,0x34,0x03,0x01,0x00,0x25,0x04,0x04,0x00,0x3e,0x03,0x02, 0x02,0x10,0x04,0x03,0x00,0x31,0x05,0x06,0x00,0x3a,0x05,0x05,0x04,0x31,0x05,0x08, 0x00,0x3a,0x05,0x07,0x04,0x31,0x05,0x0a,0x00,0x3a,0x05,0x09,0x04,0x37,0x05,0x0c, 0x04,0x3e,0x05,0x01,0x02,0x3a,0x05,0x0b,0x04,0x31,0x05,0x0e,0x00,0x3a,0x05,0x0d, 0x04,0x32,0x05,0x00,0x00,0x32,0x06,0x00,0x00,0x3a,0x05,0x0f,0x04,0x3a,0x06,0x10, 0x04,0x27,0x07,0x00,0x08,0x3a,0x07,0x11,0x04,0x31,0x07,0x13,0x00,0x3a,0x07,0x12, 0x06,0x31,0x07,0x15,0x00,0x3a,0x07,0x14,0x06,0x37,0x07,0x14,0x06,0x3a,0x07,0x16, 0x06,0x37,0x07,0x0d,0x04,0x10,0x08,0x06,0x00,0x3e,0x07,0x02,0x02,0x3a,0x07,0x17, 0x04,0x31,0x07,0x19,0x00,0x3a,0x07,0x18,0x05,0x31,0x07,0x1b,0x00,0x3a,0x07,0x1a, 0x05,0x37,0x07,0x1a,0x05,0x3a,0x07,0x16,0x05,0x37,0x07,0x0d,0x04,0x10,0x08,0x05, 0x00,0x3e,0x07,0x02,0x02,0x3a,0x07,0x1c,0x04,0x30,0x00,0x00,0x80,0x48,0x04,0x02, 0x00,0x0b,0x73,0x6f,0x75,0x72,0x63,0x65,0x00,0x11,0x75,0x6e,0x74,0x69,0x6c,0x2d, 0x63,0x6c,0x6f,0x73,0x65,0x64,0x00,0x0e,0x62,0x79,0x2d,0x6c,0x65,0x6e,0x67,0x74, 0x68,0x09,0x73,0x69,0x6e,0x6b,0x0c,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x00,0x0e, 0x6b,0x65,0x65,0x70,0x2d,0x6f,0x70,0x65,0x6e,0x00,0x14,0x63,0x6c,0x6f,0x73,0x65, 0x2d,0x77,0x68,0x65,0x6e,0x2d,0x64,0x6f,0x6e,0x65,0x0e,0x42,0x4c,0x4f,0x43,0x4b, 0x53,0x49,0x5a,0x45,0x0a,0x73,0x69,0x6e,0x6b,0x74,0x0c,0x73,0x6f,0x75,0x72,0x63, 0x65,0x74,0x00,0x0b,0x63,0x68,0x6f,0x6f,0x73,0x65,0x0b,0x6e,0x65,0x77,0x74,0x72, 0x79,0x08,0x74,0x72,0x79,0x00,0x09,0x62,0x69,0x6e,0x64,0x00,0x0d,0x63,0x6f,0x6e, 0x6e,0x65,0x63,0x74,0x36,0x00,0x0d,0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x34,0x10, 0x73,0x6f,0x63,0x6b,0x65,0x74,0x2e,0x63,0x6f,0x72,0x65,0x09,0x6d,0x61,0x74,0x68, 0x0b,0x73,0x74,0x72,0x69,0x6e,0x67,0x0c,0x72,0x65,0x71,0x75,0x69,0x72,0x65,0x07, 0x5f,0x47,0x00, }; int luaopen_lua_m_ltn12(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_ltn12, sizeof(lua_m_ltn12), "ltn12"); return 1; } int luaopen_lua_m_mime(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_mime, sizeof(lua_m_mime), "mime"); return 1; } int luaopen_lua_m_socket_ftp(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_socket_ftp, sizeof(lua_m_socket_ftp), "socket/ftp"); return 1; } int luaopen_lua_m_socket_headers(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_socket_headers, sizeof(lua_m_socket_headers), "socket/headers"); return 1; } int luaopen_lua_m_socket_http(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_socket_http, sizeof(lua_m_socket_http), "socket/http"); return 1; } int luaopen_lua_m_socket_mbox(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_socket_mbox, sizeof(lua_m_socket_mbox), "socket/mbox"); return 1; } int luaopen_lua_m_socket_smtp(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_socket_smtp, sizeof(lua_m_socket_smtp), "socket/smtp"); return 1; } int luaopen_lua_m_socket_tp(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_socket_tp, sizeof(lua_m_socket_tp), "socket/tp"); return 1; } int luaopen_lua_m_socket_url(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_socket_url, sizeof(lua_m_socket_url), "socket/url"); return 1; } int luaopen_lua_m_socket(lua_State *L) { luaL_loadbuffer(L, (const char*)lua_m_socket, sizeof(lua_m_socket), "socket"); return 1; } static luaL_Reg socket_scripts_modules[] = { {"ltn12", luaopen_lua_m_ltn12}, {"mime", luaopen_lua_m_mime}, {"socket.ftp", luaopen_lua_m_socket_ftp}, {"socket.headers", luaopen_lua_m_socket_headers}, {"socket.http", luaopen_lua_m_socket_http}, {"socket.mbox", luaopen_lua_m_socket_mbox}, {"socket.smtp", luaopen_lua_m_socket_smtp}, {"socket.tp", luaopen_lua_m_socket_tp}, {"socket.url", luaopen_lua_m_socket_url}, {"socket", luaopen_lua_m_socket}, {NULL, NULL} }; void luaopen_socket_scripts(lua_State* L) { luaL_Reg* lib = socket_scripts_modules; lua_getglobal(L, "package"); lua_getfield(L, -1, "preload"); for (; lib->func; lib++) { lib->func(L); lua_setfield(L, -2, lib->name); } lua_pop(L, 2); } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/socket_scripts.h ================================================ /* socket_scripts.h */ #ifndef __LUA_MODULES_E58C07CB2FBAF5B178B7E1836DC22849_H_ #define __LUA_MODULES_E58C07CB2FBAF5B178B7E1836DC22849_H_ #if __cplusplus extern "C" { #endif #include "lua.h" void luaopen_socket_scripts(lua_State* L); /* int luaopen_lua_m_ltn12(lua_State* L); int luaopen_lua_m_mime(lua_State* L); int luaopen_lua_m_socket_ftp(lua_State* L); int luaopen_lua_m_socket_headers(lua_State* L); int luaopen_lua_m_socket_http(lua_State* L); int luaopen_lua_m_socket_mbox(lua_State* L); int luaopen_lua_m_socket_smtp(lua_State* L); int luaopen_lua_m_socket_tp(lua_State* L); int luaopen_lua_m_socket_url(lua_State* L); int luaopen_lua_m_socket(lua_State* L); */ #if __cplusplus } #endif #endif /* __LUA_MODULES_E58C07CB2FBAF5B178B7E1836DC22849_H_ */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/tcp.c ================================================ /*=========================================================================*\ * TCP object * LuaSocket toolkit \*=========================================================================*/ #include #include "lua.h" #include "lauxlib.h" #include "auxiliar.h" #include "socket.h" #include "inet.h" #include "options.h" #include "tcp.h" /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ static int global_create(lua_State *L); static int global_create6(lua_State *L); static int global_connect(lua_State *L); static int meth_connect(lua_State *L); static int meth_listen(lua_State *L); static int meth_getfamily(lua_State *L); static int meth_bind(lua_State *L); static int meth_send(lua_State *L); static int meth_getstats(lua_State *L); static int meth_setstats(lua_State *L); static int meth_getsockname(lua_State *L); static int meth_getpeername(lua_State *L); static int meth_shutdown(lua_State *L); static int meth_receive(lua_State *L); static int meth_accept(lua_State *L); static int meth_close(lua_State *L); static int meth_getoption(lua_State *L); static int meth_setoption(lua_State *L); static int meth_settimeout(lua_State *L); static int meth_getfd(lua_State *L); static int meth_setfd(lua_State *L); static int meth_dirty(lua_State *L); /* tcp object methods */ static luaL_Reg tcp_methods[] = { {"__gc", meth_close}, {"__tostring", auxiliar_tostring}, {"accept", meth_accept}, {"bind", meth_bind}, {"close", meth_close}, {"connect", meth_connect}, {"dirty", meth_dirty}, {"getfamily", meth_getfamily}, {"getfd", meth_getfd}, {"getoption", meth_getoption}, {"getpeername", meth_getpeername}, {"getsockname", meth_getsockname}, {"getstats", meth_getstats}, {"setstats", meth_setstats}, {"listen", meth_listen}, {"receive", meth_receive}, {"send", meth_send}, {"setfd", meth_setfd}, {"setoption", meth_setoption}, {"setpeername", meth_connect}, {"setsockname", meth_bind}, {"settimeout", meth_settimeout}, {"shutdown", meth_shutdown}, {NULL, NULL} }; /* socket option handlers */ static t_opt optget[] = { {"keepalive", opt_get_keepalive}, {"reuseaddr", opt_get_reuseaddr}, {"tcp-nodelay", opt_get_tcp_nodelay}, {"linger", opt_get_linger}, {NULL, NULL} }; static t_opt optset[] = { {"keepalive", opt_set_keepalive}, {"reuseaddr", opt_set_reuseaddr}, {"tcp-nodelay", opt_set_tcp_nodelay}, {"ipv6-v6only", opt_set_ip6_v6only}, {"linger", opt_set_linger}, {NULL, NULL} }; /* functions in library namespace */ static luaL_Reg func[] = { {"tcp", global_create}, {"tcp6", global_create6}, {"connect", global_connect}, {NULL, NULL} }; /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int tcp_open(lua_State *L) { /* create classes */ auxiliar_newclass(L, "tcp{master}", tcp_methods); auxiliar_newclass(L, "tcp{client}", tcp_methods); auxiliar_newclass(L, "tcp{server}", tcp_methods); /* create class groups */ auxiliar_add2group(L, "tcp{master}", "tcp{any}"); auxiliar_add2group(L, "tcp{client}", "tcp{any}"); auxiliar_add2group(L, "tcp{server}", "tcp{any}"); /* define library functions */ luaL_openlib(L, NULL, func, 0); return 0; } /*=========================================================================*\ * Lua methods \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Just call buffered IO methods \*-------------------------------------------------------------------------*/ static int meth_send(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); return buffer_meth_send(L, &tcp->buf); } static int meth_receive(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); return buffer_meth_receive(L, &tcp->buf); } static int meth_getstats(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); return buffer_meth_getstats(L, &tcp->buf); } static int meth_setstats(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); return buffer_meth_setstats(L, &tcp->buf); } /*-------------------------------------------------------------------------*\ * Just call option handler \*-------------------------------------------------------------------------*/ static int meth_getoption(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); return opt_meth_getoption(L, optget, &tcp->sock); } static int meth_setoption(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); return opt_meth_setoption(L, optset, &tcp->sock); } /*-------------------------------------------------------------------------*\ * Select support methods \*-------------------------------------------------------------------------*/ static int meth_getfd(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); lua_pushnumber(L, (int) tcp->sock); return 1; } /* this is very dangerous, but can be handy for those that are brave enough */ static int meth_setfd(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); tcp->sock = (t_socket) luaL_checknumber(L, 2); return 0; } static int meth_dirty(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); lua_pushboolean(L, !buffer_isempty(&tcp->buf)); return 1; } /*-------------------------------------------------------------------------*\ * Waits for and returns a client object attempting connection to the * server object \*-------------------------------------------------------------------------*/ static int meth_accept(lua_State *L) { p_tcp server = (p_tcp) auxiliar_checkclass(L, "tcp{server}", 1); p_timeout tm = timeout_markstart(&server->tm); t_socket sock; const char *err = inet_tryaccept(&server->sock, server->family, &sock, tm); /* if successful, push client socket */ if (err == NULL) { p_tcp clnt = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); auxiliar_setclass(L, "tcp{client}", -1); /* initialize structure fields */ memset(clnt, 0, sizeof(t_tcp)); socket_setnonblocking(&sock); clnt->sock = sock; io_init(&clnt->io, (p_send) socket_send, (p_recv) socket_recv, (p_error) socket_ioerror, &clnt->sock); timeout_init(&clnt->tm, -1, -1); buffer_init(&clnt->buf, &clnt->io, &clnt->tm); clnt->family = server->family; return 1; } else { lua_pushnil(L); lua_pushstring(L, err); return 2; } } /*-------------------------------------------------------------------------*\ * Binds an object to an address \*-------------------------------------------------------------------------*/ static int meth_bind(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{master}", 1); const char *address = luaL_checkstring(L, 2); const char *port = luaL_checkstring(L, 3); const char *err; struct addrinfo bindhints; memset(&bindhints, 0, sizeof(bindhints)); bindhints.ai_socktype = SOCK_STREAM; bindhints.ai_family = tcp->family; bindhints.ai_flags = AI_PASSIVE; address = strcmp(address, "*")? address: NULL; err = inet_trybind(&tcp->sock, address, port, &bindhints); if (err) { lua_pushnil(L); lua_pushstring(L, err); return 2; } lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Turns a master tcp object into a client object. \*-------------------------------------------------------------------------*/ static int meth_connect(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); const char *address = luaL_checkstring(L, 2); const char *port = luaL_checkstring(L, 3); struct addrinfo connecthints; const char *err; memset(&connecthints, 0, sizeof(connecthints)); connecthints.ai_socktype = SOCK_STREAM; /* make sure we try to connect only to the same family */ connecthints.ai_family = tcp->family; timeout_markstart(&tcp->tm); err = inet_tryconnect(&tcp->sock, address, port, &tcp->tm, &connecthints); /* have to set the class even if it failed due to non-blocking connects */ auxiliar_setclass(L, "tcp{client}", 1); if (err) { lua_pushnil(L); lua_pushstring(L, err); return 2; } lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Closes socket used by object \*-------------------------------------------------------------------------*/ static int meth_close(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); socket_destroy(&tcp->sock); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Returns family as string \*-------------------------------------------------------------------------*/ static int meth_getfamily(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); if (tcp->family == PF_INET6) { lua_pushliteral(L, "inet6"); return 1; } else { lua_pushliteral(L, "inet4"); return 1; } } /*-------------------------------------------------------------------------*\ * Puts the sockt in listen mode \*-------------------------------------------------------------------------*/ static int meth_listen(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{master}", 1); int backlog = (int) luaL_optnumber(L, 2, 32); int err = socket_listen(&tcp->sock, backlog); if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, socket_strerror(err)); return 2; } /* turn master object into a server object */ auxiliar_setclass(L, "tcp{server}", 1); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Shuts the connection down partially \*-------------------------------------------------------------------------*/ static int meth_shutdown(lua_State *L) { /* SHUT_RD, SHUT_WR, SHUT_RDWR have the value 0, 1, 2, so we can use method index directly */ static const char* methods[] = { "receive", "send", "both", NULL }; p_tcp tcp = (p_tcp) auxiliar_checkclass(L, "tcp{client}", 1); int how = luaL_checkoption(L, 2, "both", methods); socket_shutdown(&tcp->sock, how); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Just call inet methods \*-------------------------------------------------------------------------*/ static int meth_getpeername(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); return inet_meth_getpeername(L, &tcp->sock, tcp->family); } static int meth_getsockname(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); return inet_meth_getsockname(L, &tcp->sock, tcp->family); } /*-------------------------------------------------------------------------*\ * Just call tm methods \*-------------------------------------------------------------------------*/ static int meth_settimeout(lua_State *L) { p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); return timeout_meth_settimeout(L, &tcp->tm); } /*=========================================================================*\ * Library functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Creates a master tcp object \*-------------------------------------------------------------------------*/ static int tcp_create(lua_State *L, int family) { t_socket sock; const char *err = inet_trycreate(&sock, family, SOCK_STREAM); /* try to allocate a system socket */ if (!err) { /* allocate tcp object */ p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); memset(tcp, 0, sizeof(t_tcp)); /* set its type as master object */ auxiliar_setclass(L, "tcp{master}", -1); /* initialize remaining structure fields */ socket_setnonblocking(&sock); if (family == PF_INET6) { int yes = 1; setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&yes, sizeof(yes)); } tcp->sock = sock; io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv, (p_error) socket_ioerror, &tcp->sock); timeout_init(&tcp->tm, -1, -1); buffer_init(&tcp->buf, &tcp->io, &tcp->tm); tcp->family = family; return 1; } else { lua_pushnil(L); lua_pushstring(L, err); return 2; } } static int global_create(lua_State *L) { return tcp_create(L, AF_INET); } static int global_create6(lua_State *L) { return tcp_create(L, AF_INET6); } static const char *tryconnect6(const char *remoteaddr, const char *remoteserv, struct addrinfo *connecthints, p_tcp tcp) { struct addrinfo *iterator = NULL, *resolved = NULL; const char *err = NULL; /* try resolving */ err = socket_gaistrerror(getaddrinfo(remoteaddr, remoteserv, connecthints, &resolved)); if (err != NULL) { if (resolved) freeaddrinfo(resolved); return err; } /* iterate over all returned addresses trying to connect */ for (iterator = resolved; iterator; iterator = iterator->ai_next) { p_timeout tm = timeout_markstart(&tcp->tm); /* create new socket if one wasn't created by the bind stage */ if (tcp->sock == SOCKET_INVALID) { err = socket_strerror(socket_create(&tcp->sock, iterator->ai_family, iterator->ai_socktype, iterator->ai_protocol)); if (err != NULL) { freeaddrinfo(resolved); return err; } tcp->family = iterator->ai_family; /* all sockets initially non-blocking */ socket_setnonblocking(&tcp->sock); } /* finally try connecting to remote address */ err = socket_strerror(socket_connect(&tcp->sock, (SA *) iterator->ai_addr, (socklen_t) iterator->ai_addrlen, tm)); /* if success, break out of loop */ if (err == NULL) break; } freeaddrinfo(resolved); /* here, if err is set, we failed */ return err; } static int global_connect(lua_State *L) { const char *remoteaddr = luaL_checkstring(L, 1); const char *remoteserv = luaL_checkstring(L, 2); const char *localaddr = luaL_optstring(L, 3, NULL); const char *localserv = luaL_optstring(L, 4, "0"); int family = inet_optfamily(L, 5, "unspec"); p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); struct addrinfo bindhints, connecthints; const char *err = NULL; /* initialize tcp structure */ memset(tcp, 0, sizeof(t_tcp)); io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv, (p_error) socket_ioerror, &tcp->sock); timeout_init(&tcp->tm, -1, -1); buffer_init(&tcp->buf, &tcp->io, &tcp->tm); tcp->sock = SOCKET_INVALID; /* allow user to pick local address and port */ memset(&bindhints, 0, sizeof(bindhints)); bindhints.ai_socktype = SOCK_STREAM; bindhints.ai_family = family; bindhints.ai_flags = AI_PASSIVE; if (localaddr) { err = inet_trybind(&tcp->sock, localaddr, localserv, &bindhints); if (err) { lua_pushnil(L); lua_pushstring(L, err); return 2; } tcp->family = bindhints.ai_family; } /* try to connect to remote address and port */ memset(&connecthints, 0, sizeof(connecthints)); connecthints.ai_socktype = SOCK_STREAM; /* make sure we try to connect only to the same family */ connecthints.ai_family = bindhints.ai_family; err = tryconnect6(remoteaddr, remoteserv, &connecthints, tcp); if (err) { socket_destroy(&tcp->sock); lua_pushnil(L); lua_pushstring(L, err); return 2; } auxiliar_setclass(L, "tcp{client}", -1); return 1; } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/tcp.h ================================================ #ifndef TCP_H #define TCP_H /*=========================================================================*\ * TCP object * LuaSocket toolkit * * The tcp.h module is basicly a glue that puts together modules buffer.h, * timeout.h socket.h and inet.h to provide the LuaSocket TCP (AF_INET, * SOCK_STREAM) support. * * Three classes are defined: master, client and server. The master class is * a newly created tcp object, that has not been bound or connected. Server * objects are tcp objects bound to some local address. Client objects are * tcp objects either connected to some address or returned by the accept * method of a server object. \*=========================================================================*/ #include "lua.h" #include "luasocket_buffer.h" #include "timeout.h" #include "socket.h" typedef struct t_tcp_ { t_socket sock; t_io io; t_buffer buf; t_timeout tm; int family; } t_tcp; typedef t_tcp *p_tcp; int tcp_open(lua_State *L); #endif /* TCP_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/timeout.c ================================================ /*=========================================================================*\ * Timeout management functions * LuaSocket toolkit \*=========================================================================*/ #include #include #include #include "lua.h" #include "lauxlib.h" #include "auxiliar.h" #include "timeout.h" #ifdef _WIN32 #include #else #include #include #endif /* min and max macros */ #ifndef MIN #define MIN(x, y) ((x) < (y) ? x : y) #endif #ifndef MAX #define MAX(x, y) ((x) > (y) ? x : y) #endif /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ static int timeout_lua_gettime(lua_State *L); static int timeout_lua_sleep(lua_State *L); static luaL_Reg func[] = { { "gettime", timeout_lua_gettime }, { "sleep", timeout_lua_sleep }, { NULL, NULL } }; /*=========================================================================*\ * Exported functions. \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Initialize structure \*-------------------------------------------------------------------------*/ void timeout_init(p_timeout tm, double block, double total) { tm->block = block; tm->total = total; } /*-------------------------------------------------------------------------*\ * Determines how much time we have left for the next system call, * if the previous call was successful * Input * tm: timeout control structure * Returns * the number of ms left or -1 if there is no time limit \*-------------------------------------------------------------------------*/ double timeout_get(p_timeout tm) { if (tm->block < 0.0 && tm->total < 0.0) { return -1; } else if (tm->block < 0.0) { double t = tm->total - timeout_gettime() + tm->start; return MAX(t, 0.0); } else if (tm->total < 0.0) { return tm->block; } else { double t = tm->total - timeout_gettime() + tm->start; return MIN(tm->block, MAX(t, 0.0)); } } /*-------------------------------------------------------------------------*\ * Returns time since start of operation * Input * tm: timeout control structure * Returns * start field of structure \*-------------------------------------------------------------------------*/ double timeout_getstart(p_timeout tm) { return tm->start; } /*-------------------------------------------------------------------------*\ * Determines how much time we have left for the next system call, * if the previous call was a failure * Input * tm: timeout control structure * Returns * the number of ms left or -1 if there is no time limit \*-------------------------------------------------------------------------*/ double timeout_getretry(p_timeout tm) { if (tm->block < 0.0 && tm->total < 0.0) { return -1; } else if (tm->block < 0.0) { double t = tm->total - timeout_gettime() + tm->start; return MAX(t, 0.0); } else if (tm->total < 0.0) { double t = tm->block - timeout_gettime() + tm->start; return MAX(t, 0.0); } else { double t = tm->total - timeout_gettime() + tm->start; return MIN(tm->block, MAX(t, 0.0)); } } /*-------------------------------------------------------------------------*\ * Marks the operation start time in structure * Input * tm: timeout control structure \*-------------------------------------------------------------------------*/ p_timeout timeout_markstart(p_timeout tm) { tm->start = timeout_gettime(); return tm; } /*-------------------------------------------------------------------------*\ * Gets time in s, relative to January 1, 1970 (UTC) * Returns * time in s. \*-------------------------------------------------------------------------*/ #ifdef _WIN32 double timeout_gettime(void) { FILETIME ft; double t; GetSystemTimeAsFileTime(&ft); /* Windows file time (time since January 1, 1601 (UTC)) */ t = ft.dwLowDateTime/1.0e7 + ft.dwHighDateTime*(4294967296.0/1.0e7); /* convert to Unix Epoch time (time since January 1, 1970 (UTC)) */ return (t - 11644473600.0); } #else double timeout_gettime(void) { struct timeval v; gettimeofday(&v, (struct timezone *) NULL); /* Unix Epoch time (time since January 1, 1970 (UTC)) */ return v.tv_sec + v.tv_usec/1.0e6; } #endif /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int timeout_open(lua_State *L) { luaL_openlib(L, NULL, func, 0); return 0; } /*-------------------------------------------------------------------------*\ * Sets timeout values for IO operations * Lua Input: base, time [, mode] * time: time out value in seconds * mode: "b" for block timeout, "t" for total timeout. (default: b) \*-------------------------------------------------------------------------*/ int timeout_meth_settimeout(lua_State *L, p_timeout tm) { double t = luaL_optnumber(L, 2, -1); const char *mode = luaL_optstring(L, 3, "b"); switch (*mode) { case 'b': tm->block = t; break; case 'r': case 't': tm->total = t; break; default: luaL_argcheck(L, 0, 3, "invalid timeout mode"); break; } lua_pushnumber(L, 1); return 1; } /*=========================================================================*\ * Test support functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Returns the time the system has been up, in secconds. \*-------------------------------------------------------------------------*/ static int timeout_lua_gettime(lua_State *L) { lua_pushnumber(L, timeout_gettime()); return 1; } /*-------------------------------------------------------------------------*\ * Sleep for n seconds. \*-------------------------------------------------------------------------*/ #ifdef _WIN32 int timeout_lua_sleep(lua_State *L) { double n = luaL_checknumber(L, 1); if (n < 0.0) n = 0.0; if (n < DBL_MAX/1000.0) n *= 1000.0; if (n > INT_MAX) n = INT_MAX; Sleep((int)n); return 0; } #else int timeout_lua_sleep(lua_State *L) { double n = luaL_checknumber(L, 1); struct timespec t, r; if (n < 0.0) n = 0.0; if (n > INT_MAX) n = INT_MAX; t.tv_sec = (int) n; n -= t.tv_sec; t.tv_nsec = (int) (n * 1000000000); if (t.tv_nsec >= 1000000000) t.tv_nsec = 999999999; while (nanosleep(&t, &r) != 0) { t.tv_sec = r.tv_sec; t.tv_nsec = r.tv_nsec; } return 0; } #endif ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/timeout.h ================================================ #ifndef TIMEOUT_H #define TIMEOUT_H /*=========================================================================*\ * Timeout management functions * LuaSocket toolkit \*=========================================================================*/ #include "lua.h" /* timeout control structure */ typedef struct t_timeout_ { double block; /* maximum time for blocking calls */ double total; /* total number of miliseconds for operation */ double start; /* time of start of operation */ } t_timeout; typedef t_timeout *p_timeout; int timeout_open(lua_State *L); void timeout_init(p_timeout tm, double block, double total); double timeout_get(p_timeout tm); double timeout_getretry(p_timeout tm); p_timeout timeout_markstart(p_timeout tm); double timeout_getstart(p_timeout tm); double timeout_gettime(void); int timeout_meth_settimeout(lua_State *L, p_timeout tm); #define timeout_iszero(tm) ((tm)->block == 0.0) #endif /* TIMEOUT_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/udp.c ================================================ /*=========================================================================*\ * UDP object * LuaSocket toolkit \*=========================================================================*/ #include #include "lua.h" #include "lauxlib.h" #include "auxiliar.h" #include "socket.h" #include "inet.h" #include "options.h" #include "udp.h" /* min and max macros */ #ifndef MIN #define MIN(x, y) ((x) < (y) ? x : y) #endif #ifndef MAX #define MAX(x, y) ((x) > (y) ? x : y) #endif /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ static int global_create(lua_State *L); static int global_create6(lua_State *L); static int meth_send(lua_State *L); static int meth_sendto(lua_State *L); static int meth_receive(lua_State *L); static int meth_receivefrom(lua_State *L); static int meth_getfamily(lua_State *L); static int meth_getsockname(lua_State *L); static int meth_getpeername(lua_State *L); static int meth_setsockname(lua_State *L); static int meth_setpeername(lua_State *L); static int meth_close(lua_State *L); static int meth_setoption(lua_State *L); static int meth_getoption(lua_State *L); static int meth_settimeout(lua_State *L); static int meth_getfd(lua_State *L); static int meth_setfd(lua_State *L); static int meth_dirty(lua_State *L); /* udp object methods */ static luaL_Reg udp_methods[] = { {"__gc", meth_close}, {"__tostring", auxiliar_tostring}, {"close", meth_close}, {"dirty", meth_dirty}, {"getfamily", meth_getfamily}, {"getfd", meth_getfd}, {"getpeername", meth_getpeername}, {"getsockname", meth_getsockname}, {"receive", meth_receive}, {"receivefrom", meth_receivefrom}, {"send", meth_send}, {"sendto", meth_sendto}, {"setfd", meth_setfd}, {"setoption", meth_setoption}, {"getoption", meth_getoption}, {"setpeername", meth_setpeername}, {"setsockname", meth_setsockname}, {"settimeout", meth_settimeout}, {NULL, NULL} }; /* socket options for setoption */ static t_opt optset[] = { {"dontroute", opt_set_dontroute}, {"broadcast", opt_set_broadcast}, {"reuseaddr", opt_set_reuseaddr}, {"reuseport", opt_set_reuseport}, {"ip-multicast-if", opt_set_ip_multicast_if}, {"ip-multicast-ttl", opt_set_ip_multicast_ttl}, {"ip-multicast-loop", opt_set_ip_multicast_loop}, {"ip-add-membership", opt_set_ip_add_membership}, {"ip-drop-membership", opt_set_ip_drop_membersip}, {"ipv6-v6only", opt_set_ip6_v6only}, {NULL, NULL} }; /* socket options for getoption */ static t_opt optget[] = { {"ip-multicast-if", opt_get_ip_multicast_if}, {"ip-multicast-loop", opt_get_ip_multicast_loop}, {NULL, NULL} }; /* functions in library namespace */ static luaL_Reg func[] = { {"udp", global_create}, {"udp6", global_create6}, {NULL, NULL} }; /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int udp_open(lua_State *L) { /* create classes */ auxiliar_newclass(L, "udp{connected}", udp_methods); auxiliar_newclass(L, "udp{unconnected}", udp_methods); /* create class groups */ auxiliar_add2group(L, "udp{connected}", "udp{any}"); auxiliar_add2group(L, "udp{unconnected}", "udp{any}"); auxiliar_add2group(L, "udp{connected}", "select{able}"); auxiliar_add2group(L, "udp{unconnected}", "select{able}"); /* define library functions */ luaL_openlib(L, NULL, func, 0); return 0; } /*=========================================================================*\ * Lua methods \*=========================================================================*/ const char *udp_strerror(int err) { /* a 'closed' error on an unconnected means the target address was not * accepted by the transport layer */ if (err == IO_CLOSED) return "refused"; else return socket_strerror(err); } /*-------------------------------------------------------------------------*\ * Send data through connected udp socket \*-------------------------------------------------------------------------*/ static int meth_send(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{connected}", 1); p_timeout tm = &udp->tm; size_t count, sent = 0; int err; const char *data = luaL_checklstring(L, 2, &count); timeout_markstart(tm); err = socket_send(&udp->sock, data, count, &sent, tm); if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, udp_strerror(err)); return 2; } lua_pushnumber(L, (lua_Number) sent); return 1; } /*-------------------------------------------------------------------------*\ * Send data through unconnected udp socket \*-------------------------------------------------------------------------*/ static int meth_sendto(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{unconnected}", 1); size_t count, sent = 0; const char *data = luaL_checklstring(L, 2, &count); const char *ip = luaL_checkstring(L, 3); unsigned short port = (unsigned short) luaL_checknumber(L, 4); p_timeout tm = &udp->tm; int err; switch (udp->family) { case PF_INET: { struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); if (!my_inet_pton(AF_INET, ip, &addr.sin_addr)) luaL_argerror(L, 3, "invalid ip address"); addr.sin_family = AF_INET; addr.sin_port = htons(port); timeout_markstart(tm); err = socket_sendto(&udp->sock, data, count, &sent, (SA *) &addr, sizeof(addr), tm); break; } case PF_INET6: { struct sockaddr_in6 addr; memset(&addr, 0, sizeof(addr)); if (!my_inet_pton(AF_INET6, ip, &addr.sin6_addr)) luaL_argerror(L, 3, "invalid ip address"); addr.sin6_family = AF_INET6; addr.sin6_port = htons(port); timeout_markstart(tm); err = socket_sendto(&udp->sock, data, count, &sent, (SA *) &addr, sizeof(addr), tm); break; } default: lua_pushnil(L); lua_pushfstring(L, "unknown family %d", udp->family); return 2; } if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, udp_strerror(err)); return 2; } lua_pushnumber(L, (lua_Number) sent); return 1; } /*-------------------------------------------------------------------------*\ * Receives data from a UDP socket \*-------------------------------------------------------------------------*/ static int meth_receive(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); char buffer[UDP_DATAGRAMSIZE]; size_t got, count = (size_t) luaL_optnumber(L, 2, sizeof(buffer)); int err; p_timeout tm = &udp->tm; count = MIN(count, sizeof(buffer)); timeout_markstart(tm); err = socket_recv(&udp->sock, buffer, count, &got, tm); /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */ if (err == IO_CLOSED) err = IO_DONE; if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, udp_strerror(err)); return 2; } lua_pushlstring(L, buffer, got); return 1; } /*-------------------------------------------------------------------------*\ * Receives data and sender from a UDP socket \*-------------------------------------------------------------------------*/ static int meth_receivefrom(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{unconnected}", 1); char buffer[UDP_DATAGRAMSIZE]; size_t got, count = (size_t) luaL_optnumber(L, 2, sizeof(buffer)); int err; p_timeout tm = &udp->tm; timeout_markstart(tm); count = MIN(count, sizeof(buffer)); switch (udp->family) { case PF_INET: { struct sockaddr_in addr; socklen_t addr_len = sizeof(addr); err = socket_recvfrom(&udp->sock, buffer, count, &got, (SA *) &addr, &addr_len, tm); /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */ if (err == IO_CLOSED) err = IO_DONE; if (err == IO_DONE) { char addrstr[INET_ADDRSTRLEN]; lua_pushlstring(L, buffer, got); if (!my_inet_ntop(AF_INET, &addr.sin_addr, addrstr, sizeof(addrstr))) { lua_pushnil(L); lua_pushstring(L, "invalid source address"); return 2; } lua_pushstring(L, addrstr); lua_pushnumber(L, ntohs(addr.sin_port)); return 3; } break; } case PF_INET6: { struct sockaddr_in6 addr; socklen_t addr_len = sizeof(addr); err = socket_recvfrom(&udp->sock, buffer, count, &got, (SA *) &addr, &addr_len, tm); /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */ if (err == IO_CLOSED) err = IO_DONE; if (err == IO_DONE) { char addrstr[INET6_ADDRSTRLEN]; lua_pushlstring(L, buffer, got); if (!my_inet_ntop(AF_INET6, &addr.sin6_addr, addrstr, sizeof(addrstr))) { lua_pushnil(L); lua_pushstring(L, "invalid source address"); return 2; } lua_pushstring(L, addrstr); lua_pushnumber(L, ntohs(addr.sin6_port)); return 3; } break; } default: lua_pushnil(L); lua_pushfstring(L, "unknown family %d", udp->family); return 2; } lua_pushnil(L); lua_pushstring(L, udp_strerror(err)); return 2; } /*-------------------------------------------------------------------------*\ * Returns family as string \*-------------------------------------------------------------------------*/ static int meth_getfamily(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); if (udp->family == PF_INET6) { lua_pushliteral(L, "inet6"); return 1; } else { lua_pushliteral(L, "inet4"); return 1; } } /*-------------------------------------------------------------------------*\ * Select support methods \*-------------------------------------------------------------------------*/ static int meth_getfd(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); lua_pushnumber(L, (int) udp->sock); return 1; } /* this is very dangerous, but can be handy for those that are brave enough */ static int meth_setfd(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); udp->sock = (t_socket) luaL_checknumber(L, 2); return 0; } static int meth_dirty(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); (void) udp; lua_pushboolean(L, 0); return 1; } /*-------------------------------------------------------------------------*\ * Just call inet methods \*-------------------------------------------------------------------------*/ static int meth_getpeername(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{connected}", 1); return inet_meth_getpeername(L, &udp->sock, udp->family); } static int meth_getsockname(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); return inet_meth_getsockname(L, &udp->sock, udp->family); } /*-------------------------------------------------------------------------*\ * Just call option handler \*-------------------------------------------------------------------------*/ static int meth_setoption(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); return opt_meth_setoption(L, optset, &udp->sock); } /*-------------------------------------------------------------------------*\ * Just call option handler \*-------------------------------------------------------------------------*/ static int meth_getoption(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); return opt_meth_getoption(L, optget, &udp->sock); } /*-------------------------------------------------------------------------*\ * Just call tm methods \*-------------------------------------------------------------------------*/ static int meth_settimeout(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); return timeout_meth_settimeout(L, &udp->tm); } /*-------------------------------------------------------------------------*\ * Turns a master udp object into a client object. \*-------------------------------------------------------------------------*/ static int meth_setpeername(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); p_timeout tm = &udp->tm; const char *address = luaL_checkstring(L, 2); int connecting = strcmp(address, "*"); const char *port = connecting? luaL_checkstring(L, 3): "0"; struct addrinfo connecthints; const char *err; memset(&connecthints, 0, sizeof(connecthints)); connecthints.ai_socktype = SOCK_DGRAM; /* make sure we try to connect only to the same family */ connecthints.ai_family = udp->family; if (connecting) { err = inet_tryconnect(&udp->sock, address, port, tm, &connecthints); if (err) { lua_pushnil(L); lua_pushstring(L, err); return 2; } auxiliar_setclass(L, "udp{connected}", 1); } else { /* we ignore possible errors because Mac OS X always * returns EAFNOSUPPORT */ inet_trydisconnect(&udp->sock, udp->family, tm); auxiliar_setclass(L, "udp{unconnected}", 1); } /* change class to connected or unconnected depending on address */ lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Closes socket used by object \*-------------------------------------------------------------------------*/ static int meth_close(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1); socket_destroy(&udp->sock); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Turns a master object into a server object \*-------------------------------------------------------------------------*/ static int meth_setsockname(lua_State *L) { p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{unconnected}", 1); const char *address = luaL_checkstring(L, 2); const char *port = luaL_checkstring(L, 3); const char *err; struct addrinfo bindhints; memset(&bindhints, 0, sizeof(bindhints)); bindhints.ai_socktype = SOCK_DGRAM; bindhints.ai_family = udp->family; bindhints.ai_flags = AI_PASSIVE; err = inet_trybind(&udp->sock, address, port, &bindhints); if (err) { lua_pushnil(L); lua_pushstring(L, err); return 2; } lua_pushnumber(L, 1); return 1; } /*=========================================================================*\ * Library functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Creates a master udp object \*-------------------------------------------------------------------------*/ static int udp_create(lua_State *L, int family) { t_socket sock; const char *err = inet_trycreate(&sock, family, SOCK_DGRAM); /* try to allocate a system socket */ if (!err) { /* allocate udp object */ p_udp udp = (p_udp) lua_newuserdata(L, sizeof(t_udp)); auxiliar_setclass(L, "udp{unconnected}", -1); /* initialize remaining structure fields */ socket_setnonblocking(&sock); if (family == PF_INET6) { int yes = 1; setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&yes, sizeof(yes)); } udp->sock = sock; timeout_init(&udp->tm, -1, -1); udp->family = family; return 1; } else { lua_pushnil(L); lua_pushstring(L, err); return 2; } } static int global_create(lua_State *L) { return udp_create(L, AF_INET); } static int global_create6(lua_State *L) { return udp_create(L, AF_INET6); } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/udp.h ================================================ #ifndef UDP_H #define UDP_H /*=========================================================================*\ * UDP object * LuaSocket toolkit * * The udp.h module provides LuaSocket with support for UDP protocol * (AF_INET, SOCK_DGRAM). * * Two classes are defined: connected and unconnected. UDP objects are * originally unconnected. They can be "connected" to a given address * with a call to the setpeername function. The same function can be used to * break the connection. \*=========================================================================*/ #include "lua.h" #include "timeout.h" #include "socket.h" /* can't be larger than wsocket.c MAXCHUNK!!! */ #define UDP_DATAGRAMSIZE 8192 typedef struct t_udp_ { t_socket sock; t_timeout tm; int family; } t_udp; typedef t_udp *p_udp; int udp_open(lua_State *L); #endif /* UDP_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/unix.c ================================================ /*=========================================================================*\ * Unix domain socket * LuaSocket toolkit \*=========================================================================*/ #include #include "lua.h" #include "lauxlib.h" #include "auxiliar.h" #include "socket.h" #include "options.h" #include "unix.h" #include /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ static int global_create(lua_State *L); static int meth_connect(lua_State *L); static int meth_listen(lua_State *L); static int meth_bind(lua_State *L); static int meth_send(lua_State *L); static int meth_shutdown(lua_State *L); static int meth_receive(lua_State *L); static int meth_accept(lua_State *L); static int meth_close(lua_State *L); static int meth_setoption(lua_State *L); static int meth_settimeout(lua_State *L); static int meth_getfd(lua_State *L); static int meth_setfd(lua_State *L); static int meth_dirty(lua_State *L); static int meth_getstats(lua_State *L); static int meth_setstats(lua_State *L); static const char *unix_tryconnect(p_unix un, const char *path); static const char *unix_trybind(p_unix un, const char *path); /* unix object methods */ static luaL_Reg unix_methods[] = { {"__gc", meth_close}, {"__tostring", auxiliar_tostring}, {"accept", meth_accept}, {"bind", meth_bind}, {"close", meth_close}, {"connect", meth_connect}, {"dirty", meth_dirty}, {"getfd", meth_getfd}, {"getstats", meth_getstats}, {"setstats", meth_setstats}, {"listen", meth_listen}, {"receive", meth_receive}, {"send", meth_send}, {"setfd", meth_setfd}, {"setoption", meth_setoption}, {"setpeername", meth_connect}, {"setsockname", meth_bind}, {"settimeout", meth_settimeout}, {"shutdown", meth_shutdown}, {NULL, NULL} }; /* socket option handlers */ static t_opt optset[] = { {"keepalive", opt_set_keepalive}, {"reuseaddr", opt_set_reuseaddr}, {"linger", opt_set_linger}, {NULL, NULL} }; /* our socket creation function */ static luaL_Reg func[] = { {"unix", global_create}, {NULL, NULL} }; /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int luaopen_socket_unix(lua_State *L) { /* create classes */ auxiliar_newclass(L, "unix{master}", unix_methods); auxiliar_newclass(L, "unix{client}", unix_methods); auxiliar_newclass(L, "unix{server}", unix_methods); /* create class groups */ auxiliar_add2group(L, "unix{master}", "unix{any}"); auxiliar_add2group(L, "unix{client}", "unix{any}"); auxiliar_add2group(L, "unix{server}", "unix{any}"); /* make sure the function ends up in the package table */ luaL_openlib(L, "socket", func, 0); /* return the function instead of the 'socket' table */ lua_pushstring(L, "unix"); lua_gettable(L, -2); return 1; } /*=========================================================================*\ * Lua methods \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Just call buffered IO methods \*-------------------------------------------------------------------------*/ static int meth_send(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); return buffer_meth_send(L, &un->buf); } static int meth_receive(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); return buffer_meth_receive(L, &un->buf); } static int meth_getstats(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); return buffer_meth_getstats(L, &un->buf); } static int meth_setstats(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); return buffer_meth_setstats(L, &un->buf); } /*-------------------------------------------------------------------------*\ * Just call option handler \*-------------------------------------------------------------------------*/ static int meth_setoption(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); return opt_meth_setoption(L, optset, &un->sock); } /*-------------------------------------------------------------------------*\ * Select support methods \*-------------------------------------------------------------------------*/ static int meth_getfd(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); lua_pushnumber(L, (int) un->sock); return 1; } /* this is very dangerous, but can be handy for those that are brave enough */ static int meth_setfd(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); un->sock = (t_socket) luaL_checknumber(L, 2); return 0; } static int meth_dirty(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); lua_pushboolean(L, !buffer_isempty(&un->buf)); return 1; } /*-------------------------------------------------------------------------*\ * Waits for and returns a client object attempting connection to the * server object \*-------------------------------------------------------------------------*/ static int meth_accept(lua_State *L) { p_unix server = (p_unix) auxiliar_checkclass(L, "unix{server}", 1); p_timeout tm = timeout_markstart(&server->tm); t_socket sock; int err = socket_accept(&server->sock, &sock, NULL, NULL, tm); /* if successful, push client socket */ if (err == IO_DONE) { p_unix clnt = (p_unix) lua_newuserdata(L, sizeof(t_unix)); auxiliar_setclass(L, "unix{client}", -1); /* initialize structure fields */ socket_setnonblocking(&sock); clnt->sock = sock; io_init(&clnt->io, (p_send)socket_send, (p_recv)socket_recv, (p_error) socket_ioerror, &clnt->sock); timeout_init(&clnt->tm, -1, -1); buffer_init(&clnt->buf, &clnt->io, &clnt->tm); return 1; } else { lua_pushnil(L); lua_pushstring(L, socket_strerror(err)); return 2; } } /*-------------------------------------------------------------------------*\ * Binds an object to an address \*-------------------------------------------------------------------------*/ static const char *unix_trybind(p_unix un, const char *path) { struct sockaddr_un local; size_t len = strlen(path); int err; if (len >= sizeof(local.sun_path)) return "path too long"; memset(&local, 0, sizeof(local)); strcpy(local.sun_path, path); local.sun_family = AF_UNIX; #ifdef UNIX_HAS_SUN_LEN local.sun_len = sizeof(local.sun_family) + sizeof(local.sun_len) + len + 1; err = socket_bind(&un->sock, (SA *) &local, local.sun_len); #else err = socket_bind(&un->sock, (SA *) &local, (socklen_t)(sizeof(local.sun_family) + len)); #endif if (err != IO_DONE) socket_destroy(&un->sock); return socket_strerror(err); } static int meth_bind(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "unix{master}", 1); const char *path = luaL_checkstring(L, 2); const char *err = unix_trybind(un, path); if (err) { lua_pushnil(L); lua_pushstring(L, err); return 2; } lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Turns a master unix object into a client object. \*-------------------------------------------------------------------------*/ static const char *unix_tryconnect(p_unix un, const char *path) { struct sockaddr_un remote; int err; size_t len = strlen(path); if (len >= sizeof(remote.sun_path)) return "path too long"; memset(&remote, 0, sizeof(remote)); strcpy(remote.sun_path, path); remote.sun_family = AF_UNIX; timeout_markstart(&un->tm); #ifdef UNIX_HAS_SUN_LEN remote.sun_len = sizeof(remote.sun_family) + sizeof(remote.sun_len) + len + 1; err = socket_connect(&un->sock, (SA *) &remote, remote.sun_len, &un->tm); #else err = socket_connect(&un->sock, (SA *) &remote, (socklen_t)(sizeof(remote.sun_family) + len), &un->tm); #endif if (err != IO_DONE) socket_destroy(&un->sock); return socket_strerror(err); } static int meth_connect(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "unix{master}", 1); const char *path = luaL_checkstring(L, 2); const char *err = unix_tryconnect(un, path); if (err) { lua_pushnil(L); lua_pushstring(L, err); return 2; } /* turn master object into a client object */ auxiliar_setclass(L, "unix{client}", 1); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Closes socket used by object \*-------------------------------------------------------------------------*/ static int meth_close(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); socket_destroy(&un->sock); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Puts the sockt in listen mode \*-------------------------------------------------------------------------*/ static int meth_listen(lua_State *L) { p_unix un = (p_unix) auxiliar_checkclass(L, "unix{master}", 1); int backlog = (int) luaL_optnumber(L, 2, 32); int err = socket_listen(&un->sock, backlog); if (err != IO_DONE) { lua_pushnil(L); lua_pushstring(L, socket_strerror(err)); return 2; } /* turn master object into a server object */ auxiliar_setclass(L, "unix{server}", 1); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Shuts the connection down partially \*-------------------------------------------------------------------------*/ static int meth_shutdown(lua_State *L) { /* SHUT_RD, SHUT_WR, SHUT_RDWR have the value 0, 1, 2, so we can use method index directly */ static const char* methods[] = { "receive", "send", "both", NULL }; p_unix tcp = (p_unix) auxiliar_checkclass(L, "unix{client}", 1); int how = luaL_checkoption(L, 2, "both", methods); socket_shutdown(&tcp->sock, how); lua_pushnumber(L, 1); return 1; } /*-------------------------------------------------------------------------*\ * Just call tm methods \*-------------------------------------------------------------------------*/ static int meth_settimeout(lua_State *L) { p_unix un = (p_unix) auxiliar_checkgroup(L, "unix{any}", 1); return timeout_meth_settimeout(L, &un->tm); } /*=========================================================================*\ * Library functions \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Creates a master unix object \*-------------------------------------------------------------------------*/ static int global_create(lua_State *L) { t_socket sock; int err = socket_create(&sock, AF_UNIX, SOCK_STREAM, 0); /* try to allocate a system socket */ if (err == IO_DONE) { /* allocate unix object */ p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix)); /* set its type as master object */ auxiliar_setclass(L, "unix{master}", -1); /* initialize remaining structure fields */ socket_setnonblocking(&sock); un->sock = sock; io_init(&un->io, (p_send) socket_send, (p_recv) socket_recv, (p_error) socket_ioerror, &un->sock); timeout_init(&un->tm, -1, -1); buffer_init(&un->buf, &un->io, &un->tm); return 1; } else { lua_pushnil(L); lua_pushstring(L, socket_strerror(err)); return 2; } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/unix.h ================================================ #ifndef UNIX_H #define UNIX_H /*=========================================================================*\ * Unix domain object * LuaSocket toolkit * * This module is just an example of how to extend LuaSocket with a new * domain. \*=========================================================================*/ #include "lua.h" #include "luasocket.h" #include "luasocket_buffer.h" #include "timeout.h" #include "socket.h" typedef struct t_unix_ { t_socket sock; t_io io; t_buffer buf; t_timeout tm; } t_unix; typedef t_unix *p_unix; LUASOCKET_API int luaopen_socket_unix(lua_State *L); #endif /* UNIX_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/usocket.c ================================================ /*=========================================================================*\ * Socket compatibilization module for Unix * LuaSocket toolkit * * The code is now interrupt-safe. * The penalty of calling select to avoid busy-wait is only paid when * the I/O call fail in the first place. \*=========================================================================*/ #include #include #include "socket.h" /*-------------------------------------------------------------------------*\ * Wait for readable/writable/connected socket with timeout \*-------------------------------------------------------------------------*/ #ifndef SOCKET_SELECT #include #define WAITFD_R POLLIN #define WAITFD_W POLLOUT #define WAITFD_C (POLLIN|POLLOUT) int socket_waitfd(p_socket ps, int sw, p_timeout tm) { int ret; struct pollfd pfd; pfd.fd = *ps; pfd.events = sw; pfd.revents = 0; if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */ do { int t = (int)(timeout_getretry(tm)*1e3); ret = poll(&pfd, 1, t >= 0? t: -1); } while (ret == -1 && errno == EINTR); if (ret == -1) return errno; if (ret == 0) return IO_TIMEOUT; if (sw == WAITFD_C && (pfd.revents & (POLLIN|POLLERR))) return IO_CLOSED; return IO_DONE; } #else #define WAITFD_R 1 #define WAITFD_W 2 #define WAITFD_C (WAITFD_R|WAITFD_W) int socket_waitfd(p_socket ps, int sw, p_timeout tm) { int ret; fd_set rfds, wfds, *rp, *wp; struct timeval tv, *tp; double t; if (*ps >= FD_SETSIZE) return EINVAL; if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */ do { /* must set bits within loop, because select may have modifed them */ rp = wp = NULL; if (sw & WAITFD_R) { FD_ZERO(&rfds); FD_SET(*ps, &rfds); rp = &rfds; } if (sw & WAITFD_W) { FD_ZERO(&wfds); FD_SET(*ps, &wfds); wp = &wfds; } t = timeout_getretry(tm); tp = NULL; if (t >= 0.0) { tv.tv_sec = (int)t; tv.tv_usec = (int)((t-tv.tv_sec)*1.0e6); tp = &tv; } ret = select(*ps+1, rp, wp, NULL, tp); } while (ret == -1 && errno == EINTR); if (ret == -1) return errno; if (ret == 0) return IO_TIMEOUT; if (sw == WAITFD_C && FD_ISSET(*ps, &rfds)) return IO_CLOSED; return IO_DONE; } #endif /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int socket_open(void) { /* instals a handler to ignore sigpipe or it will crash us */ signal(SIGPIPE, SIG_IGN); return 1; } /*-------------------------------------------------------------------------*\ * Close module \*-------------------------------------------------------------------------*/ int socket_close(void) { return 1; } /*-------------------------------------------------------------------------*\ * Close and inutilize socket \*-------------------------------------------------------------------------*/ void socket_destroy(p_socket ps) { if (*ps != SOCKET_INVALID) { socket_setblocking(ps); close(*ps); *ps = SOCKET_INVALID; } } /*-------------------------------------------------------------------------*\ * Select with timeout control \*-------------------------------------------------------------------------*/ int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_timeout tm) { int ret; do { struct timeval tv; double t = timeout_getretry(tm); tv.tv_sec = (int) t; tv.tv_usec = (int) ((t - tv.tv_sec) * 1.0e6); /* timeout = 0 means no wait */ ret = select(n, rfds, wfds, efds, t >= 0.0 ? &tv: NULL); } while (ret < 0 && errno == EINTR); return ret; } /*-------------------------------------------------------------------------*\ * Creates and sets up a socket \*-------------------------------------------------------------------------*/ int socket_create(p_socket ps, int domain, int type, int protocol) { *ps = socket(domain, type, protocol); if (*ps != SOCKET_INVALID) return IO_DONE; else return errno; } /*-------------------------------------------------------------------------*\ * Binds or returns error message \*-------------------------------------------------------------------------*/ int socket_bind(p_socket ps, SA *addr, socklen_t len) { int err = IO_DONE; socket_setblocking(ps); if (bind(*ps, addr, len) < 0) err = errno; socket_setnonblocking(ps); return err; } /*-------------------------------------------------------------------------*\ * \*-------------------------------------------------------------------------*/ int socket_listen(p_socket ps, int backlog) { int err = IO_DONE; socket_setblocking(ps); if (listen(*ps, backlog)) err = errno; socket_setnonblocking(ps); return err; } /*-------------------------------------------------------------------------*\ * \*-------------------------------------------------------------------------*/ void socket_shutdown(p_socket ps, int how) { socket_setblocking(ps); shutdown(*ps, how); socket_setnonblocking(ps); } /*-------------------------------------------------------------------------*\ * Connects or returns error message \*-------------------------------------------------------------------------*/ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) { int err; /* avoid calling on closed sockets */ if (*ps == SOCKET_INVALID) return IO_CLOSED; /* call connect until done or failed without being interrupted */ do if (connect(*ps, addr, len) == 0) return IO_DONE; while ((err = errno) == EINTR); /* if connection failed immediately, return error code */ if (err != EINPROGRESS && err != EAGAIN) return err; /* zero timeout case optimization */ if (timeout_iszero(tm)) return IO_TIMEOUT; /* wait until we have the result of the connection attempt or timeout */ err = socket_waitfd(ps, WAITFD_C, tm); if (err == IO_CLOSED) { if (recv(*ps, (char *) &err, 0, 0) == 0) return IO_DONE; else return errno; } else return err; } /*-------------------------------------------------------------------------*\ * Accept with timeout \*-------------------------------------------------------------------------*/ int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len, p_timeout tm) { if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { int err; if ((*pa = accept(*ps, addr, len)) != SOCKET_INVALID) return IO_DONE; err = errno; if (err == EINTR) continue; if (err != EAGAIN && err != ECONNABORTED) return err; if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; } /* can't reach here */ return IO_UNKNOWN; } /*-------------------------------------------------------------------------*\ * Send with timeout \*-------------------------------------------------------------------------*/ int socket_send(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm) { int err; *sent = 0; /* avoid making system calls on closed sockets */ if (*ps == SOCKET_INVALID) return IO_CLOSED; /* loop until we send something or we give up on error */ for ( ;; ) { long put = (long) send(*ps, data, count, 0); /* if we sent anything, we are done */ if (put >= 0) { *sent = put; return IO_DONE; } err = errno; /* EPIPE means the connection was closed */ if (err == EPIPE) return IO_CLOSED; /* we call was interrupted, just try again */ if (err == EINTR) continue; /* if failed fatal reason, report error */ if (err != EAGAIN) return err; /* wait until we can send something or we timeout */ if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; } /* can't reach here */ return IO_UNKNOWN; } /*-------------------------------------------------------------------------*\ * Sendto with timeout \*-------------------------------------------------------------------------*/ int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, SA *addr, socklen_t len, p_timeout tm) { int err; *sent = 0; if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { long put = (long) sendto(*ps, data, count, 0, addr, len); if (put >= 0) { *sent = put; return IO_DONE; } err = errno; if (err == EPIPE) return IO_CLOSED; if (err == EINTR) continue; if (err != EAGAIN) return err; if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; } return IO_UNKNOWN; } /*-------------------------------------------------------------------------*\ * Receive with timeout \*-------------------------------------------------------------------------*/ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm) { int err; *got = 0; if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { long taken = (long) recv(*ps, data, count, 0); if (taken > 0) { *got = taken; return IO_DONE; } err = errno; if (taken == 0) return IO_CLOSED; if (err == EINTR) continue; if (err != EAGAIN) return err; if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; } return IO_UNKNOWN; } /*-------------------------------------------------------------------------*\ * Recvfrom with timeout \*-------------------------------------------------------------------------*/ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, SA *addr, socklen_t *len, p_timeout tm) { int err; *got = 0; if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { long taken = (long) recvfrom(*ps, data, count, 0, addr, len); if (taken > 0) { *got = taken; return IO_DONE; } err = errno; if (taken == 0) return IO_CLOSED; if (err == EINTR) continue; if (err != EAGAIN) return err; if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; } return IO_UNKNOWN; } /*-------------------------------------------------------------------------*\ * Write with timeout * * socket_read and socket_write are cut-n-paste of socket_send and socket_recv, * with send/recv replaced with write/read. We can't just use write/read * in the socket version, because behaviour when size is zero is different. \*-------------------------------------------------------------------------*/ int socket_write(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm) { int err; *sent = 0; /* avoid making system calls on closed sockets */ if (*ps == SOCKET_INVALID) return IO_CLOSED; /* loop until we send something or we give up on error */ for ( ;; ) { long put = (long) write(*ps, data, count); /* if we sent anything, we are done */ if (put >= 0) { *sent = put; return IO_DONE; } err = errno; /* EPIPE means the connection was closed */ if (err == EPIPE) return IO_CLOSED; /* we call was interrupted, just try again */ if (err == EINTR) continue; /* if failed fatal reason, report error */ if (err != EAGAIN) return err; /* wait until we can send something or we timeout */ if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; } /* can't reach here */ return IO_UNKNOWN; } /*-------------------------------------------------------------------------*\ * Read with timeout * See note for socket_write \*-------------------------------------------------------------------------*/ int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm) { int err; *got = 0; if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { long taken = (long) read(*ps, data, count); if (taken > 0) { *got = taken; return IO_DONE; } err = errno; if (taken == 0) return IO_CLOSED; if (err == EINTR) continue; if (err != EAGAIN) return err; if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; } return IO_UNKNOWN; } /*-------------------------------------------------------------------------*\ * Put socket into blocking mode \*-------------------------------------------------------------------------*/ void socket_setblocking(p_socket ps) { int flags = fcntl(*ps, F_GETFL, 0); flags &= (~(O_NONBLOCK)); fcntl(*ps, F_SETFL, flags); } /*-------------------------------------------------------------------------*\ * Put socket into non-blocking mode \*-------------------------------------------------------------------------*/ void socket_setnonblocking(p_socket ps) { int flags = fcntl(*ps, F_GETFL, 0); flags |= O_NONBLOCK; fcntl(*ps, F_SETFL, flags); } /*-------------------------------------------------------------------------*\ * DNS helpers \*-------------------------------------------------------------------------*/ int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp) { *hp = gethostbyaddr(addr, len, AF_INET); if (*hp) return IO_DONE; else if (h_errno) return h_errno; else if (errno) return errno; else return IO_UNKNOWN; } int socket_gethostbyname(const char *addr, struct hostent **hp) { *hp = gethostbyname(addr); if (*hp) return IO_DONE; else if (h_errno) return h_errno; else if (errno) return errno; else return IO_UNKNOWN; } /*-------------------------------------------------------------------------*\ * Error translation functions * Make sure important error messages are standard \*-------------------------------------------------------------------------*/ const char *socket_hoststrerror(int err) { if (err <= 0) return io_strerror(err); switch (err) { case HOST_NOT_FOUND: return "host not found"; default: return hstrerror(err); } } const char *socket_strerror(int err) { if (err <= 0) return io_strerror(err); switch (err) { case EADDRINUSE: return "address already in use"; case EISCONN: return "already connected"; case EACCES: return "permission denied"; case ECONNREFUSED: return "connection refused"; case ECONNABORTED: return "closed"; case ECONNRESET: return "closed"; case ETIMEDOUT: return "timeout"; default: return strerror(err); } } const char *socket_ioerror(p_socket ps, int err) { (void) ps; return socket_strerror(err); } const char *socket_gaistrerror(int err) { if (err == 0) return NULL; switch (err) { case EAI_AGAIN: return "temporary failure in name resolution"; case EAI_BADFLAGS: return "invalid value for ai_flags"; #ifdef EAI_BADHINTS case EAI_BADHINTS: return "invalid value for hints"; #endif case EAI_FAIL: return "non-recoverable failure in name resolution"; case EAI_FAMILY: return "ai_family not supported"; case EAI_MEMORY: return "memory allocation failure"; case EAI_NONAME: return "host or service not provided, or not known"; case EAI_OVERFLOW: return "argument buffer overflow"; #ifdef EAI_PROTOCOL case EAI_PROTOCOL: return "resolved protocol is unknown"; #endif case EAI_SERVICE: return "service not supported for socket type"; case EAI_SOCKTYPE: return "ai_socktype not supported"; case EAI_SYSTEM: return strerror(errno); default: return gai_strerror(err); } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/usocket.h ================================================ #ifndef USOCKET_H #define USOCKET_H /*=========================================================================*\ * Socket compatibilization module for Unix * LuaSocket toolkit \*=========================================================================*/ /*=========================================================================*\ * BSD include files \*=========================================================================*/ /* error codes */ #include /* close function */ #include /* fnctnl function and associated constants */ #include /* struct sockaddr */ #include /* socket function */ #include /* struct timeval */ #include /* gethostbyname and gethostbyaddr functions */ #include /* sigpipe handling */ #include /* IP stuff*/ #include #include /* TCP options (nagle algorithm disable) */ #include #ifndef SO_REUSEPORT #define SO_REUSEPORT SO_REUSEADDR #endif typedef int t_socket; typedef t_socket *p_socket; typedef struct sockaddr_storage t_sockaddr_storage; #define SOCKET_INVALID (-1) #endif /* USOCKET_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/wsocket.c ================================================ /*=========================================================================*\ * Socket compatibilization module for Win32 * LuaSocket toolkit * * The penalty of calling select to avoid busy-wait is only paid when * the I/O call fail in the first place. \*=========================================================================*/ #include #include "socket.h" /* WinSock doesn't have a strerror... */ static const char *wstrerror(int err); /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ int socket_open(void) { WSADATA wsaData; WORD wVersionRequested = MAKEWORD(2, 0); int err = WSAStartup(wVersionRequested, &wsaData ); if (err != 0) return 0; if ((LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 0) && (LOBYTE(wsaData.wVersion) != 1 || HIBYTE(wsaData.wVersion) != 1)) { WSACleanup(); return 0; } return 1; } /*-------------------------------------------------------------------------*\ * Close module \*-------------------------------------------------------------------------*/ int socket_close(void) { WSACleanup(); return 1; } /*-------------------------------------------------------------------------*\ * Wait for readable/writable/connected socket with timeout \*-------------------------------------------------------------------------*/ #define WAITFD_R 1 #define WAITFD_W 2 #define WAITFD_E 4 #define WAITFD_C (WAITFD_E|WAITFD_W) int socket_waitfd(p_socket ps, int sw, p_timeout tm) { int ret; fd_set rfds, wfds, efds, *rp = NULL, *wp = NULL, *ep = NULL; struct timeval tv, *tp = NULL; double t; if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */ if (sw & WAITFD_R) { FD_ZERO(&rfds); FD_SET(*ps, &rfds); rp = &rfds; } if (sw & WAITFD_W) { FD_ZERO(&wfds); FD_SET(*ps, &wfds); wp = &wfds; } if (sw & WAITFD_C) { FD_ZERO(&efds); FD_SET(*ps, &efds); ep = &efds; } if ((t = timeout_get(tm)) >= 0.0) { tv.tv_sec = (int) t; tv.tv_usec = (int) ((t-tv.tv_sec)*1.0e6); tp = &tv; } ret = select(0, rp, wp, ep, tp); if (ret == -1) return WSAGetLastError(); if (ret == 0) return IO_TIMEOUT; if (sw == WAITFD_C && FD_ISSET(*ps, &efds)) return IO_CLOSED; return IO_DONE; } /*-------------------------------------------------------------------------*\ * Select with int timeout in ms \*-------------------------------------------------------------------------*/ int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_timeout tm) { struct timeval tv; double t = timeout_get(tm); tv.tv_sec = (int) t; tv.tv_usec = (int) ((t - tv.tv_sec) * 1.0e6); if (n <= 0) { Sleep((DWORD) (1000*t)); return 0; } else return select(0, rfds, wfds, efds, t >= 0.0? &tv: NULL); } /*-------------------------------------------------------------------------*\ * Close and inutilize socket \*-------------------------------------------------------------------------*/ void socket_destroy(p_socket ps) { if (*ps != SOCKET_INVALID) { socket_setblocking(ps); /* close can take a long time on WIN32 */ closesocket(*ps); *ps = SOCKET_INVALID; } } /*-------------------------------------------------------------------------*\ * \*-------------------------------------------------------------------------*/ void socket_shutdown(p_socket ps, int how) { socket_setblocking(ps); shutdown(*ps, how); socket_setnonblocking(ps); } /*-------------------------------------------------------------------------*\ * Creates and sets up a socket \*-------------------------------------------------------------------------*/ int socket_create(p_socket ps, int domain, int type, int protocol) { *ps = socket(domain, type, protocol); if (*ps != SOCKET_INVALID) return IO_DONE; else return WSAGetLastError(); } /*-------------------------------------------------------------------------*\ * Connects or returns error message \*-------------------------------------------------------------------------*/ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) { int err; /* don't call on closed socket */ if (*ps == SOCKET_INVALID) return IO_CLOSED; /* ask system to connect */ if (connect(*ps, addr, len) == 0) return IO_DONE; /* make sure the system is trying to connect */ err = WSAGetLastError(); if (err != WSAEWOULDBLOCK && err != WSAEINPROGRESS) return err; /* zero timeout case optimization */ if (timeout_iszero(tm)) return IO_TIMEOUT; /* we wait until something happens */ err = socket_waitfd(ps, WAITFD_C, tm); if (err == IO_CLOSED) { int len = sizeof(err); /* give windows time to set the error (yes, disgusting) */ Sleep(10); /* find out why we failed */ getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &len); /* we KNOW there was an error. if 'why' is 0, we will return * "unknown error", but it's not really our fault */ return err > 0? err: IO_UNKNOWN; } else return err; } /*-------------------------------------------------------------------------*\ * Binds or returns error message \*-------------------------------------------------------------------------*/ int socket_bind(p_socket ps, SA *addr, socklen_t len) { int err = IO_DONE; socket_setblocking(ps); if (bind(*ps, addr, len) < 0) err = WSAGetLastError(); socket_setnonblocking(ps); return err; } /*-------------------------------------------------------------------------*\ * \*-------------------------------------------------------------------------*/ int socket_listen(p_socket ps, int backlog) { int err = IO_DONE; socket_setblocking(ps); if (listen(*ps, backlog) < 0) err = WSAGetLastError(); socket_setnonblocking(ps); return err; } /*-------------------------------------------------------------------------*\ * Accept with timeout \*-------------------------------------------------------------------------*/ int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len, p_timeout tm) { if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { int err; /* try to get client socket */ if ((*pa = accept(*ps, addr, len)) != SOCKET_INVALID) return IO_DONE; /* find out why we failed */ err = WSAGetLastError(); /* if we failed because there was no connectoin, keep trying */ if (err != WSAEWOULDBLOCK && err != WSAECONNABORTED) return err; /* call select to avoid busy wait */ if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; } } /*-------------------------------------------------------------------------*\ * Send with timeout * On windows, if you try to send 10MB, the OS will buffer EVERYTHING * this can take an awful lot of time and we will end up blocked. * Therefore, whoever calls this function should not pass a huge buffer. \*-------------------------------------------------------------------------*/ int socket_send(p_socket ps, const char *data, size_t count, size_t *sent, p_timeout tm) { int err; *sent = 0; /* avoid making system calls on closed sockets */ if (*ps == SOCKET_INVALID) return IO_CLOSED; /* loop until we send something or we give up on error */ for ( ;; ) { /* try to send something */ int put = send(*ps, data, (int) count, 0); /* if we sent something, we are done */ if (put > 0) { *sent = put; return IO_DONE; } /* deal with failure */ err = WSAGetLastError(); /* we can only proceed if there was no serious error */ if (err != WSAEWOULDBLOCK) return err; /* avoid busy wait */ if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; } } /*-------------------------------------------------------------------------*\ * Sendto with timeout \*-------------------------------------------------------------------------*/ int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, SA *addr, socklen_t len, p_timeout tm) { int err; *sent = 0; if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { int put = sendto(*ps, data, (int) count, 0, addr, len); if (put > 0) { *sent = put; return IO_DONE; } err = WSAGetLastError(); if (err != WSAEWOULDBLOCK) return err; if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; } } /*-------------------------------------------------------------------------*\ * Receive with timeout \*-------------------------------------------------------------------------*/ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm) { int err; *got = 0; if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { int taken = recv(*ps, data, (int) count, 0); if (taken > 0) { *got = taken; return IO_DONE; } if (taken == 0) return IO_CLOSED; err = WSAGetLastError(); if (err != WSAEWOULDBLOCK) return err; if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; } } /*-------------------------------------------------------------------------*\ * Recvfrom with timeout \*-------------------------------------------------------------------------*/ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, SA *addr, socklen_t *len, p_timeout tm) { int err; *got = 0; if (*ps == SOCKET_INVALID) return IO_CLOSED; for ( ;; ) { int taken = recvfrom(*ps, data, (int) count, 0, addr, len); if (taken > 0) { *got = taken; return IO_DONE; } if (taken == 0) return IO_CLOSED; err = WSAGetLastError(); if (err != WSAEWOULDBLOCK) return err; if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; } } /*-------------------------------------------------------------------------*\ * Put socket into blocking mode \*-------------------------------------------------------------------------*/ void socket_setblocking(p_socket ps) { u_long argp = 0; ioctlsocket(*ps, FIONBIO, &argp); } /*-------------------------------------------------------------------------*\ * Put socket into non-blocking mode \*-------------------------------------------------------------------------*/ void socket_setnonblocking(p_socket ps) { u_long argp = 1; ioctlsocket(*ps, FIONBIO, &argp); } /*-------------------------------------------------------------------------*\ * DNS helpers \*-------------------------------------------------------------------------*/ int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent **hp) { *hp = gethostbyaddr(addr, len, AF_INET); if (*hp) return IO_DONE; else return WSAGetLastError(); } int socket_gethostbyname(const char *addr, struct hostent **hp) { *hp = gethostbyname(addr); if (*hp) return IO_DONE; else return WSAGetLastError(); } /*-------------------------------------------------------------------------*\ * Error translation functions \*-------------------------------------------------------------------------*/ const char *socket_hoststrerror(int err) { if (err <= 0) return io_strerror(err); switch (err) { case WSAHOST_NOT_FOUND: return "host not found"; default: return wstrerror(err); } } const char *socket_strerror(int err) { if (err <= 0) return io_strerror(err); switch (err) { case WSAEADDRINUSE: return "address already in use"; case WSAECONNREFUSED: return "connection refused"; case WSAEISCONN: return "already connected"; case WSAEACCES: return "permission denied"; case WSAECONNABORTED: return "closed"; case WSAECONNRESET: return "closed"; case WSAETIMEDOUT: return "timeout"; default: return wstrerror(err); } } const char *socket_ioerror(p_socket ps, int err) { (void) ps; return socket_strerror(err); } static const char *wstrerror(int err) { switch (err) { case WSAEINTR: return "Interrupted function call"; case WSAEACCES: return "Permission denied"; case WSAEFAULT: return "Bad address"; case WSAEINVAL: return "Invalid argument"; case WSAEMFILE: return "Too many open files"; case WSAEWOULDBLOCK: return "Resource temporarily unavailable"; case WSAEINPROGRESS: return "Operation now in progress"; case WSAEALREADY: return "Operation already in progress"; case WSAENOTSOCK: return "Socket operation on nonsocket"; case WSAEDESTADDRREQ: return "Destination address required"; case WSAEMSGSIZE: return "Message too long"; case WSAEPROTOTYPE: return "Protocol wrong type for socket"; case WSAENOPROTOOPT: return "Bad protocol option"; case WSAEPROTONOSUPPORT: return "Protocol not supported"; case WSAESOCKTNOSUPPORT: return "Socket type not supported"; case WSAEOPNOTSUPP: return "Operation not supported"; case WSAEPFNOSUPPORT: return "Protocol family not supported"; case WSAEAFNOSUPPORT: return "Address family not supported by protocol family"; case WSAEADDRINUSE: return "Address already in use"; case WSAEADDRNOTAVAIL: return "Cannot assign requested address"; case WSAENETDOWN: return "Network is down"; case WSAENETUNREACH: return "Network is unreachable"; case WSAENETRESET: return "Network dropped connection on reset"; case WSAECONNABORTED: return "Software caused connection abort"; case WSAECONNRESET: return "Connection reset by peer"; case WSAENOBUFS: return "No buffer space available"; case WSAEISCONN: return "Socket is already connected"; case WSAENOTCONN: return "Socket is not connected"; case WSAESHUTDOWN: return "Cannot send after socket shutdown"; case WSAETIMEDOUT: return "Connection timed out"; case WSAECONNREFUSED: return "Connection refused"; case WSAEHOSTDOWN: return "Host is down"; case WSAEHOSTUNREACH: return "No route to host"; case WSAEPROCLIM: return "Too many processes"; case WSASYSNOTREADY: return "Network subsystem is unavailable"; case WSAVERNOTSUPPORTED: return "Winsock.dll version out of range"; case WSANOTINITIALISED: return "Successful WSAStartup not yet performed"; case WSAEDISCON: return "Graceful shutdown in progress"; case WSAHOST_NOT_FOUND: return "Host not found"; case WSATRY_AGAIN: return "Nonauthoritative host not found"; case WSANO_RECOVERY: return "Nonrecoverable name lookup error"; case WSANO_DATA: return "Valid name, no data record of requested type"; default: return "Unknown error"; } } const char *socket_gaistrerror(int err) { if (err == 0) return NULL; switch (err) { case EAI_AGAIN: return "temporary failure in name resolution"; case EAI_BADFLAGS: return "invalid value for ai_flags"; #ifdef EAI_BADHINTS case EAI_BADHINTS: return "invalid value for hints"; #endif case EAI_FAIL: return "non-recoverable failure in name resolution"; case EAI_FAMILY: return "ai_family not supported"; case EAI_MEMORY: return "memory allocation failure"; case EAI_NONAME: return "host or service not provided, or not known"; // case EAI_OVERFLOW: return "argument buffer overflow"; #ifdef EAI_PROTOCOL case EAI_PROTOCOL: return "resolved protocol is unknown"; #endif case EAI_SERVICE: return "service not supported for socket type"; case EAI_SOCKTYPE: return "ai_socktype not supported"; // case EAI_SYSTEM: return strerror(errno); default: return gai_strerrorA(err); } } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/socket/wsocket.h ================================================ #ifndef WSOCKET_H #define WSOCKET_H /*=========================================================================*\ * Socket compatibilization module for Win32 * LuaSocket toolkit \*=========================================================================*/ /*=========================================================================*\ * WinSock include files \*=========================================================================*/ #include #include typedef int socklen_t; typedef SOCKADDR_STORAGE t_sockaddr_storage; typedef SOCKET t_socket; typedef t_socket *p_socket; #define SOCKET_INVALID (INVALID_SOCKET) #ifndef SO_REUSEPORT #define SO_REUSEPORT SO_REUSEADDR #endif #endif /* WSOCKET_H */ ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/tolua_fix.c ================================================ #include "tolua_fix.h" #include static int s_function_ref_id = 0; TOLUA_API void toluafix_open(lua_State* L) { lua_pushstring(L, TOLUA_REFID_PTR_MAPPING); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); } TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L, int refid, int* p_refid, void* ptr, const char* type) { if (ptr == NULL || p_refid == NULL) { lua_pushnil(L); return -1; } if (*p_refid == 0) { *p_refid = refid; lua_pushstring(L, TOLUA_REFID_PTR_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_ptr */ lua_pushinteger(L, refid); /* stack: refid_ptr refid */ lua_pushlightuserdata(L, ptr); /* stack: refid_ptr refid ptr */ lua_rawset(L, -3); /* refid_ptr[refid] = ptr, stack: refid_ptr */ lua_pop(L, 1); /* stack: - */ lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_type */ lua_pushinteger(L, refid); /* stack: refid_type refid */ lua_pushstring(L, type); /* stack: refid_type refid type */ lua_rawset(L, -3); /* refid_type[refid] = type, stack: refid_type */ lua_pop(L, 1); /* stack: - */ //printf("[LUA] push CCObject OK - refid: %d, ptr: %x, type: %s\n", *p_refid, (int)ptr, type); } tolua_pushusertype_and_addtoroot(L, ptr, type); return 0; } TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) { void* ptr = NULL; const char* type = NULL; void** ud = NULL; if (refid == 0) return -1; // get ptr from tolua_refid_ptr_mapping lua_pushstring(L, TOLUA_REFID_PTR_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_ptr */ lua_pushinteger(L, refid); /* stack: refid_ptr refid */ lua_rawget(L, -2); /* stack: refid_ptr ptr */ ptr = lua_touserdata(L, -1); lua_pop(L, 1); /* stack: refid_ptr */ if (ptr == NULL) { lua_pop(L, 1); // Lua stack has closed, C++ object not in Lua. // printf("[LUA ERROR] remove CCObject with NULL ptr, refid: %d\n", refid); return -2; } // remove ptr from tolua_refid_ptr_mapping lua_pushinteger(L, refid); /* stack: refid_ptr refid */ lua_pushnil(L); /* stack: refid_ptr refid nil */ lua_rawset(L, -3); /* delete refid_ptr[refid], stack: refid_ptr */ lua_pop(L, 1); /* stack: - */ // get type from tolua_refid_type_mapping lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_type */ lua_pushinteger(L, refid); /* stack: refid_type refid */ lua_rawget(L, -2); /* stack: refid_type type */ if (lua_isnil(L, -1)) { lua_pop(L, 2); printf("[LUA ERROR] remove CCObject with NULL type, refid: %d, ptr: %p\n", refid, ptr); return -1; } type = lua_tostring(L, -1); lua_pop(L, 1); /* stack: refid_type */ // remove type from tolua_refid_type_mapping lua_pushinteger(L, refid); /* stack: refid_type refid */ lua_pushnil(L); /* stack: refid_type refid nil */ lua_rawset(L, -3); /* delete refid_type[refid], stack: refid_type */ lua_pop(L, 1); /* stack: - */ // get ubox luaL_getmetatable(L, type); /* stack: mt */ lua_pushstring(L, "tolua_ubox"); /* stack: mt key */ lua_rawget(L, -2); /* stack: mt ubox */ if (lua_isnil(L, -1)) { // use global ubox lua_pop(L, 1); /* stack: mt */ lua_pushstring(L, "tolua_ubox"); /* stack: mt key */ lua_rawget(L, LUA_REGISTRYINDEX); /* stack: mt ubox */ }; // cleanup root tolua_remove_value_from_root(L, ptr); lua_pushlightuserdata(L, ptr); /* stack: mt ubox ptr */ lua_rawget(L,-2); /* stack: mt ubox ud */ if (lua_isnil(L, -1)) { // Lua object has released (GC), C++ object not in ubox. //printf("[LUA ERROR] remove CCObject with NULL ubox, refid: %d, ptr: %x, type: %s\n", refid, (int)ptr, type); lua_pop(L, 3); return -3; } // cleanup peertable lua_pushvalue(L, LUA_REGISTRYINDEX); lua_setfenv(L, -2); ud = (void**)lua_touserdata(L, -1); lua_pop(L, 1); /* stack: mt ubox */ if (ud == NULL) { printf("[LUA ERROR] remove CCObject with NULL userdata, refid: %d, ptr: %p, type: %s\n", refid, ptr, type); lua_pop(L, 2); return -1; } // clean userdata *ud = NULL; lua_pushlightuserdata(L, ptr); /* stack: mt ubox ptr */ lua_pushnil(L); /* stack: mt ubox ptr nil */ lua_rawset(L, -3); /* ubox[ptr] = nil, stack: mt ubox */ lua_pop(L, 2); //printf("[LUA] remove CCObject, refid: %d, ptr: %x, type: %s\n", refid, (int)ptr, type); return 0; } TOLUA_API int toluafix_ref_function(lua_State* L, int lo, int def) { // function at lo if (!lua_isfunction(L, lo)) return 0; s_function_ref_id++; lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: fun ... refid_fun */ lua_pushinteger(L, s_function_ref_id); /* stack: fun ... refid_fun refid */ lua_pushvalue(L, lo); /* stack: fun ... refid_fun refid fun */ lua_rawset(L, -3); /* refid_fun[refid] = fun, stack: fun ... refid_ptr */ lua_pop(L, 1); /* stack: fun ... */ return s_function_ref_id; // lua_pushvalue(L, lo); /* stack: ... func */ // return luaL_ref(L, LUA_REGISTRYINDEX); } TOLUA_API void toluafix_get_function_by_refid(lua_State* L, int refid) { lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: ... refid_fun */ lua_pushinteger(L, refid); /* stack: ... refid_fun refid */ lua_rawget(L, -2); /* stack: ... refid_fun fun */ lua_remove(L, -2); /* stack: ... fun */ } TOLUA_API void toluafix_remove_function_by_refid(lua_State* L, int refid) { lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: ... refid_fun */ lua_pushinteger(L, refid); /* stack: ... refid_fun refid */ lua_pushnil(L); /* stack: ... refid_fun refid nil */ lua_rawset(L, -3); /* refid_fun[refid] = fun, stack: ... refid_ptr */ lua_pop(L, 1); /* stack: ... */ // luaL_unref(L, LUA_REGISTRYINDEX, refid); } // check lua value is funciton TOLUA_API int toluafix_isfunction(lua_State* L, int lo, const char* type, int def, tolua_Error* err) { if (lua_gettop(L) >= abs(lo) && lua_isfunction(L, lo)) { return 1; } err->index = lo; err->array = 0; err->type = "[not function]"; return 0; } TOLUA_API int toluafix_totable(lua_State* L, int lo, int def) { return lo; } TOLUA_API int toluafix_istable(lua_State* L, int lo, const char* type, int def, tolua_Error* err) { return tolua_istable(L, lo, def, err); } TOLUA_API void toluafix_stack_dump(lua_State* L, const char* label) { int i; int top = lua_gettop(L); printf("Total [%d] in lua stack: %s\n", top, label != 0 ? label : ""); for (i = -1; i >= -top; i--) { int t = lua_type(L, i); switch (t) { case LUA_TSTRING: printf(" [%02d] string %s\n", i, lua_tostring(L, i)); break; case LUA_TBOOLEAN: printf(" [%02d] boolean %s\n", i, lua_toboolean(L, i) ? "true" : "false"); break; case LUA_TNUMBER: printf(" [%02d] number %g\n", i, lua_tonumber(L, i)); break; default: printf(" [%02d] %s\n", i, lua_typename(L, t)); } } printf("\n"); } ================================================ FILE: cocos2d/cocos/scripting/lua/bindings/tolua_fix.h ================================================ #ifndef __TOLUA_FIX_H_ #define __TOLUA_FIX_H_ #include "tolua++.h" #ifdef __cplusplus extern "C" { #endif #define TOLUA_REFID_PTR_MAPPING "toluafix_refid_ptr_mapping" #define TOLUA_REFID_TYPE_MAPPING "toluafix_refid_type_mapping" #define TOLUA_REFID_FUNCTION_MAPPING "toluafix_refid_function_mapping" TOLUA_API void toluafix_open(lua_State* L); TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L, int uid, int* p_refid, void* ptr, const char* type); TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid); TOLUA_API int toluafix_ref_function(lua_State* L, int lo, int def); TOLUA_API void toluafix_get_function_by_refid(lua_State* L, int refid); TOLUA_API void toluafix_remove_function_by_refid(lua_State* L, int refid); TOLUA_API int toluafix_isfunction(lua_State* L, int lo, const char* type, int def, tolua_Error* err); TOLUA_API int toluafix_totable(lua_State* L, int lo, int def); TOLUA_API int toluafix_istable(lua_State* L, int lo, const char* type, int def, tolua_Error* err); TOLUA_API void toluafix_stack_dump(lua_State* L, const char* label); #ifdef __cplusplus } // extern "C" #endif #endif // __TOLUA_FIX_H_ ================================================ FILE: cocos2d/cocos/scripting/lua/script/AudioEngine.lua ================================================ --Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects. local M = {} local audioEngineInstance = cc.SimpleAudioEngine:getInstance() function M.stopAllEffects() audioEngineInstance:stopAllEffects() end function M.getMusicVolume() return audioEngineInstance:getMusicVolume() end function M.isMusicPlaying() return audioEngineInstance:isMusicPlaying() end function M.getEffectsVolume() return audioEngineInstance:getEffectsVolume() end function M.setMusicVolume(volume) audioEngineInstance:setMusicVolume(volume) end function M.stopEffect(handle) audioEngineInstance:stopEffect(handle) end function M.stopMusic(isReleaseData) local releaseDataValue = false if nil ~= isReleaseData then releaseDataValue = isReleaseData end audioEngineInstance:stopMusic(releaseDataValue) end function M.playMusic(filename, isLoop) local loopValue = false if nil ~= isLoop then loopValue = isLoop end audioEngineInstance:playMusic(filename, loopValue) end function M.pauseAllEffects() audioEngineInstance:pauseAllEffects() end function M.preloadMusic(filename) audioEngineInstance:preloadMusic(filename) end function M.resumeMusic() audioEngineInstance:resumeMusic() end function M.playEffect(filename, isLoop) local loopValue = false if nil ~= isLoop then loopValue = isLoop end return audioEngineInstance:playEffect(filename, loopValue) end function M.rewindMusic() audioEngineInstance:rewindMusic() end function M.willPlayMusic() return audioEngineInstance:willPlayMusic() end function M.unloadEffect(filename) audioEngineInstance:unloadEffect(filename) end function M.preloadEffect(filename) audioEngineInstance:preloadEffect(filename) end function M.setEffectsVolume(volume) audioEngineInstance:setEffectsVolume(volume) end function M.pauseEffect(handle) audioEngineInstance:pauseEffect(handle) end function M.resumeAllEffects(handle) audioEngineInstance:resumeAllEffects() end function M.pauseMusic() audioEngineInstance:pauseMusic() end function M.resumeEffect(handle) audioEngineInstance:resumeEffect(handle) end local modename = "AudioEngine" local proxy = {} local mt = { __index = M, __newindex = function (t ,k ,v) print("attemp to update a read-only table") end } setmetatable(proxy,mt) _G[modename] = proxy package.loaded[modename] = proxy ================================================ FILE: cocos2d/cocos/scripting/lua/script/CCBReaderLoad.lua ================================================ ccb = ccb or {} function CCBReaderLoad(strFilePath,proxy,owner) if nil == proxy then return nil end local ccbReader = proxy:createCCBReader() local node = ccbReader:load(strFilePath) local rootName = "" --owner set in readCCBFromFile is proxy if nil ~= owner then --Callbacks local ownerCallbackNames = ccbReader:getOwnerCallbackNames() local ownerCallbackNodes = ccbReader:getOwnerCallbackNodes() local ownerCallbackControlEvents = ccbReader:getOwnerCallbackControlEvents() local i = 1 for i = 1,table.getn(ownerCallbackNames) do local callbackName = ownerCallbackNames[i] local callbackNode = tolua.cast(ownerCallbackNodes[i],"cc.Node") if "function" == type(owner[callbackName]) then proxy:setCallback(callbackNode, owner[callbackName], ownerCallbackControlEvents[i]) else print("Warning: Cannot find owner's lua function:" .. ":" .. callbackName .. " for ownerVar selector") end end --Variables local ownerOutletNames = ccbReader:getOwnerOutletNames() local ownerOutletNodes = ccbReader:getOwnerOutletNodes() for i = 1, table.getn(ownerOutletNames) do local outletName = ownerOutletNames[i] local outletNode = tolua.cast(ownerOutletNodes[i],"cc.Node") owner[outletName] = outletNode end end local nodesWithAnimationManagers = ccbReader:getNodesWithAnimationManagers() local animationManagersForNodes = ccbReader:getAnimationManagersForNodes() for i = 1 , table.getn(nodesWithAnimationManagers) do local innerNode = tolua.cast(nodesWithAnimationManagers[i], "cc.Node") local animationManager = tolua.cast(animationManagersForNodes[i], "cc.CCBAnimationManager") local documentControllerName = animationManager:getDocumentControllerName() if "" == documentControllerName then end if nil ~= ccb[documentControllerName] then ccb[documentControllerName]["mAnimationManager"] = animationManager end --Callbacks local documentCallbackNames = animationManager:getDocumentCallbackNames() local documentCallbackNodes = animationManager:getDocumentCallbackNodes() local documentCallbackControlEvents = animationManager:getDocumentCallbackControlEvents() for i = 1,table.getn(documentCallbackNames) do local callbackName = documentCallbackNames[i] local callbackNode = tolua.cast(documentCallbackNodes[i],"cc.Node") if "" ~= documentControllerName and nil ~= ccb[documentControllerName] then if "function" == type(ccb[documentControllerName][callbackName]) then proxy:setCallback(callbackNode, ccb[documentControllerName][callbackName], documentCallbackControlEvents[i]) else print("Warning: Cannot found lua function [" .. documentControllerName .. ":" .. callbackName .. "] for docRoot selector") end end end --Variables local documentOutletNames = animationManager:getDocumentOutletNames() local documentOutletNodes = animationManager:getDocumentOutletNodes() for i = 1, table.getn(documentOutletNames) do local outletName = documentOutletNames[i] local outletNode = tolua.cast(documentOutletNodes[i],"cc.Node") if nil ~= ccb[documentControllerName] then ccb[documentControllerName][outletName] = tolua.cast(outletNode, proxy:getNodeTypeName(outletNode)) end end --[[ if (typeof(controller.onDidLoadFromCCB) == "function") controller.onDidLoadFromCCB(); ]]-- --Setup timeline callbacks local keyframeCallbacks = animationManager:getKeyframeCallbacks() for i = 1 , table.getn(keyframeCallbacks) do local callbackCombine = keyframeCallbacks[i] local beignIndex,endIndex = string.find(callbackCombine,":") local callbackType = tonumber(string.sub(callbackCombine,1,beignIndex - 1)) local callbackName = string.sub(callbackCombine,endIndex + 1, -1) --Document callback if 1 == callbackType and nil ~= ccb[documentControllerName] then local callfunc = cc.CallFunc:create(ccb[documentControllerName][callbackName]) animationManager:setCallFuncForLuaCallbackNamed(callfunc, callbackCombine); elseif 2 == callbackType and nil ~= owner then --Owner callback local callfunc = cc.CallFunc:create(owner[callbackName])--need check animationManager:setCallFuncForLuaCallbackNamed(callfunc, callbackCombine) end end --start animation local autoPlaySeqId = animationManager:getAutoPlaySequenceId() if -1 ~= autoPlaySeqId then animationManager:runAnimationsForSequenceIdTweenDuration(autoPlaySeqId, 0) end end return node end local function CCBuilderReaderLoad(strFilePath,proxy,owner) print("\n********** \n".."CCBuilderReaderLoad(strFilePath,proxy,owner)".." was deprecated please use ".. "CCBReaderLoad(strFilePath,proxy,owner)" .. " instead.\n**********") return CCBReaderLoad(strFilePath,proxy,owner) end rawset(_G,"CCBuilderReaderLoad",CCBuilderReaderLoad) ================================================ FILE: cocos2d/cocos/scripting/lua/script/CocoStudio.lua ================================================ require "json" require "extern" ccs = ccs or {} function ccs.sendTriggerEvent(event) local triggerObjArr = ccs.TriggerMng.getInstance():get(event) if nil == triggerObjArr then return end for i = 1, table.getn(triggerObjArr) do local triObj = triggerObjArr[i] if nil ~= triObj and triObj.detect then triObj:done() end end end function ccs.registerTriggerClass(className, createFunc) ccs.TInfo.new(className,createFunc) end ccs.TInfo = class("TInfo") ccs.TInfo._className = "" ccs.TInfo._fun = nil function ccs.TInfo:ctor(c,f) -- @param {String|ccs.TInfo}c -- @param {Function}f if nil ~= f then self._className = c self._fun = f else self._className = c._className self._fun = c._fun end ccs.ObjectFactory.getInstance():registerType(self) end ccs.ObjectFactory = class("ObjectFactory") ccs.ObjectFactory._typeMap = nil ccs.ObjectFactory._instance = nil function ccs.ObjectFactory:ctor() self._typeMap = {} end function ccs.ObjectFactory.getInstance() if nil == ccs.ObjectFactory._instance then ccs.ObjectFactory._instance = ccs.ObjectFactory.new() end return ccs.ObjectFactory._instance end function ccs.ObjectFactory.destroyInstance() ccs.ObjectFactory._instance = nil end function ccs.ObjectFactory:createObject(classname) local obj = nil local t = self._typeMap[classname] if nil ~= t then obj = t._fun() end return obj end function ccs.ObjectFactory:registerType(t) self._typeMap[t._className] = t end ccs.TriggerObj = class("TriggerObj") ccs.TriggerObj._cons = {} ccs.TriggerObj._acts = {} ccs.TriggerObj._enable = false ccs.TriggerObj._id = 0 ccs.TriggerObj._vInt = {} function ccs.TriggerObj.extend(target) local t = tolua.getpeer(target) if not t then t = {} tolua.setpeer(target, t) end setmetatable(t, TriggerObj) return target end function ccs.TriggerObj:ctor() self:init() end function ccs.TriggerObj:init() self._id = 0 self._enable = true self._cons = {} self._acts = {} self._vInt = {} end function ccs.TriggerObj:detect() if (not self._enable) or (table.getn(self._cons) == 0) then return true end local ret = true local obj = nil for i = 1 , table.getn(self._cons) do obj = self._cons[i] if nil ~= obj and obj.detect then ret = ret and obj:detect() end end return ret end function ccs.TriggerObj:done() if (not self._enable) or (table.getn(self._acts) == 0) then return end local obj = nil for i = 1, table.getn(self._acts) do obj = self._acts[i] if nil ~= obj and obj.done then obj:done() end end end function ccs.TriggerObj:removeAll() local obj = nil for i=1, table.getn(self._cons) do obj = self._cons[i] if nil ~= obj then obj:removeAll() end end self._cons = {} for i=1, table.getn(self._acts) do obj = self._acts[i] if nil ~= obj then obj:removeAll() end end self._acts = {} end function ccs.TriggerObj:serialize(jsonValue) self._id = jsonValue["id"] local count = 0 --condition local cons = jsonValue["conditions"] if nil ~= cons then count = table.getn(cons) for i = 1, count do local subDict = cons[i] local className = subDict["classname"] if nil ~= className then local obj = ObjectFactory.getInstance():createObject(className) assert(nil ~= obj, string.format("class named %s can not implement!",className)) obj:serialize(subDict) obj:init() table.insert(self._cons, obj) end end end local actions = jsonValue["actions"] if nil ~= actions then count = table.getn(actions) for i = 1,count do local subAction = actions[i] local className = subAction["classname"] if nil ~= className then local act = ccs.ObjectFactory.getInstance():createObject(className) assert(nil ~= act ,string.format("class named %s can not implement!",className)) act:serialize(subAction) act:init() table.insert(self._acts,act) end end end local events = jsonValue["events"] if nil ~= events then count = table.getn(events) for i = 1, count do local subEveent = events[i] local eventID = subEveent["id"] if eventID >= 0 then table.insert(self._vInt,eventID) end end end end function ccs.TriggerObj:getId() return self._id end function ccs.TriggerObj:setEnable(enable) self._enable = enable end function ccs.TriggerObj:getEvents() return self._vInt end ccs.TriggerMng = class("TriggerMng") ccs.TriggerMng._eventTriggers = nil ccs.TriggerMng._triggerObjs = nil ccs.TriggerMng._movementDispatches = nil ccs.TriggerMng._instance = nil function ccs.TriggerMng:ctor() self._triggerObjs = {} self._movementDispatches = {} self._eventTriggers = {} end function ccs.TriggerMng.getInstance() if ccs.TriggerMng._instance == nil then ccs.TriggerMng._instance = ccs.TriggerMng.new() end return ccs.TriggerMng._instance end function ccs.TriggerMng.destroyInstance() if ccs.TriggerMng._instance ~= nil then ccs.TriggerMng._instance:removeAll() ccs.TriggerMng._instance = nil end end function ccs.TriggerMng:triggerMngVersion() return "1.0.0.0" end function ccs.TriggerMng:parse(jsonStr) local parseTable = json.decode(jsonStr,1) if nil == parseTable then return end local count = table.getn(parseTable) for i = 1, count do local subDict = parseTable[i] local triggerObj = ccs.TriggerObj.new() triggerObj:serialize(subDict) local events = triggerObj:getEvents() for j = 1, table.getn(events) do local event = events[j] self:add(event, triggerObj) end self._triggerObjs[triggerObj:getId()] = triggerObj end end function ccs.TriggerMng:get(event) return self._eventTriggers[event] end function ccs.TriggerMng:getTriggerObj(id) return self._triggerObjs[id] end function ccs.TriggerMng:add(event,triggerObj) local eventTriggers = self._eventTriggers[event] if nil == eventTriggers then eventTriggers = {} end local exist = false for i = 1, table.getn(eventTriggers) do if eventTriggers[i] == triggers then exist = true break end end if not exist then table.insert(eventTriggers,triggerObj) self._eventTriggers[event] = eventTriggers end end function ccs.TriggerMng:removeAll( ) for k in pairs(self._eventTriggers) do local triObjArr = self._eventTriggers[k] for j = 1, table.getn(triObjArr) do local obj = triObjArr[j] obj:removeAll() end end self._eventTriggers = {} end function ccs.TriggerMng:remove(event, obj) if nil ~= obj then return self:removeObjByEvent(event, obj) end assert(event >= 0,"event must be larger than 0") if nil == self._eventTriggers then return false end local triObjects = self._eventTriggers[event] if nil == triObjects then return false end for i = 1, table.getn(triObjects) do local triObject = triggers[i] if nil ~= triObject then triObject:remvoeAll() end end self._eventTriggers[event] = nil return true end function ccs.TriggerMng:removeObjByEvent(event, obj) assert(event >= 0,"event must be larger than 0") if nil == self._eventTriggers then return false end local triObjects = self._eventTriggers[event] if nil == triObjects then return false end for i = 1,table.getn(triObjects) do local triObject = triObjects[i] if nil ~= triObject and triObject == obj then triObject:remvoeAll() table.remove(triObjects, i) return true end end end function ccs.TriggerMng:removeTriggerObj(id) local obj = self.getTriggerObj(id) if nil == obj then return false end local events = obj:getEvents() for i = 1, table.getn(events) do self:remove(events[i],obj) end return true end function ccs.TriggerMng:isEmpty() return (not (nil == self._eventTriggers)) or table.getn(self._eventTriggers) <= 0 end ================================================ FILE: cocos2d/cocos/scripting/lua/script/Cocos2d.lua ================================================ require "CocoStudio" cc = cc or {} cc.DIRECTOR_PROJECTION_2D = 0 cc.DIRECTOR_PROJECTION_3D = 1 function cc.clampf(value, min_inclusive, max_inclusive) -- body local temp = 0 if min_inclusive > max_inclusive then temp = min_inclusive min_inclusive = max_inclusive max_inclusive = temp end if value < min_inclusive then return min_inclusive elseif value < max_inclusive then return value else return max_inclusive end end --Point function cc.p(_x,_y) if nil == _y then return { x = _x.x, y = _x.y } else return { x = _x, y = _y } end end function cc.pAdd(pt1,pt2) return {x = pt1.x + pt2.x , y = pt1.y + pt2.y } end function cc.pSub(pt1,pt2) return {x = pt1.x - pt2.x , y = pt1.y - pt2.y } end function cc.pMul(pt1,factor) return { x = pt1.x * factor , y = pt1.y * factor } end function cc.pMidpoint(pt1,pt2) return { x = (pt1.x + pt2.x) / 2.0 , y = ( pt1.y + pt2.y) / 2.0 } end function cc.pForAngle(a) return { x = math.cos(a), y = math.sin(a) } end function cc.pGetLength(pt) return math.sqrt( pt.x * pt.x + pt.y * pt.y ) end function cc.pNormalize(pt) local length = cc.pGetLength(pt) if 0 == length then return { x = 1.0,y = 0.0 } end return { x = pt.x / length, y = pt.y / length } end function cc.pCross(self,other) return self.x * other.y - self.y * other.x end function cc.pDot(self,other) return self.x * other.x + self.y * other.y end function cc.pToAngleSelf(self) return math.atan2(self.y, self.x) end function cc.pGetAngle(self,other) local a2 = cc.pNormalize(self) local b2 = cc.pNormalize(other) local angle = math.atan2(cc.pCross(a2, b2), cc.pDot(a2, b2) ) if angle < 1.192092896e-7 then return 0.0 end return angle end function cc.pGetDistance(startP,endP) return cc.pGetLength(cc.pSub(startP,endP)) end function cc.pIsLineIntersect(A, B, C, D, s, t) if ((A.x == B.x) and (A.y == B.y)) or ((C.x == D.x) and (C.y == D.y))then return false, s, t end local BAx = B.x - A.x local BAy = B.y - A.y local DCx = D.x - C.x local DCy = D.y - C.y local ACx = A.x - C.x local ACy = A.y - C.y local denom = DCy * BAx - DCx * BAy s = DCx * ACy - DCy * ACx t = BAx * ACy - BAy * ACx if (denom == 0) then if (s == 0 or t == 0) then return true, s , t end return false, s, t end s = s / denom t = t / denom return true,s,t end function cc.pPerp(pt) return { x = -pt.y, y = pt.x } end function cc.RPerp(pt) return { x = pt.y, y = -pt.x } end function cc.pProject(pt1, pt2) return { x = pt2.x * (cc.pDot(pt1,pt2) / cc.pDot(pt2,pt2)) , y = pt2.y * (cc.pDot(pt1,pt2) / cc.pDot(pt2,pt2)) } end function cc.pRotate(pt1, pt2) return { x = pt1.x * pt2.x - pt1.y * pt2.y, y = pt1.x * pt2.y + pt1.y * pt2.x } end function cc.pUnrotate(pt1, pt2) return { x = pt1.x * pt2.x + pt1.y * pt2.y, pt1.y * pt2.x - pt1.x * pt2.y } end --Calculates the square length of pt function cc.pLengthSQ(pt) return cc.pDot(pt,pt) end --Calculates the square distance between pt1 and pt2 function cc.pDistanceSQ(pt1,pt2) return cc.pLengthSQ(cc.pSub(pt1,pt2)) end function cc.pGetClampPoint(pt1,pt2,pt3) return { x = cc.clampf(pt1.x, pt2.x, pt3.x), y = cc.clampf(pt1.y, pt2.y, pt3.y) } end function cc.pFromSize(sz) return { x = sz.width, y = sz.height } end function cc.pLerp(pt1,pt2,alpha) return cc.pAdd(cc.pMul(pt1, 1.0 - alpha), cc.pMul(pt2,alpha) ) end function cc.pFuzzyEqual(pt1,pt2,variance) if (pt1.x - variance <= pt2.x) and (pt2.x <= pt1.x + variance) and (pt1.y - variance <= pt2.y) and (pt2.y <= pt1.y + variance) then return true else return false end end function cc.pRotateByAngle(pt1, pt2, angle) return cc.pAdd(pt2, cc.pRotate( cc.pSub(pt1, pt2),cc.pForAngle(angle))) end function cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4) local s,t,ret = 0,0,false ret,s,t =cc.pIsLineIntersect(pt1, pt2, pt3, pt4,s,t) if ret and s >= 0.0 and s <= 1.0 and t >= 0.0 and t <= 0.0 then return true; end return false end function cc.pGetIntersectPoint(pt1,pt2,pt3,pt4) local s,t, ret = 0,0,false ret,s,t = cc.pIsLineIntersect(pt1,pt2,pt3,pt4,s,t) if ret then return cc.p(pt1.x + s * (pt2.x - pt1.x), pt1.y + s * (pt2.y - pt1.y)) else return cc.p(0,0) end end --Size function cc.size( _width,_height ) return { width = _width, height = _height } end --Rect function cc.rect(_x,_y,_width,_height) return { x = _x, y = _y, width = _width, height = _height } end function cc.rectEqualToRect(rect1,rect2) if ((rect1.x >= rect2.x) or (rect1.y >= rect2.y) or ( rect1.x + rect1.width <= rect2.x + rect2.width) or ( rect1.y + rect1.height <= rect2.y + rect2.height)) then return false end return true end function cc.rectGetMaxX(rect) return rect.x + rect.width end function cc.rectGetMidX(rect) return rect.x + rect.width / 2.0 end function cc.rectGetMinX(rect) return rect.x end function cc.rectGetMaxY(rect) return rect.y + rect.height end function cc.rectGetMidY(rect) return rect.y + rect.height / 2.0 end function cc.rectGetMinY(rect) return rect.y end function cc.rectContainsPoint( rect, point ) local ret = false if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and (point.y >= rect.y) and (point.y <= rect.y + rect.height) then ret = true end return ret end function cc.rectIntersectsRect( rect1, rect2 ) local intersect = not ( rect1.x > rect2.x + rect2.width or rect1.x + rect1.width < rect2.x or rect1.y > rect2.y + rect2.height or rect1.y + rect1.height < rect2.y ) return intersect end function cc.rectUnion( rect1, rect2 ) local rect = cc.rect(0, 0, 0, 0) rect.x = math.min(rect1.x, rect2.x) rect.y = math.min(rect1.y, rect2.y) rect.width = math.max(rect1.x + rect1.width, rect2.x + rect2.width) - rect.x rect.height = math.max(rect1.y + rect1.height, rect2.y + rect2.height) - rect.y return rect end function cc.rectIntersection( rect1, rect2 ) local intersection = cc.rect( math.max(rect1.x, rect2.x), math.max(rect1.y, rect2.y), 0, 0) intersection.width = math.min(rect1.x + rect1.width, rect2.x + rect2.width) - intersection.x intersection.height = math.min(rect1.y + rect1.height, rect2.y + rect2.height) - intersection.y return intersection end --Color3B function cc.c3b( _r,_g,_b ) return { r = _r, g = _g, b = _b } end --Color4B function cc.c4b( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end --Color4F function cc.c4f( _r,_g,_b,_a ) return { r = _r, g = _g, b = _b, a = _a } end --Vertex2F function cc.vertex2F(_x,_y) return { x = _x, y = _y } end --Vertex3F function cc.Vertex3F(_x,_y,_z) return { x = _x, y = _y, z = _z } end --Tex2F function cc.tex2F(_u,_v) return { u = _u, v = _v } end --PointSprite function cc.PointSprite(_pos,_color,_size) return { pos = _pos, color = _color, size = _size } end --Quad2 function cc.Quad2(_tl,_tr,_bl,_br) return { tl = _tl, tr = _tr, bl = _bl, br = _br } end --Quad3 function cc.Quad3(_tl, _tr, _bl, _br) return { tl = _tl, tr = _tr, bl = _bl, br = _br } end --V2F_C4B_T2F function cc.V2F_C4B_T2F(_vertices, _colors, _texCoords) return { vertices = _vertices, colors = _colors, texCoords = _texCoords } end --V2F_C4F_T2F function cc.V2F_C4F_T2F(_vertices, _colors, _texCoords) return { vertices = _vertices, colors = _colors, texCoords = _texCoords } end --V3F_C4B_T2F function cc.V3F_C4B_T2F(_vertices, _colors, _texCoords) return { vertices = _vertices, colors = _colors, texCoords = _texCoords } end --V2F_C4B_T2F_Quad function cc.V2F_C4B_T2F_Quad(_bl, _br, _tl, _tr) return { bl = _bl, br = _br, tl = _tl, tr = _tr } end --V3F_C4B_T2F_Quad function cc.V3F_C4B_T2F_Quad(_tl, _bl, _tr, _br) return { tl = _tl, bl = _bl, tr = _tr, br = _br } end --V2F_C4F_T2F_Quad function cc.V2F_C4F_T2F_Quad(_bl, _br, _tl, _tr) return { bl = _bl, br = _br, tl = _tl, tr = _tr } end --T2F_Quad function cc.T2F_Quad(_bl, _br, _tl, _tr) return { bl = _bl, br = _br, tl = _tl, tr = _tr } end --AnimationFrameData function cc.AnimationFrameData( _texCoords, _delay, _size) return { texCoords = _texCoords, delay = _delay, size = _size } end --PhysicsMaterial function cc.PhysicsMaterial(_density, _restitution, _friction) return { density = _density, restitution = _restitution, friction = _friction } end local ConfigType = { NONE = 0, COCOSTUDIO = 1, } function __onParseConfig(configType,jasonStr) if configType == ConfigType.COCOSTUDIO then ccs.TriggerMng.getInstance():parse(jasonStr) end end ================================================ FILE: cocos2d/cocos/scripting/lua/script/Cocos2dConstants.lua ================================================ cc = cc or {} cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff cc.TMX_ORIENTATION_HEX = 0x1 cc.TMX_ORIENTATION_ISO = 0x2 cc.TMX_ORIENTATION_ORTHO = 0x0 cc.Z_COMPRESSION_BZIP2 = 0x1 cc.Z_COMPRESSION_GZIP = 0x2 cc.Z_COMPRESSION_NONE = 0x3 cc.Z_COMPRESSION_ZLIB = 0x0 cc.BLEND_DST = 0x303 cc.BLEND_SRC = 0x1 cc.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0 cc.DIRECTOR_MAC_THREAD = 0x0 cc.DIRECTOR_STATS_INTERVAL = 0.1 cc.ENABLE_BOX2_D_INTEGRATION = 0x0 cc.ENABLE_DEPRECATED = 0x1 cc.ENABLE_GL_STATE_CACHE = 0x1 cc.ENABLE_PROFILERS = 0x0 cc.ENABLE_STACKABLE_ACTIONS = 0x1 cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0 cc.GL_ALL = 0x0 cc.LABELATLAS_DEBUG_DRAW = 0x0 cc.LABELBMFONT_DEBUG_DRAW = 0x0 cc.MAC_USE_DISPLAY_LINK_THREAD = 0x0 cc.MAC_USE_MAIN_THREAD = 0x2 cc.MAC_USE_OWN_THREAD = 0x1 cc.NODE_RENDER_SUBPIXEL = 0x1 cc.PVRMIPMAP_MAX = 0x10 cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1 cc.SPRITE_DEBUG_DRAW = 0x0 cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0 cc.TEXTURE_ATLAS_USE_VAO = 0x1 cc.USE_L_A88_LABELS = 0x1 cc.ACTION_TAG_INVALID = -1 cc.DEVICE_MAC = 0x6 cc.DEVICE_MAC_RETINA_DISPLAY = 0x7 cc.DEVICEI_PAD = 0x4 cc.DEVICEI_PAD_RETINA_DISPLAY = 0x5 cc.DEVICEI_PHONE = 0x0 cc.DEVICEI_PHONE5 = 0x2 cc.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3 cc.DEVICEI_PHONE_RETINA_DISPLAY = 0x1 cc.DIRECTOR_PROJECTION2_D = 0x0 cc.DIRECTOR_PROJECTION3_D = 0x1 cc.DIRECTOR_PROJECTION_CUSTOM = 0x2 cc.DIRECTOR_PROJECTION_DEFAULT = 0x1 cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1 cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0 cc.FLIPED_ALL = 0xe0000000 cc.FLIPPED_MASK = 0x1fffffff cc.IMAGE_FORMAT_JPEG = 0x0 cc.IMAGE_FORMAT_PNG = 0x1 cc.ITEM_SIZE = 0x20 cc.LABEL_AUTOMATIC_WIDTH = -1 cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1 cc.LINE_BREAK_MODE_CLIP = 0x2 cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3 cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5 cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4 cc.LINE_BREAK_MODE_WORD_WRAP = 0x0 cc.MAC_VERSION_10_6 = 0xa060000 cc.MAC_VERSION_10_7 = 0xa070000 cc.MAC_VERSION_10_8 = 0xa080000 cc.MENU_HANDLER_PRIORITY = -128 cc.MENU_STATE_TRACKING_TOUCH = 0x1 cc.MENU_STATE_WAITING = 0x0 cc.NODE_TAG_INVALID = -1 cc.PARTICLE_DURATION_INFINITY = -1 cc.PARTICLE_MODE_GRAVITY = 0x0 cc.PARTICLE_MODE_RADIUS = 0x1 cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1 cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1 cc.POSITION_TYPE_FREE = 0x0 cc.POSITION_TYPE_GROUPED = 0x2 cc.POSITION_TYPE_RELATIVE = 0x1 cc.PRIORITY_NON_SYSTEM_MIN = -2147483647 cc.PRIORITY_SYSTEM = -2147483648 cc.PROGRESS_TIMER_TYPE_BAR = 0x1 cc.PROGRESS_TIMER_TYPE_RADIAL = 0x0 cc.REPEAT_FOREVER = 0xfffffffe cc.RESOLUTION_MAC = 0x1 cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2 cc.RESOLUTION_UNKNOWN = 0x0 cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000 cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000 cc.TMX_TILE_VERTICAL_FLAG = 0x40000000 cc.TEXT_ALIGNMENT_CENTER = 0x1 cc.TEXT_ALIGNMENT_LEFT = 0x0 cc.TEXT_ALIGNMENT_RIGHT = 0x2 cc.TEXTURE2_D_PIXEL_FORMAT_AUTO = 0x0 cc.TEXTURE2_D_PIXEL_FORMAT_BGR_A8888 = 0x1 cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x2 cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x3 cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x4 cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x5 cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x6 cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x7 cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x8 cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x9 cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0xa cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4A = 0xb cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0xc cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2A = 0xd cc.TEXTURE2_D_PIXEL_FORMAT_ETC = 0xe cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT1 = 0xf cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT3 = 0x10 cc.TEXTURE2_D_PIXEL_FORMAT_S3TC_DXT5 = 0x11 cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0 cc.TOUCHES_ALL_AT_ONCE = 0x0 cc.TOUCHES_ONE_BY_ONE = 0x1 cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1 cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0 cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1 cc.TRANSITION_ORIENTATION_UP_OVER = 0x0 cc.UNIFORM_COS_TIME = 0x5 cc.UNIFORM_MV_MATRIX = 0x1 cc.UNIFORM_MVP_MATRIX = 0x2 cc.UNIFORM_P_MATRIX = 0x0 cc.UNIFORM_RANDOM01 = 0x6 cc.UNIFORM_SAMPLER = 0x7 cc.UNIFORM_SIN_TIME = 0x4 cc.UNIFORM_TIME = 0x3 cc.UNIFORM_MAX = 0x8 cc.VERTEX_ATTRIB_FLAG_COLOR = 0x2 cc.VERTEX_ATTRIB_FLAG_NONE = 0x0 cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7 cc.VERTEX_ATTRIB_FLAG_POSITION = 0x1 cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4 cc.VERTEX_ATTRIB_COLOR = 0x1 cc.VERTEX_ATTRIB_MAX = 0x3 cc.VERTEX_ATTRIB_POSITION = 0x0 cc.VERTEX_ATTRIB_TEX_COORDS = 0x2 cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2 cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1 cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0 cc.OS_VERSION_4_0 = 0x4000000 cc.OS_VERSION_4_0_1 = 0x4000100 cc.OS_VERSION_4_1 = 0x4010000 cc.OS_VERSION_4_2 = 0x4020000 cc.OS_VERSION_4_2_1 = 0x4020100 cc.OS_VERSION_4_3 = 0x4030000 cc.OS_VERSION_4_3_1 = 0x4030100 cc.OS_VERSION_4_3_2 = 0x4030200 cc.OS_VERSION_4_3_3 = 0x4030300 cc.OS_VERSION_4_3_4 = 0x4030400 cc.OS_VERSION_4_3_5 = 0x4030500 cc.OS_VERSION_5_0 = 0x5000000 cc.OS_VERSION_5_0_1 = 0x5000100 cc.OS_VERSION_5_1_0 = 0x5010000 cc.OS_VERSION_6_0_0 = 0x6000000 cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification' cc.CHIPMUNK_IMPORT = 'chipmunk.h' cc.ATTRIBUTE_NAME_COLOR = 'a_color' cc.ATTRIBUTE_NAME_POSITION = 'a_position' cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord' cc.SHADER_POSITION_COLOR = 'ShaderPositionColor' cc.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor' cc.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture' cc.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color' cc.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor' cc.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest' cc.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor' cc.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor' cc.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue' cc.UNIFORM_COS_TIME_S = 'CC_CosTime' cc.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix' cc.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix' cc.UNIFORM_P_MATRIX_S = 'CC_PMatrix' cc.UNIFORM_RANDOM01_S = 'CC_Random01' cc.UNIFORM_SAMPLER_S = 'CC_Texture0' cc.UNIFORM_SIN_TIME_S = 'CC_SinTime' cc.UNIFORM_TIME_S = 'CC_Time' cc.PLATFORM_OS_WINDOWS = 0 cc.PLATFORM_OS_LINUX = 1 cc.PLATFORM_OS_MAC = 2 cc.PLATFORM_OS_ANDROID = 3 cc.PLATFORM_OS_IPHONE = 4 cc.PLATFORM_OS_IPAD = 5 cc.PLATFORM_OS_BLACKBERRY = 6 cc.PLATFORM_OS_NACL = 7 cc.PLATFORM_OS_EMSCRIPTEN = 8 cc.PLATFORM_OS_TIZEN = 9 cc.SCROLLVIEW_SCRIPT_SCROLL = 0 cc.SCROLLVIEW_SCRIPT_ZOOM = 1 cc.TABLECELL_TOUCHED = 2 cc.TABLECELL_HIGH_LIGHT = 3 cc.TABLECELL_UNHIGH_LIGHT = 4 cc.TABLECELL_WILL_RECYCLE = 5 cc.TABLECELL_SIZE_FOR_INDEX = 6 cc.TABLECELL_SIZE_AT_INDEX = 7 cc.NUMBER_OF_CELLS_IN_TABLEVIEW = 8 cc.SCROLLVIEW_DIRECTION_NONE = -1 cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0 cc.SCROLLVIEW_DIRECTION_VERTICAL = 1 cc.SCROLLVIEW_DIRECTION_BOTH = 2 cc.CONTROL_EVENTTYPE_TOUCH_DOWN = 1 cc.CONTROL_EVENTTYPE_DRAG_INSIDE = 2 cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE = 4 cc.CONTROL_EVENTTYPE_DRAG_ENTER = 8 cc.CONTROL_EVENTTYPE_DRAG_EXIT = 16 cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE = 32 cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE = 64 cc.CONTROL_EVENTTYPE_TOUCH_CANCEL = 128 cc.CONTROL_EVENTTYPE_VALUE_CHANGED = 256 cc.CONTROL_STATE_NORMAL = 1 cc.CONTROL_STATE_HIGH_LIGHTED = 2 cc.CONTROL_STATE_DISABLED = 4 cc.CONTROL_STATE_SELECTED = 8 cc.KEYBOARD_RETURNTYPE_DEFAULT = 0 cc.KEYBOARD_RETURNTYPE_DONE = 1 cc.KEYBOARD_RETURNTYPE_SEND = 2 cc.KEYBOARD_RETURNTYPE_SEARCH = 3 cc.KEYBOARD_RETURNTYPE_GO = 4 cc.EDITBOX_INPUT_MODE_ANY = 0 cc.EDITBOX_INPUT_MODE_EMAILADDR = 1 cc.EDITBOX_INPUT_MODE_NUMERIC = 2 cc.EDITBOX_INPUT_MODE_PHONENUMBER = 3 cc.EDITBOX_INPUT_MODE_URL = 4 cc.EDITBOX_INPUT_MODE_DECIMAL = 5 cc.EDITBOX_INPUT_MODE_SINGLELINE = 6 cc.EDITBOX_INPUT_FLAG_PASSWORD = 0 cc.EDITBOX_INPUT_FLAG_SENSITIVE = 1 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4 cc.LANGUAGE_ENGLISH = 0 cc.LANGUAGE_CHINESE = 1 cc.LANGUAGE_FRENCH = 2 cc.LANGUAGE_ITALIAN = 3 cc.LANGUAGE_GERMAN = 4 cc.LANGUAGE_SPANISH = 5 cc.LANGUAGE_RUSSIAN = 6 cc.LANGUAGE_KOREAN = 7 cc.LANGUAGE_JAPANESE = 8 cc.LANGUAGE_HUNGARIAN = 9 cc.LANGUAGE_PORTUGUESE = 10 cc.LANGUAGE_ARABIC = 11 cc.NODE_ON_ENTER = 0 cc.NODE_ON_EXIT = 1 cc.NODE_ON_ENTER_TRANSITION_DID_FINISH = 2 cc.NODE_ON_EXIT_TRANSITION_DID_START = 3 cc.NODE_ON_CLEAN_UP = 4 cc.CONTROL_STEPPER_PART_MINUS = 0 cc.CONTROL_STEPPER_PART_PLUS = 1 cc.CONTROL_STEPPER_PART_NONE = 2 cc.TABLEVIEW_FILL_TOPDOWN = 0 cc.TABLEVIEW_FILL_BOTTOMUP = 1 cc.WEBSOCKET_OPEN = 0 cc.WEBSOCKET_MESSAGE = 1 cc.WEBSOCKET_CLOSE = 2 cc.WEBSOCKET_ERROR = 3 cc.WEBSOCKET_STATE_CONNECTING = 0 cc.WEBSOCKET_STATE_OPEN = 1 cc.WEBSOCKET_STATE_CLOSING = 2 cc.WEBSOCKET_STATE_CLOSED = 3 cc.XMLHTTPREQUEST_RESPONSE_STRING = 0 cc.XMLHTTPREQUEST_RESPONSE_ARRAY_BUFFER = 1 cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2 cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3 cc.XMLHTTPREQUEST_RESPONSE_JSON = 4 cc.ASSETSMANAGER_CREATE_FILE = 0 cc.ASSETSMANAGER_NETWORK = 1 cc.ASSETSMANAGER_NO_NEW_VERSION = 2 cc.ASSETSMANAGER_UNCOMPRESS = 3 cc.ASSETSMANAGER_PROTOCOL_PROGRESS = 0 cc.ASSETSMANAGER_PROTOCOL_SUCCESS = 1 cc.ASSETSMANAGER_PROTOCOL_ERROR = 2 cc.Handler = cc.Handler or {} cc.Handler.NODE = 0 cc.Handler.MENU_CLICKED = 1 cc.Handler.CALLFUNC = 2 cc.Handler.SCHEDULE = 3 cc.Handler.TOUCHES = 4 cc.Handler.KEYPAD = 5 cc.Handler.ACCELEROMETER = 6 cc.Handler.CONTROL_TOUCH_DOWN = 7 cc.Handler.CONTROL_TOUCH_DRAG_INSIDE = 8 cc.Handler.CONTROL_TOUCH_DRAG_OUTSIDE = 9 cc.Handler.CONTROL_TOUCH_DRAG_ENTER = 10 cc.Handler.CONTROL_TOUCH_DRAG_EXIT = 11 cc.Handler.CONTROL_TOUCH_UP_INSIDE = 12 cc.Handler.CONTROL_TOUCH_UP_OUTSIDE = 13 cc.Handler.CONTROL_TOUCH_UP_CANCEL = 14 cc.Handler.CONTROL_VALUE_CHANGED = 15 cc.Handler.WEBSOCKET_OPEN = 16 cc.Handler.WEBSOCKET_MESSAGE = 17 cc.Handler.WEBSOCKET_CLOSE = 18 cc.Handler.WEBSOCKET_ERROR = 19 cc.Handler.GL_NODE_DRAW = 20 cc.Handler.SCROLLVIEW_SCROLL = 21 cc.Handler.SCROLLVIEW_ZOOM = 22 cc.Handler.TABLECELL_TOUCHED = 23 cc.Handler.TABLECELL_HIGHLIGHT = 24 cc.Handler.TABLECELL_UNHIGHLIGHT = 25 cc.Handler.TABLECELL_WILL_RECYCLE = 26 cc.Handler.TABLECELL_SIZE_FOR_INDEX = 27 cc.Handler.TABLECELL_AT_INDEX = 28 cc.Handler.TABLEVIEW_NUMS_OF_CELLS = 29 cc.Handler.HTTPREQUEST_STATE_CHANGE = 30 cc.Handler.ASSETSMANAGER_PROGRESS = 31 cc.Handler.ASSETSMANAGER_SUCCESS = 32 cc.Handler.ASSETSMANAGER_ERROR = 33 cc.Handler.STUDIO_EVENT_LISTENER = 34 cc.Handler.ARMATURE_EVENT = 35 cc.Handler.EVENT_ACC = 36 cc.Handler.EVENT_CUSTIOM = 37 cc.Handler.EVENT_KEYBOARD_PRESSED = 38 cc.Handler.EVENT_KEYBOARD_RELEASED = 39 cc.Handler.EVENT_TOUCH_BEGAN = 40 cc.Handler.EVENT_TOUCH_MOVED = 41 cc.Handler.EVENT_TOUCH_ENDED = 42 cc.Handler.EVENT_TOUCH_CANCELLED = 43 cc.Handler.EVENT_TOUCHES_BEGAN = 44 cc.Handler.EVENT_TOUCHES_MOVED = 45 cc.Handler.EVENT_TOUCHES_ENDED = 46 cc.Handler.EVENT_TOUCHES_CANCELLED = 47 cc.Handler.EVENT_MOUSE_DOWN = 48 cc.Handler.EVENT_MOUSE_UP = 49 cc.Handler.EVENT_MOUSE_MOVE = 50 cc.Handler.EVENT_MOUSE_SCROLL = 51 cc.Handler.EVENT_SPINE = 52 cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN = 53 cc.Handler.EVENT_PHYSICS_CONTACT_PRESOLVE = 54 cc.Handler.EVENT_PHYSICS_CONTACT_POSTSOLVE = 55 cc.Handler.EVENT_PHYSICS_CONTACT_SEPERATE = 56 cc.EVENT_UNKNOWN = 0 cc.EVENT_TOUCH_ONE_BY_ONE = 1 cc.EVENT_TOUCH_ALL_AT_ONCE = 2 cc.EVENT_KEYBOARD = 3 cc.EVENT_MOUSE = 4 cc.EVENT_ACCELERATION = 5 cc.EVENT_CUSTOM = 6 cc.PHYSICSSHAPE_MATERIAL_DEFAULT = {density = 0.0, restitution = 0.5, friction = 0.5} cc.PHYSICSBODY_MATERIAL_DEFAULT = {density = 0.1, restitution = 0.5, friction = 0.5} cc.GLYPHCOLLECTION_DYNAMIC = 0 cc.GLYPHCOLLECTION_NEHE = 1 cc.GLYPHCOLLECTION_ASCII = 2 cc.GLYPHCOLLECTION_CUSTOM = 3 cc.LabelEffect = { NORMAL = 0, OUTLINE = 1, SHADOW = 2, GLOW = 3, } cc.KeyCode = { KEY_NONE = 0, KEY_PAUSE = 0x0013, KEY_SCROLL_LOCK = 0x1014, KEY_PRINT = 0x1061, KEY_SYSREQ = 0x106A, KEY_BREAK = 0x106B, KEY_ESCAPE = 0x001B, KEY_BACKSPACE = 0x0008, KEY_TAB = 0x0009, KEY_BACK_TAB = 0x0089, KEY_RETURN = 0x000D, KEY_CAPS_LOCK = 0x00E5, KEY_SHIFT = 0x00E1, KEY_CTRL = 0x00E3, KEY_ALT = 0x00E9, KEY_MENU = 0x1067, KEY_HYPER = 0x10ED, KEY_INSERT = 0x1063, KEY_HOME = 0x1050, KEY_PG_UP = 0x1055, KEY_DELETE = 0x10FF, KEY_END = 0x1057, KEY_PG_DOWN = 0x1056, KEY_LEFT_ARROW = 0x1051, KEY_RIGHT_ARROW = 0x1053, KEY_UP_ARROW = 0x1052, KEY_DOWN_ARROW = 0x1054, KEY_NUM_LOCK = 0x107F, KEY_KP_PLUS = 0x10AB, KEY_KP_MINUS = 0x10AD, KEY_KP_MULTIPLY = 0x10AA, KEY_KP_DIVIDE = 0x10AF, KEY_KP_ENTER = 0x108D, KEY_KP_HOME = 0x10B7, KEY_KP_UP = 0x10B8, KEY_KP_PG_UP = 0x10B9, KEY_KP_LEFT = 0x10B4, KEY_KP_FIVE = 0x10B5, KEY_KP_RIGHT = 0x10B6, KEY_KP_END = 0x10B1, KEY_KP_DOWN = 0x10B2, KEY_KP_PG_DOWN = 0x10B3, KEY_KP_INSERT = 0x10B0, KEY_KP_DELETE = 0x10AE, KEY_F1 = 0x00BE, KEY_F2 = 0x00BF, KEY_F3 = 0x00C0, KEY_F4 = 0x00C1, KEY_F5 = 0x00C2, KEY_F6 = 0x00C3, KEY_F7 = 0x00C4, KEY_F8 = 0x00C5, KEY_F9 = 0x00C6, KEY_F10 = 0x00C7, KEY_F11 = 0x00C8, KEY_F12 = 0x00C9, KEY_SPACE = ' ', KEY_EXCLAM = '!', KEY_QUOTE = '"', KEY_NUMBER = '#', KEY_DOLLAR = '$', KEY_PERCENT = '%', KEY_CIRCUMFLEX = '^', KEY_AMPERSAND = '&', KEY_APOSTROPHE = '\'', KEY_LEFT_PARENTHESIS = '(', KEY_RIGHT_PARENTHESIS = ')', KEY_ASTERISK = '*', KEY_PLUS = '+', KEY_COMMA = ',', KEY_MINUS = '-', KEY_PERIOD = '.', KEY_SLASH = '/', KEY_0 = '0', KEY_1 = '1', KEY_2 = '2', KEY_3 = '3', KEY_4 = '4', KEY_5 = '5', KEY_6 = '6', KEY_7 = '7', KEY_8 = '8', KEY_9 = '9', KEY_COLON = ':', KEY_SEMICOLON = ';', KEY_LESS_THAN = '<', KEY_EQUAL = '=', KEY_GREATER_THAN = '>', KEY_QUESTION = '?', KEY_AT = '@', KEY_CAPITAL_A = 'A', KEY_CAPITAL_B = 'B', KEY_CAPITAL_C = 'C', KEY_CAPITAL_D = 'D', KEY_CAPITAL_E = 'E', KEY_CAPITAL_F = 'F', KEY_CAPITAL_G = 'G', KEY_CAPITAL_H = 'H', KEY_CAPITAL_I = 'I', KEY_CAPITAL_J = 'J', KEY_CAPITAL_K = 'K', KEY_CAPITAL_L = 'L', KEY_CAPITAL_M = 'M', KEY_CAPITAL_N = 'N', KEY_CAPITAL_O = 'O', KEY_CAPITAL_P = 'P', KEY_CAPITAL_Q = 'Q', KEY_CAPITAL_R = 'R', KEY_CAPITAL_S = 'S', KEY_CAPITAL_T = 'T', KEY_CAPITAL_U = 'U', KEY_CAPITAL_V = 'V', KEY_CAPITAL_W = 'W', KEY_CAPITAL_X = 'X', KEY_CAPITAL_Y = 'Y', KEY_CAPITAL_Z = 'Z', KEY_LEFT_BRACKET = '[', KEY_BACK_SLASH = '\\', KEY_RIGHT_BRACKET = ']', KEY_UNDERSCORE = '_', KEY_GRAVE = '`', KEY_A = 'a', KEY_B = 'b', KEY_C = 'c', KEY_D = 'd', KEY_E = 'e', KEY_F = 'f', KEY_G = 'g', KEY_H = 'h', KEY_I = 'i', KEY_J = 'j', KEY_K = 'k', KEY_L = 'l', KEY_M = 'm', KEY_N = 'n', KEY_O = 'o', KEY_P = 'p', KEY_Q = 'q', KEY_R = 'r', KEY_S = 's', KEY_T = 't', KEY_U = 'u', KEY_V = 'v', KEY_W = 'w', KEY_X = 'x', KEY_Y = 'y', KEY_Z = 'z', KEY_LEFT_BRACE = '{', KEY_BAR = '|', KEY_RIGHT_BRACE = '}', KEY_TILDE = '~', KEY_EURO = 0x20AC, KEY_POUND = 0x00A3, KEY_YEN = 0x00A5, KEY_MIDDLE_DOT = 0x0095, KEY_SEARCH = 0xFFAA, }; ================================================ FILE: cocos2d/cocos/scripting/lua/script/Deprecated.lua ================================================ require "Cocos2d.lua" --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") end --functions of CCDirector will be deprecated,begin local CCDirectorDeprecated = { } function CCDirectorDeprecated.sharedDirector() deprecatedTip("CCDirector:sharedDirector","cc.Director:getInstance") return cc.Director:getInstance() end rawset(CCDirector,"sharedDirector",CCDirectorDeprecated.sharedDirector) --functions of CCDirector will be deprecated,end --functions of CCTextureCache will be deprecated begin local TextureCacheDeprecated = {} function TextureCacheDeprecated.getInstance(self) deprecatedTip("cc.TextureCache:getInstance","cc.Director:getInstance():getTextureCache") return cc.Director:getInstance():getTextureCache() end rawset(cc.TextureCache,"getInstance",TextureCacheDeprecated.getInstance) function TextureCacheDeprecated.destroyInstance(self) deprecatedTip("cc.TextureCache:destroyInstance","cc.Director:getInstance():destroyTextureCache") return cc.Director:getInstance():destroyTextureCache() end rawset(cc.TextureCache,"destroyInstance",TextureCacheDeprecated.destroyInstance) function TextureCacheDeprecated.dumpCachedTextureInfo(self) deprecatedTip("self:dumpCachedTextureInfo","self:getCachedTextureInfo") return print(self:getCachedTextureInfo()) end rawset(cc.TextureCache,"dumpCachedTextureInfo",TextureCacheDeprecated.dumpCachedTextureInfo) local CCTextureCacheDeprecated = { } function CCTextureCacheDeprecated.sharedTextureCache() deprecatedTip("CCTextureCache:sharedTextureCache","CCTextureCache:getInstance") return cc.TextureCache:getInstance() end rawset(CCTextureCache,"sharedTextureCache",CCTextureCacheDeprecated.sharedTextureCache) function CCTextureCacheDeprecated.purgeSharedTextureCache() deprecatedTip("CCTextureCache:purgeSharedTextureCache","CCTextureCache:destroyInstance") return cc.TextureCache:destroyInstance() end rawset(CCTextureCache,"purgeSharedTextureCache",CCTextureCacheDeprecated.purgeSharedTextureCache) function CCTextureCacheDeprecated.addUIImage(self, image, key) deprecatedTip("CCTextureCache:addUIImage","CCTextureCache:addImage") return self:addImage(image,key) end rawset(CCTextureCache,"addUIImage",CCTextureCacheDeprecated.addUIImage) --functions of CCTextureCache will be deprecated end --functions of CCAnimation will be deprecated begin local CCAnimationDeprecated = {} function CCAnimationDeprecated.addSpriteFrameWithFileName(self,...) deprecatedTip("CCAnimationDeprecated:addSpriteFrameWithFileName","cc.Animation:addSpriteFrameWithFile") return self:addSpriteFrameWithFile(...) end rawset(CCAnimation,"addSpriteFrameWithFileName",CCAnimationDeprecated.addSpriteFrameWithFileName) --functions of CCAnimation will be deprecated end --functions of CCAnimationCache will be deprecated begin local CCAnimationCacheDeprecated = { } function CCAnimationCacheDeprecated.sharedAnimationCache() deprecatedTip("CCAnimationCache:sharedAnimationCache","CCAnimationCache:getInstance") return CCAnimationCache:getInstance() end rawset(CCAnimationCache,"sharedAnimationCache",CCAnimationCacheDeprecated.sharedAnimationCache) function CCAnimationCacheDeprecated.purgeSharedAnimationCache() deprecatedTip("CCAnimationCache:purgeSharedAnimationCache","CCAnimationCache:destroyInstance") return CCAnimationCache:destroyInstance() end rawset(CCAnimationCache,"purgeSharedAnimationCache",CCAnimationCacheDeprecated.purgeSharedAnimationCache) function CCAnimationCacheDeprecated.addAnimationsWithFile(self,...) deprecatedTip("CCAnimationCache:addAnimationsWithFile","cc.AnimationCache:addAnimations") return self:addAnimations(...) end rawset(CCAnimationCache,"addAnimationsWithFile",CCAnimationCacheDeprecated.addAnimationsWithFile) function CCAnimationCacheDeprecated.animationByName(self,...) deprecatedTip("CCAnimationCache:animationByName","cc.AnimationCache:getAnimation") return self:getAnimation(...) end rawset(CCAnimationCache,"animationByName",CCAnimationCacheDeprecated.animationByName) function CCAnimationCacheDeprecated.removeAnimationByName(self) deprecatedTip("CCAnimationCache:removeAnimationByName","cc.AnimationCache:removeAnimation") return self:removeAnimation() end rawset(CCAnimationCache,"removeAnimationByName",CCAnimationCacheDeprecated.removeAnimationByName) --functions of CCAnimationCache will be deprecated end --functions of CCFileUtils will be deprecated end local CCFileUtilsDeprecated = { } function CCFileUtilsDeprecated.sharedFileUtils() deprecatedTip("CCFileUtils:sharedFileUtils","CCFileUtils:getInstance") return cc.FileUtils:getInstance() end rawset(CCFileUtils,"sharedFileUtils",CCFileUtilsDeprecated.sharedFileUtils) function CCFileUtilsDeprecated.purgeFileUtils() deprecatedTip("CCFileUtils:purgeFileUtils","CCFileUtils:destroyInstance") return cc.FileUtils:destroyInstance() end rawset(CCFileUtils,"purgeFileUtils",CCFileUtilsDeprecated.purgeFileUtils) --functions of CCFileUtils will be deprecated end --functions of SimpleAudioEngine will be deprecated begin local SimpleAudioEngineDeprecated = { } function SimpleAudioEngineDeprecated.sharedEngine() deprecatedTip("SimpleAudioEngine:sharedEngine","SimpleAudioEngine:getInstance") return cc.SimpleAudioEngine:getInstance() end rawset(SimpleAudioEngine,"sharedEngine",SimpleAudioEngineDeprecated.sharedEngine) function SimpleAudioEngineDeprecated.playBackgroundMusic(self,...) deprecatedTip("SimpleAudioEngine:playBackgroundMusic","SimpleAudioEngine:playMusic") return self:playMusic(...) end rawset(SimpleAudioEngine,"playBackgroundMusic",SimpleAudioEngineDeprecated.playBackgroundMusic) --functions of SimpleAudioEngine will be deprecated end --functions of CCMenu will be deprecated begin local CCMenuDeprecated = { } function CCMenuDeprecated.createWithItem(self,...) deprecatedTip("CCMenuDeprecated:createWithItem","cc.Menu:createWithItem") return self:create(...) end rawset(CCMenu,"createWithItem",CCMenuDeprecated.createWithItem) function CCMenuDeprecated.setHandlerPriority(self) print("\n********** \n".."setHandlerPriority was deprecated in 3.0. \n**********") end rawset(CCMenu,"setHandlerPriority",CCMenuDeprecated.setHandlerPriority) --functions of CCMenu will be deprecated end --functions of CCNode will be deprecated begin local CCNodeDeprecated = { } function CCNodeDeprecated.boundingBox(self) deprecatedTip("CCNode:boundingBox","cc.Node:getBoundingBox") return self:getBoundingBox() end rawset(CCNode,"boundingBox",CCNodeDeprecated.boundingBox) function CCNodeDeprecated.numberOfRunningActions(self) deprecatedTip("CCNode:numberOfRunningActions","cc.Node:getNumberOfRunningActions") return self:getNumberOfRunningActions() end rawset(CCNode,"numberOfRunningActions",CCNodeDeprecated.numberOfRunningActions) function CCNodeDeprecated.removeFromParentAndCleanup(self,...) deprecatedTip("CCNode:removeFromParentAndCleanup","cc.Node:removeFromParent") return self:removeFromParent(...) end rawset(CCNode,"removeFromParentAndCleanup",CCNodeDeprecated.removeFromParentAndCleanup) --functions of CCNode will be deprecated end --CCDrawPrimitives will be deprecated begin local function CCDrawPrimitivesClassDeprecated() deprecatedTip("CCDrawPrimitives","cc.DrawPrimitives") return cc.DrawPrimitives end _G["CCDrawPrimitives"] = CCDrawPrimitivesClassDeprecated() --functions of CCDrawPrimitives will be deprecated begin local CCDrawPrimitivesDeprecated = { } function CCDrawPrimitivesDeprecated.ccDrawPoint(pt) deprecatedTip("ccDrawPoint","cc.DrawPrimitives.drawPoint") return cc.DrawPrimitives.drawPoint(pt) end rawset(_G, "ccDrawPoint", CCDrawPrimitivesDeprecated.ccDrawPoint) function CCDrawPrimitivesDeprecated.ccDrawLine(origin,destination) deprecatedTip("ccDrawLine","cc.DrawPrimitives.drawLine") return cc.DrawPrimitives.drawLine(origin,destination) end rawset(_G, "ccDrawLine", CCDrawPrimitivesDeprecated.ccDrawLine) function CCDrawPrimitivesDeprecated.ccDrawRect(origin,destination) deprecatedTip("ccDrawRect","cc.DrawPrimitives.drawRect") return cc.DrawPrimitives.drawRect(origin,destination) end rawset(_G, "ccDrawRect", CCDrawPrimitivesDeprecated.ccDrawRect) function CCDrawPrimitivesDeprecated.ccDrawSolidRect(origin,destination,color) deprecatedTip("ccDrawSolidRect","cc.DrawPrimitives.drawSolidRect") return cc.DrawPrimitives.drawSolidRect(origin,destination,color) end rawset(_G, "ccDrawSolidRect", CCDrawPrimitivesDeprecated.ccDrawSolidRect) -- params:... may represent two param(xScale,yScale) or nil function CCDrawPrimitivesDeprecated.ccDrawCircle(center,radius,angle,segments,drawLineToCenter,...) deprecatedTip("ccDrawCircle","cc.DrawPrimitives.drawCircle") return cc.DrawPrimitives.drawCircle(center,radius,angle,segments,drawLineToCenter,...) end rawset(_G, "ccDrawCircle", CCDrawPrimitivesDeprecated.ccDrawCircle) -- params:... may represent two param(xScale,yScale) or nil function CCDrawPrimitivesDeprecated.ccDrawSolidCircle(center,radius,angle,segments,...) deprecatedTip("ccDrawSolidCircle","cc.DrawPrimitives.drawSolidCircle") return cc.DrawPrimitives.drawSolidCircle(center,radius,angle,segments,...) end rawset(_G, "ccDrawSolidCircle", CCDrawPrimitivesDeprecated.ccDrawSolidCircle) function CCDrawPrimitivesDeprecated.ccDrawQuadBezier(origin,control,destination,segments) deprecatedTip("ccDrawQuadBezier","cc.DrawPrimitives.drawQuadBezier") return cc.DrawPrimitives.drawQuadBezier(origin,control,destination,segments) end rawset(_G, "ccDrawQuadBezier", CCDrawPrimitivesDeprecated.ccDrawQuadBezier) function CCDrawPrimitivesDeprecated.ccDrawCubicBezier(origin,control1,control2,destination,segments) deprecatedTip("ccDrawCubicBezier","cc.DrawPrimitives.drawCubicBezier") return cc.DrawPrimitives.drawCubicBezier(origin,control1,control2,destination,segments) end rawset(_G, "ccDrawCubicBezier", CCDrawPrimitivesDeprecated.ccDrawCubicBezier) function CCDrawPrimitivesDeprecated.ccDrawCatmullRom(arrayOfControlPoints,segments) deprecatedTip("ccDrawCatmullRom","cc.DrawPrimitives.drawCatmullRom") return cc.DrawPrimitives.drawCatmullRom(arrayOfControlPoints,segments) end rawset(_G, "ccDrawCatmullRom", CCDrawPrimitivesDeprecated.ccDrawCatmullRom) function CCDrawPrimitivesDeprecated.ccDrawCardinalSpline(config,tension,segments) deprecatedTip("ccDrawCardinalSpline","cc.DrawPrimitives.drawCardinalSpline") return cc.DrawPrimitives.drawCardinalSpline(config,tension,segments) end rawset(_G, "ccDrawCardinalSpline", CCDrawPrimitivesDeprecated.ccDrawCardinalSpline) function CCDrawPrimitivesDeprecated.ccDrawColor4B(r,g,b,a) deprecatedTip("ccDrawColor4B","cc.DrawPrimitives.drawColor4B") return cc.DrawPrimitives.drawColor4B(r,g,b,a) end rawset(_G, "ccDrawColor4B", CCDrawPrimitivesDeprecated.ccDrawColor4B) function CCDrawPrimitivesDeprecated.ccDrawColor4F(r,g,b,a) deprecatedTip("ccDrawColor4F","cc.DrawPrimitives.drawColor4F") return cc.DrawPrimitives.drawColor4F(r,g,b,a) end rawset(_G, "ccDrawColor4F", CCDrawPrimitivesDeprecated.ccDrawColor4F) function CCDrawPrimitivesDeprecated.ccPointSize(pointSize) deprecatedTip("ccPointSize","cc.DrawPrimitives.setPointSize") return cc.DrawPrimitives.setPointSize(pointSize) end rawset(_G, "ccPointSize", CCDrawPrimitivesDeprecated.ccPointSize) --functions of CCDrawPrimitives will be deprecated end --CCDrawPrimitives will be deprecated end local CCProgressTimerDeprecated = {} function CCProgressTimerDeprecated.setReverseProgress(self,...) deprecatedTip("CCProgressTimer","CCProgressTimer:setReverseDirection") return self:setReverseDirection(...) end rawset(CCProgressTimer,"setReverseProgress",CCProgressTimerDeprecated.setReverseProgress) --functions of CCSpriteFrameCache will be deprecated begin local CCSpriteFrameCacheDeprecated = { } function CCSpriteFrameCacheDeprecated.spriteFrameByName(self,szName) deprecatedTip("CCSpriteFrameCache:spriteFrameByName","CCSpriteFrameCache:getSpriteFrameByName") return self:getSpriteFrameByName(szName) end rawset(CCSpriteFrameCache,"spriteFrameByName",CCSpriteFrameCacheDeprecated.spriteFrameByName) function CCSpriteFrameCacheDeprecated.sharedSpriteFrameCache() deprecatedTip("CCSpriteFrameCache:sharedSpriteFrameCache","CCSpriteFrameCache:getInstance") return CCSpriteFrameCache:getInstance() end rawset(CCSpriteFrameCache,"sharedSpriteFrameCache",CCSpriteFrameCacheDeprecated.sharedSpriteFrameCache) function CCSpriteFrameCacheDeprecated.purgeSharedSpriteFrameCache() deprecatedTip("CCSpriteFrameCache:purgeSharedSpriteFrameCache","CCSpriteFrameCache:destroyInstance") return CCSpriteFrameCache:destroyInstance() end rawset(CCSpriteFrameCache,"purgeSharedSpriteFrameCache",CCSpriteFrameCacheDeprecated.purgeSharedSpriteFrameCache) function CCSpriteFrameCacheDeprecated.addSpriteFramesWithFile(self,...) deprecatedTip("CCSpriteFrameCache:addSpriteFramesWithFile","CCSpriteFrameCache:addSpriteFrames") return self:addSpriteFrames(...) end rawset(CCSpriteFrameCache,"addSpriteFramesWithFile",CCSpriteFrameCacheDeprecated.addSpriteFramesWithFile) function CCSpriteFrameCacheDeprecated.getSpriteFrameByName(self,...) deprecatedTip("CCSpriteFrameCache:getSpriteFrameByName","CCSpriteFrameCache:getSpriteFrame") return self:getSpriteFrame(...) end rawset(CCSpriteFrameCache,"getSpriteFrameByName",CCSpriteFrameCacheDeprecated.getSpriteFrameByName) --functions of CCSpriteFrameCache will be deprecated end --functions of CCLabelAtlas will be deprecated begin local CCLabelAtlasDeprecated = {} function CCLabelAtlasDeprecated.create(self,...) deprecatedTip("CCLabelAtlas:create","CCLabelAtlas:_create") return self:_create(...) end rawset(CCLabelAtlas,"create",CCLabelAtlasDeprecated.create) --functions of CCLabelAtlas will be deprecated end --------------------------- --global functions wil be deprecated, begin local function CCRectMake(x,y,width,height) deprecatedTip("CCRectMake(x,y,width,height)","cc.rect(x,y,width,height) in lua") return cc.rect(x,y,width,height) end rawset(_G,"CCRectMake",CCRectMake) local function ccc3(r,g,b) deprecatedTip("ccc3(r,g,b)","cc.c3b(r,g,b)") return cc.c3b(r,g,b) end rawset(_G,"ccc3",ccc3) local function ccp(x,y) deprecatedTip("ccp(x,y)","cc.p(x,y)") return cc.p(x,y) end rawset(_G,"ccp",ccp) local function CCSizeMake(width,height) deprecatedTip("CCSizeMake(width,height)","cc.size(width,height)") return cc.size(width,height) end rawset(_G,"CCSizeMake",CCSizeMake) local function ccc4(r,g,b,a) deprecatedTip("ccc4(r,g,b,a)","cc.c4b(r,g,b,a)") return cc.c4b(r,g,b,a) end rawset(_G,"ccc4",ccc4) local function ccc4FFromccc3B(color3B) deprecatedTip("ccc4FFromccc3B(color3B)","cc.c4f(color3B.r / 255.0,color3B.g / 255.0,color3B.b / 255.0,1.0)") return cc.c4f(color3B.r/255.0, color3B.g/255.0, color3B.b/255.0, 1.0) end rawset(_G,"ccc4FFromccc3B",ccc4FFromccc3B) local function ccc4f(r,g,b,a) deprecatedTip("ccc4f(r,g,b,a)","cc.c4f(r,g,b,a)") return cc.c4f(r,g,b,a) end rawset(_G,"ccc4f",ccc4f) local function ccc4FFromccc4B(color4B) deprecatedTip("ccc4FFromccc4B(color4B)","cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0)") return cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0) end rawset(_G,"ccc4FFromccc4B",ccc4FFromccc4B) local function ccc4FEqual(a,b) deprecatedTip("ccc4FEqual(a,b)","a:equals(b)") return a:equals(b) end rawset(_G,"ccc4FEqual",ccc4FEqual) --global functions wil be deprecated, end --functions of _G will be deprecated begin local function ccpLineIntersect(a,b,c,d,s,t) deprecatedTip("ccpLineIntersect","cc.pIsLineIntersect") return cc.pIsLineIntersect(a,b,c,d,s,t) end rawset(_G,"ccpLineIntersect",ccpLineIntersect) local function CCPointMake(x,y) deprecatedTip("CCPointMake(x,y)","cc.p(x,y)") return cc.p(x,y) end rawset(_G,"CCPointMake",CCPointMake) local function ccpNeg(pt) deprecatedTip("ccpNeg","cc.pSub") return cc.pSub({x = 0,y = 0}, pt) end rawset(_G,"ccpNeg",ccpNeg) local function ccpAdd(pt1,pt2) deprecatedTip("ccpAdd","cc.pAdd") return cc.pAdd(pt1,pt2) end rawset(_G,"ccpAdd",ccpAdd) local function ccpSub(pt1,pt2) deprecatedTip("ccpSub","cc.pSub") return cc.pSub(pt1,pt2) end rawset(_G,"ccpSub",ccpSub) local function ccpMult(pt,factor) deprecatedTip("ccpMult","cc.pMul") return cc.pMul(pt,factor) end rawset(_G,"ccpMult",ccpMult) local function ccpMidpoint(pt1,pt2) deprecatedTip("ccpMidpoint","cc.pMidpoint") return cc.pMidpoint(pt1,pt2) end rawset(_G,"ccpMidpoint",ccpMidpoint) local function ccpDot(pt1,pt2) deprecatedTip("ccpDot","cc.pDot") return cc.pDot(pt1,pt2) end rawset(_G,"ccpDot",ccpDot) local function ccpCross(pt1,pt2) deprecatedTip("ccpCross","cc.pCross") return cc.pCross(pt1, pt2) end rawset(_G,"ccpCross",ccpCross) local function ccpPerp(pt) deprecatedTip("ccpPerp","cc.pPerp") return cc.pPerp(pt) end rawset(_G,"ccpPerp",ccpPerp) local function ccpRPerp(pt) deprecatedTip("ccpRPerp","cc.RPerp") return cc.RPerp(pt) end rawset(_G,"ccpRPerp",ccpRPerp) local function ccpProject(pt1,pt2) deprecatedTip("ccpProject","cc.pProject") return cc.pProject(pt1,pt2) end rawset(_G,"ccpProject",ccpProject) local function ccpRotate(pt1,pt2) deprecatedTip("ccpRotate","cc.pRotate") return cc.pRotate(pt1,pt2) end rawset(_G,"ccpRotate",ccpRotate) local function ccpUnrotate(pt1,pt2) deprecatedTip("ccpUnrotate","cc.pUnrotate") return cc.pUnrotate(pt1,pt2) end rawset(_G,"ccpUnrotate",ccpUnrotate) local function ccpLengthSQ(pt) deprecatedTip("ccpLengthSQ","cc.pLengthSQ") return cc.pLengthSQ(pt) end rawset(_G,"ccpLengthSQ",ccpLengthSQ) local function ccpDistanceSQ(pt1,pt2) deprecatedTip("ccpDistanceSQ","cc.pDistanceSQ") return cc.pDistanceSQ(pt1,pt2) end rawset(_G,"ccpDistanceSQ",ccpDistanceSQ) local function ccpLength(pt) deprecatedTip("ccpLength","cc.pGetLength") return cc.pGetLength(pt) end rawset(_G,"ccpLength",ccpLength) local function ccpDistance(pt1,pt2) deprecatedTip("ccpDistance","cc.pGetDistance") return cc.pGetDistance(pt1, pt2) end rawset(_G,"ccpDistance",ccpDistance) local function ccpNormalize(pt) deprecatedTip("ccpNormalize","cc.pNormalize") return cc.pNormalize(pt) end rawset(_G,"ccpNormalize",ccpNormalize) local function ccpForAngle(angle) deprecatedTip("ccpForAngle","cc.pForAngle") return cc.pForAngle(angle) end rawset(_G,"ccpForAngle",ccpForAngle) local function ccpToAngle(pt) deprecatedTip("ccpToAngle","cc.pToAngleSelf") return cc.pToAngleSelf(pt) end rawset(_G,"ccpToAngle",ccpToAngle) local function ccpClamp(pt1,pt2,pt3) deprecatedTip("ccpClamp","cc.pGetClampPoint") return cc.pGetClampPoint(pt1,pt2,pt3) end rawset(_G,"ccpClamp",ccpClamp) local function ccpFromSize(sz) deprecatedTip("ccpFromSize(sz)","cc.pFromSize") return cc.pFromSize(sz) end rawset(_G,"ccpFromSize",ccpFromSize) local function ccpLerp(pt1,pt2,alpha) deprecatedTip("ccpLerp","cc.pLerp") return cc.pLerp(pt1,pt2,alpha) end rawset(_G,"ccpLerp",ccpLerp) local function ccpFuzzyEqual(pt1,pt2,variance) deprecatedTip("ccpFuzzyEqual","cc.pFuzzyEqual") return cc.pFuzzyEqual(pt1,pt2,variance) end rawset(_G,"ccpFuzzyEqual",ccpFuzzyEqual) local function ccpCompMult(pt1,pt2) deprecatedTip("ccpCompMult","cc.p") return cc.p(pt1.x * pt2.x , pt1.y * pt2.y) end rawset(_G,"ccpCompMult",ccpCompMult) local function ccpAngleSigned(pt1,pt2) deprecatedTip("ccpAngleSigned","cc.pGetAngle") return cc.pGetAngle(pt1, pt2) end rawset(_G,"ccpAngleSigned",ccpAngleSigned) local function ccpAngle(pt1,pt2) deprecatedTip("ccpAngle","cc.pGetAngle") return cc.pGetAngle(pt1,ptw) end rawset(_G,"ccpAngle",ccpAngle) local function ccpRotateByAngle(pt1,pt2,angle) deprecatedTip("ccpRotateByAngle","cc.pRotateByAngle") return cc.pRotateByAngle(pt1, pt2, angle) end rawset(_G,"ccpRotateByAngle",ccpRotateByAngle) local function ccpSegmentIntersect(pt1,pt2,pt3,pt4) deprecatedTip("ccpSegmentIntersect","cc.pIsSegmentIntersect") return cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4) end rawset(_G,"ccpSegmentIntersect",ccpSegmentIntersect) local function ccpIntersectPoint(pt1,pt2,pt3,pt4) deprecatedTip("ccpIntersectPoint","cc.pGetIntersectPoint") return cc.pGetIntersectPoint(pt1,pt2,pt3,pt4) end rawset(_G,"ccpIntersectPoint",ccpIntersectPoint) local function vertex2(x,y) deprecatedTip("vertex2(x,y)","cc.vertex2F(x,y)") return cc.vertex2F(x,y) end rawset(_G,"vertex2",vertex2) local function vertex3(x,y,z) deprecatedTip("vertex3(x,y,z)","cc.Vertex3F(x,y,z)") return cc.Vertex3F(x,y,z) end rawset(_G,"vertex3",vertex3) local function tex2(u,v) deprecatedTip("tex2(u,v)","cc.tex2f(u,v)") return cc.tex2f(u,v) end rawset(_G,"tex2",tex2) local function ccc4BFromccc4F(color4F) deprecatedTip("ccc4BFromccc4F(color4F)","Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0)") return Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0) end rawset(_G,"ccc4BFromccc4F",ccc4BFromccc4F) local function ccColor3BDeprecated() deprecatedTip("ccColor3B","cc.c3b(0,0,0)") return cc.c3b(0,0,0) end _G["ccColor3B"] = ccColor3BDeprecated local function ccColor4BDeprecated() deprecatedTip("ccColor4B","cc.c4b(0,0,0,0)") return cc.c4b(0,0,0,0) end _G["ccColor4B"] = ccColor4BDeprecated local function ccColor4FDeprecated() deprecatedTip("ccColor4F","cc.c4f(0.0,0.0,0.0,0.0)") return cc.c4f(0.0,0.0,0.0,0.0) end _G["ccColor4F"] = ccColor4FDeprecated local function ccVertex2FDeprecated() deprecatedTip("ccVertex2F","cc.vertex2F(0.0,0.0)") return cc.vertex2F(0.0,0.0) end _G["ccVertex2F"] = ccVertex2FDeprecated local function ccVertex3FDeprecated() deprecatedTip("ccVertex3F","cc.Vertex3F(0.0, 0.0, 0.0)") return cc.Vertex3F(0.0, 0.0, 0.0) end _G["ccVertex3F"] = ccVertex3FDeprecated local function ccTex2FDeprecated() deprecatedTip("ccTex2F","cc.tex2F(0.0, 0.0)") return cc.tex2F(0.0, 0.0) end _G["ccTex2F"] = ccTex2FDeprecated local function ccPointSpriteDeprecated() deprecatedTip("ccPointSprite","cc.PointSprite(cc.vertex2F(0.0, 0.0),cc.c4b(0.0, 0.0, 0.0),0)") return cc.PointSprite(cc.vertex2F(0.0, 0.0),cc.c4b(0.0, 0.0, 0.0),0) end _G["ccPointSprite"] = ccPointSpriteDeprecated local function ccQuad2Deprecated() deprecatedTip("ccQuad2","cc.Quad2(cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0))") return cc.Quad2(cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0)) end _G["ccQuad2"] = ccQuad2Deprecated local function ccQuad3Deprecated() deprecatedTip("ccQuad3","cc.Quad3(cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0))") return cc.Quad3(cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0)) end _G["ccQuad3"] = ccQuad3Deprecated local function ccV2FC4BT2FDeprecated() deprecatedTip("ccV2F_C4B_T2F","cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))") return cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)) end _G["ccV2F_C4B_T2F"] = ccV2FC4BT2FDeprecated local function ccV2FC4FT2FDeprecated() deprecatedTip("ccV2F_C4F_T2F","cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0 , 0.0 , 0.0 ), cc.tex2F(0.0, 0.0))") return cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0 , 0.0 , 0.0), cc.tex2F(0.0, 0.0)) end _G["ccV2F_C4F_T2F"] = ccV2FC4FT2FDeprecated local function ccV3FC4BT2FDeprecated() deprecatedTip("ccV3F_C4B_T2F","cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0 , 0, 0 ), cc.tex2F(0.0, 0.0))") return cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0 , 0, 0 ), cc.tex2F(0.0, 0.0)) end _G["ccV3F_C4B_T2F"] = ccV3FC4BT2FDeprecated local function ccV2FC4BT2FQuadDeprecated() deprecatedTip("ccV2F_C4B_T2F_Quad","cc.V2F_C4B_T2F_Quad(cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)))") return cc.V2F_C4B_T2F_Quad(cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))) end _G["ccV2F_C4B_T2F_Quad"] = ccV2FC4BT2FQuadDeprecated local function ccV3FC4BT2FQuadDeprecated() deprecatedTip("ccV3F_C4B_T2F_Quad","cc.V3F_C4B_T2F_Quad(_tl, _bl, _tr, _br)") return cc.V3F_C4B_T2F_Quad(cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))) end _G["ccV3F_C4B_T2F_Quad"] = ccV3FC4BT2FQuadDeprecated local function ccV2FC4FT2FQuadDeprecated() deprecatedTip("ccV2F_C4F_T2F_Quad","cc.V2F_C4F_T2F_Quad(_bl, _br, _tl, _tr)") return cc.V2F_C4F_T2F_Quad(cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0))) end _G["ccV2F_C4F_T2F_Quad"] = ccV2FC4FT2FQuadDeprecated local function ccT2FQuadDeprecated() deprecatedTip("ccT2F_Quad","cc.T2F_Quad(_bl, _br, _tl, _tr)") return cc.T2F_Quad(cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0)) end _G["ccT2F_Quad"] = ccT2FQuadDeprecated local function ccAnimationFrameDataDeprecated() deprecatedTip("ccAnimationFrameData","cc.AnimationFrameData( _texCoords, _delay, _size)") return cc.AnimationFrameData(cc.T2F_Quad(cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0)), 0, cc.size(0,0)) end _G["ccAnimationFrameData"] = ccAnimationFrameDataDeprecated local function tex2(u,v) deprecatedTip("tex2(u,v)","cc.tex2f(u,v)") return cc.tex2f(u,v) end rawset(_G,"tex2",tex2) --functions of CCControl will be deprecated end local CCControlDeprecated = { } function CCControlDeprecated.addHandleOfControlEvent(self,func,controlEvent) deprecatedTip("addHandleOfControlEvent","registerControlEventHandler") print("come in addHandleOfControlEvent") self:registerControlEventHandler(func,controlEvent) end rawset(CCControl,"addHandleOfControlEvent",CCControlDeprecated.addHandleOfControlEvent) --functions of CCControl will be deprecated end --functions of CCEGLView will be deprecated end local CCEGLViewDeprecated = { } function CCEGLViewDeprecated.sharedOpenGLView() deprecatedTip("CCEGLView:sharedOpenGLView","CCEGLView:getInstance") return CCEGLView:getInstance() end rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) --functions of CCFileUtils will be deprecated end --Enums of CCTableView will be deprecated begin rawset(CCTableView, "kTableViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) rawset(CCTableView,"kTableViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) rawset(CCTableView,"kTableCellTouched",cc.TABLECELL_TOUCHED) rawset(CCTableView,"kTableCellSizeForIndex",cc.TABLECELL_SIZE_FOR_INDEX) rawset(CCTableView,"kTableCellSizeAtIndex",cc.TABLECELL_SIZE_AT_INDEX) rawset(CCTableView,"kNumberOfCellsInTableView",cc.NUMBER_OF_CELLS_IN_TABLEVIEW) --Enums of CCTableView will be deprecated end --Enums of CCScrollView will be deprecated begin rawset(CCScrollView, "kScrollViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) rawset(CCScrollView,"kScrollViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) --Enums of CCScrollView will be deprecated end --functions of CCApplication will be deprecated end local CCApplicationDeprecated = { } function CCApplicationDeprecated.sharedApplication() deprecatedTip("CCApplication:sharedApplication","CCApplication:getInstance") return CCApplication:getInstance() end rawset(CCApplication,"sharedApplication",CCApplicationDeprecated.sharedApplication) --functions of CCApplication will be deprecated end --functions of CCDirector will be deprecated end local CCDirectorDeprecated = { } function CCDirectorDeprecated.sharedDirector() deprecatedTip("CCDirector:sharedDirector","CCDirector:getInstance") return CCDirector:getInstance() end rawset(CCDirector,"sharedDirector",CCDirectorDeprecated.sharedDirector) --functions of CCDirector will be deprecated end --functions of CCUserDefault will be deprecated end local CCUserDefaultDeprecated = { } function CCUserDefaultDeprecated.sharedUserDefault() deprecatedTip("CCUserDefault:sharedUserDefault","CCUserDefault:getInstance") return CCUserDefault:getInstance() end rawset(CCUserDefault,"sharedUserDefault",CCUserDefaultDeprecated.sharedUserDefault) function CCUserDefaultDeprecated.purgeSharedUserDefault() deprecatedTip("CCUserDefault:purgeSharedUserDefault","CCUserDefault:destroyInstance") return CCUserDefault:destroyInstance() end rawset(CCUserDefault,"purgeSharedUserDefault",CCUserDefaultDeprecated.purgeSharedUserDefault) --functions of CCUserDefault will be deprecated end --functions of CCGrid3DAction will be deprecated begin local CCGrid3DActionDeprecated = { } function CCGrid3DActionDeprecated.vertex(self,pt) deprecatedTip("vertex","CCGrid3DAction:getVertex") return self:getVertex(pt) end rawset(CCGrid3DAction,"vertex",CCGrid3DActionDeprecated.vertex) function CCGrid3DActionDeprecated.originalVertex(self,pt) deprecatedTip("originalVertex","CCGrid3DAction:getOriginalVertex") return self:getOriginalVertex(pt) end rawset(CCGrid3DAction,"originalVertex",CCGrid3DActionDeprecated.originalVertex) --functions of CCGrid3DAction will be deprecated end --functions of CCTiledGrid3DAction will be deprecated begin local CCTiledGrid3DActionDeprecated = { } function CCTiledGrid3DActionDeprecated.tile(self,pt) deprecatedTip("tile","CCTiledGrid3DAction:getTile") return self:getTile(pt) end rawset(CCTiledGrid3DAction,"tile",CCTiledGrid3DActionDeprecated.tile) function CCTiledGrid3DActionDeprecated.originalTile(self,pt) deprecatedTip("originalTile","CCTiledGrid3DAction:getOriginalTile") return self:getOriginalTile(pt) end rawset(CCTiledGrid3DAction,"originalTile",CCTiledGrid3DActionDeprecated.originalTile) --functions of CCTiledGrid3DAction will be deprecated end --functions of CCTexture2D will be deprecated begin local CCTexture2DDeprecated = { } function CCTexture2DDeprecated.stringForFormat(self) deprecatedTip("Texture2D:stringForFormat","Texture2D:getStringForFormat") return self:getStringForFormat() end rawset(CCTexture2D,"stringForFormat",CCTexture2DDeprecated.stringForFormat) function CCTexture2DDeprecated.bitsPerPixelForFormat(self) deprecatedTip("Texture2D:bitsPerPixelForFormat","Texture2D:getBitsPerPixelForFormat") return self:getBitsPerPixelForFormat() end rawset(CCTexture2D,"bitsPerPixelForFormat",CCTexture2DDeprecated.bitsPerPixelForFormat) function CCTexture2DDeprecated.bitsPerPixelForFormat(self,pixelFormat) deprecatedTip("Texture2D:bitsPerPixelForFormat","Texture2D:getBitsPerPixelForFormat") return self:getBitsPerPixelForFormat(pixelFormat) end rawset(CCTexture2D,"bitsPerPixelForFormat",CCTexture2DDeprecated.bitsPerPixelForFormat) function CCTexture2DDeprecated.defaultAlphaPixelFormat(self) deprecatedTip("Texture2D:defaultAlphaPixelFormat","Texture2D:getDefaultAlphaPixelFormat") return self:getDefaultAlphaPixelFormat() end rawset(CCTexture2D,"defaultAlphaPixelFormat",CCTexture2DDeprecated.defaultAlphaPixelFormat) --functions of CCTexture2D will be deprecated end --functions of CCTimer will be deprecated begin local CCTimerDeprecated = { } function CCTimerDeprecated.timerWithScriptHandler(handler,seconds) deprecatedTip("CCTimer:timerWithScriptHandler","CCTimer:createWithScriptHandler") return CCTimer:createWithScriptHandler(handler,seconds) end rawset(CCTimer,"timerWithScriptHandler",CCTimerDeprecated.timerWithScriptHandler) function CCTimerDeprecated.numberOfRunningActionsInTarget(self,target) deprecatedTip("CCActionManager:numberOfRunningActionsInTarget","CCActionManager:getNumberOfRunningActionsInTarget") return self:getNumberOfRunningActionsInTarget(target) end rawset(CCTimer,"numberOfRunningActionsInTarget",CCTimerDeprecated.numberOfRunningActionsInTarget) --functions of CCTimer will be deprecated end --functions of CCMenuItemFont will be deprecated begin local CCMenuItemFontDeprecated = { } function CCMenuItemFontDeprecated.fontSize() deprecatedTip("CCMenuItemFont:fontSize","CCMenuItemFont:getFontSize") return CCMenuItemFont:getFontSize() end rawset(CCMenuItemFont,"fontSize",CCMenuItemFontDeprecated.fontSize) function CCMenuItemFontDeprecated.fontName() deprecatedTip("CCMenuItemFont:fontName","CCMenuItemFont:getFontName") return CCMenuItemFont:getFontName() end rawset(CCMenuItemFont,"fontName",CCMenuItemFontDeprecated.fontName) function CCMenuItemFontDeprecated.fontSizeObj(self) deprecatedTip("CCMenuItemFont:fontSizeObj","CCMenuItemFont:getFontSizeObj") return self:getFontSizeObj() end rawset(CCMenuItemFont,"fontSizeObj",CCMenuItemFontDeprecated.fontSizeObj) function CCMenuItemFontDeprecated.fontNameObj(self) deprecatedTip("CCMenuItemFont:fontNameObj","CCMenuItemFont:getFontNameObj") return self:getFontNameObj() end rawset(CCMenuItemFont,"fontNameObj",CCMenuItemFontDeprecated.fontNameObj) --functions of CCMenuItemFont will be deprecated end --functions of CCMenuItemToggle will be deprecated begin local CCMenuItemToggleDeprecated = { } function CCMenuItemToggleDeprecated.selectedItem(self) deprecatedTip("CCMenuItemToggle:selectedItem","CCMenuItemToggle:getSelectedItem") return self:getSelectedItem() end rawset(CCMenuItemToggle,"selectedItem",CCMenuItemToggleDeprecated.selectedItem) --functions of CCMenuItemToggle will be deprecated end --functions of CCTileMapAtlas will be deprecated begin local CCTileMapAtlasDeprecated = { } function CCTileMapAtlasDeprecated.tileAt(self,pos) deprecatedTip("CCTileMapAtlas:tileAt","CCTileMapAtlas:getTileAt") return self:getTileAt(pos) end rawset(CCTileMapAtlas,"tileAt",CCTileMapAtlasDeprecated.tileAt) --functions of CCTileMapAtlas will be deprecated end --functions of CCTMXLayer will be deprecated begin local CCTMXLayerDeprecated = { } function CCTMXLayerDeprecated.tileAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:tileAt","CCTMXLayer:getTileAt") return self:getTileAt(tileCoordinate) end rawset(CCTMXLayer,"tileAt",CCTMXLayerDeprecated.tileAt) function CCTMXLayerDeprecated.tileGIDAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:tileGIDAt","CCTMXLayer:getTileGIDAt") return self:getTileGIDAt(tileCoordinate) end rawset(CCTMXLayer,"tileGIDAt",CCTMXLayerDeprecated.tileGIDAt) function CCTMXLayerDeprecated.positionAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:positionAt","CCTMXLayer:getPositionAt") return self:getPositionAt(tileCoordinate) end rawset(CCTMXLayer,"positionAt",CCTMXLayerDeprecated.positionAt) function CCTMXLayerDeprecated.propertyNamed(self,propertyName) deprecatedTip("CCTMXLayer:propertyNamed","CCTMXLayer:getProperty") return self:getProperty(propertyName) end rawset(CCTMXLayer,"propertyNamed",CCTMXLayerDeprecated.propertyNamed) --functions of CCTMXLayer will be deprecated end --functions of CCTMXTiledMap will be deprecated begin local CCTMXTiledMapDeprecated = { } function CCTMXTiledMapDeprecated.layerNamed(self,layerName) deprecatedTip("CCTMXTiledMap:layerNamed","CCTMXTiledMap:getLayer") return self:getLayer(layerName) end rawset(CCTMXTiledMap,"layerNamed", CCTMXTiledMapDeprecated.layerNamed) function CCTMXTiledMapDeprecated.propertyNamed(self,propertyName) deprecatedTip("CCTMXTiledMap:propertyNamed","CCTMXTiledMap:getProperty") return self:getProperty(propertyName) end rawset(CCTMXTiledMap,"propertyNamed", CCTMXTiledMapDeprecated.propertyNamed ) function CCTMXTiledMapDeprecated.propertiesForGID(self,GID) deprecatedTip("CCTMXTiledMap:propertiesForGID","CCTMXTiledMap:getPropertiesForGID") return self:getPropertiesForGID(GID) end rawset(CCTMXTiledMap,"propertiesForGID", CCTMXTiledMapDeprecated.propertiesForGID) function CCTMXTiledMapDeprecated.objectGroupNamed(self,groupName) deprecatedTip("CCTMXTiledMap:objectGroupNamed","CCTMXTiledMap:getObjectGroup") return self:getObjectGroup(groupName) end rawset(CCTMXTiledMap,"objectGroupNamed", CCTMXTiledMapDeprecated.objectGroupNamed) --functions of CCTMXTiledMap will be deprecated end --functions of CCTMXMapInfo will be deprecated begin local CCTMXMapInfoDeprecated = { } function CCTMXMapInfoDeprecated.getStoringCharacters(self) deprecatedTip("CCTMXMapInfo:getStoringCharacters","CCTMXMapInfo:isStoringCharacters") return self:isStoringCharacters() end rawset(CCTMXMapInfo,"getStoringCharacters", CCTMXMapInfoDeprecated.getStoringCharacters) function CCTMXMapInfoDeprecated.formatWithTMXFile(infoTable,tmxFile) deprecatedTip("CCTMXMapInfo:formatWithTMXFile","CCTMXMapInfo:create") return CCTMXMapInfo:create(tmxFile) end rawset(CCTMXMapInfo,"formatWithTMXFile", CCTMXMapInfoDeprecated.formatWithTMXFile) function CCTMXMapInfoDeprecated.formatWithXML(infoTable,tmxString,resourcePath) deprecatedTip("CCTMXMapInfo:formatWithXML","TMXMapInfo:createWithXML") return CCTMXMapInfo:createWithXML(tmxString,resourcePath) end rawset(CCTMXMapInfo,"formatWithXML", CCTMXMapInfoDeprecated.formatWithXML) --functions of CCTMXMapInfo will be deprecated end --functions of CCTMXObject will be deprecated begin local CCTMXObjectGroupDeprecated = { } function CCTMXObjectGroupDeprecated.propertyNamed(self,propertyName) deprecatedTip("CCTMXObjectGroup:propertyNamed","CCTMXObjectGroup:getProperty") return self:getProperty(propertyName) end rawset(CCTMXObjectGroup,"propertyNamed", CCTMXObjectGroupDeprecated.propertyNamed) function CCTMXObjectGroupDeprecated.objectNamed(self, objectName) deprecatedTip("CCTMXObjectGroup:objectNamed","CCTMXObjectGroup:getObject") return self:getObject(objectName) end rawset(CCTMXObjectGroup,"objectNamed", CCTMXObjectGroupDeprecated.objectNamed) --functions of CCTMXObject will be deprecated end --functions of WebSocket will be deprecated begin local targetPlatform = CCApplication:getInstance():getTargetPlatform() if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) then local WebSocketDeprecated = { } function WebSocketDeprecated.sendTextMsg(self, string) deprecatedTip("WebSocket:sendTextMsg","WebSocket:sendString") return self:sendString(string) end rawset(WebSocket,"sendTextMsg", WebSocketDeprecated.sendTextMsg) function WebSocketDeprecated.sendBinaryMsg(self, table,tablesize) deprecatedTip("WebSocket:sendBinaryMsg","WebSocket:sendString") string.char(unpack(table)) return self:sendString(string.char(unpack(table))) end rawset(WebSocket,"sendBinaryMsg", WebSocketDeprecated.sendBinaryMsg) end --functions of WebSocket will be deprecated end --functions of CCRenderTexture will be deprecated begin local CCRenderTextureDeprecated = { } function CCRenderTextureDeprecated.newCCImage(self) deprecatedTip("CCRenderTexture:newCCImage","CCRenderTexture:newImage") return self:newImage() end rawset(CCRenderTexture, "newCCImage", CCRenderTextureDeprecated.newCCImage) --functions of CCRenderTexture will be deprecated end --functions of Sprite will be deprecated begin local CCSpriteDeprecated = { } function CCSpriteDeprecated.setFlipX(self,flag) deprecatedTip("CCSpriteDeprecated:setFlipX","CCSpriteDeprecated:setFlippedX") return self:setFlippedX(flag) end rawset(cc.Sprite, "setFlipX", CCSpriteDeprecated.setFlipX) function CCSpriteDeprecated.setFlipY(self,flag) deprecatedTip("CCSpriteDeprecated:setFlipY","CCSpriteDeprecated:setFlippedY") return self:setFlippedY(flag) end rawset(cc.Sprite, "setFlipY", CCSpriteDeprecated.setFlipY) --functions of Sprite will be deprecated end --functions of Layer will be deprecated begin local CCLayerDeprecated = {} function CCLayerDeprecated.setKeypadEnabled( self, enabled) return self:setKeyboardEnabled(enabled) end rawset(cc.Layer, "setKeypadEnabled", CCLayerDeprecated.setKeypadEnabled ) function CCLayerDeprecated.isKeypadEnabled(self) return self:isKeyboardEnabled() end rawset(cc.Layer, "isKeypadEnabled", CCLayerDeprecated.isKeypadEnabled ) --functions of Layer will be deprecated end --functions of ccs.GUIReader will be deprecated begin local CCSGUIReaderDeprecated = { } function CCSGUIReaderDeprecated.purgeGUIReader() deprecatedTip("ccs.GUIReader:purgeGUIReader","ccs.GUIReader:destroyInstance") return ccs.GUIReader:destroyInstance() end rawset(ccs.GUIReader,"purgeGUIReader",CCSGUIReaderDeprecated.purgeGUIReader) --functions of ccs.GUIReader will be deprecated end --functions of ccs.ActionManagerEx will be deprecated begin local CCSActionManagerExDeprecated = { } function CCSActionManagerExDeprecated.destroyActionManager() deprecatedTip("ccs.ActionManagerEx:destroyActionManager","ccs.ActionManagerEx:destroyInstance") return ccs.ActionManagerEx:destroyInstance() end rawset(ccs.ActionManagerEx,"destroyActionManager",CCSActionManagerExDeprecated.destroyActionManager) --functions of ccs.ActionManagerEx will be deprecated end --functions of ccs.SceneReader will be deprecated begin local CCSSceneReaderDeprecated = { } function CCSSceneReaderDeprecated.destroySceneReader(self) deprecatedTip("ccs.SceneReader:destroySceneReader","ccs.SceneReader:destroyInstance") return self:destroyInstance() end rawset(ccs.SceneReader,"destroySceneReader",CCSSceneReaderDeprecated.destroySceneReader) --functions of ccs.SceneReader will be deprecated end --functions of CCArmatureDataManager will be deprecated begin local CCArmatureDataManagerDeprecated = { } function CCArmatureDataManagerDeprecated.sharedArmatureDataManager() deprecatedTip("CCArmatureDataManager:sharedArmatureDataManager","ccs.ArmatureDataManager:getInstance") return ccs.ArmatureDataManager:getInstance() end rawset(CCArmatureDataManager,"sharedArmatureDataManager",CCArmatureDataManagerDeprecated.sharedArmatureDataManager) function CCArmatureDataManagerDeprecated.purge() deprecatedTip("CCArmatureDataManager:purge","ccs.ArmatureDataManager:destoryInstance") return ccs.ArmatureDataManager:destoryInstance() end rawset(CCArmatureDataManager,"purge",CCArmatureDataManagerDeprecated.purge) --functions of CCArmatureDataManager will be deprecated end --functions of GUIReader will be deprecated begin local GUIReaderDeprecated = { } function GUIReaderDeprecated.shareReader() deprecatedTip("GUIReader:shareReader","ccs.GUIReader:getInstance") return ccs.GUIReader:getInstance() end rawset(GUIReader,"shareReader",GUIReaderDeprecated.shareReader) function GUIReaderDeprecated.purgeGUIReader() deprecatedTip("GUIReader:purgeGUIReader","ccs.GUIReader:destroyInstance") return ccs.GUIReader:destroyInstance() end rawset(GUIReader,"purgeGUIReader",GUIReaderDeprecated.purgeGUIReader) --functions of GUIReader will be deprecated end --functions of SceneReader will be deprecated begin local SceneReaderDeprecated = { } function SceneReaderDeprecated.sharedSceneReader() deprecatedTip("SceneReader:sharedSceneReader","ccs.SceneReader:getInstance") return ccs.SceneReader:getInstance() end rawset(SceneReader,"sharedSceneReader",SceneReaderDeprecated.sharedSceneReader) function SceneReaderDeprecated.purgeSceneReader(self) deprecatedTip("SceneReader:purgeSceneReader","ccs.SceneReader:destroyInstance") return self:destroyInstance() end rawset(SceneReader,"purgeSceneReader",SceneReaderDeprecated.purgeSceneReader) --functions of SceneReader will be deprecated end --functions of CCEGLView will be deprecated begin local CCEGLViewDeprecated = { } function CCEGLViewDeprecated.sharedOpenGLView() deprecatedTip("CCEGLView:sharedOpenGLView","cc.EGLView:getInstance") return cc.EGLView:getInstance() end rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) --functions of CCEGLView will be deprecated end --functions of cc.Node will be deprecated begin local NodeDeprecated = { } function NodeDeprecated.setZOrder(self,zOrder) deprecatedTip("cc.Node:setZOrder","cc.Node:setLocalZOrder") return self:setLocalZOrder(zOrder) end rawset(cc.Node,"setZOrder",NodeDeprecated.setZOrder) function NodeDeprecated.getZOrder(self) deprecatedTip("cc.Node:getZOrder","cc.Node:getLocalZOrder") return self:getLocalZOrder() end rawset(cc.Node,"getZOrder",NodeDeprecated.getZOrder) --functions of cc.Node will be deprecated end ================================================ FILE: cocos2d/cocos/scripting/lua/script/DeprecatedClass.lua ================================================ -- This is the DeprecatedClass DeprecatedClass = {} or DeprecatedClass --tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") end --CCProgressTo class will be Deprecated,begin function DeprecatedClass.CCProgressTo() deprecatedTip("CCProgressTo","cc.ProgressTo") return cc.ProgressTo end _G["CCProgressTo"] = DeprecatedClass.CCProgressTo() --CCProgressTo class will be Deprecated,end --CCHide class will be Deprecated,begin function DeprecatedClass.CCHide() deprecatedTip("CCHide","cc.Hide") return cc.Hide end _G["CCHide"] = DeprecatedClass.CCHide() --CCHide class will be Deprecated,end --CCTransitionMoveInB class will be Deprecated,begin function DeprecatedClass.CCTransitionMoveInB() deprecatedTip("CCTransitionMoveInB","cc.TransitionMoveInB") return cc.TransitionMoveInB end _G["CCTransitionMoveInB"] = DeprecatedClass.CCTransitionMoveInB() --CCTransitionMoveInB class will be Deprecated,end --CCEaseSineIn class will be Deprecated,begin function DeprecatedClass.CCEaseSineIn() deprecatedTip("CCEaseSineIn","cc.EaseSineIn") return cc.EaseSineIn end _G["CCEaseSineIn"] = DeprecatedClass.CCEaseSineIn() --CCEaseSineIn class will be Deprecated,end --CCTransitionMoveInL class will be Deprecated,begin function DeprecatedClass.CCTransitionMoveInL() deprecatedTip("CCTransitionMoveInL","cc.TransitionMoveInL") return cc.TransitionMoveInL end _G["CCTransitionMoveInL"] = DeprecatedClass.CCTransitionMoveInL() --CCTransitionMoveInL class will be Deprecated,end --CCEaseInOut class will be Deprecated,begin function DeprecatedClass.CCEaseInOut() deprecatedTip("CCEaseInOut","cc.EaseInOut") return cc.EaseInOut end _G["CCEaseInOut"] = DeprecatedClass.CCEaseInOut() --CCEaseInOut class will be Deprecated,end --SimpleAudioEngine class will be Deprecated,begin function DeprecatedClass.SimpleAudioEngine() deprecatedTip("SimpleAudioEngine","cc.SimpleAudioEngine") return cc.SimpleAudioEngine end _G["SimpleAudioEngine"] = DeprecatedClass.SimpleAudioEngine() --SimpleAudioEngine class will be Deprecated,end --CCTransitionMoveInT class will be Deprecated,begin function DeprecatedClass.CCTransitionMoveInT() deprecatedTip("CCTransitionMoveInT","cc.TransitionMoveInT") return cc.TransitionMoveInT end _G["CCTransitionMoveInT"] = DeprecatedClass.CCTransitionMoveInT() --CCTransitionMoveInT class will be Deprecated,end --CCTransitionMoveInR class will be Deprecated,begin function DeprecatedClass.CCTransitionMoveInR() deprecatedTip("CCTransitionMoveInR","cc.TransitionMoveInR") return cc.TransitionMoveInR end _G["CCTransitionMoveInR"] = DeprecatedClass.CCTransitionMoveInR() --CCTransitionMoveInR class will be Deprecated,end --CCControlHuePicker class will be Deprecated,begin function DeprecatedClass.CCControlHuePicker() deprecatedTip("CCControlHuePicker","cc.ControlHuePicker") return cc.ControlHuePicker end _G["CCControlHuePicker"] = DeprecatedClass.CCControlHuePicker() --CCControlHuePicker class will be Deprecated,end --CCParticleSnow class will be Deprecated,begin function DeprecatedClass.CCParticleSnow() deprecatedTip("CCParticleSnow","cc.ParticleSnow") return cc.ParticleSnow end _G["CCParticleSnow"] = DeprecatedClass.CCParticleSnow() --CCParticleSnow class will be Deprecated,end --CCActionCamera class will be Deprecated,begin function DeprecatedClass.CCActionCamera() deprecatedTip("CCActionCamera","cc.ActionCamera") return cc.ActionCamera end _G["CCActionCamera"] = DeprecatedClass.CCActionCamera() --CCActionCamera class will be Deprecated,end --CCProgressFromTo class will be Deprecated,begin function DeprecatedClass.CCProgressFromTo() deprecatedTip("CCProgressFromTo","cc.ProgressFromTo") return cc.ProgressFromTo end _G["CCProgressFromTo"] = DeprecatedClass.CCProgressFromTo() --CCProgressFromTo class will be Deprecated,end --CCMoveTo class will be Deprecated,begin function DeprecatedClass.CCMoveTo() deprecatedTip("CCMoveTo","cc.MoveTo") return cc.MoveTo end _G["CCMoveTo"] = DeprecatedClass.CCMoveTo() --CCMoveTo class will be Deprecated,end --CCJumpBy class will be Deprecated,begin function DeprecatedClass.CCJumpBy() deprecatedTip("CCJumpBy","cc.JumpBy") return cc.JumpBy end _G["CCJumpBy"] = DeprecatedClass.CCJumpBy() --CCJumpBy class will be Deprecated,end --CCObject class will be Deprecated,begin function DeprecatedClass.CCObject() deprecatedTip("CCObject","cc.Object") return cc.Object end _G["CCObject"] = DeprecatedClass.CCObject() --CCObject class will be Deprecated,end --CCTransitionRotoZoom class will be Deprecated,begin function DeprecatedClass.CCTransitionRotoZoom() deprecatedTip("CCTransitionRotoZoom","cc.TransitionRotoZoom") return cc.TransitionRotoZoom end _G["CCTransitionRotoZoom"] = DeprecatedClass.CCTransitionRotoZoom() --CCTransitionRotoZoom class will be Deprecated,end --CCControlColourPicker class will be Deprecated,begin function DeprecatedClass.CCControlColourPicker() deprecatedTip("CCControlColourPicker","cc.ControlColourPicker") return cc.ControlColourPicker end _G["CCControlColourPicker"] = DeprecatedClass.CCControlColourPicker() --CCControlColourPicker class will be Deprecated,end --CCDirector class will be Deprecated,begin function DeprecatedClass.CCDirector() deprecatedTip("CCDirector","cc.Director") return cc.Director end _G["CCDirector"] = DeprecatedClass.CCDirector() --CCDirector class will be Deprecated,end --CCScheduler class will be Deprecated,begin function DeprecatedClass.CCScheduler() deprecatedTip("CCScheduler","cc.Scheduler") return cc.Scheduler end _G["CCScheduler"] = DeprecatedClass.CCScheduler() --CCScheduler class will be Deprecated,end --CCEaseElasticOut class will be Deprecated,begin function DeprecatedClass.CCEaseElasticOut() deprecatedTip("CCEaseElasticOut","cc.EaseElasticOut") return cc.EaseElasticOut end _G["CCEaseElasticOut"] = DeprecatedClass.CCEaseElasticOut() --CCEaseElasticOut class will be Deprecated,end --CCTableViewCell class will be Deprecated,begin function DeprecatedClass.CCTableViewCell() deprecatedTip("CCTableViewCell","cc.TableViewCell") return cc.TableViewCell end _G["CCTableViewCell"] = DeprecatedClass.CCTableViewCell() --CCTableViewCell class will be Deprecated,end --CCEaseBackOut class will be Deprecated,begin function DeprecatedClass.CCEaseBackOut() deprecatedTip("CCEaseBackOut","cc.EaseBackOut") return cc.EaseBackOut end _G["CCEaseBackOut"] = DeprecatedClass.CCEaseBackOut() --CCEaseBackOut class will be Deprecated,end --CCParticleSystemQuad class will be Deprecated,begin function DeprecatedClass.CCParticleSystemQuad() deprecatedTip("CCParticleSystemQuad","cc.ParticleSystemQuad") return cc.ParticleSystemQuad end _G["CCParticleSystemQuad"] = DeprecatedClass.CCParticleSystemQuad() --CCParticleSystemQuad class will be Deprecated,end --CCMenuItemToggle class will be Deprecated,begin function DeprecatedClass.CCMenuItemToggle() deprecatedTip("CCMenuItemToggle","cc.MenuItemToggle") return cc.MenuItemToggle end _G["CCMenuItemToggle"] = DeprecatedClass.CCMenuItemToggle() --CCMenuItemToggle class will be Deprecated,end --CCStopGrid class will be Deprecated,begin function DeprecatedClass.CCStopGrid() deprecatedTip("CCStopGrid","cc.StopGrid") return cc.StopGrid end _G["CCStopGrid"] = DeprecatedClass.CCStopGrid() --CCStopGrid class will be Deprecated,end --CCTransitionScene class will be Deprecated,begin function DeprecatedClass.CCTransitionScene() deprecatedTip("CCTransitionScene","cc.TransitionScene") return cc.TransitionScene end _G["CCTransitionScene"] = DeprecatedClass.CCTransitionScene() --CCTransitionScene class will be Deprecated,end --CCSkewBy class will be Deprecated,begin function DeprecatedClass.CCSkewBy() deprecatedTip("CCSkewBy","cc.SkewBy") return cc.SkewBy end _G["CCSkewBy"] = DeprecatedClass.CCSkewBy() --CCSkewBy class will be Deprecated,end --CCLayer class will be Deprecated,begin function DeprecatedClass.CCLayer() deprecatedTip("CCLayer","cc.Layer") return cc.Layer end _G["CCLayer"] = DeprecatedClass.CCLayer() --CCLayer class will be Deprecated,end --CCEaseElastic class will be Deprecated,begin function DeprecatedClass.CCEaseElastic() deprecatedTip("CCEaseElastic","cc.EaseElastic") return cc.EaseElastic end _G["CCEaseElastic"] = DeprecatedClass.CCEaseElastic() --CCEaseElastic class will be Deprecated,end --CCTMXTiledMap class will be Deprecated,begin function DeprecatedClass.CCTMXTiledMap() deprecatedTip("CCTMXTiledMap","cc.TMXTiledMap") return cc.TMXTiledMap end _G["CCTMXTiledMap"] = DeprecatedClass.CCTMXTiledMap() --CCTMXTiledMap class will be Deprecated,end --CCGrid3DAction class will be Deprecated,begin function DeprecatedClass.CCGrid3DAction() deprecatedTip("CCGrid3DAction","cc.Grid3DAction") return cc.Grid3DAction end _G["CCGrid3DAction"] = DeprecatedClass.CCGrid3DAction() --CCGrid3DAction class will be Deprecated,end --CCFadeIn class will be Deprecated,begin function DeprecatedClass.CCFadeIn() deprecatedTip("CCFadeIn","cc.FadeIn") return cc.FadeIn end _G["CCFadeIn"] = DeprecatedClass.CCFadeIn() --CCFadeIn class will be Deprecated,end --CCNodeRGBA class will be Deprecated,begin function DeprecatedClass.CCNodeRGBA() deprecatedTip("CCNodeRGBA","cc.Node") return cc.Node end _G["CCNodeRGBA"] = DeprecatedClass.CCNodeRGBA() --CCNodeRGBA class will be Deprecated,end --NodeRGBA class will be Deprecated,begin function DeprecatedClass.NodeRGBA() deprecatedTip("cc.NodeRGBA","cc.Node") return cc.Node end _G["cc"]["NodeRGBA"] = DeprecatedClass.NodeRGBA() --NodeRGBA class will be Deprecated,end --CCAnimationCache class will be Deprecated,begin function DeprecatedClass.CCAnimationCache() deprecatedTip("CCAnimationCache","cc.AnimationCache") return cc.AnimationCache end _G["CCAnimationCache"] = DeprecatedClass.CCAnimationCache() --CCAnimationCache class will be Deprecated,end --CCFlipY3D class will be Deprecated,begin function DeprecatedClass.CCFlipY3D() deprecatedTip("CCFlipY3D","cc.FlipY3D") return cc.FlipY3D end _G["CCFlipY3D"] = DeprecatedClass.CCFlipY3D() --CCFlipY3D class will be Deprecated,end --CCEaseSineInOut class will be Deprecated,begin function DeprecatedClass.CCEaseSineInOut() deprecatedTip("CCEaseSineInOut","cc.EaseSineInOut") return cc.EaseSineInOut end _G["CCEaseSineInOut"] = DeprecatedClass.CCEaseSineInOut() --CCEaseSineInOut class will be Deprecated,end --CCTransitionFlipAngular class will be Deprecated,begin function DeprecatedClass.CCTransitionFlipAngular() deprecatedTip("CCTransitionFlipAngular","cc.TransitionFlipAngular") return cc.TransitionFlipAngular end _G["CCTransitionFlipAngular"] = DeprecatedClass.CCTransitionFlipAngular() --CCTransitionFlipAngular class will be Deprecated,end --CCControl class will be Deprecated,begin function DeprecatedClass.CCControl() deprecatedTip("CCControl","cc.Control") return cc.Control end _G["CCControl"] = DeprecatedClass.CCControl() --CCControl class will be Deprecated,end --CCEaseElasticInOut class will be Deprecated,begin function DeprecatedClass.CCEaseElasticInOut() deprecatedTip("CCEaseElasticInOut","cc.EaseElasticInOut") return cc.EaseElasticInOut end _G["CCEaseElasticInOut"] = DeprecatedClass.CCEaseElasticInOut() --CCEaseElasticInOut class will be Deprecated,end --CCEaseBounce class will be Deprecated,begin function DeprecatedClass.CCEaseBounce() deprecatedTip("CCEaseBounce","cc.EaseBounce") return cc.EaseBounce end _G["CCEaseBounce"] = DeprecatedClass.CCEaseBounce() --CCEaseBounce class will be Deprecated,end --CCShow class will be Deprecated,begin function DeprecatedClass.CCShow() deprecatedTip("CCShow","cc.Show") return cc.Show end _G["CCShow"] = DeprecatedClass.CCShow() --CCShow class will be Deprecated,end --CCEditBox class will be Deprecated,begin function DeprecatedClass.CCEditBox() deprecatedTip("CCEditBox","cc.EditBox") return cc.EditBox end _G["CCEditBox"] = DeprecatedClass.CCEditBox() --CCEditBox class will be Deprecated,end --CCFadeOut class will be Deprecated,begin function DeprecatedClass.CCFadeOut() deprecatedTip("CCFadeOut","cc.FadeOut") return cc.FadeOut end _G["CCFadeOut"] = DeprecatedClass.CCFadeOut() --CCFadeOut class will be Deprecated,end --CCCallFunc class will be Deprecated,begin function DeprecatedClass.CCCallFunc() deprecatedTip("CCCallFunc","cc.CallFunc") return cc.CallFunc end _G["CCCallFunc"] = DeprecatedClass.CCCallFunc() --CCCallFunc class will be Deprecated,end --CCWaves3D class will be Deprecated,begin function DeprecatedClass.CCWaves3D() deprecatedTip("CCWaves3D","cc.Waves3D") return cc.Waves3D end _G["CCWaves3D"] = DeprecatedClass.CCWaves3D() --CCWaves3D class will be Deprecated,end --CCFlipX3D class will be Deprecated,begin function DeprecatedClass.CCFlipX3D() deprecatedTip("CCFlipX3D","cc.FlipX3D") return cc.FlipX3D end _G["CCFlipX3D"] = DeprecatedClass.CCFlipX3D() --CCFlipX3D class will be Deprecated,end --CCParticleFireworks class will be Deprecated,begin function DeprecatedClass.CCParticleFireworks() deprecatedTip("CCParticleFireworks","cc.ParticleFireworks") return cc.ParticleFireworks end _G["CCParticleFireworks"] = DeprecatedClass.CCParticleFireworks() --CCParticleFireworks class will be Deprecated,end --CCMenuItemImage class will be Deprecated,begin function DeprecatedClass.CCMenuItemImage() deprecatedTip("CCMenuItemImage","cc.MenuItemImage") return cc.MenuItemImage end _G["CCMenuItemImage"] = DeprecatedClass.CCMenuItemImage() --CCMenuItemImage class will be Deprecated,end --CCParticleFire class will be Deprecated,begin function DeprecatedClass.CCParticleFire() deprecatedTip("CCParticleFire","cc.ParticleFire") return cc.ParticleFire end _G["CCParticleFire"] = DeprecatedClass.CCParticleFire() --CCParticleFire class will be Deprecated,end --CCMenuItem class will be Deprecated,begin function DeprecatedClass.CCMenuItem() deprecatedTip("CCMenuItem","cc.MenuItem") return cc.MenuItem end _G["CCMenuItem"] = DeprecatedClass.CCMenuItem() --CCMenuItem class will be Deprecated,end --CCActionEase class will be Deprecated,begin function DeprecatedClass.CCActionEase() deprecatedTip("CCActionEase","cc.ActionEase") return cc.ActionEase end _G["CCActionEase"] = DeprecatedClass.CCActionEase() --CCActionEase class will be Deprecated,end --CCTransitionSceneOriented class will be Deprecated,begin function DeprecatedClass.CCTransitionSceneOriented() deprecatedTip("CCTransitionSceneOriented","cc.TransitionSceneOriented") return cc.TransitionSceneOriented end _G["CCTransitionSceneOriented"] = DeprecatedClass.CCTransitionSceneOriented() --CCTransitionSceneOriented class will be Deprecated,end --CCTransitionZoomFlipAngular class will be Deprecated,begin function DeprecatedClass.CCTransitionZoomFlipAngular() deprecatedTip("CCTransitionZoomFlipAngular","cc.TransitionZoomFlipAngular") return cc.TransitionZoomFlipAngular end _G["CCTransitionZoomFlipAngular"] = DeprecatedClass.CCTransitionZoomFlipAngular() --CCTransitionZoomFlipAngular class will be Deprecated,end --CCEaseIn class will be Deprecated,begin function DeprecatedClass.CCEaseIn() deprecatedTip("CCEaseIn","cc.EaseIn") return cc.EaseIn end _G["CCEaseIn"] = DeprecatedClass.CCEaseIn() --CCEaseIn class will be Deprecated,end --CCEaseExponentialInOut class will be Deprecated,begin function DeprecatedClass.CCEaseExponentialInOut() deprecatedTip("CCEaseExponentialInOut","cc.EaseExponentialInOut") return cc.EaseExponentialInOut end _G["CCEaseExponentialInOut"] = DeprecatedClass.CCEaseExponentialInOut() --CCEaseExponentialInOut class will be Deprecated,end --CCTransitionFlipX class will be Deprecated,begin function DeprecatedClass.CCTransitionFlipX() deprecatedTip("CCTransitionFlipX","cc.TransitionFlipX") return cc.TransitionFlipX end _G["CCTransitionFlipX"] = DeprecatedClass.CCTransitionFlipX() --CCTransitionFlipX class will be Deprecated,end --CCEaseExponentialOut class will be Deprecated,begin function DeprecatedClass.CCEaseExponentialOut() deprecatedTip("CCEaseExponentialOut","cc.EaseExponentialOut") return cc.EaseExponentialOut end _G["CCEaseExponentialOut"] = DeprecatedClass.CCEaseExponentialOut() --CCEaseExponentialOut class will be Deprecated,end --CCLabel class will be Deprecated,begin function DeprecatedClass.CCLabel() deprecatedTip("CCLabel","cc.Label") return cc.Label end _G["CCLabel"] = DeprecatedClass.CCLabel() --CCLabel class will be Deprecated,end --CCApplication class will be Deprecated,begin function DeprecatedClass.CCApplication() deprecatedTip("CCApplication","cc.Application") return cc.Application end _G["CCApplication"] = DeprecatedClass.CCApplication() --CCApplication class will be Deprecated,end --CCControlSlider class will be Deprecated,begin function DeprecatedClass.CCControlSlider() deprecatedTip("CCControlSlider","cc.ControlSlider") return cc.ControlSlider end _G["CCControlSlider"] = DeprecatedClass.CCControlSlider() --CCControlSlider class will be Deprecated,end --CCDelayTime class will be Deprecated,begin function DeprecatedClass.CCDelayTime() deprecatedTip("CCDelayTime","cc.DelayTime") return cc.DelayTime end _G["CCDelayTime"] = DeprecatedClass.CCDelayTime() --CCDelayTime class will be Deprecated,end --CCLabelAtlas class will be Deprecated,begin function DeprecatedClass.CCLabelAtlas() deprecatedTip("CCLabelAtlas","cc.LabelAtlas") return cc.LabelAtlas end _G["CCLabelAtlas"] = DeprecatedClass.CCLabelAtlas() --CCLabelAtlas class will be Deprecated,end --CCLabelBMFont class will be Deprecated,begin function DeprecatedClass.CCLabelBMFont() deprecatedTip("CCLabelBMFont","cc.LabelBMFont") return cc.LabelBMFont end _G["CCLabelBMFont"] = DeprecatedClass.CCLabelBMFont() --CCLabelBMFont class will be Deprecated,end --CCScale9Sprite class will be Deprecated,begin function DeprecatedClass.CCScale9Sprite() deprecatedTip("CCScale9Sprite","cc.Scale9Sprite") return cc.Scale9Sprite end _G["CCScale9Sprite"] = DeprecatedClass.CCScale9Sprite() --CCScale9Sprite class will be Deprecated,end --CCFadeOutTRTiles class will be Deprecated,begin function DeprecatedClass.CCFadeOutTRTiles() deprecatedTip("CCFadeOutTRTiles","cc.FadeOutTRTiles") return cc.FadeOutTRTiles end _G["CCFadeOutTRTiles"] = DeprecatedClass.CCFadeOutTRTiles() --CCFadeOutTRTiles class will be Deprecated,end --CCEaseElasticIn class will be Deprecated,begin function DeprecatedClass.CCEaseElasticIn() deprecatedTip("CCEaseElasticIn","cc.EaseElasticIn") return cc.EaseElasticIn end _G["CCEaseElasticIn"] = DeprecatedClass.CCEaseElasticIn() --CCEaseElasticIn class will be Deprecated,end --CCParticleSpiral class will be Deprecated,begin function DeprecatedClass.CCParticleSpiral() deprecatedTip("CCParticleSpiral","cc.ParticleSpiral") return cc.ParticleSpiral end _G["CCParticleSpiral"] = DeprecatedClass.CCParticleSpiral() --CCParticleSpiral class will be Deprecated,end --CCBReader class will be Deprecated,begin function DeprecatedClass.CCBReader() deprecatedTip("CCBReader","cc.BReader") return cc.BReader end _G["CCBReader"] = DeprecatedClass.CCBReader() --CCBReader class will be Deprecated,end --CCFiniteTimeAction class will be Deprecated,begin function DeprecatedClass.CCFiniteTimeAction() deprecatedTip("CCFiniteTimeAction","cc.FiniteTimeAction") return cc.FiniteTimeAction end _G["CCFiniteTimeAction"] = DeprecatedClass.CCFiniteTimeAction() --CCFiniteTimeAction class will be Deprecated,end --CCFadeOutDownTiles class will be Deprecated,begin function DeprecatedClass.CCFadeOutDownTiles() deprecatedTip("CCFadeOutDownTiles","cc.FadeOutDownTiles") return cc.FadeOutDownTiles end _G["CCFadeOutDownTiles"] = DeprecatedClass.CCFadeOutDownTiles() --CCFadeOutDownTiles class will be Deprecated,end --CCJumpTiles3D class will be Deprecated,begin function DeprecatedClass.CCJumpTiles3D() deprecatedTip("CCJumpTiles3D","cc.JumpTiles3D") return cc.JumpTiles3D end _G["CCJumpTiles3D"] = DeprecatedClass.CCJumpTiles3D() --CCJumpTiles3D class will be Deprecated,end --CCEaseBackIn class will be Deprecated,begin function DeprecatedClass.CCEaseBackIn() deprecatedTip("CCEaseBackIn","cc.EaseBackIn") return cc.EaseBackIn end _G["CCEaseBackIn"] = DeprecatedClass.CCEaseBackIn() --CCEaseBackIn class will be Deprecated,end --CCSpriteBatchNode class will be Deprecated,begin function DeprecatedClass.CCSpriteBatchNode() deprecatedTip("CCSpriteBatchNode","cc.SpriteBatchNode") return cc.SpriteBatchNode end _G["CCSpriteBatchNode"] = DeprecatedClass.CCSpriteBatchNode() --CCSpriteBatchNode class will be Deprecated,end --CCParticleSystem class will be Deprecated,begin function DeprecatedClass.CCParticleSystem() deprecatedTip("CCParticleSystem","cc.ParticleSystem") return cc.ParticleSystem end _G["CCParticleSystem"] = DeprecatedClass.CCParticleSystem() --CCParticleSystem class will be Deprecated,end --CCActionTween class will be Deprecated,begin function DeprecatedClass.CCActionTween() deprecatedTip("CCActionTween","cc.ActionTween") return cc.ActionTween end _G["CCActionTween"] = DeprecatedClass.CCActionTween() --CCActionTween class will be Deprecated,end --CCTransitionFadeDown class will be Deprecated,begin function DeprecatedClass.CCTransitionFadeDown() deprecatedTip("CCTransitionFadeDown","cc.TransitionFadeDown") return cc.TransitionFadeDown end _G["CCTransitionFadeDown"] = DeprecatedClass.CCTransitionFadeDown() --CCTransitionFadeDown class will be Deprecated,end --CCParticleSun class will be Deprecated,begin function DeprecatedClass.CCParticleSun() deprecatedTip("CCParticleSun","cc.ParticleSun") return cc.ParticleSun end _G["CCParticleSun"] = DeprecatedClass.CCParticleSun() --CCParticleSun class will be Deprecated,end --CCTransitionProgressHorizontal class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressHorizontal() deprecatedTip("CCTransitionProgressHorizontal","cc.TransitionProgressHorizontal") return cc.TransitionProgressHorizontal end _G["CCTransitionProgressHorizontal"] = DeprecatedClass.CCTransitionProgressHorizontal() --CCTransitionProgressHorizontal class will be Deprecated,end --CCRipple3D class will be Deprecated,begin function DeprecatedClass.CCRipple3D() deprecatedTip("CCRipple3D","cc.Ripple3D") return cc.Ripple3D end _G["CCRipple3D"] = DeprecatedClass.CCRipple3D() --CCRipple3D class will be Deprecated,end --CCTMXLayer class will be Deprecated,begin function DeprecatedClass.CCTMXLayer() deprecatedTip("CCTMXLayer","cc.TMXLayer") return cc.TMXLayer end _G["CCTMXLayer"] = DeprecatedClass.CCTMXLayer() --CCTMXLayer class will be Deprecated,end --CCFlipX class will be Deprecated,begin function DeprecatedClass.CCFlipX() deprecatedTip("CCFlipX","cc.FlipX") return cc.FlipX end _G["CCFlipX"] = DeprecatedClass.CCFlipX() --CCFlipX class will be Deprecated,end --CCFlipY class will be Deprecated,begin function DeprecatedClass.CCFlipY() deprecatedTip("CCFlipY","cc.FlipY") return cc.FlipY end _G["CCFlipY"] = DeprecatedClass.CCFlipY() --CCFlipY class will be Deprecated,end --CCTransitionSplitCols class will be Deprecated,begin function DeprecatedClass.CCTransitionSplitCols() deprecatedTip("CCTransitionSplitCols","cc.TransitionSplitCols") return cc.TransitionSplitCols end _G["CCTransitionSplitCols"] = DeprecatedClass.CCTransitionSplitCols() --CCTransitionSplitCols class will be Deprecated,end --CCTimer class will be Deprecated,begin function DeprecatedClass.CCTimer() deprecatedTip("CCTimer","cc.Timer") return cc.Timer end _G["CCTimer"] = DeprecatedClass.CCTimer() --CCTimer class will be Deprecated,end --CCFadeTo class will be Deprecated,begin function DeprecatedClass.CCFadeTo() deprecatedTip("CCFadeTo","cc.FadeTo") return cc.FadeTo end _G["CCFadeTo"] = DeprecatedClass.CCFadeTo() --CCFadeTo class will be Deprecated,end --CCBAnimationManager class will be Deprecated,begin function DeprecatedClass.CCBAnimationManager() deprecatedTip("CCBAnimationManager","cc.BAnimationManager") return cc.BAnimationManager end _G["CCBAnimationManager"] = DeprecatedClass.CCBAnimationManager() --CCBAnimationManager class will be Deprecated,end --CCRepeatForever class will be Deprecated,begin function DeprecatedClass.CCRepeatForever() deprecatedTip("CCRepeatForever","cc.RepeatForever") return cc.RepeatForever end _G["CCRepeatForever"] = DeprecatedClass.CCRepeatForever() --CCRepeatForever class will be Deprecated,end --CCPlace class will be Deprecated,begin function DeprecatedClass.CCPlace() deprecatedTip("CCPlace","cc.Place") return cc.Place end _G["CCPlace"] = DeprecatedClass.CCPlace() --CCPlace class will be Deprecated,end --CCScrollView class will be Deprecated,begin function DeprecatedClass.CCScrollView() deprecatedTip("CCScrollView","cc.ScrollView") return cc.ScrollView end _G["CCScrollView"] = DeprecatedClass.CCScrollView() --CCScrollView class will be Deprecated,end --CCGLProgram class will be Deprecated,begin function DeprecatedClass.CCGLProgram() deprecatedTip("CCGLProgram","cc.GLProgram") return cc.GLProgram end _G["CCGLProgram"] = DeprecatedClass.CCGLProgram() --CCGLProgram class will be Deprecated,end --CCEaseBounceOut class will be Deprecated,begin function DeprecatedClass.CCEaseBounceOut() deprecatedTip("CCEaseBounceOut","cc.EaseBounceOut") return cc.EaseBounceOut end _G["CCEaseBounceOut"] = DeprecatedClass.CCEaseBounceOut() --CCEaseBounceOut class will be Deprecated,end --CCCardinalSplineBy class will be Deprecated,begin function DeprecatedClass.CCCardinalSplineBy() deprecatedTip("CCCardinalSplineBy","cc.CardinalSplineBy") return cc.CardinalSplineBy end _G["CCCardinalSplineBy"] = DeprecatedClass.CCCardinalSplineBy() --CCCardinalSplineBy class will be Deprecated,end --CCSpriteFrameCache class will be Deprecated,begin function DeprecatedClass.CCSpriteFrameCache() deprecatedTip("CCSpriteFrameCache","cc.SpriteFrameCache") return cc.SpriteFrameCache end _G["CCSpriteFrameCache"] = DeprecatedClass.CCSpriteFrameCache() --CCSpriteFrameCache class will be Deprecated,end --CCTransitionShrinkGrow class will be Deprecated,begin function DeprecatedClass.CCTransitionShrinkGrow() deprecatedTip("CCTransitionShrinkGrow","cc.TransitionShrinkGrow") return cc.TransitionShrinkGrow end _G["CCTransitionShrinkGrow"] = DeprecatedClass.CCTransitionShrinkGrow() --CCTransitionShrinkGrow class will be Deprecated,end --CCSplitCols class will be Deprecated,begin function DeprecatedClass.CCSplitCols() deprecatedTip("CCSplitCols","cc.SplitCols") return cc.SplitCols end _G["CCSplitCols"] = DeprecatedClass.CCSplitCols() --CCSplitCols class will be Deprecated,end --CCClippingNode class will be Deprecated,begin function DeprecatedClass.CCClippingNode() deprecatedTip("CCClippingNode","cc.ClippingNode") return cc.ClippingNode end _G["CCClippingNode"] = DeprecatedClass.CCClippingNode() --CCClippingNode class will be Deprecated,end --CCEaseBounceInOut class will be Deprecated,begin function DeprecatedClass.CCEaseBounceInOut() deprecatedTip("CCEaseBounceInOut","cc.EaseBounceInOut") return cc.EaseBounceInOut end _G["CCEaseBounceInOut"] = DeprecatedClass.CCEaseBounceInOut() --CCEaseBounceInOut class will be Deprecated,end --CCLiquid class will be Deprecated,begin function DeprecatedClass.CCLiquid() deprecatedTip("CCLiquid","cc.Liquid") return cc.Liquid end _G["CCLiquid"] = DeprecatedClass.CCLiquid() --CCLiquid class will be Deprecated,end --CCParticleFlower class will be Deprecated,begin function DeprecatedClass.CCParticleFlower() deprecatedTip("CCParticleFlower","cc.ParticleFlower") return cc.ParticleFlower end _G["CCParticleFlower"] = DeprecatedClass.CCParticleFlower() --CCParticleFlower class will be Deprecated,end --CCTableView class will be Deprecated,begin function DeprecatedClass.CCTableView() deprecatedTip("CCTableView","cc.TableView") return cc.TableView end _G["CCTableView"] = DeprecatedClass.CCTableView() --CCTableView class will be Deprecated,end --CCParticleSmoke class will be Deprecated,begin function DeprecatedClass.CCParticleSmoke() deprecatedTip("CCParticleSmoke","cc.ParticleSmoke") return cc.ParticleSmoke end _G["CCParticleSmoke"] = DeprecatedClass.CCParticleSmoke() --CCParticleSmoke class will be Deprecated,end --CCImage class will be Deprecated,begin function DeprecatedClass.CCImage() deprecatedTip("CCImage","cc.Image") return cc.Image end _G["CCImage"] = DeprecatedClass.CCImage() --CCImage class will be Deprecated,end --CCTurnOffTiles class will be Deprecated,begin function DeprecatedClass.CCTurnOffTiles() deprecatedTip("CCTurnOffTiles","cc.TurnOffTiles") return cc.TurnOffTiles end _G["CCTurnOffTiles"] = DeprecatedClass.CCTurnOffTiles() --CCTurnOffTiles class will be Deprecated,end --CCBlink class will be Deprecated,begin function DeprecatedClass.CCBlink() deprecatedTip("CCBlink","cc.Blink") return cc.Blink end _G["CCBlink"] = DeprecatedClass.CCBlink() --CCBlink class will be Deprecated,end --CCShaderCache class will be Deprecated,begin function DeprecatedClass.CCShaderCache() deprecatedTip("CCShaderCache","cc.ShaderCache") return cc.ShaderCache end _G["CCShaderCache"] = DeprecatedClass.CCShaderCache() --CCShaderCache class will be Deprecated,end --CCJumpTo class will be Deprecated,begin function DeprecatedClass.CCJumpTo() deprecatedTip("CCJumpTo","cc.JumpTo") return cc.JumpTo end _G["CCJumpTo"] = DeprecatedClass.CCJumpTo() --CCJumpTo class will be Deprecated,end --CCAtlasNode class will be Deprecated,begin function DeprecatedClass.CCAtlasNode() deprecatedTip("CCAtlasNode","cc.AtlasNode") return cc.AtlasNode end _G["CCAtlasNode"] = DeprecatedClass.CCAtlasNode() --CCAtlasNode class will be Deprecated,end --CCTransitionJumpZoom class will be Deprecated,begin function DeprecatedClass.CCTransitionJumpZoom() deprecatedTip("CCTransitionJumpZoom","cc.TransitionJumpZoom") return cc.TransitionJumpZoom end _G["CCTransitionJumpZoom"] = DeprecatedClass.CCTransitionJumpZoom() --CCTransitionJumpZoom class will be Deprecated,end --CCTransitionProgressVertical class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressVertical() deprecatedTip("CCTransitionProgressVertical","cc.TransitionProgressVertical") return cc.TransitionProgressVertical end _G["CCTransitionProgressVertical"] = DeprecatedClass.CCTransitionProgressVertical() --CCTransitionProgressVertical class will be Deprecated,end --CCAnimationFrame class will be Deprecated,begin function DeprecatedClass.CCAnimationFrame() deprecatedTip("CCAnimationFrame","cc.AnimationFrame") return cc.AnimationFrame end _G["CCAnimationFrame"] = DeprecatedClass.CCAnimationFrame() --CCAnimationFrame class will be Deprecated,end --CCTintTo class will be Deprecated,begin function DeprecatedClass.CCTintTo() deprecatedTip("CCTintTo","cc.TintTo") return cc.TintTo end _G["CCTintTo"] = DeprecatedClass.CCTintTo() --CCTintTo class will be Deprecated,end --CCTiledGrid3DAction class will be Deprecated,begin function DeprecatedClass.CCTiledGrid3DAction() deprecatedTip("CCTiledGrid3DAction","cc.TiledGrid3DAction") return cc.TiledGrid3DAction end _G["CCTiledGrid3DAction"] = DeprecatedClass.CCTiledGrid3DAction() --CCTiledGrid3DAction class will be Deprecated,end --CCTMXTilesetInfo class will be Deprecated,begin function DeprecatedClass.CCTMXTilesetInfo() deprecatedTip("CCTMXTilesetInfo","cc.TMXTilesetInfo") return cc.TMXTilesetInfo end _G["CCTMXTilesetInfo"] = DeprecatedClass.CCTMXTilesetInfo() --CCTMXTilesetInfo class will be Deprecated,end --CCTMXObjectGroup class will be Deprecated,begin function DeprecatedClass.CCTMXObjectGroup() deprecatedTip("CCTMXObjectGroup","cc.TMXObjectGroup") return cc.TMXObjectGroup end _G["CCTMXObjectGroup"] = DeprecatedClass.CCTMXObjectGroup() --CCTMXObjectGroup class will be Deprecated,end --CCParticleGalaxy class will be Deprecated,begin function DeprecatedClass.CCParticleGalaxy() deprecatedTip("CCParticleGalaxy","cc.ParticleGalaxy") return cc.ParticleGalaxy end _G["CCParticleGalaxy"] = DeprecatedClass.CCParticleGalaxy() --CCParticleGalaxy class will be Deprecated,end --CCTwirl class will be Deprecated,begin function DeprecatedClass.CCTwirl() deprecatedTip("CCTwirl","cc.Twirl") return cc.Twirl end _G["CCTwirl"] = DeprecatedClass.CCTwirl() --CCTwirl class will be Deprecated,end --CCMenuItemLabel class will be Deprecated,begin function DeprecatedClass.CCMenuItemLabel() deprecatedTip("CCMenuItemLabel","cc.MenuItemLabel") return cc.MenuItemLabel end _G["CCMenuItemLabel"] = DeprecatedClass.CCMenuItemLabel() --CCMenuItemLabel class will be Deprecated,end --CCLayerColor class will be Deprecated,begin function DeprecatedClass.CCLayerColor() deprecatedTip("CCLayerColor","cc.LayerColor") return cc.LayerColor end _G["CCLayerColor"] = DeprecatedClass.CCLayerColor() --CCLayerColor class will be Deprecated,end --CCFadeOutBLTiles class will be Deprecated,begin function DeprecatedClass.CCFadeOutBLTiles() deprecatedTip("CCFadeOutBLTiles","cc.FadeOutBLTiles") return cc.FadeOutBLTiles end _G["CCFadeOutBLTiles"] = DeprecatedClass.CCFadeOutBLTiles() --CCFadeOutBLTiles class will be Deprecated,end --CCTransitionProgress class will be Deprecated,begin function DeprecatedClass.CCTransitionProgress() deprecatedTip("CCTransitionProgress","cc.TransitionProgress") return cc.TransitionProgress end _G["CCTransitionProgress"] = DeprecatedClass.CCTransitionProgress() --CCTransitionProgress class will be Deprecated,end --CCEaseRateAction class will be Deprecated,begin function DeprecatedClass.CCEaseRateAction() deprecatedTip("CCEaseRateAction","cc.EaseRateAction") return cc.EaseRateAction end _G["CCEaseRateAction"] = DeprecatedClass.CCEaseRateAction() --CCEaseRateAction class will be Deprecated,end --CCLayerGradient class will be Deprecated,begin function DeprecatedClass.CCLayerGradient() deprecatedTip("CCLayerGradient","cc.LayerGradient") return cc.LayerGradient end _G["CCLayerGradient"] = DeprecatedClass.CCLayerGradient() --CCLayerGradient class will be Deprecated,end --CCMenuItemSprite class will be Deprecated,begin function DeprecatedClass.CCMenuItemSprite() deprecatedTip("CCMenuItemSprite","cc.MenuItemSprite") return cc.MenuItemSprite end _G["CCMenuItemSprite"] = DeprecatedClass.CCMenuItemSprite() --CCMenuItemSprite class will be Deprecated,end --CCNode class will be Deprecated,begin function DeprecatedClass.CCNode() deprecatedTip("CCNode","cc.Node") return cc.Node end _G["CCNode"] = DeprecatedClass.CCNode() --CCNode class will be Deprecated,end --CCToggleVisibility class will be Deprecated,begin function DeprecatedClass.CCToggleVisibility() deprecatedTip("CCToggleVisibility","cc.ToggleVisibility") return cc.ToggleVisibility end _G["CCToggleVisibility"] = DeprecatedClass.CCToggleVisibility() --CCToggleVisibility class will be Deprecated,end --CCRepeat class will be Deprecated,begin function DeprecatedClass.CCRepeat() deprecatedTip("CCRepeat","cc.Repeat") return cc.Repeat end _G["CCRepeat"] = DeprecatedClass.CCRepeat() --CCRepeat class will be Deprecated,end --CCRenderTexture class will be Deprecated,begin function DeprecatedClass.CCRenderTexture() deprecatedTip("CCRenderTexture","cc.RenderTexture") return cc.RenderTexture end _G["CCRenderTexture"] = DeprecatedClass.CCRenderTexture() --CCRenderTexture class will be Deprecated,end --CCTransitionFlipY class will be Deprecated,begin function DeprecatedClass.CCTransitionFlipY() deprecatedTip("CCTransitionFlipY","cc.TransitionFlipY") return cc.TransitionFlipY end _G["CCTransitionFlipY"] = DeprecatedClass.CCTransitionFlipY() --CCTransitionFlipY class will be Deprecated,end --CCLayerMultiplex class will be Deprecated,begin function DeprecatedClass.CCLayerMultiplex() deprecatedTip("CCLayerMultiplex","cc.LayerMultiplex") return cc.LayerMultiplex end _G["CCLayerMultiplex"] = DeprecatedClass.CCLayerMultiplex() --CCLayerMultiplex class will be Deprecated,end --CCTMXLayerInfo class will be Deprecated,begin function DeprecatedClass.CCTMXLayerInfo() deprecatedTip("CCTMXLayerInfo","cc.TMXLayerInfo") return cc.TMXLayerInfo end _G["CCTMXLayerInfo"] = DeprecatedClass.CCTMXLayerInfo() --CCTMXLayerInfo class will be Deprecated,end --CCEaseBackInOut class will be Deprecated,begin function DeprecatedClass.CCEaseBackInOut() deprecatedTip("CCEaseBackInOut","cc.EaseBackInOut") return cc.EaseBackInOut end _G["CCEaseBackInOut"] = DeprecatedClass.CCEaseBackInOut() --CCEaseBackInOut class will be Deprecated,end --CCActionInstant class will be Deprecated,begin function DeprecatedClass.CCActionInstant() deprecatedTip("CCActionInstant","cc.ActionInstant") return cc.ActionInstant end _G["CCActionInstant"] = DeprecatedClass.CCActionInstant() --CCActionInstant class will be Deprecated,end --CCTargetedAction class will be Deprecated,begin function DeprecatedClass.CCTargetedAction() deprecatedTip("CCTargetedAction","cc.TargetedAction") return cc.TargetedAction end _G["CCTargetedAction"] = DeprecatedClass.CCTargetedAction() --CCTargetedAction class will be Deprecated,end --CCDrawNode class will be Deprecated,begin function DeprecatedClass.CCDrawNode() deprecatedTip("CCDrawNode","cc.DrawNode") return cc.DrawNode end _G["CCDrawNode"] = DeprecatedClass.CCDrawNode() --CCDrawNode class will be Deprecated,end --CCTransitionTurnOffTiles class will be Deprecated,begin function DeprecatedClass.CCTransitionTurnOffTiles() deprecatedTip("CCTransitionTurnOffTiles","cc.TransitionTurnOffTiles") return cc.TransitionTurnOffTiles end _G["CCTransitionTurnOffTiles"] = DeprecatedClass.CCTransitionTurnOffTiles() --CCTransitionTurnOffTiles class will be Deprecated,end --CCRotateTo class will be Deprecated,begin function DeprecatedClass.CCRotateTo() deprecatedTip("CCRotateTo","cc.RotateTo") return cc.RotateTo end _G["CCRotateTo"] = DeprecatedClass.CCRotateTo() --CCRotateTo class will be Deprecated,end --CCTransitionSplitRows class will be Deprecated,begin function DeprecatedClass.CCTransitionSplitRows() deprecatedTip("CCTransitionSplitRows","cc.TransitionSplitRows") return cc.TransitionSplitRows end _G["CCTransitionSplitRows"] = DeprecatedClass.CCTransitionSplitRows() --CCTransitionSplitRows class will be Deprecated,end --CCTransitionProgressRadialCCW class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressRadialCCW() deprecatedTip("CCTransitionProgressRadialCCW","cc.TransitionProgressRadialCCW") return cc.TransitionProgressRadialCCW end _G["CCTransitionProgressRadialCCW"] = DeprecatedClass.CCTransitionProgressRadialCCW() --CCTransitionProgressRadialCCW class will be Deprecated,end --CCScaleTo class will be Deprecated,begin function DeprecatedClass.CCScaleTo() deprecatedTip("CCScaleTo","cc.ScaleTo") return cc.ScaleTo end _G["CCScaleTo"] = DeprecatedClass.CCScaleTo() --CCScaleTo class will be Deprecated,end --CCTransitionPageTurn class will be Deprecated,begin function DeprecatedClass.CCTransitionPageTurn() deprecatedTip("CCTransitionPageTurn","cc.TransitionPageTurn") return cc.TransitionPageTurn end _G["CCTransitionPageTurn"] = DeprecatedClass.CCTransitionPageTurn() --CCTransitionPageTurn class will be Deprecated,end --CCParticleExplosion class will be Deprecated,begin function DeprecatedClass.CCParticleExplosion() deprecatedTip("CCParticleExplosion","cc.ParticleExplosion") return cc.ParticleExplosion end _G["CCParticleExplosion"] = DeprecatedClass.CCParticleExplosion() --CCParticleExplosion class will be Deprecated,end --CCMenu class will be Deprecated,begin function DeprecatedClass.CCMenu() deprecatedTip("CCMenu","cc.Menu") return cc.Menu end _G["CCMenu"] = DeprecatedClass.CCMenu() --CCMenu class will be Deprecated,end --CCTexture2D class will be Deprecated,begin function DeprecatedClass.CCTexture2D() deprecatedTip("CCTexture2D","cc.Texture2D") return cc.Texture2D end _G["CCTexture2D"] = DeprecatedClass.CCTexture2D() --CCTexture2D class will be Deprecated,end --CCActionManager class will be Deprecated,begin function DeprecatedClass.CCActionManager() deprecatedTip("CCActionManager","cc.ActionManager") return cc.ActionManager end _G["CCActionManager"] = DeprecatedClass.CCActionManager() --CCActionManager class will be Deprecated,end --CCParticleBatchNode class will be Deprecated,begin function DeprecatedClass.CCParticleBatchNode() deprecatedTip("CCParticleBatchNode","cc.ParticleBatchNode") return cc.ParticleBatchNode end _G["CCParticleBatchNode"] = DeprecatedClass.CCParticleBatchNode() --CCParticleBatchNode class will be Deprecated,end --CCTransitionZoomFlipX class will be Deprecated,begin function DeprecatedClass.CCTransitionZoomFlipX() deprecatedTip("CCTransitionZoomFlipX","cc.TransitionZoomFlipX") return cc.TransitionZoomFlipX end _G["CCTransitionZoomFlipX"] = DeprecatedClass.CCTransitionZoomFlipX() --CCTransitionZoomFlipX class will be Deprecated,end --CCControlPotentiometer class will be Deprecated,begin function DeprecatedClass.CCControlPotentiometer() deprecatedTip("CCControlPotentiometer","cc.ControlPotentiometer") return cc.ControlPotentiometer end _G["CCControlPotentiometer"] = DeprecatedClass.CCControlPotentiometer() --CCControlPotentiometer class will be Deprecated,end --CCScaleBy class will be Deprecated,begin function DeprecatedClass.CCScaleBy() deprecatedTip("CCScaleBy","cc.ScaleBy") return cc.ScaleBy end _G["CCScaleBy"] = DeprecatedClass.CCScaleBy() --CCScaleBy class will be Deprecated,end --CCTileMapAtlas class will be Deprecated,begin function DeprecatedClass.CCTileMapAtlas() deprecatedTip("CCTileMapAtlas","cc.TileMapAtlas") return cc.TileMapAtlas end _G["CCTileMapAtlas"] = DeprecatedClass.CCTileMapAtlas() --CCTileMapAtlas class will be Deprecated,end --CCAction class will be Deprecated,begin function DeprecatedClass.CCAction() deprecatedTip("CCAction","cc.Action") return cc.Action end _G["CCAction"] = DeprecatedClass.CCAction() --CCAction class will be Deprecated,end --CCLens3D class will be Deprecated,begin function DeprecatedClass.CCLens3D() deprecatedTip("CCLens3D","cc.Lens3D") return cc.Lens3D end _G["CCLens3D"] = DeprecatedClass.CCLens3D() --CCLens3D class will be Deprecated,end --CCAnimation class will be Deprecated,begin function DeprecatedClass.CCAnimation() deprecatedTip("CCAnimation","cc.Animation") return cc.Animation end _G["CCAnimation"] = DeprecatedClass.CCAnimation() --CCAnimation class will be Deprecated,end --CCTransitionSlideInT class will be Deprecated,begin function DeprecatedClass.CCTransitionSlideInT() deprecatedTip("CCTransitionSlideInT","cc.TransitionSlideInT") return cc.TransitionSlideInT end _G["CCTransitionSlideInT"] = DeprecatedClass.CCTransitionSlideInT() --CCTransitionSlideInT class will be Deprecated,end --CCSpawn class will be Deprecated,begin function DeprecatedClass.CCSpawn() deprecatedTip("CCSpawn","cc.Spawn") return cc.Spawn end _G["CCSpawn"] = DeprecatedClass.CCSpawn() --CCSpawn class will be Deprecated,end --CCSet class will be Deprecated,begin function DeprecatedClass.CCSet() deprecatedTip("CCSet","cc.Set") return cc.Set end _G["CCSet"] = DeprecatedClass.CCSet() --CCSet class will be Deprecated,end --CCShakyTiles3D class will be Deprecated,begin function DeprecatedClass.CCShakyTiles3D() deprecatedTip("CCShakyTiles3D","cc.ShakyTiles3D") return cc.ShakyTiles3D end _G["CCShakyTiles3D"] = DeprecatedClass.CCShakyTiles3D() --CCShakyTiles3D class will be Deprecated,end --CCPageTurn3D class will be Deprecated,begin function DeprecatedClass.CCPageTurn3D() deprecatedTip("CCPageTurn3D","cc.PageTurn3D") return cc.PageTurn3D end _G["CCPageTurn3D"] = DeprecatedClass.CCPageTurn3D() --CCPageTurn3D class will be Deprecated,end --CCGrid3D class will be Deprecated,begin function DeprecatedClass.CCGrid3D() deprecatedTip("CCGrid3D","cc.Grid3D") return cc.Grid3D end _G["CCGrid3D"] = DeprecatedClass.CCGrid3D() --CCGrid3D class will be Deprecated,end --CCTransitionProgressInOut class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressInOut() deprecatedTip("CCTransitionProgressInOut","cc.TransitionProgressInOut") return cc.TransitionProgressInOut end _G["CCTransitionProgressInOut"] = DeprecatedClass.CCTransitionProgressInOut() --CCTransitionProgressInOut class will be Deprecated,end --CCTransitionFadeBL class will be Deprecated,begin function DeprecatedClass.CCTransitionFadeBL() deprecatedTip("CCTransitionFadeBL","cc.TransitionFadeBL") return cc.TransitionFadeBL end _G["CCTransitionFadeBL"] = DeprecatedClass.CCTransitionFadeBL() --CCTransitionFadeBL class will be Deprecated,end --CCCamera class will be Deprecated,begin function DeprecatedClass.CCCamera() deprecatedTip("CCCamera","cc.Camera") return cc.Camera end _G["CCCamera"] = DeprecatedClass.CCCamera() --CCCamera class will be Deprecated,end --CCLayerRGBA class will be Deprecated,begin function DeprecatedClass.CCLayerRGBA() deprecatedTip("CCLayerRGBA","cc.Layer") return cc.Layer end _G["CCLayerRGBA"] = DeprecatedClass.CCLayerRGBA() --CCLayerRGBA class will be Deprecated,end --LayerRGBA class will be Deprecated,begin function DeprecatedClass.LayerRGBA() deprecatedTip("cc.LayerRGBA","cc.Layer") return cc.Layer end _G["cc"]["LayerRGBA"] = DeprecatedClass.LayerRGBA() --LayerRGBA class will be Deprecated,end --CCBezierTo class will be Deprecated,begin function DeprecatedClass.CCBezierTo() deprecatedTip("CCBezierTo","cc.BezierTo") return cc.BezierTo end _G["CCBezierTo"] = DeprecatedClass.CCBezierTo() --CCBezierTo class will be Deprecated,end --CCControlButton class will be Deprecated,begin function DeprecatedClass.CCControlButton() deprecatedTip("CCControlButton","cc.ControlButton") return cc.ControlButton end _G["CCControlButton"] = DeprecatedClass.CCControlButton() --CCControlButton class will be Deprecated,end --CCFollow class will be Deprecated,begin function DeprecatedClass.CCFollow() deprecatedTip("CCFollow","cc.Follow") return cc.Follow end _G["CCFollow"] = DeprecatedClass.CCFollow() --CCFollow class will be Deprecated,end --CCTintBy class will be Deprecated,begin function DeprecatedClass.CCTintBy() deprecatedTip("CCTintBy","cc.TintBy") return cc.TintBy end _G["CCTintBy"] = DeprecatedClass.CCTintBy() --CCTintBy class will be Deprecated,end --CCActionInterval class will be Deprecated,begin function DeprecatedClass.CCActionInterval() deprecatedTip("CCActionInterval","cc.ActionInterval") return cc.ActionInterval end _G["CCActionInterval"] = DeprecatedClass.CCActionInterval() --CCActionInterval class will be Deprecated,end --CCAnimate class will be Deprecated,begin function DeprecatedClass.CCAnimate() deprecatedTip("CCAnimate","cc.Animate") return cc.Animate end _G["CCAnimate"] = DeprecatedClass.CCAnimate() --CCAnimate class will be Deprecated,end --CCProgressTimer class will be Deprecated,begin function DeprecatedClass.CCProgressTimer() deprecatedTip("CCProgressTimer","cc.ProgressTimer") return cc.ProgressTimer end _G["CCProgressTimer"] = DeprecatedClass.CCProgressTimer() --CCProgressTimer class will be Deprecated,end --CCParticleMeteor class will be Deprecated,begin function DeprecatedClass.CCParticleMeteor() deprecatedTip("CCParticleMeteor","cc.ParticleMeteor") return cc.ParticleMeteor end _G["CCParticleMeteor"] = DeprecatedClass.CCParticleMeteor() --CCParticleMeteor class will be Deprecated,end --CCTransitionFadeTR class will be Deprecated,begin function DeprecatedClass.CCTransitionFadeTR() deprecatedTip("CCTransitionFadeTR","cc.TransitionFadeTR") return cc.TransitionFadeTR end _G["CCTransitionFadeTR"] = DeprecatedClass.CCTransitionFadeTR() --CCTransitionFadeTR class will be Deprecated,end --CCCatmullRomTo class will be Deprecated,begin function DeprecatedClass.CCCatmullRomTo() deprecatedTip("CCCatmullRomTo","cc.CatmullRomTo") return cc.CatmullRomTo end _G["CCCatmullRomTo"] = DeprecatedClass.CCCatmullRomTo() --CCCatmullRomTo class will be Deprecated,end --CCTransitionZoomFlipY class will be Deprecated,begin function DeprecatedClass.CCTransitionZoomFlipY() deprecatedTip("CCTransitionZoomFlipY","cc.TransitionZoomFlipY") return cc.TransitionZoomFlipY end _G["CCTransitionZoomFlipY"] = DeprecatedClass.CCTransitionZoomFlipY() --CCTransitionZoomFlipY class will be Deprecated,end --CCTransitionCrossFade class will be Deprecated,begin function DeprecatedClass.CCTransitionCrossFade() deprecatedTip("CCTransitionCrossFade","cc.TransitionCrossFade") return cc.TransitionCrossFade end _G["CCTransitionCrossFade"] = DeprecatedClass.CCTransitionCrossFade() --CCTransitionCrossFade class will be Deprecated,end --CCGridBase class will be Deprecated,begin function DeprecatedClass.CCGridBase() deprecatedTip("CCGridBase","cc.GridBase") return cc.GridBase end _G["CCGridBase"] = DeprecatedClass.CCGridBase() --CCGridBase class will be Deprecated,end --CCSkewTo class will be Deprecated,begin function DeprecatedClass.CCSkewTo() deprecatedTip("CCSkewTo","cc.SkewTo") return cc.SkewTo end _G["CCSkewTo"] = DeprecatedClass.CCSkewTo() --CCSkewTo class will be Deprecated,end --CCCardinalSplineTo class will be Deprecated,begin function DeprecatedClass.CCCardinalSplineTo() deprecatedTip("CCCardinalSplineTo","cc.CardinalSplineTo") return cc.CardinalSplineTo end _G["CCCardinalSplineTo"] = DeprecatedClass.CCCardinalSplineTo() --CCCardinalSplineTo class will be Deprecated,end --CCTMXMapInfo class will be Deprecated,begin function DeprecatedClass.CCTMXMapInfo() deprecatedTip("CCTMXMapInfo","cc.TMXMapInfo") return cc.TMXMapInfo end _G["CCTMXMapInfo"] = DeprecatedClass.CCTMXMapInfo() --CCTMXMapInfo class will be Deprecated,end --CCEaseExponentialIn class will be Deprecated,begin function DeprecatedClass.CCEaseExponentialIn() deprecatedTip("CCEaseExponentialIn","cc.EaseExponentialIn") return cc.EaseExponentialIn end _G["CCEaseExponentialIn"] = DeprecatedClass.CCEaseExponentialIn() --CCEaseExponentialIn class will be Deprecated,end --CCReuseGrid class will be Deprecated,begin function DeprecatedClass.CCReuseGrid() deprecatedTip("CCReuseGrid","cc.ReuseGrid") return cc.ReuseGrid end _G["CCReuseGrid"] = DeprecatedClass.CCReuseGrid() --CCReuseGrid class will be Deprecated,end --CCMenuItemAtlasFont class will be Deprecated,begin function DeprecatedClass.CCMenuItemAtlasFont() deprecatedTip("CCMenuItemAtlasFont","cc.MenuItemAtlasFont") return cc.MenuItemAtlasFont end _G["CCMenuItemAtlasFont"] = DeprecatedClass.CCMenuItemAtlasFont() --CCMenuItemAtlasFont class will be Deprecated,end --CCSpriteFrame class will be Deprecated,begin function DeprecatedClass.CCSpriteFrame() deprecatedTip("CCSpriteFrame","cc.SpriteFrame") return cc.SpriteFrame end _G["CCSpriteFrame"] = DeprecatedClass.CCSpriteFrame() --CCSpriteFrame class will be Deprecated,end --CCSplitRows class will be Deprecated,begin function DeprecatedClass.CCSplitRows() deprecatedTip("CCSplitRows","cc.SplitRows") return cc.SplitRows end _G["CCSplitRows"] = DeprecatedClass.CCSplitRows() --CCSplitRows class will be Deprecated,end --CCControlStepper class will be Deprecated,begin function DeprecatedClass.CCControlStepper() deprecatedTip("CCControlStepper","cc.ControlStepper") return cc.ControlStepper end _G["CCControlStepper"] = DeprecatedClass.CCControlStepper() --CCControlStepper class will be Deprecated,end --CCSprite class will be Deprecated,begin function DeprecatedClass.CCSprite() deprecatedTip("CCSprite","cc.Sprite") return cc.Sprite end _G["CCSprite"] = DeprecatedClass.CCSprite() --CCSprite class will be Deprecated,end --CCOrbitCamera class will be Deprecated,begin function DeprecatedClass.CCOrbitCamera() deprecatedTip("CCOrbitCamera","cc.OrbitCamera") return cc.OrbitCamera end _G["CCOrbitCamera"] = DeprecatedClass.CCOrbitCamera() --CCOrbitCamera class will be Deprecated,end --CCUserDefault class will be Deprecated,begin function DeprecatedClass.CCUserDefault() deprecatedTip("CCUserDefault","cc.UserDefault") return cc.UserDefault end _G["CCUserDefault"] = DeprecatedClass.CCUserDefault() --CCUserDefault class will be Deprecated,end --CCFadeOutUpTiles class will be Deprecated,begin function DeprecatedClass.CCFadeOutUpTiles() deprecatedTip("CCFadeOutUpTiles","cc.FadeOutUpTiles") return cc.FadeOutUpTiles end _G["CCFadeOutUpTiles"] = DeprecatedClass.CCFadeOutUpTiles() --CCFadeOutUpTiles class will be Deprecated,end --CCParticleRain class will be Deprecated,begin function DeprecatedClass.CCParticleRain() deprecatedTip("CCParticleRain","cc.ParticleRain") return cc.ParticleRain end _G["CCParticleRain"] = DeprecatedClass.CCParticleRain() --CCParticleRain class will be Deprecated,end --CCWaves class will be Deprecated,begin function DeprecatedClass.CCWaves() deprecatedTip("CCWaves","cc.Waves") return cc.Waves end _G["CCWaves"] = DeprecatedClass.CCWaves() --CCWaves class will be Deprecated,end --CCEaseOut class will be Deprecated,begin function DeprecatedClass.CCEaseOut() deprecatedTip("CCEaseOut","cc.EaseOut") return cc.EaseOut end _G["CCEaseOut"] = DeprecatedClass.CCEaseOut() --CCEaseOut class will be Deprecated,end --CCEaseBounceIn class will be Deprecated,begin function DeprecatedClass.CCEaseBounceIn() deprecatedTip("CCEaseBounceIn","cc.EaseBounceIn") return cc.EaseBounceIn end _G["CCEaseBounceIn"] = DeprecatedClass.CCEaseBounceIn() --CCEaseBounceIn class will be Deprecated,end --CCMenuItemFont class will be Deprecated,begin function DeprecatedClass.CCMenuItemFont() deprecatedTip("CCMenuItemFont","cc.MenuItemFont") return cc.MenuItemFont end _G["CCMenuItemFont"] = DeprecatedClass.CCMenuItemFont() --CCMenuItemFont class will be Deprecated,end --CCEaseSineOut class will be Deprecated,begin function DeprecatedClass.CCEaseSineOut() deprecatedTip("CCEaseSineOut","cc.EaseSineOut") return cc.EaseSineOut end _G["CCEaseSineOut"] = DeprecatedClass.CCEaseSineOut() --CCEaseSineOut class will be Deprecated,end --CCTextureCache class will be Deprecated,begin function DeprecatedClass.CCTextureCache() deprecatedTip("CCTextureCache","cc.TextureCache") return cc.TextureCache end _G["CCTextureCache"] = DeprecatedClass.CCTextureCache() --CCTextureCache class will be Deprecated,end --CCTiledGrid3D class will be Deprecated,begin function DeprecatedClass.CCTiledGrid3D() deprecatedTip("CCTiledGrid3D","cc.TiledGrid3D") return cc.TiledGrid3D end _G["CCTiledGrid3D"] = DeprecatedClass.CCTiledGrid3D() --CCTiledGrid3D class will be Deprecated,end --CCRemoveSelf class will be Deprecated,begin function DeprecatedClass.CCRemoveSelf() deprecatedTip("CCRemoveSelf","cc.RemoveSelf") return cc.RemoveSelf end _G["CCRemoveSelf"] = DeprecatedClass.CCRemoveSelf() --CCRemoveSelf class will be Deprecated,end --CCControlSaturationBrightnessPicker class will be Deprecated,begin function DeprecatedClass.CCControlSaturationBrightnessPicker() deprecatedTip("CCControlSaturationBrightnessPicker","cc.ControlSaturationBrightnessPicker") return cc.ControlSaturationBrightnessPicker end _G["CCControlSaturationBrightnessPicker"] = DeprecatedClass.CCControlSaturationBrightnessPicker() --CCControlSaturationBrightnessPicker class will be Deprecated,end --CCLabelTTF class will be Deprecated,begin function DeprecatedClass.CCLabelTTF() deprecatedTip("CCLabelTTF","cc.LabelTTF") return cc.LabelTTF end _G["CCLabelTTF"] = DeprecatedClass.CCLabelTTF() --CCLabelTTF class will be Deprecated,end --CCTouch class will be Deprecated,begin function DeprecatedClass.CCTouch() deprecatedTip("CCTouch","cc.Touch") return cc.Touch end _G["CCTouch"] = DeprecatedClass.CCTouch() --CCTouch class will be Deprecated,end --CCMoveBy class will be Deprecated,begin function DeprecatedClass.CCMoveBy() deprecatedTip("CCMoveBy","cc.MoveBy") return cc.MoveBy end _G["CCMoveBy"] = DeprecatedClass.CCMoveBy() --CCMoveBy class will be Deprecated,end --CCMotionStreak class will be Deprecated,begin function DeprecatedClass.CCMotionStreak() deprecatedTip("CCMotionStreak","cc.MotionStreak") return cc.MotionStreak end _G["CCMotionStreak"] = DeprecatedClass.CCMotionStreak() --CCMotionStreak class will be Deprecated,end --CCRotateBy class will be Deprecated,begin function DeprecatedClass.CCRotateBy() deprecatedTip("CCRotateBy","cc.RotateBy") return cc.RotateBy end _G["CCRotateBy"] = DeprecatedClass.CCRotateBy() --CCRotateBy class will be Deprecated,end --CCFileUtils class will be Deprecated,begin function DeprecatedClass.CCFileUtils() deprecatedTip("CCFileUtils","cc.FileUtils") return cc.FileUtils end _G["CCFileUtils"] = DeprecatedClass.CCFileUtils() --CCFileUtils class will be Deprecated,end --CCBezierBy class will be Deprecated,begin function DeprecatedClass.CCBezierBy() deprecatedTip("CCBezierBy","cc.BezierBy") return cc.BezierBy end _G["CCBezierBy"] = DeprecatedClass.CCBezierBy() --CCBezierBy class will be Deprecated,end --CCTransitionFade class will be Deprecated,begin function DeprecatedClass.CCTransitionFade() deprecatedTip("CCTransitionFade","cc.TransitionFade") return cc.TransitionFade end _G["CCTransitionFade"] = DeprecatedClass.CCTransitionFade() --CCTransitionFade class will be Deprecated,end --CCTransitionProgressOutIn class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressOutIn() deprecatedTip("CCTransitionProgressOutIn","cc.TransitionProgressOutIn") return cc.TransitionProgressOutIn end _G["CCTransitionProgressOutIn"] = DeprecatedClass.CCTransitionProgressOutIn() --CCTransitionProgressOutIn class will be Deprecated,end --CCCatmullRomBy class will be Deprecated,begin function DeprecatedClass.CCCatmullRomBy() deprecatedTip("CCCatmullRomBy","cc.CatmullRomBy") return cc.CatmullRomBy end _G["CCCatmullRomBy"] = DeprecatedClass.CCCatmullRomBy() --CCCatmullRomBy class will be Deprecated,end --CCGridAction class will be Deprecated,begin function DeprecatedClass.CCGridAction() deprecatedTip("CCGridAction","cc.GridAction") return cc.GridAction end _G["CCGridAction"] = DeprecatedClass.CCGridAction() --CCGridAction class will be Deprecated,end --CCShaky3D class will be Deprecated,begin function DeprecatedClass.CCShaky3D() deprecatedTip("CCShaky3D","cc.Shaky3D") return cc.Shaky3D end _G["CCShaky3D"] = DeprecatedClass.CCShaky3D() --CCShaky3D class will be Deprecated,end --CCTransitionEaseScene class will be Deprecated,begin function DeprecatedClass.CCTransitionEaseScene() deprecatedTip("CCTransitionEaseScene","cc.TransitionEaseScene") return cc.TransitionEaseScene end _G["CCTransitionEaseScene"] = DeprecatedClass.CCTransitionEaseScene() --CCTransitionEaseScene class will be Deprecated,end --CCSequence class will be Deprecated,begin function DeprecatedClass.CCSequence() deprecatedTip("CCSequence","cc.Sequence") return cc.Sequence end _G["CCSequence"] = DeprecatedClass.CCSequence() --CCSequence class will be Deprecated,end --CCTransitionFadeUp class will be Deprecated,begin function DeprecatedClass.CCTransitionFadeUp() deprecatedTip("CCTransitionFadeUp","cc.TransitionFadeUp") return cc.TransitionFadeUp end _G["CCTransitionFadeUp"] = DeprecatedClass.CCTransitionFadeUp() --CCTransitionFadeUp class will be Deprecated,end --CCTransitionProgressRadialCW class will be Deprecated,begin function DeprecatedClass.CCTransitionProgressRadialCW() deprecatedTip("CCTransitionProgressRadialCW","cc.TransitionProgressRadialCW") return cc.TransitionProgressRadialCW end _G["CCTransitionProgressRadialCW"] = DeprecatedClass.CCTransitionProgressRadialCW() --CCTransitionProgressRadialCW class will be Deprecated,end --CCShuffleTiles class will be Deprecated,begin function DeprecatedClass.CCShuffleTiles() deprecatedTip("CCShuffleTiles","cc.ShuffleTiles") return cc.ShuffleTiles end _G["CCShuffleTiles"] = DeprecatedClass.CCShuffleTiles() --CCShuffleTiles class will be Deprecated,end --CCTransitionSlideInR class will be Deprecated,begin function DeprecatedClass.CCTransitionSlideInR() deprecatedTip("CCTransitionSlideInR","cc.TransitionSlideInR") return cc.TransitionSlideInR end _G["CCTransitionSlideInR"] = DeprecatedClass.CCTransitionSlideInR() --CCTransitionSlideInR class will be Deprecated,end --CCScene class will be Deprecated,begin function DeprecatedClass.CCScene() deprecatedTip("CCScene","cc.Scene") return cc.Scene end _G["CCScene"] = DeprecatedClass.CCScene() --CCScene class will be Deprecated,end --CCParallaxNode class will be Deprecated,begin function DeprecatedClass.CCParallaxNode() deprecatedTip("CCParallaxNode","cc.ParallaxNode") return cc.ParallaxNode end _G["CCParallaxNode"] = DeprecatedClass.CCParallaxNode() --CCParallaxNode class will be Deprecated,end --CCTransitionSlideInL class will be Deprecated,begin function DeprecatedClass.CCTransitionSlideInL() deprecatedTip("CCTransitionSlideInL","cc.TransitionSlideInL") return cc.TransitionSlideInL end _G["CCTransitionSlideInL"] = DeprecatedClass.CCTransitionSlideInL() --CCTransitionSlideInL class will be Deprecated,end --CCControlSwitch class will be Deprecated,begin function DeprecatedClass.CCControlSwitch() deprecatedTip("CCControlSwitch","cc.ControlSwitch") return cc.ControlSwitch end _G["CCControlSwitch"] = DeprecatedClass.CCControlSwitch() --CCControlSwitch class will be Deprecated,end --CCWavesTiles3D class will be Deprecated,begin function DeprecatedClass.CCWavesTiles3D() deprecatedTip("CCWavesTiles3D","cc.WavesTiles3D") return cc.WavesTiles3D end _G["CCWavesTiles3D"] = DeprecatedClass.CCWavesTiles3D() --CCWavesTiles3D class will be Deprecated,end --CCTransitionSlideInB class will be Deprecated,begin function DeprecatedClass.CCTransitionSlideInB() deprecatedTip("CCTransitionSlideInB","cc.TransitionSlideInB") return cc.TransitionSlideInB end _G["CCTransitionSlideInB"] = DeprecatedClass.CCTransitionSlideInB() --CCTransitionSlideInB class will be Deprecated,end --CCSpeed class will be Deprecated,begin function DeprecatedClass.CCSpeed() deprecatedTip("CCSpeed","cc.Speed") return cc.Speed end _G["CCSpeed"] = DeprecatedClass.CCSpeed() --CCSpeed class will be Deprecated,end --CCShatteredTiles3D class will be Deprecated,begin function DeprecatedClass.CCShatteredTiles3D() deprecatedTip("CCShatteredTiles3D","cc.ShatteredTiles3D") return cc.ShatteredTiles3D end _G["CCShatteredTiles3D"] = DeprecatedClass.CCShatteredTiles3D() --CCShatteredTiles3D class will be Deprecated,end --CCCallFuncN class will be Deprecated,begin function DeprecatedClass.CCCallFuncN() deprecatedTip("CCCallFuncN","cc.CallFunc") return cc.CallFunc end _G["CCCallFuncN"] = DeprecatedClass.CCCallFuncN() --CCCallFuncN class will be Deprecated,end --CCArmature class will be Deprecated,begin function DeprecatedClass.CCArmature() deprecatedTip("CCArmature","ccs.Armature") return ccs.Armature end _G["CCArmature"] = DeprecatedClass.CCArmature() --CCArmature class will be Deprecated,end --CCArmatureAnimation class will be Deprecated,begin function DeprecatedClass.CCArmatureAnimation() deprecatedTip("CCArmatureAnimation","ccs.ArmatureAnimation") return ccs.ArmatureAnimation end _G["CCArmatureAnimation"] = DeprecatedClass.CCArmatureAnimation() --CCArmatureAnimation class will be Deprecated,end --CCSkin class will be Deprecated,begin function DeprecatedClass.CCSkin() deprecatedTip("CCSkin","ccs.Skin") return ccs.Skin end _G["CCSkin"] = DeprecatedClass.CCSkin() --CCSkin class will be Deprecated,end --CCBone class will be Deprecated,begin function DeprecatedClass.CCBone() deprecatedTip("CCBone","ccs.Bone") return ccs.Bone end _G["CCBone"] = DeprecatedClass.CCBone() --CCBone class will be Deprecated,end --CCArmatureDataManager class will be Deprecated,begin function DeprecatedClass.CCArmatureDataManager() deprecatedTip("CCArmatureDataManager","ccs.ArmatureDataManager") return ccs.ArmatureDataManager end _G["CCArmatureDataManager"] = DeprecatedClass.CCArmatureDataManager() --CCArmatureDataManager class will be Deprecated,end --CCBatchNode class will be Deprecated,begin function DeprecatedClass.CCBatchNode() deprecatedTip("CCBatchNode","ccs.BatchNode") return ccs.BatchNode end _G["CCBatchNode"] = DeprecatedClass.CCBatchNode() --CCBatchNode class will be Deprecated,end --CCTween class will be Deprecated,begin function DeprecatedClass.CCTween() deprecatedTip("CCTween","ccs.Tween") return ccs.Tween end _G["CCTween"] = DeprecatedClass.CCTween() --CCTween class will be Deprecated,end --CCBaseData class will be Deprecated,begin function DeprecatedClass.CCBaseData() deprecatedTip("CCBaseData","ccs.BaseData") return ccs.BaseData end _G["CCBaseData"] = DeprecatedClass.CCBaseData() --CCBaseData class will be Deprecated,end --CCDisplayManager class will be Deprecated,begin function DeprecatedClass.CCDisplayManager() deprecatedTip("CCDisplayManager","ccs.DisplayManager") return ccs.DisplayManager end _G["CCDisplayManager"] = DeprecatedClass.CCDisplayManager() --CCDisplayManager class will be Deprecated,end --UIHelper class will be Deprecated,begin function DeprecatedClass.UIHelper() deprecatedTip("UIHelper","ccs.UIHelper") return ccs.UIHelper end _G["UIHelper"] = DeprecatedClass.UIHelper() --UIHelper class will be Deprecated,end --UILayout class will be Deprecated,begin function DeprecatedClass.UILayout() deprecatedTip("UILayout","ccs.UILayout") return ccs.UILayout end _G["UILayout"] = DeprecatedClass.UILayout() --UILayout class will be Deprecated,end --UIWidget class will be Deprecated,begin function DeprecatedClass.UIWidget() deprecatedTip("UIWidget","ccs.UIWidget") return ccs.UIWidget end _G["UIWidget"] = DeprecatedClass.UIWidget() --UIWidget class will be Deprecated,end --UILayer class will be Deprecated,begin function DeprecatedClass.UILayer() deprecatedTip("UILayer","ccs.UILayer") return ccs.UILayer end _G["UILayer"] = DeprecatedClass.UILayer() --UILayer class will be Deprecated,end --UIButton class will be Deprecated,begin function DeprecatedClass.UIButton() deprecatedTip("UIButton","ccs.UIButton") return ccs.UIButton end _G["UIButton"] = DeprecatedClass.UIButton() --UIButton class will be Deprecated,end --UICheckBox class will be Deprecated,begin function DeprecatedClass.UICheckBox() deprecatedTip("UICheckBox","ccs.UICheckBox") return ccs.UICheckBox end _G["UICheckBox"] = DeprecatedClass.UICheckBox() --UICheckBox class will be Deprecated,end --UIImageView class will be Deprecated,begin function DeprecatedClass.UIImageView() deprecatedTip("UIImageView","ccs.UIImageView") return ccs.UIImageView end _G["UIImageView"] = DeprecatedClass.UIImageView() --UIImageView class will be Deprecated,end --UILabel class will be Deprecated,begin function DeprecatedClass.UILabel() deprecatedTip("UILabel","ccs.UILabel") return ccs.UILabel end _G["UILabel"] = DeprecatedClass.UILabel() --UILabel class will be Deprecated,end --UILabelAtlas class will be Deprecated,begin function DeprecatedClass.UILabelAtlas() deprecatedTip("UILabelAtlas","ccs.UILabelAtlas") return ccs.UILabelAtlas end _G["UILabelAtlas"] = DeprecatedClass.UILabelAtlas() --UILabelAtlas class will be Deprecated,end --UILabelBMFont class will be Deprecated,begin function DeprecatedClass.UILabelBMFont() deprecatedTip("UILabelBMFont","ccs.UILabelBMFont") return ccs.UILabelBMFont end _G["UILabelBMFont"] = DeprecatedClass.UILabelBMFont() --UILabelBMFont class will be Deprecated,end --UILoadingBar class will be Deprecated,begin function DeprecatedClass.UILoadingBar() deprecatedTip("UILoadingBar","ccs.UILoadingBar") return ccs.UILoadingBar end _G["UILoadingBar"] = DeprecatedClass.UILoadingBar() --UILoadingBar class will be Deprecated,end --UISlider class will be Deprecated,begin function DeprecatedClass.UISlider() deprecatedTip("UISlider","ccs.UISlider") return ccs.UISlider end _G["UISlider"] = DeprecatedClass.UISlider() --UISlider class will be Deprecated,end --UITextField class will be Deprecated,begin function DeprecatedClass.UITextField() deprecatedTip("UITextField","ccs.UITextField") return ccs.UITextField end _G["UITextField"] = DeprecatedClass.UITextField() --UITextField class will be Deprecated,end --UIScrollView class will be Deprecated,begin function DeprecatedClass.UIScrollView() deprecatedTip("UIScrollView","ccs.UIScrollView") return ccs.UIScrollView end _G["UIScrollView"] = DeprecatedClass.UIScrollView() --UIScrollView class will be Deprecated,end --UIPageView class will be Deprecated,begin function DeprecatedClass.UIPageView() deprecatedTip("UIPageView","ccs.UIPageView") return ccs.UIPageView end _G["UIPageView"] = DeprecatedClass.UIPageView() --UIPageView class will be Deprecated,end --UIListView class will be Deprecated,begin function DeprecatedClass.UIListView() deprecatedTip("UIListView","ccs.UIListView") return ccs.UIListView end _G["UIListView"] = DeprecatedClass.UIListView() --UIListView class will be Deprecated,end --UILayoutParameter class will be Deprecated,begin function DeprecatedClass.UILayoutParameter() deprecatedTip("UILayoutParameter","ccs.UILayoutParameter") return ccs.UILayoutParameter end _G["UILayoutParameter"] = DeprecatedClass.UILayoutParameter() --UILayoutParameter class will be Deprecated,end --UILinearLayoutParameter class will be Deprecated,begin function DeprecatedClass.UILinearLayoutParameter() deprecatedTip("UILinearLayoutParameter","ccs.UILinearLayoutParameter") return ccs.UILinearLayoutParameter end _G["UILinearLayoutParameter"] = DeprecatedClass.UILinearLayoutParameter() --UILinearLayoutParameter class will be Deprecated,end --UIRelativeLayoutParameter class will be Deprecated,begin function DeprecatedClass.UIRelativeLayoutParameter() deprecatedTip("UIRelativeLayoutParameter","ccs.UIRelativeLayoutParameter") return ccs.UIRelativeLayoutParameter end _G["UIRelativeLayoutParameter"] = DeprecatedClass.UIRelativeLayoutParameter() --UIRelativeLayoutParameter class will be Deprecated,end --CCComController class will be Deprecated,begin function DeprecatedClass.CCComController() deprecatedTip("CCComController","ccs.ComController") return ccs.CCComController end _G["CCComController"] = DeprecatedClass.CCComController() --CCComController class will be Deprecated,end --CCComAudio class will be Deprecated,begin function DeprecatedClass.CCComAudio() deprecatedTip("CCComAudio","ccs.ComAudio") return ccs.ComAudio end _G["CCComAudio"] = DeprecatedClass.CCComAudio() --CCComAudio class will be Deprecated,end --CCComAttribute class will be Deprecated,begin function DeprecatedClass.CCComAttribute() deprecatedTip("CCComAttribute","ccs.ComAttribute") return ccs.ComAttribute end _G["CCComAttribute"] = DeprecatedClass.CCComAttribute() --CCComAttribute class will be Deprecated,end --CCComRender class will be Deprecated,begin function DeprecatedClass.CCComRender() deprecatedTip("CCComRender","ccs.ComRender") return ccs.ComRender end _G["CCComRender"] = DeprecatedClass.CCComRender() --CCComRender class will be Deprecated,end --ActionManager class will be Deprecated,begin function DeprecatedClass.ActionManager() deprecatedTip("ActionManager","ccs.ActionManagerEx") return ccs.ActionManagerEx end _G["ActionManager"] = DeprecatedClass.ActionManager() --CCComRender class will be Deprecated,end --SceneReader class will be Deprecated,begin function DeprecatedClass.SceneReader() deprecatedTip("SceneReader","ccs.SceneReader") return ccs.SceneReader end _G["SceneReader"] = DeprecatedClass.SceneReader() --SceneReader class will be Deprecated,end --GUIReader class will be Deprecated,begin function DeprecatedClass.GUIReader() deprecatedTip("GUIReader","ccs.GUIReader") return ccs.GUIReader end _G["GUIReader"] = DeprecatedClass.GUIReader() --GUIReader class will be Deprecated,end --UIRootWidget class will be Deprecated,begin function DeprecatedClass.UIRootWidget() deprecatedTip("UIRootWidget","ccs.UIRootWidget") return ccs.UIRootWidget end _G["UIRootWidget"] = DeprecatedClass.UIRootWidget() --UIRootWidget class will be Deprecated,end --ActionObject class will be Deprecated,begin function DeprecatedClass.ActionObject() deprecatedTip("ActionObject","ccs.ActionObject") return ccs.ActionObject end _G["ActionObject"] = DeprecatedClass.ActionObject() --ActionObject class will be Deprecated,end --CCEGLViewProtocol class will be Deprecated,begin function DeprecatedClass.CCEGLViewProtocol() deprecatedTip("CCEGLViewProtocol","cc.EGLViewProtocol") return cc.EGLViewProtocol end _G["CCEGLViewProtocol"] = DeprecatedClass.CCEGLViewProtocol() --CCEGLViewProtocol class will be Deprecated,end --CCEGLView class will be Deprecated,begin function DeprecatedClass.CCEGLView() deprecatedTip("CCEGLView","cc.EGLView") return cc.EGLView end _G["CCEGLView"] = DeprecatedClass.CCEGLView() --CCEGLView class will be Deprecated,end --CCBProxy class will be Deprecated,begin function DeprecatedClass.CCBProxy() deprecatedTip("CCBProxy","cc.CCBProxy") return cc.CCBProxy end _G["CCBProxy"] = DeprecatedClass.CCBProxy() --CCBProxy class will be Deprecated,end --WebSocket class will be Deprecated,begin function DeprecatedClass.WebSocket() deprecatedTip("WebSocket","cc.WebSocket") return cc.WebSocket end _G["WebSocket"] = DeprecatedClass.WebSocket() --WebSocket class will be Deprecated,end --XMLHttpRequest class will be Deprecated,begin function DeprecatedClass.XMLHttpRequest() deprecatedTip("XMLHttpRequest","cc.XMLHttpRequest") return cc.XMLHttpRequest end _G["XMLHttpRequest"] = DeprecatedClass.XMLHttpRequest() --XMLHttpRequest class will be Deprecated,end ================================================ FILE: cocos2d/cocos/scripting/lua/script/DeprecatedEnum.lua ================================================ require "Cocos2dConstants.lua" require "OpenglConstants.lua" require "StudioConstants.lua" --Enums will be deprecated,begin _G.kCCTextAlignmentLeft = cc.TEXT_ALIGNMENT_LEFT _G.kCCTextAlignmentRight = cc.TEXT_ALIGNMENT_RIGHT _G.kCCTextAlignmentCenter = cc.TEXT_ALIGNMENT_CENTER _G.kCCVerticalTextAlignmentTop = cc.VERTICAL_TEXT_ALIGNMENT_TOP _G.kCCVerticalTextAlignmentCenter = cc.VERTICAL_TEXT_ALIGNMENT_CENTER _G.kCCVerticalTextAlignmentBottom = cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM _G.kCCDirectorProjection3D = cc.DIRECTOR_PROJECTION3_D _G.kCCDirectorProjection2D = cc.DIRECTOR_PROJECTION2_D _G.kCCDirectorProjectionCustom = cc.DIRECTOR_PROJECTION_CUSTOM _G.kCCDirectorProjectionDefault = cc.DIRECTOR_PROJECTION_DEFAULT _G.kCCNodeTagInvalid = cc.NODE_TAG_INVALID _G.kCCNodeOnEnter = cc.NODE_ON_ENTER _G.kCCNodeOnExit = cc.NODE_ON_EXIT _G.kCCTexture2DPixelFormat_RGBA8888 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 _G.kCCTexture2DPixelFormat_RGB888 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 _G.kCCTexture2DPixelFormat_RGB565 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 _G.kCCTexture2DPixelFormat_A8 = cc.TEXTURE2_D_PIXEL_FORMAT_A8 _G.kCCTexture2DPixelFormat_I8 = cc.TEXTURE2_D_PIXEL_FORMAT_I8 _G.kCCTexture2DPixelFormat_AI88 = cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 _G.kCCTexture2DPixelFormat_RGBA4444 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 _G.kCCTexture2DPixelFormat_RGB5A1 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 _G.kCCTexture2DPixelFormat_PVRTC4 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 _G.kCCTexture2DPixelFormat_PVRTC2 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 _G.kCCTexture2DPixelFormat_Default = cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT _G.kCCImageFormatPNG = cc.IMAGE_FORMAT_PNG _G.kCCImageFormatJPEG = cc.IMAGE_FORMAT_JPEG _G.kCCTouchesOneByOne = cc.TOUCHES_ONE_BY_ONE _G.kCCTouchesAllAtOnce = cc.TOUCHES_ALL_AT_ONCE _G.kCCTransitionOrientationLeftOver = cc.TRANSITION_ORIENTATION_LEFT_OVER _G.kCCTransitionOrientationRightOver = cc.TRANSITION_ORIENTATION_RIGHT_OVER _G.kCCTransitionOrientationUpOver = cc.TRANSITION_ORIENTATION_UP_OVER _G.kCCTransitionOrientationDownOver = cc.TRANSITION_ORIENTATION_DOWN_OVER _G.kCCActionTagInvalid = cc.ACTION_TAG_INVALID _G.kCCLabelAutomaticWidth = cc.LABEL_AUTOMATIC_WIDTH _G.kCCMenuStateWaiting = cc.MENU_STATE_WAITING _G.kCCMenuStateTrackingTouch = cc.MENU_STATE_TRACKING_TOUCH _G.kCCMenuHandlerPriority = cc.MENU_HANDLER_PRIORITY _G.kCCParticleDurationInfinity = cc.PARTICLE_DURATION_INFINITY _G.kCCParticleStartSizeEqualToEndSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE _G.kCCParticleStartRadiusEqualToEndRadius = cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS _G.kCCParticleModeGravity = cc.PARTICLE_MODE_GRAVITY _G.kCCParticleModeRadius = cc.PARTICLE_MODE_RADIUS _G.kCCPositionTypeFree = cc.POSITION_TYPE_FREE _G.kCCPositionTypeRelative = cc.POSITION_TYPE_RELATIVE _G.kCCPositionTypeGrouped = cc.POSITION_TYPE_GROUPED _G.kCCProgressTimerTypeRadial = cc.PROGRESS_TIMER_TYPE_RADIAL _G.kCCProgressTimerTypeBar = cc.PROGRESS_TIMER_TYPE_BAR _G.kCCTMXTileHorizontalFlag = cc.TMX_TILE_HORIZONTAL_FLAG _G.kCCTMXTileVerticalFlag = cc.TMX_TILE_VERTICAL_FLAG _G.kCCTMXTileDiagonalFlag = cc.TMX_TILE_DIAGONAL_FLAG _G.kCCFlipedAll = cc.FLIPED_ALL _G.kCCFlippedMask = cc.FLIPPED_MASK _G.kCCControlStepperPartMinus = cc.CONTROL_STEPPER_PART_MINUS _G.kCCControlStepperPartPlus = cc.CONTROL_STEPPER_PART_PLUS _G.kCCControlStepperPartNone = cc.CONTROL_STEPPER_PART_NONE _G.kLanguageEnglish = cc.LANGUAGE_ENGLISH _G.kLanguageChinese = cc.LANGUAGE_CHINESE _G.kLanguageFrench = cc.LANGUAGE_FRENCH _G.kLanguageItalian = cc.LANGUAGE_ITALIAN _G.kLanguageGerman = cc.LANGUAGE_GERMAN _G.kLanguageSpanish = cc.LANGUAGE_SPANISH _G.kLanguageRussian = cc.LANGUAGE_RUSSIAN _G.kLanguageKorean = cc.LANGUAGE_KOREAN _G.kLanguageJapanese = cc.LANGUAGE_JAPANESE _G.kLanguageHungarian = cc.LANGUAGE_HUNGARIAN _G.kLanguagePortuguese = cc.LANGUAGE_PORTUGUESE _G.kLanguageArabic = cc.LANGUAGE_ARABIC _G.kTargetWindows = cc.PLATFORM_OS_WINDOWS _G.kTargetLinux = cc.PLATFORM_OS_LINUX _G.kTargetMacOS = cc.PLATFORM_OS_MAC _G.kTargetAndroid = cc.PLATFORM_OS_ANDROID _G.kTargetIphone = cc.PLATFORM_OS_IPHONE _G.kTargetIpad = cc.PLATFORM_OS_IPAD _G.kTargetBlackBerry = cc.PLATFORM_OS_BLACKBERRY _G.GL_ZERO = gl.ZERO _G.GL_ONE = gl.ONE _G.GL_SRC_COLOR = gl.SRC_COLOR _G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR _G.GL_SRC_ALPHA = gl.SRC_ALPHA _G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA _G.GL_DST_ALPHA = gl.DST_ALPHA _G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA _G.GL_DST_COLOR = gl.DST_COLOR _G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR _G.GL_RENDERBUFFER_INTERNAL_FORMAT = gl.RENDERBUFFER_INTERNAL_FORMAT _G.GL_LINE_WIDTH = gl.LINE_WIDTH _G.GL_CONSTANT_ALPHA = gl.CONSTANT_ALPHA _G.GL_BLEND_SRC_ALPHA = gl.BLEND_SRC_ALPHA _G.GL_GREEN_BITS = gl.GREEN_BITS _G.GL_STENCIL_REF = gl.STENCIL_REF _G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA _G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE _G.GL_CCW = gl.CCW _G.GL_MAX_TEXTURE_IMAGE_UNITS = gl.MAX_TEXTURE_IMAGE_UNITS _G.GL_BACK = gl.BACK _G.GL_ACTIVE_ATTRIBUTES = gl.ACTIVE_ATTRIBUTES _G.GL_TEXTURE_CUBE_MAP_POSITIVE_X = gl.TEXTURE_CUBE_MAP_POSITIVE_X _G.GL_STENCIL_BACK_VALUE_MASK = gl.STENCIL_BACK_VALUE_MASK _G.GL_TEXTURE_CUBE_MAP_POSITIVE_Z = gl.TEXTURE_CUBE_MAP_POSITIVE_Z _G.GL_ONE = gl.ONE _G.GL_TRUE = gl.TRUE _G.GL_TEXTURE12 = gl.TEXTURE12 _G.GL_LINK_STATUS = gl.LINK_STATUS _G.GL_BLEND = gl.BLEND _G.GL_LESS = gl.LESS _G.GL_TEXTURE16 = gl.TEXTURE16 _G.GL_BOOL_VEC2 = gl.BOOL_VEC2 _G.GL_KEEP = gl.KEEP _G.GL_DST_COLOR = gl.DST_COLOR _G.GL_VERTEX_ATTRIB_ARRAY_ENABLED = gl.VERTEX_ATTRIB_ARRAY_ENABLED _G.GL_EXTENSIONS = gl.EXTENSIONS _G.GL_FRONT = gl.FRONT _G.GL_DST_ALPHA = gl.DST_ALPHA _G.GL_ATTACHED_SHADERS = gl.ATTACHED_SHADERS _G.GL_STENCIL_BACK_FUNC = gl.STENCIL_BACK_FUNC _G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR _G.GL_BLEND_EQUATION = gl.BLEND_EQUATION _G.GL_RENDERBUFFER_DEPTH_SIZE = gl.RENDERBUFFER_DEPTH_SIZE _G.GL_PACK_ALIGNMENT = gl.PACK_ALIGNMENT _G.GL_VENDOR = gl.VENDOR _G.GL_NEAREST_MIPMAP_LINEAR = gl.NEAREST_MIPMAP_LINEAR _G.GL_TEXTURE_CUBE_MAP_POSITIVE_Y = gl.TEXTURE_CUBE_MAP_POSITIVE_Y _G.GL_NEAREST = gl.NEAREST _G.GL_RENDERBUFFER_WIDTH = gl.RENDERBUFFER_WIDTH _G.GL_ARRAY_BUFFER_BINDING = gl.ARRAY_BUFFER_BINDING _G.GL_ARRAY_BUFFER = gl.ARRAY_BUFFER _G.GL_LEQUAL = gl.LEQUAL _G.GL_VERSION = gl.VERSION _G.GL_COLOR_CLEAR_VALUE = gl.COLOR_CLEAR_VALUE _G.GL_RENDERER = gl.RENDERER _G.GL_STENCIL_BACK_PASS_DEPTH_PASS = gl.STENCIL_BACK_PASS_DEPTH_PASS _G.GL_STENCIL_BACK_PASS_DEPTH_FAIL = gl.STENCIL_BACK_PASS_DEPTH_FAIL _G.GL_STENCIL_BACK_WRITEMASK = gl.STENCIL_BACK_WRITEMASK _G.GL_BOOL = gl.BOOL _G.GL_VIEWPORT = gl.VIEWPORT _G.GL_FRAGMENT_SHADER = gl.FRAGMENT_SHADER _G.GL_LUMINANCE = gl.LUMINANCE _G.GL_DECR_WRAP = gl.DECR_WRAP _G.GL_FUNC_ADD = gl.FUNC_ADD _G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA _G.GL_OUT_OF_MEMORY = gl.OUT_OF_MEMORY _G.GL_BOOL_VEC4 = gl.BOOL_VEC4 _G.GL_POLYGON_OFFSET_FACTOR = gl.POLYGON_OFFSET_FACTOR _G.GL_STATIC_DRAW = gl.STATIC_DRAW _G.GL_DITHER = gl.DITHER _G.GL_TEXTURE31 = gl.TEXTURE31 _G.GL_TEXTURE30 = gl.TEXTURE30 _G.GL_UNSIGNED_BYTE = gl.UNSIGNED_BYTE _G.GL_DEPTH_COMPONENT16 = gl.DEPTH_COMPONENT16 _G.GL_TEXTURE23 = gl.TEXTURE23 _G.GL_DEPTH_TEST = gl.DEPTH_TEST _G.GL_STENCIL_PASS_DEPTH_FAIL = gl.STENCIL_PASS_DEPTH_FAIL _G.GL_BOOL_VEC3 = gl.BOOL_VEC3 _G.GL_POLYGON_OFFSET_UNITS = gl.POLYGON_OFFSET_UNITS _G.GL_TEXTURE_BINDING_2D = gl.TEXTURE_BINDING_2D _G.GL_TEXTURE21 = gl.TEXTURE21 _G.GL_UNPACK_ALIGNMENT = gl.UNPACK_ALIGNMENT _G.GL_DONT_CARE = gl.DONT_CARE _G.GL_BUFFER_SIZE = gl.BUFFER_SIZE _G.GL_FLOAT_MAT3 = gl.FLOAT_MAT3 _G.GL_UNSIGNED_SHORT_5_6_5 = gl.UNSIGNED_SHORT_5_6_5 _G.GL_INT_VEC2 = gl.INT_VEC2 _G.GL_UNSIGNED_SHORT_4_4_4_4 = gl.UNSIGNED_SHORT_4_4_4_4 _G.GL_NONE = gl.NONE _G.GL_BLEND_DST_ALPHA = gl.BLEND_DST_ALPHA _G.GL_VERTEX_ATTRIB_ARRAY_SIZE = gl.VERTEX_ATTRIB_ARRAY_SIZE _G.GL_SRC_COLOR = gl.SRC_COLOR _G.GL_COMPRESSED_TEXTURE_FORMATS = gl.COMPRESSED_TEXTURE_FORMATS _G.GL_STENCIL_ATTACHMENT = gl.STENCIL_ATTACHMENT _G.GL_MAX_VERTEX_ATTRIBS = gl.MAX_VERTEX_ATTRIBS _G.GL_NUM_COMPRESSED_TEXTURE_FORMATS = gl.NUM_COMPRESSED_TEXTURE_FORMATS _G.GL_BLEND_EQUATION_RGB = gl.BLEND_EQUATION_RGB _G.GL_TEXTURE = gl.TEXTURE _G.GL_LINEAR_MIPMAP_LINEAR = gl.LINEAR_MIPMAP_LINEAR _G.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING _G.GL_CURRENT_PROGRAM = gl.CURRENT_PROGRAM _G.GL_COLOR_BUFFER_BIT = gl.COLOR_BUFFER_BIT _G.GL_TEXTURE20 = gl.TEXTURE20 _G.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = gl.ACTIVE_ATTRIBUTE_MAX_LENGTH _G.GL_TEXTURE28 = gl.TEXTURE28 _G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE _G.GL_TEXTURE22 = gl.TEXTURE22 _G.GL_ELEMENT_ARRAY_BUFFER_BINDING = gl.ELEMENT_ARRAY_BUFFER_BINDING _G.GL_STREAM_DRAW = gl.STREAM_DRAW _G.GL_SCISSOR_BOX = gl.SCISSOR_BOX _G.GL_TEXTURE26 = gl.TEXTURE26 _G.GL_TEXTURE27 = gl.TEXTURE27 _G.GL_TEXTURE24 = gl.TEXTURE24 _G.GL_TEXTURE25 = gl.TEXTURE25 _G.GL_NO_ERROR = gl.NO_ERROR _G.GL_TEXTURE29 = gl.TEXTURE29 _G.GL_FLOAT_MAT4 = gl.FLOAT_MAT4 _G.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = gl.VERTEX_ATTRIB_ARRAY_NORMALIZED _G.GL_SAMPLE_COVERAGE_INVERT = gl.SAMPLE_COVERAGE_INVERT _G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL _G.GL_FLOAT_VEC3 = gl.FLOAT_VEC3 _G.GL_STENCIL_CLEAR_VALUE = gl.STENCIL_CLEAR_VALUE _G.GL_UNSIGNED_SHORT_5_5_5_1 = gl.UNSIGNED_SHORT_5_5_5_1 _G.GL_ACTIVE_UNIFORMS = gl.ACTIVE_UNIFORMS _G.GL_INVALID_OPERATION = gl.INVALID_OPERATION _G.GL_DEPTH_ATTACHMENT = gl.DEPTH_ATTACHMENT _G.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS _G.GL_FRAMEBUFFER_COMPLETE = gl.FRAMEBUFFER_COMPLETE _G.GL_ONE_MINUS_CONSTANT_COLOR = gl.ONE_MINUS_CONSTANT_COLOR _G.GL_TEXTURE2 = gl.TEXTURE2 _G.GL_TEXTURE1 = gl.TEXTURE1 _G.GL_GEQUAL = gl.GEQUAL _G.GL_TEXTURE7 = gl.TEXTURE7 _G.GL_TEXTURE6 = gl.TEXTURE6 _G.GL_TEXTURE5 = gl.TEXTURE5 _G.GL_TEXTURE4 = gl.TEXTURE4 _G.GL_GENERATE_MIPMAP_HINT = gl.GENERATE_MIPMAP_HINT _G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR _G.GL_TEXTURE9 = gl.TEXTURE9 _G.GL_STENCIL_TEST = gl.STENCIL_TEST _G.GL_COLOR_WRITEMASK = gl.COLOR_WRITEMASK _G.GL_DEPTH_COMPONENT = gl.DEPTH_COMPONENT _G.GL_STENCIL_INDEX8 = gl.STENCIL_INDEX8 _G.GL_VERTEX_ATTRIB_ARRAY_TYPE = gl.VERTEX_ATTRIB_ARRAY_TYPE _G.GL_FLOAT_VEC2 = gl.FLOAT_VEC2 _G.GL_BLUE_BITS = gl.BLUE_BITS _G.GL_VERTEX_SHADER = gl.VERTEX_SHADER _G.GL_SUBPIXEL_BITS = gl.SUBPIXEL_BITS _G.GL_STENCIL_WRITEMASK = gl.STENCIL_WRITEMASK _G.GL_FLOAT_VEC4 = gl.FLOAT_VEC4 _G.GL_TEXTURE17 = gl.TEXTURE17 _G.GL_ONE_MINUS_CONSTANT_ALPHA = gl.ONE_MINUS_CONSTANT_ALPHA _G.GL_TEXTURE15 = gl.TEXTURE15 _G.GL_TEXTURE14 = gl.TEXTURE14 _G.GL_TEXTURE13 = gl.TEXTURE13 _G.GL_SAMPLES = gl.SAMPLES _G.GL_TEXTURE11 = gl.TEXTURE11 _G.GL_TEXTURE10 = gl.TEXTURE10 _G.GL_FUNC_SUBTRACT = gl.FUNC_SUBTRACT _G.GL_STENCIL_BUFFER_BIT = gl.STENCIL_BUFFER_BIT _G.GL_TEXTURE19 = gl.TEXTURE19 _G.GL_TEXTURE18 = gl.TEXTURE18 _G.GL_NEAREST_MIPMAP_NEAREST = gl.NEAREST_MIPMAP_NEAREST _G.GL_SHORT = gl.SHORT _G.GL_RENDERBUFFER_BINDING = gl.RENDERBUFFER_BINDING _G.GL_REPEAT = gl.REPEAT _G.GL_TEXTURE_MIN_FILTER = gl.TEXTURE_MIN_FILTER _G.GL_RED_BITS = gl.RED_BITS _G.GL_FRONT_FACE = gl.FRONT_FACE _G.GL_BLEND_COLOR = gl.BLEND_COLOR _G.GL_MIRRORED_REPEAT = gl.MIRRORED_REPEAT _G.GL_INT_VEC4 = gl.INT_VEC4 _G.GL_MAX_CUBE_MAP_TEXTURE_SIZE = gl.MAX_CUBE_MAP_TEXTURE_SIZE _G.GL_RENDERBUFFER_BLUE_SIZE = gl.RENDERBUFFER_BLUE_SIZE _G.GL_SAMPLE_COVERAGE = gl.SAMPLE_COVERAGE _G.GL_SRC_ALPHA = gl.SRC_ALPHA _G.GL_FUNC_REVERSE_SUBTRACT = gl.FUNC_REVERSE_SUBTRACT _G.GL_DEPTH_WRITEMASK = gl.DEPTH_WRITEMASK _G.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT _G.GL_POLYGON_OFFSET_FILL = gl.POLYGON_OFFSET_FILL _G.GL_STENCIL_FUNC = gl.STENCIL_FUNC _G.GL_REPLACE = gl.REPLACE _G.GL_LUMINANCE_ALPHA = gl.LUMINANCE_ALPHA _G.GL_DEPTH_RANGE = gl.DEPTH_RANGE _G.GL_FASTEST = gl.FASTEST _G.GL_STENCIL_FAIL = gl.STENCIL_FAIL _G.GL_UNSIGNED_SHORT = gl.UNSIGNED_SHORT _G.GL_RENDERBUFFER_HEIGHT = gl.RENDERBUFFER_HEIGHT _G.GL_STENCIL_BACK_FAIL = gl.STENCIL_BACK_FAIL _G.GL_BLEND_SRC_RGB = gl.BLEND_SRC_RGB _G.GL_TEXTURE3 = gl.TEXTURE3 _G.GL_RENDERBUFFER = gl.RENDERBUFFER _G.GL_RGB5_A1 = gl.RGB5_A1 _G.GL_RENDERBUFFER_ALPHA_SIZE = gl.RENDERBUFFER_ALPHA_SIZE _G.GL_RENDERBUFFER_STENCIL_SIZE = gl.RENDERBUFFER_STENCIL_SIZE _G.GL_NOTEQUAL = gl.NOTEQUAL _G.GL_BLEND_DST_RGB = gl.BLEND_DST_RGB _G.GL_FRONT_AND_BACK = gl.FRONT_AND_BACK _G.GL_TEXTURE_BINDING_CUBE_MAP = gl.TEXTURE_BINDING_CUBE_MAP _G.GL_MAX_RENDERBUFFER_SIZE = gl.MAX_RENDERBUFFER_SIZE _G.GL_ZERO = gl.ZERO _G.GL_TEXTURE0 = gl.TEXTURE0 _G.GL_SAMPLE_ALPHA_TO_COVERAGE = gl.SAMPLE_ALPHA_TO_COVERAGE _G.GL_BUFFER_USAGE = gl.BUFFER_USAGE _G.GL_ACTIVE_TEXTURE = gl.ACTIVE_TEXTURE _G.GL_BYTE = gl.BYTE _G.GL_CW = gl.CW _G.GL_DYNAMIC_DRAW = gl.DYNAMIC_DRAW _G.GL_RENDERBUFFER_RED_SIZE = gl.RENDERBUFFER_RED_SIZE _G.GL_FALSE = gl.FALSE _G.GL_GREATER = gl.GREATER _G.GL_RGBA4 = gl.RGBA4 _G.GL_VALIDATE_STATUS = gl.VALIDATE_STATUS _G.GL_STENCIL_BITS = gl.STENCIL_BITS _G.GL_RGB = gl.RGB _G.GL_INT = gl.INT _G.GL_DEPTH_FUNC = gl.DEPTH_FUNC _G.GL_SAMPLER_2D = gl.SAMPLER_2D _G.GL_NICEST = gl.NICEST _G.GL_MAX_VIEWPORT_DIMS = gl.MAX_VIEWPORT_DIMS _G.GL_CULL_FACE = gl.CULL_FACE _G.GL_INT_VEC3 = gl.INT_VEC3 _G.GL_ALIASED_POINT_SIZE_RANGE = gl.ALIASED_POINT_SIZE_RANGE _G.GL_INVALID_ENUM = gl.INVALID_ENUM _G.GL_INVERT = gl.INVERT _G.GL_CULL_FACE_MODE = gl.CULL_FACE_MODE _G.GL_TEXTURE8 = gl.TEXTURE8 _G.GL_VERTEX_ATTRIB_ARRAY_POINTER = gl.VERTEX_ATTRIB_ARRAY_POINTER _G.GL_TEXTURE_WRAP_S = gl.TEXTURE_WRAP_S _G.GL_VERTEX_ATTRIB_ARRAY_STRIDE = gl.VERTEX_ATTRIB_ARRAY_STRIDE _G.GL_LINES = gl.LINES _G.GL_EQUAL = gl.EQUAL _G.GL_LINE_LOOP = gl.LINE_LOOP _G.GL_TEXTURE_WRAP_T = gl.TEXTURE_WRAP_T _G.GL_DEPTH_BUFFER_BIT = gl.DEPTH_BUFFER_BIT _G.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS _G.GL_SHADER_TYPE = gl.SHADER_TYPE _G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_X = gl.TEXTURE_CUBE_MAP_NEGATIVE_X _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = gl.TEXTURE_CUBE_MAP_NEGATIVE_Y _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = gl.TEXTURE_CUBE_MAP_NEGATIVE_Z _G.GL_DECR = gl.DECR _G.GL_DELETE_STATUS = gl.DELETE_STATUS _G.GL_DEPTH_BITS = gl.DEPTH_BITS _G.GL_INCR = gl.INCR _G.GL_SAMPLE_COVERAGE_VALUE = gl.SAMPLE_COVERAGE_VALUE _G.GL_ALPHA_BITS = gl.ALPHA_BITS _G.GL_FLOAT_MAT2 = gl.FLOAT_MAT2 _G.GL_LINE_STRIP = gl.LINE_STRIP _G.GL_SHADER_SOURCE_LENGTH = gl.SHADER_SOURCE_LENGTH _G.GL_INVALID_VALUE = gl.INVALID_VALUE _G.GL_NEVER = gl.NEVER _G.GL_INCR_WRAP = gl.INCR_WRAP _G.GL_BLEND_EQUATION_ALPHA = gl.BLEND_EQUATION_ALPHA _G.GL_TEXTURE_MAG_FILTER = gl.TEXTURE_MAG_FILTER _G.GL_POINTS = gl.POINTS _G.GL_COLOR_ATTACHMENT0 = gl.COLOR_ATTACHMENT0 _G.GL_RGBA = gl.RGBA _G.GL_SRC_ALPHA_SATURATE = gl.SRC_ALPHA_SATURATE _G.GL_SAMPLER_CUBE = gl.SAMPLER_CUBE _G.GL_FRAMEBUFFER = gl.FRAMEBUFFER _G.GL_TEXTURE_CUBE_MAP = gl.TEXTURE_CUBE_MAP _G.GL_SAMPLE_BUFFERS = gl.SAMPLE_BUFFERS _G.GL_LINEAR = gl.LINEAR _G.GL_LINEAR_MIPMAP_NEAREST = gl.LINEAR_MIPMAP_NEAREST _G.GL_ACTIVE_UNIFORM_MAX_LENGTH = gl.ACTIVE_UNIFORM_MAX_LENGTH _G.GL_STENCIL_BACK_REF = gl.STENCIL_BACK_REF _G.GL_ELEMENT_ARRAY_BUFFER = gl.ELEMENT_ARRAY_BUFFER _G.GL_CLAMP_TO_EDGE = gl.CLAMP_TO_EDGE _G.GL_TRIANGLE_STRIP = gl.TRIANGLE_STRIP _G.GL_CONSTANT_COLOR = gl.CONSTANT_COLOR _G.GL_COMPILE_STATUS = gl.COMPILE_STATUS _G.GL_RENDERBUFFER_GREEN_SIZE = gl.RENDERBUFFER_GREEN_SIZE _G.GL_UNSIGNED_INT = gl.UNSIGNED_INT _G.GL_DEPTH_CLEAR_VALUE = gl.DEPTH_CLEAR_VALUE _G.GL_ALIASED_LINE_WIDTH_RANGE = gl.ALIASED_LINE_WIDTH_RANGE _G.GL_SHADING_LANGUAGE_VERSION = gl.SHADING_LANGUAGE_VERSION _G.GL_FRAMEBUFFER_UNSUPPORTED = gl.FRAMEBUFFER_UNSUPPORTED _G.GL_INFO_LOG_LENGTH = gl.INFO_LOG_LENGTH _G.GL_STENCIL_PASS_DEPTH_PASS = gl.STENCIL_PASS_DEPTH_PASS _G.GL_STENCIL_VALUE_MASK = gl.STENCIL_VALUE_MASK _G.GL_ALWAYS = gl.ALWAYS _G.GL_MAX_TEXTURE_SIZE = gl.MAX_TEXTURE_SIZE _G.GL_FLOAT = gl.FLOAT _G.GL_FRAMEBUFFER_BINDING = gl.FRAMEBUFFER_BINDING _G.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT _G.GL_TRIANGLE_FAN = gl.TRIANGLE_FAN _G.GL_INVALID_FRAMEBUFFER_OPERATION = gl.INVALID_FRAMEBUFFER_OPERATION _G.GL_TEXTURE_2D = gl.TEXTURE_2D _G.GL_ALPHA = gl.ALPHA _G.GL_CURRENT_VERTEX_ATTRIB = gl.CURRENT_VERTEX_ATTRIB _G.GL_SCISSOR_TEST = gl.SCISSOR_TEST _G.GL_TRIANGLES = gl.TRIANGLES _G.CCControlEventTouchDown = cc.CONTROL_EVENTTYPE_TOUCH_DOWN _G.CCControlEventTouchDragInside = cc.CONTROL_EVENTTYPE_DRAG_INSIDE _G.CCControlEventTouchDragOutside = cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE _G.CCControlEventTouchDragEnter = cc.CONTROL_EVENTTYPE_DRAG_ENTER _G.CCControlEventTouchDragExit = cc.CONTROL_EVENTTYPE_DRAG_EXIT _G.CCControlEventTouchUpInside = cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE _G.CCControlEventTouchUpOutside = cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE _G.CCControlEventTouchCancel = cc.CONTROL_EVENTTYPE_TOUCH_CANCEL _G.CCControlEventValueChanged = cc.CONTROL_EVENTTYPE_VALUE_CHANGED _G.CCControlStateNormal = cc.CONTROL_STATE_NORMAL _G.CCControlStateHighlighted = cc.CONTROL_STATE_HIGH_LIGHTED _G.CCControlStateDisabled = cc.CONTROL_STATE_DISABLED _G.CCControlStateSelected = cc.CONTROL_STATE_SELECTED _G.kWebSocketScriptHandlerOpen = cc.WEBSOCKET_OPEN _G.kWebSocketScriptHandlerMessage = cc.WEBSOCKET_MESSAGE _G.kWebSocketScriptHandlerClose = cc.WEBSOCKET_CLOSE _G.kWebSocketScriptHandlerError = cc.WEBSOCKET_ERROR _G.kStateConnecting = cc.WEBSOCKET_STATE_CONNECTING _G.kStateOpen = cc.WEBSOCKET_STATE_OPEN _G.kStateClosing = cc.WEBSOCKET_STATE_CLOSING _G.kStateClosed = cc.WEBSOCKET_STATE_CLOSED _G.LAYOUT_COLOR_NONE = ccs.LayoutBackGroundColorType.none _G.LAYOUT_COLOR_SOLID = ccs.LayoutBackGroundColorType.solid _G.LAYOUT_COLOR_GRADIENT = ccs.LayoutBackGroundColorType.gradient _G.LAYOUT_ABSOLUTE = ccs.LayoutType.absolute _G.LAYOUT_LINEAR_VERTICAL = ccs.LayoutType.linearVertical _G.LAYOUT_LINEAR_HORIZONTAL = ccs.LayoutType.linearHorizontal _G.LAYOUT_RELATIVE = ccs.LayoutType.relative _G.BRIGHT_NONE = ccs.BrightStyle.none _G.BRIGHT_NORMAL = ccs.BrightStyle.normal _G.BRIGHT_HIGHLIGHT = ccs.BrightStyle.highlight _G.WidgetTypeWidget = ccs.WidgetType.widget _G.WidgetTypeContainer = ccs.WidgetType.container _G.UI_TEX_TYPE_LOCAL = ccs.TextureResType.UI_TEX_TYPE_LOCAL _G.UI_TEX_TYPE_PLIST = ccs.TextureResType.UI_TEX_TYPE_PLIST _G.TOUCH_EVENT_BEGAN = ccs.TouchEventType.began _G.TOUCH_EVENT_MOVED = ccs.TouchEventType.moved _G.TOUCH_EVENT_ENDED = ccs.TouchEventType.ended _G.TOUCH_EVENT_CANCELED = ccs.TouchEventType.canceled _G.SIZE_ABSOLUTE = ccs.SizeType.absolute _G.SIZE_PERCENT = ccs.SizeType.percent _G.POSITION_ABSOLUTE = ccs.PositionType.absolute _G.POSITION_PERCENT = ccs.PositionType.percent _G.CHECKBOX_STATE_EVENT_SELECTED = ccs.CheckBoxEventType.selected _G.CHECKBOX_STATE_EVENT_UNSELECTED = ccs.CheckBoxEventType.unselected _G.CHECKBOX_STATE_EVENT_SELECTED = ccs.CheckBoxEventType.selected _G.CHECKBOX_STATE_EVENT_UNSELECTED = ccs.CheckBoxEventType.unselected _G.LoadingBarTypeLeft = ccs.LoadingBarType.left _G.LoadingBarTypeRight = ccs.LoadingBarType.right _G.LoadingBarTypeRight = ccs.SliderEventType.percent_changed _G.TEXTFIELD_EVENT_ATTACH_WITH_IME = ccs.TextFiledEventType.attach_with_ime _G.TEXTFIELD_EVENT_DETACH_WITH_IME = ccs.TextFiledEventType.detach_with_ime _G.TEXTFIELD_EVENT_INSERT_TEXT = ccs.TextFiledEventType.insert_text _G.TEXTFIELD_EVENT_DELETE_BACKWARD = ccs.TextFiledEventType.delete_backward _G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccs.SCROLLVIEW_DIR.none _G.SCROLLVIEW_DIR_VERTICAL = ccs.SCROLLVIEW_DIR.vertical _G.SCROLLVIEW_DIR_HORIZONTAL = ccs.SCROLLVIEW_DIR.horizontal _G.SCROLLVIEW_DIR_BOTH = ccs.SCROLLVIEW_DIR.both _G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccs.ScrollviewEventType.SCROLL_TO_TOP _G.SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccs.ScrollviewEventType.SCROLL_TO_BOTTOM _G.SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccs.ScrollviewEventType.SCROLL_TO_LEFT _G.SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccs.ScrollviewEventType.SCROLL_TO_RIGHT _G.SCROLLVIEW_EVENT_SCROLLING = ccs.ScrollviewEventType.SCROLLING _G.SCROLLVIEW_EVENT_BOUNCE_TOP = ccs.ScrollviewEventType.BOUNCE_TOP _G.SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccs.ScrollviewEventType.BOUNCE_BOTTOM _G.SCROLLVIEW_EVENT_BOUNCE_LEFT = ccs.ScrollviewEventType.BOUNCE_LEFT _G.SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccs.ScrollviewEventType.BOUNCE_RIGHT _G.PAGEVIEW_EVENT_TURNING = ccs.PageViewEventType.turning _G.PAGEVIEW_TOUCHLEFT = ccs.PVTouchDir.touch_left _G.PAGEVIEW_TOUCHRIGHT = ccs.PVTouchDir.touch_right _G.LISTVIEW_DIR_NONE = ccs.ListViewDirection.none _G.LISTVIEW_DIR_VERTICAL = ccs.ListViewDirection.vertical _G.LISTVIEW_DIR_HORIZONTAL = ccs.ListViewDirection.horizontal _G.LISTVIEW_MOVE_DIR_NONE = ccs.ListViewMoveDirection.none _G.LISTVIEW_MOVE_DIR_UP = ccs.ListViewMoveDirection.up _G.LISTVIEW_MOVE_DIR_DOWN = ccs.ListViewMoveDirection.down _G.LISTVIEW_MOVE_DIR_LEFT = ccs.ListViewMoveDirection.left _G.LISTVIEW_MOVE_DIR_RIGHT = ccs.ListViewMoveDirection.right _G.LISTVIEW_EVENT_INIT_CHILD = ccs.ListViewEventType.init_child _G.LISTVIEW_EVENT_UPDATE_CHILD = ccs.ListViewEventType.update_child _G.LAYOUT_PARAMETER_NONE = ccs.UILayoutParameterType.none _G.LAYOUT_PARAMETER_LINEAR = ccs.UILayoutParameterType.linear _G.LAYOUT_PARAMETER_RELATIVE = ccs.UILayoutParameterType.relative _G.kCCScrollViewDirectionHorizontal = cc.SCROLLVIEW_DIRECTION_HORIZONTAL _G.kCCScrollViewDirectionVertical = cc.SCROLLVIEW_DIRECTION_VERTICAL _G.kCCTableViewFillTopDown = cc.TABLEVIEW_FILL_TOPDOWN _G.kCCTableViewFillBottomUp = cc.TABLEVIEW_FILL_BOTTOMUP ================================================ FILE: cocos2d/cocos/scripting/lua/script/DeprecatedOpenglEnum.lua ================================================ -- This is the DeprecatedEnum DeprecatedClass = {} or DeprecatedClass _G.GL_RENDERBUFFER_INTERNAL_FORMAT = gl.RENDERBUFFER_INTERNAL_FORMAT _G.GL_LINE_WIDTH = gl.LINE_WIDTH _G.GL_CONSTANT_ALPHA = gl.CONSTANT_ALPHA _G.GL_BLEND_SRC_ALPHA = gl.BLEND_SRC_ALPHA _G.GL_GREEN_BITS = gl.GREEN_BITS _G.GL_STENCIL_REF = gl.STENCIL_REF _G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA _G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE _G.GL_CCW = gl.CCW _G.GL_MAX_TEXTURE_IMAGE_UNITS = gl.MAX_TEXTURE_IMAGE_UNITS _G.GL_BACK = gl.BACK _G.GL_ACTIVE_ATTRIBUTES = gl.ACTIVE_ATTRIBUTES _G.GL_TEXTURE_CUBE_MAP_POSITIVE_X = gl.TEXTURE_CUBE_MAP_POSITIVE_X _G.GL_STENCIL_BACK_VALUE_MASK = gl.STENCIL_BACK_VALUE_MASK _G.GL_TEXTURE_CUBE_MAP_POSITIVE_Z = gl.TEXTURE_CUBE_MAP_POSITIVE_Z _G.GL_ONE = gl.ONE _G.GL_TRUE = gl.TRUE _G.GL_TEXTURE12 = gl.TEXTURE12 _G.GL_LINK_STATUS = gl.LINK_STATUS _G.GL_BLEND = gl.BLEND _G.GL_LESS = gl.LESS _G.GL_TEXTURE16 = gl.TEXTURE16 _G.GL_BOOL_VEC2 = gl.BOOL_VEC2 _G.GL_KEEP = gl.KEEP _G.GL_DST_COLOR = gl.DST_COLOR _G.GL_VERTEX_ATTRIB_ARRAY_ENABLED = gl.VERTEX_ATTRIB_ARRAY_ENABLED _G.GL_EXTENSIONS = gl.EXTENSIONS _G.GL_FRONT = gl.FRONT _G.GL_DST_ALPHA = gl.DST_ALPHA _G.GL_ATTACHED_SHADERS = gl.ATTACHED_SHADERS _G.GL_STENCIL_BACK_FUNC = gl.STENCIL_BACK_FUNC _G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR _G.GL_BLEND_EQUATION = gl.BLEND_EQUATION _G.GL_RENDERBUFFER_DEPTH_SIZE = gl.RENDERBUFFER_DEPTH_SIZE _G.GL_PACK_ALIGNMENT = gl.PACK_ALIGNMENT _G.GL_VENDOR = gl.VENDOR _G.GL_NEAREST_MIPMAP_LINEAR = gl.NEAREST_MIPMAP_LINEAR _G.GL_TEXTURE_CUBE_MAP_POSITIVE_Y = gl.TEXTURE_CUBE_MAP_POSITIVE_Y _G.GL_NEAREST = gl.NEAREST _G.GL_RENDERBUFFER_WIDTH = gl.RENDERBUFFER_WIDTH _G.GL_ARRAY_BUFFER_BINDING = gl.ARRAY_BUFFER_BINDING _G.GL_ARRAY_BUFFER = gl.ARRAY_BUFFER _G.GL_LEQUAL = gl.LEQUAL _G.GL_VERSION = gl.VERSION _G.GL_COLOR_CLEAR_VALUE = gl.COLOR_CLEAR_VALUE _G.GL_RENDERER = gl.RENDERER _G.GL_STENCIL_BACK_PASS_DEPTH_PASS = gl.STENCIL_BACK_PASS_DEPTH_PASS _G.GL_STENCIL_BACK_PASS_DEPTH_FAIL = gl.STENCIL_BACK_PASS_DEPTH_FAIL _G.GL_STENCIL_BACK_WRITEMASK = gl.STENCIL_BACK_WRITEMASK _G.GL_BOOL = gl.BOOL _G.GL_VIEWPORT = gl.VIEWPORT _G.GL_FRAGMENT_SHADER = gl.FRAGMENT_SHADER _G.GL_LUMINANCE = gl.LUMINANCE _G.GL_DECR_WRAP = gl.DECR_WRAP _G.GL_FUNC_ADD = gl.FUNC_ADD _G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA _G.GL_OUT_OF_MEMORY = gl.OUT_OF_MEMORY _G.GL_BOOL_VEC4 = gl.BOOL_VEC4 _G.GL_POLYGON_OFFSET_FACTOR = gl.POLYGON_OFFSET_FACTOR _G.GL_STATIC_DRAW = gl.STATIC_DRAW _G.GL_DITHER = gl.DITHER _G.GL_TEXTURE31 = gl.TEXTURE31 _G.GL_TEXTURE30 = gl.TEXTURE30 _G.GL_UNSIGNED_BYTE = gl.UNSIGNED_BYTE _G.GL_DEPTH_COMPONENT16 = gl.DEPTH_COMPONENT16 _G.GL_TEXTURE23 = gl.TEXTURE23 _G.GL_DEPTH_TEST = gl.DEPTH_TEST _G.GL_STENCIL_PASS_DEPTH_FAIL = gl.STENCIL_PASS_DEPTH_FAIL _G.GL_BOOL_VEC3 = gl.BOOL_VEC3 _G.GL_POLYGON_OFFSET_UNITS = gl.POLYGON_OFFSET_UNITS _G.GL_TEXTURE_BINDING_2D = gl.TEXTURE_BINDING_2D _G.GL_TEXTURE21 = gl.TEXTURE21 _G.GL_UNPACK_ALIGNMENT = gl.UNPACK_ALIGNMENT _G.GL_DONT_CARE = gl.DONT_CARE _G.GL_BUFFER_SIZE = gl.BUFFER_SIZE _G.GL_FLOAT_MAT3 = gl.FLOAT_MAT3 _G.GL_UNSIGNED_SHORT_5_6_5 = gl.UNSIGNED_SHORT_5_6_5 _G.GL_INT_VEC2 = gl.INT_VEC2 _G.GL_UNSIGNED_SHORT_4_4_4_4 = gl.UNSIGNED_SHORT_4_4_4_4 _G.GL_NONE = gl.NONE _G.GL_BLEND_DST_ALPHA = gl.BLEND_DST_ALPHA _G.GL_VERTEX_ATTRIB_ARRAY_SIZE = gl.VERTEX_ATTRIB_ARRAY_SIZE _G.GL_SRC_COLOR = gl.SRC_COLOR _G.GL_COMPRESSED_TEXTURE_FORMATS = gl.COMPRESSED_TEXTURE_FORMATS _G.GL_STENCIL_ATTACHMENT = gl.STENCIL_ATTACHMENT _G.GL_MAX_VERTEX_ATTRIBS = gl.MAX_VERTEX_ATTRIBS _G.GL_NUM_COMPRESSED_TEXTURE_FORMATS = gl.NUM_COMPRESSED_TEXTURE_FORMATS _G.GL_BLEND_EQUATION_RGB = gl.BLEND_EQUATION_RGB _G.GL_TEXTURE = gl.TEXTURE _G.GL_LINEAR_MIPMAP_LINEAR = gl.LINEAR_MIPMAP_LINEAR _G.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING _G.GL_CURRENT_PROGRAM = gl.CURRENT_PROGRAM _G.GL_COLOR_BUFFER_BIT = gl.COLOR_BUFFER_BIT _G.GL_TEXTURE20 = gl.TEXTURE20 _G.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = gl.ACTIVE_ATTRIBUTE_MAX_LENGTH _G.GL_TEXTURE28 = gl.TEXTURE28 _G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE _G.GL_TEXTURE22 = gl.TEXTURE22 _G.GL_ELEMENT_ARRAY_BUFFER_BINDING = gl.ELEMENT_ARRAY_BUFFER_BINDING _G.GL_STREAM_DRAW = gl.STREAM_DRAW _G.GL_SCISSOR_BOX = gl.SCISSOR_BOX _G.GL_TEXTURE26 = gl.TEXTURE26 _G.GL_TEXTURE27 = gl.TEXTURE27 _G.GL_TEXTURE24 = gl.TEXTURE24 _G.GL_TEXTURE25 = gl.TEXTURE25 _G.GL_NO_ERROR = gl.NO_ERROR _G.GL_TEXTURE29 = gl.TEXTURE29 _G.GL_FLOAT_MAT4 = gl.FLOAT_MAT4 _G.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = gl.VERTEX_ATTRIB_ARRAY_NORMALIZED _G.GL_SAMPLE_COVERAGE_INVERT = gl.SAMPLE_COVERAGE_INVERT _G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL _G.GL_FLOAT_VEC3 = gl.FLOAT_VEC3 _G.GL_STENCIL_CLEAR_VALUE = gl.STENCIL_CLEAR_VALUE _G.GL_UNSIGNED_SHORT_5_5_5_1 = gl.UNSIGNED_SHORT_5_5_5_1 _G.GL_ACTIVE_UNIFORMS = gl.ACTIVE_UNIFORMS _G.GL_INVALID_OPERATION = gl.INVALID_OPERATION _G.GL_DEPTH_ATTACHMENT = gl.DEPTH_ATTACHMENT _G.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS _G.GL_FRAMEBUFFER_COMPLETE = gl.FRAMEBUFFER_COMPLETE _G.GL_ONE_MINUS_CONSTANT_COLOR = gl.ONE_MINUS_CONSTANT_COLOR _G.GL_TEXTURE2 = gl.TEXTURE2 _G.GL_TEXTURE1 = gl.TEXTURE1 _G.GL_GEQUAL = gl.GEQUAL _G.GL_TEXTURE7 = gl.TEXTURE7 _G.GL_TEXTURE6 = gl.TEXTURE6 _G.GL_TEXTURE5 = gl.TEXTURE5 _G.GL_TEXTURE4 = gl.TEXTURE4 _G.GL_GENERATE_MIPMAP_HINT = gl.GENERATE_MIPMAP_HINT _G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR _G.GL_TEXTURE9 = gl.TEXTURE9 _G.GL_STENCIL_TEST = gl.STENCIL_TEST _G.GL_COLOR_WRITEMASK = gl.COLOR_WRITEMASK _G.GL_DEPTH_COMPONENT = gl.DEPTH_COMPONENT _G.GL_STENCIL_INDEX8 = gl.STENCIL_INDEX8 _G.GL_VERTEX_ATTRIB_ARRAY_TYPE = gl.VERTEX_ATTRIB_ARRAY_TYPE _G.GL_FLOAT_VEC2 = gl.FLOAT_VEC2 _G.GL_BLUE_BITS = gl.BLUE_BITS _G.GL_VERTEX_SHADER = gl.VERTEX_SHADER _G.GL_SUBPIXEL_BITS = gl.SUBPIXEL_BITS _G.GL_STENCIL_WRITEMASK = gl.STENCIL_WRITEMASK _G.GL_FLOAT_VEC4 = gl.FLOAT_VEC4 _G.GL_TEXTURE17 = gl.TEXTURE17 _G.GL_ONE_MINUS_CONSTANT_ALPHA = gl.ONE_MINUS_CONSTANT_ALPHA _G.GL_TEXTURE15 = gl.TEXTURE15 _G.GL_TEXTURE14 = gl.TEXTURE14 _G.GL_TEXTURE13 = gl.TEXTURE13 _G.GL_SAMPLES = gl.SAMPLES _G.GL_TEXTURE11 = gl.TEXTURE11 _G.GL_TEXTURE10 = gl.TEXTURE10 _G.GL_FUNC_SUBTRACT = gl.FUNC_SUBTRACT _G.GL_STENCIL_BUFFER_BIT = gl.STENCIL_BUFFER_BIT _G.GL_TEXTURE19 = gl.TEXTURE19 _G.GL_TEXTURE18 = gl.TEXTURE18 _G.GL_NEAREST_MIPMAP_NEAREST = gl.NEAREST_MIPMAP_NEAREST _G.GL_SHORT = gl.SHORT _G.GL_RENDERBUFFER_BINDING = gl.RENDERBUFFER_BINDING _G.GL_REPEAT = gl.REPEAT _G.GL_TEXTURE_MIN_FILTER = gl.TEXTURE_MIN_FILTER _G.GL_RED_BITS = gl.RED_BITS _G.GL_FRONT_FACE = gl.FRONT_FACE _G.GL_BLEND_COLOR = gl.BLEND_COLOR _G.GL_MIRRORED_REPEAT = gl.MIRRORED_REPEAT _G.GL_INT_VEC4 = gl.INT_VEC4 _G.GL_MAX_CUBE_MAP_TEXTURE_SIZE = gl.MAX_CUBE_MAP_TEXTURE_SIZE _G.GL_RENDERBUFFER_BLUE_SIZE = gl.RENDERBUFFER_BLUE_SIZE _G.GL_SAMPLE_COVERAGE = gl.SAMPLE_COVERAGE _G.GL_SRC_ALPHA = gl.SRC_ALPHA _G.GL_FUNC_REVERSE_SUBTRACT = gl.FUNC_REVERSE_SUBTRACT _G.GL_DEPTH_WRITEMASK = gl.DEPTH_WRITEMASK _G.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT _G.GL_POLYGON_OFFSET_FILL = gl.POLYGON_OFFSET_FILL _G.GL_STENCIL_FUNC = gl.STENCIL_FUNC _G.GL_REPLACE = gl.REPLACE _G.GL_LUMINANCE_ALPHA = gl.LUMINANCE_ALPHA _G.GL_DEPTH_RANGE = gl.DEPTH_RANGE _G.GL_FASTEST = gl.FASTEST _G.GL_STENCIL_FAIL = gl.STENCIL_FAIL _G.GL_UNSIGNED_SHORT = gl.UNSIGNED_SHORT _G.GL_RENDERBUFFER_HEIGHT = gl.RENDERBUFFER_HEIGHT _G.GL_STENCIL_BACK_FAIL = gl.STENCIL_BACK_FAIL _G.GL_BLEND_SRC_RGB = gl.BLEND_SRC_RGB _G.GL_TEXTURE3 = gl.TEXTURE3 _G.GL_RENDERBUFFER = gl.RENDERBUFFER _G.GL_RGB5_A1 = gl.RGB5_A1 _G.GL_RENDERBUFFER_ALPHA_SIZE = gl.RENDERBUFFER_ALPHA_SIZE _G.GL_RENDERBUFFER_STENCIL_SIZE = gl.RENDERBUFFER_STENCIL_SIZE _G.GL_NOTEQUAL = gl.NOTEQUAL _G.GL_BLEND_DST_RGB = gl.BLEND_DST_RGB _G.GL_FRONT_AND_BACK = gl.FRONT_AND_BACK _G.GL_TEXTURE_BINDING_CUBE_MAP = gl.TEXTURE_BINDING_CUBE_MAP _G.GL_MAX_RENDERBUFFER_SIZE = gl.MAX_RENDERBUFFER_SIZE _G.GL_ZERO = gl.ZERO _G.GL_TEXTURE0 = gl.TEXTURE0 _G.GL_SAMPLE_ALPHA_TO_COVERAGE = gl.SAMPLE_ALPHA_TO_COVERAGE _G.GL_BUFFER_USAGE = gl.BUFFER_USAGE _G.GL_ACTIVE_TEXTURE = gl.ACTIVE_TEXTURE _G.GL_BYTE = gl.BYTE _G.GL_CW = gl.CW _G.GL_DYNAMIC_DRAW = gl.DYNAMIC_DRAW _G.GL_RENDERBUFFER_RED_SIZE = gl.RENDERBUFFER_RED_SIZE _G.GL_FALSE = gl.FALSE _G.GL_GREATER = gl.GREATER _G.GL_RGBA4 = gl.RGBA4 _G.GL_VALIDATE_STATUS = gl.VALIDATE_STATUS _G.GL_STENCIL_BITS = gl.STENCIL_BITS _G.GL_RGB = gl.RGB _G.GL_INT = gl.INT _G.GL_DEPTH_FUNC = gl.DEPTH_FUNC _G.GL_SAMPLER_2D = gl.SAMPLER_2D _G.GL_NICEST = gl.NICEST _G.GL_MAX_VIEWPORT_DIMS = gl.MAX_VIEWPORT_DIMS _G.GL_CULL_FACE = gl.CULL_FACE _G.GL_INT_VEC3 = gl.INT_VEC3 _G.GL_ALIASED_POINT_SIZE_RANGE = gl.ALIASED_POINT_SIZE_RANGE _G.GL_INVALID_ENUM = gl.INVALID_ENUM _G.GL_INVERT = gl.INVERT _G.GL_CULL_FACE_MODE = gl.CULL_FACE_MODE _G.GL_TEXTURE8 = gl.TEXTURE8 _G.GL_VERTEX_ATTRIB_ARRAY_POINTER = gl.VERTEX_ATTRIB_ARRAY_POINTER _G.GL_TEXTURE_WRAP_S = gl.TEXTURE_WRAP_S _G.GL_VERTEX_ATTRIB_ARRAY_STRIDE = gl.VERTEX_ATTRIB_ARRAY_STRIDE _G.GL_LINES = gl.LINES _G.GL_EQUAL = gl.EQUAL _G.GL_LINE_LOOP = gl.LINE_LOOP _G.GL_TEXTURE_WRAP_T = gl.TEXTURE_WRAP_T _G.GL_DEPTH_BUFFER_BIT = gl.DEPTH_BUFFER_BIT _G.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS _G.GL_SHADER_TYPE = gl.SHADER_TYPE _G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_X = gl.TEXTURE_CUBE_MAP_NEGATIVE_X _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = gl.TEXTURE_CUBE_MAP_NEGATIVE_Y _G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = gl.TEXTURE_CUBE_MAP_NEGATIVE_Z _G.GL_DECR = gl.DECR _G.GL_DELETE_STATUS = gl.DELETE_STATUS _G.GL_DEPTH_BITS = gl.DEPTH_BITS _G.GL_INCR = gl.INCR _G.GL_SAMPLE_COVERAGE_VALUE = gl.SAMPLE_COVERAGE_VALUE _G.GL_ALPHA_BITS = gl.ALPHA_BITS _G.GL_FLOAT_MAT2 = gl.FLOAT_MAT2 _G.GL_LINE_STRIP = gl.LINE_STRIP _G.GL_SHADER_SOURCE_LENGTH = gl.SHADER_SOURCE_LENGTH _G.GL_INVALID_VALUE = gl.INVALID_VALUE _G.GL_NEVER = gl.NEVER _G.GL_INCR_WRAP = gl.INCR_WRAP _G.GL_BLEND_EQUATION_ALPHA = gl.BLEND_EQUATION_ALPHA _G.GL_TEXTURE_MAG_FILTER = gl.TEXTURE_MAG_FILTER _G.GL_POINTS = gl.POINTS _G.GL_COLOR_ATTACHMENT0 = gl.COLOR_ATTACHMENT0 _G.GL_RGBA = gl.RGBA _G.GL_SRC_ALPHA_SATURATE = gl.SRC_ALPHA_SATURATE _G.GL_SAMPLER_CUBE = gl.SAMPLER_CUBE _G.GL_FRAMEBUFFER = gl.FRAMEBUFFER _G.GL_TEXTURE_CUBE_MAP = gl.TEXTURE_CUBE_MAP _G.GL_SAMPLE_BUFFERS = gl.SAMPLE_BUFFERS _G.GL_LINEAR = gl.LINEAR _G.GL_LINEAR_MIPMAP_NEAREST = gl.LINEAR_MIPMAP_NEAREST _G.GL_ACTIVE_UNIFORM_MAX_LENGTH = gl.ACTIVE_UNIFORM_MAX_LENGTH _G.GL_STENCIL_BACK_REF = gl.STENCIL_BACK_REF _G.GL_ELEMENT_ARRAY_BUFFER = gl.ELEMENT_ARRAY_BUFFER _G.GL_CLAMP_TO_EDGE = gl.CLAMP_TO_EDGE _G.GL_TRIANGLE_STRIP = gl.TRIANGLE_STRIP _G.GL_CONSTANT_COLOR = gl.CONSTANT_COLOR _G.GL_COMPILE_STATUS = gl.COMPILE_STATUS _G.GL_RENDERBUFFER_GREEN_SIZE = gl.RENDERBUFFER_GREEN_SIZE _G.GL_UNSIGNED_INT = gl.UNSIGNED_INT _G.GL_DEPTH_CLEAR_VALUE = gl.DEPTH_CLEAR_VALUE _G.GL_ALIASED_LINE_WIDTH_RANGE = gl.ALIASED_LINE_WIDTH_RANGE _G.GL_SHADING_LANGUAGE_VERSION = gl.SHADING_LANGUAGE_VERSION _G.GL_FRAMEBUFFER_UNSUPPORTED = gl.FRAMEBUFFER_UNSUPPORTED _G.GL_INFO_LOG_LENGTH = gl.INFO_LOG_LENGTH _G.GL_STENCIL_PASS_DEPTH_PASS = gl.STENCIL_PASS_DEPTH_PASS _G.GL_STENCIL_VALUE_MASK = gl.STENCIL_VALUE_MASK _G.GL_ALWAYS = gl.ALWAYS _G.GL_MAX_TEXTURE_SIZE = gl.MAX_TEXTURE_SIZE _G.GL_FLOAT = gl.FLOAT _G.GL_FRAMEBUFFER_BINDING = gl.FRAMEBUFFER_BINDING _G.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT _G.GL_TRIANGLE_FAN = gl.TRIANGLE_FAN _G.GL_INVALID_FRAMEBUFFER_OPERATION = gl.INVALID_FRAMEBUFFER_OPERATION _G.GL_TEXTURE_2D = gl.TEXTURE_2D _G.GL_ALPHA = gl.ALPHA _G.GL_CURRENT_VERTEX_ATTRIB = gl.CURRENT_VERTEX_ATTRIB _G.GL_SCISSOR_TEST = gl.SCISSOR_TEST _G.GL_TRIANGLES = gl.TRIANGLES ================================================ FILE: cocos2d/cocos/scripting/lua/script/DrawPrimitives.lua ================================================ local dp_initialized = false local dp_shader = nil local dp_colorLocation = -1 local dp_color = { 1.0, 1.0, 1.0, 1.0 } local dp_pointSizeLocation = -1 local dp_pointSize = 1.0 local SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor" local targetPlatform = CCApplication:getInstance():getTargetPlatform() local function lazy_init() if not dp_initialized then dp_shader = CCShaderCache:getInstance():getProgram(SHADER_NAME_POSITION_U_COLOR) --dp_shader:retain() if nil ~= dp_shader then dp_colorLocation = gl.getUniformLocation( dp_shader:getProgram(), "u_color") dp_pointSizeLocation = gl.getUniformLocation( dp_shader:getProgram(), "u_pointSize") dp_Initialized = true end end if nil == dp_shader then print("Error:dp_shader is nil!") return false end return true end local function setDrawProperty() gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION ) dp_shader:use() dp_shader:setUniformsForBuiltins() dp_shader:setUniformLocationWith4fv(dp_colorLocation, dp_color, 1) end function ccDrawInit() lazy_init() end function ccDrawFree() dp_initialized = false end function ccDrawColor4f(r,g,b,a) dp_color[1] = r dp_color[2] = g dp_color[3] = b dp_color[4] = a end function ccPointSize(pointSize) dp_pointSize = pointSize * CCDirector:getInstance():getContentScaleFactor() end function ccDrawColor4B(r,g,b,a) dp_color[1] = r / 255.0 dp_color[2] = g / 255.0 dp_color[3] = b / 255.0 dp_color[4] = a / 255.0 end function ccDrawPoint(point) if not lazy_init() then return end local vertexBuffer = { } local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) local vertices = { point.x,point.y} gl.bufferData(gl.ARRAY_BUFFER,2,vertices,gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() dp_shader:setUniformLocationWith1f(dp_pointSizeLocation, dp_pointSize) gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.POINTS,0,1) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawPoints(points,numOfPoint) if not lazy_init() then return end local vertexBuffer = {} local i = 1 local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) local vertices = {} for i = 1, numOfPoint do vertices[2 * i - 1] = points[i].x vertices[2 * i] = points[i].y end gl.bufferData(gl.ARRAY_BUFFER, numOfPoint * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() dp_shader:setUniformLocationWith1f(dp_pointSizeLocation, dp_pointSize) gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.POINTS,0,numOfPoint) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawLine(origin,destination) if not lazy_init() then return end local vertexBuffer = {} local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) local vertices = { origin.x, origin.y, destination.x, destination.y} gl.bufferData(gl.ARRAY_BUFFER,4,vertices,gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.LINES ,0,2) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawPoly(points,numOfPoints,closePolygon) if not lazy_init() then return end local vertexBuffer = {} local i = 1 local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) local vertices = {} for i = 1, numOfPoints do vertices[2 * i - 1] = points[i].x vertices[2 * i] = points[i].y end gl.bufferData(gl.ARRAY_BUFFER, numOfPoints * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) if closePolygon then gl.drawArrays(gl.LINE_LOOP , 0, numOfPoints) else gl.drawArrays(gl.LINE_STRIP, 0, numOfPoints) end gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawSolidPoly(points,numOfPoints,color) if not lazy_init() then return end local vertexBuffer = {} local i = 1 local function initBuffer() vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) local vertices = {} for i = 1, numOfPoints do vertices[2 * i - 1] = points[i].x vertices[2 * i] = points[i].y end gl.bufferData(gl.ARRAY_BUFFER, numOfPoints * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION ) dp_shader:use() dp_shader:setUniformsForBuiltins() dp_shader:setUniformLocationWith4fv(dp_colorLocation, color, 1) gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_FAN , 0, numOfPoints) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawRect(origin,destination) ccDrawLine(CCPoint:__call(origin.x, origin.y), CCPoint:__call(destination.x, origin.y)) ccDrawLine(CCPoint:__call(destination.x, origin.y), CCPoint:__call(destination.x, destination.y)) ccDrawLine(CCPoint:__call(destination.x, destination.y), CCPoint:__call(origin.x, destination.y)) ccDrawLine(CCPoint:__call(origin.x, destination.y), CCPoint:__call(origin.x, origin.y)) end function ccDrawSolidRect( origin,destination,color ) local vertices = { origin, CCPoint:__call(destination.x, origin.y) , destination, CCPoint:__call(origin.x, destination.y) } ccDrawSolidPoly(vertices,4,color) end function ccDrawCircleScale( center, radius, angle, segments,drawLineToCenter,scaleX,scaleY) if not lazy_init() then return end local additionalSegment = 1 if drawLineToCenter then additionalSegment = additionalSegment + 1 end local vertexBuffer = { } local function initBuffer() local coef = 2.0 * math.pi / segments local i = 1 local vertices = {} vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) for i = 1, segments + 1 do local rads = (i - 1) * coef local j = radius * math.cos(rads + angle) * scaleX + center.x local k = radius * math.sin(rads + angle) * scaleY + center.y vertices[i * 2 - 1] = j vertices[i * 2] = k end vertices[(segments + 2) * 2 - 1] = center.x vertices[(segments + 2) * 2] = center.y gl.bufferData(gl.ARRAY_BUFFER, (segments + 2) * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.LINE_STRIP , 0, segments + additionalSegment) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawCircle(center, radius, angle, segments, drawLineToCenter) ccDrawCircleScale(center, radius, angle, segments, drawLineToCenter, 1.0, 1.0) end function ccDrawSolidCircle(center, radius, angle, segments,scaleX,scaleY) if not lazy_init() then return end local vertexBuffer = { } local function initBuffer() local coef = 2.0 * math.pi / segments local i = 1 local vertices = {} vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) for i = 1, segments + 1 do local rads = (i - 1) * coef local j = radius * math.cos(rads + angle) * scaleX + center.x local k = radius * math.sin(rads + angle) * scaleY + center.y vertices[i * 2 - 1] = j vertices[i * 2] = k end vertices[(segments + 2) * 2 - 1] = center.x vertices[(segments + 2) * 2] = center.y gl.bufferData(gl.ARRAY_BUFFER, (segments + 2) * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.TRIANGLE_FAN , 0, segments + 1) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawQuadBezier(origin, control, destination, segments) if not lazy_init() then return end local vertexBuffer = { } local function initBuffer() local vertices = { } local i = 1 local t = 0.0 for i = 1, segments do vertices[2 * i - 1] = math.pow(1 - t,2) * origin.x + 2.0 * (1 - t) * t * control.x + t * t * destination.x vertices[2 * i] = math.pow(1 - t,2) * origin.y + 2.0 * (1 - t) * t * control.y + t * t * destination.y t = t + 1.0 / segments end vertices[2 * (segments + 1) - 1] = destination.x vertices[2 * (segments + 1)] = destination.y vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) gl.bufferData(gl.ARRAY_BUFFER, (segments + 1) * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.LINE_STRIP , 0, segments + 1) gl.bindBuffer(gl.ARRAY_BUFFER,0) end function ccDrawCubicBezier(origin, control1, control2, destination, segments) if not lazy_init then return end local vertexBuffer = { } local function initBuffer() local vertices = { } local t = 0 local i = 1 for i = 1, segments do vertices[2 * i - 1] = math.pow(1 - t,3) * origin.x + 3.0 * math.pow(1 - t, 2) * t * control1.x + 3.0 * (1 - t) * t * t * control2.x + t * t * t * destination.x vertices[2 * i] = math.pow(1 - t,3) * origin.y + 3.0 * math.pow(1 - t, 2) * t * control1.y + 3.0 * (1 - t) * t * t * control2.y + t * t * t * destination.y t = t + 1.0 / segments end vertices[2 * (segments + 1) - 1] = destination.x vertices[2 * (segments + 1)] = destination.y vertexBuffer.buffer_id = gl.createBuffer() gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer.buffer_id) gl.bufferData(gl.ARRAY_BUFFER, (segments + 1) * 2, vertices, gl.STATIC_DRAW) gl.bindBuffer(gl.ARRAY_BUFFER, 0) end initBuffer() setDrawProperty() gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id) gl.vertexAttribPointer(CCConstants.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0) gl.drawArrays(gl.LINE_STRIP , 0, segments + 1) gl.bindBuffer(gl.ARRAY_BUFFER,0) end ================================================ FILE: cocos2d/cocos/scripting/lua/script/GuiConstants.lua ================================================ ccui = ccui or {} ccui.BrightStyle = { none = -1, normal = 0, highlight = 1, } ccui.WidgetType = { widget = 0, --control container = 1, --container } ccui.TextureResType = { localType = 0, plistType = 1, } ccui.TouchEventType = { began = 0, moved = 1, ended = 2, canceled = 3, } ccui.SizeType = { absolute = 0, percent = 1, } ccui.PositionType = { absolute = 0, percent = 1, } ccui.CheckBoxEventType = { selected = 0, unselected = 1, } ccui.TextFiledEventType = { attach_with_ime = 0, detach_with_ime = 1, insert_text = 2, delete_backward = 3, } ccui.LayoutBackGroundColorType = { none = 0, solid = 1, gradient = 2, } ccui.LayoutType = { absolute = 0, linearVertical = 1, linearHorizontal = 2, relative = 3, } ccui.LayoutParameterType = { none = 0, linear = 1, relative = 2, } ccui.LinearGravity = { none = 0, left = 1, top = 2, right = 3, bottom = 4, centerVertical = 5, centerHorizontal = 6, } ccui.RelativeAlign = { alignNone = 0, alignParentTopLeft = 1, alignParentTopCenterHorizontal = 2, alignParentTopRight = 3, alignParentLeftCenterVertical = 4, centerInParent = 5, alignParentRightCenterVertical = 6, alignParentLeftBottom = 7, alignParentBottomCenterHorizontal = 8, alignParentRightBottom = 9, locationAboveLeftAlign = 10, locationAboveCenter = 11, locationAboveRightAlign = 12, locationLeftOfTopAlign = 13, locationLeftOfCenter = 14, locationLeftOfBottomAlign = 15, locationRightOfTopAlign = 16, locationRightOfCenter = 17, locationRightOfBottomAlign = 18, locationBelowLeftAlign = 19, locationBelowCenter = 20, locationBelowRightAlign = 21, } ccui.SliderEventType = {percentChanged = 0} ccui.LoadingBarType = { left = 0, right = 1} ccui.ScrollViewDir = { none = 0, vertical = 1, horizontal = 2, both = 3, } ccui.ScrollViewMoveDir = { none = 0, up = 1, down = 2, left = 3, right = 4, } ccui.ScrollviewEventType = { scrollToTop = 0, scrollToBottom = 1, scrollToLeft = 2, scrollToRight = 3, scrolling = 4, bounceTop = 5, bounceBottom = 6, bounceLeft = 7, bounceRight = 8, } ccui.ListViewDirection = { none = 0, vertical = 1, horizontal = 2, } ccui.ListViewMoveDirection = { none = 0, up = 1, down = 2, left = 3, right = 4, } ccui.ListViewEventType = { onsSelectedItem = 0, } ccui.PageViewEventType = { turning = 0, } ccui.PVTouchDir = { touchLeft = 0, touchRight = 1, } ccui.ListViewGravity = { left = 0, right = 1, centerHorizontal = 2, top = 3, bottom = 4 , centerVertical = 5, } ================================================ FILE: cocos2d/cocos/scripting/lua/script/Opengl.lua ================================================ require "OpenglConstants" gl = gl or {} --Create functions function gl.createTexture() local retTable = {} retTable.texture_id = gl._createTexture() return retTable end function gl.createBuffer() local retTable = {} retTable.buffer_id = gl._createBuffer() return retTable end function gl.createRenderbuffer() local retTable = {} retTable.renderbuffer_id = gl._createRenderuffer() return retTable end function gl.createFramebuffer( ) local retTable = {} retTable.framebuffer_id = gl._createFramebuffer() return retTable end function gl.createProgram() local retTable = {} retTable.program_id = gl._createProgram() return retTable end function gl.createShader(shaderType) local retTable = {} retTable.shader_id = gl._createShader(shaderType) return retTable end --Delete Fun function gl.deleteTexture(texture) local texture_id = 0 if "number" == type(texture) then texture_id = texture elseif "table" == type(texture) then texture_id = texture.texture_id end gl._deleteTexture(texture_id) end function gl.deleteBuffer(buffer) local buffer_id = 0 if "number" == type(buffer) then buffer_id = buffer elseif "table" == type(buffer) then buffer_id = buffer.buffer_id end gl._deleteBuffer(buffer_id) end function gl.deleteRenderbuffer(buffer) local renderbuffer_id = 0 if "number" == type(buffer) then renderbuffer_id = buffer elseif "table" == type(buffer) then renderbuffer_id = buffer.renderbuffer_id end gl._deleteRenderbuffer(renderbuffer_id) end function gl.deleteFramebuffer(buffer) local framebuffer_id = 0 if "number" == type(buffer) then framebuffer_id = buffer elseif "table" == type(buffer) then framebuffer_id = buffer.framebuffer_id end gl._deleteFramebuffer(framebuffer_id) end function gl.deleteProgram( program ) local program_id = 0 if "number" == type(buffer) then program_id = program elseif "table" == type(program) then program_id = program.program_id end gl._deleteProgram(program_id) end function gl.deleteShader(shader) local shader_id = 0 if "number" == type(shader) then shader_id = shader elseif "table" == type(shader) then shader_id = shader.shader_id end gl._deleteShader(shader_id) end --Bind Related function gl.bindTexture(target, texture) local texture_id = 0 if "number" == type(texture) then texture_id = texture elseif "table" == type(texture) then texture_id = texture.texture_id end gl._bindTexture(target,texture_id) end function gl.bindBuffer( target,buffer ) local buffer_id = 0 if "number" == type(buffer) then buffer_id = buffer elseif "table" == type(buffer) then buffer_id = buffer.buffer_id end gl._bindBuffer(target, buffer_id) end function gl.bindRenderBuffer(target, buffer) local buffer_id = 0 if "number" == type(buffer) then buffer_id = buffer; elseif "table" == type(buffer) then buffer_id = buffer.buffer_id end gl._bindRenderbuffer(target, buffer_id) end function gl.bindFramebuffer(target, buffer) local buffer_id = 0 if "number" == type(buffer) then buffer_id = buffer elseif "table" == type(buffer) then buffer_id = buffer.buffer_id end gl._bindFramebuffer(target, buffer_id) end --Uniform related function gl.getUniform(program, location) local program_id = 0 local location_id = 0 if "number" == type(program) then program_id = program else program_id = program.program_id end if "number" == type(location) then location_id = location else location_id = location.location_id end return gl._getUniform(program_id, location_id) end --shader related function gl.compileShader(shader) gl._compileShader( shader.shader_id) end function gl.shaderSource(shader, source) gl._shaderSource(shader.shader_id, source) end function gl.getShaderParameter(shader, e) return gl._getShaderParameter(shader.shader_id,e) end function gl.getShaderInfoLog( shader ) return gl._getShaderInfoLog(shader.shader_id) end --program related function gl.attachShader( program, shader ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end gl._attachShader(program_id, shader.shader_id) end function gl.linkProgram( program ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end gl._linkProgram(program_id) end function gl.getProgramParameter(program, e) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getProgramParameter(program_id, e) end function gl.useProgram(program) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end gl._useProgram (program_id) end function gl.getAttribLocation(program, name ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getAttribLocation(program_id, name) end function gl.getUniformLocation( program, name ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getUniformLocation(program_id,name) end function gl.getActiveAttrib( program, index ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getActiveAttrib(program_id, index); end function gl.getActiveUniform( program, index ) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getActiveUniform(program_id, index) end function gl.getAttachedShaders(program) local program_id = 0 if "number" == type(program) then program_id = program elseif "table" == type(program) then program_id = program.program_id end return gl._getAttachedShaders(program_id) end function gl.glNodeCreate() return cc.GLNode:create() end ================================================ FILE: cocos2d/cocos/scripting/lua/script/OpenglConstants.lua ================================================ --Encapsulate opengl constants. gl = gl or {} gl.GCCSO_SHADER_BINARY_FJ = 0x9260 gl._3DC_XY_AMD = 0x87fa gl._3DC_X_AMD = 0x87f9 gl.ACTIVE_ATTRIBUTES = 0x8b89 gl.ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8b8a gl.ACTIVE_PROGRAM_EXT = 0x8259 gl.ACTIVE_TEXTURE = 0x84e0 gl.ACTIVE_UNIFORMS = 0x8b86 gl.ACTIVE_UNIFORM_MAX_LENGTH = 0x8b87 gl.ALIASED_LINE_WIDTH_RANGE = 0x846e gl.ALIASED_POINT_SIZE_RANGE = 0x846d gl.ALL_COMPLETED_NV = 0x84f2 gl.ALL_SHADER_BITS_EXT = 0xffffffff gl.ALPHA = 0x1906 gl.ALPHA16F_EXT = 0x881c gl.ALPHA32F_EXT = 0x8816 gl.ALPHA8_EXT = 0x803c gl.ALPHA8_OES = 0x803c gl.ALPHA_BITS = 0xd55 gl.ALPHA_TEST_FUNC_QCOM = 0xbc1 gl.ALPHA_TEST_QCOM = 0xbc0 gl.ALPHA_TEST_REF_QCOM = 0xbc2 gl.ALREADY_SIGNALED_APPLE = 0x911a gl.ALWAYS = 0x207 gl.AMD_compressed_3DC_texture = 0x1 gl.AMD_compressed_ATC_texture = 0x1 gl.AMD_performance_monitor = 0x1 gl.AMD_program_binary_Z400 = 0x1 gl.ANGLE_depth_texture = 0x1 gl.ANGLE_framebuffer_blit = 0x1 gl.ANGLE_framebuffer_multisample = 0x1 gl.ANGLE_instanced_arrays = 0x1 gl.ANGLE_pack_reverse_row_order = 0x1 gl.ANGLE_program_binary = 0x1 gl.ANGLE_texture_compression_dxt3 = 0x1 gl.ANGLE_texture_compression_dxt5 = 0x1 gl.ANGLE_texture_usage = 0x1 gl.ANGLE_translated_shader_source = 0x1 gl.ANY_SAMPLES_PASSED_CONSERVATIVE_EXT = 0x8d6a gl.ANY_SAMPLES_PASSED_EXT = 0x8c2f gl.APPLE_copy_texture_levels = 0x1 gl.APPLE_framebuffer_multisample = 0x1 gl.APPLE_rgb_422 = 0x1 gl.APPLE_sync = 0x1 gl.APPLE_texture_format_BGRA8888 = 0x1 gl.APPLE_texture_max_level = 0x1 gl.ARM_mali_program_binary = 0x1 gl.ARM_mali_shader_binary = 0x1 gl.ARM_rgba8 = 0x1 gl.ARRAY_BUFFER = 0x8892 gl.ARRAY_BUFFER_BINDING = 0x8894 gl.ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8c93 gl.ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87ee gl.ATC_RGB_AMD = 0x8c92 gl.ATTACHED_SHADERS = 0x8b85 gl.BACK = 0x405 gl.BGRA8_EXT = 0x93a1 gl.BGRA_EXT = 0x80e1 gl.BGRA_IMG = 0x80e1 gl.BINNING_CONTROL_HINT_QCOM = 0x8fb0 gl.BLEND = 0xbe2 gl.BLEND_COLOR = 0x8005 gl.BLEND_DST_ALPHA = 0x80ca gl.BLEND_DST_RGB = 0x80c8 gl.BLEND_EQUATION = 0x8009 gl.BLEND_EQUATION_ALPHA = 0x883d gl.BLEND_EQUATION_RGB = 0x8009 gl.BLEND_SRC_ALPHA = 0x80cb gl.BLEND_SRC_RGB = 0x80c9 gl.BLUE_BITS = 0xd54 gl.BOOL = 0x8b56 gl.BOOL_VEC2 = 0x8b57 gl.BOOL_VEC3 = 0x8b58 gl.BOOL_VEC4 = 0x8b59 gl.BUFFER = 0x82e0 gl.BUFFER_ACCESS_OES = 0x88bb gl.BUFFER_MAPPED_OES = 0x88bc gl.BUFFER_MAP_POINTER_OES = 0x88bd gl.BUFFER_OBJECT_EXT = 0x9151 gl.BUFFER_SIZE = 0x8764 gl.BUFFER_USAGE = 0x8765 gl.BYTE = 0x1400 gl.CCW = 0x901 gl.CLAMP_TO_BORDER_NV = 0x812d gl.CLAMP_TO_EDGE = 0x812f gl.COLOR_ATTACHMENT0 = 0x8ce0 gl.COLOR_ATTACHMENT0_NV = 0x8ce0 gl.COLOR_ATTACHMENT10_NV = 0x8cea gl.COLOR_ATTACHMENT11_NV = 0x8ceb gl.COLOR_ATTACHMENT12_NV = 0x8cec gl.COLOR_ATTACHMENT13_NV = 0x8ced gl.COLOR_ATTACHMENT14_NV = 0x8cee gl.COLOR_ATTACHMENT15_NV = 0x8cef gl.COLOR_ATTACHMENT1_NV = 0x8ce1 gl.COLOR_ATTACHMENT2_NV = 0x8ce2 gl.COLOR_ATTACHMENT3_NV = 0x8ce3 gl.COLOR_ATTACHMENT4_NV = 0x8ce4 gl.COLOR_ATTACHMENT5_NV = 0x8ce5 gl.COLOR_ATTACHMENT6_NV = 0x8ce6 gl.COLOR_ATTACHMENT7_NV = 0x8ce7 gl.COLOR_ATTACHMENT8_NV = 0x8ce8 gl.COLOR_ATTACHMENT9_NV = 0x8ce9 gl.COLOR_ATTACHMENT_EXT = 0x90f0 gl.COLOR_BUFFER_BIT = 0x4000 gl.COLOR_BUFFER_BIT0_QCOM = 0x1 gl.COLOR_BUFFER_BIT1_QCOM = 0x2 gl.COLOR_BUFFER_BIT2_QCOM = 0x4 gl.COLOR_BUFFER_BIT3_QCOM = 0x8 gl.COLOR_BUFFER_BIT4_QCOM = 0x10 gl.COLOR_BUFFER_BIT5_QCOM = 0x20 gl.COLOR_BUFFER_BIT6_QCOM = 0x40 gl.COLOR_BUFFER_BIT7_QCOM = 0x80 gl.COLOR_CLEAR_VALUE = 0xc22 gl.COLOR_EXT = 0x1800 gl.COLOR_WRITEMASK = 0xc23 gl.COMPARE_REF_TO_TEXTURE_EXT = 0x884e gl.COMPILE_STATUS = 0x8b81 gl.COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93bb gl.COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93b8 gl.COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93b9 gl.COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93ba gl.COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93bc gl.COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93bd gl.COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93b0 gl.COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93b1 gl.COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93b2 gl.COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93b3 gl.COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93b4 gl.COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93b5 gl.COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93b6 gl.COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93b7 gl.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8c03 gl.COMPRESSED_RGBA_PVRTC_2BPPV2_IMG = 0x9137 gl.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8c02 gl.COMPRESSED_RGBA_PVRTC_4BPPV2_IMG = 0x9138 gl.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83f1 gl.COMPRESSED_RGBA_S3TC_DXT3_ANGLE = 0x83f2 gl.COMPRESSED_RGBA_S3TC_DXT5_ANGLE = 0x83f3 gl.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8c01 gl.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8c00 gl.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83f0 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93db gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93d8 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93d9 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93da gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93dc gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93dd gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93d0 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93d1 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93d2 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93d3 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93d4 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93d5 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93d6 gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93d7 gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV = 0x8c4d gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV = 0x8c4e gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV = 0x8c4f gl.COMPRESSED_SRGB_S3TC_DXT1_NV = 0x8c4c gl.COMPRESSED_TEXTURE_FORMATS = 0x86a3 gl.CONDITION_SATISFIED_APPLE = 0x911c gl.CONSTANT_ALPHA = 0x8003 gl.CONSTANT_COLOR = 0x8001 gl.CONTEXT_FLAG_DEBUG_BIT = 0x2 gl.CONTEXT_ROBUST_ACCESS_EXT = 0x90f3 gl.COUNTER_RANGE_AMD = 0x8bc1 gl.COUNTER_TYPE_AMD = 0x8bc0 gl.COVERAGE_ALL_FRAGMENTS_NV = 0x8ed5 gl.COVERAGE_ATTACHMENT_NV = 0x8ed2 gl.COVERAGE_AUTOMATIC_NV = 0x8ed7 gl.COVERAGE_BUFFERS_NV = 0x8ed3 gl.COVERAGE_BUFFER_BIT_NV = 0x8000 gl.COVERAGE_COMPONENT4_NV = 0x8ed1 gl.COVERAGE_COMPONENT_NV = 0x8ed0 gl.COVERAGE_EDGE_FRAGMENTS_NV = 0x8ed6 gl.COVERAGE_SAMPLES_NV = 0x8ed4 gl.CPU_OPTIMIZED_QCOM = 0x8fb1 gl.CULL_FACE = 0xb44 gl.CULL_FACE_MODE = 0xb45 gl.CURRENT_PROGRAM = 0x8b8d gl.CURRENT_QUERY_EXT = 0x8865 gl.CURRENT_VERTEX_ATTRIB = 0x8626 gl.CW = 0x900 gl.DEBUG_CALLBACK_FUNCTION = 0x8244 gl.DEBUG_CALLBACK_USER_PARAM = 0x8245 gl.DEBUG_GROUP_STACK_DEPTH = 0x826d gl.DEBUG_LOGGED_MESSAGES = 0x9145 gl.DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243 gl.DEBUG_OUTPUT = 0x92e0 gl.DEBUG_OUTPUT_SYNCHRONOUS = 0x8242 gl.DEBUG_SEVERITY_HIGH = 0x9146 gl.DEBUG_SEVERITY_LOW = 0x9148 gl.DEBUG_SEVERITY_MEDIUM = 0x9147 gl.DEBUG_SEVERITY_NOTIFICATION = 0x826b gl.DEBUG_SOURCE_API = 0x8246 gl.DEBUG_SOURCE_APPLICATION = 0x824a gl.DEBUG_SOURCE_OTHER = 0x824b gl.DEBUG_SOURCE_SHADER_COMPILER = 0x8248 gl.DEBUG_SOURCE_THIRD_PARTY = 0x8249 gl.DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247 gl.DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824d gl.DEBUG_TYPE_ERROR = 0x824c gl.DEBUG_TYPE_MARKER = 0x8268 gl.DEBUG_TYPE_OTHER = 0x8251 gl.DEBUG_TYPE_PERFORMANCE = 0x8250 gl.DEBUG_TYPE_POP_GROUP = 0x826a gl.DEBUG_TYPE_PORTABILITY = 0x824f gl.DEBUG_TYPE_PUSH_GROUP = 0x8269 gl.DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824e gl.DECR = 0x1e03 gl.DECR_WRAP = 0x8508 gl.DELETE_STATUS = 0x8b80 gl.DEPTH24_STENCIL8_OES = 0x88f0 gl.DEPTH_ATTACHMENT = 0x8d00 gl.DEPTH_BITS = 0xd56 gl.DEPTH_BUFFER_BIT = 0x100 gl.DEPTH_BUFFER_BIT0_QCOM = 0x100 gl.DEPTH_BUFFER_BIT1_QCOM = 0x200 gl.DEPTH_BUFFER_BIT2_QCOM = 0x400 gl.DEPTH_BUFFER_BIT3_QCOM = 0x800 gl.DEPTH_BUFFER_BIT4_QCOM = 0x1000 gl.DEPTH_BUFFER_BIT5_QCOM = 0x2000 gl.DEPTH_BUFFER_BIT6_QCOM = 0x4000 gl.DEPTH_BUFFER_BIT7_QCOM = 0x8000 gl.DEPTH_CLEAR_VALUE = 0xb73 gl.DEPTH_COMPONENT = 0x1902 gl.DEPTH_COMPONENT16 = 0x81a5 gl.DEPTH_COMPONENT16_NONLINEAR_NV = 0x8e2c gl.DEPTH_COMPONENT16_OES = 0x81a5 gl.DEPTH_COMPONENT24_OES = 0x81a6 gl.DEPTH_COMPONENT32_OES = 0x81a7 gl.DEPTH_EXT = 0x1801 gl.DEPTH_FUNC = 0xb74 gl.DEPTH_RANGE = 0xb70 gl.DEPTH_STENCIL_OES = 0x84f9 gl.DEPTH_TEST = 0xb71 gl.DEPTH_WRITEMASK = 0xb72 gl.DITHER = 0xbd0 gl.DMP_shader_binary = 0x1 gl.DONT_CARE = 0x1100 gl.DRAW_BUFFER0_NV = 0x8825 gl.DRAW_BUFFER10_NV = 0x882f gl.DRAW_BUFFER11_NV = 0x8830 gl.DRAW_BUFFER12_NV = 0x8831 gl.DRAW_BUFFER13_NV = 0x8832 gl.DRAW_BUFFER14_NV = 0x8833 gl.DRAW_BUFFER15_NV = 0x8834 gl.DRAW_BUFFER1_NV = 0x8826 gl.DRAW_BUFFER2_NV = 0x8827 gl.DRAW_BUFFER3_NV = 0x8828 gl.DRAW_BUFFER4_NV = 0x8829 gl.DRAW_BUFFER5_NV = 0x882a gl.DRAW_BUFFER6_NV = 0x882b gl.DRAW_BUFFER7_NV = 0x882c gl.DRAW_BUFFER8_NV = 0x882d gl.DRAW_BUFFER9_NV = 0x882e gl.DRAW_BUFFER_EXT = 0xc01 gl.DRAW_FRAMEBUFFER_ANGLE = 0x8ca9 gl.DRAW_FRAMEBUFFER_APPLE = 0x8ca9 gl.DRAW_FRAMEBUFFER_BINDING_ANGLE = 0x8ca6 gl.DRAW_FRAMEBUFFER_BINDING_APPLE = 0x8ca6 gl.DRAW_FRAMEBUFFER_BINDING_NV = 0x8ca6 gl.DRAW_FRAMEBUFFER_NV = 0x8ca9 gl.DST_ALPHA = 0x304 gl.DST_COLOR = 0x306 gl.DYNAMIC_DRAW = 0x88e8 gl.ELEMENT_ARRAY_BUFFER = 0x8893 gl.ELEMENT_ARRAY_BUFFER_BINDING = 0x8895 gl.EQUAL = 0x202 gl.ES_VERSION_2_0 = 0x1 gl.ETC1_RGB8_OES = 0x8d64 gl.ETC1_SRGB8_NV = 0x88ee gl.EXTENSIONS = 0x1f03 gl.EXT_blend_minmax = 0x1 gl.EXT_color_buffer_half_float = 0x1 gl.EXT_debug_label = 0x1 gl.EXT_debug_marker = 0x1 gl.EXT_discard_framebuffer = 0x1 gl.EXT_map_buffer_range = 0x1 gl.EXT_multi_draw_arrays = 0x1 gl.EXT_multisampled_render_to_texture = 0x1 gl.EXT_multiview_draw_buffers = 0x1 gl.EXT_occlusion_query_boolean = 0x1 gl.EXT_read_format_bgra = 0x1 gl.EXT_robustness = 0x1 gl.EXT_sRGB = 0x1 gl.EXT_separate_shader_objects = 0x1 gl.EXT_shader_framebuffer_fetch = 0x1 gl.EXT_shader_texture_lod = 0x1 gl.EXT_shadow_samplers = 0x1 gl.EXT_texture_compression_dxt1 = 0x1 gl.EXT_texture_filter_anisotropic = 0x1 gl.EXT_texture_format_BGRA8888 = 0x1 gl.EXT_texture_rg = 0x1 gl.EXT_texture_storage = 0x1 gl.EXT_texture_type_2_10_10_10_REV = 0x1 gl.EXT_unpack_subimage = 0x1 gl.FALSE = 0x0 gl.FASTEST = 0x1101 gl.FENCE_CONDITION_NV = 0x84f4 gl.FENCE_STATUS_NV = 0x84f3 gl.FIXED = 0x140c gl.FJ_shader_binary_GCCSO = 0x1 gl.FLOAT = 0x1406 gl.FLOAT_MAT2 = 0x8b5a gl.FLOAT_MAT3 = 0x8b5b gl.FLOAT_MAT4 = 0x8b5c gl.FLOAT_VEC2 = 0x8b50 gl.FLOAT_VEC3 = 0x8b51 gl.FLOAT_VEC4 = 0x8b52 gl.FRAGMENT_SHADER = 0x8b30 gl.FRAGMENT_SHADER_BIT_EXT = 0x2 gl.FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8b8b gl.FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT = 0x8a52 gl.FRAMEBUFFER = 0x8d40 gl.FRAMEBUFFER_ATTACHMENT_ANGLE = 0x93a3 gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT = 0x8210 gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT = 0x8211 gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8cd1 gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8cd0 gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES = 0x8cd4 gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8cd3 gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8cd2 gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT = 0x8d6c gl.FRAMEBUFFER_BINDING = 0x8ca6 gl.FRAMEBUFFER_COMPLETE = 0x8cd5 gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8cd6 gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8cd9 gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8cd7 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE = 0x8d56 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE = 0x8d56 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT = 0x8d56 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG = 0x9134 gl.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV = 0x8d56 gl.FRAMEBUFFER_UNDEFINED_OES = 0x8219 gl.FRAMEBUFFER_UNSUPPORTED = 0x8cdd gl.FRONT = 0x404 gl.FRONT_AND_BACK = 0x408 gl.FRONT_FACE = 0xb46 gl.FUNC_ADD = 0x8006 gl.FUNC_REVERSE_SUBTRACT = 0x800b gl.FUNC_SUBTRACT = 0x800a gl.GENERATE_MIPMAP_HINT = 0x8192 gl.GEQUAL = 0x206 gl.GPU_OPTIMIZED_QCOM = 0x8fb2 gl.GREATER = 0x204 gl.GREEN_BITS = 0xd53 gl.GUILTY_CONTEXT_RESET_EXT = 0x8253 gl.HALF_FLOAT_OES = 0x8d61 gl.HIGH_FLOAT = 0x8df2 gl.HIGH_INT = 0x8df5 gl.IMG_multisampled_render_to_texture = 0x1 gl.IMG_program_binary = 0x1 gl.IMG_read_format = 0x1 gl.IMG_shader_binary = 0x1 gl.IMG_texture_compression_pvrtc = 0x1 gl.IMG_texture_compression_pvrtc2 = 0x1 gl.IMPLEMENTATION_COLOR_READ_FORMAT = 0x8b9b gl.IMPLEMENTATION_COLOR_READ_TYPE = 0x8b9a gl.INCR = 0x1e02 gl.INCR_WRAP = 0x8507 gl.INFO_LOG_LENGTH = 0x8b84 gl.INNOCENT_CONTEXT_RESET_EXT = 0x8254 gl.INT = 0x1404 gl.INT_10_10_10_2_OES = 0x8df7 gl.INT_VEC2 = 0x8b53 gl.INT_VEC3 = 0x8b54 gl.INT_VEC4 = 0x8b55 gl.INVALID_ENUM = 0x500 gl.INVALID_FRAMEBUFFER_OPERATION = 0x506 gl.INVALID_OPERATION = 0x502 gl.INVALID_VALUE = 0x501 gl.INVERT = 0x150a gl.KEEP = 0x1e00 gl.KHR_debug = 0x1 gl.KHR_texture_compression_astc_ldr = 0x1 gl.LEQUAL = 0x203 gl.LESS = 0x201 gl.LINEAR = 0x2601 gl.LINEAR_MIPMAP_LINEAR = 0x2703 gl.LINEAR_MIPMAP_NEAREST = 0x2701 gl.LINES = 0x1 gl.LINE_LOOP = 0x2 gl.LINE_STRIP = 0x3 gl.LINE_WIDTH = 0xb21 gl.LINK_STATUS = 0x8b82 gl.LOSE_CONTEXT_ON_RESET_EXT = 0x8252 gl.LOW_FLOAT = 0x8df0 gl.LOW_INT = 0x8df3 gl.LUMINANCE = 0x1909 gl.LUMINANCE16F_EXT = 0x881e gl.LUMINANCE32F_EXT = 0x8818 gl.LUMINANCE4_ALPHA4_OES = 0x8043 gl.LUMINANCE8_ALPHA8_EXT = 0x8045 gl.LUMINANCE8_ALPHA8_OES = 0x8045 gl.LUMINANCE8_EXT = 0x8040 gl.LUMINANCE8_OES = 0x8040 gl.LUMINANCE_ALPHA = 0x190a gl.LUMINANCE_ALPHA16F_EXT = 0x881f gl.LUMINANCE_ALPHA32F_EXT = 0x8819 gl.MALI_PROGRAM_BINARY_ARM = 0x8f61 gl.MALI_SHADER_BINARY_ARM = 0x8f60 gl.MAP_FLUSH_EXPLICIT_BIT_EXT = 0x10 gl.MAP_INVALIDATE_BUFFER_BIT_EXT = 0x8 gl.MAP_INVALIDATE_RANGE_BIT_EXT = 0x4 gl.MAP_READ_BIT_EXT = 0x1 gl.MAP_UNSYNCHRONIZED_BIT_EXT = 0x20 gl.MAP_WRITE_BIT_EXT = 0x2 gl.MAX_3D_TEXTURE_SIZE_OES = 0x8073 gl.MAX_COLOR_ATTACHMENTS_NV = 0x8cdf gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8b4d gl.MAX_CUBE_MAP_TEXTURE_SIZE = 0x851c gl.MAX_DEBUG_GROUP_STACK_DEPTH = 0x826c gl.MAX_DEBUG_LOGGED_MESSAGES = 0x9144 gl.MAX_DEBUG_MESSAGE_LENGTH = 0x9143 gl.MAX_DRAW_BUFFERS_NV = 0x8824 gl.MAX_EXT = 0x8008 gl.MAX_FRAGMENT_UNIFORM_VECTORS = 0x8dfd gl.MAX_LABEL_LENGTH = 0x82e8 gl.MAX_MULTIVIEW_BUFFERS_EXT = 0x90f2 gl.MAX_RENDERBUFFER_SIZE = 0x84e8 gl.MAX_SAMPLES_ANGLE = 0x8d57 gl.MAX_SAMPLES_APPLE = 0x8d57 gl.MAX_SAMPLES_EXT = 0x8d57 gl.MAX_SAMPLES_IMG = 0x9135 gl.MAX_SAMPLES_NV = 0x8d57 gl.MAX_SERVER_WAIT_TIMEOUT_APPLE = 0x9111 gl.MAX_TEXTURE_IMAGE_UNITS = 0x8872 gl.MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84ff gl.MAX_TEXTURE_SIZE = 0xd33 gl.MAX_VARYING_VECTORS = 0x8dfc gl.MAX_VERTEX_ATTRIBS = 0x8869 gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8b4c gl.MAX_VERTEX_UNIFORM_VECTORS = 0x8dfb gl.MAX_VIEWPORT_DIMS = 0xd3a gl.MEDIUM_FLOAT = 0x8df1 gl.MEDIUM_INT = 0x8df4 gl.MIN_EXT = 0x8007 gl.MIRRORED_REPEAT = 0x8370 gl.MULTISAMPLE_BUFFER_BIT0_QCOM = 0x1000000 gl.MULTISAMPLE_BUFFER_BIT1_QCOM = 0x2000000 gl.MULTISAMPLE_BUFFER_BIT2_QCOM = 0x4000000 gl.MULTISAMPLE_BUFFER_BIT3_QCOM = 0x8000000 gl.MULTISAMPLE_BUFFER_BIT4_QCOM = 0x10000000 gl.MULTISAMPLE_BUFFER_BIT5_QCOM = 0x20000000 gl.MULTISAMPLE_BUFFER_BIT6_QCOM = 0x40000000 gl.MULTISAMPLE_BUFFER_BIT7_QCOM = 0x80000000 gl.MULTIVIEW_EXT = 0x90f1 gl.NEAREST = 0x2600 gl.NEAREST_MIPMAP_LINEAR = 0x2702 gl.NEAREST_MIPMAP_NEAREST = 0x2700 gl.NEVER = 0x200 gl.NICEST = 0x1102 gl.NONE = 0x0 gl.NOTEQUAL = 0x205 gl.NO_ERROR = 0x0 gl.NO_RESET_NOTIFICATION_EXT = 0x8261 gl.NUM_COMPRESSED_TEXTURE_FORMATS = 0x86a2 gl.NUM_PROGRAM_BINARY_FORMATS_OES = 0x87fe gl.NUM_SHADER_BINARY_FORMATS = 0x8df9 gl.NV_coverage_sample = 0x1 gl.NV_depth_nonlinear = 0x1 gl.NV_draw_buffers = 0x1 gl.NV_draw_instanced = 0x1 gl.NV_fbo_color_attachments = 0x1 gl.NV_fence = 0x1 gl.NV_framebuffer_blit = 0x1 gl.NV_framebuffer_multisample = 0x1 gl.NV_generate_mipmap_sRGB = 0x1 gl.NV_instanced_arrays = 0x1 gl.NV_read_buffer = 0x1 gl.NV_read_buffer_front = 0x1 gl.NV_read_depth = 0x1 gl.NV_read_depth_stencil = 0x1 gl.NV_read_stencil = 0x1 gl.NV_sRGB_formats = 0x1 gl.NV_shadow_samplers_array = 0x1 gl.NV_shadow_samplers_cube = 0x1 gl.NV_texture_border_clamp = 0x1 gl.NV_texture_compression_s3tc_update = 0x1 gl.NV_texture_npot_2D_mipmap = 0x1 gl.OBJECT_TYPE_APPLE = 0x9112 gl.OES_EGL_image = 0x1 gl.OES_EGL_image_external = 0x1 gl.OES_compressed_ETC1_RGB8_texture = 0x1 gl.OES_compressed_paletted_texture = 0x1 gl.OES_depth24 = 0x1 gl.OES_depth32 = 0x1 gl.OES_depth_texture = 0x1 gl.OES_element_index_uint = 0x1 gl.OES_fbo_render_mipmap = 0x1 gl.OES_fragment_precision_high = 0x1 gl.OES_get_program_binary = 0x1 gl.OES_mapbuffer = 0x1 gl.OES_packed_depth_stencil = 0x1 gl.OES_required_internalformat = 0x1 gl.OES_rgb8_rgba8 = 0x1 gl.OES_standard_derivatives = 0x1 gl.OES_stencil1 = 0x1 gl.OES_stencil4 = 0x1 gl.OES_surfaceless_context = 0x1 gl.OES_texture_3D = 0x1 gl.OES_texture_float = 0x1 gl.OES_texture_float_linear = 0x1 gl.OES_texture_half_float = 0x1 gl.OES_texture_half_float_linear = 0x1 gl.OES_texture_npot = 0x1 gl.OES_vertex_array_object = 0x1 gl.OES_vertex_half_float = 0x1 gl.OES_vertex_type_10_10_10_2 = 0x1 gl.ONE = 0x1 gl.ONE_MINUS_CONSTANT_ALPHA = 0x8004 gl.ONE_MINUS_CONSTANT_COLOR = 0x8002 gl.ONE_MINUS_DST_ALPHA = 0x305 gl.ONE_MINUS_DST_COLOR = 0x307 gl.ONE_MINUS_SRC_ALPHA = 0x303 gl.ONE_MINUS_SRC_COLOR = 0x301 gl.OUT_OF_MEMORY = 0x505 gl.PACK_ALIGNMENT = 0xd05 gl.PACK_REVERSE_ROW_ORDER_ANGLE = 0x93a4 gl.PALETTE4_R5_G6_B5_OES = 0x8b92 gl.PALETTE4_RGB5_A1_OES = 0x8b94 gl.PALETTE4_RGB8_OES = 0x8b90 gl.PALETTE4_RGBA4_OES = 0x8b93 gl.PALETTE4_RGBA8_OES = 0x8b91 gl.PALETTE8_R5_G6_B5_OES = 0x8b97 gl.PALETTE8_RGB5_A1_OES = 0x8b99 gl.PALETTE8_RGB8_OES = 0x8b95 gl.PALETTE8_RGBA4_OES = 0x8b98 gl.PALETTE8_RGBA8_OES = 0x8b96 gl.PERCENTAGE_AMD = 0x8bc3 gl.PERFMON_GLOBAL_MODE_QCOM = 0x8fa0 gl.PERFMON_RESULT_AMD = 0x8bc6 gl.PERFMON_RESULT_AVAILABLE_AMD = 0x8bc4 gl.PERFMON_RESULT_SIZE_AMD = 0x8bc5 gl.POINTS = 0x0 gl.POLYGON_OFFSET_FACTOR = 0x8038 gl.POLYGON_OFFSET_FILL = 0x8037 gl.POLYGON_OFFSET_UNITS = 0x2a00 gl.PROGRAM = 0x82e2 gl.PROGRAM_BINARY_ANGLE = 0x93a6 gl.PROGRAM_BINARY_FORMATS_OES = 0x87ff gl.PROGRAM_BINARY_LENGTH_OES = 0x8741 gl.PROGRAM_OBJECT_EXT = 0x8b40 gl.PROGRAM_PIPELINE_BINDING_EXT = 0x825a gl.PROGRAM_PIPELINE_OBJECT_EXT = 0x8a4f gl.PROGRAM_SEPARABLE_EXT = 0x8258 gl.QCOM_alpha_test = 0x1 gl.QCOM_binning_control = 0x1 gl.QCOM_driver_control = 0x1 gl.QCOM_extended_get = 0x1 gl.QCOM_extended_get2 = 0x1 gl.QCOM_perfmon_global_mode = 0x1 gl.QCOM_tiled_rendering = 0x1 gl.QCOM_writeonly_rendering = 0x1 gl.QUERY = 0x82e3 gl.QUERY_OBJECT_EXT = 0x9153 gl.QUERY_RESULT_AVAILABLE_EXT = 0x8867 gl.QUERY_RESULT_EXT = 0x8866 gl.R16F_EXT = 0x822d gl.R32F_EXT = 0x822e gl.R8_EXT = 0x8229 gl.READ_BUFFER_EXT = 0xc02 gl.READ_BUFFER_NV = 0xc02 gl.READ_FRAMEBUFFER_ANGLE = 0x8ca8 gl.READ_FRAMEBUFFER_APPLE = 0x8ca8 gl.READ_FRAMEBUFFER_BINDING_ANGLE = 0x8caa gl.READ_FRAMEBUFFER_BINDING_APPLE = 0x8caa gl.READ_FRAMEBUFFER_BINDING_NV = 0x8caa gl.READ_FRAMEBUFFER_NV = 0x8ca8 gl.RED_BITS = 0xd52 gl.RED_EXT = 0x1903 gl.RENDERBUFFER = 0x8d41 gl.RENDERBUFFER_ALPHA_SIZE = 0x8d53 gl.RENDERBUFFER_BINDING = 0x8ca7 gl.RENDERBUFFER_BLUE_SIZE = 0x8d52 gl.RENDERBUFFER_DEPTH_SIZE = 0x8d54 gl.RENDERBUFFER_GREEN_SIZE = 0x8d51 gl.RENDERBUFFER_HEIGHT = 0x8d43 gl.RENDERBUFFER_INTERNAL_FORMAT = 0x8d44 gl.RENDERBUFFER_RED_SIZE = 0x8d50 gl.RENDERBUFFER_SAMPLES_ANGLE = 0x8cab gl.RENDERBUFFER_SAMPLES_APPLE = 0x8cab gl.RENDERBUFFER_SAMPLES_EXT = 0x8cab gl.RENDERBUFFER_SAMPLES_IMG = 0x9133 gl.RENDERBUFFER_SAMPLES_NV = 0x8cab gl.RENDERBUFFER_STENCIL_SIZE = 0x8d55 gl.RENDERBUFFER_WIDTH = 0x8d42 gl.RENDERER = 0x1f01 gl.RENDER_DIRECT_TO_FRAMEBUFFER_QCOM = 0x8fb3 gl.REPEAT = 0x2901 gl.REPLACE = 0x1e01 gl.REQUIRED_TEXTURE_IMAGE_UNITS_OES = 0x8d68 gl.RESET_NOTIFICATION_STRATEGY_EXT = 0x8256 gl.RG16F_EXT = 0x822f gl.RG32F_EXT = 0x8230 gl.RG8_EXT = 0x822b gl.RGB = 0x1907 gl.RGB10_A2_EXT = 0x8059 gl.RGB10_EXT = 0x8052 gl.RGB16F_EXT = 0x881b gl.RGB32F_EXT = 0x8815 gl.RGB565 = 0x8d62 gl.RGB565_OES = 0x8d62 gl.RGB5_A1 = 0x8057 gl.RGB5_A1_OES = 0x8057 gl.RGB8_OES = 0x8051 gl.RGBA = 0x1908 gl.RGBA16F_EXT = 0x881a gl.RGBA32F_EXT = 0x8814 gl.RGBA4 = 0x8056 gl.RGBA4_OES = 0x8056 gl.RGBA8_OES = 0x8058 gl.RGB_422_APPLE = 0x8a1f gl.RG_EXT = 0x8227 gl.SAMPLER = 0x82e6 gl.SAMPLER_2D = 0x8b5e gl.SAMPLER_2D_ARRAY_SHADOW_NV = 0x8dc4 gl.SAMPLER_2D_SHADOW_EXT = 0x8b62 gl.SAMPLER_3D_OES = 0x8b5f gl.SAMPLER_CUBE = 0x8b60 gl.SAMPLER_CUBE_SHADOW_NV = 0x8dc5 gl.SAMPLER_EXTERNAL_OES = 0x8d66 gl.SAMPLES = 0x80a9 gl.SAMPLE_ALPHA_TO_COVERAGE = 0x809e gl.SAMPLE_BUFFERS = 0x80a8 gl.SAMPLE_COVERAGE = 0x80a0 gl.SAMPLE_COVERAGE_INVERT = 0x80ab gl.SAMPLE_COVERAGE_VALUE = 0x80aa gl.SCISSOR_BOX = 0xc10 gl.SCISSOR_TEST = 0xc11 gl.SGX_BINARY_IMG = 0x8c0a gl.SGX_PROGRAM_BINARY_IMG = 0x9130 gl.SHADER = 0x82e1 gl.SHADER_BINARY_DMP = 0x9250 gl.SHADER_BINARY_FORMATS = 0x8df8 gl.SHADER_BINARY_VIV = 0x8fc4 gl.SHADER_COMPILER = 0x8dfa gl.SHADER_OBJECT_EXT = 0x8b48 gl.SHADER_SOURCE_LENGTH = 0x8b88 gl.SHADER_TYPE = 0x8b4f gl.SHADING_LANGUAGE_VERSION = 0x8b8c gl.SHORT = 0x1402 gl.SIGNALED_APPLE = 0x9119 gl.SLUMINANCE8_ALPHA8_NV = 0x8c45 gl.SLUMINANCE8_NV = 0x8c47 gl.SLUMINANCE_ALPHA_NV = 0x8c44 gl.SLUMINANCE_NV = 0x8c46 gl.SRC_ALPHA = 0x302 gl.SRC_ALPHA_SATURATE = 0x308 gl.SRC_COLOR = 0x300 gl.SRGB8_ALPHA8_EXT = 0x8c43 gl.SRGB8_NV = 0x8c41 gl.SRGB_ALPHA_EXT = 0x8c42 gl.SRGB_EXT = 0x8c40 gl.STACK_OVERFLOW = 0x503 gl.STACK_UNDERFLOW = 0x504 gl.STATE_RESTORE = 0x8bdc gl.STATIC_DRAW = 0x88e4 gl.STENCIL_ATTACHMENT = 0x8d20 gl.STENCIL_BACK_FAIL = 0x8801 gl.STENCIL_BACK_FUNC = 0x8800 gl.STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802 gl.STENCIL_BACK_PASS_DEPTH_PASS = 0x8803 gl.STENCIL_BACK_REF = 0x8ca3 gl.STENCIL_BACK_VALUE_MASK = 0x8ca4 gl.STENCIL_BACK_WRITEMASK = 0x8ca5 gl.STENCIL_BITS = 0xd57 gl.STENCIL_BUFFER_BIT = 0x400 gl.STENCIL_BUFFER_BIT0_QCOM = 0x10000 gl.STENCIL_BUFFER_BIT1_QCOM = 0x20000 gl.STENCIL_BUFFER_BIT2_QCOM = 0x40000 gl.STENCIL_BUFFER_BIT3_QCOM = 0x80000 gl.STENCIL_BUFFER_BIT4_QCOM = 0x100000 gl.STENCIL_BUFFER_BIT5_QCOM = 0x200000 gl.STENCIL_BUFFER_BIT6_QCOM = 0x400000 gl.STENCIL_BUFFER_BIT7_QCOM = 0x800000 gl.STENCIL_CLEAR_VALUE = 0xb91 gl.STENCIL_EXT = 0x1802 gl.STENCIL_FAIL = 0xb94 gl.STENCIL_FUNC = 0xb92 gl.STENCIL_INDEX1_OES = 0x8d46 gl.STENCIL_INDEX4_OES = 0x8d47 gl.STENCIL_INDEX8 = 0x8d48 gl.STENCIL_PASS_DEPTH_FAIL = 0xb95 gl.STENCIL_PASS_DEPTH_PASS = 0xb96 gl.STENCIL_REF = 0xb97 gl.STENCIL_TEST = 0xb90 gl.STENCIL_VALUE_MASK = 0xb93 gl.STENCIL_WRITEMASK = 0xb98 gl.STREAM_DRAW = 0x88e0 gl.SUBPIXEL_BITS = 0xd50 gl.SYNC_CONDITION_APPLE = 0x9113 gl.SYNC_FENCE_APPLE = 0x9116 gl.SYNC_FLAGS_APPLE = 0x9115 gl.SYNC_FLUSH_COMMANDS_BIT_APPLE = 0x1 gl.SYNC_GPU_COMMANDS_COMPLETE_APPLE = 0x9117 gl.SYNC_OBJECT_APPLE = 0x8a53 gl.SYNC_STATUS_APPLE = 0x9114 gl.TEXTURE = 0x1702 gl.TEXTURE0 = 0x84c0 gl.TEXTURE1 = 0x84c1 gl.TEXTURE10 = 0x84ca gl.TEXTURE11 = 0x84cb gl.TEXTURE12 = 0x84cc gl.TEXTURE13 = 0x84cd gl.TEXTURE14 = 0x84ce gl.TEXTURE15 = 0x84cf gl.TEXTURE16 = 0x84d0 gl.TEXTURE17 = 0x84d1 gl.TEXTURE18 = 0x84d2 gl.TEXTURE19 = 0x84d3 gl.TEXTURE2 = 0x84c2 gl.TEXTURE20 = 0x84d4 gl.TEXTURE21 = 0x84d5 gl.TEXTURE22 = 0x84d6 gl.TEXTURE23 = 0x84d7 gl.TEXTURE24 = 0x84d8 gl.TEXTURE25 = 0x84d9 gl.TEXTURE26 = 0x84da gl.TEXTURE27 = 0x84db gl.TEXTURE28 = 0x84dc gl.TEXTURE29 = 0x84dd gl.TEXTURE3 = 0x84c3 gl.TEXTURE30 = 0x84de gl.TEXTURE31 = 0x84df gl.TEXTURE4 = 0x84c4 gl.TEXTURE5 = 0x84c5 gl.TEXTURE6 = 0x84c6 gl.TEXTURE7 = 0x84c7 gl.TEXTURE8 = 0x84c8 gl.TEXTURE9 = 0x84c9 gl.TEXTURE_2D = 0xde1 gl.TEXTURE_3D_OES = 0x806f gl.TEXTURE_BINDING_2D = 0x8069 gl.TEXTURE_BINDING_3D_OES = 0x806a gl.TEXTURE_BINDING_CUBE_MAP = 0x8514 gl.TEXTURE_BINDING_EXTERNAL_OES = 0x8d67 gl.TEXTURE_BORDER_COLOR_NV = 0x1004 gl.TEXTURE_COMPARE_FUNC_EXT = 0x884d gl.TEXTURE_COMPARE_MODE_EXT = 0x884c gl.TEXTURE_CUBE_MAP = 0x8513 gl.TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516 gl.TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518 gl.TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851a gl.TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515 gl.TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517 gl.TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519 gl.TEXTURE_DEPTH_QCOM = 0x8bd4 gl.TEXTURE_EXTERNAL_OES = 0x8d65 gl.TEXTURE_FORMAT_QCOM = 0x8bd6 gl.TEXTURE_HEIGHT_QCOM = 0x8bd3 gl.TEXTURE_IMAGE_VALID_QCOM = 0x8bd8 gl.TEXTURE_IMMUTABLE_FORMAT_EXT = 0x912f gl.TEXTURE_INTERNAL_FORMAT_QCOM = 0x8bd5 gl.TEXTURE_MAG_FILTER = 0x2800 gl.TEXTURE_MAX_ANISOTROPY_EXT = 0x84fe gl.TEXTURE_MAX_LEVEL_APPLE = 0x813d gl.TEXTURE_MIN_FILTER = 0x2801 gl.TEXTURE_NUM_LEVELS_QCOM = 0x8bd9 gl.TEXTURE_OBJECT_VALID_QCOM = 0x8bdb gl.TEXTURE_SAMPLES_IMG = 0x9136 gl.TEXTURE_TARGET_QCOM = 0x8bda gl.TEXTURE_TYPE_QCOM = 0x8bd7 gl.TEXTURE_USAGE_ANGLE = 0x93a2 gl.TEXTURE_WIDTH_QCOM = 0x8bd2 gl.TEXTURE_WRAP_R_OES = 0x8072 gl.TEXTURE_WRAP_S = 0x2802 gl.TEXTURE_WRAP_T = 0x2803 gl.TIMEOUT_EXPIRED_APPLE = 0x911b gl.TIMEOUT_IGNORED_APPLE = 0xffffffffffffffff gl.TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE = 0x93a0 gl.TRIANGLES = 0x4 gl.TRIANGLE_FAN = 0x6 gl.TRIANGLE_STRIP = 0x5 gl.TRUE = 0x1 gl.UNKNOWN_CONTEXT_RESET_EXT = 0x8255 gl.UNPACK_ALIGNMENT = 0xcf5 gl.UNPACK_ROW_LENGTH = 0xcf2 gl.UNPACK_SKIP_PIXELS = 0xcf4 gl.UNPACK_SKIP_ROWS = 0xcf3 gl.UNSIGNALED_APPLE = 0x9118 gl.UNSIGNED_BYTE = 0x1401 gl.UNSIGNED_INT = 0x1405 gl.UNSIGNED_INT64_AMD = 0x8bc2 gl.UNSIGNED_INT_10_10_10_2_OES = 0x8df6 gl.UNSIGNED_INT_24_8_OES = 0x84fa gl.UNSIGNED_INT_2_10_10_10_REV_EXT = 0x8368 gl.UNSIGNED_NORMALIZED_EXT = 0x8c17 gl.UNSIGNED_SHORT = 0x1403 gl.UNSIGNED_SHORT_1_5_5_5_REV_EXT = 0x8366 gl.UNSIGNED_SHORT_4_4_4_4 = 0x8033 gl.UNSIGNED_SHORT_4_4_4_4_REV_EXT = 0x8365 gl.UNSIGNED_SHORT_4_4_4_4_REV_IMG = 0x8365 gl.UNSIGNED_SHORT_5_5_5_1 = 0x8034 gl.UNSIGNED_SHORT_5_6_5 = 0x8363 gl.UNSIGNED_SHORT_8_8_APPLE = 0x85ba gl.UNSIGNED_SHORT_8_8_REV_APPLE = 0x85bb gl.VALIDATE_STATUS = 0x8b83 gl.VENDOR = 0x1f00 gl.VERSION = 0x1f02 gl.VERTEX_ARRAY_BINDING_OES = 0x85b5 gl.VERTEX_ARRAY_OBJECT_EXT = 0x9154 gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889f gl.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88fe gl.VERTEX_ATTRIB_ARRAY_DIVISOR_NV = 0x88fe gl.VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622 gl.VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886a gl.VERTEX_ATTRIB_ARRAY_POINTER = 0x8645 gl.VERTEX_ATTRIB_ARRAY_SIZE = 0x8623 gl.VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624 gl.VERTEX_ATTRIB_ARRAY_TYPE = 0x8625 gl.VERTEX_SHADER = 0x8b31 gl.VERTEX_SHADER_BIT_EXT = 0x1 gl.VIEWPORT = 0xba2 gl.VIV_shader_binary = 0x1 gl.WAIT_FAILED_APPLE = 0x911d gl.WRITEONLY_RENDERING_QCOM = 0x8823 gl.WRITE_ONLY_OES = 0x88b9 gl.Z400_BINARY_AMD = 0x8740 gl.ZERO = 0x0 ================================================ FILE: cocos2d/cocos/scripting/lua/script/StudioConstants.lua ================================================ ccs = ccs or {} ccs.MovementEventType = { start = 0, complete = 1, loopComplete = 2, } ================================================ FILE: cocos2d/cocos/scripting/lua/script/extern.lua ================================================ function clone(object) local lookup_table = {} local function _copy(object) if type(object) ~= "table" then return object elseif lookup_table[object] then return lookup_table[object] end local new_table = {} lookup_table[object] = new_table for key, value in pairs(object) do new_table[_copy(key)] = _copy(value) end return setmetatable(new_table, getmetatable(object)) end return _copy(object) end --Create an class. function class(classname, super) local superType = type(super) local cls if superType ~= "function" and superType ~= "table" then superType = nil super = nil end if superType == "function" or (super and super.__ctype == 1) then -- inherited from native C++ Object cls = {} if superType == "table" then -- copy fields from super for k,v in pairs(super) do cls[k] = v end cls.__create = super.__create cls.super = super else cls.__create = super end cls.ctor = function() end cls.__cname = classname cls.__ctype = 1 function cls.new(...) local instance = cls.__create(...) -- copy fields from class to native object for k,v in pairs(cls) do instance[k] = v end instance.class = cls instance:ctor(...) return instance end else -- inherited from Lua Object if super then cls = clone(super) cls.super = super else cls = {ctor = function() end} end cls.__cname = classname cls.__ctype = 2 -- lua cls.__index = cls function cls.new(...) local instance = setmetatable({}, cls) instance.class = cls instance:ctor(...) return instance end end return cls end function schedule(node, callback, delay) local delay = cc.DelayTime:create(delay) local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback)) local action = cc.RepeatForever:create(sequence) node:runAction(action) return action end function performWithDelay(node, callback, delay) local delay = cc.DelayTime:create(delay) local sequence = cc.Sequence:create(delay, cc.CallFunc:create(callback)) node:runAction(sequence) return sequence end ================================================ FILE: cocos2d/cocos/scripting/lua/script/json.lua ================================================ ----------------------------------------------------------------------------- -- JSON4Lua: JSON encoding / decoding support for the Lua language. -- json Module. -- Author: Craig Mason-Jones -- Homepage: http://json.luaforge.net/ -- Version: 0.9.40 -- This module is released under the MIT License (MIT). -- Please see LICENCE.txt for details. -- -- USAGE: -- This module exposes two functions: -- encode(o) -- Returns the table / string / boolean / number / nil / json.null value as a JSON-encoded string. -- decode(json_string) -- Returns a Lua object populated with the data encoded in the JSON string json_string. -- -- REQUIREMENTS: -- compat-5.1 if using Lua 5.0 -- -- CHANGELOG -- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix). -- Fixed Lua 5.1 compatibility issues. -- Introduced json.null to have null values in associative arrays. -- encode() performance improvement (more than 50%) through table.concat rather than .. -- Introduced decode ability to ignore /**/ comments in the JSON string. -- 0.9.10 Fix to array encoding / decoding to correctly manage nil/null values in arrays. ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- -- Imports and dependencies ----------------------------------------------------------------------------- local math = require('math') local string = require("string") local table = require("table") local base = _G ----------------------------------------------------------------------------- -- Module declaration ----------------------------------------------------------------------------- module("json") -- Public functions -- Private functions local decode_scanArray local decode_scanComment local decode_scanConstant local decode_scanNumber local decode_scanObject local decode_scanString local decode_scanWhitespace local encodeString local isArray local isEncodable ----------------------------------------------------------------------------- -- PUBLIC FUNCTIONS ----------------------------------------------------------------------------- --- Encodes an arbitrary Lua object / variable. -- @param v The Lua object / variable to be JSON encoded. -- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) function encode (v) -- Handle nil values if v==nil then return "null" end local vtype = base.type(v) -- Handle strings if vtype=='string' then return '"' .. encodeString(v) .. '"' -- Need to handle encoding in string end -- Handle booleans if vtype=='number' or vtype=='boolean' then return base.tostring(v) end -- Handle tables if vtype=='table' then local rval = {} -- Consider arrays separately local bArray, maxCount = isArray(v) if bArray then for i = 1,maxCount do table.insert(rval, encode(v[i])) end else -- An object, not an array for i,j in base.pairs(v) do if isEncodable(i) and isEncodable(j) then table.insert(rval, '"' .. encodeString(i) .. '":' .. encode(j)) end end end if bArray then return '[' .. table.concat(rval,',') ..']' else return '{' .. table.concat(rval,',') .. '}' end end -- Handle null values if vtype=='function' and v==null then return 'null' end base.assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. base.tostring(v)) end --- Decodes a JSON string and returns the decoded value as a Lua data structure / value. -- @param s The string to scan. -- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. -- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil, -- and the position of the first character after -- the scanned JSON object. function decode(s, startPos) startPos = startPos and startPos or 1 startPos = decode_scanWhitespace(s,startPos) base.assert(startPos<=string.len(s), 'Unterminated JSON encoded object found at position in [' .. s .. ']') local curChar = string.sub(s,startPos,startPos) -- Object if curChar=='{' then return decode_scanObject(s,startPos) end -- Array if curChar=='[' then return decode_scanArray(s,startPos) end -- Number if string.find("+-0123456789.e", curChar, 1, true) then return decode_scanNumber(s,startPos) end -- String if curChar==[["]] or curChar==[[']] then return decode_scanString(s,startPos) end if string.sub(s,startPos,startPos+1)=='/*' then return decode(s, decode_scanComment(s,startPos)) end -- Otherwise, it must be a constant return decode_scanConstant(s,startPos) end --- The null function allows one to specify a null value in an associative array (which is otherwise -- discarded if you set the value with 'nil' in Lua. Simply set t = { first=json.null } function null() return null -- so json.null() will also return null ;-) end ----------------------------------------------------------------------------- -- Internal, PRIVATE functions. -- Following a Python-like convention, I have prefixed all these 'PRIVATE' -- functions with an underscore. ----------------------------------------------------------------------------- --- Scans an array from JSON into a Lua object -- startPos begins at the start of the array. -- Returns the array and the next starting position -- @param s The string being scanned. -- @param startPos The starting position for the scan. -- @return table, int The scanned array as a table, and the position of the next character to scan. function decode_scanArray(s,startPos) local array = {} -- The return value local stringLen = string.len(s) base.assert(string.sub(s,startPos,startPos)=='[','decode_scanArray called but array does not start at position ' .. startPos .. ' in string:\n'..s ) startPos = startPos + 1 -- Infinite loop for array elements repeat startPos = decode_scanWhitespace(s,startPos) base.assert(startPos<=stringLen,'JSON String ended unexpectedly scanning array.') local curChar = string.sub(s,startPos,startPos) if (curChar==']') then return array, startPos+1 end if (curChar==',') then startPos = decode_scanWhitespace(s,startPos+1) end base.assert(startPos<=stringLen, 'JSON String ended unexpectedly scanning array.') object, startPos = decode(s,startPos) table.insert(array,object) until false end --- Scans a comment and discards the comment. -- Returns the position of the next character following the comment. -- @param string s The JSON string to scan. -- @param int startPos The starting position of the comment function decode_scanComment(s, startPos) base.assert( string.sub(s,startPos,startPos+1)=='/*', "decode_scanComment called but comment does not start at position " .. startPos) local endPos = string.find(s,'*/',startPos+2) base.assert(endPos~=nil, "Unterminated comment in string at " .. startPos) return endPos+2 end --- Scans for given constants: true, false or null -- Returns the appropriate Lua type, and the position of the next character to read. -- @param s The string being scanned. -- @param startPos The position in the string at which to start scanning. -- @return object, int The object (true, false or nil) and the position at which the next character should be -- scanned. function decode_scanConstant(s, startPos) local consts = { ["true"] = true, ["false"] = false, ["null"] = nil } local constNames = {"true","false","null"} for i,k in base.pairs(constNames) do --print ("[" .. string.sub(s,startPos, startPos + string.len(k) -1) .."]", k) if string.sub(s,startPos, startPos + string.len(k) -1 )==k then return consts[k], startPos + string.len(k) end end base.assert(nil, 'Failed to scan constant from string ' .. s .. ' at starting position ' .. startPos) end --- Scans a number from the JSON encoded string. -- (in fact, also is able to scan numeric +- eqns, which is not -- in the JSON spec.) -- Returns the number, and the position of the next character -- after the number. -- @param s The string being scanned. -- @param startPos The position at which to start scanning. -- @return number, int The extracted number and the position of the next character to scan. function decode_scanNumber(s,startPos) local endPos = startPos+1 local stringLen = string.len(s) local acceptableChars = "+-0123456789.e" while (string.find(acceptableChars, string.sub(s,endPos,endPos), 1, true) and endPos<=stringLen ) do endPos = endPos + 1 end local stringValue = 'return ' .. string.sub(s,startPos, endPos-1) local stringEval = base.loadstring(stringValue) base.assert(stringEval, 'Failed to scan number [ ' .. stringValue .. '] in JSON string at position ' .. startPos .. ' : ' .. endPos) return stringEval(), endPos end --- Scans a JSON object into a Lua object. -- startPos begins at the start of the object. -- Returns the object and the next starting position. -- @param s The string being scanned. -- @param startPos The starting position of the scan. -- @return table, int The scanned object as a table and the position of the next character to scan. function decode_scanObject(s,startPos) local object = {} local stringLen = string.len(s) local key, value base.assert(string.sub(s,startPos,startPos)=='{','decode_scanObject called but object does not start at position ' .. startPos .. ' in string:\n' .. s) startPos = startPos + 1 repeat startPos = decode_scanWhitespace(s,startPos) base.assert(startPos<=stringLen, 'JSON string ended unexpectedly while scanning object.') local curChar = string.sub(s,startPos,startPos) if (curChar=='}') then return object,startPos+1 end if (curChar==',') then startPos = decode_scanWhitespace(s,startPos+1) end base.assert(startPos<=stringLen, 'JSON string ended unexpectedly scanning object.') -- Scan the key key, startPos = decode(s,startPos) base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) startPos = decode_scanWhitespace(s,startPos) base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) base.assert(string.sub(s,startPos,startPos)==':','JSON object key-value assignment mal-formed at ' .. startPos) startPos = decode_scanWhitespace(s,startPos+1) base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) value, startPos = decode(s,startPos) object[key]=value until false -- infinite loop while key-value pairs are found end --- Scans a JSON string from the opening inverted comma or single quote to the -- end of the string. -- Returns the string extracted as a Lua string, -- and the position of the next non-string character -- (after the closing inverted comma or single quote). -- @param s The string being scanned. -- @param startPos The starting position of the scan. -- @return string, int The extracted string as a Lua string, and the next character to parse. function decode_scanString(s,startPos) base.assert(startPos, 'decode_scanString(..) called without start position') local startChar = string.sub(s,startPos,startPos) base.assert(startChar==[[']] or startChar==[["]],'decode_scanString called for a non-string') local escaped = false local endPos = startPos + 1 local bEnded = false local stringLen = string.len(s) repeat local curChar = string.sub(s,endPos,endPos) if not escaped then if curChar==[[\]] then escaped = true else bEnded = curChar==startChar end else -- If we're escaped, we accept the current character come what may escaped = false end endPos = endPos + 1 base.assert(endPos <= stringLen+1, "String decoding failed: unterminated string at position " .. endPos) until bEnded local stringValue = 'return ' .. string.sub(s, startPos, endPos-1) local stringEval = base.loadstring(stringValue) base.assert(stringEval, 'Failed to load string [ ' .. stringValue .. '] in JSON4Lua.decode_scanString at position ' .. startPos .. ' : ' .. endPos) return stringEval(), endPos end --- Scans a JSON string skipping all whitespace from the current start position. -- Returns the position of the first non-whitespace character, or nil if the whole end of string is reached. -- @param s The string being scanned -- @param startPos The starting position where we should begin removing whitespace. -- @return int The first position where non-whitespace was encountered, or string.len(s)+1 if the end of string -- was reached. function decode_scanWhitespace(s,startPos) local whitespace=" \n\r\t" local stringLen = string.len(s) while ( string.find(whitespace, string.sub(s,startPos,startPos), 1, true) and startPos <= stringLen) do startPos = startPos + 1 end return startPos end --- Encodes a string to be JSON-compatible. -- This just involves back-quoting inverted commas, back-quotes and newlines, I think ;-) -- @param s The string to return as a JSON encoded (i.e. backquoted string) -- @return The string appropriately escaped. function encodeString(s) s = string.gsub(s,'\\','\\\\') s = string.gsub(s,'"','\\"') s = string.gsub(s,"'","\\'") s = string.gsub(s,'\n','\\n') s = string.gsub(s,'\t','\\t') return s end -- Determines whether the given Lua type is an array or a table / dictionary. -- We consider any table an array if it has indexes 1..n for its n items, and no -- other data in the table. -- I think this method is currently a little 'flaky', but can't think of a good way around it yet... -- @param t The table to evaluate as an array -- @return boolean, number True if the table can be represented as an array, false otherwise. If true, -- the second returned value is the maximum -- number of indexed elements in the array. function isArray(t) -- Next we count all the elements, ensuring that any non-indexed elements are not-encodable -- (with the possible exception of 'n') local maxIndex = 0 for k,v in base.pairs(t) do if (base.type(k)=='number' and math.floor(k)==k and 1<=k) then -- k,v is an indexed pair if (not isEncodable(v)) then return false end -- All array elements must be encodable maxIndex = math.max(maxIndex,k) else if (k=='n') then if v ~= table.getn(t) then return false end -- False if n does not hold the number of elements else -- Else of (k=='n') if isEncodable(v) then return false end end -- End of (k~='n') end -- End of k,v not an indexed pair end -- End of loop across all pairs return true, maxIndex end --- Determines whether the given Lua object / table / variable can be JSON encoded. The only -- types that are JSON encodable are: string, boolean, number, nil, table and json.null. -- In this implementation, all other types are ignored. -- @param o The object to examine. -- @return boolean True if the object should be JSON encoded, false if it should be ignored. function isEncodable(o) local t = base.type(o) return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null) end ================================================ FILE: cocos2d/cocos/scripting/lua/script/luaj.lua ================================================ local luaj = {} local callJavaStaticMethod = LuaJavaBridge.callStaticMethod local function checkArguments(args, sig) if type(args) ~= "table" then args = {} end if sig then return args, sig end sig = {"("} for i, v in ipairs(args) do local t = type(v) if t == "number" then sig[#sig + 1] = "F" elseif t == "boolean" then sig[#sig + 1] = "Z" elseif t == "function" then sig[#sig + 1] = "I" else sig[#sig + 1] = "Ljava/lang/String;" end end sig[#sig + 1] = ")V" return args, table.concat(sig) end function luaj.callStaticMethod(className, methodName, args, sig) local args, sig = checkArguments(args, sig) --echoInfo("luaj.callStaticMethod(\"%s\",\n\t\"%s\",\n\targs,\n\t\"%s\"", className, methodName, sig) return callJavaStaticMethod(className, methodName, args, sig) end return luaj ================================================ FILE: cocos2d/cocos/scripting/lua/script/luaoc.lua ================================================ local luaoc = {} local callStaticMethod = LuaObjcBridge.callStaticMethod function luaoc.callStaticMethod(className, methodName, args) local ok, ret = callStaticMethod(className, methodName, args) if not ok then local msg = string.format("luaoc.callStaticMethod(\"%s\", \"%s\", \"%s\") - error: [%s] ", className, methodName, tostring(args), tostring(ret)) if ret == -1 then print(msg .. "INVALID PARAMETERS") elseif ret == -2 then print(msg .. "CLASS NOT FOUND") elseif ret == -3 then print(msg .. "METHOD NOT FOUND") elseif ret == -4 then print(msg .. "EXCEPTION OCCURRED") elseif ret == -5 then print(msg .. "INVALID METHOD SIGNATURE") else print(msg .. "UNKNOWN") end end return ok, ret end return luaoc ================================================ FILE: cocos2d/cocos/storage/local-storage/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos_localstorage_static LOCAL_MODULE_FILENAME := liblocalstorage LOCAL_SRC_FILES := LocalStorage.cpp \ LocalStorageAndroid.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static include $(BUILD_STATIC_LIBRARY) $(call import-module,2d) ================================================ FILE: cocos2d/cocos/storage/local-storage/LocalStorage.cpp ================================================ /* Copyright (c) 2012 - Zynga Inc. 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. */ /* Local Storage support for the JS Bindings for iOS. Works on cocos2d-iphone and cocos2d-x. */ #include "LocalStorage.h" #include "CCPlatformMacros.h" #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) #include #include #include #include static int _initialized = 0; static sqlite3 *_db; static sqlite3_stmt *_stmt_select; static sqlite3_stmt *_stmt_remove; static sqlite3_stmt *_stmt_update; static void localStorageCreateTable() { const char *sql_createtable = "CREATE TABLE IF NOT EXISTS data(key TEXT PRIMARY KEY,value TEXT);"; sqlite3_stmt *stmt; int ok=sqlite3_prepare_v2(_db, sql_createtable, -1, &stmt, NULL); ok |= sqlite3_step(stmt); ok |= sqlite3_finalize(stmt); if( ok != SQLITE_OK && ok != SQLITE_DONE) printf("Error in CREATE TABLE\n"); } void localStorageInit( const std::string& fullpath/* = "" */) { if( ! _initialized ) { int ret = 0; if (fullpath.empty()) ret = sqlite3_open(":memory:",&_db); else ret = sqlite3_open(fullpath.c_str(), &_db); localStorageCreateTable(); // SELECT const char *sql_select = "SELECT value FROM data WHERE key=?;"; ret |= sqlite3_prepare_v2(_db, sql_select, -1, &_stmt_select, NULL); // REPLACE const char *sql_update = "REPLACE INTO data (key, value) VALUES (?,?);"; ret |= sqlite3_prepare_v2(_db, sql_update, -1, &_stmt_update, NULL); // DELETE const char *sql_remove = "DELETE FROM data WHERE key=?;"; ret |= sqlite3_prepare_v2(_db, sql_remove, -1, &_stmt_remove, NULL); if( ret != SQLITE_OK ) { printf("Error initializing DB\n"); // report error } _initialized = 1; } } void localStorageFree() { if( _initialized ) { sqlite3_finalize(_stmt_select); sqlite3_finalize(_stmt_remove); sqlite3_finalize(_stmt_update); sqlite3_close(_db); _initialized = 0; } } /** sets an item in the LS */ void localStorageSetItem( const std::string& key, const std::string& value) { assert( _initialized ); int ok = sqlite3_bind_text(_stmt_update, 1, key.c_str(), -1, SQLITE_TRANSIENT); ok |= sqlite3_bind_text(_stmt_update, 2, value.c_str(), -1, SQLITE_TRANSIENT); ok |= sqlite3_step(_stmt_update); ok |= sqlite3_reset(_stmt_update); if( ok != SQLITE_OK && ok != SQLITE_DONE) printf("Error in localStorage.setItem()\n"); } /** gets an item from the LS */ std::string localStorageGetItem( const std::string& key ) { assert( _initialized ); std::string ret; int ok = sqlite3_reset(_stmt_select); ok |= sqlite3_bind_text(_stmt_select, 1, key.c_str(), -1, SQLITE_TRANSIENT); ok |= sqlite3_step(_stmt_select); const unsigned char *text = sqlite3_column_text(_stmt_select, 0); if (text) ret = (const char*)text; if( ok != SQLITE_OK && ok != SQLITE_DONE && ok != SQLITE_ROW) printf("Error in localStorage.getItem()\n"); return ret; } /** removes an item from the LS */ void localStorageRemoveItem( const std::string& key ) { assert( _initialized ); int ok = sqlite3_bind_text(_stmt_remove, 1, key.c_str(), -1, SQLITE_TRANSIENT); ok |= sqlite3_step(_stmt_remove); ok |= sqlite3_reset(_stmt_remove); if( ok != SQLITE_OK && ok != SQLITE_DONE) printf("Error in localStorage.removeItem()\n"); } #endif // #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) ================================================ FILE: cocos2d/cocos/storage/local-storage/LocalStorage.h ================================================ /* Copyright (c) 2012 - Zynga Inc. 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. */ /* Local Storage support for the JS Bindings for iOS. Works on cocos2d-iphone and cocos2d-x. */ #ifndef __JSB_LOCALSTORAGE_H #define __JSB_LOCALSTORAGE_H #include /** Initializes the database. If path is null, it will create an in-memory DB */ void localStorageInit( const std::string& fullpath = ""); /** Frees the allocated resources */ void localStorageFree(); /** sets an item in the LS */ void localStorageSetItem( const std::string& key, const std::string& value); /** gets an item from the LS */ std::string localStorageGetItem( const std::string& key ); /** removes an item from the LS */ void localStorageRemoveItem( const std::string& key ); #endif // __JSB_LOCALSTORAGE_H ================================================ FILE: cocos2d/cocos/storage/local-storage/LocalStorageAndroid.cpp ================================================ /*************************************************************************** Copyright (c) 2012 Zynga Inc. Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologic Inc. 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. ***************************************************************************/ /* Local Storage support for the JS Bindings for iOS. Works on cocos2d-iphone and cocos2d-x. */ #include "LocalStorage.h" #include "CCPlatformMacros.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include #include #include #include "jni.h" #include "jni/JniHelper.h" USING_NS_CC; static int _initialized = 0; static void splitFilename (std::string& str) { size_t found = 0; found=str.find_last_of("/\\"); if (found != std::string::npos) { str = str.substr(found+1); } } void localStorageInit( const std::string& fullpath) { if (fullpath.empty()) return; if( ! _initialized ) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxLocalStorage", "init", "(Ljava/lang/String;Ljava/lang/String;)Z")) { std::string strDBFilename = fullpath; splitFilename(strDBFilename); jstring jdbName = t.env->NewStringUTF(strDBFilename.c_str()); jstring jtableName = t.env->NewStringUTF("data"); jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, jdbName, jtableName); t.env->DeleteLocalRef(jdbName); t.env->DeleteLocalRef(jtableName); t.env->DeleteLocalRef(t.classID); if (ret) { _initialized = 1; } } } } void localStorageFree() { if( _initialized ) { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxLocalStorage", "destory", "()V")) { t.env->CallStaticVoidMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); } _initialized = 0; } } /** sets an item in the LS */ void localStorageSetItem( const std::string& key, const std::string& value) { assert( _initialized ); JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxLocalStorage", "setItem", "(Ljava/lang/String;Ljava/lang/String;)V")) { jstring jkey = t.env->NewStringUTF(key.c_str()); jstring jvalue = t.env->NewStringUTF(value.c_str()); t.env->CallStaticVoidMethod(t.classID, t.methodID, jkey, jvalue); t.env->DeleteLocalRef(jkey); t.env->DeleteLocalRef(jvalue); t.env->DeleteLocalRef(t.classID); } } /** gets an item from the LS */ std::string localStorageGetItem( const std::string& key ) { assert( _initialized ); JniMethodInfo t; std::string ret; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxLocalStorage", "getItem", "(Ljava/lang/String;)Ljava/lang/String;")) { jstring jkey = t.env->NewStringUTF(key.c_str()); jstring jret = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID, jkey); ret = JniHelper::jstring2string(jret); t.env->DeleteLocalRef(jret); t.env->DeleteLocalRef(jkey); t.env->DeleteLocalRef(t.classID); } return ret; } /** removes an item from the LS */ void localStorageRemoveItem( const std::string& key ) { assert( _initialized ); JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxLocalStorage", "removeItem", "(Ljava/lang/String;)V")) { jstring jkey = t.env->NewStringUTF(key.c_str()); t.env->CallStaticVoidMethod(t.classID, t.methodID, jkey); t.env->DeleteLocalRef(jkey); t.env->DeleteLocalRef(t.classID); } } #endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) ================================================ FILE: cocos2d/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj ================================================  Debug Win32 Release Win32 {632A8F38-D0F0-4D22-86B3-D69F5E6BF63A} libLocalStorage StaticLibrary true v100 v110 v110_xp Unicode StaticLibrary false v100 v110 v110_xp true Unicode $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ Level3 Disabled $(EngineRoot)external\sqlite3\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true 4267;4251;4244;%(DisableSpecificWarnings) false true Level3 MaxSpeed true true $(EngineRoot)external\sqlite3\include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true true ================================================ FILE: cocos2d/cocos/storage/local-storage/proj.win32/libLocalStorage.vcxproj.filters ================================================  {0310200c-b520-4f77-85f6-46f568b10f4d} {69cfa37c-4b20-409e-ad74-a26314878d8a} Source Files Header Files ================================================ FILE: cocos2d/docs/.gitignore ================================================ html/ .tee-*.txt ================================================ FILE: cocos2d/docs/CODING_STYLE.md ================================================ # ![][1] C++ coding style _v0.2 - Last updated November 8, 2013_ _Forked from [Google's C++ coding style](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml) rev. 3.274_ **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* - [Header Files](#header-files) - [The #define Guard](#the-define-guard) - [Forward Declarations](#forward-declarations) - [Inline Functions](#inline-functions) - [The -inl.h Files](#the--inlh-files) - [Function Parameter Ordering](#function-parameter-ordering) - [Names and Order of Includes](#names-and-order-of-includes) - [Scoping](#scoping) - [Namespaces](#namespaces) - [Unnamed Namespaces](#unnamed-namespaces) - [Named Namespaces](#named-namespaces) - [Nested Classes](#nested-classes) - [Nonmember, Static Member, and Global Functions](#nonmember-static-member-and-global-functions) - [Local Variables](#local-variables) - [Static and Global Variables](#static-and-global-variables) - [Classes](#classes) - [Doing Work in Constructors](#doing-work-in-constructors) - [Initialization](#initialization) - [Explicit Constructors](#explicit-constructors) - [Copy Constructors](#copy-constructors) - [Delegating and inheriting constructors](#delegating-and-inheriting-constructors) - [Structs vs. Classes](#structs-vs-classes) - [Inheritance](#inheritance) - [Multiple Inheritance](#multiple-inheritance) - [Interfaces](#interfaces) - [Operator Overloading](#operator-overloading) - [Access Control](#access-control) - [Declaration Order](#declaration-order) - [Write Short Functions](#write-short-functions) - [Other C++ Features](#other-c-features) - [Ownership and Smart Pointers](#ownership-and-smart-pointers) - [Reference Arguments](#reference-arguments) - [Rvalue references](#rvalue-references) - [Function Overloading](#function-overloading) - [Default Arguments](#default-arguments) - [Variable-Length Arrays and alloca()](#variable-length-arrays-and-alloca) - [Friends](#friends) - [Exceptions](#exceptions) - [Run-Time Type Information (RTTI)](#run-time-type-information-rtti) - [Casting](#casting) - [Streams](#streams) - [Preincrement and Predecrement](#preincrement-and-predecrement) - [Use of const](#use-of-const) - [Use of constexpr](#use-of-constexpr) - [Use of constexpr](#use-of-constexpr-1) - [Integer Types](#integer-types) - [On Unsigned Integers](#on-unsigned-integers) - [64-bit Portability](#64-bit-portability) - [Preprocessor Macros](#preprocessor-macros) - [0 and nullptr/NULL](#0-and-nullptrnull) - [sizeof](#sizeof) - [auto](#auto) - [Brace Initialization](#brace-initialization) - [Lambda expressions](#lambda-expressions) - [Boost](#boost) - [C++11](#c11) - [General Naming Rules](#general-naming-rules) - [File Names](#file-names) - [Type Names](#type-names) - [Variable Names](#variable-names) - [Common Variable names](#common-variable-names) - [Class Data Members](#class-data-members) - [Struct Variables](#struct-variables) - [Global Variables](#global-variables) - [Constant Names](#constant-names) - [Function Names](#function-names) - [Regular Functions](#regular-functions) - [Accessors and Mutators](#accessors-and-mutators) - [Namespace Names](#namespace-names) - [Enumerator Names](#enumerator-names) - [Macro Names](#macro-names) - [Exceptions to Naming Rules](#exceptions-to-naming-rules) - [bigopen()](#bigopen) - [uint](#uint) - [bigpos](#bigpos) - [sparse_hash_map](#sparse_hash_map) - [LONGLONG_MAX](#longlong_max) - [Comments](#comments) - [Doxygen](#doxygen) - [Comment Style](#comment-style) - [File Comments](#file-comments) - [Legal Notice and Author Line](#legal-notice-and-author-line) - [File Contents](#file-contents) - [Class Comments](#class-comments) - [Function Comments](#function-comments) - [Function Declarations](#function-declarations) - [Function Definitions](#function-definitions) - [Variable Comments](#variable-comments) - [Class Data Members](#class-data-members-1) - [Global Variables](#global-variables-1) - [Implementation Comments](#implementation-comments) - [Class Data Members](#class-data-members-2) - [Line Comments](#line-comments) - [nullptr/NULL, true/false, 1, 2, 3...](#nullptrnull-truefalse-1-2-3) - [Don'ts](#donts) - [Punctuation, Spelling and Grammar](#punctuation-spelling-and-grammar) - [TODO Comments](#todo-comments) - [Deprecation Comments](#deprecation-comments) - [Formatting](#formatting) - [Line Length](#line-length) - [Non-ASCII Characters](#non-ascii-characters) - [Spaces vs. Tabs](#spaces-vs-tabs) - [Function Declarations and Definitions](#function-declarations-and-definitions) - [Function Calls](#function-calls) - [Braced Initializer Lists](#braced-initializer-lists) - [Conditionals](#conditionals) - [Loops and Switch Statements](#loops-and-switch-statements) - [Pointer and Reference Expressions](#pointer-and-reference-expressions) - [Boolean Expressions](#boolean-expressions) - [Return Values](#return-values) - [Variable and Array Initialization](#variable-and-array-initialization) - [Preprocessor Directives](#preprocessor-directives) - [Class Format](#class-format) - [Constructor Initializer Lists](#constructor-initializer-lists) - [Namespace Formatting](#namespace-formatting) - [Horizontal Whitespace](#horizontal-whitespace) - [General](#general) - [Loops and Conditionals](#loops-and-conditionals) - [Operators](#operators) - [Templates and Casts](#templates-and-casts) - [Vertical Whitespace](#vertical-whitespace) - [Exceptions to the Rules](#exceptions-to-the-rules) - [Existing Non-conformant Code](#existing-non-conformant-code) - [Windows Code](#windows-code) - [Parting Words](#parting-words) # Header Files In general, every `.cpp` file should have an associated `.h` file. There are some common exceptions, such as unittests and small `.cpp` files containing just a `main()` function. Correct use of header files can make a huge difference to the readability, size and performance of your code. The following rules will guide you through the various pitfalls of using header files. ## The #define Guard All header files should have `#define` guards to prevent multiple inclusion. The format of the symbol name should be `___H_.` To guarantee uniqueness, they should be based on the full path in a project's source tree. For example, the file `cocos2dx/sprites_nodes/CCSprite.h` in project foo should have the following guard: ```cpp #ifndef COCOS2DX_SPRITE_NODES_CCSPRITE_H_ #define COCOS2DX_SPRITE_NODES_CCSPRITE_H_ ... #endif // COCOS2DX_SPRITE_NODES_CCSPRITE_H_ ``` ```cpp // Pragma once is still open for debate #pragma once ``` We are cosidering using `#pragma once` as well, although we haven't determined yet if it is supported in all our target platforms. ## Forward Declarations You may forward declare ordinary classes in order to avoid unnecessary `#includes`. **Definition:** A "forward declaration" is a declaration of a class, function, or template without an associated definition. #include lines can often be replaced with forward declarations of whatever symbols are actually used by the client code. **Pros:** * Unnecessary #includes force the compiler to open more files and process more input. * They can also force your code to be recompiled more often, due to changes in the header. **Cons:** * It can be difficult to determine the correct form of a forward declaration in the presence of features like templates, typedefs, default parameters, and using declarations. * It can be difficult to determine whether a forward declaration or a full #include is needed for a given piece of code, particularly when implicit conversion operations are involved. In extreme cases, replacing an #include with a forward declaration can silently change the meaning of code. * Forward declaring multiple symbols from a header can be more verbose than simply #includeing the header. * Forward declarations of functions and templates can prevent the header owners from making otherwise-compatible changes to their APIs; for example, widening a parameter type, or adding a template parameter with a default value. * Forward declaring symbols from namespace std:: usually yields undefined behavior. * Structuring code to enable forward declarations (e.g. using pointer members instead of object members) can make the code slower and more complex. * The practical efficiency benefits of forward declarations are unproven. **Decision:** * When using a function declared in a header file, always #include that header. * When using a class template, prefer to #include its header file. * When using an ordinary class, relying on a forward declaration is OK, but be wary of situations where a forward declaration may be insufficient or incorrect; when in doubt, just #include the appropriate header. * Do not replace data members with pointers just to avoid an #include. Always #include the file that actually provides the declarations/definitions you need; do not rely on the symbol being brought in transitively via headers not directly included. One exception is that `Myfile.cpp` may rely on #includes and forward declarations from its corresponding header file `Myfile.h`. ## Inline Functions Define functions inline only when they are small, say, 10 lines or less. **Definition:** You can declare functions in a way that allows the compiler to expand them inline rather than calling them through the usual function call mechanism. **Pros:** Inlining a function can generate more efficient object code, as long as the inlined function is small. Feel free to inline accessors and mutators, and other short, performance-critical functions. **Cons:** Overuse of inlining can actually make programs slower. Depending on a function's size, inlining it can cause the code size to increase or decrease. Inlining a very small accessor function will usually decrease code size while inlining a very large function can dramatically increase code size. On modern processors smaller code usually runs faster due to better use of the instruction cache. **Decision:** A decent rule of thumb is to not inline a function if it is more than 10 lines long. Beware of destructors, which are often longer than they appear because of implicit member- and base-destructor calls! Another useful rule of thumb: it's typically not cost effective to inline functions with loops or switch statements (unless, in the common case, the loop or switch statement is never executed). It is important to know that functions are not always inlined even if they are declared as such; for example, virtual and recursive functions are not normally inlined. Usually recursive functions should not be inline. The main reason for making a virtual function inline is to place its definition in the class, either for convenience or to document its behavior, e.g., for accessors and mutators. ## The -inl.h Files You may use file names with a -inl.h suffix to define complex inline functions when needed. The definition of an inline function needs to be in a header file, so that the compiler has the definition available for inlining at the call sites. However, implementation code properly belongs in .cpp files, and we do not like to have much actual code in .h files unless there is a readability or performance advantage. If an inline function definition is short, with very little, if any, logic in it, you should put the code in your .h file. For example, accessors and mutators should certainly be inside a class definition. More complex inline functions may also be put in a .h file for the convenience of the implementer and callers, though if this makes the .h file too unwieldy you can instead put that code in a separate -inl.h file. This separates the implementation from the class definition, while still allowing the implementation to be included where necessary. Another use of -inl.h files is for definitions of function templates. This can be used to keep your template definitions easy to read. Do not forget that a -inl.h file requires a #define guard just like any other header file. ## Function Parameter Ordering When defining a function, parameter order is: inputs, then outputs. Parameters to C/C++ functions are either input to the function, output from the function, or both. Input parameters are usually `values` or `const references`, while output and input/output parameters will be `non-const pointers` . When ordering function parameters, put all input-only parameters before any output parameters. In particular, do not add new parameters to the end of the function just because they are new; place new input-only parameters before the output parameters. This is not a hard-and-fast rule. Parameters that are both input and output (often classes/structs) muddy the waters, and, as always, consistency with related functions may require you to bend the rule. ## Names and Order of Includes Use standard order for readability and to avoid hidden dependencies: C library, C++ library, other libraries' .h, your project's .h. All of a project's header files should be listed as descendants of the project's source directory without use of UNIX directory shortcuts . (the current directory) or .. (the parent directory). For example, google-awesome-project/src/base/logging.h should be included as ```cpp #include "base/logging.h" ``` In `dir/foo.cpp` or `dir/foo_test.cpp`, whose main purpose is to implement or test the stuff in `dir2/foo2.h`, order your includes as follows: * dir2/foo2.h (preferred location — see details below). * C system files. * C++ system files. * Other libraries' .h files. * Your project's .h files. With the preferred ordering, if `dir2/foo2.h` omits any necessary includes, the build of `dir/foo.cpp` or `dir/foo_test.cpp` will break. Thus, this rule ensures that build breaks show up first for the people working on these files, not for innocent people in other packages. `dir/foo.cpp` and `dir2/foo2.h` are often in the same directory (e.g. `base/basictypes_test.cpp` and `base/basictypes.h`), but can be in different directories too. Within each section the includes should be ordered alphabetically. Note that older code might not conform to this rule and should be fixed when convenient. For example, the includes in `cocos2dx/sprite_nodes/CCSprite.cpp` might look like this: ```cpp #include "sprite_nodes/CCSprite.h" // Preferred location. #include #include #include #include #include "base/basictypes.h" #include "base/commandlineflags.h" #include "foo/public/bar.h" ``` Exception: sometimes, system-specific code needs conditional includes. Such code can put conditional includes after other includes. Of course, keep your system-specific code small and localized. Example: ```cpp #include "foo/public/fooserver.h" #include "base/port.h" // For LANG_CXX11. #ifdef LANG_CXX11 #include #endif // LANG_CXX11 ``` # Scoping ## Namespaces Unnamed namespaces in `.cpp` files are encouraged. With named namespaces, choose the name based on the project, and possibly its path. Do not use a using-directive. Do not use inline namespaces. **Definition:** Namespaces subdivide the global scope into distinct, named scopes, and so are useful for preventing name collisions in the global scope. **Pros:** Namespaces provide a (hierarchical) axis of naming, in addition to the (also hierarchical) name axis provided by classes. For example, if two different projects have a class Foo in the global scope, these symbols may collide at compile time or at runtime. If each project places their code in a namespace, project1::Foo and project2::Foo are now distinct symbols that do not collide. Inline namespaces automatically place their names in the enclosing scope. Consider the following snippet, for example: ```cpp namespace X { inline namespace Y { void foo(); } } ``` The expressions `X::Y::foo()` and `X::foo()` are interchangeable. Inline namespaces are primarily intended for ABI compatibility across versions. **Cons:** Namespaces can be confusing, because they provide an additional (hierarchical) axis of naming, in addition to the (also hierarchical) name axis provided by classes. Inline namespaces, in particular, can be confusing because names aren't actually restricted to the namespace where they are declared. They are only useful as part of some larger versioning policy. Use of unnamed namespaces in header files can easily cause violations of the C++ One Definition Rule (ODR). **Decision:** Use namespaces according to the policy described below. Terminate namespaces with comments as shown in the given examples. ### Unnamed Namespaces Unnamed namespaces are allowed and even encouraged in .cpp files, to avoid runtime naming conflicts: ```cpp namespace { // This is in a .cpp file. // The content of a namespace is not indented enum { UNUSED, EOF, ERROR }; // Commonly used tokens. bool atEof() { return _pos == EOF; } // Uses our namespace's EOF. } // namespace ``` However, file-scope declarations that are associated with a particular class may be declared in that class as types, static data members or static member functions rather than as members of an unnamed namespace. Do not use unnamed namespaces in .h files. ### Named Namespaces Named namespaces should be used as follows: Namespaces wrap the entire source file after includes, gflags definitions/declarations, and forward declarations of classes from other namespaces: ```cpp // In the .h file // When using the cocos2d namespace NS_CC_BEGIN // All declarations are within the namespace scope. // Notice the lack of indentation. class MyClass { public: ... void foo(); }; NS_CC_END ``` ```cpp // In the .h file // When NOT using the cocos2d namespace namespace mynamespace { // All declarations are within the namespace scope. // Notice the lack of indentation. class MyClass { public: ... void foo(); }; } // namespace mynamespace ``` ```cpp // In the .cpp file namespace mynamespace { // Definition of functions is within scope of the namespace. void MyClass::foo() { ... } } // namespace mynamespace ``` The typical .cpp file might have more complex detail, including the need to reference classes in other namespaces. ```cpp #include "a.h" DEFINE_bool(someflag, false, "dummy flag"); class C; // Forward declaration of class C in the global namespace. namespace a { class A; } // Forward declaration of a::A. namespace b { ...code for b... // Code goes against the left margin. } // namespace b ``` * Do not declare anything in namespace std, not even forward declarations of standard library classes. Declaring entities in namespace std is undefined behavior, i.e., not portable. To declare entities from the standard library, include the appropriate header file. You may not use a using-directive to make all names from a namespace available. ```cpp // Forbidden -- This pollutes the namespace. using namespace foo; ``` * You may use a using-declaration anywhere in a .cpp file, and in functions, methods or classes in .h files. ```cpp // OK in .cpp files. // Must be in a function, method or class in .h files. using ::foo::bar; ``` * Namespace aliases are allowed anywhere in a .cpp file, anywhere inside the named namespace that wraps an entire .h file, and in functions and methods. ```cpp // Shorten access to some commonly used names in .cpp files. namespace fbz = ::foo::bar::baz; // Shorten access to some commonly used names (in a .h file). namespace librarian { // The following alias is available to all files including // this header (in namespace librarian): // alias names should therefore be chosen consistently // within a project. namespace pd_s = ::pipeline_diagnostics::sidetable; inline void myInlineFunction() { // namespace alias local to a function (or method). namespace fbz = ::foo::bar::baz; ... } } // namespace librarian ``` Note that an alias in a .h file is visible to everyone #including that file, so public headers (those available outside a project) and headers transitively #included by them, should avoid defining aliases, as part of the general goal of keeping public APIs as small as possible. * Do not use inline namespaces. ## Nested Classes Although you may use public nested classes when they are part of an interface, consider a namespace to keep declarations out of the global scope. **Definition:** A class can define another class within it; this is also called a member class. ```cpp class Foo { private: // Bar is a member class, nested within Foo. class Bar { ... }; }; ``` **Pros:** This is useful when the nested (or member) class is only used by the enclosing class; making it a member puts it in the enclosing class scope rather than polluting the outer scope with the class name. Nested classes can be forward declared within the enclosing class and then defined in the .cpp file to avoid including the nested class definition in the enclosing class declaration, since the nested class definition is usually only relevant to the implementation. **Cons:** Nested classes can be forward-declared only within the definition of the enclosing class. Thus, any header file manipulating a Foo::Bar* pointer will have to include the full class declaration for Foo. **Decision:** Do not make nested classes public unless they are actually part of the interface, e.g., a class that holds a set of options for some method. ## Nonmember, Static Member, and Global Functions Prefer nonmember functions within a namespace or static member functions to global functions; use completely global functions rarely. **Pros:** Nonmember and static member functions can be useful in some situations. Putting nonmember functions in a namespace avoids polluting the global namespace. **Cons:** Nonmember and static member functions may make more sense as members of a new class, especially if they access external resources or have significant dependencies. **Decision:** Sometimes it is useful, or even necessary, to define a function not bound to a class instance. Such a function can be either a static member or a nonmember function. Nonmember functions should not depend on external variables, and should nearly always exist in a namespace. Rather than creating classes only to group static member functions which do not share static data, use namespaces instead. Functions defined in the same compilation unit as production classes may introduce unnecessary coupling and link-time dependencies when directly called from other compilation units; static member functions are particularly susceptible to this. Consider extracting a new class, or placing the functions in a namespace possibly in a separate library. If you must define a nonmember function and it is only needed in its .cpp file, use an unnamed namespace or static linkage (eg static int Foo() {...}) to limit its scope. ## Local Variables Place a function's variables in the narrowest scope possible, and initialize variables in the declaration. C++ allows you to declare variables anywhere in a function. We encourage you to declare them in as local a scope as possible, and as close to the first use as possible. This makes it easier for the reader to find the declaration and see what type the variable is and what it was initialized to. In particular, initialization should be used instead of declaration and assignment, e.g. ```cpp int i; i = f(); // Bad -- initialization separate from declaration. int j = g(); // Good -- declaration has initialization. vector v; v.push_back(1); // Prefer initializing using brace initialization. v.push_back(2); vector v = {1, 2}; // Good -- v starts initialized. ``` Note that gcc implements `for (int i = 0; i < 10; ++i)` correctly (the scope of i is only the scope of the for loop), so you can then reuse i in another for loop in the same scope. It also correctly scopes declarations in if and while statements, e.g. ```cpp while (const char* p = strchr(str, '/')) str = p + 1; ``` There is one caveat: if the variable is an object, its constructor is invoked every time it enters scope and is created, and its destructor is invoked every time it goes out of scope. ```cpp // Inefficient implementation: for (int i = 0; i < 1000000; ++i) { Foo f; // My ctor and dtor get called 1000000 times each. f.doSomething(i); } It may be more efficient to declare such a variable used in a loop outside that loop: Foo f; // My ctor and dtor get called once each. for (int i = 0; i < 1000000; ++i) { f.doSomething(i); } ``` ## Static and Global Variables Static or global variables of class type are forbidden: they cause hard-to-find bugs due to indeterminate order of construction and destruction. However, such variables are allowed if they are `constexpr`: they have no dynamic initialization or destruction. Objects with static storage duration, including global variables, static variables, static class member variables, and function static variables, must be Plain Old Data (POD): only ints, chars, floats, or pointers, or arrays/structs of POD. The order in which class constructors and initializers for static variables are called is only partially specified in C++ and can even change from build to build, which can cause bugs that are difficult to find. Therefore in addition to banning globals of class type, we do not allow static POD variables to be initialized with the result of a function, unless that function (such as getenv(), or getpid()) does not itself depend on any other globals. Likewise, global and static variables are destroyed when the program terminates, regardless of whether the termination is by returning from `main()` or by calling `exit()`. The order in which destructors are called is defined to be the reverse of the order in which the constructors were called. Since constructor order is indeterminate, so is destructor order. For example, at program-end time a static variable might have been destroyed, but code still running — perhaps in another thread — tries to access it and fails. Or the destructor for a static `string` variable might be run prior to the destructor for another variable that contains a reference to that string. One way to alleviate the destructor problem is to terminate the program by calling `quick_exit()` instead of `exit()`. The difference is that `quick_exit()` does not invoke destructors and does not invoke any handlers that were registered by calling `atexit()`. If you have a handler that needs to run when a program terminates via `quick_exit()` (flushing logs, for example), you can register it `using at_quick_exit()`. (If you have a handler that needs to run at both exit() and quick_exit(), you need to register it in both places.) As a result we only allow static variables to contain POD data. This rule completely disallows vector (use C arrays instead), or string (use const char []). If you need a static or global variable of a class type, consider initializing a pointer (which will never be freed), from either your main() function or from pthread_once(). Note that this must be a raw pointer, not a "smart" pointer, since the smart pointer's destructor will have the order-of-destructor issue that we are trying to avoid. # Classes Classes are the fundamental unit of code in C++. Naturally, we use them extensively. This section lists the main dos and don'ts you should follow when writing a class. ## Doing Work in Constructors Avoid doing complex initialization in constructors (in particular, initialization that can fail or that requires virtual method calls). **Definition:** It is possible to perform initialization in the body of the constructor. **Pros:** Convenience in typing. No need to worry about whether the class has been initialized or not. **Cons:** The problems with doing work in constructors are: * There is no easy way for constructors to signal errors, short of using exceptions (which are forbidden). * If the work fails, we now have an object whose initialization code failed, so it may be an indeterminate state. * If the work calls virtual functions, these calls will not get dispatched to the subclass implementations. Future modification to your class can quietly introduce this problem even if your class is not currently subclassed, causing much confusion. * If someone creates a global variable of this type (which is against the rules, but still), the constructor code will be called before main(), possibly breaking some implicit assumptions in the constructor code. For instance, gflags will not yet have been initialized. **Decision:** Constructors should never call virtual functions or attempt to raise non-fatal failures. If your object requires non-trivial initialization, consider using a factory function or Init() method. ## Initialization If your class defines member variables, you must provide an in-class initializer for every member variable or write a constructor (which can be a default constructor). If you do not declare any constructors yourself then the compiler will generate a default constructor for you, which may leave some fields uninitialized or initialized to inappropriate values. **Definition:** The default constructor is called when we new a class object with no arguments. It is always called when calling `new[]` (for arrays). In-class member initialization means declaring a member variable using a construction like `int _count = 17;` or `string name_{"abc"};`, as opposed to just `int _count;` or `string _name;`. **Pros:** A user defined default constructor is used to initialize an object if no initializer is provided. It can ensure that an object is always in a valid and usable state as soon as it's constructed; it can also ensure that an object is initially created in an obviously "impossible" state, to aid debugging. In-class member initialization ensures that a member variable will be initialized appropriately without having to duplicate the initialization code in multiple constructors. This can reduce bugs where you add a new member variable, initialize it in one constructor, and forget to put that initialization code in another constructor. **Cons:** Explicitly defining a default constructor is extra work for you, the code writer. In-class member initialization is potentially confusing if a member variable is initialized as part of its declaration and also initialized in a constructor, since the value in the constructor will override the value in the declaration. **Decision:** Use in-class member initialization for simple initializations, especially when a member variable must be initialized the same way in more than one constructor. If your class defines member variables that aren't initialized in-class, and if it has no other constructors, you must define a default constructor (one that takes no arguments). It should preferably initialize the object in such a way that its internal state is consistent and valid. The reason for this is that if you have no other constructors and do not define a default constructor, the compiler will generate one for you. This compiler generated constructor may not initialize your object sensibly. If your class inherits from an existing class but you add no new member variables, you are not required to have a default constructor. The reason for this is that if you have no other constructors and do not define a default constructor, the compiler will generate one for you. This compiler generated constructor may not initialize your object sensibly. If your class inherits from an existing class but you add no new member variables, you are not required to have a default constructor. ## Explicit Constructors Use the C++ keyword explicit for constructors with one argument. **Definition:** Normally, if a constructor takes one argument, it can be used as a conversion. For instance, if you define Foo::Foo(string name) and then pass a string to a function that expects a Foo, the constructor will be called to convert the string into a Foo and will pass the Foo to your function for you. This can be convenient but is also a source of trouble when things get converted and new objects created without you meaning them to. Declaring a constructor explicit prevents it from being invoked implicitly as a conversion. **Pros:** Avoids undesirable conversions. **Cons:** None. **Decision:** We require all single argument constructors to be explicit. Always put explicit in front of one-argument constructors in the class definition: explicit Foo(string name); The exception is copy constructors, which, in the rare cases when we allow them, should probably not be explicit. Classes that are intended to be transparent wrappers around other classes are also exceptions. Such exceptions should be clearly marked with comments. Finally, constructors that take only an initializer_list may be non-explicit. This is to permit construction of your type using the assigment form for brace init lists (i.e. `MyType m = {1, 2}` ). ## Copy Constructors Provide a copy constructor and assignment operator only when necessary. Otherwise, disable them with `DISALLOW_COPY_AND_ASSIGN`. **Definition:** The copy constructor and assignment operator are used to create copies of objects. The copy constructor is implicitly invoked by the compiler in some situations, e.g. passing objects by value. **Pros:** Copy constructors make it easy to copy objects. STL containers require that all contents be copyable and assignable. Copy constructors can be more efficient than CopyFrom()-style workarounds because they combine construction with copying, the compiler can elide them in some contexts, and they make it easier to avoid heap allocation. **Cons:** Implicit copying of objects in C++ is a rich source of bugs and of performance problems. It also reduces readability, as it becomes hard to track which objects are being passed around by value as opposed to by reference, and therefore where changes to an object are reflected. **Decision:** Few classes need to be copyable. Most should have neither a copy constructor nor an assignment operator. In many situations, a pointer or reference will work just as well as a copied value, with better performance. For example, you can pass function parameters by reference or pointer instead of by value, and you can store pointers rather than objects in an STL container. If your class needs to be copyable, prefer providing a copy method, such as `clone()`, rather than a copy constructor, because such methods cannot be invoked implicitly. If a copy method is insufficient in your situation (e.g. for performance reasons, or because your class needs to be stored by value in an STL container), provide both a copy constructor and assignment operator. If your class does not need a copy constructor or assignment operator, you must explicitly disable them. To do so, add dummy declarations for the copy constructor and assignment operator in the private: section of your class, but do not provide any corresponding definition (so that any attempt to use them results in a link error). For convenience, a `DISALLOW_COPY_AND_ASSIGN` macro can be used: ```cpp // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) ``` Then, in class Foo: ```cpp class Foo { public: Foo(int f); ~Foo(); private: DISALLOW_COPY_AND_ASSIGN(Foo); }; ``` ## Delegating and inheriting constructors Use delegating and inheriting constructors when they reduce code duplication. **Definition:** Delegating and inheriting constructors are two different features, both introduced in C++11, for reducing code duplication in constructors. Delegating constructors allow one of a class's constructors to forward work to one of the class's other constructors, using a special variant of the initialization list syntax. For example: ```cpp X::X(const string& name) : name_(name) { ... } X::X() : X("") { } ``` Inheriting constructors allow a derived class to have its base class's constructors available directly, just as with any of the base class's other member functions, instead of having to redeclare them. This is especially useful if the base has multiple constructors. For example: ```cpp class Base { public: Base(); Base(int n); Base(const string& s); ... }; class Derived : public Base { public: using Base::Base; // Base's constructors are redeclared here. }; ``` This is especially useful when Derived's constructors don't have to do anything more than calling Base's constructors. **Pros:** Delegating and inheriting constructors reduce verbosity and boilerplate, which can improve readability. Delegating constructors are familiar to Java programmers. **Cons:** It's possible to approximate the behavior of delegating constructors by using a helper function. Inheriting constructors may be confusing if a derived class introduces new member variables, since the base class constructor doesn't know about them. **Decision:** Use delegating and inheriting constructors when they reduce boilerplate and improve readability. Be cautious about inheriting constructors when your derived class has new member variables. Inheriting constructors may still be appropriate in that case if you can use in-class member initialization for the derived class's member variables. ## Structs vs. Classes Use a struct only for passive objects that carry data; everything else is a class. The struct and class keywords behave almost identically in C++. We add our own semantic meanings to each keyword, so you should use the appropriate keyword for the data-type you're defining. structs should be used for passive objects that carry data, and may have associated constants, but lack any functionality other than access/setting the data members. The accessing/setting of fields is done by directly accessing the fields rather than through method invocations. Methods should not provide behavior but should only be used to set up the data members, e.g., constructor, destructor, Initialize(), Reset(), Validate(). If more functionality is required, a class is more appropriate. If in doubt, make it a class. For consistency with STL, you can use struct instead of class for functors and traits. Note that member variables in structs and classes have different naming rules. ## Inheritance Composition is often more appropriate than inheritance. When using inheritance, make it public. **Definition:** When a sub-class inherits from a base class, it includes the definitions of all the data and operations that the parent base class defines. In practice, inheritance is used in two major ways in C++: implementation inheritance, in which actual code is inherited by the child, and interface inheritance, in which only method names are inherited. **Pros:** Implementation inheritance reduces code size by re-using the base class code as it specializes an existing type. Because inheritance is a compile-time declaration, you and the compiler can understand the operation and detect errors. Interface inheritance can be used to programmatically enforce that a class expose a particular API. Again, the compiler can detect errors, in this case, when a class does not define a necessary method of the API. **Cons:** For implementation inheritance, because the code implementing a sub-class is spread between the base and the sub-class, it can be more difficult to understand an implementation. The sub-class cannot override functions that are not virtual, so the sub-class cannot change implementation. The base class may also define some data members, so that specifies physical layout of the base class. **Decision:** All inheritance should be public. If you want to do private inheritance, you should be including an instance of the base class as a member instead. Do not overuse implementation inheritance. Composition is often more appropriate. Try to restrict use of inheritance to the "is-a" case: Bar subclasses Foo if it can reasonably be said that Bar "is a kind of" Foo. Make your destructor virtual if necessary. If your class has virtual methods, its destructor should be virtual. Limit the use of protected to those member functions that might need to be accessed from subclasses. Note that data members should be private. When redefining an inherited virtual function, explicitly declare it virtual in the declaration of the derived class. Rationale: If virtual is omitted, the reader has to check all ancestors of the class in question to determine if the function is virtual or not. ## Multiple Inheritance Only very rarely is multiple implementation inheritance actually useful. We allow multiple inheritance only when at most one of the base classes has an implementation; all other base classes must be pure interface classes tagged with the Interface suffix. **Definition:** Multiple inheritance allows a sub-class to have more than one base class. We distinguish between base classes that are pure interfaces and those that have an implementation. **Pros:** Multiple implementation inheritance may let you re-use even more code than single inheritance (see Inheritance). **Cons:** Only very rarely is multiple implementation inheritance actually useful. When multiple implementation inheritance seems like the solution, you can usually find a different, more explicit, and cleaner solution. **Decision:** Multiple inheritance is allowed only when all superclasses, with the possible exception of the first one, are pure interfaces. In order to ensure that they remain pure interfaces, they must end with the Interface suffix. Note: There is an exception to this rule on Windows. ## Interfaces Classes that satisfy certain conditions are allowed, but not required, to end with an `Interface` suffix. **Definition:** A class is a pure interface if it meets the following requirements: * It has only public pure virtual ("= 0") methods and static methods (but see below for destructor). * It may not have non-static data members. * It need not have any constructors defined. If a constructor is provided, it must take no arguments and it must be protected. * If it is a subclass, it may only be derived from classes that satisfy these conditions and are tagged with the Interface suffix. An interface class can never be directly instantiated because of the pure virtual method(s) it declares. To make sure all implementations of the interface can be destroyed correctly, the interface must also declare a virtual destructor (in an exception to the first rule, this should not be pure). See Stroustrup, The C++ Programming Language, 3rd edition, section 12.4 for details. **Pros:** Tagging a class with the `Interface` suffix lets others know that they must not add implemented methods or non static data members. This is particularly important in the case of multiple inheritance. Additionally, the interface concept is already well-understood by Java programmers. **Cons:** The `Interface` suffix lengthens the class name, which can make it harder to read and understand. Also, the interface property may be considered an implementation detail that shouldn't be exposed to clients. **Decision:** A class may end with `Interface` only if it meets the above requirements. We do not require the converse, however: classes that meet the above requirements are not required to end with `Interface`. ## Operator Overloading Do not overload operators except in rare, special circumstances. **Definition:** A class can define that operators such as + and / operate on the class as if it were a built-in type. An overload of `operator""` allows the built-in literal syntax to be used to create objects of class types. **Pros:** Operator overloading can make code appear more intuitive because a class will behave in the same way as built-in types (such as int). Overloaded operators are more playful names for functions that are less-colorfully named, such as `Equals()` or `Add()`. For some template functions to work correctly, you may need to define operators. User-defined literals are a very concise notation for creating objects of user-defined types. **Cons:** While operator overloading can make code more intuitive, it has several drawbacks: * It can fool our intuition into thinking that expensive operations are cheap, built-in operations. * It is much harder to find the call sites for overloaded operators. Searching for `equals()` is much easier than searching for relevant invocations of `==`. * Some operators work on pointers too, making it easy to introduce bugs. Foo + 4 may do one thing, while &Foo + 4 does something totally different. The compiler does not complain for either of these, making this very hard to debug. * User-defined literals allow creating new syntactic forms that are unfamiliar even to experienced C++ programmers. Overloading also has surprising ramifications. For instance, if a class overloads unary operator&, it cannot safely be forward-declared. **Decision:** In general, do not overload operators. The assignment operator (`operator=`), in particular, is insidious and should be avoided. You can define functions like `equals()` and `clone()` if you need them. Likewise, avoid the dangerous unary operator& at all costs, if there's any possibility the class might be forward-declared. Do not overload `operator""`, i.e. do not introduce user-defined literals. However, there may be rare cases where you need to overload an operator to interoperate with templates or "standard" C++ classes (such as `operator<< (ostream&, const T&)` for logging). These are acceptable if fully justified, but you should try to avoid these whenever possible. In particular, do not overload `operator==` or `operator<` just so that your class can be used as a key in an STL container; instead, you should create equality and comparison functor types when declaring the container. Some of the STL algorithms do require you to overload `operator==`, and you may do so in these cases, provided you document why. See also Copy Constructors and Function Overloading. ## Access Control Make data members private, and provide access to them through accessor functions as needed (for technical reasons, we allow data members of a test fixture class to be protected when using Google Test). Typically a variable would be called `_foo` and the accessor function `getFoo()` . You may also want a mutator function `setFoo()` . Exception: static const data members (typically called FOO) need not be private. The definitions of accessors are usually inlined in the header file. See also Inheritance and Function Names. ## Declaration Order Use the specified order of declarations within a class: public: before private:, methods before data members (variables), etc. Your class definition should start with its public: section, followed by its protected: section and then its private: section. If any of these sections are empty, omit them. Within each section, the declarations generally should be in the following order: * Typedefs and Enums * Constants (`static const` data members) * Creators (`createXXX` methods) * Constructors * Destructor * Methods, including static methods * overriden methods (must have the `override` keyword as suffix) * Data Members (except `static const` data members) Friend declarations should always be in the private section, and the `DISALLOW_COPY_AND_ASSIGN` macro invocation should be at the end of the private: section. It should be the last thing in the class. See Copy Constructors. Method definitions in the corresponding .cpp file should be the same as the declaration order, as much as possible. Do not put large method definitions inline in the class definition. Usually, only trivial or performance-critical, and very short, methods may be defined inline. See Inline Functions for more details. Example: ```cpp class MyNode : public Node { // public first public: // "creator" methods first static MyNode *create(); static MyNode *createWithParam(const something& arg); // If applicable, then Constructors and the Destructor MyNode(); virtual ~MyNode(); // Then the init methods bool init(); bool initWithParam(const something& arg); // Then methods of the instance void addColor( const Color& color ); void addBackgroundImage( const char* filepath ); // Then the overrides virtual void visit(void) override; virtual void addChild(Node * child, int zOrder, int tag) override; // then protected protected: Point absolutePosition(); // then private private: Point _lastPosition; }; } ``` ## Write Short Functions Prefer small and focused functions. We recognize that long functions are sometimes appropriate, so no hard limit is placed on functions length. If a function exceeds about 40 lines, think about whether it can be broken up without harming the structure of the program. Even if your long function works perfectly now, someone modifying it in a few months may add new behavior. This could result in bugs that are hard to find. Keeping your functions short and simple makes it easier for other people to read and modify your code. You could find long and complicated functions when working with some code. Do not be intimidated by modifying existing code: if working with such a function proves to be difficult, you find that errors are hard to debug, or you want to use a piece of it in several different contexts, consider breaking up the function into smaller and more manageable pieces. # Other C++ Features ## Ownership and Smart Pointers Prefer to have single, fixed owners for dynamically allocated objects. Prefer to transfer ownership with smart pointers. **Definition:** "Ownership" is a bookkeeping technique for managing dynamically allocated memory (and other resources). The owner of a dynamically allocated object is an object or function that is responsible for ensuring that it is deleted when no longer needed. Ownership can sometimes be shared, in which case the last owner is typically responsible for deleting it. Even when ownership is not shared, it can be transferred from one piece of code to another. "Smart" pointers are classes that act like pointers, e.g. by overloading the * and -> operators. Some smart pointer types can be used to automate ownership bookkeeping, to ensure these responsibilities are met. `std::unique_ptr` is a smart pointer type introduced in C++11, which expresses exclusive ownership of a dynamically allocated object; the object is deleted when the `std::unique_ptr` goes out of scope. It cannot be copied, but can be moved to represent ownership transfer. shared_ptr is a smart pointer type which expresses shared ownership of a dynamically allocated object. `shared_ptrs` can be copied; ownership of the object is shared among all copies, and the object is deleted when the last `shared_ptr` is destroyed. **Pros:** * It's virtually impossible to manage dynamically allocated memory without some sort of ownership logic. * Transferring ownership of an object can be cheaper than copying it (if copying it is even possible). * Transferring ownership can be simpler than 'borrowing' a pointer or reference, because it reduces the need to coordinate the lifetime of the object between the two users. * Smart pointers can improve readability by making ownership logic explicit, self-documenting, and unambiguous. * Smart pointers can eliminate manual ownership bookkeeping, simplifying the code and ruling out large classes of errors. * For const objects, shared ownership can be a simple and efficient alternative to deep copying. **Cons:** * Ownership must be represented and transferred via pointers (whether smart or plain). Pointer semantics are more complicated than value semantics, especially in APIs: you have to worry not just about ownership, but also aliasing, lifetime, and mutability, among other issues. * The performance costs of value semantics are often overestimated, so the performance benefits of ownership transfer might not justify the readability and complexity costs. * APIs that transfer ownership force their clients into a single memory management model. * Code using smart pointers is less explicit about where the resource releases take place. * `std::unique_ptr` expresses ownership transfer using C++11's move semantics, which are generally forbidden in Google code, and may confuse some programmers. * Shared ownership can be a tempting alternative to careful ownership design, obfuscating the design of a system. * Shared ownership requires explicit bookkeeping at run-time, which can be costly. * In some cases (e.g. cyclic references), objects with shared ownership may never be deleted. * Smart pointers are not perfect substitutes for plain pointers. **Decision:** If dynamic allocation is necessary, prefer to keep ownership with the code that allocated it. If other code needs access to the object, consider passing it a copy, or passing a pointer or reference without transferring ownership. Prefer to use `std::unique_ptr` to make ownership transfer explicit. For example: ```cpp std::unique_ptr FooFactory(); void FooConsumer(std::unique_ptr ptr); ``` Do not design your code to use shared ownership without a very good reason. One such reason is to avoid expensive copy operations, but you should only do this if the performance benefits are significant, and the underlying object is immutable (i.e. `shared_ptr`). If you do use shared ownership, prefer to use shared_ptr. Do not use `scoped_ptr` in new code unless you need to be compatible with older versions of C++. Never use `linked_ptr` or `std::auto_ptr`. In all three cases, use `std::unique_ptr` instead. ## Reference Arguments All parameters passed by reference must be labeled `const`. **Definition:** In C, if a function needs to modify a variable, the parameter must use a pointer, eg int foo(int *pval). In C++, the function can alternatively declare a reference parameter: int foo(int &val). **Pros:** Defining a parameter as reference avoids ugly code like (*pval)++. Necessary for some applications like copy constructors. Makes it clear, unlike with pointers, that a null pointer is not a possible value. **Cons:** References can be confusing, as they have value syntax but pointer semantics. **Decision:** Within function parameter lists all references must be const: ```cpp void foo(const string &in, string *out); ``` It is a very strong convention that input arguments are values or const references while output arguments are pointers. Input parameters may be const pointers, but we never allow non-const reference parameters except when required by convention, e.g., `swap()` . However, there are some instances where using `const T*` is preferable to `const T&` for input parameters. For example: * You want to pass in a null pointer. * The function saves a pointer or reference to the input. * Passing `const char*` for strings Remember that most of the time input parameters are going to be specified as `const T&` . Using `const T*` instead communicates to the reader that the input is somehow treated differently. So if you choose `const T*` rather than `const T&` , do so for a concrete reason; otherwise it will likely confuse readers by making them look for an explanation that doesn't exist. ## Rvalue references Do not use rvalue references, `std::forward`, `std::move_iterator`, or `std::move_if_noexcept`. Use the single-argument form of `std::move` only with non-copyable arguments. **Definition:** Rvalue references are a type of reference that can only bind to temporary objects. The syntax is similar to traditional reference syntax. For example, void f(string&& s); declares a function whose argument is an rvalue reference to a string. **Pros:** * Defining a move constructor (a constructor taking an rvalue reference to the class type) makes it possible to move a value instead of copying it. If `v1` is a `vector`, for example, then `auto v2(std::move(v1))` will probably just result in some simple pointer manipulation instead of copying a large amount of data. In some cases this can result in a major performance improvement. * Rvalue references make it possible to write a generic function wrapper that forwards its arguments to another function, and works whether or not its arguments are temporary objects. * Rvalue references make it possible to implement types that are moveable but not copyable, which can be useful for types that have no sensible definition of copying but where you might still want to pass them as function arguments, put them in containers, etc. * `std::move` is necessary to make effective use of some standard-library types, such as `std::unique_ptr`. **Cons:** * Rvalue references are a relatively new feature (introduced as part of C++11), and not yet widely understood. Rules like reference collapsing, and automatic synthesis of move constructors, are complicated. * Rvalue references encourage a programming style that makes heavier use of value semantics. This style is unfamiliar to many developers, and its performance characteristics can be hard to reason about. **Decision:** Do not use rvalue references, and do not use the `std::forward` or `std::move_if_noexcept` utility functions (which are essentially just casts to rvalue reference types), or `std::move_iterator`. Use single-argument `std::move` only with objects that are not copyable (e.g. `std::unique_ptr`), or in templated code with objects that might not be copyable. ## Function Overloading Use overloaded functions (including constructors) only if a reader looking at a call site can get a good idea of what is happening without having to first figure out exactly which overload is being called. **Definition:** You may write a function that takes a `const string&` and overload it with another that takes `const char*` . ```cpp class MyClass { public: void analyze(const string &text); void analyze(const char *text, size_t textlen); }; ``` **Pros:** Overloading can make code more intuitive by allowing an identically-named function to take different arguments. It may be necessary for templatized code, and it can be convenient for Visitors. **Cons:** If a function is overloaded by the argument types alone, a reader may have to understand C++'s complex matching rules in order to tell what's going on. Also many people are confused by the semantics of inheritance if a derived class overrides only some of the variants of a function. **Decision:** If you want to overload a function, consider qualifying the name with some information about the arguments, e.g., `appendString()` , `appendInt()` rather than just `append()` . ## Default Arguments We do not allow default function parameters, except in limited situations as explained below. Simulate them with function overloading instead, if appropriate. **Pros:** Often you have a function that uses default values, but occasionally you want to override the defaults. Default parameters allow an easy way to do this without having to define many functions for the rare exceptions. Compared to overloading the function, default arguments have a cleaner syntax, with less boilerplate and a clearer distinction between 'required' and 'optional' arguments. **Cons:** Function pointers are confusing in the presence of default arguments, since the function signature often doesn't match the call signature. Adding a default argument to an existing function changes its type, which can cause problems with code taking its address. Adding function overloads avoids these problems. In addition, default parameters may result in bulkier code since they are replicated at every call-site -- as opposed to overloaded functions, where "the default" appears only in the function definition. **Decision:** While the cons above are not that onerous, they still outweigh the (small) benefits of default arguments over function overloading. So except as described below, we require all arguments to be explicitly specified. One specific exception is when the function is a static function (or in an unnamed namespace) in a .cpp file. In this case, the cons don't apply since the function's use is so localized. In particular, the `createXXX` and `initXXX` methods in cocos2dx are allowed to use default arguments. Another specific exception is when default arguments are used to simulate variable-length argument lists. Example: ```cpp // Support up to 4 params by using a default empty AlphaNum. string strCat(const AlphaNum &a, const AlphaNum &b = gEmptyAlphaNum, const AlphaNum &c = gEmptyAlphaNum, const AlphaNum &d = gEmptyAlphaNum); ``` ## Variable-Length Arrays and alloca() We do not allow variable-length arrays or alloca(). **Pros:** Variable-length arrays have natural-looking syntax. Both variable-length arrays and alloca() are very efficient. **Cons:** Variable-length arrays and alloca are not part of Standard C++. More importantly, they allocate a data-dependent amount of stack space that can trigger difficult-to-find memory overwriting bugs: "It ran fine on my machine, but dies mysteriously in production". **Decision:** Use a safe allocator instead, such as scoped_ptr/scoped_array. ## Friends We allow use of friend classes and functions, within reason. Friends should usually be defined in the same file so that the reader does not have to look in another file to find uses of the private members of a class. A common use of friend is to have a FooBuilder class be a friend of Foo so that it can construct the inner state of Foo correctly, without exposing this state to the world. In some cases it may be useful to make a unittest class a friend of the class it tests. Friends extend, but do not break, the encapsulation boundary of a class. In some cases this is better than making a member public when you want to give only one other class access to it. However, most classes should interact with other classes solely through their public members. ## Exceptions We do not use C++ exceptions. **Pros:** * Exceptions allow higher levels of an application to decide how to handle "can't happen" failures in deeply nested functions, without the obscuring and error-prone bookkeeping of error codes. * Exceptions are used by most other modern languages. Using them in C++ would make it more consistent with Python, Java, and the C++ that others are familiar with. * Some third-party C++ libraries use exceptions, and turning them off internally makes it harder to integrate with those libraries. * Exceptions are the only way for a constructor to fail. We can simulate this with a factory function or an `init()` method, but these require heap allocation or a new "invalid" state, respectively. * Exceptions are really handy in testing frameworks. **Cons:** * When you add a throw statement to an existing function, you must examine all of its transitive callers. Either they must make at least the basic exception safety guarantee, or they must never catch the exception and be happy with the program terminating as a result. For instance, if f() calls g() calls h(), and h throws an exception that f catches, g has to be careful or it may not clean up properly. * More generally, exceptions make the control flow of programs difficult to evaluate by looking at code: functions may return in places you don't expect. This causes maintainability and debugging difficulties. You can minimize this cost via some rules on how and where exceptions can be used, but at the cost of more that a developer needs to know and understand. * Exception safety requires both RAII and different coding practices. Lots of supporting machinery is needed to make writing correct exception-safe code easy. Further, to avoid requiring readers to understand the entire call graph, exception-safe code must isolate logic that writes to persistent state into a "commit" phase. This will have both benefits and costs (perhaps where you're forced to obfuscate code to isolate the commit). Allowing exceptions would force us to always pay those costs even when they're not worth it. * Turning on exceptions adds data to each binary produced, increasing compile time (probably slightly) and possibly increasing address space pressure. * The availability of exceptions may encourage developers to throw them when they are not appropriate or recover from them when it's not safe to do so. For example, invalid user input should not cause exceptions to be thrown. We would need to make the style guide even longer to document these restrictions! **Decision:** On their face, the benefits of using exceptions outweigh the costs, especially in new projects. However, for existing code, the introduction of exceptions has implications on all dependent code. If exceptions can be propagated beyond a new project, it also becomes problematic to integrate the new project into existing exception-free code. Because most existing C++ code at Google is not prepared to deal with exceptions, it is comparatively difficult to adopt new code that generates exceptions. Given that Google's existing code is not exception-tolerant, the costs of using exceptions are somewhat greater than the costs in a new project. The conversion process would be slow and error-prone. We don't believe that the available alternatives to exceptions, such as error codes and assertions, introduce a significant burden. Our advice against using exceptions is not predicated on philosophical or moral grounds, but practical ones. Because we'd like to use our open-source projects at Google and it's difficult to do so if those projects use exceptions, we need to advise against exceptions in Google open-source projects as well. Things would probably be different if we had to do it all over again from scratch. This prohibition also applies to the exception-related features added in C++11, such as noexcept, `std::exception_ptr`, and `std::nested_exception`. There is an exception to this rule (no pun intended) for Windows code. ## Run-Time Type Information (RTTI) cocos2dx requires Run Time Type Information (RTTI) in order to compile and run. That being said, you should be careful and not abuse the RTTI features. **Definition:** RTTI allows a programmer to query the C++ class of an object at run time. This is done by use of typeid or dynamic_cast. **Cons:** Querying the type of an object at run-time frequently means a design problem. Needing to know the type of an object at runtime is often an indication that the design of your class hierarchy is flawed. Undisciplined use of RTTI makes code hard to maintain. It can lead to type-based decision trees or switch statements scattered throughout the code, all of which must be examined when making further changes. **Pros:** The standard alternatives to RTTI (described below) require modification or redesign of the class hierarchy in question. Sometimes such modifications are infeasible or undesirable, particularly in widely-used or mature code. RTTI can be useful in some unit tests. For example, it is useful in tests of factory classes where the test has to verify that a newly created object has the expected dynamic type. It is also useful in managing the relationship between objects and their mocks. RTTI is useful when considering multiple abstract objects. Consider ```cpp bool Base::equal(Base* other) = 0; bool Derived::equal(Base* other) { Derived* that = dynamic_cast(other); if (that == NULL) return false; ... } ``` **Decision:** RTTI has legitimate uses but is prone to abuse, so you must be careful when using it. You may use it freely in unittests, but avoid it when possible in other code. In particular, think twice before using RTTI in new code. If you find yourself needing to write code that behaves differently based on the class of an object, consider one of the following alternatives to querying the type: * Virtual methods are the preferred way of executing different code paths depending on a specific subclass type. This puts the work within the object itself. * If the work belongs outside the object and instead in some processing code, consider a double-dispatch solution, such as the Visitor design pattern. This allows a facility outside the object itself to determine the type of class using the built-in type system. When the logic of a program guarantees that a given instance of a base class is in fact an instance of a particular derived class, then a `dynamic_cast` may be used freely on the object. Usually one can use a `static_cast` as an alternative in such situations. Decision trees based on type are a strong indication that your code is on the wrong track. ```cpp if (typeid(*data) == typeid(D1)) { ... } else if (typeid(*data) == typeid(D2)) { ... } else if (typeid(*data) == typeid(D3)) { ... ``` Code such as this usually breaks when additional subclasses are added to the class hierarchy. Moreover, when properties of a subclass change, it is difficult to find and modify all the affected code segments. Do not hand-implement an RTTI-like workaround. The arguments against RTTI apply just as much to workarounds like class hierarchies with type tags. Moreover, workarounds disguise your true intent. ## Casting Use C++ casts like `static_cast<>()`. Do not use other cast formats like `int y = (int)x; or int y = int(x);`. **Definition:** C++ introduced a different cast system from C that distinguishes the types of cast operations. **Pros:** The problem with C casts is the ambiguity of the operation; sometimes you are doing a conversion (e.g., (int)3.5) and sometimes you are doing a cast (e.g., (int)"hello"); C++ casts avoid this. Additionally C++ casts are more visible when searching for them. **Cons:** The syntax is nasty. **Decision:** Do not use C-style casts. Instead, use these C++-style casts. * Use `static_cast` as the equivalent of a C-style cast that does value conversion, or when you need to explicitly up-cast a pointer from a class to its superclass. * Use `const_cast` to remove the const qualifier (see const). * Use `reinterpret_cast` to do unsafe conversions of pointer types to and from integer and other pointer types. Use this only if you know what you are doing and you understand the aliasing issues. See the RTTI section for guidance on the use of dynamic_cast. ## Streams Use streams only for logging. **Definition:** Streams are a replacement for printf() and scanf(). **Pros:** With streams, you do not need to know the type of the object you are printing. You do not have problems with format strings not matching the argument list. (Though with gcc, you do not have that problem with printf either.) Streams have automatic constructors and destructors that open and close the relevant files. **Cons:** Streams make it difficult to do functionality like pread(). Some formatting (particularly the common format string idiom %.*s) is difficult if not impossible to do efficiently using streams without using printf-like hacks. Streams do not support operator reordering (the %1s directive), which is helpful for internationalization. **Decision:** Do not use streams, except where required by a logging interface. Use printf-like routines instead. There are various pros and cons to using streams, but in this case, as in many other cases, consistency trumps the debate. Do not use streams in your code. **Extended Discussion** There has been debate on this issue, so this explains the reasoning in greater depth. Recall the Only One Way guiding principle: we want to make sure that whenever we do a certain type of I/O, the code looks the same in all those places. Because of this, we do not want to allow users to decide between using streams or using printf plus Read/Write/etc. Instead, we should settle on one or the other. We made an exception for logging because it is a pretty specialized application, and for historical reasons. Proponents of streams have argued that streams are the obvious choice of the two, but the issue is not actually so clear. For every advantage of streams they point out, there is an equivalent disadvantage. The biggest advantage is that you do not need to know the type of the object to be printing. This is a fair point. But, there is a downside: you can easily use the wrong type, and the compiler will not warn you. It is easy to make this kind of mistake without knowing when using streams. ```cpp cout << this; // Prints the address cout << *this; // Prints the contents ``` The compiler does not generate an error because << has been overloaded. We discourage overloading for just this reason. Some say `printf` formatting is ugly and hard to read, but streams are often no better. Consider the following two fragments, both with the same typo. Which is easier to discover? ```cpp cerr << "Error connecting to '" << foo->bar()->hostname.first << ":" << foo->bar()->hostname.second << ": " << strerror(errno); fprintf(stderr, "Error connecting to '%s:%u: %s", foo->bar()->hostname.first, foo->bar()->hostname.second, strerror(errno)); ``` And so on and so forth for any issue you might bring up. (You could argue, "Things would be better with the right wrappers," but if it is true for one scheme, is it not also true for the other? Also, remember the goal is to make the language smaller, not add yet more machinery that someone has to learn.) Either path would yield different advantages and disadvantages, and there is not a clearly superior solution. The simplicity doctrine mandates we settle on one of them though, and the majority decision was on printf + read/write. ## Preincrement and Predecrement Use prefix form (++i) of the increment and decrement operators with iterators and other template objects. **Definition:** When a variable is incremented (++i or i++) or decremented (--i or i--) and the value of the expression is not used, one must decide whether to preincrement (decrement) or postincrement (decrement). **Pros:** When the return value is ignored, the "pre" form (++i) is never less efficient than the "post" form (i++), and is often more efficient. This is because post-increment (or decrement) requires a copy of i to be made, which is the value of the expression. If i is an iterator or other non-scalar type, copying i could be expensive. Since the two types of increment behave the same when the value is ignored, why not just always pre-increment? **Cons:** The tradition developed, in C, of using post-increment when the expression value is not used, especially in for loops. Some find post-increment easier to read, since the "subject" (i) precedes the "verb" (++), just like in English. **Decision:** For simple scalar (non-object) values there is no reason to prefer one form and we allow either. For iterators and other template types, use pre-increment. ## Use of const Use `const` whenever it makes sense. With C++11, `constexpr` is a better choice for some uses of `const`. **Definition:** Declared variables and parameters can be preceded by the keyword const to indicate the variables are not changed (e.g., `const int foo`). Class functions can have the `const` qualifier to indicate the function does not change the state of the class member variables (e.g., `class Foo { int Bar(char c) const; };`). **Pros:** Easier for people to understand how variables are being used. Allows the compiler to do better type checking, and, conceivably, generate better code. Helps people convince themselves of program correctness because they know the functions they call are limited in how they can modify your variables. Helps people know what functions are safe to use without locks in multi-threaded programs. **Cons:** `const` is viral: if you pass a const variable to a function, that function must have `const` in its prototype (or the variable will need a `const_cast`). This can be a particular problem when calling library functions. **Decision:** `const` variables, data members, methods and arguments add a level of compile-time type checking; it is better to detect errors as soon as possible. Therefore we strongly recommend that you use `const` whenever it makes sense to do so: * If a function does not modify an argument passed by reference or by pointer, that argument should be `const`. * Declare methods to be `const` whenever possible. Accessors should almost always be `const`. Other methods should be `const` if they do not modify any data members, do not call any non-const methods, and do not return a non-const pointer or non-const reference to a data member. * Consider making data members `const` whenever they do not need to be modified after construction. The `mutable` keyword is allowed but is unsafe when used with threads, so thread safety should be carefully considered first. ** Where to put the `const` ** Some people favor the form `int const *foo` to `const int* foo`. They argue that this is more readable because it's more consistent: it keeps the rule that `const` always follows the object it's describing. However, this consistency argument doesn't apply in codebases with few deeply-nested pointer expressions since most `const` expressions have only one `const`, and it applies to the underlying value. In such cases, there's no consistency to maintain. Putting the `const` first is arguably more readable, since it follows English in putting the "adjective" (const) before the "noun" (int). That said, while we encourage putting `const` first, we do not require it. But be consistent with the code around you! ## Use of constexpr In C++11, use `constexpr` to define true constants or to ensure constant initialization. **Definition:** Some variables can be declared `constexpr` to indicate the variables are true constants, i.e. fixed at compilation/link time. Some functions and constructors can be declared constexpr which enables them to be used in defining a constexpr variable. **Pros:** Use of `constexpr` enables definition of constants with floating-point expressions rather than just literals; definition of constants of user-defined types; and definition of constants with function calls. **Cons:** Prematurely marking something as constexpr may cause migration problems if later on it has to be downgraded. Current restrictions on what is allowed in constexpr functions and constructors may invite obscure workarounds in these definitions. **Decision:** `constexpr` definitions enable a more robust specification of the constant parts of an interface. Use `constexpr` to specify true constants and the functions that support their definitions. Avoid complexifying function definitions to enable their use with constexpr. Do not use constexpr to force inlining. ## Use of constexpr In C++11, use `constexpr` to define true constants or to ensure constant initialization. **Definition:** Some variables can be declared constexpr to indicate the variables are true constants, i.e. fixed at compilation/link time. Some functions and constructors can be declared constexpr which enables them to be used in defining a constexpr variable. **Pros:** Use of constexpr enables definition of constants with floating-point expressions rather than just literals; definition of constants of user-defined types; and definition of constants with function calls. **Cons:** Prematurely marking something as `constexpr` may cause migration problems if later on it has to be downgraded. Current restrictions on what is allowed in constexpr functions and constructors may invite obscure workarounds in these definitions. **Decision:** `constexpr` definitions enable a more robust specification of the constant parts of an interface. Use constexpr to specify true constants and the functions that support their definitions. Avoid complexifying function definitions to enable their use with constexpr. Do not use constexpr to force inlining. ## Integer Types Of the built-in C++ integer types, the only one used is `int`. If a program needs a variable of a different size, use a precise-width integer type from ``, such as `int16_t`. If your variable represents a value that could ever be greater than or equal to 2^31 (2GiB), use a 64-bit type such as `int64_t`. Keep in mind that even if your value won't ever be too large for an `int`, it may be used in intermediate calculations which may require a larger type. When in doubt, choose a larger type. **Definition:** C++ does not specify the sizes of its integer types. Typically people assume that `short` is 16 bits, `int` is 32 bits, `long` is 32 bits and `long long` is 64 bits. **Pros:** Uniformity of declaration. **Cons:** The sizes of integral types in C++ can vary based on compiler and architecture. **Decision:** `` defines types like `int16_t` , `uint32_t` , `int64_t` , etc. You should always use those in preference to `short`, `unsigned long long` and the like, when you need a guarantee on the size of an integer. Of the C integer types, only int should be used. When appropriate, you are welcome to use standard types like `size_t` and `ptrdiff_t` . We use `int` very often, for integers we know are not going to be too big, e.g., loop counters. Use plain old `int` for such things. You should assume that an `int` is at least 32 bits, but don't assume that it has more than 32 bits. If you need a 64-bit integer type, use `int64_t` or `uint64_t` . For integers we know can be "big", use `int64_t` . You should not use the unsigned integer types such as `uint32_t`, unless there is a valid reason such as representing a bit pattern rather than a number, or you need defined overflow modulo 2^N. In particular, do not use unsigned types to say a number will never be negative. Instead, use assertions for this. If your code is a container that returns a size, be sure to use a type that will accommodate any possible usage of your container. When in doubt, use a larger type rather than a smaller type. Use care when converting integer types. Integer conversions and promotions can cause non-intuitive behavior. ### On Unsigned Integers Some people, including some textbook authors, recommend using unsigned types to represent numbers that are never negative. This is intended as a form of self-documentation. However, in C, the advantages of such documentation are outweighed by the real bugs it can introduce. Consider: ```cpp // buggy code for (unsigned int i = foo.Length()-1; i >= 0; --i) ... ``` This code will never terminate! Sometimes gcc will notice this bug and warn you, but often it will not. Equally bad bugs can occur when comparing signed and unsigned variables. Basically, C's type-promotion scheme causes unsigned types to behave differently than one might expect. So, document that a variable is non-negative using assertions. Don't use an unsigned type. ## 64-bit Portability Code should be 64-bit and 32-bit friendly. Bear in mind problems of printing, comparisons, and structure alignment. * `printf()` specifiers for some types are not cleanly portable between 32-bit and 64-bit systems. C99 defines some portable format specifiers. Unfortunately, MSVC 7.1 does not understand some of these specifiers and the standard is missing a few, so we have to define our own ugly versions in some cases (in the style of the standard include file inttypes.h): ```cpp // printf macros for size_t, in the style of inttypes.h #ifdef _LP64 #define __PRIS_PREFIX "z" #else #define __PRIS_PREFIX #endif // Use these macros after a % in a printf format string // to get correct 32/64 bit behavior, like this: // size_t size = records.size(); // printf("%"PRIuS"\n", size); #define PRIdS __PRIS_PREFIX "d" #define PRIxS __PRIS_PREFIX "x" #define PRIuS __PRIS_PREFIX "u" #define PRIXS __PRIS_PREFIX "X" #define PRIoS __PRIS_PREFIX "o" ``` * For `void *` (or any pointer) DO NOT USE `%lx`. Instead USE `%p` * For `int64_t` DO NOT USE `%qd, %lld`. Instead USE `%"PRId64"` * For `uint64_t` DO NOT USE `%qu, %llu, %llx`. Instead USE `%"PRIu64", %"PRIx64"` * For `size_t` DO NOT USE `%u`. Instead USE `%"PRIuS", %"PRIxS`. C99 specifies `%zu` * For `ptrdiff_t` DO NOT USE `%d`. Instead USE `%"PRIdS"`. C99 specifies `%td` Note that the `PRI*` macros expand to independent strings which are concatenated by the compiler. Hence if you are using a non-constant format string, you need to insert the value of the macro into the format, rather than the name. It is still possible, as usual, to include length specifiers, etc., after the % when using the PRI* macros. So, e.g. `printf("x = %30"PRIuS"\n", x)` would expand on 32-bit Linux to `printf("x = %30" "u" "\n", x)`, which the compiler will treat as `printf("x = %30u\n", x)`. * Remember that `sizeof(void *) != sizeof(int)`. Use `intptr_t` if you want a pointer-sized integer. * You may need to be careful with structure alignments, particularly for structures being stored on disk. Any class/structure with a int64_t/uint64_t member will by default end up being 8-byte aligned on a 64-bit system. If you have such structures being shared on disk between 32-bit and 64-bit code, you will need to ensure that they are packed the same on both architectures. Most compilers offer a way to alter structure alignment. For gcc, you can use `__attribute__((packed))`. MSVC offers `#pragma pack()` and `__declspec(align())`. * Use the `LL` or `ULL` suffixes as needed to create 64-bit constants. For example: ```cpp int64_t my_value = 0x123456789LL; uint64_t my_mask = 3ULL << 48; ``` If you really need different code on 32-bit and 64-bit systems, use #ifdef _LP64 to choose between the code variants. (But please avoid this if possible, and keep any such changes localized.) ## Preprocessor Macros Be very cautious with macros. Prefer inline functions, enums, and const variables to macros. Macros mean that the code you see is not the same as the code the compiler sees. This can introduce unexpected behavior, especially since macros have global scope. Luckily, macros are not nearly as necessary in C++ as they are in C. Instead of using a macro to inline performance-critical code, use an inline function. Instead of using a macro to store a constant, use a const variable. Instead of using a macro to "abbreviate" a long variable name, use a reference. Instead of using a macro to conditionally compile code ... well, don't do that at all (except, of course, for the #define guards to prevent double inclusion of header files). It makes testing much more difficult. Macros can do things these other techniques cannot, and you do see them in the codebase, especially in the lower-level libraries. And some of their special features (like stringifying, concatenation, and so forth) are not available through the language proper. But before using a macro, consider carefully whether there's a non-macro way to achieve the same result. The following usage pattern will avoid many problems with macros; if you use macros, follow it whenever possible: * Don't define macros in a .h file. * `#define` macros right before you use them, and `#undef` them right after. * Do not just #undef an existing macro before replacing it with your own; instead, pick a name that's likely to be unique. * Try not to use macros that expand to unbalanced C++ constructs, or at least document that behavior well. * Prefer not using ## to generate function/class/variable names. ## 0 and nullptr/NULL Use 0 for integers, 0.0 for reals, nullptr (or NULL) for pointers, and '\0' for chars. Use 0 for integers and 0.0 for reals. This is not controversial. For pointers (address values), there is a choice between `0`, `NULL`, and `nullptr`. For projects that allow C++11 features, use `nullptr`. For C++03 projects, we prefer `NULL` because it looks like a pointer. In fact, some C++ compilers provide special definitions of `NULL` which enable them to give useful warnings, particularly in situations where `sizeof(NULL)` is not equal to `sizeof(0)`. Use `'\0'` for chars. This is the correct type and also makes code more readable. ## sizeof Prefer `sizeof(varname)` to `sizeof(type)`. Use `sizeof(varname)` when you take the size of a particular variable. `sizeof(varname)` will update appropriately if someone changes the variable type either now or later. You may use `sizeof(type)` for code unrelated to any particular variable, such as code that manages an external or internal data format where a variable of an appropriate C++ type is not convenient. ```cpp Struct data; memset(&data, 0, sizeof(data)); // GOOD memset(&data, 0, sizeof(Struct)); // BAD if (raw_size < sizeof(int)) { LOG(ERROR) << "compressed record not big enough for count: " << raw_size; return false; } ``` ## auto Use `auto` to avoid type names that are just clutter. Continue to use manifest type declarations when it helps readability, and never use `auto` for anything but local variables. **Definition:** In C++11, a variable whose type is given as `auto` will be given a type that matches that of the expression used to initialize it. You can use `auto` either to initialize a variable by copying, or to bind a reference. ```cpp vector v; ... auto s1 = v[0]; // Makes a copy of v[0]. const auto& s2 = v[0]; // s2 is a reference to v[0]. ``` **Pros:** C++ type names can sometimes be long and cumbersome, especially when they involve templates or namespaces. In a statement like ```cpp sparse_hash_map::iterator iter = m.find(val); ``` the return type is hard to read, and obscures the primary purpose of the statement. Changing it to ```cpp auto iter = m.find(val); ``` makes it more readable. Without `auto` we are sometimes forced to write a type name twice in the same expression, adding no value for the reader, as in ```cpp diagnostics::ErrorStatus* status = new diagnostics::ErrorStatus("xyz"); ``` Using `auto` makes it easier to use intermediate variables when appropriate, by reducing the burden of writing their types explicitly. **Cons:** Sometimes code is clearer when types are manifest, especially when a variable's initialization depends on things that were declared far away. In an expression like ```cpp auto i = x.Lookup(key); ``` it may not be obvious what i's type is, if x was declared hundreds of lines earlier. Programmers have to understand the difference between `auto` and `const auto&` or they'll get copies when they didn't mean to. The interaction between auto and C++11 brace-initialization can be confusing. The declarations ```cpp auto x(3); // Note: parentheses. auto y{3}; // Note: curly braces. ``` mean different things — x is an int, while y is an initializer_list. The same applies to other normally-invisible proxy types. If an `auto` variable is used as part of an interface, e.g. as a constant in a header, then a programmer might change its type while only intending to change its value, leading to a more radical API change than intended. **Decision:** `auto` is permitted, for local variables only. Do not use `auto` for file-scope or namespace-scope variables, or for class members. Never assign a braced initializer list to an auto-typed variable. The `auto` keyword is also used in an unrelated C++11 feature: it's part of the syntax for a new kind of function declaration with a trailing return type. Function declarations with trailing return types are not permitted. ## Brace Initialization You may use brace initialization. In C++03, aggregate types (arrays and structs with no constructor) could be initialized using braces. ```cpp struct Point { int x; int y; }; Point p = {1, 2}; ``` In C++11, this syntax has been expanded for use with all other datatypes. The brace initialization form is called braced-init-list. Here are a few examples of its use. ```cpp // Vector takes lists of elements. vector v{"foo", "bar"}; // The same, except this form cannot be used if the initializer_list // constructor is explicit. You may choose to use either form. vector v = {"foo", "bar"}; // Maps take lists of pairs. Nested braced-init-lists work. map m = {{1, "one"}, {2, "2"}}; // braced-init-lists can be implicitly converted to return types. vector testFunction() { return {1, 2, 3}; } // Iterate over a braced-init-list. for (int i : {-1, -2, -3}) {} // Call a function using a braced-init-list. void testFunction2(vector v) {} testFunction2({1, 2, 3}); ``` User data types can also define constructors that take initializer_list, which is automatically created from braced-init-list: ```cpp class MyType { public: // initializer_list is a reference to the underlying init list, // so it can be passed by value. MyType(initializer_list init_list) { for (int element : init_list) {} } }; MyType m{2, 3, 5, 7}; ``` Finally, brace initialization can also call ordinary constructors of data types that do not have initializer_list constructors. ```cpp double d{1.23}; // Calls ordinary constructor as long as MyOtherType has no // initializer_list constructor. class MyOtherType { public: explicit MyOtherType(string); MyOtherType(int, string); }; MyOtherType m = {1, "b"}; // If the constructor is explicit, you can't use the "= {}" form. MyOtherType m{"b"}; ``` Never assign a braced-init-list to an auto local variable. In the single element case, what this means can be confusing. ```cpp auto d = {1.23}; // d is an initializer_list auto d = double{1.23}; // Good -- d is a double, not an initializer_list. ``` ## Lambda expressions Use lambda expressions, or the related `std::function` or `std::bind` utilities only in special places like cocos2d callbacks. **Definition:** Lambda expressions are a concise way of creating anonymous function objects. They're often useful when passing functions as arguments. For example: `std::sort(v.begin(), v.end(), [](string x, string y) { return x[1] < y[1]; });` Lambdas were introduced in C++11 along with a set of utilities for working with function objects, such as the polymorphic wrapper `std::function`. **Pros:** * Lambdas are much more concise than other ways of defining function objects to be passed to STL algorithms, which can be a readability improvement. * Lambdas, `std::function`, and `std::bind` can be used in combination as a general purpose callback mechanism; they make it easy to write functions that take bound functions as arguments. **Cons:** * Variable capture in lambdas can be tricky, and might be a new source of dangling-pointer bugs. * It's possible for use of lambdas to get out of hand; very long nested anonymous functions can make code harder to understand. Decision: Use lambda expressions, or the related `std::function` or `std::bind` utilities only in special places like cocos2d callbacks. ## Boost Do not use boost. **Definition:** The Boost library collection is a popular collection of peer-reviewed, free, open-source C++ libraries. **Pros:** Boost code is generally very high-quality, is widely portable, and fills many important gaps in the C++ standard library, such as type traits, better binders, and better smart pointers. It also provides an implementation of the TR1 extension to the standard library. **Cons:** Some Boost libraries encourage coding practices which can hamper readability, such as metaprogramming and other advanced template techniques, and an excessively "functional" style of programming. It also adds more dependencies in cocos2d-x. **Decision:** In order to maintain a high level of readability for all contributors who might read and maintain code, and also in order to keep the dependencies as minimal as possible, we do not use Boost. ## C++11 Use libraries and language extensions from C++11 (formerly known as C++0x) when appropriate. Consider portability to other environments before using C++11 features in your project. **Definition:** C++11 is the latest ISO C++ standard. It contains significant changes both to the language and libraries. **Pros:** C++11 has become the official standard, and eventually will be supported by most C++ compilers. It standardizes some common C++ extensions that we use already, allows shorthands for some operations, and has some performance and safety improvements. **Cons:** The C++11 standard is substantially more complex than its predecessor (1,300 pages versus 800 pages), and is unfamiliar to many developers. The long-term effects of some features on code readability and maintenance are unknown. We cannot predict when its various features will be implemented uniformly by tools that may be of interest, particularly in the case of projects that are forced to use older versions of tools. As with Boost, some C++11 extensions encourage coding practices that hamper readability—for example by removing checked redundancy (such as type names) that may be helpful to readers, or by encouraging template metaprogramming. Other extensions duplicate functionality available through existing mechanisms, which may lead to confusion and conversion costs. **Decision:** C++11 features may be used unless specified otherwise. In addition to what's described in the rest of the style guide, the following C++11 features may not be used: * Functions with trailing return types, e.g. writing `auto foo() -> int;` instead of `int foo();`, because of a desire to preserve stylistic consistency with the many existing function declarations. * Compile-time rational numbers (``), because of concerns that it's tied to a more template-heavy interface style. * The `` and `` headers, because many compilers do not support those features reliably. Additionaly, any C++11 features that is used, must work on the following compilers: * Xcode 5.0.2 or newer * gcc 4.8 or newer * VS 2012 or newer ## General Naming Rules Function names, variable names, and filenames should be descriptive; eschew abbreviation. Give as descriptive a name as possible, within reason. Do not worry about saving horizontal space as it is far more important to make your code immediately understandable by a new reader. Do not use abbreviations that are ambiguous or unfamiliar to readers outside your project, and do not abbreviate by deleting letters within a word. ```cpp // OK int priceCountReader; // No abbreviation. int numErrors; // "num" is a widespread convention. int numDNSConnections; // Most people know what "DNS" stands for. ``` ```cpp // BAD int n; // Meaningless. int nerr; // Ambiguous abbreviation. int nCompConns; // Ambiguous abbreviation. int wgcConnections; // Only your group knows what this stands for. int pcReader; // Lots of things can be abbreviated "pc". int cstmrId; // Deletes internal letters. ``` ## File Names Filenames should be all in CamelCasel, and for cocos2d specific files, they should start with the `CC` prefix as well. Examples of acceptable file names: CCSprite.cpp CCTextureCache.cpp CCTexture2D.cpp C++ files should end in `.cpp` and header files should end in `.h`. Do not use filenames that already exist in /usr/include, such as db.h. In general, make your filenames very specific. For example, use `CCTexture2D.h` rather than `Texture.h`. A very common case is to have a pair of files called, e.g., `FooBar.h` and `FooBar.cpp` , defining a class called `FooBar` . Inline functions must be in a `.h` file. If your inline functions are very short, they should go directly into your .h file. However, if your inline functions include a lot of code, they may go into a third file that ends in `-inl.h` . In a class with a lot of inline code, your class could have three files: ```cpp UrlTable.h // The class declaration. UrlTable.cpp // The class definition. UrlTable-inl.h // Inline functions that include lots of code. ``` See also the section -inl.h Files ## Type Names Type names start with a capital letter and have a capital letter for each new word, with no underscores: `MyExcitingClass`, `MyExcitingEnum`. The names of all types — classes, structs, typedefs, and enums — have the same naming convention. Type names should start with a capital letter and have a capital letter for each new word. No underscores. For example: ```cpp // classes and structs class UrlTable { ... class UrlTableTester { ... struct UrlTableProperties { ... // typedefs typedef hash_map PropertiesMap; // enums enum UrlTableErrors { ... ``` ## Variable Names Variable names are all camelCase (they start with lowercase). Class member variables have an underscore as prefix. For instance: `myExcitingLocalVariable` , `_myExcitingLocalVariable` . All lowercase variables are accepted as well. ### Common Variable names For example: ```cpp string tableName; // OK - uses camelcase string tablename; // OK - all lowercase. string table_name; // Bad - uses underscore. string TableNname; // Bad - starts with Uppercase ``` ### Class Data Members Data members (also called instance variables or member variables) are lowercase with optional underscores like regular variable names, but always end with a trailing underscore. ```cpp string _tableName; // OK string _tablename; // OK ``` ### Struct Variables Data members in structs should be named like regular variables without the underscores as prefix that data members in classes have. ```cpp struct UrlTableProperties { string name; int numEntries; } ``` See Structs vs. Classes for a discussion of when to use a struct versus a class. ### Global Variables There are no special requirements for global variables, which should be rare in any case, but if you use one, consider prefixing it with `g_` or some other marker to easily distinguish it from local variables. ## Constant Names Constant names should all be in UPPERCASE with underscores to separate the words. Do not use `#define` for consts. Prefer strongly typed enums over `const` variables, whenever it makes sense. All compile-time constants, whether they are declared locally, globally, or as part of a class, follow a slightly different naming convention from other variables. They should be declared in UPPERCASE and use underscore to separate the different words: ```cpp const int MENU_DEFAULT_VALUE = 10; const float GRAVITY = -9.8; enum class Projection { ORTHOGONAL, PERSPECTIVE }; enum class PixelFormat { RGBA_8888, RGBA_4444, RGBA_5551, RGB_565, }; ``` ## Function Names Regular functions have mixed case; accessors and mutators match the name of the variable: `myExcitingFunction()`, `myExcitingMethod()`, `getMyExcitingMemberVariable()`, `setMyExcitingMemberVariable`. ### Regular Functions Functions should start with lowercase and have a capital letter for each new word. No underscores. If your function crashes upon an error, you should append OrDie to the function name. This only applies to functions which could be used by production code and to errors that are reasonably likely to occur during normal operation. ```cpp addTableEntry() deleteUrl() openFileOrDie() ``` ### Accessors and Mutators Accessors and mutators ( `get` and `set` functions) should match the name of the variable they are getting and setting. This shows an excerpt of a class whose instance variable is `_numEntries` . ```cpp class MyClass { public: ... int getNumEntries() const { return _numEntries; } void setNumEntries(int numEntries) { _numEntries = numEntries; } private: int _numEntries; }; ``` ## Namespace Names Namespace names are all lower-case, and based on project names and possibly their directory structure: google_awesome_project. See Namespaces for a discussion of namespaces and how to name them. ## Enumerator Names Enumerators should be named either like constants: `ENUM_NAME`. Prefer strongly typed enums over non-strongly typed enums. ```cpp enum class UrlTableErrors { OK = 0, ERROR_OUT_OF_MEMORY, ERROR_MALFORMED_INPUT, }; ``` ## Macro Names You're not really going to define a macro, are you? If you do, they're like this: CC_MY_MACRO_THAT_SCARES_SMALL_CHILDREN. Please see the description of macros; in general macros should not be used. However, if they are absolutely needed, then they should be named with all capitals and underscores, and they should be prefixed with `CC_` or `CC` ```cpp #define CC_ROUND(x) ... #define CC_PI_ROUNDED 3.0 #define CCLOG(x) ... ``` ## Exceptions to Naming Rules If you are naming something that is analogous to an existing C or C++ entity then you can follow the existing naming convention scheme. ### `bigopen()` function name, follows form of open() ### `uint` typedef ### `bigpos` struct or class, follows form of pos ### `sparse_hash_map` STL-like entity; follows STL naming conventions ### `LONGLONG_MAX` a constant, as in INT_MAX # Comments Though a pain to write, comments are absolutely vital to keeping our code readable. The following rules describe what you should comment and where. But remember: while comments are very important, the best code is self-documenting. Giving sensible names to types and variables is much better than using obscure names that you must then explain through comments. When writing your comments, write for your audience: the next contributor who will need to understand your code. Be generous — the next one may be you! ## Doxygen * Use Doxygen strings in the header files. Doxygen comments on the implementation file are not required. * All public `class` objects MUST have a Doxygen comment that explains what it does. * All `public` methods of the class, with the exception of overridden methods, MUST be documented using Doxygen comments. * `protected` and `private` methods are suggested to have Doxygen comments, but are not mandatory. * Instance variables should NOT have Doxygen comments, unless they are public. * Markdown systax is allowed within your Doxygen comments Example: ```cpp /** `WorldPeace` extends `Node` by adding enough power to create world peace. * * `WorldPeace` should be used only when the world is about to collapse. * Do not create an instance of `WorldPeace` if the `Scene` has a peace level of 5. * */ class WorldPeace : public Node { public: /** creates a `WorldPeace` with a predefined number of preachers */ static WorldPeace* create(int numberOfPreachers); /** sets the number of preachers that will try to create the world peace. The more the better. But be aware that corruption might appear if the number if higher than the 20% of the population. */ void setNumberOfPreachers(int numberOfPreachers); /** displays an aura around the WorldPeace object @see See all `displaySuperAura()` */ void displayAura(); // Overrides virtual void addChild(Node * child) override; virtual void removeChild(Node* child, bool cleanup) override; protected: WorldPeace(); virtual ~WorldPeace(); bool init(int nubmerOfPreachers); int _nubmerOfPreachers; }; ``` ## Comment Style Use either the `//` or `/* */` syntax, as long as you are consistent. You can use either the `//` or the `/* */` syntax; however, `//` is much more common. Be consistent with how you comment and what style you use where. ## File Comments Start each file with license boilerplate, followed by a description of its contents. ### Legal Notice and Author Line Every file should contain license boilerplate. Choose the appropriate boilerplate for the license used by the project (for example, Apache 2.0, BSD, MIT, etc). The license must be compatible for the different App Stores, so GPL and LGPL code cannot be used in cocos2d-x. If you make significant changes to a file with an author line, consider deleting the author line. ### File Contents Every file should have a comment at the top describing its contents. Generally a .h file will describe the classes that are declared in the file with an overview of what they are for and how they are used. A .cpp file should contain more information about implementation details or discussions of tricky algorithms. If you feel the implementation details or a discussion of the algorithms would be useful for someone reading the .h, feel free to put it there instead, but mention in the .cpp that the documentation is in the .h file. Do not duplicate comments in both the .h and the .cpp. Duplicated comments diverge. ## Class Comments Every class definition should have an accompanying comment that describes what it is for and how it should be used. If the class is public (exposed to the users), it should use Doxygen comments. ```cpp // Iterates over the contents of a GargantuanTable. Sample usage: // GargantuanTableIterator* iter = table->NewIterator(); // for (iter->Seek("foo"); !iter->done(); iter->Next()) { // process(iter->key(), iter->value()); // } // delete iter; class GargantuanTableIterator { ... }; ``` If you have already described a class in detail in the comments at the top of your file feel free to simply state "See comment at top of file for a complete description", but be sure to have some sort of comment. Document the synchronization assumptions the class makes, if any. If an instance of the class can be accessed by multiple threads, take extra care to document the rules and invariants surrounding multithreaded use. ## Function Comments Declaration comments describe use of the function; comments at the definition of a function describe operation. If the function is public (exposed to the users), it should be documented using Doxygen comments. ### Function Declarations Every function declaration should have comments immediately preceding it that describe what the function does and how to use it. These comments should be descriptive ("Opens the file") rather than imperative ("Open the file"); the comment describes the function, it does not tell the function what to do. In general, these comments do not describe how the function performs its task. Instead, that should be left to comments in the function definition. Types of things to mention in comments at the function declaration: * What the inputs and outputs are. * For class member functions: whether the object remembers reference arguments beyond the duration of the method call, and whether it will free them or not. * If the function allocates memory that the caller must free. * Whether any of the arguments can be a null pointer. * If there are any performance implications of how a function is used. * If the function is re-entrant. What are its synchronization assumptions? Here is an example: ```cpp // Returns an iterator for this table. It is the client's // responsibility to delete the iterator when it is done with it, // and it must not use the iterator once the GargantuanTable object // on which the iterator was created has been deleted. // // The iterator is initially positioned at the beginning of the table. // // This method is equivalent to: // Iterator* iter = table->NewIterator(); // iter->Seek(""); // return iter; // If you are going to immediately seek to another place in the // returned iterator, it will be faster to use NewIterator() // and avoid the extra seek. Iterator* getIterator() const; ``` However, do not be unnecessarily verbose or state the completely obvious. Notice below that it is not necessary to say "returns false otherwise" because this is implied. ```cpp /// Returns true if the table cannot hold any more entries. bool isTableFull(); ``` When commenting constructors and destructors, remember that the person reading your code knows what constructors and destructors are for, so comments that just say something like "destroys this object" are not useful. Document what constructors do with their arguments (for example, if they take ownership of pointers), and what cleanup the destructor does. If this is trivial, just skip the comment. It is quite common for destructors not to have a header comment. ### Function Definitions If there is anything tricky about how a function does its job, the function definition should have an explanatory comment. For example, in the definition comment you might describe any coding tricks you use, give an overview of the steps you go through, or explain why you chose to implement the function in the way you did rather than using a viable alternative. For instance, you might mention why it must acquire a lock for the first half of the function but why it is not needed for the second half. Note you should not just repeat the comments given with the function declaration, in the .h file or wherever. It's okay to recapitulate briefly what the function does, but the focus of the comments should be on how it does it. ## Variable Comments In general the actual name of the variable should be descriptive enough to give a good idea of what the variable is used for. In certain cases, more comments are required. ### Class Data Members Each class data member (also called an instance variable or member variable) should have a comment describing what it is used for. If the variable can take sentinel values with special meanings, such as a null pointer or -1, document this. For example: ```cpp private: // Keeps track of the total number of entries in the table. // Used to ensure we do not go over the limit. -1 means // that we don't yet know how many entries the table has. int _numTotalEntries; ``` ### Global Variables As with data members, all global variables should have a comment describing what they are and what they are used for. For example: ```cpp // The total number of tests cases that we run through in this regression test. const int NUM_TEST_CASES = 6; ``` ## Implementation Comments In your implementation you should have comments in tricky, non-obvious, interesting, or important parts of your code. ### Class Data Members Tricky or complicated code blocks should have comments before them. Example: ```cpp // Divide result by two, taking into account that x // contains the carry from the add. for (int i = 0; i < result->size(); i++) { x = (x << 8) + (*result)[i]; (*result)[i] = x >> 1; x &= 1; } ``` ### Line Comments Also, lines that are non-obvious should get a comment at the end of the line. These end-of-line comments should be separated from the code by 2 spaces. Example: ```cpp // If we have enough memory, mmap the data portion too. mmap_budget = max(0, mmap_budget - index_->length()); if (mmap_budget >= data_size_ && !MmapData(mmap_chunk_bytes, mlock)) return; // Error already logged. ``` Note that there are both comments that describe what the code is doing, and comments that mention that an error has already been logged when the function returns. If you have several comments on subsequent lines, it can often be more readable to line them up: ```cpp doSomething(); // Comment here so the comments line up. doSomethingElseThatIsLonger(); // Comment here so there are two spaces between // the code and the comment. { // One space before comment when opening a new scope is allowed, // thus the comment lines up with the following comments and code. doSomethingElse(); // Two spaces before line comments normally. } doSomething(); /* For trailing block comments, one space is fine. */ ``` ### nullptr/NULL, true/false, 1, 2, 3... When you pass in a null pointer, boolean, or literal integer values to functions, you should consider adding a comment about what they are, or make your code self-documenting by using constants. For example, compare: ```cpp bool success = calculateSomething(interesting_value, 10, false, NULL); // What are these arguments?? ``` versus: ```cpp bool success = calculateSomething(interesting_value, 10, // Default base value. false, // Not the first time we're calling this. NULL); // No callback. ``` Or alternatively, constants or self-describing variables: ```cpp const int DEFAULT_BASE_VALUE = 10; const bool FIRST_TIME_CALLING = false; Callback *nullCallback = NULL; bool success = CalculateSomething(interestingValue, DEFAULT_BASE_VALUE, FIRST_TIME_CALLING, nullCallback); ``` ### Don'ts Note that you should never describe the code itself. Assume that the person reading the code knows C++ better than you do, even though he or she does not know what you are trying to do: ```cpp // Now go through the b array and make sure that if i occurs, // the next element is i+1. ... // Geez. What a useless comment. ``` ## Punctuation, Spelling and Grammar Pay attention to punctuation, spelling, and grammar; it is easier to read well-written comments than badly written ones. Comments should be as readable as narrative text, with proper capitalization and punctuation. In many cases, complete sentences are more readable than sentence fragments. Shorter comments, such as comments at the end of a line of code, can sometimes be less formal, but you should be consistent with your style. Although it can be frustrating to have a code reviewer point out that you are using a comma when you should be using a semicolon, it is very important that source code maintain a high level of clarity and readability. Proper punctuation, spelling, and grammar help with that goal. ## TODO Comments Use TODO comments for code that is temporary, a short-term solution, or good-enough but not perfect. TODOs should include the string TODO in all caps, followed by the name, e-mail address, or other identifier of the person who can best provide context about the problem referenced by the TODO. A colon is optional. The main purpose is to have a consistent TODO format that can be searched to find the person who can provide more details upon request. A TODO is not a commitment that the person referenced will fix the problem. Thus when you create a TODO, it is almost always your name that is given. ```cpp // TODO(kl`gmail.com): Use a "*" here for concatenation operator. // TODO(Zeke) change this to use relations. ``` If your TODO is of the form "At a future date do something" make sure that you either include a very specific date ("Fix by November 2005") or a very specific event ("Remove this code when all clients can handle XML responses."). ## Deprecation Comments Use the `CC_DEPRECATED_ATTRIBUTE` macro to mark an methods as deprecated. Also use the ` ``deprecated ` doxygen docstring to mark it as deprecated in the documentation. A deprecation comment must include simple, clear directions for people to fix their callsites. In C++, you can implement a deprecated function as an inline function that calls the new interface point. Marking an interface point DEPRECATED will not magically cause any callsites to change. If you want people to actually stop using the deprecated facility, you will have to fix the callsites yourself or recruit a crew to help you. New code should not contain calls to deprecated interface points. Use the new interface point instead. If you cannot understand the directions, find the person who created the deprecation and ask them for help using the new interface point. # Formatting Coding style and formatting are pretty arbitrary, but a project is much easier to follow if everyone uses the same style. Individuals may not agree with every aspect of the formatting rules, and some of the rules may take some getting used to, but it is important that all project contributors follow the style rules so that they can all read and understand everyone's code easily. To help you format code correctly, we've created a settings file for emacs. ## Line Length Each line of text in your code should be at most 80 characters long. We recognize that this rule is controversial, but so much existing code already adheres to it, and we feel that consistency is important. **Pros:** Those who favor this rule argue that it is rude to force them to resize their windows and there is no need for anything longer. Some folks are used to having several code windows side-by-side, and thus don't have room to widen their windows in any case. People set up their work environment assuming a particular maximum window width, and 80 columns has been the traditional standard. Why change it? **Cons:** Proponents of change argue that a wider line can make code more readable. The 80-column limit is an hidebound throwback to 1960s mainframes; modern equipment has wide screens that can easily show longer lines. **Decision:** 80 characters is the maximum. Exception: if a comment line contains an example command or a literal URL longer than 80 characters, that line may be longer than 80 characters for ease of cut and paste. Exception: an #include statement with a long path may exceed 80 columns. Try to avoid situations where this becomes necessary. Exception: you needn't be concerned about header guards that exceed the maximum length. ## Non-ASCII Characters Non-ASCII characters should be rare, and must use UTF-8 formatting. You shouldn't hard-code user-facing text in source, even English, so use of non-ASCII characters should be rare. However, in certain cases it is appropriate to include such words in your code. For example, if your code parses data files from foreign sources, it may be appropriate to hard-code the non-ASCII string(s) used in those data files as delimiters. More commonly, unittest code (which does not need to be localized) might contain non-ASCII strings. In such cases, you should use UTF-8, since that is an encoding understood by most tools able to handle more than just ASCII. Hex encoding is also OK, and encouraged where it enhances readability — for example, `"\xEF\xBB\xBF"`, or, even more simply, `u8"\uFEFF"`, is the Unicode zero-width no-break space character, which would be invisible if included in the source as straight UTF-8. Use the `u8` prefix to guarantee that a string literal containing `\uXXXX` escape sequences is encoded as UTF-8. Do not use it for strings containing non-ASCII characters encoded as UTF-8, because that will produce incorrect output if the compiler does not interpret the source file as UTF-8. You shouldn't use the C++11 `char16_t` and `char32_t` character types, since they're for non-UTF-8 text. For similar reasons you also shouldn't use `wchar_t` (unless you're writing code that interacts with the Windows API, which uses `wchar_t` extensively). ## Spaces vs. Tabs Use only spaces, and indent 4 spaces at a time. We use spaces for indentation. Do not use tabs in your code. You should set your editor to emit spaces when you hit the tab key. ## Function Declarations and Definitions Return type on the same line as function name, parameters on the same line if they fit. Functions look like this: ```cpp ReturnType ClassName::FunctionName(Type par_name1, Type par_name2) { DoSomething(); ... } ``` If you have too much text to fit on one line: ```cpp ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2, Type par_name3) { DoSomething(); ... } ``` or if you cannot fit even the first parameter: ```cpp ReturnType LongClassName::ReallyReallyReallyLongFunctionName( Type par_name1, // 4 space indent Type par_name2, Type par_name3) { DoSomething(); // 4 space indent ... } ``` Some points to note: * If you cannot fit the return type and the function name on a single line, break between them. * If you break after the return type of a function definition, do not indent. * The open parenthesis is always on the same line as the function name. * There is never a space between the function name and the open parenthesis. * There is never a space between the parentheses and the parameters. * The open curly brace is always at the end of the same line as the last parameter. * The close curly brace is either on the last line by itself or (if other style rules permit) on the same line as the open curly brace. * There should be a space between the close parenthesis and the open curly brace. * All parameters should be named, with identical names in the declaration and implementation. * All parameters should be aligned if possible. * Default indentation is 4 spaces. * Wrapped parameters have a 4 space indent. If some parameters are unused, comment out the variable name in the function definition: ```cpp // Always have named parameters in interfaces. class Shape { public: virtual void rotate(double radians) = 0; } // Always have named parameters in the declaration. class Circle : public Shape { public: virtual void rotate(double radians); } // Comment out unused named parameters in definitions. void Circle::rotate(double /*radians*/) {} // Bad - if someone wants to implement later, it's not clear what the // variable means. void Circle::rotate(double) {} ``` ## Function Calls On one line if it fits; otherwise, wrap arguments at the parenthesis. Function calls have the following format: ```cpp bool retval = doSomething(argument1, argument2, argument3); ``` If the arguments do not all fit on one line, they should be broken up onto multiple lines, with each subsequent line aligned with the first argument. Do not add spaces after the open paren or before the close paren: ```cpp bool retval = doSomething(averyveryveryverylongargument1, argument2, argument3); ``` If the function has many arguments, consider having one per line if this makes the code more readable: ```cpp bool retval = doSomething(argument1, argument2, argument3, argument4); ``` Arguments may optionally all be placed on subsequent lines, with one line per argument: ```cpp if (...) { ... ... if (...) { doSomething( argument1, // 4 space indent argument2, argument3, argument4); } ``` In particular, this should be done if the function signature is so long that it cannot fit within the maximum line length. ## Braced Initializer Lists Format a braced list exactly like you would format a function call in its place. If the braced list follows a name (e.g. a type or variable name), format as if the `{}` were the parentheses of a function call with that name. If there is no name, assume a zero-length name. ```cpp // Examples of braced init list on a single line. return {foo, bar}; functioncall({foo, bar}); pair p{foo, bar}; // When you have to wrap. SomeFunction( {"assume a zero-length name before {"}, some_other_function_parameter); SomeType variable{ some, other, values, {"assume a zero-length name before {"}, SomeOtherType{ "Very long string requiring the surrounding breaks.", some, other values}, SomeOtherType{"Slightly shorter string", some, other, values}}; SomeType variable{ "This is too long to fit all in one line"}; MyType m = { // Here, you could also break before {. superlongvariablename1, superlongvariablename2, {short, interior, list}, {interiorwrappinglist, interiorwrappinglist2}}; ``` ## Conditionals Prefer no spaces inside parentheses. The else keyword belongs on a new line. There are two acceptable formats for a basic conditional statement. One includes spaces between the parentheses and the condition, and one does not. The most common form is without spaces. Either is fine, but be consistent. If you are modifying a file, use the format that is already present. If you are writing new code, use the format that the other files in that directory or project use. If in doubt and you have no personal preference, do not add the spaces. ```cpp if (condition) { // no spaces inside parentheses ... // 4 space indent. } else if (...) { // The else goes on the same line as the closing brace. ... } else { ... } ``` If you prefer you may add spaces inside the parentheses: ```cpp if ( condition ) { // spaces inside parentheses - rare ... // 4 space indent. } else { // The else goes on the same line as the closing brace. ... } ``` Note that in all cases you must have a space between the `if` and the open parenthesis. You must also have a space between the close parenthesis and the curly brace, if you're using one. ```cpp if(condition) // Bad - space missing after IF. if (condition){ // Bad - space missing before {. if(condition){ // Doubly bad. if (condition) { // Good - proper space after IF and before {. ``` Short conditional statements may be written on one line if this enhances readability. You may use this only when the line is brief and the statement does not use the else clause. ```cpp if (x == FOO) return new Foo(); if (x == BAR) return new Bar(); ``` This is not allowed when the if statement has an `else`: ```cpp // Not allowed - IF statement on one line when there is an ELSE clause if (x) doThis(); else doThat(); ``` In general, curly braces are not required for single-line statements, but they are allowed if you like them; conditional or loop statements with complex conditions or statements may be more readable with curly braces. Some projects require that an if must always always have an accompanying brace. ```cpp if (condition) doSomething(); // 4 space indent. if (condition) { doSomething(); // 4 space indent. } ``` However, if one part of an if-else statement uses curly braces, the other part must too: ```cpp // Not allowed - curly on IF but not ELSE if (condition) { foo; } else bar; // Not allowed - curly on ELSE but not IF if (condition) foo; else { bar; } // Curly braces around both IF and ELSE required because // one of the clauses used braces. if (condition) { foo; } else { bar; } ``` ## Loops and Switch Statements Switch statements may use braces for blocks. Annotate non-trivial fall-through between cases. Empty loop bodies should use {} or continue. case blocks in switch statements can have curly braces or not, depending on your preference. If you do include curly braces they should be placed as shown below. If not conditional on an enumerated value, switch statements should always have a default case (in the case of an enumerated value, the compiler will warn you if any values are not handled). If the default case should never execute, simply assert: ```cpp switch (var) { case 0: { // 4 space indent ... // 4 space indent break; } case 1: { ... break; } default: { assert(false); } } ``` Empty loop bodies should use `{}` or `continue`, but not a single semicolon. ```cpp while (condition) { // Repeat test until it returns false. } for (int i = 0; i < SOME_NUMBER; ++i) {} // Good - empty body. while (condition) continue; // Good - continue indicates no logic. while (condition); // Bad - looks like part of do/while loop. ``` ## Pointer and Reference Expressions No spaces around period or arrow. Pointer operators do not have trailing spaces. The following are examples of correctly-formatted pointer and reference expressions: ```cpp x = *p; p = &x; x = r.y; x = r->y; ``` Note that: * There are no spaces around the period or arrow when accessing a member. * Pointer operators have no space after the * or &. When declaring a pointer variable or argument, you may place the asterisk adjacent to either the type or to the variable name: ```cpp // These are fine, space preceding. char *c; const string &str; // These are fine, space following. char* c; // but remember to do "char* c, *d, *e, ...;"! const string& str; char * c; // Bad - spaces on both sides of * const string & str; // Bad - spaces on both sides of & ``` You should do this consistently within a single file, so, when modifying an existing file, use the style in that file. ## Boolean Expressions When you have a boolean expression that is longer than the standard line length, be consistent in how you break up the lines. In this example, the logical AND operator is always at the end of the lines: ```cpp if (thisOneThing > thisOtherThing && aThirdThing == aFourthThing && yetAnother && lastOne) { ... } ``` Note that when the code wraps in this example, both of the && logical AND operators are at the end of the line. This is more common in Google code, though wrapping all operators at the beginning of the line is also allowed. Feel free to insert extra parentheses judiciously because they can be very helpful in increasing readability when used appropriately. Also note that you should always use the punctuation operators, such as && and ~, rather than the word operators, such as and and compl. ## Return Values Do not needlessly surround the return expression with parentheses. Use parentheses in `return expr;` only where you would use them in `x = expr;`. ```cpp return result; // No parentheses in the simple case. return (someLongCondition && // Parentheses ok to make a complex anotherCondition); // expression more readable. return (value); // You wouldn't write var = (value); return(result); // return is not a function! ``` ## Variable and Array Initialization Your choice of `=`, `()`, or `{}`. You may choose between `=`, `()`, and `{}`; the following are all correct: ```cpp int x = 3; int x(3); int x{3}; string name = "Some Name"; string name("Some Name"); string name{"Some Name"}; ``` Be careful when using the `{}` on a type that takes an initializer_list in one of its constructors. The `{}` syntax prefers the initializer_list constructor whenever possible. To get the non- initializer_list constructor, use `()`. ```cpp vector v(100, 1); // A vector of 100 1s. vector v{100, 1}; // A vector of 100, 1. ``` Also, the brace form prevents narrowing of integral types. This can prevent some types of programming errors. ```cpp int pi(3.14); // OK -- pi == 3. int pi{3.14}; // Compile error: narrowing conversion. ``` ## Preprocessor Directives The hash mark that starts a preprocessor directive should always be at the beginning of the line. Even when preprocessor directives are within the body of indented code, the directives should start at the beginning of the line. ```cpp // Good - directives at beginning of line if (lopsidedScore) { #if DISASTER_PENDING // Correct -- Starts at beginning of line dropEverything(); # if NOTIFY // OK but not required -- Spaces after # notifyClient(); # endif #endif backToNormal(); } ``` ```cpp // Bad - indented directives if (lopsidedScore) { #if DISASTER_PENDING // Wrong! The "#if" should be at beginning of line dropEverything(); #endif // Wrong! Do not indent "#endif" backToNormal(); } ``` ## Class Format Sections in public, protected and private order, each indented one space. The basic format for a class declaration (lacking the comments, see Class Comments for a discussion of what comments are needed) is: ```cpp class MyClass : public OtherClass { public: // Note the 0 space indent! MyClass(); // Regular 4 space indent. explicit MyClass(int var); ~MyClass() {} void someFunction(); void someFunctionThatDoesNothing() { } void setSomeVar(int var) { _someVar = var; } int getSomeVar() const { return _someVar; } private: bool someInternalFunction(); int _someVar; int _someOtherVar; DISALLOW_COPY_AND_ASSIGN(MyClass); }; ``` Things to note: * Any base class name should be on the same line as the subclass name, subject to the 80-column limit. * The `public:`, `protected:`, and `private:` keywords should not be indented. * Except for the first instance, these keywords should be preceded by a blank line. This rule is optional in small classes. * Do not leave a blank line after these keywords. * The `public:` section should be first, followed by the `protected:` and finally the `private:` section. * See Declaration Order for rules on ordering declarations within each of these sections. ## Constructor Initializer Lists Constructor initializer lists can be all on one line or with subsequent lines indented zero spaces. There are two acceptable formats for initializer lists: ```cpp // When it all fits on one line: MyClass::MyClass(int var) : _someVar(var), _someOtherVar(var + 1) {} ``` or ```cpp // When it requires multiple lines, indent zero spaces, putting the colon on // the first initializer line, and commas in new lines if needed: MyClass::MyClass(int var) : _someVar(var) // 0 space indent , _someOtherVar(var + 1) // lined up { ... doSomething(); ... } ``` ## Namespace Formatting The contents of namespaces are not indented. Namespaces do not add an extra level of indentation. For example, use: ```cpp namespace { void foo() { // Correct. No extra indentation within namespace. ... } } // namespace ``` Do not indent within a namespace: ```cpp namespace { // Wrong. Indented when it should not be. void foo() { ... } } // namespace ``` When declaring nested namespaces, put each namespace on its own line. ```cpp namespace foo { namespace bar { ``` ## Horizontal Whitespace Use of horizontal whitespace depends on location. Never put trailing whitespace at the end of a line. ### General ```cpp void f(bool b) { // Open braces should always have a space before them. ... int i = 0; // Semicolons usually have no space before them. int x[] = { 0 }; // Spaces inside braces for braced-init-list are int x[] = {0}; // optional. If you use them, put them on both sides! // Spaces around the colon in inheritance and initializer lists. class Foo : public Bar { public: // For inline function implementations, put spaces between the braces // and the implementation itself. Foo(int b) : Bar(), baz_(b) {} // No spaces inside empty braces. void Reset() { baz_ = 0; } // Spaces separating braces from implementation. ... ``` Adding trailing whitespace can cause extra work for others editing the same file, when they merge, as can removing existing trailing whitespace. So: Don't introduce trailing whitespace. Remove it if you're already changing that line, or do it in a separate clean-up operation (preferably when no-one else is working on the file). ### Loops and Conditionals ```cpp if (b) { // Space after the keyword in conditions and loops. } else { // Spaces around else. } while (test) {} // There is usually no space inside parentheses. switch (i) { for (int i = 0; i < 5; ++i) { switch ( i ) { // Loops and conditions may have spaces inside if ( test ) { // parentheses, but this is rare. Be consistent. for ( int i = 0; i < 5; ++i ) { for ( ; i < 5 ; ++i) { // For loops always have a space after the ... // semicolon, and may have a space before the // semicolon. for (auto x : counts) { // Range-based for loops always have a ... // space before and after the colon. } switch (i) { case 1: // No space before colon in a switch case. ... case 2: break; // Use a space after a colon if there's code after it. ``` ### Operators ```cpp x = 0; // Assignment operators always have spaces around // them. x = -5; // No spaces separating unary operators and their ++x; // arguments. if (x && !y) ... v = w * x + y / z; // Binary operators usually have spaces around them, v = w*x + y/z; // but it's okay to remove spaces around factors. v = w * (x + z); // Parentheses should have no spaces inside them. ``` ### Templates and Casts ```cpp vector x; // No spaces inside the angle y = static_cast(x); // brackets (< and >), before // <, or between >( in a cast. vector x; // Spaces between type and pointer are // okay, but be consistent. set> x; // Permitted in C++11 code. set > x; // C++03 required a space in > >. set< list > x; // You may optionally use // symmetric spacing in < <. ``` ## Vertical Whitespace Minimize use of vertical whitespace. This is more a principle than a rule: don't use blank lines when you don't have to. In particular, don't put more than one or two blank lines between functions, resist starting functions with a blank line, don't end functions with a blank line, and be discriminating with your use of blank lines inside functions. The basic principle is: The more code that fits on one screen, the easier it is to follow and understand the control flow of the program. Of course, readability can suffer from code being too dense as well as too spread out, so use your judgement. But in general, minimize use of vertical whitespace. Some rules of thumb to help when blank lines may be useful: * Blank lines at the beginning or end of a function very rarely help readability. * Blank lines inside a chain of if-else blocks may well help readability. # Exceptions to the Rules The coding conventions described above are mandatory. However, like all good rules, these sometimes have exceptions, which we discuss here. ## Existing Non-conformant Code You may diverge from the rules when dealing with code that does not conform to this style guide. If you find yourself modifying code that was written to specifications other than those presented by this guide, you may have to diverge from these rules in order to stay consistent with the local conventions in that code. If you are in doubt about how to do this, ask the original author or the person currently responsible for the code. Remember that consistency includes local consistency, too. ## Windows Code Windows programmers have developed their own set of coding conventions, mainly derived from the conventions in Windows headers and other Microsoft code. We want to make it easy for anyone to understand your code, so we have a single set of guidelines for everyone writing C++ on any platform. It is worth reiterating a few of the guidelines that you might forget if you are used to the prevalent Windows style: * Do not use Hungarian notation (for example, naming an integer iNum). Use the Google naming conventions, including the .cpp extension for source files. * Windows defines many of its own synonyms for primitive types, such as DWORD, HANDLE, etc. It is perfectly acceptable, and encouraged, that you use these types when calling Windows API functions. Even so, keep as close as you can to the underlying C++ types. For example, use const TCHAR * instead of LPCTSTR. * When compiling with Microsoft Visual C++, set the compiler to warning level 3 or higher, and treat all warnings as errors. * Do not use #pragma once; instead use the standard Google include guards. The path in the include guards should be relative to the top of your project tree. * In fact, do not use any nonstandard extensions, like #pragma and __declspec, unless you absolutely must. Using `__declspec(dllimport)` and `__declspec(dllexport)` is allowed; however, you must use them through macros such as `DLLIMPORT` and `DLLEXPORT` or `CC_DLL`, so that someone can easily disable the extensions if they share the code. However, there are just a few rules that we occasionally need to break on Windows: * Normally we forbid the use of multiple implementation inheritance; however, it is required when using COM and some ATL/WTL classes. You may use multiple implementation inheritance to implement COM or ATL/WTL classes and interfaces. * Although you should not use exceptions in your own code, they are used extensively in the ATL and some STLs, including the one that comes with Visual C++. When using the ATL, you should define _ATL_NO_EXCEPTIONS to disable exceptions. You should investigate whether you can also disable exceptions in your STL, but if not, it is OK to turn on exceptions in the compiler. (Note that this is only to get the STL to compile. You should still not write exception handling code yourself.) * The usual way of working with precompiled headers is to include a header file at the top of each source file, typically with a name like StdAfx.h or precompile.h. To make your code easier to share with other projects, avoid including this file explicitly (except in precompile.cpp), and use the /FI compiler option to include the file automatically. * Resource headers, which are usually named resource.h and contain only macros, do not need to conform to these style guidelines. # Parting Words Use common sense and **BE CONSISTENT**. If you are editing code, take a few minutes to look at the code around you and determine its style. If they use spaces around their if clauses, you should, too. If their comments have little boxes of stars around them, make your comments have little boxes of stars around them too. The point of having style guidelines is to have a common vocabulary of coding so people can concentrate on what you are saying, rather than on how you are saying it. We present global style rules here so people know the vocabulary. But local style is also important. If code you add to a file looks drastically different from the existing code around it, the discontinuity throws readers out of their rhythm when they go to read it. Try to avoid this. OK, enough writing about writing code; the code itself is much more interesting. Have fun! [1]: https://lh3.googleusercontent.com/-glwwzmFyUmk/UQgPnlx40uI/AAAAAAAArzg/WPRW10kkecM/s144/cocos2d-x-logo.png ================================================ FILE: cocos2d/docs/Groups.h ================================================ /** @defgroup actions Actions @defgroup data_structures Data Structures @defgroup base_nodes Base Nodes @defgroup effects Effects @defgroup cocosbuilder CocosBuilder Support @defgroup global Global @defgroup input Human Machine Interation @defgroup data_storage Data Storage @defgroup layer Layer @defgroup scene Scene @defgroup transition Transition @defgroup GUI GUI @defgroup label Label @defgroup menu Menu, MenuItem @defgroup control_extension Control Exntension @defgroup misc_nodes Misc Nodes @defgroup particle_nodes Particle System @defgroup platform Platform Adaptor @defgroup script_support Script Support @defgroup shaders Shaders @defgroup sprite_nodes Sprite Nodes @defgroup textures Textures @defgroup tilemap_parallax_nodes TileMap, Parallax */ ================================================ FILE: cocos2d/docs/MainPage.h ================================================ /*! @mainpage cocos2d-x @image html cocos2dx_portrait.png @section sec1 About cocos2d-x cocos2d-x open source project is designed to be a cross-platform 2D game engine for building 2D games, demos and other graphical/interactive mobile applications. It runs on OpenGL ES 1.1, and is written in C++ language, provides C++ API.\n This project is based on the famous "cocos2d-iphone" project, and will keep pace with it. \n - website: http://www.cocos2d-x.org/ - forum: http://forum.cocos2d-x.org/ - twitter: http://twitter.com/cocos2dx/ - weibo: http://weibo.com/cocos2dx/ - wiki: http://wiki.cocos2d-x.org/ - show cases: http://www.cocos2d-x.org/games - Tutorials of Cocos2dxSimpleGame - Installation and First run - DEVELOP FAQ \n @section sec2 License Copyright (c) 2010-2012 cocos2d-x.org \n \n Permission is hereby granted, free of charge, to any person obtaining a copy \n of this software and associated documentation files (the "Software"), to deal \n in the Software without restriction, including without limitation the rights \n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell \n copies of the Software, and to permit persons to whom the Software is \n furnished to do so, subject to the following conditions: \n \n The above copyright notice and this permission notice shall be included in \n all copies or substantial portions of the Software. \n \n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE \n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n THE SOFTWARE. \n \n @section sec3 Get the source code - Stable version: \n - publish at http://download.cocos2d-x.org/ - Last code: \n - http://github.com/cocos2d/cocos2d-x/ @section sec4 How to contribute - Fork our repository on github, commit your changes, and send a "pull request" to us. We will merge your contribution to master - Any suggestion, bug fix, improvment will be appreciated. */ ================================================ FILE: cocos2d/docs/RELEASE_NOTES.md ================================================ # cocos2d-x v3.0 Release Notes # **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* - [cocos2d-x v3.0 Release Notes](#cocos2d-x-v30-release-notes) - [Misc Information](#misc-information) - [Requirements](#requirements) - [Runtime Requirements](#runtime-requirements) - [Compiler Requirements](#compiler-requirements) - [Highlights of v3.0.0](#highlights-of-v300) - [Features in detail](#features-in-detail) - [C++11 features](#c++11-features) - [std::function](#stdfunction) - [strongly typed enums](#strongly-typed-enums) - [override](#override) - [Removed Objective-C patterns](#removed-objective-c-patterns) - [No more 'CC' prefix for C++ classes and free functions](#no-more-'cc'-prefix-for-c++-classes-and-free-functions) - [clone() instead of copy()](#clone-instead-of-copy) - [Singletons use getInstance() and destroyInstance()](#singletons-use-getinstance-and-destroyinstance) - [getters](#getters) - [POD types](#pod-types) - [New renderer](#new-renderer) - [Improved LabelTTF / LabelBMFont](#improved-labelttf--labelbmfont) - [New EventDispatcher](#new-eventdispatcher) - [Adding Touch Event Listener](#adding-touch-event-listener) - [Adding Mouse Event Listener](#adding-mouse-event-listener) - [Adding A Keyboard Event Listener](#adding-a-keyboard-event-listener) - [Adding An Acceleration Event Listener](#adding-an-acceleration-event-listener) - [Adding A Custom Event Listener](#adding-a-custom-event-listener) - [Dispatching A Custom Event](#dispatching-a-custom-event) - [Setting Fixed Priority For A Listener](#setting-fixed-priority-for-a-listener) - [Removing Event Listener](#removing-event-listener) - [Removing A Specified Event Listener](#removing-a-specified-event-listener) - [Removing Custom Event Listener](#removing-custom-event-listener) - [Removing All Listeners For Specified Event Listener Type](#removing-all-listeners-for-specified-event-listener-type) - [Removing All Listeners](#removing-all-listeners) - [Physics Integration](#physics-integration) - [PhysicsWorld](#physicsworld) - [PhysicsBody](#physicsbody) - [PhysicsShape](#physicsshape) - [PhysicsJoint](#physicsjoint) - [PhysicsContact](#physicscontact) - [Misc API Changes](#misc-api-changes) - [`ccTypes.h`](#cctypesh) - [deprecated functions and global variables](#deprecated-functions-and--global-variables) - [Changes in the Lua bindings](#changes-in-the-lua-bindings) - [Use bindings-generator tool for lua binding](#use-bindings-generator-tool-for-lua-binding) - [Bind the classes with namespace to lua](#bind-the-classes-with-namespace-to-lua) - [Use ScriptHandlerMgr to manage the register and unregister of lua function](#use-scripthandlermgr-to-manage-the-register-and-unregister-of-lua-function) - [Use "cc" and "ccs" as module name](#use-cc-and-ccs-as-module-name) - [Deprecated funtions, tables and classes](#deprecated-funtions-tables-and-classes) - [Use the lua table instead of the some structs and classes binding](#use-the-lua-table-instead-of-the-some-structs-and-classes-binding) - [Integrate more modules into lua](#integrate-more-modules-into-lua) - [Known issues](#known-issues) # Misc Information * Download: http://cdn.cocos2d-x.org/cocos2d-x-3.0beta.zip * Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0beta/CHANGELOG * API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.0beta/index.html # Requirements ## Runtime Requirements * Android 2.3 or newer * iOS 5.0 or newer * OS X 10.7 or newer * Windows 7 or newer * ~~Windows Phone 8 or newer~~ N/A for the moment * Linux Ubuntu 12.04 (or newer) * ~~Browsers via Emscripten~~ N/A for the moment * ~~Marmalade~~ N/A for the moment * ~~BlackBerry~~ N/A for the moment ## Compiler Requirements * Xcode 4.6 (for iOS or Mac) * gcc 4.7 for Linux or Android. For Android ndk-r9 or newer is required. * Visual Studio 2012 (for Windows) # Highlights of v3.0 * Replaced Objective-C patters with C++ (C++11) patterns and best practices * Improved Labels * Improved renderer * New Event Dispatcher * Physics integration * New GUI * JavaScript remote debugger * Remote Console support * Refactor Image - release memory in time and uniform the api of supported file format * Automatically generated Lua bindings, add LuaJavaBridge and LuaObjcBridge * Templated containers # Features in detail ## C++11 features _Feature added in v3.0-pre-alpha0_ A subset of C++11 features are being used in cocos2d-x: * `std::function`, including lambda objects for callbacks * strongly typed enums, for most of the cocos2d-x enums and constants * `std::thread` for threading * `override` context keyword, for overriden methods ### std::function * `CallFunc` can be created with an `std::function` * `CallFuncN` can be created with an `std::function` * `CallFuncND` and `CallFuncO` were removed since it can be created with simulated with `CallFuncN` and `CallFunc`. See ActionsTest.cpp for more examples * `MenuItem` supports `std::function` as callbacks `CallFunc` example: ```cpp // in v2.1 CCCallFunc *action1 = CCCallFunc::create( this, callfunc_selector( MyClass::callback_0 ) ); // in v3.0 (short version) auto action1 = CallFunc::create( CC_CALLBACK_0(MyClass::callback_0,this)); auto action2 = CallFunc::create( CC_CALLBACK_0(MyClass::callback_1,this, additional_parameters)); // in v3.0 (long version) auto action1 = CallFunc::create( std::bind( &MyClass::callback_0, this)); auto action2 = CallFunc::create( std::bind( &MyClass::callback_1, this, additional_parameters)); // in v3.0 you can also use lambdas or any other "Function" object auto action1 = CallFunc::create( [&](){ auto s = Director::sharedDirector()->getWinSize(); auto label = LabelTTF::create("called:lambda callback", "Marker Felt", 16); label->setPosition(ccp( s.width/4*1,s.height/2-40)); this->addChild(label); } ); ``` `MenuItem` example: ```c++ // in v2.1 CCMenuItemLabel *item = CCMenuItemLabel::create(label, this, menu_selector(MyClass::callback)); // in v3.0 (short version) auto item = MenuItemLabel::create(label, CC_CALLBACK_1(MyClass::callback, this)); // in v3.0 (long version) auto item = MenuItemLabel::create(label, std::bind(&MyClass::callback, this, std::placeholders::_1)); // in v3.0 you can use lambdas or any other "Function" object auto item = MenuItemLabel::create(label, [&](Object *sender) { // do something. Item "sender" clicked }); ``` ### strongly typed enums _Feature added in v3.0-pre-alpha0_ Constants and enums that started with `k`, and that usually were defined as `int` or as simple `enum` where replaced with strongly typed enums ( `enum class` ) to prevent collisions and type errors. The new format is: | v2.1 | v3.0 | | kTypeValue | Type::VALUE | Examples: | v2.1 | v3.0 | | kCCTexture2DPixelFormat_RGBA8888 | Texture2D::PixelFormat::RGBA8888 | | kCCDirectorProjectionCustom | Director::Projection::CUSTOM | | ccGREEN | Color3B::GREEN | | CCPointZero | Point::ZERO | | CCSizeZero | Size::ZERO | The old values can still be used, but are not deprecated. ### override To catch possible errors while overriding methods, subclasses with override methods have the `override` context keyword. Example: ```c++ class Sprite : public Node { bool isFlipY(void) const; void setFlipY(bool bFlipY); // Overrides virtual void setTexture(Texture2D *texture) override; virtual Texture2D* getTexture() const override; inline void setBlendFunc(const BlendFunc &blendFunc) override; inline const BlendFunc& getBlendFunc() const override; } ``` ## Removed Objective-C patterns _Feature added in v3.0-pre-alpha0_ ### No more 'CC' prefix for C++ classes and free functions *Changes in classes* Since cocos2d-x already uses the `cocos2d` namespace, there is not need to add the prefix `CC` to all its classes. Examples: | v2.1 | v3.0 | | CCSprite | Sprite | | CCNode | Node | | CCDirector | Director | | etc... | v2.1 class names are still available, but they were tagged as deprecated. *Changes in free functions* For the *drawing primitives*: * They were added in the `DrawPrimitives` namespace * The `cc` prefix was removed For the *gl proxy functions*: * They were added in the `GL` namespace * The `ccGL` prefix was removed Examples: | v2.1 | v3.0 | | ccDrawPoint() | DrawPrimitives::drawPoint() | | ccDrawCircle() | DrawPrimitives::drawCircle() | | ccGLBlendFunc() | GL::blendFunc() | | ccGLBindTexture2D() | GL::bindTexture2D() | | etc... | v2.1 free functions are still available, but they were tagged as deprecated. ### clone() instead of copy() `clone()` returns an autoreleased version of the copy. `copy()` is no longer supported. If you use it, it will compile, but the code will crash. Example: ```c++ // v2.1 CCMoveBy *action = (CCMoveBy*) move->copy(); action->autorelease(); // v3.0 // No need to do autorelease, no need to do casting. auto action = move->clone(); ``` ### Singletons use getInstance() and destroyInstance() All singletons use `getInstance()` and `destroyInstance()` (if applicable) to get and destroy the instance. Examples: | v2.1 | v3.0 | | CCDirector->sharedDirector() | Director->getInstance() | | CCDirector->endDirector() | Director->destroyInstance() | | etc... | v2.1 methods are still available, but they were tagged as deprecated. ### getters Getters now use the `get` prefix. Examples: | v2.1 | v3.0* | | node->boundingBox() | node->getBoundingBox() | | sprite->nodeToParentTransform() | sprite->getNodeToParentTransform() | | etc... | And getters were also tagged as `const` in their declaration. Example: ```c++ // v2.1 virtual float getScale(); // v3.0 virtual float getScale() const; ``` v2.1 methods are still available, but they were tagged as deprecated. ### POD types Methods that were receiving POD types as arguments (eg: `TexParams`, `Point`, `Size`, etc.) are being passed as `const` reference. Example: ```c++ // v2.1 void setTexParameters(ccTexParams* texParams); // v3.0 void setTexParameters(const ccTexParams& texParams); ``` ## New Renderer _Feature added in v3.0-beta and improved in v3.0-beta2_ The renderer functionality has been decoupled from the Scene graph / Node logic. A new object called `Renderer` is responsible for rendering the object. Auto-batching ~~and auto-culling~~ support has been added. Please, see this document for detail information about its internal funcitonality: [Renderer Specification document](https://docs.google.com/document/d/17zjC55vbP_PYTftTZEuvqXuMb9PbYNxRFu0EGTULPK8/edit) ### Renderer features #### Auto-batching TODO #### Auto-culling TODO #### Global Z order A new method called `setGlobalZOrder()` / `getGlobalZOrder()` was added to `Node`, and the old methods `setZOrder()` / `getZOrder()` were renamed to `setLocalZOrder()` / `getLocalZOrder()`. `globalZOrder` receives a `float` (and not an `int`) as argument. And this value is used to sort the Nodes in the Renderer. Lower values have higher priority over higher values. That means that a Node with a `globalZOrder` of `-10` is going to be drawn BEFORE a Node with `globalZOrder` of `10`. Nodes that have a `globalZOrder` of `0` (default value) will be drawn according to the Scene Graph order. So, if the `globalZOrder` is not changed, cocos2d-x v3.0 will behave exaclty as cocos2d-x v2.2. __`globalZOrder()` vs. `localZOrder()`__: * `globalZOrder` is used to sort the "draw commands" in the Renderer * `localZOrder` is used to sort the Node in its parent's children Array __Exceptions__: TODO ## Improved LabelTTF / LabelBMFont _Feature added in v3.0-alpha0_ ## New EventDispatcher _Feature added in v3.0-alpha0_ All events like touch event, keyboard event, acceleration event and custom event are dispatched by `EventDispatcher`. `TouchDispatcher`, `KeypadDispatcher`, `KeyboardDispatcher`, `AccelerometerDispatcher` were removed. ### Adding Touch Event Listener For TouchOneByOne: ```c++ auto sprite = Sprite::create("file.png"); ... auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouch(true); listener->onTouchBegan = [](Touch* touch, Event* event) { do_some_thing(); return true; }; listener->onTouchMoved = [](Touch* touch, Event* event) { do_some_thing(); }; listener->onTouchEnded = [](Touch* touch, Event* event) { do_some_thing(); }; listener->onTouchCancelled = [](Touch* touch, Event* event) { do_some_thing(); }; // The priority of the touch listener is based on the draw order of sprite EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, sprite); // Or the priority of the touch listener is a fixed value EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 100); // 100 is a fixed value ``` For TouchAllAtOnce ```c++ auto sprite = Sprite::create("file.png"); ... auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = [](const std::vector& touches, Event* event) { do_some_thing(); }; listener->onTouchesMoved = [](const std::vector& touches, Event* event) { do_some_thing(); }; listener->onTouchesEnded = [](const std::vector& touches, Event* event) { do_some_thing(); }; listener->onTouchesCancelled = [](const std::vector& touches, Event* event) { do_some_thing(); }; // The priority of the touch listener is based on the draw order of sprite EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, sprite); // Or the priority of the touch listener is a fixed value EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 100); // 100 is a fixed value ``` ### Adding Mouse Event Listener ### ```c++ auto mouseListener = EventListenerMouse::create(); mouseListener->onMouseScroll = [](Event* event) { EventMouse* e = static_cast(event); do_some_thing(); }; mouseListener->onMouseUp = [](Event* event) { EventMouse* e = static_cast(event); do_some_thing(); }; mouseListener->onMouseDown = [](Event* event) { EventMouse* e = static_cast(event); do_some_thing(); }; dispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this); ``` ### Adding A Keyboard Event Listener ```c++ auto listener = EventListenerKeyboard::create(); listener->onKeyPressed = CC_CALLBACK_2(SomeClass::onKeyPressed, this); listener->onKeyReleased = CC_CALLBACK_2(SomeClass::onKeyReleased, this); EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this); ``` ### Adding An Acceleration Event Listener ```c++ auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(SomeClass::onAcceleration, this)); EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this); ``` ### Adding A Custom Event Listener ```c++ auto listener = EventListenerCustom::create("game_custom_event", [=](EventCustom* event){ void* userData= event->getUserData(); do_some_with_user_data(); }); dispatcher->addEventListenerWithFixedPriority(listener, 1); ``` ### Dispatching A Custom Event ```c++ EventCustom event("game_custom_event"); event.setUserData(some_data); dispatcher->dispatchEvent(&event); ``` ### Setting Fixed Priority For A Listener ```c++ dispatcher->setPriority(fixedPriorityListener, 200); ``` ### Removing Event Listener #### Removing A Specified Event Listener ```c++ dispatcher->removeEventListener(listener); ``` #### Removing Custom Event Listener #### ```c++ dispatcher->removeCustomEventListener("my_custom_event_listener_name"); ``` #### Removing All Listeners For An Event Listener Type ```c++ dispatcher->removeEventListeners(EventListener::Type::TOUCH_ONE_BY_ONE); ``` #### Removing All Listeners ```c++ dispatcher->removeAllListeners(); ``` ## Physics Integration _Feature added in v3.0-pre-alpha0_ Physics integration have five concepts: `PhysicsWorld`, `PhysicsBody`, `PhysicsShape`, `PhysicsJoint` and `PhysicsContact`. You must define `CC_USE_PHYSICS` macro in `ccConfig.h` to use the physics API. ### PhysicsWorld A `PhysicsWorld` object simulates collisions and other physical properties, you do not create it directly, you can get it from scene which create with physics. ```c++ Scene* scene = Scene::createWithPhysics(); PhysicsWorld* world = scene->getPhysicsWorld(); ``` ### PhysicsBody A `PhysicsBody` object is used to add physics simulation to a node. If you create a `PhysicsBody` and set it to a node, and add the node the a scene which create with physics, it will perform the physics simulation when update. ```c++ PhysicsBody* body = PhysicsBody::createCircle(5.0f); Node* node = Node::create(); node->setPhysicsBody(body); scene->addChild(node); ``` ### PhysicsShape A `PhysicsShape` object is a shape that make the body can have collisions. you can add one or more `PhysicsShape` to a `PhysicsBody`. Shape classes: `PhysicsShapeCircle`, `PhysicsShapeBox`, `PhysicsShapePolygon`, `PhysicsShapeEdgeSegment`, `PhysicsShapeEdgeBox`, `PhysicsShapeEdgePolygon`, `PhysicsShapeEdgeChain`. ```c++ PhysicsShape* shape = PhysicsShapeBox::create(Size(5.0f, 10.0f); body->addShape(shape); ``` ### PhysicsJoint A `PhysicsJoint` object connects two physics bodies together so that they are simulated together by the physics world. Joint classes: `PhysicsJointFixed`, `PhysicsJointLimit`, `PhysicsJointPin`, `PhysicsJointDistance`, `PhysicsJointSpring`, `PhysicsJointGroove`, `PhysicsJointRotarySpring`, `PhysicsJointRotaryLimit`, `PhysicsJointRatchet`, `PhysicsJointGear`, `PhysicsJointMotor`. ```c++ PhysicsJoint* joint = PhysicsJointDistance::construct(bodyA, bodyB, Point::ZERO, Point::ZERO); world->addJoint(joint); ``` ### PhysicsContact A `PhysicsContact` object is created automatically to describes a contact between two physical bodies in a `PhysicsWorld`. you can control the contact behavior from the physics contact event listener. Other classes contain the contact information: `PhysicsContactPreSolve`, `PhysicsContactPostSolve`. The event listener for physics: `EventListenerPhysicsContact`, `EventListenerPhysicsContactWithBodies`, `EventListenerPhysicsContactWithShapes`, `EventListenerPhysicsContactWithGroup`. ```c++ auto contactListener = EventListenerPhysicsContactWithBodies::create(bodyA, bodyB); contactListener->onContactBegin = [](EventCustom* event, const PhysicsContact& contact) -> bool { doSomething(); return true; }; _eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this); ``` # Misc API Changes ## `ccTypes.h` Remove *cc* prefix for structure names in ccTypes.h, move global functions into static member functions, and move global constants into const static member variables. | v2.1 struct names | v3.0 struct names | | ccColor3B | Color3B | | ccColor4B | Color4B | | ccColor4F | Color4F | | ccVertex2F | Vertex2F | | ccVertex3F | Vertex3F | | ccTex2F | Tex2F | | ccPointSprite | PointSprite | | ccQuad2 | Quad2 | | ccQuad3 | Quad3 | | ccV2F_C4B_T2F | V2F_C4B_T2F | | ccV2F_C4F_T2F | V2F_C4F_T2F | | ccV3F_C4B_T2F | V3F_C4B_T2F | | ccV2F_C4B_T2F_Triangle | V2F_C4B_T2F_Triangle | | ccV2F_C4B_T2F_Quad | V2F_C4B_T2F_Quad | | ccV3F_C4B_T2F_Quad | V3F_C4B_T2F_Quad | | ccV2F_C4F_T2F_Quad | V2F_C4F_T2F_Quad | | ccBlendFunc | BlendFunc | | ccT2F_Quad | T2F_Quad | | ccAnimationFrameData | AnimationFrameData | Global functions changed example ```c++ // in v2.1 ccColor3B color3B = ccc3(0, 0, 0); ccc3BEqual(color3B, ccc3(1, 1, 1)); ccColor4B color4B = ccc4(0, 0, 0, 0); ccColor4F color4F = ccc4f(0, 0, 0, 0); color4F = ccc4FFromccc3B(color3B); color4F = ccc4FFromccc4B(color4B); ccc4FEqual(color4F, ccc4F(1, 1, 1, 1)); color4B = ccc4BFromccc4F(color4F); color3B = ccWHITE; // in v3.0 Color3B color3B = Color3B(0, 0, 0); color3B.equals(Color3B(1, 1, 1)); Color4B color4B = Color4B(0, 0, 0, 0); Color4F color4F = Color4F(0, 0, 0, 0); color4F = Color4F(color3B); color4F = Color4F(color4B); color4F.equals(Color4F(1, 1, 1, 1)); color4B = Color4B(color4F); color3B = Color3B::WHITE; ``` ## deprecated functions and global variables | v2.1 names | v3.0 names | | ccp | Point | | ccpNeg | Point::- | | ccpAdd | Point::+ | | ccpSub | Point::- | | ccpMult | Point::* | | ccpMidpoint | Point::getMidpoint | | ccpDot | Point::dot | | ccpCrosss | Point::cross | | ccpPerp | Point::getPerp | | ccpRPerp | Point::getRPerp | | ccpProject | Point::project | | ccpRotate | Point::rotate | | ccpUnrotate | Point::unrotate | | ccpLengthSQ | Point::getLengthSq() | | ccpDistanceSQ | Point::getDistanceSq | | ccpLength | Point::getLength | | ccpDistance | Point::getDistance | | ccpNormalize | Point::normalize | | ccpForAngle | Point::forAngle | | ccpToAngle | Point::getAngle | | ccpClamp | Point::getClampPoint | | ccpFromSize | Point::Point | | ccpCompOp | Point::compOp | | ccpLerp | Point::lerp | | ccpFuzzyEqual | Point::fuzzyEqual | | ccpCompMult | Point::Point | | ccpAngleSigned | Point::getAngle | | ccpAngle | Point::getAngle | | ccpRotateByAngle | Point::rotateByAngle | | ccpLineInersect | Point::isLineIntersect | | ccpSegmentIntersect | Point::isSegmentIntersect | | ccpIntersectPoint | Point::getIntersectPoint | | CCPointMake | Point::Point | | CCSizeMake | Size::Size | | CCRectMake | Rect::Rect | | PointZero | Point::ZERO | | SizeZero | Size::ZERO | | RectZero | Rect::ZERO | | TiledGrid3DAction::tile | TiledGrid3DAction::getTile | | TiledGrid3DAction::originalTile | TiledGrid3DAction::getOriginalTile | | TiledGrid3D::tile | TiledGrid3D::getTile | | TiledGrid3D::originalTile | TiledGrid3D::getOriginalTile | | Grid3DAction::vertex | Grid3DAction::getVertex | | Grid3DAction::originalVertex | Grid3DAction::getOriginalVertex | | Grid3D::vertex | Grid3D::getVertex | | Grid3D::originalVertex | Grid3D::getOriginalVertex | | Configuration::sharedConfiguration | Configuration::getInstance | | Configuration::purgeConfiguration | Configuration::destroyInstance() | | Director::sharedDirector() | Director::getInstance() | | FileUtils::sharedFileUtils | FileUtils::getInstance | | FileUtils::purgeFileUtils | FileUtils::destroyInstance | | EGLView::sharedOpenGLView | EGLView::getInstance | | ShaderCache::sharedShaderCache | ShaderCache::getInstance | | ShaderCache::purgeSharedShaderCache | ShaderCache::destroyInstance | | AnimationCache::sharedAnimationCache | AnimationCache::getInstance | | AnimationCache::purgeSharedAnimationCache | AnimationCache::destroyInstance | | SpriteFrameCache::sharedSpriteFrameCache | SpriteFrameCache::getInstance | | SpriteFrameCache:: purgeSharedSpriteFrameCache | SpriteFrameCache::destroyInstance | | NotificationCenter::sharedNotificationCenter | NotificationCenter::getInstance | | NotificationCenter:: purgeNotificationCenter | NotificationCenter::destroyInstance | | Profiler::sharedProfiler | Profiler::getInstance | | UserDefault::sharedUserDefault | UserDefault::getInstance | | UserDefault::purgeSharedUserDefault | UserDefault::destroyInstance | | Application::sharedApplication | Application::getInstance | | ccc3() | Color3B() | | ccc3BEqual() | Color3B::equals() | | ccc4() | Color4B() | | ccc4FFromccc3B() | Color4F() | | ccc4f() | Color4F() | | ccc4FFromccc4B() | Color4F() | | ccc4BFromccc4F() | Color4B() | | ccc4FEqual() | Color4F::equals() | | ccWHITE | Color3B::WHITE | | ccYELLOW | Color3B::YELLOW | | ccBLUE | Color3B::BLUE | | ccGREEN | Color3B::GREEN | | ccRED | Color3B::RED | | ccMAGENTA | Color3B::MAGENTA | | ccBLACK | Color3B::BLACK | | ccORANGE | Color3B::ORANGE | | ccGRAY | Color3B::GRAY | | kBlendFuncDisable | BlendFunc::BLEND_FUNC_DISABLE | ## Changes in the Lua bindings ### Use bindings-generator tool for lua binding Only have to write an ini file for a module, don't have to write a lot of .pkg files ### Bind the classes with namespace to lua In previous, the lua binding can not bind classes that have the same class name but different namespaces. In order to resolve this issue, now the metatable name of a class is changed. For example, `CCNode` will be changed to `cc.Node`. This modification will affect some APIs as follows: | v2.x | v3.0 | | tolua_usertype(tolua_S,"CCNode") | tolua_usertype(tolua_S,"cc.Node") | | tolua_isusertable(tolua_S,1,"CCNode",0,&tolua_err | tolua_isusertable(tolua_S,1,"cc.Node",0,&tolua_err | | tolua_isusertype(tolua_S,1,"CCNode",0,&tolua_err) | tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err) | | toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCNode") | toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.Node") | | tolua_pushusertype(tolua_S,(void*)tolua_ret,"CCFileUtils") | tolua_pushusertype(tolua_S,(void*)tolua_ret,"cc.FileUtils") | | tolua.cast(pChildren[i + 1], "CCNode") | tolua.cast(pChildren[i + 1], "cc.Node") | ### Use ScriptHandlerMgr to manage the register and unregister of Lua function When we want to add register and unregister functions of Lua function for class, we need to change the declarative and defined files and then bind to Lua. In v3.0, we use the `ScriptHandlerMgr`. As an example, lets see the `MenuItem` class: In the 2.x version, we needed to add a declaration in the MenuItem header file: ```c++ virtual void registerScriptTapHandler(int nHandler); virtual void unregisterScriptTapHandler(void); ``` then implement them in the .cpp file. In the Lua script ,we use it as follow: ```lua menuItem:registerScriptTapHandler(luafunction) ``` In v3.0 version, we only need to add the `HandlerType` enum in the `ScriptHandlerMgr`, and the implementation in luascript as follow: ```lua ScriptHandlerMgr:getInstance():registerScriptHandler(menuItem, luafunction,cc.HANDLERTYPE_MENU_CLICKED) ``` ### Use "cc"、"ccs"、"ccui" and "sp" as module name The classes in the `cocos2d`、`cocos2d::extension`、`CocosDenshion` and `cocosbuilder` namespace were bound to lua in the `cc` module; The classes in the `cocos2d::gui` namespace were bound to lua in the `ccui` module; The classes in the `spine` namespace were bound to lua in the `sp` module; The classes in the `cocostudio` namespace were bound to lua in the `ccs` module. The main differences in the script are as follows: ```lua // v2.x CCSprite:create(s_pPathGrossini) CCEaseIn:create(createSimpleMoveBy(), 2.5) CCArmature:create("bear") ImageView:create() // v3.0 cc.Director:getInstance():getWinSize() cc.EaseIn:create(createSimpleMoveBy(), 2.5) ccs.Armature:create("bear") ccui.ImageView:create() ``` ### Deprecated funtions, tables and classes Add a lot of deprecate funtions、table and classes to support 2.x version as far as possible Note: `Rect does not support the origin and size member variables` ### Use the Lua table instead of the some structs and classes binding Point、Size、Rect、Color3b、Color4b、Color4F、AffineTransform、FontDefinition、Array、Dictionary、PointArray are not bound. The difference is as follow: ```lua // v2.x local pt = CCPoint(0 , 0) local rect = CCRect(0, 0, 0, 0) // v3.0 local pt = cc.p(0, 0) local rect = cc.rect(0,0,0,0) ``` Global functions about these classes are changed as follow: ```lua // in v2.x local pt = ccp(0,0) local color3B = ccc3(0, 0, 0) local color4B = ccc4(0, 0, 0, 0) // in v3.0 local pt = cc.p(0,0) local color3B = cc.c3b(0,0,0) local color4B = cc.c4b(0,0,0,0) ``` Through the funtions of the LuaBasicConversion file,they can be converted the Lua table when they are as a parameter in the bindings generator. ### Integrate more modules into lua In the version 3.0,more modules were bound to lua,specific as follows: ``` 1.physics 2.spine 3.XMLHttpRequest ``` The XMLHttpRequest and physics are in the "cc" module,and the spine is in the "sp" module. The related test cases located in: ``` physics ---> TestLua/PhysicsTest spine ---> TestLua/SpineTest XMLHttpRequest ---> TestLua/XMLHttpRequestTest ``` ## Known issues You can find all the known issues "here":http://www.cocos2d-x.org/projects/native/issues ================================================ FILE: cocos2d/docs/doxygen.config ================================================ # Doxyfile 1.8.5 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a double hash (##) is considered a comment and is placed in # front of the TAG it is preceding. # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all text # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv # built into libc) for the transcoding. See http://www.gnu.org/software/libiconv # for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the # project for which the documentation is generated. This name is used in the # title of most generated pages and in a few other places. # The default value is: My Project. PROJECT_NAME = cocos2d-x # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. PROJECT_NUMBER = 3.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify an logo or icon that is included in # the documentation. The maximum height of the logo should not exceed 55 pixels # and the maximum width should not exceed 200 pixels. Doxygen will copy the logo # to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. OUTPUT_DIRECTORY = ./ # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes # performance problems for the file system. # The default value is: NO. CREATE_SUBDIRS = YES # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # Possible values are: Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese- # Traditional, Croatian, Czech, Danish, Dutch, English, Esperanto, Farsi, # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en, # Korean, Korean-en, Latvian, Norwegian, Macedonian, Persian, Polish, # Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, # Turkish, Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. # The default value is: YES. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found # as the leading text of the brief description, will be stripped from the text # and the result, after processing the whole list, is used as the annotated # text. Otherwise, the brief description is used as-is. If left blank, the # following values are used ($name is automatically replaced with the name of # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. # The default value is: NO. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand # part of the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the path to # strip. # # Note that you can specify absolute paths here, but also relative paths, which # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler # using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief # description. If set to NO, the Javadoc-style will behave just like regular Qt- # style comments (thus requiring an explicit @brief command for a brief # description.) # The default value is: NO. JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus # requiring an explicit \brief command for a brief description.) # The default value is: NO. QT_AUTOBRIEF = YES # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as # a brief description. This used to be the default behavior. The new default is # to treat a multi-line C++ comment block as a detailed description. Set this # tag to YES if you prefer the old behavior instead. # # Note that setting this tag to YES also means that rational rose comments are # not recognized any more. # The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a # new page for each member. If set to NO, the documentation of a member will be # part of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: # name=value # For example adding # "sideeffect=@par Side Effects:\n" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all # members will be omitted, etc. # The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored # for that language. For instance, namespaces will be presented as packages, # qualified scopes will look different, etc. # The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, Javascript, # C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. # # Note For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. # The default value is: YES. MARKDOWN_SUPPORT = YES # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by by putting a % sign in front of the word # or globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this # tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); # versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # The default value is: NO. BUILTIN_STL_SUPPORT = YES # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make # doxygen to replace the get and set methods by a property in the documentation. # This will only work if the methods are indeed getting or setting a simple # type. If this is not the case, or you want to show the methods anyway, you # should set this option to NO. # The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent # subgrouping. Alternatively, this can be done per class using the # \nosubgrouping command. # The default value is: YES. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) # instead of on a separate page (for HTML and Man pages) or section (for LaTeX # and RTF). # # Note that this feature does not work in combination with # SEPARATE_MEMBER_PAGES. # The default value is: NO. INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in # the documentation of the scope in which they are defined (i.e. file, # namespace, or group documentation), provided this scope is documented. If set # to NO, structs, classes, and unions are shown on a separate page (for HTML and # Man pages) or section (for LaTeX and RTF). # The default value is: NO. INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically be # useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. TYPEDEF_HIDES_STRUCT = YES # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be # an expensive process and often the same symbol appears multiple times in the # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. # Note: This will also disable the warnings about undocumented members that are # normally produced when WARNINGS is set to YES. # The default value is: NO. EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined # locally in source files will be included in the documentation. If set to NO # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO only methods in the interface are # included. # The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace # are hidden. # The default value is: NO. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO these classes will be included in the various overviews. This option has # no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # (class|struct|union) declarations. If set to NO these declarations will be # included in the documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file # names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = YES # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member # name. If set to NO the members will appear in declaration order. # The default value is: NO. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and # destructors are listed first. If set to NO the constructors will appear in the # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief # member documentation. # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting # detailed member documentation. # The default value is: NO. SORT_MEMBERS_CTORS_1ST = YES # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will # be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the alphabetical # list. # The default value is: NO. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between # the prototype and the implementation of a member function even if there is # only one candidate or it is obvious which candidate to choose by doing a # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still # accept a match between prototype and implementation in such cases. # The default value is: NO. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the # todo list. This list is created by putting \todo commands in the # documentation. # The default value is: YES. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the # test list. This list is created by putting \test commands in the # documentation. # The default value is: YES. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if ... \endif and \cond # ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the # documentation. If the initializer consists of more lines than specified here # it will be hidden. Use a value of 0 to hide initializers completely. The # appearance of the value of individual variables and macros / defines can be # controlled using \showinitializer or \hideinitializer command in the # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES the list # will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command command input-file, where command is the value of the # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml # will be used as the name of the layout file. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool # to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. Do not use file names with spaces, bibtex cannot handle them. See # also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated to # standard output by doxygen. If QUIET is set to YES this implies that the # messages are off. # The default value is: NO. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. # The default value is: YES. WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters # in a documented function, or documenting parameters that don't exist or using # markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO doxygen will only warn about wrong or incomplete parameter # documentation, but not about the absence of documentation. # The default value is: NO. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with # spaces. # Note: If this tag is empty the current directory is searched. INPUT = ../cocos \ ../cocos/2d/platform \ ../docs \ ../extensions \ ../cocos/scripting/lua/bindings # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: http://www.gnu.org/software/libiconv) for the list of # possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank the # following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, # *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, # *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, # *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, # *.qsf, *.as and *.js. FILE_PATTERNS = *.h # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = ../cocos2dx/platform/third_party # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = .svn \ kazmath \ FontLabel \ proj.ios \ data_support \ image_support \ zip_support # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = ccArray \ ccCArray # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the # \image command). IMAGE_PATH = ./ # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command: # # # # where is the value of the INPUT_FILTER tag, and is the # name of an input file. Doxygen will then use the output that the filter # program writes to standard output. If FILTER_PATTERNS is specified, this tag # will be ignored. # # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: pattern=filter # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER ) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and # it is also possible to disable source filtering for a specific pattern using # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will be # generated. Documented entities will be cross-referenced with these sources. # # Note: To get rid of all source code in the generated output, make sure that # also VERBATIM_HEADERS is set to NO. # The default value is: NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. # The default value is: NO. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any # special comment blocks from generated source code fragments. Normal C, C++ and # Fortran comments will always remain visible. # The default value is: YES. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # function all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. # The default value is: NO. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set # to YES, then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, # brief description and links to the definition and documentation. Since this # will make the HTML file larger and loading of large files a bit slower, you # can opt to disable this feature. # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system # (see http://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global # - Enable SOURCE_BROWSER and USE_HTAGS in the config file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # # Doxygen will invoke htags (and that will in turn invoke gtags), so these # tools must be available from the command line (i.e. in the search path). # # The result: instead of the source browser generated by doxygen, the links to # source code will now point to the output of htags. # The default value is: NO. # This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a # verbatim copy of the header file for each class for which an include is # specified. Set to NO to disable this. # See also: Section \class. # The default value is: YES. VERBATIM_HEADERS = NO # If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the # clang parser (see: http://clang.llvm.org/) for more acurate parsing at the # cost of reduced performance. This can be particularly helpful with template # rich C++ code for which doxygen's built-in parser lacks the necessary type # information. # Note: The availability of this option depends on whether or not doxygen was # compiled with the --with-libclang option. # The default value is: NO. CLANG_ASSISTED_PARSING = NO # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all # compounds will be generated. Enable this if the project contains a lot of # classes, structs, unions or interfaces. # The default value is: YES. ALPHABETICAL_INDEX = YES # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. # Minimum value: 1, maximum value: 20, default value: 5. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). # The default value is: .html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a user-defined HTML header file for # each generated HTML page. If the tag is left blank doxygen will generate a # standard header. # # To get valid HTML the header file that includes any scripts and style sheets # that doxygen needs, which is dependent on the configuration options used (e.g. # the setting GENERATE_TREEVIEW). It is highly recommended to start with a # default header using # doxygen -w html new_header.html new_footer.html new_stylesheet.css # YourConfigFile # and then modify the file new_header.html. See also section "Doxygen usage" # for information on how to generate the default header that doxygen normally # uses. # Note: The header is subject to change so you typically have to regenerate the # default header when upgrading to a newer version of doxygen. For a description # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard # footer. See HTML_HEADER for more information on how to generate a default # footer and what special commands can be used inside the footer. See also # section "Doxygen usage" for information on how to generate the default footer # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. # See also section "Doxygen usage" for information on how to generate the style # sheet that doxygen normally uses. # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as # it is more robust and this tag (HTML_STYLESHEET) will in the future become # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user- # defined cascading style sheet that is included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the # standard style sheet and is therefor more robust against future updates. # Doxygen will copy the style sheet file to the output directory. For an example # see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that the # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the stylesheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see # http://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 # gradually make the output lighter, whereas values above 100 make the output # darker. The value divided by 100 is the actual gamma applied, so 80 represents # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not # change the gamma. # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this # to NO can help when comparing the output of multiple runs. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand # and collapse entries dynamically later on. Doxygen will expand the tree to # such a level that at most the specified number of entries are visible (unless # a fully collapsed tree already exceeds this amount). So setting the number of # entries 1 will produce a full collapsed tree by default. 0 is a special value # representing an infinite number of entries and will result in a full expanded # tree by default. # Minimum value: 0, maximum value: 9999, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development # environment (see: http://developer.apple.com/tools/xcode/), introduced with # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO # This tag determines the name of the docset feed. A documentation feed provides # an umbrella under which multiple documentation sets from a single provider # (such as a company or product suite) can be grouped. # The default value is: Doxygen generated docs. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. # The default value is: org.doxygen.Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop # (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML # files are now used as the Windows 98 help format, and will replace the old # Windows help format (.hlp) on all Windows platforms in the future. Compressed # HTML files also contain an index, a table of contents, and you can search for # words in the documentation. The HTML workshop also contains a viewer for # compressed HTML files. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO # The CHM_FILE tag can be used to specify the file name of the resulting .chm # file. You can add a path in front of the file if the result should not be # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler ( hhc.exe). If non-empty # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated ( # YES) or that it should be included in the master .chm file ( NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO # The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated ( # YES) or a normal table of contents ( NO) in the .chm file. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # (.qch) of the generated HTML documentation. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify # the file name of the resulting .qch file. The path specified is relative to # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace # (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual # Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To # install this plugin and make it available under the help contents menu in # Eclipse, the contents of the directory containing the HTML and XML files needs # to be copied into the plugins directory of eclipse. The name of the directory # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. # After copying Eclipse needs to be restarted before the help appears. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO # A unique identifier for the Eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have this # name. Each documentation set should have its own identifier. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project # If you want full control over the layout of the generated HTML pages it might # be necessary to disable the index and replace it with your own. The # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top # of each HTML page. A value of NO enables the index and the value YES disables # it. Since the tabs in the index contain the same information as the navigation # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag # value is set to YES, a side panel will be generated containing a tree-like # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has # the same information as the tab index, you could consider setting # DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = YES # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # # Note that a value of 0 will completely suppress the enum values from appearing # in the overview section. # Minimum value: 0, maximum value: 20, default value: 4. # This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used # to set the initial width (in pixels) of the frame in which the tree is shown. # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML # output directory to force them to be regenerated. # Minimum value: 8, maximum value: 50, default value: 10. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # # Note that when changing this option you need to delete any form_*.png files in # the HTML output directory before the changes have effect. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # http://www.mathjax.org) which uses client side Javascript for the rendering # instead of using prerendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the HTML # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from http://www.mathjax.org before deployment. # The default value is: http://cdn.mathjax.org/mathjax/latest. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://www.mathjax.org/mathjax # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and # should work on any modern browser. Note that when using HTML help # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) # there is already a search function so this one should typically be disabled. # For large projects the javascript based search engine can be slow, then # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to # search using the keyboard; to jump to the search box use + S # (what the is depends on the OS and browser, but it is typically # , /
Parameter Description
32bit32 bit architecture
64bit64 bit architecture
leLittle-endian architecture
beBig-endian architecture
fpuTarget has a hardware FPU
softfpsoftfp calling conventions
hardfphardfp calling conventions
eabiEABI variant of the standard ABI
winWindows variant of the standard ABI

ffi.os

Contains the target OS name. Same contents as jit.os.

ffi.arch

Contains the target architecture name. Same contents as jit.arch.

Methods for Callbacks

The C types for callbacks have some extra methods:

cb:free()

Free the resources associated with a callback. The associated Lua function is unanchored and may be garbage collected. The callback function pointer is no longer valid and must not be called anymore (it may be reused by a subsequently created callback).

cb:set(func)

Associate a new Lua function with a callback. The C type of the callback and the callback function pointer are unchanged.

This method is useful to dynamically switch the receiver of callbacks without creating a new callback each time and registering it again (e.g. with a GUI library).

Extended Standard Library Functions

The following standard library functions have been extended to work with cdata objects:

n = tonumber(cdata)

Converts a number cdata object to a double and returns it as a Lua number. This is particularly useful for boxed 64 bit integer values. Caveat: this conversion may incur a precision loss.

s = tostring(cdata)

Returns a string representation of the value of 64 bit integers ("nnnLL" or "nnnULL") or complex numbers ("re±imi"). Otherwise returns a string representation of the C type of a ctype object ("ctype<type>") or a cdata object ("cdata<type>: address"), unless you override it with a __tostring metamethod (see ffi.metatype()).

iter, obj, start = pairs(cdata)
iter, obj, start = ipairs(cdata)

Calls the __pairs or __ipairs metamethod of the corresponding ctype.

Extensions to the Lua Parser

The parser for Lua source code treats numeric literals with the suffixes LL or ULL as signed or unsigned 64 bit integers. Case doesn't matter, but uppercase is recommended for readability. It handles both decimal (42LL) and hexadecimal (0x2aLL) literals.

The imaginary part of complex numbers can be specified by suffixing number literals with i or I, e.g. 12.5i. Caveat: you'll need to use 1i to get an imaginary part with the value one, since i itself still refers to a variable named i.


================================================ FILE: cocos2d/external/lua/luajit/src/doc/ext_ffi_semantics.html ================================================ FFI Semantics

This page describes the detailed semantics underlying the FFI library and its interaction with both Lua and C code.

Given that the FFI library is designed to interface with C code and that declarations can be written in plain C syntax, it closely follows the C language semantics, wherever possible. Some minor concessions are needed for smoother interoperation with Lua language semantics.

Please don't be overwhelmed by the contents of this page — this is a reference and you may need to consult it, if in doubt. It doesn't hurt to skim this page, but most of the semantics "just work" as you'd expect them to work. It should be straightforward to write applications using the LuaJIT FFI for developers with a C or C++ background.

C Language Support

The FFI library has a built-in C parser with a minimal memory footprint. It's used by the ffi.* library functions to declare C types or external symbols.

It's only purpose is to parse C declarations, as found e.g. in C header files. Although it does evaluate constant expressions, it's not a C compiler. The body of inline C function definitions is simply ignored.

Also, this is not a validating C parser. It expects and accepts correctly formed C declarations, but it may choose to ignore bad declarations or show rather generic error messages. If in doubt, please check the input against your favorite C compiler.

The C parser complies to the C99 language standard plus the following extensions:

  • The '\e' escape in character and string literals.
  • The C99/C++ boolean type, declared with the keywords bool or _Bool.
  • Complex numbers, declared with the keywords complex or _Complex.
  • Two complex number types: complex (aka complex double) and complex float.
  • Vector types, declared with the GCC mode or vector_size attribute.
  • Unnamed ('transparent') struct/union fields inside a struct/union.
  • Incomplete enum declarations, handled like incomplete struct declarations.
  • Unnamed enum fields inside a struct/union. This is similar to a scoped C++ enum, except that declared constants are visible in the global namespace, too.
  • Scoped static const declarations inside a struct/union (from C++).
  • Zero-length arrays ([0]), empty struct/union, variable-length arrays (VLA, [?]) and variable-length structs (VLS, with a trailing VLA).
  • C++ reference types (int &x).
  • Alternate GCC keywords with '__', e.g. __const__.
  • GCC __attribute__ with the following attributes: aligned, packed, mode, vector_size, cdecl, fastcall, stdcall, thiscall.
  • The GCC __extension__ keyword and the GCC __alignof__ operator.
  • GCC __asm__("symname") symbol name redirection for function declarations.
  • MSVC keywords for fixed-length types: __int8, __int16, __int32 and __int64.
  • MSVC __cdecl, __fastcall, __stdcall, __thiscall, __ptr32, __ptr64, __declspec(align(n)) and #pragma pack.
  • All other GCC/MSVC-specific attributes are ignored.

The following C types are pre-defined by the C parser (like a typedef, except re-declarations will be ignored):

  • Vararg handling: va_list, __builtin_va_list, __gnuc_va_list.
  • From <stddef.h>: ptrdiff_t, size_t, wchar_t.
  • From <stdint.h>: int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t.

You're encouraged to use these types in preference to compiler-specific extensions or target-dependent standard types. E.g. char differs in signedness and long differs in size, depending on the target architecture and platform ABI.

The following C features are not supported:

  • A declaration must always have a type specifier; it doesn't default to an int type.
  • Old-style empty function declarations (K&R) are not allowed. All C functions must have a proper prototype declaration. A function declared without parameters (int foo();) is treated as a function taking zero arguments, like in C++.
  • The long double C type is parsed correctly, but there's no support for the related conversions, accesses or arithmetic operations.
  • Wide character strings and character literals are not supported.
  • See below for features that are currently not implemented.

C Type Conversion Rules

Conversions from C types to Lua objects

These conversion rules apply for read accesses to C types: indexing pointers, arrays or struct/union types; reading external variables or constant values; retrieving return values from C calls:

Input Conversion Output
int8_t, int16_tsign-ext int32_tdoublenumber
uint8_t, uint16_tzero-ext int32_tdoublenumber
int32_t, uint32_tdoublenumber
int64_t, uint64_tboxed value64 bit int cdata
double, floatdoublenumber
bool0 → false, otherwise trueboolean
enumboxed valueenum cdata
Complex numberboxed valuecomplex cdata
Vectorboxed valuevector cdata
Pointerboxed valuepointer cdata
Arrayboxed referencereference cdata
struct/unionboxed referencereference cdata

Bitfields are treated like their underlying type.

Reference types are dereferenced before a conversion can take place — the conversion is applied to the C type pointed to by the reference.

Conversions from Lua objects to C types

These conversion rules apply for write accesses to C types: indexing pointers, arrays or struct/union types; initializing cdata objects; casts to C types; writing to external variables; passing arguments to C calls:

Input Conversion Output
numberdouble
booleanfalse → 0, true → 1bool
nilNULL(void *)
lightuserdatalightuserdata address →(void *)
userdatauserdata payload →(void *)
io.* fileget FILE * handle →(void *)
stringmatch against enum constantenum
stringcopy string data + zero-byteint8_t[], uint8_t[]
stringstring data →const char[]
functioncreate callbackC function type
tabletable initializerArray
tabletable initializerstruct/union
cdatacdata payload →C type

If the result type of this conversion doesn't match the C type of the destination, the conversion rules between C types are applied.

Reference types are immutable after initialization ("no re-seating of references"). For initialization purposes or when passing values to reference parameters, they are treated like pointers. Note that unlike in C++, there's no way to implement automatic reference generation of variables under the Lua language semantics. If you want to call a function with a reference parameter, you need to explicitly pass a one-element array.

Conversions between C types

These conversion rules are more or less the same as the standard C conversion rules. Some rules only apply to casts, or require pointer or type compatibility:

Input Conversion Output
Signed integernarrow or sign-extendInteger
Unsigned integernarrow or zero-extendInteger
Integerrounddouble, float
double, floattrunc int32_tnarrow(u)int8_t, (u)int16_t
double, floattrunc(u)int32_t, (u)int64_t
double, floatroundfloat, double
Numbern == 0 → 0, otherwise 1bool
boolfalse → 0, true → 1Number
Complex numberconvert real partNumber
Numberconvert real part, imag = 0Complex number
Complex numberconvert real and imag partComplex number
Numberconvert scalar and replicateVector
Vectorcopy (same size)Vector
struct/uniontake base address (compat)Pointer
Arraytake base address (compat)Pointer
Functiontake function addressFunction pointer
Numberconvert via uintptr_t (cast)Pointer
Pointerconvert address (compat/cast)Pointer
Pointerconvert address (cast)Integer
Arrayconvert base address (cast)Integer
Arraycopy (compat)Array
struct/unioncopy (identical type)struct/union

Bitfields or enum types are treated like their underlying type.

Conversions not listed above will raise an error. E.g. it's not possible to convert a pointer to a complex number or vice versa.

Conversions for vararg C function arguments

The following default conversion rules apply when passing Lua objects to the variable argument part of vararg C functions:

Input Conversion Output
numberdouble
booleanfalse → 0, true → 1bool
nilNULL(void *)
userdatauserdata payload →(void *)
lightuserdatalightuserdata address →(void *)
stringstring data →const char *
float cdatadouble
Array cdatatake base addressElement pointer
struct/union cdatatake base addressstruct/union pointer
Function cdatatake function addressFunction pointer
Any other cdatano conversionC type

To pass a Lua object, other than a cdata object, as a specific type, you need to override the conversion rules: create a temporary cdata object with a constructor or a cast and initialize it with the value to pass:

Assuming x is a Lua number, here's how to pass it as an integer to a vararg function:

ffi.cdef[[
int printf(const char *fmt, ...);
]]
ffi.C.printf("integer value: %d\n", ffi.new("int", x))

If you don't do this, the default Lua number → double conversion rule applies. A vararg C function expecting an integer will see a garbled or uninitialized value.

Initializers

Creating a cdata object with ffi.new() or the equivalent constructor syntax always initializes its contents, too. Different rules apply, depending on the number of optional initializers and the C types involved:

  • If no initializers are given, the object is filled with zero bytes.
  • Scalar types (numbers and pointers) accept a single initializer. The Lua object is converted to the scalar C type.
  • Valarrays (complex numbers and vectors) are treated like scalars when a single initializer is given. Otherwise they are treated like regular arrays.
  • Aggregate types (arrays and structs) accept either a single cdata initializer of the same type (copy constructor), a single table initializer, or a flat list of initializers.
  • The elements of an array are initialized, starting at index zero. If a single initializer is given for an array, it's repeated for all remaining elements. This doesn't happen if two or more initializers are given: all remaining uninitialized elements are filled with zero bytes.
  • Byte arrays may also be initialized with a Lua string. This copies the whole string plus a terminating zero-byte. The copy stops early only if the array has a known, fixed size.
  • The fields of a struct are initialized in the order of their declaration. Uninitialized fields are filled with zero bytes.
  • Only the first field of a union can be initialized with a flat initializer.
  • Elements or fields which are aggregates themselves are initialized with a single initializer, but this may be a table initializer or a compatible aggregate.
  • Excess initializers cause an error.

Table Initializers

The following rules apply if a Lua table is used to initialize an Array or a struct/union:

  • If the table index [0] is non-nil, then the table is assumed to be zero-based. Otherwise it's assumed to be one-based.
  • Array elements, starting at index zero, are initialized one-by-one with the consecutive table elements, starting at either index [0] or [1]. This process stops at the first nil table element.
  • If exactly one array element was initialized, it's repeated for all the remaining elements. Otherwise all remaining uninitialized elements are filled with zero bytes.
  • The above logic only applies to arrays with a known fixed size. A VLA is only initialized with the element(s) given in the table. Depending on the use case, you may need to explicitly add a NULL or 0 terminator to a VLA.
  • A struct/union can be initialized in the order of the declaration of its fields. Each field is initialized with consecutive table elements, starting at either index [0] or [1]. This process stops at the first nil table element.
  • Otherwise, if neither index [0] nor [1] is present, a struct/union is initialized by looking up each field name (as a string key) in the table. Each non-nil value is used to initialize the corresponding field.
  • Uninitialized fields of a struct are filled with zero bytes, except for the trailing VLA of a VLS.
  • Initialization of a union stops after one field has been initialized. If no field has been initialized, the union is filled with zero bytes.
  • Elements or fields which are aggregates themselves are initialized with a single initializer, but this may be a nested table initializer (or a compatible aggregate).
  • Excess initializers for an array cause an error. Excess initializers for a struct/union are ignored. Unrelated table entries are ignored, too.

Example:

local ffi = require("ffi")

ffi.cdef[[
struct foo { int a, b; };
union bar { int i; double d; };
struct nested { int x; struct foo y; };
]]

ffi.new("int[3]", {})            --> 0, 0, 0
ffi.new("int[3]", {1})           --> 1, 1, 1
ffi.new("int[3]", {1,2})         --> 1, 2, 0
ffi.new("int[3]", {1,2,3})       --> 1, 2, 3
ffi.new("int[3]", {[0]=1})       --> 1, 1, 1
ffi.new("int[3]", {[0]=1,2})     --> 1, 2, 0
ffi.new("int[3]", {[0]=1,2,3})   --> 1, 2, 3
ffi.new("int[3]", {[0]=1,2,3,4}) --> error: too many initializers

ffi.new("struct foo", {})            --> a = 0, b = 0
ffi.new("struct foo", {1})           --> a = 1, b = 0
ffi.new("struct foo", {1,2})         --> a = 1, b = 2
ffi.new("struct foo", {[0]=1,2})     --> a = 1, b = 2
ffi.new("struct foo", {b=2})         --> a = 0, b = 2
ffi.new("struct foo", {a=1,b=2,c=3}) --> a = 1, b = 2  'c' is ignored

ffi.new("union bar", {})        --> i = 0, d = 0.0
ffi.new("union bar", {1})       --> i = 1, d = ?
ffi.new("union bar", {[0]=1,2}) --> i = 1, d = ?    '2' is ignored
ffi.new("union bar", {d=2})     --> i = ?, d = 2.0

ffi.new("struct nested", {1,{2,3}})     --> x = 1, y.a = 2, y.b = 3
ffi.new("struct nested", {x=1,y={2,3}}) --> x = 1, y.a = 2, y.b = 3

Operations on cdata Objects

All of the standard Lua operators can be applied to cdata objects or a mix of a cdata object and another Lua object. The following list shows the pre-defined operations.

Reference types are dereferenced before performing each of the operations below — the operation is applied to the C type pointed to by the reference.

The pre-defined operations are always tried first before deferring to a metamethod or index table (if any) for the corresponding ctype (except for __new). An error is raised if the metamethod lookup or index table lookup fails.

Indexing a cdata object

  • Indexing a pointer/array: a cdata pointer/array can be indexed by a cdata number or a Lua number. The element address is computed as the base address plus the number value multiplied by the element size in bytes. A read access loads the element value and converts it to a Lua object. A write access converts a Lua object to the element type and stores the converted value to the element. An error is raised if the element size is undefined or a write access to a constant element is attempted.
  • Dereferencing a struct/union field: a cdata struct/union or a pointer to a struct/union can be dereferenced by a string key, giving the field name. The field address is computed as the base address plus the relative offset of the field. A read access loads the field value and converts it to a Lua object. A write access converts a Lua object to the field type and stores the converted value to the field. An error is raised if a write access to a constant struct/union or a constant field is attempted. Scoped enum constants or static constants are treated like a constant field.
  • Indexing a complex number: a complex number can be indexed either by a cdata number or a Lua number with the values 0 or 1, or by the strings "re" or "im". A read access loads the real part ([0], .re) or the imaginary part ([1], .im) part of a complex number and converts it to a Lua number. The sub-parts of a complex number are immutable — assigning to an index of a complex number raises an error. Accessing out-of-bound indexes returns unspecified results, but is guaranteed not to trigger memory access violations.
  • Indexing a vector: a vector is treated like an array for indexing purposes, except the vector elements are immutable — assigning to an index of a vector raises an error.

A ctype object can be indexed with a string key, too. The only pre-defined operation is reading scoped constants of struct/union types. All other accesses defer to the corresponding metamethods or index tables (if any).

Note: since there's (deliberately) no address-of operator, a cdata object holding a value type is effectively immutable after initialization. The JIT compiler benefits from this fact when applying certain optimizations.

As a consequence, the elements of complex numbers and vectors are immutable. But the elements of an aggregate holding these types may be modified of course. I.e. you cannot assign to foo.c.im, but you can assign a (newly created) complex number to foo.c.

The JIT compiler implements strict aliasing rules: accesses to different types do not alias, except for differences in signedness (this applies even to char pointers, unlike C99). Type punning through unions is explicitly detected and allowed.

Calling a cdata object

  • Constructor: a ctype object can be called and used as a constructor. This is equivalent to ffi.new(ct, ...), unless a __new metamethod is defined. The __new metamethod is called with the ctype object plus any other arguments passed to the contructor. Note that you have to use ffi.new inside of it, since calling ct(...) would cause infinite recursion.
  • C function call: a cdata function or cdata function pointer can be called. The passed arguments are converted to the C types of the parameters given by the function declaration. Arguments passed to the variable argument part of vararg C function use special conversion rules. This C function is called and the return value (if any) is converted to a Lua object.
    On Windows/x86 systems, __stdcall functions are automatically detected and a function declared as __cdecl (the default) is silently fixed up after the first call.

Arithmetic on cdata objects

  • Pointer arithmetic: a cdata pointer/array and a cdata number or a Lua number can be added or subtracted. The number must be on the right hand side for a subtraction. The result is a pointer of the same type with an address plus or minus the number value multiplied by the element size in bytes. An error is raised if the element size is undefined.
  • Pointer difference: two compatible cdata pointers/arrays can be subtracted. The result is the difference between their addresses, divided by the element size in bytes. An error is raised if the element size is undefined or zero.
  • 64 bit integer arithmetic: the standard arithmetic operators (+ - * / % ^ and unary minus) can be applied to two cdata numbers, or a cdata number and a Lua number. If one of them is an uint64_t, the other side is converted to an uint64_t and an unsigned arithmetic operation is performed. Otherwise both sides are converted to an int64_t and a signed arithmetic operation is performed. The result is a boxed 64 bit cdata object.
    If one of the operands is an enum and the other operand is a string, the string is converted to the value of a matching enum constant before the above conversion.
    These rules ensure that 64 bit integers are "sticky". Any expression involving at least one 64 bit integer operand results in another one. The undefined cases for the division, modulo and power operators return 2LL ^ 63 or 2ULL ^ 63.
    You'll have to explicitly convert a 64 bit integer to a Lua number (e.g. for regular floating-point calculations) with tonumber(). But note this may incur a precision loss.

Comparisons of cdata objects

  • Pointer comparison: two compatible cdata pointers/arrays can be compared. The result is the same as an unsigned comparison of their addresses. nil is treated like a NULL pointer, which is compatible with any other pointer type.
  • 64 bit integer comparison: two cdata numbers, or a cdata number and a Lua number can be compared with each other. If one of them is an uint64_t, the other side is converted to an uint64_t and an unsigned comparison is performed. Otherwise both sides are converted to an int64_t and a signed comparison is performed.
    If one of the operands is an enum and the other operand is a string, the string is converted to the value of a matching enum constant before the above conversion.
  • Comparisons for equality/inequality never raise an error. Even incompatible pointers can be compared for equality by address. Any other incompatible comparison (also with non-cdata objects) treats the two sides as unequal.

cdata objects as table keys

Lua tables may be indexed by cdata objects, but this doesn't provide any useful semantics — cdata objects are unsuitable as table keys!

A cdata object is treated like any other garbage-collected object and is hashed and compared by its address for table indexing. Since there's no interning for cdata value types, the same value may be boxed in different cdata objects with different addresses. Thus t[1LL+1LL] and t[2LL] usually do not point to the same hash slot and they certainly do not point to the same hash slot as t[2].

It would seriously drive up implementation complexity and slow down the common case, if one were to add extra handling for by-value hashing and comparisons to Lua tables. Given the ubiquity of their use inside the VM, this is not acceptable.

There are three viable alternatives, if you really need to use cdata objects as keys:

  • If you can get by with the precision of Lua numbers (52 bits), then use tonumber() on a cdata number or combine multiple fields of a cdata aggregate to a Lua number. Then use the resulting Lua number as a key when indexing tables.
    One obvious benefit: t[tonumber(2LL)] does point to the same slot as t[2].
  • Otherwise use either tostring() on 64 bit integers or complex numbers or combine multiple fields of a cdata aggregate to a Lua string (e.g. with ffi.string()). Then use the resulting Lua string as a key when indexing tables.
  • Create your own specialized hash table implementation using the C types provided by the FFI library, just like you would in C code. Ultimately this may give much better performance than the other alternatives or what a generic by-value hash table could possibly provide.

Parameterized Types

To facilitate some abstractions, the two functions ffi.typeof and ffi.cdef support parameterized types in C declarations. Note: none of the other API functions taking a cdecl allow this.

Any place you can write a typedef name, an identifier or a number in a declaration, you can write $ (the dollar sign) instead. These placeholders are replaced in order of appearance with the arguments following the cdecl string:

-- Declare a struct with a parameterized field type and name:
ffi.cdef([[
typedef struct { $ $; } foo_t;
]], type1, name1)

-- Anonymous struct with dynamic names:
local bar_t = ffi.typeof("struct { int $, $; }", name1, name2)
-- Derived pointer type:
local bar_ptr_t = ffi.typeof("$ *", bar_t)

-- Parameterized dimensions work even where a VLA won't work:
local matrix_t = ffi.typeof("uint8_t[$][$]", width, height)

Caveat: this is not simple text substitution! A passed ctype or cdata object is treated like the underlying type, a passed string is considered an identifier and a number is considered a number. You must not mix this up: e.g. passing "int" as a string doesn't work in place of a type, you'd need to use ffi.typeof("int") instead.

The main use for parameterized types are libraries implementing abstract data types (» example), similar to what can be achieved with C++ template metaprogramming. Another use case are derived types of anonymous structs, which avoids pollution of the global struct namespace.

Please note that parameterized types are a nice tool and indispensable for certain use cases. But you'll want to use them sparingly in regular code, e.g. when all types are actually fixed.

Garbage Collection of cdata Objects

All explicitly (ffi.new(), ffi.cast() etc.) or implicitly (accessors) created cdata objects are garbage collected. You need to ensure to retain valid references to cdata objects somewhere on a Lua stack, an upvalue or in a Lua table while they are still in use. Once the last reference to a cdata object is gone, the garbage collector will automatically free the memory used by it (at the end of the next GC cycle).

Please note that pointers themselves are cdata objects, however they are not followed by the garbage collector. So e.g. if you assign a cdata array to a pointer, you must keep the cdata object holding the array alive as long as the pointer is still in use:

ffi.cdef[[
typedef struct { int *a; } foo_t;
]]

local s = ffi.new("foo_t", ffi.new("int[10]")) -- WRONG!

local a = ffi.new("int[10]") -- OK
local s = ffi.new("foo_t", a)
-- Now do something with 's', but keep 'a' alive until you're done.

Similar rules apply for Lua strings which are implicitly converted to "const char *": the string object itself must be referenced somewhere or it'll be garbage collected eventually. The pointer will then point to stale data, which may have already been overwritten. Note that string literals are automatically kept alive as long as the function containing it (actually its prototype) is not garbage collected.

Objects which are passed as an argument to an external C function are kept alive until the call returns. So it's generally safe to create temporary cdata objects in argument lists. This is a common idiom for passing specific C types to vararg functions.

Memory areas returned by C functions (e.g. from malloc()) must be manually managed, of course (or use ffi.gc()). Pointers to cdata objects are indistinguishable from pointers returned by C functions (which is one of the reasons why the GC cannot follow them).

Callbacks

The LuaJIT FFI automatically generates special callback functions whenever a Lua function is converted to a C function pointer. This associates the generated callback function pointer with the C type of the function pointer and the Lua function object (closure).

This can happen implicitly due to the usual conversions, e.g. when passing a Lua function to a function pointer argument. Or you can use ffi.cast() to explicitly cast a Lua function to a C function pointer.

Currently only certain C function types can be used as callback functions. Neither C vararg functions nor functions with pass-by-value aggregate argument or result types are supported. There are no restrictions for the kind of Lua functions that can be called from the callback — no checks for the proper number of arguments are made. The return value of the Lua function will be converted to the result type and an error will be thrown for invalid conversions.

It's allowed to throw errors across a callback invocation, but it's not advisable in general. Do this only if you know the C function, that called the callback, copes with the forced stack unwinding and doesn't leak resources.

One thing that's not allowed, is to let an FFI call into a C function get JIT-compiled, which in turn calls a callback, calling into Lua again. Usually this attempt is caught by the interpreter first and the C function is blacklisted for compilation.

However, this heuristic may fail under specific circumstances: e.g. a message polling function might not run Lua callbacks right away and the call gets JIT-compiled. If it later happens to call back into Lua (e.g. a rarely invoked error callback), you'll get a VM PANIC with the message "bad callback". Then you'll need to manually turn off JIT-compilation with jit.off() for the surrounding Lua function that invokes such a message polling function (or similar).

Callback resource handling

Callbacks take up resources — you can only have a limited number of them at the same time (500 - 1000, depending on the architecture). The associated Lua functions are anchored to prevent garbage collection, too.

Callbacks due to implicit conversions are permanent! There is no way to guess their lifetime, since the C side might store the function pointer for later use (typical for GUI toolkits). The associated resources cannot be reclaimed until termination:

ffi.cdef[[
typedef int (__stdcall *WNDENUMPROC)(void *hwnd, intptr_t l);
int EnumWindows(WNDENUMPROC func, intptr_t l);
]]

-- Implicit conversion to a callback via function pointer argument.
local count = 0
ffi.C.EnumWindows(function(hwnd, l)
  count = count + 1
  return true
end, 0)
-- The callback is permanent and its resources cannot be reclaimed!
-- Ok, so this may not be a problem, if you do this only once.

Note: this example shows that you must properly declare __stdcall callbacks on Windows/x86 systems. The calling convention cannot be automatically detected, unlike for __stdcall calls to Windows functions.

For some use cases it's necessary to free up the resources or to dynamically redirect callbacks. Use an explicit cast to a C function pointer and keep the resulting cdata object. Then use the cb:free() or cb:set() methods on the cdata object:

-- Explicitly convert to a callback via cast.
local count = 0
local cb = ffi.cast("WNDENUMPROC", function(hwnd, l)
  count = count + 1
  return true
end)

-- Pass it to a C function.
ffi.C.EnumWindows(cb, 0)
-- EnumWindows doesn't need the callback after it returns, so free it.

cb:free()
-- The callback function pointer is no longer valid and its resources
-- will be reclaimed. The created Lua closure will be garbage collected.

Callback performance

Callbacks are slow! First, the C to Lua transition itself has an unavoidable cost, similar to a lua_call() or lua_pcall(). Argument and result marshalling add to that cost. And finally, neither the C compiler nor LuaJIT can inline or optimize across the language barrier and hoist repeated computations out of a callback function.

Do not use callbacks for performance-sensitive work: e.g. consider a numerical integration routine which takes a user-defined function to integrate over. It's a bad idea to call a user-defined Lua function from C code millions of times. The callback overhead will be absolutely detrimental for performance.

It's considerably faster to write the numerical integration routine itself in Lua — the JIT compiler will be able to inline the user-defined function and optimize it together with its calling context, with very competitive performance.

As a general guideline: use callbacks only when you must, because of existing C APIs. E.g. callback performance is irrelevant for a GUI application, which waits for user input most of the time, anyway.

For new designs avoid push-style APIs: a C function repeatedly calling a callback for each result. Instead use pull-style APIs: call a C function repeatedly to get a new result. Calls from Lua to C via the FFI are much faster than the other way round. Most well-designed libraries already use pull-style APIs (read/write, get/put).

C Library Namespaces

A C library namespace is a special kind of object which allows access to the symbols contained in shared libraries or the default symbol namespace. The default ffi.C namespace is automatically created when the FFI library is loaded. C library namespaces for specific shared libraries may be created with the ffi.load() API function.

Indexing a C library namespace object with a symbol name (a Lua string) automatically binds it to the library. First the symbol type is resolved — it must have been declared with ffi.cdef. Then the symbol address is resolved by searching for the symbol name in the associated shared libraries or the default symbol namespace. Finally, the resulting binding between the symbol name, the symbol type and its address is cached. Missing symbol declarations or nonexistent symbol names cause an error.

This is what happens on a read access for the different kinds of symbols:

  • External functions: a cdata object with the type of the function and its address is returned.
  • External variables: the symbol address is dereferenced and the loaded value is converted to a Lua object and returned.
  • Constant values (static const or enum constants): the constant is converted to a Lua object and returned.

This is what happens on a write access:

  • External variables: the value to be written is converted to the C type of the variable and then stored at the symbol address.
  • Writing to constant variables or to any other symbol type causes an error, like any other attempted write to a constant location.

C library namespaces themselves are garbage collected objects. If the last reference to the namespace object is gone, the garbage collector will eventually release the shared library reference and remove all memory associated with the namespace. Since this may trigger the removal of the shared library from the memory of the running process, it's generally not safe to use function cdata objects obtained from a library if the namespace object may be unreferenced.

Performance notice: the JIT compiler specializes to the identity of namespace objects and to the strings used to index it. This effectively turns function cdata objects into constants. It's not useful and actually counter-productive to explicitly cache these function objects, e.g. local strlen = ffi.C.strlen. OTOH it is useful to cache the namespace itself, e.g. local C = ffi.C.

No Hand-holding!

The FFI library has been designed as a low-level library. The goal is to interface with C code and C data types with a minimum of overhead. This means you can do anything you can do from C: access all memory, overwrite anything in memory, call machine code at any memory address and so on.

The FFI library provides no memory safety, unlike regular Lua code. It will happily allow you to dereference a NULL pointer, to access arrays out of bounds or to misdeclare C functions. If you make a mistake, your application might crash, just like equivalent C code would.

This behavior is inevitable, since the goal is to provide full interoperability with C code. Adding extra safety measures, like bounds checks, would be futile. There's no way to detect misdeclarations of C functions, since shared libraries only provide symbol names, but no type information. Likewise there's no way to infer the valid range of indexes for a returned pointer.

Again: the FFI library is a low-level library. This implies it needs to be used with care, but it's flexibility and performance often outweigh this concern. If you're a C or C++ developer, it'll be easy to apply your existing knowledge. OTOH writing code for the FFI library is not for the faint of heart and probably shouldn't be the first exercise for someone with little experience in Lua, C or C++.

As a corollary of the above, the FFI library is not safe for use by untrusted Lua code. If you're sandboxing untrusted Lua code, you definitely don't want to give this code access to the FFI library or to any cdata object (except 64 bit integers or complex numbers). Any properly engineered Lua sandbox needs to provide safety wrappers for many of the standard Lua library functions — similar wrappers need to be written for high-level operations on FFI data types, too.

Current Status

The initial release of the FFI library has some limitations and is missing some features. Most of these will be fixed in future releases.

C language support is currently incomplete:

  • C declarations are not passed through a C pre-processor, yet.
  • The C parser is able to evaluate most constant expressions commonly found in C header files. However it doesn't handle the full range of C expression semantics and may fail for some obscure constructs.
  • static const declarations only work for integer types up to 32 bits. Neither declaring string constants nor floating-point constants is supported.
  • Packed struct bitfields that cross container boundaries are not implemented.
  • Native vector types may be defined with the GCC mode or vector_size attribute. But no operations other than loading, storing and initializing them are supported, yet.
  • The volatile type qualifier is currently ignored by compiled code.
  • ffi.cdef silently ignores all re-declarations.

The JIT compiler already handles a large subset of all FFI operations. It automatically falls back to the interpreter for unimplemented operations (you can check for this with the -jv command line option). The following operations are currently not compiled and may exhibit suboptimal performance, especially when used in inner loops:

  • Bitfield accesses and initializations.
  • Vector operations.
  • Table initializers.
  • Initialization of nested struct/union types.
  • Allocations of variable-length arrays or structs.
  • Allocations of C types with a size > 128 bytes or an alignment > 8 bytes.
  • Conversions from lightuserdata to void *.
  • Pointer differences for element sizes that are not a power of two.
  • Calls to C functions with aggregates passed or returned by value.
  • Calls to ctype metamethods which are not plain functions.
  • ctype __newindex tables and non-string lookups in ctype __index tables.
  • tostring() for cdata types.
  • Calls to ffi.cdef(), ffi.load() and ffi.metatype().

Other missing features:

  • Bit operations for 64 bit types.
  • Arithmetic for complex numbers.
  • Passing structs by value to vararg C functions.
  • C++ exception interoperability does not extend to C functions called via the FFI, if the call is compiled.

================================================ FILE: cocos2d/external/lua/luajit/src/doc/ext_ffi_tutorial.html ================================================ FFI Tutorial

This page is intended to give you an overview of the features of the FFI library by presenting a few use cases and guidelines.

This page makes no attempt to explain all of the FFI library, though. You'll want to have a look at the ffi.* API function reference and the FFI semantics to learn more.

Loading the FFI Library

The FFI library is built into LuaJIT by default, but it's not loaded and initialized by default. The suggested way to use the FFI library is to add the following to the start of every Lua file that needs one of its functions:

local ffi = require("ffi")

Please note this doesn't define an ffi variable in the table of globals — you really need to use the local variable. The require function ensures the library is only loaded once.

Note: If you want to experiment with the FFI from the interactive prompt of the command line executable, omit the local, as it doesn't preserve local variables across lines.

Accessing Standard System Functions

The following code explains how to access standard system functions. We slowly print two lines of dots by sleeping for 10 milliseconds after each dot:

 
①





②
③
④



⑤





⑥local ffi = require("ffi")
ffi.cdef[[
void Sleep(int ms);
int poll(struct pollfd *fds, unsigned long nfds, int timeout);
]]

local sleep
if ffi.os == "Windows" then
  function sleep(s)
    ffi.C.Sleep(s*1000)
  end
else
  function sleep(s)
    ffi.C.poll(nil, 0, s*1000)
  end
end

for i=1,160 do
  io.write("."); io.flush()
  sleep(0.01)
end
io.write("\n")

Here's the step-by-step explanation:

This defines the C library functions we're going to use. The part inside the double-brackets (in green) is just standard C syntax. You can usually get this info from the C header files or the documentation provided by each C library or C compiler.

The difficulty we're facing here, is that there are different standards to choose from. Windows has a simple Sleep() function. On other systems there are a variety of functions available to achieve sub-second sleeps, but with no clear consensus. Thankfully poll() can be used for this task, too, and it's present on most non-Windows systems. The check for ffi.os makes sure we use the Windows-specific function only on Windows systems.

Here we're wrapping the call to the C function in a Lua function. This isn't strictly necessary, but it's helpful to deal with system-specific issues only in one part of the code. The way we're wrapping it ensures the check for the OS is only done during initialization and not for every call.

A more subtle point is that we defined our sleep() function (for the sake of this example) as taking the number of seconds, but accepting fractional seconds. Multiplying this by 1000 gets us milliseconds, but that still leaves it a Lua number, which is a floating-point value. Alas, the Sleep() function only accepts an integer value. Luckily for us, the FFI library automatically performs the conversion when calling the function (truncating the FP value towards zero, like in C).

Some readers will notice that Sleep() is part of KERNEL32.DLL and is also a stdcall function. So how can this possibly work? The FFI library provides the ffi.C default C library namespace, which allows calling functions from the default set of libraries, like a C compiler would. Also, the FFI library automatically detects stdcall functions, so you don't need to declare them as such.

The poll() function takes a couple more arguments we're not going to use. You can simply use nil to pass a NULL pointer and 0 for the nfds parameter. Please note that the number 0 does not convert to a pointer value, unlike in C++. You really have to pass pointers to pointer arguments and numbers to number arguments.

The page on FFI semantics has all of the gory details about conversions between Lua objects and C types. For the most part you don't have to deal with this, as it's performed automatically and it's carefully designed to bridge the semantic differences between Lua and C.

Now that we have defined our own sleep() function, we can just call it from plain Lua code. That wasn't so bad, huh? Turning these boring animated dots into a fascinating best-selling game is left as an exercise for the reader. :-)

Accessing the zlib Compression Library

The following code shows how to access the zlib compression library from Lua code. We'll define two convenience wrapper functions that take a string and compress or uncompress it to another string:

 
①






②


③

④


⑤


⑥







⑦local ffi = require("ffi")
ffi.cdef[[
unsigned long compressBound(unsigned long sourceLen);
int compress2(uint8_t *dest, unsigned long *destLen,
	      const uint8_t *source, unsigned long sourceLen, int level);
int uncompress(uint8_t *dest, unsigned long *destLen,
	       const uint8_t *source, unsigned long sourceLen);
]]
local zlib = ffi.load(ffi.os == "Windows" and "zlib1" or "z")

local function compress(txt)
  local n = zlib.compressBound(#txt)
  local buf = ffi.new("uint8_t[?]", n)
  local buflen = ffi.new("unsigned long[1]", n)
  local res = zlib.compress2(buf, buflen, txt, #txt, 9)
  assert(res == 0)
  return ffi.string(buf, buflen[0])
end

local function uncompress(comp, n)
  local buf = ffi.new("uint8_t[?]", n)
  local buflen = ffi.new("unsigned long[1]", n)
  local res = zlib.uncompress(buf, buflen, comp, #comp)
  assert(res == 0)
  return ffi.string(buf, buflen[0])
end

-- Simple test code.
local txt = string.rep("abcd", 1000)
print("Uncompressed size: ", #txt)
local c = compress(txt)
print("Compressed size: ", #c)
local txt2 = uncompress(c, #txt)
assert(txt2 == txt)

Here's the step-by-step explanation:

This defines some of the C functions provided by zlib. For the sake of this example, some type indirections have been reduced and it uses the pre-defined fixed-size integer types, while still adhering to the zlib API/ABI.

This loads the zlib shared library. On POSIX systems it's named libz.so and usually comes pre-installed. Since ffi.load() automatically adds any missing standard prefixes/suffixes, we can simply load the "z" library. On Windows it's named zlib1.dll and you'll have to download it first from the » zlib site. The check for ffi.os makes sure we pass the right name to ffi.load().

First, the maximum size of the compression buffer is obtained by calling the zlib.compressBound function with the length of the uncompressed string. The next line allocates a byte buffer of this size. The [?] in the type specification indicates a variable-length array (VLA). The actual number of elements of this array is given as the 2nd argument to ffi.new().

This may look strange at first, but have a look at the declaration of the compress2 function from zlib: the destination length is defined as a pointer! This is because you pass in the maximum buffer size and get back the actual length that was used.

In C you'd pass in the address of a local variable (&buflen). But since there's no address-of operator in Lua, we'll just pass in a one-element array. Conveniently it can be initialized with the maximum buffer size in one step. Calling the actual zlib.compress2 function is then straightforward.

We want to return the compressed data as a Lua string, so we'll use ffi.string(). It needs a pointer to the start of the data and the actual length. The length has been returned in the buflen array, so we'll just get it from there.

Note that since the function returns now, the buf and buflen variables will eventually be garbage collected. This is fine, because ffi.string() has copied the contents to a newly created (interned) Lua string. If you plan to call this function lots of times, consider reusing the buffers and/or handing back the results in buffers instead of strings. This will reduce the overhead for garbage collection and string interning.

The uncompress functions does the exact opposite of the compress function. The compressed data doesn't include the size of the original string, so this needs to be passed in. Otherwise no surprises here.

The code, that makes use of the functions we just defined, is just plain Lua code. It doesn't need to know anything about the LuaJIT FFI — the convenience wrapper functions completely hide it.

One major advantage of the LuaJIT FFI is that you are now able to write those wrappers in Lua. And at a fraction of the time it would cost you to create an extra C module using the Lua/C API. Many of the simpler C functions can probably be used directly from your Lua code, without any wrappers.

Side note: the zlib API uses the long type for passing lengths and sizes around. But all those zlib functions actually only deal with 32 bit values. This is an unfortunate choice for a public API, but may be explained by zlib's history — we'll just have to deal with it.

First, you should know that a long is a 64 bit type e.g. on POSIX/x64 systems, but a 32 bit type on Windows/x64 and on 32 bit systems. Thus a long result can be either a plain Lua number or a boxed 64 bit integer cdata object, depending on the target system.

Ok, so the ffi.* functions generally accept cdata objects wherever you'd want to use a number. That's why we get a away with passing n to ffi.string() above. But other Lua library functions or modules don't know how to deal with this. So for maximum portability one needs to use tonumber() on returned long results before passing them on. Otherwise the application might work on some systems, but would fail in a POSIX/x64 environment.

Defining Metamethods for a C Type

The following code explains how to define metamethods for a C type. We define a simple point type and add some operations to it:

 
①



②

③

④



⑤

⑥local ffi = require("ffi")
ffi.cdef[[
typedef struct { double x, y; } point_t;
]]

local point
local mt = {
  __add = function(a, b) return point(a.x+b.x, a.y+b.y) end,
  __len = function(a) return math.sqrt(a.x*a.x + a.y*a.y) end,
  __index = {
    area = function(a) return a.x*a.x + a.y*a.y end,
  },
}
point = ffi.metatype("point_t", mt)

local a = point(3, 4)
print(a.x, a.y)  --> 3  4
print(#a)        --> 5
print(a:area())  --> 25
local b = a + point(0.5, 8)
print(#b)        --> 12.5

Here's the step-by-step explanation:

This defines the C type for a two-dimensional point object.

We have to declare the variable holding the point constructor first, because it's used inside of a metamethod.

Let's define an __add metamethod which adds the coordinates of two points and creates a new point object. For simplicity, this function assumes that both arguments are points. But it could be any mix of objects, if at least one operand is of the required type (e.g. adding a point plus a number or vice versa). Our __len metamethod returns the distance of a point to the origin.

If we run out of operators, we can define named methods, too. Here the __index table defines an area function. For custom indexing needs, one might want to define __index and __newindex functions instead.

This associates the metamethods with our C type. This only needs to be done once. For convenience, a constructor is returned by ffi.metatype(). We're not required to use it, though. The original C type can still be used e.g. to create an array of points. The metamethods automatically apply to any and all uses of this type.

Please note that the association with a metatable is permanent and the metatable must not be modified afterwards! Ditto for the __index table.

Here are some simple usage examples for the point type and their expected results. The pre-defined operations (such as a.x) can be freely mixed with the newly defined metamethods. Note that area is a method and must be called with the Lua syntax for methods: a:area(), not a.area().

The C type metamethod mechanism is most useful when used in conjunction with C libraries that are written in an object-oriented style. Creators return a pointer to a new instance and methods take an instance pointer as the first argument. Sometimes you can just point __index to the library namespace and __gc to the destructor and you're done. But often enough you'll want to add convenience wrappers, e.g. to return actual Lua strings or when returning multiple values.

Some C libraries only declare instance pointers as an opaque void * type. In this case you can use a fake type for all declarations, e.g. a pointer to a named (incomplete) struct will do: typedef struct foo_type *foo_handle. The C side doesn't know what you declare with the LuaJIT FFI, but as long as the underlying types are compatible, everything still works.

Translating C Idioms

Here's a list of common C idioms and their translation to the LuaJIT FFI:

Idiom C code Lua code
Pointer dereference
int *p;
x = *p;
*p = y;
x = p[0]
p[0] = y
Pointer indexing
int i, *p;
x = p[i];
p[i+1] = y;
x = p[i]
p[i+1] = y
Array indexing
int i, a[];
x = a[i];
a[i+1] = y;
x = a[i]
a[i+1] = y
struct/union dereference
struct foo s;
x = s.field;
s.field = y;
x = s.field
s.field = y
struct/union pointer deref.
struct foo *sp;
x = sp->field;
sp->field = y;
x = s.field
s.field = y
Pointer arithmetic
int i, *p;
x = p + i;
y = p - i;
x = p + i
y = p - i
Pointer difference
int *p1, *p2;
x = p1 - p2;x = p1 - p2
Array element pointer
int i, a[];
x = &a[i];x = a+i
Cast pointer to address
int *p;
x = (intptr_t)p;x = tonumber(
 ffi.cast("intptr_t",
          p))
Functions with outargs
void foo(int *inoutlen);
int len = x;
foo(&len);
y = len;
local len =
  ffi.new("int[1]", x)
foo(len)
y = len[0]
Vararg conversions
int printf(char *fmt, ...);
printf("%g", 1.0);
printf("%d", 1);
 
printf("%g", 1);
printf("%d",
  ffi.new("int", 1))

To Cache or Not to Cache

It's a common Lua idiom to cache library functions in local variables or upvalues, e.g.:

local byte, char = string.byte, string.char
local function foo(x)
  return char(byte(x)+1)
end

This replaces several hash-table lookups with a (faster) direct use of a local or an upvalue. This is less important with LuaJIT, since the JIT compiler optimizes hash-table lookups a lot and is even able to hoist most of them out of the inner loops. It can't eliminate all of them, though, and it saves some typing for often-used functions. So there's still a place for this, even with LuaJIT.

The situation is a bit different with C function calls via the FFI library. The JIT compiler has special logic to eliminate all of the lookup overhead for functions resolved from a C library namespace! Thus it's not helpful and actually counter-productive to cache individual C functions like this:

local funca, funcb = ffi.C.funcb, ffi.C.funcb -- Not helpful!
local function foo(x, n)
  for i=1,n do funcb(funca(x, i), 1) end
end

This turns them into indirect calls and generates bigger and slower machine code. Instead you'll want to cache the namespace itself and rely on the JIT compiler to eliminate the lookups:

local C = ffi.C          -- Instead use this!
local function foo(x, n)
  for i=1,n do C.funcb(C.funca(x, i), 1) end
end

This generates both shorter and faster code. So don't cache C functions, but do cache namespaces! Most often the namespace is already in a local variable at an outer scope, e.g. from local lib = ffi.load(...). Note that copying it to a local variable in the function scope is unnecessary.


================================================ FILE: cocos2d/external/lua/luajit/src/doc/ext_jit.html ================================================ jit.* Library

The functions in this built-in module control the behavior of the JIT compiler engine. Note that JIT-compilation is fully automatic — you probably won't need to use any of the following functions unless you have special needs.

jit.on()
jit.off()

Turns the whole JIT compiler on (default) or off.

These functions are typically used with the command line options -j on or -j off.

jit.flush()

Flushes the whole cache of compiled code.

jit.on(func|true [,true|false])
jit.off(func|true [,true|false])
jit.flush(func|true [,true|false])

jit.on enables JIT compilation for a Lua function (this is the default).

jit.off disables JIT compilation for a Lua function and flushes any already compiled code from the code cache.

jit.flush flushes the code, but doesn't affect the enable/disable status.

The current function, i.e. the Lua function calling this library function, can also be specified by passing true as the first argument.

If the second argument is true, JIT compilation is also enabled, disabled or flushed recursively for all sub-functions of a function. With false only the sub-functions are affected.

The jit.on and jit.off functions only set a flag which is checked when the function is about to be compiled. They do not trigger immediate compilation.

Typical usage is jit.off(true, true) in the main chunk of a module to turn off JIT compilation for the whole module for debugging purposes.

jit.flush(tr)

Flushes the root trace, specified by its number, and all of its side traces from the cache. The code for the trace will be retained as long as there are any other traces which link to it.

status, ... = jit.status()

Returns the current status of the JIT compiler. The first result is either true or false if the JIT compiler is turned on or off. The remaining results are strings for CPU-specific features and enabled optimizations.

jit.version

Contains the LuaJIT version string.

jit.version_num

Contains the version number of the LuaJIT core. Version xx.yy.zz is represented by the decimal number xxyyzz.

jit.os

Contains the target OS name: "Windows", "Linux", "OSX", "BSD", "POSIX" or "Other".

jit.arch

Contains the target architecture name: "x86", "x64" or "ppcspe".

jit.opt.* — JIT compiler optimization control

This sub-module provides the backend for the -O command line option.

You can also use it programmatically, e.g.:

jit.opt.start(2) -- same as -O2
jit.opt.start("-dce")
jit.opt.start("hotloop=10", "hotexit=2")

Unlike in LuaJIT 1.x, the module is built-in and optimization is turned on by default! It's no longer necessary to run require("jit.opt").start(), which was one of the ways to enable optimization.

jit.util.* — JIT compiler introspection

This sub-module holds functions to introspect the bytecode, generated traces, the IR and the generated machine code. The functionality provided by this module is still in flux and therefore undocumented.

The debug modules -jbc, -jv and -jdump make extensive use of these functions. Please check out their source code, if you want to know more.


================================================ FILE: cocos2d/external/lua/luajit/src/doc/extensions.html ================================================ Extensions

LuaJIT is fully upwards-compatible with Lua 5.1. It supports all » standard Lua library functions and the full set of » Lua/C API functions.

LuaJIT is also fully ABI-compatible to Lua 5.1 at the linker/dynamic loader level. This means you can compile a C module against the standard Lua headers and load the same shared library from either Lua or LuaJIT.

LuaJIT extends the standard Lua VM with new functionality and adds several extension modules. Please note this page is only about functional enhancements and not about performance enhancements, such as the optimized VM, the faster interpreter or the JIT compiler.

Extensions Modules

LuaJIT comes with several built-in extension modules:

bit.* — Bitwise operations

LuaJIT supports all bitwise operations as defined by » Lua BitOp:

bit.tobit  bit.tohex  bit.bnot    bit.band bit.bor  bit.bxor
bit.lshift bit.rshift bit.arshift bit.rol  bit.ror  bit.bswap

This module is a LuaJIT built-in — you don't need to download or install Lua BitOp. The Lua BitOp site has full documentation for all » Lua BitOp API functions.

Please make sure to require the module before using any of its functions:

local bit = require("bit")

An already installed Lua BitOp module is ignored by LuaJIT. This way you can use bit operations from both Lua and LuaJIT on a shared installation.

ffi.* — FFI library

The FFI library allows calling external C functions and the use of C data structures from pure Lua code.

jit.* — JIT compiler control

The functions in this module control the behavior of the JIT compiler engine.

C API extensions

LuaJIT adds some extra functions to the Lua/C API.

Enhanced Standard Library Functions

xpcall(f, err [,args...]) passes arguments

Unlike the standard implementation in Lua 5.1, xpcall() passes any arguments after the error function to the function which is called in a protected context.

loadfile() etc. handle UTF-8 source code

Non-ASCII characters are handled transparently by the Lua source code parser. This allows the use of UTF-8 characters in identifiers and strings. A UTF-8 BOM is skipped at the start of the source code.

tostring() etc. canonicalize NaN and ±Inf

All number-to-string conversions consistently convert non-finite numbers to the same strings on all platforms. NaN results in "nan", positive infinity results in "inf" and negative infinity results in "-inf".

tonumber() etc. use builtin string to number conversion

All string-to-number conversions consistently convert integer and floating-point inputs in decimal and hexadecimal on all platforms. strtod() is not used anymore, which avoids numerous problems with poor C library implementations. The builtin conversion function provides full precision according to the IEEE-754 standard, it works independently of the current locale and it supports hex floating-point numbers (e.g. 0x1.5p-3).

string.dump(f [,strip]) generates portable bytecode

An extra argument has been added to string.dump(). If set to true, 'stripped' bytecode without debug information is generated. This speeds up later bytecode loading and reduces memory usage. See also the -b command line option.

The generated bytecode is portable and can be loaded on any architecture that LuaJIT supports, independent of word size or endianess. However the bytecode compatibility versions must match. Bytecode stays compatible for dot releases (x.y.0 → x.y.1), but may change with major or minor releases (2.0 → 2.1) or between any beta release. Foreign bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded.

Enhanced PRNG for math.random()

LuaJIT uses a Tausworthe PRNG with period 2^223 to implement math.random() and math.randomseed(). The quality of the PRNG results is much superior compared to the standard Lua implementation which uses the platform-specific ANSI rand().

The PRNG generates the same sequences from the same seeds on all platforms and makes use of all bits in the seed argument. math.random() without arguments generates 52 pseudo-random bits for every call. The result is uniformly distributed between 0.0 and 1.0. It's correctly scaled up and rounded for math.random(n [,m]) to preserve uniformity.

io.* functions handle 64 bit file offsets

The file I/O functions in the standard io.* library handle 64 bit file offsets. In particular this means it's possible to open files larger than 2 Gigabytes and to reposition or obtain the current file position for offsets beyond 2 GB (fp:seek() method).

debug.* functions identify metamethods

debug.getinfo() and lua_getinfo() also return information about invoked metamethods. The namewhat field is set to "metamethod" and the name field has the name of the corresponding metamethod (e.g. "__index").

Fully Resumable VM

The LuaJIT VM is fully resumable. This means you can yield from a coroutine even across contexts, where this would not possible with the standard Lua 5.1 VM: e.g. you can yield across pcall() and xpcall(), across iterators and across metamethods.

Extensions from Lua 5.2

LuaJIT supports some language and library extensions from Lua 5.2. Features that are unlikely to break existing code are unconditionally enabled:

  • goto and ::labels::.
  • Hex escapes '\x3F' and '\*' escape in strings.
  • load(string|reader, chunkname [,mode [,env]]). loadstring() is an alias.
  • math.log(x [,base]).
  • string.rep(s, n [,sep]).
  • string.format(): %q reversible. %s checks __tostring. %a and "%A added.
  • String matching pattern %g added.
  • io.read("*L").
  • io.lines() and file:lines() process io.read() options.
  • os.exit(status|true|false [,close]).
  • package.searchpath(name, path [, sep [, rep]]).
  • package.loadlib(name, "*").
  • debug.getinfo() returns nparams and isvararg for option "u".
  • debug.getlocal() accepts function instead of level.
  • debug.getlocal() and debug.setlocal() accept negative indexes for varargs.
  • debug.getupvalue() and debug.setupvalue() handle C functions.
  • debug.upvalueid() and debug.upvaluejoin().
  • Command line option -E.
  • Command line checks __tostring for errors.

Other features are only enabled, if LuaJIT is built with -DLUAJIT_ENABLE_LUA52COMPAT:

  • goto is a keyword and not a valid variable name anymore.
  • break can be placed anywhere. Empty statements (;;) are allowed.
  • __lt, __le are invoked for mixed types.
  • __len for tables. rawlen() library function.
  • pairs() and ipairs() check for __pairs and __ipairs.
  • coroutine.running() returns two results.
  • table.pack() and table.unpack() (same as unpack()).
  • io.write() and file:write() return file handle instead of true.
  • os.execute() and pipe:close() return detailed exit status.
  • debug.setmetatable() returns object.
  • debug.getuservalue() and debug.setuservalue().
  • Remove math.mod(), string.gfind().

Note: this provides only partial compatibility with Lua 5.2 at the language and Lua library level. LuaJIT is API+ABI-compatible with Lua 5.1, which prevents implementing features that would otherwise break the Lua/C API and ABI (e.g. _ENV).

C++ Exception Interoperability

LuaJIT has built-in support for interoperating with C++ exceptions. The available range of features depends on the target platform and the toolchain used to compile LuaJIT:

Platform Compiler Interoperability
POSIX/x64, DWARF2 unwinding GCC 4.3+ Full
Other platforms, DWARF2 unwinding GCC Limited
Windows/x64 MSVC or WinSDK Full
Windows/x86 Any No
Other platforms Other compilers No

Full interoperability means:

  • C++ exceptions can be caught on the Lua side with pcall(), lua_pcall() etc.
  • C++ exceptions will be converted to the generic Lua error "C++ exception", unless you use the C call wrapper feature.
  • It's safe to throw C++ exceptions across non-protected Lua frames on the C stack. The contents of the C++ exception object pass through unmodified.
  • Lua errors can be caught on the C++ side with catch(...). The corresponding Lua error message can be retrieved from the Lua stack.
  • Throwing Lua errors across C++ frames is safe. C++ destructors will be called.

Limited interoperability means:

  • C++ exceptions can be caught on the Lua side with pcall(), lua_pcall() etc.
  • C++ exceptions will be converted to the generic Lua error "C++ exception", unless you use the C call wrapper feature.
  • C++ exceptions will be caught by non-protected Lua frames and are rethrown as a generic Lua error. The C++ exception object will be destroyed.
  • Lua errors cannot be caught on the C++ side.
  • Throwing Lua errors across C++ frames will not call C++ destructors.

No interoperability means:

  • It's not safe to throw C++ exceptions across Lua frames.
  • C++ exceptions cannot be caught on the Lua side.
  • Lua errors cannot be caught on the C++ side.
  • Throwing Lua errors across C++ frames will not call C++ destructors.
  • Additionally, on Windows/x86 with SEH-based C++ exceptions: it's not safe to throw a Lua error across any frames containing a C++ function with any try/catch construct or using variables with (implicit) destructors. This also applies to any functions which may be inlined in such a function. It doesn't matter whether lua_error() is called inside or outside of a try/catch or whether any object actually needs to be destroyed: the SEH chain is corrupted and this will eventually lead to the termination of the process.

================================================ FILE: cocos2d/external/lua/luajit/src/doc/faq.html ================================================ Frequently Asked Questions (FAQ)
Q: Where can I learn more about LuaJIT and Lua?
Q: Where can I learn more about the compiler technology used by LuaJIT?
I'm planning to write more documentation about the internals of LuaJIT. In the meantime, please use the following Google Scholar searches to find relevant papers:
Search for: » Trace Compiler
Search for: » JIT Compiler
Search for: » Dynamic Language Optimizations
Search for: » SSA Form
Search for: » Linear Scan Register Allocation
Here is a list of the » innovative features in LuaJIT.
And, you know, reading the source is of course the only way to enlightenment. :-)
Q: Why do I get this error: "attempt to index global 'arg' (a nil value)"?
Q: My vararg functions fail after switching to LuaJIT!
LuaJIT is compatible to the Lua 5.1 language standard. It doesn't support the implicit arg parameter for old-style vararg functions from Lua 5.0.
Please convert your code to the » Lua 5.1 vararg syntax.
Q: Why do I get this error: "bad FPU precision"?
Q: I get weird behavior after initializing Direct3D.
Q: Some FPU operations crash after I load a Delphi DLL.
DirectX/Direct3D (up to version 9) sets the x87 FPU to single-precision mode by default. This violates the Windows ABI and interferes with the operation of many programs — LuaJIT is affected, too. Please make sure you always use the D3DCREATE_FPU_PRESERVE flag when initializing Direct3D.
Direct3D version 10 or higher do not show this behavior anymore. Consider testing your application with older versions, too.
Similarly, the Borland/Delphi runtime modifies the FPU control word and enables FP exceptions. Of course this violates the Windows ABI, too. Please check the Delphi docs for the Set8087CW method.
Q: Sometimes Ctrl-C fails to stop my Lua program. Why?
The interrupt signal handler sets a Lua debug hook. But this is currently ignored by compiled code (this will eventually be fixed). If your program is running in a tight loop and never falls back to the interpreter, the debug hook never runs and can't throw the "interrupted!" error.
In the meantime you have to press Ctrl-C twice to get stop your program. That's similar to when it's stuck running inside a C function under the Lua interpreter.
Q: Why doesn't my favorite power-patch for Lua apply against LuaJIT?
Because it's a completely redesigned VM and has very little code in common with Lua anymore. Also, if the patch introduces changes to the Lua semantics, these would need to be reflected everywhere in the VM, from the interpreter up to all stages of the compiler.
Please use only standard Lua language constructs. For many common needs you can use source transformations or use wrapper or proxy functions. The compiler will happily optimize away such indirections.
Q: Lua runs everywhere. Why doesn't LuaJIT support my CPU?
Because it's a compiler — it needs to generate native machine code. This means the code generator must be ported to each architecture. And the fast interpreter is written in assembler and must be ported, too. This is quite an undertaking.
The install documentation shows the supported architectures. Other architectures will follow based on sufficient user demand and/or sponsoring.
Q: When will feature X be added? When will the next version be released?
When it's ready.
C'mon, it's open source — I'm doing it on my own time and you're getting it for free. You can either contribute a patch or sponsor the development of certain features, if they are important to you.

================================================ FILE: cocos2d/external/lua/luajit/src/doc/install.html ================================================ Installation

LuaJIT is only distributed as a source package. This page explains how to build and install LuaJIT with different operating systems and C compilers.

For the impatient (on POSIX systems):

make && sudo make install

LuaJIT currently builds out-of-the box on most systems. Here's the compatibility matrix for the supported combinations of operating systems, CPUs and compilers:

CPU / OS Linux or
Android
*BSD, Other OSX 10.4+ or
iOS 3.0+
Windows
XP/Vista/7
x86 (32 bit) GCC 4.x
GCC 3.4
GCC 4.x
GCC 3.4
GCC 4.x
GCC 3.4
MSVC, MSVC/EE
WinSDK
MinGW, Cygwin
x64 (64 bit) GCC 4.x   GCC 4.x MSVC + SDK v7.0
WinSDK v7.0
ARMv5+
ARM9E+
GCC 4.2+ GCC 4.2+ GCC 4.2+  
PPC GCC 4.3+ GCC 4.3+
GCC 4.1 (PS3)
  XEDK (Xbox 360)
PPC/e500v2 GCC 4.3+ GCC 4.3+    
MIPS GCC 4.3+ GCC 4.3+    

Configuring LuaJIT

The standard configuration should work fine for most installations. Usually there is no need to tweak the settings. The following files hold all user-configurable settings:

  • src/luaconf.h sets some configuration variables.
  • Makefile has settings for installing LuaJIT (POSIX only).
  • src/Makefile has settings for compiling LuaJIT under POSIX, MinGW or Cygwin.
  • src/msvcbuild.bat has settings for compiling LuaJIT with MSVC or WinSDK.

Please read the instructions given in these files, before changing any settings.

POSIX Systems (Linux, OSX, *BSD etc.)

Prerequisites

Depending on your distribution, you may need to install a package for GCC, the development headers and/or a complete SDK. E.g. on a current Debian/Ubuntu, install libc6-dev with the package manager.

Download the current source package of LuaJIT (pick the .tar.gz), if you haven't already done so. Move it to a directory of your choice, open a terminal window and change to this directory. Now unpack the archive and change to the newly created directory:

tar zxf LuaJIT-2.0.1.tar.gz
cd LuaJIT-2.0.1

Building LuaJIT

The supplied Makefiles try to auto-detect the settings needed for your operating system and your compiler. They need to be run with GNU Make, which is probably the default on your system, anyway. Simply run:

make

This always builds a native x86, x64 or PPC binary, depending on the host OS you're running this command on. Check the section on cross-compilation for more options.

By default, modules are only searched under the prefix /usr/local. You can add an extra prefix to the search paths by appending the PREFIX option, e.g.:

make PREFIX=/home/myself/lj2

Note for OSX: if the MACOSX_DEPLOYMENT_TARGET environment variable is not set, then it's forced to 10.4.

Installing LuaJIT

The top-level Makefile installs LuaJIT by default under /usr/local, i.e. the executable ends up in /usr/local/bin and so on. You need root privileges to write to this path. So, assuming sudo is installed on your system, run the following command and enter your sudo password:

sudo make install

Otherwise specify the directory prefix as an absolute path, e.g.:

make install PREFIX=/home/myself/lj2

Obviously the prefixes given during build and installation need to be the same.

Windows Systems

Prerequisites

Either install one of the open source SDKs (» MinGW or » Cygwin), which come with a modified GCC plus the required development headers.

Or install Microsoft's Visual C++ (MSVC). The freely downloadable » Express Edition works just fine, but only contains an x86 compiler.

The freely downloadable » Windows SDK only comes with command line tools, but this is all you need to build LuaJIT. It contains x86 and x64 compilers.

Next, download the source package and unpack it using an archive manager (e.g. the Windows Explorer) to a directory of your choice.

Building with MSVC

Open a "Visual Studio .NET Command Prompt", cd to the directory where you've unpacked the sources and run these commands:

cd src
msvcbuild

Then follow the installation instructions below.

Building with the Windows SDK

Open a "Windows SDK Command Shell" and select the x86 compiler:

setenv /release /x86

Or select the x64 compiler:

setenv /release /x64

Then cd to the directory where you've unpacked the sources and run these commands:

cd src
msvcbuild

Then follow the installation instructions below.

Building with MinGW or Cygwin

Open a command prompt window and make sure the MinGW or Cygwin programs are in your path. Then cd to the directory where you've unpacked the sources and run this command for MinGW:

mingw32-make

Or this command for Cygwin:

make

Then follow the installation instructions below.

Installing LuaJIT

Copy luajit.exe and lua51.dll (built in the src directory) to a newly created directory (any location is ok). Add lua and lua\jit directories below it and copy all Lua files from the src\jit directory of the distribution to the latter directory.

There are no hardcoded absolute path names — all modules are loaded relative to the directory where luajit.exe is installed (see src/luaconf.h).

Cross-compiling LuaJIT

The GNU Makefile-based build system allows cross-compiling on any host for any supported target, as long as both architectures have the same pointer size. If you want to cross-compile to any 32 bit target on an x64 OS, you need to install the multilib development package (e.g. libc6-dev-i386 on Debian/Ubuntu) and build a 32 bit host part (HOST_CC="gcc -m32").

You need to specify TARGET_SYS whenever the host OS and the target OS differ, or you'll get assembler or linker errors. E.g. if you're compiling on a Windows or OSX host for embedded Linux or Android, you need to add TARGET_SYS=Linux to the examples below. For a minimal target OS, you may need to disable the built-in allocator in src/Makefile and use TARGET_SYS=Other. The examples below only show some popular targets — please check the comments in src/Makefile for more details.

# Cross-compile to a 32 bit binary on a multilib x64 OS
make CC="gcc -m32"

# Cross-compile on Debian/Ubuntu for Windows (mingw32 package)
make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows

The CROSS prefix allows specifying a standard GNU cross-compile toolchain (Binutils, GCC and a matching libc). The prefix may vary depending on the --target the toolchain was built for (note the CROSS prefix has a trailing "-"). The examples below use the canonical toolchain triplets for Linux.

Since there's often no easy way to detect CPU features at runtime, it's important to compile with the proper CPU or architecture settings. You can specify these when building the toolchain yourself. Or add -mcpu=... or -march=... to TARGET_CFLAGS. For ARM it's important to have the correct -mfloat-abi=... setting, too. Otherwise LuaJIT may not run at the full performance of your target CPU.

# ARM soft-float
make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
     TARGET_CFLAGS="-mfloat-abi=soft"

# ARM soft-float ABI with VFP (example for Cortex-A8)
make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
     TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp"

# ARM hard-float ABI with VFP (armhf, requires recent toolchain)
make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-

# PPC
make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
# PPC/e500v2 (fast interpreter only)
make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-

# MIPS big-endian
make HOST_CC="gcc -m32" CROSS=mips-linux-
# MIPS little-endian
make HOST_CC="gcc -m32" CROSS=mipsel-linux-

You can cross-compile for Android using the » Android NDK. The environment variables need to match the install locations and the desired target platform. E.g. Android 4.0 corresponds to ABI level 14. For details check the folder docs in the NDK directory.

Only a few common variations for the different CPUs, ABIs and platforms are listed. Please use your own judgement for which combination you want to build/deploy or which lowest common denominator you want to pick:

# Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo)
NDK=/opt/android/ndk
NDKABI=8
NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"

# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS)
NDK=/opt/android/ndk
NDKABI=14
NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH"

# Android/MIPS, mips (MIPS32R1 hard-float), Android 4.0+ (ICS)
NDK=/opt/android/ndk
NDKABI=14
NDKVER=$NDK/toolchains/mipsel-linux-android-4.6
NDKP=$NDKVER/prebuilt/linux-x86/bin/mipsel-linux-android-
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-mips"
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"

# Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS)
NDK=/opt/android/ndk
NDKABI=14
NDKVER=$NDK/toolchains/x86-4.6
NDKP=$NDKVER/prebuilt/linux-x86/bin/i686-linux-android-
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86"
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"

You can cross-compile for iOS 3.0+ (iPhone/iPad) using the » iOS SDK. The environment variables need to match the iOS SDK version:

Note: the JIT compiler is disabled for iOS, because regular iOS Apps are not allowed to generate code at runtime. You'll only get the performance of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but much slower than the JIT compiler. Please complain to Apple, not me. Or use Android. :-p

IXCODE=`xcode-select -print-path`
ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
ISDKVER=iPhoneOS6.0.sdk
ISDKP=$ISDK/usr/bin/
ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \
     TARGET_SYS=iOS

You can cross-compile for PS3 using the PS3 SDK from a Linux host or a Windows host (requires 32 bit MinGW (GCC) on the host, too). Due to restrictions on consoles, the JIT compiler is disabled and only the fast interpreter is built:

make HOST_CC="gcc -m32" CROSS=ppu-lv2-

You can cross-compile for Xbox 360 using the Xbox 360 SDK (MSVC + XEDK). Due to restrictions on consoles, the JIT compiler is disabled and only the fast interpreter is built.

Open a "Visual Studio .NET Command Prompt" (32 bit host compiler), cd to the directory where you've unpacked the sources and run the following commands. This builds a static library luajit20.lib, which can be linked against your game, just like the Lua library.

cd src
xedkbuild

Embedding LuaJIT

LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua into your application, you probably don't need to do anything to switch to LuaJIT, except link with a different library:

  • It's strongly suggested to build LuaJIT separately using the supplied build system. Please do not attempt to integrate the individual source files into your build tree. You'll most likely get the internal build dependencies wrong or mess up the compiler flags. Treat LuaJIT like any other external library and link your application with either the dynamic or static library, depending on your needs.
  • If you want to load C modules compiled for plain Lua with require(), you need to make sure the public symbols (e.g. lua_pushnumber) are exported, too:
    • On POSIX systems you can either link to the shared library or link the static library into your application. In the latter case you'll need to export all public symbols from your main executable (e.g. -Wl,-E on Linux) and add the external dependencies (e.g. -lm -ldl on Linux).
    • Since Windows symbols are bound to a specific DLL name, you need to link to the lua51.dll created by the LuaJIT build (do not rename the DLL). You may link LuaJIT statically on Windows only if you don't intend to load Lua/C modules at runtime.
  • If you're building a 64 bit application on OSX which links directly or indirectly against LuaJIT, you need to link your main executable with these flags:
    -pagezero_size 10000 -image_base 100000000
    
    Also, it's recommended to rebase all (self-compiled) shared libraries which are loaded at runtime on OSX/x64 (e.g. C extension modules for Lua). See: man rebase

Additional hints for initializing LuaJIT using the C API functions:

  • Here's a » simple example for embedding Lua or LuaJIT into your application.
  • Make sure you use luaL_newstate. Avoid using lua_newstate, since this uses the (slower) default memory allocator from your system (no support for this on x64).
  • Make sure you use luaL_openlibs and not the old Lua 5.0 style of calling luaopen_base etc. directly.
  • To change or extend the list of standard libraries to load, copy src/lib_init.c to your project and modify it accordingly. Make sure the jit library is loaded or the JIT compiler will not be activated.
  • The bit.* module for bitwise operations is already built-in. There's no need to statically link » Lua BitOp to your application.

Hints for Distribution Maintainers

The LuaJIT build system has extra provisions for the needs of most POSIX-based distributions. If you're a package maintainer for a distribution, please make use of these features and avoid patching, subverting, autotoolizing or messing up the build system in unspeakable ways.

There should be absolutely no need to patch luaconf.h or any of the Makefiles. And please do not hand-pick files for your packages — simply use whatever make install creates. There's a reason for all of the files and directories it creates.

The build system uses GNU make and auto-detects most settings based on the host you're building it on. This should work fine for native builds, even when sandboxed. You may need to pass some of the following flags to both the make and the make install command lines for a regular distribution build:

  • PREFIX overrides the installation path and should usually be set to /usr. Setting this also changes the module paths and the -rpath of the shared library.
  • DESTDIR is an absolute path which allows you to install to a shadow tree instead of the root tree of the build system.
  • Have a look at the top-level Makefile and src/Makefile for additional variables to tweak. The following variables may be overridden, but it's not recommended, except for special needs like cross-builds: BUILDMODE, CC, HOST_CC, STATIC_CC, DYNAMIC_CC, CFLAGS, HOST_CFLAGS, TARGET_CFLAGS, LDFLAGS, HOST_LDFLAGS, TARGET_LDFLAGS, TARGET_SHLDFLAGS, TARGET_FLAGS, LIBS, HOST_LIBS, TARGET_LIBS, CROSS, HOST_SYS, TARGET_SYS

The build system has a special target for an amalgamated build, i.e. make amalg. This compiles the LuaJIT core as one huge C file and allows GCC to generate faster and shorter code. Alas, this requires lots of memory during the build. This may be a problem for some users, that's why it's not enabled by default. But it shouldn't be a problem for most build farms. It's recommended that binary distributions use this target for their LuaJIT builds.

The tl;dr version of the above:

make amalg PREFIX=/usr && \
make install PREFIX=/usr DESTDIR=/tmp/buildroot

Finally, if you encounter any difficulties, please contact me first, instead of releasing a broken package onto unsuspecting users. Because they'll usually gonna complain to me (the upstream) and not you (the package maintainer), anyway.


================================================ FILE: cocos2d/external/lua/luajit/src/doc/luajit.html ================================================ LuaJIT

LuaJIT is a Just-In-Time Compiler (JIT) for the » Lua programming language. Lua is a powerful, dynamic and light-weight programming language. It may be embedded or used as a general-purpose, stand-alone language.

LuaJIT is Copyright © 2005-2013 Mike Pall, released under the » MIT open source license.

Compatibility

WindowsLinuxBSDOSXPOSIX
EmbeddedAndroidiOSPS3Xbox 360
GCCCLANG
LLVM
MSVC
x86x64ARMPPCe500MIPS
Lua 5.1
API+ABI
+ JIT+ BitOp+ FFIDrop-in
DLL/.so

Overview

3x
-  100x
115 KB
VM
90 KB
JIT
63 KLOC
C
24 KLOC
ASM
11 KLOC
Lua

LuaJIT has been successfully used as a scripting middleware in games, appliances, network and graphics apps, numerical simulations, trading platforms and many other specialty applications. It scales from embedded devices, smartphones, desktops up to server farms. It combines high flexibility with » high performance and an unmatched low memory footprint.

LuaJIT has been in continuous development since 2005. It's widely considered to be one of the fastest dynamic language implementations. It has outperformed other dynamic languages on many cross-language benchmarks since its first release — often by a substantial margin.

For LuaJIT 2.0, the whole VM has been rewritten from the ground up and relentlessly optimized for performance. It combines a high-speed interpreter, written in assembler, with a state-of-the-art JIT compiler.

An innovative trace compiler is integrated with advanced, SSA-based optimizations and highly tuned code generation backends. A substantial reduction of the overhead associated with dynamic languages allows it to break into the performance range traditionally reserved for offline, static language compilers.

More ...

Please select a sub-topic in the navigation bar to learn more about LuaJIT.


================================================ FILE: cocos2d/external/lua/luajit/src/doc/running.html ================================================ Running LuaJIT

LuaJIT has only a single stand-alone executable, called luajit on POSIX systems or luajit.exe on Windows. It can be used to run simple Lua statements or whole Lua applications from the command line. It has an interactive mode, too.

Command Line Options

The luajit stand-alone executable is just a slightly modified version of the regular lua stand-alone executable. It supports the same basic options, too. luajit -h prints a short list of the available options. Please have a look at the » Lua manual for details.

LuaJIT has some additional options:

-b[options] input output

This option saves or lists bytecode. The following additional options are accepted:

  • -l — Only list bytecode.
  • -s — Strip debug info (this is the default).
  • -g — Keep debug info.
  • -n name — Set module name (default: auto-detect from input name)
  • -t type — Set output file type (default: auto-detect from output name).
  • -a arch — Override architecture for object files (default: native).
  • -o os — Override OS for object files (default: native).
  • -e chunk — Use chunk string as input.
  • - (a single minus sign) — Use stdin as input and/or stdout as output.

The output file type is auto-detected from the extension of the output file name:

  • c — C source file, exported bytecode data.
  • h — C header file, static bytecode data.
  • obj or o — Object file, exported bytecode data (OS- and architecture-specific).
  • raw or any other extension — Raw bytecode file (portable).

Notes:

  • See also string.dump() for information on bytecode portability and compatibility.
  • A file in raw bytecode format is auto-detected and can be loaded like any Lua source file. E.g. directly from the command line or with loadfile(), dofile() etc.
  • To statically embed the bytecode of a module in your application, generate an object file and just link it with your application.
  • On most ELF-based systems (e.g. Linux) you need to explicitly export the global symbols when linking your application, e.g. with: -Wl,-E
  • require() tries to load embedded bytecode data from exported symbols (in *.exe or lua51.dll on Windows) and from shared libraries in package.cpath.

Typical usage examples:

luajit -b test.lua test.out                 # Save bytecode to test.out
luajit -bg test.lua test.out                # Keep debug info
luajit -be "print('hello world')" test.out  # Save cmdline script

luajit -bl test.lua                         # List to stdout
luajit -bl test.lua test.txt                # List to test.txt
luajit -ble "print('hello world')"          # List cmdline script

luajit -b test.lua test.obj                 # Generate object file
# Link test.obj with your application and load it with require("test")

-j cmd[=arg[,arg...]]

This option performs a LuaJIT control command or activates one of the loadable extension modules. The command is first looked up in the jit.* library. If no matching function is found, a module named jit.<cmd> is loaded and the start() function of the module is called with the specified arguments (if any). The space between -j and cmd is optional.

Here are the available LuaJIT control commands:

  • -jon — Turns the JIT compiler on (default).
  • -joff — Turns the JIT compiler off (only use the interpreter).
  • -jflush — Flushes the whole cache of compiled code.
  • -jv — Shows verbose information about the progress of the JIT compiler.
  • -jdump — Dumps the code and structures used in various compiler stages.

The -jv and -jdump commands are extension modules written in Lua. They are mainly used for debugging the JIT compiler itself. For a description of their options and output format, please read the comment block at the start of their source. They can be found in the lib directory of the source distribution or installed under the jit directory. By default this is /usr/local/share/luajit-2.0.1/jit on POSIX systems.

-O[level]
-O[+]flag   -O-flag
-Oparam=value

This options allows fine-tuned control of the optimizations used by the JIT compiler. This is mainly intended for debugging LuaJIT itself. Please note that the JIT compiler is extremely fast (we are talking about the microsecond to millisecond range). Disabling optimizations doesn't have any visible impact on its overhead, but usually generates code that runs slower.

The first form sets an optimization level — this enables a specific mix of optimization flags. -O0 turns off all optimizations and higher numbers enable more optimizations. Omitting the level (i.e. just -O) sets the default optimization level, which is -O3 in the current version.

The second form adds or removes individual optimization flags. The third form sets a parameter for the VM or the JIT compiler to a specific value.

You can either use this option multiple times (like -Ocse -O-dce -Ohotloop=10) or separate several settings with a comma (like -O+cse,-dce,hotloop=10). The settings are applied from left to right and later settings override earlier ones. You can freely mix the three forms, but note that setting an optimization level overrides all earlier flags.

Here are the available flags and at what optimization levels they are enabled:

Flag -O1 -O2 -O3  
foldConstant Folding, Simplifications and Reassociation
cseCommon-Subexpression Elimination
dceDead-Code Elimination
narrow Narrowing of numbers to integers
loop Loop Optimizations (code hoisting)
fwd  Load Forwarding (L2L) and Store Forwarding (S2L)
dse  Dead-Store Elimination
abc  Array Bounds Check Elimination
sink  Allocation/Store Sinking
fuse  Fusion of operands into instructions

Here are the parameters and their default settings:

Parameter Default  
maxtrace1000Max. number of traces in the cache
maxrecord4000Max. number of recorded IR instructions
maxirconst500Max. number of IR constants of a trace
maxside100Max. number of side traces of a root trace
maxsnap500Max. number of snapshots for a trace
hotloop56Number of iterations to detect a hot loop or hot call
hotexit10Number of taken exits to start a side trace
tryside4Number of attempts to compile a side trace
instunroll4Max. unroll factor for instable loops
loopunroll15Max. unroll factor for loop ops in side traces
callunroll3Max. unroll factor for pseudo-recursive calls
recunroll2Min. unroll factor for true recursion
sizemcode32Size of each machine code area in KBytes (Windows: 64K)
maxmcode512Max. total size of all machine code areas in KBytes

================================================ FILE: cocos2d/external/lua/luajit/src/doc/status.html ================================================ Status & Roadmap

LuaJIT 2.0 is the current stable branch. This branch is in feature-freeze — new features will only be added to LuaJIT 2.1.

Current Status

LuaJIT ought to run all Lua 5.1-compatible source code just fine. It's considered a serious bug if the VM crashes or produces unexpected results — please report this.

Known incompatibilities and issues in LuaJIT 2.0:

  • There are some differences in implementation-defined behavior. These either have a good reason, are arbitrary design choices or are due to quirks in the VM. The latter cases may get fixed if a demonstrable need is shown.
  • The Lua debug API is missing a couple of features (return hooks for non-Lua functions) and shows slightly different behavior in LuaJIT (no per-coroutine hooks, no tail call counting).
  • Some checks are missing in the JIT-compiled code for obscure situations with open upvalues aliasing one of the SSA slots later on (or vice versa). Bonus points, if you can find a real world test case for this.
  • Currently some out-of-memory errors from on-trace code are not handled correctly. The error may fall through an on-trace pcall or it may be passed on to the function set with lua_atpanic on x64. This issue will be fixed with the new garbage collector.

Roadmap

Please refer to the » LuaJIT Roadmap 2012/2013 and an » update on release planning for details.


================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_arm.h ================================================ /* ** DynASM ARM encoding engine. ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. ** Released under the MIT license. See dynasm.lua for full copyright notice. */ #include #include #include #include #define DASM_ARCH "arm" #ifndef DASM_EXTERN #define DASM_EXTERN(a,b,c,d) 0 #endif /* Action definitions. */ enum { DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, /* The following actions need a buffer position. */ DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, /* The following actions also have an argument. */ DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, DASM_IMM12, DASM_IMM16, DASM_IMML8, DASM_IMML12, DASM_IMMV8, DASM__MAX }; /* Maximum number of section buffer positions for a single dasm_put() call. */ #define DASM_MAXSECPOS 25 /* DynASM encoder status codes. Action list offset or number are or'ed in. */ #define DASM_S_OK 0x00000000 #define DASM_S_NOMEM 0x01000000 #define DASM_S_PHASE 0x02000000 #define DASM_S_MATCH_SEC 0x03000000 #define DASM_S_RANGE_I 0x11000000 #define DASM_S_RANGE_SEC 0x12000000 #define DASM_S_RANGE_LG 0x13000000 #define DASM_S_RANGE_PC 0x14000000 #define DASM_S_RANGE_REL 0x15000000 #define DASM_S_UNDEF_LG 0x21000000 #define DASM_S_UNDEF_PC 0x22000000 /* Macros to convert positions (8 bit section + 24 bit index). */ #define DASM_POS2IDX(pos) ((pos)&0x00ffffff) #define DASM_POS2BIAS(pos) ((pos)&0xff000000) #define DASM_SEC2POS(sec) ((sec)<<24) #define DASM_POS2SEC(pos) ((pos)>>24) #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) /* Action list type. */ typedef const unsigned int *dasm_ActList; /* Per-section structure. */ typedef struct dasm_Section { int *rbuf; /* Biased buffer pointer (negative section bias). */ int *buf; /* True buffer pointer. */ size_t bsize; /* Buffer size in bytes. */ int pos; /* Biased buffer position. */ int epos; /* End of biased buffer position - max single put. */ int ofs; /* Byte offset into section. */ } dasm_Section; /* Core structure holding the DynASM encoding state. */ struct dasm_State { size_t psize; /* Allocated size of this structure. */ dasm_ActList actionlist; /* Current actionlist pointer. */ int *lglabels; /* Local/global chain/pos ptrs. */ size_t lgsize; int *pclabels; /* PC label chains/pos ptrs. */ size_t pcsize; void **globals; /* Array of globals (bias -10). */ dasm_Section *section; /* Pointer to active section. */ size_t codesize; /* Total size of all code sections. */ int maxsection; /* 0 <= sectionidx < maxsection. */ int status; /* Status code. */ dasm_Section sections[1]; /* All sections. Alloc-extended. */ }; /* The size of the core structure depends on the max. number of sections. */ #define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) /* Initialize DynASM state. */ void dasm_init(Dst_DECL, int maxsection) { dasm_State *D; size_t psz = 0; int i; Dst_REF = NULL; DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); D = Dst_REF; D->psize = psz; D->lglabels = NULL; D->lgsize = 0; D->pclabels = NULL; D->pcsize = 0; D->globals = NULL; D->maxsection = maxsection; for (i = 0; i < maxsection; i++) { D->sections[i].buf = NULL; /* Need this for pass3. */ D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); D->sections[i].bsize = 0; D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ } } /* Free DynASM state. */ void dasm_free(Dst_DECL) { dasm_State *D = Dst_REF; int i; for (i = 0; i < D->maxsection; i++) if (D->sections[i].buf) DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); DASM_M_FREE(Dst, D, D->psize); } /* Setup global label array. Must be called before dasm_setup(). */ void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) { dasm_State *D = Dst_REF; D->globals = gl - 10; /* Negative bias to compensate for locals. */ DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); } /* Grow PC label array. Can be called after dasm_setup(), too. */ void dasm_growpc(Dst_DECL, unsigned int maxpc) { dasm_State *D = Dst_REF; size_t osz = D->pcsize; DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); } /* Setup encoder. */ void dasm_setup(Dst_DECL, const void *actionlist) { dasm_State *D = Dst_REF; int i; D->actionlist = (dasm_ActList)actionlist; D->status = DASM_S_OK; D->section = &D->sections[0]; memset((void *)D->lglabels, 0, D->lgsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); for (i = 0; i < D->maxsection; i++) { D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].ofs = 0; } } #ifdef DASM_CHECKS #define CK(x, st) \ do { if (!(x)) { \ D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) #define CKPL(kind, st) \ do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) #else #define CK(x, st) ((void)0) #define CKPL(kind, st) ((void)0) #endif static int dasm_imm12(unsigned int n) { int i; for (i = 0; i < 16; i++, n = (n << 2) | (n >> 30)) if (n <= 255) return (int)(n + (i << 8)); return -1; } /* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ void dasm_put(Dst_DECL, int start, ...) { va_list ap; dasm_State *D = Dst_REF; dasm_ActList p = D->actionlist + start; dasm_Section *sec = D->section; int pos = sec->pos, ofs = sec->ofs; int *b; if (pos >= sec->epos) { DASM_M_GROW(Dst, int, sec->buf, sec->bsize, sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); sec->rbuf = sec->buf - DASM_POS2BIAS(pos); sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); } b = sec->rbuf; b[pos++] = start; va_start(ap, start); while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16); if (action >= DASM__MAX) { ofs += 4; } else { int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; switch (action) { case DASM_STOP: goto stop; case DASM_SECTION: n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; goto stop; case DASM_ESC: p++; ofs += 4; break; case DASM_REL_EXT: break; case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; case DASM_REL_LG: n = (ins & 2047) - 10; pl = D->lglabels + n; if (n >= 0) { CKPL(lg, LG); goto putrel; } /* Bkwd rel or global. */ pl += 10; n = *pl; if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ goto linkrel; case DASM_REL_PC: pl = D->pclabels + n; CKPL(pc, PC); putrel: n = *pl; if (n < 0) { /* Label exists. Get label pos and store it. */ b[pos] = -n; } else { linkrel: b[pos] = n; /* Else link to rel chain, anchored at label. */ *pl = pos; } pos++; break; case DASM_LABEL_LG: pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; case DASM_LABEL_PC: pl = D->pclabels + n; CKPL(pc, PC); putlabel: n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } *pl = -pos; /* Label exists now. */ b[pos++] = ofs; /* Store pass1 offset estimate. */ break; case DASM_IMM: case DASM_IMM16: #ifdef DASM_CHECKS CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); if ((ins & 0x8000)) CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); else CK((n>>((ins>>5)&31)) == 0, RANGE_I); #endif b[pos++] = n; break; case DASM_IMMV8: CK((n & 3) == 0, RANGE_I); n >>= 2; case DASM_IMML8: case DASM_IMML12: CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) : (((-n)>>((ins>>5)&31)) == 0), RANGE_I); b[pos++] = n; break; case DASM_IMM12: CK(dasm_imm12((unsigned int)n) != -1, RANGE_I); b[pos++] = n; break; } } } stop: va_end(ap); sec->pos = pos; sec->ofs = ofs; } #undef CK /* Pass 2: Link sections, shrink aligns, fix label offsets. */ int dasm_link(Dst_DECL, size_t *szp) { dasm_State *D = Dst_REF; int secnum; int ofs = 0; #ifdef DASM_CHECKS *szp = 0; if (D->status != DASM_S_OK) return D->status; { int pc; for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; } #endif { /* Handle globals not defined in this translation unit. */ int idx; for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { int n = D->lglabels[idx]; /* Undefined label: Collapse rel chain and replace with marker (< 0). */ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } } } /* Combine all code sections. No support for data sections (yet). */ for (secnum = 0; secnum < D->maxsection; secnum++) { dasm_Section *sec = D->sections + secnum; int *b = sec->rbuf; int pos = DASM_SEC2POS(secnum); int lastpos = sec->pos; while (pos != lastpos) { dasm_ActList p = D->actionlist + b[pos++]; while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16); switch (action) { case DASM_STOP: case DASM_SECTION: goto stop; case DASM_ESC: p++; break; case DASM_REL_EXT: break; case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; case DASM_REL_LG: case DASM_REL_PC: pos++; break; case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; case DASM_IMM: case DASM_IMM12: case DASM_IMM16: case DASM_IMML8: case DASM_IMML12: case DASM_IMMV8: pos++; break; } } stop: (void)0; } ofs += sec->ofs; /* Next section starts right after current section. */ } D->codesize = ofs; /* Total size of all code sections */ *szp = ofs; return DASM_S_OK; } #ifdef DASM_CHECKS #define CK(x, st) \ do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) #else #define CK(x, st) ((void)0) #endif /* Pass 3: Encode sections. */ int dasm_encode(Dst_DECL, void *buffer) { dasm_State *D = Dst_REF; char *base = (char *)buffer; unsigned int *cp = (unsigned int *)buffer; int secnum; /* Encode all code sections. No support for data sections (yet). */ for (secnum = 0; secnum < D->maxsection; secnum++) { dasm_Section *sec = D->sections + secnum; int *b = sec->buf; int *endb = sec->rbuf + sec->pos; while (b != endb) { dasm_ActList p = D->actionlist + *b++; while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16); int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; switch (action) { case DASM_STOP: case DASM_SECTION: goto stop; case DASM_ESC: *cp++ = *p++; break; case DASM_REL_EXT: n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins&2047), !(ins&2048)); goto patchrel; case DASM_ALIGN: ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000; break; case DASM_REL_LG: CK(n >= 0, UNDEF_LG); case DASM_REL_PC: CK(n >= 0, UNDEF_PC); n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) - 4; patchrel: if ((ins & 0x800) == 0) { CK((n & 3) == 0 && ((n+0x02000000) >> 26) == 0, RANGE_REL); cp[-1] |= ((n >> 2) & 0x00ffffff); } else if ((ins & 0x1000)) { CK((n & 3) == 0 && -256 <= n && n <= 256, RANGE_REL); goto patchimml8; } else if ((ins & 0x2000) == 0) { CK((n & 3) == 0 && -4096 <= n && n <= 4096, RANGE_REL); goto patchimml; } else { CK((n & 3) == 0 && -1020 <= n && n <= 1020, RANGE_REL); n >>= 2; goto patchimml; } break; case DASM_LABEL_LG: ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); break; case DASM_LABEL_PC: break; case DASM_IMM: cp[-1] |= ((n>>((ins>>10)&31)) & ((1<<((ins>>5)&31))-1)) << (ins&31); break; case DASM_IMM12: cp[-1] |= dasm_imm12((unsigned int)n); break; case DASM_IMM16: cp[-1] |= ((n & 0xf000) << 4) | (n & 0x0fff); break; case DASM_IMML8: patchimml8: cp[-1] |= n >= 0 ? (0x00800000 | (n & 0x0f) | ((n & 0xf0) << 4)) : ((-n & 0x0f) | ((-n & 0xf0) << 4)); break; case DASM_IMML12: case DASM_IMMV8: patchimml: cp[-1] |= n >= 0 ? (0x00800000 | n) : (-n); break; default: *cp++ = ins; break; } } stop: (void)0; } } if (base + D->codesize != (char *)cp) /* Check for phase errors. */ return DASM_S_PHASE; return DASM_S_OK; } #undef CK /* Get PC label offset. */ int dasm_getpclabel(Dst_DECL, unsigned int pc) { dasm_State *D = Dst_REF; if (pc*sizeof(int) < D->pcsize) { int pos = D->pclabels[pc]; if (pos < 0) return *DASM_POS2PTR(D, -pos); if (pos > 0) return -1; /* Undefined. */ } return -2; /* Unused or out of range. */ } #ifdef DASM_CHECKS /* Optional sanity checker to call between isolated encoding steps. */ int dasm_checkstep(Dst_DECL, int secmatch) { dasm_State *D = Dst_REF; if (D->status == DASM_S_OK) { int i; for (i = 1; i <= 9; i++) { if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } D->lglabels[i] = 0; } } if (D->status == DASM_S_OK && secmatch >= 0 && D->section != &D->sections[secmatch]) D->status = DASM_S_MATCH_SEC|(D->section-D->sections); return D->status; } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_arm.lua ================================================ ------------------------------------------------------------------------------ -- DynASM ARM module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------ -- Module information: local _info = { arch = "arm", description = "DynASM ARM module", version = "1.3.0", vernum = 10300, release = "2011-05-05", author = "Mike Pall", license = "MIT", } -- Exported glue functions for the arch-specific module. local _M = { _info = _info } -- Cache library functions. local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs local assert, setmetatable, rawget = assert, setmetatable, rawget local _s = string local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char local match, gmatch, gsub = _s.match, _s.gmatch, _s.gsub local concat, sort, insert = table.concat, table.sort, table.insert local bit = bit or require("bit") local band, shl, shr, sar = bit.band, bit.lshift, bit.rshift, bit.arshift local ror, tohex = bit.ror, bit.tohex -- Inherited tables and callbacks. local g_opt, g_arch local wline, werror, wfatal, wwarn -- Action name list. -- CHECK: Keep this in sync with the C code! local action_names = { "STOP", "SECTION", "ESC", "REL_EXT", "ALIGN", "REL_LG", "LABEL_LG", "REL_PC", "LABEL_PC", "IMM", "IMM12", "IMM16", "IMML8", "IMML12", "IMMV8", } -- Maximum number of section buffer positions for dasm_put(). -- CHECK: Keep this in sync with the C code! local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. -- Action name -> action number. local map_action = {} for n,name in ipairs(action_names) do map_action[name] = n-1 end -- Action list buffer. local actlist = {} -- Argument list for next dasm_put(). Start with offset 0 into action list. local actargs = { 0 } -- Current number of section buffer positions for dasm_put(). local secpos = 1 ------------------------------------------------------------------------------ -- Dump action names and numbers. local function dumpactions(out) out:write("DynASM encoding engine action codes:\n") for n,name in ipairs(action_names) do local num = map_action[name] out:write(format(" %-10s %02X %d\n", name, num, num)) end out:write("\n") end -- Write action list buffer as a huge static C array. local function writeactions(out, name) local nn = #actlist if nn == 0 then nn = 1; actlist[0] = map_action.STOP end out:write("static const unsigned int ", name, "[", nn, "] = {\n") for i = 1,nn-1 do assert(out:write("0x", tohex(actlist[i]), ",\n")) end assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) end ------------------------------------------------------------------------------ -- Add word to action list. local function wputxw(n) assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") actlist[#actlist+1] = n end -- Add action to list with optional arg. Advance buffer pos, too. local function waction(action, val, a, num) local w = assert(map_action[action], "bad action name `"..action.."'") wputxw(w * 0x10000 + (val or 0)) if a then actargs[#actargs+1] = a end if a or num then secpos = secpos + (num or 1) end end -- Flush action list (intervening C code or buffer pos overflow). local function wflush(term) if #actlist == actargs[1] then return end -- Nothing to flush. if not term then waction("STOP") end -- Terminate action list. wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). secpos = 1 -- The actionlist offset occupies a buffer position, too. end -- Put escaped word. local function wputw(n) if n <= 0x000fffff then waction("ESC") end wputxw(n) end -- Reserve position for word. local function wpos() local pos = #actlist+1 actlist[pos] = "" return pos end -- Store word to reserved position. local function wputpos(pos, n) assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") if n <= 0x000fffff then insert(actlist, pos+1, n) n = map_action.ESC * 0x10000 end actlist[pos] = n end ------------------------------------------------------------------------------ -- Global label name -> global label number. With auto assignment on 1st use. local next_global = 20 local map_global = setmetatable({}, { __index = function(t, name) if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end local n = next_global if n > 2047 then werror("too many global labels") end next_global = n + 1 t[name] = n return n end}) -- Dump global labels. local function dumpglobals(out, lvl) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("Global labels:\n") for i=20,next_global-1 do out:write(format(" %s\n", t[i])) end out:write("\n") end -- Write global label enum. local function writeglobals(out, prefix) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("enum {\n") for i=20,next_global-1 do out:write(" ", prefix, t[i], ",\n") end out:write(" ", prefix, "_MAX\n};\n") end -- Write global label names. local function writeglobalnames(out, name) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("static const char *const ", name, "[] = {\n") for i=20,next_global-1 do out:write(" \"", t[i], "\",\n") end out:write(" (const char *)0\n};\n") end ------------------------------------------------------------------------------ -- Extern label name -> extern label number. With auto assignment on 1st use. local next_extern = 0 local map_extern_ = {} local map_extern = setmetatable({}, { __index = function(t, name) -- No restrictions on the name for now. local n = next_extern if n > 2047 then werror("too many extern labels") end next_extern = n + 1 t[name] = n map_extern_[n] = name return n end}) -- Dump extern labels. local function dumpexterns(out, lvl) out:write("Extern labels:\n") for i=0,next_extern-1 do out:write(format(" %s\n", map_extern_[i])) end out:write("\n") end -- Write extern label names. local function writeexternnames(out, name) out:write("static const char *const ", name, "[] = {\n") for i=0,next_extern-1 do out:write(" \"", map_extern_[i], "\",\n") end out:write(" (const char *)0\n};\n") end ------------------------------------------------------------------------------ -- Arch-specific maps. -- Ext. register name -> int. name. local map_archdef = { sp = "r13", lr = "r14", pc = "r15", } -- Int. register name -> ext. name. local map_reg_rev = { r13 = "sp", r14 = "lr", r15 = "pc", } local map_type = {} -- Type name -> { ctype, reg } local ctypenum = 0 -- Type number (for Dt... macros). -- Reverse defines for registers. function _M.revdef(s) return map_reg_rev[s] or s end local map_shift = { lsl = 0, lsr = 1, asr = 2, ror = 3, } local map_cond = { eq = 0, ne = 1, cs = 2, cc = 3, mi = 4, pl = 5, vs = 6, vc = 7, hi = 8, ls = 9, ge = 10, lt = 11, gt = 12, le = 13, al = 14, hs = 2, lo = 3, } ------------------------------------------------------------------------------ -- Template strings for ARM instructions. local map_op = { -- Basic data processing instructions. and_3 = "e0000000DNPs", eor_3 = "e0200000DNPs", sub_3 = "e0400000DNPs", rsb_3 = "e0600000DNPs", add_3 = "e0800000DNPs", adc_3 = "e0a00000DNPs", sbc_3 = "e0c00000DNPs", rsc_3 = "e0e00000DNPs", tst_2 = "e1100000NP", teq_2 = "e1300000NP", cmp_2 = "e1500000NP", cmn_2 = "e1700000NP", orr_3 = "e1800000DNPs", mov_2 = "e1a00000DPs", bic_3 = "e1c00000DNPs", mvn_2 = "e1e00000DPs", and_4 = "e0000000DNMps", eor_4 = "e0200000DNMps", sub_4 = "e0400000DNMps", rsb_4 = "e0600000DNMps", add_4 = "e0800000DNMps", adc_4 = "e0a00000DNMps", sbc_4 = "e0c00000DNMps", rsc_4 = "e0e00000DNMps", tst_3 = "e1100000NMp", teq_3 = "e1300000NMp", cmp_3 = "e1500000NMp", cmn_3 = "e1700000NMp", orr_4 = "e1800000DNMps", mov_3 = "e1a00000DMps", bic_4 = "e1c00000DNMps", mvn_3 = "e1e00000DMps", lsl_3 = "e1a00000DMws", lsr_3 = "e1a00020DMws", asr_3 = "e1a00040DMws", ror_3 = "e1a00060DMws", rrx_2 = "e1a00060DMs", -- Multiply and multiply-accumulate. mul_3 = "e0000090NMSs", mla_4 = "e0200090NMSDs", umaal_4 = "e0400090DNMSs", -- v6 mls_4 = "e0600090DNMSs", -- v6T2 umull_4 = "e0800090DNMSs", umlal_4 = "e0a00090DNMSs", smull_4 = "e0c00090DNMSs", smlal_4 = "e0e00090DNMSs", -- Halfword multiply and multiply-accumulate. smlabb_4 = "e1000080NMSD", -- v5TE smlatb_4 = "e10000a0NMSD", -- v5TE smlabt_4 = "e10000c0NMSD", -- v5TE smlatt_4 = "e10000e0NMSD", -- v5TE smlawb_4 = "e1200080NMSD", -- v5TE smulwb_3 = "e12000a0NMS", -- v5TE smlawt_4 = "e12000c0NMSD", -- v5TE smulwt_3 = "e12000e0NMS", -- v5TE smlalbb_4 = "e1400080NMSD", -- v5TE smlaltb_4 = "e14000a0NMSD", -- v5TE smlalbt_4 = "e14000c0NMSD", -- v5TE smlaltt_4 = "e14000e0NMSD", -- v5TE smulbb_3 = "e1600080NMS", -- v5TE smultb_3 = "e16000a0NMS", -- v5TE smulbt_3 = "e16000c0NMS", -- v5TE smultt_3 = "e16000e0NMS", -- v5TE -- Miscellaneous data processing instructions. clz_2 = "e16f0f10DM", -- v5T rev_2 = "e6bf0f30DM", -- v6 rev16_2 = "e6bf0fb0DM", -- v6 revsh_2 = "e6ff0fb0DM", -- v6 sel_3 = "e6800fb0DNM", -- v6 usad8_3 = "e780f010NMS", -- v6 usada8_4 = "e7800010NMSD", -- v6 rbit_2 = "e6ff0f30DM", -- v6T2 movw_2 = "e3000000DW", -- v6T2 movt_2 = "e3400000DW", -- v6T2 -- Note: the X encodes width-1, not width. sbfx_4 = "e7a00050DMvX", -- v6T2 ubfx_4 = "e7e00050DMvX", -- v6T2 -- Note: the X encodes the msb field, not the width. bfc_3 = "e7c0001fDvX", -- v6T2 bfi_4 = "e7c00010DMvX", -- v6T2 -- Packing and unpacking instructions. pkhbt_3 = "e6800010DNM", pkhbt_4 = "e6800010DNMv", -- v6 pkhtb_3 = "e6800050DNM", pkhtb_4 = "e6800050DNMv", -- v6 sxtab_3 = "e6a00070DNM", sxtab_4 = "e6a00070DNMv", -- v6 sxtab16_3 = "e6800070DNM", sxtab16_4 = "e6800070DNMv", -- v6 sxtah_3 = "e6b00070DNM", sxtah_4 = "e6b00070DNMv", -- v6 sxtb_2 = "e6af0070DM", sxtb_3 = "e6af0070DMv", -- v6 sxtb16_2 = "e68f0070DM", sxtb16_3 = "e68f0070DMv", -- v6 sxth_2 = "e6bf0070DM", sxth_3 = "e6bf0070DMv", -- v6 uxtab_3 = "e6e00070DNM", uxtab_4 = "e6e00070DNMv", -- v6 uxtab16_3 = "e6c00070DNM", uxtab16_4 = "e6c00070DNMv", -- v6 uxtah_3 = "e6f00070DNM", uxtah_4 = "e6f00070DNMv", -- v6 uxtb_2 = "e6ef0070DM", uxtb_3 = "e6ef0070DMv", -- v6 uxtb16_2 = "e6cf0070DM", uxtb16_3 = "e6cf0070DMv", -- v6 uxth_2 = "e6ff0070DM", uxth_3 = "e6ff0070DMv", -- v6 -- Saturating instructions. qadd_3 = "e1000050DMN", -- v5TE qsub_3 = "e1200050DMN", -- v5TE qdadd_3 = "e1400050DMN", -- v5TE qdsub_3 = "e1600050DMN", -- v5TE -- Note: the X for ssat* encodes sat_imm-1, not sat_imm. ssat_3 = "e6a00010DXM", ssat_4 = "e6a00010DXMp", -- v6 usat_3 = "e6e00010DXM", usat_4 = "e6e00010DXMp", -- v6 ssat16_3 = "e6a00f30DXM", -- v6 usat16_3 = "e6e00f30DXM", -- v6 -- Parallel addition and subtraction. sadd16_3 = "e6100f10DNM", -- v6 sasx_3 = "e6100f30DNM", -- v6 ssax_3 = "e6100f50DNM", -- v6 ssub16_3 = "e6100f70DNM", -- v6 sadd8_3 = "e6100f90DNM", -- v6 ssub8_3 = "e6100ff0DNM", -- v6 qadd16_3 = "e6200f10DNM", -- v6 qasx_3 = "e6200f30DNM", -- v6 qsax_3 = "e6200f50DNM", -- v6 qsub16_3 = "e6200f70DNM", -- v6 qadd8_3 = "e6200f90DNM", -- v6 qsub8_3 = "e6200ff0DNM", -- v6 shadd16_3 = "e6300f10DNM", -- v6 shasx_3 = "e6300f30DNM", -- v6 shsax_3 = "e6300f50DNM", -- v6 shsub16_3 = "e6300f70DNM", -- v6 shadd8_3 = "e6300f90DNM", -- v6 shsub8_3 = "e6300ff0DNM", -- v6 uadd16_3 = "e6500f10DNM", -- v6 uasx_3 = "e6500f30DNM", -- v6 usax_3 = "e6500f50DNM", -- v6 usub16_3 = "e6500f70DNM", -- v6 uadd8_3 = "e6500f90DNM", -- v6 usub8_3 = "e6500ff0DNM", -- v6 uqadd16_3 = "e6600f10DNM", -- v6 uqasx_3 = "e6600f30DNM", -- v6 uqsax_3 = "e6600f50DNM", -- v6 uqsub16_3 = "e6600f70DNM", -- v6 uqadd8_3 = "e6600f90DNM", -- v6 uqsub8_3 = "e6600ff0DNM", -- v6 uhadd16_3 = "e6700f10DNM", -- v6 uhasx_3 = "e6700f30DNM", -- v6 uhsax_3 = "e6700f50DNM", -- v6 uhsub16_3 = "e6700f70DNM", -- v6 uhadd8_3 = "e6700f90DNM", -- v6 uhsub8_3 = "e6700ff0DNM", -- v6 -- Load/store instructions. str_2 = "e4000000DL", str_3 = "e4000000DL", str_4 = "e4000000DL", strb_2 = "e4400000DL", strb_3 = "e4400000DL", strb_4 = "e4400000DL", ldr_2 = "e4100000DL", ldr_3 = "e4100000DL", ldr_4 = "e4100000DL", ldrb_2 = "e4500000DL", ldrb_3 = "e4500000DL", ldrb_4 = "e4500000DL", strh_2 = "e00000b0DL", strh_3 = "e00000b0DL", ldrh_2 = "e01000b0DL", ldrh_3 = "e01000b0DL", ldrd_2 = "e00000d0DL", ldrd_3 = "e00000d0DL", -- v5TE ldrsb_2 = "e01000d0DL", ldrsb_3 = "e01000d0DL", strd_2 = "e00000f0DL", strd_3 = "e00000f0DL", -- v5TE ldrsh_2 = "e01000f0DL", ldrsh_3 = "e01000f0DL", ldm_2 = "e8900000oR", ldmia_2 = "e8900000oR", ldmfd_2 = "e8900000oR", ldmda_2 = "e8100000oR", ldmfa_2 = "e8100000oR", ldmdb_2 = "e9100000oR", ldmea_2 = "e9100000oR", ldmib_2 = "e9900000oR", ldmed_2 = "e9900000oR", stm_2 = "e8800000oR", stmia_2 = "e8800000oR", stmfd_2 = "e8800000oR", stmda_2 = "e8000000oR", stmfa_2 = "e8000000oR", stmdb_2 = "e9000000oR", stmea_2 = "e9000000oR", stmib_2 = "e9800000oR", stmed_2 = "e9800000oR", pop_1 = "e8bd0000R", push_1 = "e92d0000R", -- Branch instructions. b_1 = "ea000000B", bl_1 = "eb000000B", blx_1 = "e12fff30C", bx_1 = "e12fff10M", -- Miscellaneous instructions. nop_0 = "e1a00000", mrs_1 = "e10f0000D", bkpt_1 = "e1200070K", -- v5T svc_1 = "ef000000T", swi_1 = "ef000000T", ud_0 = "e7f001f0", -- VFP instructions. ["vadd.f32_3"] = "ee300a00dnm", ["vadd.f64_3"] = "ee300b00Gdnm", ["vsub.f32_3"] = "ee300a40dnm", ["vsub.f64_3"] = "ee300b40Gdnm", ["vmul.f32_3"] = "ee200a00dnm", ["vmul.f64_3"] = "ee200b00Gdnm", ["vnmul.f32_3"] = "ee200a40dnm", ["vnmul.f64_3"] = "ee200b40Gdnm", ["vmla.f32_3"] = "ee000a00dnm", ["vmla.f64_3"] = "ee000b00Gdnm", ["vmls.f32_3"] = "ee000a40dnm", ["vmls.f64_3"] = "ee000b40Gdnm", ["vnmla.f32_3"] = "ee100a40dnm", ["vnmla.f64_3"] = "ee100b40Gdnm", ["vnmls.f32_3"] = "ee100a00dnm", ["vnmls.f64_3"] = "ee100b00Gdnm", ["vdiv.f32_3"] = "ee800a00dnm", ["vdiv.f64_3"] = "ee800b00Gdnm", ["vabs.f32_2"] = "eeb00ac0dm", ["vabs.f64_2"] = "eeb00bc0Gdm", ["vneg.f32_2"] = "eeb10a40dm", ["vneg.f64_2"] = "eeb10b40Gdm", ["vsqrt.f32_2"] = "eeb10ac0dm", ["vsqrt.f64_2"] = "eeb10bc0Gdm", ["vcmp.f32_2"] = "eeb40a40dm", ["vcmp.f64_2"] = "eeb40b40Gdm", ["vcmpe.f32_2"] = "eeb40ac0dm", ["vcmpe.f64_2"] = "eeb40bc0Gdm", ["vcmpz.f32_1"] = "eeb50a40d", ["vcmpz.f64_1"] = "eeb50b40Gd", ["vcmpze.f32_1"] = "eeb50ac0d", ["vcmpze.f64_1"] = "eeb50bc0Gd", vldr_2 = "ed100a00dl|ed100b00Gdl", vstr_2 = "ed000a00dl|ed000b00Gdl", vldm_2 = "ec900a00or", vldmia_2 = "ec900a00or", vldmdb_2 = "ed100a00or", vpop_1 = "ecbd0a00r", vstm_2 = "ec800a00or", vstmia_2 = "ec800a00or", vstmdb_2 = "ed000a00or", vpush_1 = "ed2d0a00r", ["vmov.f32_2"] = "eeb00a40dm|eeb00a00dY", -- #imm is VFPv3 only ["vmov.f64_2"] = "eeb00b40Gdm|eeb00b00GdY", -- #imm is VFPv3 only vmov_2 = "ee100a10Dn|ee000a10nD", vmov_3 = "ec500a10DNm|ec400a10mDN|ec500b10GDNm|ec400b10GmDN", vmrs_0 = "eef1fa10", vmrs_1 = "eef10a10D", vmsr_1 = "eee10a10D", ["vcvt.s32.f32_2"] = "eebd0ac0dm", ["vcvt.s32.f64_2"] = "eebd0bc0dGm", ["vcvt.u32.f32_2"] = "eebc0ac0dm", ["vcvt.u32.f64_2"] = "eebc0bc0dGm", ["vcvtr.s32.f32_2"] = "eebd0a40dm", ["vcvtr.s32.f64_2"] = "eebd0b40dGm", ["vcvtr.u32.f32_2"] = "eebc0a40dm", ["vcvtr.u32.f64_2"] = "eebc0b40dGm", ["vcvt.f32.s32_2"] = "eeb80ac0dm", ["vcvt.f64.s32_2"] = "eeb80bc0GdFm", ["vcvt.f32.u32_2"] = "eeb80a40dm", ["vcvt.f64.u32_2"] = "eeb80b40GdFm", ["vcvt.f32.f64_2"] = "eeb70bc0dGm", ["vcvt.f64.f32_2"] = "eeb70ac0GdFm", -- VFPv4 only: ["vfma.f32_3"] = "eea00a00dnm", ["vfma.f64_3"] = "eea00b00Gdnm", ["vfms.f32_3"] = "eea00a40dnm", ["vfms.f64_3"] = "eea00b40Gdnm", ["vfnma.f32_3"] = "ee900a40dnm", ["vfnma.f64_3"] = "ee900b40Gdnm", ["vfnms.f32_3"] = "ee900a00dnm", ["vfnms.f64_3"] = "ee900b00Gdnm", -- NYI: Advanced SIMD instructions. -- NYI: I have no need for these instructions right now: -- swp, swpb, strex, ldrex, strexd, ldrexd, strexb, ldrexb, strexh, ldrexh -- msr, nopv6, yield, wfe, wfi, sev, dbg, bxj, smc, srs, rfe -- cps, setend, pli, pld, pldw, clrex, dsb, dmb, isb -- stc, ldc, mcr, mcr2, mrc, mrc2, mcrr, mcrr2, mrrc, mrrc2, cdp, cdp2 } -- Add mnemonics for "s" variants. do local t = {} for k,v in pairs(map_op) do if sub(v, -1) == "s" then local v2 = sub(v, 1, 2)..char(byte(v, 3)+1)..sub(v, 4, -2) t[sub(k, 1, -3).."s"..sub(k, -2)] = v2 end end for k,v in pairs(t) do map_op[k] = v end end ------------------------------------------------------------------------------ local function parse_gpr(expr) local tname, ovreg = match(expr, "^([%w_]+):(r1?[0-9])$") local tp = map_type[tname or expr] if tp then local reg = ovreg or tp.reg if not reg then werror("type `"..(tname or expr).."' needs a register override") end expr = reg end local r = match(expr, "^r(1?[0-9])$") if r then r = tonumber(r) if r <= 15 then return r, tp end end werror("bad register name `"..expr.."'") end local function parse_gpr_pm(expr) local pm, expr2 = match(expr, "^([+-]?)(.*)$") return parse_gpr(expr2), (pm == "-") end local function parse_vr(expr, tp) local t, r = match(expr, "^([sd])([0-9]+)$") if t == tp then r = tonumber(r) if r <= 31 then if t == "s" then return shr(r, 1), band(r, 1) end return band(r, 15), shr(r, 4) end end werror("bad register name `"..expr.."'") end local function parse_reglist(reglist) reglist = match(reglist, "^{%s*([^}]*)}$") if not reglist then werror("register list expected") end local rr = 0 for p in gmatch(reglist..",", "%s*([^,]*),") do local rbit = shl(1, parse_gpr(gsub(p, "%s+$", ""))) if band(rr, rbit) ~= 0 then werror("duplicate register `"..p.."'") end rr = rr + rbit end return rr end local function parse_vrlist(reglist) local ta, ra, tb, rb = match(reglist, "^{%s*([sd])([0-9]+)%s*%-%s*([sd])([0-9]+)%s*}$") ra, rb = tonumber(ra), tonumber(rb) if ta and ta == tb and ra and rb and ra <= 31 and rb <= 31 and ra <= rb then local nr = rb+1 - ra if ta == "s" then return shl(shr(ra,1),12)+shl(band(ra,1),22) + nr else return shl(band(ra,15),12)+shl(shr(ra,4),22) + nr*2 + 0x100 end end werror("register list expected") end local function parse_imm(imm, bits, shift, scale, signed) imm = match(imm, "^#(.*)$") if not imm then werror("expected immediate operand") end local n = tonumber(imm) if n then local m = sar(n, scale) if shl(m, scale) == n then if signed then local s = sar(m, bits-1) if s == 0 then return shl(m, shift) elseif s == -1 then return shl(m + shl(1, bits), shift) end else if sar(m, bits) == 0 then return shl(m, shift) end end end werror("out of range immediate `"..imm.."'") else waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) return 0 end end local function parse_imm12(imm) local n = tonumber(imm) if n then local m = band(n) for i=0,-15,-1 do if shr(m, 8) == 0 then return m + shl(band(i, 15), 8) end m = ror(m, 2) end werror("out of range immediate `"..imm.."'") else waction("IMM12", 0, imm) return 0 end end local function parse_imm16(imm) imm = match(imm, "^#(.*)$") if not imm then werror("expected immediate operand") end local n = tonumber(imm) if n then if shr(n, 16) == 0 then return band(n, 0x0fff) + shl(band(n, 0xf000), 4) end werror("out of range immediate `"..imm.."'") else waction("IMM16", 32*16, imm) return 0 end end local function parse_imm_load(imm, ext) local n = tonumber(imm) if n then if ext then if n >= -255 and n <= 255 then local up = 0x00800000 if n < 0 then n = -n; up = 0 end return shl(band(n, 0xf0), 4) + band(n, 0x0f) + up end else if n >= -4095 and n <= 4095 then if n >= 0 then return n+0x00800000 end return -n end end werror("out of range immediate `"..imm.."'") else waction(ext and "IMML8" or "IMML12", 32768 + shl(ext and 8 or 12, 5), imm) return 0 end end local function parse_shift(shift, gprok) if shift == "rrx" then return 3 * 32 else local s, s2 = match(shift, "^(%S+)%s*(.*)$") s = map_shift[s] if not s then werror("expected shift operand") end if sub(s2, 1, 1) == "#" then return parse_imm(s2, 5, 7, 0, false) + shl(s, 5) else if not gprok then werror("expected immediate shift operand") end return shl(parse_gpr(s2), 8) + shl(s, 5) + 16 end end end local function parse_label(label, def) local prefix = sub(label, 1, 2) -- =>label (pc label reference) if prefix == "=>" then return "PC", 0, sub(label, 3) end -- ->name (global label reference) if prefix == "->" then return "LG", map_global[sub(label, 3)] end if def then -- [1-9] (local label definition) if match(label, "^[1-9]$") then return "LG", 10+tonumber(label) end else -- [<>][1-9] (local label reference) local dir, lnum = match(label, "^([<>])([1-9])$") if dir then -- Fwd: 1-9, Bkwd: 11-19. return "LG", lnum + (dir == ">" and 0 or 10) end -- extern label (extern label reference) local extname = match(label, "^extern%s+(%S+)$") if extname then return "EXT", map_extern[extname] end end werror("bad label `"..label.."'") end local function parse_load(params, nparams, n, op) local oplo = band(op, 255) local ext, ldrd = (oplo ~= 0), (oplo == 208) local d if (ldrd or oplo == 240) then d = band(shr(op, 12), 15) if band(d, 1) ~= 0 then werror("odd destination register") end end local pn = params[n] local p1, wb = match(pn, "^%[%s*(.-)%s*%](!?)$") local p2 = params[n+1] if not p1 then if not p2 then if match(pn, "^[<>=%-]") or match(pn, "^extern%s+") then local mode, n, s = parse_label(pn, false) waction("REL_"..mode, n + (ext and 0x1800 or 0x0800), s, 1) return op + 15 * 65536 + 0x01000000 + (ext and 0x00400000 or 0) end local reg, tailr = match(pn, "^([%w_:]+)%s*(.*)$") if reg and tailr ~= "" then local d, tp = parse_gpr(reg) if tp then waction(ext and "IMML8" or "IMML12", 32768 + 32*(ext and 8 or 12), format(tp.ctypefmt, tailr)) return op + shl(d, 16) + 0x01000000 + (ext and 0x00400000 or 0) end end end werror("expected address operand") end if wb == "!" then op = op + 0x00200000 end if p2 then if wb == "!" then werror("bad use of '!'") end local p3 = params[n+2] op = op + shl(parse_gpr(p1), 16) local imm = match(p2, "^#(.*)$") if imm then local m = parse_imm_load(imm, ext) if p3 then werror("too many parameters") end op = op + m + (ext and 0x00400000 or 0) else local m, neg = parse_gpr_pm(p2) if ldrd and (m == d or m-1 == d) then werror("register conflict") end op = op + m + (neg and 0 or 0x00800000) + (ext and 0 or 0x02000000) if p3 then op = op + parse_shift(p3) end end else local p1a, p2 = match(p1, "^([^,%s]*)%s*(.*)$") op = op + shl(parse_gpr(p1a), 16) + 0x01000000 if p2 ~= "" then local imm = match(p2, "^,%s*#(.*)$") if imm then local m = parse_imm_load(imm, ext) op = op + m + (ext and 0x00400000 or 0) else local p2a, p3 = match(p2, "^,%s*([^,%s]*)%s*,?%s*(.*)$") local m, neg = parse_gpr_pm(p2a) if ldrd and (m == d or m-1 == d) then werror("register conflict") end op = op + m + (neg and 0 or 0x00800000) + (ext and 0 or 0x02000000) if p3 ~= "" then if ext then werror("too many parameters") end op = op + parse_shift(p3) end end else if wb == "!" then werror("bad use of '!'") end op = op + (ext and 0x00c00000 or 0x00800000) end end return op end local function parse_vload(q) local reg, imm = match(q, "^%[%s*([^,%s]*)%s*(.*)%]$") if reg then local d = shl(parse_gpr(reg), 16) if imm == "" then return d end imm = match(imm, "^,%s*#(.*)$") if imm then local n = tonumber(imm) if n then if n >= -1020 and n <= 1020 and n%4 == 0 then return d + (n >= 0 and n/4+0x00800000 or -n/4) end werror("out of range immediate `"..imm.."'") else waction("IMMV8", 32768 + 32*8, imm) return d end end else if match(q, "^[<>=%-]") or match(q, "^extern%s+") then local mode, n, s = parse_label(q, false) waction("REL_"..mode, n + 0x2800, s, 1) return 15 * 65536 end local reg, tailr = match(q, "^([%w_:]+)%s*(.*)$") if reg and tailr ~= "" then local d, tp = parse_gpr(reg) if tp then waction("IMMV8", 32768 + 32*8, format(tp.ctypefmt, tailr)) return shl(d, 16) end end end werror("expected address operand") end ------------------------------------------------------------------------------ -- Handle opcodes defined with template strings. local function parse_template(params, template, nparams, pos) local op = tonumber(sub(template, 1, 8), 16) local n = 1 local vr = "s" -- Process each character. for p in gmatch(sub(template, 9), ".") do local q = params[n] if p == "D" then op = op + shl(parse_gpr(q), 12); n = n + 1 elseif p == "N" then op = op + shl(parse_gpr(q), 16); n = n + 1 elseif p == "S" then op = op + shl(parse_gpr(q), 8); n = n + 1 elseif p == "M" then op = op + parse_gpr(q); n = n + 1 elseif p == "d" then local r,h = parse_vr(q, vr); op = op+shl(r,12)+shl(h,22); n = n + 1 elseif p == "n" then local r,h = parse_vr(q, vr); op = op+shl(r,16)+shl(h,7); n = n + 1 elseif p == "m" then local r,h = parse_vr(q, vr); op = op+r+shl(h,5); n = n + 1 elseif p == "P" then local imm = match(q, "^#(.*)$") if imm then op = op + parse_imm12(imm) + 0x02000000 else op = op + parse_gpr(q) end n = n + 1 elseif p == "p" then op = op + parse_shift(q, true); n = n + 1 elseif p == "L" then op = parse_load(params, nparams, n, op) elseif p == "l" then op = op + parse_vload(q) elseif p == "B" then local mode, n, s = parse_label(q, false) waction("REL_"..mode, n, s, 1) elseif p == "C" then -- blx gpr vs. blx label. if match(q, "^([%w_]+):(r1?[0-9])$") or match(q, "^r(1?[0-9])$") then op = op + parse_gpr(q) else if op < 0xe0000000 then werror("unconditional instruction") end local mode, n, s = parse_label(q, false) waction("REL_"..mode, n, s, 1) op = 0xfa000000 end elseif p == "F" then vr = "s" elseif p == "G" then vr = "d" elseif p == "o" then local r, wb = match(q, "^([^!]*)(!?)$") op = op + shl(parse_gpr(r), 16) + (wb == "!" and 0x00200000 or 0) n = n + 1 elseif p == "R" then op = op + parse_reglist(q); n = n + 1 elseif p == "r" then op = op + parse_vrlist(q); n = n + 1 elseif p == "W" then op = op + parse_imm16(q); n = n + 1 elseif p == "v" then op = op + parse_imm(q, 5, 7, 0, false); n = n + 1 elseif p == "w" then local imm = match(q, "^#(.*)$") if imm then op = op + parse_imm(q, 5, 7, 0, false); n = n + 1 else op = op + shl(parse_gpr(q), 8) + 16 end elseif p == "X" then op = op + parse_imm(q, 5, 16, 0, false); n = n + 1 elseif p == "Y" then local imm = tonumber(match(q, "^#(.*)$")); n = n + 1 if not imm or shr(imm, 8) ~= 0 then werror("bad immediate operand") end op = op + shl(band(imm, 0xf0), 12) + band(imm, 0x0f) elseif p == "K" then local imm = tonumber(match(q, "^#(.*)$")); n = n + 1 if not imm or shr(imm, 16) ~= 0 then werror("bad immediate operand") end op = op + shl(band(imm, 0xfff0), 4) + band(imm, 0x000f) elseif p == "T" then op = op + parse_imm(q, 24, 0, 0, false); n = n + 1 elseif p == "s" then -- Ignored. else assert(false) end end wputpos(pos, op) end map_op[".template__"] = function(params, template, nparams) if not params then return sub(template, 9) end -- Limit number of section buffer positions used by a single dasm_put(). -- A single opcode needs a maximum of 3 positions. if secpos+3 > maxsecpos then wflush() end local pos = wpos() local apos, spos = #actargs, secpos local ok, err for t in gmatch(template, "[^|]+") do ok, err = pcall(parse_template, params, t, nparams, pos) if ok then return end secpos = spos actargs[apos+1] = nil actargs[apos+2] = nil actargs[apos+3] = nil end error(err, 0) end ------------------------------------------------------------------------------ -- Pseudo-opcode to mark the position where the action list is to be emitted. map_op[".actionlist_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeactions(out, name) end) end -- Pseudo-opcode to mark the position where the global enum is to be emitted. map_op[".globals_1"] = function(params) if not params then return "prefix" end local prefix = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeglobals(out, prefix) end) end -- Pseudo-opcode to mark the position where the global names are to be emitted. map_op[".globalnames_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeglobalnames(out, name) end) end -- Pseudo-opcode to mark the position where the extern names are to be emitted. map_op[".externnames_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeexternnames(out, name) end) end ------------------------------------------------------------------------------ -- Label pseudo-opcode (converted from trailing colon form). map_op[".label_1"] = function(params) if not params then return "[1-9] | ->global | =>pcexpr" end if secpos+1 > maxsecpos then wflush() end local mode, n, s = parse_label(params[1], true) if mode == "EXT" then werror("bad label definition") end waction("LABEL_"..mode, n, s, 1) end ------------------------------------------------------------------------------ -- Pseudo-opcodes for data storage. map_op[".long_*"] = function(params) if not params then return "imm..." end for _,p in ipairs(params) do local n = tonumber(p) if not n then werror("bad immediate `"..p.."'") end if n < 0 then n = n + 2^32 end wputw(n) if secpos+2 > maxsecpos then wflush() end end end -- Alignment pseudo-opcode. map_op[".align_1"] = function(params) if not params then return "numpow2" end if secpos+1 > maxsecpos then wflush() end local align = tonumber(params[1]) if align then local x = align -- Must be a power of 2 in the range (2 ... 256). for i=1,8 do x = x / 2 if x == 1 then waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. return end end end werror("bad alignment") end ------------------------------------------------------------------------------ -- Pseudo-opcode for (primitive) type definitions (map to C types). map_op[".type_3"] = function(params, nparams) if not params then return nparams == 2 and "name, ctype" or "name, ctype, reg" end local name, ctype, reg = params[1], params[2], params[3] if not match(name, "^[%a_][%w_]*$") then werror("bad type name `"..name.."'") end local tp = map_type[name] if tp then werror("duplicate type `"..name.."'") end -- Add #type to defines. A bit unclean to put it in map_archdef. map_archdef["#"..name] = "sizeof("..ctype..")" -- Add new type and emit shortcut define. local num = ctypenum + 1 map_type[name] = { ctype = ctype, ctypefmt = format("Dt%X(%%s)", num), reg = reg, } wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) ctypenum = num end map_op[".type_2"] = map_op[".type_3"] -- Dump type definitions. local function dumptypes(out, lvl) local t = {} for name in pairs(map_type) do t[#t+1] = name end sort(t) out:write("Type definitions:\n") for _,name in ipairs(t) do local tp = map_type[name] local reg = tp.reg or "" out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) end out:write("\n") end ------------------------------------------------------------------------------ -- Set the current section. function _M.section(num) waction("SECTION", num) wflush(true) -- SECTION is a terminal action. end ------------------------------------------------------------------------------ -- Dump architecture description. function _M.dumparch(out) out:write(format("DynASM %s version %s, released %s\n\n", _info.arch, _info.version, _info.release)) dumpactions(out) end -- Dump all user defined elements. function _M.dumpdef(out, lvl) dumptypes(out, lvl) dumpglobals(out, lvl) dumpexterns(out, lvl) end ------------------------------------------------------------------------------ -- Pass callbacks from/to the DynASM core. function _M.passcb(wl, we, wf, ww) wline, werror, wfatal, wwarn = wl, we, wf, ww return wflush end -- Setup the arch-specific module. function _M.setup(arch, opt) g_arch, g_opt = arch, opt end -- Merge the core maps and the arch-specific maps. function _M.mergemaps(map_coreop, map_def) setmetatable(map_op, { __index = function(t, k) local v = map_coreop[k] if v then return v end local k1, cc, k2 = match(k, "^(.-)(..)([._].*)$") local cv = map_cond[cc] if cv then local v = rawget(t, k1..k2) if type(v) == "string" then local scv = format("%x", cv) return gsub(scv..sub(v, 2), "|e", "|"..scv) end end end }) setmetatable(map_def, { __index = map_archdef }) return map_op, map_def end return _M ------------------------------------------------------------------------------ ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_mips.h ================================================ /* ** DynASM MIPS encoding engine. ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. ** Released under the MIT license. See dynasm.lua for full copyright notice. */ #include #include #include #include #define DASM_ARCH "mips" #ifndef DASM_EXTERN #define DASM_EXTERN(a,b,c,d) 0 #endif /* Action definitions. */ enum { DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, /* The following actions need a buffer position. */ DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, /* The following actions also have an argument. */ DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, DASM__MAX }; /* Maximum number of section buffer positions for a single dasm_put() call. */ #define DASM_MAXSECPOS 25 /* DynASM encoder status codes. Action list offset or number are or'ed in. */ #define DASM_S_OK 0x00000000 #define DASM_S_NOMEM 0x01000000 #define DASM_S_PHASE 0x02000000 #define DASM_S_MATCH_SEC 0x03000000 #define DASM_S_RANGE_I 0x11000000 #define DASM_S_RANGE_SEC 0x12000000 #define DASM_S_RANGE_LG 0x13000000 #define DASM_S_RANGE_PC 0x14000000 #define DASM_S_RANGE_REL 0x15000000 #define DASM_S_UNDEF_LG 0x21000000 #define DASM_S_UNDEF_PC 0x22000000 /* Macros to convert positions (8 bit section + 24 bit index). */ #define DASM_POS2IDX(pos) ((pos)&0x00ffffff) #define DASM_POS2BIAS(pos) ((pos)&0xff000000) #define DASM_SEC2POS(sec) ((sec)<<24) #define DASM_POS2SEC(pos) ((pos)>>24) #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) /* Action list type. */ typedef const unsigned int *dasm_ActList; /* Per-section structure. */ typedef struct dasm_Section { int *rbuf; /* Biased buffer pointer (negative section bias). */ int *buf; /* True buffer pointer. */ size_t bsize; /* Buffer size in bytes. */ int pos; /* Biased buffer position. */ int epos; /* End of biased buffer position - max single put. */ int ofs; /* Byte offset into section. */ } dasm_Section; /* Core structure holding the DynASM encoding state. */ struct dasm_State { size_t psize; /* Allocated size of this structure. */ dasm_ActList actionlist; /* Current actionlist pointer. */ int *lglabels; /* Local/global chain/pos ptrs. */ size_t lgsize; int *pclabels; /* PC label chains/pos ptrs. */ size_t pcsize; void **globals; /* Array of globals (bias -10). */ dasm_Section *section; /* Pointer to active section. */ size_t codesize; /* Total size of all code sections. */ int maxsection; /* 0 <= sectionidx < maxsection. */ int status; /* Status code. */ dasm_Section sections[1]; /* All sections. Alloc-extended. */ }; /* The size of the core structure depends on the max. number of sections. */ #define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) /* Initialize DynASM state. */ void dasm_init(Dst_DECL, int maxsection) { dasm_State *D; size_t psz = 0; int i; Dst_REF = NULL; DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); D = Dst_REF; D->psize = psz; D->lglabels = NULL; D->lgsize = 0; D->pclabels = NULL; D->pcsize = 0; D->globals = NULL; D->maxsection = maxsection; for (i = 0; i < maxsection; i++) { D->sections[i].buf = NULL; /* Need this for pass3. */ D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); D->sections[i].bsize = 0; D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ } } /* Free DynASM state. */ void dasm_free(Dst_DECL) { dasm_State *D = Dst_REF; int i; for (i = 0; i < D->maxsection; i++) if (D->sections[i].buf) DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); DASM_M_FREE(Dst, D, D->psize); } /* Setup global label array. Must be called before dasm_setup(). */ void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) { dasm_State *D = Dst_REF; D->globals = gl - 10; /* Negative bias to compensate for locals. */ DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); } /* Grow PC label array. Can be called after dasm_setup(), too. */ void dasm_growpc(Dst_DECL, unsigned int maxpc) { dasm_State *D = Dst_REF; size_t osz = D->pcsize; DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); } /* Setup encoder. */ void dasm_setup(Dst_DECL, const void *actionlist) { dasm_State *D = Dst_REF; int i; D->actionlist = (dasm_ActList)actionlist; D->status = DASM_S_OK; D->section = &D->sections[0]; memset((void *)D->lglabels, 0, D->lgsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); for (i = 0; i < D->maxsection; i++) { D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].ofs = 0; } } #ifdef DASM_CHECKS #define CK(x, st) \ do { if (!(x)) { \ D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) #define CKPL(kind, st) \ do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) #else #define CK(x, st) ((void)0) #define CKPL(kind, st) ((void)0) #endif /* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ void dasm_put(Dst_DECL, int start, ...) { va_list ap; dasm_State *D = Dst_REF; dasm_ActList p = D->actionlist + start; dasm_Section *sec = D->section; int pos = sec->pos, ofs = sec->ofs; int *b; if (pos >= sec->epos) { DASM_M_GROW(Dst, int, sec->buf, sec->bsize, sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); sec->rbuf = sec->buf - DASM_POS2BIAS(pos); sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); } b = sec->rbuf; b[pos++] = start; va_start(ap, start); while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16) - 0xff00; if (action >= DASM__MAX) { ofs += 4; } else { int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; switch (action) { case DASM_STOP: goto stop; case DASM_SECTION: n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; goto stop; case DASM_ESC: p++; ofs += 4; break; case DASM_REL_EXT: break; case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; case DASM_REL_LG: n = (ins & 2047) - 10; pl = D->lglabels + n; if (n >= 0) { CKPL(lg, LG); goto putrel; } /* Bkwd rel or global. */ pl += 10; n = *pl; if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ goto linkrel; case DASM_REL_PC: pl = D->pclabels + n; CKPL(pc, PC); putrel: n = *pl; if (n < 0) { /* Label exists. Get label pos and store it. */ b[pos] = -n; } else { linkrel: b[pos] = n; /* Else link to rel chain, anchored at label. */ *pl = pos; } pos++; break; case DASM_LABEL_LG: pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; case DASM_LABEL_PC: pl = D->pclabels + n; CKPL(pc, PC); putlabel: n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } *pl = -pos; /* Label exists now. */ b[pos++] = ofs; /* Store pass1 offset estimate. */ break; case DASM_IMM: #ifdef DASM_CHECKS CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); #endif n >>= ((ins>>10)&31); #ifdef DASM_CHECKS if (ins & 0x8000) CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); else CK((n>>((ins>>5)&31)) == 0, RANGE_I); #endif b[pos++] = n; break; } } } stop: va_end(ap); sec->pos = pos; sec->ofs = ofs; } #undef CK /* Pass 2: Link sections, shrink aligns, fix label offsets. */ int dasm_link(Dst_DECL, size_t *szp) { dasm_State *D = Dst_REF; int secnum; int ofs = 0; #ifdef DASM_CHECKS *szp = 0; if (D->status != DASM_S_OK) return D->status; { int pc; for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; } #endif { /* Handle globals not defined in this translation unit. */ int idx; for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { int n = D->lglabels[idx]; /* Undefined label: Collapse rel chain and replace with marker (< 0). */ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } } } /* Combine all code sections. No support for data sections (yet). */ for (secnum = 0; secnum < D->maxsection; secnum++) { dasm_Section *sec = D->sections + secnum; int *b = sec->rbuf; int pos = DASM_SEC2POS(secnum); int lastpos = sec->pos; while (pos != lastpos) { dasm_ActList p = D->actionlist + b[pos++]; while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16) - 0xff00; switch (action) { case DASM_STOP: case DASM_SECTION: goto stop; case DASM_ESC: p++; break; case DASM_REL_EXT: break; case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; case DASM_REL_LG: case DASM_REL_PC: pos++; break; case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; case DASM_IMM: pos++; break; } } stop: (void)0; } ofs += sec->ofs; /* Next section starts right after current section. */ } D->codesize = ofs; /* Total size of all code sections */ *szp = ofs; return DASM_S_OK; } #ifdef DASM_CHECKS #define CK(x, st) \ do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) #else #define CK(x, st) ((void)0) #endif /* Pass 3: Encode sections. */ int dasm_encode(Dst_DECL, void *buffer) { dasm_State *D = Dst_REF; char *base = (char *)buffer; unsigned int *cp = (unsigned int *)buffer; int secnum; /* Encode all code sections. No support for data sections (yet). */ for (secnum = 0; secnum < D->maxsection; secnum++) { dasm_Section *sec = D->sections + secnum; int *b = sec->buf; int *endb = sec->rbuf + sec->pos; while (b != endb) { dasm_ActList p = D->actionlist + *b++; while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16) - 0xff00; int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; switch (action) { case DASM_STOP: case DASM_SECTION: goto stop; case DASM_ESC: *cp++ = *p++; break; case DASM_REL_EXT: n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1); goto patchrel; case DASM_ALIGN: ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; break; case DASM_REL_LG: CK(n >= 0, UNDEF_LG); case DASM_REL_PC: CK(n >= 0, UNDEF_PC); n = *DASM_POS2PTR(D, n); if (ins & 2048) n = n - (int)((char *)cp - base); else n = (n + (int)base) & 0x0fffffff; patchrel: CK((n & 3) == 0 && ((n + ((ins & 2048) ? 0x00020000 : 0)) >> ((ins & 2048) ? 18 : 28)) == 0, RANGE_REL); cp[-1] |= ((n>>2) & ((ins & 2048) ? 0x0000ffff: 0x03ffffff)); break; case DASM_LABEL_LG: ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); break; case DASM_LABEL_PC: break; case DASM_IMM: cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); break; default: *cp++ = ins; break; } } stop: (void)0; } } if (base + D->codesize != (char *)cp) /* Check for phase errors. */ return DASM_S_PHASE; return DASM_S_OK; } #undef CK /* Get PC label offset. */ int dasm_getpclabel(Dst_DECL, unsigned int pc) { dasm_State *D = Dst_REF; if (pc*sizeof(int) < D->pcsize) { int pos = D->pclabels[pc]; if (pos < 0) return *DASM_POS2PTR(D, -pos); if (pos > 0) return -1; /* Undefined. */ } return -2; /* Unused or out of range. */ } #ifdef DASM_CHECKS /* Optional sanity checker to call between isolated encoding steps. */ int dasm_checkstep(Dst_DECL, int secmatch) { dasm_State *D = Dst_REF; if (D->status == DASM_S_OK) { int i; for (i = 1; i <= 9; i++) { if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } D->lglabels[i] = 0; } } if (D->status == DASM_S_OK && secmatch >= 0 && D->section != &D->sections[secmatch]) D->status = DASM_S_MATCH_SEC|(D->section-D->sections); return D->status; } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_mips.lua ================================================ ------------------------------------------------------------------------------ -- DynASM MIPS module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------ -- Module information: local _info = { arch = "mips", description = "DynASM MIPS module", version = "1.3.0", vernum = 10300, release = "2012-01-23", author = "Mike Pall", license = "MIT", } -- Exported glue functions for the arch-specific module. local _M = { _info = _info } -- Cache library functions. local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs local assert, setmetatable = assert, setmetatable local _s = string local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char local match, gmatch = _s.match, _s.gmatch local concat, sort = table.concat, table.sort local bit = bit or require("bit") local band, shl, sar, tohex = bit.band, bit.lshift, bit.arshift, bit.tohex -- Inherited tables and callbacks. local g_opt, g_arch local wline, werror, wfatal, wwarn -- Action name list. -- CHECK: Keep this in sync with the C code! local action_names = { "STOP", "SECTION", "ESC", "REL_EXT", "ALIGN", "REL_LG", "LABEL_LG", "REL_PC", "LABEL_PC", "IMM", } -- Maximum number of section buffer positions for dasm_put(). -- CHECK: Keep this in sync with the C code! local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. -- Action name -> action number. local map_action = {} for n,name in ipairs(action_names) do map_action[name] = n-1 end -- Action list buffer. local actlist = {} -- Argument list for next dasm_put(). Start with offset 0 into action list. local actargs = { 0 } -- Current number of section buffer positions for dasm_put(). local secpos = 1 ------------------------------------------------------------------------------ -- Dump action names and numbers. local function dumpactions(out) out:write("DynASM encoding engine action codes:\n") for n,name in ipairs(action_names) do local num = map_action[name] out:write(format(" %-10s %02X %d\n", name, num, num)) end out:write("\n") end -- Write action list buffer as a huge static C array. local function writeactions(out, name) local nn = #actlist if nn == 0 then nn = 1; actlist[0] = map_action.STOP end out:write("static const unsigned int ", name, "[", nn, "] = {\n") for i = 1,nn-1 do assert(out:write("0x", tohex(actlist[i]), ",\n")) end assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) end ------------------------------------------------------------------------------ -- Add word to action list. local function wputxw(n) assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") actlist[#actlist+1] = n end -- Add action to list with optional arg. Advance buffer pos, too. local function waction(action, val, a, num) local w = assert(map_action[action], "bad action name `"..action.."'") wputxw(0xff000000 + w * 0x10000 + (val or 0)) if a then actargs[#actargs+1] = a end if a or num then secpos = secpos + (num or 1) end end -- Flush action list (intervening C code or buffer pos overflow). local function wflush(term) if #actlist == actargs[1] then return end -- Nothing to flush. if not term then waction("STOP") end -- Terminate action list. wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). secpos = 1 -- The actionlist offset occupies a buffer position, too. end -- Put escaped word. local function wputw(n) if n >= 0xff000000 then waction("ESC") end wputxw(n) end -- Reserve position for word. local function wpos() local pos = #actlist+1 actlist[pos] = "" return pos end -- Store word to reserved position. local function wputpos(pos, n) assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") actlist[pos] = n end ------------------------------------------------------------------------------ -- Global label name -> global label number. With auto assignment on 1st use. local next_global = 20 local map_global = setmetatable({}, { __index = function(t, name) if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end local n = next_global if n > 2047 then werror("too many global labels") end next_global = n + 1 t[name] = n return n end}) -- Dump global labels. local function dumpglobals(out, lvl) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("Global labels:\n") for i=20,next_global-1 do out:write(format(" %s\n", t[i])) end out:write("\n") end -- Write global label enum. local function writeglobals(out, prefix) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("enum {\n") for i=20,next_global-1 do out:write(" ", prefix, t[i], ",\n") end out:write(" ", prefix, "_MAX\n};\n") end -- Write global label names. local function writeglobalnames(out, name) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("static const char *const ", name, "[] = {\n") for i=20,next_global-1 do out:write(" \"", t[i], "\",\n") end out:write(" (const char *)0\n};\n") end ------------------------------------------------------------------------------ -- Extern label name -> extern label number. With auto assignment on 1st use. local next_extern = 0 local map_extern_ = {} local map_extern = setmetatable({}, { __index = function(t, name) -- No restrictions on the name for now. local n = next_extern if n > 2047 then werror("too many extern labels") end next_extern = n + 1 t[name] = n map_extern_[n] = name return n end}) -- Dump extern labels. local function dumpexterns(out, lvl) out:write("Extern labels:\n") for i=0,next_extern-1 do out:write(format(" %s\n", map_extern_[i])) end out:write("\n") end -- Write extern label names. local function writeexternnames(out, name) out:write("static const char *const ", name, "[] = {\n") for i=0,next_extern-1 do out:write(" \"", map_extern_[i], "\",\n") end out:write(" (const char *)0\n};\n") end ------------------------------------------------------------------------------ -- Arch-specific maps. local map_archdef = { sp="r29", ra="r31" } -- Ext. register name -> int. name. local map_type = {} -- Type name -> { ctype, reg } local ctypenum = 0 -- Type number (for Dt... macros). -- Reverse defines for registers. function _M.revdef(s) if s == "r29" then return "sp" elseif s == "r31" then return "ra" end return s end ------------------------------------------------------------------------------ -- Template strings for MIPS instructions. local map_op = { -- First-level opcodes. j_1 = "08000000J", jal_1 = "0c000000J", b_1 = "10000000B", beqz_2 = "10000000SB", beq_3 = "10000000STB", bnez_2 = "14000000SB", bne_3 = "14000000STB", blez_2 = "18000000SB", bgtz_2 = "1c000000SB", addi_3 = "20000000TSI", li_2 = "24000000TI", addiu_3 = "24000000TSI", slti_3 = "28000000TSI", sltiu_3 = "2c000000TSI", andi_3 = "30000000TSU", lu_2 = "34000000TU", ori_3 = "34000000TSU", xori_3 = "38000000TSU", lui_2 = "3c000000TU", beqzl_2 = "50000000SB", beql_3 = "50000000STB", bnezl_2 = "54000000SB", bnel_3 = "54000000STB", blezl_2 = "58000000SB", bgtzl_2 = "5c000000SB", lb_2 = "80000000TO", lh_2 = "84000000TO", lwl_2 = "88000000TO", lw_2 = "8c000000TO", lbu_2 = "90000000TO", lhu_2 = "94000000TO", lwr_2 = "98000000TO", sb_2 = "a0000000TO", sh_2 = "a4000000TO", swl_2 = "a8000000TO", sw_2 = "ac000000TO", swr_2 = "b8000000TO", cache_2 = "bc000000NO", ll_2 = "c0000000TO", lwc1_2 = "c4000000HO", pref_2 = "cc000000NO", ldc1_2 = "d4000000HO", sc_2 = "e0000000TO", swc1_2 = "e4000000HO", sdc1_2 = "f4000000HO", -- Opcode SPECIAL. nop_0 = "00000000", sll_3 = "00000000DTA", movf_2 = "00000001DS", movf_3 = "00000001DSC", movt_2 = "00010001DS", movt_3 = "00010001DSC", srl_3 = "00000002DTA", rotr_3 = "00200002DTA", sra_3 = "00000003DTA", sllv_3 = "00000004DTS", srlv_3 = "00000006DTS", rotrv_3 = "00000046DTS", srav_3 = "00000007DTS", jr_1 = "00000008S", jalr_1 = "0000f809S", jalr_2 = "00000009DS", movz_3 = "0000000aDST", movn_3 = "0000000bDST", syscall_0 = "0000000c", syscall_1 = "0000000cY", break_0 = "0000000d", break_1 = "0000000dY", sync_0 = "0000000f", mfhi_1 = "00000010D", mthi_1 = "00000011S", mflo_1 = "00000012D", mtlo_1 = "00000013S", mult_2 = "00000018ST", multu_2 = "00000019ST", div_2 = "0000001aST", divu_2 = "0000001bST", add_3 = "00000020DST", move_2 = "00000021DS", addu_3 = "00000021DST", sub_3 = "00000022DST", negu_2 = "00000023DT", subu_3 = "00000023DST", and_3 = "00000024DST", or_3 = "00000025DST", xor_3 = "00000026DST", not_2 = "00000027DS", nor_3 = "00000027DST", slt_3 = "0000002aDST", sltu_3 = "0000002bDST", tge_2 = "00000030ST", tge_3 = "00000030STZ", tgeu_2 = "00000031ST", tgeu_3 = "00000031STZ", tlt_2 = "00000032ST", tlt_3 = "00000032STZ", tltu_2 = "00000033ST", tltu_3 = "00000033STZ", teq_2 = "00000034ST", teq_3 = "00000034STZ", tne_2 = "00000036ST", tne_3 = "00000036STZ", -- Opcode REGIMM. bltz_2 = "04000000SB", bgez_2 = "04010000SB", bltzl_2 = "04020000SB", bgezl_2 = "04030000SB", tgei_2 = "04080000SI", tgeiu_2 = "04090000SI", tlti_2 = "040a0000SI", tltiu_2 = "040b0000SI", teqi_2 = "040c0000SI", tnei_2 = "040e0000SI", bltzal_2 = "04100000SB", bal_1 = "04110000B", bgezal_2 = "04110000SB", bltzall_2 = "04120000SB", bgezall_2 = "04130000SB", synci_1 = "041f0000O", -- Opcode SPECIAL2. madd_2 = "70000000ST", maddu_2 = "70000001ST", mul_3 = "70000002DST", msub_2 = "70000004ST", msubu_2 = "70000005ST", clz_2 = "70000020DS=", clo_2 = "70000021DS=", sdbbp_0 = "7000003f", sdbbp_1 = "7000003fY", -- Opcode SPECIAL3. ext_4 = "7c000000TSAM", -- Note: last arg is msbd = size-1 ins_4 = "7c000004TSAM", -- Note: last arg is msb = pos+size-1 wsbh_2 = "7c0000a0DT", seb_2 = "7c000420DT", seh_2 = "7c000620DT", rdhwr_2 = "7c00003bTD", -- Opcode COP0. mfc0_2 = "40000000TD", mfc0_3 = "40000000TDW", mtc0_2 = "40800000TD", mtc0_3 = "40800000TDW", rdpgpr_2 = "41400000DT", di_0 = "41606000", di_1 = "41606000T", ei_0 = "41606020", ei_1 = "41606020T", wrpgpr_2 = "41c00000DT", tlbr_0 = "42000001", tlbwi_0 = "42000002", tlbwr_0 = "42000006", tlbp_0 = "42000008", eret_0 = "42000018", deret_0 = "4200001f", wait_0 = "42000020", -- Opcode COP1. mfc1_2 = "44000000TG", cfc1_2 = "44400000TG", mfhc1_2 = "44600000TG", mtc1_2 = "44800000TG", ctc1_2 = "44c00000TG", mthc1_2 = "44e00000TG", bc1f_1 = "45000000B", bc1f_2 = "45000000CB", bc1t_1 = "45010000B", bc1t_2 = "45010000CB", bc1fl_1 = "45020000B", bc1fl_2 = "45020000CB", bc1tl_1 = "45030000B", bc1tl_2 = "45030000CB", ["add.s_3"] = "46000000FGH", ["sub.s_3"] = "46000001FGH", ["mul.s_3"] = "46000002FGH", ["div.s_3"] = "46000003FGH", ["sqrt.s_2"] = "46000004FG", ["abs.s_2"] = "46000005FG", ["mov.s_2"] = "46000006FG", ["neg.s_2"] = "46000007FG", ["round.l.s_2"] = "46000008FG", ["trunc.l.s_2"] = "46000009FG", ["ceil.l.s_2"] = "4600000aFG", ["floor.l.s_2"] = "4600000bFG", ["round.w.s_2"] = "4600000cFG", ["trunc.w.s_2"] = "4600000dFG", ["ceil.w.s_2"] = "4600000eFG", ["floor.w.s_2"] = "4600000fFG", ["movf.s_2"] = "46000011FG", ["movf.s_3"] = "46000011FGC", ["movt.s_2"] = "46010011FG", ["movt.s_3"] = "46010011FGC", ["movz.s_3"] = "46000012FGT", ["movn.s_3"] = "46000013FGT", ["recip.s_2"] = "46000015FG", ["rsqrt.s_2"] = "46000016FG", ["cvt.d.s_2"] = "46000021FG", ["cvt.w.s_2"] = "46000024FG", ["cvt.l.s_2"] = "46000025FG", ["cvt.ps.s_3"] = "46000026FGH", ["c.f.s_2"] = "46000030GH", ["c.f.s_3"] = "46000030VGH", ["c.un.s_2"] = "46000031GH", ["c.un.s_3"] = "46000031VGH", ["c.eq.s_2"] = "46000032GH", ["c.eq.s_3"] = "46000032VGH", ["c.ueq.s_2"] = "46000033GH", ["c.ueq.s_3"] = "46000033VGH", ["c.olt.s_2"] = "46000034GH", ["c.olt.s_3"] = "46000034VGH", ["c.ult.s_2"] = "46000035GH", ["c.ult.s_3"] = "46000035VGH", ["c.ole.s_2"] = "46000036GH", ["c.ole.s_3"] = "46000036VGH", ["c.ule.s_2"] = "46000037GH", ["c.ule.s_3"] = "46000037VGH", ["c.sf.s_2"] = "46000038GH", ["c.sf.s_3"] = "46000038VGH", ["c.ngle.s_2"] = "46000039GH", ["c.ngle.s_3"] = "46000039VGH", ["c.seq.s_2"] = "4600003aGH", ["c.seq.s_3"] = "4600003aVGH", ["c.ngl.s_2"] = "4600003bGH", ["c.ngl.s_3"] = "4600003bVGH", ["c.lt.s_2"] = "4600003cGH", ["c.lt.s_3"] = "4600003cVGH", ["c.nge.s_2"] = "4600003dGH", ["c.nge.s_3"] = "4600003dVGH", ["c.le.s_2"] = "4600003eGH", ["c.le.s_3"] = "4600003eVGH", ["c.ngt.s_2"] = "4600003fGH", ["c.ngt.s_3"] = "4600003fVGH", ["add.d_3"] = "46200000FGH", ["sub.d_3"] = "46200001FGH", ["mul.d_3"] = "46200002FGH", ["div.d_3"] = "46200003FGH", ["sqrt.d_2"] = "46200004FG", ["abs.d_2"] = "46200005FG", ["mov.d_2"] = "46200006FG", ["neg.d_2"] = "46200007FG", ["round.l.d_2"] = "46200008FG", ["trunc.l.d_2"] = "46200009FG", ["ceil.l.d_2"] = "4620000aFG", ["floor.l.d_2"] = "4620000bFG", ["round.w.d_2"] = "4620000cFG", ["trunc.w.d_2"] = "4620000dFG", ["ceil.w.d_2"] = "4620000eFG", ["floor.w.d_2"] = "4620000fFG", ["movf.d_2"] = "46200011FG", ["movf.d_3"] = "46200011FGC", ["movt.d_2"] = "46210011FG", ["movt.d_3"] = "46210011FGC", ["movz.d_3"] = "46200012FGT", ["movn.d_3"] = "46200013FGT", ["recip.d_2"] = "46200015FG", ["rsqrt.d_2"] = "46200016FG", ["cvt.s.d_2"] = "46200020FG", ["cvt.w.d_2"] = "46200024FG", ["cvt.l.d_2"] = "46200025FG", ["c.f.d_2"] = "46200030GH", ["c.f.d_3"] = "46200030VGH", ["c.un.d_2"] = "46200031GH", ["c.un.d_3"] = "46200031VGH", ["c.eq.d_2"] = "46200032GH", ["c.eq.d_3"] = "46200032VGH", ["c.ueq.d_2"] = "46200033GH", ["c.ueq.d_3"] = "46200033VGH", ["c.olt.d_2"] = "46200034GH", ["c.olt.d_3"] = "46200034VGH", ["c.ult.d_2"] = "46200035GH", ["c.ult.d_3"] = "46200035VGH", ["c.ole.d_2"] = "46200036GH", ["c.ole.d_3"] = "46200036VGH", ["c.ule.d_2"] = "46200037GH", ["c.ule.d_3"] = "46200037VGH", ["c.sf.d_2"] = "46200038GH", ["c.sf.d_3"] = "46200038VGH", ["c.ngle.d_2"] = "46200039GH", ["c.ngle.d_3"] = "46200039VGH", ["c.seq.d_2"] = "4620003aGH", ["c.seq.d_3"] = "4620003aVGH", ["c.ngl.d_2"] = "4620003bGH", ["c.ngl.d_3"] = "4620003bVGH", ["c.lt.d_2"] = "4620003cGH", ["c.lt.d_3"] = "4620003cVGH", ["c.nge.d_2"] = "4620003dGH", ["c.nge.d_3"] = "4620003dVGH", ["c.le.d_2"] = "4620003eGH", ["c.le.d_3"] = "4620003eVGH", ["c.ngt.d_2"] = "4620003fGH", ["c.ngt.d_3"] = "4620003fVGH", ["add.ps_3"] = "46c00000FGH", ["sub.ps_3"] = "46c00001FGH", ["mul.ps_3"] = "46c00002FGH", ["abs.ps_2"] = "46c00005FG", ["mov.ps_2"] = "46c00006FG", ["neg.ps_2"] = "46c00007FG", ["movf.ps_2"] = "46c00011FG", ["movf.ps_3"] = "46c00011FGC", ["movt.ps_2"] = "46c10011FG", ["movt.ps_3"] = "46c10011FGC", ["movz.ps_3"] = "46c00012FGT", ["movn.ps_3"] = "46c00013FGT", ["cvt.s.pu_2"] = "46c00020FG", ["cvt.s.pl_2"] = "46c00028FG", ["pll.ps_3"] = "46c0002cFGH", ["plu.ps_3"] = "46c0002dFGH", ["pul.ps_3"] = "46c0002eFGH", ["puu.ps_3"] = "46c0002fFGH", ["c.f.ps_2"] = "46c00030GH", ["c.f.ps_3"] = "46c00030VGH", ["c.un.ps_2"] = "46c00031GH", ["c.un.ps_3"] = "46c00031VGH", ["c.eq.ps_2"] = "46c00032GH", ["c.eq.ps_3"] = "46c00032VGH", ["c.ueq.ps_2"] = "46c00033GH", ["c.ueq.ps_3"] = "46c00033VGH", ["c.olt.ps_2"] = "46c00034GH", ["c.olt.ps_3"] = "46c00034VGH", ["c.ult.ps_2"] = "46c00035GH", ["c.ult.ps_3"] = "46c00035VGH", ["c.ole.ps_2"] = "46c00036GH", ["c.ole.ps_3"] = "46c00036VGH", ["c.ule.ps_2"] = "46c00037GH", ["c.ule.ps_3"] = "46c00037VGH", ["c.sf.ps_2"] = "46c00038GH", ["c.sf.ps_3"] = "46c00038VGH", ["c.ngle.ps_2"] = "46c00039GH", ["c.ngle.ps_3"] = "46c00039VGH", ["c.seq.ps_2"] = "46c0003aGH", ["c.seq.ps_3"] = "46c0003aVGH", ["c.ngl.ps_2"] = "46c0003bGH", ["c.ngl.ps_3"] = "46c0003bVGH", ["c.lt.ps_2"] = "46c0003cGH", ["c.lt.ps_3"] = "46c0003cVGH", ["c.nge.ps_2"] = "46c0003dGH", ["c.nge.ps_3"] = "46c0003dVGH", ["c.le.ps_2"] = "46c0003eGH", ["c.le.ps_3"] = "46c0003eVGH", ["c.ngt.ps_2"] = "46c0003fGH", ["c.ngt.ps_3"] = "46c0003fVGH", ["cvt.s.w_2"] = "46800020FG", ["cvt.d.w_2"] = "46800021FG", ["cvt.s.l_2"] = "46a00020FG", ["cvt.d.l_2"] = "46a00021FG", -- Opcode COP1X. lwxc1_2 = "4c000000FX", ldxc1_2 = "4c000001FX", luxc1_2 = "4c000005FX", swxc1_2 = "4c000008FX", sdxc1_2 = "4c000009FX", suxc1_2 = "4c00000dFX", prefx_2 = "4c00000fMX", ["alnv.ps_4"] = "4c00001eFGHS", ["madd.s_4"] = "4c000020FRGH", ["madd.d_4"] = "4c000021FRGH", ["madd.ps_4"] = "4c000026FRGH", ["msub.s_4"] = "4c000028FRGH", ["msub.d_4"] = "4c000029FRGH", ["msub.ps_4"] = "4c00002eFRGH", ["nmadd.s_4"] = "4c000030FRGH", ["nmadd.d_4"] = "4c000031FRGH", ["nmadd.ps_4"] = "4c000036FRGH", ["nmsub.s_4"] = "4c000038FRGH", ["nmsub.d_4"] = "4c000039FRGH", ["nmsub.ps_4"] = "4c00003eFRGH", } ------------------------------------------------------------------------------ local function parse_gpr(expr) local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$") local tp = map_type[tname or expr] if tp then local reg = ovreg or tp.reg if not reg then werror("type `"..(tname or expr).."' needs a register override") end expr = reg end local r = match(expr, "^r([1-3]?[0-9])$") if r then r = tonumber(r) if r <= 31 then return r, tp end end werror("bad register name `"..expr.."'") end local function parse_fpr(expr) local r = match(expr, "^f([1-3]?[0-9])$") if r then r = tonumber(r) if r <= 31 then return r end end werror("bad register name `"..expr.."'") end local function parse_imm(imm, bits, shift, scale, signed) local n = tonumber(imm) if n then local m = sar(n, scale) if shl(m, scale) == n then if signed then local s = sar(m, bits-1) if s == 0 then return shl(m, shift) elseif s == -1 then return shl(m + shl(1, bits), shift) end else if sar(m, bits) == 0 then return shl(m, shift) end end end werror("out of range immediate `"..imm.."'") elseif match(imm, "^[rf]([1-3]?[0-9])$") or match(imm, "^([%w_]+):([rf][1-3]?[0-9])$") then werror("expected immediate operand, got register") else waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) return 0 end end local function parse_disp(disp) local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") if imm then local r = shl(parse_gpr(reg), 21) local extname = match(imm, "^extern%s+(%S+)$") if extname then waction("REL_EXT", map_extern[extname], nil, 1) return r else return r + parse_imm(imm, 16, 0, 0, true) end end local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") if reg and tailr ~= "" then local r, tp = parse_gpr(reg) if tp then waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr)) return shl(r, 21) end end werror("bad displacement `"..disp.."'") end local function parse_index(idx) local rt, rs = match(idx, "^(.*)%(([%w_:]+)%)$") if rt then rt = parse_gpr(rt) rs = parse_gpr(rs) return shl(rt, 16) + shl(rs, 21) end werror("bad index `"..idx.."'") end local function parse_label(label, def) local prefix = sub(label, 1, 2) -- =>label (pc label reference) if prefix == "=>" then return "PC", 0, sub(label, 3) end -- ->name (global label reference) if prefix == "->" then return "LG", map_global[sub(label, 3)] end if def then -- [1-9] (local label definition) if match(label, "^[1-9]$") then return "LG", 10+tonumber(label) end else -- [<>][1-9] (local label reference) local dir, lnum = match(label, "^([<>])([1-9])$") if dir then -- Fwd: 1-9, Bkwd: 11-19. return "LG", lnum + (dir == ">" and 0 or 10) end -- extern label (extern label reference) local extname = match(label, "^extern%s+(%S+)$") if extname then return "EXT", map_extern[extname] end end werror("bad label `"..label.."'") end ------------------------------------------------------------------------------ -- Handle opcodes defined with template strings. map_op[".template__"] = function(params, template, nparams) if not params then return sub(template, 9) end local op = tonumber(sub(template, 1, 8), 16) local n = 1 -- Limit number of section buffer positions used by a single dasm_put(). -- A single opcode needs a maximum of 2 positions (ins/ext). if secpos+2 > maxsecpos then wflush() end local pos = wpos() -- Process each character. for p in gmatch(sub(template, 9), ".") do if p == "D" then op = op + shl(parse_gpr(params[n]), 11); n = n + 1 elseif p == "T" then op = op + shl(parse_gpr(params[n]), 16); n = n + 1 elseif p == "S" then op = op + shl(parse_gpr(params[n]), 21); n = n + 1 elseif p == "F" then op = op + shl(parse_fpr(params[n]), 6); n = n + 1 elseif p == "G" then op = op + shl(parse_fpr(params[n]), 11); n = n + 1 elseif p == "H" then op = op + shl(parse_fpr(params[n]), 16); n = n + 1 elseif p == "R" then op = op + shl(parse_fpr(params[n]), 21); n = n + 1 elseif p == "I" then op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1 elseif p == "U" then op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1 elseif p == "O" then op = op + parse_disp(params[n]); n = n + 1 elseif p == "X" then op = op + parse_index(params[n]); n = n + 1 elseif p == "B" or p == "J" then local mode, n, s = parse_label(params[n], false) if p == "B" then n = n + 2048 end waction("REL_"..mode, n, s, 1) n = n + 1 elseif p == "A" then op = op + parse_imm(params[n], 5, 6, 0, false); n = n + 1 elseif p == "M" then op = op + parse_imm(params[n], 5, 11, 0, false); n = n + 1 elseif p == "N" then op = op + parse_imm(params[n], 5, 16, 0, false); n = n + 1 elseif p == "C" then op = op + parse_imm(params[n], 3, 18, 0, false); n = n + 1 elseif p == "V" then op = op + parse_imm(params[n], 3, 8, 0, false); n = n + 1 elseif p == "W" then op = op + parse_imm(params[n], 3, 0, 0, false); n = n + 1 elseif p == "Y" then op = op + parse_imm(params[n], 20, 6, 0, false); n = n + 1 elseif p == "Z" then op = op + parse_imm(params[n], 10, 6, 0, false); n = n + 1 elseif p == "=" then op = op + shl(band(op, 0xf800), 5) -- Copy D to T for clz, clo. else assert(false) end end wputpos(pos, op) end ------------------------------------------------------------------------------ -- Pseudo-opcode to mark the position where the action list is to be emitted. map_op[".actionlist_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeactions(out, name) end) end -- Pseudo-opcode to mark the position where the global enum is to be emitted. map_op[".globals_1"] = function(params) if not params then return "prefix" end local prefix = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeglobals(out, prefix) end) end -- Pseudo-opcode to mark the position where the global names are to be emitted. map_op[".globalnames_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeglobalnames(out, name) end) end -- Pseudo-opcode to mark the position where the extern names are to be emitted. map_op[".externnames_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeexternnames(out, name) end) end ------------------------------------------------------------------------------ -- Label pseudo-opcode (converted from trailing colon form). map_op[".label_1"] = function(params) if not params then return "[1-9] | ->global | =>pcexpr" end if secpos+1 > maxsecpos then wflush() end local mode, n, s = parse_label(params[1], true) if mode == "EXT" then werror("bad label definition") end waction("LABEL_"..mode, n, s, 1) end ------------------------------------------------------------------------------ -- Pseudo-opcodes for data storage. map_op[".long_*"] = function(params) if not params then return "imm..." end for _,p in ipairs(params) do local n = tonumber(p) if not n then werror("bad immediate `"..p.."'") end if n < 0 then n = n + 2^32 end wputw(n) if secpos+2 > maxsecpos then wflush() end end end -- Alignment pseudo-opcode. map_op[".align_1"] = function(params) if not params then return "numpow2" end if secpos+1 > maxsecpos then wflush() end local align = tonumber(params[1]) if align then local x = align -- Must be a power of 2 in the range (2 ... 256). for i=1,8 do x = x / 2 if x == 1 then waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. return end end end werror("bad alignment") end ------------------------------------------------------------------------------ -- Pseudo-opcode for (primitive) type definitions (map to C types). map_op[".type_3"] = function(params, nparams) if not params then return nparams == 2 and "name, ctype" or "name, ctype, reg" end local name, ctype, reg = params[1], params[2], params[3] if not match(name, "^[%a_][%w_]*$") then werror("bad type name `"..name.."'") end local tp = map_type[name] if tp then werror("duplicate type `"..name.."'") end -- Add #type to defines. A bit unclean to put it in map_archdef. map_archdef["#"..name] = "sizeof("..ctype..")" -- Add new type and emit shortcut define. local num = ctypenum + 1 map_type[name] = { ctype = ctype, ctypefmt = format("Dt%X(%%s)", num), reg = reg, } wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) ctypenum = num end map_op[".type_2"] = map_op[".type_3"] -- Dump type definitions. local function dumptypes(out, lvl) local t = {} for name in pairs(map_type) do t[#t+1] = name end sort(t) out:write("Type definitions:\n") for _,name in ipairs(t) do local tp = map_type[name] local reg = tp.reg or "" out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) end out:write("\n") end ------------------------------------------------------------------------------ -- Set the current section. function _M.section(num) waction("SECTION", num) wflush(true) -- SECTION is a terminal action. end ------------------------------------------------------------------------------ -- Dump architecture description. function _M.dumparch(out) out:write(format("DynASM %s version %s, released %s\n\n", _info.arch, _info.version, _info.release)) dumpactions(out) end -- Dump all user defined elements. function _M.dumpdef(out, lvl) dumptypes(out, lvl) dumpglobals(out, lvl) dumpexterns(out, lvl) end ------------------------------------------------------------------------------ -- Pass callbacks from/to the DynASM core. function _M.passcb(wl, we, wf, ww) wline, werror, wfatal, wwarn = wl, we, wf, ww return wflush end -- Setup the arch-specific module. function _M.setup(arch, opt) g_arch, g_opt = arch, opt end -- Merge the core maps and the arch-specific maps. function _M.mergemaps(map_coreop, map_def) setmetatable(map_op, { __index = map_coreop }) setmetatable(map_def, { __index = map_archdef }) return map_op, map_def end return _M ------------------------------------------------------------------------------ ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_ppc.h ================================================ /* ** DynASM PPC encoding engine. ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. ** Released under the MIT license. See dynasm.lua for full copyright notice. */ #include #include #include #include #define DASM_ARCH "ppc" #ifndef DASM_EXTERN #define DASM_EXTERN(a,b,c,d) 0 #endif /* Action definitions. */ enum { DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT, /* The following actions need a buffer position. */ DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, /* The following actions also have an argument. */ DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, DASM__MAX }; /* Maximum number of section buffer positions for a single dasm_put() call. */ #define DASM_MAXSECPOS 25 /* DynASM encoder status codes. Action list offset or number are or'ed in. */ #define DASM_S_OK 0x00000000 #define DASM_S_NOMEM 0x01000000 #define DASM_S_PHASE 0x02000000 #define DASM_S_MATCH_SEC 0x03000000 #define DASM_S_RANGE_I 0x11000000 #define DASM_S_RANGE_SEC 0x12000000 #define DASM_S_RANGE_LG 0x13000000 #define DASM_S_RANGE_PC 0x14000000 #define DASM_S_RANGE_REL 0x15000000 #define DASM_S_UNDEF_LG 0x21000000 #define DASM_S_UNDEF_PC 0x22000000 /* Macros to convert positions (8 bit section + 24 bit index). */ #define DASM_POS2IDX(pos) ((pos)&0x00ffffff) #define DASM_POS2BIAS(pos) ((pos)&0xff000000) #define DASM_SEC2POS(sec) ((sec)<<24) #define DASM_POS2SEC(pos) ((pos)>>24) #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) /* Action list type. */ typedef const unsigned int *dasm_ActList; /* Per-section structure. */ typedef struct dasm_Section { int *rbuf; /* Biased buffer pointer (negative section bias). */ int *buf; /* True buffer pointer. */ size_t bsize; /* Buffer size in bytes. */ int pos; /* Biased buffer position. */ int epos; /* End of biased buffer position - max single put. */ int ofs; /* Byte offset into section. */ } dasm_Section; /* Core structure holding the DynASM encoding state. */ struct dasm_State { size_t psize; /* Allocated size of this structure. */ dasm_ActList actionlist; /* Current actionlist pointer. */ int *lglabels; /* Local/global chain/pos ptrs. */ size_t lgsize; int *pclabels; /* PC label chains/pos ptrs. */ size_t pcsize; void **globals; /* Array of globals (bias -10). */ dasm_Section *section; /* Pointer to active section. */ size_t codesize; /* Total size of all code sections. */ int maxsection; /* 0 <= sectionidx < maxsection. */ int status; /* Status code. */ dasm_Section sections[1]; /* All sections. Alloc-extended. */ }; /* The size of the core structure depends on the max. number of sections. */ #define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) /* Initialize DynASM state. */ void dasm_init(Dst_DECL, int maxsection) { dasm_State *D; size_t psz = 0; int i; Dst_REF = NULL; DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); D = Dst_REF; D->psize = psz; D->lglabels = NULL; D->lgsize = 0; D->pclabels = NULL; D->pcsize = 0; D->globals = NULL; D->maxsection = maxsection; for (i = 0; i < maxsection; i++) { D->sections[i].buf = NULL; /* Need this for pass3. */ D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); D->sections[i].bsize = 0; D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ } } /* Free DynASM state. */ void dasm_free(Dst_DECL) { dasm_State *D = Dst_REF; int i; for (i = 0; i < D->maxsection; i++) if (D->sections[i].buf) DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); DASM_M_FREE(Dst, D, D->psize); } /* Setup global label array. Must be called before dasm_setup(). */ void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) { dasm_State *D = Dst_REF; D->globals = gl - 10; /* Negative bias to compensate for locals. */ DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); } /* Grow PC label array. Can be called after dasm_setup(), too. */ void dasm_growpc(Dst_DECL, unsigned int maxpc) { dasm_State *D = Dst_REF; size_t osz = D->pcsize; DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); } /* Setup encoder. */ void dasm_setup(Dst_DECL, const void *actionlist) { dasm_State *D = Dst_REF; int i; D->actionlist = (dasm_ActList)actionlist; D->status = DASM_S_OK; D->section = &D->sections[0]; memset((void *)D->lglabels, 0, D->lgsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); for (i = 0; i < D->maxsection; i++) { D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].ofs = 0; } } #ifdef DASM_CHECKS #define CK(x, st) \ do { if (!(x)) { \ D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0) #define CKPL(kind, st) \ do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0) #else #define CK(x, st) ((void)0) #define CKPL(kind, st) ((void)0) #endif /* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ void dasm_put(Dst_DECL, int start, ...) { va_list ap; dasm_State *D = Dst_REF; dasm_ActList p = D->actionlist + start; dasm_Section *sec = D->section; int pos = sec->pos, ofs = sec->ofs; int *b; if (pos >= sec->epos) { DASM_M_GROW(Dst, int, sec->buf, sec->bsize, sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); sec->rbuf = sec->buf - DASM_POS2BIAS(pos); sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); } b = sec->rbuf; b[pos++] = start; va_start(ap, start); while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16); if (action >= DASM__MAX) { ofs += 4; } else { int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0; switch (action) { case DASM_STOP: goto stop; case DASM_SECTION: n = (ins & 255); CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; goto stop; case DASM_ESC: p++; ofs += 4; break; case DASM_REL_EXT: break; case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break; case DASM_REL_LG: n = (ins & 2047) - 10; pl = D->lglabels + n; if (n >= 0) { CKPL(lg, LG); goto putrel; } /* Bkwd rel or global. */ pl += 10; n = *pl; if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ goto linkrel; case DASM_REL_PC: pl = D->pclabels + n; CKPL(pc, PC); putrel: n = *pl; if (n < 0) { /* Label exists. Get label pos and store it. */ b[pos] = -n; } else { linkrel: b[pos] = n; /* Else link to rel chain, anchored at label. */ *pl = pos; } pos++; break; case DASM_LABEL_LG: pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel; case DASM_LABEL_PC: pl = D->pclabels + n; CKPL(pc, PC); putlabel: n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } *pl = -pos; /* Label exists now. */ b[pos++] = ofs; /* Store pass1 offset estimate. */ break; case DASM_IMM: #ifdef DASM_CHECKS CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I); #endif n >>= ((ins>>10)&31); #ifdef DASM_CHECKS if (ins & 0x8000) CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I); else CK((n>>((ins>>5)&31)) == 0, RANGE_I); #endif b[pos++] = n; break; } } } stop: va_end(ap); sec->pos = pos; sec->ofs = ofs; } #undef CK /* Pass 2: Link sections, shrink aligns, fix label offsets. */ int dasm_link(Dst_DECL, size_t *szp) { dasm_State *D = Dst_REF; int secnum; int ofs = 0; #ifdef DASM_CHECKS *szp = 0; if (D->status != DASM_S_OK) return D->status; { int pc; for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; } #endif { /* Handle globals not defined in this translation unit. */ int idx; for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { int n = D->lglabels[idx]; /* Undefined label: Collapse rel chain and replace with marker (< 0). */ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } } } /* Combine all code sections. No support for data sections (yet). */ for (secnum = 0; secnum < D->maxsection; secnum++) { dasm_Section *sec = D->sections + secnum; int *b = sec->rbuf; int pos = DASM_SEC2POS(secnum); int lastpos = sec->pos; while (pos != lastpos) { dasm_ActList p = D->actionlist + b[pos++]; while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16); switch (action) { case DASM_STOP: case DASM_SECTION: goto stop; case DASM_ESC: p++; break; case DASM_REL_EXT: break; case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; case DASM_REL_LG: case DASM_REL_PC: pos++; break; case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; case DASM_IMM: pos++; break; } } stop: (void)0; } ofs += sec->ofs; /* Next section starts right after current section. */ } D->codesize = ofs; /* Total size of all code sections */ *szp = ofs; return DASM_S_OK; } #ifdef DASM_CHECKS #define CK(x, st) \ do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0) #else #define CK(x, st) ((void)0) #endif /* Pass 3: Encode sections. */ int dasm_encode(Dst_DECL, void *buffer) { dasm_State *D = Dst_REF; char *base = (char *)buffer; unsigned int *cp = (unsigned int *)buffer; int secnum; /* Encode all code sections. No support for data sections (yet). */ for (secnum = 0; secnum < D->maxsection; secnum++) { dasm_Section *sec = D->sections + secnum; int *b = sec->buf; int *endb = sec->rbuf + sec->pos; while (b != endb) { dasm_ActList p = D->actionlist + *b++; while (1) { unsigned int ins = *p++; unsigned int action = (ins >> 16); int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0; switch (action) { case DASM_STOP: case DASM_SECTION: goto stop; case DASM_ESC: *cp++ = *p++; break; case DASM_REL_EXT: n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1) - 4; goto patchrel; case DASM_ALIGN: ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; break; case DASM_REL_LG: CK(n >= 0, UNDEF_LG); case DASM_REL_PC: CK(n >= 0, UNDEF_PC); n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base); patchrel: CK((n & 3) == 0 && (((n+4) + ((ins & 2048) ? 0x00008000 : 0x02000000)) >> ((ins & 2048) ? 16 : 26)) == 0, RANGE_REL); cp[-1] |= ((n+4) & ((ins & 2048) ? 0x0000fffc: 0x03fffffc)); break; case DASM_LABEL_LG: ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n); break; case DASM_LABEL_PC: break; case DASM_IMM: cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); break; default: *cp++ = ins; break; } } stop: (void)0; } } if (base + D->codesize != (char *)cp) /* Check for phase errors. */ return DASM_S_PHASE; return DASM_S_OK; } #undef CK /* Get PC label offset. */ int dasm_getpclabel(Dst_DECL, unsigned int pc) { dasm_State *D = Dst_REF; if (pc*sizeof(int) < D->pcsize) { int pos = D->pclabels[pc]; if (pos < 0) return *DASM_POS2PTR(D, -pos); if (pos > 0) return -1; /* Undefined. */ } return -2; /* Unused or out of range. */ } #ifdef DASM_CHECKS /* Optional sanity checker to call between isolated encoding steps. */ int dasm_checkstep(Dst_DECL, int secmatch) { dasm_State *D = Dst_REF; if (D->status == DASM_S_OK) { int i; for (i = 1; i <= 9; i++) { if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; } D->lglabels[i] = 0; } } if (D->status == DASM_S_OK && secmatch >= 0 && D->section != &D->sections[secmatch]) D->status = DASM_S_MATCH_SEC|(D->section-D->sections); return D->status; } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_ppc.lua ================================================ ------------------------------------------------------------------------------ -- DynASM PPC module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------ -- Module information: local _info = { arch = "ppc", description = "DynASM PPC module", version = "1.3.0", vernum = 10300, release = "2011-05-05", author = "Mike Pall", license = "MIT", } -- Exported glue functions for the arch-specific module. local _M = { _info = _info } -- Cache library functions. local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs local assert, setmetatable = assert, setmetatable local _s = string local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char local match, gmatch = _s.match, _s.gmatch local concat, sort = table.concat, table.sort local bit = bit or require("bit") local band, shl, shr, sar = bit.band, bit.lshift, bit.rshift, bit.arshift local tohex = bit.tohex -- Inherited tables and callbacks. local g_opt, g_arch local wline, werror, wfatal, wwarn -- Action name list. -- CHECK: Keep this in sync with the C code! local action_names = { "STOP", "SECTION", "ESC", "REL_EXT", "ALIGN", "REL_LG", "LABEL_LG", "REL_PC", "LABEL_PC", "IMM", } -- Maximum number of section buffer positions for dasm_put(). -- CHECK: Keep this in sync with the C code! local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. -- Action name -> action number. local map_action = {} for n,name in ipairs(action_names) do map_action[name] = n-1 end -- Action list buffer. local actlist = {} -- Argument list for next dasm_put(). Start with offset 0 into action list. local actargs = { 0 } -- Current number of section buffer positions for dasm_put(). local secpos = 1 ------------------------------------------------------------------------------ -- Dump action names and numbers. local function dumpactions(out) out:write("DynASM encoding engine action codes:\n") for n,name in ipairs(action_names) do local num = map_action[name] out:write(format(" %-10s %02X %d\n", name, num, num)) end out:write("\n") end -- Write action list buffer as a huge static C array. local function writeactions(out, name) local nn = #actlist if nn == 0 then nn = 1; actlist[0] = map_action.STOP end out:write("static const unsigned int ", name, "[", nn, "] = {\n") for i = 1,nn-1 do assert(out:write("0x", tohex(actlist[i]), ",\n")) end assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n")) end ------------------------------------------------------------------------------ -- Add word to action list. local function wputxw(n) assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") actlist[#actlist+1] = n end -- Add action to list with optional arg. Advance buffer pos, too. local function waction(action, val, a, num) local w = assert(map_action[action], "bad action name `"..action.."'") wputxw(w * 0x10000 + (val or 0)) if a then actargs[#actargs+1] = a end if a or num then secpos = secpos + (num or 1) end end -- Flush action list (intervening C code or buffer pos overflow). local function wflush(term) if #actlist == actargs[1] then return end -- Nothing to flush. if not term then waction("STOP") end -- Terminate action list. wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true) actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). secpos = 1 -- The actionlist offset occupies a buffer position, too. end -- Put escaped word. local function wputw(n) if n <= 0xffffff then waction("ESC") end wputxw(n) end -- Reserve position for word. local function wpos() local pos = #actlist+1 actlist[pos] = "" return pos end -- Store word to reserved position. local function wputpos(pos, n) assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range") actlist[pos] = n end ------------------------------------------------------------------------------ -- Global label name -> global label number. With auto assignment on 1st use. local next_global = 20 local map_global = setmetatable({}, { __index = function(t, name) if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end local n = next_global if n > 2047 then werror("too many global labels") end next_global = n + 1 t[name] = n return n end}) -- Dump global labels. local function dumpglobals(out, lvl) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("Global labels:\n") for i=20,next_global-1 do out:write(format(" %s\n", t[i])) end out:write("\n") end -- Write global label enum. local function writeglobals(out, prefix) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("enum {\n") for i=20,next_global-1 do out:write(" ", prefix, t[i], ",\n") end out:write(" ", prefix, "_MAX\n};\n") end -- Write global label names. local function writeglobalnames(out, name) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("static const char *const ", name, "[] = {\n") for i=20,next_global-1 do out:write(" \"", t[i], "\",\n") end out:write(" (const char *)0\n};\n") end ------------------------------------------------------------------------------ -- Extern label name -> extern label number. With auto assignment on 1st use. local next_extern = 0 local map_extern_ = {} local map_extern = setmetatable({}, { __index = function(t, name) -- No restrictions on the name for now. local n = next_extern if n > 2047 then werror("too many extern labels") end next_extern = n + 1 t[name] = n map_extern_[n] = name return n end}) -- Dump extern labels. local function dumpexterns(out, lvl) out:write("Extern labels:\n") for i=0,next_extern-1 do out:write(format(" %s\n", map_extern_[i])) end out:write("\n") end -- Write extern label names. local function writeexternnames(out, name) out:write("static const char *const ", name, "[] = {\n") for i=0,next_extern-1 do out:write(" \"", map_extern_[i], "\",\n") end out:write(" (const char *)0\n};\n") end ------------------------------------------------------------------------------ -- Arch-specific maps. local map_archdef = { sp = "r1" } -- Ext. register name -> int. name. local map_type = {} -- Type name -> { ctype, reg } local ctypenum = 0 -- Type number (for Dt... macros). -- Reverse defines for registers. function _M.revdef(s) if s == "r1" then return "sp" end return s end local map_cond = { lt = 0, gt = 1, eq = 2, so = 3, ge = 4, le = 5, ne = 6, ns = 7, } ------------------------------------------------------------------------------ -- Template strings for PPC instructions. local map_op = { tdi_3 = "08000000ARI", twi_3 = "0c000000ARI", mulli_3 = "1c000000RRI", subfic_3 = "20000000RRI", cmplwi_3 = "28000000XRU", cmplwi_2 = "28000000-RU", cmpldi_3 = "28200000XRU", cmpldi_2 = "28200000-RU", cmpwi_3 = "2c000000XRI", cmpwi_2 = "2c000000-RI", cmpdi_3 = "2c200000XRI", cmpdi_2 = "2c200000-RI", addic_3 = "30000000RRI", ["addic._3"] = "34000000RRI", addi_3 = "38000000RR0I", li_2 = "38000000RI", la_2 = "38000000RD", addis_3 = "3c000000RR0I", lis_2 = "3c000000RI", lus_2 = "3c000000RU", bc_3 = "40000000AAK", bcl_3 = "40000001AAK", bdnz_1 = "42000000K", bdz_1 = "42400000K", sc_0 = "44000000", b_1 = "48000000J", bl_1 = "48000001J", rlwimi_5 = "50000000RR~AAA.", rlwinm_5 = "54000000RR~AAA.", rlwnm_5 = "5c000000RR~RAA.", ori_3 = "60000000RR~U", nop_0 = "60000000", oris_3 = "64000000RR~U", xori_3 = "68000000RR~U", xoris_3 = "6c000000RR~U", ["andi._3"] = "70000000RR~U", ["andis._3"] = "74000000RR~U", lwz_2 = "80000000RD", lwzu_2 = "84000000RD", lbz_2 = "88000000RD", lbzu_2 = "8c000000RD", stw_2 = "90000000RD", stwu_2 = "94000000RD", stb_2 = "98000000RD", stbu_2 = "9c000000RD", lhz_2 = "a0000000RD", lhzu_2 = "a4000000RD", lha_2 = "a8000000RD", lhau_2 = "ac000000RD", sth_2 = "b0000000RD", sthu_2 = "b4000000RD", lmw_2 = "b8000000RD", stmw_2 = "bc000000RD", lfs_2 = "c0000000FD", lfsu_2 = "c4000000FD", lfd_2 = "c8000000FD", lfdu_2 = "cc000000FD", stfs_2 = "d0000000FD", stfsu_2 = "d4000000FD", stfd_2 = "d8000000FD", stfdu_2 = "dc000000FD", ld_2 = "e8000000RD", -- NYI: displacement must be divisible by 4. ldu_2 = "e8000001RD", lwa_2 = "e8000002RD", std_2 = "f8000000RD", stdu_2 = "f8000001RD", -- Primary opcode 19: mcrf_2 = "4c000000XX", isync_0 = "4c00012c", crnor_3 = "4c000042CCC", crnot_2 = "4c000042CC=", crandc_3 = "4c000102CCC", crxor_3 = "4c000182CCC", crclr_1 = "4c000182C==", crnand_3 = "4c0001c2CCC", crand_3 = "4c000202CCC", creqv_3 = "4c000242CCC", crset_1 = "4c000242C==", crorc_3 = "4c000342CCC", cror_3 = "4c000382CCC", crmove_2 = "4c000382CC=", bclr_2 = "4c000020AA", bclrl_2 = "4c000021AA", bcctr_2 = "4c000420AA", bcctrl_2 = "4c000421AA", blr_0 = "4e800020", blrl_0 = "4e800021", bctr_0 = "4e800420", bctrl_0 = "4e800421", -- Primary opcode 31: cmpw_3 = "7c000000XRR", cmpw_2 = "7c000000-RR", cmpd_3 = "7c200000XRR", cmpd_2 = "7c200000-RR", tw_3 = "7c000008ARR", subfc_3 = "7c000010RRR.", subc_3 = "7c000010RRR~.", mulhdu_3 = "7c000012RRR.", addc_3 = "7c000014RRR.", mulhwu_3 = "7c000016RRR.", isel_4 = "7c00001eRRRC", isellt_3 = "7c00001eRRR", iselgt_3 = "7c00005eRRR", iseleq_3 = "7c00009eRRR", mfcr_1 = "7c000026R", mfocrf_2 = "7c100026RG", mtcrf_2 = "7c000120GR", mtocrf_2 = "7c100120GR", lwarx_3 = "7c000028RR0R", ldx_3 = "7c00002aRR0R", lwzx_3 = "7c00002eRR0R", slw_3 = "7c000030RR~R.", cntlzw_2 = "7c000034RR~", sld_3 = "7c000036RR~R.", and_3 = "7c000038RR~R.", cmplw_3 = "7c000040XRR", cmplw_2 = "7c000040-RR", cmpld_3 = "7c200040XRR", cmpld_2 = "7c200040-RR", subf_3 = "7c000050RRR.", sub_3 = "7c000050RRR~.", ldux_3 = "7c00006aRR0R", dcbst_2 = "7c00006c-RR", lwzux_3 = "7c00006eRR0R", cntlzd_2 = "7c000074RR~", andc_3 = "7c000078RR~R.", td_3 = "7c000088ARR", mulhd_3 = "7c000092RRR.", mulhw_3 = "7c000096RRR.", ldarx_3 = "7c0000a8RR0R", dcbf_2 = "7c0000ac-RR", lbzx_3 = "7c0000aeRR0R", neg_2 = "7c0000d0RR.", lbzux_3 = "7c0000eeRR0R", popcntb_2 = "7c0000f4RR~", not_2 = "7c0000f8RR~%.", nor_3 = "7c0000f8RR~R.", subfe_3 = "7c000110RRR.", sube_3 = "7c000110RRR~.", adde_3 = "7c000114RRR.", stdx_3 = "7c00012aRR0R", stwcx_3 = "7c00012cRR0R.", stwx_3 = "7c00012eRR0R", prtyw_2 = "7c000134RR~", stdux_3 = "7c00016aRR0R", stwux_3 = "7c00016eRR0R", prtyd_2 = "7c000174RR~", subfze_2 = "7c000190RR.", addze_2 = "7c000194RR.", stdcx_3 = "7c0001acRR0R.", stbx_3 = "7c0001aeRR0R", subfme_2 = "7c0001d0RR.", mulld_3 = "7c0001d2RRR.", addme_2 = "7c0001d4RR.", mullw_3 = "7c0001d6RRR.", dcbtst_2 = "7c0001ec-RR", stbux_3 = "7c0001eeRR0R", add_3 = "7c000214RRR.", dcbt_2 = "7c00022c-RR", lhzx_3 = "7c00022eRR0R", eqv_3 = "7c000238RR~R.", eciwx_3 = "7c00026cRR0R", lhzux_3 = "7c00026eRR0R", xor_3 = "7c000278RR~R.", mfspefscr_1 = "7c0082a6R", mfxer_1 = "7c0102a6R", mflr_1 = "7c0802a6R", mfctr_1 = "7c0902a6R", lwax_3 = "7c0002aaRR0R", lhax_3 = "7c0002aeRR0R", mftb_1 = "7c0c42e6R", mftbu_1 = "7c0d42e6R", lwaux_3 = "7c0002eaRR0R", lhaux_3 = "7c0002eeRR0R", sthx_3 = "7c00032eRR0R", orc_3 = "7c000338RR~R.", ecowx_3 = "7c00036cRR0R", sthux_3 = "7c00036eRR0R", or_3 = "7c000378RR~R.", mr_2 = "7c000378RR~%.", divdu_3 = "7c000392RRR.", divwu_3 = "7c000396RRR.", mtspefscr_1 = "7c0083a6R", mtxer_1 = "7c0103a6R", mtlr_1 = "7c0803a6R", mtctr_1 = "7c0903a6R", dcbi_2 = "7c0003ac-RR", nand_3 = "7c0003b8RR~R.", divd_3 = "7c0003d2RRR.", divw_3 = "7c0003d6RRR.", cmpb_3 = "7c0003f8RR~R.", mcrxr_1 = "7c000400X", subfco_3 = "7c000410RRR.", subco_3 = "7c000410RRR~.", addco_3 = "7c000414RRR.", ldbrx_3 = "7c000428RR0R", lswx_3 = "7c00042aRR0R", lwbrx_3 = "7c00042cRR0R", lfsx_3 = "7c00042eFR0R", srw_3 = "7c000430RR~R.", srd_3 = "7c000436RR~R.", subfo_3 = "7c000450RRR.", subo_3 = "7c000450RRR~.", lfsux_3 = "7c00046eFR0R", lswi_3 = "7c0004aaRR0A", sync_0 = "7c0004ac", lwsync_0 = "7c2004ac", ptesync_0 = "7c4004ac", lfdx_3 = "7c0004aeFR0R", nego_2 = "7c0004d0RR.", lfdux_3 = "7c0004eeFR0R", subfeo_3 = "7c000510RRR.", subeo_3 = "7c000510RRR~.", addeo_3 = "7c000514RRR.", stdbrx_3 = "7c000528RR0R", stswx_3 = "7c00052aRR0R", stwbrx_3 = "7c00052cRR0R", stfsx_3 = "7c00052eFR0R", stfsux_3 = "7c00056eFR0R", subfzeo_2 = "7c000590RR.", addzeo_2 = "7c000594RR.", stswi_3 = "7c0005aaRR0A", stfdx_3 = "7c0005aeFR0R", subfmeo_2 = "7c0005d0RR.", mulldo_3 = "7c0005d2RRR.", addmeo_2 = "7c0005d4RR.", mullwo_3 = "7c0005d6RRR.", dcba_2 = "7c0005ec-RR", stfdux_3 = "7c0005eeFR0R", addo_3 = "7c000614RRR.", lhbrx_3 = "7c00062cRR0R", sraw_3 = "7c000630RR~R.", srad_3 = "7c000634RR~R.", srawi_3 = "7c000670RR~A.", sradi_3 = "7c000674RR~H.", eieio_0 = "7c0006ac", lfiwax_3 = "7c0006aeFR0R", sthbrx_3 = "7c00072cRR0R", extsh_2 = "7c000734RR~.", extsb_2 = "7c000774RR~.", divduo_3 = "7c000792RRR.", divwou_3 = "7c000796RRR.", icbi_2 = "7c0007ac-RR", stfiwx_3 = "7c0007aeFR0R", extsw_2 = "7c0007b4RR~.", divdo_3 = "7c0007d2RRR.", divwo_3 = "7c0007d6RRR.", dcbz_2 = "7c0007ec-RR", -- Primary opcode 30: rldicl_4 = "78000000RR~HM.", rldicr_4 = "78000004RR~HM.", rldic_4 = "78000008RR~HM.", rldimi_4 = "7800000cRR~HM.", rldcl_4 = "78000010RR~RM.", rldcr_4 = "78000012RR~RM.", -- Primary opcode 59: fdivs_3 = "ec000024FFF.", fsubs_3 = "ec000028FFF.", fadds_3 = "ec00002aFFF.", fsqrts_2 = "ec00002cF-F.", fres_2 = "ec000030F-F.", fmuls_3 = "ec000032FF-F.", frsqrtes_2 = "ec000034F-F.", fmsubs_4 = "ec000038FFFF~.", fmadds_4 = "ec00003aFFFF~.", fnmsubs_4 = "ec00003cFFFF~.", fnmadds_4 = "ec00003eFFFF~.", -- Primary opcode 63: fdiv_3 = "fc000024FFF.", fsub_3 = "fc000028FFF.", fadd_3 = "fc00002aFFF.", fsqrt_2 = "fc00002cF-F.", fsel_4 = "fc00002eFFFF~.", fre_2 = "fc000030F-F.", fmul_3 = "fc000032FF-F.", frsqrte_2 = "fc000034F-F.", fmsub_4 = "fc000038FFFF~.", fmadd_4 = "fc00003aFFFF~.", fnmsub_4 = "fc00003cFFFF~.", fnmadd_4 = "fc00003eFFFF~.", fcmpu_3 = "fc000000XFF", fcpsgn_3 = "fc000010FFF.", fcmpo_3 = "fc000040XFF", mtfsb1_1 = "fc00004cA", fneg_2 = "fc000050F-F.", mcrfs_2 = "fc000080XX", mtfsb0_1 = "fc00008cA", fmr_2 = "fc000090F-F.", frsp_2 = "fc000018F-F.", fctiw_2 = "fc00001cF-F.", fctiwz_2 = "fc00001eF-F.", mtfsfi_2 = "fc00010cAA", -- NYI: upshift. fnabs_2 = "fc000110F-F.", fabs_2 = "fc000210F-F.", frin_2 = "fc000310F-F.", friz_2 = "fc000350F-F.", frip_2 = "fc000390F-F.", frim_2 = "fc0003d0F-F.", mffs_1 = "fc00048eF.", -- NYI: mtfsf, mtfsb0, mtfsb1. fctid_2 = "fc00065cF-F.", fctidz_2 = "fc00065eF-F.", fcfid_2 = "fc00069cF-F.", -- Primary opcode 4, SPE APU extension: evaddw_3 = "10000200RRR", evaddiw_3 = "10000202RAR~", evsubw_3 = "10000204RRR~", evsubiw_3 = "10000206RAR~", evabs_2 = "10000208RR", evneg_2 = "10000209RR", evextsb_2 = "1000020aRR", evextsh_2 = "1000020bRR", evrndw_2 = "1000020cRR", evcntlzw_2 = "1000020dRR", evcntlsw_2 = "1000020eRR", brinc_3 = "1000020fRRR", evand_3 = "10000211RRR", evandc_3 = "10000212RRR", evxor_3 = "10000216RRR", evor_3 = "10000217RRR", evmr_2 = "10000217RR=", evnor_3 = "10000218RRR", evnot_2 = "10000218RR=", eveqv_3 = "10000219RRR", evorc_3 = "1000021bRRR", evnand_3 = "1000021eRRR", evsrwu_3 = "10000220RRR", evsrws_3 = "10000221RRR", evsrwiu_3 = "10000222RRA", evsrwis_3 = "10000223RRA", evslw_3 = "10000224RRR", evslwi_3 = "10000226RRA", evrlw_3 = "10000228RRR", evsplati_2 = "10000229RS", evrlwi_3 = "1000022aRRA", evsplatfi_2 = "1000022bRS", evmergehi_3 = "1000022cRRR", evmergelo_3 = "1000022dRRR", evcmpgtu_3 = "10000230XRR", evcmpgtu_2 = "10000230-RR", evcmpgts_3 = "10000231XRR", evcmpgts_2 = "10000231-RR", evcmpltu_3 = "10000232XRR", evcmpltu_2 = "10000232-RR", evcmplts_3 = "10000233XRR", evcmplts_2 = "10000233-RR", evcmpeq_3 = "10000234XRR", evcmpeq_2 = "10000234-RR", evsel_4 = "10000278RRRW", evsel_3 = "10000278RRR", evfsadd_3 = "10000280RRR", evfssub_3 = "10000281RRR", evfsabs_2 = "10000284RR", evfsnabs_2 = "10000285RR", evfsneg_2 = "10000286RR", evfsmul_3 = "10000288RRR", evfsdiv_3 = "10000289RRR", evfscmpgt_3 = "1000028cXRR", evfscmpgt_2 = "1000028c-RR", evfscmplt_3 = "1000028dXRR", evfscmplt_2 = "1000028d-RR", evfscmpeq_3 = "1000028eXRR", evfscmpeq_2 = "1000028e-RR", evfscfui_2 = "10000290R-R", evfscfsi_2 = "10000291R-R", evfscfuf_2 = "10000292R-R", evfscfsf_2 = "10000293R-R", evfsctui_2 = "10000294R-R", evfsctsi_2 = "10000295R-R", evfsctuf_2 = "10000296R-R", evfsctsf_2 = "10000297R-R", evfsctuiz_2 = "10000298R-R", evfsctsiz_2 = "1000029aR-R", evfststgt_3 = "1000029cXRR", evfststgt_2 = "1000029c-RR", evfststlt_3 = "1000029dXRR", evfststlt_2 = "1000029d-RR", evfststeq_3 = "1000029eXRR", evfststeq_2 = "1000029e-RR", efsadd_3 = "100002c0RRR", efssub_3 = "100002c1RRR", efsabs_2 = "100002c4RR", efsnabs_2 = "100002c5RR", efsneg_2 = "100002c6RR", efsmul_3 = "100002c8RRR", efsdiv_3 = "100002c9RRR", efscmpgt_3 = "100002ccXRR", efscmpgt_2 = "100002cc-RR", efscmplt_3 = "100002cdXRR", efscmplt_2 = "100002cd-RR", efscmpeq_3 = "100002ceXRR", efscmpeq_2 = "100002ce-RR", efscfd_2 = "100002cfR-R", efscfui_2 = "100002d0R-R", efscfsi_2 = "100002d1R-R", efscfuf_2 = "100002d2R-R", efscfsf_2 = "100002d3R-R", efsctui_2 = "100002d4R-R", efsctsi_2 = "100002d5R-R", efsctuf_2 = "100002d6R-R", efsctsf_2 = "100002d7R-R", efsctuiz_2 = "100002d8R-R", efsctsiz_2 = "100002daR-R", efststgt_3 = "100002dcXRR", efststgt_2 = "100002dc-RR", efststlt_3 = "100002ddXRR", efststlt_2 = "100002dd-RR", efststeq_3 = "100002deXRR", efststeq_2 = "100002de-RR", efdadd_3 = "100002e0RRR", efdsub_3 = "100002e1RRR", efdcfuid_2 = "100002e2R-R", efdcfsid_2 = "100002e3R-R", efdabs_2 = "100002e4RR", efdnabs_2 = "100002e5RR", efdneg_2 = "100002e6RR", efdmul_3 = "100002e8RRR", efddiv_3 = "100002e9RRR", efdctuidz_2 = "100002eaR-R", efdctsidz_2 = "100002ebR-R", efdcmpgt_3 = "100002ecXRR", efdcmpgt_2 = "100002ec-RR", efdcmplt_3 = "100002edXRR", efdcmplt_2 = "100002ed-RR", efdcmpeq_3 = "100002eeXRR", efdcmpeq_2 = "100002ee-RR", efdcfs_2 = "100002efR-R", efdcfui_2 = "100002f0R-R", efdcfsi_2 = "100002f1R-R", efdcfuf_2 = "100002f2R-R", efdcfsf_2 = "100002f3R-R", efdctui_2 = "100002f4R-R", efdctsi_2 = "100002f5R-R", efdctuf_2 = "100002f6R-R", efdctsf_2 = "100002f7R-R", efdctuiz_2 = "100002f8R-R", efdctsiz_2 = "100002faR-R", efdtstgt_3 = "100002fcXRR", efdtstgt_2 = "100002fc-RR", efdtstlt_3 = "100002fdXRR", efdtstlt_2 = "100002fd-RR", efdtsteq_3 = "100002feXRR", efdtsteq_2 = "100002fe-RR", evlddx_3 = "10000300RR0R", evldd_2 = "10000301R8", evldwx_3 = "10000302RR0R", evldw_2 = "10000303R8", evldhx_3 = "10000304RR0R", evldh_2 = "10000305R8", evlwhex_3 = "10000310RR0R", evlwhe_2 = "10000311R4", evlwhoux_3 = "10000314RR0R", evlwhou_2 = "10000315R4", evlwhosx_3 = "10000316RR0R", evlwhos_2 = "10000317R4", evstddx_3 = "10000320RR0R", evstdd_2 = "10000321R8", evstdwx_3 = "10000322RR0R", evstdw_2 = "10000323R8", evstdhx_3 = "10000324RR0R", evstdh_2 = "10000325R8", evstwhex_3 = "10000330RR0R", evstwhe_2 = "10000331R4", evstwhox_3 = "10000334RR0R", evstwho_2 = "10000335R4", evstwwex_3 = "10000338RR0R", evstwwe_2 = "10000339R4", evstwwox_3 = "1000033cRR0R", evstwwo_2 = "1000033dR4", evmhessf_3 = "10000403RRR", evmhossf_3 = "10000407RRR", evmheumi_3 = "10000408RRR", evmhesmi_3 = "10000409RRR", evmhesmf_3 = "1000040bRRR", evmhoumi_3 = "1000040cRRR", evmhosmi_3 = "1000040dRRR", evmhosmf_3 = "1000040fRRR", evmhessfa_3 = "10000423RRR", evmhossfa_3 = "10000427RRR", evmheumia_3 = "10000428RRR", evmhesmia_3 = "10000429RRR", evmhesmfa_3 = "1000042bRRR", evmhoumia_3 = "1000042cRRR", evmhosmia_3 = "1000042dRRR", evmhosmfa_3 = "1000042fRRR", evmwhssf_3 = "10000447RRR", evmwlumi_3 = "10000448RRR", evmwhumi_3 = "1000044cRRR", evmwhsmi_3 = "1000044dRRR", evmwhsmf_3 = "1000044fRRR", evmwssf_3 = "10000453RRR", evmwumi_3 = "10000458RRR", evmwsmi_3 = "10000459RRR", evmwsmf_3 = "1000045bRRR", evmwhssfa_3 = "10000467RRR", evmwlumia_3 = "10000468RRR", evmwhumia_3 = "1000046cRRR", evmwhsmia_3 = "1000046dRRR", evmwhsmfa_3 = "1000046fRRR", evmwssfa_3 = "10000473RRR", evmwumia_3 = "10000478RRR", evmwsmia_3 = "10000479RRR", evmwsmfa_3 = "1000047bRRR", evmra_2 = "100004c4RR", evdivws_3 = "100004c6RRR", evdivwu_3 = "100004c7RRR", evmwssfaa_3 = "10000553RRR", evmwumiaa_3 = "10000558RRR", evmwsmiaa_3 = "10000559RRR", evmwsmfaa_3 = "1000055bRRR", evmwssfan_3 = "100005d3RRR", evmwumian_3 = "100005d8RRR", evmwsmian_3 = "100005d9RRR", evmwsmfan_3 = "100005dbRRR", evmergehilo_3 = "1000022eRRR", evmergelohi_3 = "1000022fRRR", evlhhesplatx_3 = "10000308RR0R", evlhhesplat_2 = "10000309R2", evlhhousplatx_3 = "1000030cRR0R", evlhhousplat_2 = "1000030dR2", evlhhossplatx_3 = "1000030eRR0R", evlhhossplat_2 = "1000030fR2", evlwwsplatx_3 = "10000318RR0R", evlwwsplat_2 = "10000319R4", evlwhsplatx_3 = "1000031cRR0R", evlwhsplat_2 = "1000031dR4", evaddusiaaw_2 = "100004c0RR", evaddssiaaw_2 = "100004c1RR", evsubfusiaaw_2 = "100004c2RR", evsubfssiaaw_2 = "100004c3RR", evaddumiaaw_2 = "100004c8RR", evaddsmiaaw_2 = "100004c9RR", evsubfumiaaw_2 = "100004caRR", evsubfsmiaaw_2 = "100004cbRR", evmheusiaaw_3 = "10000500RRR", evmhessiaaw_3 = "10000501RRR", evmhessfaaw_3 = "10000503RRR", evmhousiaaw_3 = "10000504RRR", evmhossiaaw_3 = "10000505RRR", evmhossfaaw_3 = "10000507RRR", evmheumiaaw_3 = "10000508RRR", evmhesmiaaw_3 = "10000509RRR", evmhesmfaaw_3 = "1000050bRRR", evmhoumiaaw_3 = "1000050cRRR", evmhosmiaaw_3 = "1000050dRRR", evmhosmfaaw_3 = "1000050fRRR", evmhegumiaa_3 = "10000528RRR", evmhegsmiaa_3 = "10000529RRR", evmhegsmfaa_3 = "1000052bRRR", evmhogumiaa_3 = "1000052cRRR", evmhogsmiaa_3 = "1000052dRRR", evmhogsmfaa_3 = "1000052fRRR", evmwlusiaaw_3 = "10000540RRR", evmwlssiaaw_3 = "10000541RRR", evmwlumiaaw_3 = "10000548RRR", evmwlsmiaaw_3 = "10000549RRR", evmheusianw_3 = "10000580RRR", evmhessianw_3 = "10000581RRR", evmhessfanw_3 = "10000583RRR", evmhousianw_3 = "10000584RRR", evmhossianw_3 = "10000585RRR", evmhossfanw_3 = "10000587RRR", evmheumianw_3 = "10000588RRR", evmhesmianw_3 = "10000589RRR", evmhesmfanw_3 = "1000058bRRR", evmhoumianw_3 = "1000058cRRR", evmhosmianw_3 = "1000058dRRR", evmhosmfanw_3 = "1000058fRRR", evmhegumian_3 = "100005a8RRR", evmhegsmian_3 = "100005a9RRR", evmhegsmfan_3 = "100005abRRR", evmhogumian_3 = "100005acRRR", evmhogsmian_3 = "100005adRRR", evmhogsmfan_3 = "100005afRRR", evmwlusianw_3 = "100005c0RRR", evmwlssianw_3 = "100005c1RRR", evmwlumianw_3 = "100005c8RRR", evmwlsmianw_3 = "100005c9RRR", -- NYI: Book E instructions. } -- Add mnemonics for "." variants. do local t = {} for k,v in pairs(map_op) do if sub(v, -1) == "." then local v2 = sub(v, 1, 7)..char(byte(v, 8)+1)..sub(v, 9, -2) t[sub(k, 1, -3).."."..sub(k, -2)] = v2 end end for k,v in pairs(t) do map_op[k] = v end end -- Add more branch mnemonics. for cond,c in pairs(map_cond) do local b1 = "b"..cond local c1 = shl(band(c, 3), 16) + (c < 4 and 0x01000000 or 0) -- bX[l] map_op[b1.."_1"] = tohex(0x40800000 + c1).."K" map_op[b1.."y_1"] = tohex(0x40a00000 + c1).."K" map_op[b1.."l_1"] = tohex(0x40800001 + c1).."K" map_op[b1.."_2"] = tohex(0x40800000 + c1).."-XK" map_op[b1.."y_2"] = tohex(0x40a00000 + c1).."-XK" map_op[b1.."l_2"] = tohex(0x40800001 + c1).."-XK" -- bXlr[l] map_op[b1.."lr_0"] = tohex(0x4c800020 + c1) map_op[b1.."lrl_0"] = tohex(0x4c800021 + c1) map_op[b1.."ctr_0"] = tohex(0x4c800420 + c1) map_op[b1.."ctrl_0"] = tohex(0x4c800421 + c1) -- bXctr[l] map_op[b1.."lr_1"] = tohex(0x4c800020 + c1).."-X" map_op[b1.."lrl_1"] = tohex(0x4c800021 + c1).."-X" map_op[b1.."ctr_1"] = tohex(0x4c800420 + c1).."-X" map_op[b1.."ctrl_1"] = tohex(0x4c800421 + c1).."-X" end ------------------------------------------------------------------------------ local function parse_gpr(expr) local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$") local tp = map_type[tname or expr] if tp then local reg = ovreg or tp.reg if not reg then werror("type `"..(tname or expr).."' needs a register override") end expr = reg end local r = match(expr, "^r([1-3]?[0-9])$") if r then r = tonumber(r) if r <= 31 then return r, tp end end werror("bad register name `"..expr.."'") end local function parse_fpr(expr) local r = match(expr, "^f([1-3]?[0-9])$") if r then r = tonumber(r) if r <= 31 then return r end end werror("bad register name `"..expr.."'") end local function parse_cr(expr) local r = match(expr, "^cr([0-7])$") if r then return tonumber(r) end werror("bad condition register name `"..expr.."'") end local function parse_cond(expr) local r, cond = match(expr, "^4%*cr([0-7])%+(%w%w)$") if r then r = tonumber(r) local c = map_cond[cond] if c and c < 4 then return r*4+c end end werror("bad condition bit name `"..expr.."'") end local function parse_imm(imm, bits, shift, scale, signed) local n = tonumber(imm) if n then local m = sar(n, scale) if shl(m, scale) == n then if signed then local s = sar(m, bits-1) if s == 0 then return shl(m, shift) elseif s == -1 then return shl(m + shl(1, bits), shift) end else if sar(m, bits) == 0 then return shl(m, shift) end end end werror("out of range immediate `"..imm.."'") elseif match(imm, "^r([1-3]?[0-9])$") or match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then werror("expected immediate operand, got register") else waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm) return 0 end end local function parse_shiftmask(imm, isshift) local n = tonumber(imm) if n then if shr(n, 6) == 0 then local lsb = band(imm, 31) local msb = imm - lsb return isshift and (shl(lsb, 11)+shr(msb, 4)) or (shl(lsb, 6)+msb) end werror("out of range immediate `"..imm.."'") elseif match(imm, "^r([1-3]?[0-9])$") or match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then werror("expected immediate operand, got register") else werror("NYI: parameterized 64 bit shift/mask") end end local function parse_disp(disp) local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") if imm then local r = parse_gpr(reg) if r == 0 then werror("cannot use r0 in displacement") end return shl(r, 16) + parse_imm(imm, 16, 0, 0, true) end local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") if reg and tailr ~= "" then local r, tp = parse_gpr(reg) if r == 0 then werror("cannot use r0 in displacement") end if tp then waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr)) return shl(r, 16) end end werror("bad displacement `"..disp.."'") end local function parse_u5disp(disp, scale) local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$") if imm then local r = parse_gpr(reg) if r == 0 then werror("cannot use r0 in displacement") end return shl(r, 16) + parse_imm(imm, 5, 11, scale, false) end local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$") if reg and tailr ~= "" then local r, tp = parse_gpr(reg) if r == 0 then werror("cannot use r0 in displacement") end if tp then waction("IMM", scale*1024+5*32+11, format(tp.ctypefmt, tailr)) return shl(r, 16) end end werror("bad displacement `"..disp.."'") end local function parse_label(label, def) local prefix = sub(label, 1, 2) -- =>label (pc label reference) if prefix == "=>" then return "PC", 0, sub(label, 3) end -- ->name (global label reference) if prefix == "->" then return "LG", map_global[sub(label, 3)] end if def then -- [1-9] (local label definition) if match(label, "^[1-9]$") then return "LG", 10+tonumber(label) end else -- [<>][1-9] (local label reference) local dir, lnum = match(label, "^([<>])([1-9])$") if dir then -- Fwd: 1-9, Bkwd: 11-19. return "LG", lnum + (dir == ">" and 0 or 10) end -- extern label (extern label reference) local extname = match(label, "^extern%s+(%S+)$") if extname then return "EXT", map_extern[extname] end end werror("bad label `"..label.."'") end ------------------------------------------------------------------------------ -- Handle opcodes defined with template strings. map_op[".template__"] = function(params, template, nparams) if not params then return sub(template, 9) end local op = tonumber(sub(template, 1, 8), 16) local n, rs = 1, 26 -- Limit number of section buffer positions used by a single dasm_put(). -- A single opcode needs a maximum of 3 positions (rlwinm). if secpos+3 > maxsecpos then wflush() end local pos = wpos() -- Process each character. for p in gmatch(sub(template, 9), ".") do if p == "R" then rs = rs - 5; op = op + shl(parse_gpr(params[n]), rs); n = n + 1 elseif p == "F" then rs = rs - 5; op = op + shl(parse_fpr(params[n]), rs); n = n + 1 elseif p == "A" then rs = rs - 5; op = op + parse_imm(params[n], 5, rs, 0, false); n = n + 1 elseif p == "S" then rs = rs - 5; op = op + parse_imm(params[n], 5, rs, 0, true); n = n + 1 elseif p == "I" then op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1 elseif p == "U" then op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1 elseif p == "D" then op = op + parse_disp(params[n]); n = n + 1 elseif p == "2" then op = op + parse_u5disp(params[n], 1); n = n + 1 elseif p == "4" then op = op + parse_u5disp(params[n], 2); n = n + 1 elseif p == "8" then op = op + parse_u5disp(params[n], 3); n = n + 1 elseif p == "C" then rs = rs - 5; op = op + shl(parse_cond(params[n]), rs); n = n + 1 elseif p == "X" then rs = rs - 5; op = op + shl(parse_cr(params[n]), rs+2); n = n + 1 elseif p == "W" then op = op + parse_cr(params[n]); n = n + 1 elseif p == "G" then op = op + parse_imm(params[n], 8, 12, 0, false); n = n + 1 elseif p == "H" then op = op + parse_shiftmask(params[n], true); n = n + 1 elseif p == "M" then op = op + parse_shiftmask(params[n], false); n = n + 1 elseif p == "J" or p == "K" then local mode, n, s = parse_label(params[n], false) if p == "K" then n = n + 2048 end waction("REL_"..mode, n, s, 1) n = n + 1 elseif p == "0" then if band(shr(op, rs), 31) == 0 then werror("cannot use r0") end elseif p == "=" or p == "%" then local t = band(shr(op, p == "%" and rs+5 or rs), 31) rs = rs - 5 op = op + shl(t, rs) elseif p == "~" then local mm = shl(31, rs) local lo = band(op, mm) local hi = band(op, shl(mm, 5)) op = op - lo - hi + shl(lo, 5) + shr(hi, 5) elseif p == "-" then rs = rs - 5 elseif p == "." then -- Ignored. else assert(false) end end wputpos(pos, op) end ------------------------------------------------------------------------------ -- Pseudo-opcode to mark the position where the action list is to be emitted. map_op[".actionlist_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeactions(out, name) end) end -- Pseudo-opcode to mark the position where the global enum is to be emitted. map_op[".globals_1"] = function(params) if not params then return "prefix" end local prefix = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeglobals(out, prefix) end) end -- Pseudo-opcode to mark the position where the global names are to be emitted. map_op[".globalnames_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeglobalnames(out, name) end) end -- Pseudo-opcode to mark the position where the extern names are to be emitted. map_op[".externnames_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeexternnames(out, name) end) end ------------------------------------------------------------------------------ -- Label pseudo-opcode (converted from trailing colon form). map_op[".label_1"] = function(params) if not params then return "[1-9] | ->global | =>pcexpr" end if secpos+1 > maxsecpos then wflush() end local mode, n, s = parse_label(params[1], true) if mode == "EXT" then werror("bad label definition") end waction("LABEL_"..mode, n, s, 1) end ------------------------------------------------------------------------------ -- Pseudo-opcodes for data storage. map_op[".long_*"] = function(params) if not params then return "imm..." end for _,p in ipairs(params) do local n = tonumber(p) if not n then werror("bad immediate `"..p.."'") end if n < 0 then n = n + 2^32 end wputw(n) if secpos+2 > maxsecpos then wflush() end end end -- Alignment pseudo-opcode. map_op[".align_1"] = function(params) if not params then return "numpow2" end if secpos+1 > maxsecpos then wflush() end local align = tonumber(params[1]) if align then local x = align -- Must be a power of 2 in the range (2 ... 256). for i=1,8 do x = x / 2 if x == 1 then waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1. return end end end werror("bad alignment") end ------------------------------------------------------------------------------ -- Pseudo-opcode for (primitive) type definitions (map to C types). map_op[".type_3"] = function(params, nparams) if not params then return nparams == 2 and "name, ctype" or "name, ctype, reg" end local name, ctype, reg = params[1], params[2], params[3] if not match(name, "^[%a_][%w_]*$") then werror("bad type name `"..name.."'") end local tp = map_type[name] if tp then werror("duplicate type `"..name.."'") end -- Add #type to defines. A bit unclean to put it in map_archdef. map_archdef["#"..name] = "sizeof("..ctype..")" -- Add new type and emit shortcut define. local num = ctypenum + 1 map_type[name] = { ctype = ctype, ctypefmt = format("Dt%X(%%s)", num), reg = reg, } wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) ctypenum = num end map_op[".type_2"] = map_op[".type_3"] -- Dump type definitions. local function dumptypes(out, lvl) local t = {} for name in pairs(map_type) do t[#t+1] = name end sort(t) out:write("Type definitions:\n") for _,name in ipairs(t) do local tp = map_type[name] local reg = tp.reg or "" out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) end out:write("\n") end ------------------------------------------------------------------------------ -- Set the current section. function _M.section(num) waction("SECTION", num) wflush(true) -- SECTION is a terminal action. end ------------------------------------------------------------------------------ -- Dump architecture description. function _M.dumparch(out) out:write(format("DynASM %s version %s, released %s\n\n", _info.arch, _info.version, _info.release)) dumpactions(out) end -- Dump all user defined elements. function _M.dumpdef(out, lvl) dumptypes(out, lvl) dumpglobals(out, lvl) dumpexterns(out, lvl) end ------------------------------------------------------------------------------ -- Pass callbacks from/to the DynASM core. function _M.passcb(wl, we, wf, ww) wline, werror, wfatal, wwarn = wl, we, wf, ww return wflush end -- Setup the arch-specific module. function _M.setup(arch, opt) g_arch, g_opt = arch, opt end -- Merge the core maps and the arch-specific maps. function _M.mergemaps(map_coreop, map_def) setmetatable(map_op, { __index = map_coreop }) setmetatable(map_def, { __index = map_archdef }) return map_op, map_def end return _M ------------------------------------------------------------------------------ ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_proto.h ================================================ /* ** DynASM encoding engine prototypes. ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. ** Released under the MIT license. See dynasm.lua for full copyright notice. */ #ifndef _DASM_PROTO_H #define _DASM_PROTO_H #include #include #define DASM_IDENT "DynASM 1.3.0" #define DASM_VERSION 10300 /* 1.3.0 */ #ifndef Dst_DECL #define Dst_DECL dasm_State **Dst #endif #ifndef Dst_REF #define Dst_REF (*Dst) #endif #ifndef DASM_FDEF #define DASM_FDEF extern #endif #ifndef DASM_M_GROW #define DASM_M_GROW(ctx, t, p, sz, need) \ do { \ size_t _sz = (sz), _need = (need); \ if (_sz < _need) { \ if (_sz < 16) _sz = 16; \ while (_sz < _need) _sz += _sz; \ (p) = (t *)realloc((p), _sz); \ if ((p) == NULL) exit(1); \ (sz) = _sz; \ } \ } while(0) #endif #ifndef DASM_M_FREE #define DASM_M_FREE(ctx, p, sz) free(p) #endif /* Internal DynASM encoder state. */ typedef struct dasm_State dasm_State; /* Initialize and free DynASM state. */ DASM_FDEF void dasm_init(Dst_DECL, int maxsection); DASM_FDEF void dasm_free(Dst_DECL); /* Setup global array. Must be called before dasm_setup(). */ DASM_FDEF void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl); /* Grow PC label array. Can be called after dasm_setup(), too. */ DASM_FDEF void dasm_growpc(Dst_DECL, unsigned int maxpc); /* Setup encoder. */ DASM_FDEF void dasm_setup(Dst_DECL, const void *actionlist); /* Feed encoder with actions. Calls are generated by pre-processor. */ DASM_FDEF void dasm_put(Dst_DECL, int start, ...); /* Link sections and return the resulting size. */ DASM_FDEF int dasm_link(Dst_DECL, size_t *szp); /* Encode sections into buffer. */ DASM_FDEF int dasm_encode(Dst_DECL, void *buffer); /* Get PC label offset. */ DASM_FDEF int dasm_getpclabel(Dst_DECL, unsigned int pc); #ifdef DASM_CHECKS /* Optional sanity checker to call between isolated encoding steps. */ DASM_FDEF int dasm_checkstep(Dst_DECL, int secmatch); #else #define dasm_checkstep(a, b) 0 #endif #endif /* _DASM_PROTO_H */ ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_x64.lua ================================================ ------------------------------------------------------------------------------ -- DynASM x64 module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------ -- This module just sets 64 bit mode for the combined x86/x64 module. -- All the interesting stuff is there. ------------------------------------------------------------------------------ x64 = true -- Using a global is an ugly, but effective solution. return require("dasm_x86") ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_x86.h ================================================ /* ** DynASM x86 encoding engine. ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. ** Released under the MIT license. See dynasm.lua for full copyright notice. */ #include #include #include #include #define DASM_ARCH "x86" #ifndef DASM_EXTERN #define DASM_EXTERN(a,b,c,d) 0 #endif /* Action definitions. DASM_STOP must be 255. */ enum { DASM_DISP = 233, DASM_IMM_S, DASM_IMM_B, DASM_IMM_W, DASM_IMM_D, DASM_IMM_WB, DASM_IMM_DB, DASM_VREG, DASM_SPACE, DASM_SETLABEL, DASM_REL_A, DASM_REL_LG, DASM_REL_PC, DASM_IMM_LG, DASM_IMM_PC, DASM_LABEL_LG, DASM_LABEL_PC, DASM_ALIGN, DASM_EXTERN, DASM_ESC, DASM_MARK, DASM_SECTION, DASM_STOP }; /* Maximum number of section buffer positions for a single dasm_put() call. */ #define DASM_MAXSECPOS 25 /* DynASM encoder status codes. Action list offset or number are or'ed in. */ #define DASM_S_OK 0x00000000 #define DASM_S_NOMEM 0x01000000 #define DASM_S_PHASE 0x02000000 #define DASM_S_MATCH_SEC 0x03000000 #define DASM_S_RANGE_I 0x11000000 #define DASM_S_RANGE_SEC 0x12000000 #define DASM_S_RANGE_LG 0x13000000 #define DASM_S_RANGE_PC 0x14000000 #define DASM_S_RANGE_VREG 0x15000000 #define DASM_S_UNDEF_L 0x21000000 #define DASM_S_UNDEF_PC 0x22000000 /* Macros to convert positions (8 bit section + 24 bit index). */ #define DASM_POS2IDX(pos) ((pos)&0x00ffffff) #define DASM_POS2BIAS(pos) ((pos)&0xff000000) #define DASM_SEC2POS(sec) ((sec)<<24) #define DASM_POS2SEC(pos) ((pos)>>24) #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) /* Action list type. */ typedef const unsigned char *dasm_ActList; /* Per-section structure. */ typedef struct dasm_Section { int *rbuf; /* Biased buffer pointer (negative section bias). */ int *buf; /* True buffer pointer. */ size_t bsize; /* Buffer size in bytes. */ int pos; /* Biased buffer position. */ int epos; /* End of biased buffer position - max single put. */ int ofs; /* Byte offset into section. */ } dasm_Section; /* Core structure holding the DynASM encoding state. */ struct dasm_State { size_t psize; /* Allocated size of this structure. */ dasm_ActList actionlist; /* Current actionlist pointer. */ int *lglabels; /* Local/global chain/pos ptrs. */ size_t lgsize; int *pclabels; /* PC label chains/pos ptrs. */ size_t pcsize; void **globals; /* Array of globals (bias -10). */ dasm_Section *section; /* Pointer to active section. */ size_t codesize; /* Total size of all code sections. */ int maxsection; /* 0 <= sectionidx < maxsection. */ int status; /* Status code. */ dasm_Section sections[1]; /* All sections. Alloc-extended. */ }; /* The size of the core structure depends on the max. number of sections. */ #define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section)) /* Initialize DynASM state. */ void dasm_init(Dst_DECL, int maxsection) { dasm_State *D; size_t psz = 0; int i; Dst_REF = NULL; DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection)); D = Dst_REF; D->psize = psz; D->lglabels = NULL; D->lgsize = 0; D->pclabels = NULL; D->pcsize = 0; D->globals = NULL; D->maxsection = maxsection; for (i = 0; i < maxsection; i++) { D->sections[i].buf = NULL; /* Need this for pass3. */ D->sections[i].rbuf = D->sections[i].buf - DASM_SEC2POS(i); D->sections[i].bsize = 0; D->sections[i].epos = 0; /* Wrong, but is recalculated after resize. */ } } /* Free DynASM state. */ void dasm_free(Dst_DECL) { dasm_State *D = Dst_REF; int i; for (i = 0; i < D->maxsection; i++) if (D->sections[i].buf) DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize); if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize); if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize); DASM_M_FREE(Dst, D, D->psize); } /* Setup global label array. Must be called before dasm_setup(). */ void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl) { dasm_State *D = Dst_REF; D->globals = gl - 10; /* Negative bias to compensate for locals. */ DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int)); } /* Grow PC label array. Can be called after dasm_setup(), too. */ void dasm_growpc(Dst_DECL, unsigned int maxpc) { dasm_State *D = Dst_REF; size_t osz = D->pcsize; DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int)); memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz); } /* Setup encoder. */ void dasm_setup(Dst_DECL, const void *actionlist) { dasm_State *D = Dst_REF; int i; D->actionlist = (dasm_ActList)actionlist; D->status = DASM_S_OK; D->section = &D->sections[0]; memset((void *)D->lglabels, 0, D->lgsize); if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize); for (i = 0; i < D->maxsection; i++) { D->sections[i].pos = DASM_SEC2POS(i); D->sections[i].ofs = 0; } } #ifdef DASM_CHECKS #define CK(x, st) \ do { if (!(x)) { \ D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0) #define CKPL(kind, st) \ do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \ D->status=DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0) #else #define CK(x, st) ((void)0) #define CKPL(kind, st) ((void)0) #endif /* Pass 1: Store actions and args, link branches/labels, estimate offsets. */ void dasm_put(Dst_DECL, int start, ...) { va_list ap; dasm_State *D = Dst_REF; dasm_ActList p = D->actionlist + start; dasm_Section *sec = D->section; int pos = sec->pos, ofs = sec->ofs, mrm = 4; int *b; if (pos >= sec->epos) { DASM_M_GROW(Dst, int, sec->buf, sec->bsize, sec->bsize + 2*DASM_MAXSECPOS*sizeof(int)); sec->rbuf = sec->buf - DASM_POS2BIAS(pos); sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos); } b = sec->rbuf; b[pos++] = start; va_start(ap, start); while (1) { int action = *p++; if (action < DASM_DISP) { ofs++; } else if (action <= DASM_REL_A) { int n = va_arg(ap, int); b[pos++] = n; switch (action) { case DASM_DISP: if (n == 0) { if ((mrm&7) == 4) mrm = p[-2]; if ((mrm&7) != 5) break; } case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; case DASM_REL_A: /* Assumes ptrdiff_t is int. !x64 */ case DASM_IMM_D: ofs += 4; break; case DASM_IMM_S: CK(((n+128)&-256) == 0, RANGE_I); goto ob; case DASM_IMM_B: CK((n&-256) == 0, RANGE_I); ob: ofs++; break; case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; case DASM_IMM_W: CK((n&-65536) == 0, RANGE_I); ofs += 2; break; case DASM_SPACE: p++; ofs += n; break; case DASM_SETLABEL: b[pos-2] = -0x40000000; break; /* Neg. label ofs. */ case DASM_VREG: CK((n&-8) == 0 && (n != 4 || (*p&1) == 0), RANGE_VREG); if (*p++ == 1 && *p == DASM_DISP) mrm = n; continue; } mrm = 4; } else { int *pl, n; switch (action) { case DASM_REL_LG: case DASM_IMM_LG: n = *p++; pl = D->lglabels + n; if (n <= 246) { CKPL(lg, LG); goto putrel; } /* Bkwd rel or global. */ pl -= 246; n = *pl; if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */ goto linkrel; case DASM_REL_PC: case DASM_IMM_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); putrel: n = *pl; if (n < 0) { /* Label exists. Get label pos and store it. */ b[pos] = -n; } else { linkrel: b[pos] = n; /* Else link to rel chain, anchored at label. */ *pl = pos; } pos++; ofs += 4; /* Maximum offset needed. */ if (action == DASM_REL_LG || action == DASM_REL_PC) b[pos++] = ofs; /* Store pass1 offset estimate. */ break; case DASM_LABEL_LG: pl = D->lglabels + *p++; CKPL(lg, LG); goto putlabel; case DASM_LABEL_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC); putlabel: n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; } *pl = -pos; /* Label exists now. */ b[pos++] = ofs; /* Store pass1 offset estimate. */ break; case DASM_ALIGN: ofs += *p++; /* Maximum alignment needed (arg is 2**n-1). */ b[pos++] = ofs; /* Store pass1 offset estimate. */ break; case DASM_EXTERN: p += 2; ofs += 4; break; case DASM_ESC: p++; ofs++; break; case DASM_MARK: mrm = p[-2]; break; case DASM_SECTION: n = *p; CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n]; case DASM_STOP: goto stop; } } } stop: va_end(ap); sec->pos = pos; sec->ofs = ofs; } #undef CK /* Pass 2: Link sections, shrink branches/aligns, fix label offsets. */ int dasm_link(Dst_DECL, size_t *szp) { dasm_State *D = Dst_REF; int secnum; int ofs = 0; #ifdef DASM_CHECKS *szp = 0; if (D->status != DASM_S_OK) return D->status; { int pc; for (pc = 0; pc*sizeof(int) < D->pcsize; pc++) if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc; } #endif { /* Handle globals not defined in this translation unit. */ int idx; for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) { int n = D->lglabels[idx]; /* Undefined label: Collapse rel chain and replace with marker (< 0). */ while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } } } /* Combine all code sections. No support for data sections (yet). */ for (secnum = 0; secnum < D->maxsection; secnum++) { dasm_Section *sec = D->sections + secnum; int *b = sec->rbuf; int pos = DASM_SEC2POS(secnum); int lastpos = sec->pos; while (pos != lastpos) { dasm_ActList p = D->actionlist + b[pos++]; while (1) { int op, action = *p++; switch (action) { case DASM_REL_LG: p++; op = p[-3]; goto rel_pc; case DASM_REL_PC: op = p[-2]; rel_pc: { int shrink = op == 0xe9 ? 3 : ((op&0xf0) == 0x80 ? 4 : 0); if (shrink) { /* Shrinkable branch opcode? */ int lofs, lpos = b[pos]; if (lpos < 0) goto noshrink; /* Ext global? */ lofs = *DASM_POS2PTR(D, lpos); if (lpos > pos) { /* Fwd label: add cumulative section offsets. */ int i; for (i = secnum; i < DASM_POS2SEC(lpos); i++) lofs += D->sections[i].ofs; } else { lofs -= ofs; /* Bkwd label: unfix offset. */ } lofs -= b[pos+1]; /* Short branch ok? */ if (lofs >= -128-shrink && lofs <= 127) ofs -= shrink; /* Yes. */ else { noshrink: shrink = 0; } /* No, cannot shrink op. */ } b[pos+1] = shrink; pos += 2; break; } case DASM_SPACE: case DASM_IMM_LG: case DASM_VREG: p++; case DASM_DISP: case DASM_IMM_S: case DASM_IMM_B: case DASM_IMM_W: case DASM_IMM_D: case DASM_IMM_WB: case DASM_IMM_DB: case DASM_SETLABEL: case DASM_REL_A: case DASM_IMM_PC: pos++; break; case DASM_LABEL_LG: p++; case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */ case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */ case DASM_EXTERN: p += 2; break; case DASM_ESC: p++; break; case DASM_MARK: break; case DASM_SECTION: case DASM_STOP: goto stop; } } stop: (void)0; } ofs += sec->ofs; /* Next section starts right after current section. */ } D->codesize = ofs; /* Total size of all code sections */ *szp = ofs; return DASM_S_OK; } #define dasmb(x) *cp++ = (unsigned char)(x) #ifndef DASM_ALIGNED_WRITES #define dasmw(x) \ do { *((unsigned short *)cp) = (unsigned short)(x); cp+=2; } while (0) #define dasmd(x) \ do { *((unsigned int *)cp) = (unsigned int)(x); cp+=4; } while (0) #else #define dasmw(x) do { dasmb(x); dasmb((x)>>8); } while (0) #define dasmd(x) do { dasmw(x); dasmw((x)>>16); } while (0) #endif /* Pass 3: Encode sections. */ int dasm_encode(Dst_DECL, void *buffer) { dasm_State *D = Dst_REF; unsigned char *base = (unsigned char *)buffer; unsigned char *cp = base; int secnum; /* Encode all code sections. No support for data sections (yet). */ for (secnum = 0; secnum < D->maxsection; secnum++) { dasm_Section *sec = D->sections + secnum; int *b = sec->buf; int *endb = sec->rbuf + sec->pos; while (b != endb) { dasm_ActList p = D->actionlist + *b++; unsigned char *mark = NULL; while (1) { int action = *p++; int n = (action >= DASM_DISP && action <= DASM_ALIGN) ? *b++ : 0; switch (action) { case DASM_DISP: if (!mark) mark = cp; { unsigned char *mm = mark; if (*p != DASM_IMM_DB && *p != DASM_IMM_WB) mark = NULL; if (n == 0) { int mrm = mm[-1]&7; if (mrm == 4) mrm = mm[0]&7; if (mrm != 5) { mm[-1] -= 0x80; break; } } if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40; } case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break; case DASM_IMM_DB: if (((n+128)&-256) == 0) { db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb; } else mark = NULL; case DASM_IMM_D: wd: dasmd(n); break; case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL; case DASM_IMM_W: dasmw(n); break; case DASM_VREG: { int t = *p++; if (t >= 2) n<<=3; cp[-1] |= n; break; } case DASM_REL_LG: p++; if (n >= 0) goto rel_pc; b++; n = (int)(ptrdiff_t)D->globals[-n]; case DASM_REL_A: rel_a: n -= (int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */ case DASM_REL_PC: rel_pc: { int shrink = *b++; int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; } n = *pb - ((int)(cp-base) + 4-shrink); if (shrink == 0) goto wd; if (shrink == 4) { cp--; cp[-1] = *cp-0x10; } else cp[-1] = 0xeb; goto wb; } case DASM_IMM_LG: p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; } case DASM_IMM_PC: { int *pb = DASM_POS2PTR(D, n); n = *pb < 0 ? pb[1] : (*pb + (int)(ptrdiff_t)base); goto wd; } case DASM_LABEL_LG: { int idx = *p++; if (idx >= 10) D->globals[idx] = (void *)(base + (*p == DASM_SETLABEL ? *b : n)); break; } case DASM_LABEL_PC: case DASM_SETLABEL: break; case DASM_SPACE: { int fill = *p++; while (n--) *cp++ = fill; break; } case DASM_ALIGN: n = *p++; while (((cp-base) & n)) *cp++ = 0x90; /* nop */ break; case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd; case DASM_MARK: mark = cp; break; case DASM_ESC: action = *p++; default: *cp++ = action; break; case DASM_SECTION: case DASM_STOP: goto stop; } } stop: (void)0; } } if (base + D->codesize != cp) /* Check for phase errors. */ return DASM_S_PHASE; return DASM_S_OK; } /* Get PC label offset. */ int dasm_getpclabel(Dst_DECL, unsigned int pc) { dasm_State *D = Dst_REF; if (pc*sizeof(int) < D->pcsize) { int pos = D->pclabels[pc]; if (pos < 0) return *DASM_POS2PTR(D, -pos); if (pos > 0) return -1; /* Undefined. */ } return -2; /* Unused or out of range. */ } #ifdef DASM_CHECKS /* Optional sanity checker to call between isolated encoding steps. */ int dasm_checkstep(Dst_DECL, int secmatch) { dasm_State *D = Dst_REF; if (D->status == DASM_S_OK) { int i; for (i = 1; i <= 9; i++) { if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_L|i; break; } D->lglabels[i] = 0; } } if (D->status == DASM_S_OK && secmatch >= 0 && D->section != &D->sections[secmatch]) D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections); return D->status; } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dasm_x86.lua ================================================ ------------------------------------------------------------------------------ -- DynASM x86/x64 module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- See dynasm.lua for full copyright notice. ------------------------------------------------------------------------------ local x64 = x64 -- Module information: local _info = { arch = x64 and "x64" or "x86", description = "DynASM x86/x64 module", version = "1.3.0", vernum = 10300, release = "2011-05-05", author = "Mike Pall", license = "MIT", } -- Exported glue functions for the arch-specific module. local _M = { _info = _info } -- Cache library functions. local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs local assert, unpack, setmetatable = assert, unpack or table.unpack, setmetatable local _s = string local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char local find, match, gmatch, gsub = _s.find, _s.match, _s.gmatch, _s.gsub local concat, sort = table.concat, table.sort local bit = bit or require("bit") local band, shl, shr = bit.band, bit.lshift, bit.rshift -- Inherited tables and callbacks. local g_opt, g_arch local wline, werror, wfatal, wwarn -- Action name list. -- CHECK: Keep this in sync with the C code! local action_names = { -- int arg, 1 buffer pos: "DISP", "IMM_S", "IMM_B", "IMM_W", "IMM_D", "IMM_WB", "IMM_DB", -- action arg (1 byte), int arg, 1 buffer pos (reg/num): "VREG", "SPACE", -- !x64: VREG support NYI. -- ptrdiff_t arg, 1 buffer pos (address): !x64 "SETLABEL", "REL_A", -- action arg (1 byte) or int arg, 2 buffer pos (link, offset): "REL_LG", "REL_PC", -- action arg (1 byte) or int arg, 1 buffer pos (link): "IMM_LG", "IMM_PC", -- action arg (1 byte) or int arg, 1 buffer pos (offset): "LABEL_LG", "LABEL_PC", -- action arg (1 byte), 1 buffer pos (offset): "ALIGN", -- action args (2 bytes), no buffer pos. "EXTERN", -- action arg (1 byte), no buffer pos. "ESC", -- no action arg, no buffer pos. "MARK", -- action arg (1 byte), no buffer pos, terminal action: "SECTION", -- no args, no buffer pos, terminal action: "STOP" } -- Maximum number of section buffer positions for dasm_put(). -- CHECK: Keep this in sync with the C code! local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines. -- Action name -> action number (dynamically generated below). local map_action = {} -- First action number. Everything below does not need to be escaped. local actfirst = 256-#action_names -- Action list buffer and string (only used to remove dupes). local actlist = {} local actstr = "" -- Argument list for next dasm_put(). Start with offset 0 into action list. local actargs = { 0 } -- Current number of section buffer positions for dasm_put(). local secpos = 1 ------------------------------------------------------------------------------ -- Compute action numbers for action names. for n,name in ipairs(action_names) do local num = actfirst + n - 1 map_action[name] = num end -- Dump action names and numbers. local function dumpactions(out) out:write("DynASM encoding engine action codes:\n") for n,name in ipairs(action_names) do local num = map_action[name] out:write(format(" %-10s %02X %d\n", name, num, num)) end out:write("\n") end -- Write action list buffer as a huge static C array. local function writeactions(out, name) local nn = #actlist local last = actlist[nn] or 255 actlist[nn] = nil -- Remove last byte. if nn == 0 then nn = 1 end out:write("static const unsigned char ", name, "[", nn, "] = {\n") local s = " " for n,b in ipairs(actlist) do s = s..b.."," if #s >= 75 then assert(out:write(s, "\n")) s = " " end end out:write(s, last, "\n};\n\n") -- Add last byte back. end ------------------------------------------------------------------------------ -- Add byte to action list. local function wputxb(n) assert(n >= 0 and n <= 255 and n % 1 == 0, "byte out of range") actlist[#actlist+1] = n end -- Add action to list with optional arg. Advance buffer pos, too. local function waction(action, a, num) wputxb(assert(map_action[action], "bad action name `"..action.."'")) if a then actargs[#actargs+1] = a end if a or num then secpos = secpos + (num or 1) end end -- Add call to embedded DynASM C code. local function wcall(func, args) wline(format("dasm_%s(Dst, %s);", func, concat(args, ", ")), true) end -- Delete duplicate action list chunks. A tad slow, but so what. local function dedupechunk(offset) local al, as = actlist, actstr local chunk = char(unpack(al, offset+1, #al)) local orig = find(as, chunk, 1, true) if orig then actargs[1] = orig-1 -- Replace with original offset. for i=offset+1,#al do al[i] = nil end -- Kill dupe. else actstr = as..chunk end end -- Flush action list (intervening C code or buffer pos overflow). local function wflush(term) local offset = actargs[1] if #actlist == offset then return end -- Nothing to flush. if not term then waction("STOP") end -- Terminate action list. dedupechunk(offset) wcall("put", actargs) -- Add call to dasm_put(). actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put(). secpos = 1 -- The actionlist offset occupies a buffer position, too. end -- Put escaped byte. local function wputb(n) if n >= actfirst then waction("ESC") end -- Need to escape byte. wputxb(n) end ------------------------------------------------------------------------------ -- Global label name -> global label number. With auto assignment on 1st use. local next_global = 10 local map_global = setmetatable({}, { __index = function(t, name) if not match(name, "^[%a_][%w_@]*$") then werror("bad global label") end local n = next_global if n > 246 then werror("too many global labels") end next_global = n + 1 t[name] = n return n end}) -- Dump global labels. local function dumpglobals(out, lvl) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("Global labels:\n") for i=10,next_global-1 do out:write(format(" %s\n", t[i])) end out:write("\n") end -- Write global label enum. local function writeglobals(out, prefix) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("enum {\n") for i=10,next_global-1 do out:write(" ", prefix, gsub(t[i], "@.*", ""), ",\n") end out:write(" ", prefix, "_MAX\n};\n") end -- Write global label names. local function writeglobalnames(out, name) local t = {} for name, n in pairs(map_global) do t[n] = name end out:write("static const char *const ", name, "[] = {\n") for i=10,next_global-1 do out:write(" \"", t[i], "\",\n") end out:write(" (const char *)0\n};\n") end ------------------------------------------------------------------------------ -- Extern label name -> extern label number. With auto assignment on 1st use. local next_extern = -1 local map_extern = setmetatable({}, { __index = function(t, name) -- No restrictions on the name for now. local n = next_extern if n < -256 then werror("too many extern labels") end next_extern = n - 1 t[name] = n return n end}) -- Dump extern labels. local function dumpexterns(out, lvl) local t = {} for name, n in pairs(map_extern) do t[-n] = name end out:write("Extern labels:\n") for i=1,-next_extern-1 do out:write(format(" %s\n", t[i])) end out:write("\n") end -- Write extern label names. local function writeexternnames(out, name) local t = {} for name, n in pairs(map_extern) do t[-n] = name end out:write("static const char *const ", name, "[] = {\n") for i=1,-next_extern-1 do out:write(" \"", t[i], "\",\n") end out:write(" (const char *)0\n};\n") end ------------------------------------------------------------------------------ -- Arch-specific maps. local map_archdef = {} -- Ext. register name -> int. name. local map_reg_rev = {} -- Int. register name -> ext. name. local map_reg_num = {} -- Int. register name -> register number. local map_reg_opsize = {} -- Int. register name -> operand size. local map_reg_valid_base = {} -- Int. register name -> valid base register? local map_reg_valid_index = {} -- Int. register name -> valid index register? local map_reg_needrex = {} -- Int. register name -> need rex vs. no rex. local reg_list = {} -- Canonical list of int. register names. local map_type = {} -- Type name -> { ctype, reg } local ctypenum = 0 -- Type number (for _PTx macros). local addrsize = x64 and "q" or "d" -- Size for address operands. -- Helper functions to fill register maps. local function mkrmap(sz, cl, names) local cname = format("@%s", sz) reg_list[#reg_list+1] = cname map_archdef[cl] = cname map_reg_rev[cname] = cl map_reg_num[cname] = -1 map_reg_opsize[cname] = sz if sz == addrsize or sz == "d" then map_reg_valid_base[cname] = true map_reg_valid_index[cname] = true end if names then for n,name in ipairs(names) do local iname = format("@%s%x", sz, n-1) reg_list[#reg_list+1] = iname map_archdef[name] = iname map_reg_rev[iname] = name map_reg_num[iname] = n-1 map_reg_opsize[iname] = sz if sz == "b" and n > 4 then map_reg_needrex[iname] = false end if sz == addrsize or sz == "d" then map_reg_valid_base[iname] = true map_reg_valid_index[iname] = true end end end for i=0,(x64 and sz ~= "f") and 15 or 7 do local needrex = sz == "b" and i > 3 local iname = format("@%s%x%s", sz, i, needrex and "R" or "") if needrex then map_reg_needrex[iname] = true end local name if sz == "o" then name = format("xmm%d", i) elseif sz == "f" then name = format("st%d", i) else name = format("r%d%s", i, sz == addrsize and "" or sz) end map_archdef[name] = iname if not map_reg_rev[iname] then reg_list[#reg_list+1] = iname map_reg_rev[iname] = name map_reg_num[iname] = i map_reg_opsize[iname] = sz if sz == addrsize or sz == "d" then map_reg_valid_base[iname] = true map_reg_valid_index[iname] = true end end end reg_list[#reg_list+1] = "" end -- Integer registers (qword, dword, word and byte sized). if x64 then mkrmap("q", "Rq", {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi"}) end mkrmap("d", "Rd", {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"}) mkrmap("w", "Rw", {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di"}) mkrmap("b", "Rb", {"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"}) map_reg_valid_index[map_archdef.esp] = false if x64 then map_reg_valid_index[map_archdef.rsp] = false end map_archdef["Ra"] = "@"..addrsize -- FP registers (internally tword sized, but use "f" as operand size). mkrmap("f", "Rf") -- SSE registers (oword sized, but qword and dword accessible). mkrmap("o", "xmm") -- Operand size prefixes to codes. local map_opsize = { byte = "b", word = "w", dword = "d", qword = "q", oword = "o", tword = "t", aword = addrsize, } -- Operand size code to number. local map_opsizenum = { b = 1, w = 2, d = 4, q = 8, o = 16, t = 10, } -- Operand size code to name. local map_opsizename = { b = "byte", w = "word", d = "dword", q = "qword", o = "oword", t = "tword", f = "fpword", } -- Valid index register scale factors. local map_xsc = { ["1"] = 0, ["2"] = 1, ["4"] = 2, ["8"] = 3, } -- Condition codes. local map_cc = { o = 0, no = 1, b = 2, nb = 3, e = 4, ne = 5, be = 6, nbe = 7, s = 8, ns = 9, p = 10, np = 11, l = 12, nl = 13, le = 14, nle = 15, c = 2, nae = 2, nc = 3, ae = 3, z = 4, nz = 5, na = 6, a = 7, pe = 10, po = 11, nge = 12, ge = 13, ng = 14, g = 15, } -- Reverse defines for registers. function _M.revdef(s) return gsub(s, "@%w+", map_reg_rev) end -- Dump register names and numbers local function dumpregs(out) out:write("Register names, sizes and internal numbers:\n") for _,reg in ipairs(reg_list) do if reg == "" then out:write("\n") else local name = map_reg_rev[reg] local num = map_reg_num[reg] local opsize = map_opsizename[map_reg_opsize[reg]] out:write(format(" %-5s %-8s %s\n", name, opsize, num < 0 and "(variable)" or num)) end end end ------------------------------------------------------------------------------ -- Put action for label arg (IMM_LG, IMM_PC, REL_LG, REL_PC). local function wputlabel(aprefix, imm, num) if type(imm) == "number" then if imm < 0 then waction("EXTERN") wputxb(aprefix == "IMM_" and 0 or 1) imm = -imm-1 else waction(aprefix.."LG", nil, num); end wputxb(imm) else waction(aprefix.."PC", imm, num) end end -- Put signed byte or arg. local function wputsbarg(n) if type(n) == "number" then if n < -128 or n > 127 then werror("signed immediate byte out of range") end if n < 0 then n = n + 256 end wputb(n) else waction("IMM_S", n) end end -- Put unsigned byte or arg. local function wputbarg(n) if type(n) == "number" then if n < 0 or n > 255 then werror("unsigned immediate byte out of range") end wputb(n) else waction("IMM_B", n) end end -- Put unsigned word or arg. local function wputwarg(n) if type(n) == "number" then if shr(n, 16) ~= 0 then werror("unsigned immediate word out of range") end wputb(band(n, 255)); wputb(shr(n, 8)); else waction("IMM_W", n) end end -- Put signed or unsigned dword or arg. local function wputdarg(n) local tn = type(n) if tn == "number" then wputb(band(n, 255)) wputb(band(shr(n, 8), 255)) wputb(band(shr(n, 16), 255)) wputb(shr(n, 24)) elseif tn == "table" then wputlabel("IMM_", n[1], 1) else waction("IMM_D", n) end end -- Put operand-size dependent number or arg (defaults to dword). local function wputszarg(sz, n) if not sz or sz == "d" or sz == "q" then wputdarg(n) elseif sz == "w" then wputwarg(n) elseif sz == "b" then wputbarg(n) elseif sz == "s" then wputsbarg(n) else werror("bad operand size") end end -- Put multi-byte opcode with operand-size dependent modifications. local function wputop(sz, op, rex) local r if rex ~= 0 and not x64 then werror("bad operand size") end if sz == "w" then wputb(102) end -- Needs >32 bit numbers, but only for crc32 eax, word [ebx] if op >= 4294967296 then r = op%4294967296 wputb((op-r)/4294967296) op = r end if op >= 16777216 then wputb(shr(op, 24)); op = band(op, 0xffffff) end if op >= 65536 then if rex ~= 0 then local opc3 = band(op, 0xffff00) if opc3 == 0x0f3a00 or opc3 == 0x0f3800 then wputb(64 + band(rex, 15)); rex = 0 end end wputb(shr(op, 16)); op = band(op, 0xffff) end if op >= 256 then local b = shr(op, 8) if b == 15 and rex ~= 0 then wputb(64 + band(rex, 15)); rex = 0 end wputb(b) op = band(op, 255) end if rex ~= 0 then wputb(64 + band(rex, 15)) end if sz == "b" then op = op - 1 end wputb(op) end -- Put ModRM or SIB formatted byte. local function wputmodrm(m, s, rm, vs, vrm) assert(m < 4 and s < 16 and rm < 16, "bad modrm operands") wputb(shl(m, 6) + shl(band(s, 7), 3) + band(rm, 7)) end -- Put ModRM/SIB plus optional displacement. local function wputmrmsib(t, imark, s, vsreg) local vreg, vxreg local reg, xreg = t.reg, t.xreg if reg and reg < 0 then reg = 0; vreg = t.vreg end if xreg and xreg < 0 then xreg = 0; vxreg = t.vxreg end if s < 0 then s = 0 end -- Register mode. if sub(t.mode, 1, 1) == "r" then wputmodrm(3, s, reg) if vsreg then waction("VREG", vsreg); wputxb(2) end if vreg then waction("VREG", vreg); wputxb(0) end return end local disp = t.disp local tdisp = type(disp) -- No base register? if not reg then local riprel = false if xreg then -- Indexed mode with index register only. -- [xreg*xsc+disp] -> (0, s, esp) (xsc, xreg, ebp) wputmodrm(0, s, 4) if imark == "I" then waction("MARK") end if vsreg then waction("VREG", vsreg); wputxb(2) end wputmodrm(t.xsc, xreg, 5) if vxreg then waction("VREG", vxreg); wputxb(3) end else -- Pure 32 bit displacement. if x64 and tdisp ~= "table" then wputmodrm(0, s, 4) -- [disp] -> (0, s, esp) (0, esp, ebp) if imark == "I" then waction("MARK") end wputmodrm(0, 4, 5) else riprel = x64 wputmodrm(0, s, 5) -- [disp|rip-label] -> (0, s, ebp) if imark == "I" then waction("MARK") end end if vsreg then waction("VREG", vsreg); wputxb(2) end end if riprel then -- Emit rip-relative displacement. if match("UWSiI", imark) then werror("NYI: rip-relative displacement followed by immediate") end -- The previous byte in the action buffer cannot be 0xe9 or 0x80-0x8f. wputlabel("REL_", disp[1], 2) else wputdarg(disp) end return end local m if tdisp == "number" then -- Check displacement size at assembly time. if disp == 0 and band(reg, 7) ~= 5 then -- [ebp] -> [ebp+0] (in SIB, too) if not vreg then m = 0 end -- Force DISP to allow [Rd(5)] -> [ebp+0] elseif disp >= -128 and disp <= 127 then m = 1 else m = 2 end elseif tdisp == "table" then m = 2 end -- Index register present or esp as base register: need SIB encoding. if xreg or band(reg, 7) == 4 then wputmodrm(m or 2, s, 4) -- ModRM. if m == nil or imark == "I" then waction("MARK") end if vsreg then waction("VREG", vsreg); wputxb(2) end wputmodrm(t.xsc or 0, xreg or 4, reg) -- SIB. if vxreg then waction("VREG", vxreg); wputxb(3) end if vreg then waction("VREG", vreg); wputxb(1) end else wputmodrm(m or 2, s, reg) -- ModRM. if (imark == "I" and (m == 1 or m == 2)) or (m == nil and (vsreg or vreg)) then waction("MARK") end if vsreg then waction("VREG", vsreg); wputxb(2) end if vreg then waction("VREG", vreg); wputxb(1) end end -- Put displacement. if m == 1 then wputsbarg(disp) elseif m == 2 then wputdarg(disp) elseif m == nil then waction("DISP", disp) end end ------------------------------------------------------------------------------ -- Return human-readable operand mode string. local function opmodestr(op, args) local m = {} for i=1,#args do local a = args[i] m[#m+1] = sub(a.mode, 1, 1)..(a.opsize or "?") end return op.." "..concat(m, ",") end -- Convert number to valid integer or nil. local function toint(expr) local n = tonumber(expr) if n then if n % 1 ~= 0 or n < -2147483648 or n > 4294967295 then werror("bad integer number `"..expr.."'") end return n end end -- Parse immediate expression. local function immexpr(expr) -- &expr (pointer) if sub(expr, 1, 1) == "&" then return "iPJ", format("(ptrdiff_t)(%s)", sub(expr,2)) end local prefix = sub(expr, 1, 2) -- =>expr (pc label reference) if prefix == "=>" then return "iJ", sub(expr, 3) end -- ->name (global label reference) if prefix == "->" then return "iJ", map_global[sub(expr, 3)] end -- [<>][1-9] (local label reference) local dir, lnum = match(expr, "^([<>])([1-9])$") if dir then -- Fwd: 247-255, Bkwd: 1-9. return "iJ", lnum + (dir == ">" and 246 or 0) end local extname = match(expr, "^extern%s+(%S+)$") if extname then return "iJ", map_extern[extname] end -- expr (interpreted as immediate) return "iI", expr end -- Parse displacement expression: +-num, +-expr, +-opsize*num local function dispexpr(expr) local disp = expr == "" and 0 or toint(expr) if disp then return disp end local c, dispt = match(expr, "^([+-])%s*(.+)$") if c == "+" then expr = dispt elseif not c then werror("bad displacement expression `"..expr.."'") end local opsize, tailops = match(dispt, "^(%w+)%s*%*%s*(.+)$") local ops, imm = map_opsize[opsize], toint(tailops) if ops and imm then if c == "-" then imm = -imm end return imm*map_opsizenum[ops] end local mode, iexpr = immexpr(dispt) if mode == "iJ" then if c == "-" then werror("cannot invert label reference") end return { iexpr } end return expr -- Need to return original signed expression. end -- Parse register or type expression. local function rtexpr(expr) if not expr then return end local tname, ovreg = match(expr, "^([%w_]+):(@[%w_]+)$") local tp = map_type[tname or expr] if tp then local reg = ovreg or tp.reg local rnum = map_reg_num[reg] if not rnum then werror("type `"..(tname or expr).."' needs a register override") end if not map_reg_valid_base[reg] then werror("bad base register override `"..(map_reg_rev[reg] or reg).."'") end return reg, rnum, tp end return expr, map_reg_num[expr] end -- Parse operand and return { mode, opsize, reg, xreg, xsc, disp, imm }. local function parseoperand(param) local t = {} local expr = param local opsize, tailops = match(param, "^(%w+)%s*(.+)$") if opsize then t.opsize = map_opsize[opsize] if t.opsize then expr = tailops end end local br = match(expr, "^%[%s*(.-)%s*%]$") repeat if br then t.mode = "xm" -- [disp] t.disp = toint(br) if t.disp then t.mode = x64 and "xm" or "xmO" break end -- [reg...] local tp local reg, tailr = match(br, "^([@%w_:]+)%s*(.*)$") reg, t.reg, tp = rtexpr(reg) if not t.reg then -- [expr] t.mode = x64 and "xm" or "xmO" t.disp = dispexpr("+"..br) break end if t.reg == -1 then t.vreg, tailr = match(tailr, "^(%b())(.*)$") if not t.vreg then werror("bad variable register expression") end end -- [xreg*xsc] or [xreg*xsc+-disp] or [xreg*xsc+-expr] local xsc, tailsc = match(tailr, "^%*%s*([1248])%s*(.*)$") if xsc then if not map_reg_valid_index[reg] then werror("bad index register `"..map_reg_rev[reg].."'") end t.xsc = map_xsc[xsc] t.xreg = t.reg t.vxreg = t.vreg t.reg = nil t.vreg = nil t.disp = dispexpr(tailsc) break end if not map_reg_valid_base[reg] then werror("bad base register `"..map_reg_rev[reg].."'") end -- [reg] or [reg+-disp] t.disp = toint(tailr) or (tailr == "" and 0) if t.disp then break end -- [reg+xreg...] local xreg, tailx = match(tailr, "^+%s*([@%w_:]+)%s*(.*)$") xreg, t.xreg, tp = rtexpr(xreg) if not t.xreg then -- [reg+-expr] t.disp = dispexpr(tailr) break end if not map_reg_valid_index[xreg] then werror("bad index register `"..map_reg_rev[xreg].."'") end if t.xreg == -1 then t.vxreg, tailx = match(tailx, "^(%b())(.*)$") if not t.vxreg then werror("bad variable register expression") end end -- [reg+xreg*xsc...] local xsc, tailsc = match(tailx, "^%*%s*([1248])%s*(.*)$") if xsc then t.xsc = map_xsc[xsc] tailx = tailsc end -- [...] or [...+-disp] or [...+-expr] t.disp = dispexpr(tailx) else -- imm or opsize*imm local imm = toint(expr) if not imm and sub(expr, 1, 1) == "*" and t.opsize then imm = toint(sub(expr, 2)) if imm then imm = imm * map_opsizenum[t.opsize] t.opsize = nil end end if imm then if t.opsize then werror("bad operand size override") end local m = "i" if imm == 1 then m = m.."1" end if imm >= 4294967168 and imm <= 4294967295 then imm = imm-4294967296 end if imm >= -128 and imm <= 127 then m = m.."S" end t.imm = imm t.mode = m break end local tp local reg, tailr = match(expr, "^([@%w_:]+)%s*(.*)$") reg, t.reg, tp = rtexpr(reg) if t.reg then if t.reg == -1 then t.vreg, tailr = match(tailr, "^(%b())(.*)$") if not t.vreg then werror("bad variable register expression") end end -- reg if tailr == "" then if t.opsize then werror("bad operand size override") end t.opsize = map_reg_opsize[reg] if t.opsize == "f" then t.mode = t.reg == 0 and "fF" or "f" else if reg == "@w4" or (x64 and reg == "@d4") then wwarn("bad idea, try again with `"..(x64 and "rsp'" or "esp'")) end t.mode = t.reg == 0 and "rmR" or (reg == "@b1" and "rmC" or "rm") end t.needrex = map_reg_needrex[reg] break end -- type[idx], type[idx].field, type->field -> [reg+offset_expr] if not tp then werror("bad operand `"..param.."'") end t.mode = "xm" t.disp = format(tp.ctypefmt, tailr) else t.mode, t.imm = immexpr(expr) if sub(t.mode, -1) == "J" then if t.opsize and t.opsize ~= addrsize then werror("bad operand size override") end t.opsize = addrsize end end end until true return t end ------------------------------------------------------------------------------ -- x86 Template String Description -- =============================== -- -- Each template string is a list of [match:]pattern pairs, -- separated by "|". The first match wins. No match means a -- bad or unsupported combination of operand modes or sizes. -- -- The match part and the ":" is omitted if the operation has -- no operands. Otherwise the first N characters are matched -- against the mode strings of each of the N operands. -- -- The mode string for each operand type is (see parseoperand()): -- Integer register: "rm", +"R" for eax, ax, al, +"C" for cl -- FP register: "f", +"F" for st0 -- Index operand: "xm", +"O" for [disp] (pure offset) -- Immediate: "i", +"S" for signed 8 bit, +"1" for 1, -- +"I" for arg, +"P" for pointer -- Any: +"J" for valid jump targets -- -- So a match character "m" (mixed) matches both an integer register -- and an index operand (to be encoded with the ModRM/SIB scheme). -- But "r" matches only a register and "x" only an index operand -- (e.g. for FP memory access operations). -- -- The operand size match string starts right after the mode match -- characters and ends before the ":". "dwb" or "qdwb" is assumed, if empty. -- The effective data size of the operation is matched against this list. -- -- If only the regular "b", "w", "d", "q", "t" operand sizes are -- present, then all operands must be the same size. Unspecified sizes -- are ignored, but at least one operand must have a size or the pattern -- won't match (use the "byte", "word", "dword", "qword", "tword" -- operand size overrides. E.g.: mov dword [eax], 1). -- -- If the list has a "1" or "2" prefix, the operand size is taken -- from the respective operand and any other operand sizes are ignored. -- If the list contains only ".", all operand sizes are ignored. -- If the list has a "/" prefix, the concatenated (mixed) operand sizes -- are compared to the match. -- -- E.g. "rrdw" matches for either two dword registers or two word -- registers. "Fx2dq" matches an st0 operand plus an index operand -- pointing to a dword (float) or qword (double). -- -- Every character after the ":" is part of the pattern string: -- Hex chars are accumulated to form the opcode (left to right). -- "n" disables the standard opcode mods -- (otherwise: -1 for "b", o16 prefix for "w", rex.w for "q") -- "X" Force REX.W. -- "r"/"R" adds the reg. number from the 1st/2nd operand to the opcode. -- "m"/"M" generates ModRM/SIB from the 1st/2nd operand. -- The spare 3 bits are either filled with the last hex digit or -- the result from a previous "r"/"R". The opcode is restored. -- -- All of the following characters force a flush of the opcode: -- "o"/"O" stores a pure 32 bit disp (offset) from the 1st/2nd operand. -- "S" stores a signed 8 bit immediate from the last operand. -- "U" stores an unsigned 8 bit immediate from the last operand. -- "W" stores an unsigned 16 bit immediate from the last operand. -- "i" stores an operand sized immediate from the last operand. -- "I" dito, but generates an action code to optionally modify -- the opcode (+2) for a signed 8 bit immediate. -- "J" generates one of the REL action codes from the last operand. -- ------------------------------------------------------------------------------ -- Template strings for x86 instructions. Ordered by first opcode byte. -- Unimplemented opcodes (deliberate omissions) are marked with *. local map_op = { -- 00-05: add... -- 06: *push es -- 07: *pop es -- 08-0D: or... -- 0E: *push cs -- 0F: two byte opcode prefix -- 10-15: adc... -- 16: *push ss -- 17: *pop ss -- 18-1D: sbb... -- 1E: *push ds -- 1F: *pop ds -- 20-25: and... es_0 = "26", -- 27: *daa -- 28-2D: sub... cs_0 = "2E", -- 2F: *das -- 30-35: xor... ss_0 = "36", -- 37: *aaa -- 38-3D: cmp... ds_0 = "3E", -- 3F: *aas inc_1 = x64 and "m:FF0m" or "rdw:40r|m:FF0m", dec_1 = x64 and "m:FF1m" or "rdw:48r|m:FF1m", push_1 = (x64 and "rq:n50r|rw:50r|mq:nFF6m|mw:FF6m" or "rdw:50r|mdw:FF6m").."|S.:6AS|ib:n6Ai|i.:68i", pop_1 = x64 and "rq:n58r|rw:58r|mq:n8F0m|mw:8F0m" or "rdw:58r|mdw:8F0m", -- 60: *pusha, *pushad, *pushaw -- 61: *popa, *popad, *popaw -- 62: *bound rdw,x -- 63: x86: *arpl mw,rw movsxd_2 = x64 and "rm/qd:63rM", fs_0 = "64", gs_0 = "65", o16_0 = "66", a16_0 = not x64 and "67" or nil, a32_0 = x64 and "67", -- 68: push idw -- 69: imul rdw,mdw,idw -- 6A: push ib -- 6B: imul rdw,mdw,S -- 6C: *insb -- 6D: *insd, *insw -- 6E: *outsb -- 6F: *outsd, *outsw -- 70-7F: jcc lb -- 80: add... mb,i -- 81: add... mdw,i -- 82: *undefined -- 83: add... mdw,S test_2 = "mr:85Rm|rm:85rM|Ri:A9ri|mi:F70mi", -- 86: xchg rb,mb -- 87: xchg rdw,mdw -- 88: mov mb,r -- 89: mov mdw,r -- 8A: mov r,mb -- 8B: mov r,mdw -- 8C: *mov mdw,seg lea_2 = "rx1dq:8DrM", -- 8E: *mov seg,mdw -- 8F: pop mdw nop_0 = "90", xchg_2 = "Rrqdw:90R|rRqdw:90r|rm:87rM|mr:87Rm", cbw_0 = "6698", cwde_0 = "98", cdqe_0 = "4898", cwd_0 = "6699", cdq_0 = "99", cqo_0 = "4899", -- 9A: *call iw:idw wait_0 = "9B", fwait_0 = "9B", pushf_0 = "9C", pushfd_0 = not x64 and "9C", pushfq_0 = x64 and "9C", popf_0 = "9D", popfd_0 = not x64 and "9D", popfq_0 = x64 and "9D", sahf_0 = "9E", lahf_0 = "9F", mov_2 = "OR:A3o|RO:A1O|mr:89Rm|rm:8BrM|rib:nB0ri|ridw:B8ri|mi:C70mi", movsb_0 = "A4", movsw_0 = "66A5", movsd_0 = "A5", cmpsb_0 = "A6", cmpsw_0 = "66A7", cmpsd_0 = "A7", -- A8: test Rb,i -- A9: test Rdw,i stosb_0 = "AA", stosw_0 = "66AB", stosd_0 = "AB", lodsb_0 = "AC", lodsw_0 = "66AD", lodsd_0 = "AD", scasb_0 = "AE", scasw_0 = "66AF", scasd_0 = "AF", -- B0-B7: mov rb,i -- B8-BF: mov rdw,i -- C0: rol... mb,i -- C1: rol... mdw,i ret_1 = "i.:nC2W", ret_0 = "C3", -- C4: *les rdw,mq -- C5: *lds rdw,mq -- C6: mov mb,i -- C7: mov mdw,i -- C8: *enter iw,ib leave_0 = "C9", -- CA: *retf iw -- CB: *retf int3_0 = "CC", int_1 = "i.:nCDU", into_0 = "CE", -- CF: *iret -- D0: rol... mb,1 -- D1: rol... mdw,1 -- D2: rol... mb,cl -- D3: rol... mb,cl -- D4: *aam ib -- D5: *aad ib -- D6: *salc -- D7: *xlat -- D8-DF: floating point ops -- E0: *loopne -- E1: *loope -- E2: *loop -- E3: *jcxz, *jecxz -- E4: *in Rb,ib -- E5: *in Rdw,ib -- E6: *out ib,Rb -- E7: *out ib,Rdw call_1 = x64 and "mq:nFF2m|J.:E8nJ" or "md:FF2m|J.:E8J", jmp_1 = x64 and "mq:nFF4m|J.:E9nJ" or "md:FF4m|J.:E9J", -- short: EB -- EA: *jmp iw:idw -- EB: jmp ib -- EC: *in Rb,dx -- ED: *in Rdw,dx -- EE: *out dx,Rb -- EF: *out dx,Rdw -- F0: *lock int1_0 = "F1", repne_0 = "F2", repnz_0 = "F2", rep_0 = "F3", repe_0 = "F3", repz_0 = "F3", -- F4: *hlt cmc_0 = "F5", -- F6: test... mb,i; div... mb -- F7: test... mdw,i; div... mdw clc_0 = "F8", stc_0 = "F9", -- FA: *cli cld_0 = "FC", std_0 = "FD", -- FE: inc... mb -- FF: inc... mdw -- misc ops not_1 = "m:F72m", neg_1 = "m:F73m", mul_1 = "m:F74m", imul_1 = "m:F75m", div_1 = "m:F76m", idiv_1 = "m:F77m", imul_2 = "rmqdw:0FAFrM|rIqdw:69rmI|rSqdw:6BrmS|riqdw:69rmi", imul_3 = "rmIqdw:69rMI|rmSqdw:6BrMS|rmiqdw:69rMi", movzx_2 = "rm/db:0FB6rM|rm/qb:|rm/wb:0FB6rM|rm/dw:0FB7rM|rm/qw:", movsx_2 = "rm/db:0FBErM|rm/qb:|rm/wb:0FBErM|rm/dw:0FBFrM|rm/qw:", bswap_1 = "rqd:0FC8r", bsf_2 = "rmqdw:0FBCrM", bsr_2 = "rmqdw:0FBDrM", bt_2 = "mrqdw:0FA3Rm|miqdw:0FBA4mU", btc_2 = "mrqdw:0FBBRm|miqdw:0FBA7mU", btr_2 = "mrqdw:0FB3Rm|miqdw:0FBA6mU", bts_2 = "mrqdw:0FABRm|miqdw:0FBA5mU", rdtsc_0 = "0F31", -- P1+ cpuid_0 = "0FA2", -- P1+ -- floating point ops fst_1 = "ff:DDD0r|xd:D92m|xq:nDD2m", fstp_1 = "ff:DDD8r|xd:D93m|xq:nDD3m|xt:DB7m", fld_1 = "ff:D9C0r|xd:D90m|xq:nDD0m|xt:DB5m", fpop_0 = "DDD8", -- Alias for fstp st0. fist_1 = "xw:nDF2m|xd:DB2m", fistp_1 = "xw:nDF3m|xd:DB3m|xq:nDF7m", fild_1 = "xw:nDF0m|xd:DB0m|xq:nDF5m", fxch_0 = "D9C9", fxch_1 = "ff:D9C8r", fxch_2 = "fFf:D9C8r|Fff:D9C8R", fucom_1 = "ff:DDE0r", fucom_2 = "Fff:DDE0R", fucomp_1 = "ff:DDE8r", fucomp_2 = "Fff:DDE8R", fucomi_1 = "ff:DBE8r", -- P6+ fucomi_2 = "Fff:DBE8R", -- P6+ fucomip_1 = "ff:DFE8r", -- P6+ fucomip_2 = "Fff:DFE8R", -- P6+ fcomi_1 = "ff:DBF0r", -- P6+ fcomi_2 = "Fff:DBF0R", -- P6+ fcomip_1 = "ff:DFF0r", -- P6+ fcomip_2 = "Fff:DFF0R", -- P6+ fucompp_0 = "DAE9", fcompp_0 = "DED9", fldcw_1 = "xw:nD95m", fstcw_1 = "xw:n9BD97m", fnstcw_1 = "xw:nD97m", fstsw_1 = "Rw:n9BDFE0|xw:n9BDD7m", fnstsw_1 = "Rw:nDFE0|xw:nDD7m", fclex_0 = "9BDBE2", fnclex_0 = "DBE2", fnop_0 = "D9D0", -- D9D1-D9DF: unassigned fchs_0 = "D9E0", fabs_0 = "D9E1", -- D9E2: unassigned -- D9E3: unassigned ftst_0 = "D9E4", fxam_0 = "D9E5", -- D9E6: unassigned -- D9E7: unassigned fld1_0 = "D9E8", fldl2t_0 = "D9E9", fldl2e_0 = "D9EA", fldpi_0 = "D9EB", fldlg2_0 = "D9EC", fldln2_0 = "D9ED", fldz_0 = "D9EE", -- D9EF: unassigned f2xm1_0 = "D9F0", fyl2x_0 = "D9F1", fptan_0 = "D9F2", fpatan_0 = "D9F3", fxtract_0 = "D9F4", fprem1_0 = "D9F5", fdecstp_0 = "D9F6", fincstp_0 = "D9F7", fprem_0 = "D9F8", fyl2xp1_0 = "D9F9", fsqrt_0 = "D9FA", fsincos_0 = "D9FB", frndint_0 = "D9FC", fscale_0 = "D9FD", fsin_0 = "D9FE", fcos_0 = "D9FF", -- SSE, SSE2 andnpd_2 = "rmo:660F55rM", andnps_2 = "rmo:0F55rM", andpd_2 = "rmo:660F54rM", andps_2 = "rmo:0F54rM", clflush_1 = "x.:0FAE7m", cmppd_3 = "rmio:660FC2rMU", cmpps_3 = "rmio:0FC2rMU", cmpsd_3 = "rrio:F20FC2rMU|rxi/oq:", cmpss_3 = "rrio:F30FC2rMU|rxi/od:", comisd_2 = "rro:660F2FrM|rx/oq:", comiss_2 = "rro:0F2FrM|rx/od:", cvtdq2pd_2 = "rro:F30FE6rM|rx/oq:", cvtdq2ps_2 = "rmo:0F5BrM", cvtpd2dq_2 = "rmo:F20FE6rM", cvtpd2ps_2 = "rmo:660F5ArM", cvtpi2pd_2 = "rx/oq:660F2ArM", cvtpi2ps_2 = "rx/oq:0F2ArM", cvtps2dq_2 = "rmo:660F5BrM", cvtps2pd_2 = "rro:0F5ArM|rx/oq:", cvtsd2si_2 = "rr/do:F20F2DrM|rr/qo:|rx/dq:|rxq:", cvtsd2ss_2 = "rro:F20F5ArM|rx/oq:", cvtsi2sd_2 = "rm/od:F20F2ArM|rm/oq:F20F2ArXM", cvtsi2ss_2 = "rm/od:F30F2ArM|rm/oq:F30F2ArXM", cvtss2sd_2 = "rro:F30F5ArM|rx/od:", cvtss2si_2 = "rr/do:F20F2CrM|rr/qo:|rxd:|rx/qd:", cvttpd2dq_2 = "rmo:660FE6rM", cvttps2dq_2 = "rmo:F30F5BrM", cvttsd2si_2 = "rr/do:F20F2CrM|rr/qo:|rx/dq:|rxq:", cvttss2si_2 = "rr/do:F30F2CrM|rr/qo:|rxd:|rx/qd:", ldmxcsr_1 = "xd:0FAE2m", lfence_0 = "0FAEE8", maskmovdqu_2 = "rro:660FF7rM", mfence_0 = "0FAEF0", movapd_2 = "rmo:660F28rM|mro:660F29Rm", movaps_2 = "rmo:0F28rM|mro:0F29Rm", movd_2 = "rm/od:660F6ErM|rm/oq:660F6ErXM|mr/do:660F7ERm|mr/qo:", movdqa_2 = "rmo:660F6FrM|mro:660F7FRm", movdqu_2 = "rmo:F30F6FrM|mro:F30F7FRm", movhlps_2 = "rro:0F12rM", movhpd_2 = "rx/oq:660F16rM|xr/qo:n660F17Rm", movhps_2 = "rx/oq:0F16rM|xr/qo:n0F17Rm", movlhps_2 = "rro:0F16rM", movlpd_2 = "rx/oq:660F12rM|xr/qo:n660F13Rm", movlps_2 = "rx/oq:0F12rM|xr/qo:n0F13Rm", movmskpd_2 = "rr/do:660F50rM", movmskps_2 = "rr/do:0F50rM", movntdq_2 = "xro:660FE7Rm", movnti_2 = "xrqd:0FC3Rm", movntpd_2 = "xro:660F2BRm", movntps_2 = "xro:0F2BRm", movq_2 = "rro:F30F7ErM|rx/oq:|xr/qo:n660FD6Rm", movsd_2 = "rro:F20F10rM|rx/oq:|xr/qo:nF20F11Rm", movss_2 = "rro:F30F10rM|rx/od:|xr/do:F30F11Rm", movupd_2 = "rmo:660F10rM|mro:660F11Rm", movups_2 = "rmo:0F10rM|mro:0F11Rm", orpd_2 = "rmo:660F56rM", orps_2 = "rmo:0F56rM", packssdw_2 = "rmo:660F6BrM", packsswb_2 = "rmo:660F63rM", packuswb_2 = "rmo:660F67rM", paddb_2 = "rmo:660FFCrM", paddd_2 = "rmo:660FFErM", paddq_2 = "rmo:660FD4rM", paddsb_2 = "rmo:660FECrM", paddsw_2 = "rmo:660FEDrM", paddusb_2 = "rmo:660FDCrM", paddusw_2 = "rmo:660FDDrM", paddw_2 = "rmo:660FFDrM", pand_2 = "rmo:660FDBrM", pandn_2 = "rmo:660FDFrM", pause_0 = "F390", pavgb_2 = "rmo:660FE0rM", pavgw_2 = "rmo:660FE3rM", pcmpeqb_2 = "rmo:660F74rM", pcmpeqd_2 = "rmo:660F76rM", pcmpeqw_2 = "rmo:660F75rM", pcmpgtb_2 = "rmo:660F64rM", pcmpgtd_2 = "rmo:660F66rM", pcmpgtw_2 = "rmo:660F65rM", pextrw_3 = "rri/do:660FC5rMU|xri/wo:660F3A15nrMU", -- Mem op: SSE4.1 only. pinsrw_3 = "rri/od:660FC4rMU|rxi/ow:", pmaddwd_2 = "rmo:660FF5rM", pmaxsw_2 = "rmo:660FEErM", pmaxub_2 = "rmo:660FDErM", pminsw_2 = "rmo:660FEArM", pminub_2 = "rmo:660FDArM", pmovmskb_2 = "rr/do:660FD7rM", pmulhuw_2 = "rmo:660FE4rM", pmulhw_2 = "rmo:660FE5rM", pmullw_2 = "rmo:660FD5rM", pmuludq_2 = "rmo:660FF4rM", por_2 = "rmo:660FEBrM", prefetchnta_1 = "xb:n0F180m", prefetcht0_1 = "xb:n0F181m", prefetcht1_1 = "xb:n0F182m", prefetcht2_1 = "xb:n0F183m", psadbw_2 = "rmo:660FF6rM", pshufd_3 = "rmio:660F70rMU", pshufhw_3 = "rmio:F30F70rMU", pshuflw_3 = "rmio:F20F70rMU", pslld_2 = "rmo:660FF2rM|rio:660F726mU", pslldq_2 = "rio:660F737mU", psllq_2 = "rmo:660FF3rM|rio:660F736mU", psllw_2 = "rmo:660FF1rM|rio:660F716mU", psrad_2 = "rmo:660FE2rM|rio:660F724mU", psraw_2 = "rmo:660FE1rM|rio:660F714mU", psrld_2 = "rmo:660FD2rM|rio:660F722mU", psrldq_2 = "rio:660F733mU", psrlq_2 = "rmo:660FD3rM|rio:660F732mU", psrlw_2 = "rmo:660FD1rM|rio:660F712mU", psubb_2 = "rmo:660FF8rM", psubd_2 = "rmo:660FFArM", psubq_2 = "rmo:660FFBrM", psubsb_2 = "rmo:660FE8rM", psubsw_2 = "rmo:660FE9rM", psubusb_2 = "rmo:660FD8rM", psubusw_2 = "rmo:660FD9rM", psubw_2 = "rmo:660FF9rM", punpckhbw_2 = "rmo:660F68rM", punpckhdq_2 = "rmo:660F6ArM", punpckhqdq_2 = "rmo:660F6DrM", punpckhwd_2 = "rmo:660F69rM", punpcklbw_2 = "rmo:660F60rM", punpckldq_2 = "rmo:660F62rM", punpcklqdq_2 = "rmo:660F6CrM", punpcklwd_2 = "rmo:660F61rM", pxor_2 = "rmo:660FEFrM", rcpps_2 = "rmo:0F53rM", rcpss_2 = "rro:F30F53rM|rx/od:", rsqrtps_2 = "rmo:0F52rM", rsqrtss_2 = "rmo:F30F52rM", sfence_0 = "0FAEF8", shufpd_3 = "rmio:660FC6rMU", shufps_3 = "rmio:0FC6rMU", stmxcsr_1 = "xd:0FAE3m", ucomisd_2 = "rro:660F2ErM|rx/oq:", ucomiss_2 = "rro:0F2ErM|rx/od:", unpckhpd_2 = "rmo:660F15rM", unpckhps_2 = "rmo:0F15rM", unpcklpd_2 = "rmo:660F14rM", unpcklps_2 = "rmo:0F14rM", xorpd_2 = "rmo:660F57rM", xorps_2 = "rmo:0F57rM", -- SSE3 ops fisttp_1 = "xw:nDF1m|xd:DB1m|xq:nDD1m", addsubpd_2 = "rmo:660FD0rM", addsubps_2 = "rmo:F20FD0rM", haddpd_2 = "rmo:660F7CrM", haddps_2 = "rmo:F20F7CrM", hsubpd_2 = "rmo:660F7DrM", hsubps_2 = "rmo:F20F7DrM", lddqu_2 = "rxo:F20FF0rM", movddup_2 = "rmo:F20F12rM", movshdup_2 = "rmo:F30F16rM", movsldup_2 = "rmo:F30F12rM", -- SSSE3 ops pabsb_2 = "rmo:660F381CrM", pabsd_2 = "rmo:660F381ErM", pabsw_2 = "rmo:660F381DrM", palignr_3 = "rmio:660F3A0FrMU", phaddd_2 = "rmo:660F3802rM", phaddsw_2 = "rmo:660F3803rM", phaddw_2 = "rmo:660F3801rM", phsubd_2 = "rmo:660F3806rM", phsubsw_2 = "rmo:660F3807rM", phsubw_2 = "rmo:660F3805rM", pmaddubsw_2 = "rmo:660F3804rM", pmulhrsw_2 = "rmo:660F380BrM", pshufb_2 = "rmo:660F3800rM", psignb_2 = "rmo:660F3808rM", psignd_2 = "rmo:660F380ArM", psignw_2 = "rmo:660F3809rM", -- SSE4.1 ops blendpd_3 = "rmio:660F3A0DrMU", blendps_3 = "rmio:660F3A0CrMU", blendvpd_3 = "rmRo:660F3815rM", blendvps_3 = "rmRo:660F3814rM", dppd_3 = "rmio:660F3A41rMU", dpps_3 = "rmio:660F3A40rMU", extractps_3 = "mri/do:660F3A17RmU|rri/qo:660F3A17RXmU", insertps_3 = "rrio:660F3A41rMU|rxi/od:", movntdqa_2 = "rmo:660F382ArM", mpsadbw_3 = "rmio:660F3A42rMU", packusdw_2 = "rmo:660F382BrM", pblendvb_3 = "rmRo:660F3810rM", pblendw_3 = "rmio:660F3A0ErMU", pcmpeqq_2 = "rmo:660F3829rM", pextrb_3 = "rri/do:660F3A14nRmU|rri/qo:|xri/bo:", pextrd_3 = "mri/do:660F3A16RmU", pextrq_3 = "mri/qo:660F3A16RmU", -- pextrw is SSE2, mem operand is SSE4.1 only phminposuw_2 = "rmo:660F3841rM", pinsrb_3 = "rri/od:660F3A20nrMU|rxi/ob:", pinsrd_3 = "rmi/od:660F3A22rMU", pinsrq_3 = "rmi/oq:660F3A22rXMU", pmaxsb_2 = "rmo:660F383CrM", pmaxsd_2 = "rmo:660F383DrM", pmaxud_2 = "rmo:660F383FrM", pmaxuw_2 = "rmo:660F383ErM", pminsb_2 = "rmo:660F3838rM", pminsd_2 = "rmo:660F3839rM", pminud_2 = "rmo:660F383BrM", pminuw_2 = "rmo:660F383ArM", pmovsxbd_2 = "rro:660F3821rM|rx/od:", pmovsxbq_2 = "rro:660F3822rM|rx/ow:", pmovsxbw_2 = "rro:660F3820rM|rx/oq:", pmovsxdq_2 = "rro:660F3825rM|rx/oq:", pmovsxwd_2 = "rro:660F3823rM|rx/oq:", pmovsxwq_2 = "rro:660F3824rM|rx/od:", pmovzxbd_2 = "rro:660F3831rM|rx/od:", pmovzxbq_2 = "rro:660F3832rM|rx/ow:", pmovzxbw_2 = "rro:660F3830rM|rx/oq:", pmovzxdq_2 = "rro:660F3835rM|rx/oq:", pmovzxwd_2 = "rro:660F3833rM|rx/oq:", pmovzxwq_2 = "rro:660F3834rM|rx/od:", pmuldq_2 = "rmo:660F3828rM", pmulld_2 = "rmo:660F3840rM", ptest_2 = "rmo:660F3817rM", roundpd_3 = "rmio:660F3A09rMU", roundps_3 = "rmio:660F3A08rMU", roundsd_3 = "rrio:660F3A0BrMU|rxi/oq:", roundss_3 = "rrio:660F3A0ArMU|rxi/od:", -- SSE4.2 ops crc32_2 = "rmqd:F20F38F1rM|rm/dw:66F20F38F1rM|rm/db:F20F38F0rM|rm/qb:", pcmpestri_3 = "rmio:660F3A61rMU", pcmpestrm_3 = "rmio:660F3A60rMU", pcmpgtq_2 = "rmo:660F3837rM", pcmpistri_3 = "rmio:660F3A63rMU", pcmpistrm_3 = "rmio:660F3A62rMU", popcnt_2 = "rmqdw:F30FB8rM", -- SSE4a extrq_2 = "rro:660F79rM", extrq_3 = "riio:660F780mUU", insertq_2 = "rro:F20F79rM", insertq_4 = "rriio:F20F78rMUU", lzcnt_2 = "rmqdw:F30FBDrM", movntsd_2 = "xr/qo:nF20F2BRm", movntss_2 = "xr/do:F30F2BRm", -- popcnt is also in SSE4.2 } ------------------------------------------------------------------------------ -- Arithmetic ops. for name,n in pairs{ add = 0, ["or"] = 1, adc = 2, sbb = 3, ["and"] = 4, sub = 5, xor = 6, cmp = 7 } do local n8 = shl(n, 3) map_op[name.."_2"] = format( "mr:%02XRm|rm:%02XrM|mI1qdw:81%XmI|mS1qdw:83%XmS|Ri1qdwb:%02Xri|mi1qdwb:81%Xmi", 1+n8, 3+n8, n, n, 5+n8, n) end -- Shift ops. for name,n in pairs{ rol = 0, ror = 1, rcl = 2, rcr = 3, shl = 4, shr = 5, sar = 7, sal = 4 } do map_op[name.."_2"] = format("m1:D1%Xm|mC1qdwb:D3%Xm|mi:C1%XmU", n, n, n) end -- Conditional ops. for cc,n in pairs(map_cc) do map_op["j"..cc.."_1"] = format("J.:n0F8%XJ", n) -- short: 7%X map_op["set"..cc.."_1"] = format("mb:n0F9%X2m", n) map_op["cmov"..cc.."_2"] = format("rmqdw:0F4%XrM", n) -- P6+ end -- FP arithmetic ops. for name,n in pairs{ add = 0, mul = 1, com = 2, comp = 3, sub = 4, subr = 5, div = 6, divr = 7 } do local nc = 0xc0 + shl(n, 3) local nr = nc + (n < 4 and 0 or (n % 2 == 0 and 8 or -8)) local fn = "f"..name map_op[fn.."_1"] = format("ff:D8%02Xr|xd:D8%Xm|xq:nDC%Xm", nc, n, n) if n == 2 or n == 3 then map_op[fn.."_2"] = format("Fff:D8%02XR|Fx2d:D8%XM|Fx2q:nDC%XM", nc, n, n) else map_op[fn.."_2"] = format("Fff:D8%02XR|fFf:DC%02Xr|Fx2d:D8%XM|Fx2q:nDC%XM", nc, nr, n, n) map_op[fn.."p_1"] = format("ff:DE%02Xr", nr) map_op[fn.."p_2"] = format("fFf:DE%02Xr", nr) end map_op["fi"..name.."_1"] = format("xd:DA%Xm|xw:nDE%Xm", n, n) end -- FP conditional moves. for cc,n in pairs{ b=0, e=1, be=2, u=3, nb=4, ne=5, nbe=6, nu=7 } do local nc = 0xdac0 + shl(band(n, 3), 3) + shl(band(n, 4), 6) map_op["fcmov"..cc.."_1"] = format("ff:%04Xr", nc) -- P6+ map_op["fcmov"..cc.."_2"] = format("Fff:%04XR", nc) -- P6+ end -- SSE FP arithmetic ops. for name,n in pairs{ sqrt = 1, add = 8, mul = 9, sub = 12, min = 13, div = 14, max = 15 } do map_op[name.."ps_2"] = format("rmo:0F5%XrM", n) map_op[name.."ss_2"] = format("rro:F30F5%XrM|rx/od:", n) map_op[name.."pd_2"] = format("rmo:660F5%XrM", n) map_op[name.."sd_2"] = format("rro:F20F5%XrM|rx/oq:", n) end ------------------------------------------------------------------------------ -- Process pattern string. local function dopattern(pat, args, sz, op, needrex) local digit, addin local opcode = 0 local szov = sz local narg = 1 local rex = 0 -- Limit number of section buffer positions used by a single dasm_put(). -- A single opcode needs a maximum of 5 positions. if secpos+5 > maxsecpos then wflush() end -- Process each character. for c in gmatch(pat.."|", ".") do if match(c, "%x") then -- Hex digit. digit = byte(c) - 48 if digit > 48 then digit = digit - 39 elseif digit > 16 then digit = digit - 7 end opcode = opcode*16 + digit addin = nil elseif c == "n" then -- Disable operand size mods for opcode. szov = nil elseif c == "X" then -- Force REX.W. rex = 8 elseif c == "r" then -- Merge 1st operand regno. into opcode. addin = args[1]; opcode = opcode + (addin.reg % 8) if narg < 2 then narg = 2 end elseif c == "R" then -- Merge 2nd operand regno. into opcode. addin = args[2]; opcode = opcode + (addin.reg % 8) narg = 3 elseif c == "m" or c == "M" then -- Encode ModRM/SIB. local s if addin then s = addin.reg opcode = opcode - band(s, 7) -- Undo regno opcode merge. else s = band(opcode, 15) -- Undo last digit. opcode = shr(opcode, 4) end local nn = c == "m" and 1 or 2 local t = args[nn] if narg <= nn then narg = nn + 1 end if szov == "q" and rex == 0 then rex = rex + 8 end if t.reg and t.reg > 7 then rex = rex + 1 end if t.xreg and t.xreg > 7 then rex = rex + 2 end if s > 7 then rex = rex + 4 end if needrex then rex = rex + 16 end wputop(szov, opcode, rex); opcode = nil local imark = sub(pat, -1) -- Force a mark (ugly). -- Put ModRM/SIB with regno/last digit as spare. wputmrmsib(t, imark, s, addin and addin.vreg) addin = nil else if opcode then -- Flush opcode. if szov == "q" and rex == 0 then rex = rex + 8 end if needrex then rex = rex + 16 end if addin and addin.reg == -1 then wputop(szov, opcode - 7, rex) waction("VREG", addin.vreg); wputxb(0) else if addin and addin.reg > 7 then rex = rex + 1 end wputop(szov, opcode, rex) end opcode = nil end if c == "|" then break end if c == "o" then -- Offset (pure 32 bit displacement). wputdarg(args[1].disp); if narg < 2 then narg = 2 end elseif c == "O" then wputdarg(args[2].disp); narg = 3 else -- Anything else is an immediate operand. local a = args[narg] narg = narg + 1 local mode, imm = a.mode, a.imm if mode == "iJ" and not match("iIJ", c) then werror("bad operand size for label") end if c == "S" then wputsbarg(imm) elseif c == "U" then wputbarg(imm) elseif c == "W" then wputwarg(imm) elseif c == "i" or c == "I" then if mode == "iJ" then wputlabel("IMM_", imm, 1) elseif mode == "iI" and c == "I" then waction(sz == "w" and "IMM_WB" or "IMM_DB", imm) else wputszarg(sz, imm) end elseif c == "J" then if mode == "iPJ" then waction("REL_A", imm) -- !x64 (secpos) else wputlabel("REL_", imm, 2) end else werror("bad char `"..c.."' in pattern `"..pat.."' for `"..op.."'") end end end end end ------------------------------------------------------------------------------ -- Mapping of operand modes to short names. Suppress output with '#'. local map_modename = { r = "reg", R = "eax", C = "cl", x = "mem", m = "mrm", i = "imm", f = "stx", F = "st0", J = "lbl", ["1"] = "1", I = "#", S = "#", O = "#", } -- Return a table/string showing all possible operand modes. local function templatehelp(template, nparams) if nparams == 0 then return "" end local t = {} for tm in gmatch(template, "[^%|]+") do local s = map_modename[sub(tm, 1, 1)] s = s..gsub(sub(tm, 2, nparams), ".", function(c) return ", "..map_modename[c] end) if not match(s, "#") then t[#t+1] = s end end return t end -- Match operand modes against mode match part of template. local function matchtm(tm, args) for i=1,#args do if not match(args[i].mode, sub(tm, i, i)) then return end end return true end -- Handle opcodes defined with template strings. map_op[".template__"] = function(params, template, nparams) if not params then return templatehelp(template, nparams) end local args = {} -- Zero-operand opcodes have no match part. if #params == 0 then dopattern(template, args, "d", params.op, nil) return end -- Determine common operand size (coerce undefined size) or flag as mixed. local sz, szmix, needrex for i,p in ipairs(params) do args[i] = parseoperand(p) local nsz = args[i].opsize if nsz then if sz and sz ~= nsz then szmix = true else sz = nsz end end local nrex = args[i].needrex if nrex ~= nil then if needrex == nil then needrex = nrex elseif needrex ~= nrex then werror("bad mix of byte-addressable registers") end end end -- Try all match:pattern pairs (separated by '|'). local gotmatch, lastpat for tm in gmatch(template, "[^%|]+") do -- Split off size match (starts after mode match) and pattern string. local szm, pat = match(tm, "^(.-):(.*)$", #args+1) if pat == "" then pat = lastpat else lastpat = pat end if matchtm(tm, args) then local prefix = sub(szm, 1, 1) if prefix == "/" then -- Match both operand sizes. if args[1].opsize == sub(szm, 2, 2) and args[2].opsize == sub(szm, 3, 3) then dopattern(pat, args, sz, params.op, needrex) -- Process pattern. return end else -- Match common operand size. local szp = sz if szm == "" then szm = x64 and "qdwb" or "dwb" end -- Default sizes. if prefix == "1" then szp = args[1].opsize; szmix = nil elseif prefix == "2" then szp = args[2].opsize; szmix = nil end if not szmix and (prefix == "." or match(szm, szp or "#")) then dopattern(pat, args, szp, params.op, needrex) -- Process pattern. return end end gotmatch = true end end local msg = "bad operand mode" if gotmatch then if szmix then msg = "mixed operand size" else msg = sz and "bad operand size" or "missing operand size" end end werror(msg.." in `"..opmodestr(params.op, args).."'") end ------------------------------------------------------------------------------ -- x64-specific opcode for 64 bit immediates and displacements. if x64 then function map_op.mov64_2(params) if not params then return { "reg, imm", "reg, [disp]", "[disp], reg" } end if secpos+2 > maxsecpos then wflush() end local opcode, op64, sz, rex local op64 = match(params[1], "^%[%s*(.-)%s*%]$") if op64 then local a = parseoperand(params[2]) if a.mode ~= "rmR" then werror("bad operand mode") end sz = a.opsize rex = sz == "q" and 8 or 0 opcode = 0xa3 else op64 = match(params[2], "^%[%s*(.-)%s*%]$") local a = parseoperand(params[1]) if op64 then if a.mode ~= "rmR" then werror("bad operand mode") end sz = a.opsize rex = sz == "q" and 8 or 0 opcode = 0xa1 else if sub(a.mode, 1, 1) ~= "r" or a.opsize ~= "q" then werror("bad operand mode") end op64 = params[2] opcode = 0xb8 + band(a.reg, 7) -- !x64: no VREG support. rex = a.reg > 7 and 9 or 8 end end wputop(sz, opcode, rex) waction("IMM_D", format("(unsigned int)(%s)", op64)) waction("IMM_D", format("(unsigned int)((%s)>>32)", op64)) end end ------------------------------------------------------------------------------ -- Pseudo-opcodes for data storage. local function op_data(params) if not params then return "imm..." end local sz = sub(params.op, 2, 2) if sz == "a" then sz = addrsize end for _,p in ipairs(params) do local a = parseoperand(p) if sub(a.mode, 1, 1) ~= "i" or (a.opsize and a.opsize ~= sz) then werror("bad mode or size in `"..p.."'") end if a.mode == "iJ" then wputlabel("IMM_", a.imm, 1) else wputszarg(sz, a.imm) end if secpos+2 > maxsecpos then wflush() end end end map_op[".byte_*"] = op_data map_op[".sbyte_*"] = op_data map_op[".word_*"] = op_data map_op[".dword_*"] = op_data map_op[".aword_*"] = op_data ------------------------------------------------------------------------------ -- Pseudo-opcode to mark the position where the action list is to be emitted. map_op[".actionlist_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeactions(out, name) end) end -- Pseudo-opcode to mark the position where the global enum is to be emitted. map_op[".globals_1"] = function(params) if not params then return "prefix" end local prefix = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeglobals(out, prefix) end) end -- Pseudo-opcode to mark the position where the global names are to be emitted. map_op[".globalnames_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeglobalnames(out, name) end) end -- Pseudo-opcode to mark the position where the extern names are to be emitted. map_op[".externnames_1"] = function(params) if not params then return "cvar" end local name = params[1] -- No syntax check. You get to keep the pieces. wline(function(out) writeexternnames(out, name) end) end ------------------------------------------------------------------------------ -- Label pseudo-opcode (converted from trailing colon form). map_op[".label_2"] = function(params) if not params then return "[1-9] | ->global | =>pcexpr [, addr]" end if secpos+2 > maxsecpos then wflush() end local a = parseoperand(params[1]) local mode, imm = a.mode, a.imm if type(imm) == "number" and (mode == "iJ" or (imm >= 1 and imm <= 9)) then -- Local label (1: ... 9:) or global label (->global:). waction("LABEL_LG", nil, 1) wputxb(imm) elseif mode == "iJ" then -- PC label (=>pcexpr:). waction("LABEL_PC", imm) else werror("bad label definition") end -- SETLABEL must immediately follow LABEL_LG/LABEL_PC. local addr = params[2] if addr then local a = parseoperand(addr) if a.mode == "iPJ" then waction("SETLABEL", a.imm) else werror("bad label assignment") end end end map_op[".label_1"] = map_op[".label_2"] ------------------------------------------------------------------------------ -- Alignment pseudo-opcode. map_op[".align_1"] = function(params) if not params then return "numpow2" end if secpos+1 > maxsecpos then wflush() end local align = tonumber(params[1]) or map_opsizenum[map_opsize[params[1]]] if align then local x = align -- Must be a power of 2 in the range (2 ... 256). for i=1,8 do x = x / 2 if x == 1 then waction("ALIGN", nil, 1) wputxb(align-1) -- Action byte is 2**n-1. return end end end werror("bad alignment") end -- Spacing pseudo-opcode. map_op[".space_2"] = function(params) if not params then return "num [, filler]" end if secpos+1 > maxsecpos then wflush() end waction("SPACE", params[1]) local fill = params[2] if fill then fill = tonumber(fill) if not fill or fill < 0 or fill > 255 then werror("bad filler") end end wputxb(fill or 0) end map_op[".space_1"] = map_op[".space_2"] ------------------------------------------------------------------------------ -- Pseudo-opcode for (primitive) type definitions (map to C types). map_op[".type_3"] = function(params, nparams) if not params then return nparams == 2 and "name, ctype" or "name, ctype, reg" end local name, ctype, reg = params[1], params[2], params[3] if not match(name, "^[%a_][%w_]*$") then werror("bad type name `"..name.."'") end local tp = map_type[name] if tp then werror("duplicate type `"..name.."'") end if reg and not map_reg_valid_base[reg] then werror("bad base register `"..(map_reg_rev[reg] or reg).."'") end -- Add #type to defines. A bit unclean to put it in map_archdef. map_archdef["#"..name] = "sizeof("..ctype..")" -- Add new type and emit shortcut define. local num = ctypenum + 1 map_type[name] = { ctype = ctype, ctypefmt = format("Dt%X(%%s)", num), reg = reg, } wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype)) ctypenum = num end map_op[".type_2"] = map_op[".type_3"] -- Dump type definitions. local function dumptypes(out, lvl) local t = {} for name in pairs(map_type) do t[#t+1] = name end sort(t) out:write("Type definitions:\n") for _,name in ipairs(t) do local tp = map_type[name] local reg = tp.reg and map_reg_rev[tp.reg] or "" out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg)) end out:write("\n") end ------------------------------------------------------------------------------ -- Set the current section. function _M.section(num) waction("SECTION") wputxb(num) wflush(true) -- SECTION is a terminal action. end ------------------------------------------------------------------------------ -- Dump architecture description. function _M.dumparch(out) out:write(format("DynASM %s version %s, released %s\n\n", _info.arch, _info.version, _info.release)) dumpregs(out) dumpactions(out) end -- Dump all user defined elements. function _M.dumpdef(out, lvl) dumptypes(out, lvl) dumpglobals(out, lvl) dumpexterns(out, lvl) end ------------------------------------------------------------------------------ -- Pass callbacks from/to the DynASM core. function _M.passcb(wl, we, wf, ww) wline, werror, wfatal, wwarn = wl, we, wf, ww return wflush end -- Setup the arch-specific module. function _M.setup(arch, opt) g_arch, g_opt = arch, opt end -- Merge the core maps and the arch-specific maps. function _M.mergemaps(map_coreop, map_def) setmetatable(map_op, { __index = map_coreop }) setmetatable(map_def, { __index = map_archdef }) return map_op, map_def end return _M ------------------------------------------------------------------------------ ================================================ FILE: cocos2d/external/lua/luajit/src/dynasm/dynasm.lua ================================================ ------------------------------------------------------------------------------ -- DynASM. A dynamic assembler for code generation engines. -- Originally designed and implemented for LuaJIT. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- See below for full copyright notice. ------------------------------------------------------------------------------ -- Application information. local _info = { name = "DynASM", description = "A dynamic assembler for code generation engines", version = "1.3.0", vernum = 10300, release = "2011-05-05", author = "Mike Pall", url = "http://luajit.org/dynasm.html", license = "MIT", copyright = [[ Copyright (C) 2005-2013 Mike Pall. All rights reserved. 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. [ MIT license: http://www.opensource.org/licenses/mit-license.php ] ]], } -- Cache library functions. local type, pairs, ipairs = type, pairs, ipairs local pcall, error, assert = pcall, error, assert local _s = string local sub, match, gmatch, gsub = _s.sub, _s.match, _s.gmatch, _s.gsub local format, rep, upper = _s.format, _s.rep, _s.upper local _t = table local insert, remove, concat, sort = _t.insert, _t.remove, _t.concat, _t.sort local exit = os.exit local io = io local stdin, stdout, stderr = io.stdin, io.stdout, io.stderr ------------------------------------------------------------------------------ -- Program options. local g_opt = {} -- Global state for current file. local g_fname, g_curline, g_indent, g_lineno, g_synclineno, g_arch local g_errcount = 0 -- Write buffer for output file. local g_wbuffer, g_capbuffer ------------------------------------------------------------------------------ -- Write an output line (or callback function) to the buffer. local function wline(line, needindent) local buf = g_capbuffer or g_wbuffer buf[#buf+1] = needindent and g_indent..line or line g_synclineno = g_synclineno + 1 end -- Write assembler line as a comment, if requestd. local function wcomment(aline) if g_opt.comment then wline(g_opt.comment..aline..g_opt.endcomment, true) end end -- Resync CPP line numbers. local function wsync() if g_synclineno ~= g_lineno and g_opt.cpp then wline("# "..g_lineno..' "'..g_fname..'"') g_synclineno = g_lineno end end -- Dummy action flush function. Replaced with arch-specific function later. local function wflush(term) end -- Dump all buffered output lines. local function wdumplines(out, buf) for _,line in ipairs(buf) do if type(line) == "string" then assert(out:write(line, "\n")) else -- Special callback to dynamically insert lines after end of processing. line(out) end end end ------------------------------------------------------------------------------ -- Emit an error. Processing continues with next statement. local function werror(msg) error(format("%s:%s: error: %s:\n%s", g_fname, g_lineno, msg, g_curline), 0) end -- Emit a fatal error. Processing stops. local function wfatal(msg) g_errcount = "fatal" werror(msg) end -- Print a warning. Processing continues. local function wwarn(msg) stderr:write(format("%s:%s: warning: %s:\n%s\n", g_fname, g_lineno, msg, g_curline)) end -- Print caught error message. But suppress excessive errors. local function wprinterr(...) if type(g_errcount) == "number" then -- Regular error. g_errcount = g_errcount + 1 if g_errcount < 21 then -- Seems to be a reasonable limit. stderr:write(...) elseif g_errcount == 21 then stderr:write(g_fname, ":*: warning: too many errors (suppressed further messages).\n") end else -- Fatal error. stderr:write(...) return true -- Stop processing. end end ------------------------------------------------------------------------------ -- Map holding all option handlers. local opt_map = {} local opt_current -- Print error and exit with error status. local function opterror(...) stderr:write("dynasm.lua: ERROR: ", ...) stderr:write("\n") exit(1) end -- Get option parameter. local function optparam(args) local argn = args.argn local p = args[argn] if not p then opterror("missing parameter for option `", opt_current, "'.") end args.argn = argn + 1 return p end ------------------------------------------------------------------------------ -- Core pseudo-opcodes. local map_coreop = {} -- Dummy opcode map. Replaced by arch-specific map. local map_op = {} -- Forward declarations. local dostmt local readfile ------------------------------------------------------------------------------ -- Map for defines (initially empty, chains to arch-specific map). local map_def = {} -- Pseudo-opcode to define a substitution. map_coreop[".define_2"] = function(params, nparams) if not params then return nparams == 1 and "name" or "name, subst" end local name, def = params[1], params[2] or "1" if not match(name, "^[%a_][%w_]*$") then werror("bad or duplicate define") end map_def[name] = def end map_coreop[".define_1"] = map_coreop[".define_2"] -- Define a substitution on the command line. function opt_map.D(args) local namesubst = optparam(args) local name, subst = match(namesubst, "^([%a_][%w_]*)=(.*)$") if name then map_def[name] = subst elseif match(namesubst, "^[%a_][%w_]*$") then map_def[namesubst] = "1" else opterror("bad define") end end -- Undefine a substitution on the command line. function opt_map.U(args) local name = optparam(args) if match(name, "^[%a_][%w_]*$") then map_def[name] = nil else opterror("bad define") end end -- Helper for definesubst. local gotsubst local function definesubst_one(word) local subst = map_def[word] if subst then gotsubst = word; return subst else return word end end -- Iteratively substitute defines. local function definesubst(stmt) -- Limit number of iterations. for i=1,100 do gotsubst = false stmt = gsub(stmt, "#?[%w_]+", definesubst_one) if not gotsubst then break end end if gotsubst then wfatal("recursive define involving `"..gotsubst.."'") end return stmt end -- Dump all defines. local function dumpdefines(out, lvl) local t = {} for name in pairs(map_def) do t[#t+1] = name end sort(t) out:write("Defines:\n") for _,name in ipairs(t) do local subst = map_def[name] if g_arch then subst = g_arch.revdef(subst) end out:write(format(" %-20s %s\n", name, subst)) end out:write("\n") end ------------------------------------------------------------------------------ -- Support variables for conditional assembly. local condlevel = 0 local condstack = {} -- Evaluate condition with a Lua expression. Substitutions already performed. local function cond_eval(cond) local func, err if setfenv then func, err = loadstring("return "..cond, "=expr") else -- No globals. All unknown identifiers evaluate to nil. func, err = load("return "..cond, "=expr", "t", {}) end if func then if setfenv then setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil. end local ok, res = pcall(func) if ok then if res == 0 then return false end -- Oh well. return not not res end err = res end wfatal("bad condition: "..err) end -- Skip statements until next conditional pseudo-opcode at the same level. local function stmtskip() local dostmt_save = dostmt local lvl = 0 dostmt = function(stmt) local op = match(stmt, "^%s*(%S+)") if op == ".if" then lvl = lvl + 1 elseif lvl ~= 0 then if op == ".endif" then lvl = lvl - 1 end elseif op == ".elif" or op == ".else" or op == ".endif" then dostmt = dostmt_save dostmt(stmt) end end end -- Pseudo-opcodes for conditional assembly. map_coreop[".if_1"] = function(params) if not params then return "condition" end local lvl = condlevel + 1 local res = cond_eval(params[1]) condlevel = lvl condstack[lvl] = res if not res then stmtskip() end end map_coreop[".elif_1"] = function(params) if not params then return "condition" end if condlevel == 0 then wfatal(".elif without .if") end local lvl = condlevel local res = condstack[lvl] if res then if res == "else" then wfatal(".elif after .else") end else res = cond_eval(params[1]) if res then condstack[lvl] = res return end end stmtskip() end map_coreop[".else_0"] = function(params) if condlevel == 0 then wfatal(".else without .if") end local lvl = condlevel local res = condstack[lvl] condstack[lvl] = "else" if res then if res == "else" then wfatal(".else after .else") end stmtskip() end end map_coreop[".endif_0"] = function(params) local lvl = condlevel if lvl == 0 then wfatal(".endif without .if") end condlevel = lvl - 1 end -- Check for unfinished conditionals. local function checkconds() if g_errcount ~= "fatal" and condlevel ~= 0 then wprinterr(g_fname, ":*: error: unbalanced conditional\n") end end ------------------------------------------------------------------------------ -- Search for a file in the given path and open it for reading. local function pathopen(path, name) local dirsep = package and match(package.path, "\\") and "\\" or "/" for _,p in ipairs(path) do local fullname = p == "" and name or p..dirsep..name local fin = io.open(fullname, "r") if fin then g_fname = fullname return fin end end end -- Include a file. map_coreop[".include_1"] = function(params) if not params then return "filename" end local name = params[1] -- Save state. Ugly, I know. but upvalues are fast. local gf, gl, gcl, gi = g_fname, g_lineno, g_curline, g_indent -- Read the included file. local fatal = readfile(pathopen(g_opt.include, name) or wfatal("include file `"..name.."' not found")) -- Restore state. g_synclineno = -1 g_fname, g_lineno, g_curline, g_indent = gf, gl, gcl, gi if fatal then wfatal("in include file") end end -- Make .include and conditionals initially available, too. map_op[".include_1"] = map_coreop[".include_1"] map_op[".if_1"] = map_coreop[".if_1"] map_op[".elif_1"] = map_coreop[".elif_1"] map_op[".else_0"] = map_coreop[".else_0"] map_op[".endif_0"] = map_coreop[".endif_0"] ------------------------------------------------------------------------------ -- Support variables for macros. local mac_capture, mac_lineno, mac_name local mac_active = {} local mac_list = {} -- Pseudo-opcode to define a macro. map_coreop[".macro_*"] = function(mparams) if not mparams then return "name [, params...]" end -- Split off and validate macro name. local name = remove(mparams, 1) if not name then werror("missing macro name") end if not (match(name, "^[%a_][%w_%.]*$") or match(name, "^%.[%w_%.]*$")) then wfatal("bad macro name `"..name.."'") end -- Validate macro parameter names. local mdup = {} for _,mp in ipairs(mparams) do if not match(mp, "^[%a_][%w_]*$") then wfatal("bad macro parameter name `"..mp.."'") end if mdup[mp] then wfatal("duplicate macro parameter name `"..mp.."'") end mdup[mp] = true end -- Check for duplicate or recursive macro definitions. local opname = name.."_"..#mparams if map_op[opname] or map_op[name.."_*"] then wfatal("duplicate macro `"..name.."' ("..#mparams.." parameters)") end if mac_capture then wfatal("recursive macro definition") end -- Enable statement capture. local lines = {} mac_lineno = g_lineno mac_name = name mac_capture = function(stmt) -- Statement capture function. -- Stop macro definition with .endmacro pseudo-opcode. if not match(stmt, "^%s*.endmacro%s*$") then lines[#lines+1] = stmt return end mac_capture = nil mac_lineno = nil mac_name = nil mac_list[#mac_list+1] = opname -- Add macro-op definition. map_op[opname] = function(params) if not params then return mparams, lines end -- Protect against recursive macro invocation. if mac_active[opname] then wfatal("recursive macro invocation") end mac_active[opname] = true -- Setup substitution map. local subst = {} for i,mp in ipairs(mparams) do subst[mp] = params[i] end local mcom if g_opt.maccomment and g_opt.comment then mcom = " MACRO "..name.." ("..#mparams..")" wcomment("{"..mcom) end -- Loop through all captured statements for _,stmt in ipairs(lines) do -- Substitute macro parameters. local st = gsub(stmt, "[%w_]+", subst) st = definesubst(st) st = gsub(st, "%s*%.%.%s*", "") -- Token paste a..b. if mcom and sub(st, 1, 1) ~= "|" then wcomment(st) end -- Emit statement. Use a protected call for better diagnostics. local ok, err = pcall(dostmt, st) if not ok then -- Add the captured statement to the error. wprinterr(err, "\n", g_indent, "| ", stmt, "\t[MACRO ", name, " (", #mparams, ")]\n") end end if mcom then wcomment("}"..mcom) end mac_active[opname] = nil end end end -- An .endmacro pseudo-opcode outside of a macro definition is an error. map_coreop[".endmacro_0"] = function(params) wfatal(".endmacro without .macro") end -- Dump all macros and their contents (with -PP only). local function dumpmacros(out, lvl) sort(mac_list) out:write("Macros:\n") for _,opname in ipairs(mac_list) do local name = sub(opname, 1, -3) local params, lines = map_op[opname]() out:write(format(" %-20s %s\n", name, concat(params, ", "))) if lvl > 1 then for _,line in ipairs(lines) do out:write(" |", line, "\n") end out:write("\n") end end out:write("\n") end -- Check for unfinished macro definitions. local function checkmacros() if mac_capture then wprinterr(g_fname, ":", mac_lineno, ": error: unfinished .macro `", mac_name ,"'\n") end end ------------------------------------------------------------------------------ -- Support variables for captures. local cap_lineno, cap_name local cap_buffers = {} local cap_used = {} -- Start a capture. map_coreop[".capture_1"] = function(params) if not params then return "name" end wflush() local name = params[1] if not match(name, "^[%a_][%w_]*$") then wfatal("bad capture name `"..name.."'") end if cap_name then wfatal("already capturing to `"..cap_name.."' since line "..cap_lineno) end cap_name = name cap_lineno = g_lineno -- Create or continue a capture buffer and start the output line capture. local buf = cap_buffers[name] if not buf then buf = {}; cap_buffers[name] = buf end g_capbuffer = buf g_synclineno = 0 end -- Stop a capture. map_coreop[".endcapture_0"] = function(params) wflush() if not cap_name then wfatal(".endcapture without a valid .capture") end cap_name = nil cap_lineno = nil g_capbuffer = nil g_synclineno = 0 end -- Dump a capture buffer. map_coreop[".dumpcapture_1"] = function(params) if not params then return "name" end wflush() local name = params[1] if not match(name, "^[%a_][%w_]*$") then wfatal("bad capture name `"..name.."'") end cap_used[name] = true wline(function(out) local buf = cap_buffers[name] if buf then wdumplines(out, buf) end end) g_synclineno = 0 end -- Dump all captures and their buffers (with -PP only). local function dumpcaptures(out, lvl) out:write("Captures:\n") for name,buf in pairs(cap_buffers) do out:write(format(" %-20s %4s)\n", name, "("..#buf)) if lvl > 1 then local bar = rep("=", 76) out:write(" ", bar, "\n") for _,line in ipairs(buf) do out:write(" ", line, "\n") end out:write(" ", bar, "\n\n") end end out:write("\n") end -- Check for unfinished or unused captures. local function checkcaptures() if cap_name then wprinterr(g_fname, ":", cap_lineno, ": error: unfinished .capture `", cap_name,"'\n") return end for name in pairs(cap_buffers) do if not cap_used[name] then wprinterr(g_fname, ":*: error: missing .dumpcapture ", name ,"\n") end end end ------------------------------------------------------------------------------ -- Sections names. local map_sections = {} -- Pseudo-opcode to define code sections. -- TODO: Data sections, BSS sections. Needs extra C code and API. map_coreop[".section_*"] = function(params) if not params then return "name..." end if #map_sections > 0 then werror("duplicate section definition") end wflush() for sn,name in ipairs(params) do local opname = "."..name.."_0" if not match(name, "^[%a][%w_]*$") or map_op[opname] or map_op["."..name.."_*"] then werror("bad section name `"..name.."'") end map_sections[#map_sections+1] = name wline(format("#define DASM_SECTION_%s\t%d", upper(name), sn-1)) map_op[opname] = function(params) g_arch.section(sn-1) end end wline(format("#define DASM_MAXSECTION\t\t%d", #map_sections)) end -- Dump all sections. local function dumpsections(out, lvl) out:write("Sections:\n") for _,name in ipairs(map_sections) do out:write(format(" %s\n", name)) end out:write("\n") end ------------------------------------------------------------------------------ -- Replacement for customized Lua, which lacks the package library. local prefix = "" if not require then function require(name) local fp = assert(io.open(prefix..name..".lua")) local s = fp:read("*a") assert(fp:close()) return assert(loadstring(s, "@"..name..".lua"))() end end -- Load architecture-specific module. local function loadarch(arch) if not match(arch, "^[%w_]+$") then return "bad arch name" end local ok, m_arch = pcall(require, "dasm_"..arch) if not ok then return "cannot load module: "..m_arch end g_arch = m_arch wflush = m_arch.passcb(wline, werror, wfatal, wwarn) m_arch.setup(arch, g_opt) map_op, map_def = m_arch.mergemaps(map_coreop, map_def) end -- Dump architecture description. function opt_map.dumparch(args) local name = optparam(args) if not g_arch then local err = loadarch(name) if err then opterror(err) end end local t = {} for name in pairs(map_coreop) do t[#t+1] = name end for name in pairs(map_op) do t[#t+1] = name end sort(t) local out = stdout local _arch = g_arch._info out:write(format("%s version %s, released %s, %s\n", _info.name, _info.version, _info.release, _info.url)) g_arch.dumparch(out) local pseudo = true out:write("Pseudo-Opcodes:\n") for _,sname in ipairs(t) do local name, nparam = match(sname, "^(.+)_([0-9%*])$") if name then if pseudo and sub(name, 1, 1) ~= "." then out:write("\nOpcodes:\n") pseudo = false end local f = map_op[sname] local s if nparam ~= "*" then nparam = nparam + 0 end if nparam == 0 then s = "" elseif type(f) == "string" then s = map_op[".template__"](nil, f, nparam) else s = f(nil, nparam) end if type(s) == "table" then for _,s2 in ipairs(s) do out:write(format(" %-12s %s\n", name, s2)) end else out:write(format(" %-12s %s\n", name, s)) end end end out:write("\n") exit(0) end -- Pseudo-opcode to set the architecture. -- Only initially available (map_op is replaced when called). map_op[".arch_1"] = function(params) if not params then return "name" end local err = loadarch(params[1]) if err then wfatal(err) end end -- Dummy .arch pseudo-opcode to improve the error report. map_coreop[".arch_1"] = function(params) if not params then return "name" end wfatal("duplicate .arch statement") end ------------------------------------------------------------------------------ -- Dummy pseudo-opcode. Don't confuse '.nop' with 'nop'. map_coreop[".nop_*"] = function(params) if not params then return "[ignored...]" end end -- Pseudo-opcodes to raise errors. map_coreop[".error_1"] = function(params) if not params then return "message" end werror(params[1]) end map_coreop[".fatal_1"] = function(params) if not params then return "message" end wfatal(params[1]) end -- Dump all user defined elements. local function dumpdef(out) local lvl = g_opt.dumpdef if lvl == 0 then return end dumpsections(out, lvl) dumpdefines(out, lvl) if g_arch then g_arch.dumpdef(out, lvl) end dumpmacros(out, lvl) dumpcaptures(out, lvl) end ------------------------------------------------------------------------------ -- Helper for splitstmt. local splitlvl local function splitstmt_one(c) if c == "(" then splitlvl = ")"..splitlvl elseif c == "[" then splitlvl = "]"..splitlvl elseif c == "{" then splitlvl = "}"..splitlvl elseif c == ")" or c == "]" or c == "}" then if sub(splitlvl, 1, 1) ~= c then werror("unbalanced (), [] or {}") end splitlvl = sub(splitlvl, 2) elseif splitlvl == "" then return " \0 " end return c end -- Split statement into (pseudo-)opcode and params. local function splitstmt(stmt) -- Convert label with trailing-colon into .label statement. local label = match(stmt, "^%s*(.+):%s*$") if label then return ".label", {label} end -- Split at commas and equal signs, but obey parentheses and brackets. splitlvl = "" stmt = gsub(stmt, "[,%(%)%[%]{}]", splitstmt_one) if splitlvl ~= "" then werror("unbalanced () or []") end -- Split off opcode. local op, other = match(stmt, "^%s*([^%s%z]+)%s*(.*)$") if not op then werror("bad statement syntax") end -- Split parameters. local params = {} for p in gmatch(other, "%s*(%Z+)%z?") do params[#params+1] = gsub(p, "%s+$", "") end if #params > 16 then werror("too many parameters") end params.op = op return op, params end -- Process a single statement. dostmt = function(stmt) -- Ignore empty statements. if match(stmt, "^%s*$") then return end -- Capture macro defs before substitution. if mac_capture then return mac_capture(stmt) end stmt = definesubst(stmt) -- Emit C code without parsing the line. if sub(stmt, 1, 1) == "|" then local tail = sub(stmt, 2) wflush() if sub(tail, 1, 2) == "//" then wcomment(tail) else wline(tail, true) end return end -- Split into (pseudo-)opcode and params. local op, params = splitstmt(stmt) -- Get opcode handler (matching # of parameters or generic handler). local f = map_op[op.."_"..#params] or map_op[op.."_*"] if not f then if not g_arch then wfatal("first statement must be .arch") end -- Improve error report. for i=0,9 do if map_op[op.."_"..i] then werror("wrong number of parameters for `"..op.."'") end end werror("unknown statement `"..op.."'") end -- Call opcode handler or special handler for template strings. if type(f) == "string" then map_op[".template__"](params, f) else f(params) end end -- Process a single line. local function doline(line) if g_opt.flushline then wflush() end -- Assembler line? local indent, aline = match(line, "^(%s*)%|(.*)$") if not aline then -- No, plain C code line, need to flush first. wflush() wsync() wline(line, false) return end g_indent = indent -- Remember current line indentation. -- Emit C code (even from macros). Avoids echo and line parsing. if sub(aline, 1, 1) == "|" then if not mac_capture then wsync() elseif g_opt.comment then wsync() wcomment(aline) end dostmt(aline) return end -- Echo assembler line as a comment. if g_opt.comment then wsync() wcomment(aline) end -- Strip assembler comments. aline = gsub(aline, "//.*$", "") -- Split line into statements at semicolons. if match(aline, ";") then for stmt in gmatch(aline, "[^;]+") do dostmt(stmt) end else dostmt(aline) end end ------------------------------------------------------------------------------ -- Write DynASM header. local function dasmhead(out) out:write(format([[ /* ** This file has been pre-processed with DynASM. ** %s ** DynASM version %s, DynASM %s version %s ** DO NOT EDIT! The original file is in "%s". */ #if DASM_VERSION != %d #error "Version mismatch between DynASM and included encoding engine" #endif ]], _info.url, _info.version, g_arch._info.arch, g_arch._info.version, g_fname, _info.vernum)) end -- Read input file. readfile = function(fin) g_indent = "" g_lineno = 0 g_synclineno = -1 -- Process all lines. for line in fin:lines() do g_lineno = g_lineno + 1 g_curline = line local ok, err = pcall(doline, line) if not ok and wprinterr(err, "\n") then return true end end wflush() -- Close input file. assert(fin == stdin or fin:close()) end -- Write output file. local function writefile(outfile) local fout -- Open output file. if outfile == nil or outfile == "-" then fout = stdout else fout = assert(io.open(outfile, "w")) end -- Write all buffered lines wdumplines(fout, g_wbuffer) -- Close output file. assert(fout == stdout or fout:close()) -- Optionally dump definitions. dumpdef(fout == stdout and stderr or stdout) end -- Translate an input file to an output file. local function translate(infile, outfile) g_wbuffer = {} g_indent = "" g_lineno = 0 g_synclineno = -1 -- Put header. wline(dasmhead) -- Read input file. local fin if infile == "-" then g_fname = "(stdin)" fin = stdin else g_fname = infile fin = assert(io.open(infile, "r")) end readfile(fin) -- Check for errors. if not g_arch then wprinterr(g_fname, ":*: error: missing .arch directive\n") end checkconds() checkmacros() checkcaptures() if g_errcount ~= 0 then stderr:write(g_fname, ":*: info: ", g_errcount, " error", (type(g_errcount) == "number" and g_errcount > 1) and "s" or "", " in input file -- no output file generated.\n") dumpdef(stderr) exit(1) end -- Write output file. writefile(outfile) end ------------------------------------------------------------------------------ -- Print help text. function opt_map.help() stdout:write("DynASM -- ", _info.description, ".\n") stdout:write("DynASM ", _info.version, " ", _info.release, " ", _info.url, "\n") stdout:write[[ Usage: dynasm [OPTION]... INFILE.dasc|- -h, --help Display this help text. -V, --version Display version and copyright information. -o, --outfile FILE Output file name (default is stdout). -I, --include DIR Add directory to the include search path. -c, --ccomment Use /* */ comments for assembler lines. -C, --cppcomment Use // comments for assembler lines (default). -N, --nocomment Suppress assembler lines in output. -M, --maccomment Show macro expansions as comments (default off). -L, --nolineno Suppress CPP line number information in output. -F, --flushline Flush action list for every line. -D NAME[=SUBST] Define a substitution. -U NAME Undefine a substitution. -P, --dumpdef Dump defines, macros, etc. Repeat for more output. -A, --dumparch ARCH Load architecture ARCH and dump description. ]] exit(0) end -- Print version information. function opt_map.version() stdout:write(format("%s version %s, released %s\n%s\n\n%s", _info.name, _info.version, _info.release, _info.url, _info.copyright)) exit(0) end -- Misc. options. function opt_map.outfile(args) g_opt.outfile = optparam(args) end function opt_map.include(args) insert(g_opt.include, 1, optparam(args)) end function opt_map.ccomment() g_opt.comment = "/*|"; g_opt.endcomment = " */" end function opt_map.cppcomment() g_opt.comment = "//|"; g_opt.endcomment = "" end function opt_map.nocomment() g_opt.comment = false end function opt_map.maccomment() g_opt.maccomment = true end function opt_map.nolineno() g_opt.cpp = false end function opt_map.flushline() g_opt.flushline = true end function opt_map.dumpdef() g_opt.dumpdef = g_opt.dumpdef + 1 end ------------------------------------------------------------------------------ -- Short aliases for long options. local opt_alias = { h = "help", ["?"] = "help", V = "version", o = "outfile", I = "include", c = "ccomment", C = "cppcomment", N = "nocomment", M = "maccomment", L = "nolineno", F = "flushline", P = "dumpdef", A = "dumparch", } -- Parse single option. local function parseopt(opt, args) opt_current = #opt == 1 and "-"..opt or "--"..opt local f = opt_map[opt] or opt_map[opt_alias[opt]] if not f then opterror("unrecognized option `", opt_current, "'. Try `--help'.\n") end f(args) end -- Parse arguments. local function parseargs(args) -- Default options. g_opt.comment = "//|" g_opt.endcomment = "" g_opt.cpp = true g_opt.dumpdef = 0 g_opt.include = { "" } -- Process all option arguments. args.argn = 1 repeat local a = args[args.argn] if not a then break end local lopt, opt = match(a, "^%-(%-?)(.+)") if not opt then break end args.argn = args.argn + 1 if lopt == "" then -- Loop through short options. for o in gmatch(opt, ".") do parseopt(o, args) end else -- Long option. parseopt(opt, args) end until false -- Check for proper number of arguments. local nargs = #args - args.argn + 1 if nargs ~= 1 then if nargs == 0 then if g_opt.dumpdef > 0 then return dumpdef(stdout) end end opt_map.help() end -- Translate a single input file to a single output file -- TODO: Handle multiple files? translate(args[args.argn], g_opt.outfile) end ------------------------------------------------------------------------------ -- Add the directory dynasm.lua resides in to the Lua module search path. local arg = arg if arg and arg[0] then prefix = match(arg[0], "^(.*[/\\])") if package and prefix then package.path = prefix.."?.lua;"..package.path end end -- Start DynASM. parseargs{...} ------------------------------------------------------------------------------ ================================================ FILE: cocos2d/external/lua/luajit/src/etc/luajit.1 ================================================ .TH luajit 1 "" "" "LuaJIT documentation" .SH NAME luajit \- Just-In-Time Compiler for the Lua Language \fB .SH SYNOPSIS .B luajit [\fIoptions\fR]... [\fIscript\fR [\fIargs\fR]...] .SH "WEB SITE" .IR http://luajit.org .SH DESCRIPTION .PP This is the command-line program to run Lua programs with \fBLuaJIT\fR. .PP \fBLuaJIT\fR is a just-in-time (JIT) compiler for the Lua language. The virtual machine (VM) is based on a fast interpreter combined with a trace compiler. It can significantly improve the performance of Lua programs. .PP \fBLuaJIT\fR is API\- and ABI-compatible with the VM of the standard Lua\ 5.1 interpreter. When embedding the VM into an application, the built library can be used as a drop-in replacement. .SH OPTIONS .TP .BI "\-e " chunk Run the given chunk of Lua code. .TP .BI "\-l " library Load the named library, just like \fBrequire("\fR\fIlibrary\fR\fB")\fR. .TP .BI "\-b " ... Save or list bytecode. Run without arguments to get help on options. .TP .BI "\-j " command Perform LuaJIT control command (optional space after \fB\-j\fR). .TP .BI "\-O" [opt] Control LuaJIT optimizations. .TP .B "\-i" Run in interactive mode. .TP .B "\-v" Show \fBLuaJIT\fR version. .TP .B "\-E" Ignore environment variables. .TP .B "\-\-" Stop processing options. .TP .B "\-" Read script from stdin instead. .PP After all options are processed, the given \fIscript\fR is run. The arguments are passed in the global \fIarg\fR table. .PP Interactive mode is only entered, if no \fIscript\fR and no \fB\-e\fR option is given. Interactive mode can be left with EOF (\fICtrl\-Z\fB). .SH EXAMPLES .TP luajit hello.lua world Prints "Hello world", assuming \fIhello.lua\fR contains: .br print("Hello", arg[1]) .TP luajit \-e "local x=0; for i=1,1e9 do x=x+i end; print(x)" Calculates the sum of the numbers from 1 to 1000000000. .br And finishes in a reasonable amount of time, too. .TP luajit \-jv \-e "for i=1,10 do for j=1,10 do for k=1,100 do end end end" Runs some nested loops and shows the resulting traces. .SH COPYRIGHT .PP \fBLuaJIT\fR is Copyright \(co 2005-2013 Mike Pall. .br \fBLuaJIT\fR is open source software, released under the MIT license. .SH SEE ALSO .PP More details in the provided HTML docs or at: .IR http://luajit.org .br More about the Lua language can be found at: .IR http://lua.org/docs.html .PP lua(1) ================================================ FILE: cocos2d/external/lua/luajit/src/etc/luajit.pc ================================================ # Package information for LuaJIT to be used by pkg-config. majver=2 minver=0 relver=1 version=${majver}.${minver}.${relver} abiver=5.1 prefix=/usr/local exec_prefix=${prefix} libdir=${exec_prefix}/lib libname=luajit-${abiver} includedir=${prefix}/include/luajit-${majver}.${minver} INSTALL_LMOD=${prefix}/share/lua/${abiver} INSTALL_CMOD=${prefix}/lib/lua/${abiver} Name: LuaJIT Description: Just-in-time compiler for Lua URL: http://luajit.org Version: ${version} Requires: Libs: -L${libdir} -l${libname} Libs.private: -Wl,-E -lm -ldl Cflags: -I${includedir} ================================================ FILE: cocos2d/external/lua/luajit/src/src/Makefile ================================================ ############################################################################## # LuaJIT Makefile. Requires GNU Make. # # Please read doc/install.html before changing any variables! # # Suitable for POSIX platforms (Linux, *BSD, OSX etc.). # Also works with MinGW and Cygwin on Windows. # Please check msvcbuild.bat for building with MSVC on Windows. # # Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h ############################################################################## MAJVER= 2 MINVER= 0 RELVER= 0 ABIVER= 5.1 NODOTABIVER= 51 ############################################################################## ############################# COMPILER OPTIONS ############################# ############################################################################## # These options mainly affect the speed of the JIT compiler itself, not the # speed of the JIT-compiled code. Turn any of the optional settings on by # removing the '#' in front of them. Make sure you force a full recompile # with "make clean", followed by "make" if you change any options. # # LuaJIT builds as a native 32 or 64 bit binary by default. CC= gcc # # Use this if you want to force a 32 bit build on a 64 bit multilib OS. #CC= gcc -m32 # # Since the assembler part does NOT maintain a frame pointer, it's pointless # to slow down the C part by not omitting it. Debugging, tracebacks and # unwinding are not affected -- the assembler part has frame unwind # information and GCC emits it where needed (x64) or with -g (see CCDEBUG). CCOPT= -O2 -fomit-frame-pointer # Use this if you want to generate a smaller binary (but it's slower): #CCOPT= -Os -fomit-frame-pointer # Note: it's no longer recommended to use -O3 with GCC 4.x. # The I-Cache bloat usually outweighs the benefits from aggressive inlining. # # Target-specific compiler options: # # x86 only: it's recommended to compile at least for i686. Better yet, # compile for an architecture that has SSE2, too (-msse -msse2). # # x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute # the binaries to a different machine you could also use: -march=native # CCOPT_x86= -march=i686 CCOPT_x64= CCOPT_arm= CCOPT_ppc= CCOPT_ppcspe= CCOPT_mips= # CCDEBUG= # Uncomment the next line to generate debug information: #CCDEBUG= -g # CCWARN= -Wall # Uncomment the next line to enable more warnings: #CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith # ############################################################################## ############################################################################## ################################ BUILD MODE ################################ ############################################################################## # The default build mode is mixed mode on POSIX. On Windows this is the same # as dynamic mode. # # Mixed mode creates a static + dynamic library and a statically linked luajit. BUILDMODE= mixed # # Static mode creates a static library and a statically linked luajit. #BUILDMODE= static # # Dynamic mode creates a dynamic library and a dynamically linked luajit. # Note: this executable will only run when the library is installed! #BUILDMODE= dynamic # ############################################################################## ############################################################################## ################################# FEATURES ################################# ############################################################################## # Enable/disable these features as needed, but make sure you force a full # recompile with "make clean", followed by "make". XCFLAGS= # # Permanently disable the FFI extension to reduce the size of the LuaJIT # executable. But please consider that the FFI library is compiled-in, # but NOT loaded by default. It only allocates any memory, if you actually # make use of it. #XCFLAGS+= -DLUAJIT_DISABLE_FFI # # Features from Lua 5.2 that are unlikely to break existing code are # enabled by default. Some other features that *might* break some existing # code (e.g. __pairs or os.execute() return values) can be enabled here. # Note: this does not provide full compatibility with Lua 5.2 at this time. #XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT # # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. #XCFLAGS+= -DLUAJIT_DISABLE_JIT # # Some architectures (e.g. PPC) can use either single-number (1) or # dual-number (2) mode. Uncomment one of these lines to override the # default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details. #XCFLAGS+= -DLUAJIT_NUMMODE=1 #XCFLAGS+= -DLUAJIT_NUMMODE=2 # ############################################################################## ############################################################################## ############################ DEBUGGING SUPPORT ############################# ############################################################################## # Enable these options as needed, but make sure you force a full recompile # with "make clean", followed by "make". # Note that most of these are NOT suitable for benchmarking or release mode! # # Use the system provided memory allocator (realloc) instead of the # bundled memory allocator. This is slower, but sometimes helpful for # debugging. It's helpful for Valgrind's memcheck tool, too. This option # cannot be enabled on x64, since the built-in allocator is mandatory. #XCFLAGS+= -DLUAJIT_USE_SYSMALLOC # # This define is required to run LuaJIT under Valgrind. The Valgrind # header files must be installed. You should enable debug information, too. # Use --suppressions=lj.supp to avoid some false positives. #XCFLAGS+= -DLUAJIT_USE_VALGRIND # # This is the client for the GDB JIT API. GDB 7.0 or higher is required # to make use of it. See lj_gdbjit.c for details. Enabling this causes # a non-negligible overhead, even when not running under GDB. #XCFLAGS+= -DLUAJIT_USE_GDBJIT # # Turn on assertions for the Lua/C API to debug problems with lua_* calls. # This is rather slow -- use only while developing C libraries/embeddings. #XCFLAGS+= -DLUA_USE_APICHECK # # Turn on assertions for the whole LuaJIT VM. This significantly slows down # everything. Use only if you suspect a problem with LuaJIT itself. #XCFLAGS+= -DLUA_USE_ASSERT # ############################################################################## # You probably don't need to change anything below this line! ############################################################################## ############################################################################## # Flags and options for host and target. ############################################################################## # You can override the following variables at the make command line: # CC HOST_CC STATIC_CC DYNAMIC_CC # CFLAGS HOST_CFLAGS TARGET_CFLAGS # LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS # LIBS HOST_LIBS TARGET_LIBS # CROSS HOST_SYS TARGET_SYS TARGET_FLAGS # # Cross-compilation examples: # make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows # make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS) LDOPTIONS= $(CCDEBUG) $(LDFLAGS) HOST_CC= $(CC) HOST_RM= rm -f # If left blank, minilua is built and used. You can supply an installed # copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua HOST_LUA= HOST_XCFLAGS= -I. HOST_XLDFLAGS= HOST_XLIBS= HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS) HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS) HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS) STATIC_CC = $(CROSS)$(CC) DYNAMIC_CC = $(CROSS)$(CC) -fPIC TARGET_CC= $(STATIC_CC) TARGET_STCC= $(STATIC_CC) TARGET_DYNCC= $(DYNAMIC_CC) TARGET_LD= $(CROSS)$(CC) TARGET_AR= $(CROSS)ar rcus TARGET_STRIP= $(CROSS)strip TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER) TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib TARGET_DYLIBPATH= $(or $(PREFIX),/usr/local)/lib/$(TARGET_DYLIBNAME) TARGET_DLLNAME= lua$(NODOTABIVER).dll TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME) TARGET_DYNXLDOPTS= TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE TARGET_XLDFLAGS= TARGET_XLIBS= -lm TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS) TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS) TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS) TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS) TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM) ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH))) TARGET_LJARCH= x64 else ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH))) TARGET_LJARCH= x86 else ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH))) TARGET_LJARCH= arm else ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH))) TARGET_LJARCH= ppc else ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH))) TARGET_LJARCH= ppcspe else ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH))) ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH))) TARGET_ARCH= -D__MIPSEL__=1 endif TARGET_LJARCH= mips else $(error Unsupported target architecture) endif endif endif endif endif endif ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH))) TARGET_SYS= PS3 TARGET_ARCH+= -D__CELLOS_LV2__ TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC endif ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH))) TARGET_ARCH+= -DLUAJIT_NO_UNWIND endif TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH)) TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH)) ifneq (,$(PREFIX)) ifneq (/usr/local,$(PREFIX)) TARGET_XCFLAGS+= -DLUA_XROOT=\"$(PREFIX)/\" ifneq (/usr,$(PREFIX)) TARGET_DYNXLDOPTS= -Wl,-rpath,$(PREFIX)/lib endif endif endif ############################################################################## # System detection. ############################################################################## ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) HOST_SYS= Windows HOST_RM= del else HOST_SYS:= $(shell uname -s) ifneq (,$(findstring MINGW,$(HOST_SYS))) HOST_SYS= Windows HOST_MSYS= mingw endif ifneq (,$(findstring CYGWIN,$(HOST_SYS))) HOST_SYS= Windows HOST_MSYS= cygwin endif endif TARGET_SYS?= $(HOST_SYS) ifeq (Windows,$(TARGET_SYS)) TARGET_STRIP+= --strip-unneeded TARGET_XSHLDFLAGS= -shared TARGET_DYNXLDOPTS= else ifeq (Darwin,$(TARGET_SYS)) ifeq (,$(MACOSX_DEPLOYMENT_TARGET)) export MACOSX_DEPLOYMENT_TARGET=10.4 endif TARGET_STRIP+= -x TARGET_AR+= 2>/dev/null TARGET_XCFLAGS+= -fno-stack-protector TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_DYNXLDOPTS= TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) ifeq (x64,$(TARGET_LJARCH)) TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000 TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000 endif else ifeq (iOS,$(TARGET_SYS)) TARGET_STRIP+= -x TARGET_AR+= 2>/dev/null TARGET_XCFLAGS+= -fno-stack-protector TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_DYNXLDOPTS= TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) else ifneq (,$(findstring stack-protector,$(shell $(TARGET_CC) -dumpspecs))) TARGET_XCFLAGS+= -fno-stack-protector endif ifneq (SunOS,$(TARGET_SYS)) ifneq (PS3,$(TARGET_SYS)) TARGET_XLDFLAGS+= -Wl,-E endif endif ifeq (Linux,$(TARGET_SYS)) TARGET_XLIBS+= -ldl endif ifeq (GNU/kFreeBSD,$(TARGET_SYS)) TARGET_XLIBS+= -ldl endif endif endif endif ifneq ($(HOST_SYS),$(TARGET_SYS)) ifeq (Windows,$(TARGET_SYS)) HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS else ifeq (Linux,$(TARGET_SYS)) HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX else ifeq (Darwin,$(TARGET_SYS)) HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX else ifeq (iOS,$(TARGET_SYS)) HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX else HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER endif endif endif endif endif ifneq (,$(CCDEBUG)) TARGET_STRIP= @: endif ############################################################################## # Files and pathnames. ############################################################################## MINILUA_O= host/minilua.o MINILUA_LIBS= -lm MINILUA_T= host/minilua MINILUA_X= $(MINILUA_T) ifeq (,$(HOST_LUA)) HOST_LUA= $(MINILUA_X) DASM_DEP= $(MINILUA_T) endif DASM_DIR= ../dynasm DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua DASM_XFLAGS= DASM_AFLAGS= DASM_ARCH= $(TARGET_LJARCH) ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D P64 endif ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D JIT endif ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D FFI endif ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D DUALNUM endif ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D FPU TARGET_ARCH+= -DLJ_ARCH_HASFPU=1 else TARGET_ARCH+= -DLJ_ARCH_HASFPU=0 endif ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D HFABI TARGET_ARCH+= -DLJ_ABI_SOFTFP=0 else TARGET_ARCH+= -DLJ_ABI_SOFTFP=1 endif DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH)))) ifeq (Windows,$(TARGET_SYS)) DASM_AFLAGS+= -D WIN endif ifeq (x86,$(TARGET_LJARCH)) ifneq (,$(findstring __SSE2__ 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D SSE endif else ifeq (x64,$(TARGET_LJARCH)) DASM_ARCH= x86 else ifeq (arm,$(TARGET_LJARCH)) ifeq (iOS,$(TARGET_SYS)) DASM_AFLAGS+= -D IOS endif else ifeq (ppc,$(TARGET_LJARCH)) ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D SQRT endif ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D ROUND endif ifneq (,$(findstring LJ_ARCH_PPC64 1,$(TARGET_TESTARCH))) DASM_AFLAGS+= -D GPR64 endif ifeq (PS3,$(TARGET_SYS)) DASM_AFLAGS+= -D PPE -D TOC endif endif endif endif endif DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS) DASM_DASC= vm_$(DASM_ARCH).dasc BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \ host/buildvm_lib.o host/buildvm_fold.o BUILDVM_T= host/buildvm BUILDVM_X= $(BUILDVM_T) HOST_O= $(MINILUA_O) $(BUILDVM_O) HOST_T= $(MINILUA_T) $(BUILDVM_T) LJVM_S= lj_vm.s LJVM_O= lj_vm.o LJVM_BOUT= $(LJVM_S) LJVM_MODE= elfasm LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \ lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o LJLIB_C= $(LJLIB_O:.o=.c) LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \ lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \ lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_strscan.o \ lj_api.o lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \ lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \ lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \ lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \ lj_asm.o lj_trace.o lj_gdbjit.o \ lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \ lj_carith.o lj_clib.o lj_cparse.o \ lj_lib.o lj_alloc.o lib_aux.o \ $(LJLIB_O) lib_init.o LJVMCORE_O= $(LJVM_O) $(LJCORE_O) LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o) LIB_VMDEF= jit/vmdef.lua LIB_VMDEFP= $(LIB_VMDEF) LUAJIT_O= luajit.o LUAJIT_A= libluajit.a LUAJIT_SO= libluajit.so LUAJIT_T= luajit ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T) ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \ host/buildvm_arch.h ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP) WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM) ############################################################################## # Build mode handling. ############################################################################## # Mixed mode defaults. TARGET_O= $(LUAJIT_A) TARGET_T= $(LUAJIT_T) $(LUAJIT_SO) TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) ifeq (Windows,$(TARGET_SYS)) TARGET_DYNCC= $(STATIC_CC) LJVM_MODE= coffasm LUAJIT_T= luajit.exe ifeq (cygwin,$(HOST_MSYS)) LUAJIT_SO= cyg$(TARGET_DLLNAME) else LUAJIT_SO= $(TARGET_DLLNAME) endif # Mixed mode is not supported on Windows. And static mode doesn't work well. # C modules cannot be loaded, because they bind to lua51.dll. ifneq (static,$(BUILDMODE)) BUILDMODE= dynamic TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL endif endif ifeq (Darwin,$(TARGET_SYS)) LJVM_MODE= machasm endif ifeq (iOS,$(TARGET_SYS)) LJVM_MODE= machasm endif ifeq (SunOS,$(TARGET_SYS)) BUILDMODE= static endif ifeq (PS3,$(TARGET_SYS)) BUILDMODE= static endif ifeq (Windows,$(HOST_SYS)) MINILUA_T= host/minilua.exe BUILDVM_T= host/buildvm.exe ifeq (,$(HOST_MSYS)) MINILUA_X= host\minilua BUILDVM_X= host\buildvm ALL_RM:= $(subst /,\,$(ALL_RM)) endif endif ifeq (static,$(BUILDMODE)) TARGET_DYNCC= @: TARGET_T= $(LUAJIT_T) TARGET_DEP= $(LIB_VMDEF) else ifeq (dynamic,$(BUILDMODE)) ifneq (Windows,$(TARGET_SYS)) TARGET_CC= $(DYNAMIC_CC) endif TARGET_DYNCC= @: LJVMCORE_DYNO= $(LJVMCORE_O) TARGET_O= $(LUAJIT_SO) TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS) else ifeq (Darwin,$(TARGET_SYS)) TARGET_DYNCC= @: LJVMCORE_DYNO= $(LJVMCORE_O) endif ifeq (iOS,$(TARGET_SYS)) TARGET_DYNCC= @: LJVMCORE_DYNO= $(LJVMCORE_O) endif endif endif Q= @ E= @echo #Q= #E= @: ############################################################################## # Make targets. ############################################################################## default all: $(TARGET_T) amalg: @grep "^[+|]" ljamalg.c $(MAKE) all "LJCORE_O=ljamalg.o" clean: $(HOST_RM) $(ALL_RM) depend: @for file in $(ALL_HDRGEN); do \ test -f $$file || touch $$file; \ done @$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \ sed -e "s| [^ ]*/dasm_\S*\.h||g" \ -e "s|^\([^l ]\)|host/\1|" \ -e "s| lj_target_\S*\.h| lj_target_*.h|g" \ -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \ -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep @for file in $(ALL_HDRGEN); do \ test -s $$file || $(HOST_RM) $$file; \ done .PHONY: default all amalg clean depend ############################################################################## # Rules for generated files. ############################################################################## $(MINILUA_T): $(MINILUA_O) $(E) "HOSTLINK $@" $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS) host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) $(E) "DYNASM $@" $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) host/buildvm.o: $(DASM_DIR)/dasm_*.h $(BUILDVM_T): $(BUILDVM_O) $(E) "HOSTLINK $@" $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS) $(LJVM_BOUT): $(BUILDVM_T) $(E) "BUILDVM $@" $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@ lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C) $(E) "BUILDVM $@" $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C) lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C) $(E) "BUILDVM $@" $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C) lj_libdef.h: $(BUILDVM_T) $(LJLIB_C) $(E) "BUILDVM $@" $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C) lj_recdef.h: $(BUILDVM_T) $(LJLIB_C) $(E) "BUILDVM $@" $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C) $(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C) $(E) "BUILDVM $@" $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C) lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c $(E) "BUILDVM $@" $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c ############################################################################## # Object file rules. ############################################################################## %.o: %.c $(E) "CC $@" $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< %.o: %.s $(E) "ASM $@" $(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $< $(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $< $(LUAJIT_O): $(E) "CC $@" $(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $< $(HOST_O): %.o: %.c $(E) "HOSTCC $@" $(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $< include Makefile.dep ############################################################################## # Target file rules. ############################################################################## $(LUAJIT_A): $(LJVMCORE_O) $(E) "AR $@" $(Q)$(TARGET_AR) $@ $(LJVMCORE_O) # The dependency on _O, but linking with _DYNO is intentional. $(LUAJIT_SO): $(LJVMCORE_O) $(E) "DYNLINK $@" $(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS) $(Q)$(TARGET_STRIP) $@ $(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP) $(E) "LINK $@" $(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS) $(Q)$(TARGET_STRIP) $@ $(E) "OK Successfully built LuaJIT" ############################################################################## ================================================ FILE: cocos2d/external/lua/luajit/src/src/Makefile.dep ================================================ lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_trace.h lj_jit.h lj_ir.h \ lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \ lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ lj_lib.h lj_libdef.h lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_lib.h \ lj_libdef.h lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h \ lj_ctype.h lj_cparse.h lj_cdata.h lj_cconv.h lj_carith.h lj_ccall.h \ lj_ccallback.h lj_clib.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h lj_ffdef.h \ lj_lib.h lj_libdef.h lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \ lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \ lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \ lj_libdef.h lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_libdef.h lib_package.o: lib_package.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h \ lj_meta.h lj_state.h lj_ff.h lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \ lj_lib.h lj_libdef.h lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_lib.h \ lj_libdef.h lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \ lj_meta.h lj_state.h lj_bc.h lj_frame.h lj_trace.h lj_jit.h lj_ir.h \ lj_dispatch.h lj_traceerr.h lj_vm.h lj_strscan.h lj_asm.o: lj_asm.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h \ lj_ircall.h lj_iropt.h lj_mcode.h lj_trace.h lj_dispatch.h lj_traceerr.h \ lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \ lj_asm_*.h lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \ lj_bcdef.h lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h lj_ctype.h \ lj_cdata.h lualib.h lj_lex.h lj_bcdump.h lj_state.h lj_bcwrite.o: lj_bcwrite.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_str.h lj_bc.h lj_ctype.h lj_dispatch.h lj_jit.h lj_ir.h \ lj_bcdump.h lj_lex.h lj_err.h lj_errmsg.h lj_vm.h lj_carith.o: lj_carith.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_meta.h lj_ctype.h lj_cconv.h \ lj_cdata.h lj_carith.h lj_ccall.o: lj_ccall.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \ lj_cdata.h lj_ccall.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ lj_traceerr.h lj_ccallback.o: lj_ccallback.c lj_obj.h lua.h luaconf.h lj_def.h \ lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_state.h lj_frame.h \ lj_bc.h lj_ctype.h lj_cconv.h lj_ccall.h lj_ccallback.h lj_target.h \ lj_target_*.h lj_mcode.h lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h \ lj_traceerr.h lj_vm.h lj_cconv.o: lj_cconv.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_err.h lj_errmsg.h lj_tab.h lj_ctype.h lj_gc.h lj_cdata.h lj_cconv.h \ lj_ccallback.h lj_cdata.o: lj_cdata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \ lj_cdata.h lj_char.o: lj_char.c lj_char.h lj_def.h lua.h luaconf.h lj_clib.o: lj_clib.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_err.h lj_errmsg.h lj_tab.h lj_str.h lj_udata.h lj_ctype.h lj_cconv.h \ lj_cdata.h lj_clib.h lj_cparse.o: lj_cparse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_ctype.h lj_cparse.h lj_frame.h \ lj_bc.h lj_vm.h lj_char.h lj_strscan.h lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h \ lj_gc.h lj_cdata.h lj_cparse.h lj_cconv.h lj_clib.h lj_ccall.h lj_ff.h \ lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \ lj_crecord.h lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_ccallback.h lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \ lj_bc.h lj_jit.h lj_ir.h lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_err.h lj_errmsg.h lj_func.h lj_str.h lj_tab.h lj_meta.h lj_debug.h \ lj_state.h lj_frame.h lj_bc.h lj_ff.h lj_ffdef.h lj_jit.h lj_ir.h \ lj_ccallback.h lj_ctype.h lj_gc.h lj_trace.h lj_dispatch.h lj_traceerr.h \ lj_vm.h luajit.h lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ lj_errmsg.h lj_debug.h lj_str.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ lj_traceerr.h lj_vm.h lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \ lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_crecord.h \ lj_vm.h lj_strscan.h lj_recdef.h lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ lj_traceerr.h lj_vm.h lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h \ lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h lj_trace.h lj_jit.h \ lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_frame.h lj_bc.h lj_jit.h \ lj_ir.h lj_dispatch.h lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ lj_dispatch.h lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h lj_carith.h \ lj_vm.h lj_strscan.h lj_lib.h lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cdata.h lualib.h \ lj_state.h lj_lex.h lj_parse.h lj_char.h lj_strscan.h lj_lib.o: lj_lib.c lauxlib.h lua.h luaconf.h lj_obj.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_bc.h \ lj_dispatch.h lj_jit.h lj_ir.h lj_vm.h lj_strscan.h lj_lib.h lj_load.o: lj_load.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \ lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_func.h lj_frame.h \ lj_bc.h lj_vm.h lj_lex.h lj_bcdump.h lj_parse.h lj_mcode.o: lj_mcode.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_jit.h lj_ir.h lj_mcode.h lj_trace.h lj_dispatch.h lj_bc.h \ lj_traceerr.h lj_vm.h lj_meta.o: lj_meta.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ lj_vm.h lj_strscan.h lj_obj.o: lj_obj.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_ir.h lj_jit.h lj_iropt.h lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \ lj_strscan.h lj_folddef.h lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h lj_opt_mem.o: lj_opt_mem.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \ lj_arch.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ lj_traceerr.h lj_vm.h lj_strscan.h lj_opt_sink.o: lj_opt_sink.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_ir.h lj_jit.h lj_iropt.h lj_target.h lj_target_*.h lj_opt_split.o: lj_opt_split.c lj_obj.h lua.h luaconf.h lj_def.h \ lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_ircall.h \ lj_iropt.h lj_vm.h lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h \ lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \ lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \ lj_ffrecord.h lj_snap.h lj_vm.h lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_tab.h lj_state.h lj_frame.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h \ lj_trace.h lj_dispatch.h lj_traceerr.h lj_snap.h lj_target.h \ lj_target_*.h lj_ctype.h lj_cdata.h lj_state.o: lj_state.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_meta.h \ lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_trace.h lj_jit.h lj_ir.h \ lj_dispatch.h lj_traceerr.h lj_vm.h lj_lex.h lj_alloc.h lj_str.o: lj_str.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_char.h lj_strscan.o: lj_strscan.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_char.h lj_strscan.h lj_tab.o: lj_tab.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_err.h lj_errmsg.h lj_tab.h lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_frame.h lj_bc.h \ lj_state.h lj_ir.h lj_jit.h lj_iropt.h lj_mcode.h lj_trace.h \ lj_dispatch.h lj_traceerr.h lj_snap.h lj_gdbjit.h lj_record.h lj_asm.h \ lj_vm.h lj_vmevent.h lj_target.h lj_target_*.h lj_udata.o: lj_udata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_gc.h lj_udata.h lj_vmevent.o: lj_vmevent.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_str.h lj_tab.h lj_state.h lj_dispatch.h lj_bc.h lj_jit.h lj_ir.h \ lj_vm.h lj_vmevent.h lj_vmmath.o: lj_vmmath.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_ir.h lj_vm.h ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \ lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h \ lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \ lj_debug.h lj_ff.h lj_ffdef.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h \ lj_obj.c lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h \ lj_debug.c lj_state.c lj_lex.h lj_alloc.h lj_dispatch.c lj_ccallback.h \ luajit.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c lj_api.c \ lj_lex.c lualib.h lj_parse.h lj_parse.c lj_bcread.c lj_bcdump.h \ lj_bcwrite.c lj_load.c lj_ctype.c lj_cdata.c lj_cconv.h lj_cconv.c \ lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h lj_target_*.h \ lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h lj_cparse.c \ lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_ircall.h lj_iropt.h \ lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \ lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \ lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \ lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \ lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \ lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \ lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \ lib_init.c luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \ lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \ lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \ lj_gc.h lj_ccall.h lj_ctype.h luajit.h \ host/buildvm_arch.h lj_traceerr.h host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \ lj_arch.h lj_bc.h lj_def.h lj_arch.h host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \ luaconf.h lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_ir.h lj_obj.h host/buildvm_lib.o: host/buildvm_lib.c host/buildvm.h lj_def.h lua.h luaconf.h \ lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_lib.h lj_obj.h host/buildvm_peobj.o: host/buildvm_peobj.c host/buildvm.h lj_def.h lua.h \ luaconf.h lj_arch.h lj_bc.h lj_def.h lj_arch.h host/minilua.o: host/minilua.c ================================================ FILE: cocos2d/external/lua/luajit/src/src/host/README ================================================ The files in this directory are only used during the build process of LuaJIT. For cross-compilation, they must be executed on the host, not on the target. These files should NOT be installed! ================================================ FILE: cocos2d/external/lua/luajit/src/src/host/buildvm.c ================================================ /* ** LuaJIT VM builder. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** This is a tool to build the hand-tuned assembler code required for ** LuaJIT's bytecode interpreter. It supports a variety of output formats ** to feed different toolchains (see usage() below). ** ** This tool is not particularly optimized because it's only used while ** _building_ LuaJIT. There's no point in distributing or installing it. ** Only the object code generated by this tool is linked into LuaJIT. ** ** Caveat: some memory is not free'd, error handling is lazy. ** It's a one-shot tool -- any effort fixing this would be wasted. */ #include "buildvm.h" #include "lj_obj.h" #include "lj_gc.h" #include "lj_bc.h" #include "lj_ir.h" #include "lj_ircall.h" #include "lj_frame.h" #include "lj_dispatch.h" #if LJ_HASFFI #include "lj_ctype.h" #include "lj_ccall.h" #endif #include "luajit.h" #if defined(_WIN32) #include #include #endif /* ------------------------------------------------------------------------ */ /* DynASM glue definitions. */ #define Dst ctx #define Dst_DECL BuildCtx *ctx #define Dst_REF (ctx->D) #define DASM_CHECKS 1 #include "../dynasm/dasm_proto.h" /* Glue macros for DynASM. */ static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type); #define DASM_EXTERN(ctx, addr, idx, type) \ collect_reloc(ctx, addr, idx, type) /* ------------------------------------------------------------------------ */ /* Avoid trouble if cross-compiling for an x86 target. Speed doesn't matter. */ #define DASM_ALIGNED_WRITES 1 /* Embed architecture-specific DynASM encoder. */ #if LJ_TARGET_X86ORX64 #include "../dynasm/dasm_x86.h" #elif LJ_TARGET_ARM #include "../dynasm/dasm_arm.h" #elif LJ_TARGET_PPC #include "../dynasm/dasm_ppc.h" #elif LJ_TARGET_PPCSPE #include "../dynasm/dasm_ppc.h" #elif LJ_TARGET_MIPS #include "../dynasm/dasm_mips.h" #else #error "No support for this architecture (yet)" #endif /* Embed generated architecture-specific backend. */ #include "buildvm_arch.h" /* ------------------------------------------------------------------------ */ void owrite(BuildCtx *ctx, const void *ptr, size_t sz) { if (fwrite(ptr, 1, sz, ctx->fp) != sz) { fprintf(stderr, "Error: cannot write to output file: %s\n", strerror(errno)); exit(1); } } /* ------------------------------------------------------------------------ */ /* Emit code as raw bytes. Only used for DynASM debugging. */ static void emit_raw(BuildCtx *ctx) { owrite(ctx, ctx->code, ctx->codesz); } /* -- Build machine code -------------------------------------------------- */ static const char *sym_decorate(BuildCtx *ctx, const char *prefix, const char *suffix) { char name[256]; char *p; #if LJ_64 const char *symprefix = ctx->mode == BUILD_machasm ? "_" : ""; #elif LJ_TARGET_XBOX360 const char *symprefix = ""; #else const char *symprefix = ctx->mode != BUILD_elfasm ? "_" : ""; #endif sprintf(name, "%s%s%s", symprefix, prefix, suffix); p = strchr(name, '@'); if (p) { if (!LJ_64 && (ctx->mode == BUILD_coffasm || ctx->mode == BUILD_peobj)) name[0] = '@'; else *p = '\0'; } p = (char *)malloc(strlen(name)+1); /* MSVC doesn't like strdup. */ strcpy(p, name); return p; } #define NRELOCSYM (sizeof(extnames)/sizeof(extnames[0])-1) static int relocmap[NRELOCSYM]; /* Collect external relocations. */ static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type) { if (ctx->nreloc >= BUILD_MAX_RELOC) { fprintf(stderr, "Error: too many relocations, increase BUILD_MAX_RELOC.\n"); exit(1); } if (relocmap[idx] < 0) { relocmap[idx] = ctx->nrelocsym; ctx->relocsym[ctx->nrelocsym] = sym_decorate(ctx, "", extnames[idx]); ctx->nrelocsym++; } ctx->reloc[ctx->nreloc].ofs = (int32_t)(addr - ctx->code); ctx->reloc[ctx->nreloc].sym = relocmap[idx]; ctx->reloc[ctx->nreloc].type = type; ctx->nreloc++; #if LJ_TARGET_XBOX360 return (int)(ctx->code - addr) + 4; /* Encode symbol offset of .text. */ #else return 0; /* Encode symbol offset of 0. */ #endif } /* Naive insertion sort. Performance doesn't matter here. */ static void sym_insert(BuildCtx *ctx, int32_t ofs, const char *prefix, const char *suffix) { ptrdiff_t i = ctx->nsym++; while (i > 0) { if (ctx->sym[i-1].ofs <= ofs) break; ctx->sym[i] = ctx->sym[i-1]; i--; } ctx->sym[i].ofs = ofs; ctx->sym[i].name = sym_decorate(ctx, prefix, suffix); } /* Build the machine code. */ static int build_code(BuildCtx *ctx) { int status; int i; /* Initialize DynASM structures. */ ctx->nglob = GLOB__MAX; ctx->glob = (void **)malloc(ctx->nglob*sizeof(void *)); memset(ctx->glob, 0, ctx->nglob*sizeof(void *)); ctx->nreloc = 0; ctx->globnames = globnames; ctx->relocsym = (const char **)malloc(NRELOCSYM*sizeof(const char *)); ctx->nrelocsym = 0; for (i = 0; i < (int)NRELOCSYM; i++) relocmap[i] = -1; ctx->dasm_ident = DASM_IDENT; ctx->dasm_arch = DASM_ARCH; dasm_init(Dst, DASM_MAXSECTION); dasm_setupglobal(Dst, ctx->glob, ctx->nglob); dasm_setup(Dst, build_actionlist); /* Call arch-specific backend to emit the code. */ ctx->npc = build_backend(ctx); /* Finalize the code. */ (void)dasm_checkstep(Dst, -1); if ((status = dasm_link(Dst, &ctx->codesz))) return status; ctx->code = (uint8_t *)malloc(ctx->codesz); if ((status = dasm_encode(Dst, (void *)ctx->code))) return status; /* Allocate symbol table and bytecode offsets. */ ctx->beginsym = sym_decorate(ctx, "", LABEL_PREFIX "vm_asm_begin"); ctx->sym = (BuildSym *)malloc((ctx->npc+ctx->nglob+1)*sizeof(BuildSym)); ctx->nsym = 0; ctx->bc_ofs = (int32_t *)malloc(ctx->npc*sizeof(int32_t)); /* Collect the opcodes (PC labels). */ for (i = 0; i < ctx->npc; i++) { int32_t ofs = dasm_getpclabel(Dst, i); if (ofs < 0) return 0x22000000|i; ctx->bc_ofs[i] = ofs; if ((LJ_HASJIT || !(i == BC_JFORI || i == BC_JFORL || i == BC_JITERL || i == BC_JLOOP || i == BC_IFORL || i == BC_IITERL || i == BC_ILOOP)) && (LJ_HASFFI || i != BC_KCDATA)) sym_insert(ctx, ofs, LABEL_PREFIX_BC, bc_names[i]); } /* Collect the globals (named labels). */ for (i = 0; i < ctx->nglob; i++) { const char *gl = globnames[i]; int len = (int)strlen(gl); if (!ctx->glob[i]) { fprintf(stderr, "Error: undefined global %s\n", gl); exit(2); } /* Skip the _Z symbols. */ if (!(len >= 2 && gl[len-2] == '_' && gl[len-1] == 'Z')) sym_insert(ctx, (int32_t)((uint8_t *)(ctx->glob[i]) - ctx->code), LABEL_PREFIX, globnames[i]); } /* Close the address range. */ sym_insert(ctx, (int32_t)ctx->codesz, "", ""); ctx->nsym--; dasm_free(Dst); return 0; } /* -- Generate VM enums --------------------------------------------------- */ const char *const bc_names[] = { #define BCNAME(name, ma, mb, mc, mt) #name, BCDEF(BCNAME) #undef BCNAME NULL }; const char *const ir_names[] = { #define IRNAME(name, m, m1, m2) #name, IRDEF(IRNAME) #undef IRNAME NULL }; const char *const irt_names[] = { #define IRTNAME(name, size) #name, IRTDEF(IRTNAME) #undef IRTNAME NULL }; const char *const irfpm_names[] = { #define FPMNAME(name) #name, IRFPMDEF(FPMNAME) #undef FPMNAME NULL }; const char *const irfield_names[] = { #define FLNAME(name, ofs) #name, IRFLDEF(FLNAME) #undef FLNAME NULL }; const char *const ircall_names[] = { #define IRCALLNAME(cond, name, nargs, kind, type, flags) #name, IRCALLDEF(IRCALLNAME) #undef IRCALLNAME NULL }; static const char *const trace_errors[] = { #define TREDEF(name, msg) msg, #include "lj_traceerr.h" NULL }; static const char *lower(char *buf, const char *s) { char *p = buf; while (*s) { *p++ = (*s >= 'A' && *s <= 'Z') ? *s+0x20 : *s; s++; } *p = '\0'; return buf; } /* Emit C source code for bytecode-related definitions. */ static void emit_bcdef(BuildCtx *ctx) { int i; fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_ofs[] = {\n"); for (i = 0; i < ctx->npc; i++) { if (i != 0) fprintf(ctx->fp, ",\n"); fprintf(ctx->fp, "%d", ctx->bc_ofs[i]); } } /* Emit VM definitions as Lua code for debug modules. */ static void emit_vmdef(BuildCtx *ctx) { char buf[80]; int i; fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); fprintf(ctx->fp, "module(...)\n\n"); fprintf(ctx->fp, "bcnames = \""); for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]); fprintf(ctx->fp, "\"\n\n"); fprintf(ctx->fp, "irnames = \""); for (i = 0; ir_names[i]; i++) fprintf(ctx->fp, "%-6s", ir_names[i]); fprintf(ctx->fp, "\"\n\n"); fprintf(ctx->fp, "irfpm = { [0]="); for (i = 0; irfpm_names[i]; i++) fprintf(ctx->fp, "\"%s\", ", lower(buf, irfpm_names[i])); fprintf(ctx->fp, "}\n\n"); fprintf(ctx->fp, "irfield = { [0]="); for (i = 0; irfield_names[i]; i++) { char *p; lower(buf, irfield_names[i]); p = strchr(buf, '_'); if (p) *p = '.'; fprintf(ctx->fp, "\"%s\", ", buf); } fprintf(ctx->fp, "}\n\n"); fprintf(ctx->fp, "ircall = {\n[0]="); for (i = 0; ircall_names[i]; i++) fprintf(ctx->fp, "\"%s\",\n", ircall_names[i]); fprintf(ctx->fp, "}\n\n"); fprintf(ctx->fp, "traceerr = {\n[0]="); for (i = 0; trace_errors[i]; i++) fprintf(ctx->fp, "\"%s\",\n", trace_errors[i]); fprintf(ctx->fp, "}\n\n"); } /* -- Argument parsing ---------------------------------------------------- */ /* Build mode names. */ static const char *const modenames[] = { #define BUILDNAME(name) #name, BUILDDEF(BUILDNAME) #undef BUILDNAME NULL }; /* Print usage information and exit. */ static void usage(void) { int i; fprintf(stderr, LUAJIT_VERSION " VM builder.\n"); fprintf(stderr, LUAJIT_COPYRIGHT ", " LUAJIT_URL "\n"); fprintf(stderr, "Target architecture: " LJ_ARCH_NAME "\n\n"); fprintf(stderr, "Usage: buildvm -m mode [-o outfile] [infiles...]\n\n"); fprintf(stderr, "Available modes:\n"); for (i = 0; i < BUILD__MAX; i++) fprintf(stderr, " %s\n", modenames[i]); exit(1); } /* Parse the output mode name. */ static BuildMode parsemode(const char *mode) { int i; for (i = 0; modenames[i]; i++) if (!strcmp(mode, modenames[i])) return (BuildMode)i; usage(); return (BuildMode)-1; } /* Parse arguments. */ static void parseargs(BuildCtx *ctx, char **argv) { const char *a; int i; ctx->mode = (BuildMode)-1; ctx->outname = "-"; for (i = 1; (a = argv[i]) != NULL; i++) { if (a[0] != '-') break; switch (a[1]) { case '-': if (a[2]) goto err; i++; goto ok; case '\0': goto ok; case 'm': i++; if (a[2] || argv[i] == NULL) goto err; ctx->mode = parsemode(argv[i]); break; case 'o': i++; if (a[2] || argv[i] == NULL) goto err; ctx->outname = argv[i]; break; default: err: usage(); break; } } ok: ctx->args = argv+i; if (ctx->mode == (BuildMode)-1) goto err; } int main(int argc, char **argv) { BuildCtx ctx_; BuildCtx *ctx = &ctx_; int status, binmode; if (sizeof(void *) != 4*LJ_32+8*LJ_64) { fprintf(stderr,"Error: pointer size mismatch in cross-build.\n"); fprintf(stderr,"Try: make HOST_CC=\"gcc -m32\" CROSS=...\n\n"); return 1; } UNUSED(argc); parseargs(ctx, argv); if ((status = build_code(ctx))) { fprintf(stderr,"Error: DASM error %08x\n", status); return 1; } switch (ctx->mode) { case BUILD_peobj: case BUILD_raw: binmode = 1; break; default: binmode = 0; break; } if (ctx->outname[0] == '-' && ctx->outname[1] == '\0') { ctx->fp = stdout; #if defined(_WIN32) if (binmode) _setmode(_fileno(stdout), _O_BINARY); /* Yuck. */ #endif } else if (!(ctx->fp = fopen(ctx->outname, binmode ? "wb" : "w"))) { fprintf(stderr, "Error: cannot open output file '%s': %s\n", ctx->outname, strerror(errno)); exit(1); } switch (ctx->mode) { case BUILD_elfasm: case BUILD_coffasm: case BUILD_machasm: emit_asm(ctx); emit_asm_debug(ctx); break; case BUILD_peobj: emit_peobj(ctx); break; case BUILD_raw: emit_raw(ctx); break; case BUILD_bcdef: emit_bcdef(ctx); emit_lib(ctx); break; case BUILD_vmdef: emit_vmdef(ctx); emit_lib(ctx); break; case BUILD_ffdef: case BUILD_libdef: case BUILD_recdef: emit_lib(ctx); break; case BUILD_folddef: emit_fold(ctx); break; default: break; } fflush(ctx->fp); if (ferror(ctx->fp)) { fprintf(stderr, "Error: cannot write to output file: %s\n", strerror(errno)); exit(1); } fclose(ctx->fp); return 0; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/host/buildvm.h ================================================ /* ** LuaJIT VM builder. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _BUILDVM_H #define _BUILDVM_H #include #include #include #include #include #include "lj_def.h" #include "lj_arch.h" /* Hardcoded limits. Increase as needed. */ #define BUILD_MAX_RELOC 200 /* Max. number of relocations. */ #define BUILD_MAX_FOLD 4096 /* Max. number of fold rules. */ /* Prefix for scanned library definitions. */ #define LIBDEF_PREFIX "LJLIB_" /* Prefix for scanned fold definitions. */ #define FOLDDEF_PREFIX "LJFOLD" /* Prefixes for generated labels. */ #define LABEL_PREFIX "lj_" #define LABEL_PREFIX_BC LABEL_PREFIX "BC_" #define LABEL_PREFIX_FF LABEL_PREFIX "ff_" #define LABEL_PREFIX_CF LABEL_PREFIX "cf_" #define LABEL_PREFIX_FFH LABEL_PREFIX "ffh_" #define LABEL_PREFIX_LIBCF LABEL_PREFIX "lib_cf_" #define LABEL_PREFIX_LIBINIT LABEL_PREFIX "lib_init_" /* Forward declaration. */ struct dasm_State; /* Build modes. */ #define BUILDDEF(_) \ _(elfasm) _(coffasm) _(machasm) _(peobj) _(raw) \ _(bcdef) _(ffdef) _(libdef) _(recdef) _(vmdef) \ _(folddef) typedef enum { #define BUILDENUM(name) BUILD_##name, BUILDDEF(BUILDENUM) #undef BUILDENUM BUILD__MAX } BuildMode; /* Code relocation. */ typedef struct BuildReloc { int32_t ofs; int sym; int type; } BuildReloc; typedef struct BuildSym { const char *name; int32_t ofs; } BuildSym; /* Build context structure. */ typedef struct BuildCtx { /* DynASM state pointer. Should be first member. */ struct dasm_State *D; /* Parsed command line. */ BuildMode mode; FILE *fp; const char *outname; char **args; /* Code and symbols generated by DynASM. */ uint8_t *code; size_t codesz; int npc, nglob, nsym, nreloc, nrelocsym; void **glob; BuildSym *sym; const char **relocsym; int32_t *bc_ofs; const char *beginsym; /* Strings generated by DynASM. */ const char *const *globnames; const char *dasm_ident; const char *dasm_arch; /* Relocations. */ BuildReloc reloc[BUILD_MAX_RELOC]; } BuildCtx; extern void owrite(BuildCtx *ctx, const void *ptr, size_t sz); extern void emit_asm(BuildCtx *ctx); extern void emit_peobj(BuildCtx *ctx); extern void emit_lib(BuildCtx *ctx); extern void emit_fold(BuildCtx *ctx); extern const char *const bc_names[]; extern const char *const ir_names[]; extern const char *const irt_names[]; extern const char *const irfpm_names[]; extern const char *const irfield_names[]; extern const char *const ircall_names[]; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/host/buildvm_asm.c ================================================ /* ** LuaJIT VM builder: Assembler source code emitter. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "buildvm.h" #include "lj_bc.h" /* ------------------------------------------------------------------------ */ #if LJ_TARGET_X86ORX64 /* Emit bytes piecewise as assembler text. */ static void emit_asm_bytes(BuildCtx *ctx, uint8_t *p, int n) { int i; for (i = 0; i < n; i++) { if ((i & 15) == 0) fprintf(ctx->fp, "\t.byte %d", p[i]); else fprintf(ctx->fp, ",%d", p[i]); if ((i & 15) == 15) putc('\n', ctx->fp); } if ((n & 15) != 0) putc('\n', ctx->fp); } /* Emit relocation */ static void emit_asm_reloc(BuildCtx *ctx, int type, const char *sym) { switch (ctx->mode) { case BUILD_elfasm: if (type) fprintf(ctx->fp, "\t.long %s-.-4\n", sym); else fprintf(ctx->fp, "\t.long %s\n", sym); break; case BUILD_coffasm: fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", sym); if (type) fprintf(ctx->fp, "\t.long %s-.-4\n", sym); else fprintf(ctx->fp, "\t.long %s\n", sym); break; default: /* BUILD_machasm for relative relocations handled below. */ fprintf(ctx->fp, "\t.long %s\n", sym); break; } } static const char *const jccnames[] = { "jo", "jno", "jb", "jnb", "jz", "jnz", "jbe", "ja", "js", "jns", "jpe", "jpo", "jl", "jge", "jle", "jg" }; /* Emit relocation for the incredibly stupid OSX assembler. */ static void emit_asm_reloc_mach(BuildCtx *ctx, uint8_t *cp, int n, const char *sym) { const char *opname = NULL; if (--n < 0) goto err; if (cp[n] == 0xe8) { opname = "call"; } else if (cp[n] == 0xe9) { opname = "jmp"; } else if (cp[n] >= 0x80 && cp[n] <= 0x8f && n > 0 && cp[n-1] == 0x0f) { opname = jccnames[cp[n]-0x80]; n--; } else { err: fprintf(stderr, "Error: unsupported opcode for %s symbol relocation.\n", sym); exit(1); } emit_asm_bytes(ctx, cp, n); fprintf(ctx->fp, "\t%s %s\n", opname, sym); } #else /* Emit words piecewise as assembler text. */ static void emit_asm_words(BuildCtx *ctx, uint8_t *p, int n) { int i; for (i = 0; i < n; i += 4) { if ((i & 15) == 0) fprintf(ctx->fp, "\t.long 0x%08x", *(uint32_t *)(p+i)); else fprintf(ctx->fp, ",0x%08x", *(uint32_t *)(p+i)); if ((i & 15) == 12) putc('\n', ctx->fp); } if ((n & 15) != 0) putc('\n', ctx->fp); } /* Emit relocation as part of an instruction. */ static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n, const char *sym) { uint32_t ins; emit_asm_words(ctx, p, n-4); ins = *(uint32_t *)(p+n-4); #if LJ_TARGET_ARM if ((ins & 0xff000000u) == 0xfa000000u) { fprintf(ctx->fp, "\tblx %s\n", sym); } else if ((ins & 0x0e000000u) == 0x0a000000u) { fprintf(ctx->fp, "\t%s%.2s %s\n", (ins & 0x01000000u) ? "bl" : "b", "eqnecsccmiplvsvchilsgeltgtle" + 2*(ins >> 28), sym); } else { fprintf(stderr, "Error: unsupported opcode %08x for %s symbol relocation.\n", ins, sym); exit(1); } #elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE #if LJ_TARGET_PS3 #define TOCPREFIX "." #else #define TOCPREFIX "" #endif if ((ins >> 26) == 16) { fprintf(ctx->fp, "\t%s %d, %d, " TOCPREFIX "%s\n", (ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym); } else if ((ins >> 26) == 18) { fprintf(ctx->fp, "\t%s " TOCPREFIX "%s\n", (ins & 1) ? "bl" : "b", sym); } else { fprintf(stderr, "Error: unsupported opcode %08x for %s symbol relocation.\n", ins, sym); exit(1); } #elif LJ_TARGET_MIPS fprintf(stderr, "Error: unsupported opcode %08x for %s symbol relocation.\n", ins, sym); exit(1); #else #error "missing relocation support for this architecture" #endif } #endif #if LJ_TARGET_ARM #define ELFASM_PX "%%" #else #define ELFASM_PX "@" #endif /* Emit an assembler label. */ static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc) { switch (ctx->mode) { case BUILD_elfasm: #if LJ_TARGET_PS3 if (!strncmp(name, "lj_vm_", 6) && strcmp(name, ctx->beginsym) && !strstr(name, "hook")) { fprintf(ctx->fp, "\n\t.globl %s\n" "\t.section \".opd\",\"aw\"\n" "%s:\n" "\t.long .%s,.TOC.@tocbase32\n" "\t.size %s,8\n" "\t.previous\n" "\t.globl .%s\n" "\t.hidden .%s\n" "\t.type .%s, " ELFASM_PX "function\n" "\t.size .%s, %d\n" ".%s:\n", name, name, name, name, name, name, name, name, size, name); break; } #endif fprintf(ctx->fp, "\n\t.globl %s\n" "\t.hidden %s\n" "\t.type %s, " ELFASM_PX "%s\n" "\t.size %s, %d\n" "%s:\n", name, name, name, isfunc ? "function" : "object", name, size, name); break; case BUILD_coffasm: fprintf(ctx->fp, "\n\t.globl %s\n", name); if (isfunc) fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", name); fprintf(ctx->fp, "%s:\n", name); break; case BUILD_machasm: fprintf(ctx->fp, "\n\t.private_extern %s\n" "%s:\n", name, name); break; default: break; } } /* Emit alignment. */ static void emit_asm_align(BuildCtx *ctx, int bits) { switch (ctx->mode) { case BUILD_elfasm: case BUILD_coffasm: fprintf(ctx->fp, "\t.p2align %d\n", bits); break; case BUILD_machasm: fprintf(ctx->fp, "\t.align %d\n", bits); break; default: break; } } /* ------------------------------------------------------------------------ */ /* Emit assembler source code. */ void emit_asm(BuildCtx *ctx) { int i, rel; fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch); fprintf(ctx->fp, "\t.text\n"); emit_asm_align(ctx, 4); #if LJ_TARGET_PS3 emit_asm_label(ctx, ctx->beginsym, ctx->codesz, 0); #else emit_asm_label(ctx, ctx->beginsym, 0, 0); #endif if (ctx->mode != BUILD_machasm) fprintf(ctx->fp, ".Lbegin:\n"); #if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND /* This should really be moved into buildvm_arm.dasc. */ fprintf(ctx->fp, ".fnstart\n" ".save {r4, r5, r6, r7, r8, r9, r10, r11, lr}\n" ".pad #28\n"); #endif #if LJ_TARGET_MIPS fprintf(ctx->fp, ".set nomips16\n.abicalls\n.set noreorder\n.set nomacro\n"); #endif for (i = rel = 0; i < ctx->nsym; i++) { int32_t ofs = ctx->sym[i].ofs; int32_t next = ctx->sym[i+1].ofs; #if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND && LJ_HASFFI if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call")) fprintf(ctx->fp, ".globl lj_err_unwind_arm\n" ".personality lj_err_unwind_arm\n" ".fnend\n" ".fnstart\n" ".save {r4, r5, r11, lr}\n" ".setfp r11, sp\n"); #endif emit_asm_label(ctx, ctx->sym[i].name, next - ofs, 1); while (rel < ctx->nreloc && ctx->reloc[rel].ofs <= next) { BuildReloc *r = &ctx->reloc[rel]; int n = r->ofs - ofs; #if LJ_TARGET_X86ORX64 if (ctx->mode == BUILD_machasm && r->type != 0) { emit_asm_reloc_mach(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]); } else { emit_asm_bytes(ctx, ctx->code+ofs, n); emit_asm_reloc(ctx, r->type, ctx->relocsym[r->sym]); } ofs += n+4; #else emit_asm_wordreloc(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]); ofs += n; #endif rel++; } #if LJ_TARGET_X86ORX64 emit_asm_bytes(ctx, ctx->code+ofs, next-ofs); #else emit_asm_words(ctx, ctx->code+ofs, next-ofs); #endif } #if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND fprintf(ctx->fp, #if !LJ_HASFFI ".globl lj_err_unwind_arm\n" ".personality lj_err_unwind_arm\n" #endif ".fnend\n"); #endif fprintf(ctx->fp, "\n"); switch (ctx->mode) { case BUILD_elfasm: #if !LJ_TARGET_PS3 fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); #endif #if LJ_TARGET_PPCSPE /* Soft-float ABI + SPE. */ fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n"); #elif LJ_TARGET_PPC && !LJ_TARGET_PS3 /* Hard-float ABI. */ fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n"); #endif /* fallthrough */ case BUILD_coffasm: fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident); break; case BUILD_machasm: fprintf(ctx->fp, "\t.cstring\n" "\t.ascii \"%s\\0\"\n", ctx->dasm_ident); break; default: break; } fprintf(ctx->fp, "\n"); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/host/buildvm_fold.c ================================================ /* ** LuaJIT VM builder: IR folding hash table generator. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "buildvm.h" #include "lj_obj.h" #include "lj_ir.h" /* Context for the folding hash table generator. */ static int lineno; static int funcidx; static uint32_t foldkeys[BUILD_MAX_FOLD]; static uint32_t nkeys; /* Try to fill the hash table with keys using the hash parameters. */ static int tryhash(uint32_t *htab, uint32_t sz, uint32_t r, int dorol) { uint32_t i; if (dorol && ((r & 31) == 0 || (r>>5) == 0)) return 0; /* Avoid zero rotates. */ memset(htab, 0xff, (sz+1)*sizeof(uint32_t)); for (i = 0; i < nkeys; i++) { uint32_t key = foldkeys[i]; uint32_t k = key & 0xffffff; uint32_t h = (dorol ? lj_rol(lj_rol(k, r>>5) - k, r&31) : (((k << (r>>5)) - k) << (r&31))) % sz; if (htab[h] != 0xffffffff) { /* Collision on primary slot. */ if (htab[h+1] != 0xffffffff) { /* Collision on secondary slot. */ /* Try to move the colliding key, if possible. */ if (h < sz-1 && htab[h+2] == 0xffffffff) { uint32_t k2 = htab[h+1] & 0xffffff; uint32_t h2 = (dorol ? lj_rol(lj_rol(k2, r>>5) - k2, r&31) : (((k2 << (r>>5)) - k2) << (r&31))) % sz; if (h2 != h+1) return 0; /* Cannot resolve collision. */ htab[h+2] = htab[h+1]; /* Move colliding key to secondary slot. */ } else { return 0; /* Collision. */ } } htab[h+1] = key; } else { htab[h] = key; } } return 1; /* Success, all keys could be stored. */ } /* Print the generated hash table. */ static void printhash(BuildCtx *ctx, uint32_t *htab, uint32_t sz) { uint32_t i; fprintf(ctx->fp, "static const uint32_t fold_hash[%d] = {\n0x%08x", sz+1, htab[0]); for (i = 1; i < sz+1; i++) fprintf(ctx->fp, ",\n0x%08x", htab[i]); fprintf(ctx->fp, "\n};\n\n"); } /* Exhaustive search for the shortest semi-perfect hash table. */ static void makehash(BuildCtx *ctx) { uint32_t htab[BUILD_MAX_FOLD*2+1]; uint32_t sz, r; /* Search for the smallest hash table with an odd size. */ for (sz = (nkeys|1); sz < BUILD_MAX_FOLD*2; sz += 2) { /* First try all shift hash combinations. */ for (r = 0; r < 32*32; r++) { if (tryhash(htab, sz, r, 0)) { printhash(ctx, htab, sz); fprintf(ctx->fp, "#define fold_hashkey(k)\t(((((k)<<%u)-(k))<<%u)%%%u)\n\n", r>>5, r&31, sz); return; } } /* Then try all rotate hash combinations. */ for (r = 0; r < 32*32; r++) { if (tryhash(htab, sz, r, 1)) { printhash(ctx, htab, sz); fprintf(ctx->fp, "#define fold_hashkey(k)\t(lj_rol(lj_rol((k),%u)-(k),%u)%%%u)\n\n", r>>5, r&31, sz); return; } } } fprintf(stderr, "Error: search for perfect hash failed\n"); exit(1); } /* Parse one token of a fold rule. */ static uint32_t nexttoken(char **pp, int allowlit, int allowany) { char *p = *pp; if (p) { uint32_t i; char *q = strchr(p, ' '); if (q) *q++ = '\0'; *pp = q; if (allowlit && !strncmp(p, "IRFPM_", 6)) { for (i = 0; irfpm_names[i]; i++) if (!strcmp(irfpm_names[i], p+6)) return i; } else if (allowlit && !strncmp(p, "IRFL_", 5)) { for (i = 0; irfield_names[i]; i++) if (!strcmp(irfield_names[i], p+5)) return i; } else if (allowlit && !strncmp(p, "IRCALL_", 7)) { for (i = 0; ircall_names[i]; i++) if (!strcmp(ircall_names[i], p+7)) return i; } else if (allowlit && !strncmp(p, "IRCONV_", 7)) { for (i = 0; irt_names[i]; i++) { const char *r = strchr(p+7, '_'); if (r && !strncmp(irt_names[i], p+7, r-(p+7))) { uint32_t j; for (j = 0; irt_names[j]; j++) if (!strcmp(irt_names[j], r+1)) return (i << 5) + j; } } } else if (allowlit && *p >= '0' && *p <= '9') { for (i = 0; *p >= '0' && *p <= '9'; p++) i = i*10 + (*p - '0'); if (*p == '\0') return i; } else if (allowany && !strcmp("any", p)) { return allowany; } else { for (i = 0; ir_names[i]; i++) if (!strcmp(ir_names[i], p)) return i; } fprintf(stderr, "Error: bad fold definition token \"%s\" at line %d\n", p, lineno); exit(1); } return 0; } /* Parse a fold rule. */ static void foldrule(char *p) { uint32_t op = nexttoken(&p, 0, 0); uint32_t left = nexttoken(&p, 0, 0x7f); uint32_t right = nexttoken(&p, 1, 0x3ff); uint32_t key = (funcidx << 24) | (op << 17) | (left << 10) | right; uint32_t i; if (nkeys >= BUILD_MAX_FOLD) { fprintf(stderr, "Error: too many fold rules, increase BUILD_MAX_FOLD.\n"); exit(1); } /* Simple insertion sort to detect duplicates. */ for (i = nkeys; i > 0; i--) { if ((foldkeys[i-1]&0xffffff) < (key & 0xffffff)) break; if ((foldkeys[i-1]&0xffffff) == (key & 0xffffff)) { fprintf(stderr, "Error: duplicate fold definition at line %d\n", lineno); exit(1); } foldkeys[i] = foldkeys[i-1]; } foldkeys[i] = key; nkeys++; } /* Emit C source code for IR folding hash table. */ void emit_fold(BuildCtx *ctx) { char buf[256]; /* We don't care about analyzing lines longer than that. */ const char *fname = ctx->args[0]; FILE *fp; if (fname == NULL) { fprintf(stderr, "Error: missing input filename\n"); exit(1); } if (fname[0] == '-' && fname[1] == '\0') { fp = stdin; } else { fp = fopen(fname, "r"); if (!fp) { fprintf(stderr, "Error: cannot open input file '%s': %s\n", fname, strerror(errno)); exit(1); } } fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); fprintf(ctx->fp, "static const FoldFunc fold_func[] = {\n"); lineno = 0; funcidx = 0; nkeys = 0; while (fgets(buf, sizeof(buf), fp) != NULL) { lineno++; /* The prefix must be at the start of a line, otherwise it's ignored. */ if (!strncmp(buf, FOLDDEF_PREFIX, sizeof(FOLDDEF_PREFIX)-1)) { char *p = buf+sizeof(FOLDDEF_PREFIX)-1; char *q = strchr(p, ')'); if (p[0] == '(' && q) { p++; *q = '\0'; foldrule(p); } else if ((p[0] == 'F' || p[0] == 'X') && p[1] == '(' && q) { p += 2; *q = '\0'; if (funcidx) fprintf(ctx->fp, ",\n"); if (p[-2] == 'X') fprintf(ctx->fp, " %s", p); else fprintf(ctx->fp, " fold_%s", p); funcidx++; } else { buf[strlen(buf)-1] = '\0'; fprintf(stderr, "Error: unknown fold definition tag %s%s at line %d\n", FOLDDEF_PREFIX, p, lineno); exit(1); } } } fclose(fp); fprintf(ctx->fp, "\n};\n\n"); makehash(ctx); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/host/buildvm_lib.c ================================================ /* ** LuaJIT VM builder: library definition compiler. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "buildvm.h" #include "lj_obj.h" #include "lj_lib.h" /* Context for library definitions. */ static uint8_t obuf[8192]; static uint8_t *optr; static char modname[80]; static size_t modnamelen; static char funcname[80]; static int modstate, regfunc; static int ffid, recffid, ffasmfunc; enum { REGFUNC_OK, REGFUNC_NOREG, REGFUNC_NOREGUV }; static void libdef_name(const char *p, int kind) { size_t n = strlen(p); if (kind != LIBINIT_STRING) { if (n > modnamelen && p[modnamelen] == '_' && !strncmp(p, modname, modnamelen)) { p += modnamelen+1; n -= modnamelen+1; } } if (n > LIBINIT_MAXSTR) { fprintf(stderr, "Error: string too long: '%s'\n", p); exit(1); } if (optr+1+n+2 > obuf+sizeof(obuf)) { /* +2 for caller. */ fprintf(stderr, "Error: output buffer overflow\n"); exit(1); } *optr++ = (uint8_t)(n | kind); memcpy(optr, p, n); optr += n; } static void libdef_endmodule(BuildCtx *ctx) { if (modstate != 0) { char line[80]; const uint8_t *p; int n; if (modstate == 1) fprintf(ctx->fp, " (lua_CFunction)0"); fprintf(ctx->fp, "\n};\n"); fprintf(ctx->fp, "static const uint8_t %s%s[] = {\n", LABEL_PREFIX_LIBINIT, modname); line[0] = '\0'; for (n = 0, p = obuf; p < optr; p++) { n += sprintf(line+n, "%d,", *p); if (n >= 75) { fprintf(ctx->fp, "%s\n", line); n = 0; line[0] = '\0'; } } fprintf(ctx->fp, "%s%d\n};\n#endif\n\n", line, LIBINIT_END); } } static void libdef_module(BuildCtx *ctx, char *p, int arg) { UNUSED(arg); if (ctx->mode == BUILD_libdef) { libdef_endmodule(ctx); optr = obuf; *optr++ = (uint8_t)ffid; *optr++ = (uint8_t)ffasmfunc; *optr++ = 0; /* Hash table size. */ modstate = 1; fprintf(ctx->fp, "#ifdef %sMODULE_%s\n", LIBDEF_PREFIX, p); fprintf(ctx->fp, "#undef %sMODULE_%s\n", LIBDEF_PREFIX, p); fprintf(ctx->fp, "static const lua_CFunction %s%s[] = {\n", LABEL_PREFIX_LIBCF, p); } modnamelen = strlen(p); if (modnamelen > sizeof(modname)-1) { fprintf(stderr, "Error: module name too long: '%s'\n", p); exit(1); } strcpy(modname, p); } static int find_ffofs(BuildCtx *ctx, const char *name) { int i; for (i = 0; i < ctx->nglob; i++) { const char *gl = ctx->globnames[i]; if (gl[0] == 'f' && gl[1] == 'f' && gl[2] == '_' && !strcmp(gl+3, name)) { return (int)((uint8_t *)ctx->glob[i] - ctx->code); } } fprintf(stderr, "Error: undefined fast function %s%s\n", LABEL_PREFIX_FF, name); exit(1); } static void libdef_func(BuildCtx *ctx, char *p, int arg) { if (arg != LIBINIT_CF) ffasmfunc++; if (ctx->mode == BUILD_libdef) { if (modstate == 0) { fprintf(stderr, "Error: no module for function definition %s\n", p); exit(1); } if (regfunc == REGFUNC_NOREG) { if (optr+1 > obuf+sizeof(obuf)) { fprintf(stderr, "Error: output buffer overflow\n"); exit(1); } *optr++ = LIBINIT_FFID; } else { if (arg != LIBINIT_ASM_) { if (modstate != 1) fprintf(ctx->fp, ",\n"); modstate = 2; fprintf(ctx->fp, " %s%s", arg ? LABEL_PREFIX_FFH : LABEL_PREFIX_CF, p); } if (regfunc != REGFUNC_NOREGUV) obuf[2]++; /* Bump hash table size. */ libdef_name(regfunc == REGFUNC_NOREGUV ? "" : p, arg); } } else if (ctx->mode == BUILD_ffdef) { fprintf(ctx->fp, "FFDEF(%s)\n", p); } else if (ctx->mode == BUILD_recdef) { if (strlen(p) > sizeof(funcname)-1) { fprintf(stderr, "Error: function name too long: '%s'\n", p); exit(1); } strcpy(funcname, p); } else if (ctx->mode == BUILD_vmdef) { int i; for (i = 1; p[i] && modname[i-1]; i++) if (p[i] == '_') p[i] = '.'; fprintf(ctx->fp, "\"%s\",\n", p); } else if (ctx->mode == BUILD_bcdef) { if (arg != LIBINIT_CF) fprintf(ctx->fp, ",\n%d", find_ffofs(ctx, p)); } ffid++; regfunc = REGFUNC_OK; } static uint32_t find_rec(char *name) { char *p = (char *)obuf; uint32_t n; for (n = 2; *p; n++) { if (strcmp(p, name) == 0) return n; p += strlen(p)+1; } if (p+strlen(name)+1 >= (char *)obuf+sizeof(obuf)) { fprintf(stderr, "Error: output buffer overflow\n"); exit(1); } strcpy(p, name); return n; } static void libdef_rec(BuildCtx *ctx, char *p, int arg) { UNUSED(arg); if (ctx->mode == BUILD_recdef) { char *q; uint32_t n; for (; recffid+1 < ffid; recffid++) fprintf(ctx->fp, ",\n0"); recffid = ffid; if (*p == '.') p = funcname; q = strchr(p, ' '); if (q) *q++ = '\0'; n = find_rec(p); if (q) fprintf(ctx->fp, ",\n0x%02x00+(%s)", n, q); else fprintf(ctx->fp, ",\n0x%02x00", n); } } static void memcpy_endian(void *dst, void *src, size_t n) { union { uint8_t b; uint32_t u; } host_endian; host_endian.u = 1; if (host_endian.b == LJ_ENDIAN_SELECT(1, 0)) { memcpy(dst, src, n); } else { size_t i; for (i = 0; i < n; i++) ((uint8_t *)dst)[i] = ((uint8_t *)src)[n-i-1]; } } static void libdef_push(BuildCtx *ctx, char *p, int arg) { UNUSED(arg); if (ctx->mode == BUILD_libdef) { int len = (int)strlen(p); if (*p == '"') { if (len > 1 && p[len-1] == '"') { p[len-1] = '\0'; libdef_name(p+1, LIBINIT_STRING); return; } } else if (*p >= '0' && *p <= '9') { char *ep; double d = strtod(p, &ep); if (*ep == '\0') { if (optr+1+sizeof(double) > obuf+sizeof(obuf)) { fprintf(stderr, "Error: output buffer overflow\n"); exit(1); } *optr++ = LIBINIT_NUMBER; memcpy_endian(optr, &d, sizeof(double)); optr += sizeof(double); return; } } else if (!strcmp(p, "lastcl")) { if (optr+1 > obuf+sizeof(obuf)) { fprintf(stderr, "Error: output buffer overflow\n"); exit(1); } *optr++ = LIBINIT_LASTCL; return; } else if (len > 4 && !strncmp(p, "top-", 4)) { if (optr+2 > obuf+sizeof(obuf)) { fprintf(stderr, "Error: output buffer overflow\n"); exit(1); } *optr++ = LIBINIT_COPY; *optr++ = (uint8_t)atoi(p+4); return; } fprintf(stderr, "Error: bad value for %sPUSH(%s)\n", LIBDEF_PREFIX, p); exit(1); } } static void libdef_set(BuildCtx *ctx, char *p, int arg) { UNUSED(arg); if (ctx->mode == BUILD_libdef) { if (p[0] == '!' && p[1] == '\0') p[0] = '\0'; /* Set env. */ libdef_name(p, LIBINIT_STRING); *optr++ = LIBINIT_SET; obuf[2]++; /* Bump hash table size. */ } } static void libdef_regfunc(BuildCtx *ctx, char *p, int arg) { UNUSED(ctx); UNUSED(p); regfunc = arg; } typedef void (*LibDefFunc)(BuildCtx *ctx, char *p, int arg); typedef struct LibDefHandler { const char *suffix; const char *stop; const LibDefFunc func; const int arg; } LibDefHandler; static const LibDefHandler libdef_handlers[] = { { "MODULE_", " \t\r\n", libdef_module, 0 }, { "CF(", ")", libdef_func, LIBINIT_CF }, { "ASM(", ")", libdef_func, LIBINIT_ASM }, { "ASM_(", ")", libdef_func, LIBINIT_ASM_ }, { "REC(", ")", libdef_rec, 0 }, { "PUSH(", ")", libdef_push, 0 }, { "SET(", ")", libdef_set, 0 }, { "NOREGUV", NULL, libdef_regfunc, REGFUNC_NOREGUV }, { "NOREG", NULL, libdef_regfunc, REGFUNC_NOREG }, { NULL, NULL, (LibDefFunc)0, 0 } }; /* Emit C source code for library function definitions. */ void emit_lib(BuildCtx *ctx) { const char *fname; if (ctx->mode == BUILD_ffdef || ctx->mode == BUILD_libdef || ctx->mode == BUILD_recdef) fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n"); else if (ctx->mode == BUILD_vmdef) fprintf(ctx->fp, "ffnames = {\n[0]=\"Lua\",\n\"C\",\n"); if (ctx->mode == BUILD_recdef) fprintf(ctx->fp, "static const uint16_t recff_idmap[] = {\n0,\n0x0100"); recffid = ffid = FF_C+1; ffasmfunc = 0; while ((fname = *ctx->args++)) { char buf[256]; /* We don't care about analyzing lines longer than that. */ FILE *fp; if (fname[0] == '-' && fname[1] == '\0') { fp = stdin; } else { fp = fopen(fname, "r"); if (!fp) { fprintf(stderr, "Error: cannot open input file '%s': %s\n", fname, strerror(errno)); exit(1); } } modstate = 0; regfunc = REGFUNC_OK; while (fgets(buf, sizeof(buf), fp) != NULL) { char *p; /* Simplistic pre-processor. Only handles top-level #if/#endif. */ if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { int ok = 1; if (!strcmp(buf, "#if LJ_52\n")) ok = LJ_52; else if (!strcmp(buf, "#if LJ_HASJIT\n")) ok = LJ_HASJIT; else if (!strcmp(buf, "#if LJ_HASFFI\n")) ok = LJ_HASFFI; if (!ok) { int lvl = 1; while (fgets(buf, sizeof(buf), fp) != NULL) { if (buf[0] == '#' && buf[1] == 'e' && buf[2] == 'n') { if (--lvl == 0) break; } else if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { lvl++; } } continue; } } for (p = buf; (p = strstr(p, LIBDEF_PREFIX)) != NULL; ) { const LibDefHandler *ldh; p += sizeof(LIBDEF_PREFIX)-1; for (ldh = libdef_handlers; ldh->suffix != NULL; ldh++) { size_t n, len = strlen(ldh->suffix); if (!strncmp(p, ldh->suffix, len)) { p += len; n = ldh->stop ? strcspn(p, ldh->stop) : 0; if (!p[n]) break; p[n] = '\0'; ldh->func(ctx, p, ldh->arg); p += n+1; break; } } if (ldh->suffix == NULL) { buf[strlen(buf)-1] = '\0'; fprintf(stderr, "Error: unknown library definition tag %s%s\n", LIBDEF_PREFIX, p); exit(1); } } } fclose(fp); if (ctx->mode == BUILD_libdef) { libdef_endmodule(ctx); } } if (ctx->mode == BUILD_ffdef) { fprintf(ctx->fp, "\n#undef FFDEF\n\n"); fprintf(ctx->fp, "#ifndef FF_NUM_ASMFUNC\n#define FF_NUM_ASMFUNC %d\n#endif\n\n", ffasmfunc); } else if (ctx->mode == BUILD_vmdef) { fprintf(ctx->fp, "}\n\n"); } else if (ctx->mode == BUILD_bcdef) { int i; fprintf(ctx->fp, "\n};\n\n"); fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_mode[] = {\n"); fprintf(ctx->fp, "BCDEF(BCMODE)\n"); for (i = ffasmfunc-1; i > 0; i--) fprintf(ctx->fp, "BCMODE_FF,\n"); fprintf(ctx->fp, "BCMODE_FF\n};\n\n"); } else if (ctx->mode == BUILD_recdef) { char *p = (char *)obuf; fprintf(ctx->fp, "\n};\n\n"); fprintf(ctx->fp, "static const RecordFunc recff_func[] = {\n" "recff_nyi,\n" "recff_c"); while (*p) { fprintf(ctx->fp, ",\nrecff_%s", p); p += strlen(p)+1; } fprintf(ctx->fp, "\n};\n\n"); } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/host/buildvm_peobj.c ================================================ /* ** LuaJIT VM builder: PE object emitter. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Only used for building on Windows, since we cannot assume the presence ** of a suitable assembler. The host and target byte order must match. */ #include "buildvm.h" #include "lj_bc.h" #if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC /* Context for PE object emitter. */ static char *strtab; static size_t strtabofs; /* -- PE object definitions ----------------------------------------------- */ /* PE header. */ typedef struct PEheader { uint16_t arch; uint16_t nsects; uint32_t time; uint32_t symtabofs; uint32_t nsyms; uint16_t opthdrsz; uint16_t flags; } PEheader; /* PE section. */ typedef struct PEsection { char name[8]; uint32_t vsize; uint32_t vaddr; uint32_t size; uint32_t ofs; uint32_t relocofs; uint32_t lineofs; uint16_t nreloc; uint16_t nline; uint32_t flags; } PEsection; /* PE relocation. */ typedef struct PEreloc { uint32_t vaddr; uint32_t symidx; uint16_t type; } PEreloc; /* Cannot use sizeof, because it pads up to the max. alignment. */ #define PEOBJ_RELOC_SIZE (4+4+2) /* PE symbol table entry. */ typedef struct PEsym { union { char name[8]; uint32_t nameref[2]; } n; uint32_t value; int16_t sect; uint16_t type; uint8_t scl; uint8_t naux; } PEsym; /* PE symbol table auxiliary entry for a section. */ typedef struct PEsymaux { uint32_t size; uint16_t nreloc; uint16_t nline; uint32_t cksum; uint16_t assoc; uint8_t comdatsel; uint8_t unused[3]; } PEsymaux; /* Cannot use sizeof, because it pads up to the max. alignment. */ #define PEOBJ_SYM_SIZE (8+4+2+2+1+1) /* PE object CPU specific defines. */ #if LJ_TARGET_X86 #define PEOBJ_ARCH_TARGET 0x014c #define PEOBJ_RELOC_REL32 0x14 /* MS: REL32, GNU: DISP32. */ #define PEOBJ_RELOC_DIR32 0x06 #define PEOBJ_RELOC_OFS 0 #define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */ #elif LJ_TARGET_X64 #define PEOBJ_ARCH_TARGET 0x8664 #define PEOBJ_RELOC_REL32 0x04 /* MS: REL32, GNU: DISP32. */ #define PEOBJ_RELOC_DIR32 0x02 #define PEOBJ_RELOC_ADDR32NB 0x03 #define PEOBJ_RELOC_OFS 0 #define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */ #elif LJ_TARGET_PPC #define PEOBJ_ARCH_TARGET 0x01f2 #define PEOBJ_RELOC_REL32 0x06 #define PEOBJ_RELOC_DIR32 0x02 #define PEOBJ_RELOC_OFS (-4) #define PEOBJ_TEXT_FLAGS 0x60400020 /* 60=r+x, 40=align8, 20=code. */ #endif /* Section numbers (0-based). */ enum { PEOBJ_SECT_ABS = -2, PEOBJ_SECT_UNDEF = -1, PEOBJ_SECT_TEXT, #if LJ_TARGET_X64 PEOBJ_SECT_PDATA, PEOBJ_SECT_XDATA, #endif PEOBJ_SECT_RDATA_Z, PEOBJ_NSECTIONS }; /* Symbol types. */ #define PEOBJ_TYPE_NULL 0 #define PEOBJ_TYPE_FUNC 0x20 /* Symbol storage class. */ #define PEOBJ_SCL_EXTERN 2 #define PEOBJ_SCL_STATIC 3 /* -- PE object emitter --------------------------------------------------- */ /* Emit PE object symbol. */ static void emit_peobj_sym(BuildCtx *ctx, const char *name, uint32_t value, int sect, int type, int scl) { PEsym sym; size_t len = strlen(name); if (!strtab) { /* Pass 1: only calculate string table length. */ if (len > 8) strtabofs += len+1; return; } if (len <= 8) { memcpy(sym.n.name, name, len); memset(sym.n.name+len, 0, 8-len); } else { sym.n.nameref[0] = 0; sym.n.nameref[1] = (uint32_t)strtabofs; memcpy(strtab + strtabofs, name, len); strtab[strtabofs+len] = 0; strtabofs += len+1; } sym.value = value; sym.sect = (int16_t)(sect+1); /* 1-based section number. */ sym.type = (uint16_t)type; sym.scl = (uint8_t)scl; sym.naux = 0; owrite(ctx, &sym, PEOBJ_SYM_SIZE); } /* Emit PE object section symbol. */ static void emit_peobj_sym_sect(BuildCtx *ctx, PEsection *pesect, int sect) { PEsym sym; PEsymaux aux; if (!strtab) return; /* Pass 1: no output. */ memcpy(sym.n.name, pesect[sect].name, 8); sym.value = 0; sym.sect = (int16_t)(sect+1); /* 1-based section number. */ sym.type = PEOBJ_TYPE_NULL; sym.scl = PEOBJ_SCL_STATIC; sym.naux = 1; owrite(ctx, &sym, PEOBJ_SYM_SIZE); memset(&aux, 0, sizeof(PEsymaux)); aux.size = pesect[sect].size; aux.nreloc = pesect[sect].nreloc; owrite(ctx, &aux, PEOBJ_SYM_SIZE); } /* Emit Windows PE object file. */ void emit_peobj(BuildCtx *ctx) { PEheader pehdr; PEsection pesect[PEOBJ_NSECTIONS]; uint32_t sofs; int i, nrsym; union { uint8_t b; uint32_t u; } host_endian; sofs = sizeof(PEheader) + PEOBJ_NSECTIONS*sizeof(PEsection); /* Fill in PE sections. */ memset(&pesect, 0, PEOBJ_NSECTIONS*sizeof(PEsection)); memcpy(pesect[PEOBJ_SECT_TEXT].name, ".text", sizeof(".text")-1); pesect[PEOBJ_SECT_TEXT].ofs = sofs; sofs += (pesect[PEOBJ_SECT_TEXT].size = (uint32_t)ctx->codesz); pesect[PEOBJ_SECT_TEXT].relocofs = sofs; sofs += (pesect[PEOBJ_SECT_TEXT].nreloc = (uint16_t)ctx->nreloc) * PEOBJ_RELOC_SIZE; /* Flags: 60 = read+execute, 50 = align16, 20 = code. */ pesect[PEOBJ_SECT_TEXT].flags = PEOBJ_TEXT_FLAGS; #if LJ_TARGET_X64 memcpy(pesect[PEOBJ_SECT_PDATA].name, ".pdata", sizeof(".pdata")-1); pesect[PEOBJ_SECT_PDATA].ofs = sofs; sofs += (pesect[PEOBJ_SECT_PDATA].size = 6*4); pesect[PEOBJ_SECT_PDATA].relocofs = sofs; sofs += (pesect[PEOBJ_SECT_PDATA].nreloc = 6) * PEOBJ_RELOC_SIZE; /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ pesect[PEOBJ_SECT_PDATA].flags = 0x40300040; memcpy(pesect[PEOBJ_SECT_XDATA].name, ".xdata", sizeof(".xdata")-1); pesect[PEOBJ_SECT_XDATA].ofs = sofs; sofs += (pesect[PEOBJ_SECT_XDATA].size = 8*2+4+6*2); /* See below. */ pesect[PEOBJ_SECT_XDATA].relocofs = sofs; sofs += (pesect[PEOBJ_SECT_XDATA].nreloc = 1) * PEOBJ_RELOC_SIZE; /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ pesect[PEOBJ_SECT_XDATA].flags = 0x40300040; #endif memcpy(pesect[PEOBJ_SECT_RDATA_Z].name, ".rdata$Z", sizeof(".rdata$Z")-1); pesect[PEOBJ_SECT_RDATA_Z].ofs = sofs; sofs += (pesect[PEOBJ_SECT_RDATA_Z].size = (uint32_t)strlen(ctx->dasm_ident)+1); /* Flags: 40 = read, 30 = align4, 40 = initialized data. */ pesect[PEOBJ_SECT_RDATA_Z].flags = 0x40300040; /* Fill in PE header. */ pehdr.arch = PEOBJ_ARCH_TARGET; pehdr.nsects = PEOBJ_NSECTIONS; pehdr.time = 0; /* Timestamp is optional. */ pehdr.symtabofs = sofs; pehdr.opthdrsz = 0; pehdr.flags = 0; /* Compute the size of the symbol table: ** @feat.00 + nsections*2 ** + asm_start + nsym ** + nrsym */ nrsym = ctx->nrelocsym; pehdr.nsyms = 1+PEOBJ_NSECTIONS*2 + 1+ctx->nsym + nrsym; #if LJ_TARGET_X64 pehdr.nsyms += 1; /* Symbol for lj_err_unwind_win64. */ #endif /* Write PE object header and all sections. */ owrite(ctx, &pehdr, sizeof(PEheader)); owrite(ctx, &pesect, sizeof(PEsection)*PEOBJ_NSECTIONS); /* Write .text section. */ host_endian.u = 1; if (host_endian.b != LJ_ENDIAN_SELECT(1, 0)) { #if LJ_TARGET_PPC uint32_t *p = (uint32_t *)ctx->code; int n = (int)(ctx->codesz >> 2); for (i = 0; i < n; i++, p++) *p = lj_bswap(*p); /* Byteswap .text section. */ #else fprintf(stderr, "Error: different byte order for host and target\n"); exit(1); #endif } owrite(ctx, ctx->code, ctx->codesz); for (i = 0; i < ctx->nreloc; i++) { PEreloc reloc; reloc.vaddr = (uint32_t)ctx->reloc[i].ofs + PEOBJ_RELOC_OFS; reloc.symidx = 1+2+ctx->reloc[i].sym; /* Reloc syms are after .text sym. */ reloc.type = ctx->reloc[i].type ? PEOBJ_RELOC_REL32 : PEOBJ_RELOC_DIR32; owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); } #if LJ_TARGET_X64 { /* Write .pdata section. */ uint32_t fcofs = (uint32_t)ctx->sym[ctx->nsym-1].ofs; uint32_t pdata[3]; /* Start of .text, end of .text and .xdata. */ PEreloc reloc; pdata[0] = 0; pdata[1] = fcofs; pdata[2] = 0; owrite(ctx, &pdata, sizeof(pdata)); pdata[0] = fcofs; pdata[1] = (uint32_t)ctx->codesz; pdata[2] = 20; owrite(ctx, &pdata, sizeof(pdata)); reloc.vaddr = 0; reloc.symidx = 1+2+nrsym+2+2+1; reloc.type = PEOBJ_RELOC_ADDR32NB; owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); reloc.vaddr = 4; reloc.symidx = 1+2+nrsym+2+2+1; reloc.type = PEOBJ_RELOC_ADDR32NB; owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); reloc.vaddr = 8; reloc.symidx = 1+2+nrsym+2; reloc.type = PEOBJ_RELOC_ADDR32NB; owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); reloc.vaddr = 12; reloc.symidx = 1+2+nrsym+2+2+1; reloc.type = PEOBJ_RELOC_ADDR32NB; owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); reloc.vaddr = 16; reloc.symidx = 1+2+nrsym+2+2+1; reloc.type = PEOBJ_RELOC_ADDR32NB; owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); reloc.vaddr = 20; reloc.symidx = 1+2+nrsym+2; reloc.type = PEOBJ_RELOC_ADDR32NB; owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); } { /* Write .xdata section. */ uint16_t xdata[8+2+6]; PEreloc reloc; xdata[0] = 0x01|0x08|0x10; /* Ver. 1, uhandler/ehandler, prolog size 0. */ xdata[1] = 0x0005; /* Number of unwind codes, no frame pointer. */ xdata[2] = 0x4200; /* Stack offset 4*8+8 = aword*5. */ xdata[3] = 0x3000; /* Push rbx. */ xdata[4] = 0x6000; /* Push rsi. */ xdata[5] = 0x7000; /* Push rdi. */ xdata[6] = 0x5000; /* Push rbp. */ xdata[7] = 0; /* Alignment. */ xdata[8] = xdata[9] = 0; /* Relocated address of exception handler. */ xdata[10] = 0x01; /* Ver. 1, no handler, prolog size 0. */ xdata[11] = 0x1504; /* Number of unwind codes, fp = rbp, fpofs = 16. */ xdata[12] = 0x0300; /* set_fpreg. */ xdata[13] = 0x0200; /* stack offset 0*8+8 = aword*1. */ xdata[14] = 0x3000; /* Push rbx. */ xdata[15] = 0x5000; /* Push rbp. */ owrite(ctx, &xdata, sizeof(xdata)); reloc.vaddr = 2*8; reloc.symidx = 1+2+nrsym+2+2; reloc.type = PEOBJ_RELOC_ADDR32NB; owrite(ctx, &reloc, PEOBJ_RELOC_SIZE); } #endif /* Write .rdata$Z section. */ owrite(ctx, ctx->dasm_ident, strlen(ctx->dasm_ident)+1); /* Write symbol table. */ strtab = NULL; /* 1st pass: collect string sizes. */ for (;;) { strtabofs = 4; /* Mark as SafeSEH compliant. */ emit_peobj_sym(ctx, "@feat.00", 1, PEOBJ_SECT_ABS, PEOBJ_TYPE_NULL, PEOBJ_SCL_STATIC); emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_TEXT); for (i = 0; i < nrsym; i++) emit_peobj_sym(ctx, ctx->relocsym[i], 0, PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); #if LJ_TARGET_X64 emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_PDATA); emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_XDATA); emit_peobj_sym(ctx, "lj_err_unwind_win64", 0, PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); #endif emit_peobj_sym(ctx, ctx->beginsym, 0, PEOBJ_SECT_TEXT, PEOBJ_TYPE_NULL, PEOBJ_SCL_EXTERN); for (i = 0; i < ctx->nsym; i++) emit_peobj_sym(ctx, ctx->sym[i].name, (uint32_t)ctx->sym[i].ofs, PEOBJ_SECT_TEXT, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN); emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA_Z); if (strtab) break; /* 2nd pass: alloc strtab, write syms and copy strings. */ strtab = (char *)malloc(strtabofs); *(uint32_t *)strtab = (uint32_t)strtabofs; } /* Write string table. */ owrite(ctx, strtab, strtabofs); } #else void emit_peobj(BuildCtx *ctx) { UNUSED(ctx); fprintf(stderr, "Error: no PE object support for this target\n"); exit(1); } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/host/genminilua.lua ================================================ ---------------------------------------------------------------------------- -- Lua script to generate a customized, minified version of Lua. -- The resulting 'minilua' is used for the build process of LuaJIT. ---------------------------------------------------------------------------- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- local sub, match, gsub = string.sub, string.match, string.gsub local LUA_VERSION = "5.1.5" local LUA_SOURCE local function usage() io.stderr:write("Usage: ", arg and arg[0] or "genminilua", " lua-", LUA_VERSION, "-source-dir\n") os.exit(1) end local function find_sources() LUA_SOURCE = arg and arg[1] if not LUA_SOURCE then usage() end if sub(LUA_SOURCE, -1) ~= "/" then LUA_SOURCE = LUA_SOURCE.."/" end local fp = io.open(LUA_SOURCE .. "lua.h") if not fp then LUA_SOURCE = LUA_SOURCE.."src/" fp = io.open(LUA_SOURCE .. "lua.h") if not fp then usage() end end local all = fp:read("*a") fp:close() if not match(all, 'LUA_RELEASE%s*"Lua '..LUA_VERSION..'"') then io.stderr:write("Error: version mismatch\n") usage() end end local LUA_FILES = { "lmem.c", "lobject.c", "ltm.c", "lfunc.c", "ldo.c", "lstring.c", "ltable.c", "lgc.c", "lstate.c", "ldebug.c", "lzio.c", "lopcodes.c", "llex.c", "lcode.c", "lparser.c", "lvm.c", "lapi.c", "lauxlib.c", "lbaselib.c", "ltablib.c", "liolib.c", "loslib.c", "lstrlib.c", "linit.c", } local REMOVE_LIB = {} gsub([[ collectgarbage dofile gcinfo getfenv getmetatable load print rawequal rawset select tostring xpcall foreach foreachi getn maxn setn popen tmpfile seek setvbuf __tostring clock date difftime execute getenv rename setlocale time tmpname dump gfind len reverse LUA_LOADLIBNAME LUA_MATHLIBNAME LUA_DBLIBNAME ]], "%S+", function(name) REMOVE_LIB[name] = true end) local REMOVE_EXTINC = { [""] = true, [""] = true, } local CUSTOM_MAIN = [[ typedef unsigned int UB; static UB barg(lua_State *L,int idx){ union{lua_Number n;U64 b;}bn; bn.n=lua_tonumber(L,idx)+6755399441055744.0; if (bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,"number"); return(UB)bn.b; } #define BRET(b) lua_pushnumber(L,(lua_Number)(int)(b));return 1; static int tobit(lua_State *L){ BRET(barg(L,1))} static int bnot(lua_State *L){ BRET(~barg(L,1))} static int band(lua_State *L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);BRET(b)} static int bor(lua_State *L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);BRET(b)} static int bxor(lua_State *L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);BRET(b)} static int lshift(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET(b<>n)} static int arshift(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((int)b>>n)} static int rol(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((b<>(32-n)))} static int ror(lua_State *L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((b>>n)|(b<<(32-n)))} static int bswap(lua_State *L){ UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} static int tohex(lua_State *L){ UB b=barg(L,1); int n=lua_isnone(L,2)?8:(int)barg(L,2); const char *hexdigits="0123456789abcdef"; char buf[8]; int i; if(n<0){n=-n;hexdigits="0123456789ABCDEF";} if(n>8)n=8; for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} lua_pushlstring(L,buf,(size_t)n); return 1; } static const struct luaL_Reg bitlib[] = { {"tobit",tobit}, {"bnot",bnot}, {"band",band}, {"bor",bor}, {"bxor",bxor}, {"lshift",lshift}, {"rshift",rshift}, {"arshift",arshift}, {"rol",rol}, {"ror",ror}, {"bswap",bswap}, {"tohex",tohex}, {NULL,NULL} }; int main(int argc, char **argv){ lua_State *L = luaL_newstate(); int i; luaL_openlibs(L); luaL_register(L, "bit", bitlib); if (argc < 2) return sizeof(void *); lua_createtable(L, 0, 1); lua_pushstring(L, argv[1]); lua_rawseti(L, -2, 0); lua_setglobal(L, "arg"); if (luaL_loadfile(L, argv[1])) goto err; for (i = 2; i < argc; i++) lua_pushstring(L, argv[i]); if (lua_pcall(L, argc - 2, 0, 0)) { err: fprintf(stderr, "Error: %s\n", lua_tostring(L, -1)); return 1; } lua_close(L); return 0; } ]] local function read_sources() local t = {} for i, name in ipairs(LUA_FILES) do local fp = assert(io.open(LUA_SOURCE..name, "r")) t[i] = fp:read("*a") assert(fp:close()) end t[#t+1] = CUSTOM_MAIN return table.concat(t) end local includes = {} local function merge_includes(src) return gsub(src, '#include%s*"([^"]*)"%s*\n', function(name) if includes[name] then return "" end includes[name] = true local fp = assert(io.open(LUA_SOURCE..name, "r")) local src = fp:read("*a") assert(fp:close()) src = gsub(src, "#ifndef%s+%w+_h\n#define%s+%w+_h\n", "") src = gsub(src, "#endif%s*$", "") return merge_includes(src) end) end local function get_license(src) return match(src, "/%*+\n%* Copyright %(.-%*/\n") end local function fold_lines(src) return gsub(src, "\\\n", " ") end local strings = {} local function save_str(str) local n = #strings+1 strings[n] = str return "\1"..n.."\2" end local function save_strings(src) src = gsub(src, '"[^"\n]*"', save_str) return gsub(src, "'[^'\n]*'", save_str) end local function restore_strings(src) return gsub(src, "\1(%d+)\2", function(numstr) return strings[tonumber(numstr)] end) end local function def_istrue(def) return def == "INT_MAX > 2147483640L" or def == "LUAI_BITSINT >= 32" or def == "SIZE_Bx < LUAI_BITSINT-1" or def == "cast" or def == "defined(LUA_CORE)" or def == "MINSTRTABSIZE" or def == "LUA_MINBUFFER" or def == "HARDSTACKTESTS" or def == "UNUSED" end local head, defs = {[[ #ifdef _MSC_VER typedef unsigned __int64 U64; #else typedef unsigned long long U64; #endif ]]}, {} local function preprocess(src) local t = { match(src, "^(.-)#") } local lvl, on, oldon = 0, true, {} for pp, def, txt in string.gmatch(src, "#(%w+) *([^\n]*)\n([^#]*)") do if pp == "if" or pp == "ifdef" or pp == "ifndef" then lvl = lvl + 1 oldon[lvl] = on on = def_istrue(def) elseif pp == "else" then if oldon[lvl] then if on == false then on = true else on = false end end elseif pp == "elif" then if oldon[lvl] then on = def_istrue(def) end elseif pp == "endif" then on = oldon[lvl] lvl = lvl - 1 elseif on then if pp == "include" then if not head[def] and not REMOVE_EXTINC[def] then head[def] = true head[#head+1] = "#include "..def.."\n" end elseif pp == "define" then local k, sp, v = match(def, "([%w_]+)(%s*)(.*)") if k and not (sp == "" and sub(v, 1, 1) == "(") then defs[k] = gsub(v, "%a[%w_]*", function(tok) return defs[tok] or tok end) else t[#t+1] = "#define "..def.."\n" end elseif pp ~= "undef" then error("unexpected directive: "..pp.." "..def) end end if on then t[#t+1] = txt end end return gsub(table.concat(t), "%a[%w_]*", function(tok) return defs[tok] or tok end) end local function merge_header(src, license) local hdr = string.format([[ /* This is a heavily customized and minimized copy of Lua %s. */ /* It's only used to build LuaJIT. It does NOT have all standard functions! */ ]], LUA_VERSION) return hdr..license..table.concat(head)..src end local function strip_unused1(src) return gsub(src, '( {"?([%w_]+)"?,%s+%a[%w_]*},\n)', function(line, func) return REMOVE_LIB[func] and "" or line end) end local function strip_unused2(src) return gsub(src, "Symbolic Execution.-}=", "") end local function strip_unused3(src) src = gsub(src, "extern", "static") src = gsub(src, "\nstatic([^\n]-)%(([^)]*)%)%(", "\nstatic%1 %2(") src = gsub(src, "#define lua_assert[^\n]*\n", "") src = gsub(src, "lua_assert%b();?", "") src = gsub(src, "default:\n}", "default:;\n}") src = gsub(src, "lua_lock%b();", "") src = gsub(src, "lua_unlock%b();", "") src = gsub(src, "luai_threadyield%b();", "") src = gsub(src, "luai_userstateopen%b();", "{}") src = gsub(src, "luai_userstate%w+%b();", "") src = gsub(src, "%(%(c==.*luaY_parser%)", "luaY_parser") src = gsub(src, "trydecpoint%(ls,seminfo%)", "luaX_lexerror(ls,\"malformed number\",TK_NUMBER)") src = gsub(src, "int c=luaZ_lookahead%b();", "") src = gsub(src, "luaL_register%(L,[^,]*,co_funcs%);\nreturn 2;", "return 1;") src = gsub(src, "getfuncname%b():", "NULL:") src = gsub(src, "getobjname%b():", "NULL:") src = gsub(src, "if%([^\n]*hookmask[^\n]*%)\n[^\n]*\n", "") src = gsub(src, "if%([^\n]*hookmask[^\n]*%)%b{}\n", "") src = gsub(src, "if%([^\n]*hookmask[^\n]*&&\n[^\n]*%b{}\n", "") src = gsub(src, "(twoto%b()%()", "%1(size_t)") src = gsub(src, "i #include #include #include #include #include #include #include #include #include #include typedef enum{ TM_INDEX, TM_NEWINDEX, TM_GC, TM_MODE, TM_EQ, TM_ADD, TM_SUB, TM_MUL, TM_DIV, TM_MOD, TM_POW, TM_UNM, TM_LEN, TM_LT, TM_LE, TM_CONCAT, TM_CALL, TM_N }TMS; enum OpMode{iABC,iABx,iAsBx}; typedef enum{ OP_MOVE, OP_LOADK, OP_LOADBOOL, OP_LOADNIL, OP_GETUPVAL, OP_GETGLOBAL, OP_GETTABLE, OP_SETGLOBAL, OP_SETUPVAL, OP_SETTABLE, OP_NEWTABLE, OP_SELF, OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_POW, OP_UNM, OP_NOT, OP_LEN, OP_CONCAT, OP_JMP, OP_EQ, OP_LT, OP_LE, OP_TEST, OP_TESTSET, OP_CALL, OP_TAILCALL, OP_RETURN, OP_FORLOOP, OP_FORPREP, OP_TFORLOOP, OP_SETLIST, OP_CLOSE, OP_CLOSURE, OP_VARARG }OpCode; enum OpArgMask{ OpArgN, OpArgU, OpArgR, OpArgK }; typedef enum{ VVOID, VNIL, VTRUE, VFALSE, VK, VKNUM, VLOCAL, VUPVAL, VGLOBAL, VINDEXED, VJMP, VRELOCABLE, VNONRELOC, VCALL, VVARARG }expkind; enum RESERVED{ TK_AND=257,TK_BREAK, TK_DO,TK_ELSE,TK_ELSEIF,TK_END,TK_FALSE,TK_FOR,TK_FUNCTION, TK_IF,TK_IN,TK_LOCAL,TK_NIL,TK_NOT,TK_OR,TK_REPEAT, TK_RETURN,TK_THEN,TK_TRUE,TK_UNTIL,TK_WHILE, TK_CONCAT,TK_DOTS,TK_EQ,TK_GE,TK_LE,TK_NE,TK_NUMBER, TK_NAME,TK_STRING,TK_EOS }; typedef enum BinOpr{ OPR_ADD,OPR_SUB,OPR_MUL,OPR_DIV,OPR_MOD,OPR_POW, OPR_CONCAT, OPR_NE,OPR_EQ, OPR_LT,OPR_LE,OPR_GT,OPR_GE, OPR_AND,OPR_OR, OPR_NOBINOPR }BinOpr; typedef enum UnOpr{OPR_MINUS,OPR_NOT,OPR_LEN,OPR_NOUNOPR}UnOpr; #define LUA_QL(x)"'"x"'" #define luai_apicheck(L,o){(void)L;} #define lua_number2str(s,n)sprintf((s),"%.14g",(n)) #define lua_str2number(s,p)strtod((s),(p)) #define luai_numadd(a,b)((a)+(b)) #define luai_numsub(a,b)((a)-(b)) #define luai_nummul(a,b)((a)*(b)) #define luai_numdiv(a,b)((a)/(b)) #define luai_nummod(a,b)((a)-floor((a)/(b))*(b)) #define luai_numpow(a,b)(pow(a,b)) #define luai_numunm(a)(-(a)) #define luai_numeq(a,b)((a)==(b)) #define luai_numlt(a,b)((a)<(b)) #define luai_numle(a,b)((a)<=(b)) #define luai_numisnan(a)(!luai_numeq((a),(a))) #define lua_number2int(i,d)((i)=(int)(d)) #define lua_number2integer(i,d)((i)=(lua_Integer)(d)) #define LUAI_THROW(L,c)longjmp((c)->b,1) #define LUAI_TRY(L,c,a)if(setjmp((c)->b)==0){a} #define lua_pclose(L,file)((void)((void)L,file),0) #define lua_upvalueindex(i)((-10002)-(i)) typedef struct lua_State lua_State; typedef int(*lua_CFunction)(lua_State*L); typedef const char*(*lua_Reader)(lua_State*L,void*ud,size_t*sz); typedef void*(*lua_Alloc)(void*ud,void*ptr,size_t osize,size_t nsize); typedef double lua_Number; typedef ptrdiff_t lua_Integer; static void lua_settop(lua_State*L,int idx); static int lua_type(lua_State*L,int idx); static const char* lua_tolstring(lua_State*L,int idx,size_t*len); static size_t lua_objlen(lua_State*L,int idx); static void lua_pushlstring(lua_State*L,const char*s,size_t l); static void lua_pushcclosure(lua_State*L,lua_CFunction fn,int n); static void lua_createtable(lua_State*L,int narr,int nrec); static void lua_setfield(lua_State*L,int idx,const char*k); #define lua_pop(L,n)lua_settop(L,-(n)-1) #define lua_newtable(L)lua_createtable(L,0,0) #define lua_pushcfunction(L,f)lua_pushcclosure(L,(f),0) #define lua_strlen(L,i)lua_objlen(L,(i)) #define lua_isfunction(L,n)(lua_type(L,(n))==6) #define lua_istable(L,n)(lua_type(L,(n))==5) #define lua_isnil(L,n)(lua_type(L,(n))==0) #define lua_isboolean(L,n)(lua_type(L,(n))==1) #define lua_isnone(L,n)(lua_type(L,(n))==(-1)) #define lua_isnoneornil(L,n)(lua_type(L,(n))<=0) #define lua_pushliteral(L,s)lua_pushlstring(L,""s,(sizeof(s)/sizeof(char))-1) #define lua_setglobal(L,s)lua_setfield(L,(-10002),(s)) #define lua_tostring(L,i)lua_tolstring(L,(i),NULL) typedef struct lua_Debug lua_Debug; typedef void(*lua_Hook)(lua_State*L,lua_Debug*ar); struct lua_Debug{ int event; const char*name; const char*namewhat; const char*what; const char*source; int currentline; int nups; int linedefined; int lastlinedefined; char short_src[60]; int i_ci; }; typedef unsigned int lu_int32; typedef size_t lu_mem; typedef ptrdiff_t l_mem; typedef unsigned char lu_byte; #define IntPoint(p)((unsigned int)(lu_mem)(p)) typedef union{double u;void*s;long l;}L_Umaxalign; typedef double l_uacNumber; #define check_exp(c,e)(e) #define UNUSED(x)((void)(x)) #define cast(t,exp)((t)(exp)) #define cast_byte(i)cast(lu_byte,(i)) #define cast_num(i)cast(lua_Number,(i)) #define cast_int(i)cast(int,(i)) typedef lu_int32 Instruction; #define condhardstacktests(x)((void)0) typedef union GCObject GCObject; typedef struct GCheader{ GCObject*next;lu_byte tt;lu_byte marked; }GCheader; typedef union{ GCObject*gc; void*p; lua_Number n; int b; }Value; typedef struct lua_TValue{ Value value;int tt; }TValue; #define ttisnil(o)(ttype(o)==0) #define ttisnumber(o)(ttype(o)==3) #define ttisstring(o)(ttype(o)==4) #define ttistable(o)(ttype(o)==5) #define ttisfunction(o)(ttype(o)==6) #define ttisboolean(o)(ttype(o)==1) #define ttisuserdata(o)(ttype(o)==7) #define ttisthread(o)(ttype(o)==8) #define ttislightuserdata(o)(ttype(o)==2) #define ttype(o)((o)->tt) #define gcvalue(o)check_exp(iscollectable(o),(o)->value.gc) #define pvalue(o)check_exp(ttislightuserdata(o),(o)->value.p) #define nvalue(o)check_exp(ttisnumber(o),(o)->value.n) #define rawtsvalue(o)check_exp(ttisstring(o),&(o)->value.gc->ts) #define tsvalue(o)(&rawtsvalue(o)->tsv) #define rawuvalue(o)check_exp(ttisuserdata(o),&(o)->value.gc->u) #define uvalue(o)(&rawuvalue(o)->uv) #define clvalue(o)check_exp(ttisfunction(o),&(o)->value.gc->cl) #define hvalue(o)check_exp(ttistable(o),&(o)->value.gc->h) #define bvalue(o)check_exp(ttisboolean(o),(o)->value.b) #define thvalue(o)check_exp(ttisthread(o),&(o)->value.gc->th) #define l_isfalse(o)(ttisnil(o)||(ttisboolean(o)&&bvalue(o)==0)) #define checkconsistency(obj) #define checkliveness(g,obj) #define setnilvalue(obj)((obj)->tt=0) #define setnvalue(obj,x){TValue*i_o=(obj);i_o->value.n=(x);i_o->tt=3;} #define setbvalue(obj,x){TValue*i_o=(obj);i_o->value.b=(x);i_o->tt=1;} #define setsvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=4;checkliveness(G(L),i_o);} #define setuvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=7;checkliveness(G(L),i_o);} #define setthvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=8;checkliveness(G(L),i_o);} #define setclvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=6;checkliveness(G(L),i_o);} #define sethvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=5;checkliveness(G(L),i_o);} #define setptvalue(L,obj,x){TValue*i_o=(obj);i_o->value.gc=cast(GCObject*,(x));i_o->tt=(8+1);checkliveness(G(L),i_o);} #define setobj(L,obj1,obj2){const TValue*o2=(obj2);TValue*o1=(obj1);o1->value=o2->value;o1->tt=o2->tt;checkliveness(G(L),o1);} #define setttype(obj,tt)(ttype(obj)=(tt)) #define iscollectable(o)(ttype(o)>=4) typedef TValue*StkId; typedef union TString{ L_Umaxalign dummy; struct{ GCObject*next;lu_byte tt;lu_byte marked; lu_byte reserved; unsigned int hash; size_t len; }tsv; }TString; #define getstr(ts)cast(const char*,(ts)+1) #define svalue(o)getstr(rawtsvalue(o)) typedef union Udata{ L_Umaxalign dummy; struct{ GCObject*next;lu_byte tt;lu_byte marked; struct Table*metatable; struct Table*env; size_t len; }uv; }Udata; typedef struct Proto{ GCObject*next;lu_byte tt;lu_byte marked; TValue*k; Instruction*code; struct Proto**p; int*lineinfo; struct LocVar*locvars; TString**upvalues; TString*source; int sizeupvalues; int sizek; int sizecode; int sizelineinfo; int sizep; int sizelocvars; int linedefined; int lastlinedefined; GCObject*gclist; lu_byte nups; lu_byte numparams; lu_byte is_vararg; lu_byte maxstacksize; }Proto; typedef struct LocVar{ TString*varname; int startpc; int endpc; }LocVar; typedef struct UpVal{ GCObject*next;lu_byte tt;lu_byte marked; TValue*v; union{ TValue value; struct{ struct UpVal*prev; struct UpVal*next; }l; }u; }UpVal; typedef struct CClosure{ GCObject*next;lu_byte tt;lu_byte marked;lu_byte isC;lu_byte nupvalues;GCObject*gclist;struct Table*env; lua_CFunction f; TValue upvalue[1]; }CClosure; typedef struct LClosure{ GCObject*next;lu_byte tt;lu_byte marked;lu_byte isC;lu_byte nupvalues;GCObject*gclist;struct Table*env; struct Proto*p; UpVal*upvals[1]; }LClosure; typedef union Closure{ CClosure c; LClosure l; }Closure; #define iscfunction(o)(ttype(o)==6&&clvalue(o)->c.isC) typedef union TKey{ struct{ Value value;int tt; struct Node*next; }nk; TValue tvk; }TKey; typedef struct Node{ TValue i_val; TKey i_key; }Node; typedef struct Table{ GCObject*next;lu_byte tt;lu_byte marked; lu_byte flags; lu_byte lsizenode; struct Table*metatable; TValue*array; Node*node; Node*lastfree; GCObject*gclist; int sizearray; }Table; #define lmod(s,size)(check_exp((size&(size-1))==0,(cast(int,(s)&((size)-1))))) #define twoto(x)((size_t)1<<(x)) #define sizenode(t)(twoto((t)->lsizenode)) static const TValue luaO_nilobject_; #define ceillog2(x)(luaO_log2((x)-1)+1) static int luaO_log2(unsigned int x); #define gfasttm(g,et,e)((et)==NULL?NULL:((et)->flags&(1u<<(e)))?NULL:luaT_gettm(et,e,(g)->tmname[e])) #define fasttm(l,et,e)gfasttm(G(l),et,e) static const TValue*luaT_gettm(Table*events,TMS event,TString*ename); #define luaM_reallocv(L,b,on,n,e)((cast(size_t,(n)+1)<=((size_t)(~(size_t)0)-2)/(e))?luaM_realloc_(L,(b),(on)*(e),(n)*(e)):luaM_toobig(L)) #define luaM_freemem(L,b,s)luaM_realloc_(L,(b),(s),0) #define luaM_free(L,b)luaM_realloc_(L,(b),sizeof(*(b)),0) #define luaM_freearray(L,b,n,t)luaM_reallocv(L,(b),n,0,sizeof(t)) #define luaM_malloc(L,t)luaM_realloc_(L,NULL,0,(t)) #define luaM_new(L,t)cast(t*,luaM_malloc(L,sizeof(t))) #define luaM_newvector(L,n,t)cast(t*,luaM_reallocv(L,NULL,0,n,sizeof(t))) #define luaM_growvector(L,v,nelems,size,t,limit,e)if((nelems)+1>(size))((v)=cast(t*,luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) #define luaM_reallocvector(L,v,oldn,n,t)((v)=cast(t*,luaM_reallocv(L,v,oldn,n,sizeof(t)))) static void*luaM_realloc_(lua_State*L,void*block,size_t oldsize, size_t size); static void*luaM_toobig(lua_State*L); static void*luaM_growaux_(lua_State*L,void*block,int*size, size_t size_elem,int limit, const char*errormsg); typedef struct Zio ZIO; #define char2int(c)cast(int,cast(unsigned char,(c))) #define zgetc(z)(((z)->n--)>0?char2int(*(z)->p++):luaZ_fill(z)) typedef struct Mbuffer{ char*buffer; size_t n; size_t buffsize; }Mbuffer; #define luaZ_initbuffer(L,buff)((buff)->buffer=NULL,(buff)->buffsize=0) #define luaZ_buffer(buff)((buff)->buffer) #define luaZ_sizebuffer(buff)((buff)->buffsize) #define luaZ_bufflen(buff)((buff)->n) #define luaZ_resetbuffer(buff)((buff)->n=0) #define luaZ_resizebuffer(L,buff,size)(luaM_reallocvector(L,(buff)->buffer,(buff)->buffsize,size,char),(buff)->buffsize=size) #define luaZ_freebuffer(L,buff)luaZ_resizebuffer(L,buff,0) struct Zio{ size_t n; const char*p; lua_Reader reader; void*data; lua_State*L; }; static int luaZ_fill(ZIO*z); struct lua_longjmp; #define gt(L)(&L->l_gt) #define registry(L)(&G(L)->l_registry) typedef struct stringtable{ GCObject**hash; lu_int32 nuse; int size; }stringtable; typedef struct CallInfo{ StkId base; StkId func; StkId top; const Instruction*savedpc; int nresults; int tailcalls; }CallInfo; #define curr_func(L)(clvalue(L->ci->func)) #define ci_func(ci)(clvalue((ci)->func)) #define f_isLua(ci)(!ci_func(ci)->c.isC) #define isLua(ci)(ttisfunction((ci)->func)&&f_isLua(ci)) typedef struct global_State{ stringtable strt; lua_Alloc frealloc; void*ud; lu_byte currentwhite; lu_byte gcstate; int sweepstrgc; GCObject*rootgc; GCObject**sweepgc; GCObject*gray; GCObject*grayagain; GCObject*weak; GCObject*tmudata; Mbuffer buff; lu_mem GCthreshold; lu_mem totalbytes; lu_mem estimate; lu_mem gcdept; int gcpause; int gcstepmul; lua_CFunction panic; TValue l_registry; struct lua_State*mainthread; UpVal uvhead; struct Table*mt[(8+1)]; TString*tmname[TM_N]; }global_State; struct lua_State{ GCObject*next;lu_byte tt;lu_byte marked; lu_byte status; StkId top; StkId base; global_State*l_G; CallInfo*ci; const Instruction*savedpc; StkId stack_last; StkId stack; CallInfo*end_ci; CallInfo*base_ci; int stacksize; int size_ci; unsigned short nCcalls; unsigned short baseCcalls; lu_byte hookmask; lu_byte allowhook; int basehookcount; int hookcount; lua_Hook hook; TValue l_gt; TValue env; GCObject*openupval; GCObject*gclist; struct lua_longjmp*errorJmp; ptrdiff_t errfunc; }; #define G(L)(L->l_G) union GCObject{ GCheader gch; union TString ts; union Udata u; union Closure cl; struct Table h; struct Proto p; struct UpVal uv; struct lua_State th; }; #define rawgco2ts(o)check_exp((o)->gch.tt==4,&((o)->ts)) #define gco2ts(o)(&rawgco2ts(o)->tsv) #define rawgco2u(o)check_exp((o)->gch.tt==7,&((o)->u)) #define gco2u(o)(&rawgco2u(o)->uv) #define gco2cl(o)check_exp((o)->gch.tt==6,&((o)->cl)) #define gco2h(o)check_exp((o)->gch.tt==5,&((o)->h)) #define gco2p(o)check_exp((o)->gch.tt==(8+1),&((o)->p)) #define gco2uv(o)check_exp((o)->gch.tt==(8+2),&((o)->uv)) #define ngcotouv(o)check_exp((o)==NULL||(o)->gch.tt==(8+2),&((o)->uv)) #define gco2th(o)check_exp((o)->gch.tt==8,&((o)->th)) #define obj2gco(v)(cast(GCObject*,(v))) static void luaE_freethread(lua_State*L,lua_State*L1); #define pcRel(pc,p)(cast(int,(pc)-(p)->code)-1) #define getline_(f,pc)(((f)->lineinfo)?(f)->lineinfo[pc]:0) #define resethookcount(L)(L->hookcount=L->basehookcount) static void luaG_typeerror(lua_State*L,const TValue*o, const char*opname); static void luaG_runerror(lua_State*L,const char*fmt,...); #define luaD_checkstack(L,n)if((char*)L->stack_last-(char*)L->top<=(n)*(int)sizeof(TValue))luaD_growstack(L,n);else condhardstacktests(luaD_reallocstack(L,L->stacksize-5-1)); #define incr_top(L){luaD_checkstack(L,1);L->top++;} #define savestack(L,p)((char*)(p)-(char*)L->stack) #define restorestack(L,n)((TValue*)((char*)L->stack+(n))) #define saveci(L,p)((char*)(p)-(char*)L->base_ci) #define restoreci(L,n)((CallInfo*)((char*)L->base_ci+(n))) typedef void(*Pfunc)(lua_State*L,void*ud); static int luaD_poscall(lua_State*L,StkId firstResult); static void luaD_reallocCI(lua_State*L,int newsize); static void luaD_reallocstack(lua_State*L,int newsize); static void luaD_growstack(lua_State*L,int n); static void luaD_throw(lua_State*L,int errcode); static void*luaM_growaux_(lua_State*L,void*block,int*size,size_t size_elems, int limit,const char*errormsg){ void*newblock; int newsize; if(*size>=limit/2){ if(*size>=limit) luaG_runerror(L,errormsg); newsize=limit; } else{ newsize=(*size)*2; if(newsize<4) newsize=4; } newblock=luaM_reallocv(L,block,*size,newsize,size_elems); *size=newsize; return newblock; } static void*luaM_toobig(lua_State*L){ luaG_runerror(L,"memory allocation error: block too big"); return NULL; } static void*luaM_realloc_(lua_State*L,void*block,size_t osize,size_t nsize){ global_State*g=G(L); block=(*g->frealloc)(g->ud,block,osize,nsize); if(block==NULL&&nsize>0) luaD_throw(L,4); g->totalbytes=(g->totalbytes-osize)+nsize; return block; } #define resetbits(x,m)((x)&=cast(lu_byte,~(m))) #define setbits(x,m)((x)|=(m)) #define testbits(x,m)((x)&(m)) #define bitmask(b)(1<<(b)) #define bit2mask(b1,b2)(bitmask(b1)|bitmask(b2)) #define l_setbit(x,b)setbits(x,bitmask(b)) #define resetbit(x,b)resetbits(x,bitmask(b)) #define testbit(x,b)testbits(x,bitmask(b)) #define set2bits(x,b1,b2)setbits(x,(bit2mask(b1,b2))) #define reset2bits(x,b1,b2)resetbits(x,(bit2mask(b1,b2))) #define test2bits(x,b1,b2)testbits(x,(bit2mask(b1,b2))) #define iswhite(x)test2bits((x)->gch.marked,0,1) #define isblack(x)testbit((x)->gch.marked,2) #define isgray(x)(!isblack(x)&&!iswhite(x)) #define otherwhite(g)(g->currentwhite^bit2mask(0,1)) #define isdead(g,v)((v)->gch.marked&otherwhite(g)&bit2mask(0,1)) #define changewhite(x)((x)->gch.marked^=bit2mask(0,1)) #define gray2black(x)l_setbit((x)->gch.marked,2) #define valiswhite(x)(iscollectable(x)&&iswhite(gcvalue(x))) #define luaC_white(g)cast(lu_byte,(g)->currentwhite&bit2mask(0,1)) #define luaC_checkGC(L){condhardstacktests(luaD_reallocstack(L,L->stacksize-5-1));if(G(L)->totalbytes>=G(L)->GCthreshold)luaC_step(L);} #define luaC_barrier(L,p,v){if(valiswhite(v)&&isblack(obj2gco(p)))luaC_barrierf(L,obj2gco(p),gcvalue(v));} #define luaC_barriert(L,t,v){if(valiswhite(v)&&isblack(obj2gco(t)))luaC_barrierback(L,t);} #define luaC_objbarrier(L,p,o){if(iswhite(obj2gco(o))&&isblack(obj2gco(p)))luaC_barrierf(L,obj2gco(p),obj2gco(o));} #define luaC_objbarriert(L,t,o){if(iswhite(obj2gco(o))&&isblack(obj2gco(t)))luaC_barrierback(L,t);} static void luaC_step(lua_State*L); static void luaC_link(lua_State*L,GCObject*o,lu_byte tt); static void luaC_linkupval(lua_State*L,UpVal*uv); static void luaC_barrierf(lua_State*L,GCObject*o,GCObject*v); static void luaC_barrierback(lua_State*L,Table*t); #define sizestring(s)(sizeof(union TString)+((s)->len+1)*sizeof(char)) #define sizeudata(u)(sizeof(union Udata)+(u)->len) #define luaS_new(L,s)(luaS_newlstr(L,s,strlen(s))) #define luaS_newliteral(L,s)(luaS_newlstr(L,""s,(sizeof(s)/sizeof(char))-1)) #define luaS_fix(s)l_setbit((s)->tsv.marked,5) static TString*luaS_newlstr(lua_State*L,const char*str,size_t l); #define tostring(L,o)((ttype(o)==4)||(luaV_tostring(L,o))) #define tonumber(o,n)(ttype(o)==3||(((o)=luaV_tonumber(o,n))!=NULL)) #define equalobj(L,o1,o2)(ttype(o1)==ttype(o2)&&luaV_equalval(L,o1,o2)) static int luaV_equalval(lua_State*L,const TValue*t1,const TValue*t2); static const TValue*luaV_tonumber(const TValue*obj,TValue*n); static int luaV_tostring(lua_State*L,StkId obj); static void luaV_execute(lua_State*L,int nexeccalls); static void luaV_concat(lua_State*L,int total,int last); static const TValue luaO_nilobject_={{NULL},0}; static int luaO_int2fb(unsigned int x){ int e=0; while(x>=16){ x=(x+1)>>1; e++; } if(x<8)return x; else return((e+1)<<3)|(cast_int(x)-8); } static int luaO_fb2int(int x){ int e=(x>>3)&31; if(e==0)return x; else return((x&7)+8)<<(e-1); } static int luaO_log2(unsigned int x){ static const lu_byte log_2[256]={ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 }; int l=-1; while(x>=256){l+=8;x>>=8;} return l+log_2[x]; } static int luaO_rawequalObj(const TValue*t1,const TValue*t2){ if(ttype(t1)!=ttype(t2))return 0; else switch(ttype(t1)){ case 0: return 1; case 3: return luai_numeq(nvalue(t1),nvalue(t2)); case 1: return bvalue(t1)==bvalue(t2); case 2: return pvalue(t1)==pvalue(t2); default: return gcvalue(t1)==gcvalue(t2); } } static int luaO_str2d(const char*s,lua_Number*result){ char*endptr; *result=lua_str2number(s,&endptr); if(endptr==s)return 0; if(*endptr=='x'||*endptr=='X') *result=cast_num(strtoul(s,&endptr,16)); if(*endptr=='\0')return 1; while(isspace(cast(unsigned char,*endptr)))endptr++; if(*endptr!='\0')return 0; return 1; } static void pushstr(lua_State*L,const char*str){ setsvalue(L,L->top,luaS_new(L,str)); incr_top(L); } static const char*luaO_pushvfstring(lua_State*L,const char*fmt,va_list argp){ int n=1; pushstr(L,""); for(;;){ const char*e=strchr(fmt,'%'); if(e==NULL)break; setsvalue(L,L->top,luaS_newlstr(L,fmt,e-fmt)); incr_top(L); switch(*(e+1)){ case's':{ const char*s=va_arg(argp,char*); if(s==NULL)s="(null)"; pushstr(L,s); break; } case'c':{ char buff[2]; buff[0]=cast(char,va_arg(argp,int)); buff[1]='\0'; pushstr(L,buff); break; } case'd':{ setnvalue(L->top,cast_num(va_arg(argp,int))); incr_top(L); break; } case'f':{ setnvalue(L->top,cast_num(va_arg(argp,l_uacNumber))); incr_top(L); break; } case'p':{ char buff[4*sizeof(void*)+8]; sprintf(buff,"%p",va_arg(argp,void*)); pushstr(L,buff); break; } case'%':{ pushstr(L,"%"); break; } default:{ char buff[3]; buff[0]='%'; buff[1]=*(e+1); buff[2]='\0'; pushstr(L,buff); break; } } n+=2; fmt=e+2; } pushstr(L,fmt); luaV_concat(L,n+1,cast_int(L->top-L->base)-1); L->top-=n; return svalue(L->top-1); } static const char*luaO_pushfstring(lua_State*L,const char*fmt,...){ const char*msg; va_list argp; va_start(argp,fmt); msg=luaO_pushvfstring(L,fmt,argp); va_end(argp); return msg; } static void luaO_chunkid(char*out,const char*source,size_t bufflen){ if(*source=='='){ strncpy(out,source+1,bufflen); out[bufflen-1]='\0'; } else{ if(*source=='@'){ size_t l; source++; bufflen-=sizeof(" '...' "); l=strlen(source); strcpy(out,""); if(l>bufflen){ source+=(l-bufflen); strcat(out,"..."); } strcat(out,source); } else{ size_t len=strcspn(source,"\n\r"); bufflen-=sizeof(" [string \"...\"] "); if(len>bufflen)len=bufflen; strcpy(out,"[string \""); if(source[len]!='\0'){ strncat(out,source,len); strcat(out,"..."); } else strcat(out,source); strcat(out,"\"]"); } } } #define gnode(t,i)(&(t)->node[i]) #define gkey(n)(&(n)->i_key.nk) #define gval(n)(&(n)->i_val) #define gnext(n)((n)->i_key.nk.next) #define key2tval(n)(&(n)->i_key.tvk) static TValue*luaH_setnum(lua_State*L,Table*t,int key); static const TValue*luaH_getstr(Table*t,TString*key); static TValue*luaH_set(lua_State*L,Table*t,const TValue*key); static const char*const luaT_typenames[]={ "nil","boolean","userdata","number", "string","table","function","userdata","thread", "proto","upval" }; static void luaT_init(lua_State*L){ static const char*const luaT_eventname[]={ "__index","__newindex", "__gc","__mode","__eq", "__add","__sub","__mul","__div","__mod", "__pow","__unm","__len","__lt","__le", "__concat","__call" }; int i; for(i=0;itmname[i]=luaS_new(L,luaT_eventname[i]); luaS_fix(G(L)->tmname[i]); } } static const TValue*luaT_gettm(Table*events,TMS event,TString*ename){ const TValue*tm=luaH_getstr(events,ename); if(ttisnil(tm)){ events->flags|=cast_byte(1u<metatable; break; case 7: mt=uvalue(o)->metatable; break; default: mt=G(L)->mt[ttype(o)]; } return(mt?luaH_getstr(mt,G(L)->tmname[event]):(&luaO_nilobject_)); } #define sizeCclosure(n)(cast(int,sizeof(CClosure))+cast(int,sizeof(TValue)*((n)-1))) #define sizeLclosure(n)(cast(int,sizeof(LClosure))+cast(int,sizeof(TValue*)*((n)-1))) static Closure*luaF_newCclosure(lua_State*L,int nelems,Table*e){ Closure*c=cast(Closure*,luaM_malloc(L,sizeCclosure(nelems))); luaC_link(L,obj2gco(c),6); c->c.isC=1; c->c.env=e; c->c.nupvalues=cast_byte(nelems); return c; } static Closure*luaF_newLclosure(lua_State*L,int nelems,Table*e){ Closure*c=cast(Closure*,luaM_malloc(L,sizeLclosure(nelems))); luaC_link(L,obj2gco(c),6); c->l.isC=0; c->l.env=e; c->l.nupvalues=cast_byte(nelems); while(nelems--)c->l.upvals[nelems]=NULL; return c; } static UpVal*luaF_newupval(lua_State*L){ UpVal*uv=luaM_new(L,UpVal); luaC_link(L,obj2gco(uv),(8+2)); uv->v=&uv->u.value; setnilvalue(uv->v); return uv; } static UpVal*luaF_findupval(lua_State*L,StkId level){ global_State*g=G(L); GCObject**pp=&L->openupval; UpVal*p; UpVal*uv; while(*pp!=NULL&&(p=ngcotouv(*pp))->v>=level){ if(p->v==level){ if(isdead(g,obj2gco(p))) changewhite(obj2gco(p)); return p; } pp=&p->next; } uv=luaM_new(L,UpVal); uv->tt=(8+2); uv->marked=luaC_white(g); uv->v=level; uv->next=*pp; *pp=obj2gco(uv); uv->u.l.prev=&g->uvhead; uv->u.l.next=g->uvhead.u.l.next; uv->u.l.next->u.l.prev=uv; g->uvhead.u.l.next=uv; return uv; } static void unlinkupval(UpVal*uv){ uv->u.l.next->u.l.prev=uv->u.l.prev; uv->u.l.prev->u.l.next=uv->u.l.next; } static void luaF_freeupval(lua_State*L,UpVal*uv){ if(uv->v!=&uv->u.value) unlinkupval(uv); luaM_free(L,uv); } static void luaF_close(lua_State*L,StkId level){ UpVal*uv; global_State*g=G(L); while(L->openupval!=NULL&&(uv=ngcotouv(L->openupval))->v>=level){ GCObject*o=obj2gco(uv); L->openupval=uv->next; if(isdead(g,o)) luaF_freeupval(L,uv); else{ unlinkupval(uv); setobj(L,&uv->u.value,uv->v); uv->v=&uv->u.value; luaC_linkupval(L,uv); } } } static Proto*luaF_newproto(lua_State*L){ Proto*f=luaM_new(L,Proto); luaC_link(L,obj2gco(f),(8+1)); f->k=NULL; f->sizek=0; f->p=NULL; f->sizep=0; f->code=NULL; f->sizecode=0; f->sizelineinfo=0; f->sizeupvalues=0; f->nups=0; f->upvalues=NULL; f->numparams=0; f->is_vararg=0; f->maxstacksize=0; f->lineinfo=NULL; f->sizelocvars=0; f->locvars=NULL; f->linedefined=0; f->lastlinedefined=0; f->source=NULL; return f; } static void luaF_freeproto(lua_State*L,Proto*f){ luaM_freearray(L,f->code,f->sizecode,Instruction); luaM_freearray(L,f->p,f->sizep,Proto*); luaM_freearray(L,f->k,f->sizek,TValue); luaM_freearray(L,f->lineinfo,f->sizelineinfo,int); luaM_freearray(L,f->locvars,f->sizelocvars,struct LocVar); luaM_freearray(L,f->upvalues,f->sizeupvalues,TString*); luaM_free(L,f); } static void luaF_freeclosure(lua_State*L,Closure*c){ int size=(c->c.isC)?sizeCclosure(c->c.nupvalues): sizeLclosure(c->l.nupvalues); luaM_freemem(L,c,size); } #define MASK1(n,p)((~((~(Instruction)0)<>0)&MASK1(6,0))) #define SET_OPCODE(i,o)((i)=(((i)&MASK0(6,0))|((cast(Instruction,o)<<0)&MASK1(6,0)))) #define GETARG_A(i)(cast(int,((i)>>(0+6))&MASK1(8,0))) #define SETARG_A(i,u)((i)=(((i)&MASK0(8,(0+6)))|((cast(Instruction,u)<<(0+6))&MASK1(8,(0+6))))) #define GETARG_B(i)(cast(int,((i)>>(((0+6)+8)+9))&MASK1(9,0))) #define SETARG_B(i,b)((i)=(((i)&MASK0(9,(((0+6)+8)+9)))|((cast(Instruction,b)<<(((0+6)+8)+9))&MASK1(9,(((0+6)+8)+9))))) #define GETARG_C(i)(cast(int,((i)>>((0+6)+8))&MASK1(9,0))) #define SETARG_C(i,b)((i)=(((i)&MASK0(9,((0+6)+8)))|((cast(Instruction,b)<<((0+6)+8))&MASK1(9,((0+6)+8))))) #define GETARG_Bx(i)(cast(int,((i)>>((0+6)+8))&MASK1((9+9),0))) #define SETARG_Bx(i,b)((i)=(((i)&MASK0((9+9),((0+6)+8)))|((cast(Instruction,b)<<((0+6)+8))&MASK1((9+9),((0+6)+8))))) #define GETARG_sBx(i)(GETARG_Bx(i)-(((1<<(9+9))-1)>>1)) #define SETARG_sBx(i,b)SETARG_Bx((i),cast(unsigned int,(b)+(((1<<(9+9))-1)>>1))) #define CREATE_ABC(o,a,b,c)((cast(Instruction,o)<<0)|(cast(Instruction,a)<<(0+6))|(cast(Instruction,b)<<(((0+6)+8)+9))|(cast(Instruction,c)<<((0+6)+8))) #define CREATE_ABx(o,a,bc)((cast(Instruction,o)<<0)|(cast(Instruction,a)<<(0+6))|(cast(Instruction,bc)<<((0+6)+8))) #define ISK(x)((x)&(1<<(9-1))) #define INDEXK(r)((int)(r)&~(1<<(9-1))) #define RKASK(x)((x)|(1<<(9-1))) static const lu_byte luaP_opmodes[(cast(int,OP_VARARG)+1)]; #define getBMode(m)(cast(enum OpArgMask,(luaP_opmodes[m]>>4)&3)) #define getCMode(m)(cast(enum OpArgMask,(luaP_opmodes[m]>>2)&3)) #define testTMode(m)(luaP_opmodes[m]&(1<<7)) typedef struct expdesc{ expkind k; union{ struct{int info,aux;}s; lua_Number nval; }u; int t; int f; }expdesc; typedef struct upvaldesc{ lu_byte k; lu_byte info; }upvaldesc; struct BlockCnt; typedef struct FuncState{ Proto*f; Table*h; struct FuncState*prev; struct LexState*ls; struct lua_State*L; struct BlockCnt*bl; int pc; int lasttarget; int jpc; int freereg; int nk; int np; short nlocvars; lu_byte nactvar; upvaldesc upvalues[60]; unsigned short actvar[200]; }FuncState; static Proto*luaY_parser(lua_State*L,ZIO*z,Mbuffer*buff, const char*name); struct lua_longjmp{ struct lua_longjmp*previous; jmp_buf b; volatile int status; }; static void luaD_seterrorobj(lua_State*L,int errcode,StkId oldtop){ switch(errcode){ case 4:{ setsvalue(L,oldtop,luaS_newliteral(L,"not enough memory")); break; } case 5:{ setsvalue(L,oldtop,luaS_newliteral(L,"error in error handling")); break; } case 3: case 2:{ setobj(L,oldtop,L->top-1); break; } } L->top=oldtop+1; } static void restore_stack_limit(lua_State*L){ if(L->size_ci>20000){ int inuse=cast_int(L->ci-L->base_ci); if(inuse+1<20000) luaD_reallocCI(L,20000); } } static void resetstack(lua_State*L,int status){ L->ci=L->base_ci; L->base=L->ci->base; luaF_close(L,L->base); luaD_seterrorobj(L,status,L->base); L->nCcalls=L->baseCcalls; L->allowhook=1; restore_stack_limit(L); L->errfunc=0; L->errorJmp=NULL; } static void luaD_throw(lua_State*L,int errcode){ if(L->errorJmp){ L->errorJmp->status=errcode; LUAI_THROW(L,L->errorJmp); } else{ L->status=cast_byte(errcode); if(G(L)->panic){ resetstack(L,errcode); G(L)->panic(L); } exit(EXIT_FAILURE); } } static int luaD_rawrunprotected(lua_State*L,Pfunc f,void*ud){ struct lua_longjmp lj; lj.status=0; lj.previous=L->errorJmp; L->errorJmp=&lj; LUAI_TRY(L,&lj, (*f)(L,ud); ); L->errorJmp=lj.previous; return lj.status; } static void correctstack(lua_State*L,TValue*oldstack){ CallInfo*ci; GCObject*up; L->top=(L->top-oldstack)+L->stack; for(up=L->openupval;up!=NULL;up=up->gch.next) gco2uv(up)->v=(gco2uv(up)->v-oldstack)+L->stack; for(ci=L->base_ci;ci<=L->ci;ci++){ ci->top=(ci->top-oldstack)+L->stack; ci->base=(ci->base-oldstack)+L->stack; ci->func=(ci->func-oldstack)+L->stack; } L->base=(L->base-oldstack)+L->stack; } static void luaD_reallocstack(lua_State*L,int newsize){ TValue*oldstack=L->stack; int realsize=newsize+1+5; luaM_reallocvector(L,L->stack,L->stacksize,realsize,TValue); L->stacksize=realsize; L->stack_last=L->stack+newsize; correctstack(L,oldstack); } static void luaD_reallocCI(lua_State*L,int newsize){ CallInfo*oldci=L->base_ci; luaM_reallocvector(L,L->base_ci,L->size_ci,newsize,CallInfo); L->size_ci=newsize; L->ci=(L->ci-oldci)+L->base_ci; L->end_ci=L->base_ci+L->size_ci-1; } static void luaD_growstack(lua_State*L,int n){ if(n<=L->stacksize) luaD_reallocstack(L,2*L->stacksize); else luaD_reallocstack(L,L->stacksize+n); } static CallInfo*growCI(lua_State*L){ if(L->size_ci>20000) luaD_throw(L,5); else{ luaD_reallocCI(L,2*L->size_ci); if(L->size_ci>20000) luaG_runerror(L,"stack overflow"); } return++L->ci; } static StkId adjust_varargs(lua_State*L,Proto*p,int actual){ int i; int nfixargs=p->numparams; Table*htab=NULL; StkId base,fixed; for(;actualtop++); fixed=L->top-actual; base=L->top; for(i=0;itop++,fixed+i); setnilvalue(fixed+i); } if(htab){ sethvalue(L,L->top++,htab); } return base; } static StkId tryfuncTM(lua_State*L,StkId func){ const TValue*tm=luaT_gettmbyobj(L,func,TM_CALL); StkId p; ptrdiff_t funcr=savestack(L,func); if(!ttisfunction(tm)) luaG_typeerror(L,func,"call"); for(p=L->top;p>func;p--)setobj(L,p,p-1); incr_top(L); func=restorestack(L,funcr); setobj(L,func,tm); return func; } #define inc_ci(L)((L->ci==L->end_ci)?growCI(L):(condhardstacktests(luaD_reallocCI(L,L->size_ci)),++L->ci)) static int luaD_precall(lua_State*L,StkId func,int nresults){ LClosure*cl; ptrdiff_t funcr; if(!ttisfunction(func)) func=tryfuncTM(L,func); funcr=savestack(L,func); cl=&clvalue(func)->l; L->ci->savedpc=L->savedpc; if(!cl->isC){ CallInfo*ci; StkId st,base; Proto*p=cl->p; luaD_checkstack(L,p->maxstacksize); func=restorestack(L,funcr); if(!p->is_vararg){ base=func+1; if(L->top>base+p->numparams) L->top=base+p->numparams; } else{ int nargs=cast_int(L->top-func)-1; base=adjust_varargs(L,p,nargs); func=restorestack(L,funcr); } ci=inc_ci(L); ci->func=func; L->base=ci->base=base; ci->top=L->base+p->maxstacksize; L->savedpc=p->code; ci->tailcalls=0; ci->nresults=nresults; for(st=L->top;sttop;st++) setnilvalue(st); L->top=ci->top; return 0; } else{ CallInfo*ci; int n; luaD_checkstack(L,20); ci=inc_ci(L); ci->func=restorestack(L,funcr); L->base=ci->base=ci->func+1; ci->top=L->top+20; ci->nresults=nresults; n=(*curr_func(L)->c.f)(L); if(n<0) return 2; else{ luaD_poscall(L,L->top-n); return 1; } } } static int luaD_poscall(lua_State*L,StkId firstResult){ StkId res; int wanted,i; CallInfo*ci; ci=L->ci--; res=ci->func; wanted=ci->nresults; L->base=(ci-1)->base; L->savedpc=(ci-1)->savedpc; for(i=wanted;i!=0&&firstResulttop;i--) setobj(L,res++,firstResult++); while(i-->0) setnilvalue(res++); L->top=res; return(wanted-(-1)); } static void luaD_call(lua_State*L,StkId func,int nResults){ if(++L->nCcalls>=200){ if(L->nCcalls==200) luaG_runerror(L,"C stack overflow"); else if(L->nCcalls>=(200+(200>>3))) luaD_throw(L,5); } if(luaD_precall(L,func,nResults)==0) luaV_execute(L,1); L->nCcalls--; luaC_checkGC(L); } static int luaD_pcall(lua_State*L,Pfunc func,void*u, ptrdiff_t old_top,ptrdiff_t ef){ int status; unsigned short oldnCcalls=L->nCcalls; ptrdiff_t old_ci=saveci(L,L->ci); lu_byte old_allowhooks=L->allowhook; ptrdiff_t old_errfunc=L->errfunc; L->errfunc=ef; status=luaD_rawrunprotected(L,func,u); if(status!=0){ StkId oldtop=restorestack(L,old_top); luaF_close(L,oldtop); luaD_seterrorobj(L,status,oldtop); L->nCcalls=oldnCcalls; L->ci=restoreci(L,old_ci); L->base=L->ci->base; L->savedpc=L->ci->savedpc; L->allowhook=old_allowhooks; restore_stack_limit(L); } L->errfunc=old_errfunc; return status; } struct SParser{ ZIO*z; Mbuffer buff; const char*name; }; static void f_parser(lua_State*L,void*ud){ int i; Proto*tf; Closure*cl; struct SParser*p=cast(struct SParser*,ud); luaC_checkGC(L); tf=luaY_parser(L,p->z, &p->buff,p->name); cl=luaF_newLclosure(L,tf->nups,hvalue(gt(L))); cl->l.p=tf; for(i=0;inups;i++) cl->l.upvals[i]=luaF_newupval(L); setclvalue(L,L->top,cl); incr_top(L); } static int luaD_protectedparser(lua_State*L,ZIO*z,const char*name){ struct SParser p; int status; p.z=z;p.name=name; luaZ_initbuffer(L,&p.buff); status=luaD_pcall(L,f_parser,&p,savestack(L,L->top),L->errfunc); luaZ_freebuffer(L,&p.buff); return status; } static void luaS_resize(lua_State*L,int newsize){ GCObject**newhash; stringtable*tb; int i; if(G(L)->gcstate==2) return; newhash=luaM_newvector(L,newsize,GCObject*); tb=&G(L)->strt; for(i=0;isize;i++){ GCObject*p=tb->hash[i]; while(p){ GCObject*next=p->gch.next; unsigned int h=gco2ts(p)->hash; int h1=lmod(h,newsize); p->gch.next=newhash[h1]; newhash[h1]=p; p=next; } } luaM_freearray(L,tb->hash,tb->size,TString*); tb->size=newsize; tb->hash=newhash; } static TString*newlstr(lua_State*L,const char*str,size_t l, unsigned int h){ TString*ts; stringtable*tb; if(l+1>(((size_t)(~(size_t)0)-2)-sizeof(TString))/sizeof(char)) luaM_toobig(L); ts=cast(TString*,luaM_malloc(L,(l+1)*sizeof(char)+sizeof(TString))); ts->tsv.len=l; ts->tsv.hash=h; ts->tsv.marked=luaC_white(G(L)); ts->tsv.tt=4; ts->tsv.reserved=0; memcpy(ts+1,str,l*sizeof(char)); ((char*)(ts+1))[l]='\0'; tb=&G(L)->strt; h=lmod(h,tb->size); ts->tsv.next=tb->hash[h]; tb->hash[h]=obj2gco(ts); tb->nuse++; if(tb->nuse>cast(lu_int32,tb->size)&&tb->size<=(INT_MAX-2)/2) luaS_resize(L,tb->size*2); return ts; } static TString*luaS_newlstr(lua_State*L,const char*str,size_t l){ GCObject*o; unsigned int h=cast(unsigned int,l); size_t step=(l>>5)+1; size_t l1; for(l1=l;l1>=step;l1-=step) h=h^((h<<5)+(h>>2)+cast(unsigned char,str[l1-1])); for(o=G(L)->strt.hash[lmod(h,G(L)->strt.size)]; o!=NULL; o=o->gch.next){ TString*ts=rawgco2ts(o); if(ts->tsv.len==l&&(memcmp(str,getstr(ts),l)==0)){ if(isdead(G(L),o))changewhite(o); return ts; } } return newlstr(L,str,l,h); } static Udata*luaS_newudata(lua_State*L,size_t s,Table*e){ Udata*u; if(s>((size_t)(~(size_t)0)-2)-sizeof(Udata)) luaM_toobig(L); u=cast(Udata*,luaM_malloc(L,s+sizeof(Udata))); u->uv.marked=luaC_white(G(L)); u->uv.tt=7; u->uv.len=s; u->uv.metatable=NULL; u->uv.env=e; u->uv.next=G(L)->mainthread->next; G(L)->mainthread->next=obj2gco(u); return u; } #define hashpow2(t,n)(gnode(t,lmod((n),sizenode(t)))) #define hashstr(t,str)hashpow2(t,(str)->tsv.hash) #define hashboolean(t,p)hashpow2(t,p) #define hashmod(t,n)(gnode(t,((n)%((sizenode(t)-1)|1)))) #define hashpointer(t,p)hashmod(t,IntPoint(p)) static const Node dummynode_={ {{NULL},0}, {{{NULL},0,NULL}} }; static Node*hashnum(const Table*t,lua_Number n){ unsigned int a[cast_int(sizeof(lua_Number)/sizeof(int))]; int i; if(luai_numeq(n,0)) return gnode(t,0); memcpy(a,&n,sizeof(a)); for(i=1;isizearray) return i-1; else{ Node*n=mainposition(t,key); do{ if(luaO_rawequalObj(key2tval(n),key)|| (ttype(gkey(n))==(8+3)&&iscollectable(key)&& gcvalue(gkey(n))==gcvalue(key))){ i=cast_int(n-gnode(t,0)); return i+t->sizearray; } else n=gnext(n); }while(n); luaG_runerror(L,"invalid key to "LUA_QL("next")); return 0; } } static int luaH_next(lua_State*L,Table*t,StkId key){ int i=findindex(L,t,key); for(i++;isizearray;i++){ if(!ttisnil(&t->array[i])){ setnvalue(key,cast_num(i+1)); setobj(L,key+1,&t->array[i]); return 1; } } for(i-=t->sizearray;i<(int)sizenode(t);i++){ if(!ttisnil(gval(gnode(t,i)))){ setobj(L,key,key2tval(gnode(t,i))); setobj(L,key+1,gval(gnode(t,i))); return 1; } } return 0; } static int computesizes(int nums[],int*narray){ int i; int twotoi; int a=0; int na=0; int n=0; for(i=0,twotoi=1;twotoi/2<*narray;i++,twotoi*=2){ if(nums[i]>0){ a+=nums[i]; if(a>twotoi/2){ n=twotoi; na=a; } } if(a==*narray)break; } *narray=n; return na; } static int countint(const TValue*key,int*nums){ int k=arrayindex(key); if(0t->sizearray){ lim=t->sizearray; if(i>lim) break; } for(;i<=lim;i++){ if(!ttisnil(&t->array[i-1])) lc++; } nums[lg]+=lc; ause+=lc; } return ause; } static int numusehash(const Table*t,int*nums,int*pnasize){ int totaluse=0; int ause=0; int i=sizenode(t); while(i--){ Node*n=&t->node[i]; if(!ttisnil(gval(n))){ ause+=countint(key2tval(n),nums); totaluse++; } } *pnasize+=ause; return totaluse; } static void setarrayvector(lua_State*L,Table*t,int size){ int i; luaM_reallocvector(L,t->array,t->sizearray,size,TValue); for(i=t->sizearray;iarray[i]); t->sizearray=size; } static void setnodevector(lua_State*L,Table*t,int size){ int lsize; if(size==0){ t->node=cast(Node*,(&dummynode_)); lsize=0; } else{ int i; lsize=ceillog2(size); if(lsize>(32-2)) luaG_runerror(L,"table overflow"); size=twoto(lsize); t->node=luaM_newvector(L,size,Node); for(i=0;ilsizenode=cast_byte(lsize); t->lastfree=gnode(t,size); } static void resize(lua_State*L,Table*t,int nasize,int nhsize){ int i; int oldasize=t->sizearray; int oldhsize=t->lsizenode; Node*nold=t->node; if(nasize>oldasize) setarrayvector(L,t,nasize); setnodevector(L,t,nhsize); if(nasizesizearray=nasize; for(i=nasize;iarray[i])) setobj(L,luaH_setnum(L,t,i+1),&t->array[i]); } luaM_reallocvector(L,t->array,oldasize,nasize,TValue); } for(i=twoto(oldhsize)-1;i>=0;i--){ Node*old=nold+i; if(!ttisnil(gval(old))) setobj(L,luaH_set(L,t,key2tval(old)),gval(old)); } if(nold!=(&dummynode_)) luaM_freearray(L,nold,twoto(oldhsize),Node); } static void luaH_resizearray(lua_State*L,Table*t,int nasize){ int nsize=(t->node==(&dummynode_))?0:sizenode(t); resize(L,t,nasize,nsize); } static void rehash(lua_State*L,Table*t,const TValue*ek){ int nasize,na; int nums[(32-2)+1]; int i; int totaluse; for(i=0;i<=(32-2);i++)nums[i]=0; nasize=numusearray(t,nums); totaluse=nasize; totaluse+=numusehash(t,nums,&nasize); nasize+=countint(ek,nums); totaluse++; na=computesizes(nums,&nasize); resize(L,t,nasize,totaluse-na); } static Table*luaH_new(lua_State*L,int narray,int nhash){ Table*t=luaM_new(L,Table); luaC_link(L,obj2gco(t),5); t->metatable=NULL; t->flags=cast_byte(~0); t->array=NULL; t->sizearray=0; t->lsizenode=0; t->node=cast(Node*,(&dummynode_)); setarrayvector(L,t,narray); setnodevector(L,t,nhash); return t; } static void luaH_free(lua_State*L,Table*t){ if(t->node!=(&dummynode_)) luaM_freearray(L,t->node,sizenode(t),Node); luaM_freearray(L,t->array,t->sizearray,TValue); luaM_free(L,t); } static Node*getfreepos(Table*t){ while(t->lastfree-->t->node){ if(ttisnil(gkey(t->lastfree))) return t->lastfree; } return NULL; } static TValue*newkey(lua_State*L,Table*t,const TValue*key){ Node*mp=mainposition(t,key); if(!ttisnil(gval(mp))||mp==(&dummynode_)){ Node*othern; Node*n=getfreepos(t); if(n==NULL){ rehash(L,t,key); return luaH_set(L,t,key); } othern=mainposition(t,key2tval(mp)); if(othern!=mp){ while(gnext(othern)!=mp)othern=gnext(othern); gnext(othern)=n; *n=*mp; gnext(mp)=NULL; setnilvalue(gval(mp)); } else{ gnext(n)=gnext(mp); gnext(mp)=n; mp=n; } } gkey(mp)->value=key->value;gkey(mp)->tt=key->tt; luaC_barriert(L,t,key); return gval(mp); } static const TValue*luaH_getnum(Table*t,int key){ if(cast(unsigned int,key-1)sizearray)) return&t->array[key-1]; else{ lua_Number nk=cast_num(key); Node*n=hashnum(t,nk); do{ if(ttisnumber(gkey(n))&&luai_numeq(nvalue(gkey(n)),nk)) return gval(n); else n=gnext(n); }while(n); return(&luaO_nilobject_); } } static const TValue*luaH_getstr(Table*t,TString*key){ Node*n=hashstr(t,key); do{ if(ttisstring(gkey(n))&&rawtsvalue(gkey(n))==key) return gval(n); else n=gnext(n); }while(n); return(&luaO_nilobject_); } static const TValue*luaH_get(Table*t,const TValue*key){ switch(ttype(key)){ case 0:return(&luaO_nilobject_); case 4:return luaH_getstr(t,rawtsvalue(key)); case 3:{ int k; lua_Number n=nvalue(key); lua_number2int(k,n); if(luai_numeq(cast_num(k),nvalue(key))) return luaH_getnum(t,k); } default:{ Node*n=mainposition(t,key); do{ if(luaO_rawequalObj(key2tval(n),key)) return gval(n); else n=gnext(n); }while(n); return(&luaO_nilobject_); } } } static TValue*luaH_set(lua_State*L,Table*t,const TValue*key){ const TValue*p=luaH_get(t,key); t->flags=0; if(p!=(&luaO_nilobject_)) return cast(TValue*,p); else{ if(ttisnil(key))luaG_runerror(L,"table index is nil"); else if(ttisnumber(key)&&luai_numisnan(nvalue(key))) luaG_runerror(L,"table index is NaN"); return newkey(L,t,key); } } static TValue*luaH_setnum(lua_State*L,Table*t,int key){ const TValue*p=luaH_getnum(t,key); if(p!=(&luaO_nilobject_)) return cast(TValue*,p); else{ TValue k; setnvalue(&k,cast_num(key)); return newkey(L,t,&k); } } static TValue*luaH_setstr(lua_State*L,Table*t,TString*key){ const TValue*p=luaH_getstr(t,key); if(p!=(&luaO_nilobject_)) return cast(TValue*,p); else{ TValue k; setsvalue(L,&k,key); return newkey(L,t,&k); } } static int unbound_search(Table*t,unsigned int j){ unsigned int i=j; j++; while(!ttisnil(luaH_getnum(t,j))){ i=j; j*=2; if(j>cast(unsigned int,(INT_MAX-2))){ i=1; while(!ttisnil(luaH_getnum(t,i)))i++; return i-1; } } while(j-i>1){ unsigned int m=(i+j)/2; if(ttisnil(luaH_getnum(t,m)))j=m; else i=m; } return i; } static int luaH_getn(Table*t){ unsigned int j=t->sizearray; if(j>0&&ttisnil(&t->array[j-1])){ unsigned int i=0; while(j-i>1){ unsigned int m=(i+j)/2; if(ttisnil(&t->array[m-1]))j=m; else i=m; } return i; } else if(t->node==(&dummynode_)) return j; else return unbound_search(t,j); } #define makewhite(g,x)((x)->gch.marked=cast_byte(((x)->gch.marked&cast_byte(~(bitmask(2)|bit2mask(0,1))))|luaC_white(g))) #define white2gray(x)reset2bits((x)->gch.marked,0,1) #define black2gray(x)resetbit((x)->gch.marked,2) #define stringmark(s)reset2bits((s)->tsv.marked,0,1) #define isfinalized(u)testbit((u)->marked,3) #define markfinalized(u)l_setbit((u)->marked,3) #define markvalue(g,o){checkconsistency(o);if(iscollectable(o)&&iswhite(gcvalue(o)))reallymarkobject(g,gcvalue(o));} #define markobject(g,t){if(iswhite(obj2gco(t)))reallymarkobject(g,obj2gco(t));} #define setthreshold(g)(g->GCthreshold=(g->estimate/100)*g->gcpause) static void removeentry(Node*n){ if(iscollectable(gkey(n))) setttype(gkey(n),(8+3)); } static void reallymarkobject(global_State*g,GCObject*o){ white2gray(o); switch(o->gch.tt){ case 4:{ return; } case 7:{ Table*mt=gco2u(o)->metatable; gray2black(o); if(mt)markobject(g,mt); markobject(g,gco2u(o)->env); return; } case(8+2):{ UpVal*uv=gco2uv(o); markvalue(g,uv->v); if(uv->v==&uv->u.value) gray2black(o); return; } case 6:{ gco2cl(o)->c.gclist=g->gray; g->gray=o; break; } case 5:{ gco2h(o)->gclist=g->gray; g->gray=o; break; } case 8:{ gco2th(o)->gclist=g->gray; g->gray=o; break; } case(8+1):{ gco2p(o)->gclist=g->gray; g->gray=o; break; } default:; } } static void marktmu(global_State*g){ GCObject*u=g->tmudata; if(u){ do{ u=u->gch.next; makewhite(g,u); reallymarkobject(g,u); }while(u!=g->tmudata); } } static size_t luaC_separateudata(lua_State*L,int all){ global_State*g=G(L); size_t deadmem=0; GCObject**p=&g->mainthread->next; GCObject*curr; while((curr=*p)!=NULL){ if(!(iswhite(curr)||all)||isfinalized(gco2u(curr))) p=&curr->gch.next; else if(fasttm(L,gco2u(curr)->metatable,TM_GC)==NULL){ markfinalized(gco2u(curr)); p=&curr->gch.next; } else{ deadmem+=sizeudata(gco2u(curr)); markfinalized(gco2u(curr)); *p=curr->gch.next; if(g->tmudata==NULL) g->tmudata=curr->gch.next=curr; else{ curr->gch.next=g->tmudata->gch.next; g->tmudata->gch.next=curr; g->tmudata=curr; } } } return deadmem; } static int traversetable(global_State*g,Table*h){ int i; int weakkey=0; int weakvalue=0; const TValue*mode; if(h->metatable) markobject(g,h->metatable); mode=gfasttm(g,h->metatable,TM_MODE); if(mode&&ttisstring(mode)){ weakkey=(strchr(svalue(mode),'k')!=NULL); weakvalue=(strchr(svalue(mode),'v')!=NULL); if(weakkey||weakvalue){ h->marked&=~(bitmask(3)|bitmask(4)); h->marked|=cast_byte((weakkey<<3)| (weakvalue<<4)); h->gclist=g->weak; g->weak=obj2gco(h); } } if(weakkey&&weakvalue)return 1; if(!weakvalue){ i=h->sizearray; while(i--) markvalue(g,&h->array[i]); } i=sizenode(h); while(i--){ Node*n=gnode(h,i); if(ttisnil(gval(n))) removeentry(n); else{ if(!weakkey)markvalue(g,gkey(n)); if(!weakvalue)markvalue(g,gval(n)); } } return weakkey||weakvalue; } static void traverseproto(global_State*g,Proto*f){ int i; if(f->source)stringmark(f->source); for(i=0;isizek;i++) markvalue(g,&f->k[i]); for(i=0;isizeupvalues;i++){ if(f->upvalues[i]) stringmark(f->upvalues[i]); } for(i=0;isizep;i++){ if(f->p[i]) markobject(g,f->p[i]); } for(i=0;isizelocvars;i++){ if(f->locvars[i].varname) stringmark(f->locvars[i].varname); } } static void traverseclosure(global_State*g,Closure*cl){ markobject(g,cl->c.env); if(cl->c.isC){ int i; for(i=0;ic.nupvalues;i++) markvalue(g,&cl->c.upvalue[i]); } else{ int i; markobject(g,cl->l.p); for(i=0;il.nupvalues;i++) markobject(g,cl->l.upvals[i]); } } static void checkstacksizes(lua_State*L,StkId max){ int ci_used=cast_int(L->ci-L->base_ci); int s_used=cast_int(max-L->stack); if(L->size_ci>20000) return; if(4*ci_usedsize_ci&&2*8size_ci) luaD_reallocCI(L,L->size_ci/2); condhardstacktests(luaD_reallocCI(L,ci_used+1)); if(4*s_usedstacksize&& 2*((2*20)+5)stacksize) luaD_reallocstack(L,L->stacksize/2); condhardstacktests(luaD_reallocstack(L,s_used)); } static void traversestack(global_State*g,lua_State*l){ StkId o,lim; CallInfo*ci; markvalue(g,gt(l)); lim=l->top; for(ci=l->base_ci;ci<=l->ci;ci++){ if(limtop)lim=ci->top; } for(o=l->stack;otop;o++) markvalue(g,o); for(;o<=lim;o++) setnilvalue(o); checkstacksizes(l,lim); } static l_mem propagatemark(global_State*g){ GCObject*o=g->gray; gray2black(o); switch(o->gch.tt){ case 5:{ Table*h=gco2h(o); g->gray=h->gclist; if(traversetable(g,h)) black2gray(o); return sizeof(Table)+sizeof(TValue)*h->sizearray+ sizeof(Node)*sizenode(h); } case 6:{ Closure*cl=gco2cl(o); g->gray=cl->c.gclist; traverseclosure(g,cl); return(cl->c.isC)?sizeCclosure(cl->c.nupvalues): sizeLclosure(cl->l.nupvalues); } case 8:{ lua_State*th=gco2th(o); g->gray=th->gclist; th->gclist=g->grayagain; g->grayagain=o; black2gray(o); traversestack(g,th); return sizeof(lua_State)+sizeof(TValue)*th->stacksize+ sizeof(CallInfo)*th->size_ci; } case(8+1):{ Proto*p=gco2p(o); g->gray=p->gclist; traverseproto(g,p); return sizeof(Proto)+sizeof(Instruction)*p->sizecode+ sizeof(Proto*)*p->sizep+ sizeof(TValue)*p->sizek+ sizeof(int)*p->sizelineinfo+ sizeof(LocVar)*p->sizelocvars+ sizeof(TString*)*p->sizeupvalues; } default:return 0; } } static size_t propagateall(global_State*g){ size_t m=0; while(g->gray)m+=propagatemark(g); return m; } static int iscleared(const TValue*o,int iskey){ if(!iscollectable(o))return 0; if(ttisstring(o)){ stringmark(rawtsvalue(o)); return 0; } return iswhite(gcvalue(o))|| (ttisuserdata(o)&&(!iskey&&isfinalized(uvalue(o)))); } static void cleartable(GCObject*l){ while(l){ Table*h=gco2h(l); int i=h->sizearray; if(testbit(h->marked,4)){ while(i--){ TValue*o=&h->array[i]; if(iscleared(o,0)) setnilvalue(o); } } i=sizenode(h); while(i--){ Node*n=gnode(h,i); if(!ttisnil(gval(n))&& (iscleared(key2tval(n),1)||iscleared(gval(n),0))){ setnilvalue(gval(n)); removeentry(n); } } l=h->gclist; } } static void freeobj(lua_State*L,GCObject*o){ switch(o->gch.tt){ case(8+1):luaF_freeproto(L,gco2p(o));break; case 6:luaF_freeclosure(L,gco2cl(o));break; case(8+2):luaF_freeupval(L,gco2uv(o));break; case 5:luaH_free(L,gco2h(o));break; case 8:{ luaE_freethread(L,gco2th(o)); break; } case 4:{ G(L)->strt.nuse--; luaM_freemem(L,o,sizestring(gco2ts(o))); break; } case 7:{ luaM_freemem(L,o,sizeudata(gco2u(o))); break; } default:; } } #define sweepwholelist(L,p)sweeplist(L,p,((lu_mem)(~(lu_mem)0)-2)) static GCObject**sweeplist(lua_State*L,GCObject**p,lu_mem count){ GCObject*curr; global_State*g=G(L); int deadmask=otherwhite(g); while((curr=*p)!=NULL&&count-->0){ if(curr->gch.tt==8) sweepwholelist(L,&gco2th(curr)->openupval); if((curr->gch.marked^bit2mask(0,1))&deadmask){ makewhite(g,curr); p=&curr->gch.next; } else{ *p=curr->gch.next; if(curr==g->rootgc) g->rootgc=curr->gch.next; freeobj(L,curr); } } return p; } static void checkSizes(lua_State*L){ global_State*g=G(L); if(g->strt.nusestrt.size/4)&& g->strt.size>32*2) luaS_resize(L,g->strt.size/2); if(luaZ_sizebuffer(&g->buff)>32*2){ size_t newsize=luaZ_sizebuffer(&g->buff)/2; luaZ_resizebuffer(L,&g->buff,newsize); } } static void GCTM(lua_State*L){ global_State*g=G(L); GCObject*o=g->tmudata->gch.next; Udata*udata=rawgco2u(o); const TValue*tm; if(o==g->tmudata) g->tmudata=NULL; else g->tmudata->gch.next=udata->uv.next; udata->uv.next=g->mainthread->next; g->mainthread->next=o; makewhite(g,o); tm=fasttm(L,udata->uv.metatable,TM_GC); if(tm!=NULL){ lu_byte oldah=L->allowhook; lu_mem oldt=g->GCthreshold; L->allowhook=0; g->GCthreshold=2*g->totalbytes; setobj(L,L->top,tm); setuvalue(L,L->top+1,udata); L->top+=2; luaD_call(L,L->top-2,0); L->allowhook=oldah; g->GCthreshold=oldt; } } static void luaC_callGCTM(lua_State*L){ while(G(L)->tmudata) GCTM(L); } static void luaC_freeall(lua_State*L){ global_State*g=G(L); int i; g->currentwhite=bit2mask(0,1)|bitmask(6); sweepwholelist(L,&g->rootgc); for(i=0;istrt.size;i++) sweepwholelist(L,&g->strt.hash[i]); } static void markmt(global_State*g){ int i; for(i=0;i<(8+1);i++) if(g->mt[i])markobject(g,g->mt[i]); } static void markroot(lua_State*L){ global_State*g=G(L); g->gray=NULL; g->grayagain=NULL; g->weak=NULL; markobject(g,g->mainthread); markvalue(g,gt(g->mainthread)); markvalue(g,registry(L)); markmt(g); g->gcstate=1; } static void remarkupvals(global_State*g){ UpVal*uv; for(uv=g->uvhead.u.l.next;uv!=&g->uvhead;uv=uv->u.l.next){ if(isgray(obj2gco(uv))) markvalue(g,uv->v); } } static void atomic(lua_State*L){ global_State*g=G(L); size_t udsize; remarkupvals(g); propagateall(g); g->gray=g->weak; g->weak=NULL; markobject(g,L); markmt(g); propagateall(g); g->gray=g->grayagain; g->grayagain=NULL; propagateall(g); udsize=luaC_separateudata(L,0); marktmu(g); udsize+=propagateall(g); cleartable(g->weak); g->currentwhite=cast_byte(otherwhite(g)); g->sweepstrgc=0; g->sweepgc=&g->rootgc; g->gcstate=2; g->estimate=g->totalbytes-udsize; } static l_mem singlestep(lua_State*L){ global_State*g=G(L); switch(g->gcstate){ case 0:{ markroot(L); return 0; } case 1:{ if(g->gray) return propagatemark(g); else{ atomic(L); return 0; } } case 2:{ lu_mem old=g->totalbytes; sweepwholelist(L,&g->strt.hash[g->sweepstrgc++]); if(g->sweepstrgc>=g->strt.size) g->gcstate=3; g->estimate-=old-g->totalbytes; return 10; } case 3:{ lu_mem old=g->totalbytes; g->sweepgc=sweeplist(L,g->sweepgc,40); if(*g->sweepgc==NULL){ checkSizes(L); g->gcstate=4; } g->estimate-=old-g->totalbytes; return 40*10; } case 4:{ if(g->tmudata){ GCTM(L); if(g->estimate>100) g->estimate-=100; return 100; } else{ g->gcstate=0; g->gcdept=0; return 0; } } default:return 0; } } static void luaC_step(lua_State*L){ global_State*g=G(L); l_mem lim=(1024u/100)*g->gcstepmul; if(lim==0) lim=(((lu_mem)(~(lu_mem)0)-2)-1)/2; g->gcdept+=g->totalbytes-g->GCthreshold; do{ lim-=singlestep(L); if(g->gcstate==0) break; }while(lim>0); if(g->gcstate!=0){ if(g->gcdept<1024u) g->GCthreshold=g->totalbytes+1024u; else{ g->gcdept-=1024u; g->GCthreshold=g->totalbytes; } } else{ setthreshold(g); } } static void luaC_barrierf(lua_State*L,GCObject*o,GCObject*v){ global_State*g=G(L); if(g->gcstate==1) reallymarkobject(g,v); else makewhite(g,o); } static void luaC_barrierback(lua_State*L,Table*t){ global_State*g=G(L); GCObject*o=obj2gco(t); black2gray(o); t->gclist=g->grayagain; g->grayagain=o; } static void luaC_link(lua_State*L,GCObject*o,lu_byte tt){ global_State*g=G(L); o->gch.next=g->rootgc; g->rootgc=o; o->gch.marked=luaC_white(g); o->gch.tt=tt; } static void luaC_linkupval(lua_State*L,UpVal*uv){ global_State*g=G(L); GCObject*o=obj2gco(uv); o->gch.next=g->rootgc; g->rootgc=o; if(isgray(o)){ if(g->gcstate==1){ gray2black(o); luaC_barrier(L,uv,uv->v); } else{ makewhite(g,o); } } } typedef union{ lua_Number r; TString*ts; }SemInfo; typedef struct Token{ int token; SemInfo seminfo; }Token; typedef struct LexState{ int current; int linenumber; int lastline; Token t; Token lookahead; struct FuncState*fs; struct lua_State*L; ZIO*z; Mbuffer*buff; TString*source; char decpoint; }LexState; static void luaX_init(lua_State*L); static void luaX_lexerror(LexState*ls,const char*msg,int token); #define state_size(x)(sizeof(x)+0) #define fromstate(l)(cast(lu_byte*,(l))-0) #define tostate(l)(cast(lua_State*,cast(lu_byte*,l)+0)) typedef struct LG{ lua_State l; global_State g; }LG; static void stack_init(lua_State*L1,lua_State*L){ L1->base_ci=luaM_newvector(L,8,CallInfo); L1->ci=L1->base_ci; L1->size_ci=8; L1->end_ci=L1->base_ci+L1->size_ci-1; L1->stack=luaM_newvector(L,(2*20)+5,TValue); L1->stacksize=(2*20)+5; L1->top=L1->stack; L1->stack_last=L1->stack+(L1->stacksize-5)-1; L1->ci->func=L1->top; setnilvalue(L1->top++); L1->base=L1->ci->base=L1->top; L1->ci->top=L1->top+20; } static void freestack(lua_State*L,lua_State*L1){ luaM_freearray(L,L1->base_ci,L1->size_ci,CallInfo); luaM_freearray(L,L1->stack,L1->stacksize,TValue); } static void f_luaopen(lua_State*L,void*ud){ global_State*g=G(L); UNUSED(ud); stack_init(L,L); sethvalue(L,gt(L),luaH_new(L,0,2)); sethvalue(L,registry(L),luaH_new(L,0,2)); luaS_resize(L,32); luaT_init(L); luaX_init(L); luaS_fix(luaS_newliteral(L,"not enough memory")); g->GCthreshold=4*g->totalbytes; } static void preinit_state(lua_State*L,global_State*g){ G(L)=g; L->stack=NULL; L->stacksize=0; L->errorJmp=NULL; L->hook=NULL; L->hookmask=0; L->basehookcount=0; L->allowhook=1; resethookcount(L); L->openupval=NULL; L->size_ci=0; L->nCcalls=L->baseCcalls=0; L->status=0; L->base_ci=L->ci=NULL; L->savedpc=NULL; L->errfunc=0; setnilvalue(gt(L)); } static void close_state(lua_State*L){ global_State*g=G(L); luaF_close(L,L->stack); luaC_freeall(L); luaM_freearray(L,G(L)->strt.hash,G(L)->strt.size,TString*); luaZ_freebuffer(L,&g->buff); freestack(L,L); (*g->frealloc)(g->ud,fromstate(L),state_size(LG),0); } static void luaE_freethread(lua_State*L,lua_State*L1){ luaF_close(L1,L1->stack); freestack(L,L1); luaM_freemem(L,fromstate(L1),state_size(lua_State)); } static lua_State*lua_newstate(lua_Alloc f,void*ud){ int i; lua_State*L; global_State*g; void*l=(*f)(ud,NULL,0,state_size(LG)); if(l==NULL)return NULL; L=tostate(l); g=&((LG*)L)->g; L->next=NULL; L->tt=8; g->currentwhite=bit2mask(0,5); L->marked=luaC_white(g); set2bits(L->marked,5,6); preinit_state(L,g); g->frealloc=f; g->ud=ud; g->mainthread=L; g->uvhead.u.l.prev=&g->uvhead; g->uvhead.u.l.next=&g->uvhead; g->GCthreshold=0; g->strt.size=0; g->strt.nuse=0; g->strt.hash=NULL; setnilvalue(registry(L)); luaZ_initbuffer(L,&g->buff); g->panic=NULL; g->gcstate=0; g->rootgc=obj2gco(L); g->sweepstrgc=0; g->sweepgc=&g->rootgc; g->gray=NULL; g->grayagain=NULL; g->weak=NULL; g->tmudata=NULL; g->totalbytes=sizeof(LG); g->gcpause=200; g->gcstepmul=200; g->gcdept=0; for(i=0;i<(8+1);i++)g->mt[i]=NULL; if(luaD_rawrunprotected(L,f_luaopen,NULL)!=0){ close_state(L); L=NULL; } else {} return L; } static void callallgcTM(lua_State*L,void*ud){ UNUSED(ud); luaC_callGCTM(L); } static void lua_close(lua_State*L){ L=G(L)->mainthread; luaF_close(L,L->stack); luaC_separateudata(L,1); L->errfunc=0; do{ L->ci=L->base_ci; L->base=L->top=L->ci->base; L->nCcalls=L->baseCcalls=0; }while(luaD_rawrunprotected(L,callallgcTM,NULL)!=0); close_state(L); } #define getcode(fs,e)((fs)->f->code[(e)->u.s.info]) #define luaK_codeAsBx(fs,o,A,sBx)luaK_codeABx(fs,o,A,(sBx)+(((1<<(9+9))-1)>>1)) #define luaK_setmultret(fs,e)luaK_setreturns(fs,e,(-1)) static int luaK_codeABx(FuncState*fs,OpCode o,int A,unsigned int Bx); static int luaK_codeABC(FuncState*fs,OpCode o,int A,int B,int C); static void luaK_setreturns(FuncState*fs,expdesc*e,int nresults); static void luaK_patchtohere(FuncState*fs,int list); static void luaK_concat(FuncState*fs,int*l1,int l2); static int currentpc(lua_State*L,CallInfo*ci){ if(!isLua(ci))return-1; if(ci==L->ci) ci->savedpc=L->savedpc; return pcRel(ci->savedpc,ci_func(ci)->l.p); } static int currentline(lua_State*L,CallInfo*ci){ int pc=currentpc(L,ci); if(pc<0) return-1; else return getline_(ci_func(ci)->l.p,pc); } static int lua_getstack(lua_State*L,int level,lua_Debug*ar){ int status; CallInfo*ci; for(ci=L->ci;level>0&&ci>L->base_ci;ci--){ level--; if(f_isLua(ci)) level-=ci->tailcalls; } if(level==0&&ci>L->base_ci){ status=1; ar->i_ci=cast_int(ci-L->base_ci); } else if(level<0){ status=1; ar->i_ci=0; } else status=0; return status; } static Proto*getluaproto(CallInfo*ci){ return(isLua(ci)?ci_func(ci)->l.p:NULL); } static void funcinfo(lua_Debug*ar,Closure*cl){ if(cl->c.isC){ ar->source="=[C]"; ar->linedefined=-1; ar->lastlinedefined=-1; ar->what="C"; } else{ ar->source=getstr(cl->l.p->source); ar->linedefined=cl->l.p->linedefined; ar->lastlinedefined=cl->l.p->lastlinedefined; ar->what=(ar->linedefined==0)?"main":"Lua"; } luaO_chunkid(ar->short_src,ar->source,60); } static void info_tailcall(lua_Debug*ar){ ar->name=ar->namewhat=""; ar->what="tail"; ar->lastlinedefined=ar->linedefined=ar->currentline=-1; ar->source="=(tail call)"; luaO_chunkid(ar->short_src,ar->source,60); ar->nups=0; } static void collectvalidlines(lua_State*L,Closure*f){ if(f==NULL||f->c.isC){ setnilvalue(L->top); } else{ Table*t=luaH_new(L,0,0); int*lineinfo=f->l.p->lineinfo; int i; for(i=0;il.p->sizelineinfo;i++) setbvalue(luaH_setnum(L,t,lineinfo[i]),1); sethvalue(L,L->top,t); } incr_top(L); } static int auxgetinfo(lua_State*L,const char*what,lua_Debug*ar, Closure*f,CallInfo*ci){ int status=1; if(f==NULL){ info_tailcall(ar); return status; } for(;*what;what++){ switch(*what){ case'S':{ funcinfo(ar,f); break; } case'l':{ ar->currentline=(ci)?currentline(L,ci):-1; break; } case'u':{ ar->nups=f->c.nupvalues; break; } case'n':{ ar->namewhat=(ci)?NULL:NULL; if(ar->namewhat==NULL){ ar->namewhat=""; ar->name=NULL; } break; } case'L': case'f': break; default:status=0; } } return status; } static int lua_getinfo(lua_State*L,const char*what,lua_Debug*ar){ int status; Closure*f=NULL; CallInfo*ci=NULL; if(*what=='>'){ StkId func=L->top-1; luai_apicheck(L,ttisfunction(func)); what++; f=clvalue(func); L->top--; } else if(ar->i_ci!=0){ ci=L->base_ci+ar->i_ci; f=clvalue(ci->func); } status=auxgetinfo(L,what,ar,f,ci); if(strchr(what,'f')){ if(f==NULL)setnilvalue(L->top); else setclvalue(L,L->top,f); incr_top(L); } if(strchr(what,'L')) collectvalidlines(L,f); return status; } static int isinstack(CallInfo*ci,const TValue*o){ StkId p; for(p=ci->base;ptop;p++) if(o==p)return 1; return 0; } static void luaG_typeerror(lua_State*L,const TValue*o,const char*op){ const char*name=NULL; const char*t=luaT_typenames[ttype(o)]; const char*kind=(isinstack(L->ci,o))? NULL: NULL; if(kind) luaG_runerror(L,"attempt to %s %s "LUA_QL("%s")" (a %s value)", op,kind,name,t); else luaG_runerror(L,"attempt to %s a %s value",op,t); } static void luaG_concaterror(lua_State*L,StkId p1,StkId p2){ if(ttisstring(p1)||ttisnumber(p1))p1=p2; luaG_typeerror(L,p1,"concatenate"); } static void luaG_aritherror(lua_State*L,const TValue*p1,const TValue*p2){ TValue temp; if(luaV_tonumber(p1,&temp)==NULL) p2=p1; luaG_typeerror(L,p2,"perform arithmetic on"); } static int luaG_ordererror(lua_State*L,const TValue*p1,const TValue*p2){ const char*t1=luaT_typenames[ttype(p1)]; const char*t2=luaT_typenames[ttype(p2)]; if(t1[2]==t2[2]) luaG_runerror(L,"attempt to compare two %s values",t1); else luaG_runerror(L,"attempt to compare %s with %s",t1,t2); return 0; } static void addinfo(lua_State*L,const char*msg){ CallInfo*ci=L->ci; if(isLua(ci)){ char buff[60]; int line=currentline(L,ci); luaO_chunkid(buff,getstr(getluaproto(ci)->source),60); luaO_pushfstring(L,"%s:%d: %s",buff,line,msg); } } static void luaG_errormsg(lua_State*L){ if(L->errfunc!=0){ StkId errfunc=restorestack(L,L->errfunc); if(!ttisfunction(errfunc))luaD_throw(L,5); setobj(L,L->top,L->top-1); setobj(L,L->top-1,errfunc); incr_top(L); luaD_call(L,L->top-2,1); } luaD_throw(L,2); } static void luaG_runerror(lua_State*L,const char*fmt,...){ va_list argp; va_start(argp,fmt); addinfo(L,luaO_pushvfstring(L,fmt,argp)); va_end(argp); luaG_errormsg(L); } static int luaZ_fill(ZIO*z){ size_t size; lua_State*L=z->L; const char*buff; buff=z->reader(L,z->data,&size); if(buff==NULL||size==0)return(-1); z->n=size-1; z->p=buff; return char2int(*(z->p++)); } static void luaZ_init(lua_State*L,ZIO*z,lua_Reader reader,void*data){ z->L=L; z->reader=reader; z->data=data; z->n=0; z->p=NULL; } static char*luaZ_openspace(lua_State*L,Mbuffer*buff,size_t n){ if(n>buff->buffsize){ if(n<32)n=32; luaZ_resizebuffer(L,buff,n); } return buff->buffer; } #define opmode(t,a,b,c,m)(((t)<<7)|((a)<<6)|((b)<<4)|((c)<<2)|(m)) static const lu_byte luaP_opmodes[(cast(int,OP_VARARG)+1)]={ opmode(0,1,OpArgR,OpArgN,iABC) ,opmode(0,1,OpArgK,OpArgN,iABx) ,opmode(0,1,OpArgU,OpArgU,iABC) ,opmode(0,1,OpArgR,OpArgN,iABC) ,opmode(0,1,OpArgU,OpArgN,iABC) ,opmode(0,1,OpArgK,OpArgN,iABx) ,opmode(0,1,OpArgR,OpArgK,iABC) ,opmode(0,0,OpArgK,OpArgN,iABx) ,opmode(0,0,OpArgU,OpArgN,iABC) ,opmode(0,0,OpArgK,OpArgK,iABC) ,opmode(0,1,OpArgU,OpArgU,iABC) ,opmode(0,1,OpArgR,OpArgK,iABC) ,opmode(0,1,OpArgK,OpArgK,iABC) ,opmode(0,1,OpArgK,OpArgK,iABC) ,opmode(0,1,OpArgK,OpArgK,iABC) ,opmode(0,1,OpArgK,OpArgK,iABC) ,opmode(0,1,OpArgK,OpArgK,iABC) ,opmode(0,1,OpArgK,OpArgK,iABC) ,opmode(0,1,OpArgR,OpArgN,iABC) ,opmode(0,1,OpArgR,OpArgN,iABC) ,opmode(0,1,OpArgR,OpArgN,iABC) ,opmode(0,1,OpArgR,OpArgR,iABC) ,opmode(0,0,OpArgR,OpArgN,iAsBx) ,opmode(1,0,OpArgK,OpArgK,iABC) ,opmode(1,0,OpArgK,OpArgK,iABC) ,opmode(1,0,OpArgK,OpArgK,iABC) ,opmode(1,1,OpArgR,OpArgU,iABC) ,opmode(1,1,OpArgR,OpArgU,iABC) ,opmode(0,1,OpArgU,OpArgU,iABC) ,opmode(0,1,OpArgU,OpArgU,iABC) ,opmode(0,0,OpArgU,OpArgN,iABC) ,opmode(0,1,OpArgR,OpArgN,iAsBx) ,opmode(0,1,OpArgR,OpArgN,iAsBx) ,opmode(1,0,OpArgN,OpArgU,iABC) ,opmode(0,0,OpArgU,OpArgU,iABC) ,opmode(0,0,OpArgN,OpArgN,iABC) ,opmode(0,1,OpArgU,OpArgN,iABx) ,opmode(0,1,OpArgU,OpArgN,iABC) }; #define next(ls)(ls->current=zgetc(ls->z)) #define currIsNewline(ls)(ls->current=='\n'||ls->current=='\r') static const char*const luaX_tokens[]={ "and","break","do","else","elseif", "end","false","for","function","if", "in","local","nil","not","or","repeat", "return","then","true","until","while", "..","...","==",">=","<=","~=", "","","","", NULL }; #define save_and_next(ls)(save(ls,ls->current),next(ls)) static void save(LexState*ls,int c){ Mbuffer*b=ls->buff; if(b->n+1>b->buffsize){ size_t newsize; if(b->buffsize>=((size_t)(~(size_t)0)-2)/2) luaX_lexerror(ls,"lexical element too long",0); newsize=b->buffsize*2; luaZ_resizebuffer(ls->L,b,newsize); } b->buffer[b->n++]=cast(char,c); } static void luaX_init(lua_State*L){ int i; for(i=0;i<(cast(int,TK_WHILE-257+1));i++){ TString*ts=luaS_new(L,luaX_tokens[i]); luaS_fix(ts); ts->tsv.reserved=cast_byte(i+1); } } static const char*luaX_token2str(LexState*ls,int token){ if(token<257){ return(iscntrl(token))?luaO_pushfstring(ls->L,"char(%d)",token): luaO_pushfstring(ls->L,"%c",token); } else return luaX_tokens[token-257]; } static const char*txtToken(LexState*ls,int token){ switch(token){ case TK_NAME: case TK_STRING: case TK_NUMBER: save(ls,'\0'); return luaZ_buffer(ls->buff); default: return luaX_token2str(ls,token); } } static void luaX_lexerror(LexState*ls,const char*msg,int token){ char buff[80]; luaO_chunkid(buff,getstr(ls->source),80); msg=luaO_pushfstring(ls->L,"%s:%d: %s",buff,ls->linenumber,msg); if(token) luaO_pushfstring(ls->L,"%s near "LUA_QL("%s"),msg,txtToken(ls,token)); luaD_throw(ls->L,3); } static void luaX_syntaxerror(LexState*ls,const char*msg){ luaX_lexerror(ls,msg,ls->t.token); } static TString*luaX_newstring(LexState*ls,const char*str,size_t l){ lua_State*L=ls->L; TString*ts=luaS_newlstr(L,str,l); TValue*o=luaH_setstr(L,ls->fs->h,ts); if(ttisnil(o)){ setbvalue(o,1); luaC_checkGC(L); } return ts; } static void inclinenumber(LexState*ls){ int old=ls->current; next(ls); if(currIsNewline(ls)&&ls->current!=old) next(ls); if(++ls->linenumber>=(INT_MAX-2)) luaX_syntaxerror(ls,"chunk has too many lines"); } static void luaX_setinput(lua_State*L,LexState*ls,ZIO*z,TString*source){ ls->decpoint='.'; ls->L=L; ls->lookahead.token=TK_EOS; ls->z=z; ls->fs=NULL; ls->linenumber=1; ls->lastline=1; ls->source=source; luaZ_resizebuffer(ls->L,ls->buff,32); next(ls); } static int check_next(LexState*ls,const char*set){ if(!strchr(set,ls->current)) return 0; save_and_next(ls); return 1; } static void buffreplace(LexState*ls,char from,char to){ size_t n=luaZ_bufflen(ls->buff); char*p=luaZ_buffer(ls->buff); while(n--) if(p[n]==from)p[n]=to; } static void read_numeral(LexState*ls,SemInfo*seminfo){ do{ save_and_next(ls); }while(isdigit(ls->current)||ls->current=='.'); if(check_next(ls,"Ee")) check_next(ls,"+-"); while(isalnum(ls->current)||ls->current=='_') save_and_next(ls); save(ls,'\0'); buffreplace(ls,'.',ls->decpoint); if(!luaO_str2d(luaZ_buffer(ls->buff),&seminfo->r)) luaX_lexerror(ls,"malformed number",TK_NUMBER); } static int skip_sep(LexState*ls){ int count=0; int s=ls->current; save_and_next(ls); while(ls->current=='='){ save_and_next(ls); count++; } return(ls->current==s)?count:(-count)-1; } static void read_long_string(LexState*ls,SemInfo*seminfo,int sep){ int cont=0; (void)(cont); save_and_next(ls); if(currIsNewline(ls)) inclinenumber(ls); for(;;){ switch(ls->current){ case(-1): luaX_lexerror(ls,(seminfo)?"unfinished long string": "unfinished long comment",TK_EOS); break; case']':{ if(skip_sep(ls)==sep){ save_and_next(ls); goto endloop; } break; } case'\n': case'\r':{ save(ls,'\n'); inclinenumber(ls); if(!seminfo)luaZ_resetbuffer(ls->buff); break; } default:{ if(seminfo)save_and_next(ls); else next(ls); } } }endloop: if(seminfo) seminfo->ts=luaX_newstring(ls,luaZ_buffer(ls->buff)+(2+sep), luaZ_bufflen(ls->buff)-2*(2+sep)); } static void read_string(LexState*ls,int del,SemInfo*seminfo){ save_and_next(ls); while(ls->current!=del){ switch(ls->current){ case(-1): luaX_lexerror(ls,"unfinished string",TK_EOS); continue; case'\n': case'\r': luaX_lexerror(ls,"unfinished string",TK_STRING); continue; case'\\':{ int c; next(ls); switch(ls->current){ case'a':c='\a';break; case'b':c='\b';break; case'f':c='\f';break; case'n':c='\n';break; case'r':c='\r';break; case't':c='\t';break; case'v':c='\v';break; case'\n': case'\r':save(ls,'\n');inclinenumber(ls);continue; case(-1):continue; default:{ if(!isdigit(ls->current)) save_and_next(ls); else{ int i=0; c=0; do{ c=10*c+(ls->current-'0'); next(ls); }while(++i<3&&isdigit(ls->current)); if(c>UCHAR_MAX) luaX_lexerror(ls,"escape sequence too large",TK_STRING); save(ls,c); } continue; } } save(ls,c); next(ls); continue; } default: save_and_next(ls); } } save_and_next(ls); seminfo->ts=luaX_newstring(ls,luaZ_buffer(ls->buff)+1, luaZ_bufflen(ls->buff)-2); } static int llex(LexState*ls,SemInfo*seminfo){ luaZ_resetbuffer(ls->buff); for(;;){ switch(ls->current){ case'\n': case'\r':{ inclinenumber(ls); continue; } case'-':{ next(ls); if(ls->current!='-')return'-'; next(ls); if(ls->current=='['){ int sep=skip_sep(ls); luaZ_resetbuffer(ls->buff); if(sep>=0){ read_long_string(ls,NULL,sep); luaZ_resetbuffer(ls->buff); continue; } } while(!currIsNewline(ls)&&ls->current!=(-1)) next(ls); continue; } case'[':{ int sep=skip_sep(ls); if(sep>=0){ read_long_string(ls,seminfo,sep); return TK_STRING; } else if(sep==-1)return'['; else luaX_lexerror(ls,"invalid long string delimiter",TK_STRING); } case'=':{ next(ls); if(ls->current!='=')return'='; else{next(ls);return TK_EQ;} } case'<':{ next(ls); if(ls->current!='=')return'<'; else{next(ls);return TK_LE;} } case'>':{ next(ls); if(ls->current!='=')return'>'; else{next(ls);return TK_GE;} } case'~':{ next(ls); if(ls->current!='=')return'~'; else{next(ls);return TK_NE;} } case'"': case'\'':{ read_string(ls,ls->current,seminfo); return TK_STRING; } case'.':{ save_and_next(ls); if(check_next(ls,".")){ if(check_next(ls,".")) return TK_DOTS; else return TK_CONCAT; } else if(!isdigit(ls->current))return'.'; else{ read_numeral(ls,seminfo); return TK_NUMBER; } } case(-1):{ return TK_EOS; } default:{ if(isspace(ls->current)){ next(ls); continue; } else if(isdigit(ls->current)){ read_numeral(ls,seminfo); return TK_NUMBER; } else if(isalpha(ls->current)||ls->current=='_'){ TString*ts; do{ save_and_next(ls); }while(isalnum(ls->current)||ls->current=='_'); ts=luaX_newstring(ls,luaZ_buffer(ls->buff), luaZ_bufflen(ls->buff)); if(ts->tsv.reserved>0) return ts->tsv.reserved-1+257; else{ seminfo->ts=ts; return TK_NAME; } } else{ int c=ls->current; next(ls); return c; } } } } } static void luaX_next(LexState*ls){ ls->lastline=ls->linenumber; if(ls->lookahead.token!=TK_EOS){ ls->t=ls->lookahead; ls->lookahead.token=TK_EOS; } else ls->t.token=llex(ls,&ls->t.seminfo); } static void luaX_lookahead(LexState*ls){ ls->lookahead.token=llex(ls,&ls->lookahead.seminfo); } #define hasjumps(e)((e)->t!=(e)->f) static int isnumeral(expdesc*e){ return(e->k==VKNUM&&e->t==(-1)&&e->f==(-1)); } static void luaK_nil(FuncState*fs,int from,int n){ Instruction*previous; if(fs->pc>fs->lasttarget){ if(fs->pc==0){ if(from>=fs->nactvar) return; } else{ previous=&fs->f->code[fs->pc-1]; if(GET_OPCODE(*previous)==OP_LOADNIL){ int pfrom=GETARG_A(*previous); int pto=GETARG_B(*previous); if(pfrom<=from&&from<=pto+1){ if(from+n-1>pto) SETARG_B(*previous,from+n-1); return; } } } } luaK_codeABC(fs,OP_LOADNIL,from,from+n-1,0); } static int luaK_jump(FuncState*fs){ int jpc=fs->jpc; int j; fs->jpc=(-1); j=luaK_codeAsBx(fs,OP_JMP,0,(-1)); luaK_concat(fs,&j,jpc); return j; } static void luaK_ret(FuncState*fs,int first,int nret){ luaK_codeABC(fs,OP_RETURN,first,nret+1,0); } static int condjump(FuncState*fs,OpCode op,int A,int B,int C){ luaK_codeABC(fs,op,A,B,C); return luaK_jump(fs); } static void fixjump(FuncState*fs,int pc,int dest){ Instruction*jmp=&fs->f->code[pc]; int offset=dest-(pc+1); if(abs(offset)>(((1<<(9+9))-1)>>1)) luaX_syntaxerror(fs->ls,"control structure too long"); SETARG_sBx(*jmp,offset); } static int luaK_getlabel(FuncState*fs){ fs->lasttarget=fs->pc; return fs->pc; } static int getjump(FuncState*fs,int pc){ int offset=GETARG_sBx(fs->f->code[pc]); if(offset==(-1)) return(-1); else return(pc+1)+offset; } static Instruction*getjumpcontrol(FuncState*fs,int pc){ Instruction*pi=&fs->f->code[pc]; if(pc>=1&&testTMode(GET_OPCODE(*(pi-1)))) return pi-1; else return pi; } static int need_value(FuncState*fs,int list){ for(;list!=(-1);list=getjump(fs,list)){ Instruction i=*getjumpcontrol(fs,list); if(GET_OPCODE(i)!=OP_TESTSET)return 1; } return 0; } static int patchtestreg(FuncState*fs,int node,int reg){ Instruction*i=getjumpcontrol(fs,node); if(GET_OPCODE(*i)!=OP_TESTSET) return 0; if(reg!=((1<<8)-1)&®!=GETARG_B(*i)) SETARG_A(*i,reg); else *i=CREATE_ABC(OP_TEST,GETARG_B(*i),0,GETARG_C(*i)); return 1; } static void removevalues(FuncState*fs,int list){ for(;list!=(-1);list=getjump(fs,list)) patchtestreg(fs,list,((1<<8)-1)); } static void patchlistaux(FuncState*fs,int list,int vtarget,int reg, int dtarget){ while(list!=(-1)){ int next=getjump(fs,list); if(patchtestreg(fs,list,reg)) fixjump(fs,list,vtarget); else fixjump(fs,list,dtarget); list=next; } } static void dischargejpc(FuncState*fs){ patchlistaux(fs,fs->jpc,fs->pc,((1<<8)-1),fs->pc); fs->jpc=(-1); } static void luaK_patchlist(FuncState*fs,int list,int target){ if(target==fs->pc) luaK_patchtohere(fs,list); else{ patchlistaux(fs,list,target,((1<<8)-1),target); } } static void luaK_patchtohere(FuncState*fs,int list){ luaK_getlabel(fs); luaK_concat(fs,&fs->jpc,list); } static void luaK_concat(FuncState*fs,int*l1,int l2){ if(l2==(-1))return; else if(*l1==(-1)) *l1=l2; else{ int list=*l1; int next; while((next=getjump(fs,list))!=(-1)) list=next; fixjump(fs,list,l2); } } static void luaK_checkstack(FuncState*fs,int n){ int newstack=fs->freereg+n; if(newstack>fs->f->maxstacksize){ if(newstack>=250) luaX_syntaxerror(fs->ls,"function or expression too complex"); fs->f->maxstacksize=cast_byte(newstack); } } static void luaK_reserveregs(FuncState*fs,int n){ luaK_checkstack(fs,n); fs->freereg+=n; } static void freereg(FuncState*fs,int reg){ if(!ISK(reg)&®>=fs->nactvar){ fs->freereg--; } } static void freeexp(FuncState*fs,expdesc*e){ if(e->k==VNONRELOC) freereg(fs,e->u.s.info); } static int addk(FuncState*fs,TValue*k,TValue*v){ lua_State*L=fs->L; TValue*idx=luaH_set(L,fs->h,k); Proto*f=fs->f; int oldsize=f->sizek; if(ttisnumber(idx)){ return cast_int(nvalue(idx)); } else{ setnvalue(idx,cast_num(fs->nk)); luaM_growvector(L,f->k,fs->nk,f->sizek,TValue, ((1<<(9+9))-1),"constant table overflow"); while(oldsizesizek)setnilvalue(&f->k[oldsize++]); setobj(L,&f->k[fs->nk],v); luaC_barrier(L,f,v); return fs->nk++; } } static int luaK_stringK(FuncState*fs,TString*s){ TValue o; setsvalue(fs->L,&o,s); return addk(fs,&o,&o); } static int luaK_numberK(FuncState*fs,lua_Number r){ TValue o; setnvalue(&o,r); return addk(fs,&o,&o); } static int boolK(FuncState*fs,int b){ TValue o; setbvalue(&o,b); return addk(fs,&o,&o); } static int nilK(FuncState*fs){ TValue k,v; setnilvalue(&v); sethvalue(fs->L,&k,fs->h); return addk(fs,&k,&v); } static void luaK_setreturns(FuncState*fs,expdesc*e,int nresults){ if(e->k==VCALL){ SETARG_C(getcode(fs,e),nresults+1); } else if(e->k==VVARARG){ SETARG_B(getcode(fs,e),nresults+1); SETARG_A(getcode(fs,e),fs->freereg); luaK_reserveregs(fs,1); } } static void luaK_setoneret(FuncState*fs,expdesc*e){ if(e->k==VCALL){ e->k=VNONRELOC; e->u.s.info=GETARG_A(getcode(fs,e)); } else if(e->k==VVARARG){ SETARG_B(getcode(fs,e),2); e->k=VRELOCABLE; } } static void luaK_dischargevars(FuncState*fs,expdesc*e){ switch(e->k){ case VLOCAL:{ e->k=VNONRELOC; break; } case VUPVAL:{ e->u.s.info=luaK_codeABC(fs,OP_GETUPVAL,0,e->u.s.info,0); e->k=VRELOCABLE; break; } case VGLOBAL:{ e->u.s.info=luaK_codeABx(fs,OP_GETGLOBAL,0,e->u.s.info); e->k=VRELOCABLE; break; } case VINDEXED:{ freereg(fs,e->u.s.aux); freereg(fs,e->u.s.info); e->u.s.info=luaK_codeABC(fs,OP_GETTABLE,0,e->u.s.info,e->u.s.aux); e->k=VRELOCABLE; break; } case VVARARG: case VCALL:{ luaK_setoneret(fs,e); break; } default:break; } } static int code_label(FuncState*fs,int A,int b,int jump){ luaK_getlabel(fs); return luaK_codeABC(fs,OP_LOADBOOL,A,b,jump); } static void discharge2reg(FuncState*fs,expdesc*e,int reg){ luaK_dischargevars(fs,e); switch(e->k){ case VNIL:{ luaK_nil(fs,reg,1); break; } case VFALSE:case VTRUE:{ luaK_codeABC(fs,OP_LOADBOOL,reg,e->k==VTRUE,0); break; } case VK:{ luaK_codeABx(fs,OP_LOADK,reg,e->u.s.info); break; } case VKNUM:{ luaK_codeABx(fs,OP_LOADK,reg,luaK_numberK(fs,e->u.nval)); break; } case VRELOCABLE:{ Instruction*pc=&getcode(fs,e); SETARG_A(*pc,reg); break; } case VNONRELOC:{ if(reg!=e->u.s.info) luaK_codeABC(fs,OP_MOVE,reg,e->u.s.info,0); break; } default:{ return; } } e->u.s.info=reg; e->k=VNONRELOC; } static void discharge2anyreg(FuncState*fs,expdesc*e){ if(e->k!=VNONRELOC){ luaK_reserveregs(fs,1); discharge2reg(fs,e,fs->freereg-1); } } static void exp2reg(FuncState*fs,expdesc*e,int reg){ discharge2reg(fs,e,reg); if(e->k==VJMP) luaK_concat(fs,&e->t,e->u.s.info); if(hasjumps(e)){ int final; int p_f=(-1); int p_t=(-1); if(need_value(fs,e->t)||need_value(fs,e->f)){ int fj=(e->k==VJMP)?(-1):luaK_jump(fs); p_f=code_label(fs,reg,0,1); p_t=code_label(fs,reg,1,0); luaK_patchtohere(fs,fj); } final=luaK_getlabel(fs); patchlistaux(fs,e->f,final,reg,p_f); patchlistaux(fs,e->t,final,reg,p_t); } e->f=e->t=(-1); e->u.s.info=reg; e->k=VNONRELOC; } static void luaK_exp2nextreg(FuncState*fs,expdesc*e){ luaK_dischargevars(fs,e); freeexp(fs,e); luaK_reserveregs(fs,1); exp2reg(fs,e,fs->freereg-1); } static int luaK_exp2anyreg(FuncState*fs,expdesc*e){ luaK_dischargevars(fs,e); if(e->k==VNONRELOC){ if(!hasjumps(e))return e->u.s.info; if(e->u.s.info>=fs->nactvar){ exp2reg(fs,e,e->u.s.info); return e->u.s.info; } } luaK_exp2nextreg(fs,e); return e->u.s.info; } static void luaK_exp2val(FuncState*fs,expdesc*e){ if(hasjumps(e)) luaK_exp2anyreg(fs,e); else luaK_dischargevars(fs,e); } static int luaK_exp2RK(FuncState*fs,expdesc*e){ luaK_exp2val(fs,e); switch(e->k){ case VKNUM: case VTRUE: case VFALSE: case VNIL:{ if(fs->nk<=((1<<(9-1))-1)){ e->u.s.info=(e->k==VNIL)?nilK(fs): (e->k==VKNUM)?luaK_numberK(fs,e->u.nval): boolK(fs,(e->k==VTRUE)); e->k=VK; return RKASK(e->u.s.info); } else break; } case VK:{ if(e->u.s.info<=((1<<(9-1))-1)) return RKASK(e->u.s.info); else break; } default:break; } return luaK_exp2anyreg(fs,e); } static void luaK_storevar(FuncState*fs,expdesc*var,expdesc*ex){ switch(var->k){ case VLOCAL:{ freeexp(fs,ex); exp2reg(fs,ex,var->u.s.info); return; } case VUPVAL:{ int e=luaK_exp2anyreg(fs,ex); luaK_codeABC(fs,OP_SETUPVAL,e,var->u.s.info,0); break; } case VGLOBAL:{ int e=luaK_exp2anyreg(fs,ex); luaK_codeABx(fs,OP_SETGLOBAL,e,var->u.s.info); break; } case VINDEXED:{ int e=luaK_exp2RK(fs,ex); luaK_codeABC(fs,OP_SETTABLE,var->u.s.info,var->u.s.aux,e); break; } default:{ break; } } freeexp(fs,ex); } static void luaK_self(FuncState*fs,expdesc*e,expdesc*key){ int func; luaK_exp2anyreg(fs,e); freeexp(fs,e); func=fs->freereg; luaK_reserveregs(fs,2); luaK_codeABC(fs,OP_SELF,func,e->u.s.info,luaK_exp2RK(fs,key)); freeexp(fs,key); e->u.s.info=func; e->k=VNONRELOC; } static void invertjump(FuncState*fs,expdesc*e){ Instruction*pc=getjumpcontrol(fs,e->u.s.info); SETARG_A(*pc,!(GETARG_A(*pc))); } static int jumponcond(FuncState*fs,expdesc*e,int cond){ if(e->k==VRELOCABLE){ Instruction ie=getcode(fs,e); if(GET_OPCODE(ie)==OP_NOT){ fs->pc--; return condjump(fs,OP_TEST,GETARG_B(ie),0,!cond); } } discharge2anyreg(fs,e); freeexp(fs,e); return condjump(fs,OP_TESTSET,((1<<8)-1),e->u.s.info,cond); } static void luaK_goiftrue(FuncState*fs,expdesc*e){ int pc; luaK_dischargevars(fs,e); switch(e->k){ case VK:case VKNUM:case VTRUE:{ pc=(-1); break; } case VJMP:{ invertjump(fs,e); pc=e->u.s.info; break; } default:{ pc=jumponcond(fs,e,0); break; } } luaK_concat(fs,&e->f,pc); luaK_patchtohere(fs,e->t); e->t=(-1); } static void luaK_goiffalse(FuncState*fs,expdesc*e){ int pc; luaK_dischargevars(fs,e); switch(e->k){ case VNIL:case VFALSE:{ pc=(-1); break; } case VJMP:{ pc=e->u.s.info; break; } default:{ pc=jumponcond(fs,e,1); break; } } luaK_concat(fs,&e->t,pc); luaK_patchtohere(fs,e->f); e->f=(-1); } static void codenot(FuncState*fs,expdesc*e){ luaK_dischargevars(fs,e); switch(e->k){ case VNIL:case VFALSE:{ e->k=VTRUE; break; } case VK:case VKNUM:case VTRUE:{ e->k=VFALSE; break; } case VJMP:{ invertjump(fs,e); break; } case VRELOCABLE: case VNONRELOC:{ discharge2anyreg(fs,e); freeexp(fs,e); e->u.s.info=luaK_codeABC(fs,OP_NOT,0,e->u.s.info,0); e->k=VRELOCABLE; break; } default:{ break; } } {int temp=e->f;e->f=e->t;e->t=temp;} removevalues(fs,e->f); removevalues(fs,e->t); } static void luaK_indexed(FuncState*fs,expdesc*t,expdesc*k){ t->u.s.aux=luaK_exp2RK(fs,k); t->k=VINDEXED; } static int constfolding(OpCode op,expdesc*e1,expdesc*e2){ lua_Number v1,v2,r; if(!isnumeral(e1)||!isnumeral(e2))return 0; v1=e1->u.nval; v2=e2->u.nval; switch(op){ case OP_ADD:r=luai_numadd(v1,v2);break; case OP_SUB:r=luai_numsub(v1,v2);break; case OP_MUL:r=luai_nummul(v1,v2);break; case OP_DIV: if(v2==0)return 0; r=luai_numdiv(v1,v2);break; case OP_MOD: if(v2==0)return 0; r=luai_nummod(v1,v2);break; case OP_POW:r=luai_numpow(v1,v2);break; case OP_UNM:r=luai_numunm(v1);break; case OP_LEN:return 0; default:r=0;break; } if(luai_numisnan(r))return 0; e1->u.nval=r; return 1; } static void codearith(FuncState*fs,OpCode op,expdesc*e1,expdesc*e2){ if(constfolding(op,e1,e2)) return; else{ int o2=(op!=OP_UNM&&op!=OP_LEN)?luaK_exp2RK(fs,e2):0; int o1=luaK_exp2RK(fs,e1); if(o1>o2){ freeexp(fs,e1); freeexp(fs,e2); } else{ freeexp(fs,e2); freeexp(fs,e1); } e1->u.s.info=luaK_codeABC(fs,op,0,o1,o2); e1->k=VRELOCABLE; } } static void codecomp(FuncState*fs,OpCode op,int cond,expdesc*e1, expdesc*e2){ int o1=luaK_exp2RK(fs,e1); int o2=luaK_exp2RK(fs,e2); freeexp(fs,e2); freeexp(fs,e1); if(cond==0&&op!=OP_EQ){ int temp; temp=o1;o1=o2;o2=temp; cond=1; } e1->u.s.info=condjump(fs,op,cond,o1,o2); e1->k=VJMP; } static void luaK_prefix(FuncState*fs,UnOpr op,expdesc*e){ expdesc e2; e2.t=e2.f=(-1);e2.k=VKNUM;e2.u.nval=0; switch(op){ case OPR_MINUS:{ if(!isnumeral(e)) luaK_exp2anyreg(fs,e); codearith(fs,OP_UNM,e,&e2); break; } case OPR_NOT:codenot(fs,e);break; case OPR_LEN:{ luaK_exp2anyreg(fs,e); codearith(fs,OP_LEN,e,&e2); break; } default:; } } static void luaK_infix(FuncState*fs,BinOpr op,expdesc*v){ switch(op){ case OPR_AND:{ luaK_goiftrue(fs,v); break; } case OPR_OR:{ luaK_goiffalse(fs,v); break; } case OPR_CONCAT:{ luaK_exp2nextreg(fs,v); break; } case OPR_ADD:case OPR_SUB:case OPR_MUL:case OPR_DIV: case OPR_MOD:case OPR_POW:{ if(!isnumeral(v))luaK_exp2RK(fs,v); break; } default:{ luaK_exp2RK(fs,v); break; } } } static void luaK_posfix(FuncState*fs,BinOpr op,expdesc*e1,expdesc*e2){ switch(op){ case OPR_AND:{ luaK_dischargevars(fs,e2); luaK_concat(fs,&e2->f,e1->f); *e1=*e2; break; } case OPR_OR:{ luaK_dischargevars(fs,e2); luaK_concat(fs,&e2->t,e1->t); *e1=*e2; break; } case OPR_CONCAT:{ luaK_exp2val(fs,e2); if(e2->k==VRELOCABLE&&GET_OPCODE(getcode(fs,e2))==OP_CONCAT){ freeexp(fs,e1); SETARG_B(getcode(fs,e2),e1->u.s.info); e1->k=VRELOCABLE;e1->u.s.info=e2->u.s.info; } else{ luaK_exp2nextreg(fs,e2); codearith(fs,OP_CONCAT,e1,e2); } break; } case OPR_ADD:codearith(fs,OP_ADD,e1,e2);break; case OPR_SUB:codearith(fs,OP_SUB,e1,e2);break; case OPR_MUL:codearith(fs,OP_MUL,e1,e2);break; case OPR_DIV:codearith(fs,OP_DIV,e1,e2);break; case OPR_MOD:codearith(fs,OP_MOD,e1,e2);break; case OPR_POW:codearith(fs,OP_POW,e1,e2);break; case OPR_EQ:codecomp(fs,OP_EQ,1,e1,e2);break; case OPR_NE:codecomp(fs,OP_EQ,0,e1,e2);break; case OPR_LT:codecomp(fs,OP_LT,1,e1,e2);break; case OPR_LE:codecomp(fs,OP_LE,1,e1,e2);break; case OPR_GT:codecomp(fs,OP_LT,0,e1,e2);break; case OPR_GE:codecomp(fs,OP_LE,0,e1,e2);break; default:; } } static void luaK_fixline(FuncState*fs,int line){ fs->f->lineinfo[fs->pc-1]=line; } static int luaK_code(FuncState*fs,Instruction i,int line){ Proto*f=fs->f; dischargejpc(fs); luaM_growvector(fs->L,f->code,fs->pc,f->sizecode,Instruction, (INT_MAX-2),"code size overflow"); f->code[fs->pc]=i; luaM_growvector(fs->L,f->lineinfo,fs->pc,f->sizelineinfo,int, (INT_MAX-2),"code size overflow"); f->lineinfo[fs->pc]=line; return fs->pc++; } static int luaK_codeABC(FuncState*fs,OpCode o,int a,int b,int c){ return luaK_code(fs,CREATE_ABC(o,a,b,c),fs->ls->lastline); } static int luaK_codeABx(FuncState*fs,OpCode o,int a,unsigned int bc){ return luaK_code(fs,CREATE_ABx(o,a,bc),fs->ls->lastline); } static void luaK_setlist(FuncState*fs,int base,int nelems,int tostore){ int c=(nelems-1)/50+1; int b=(tostore==(-1))?0:tostore; if(c<=((1<<9)-1)) luaK_codeABC(fs,OP_SETLIST,base,b,c); else{ luaK_codeABC(fs,OP_SETLIST,base,b,0); luaK_code(fs,cast(Instruction,c),fs->ls->lastline); } fs->freereg=base+1; } #define hasmultret(k)((k)==VCALL||(k)==VVARARG) #define getlocvar(fs,i)((fs)->f->locvars[(fs)->actvar[i]]) #define luaY_checklimit(fs,v,l,m)if((v)>(l))errorlimit(fs,l,m) typedef struct BlockCnt{ struct BlockCnt*previous; int breaklist; lu_byte nactvar; lu_byte upval; lu_byte isbreakable; }BlockCnt; static void chunk(LexState*ls); static void expr(LexState*ls,expdesc*v); static void anchor_token(LexState*ls){ if(ls->t.token==TK_NAME||ls->t.token==TK_STRING){ TString*ts=ls->t.seminfo.ts; luaX_newstring(ls,getstr(ts),ts->tsv.len); } } static void error_expected(LexState*ls,int token){ luaX_syntaxerror(ls, luaO_pushfstring(ls->L,LUA_QL("%s")" expected",luaX_token2str(ls,token))); } static void errorlimit(FuncState*fs,int limit,const char*what){ const char*msg=(fs->f->linedefined==0)? luaO_pushfstring(fs->L,"main function has more than %d %s",limit,what): luaO_pushfstring(fs->L,"function at line %d has more than %d %s", fs->f->linedefined,limit,what); luaX_lexerror(fs->ls,msg,0); } static int testnext(LexState*ls,int c){ if(ls->t.token==c){ luaX_next(ls); return 1; } else return 0; } static void check(LexState*ls,int c){ if(ls->t.token!=c) error_expected(ls,c); } static void checknext(LexState*ls,int c){ check(ls,c); luaX_next(ls); } #define check_condition(ls,c,msg){if(!(c))luaX_syntaxerror(ls,msg);} static void check_match(LexState*ls,int what,int who,int where){ if(!testnext(ls,what)){ if(where==ls->linenumber) error_expected(ls,what); else{ luaX_syntaxerror(ls,luaO_pushfstring(ls->L, LUA_QL("%s")" expected (to close "LUA_QL("%s")" at line %d)", luaX_token2str(ls,what),luaX_token2str(ls,who),where)); } } } static TString*str_checkname(LexState*ls){ TString*ts; check(ls,TK_NAME); ts=ls->t.seminfo.ts; luaX_next(ls); return ts; } static void init_exp(expdesc*e,expkind k,int i){ e->f=e->t=(-1); e->k=k; e->u.s.info=i; } static void codestring(LexState*ls,expdesc*e,TString*s){ init_exp(e,VK,luaK_stringK(ls->fs,s)); } static void checkname(LexState*ls,expdesc*e){ codestring(ls,e,str_checkname(ls)); } static int registerlocalvar(LexState*ls,TString*varname){ FuncState*fs=ls->fs; Proto*f=fs->f; int oldsize=f->sizelocvars; luaM_growvector(ls->L,f->locvars,fs->nlocvars,f->sizelocvars, LocVar,SHRT_MAX,"too many local variables"); while(oldsizesizelocvars)f->locvars[oldsize++].varname=NULL; f->locvars[fs->nlocvars].varname=varname; luaC_objbarrier(ls->L,f,varname); return fs->nlocvars++; } #define new_localvarliteral(ls,v,n)new_localvar(ls,luaX_newstring(ls,""v,(sizeof(v)/sizeof(char))-1),n) static void new_localvar(LexState*ls,TString*name,int n){ FuncState*fs=ls->fs; luaY_checklimit(fs,fs->nactvar+n+1,200,"local variables"); fs->actvar[fs->nactvar+n]=cast(unsigned short,registerlocalvar(ls,name)); } static void adjustlocalvars(LexState*ls,int nvars){ FuncState*fs=ls->fs; fs->nactvar=cast_byte(fs->nactvar+nvars); for(;nvars;nvars--){ getlocvar(fs,fs->nactvar-nvars).startpc=fs->pc; } } static void removevars(LexState*ls,int tolevel){ FuncState*fs=ls->fs; while(fs->nactvar>tolevel) getlocvar(fs,--fs->nactvar).endpc=fs->pc; } static int indexupvalue(FuncState*fs,TString*name,expdesc*v){ int i; Proto*f=fs->f; int oldsize=f->sizeupvalues; for(i=0;inups;i++){ if(fs->upvalues[i].k==v->k&&fs->upvalues[i].info==v->u.s.info){ return i; } } luaY_checklimit(fs,f->nups+1,60,"upvalues"); luaM_growvector(fs->L,f->upvalues,f->nups,f->sizeupvalues, TString*,(INT_MAX-2),""); while(oldsizesizeupvalues)f->upvalues[oldsize++]=NULL; f->upvalues[f->nups]=name; luaC_objbarrier(fs->L,f,name); fs->upvalues[f->nups].k=cast_byte(v->k); fs->upvalues[f->nups].info=cast_byte(v->u.s.info); return f->nups++; } static int searchvar(FuncState*fs,TString*n){ int i; for(i=fs->nactvar-1;i>=0;i--){ if(n==getlocvar(fs,i).varname) return i; } return-1; } static void markupval(FuncState*fs,int level){ BlockCnt*bl=fs->bl; while(bl&&bl->nactvar>level)bl=bl->previous; if(bl)bl->upval=1; } static int singlevaraux(FuncState*fs,TString*n,expdesc*var,int base){ if(fs==NULL){ init_exp(var,VGLOBAL,((1<<8)-1)); return VGLOBAL; } else{ int v=searchvar(fs,n); if(v>=0){ init_exp(var,VLOCAL,v); if(!base) markupval(fs,v); return VLOCAL; } else{ if(singlevaraux(fs->prev,n,var,0)==VGLOBAL) return VGLOBAL; var->u.s.info=indexupvalue(fs,n,var); var->k=VUPVAL; return VUPVAL; } } } static void singlevar(LexState*ls,expdesc*var){ TString*varname=str_checkname(ls); FuncState*fs=ls->fs; if(singlevaraux(fs,varname,var,1)==VGLOBAL) var->u.s.info=luaK_stringK(fs,varname); } static void adjust_assign(LexState*ls,int nvars,int nexps,expdesc*e){ FuncState*fs=ls->fs; int extra=nvars-nexps; if(hasmultret(e->k)){ extra++; if(extra<0)extra=0; luaK_setreturns(fs,e,extra); if(extra>1)luaK_reserveregs(fs,extra-1); } else{ if(e->k!=VVOID)luaK_exp2nextreg(fs,e); if(extra>0){ int reg=fs->freereg; luaK_reserveregs(fs,extra); luaK_nil(fs,reg,extra); } } } static void enterlevel(LexState*ls){ if(++ls->L->nCcalls>200) luaX_lexerror(ls,"chunk has too many syntax levels",0); } #define leavelevel(ls)((ls)->L->nCcalls--) static void enterblock(FuncState*fs,BlockCnt*bl,lu_byte isbreakable){ bl->breaklist=(-1); bl->isbreakable=isbreakable; bl->nactvar=fs->nactvar; bl->upval=0; bl->previous=fs->bl; fs->bl=bl; } static void leaveblock(FuncState*fs){ BlockCnt*bl=fs->bl; fs->bl=bl->previous; removevars(fs->ls,bl->nactvar); if(bl->upval) luaK_codeABC(fs,OP_CLOSE,bl->nactvar,0,0); fs->freereg=fs->nactvar; luaK_patchtohere(fs,bl->breaklist); } static void pushclosure(LexState*ls,FuncState*func,expdesc*v){ FuncState*fs=ls->fs; Proto*f=fs->f; int oldsize=f->sizep; int i; luaM_growvector(ls->L,f->p,fs->np,f->sizep,Proto*, ((1<<(9+9))-1),"constant table overflow"); while(oldsizesizep)f->p[oldsize++]=NULL; f->p[fs->np++]=func->f; luaC_objbarrier(ls->L,f,func->f); init_exp(v,VRELOCABLE,luaK_codeABx(fs,OP_CLOSURE,0,fs->np-1)); for(i=0;if->nups;i++){ OpCode o=(func->upvalues[i].k==VLOCAL)?OP_MOVE:OP_GETUPVAL; luaK_codeABC(fs,o,0,func->upvalues[i].info,0); } } static void open_func(LexState*ls,FuncState*fs){ lua_State*L=ls->L; Proto*f=luaF_newproto(L); fs->f=f; fs->prev=ls->fs; fs->ls=ls; fs->L=L; ls->fs=fs; fs->pc=0; fs->lasttarget=-1; fs->jpc=(-1); fs->freereg=0; fs->nk=0; fs->np=0; fs->nlocvars=0; fs->nactvar=0; fs->bl=NULL; f->source=ls->source; f->maxstacksize=2; fs->h=luaH_new(L,0,0); sethvalue(L,L->top,fs->h); incr_top(L); setptvalue(L,L->top,f); incr_top(L); } static void close_func(LexState*ls){ lua_State*L=ls->L; FuncState*fs=ls->fs; Proto*f=fs->f; removevars(ls,0); luaK_ret(fs,0,0); luaM_reallocvector(L,f->code,f->sizecode,fs->pc,Instruction); f->sizecode=fs->pc; luaM_reallocvector(L,f->lineinfo,f->sizelineinfo,fs->pc,int); f->sizelineinfo=fs->pc; luaM_reallocvector(L,f->k,f->sizek,fs->nk,TValue); f->sizek=fs->nk; luaM_reallocvector(L,f->p,f->sizep,fs->np,Proto*); f->sizep=fs->np; luaM_reallocvector(L,f->locvars,f->sizelocvars,fs->nlocvars,LocVar); f->sizelocvars=fs->nlocvars; luaM_reallocvector(L,f->upvalues,f->sizeupvalues,f->nups,TString*); f->sizeupvalues=f->nups; ls->fs=fs->prev; if(fs)anchor_token(ls); L->top-=2; } static Proto*luaY_parser(lua_State*L,ZIO*z,Mbuffer*buff,const char*name){ struct LexState lexstate; struct FuncState funcstate; lexstate.buff=buff; luaX_setinput(L,&lexstate,z,luaS_new(L,name)); open_func(&lexstate,&funcstate); funcstate.f->is_vararg=2; luaX_next(&lexstate); chunk(&lexstate); check(&lexstate,TK_EOS); close_func(&lexstate); return funcstate.f; } static void field(LexState*ls,expdesc*v){ FuncState*fs=ls->fs; expdesc key; luaK_exp2anyreg(fs,v); luaX_next(ls); checkname(ls,&key); luaK_indexed(fs,v,&key); } static void yindex(LexState*ls,expdesc*v){ luaX_next(ls); expr(ls,v); luaK_exp2val(ls->fs,v); checknext(ls,']'); } struct ConsControl{ expdesc v; expdesc*t; int nh; int na; int tostore; }; static void recfield(LexState*ls,struct ConsControl*cc){ FuncState*fs=ls->fs; int reg=ls->fs->freereg; expdesc key,val; int rkkey; if(ls->t.token==TK_NAME){ luaY_checklimit(fs,cc->nh,(INT_MAX-2),"items in a constructor"); checkname(ls,&key); } else yindex(ls,&key); cc->nh++; checknext(ls,'='); rkkey=luaK_exp2RK(fs,&key); expr(ls,&val); luaK_codeABC(fs,OP_SETTABLE,cc->t->u.s.info,rkkey,luaK_exp2RK(fs,&val)); fs->freereg=reg; } static void closelistfield(FuncState*fs,struct ConsControl*cc){ if(cc->v.k==VVOID)return; luaK_exp2nextreg(fs,&cc->v); cc->v.k=VVOID; if(cc->tostore==50){ luaK_setlist(fs,cc->t->u.s.info,cc->na,cc->tostore); cc->tostore=0; } } static void lastlistfield(FuncState*fs,struct ConsControl*cc){ if(cc->tostore==0)return; if(hasmultret(cc->v.k)){ luaK_setmultret(fs,&cc->v); luaK_setlist(fs,cc->t->u.s.info,cc->na,(-1)); cc->na--; } else{ if(cc->v.k!=VVOID) luaK_exp2nextreg(fs,&cc->v); luaK_setlist(fs,cc->t->u.s.info,cc->na,cc->tostore); } } static void listfield(LexState*ls,struct ConsControl*cc){ expr(ls,&cc->v); luaY_checklimit(ls->fs,cc->na,(INT_MAX-2),"items in a constructor"); cc->na++; cc->tostore++; } static void constructor(LexState*ls,expdesc*t){ FuncState*fs=ls->fs; int line=ls->linenumber; int pc=luaK_codeABC(fs,OP_NEWTABLE,0,0,0); struct ConsControl cc; cc.na=cc.nh=cc.tostore=0; cc.t=t; init_exp(t,VRELOCABLE,pc); init_exp(&cc.v,VVOID,0); luaK_exp2nextreg(ls->fs,t); checknext(ls,'{'); do{ if(ls->t.token=='}')break; closelistfield(fs,&cc); switch(ls->t.token){ case TK_NAME:{ luaX_lookahead(ls); if(ls->lookahead.token!='=') listfield(ls,&cc); else recfield(ls,&cc); break; } case'[':{ recfield(ls,&cc); break; } default:{ listfield(ls,&cc); break; } } }while(testnext(ls,',')||testnext(ls,';')); check_match(ls,'}','{',line); lastlistfield(fs,&cc); SETARG_B(fs->f->code[pc],luaO_int2fb(cc.na)); SETARG_C(fs->f->code[pc],luaO_int2fb(cc.nh)); } static void parlist(LexState*ls){ FuncState*fs=ls->fs; Proto*f=fs->f; int nparams=0; f->is_vararg=0; if(ls->t.token!=')'){ do{ switch(ls->t.token){ case TK_NAME:{ new_localvar(ls,str_checkname(ls),nparams++); break; } case TK_DOTS:{ luaX_next(ls); f->is_vararg|=2; break; } default:luaX_syntaxerror(ls," or "LUA_QL("...")" expected"); } }while(!f->is_vararg&&testnext(ls,',')); } adjustlocalvars(ls,nparams); f->numparams=cast_byte(fs->nactvar-(f->is_vararg&1)); luaK_reserveregs(fs,fs->nactvar); } static void body(LexState*ls,expdesc*e,int needself,int line){ FuncState new_fs; open_func(ls,&new_fs); new_fs.f->linedefined=line; checknext(ls,'('); if(needself){ new_localvarliteral(ls,"self",0); adjustlocalvars(ls,1); } parlist(ls); checknext(ls,')'); chunk(ls); new_fs.f->lastlinedefined=ls->linenumber; check_match(ls,TK_END,TK_FUNCTION,line); close_func(ls); pushclosure(ls,&new_fs,e); } static int explist1(LexState*ls,expdesc*v){ int n=1; expr(ls,v); while(testnext(ls,',')){ luaK_exp2nextreg(ls->fs,v); expr(ls,v); n++; } return n; } static void funcargs(LexState*ls,expdesc*f){ FuncState*fs=ls->fs; expdesc args; int base,nparams; int line=ls->linenumber; switch(ls->t.token){ case'(':{ if(line!=ls->lastline) luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); luaX_next(ls); if(ls->t.token==')') args.k=VVOID; else{ explist1(ls,&args); luaK_setmultret(fs,&args); } check_match(ls,')','(',line); break; } case'{':{ constructor(ls,&args); break; } case TK_STRING:{ codestring(ls,&args,ls->t.seminfo.ts); luaX_next(ls); break; } default:{ luaX_syntaxerror(ls,"function arguments expected"); return; } } base=f->u.s.info; if(hasmultret(args.k)) nparams=(-1); else{ if(args.k!=VVOID) luaK_exp2nextreg(fs,&args); nparams=fs->freereg-(base+1); } init_exp(f,VCALL,luaK_codeABC(fs,OP_CALL,base,nparams+1,2)); luaK_fixline(fs,line); fs->freereg=base+1; } static void prefixexp(LexState*ls,expdesc*v){ switch(ls->t.token){ case'(':{ int line=ls->linenumber; luaX_next(ls); expr(ls,v); check_match(ls,')','(',line); luaK_dischargevars(ls->fs,v); return; } case TK_NAME:{ singlevar(ls,v); return; } default:{ luaX_syntaxerror(ls,"unexpected symbol"); return; } } } static void primaryexp(LexState*ls,expdesc*v){ FuncState*fs=ls->fs; prefixexp(ls,v); for(;;){ switch(ls->t.token){ case'.':{ field(ls,v); break; } case'[':{ expdesc key; luaK_exp2anyreg(fs,v); yindex(ls,&key); luaK_indexed(fs,v,&key); break; } case':':{ expdesc key; luaX_next(ls); checkname(ls,&key); luaK_self(fs,v,&key); funcargs(ls,v); break; } case'(':case TK_STRING:case'{':{ luaK_exp2nextreg(fs,v); funcargs(ls,v); break; } default:return; } } } static void simpleexp(LexState*ls,expdesc*v){ switch(ls->t.token){ case TK_NUMBER:{ init_exp(v,VKNUM,0); v->u.nval=ls->t.seminfo.r; break; } case TK_STRING:{ codestring(ls,v,ls->t.seminfo.ts); break; } case TK_NIL:{ init_exp(v,VNIL,0); break; } case TK_TRUE:{ init_exp(v,VTRUE,0); break; } case TK_FALSE:{ init_exp(v,VFALSE,0); break; } case TK_DOTS:{ FuncState*fs=ls->fs; check_condition(ls,fs->f->is_vararg, "cannot use "LUA_QL("...")" outside a vararg function"); fs->f->is_vararg&=~4; init_exp(v,VVARARG,luaK_codeABC(fs,OP_VARARG,0,1,0)); break; } case'{':{ constructor(ls,v); return; } case TK_FUNCTION:{ luaX_next(ls); body(ls,v,0,ls->linenumber); return; } default:{ primaryexp(ls,v); return; } } luaX_next(ls); } static UnOpr getunopr(int op){ switch(op){ case TK_NOT:return OPR_NOT; case'-':return OPR_MINUS; case'#':return OPR_LEN; default:return OPR_NOUNOPR; } } static BinOpr getbinopr(int op){ switch(op){ case'+':return OPR_ADD; case'-':return OPR_SUB; case'*':return OPR_MUL; case'/':return OPR_DIV; case'%':return OPR_MOD; case'^':return OPR_POW; case TK_CONCAT:return OPR_CONCAT; case TK_NE:return OPR_NE; case TK_EQ:return OPR_EQ; case'<':return OPR_LT; case TK_LE:return OPR_LE; case'>':return OPR_GT; case TK_GE:return OPR_GE; case TK_AND:return OPR_AND; case TK_OR:return OPR_OR; default:return OPR_NOBINOPR; } } static const struct{ lu_byte left; lu_byte right; }priority[]={ {6,6},{6,6},{7,7},{7,7},{7,7}, {10,9},{5,4}, {3,3},{3,3}, {3,3},{3,3},{3,3},{3,3}, {2,2},{1,1} }; static BinOpr subexpr(LexState*ls,expdesc*v,unsigned int limit){ BinOpr op; UnOpr uop; enterlevel(ls); uop=getunopr(ls->t.token); if(uop!=OPR_NOUNOPR){ luaX_next(ls); subexpr(ls,v,8); luaK_prefix(ls->fs,uop,v); } else simpleexp(ls,v); op=getbinopr(ls->t.token); while(op!=OPR_NOBINOPR&&priority[op].left>limit){ expdesc v2; BinOpr nextop; luaX_next(ls); luaK_infix(ls->fs,op,v); nextop=subexpr(ls,&v2,priority[op].right); luaK_posfix(ls->fs,op,v,&v2); op=nextop; } leavelevel(ls); return op; } static void expr(LexState*ls,expdesc*v){ subexpr(ls,v,0); } static int block_follow(int token){ switch(token){ case TK_ELSE:case TK_ELSEIF:case TK_END: case TK_UNTIL:case TK_EOS: return 1; default:return 0; } } static void block(LexState*ls){ FuncState*fs=ls->fs; BlockCnt bl; enterblock(fs,&bl,0); chunk(ls); leaveblock(fs); } struct LHS_assign{ struct LHS_assign*prev; expdesc v; }; static void check_conflict(LexState*ls,struct LHS_assign*lh,expdesc*v){ FuncState*fs=ls->fs; int extra=fs->freereg; int conflict=0; for(;lh;lh=lh->prev){ if(lh->v.k==VINDEXED){ if(lh->v.u.s.info==v->u.s.info){ conflict=1; lh->v.u.s.info=extra; } if(lh->v.u.s.aux==v->u.s.info){ conflict=1; lh->v.u.s.aux=extra; } } } if(conflict){ luaK_codeABC(fs,OP_MOVE,fs->freereg,v->u.s.info,0); luaK_reserveregs(fs,1); } } static void assignment(LexState*ls,struct LHS_assign*lh,int nvars){ expdesc e; check_condition(ls,VLOCAL<=lh->v.k&&lh->v.k<=VINDEXED, "syntax error"); if(testnext(ls,',')){ struct LHS_assign nv; nv.prev=lh; primaryexp(ls,&nv.v); if(nv.v.k==VLOCAL) check_conflict(ls,lh,&nv.v); luaY_checklimit(ls->fs,nvars,200-ls->L->nCcalls, "variables in assignment"); assignment(ls,&nv,nvars+1); } else{ int nexps; checknext(ls,'='); nexps=explist1(ls,&e); if(nexps!=nvars){ adjust_assign(ls,nvars,nexps,&e); if(nexps>nvars) ls->fs->freereg-=nexps-nvars; } else{ luaK_setoneret(ls->fs,&e); luaK_storevar(ls->fs,&lh->v,&e); return; } } init_exp(&e,VNONRELOC,ls->fs->freereg-1); luaK_storevar(ls->fs,&lh->v,&e); } static int cond(LexState*ls){ expdesc v; expr(ls,&v); if(v.k==VNIL)v.k=VFALSE; luaK_goiftrue(ls->fs,&v); return v.f; } static void breakstat(LexState*ls){ FuncState*fs=ls->fs; BlockCnt*bl=fs->bl; int upval=0; while(bl&&!bl->isbreakable){ upval|=bl->upval; bl=bl->previous; } if(!bl) luaX_syntaxerror(ls,"no loop to break"); if(upval) luaK_codeABC(fs,OP_CLOSE,bl->nactvar,0,0); luaK_concat(fs,&bl->breaklist,luaK_jump(fs)); } static void whilestat(LexState*ls,int line){ FuncState*fs=ls->fs; int whileinit; int condexit; BlockCnt bl; luaX_next(ls); whileinit=luaK_getlabel(fs); condexit=cond(ls); enterblock(fs,&bl,1); checknext(ls,TK_DO); block(ls); luaK_patchlist(fs,luaK_jump(fs),whileinit); check_match(ls,TK_END,TK_WHILE,line); leaveblock(fs); luaK_patchtohere(fs,condexit); } static void repeatstat(LexState*ls,int line){ int condexit; FuncState*fs=ls->fs; int repeat_init=luaK_getlabel(fs); BlockCnt bl1,bl2; enterblock(fs,&bl1,1); enterblock(fs,&bl2,0); luaX_next(ls); chunk(ls); check_match(ls,TK_UNTIL,TK_REPEAT,line); condexit=cond(ls); if(!bl2.upval){ leaveblock(fs); luaK_patchlist(ls->fs,condexit,repeat_init); } else{ breakstat(ls); luaK_patchtohere(ls->fs,condexit); leaveblock(fs); luaK_patchlist(ls->fs,luaK_jump(fs),repeat_init); } leaveblock(fs); } static int exp1(LexState*ls){ expdesc e; int k; expr(ls,&e); k=e.k; luaK_exp2nextreg(ls->fs,&e); return k; } static void forbody(LexState*ls,int base,int line,int nvars,int isnum){ BlockCnt bl; FuncState*fs=ls->fs; int prep,endfor; adjustlocalvars(ls,3); checknext(ls,TK_DO); prep=isnum?luaK_codeAsBx(fs,OP_FORPREP,base,(-1)):luaK_jump(fs); enterblock(fs,&bl,0); adjustlocalvars(ls,nvars); luaK_reserveregs(fs,nvars); block(ls); leaveblock(fs); luaK_patchtohere(fs,prep); endfor=(isnum)?luaK_codeAsBx(fs,OP_FORLOOP,base,(-1)): luaK_codeABC(fs,OP_TFORLOOP,base,0,nvars); luaK_fixline(fs,line); luaK_patchlist(fs,(isnum?endfor:luaK_jump(fs)),prep+1); } static void fornum(LexState*ls,TString*varname,int line){ FuncState*fs=ls->fs; int base=fs->freereg; new_localvarliteral(ls,"(for index)",0); new_localvarliteral(ls,"(for limit)",1); new_localvarliteral(ls,"(for step)",2); new_localvar(ls,varname,3); checknext(ls,'='); exp1(ls); checknext(ls,','); exp1(ls); if(testnext(ls,',')) exp1(ls); else{ luaK_codeABx(fs,OP_LOADK,fs->freereg,luaK_numberK(fs,1)); luaK_reserveregs(fs,1); } forbody(ls,base,line,1,1); } static void forlist(LexState*ls,TString*indexname){ FuncState*fs=ls->fs; expdesc e; int nvars=0; int line; int base=fs->freereg; new_localvarliteral(ls,"(for generator)",nvars++); new_localvarliteral(ls,"(for state)",nvars++); new_localvarliteral(ls,"(for control)",nvars++); new_localvar(ls,indexname,nvars++); while(testnext(ls,',')) new_localvar(ls,str_checkname(ls),nvars++); checknext(ls,TK_IN); line=ls->linenumber; adjust_assign(ls,3,explist1(ls,&e),&e); luaK_checkstack(fs,3); forbody(ls,base,line,nvars-3,0); } static void forstat(LexState*ls,int line){ FuncState*fs=ls->fs; TString*varname; BlockCnt bl; enterblock(fs,&bl,1); luaX_next(ls); varname=str_checkname(ls); switch(ls->t.token){ case'=':fornum(ls,varname,line);break; case',':case TK_IN:forlist(ls,varname);break; default:luaX_syntaxerror(ls,LUA_QL("=")" or "LUA_QL("in")" expected"); } check_match(ls,TK_END,TK_FOR,line); leaveblock(fs); } static int test_then_block(LexState*ls){ int condexit; luaX_next(ls); condexit=cond(ls); checknext(ls,TK_THEN); block(ls); return condexit; } static void ifstat(LexState*ls,int line){ FuncState*fs=ls->fs; int flist; int escapelist=(-1); flist=test_then_block(ls); while(ls->t.token==TK_ELSEIF){ luaK_concat(fs,&escapelist,luaK_jump(fs)); luaK_patchtohere(fs,flist); flist=test_then_block(ls); } if(ls->t.token==TK_ELSE){ luaK_concat(fs,&escapelist,luaK_jump(fs)); luaK_patchtohere(fs,flist); luaX_next(ls); block(ls); } else luaK_concat(fs,&escapelist,flist); luaK_patchtohere(fs,escapelist); check_match(ls,TK_END,TK_IF,line); } static void localfunc(LexState*ls){ expdesc v,b; FuncState*fs=ls->fs; new_localvar(ls,str_checkname(ls),0); init_exp(&v,VLOCAL,fs->freereg); luaK_reserveregs(fs,1); adjustlocalvars(ls,1); body(ls,&b,0,ls->linenumber); luaK_storevar(fs,&v,&b); getlocvar(fs,fs->nactvar-1).startpc=fs->pc; } static void localstat(LexState*ls){ int nvars=0; int nexps; expdesc e; do{ new_localvar(ls,str_checkname(ls),nvars++); }while(testnext(ls,',')); if(testnext(ls,'=')) nexps=explist1(ls,&e); else{ e.k=VVOID; nexps=0; } adjust_assign(ls,nvars,nexps,&e); adjustlocalvars(ls,nvars); } static int funcname(LexState*ls,expdesc*v){ int needself=0; singlevar(ls,v); while(ls->t.token=='.') field(ls,v); if(ls->t.token==':'){ needself=1; field(ls,v); } return needself; } static void funcstat(LexState*ls,int line){ int needself; expdesc v,b; luaX_next(ls); needself=funcname(ls,&v); body(ls,&b,needself,line); luaK_storevar(ls->fs,&v,&b); luaK_fixline(ls->fs,line); } static void exprstat(LexState*ls){ FuncState*fs=ls->fs; struct LHS_assign v; primaryexp(ls,&v.v); if(v.v.k==VCALL) SETARG_C(getcode(fs,&v.v),1); else{ v.prev=NULL; assignment(ls,&v,1); } } static void retstat(LexState*ls){ FuncState*fs=ls->fs; expdesc e; int first,nret; luaX_next(ls); if(block_follow(ls->t.token)||ls->t.token==';') first=nret=0; else{ nret=explist1(ls,&e); if(hasmultret(e.k)){ luaK_setmultret(fs,&e); if(e.k==VCALL&&nret==1){ SET_OPCODE(getcode(fs,&e),OP_TAILCALL); } first=fs->nactvar; nret=(-1); } else{ if(nret==1) first=luaK_exp2anyreg(fs,&e); else{ luaK_exp2nextreg(fs,&e); first=fs->nactvar; } } } luaK_ret(fs,first,nret); } static int statement(LexState*ls){ int line=ls->linenumber; switch(ls->t.token){ case TK_IF:{ ifstat(ls,line); return 0; } case TK_WHILE:{ whilestat(ls,line); return 0; } case TK_DO:{ luaX_next(ls); block(ls); check_match(ls,TK_END,TK_DO,line); return 0; } case TK_FOR:{ forstat(ls,line); return 0; } case TK_REPEAT:{ repeatstat(ls,line); return 0; } case TK_FUNCTION:{ funcstat(ls,line); return 0; } case TK_LOCAL:{ luaX_next(ls); if(testnext(ls,TK_FUNCTION)) localfunc(ls); else localstat(ls); return 0; } case TK_RETURN:{ retstat(ls); return 1; } case TK_BREAK:{ luaX_next(ls); breakstat(ls); return 1; } default:{ exprstat(ls); return 0; } } } static void chunk(LexState*ls){ int islast=0; enterlevel(ls); while(!islast&&!block_follow(ls->t.token)){ islast=statement(ls); testnext(ls,';'); ls->fs->freereg=ls->fs->nactvar; } leavelevel(ls); } static const TValue*luaV_tonumber(const TValue*obj,TValue*n){ lua_Number num; if(ttisnumber(obj))return obj; if(ttisstring(obj)&&luaO_str2d(svalue(obj),&num)){ setnvalue(n,num); return n; } else return NULL; } static int luaV_tostring(lua_State*L,StkId obj){ if(!ttisnumber(obj)) return 0; else{ char s[32]; lua_Number n=nvalue(obj); lua_number2str(s,n); setsvalue(L,obj,luaS_new(L,s)); return 1; } } static void callTMres(lua_State*L,StkId res,const TValue*f, const TValue*p1,const TValue*p2){ ptrdiff_t result=savestack(L,res); setobj(L,L->top,f); setobj(L,L->top+1,p1); setobj(L,L->top+2,p2); luaD_checkstack(L,3); L->top+=3; luaD_call(L,L->top-3,1); res=restorestack(L,result); L->top--; setobj(L,res,L->top); } static void callTM(lua_State*L,const TValue*f,const TValue*p1, const TValue*p2,const TValue*p3){ setobj(L,L->top,f); setobj(L,L->top+1,p1); setobj(L,L->top+2,p2); setobj(L,L->top+3,p3); luaD_checkstack(L,4); L->top+=4; luaD_call(L,L->top-4,0); } static void luaV_gettable(lua_State*L,const TValue*t,TValue*key,StkId val){ int loop; for(loop=0;loop<100;loop++){ const TValue*tm; if(ttistable(t)){ Table*h=hvalue(t); const TValue*res=luaH_get(h,key); if(!ttisnil(res)|| (tm=fasttm(L,h->metatable,TM_INDEX))==NULL){ setobj(L,val,res); return; } } else if(ttisnil(tm=luaT_gettmbyobj(L,t,TM_INDEX))) luaG_typeerror(L,t,"index"); if(ttisfunction(tm)){ callTMres(L,val,tm,t,key); return; } t=tm; } luaG_runerror(L,"loop in gettable"); } static void luaV_settable(lua_State*L,const TValue*t,TValue*key,StkId val){ int loop; TValue temp; for(loop=0;loop<100;loop++){ const TValue*tm; if(ttistable(t)){ Table*h=hvalue(t); TValue*oldval=luaH_set(L,h,key); if(!ttisnil(oldval)|| (tm=fasttm(L,h->metatable,TM_NEWINDEX))==NULL){ setobj(L,oldval,val); h->flags=0; luaC_barriert(L,h,val); return; } } else if(ttisnil(tm=luaT_gettmbyobj(L,t,TM_NEWINDEX))) luaG_typeerror(L,t,"index"); if(ttisfunction(tm)){ callTM(L,tm,t,key,val); return; } setobj(L,&temp,tm); t=&temp; } luaG_runerror(L,"loop in settable"); } static int call_binTM(lua_State*L,const TValue*p1,const TValue*p2, StkId res,TMS event){ const TValue*tm=luaT_gettmbyobj(L,p1,event); if(ttisnil(tm)) tm=luaT_gettmbyobj(L,p2,event); if(ttisnil(tm))return 0; callTMres(L,res,tm,p1,p2); return 1; } static const TValue*get_compTM(lua_State*L,Table*mt1,Table*mt2, TMS event){ const TValue*tm1=fasttm(L,mt1,event); const TValue*tm2; if(tm1==NULL)return NULL; if(mt1==mt2)return tm1; tm2=fasttm(L,mt2,event); if(tm2==NULL)return NULL; if(luaO_rawequalObj(tm1,tm2)) return tm1; return NULL; } static int call_orderTM(lua_State*L,const TValue*p1,const TValue*p2, TMS event){ const TValue*tm1=luaT_gettmbyobj(L,p1,event); const TValue*tm2; if(ttisnil(tm1))return-1; tm2=luaT_gettmbyobj(L,p2,event); if(!luaO_rawequalObj(tm1,tm2)) return-1; callTMres(L,L->top,tm1,p1,p2); return!l_isfalse(L->top); } static int l_strcmp(const TString*ls,const TString*rs){ const char*l=getstr(ls); size_t ll=ls->tsv.len; const char*r=getstr(rs); size_t lr=rs->tsv.len; for(;;){ int temp=strcoll(l,r); if(temp!=0)return temp; else{ size_t len=strlen(l); if(len==lr) return(len==ll)?0:1; else if(len==ll) return-1; len++; l+=len;ll-=len;r+=len;lr-=len; } } } static int luaV_lessthan(lua_State*L,const TValue*l,const TValue*r){ int res; if(ttype(l)!=ttype(r)) return luaG_ordererror(L,l,r); else if(ttisnumber(l)) return luai_numlt(nvalue(l),nvalue(r)); else if(ttisstring(l)) return l_strcmp(rawtsvalue(l),rawtsvalue(r))<0; else if((res=call_orderTM(L,l,r,TM_LT))!=-1) return res; return luaG_ordererror(L,l,r); } static int lessequal(lua_State*L,const TValue*l,const TValue*r){ int res; if(ttype(l)!=ttype(r)) return luaG_ordererror(L,l,r); else if(ttisnumber(l)) return luai_numle(nvalue(l),nvalue(r)); else if(ttisstring(l)) return l_strcmp(rawtsvalue(l),rawtsvalue(r))<=0; else if((res=call_orderTM(L,l,r,TM_LE))!=-1) return res; else if((res=call_orderTM(L,r,l,TM_LT))!=-1) return!res; return luaG_ordererror(L,l,r); } static int luaV_equalval(lua_State*L,const TValue*t1,const TValue*t2){ const TValue*tm; switch(ttype(t1)){ case 0:return 1; case 3:return luai_numeq(nvalue(t1),nvalue(t2)); case 1:return bvalue(t1)==bvalue(t2); case 2:return pvalue(t1)==pvalue(t2); case 7:{ if(uvalue(t1)==uvalue(t2))return 1; tm=get_compTM(L,uvalue(t1)->metatable,uvalue(t2)->metatable, TM_EQ); break; } case 5:{ if(hvalue(t1)==hvalue(t2))return 1; tm=get_compTM(L,hvalue(t1)->metatable,hvalue(t2)->metatable,TM_EQ); break; } default:return gcvalue(t1)==gcvalue(t2); } if(tm==NULL)return 0; callTMres(L,L->top,tm,t1,t2); return!l_isfalse(L->top); } static void luaV_concat(lua_State*L,int total,int last){ do{ StkId top=L->base+last+1; int n=2; if(!(ttisstring(top-2)||ttisnumber(top-2))||!tostring(L,top-1)){ if(!call_binTM(L,top-2,top-1,top-2,TM_CONCAT)) luaG_concaterror(L,top-2,top-1); }else if(tsvalue(top-1)->len==0) (void)tostring(L,top-2); else{ size_t tl=tsvalue(top-1)->len; char*buffer; int i; for(n=1;nlen; if(l>=((size_t)(~(size_t)0)-2)-tl)luaG_runerror(L,"string length overflow"); tl+=l; } buffer=luaZ_openspace(L,&G(L)->buff,tl); tl=0; for(i=n;i>0;i--){ size_t l=tsvalue(top-i)->len; memcpy(buffer+tl,svalue(top-i),l); tl+=l; } setsvalue(L,top-n,luaS_newlstr(L,buffer,tl)); } total-=n-1; last-=n-1; }while(total>1); } static void Arith(lua_State*L,StkId ra,const TValue*rb, const TValue*rc,TMS op){ TValue tempb,tempc; const TValue*b,*c; if((b=luaV_tonumber(rb,&tempb))!=NULL&& (c=luaV_tonumber(rc,&tempc))!=NULL){ lua_Number nb=nvalue(b),nc=nvalue(c); switch(op){ case TM_ADD:setnvalue(ra,luai_numadd(nb,nc));break; case TM_SUB:setnvalue(ra,luai_numsub(nb,nc));break; case TM_MUL:setnvalue(ra,luai_nummul(nb,nc));break; case TM_DIV:setnvalue(ra,luai_numdiv(nb,nc));break; case TM_MOD:setnvalue(ra,luai_nummod(nb,nc));break; case TM_POW:setnvalue(ra,luai_numpow(nb,nc));break; case TM_UNM:setnvalue(ra,luai_numunm(nb));break; default:break; } } else if(!call_binTM(L,rb,rc,ra,op)) luaG_aritherror(L,rb,rc); } #define runtime_check(L,c){if(!(c))break;} #define RA(i)(base+GETARG_A(i)) #define RB(i)check_exp(getBMode(GET_OPCODE(i))==OpArgR,base+GETARG_B(i)) #define RKB(i)check_exp(getBMode(GET_OPCODE(i))==OpArgK,ISK(GETARG_B(i))?k+INDEXK(GETARG_B(i)):base+GETARG_B(i)) #define RKC(i)check_exp(getCMode(GET_OPCODE(i))==OpArgK,ISK(GETARG_C(i))?k+INDEXK(GETARG_C(i)):base+GETARG_C(i)) #define KBx(i)check_exp(getBMode(GET_OPCODE(i))==OpArgK,k+GETARG_Bx(i)) #define dojump(L,pc,i){(pc)+=(i);} #define Protect(x){L->savedpc=pc;{x;};base=L->base;} #define arith_op(op,tm){TValue*rb=RKB(i);TValue*rc=RKC(i);if(ttisnumber(rb)&&ttisnumber(rc)){lua_Number nb=nvalue(rb),nc=nvalue(rc);setnvalue(ra,op(nb,nc));}else Protect(Arith(L,ra,rb,rc,tm));} static void luaV_execute(lua_State*L,int nexeccalls){ LClosure*cl; StkId base; TValue*k; const Instruction*pc; reentry: pc=L->savedpc; cl=&clvalue(L->ci->func)->l; base=L->base; k=cl->p->k; for(;;){ const Instruction i=*pc++; StkId ra; ra=RA(i); switch(GET_OPCODE(i)){ case OP_MOVE:{ setobj(L,ra,RB(i)); continue; } case OP_LOADK:{ setobj(L,ra,KBx(i)); continue; } case OP_LOADBOOL:{ setbvalue(ra,GETARG_B(i)); if(GETARG_C(i))pc++; continue; } case OP_LOADNIL:{ TValue*rb=RB(i); do{ setnilvalue(rb--); }while(rb>=ra); continue; } case OP_GETUPVAL:{ int b=GETARG_B(i); setobj(L,ra,cl->upvals[b]->v); continue; } case OP_GETGLOBAL:{ TValue g; TValue*rb=KBx(i); sethvalue(L,&g,cl->env); Protect(luaV_gettable(L,&g,rb,ra)); continue; } case OP_GETTABLE:{ Protect(luaV_gettable(L,RB(i),RKC(i),ra)); continue; } case OP_SETGLOBAL:{ TValue g; sethvalue(L,&g,cl->env); Protect(luaV_settable(L,&g,KBx(i),ra)); continue; } case OP_SETUPVAL:{ UpVal*uv=cl->upvals[GETARG_B(i)]; setobj(L,uv->v,ra); luaC_barrier(L,uv,ra); continue; } case OP_SETTABLE:{ Protect(luaV_settable(L,ra,RKB(i),RKC(i))); continue; } case OP_NEWTABLE:{ int b=GETARG_B(i); int c=GETARG_C(i); sethvalue(L,ra,luaH_new(L,luaO_fb2int(b),luaO_fb2int(c))); Protect(luaC_checkGC(L)); continue; } case OP_SELF:{ StkId rb=RB(i); setobj(L,ra+1,rb); Protect(luaV_gettable(L,rb,RKC(i),ra)); continue; } case OP_ADD:{ arith_op(luai_numadd,TM_ADD); continue; } case OP_SUB:{ arith_op(luai_numsub,TM_SUB); continue; } case OP_MUL:{ arith_op(luai_nummul,TM_MUL); continue; } case OP_DIV:{ arith_op(luai_numdiv,TM_DIV); continue; } case OP_MOD:{ arith_op(luai_nummod,TM_MOD); continue; } case OP_POW:{ arith_op(luai_numpow,TM_POW); continue; } case OP_UNM:{ TValue*rb=RB(i); if(ttisnumber(rb)){ lua_Number nb=nvalue(rb); setnvalue(ra,luai_numunm(nb)); } else{ Protect(Arith(L,ra,rb,rb,TM_UNM)); } continue; } case OP_NOT:{ int res=l_isfalse(RB(i)); setbvalue(ra,res); continue; } case OP_LEN:{ const TValue*rb=RB(i); switch(ttype(rb)){ case 5:{ setnvalue(ra,cast_num(luaH_getn(hvalue(rb)))); break; } case 4:{ setnvalue(ra,cast_num(tsvalue(rb)->len)); break; } default:{ Protect( if(!call_binTM(L,rb,(&luaO_nilobject_),ra,TM_LEN)) luaG_typeerror(L,rb,"get length of"); ) } } continue; } case OP_CONCAT:{ int b=GETARG_B(i); int c=GETARG_C(i); Protect(luaV_concat(L,c-b+1,c);luaC_checkGC(L)); setobj(L,RA(i),base+b); continue; } case OP_JMP:{ dojump(L,pc,GETARG_sBx(i)); continue; } case OP_EQ:{ TValue*rb=RKB(i); TValue*rc=RKC(i); Protect( if(equalobj(L,rb,rc)==GETARG_A(i)) dojump(L,pc,GETARG_sBx(*pc)); ) pc++; continue; } case OP_LT:{ Protect( if(luaV_lessthan(L,RKB(i),RKC(i))==GETARG_A(i)) dojump(L,pc,GETARG_sBx(*pc)); ) pc++; continue; } case OP_LE:{ Protect( if(lessequal(L,RKB(i),RKC(i))==GETARG_A(i)) dojump(L,pc,GETARG_sBx(*pc)); ) pc++; continue; } case OP_TEST:{ if(l_isfalse(ra)!=GETARG_C(i)) dojump(L,pc,GETARG_sBx(*pc)); pc++; continue; } case OP_TESTSET:{ TValue*rb=RB(i); if(l_isfalse(rb)!=GETARG_C(i)){ setobj(L,ra,rb); dojump(L,pc,GETARG_sBx(*pc)); } pc++; continue; } case OP_CALL:{ int b=GETARG_B(i); int nresults=GETARG_C(i)-1; if(b!=0)L->top=ra+b; L->savedpc=pc; switch(luaD_precall(L,ra,nresults)){ case 0:{ nexeccalls++; goto reentry; } case 1:{ if(nresults>=0)L->top=L->ci->top; base=L->base; continue; } default:{ return; } } } case OP_TAILCALL:{ int b=GETARG_B(i); if(b!=0)L->top=ra+b; L->savedpc=pc; switch(luaD_precall(L,ra,(-1))){ case 0:{ CallInfo*ci=L->ci-1; int aux; StkId func=ci->func; StkId pfunc=(ci+1)->func; if(L->openupval)luaF_close(L,ci->base); L->base=ci->base=ci->func+((ci+1)->base-pfunc); for(aux=0;pfunc+auxtop;aux++) setobj(L,func+aux,pfunc+aux); ci->top=L->top=func+aux; ci->savedpc=L->savedpc; ci->tailcalls++; L->ci--; goto reentry; } case 1:{ base=L->base; continue; } default:{ return; } } } case OP_RETURN:{ int b=GETARG_B(i); if(b!=0)L->top=ra+b-1; if(L->openupval)luaF_close(L,base); L->savedpc=pc; b=luaD_poscall(L,ra); if(--nexeccalls==0) return; else{ if(b)L->top=L->ci->top; goto reentry; } } case OP_FORLOOP:{ lua_Number step=nvalue(ra+2); lua_Number idx=luai_numadd(nvalue(ra),step); lua_Number limit=nvalue(ra+1); if(luai_numlt(0,step)?luai_numle(idx,limit) :luai_numle(limit,idx)){ dojump(L,pc,GETARG_sBx(i)); setnvalue(ra,idx); setnvalue(ra+3,idx); } continue; } case OP_FORPREP:{ const TValue*init=ra; const TValue*plimit=ra+1; const TValue*pstep=ra+2; L->savedpc=pc; if(!tonumber(init,ra)) luaG_runerror(L,LUA_QL("for")" initial value must be a number"); else if(!tonumber(plimit,ra+1)) luaG_runerror(L,LUA_QL("for")" limit must be a number"); else if(!tonumber(pstep,ra+2)) luaG_runerror(L,LUA_QL("for")" step must be a number"); setnvalue(ra,luai_numsub(nvalue(ra),nvalue(pstep))); dojump(L,pc,GETARG_sBx(i)); continue; } case OP_TFORLOOP:{ StkId cb=ra+3; setobj(L,cb+2,ra+2); setobj(L,cb+1,ra+1); setobj(L,cb,ra); L->top=cb+3; Protect(luaD_call(L,cb,GETARG_C(i))); L->top=L->ci->top; cb=RA(i)+3; if(!ttisnil(cb)){ setobj(L,cb-1,cb); dojump(L,pc,GETARG_sBx(*pc)); } pc++; continue; } case OP_SETLIST:{ int n=GETARG_B(i); int c=GETARG_C(i); int last; Table*h; if(n==0){ n=cast_int(L->top-ra)-1; L->top=L->ci->top; } if(c==0)c=cast_int(*pc++); runtime_check(L,ttistable(ra)); h=hvalue(ra); last=((c-1)*50)+n; if(last>h->sizearray) luaH_resizearray(L,h,last); for(;n>0;n--){ TValue*val=ra+n; setobj(L,luaH_setnum(L,h,last--),val); luaC_barriert(L,h,val); } continue; } case OP_CLOSE:{ luaF_close(L,ra); continue; } case OP_CLOSURE:{ Proto*p; Closure*ncl; int nup,j; p=cl->p->p[GETARG_Bx(i)]; nup=p->nups; ncl=luaF_newLclosure(L,nup,cl->env); ncl->l.p=p; for(j=0;jl.upvals[j]=cl->upvals[GETARG_B(*pc)]; else{ ncl->l.upvals[j]=luaF_findupval(L,base+GETARG_B(*pc)); } } setclvalue(L,ra,ncl); Protect(luaC_checkGC(L)); continue; } case OP_VARARG:{ int b=GETARG_B(i)-1; int j; CallInfo*ci=L->ci; int n=cast_int(ci->base-ci->func)-cl->p->numparams-1; if(b==(-1)){ Protect(luaD_checkstack(L,n)); ra=RA(i); b=n; L->top=ra+n; } for(j=0;jbase-n+j); } else{ setnilvalue(ra+j); } } continue; } } } } #define api_checknelems(L,n)luai_apicheck(L,(n)<=(L->top-L->base)) #define api_checkvalidindex(L,i)luai_apicheck(L,(i)!=(&luaO_nilobject_)) #define api_incr_top(L){luai_apicheck(L,L->topci->top);L->top++;} static TValue*index2adr(lua_State*L,int idx){ if(idx>0){ TValue*o=L->base+(idx-1); luai_apicheck(L,idx<=L->ci->top-L->base); if(o>=L->top)return cast(TValue*,(&luaO_nilobject_)); else return o; } else if(idx>(-10000)){ luai_apicheck(L,idx!=0&&-idx<=L->top-L->base); return L->top+idx; } else switch(idx){ case(-10000):return registry(L); case(-10001):{ Closure*func=curr_func(L); sethvalue(L,&L->env,func->c.env); return&L->env; } case(-10002):return gt(L); default:{ Closure*func=curr_func(L); idx=(-10002)-idx; return(idx<=func->c.nupvalues) ?&func->c.upvalue[idx-1] :cast(TValue*,(&luaO_nilobject_)); } } } static Table*getcurrenv(lua_State*L){ if(L->ci==L->base_ci) return hvalue(gt(L)); else{ Closure*func=curr_func(L); return func->c.env; } } static int lua_checkstack(lua_State*L,int size){ int res=1; if(size>8000||(L->top-L->base+size)>8000) res=0; else if(size>0){ luaD_checkstack(L,size); if(L->ci->toptop+size) L->ci->top=L->top+size; } return res; } static lua_CFunction lua_atpanic(lua_State*L,lua_CFunction panicf){ lua_CFunction old; old=G(L)->panic; G(L)->panic=panicf; return old; } static int lua_gettop(lua_State*L){ return cast_int(L->top-L->base); } static void lua_settop(lua_State*L,int idx){ if(idx>=0){ luai_apicheck(L,idx<=L->stack_last-L->base); while(L->topbase+idx) setnilvalue(L->top++); L->top=L->base+idx; } else{ luai_apicheck(L,-(idx+1)<=(L->top-L->base)); L->top+=idx+1; } } static void lua_remove(lua_State*L,int idx){ StkId p; p=index2adr(L,idx); api_checkvalidindex(L,p); while(++ptop)setobj(L,p-1,p); L->top--; } static void lua_insert(lua_State*L,int idx){ StkId p; StkId q; p=index2adr(L,idx); api_checkvalidindex(L,p); for(q=L->top;q>p;q--)setobj(L,q,q-1); setobj(L,p,L->top); } static void lua_replace(lua_State*L,int idx){ StkId o; if(idx==(-10001)&&L->ci==L->base_ci) luaG_runerror(L,"no calling environment"); api_checknelems(L,1); o=index2adr(L,idx); api_checkvalidindex(L,o); if(idx==(-10001)){ Closure*func=curr_func(L); luai_apicheck(L,ttistable(L->top-1)); func->c.env=hvalue(L->top-1); luaC_barrier(L,func,L->top-1); } else{ setobj(L,o,L->top-1); if(idx<(-10002)) luaC_barrier(L,curr_func(L),L->top-1); } L->top--; } static void lua_pushvalue(lua_State*L,int idx){ setobj(L,L->top,index2adr(L,idx)); api_incr_top(L); } static int lua_type(lua_State*L,int idx){ StkId o=index2adr(L,idx); return(o==(&luaO_nilobject_))?(-1):ttype(o); } static const char*lua_typename(lua_State*L,int t){ UNUSED(L); return(t==(-1))?"no value":luaT_typenames[t]; } static int lua_iscfunction(lua_State*L,int idx){ StkId o=index2adr(L,idx); return iscfunction(o); } static int lua_isnumber(lua_State*L,int idx){ TValue n; const TValue*o=index2adr(L,idx); return tonumber(o,&n); } static int lua_isstring(lua_State*L,int idx){ int t=lua_type(L,idx); return(t==4||t==3); } static int lua_rawequal(lua_State*L,int index1,int index2){ StkId o1=index2adr(L,index1); StkId o2=index2adr(L,index2); return(o1==(&luaO_nilobject_)||o2==(&luaO_nilobject_))?0 :luaO_rawequalObj(o1,o2); } static int lua_lessthan(lua_State*L,int index1,int index2){ StkId o1,o2; int i; o1=index2adr(L,index1); o2=index2adr(L,index2); i=(o1==(&luaO_nilobject_)||o2==(&luaO_nilobject_))?0 :luaV_lessthan(L,o1,o2); return i; } static lua_Number lua_tonumber(lua_State*L,int idx){ TValue n; const TValue*o=index2adr(L,idx); if(tonumber(o,&n)) return nvalue(o); else return 0; } static lua_Integer lua_tointeger(lua_State*L,int idx){ TValue n; const TValue*o=index2adr(L,idx); if(tonumber(o,&n)){ lua_Integer res; lua_Number num=nvalue(o); lua_number2integer(res,num); return res; } else return 0; } static int lua_toboolean(lua_State*L,int idx){ const TValue*o=index2adr(L,idx); return!l_isfalse(o); } static const char*lua_tolstring(lua_State*L,int idx,size_t*len){ StkId o=index2adr(L,idx); if(!ttisstring(o)){ if(!luaV_tostring(L,o)){ if(len!=NULL)*len=0; return NULL; } luaC_checkGC(L); o=index2adr(L,idx); } if(len!=NULL)*len=tsvalue(o)->len; return svalue(o); } static size_t lua_objlen(lua_State*L,int idx){ StkId o=index2adr(L,idx); switch(ttype(o)){ case 4:return tsvalue(o)->len; case 7:return uvalue(o)->len; case 5:return luaH_getn(hvalue(o)); case 3:{ size_t l; l=(luaV_tostring(L,o)?tsvalue(o)->len:0); return l; } default:return 0; } } static lua_CFunction lua_tocfunction(lua_State*L,int idx){ StkId o=index2adr(L,idx); return(!iscfunction(o))?NULL:clvalue(o)->c.f; } static void*lua_touserdata(lua_State*L,int idx){ StkId o=index2adr(L,idx); switch(ttype(o)){ case 7:return(rawuvalue(o)+1); case 2:return pvalue(o); default:return NULL; } } static void lua_pushnil(lua_State*L){ setnilvalue(L->top); api_incr_top(L); } static void lua_pushnumber(lua_State*L,lua_Number n){ setnvalue(L->top,n); api_incr_top(L); } static void lua_pushinteger(lua_State*L,lua_Integer n){ setnvalue(L->top,cast_num(n)); api_incr_top(L); } static void lua_pushlstring(lua_State*L,const char*s,size_t len){ luaC_checkGC(L); setsvalue(L,L->top,luaS_newlstr(L,s,len)); api_incr_top(L); } static void lua_pushstring(lua_State*L,const char*s){ if(s==NULL) lua_pushnil(L); else lua_pushlstring(L,s,strlen(s)); } static const char*lua_pushvfstring(lua_State*L,const char*fmt, va_list argp){ const char*ret; luaC_checkGC(L); ret=luaO_pushvfstring(L,fmt,argp); return ret; } static const char*lua_pushfstring(lua_State*L,const char*fmt,...){ const char*ret; va_list argp; luaC_checkGC(L); va_start(argp,fmt); ret=luaO_pushvfstring(L,fmt,argp); va_end(argp); return ret; } static void lua_pushcclosure(lua_State*L,lua_CFunction fn,int n){ Closure*cl; luaC_checkGC(L); api_checknelems(L,n); cl=luaF_newCclosure(L,n,getcurrenv(L)); cl->c.f=fn; L->top-=n; while(n--) setobj(L,&cl->c.upvalue[n],L->top+n); setclvalue(L,L->top,cl); api_incr_top(L); } static void lua_pushboolean(lua_State*L,int b){ setbvalue(L->top,(b!=0)); api_incr_top(L); } static int lua_pushthread(lua_State*L){ setthvalue(L,L->top,L); api_incr_top(L); return(G(L)->mainthread==L); } static void lua_gettable(lua_State*L,int idx){ StkId t; t=index2adr(L,idx); api_checkvalidindex(L,t); luaV_gettable(L,t,L->top-1,L->top-1); } static void lua_getfield(lua_State*L,int idx,const char*k){ StkId t; TValue key; t=index2adr(L,idx); api_checkvalidindex(L,t); setsvalue(L,&key,luaS_new(L,k)); luaV_gettable(L,t,&key,L->top); api_incr_top(L); } static void lua_rawget(lua_State*L,int idx){ StkId t; t=index2adr(L,idx); luai_apicheck(L,ttistable(t)); setobj(L,L->top-1,luaH_get(hvalue(t),L->top-1)); } static void lua_rawgeti(lua_State*L,int idx,int n){ StkId o; o=index2adr(L,idx); luai_apicheck(L,ttistable(o)); setobj(L,L->top,luaH_getnum(hvalue(o),n)); api_incr_top(L); } static void lua_createtable(lua_State*L,int narray,int nrec){ luaC_checkGC(L); sethvalue(L,L->top,luaH_new(L,narray,nrec)); api_incr_top(L); } static int lua_getmetatable(lua_State*L,int objindex){ const TValue*obj; Table*mt=NULL; int res; obj=index2adr(L,objindex); switch(ttype(obj)){ case 5: mt=hvalue(obj)->metatable; break; case 7: mt=uvalue(obj)->metatable; break; default: mt=G(L)->mt[ttype(obj)]; break; } if(mt==NULL) res=0; else{ sethvalue(L,L->top,mt); api_incr_top(L); res=1; } return res; } static void lua_getfenv(lua_State*L,int idx){ StkId o; o=index2adr(L,idx); api_checkvalidindex(L,o); switch(ttype(o)){ case 6: sethvalue(L,L->top,clvalue(o)->c.env); break; case 7: sethvalue(L,L->top,uvalue(o)->env); break; case 8: setobj(L,L->top,gt(thvalue(o))); break; default: setnilvalue(L->top); break; } api_incr_top(L); } static void lua_settable(lua_State*L,int idx){ StkId t; api_checknelems(L,2); t=index2adr(L,idx); api_checkvalidindex(L,t); luaV_settable(L,t,L->top-2,L->top-1); L->top-=2; } static void lua_setfield(lua_State*L,int idx,const char*k){ StkId t; TValue key; api_checknelems(L,1); t=index2adr(L,idx); api_checkvalidindex(L,t); setsvalue(L,&key,luaS_new(L,k)); luaV_settable(L,t,&key,L->top-1); L->top--; } static void lua_rawset(lua_State*L,int idx){ StkId t; api_checknelems(L,2); t=index2adr(L,idx); luai_apicheck(L,ttistable(t)); setobj(L,luaH_set(L,hvalue(t),L->top-2),L->top-1); luaC_barriert(L,hvalue(t),L->top-1); L->top-=2; } static void lua_rawseti(lua_State*L,int idx,int n){ StkId o; api_checknelems(L,1); o=index2adr(L,idx); luai_apicheck(L,ttistable(o)); setobj(L,luaH_setnum(L,hvalue(o),n),L->top-1); luaC_barriert(L,hvalue(o),L->top-1); L->top--; } static int lua_setmetatable(lua_State*L,int objindex){ TValue*obj; Table*mt; api_checknelems(L,1); obj=index2adr(L,objindex); api_checkvalidindex(L,obj); if(ttisnil(L->top-1)) mt=NULL; else{ luai_apicheck(L,ttistable(L->top-1)); mt=hvalue(L->top-1); } switch(ttype(obj)){ case 5:{ hvalue(obj)->metatable=mt; if(mt) luaC_objbarriert(L,hvalue(obj),mt); break; } case 7:{ uvalue(obj)->metatable=mt; if(mt) luaC_objbarrier(L,rawuvalue(obj),mt); break; } default:{ G(L)->mt[ttype(obj)]=mt; break; } } L->top--; return 1; } static int lua_setfenv(lua_State*L,int idx){ StkId o; int res=1; api_checknelems(L,1); o=index2adr(L,idx); api_checkvalidindex(L,o); luai_apicheck(L,ttistable(L->top-1)); switch(ttype(o)){ case 6: clvalue(o)->c.env=hvalue(L->top-1); break; case 7: uvalue(o)->env=hvalue(L->top-1); break; case 8: sethvalue(L,gt(thvalue(o)),hvalue(L->top-1)); break; default: res=0; break; } if(res)luaC_objbarrier(L,gcvalue(o),hvalue(L->top-1)); L->top--; return res; } #define adjustresults(L,nres){if(nres==(-1)&&L->top>=L->ci->top)L->ci->top=L->top;} #define checkresults(L,na,nr)luai_apicheck(L,(nr)==(-1)||(L->ci->top-L->top>=(nr)-(na))) static void lua_call(lua_State*L,int nargs,int nresults){ StkId func; api_checknelems(L,nargs+1); checkresults(L,nargs,nresults); func=L->top-(nargs+1); luaD_call(L,func,nresults); adjustresults(L,nresults); } struct CallS{ StkId func; int nresults; }; static void f_call(lua_State*L,void*ud){ struct CallS*c=cast(struct CallS*,ud); luaD_call(L,c->func,c->nresults); } static int lua_pcall(lua_State*L,int nargs,int nresults,int errfunc){ struct CallS c; int status; ptrdiff_t func; api_checknelems(L,nargs+1); checkresults(L,nargs,nresults); if(errfunc==0) func=0; else{ StkId o=index2adr(L,errfunc); api_checkvalidindex(L,o); func=savestack(L,o); } c.func=L->top-(nargs+1); c.nresults=nresults; status=luaD_pcall(L,f_call,&c,savestack(L,c.func),func); adjustresults(L,nresults); return status; } static int lua_load(lua_State*L,lua_Reader reader,void*data, const char*chunkname){ ZIO z; int status; if(!chunkname)chunkname="?"; luaZ_init(L,&z,reader,data); status=luaD_protectedparser(L,&z,chunkname); return status; } static int lua_error(lua_State*L){ api_checknelems(L,1); luaG_errormsg(L); return 0; } static int lua_next(lua_State*L,int idx){ StkId t; int more; t=index2adr(L,idx); luai_apicheck(L,ttistable(t)); more=luaH_next(L,hvalue(t),L->top-1); if(more){ api_incr_top(L); } else L->top-=1; return more; } static void lua_concat(lua_State*L,int n){ api_checknelems(L,n); if(n>=2){ luaC_checkGC(L); luaV_concat(L,n,cast_int(L->top-L->base)-1); L->top-=(n-1); } else if(n==0){ setsvalue(L,L->top,luaS_newlstr(L,"",0)); api_incr_top(L); } } static void*lua_newuserdata(lua_State*L,size_t size){ Udata*u; luaC_checkGC(L); u=luaS_newudata(L,size,getcurrenv(L)); setuvalue(L,L->top,u); api_incr_top(L); return u+1; } #define luaL_getn(L,i)((int)lua_objlen(L,i)) #define luaL_setn(L,i,j)((void)0) typedef struct luaL_Reg{ const char*name; lua_CFunction func; }luaL_Reg; static void luaI_openlib(lua_State*L,const char*libname, const luaL_Reg*l,int nup); static int luaL_argerror(lua_State*L,int numarg,const char*extramsg); static const char* luaL_checklstring(lua_State*L,int numArg, size_t*l); static const char* luaL_optlstring(lua_State*L,int numArg, const char*def,size_t*l); static lua_Integer luaL_checkinteger(lua_State*L,int numArg); static lua_Integer luaL_optinteger(lua_State*L,int nArg, lua_Integer def); static int luaL_error(lua_State*L,const char*fmt,...); static const char* luaL_findtable(lua_State*L,int idx, const char*fname,int szhint); #define luaL_argcheck(L,cond,numarg,extramsg)((void)((cond)||luaL_argerror(L,(numarg),(extramsg)))) #define luaL_checkstring(L,n)(luaL_checklstring(L,(n),NULL)) #define luaL_optstring(L,n,d)(luaL_optlstring(L,(n),(d),NULL)) #define luaL_checkint(L,n)((int)luaL_checkinteger(L,(n))) #define luaL_optint(L,n,d)((int)luaL_optinteger(L,(n),(d))) #define luaL_typename(L,i)lua_typename(L,lua_type(L,(i))) #define luaL_getmetatable(L,n)(lua_getfield(L,(-10000),(n))) #define luaL_opt(L,f,n,d)(lua_isnoneornil(L,(n))?(d):f(L,(n))) typedef struct luaL_Buffer{ char*p; int lvl; lua_State*L; char buffer[BUFSIZ]; }luaL_Buffer; #define luaL_addchar(B,c)((void)((B)->p<((B)->buffer+BUFSIZ)||luaL_prepbuffer(B)),(*(B)->p++=(char)(c))) #define luaL_addsize(B,n)((B)->p+=(n)) static char* luaL_prepbuffer(luaL_Buffer*B); static int luaL_argerror(lua_State*L,int narg,const char*extramsg){ lua_Debug ar; if(!lua_getstack(L,0,&ar)) return luaL_error(L,"bad argument #%d (%s)",narg,extramsg); lua_getinfo(L,"n",&ar); if(strcmp(ar.namewhat,"method")==0){ narg--; if(narg==0) return luaL_error(L,"calling "LUA_QL("%s")" on bad self (%s)", ar.name,extramsg); } if(ar.name==NULL) ar.name="?"; return luaL_error(L,"bad argument #%d to "LUA_QL("%s")" (%s)", narg,ar.name,extramsg); } static int luaL_typerror(lua_State*L,int narg,const char*tname){ const char*msg=lua_pushfstring(L,"%s expected, got %s", tname,luaL_typename(L,narg)); return luaL_argerror(L,narg,msg); } static void tag_error(lua_State*L,int narg,int tag){ luaL_typerror(L,narg,lua_typename(L,tag)); } static void luaL_where(lua_State*L,int level){ lua_Debug ar; if(lua_getstack(L,level,&ar)){ lua_getinfo(L,"Sl",&ar); if(ar.currentline>0){ lua_pushfstring(L,"%s:%d: ",ar.short_src,ar.currentline); return; } } lua_pushliteral(L,""); } static int luaL_error(lua_State*L,const char*fmt,...){ va_list argp; va_start(argp,fmt); luaL_where(L,1); lua_pushvfstring(L,fmt,argp); va_end(argp); lua_concat(L,2); return lua_error(L); } static int luaL_newmetatable(lua_State*L,const char*tname){ lua_getfield(L,(-10000),tname); if(!lua_isnil(L,-1)) return 0; lua_pop(L,1); lua_newtable(L); lua_pushvalue(L,-1); lua_setfield(L,(-10000),tname); return 1; } static void*luaL_checkudata(lua_State*L,int ud,const char*tname){ void*p=lua_touserdata(L,ud); if(p!=NULL){ if(lua_getmetatable(L,ud)){ lua_getfield(L,(-10000),tname); if(lua_rawequal(L,-1,-2)){ lua_pop(L,2); return p; } } } luaL_typerror(L,ud,tname); return NULL; } static void luaL_checkstack(lua_State*L,int space,const char*mes){ if(!lua_checkstack(L,space)) luaL_error(L,"stack overflow (%s)",mes); } static void luaL_checktype(lua_State*L,int narg,int t){ if(lua_type(L,narg)!=t) tag_error(L,narg,t); } static void luaL_checkany(lua_State*L,int narg){ if(lua_type(L,narg)==(-1)) luaL_argerror(L,narg,"value expected"); } static const char*luaL_checklstring(lua_State*L,int narg,size_t*len){ const char*s=lua_tolstring(L,narg,len); if(!s)tag_error(L,narg,4); return s; } static const char*luaL_optlstring(lua_State*L,int narg, const char*def,size_t*len){ if(lua_isnoneornil(L,narg)){ if(len) *len=(def?strlen(def):0); return def; } else return luaL_checklstring(L,narg,len); } static lua_Number luaL_checknumber(lua_State*L,int narg){ lua_Number d=lua_tonumber(L,narg); if(d==0&&!lua_isnumber(L,narg)) tag_error(L,narg,3); return d; } static lua_Integer luaL_checkinteger(lua_State*L,int narg){ lua_Integer d=lua_tointeger(L,narg); if(d==0&&!lua_isnumber(L,narg)) tag_error(L,narg,3); return d; } static lua_Integer luaL_optinteger(lua_State*L,int narg, lua_Integer def){ return luaL_opt(L,luaL_checkinteger,narg,def); } static int luaL_getmetafield(lua_State*L,int obj,const char*event){ if(!lua_getmetatable(L,obj)) return 0; lua_pushstring(L,event); lua_rawget(L,-2); if(lua_isnil(L,-1)){ lua_pop(L,2); return 0; } else{ lua_remove(L,-2); return 1; } } static void luaL_register(lua_State*L,const char*libname, const luaL_Reg*l){ luaI_openlib(L,libname,l,0); } static int libsize(const luaL_Reg*l){ int size=0; for(;l->name;l++)size++; return size; } static void luaI_openlib(lua_State*L,const char*libname, const luaL_Reg*l,int nup){ if(libname){ int size=libsize(l); luaL_findtable(L,(-10000),"_LOADED",1); lua_getfield(L,-1,libname); if(!lua_istable(L,-1)){ lua_pop(L,1); if(luaL_findtable(L,(-10002),libname,size)!=NULL) luaL_error(L,"name conflict for module "LUA_QL("%s"),libname); lua_pushvalue(L,-1); lua_setfield(L,-3,libname); } lua_remove(L,-2); lua_insert(L,-(nup+1)); } for(;l->name;l++){ int i; for(i=0;ifunc,nup); lua_setfield(L,-(nup+2),l->name); } lua_pop(L,nup); } static const char*luaL_findtable(lua_State*L,int idx, const char*fname,int szhint){ const char*e; lua_pushvalue(L,idx); do{ e=strchr(fname,'.'); if(e==NULL)e=fname+strlen(fname); lua_pushlstring(L,fname,e-fname); lua_rawget(L,-2); if(lua_isnil(L,-1)){ lua_pop(L,1); lua_createtable(L,0,(*e=='.'?1:szhint)); lua_pushlstring(L,fname,e-fname); lua_pushvalue(L,-2); lua_settable(L,-4); } else if(!lua_istable(L,-1)){ lua_pop(L,2); return fname; } lua_remove(L,-2); fname=e+1; }while(*e=='.'); return NULL; } #define bufflen(B)((B)->p-(B)->buffer) #define bufffree(B)((size_t)(BUFSIZ-bufflen(B))) static int emptybuffer(luaL_Buffer*B){ size_t l=bufflen(B); if(l==0)return 0; else{ lua_pushlstring(B->L,B->buffer,l); B->p=B->buffer; B->lvl++; return 1; } } static void adjuststack(luaL_Buffer*B){ if(B->lvl>1){ lua_State*L=B->L; int toget=1; size_t toplen=lua_strlen(L,-1); do{ size_t l=lua_strlen(L,-(toget+1)); if(B->lvl-toget+1>=(20/2)||toplen>l){ toplen+=l; toget++; } else break; }while(togetlvl); lua_concat(L,toget); B->lvl=B->lvl-toget+1; } } static char*luaL_prepbuffer(luaL_Buffer*B){ if(emptybuffer(B)) adjuststack(B); return B->buffer; } static void luaL_addlstring(luaL_Buffer*B,const char*s,size_t l){ while(l--) luaL_addchar(B,*s++); } static void luaL_pushresult(luaL_Buffer*B){ emptybuffer(B); lua_concat(B->L,B->lvl); B->lvl=1; } static void luaL_addvalue(luaL_Buffer*B){ lua_State*L=B->L; size_t vl; const char*s=lua_tolstring(L,-1,&vl); if(vl<=bufffree(B)){ memcpy(B->p,s,vl); B->p+=vl; lua_pop(L,1); } else{ if(emptybuffer(B)) lua_insert(L,-2); B->lvl++; adjuststack(B); } } static void luaL_buffinit(lua_State*L,luaL_Buffer*B){ B->L=L; B->p=B->buffer; B->lvl=0; } typedef struct LoadF{ int extraline; FILE*f; char buff[BUFSIZ]; }LoadF; static const char*getF(lua_State*L,void*ud,size_t*size){ LoadF*lf=(LoadF*)ud; (void)L; if(lf->extraline){ lf->extraline=0; *size=1; return"\n"; } if(feof(lf->f))return NULL; *size=fread(lf->buff,1,sizeof(lf->buff),lf->f); return(*size>0)?lf->buff:NULL; } static int errfile(lua_State*L,const char*what,int fnameindex){ const char*serr=strerror(errno); const char*filename=lua_tostring(L,fnameindex)+1; lua_pushfstring(L,"cannot %s %s: %s",what,filename,serr); lua_remove(L,fnameindex); return(5+1); } static int luaL_loadfile(lua_State*L,const char*filename){ LoadF lf; int status,readstatus; int c; int fnameindex=lua_gettop(L)+1; lf.extraline=0; if(filename==NULL){ lua_pushliteral(L,"=stdin"); lf.f=stdin; } else{ lua_pushfstring(L,"@%s",filename); lf.f=fopen(filename,"r"); if(lf.f==NULL)return errfile(L,"open",fnameindex); } c=getc(lf.f); if(c=='#'){ lf.extraline=1; while((c=getc(lf.f))!=EOF&&c!='\n'); if(c=='\n')c=getc(lf.f); } if(c=="\033Lua"[0]&&filename){ lf.f=freopen(filename,"rb",lf.f); if(lf.f==NULL)return errfile(L,"reopen",fnameindex); while((c=getc(lf.f))!=EOF&&c!="\033Lua"[0]); lf.extraline=0; } ungetc(c,lf.f); status=lua_load(L,getF,&lf,lua_tostring(L,-1)); readstatus=ferror(lf.f); if(filename)fclose(lf.f); if(readstatus){ lua_settop(L,fnameindex); return errfile(L,"read",fnameindex); } lua_remove(L,fnameindex); return status; } typedef struct LoadS{ const char*s; size_t size; }LoadS; static const char*getS(lua_State*L,void*ud,size_t*size){ LoadS*ls=(LoadS*)ud; (void)L; if(ls->size==0)return NULL; *size=ls->size; ls->size=0; return ls->s; } static int luaL_loadbuffer(lua_State*L,const char*buff,size_t size, const char*name){ LoadS ls; ls.s=buff; ls.size=size; return lua_load(L,getS,&ls,name); } static void*l_alloc(void*ud,void*ptr,size_t osize,size_t nsize){ (void)ud; (void)osize; if(nsize==0){ free(ptr); return NULL; } else return realloc(ptr,nsize); } static int panic(lua_State*L){ (void)L; fprintf(stderr,"PANIC: unprotected error in call to Lua API (%s)\n", lua_tostring(L,-1)); return 0; } static lua_State*luaL_newstate(void){ lua_State*L=lua_newstate(l_alloc,NULL); if(L)lua_atpanic(L,&panic); return L; } static int luaB_tonumber(lua_State*L){ int base=luaL_optint(L,2,10); if(base==10){ luaL_checkany(L,1); if(lua_isnumber(L,1)){ lua_pushnumber(L,lua_tonumber(L,1)); return 1; } } else{ const char*s1=luaL_checkstring(L,1); char*s2; unsigned long n; luaL_argcheck(L,2<=base&&base<=36,2,"base out of range"); n=strtoul(s1,&s2,base); if(s1!=s2){ while(isspace((unsigned char)(*s2)))s2++; if(*s2=='\0'){ lua_pushnumber(L,(lua_Number)n); return 1; } } } lua_pushnil(L); return 1; } static int luaB_error(lua_State*L){ int level=luaL_optint(L,2,1); lua_settop(L,1); if(lua_isstring(L,1)&&level>0){ luaL_where(L,level); lua_pushvalue(L,1); lua_concat(L,2); } return lua_error(L); } static int luaB_setmetatable(lua_State*L){ int t=lua_type(L,2); luaL_checktype(L,1,5); luaL_argcheck(L,t==0||t==5,2, "nil or table expected"); if(luaL_getmetafield(L,1,"__metatable")) luaL_error(L,"cannot change a protected metatable"); lua_settop(L,2); lua_setmetatable(L,1); return 1; } static void getfunc(lua_State*L,int opt){ if(lua_isfunction(L,1))lua_pushvalue(L,1); else{ lua_Debug ar; int level=opt?luaL_optint(L,1,1):luaL_checkint(L,1); luaL_argcheck(L,level>=0,1,"level must be non-negative"); if(lua_getstack(L,level,&ar)==0) luaL_argerror(L,1,"invalid level"); lua_getinfo(L,"f",&ar); if(lua_isnil(L,-1)) luaL_error(L,"no function environment for tail call at level %d", level); } } static int luaB_setfenv(lua_State*L){ luaL_checktype(L,2,5); getfunc(L,0); lua_pushvalue(L,2); if(lua_isnumber(L,1)&&lua_tonumber(L,1)==0){ lua_pushthread(L); lua_insert(L,-2); lua_setfenv(L,-2); return 0; } else if(lua_iscfunction(L,-2)||lua_setfenv(L,-2)==0) luaL_error(L, LUA_QL("setfenv")" cannot change environment of given object"); return 1; } static int luaB_rawget(lua_State*L){ luaL_checktype(L,1,5); luaL_checkany(L,2); lua_settop(L,2); lua_rawget(L,1); return 1; } static int luaB_type(lua_State*L){ luaL_checkany(L,1); lua_pushstring(L,luaL_typename(L,1)); return 1; } static int luaB_next(lua_State*L){ luaL_checktype(L,1,5); lua_settop(L,2); if(lua_next(L,1)) return 2; else{ lua_pushnil(L); return 1; } } static int luaB_pairs(lua_State*L){ luaL_checktype(L,1,5); lua_pushvalue(L,lua_upvalueindex(1)); lua_pushvalue(L,1); lua_pushnil(L); return 3; } static int ipairsaux(lua_State*L){ int i=luaL_checkint(L,2); luaL_checktype(L,1,5); i++; lua_pushinteger(L,i); lua_rawgeti(L,1,i); return(lua_isnil(L,-1))?0:2; } static int luaB_ipairs(lua_State*L){ luaL_checktype(L,1,5); lua_pushvalue(L,lua_upvalueindex(1)); lua_pushvalue(L,1); lua_pushinteger(L,0); return 3; } static int load_aux(lua_State*L,int status){ if(status==0) return 1; else{ lua_pushnil(L); lua_insert(L,-2); return 2; } } static int luaB_loadstring(lua_State*L){ size_t l; const char*s=luaL_checklstring(L,1,&l); const char*chunkname=luaL_optstring(L,2,s); return load_aux(L,luaL_loadbuffer(L,s,l,chunkname)); } static int luaB_loadfile(lua_State*L){ const char*fname=luaL_optstring(L,1,NULL); return load_aux(L,luaL_loadfile(L,fname)); } static int luaB_assert(lua_State*L){ luaL_checkany(L,1); if(!lua_toboolean(L,1)) return luaL_error(L,"%s",luaL_optstring(L,2,"assertion failed!")); return lua_gettop(L); } static int luaB_unpack(lua_State*L){ int i,e,n; luaL_checktype(L,1,5); i=luaL_optint(L,2,1); e=luaL_opt(L,luaL_checkint,3,luaL_getn(L,1)); if(i>e)return 0; n=e-i+1; if(n<=0||!lua_checkstack(L,n)) return luaL_error(L,"too many results to unpack"); lua_rawgeti(L,1,i); while(i++e)e=pos; for(i=e;i>pos;i--){ lua_rawgeti(L,1,i-1); lua_rawseti(L,1,i); } break; } default:{ return luaL_error(L,"wrong number of arguments to "LUA_QL("insert")); } } luaL_setn(L,1,e); lua_rawseti(L,1,pos); return 0; } static int tremove(lua_State*L){ int e=aux_getn(L,1); int pos=luaL_optint(L,2,e); if(!(1<=pos&&pos<=e)) return 0; luaL_setn(L,1,e-1); lua_rawgeti(L,1,pos); for(;posu)luaL_error(L,"invalid order function for sorting"); lua_pop(L,1); } while(lua_rawgeti(L,1,--j),sort_comp(L,-3,-1)){ if(j0); } l=strlen(p); if(l==0||p[l-1]!='\n') luaL_addsize(&b,l); else{ luaL_addsize(&b,l-1); luaL_pushresult(&b); return 1; } } } static int read_chars(lua_State*L,FILE*f,size_t n){ size_t rlen; size_t nr; luaL_Buffer b; luaL_buffinit(L,&b); rlen=BUFSIZ; do{ char*p=luaL_prepbuffer(&b); if(rlen>n)rlen=n; nr=fread(p,sizeof(char),rlen,f); luaL_addsize(&b,nr); n-=nr; }while(n>0&&nr==rlen); luaL_pushresult(&b); return(n==0||lua_objlen(L,-1)>0); } static int g_read(lua_State*L,FILE*f,int first){ int nargs=lua_gettop(L)-1; int success; int n; clearerr(f); if(nargs==0){ success=read_line(L,f); n=first+1; } else{ luaL_checkstack(L,nargs+20,"too many arguments"); success=1; for(n=first;nargs--&&success;n++){ if(lua_type(L,n)==3){ size_t l=(size_t)lua_tointeger(L,n); success=(l==0)?test_eof(L,f):read_chars(L,f,l); } else{ const char*p=lua_tostring(L,n); luaL_argcheck(L,p&&p[0]=='*',n,"invalid option"); switch(p[1]){ case'n': success=read_number(L,f); break; case'l': success=read_line(L,f); break; case'a': read_chars(L,f,~((size_t)0)); success=1; break; default: return luaL_argerror(L,n,"invalid format"); } } } } if(ferror(f)) return pushresult(L,0,NULL); if(!success){ lua_pop(L,1); lua_pushnil(L); } return n-first; } static int io_read(lua_State*L){ return g_read(L,getiofile(L,1),1); } static int f_read(lua_State*L){ return g_read(L,tofile(L),2); } static int io_readline(lua_State*L){ FILE*f=*(FILE**)lua_touserdata(L,lua_upvalueindex(1)); int sucess; if(f==NULL) luaL_error(L,"file is already closed"); sucess=read_line(L,f); if(ferror(f)) return luaL_error(L,"%s",strerror(errno)); if(sucess)return 1; else{ if(lua_toboolean(L,lua_upvalueindex(2))){ lua_settop(L,0); lua_pushvalue(L,lua_upvalueindex(1)); aux_close(L); } return 0; } } static int g_write(lua_State*L,FILE*f,int arg){ int nargs=lua_gettop(L)-1; int status=1; for(;nargs--;arg++){ if(lua_type(L,arg)==3){ status=status&& fprintf(f,"%.14g",lua_tonumber(L,arg))>0; } else{ size_t l; const char*s=luaL_checklstring(L,arg,&l); status=status&&(fwrite(s,sizeof(char),l,f)==l); } } return pushresult(L,status,NULL); } static int io_write(lua_State*L){ return g_write(L,getiofile(L,2),1); } static int f_write(lua_State*L){ return g_write(L,tofile(L),2); } static int io_flush(lua_State*L){ return pushresult(L,fflush(getiofile(L,2))==0,NULL); } static int f_flush(lua_State*L){ return pushresult(L,fflush(tofile(L))==0,NULL); } static const luaL_Reg iolib[]={ {"close",io_close}, {"flush",io_flush}, {"input",io_input}, {"lines",io_lines}, {"open",io_open}, {"output",io_output}, {"read",io_read}, {"type",io_type}, {"write",io_write}, {NULL,NULL} }; static const luaL_Reg flib[]={ {"close",io_close}, {"flush",f_flush}, {"lines",f_lines}, {"read",f_read}, {"write",f_write}, {"__gc",io_gc}, {NULL,NULL} }; static void createmeta(lua_State*L){ luaL_newmetatable(L,"FILE*"); lua_pushvalue(L,-1); lua_setfield(L,-2,"__index"); luaL_register(L,NULL,flib); } static void createstdfile(lua_State*L,FILE*f,int k,const char*fname){ *newfile(L)=f; if(k>0){ lua_pushvalue(L,-1); lua_rawseti(L,(-10001),k); } lua_pushvalue(L,-2); lua_setfenv(L,-2); lua_setfield(L,-3,fname); } static void newfenv(lua_State*L,lua_CFunction cls){ lua_createtable(L,0,1); lua_pushcfunction(L,cls); lua_setfield(L,-2,"__close"); } static int luaopen_io(lua_State*L){ createmeta(L); newfenv(L,io_fclose); lua_replace(L,(-10001)); luaL_register(L,"io",iolib); newfenv(L,io_noclose); createstdfile(L,stdin,1,"stdin"); createstdfile(L,stdout,2,"stdout"); createstdfile(L,stderr,0,"stderr"); lua_pop(L,1); lua_getfield(L,-1,"popen"); newfenv(L,io_pclose); lua_setfenv(L,-2); lua_pop(L,1); return 1; } static int os_pushresult(lua_State*L,int i,const char*filename){ int en=errno; if(i){ lua_pushboolean(L,1); return 1; } else{ lua_pushnil(L); lua_pushfstring(L,"%s: %s",filename,strerror(en)); lua_pushinteger(L,en); return 3; } } static int os_remove(lua_State*L){ const char*filename=luaL_checkstring(L,1); return os_pushresult(L,remove(filename)==0,filename); } static int os_exit(lua_State*L){ exit(luaL_optint(L,1,EXIT_SUCCESS)); } static const luaL_Reg syslib[]={ {"exit",os_exit}, {"remove",os_remove}, {NULL,NULL} }; static int luaopen_os(lua_State*L){ luaL_register(L,"os",syslib); return 1; } #define uchar(c)((unsigned char)(c)) static ptrdiff_t posrelat(ptrdiff_t pos,size_t len){ if(pos<0)pos+=(ptrdiff_t)len+1; return(pos>=0)?pos:0; } static int str_sub(lua_State*L){ size_t l; const char*s=luaL_checklstring(L,1,&l); ptrdiff_t start=posrelat(luaL_checkinteger(L,2),l); ptrdiff_t end=posrelat(luaL_optinteger(L,3,-1),l); if(start<1)start=1; if(end>(ptrdiff_t)l)end=(ptrdiff_t)l; if(start<=end) lua_pushlstring(L,s+start-1,end-start+1); else lua_pushliteral(L,""); return 1; } static int str_lower(lua_State*L){ size_t l; size_t i; luaL_Buffer b; const char*s=luaL_checklstring(L,1,&l); luaL_buffinit(L,&b); for(i=0;i0) luaL_addlstring(&b,s,l); luaL_pushresult(&b); return 1; } static int str_byte(lua_State*L){ size_t l; const char*s=luaL_checklstring(L,1,&l); ptrdiff_t posi=posrelat(luaL_optinteger(L,2,1),l); ptrdiff_t pose=posrelat(luaL_optinteger(L,3,posi),l); int n,i; if(posi<=0)posi=1; if((size_t)pose>l)pose=l; if(posi>pose)return 0; n=(int)(pose-posi+1); if(posi+n<=pose) luaL_error(L,"string slice too long"); luaL_checkstack(L,n,"string slice too long"); for(i=0;i=ms->level||ms->capture[l].len==(-1)) return luaL_error(ms->L,"invalid capture index"); return l; } static int capture_to_close(MatchState*ms){ int level=ms->level; for(level--;level>=0;level--) if(ms->capture[level].len==(-1))return level; return luaL_error(ms->L,"invalid pattern capture"); } static const char*classend(MatchState*ms,const char*p){ switch(*p++){ case'%':{ if(*p=='\0') luaL_error(ms->L,"malformed pattern (ends with "LUA_QL("%%")")"); return p+1; } case'[':{ if(*p=='^')p++; do{ if(*p=='\0') luaL_error(ms->L,"malformed pattern (missing "LUA_QL("]")")"); if(*(p++)=='%'&&*p!='\0') p++; }while(*p!=']'); return p+1; } default:{ return p; } } } static int match_class(int c,int cl){ int res; switch(tolower(cl)){ case'a':res=isalpha(c);break; case'c':res=iscntrl(c);break; case'd':res=isdigit(c);break; case'l':res=islower(c);break; case'p':res=ispunct(c);break; case's':res=isspace(c);break; case'u':res=isupper(c);break; case'w':res=isalnum(c);break; case'x':res=isxdigit(c);break; case'z':res=(c==0);break; default:return(cl==c); } return(islower(cl)?res:!res); } static int matchbracketclass(int c,const char*p,const char*ec){ int sig=1; if(*(p+1)=='^'){ sig=0; p++; } while(++pL,"unbalanced pattern"); if(*s!=*p)return NULL; else{ int b=*p; int e=*(p+1); int cont=1; while(++ssrc_end){ if(*s==e){ if(--cont==0)return s+1; } else if(*s==b)cont++; } } return NULL; } static const char*max_expand(MatchState*ms,const char*s, const char*p,const char*ep){ ptrdiff_t i=0; while((s+i)src_end&&singlematch(uchar(*(s+i)),p,ep)) i++; while(i>=0){ const char*res=match(ms,(s+i),ep+1); if(res)return res; i--; } return NULL; } static const char*min_expand(MatchState*ms,const char*s, const char*p,const char*ep){ for(;;){ const char*res=match(ms,s,ep+1); if(res!=NULL) return res; else if(ssrc_end&&singlematch(uchar(*s),p,ep)) s++; else return NULL; } } static const char*start_capture(MatchState*ms,const char*s, const char*p,int what){ const char*res; int level=ms->level; if(level>=32)luaL_error(ms->L,"too many captures"); ms->capture[level].init=s; ms->capture[level].len=what; ms->level=level+1; if((res=match(ms,s,p))==NULL) ms->level--; return res; } static const char*end_capture(MatchState*ms,const char*s, const char*p){ int l=capture_to_close(ms); const char*res; ms->capture[l].len=s-ms->capture[l].init; if((res=match(ms,s,p))==NULL) ms->capture[l].len=(-1); return res; } static const char*match_capture(MatchState*ms,const char*s,int l){ size_t len; l=check_capture(ms,l); len=ms->capture[l].len; if((size_t)(ms->src_end-s)>=len&& memcmp(ms->capture[l].init,s,len)==0) return s+len; else return NULL; } static const char*match(MatchState*ms,const char*s,const char*p){ init: switch(*p){ case'(':{ if(*(p+1)==')') return start_capture(ms,s,p+2,(-2)); else return start_capture(ms,s,p+1,(-1)); } case')':{ return end_capture(ms,s,p+1); } case'%':{ switch(*(p+1)){ case'b':{ s=matchbalance(ms,s,p+2); if(s==NULL)return NULL; p+=4;goto init; } case'f':{ const char*ep;char previous; p+=2; if(*p!='[') luaL_error(ms->L,"missing "LUA_QL("[")" after " LUA_QL("%%f")" in pattern"); ep=classend(ms,p); previous=(s==ms->src_init)?'\0':*(s-1); if(matchbracketclass(uchar(previous),p,ep-1)|| !matchbracketclass(uchar(*s),p,ep-1))return NULL; p=ep;goto init; } default:{ if(isdigit(uchar(*(p+1)))){ s=match_capture(ms,s,uchar(*(p+1))); if(s==NULL)return NULL; p+=2;goto init; } goto dflt; } } } case'\0':{ return s; } case'$':{ if(*(p+1)=='\0') return(s==ms->src_end)?s:NULL; else goto dflt; } default:dflt:{ const char*ep=classend(ms,p); int m=ssrc_end&&singlematch(uchar(*s),p,ep); switch(*ep){ case'?':{ const char*res; if(m&&((res=match(ms,s+1,ep+1))!=NULL)) return res; p=ep+1;goto init; } case'*':{ return max_expand(ms,s,p,ep); } case'+':{ return(m?max_expand(ms,s+1,p,ep):NULL); } case'-':{ return min_expand(ms,s,p,ep); } default:{ if(!m)return NULL; s++;p=ep;goto init; } } } } } static const char*lmemfind(const char*s1,size_t l1, const char*s2,size_t l2){ if(l2==0)return s1; else if(l2>l1)return NULL; else{ const char*init; l2--; l1=l1-l2; while(l1>0&&(init=(const char*)memchr(s1,*s2,l1))!=NULL){ init++; if(memcmp(init,s2+1,l2)==0) return init-1; else{ l1-=init-s1; s1=init; } } return NULL; } } static void push_onecapture(MatchState*ms,int i,const char*s, const char*e){ if(i>=ms->level){ if(i==0) lua_pushlstring(ms->L,s,e-s); else luaL_error(ms->L,"invalid capture index"); } else{ ptrdiff_t l=ms->capture[i].len; if(l==(-1))luaL_error(ms->L,"unfinished capture"); if(l==(-2)) lua_pushinteger(ms->L,ms->capture[i].init-ms->src_init+1); else lua_pushlstring(ms->L,ms->capture[i].init,l); } } static int push_captures(MatchState*ms,const char*s,const char*e){ int i; int nlevels=(ms->level==0&&s)?1:ms->level; luaL_checkstack(ms->L,nlevels,"too many captures"); for(i=0;il1)init=(ptrdiff_t)l1; if(find&&(lua_toboolean(L,4)|| strpbrk(p,"^$*+?.([%-")==NULL)){ const char*s2=lmemfind(s+init,l1-init,p,l2); if(s2){ lua_pushinteger(L,s2-s+1); lua_pushinteger(L,s2-s+l2); return 2; } } else{ MatchState ms; int anchor=(*p=='^')?(p++,1):0; const char*s1=s+init; ms.L=L; ms.src_init=s; ms.src_end=s+l1; do{ const char*res; ms.level=0; if((res=match(&ms,s1,p))!=NULL){ if(find){ lua_pushinteger(L,s1-s+1); lua_pushinteger(L,res-s); return push_captures(&ms,NULL,0)+2; } else return push_captures(&ms,s1,res); } }while(s1++L,3,&l); for(i=0;iL; switch(lua_type(L,3)){ case 3: case 4:{ add_s(ms,b,s,e); return; } case 6:{ int n; lua_pushvalue(L,3); n=push_captures(ms,s,e); lua_call(L,n,1); break; } case 5:{ push_onecapture(ms,0,s,e); lua_gettable(L,3); break; } } if(!lua_toboolean(L,-1)){ lua_pop(L,1); lua_pushlstring(L,s,e-s); } else if(!lua_isstring(L,-1)) luaL_error(L,"invalid replacement value (a %s)",luaL_typename(L,-1)); luaL_addvalue(b); } static int str_gsub(lua_State*L){ size_t srcl; const char*src=luaL_checklstring(L,1,&srcl); const char*p=luaL_checkstring(L,2); int tr=lua_type(L,3); int max_s=luaL_optint(L,4,srcl+1); int anchor=(*p=='^')?(p++,1):0; int n=0; MatchState ms; luaL_Buffer b; luaL_argcheck(L,tr==3||tr==4|| tr==6||tr==5,3, "string/function/table expected"); luaL_buffinit(L,&b); ms.L=L; ms.src_init=src; ms.src_end=src+srcl; while(nsrc) src=e; else if(src=sizeof("-+ #0")) luaL_error(L,"invalid format (repeated flags)"); if(isdigit(uchar(*p)))p++; if(isdigit(uchar(*p)))p++; if(*p=='.'){ p++; if(isdigit(uchar(*p)))p++; if(isdigit(uchar(*p)))p++; } if(isdigit(uchar(*p))) luaL_error(L,"invalid format (width or precision too long)"); *(form++)='%'; strncpy(form,strfrmt,p-strfrmt+1); form+=p-strfrmt+1; *form='\0'; return p; } static void addintlen(char*form){ size_t l=strlen(form); char spec=form[l-1]; strcpy(form+l-1,"l"); form[l+sizeof("l")-2]=spec; form[l+sizeof("l")-1]='\0'; } static int str_format(lua_State*L){ int top=lua_gettop(L); int arg=1; size_t sfl; const char*strfrmt=luaL_checklstring(L,arg,&sfl); const char*strfrmt_end=strfrmt+sfl; luaL_Buffer b; luaL_buffinit(L,&b); while(strfrmttop) luaL_argerror(L,arg,"no value"); strfrmt=scanformat(L,strfrmt,form); switch(*strfrmt++){ case'c':{ sprintf(buff,form,(int)luaL_checknumber(L,arg)); break; } case'd':case'i':{ addintlen(form); sprintf(buff,form,(long)luaL_checknumber(L,arg)); break; } case'o':case'u':case'x':case'X':{ addintlen(form); sprintf(buff,form,(unsigned long)luaL_checknumber(L,arg)); break; } case'e':case'E':case'f': case'g':case'G':{ sprintf(buff,form,(double)luaL_checknumber(L,arg)); break; } case'q':{ addquoted(L,&b,arg); continue; } case's':{ size_t l; const char*s=luaL_checklstring(L,arg,&l); if(!strchr(form,'.')&&l>=100){ lua_pushvalue(L,arg); luaL_addvalue(&b); continue; } else{ sprintf(buff,form,s); break; } } default:{ return luaL_error(L,"invalid option "LUA_QL("%%%c")" to " LUA_QL("format"),*(strfrmt-1)); } } luaL_addlstring(&b,buff,strlen(buff)); } } luaL_pushresult(&b); return 1; } static const luaL_Reg strlib[]={ {"byte",str_byte}, {"char",str_char}, {"find",str_find}, {"format",str_format}, {"gmatch",gmatch}, {"gsub",str_gsub}, {"lower",str_lower}, {"match",str_match}, {"rep",str_rep}, {"sub",str_sub}, {"upper",str_upper}, {NULL,NULL} }; static void createmetatable(lua_State*L){ lua_createtable(L,0,1); lua_pushliteral(L,""); lua_pushvalue(L,-2); lua_setmetatable(L,-2); lua_pop(L,1); lua_pushvalue(L,-2); lua_setfield(L,-2,"__index"); lua_pop(L,1); } static int luaopen_string(lua_State*L){ luaL_register(L,"string",strlib); createmetatable(L); return 1; } static const luaL_Reg lualibs[]={ {"",luaopen_base}, {"table",luaopen_table}, {"io",luaopen_io}, {"os",luaopen_os}, {"string",luaopen_string}, {NULL,NULL} }; static void luaL_openlibs(lua_State*L){ const luaL_Reg*lib=lualibs; for(;lib->func;lib++){ lua_pushcfunction(L,lib->func); lua_pushstring(L,lib->name); lua_call(L,1,0); } } typedef unsigned int UB; static UB barg(lua_State*L,int idx){ union{lua_Number n;U64 b;}bn; bn.n=lua_tonumber(L,idx)+6755399441055744.0; if(bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,"number"); return(UB)bn.b; } #define BRET(b)lua_pushnumber(L,(lua_Number)(int)(b));return 1; static int tobit(lua_State*L){ BRET(barg(L,1))} static int bnot(lua_State*L){ BRET(~barg(L,1))} static int band(lua_State*L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);BRET(b)} static int bor(lua_State*L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);BRET(b)} static int bxor(lua_State*L){ int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);BRET(b)} static int lshift(lua_State*L){ UB b=barg(L,1),n=barg(L,2)&31;BRET(b<>n)} static int arshift(lua_State*L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((int)b>>n)} static int rol(lua_State*L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((b<>(32-n)))} static int ror(lua_State*L){ UB b=barg(L,1),n=barg(L,2)&31;BRET((b>>n)|(b<<(32-n)))} static int bswap(lua_State*L){ UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)} static int tohex(lua_State*L){ UB b=barg(L,1); int n=lua_isnone(L,2)?8:(int)barg(L,2); const char*hexdigits="0123456789abcdef"; char buf[8]; int i; if(n<0){n=-n;hexdigits="0123456789ABCDEF";} if(n>8)n=8; for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;} lua_pushlstring(L,buf,(size_t)n); return 1; } static const struct luaL_Reg bitlib[]={ {"tobit",tobit}, {"bnot",bnot}, {"band",band}, {"bor",bor}, {"bxor",bxor}, {"lshift",lshift}, {"rshift",rshift}, {"arshift",arshift}, {"rol",rol}, {"ror",ror}, {"bswap",bswap}, {"tohex",tohex}, {NULL,NULL} }; int main(int argc,char**argv){ lua_State*L=luaL_newstate(); int i; luaL_openlibs(L); luaL_register(L,"bit",bitlib); if(argc<2)return sizeof(void*); lua_createtable(L,0,1); lua_pushstring(L,argv[1]); lua_rawseti(L,-2,0); lua_setglobal(L,"arg"); if(luaL_loadfile(L,argv[1])) goto err; for(i=2;i -- BYTECODE -- [...] -- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" -- -- local out = { -- -- Do something with each line: -- write = function(t, ...) io.write(...) end, -- close = function(t) end, -- flush = function(t) end, -- } -- bc.dump(foo, out) -- ------------------------------------------------------------------------------ -- Cache some library functions and objects. local jit = require("jit") assert(jit.version_num == 20001, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local bit = require("bit") local sub, gsub, format = string.sub, string.gsub, string.format local byte, band, shr = string.byte, bit.band, bit.rshift local funcinfo, funcbc, funck = jutil.funcinfo, jutil.funcbc, jutil.funck local funcuvname = jutil.funcuvname local bcnames = vmdef.bcnames local stdout, stderr = io.stdout, io.stderr ------------------------------------------------------------------------------ local function ctlsub(c) if c == "\n" then return "\\n" elseif c == "\r" then return "\\r" elseif c == "\t" then return "\\t" else return format("\\%03d", byte(c)) end end -- Return one bytecode line. local function bcline(func, pc, prefix) local ins, m = funcbc(func, pc) if not ins then return end local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) local a = band(shr(ins, 8), 0xff) local oidx = 6*band(ins, 0xff) local op = sub(bcnames, oidx+1, oidx+6) local s = format("%04d %s %-6s %3s ", pc, prefix or " ", op, ma == 0 and "" or a) local d = shr(ins, 16) if mc == 13*128 then -- BCMjump return format("%s=> %04d\n", s, pc+d-0x7fff) end if mb ~= 0 then d = band(d, 0xff) elseif mc == 0 then return s.."\n" end local kc if mc == 10*128 then -- BCMstr kc = funck(func, -d-1) kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) elseif mc == 9*128 then -- BCMnum kc = funck(func, d) if op == "TSETM " then kc = kc - 2^52 end elseif mc == 12*128 then -- BCMfunc local fi = funcinfo(funck(func, -d-1)) if fi.ffid then kc = vmdef.ffnames[fi.ffid] else kc = fi.loc end elseif mc == 5*128 then -- BCMuv kc = funcuvname(func, d) end if ma == 5 then -- BCMuv local ka = funcuvname(func, a) if kc then kc = ka.." ; "..kc else kc = ka end end if mb ~= 0 then local b = shr(ins, 24) if kc then return format("%s%3d %3d ; %s\n", s, b, d, kc) end return format("%s%3d %3d\n", s, b, d) end if kc then return format("%s%3d ; %s\n", s, d, kc) end if mc == 7*128 and d > 32767 then d = d - 65536 end -- BCMlits return format("%s%3d\n", s, d) end -- Collect branch targets of a function. local function bctargets(func) local target = {} for pc=1,1000000000 do local ins, m = funcbc(func, pc) if not ins then break end if band(m, 15*128) == 13*128 then target[pc+shr(ins, 16)-0x7fff] = true end end return target end -- Dump bytecode instructions of a function. local function bcdump(func, out, all) if not out then out = stdout end local fi = funcinfo(func) if all and fi.children then for n=-1,-1000000000,-1 do local k = funck(func, n) if not k then break end if type(k) == "proto" then bcdump(k, out, true) end end end out:write(format("-- BYTECODE -- %s-%d\n", fi.loc, fi.lastlinedefined)) local target = bctargets(func) for pc=1,1000000000 do local s = bcline(func, pc, target[pc] and "=>") if not s then break end out:write(s) end out:write("\n") out:flush() end ------------------------------------------------------------------------------ -- Active flag and output file handle. local active, out -- List handler. local function h_list(func) return bcdump(func, out) end -- Detach list handler. local function bclistoff() if active then active = false jit.attach(h_list) if out and out ~= stdout and out ~= stderr then out:close() end out = nil end end -- Open the output file and attach list handler. local function bcliston(outfile) if active then bclistoff() end if not outfile then outfile = os.getenv("LUAJIT_LISTFILE") end if outfile then out = outfile == "-" and stdout or assert(io.open(outfile, "w")) else out = stderr end jit.attach(h_list, "bc") active = true end -- Public module functions. module(...) line = bcline dump = bcdump targets = bctargets on = bcliston off = bclistoff start = bcliston -- For -j command line option. ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/bcsave.lua ================================================ ---------------------------------------------------------------------------- -- LuaJIT module to save/list bytecode. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- -- This module saves or lists the bytecode for an input file. -- It's run by the -b command line option. -- ------------------------------------------------------------------------------ local jit = require("jit") assert(jit.version_num == 20001, "LuaJIT core/library version mismatch") local bit = require("bit") -- Symbol name prefix for LuaJIT bytecode. local LJBC_PREFIX = "luaJIT_BC_" ------------------------------------------------------------------------------ local function usage() io.stderr:write[[ Save LuaJIT bytecode: luajit -b[options] input output -l Only list bytecode. -s Strip debug info (default). -g Keep debug info. -n name Set module name (default: auto-detect from input name). -t type Set output file type (default: auto-detect from output name). -a arch Override architecture for object files (default: native). -o os Override OS for object files (default: native). -e chunk Use chunk string as input. -- Stop handling options. - Use stdin as input and/or stdout as output. File types: c h obj o raw (default) ]] os.exit(1) end local function check(ok, ...) if ok then return ok, ... end io.stderr:write("luajit: ", ...) io.stderr:write("\n") os.exit(1) end local function readfile(input) if type(input) == "function" then return input end if input == "-" then input = nil end return check(loadfile(input)) end local function savefile(name, mode) if name == "-" then return io.stdout end return check(io.open(name, mode)) end ------------------------------------------------------------------------------ local map_type = { raw = "raw", c = "c", h = "h", o = "obj", obj = "obj", } local map_arch = { x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true, mips = true, mipsel = true, } local map_os = { linux = true, windows = true, osx = true, freebsd = true, netbsd = true, openbsd = true, solaris = true, } local function checkarg(str, map, err) str = string.lower(str) local s = check(map[str], "unknown ", err) return s == true and str or s end local function detecttype(str) local ext = string.match(string.lower(str), "%.(%a+)$") return map_type[ext] or "raw" end local function checkmodname(str) check(string.match(str, "^[%w_.%-]+$"), "bad module name") return string.gsub(str, "[%.%-]", "_") end local function detectmodname(str) if type(str) == "string" then local tail = string.match(str, "[^/\\]+$") if tail then str = tail end local head = string.match(str, "^(.*)%.[^.]*$") if head then str = head end str = string.match(str, "^[%w_.%-]+") else str = nil end check(str, "cannot derive module name, use -n name") return string.gsub(str, "[%.%-]", "_") end ------------------------------------------------------------------------------ local function bcsave_tail(fp, output, s) local ok, err = fp:write(s) if ok and output ~= "-" then ok, err = fp:close() end check(ok, "cannot write ", output, ": ", err) end local function bcsave_raw(output, s) local fp = savefile(output, "wb") bcsave_tail(fp, output, s) end local function bcsave_c(ctx, output, s) local fp = savefile(output, "w") if ctx.type == "c" then fp:write(string.format([[ #ifdef _cplusplus extern "C" #endif #ifdef _WIN32 __declspec(dllexport) #endif const char %s%s[] = { ]], LJBC_PREFIX, ctx.modname)) else fp:write(string.format([[ #define %s%s_SIZE %d static const char %s%s[] = { ]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname)) end local t, n, m = {}, 0, 0 for i=1,#s do local b = tostring(string.byte(s, i)) m = m + #b + 1 if m > 78 then fp:write(table.concat(t, ",", 1, n), ",\n") n, m = 0, #b + 1 end n = n + 1 t[n] = b end bcsave_tail(fp, output, table.concat(t, ",", 1, n).."\n};\n") end local function bcsave_elfobj(ctx, output, s, ffi) ffi.cdef[[ typedef struct { uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7]; uint16_t type, machine; uint32_t version; uint32_t entry, phofs, shofs; uint32_t flags; uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx; } ELF32header; typedef struct { uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7]; uint16_t type, machine; uint32_t version; uint64_t entry, phofs, shofs; uint32_t flags; uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx; } ELF64header; typedef struct { uint32_t name, type, flags, addr, ofs, size, link, info, align, entsize; } ELF32sectheader; typedef struct { uint32_t name, type; uint64_t flags, addr, ofs, size; uint32_t link, info; uint64_t align, entsize; } ELF64sectheader; typedef struct { uint32_t name, value, size; uint8_t info, other; uint16_t sectidx; } ELF32symbol; typedef struct { uint32_t name; uint8_t info, other; uint16_t sectidx; uint64_t value, size; } ELF64symbol; typedef struct { ELF32header hdr; ELF32sectheader sect[6]; ELF32symbol sym[2]; uint8_t space[4096]; } ELF32obj; typedef struct { ELF64header hdr; ELF64sectheader sect[6]; ELF64symbol sym[2]; uint8_t space[4096]; } ELF64obj; ]] local symname = LJBC_PREFIX..ctx.modname local is64, isbe = false, false if ctx.arch == "x64" then is64 = true elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" or ctx.arch == "mips" then isbe = true end -- Handle different host/target endianess. local function f32(x) return x end local f16, fofs = f32, f32 if ffi.abi("be") ~= isbe then f32 = bit.bswap function f16(x) return bit.rshift(bit.bswap(x), 16) end if is64 then local two32 = ffi.cast("int64_t", 2^32) function fofs(x) return bit.bswap(x)*two32 end else fofs = f32 end end -- Create ELF object and fill in header. local o = ffi.new(is64 and "ELF64obj" or "ELF32obj") local hdr = o.hdr if ctx.os == "bsd" or ctx.os == "other" then -- Determine native hdr.eosabi. local bf = assert(io.open("/bin/ls", "rb")) local bs = bf:read(9) bf:close() ffi.copy(o, bs, 9) check(hdr.emagic[0] == 127, "no support for writing native object files") else hdr.emagic = "\127ELF" hdr.eosabi = ({ freebsd=9, netbsd=2, openbsd=12, solaris=6 })[ctx.os] or 0 end hdr.eclass = is64 and 2 or 1 hdr.eendian = isbe and 2 or 1 hdr.eversion = 1 hdr.type = f16(1) hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20, mips=8, mipsel=8 })[ctx.arch]) if ctx.arch == "mips" or ctx.arch == "mipsel" then hdr.flags = 0x50001006 end hdr.version = f32(1) hdr.shofs = fofs(ffi.offsetof(o, "sect")) hdr.ehsize = f16(ffi.sizeof(hdr)) hdr.shentsize = f16(ffi.sizeof(o.sect[0])) hdr.shnum = f16(6) hdr.shstridx = f16(2) -- Fill in sections and symbols. local sofs, ofs = ffi.offsetof(o, "space"), 1 for i,name in ipairs{ ".symtab", ".shstrtab", ".strtab", ".rodata", ".note.GNU-stack", } do local sect = o.sect[i] sect.align = fofs(1) sect.name = f32(ofs) ffi.copy(o.space+ofs, name) ofs = ofs + #name+1 end o.sect[1].type = f32(2) -- .symtab o.sect[1].link = f32(3) o.sect[1].info = f32(1) o.sect[1].align = fofs(8) o.sect[1].ofs = fofs(ffi.offsetof(o, "sym")) o.sect[1].entsize = fofs(ffi.sizeof(o.sym[0])) o.sect[1].size = fofs(ffi.sizeof(o.sym)) o.sym[1].name = f32(1) o.sym[1].sectidx = f16(4) o.sym[1].size = fofs(#s) o.sym[1].info = 17 o.sect[2].type = f32(3) -- .shstrtab o.sect[2].ofs = fofs(sofs) o.sect[2].size = fofs(ofs) o.sect[3].type = f32(3) -- .strtab o.sect[3].ofs = fofs(sofs + ofs) o.sect[3].size = fofs(#symname+1) ffi.copy(o.space+ofs+1, symname) ofs = ofs + #symname + 2 o.sect[4].type = f32(1) -- .rodata o.sect[4].flags = fofs(2) o.sect[4].ofs = fofs(sofs + ofs) o.sect[4].size = fofs(#s) o.sect[5].type = f32(1) -- .note.GNU-stack o.sect[5].ofs = fofs(sofs + ofs + #s) -- Write ELF object file. local fp = savefile(output, "wb") fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs)) bcsave_tail(fp, output, s) end local function bcsave_peobj(ctx, output, s, ffi) ffi.cdef[[ typedef struct { uint16_t arch, nsects; uint32_t time, symtabofs, nsyms; uint16_t opthdrsz, flags; } PEheader; typedef struct { char name[8]; uint32_t vsize, vaddr, size, ofs, relocofs, lineofs; uint16_t nreloc, nline; uint32_t flags; } PEsection; typedef struct __attribute((packed)) { union { char name[8]; uint32_t nameref[2]; }; uint32_t value; int16_t sect; uint16_t type; uint8_t scl, naux; } PEsym; typedef struct __attribute((packed)) { uint32_t size; uint16_t nreloc, nline; uint32_t cksum; uint16_t assoc; uint8_t comdatsel, unused[3]; } PEsymaux; typedef struct { PEheader hdr; PEsection sect[2]; // Must be an even number of symbol structs. PEsym sym0; PEsymaux sym0aux; PEsym sym1; PEsymaux sym1aux; PEsym sym2; PEsym sym3; uint32_t strtabsize; uint8_t space[4096]; } PEobj; ]] local symname = LJBC_PREFIX..ctx.modname local is64 = false if ctx.arch == "x86" then symname = "_"..symname elseif ctx.arch == "x64" then is64 = true end local symexport = " /EXPORT:"..symname..",DATA " -- The file format is always little-endian. Swap if the host is big-endian. local function f32(x) return x end local f16 = f32 if ffi.abi("be") then f32 = bit.bswap function f16(x) return bit.rshift(bit.bswap(x), 16) end end -- Create PE object and fill in header. local o = ffi.new("PEobj") local hdr = o.hdr hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2, mips=0x366, mipsel=0x366 })[ctx.arch]) hdr.nsects = f16(2) hdr.symtabofs = f32(ffi.offsetof(o, "sym0")) hdr.nsyms = f32(6) -- Fill in sections and symbols. o.sect[0].name = ".drectve" o.sect[0].size = f32(#symexport) o.sect[0].flags = f32(0x00100a00) o.sym0.sect = f16(1) o.sym0.scl = 3 o.sym0.name = ".drectve" o.sym0.naux = 1 o.sym0aux.size = f32(#symexport) o.sect[1].name = ".rdata" o.sect[1].size = f32(#s) o.sect[1].flags = f32(0x40300040) o.sym1.sect = f16(2) o.sym1.scl = 3 o.sym1.name = ".rdata" o.sym1.naux = 1 o.sym1aux.size = f32(#s) o.sym2.sect = f16(2) o.sym2.scl = 2 o.sym2.nameref[1] = f32(4) o.sym3.sect = f16(-1) o.sym3.scl = 2 o.sym3.value = f32(1) o.sym3.name = "@feat.00" -- Mark as SafeSEH compliant. ffi.copy(o.space, symname) local ofs = #symname + 1 o.strtabsize = f32(ofs + 4) o.sect[0].ofs = f32(ffi.offsetof(o, "space") + ofs) ffi.copy(o.space + ofs, symexport) ofs = ofs + #symexport o.sect[1].ofs = f32(ffi.offsetof(o, "space") + ofs) -- Write PE object file. local fp = savefile(output, "wb") fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs)) bcsave_tail(fp, output, s) end local function bcsave_machobj(ctx, output, s, ffi) ffi.cdef[[ typedef struct { uint32_t magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags; } mach_header; typedef struct { mach_header; uint32_t reserved; } mach_header_64; typedef struct { uint32_t cmd, cmdsize; char segname[16]; uint32_t vmaddr, vmsize, fileoff, filesize; uint32_t maxprot, initprot, nsects, flags; } mach_segment_command; typedef struct { uint32_t cmd, cmdsize; char segname[16]; uint64_t vmaddr, vmsize, fileoff, filesize; uint32_t maxprot, initprot, nsects, flags; } mach_segment_command_64; typedef struct { char sectname[16], segname[16]; uint32_t addr, size; uint32_t offset, align, reloff, nreloc, flags; uint32_t reserved1, reserved2; } mach_section; typedef struct { char sectname[16], segname[16]; uint64_t addr, size; uint32_t offset, align, reloff, nreloc, flags; uint32_t reserved1, reserved2, reserved3; } mach_section_64; typedef struct { uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize; } mach_symtab_command; typedef struct { int32_t strx; uint8_t type, sect; int16_t desc; uint32_t value; } mach_nlist; typedef struct { uint32_t strx; uint8_t type, sect; uint16_t desc; uint64_t value; } mach_nlist_64; typedef struct { uint32_t magic, nfat_arch; } mach_fat_header; typedef struct { uint32_t cputype, cpusubtype, offset, size, align; } mach_fat_arch; typedef struct { struct { mach_header hdr; mach_segment_command seg; mach_section sec; mach_symtab_command sym; } arch[1]; mach_nlist sym_entry; uint8_t space[4096]; } mach_obj; typedef struct { struct { mach_header_64 hdr; mach_segment_command_64 seg; mach_section_64 sec; mach_symtab_command sym; } arch[1]; mach_nlist_64 sym_entry; uint8_t space[4096]; } mach_obj_64; typedef struct { mach_fat_header fat; mach_fat_arch fat_arch[4]; struct { mach_header hdr; mach_segment_command seg; mach_section sec; mach_symtab_command sym; } arch[4]; mach_nlist sym_entry; uint8_t space[4096]; } mach_fat_obj; ]] local symname = '_'..LJBC_PREFIX..ctx.modname local isfat, is64, align, mobj = false, false, 4, "mach_obj" if ctx.arch == "x64" then is64, align, mobj = true, 8, "mach_obj_64" elseif ctx.arch == "arm" then isfat, mobj = true, "mach_fat_obj" else check(ctx.arch == "x86", "unsupported architecture for OSX") end local function aligned(v, a) return bit.band(v+a-1, -a) end local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE. -- Create Mach-O object and fill in header. local o = ffi.new(mobj) local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12,12,12} })[ctx.arch] local cpusubtype = ({ x86={3}, x64={3}, arm={3,6,9,11} })[ctx.arch] if isfat then o.fat.magic = be32(0xcafebabe) o.fat.nfat_arch = be32(#cpusubtype) end -- Fill in sections and symbols. for i=0,#cpusubtype-1 do local ofs = 0 if isfat then local a = o.fat_arch[i] a.cputype = be32(cputype[i+1]) a.cpusubtype = be32(cpusubtype[i+1]) -- Subsequent slices overlap each other to share data. ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0]) a.offset = be32(ofs) a.size = be32(mach_size-ofs+#s) end local a = o.arch[i] a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface a.hdr.cputype = cputype[i+1] a.hdr.cpusubtype = cpusubtype[i+1] a.hdr.filetype = 1 a.hdr.ncmds = 2 a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym) a.seg.cmd = is64 and 0x19 or 0x1 a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec) a.seg.vmsize = #s a.seg.fileoff = mach_size-ofs a.seg.filesize = #s a.seg.maxprot = 1 a.seg.initprot = 1 a.seg.nsects = 1 ffi.copy(a.sec.sectname, "__data") ffi.copy(a.sec.segname, "__DATA") a.sec.size = #s a.sec.offset = mach_size-ofs a.sym.cmd = 2 a.sym.cmdsize = ffi.sizeof(a.sym) a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs a.sym.nsyms = 1 a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs a.sym.strsize = aligned(#symname+2, align) end o.sym_entry.type = 0xf o.sym_entry.sect = 1 o.sym_entry.strx = 1 ffi.copy(o.space+1, symname) -- Write Macho-O object file. local fp = savefile(output, "wb") fp:write(ffi.string(o, mach_size)) bcsave_tail(fp, output, s) end local function bcsave_obj(ctx, output, s) local ok, ffi = pcall(require, "ffi") check(ok, "FFI library required to write this file type") if ctx.os == "windows" then return bcsave_peobj(ctx, output, s, ffi) elseif ctx.os == "osx" then return bcsave_machobj(ctx, output, s, ffi) else return bcsave_elfobj(ctx, output, s, ffi) end end ------------------------------------------------------------------------------ local function bclist(input, output) local f = readfile(input) require("jit.bc").dump(f, savefile(output, "w"), true) end local function bcsave(ctx, input, output) local f = readfile(input) local s = string.dump(f, ctx.strip) local t = ctx.type if not t then t = detecttype(output) ctx.type = t end if t == "raw" then bcsave_raw(output, s) else if not ctx.modname then ctx.modname = detectmodname(input) end if t == "obj" then bcsave_obj(ctx, output, s) else bcsave_c(ctx, output, s) end end end local function docmd(...) local arg = {...} local n = 1 local list = false local ctx = { strip = true, arch = jit.arch, os = string.lower(jit.os), type = false, modname = false, } while n <= #arg do local a = arg[n] if type(a) == "string" and string.sub(a, 1, 1) == "-" and a ~= "-" then table.remove(arg, n) if a == "--" then break end for m=2,#a do local opt = string.sub(a, m, m) if opt == "l" then list = true elseif opt == "s" then ctx.strip = true elseif opt == "g" then ctx.strip = false else if arg[n] == nil or m ~= #a then usage() end if opt == "e" then if n ~= 1 then usage() end arg[1] = check(loadstring(arg[1])) elseif opt == "n" then ctx.modname = checkmodname(table.remove(arg, n)) elseif opt == "t" then ctx.type = checkarg(table.remove(arg, n), map_type, "file type") elseif opt == "a" then ctx.arch = checkarg(table.remove(arg, n), map_arch, "architecture") elseif opt == "o" then ctx.os = checkarg(table.remove(arg, n), map_os, "OS name") else usage() end end end else n = n + 1 end end if list then if #arg == 0 or #arg > 2 then usage() end bclist(arg[1], arg[2] or "-") else if #arg ~= 2 then usage() end bcsave(ctx, arg[1], arg[2]) end end ------------------------------------------------------------------------------ -- Public module functions. module(...) start = docmd -- Process -b command line option. ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/dis_arm.lua ================================================ ---------------------------------------------------------------------------- -- LuaJIT ARM disassembler module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- This is a helper module used by the LuaJIT machine code dumper module. -- -- It disassembles most user-mode ARMv7 instructions -- NYI: Advanced SIMD and VFP instructions. ------------------------------------------------------------------------------ local type = type local sub, byte, format = string.sub, string.byte, string.format local match, gmatch, gsub = string.match, string.gmatch, string.gsub local concat = table.concat local bit = require("bit") local band, bor, ror, tohex = bit.band, bit.bor, bit.ror, bit.tohex local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift ------------------------------------------------------------------------------ -- Opcode maps ------------------------------------------------------------------------------ local map_loadc = { shift = 8, mask = 15, [10] = { shift = 20, mask = 1, [0] = { shift = 23, mask = 3, [0] = "vmovFmDN", "vstmFNdr", _ = { shift = 21, mask = 1, [0] = "vstrFdl", { shift = 16, mask = 15, [13] = "vpushFdr", _ = "vstmdbFNdr", } }, }, { shift = 23, mask = 3, [0] = "vmovFDNm", { shift = 16, mask = 15, [13] = "vpopFdr", _ = "vldmFNdr", }, _ = { shift = 21, mask = 1, [0] = "vldrFdl", "vldmdbFNdr", }, }, }, [11] = { shift = 20, mask = 1, [0] = { shift = 23, mask = 3, [0] = "vmovGmDN", "vstmGNdr", _ = { shift = 21, mask = 1, [0] = "vstrGdl", { shift = 16, mask = 15, [13] = "vpushGdr", _ = "vstmdbGNdr", } }, }, { shift = 23, mask = 3, [0] = "vmovGDNm", { shift = 16, mask = 15, [13] = "vpopGdr", _ = "vldmGNdr", }, _ = { shift = 21, mask = 1, [0] = "vldrGdl", "vldmdbGNdr", }, }, }, _ = { shift = 0, mask = 0 -- NYI ldc, mcrr, mrrc. }, } local map_vfps = { shift = 6, mask = 0x2c001, [0] = "vmlaF.dnm", "vmlsF.dnm", [0x04000] = "vnmlsF.dnm", [0x04001] = "vnmlaF.dnm", [0x08000] = "vmulF.dnm", [0x08001] = "vnmulF.dnm", [0x0c000] = "vaddF.dnm", [0x0c001] = "vsubF.dnm", [0x20000] = "vdivF.dnm", [0x24000] = "vfnmsF.dnm", [0x24001] = "vfnmaF.dnm", [0x28000] = "vfmaF.dnm", [0x28001] = "vfmsF.dnm", [0x2c000] = "vmovF.dY", [0x2c001] = { shift = 7, mask = 0x1e01, [0] = "vmovF.dm", "vabsF.dm", [0x0200] = "vnegF.dm", [0x0201] = "vsqrtF.dm", [0x0800] = "vcmpF.dm", [0x0801] = "vcmpeF.dm", [0x0a00] = "vcmpzF.d", [0x0a01] = "vcmpzeF.d", [0x0e01] = "vcvtG.dF.m", [0x1000] = "vcvt.f32.u32Fdm", [0x1001] = "vcvt.f32.s32Fdm", [0x1800] = "vcvtr.u32F.dm", [0x1801] = "vcvt.u32F.dm", [0x1a00] = "vcvtr.s32F.dm", [0x1a01] = "vcvt.s32F.dm", }, } local map_vfpd = { shift = 6, mask = 0x2c001, [0] = "vmlaG.dnm", "vmlsG.dnm", [0x04000] = "vnmlsG.dnm", [0x04001] = "vnmlaG.dnm", [0x08000] = "vmulG.dnm", [0x08001] = "vnmulG.dnm", [0x0c000] = "vaddG.dnm", [0x0c001] = "vsubG.dnm", [0x20000] = "vdivG.dnm", [0x24000] = "vfnmsG.dnm", [0x24001] = "vfnmaG.dnm", [0x28000] = "vfmaG.dnm", [0x28001] = "vfmsG.dnm", [0x2c000] = "vmovG.dY", [0x2c001] = { shift = 7, mask = 0x1e01, [0] = "vmovG.dm", "vabsG.dm", [0x0200] = "vnegG.dm", [0x0201] = "vsqrtG.dm", [0x0800] = "vcmpG.dm", [0x0801] = "vcmpeG.dm", [0x0a00] = "vcmpzG.d", [0x0a01] = "vcmpzeG.d", [0x0e01] = "vcvtF.dG.m", [0x1000] = "vcvt.f64.u32GdFm", [0x1001] = "vcvt.f64.s32GdFm", [0x1800] = "vcvtr.u32FdG.m", [0x1801] = "vcvt.u32FdG.m", [0x1a00] = "vcvtr.s32FdG.m", [0x1a01] = "vcvt.s32FdG.m", }, } local map_datac = { shift = 24, mask = 1, [0] = { shift = 4, mask = 1, [0] = { shift = 8, mask = 15, [10] = map_vfps, [11] = map_vfpd, -- NYI cdp, mcr, mrc. }, { shift = 8, mask = 15, [10] = { shift = 20, mask = 15, [0] = "vmovFnD", "vmovFDn", [14] = "vmsrD", [15] = { shift = 12, mask = 15, [15] = "vmrs", _ = "vmrsD", }, }, }, }, "svcT", } local map_loadcu = { shift = 0, mask = 0, -- NYI unconditional CP load/store. } local map_datacu = { shift = 0, mask = 0, -- NYI unconditional CP data. } local map_simddata = { shift = 0, mask = 0, -- NYI SIMD data. } local map_simdload = { shift = 0, mask = 0, -- NYI SIMD load/store, preload. } local map_preload = { shift = 0, mask = 0, -- NYI preload. } local map_media = { shift = 20, mask = 31, [0] = false, { --01 shift = 5, mask = 7, [0] = "sadd16DNM", "sasxDNM", "ssaxDNM", "ssub16DNM", "sadd8DNM", false, false, "ssub8DNM", }, { --02 shift = 5, mask = 7, [0] = "qadd16DNM", "qasxDNM", "qsaxDNM", "qsub16DNM", "qadd8DNM", false, false, "qsub8DNM", }, { --03 shift = 5, mask = 7, [0] = "shadd16DNM", "shasxDNM", "shsaxDNM", "shsub16DNM", "shadd8DNM", false, false, "shsub8DNM", }, false, { --05 shift = 5, mask = 7, [0] = "uadd16DNM", "uasxDNM", "usaxDNM", "usub16DNM", "uadd8DNM", false, false, "usub8DNM", }, { --06 shift = 5, mask = 7, [0] = "uqadd16DNM", "uqasxDNM", "uqsaxDNM", "uqsub16DNM", "uqadd8DNM", false, false, "uqsub8DNM", }, { --07 shift = 5, mask = 7, [0] = "uhadd16DNM", "uhasxDNM", "uhsaxDNM", "uhsub16DNM", "uhadd8DNM", false, false, "uhsub8DNM", }, { --08 shift = 5, mask = 7, [0] = "pkhbtDNMU", false, "pkhtbDNMU", { shift = 16, mask = 15, [15] = "sxtb16DMU", _ = "sxtab16DNMU", }, "pkhbtDNMU", "selDNM", "pkhtbDNMU", }, false, { --0a shift = 5, mask = 7, [0] = "ssatDxMu", "ssat16DxM", "ssatDxMu", { shift = 16, mask = 15, [15] = "sxtbDMU", _ = "sxtabDNMU", }, "ssatDxMu", false, "ssatDxMu", }, { --0b shift = 5, mask = 7, [0] = "ssatDxMu", "revDM", "ssatDxMu", { shift = 16, mask = 15, [15] = "sxthDMU", _ = "sxtahDNMU", }, "ssatDxMu", "rev16DM", "ssatDxMu", }, { --0c shift = 5, mask = 7, [3] = { shift = 16, mask = 15, [15] = "uxtb16DMU", _ = "uxtab16DNMU", }, }, false, { --0e shift = 5, mask = 7, [0] = "usatDwMu", "usat16DwM", "usatDwMu", { shift = 16, mask = 15, [15] = "uxtbDMU", _ = "uxtabDNMU", }, "usatDwMu", false, "usatDwMu", }, { --0f shift = 5, mask = 7, [0] = "usatDwMu", "rbitDM", "usatDwMu", { shift = 16, mask = 15, [15] = "uxthDMU", _ = "uxtahDNMU", }, "usatDwMu", "revshDM", "usatDwMu", }, { --10 shift = 12, mask = 15, [15] = { shift = 5, mask = 7, "smuadNMS", "smuadxNMS", "smusdNMS", "smusdxNMS", }, _ = { shift = 5, mask = 7, [0] = "smladNMSD", "smladxNMSD", "smlsdNMSD", "smlsdxNMSD", }, }, false, false, false, { --14 shift = 5, mask = 7, [0] = "smlaldDNMS", "smlaldxDNMS", "smlsldDNMS", "smlsldxDNMS", }, { --15 shift = 5, mask = 7, [0] = { shift = 12, mask = 15, [15] = "smmulNMS", _ = "smmlaNMSD", }, { shift = 12, mask = 15, [15] = "smmulrNMS", _ = "smmlarNMSD", }, false, false, false, false, "smmlsNMSD", "smmlsrNMSD", }, false, false, { --18 shift = 5, mask = 7, [0] = { shift = 12, mask = 15, [15] = "usad8NMS", _ = "usada8NMSD", }, }, false, { --1a shift = 5, mask = 3, [2] = "sbfxDMvw", }, { --1b shift = 5, mask = 3, [2] = "sbfxDMvw", }, { --1c shift = 5, mask = 3, [0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", }, }, { --1d shift = 5, mask = 3, [0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", }, }, { --1e shift = 5, mask = 3, [2] = "ubfxDMvw", }, { --1f shift = 5, mask = 3, [2] = "ubfxDMvw", }, } local map_load = { shift = 21, mask = 9, { shift = 20, mask = 5, [0] = "strtDL", "ldrtDL", [4] = "strbtDL", [5] = "ldrbtDL", }, _ = { shift = 20, mask = 5, [0] = "strDL", "ldrDL", [4] = "strbDL", [5] = "ldrbDL", } } local map_load1 = { shift = 4, mask = 1, [0] = map_load, map_media, } local map_loadm = { shift = 20, mask = 1, [0] = { shift = 23, mask = 3, [0] = "stmdaNR", "stmNR", { shift = 16, mask = 63, [45] = "pushR", _ = "stmdbNR", }, "stmibNR", }, { shift = 23, mask = 3, [0] = "ldmdaNR", { shift = 16, mask = 63, [61] = "popR", _ = "ldmNR", }, "ldmdbNR", "ldmibNR", }, } local map_data = { shift = 21, mask = 15, [0] = "andDNPs", "eorDNPs", "subDNPs", "rsbDNPs", "addDNPs", "adcDNPs", "sbcDNPs", "rscDNPs", "tstNP", "teqNP", "cmpNP", "cmnNP", "orrDNPs", "movDPs", "bicDNPs", "mvnDPs", } local map_mul = { shift = 21, mask = 7, [0] = "mulNMSs", "mlaNMSDs", "umaalDNMS", "mlsDNMS", "umullDNMSs", "umlalDNMSs", "smullDNMSs", "smlalDNMSs", } local map_sync = { shift = 20, mask = 15, -- NYI: brackets around N. R(D+1) for ldrexd/strexd. [0] = "swpDMN", false, false, false, "swpbDMN", false, false, false, "strexDMN", "ldrexDN", "strexdDN", "ldrexdDN", "strexbDMN", "ldrexbDN", "strexhDN", "ldrexhDN", } local map_mulh = { shift = 21, mask = 3, [0] = { shift = 5, mask = 3, [0] = "smlabbNMSD", "smlatbNMSD", "smlabtNMSD", "smlattNMSD", }, { shift = 5, mask = 3, [0] = "smlawbNMSD", "smulwbNMS", "smlawtNMSD", "smulwtNMS", }, { shift = 5, mask = 3, [0] = "smlalbbDNMS", "smlaltbDNMS", "smlalbtDNMS", "smlalttDNMS", }, { shift = 5, mask = 3, [0] = "smulbbNMS", "smultbNMS", "smulbtNMS", "smulttNMS", }, } local map_misc = { shift = 4, mask = 7, -- NYI: decode PSR bits of msr. [0] = { shift = 21, mask = 1, [0] = "mrsD", "msrM", }, { shift = 21, mask = 3, "bxM", false, "clzDM", }, { shift = 21, mask = 3, "bxjM", }, { shift = 21, mask = 3, "blxM", }, false, { shift = 21, mask = 3, [0] = "qaddDMN", "qsubDMN", "qdaddDMN", "qdsubDMN", }, false, { shift = 21, mask = 3, "bkptK", }, } local map_datar = { shift = 4, mask = 9, [9] = { shift = 5, mask = 3, [0] = { shift = 24, mask = 1, [0] = map_mul, map_sync, }, { shift = 20, mask = 1, [0] = "strhDL", "ldrhDL", }, { shift = 20, mask = 1, [0] = "ldrdDL", "ldrsbDL", }, { shift = 20, mask = 1, [0] = "strdDL", "ldrshDL", }, }, _ = { shift = 20, mask = 25, [16] = { shift = 7, mask = 1, [0] = map_misc, map_mulh, }, _ = { shift = 0, mask = 0xffffffff, [bor(0xe1a00000)] = "nop", _ = map_data, } }, } local map_datai = { shift = 20, mask = 31, -- NYI: decode PSR bits of msr. Decode imm12. [16] = "movwDW", [20] = "movtDW", [18] = { shift = 0, mask = 0xf00ff, [0] = "nopv6", _ = "msrNW", }, [22] = "msrNW", _ = map_data, } local map_branch = { shift = 24, mask = 1, [0] = "bB", "blB" } local map_condins = { [0] = map_datar, map_datai, map_load, map_load1, map_loadm, map_branch, map_loadc, map_datac } -- NYI: setend. local map_uncondins = { [0] = false, map_simddata, map_simdload, map_preload, false, "blxB", map_loadcu, map_datacu, } ------------------------------------------------------------------------------ local map_gpr = { [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc", } local map_cond = { [0] = "eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc", "hi", "ls", "ge", "lt", "gt", "le", "al", } local map_shift = { [0] = "lsl", "lsr", "asr", "ror", } ------------------------------------------------------------------------------ -- Output a nicely formatted line with an opcode and operands. local function putop(ctx, text, operands) local pos = ctx.pos local extra = "" if ctx.rel then local sym = ctx.symtab[ctx.rel] if sym then extra = "\t->"..sym elseif band(ctx.op, 0x0e000000) ~= 0x0a000000 then extra = "\t; 0x"..tohex(ctx.rel) end end if ctx.hexdump > 0 then ctx.out(format("%08x %s %-5s %s%s\n", ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) else ctx.out(format("%08x %-5s %s%s\n", ctx.addr+pos, text, concat(operands, ", "), extra)) end ctx.pos = pos + 4 end -- Fallback for unknown opcodes. local function unknown(ctx) return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) end -- Format operand 2 of load/store opcodes. local function fmtload(ctx, op, pos) local base = map_gpr[band(rshift(op, 16), 15)] local x, ofs local ext = (band(op, 0x04000000) == 0) if not ext and band(op, 0x02000000) == 0 then ofs = band(op, 4095) if band(op, 0x00800000) == 0 then ofs = -ofs end if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end ofs = "#"..ofs elseif ext and band(op, 0x00400000) ~= 0 then ofs = band(op, 15) + band(rshift(op, 4), 0xf0) if band(op, 0x00800000) == 0 then ofs = -ofs end if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end ofs = "#"..ofs else ofs = map_gpr[band(op, 15)] if ext or band(op, 0xfe0) == 0 then elseif band(op, 0xfe0) == 0x60 then ofs = format("%s, rrx", ofs) else local sh = band(rshift(op, 7), 31) if sh == 0 then sh = 32 end ofs = format("%s, %s #%d", ofs, map_shift[band(rshift(op, 5), 3)], sh) end if band(op, 0x00800000) == 0 then ofs = "-"..ofs end end if ofs == "#0" then x = format("[%s]", base) elseif band(op, 0x01000000) == 0 then x = format("[%s], %s", base, ofs) else x = format("[%s, %s]", base, ofs) end if band(op, 0x01200000) == 0x01200000 then x = x.."!" end return x end -- Format operand 2 of vector load/store opcodes. local function fmtvload(ctx, op, pos) local base = map_gpr[band(rshift(op, 16), 15)] local ofs = band(op, 255)*4 if band(op, 0x00800000) == 0 then ofs = -ofs end if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end if ofs == 0 then return format("[%s]", base) else return format("[%s, #%d]", base, ofs) end end local function fmtvr(op, vr, sh0, sh1) if vr == "s" then return format("s%d", 2*band(rshift(op, sh0), 15)+band(rshift(op, sh1), 1)) else return format("d%d", band(rshift(op, sh0), 15)+band(rshift(op, sh1-4), 16)) end end -- Disassemble a single instruction. local function disass_ins(ctx) local pos = ctx.pos local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) local op = bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) local operands = {} local suffix = "" local last, name, pat local vr ctx.op = op ctx.rel = nil local cond = rshift(op, 28) local opat if cond == 15 then opat = map_uncondins[band(rshift(op, 25), 7)] else if cond ~= 14 then suffix = map_cond[cond] end opat = map_condins[band(rshift(op, 25), 7)] end while type(opat) ~= "string" do if not opat then return unknown(ctx) end opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ end name, pat = match(opat, "^([a-z0-9]*)(.*)") if sub(pat, 1, 1) == "." then local s2, p2 = match(pat, "^([a-z0-9.]*)(.*)") suffix = suffix..s2 pat = p2 end for p in gmatch(pat, ".") do local x = nil if p == "D" then x = map_gpr[band(rshift(op, 12), 15)] elseif p == "N" then x = map_gpr[band(rshift(op, 16), 15)] elseif p == "S" then x = map_gpr[band(rshift(op, 8), 15)] elseif p == "M" then x = map_gpr[band(op, 15)] elseif p == "d" then x = fmtvr(op, vr, 12, 22) elseif p == "n" then x = fmtvr(op, vr, 16, 7) elseif p == "m" then x = fmtvr(op, vr, 0, 5) elseif p == "P" then if band(op, 0x02000000) ~= 0 then x = ror(band(op, 255), 2*band(rshift(op, 8), 15)) else x = map_gpr[band(op, 15)] if band(op, 0xff0) ~= 0 then operands[#operands+1] = x local s = map_shift[band(rshift(op, 5), 3)] local r = nil if band(op, 0xf90) == 0 then if s == "ror" then s = "rrx" else r = "#32" end elseif band(op, 0x10) == 0 then r = "#"..band(rshift(op, 7), 31) else r = map_gpr[band(rshift(op, 8), 15)] end if name == "mov" then name = s; x = r elseif r then x = format("%s %s", s, r) else x = s end end end elseif p == "L" then x = fmtload(ctx, op, pos) elseif p == "l" then x = fmtvload(ctx, op, pos) elseif p == "B" then local addr = ctx.addr + pos + 8 + arshift(lshift(op, 8), 6) if cond == 15 then addr = addr + band(rshift(op, 23), 2) end ctx.rel = addr x = "0x"..tohex(addr) elseif p == "F" then vr = "s" elseif p == "G" then vr = "d" elseif p == "." then suffix = suffix..(vr == "s" and ".f32" or ".f64") elseif p == "R" then if band(op, 0x00200000) ~= 0 and #operands == 1 then operands[1] = operands[1].."!" end local t = {} for i=0,15 do if band(rshift(op, i), 1) == 1 then t[#t+1] = map_gpr[i] end end x = "{"..concat(t, ", ").."}" elseif p == "r" then if band(op, 0x00200000) ~= 0 and #operands == 2 then operands[1] = operands[1].."!" end local s = tonumber(sub(last, 2)) local n = band(op, 255) if vr == "d" then n = rshift(n, 1) end operands[#operands] = format("{%s-%s%d}", last, vr, s+n-1) elseif p == "W" then x = band(op, 0x0fff) + band(rshift(op, 4), 0xf000) elseif p == "T" then x = "#0x"..tohex(band(op, 0x00ffffff), 6) elseif p == "U" then x = band(rshift(op, 7), 31) if x == 0 then x = nil end elseif p == "u" then x = band(rshift(op, 7), 31) if band(op, 0x40) == 0 then if x == 0 then x = nil else x = "lsl #"..x end else if x == 0 then x = "asr #32" else x = "asr #"..x end end elseif p == "v" then x = band(rshift(op, 7), 31) elseif p == "w" then x = band(rshift(op, 16), 31) elseif p == "x" then x = band(rshift(op, 16), 31) + 1 elseif p == "X" then x = band(rshift(op, 16), 31) - last + 1 elseif p == "Y" then x = band(rshift(op, 12), 0xf0) + band(op, 0x0f) elseif p == "K" then x = "#0x"..tohex(band(rshift(op, 4), 0x0000fff0) + band(op, 15), 4) elseif p == "s" then if band(op, 0x00100000) ~= 0 then suffix = "s"..suffix end else assert(false) end if x then last = x if type(x) == "number" then x = "#"..x end operands[#operands+1] = x end end return putop(ctx, name..suffix, operands) end ------------------------------------------------------------------------------ -- Disassemble a block of code. local function disass_block(ctx, ofs, len) if not ofs then ofs = 0 end local stop = len and ofs+len or #ctx.code ctx.pos = ofs ctx.rel = nil while ctx.pos < stop do disass_ins(ctx) end end -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). local function create_(code, addr, out) local ctx = {} ctx.code = code ctx.addr = addr or 0 ctx.out = out or io.write ctx.symtab = {} ctx.disass = disass_block ctx.hexdump = 8 return ctx end -- Simple API: disassemble code (a string) at address and output via out. local function disass_(code, addr, out) create_(code, addr, out):disass() end -- Return register name for RID. local function regname_(r) if r < 16 then return map_gpr[r] end return "d"..(r-16) end -- Public module functions. module(...) create = create_ disass = disass_ regname = regname_ ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/dis_mips.lua ================================================ ---------------------------------------------------------------------------- -- LuaJIT MIPS disassembler module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT/X license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- This is a helper module used by the LuaJIT machine code dumper module. -- -- It disassembles all standard MIPS32R1/R2 instructions. -- Default mode is big-endian, but see: dis_mipsel.lua ------------------------------------------------------------------------------ local type = type local sub, byte, format = string.sub, string.byte, string.format local match, gmatch, gsub = string.match, string.gmatch, string.gsub local concat = table.concat local bit = require("bit") local band, bor, tohex = bit.band, bit.bor, bit.tohex local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift ------------------------------------------------------------------------------ -- Primary and extended opcode maps ------------------------------------------------------------------------------ local map_movci = { shift = 16, mask = 1, [0] = "movfDSC", "movtDSC", } local map_srl = { shift = 21, mask = 1, [0] = "srlDTA", "rotrDTA", } local map_srlv = { shift = 6, mask = 1, [0] = "srlvDTS", "rotrvDTS", } local map_special = { shift = 0, mask = 63, [0] = { shift = 0, mask = -1, [0] = "nop", _ = "sllDTA" }, map_movci, map_srl, "sraDTA", "sllvDTS", false, map_srlv, "sravDTS", "jrS", "jalrD1S", "movzDST", "movnDST", "syscallY", "breakY", false, "sync", "mfhiD", "mthiS", "mfloD", "mtloS", false, false, false, false, "multST", "multuST", "divST", "divuST", false, false, false, false, "addDST", "addu|moveDST0", "subDST", "subu|neguDS0T", "andDST", "orDST", "xorDST", "nor|notDST0", false, false, "sltDST", "sltuDST", false, false, false, false, "tgeSTZ", "tgeuSTZ", "tltSTZ", "tltuSTZ", "teqSTZ", false, "tneSTZ", } local map_special2 = { shift = 0, mask = 63, [0] = "maddST", "madduST", "mulDST", false, "msubST", "msubuST", [32] = "clzDS", [33] = "cloDS", [63] = "sdbbpY", } local map_bshfl = { shift = 6, mask = 31, [2] = "wsbhDT", [16] = "sebDT", [24] = "sehDT", } local map_special3 = { shift = 0, mask = 63, [0] = "extTSAK", [4] = "insTSAL", [32] = map_bshfl, [59] = "rdhwrTD", } local map_regimm = { shift = 16, mask = 31, [0] = "bltzSB", "bgezSB", "bltzlSB", "bgezlSB", false, false, false, false, "tgeiSI", "tgeiuSI", "tltiSI", "tltiuSI", "teqiSI", false, "tneiSI", false, "bltzalSB", "bgezalSB", "bltzallSB", "bgezallSB", false, false, false, false, false, false, false, false, false, false, false, "synciSO", } local map_cop0 = { shift = 25, mask = 1, [0] = { shift = 21, mask = 15, [0] = "mfc0TDW", [4] = "mtc0TDW", [10] = "rdpgprDT", [11] = { shift = 5, mask = 1, [0] = "diT0", "eiT0", }, [14] = "wrpgprDT", }, { shift = 0, mask = 63, [1] = "tlbr", [2] = "tlbwi", [6] = "tlbwr", [8] = "tlbp", [24] = "eret", [31] = "deret", [32] = "wait", }, } local map_cop1s = { shift = 0, mask = 63, [0] = "add.sFGH", "sub.sFGH", "mul.sFGH", "div.sFGH", "sqrt.sFG", "abs.sFG", "mov.sFG", "neg.sFG", "round.l.sFG", "trunc.l.sFG", "ceil.l.sFG", "floor.l.sFG", "round.w.sFG", "trunc.w.sFG", "ceil.w.sFG", "floor.w.sFG", false, { shift = 16, mask = 1, [0] = "movf.sFGC", "movt.sFGC" }, "movz.sFGT", "movn.sFGT", false, "recip.sFG", "rsqrt.sFG", false, false, false, false, false, false, false, false, false, false, "cvt.d.sFG", false, false, "cvt.w.sFG", "cvt.l.sFG", "cvt.ps.sFGH", false, false, false, false, false, false, false, false, false, "c.f.sVGH", "c.un.sVGH", "c.eq.sVGH", "c.ueq.sVGH", "c.olt.sVGH", "c.ult.sVGH", "c.ole.sVGH", "c.ule.sVGH", "c.sf.sVGH", "c.ngle.sVGH", "c.seq.sVGH", "c.ngl.sVGH", "c.lt.sVGH", "c.nge.sVGH", "c.le.sVGH", "c.ngt.sVGH", } local map_cop1d = { shift = 0, mask = 63, [0] = "add.dFGH", "sub.dFGH", "mul.dFGH", "div.dFGH", "sqrt.dFG", "abs.dFG", "mov.dFG", "neg.dFG", "round.l.dFG", "trunc.l.dFG", "ceil.l.dFG", "floor.l.dFG", "round.w.dFG", "trunc.w.dFG", "ceil.w.dFG", "floor.w.dFG", false, { shift = 16, mask = 1, [0] = "movf.dFGC", "movt.dFGC" }, "movz.dFGT", "movn.dFGT", false, "recip.dFG", "rsqrt.dFG", false, false, false, false, false, false, false, false, false, "cvt.s.dFG", false, false, false, "cvt.w.dFG", "cvt.l.dFG", false, false, false, false, false, false, false, false, false, false, "c.f.dVGH", "c.un.dVGH", "c.eq.dVGH", "c.ueq.dVGH", "c.olt.dVGH", "c.ult.dVGH", "c.ole.dVGH", "c.ule.dVGH", "c.df.dVGH", "c.ngle.dVGH", "c.deq.dVGH", "c.ngl.dVGH", "c.lt.dVGH", "c.nge.dVGH", "c.le.dVGH", "c.ngt.dVGH", } local map_cop1ps = { shift = 0, mask = 63, [0] = "add.psFGH", "sub.psFGH", "mul.psFGH", false, false, "abs.psFG", "mov.psFG", "neg.psFG", false, false, false, false, false, false, false, false, false, { shift = 16, mask = 1, [0] = "movf.psFGC", "movt.psFGC" }, "movz.psFGT", "movn.psFGT", false, false, false, false, false, false, false, false, false, false, false, false, "cvt.s.puFG", false, false, false, false, false, false, false, "cvt.s.plFG", false, false, false, "pll.psFGH", "plu.psFGH", "pul.psFGH", "puu.psFGH", "c.f.psVGH", "c.un.psVGH", "c.eq.psVGH", "c.ueq.psVGH", "c.olt.psVGH", "c.ult.psVGH", "c.ole.psVGH", "c.ule.psVGH", "c.psf.psVGH", "c.ngle.psVGH", "c.pseq.psVGH", "c.ngl.psVGH", "c.lt.psVGH", "c.nge.psVGH", "c.le.psVGH", "c.ngt.psVGH", } local map_cop1w = { shift = 0, mask = 63, [32] = "cvt.s.wFG", [33] = "cvt.d.wFG", } local map_cop1l = { shift = 0, mask = 63, [32] = "cvt.s.lFG", [33] = "cvt.d.lFG", } local map_cop1bc = { shift = 16, mask = 3, [0] = "bc1fCB", "bc1tCB", "bc1flCB", "bc1tlCB", } local map_cop1 = { shift = 21, mask = 31, [0] = "mfc1TG", false, "cfc1TG", "mfhc1TG", "mtc1TG", false, "ctc1TG", "mthc1TG", map_cop1bc, false, false, false, false, false, false, false, map_cop1s, map_cop1d, false, false, map_cop1w, map_cop1l, map_cop1ps, } local map_cop1x = { shift = 0, mask = 63, [0] = "lwxc1FSX", "ldxc1FSX", false, false, false, "luxc1FSX", false, false, "swxc1FSX", "sdxc1FSX", false, false, false, "suxc1FSX", false, "prefxMSX", false, false, false, false, false, false, false, false, false, false, false, false, false, false, "alnv.psFGHS", false, "madd.sFRGH", "madd.dFRGH", false, false, false, false, "madd.psFRGH", false, "msub.sFRGH", "msub.dFRGH", false, false, false, false, "msub.psFRGH", false, "nmadd.sFRGH", "nmadd.dFRGH", false, false, false, false, "nmadd.psFRGH", false, "nmsub.sFRGH", "nmsub.dFRGH", false, false, false, false, "nmsub.psFRGH", false, } local map_pri = { [0] = map_special, map_regimm, "jJ", "jalJ", "beq|beqz|bST00B", "bne|bnezST0B", "blezSB", "bgtzSB", "addiTSI", "addiu|liTS0I", "sltiTSI", "sltiuTSI", "andiTSU", "ori|liTS0U", "xoriTSU", "luiTU", map_cop0, map_cop1, false, map_cop1x, "beql|beqzlST0B", "bnel|bnezlST0B", "blezlSB", "bgtzlSB", false, false, false, false, map_special2, false, false, map_special3, "lbTSO", "lhTSO", "lwlTSO", "lwTSO", "lbuTSO", "lhuTSO", "lwrTSO", false, "sbTSO", "shTSO", "swlTSO", "swTSO", false, false, "swrTSO", "cacheNSO", "llTSO", "lwc1HSO", "lwc2TSO", "prefNSO", false, "ldc1HSO", "ldc2TSO", false, "scTSO", "swc1HSO", "swc2TSO", false, false, "sdc1HSO", "sdc2TSO", false, } ------------------------------------------------------------------------------ local map_gpr = { [0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "sp", "r30", "ra", } ------------------------------------------------------------------------------ -- Output a nicely formatted line with an opcode and operands. local function putop(ctx, text, operands) local pos = ctx.pos local extra = "" if ctx.rel then local sym = ctx.symtab[ctx.rel] if sym then extra = "\t->"..sym end end if ctx.hexdump > 0 then ctx.out(format("%08x %s %-7s %s%s\n", ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) else ctx.out(format("%08x %-7s %s%s\n", ctx.addr+pos, text, concat(operands, ", "), extra)) end ctx.pos = pos + 4 end -- Fallback for unknown opcodes. local function unknown(ctx) return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) end local function get_be(ctx) local pos = ctx.pos local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) return bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) end local function get_le(ctx) local pos = ctx.pos local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) return bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0) end -- Disassemble a single instruction. local function disass_ins(ctx) local op = ctx:get() local operands = {} local last = nil ctx.op = op ctx.rel = nil local opat = map_pri[rshift(op, 26)] while type(opat) ~= "string" do if not opat then return unknown(ctx) end opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._ end local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") local altname, pat2 = match(pat, "|([a-z0-9_.|]*)(.*)") if altname then pat = pat2 end for p in gmatch(pat, ".") do local x = nil if p == "S" then x = map_gpr[band(rshift(op, 21), 31)] elseif p == "T" then x = map_gpr[band(rshift(op, 16), 31)] elseif p == "D" then x = map_gpr[band(rshift(op, 11), 31)] elseif p == "F" then x = "f"..band(rshift(op, 6), 31) elseif p == "G" then x = "f"..band(rshift(op, 11), 31) elseif p == "H" then x = "f"..band(rshift(op, 16), 31) elseif p == "R" then x = "f"..band(rshift(op, 21), 31) elseif p == "A" then x = band(rshift(op, 6), 31) elseif p == "M" then x = band(rshift(op, 11), 31) elseif p == "N" then x = band(rshift(op, 16), 31) elseif p == "C" then x = band(rshift(op, 18), 7) if x == 0 then x = nil end elseif p == "K" then x = band(rshift(op, 11), 31) + 1 elseif p == "L" then x = band(rshift(op, 11), 31) - last + 1 elseif p == "I" then x = arshift(lshift(op, 16), 16) elseif p == "U" then x = band(op, 0xffff) elseif p == "O" then local disp = arshift(lshift(op, 16), 16) operands[#operands] = format("%d(%s)", disp, last) elseif p == "X" then local index = map_gpr[band(rshift(op, 16), 31)] operands[#operands] = format("%s(%s)", index, last) elseif p == "B" then x = ctx.addr + ctx.pos + arshift(lshift(op, 16), 16)*4 + 4 ctx.rel = x x = "0x"..tohex(x) elseif p == "J" then x = band(ctx.addr + ctx.pos, 0xf0000000) + band(op, 0x03ffffff)*4 ctx.rel = x x = "0x"..tohex(x) elseif p == "V" then x = band(rshift(op, 8), 7) if x == 0 then x = nil end elseif p == "W" then x = band(op, 7) if x == 0 then x = nil end elseif p == "Y" then x = band(rshift(op, 6), 0x000fffff) if x == 0 then x = nil end elseif p == "Z" then x = band(rshift(op, 6), 1023) if x == 0 then x = nil end elseif p == "0" then if last == "r0" or last == 0 then local n = #operands operands[n] = nil last = operands[n-1] if altname then local a1, a2 = match(altname, "([^|]*)|(.*)") if a1 then name, altname = a1, a2 else name = altname end end end elseif p == "1" then if last == "ra" then operands[#operands] = nil end else assert(false) end if x then operands[#operands+1] = x; last = x end end return putop(ctx, name, operands) end ------------------------------------------------------------------------------ -- Disassemble a block of code. local function disass_block(ctx, ofs, len) if not ofs then ofs = 0 end local stop = len and ofs+len or #ctx.code stop = stop - stop % 4 ctx.pos = ofs - ofs % 4 ctx.rel = nil while ctx.pos < stop do disass_ins(ctx) end end -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). local function create_(code, addr, out) local ctx = {} ctx.code = code ctx.addr = addr or 0 ctx.out = out or io.write ctx.symtab = {} ctx.disass = disass_block ctx.hexdump = 8 ctx.get = get_be return ctx end local function create_el_(code, addr, out) local ctx = create_(code, addr, out) ctx.get = get_le return ctx end -- Simple API: disassemble code (a string) at address and output via out. local function disass_(code, addr, out) create_(code, addr, out):disass() end local function disass_el_(code, addr, out) create_el_(code, addr, out):disass() end -- Return register name for RID. local function regname_(r) if r < 32 then return map_gpr[r] end return "f"..(r-32) end -- Public module functions. module(...) create = create_ create_el = create_el_ disass = disass_ disass_el = disass_el_ regname = regname_ ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/dis_mipsel.lua ================================================ ---------------------------------------------------------------------------- -- LuaJIT MIPSEL disassembler wrapper module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- This module just exports the little-endian functions from the -- MIPS disassembler module. All the interesting stuff is there. ------------------------------------------------------------------------------ local require = require module(...) local dis_mips = require(_PACKAGE.."dis_mips") create = dis_mips.create_el disass = dis_mips.disass_el regname = dis_mips.regname ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/dis_ppc.lua ================================================ ---------------------------------------------------------------------------- -- LuaJIT PPC disassembler module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT/X license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- This is a helper module used by the LuaJIT machine code dumper module. -- -- It disassembles all common, non-privileged 32/64 bit PowerPC instructions -- plus the e500 SPE instructions and some Cell/Xenon extensions. -- -- NYI: VMX, VMX128 ------------------------------------------------------------------------------ local type = type local sub, byte, format = string.sub, string.byte, string.format local match, gmatch, gsub = string.match, string.gmatch, string.gsub local concat = table.concat local bit = require("bit") local band, bor, tohex = bit.band, bit.bor, bit.tohex local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift ------------------------------------------------------------------------------ -- Primary and extended opcode maps ------------------------------------------------------------------------------ local map_crops = { shift = 1, mask = 1023, [0] = "mcrfXX", [33] = "crnor|crnotCCC=", [129] = "crandcCCC", [193] = "crxor|crclrCCC%", [225] = "crnandCCC", [257] = "crandCCC", [289] = "creqv|crsetCCC%", [417] = "crorcCCC", [449] = "cror|crmoveCCC=", [16] = "b_lrKB", [528] = "b_ctrKB", [150] = "isync", } local map_rlwinm = setmetatable({ shift = 0, mask = -1, }, { __index = function(t, x) local rot = band(rshift(x, 11), 31) local mb = band(rshift(x, 6), 31) local me = band(rshift(x, 1), 31) if mb == 0 and me == 31-rot then return "slwiRR~A." elseif me == 31 and mb == 32-rot then return "srwiRR~-A." else return "rlwinmRR~AAA." end end }) local map_rld = { shift = 2, mask = 7, [0] = "rldiclRR~HM.", "rldicrRR~HM.", "rldicRR~HM.", "rldimiRR~HM.", { shift = 1, mask = 1, [0] = "rldclRR~RM.", "rldcrRR~RM.", }, } local map_ext = setmetatable({ shift = 1, mask = 1023, [0] = "cmp_YLRR", [32] = "cmpl_YLRR", [4] = "twARR", [68] = "tdARR", [8] = "subfcRRR.", [40] = "subfRRR.", [104] = "negRR.", [136] = "subfeRRR.", [200] = "subfzeRR.", [232] = "subfmeRR.", [520] = "subfcoRRR.", [552] = "subfoRRR.", [616] = "negoRR.", [648] = "subfeoRRR.", [712] = "subfzeoRR.", [744] = "subfmeoRR.", [9] = "mulhduRRR.", [73] = "mulhdRRR.", [233] = "mulldRRR.", [457] = "divduRRR.", [489] = "divdRRR.", [745] = "mulldoRRR.", [969] = "divduoRRR.", [1001] = "divdoRRR.", [10] = "addcRRR.", [138] = "addeRRR.", [202] = "addzeRR.", [234] = "addmeRR.", [266] = "addRRR.", [522] = "addcoRRR.", [650] = "addeoRRR.", [714] = "addzeoRR.", [746] = "addmeoRR.", [778] = "addoRRR.", [11] = "mulhwuRRR.", [75] = "mulhwRRR.", [235] = "mullwRRR.", [459] = "divwuRRR.", [491] = "divwRRR.", [747] = "mullwoRRR.", [971] = "divwouRRR.", [1003] = "divwoRRR.", [15] = "iselltRRR", [47] = "iselgtRRR", [79] = "iseleqRRR", [144] = { shift = 20, mask = 1, [0] = "mtcrfRZ~", "mtocrfRZ~", }, [19] = { shift = 20, mask = 1, [0] = "mfcrR", "mfocrfRZ", }, [371] = { shift = 11, mask = 1023, [392] = "mftbR", [424] = "mftbuR", }, [339] = { shift = 11, mask = 1023, [32] = "mferR", [256] = "mflrR", [288] = "mfctrR", [16] = "mfspefscrR", }, [467] = { shift = 11, mask = 1023, [32] = "mtxerR", [256] = "mtlrR", [288] = "mtctrR", [16] = "mtspefscrR", }, [20] = "lwarxRR0R", [84] = "ldarxRR0R", [21] = "ldxRR0R", [53] = "lduxRRR", [149] = "stdxRR0R", [181] = "stduxRRR", [341] = "lwaxRR0R", [373] = "lwauxRRR", [23] = "lwzxRR0R", [55] = "lwzuxRRR", [87] = "lbzxRR0R", [119] = "lbzuxRRR", [151] = "stwxRR0R", [183] = "stwuxRRR", [215] = "stbxRR0R", [247] = "stbuxRRR", [279] = "lhzxRR0R", [311] = "lhzuxRRR", [343] = "lhaxRR0R", [375] = "lhauxRRR", [407] = "sthxRR0R", [439] = "sthuxRRR", [54] = "dcbst-R0R", [86] = "dcbf-R0R", [150] = "stwcxRR0R.", [214] = "stdcxRR0R.", [246] = "dcbtst-R0R", [278] = "dcbt-R0R", [310] = "eciwxRR0R", [438] = "ecowxRR0R", [470] = "dcbi-RR", [598] = { shift = 21, mask = 3, [0] = "sync", "lwsync", "ptesync", }, [758] = "dcba-RR", [854] = "eieio", [982] = "icbi-R0R", [1014] = "dcbz-R0R", [26] = "cntlzwRR~", [58] = "cntlzdRR~", [122] = "popcntbRR~", [154] = "prtywRR~", [186] = "prtydRR~", [28] = "andRR~R.", [60] = "andcRR~R.", [124] = "nor|notRR~R=.", [284] = "eqvRR~R.", [316] = "xorRR~R.", [412] = "orcRR~R.", [444] = "or|mrRR~R=.", [476] = "nandRR~R.", [508] = "cmpbRR~R", [512] = "mcrxrX", [532] = "ldbrxRR0R", [660] = "stdbrxRR0R", [533] = "lswxRR0R", [597] = "lswiRR0A", [661] = "stswxRR0R", [725] = "stswiRR0A", [534] = "lwbrxRR0R", [662] = "stwbrxRR0R", [790] = "lhbrxRR0R", [918] = "sthbrxRR0R", [535] = "lfsxFR0R", [567] = "lfsuxFRR", [599] = "lfdxFR0R", [631] = "lfduxFRR", [663] = "stfsxFR0R", [695] = "stfsuxFRR", [727] = "stfdxFR0R", [759] = "stfduxFR0R", [855] = "lfiwaxFR0R", [983] = "stfiwxFR0R", [24] = "slwRR~R.", [27] = "sldRR~R.", [536] = "srwRR~R.", [792] = "srawRR~R.", [824] = "srawiRR~A.", [794] = "sradRR~R.", [826] = "sradiRR~H.", [827] = "sradiRR~H.", [922] = "extshRR~.", [954] = "extsbRR~.", [986] = "extswRR~.", [539] = "srdRR~R.", }, { __index = function(t, x) if band(x, 31) == 15 then return "iselRRRC" end end }) local map_ld = { shift = 0, mask = 3, [0] = "ldRRE", "lduRRE", "lwaRRE", } local map_std = { shift = 0, mask = 3, [0] = "stdRRE", "stduRRE", } local map_fps = { shift = 5, mask = 1, { shift = 1, mask = 15, [0] = false, false, "fdivsFFF.", false, "fsubsFFF.", "faddsFFF.", "fsqrtsF-F.", false, "fresF-F.", "fmulsFF-F.", "frsqrtesF-F.", false, "fmsubsFFFF~.", "fmaddsFFFF~.", "fnmsubsFFFF~.", "fnmaddsFFFF~.", } } local map_fpd = { shift = 5, mask = 1, [0] = { shift = 1, mask = 1023, [0] = "fcmpuXFF", [32] = "fcmpoXFF", [64] = "mcrfsXX", [38] = "mtfsb1A.", [70] = "mtfsb0A.", [134] = "mtfsfiA>>-A>", [8] = "fcpsgnFFF.", [40] = "fnegF-F.", [72] = "fmrF-F.", [136] = "fnabsF-F.", [264] = "fabsF-F.", [12] = "frspF-F.", [14] = "fctiwF-F.", [15] = "fctiwzF-F.", [583] = "mffsF.", [711] = "mtfsfZF.", [392] = "frinF-F.", [424] = "frizF-F.", [456] = "fripF-F.", [488] = "frimF-F.", [814] = "fctidF-F.", [815] = "fctidzF-F.", [846] = "fcfidF-F.", }, { shift = 1, mask = 15, [0] = false, false, "fdivFFF.", false, "fsubFFF.", "faddFFF.", "fsqrtF-F.", "fselFFFF~.", "freF-F.", "fmulFF-F.", "frsqrteF-F.", false, "fmsubFFFF~.", "fmaddFFFF~.", "fnmsubFFFF~.", "fnmaddFFFF~.", } } local map_spe = { shift = 0, mask = 2047, [512] = "evaddwRRR", [514] = "evaddiwRAR~", [516] = "evsubwRRR~", [518] = "evsubiwRAR~", [520] = "evabsRR", [521] = "evnegRR", [522] = "evextsbRR", [523] = "evextshRR", [524] = "evrndwRR", [525] = "evcntlzwRR", [526] = "evcntlswRR", [527] = "brincRRR", [529] = "evandRRR", [530] = "evandcRRR", [534] = "evxorRRR", [535] = "evor|evmrRRR=", [536] = "evnor|evnotRRR=", [537] = "eveqvRRR", [539] = "evorcRRR", [542] = "evnandRRR", [544] = "evsrwuRRR", [545] = "evsrwsRRR", [546] = "evsrwiuRRA", [547] = "evsrwisRRA", [548] = "evslwRRR", [550] = "evslwiRRA", [552] = "evrlwRRR", [553] = "evsplatiRS", [554] = "evrlwiRRA", [555] = "evsplatfiRS", [556] = "evmergehiRRR", [557] = "evmergeloRRR", [558] = "evmergehiloRRR", [559] = "evmergelohiRRR", [560] = "evcmpgtuYRR", [561] = "evcmpgtsYRR", [562] = "evcmpltuYRR", [563] = "evcmpltsYRR", [564] = "evcmpeqYRR", [632] = "evselRRR", [633] = "evselRRRW", [634] = "evselRRRW", [635] = "evselRRRW", [636] = "evselRRRW", [637] = "evselRRRW", [638] = "evselRRRW", [639] = "evselRRRW", [640] = "evfsaddRRR", [641] = "evfssubRRR", [644] = "evfsabsRR", [645] = "evfsnabsRR", [646] = "evfsnegRR", [648] = "evfsmulRRR", [649] = "evfsdivRRR", [652] = "evfscmpgtYRR", [653] = "evfscmpltYRR", [654] = "evfscmpeqYRR", [656] = "evfscfuiR-R", [657] = "evfscfsiR-R", [658] = "evfscfufR-R", [659] = "evfscfsfR-R", [660] = "evfsctuiR-R", [661] = "evfsctsiR-R", [662] = "evfsctufR-R", [663] = "evfsctsfR-R", [664] = "evfsctuizR-R", [666] = "evfsctsizR-R", [668] = "evfststgtYRR", [669] = "evfststltYRR", [670] = "evfststeqYRR", [704] = "efsaddRRR", [705] = "efssubRRR", [708] = "efsabsRR", [709] = "efsnabsRR", [710] = "efsnegRR", [712] = "efsmulRRR", [713] = "efsdivRRR", [716] = "efscmpgtYRR", [717] = "efscmpltYRR", [718] = "efscmpeqYRR", [719] = "efscfdR-R", [720] = "efscfuiR-R", [721] = "efscfsiR-R", [722] = "efscfufR-R", [723] = "efscfsfR-R", [724] = "efsctuiR-R", [725] = "efsctsiR-R", [726] = "efsctufR-R", [727] = "efsctsfR-R", [728] = "efsctuizR-R", [730] = "efsctsizR-R", [732] = "efststgtYRR", [733] = "efststltYRR", [734] = "efststeqYRR", [736] = "efdaddRRR", [737] = "efdsubRRR", [738] = "efdcfuidR-R", [739] = "efdcfsidR-R", [740] = "efdabsRR", [741] = "efdnabsRR", [742] = "efdnegRR", [744] = "efdmulRRR", [745] = "efddivRRR", [746] = "efdctuidzR-R", [747] = "efdctsidzR-R", [748] = "efdcmpgtYRR", [749] = "efdcmpltYRR", [750] = "efdcmpeqYRR", [751] = "efdcfsR-R", [752] = "efdcfuiR-R", [753] = "efdcfsiR-R", [754] = "efdcfufR-R", [755] = "efdcfsfR-R", [756] = "efdctuiR-R", [757] = "efdctsiR-R", [758] = "efdctufR-R", [759] = "efdctsfR-R", [760] = "efdctuizR-R", [762] = "efdctsizR-R", [764] = "efdtstgtYRR", [765] = "efdtstltYRR", [766] = "efdtsteqYRR", [768] = "evlddxRR0R", [769] = "evlddRR8", [770] = "evldwxRR0R", [771] = "evldwRR8", [772] = "evldhxRR0R", [773] = "evldhRR8", [776] = "evlhhesplatxRR0R", [777] = "evlhhesplatRR2", [780] = "evlhhousplatxRR0R", [781] = "evlhhousplatRR2", [782] = "evlhhossplatxRR0R", [783] = "evlhhossplatRR2", [784] = "evlwhexRR0R", [785] = "evlwheRR4", [788] = "evlwhouxRR0R", [789] = "evlwhouRR4", [790] = "evlwhosxRR0R", [791] = "evlwhosRR4", [792] = "evlwwsplatxRR0R", [793] = "evlwwsplatRR4", [796] = "evlwhsplatxRR0R", [797] = "evlwhsplatRR4", [800] = "evstddxRR0R", [801] = "evstddRR8", [802] = "evstdwxRR0R", [803] = "evstdwRR8", [804] = "evstdhxRR0R", [805] = "evstdhRR8", [816] = "evstwhexRR0R", [817] = "evstwheRR4", [820] = "evstwhoxRR0R", [821] = "evstwhoRR4", [824] = "evstwwexRR0R", [825] = "evstwweRR4", [828] = "evstwwoxRR0R", [829] = "evstwwoRR4", [1027] = "evmhessfRRR", [1031] = "evmhossfRRR", [1032] = "evmheumiRRR", [1033] = "evmhesmiRRR", [1035] = "evmhesmfRRR", [1036] = "evmhoumiRRR", [1037] = "evmhosmiRRR", [1039] = "evmhosmfRRR", [1059] = "evmhessfaRRR", [1063] = "evmhossfaRRR", [1064] = "evmheumiaRRR", [1065] = "evmhesmiaRRR", [1067] = "evmhesmfaRRR", [1068] = "evmhoumiaRRR", [1069] = "evmhosmiaRRR", [1071] = "evmhosmfaRRR", [1095] = "evmwhssfRRR", [1096] = "evmwlumiRRR", [1100] = "evmwhumiRRR", [1101] = "evmwhsmiRRR", [1103] = "evmwhsmfRRR", [1107] = "evmwssfRRR", [1112] = "evmwumiRRR", [1113] = "evmwsmiRRR", [1115] = "evmwsmfRRR", [1127] = "evmwhssfaRRR", [1128] = "evmwlumiaRRR", [1132] = "evmwhumiaRRR", [1133] = "evmwhsmiaRRR", [1135] = "evmwhsmfaRRR", [1139] = "evmwssfaRRR", [1144] = "evmwumiaRRR", [1145] = "evmwsmiaRRR", [1147] = "evmwsmfaRRR", [1216] = "evaddusiaawRR", [1217] = "evaddssiaawRR", [1218] = "evsubfusiaawRR", [1219] = "evsubfssiaawRR", [1220] = "evmraRR", [1222] = "evdivwsRRR", [1223] = "evdivwuRRR", [1224] = "evaddumiaawRR", [1225] = "evaddsmiaawRR", [1226] = "evsubfumiaawRR", [1227] = "evsubfsmiaawRR", [1280] = "evmheusiaawRRR", [1281] = "evmhessiaawRRR", [1283] = "evmhessfaawRRR", [1284] = "evmhousiaawRRR", [1285] = "evmhossiaawRRR", [1287] = "evmhossfaawRRR", [1288] = "evmheumiaawRRR", [1289] = "evmhesmiaawRRR", [1291] = "evmhesmfaawRRR", [1292] = "evmhoumiaawRRR", [1293] = "evmhosmiaawRRR", [1295] = "evmhosmfaawRRR", [1320] = "evmhegumiaaRRR", [1321] = "evmhegsmiaaRRR", [1323] = "evmhegsmfaaRRR", [1324] = "evmhogumiaaRRR", [1325] = "evmhogsmiaaRRR", [1327] = "evmhogsmfaaRRR", [1344] = "evmwlusiaawRRR", [1345] = "evmwlssiaawRRR", [1352] = "evmwlumiaawRRR", [1353] = "evmwlsmiaawRRR", [1363] = "evmwssfaaRRR", [1368] = "evmwumiaaRRR", [1369] = "evmwsmiaaRRR", [1371] = "evmwsmfaaRRR", [1408] = "evmheusianwRRR", [1409] = "evmhessianwRRR", [1411] = "evmhessfanwRRR", [1412] = "evmhousianwRRR", [1413] = "evmhossianwRRR", [1415] = "evmhossfanwRRR", [1416] = "evmheumianwRRR", [1417] = "evmhesmianwRRR", [1419] = "evmhesmfanwRRR", [1420] = "evmhoumianwRRR", [1421] = "evmhosmianwRRR", [1423] = "evmhosmfanwRRR", [1448] = "evmhegumianRRR", [1449] = "evmhegsmianRRR", [1451] = "evmhegsmfanRRR", [1452] = "evmhogumianRRR", [1453] = "evmhogsmianRRR", [1455] = "evmhogsmfanRRR", [1472] = "evmwlusianwRRR", [1473] = "evmwlssianwRRR", [1480] = "evmwlumianwRRR", [1481] = "evmwlsmianwRRR", [1491] = "evmwssfanRRR", [1496] = "evmwumianRRR", [1497] = "evmwsmianRRR", [1499] = "evmwsmfanRRR", } local map_pri = { [0] = false, false, "tdiARI", "twiARI", map_spe, false, false, "mulliRRI", "subficRRI", false, "cmpl_iYLRU", "cmp_iYLRI", "addicRRI", "addic.RRI", "addi|liRR0I", "addis|lisRR0I", "b_KBJ", "sc", "bKJ", map_crops, "rlwimiRR~AAA.", map_rlwinm, false, "rlwnmRR~RAA.", "oriNRR~U", "orisRR~U", "xoriRR~U", "xorisRR~U", "andi.RR~U", "andis.RR~U", map_rld, map_ext, "lwzRRD", "lwzuRRD", "lbzRRD", "lbzuRRD", "stwRRD", "stwuRRD", "stbRRD", "stbuRRD", "lhzRRD", "lhzuRRD", "lhaRRD", "lhauRRD", "sthRRD", "sthuRRD", "lmwRRD", "stmwRRD", "lfsFRD", "lfsuFRD", "lfdFRD", "lfduFRD", "stfsFRD", "stfsuFRD", "stfdFRD", "stfduFRD", false, false, map_ld, map_fps, false, false, map_std, map_fpd, } ------------------------------------------------------------------------------ local map_gpr = { [0] = "r0", "sp", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", } local map_cond = { [0] = "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", } -- Format a condition bit. local function condfmt(cond) if cond <= 3 then return map_cond[band(cond, 3)] else return format("4*cr%d+%s", rshift(cond, 2), map_cond[band(cond, 3)]) end end ------------------------------------------------------------------------------ -- Output a nicely formatted line with an opcode and operands. local function putop(ctx, text, operands) local pos = ctx.pos local extra = "" if ctx.rel then local sym = ctx.symtab[ctx.rel] if sym then extra = "\t->"..sym end end if ctx.hexdump > 0 then ctx.out(format("%08x %s %-7s %s%s\n", ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra)) else ctx.out(format("%08x %-7s %s%s\n", ctx.addr+pos, text, concat(operands, ", "), extra)) end ctx.pos = pos + 4 end -- Fallback for unknown opcodes. local function unknown(ctx) return putop(ctx, ".long", { "0x"..tohex(ctx.op) }) end -- Disassemble a single instruction. local function disass_ins(ctx) local pos = ctx.pos local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4) local op = bor(lshift(b0, 24), lshift(b1, 16), lshift(b2, 8), b3) local operands = {} local last = nil local rs = 21 ctx.op = op ctx.rel = nil local opat = map_pri[rshift(b0, 2)] while type(opat) ~= "string" do if not opat then return unknown(ctx) end opat = opat[band(rshift(op, opat.shift), opat.mask)] end local name, pat = match(opat, "^([a-z0-9_.]*)(.*)") local altname, pat2 = match(pat, "|([a-z0-9_.]*)(.*)") if altname then pat = pat2 end for p in gmatch(pat, ".") do local x = nil if p == "R" then x = map_gpr[band(rshift(op, rs), 31)] rs = rs - 5 elseif p == "F" then x = "f"..band(rshift(op, rs), 31) rs = rs - 5 elseif p == "A" then x = band(rshift(op, rs), 31) rs = rs - 5 elseif p == "S" then x = arshift(lshift(op, 27-rs), 27) rs = rs - 5 elseif p == "I" then x = arshift(lshift(op, 16), 16) elseif p == "U" then x = band(op, 0xffff) elseif p == "D" or p == "E" then local disp = arshift(lshift(op, 16), 16) if p == "E" then disp = band(disp, -4) end if last == "r0" then last = "0" end operands[#operands] = format("%d(%s)", disp, last) elseif p >= "2" and p <= "8" then local disp = band(rshift(op, rs), 31) * p if last == "r0" then last = "0" end operands[#operands] = format("%d(%s)", disp, last) elseif p == "H" then x = band(rshift(op, rs), 31) + lshift(band(op, 2), 4) rs = rs - 5 elseif p == "M" then x = band(rshift(op, rs), 31) + band(op, 0x20) elseif p == "C" then x = condfmt(band(rshift(op, rs), 31)) rs = rs - 5 elseif p == "B" then local bo = rshift(op, 21) local cond = band(rshift(op, 16), 31) local cn = "" rs = rs - 10 if band(bo, 4) == 0 then cn = band(bo, 2) == 0 and "dnz" or "dz" if band(bo, 0x10) == 0 then cn = cn..(band(bo, 8) == 0 and "f" or "t") end if band(bo, 0x10) == 0 then x = condfmt(cond) end name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+") elseif band(bo, 0x10) == 0 then cn = map_cond[band(cond, 3) + (band(bo, 8) == 0 and 4 or 0)] if cond > 3 then x = "cr"..rshift(cond, 2) end name = name..(band(bo, 1) == band(rshift(op, 15), 1) and "-" or "+") end name = gsub(name, "_", cn) elseif p == "J" then x = arshift(lshift(op, 27-rs), 29-rs)*4 if band(op, 2) == 0 then x = ctx.addr + pos + x end ctx.rel = x x = "0x"..tohex(x) elseif p == "K" then if band(op, 1) ~= 0 then name = name.."l" end if band(op, 2) ~= 0 then name = name.."a" end elseif p == "X" or p == "Y" then x = band(rshift(op, rs+2), 7) if x == 0 and p == "Y" then x = nil else x = "cr"..x end rs = rs - 5 elseif p == "W" then x = "cr"..band(op, 7) elseif p == "Z" then x = band(rshift(op, rs-4), 255) rs = rs - 10 elseif p == ">" then operands[#operands] = rshift(operands[#operands], 1) elseif p == "0" then if last == "r0" then operands[#operands] = nil if altname then name = altname end end elseif p == "L" then name = gsub(name, "_", band(op, 0x00200000) ~= 0 and "d" or "w") elseif p == "." then if band(op, 1) == 1 then name = name.."." end elseif p == "N" then if op == 0x60000000 then name = "nop"; break end elseif p == "~" then local n = #operands operands[n-1], operands[n] = operands[n], operands[n-1] elseif p == "=" then local n = #operands if last == operands[n-1] then operands[n] = nil name = altname end elseif p == "%" then local n = #operands if last == operands[n-1] and last == operands[n-2] then operands[n] = nil operands[n-1] = nil name = altname end elseif p == "-" then rs = rs - 5 else assert(false) end if x then operands[#operands+1] = x; last = x end end return putop(ctx, name, operands) end ------------------------------------------------------------------------------ -- Disassemble a block of code. local function disass_block(ctx, ofs, len) if not ofs then ofs = 0 end local stop = len and ofs+len or #ctx.code stop = stop - stop % 4 ctx.pos = ofs - ofs % 4 ctx.rel = nil while ctx.pos < stop do disass_ins(ctx) end end -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). local function create_(code, addr, out) local ctx = {} ctx.code = code ctx.addr = addr or 0 ctx.out = out or io.write ctx.symtab = {} ctx.disass = disass_block ctx.hexdump = 8 return ctx end -- Simple API: disassemble code (a string) at address and output via out. local function disass_(code, addr, out) create_(code, addr, out):disass() end -- Return register name for RID. local function regname_(r) if r < 32 then return map_gpr[r] end return "f"..(r-32) end -- Public module functions. module(...) create = create_ disass = disass_ regname = regname_ ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/dis_x64.lua ================================================ ---------------------------------------------------------------------------- -- LuaJIT x64 disassembler wrapper module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- This module just exports the 64 bit functions from the combined -- x86/x64 disassembler module. All the interesting stuff is there. ------------------------------------------------------------------------------ local require = require module(...) local dis_x86 = require(_PACKAGE.."dis_x86") create = dis_x86.create64 disass = dis_x86.disass64 regname = dis_x86.regname64 ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/dis_x86.lua ================================================ ---------------------------------------------------------------------------- -- LuaJIT x86/x64 disassembler module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- This is a helper module used by the LuaJIT machine code dumper module. -- -- Sending small code snippets to an external disassembler and mixing the -- output with our own stuff was too fragile. So I had to bite the bullet -- and write yet another x86 disassembler. Oh well ... -- -- The output format is very similar to what ndisasm generates. But it has -- been developed independently by looking at the opcode tables from the -- Intel and AMD manuals. The supported instruction set is quite extensive -- and reflects what a current generation Intel or AMD CPU implements in -- 32 bit and 64 bit mode. Yes, this includes MMX, SSE, SSE2, SSE3, SSSE3, -- SSE4.1, SSE4.2, SSE4a and even privileged and hypervisor (VMX/SVM) -- instructions. -- -- Notes: -- * The (useless) a16 prefix, 3DNow and pre-586 opcodes are unsupported. -- * No attempt at optimization has been made -- it's fast enough for my needs. -- * The public API may change when more architectures are added. ------------------------------------------------------------------------------ local type = type local sub, byte, format = string.sub, string.byte, string.format local match, gmatch, gsub = string.match, string.gmatch, string.gsub local lower, rep = string.lower, string.rep -- Map for 1st opcode byte in 32 bit mode. Ugly? Well ... read on. local map_opc1_32 = { --0x [0]="addBmr","addVmr","addBrm","addVrm","addBai","addVai","push es","pop es", "orBmr","orVmr","orBrm","orVrm","orBai","orVai","push cs","opc2*", --1x "adcBmr","adcVmr","adcBrm","adcVrm","adcBai","adcVai","push ss","pop ss", "sbbBmr","sbbVmr","sbbBrm","sbbVrm","sbbBai","sbbVai","push ds","pop ds", --2x "andBmr","andVmr","andBrm","andVrm","andBai","andVai","es:seg","daa", "subBmr","subVmr","subBrm","subVrm","subBai","subVai","cs:seg","das", --3x "xorBmr","xorVmr","xorBrm","xorVrm","xorBai","xorVai","ss:seg","aaa", "cmpBmr","cmpVmr","cmpBrm","cmpVrm","cmpBai","cmpVai","ds:seg","aas", --4x "incVR","incVR","incVR","incVR","incVR","incVR","incVR","incVR", "decVR","decVR","decVR","decVR","decVR","decVR","decVR","decVR", --5x "pushUR","pushUR","pushUR","pushUR","pushUR","pushUR","pushUR","pushUR", "popUR","popUR","popUR","popUR","popUR","popUR","popUR","popUR", --6x "sz*pushaw,pusha","sz*popaw,popa","boundVrm","arplWmr", "fs:seg","gs:seg","o16:","a16", "pushUi","imulVrmi","pushBs","imulVrms", "insb","insVS","outsb","outsVS", --7x "joBj","jnoBj","jbBj","jnbBj","jzBj","jnzBj","jbeBj","jaBj", "jsBj","jnsBj","jpeBj","jpoBj","jlBj","jgeBj","jleBj","jgBj", --8x "arith!Bmi","arith!Vmi","arith!Bmi","arith!Vms", "testBmr","testVmr","xchgBrm","xchgVrm", "movBmr","movVmr","movBrm","movVrm", "movVmg","leaVrm","movWgm","popUm", --9x "nop*xchgVaR|pause|xchgWaR|repne nop","xchgVaR","xchgVaR","xchgVaR", "xchgVaR","xchgVaR","xchgVaR","xchgVaR", "sz*cbw,cwde,cdqe","sz*cwd,cdq,cqo","call farViw","wait", "sz*pushfw,pushf","sz*popfw,popf","sahf","lahf", --Ax "movBao","movVao","movBoa","movVoa", "movsb","movsVS","cmpsb","cmpsVS", "testBai","testVai","stosb","stosVS", "lodsb","lodsVS","scasb","scasVS", --Bx "movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi", "movVRI","movVRI","movVRI","movVRI","movVRI","movVRI","movVRI","movVRI", --Cx "shift!Bmu","shift!Vmu","retBw","ret","$lesVrm","$ldsVrm","movBmi","movVmi", "enterBwu","leave","retfBw","retf","int3","intBu","into","iretVS", --Dx "shift!Bm1","shift!Vm1","shift!Bmc","shift!Vmc","aamBu","aadBu","salc","xlatb", "fp*0","fp*1","fp*2","fp*3","fp*4","fp*5","fp*6","fp*7", --Ex "loopneBj","loopeBj","loopBj","sz*jcxzBj,jecxzBj,jrcxzBj", "inBau","inVau","outBua","outVua", "callVj","jmpVj","jmp farViw","jmpBj","inBad","inVad","outBda","outVda", --Fx "lock:","int1","repne:rep","rep:","hlt","cmc","testb!Bm","testv!Vm", "clc","stc","cli","sti","cld","std","incb!Bm","incd!Vm", } assert(#map_opc1_32 == 255) -- Map for 1st opcode byte in 64 bit mode (overrides only). local map_opc1_64 = setmetatable({ [0x06]=false, [0x07]=false, [0x0e]=false, [0x16]=false, [0x17]=false, [0x1e]=false, [0x1f]=false, [0x27]=false, [0x2f]=false, [0x37]=false, [0x3f]=false, [0x60]=false, [0x61]=false, [0x62]=false, [0x63]="movsxdVrDmt", [0x67]="a32:", [0x40]="rex*", [0x41]="rex*b", [0x42]="rex*x", [0x43]="rex*xb", [0x44]="rex*r", [0x45]="rex*rb", [0x46]="rex*rx", [0x47]="rex*rxb", [0x48]="rex*w", [0x49]="rex*wb", [0x4a]="rex*wx", [0x4b]="rex*wxb", [0x4c]="rex*wr", [0x4d]="rex*wrb", [0x4e]="rex*wrx", [0x4f]="rex*wrxb", [0x82]=false, [0x9a]=false, [0xc4]=false, [0xc5]=false, [0xce]=false, [0xd4]=false, [0xd5]=false, [0xd6]=false, [0xea]=false, }, { __index = map_opc1_32 }) -- Map for 2nd opcode byte (0F xx). True CISC hell. Hey, I told you. -- Prefix dependent MMX/SSE opcodes: (none)|rep|o16|repne, -|F3|66|F2 local map_opc2 = { --0x [0]="sldt!Dmp","sgdt!Ump","larVrm","lslVrm",nil,"syscall","clts","sysret", "invd","wbinvd",nil,"ud1",nil,"$prefetch!Bm","femms","3dnowMrmu", --1x "movupsXrm|movssXrm|movupdXrm|movsdXrm", "movupsXmr|movssXmr|movupdXmr|movsdXmr", "movhlpsXrm$movlpsXrm|movsldupXrm|movlpdXrm|movddupXrm", "movlpsXmr||movlpdXmr", "unpcklpsXrm||unpcklpdXrm", "unpckhpsXrm||unpckhpdXrm", "movlhpsXrm$movhpsXrm|movshdupXrm|movhpdXrm", "movhpsXmr||movhpdXmr", "$prefetcht!Bm","hintnopVm","hintnopVm","hintnopVm", "hintnopVm","hintnopVm","hintnopVm","hintnopVm", --2x "movUmx$","movUmy$","movUxm$","movUym$","movUmz$",nil,"movUzm$",nil, "movapsXrm||movapdXrm", "movapsXmr||movapdXmr", "cvtpi2psXrMm|cvtsi2ssXrVmt|cvtpi2pdXrMm|cvtsi2sdXrVmt", "movntpsXmr|movntssXmr|movntpdXmr|movntsdXmr", "cvttps2piMrXm|cvttss2siVrXm|cvttpd2piMrXm|cvttsd2siVrXm", "cvtps2piMrXm|cvtss2siVrXm|cvtpd2piMrXm|cvtsd2siVrXm", "ucomissXrm||ucomisdXrm", "comissXrm||comisdXrm", --3x "wrmsr","rdtsc","rdmsr","rdpmc","sysenter","sysexit",nil,"getsec", "opc3*38",nil,"opc3*3a",nil,nil,nil,nil,nil, --4x "cmovoVrm","cmovnoVrm","cmovbVrm","cmovnbVrm", "cmovzVrm","cmovnzVrm","cmovbeVrm","cmovaVrm", "cmovsVrm","cmovnsVrm","cmovpeVrm","cmovpoVrm", "cmovlVrm","cmovgeVrm","cmovleVrm","cmovgVrm", --5x "movmskpsVrXm$||movmskpdVrXm$","sqrtpsXrm|sqrtssXrm|sqrtpdXrm|sqrtsdXrm", "rsqrtpsXrm|rsqrtssXrm","rcppsXrm|rcpssXrm", "andpsXrm||andpdXrm","andnpsXrm||andnpdXrm", "orpsXrm||orpdXrm","xorpsXrm||xorpdXrm", "addpsXrm|addssXrm|addpdXrm|addsdXrm","mulpsXrm|mulssXrm|mulpdXrm|mulsdXrm", "cvtps2pdXrm|cvtss2sdXrm|cvtpd2psXrm|cvtsd2ssXrm", "cvtdq2psXrm|cvttps2dqXrm|cvtps2dqXrm", "subpsXrm|subssXrm|subpdXrm|subsdXrm","minpsXrm|minssXrm|minpdXrm|minsdXrm", "divpsXrm|divssXrm|divpdXrm|divsdXrm","maxpsXrm|maxssXrm|maxpdXrm|maxsdXrm", --6x "punpcklbwPrm","punpcklwdPrm","punpckldqPrm","packsswbPrm", "pcmpgtbPrm","pcmpgtwPrm","pcmpgtdPrm","packuswbPrm", "punpckhbwPrm","punpckhwdPrm","punpckhdqPrm","packssdwPrm", "||punpcklqdqXrm","||punpckhqdqXrm", "movPrVSm","movqMrm|movdquXrm|movdqaXrm", --7x "pshufwMrmu|pshufhwXrmu|pshufdXrmu|pshuflwXrmu","pshiftw!Pmu", "pshiftd!Pmu","pshiftq!Mmu||pshiftdq!Xmu", "pcmpeqbPrm","pcmpeqwPrm","pcmpeqdPrm","emms|", "vmreadUmr||extrqXmuu$|insertqXrmuu$","vmwriteUrm||extrqXrm$|insertqXrm$", nil,nil, "||haddpdXrm|haddpsXrm","||hsubpdXrm|hsubpsXrm", "movVSmMr|movqXrm|movVSmXr","movqMmr|movdquXmr|movdqaXmr", --8x "joVj","jnoVj","jbVj","jnbVj","jzVj","jnzVj","jbeVj","jaVj", "jsVj","jnsVj","jpeVj","jpoVj","jlVj","jgeVj","jleVj","jgVj", --9x "setoBm","setnoBm","setbBm","setnbBm","setzBm","setnzBm","setbeBm","setaBm", "setsBm","setnsBm","setpeBm","setpoBm","setlBm","setgeBm","setleBm","setgBm", --Ax "push fs","pop fs","cpuid","btVmr","shldVmru","shldVmrc",nil,nil, "push gs","pop gs","rsm","btsVmr","shrdVmru","shrdVmrc","fxsave!Dmp","imulVrm", --Bx "cmpxchgBmr","cmpxchgVmr","$lssVrm","btrVmr", "$lfsVrm","$lgsVrm","movzxVrBmt","movzxVrWmt", "|popcntVrm","ud2Dp","bt!Vmu","btcVmr", "bsfVrm","bsrVrm|lzcntVrm|bsrWrm","movsxVrBmt","movsxVrWmt", --Cx "xaddBmr","xaddVmr", "cmppsXrmu|cmpssXrmu|cmppdXrmu|cmpsdXrmu","$movntiVmr|", "pinsrwPrWmu","pextrwDrPmu", "shufpsXrmu||shufpdXrmu","$cmpxchg!Qmp", "bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR","bswapVR", --Dx "||addsubpdXrm|addsubpsXrm","psrlwPrm","psrldPrm","psrlqPrm", "paddqPrm","pmullwPrm", "|movq2dqXrMm|movqXmr|movdq2qMrXm$","pmovmskbVrMm||pmovmskbVrXm", "psubusbPrm","psubuswPrm","pminubPrm","pandPrm", "paddusbPrm","padduswPrm","pmaxubPrm","pandnPrm", --Ex "pavgbPrm","psrawPrm","psradPrm","pavgwPrm", "pmulhuwPrm","pmulhwPrm", "|cvtdq2pdXrm|cvttpd2dqXrm|cvtpd2dqXrm","$movntqMmr||$movntdqXmr", "psubsbPrm","psubswPrm","pminswPrm","porPrm", "paddsbPrm","paddswPrm","pmaxswPrm","pxorPrm", --Fx "|||lddquXrm","psllwPrm","pslldPrm","psllqPrm", "pmuludqPrm","pmaddwdPrm","psadbwPrm","maskmovqMrm||maskmovdquXrm$", "psubbPrm","psubwPrm","psubdPrm","psubqPrm", "paddbPrm","paddwPrm","padddPrm","ud", } assert(map_opc2[255] == "ud") -- Map for three-byte opcodes. Can't wait for their next invention. local map_opc3 = { ["38"] = { -- [66] 0f 38 xx --0x [0]="pshufbPrm","phaddwPrm","phadddPrm","phaddswPrm", "pmaddubswPrm","phsubwPrm","phsubdPrm","phsubswPrm", "psignbPrm","psignwPrm","psigndPrm","pmulhrswPrm", nil,nil,nil,nil, --1x "||pblendvbXrma",nil,nil,nil, "||blendvpsXrma","||blendvpdXrma",nil,"||ptestXrm", nil,nil,nil,nil, "pabsbPrm","pabswPrm","pabsdPrm",nil, --2x "||pmovsxbwXrm","||pmovsxbdXrm","||pmovsxbqXrm","||pmovsxwdXrm", "||pmovsxwqXrm","||pmovsxdqXrm",nil,nil, "||pmuldqXrm","||pcmpeqqXrm","||$movntdqaXrm","||packusdwXrm", nil,nil,nil,nil, --3x "||pmovzxbwXrm","||pmovzxbdXrm","||pmovzxbqXrm","||pmovzxwdXrm", "||pmovzxwqXrm","||pmovzxdqXrm",nil,"||pcmpgtqXrm", "||pminsbXrm","||pminsdXrm","||pminuwXrm","||pminudXrm", "||pmaxsbXrm","||pmaxsdXrm","||pmaxuwXrm","||pmaxudXrm", --4x "||pmulddXrm","||phminposuwXrm", --Fx [0xf0] = "|||crc32TrBmt",[0xf1] = "|||crc32TrVmt", }, ["3a"] = { -- [66] 0f 3a xx --0x [0x00]=nil,nil,nil,nil,nil,nil,nil,nil, "||roundpsXrmu","||roundpdXrmu","||roundssXrmu","||roundsdXrmu", "||blendpsXrmu","||blendpdXrmu","||pblendwXrmu","palignrPrmu", --1x nil,nil,nil,nil, "||pextrbVmXru","||pextrwVmXru","||pextrVmSXru","||extractpsVmXru", nil,nil,nil,nil,nil,nil,nil,nil, --2x "||pinsrbXrVmu","||insertpsXrmu","||pinsrXrVmuS",nil, --4x [0x40] = "||dppsXrmu", [0x41] = "||dppdXrmu", [0x42] = "||mpsadbwXrmu", --6x [0x60] = "||pcmpestrmXrmu",[0x61] = "||pcmpestriXrmu", [0x62] = "||pcmpistrmXrmu",[0x63] = "||pcmpistriXrmu", }, } -- Map for VMX/SVM opcodes 0F 01 C0-FF (sgdt group with register operands). local map_opcvm = { [0xc1]="vmcall",[0xc2]="vmlaunch",[0xc3]="vmresume",[0xc4]="vmxoff", [0xc8]="monitor",[0xc9]="mwait", [0xd8]="vmrun",[0xd9]="vmmcall",[0xda]="vmload",[0xdb]="vmsave", [0xdc]="stgi",[0xdd]="clgi",[0xde]="skinit",[0xdf]="invlpga", [0xf8]="swapgs",[0xf9]="rdtscp", } -- Map for FP opcodes. And you thought stack machines are simple? local map_opcfp = { -- D8-DF 00-BF: opcodes with a memory operand. -- D8 [0]="faddFm","fmulFm","fcomFm","fcompFm","fsubFm","fsubrFm","fdivFm","fdivrFm", "fldFm",nil,"fstFm","fstpFm","fldenvVm","fldcwWm","fnstenvVm","fnstcwWm", -- DA "fiaddDm","fimulDm","ficomDm","ficompDm", "fisubDm","fisubrDm","fidivDm","fidivrDm", -- DB "fildDm","fisttpDm","fistDm","fistpDm",nil,"fld twordFmp",nil,"fstp twordFmp", -- DC "faddGm","fmulGm","fcomGm","fcompGm","fsubGm","fsubrGm","fdivGm","fdivrGm", -- DD "fldGm","fisttpQm","fstGm","fstpGm","frstorDmp",nil,"fnsaveDmp","fnstswWm", -- DE "fiaddWm","fimulWm","ficomWm","ficompWm", "fisubWm","fisubrWm","fidivWm","fidivrWm", -- DF "fildWm","fisttpWm","fistWm","fistpWm", "fbld twordFmp","fildQm","fbstp twordFmp","fistpQm", -- xx C0-FF: opcodes with a pseudo-register operand. -- D8 "faddFf","fmulFf","fcomFf","fcompFf","fsubFf","fsubrFf","fdivFf","fdivrFf", -- D9 "fldFf","fxchFf",{"fnop"},nil, {"fchs","fabs",nil,nil,"ftst","fxam"}, {"fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz"}, {"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp"}, {"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"}, -- DA "fcmovbFf","fcmoveFf","fcmovbeFf","fcmovuFf",nil,{nil,"fucompp"},nil,nil, -- DB "fcmovnbFf","fcmovneFf","fcmovnbeFf","fcmovnuFf", {nil,nil,"fnclex","fninit"},"fucomiFf","fcomiFf",nil, -- DC "fadd toFf","fmul toFf",nil,nil, "fsub toFf","fsubr toFf","fdivr toFf","fdiv toFf", -- DD "ffreeFf",nil,"fstFf","fstpFf","fucomFf","fucompFf",nil,nil, -- DE "faddpFf","fmulpFf",nil,{nil,"fcompp"}, "fsubrpFf","fsubpFf","fdivrpFf","fdivpFf", -- DF nil,nil,nil,nil,{"fnstsw ax"},"fucomipFf","fcomipFf",nil, } assert(map_opcfp[126] == "fcomipFf") -- Map for opcode groups. The subkey is sp from the ModRM byte. local map_opcgroup = { arith = { "add", "or", "adc", "sbb", "and", "sub", "xor", "cmp" }, shift = { "rol", "ror", "rcl", "rcr", "shl", "shr", "sal", "sar" }, testb = { "testBmi", "testBmi", "not", "neg", "mul", "imul", "div", "idiv" }, testv = { "testVmi", "testVmi", "not", "neg", "mul", "imul", "div", "idiv" }, incb = { "inc", "dec" }, incd = { "inc", "dec", "callUmp", "$call farDmp", "jmpUmp", "$jmp farDmp", "pushUm" }, sldt = { "sldt", "str", "lldt", "ltr", "verr", "verw" }, sgdt = { "vm*$sgdt", "vm*$sidt", "$lgdt", "vm*$lidt", "smsw", nil, "lmsw", "vm*$invlpg" }, bt = { nil, nil, nil, nil, "bt", "bts", "btr", "btc" }, cmpxchg = { nil, "sz*,cmpxchg8bQmp,cmpxchg16bXmp", nil, nil, nil, nil, "vmptrld|vmxon|vmclear", "vmptrst" }, pshiftw = { nil, nil, "psrlw", nil, "psraw", nil, "psllw" }, pshiftd = { nil, nil, "psrld", nil, "psrad", nil, "pslld" }, pshiftq = { nil, nil, "psrlq", nil, nil, nil, "psllq" }, pshiftdq = { nil, nil, "psrlq", "psrldq", nil, nil, "psllq", "pslldq" }, fxsave = { "$fxsave", "$fxrstor", "$ldmxcsr", "$stmxcsr", nil, "lfenceDp$", "mfenceDp$", "sfenceDp$clflush" }, prefetch = { "prefetch", "prefetchw" }, prefetcht = { "prefetchnta", "prefetcht0", "prefetcht1", "prefetcht2" }, } ------------------------------------------------------------------------------ -- Maps for register names. local map_regs = { B = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh", "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }, B64 = { "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b" }, W = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w" }, D = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" }, Q = { "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" }, M = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }, -- No x64 ext! X = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" }, } local map_segregs = { "es", "cs", "ss", "ds", "fs", "gs", "segr6", "segr7" } -- Maps for size names. local map_sz2n = { B = 1, W = 2, D = 4, Q = 8, M = 8, X = 16, } local map_sz2prefix = { B = "byte", W = "word", D = "dword", Q = "qword", M = "qword", X = "xword", F = "dword", G = "qword", -- No need for sizes/register names for these two. } ------------------------------------------------------------------------------ -- Output a nicely formatted line with an opcode and operands. local function putop(ctx, text, operands) local code, pos, hex = ctx.code, ctx.pos, "" local hmax = ctx.hexdump if hmax > 0 then for i=ctx.start,pos-1 do hex = hex..format("%02X", byte(code, i, i)) end if #hex > hmax then hex = sub(hex, 1, hmax)..". " else hex = hex..rep(" ", hmax-#hex+2) end end if operands then text = text.." "..operands end if ctx.o16 then text = "o16 "..text; ctx.o16 = false end if ctx.a32 then text = "a32 "..text; ctx.a32 = false end if ctx.rep then text = ctx.rep.." "..text; ctx.rep = false end if ctx.rex then local t = (ctx.rexw and "w" or "")..(ctx.rexr and "r" or "").. (ctx.rexx and "x" or "")..(ctx.rexb and "b" or "") if t ~= "" then text = "rex."..t.." "..text end ctx.rexw = false; ctx.rexr = false; ctx.rexx = false; ctx.rexb = false ctx.rex = false end if ctx.seg then local text2, n = gsub(text, "%[", "["..ctx.seg..":") if n == 0 then text = ctx.seg.." "..text else text = text2 end ctx.seg = false end if ctx.lock then text = "lock "..text; ctx.lock = false end local imm = ctx.imm if imm then local sym = ctx.symtab[imm] if sym then text = text.."\t->"..sym end end ctx.out(format("%08x %s%s\n", ctx.addr+ctx.start, hex, text)) ctx.mrm = false ctx.start = pos ctx.imm = nil end -- Clear all prefix flags. local function clearprefixes(ctx) ctx.o16 = false; ctx.seg = false; ctx.lock = false; ctx.rep = false ctx.rexw = false; ctx.rexr = false; ctx.rexx = false; ctx.rexb = false ctx.rex = false; ctx.a32 = false end -- Fallback for incomplete opcodes at the end. local function incomplete(ctx) ctx.pos = ctx.stop+1 clearprefixes(ctx) return putop(ctx, "(incomplete)") end -- Fallback for unknown opcodes. local function unknown(ctx) clearprefixes(ctx) return putop(ctx, "(unknown)") end -- Return an immediate of the specified size. local function getimm(ctx, pos, n) if pos+n-1 > ctx.stop then return incomplete(ctx) end local code = ctx.code if n == 1 then local b1 = byte(code, pos, pos) return b1 elseif n == 2 then local b1, b2 = byte(code, pos, pos+1) return b1+b2*256 else local b1, b2, b3, b4 = byte(code, pos, pos+3) local imm = b1+b2*256+b3*65536+b4*16777216 ctx.imm = imm return imm end end -- Process pattern string and generate the operands. local function putpat(ctx, name, pat) local operands, regs, sz, mode, sp, rm, sc, rx, sdisp local code, pos, stop = ctx.code, ctx.pos, ctx.stop -- Chars used: 1DFGIMPQRSTUVWXacdfgijmoprstuwxyz for p in gmatch(pat, ".") do local x = nil if p == "V" or p == "U" then if ctx.rexw then sz = "Q"; ctx.rexw = false elseif ctx.o16 then sz = "W"; ctx.o16 = false elseif p == "U" and ctx.x64 then sz = "Q" else sz = "D" end regs = map_regs[sz] elseif p == "T" then if ctx.rexw then sz = "Q"; ctx.rexw = false else sz = "D" end regs = map_regs[sz] elseif p == "B" then sz = "B" regs = ctx.rex and map_regs.B64 or map_regs.B elseif match(p, "[WDQMXFG]") then sz = p regs = map_regs[sz] elseif p == "P" then sz = ctx.o16 and "X" or "M"; ctx.o16 = false regs = map_regs[sz] elseif p == "S" then name = name..lower(sz) elseif p == "s" then local imm = getimm(ctx, pos, 1); if not imm then return end x = imm <= 127 and format("+0x%02x", imm) or format("-0x%02x", 256-imm) pos = pos+1 elseif p == "u" then local imm = getimm(ctx, pos, 1); if not imm then return end x = format("0x%02x", imm) pos = pos+1 elseif p == "w" then local imm = getimm(ctx, pos, 2); if not imm then return end x = format("0x%x", imm) pos = pos+2 elseif p == "o" then -- [offset] if ctx.x64 then local imm1 = getimm(ctx, pos, 4); if not imm1 then return end local imm2 = getimm(ctx, pos+4, 4); if not imm2 then return end x = format("[0x%08x%08x]", imm2, imm1) pos = pos+8 else local imm = getimm(ctx, pos, 4); if not imm then return end x = format("[0x%08x]", imm) pos = pos+4 end elseif p == "i" or p == "I" then local n = map_sz2n[sz] if n == 8 and ctx.x64 and p == "I" then local imm1 = getimm(ctx, pos, 4); if not imm1 then return end local imm2 = getimm(ctx, pos+4, 4); if not imm2 then return end x = format("0x%08x%08x", imm2, imm1) else if n == 8 then n = 4 end local imm = getimm(ctx, pos, n); if not imm then return end if sz == "Q" and (imm < 0 or imm > 0x7fffffff) then imm = (0xffffffff+1)-imm x = format(imm > 65535 and "-0x%08x" or "-0x%x", imm) else x = format(imm > 65535 and "0x%08x" or "0x%x", imm) end end pos = pos+n elseif p == "j" then local n = map_sz2n[sz] if n == 8 then n = 4 end local imm = getimm(ctx, pos, n); if not imm then return end if sz == "B" and imm > 127 then imm = imm-256 elseif imm > 2147483647 then imm = imm-4294967296 end pos = pos+n imm = imm + pos + ctx.addr if imm > 4294967295 and not ctx.x64 then imm = imm-4294967296 end ctx.imm = imm if sz == "W" then x = format("word 0x%04x", imm%65536) elseif ctx.x64 then local lo = imm % 0x1000000 x = format("0x%02x%06x", (imm-lo) / 0x1000000, lo) else x = format("0x%08x", imm) end elseif p == "R" then local r = byte(code, pos-1, pos-1)%8 if ctx.rexb then r = r + 8; ctx.rexb = false end x = regs[r+1] elseif p == "a" then x = regs[1] elseif p == "c" then x = "cl" elseif p == "d" then x = "dx" elseif p == "1" then x = "1" else if not mode then mode = ctx.mrm if not mode then if pos > stop then return incomplete(ctx) end mode = byte(code, pos, pos) pos = pos+1 end rm = mode%8; mode = (mode-rm)/8 sp = mode%8; mode = (mode-sp)/8 sdisp = "" if mode < 3 then if rm == 4 then if pos > stop then return incomplete(ctx) end sc = byte(code, pos, pos) pos = pos+1 rm = sc%8; sc = (sc-rm)/8 rx = sc%8; sc = (sc-rx)/8 if ctx.rexx then rx = rx + 8; ctx.rexx = false end if rx == 4 then rx = nil end end if mode > 0 or rm == 5 then local dsz = mode if dsz ~= 1 then dsz = 4 end local disp = getimm(ctx, pos, dsz); if not disp then return end if mode == 0 then rm = nil end if rm or rx or (not sc and ctx.x64 and not ctx.a32) then if dsz == 1 and disp > 127 then sdisp = format("-0x%x", 256-disp) elseif disp >= 0 and disp <= 0x7fffffff then sdisp = format("+0x%x", disp) else sdisp = format("-0x%x", (0xffffffff+1)-disp) end else sdisp = format(ctx.x64 and not ctx.a32 and not (disp >= 0 and disp <= 0x7fffffff) and "0xffffffff%08x" or "0x%08x", disp) end pos = pos+dsz end end if rm and ctx.rexb then rm = rm + 8; ctx.rexb = false end if ctx.rexr then sp = sp + 8; ctx.rexr = false end end if p == "m" then if mode == 3 then x = regs[rm+1] else local aregs = ctx.a32 and map_regs.D or ctx.aregs local srm, srx = "", "" if rm then srm = aregs[rm+1] elseif not sc and ctx.x64 and not ctx.a32 then srm = "rip" end ctx.a32 = false if rx then if rm then srm = srm.."+" end srx = aregs[rx+1] if sc > 0 then srx = srx.."*"..(2^sc) end end x = format("[%s%s%s]", srm, srx, sdisp) end if mode < 3 and (not match(pat, "[aRrgp]") or match(pat, "t")) then -- Yuck. x = map_sz2prefix[sz].." "..x end elseif p == "r" then x = regs[sp+1] elseif p == "g" then x = map_segregs[sp+1] elseif p == "p" then -- Suppress prefix. elseif p == "f" then x = "st"..rm elseif p == "x" then if sp == 0 and ctx.lock and not ctx.x64 then x = "CR8"; ctx.lock = false else x = "CR"..sp end elseif p == "y" then x = "DR"..sp elseif p == "z" then x = "TR"..sp elseif p == "t" then else error("bad pattern `"..pat.."'") end end if x then operands = operands and operands..", "..x or x end end ctx.pos = pos return putop(ctx, name, operands) end -- Forward declaration. local map_act -- Fetch and cache MRM byte. local function getmrm(ctx) local mrm = ctx.mrm if not mrm then local pos = ctx.pos if pos > ctx.stop then return nil end mrm = byte(ctx.code, pos, pos) ctx.pos = pos+1 ctx.mrm = mrm end return mrm end -- Dispatch to handler depending on pattern. local function dispatch(ctx, opat, patgrp) if not opat then return unknown(ctx) end if match(opat, "%|") then -- MMX/SSE variants depending on prefix. local p if ctx.rep then p = ctx.rep=="rep" and "%|([^%|]*)" or "%|[^%|]*%|[^%|]*%|([^%|]*)" ctx.rep = false elseif ctx.o16 then p = "%|[^%|]*%|([^%|]*)"; ctx.o16 = false else p = "^[^%|]*" end opat = match(opat, p) if not opat then return unknown(ctx) end -- ctx.rep = false; ctx.o16 = false --XXX fails for 66 f2 0f 38 f1 06 crc32 eax,WORD PTR [esi] --XXX remove in branches? end if match(opat, "%$") then -- reg$mem variants. local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end opat = match(opat, mrm >= 192 and "^[^%$]*" or "%$(.*)") if opat == "" then return unknown(ctx) end end if opat == "" then return unknown(ctx) end local name, pat = match(opat, "^([a-z0-9 ]*)(.*)") if pat == "" and patgrp then pat = patgrp end return map_act[sub(pat, 1, 1)](ctx, name, pat) end -- Get a pattern from an opcode map and dispatch to handler. local function dispatchmap(ctx, opcmap) local pos = ctx.pos local opat = opcmap[byte(ctx.code, pos, pos)] pos = pos + 1 ctx.pos = pos return dispatch(ctx, opat) end -- Map for action codes. The key is the first char after the name. map_act = { -- Simple opcodes without operands. [""] = function(ctx, name, pat) return putop(ctx, name) end, -- Operand size chars fall right through. B = putpat, W = putpat, D = putpat, Q = putpat, V = putpat, U = putpat, T = putpat, M = putpat, X = putpat, P = putpat, F = putpat, G = putpat, -- Collect prefixes. [":"] = function(ctx, name, pat) ctx[pat == ":" and name or sub(pat, 2)] = name if ctx.pos - ctx.start > 5 then return unknown(ctx) end -- Limit #prefixes. end, -- Chain to special handler specified by name. ["*"] = function(ctx, name, pat) return map_act[name](ctx, name, sub(pat, 2)) end, -- Use named subtable for opcode group. ["!"] = function(ctx, name, pat) local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end return dispatch(ctx, map_opcgroup[name][((mrm-(mrm%8))/8)%8+1], sub(pat, 2)) end, -- o16,o32[,o64] variants. sz = function(ctx, name, pat) if ctx.o16 then ctx.o16 = false else pat = match(pat, ",(.*)") if ctx.rexw then local p = match(pat, ",(.*)") if p then pat = p; ctx.rexw = false end end end pat = match(pat, "^[^,]*") return dispatch(ctx, pat) end, -- Two-byte opcode dispatch. opc2 = function(ctx, name, pat) return dispatchmap(ctx, map_opc2) end, -- Three-byte opcode dispatch. opc3 = function(ctx, name, pat) return dispatchmap(ctx, map_opc3[pat]) end, -- VMX/SVM dispatch. vm = function(ctx, name, pat) return dispatch(ctx, map_opcvm[ctx.mrm]) end, -- Floating point opcode dispatch. fp = function(ctx, name, pat) local mrm = getmrm(ctx); if not mrm then return incomplete(ctx) end local rm = mrm%8 local idx = pat*8 + ((mrm-rm)/8)%8 if mrm >= 192 then idx = idx + 64 end local opat = map_opcfp[idx] if type(opat) == "table" then opat = opat[rm+1] end return dispatch(ctx, opat) end, -- REX prefix. rex = function(ctx, name, pat) if ctx.rex then return unknown(ctx) end -- Only 1 REX prefix allowed. for p in gmatch(pat, ".") do ctx["rex"..p] = true end ctx.rex = true end, -- Special case for nop with REX prefix. nop = function(ctx, name, pat) return dispatch(ctx, ctx.rex and pat or "nop") end, } ------------------------------------------------------------------------------ -- Disassemble a block of code. local function disass_block(ctx, ofs, len) if not ofs then ofs = 0 end local stop = len and ofs+len or #ctx.code ofs = ofs + 1 ctx.start = ofs ctx.pos = ofs ctx.stop = stop ctx.imm = nil ctx.mrm = false clearprefixes(ctx) while ctx.pos <= stop do dispatchmap(ctx, ctx.map1) end if ctx.pos ~= ctx.start then incomplete(ctx) end end -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). local function create_(code, addr, out) local ctx = {} ctx.code = code ctx.addr = (addr or 0) - 1 ctx.out = out or io.write ctx.symtab = {} ctx.disass = disass_block ctx.hexdump = 16 ctx.x64 = false ctx.map1 = map_opc1_32 ctx.aregs = map_regs.D return ctx end local function create64_(code, addr, out) local ctx = create_(code, addr, out) ctx.x64 = true ctx.map1 = map_opc1_64 ctx.aregs = map_regs.Q return ctx end -- Simple API: disassemble code (a string) at address and output via out. local function disass_(code, addr, out) create_(code, addr, out):disass() end local function disass64_(code, addr, out) create64_(code, addr, out):disass() end -- Return register name for RID. local function regname_(r) if r < 8 then return map_regs.D[r+1] end return map_regs.X[r-7] end local function regname64_(r) if r < 16 then return map_regs.Q[r+1] end return map_regs.X[r-15] end -- Public module functions. module(...) create = create_ create64 = create64_ disass = disass_ disass64 = disass64_ regname = regname_ regname64 = regname64_ ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/dump.lua ================================================ ---------------------------------------------------------------------------- -- LuaJIT compiler dump module. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- -- This module can be used to debug the JIT compiler itself. It dumps the -- code representations and structures used in various compiler stages. -- -- Example usage: -- -- luajit -jdump -e "local x=0; for i=1,1e6 do x=x+i end; print(x)" -- luajit -jdump=im -e "for i=1,1000 do for j=1,1000 do end end" | less -R -- luajit -jdump=is myapp.lua | less -R -- luajit -jdump=-b myapp.lua -- luajit -jdump=+aH,myapp.html myapp.lua -- luajit -jdump=ixT,myapp.dump myapp.lua -- -- The first argument specifies the dump mode. The second argument gives -- the output file name. Default output is to stdout, unless the environment -- variable LUAJIT_DUMPFILE is set. The file is overwritten every time the -- module is started. -- -- Different features can be turned on or off with the dump mode. If the -- mode starts with a '+', the following features are added to the default -- set of features; a '-' removes them. Otherwise the features are replaced. -- -- The following dump features are available (* marks the default): -- -- * t Print a line for each started, ended or aborted trace (see also -jv). -- * b Dump the traced bytecode. -- * i Dump the IR (intermediate representation). -- r Augment the IR with register/stack slots. -- s Dump the snapshot map. -- * m Dump the generated machine code. -- x Print each taken trace exit. -- X Print each taken trace exit and the contents of all registers. -- -- The output format can be set with the following characters: -- -- T Plain text output. -- A ANSI-colored text output -- H Colorized HTML + CSS output. -- -- The default output format is plain text. It's set to ANSI-colored text -- if the COLORTERM variable is set. Note: this is independent of any output -- redirection, which is actually considered a feature. -- -- You probably want to use less -R to enjoy viewing ANSI-colored text from -- a pipe or a file. Add this to your ~/.bashrc: export LESS="-R" -- ------------------------------------------------------------------------------ -- Cache some library functions and objects. local jit = require("jit") assert(jit.version_num == 20001, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc local traceinfo, traceir, tracek = jutil.traceinfo, jutil.traceir, jutil.tracek local tracemc, tracesnap = jutil.tracemc, jutil.tracesnap local traceexitstub, ircalladdr = jutil.traceexitstub, jutil.ircalladdr local bit = require("bit") local band, shl, shr = bit.band, bit.lshift, bit.rshift local sub, gsub, format = string.sub, string.gsub, string.format local byte, char, rep = string.byte, string.char, string.rep local type, tostring = type, tostring local stdout, stderr = io.stdout, io.stderr -- Load other modules on-demand. local bcline, disass -- Active flag, output file handle and dump mode. local active, out, dumpmode ------------------------------------------------------------------------------ local symtabmt = { __index = false } local symtab = {} local nexitsym = 0 -- Fill nested symbol table with per-trace exit stub addresses. local function fillsymtab_tr(tr, nexit) local t = {} symtabmt.__index = t if jit.arch == "mips" or jit.arch == "mipsel" then t[traceexitstub(tr, 0)] = "exit" return end for i=0,nexit-1 do local addr = traceexitstub(tr, i) t[addr] = tostring(i) end local addr = traceexitstub(tr, nexit) if addr then t[addr] = "stack_check" end end -- Fill symbol table with trace exit stub addresses. local function fillsymtab(tr, nexit) local t = symtab if nexitsym == 0 then local ircall = vmdef.ircall for i=0,#ircall do local addr = ircalladdr(i) if addr ~= 0 then t[addr] = ircall[i] end end end if nexitsym == 1000000 then -- Per-trace exit stubs. fillsymtab_tr(tr, nexit) elseif nexit > nexitsym then -- Shared exit stubs. for i=nexitsym,nexit-1 do local addr = traceexitstub(i) if addr == nil then -- Fall back to per-trace exit stubs. fillsymtab_tr(tr, nexit) setmetatable(symtab, symtabmt) nexit = 1000000 break end t[addr] = tostring(i) end nexitsym = nexit end return t end local function dumpwrite(s) out:write(s) end -- Disassemble machine code. local function dump_mcode(tr) local info = traceinfo(tr) if not info then return end local mcode, addr, loop = tracemc(tr) if not mcode then return end if not disass then disass = require("jit.dis_"..jit.arch) end out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") local ctx = disass.create(mcode, addr, dumpwrite) ctx.hexdump = 0 ctx.symtab = fillsymtab(tr, info.nexit) if loop ~= 0 then symtab[addr+loop] = "LOOP" ctx:disass(0, loop) out:write("->LOOP:\n") ctx:disass(loop, #mcode-loop) symtab[addr+loop] = nil else ctx:disass(0, #mcode) end end ------------------------------------------------------------------------------ local irtype_text = { [0] = "nil", "fal", "tru", "lud", "str", "p32", "thr", "pro", "fun", "p64", "cdt", "tab", "udt", "flt", "num", "i8 ", "u8 ", "i16", "u16", "int", "u32", "i64", "u64", "sfp", } local colortype_ansi = { [0] = "%s", "%s", "%s", "\027[36m%s\027[m", "\027[32m%s\027[m", "%s", "\027[1m%s\027[m", "%s", "\027[1m%s\027[m", "%s", "\027[33m%s\027[m", "\027[31m%s\027[m", "\027[36m%s\027[m", "\027[34m%s\027[m", "\027[34m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", "\027[35m%s\027[m", } local function colorize_text(s, t) return s end local function colorize_ansi(s, t) return format(colortype_ansi[t], s) end local irtype_ansi = setmetatable({}, { __index = function(tab, t) local s = colorize_ansi(irtype_text[t], t); tab[t] = s; return s; end }) local html_escape = { ["<"] = "<", [">"] = ">", ["&"] = "&", } local function colorize_html(s, t) s = gsub(s, "[<>&]", html_escape) return format('%s', irtype_text[t], s) end local irtype_html = setmetatable({}, { __index = function(tab, t) local s = colorize_html(irtype_text[t], t); tab[t] = s; return s; end }) local header_html = [[ ]] local colorize, irtype -- Lookup tables to convert some literals into names. local litname = { ["SLOAD "] = setmetatable({}, { __index = function(t, mode) local s = "" if band(mode, 1) ~= 0 then s = s.."P" end if band(mode, 2) ~= 0 then s = s.."F" end if band(mode, 4) ~= 0 then s = s.."T" end if band(mode, 8) ~= 0 then s = s.."C" end if band(mode, 16) ~= 0 then s = s.."R" end if band(mode, 32) ~= 0 then s = s.."I" end t[mode] = s return s end}), ["XLOAD "] = { [0] = "", "R", "V", "RV", "U", "RU", "VU", "RVU", }, ["CONV "] = setmetatable({}, { __index = function(t, mode) local s = irtype[band(mode, 31)] s = irtype[band(shr(mode, 5), 31)].."."..s if band(mode, 0x400) ~= 0 then s = s.." trunc" elseif band(mode, 0x800) ~= 0 then s = s.." sext" end local c = shr(mode, 14) if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end t[mode] = s return s end}), ["FLOAD "] = vmdef.irfield, ["FREF "] = vmdef.irfield, ["FPMATH"] = vmdef.irfpm, } local function ctlsub(c) if c == "\n" then return "\\n" elseif c == "\r" then return "\\r" elseif c == "\t" then return "\\t" else return format("\\%03d", byte(c)) end end local function fmtfunc(func, pc) local fi = funcinfo(func, pc) if fi.loc then return fi.loc elseif fi.ffid then return vmdef.ffnames[fi.ffid] elseif fi.addr then return format("C:%x", fi.addr) else return "(?)" end end local function formatk(tr, idx) local k, t, slot = tracek(tr, idx) local tn = type(k) local s if tn == "number" then if k == 2^52+2^51 then s = "bias" else s = format("%+.14g", k) end elseif tn == "string" then s = format(#k > 20 and '"%.20s"~' or '"%s"', gsub(k, "%c", ctlsub)) elseif tn == "function" then s = fmtfunc(k) elseif tn == "table" then s = format("{%p}", k) elseif tn == "userdata" then if t == 12 then s = format("userdata:%p", k) else s = format("[%p]", k) if s == "[0x00000000]" then s = "NULL" end end elseif t == 21 then -- int64_t s = sub(tostring(k), 1, -3) if sub(s, 1, 1) ~= "-" then s = "+"..s end else s = tostring(k) -- For primitives. end s = colorize(format("%-4s", s), t) if slot then s = format("%s @%d", s, slot) end return s end local function printsnap(tr, snap) local n = 2 for s=0,snap[1]-1 do local sn = snap[n] if shr(sn, 24) == s then n = n + 1 local ref = band(sn, 0xffff) - 0x8000 -- REF_BIAS if ref < 0 then out:write(formatk(tr, ref)) elseif band(sn, 0x80000) ~= 0 then -- SNAP_SOFTFPNUM out:write(colorize(format("%04d/%04d", ref, ref+1), 14)) else local m, ot, op1, op2 = traceir(tr, ref) out:write(colorize(format("%04d", ref), band(ot, 31))) end out:write(band(sn, 0x10000) == 0 and " " or "|") -- SNAP_FRAME else out:write("---- ") end end out:write("]\n") end -- Dump snapshots (not interleaved with IR). local function dump_snap(tr) out:write("---- TRACE ", tr, " snapshots\n") for i=0,1000000000 do local snap = tracesnap(tr, i) if not snap then break end out:write(format("#%-3d %04d [ ", i, snap[0])) printsnap(tr, snap) end end -- Return a register name or stack slot for a rid/sp location. local function ridsp_name(ridsp, ins) if not disass then disass = require("jit.dis_"..jit.arch) end local rid, slot = band(ridsp, 0xff), shr(ridsp, 8) if rid == 253 or rid == 254 then return (slot == 0 or slot == 255) and " {sink" or format(" {%04d", ins-slot) end if ridsp > 255 then return format("[%x]", slot*4) end if rid < 128 then return disass.regname(rid) end return "" end -- Dump CALL* function ref and return optional ctype. local function dumpcallfunc(tr, ins) local ctype if ins > 0 then local m, ot, op1, op2 = traceir(tr, ins) if band(ot, 31) == 0 then -- nil type means CARG(func, ctype). ins = op1 ctype = formatk(tr, op2) end end if ins < 0 then out:write(format("[0x%x](", tonumber((tracek(tr, ins))))) else out:write(format("%04d (", ins)) end return ctype end -- Recursively gather CALL* args and dump them. local function dumpcallargs(tr, ins) if ins < 0 then out:write(formatk(tr, ins)) else local m, ot, op1, op2 = traceir(tr, ins) local oidx = 6*shr(ot, 8) local op = sub(vmdef.irnames, oidx+1, oidx+6) if op == "CARG " then dumpcallargs(tr, op1) if op2 < 0 then out:write(" ", formatk(tr, op2)) else out:write(" ", format("%04d", op2)) end else out:write(format("%04d", ins)) end end end -- Dump IR and interleaved snapshots. local function dump_ir(tr, dumpsnap, dumpreg) local info = traceinfo(tr) if not info then return end local nins = info.nins out:write("---- TRACE ", tr, " IR\n") local irnames = vmdef.irnames local snapref = 65536 local snap, snapno if dumpsnap then snap = tracesnap(tr, 0) snapref = snap[0] snapno = 0 end for ins=1,nins do if ins >= snapref then if dumpreg then out:write(format(".... SNAP #%-3d [ ", snapno)) else out:write(format(".... SNAP #%-3d [ ", snapno)) end printsnap(tr, snap) snapno = snapno + 1 snap = tracesnap(tr, snapno) snapref = snap and snap[0] or 65536 end local m, ot, op1, op2, ridsp = traceir(tr, ins) local oidx, t = 6*shr(ot, 8), band(ot, 31) local op = sub(irnames, oidx+1, oidx+6) if op == "LOOP " then if dumpreg then out:write(format("%04d ------------ LOOP ------------\n", ins)) else out:write(format("%04d ------ LOOP ------------\n", ins)) end elseif op ~= "NOP " and op ~= "CARG " and (dumpreg or op ~= "RENAME") then local rid = band(ridsp, 255) if dumpreg then out:write(format("%04d %-6s", ins, ridsp_name(ridsp, ins))) else out:write(format("%04d ", ins)) end out:write(format("%s%s %s %s ", (rid == 254 or rid == 253) and "}" or (band(ot, 128) == 0 and " " or ">"), band(ot, 64) == 0 and " " or "+", irtype[t], op)) local m1, m2 = band(m, 3), band(m, 3*4) if sub(op, 1, 4) == "CALL" then local ctype if m2 == 1*4 then -- op2 == IRMlit out:write(format("%-10s (", vmdef.ircall[op2])) else ctype = dumpcallfunc(tr, op2) end if op1 ~= -1 then dumpcallargs(tr, op1) end out:write(")") if ctype then out:write(" ctype ", ctype) end elseif op == "CNEW " and op2 == -1 then out:write(formatk(tr, op1)) elseif m1 ~= 3 then -- op1 != IRMnone if op1 < 0 then out:write(formatk(tr, op1)) else out:write(format(m1 == 0 and "%04d" or "#%-3d", op1)) end if m2 ~= 3*4 then -- op2 != IRMnone if m2 == 1*4 then -- op2 == IRMlit local litn = litname[op] if litn and litn[op2] then out:write(" ", litn[op2]) elseif op == "UREFO " or op == "UREFC " then out:write(format(" #%-3d", shr(op2, 8))) else out:write(format(" #%-3d", op2)) end elseif op2 < 0 then out:write(" ", formatk(tr, op2)) else out:write(format(" %04d", op2)) end end end out:write("\n") end end if snap then if dumpreg then out:write(format(".... SNAP #%-3d [ ", snapno)) else out:write(format(".... SNAP #%-3d [ ", snapno)) end printsnap(tr, snap) end end ------------------------------------------------------------------------------ local recprefix = "" local recdepth = 0 -- Format trace error message. local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end err = format(vmdef.traceerr[err], info) end return err end -- Dump trace states. local function dump_trace(what, tr, func, pc, otr, oex) if what == "stop" or (what == "abort" and dumpmode.a) then if dumpmode.i then dump_ir(tr, dumpmode.s, dumpmode.r and what == "stop") elseif dumpmode.s then dump_snap(tr) end if dumpmode.m then dump_mcode(tr) end end if what == "start" then if dumpmode.H then out:write('
\n') end
    out:write("---- TRACE ", tr, " ", what)
    if otr then out:write(" ", otr, "/", oex) end
    out:write(" ", fmtfunc(func, pc), "\n")
    recprefix = ""
  elseif what == "stop" or what == "abort" then
    out:write("---- TRACE ", tr, " ", what)
    recprefix = nil
    if what == "abort" then
      out:write(" ", fmtfunc(func, pc), " -- ", fmterr(otr, oex), "\n")
    else
      local info = traceinfo(tr)
      local link, ltype = info.link, info.linktype
      if link == tr or link == 0 then
	out:write(" -> ", ltype, "\n")
      elseif ltype == "root" then
	out:write(" -> ", link, "\n")
      else
	out:write(" -> ", link, " ", ltype, "\n")
      end
    end
    if dumpmode.H then out:write("
\n\n") else out:write("\n") end else out:write("---- TRACE ", what, "\n\n") end out:flush() end -- Dump recorded bytecode. local function dump_record(tr, func, pc, depth, callee) if depth ~= recdepth then recdepth = depth recprefix = rep(" .", depth) end local line if pc >= 0 then line = bcline(func, pc, recprefix) if dumpmode.H then line = gsub(line, "[<>&]", html_escape) end else line = "0000 "..recprefix.." FUNCC \n" callee = func end if pc <= 0 then out:write(sub(line, 1, -2), " ; ", fmtfunc(func), "\n") else out:write(line) end if pc >= 0 and band(funcbc(func, pc), 0xff) < 16 then -- ORDER BC out:write(bcline(func, pc+1, recprefix)) -- Write JMP for cond. end end ------------------------------------------------------------------------------ -- Dump taken trace exits. local function dump_texit(tr, ex, ngpr, nfpr, ...) out:write("---- TRACE ", tr, " exit ", ex, "\n") if dumpmode.X then local regs = {...} if jit.arch == "x64" then for i=1,ngpr do out:write(format(" %016x", regs[i])) if i % 4 == 0 then out:write("\n") end end else for i=1,ngpr do out:write(format(" %08x", regs[i])) if i % 8 == 0 then out:write("\n") end end end if jit.arch == "mips" or jit.arch == "mipsel" then for i=1,nfpr,2 do out:write(format(" %+17.14g", regs[ngpr+i])) if i % 8 == 7 then out:write("\n") end end else for i=1,nfpr do out:write(format(" %+17.14g", regs[ngpr+i])) if i % 4 == 0 then out:write("\n") end end end end end ------------------------------------------------------------------------------ -- Detach dump handlers. local function dumpoff() if active then active = false jit.attach(dump_texit) jit.attach(dump_record) jit.attach(dump_trace) if out and out ~= stdout and out ~= stderr then out:close() end out = nil end end -- Open the output file and attach dump handlers. local function dumpon(opt, outfile) if active then dumpoff() end local colormode = os.getenv("COLORTERM") and "A" or "T" if opt then opt = gsub(opt, "[TAH]", function(mode) colormode = mode; return ""; end) end local m = { t=true, b=true, i=true, m=true, } if opt and opt ~= "" then local o = sub(opt, 1, 1) if o ~= "+" and o ~= "-" then m = {} end for i=1,#opt do m[sub(opt, i, i)] = (o ~= "-") end end dumpmode = m if m.t or m.b or m.i or m.s or m.m then jit.attach(dump_trace, "trace") end if m.b then jit.attach(dump_record, "record") if not bcline then bcline = require("jit.bc").line end end if m.x or m.X then jit.attach(dump_texit, "texit") end if not outfile then outfile = os.getenv("LUAJIT_DUMPFILE") end if outfile then out = outfile == "-" and stdout or assert(io.open(outfile, "w")) else out = stdout end m[colormode] = true if colormode == "A" then colorize = colorize_ansi irtype = irtype_ansi elseif colormode == "H" then colorize = colorize_html irtype = irtype_html out:write(header_html) else colorize = colorize_text irtype = irtype_text end active = true end -- Public module functions. module(...) on = dumpon off = dumpoff start = dumpon -- For -j command line option. ================================================ FILE: cocos2d/external/lua/luajit/src/src/jit/v.lua ================================================ ---------------------------------------------------------------------------- -- Verbose mode of the LuaJIT compiler. -- -- Copyright (C) 2005-2013 Mike Pall. All rights reserved. -- Released under the MIT license. See Copyright Notice in luajit.h ---------------------------------------------------------------------------- -- -- This module shows verbose information about the progress of the -- JIT compiler. It prints one line for each generated trace. This module -- is useful to see which code has been compiled or where the compiler -- punts and falls back to the interpreter. -- -- Example usage: -- -- luajit -jv -e "for i=1,1000 do for j=1,1000 do end end" -- luajit -jv=myapp.out myapp.lua -- -- Default output is to stderr. To redirect the output to a file, pass a -- filename as an argument (use '-' for stdout) or set the environment -- variable LUAJIT_VERBOSEFILE. The file is overwritten every time the -- module is started. -- -- The output from the first example should look like this: -- -- [TRACE 1 (command line):1 loop] -- [TRACE 2 (1/3) (command line):1 -> 1] -- -- The first number in each line is the internal trace number. Next are -- the file name ('(command line)') and the line number (':1') where the -- trace has started. Side traces also show the parent trace number and -- the exit number where they are attached to in parentheses ('(1/3)'). -- An arrow at the end shows where the trace links to ('-> 1'), unless -- it loops to itself. -- -- In this case the inner loop gets hot and is traced first, generating -- a root trace. Then the last exit from the 1st trace gets hot, too, -- and triggers generation of the 2nd trace. The side trace follows the -- path along the outer loop and *around* the inner loop, back to its -- start, and then links to the 1st trace. Yes, this may seem unusual, -- if you know how traditional compilers work. Trace compilers are full -- of surprises like this -- have fun! :-) -- -- Aborted traces are shown like this: -- -- [TRACE --- foo.lua:44 -- leaving loop in root trace at foo:lua:50] -- -- Don't worry -- trace aborts are quite common, even in programs which -- can be fully compiled. The compiler may retry several times until it -- finds a suitable trace. -- -- Of course this doesn't work with features that are not-yet-implemented -- (NYI error messages). The VM simply falls back to the interpreter. This -- may not matter at all if the particular trace is not very high up in -- the CPU usage profile. Oh, and the interpreter is quite fast, too. -- -- Also check out the -jdump module, which prints all the gory details. -- ------------------------------------------------------------------------------ -- Cache some library functions and objects. local jit = require("jit") assert(jit.version_num == 20001, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo local type, format = type, string.format local stdout, stderr = io.stdout, io.stderr -- Active flag and output file handle. local active, out ------------------------------------------------------------------------------ local startloc, startex local function fmtfunc(func, pc) local fi = funcinfo(func, pc) if fi.loc then return fi.loc elseif fi.ffid then return vmdef.ffnames[fi.ffid] elseif fi.addr then return format("C:%x", fi.addr) else return "(?)" end end -- Format trace error message. local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end err = format(vmdef.traceerr[err], info) end return err end -- Dump trace states. local function dump_trace(what, tr, func, pc, otr, oex) if what == "start" then startloc = fmtfunc(func, pc) startex = otr and "("..otr.."/"..oex..") " or "" else if what == "abort" then local loc = fmtfunc(func, pc) if loc ~= startloc then out:write(format("[TRACE --- %s%s -- %s at %s]\n", startex, startloc, fmterr(otr, oex), loc)) else out:write(format("[TRACE --- %s%s -- %s]\n", startex, startloc, fmterr(otr, oex))) end elseif what == "stop" then local info = traceinfo(tr) local link, ltype = info.link, info.linktype if ltype == "interpreter" then out:write(format("[TRACE %3s %s%s -- fallback to interpreter]\n", tr, startex, startloc)) elseif link == tr or link == 0 then out:write(format("[TRACE %3s %s%s %s]\n", tr, startex, startloc, ltype)) elseif ltype == "root" then out:write(format("[TRACE %3s %s%s -> %d]\n", tr, startex, startloc, link)) else out:write(format("[TRACE %3s %s%s -> %d %s]\n", tr, startex, startloc, link, ltype)) end else out:write(format("[TRACE %s]\n", what)) end out:flush() end end ------------------------------------------------------------------------------ -- Detach dump handlers. local function dumpoff() if active then active = false jit.attach(dump_trace) if out and out ~= stdout and out ~= stderr then out:close() end out = nil end end -- Open the output file and attach dump handlers. local function dumpon(outfile) if active then dumpoff() end if not outfile then outfile = os.getenv("LUAJIT_VERBOSEFILE") end if outfile then out = outfile == "-" and stdout or assert(io.open(outfile, "w")) else out = stderr end jit.attach(dump_trace, "trace") active = true end -- Public module functions. module(...) on = dumpon off = dumpoff start = dumpon -- For -j command line option. ================================================ FILE: cocos2d/external/lua/luajit/src/src/lauxlib.h ================================================ /* ** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ #ifndef lauxlib_h #define lauxlib_h #include #include #include "lua.h" #define luaL_getn(L,i) ((int)lua_objlen(L, i)) #define luaL_setn(L,i,j) ((void)0) /* no op! */ /* extra error code for `luaL_load' */ #define LUA_ERRFILE (LUA_ERRERR+1) typedef struct luaL_Reg { const char *name; lua_CFunction func; } luaL_Reg; LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, const luaL_Reg *l, int nup); LUALIB_API void (luaL_register) (lua_State *L, const char *libname, const luaL_Reg *l); LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, size_t *l); LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, const char *def, size_t *l); LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, lua_Integer def); LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); LUALIB_API void (luaL_checkany) (lua_State *L, int narg); LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); LUALIB_API void (luaL_where) (lua_State *L, int lvl); LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, const char *const lst[]); LUALIB_API int (luaL_ref) (lua_State *L, int t); LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, const char *name); LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); LUALIB_API lua_State *(luaL_newstate) (void); LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, const char *r); LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, const char *fname, int szhint); /* From Lua 5.2. */ LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname); LUALIB_API int luaL_execresult(lua_State *L, int stat); LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, const char *mode); LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, const char *name, const char *mode); LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, int level); /* ** =============================================================== ** some useful macros ** =============================================================== */ #define luaL_argcheck(L, cond,numarg,extramsg) \ ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) #define luaL_dofile(L, fn) \ (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) #define luaL_dostring(L, s) \ (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) /* ** {====================================================== ** Generic Buffer manipulation ** ======================================================= */ typedef struct luaL_Buffer { char *p; /* current position in buffer */ int lvl; /* number of strings in the stack (level) */ lua_State *L; char buffer[LUAL_BUFFERSIZE]; } luaL_Buffer; #define luaL_addchar(B,c) \ ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ (*(B)->p++ = (char)(c))) /* compatibility only */ #define luaL_putchar(B,c) luaL_addchar(B,c) #define luaL_addsize(B,n) ((B)->p += (n)) LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); /* }====================================================== */ /* compatibility with ref system */ /* pre-defined references */ #define LUA_NOREF (-2) #define LUA_REFNIL (-1) #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) #define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) #define luaL_reg luaL_Reg #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_aux.c ================================================ /* ** Auxiliary library for the Lua/C API. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major parts taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #include #include #include #define lib_aux_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lj_obj.h" #include "lj_err.h" #include "lj_state.h" #include "lj_trace.h" #include "lj_lib.h" #if LJ_TARGET_POSIX #include #endif /* -- I/O error handling -------------------------------------------------- */ LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname) { if (stat) { setboolV(L->top++, 1); return 1; } else { int en = errno; /* Lua API calls may change this value. */ setnilV(L->top++); if (fname) lua_pushfstring(L, "%s: %s", fname, strerror(en)); else lua_pushfstring(L, "%s", strerror(en)); setintV(L->top++, en); lj_trace_abort(G(L)); return 3; } } LUALIB_API int luaL_execresult(lua_State *L, int stat) { if (stat != -1) { #if LJ_TARGET_POSIX if (WIFSIGNALED(stat)) { stat = WTERMSIG(stat); setnilV(L->top++); lua_pushliteral(L, "signal"); } else { if (WIFEXITED(stat)) stat = WEXITSTATUS(stat); if (stat == 0) setboolV(L->top++, 1); else setnilV(L->top++); lua_pushliteral(L, "exit"); } #else if (stat == 0) setboolV(L->top++, 1); else setnilV(L->top++); lua_pushliteral(L, "exit"); #endif setintV(L->top++, stat); return 3; } return luaL_fileresult(L, 0, NULL); } /* -- Module registration ------------------------------------------------- */ LUALIB_API const char *luaL_findtable(lua_State *L, int idx, const char *fname, int szhint) { const char *e; lua_pushvalue(L, idx); do { e = strchr(fname, '.'); if (e == NULL) e = fname + strlen(fname); lua_pushlstring(L, fname, (size_t)(e - fname)); lua_rawget(L, -2); if (lua_isnil(L, -1)) { /* no such field? */ lua_pop(L, 1); /* remove this nil */ lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ lua_pushlstring(L, fname, (size_t)(e - fname)); lua_pushvalue(L, -2); lua_settable(L, -4); /* set new table into field */ } else if (!lua_istable(L, -1)) { /* field has a non-table value? */ lua_pop(L, 2); /* remove table and value */ return fname; /* return problematic part of the name */ } lua_remove(L, -2); /* remove previous table */ fname = e + 1; } while (*e == '.'); return NULL; } static int libsize(const luaL_Reg *l) { int size = 0; for (; l->name; l++) size++; return size; } LUALIB_API void luaL_openlib(lua_State *L, const char *libname, const luaL_Reg *l, int nup) { lj_lib_checkfpu(L); if (libname) { int size = libsize(l); /* check whether lib already exists */ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); lua_getfield(L, -1, libname); /* get _LOADED[libname] */ if (!lua_istable(L, -1)) { /* not found? */ lua_pop(L, 1); /* remove previous result */ /* try global variable (and create one if it does not exist) */ if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) lj_err_callerv(L, LJ_ERR_BADMODN, libname); lua_pushvalue(L, -1); lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ } lua_remove(L, -2); /* remove _LOADED table */ lua_insert(L, -(nup+1)); /* move library table to below upvalues */ } for (; l->name; l++) { int i; for (i = 0; i < nup; i++) /* copy upvalues to the top */ lua_pushvalue(L, -nup); lua_pushcclosure(L, l->func, nup); lua_setfield(L, -(nup+2), l->name); } lua_pop(L, nup); /* remove upvalues */ } LUALIB_API void luaL_register(lua_State *L, const char *libname, const luaL_Reg *l) { luaL_openlib(L, libname, l, 0); } LUALIB_API const char *luaL_gsub(lua_State *L, const char *s, const char *p, const char *r) { const char *wild; size_t l = strlen(p); luaL_Buffer b; luaL_buffinit(L, &b); while ((wild = strstr(s, p)) != NULL) { luaL_addlstring(&b, s, (size_t)(wild - s)); /* push prefix */ luaL_addstring(&b, r); /* push replacement in place of pattern */ s = wild + l; /* continue after `p' */ } luaL_addstring(&b, s); /* push last suffix */ luaL_pushresult(&b); return lua_tostring(L, -1); } /* -- Buffer handling ----------------------------------------------------- */ #define bufflen(B) ((size_t)((B)->p - (B)->buffer)) #define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) static int emptybuffer(luaL_Buffer *B) { size_t l = bufflen(B); if (l == 0) return 0; /* put nothing on stack */ lua_pushlstring(B->L, B->buffer, l); B->p = B->buffer; B->lvl++; return 1; } static void adjuststack(luaL_Buffer *B) { if (B->lvl > 1) { lua_State *L = B->L; int toget = 1; /* number of levels to concat */ size_t toplen = lua_strlen(L, -1); do { size_t l = lua_strlen(L, -(toget+1)); if (!(B->lvl - toget + 1 >= LUA_MINSTACK/2 || toplen > l)) break; toplen += l; toget++; } while (toget < B->lvl); lua_concat(L, toget); B->lvl = B->lvl - toget + 1; } } LUALIB_API char *luaL_prepbuffer(luaL_Buffer *B) { if (emptybuffer(B)) adjuststack(B); return B->buffer; } LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l) { while (l--) luaL_addchar(B, *s++); } LUALIB_API void luaL_addstring(luaL_Buffer *B, const char *s) { luaL_addlstring(B, s, strlen(s)); } LUALIB_API void luaL_pushresult(luaL_Buffer *B) { emptybuffer(B); lua_concat(B->L, B->lvl); B->lvl = 1; } LUALIB_API void luaL_addvalue(luaL_Buffer *B) { lua_State *L = B->L; size_t vl; const char *s = lua_tolstring(L, -1, &vl); if (vl <= bufffree(B)) { /* fit into buffer? */ memcpy(B->p, s, vl); /* put it there */ B->p += vl; lua_pop(L, 1); /* remove from stack */ } else { if (emptybuffer(B)) lua_insert(L, -2); /* put buffer before new value */ B->lvl++; /* add new value into B stack */ adjuststack(B); } } LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B) { B->L = L; B->p = B->buffer; B->lvl = 0; } /* -- Reference management ------------------------------------------------ */ #define FREELIST_REF 0 /* Convert a stack index to an absolute index. */ #define abs_index(L, i) \ ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : lua_gettop(L) + (i) + 1) LUALIB_API int luaL_ref(lua_State *L, int t) { int ref; t = abs_index(L, t); if (lua_isnil(L, -1)) { lua_pop(L, 1); /* remove from stack */ return LUA_REFNIL; /* `nil' has a unique fixed reference */ } lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ lua_pop(L, 1); /* remove it from stack */ if (ref != 0) { /* any free element? */ lua_rawgeti(L, t, ref); /* remove it from list */ lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ } else { /* no free elements */ ref = (int)lua_objlen(L, t); ref++; /* create new reference */ } lua_rawseti(L, t, ref); return ref; } LUALIB_API void luaL_unref(lua_State *L, int t, int ref) { if (ref >= 0) { t = abs_index(L, t); lua_rawgeti(L, t, FREELIST_REF); lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ lua_pushinteger(L, ref); lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ } } /* -- Default allocator and panic function -------------------------------- */ static int panic(lua_State *L) { const char *s = lua_tostring(L, -1); fputs("PANIC: unprotected error in call to Lua API (", stderr); fputs(s ? s : "?", stderr); fputc(')', stderr); fputc('\n', stderr); fflush(stderr); return 0; } #ifdef LUAJIT_USE_SYSMALLOC #if LJ_64 #error "Must use builtin allocator for 64 bit target" #endif static void *mem_alloc(void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; if (nsize == 0) { free(ptr); return NULL; } else { return realloc(ptr, nsize); } } LUALIB_API lua_State *luaL_newstate(void) { lua_State *L = lua_newstate(mem_alloc, NULL); if (L) G(L)->panic = panic; return L; } #else #include "lj_alloc.h" LUALIB_API lua_State *luaL_newstate(void) { lua_State *L; void *ud = lj_alloc_create(); if (ud == NULL) return NULL; #if LJ_64 L = lj_state_newstate(lj_alloc_f, ud); #else L = lua_newstate(lj_alloc_f, ud); #endif if (L) G(L)->panic = panic; return L; } #if LJ_64 LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) { UNUSED(f); UNUSED(ud); fputs("Must use luaL_newstate() for 64 bit target\n", stderr); return NULL; } #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_base.c ================================================ /* ** Base and coroutine library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #include #define lib_base_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_meta.h" #include "lj_state.h" #if LJ_HASFFI #include "lj_ctype.h" #include "lj_cconv.h" #endif #include "lj_bc.h" #include "lj_ff.h" #include "lj_dispatch.h" #include "lj_char.h" #include "lj_strscan.h" #include "lj_lib.h" /* -- Base library: checks ------------------------------------------------ */ #define LJLIB_MODULE_base LJLIB_ASM(assert) LJLIB_REC(.) { GCstr *s; lj_lib_checkany(L, 1); s = lj_lib_optstr(L, 2); if (s) lj_err_callermsg(L, strdata(s)); else lj_err_caller(L, LJ_ERR_ASSERT); return FFH_UNREACHABLE; } /* ORDER LJ_T */ LJLIB_PUSH("nil") LJLIB_PUSH("boolean") LJLIB_PUSH(top-1) /* boolean */ LJLIB_PUSH("userdata") LJLIB_PUSH("string") LJLIB_PUSH("upval") LJLIB_PUSH("thread") LJLIB_PUSH("proto") LJLIB_PUSH("function") LJLIB_PUSH("trace") LJLIB_PUSH("cdata") LJLIB_PUSH("table") LJLIB_PUSH(top-9) /* userdata */ LJLIB_PUSH("number") LJLIB_ASM_(type) LJLIB_REC(.) /* Recycle the lj_lib_checkany(L, 1) from assert. */ /* -- Base library: iterators --------------------------------------------- */ /* This solves a circular dependency problem -- change FF_next_N as needed. */ LJ_STATIC_ASSERT((int)FF_next == FF_next_N); LJLIB_ASM(next) { lj_lib_checktab(L, 1); return FFH_UNREACHABLE; } #if LJ_52 || LJ_HASFFI static int ffh_pairs(lua_State *L, MMS mm) { TValue *o = lj_lib_checkany(L, 1); cTValue *mo = lj_meta_lookup(L, o, mm); if ((LJ_52 || tviscdata(o)) && !tvisnil(mo)) { L->top = o+1; /* Only keep one argument. */ copyTV(L, L->base-1, mo); /* Replace callable. */ return FFH_TAILCALL; } else { if (!tvistab(o)) lj_err_argt(L, 1, LUA_TTABLE); setfuncV(L, o-1, funcV(lj_lib_upvalue(L, 1))); if (mm == MM_pairs) setnilV(o+1); else setintV(o+1, 0); return FFH_RES(3); } } #else #define ffh_pairs(L, mm) (lj_lib_checktab(L, 1), FFH_UNREACHABLE) #endif LJLIB_PUSH(lastcl) LJLIB_ASM(pairs) { return ffh_pairs(L, MM_pairs); } LJLIB_NOREGUV LJLIB_ASM(ipairs_aux) LJLIB_REC(.) { lj_lib_checktab(L, 1); lj_lib_checkint(L, 2); return FFH_UNREACHABLE; } LJLIB_PUSH(lastcl) LJLIB_ASM(ipairs) LJLIB_REC(.) { return ffh_pairs(L, MM_ipairs); } /* -- Base library: getters and setters ----------------------------------- */ LJLIB_ASM_(getmetatable) LJLIB_REC(.) /* Recycle the lj_lib_checkany(L, 1) from assert. */ LJLIB_ASM(setmetatable) LJLIB_REC(.) { GCtab *t = lj_lib_checktab(L, 1); GCtab *mt = lj_lib_checktabornil(L, 2); if (!tvisnil(lj_meta_lookup(L, L->base, MM_metatable))) lj_err_caller(L, LJ_ERR_PROTMT); setgcref(t->metatable, obj2gco(mt)); if (mt) { lj_gc_objbarriert(L, t, mt); } settabV(L, L->base-1, t); return FFH_RES(1); } LJLIB_CF(getfenv) { GCfunc *fn; cTValue *o = L->base; if (!(o < L->top && tvisfunc(o))) { int level = lj_lib_optint(L, 1, 1); o = lj_debug_frame(L, level, &level); if (o == NULL) lj_err_arg(L, 1, LJ_ERR_INVLVL); } fn = &gcval(o)->fn; settabV(L, L->top++, isluafunc(fn) ? tabref(fn->l.env) : tabref(L->env)); return 1; } LJLIB_CF(setfenv) { GCfunc *fn; GCtab *t = lj_lib_checktab(L, 2); cTValue *o = L->base; if (!(o < L->top && tvisfunc(o))) { int level = lj_lib_checkint(L, 1); if (level == 0) { /* NOBARRIER: A thread (i.e. L) is never black. */ setgcref(L->env, obj2gco(t)); return 0; } o = lj_debug_frame(L, level, &level); if (o == NULL) lj_err_arg(L, 1, LJ_ERR_INVLVL); } fn = &gcval(o)->fn; if (!isluafunc(fn)) lj_err_caller(L, LJ_ERR_SETFENV); setgcref(fn->l.env, obj2gco(t)); lj_gc_objbarrier(L, obj2gco(fn), t); setfuncV(L, L->top++, fn); return 1; } LJLIB_ASM(rawget) LJLIB_REC(.) { lj_lib_checktab(L, 1); lj_lib_checkany(L, 2); return FFH_UNREACHABLE; } LJLIB_CF(rawset) LJLIB_REC(.) { lj_lib_checktab(L, 1); lj_lib_checkany(L, 2); L->top = 1+lj_lib_checkany(L, 3); lua_rawset(L, 1); return 1; } LJLIB_CF(rawequal) LJLIB_REC(.) { cTValue *o1 = lj_lib_checkany(L, 1); cTValue *o2 = lj_lib_checkany(L, 2); setboolV(L->top-1, lj_obj_equal(o1, o2)); return 1; } #if LJ_52 LJLIB_CF(rawlen) LJLIB_REC(.) { cTValue *o = L->base; int32_t len; if (L->top > o && tvisstr(o)) len = (int32_t)strV(o)->len; else len = (int32_t)lj_tab_len(lj_lib_checktab(L, 1)); setintV(L->top-1, len); return 1; } #endif LJLIB_CF(unpack) { GCtab *t = lj_lib_checktab(L, 1); int32_t n, i = lj_lib_optint(L, 2, 1); int32_t e = (L->base+3-1 < L->top && !tvisnil(L->base+3-1)) ? lj_lib_checkint(L, 3) : (int32_t)lj_tab_len(t); if (i > e) return 0; n = e - i + 1; if (n <= 0 || !lua_checkstack(L, n)) lj_err_caller(L, LJ_ERR_UNPACK); do { cTValue *tv = lj_tab_getint(t, i); if (tv) { copyTV(L, L->top++, tv); } else { setnilV(L->top++); } } while (i++ < e); return n; } LJLIB_CF(select) LJLIB_REC(.) { int32_t n = (int32_t)(L->top - L->base); if (n >= 1 && tvisstr(L->base) && *strVdata(L->base) == '#') { setintV(L->top-1, n-1); return 1; } else { int32_t i = lj_lib_checkint(L, 1); if (i < 0) i = n + i; else if (i > n) i = n; if (i < 1) lj_err_arg(L, 1, LJ_ERR_IDXRNG); return n - i; } } /* -- Base library: conversions ------------------------------------------- */ LJLIB_ASM(tonumber) LJLIB_REC(.) { int32_t base = lj_lib_optint(L, 2, 10); if (base == 10) { TValue *o = lj_lib_checkany(L, 1); if (lj_strscan_numberobj(o)) { copyTV(L, L->base-1, o); return FFH_RES(1); } #if LJ_HASFFI if (tviscdata(o)) { CTState *cts = ctype_cts(L); CType *ct = lj_ctype_rawref(cts, cdataV(o)->ctypeid); if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) { if (LJ_DUALNUM && ctype_isinteger_or_bool(ct->info) && ct->size <= 4 && !(ct->size == 4 && (ct->info & CTF_UNSIGNED))) { int32_t i; lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, 0); setintV(L->base-1, i); return FFH_RES(1); } lj_cconv_ct_tv(cts, ctype_get(cts, CTID_DOUBLE), (uint8_t *)&(L->base-1)->n, o, 0); return FFH_RES(1); } } #endif } else { const char *p = strdata(lj_lib_checkstr(L, 1)); char *ep; unsigned long ul; if (base < 2 || base > 36) lj_err_arg(L, 2, LJ_ERR_BASERNG); ul = strtoul(p, &ep, base); if (p != ep) { while (lj_char_isspace((unsigned char)(*ep))) ep++; if (*ep == '\0') { if (LJ_DUALNUM && LJ_LIKELY(ul < 0x80000000u)) setintV(L->base-1, (int32_t)ul); else setnumV(L->base-1, (lua_Number)ul); return FFH_RES(1); } } } setnilV(L->base-1); return FFH_RES(1); } LJLIB_PUSH("nil") LJLIB_PUSH("false") LJLIB_PUSH("true") LJLIB_ASM(tostring) LJLIB_REC(.) { TValue *o = lj_lib_checkany(L, 1); cTValue *mo; L->top = o+1; /* Only keep one argument. */ if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { copyTV(L, L->base-1, mo); /* Replace callable. */ return FFH_TAILCALL; } else { GCstr *s; if (tvisnumber(o)) { s = lj_str_fromnumber(L, o); } else if (tvispri(o)) { s = strV(lj_lib_upvalue(L, -(int32_t)itype(o))); } else { if (tvisfunc(o) && isffunc(funcV(o))) lua_pushfstring(L, "function: builtin#%d", funcV(o)->c.ffid); else lua_pushfstring(L, "%s: %p", lj_typename(o), lua_topointer(L, 1)); /* Note: lua_pushfstring calls the GC which may invalidate o. */ s = strV(L->top-1); } setstrV(L, L->base-1, s); return FFH_RES(1); } } /* -- Base library: throw and catch errors -------------------------------- */ LJLIB_CF(error) { int32_t level = lj_lib_optint(L, 2, 1); lua_settop(L, 1); if (lua_isstring(L, 1) && level > 0) { luaL_where(L, level); lua_pushvalue(L, 1); lua_concat(L, 2); } return lua_error(L); } LJLIB_ASM(pcall) LJLIB_REC(.) { lj_lib_checkany(L, 1); lj_lib_checkfunc(L, 2); /* For xpcall only. */ return FFH_UNREACHABLE; } LJLIB_ASM_(xpcall) LJLIB_REC(.) /* -- Base library: load Lua code ----------------------------------------- */ static int load_aux(lua_State *L, int status, int envarg) { if (status == 0) { if (tvistab(L->base+envarg-1)) { GCfunc *fn = funcV(L->top-1); GCtab *t = tabV(L->base+envarg-1); setgcref(fn->c.env, obj2gco(t)); lj_gc_objbarrier(L, fn, t); } return 1; } else { setnilV(L->top-2); return 2; } } LJLIB_CF(loadfile) { GCstr *fname = lj_lib_optstr(L, 1); GCstr *mode = lj_lib_optstr(L, 2); int status; lua_settop(L, 3); /* Ensure env arg exists. */ status = luaL_loadfilex(L, fname ? strdata(fname) : NULL, mode ? strdata(mode) : NULL); return load_aux(L, status, 3); } static const char *reader_func(lua_State *L, void *ud, size_t *size) { UNUSED(ud); luaL_checkstack(L, 2, "too many nested functions"); copyTV(L, L->top++, L->base); lua_call(L, 0, 1); /* Call user-supplied function. */ L->top--; if (tvisnil(L->top)) { *size = 0; return NULL; } else if (tvisstr(L->top) || tvisnumber(L->top)) { copyTV(L, L->base+4, L->top); /* Anchor string in reserved stack slot. */ return lua_tolstring(L, 5, size); } else { lj_err_caller(L, LJ_ERR_RDRSTR); return NULL; } } LJLIB_CF(load) { GCstr *name = lj_lib_optstr(L, 2); GCstr *mode = lj_lib_optstr(L, 3); int status; if (L->base < L->top && (tvisstr(L->base) || tvisnumber(L->base))) { GCstr *s = lj_lib_checkstr(L, 1); lua_settop(L, 4); /* Ensure env arg exists. */ status = luaL_loadbufferx(L, strdata(s), s->len, strdata(name ? name : s), mode ? strdata(mode) : NULL); } else { lj_lib_checkfunc(L, 1); lua_settop(L, 5); /* Reserve a slot for the string from the reader. */ status = lua_loadx(L, reader_func, NULL, name ? strdata(name) : "=(load)", mode ? strdata(mode) : NULL); } return load_aux(L, status, 4); } LJLIB_CF(loadstring) { return lj_cf_load(L); } LJLIB_CF(dofile) { GCstr *fname = lj_lib_optstr(L, 1); setnilV(L->top); L->top = L->base+1; if (luaL_loadfile(L, fname ? strdata(fname) : NULL) != 0) lua_error(L); lua_call(L, 0, LUA_MULTRET); return (int)(L->top - L->base) - 1; } /* -- Base library: GC control -------------------------------------------- */ LJLIB_CF(gcinfo) { setintV(L->top++, (G(L)->gc.total >> 10)); return 1; } LJLIB_CF(collectgarbage) { int opt = lj_lib_checkopt(L, 1, LUA_GCCOLLECT, /* ORDER LUA_GC* */ "\4stop\7restart\7collect\5count\1\377\4step\10setpause\12setstepmul"); int32_t data = lj_lib_optint(L, 2, 0); if (opt == LUA_GCCOUNT) { setnumV(L->top, (lua_Number)G(L)->gc.total/1024.0); } else { int res = lua_gc(L, opt, data); if (opt == LUA_GCSTEP) setboolV(L->top, res); else setintV(L->top, res); } L->top++; return 1; } /* -- Base library: miscellaneous functions ------------------------------- */ LJLIB_PUSH(top-2) /* Upvalue holds weak table. */ LJLIB_CF(newproxy) { lua_settop(L, 1); lua_newuserdata(L, 0); if (lua_toboolean(L, 1) == 0) { /* newproxy(): without metatable. */ return 1; } else if (lua_isboolean(L, 1)) { /* newproxy(true): with metatable. */ lua_newtable(L); lua_pushvalue(L, -1); lua_pushboolean(L, 1); lua_rawset(L, lua_upvalueindex(1)); /* Remember mt in weak table. */ } else { /* newproxy(proxy): inherit metatable. */ int validproxy = 0; if (lua_getmetatable(L, 1)) { lua_rawget(L, lua_upvalueindex(1)); validproxy = lua_toboolean(L, -1); lua_pop(L, 1); } if (!validproxy) lj_err_arg(L, 1, LJ_ERR_NOPROXY); lua_getmetatable(L, 1); } lua_setmetatable(L, 2); return 1; } LJLIB_PUSH("tostring") LJLIB_CF(print) { ptrdiff_t i, nargs = L->top - L->base; cTValue *tv = lj_tab_getstr(tabref(L->env), strV(lj_lib_upvalue(L, 1))); int shortcut; if (tv && !tvisnil(tv)) { copyTV(L, L->top++, tv); } else { setstrV(L, L->top++, strV(lj_lib_upvalue(L, 1))); lua_gettable(L, LUA_GLOBALSINDEX); tv = L->top-1; } shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring); for (i = 0; i < nargs; i++) { const char *str; size_t size; cTValue *o = &L->base[i]; if (shortcut && tvisstr(o)) { str = strVdata(o); size = strV(o)->len; } else if (shortcut && tvisint(o)) { char buf[LJ_STR_INTBUF]; char *p = lj_str_bufint(buf, intV(o)); size = (size_t)(buf+LJ_STR_INTBUF-p); str = p; } else if (shortcut && tvisnum(o)) { char buf[LJ_STR_NUMBUF]; size = lj_str_bufnum(buf, o); str = buf; } else { copyTV(L, L->top+1, o); copyTV(L, L->top, L->top-1); L->top += 2; lua_call(L, 1, 1); str = lua_tolstring(L, -1, &size); if (!str) lj_err_caller(L, LJ_ERR_PRTOSTR); L->top--; } if (i) putchar('\t'); fwrite(str, 1, size, stdout); } putchar('\n'); return 0; } LJLIB_PUSH(top-3) LJLIB_SET(_VERSION) #include "lj_libdef.h" /* -- Coroutine library --------------------------------------------------- */ #define LJLIB_MODULE_coroutine LJLIB_CF(coroutine_status) { const char *s; lua_State *co; if (!(L->top > L->base && tvisthread(L->base))) lj_err_arg(L, 1, LJ_ERR_NOCORO); co = threadV(L->base); if (co == L) s = "running"; else if (co->status == LUA_YIELD) s = "suspended"; else if (co->status != 0) s = "dead"; else if (co->base > tvref(co->stack)+1) s = "normal"; else if (co->top == co->base) s = "dead"; else s = "suspended"; lua_pushstring(L, s); return 1; } LJLIB_CF(coroutine_running) { #if LJ_52 int ismain = lua_pushthread(L); setboolV(L->top++, ismain); return 2; #else if (lua_pushthread(L)) setnilV(L->top++); return 1; #endif } LJLIB_CF(coroutine_create) { lua_State *L1; if (!(L->base < L->top && tvisfunc(L->base))) lj_err_argt(L, 1, LUA_TFUNCTION); L1 = lua_newthread(L); setfuncV(L, L1->top++, funcV(L->base)); return 1; } LJLIB_ASM(coroutine_yield) { lj_err_caller(L, LJ_ERR_CYIELD); return FFH_UNREACHABLE; } static int ffh_resume(lua_State *L, lua_State *co, int wrap) { if (co->cframe != NULL || co->status > LUA_YIELD || (co->status == 0 && co->top == co->base)) { ErrMsg em = co->cframe ? LJ_ERR_CORUN : LJ_ERR_CODEAD; if (wrap) lj_err_caller(L, em); setboolV(L->base-1, 0); setstrV(L, L->base, lj_err_str(L, em)); return FFH_RES(2); } lj_state_growstack(co, (MSize)(L->top - L->base)); return FFH_RETRY; } LJLIB_ASM(coroutine_resume) { if (!(L->top > L->base && tvisthread(L->base))) lj_err_arg(L, 1, LJ_ERR_NOCORO); return ffh_resume(L, threadV(L->base), 0); } LJLIB_NOREG LJLIB_ASM(coroutine_wrap_aux) { return ffh_resume(L, threadV(lj_lib_upvalue(L, 1)), 1); } /* Inline declarations. */ LJ_ASMF void lj_ff_coroutine_wrap_aux(void); #if !(LJ_TARGET_MIPS && defined(ljamalg_c)) LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co); #endif /* Error handler, called from assembler VM. */ void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co) { co->top--; copyTV(L, L->top, co->top); L->top++; if (tvisstr(L->top-1)) lj_err_callermsg(L, strVdata(L->top-1)); else lj_err_run(L); } /* Forward declaration. */ static void setpc_wrap_aux(lua_State *L, GCfunc *fn); LJLIB_CF(coroutine_wrap) { lj_cf_coroutine_create(L); lj_lib_pushcc(L, lj_ffh_coroutine_wrap_aux, FF_coroutine_wrap_aux, 1); setpc_wrap_aux(L, funcV(L->top-1)); return 1; } #include "lj_libdef.h" /* Fix the PC of wrap_aux. Really ugly workaround. */ static void setpc_wrap_aux(lua_State *L, GCfunc *fn) { setmref(fn->c.pc, &L2GG(L)->bcff[lj_lib_init_coroutine[1]+2]); } /* ------------------------------------------------------------------------ */ static void newproxy_weaktable(lua_State *L) { /* NOBARRIER: The table is new (marked white). */ GCtab *t = lj_tab_new(L, 0, 1); settabV(L, L->top++, t); setgcref(t->metatable, obj2gco(t)); setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), lj_str_newlit(L, "kv")); t->nomm = (uint8_t)(~(1u<env); settabV(L, lj_tab_setstr(L, env, lj_str_newlit(L, "_G")), env); lua_pushliteral(L, LUA_VERSION); /* top-3. */ newproxy_weaktable(L); /* top-2. */ LJ_LIB_REG(L, "_G", base); LJ_LIB_REG(L, LUA_COLIBNAME, coroutine); return 2; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_bit.c ================================================ /* ** Bit manipulation library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lib_bit_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #include "lj_err.h" #include "lj_str.h" #include "lj_lib.h" /* ------------------------------------------------------------------------ */ #define LJLIB_MODULE_bit LJLIB_ASM(bit_tobit) LJLIB_REC(bit_unary IR_TOBIT) { lj_lib_checknumber(L, 1); return FFH_RETRY; } LJLIB_ASM_(bit_bnot) LJLIB_REC(bit_unary IR_BNOT) LJLIB_ASM_(bit_bswap) LJLIB_REC(bit_unary IR_BSWAP) LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL) { lj_lib_checknumber(L, 1); lj_lib_checkbit(L, 2); return FFH_RETRY; } LJLIB_ASM_(bit_rshift) LJLIB_REC(bit_shift IR_BSHR) LJLIB_ASM_(bit_arshift) LJLIB_REC(bit_shift IR_BSAR) LJLIB_ASM_(bit_rol) LJLIB_REC(bit_shift IR_BROL) LJLIB_ASM_(bit_ror) LJLIB_REC(bit_shift IR_BROR) LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND) { int i = 0; do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); return FFH_RETRY; } LJLIB_ASM_(bit_bor) LJLIB_REC(bit_nary IR_BOR) LJLIB_ASM_(bit_bxor) LJLIB_REC(bit_nary IR_BXOR) /* ------------------------------------------------------------------------ */ LJLIB_CF(bit_tohex) { uint32_t b = (uint32_t)lj_lib_checkbit(L, 1); int32_t i, n = L->base+1 >= L->top ? 8 : lj_lib_checkbit(L, 2); const char *hexdigits = "0123456789abcdef"; char buf[8]; if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; } if (n > 8) n = 8; for (i = n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; } lua_pushlstring(L, buf, (size_t)n); return 1; } /* ------------------------------------------------------------------------ */ #include "lj_libdef.h" LUALIB_API int luaopen_bit(lua_State *L) { LJ_LIB_REG(L, LUA_BITLIBNAME, bit); return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_debug.c ================================================ /* ** Debug library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lib_debug_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_lib.h" /* ------------------------------------------------------------------------ */ #define LJLIB_MODULE_debug LJLIB_CF(debug_getregistry) { copyTV(L, L->top++, registry(L)); return 1; } LJLIB_CF(debug_getmetatable) { lj_lib_checkany(L, 1); if (!lua_getmetatable(L, 1)) { setnilV(L->top-1); } return 1; } LJLIB_CF(debug_setmetatable) { lj_lib_checktabornil(L, 2); L->top = L->base+2; lua_setmetatable(L, 1); #if !LJ_52 setboolV(L->top-1, 1); #endif return 1; } LJLIB_CF(debug_getfenv) { lj_lib_checkany(L, 1); lua_getfenv(L, 1); return 1; } LJLIB_CF(debug_setfenv) { lj_lib_checktab(L, 2); L->top = L->base+2; if (!lua_setfenv(L, 1)) lj_err_caller(L, LJ_ERR_SETFENV); return 1; } /* ------------------------------------------------------------------------ */ static void settabss(lua_State *L, const char *i, const char *v) { lua_pushstring(L, v); lua_setfield(L, -2, i); } static void settabsi(lua_State *L, const char *i, int v) { lua_pushinteger(L, v); lua_setfield(L, -2, i); } static void settabsb(lua_State *L, const char *i, int v) { lua_pushboolean(L, v); lua_setfield(L, -2, i); } static lua_State *getthread(lua_State *L, int *arg) { if (L->base < L->top && tvisthread(L->base)) { *arg = 1; return threadV(L->base); } else { *arg = 0; return L; } } static void treatstackoption(lua_State *L, lua_State *L1, const char *fname) { if (L == L1) { lua_pushvalue(L, -2); lua_remove(L, -3); } else lua_xmove(L1, L, 1); lua_setfield(L, -2, fname); } LJLIB_CF(debug_getinfo) { lj_Debug ar; int arg, opt_f = 0, opt_L = 0; lua_State *L1 = getthread(L, &arg); const char *options = luaL_optstring(L, arg+2, "flnSu"); if (lua_isnumber(L, arg+1)) { if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), (lua_Debug *)&ar)) { setnilV(L->top-1); return 1; } } else if (L->base+arg < L->top && tvisfunc(L->base+arg)) { options = lua_pushfstring(L, ">%s", options); setfuncV(L1, L1->top++, funcV(L->base+arg)); } else { lj_err_arg(L, arg+1, LJ_ERR_NOFUNCL); } if (!lj_debug_getinfo(L1, options, &ar, 1)) lj_err_arg(L, arg+2, LJ_ERR_INVOPT); lua_createtable(L, 0, 16); /* Create result table. */ for (; *options; options++) { switch (*options) { case 'S': settabss(L, "source", ar.source); settabss(L, "short_src", ar.short_src); settabsi(L, "linedefined", ar.linedefined); settabsi(L, "lastlinedefined", ar.lastlinedefined); settabss(L, "what", ar.what); break; case 'l': settabsi(L, "currentline", ar.currentline); break; case 'u': settabsi(L, "nups", ar.nups); settabsi(L, "nparams", ar.nparams); settabsb(L, "isvararg", ar.isvararg); break; case 'n': settabss(L, "name", ar.name); settabss(L, "namewhat", ar.namewhat); break; case 'f': opt_f = 1; break; case 'L': opt_L = 1; break; default: break; } } if (opt_L) treatstackoption(L, L1, "activelines"); if (opt_f) treatstackoption(L, L1, "func"); return 1; /* Return result table. */ } LJLIB_CF(debug_getlocal) { int arg; lua_State *L1 = getthread(L, &arg); lua_Debug ar; const char *name; int slot = lj_lib_checkint(L, arg+2); if (tvisfunc(L->base+arg)) { L->top = L->base+arg+1; lua_pushstring(L, lua_getlocal(L, NULL, slot)); return 1; } if (!lua_getstack(L1, lj_lib_checkint(L, arg+1), &ar)) lj_err_arg(L, arg+1, LJ_ERR_LVLRNG); name = lua_getlocal(L1, &ar, slot); if (name) { lua_xmove(L1, L, 1); lua_pushstring(L, name); lua_pushvalue(L, -2); return 2; } else { setnilV(L->top-1); return 1; } } LJLIB_CF(debug_setlocal) { int arg; lua_State *L1 = getthread(L, &arg); lua_Debug ar; TValue *tv; if (!lua_getstack(L1, lj_lib_checkint(L, arg+1), &ar)) lj_err_arg(L, arg+1, LJ_ERR_LVLRNG); tv = lj_lib_checkany(L, arg+3); copyTV(L1, L1->top++, tv); lua_pushstring(L, lua_setlocal(L1, &ar, lj_lib_checkint(L, arg+2))); return 1; } static int debug_getupvalue(lua_State *L, int get) { int32_t n = lj_lib_checkint(L, 2); const char *name; lj_lib_checkfunc(L, 1); name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); if (name) { lua_pushstring(L, name); if (!get) return 1; copyTV(L, L->top, L->top-2); L->top++; return 2; } return 0; } LJLIB_CF(debug_getupvalue) { return debug_getupvalue(L, 1); } LJLIB_CF(debug_setupvalue) { lj_lib_checkany(L, 3); return debug_getupvalue(L, 0); } LJLIB_CF(debug_upvalueid) { GCfunc *fn = lj_lib_checkfunc(L, 1); int32_t n = lj_lib_checkint(L, 2) - 1; if ((uint32_t)n >= fn->l.nupvalues) lj_err_arg(L, 2, LJ_ERR_IDXRNG); setlightudV(L->top-1, isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : (void *)&fn->c.upvalue[n]); return 1; } LJLIB_CF(debug_upvaluejoin) { GCfunc *fn[2]; GCRef *p[2]; int i; for (i = 0; i < 2; i++) { int32_t n; fn[i] = lj_lib_checkfunc(L, 2*i+1); if (!isluafunc(fn[i])) lj_err_arg(L, 2*i+1, LJ_ERR_NOLFUNC); n = lj_lib_checkint(L, 2*i+2) - 1; if ((uint32_t)n >= fn[i]->l.nupvalues) lj_err_arg(L, 2*i+2, LJ_ERR_IDXRNG); p[i] = &fn[i]->l.uvptr[n]; } setgcrefr(*p[0], *p[1]); lj_gc_objbarrier(L, fn[0], gcref(*p[1])); return 0; } #if LJ_52 LJLIB_CF(debug_getuservalue) { TValue *o = L->base; if (o < L->top && tvisudata(o)) settabV(L, o, tabref(udataV(o)->env)); else setnilV(o); L->top = o+1; return 1; } LJLIB_CF(debug_setuservalue) { TValue *o = L->base; if (!(o < L->top && tvisudata(o))) lj_err_argt(L, 1, LUA_TUSERDATA); if (!(o+1 < L->top && tvistab(o+1))) lj_err_argt(L, 2, LUA_TTABLE); L->top = o+2; lua_setfenv(L, 1); return 1; } #endif /* ------------------------------------------------------------------------ */ static const char KEY_HOOK = 'h'; static void hookf(lua_State *L, lua_Debug *ar) { static const char *const hooknames[] = {"call", "return", "line", "count", "tail return"}; lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_isfunction(L, -1)) { lua_pushstring(L, hooknames[(int)ar->event]); if (ar->currentline >= 0) lua_pushinteger(L, ar->currentline); else lua_pushnil(L); lua_call(L, 2, 0); } } static int makemask(const char *smask, int count) { int mask = 0; if (strchr(smask, 'c')) mask |= LUA_MASKCALL; if (strchr(smask, 'r')) mask |= LUA_MASKRET; if (strchr(smask, 'l')) mask |= LUA_MASKLINE; if (count > 0) mask |= LUA_MASKCOUNT; return mask; } static char *unmakemask(int mask, char *smask) { int i = 0; if (mask & LUA_MASKCALL) smask[i++] = 'c'; if (mask & LUA_MASKRET) smask[i++] = 'r'; if (mask & LUA_MASKLINE) smask[i++] = 'l'; smask[i] = '\0'; return smask; } LJLIB_CF(debug_sethook) { int arg, mask, count; lua_Hook func; (void)getthread(L, &arg); if (lua_isnoneornil(L, arg+1)) { lua_settop(L, arg+1); func = NULL; mask = 0; count = 0; /* turn off hooks */ } else { const char *smask = luaL_checkstring(L, arg+2); luaL_checktype(L, arg+1, LUA_TFUNCTION); count = luaL_optint(L, arg+3, 0); func = hookf; mask = makemask(smask, count); } lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_pushvalue(L, arg+1); lua_rawset(L, LUA_REGISTRYINDEX); lua_sethook(L, func, mask, count); return 0; } LJLIB_CF(debug_gethook) { char buff[5]; int mask = lua_gethookmask(L); lua_Hook hook = lua_gethook(L); if (hook != NULL && hook != hookf) { /* external hook? */ lua_pushliteral(L, "external hook"); } else { lua_pushlightuserdata(L, (void *)&KEY_HOOK); lua_rawget(L, LUA_REGISTRYINDEX); /* get hook */ } lua_pushstring(L, unmakemask(mask, buff)); lua_pushinteger(L, lua_gethookcount(L)); return 3; } /* ------------------------------------------------------------------------ */ LJLIB_CF(debug_debug) { for (;;) { char buffer[250]; fputs("lua_debug> ", stderr); if (fgets(buffer, sizeof(buffer), stdin) == 0 || strcmp(buffer, "cont\n") == 0) return 0; if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || lua_pcall(L, 0, 0, 0)) { fputs(lua_tostring(L, -1), stderr); fputs("\n", stderr); } lua_settop(L, 0); /* remove eventual returns */ } } /* ------------------------------------------------------------------------ */ #define LEVELS1 12 /* size of the first part of the stack */ #define LEVELS2 10 /* size of the second part of the stack */ LJLIB_CF(debug_traceback) { int arg; lua_State *L1 = getthread(L, &arg); const char *msg = lua_tostring(L, arg+1); if (msg == NULL && L->top > L->base+arg) L->top = L->base+arg+1; else luaL_traceback(L, L1, msg, lj_lib_optint(L, arg+2, (L == L1))); return 1; } /* ------------------------------------------------------------------------ */ #include "lj_libdef.h" LUALIB_API int luaopen_debug(lua_State *L) { LJ_LIB_REG(L, LUA_DBLIBNAME, debug); return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_ffi.c ================================================ /* ** FFI library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lib_ffi_c #define LUA_LIB #include #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #if LJ_HASFFI #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_meta.h" #include "lj_ctype.h" #include "lj_cparse.h" #include "lj_cdata.h" #include "lj_cconv.h" #include "lj_carith.h" #include "lj_ccall.h" #include "lj_ccallback.h" #include "lj_clib.h" #include "lj_ff.h" #include "lj_lib.h" /* -- C type checks ------------------------------------------------------- */ /* Check first argument for a C type and returns its ID. */ static CTypeID ffi_checkctype(lua_State *L, CTState *cts, TValue *param) { TValue *o = L->base; if (!(o < L->top)) { err_argtype: lj_err_argtype(L, 1, "C type"); } if (tvisstr(o)) { /* Parse an abstract C type declaration. */ GCstr *s = strV(o); CPState cp; int errcode; cp.L = L; cp.cts = cts; cp.srcname = strdata(s); cp.p = strdata(s); cp.param = param; cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT; errcode = lj_cparse(&cp); if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ return cp.val.id; } else { GCcdata *cd; if (!tviscdata(o)) goto err_argtype; if (param && param < L->top) lj_err_arg(L, 1, LJ_ERR_FFI_NUMPARAM); cd = cdataV(o); return cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : cd->ctypeid; } } /* Check argument for C data and return it. */ static GCcdata *ffi_checkcdata(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (!(o < L->top && tviscdata(o))) lj_err_argt(L, narg, LUA_TCDATA); return cdataV(o); } /* Convert argument to C pointer. */ static void *ffi_checkptr(lua_State *L, int narg, CTypeID id) { CTState *cts = ctype_cts(L); TValue *o = L->base + narg-1; void *p; if (o >= L->top) lj_err_arg(L, narg, LJ_ERR_NOVAL); lj_cconv_ct_tv(cts, ctype_get(cts, id), (uint8_t *)&p, o, CCF_ARG(narg)); return p; } /* Convert argument to int32_t. */ static int32_t ffi_checkint(lua_State *L, int narg) { CTState *cts = ctype_cts(L); TValue *o = L->base + narg-1; int32_t i; if (o >= L->top) lj_err_arg(L, narg, LJ_ERR_NOVAL); lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, CCF_ARG(narg)); return i; } /* -- C type metamethods -------------------------------------------------- */ #define LJLIB_MODULE_ffi_meta /* Handle ctype __index/__newindex metamethods. */ static int ffi_index_meta(lua_State *L, CTState *cts, CType *ct, MMS mm) { CTypeID id = ctype_typeid(cts, ct); cTValue *tv = lj_ctype_meta(cts, id, mm); TValue *base = L->base; if (!tv) { const char *s; err_index: s = strdata(lj_ctype_repr(L, id, NULL)); if (tvisstr(L->base+1)) { lj_err_callerv(L, LJ_ERR_FFI_BADMEMBER, s, strVdata(L->base+1)); } else { const char *key = tviscdata(L->base+1) ? strdata(lj_ctype_repr(L, cdataV(L->base+1)->ctypeid, NULL)) : lj_typename(L->base+1); lj_err_callerv(L, LJ_ERR_FFI_BADIDXW, s, key); } } if (!tvisfunc(tv)) { if (mm == MM_index) { cTValue *o = lj_meta_tget(L, tv, base+1); if (o) { if (tvisnil(o)) goto err_index; copyTV(L, L->top-1, o); return 1; } } else { TValue *o = lj_meta_tset(L, tv, base+1); if (o) { copyTV(L, o, base+2); return 0; } } tv = L->top-1; } return lj_meta_tailcall(L, tv); } LJLIB_CF(ffi_meta___index) LJLIB_REC(cdata_index 0) { CTState *cts = ctype_cts(L); CTInfo qual = 0; CType *ct; uint8_t *p; TValue *o = L->base; if (!(o+1 < L->top && tviscdata(o))) /* Also checks for presence of key. */ lj_err_argt(L, 1, LUA_TCDATA); ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); if ((qual & 1)) return ffi_index_meta(L, cts, ct, MM_index); if (lj_cdata_get(cts, ct, L->top-1, p)) lj_gc_check(L); return 1; } LJLIB_CF(ffi_meta___newindex) LJLIB_REC(cdata_index 1) { CTState *cts = ctype_cts(L); CTInfo qual = 0; CType *ct; uint8_t *p; TValue *o = L->base; if (!(o+2 < L->top && tviscdata(o))) /* Also checks for key and value. */ lj_err_argt(L, 1, LUA_TCDATA); ct = lj_cdata_index(cts, cdataV(o), o+1, &p, &qual); if ((qual & 1)) { if ((qual & CTF_CONST)) lj_err_caller(L, LJ_ERR_FFI_WRCONST); return ffi_index_meta(L, cts, ct, MM_newindex); } lj_cdata_set(cts, ct, p, o+2, qual); return 0; } /* Common handler for cdata arithmetic. */ static int ffi_arith(lua_State *L) { MMS mm = (MMS)(curr_func(L)->c.ffid - (int)FF_ffi_meta___eq + (int)MM_eq); return lj_carith_op(L, mm); } /* The following functions must be in contiguous ORDER MM. */ LJLIB_CF(ffi_meta___eq) LJLIB_REC(cdata_arith MM_eq) { return ffi_arith(L); } LJLIB_CF(ffi_meta___len) LJLIB_REC(cdata_arith MM_len) { return ffi_arith(L); } LJLIB_CF(ffi_meta___lt) LJLIB_REC(cdata_arith MM_lt) { return ffi_arith(L); } LJLIB_CF(ffi_meta___le) LJLIB_REC(cdata_arith MM_le) { return ffi_arith(L); } LJLIB_CF(ffi_meta___concat) LJLIB_REC(cdata_arith MM_concat) { return ffi_arith(L); } /* Forward declaration. */ static int lj_cf_ffi_new(lua_State *L); LJLIB_CF(ffi_meta___call) LJLIB_REC(cdata_call) { CTState *cts = ctype_cts(L); GCcdata *cd = ffi_checkcdata(L, 1); CTypeID id = cd->ctypeid; CType *ct; cTValue *tv; MMS mm = MM_call; if (cd->ctypeid == CTID_CTYPEID) { id = *(CTypeID *)cdataptr(cd); mm = MM_new; } else { int ret = lj_ccall_func(L, cd); if (ret >= 0) return ret; } /* Handle ctype __call/__new metamethod. */ ct = ctype_raw(cts, id); if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); tv = lj_ctype_meta(cts, id, mm); if (tv) return lj_meta_tailcall(L, tv); else if (mm == MM_call) lj_err_callerv(L, LJ_ERR_FFI_BADCALL, strdata(lj_ctype_repr(L, id, NULL))); return lj_cf_ffi_new(L); } LJLIB_CF(ffi_meta___add) LJLIB_REC(cdata_arith MM_add) { return ffi_arith(L); } LJLIB_CF(ffi_meta___sub) LJLIB_REC(cdata_arith MM_sub) { return ffi_arith(L); } LJLIB_CF(ffi_meta___mul) LJLIB_REC(cdata_arith MM_mul) { return ffi_arith(L); } LJLIB_CF(ffi_meta___div) LJLIB_REC(cdata_arith MM_div) { return ffi_arith(L); } LJLIB_CF(ffi_meta___mod) LJLIB_REC(cdata_arith MM_mod) { return ffi_arith(L); } LJLIB_CF(ffi_meta___pow) LJLIB_REC(cdata_arith MM_pow) { return ffi_arith(L); } LJLIB_CF(ffi_meta___unm) LJLIB_REC(cdata_arith MM_unm) { return ffi_arith(L); } /* End of contiguous ORDER MM. */ LJLIB_CF(ffi_meta___tostring) { GCcdata *cd = ffi_checkcdata(L, 1); const char *msg = "cdata<%s>: %p"; CTypeID id = cd->ctypeid; void *p = cdataptr(cd); if (id == CTID_CTYPEID) { msg = "ctype<%s>"; id = *(CTypeID *)p; } else { CTState *cts = ctype_cts(L); CType *ct = ctype_raw(cts, id); if (ctype_isref(ct->info)) { p = *(void **)p; ct = ctype_rawchild(cts, ct); } if (ctype_iscomplex(ct->info)) { setstrV(L, L->top-1, lj_ctype_repr_complex(L, cdataptr(cd), ct->size)); goto checkgc; } else if (ct->size == 8 && ctype_isinteger(ct->info)) { setstrV(L, L->top-1, lj_ctype_repr_int64(L, *(uint64_t *)cdataptr(cd), (ct->info & CTF_UNSIGNED))); goto checkgc; } else if (ctype_isfunc(ct->info)) { p = *(void **)p; } else if (ctype_isenum(ct->info)) { msg = "cdata<%s>: %d"; p = (void *)(uintptr_t)*(uint32_t **)p; } else { if (ctype_isptr(ct->info)) { p = cdata_getptr(p, ct->size); ct = ctype_rawchild(cts, ct); } if (ctype_isstruct(ct->info) || ctype_isvector(ct->info)) { /* Handle ctype __tostring metamethod. */ cTValue *tv = lj_ctype_meta(cts, ctype_typeid(cts, ct), MM_tostring); if (tv) return lj_meta_tailcall(L, tv); } } } lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), p); checkgc: lj_gc_check(L); return 1; } static int ffi_pairs(lua_State *L, MMS mm) { CTState *cts = ctype_cts(L); CTypeID id = ffi_checkcdata(L, 1)->ctypeid; CType *ct = ctype_raw(cts, id); cTValue *tv; if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); tv = lj_ctype_meta(cts, id, mm); if (!tv) lj_err_callerv(L, LJ_ERR_FFI_BADMM, strdata(lj_ctype_repr(L, id, NULL)), strdata(mmname_str(G(L), mm))); return lj_meta_tailcall(L, tv); } LJLIB_CF(ffi_meta___pairs) { return ffi_pairs(L, MM_pairs); } LJLIB_CF(ffi_meta___ipairs) { return ffi_pairs(L, MM_ipairs); } LJLIB_PUSH("ffi") LJLIB_SET(__metatable) #include "lj_libdef.h" /* -- C library metamethods ----------------------------------------------- */ #define LJLIB_MODULE_ffi_clib /* Index C library by a name. */ static TValue *ffi_clib_index(lua_State *L) { TValue *o = L->base; CLibrary *cl; if (!(o < L->top && tvisudata(o) && udataV(o)->udtype == UDTYPE_FFI_CLIB)) lj_err_argt(L, 1, LUA_TUSERDATA); cl = (CLibrary *)uddata(udataV(o)); if (!(o+1 < L->top && tvisstr(o+1))) lj_err_argt(L, 2, LUA_TSTRING); return lj_clib_index(L, cl, strV(o+1)); } LJLIB_CF(ffi_clib___index) LJLIB_REC(clib_index 1) { TValue *tv = ffi_clib_index(L); if (tviscdata(tv)) { CTState *cts = ctype_cts(L); GCcdata *cd = cdataV(tv); CType *s = ctype_get(cts, cd->ctypeid); if (ctype_isextern(s->info)) { CTypeID sid = ctype_cid(s->info); void *sp = *(void **)cdataptr(cd); CType *ct = ctype_raw(cts, sid); if (lj_cconv_tv_ct(cts, ct, sid, L->top-1, sp)) lj_gc_check(L); return 1; } } copyTV(L, L->top-1, tv); return 1; } LJLIB_CF(ffi_clib___newindex) LJLIB_REC(clib_index 0) { TValue *tv = ffi_clib_index(L); TValue *o = L->base+2; if (o < L->top && tviscdata(tv)) { CTState *cts = ctype_cts(L); GCcdata *cd = cdataV(tv); CType *d = ctype_get(cts, cd->ctypeid); if (ctype_isextern(d->info)) { CTInfo qual = 0; for (;;) { /* Skip attributes and collect qualifiers. */ d = ctype_child(cts, d); if (!ctype_isattrib(d->info)) break; if (ctype_attrib(d->info) == CTA_QUAL) qual |= d->size; } if (!((d->info|qual) & CTF_CONST)) { lj_cconv_ct_tv(cts, d, *(void **)cdataptr(cd), o, 0); return 0; } } } lj_err_caller(L, LJ_ERR_FFI_WRCONST); return 0; /* unreachable */ } LJLIB_CF(ffi_clib___gc) { TValue *o = L->base; if (o < L->top && tvisudata(o) && udataV(o)->udtype == UDTYPE_FFI_CLIB) lj_clib_unload((CLibrary *)uddata(udataV(o))); return 0; } #include "lj_libdef.h" /* -- Callback function metamethods --------------------------------------- */ #define LJLIB_MODULE_ffi_callback static int ffi_callback_set(lua_State *L, GCfunc *fn) { GCcdata *cd = ffi_checkcdata(L, 1); CTState *cts = ctype_cts(L); CType *ct = ctype_raw(cts, cd->ctypeid); if (ctype_isptr(ct->info) && (LJ_32 || ct->size == 8)) { MSize slot = lj_ccallback_ptr2slot(cts, *(void **)cdataptr(cd)); if (slot < cts->cb.sizeid && cts->cb.cbid[slot] != 0) { GCtab *t = cts->miscmap; TValue *tv = lj_tab_setint(L, t, (int32_t)slot); if (fn) { setfuncV(L, tv, fn); lj_gc_anybarriert(L, t); } else { setnilV(tv); cts->cb.cbid[slot] = 0; cts->cb.topid = slot < cts->cb.topid ? slot : cts->cb.topid; } return 0; } } lj_err_caller(L, LJ_ERR_FFI_BADCBACK); return 0; } LJLIB_CF(ffi_callback_free) { return ffi_callback_set(L, NULL); } LJLIB_CF(ffi_callback_set) { GCfunc *fn = lj_lib_checkfunc(L, 2); return ffi_callback_set(L, fn); } LJLIB_PUSH(top-1) LJLIB_SET(__index) #include "lj_libdef.h" /* -- FFI library functions ----------------------------------------------- */ #define LJLIB_MODULE_ffi LJLIB_CF(ffi_cdef) { GCstr *s = lj_lib_checkstr(L, 1); CPState cp; int errcode; cp.L = L; cp.cts = ctype_cts(L); cp.srcname = strdata(s); cp.p = strdata(s); cp.param = L->base+1; cp.mode = CPARSE_MODE_MULTI|CPARSE_MODE_DIRECT; errcode = lj_cparse(&cp); if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ lj_gc_check(L); return 0; } LJLIB_CF(ffi_new) LJLIB_REC(.) { CTState *cts = ctype_cts(L); CTypeID id = ffi_checkctype(L, cts, NULL); CType *ct = ctype_raw(cts, id); CTSize sz; CTInfo info = lj_ctype_info(cts, id, &sz); TValue *o = L->base+1; GCcdata *cd; if ((info & CTF_VLA)) { o++; sz = lj_ctype_vlsize(cts, ct, (CTSize)ffi_checkint(L, 2)); } if (sz == CTSIZE_INVALID) lj_err_arg(L, 1, LJ_ERR_FFI_INVSIZE); if (!(info & CTF_VLA) && ctype_align(info) <= CT_MEMALIGN) cd = lj_cdata_new(cts, id, sz); else cd = lj_cdata_newv(cts, id, sz, ctype_align(info)); setcdataV(L, o-1, cd); /* Anchor the uninitialized cdata. */ lj_cconv_ct_init(cts, ct, sz, cdataptr(cd), o, (MSize)(L->top - o)); /* Initialize cdata. */ if (ctype_isstruct(ct->info)) { /* Handle ctype __gc metamethod. Use the fast lookup here. */ cTValue *tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); if (tv && tvistab(tv) && (tv = lj_meta_fast(L, tabV(tv), MM_gc))) { GCtab *t = cts->finalizer; if (gcref(t->metatable)) { /* Add to finalizer table, if still enabled. */ copyTV(L, lj_tab_set(L, t, o-1), tv); lj_gc_anybarriert(L, t); cd->marked |= LJ_GC_CDATA_FIN; } } } L->top = o; /* Only return the cdata itself. */ lj_gc_check(L); return 1; } LJLIB_CF(ffi_cast) LJLIB_REC(ffi_new) { CTState *cts = ctype_cts(L); CTypeID id = ffi_checkctype(L, cts, NULL); CType *d = ctype_raw(cts, id); TValue *o = lj_lib_checkany(L, 2); L->top = o+1; /* Make sure this is the last item on the stack. */ if (!(ctype_isnum(d->info) || ctype_isptr(d->info) || ctype_isenum(d->info))) lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); if (!(tviscdata(o) && cdataV(o)->ctypeid == id)) { GCcdata *cd = lj_cdata_new(cts, id, d->size); lj_cconv_ct_tv(cts, d, cdataptr(cd), o, CCF_CAST); setcdataV(L, o, cd); lj_gc_check(L); } return 1; } LJLIB_CF(ffi_typeof) LJLIB_REC(.) { CTState *cts = ctype_cts(L); CTypeID id = ffi_checkctype(L, cts, L->base+1); GCcdata *cd = lj_cdata_new(cts, CTID_CTYPEID, 4); *(CTypeID *)cdataptr(cd) = id; setcdataV(L, L->top-1, cd); lj_gc_check(L); return 1; } LJLIB_CF(ffi_istype) LJLIB_REC(.) { CTState *cts = ctype_cts(L); CTypeID id1 = ffi_checkctype(L, cts, NULL); TValue *o = lj_lib_checkany(L, 2); int b = 0; if (tviscdata(o)) { GCcdata *cd = cdataV(o); CTypeID id2 = cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : cd->ctypeid; CType *ct1 = lj_ctype_rawref(cts, id1); CType *ct2 = lj_ctype_rawref(cts, id2); if (ct1 == ct2) { b = 1; } else if (ctype_type(ct1->info) == ctype_type(ct2->info) && ct1->size == ct2->size) { if (ctype_ispointer(ct1->info)) b = lj_cconv_compatptr(cts, ct1, ct2, CCF_IGNQUAL); else if (ctype_isnum(ct1->info) || ctype_isvoid(ct1->info)) b = (((ct1->info ^ ct2->info) & ~CTF_QUAL) == 0); } else if (ctype_isstruct(ct1->info) && ctype_isptr(ct2->info) && ct1 == ctype_rawchild(cts, ct2)) { b = 1; } } setboolV(L->top-1, b); setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */ return 1; } LJLIB_CF(ffi_sizeof) LJLIB_REC(ffi_xof FF_ffi_sizeof) { CTState *cts = ctype_cts(L); CTypeID id = ffi_checkctype(L, cts, NULL); CTSize sz; if (LJ_UNLIKELY(tviscdata(L->base) && cdataisv(cdataV(L->base)))) { sz = cdatavlen(cdataV(L->base)); } else { CType *ct = lj_ctype_rawref(cts, id); if (ctype_isvltype(ct->info)) sz = lj_ctype_vlsize(cts, ct, (CTSize)ffi_checkint(L, 2)); else sz = ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID; if (LJ_UNLIKELY(sz == CTSIZE_INVALID)) { setnilV(L->top-1); return 1; } } setintV(L->top-1, (int32_t)sz); return 1; } LJLIB_CF(ffi_alignof) LJLIB_REC(ffi_xof FF_ffi_alignof) { CTState *cts = ctype_cts(L); CTypeID id = ffi_checkctype(L, cts, NULL); CTSize sz = 0; CTInfo info = lj_ctype_info(cts, id, &sz); setintV(L->top-1, 1 << ctype_align(info)); return 1; } LJLIB_CF(ffi_offsetof) LJLIB_REC(ffi_xof FF_ffi_offsetof) { CTState *cts = ctype_cts(L); CTypeID id = ffi_checkctype(L, cts, NULL); GCstr *name = lj_lib_checkstr(L, 2); CType *ct = lj_ctype_rawref(cts, id); CTSize ofs; if (ctype_isstruct(ct->info) && ct->size != CTSIZE_INVALID) { CType *fct = lj_ctype_getfield(cts, ct, name, &ofs); if (fct) { setintV(L->top-1, ofs); if (ctype_isfield(fct->info)) { return 1; } else if (ctype_isbitfield(fct->info)) { setintV(L->top++, ctype_bitpos(fct->info)); setintV(L->top++, ctype_bitbsz(fct->info)); return 3; } } } return 0; } LJLIB_CF(ffi_errno) LJLIB_REC(.) { int err = errno; if (L->top > L->base) errno = ffi_checkint(L, 1); setintV(L->top++, err); return 1; } LJLIB_CF(ffi_string) LJLIB_REC(.) { CTState *cts = ctype_cts(L); TValue *o = lj_lib_checkany(L, 1); const char *p; size_t len; if (o+1 < L->top) { len = (size_t)ffi_checkint(L, 2); lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CVOID), (uint8_t *)&p, o, CCF_ARG(1)); } else { lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CCHAR), (uint8_t *)&p, o, CCF_ARG(1)); len = strlen(p); } L->top = o+1; /* Make sure this is the last item on the stack. */ setstrV(L, o, lj_str_new(L, p, len)); lj_gc_check(L); return 1; } LJLIB_CF(ffi_copy) LJLIB_REC(.) { void *dp = ffi_checkptr(L, 1, CTID_P_VOID); void *sp = ffi_checkptr(L, 2, CTID_P_CVOID); TValue *o = L->base+1; CTSize len; if (tvisstr(o) && o+1 >= L->top) len = strV(o)->len+1; /* Copy Lua string including trailing '\0'. */ else len = (CTSize)ffi_checkint(L, 3); memcpy(dp, sp, len); return 0; } LJLIB_CF(ffi_fill) LJLIB_REC(.) { void *dp = ffi_checkptr(L, 1, CTID_P_VOID); CTSize len = (CTSize)ffi_checkint(L, 2); int32_t fill = 0; if (L->base+2 < L->top && !tvisnil(L->base+2)) fill = ffi_checkint(L, 3); memset(dp, fill, len); return 0; } #define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be) /* Test ABI string. */ LJLIB_CF(ffi_abi) LJLIB_REC(.) { GCstr *s = lj_lib_checkstr(L, 1); int b = 0; switch (s->hash) { #if LJ_64 case H_(849858eb,ad35fd06): b = 1; break; /* 64bit */ #else case H_(662d3c79,d0e22477): b = 1; break; /* 32bit */ #endif #if LJ_ARCH_HASFPU case H_(e33ee463,e33ee463): b = 1; break; /* fpu */ #endif #if LJ_ABI_SOFTFP case H_(61211a23,c2e8c81c): b = 1; break; /* softfp */ #else case H_(539417a8,8ce0812f): b = 1; break; /* hardfp */ #endif #if LJ_ABI_EABI case H_(2182df8f,f2ed1152): b = 1; break; /* eabi */ #endif #if LJ_ABI_WIN case H_(4ab624a8,4ab624a8): b = 1; break; /* win */ #endif case H_(3af93066,1f001464): b = 1; break; /* le/be */ default: break; } setboolV(L->top-1, b); setboolV(&G(L)->tmptv2, b); /* Remember for trace recorder. */ return 1; } #undef H_ LJLIB_PUSH(top-8) LJLIB_SET(!) /* Store reference to miscmap table. */ LJLIB_CF(ffi_metatype) { CTState *cts = ctype_cts(L); CTypeID id = ffi_checkctype(L, cts, NULL); GCtab *mt = lj_lib_checktab(L, 2); GCtab *t = cts->miscmap; CType *ct = ctype_get(cts, id); /* Only allow raw types. */ TValue *tv; GCcdata *cd; if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) || ctype_isvector(ct->info))) lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); tv = lj_tab_setinth(L, t, -(int32_t)id); if (!tvisnil(tv)) lj_err_caller(L, LJ_ERR_PROTMT); settabV(L, tv, mt); lj_gc_anybarriert(L, t); cd = lj_cdata_new(cts, CTID_CTYPEID, 4); *(CTypeID *)cdataptr(cd) = id; setcdataV(L, L->top-1, cd); lj_gc_check(L); return 1; } LJLIB_PUSH(top-7) LJLIB_SET(!) /* Store reference to finalizer table. */ LJLIB_CF(ffi_gc) LJLIB_REC(.) { GCcdata *cd = ffi_checkcdata(L, 1); TValue *fin = lj_lib_checkany(L, 2); CTState *cts = ctype_cts(L); GCtab *t = cts->finalizer; CType *ct = ctype_raw(cts, cd->ctypeid); if (!(ctype_isptr(ct->info) || ctype_isstruct(ct->info) || ctype_isrefarray(ct->info))) lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE); if (gcref(t->metatable)) { /* Update finalizer table, if still enabled. */ copyTV(L, lj_tab_set(L, t, L->base), fin); lj_gc_anybarriert(L, t); if (!tvisnil(fin)) cd->marked |= LJ_GC_CDATA_FIN; else cd->marked &= ~LJ_GC_CDATA_FIN; } L->top = L->base+1; /* Pass through the cdata object. */ return 1; } LJLIB_PUSH(top-5) LJLIB_SET(!) /* Store clib metatable in func environment. */ LJLIB_CF(ffi_load) { GCstr *name = lj_lib_checkstr(L, 1); int global = (L->base+1 < L->top && tvistruecond(L->base+1)); lj_clib_load(L, tabref(curr_func(L)->c.env), name, global); return 1; } LJLIB_PUSH(top-4) LJLIB_SET(C) LJLIB_PUSH(top-3) LJLIB_SET(os) LJLIB_PUSH(top-2) LJLIB_SET(arch) #include "lj_libdef.h" /* ------------------------------------------------------------------------ */ /* Create special weak-keyed finalizer table. */ static GCtab *ffi_finalizer(lua_State *L) { /* NOBARRIER: The table is new (marked white). */ GCtab *t = lj_tab_new(L, 0, 1); settabV(L, L->top++, t); setgcref(t->metatable, obj2gco(t)); setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), lj_str_newlit(L, "K")); t->nomm = (uint8_t)(~(1u<top-1); lj_gc_anybarriert(L, t); } } LUALIB_API int luaopen_ffi(lua_State *L) { CTState *cts = lj_ctype_init(L); settabV(L, L->top++, (cts->miscmap = lj_tab_new(L, 0, 1))); cts->finalizer = ffi_finalizer(L); LJ_LIB_REG(L, NULL, ffi_meta); /* NOBARRIER: basemt is a GC root. */ setgcref(basemt_it(G(L), LJ_TCDATA), obj2gco(tabV(L->top-1))); LJ_LIB_REG(L, NULL, ffi_clib); LJ_LIB_REG(L, NULL, ffi_callback); /* NOBARRIER: the key is new and lj_tab_newkey() handles the barrier. */ settabV(L, lj_tab_setstr(L, cts->miscmap, &cts->g->strempty), tabV(L->top-1)); L->top--; lj_clib_default(L, tabV(L->top-1)); /* Create ffi.C default namespace. */ lua_pushliteral(L, LJ_OS_NAME); lua_pushliteral(L, LJ_ARCH_NAME); LJ_LIB_REG(L, NULL, ffi); /* Note: no global "ffi" created! */ ffi_register_module(L); return 1; } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_init.c ================================================ /* ** Library initialization. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major parts taken verbatim from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lib_init_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_arch.h" static const luaL_Reg lj_lib_load[] = { { "", luaopen_base }, { LUA_LOADLIBNAME, luaopen_package }, { LUA_TABLIBNAME, luaopen_table }, { LUA_IOLIBNAME, luaopen_io }, { LUA_OSLIBNAME, luaopen_os }, { LUA_STRLIBNAME, luaopen_string }, { LUA_MATHLIBNAME, luaopen_math }, { LUA_DBLIBNAME, luaopen_debug }, { LUA_BITLIBNAME, luaopen_bit }, { LUA_JITLIBNAME, luaopen_jit }, { NULL, NULL } }; static const luaL_Reg lj_lib_preload[] = { #if LJ_HASFFI { LUA_FFILIBNAME, luaopen_ffi }, #endif { NULL, NULL } }; LUALIB_API void luaL_openlibs(lua_State *L) { const luaL_Reg *lib; for (lib = lj_lib_load; lib->func; lib++) { lua_pushcfunction(L, lib->func); lua_pushstring(L, lib->name); lua_call(L, 1, 0); } luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", sizeof(lj_lib_preload)/sizeof(lj_lib_preload[0])-1); for (lib = lj_lib_preload; lib->func; lib++) { lua_pushcfunction(L, lib->func); lua_setfield(L, -2, lib->name); } lua_pop(L, 1); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_io.c ================================================ /* ** I/O library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #include #include #define lib_io_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_state.h" #include "lj_ff.h" #include "lj_lib.h" /* Userdata payload for I/O file. */ typedef struct IOFileUD { FILE *fp; /* File handle. */ uint32_t type; /* File type. */ } IOFileUD; #define IOFILE_TYPE_FILE 0 /* Regular file. */ #define IOFILE_TYPE_PIPE 1 /* Pipe. */ #define IOFILE_TYPE_STDF 2 /* Standard file handle. */ #define IOFILE_TYPE_MASK 3 #define IOFILE_FLAG_CLOSE 4 /* Close after io.lines() iterator. */ #define IOSTDF_UD(L, id) (&gcref(G(L)->gcroot[(id)])->ud) #define IOSTDF_IOF(L, id) ((IOFileUD *)uddata(IOSTDF_UD(L, (id)))) /* -- Open/close helpers -------------------------------------------------- */ static IOFileUD *io_tofilep(lua_State *L) { if (!(L->base < L->top && tvisudata(L->base) && udataV(L->base)->udtype == UDTYPE_IO_FILE)) lj_err_argtype(L, 1, "FILE*"); return (IOFileUD *)uddata(udataV(L->base)); } static IOFileUD *io_tofile(lua_State *L) { IOFileUD *iof = io_tofilep(L); if (iof->fp == NULL) lj_err_caller(L, LJ_ERR_IOCLFL); return iof; } static FILE *io_stdfile(lua_State *L, ptrdiff_t id) { IOFileUD *iof = IOSTDF_IOF(L, id); if (iof->fp == NULL) lj_err_caller(L, LJ_ERR_IOSTDCL); return iof->fp; } static IOFileUD *io_file_new(lua_State *L) { IOFileUD *iof = (IOFileUD *)lua_newuserdata(L, sizeof(IOFileUD)); GCudata *ud = udataV(L->top-1); ud->udtype = UDTYPE_IO_FILE; /* NOBARRIER: The GCudata is new (marked white). */ setgcrefr(ud->metatable, curr_func(L)->c.env); iof->fp = NULL; iof->type = IOFILE_TYPE_FILE; return iof; } static IOFileUD *io_file_open(lua_State *L, const char *mode) { const char *fname = strdata(lj_lib_checkstr(L, 1)); IOFileUD *iof = io_file_new(L); iof->fp = fopen(fname, mode); if (iof->fp == NULL) luaL_argerror(L, 1, lj_str_pushf(L, "%s: %s", fname, strerror(errno))); return iof; } static int io_file_close(lua_State *L, IOFileUD *iof) { int ok; if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_FILE) { ok = (fclose(iof->fp) == 0); } else if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_PIPE) { int stat = -1; #if LJ_TARGET_POSIX stat = pclose(iof->fp); #elif LJ_TARGET_WINDOWS stat = _pclose(iof->fp); #else lua_assert(0); return 0; #endif #if LJ_52 iof->fp = NULL; return luaL_execresult(L, stat); #else ok = (stat != -1); #endif } else { lua_assert((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_STDF); setnilV(L->top++); lua_pushliteral(L, "cannot close standard file"); return 2; } iof->fp = NULL; return luaL_fileresult(L, ok, NULL); } /* -- Read/write helpers -------------------------------------------------- */ static int io_file_readnum(lua_State *L, FILE *fp) { lua_Number d; if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) { if (LJ_DUALNUM) { int32_t i = lj_num2int(d); if (d == (lua_Number)i && !tvismzero((cTValue *)&d)) { setintV(L->top++, i); return 1; } } setnumV(L->top++, d); return 1; } else { setnilV(L->top++); return 0; } } static int io_file_readline(lua_State *L, FILE *fp, MSize chop) { MSize m = LUAL_BUFFERSIZE, n = 0, ok = 0; char *buf; for (;;) { buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); if (fgets(buf+n, m-n, fp) == NULL) break; n += (MSize)strlen(buf+n); ok |= n; if (n && buf[n-1] == '\n') { n -= chop; break; } if (n >= m - 64) m += m; } setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); lj_gc_check(L); return (int)ok; } static void io_file_readall(lua_State *L, FILE *fp) { MSize m, n; for (m = LUAL_BUFFERSIZE, n = 0; ; m += m) { char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); n += (MSize)fread(buf+n, 1, m-n, fp); if (n != m) { setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); lj_gc_check(L); return; } } } static int io_file_readlen(lua_State *L, FILE *fp, MSize m) { if (m) { char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); MSize n = (MSize)fread(buf, 1, m, fp); setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); lj_gc_check(L); return (n > 0 || m == 0); } else { int c = getc(fp); ungetc(c, fp); setstrV(L, L->top++, &G(L)->strempty); return (c != EOF); } } static int io_file_read(lua_State *L, FILE *fp, int start) { int ok, n, nargs = (int)(L->top - L->base) - start; clearerr(fp); if (nargs == 0) { ok = io_file_readline(L, fp, 1); n = start+1; /* Return 1 result. */ } else { /* The results plus the buffers go on top of the args. */ luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); ok = 1; for (n = start; nargs-- && ok; n++) { if (tvisstr(L->base+n)) { const char *p = strVdata(L->base+n); if (p[0] != '*') lj_err_arg(L, n+1, LJ_ERR_INVOPT); if (p[1] == 'n') ok = io_file_readnum(L, fp); else if ((p[1] & ~0x20) == 'L') ok = io_file_readline(L, fp, (p[1] == 'l')); else if (p[1] == 'a') io_file_readall(L, fp); else lj_err_arg(L, n+1, LJ_ERR_INVFMT); } else if (tvisnumber(L->base+n)) { ok = io_file_readlen(L, fp, (MSize)lj_lib_checkint(L, n+1)); } else { lj_err_arg(L, n+1, LJ_ERR_INVOPT); } } } if (ferror(fp)) return luaL_fileresult(L, 0, NULL); if (!ok) setnilV(L->top-1); /* Replace last result with nil. */ return n - start; } static int io_file_write(lua_State *L, FILE *fp, int start) { cTValue *tv; int status = 1; for (tv = L->base+start; tv < L->top; tv++) { if (tvisstr(tv)) { MSize len = strV(tv)->len; status = status && (fwrite(strVdata(tv), 1, len, fp) == len); } else if (tvisint(tv)) { char buf[LJ_STR_INTBUF]; char *p = lj_str_bufint(buf, intV(tv)); size_t len = (size_t)(buf+LJ_STR_INTBUF-p); status = status && (fwrite(p, 1, len, fp) == len); } else if (tvisnum(tv)) { status = status && (fprintf(fp, LUA_NUMBER_FMT, numV(tv)) > 0); } else { lj_err_argt(L, (int)(tv - L->base) + 1, LUA_TSTRING); } } if (LJ_52 && status) { L->top = L->base+1; if (start == 0) setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_OUTPUT)); return 1; } return luaL_fileresult(L, status, NULL); } static int io_file_iter(lua_State *L) { GCfunc *fn = curr_func(L); IOFileUD *iof = uddata(udataV(&fn->c.upvalue[0])); int n = fn->c.nupvalues - 1; if (iof->fp == NULL) lj_err_caller(L, LJ_ERR_IOCLFL); L->top = L->base; if (n) { /* Copy upvalues with options to stack. */ if (n > LUAI_MAXCSTACK) lj_err_caller(L, LJ_ERR_STKOV); lj_state_checkstack(L, (MSize)n); memcpy(L->top, &fn->c.upvalue[1], n*sizeof(TValue)); L->top += n; } n = io_file_read(L, iof->fp, 0); if (ferror(iof->fp)) lj_err_callermsg(L, strVdata(L->top-2)); if (tvisnil(L->base) && (iof->type & IOFILE_FLAG_CLOSE)) { io_file_close(L, iof); /* Return values are ignored. */ return 0; } return n; } /* -- I/O file methods ---------------------------------------------------- */ #define LJLIB_MODULE_io_method LJLIB_CF(io_method_close) { IOFileUD *iof = L->base < L->top ? io_tofile(L) : IOSTDF_IOF(L, GCROOT_IO_OUTPUT); return io_file_close(L, iof); } LJLIB_CF(io_method_read) { return io_file_read(L, io_tofile(L)->fp, 1); } LJLIB_CF(io_method_write) LJLIB_REC(io_write 0) { return io_file_write(L, io_tofile(L)->fp, 1); } LJLIB_CF(io_method_flush) LJLIB_REC(io_flush 0) { return luaL_fileresult(L, fflush(io_tofile(L)->fp) == 0, NULL); } LJLIB_CF(io_method_seek) { FILE *fp = io_tofile(L)->fp; int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end"); int64_t ofs = 0; cTValue *o; int res; if (opt == 0) opt = SEEK_SET; else if (opt == 1) opt = SEEK_CUR; else if (opt == 2) opt = SEEK_END; o = L->base+2; if (o < L->top) { if (tvisint(o)) ofs = (int64_t)intV(o); else if (tvisnum(o)) ofs = (int64_t)numV(o); else if (!tvisnil(o)) lj_err_argt(L, 3, LUA_TNUMBER); } #if LJ_TARGET_POSIX res = fseeko(fp, ofs, opt); #elif _MSC_VER >= 1400 res = _fseeki64(fp, ofs, opt); #elif defined(__MINGW32__) res = fseeko64(fp, ofs, opt); #else res = fseek(fp, (long)ofs, opt); #endif if (res) return luaL_fileresult(L, 0, NULL); #if LJ_TARGET_POSIX ofs = ftello(fp); #elif _MSC_VER >= 1400 ofs = _ftelli64(fp); #elif defined(__MINGW32__) ofs = ftello64(fp); #else ofs = (int64_t)ftell(fp); #endif setint64V(L->top-1, ofs); return 1; } LJLIB_CF(io_method_setvbuf) { FILE *fp = io_tofile(L)->fp; int opt = lj_lib_checkopt(L, 2, -1, "\4full\4line\2no"); size_t sz = (size_t)lj_lib_optint(L, 3, LUAL_BUFFERSIZE); if (opt == 0) opt = _IOFBF; else if (opt == 1) opt = _IOLBF; else if (opt == 2) opt = _IONBF; return luaL_fileresult(L, setvbuf(fp, NULL, opt, sz) == 0, NULL); } LJLIB_CF(io_method_lines) { io_tofile(L); lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base)); return 1; } LJLIB_CF(io_method___gc) { IOFileUD *iof = io_tofilep(L); if (iof->fp != NULL && (iof->type & IOFILE_TYPE_MASK) != IOFILE_TYPE_STDF) io_file_close(L, iof); return 0; } LJLIB_CF(io_method___tostring) { IOFileUD *iof = io_tofilep(L); if (iof->fp != NULL) lua_pushfstring(L, "file (%p)", iof->fp); else lua_pushliteral(L, "file (closed)"); return 1; } LJLIB_PUSH(top-1) LJLIB_SET(__index) #include "lj_libdef.h" /* -- I/O library functions ----------------------------------------------- */ #define LJLIB_MODULE_io LJLIB_PUSH(top-2) LJLIB_SET(!) /* Set environment. */ LJLIB_CF(io_open) { const char *fname = strdata(lj_lib_checkstr(L, 1)); GCstr *s = lj_lib_optstr(L, 2); const char *mode = s ? strdata(s) : "r"; IOFileUD *iof = io_file_new(L); iof->fp = fopen(fname, mode); return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); } LJLIB_CF(io_popen) { #if LJ_TARGET_POSIX || LJ_TARGET_WINDOWS const char *fname = strdata(lj_lib_checkstr(L, 1)); GCstr *s = lj_lib_optstr(L, 2); const char *mode = s ? strdata(s) : "r"; IOFileUD *iof = io_file_new(L); iof->type = IOFILE_TYPE_PIPE; #if LJ_TARGET_POSIX fflush(NULL); iof->fp = popen(fname, mode); #else iof->fp = _popen(fname, mode); #endif return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); #else return luaL_error(L, LUA_QL("popen") " not supported"); #endif } LJLIB_CF(io_tmpfile) { IOFileUD *iof = io_file_new(L); #if LJ_TARGET_PS3 iof->fp = NULL; errno = ENOSYS; #else iof->fp = tmpfile(); #endif return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, NULL); } LJLIB_CF(io_close) { return lj_cf_io_method_close(L); } LJLIB_CF(io_read) { return io_file_read(L, io_stdfile(L, GCROOT_IO_INPUT), 0); } LJLIB_CF(io_write) LJLIB_REC(io_write GCROOT_IO_OUTPUT) { return io_file_write(L, io_stdfile(L, GCROOT_IO_OUTPUT), 0); } LJLIB_CF(io_flush) LJLIB_REC(io_flush GCROOT_IO_OUTPUT) { return luaL_fileresult(L, fflush(io_stdfile(L, GCROOT_IO_OUTPUT)) == 0, NULL); } static int io_std_getset(lua_State *L, ptrdiff_t id, const char *mode) { if (L->base < L->top && !tvisnil(L->base)) { if (tvisudata(L->base)) { io_tofile(L); L->top = L->base+1; } else { io_file_open(L, mode); } /* NOBARRIER: The standard I/O handles are GC roots. */ setgcref(G(L)->gcroot[id], gcV(L->top-1)); } else { setudataV(L, L->top++, IOSTDF_UD(L, id)); } return 1; } LJLIB_CF(io_input) { return io_std_getset(L, GCROOT_IO_INPUT, "r"); } LJLIB_CF(io_output) { return io_std_getset(L, GCROOT_IO_OUTPUT, "w"); } LJLIB_CF(io_lines) { if (L->base == L->top) setnilV(L->top++); if (!tvisnil(L->base)) { /* io.lines(fname) */ IOFileUD *iof = io_file_open(L, "r"); iof->type = IOFILE_TYPE_FILE|IOFILE_FLAG_CLOSE; L->top--; setudataV(L, L->base, udataV(L->top)); } else { /* io.lines() iterates over stdin. */ setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT)); } lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base)); return 1; } LJLIB_CF(io_type) { cTValue *o = lj_lib_checkany(L, 1); if (!(tvisudata(o) && udataV(o)->udtype == UDTYPE_IO_FILE)) setnilV(L->top++); else if (((IOFileUD *)uddata(udataV(o)))->fp != NULL) lua_pushliteral(L, "file"); else lua_pushliteral(L, "closed file"); return 1; } #include "lj_libdef.h" /* ------------------------------------------------------------------------ */ static GCobj *io_std_new(lua_State *L, FILE *fp, const char *name) { IOFileUD *iof = (IOFileUD *)lua_newuserdata(L, sizeof(IOFileUD)); GCudata *ud = udataV(L->top-1); ud->udtype = UDTYPE_IO_FILE; /* NOBARRIER: The GCudata is new (marked white). */ setgcref(ud->metatable, gcV(L->top-3)); iof->fp = fp; iof->type = IOFILE_TYPE_STDF; lua_setfield(L, -2, name); return obj2gco(ud); } LUALIB_API int luaopen_io(lua_State *L) { LJ_LIB_REG(L, NULL, io_method); copyTV(L, L->top, L->top-1); L->top++; lua_setfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); LJ_LIB_REG(L, LUA_IOLIBNAME, io); setgcref(G(L)->gcroot[GCROOT_IO_INPUT], io_std_new(L, stdin, "stdin")); setgcref(G(L)->gcroot[GCROOT_IO_OUTPUT], io_std_new(L, stdout, "stdout")); io_std_new(L, stderr, "stderr"); return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_jit.c ================================================ /* ** JIT library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lib_jit_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_arch.h" #include "lj_obj.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_bc.h" #if LJ_HASJIT #include "lj_ir.h" #include "lj_jit.h" #include "lj_ircall.h" #include "lj_iropt.h" #include "lj_target.h" #endif #include "lj_dispatch.h" #include "lj_vm.h" #include "lj_vmevent.h" #include "lj_lib.h" #include "luajit.h" /* -- jit.* functions ----------------------------------------------------- */ #define LJLIB_MODULE_jit static int setjitmode(lua_State *L, int mode) { int idx = 0; if (L->base == L->top || tvisnil(L->base)) { /* jit.on/off/flush([nil]) */ mode |= LUAJIT_MODE_ENGINE; } else { /* jit.on/off/flush(func|proto, nil|true|false) */ if (tvisfunc(L->base) || tvisproto(L->base)) idx = 1; else if (!tvistrue(L->base)) /* jit.on/off/flush(true, nil|true|false) */ goto err; if (L->base+1 < L->top && tvisbool(L->base+1)) mode |= boolV(L->base+1) ? LUAJIT_MODE_ALLFUNC : LUAJIT_MODE_ALLSUBFUNC; else mode |= LUAJIT_MODE_FUNC; } if (luaJIT_setmode(L, idx, mode) != 1) { if ((mode & LUAJIT_MODE_MASK) == LUAJIT_MODE_ENGINE) lj_err_caller(L, LJ_ERR_NOJIT); err: lj_err_argt(L, 1, LUA_TFUNCTION); } return 0; } LJLIB_CF(jit_on) { return setjitmode(L, LUAJIT_MODE_ON); } LJLIB_CF(jit_off) { return setjitmode(L, LUAJIT_MODE_OFF); } LJLIB_CF(jit_flush) { #if LJ_HASJIT if (L->base < L->top && !tvisnil(L->base)) { int traceno = lj_lib_checkint(L, 1); luaJIT_setmode(L, traceno, LUAJIT_MODE_FLUSH|LUAJIT_MODE_TRACE); return 0; } #endif return setjitmode(L, LUAJIT_MODE_FLUSH); } #if LJ_HASJIT /* Push a string for every flag bit that is set. */ static void flagbits_to_strings(lua_State *L, uint32_t flags, uint32_t base, const char *str) { for (; *str; base <<= 1, str += 1+*str) if (flags & base) setstrV(L, L->top++, lj_str_new(L, str+1, *(uint8_t *)str)); } #endif LJLIB_CF(jit_status) { #if LJ_HASJIT jit_State *J = L2J(L); L->top = L->base; setboolV(L->top++, (J->flags & JIT_F_ON) ? 1 : 0); flagbits_to_strings(L, J->flags, JIT_F_CPU_FIRST, JIT_F_CPUSTRING); flagbits_to_strings(L, J->flags, JIT_F_OPT_FIRST, JIT_F_OPTSTRING); return (int)(L->top - L->base); #else setboolV(L->top++, 0); return 1; #endif } LJLIB_CF(jit_attach) { #ifdef LUAJIT_DISABLE_VMEVENT luaL_error(L, "vmevent API disabled"); #else GCfunc *fn = lj_lib_checkfunc(L, 1); GCstr *s = lj_lib_optstr(L, 2); luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE); if (s) { /* Attach to given event. */ const uint8_t *p = (const uint8_t *)strdata(s); uint32_t h = s->len; while (*p) h = h ^ (lj_rol(h, 6) + *p++); lua_pushvalue(L, 1); lua_rawseti(L, -2, VMEVENT_HASHIDX(h)); G(L)->vmevmask = VMEVENT_NOCACHE; /* Invalidate cache. */ } else { /* Detach if no event given. */ setnilV(L->top++); while (lua_next(L, -2)) { L->top--; if (tvisfunc(L->top) && funcV(L->top) == fn) { setnilV(lj_tab_set(L, tabV(L->top-2), L->top-1)); } } } #endif return 0; } LJLIB_PUSH(top-5) LJLIB_SET(os) LJLIB_PUSH(top-4) LJLIB_SET(arch) LJLIB_PUSH(top-3) LJLIB_SET(version_num) LJLIB_PUSH(top-2) LJLIB_SET(version) #include "lj_libdef.h" /* -- jit.util.* functions ------------------------------------------------ */ #define LJLIB_MODULE_jit_util /* -- Reflection API for Lua functions ------------------------------------ */ /* Return prototype of first argument (Lua function or prototype object) */ static GCproto *check_Lproto(lua_State *L, int nolua) { TValue *o = L->base; if (L->top > o) { if (tvisproto(o)) { return protoV(o); } else if (tvisfunc(o)) { if (isluafunc(funcV(o))) return funcproto(funcV(o)); else if (nolua) return NULL; } } lj_err_argt(L, 1, LUA_TFUNCTION); return NULL; /* unreachable */ } static void setintfield(lua_State *L, GCtab *t, const char *name, int32_t val) { setintV(lj_tab_setstr(L, t, lj_str_newz(L, name)), val); } /* local info = jit.util.funcinfo(func [,pc]) */ LJLIB_CF(jit_util_funcinfo) { GCproto *pt = check_Lproto(L, 1); if (pt) { BCPos pc = (BCPos)lj_lib_optint(L, 2, 0); GCtab *t; lua_createtable(L, 0, 16); /* Increment hash size if fields are added. */ t = tabV(L->top-1); setintfield(L, t, "linedefined", pt->firstline); setintfield(L, t, "lastlinedefined", pt->firstline + pt->numline); setintfield(L, t, "stackslots", pt->framesize); setintfield(L, t, "params", pt->numparams); setintfield(L, t, "bytecodes", (int32_t)pt->sizebc); setintfield(L, t, "gcconsts", (int32_t)pt->sizekgc); setintfield(L, t, "nconsts", (int32_t)pt->sizekn); setintfield(L, t, "upvalues", (int32_t)pt->sizeuv); if (pc < pt->sizebc) setintfield(L, t, "currentline", lj_debug_line(pt, pc)); lua_pushboolean(L, (pt->flags & PROTO_VARARG)); lua_setfield(L, -2, "isvararg"); lua_pushboolean(L, (pt->flags & PROTO_CHILD)); lua_setfield(L, -2, "children"); setstrV(L, L->top++, proto_chunkname(pt)); lua_setfield(L, -2, "source"); lj_debug_pushloc(L, pt, pc); lua_setfield(L, -2, "loc"); } else { GCfunc *fn = funcV(L->base); GCtab *t; lua_createtable(L, 0, 4); /* Increment hash size if fields are added. */ t = tabV(L->top-1); if (!iscfunc(fn)) setintfield(L, t, "ffid", fn->c.ffid); setintptrV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")), (intptr_t)(void *)fn->c.f); setintfield(L, t, "upvalues", fn->c.nupvalues); } return 1; } /* local ins, m = jit.util.funcbc(func, pc) */ LJLIB_CF(jit_util_funcbc) { GCproto *pt = check_Lproto(L, 0); BCPos pc = (BCPos)lj_lib_checkint(L, 2); if (pc < pt->sizebc) { BCIns ins = proto_bc(pt)[pc]; BCOp op = bc_op(ins); lua_assert(op < BC__MAX); setintV(L->top, ins); setintV(L->top+1, lj_bc_mode[op]); L->top += 2; return 2; } return 0; } /* local k = jit.util.funck(func, idx) */ LJLIB_CF(jit_util_funck) { GCproto *pt = check_Lproto(L, 0); ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); if (idx >= 0) { if (idx < (ptrdiff_t)pt->sizekn) { copyTV(L, L->top-1, proto_knumtv(pt, idx)); return 1; } } else { if (~idx < (ptrdiff_t)pt->sizekgc) { GCobj *gc = proto_kgc(pt, idx); setgcV(L, L->top-1, gc, ~gc->gch.gct); return 1; } } return 0; } /* local name = jit.util.funcuvname(func, idx) */ LJLIB_CF(jit_util_funcuvname) { GCproto *pt = check_Lproto(L, 0); uint32_t idx = (uint32_t)lj_lib_checkint(L, 2); if (idx < pt->sizeuv) { setstrV(L, L->top-1, lj_str_newz(L, lj_debug_uvname(pt, idx))); return 1; } return 0; } /* -- Reflection API for traces ------------------------------------------- */ #if LJ_HASJIT /* Check trace argument. Must not throw for non-existent trace numbers. */ static GCtrace *jit_checktrace(lua_State *L) { TraceNo tr = (TraceNo)lj_lib_checkint(L, 1); jit_State *J = L2J(L); if (tr > 0 && tr < J->sizetrace) return traceref(J, tr); return NULL; } /* Names of link types. ORDER LJ_TRLINK */ static const char *const jit_trlinkname[] = { "none", "root", "loop", "tail-recursion", "up-recursion", "down-recursion", "interpreter", "return" }; /* local info = jit.util.traceinfo(tr) */ LJLIB_CF(jit_util_traceinfo) { GCtrace *T = jit_checktrace(L); if (T) { GCtab *t; lua_createtable(L, 0, 8); /* Increment hash size if fields are added. */ t = tabV(L->top-1); setintfield(L, t, "nins", (int32_t)T->nins - REF_BIAS - 1); setintfield(L, t, "nk", REF_BIAS - (int32_t)T->nk); setintfield(L, t, "link", T->link); setintfield(L, t, "nexit", T->nsnap); setstrV(L, L->top++, lj_str_newz(L, jit_trlinkname[T->linktype])); lua_setfield(L, -2, "linktype"); /* There are many more fields. Add them only when needed. */ return 1; } return 0; } /* local m, ot, op1, op2, prev = jit.util.traceir(tr, idx) */ LJLIB_CF(jit_util_traceir) { GCtrace *T = jit_checktrace(L); IRRef ref = (IRRef)lj_lib_checkint(L, 2) + REF_BIAS; if (T && ref >= REF_BIAS && ref < T->nins) { IRIns *ir = &T->ir[ref]; int32_t m = lj_ir_mode[ir->o]; setintV(L->top-2, m); setintV(L->top-1, ir->ot); setintV(L->top++, (int32_t)ir->op1 - (irm_op1(m)==IRMref ? REF_BIAS : 0)); setintV(L->top++, (int32_t)ir->op2 - (irm_op2(m)==IRMref ? REF_BIAS : 0)); setintV(L->top++, ir->prev); return 5; } return 0; } /* local k, t [, slot] = jit.util.tracek(tr, idx) */ LJLIB_CF(jit_util_tracek) { GCtrace *T = jit_checktrace(L); IRRef ref = (IRRef)lj_lib_checkint(L, 2) + REF_BIAS; if (T && ref >= T->nk && ref < REF_BIAS) { IRIns *ir = &T->ir[ref]; int32_t slot = -1; if (ir->o == IR_KSLOT) { slot = ir->op2; ir = &T->ir[ir->op1]; } lj_ir_kvalue(L, L->top-2, ir); setintV(L->top-1, (int32_t)irt_type(ir->t)); if (slot == -1) return 2; setintV(L->top++, slot); return 3; } return 0; } /* local snap = jit.util.tracesnap(tr, sn) */ LJLIB_CF(jit_util_tracesnap) { GCtrace *T = jit_checktrace(L); SnapNo sn = (SnapNo)lj_lib_checkint(L, 2); if (T && sn < T->nsnap) { SnapShot *snap = &T->snap[sn]; SnapEntry *map = &T->snapmap[snap->mapofs]; MSize n, nent = snap->nent; GCtab *t; lua_createtable(L, nent+2, 0); t = tabV(L->top-1); setintV(lj_tab_setint(L, t, 0), (int32_t)snap->ref - REF_BIAS); setintV(lj_tab_setint(L, t, 1), (int32_t)snap->nslots); for (n = 0; n < nent; n++) setintV(lj_tab_setint(L, t, (int32_t)(n+2)), (int32_t)map[n]); setintV(lj_tab_setint(L, t, (int32_t)(nent+2)), (int32_t)SNAP(255, 0, 0)); return 1; } return 0; } /* local mcode, addr, loop = jit.util.tracemc(tr) */ LJLIB_CF(jit_util_tracemc) { GCtrace *T = jit_checktrace(L); if (T && T->mcode != NULL) { setstrV(L, L->top-1, lj_str_new(L, (const char *)T->mcode, T->szmcode)); setintptrV(L->top++, (intptr_t)(void *)T->mcode); setintV(L->top++, T->mcloop); return 3; } return 0; } /* local addr = jit.util.traceexitstub([tr,] exitno) */ LJLIB_CF(jit_util_traceexitstub) { #ifdef EXITSTUBS_PER_GROUP ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); jit_State *J = L2J(L); if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno)); return 1; } #else if (L->top > L->base+1) { /* Don't throw for one-argument variant. */ GCtrace *T = jit_checktrace(L); ExitNo exitno = (ExitNo)lj_lib_checkint(L, 2); ExitNo maxexit = T->root ? T->nsnap+1 : T->nsnap; if (T && T->mcode != NULL && exitno < maxexit) { setintptrV(L->top-1, (intptr_t)(void *)exitstub_trace_addr(T, exitno)); return 1; } } #endif return 0; } /* local addr = jit.util.ircalladdr(idx) */ LJLIB_CF(jit_util_ircalladdr) { uint32_t idx = (uint32_t)lj_lib_checkint(L, 1); if (idx < IRCALL__MAX) { setintptrV(L->top-1, (intptr_t)(void *)lj_ir_callinfo[idx].func); return 1; } return 0; } #endif #include "lj_libdef.h" /* -- jit.opt module ------------------------------------------------------ */ #if LJ_HASJIT #define LJLIB_MODULE_jit_opt /* Parse optimization level. */ static int jitopt_level(jit_State *J, const char *str) { if (str[0] >= '0' && str[0] <= '9' && str[1] == '\0') { uint32_t flags; if (str[0] == '0') flags = JIT_F_OPT_0; else if (str[0] == '1') flags = JIT_F_OPT_1; else if (str[0] == '2') flags = JIT_F_OPT_2; else flags = JIT_F_OPT_3; J->flags = (J->flags & ~JIT_F_OPT_MASK) | flags; return 1; /* Ok. */ } return 0; /* No match. */ } /* Parse optimization flag. */ static int jitopt_flag(jit_State *J, const char *str) { const char *lst = JIT_F_OPTSTRING; uint32_t opt; int set = 1; if (str[0] == '+') { str++; } else if (str[0] == '-') { str++; set = 0; } else if (str[0] == 'n' && str[1] == 'o') { str += str[2] == '-' ? 3 : 2; set = 0; } for (opt = JIT_F_OPT_FIRST; ; opt <<= 1) { size_t len = *(const uint8_t *)lst; if (len == 0) break; if (strncmp(str, lst+1, len) == 0 && str[len] == '\0') { if (set) J->flags |= opt; else J->flags &= ~opt; return 1; /* Ok. */ } lst += 1+len; } return 0; /* No match. */ } /* Parse optimization parameter. */ static int jitopt_param(jit_State *J, const char *str) { const char *lst = JIT_P_STRING; int i; for (i = 0; i < JIT_P__MAX; i++) { size_t len = *(const uint8_t *)lst; lua_assert(len != 0); if (strncmp(str, lst+1, len) == 0 && str[len] == '=') { int32_t n = 0; const char *p = &str[len+1]; while (*p >= '0' && *p <= '9') n = n*10 + (*p++ - '0'); if (*p) return 0; /* Malformed number. */ J->param[i] = n; if (i == JIT_P_hotloop) lj_dispatch_init_hotcount(J2G(J)); return 1; /* Ok. */ } lst += 1+len; } return 0; /* No match. */ } /* jit.opt.start(flags...) */ LJLIB_CF(jit_opt_start) { jit_State *J = L2J(L); int nargs = (int)(L->top - L->base); if (nargs == 0) { J->flags = (J->flags & ~JIT_F_OPT_MASK) | JIT_F_OPT_DEFAULT; } else { int i; for (i = 1; i <= nargs; i++) { const char *str = strdata(lj_lib_checkstr(L, i)); if (!jitopt_level(J, str) && !jitopt_flag(J, str) && !jitopt_param(J, str)) lj_err_callerv(L, LJ_ERR_JITOPT, str); } } return 0; } #include "lj_libdef.h" #endif /* -- JIT compiler initialization ----------------------------------------- */ #if LJ_HASJIT /* Default values for JIT parameters. */ static const int32_t jit_param_default[JIT_P__MAX+1] = { #define JIT_PARAMINIT(len, name, value) (value), JIT_PARAMDEF(JIT_PARAMINIT) #undef JIT_PARAMINIT 0 }; #endif #if LJ_TARGET_ARM && LJ_TARGET_LINUX #include #endif /* Arch-dependent CPU detection. */ static uint32_t jit_cpudetect(lua_State *L) { uint32_t flags = 0; #if LJ_TARGET_X86ORX64 uint32_t vendor[4]; uint32_t features[4]; if (lj_vm_cpuid(0, vendor) && lj_vm_cpuid(1, features)) { #if !LJ_HASJIT #define JIT_F_CMOV 1 #define JIT_F_SSE2 2 #endif flags |= ((features[3] >> 15)&1) * JIT_F_CMOV; flags |= ((features[3] >> 26)&1) * JIT_F_SSE2; #if LJ_HASJIT flags |= ((features[2] >> 0)&1) * JIT_F_SSE3; flags |= ((features[2] >> 19)&1) * JIT_F_SSE4_1; if (vendor[2] == 0x6c65746e) { /* Intel. */ if ((features[0] & 0x0ff00f00) == 0x00000f00) /* P4. */ flags |= JIT_F_P4; /* Currently unused. */ else if ((features[0] & 0x0fff0ff0) == 0x000106c0) /* Atom. */ flags |= JIT_F_LEA_AGU; } else if (vendor[2] == 0x444d4163) { /* AMD. */ uint32_t fam = (features[0] & 0x0ff00f00); if (fam == 0x00000f00) /* K8. */ flags |= JIT_F_SPLIT_XMM; if (fam >= 0x00000f00) /* K8, K10. */ flags |= JIT_F_PREFER_IMUL; } #endif } /* Check for required instruction set support on x86 (unnecessary on x64). */ #if LJ_TARGET_X86 #if !defined(LUAJIT_CPU_NOCMOV) if (!(flags & JIT_F_CMOV)) luaL_error(L, "CPU not supported"); #endif #if defined(LUAJIT_CPU_SSE2) if (!(flags & JIT_F_SSE2)) luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); #endif #endif #elif LJ_TARGET_ARM #if LJ_HASJIT int ver = LJ_ARCH_VERSION; /* Compile-time ARM CPU detection. */ #if LJ_TARGET_LINUX if (ver < 70) { /* Runtime ARM CPU detection. */ struct utsname ut; uname(&ut); if (strncmp(ut.machine, "armv", 4) == 0) { if (ut.machine[4] >= '7') ver = 70; else if (ut.machine[4] == '6') ver = 60; } } #endif flags |= ver >= 70 ? JIT_F_ARMV7 : ver >= 61 ? JIT_F_ARMV6T2_ : ver >= 60 ? JIT_F_ARMV6_ : 0; flags |= LJ_ARCH_HASFPU == 0 ? 0 : ver >= 70 ? JIT_F_VFPV3 : JIT_F_VFPV2; #endif #elif LJ_TARGET_PPC #if LJ_HASJIT #if LJ_ARCH_SQRT flags |= JIT_F_SQRT; #endif #if LJ_ARCH_ROUND flags |= JIT_F_ROUND; #endif #endif #elif LJ_TARGET_PPCSPE /* Nothing to do. */ #elif LJ_TARGET_MIPS #if LJ_HASJIT /* Compile-time MIPS CPU detection. */ #if LJ_ARCH_VERSION >= 20 flags |= JIT_F_MIPS32R2; #endif /* Runtime MIPS CPU detection. */ #if defined(__GNUC__) if (!(flags & JIT_F_MIPS32R2)) { int x; /* On MIPS32R1 rotr is treated as srl. rotr r2,r2,1 -> srl r2,r2,1. */ __asm__("li $2, 1\n\t.long 0x00221042\n\tmove %0, $2" : "=r"(x) : : "$2"); if (x) flags |= JIT_F_MIPS32R2; /* Either 0x80000000 (R2) or 0 (R1). */ } #endif #endif #else #error "Missing CPU detection for this architecture" #endif UNUSED(L); return flags; } /* Initialize JIT compiler. */ static void jit_init(lua_State *L) { uint32_t flags = jit_cpudetect(L); #if LJ_HASJIT jit_State *J = L2J(L); #if LJ_TARGET_X86 /* Silently turn off the JIT compiler on CPUs without SSE2. */ if ((flags & JIT_F_SSE2)) #endif J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT; memcpy(J->param, jit_param_default, sizeof(J->param)); lj_dispatch_update(G(L)); #else UNUSED(flags); #endif } LUALIB_API int luaopen_jit(lua_State *L) { lua_pushliteral(L, LJ_OS_NAME); lua_pushliteral(L, LJ_ARCH_NAME); lua_pushinteger(L, LUAJIT_VERSION_NUM); lua_pushliteral(L, LUAJIT_VERSION); LJ_LIB_REG(L, LUA_JITLIBNAME, jit); #ifndef LUAJIT_DISABLE_JITUTIL LJ_LIB_REG(L, "jit.util", jit_util); #endif #if LJ_HASJIT LJ_LIB_REG(L, "jit.opt", jit_opt); #endif L->top -= 2; jit_init(L); return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_math.c ================================================ /* ** Math library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include #define lib_math_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #include "lj_lib.h" #include "lj_vm.h" /* ------------------------------------------------------------------------ */ #define LJLIB_MODULE_math LJLIB_ASM(math_abs) LJLIB_REC(.) { lj_lib_checknumber(L, 1); return FFH_RETRY; } LJLIB_ASM_(math_floor) LJLIB_REC(math_round IRFPM_FLOOR) LJLIB_ASM_(math_ceil) LJLIB_REC(math_round IRFPM_CEIL) LJLIB_ASM(math_sqrt) LJLIB_REC(math_unary IRFPM_SQRT) { lj_lib_checknum(L, 1); return FFH_RETRY; } LJLIB_ASM_(math_log10) LJLIB_REC(math_unary IRFPM_LOG10) LJLIB_ASM_(math_exp) LJLIB_REC(math_unary IRFPM_EXP) LJLIB_ASM_(math_sin) LJLIB_REC(math_unary IRFPM_SIN) LJLIB_ASM_(math_cos) LJLIB_REC(math_unary IRFPM_COS) LJLIB_ASM_(math_tan) LJLIB_REC(math_unary IRFPM_TAN) LJLIB_ASM_(math_asin) LJLIB_REC(math_atrig FF_math_asin) LJLIB_ASM_(math_acos) LJLIB_REC(math_atrig FF_math_acos) LJLIB_ASM_(math_atan) LJLIB_REC(math_atrig FF_math_atan) LJLIB_ASM_(math_sinh) LJLIB_REC(math_htrig IRCALL_sinh) LJLIB_ASM_(math_cosh) LJLIB_REC(math_htrig IRCALL_cosh) LJLIB_ASM_(math_tanh) LJLIB_REC(math_htrig IRCALL_tanh) LJLIB_ASM_(math_frexp) LJLIB_ASM_(math_modf) LJLIB_REC(.) LJLIB_ASM(math_log) LJLIB_REC(math_log) { double x = lj_lib_checknum(L, 1); if (L->base+1 < L->top) { double y = lj_lib_checknum(L, 2); #ifdef LUAJIT_NO_LOG2 x = log(x); y = 1.0 / log(y); #else x = lj_vm_log2(x); y = 1.0 / lj_vm_log2(y); #endif setnumV(L->base-1, x*y); /* Do NOT join the expression to x / y. */ return FFH_RES(1); } return FFH_RETRY; } LJLIB_PUSH(57.29577951308232) LJLIB_ASM_(math_deg) LJLIB_REC(math_degrad) LJLIB_PUSH(0.017453292519943295) LJLIB_ASM_(math_rad) LJLIB_REC(math_degrad) LJLIB_ASM(math_atan2) LJLIB_REC(.) { lj_lib_checknum(L, 1); lj_lib_checknum(L, 2); return FFH_RETRY; } LJLIB_ASM_(math_pow) LJLIB_REC(.) LJLIB_ASM_(math_fmod) LJLIB_ASM(math_ldexp) LJLIB_REC(.) { lj_lib_checknum(L, 1); #if LJ_DUALNUM && !LJ_TARGET_X86ORX64 lj_lib_checkint(L, 2); #else lj_lib_checknum(L, 2); #endif return FFH_RETRY; } LJLIB_ASM(math_min) LJLIB_REC(math_minmax IR_MIN) { int i = 0; do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top); return FFH_RETRY; } LJLIB_ASM_(math_max) LJLIB_REC(math_minmax IR_MAX) LJLIB_PUSH(3.14159265358979323846) LJLIB_SET(pi) LJLIB_PUSH(1e310) LJLIB_SET(huge) /* ------------------------------------------------------------------------ */ /* This implements a Tausworthe PRNG with period 2^223. Based on: ** Tables of maximally-equidistributed combined LFSR generators, ** Pierre L'Ecuyer, 1991, table 3, 1st entry. ** Full-period ME-CF generator with L=64, J=4, k=223, N1=49. */ /* PRNG state. */ struct RandomState { uint64_t gen[4]; /* State of the 4 LFSR generators. */ int valid; /* State is valid. */ }; /* Union needed for bit-pattern conversion between uint64_t and double. */ typedef union { uint64_t u64; double d; } U64double; /* Update generator i and compute a running xor of all states. */ #define TW223_GEN(i, k, q, s) \ z = rs->gen[i]; \ z = (((z<> (k-s)) ^ ((z&((uint64_t)(int64_t)-1 << (64-k)))<gen[i] = z; /* PRNG step function. Returns a double in the range 1.0 <= d < 2.0. */ LJ_NOINLINE uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs) { uint64_t z, r = 0; TW223_GEN(0, 63, 31, 18) TW223_GEN(1, 58, 19, 28) TW223_GEN(2, 55, 24, 7) TW223_GEN(3, 47, 21, 8) return (r & U64x(000fffff,ffffffff)) | U64x(3ff00000,00000000); } /* PRNG initialization function. */ static void random_init(RandomState *rs, double d) { uint32_t r = 0x11090601; /* 64-k[i] as four 8 bit constants. */ int i; for (i = 0; i < 4; i++) { U64double u; uint32_t m = 1u << (r&255); r >>= 8; u.d = d = d * 3.14159265358979323846 + 2.7182818284590452354; if (u.u64 < m) u.u64 += m; /* Ensure k[i] MSB of gen[i] are non-zero. */ rs->gen[i] = u.u64; } rs->valid = 1; for (i = 0; i < 10; i++) lj_math_random_step(rs); } /* PRNG extract function. */ LJLIB_PUSH(top-2) /* Upvalue holds userdata with RandomState. */ LJLIB_CF(math_random) LJLIB_REC(.) { int n = (int)(L->top - L->base); RandomState *rs = (RandomState *)(uddata(udataV(lj_lib_upvalue(L, 1)))); U64double u; double d; if (LJ_UNLIKELY(!rs->valid)) random_init(rs, 0.0); u.u64 = lj_math_random_step(rs); d = u.d - 1.0; if (n > 0) { #if LJ_DUALNUM int isint = 1; double r1; lj_lib_checknumber(L, 1); if (tvisint(L->base)) { r1 = (lua_Number)intV(L->base); } else { isint = 0; r1 = numV(L->base); } #else double r1 = lj_lib_checknum(L, 1); #endif if (n == 1) { d = lj_vm_floor(d*r1) + 1.0; /* d is an int in range [1, r1] */ } else { #if LJ_DUALNUM double r2; lj_lib_checknumber(L, 2); if (tvisint(L->base+1)) { r2 = (lua_Number)intV(L->base+1); } else { isint = 0; r2 = numV(L->base+1); } #else double r2 = lj_lib_checknum(L, 2); #endif d = lj_vm_floor(d*(r2-r1+1.0)) + r1; /* d is an int in range [r1, r2] */ } #if LJ_DUALNUM if (isint) { setintV(L->top-1, lj_num2int(d)); return 1; } #endif } /* else: d is a double in range [0, 1] */ setnumV(L->top++, d); return 1; } /* PRNG seed function. */ LJLIB_PUSH(top-2) /* Upvalue holds userdata with RandomState. */ LJLIB_CF(math_randomseed) { RandomState *rs = (RandomState *)(uddata(udataV(lj_lib_upvalue(L, 1)))); random_init(rs, lj_lib_checknum(L, 1)); return 0; } /* ------------------------------------------------------------------------ */ #include "lj_libdef.h" LUALIB_API int luaopen_math(lua_State *L) { RandomState *rs; rs = (RandomState *)lua_newuserdata(L, sizeof(RandomState)); rs->valid = 0; /* Use lazy initialization to save some time on startup. */ LJ_LIB_REG(L, LUA_MATHLIBNAME, math); #if defined(LUA_COMPAT_MOD) && !LJ_52 lua_getfield(L, -1, "fmod"); lua_setfield(L, -2, "mod"); #endif return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_os.c ================================================ /* ** OS library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #include #include #include #define lib_os_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #include "lj_err.h" #include "lj_lib.h" #if LJ_TARGET_POSIX #include #else #include #endif /* ------------------------------------------------------------------------ */ #define LJLIB_MODULE_os LJLIB_CF(os_execute) { #if LJ_TARGET_CONSOLE #if LJ_52 errno = ENOSYS; return luaL_fileresult(L, 0, NULL); #else lua_pushinteger(L, -1); return 1; #endif #else const char *cmd = luaL_optstring(L, 1, NULL); int stat = system(cmd); #if LJ_52 if (cmd) return luaL_execresult(L, stat); setboolV(L->top++, 1); #else setintV(L->top++, stat); #endif return 1; #endif } LJLIB_CF(os_remove) { const char *filename = luaL_checkstring(L, 1); return luaL_fileresult(L, remove(filename) == 0, filename); } LJLIB_CF(os_rename) { const char *fromname = luaL_checkstring(L, 1); const char *toname = luaL_checkstring(L, 2); return luaL_fileresult(L, rename(fromname, toname) == 0, fromname); } LJLIB_CF(os_tmpname) { #if LJ_TARGET_PS3 lj_err_caller(L, LJ_ERR_OSUNIQF); return 0; #else #if LJ_TARGET_POSIX char buf[15+1]; int fp; strcpy(buf, "/tmp/lua_XXXXXX"); fp = mkstemp(buf); if (fp != -1) close(fp); else lj_err_caller(L, LJ_ERR_OSUNIQF); #else char buf[L_tmpnam]; if (tmpnam(buf) == NULL) lj_err_caller(L, LJ_ERR_OSUNIQF); #endif lua_pushstring(L, buf); return 1; #endif } LJLIB_CF(os_getenv) { #if LJ_TARGET_CONSOLE lua_pushnil(L); #else lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ #endif return 1; } LJLIB_CF(os_exit) { int status; if (L->base < L->top && tvisbool(L->base)) status = boolV(L->base) ? EXIT_SUCCESS : EXIT_FAILURE; else status = lj_lib_optint(L, 1, EXIT_SUCCESS); if (L->base+1 < L->top && tvistruecond(L->base+1)) lua_close(L); exit(status); return 0; /* Unreachable. */ } LJLIB_CF(os_clock) { setnumV(L->top++, ((lua_Number)clock())*(1.0/(lua_Number)CLOCKS_PER_SEC)); return 1; } /* ------------------------------------------------------------------------ */ static void setfield(lua_State *L, const char *key, int value) { lua_pushinteger(L, value); lua_setfield(L, -2, key); } static void setboolfield(lua_State *L, const char *key, int value) { if (value < 0) /* undefined? */ return; /* does not set field */ lua_pushboolean(L, value); lua_setfield(L, -2, key); } static int getboolfield(lua_State *L, const char *key) { int res; lua_getfield(L, -1, key); res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); lua_pop(L, 1); return res; } static int getfield(lua_State *L, const char *key, int d) { int res; lua_getfield(L, -1, key); if (lua_isnumber(L, -1)) { res = (int)lua_tointeger(L, -1); } else { if (d < 0) lj_err_callerv(L, LJ_ERR_OSDATEF, key); res = d; } lua_pop(L, 1); return res; } LJLIB_CF(os_date) { const char *s = luaL_optstring(L, 1, "%c"); time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); struct tm *stm; #if LJ_TARGET_POSIX struct tm rtm; #endif if (*s == '!') { /* UTC? */ s++; /* Skip '!' */ #if LJ_TARGET_POSIX stm = gmtime_r(&t, &rtm); #else stm = gmtime(&t); #endif } else { #if LJ_TARGET_POSIX stm = localtime_r(&t, &rtm); #else stm = localtime(&t); #endif } if (stm == NULL) { /* Invalid date? */ setnilV(L->top-1); } else if (strcmp(s, "*t") == 0) { lua_createtable(L, 0, 9); /* 9 = number of fields */ setfield(L, "sec", stm->tm_sec); setfield(L, "min", stm->tm_min); setfield(L, "hour", stm->tm_hour); setfield(L, "day", stm->tm_mday); setfield(L, "month", stm->tm_mon+1); setfield(L, "year", stm->tm_year+1900); setfield(L, "wday", stm->tm_wday+1); setfield(L, "yday", stm->tm_yday+1); setboolfield(L, "isdst", stm->tm_isdst); } else { char cc[3]; luaL_Buffer b; cc[0] = '%'; cc[2] = '\0'; luaL_buffinit(L, &b); for (; *s; s++) { if (*s != '%' || *(s + 1) == '\0') { /* No conversion specifier? */ luaL_addchar(&b, *s); } else { size_t reslen; char buff[200]; /* Should be big enough for any conversion result. */ cc[1] = *(++s); reslen = strftime(buff, sizeof(buff), cc, stm); luaL_addlstring(&b, buff, reslen); } } luaL_pushresult(&b); } return 1; } LJLIB_CF(os_time) { time_t t; if (lua_isnoneornil(L, 1)) { /* called without args? */ t = time(NULL); /* get current time */ } else { struct tm ts; luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); /* make sure table is at the top */ ts.tm_sec = getfield(L, "sec", 0); ts.tm_min = getfield(L, "min", 0); ts.tm_hour = getfield(L, "hour", 12); ts.tm_mday = getfield(L, "day", -1); ts.tm_mon = getfield(L, "month", -1) - 1; ts.tm_year = getfield(L, "year", -1) - 1900; ts.tm_isdst = getboolfield(L, "isdst"); t = mktime(&ts); } if (t == (time_t)(-1)) lua_pushnil(L); else lua_pushnumber(L, (lua_Number)t); return 1; } LJLIB_CF(os_difftime) { lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), (time_t)(luaL_optnumber(L, 2, (lua_Number)0)))); return 1; } /* ------------------------------------------------------------------------ */ LJLIB_CF(os_setlocale) { GCstr *s = lj_lib_optstr(L, 1); const char *str = s ? strdata(s) : NULL; int opt = lj_lib_checkopt(L, 2, 6, "\5ctype\7numeric\4time\7collate\10monetary\1\377\3all"); if (opt == 0) opt = LC_CTYPE; else if (opt == 1) opt = LC_NUMERIC; else if (opt == 2) opt = LC_TIME; else if (opt == 3) opt = LC_COLLATE; else if (opt == 4) opt = LC_MONETARY; else if (opt == 6) opt = LC_ALL; lua_pushstring(L, setlocale(opt, str)); return 1; } /* ------------------------------------------------------------------------ */ #include "lj_libdef.h" LUALIB_API int luaopen_os(lua_State *L) { LJ_LIB_REG(L, LUA_OSLIBNAME, os); return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_package.c ================================================ /* ** Package library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lib_package_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #include "lj_err.h" #include "lj_lib.h" /* ------------------------------------------------------------------------ */ /* Error codes for ll_loadfunc. */ #define PACKAGE_ERR_LIB 1 #define PACKAGE_ERR_FUNC 2 #define PACKAGE_ERR_LOAD 3 /* Redefined in platform specific part. */ #define PACKAGE_LIB_FAIL "open" #define setprogdir(L) ((void)0) /* Symbol name prefixes. */ #define SYMPREFIX_CF "luaopen_%s" #define SYMPREFIX_BC "luaJIT_BC_%s" #if LJ_TARGET_DLOPEN #include static void ll_unloadlib(void *lib) { dlclose(lib); } static void *ll_load(lua_State *L, const char *path, int gl) { void *lib = dlopen(path, RTLD_NOW | (gl ? RTLD_GLOBAL : RTLD_LOCAL)); if (lib == NULL) lua_pushstring(L, dlerror()); return lib; } static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) { lua_CFunction f = (lua_CFunction)dlsym(lib, sym); if (f == NULL) lua_pushstring(L, dlerror()); return f; } static const char *ll_bcsym(void *lib, const char *sym) { #if defined(RTLD_DEFAULT) if (lib == NULL) lib = RTLD_DEFAULT; #elif LJ_TARGET_OSX || LJ_TARGET_BSD if (lib == NULL) lib = (void *)(intptr_t)-2; #endif return (const char *)dlsym(lib, sym); } #elif LJ_TARGET_WINDOWS #define WIN32_LEAN_AND_MEAN #ifndef WINVER #define WINVER 0x0500 #endif #include #ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS #define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4 #define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2 BOOL WINAPI GetModuleHandleExA(DWORD, LPCSTR, HMODULE*); #endif #undef setprogdir static void setprogdir(lua_State *L) { char buff[MAX_PATH + 1]; char *lb; DWORD nsize = sizeof(buff); DWORD n = GetModuleFileNameA(NULL, buff, nsize); if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) { luaL_error(L, "unable to get ModuleFileName"); } else { *lb = '\0'; luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); lua_remove(L, -2); /* remove original string */ } } static void pusherror(lua_State *L) { DWORD error = GetLastError(); char buffer[128]; if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buffer, sizeof(buffer), NULL)) lua_pushstring(L, buffer); else lua_pushfstring(L, "system error %d\n", error); } static void ll_unloadlib(void *lib) { FreeLibrary((HINSTANCE)lib); } static void *ll_load(lua_State *L, const char *path, int gl) { HINSTANCE lib = LoadLibraryA(path); if (lib == NULL) pusherror(L); UNUSED(gl); return lib; } static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) { lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); if (f == NULL) pusherror(L); return f; } static const char *ll_bcsym(void *lib, const char *sym) { if (lib) { return (const char *)GetProcAddress((HINSTANCE)lib, sym); } else { HINSTANCE h = GetModuleHandleA(NULL); const char *p = (const char *)GetProcAddress(h, sym); if (p == NULL && GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (const char *)ll_bcsym, &h)) p = (const char *)GetProcAddress(h, sym); return p; } } #else #undef PACKAGE_LIB_FAIL #define PACKAGE_LIB_FAIL "absent" #define DLMSG "dynamic libraries not enabled; no support for target OS" static void ll_unloadlib(void *lib) { UNUSED(lib); } static void *ll_load(lua_State *L, const char *path, int gl) { UNUSED(path); UNUSED(gl); lua_pushliteral(L, DLMSG); return NULL; } static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym) { UNUSED(lib); UNUSED(sym); lua_pushliteral(L, DLMSG); return NULL; } static const char *ll_bcsym(void *lib, const char *sym) { UNUSED(lib); UNUSED(sym); return NULL; } #endif /* ------------------------------------------------------------------------ */ static void **ll_register(lua_State *L, const char *path) { void **plib; lua_pushfstring(L, "LOADLIB: %s", path); lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ if (!lua_isnil(L, -1)) { /* is there an entry? */ plib = (void **)lua_touserdata(L, -1); } else { /* no entry yet; create one */ lua_pop(L, 1); plib = (void **)lua_newuserdata(L, sizeof(void *)); *plib = NULL; luaL_getmetatable(L, "_LOADLIB"); lua_setmetatable(L, -2); lua_pushfstring(L, "LOADLIB: %s", path); lua_pushvalue(L, -2); lua_settable(L, LUA_REGISTRYINDEX); } return plib; } static const char *mksymname(lua_State *L, const char *modname, const char *prefix) { const char *funcname; const char *mark = strchr(modname, *LUA_IGMARK); if (mark) modname = mark + 1; funcname = luaL_gsub(L, modname, ".", "_"); funcname = lua_pushfstring(L, prefix, funcname); lua_remove(L, -2); /* remove 'gsub' result */ return funcname; } static int ll_loadfunc(lua_State *L, const char *path, const char *name, int r) { void **reg = ll_register(L, path); if (*reg == NULL) *reg = ll_load(L, path, (*name == '*')); if (*reg == NULL) { return PACKAGE_ERR_LIB; /* Unable to load library. */ } else if (*name == '*') { /* Only load library into global namespace. */ lua_pushboolean(L, 1); return 0; } else { const char *sym = r ? name : mksymname(L, name, SYMPREFIX_CF); lua_CFunction f = ll_sym(L, *reg, sym); if (f) { lua_pushcfunction(L, f); return 0; } if (!r) { const char *bcdata = ll_bcsym(*reg, mksymname(L, name, SYMPREFIX_BC)); lua_pop(L, 1); if (bcdata) { if (luaL_loadbuffer(L, bcdata, ~(size_t)0, name) != 0) return PACKAGE_ERR_LOAD; return 0; } } return PACKAGE_ERR_FUNC; /* Unable to find function. */ } } static int lj_cf_package_loadlib(lua_State *L) { const char *path = luaL_checkstring(L, 1); const char *init = luaL_checkstring(L, 2); int st = ll_loadfunc(L, path, init, 1); if (st == 0) { /* no errors? */ return 1; /* return the loaded function */ } else { /* error; error message is on stack top */ lua_pushnil(L); lua_insert(L, -2); lua_pushstring(L, (st == PACKAGE_ERR_LIB) ? PACKAGE_LIB_FAIL : "init"); return 3; /* return nil, error message, and where */ } } static int lj_cf_package_unloadlib(lua_State *L) { void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); if (*lib) ll_unloadlib(*lib); *lib = NULL; /* mark library as closed */ return 0; } /* ------------------------------------------------------------------------ */ static int readable(const char *filename) { FILE *f = fopen(filename, "r"); /* try to open file */ if (f == NULL) return 0; /* open failed */ fclose(f); return 1; } static const char *pushnexttemplate(lua_State *L, const char *path) { const char *l; while (*path == *LUA_PATHSEP) path++; /* skip separators */ if (*path == '\0') return NULL; /* no more templates */ l = strchr(path, *LUA_PATHSEP); /* find next separator */ if (l == NULL) l = path + strlen(path); lua_pushlstring(L, path, (size_t)(l - path)); /* template */ return l; } static const char *searchpath (lua_State *L, const char *name, const char *path, const char *sep, const char *dirsep) { luaL_Buffer msg; /* to build error message */ luaL_buffinit(L, &msg); if (*sep != '\0') /* non-empty separator? */ name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ while ((path = pushnexttemplate(L, path)) != NULL) { const char *filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ lua_pushfstring(L, "\n\tno file " LUA_QS, filename); lua_remove(L, -2); /* remove file name */ luaL_addvalue(&msg); /* concatenate error msg. entry */ } luaL_pushresult(&msg); /* create error message */ return NULL; /* not found */ } static int lj_cf_package_searchpath(lua_State *L) { const char *f = searchpath(L, luaL_checkstring(L, 1), luaL_checkstring(L, 2), luaL_optstring(L, 3, "."), luaL_optstring(L, 4, LUA_DIRSEP)); if (f != NULL) { return 1; } else { /* error message is on top of the stack */ lua_pushnil(L); lua_insert(L, -2); return 2; /* return nil + error message */ } } static const char *findfile(lua_State *L, const char *name, const char *pname) { const char *path; lua_getfield(L, LUA_ENVIRONINDEX, pname); path = lua_tostring(L, -1); if (path == NULL) luaL_error(L, LUA_QL("package.%s") " must be a string", pname); return searchpath(L, name, path, ".", LUA_DIRSEP); } static void loaderror(lua_State *L, const char *filename) { luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", lua_tostring(L, 1), filename, lua_tostring(L, -1)); } static int lj_cf_package_loader_lua(lua_State *L) { const char *filename; const char *name = luaL_checkstring(L, 1); filename = findfile(L, name, "path"); if (filename == NULL) return 1; /* library not found in this path */ if (luaL_loadfile(L, filename) != 0) loaderror(L, filename); return 1; /* library loaded successfully */ } static int lj_cf_package_loader_c(lua_State *L) { const char *name = luaL_checkstring(L, 1); const char *filename = findfile(L, name, "cpath"); if (filename == NULL) return 1; /* library not found in this path */ if (ll_loadfunc(L, filename, name, 0) != 0) loaderror(L, filename); return 1; /* library loaded successfully */ } static int lj_cf_package_loader_croot(lua_State *L) { const char *filename; const char *name = luaL_checkstring(L, 1); const char *p = strchr(name, '.'); int st; if (p == NULL) return 0; /* is root */ lua_pushlstring(L, name, (size_t)(p - name)); filename = findfile(L, lua_tostring(L, -1), "cpath"); if (filename == NULL) return 1; /* root not found */ if ((st = ll_loadfunc(L, filename, name, 0)) != 0) { if (st != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, name, filename); return 1; /* function not found */ } return 1; } static int lj_cf_package_loader_preload(lua_State *L) { const char *name = luaL_checkstring(L, 1); lua_getfield(L, LUA_ENVIRONINDEX, "preload"); if (!lua_istable(L, -1)) luaL_error(L, LUA_QL("package.preload") " must be a table"); lua_getfield(L, -1, name); if (lua_isnil(L, -1)) { /* Not found? */ const char *bcname = mksymname(L, name, SYMPREFIX_BC); const char *bcdata = ll_bcsym(NULL, bcname); if (bcdata == NULL || luaL_loadbuffer(L, bcdata, ~(size_t)0, name) != 0) lua_pushfstring(L, "\n\tno field package.preload['%s']", name); } return 1; } /* ------------------------------------------------------------------------ */ static const int sentinel_ = 0; #define sentinel ((void *)&sentinel_) static int lj_cf_package_require(lua_State *L) { const char *name = luaL_checkstring(L, 1); int i; lua_settop(L, 1); /* _LOADED table will be at index 2 */ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); lua_getfield(L, 2, name); if (lua_toboolean(L, -1)) { /* is it there? */ if (lua_touserdata(L, -1) == sentinel) /* check loops */ luaL_error(L, "loop or previous error loading module " LUA_QS, name); return 1; /* package is already loaded */ } /* else must load it; iterate over available loaders */ lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); if (!lua_istable(L, -1)) luaL_error(L, LUA_QL("package.loaders") " must be a table"); lua_pushliteral(L, ""); /* error message accumulator */ for (i = 1; ; i++) { lua_rawgeti(L, -2, i); /* get a loader */ if (lua_isnil(L, -1)) luaL_error(L, "module " LUA_QS " not found:%s", name, lua_tostring(L, -2)); lua_pushstring(L, name); lua_call(L, 1, 1); /* call it */ if (lua_isfunction(L, -1)) /* did it find module? */ break; /* module loaded successfully */ else if (lua_isstring(L, -1)) /* loader returned error message? */ lua_concat(L, 2); /* accumulate it */ else lua_pop(L, 1); } lua_pushlightuserdata(L, sentinel); lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ lua_pushstring(L, name); /* pass name as argument to module */ lua_call(L, 1, 1); /* run loaded module */ if (!lua_isnil(L, -1)) /* non-nil return? */ lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ lua_getfield(L, 2, name); if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ lua_pushboolean(L, 1); /* use true as result */ lua_pushvalue(L, -1); /* extra copy to be returned */ lua_setfield(L, 2, name); /* _LOADED[name] = true */ } lj_lib_checkfpu(L); return 1; } /* ------------------------------------------------------------------------ */ static void setfenv(lua_State *L) { lua_Debug ar; if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ lua_iscfunction(L, -1)) luaL_error(L, LUA_QL("module") " not called from a Lua function"); lua_pushvalue(L, -2); lua_setfenv(L, -2); lua_pop(L, 1); } static void dooptions(lua_State *L, int n) { int i; for (i = 2; i <= n; i++) { lua_pushvalue(L, i); /* get option (a function) */ lua_pushvalue(L, -2); /* module */ lua_call(L, 1, 0); } } static void modinit(lua_State *L, const char *modname) { const char *dot; lua_pushvalue(L, -1); lua_setfield(L, -2, "_M"); /* module._M = module */ lua_pushstring(L, modname); lua_setfield(L, -2, "_NAME"); dot = strrchr(modname, '.'); /* look for last dot in module name */ if (dot == NULL) dot = modname; else dot++; /* set _PACKAGE as package name (full module name minus last part) */ lua_pushlstring(L, modname, (size_t)(dot - modname)); lua_setfield(L, -2, "_PACKAGE"); } static int lj_cf_package_module(lua_State *L) { const char *modname = luaL_checkstring(L, 1); int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ if (!lua_istable(L, -1)) { /* not found? */ lua_pop(L, 1); /* remove previous result */ /* try global variable (and create one if it does not exist) */ if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) lj_err_callerv(L, LJ_ERR_BADMODN, modname); lua_pushvalue(L, -1); lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ } /* check whether table already has a _NAME field */ lua_getfield(L, -1, "_NAME"); if (!lua_isnil(L, -1)) { /* is table an initialized module? */ lua_pop(L, 1); } else { /* no; initialize it */ lua_pop(L, 1); modinit(L, modname); } lua_pushvalue(L, -1); setfenv(L); dooptions(L, loaded - 1); return 0; } static int lj_cf_package_seeall(lua_State *L) { luaL_checktype(L, 1, LUA_TTABLE); if (!lua_getmetatable(L, 1)) { lua_createtable(L, 0, 1); /* create new metatable */ lua_pushvalue(L, -1); lua_setmetatable(L, 1); } lua_pushvalue(L, LUA_GLOBALSINDEX); lua_setfield(L, -2, "__index"); /* mt.__index = _G */ return 0; } /* ------------------------------------------------------------------------ */ #define AUXMARK "\1" static void setpath(lua_State *L, const char *fieldname, const char *envname, const char *def, int noenv) { #if LJ_TARGET_CONSOLE const char *path = NULL; UNUSED(envname); #else const char *path = getenv(envname); #endif if (path == NULL || noenv) { lua_pushstring(L, def); } else { path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, LUA_PATHSEP AUXMARK LUA_PATHSEP); luaL_gsub(L, path, AUXMARK, def); lua_remove(L, -2); } setprogdir(L); lua_setfield(L, -2, fieldname); } static const luaL_Reg package_lib[] = { { "loadlib", lj_cf_package_loadlib }, { "searchpath", lj_cf_package_searchpath }, { "seeall", lj_cf_package_seeall }, { NULL, NULL } }; static const luaL_Reg package_global[] = { { "module", lj_cf_package_module }, { "require", lj_cf_package_require }, { NULL, NULL } }; static const lua_CFunction package_loaders[] = { lj_cf_package_loader_preload, lj_cf_package_loader_lua, lj_cf_package_loader_c, lj_cf_package_loader_croot, NULL }; LUALIB_API int luaopen_package(lua_State *L) { int i; int noenv; luaL_newmetatable(L, "_LOADLIB"); lj_lib_pushcf(L, lj_cf_package_unloadlib, 1); lua_setfield(L, -2, "__gc"); luaL_register(L, LUA_LOADLIBNAME, package_lib); lua_pushvalue(L, -1); lua_replace(L, LUA_ENVIRONINDEX); lua_createtable(L, sizeof(package_loaders)/sizeof(package_loaders[0])-1, 0); for (i = 0; package_loaders[i] != NULL; i++) { lj_lib_pushcf(L, package_loaders[i], 1); lua_rawseti(L, -2, i+1); } lua_setfield(L, -2, "loaders"); lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); noenv = lua_toboolean(L, -1); lua_pop(L, 1); setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT, noenv); setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT, noenv); lua_pushliteral(L, LUA_PATH_CONFIG); lua_setfield(L, -2, "config"); luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); lua_setfield(L, -2, "loaded"); luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 4); lua_setfield(L, -2, "preload"); lua_pushvalue(L, LUA_GLOBALSINDEX); luaL_register(L, NULL, package_global); lua_pop(L, 1); return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lib_string.c ================================================ /* ** String library. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #include #define lib_string_c #define LUA_LIB #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_meta.h" #include "lj_state.h" #include "lj_ff.h" #include "lj_bcdump.h" #include "lj_char.h" #include "lj_lib.h" /* ------------------------------------------------------------------------ */ #define LJLIB_MODULE_string LJLIB_ASM(string_len) LJLIB_REC(.) { lj_lib_checkstr(L, 1); return FFH_RETRY; } LJLIB_ASM(string_byte) LJLIB_REC(string_range 0) { GCstr *s = lj_lib_checkstr(L, 1); int32_t len = (int32_t)s->len; int32_t start = lj_lib_optint(L, 2, 1); int32_t stop = lj_lib_optint(L, 3, start); int32_t n, i; const unsigned char *p; if (stop < 0) stop += len+1; if (start < 0) start += len+1; if (start <= 0) start = 1; if (stop > len) stop = len; if (start > stop) return FFH_RES(0); /* Empty interval: return no results. */ start--; n = stop - start; if ((uint32_t)n > LUAI_MAXCSTACK) lj_err_caller(L, LJ_ERR_STRSLC); lj_state_checkstack(L, (MSize)n); p = (const unsigned char *)strdata(s) + start; for (i = 0; i < n; i++) setintV(L->base + i-1, p[i]); return FFH_RES(n); } LJLIB_ASM(string_char) { int i, nargs = (int)(L->top - L->base); char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, (size_t)nargs); for (i = 1; i <= nargs; i++) { int32_t k = lj_lib_checkint(L, i); if (!checku8(k)) lj_err_arg(L, i, LJ_ERR_BADVAL); buf[i-1] = (char)k; } setstrV(L, L->base-1, lj_str_new(L, buf, (size_t)nargs)); return FFH_RES(1); } LJLIB_ASM(string_sub) LJLIB_REC(string_range 1) { lj_lib_checkstr(L, 1); lj_lib_checkint(L, 2); setintV(L->base+2, lj_lib_optint(L, 3, -1)); return FFH_RETRY; } LJLIB_ASM(string_rep) { GCstr *s = lj_lib_checkstr(L, 1); int32_t k = lj_lib_checkint(L, 2); GCstr *sep = lj_lib_optstr(L, 3); int32_t len = (int32_t)s->len; global_State *g = G(L); int64_t tlen; const char *src; char *buf; if (k <= 0) { empty: setstrV(L, L->base-1, &g->strempty); return FFH_RES(1); } if (sep) { tlen = (int64_t)len + sep->len; if (tlen > LJ_MAX_STR) lj_err_caller(L, LJ_ERR_STROV); tlen *= k; if (tlen > LJ_MAX_STR) lj_err_caller(L, LJ_ERR_STROV); } else { tlen = (int64_t)k * len; if (tlen > LJ_MAX_STR) lj_err_caller(L, LJ_ERR_STROV); } if (tlen == 0) goto empty; buf = lj_str_needbuf(L, &g->tmpbuf, (MSize)tlen); src = strdata(s); if (sep) { tlen -= sep->len; /* Ignore trailing separator. */ if (k > 1) { /* Paste one string and one separator. */ int32_t i; i = 0; while (i < len) *buf++ = src[i++]; src = strdata(sep); len = sep->len; i = 0; while (i < len) *buf++ = src[i++]; src = g->tmpbuf.buf; len += s->len; k--; /* Now copy that k-1 times. */ } } do { int32_t i = 0; do { *buf++ = src[i++]; } while (i < len); } while (--k > 0); setstrV(L, L->base-1, lj_str_new(L, g->tmpbuf.buf, (size_t)tlen)); return FFH_RES(1); } LJLIB_ASM(string_reverse) { GCstr *s = lj_lib_checkstr(L, 1); lj_str_needbuf(L, &G(L)->tmpbuf, s->len); return FFH_RETRY; } LJLIB_ASM_(string_lower) LJLIB_ASM_(string_upper) /* ------------------------------------------------------------------------ */ static int writer_buf(lua_State *L, const void *p, size_t size, void *b) { luaL_addlstring((luaL_Buffer *)b, (const char *)p, size); UNUSED(L); return 0; } LJLIB_CF(string_dump) { GCfunc *fn = lj_lib_checkfunc(L, 1); int strip = L->base+1 < L->top && tvistruecond(L->base+1); luaL_Buffer b; L->top = L->base+1; luaL_buffinit(L, &b); if (!isluafunc(fn) || lj_bcwrite(L, funcproto(fn), writer_buf, &b, strip)) lj_err_caller(L, LJ_ERR_STRDUMP); luaL_pushresult(&b); return 1; } /* ------------------------------------------------------------------------ */ /* macro to `unsign' a character */ #define uchar(c) ((unsigned char)(c)) #define CAP_UNFINISHED (-1) #define CAP_POSITION (-2) typedef struct MatchState { const char *src_init; /* init of source string */ const char *src_end; /* end (`\0') of source string */ lua_State *L; int level; /* total number of captures (finished or unfinished) */ int depth; struct { const char *init; ptrdiff_t len; } capture[LUA_MAXCAPTURES]; } MatchState; #define L_ESC '%' #define SPECIALS "^$*+?.([%-" static int check_capture(MatchState *ms, int l) { l -= '1'; if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) lj_err_caller(ms->L, LJ_ERR_STRCAPI); return l; } static int capture_to_close(MatchState *ms) { int level = ms->level; for (level--; level>=0; level--) if (ms->capture[level].len == CAP_UNFINISHED) return level; lj_err_caller(ms->L, LJ_ERR_STRPATC); return 0; /* unreachable */ } static const char *classend(MatchState *ms, const char *p) { switch (*p++) { case L_ESC: if (*p == '\0') lj_err_caller(ms->L, LJ_ERR_STRPATE); return p+1; case '[': if (*p == '^') p++; do { /* look for a `]' */ if (*p == '\0') lj_err_caller(ms->L, LJ_ERR_STRPATM); if (*(p++) == L_ESC && *p != '\0') p++; /* skip escapes (e.g. `%]') */ } while (*p != ']'); return p+1; default: return p; } } static const unsigned char match_class_map[32] = { 0,LJ_CHAR_ALPHA,0,LJ_CHAR_CNTRL,LJ_CHAR_DIGIT,0,0,LJ_CHAR_GRAPH,0,0,0,0, LJ_CHAR_LOWER,0,0,0,LJ_CHAR_PUNCT,0,0,LJ_CHAR_SPACE,0, LJ_CHAR_UPPER,0,LJ_CHAR_ALNUM,LJ_CHAR_XDIGIT,0,0,0,0,0,0,0 }; static int match_class(int c, int cl) { if ((cl & 0xc0) == 0x40) { int t = match_class_map[(cl&0x1f)]; if (t) { t = lj_char_isa(c, t); return (cl & 0x20) ? t : !t; } if (cl == 'z') return c == 0; if (cl == 'Z') return c != 0; } return (cl == c); } static int matchbracketclass(int c, const char *p, const char *ec) { int sig = 1; if (*(p+1) == '^') { sig = 0; p++; /* skip the `^' */ } while (++p < ec) { if (*p == L_ESC) { p++; if (match_class(c, uchar(*p))) return sig; } else if ((*(p+1) == '-') && (p+2 < ec)) { p+=2; if (uchar(*(p-2)) <= c && c <= uchar(*p)) return sig; } else if (uchar(*p) == c) return sig; } return !sig; } static int singlematch(int c, const char *p, const char *ep) { switch (*p) { case '.': return 1; /* matches any char */ case L_ESC: return match_class(c, uchar(*(p+1))); case '[': return matchbracketclass(c, p, ep-1); default: return (uchar(*p) == c); } } static const char *match(MatchState *ms, const char *s, const char *p); static const char *matchbalance(MatchState *ms, const char *s, const char *p) { if (*p == 0 || *(p+1) == 0) lj_err_caller(ms->L, LJ_ERR_STRPATU); if (*s != *p) { return NULL; } else { int b = *p; int e = *(p+1); int cont = 1; while (++s < ms->src_end) { if (*s == e) { if (--cont == 0) return s+1; } else if (*s == b) { cont++; } } } return NULL; /* string ends out of balance */ } static const char *max_expand(MatchState *ms, const char *s, const char *p, const char *ep) { ptrdiff_t i = 0; /* counts maximum expand for item */ while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) i++; /* keeps trying to match with the maximum repetitions */ while (i>=0) { const char *res = match(ms, (s+i), ep+1); if (res) return res; i--; /* else didn't match; reduce 1 repetition to try again */ } return NULL; } static const char *min_expand(MatchState *ms, const char *s, const char *p, const char *ep) { for (;;) { const char *res = match(ms, s, ep+1); if (res != NULL) return res; else if (ssrc_end && singlematch(uchar(*s), p, ep)) s++; /* try with one more repetition */ else return NULL; } } static const char *start_capture(MatchState *ms, const char *s, const char *p, int what) { const char *res; int level = ms->level; if (level >= LUA_MAXCAPTURES) lj_err_caller(ms->L, LJ_ERR_STRCAPN); ms->capture[level].init = s; ms->capture[level].len = what; ms->level = level+1; if ((res=match(ms, s, p)) == NULL) /* match failed? */ ms->level--; /* undo capture */ return res; } static const char *end_capture(MatchState *ms, const char *s, const char *p) { int l = capture_to_close(ms); const char *res; ms->capture[l].len = s - ms->capture[l].init; /* close capture */ if ((res = match(ms, s, p)) == NULL) /* match failed? */ ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ return res; } static const char *match_capture(MatchState *ms, const char *s, int l) { size_t len; l = check_capture(ms, l); len = (size_t)ms->capture[l].len; if ((size_t)(ms->src_end-s) >= len && memcmp(ms->capture[l].init, s, len) == 0) return s+len; else return NULL; } static const char *match(MatchState *ms, const char *s, const char *p) { if (++ms->depth > LJ_MAX_XLEVEL) lj_err_caller(ms->L, LJ_ERR_STRPATX); init: /* using goto's to optimize tail recursion */ switch (*p) { case '(': /* start capture */ if (*(p+1) == ')') /* position capture? */ s = start_capture(ms, s, p+2, CAP_POSITION); else s = start_capture(ms, s, p+1, CAP_UNFINISHED); break; case ')': /* end capture */ s = end_capture(ms, s, p+1); break; case L_ESC: switch (*(p+1)) { case 'b': /* balanced string? */ s = matchbalance(ms, s, p+2); if (s == NULL) break; p+=4; goto init; /* else s = match(ms, s, p+4); */ case 'f': { /* frontier? */ const char *ep; char previous; p += 2; if (*p != '[') lj_err_caller(ms->L, LJ_ERR_STRPATB); ep = classend(ms, p); /* points to what is next */ previous = (s == ms->src_init) ? '\0' : *(s-1); if (matchbracketclass(uchar(previous), p, ep-1) || !matchbracketclass(uchar(*s), p, ep-1)) { s = NULL; break; } p=ep; goto init; /* else s = match(ms, s, ep); */ } default: if (lj_char_isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ s = match_capture(ms, s, uchar(*(p+1))); if (s == NULL) break; p+=2; goto init; /* else s = match(ms, s, p+2) */ } goto dflt; /* case default */ } break; case '\0': /* end of pattern */ break; /* match succeeded */ case '$': /* is the `$' the last char in pattern? */ if (*(p+1) != '\0') goto dflt; if (s != ms->src_end) s = NULL; /* check end of string */ break; default: dflt: { /* it is a pattern item */ const char *ep = classend(ms, p); /* points to what is next */ int m = ssrc_end && singlematch(uchar(*s), p, ep); switch (*ep) { case '?': { /* optional */ const char *res; if (m && ((res=match(ms, s+1, ep+1)) != NULL)) { s = res; break; } p=ep+1; goto init; /* else s = match(ms, s, ep+1); */ } case '*': /* 0 or more repetitions */ s = max_expand(ms, s, p, ep); break; case '+': /* 1 or more repetitions */ s = (m ? max_expand(ms, s+1, p, ep) : NULL); break; case '-': /* 0 or more repetitions (minimum) */ s = min_expand(ms, s, p, ep); break; default: if (m) { s++; p=ep; goto init; } /* else s = match(ms, s+1, ep); */ s = NULL; break; } break; } } ms->depth--; return s; } static const char *lmemfind(const char *s1, size_t l1, const char *s2, size_t l2) { if (l2 == 0) { return s1; /* empty strings are everywhere */ } else if (l2 > l1) { return NULL; /* avoids a negative `l1' */ } else { const char *init; /* to search for a `*s2' inside `s1' */ l2--; /* 1st char will be checked by `memchr' */ l1 = l1-l2; /* `s2' cannot be found after that */ while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { init++; /* 1st char is already checked */ if (memcmp(init, s2+1, l2) == 0) { return init-1; } else { /* correct `l1' and `s1' to try again */ l1 -= (size_t)(init-s1); s1 = init; } } return NULL; /* not found */ } } static void push_onecapture(MatchState *ms, int i, const char *s, const char *e) { if (i >= ms->level) { if (i == 0) /* ms->level == 0, too */ lua_pushlstring(ms->L, s, (size_t)(e - s)); /* add whole match */ else lj_err_caller(ms->L, LJ_ERR_STRCAPI); } else { ptrdiff_t l = ms->capture[i].len; if (l == CAP_UNFINISHED) lj_err_caller(ms->L, LJ_ERR_STRCAPU); if (l == CAP_POSITION) lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); else lua_pushlstring(ms->L, ms->capture[i].init, (size_t)l); } } static int push_captures(MatchState *ms, const char *s, const char *e) { int i; int nlevels = (ms->level == 0 && s) ? 1 : ms->level; luaL_checkstack(ms->L, nlevels, "too many captures"); for (i = 0; i < nlevels; i++) push_onecapture(ms, i, s, e); return nlevels; /* number of strings pushed */ } static ptrdiff_t posrelat(ptrdiff_t pos, size_t len) { /* relative string position: negative means back from end */ if (pos < 0) pos += (ptrdiff_t)len + 1; return (pos >= 0) ? pos : 0; } static int str_find_aux(lua_State *L, int find) { size_t l1, l2; const char *s = luaL_checklstring(L, 1, &l1); const char *p = luaL_checklstring(L, 2, &l2); ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; if (init < 0) { init = 0; } else if ((size_t)(init) > l1) { #if LJ_52 setnilV(L->top-1); return 1; #else init = (ptrdiff_t)l1; #endif } if (find && (lua_toboolean(L, 4) || /* explicit request? */ strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ /* do a plain search */ const char *s2 = lmemfind(s+init, l1-(size_t)init, p, l2); if (s2) { lua_pushinteger(L, s2-s+1); lua_pushinteger(L, s2-s+(ptrdiff_t)l2); return 2; } } else { MatchState ms; int anchor = (*p == '^') ? (p++, 1) : 0; const char *s1=s+init; ms.L = L; ms.src_init = s; ms.src_end = s+l1; do { const char *res; ms.level = ms.depth = 0; if ((res=match(&ms, s1, p)) != NULL) { if (find) { lua_pushinteger(L, s1-s+1); /* start */ lua_pushinteger(L, res-s); /* end */ return push_captures(&ms, NULL, 0) + 2; } else { return push_captures(&ms, s1, res); } } } while (s1++ < ms.src_end && !anchor); } lua_pushnil(L); /* not found */ return 1; } LJLIB_CF(string_find) { return str_find_aux(L, 1); } LJLIB_CF(string_match) { return str_find_aux(L, 0); } LJLIB_NOREG LJLIB_CF(string_gmatch_aux) { const char *p = strVdata(lj_lib_upvalue(L, 2)); GCstr *str = strV(lj_lib_upvalue(L, 1)); const char *s = strdata(str); TValue *tvpos = lj_lib_upvalue(L, 3); const char *src = s + tvpos->u32.lo; MatchState ms; ms.L = L; ms.src_init = s; ms.src_end = s + str->len; for (; src <= ms.src_end; src++) { const char *e; ms.level = ms.depth = 0; if ((e = match(&ms, src, p)) != NULL) { int32_t pos = (int32_t)(e - s); if (e == src) pos++; /* Ensure progress for empty match. */ tvpos->u32.lo = (uint32_t)pos; return push_captures(&ms, src, e); } } return 0; /* not found */ } LJLIB_CF(string_gmatch) { lj_lib_checkstr(L, 1); lj_lib_checkstr(L, 2); L->top = L->base+3; (L->top-1)->u64 = 0; lj_lib_pushcc(L, lj_cf_string_gmatch_aux, FF_string_gmatch_aux, 3); return 1; } static void add_s(MatchState *ms, luaL_Buffer *b, const char *s, const char *e) { size_t l, i; const char *news = lua_tolstring(ms->L, 3, &l); for (i = 0; i < l; i++) { if (news[i] != L_ESC) { luaL_addchar(b, news[i]); } else { i++; /* skip ESC */ if (!lj_char_isdigit(uchar(news[i]))) { luaL_addchar(b, news[i]); } else if (news[i] == '0') { luaL_addlstring(b, s, (size_t)(e - s)); } else { push_onecapture(ms, news[i] - '1', s, e); luaL_addvalue(b); /* add capture to accumulated result */ } } } } static void add_value(MatchState *ms, luaL_Buffer *b, const char *s, const char *e) { lua_State *L = ms->L; switch (lua_type(L, 3)) { case LUA_TNUMBER: case LUA_TSTRING: { add_s(ms, b, s, e); return; } case LUA_TFUNCTION: { int n; lua_pushvalue(L, 3); n = push_captures(ms, s, e); lua_call(L, n, 1); break; } case LUA_TTABLE: { push_onecapture(ms, 0, s, e); lua_gettable(L, 3); break; } } if (!lua_toboolean(L, -1)) { /* nil or false? */ lua_pop(L, 1); lua_pushlstring(L, s, (size_t)(e - s)); /* keep original text */ } else if (!lua_isstring(L, -1)) { lj_err_callerv(L, LJ_ERR_STRGSRV, luaL_typename(L, -1)); } luaL_addvalue(b); /* add result to accumulator */ } LJLIB_CF(string_gsub) { size_t srcl; const char *src = luaL_checklstring(L, 1, &srcl); const char *p = luaL_checkstring(L, 2); int tr = lua_type(L, 3); int max_s = luaL_optint(L, 4, (int)(srcl+1)); int anchor = (*p == '^') ? (p++, 1) : 0; int n = 0; MatchState ms; luaL_Buffer b; if (!(tr == LUA_TNUMBER || tr == LUA_TSTRING || tr == LUA_TFUNCTION || tr == LUA_TTABLE)) lj_err_arg(L, 3, LJ_ERR_NOSFT); luaL_buffinit(L, &b); ms.L = L; ms.src_init = src; ms.src_end = src+srcl; while (n < max_s) { const char *e; ms.level = ms.depth = 0; e = match(&ms, src, p); if (e) { n++; add_value(&ms, &b, src, e); } if (e && e>src) /* non empty match? */ src = e; /* skip it */ else if (src < ms.src_end) luaL_addchar(&b, *src++); else break; if (anchor) break; } luaL_addlstring(&b, src, (size_t)(ms.src_end-src)); luaL_pushresult(&b); lua_pushinteger(L, n); /* number of substitutions */ return 2; } /* ------------------------------------------------------------------------ */ /* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ #define MAX_FMTITEM 512 /* valid flags in a format specification */ #define FMT_FLAGS "-+ #0" /* ** maximum size of each format specification (such as '%-099.99d') ** (+10 accounts for %99.99x plus margin of error) */ #define MAX_FMTSPEC (sizeof(FMT_FLAGS) + sizeof(LUA_INTFRMLEN) + 10) static void addquoted(lua_State *L, luaL_Buffer *b, int arg) { GCstr *str = lj_lib_checkstr(L, arg); int32_t len = (int32_t)str->len; const char *s = strdata(str); luaL_addchar(b, '"'); while (len--) { uint32_t c = uchar(*s); if (c == '"' || c == '\\' || c == '\n') { luaL_addchar(b, '\\'); } else if (lj_char_iscntrl(c)) { /* This can only be 0-31 or 127. */ uint32_t d; luaL_addchar(b, '\\'); if (c >= 100 || lj_char_isdigit(uchar(s[1]))) { luaL_addchar(b, '0'+(c >= 100)); if (c >= 100) c -= 100; goto tens; } else if (c >= 10) { tens: d = (c * 205) >> 11; c -= d * 10; luaL_addchar(b, '0'+d); } c += '0'; } luaL_addchar(b, c); s++; } luaL_addchar(b, '"'); } static const char *scanformat(lua_State *L, const char *strfrmt, char *form) { const char *p = strfrmt; while (*p != '\0' && strchr(FMT_FLAGS, *p) != NULL) p++; /* skip flags */ if ((size_t)(p - strfrmt) >= sizeof(FMT_FLAGS)) lj_err_caller(L, LJ_ERR_STRFMTR); if (lj_char_isdigit(uchar(*p))) p++; /* skip width */ if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */ if (*p == '.') { p++; if (lj_char_isdigit(uchar(*p))) p++; /* skip precision */ if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */ } if (lj_char_isdigit(uchar(*p))) lj_err_caller(L, LJ_ERR_STRFMTW); *(form++) = '%'; strncpy(form, strfrmt, (size_t)(p - strfrmt + 1)); form += p - strfrmt + 1; *form = '\0'; return p; } static void addintlen(char *form) { size_t l = strlen(form); char spec = form[l - 1]; strcpy(form + l - 1, LUA_INTFRMLEN); form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; } static unsigned LUA_INTFRM_T num2intfrm(lua_State *L, int arg) { if (sizeof(LUA_INTFRM_T) == 4) { return (LUA_INTFRM_T)lj_lib_checkbit(L, arg); } else { cTValue *o; lj_lib_checknumber(L, arg); o = L->base+arg-1; if (tvisint(o)) return (LUA_INTFRM_T)intV(o); else return (LUA_INTFRM_T)numV(o); } } static unsigned LUA_INTFRM_T num2uintfrm(lua_State *L, int arg) { if (sizeof(LUA_INTFRM_T) == 4) { return (unsigned LUA_INTFRM_T)lj_lib_checkbit(L, arg); } else { cTValue *o; lj_lib_checknumber(L, arg); o = L->base+arg-1; if (tvisint(o)) return (unsigned LUA_INTFRM_T)intV(o); else if ((int32_t)o->u32.hi < 0) return (unsigned LUA_INTFRM_T)(LUA_INTFRM_T)numV(o); else return (unsigned LUA_INTFRM_T)numV(o); } } static GCstr *meta_tostring(lua_State *L, int arg) { TValue *o = L->base+arg-1; cTValue *mo; lua_assert(o < L->top); /* Caller already checks for existence. */ if (LJ_LIKELY(tvisstr(o))) return strV(o); if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { copyTV(L, L->top++, mo); copyTV(L, L->top++, o); lua_call(L, 1, 1); L->top--; if (tvisstr(L->top)) return strV(L->top); o = L->base+arg-1; copyTV(L, o, L->top); } if (tvisnumber(o)) { return lj_str_fromnumber(L, o); } else if (tvisnil(o)) { return lj_str_newlit(L, "nil"); } else if (tvisfalse(o)) { return lj_str_newlit(L, "false"); } else if (tvistrue(o)) { return lj_str_newlit(L, "true"); } else { if (tvisfunc(o) && isffunc(funcV(o))) lj_str_pushf(L, "function: builtin#%d", funcV(o)->c.ffid); else lj_str_pushf(L, "%s: %p", lj_typename(o), lua_topointer(L, arg)); L->top--; return strV(L->top); } } LJLIB_CF(string_format) { int arg = 1, top = (int)(L->top - L->base); GCstr *fmt = lj_lib_checkstr(L, arg); const char *strfrmt = strdata(fmt); const char *strfrmt_end = strfrmt + fmt->len; luaL_Buffer b; luaL_buffinit(L, &b); while (strfrmt < strfrmt_end) { if (*strfrmt != L_ESC) { luaL_addchar(&b, *strfrmt++); } else if (*++strfrmt == L_ESC) { luaL_addchar(&b, *strfrmt++); /* %% */ } else { /* format item */ char form[MAX_FMTSPEC]; /* to store the format (`%...') */ char buff[MAX_FMTITEM]; /* to store the formatted item */ if (++arg > top) luaL_argerror(L, arg, lj_obj_typename[0]); strfrmt = scanformat(L, strfrmt, form); switch (*strfrmt++) { case 'c': sprintf(buff, form, lj_lib_checkint(L, arg)); break; case 'd': case 'i': addintlen(form); sprintf(buff, form, num2intfrm(L, arg)); break; case 'o': case 'u': case 'x': case 'X': addintlen(form); sprintf(buff, form, num2uintfrm(L, arg)); break; case 'e': case 'E': case 'f': case 'g': case 'G': case 'a': case 'A': { TValue tv; tv.n = lj_lib_checknum(L, arg); if (LJ_UNLIKELY((tv.u32.hi << 1) >= 0xffe00000)) { /* Canonicalize output of non-finite values. */ char *p, nbuf[LJ_STR_NUMBUF]; size_t len = lj_str_bufnum(nbuf, &tv); if (strfrmt[-1] < 'a') { nbuf[len-3] = nbuf[len-3] - 0x20; nbuf[len-2] = nbuf[len-2] - 0x20; nbuf[len-1] = nbuf[len-1] - 0x20; } nbuf[len] = '\0'; for (p = form; *p < 'A' && *p != '.'; p++) ; *p++ = 's'; *p = '\0'; sprintf(buff, form, nbuf); break; } sprintf(buff, form, (double)tv.n); break; } case 'q': addquoted(L, &b, arg); continue; case 'p': lj_str_pushf(L, "%p", lua_topointer(L, arg)); luaL_addvalue(&b); continue; case 's': { GCstr *str = meta_tostring(L, arg); if (!strchr(form, '.') && str->len >= 100) { /* no precision and string is too long to be formatted; keep original string */ setstrV(L, L->top++, str); luaL_addvalue(&b); continue; } sprintf(buff, form, strdata(str)); break; } default: lj_err_callerv(L, LJ_ERR_STRFMTO, *(strfrmt -1)); break; } luaL_addlstring(&b, buff, strlen(buff)); } } luaL_pushresult(&b); return 1; } /* ------------------------------------------------------------------------ */ #include "lj_libdef.h" LUALIB_API int luaopen_string(lua_State *L) { GCtab *mt; global_State *g; LJ_LIB_REG(L, LUA_STRLIBNAME, string); #if defined(LUA_COMPAT_GFIND) && !LJ_52 lua_getfield(L, -1, "gmatch"); lua_setfield(L, -2, "gfind"); #endif mt = lj_tab_new(L, 0, 1); /* NOBARRIER: basemt is a GC root. */ g = G(L); setgcref(basemt_it(g, LJ_TSTR), obj2gco(mt)); settabV(L, lj_tab_setstr(L, mt, mmname_str(g, MM_index)), tabV(L->top-1)); mt->nomm = (uint8_t)(~(1u<top, func); setintV(L->top+1, i); val = lj_tab_getint(t, (int32_t)i); if (val) { copyTV(L, L->top+2, val); } else { setnilV(L->top+2); } L->top += 3; lua_call(L, 2, 1); if (!tvisnil(L->top-1)) return 1; L->top--; } return 0; } LJLIB_CF(table_foreach) { GCtab *t = lj_lib_checktab(L, 1); GCfunc *func = lj_lib_checkfunc(L, 2); L->top = L->base+3; setnilV(L->top-1); while (lj_tab_next(L, t, L->top-1)) { copyTV(L, L->top+2, L->top); copyTV(L, L->top+1, L->top-1); setfuncV(L, L->top, func); L->top += 3; lua_call(L, 2, 1); if (!tvisnil(L->top-1)) return 1; L->top--; } return 0; } LJLIB_ASM(table_getn) LJLIB_REC(.) { lj_lib_checktab(L, 1); return FFH_UNREACHABLE; } LJLIB_CF(table_maxn) { GCtab *t = lj_lib_checktab(L, 1); TValue *array = tvref(t->array); Node *node; lua_Number m = 0; ptrdiff_t i; for (i = (ptrdiff_t)t->asize - 1; i >= 0; i--) if (!tvisnil(&array[i])) { m = (lua_Number)(int32_t)i; break; } node = noderef(t->node); for (i = (ptrdiff_t)t->hmask; i >= 0; i--) if (!tvisnil(&node[i].val) && tvisnumber(&node[i].key)) { lua_Number n = numberVnum(&node[i].key); if (n > m) m = n; } setnumV(L->top-1, m); return 1; } LJLIB_CF(table_insert) LJLIB_REC(.) { GCtab *t = lj_lib_checktab(L, 1); int32_t n, i = (int32_t)lj_tab_len(t) + 1; int nargs = (int)((char *)L->top - (char *)L->base); if (nargs != 2*sizeof(TValue)) { if (nargs != 3*sizeof(TValue)) lj_err_caller(L, LJ_ERR_TABINS); /* NOBARRIER: This just moves existing elements around. */ for (n = lj_lib_checkint(L, 2); i > n; i--) { /* The set may invalidate the get pointer, so need to do it first! */ TValue *dst = lj_tab_setint(L, t, i); cTValue *src = lj_tab_getint(t, i-1); if (src) { copyTV(L, dst, src); } else { setnilV(dst); } } i = n; } { TValue *dst = lj_tab_setint(L, t, i); copyTV(L, dst, L->top-1); /* Set new value. */ lj_gc_barriert(L, t, dst); } return 0; } LJLIB_CF(table_remove) LJLIB_REC(.) { GCtab *t = lj_lib_checktab(L, 1); int32_t e = (int32_t)lj_tab_len(t); int32_t pos = lj_lib_optint(L, 2, e); if (!(1 <= pos && pos <= e)) /* Nothing to remove? */ return 0; lua_rawgeti(L, 1, pos); /* Get previous value. */ /* NOBARRIER: This just moves existing elements around. */ for (; pos < e; pos++) { cTValue *src = lj_tab_getint(t, pos+1); TValue *dst = lj_tab_setint(L, t, pos); if (src) { copyTV(L, dst, src); } else { setnilV(dst); } } setnilV(lj_tab_setint(L, t, e)); /* Remove (last) value. */ return 1; /* Return previous value. */ } LJLIB_CF(table_concat) { luaL_Buffer b; GCtab *t = lj_lib_checktab(L, 1); GCstr *sep = lj_lib_optstr(L, 2); MSize seplen = sep ? sep->len : 0; int32_t i = lj_lib_optint(L, 3, 1); int32_t e = L->base+3 < L->top ? lj_lib_checkint(L, 4) : (int32_t)lj_tab_len(t); luaL_buffinit(L, &b); if (i <= e) { for (;;) { cTValue *o; lua_rawgeti(L, 1, i); o = L->top-1; if (!(tvisstr(o) || tvisnumber(o))) lj_err_callerv(L, LJ_ERR_TABCAT, lj_typename(o), i); luaL_addvalue(&b); if (i++ == e) break; if (seplen) luaL_addlstring(&b, strdata(sep), seplen); } } luaL_pushresult(&b); return 1; } /* ------------------------------------------------------------------------ */ static void set2(lua_State *L, int i, int j) { lua_rawseti(L, 1, i); lua_rawseti(L, 1, j); } static int sort_comp(lua_State *L, int a, int b) { if (!lua_isnil(L, 2)) { /* function? */ int res; lua_pushvalue(L, 2); lua_pushvalue(L, a-1); /* -1 to compensate function */ lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ lua_call(L, 2, 1); res = lua_toboolean(L, -1); lua_pop(L, 1); return res; } else { /* a < b? */ return lua_lessthan(L, a, b); } } static void auxsort(lua_State *L, int l, int u) { while (l < u) { /* for tail recursion */ int i, j; /* sort elements a[l], a[(l+u)/2] and a[u] */ lua_rawgeti(L, 1, l); lua_rawgeti(L, 1, u); if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */ set2(L, l, u); /* swap a[l] - a[u] */ else lua_pop(L, 2); if (u-l == 1) break; /* only 2 elements */ i = (l+u)/2; lua_rawgeti(L, 1, i); lua_rawgeti(L, 1, l); if (sort_comp(L, -2, -1)) { /* a[i]= P */ while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { if (i>=u) lj_err_caller(L, LJ_ERR_TABSORT); lua_pop(L, 1); /* remove a[i] */ } /* repeat --j until a[j] <= P */ while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { if (j<=l) lj_err_caller(L, LJ_ERR_TABSORT); lua_pop(L, 1); /* remove a[j] */ } if (jbase+1)) lj_lib_checkfunc(L, 2); auxsort(L, 1, n); return 0; } #if LJ_52 LJLIB_PUSH("n") LJLIB_CF(table_pack) { TValue *array, *base = L->base; MSize i, n = (uint32_t)(L->top - base); GCtab *t = lj_tab_new(L, n ? n+1 : 0, 1); /* NOBARRIER: The table is new (marked white). */ setintV(lj_tab_setstr(L, t, strV(lj_lib_upvalue(L, 1))), (int32_t)n); for (array = tvref(t->array) + 1, i = 0; i < n; i++) copyTV(L, &array[i], &base[i]); settabV(L, base, t); L->top = base+1; lj_gc_check(L); return 1; } #endif /* ------------------------------------------------------------------------ */ #include "lj_libdef.h" LUALIB_API int luaopen_table(lua_State *L) { LJ_LIB_REG(L, LUA_TABLIBNAME, table); #if LJ_52 lua_getglobal(L, "unpack"); lua_setfield(L, -2, "unpack"); #endif return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj.supp ================================================ # Valgrind suppression file for LuaJIT 2.0. { Optimized string compare Memcheck:Addr4 fun:lj_str_cmp } { Optimized string compare Memcheck:Addr1 fun:lj_str_cmp } { Optimized string compare Memcheck:Addr4 fun:lj_str_new } { Optimized string compare Memcheck:Addr1 fun:lj_str_new } { Optimized string compare Memcheck:Cond fun:lj_str_new } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_alloc.c ================================================ /* ** Bundled memory allocator. ** ** Beware: this is a HEAVILY CUSTOMIZED version of dlmalloc. ** The original bears the following remark: ** ** This is a version (aka dlmalloc) of malloc/free/realloc written by ** Doug Lea and released to the public domain, as explained at ** http://creativecommons.org/licenses/publicdomain. ** ** * Version pre-2.8.4 Wed Mar 29 19:46:29 2006 (dl at gee) ** ** No additional copyright is claimed over the customizations. ** Please do NOT bother the original author about this version here! ** ** If you want to use dlmalloc in another project, you should get ** the original from: ftp://gee.cs.oswego.edu/pub/misc/ ** For thread-safe derivatives, take a look at: ** - ptmalloc: http://www.malloc.de/ ** - nedmalloc: http://www.nedprod.com/programs/portable/nedmalloc/ */ #define lj_alloc_c #define LUA_CORE /* To get the mremap prototype. Must be defined before any system includes. */ #if defined(__linux__) && !defined(_GNU_SOURCE) #define _GNU_SOURCE #endif #include "lj_def.h" #include "lj_arch.h" #include "lj_alloc.h" #ifndef LUAJIT_USE_SYSMALLOC #define MAX_SIZE_T (~(size_t)0) #define MALLOC_ALIGNMENT ((size_t)8U) #define DEFAULT_GRANULARITY ((size_t)128U * (size_t)1024U) #define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) #define DEFAULT_MMAP_THRESHOLD ((size_t)128U * (size_t)1024U) #define MAX_RELEASE_CHECK_RATE 255 /* ------------------- size_t and alignment properties -------------------- */ /* The byte and bit size of a size_t */ #define SIZE_T_SIZE (sizeof(size_t)) #define SIZE_T_BITSIZE (sizeof(size_t) << 3) /* Some constants coerced to size_t */ /* Annoying but necessary to avoid errors on some platforms */ #define SIZE_T_ZERO ((size_t)0) #define SIZE_T_ONE ((size_t)1) #define SIZE_T_TWO ((size_t)2) #define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) #define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) #define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) /* The bit mask value corresponding to MALLOC_ALIGNMENT */ #define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) /* the number of bytes to offset an address to align it */ #define align_offset(A)\ ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) /* -------------------------- MMAP support ------------------------------- */ #define MFAIL ((void *)(MAX_SIZE_T)) #define CMFAIL ((char *)(MFAIL)) /* defined for convenience */ #define IS_DIRECT_BIT (SIZE_T_ONE) #if LJ_TARGET_WINDOWS #define WIN32_LEAN_AND_MEAN #include #if LJ_64 /* Undocumented, but hey, that's what we all love so much about Windows. */ typedef long (*PNTAVM)(HANDLE handle, void **addr, ULONG zbits, size_t *size, ULONG alloctype, ULONG prot); static PNTAVM ntavm; /* Number of top bits of the lower 32 bits of an address that must be zero. ** Apparently 0 gives us full 64 bit addresses and 1 gives us the lower 2GB. */ #define NTAVM_ZEROBITS 1 static void INIT_MMAP(void) { ntavm = (PNTAVM)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtAllocateVirtualMemory"); } /* Win64 32 bit MMAP via NtAllocateVirtualMemory. */ static LJ_AINLINE void *CALL_MMAP(size_t size) { DWORD olderr = GetLastError(); void *ptr = NULL; long st = ntavm(INVALID_HANDLE_VALUE, &ptr, NTAVM_ZEROBITS, &size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); SetLastError(olderr); return st == 0 ? ptr : MFAIL; } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ static LJ_AINLINE void *DIRECT_MMAP(size_t size) { DWORD olderr = GetLastError(); void *ptr = NULL; long st = ntavm(INVALID_HANDLE_VALUE, &ptr, NTAVM_ZEROBITS, &size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, PAGE_READWRITE); SetLastError(olderr); return st == 0 ? ptr : MFAIL; } #else #define INIT_MMAP() ((void)0) /* Win32 MMAP via VirtualAlloc */ static LJ_AINLINE void *CALL_MMAP(size_t size) { DWORD olderr = GetLastError(); void *ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); SetLastError(olderr); return ptr ? ptr : MFAIL; } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ static LJ_AINLINE void *DIRECT_MMAP(size_t size) { DWORD olderr = GetLastError(); void *ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, PAGE_READWRITE); SetLastError(olderr); return ptr ? ptr : MFAIL; } #endif /* This function supports releasing coalesed segments */ static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size) { DWORD olderr = GetLastError(); MEMORY_BASIC_INFORMATION minfo; char *cptr = (char *)ptr; while (size) { if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) return -1; if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || minfo.State != MEM_COMMIT || minfo.RegionSize > size) return -1; if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) return -1; cptr += minfo.RegionSize; size -= minfo.RegionSize; } SetLastError(olderr); return 0; } #else #include #include #define MMAP_PROT (PROT_READ|PROT_WRITE) #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) #define MAP_ANONYMOUS MAP_ANON #endif #define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) #if LJ_64 /* 64 bit mode needs special support for allocating memory in the lower 2GB. */ #if LJ_TARGET_LINUX /* Actually this only gives us max. 1GB in current Linux kernels. */ static LJ_AINLINE void *CALL_MMAP(size_t size) { int olderr = errno; void *ptr = mmap(NULL, size, MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0); errno = olderr; return ptr; } #elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) /* OSX and FreeBSD mmap() use a naive first-fit linear search. ** That's perfect for us. Except that -pagezero_size must be set for OSX, ** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs ** to be reduced to 250MB on FreeBSD. */ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) #include #define MMAP_REGION_START ((uintptr_t)0x10000000) #else #define MMAP_REGION_START ((uintptr_t)0x10000) #endif #define MMAP_REGION_END ((uintptr_t)0x80000000) static LJ_AINLINE void *CALL_MMAP(size_t size) { int olderr = errno; /* Hint for next allocation. Doesn't need to be thread-safe. */ static uintptr_t alloc_hint = MMAP_REGION_START; int retry = 0; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) static int rlimit_modified = 0; if (LJ_UNLIKELY(rlimit_modified == 0)) { struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = MMAP_REGION_START; setrlimit(RLIMIT_DATA, &rlim); /* Ignore result. May fail below. */ rlimit_modified = 1; } #endif for (;;) { void *p = mmap((void *)alloc_hint, size, MMAP_PROT, MMAP_FLAGS, -1, 0); if ((uintptr_t)p >= MMAP_REGION_START && (uintptr_t)p + size < MMAP_REGION_END) { alloc_hint = (uintptr_t)p + size; errno = olderr; return p; } if (p != CMFAIL) munmap(p, size); if (retry) break; retry = 1; alloc_hint = MMAP_REGION_START; } errno = olderr; return CMFAIL; } #else #error "NYI: need an equivalent of MAP_32BIT for this 64 bit OS" #endif #else /* 32 bit mode is easy. */ static LJ_AINLINE void *CALL_MMAP(size_t size) { int olderr = errno; void *ptr = mmap(NULL, size, MMAP_PROT, MMAP_FLAGS, -1, 0); errno = olderr; return ptr; } #endif #define INIT_MMAP() ((void)0) #define DIRECT_MMAP(s) CALL_MMAP(s) static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size) { int olderr = errno; int ret = munmap(ptr, size); errno = olderr; return ret; } #if LJ_TARGET_LINUX /* Need to define _GNU_SOURCE to get the mremap prototype. */ static LJ_AINLINE void *CALL_MREMAP_(void *ptr, size_t osz, size_t nsz, int flags) { int olderr = errno; ptr = mremap(ptr, osz, nsz, flags); errno = olderr; return ptr; } #define CALL_MREMAP(addr, osz, nsz, mv) CALL_MREMAP_((addr), (osz), (nsz), (mv)) #define CALL_MREMAP_NOMOVE 0 #define CALL_MREMAP_MAYMOVE 1 #if LJ_64 #define CALL_MREMAP_MV CALL_MREMAP_NOMOVE #else #define CALL_MREMAP_MV CALL_MREMAP_MAYMOVE #endif #endif #endif #ifndef CALL_MREMAP #define CALL_MREMAP(addr, osz, nsz, mv) ((void)osz, MFAIL) #endif /* ----------------------- Chunk representations ------------------------ */ struct malloc_chunk { size_t prev_foot; /* Size of previous chunk (if free). */ size_t head; /* Size and inuse bits. */ struct malloc_chunk *fd; /* double links -- used only if free. */ struct malloc_chunk *bk; }; typedef struct malloc_chunk mchunk; typedef struct malloc_chunk *mchunkptr; typedef struct malloc_chunk *sbinptr; /* The type of bins of chunks */ typedef size_t bindex_t; /* Described below */ typedef unsigned int binmap_t; /* Described below */ typedef unsigned int flag_t; /* The type of various bit flag sets */ /* ------------------- Chunks sizes and alignments ----------------------- */ #define MCHUNK_SIZE (sizeof(mchunk)) #define CHUNK_OVERHEAD (SIZE_T_SIZE) /* Direct chunks need a second word of overhead ... */ #define DIRECT_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) /* ... and additional padding for fake next-chunk at foot */ #define DIRECT_FOOT_PAD (FOUR_SIZE_T_SIZES) /* The smallest size we can malloc is an aligned minimal chunk */ #define MIN_CHUNK_SIZE\ ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* conversion from malloc headers to user pointers, and back */ #define chunk2mem(p) ((void *)((char *)(p) + TWO_SIZE_T_SIZES)) #define mem2chunk(mem) ((mchunkptr)((char *)(mem) - TWO_SIZE_T_SIZES)) /* chunk associated with aligned address A */ #define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) /* Bounds on request (not chunk) sizes. */ #define MAX_REQUEST ((~MIN_CHUNK_SIZE+1) << 2) #define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) /* pad request bytes into a usable size */ #define pad_request(req) \ (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* pad request, checking for minimum (but not maximum) */ #define request2size(req) \ (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) /* ------------------ Operations on head and foot fields ----------------- */ #define PINUSE_BIT (SIZE_T_ONE) #define CINUSE_BIT (SIZE_T_TWO) #define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) /* Head value for fenceposts */ #define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) /* extraction of fields from head words */ #define cinuse(p) ((p)->head & CINUSE_BIT) #define pinuse(p) ((p)->head & PINUSE_BIT) #define chunksize(p) ((p)->head & ~(INUSE_BITS)) #define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) #define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) /* Treat space at ptr +/- offset as a chunk */ #define chunk_plus_offset(p, s) ((mchunkptr)(((char *)(p)) + (s))) #define chunk_minus_offset(p, s) ((mchunkptr)(((char *)(p)) - (s))) /* Ptr to next or previous physical malloc_chunk. */ #define next_chunk(p) ((mchunkptr)(((char *)(p)) + ((p)->head & ~INUSE_BITS))) #define prev_chunk(p) ((mchunkptr)(((char *)(p)) - ((p)->prev_foot) )) /* extract next chunk's pinuse bit */ #define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) /* Get/set size at footer */ #define get_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot) #define set_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot = (s)) /* Set size, pinuse bit, and foot */ #define set_size_and_pinuse_of_free_chunk(p, s)\ ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) /* Set size, pinuse bit, foot, and clear next pinuse */ #define set_free_with_pinuse(p, s, n)\ (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) #define is_direct(p)\ (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_DIRECT_BIT)) /* Get the internal overhead associated with chunk p */ #define overhead_for(p)\ (is_direct(p)? DIRECT_CHUNK_OVERHEAD : CHUNK_OVERHEAD) /* ---------------------- Overlaid data structures ----------------------- */ struct malloc_tree_chunk { /* The first four fields must be compatible with malloc_chunk */ size_t prev_foot; size_t head; struct malloc_tree_chunk *fd; struct malloc_tree_chunk *bk; struct malloc_tree_chunk *child[2]; struct malloc_tree_chunk *parent; bindex_t index; }; typedef struct malloc_tree_chunk tchunk; typedef struct malloc_tree_chunk *tchunkptr; typedef struct malloc_tree_chunk *tbinptr; /* The type of bins of trees */ /* A little helper macro for trees */ #define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) /* ----------------------------- Segments -------------------------------- */ struct malloc_segment { char *base; /* base address */ size_t size; /* allocated size */ struct malloc_segment *next; /* ptr to next segment */ }; typedef struct malloc_segment msegment; typedef struct malloc_segment *msegmentptr; /* ---------------------------- malloc_state ----------------------------- */ /* Bin types, widths and sizes */ #define NSMALLBINS (32U) #define NTREEBINS (32U) #define SMALLBIN_SHIFT (3U) #define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) #define TREEBIN_SHIFT (8U) #define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) #define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) struct malloc_state { binmap_t smallmap; binmap_t treemap; size_t dvsize; size_t topsize; mchunkptr dv; mchunkptr top; size_t trim_check; size_t release_checks; mchunkptr smallbins[(NSMALLBINS+1)*2]; tbinptr treebins[NTREEBINS]; msegment seg; }; typedef struct malloc_state *mstate; #define is_initialized(M) ((M)->top != 0) /* -------------------------- system alloc setup ------------------------- */ /* page-align a size */ #define page_align(S)\ (((S) + (LJ_PAGESIZE - SIZE_T_ONE)) & ~(LJ_PAGESIZE - SIZE_T_ONE)) /* granularity-align a size */ #define granularity_align(S)\ (((S) + (DEFAULT_GRANULARITY - SIZE_T_ONE))\ & ~(DEFAULT_GRANULARITY - SIZE_T_ONE)) #if LJ_TARGET_WINDOWS #define mmap_align(S) granularity_align(S) #else #define mmap_align(S) page_align(S) #endif /* True if segment S holds address A */ #define segment_holds(S, A)\ ((char *)(A) >= S->base && (char *)(A) < S->base + S->size) /* Return segment holding given address */ static msegmentptr segment_holding(mstate m, char *addr) { msegmentptr sp = &m->seg; for (;;) { if (addr >= sp->base && addr < sp->base + sp->size) return sp; if ((sp = sp->next) == 0) return 0; } } /* Return true if segment contains a segment link */ static int has_segment_link(mstate m, msegmentptr ss) { msegmentptr sp = &m->seg; for (;;) { if ((char *)sp >= ss->base && (char *)sp < ss->base + ss->size) return 1; if ((sp = sp->next) == 0) return 0; } } /* TOP_FOOT_SIZE is padding at the end of a segment, including space that may be needed to place segment records and fenceposts when new noncontiguous segments are added. */ #define TOP_FOOT_SIZE\ (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) /* ---------------------------- Indexing Bins ---------------------------- */ #define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) #define small_index(s) ((s) >> SMALLBIN_SHIFT) #define small_index2size(i) ((i) << SMALLBIN_SHIFT) #define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) /* addressing by index. See above about smallbin repositioning */ #define smallbin_at(M, i) ((sbinptr)((char *)&((M)->smallbins[(i)<<1]))) #define treebin_at(M,i) (&((M)->treebins[i])) /* assign tree index for size S to variable I */ #define compute_tree_index(S, I)\ {\ unsigned int X = (unsigned int)(S >> TREEBIN_SHIFT);\ if (X == 0) {\ I = 0;\ } else if (X > 0xFFFF) {\ I = NTREEBINS-1;\ } else {\ unsigned int K = lj_fls(X);\ I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ }\ } /* Bit representing maximum resolved size in a treebin at i */ #define bit_for_tree_index(i) \ (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) /* Shift placing maximum resolved bit in a treebin at i as sign bit */ #define leftshift_for_tree_index(i) \ ((i == NTREEBINS-1)? 0 : \ ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) /* The size of the smallest chunk held in bin with index i */ #define minsize_for_tree_index(i) \ ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) /* ------------------------ Operations on bin maps ----------------------- */ /* bit corresponding to given index */ #define idx2bit(i) ((binmap_t)(1) << (i)) /* Mark/Clear bits with given index */ #define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) #define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) #define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) #define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) #define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) #define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) /* mask with all bits to left of least bit of x on */ #define left_bits(x) ((x<<1) | (~(x<<1)+1)) /* Set cinuse bit and pinuse bit of next chunk */ #define set_inuse(M,p,s)\ ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) /* Set cinuse and pinuse of this chunk and pinuse of next chunk */ #define set_inuse_and_pinuse(M,p,s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) /* Set size, cinuse and pinuse bit of this chunk */ #define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) /* ----------------------- Operations on smallbins ----------------------- */ /* Link a free chunk into a smallbin */ #define insert_small_chunk(M, P, S) {\ bindex_t I = small_index(S);\ mchunkptr B = smallbin_at(M, I);\ mchunkptr F = B;\ if (!smallmap_is_marked(M, I))\ mark_smallmap(M, I);\ else\ F = B->fd;\ B->fd = P;\ F->bk = P;\ P->fd = F;\ P->bk = B;\ } /* Unlink a chunk from a smallbin */ #define unlink_small_chunk(M, P, S) {\ mchunkptr F = P->fd;\ mchunkptr B = P->bk;\ bindex_t I = small_index(S);\ if (F == B) {\ clear_smallmap(M, I);\ } else {\ F->bk = B;\ B->fd = F;\ }\ } /* Unlink the first chunk from a smallbin */ #define unlink_first_small_chunk(M, B, P, I) {\ mchunkptr F = P->fd;\ if (B == F) {\ clear_smallmap(M, I);\ } else {\ B->fd = F;\ F->bk = B;\ }\ } /* Replace dv node, binning the old one */ /* Used only when dvsize known to be small */ #define replace_dv(M, P, S) {\ size_t DVS = M->dvsize;\ if (DVS != 0) {\ mchunkptr DV = M->dv;\ insert_small_chunk(M, DV, DVS);\ }\ M->dvsize = S;\ M->dv = P;\ } /* ------------------------- Operations on trees ------------------------- */ /* Insert chunk into tree */ #define insert_large_chunk(M, X, S) {\ tbinptr *H;\ bindex_t I;\ compute_tree_index(S, I);\ H = treebin_at(M, I);\ X->index = I;\ X->child[0] = X->child[1] = 0;\ if (!treemap_is_marked(M, I)) {\ mark_treemap(M, I);\ *H = X;\ X->parent = (tchunkptr)H;\ X->fd = X->bk = X;\ } else {\ tchunkptr T = *H;\ size_t K = S << leftshift_for_tree_index(I);\ for (;;) {\ if (chunksize(T) != S) {\ tchunkptr *C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ K <<= 1;\ if (*C != 0) {\ T = *C;\ } else {\ *C = X;\ X->parent = T;\ X->fd = X->bk = X;\ break;\ }\ } else {\ tchunkptr F = T->fd;\ T->fd = F->bk = X;\ X->fd = F;\ X->bk = T;\ X->parent = 0;\ break;\ }\ }\ }\ } #define unlink_large_chunk(M, X) {\ tchunkptr XP = X->parent;\ tchunkptr R;\ if (X->bk != X) {\ tchunkptr F = X->fd;\ R = X->bk;\ F->bk = R;\ R->fd = F;\ } else {\ tchunkptr *RP;\ if (((R = *(RP = &(X->child[1]))) != 0) ||\ ((R = *(RP = &(X->child[0]))) != 0)) {\ tchunkptr *CP;\ while ((*(CP = &(R->child[1])) != 0) ||\ (*(CP = &(R->child[0])) != 0)) {\ R = *(RP = CP);\ }\ *RP = 0;\ }\ }\ if (XP != 0) {\ tbinptr *H = treebin_at(M, X->index);\ if (X == *H) {\ if ((*H = R) == 0) \ clear_treemap(M, X->index);\ } else {\ if (XP->child[0] == X) \ XP->child[0] = R;\ else \ XP->child[1] = R;\ }\ if (R != 0) {\ tchunkptr C0, C1;\ R->parent = XP;\ if ((C0 = X->child[0]) != 0) {\ R->child[0] = C0;\ C0->parent = R;\ }\ if ((C1 = X->child[1]) != 0) {\ R->child[1] = C1;\ C1->parent = R;\ }\ }\ }\ } /* Relays to large vs small bin operations */ #define insert_chunk(M, P, S)\ if (is_small(S)) { insert_small_chunk(M, P, S)\ } else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } #define unlink_chunk(M, P, S)\ if (is_small(S)) { unlink_small_chunk(M, P, S)\ } else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } /* ----------------------- Direct-mmapping chunks ----------------------- */ static void *direct_alloc(size_t nb) { size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); if (LJ_LIKELY(mmsize > nb)) { /* Check for wrap around 0 */ char *mm = (char *)(DIRECT_MMAP(mmsize)); if (mm != CMFAIL) { size_t offset = align_offset(chunk2mem(mm)); size_t psize = mmsize - offset - DIRECT_FOOT_PAD; mchunkptr p = (mchunkptr)(mm + offset); p->prev_foot = offset | IS_DIRECT_BIT; p->head = psize|CINUSE_BIT; chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; return chunk2mem(p); } } return NULL; } static mchunkptr direct_resize(mchunkptr oldp, size_t nb) { size_t oldsize = chunksize(oldp); if (is_small(nb)) /* Can't shrink direct regions below small size */ return NULL; /* Keep old chunk if big enough but not too big */ if (oldsize >= nb + SIZE_T_SIZE && (oldsize - nb) <= (DEFAULT_GRANULARITY >> 1)) { return oldp; } else { size_t offset = oldp->prev_foot & ~IS_DIRECT_BIT; size_t oldmmsize = oldsize + offset + DIRECT_FOOT_PAD; size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); char *cp = (char *)CALL_MREMAP((char *)oldp - offset, oldmmsize, newmmsize, CALL_MREMAP_MV); if (cp != CMFAIL) { mchunkptr newp = (mchunkptr)(cp + offset); size_t psize = newmmsize - offset - DIRECT_FOOT_PAD; newp->head = psize|CINUSE_BIT; chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; return newp; } } return NULL; } /* -------------------------- mspace management -------------------------- */ /* Initialize top chunk and its size */ static void init_top(mstate m, mchunkptr p, size_t psize) { /* Ensure alignment */ size_t offset = align_offset(chunk2mem(p)); p = (mchunkptr)((char *)p + offset); psize -= offset; m->top = p; m->topsize = psize; p->head = psize | PINUSE_BIT; /* set size of fake trailing chunk holding overhead space only once */ chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; m->trim_check = DEFAULT_TRIM_THRESHOLD; /* reset on each update */ } /* Initialize bins for a new mstate that is otherwise zeroed out */ static void init_bins(mstate m) { /* Establish circular links for smallbins */ bindex_t i; for (i = 0; i < NSMALLBINS; i++) { sbinptr bin = smallbin_at(m,i); bin->fd = bin->bk = bin; } } /* Allocate chunk and prepend remainder with chunk in successor base. */ static void *prepend_alloc(mstate m, char *newbase, char *oldbase, size_t nb) { mchunkptr p = align_as_chunk(newbase); mchunkptr oldfirst = align_as_chunk(oldbase); size_t psize = (size_t)((char *)oldfirst - (char *)p); mchunkptr q = chunk_plus_offset(p, nb); size_t qsize = psize - nb; set_size_and_pinuse_of_inuse_chunk(m, p, nb); /* consolidate remainder with first chunk of old base */ if (oldfirst == m->top) { size_t tsize = m->topsize += qsize; m->top = q; q->head = tsize | PINUSE_BIT; } else if (oldfirst == m->dv) { size_t dsize = m->dvsize += qsize; m->dv = q; set_size_and_pinuse_of_free_chunk(q, dsize); } else { if (!cinuse(oldfirst)) { size_t nsize = chunksize(oldfirst); unlink_chunk(m, oldfirst, nsize); oldfirst = chunk_plus_offset(oldfirst, nsize); qsize += nsize; } set_free_with_pinuse(q, qsize, oldfirst); insert_chunk(m, q, qsize); } return chunk2mem(p); } /* Add a segment to hold a new noncontiguous region */ static void add_segment(mstate m, char *tbase, size_t tsize) { /* Determine locations and sizes of segment, fenceposts, old top */ char *old_top = (char *)m->top; msegmentptr oldsp = segment_holding(m, old_top); char *old_end = oldsp->base + oldsp->size; size_t ssize = pad_request(sizeof(struct malloc_segment)); char *rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); size_t offset = align_offset(chunk2mem(rawsp)); char *asp = rawsp + offset; char *csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; mchunkptr sp = (mchunkptr)csp; msegmentptr ss = (msegmentptr)(chunk2mem(sp)); mchunkptr tnext = chunk_plus_offset(sp, ssize); mchunkptr p = tnext; /* reset top to new space */ init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); /* Set up segment record */ set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); *ss = m->seg; /* Push current record */ m->seg.base = tbase; m->seg.size = tsize; m->seg.next = ss; /* Insert trailing fenceposts */ for (;;) { mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); p->head = FENCEPOST_HEAD; if ((char *)(&(nextp->head)) < old_end) p = nextp; else break; } /* Insert the rest of old top into a bin as an ordinary free chunk */ if (csp != old_top) { mchunkptr q = (mchunkptr)old_top; size_t psize = (size_t)(csp - old_top); mchunkptr tn = chunk_plus_offset(q, psize); set_free_with_pinuse(q, psize, tn); insert_chunk(m, q, psize); } } /* -------------------------- System allocation -------------------------- */ static void *alloc_sys(mstate m, size_t nb) { char *tbase = CMFAIL; size_t tsize = 0; /* Directly map large chunks */ if (LJ_UNLIKELY(nb >= DEFAULT_MMAP_THRESHOLD)) { void *mem = direct_alloc(nb); if (mem != 0) return mem; } { size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; size_t rsize = granularity_align(req); if (LJ_LIKELY(rsize > nb)) { /* Fail if wraps around zero */ char *mp = (char *)(CALL_MMAP(rsize)); if (mp != CMFAIL) { tbase = mp; tsize = rsize; } } } if (tbase != CMFAIL) { msegmentptr sp = &m->seg; /* Try to merge with an existing segment */ while (sp != 0 && tbase != sp->base + sp->size) sp = sp->next; if (sp != 0 && segment_holds(sp, m->top)) { /* append */ sp->size += tsize; init_top(m, m->top, m->topsize + tsize); } else { sp = &m->seg; while (sp != 0 && sp->base != tbase + tsize) sp = sp->next; if (sp != 0) { char *oldbase = sp->base; sp->base = tbase; sp->size += tsize; return prepend_alloc(m, tbase, oldbase, nb); } else { add_segment(m, tbase, tsize); } } if (nb < m->topsize) { /* Allocate from new or extended top space */ size_t rsize = m->topsize -= nb; mchunkptr p = m->top; mchunkptr r = m->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; set_size_and_pinuse_of_inuse_chunk(m, p, nb); return chunk2mem(p); } } return NULL; } /* ----------------------- system deallocation -------------------------- */ /* Unmap and unlink any mmapped segments that don't contain used chunks */ static size_t release_unused_segments(mstate m) { size_t released = 0; size_t nsegs = 0; msegmentptr pred = &m->seg; msegmentptr sp = pred->next; while (sp != 0) { char *base = sp->base; size_t size = sp->size; msegmentptr next = sp->next; nsegs++; { mchunkptr p = align_as_chunk(base); size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ if (!cinuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { tchunkptr tp = (tchunkptr)p; if (p == m->dv) { m->dv = 0; m->dvsize = 0; } else { unlink_large_chunk(m, tp); } if (CALL_MUNMAP(base, size) == 0) { released += size; /* unlink obsoleted record */ sp = pred; sp->next = next; } else { /* back out if cannot unmap */ insert_large_chunk(m, tp, psize); } } } pred = sp; sp = next; } /* Reset check counter */ m->release_checks = nsegs > MAX_RELEASE_CHECK_RATE ? nsegs : MAX_RELEASE_CHECK_RATE; return released; } static int alloc_trim(mstate m, size_t pad) { size_t released = 0; if (pad < MAX_REQUEST && is_initialized(m)) { pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ if (m->topsize > pad) { /* Shrink top space in granularity-size units, keeping at least one */ size_t unit = DEFAULT_GRANULARITY; size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - SIZE_T_ONE) * unit; msegmentptr sp = segment_holding(m, (char *)m->top); if (sp->size >= extra && !has_segment_link(m, sp)) { /* can't shrink if pinned */ size_t newsize = sp->size - extra; /* Prefer mremap, fall back to munmap */ if ((CALL_MREMAP(sp->base, sp->size, newsize, CALL_MREMAP_NOMOVE) != MFAIL) || (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { released = extra; } } if (released != 0) { sp->size -= released; init_top(m, m->top, m->topsize - released); } } /* Unmap any unused mmapped segments */ released += release_unused_segments(m); /* On failure, disable autotrim to avoid repeated failed future calls */ if (released == 0 && m->topsize > m->trim_check) m->trim_check = MAX_SIZE_T; } return (released != 0)? 1 : 0; } /* ---------------------------- malloc support --------------------------- */ /* allocate a large request from the best fitting chunk in a treebin */ static void *tmalloc_large(mstate m, size_t nb) { tchunkptr v = 0; size_t rsize = ~nb+1; /* Unsigned negation */ tchunkptr t; bindex_t idx; compute_tree_index(nb, idx); if ((t = *treebin_at(m, idx)) != 0) { /* Traverse tree for this bin looking for node with size == nb */ size_t sizebits = nb << leftshift_for_tree_index(idx); tchunkptr rst = 0; /* The deepest untaken right subtree */ for (;;) { tchunkptr rt; size_t trem = chunksize(t) - nb; if (trem < rsize) { v = t; if ((rsize = trem) == 0) break; } rt = t->child[1]; t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; if (rt != 0 && rt != t) rst = rt; if (t == 0) { t = rst; /* set t to least subtree holding sizes > nb */ break; } sizebits <<= 1; } } if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; if (leftbits != 0) t = *treebin_at(m, lj_ffs(leftbits)); } while (t != 0) { /* find smallest of tree or subtree */ size_t trem = chunksize(t) - nb; if (trem < rsize) { rsize = trem; v = t; } t = leftmost_child(t); } /* If dv is a better fit, return NULL so malloc will use it */ if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { mchunkptr r = chunk_plus_offset(v, nb); unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) { set_inuse_and_pinuse(m, v, (rsize + nb)); } else { set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); insert_chunk(m, r, rsize); } return chunk2mem(v); } return NULL; } /* allocate a small request from the best fitting chunk in a treebin */ static void *tmalloc_small(mstate m, size_t nb) { tchunkptr t, v; mchunkptr r; size_t rsize; bindex_t i = lj_ffs(m->treemap); v = t = *treebin_at(m, i); rsize = chunksize(t) - nb; while ((t = leftmost_child(t)) != 0) { size_t trem = chunksize(t) - nb; if (trem < rsize) { rsize = trem; v = t; } } r = chunk_plus_offset(v, nb); unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) { set_inuse_and_pinuse(m, v, (rsize + nb)); } else { set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(m, r, rsize); } return chunk2mem(v); } /* ----------------------------------------------------------------------- */ void *lj_alloc_create(void) { size_t tsize = DEFAULT_GRANULARITY; char *tbase; INIT_MMAP(); tbase = (char *)(CALL_MMAP(tsize)); if (tbase != CMFAIL) { size_t msize = pad_request(sizeof(struct malloc_state)); mchunkptr mn; mchunkptr msp = align_as_chunk(tbase); mstate m = (mstate)(chunk2mem(msp)); memset(m, 0, msize); msp->head = (msize|PINUSE_BIT|CINUSE_BIT); m->seg.base = tbase; m->seg.size = tsize; m->release_checks = MAX_RELEASE_CHECK_RATE; init_bins(m); mn = next_chunk(mem2chunk(m)); init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); return m; } return NULL; } void lj_alloc_destroy(void *msp) { mstate ms = (mstate)msp; msegmentptr sp = &ms->seg; while (sp != 0) { char *base = sp->base; size_t size = sp->size; sp = sp->next; CALL_MUNMAP(base, size); } } static LJ_NOINLINE void *lj_alloc_malloc(void *msp, size_t nsize) { mstate ms = (mstate)msp; void *mem; size_t nb; if (nsize <= MAX_SMALL_REQUEST) { bindex_t idx; binmap_t smallbits; nb = (nsize < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(nsize); idx = small_index(nb); smallbits = ms->smallmap >> idx; if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(ms, idx); p = b->fd; unlink_first_small_chunk(ms, b, p, idx); set_inuse_and_pinuse(ms, p, small_index2size(idx)); mem = chunk2mem(p); return mem; } else if (nb > ms->dvsize) { if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; size_t rsize; binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); bindex_t i = lj_ffs(leftbits); b = smallbin_at(ms, i); p = b->fd; unlink_first_small_chunk(ms, b, p, i); rsize = small_index2size(i) - nb; /* Fit here cannot be remainderless if 4byte sizes */ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) { set_inuse_and_pinuse(ms, p, small_index2size(i)); } else { set_size_and_pinuse_of_inuse_chunk(ms, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(ms, r, rsize); } mem = chunk2mem(p); return mem; } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { return mem; } } } else if (nsize >= MAX_REQUEST) { nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ } else { nb = pad_request(nsize); if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { return mem; } } if (nb <= ms->dvsize) { size_t rsize = ms->dvsize - nb; mchunkptr p = ms->dv; if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = ms->dv = chunk_plus_offset(p, nb); ms->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(ms, p, nb); } else { /* exhaust dv */ size_t dvs = ms->dvsize; ms->dvsize = 0; ms->dv = 0; set_inuse_and_pinuse(ms, p, dvs); } mem = chunk2mem(p); return mem; } else if (nb < ms->topsize) { /* Split top */ size_t rsize = ms->topsize -= nb; mchunkptr p = ms->top; mchunkptr r = ms->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; set_size_and_pinuse_of_inuse_chunk(ms, p, nb); mem = chunk2mem(p); return mem; } return alloc_sys(ms, nb); } static LJ_NOINLINE void *lj_alloc_free(void *msp, void *ptr) { if (ptr != 0) { mchunkptr p = mem2chunk(ptr); mstate fm = (mstate)msp; size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { size_t prevsize = p->prev_foot; if ((prevsize & IS_DIRECT_BIT) != 0) { prevsize &= ~IS_DIRECT_BIT; psize += prevsize + DIRECT_FOOT_PAD; CALL_MUNMAP((char *)p - prevsize, psize); return NULL; } else { mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; /* consolidate backward */ if (p != fm->dv) { unlink_chunk(fm, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; set_free_with_pinuse(p, psize, next); return NULL; } } } if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { fm->dv = 0; fm->dvsize = 0; } if (tsize > fm->trim_check) alloc_trim(fm, 0); return NULL; } else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); return NULL; } else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { fm->dvsize = psize; return NULL; } } } else { set_free_with_pinuse(p, psize, next); } if (is_small(psize)) { insert_small_chunk(fm, p, psize); } else { tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); if (--fm->release_checks == 0) release_unused_segments(fm); } } return NULL; } static LJ_NOINLINE void *lj_alloc_realloc(void *msp, void *ptr, size_t nsize) { if (nsize >= MAX_REQUEST) { return NULL; } else { mstate m = (mstate)msp; mchunkptr oldp = mem2chunk(ptr); size_t oldsize = chunksize(oldp); mchunkptr next = chunk_plus_offset(oldp, oldsize); mchunkptr newp = 0; size_t nb = request2size(nsize); /* Try to either shrink or extend into top. Else malloc-copy-free */ if (is_direct(oldp)) { newp = direct_resize(oldp, nb); /* this may return NULL. */ } else if (oldsize >= nb) { /* already big enough */ size_t rsize = oldsize - nb; newp = oldp; if (rsize >= MIN_CHUNK_SIZE) { mchunkptr rem = chunk_plus_offset(newp, nb); set_inuse(m, newp, nb); set_inuse(m, rem, rsize); lj_alloc_free(m, chunk2mem(rem)); } } else if (next == m->top && oldsize + m->topsize > nb) { /* Expand into top */ size_t newsize = oldsize + m->topsize; size_t newtopsize = newsize - nb; mchunkptr newtop = chunk_plus_offset(oldp, nb); set_inuse(m, oldp, nb); newtop->head = newtopsize |PINUSE_BIT; m->top = newtop; m->topsize = newtopsize; newp = oldp; } if (newp != 0) { return chunk2mem(newp); } else { void *newmem = lj_alloc_malloc(m, nsize); if (newmem != 0) { size_t oc = oldsize - overhead_for(oldp); memcpy(newmem, ptr, oc < nsize ? oc : nsize); lj_alloc_free(m, ptr); } return newmem; } } } void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize) { (void)osize; if (nsize == 0) { return lj_alloc_free(msp, ptr); } else if (ptr == NULL) { return lj_alloc_malloc(msp, nsize); } else { return lj_alloc_realloc(msp, ptr, nsize); } } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_alloc.h ================================================ /* ** Bundled memory allocator. ** Donated to the public domain. */ #ifndef _LJ_ALLOC_H #define _LJ_ALLOC_H #include "lj_def.h" #ifndef LUAJIT_USE_SYSMALLOC LJ_FUNC void *lj_alloc_create(void); LJ_FUNC void lj_alloc_destroy(void *msp); LJ_FUNC void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_api.c ================================================ /* ** Public Lua/C API. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lj_api_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_func.h" #include "lj_udata.h" #include "lj_meta.h" #include "lj_state.h" #include "lj_bc.h" #include "lj_frame.h" #include "lj_trace.h" #include "lj_vm.h" #include "lj_strscan.h" /* -- Common helper functions --------------------------------------------- */ #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) #define api_checkvalidindex(L, i) api_check(L, (i) != niltv(L)) static TValue *index2adr(lua_State *L, int idx) { if (idx > 0) { TValue *o = L->base + (idx - 1); return o < L->top ? o : niltv(L); } else if (idx > LUA_REGISTRYINDEX) { api_check(L, idx != 0 && -idx <= L->top - L->base); return L->top + idx; } else if (idx == LUA_GLOBALSINDEX) { TValue *o = &G(L)->tmptv; settabV(L, o, tabref(L->env)); return o; } else if (idx == LUA_REGISTRYINDEX) { return registry(L); } else { GCfunc *fn = curr_func(L); api_check(L, fn->c.gct == ~LJ_TFUNC && !isluafunc(fn)); if (idx == LUA_ENVIRONINDEX) { TValue *o = &G(L)->tmptv; settabV(L, o, tabref(fn->c.env)); return o; } else { idx = LUA_GLOBALSINDEX - idx; return idx <= fn->c.nupvalues ? &fn->c.upvalue[idx-1] : niltv(L); } } } static TValue *stkindex2adr(lua_State *L, int idx) { if (idx > 0) { TValue *o = L->base + (idx - 1); return o < L->top ? o : niltv(L); } else { api_check(L, idx != 0 && -idx <= L->top - L->base); return L->top + idx; } } static GCtab *getcurrenv(lua_State *L) { GCfunc *fn = curr_func(L); return fn->c.gct == ~LJ_TFUNC ? tabref(fn->c.env) : tabref(L->env); } /* -- Miscellaneous API functions ----------------------------------------- */ LUA_API int lua_status(lua_State *L) { return L->status; } LUA_API int lua_checkstack(lua_State *L, int size) { if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) { return 0; /* Stack overflow. */ } else if (size > 0) { lj_state_checkstack(L, (MSize)size); } return 1; } LUALIB_API void luaL_checkstack(lua_State *L, int size, const char *msg) { if (!lua_checkstack(L, size)) lj_err_callerv(L, LJ_ERR_STKOVM, msg); } LUA_API void lua_xmove(lua_State *from, lua_State *to, int n) { TValue *f, *t; if (from == to) return; api_checknelems(from, n); api_check(from, G(from) == G(to)); lj_state_checkstack(to, (MSize)n); f = from->top; t = to->top = to->top + n; while (--n >= 0) copyTV(to, --t, --f); from->top = f; } /* -- Stack manipulation -------------------------------------------------- */ LUA_API int lua_gettop(lua_State *L) { return (int)(L->top - L->base); } LUA_API void lua_settop(lua_State *L, int idx) { if (idx >= 0) { api_check(L, idx <= tvref(L->maxstack) - L->base); if (L->base + idx > L->top) { if (L->base + idx >= tvref(L->maxstack)) lj_state_growstack(L, (MSize)idx - (MSize)(L->top - L->base)); do { setnilV(L->top++); } while (L->top < L->base + idx); } else { L->top = L->base + idx; } } else { api_check(L, -(idx+1) <= (L->top - L->base)); L->top += idx+1; /* Shrinks top (idx < 0). */ } } LUA_API void lua_remove(lua_State *L, int idx) { TValue *p = stkindex2adr(L, idx); api_checkvalidindex(L, p); while (++p < L->top) copyTV(L, p-1, p); L->top--; } LUA_API void lua_insert(lua_State *L, int idx) { TValue *q, *p = stkindex2adr(L, idx); api_checkvalidindex(L, p); for (q = L->top; q > p; q--) copyTV(L, q, q-1); copyTV(L, p, L->top); } LUA_API void lua_replace(lua_State *L, int idx) { api_checknelems(L, 1); if (idx == LUA_GLOBALSINDEX) { api_check(L, tvistab(L->top-1)); /* NOBARRIER: A thread (i.e. L) is never black. */ setgcref(L->env, obj2gco(tabV(L->top-1))); } else if (idx == LUA_ENVIRONINDEX) { GCfunc *fn = curr_func(L); if (fn->c.gct != ~LJ_TFUNC) lj_err_msg(L, LJ_ERR_NOENV); api_check(L, tvistab(L->top-1)); setgcref(fn->c.env, obj2gco(tabV(L->top-1))); lj_gc_barrier(L, fn, L->top-1); } else { TValue *o = index2adr(L, idx); api_checkvalidindex(L, o); copyTV(L, o, L->top-1); if (idx < LUA_GLOBALSINDEX) /* Need a barrier for upvalues. */ lj_gc_barrier(L, curr_func(L), L->top-1); } L->top--; } LUA_API void lua_pushvalue(lua_State *L, int idx) { copyTV(L, L->top, index2adr(L, idx)); incr_top(L); } /* -- Stack getters ------------------------------------------------------- */ LUA_API int lua_type(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); if (tvisnumber(o)) { return LUA_TNUMBER; #if LJ_64 } else if (tvislightud(o)) { return LUA_TLIGHTUSERDATA; #endif } else if (o == niltv(L)) { return LUA_TNONE; } else { /* Magic internal/external tag conversion. ORDER LJ_T */ uint32_t t = ~itype(o); #if LJ_64 int tt = (int)((U64x(75a06,98042110) >> 4*t) & 15u); #else int tt = (int)(((t < 8 ? 0x98042110u : 0x75a06u) >> 4*(t&7)) & 15u); #endif lua_assert(tt != LUA_TNIL || tvisnil(o)); return tt; } } LUALIB_API void luaL_checktype(lua_State *L, int idx, int tt) { if (lua_type(L, idx) != tt) lj_err_argt(L, idx, tt); } LUALIB_API void luaL_checkany(lua_State *L, int idx) { if (index2adr(L, idx) == niltv(L)) lj_err_arg(L, idx, LJ_ERR_NOVAL); } LUA_API const char *lua_typename(lua_State *L, int t) { UNUSED(L); return lj_obj_typename[t+1]; } LUA_API int lua_iscfunction(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); return tvisfunc(o) && !isluafunc(funcV(o)); } LUA_API int lua_isnumber(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); TValue tmp; return (tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), &tmp))); } LUA_API int lua_isstring(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); return (tvisstr(o) || tvisnumber(o)); } LUA_API int lua_isuserdata(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); return (tvisudata(o) || tvislightud(o)); } LUA_API int lua_rawequal(lua_State *L, int idx1, int idx2) { cTValue *o1 = index2adr(L, idx1); cTValue *o2 = index2adr(L, idx2); return (o1 == niltv(L) || o2 == niltv(L)) ? 0 : lj_obj_equal(o1, o2); } LUA_API int lua_equal(lua_State *L, int idx1, int idx2) { cTValue *o1 = index2adr(L, idx1); cTValue *o2 = index2adr(L, idx2); if (tvisint(o1) && tvisint(o2)) { return intV(o1) == intV(o2); } else if (tvisnumber(o1) && tvisnumber(o2)) { return numberVnum(o1) == numberVnum(o2); } else if (itype(o1) != itype(o2)) { return 0; } else if (tvispri(o1)) { return o1 != niltv(L) && o2 != niltv(L); #if LJ_64 } else if (tvislightud(o1)) { return o1->u64 == o2->u64; #endif } else if (gcrefeq(o1->gcr, o2->gcr)) { return 1; } else if (!tvistabud(o1)) { return 0; } else { TValue *base = lj_meta_equal(L, gcV(o1), gcV(o2), 0); if ((uintptr_t)base <= 1) { return (int)(uintptr_t)base; } else { L->top = base+2; lj_vm_call(L, base, 1+1); L->top -= 2; return tvistruecond(L->top+1); } } } LUA_API int lua_lessthan(lua_State *L, int idx1, int idx2) { cTValue *o1 = index2adr(L, idx1); cTValue *o2 = index2adr(L, idx2); if (o1 == niltv(L) || o2 == niltv(L)) { return 0; } else if (tvisint(o1) && tvisint(o2)) { return intV(o1) < intV(o2); } else if (tvisnumber(o1) && tvisnumber(o2)) { return numberVnum(o1) < numberVnum(o2); } else { TValue *base = lj_meta_comp(L, o1, o2, 0); if ((uintptr_t)base <= 1) { return (int)(uintptr_t)base; } else { L->top = base+2; lj_vm_call(L, base, 1+1); L->top -= 2; return tvistruecond(L->top+1); } } } LUA_API lua_Number lua_tonumber(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); TValue tmp; if (LJ_LIKELY(tvisnumber(o))) return numberVnum(o); else if (tvisstr(o) && lj_strscan_num(strV(o), &tmp)) return numV(&tmp); else return 0; } LUALIB_API lua_Number luaL_checknumber(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); TValue tmp; if (LJ_LIKELY(tvisnumber(o))) return numberVnum(o); else if (!(tvisstr(o) && lj_strscan_num(strV(o), &tmp))) lj_err_argt(L, idx, LUA_TNUMBER); return numV(&tmp); } LUALIB_API lua_Number luaL_optnumber(lua_State *L, int idx, lua_Number def) { cTValue *o = index2adr(L, idx); TValue tmp; if (LJ_LIKELY(tvisnumber(o))) return numberVnum(o); else if (tvisnil(o)) return def; else if (!(tvisstr(o) && lj_strscan_num(strV(o), &tmp))) lj_err_argt(L, idx, LUA_TNUMBER); return numV(&tmp); } LUA_API lua_Integer lua_tointeger(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); TValue tmp; lua_Number n; if (LJ_LIKELY(tvisint(o))) { return intV(o); } else if (LJ_LIKELY(tvisnum(o))) { n = numV(o); } else { if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) return 0; if (tvisint(&tmp)) return (lua_Integer)intV(&tmp); n = numV(&tmp); } #if LJ_64 return (lua_Integer)n; #else return lj_num2int(n); #endif } LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); TValue tmp; lua_Number n; if (LJ_LIKELY(tvisint(o))) { return intV(o); } else if (LJ_LIKELY(tvisnum(o))) { n = numV(o); } else { if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) lj_err_argt(L, idx, LUA_TNUMBER); if (tvisint(&tmp)) return (lua_Integer)intV(&tmp); n = numV(&tmp); } #if LJ_64 return (lua_Integer)n; #else return lj_num2int(n); #endif } LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def) { cTValue *o = index2adr(L, idx); TValue tmp; lua_Number n; if (LJ_LIKELY(tvisint(o))) { return intV(o); } else if (LJ_LIKELY(tvisnum(o))) { n = numV(o); } else if (tvisnil(o)) { return def; } else { if (!(tvisstr(o) && lj_strscan_number(strV(o), &tmp))) lj_err_argt(L, idx, LUA_TNUMBER); if (tvisint(&tmp)) return (lua_Integer)intV(&tmp); n = numV(&tmp); } #if LJ_64 return (lua_Integer)n; #else return lj_num2int(n); #endif } LUA_API int lua_toboolean(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); return tvistruecond(o); } LUA_API const char *lua_tolstring(lua_State *L, int idx, size_t *len) { TValue *o = index2adr(L, idx); GCstr *s; if (LJ_LIKELY(tvisstr(o))) { s = strV(o); } else if (tvisnumber(o)) { lj_gc_check(L); o = index2adr(L, idx); /* GC may move the stack. */ s = lj_str_fromnumber(L, o); setstrV(L, o, s); } else { if (len != NULL) *len = 0; return NULL; } if (len != NULL) *len = s->len; return strdata(s); } LUALIB_API const char *luaL_checklstring(lua_State *L, int idx, size_t *len) { TValue *o = index2adr(L, idx); GCstr *s; if (LJ_LIKELY(tvisstr(o))) { s = strV(o); } else if (tvisnumber(o)) { lj_gc_check(L); o = index2adr(L, idx); /* GC may move the stack. */ s = lj_str_fromnumber(L, o); setstrV(L, o, s); } else { lj_err_argt(L, idx, LUA_TSTRING); } if (len != NULL) *len = s->len; return strdata(s); } LUALIB_API const char *luaL_optlstring(lua_State *L, int idx, const char *def, size_t *len) { TValue *o = index2adr(L, idx); GCstr *s; if (LJ_LIKELY(tvisstr(o))) { s = strV(o); } else if (tvisnil(o)) { if (len != NULL) *len = def ? strlen(def) : 0; return def; } else if (tvisnumber(o)) { lj_gc_check(L); o = index2adr(L, idx); /* GC may move the stack. */ s = lj_str_fromnumber(L, o); setstrV(L, o, s); } else { lj_err_argt(L, idx, LUA_TSTRING); } if (len != NULL) *len = s->len; return strdata(s); } LUALIB_API int luaL_checkoption(lua_State *L, int idx, const char *def, const char *const lst[]) { ptrdiff_t i; const char *s = lua_tolstring(L, idx, NULL); if (s == NULL && (s = def) == NULL) lj_err_argt(L, idx, LUA_TSTRING); for (i = 0; lst[i]; i++) if (strcmp(lst[i], s) == 0) return (int)i; lj_err_argv(L, idx, LJ_ERR_INVOPTM, s); } LUA_API size_t lua_objlen(lua_State *L, int idx) { TValue *o = index2adr(L, idx); if (tvisstr(o)) { return strV(o)->len; } else if (tvistab(o)) { return (size_t)lj_tab_len(tabV(o)); } else if (tvisudata(o)) { return udataV(o)->len; } else if (tvisnumber(o)) { GCstr *s = lj_str_fromnumber(L, o); setstrV(L, o, s); return s->len; } else { return 0; } } LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); if (tvisfunc(o)) { BCOp op = bc_op(*mref(funcV(o)->c.pc, BCIns)); if (op == BC_FUNCC || op == BC_FUNCCW) return funcV(o)->c.f; } return NULL; } LUA_API void *lua_touserdata(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); if (tvisudata(o)) return uddata(udataV(o)); else if (tvislightud(o)) return lightudV(o); else return NULL; } LUA_API lua_State *lua_tothread(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); return (!tvisthread(o)) ? NULL : threadV(o); } LUA_API const void *lua_topointer(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); if (tvisudata(o)) return uddata(udataV(o)); else if (tvislightud(o)) return lightudV(o); else if (tviscdata(o)) return cdataptr(cdataV(o)); else if (tvisgcv(o)) return gcV(o); else return NULL; } /* -- Stack setters (object creation) ------------------------------------- */ LUA_API void lua_pushnil(lua_State *L) { setnilV(L->top); incr_top(L); } LUA_API void lua_pushnumber(lua_State *L, lua_Number n) { setnumV(L->top, n); if (LJ_UNLIKELY(tvisnan(L->top))) setnanV(L->top); /* Canonicalize injected NaNs. */ incr_top(L); } LUA_API void lua_pushinteger(lua_State *L, lua_Integer n) { setintptrV(L->top, n); incr_top(L); } LUA_API void lua_pushlstring(lua_State *L, const char *str, size_t len) { GCstr *s; lj_gc_check(L); s = lj_str_new(L, str, len); setstrV(L, L->top, s); incr_top(L); } LUA_API void lua_pushstring(lua_State *L, const char *str) { if (str == NULL) { setnilV(L->top); } else { GCstr *s; lj_gc_check(L); s = lj_str_newz(L, str); setstrV(L, L->top, s); } incr_top(L); } LUA_API const char *lua_pushvfstring(lua_State *L, const char *fmt, va_list argp) { lj_gc_check(L); return lj_str_pushvf(L, fmt, argp); } LUA_API const char *lua_pushfstring(lua_State *L, const char *fmt, ...) { const char *ret; va_list argp; lj_gc_check(L); va_start(argp, fmt); ret = lj_str_pushvf(L, fmt, argp); va_end(argp); return ret; } LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction f, int n) { GCfunc *fn; lj_gc_check(L); api_checknelems(L, n); fn = lj_func_newC(L, (MSize)n, getcurrenv(L)); fn->c.f = f; L->top -= n; while (n--) copyTV(L, &fn->c.upvalue[n], L->top+n); setfuncV(L, L->top, fn); lua_assert(iswhite(obj2gco(fn))); incr_top(L); } LUA_API void lua_pushboolean(lua_State *L, int b) { setboolV(L->top, (b != 0)); incr_top(L); } LUA_API void lua_pushlightuserdata(lua_State *L, void *p) { setlightudV(L->top, checklightudptr(L, p)); incr_top(L); } LUA_API void lua_createtable(lua_State *L, int narray, int nrec) { GCtab *t; lj_gc_check(L); t = lj_tab_new(L, (uint32_t)(narray > 0 ? narray+1 : 0), hsize2hbits(nrec)); settabV(L, L->top, t); incr_top(L); } LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname) { GCtab *regt = tabV(registry(L)); TValue *tv = lj_tab_setstr(L, regt, lj_str_newz(L, tname)); if (tvisnil(tv)) { GCtab *mt = lj_tab_new(L, 0, 1); settabV(L, tv, mt); settabV(L, L->top++, mt); lj_gc_anybarriert(L, regt); return 1; } else { copyTV(L, L->top++, tv); return 0; } } LUA_API int lua_pushthread(lua_State *L) { setthreadV(L, L->top, L); incr_top(L); return (mainthread(G(L)) == L); } LUA_API lua_State *lua_newthread(lua_State *L) { lua_State *L1; lj_gc_check(L); L1 = lj_state_new(L); setthreadV(L, L->top, L1); incr_top(L); return L1; } LUA_API void *lua_newuserdata(lua_State *L, size_t size) { GCudata *ud; lj_gc_check(L); if (size > LJ_MAX_UDATA) lj_err_msg(L, LJ_ERR_UDATAOV); ud = lj_udata_new(L, (MSize)size, getcurrenv(L)); setudataV(L, L->top, ud); incr_top(L); return uddata(ud); } LUA_API void lua_concat(lua_State *L, int n) { api_checknelems(L, n); if (n >= 2) { n--; do { TValue *top = lj_meta_cat(L, L->top-1, -n); if (top == NULL) { L->top -= n; break; } n -= (int)(L->top - top); L->top = top+2; lj_vm_call(L, top, 1+1); L->top--; copyTV(L, L->top-1, L->top); } while (--n > 0); } else if (n == 0) { /* Push empty string. */ setstrV(L, L->top, &G(L)->strempty); incr_top(L); } /* else n == 1: nothing to do. */ } /* -- Object getters ------------------------------------------------------ */ LUA_API void lua_gettable(lua_State *L, int idx) { cTValue *v, *t = index2adr(L, idx); api_checkvalidindex(L, t); v = lj_meta_tget(L, t, L->top-1); if (v == NULL) { L->top += 2; lj_vm_call(L, L->top-2, 1+1); L->top -= 2; v = L->top+1; } copyTV(L, L->top-1, v); } LUA_API void lua_getfield(lua_State *L, int idx, const char *k) { cTValue *v, *t = index2adr(L, idx); TValue key; api_checkvalidindex(L, t); setstrV(L, &key, lj_str_newz(L, k)); v = lj_meta_tget(L, t, &key); if (v == NULL) { L->top += 2; lj_vm_call(L, L->top-2, 1+1); L->top -= 2; v = L->top+1; } copyTV(L, L->top, v); incr_top(L); } LUA_API void lua_rawget(lua_State *L, int idx) { cTValue *t = index2adr(L, idx); api_check(L, tvistab(t)); copyTV(L, L->top-1, lj_tab_get(L, tabV(t), L->top-1)); } LUA_API void lua_rawgeti(lua_State *L, int idx, int n) { cTValue *v, *t = index2adr(L, idx); api_check(L, tvistab(t)); v = lj_tab_getint(tabV(t), n); if (v) { copyTV(L, L->top, v); } else { setnilV(L->top); } incr_top(L); } LUA_API int lua_getmetatable(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); GCtab *mt = NULL; if (tvistab(o)) mt = tabref(tabV(o)->metatable); else if (tvisudata(o)) mt = tabref(udataV(o)->metatable); else mt = tabref(basemt_obj(G(L), o)); if (mt == NULL) return 0; settabV(L, L->top, mt); incr_top(L); return 1; } LUALIB_API int luaL_getmetafield(lua_State *L, int idx, const char *field) { if (lua_getmetatable(L, idx)) { cTValue *tv = lj_tab_getstr(tabV(L->top-1), lj_str_newz(L, field)); if (tv && !tvisnil(tv)) { copyTV(L, L->top-1, tv); return 1; } L->top--; } return 0; } LUA_API void lua_getfenv(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); api_checkvalidindex(L, o); if (tvisfunc(o)) { settabV(L, L->top, tabref(funcV(o)->c.env)); } else if (tvisudata(o)) { settabV(L, L->top, tabref(udataV(o)->env)); } else if (tvisthread(o)) { settabV(L, L->top, tabref(threadV(o)->env)); } else { setnilV(L->top); } incr_top(L); } LUA_API int lua_next(lua_State *L, int idx) { cTValue *t = index2adr(L, idx); int more; api_check(L, tvistab(t)); more = lj_tab_next(L, tabV(t), L->top-1); if (more) { incr_top(L); /* Return new key and value slot. */ } else { /* End of traversal. */ L->top--; /* Remove key slot. */ } return more; } LUA_API const char *lua_getupvalue(lua_State *L, int idx, int n) { TValue *val; const char *name = lj_debug_uvnamev(index2adr(L, idx), (uint32_t)(n-1), &val); if (name) { copyTV(L, L->top, val); incr_top(L); } return name; } LUA_API void *lua_upvalueid(lua_State *L, int idx, int n) { GCfunc *fn = funcV(index2adr(L, idx)); n--; api_check(L, (uint32_t)n < fn->l.nupvalues); return isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : (void *)&fn->c.upvalue[n]; } LUA_API void lua_upvaluejoin(lua_State *L, int idx1, int n1, int idx2, int n2) { GCfunc *fn1 = funcV(index2adr(L, idx1)); GCfunc *fn2 = funcV(index2adr(L, idx2)); n1--; n2--; api_check(L, isluafunc(fn1) && (uint32_t)n1 < fn1->l.nupvalues); api_check(L, isluafunc(fn2) && (uint32_t)n2 < fn2->l.nupvalues); setgcrefr(fn1->l.uvptr[n1], fn2->l.uvptr[n2]); lj_gc_objbarrier(L, fn1, gcref(fn1->l.uvptr[n1])); } LUALIB_API void *luaL_checkudata(lua_State *L, int idx, const char *tname) { cTValue *o = index2adr(L, idx); if (tvisudata(o)) { GCudata *ud = udataV(o); cTValue *tv = lj_tab_getstr(tabV(registry(L)), lj_str_newz(L, tname)); if (tv && tvistab(tv) && tabV(tv) == tabref(ud->metatable)) return uddata(ud); } lj_err_argtype(L, idx, tname); return NULL; /* unreachable */ } /* -- Object setters ------------------------------------------------------ */ LUA_API void lua_settable(lua_State *L, int idx) { TValue *o; cTValue *t = index2adr(L, idx); api_checknelems(L, 2); api_checkvalidindex(L, t); o = lj_meta_tset(L, t, L->top-2); if (o) { /* NOBARRIER: lj_meta_tset ensures the table is not black. */ copyTV(L, o, L->top-1); L->top -= 2; } else { L->top += 3; copyTV(L, L->top-1, L->top-6); lj_vm_call(L, L->top-3, 0+1); L->top -= 3; } } LUA_API void lua_setfield(lua_State *L, int idx, const char *k) { TValue *o; TValue key; cTValue *t = index2adr(L, idx); api_checknelems(L, 1); api_checkvalidindex(L, t); setstrV(L, &key, lj_str_newz(L, k)); o = lj_meta_tset(L, t, &key); if (o) { L->top--; /* NOBARRIER: lj_meta_tset ensures the table is not black. */ copyTV(L, o, L->top); } else { L->top += 3; copyTV(L, L->top-1, L->top-6); lj_vm_call(L, L->top-3, 0+1); L->top -= 2; } } LUA_API void lua_rawset(lua_State *L, int idx) { GCtab *t = tabV(index2adr(L, idx)); TValue *dst, *key; api_checknelems(L, 2); key = L->top-2; dst = lj_tab_set(L, t, key); copyTV(L, dst, key+1); lj_gc_anybarriert(L, t); L->top = key; } LUA_API void lua_rawseti(lua_State *L, int idx, int n) { GCtab *t = tabV(index2adr(L, idx)); TValue *dst, *src; api_checknelems(L, 1); dst = lj_tab_setint(L, t, n); src = L->top-1; copyTV(L, dst, src); lj_gc_barriert(L, t, dst); L->top = src; } LUA_API int lua_setmetatable(lua_State *L, int idx) { global_State *g; GCtab *mt; cTValue *o = index2adr(L, idx); api_checknelems(L, 1); api_checkvalidindex(L, o); if (tvisnil(L->top-1)) { mt = NULL; } else { api_check(L, tvistab(L->top-1)); mt = tabV(L->top-1); } g = G(L); if (tvistab(o)) { setgcref(tabV(o)->metatable, obj2gco(mt)); if (mt) lj_gc_objbarriert(L, tabV(o), mt); } else if (tvisudata(o)) { setgcref(udataV(o)->metatable, obj2gco(mt)); if (mt) lj_gc_objbarrier(L, udataV(o), mt); } else { /* Flush cache, since traces specialize to basemt. But not during __gc. */ if (lj_trace_flushall(L)) lj_err_caller(L, LJ_ERR_NOGCMM); if (tvisbool(o)) { /* NOBARRIER: basemt is a GC root. */ setgcref(basemt_it(g, LJ_TTRUE), obj2gco(mt)); setgcref(basemt_it(g, LJ_TFALSE), obj2gco(mt)); } else { /* NOBARRIER: basemt is a GC root. */ setgcref(basemt_obj(g, o), obj2gco(mt)); } } L->top--; return 1; } LUA_API int lua_setfenv(lua_State *L, int idx) { cTValue *o = index2adr(L, idx); GCtab *t; api_checknelems(L, 1); api_checkvalidindex(L, o); api_check(L, tvistab(L->top-1)); t = tabV(L->top-1); if (tvisfunc(o)) { setgcref(funcV(o)->c.env, obj2gco(t)); } else if (tvisudata(o)) { setgcref(udataV(o)->env, obj2gco(t)); } else if (tvisthread(o)) { setgcref(threadV(o)->env, obj2gco(t)); } else { L->top--; return 0; } lj_gc_objbarrier(L, gcV(o), t); L->top--; return 1; } LUA_API const char *lua_setupvalue(lua_State *L, int idx, int n) { cTValue *f = index2adr(L, idx); TValue *val; const char *name; api_checknelems(L, 1); name = lj_debug_uvnamev(f, (uint32_t)(n-1), &val); if (name) { L->top--; copyTV(L, val, L->top); lj_gc_barrier(L, funcV(f), L->top); } return name; } /* -- Calls --------------------------------------------------------------- */ LUA_API void lua_call(lua_State *L, int nargs, int nresults) { api_check(L, L->status == 0 || L->status == LUA_ERRERR); api_checknelems(L, nargs+1); lj_vm_call(L, L->top - nargs, nresults+1); } LUA_API int lua_pcall(lua_State *L, int nargs, int nresults, int errfunc) { global_State *g = G(L); uint8_t oldh = hook_save(g); ptrdiff_t ef; int status; api_check(L, L->status == 0 || L->status == LUA_ERRERR); api_checknelems(L, nargs+1); if (errfunc == 0) { ef = 0; } else { cTValue *o = stkindex2adr(L, errfunc); api_checkvalidindex(L, o); ef = savestack(L, o); } status = lj_vm_pcall(L, L->top - nargs, nresults+1, ef); if (status) hook_restore(g, oldh); return status; } static TValue *cpcall(lua_State *L, lua_CFunction func, void *ud) { GCfunc *fn = lj_func_newC(L, 0, getcurrenv(L)); fn->c.f = func; setfuncV(L, L->top, fn); setlightudV(L->top+1, checklightudptr(L, ud)); cframe_nres(L->cframe) = 1+0; /* Zero results. */ L->top += 2; return L->top-1; /* Now call the newly allocated C function. */ } LUA_API int lua_cpcall(lua_State *L, lua_CFunction func, void *ud) { global_State *g = G(L); uint8_t oldh = hook_save(g); int status; api_check(L, L->status == 0 || L->status == LUA_ERRERR); status = lj_vm_cpcall(L, func, ud, cpcall); if (status) hook_restore(g, oldh); return status; } LUALIB_API int luaL_callmeta(lua_State *L, int idx, const char *field) { if (luaL_getmetafield(L, idx, field)) { TValue *base = L->top--; copyTV(L, base, index2adr(L, idx)); L->top = base+1; lj_vm_call(L, base, 1+1); return 1; } return 0; } /* -- Coroutine yield and resume ------------------------------------------ */ LUA_API int lua_yield(lua_State *L, int nresults) { void *cf = L->cframe; global_State *g = G(L); if (cframe_canyield(cf)) { cf = cframe_raw(cf); if (!hook_active(g)) { /* Regular yield: move results down if needed. */ cTValue *f = L->top - nresults; if (f > L->base) { TValue *t = L->base; while (--nresults >= 0) copyTV(L, t++, f++); L->top = t; } L->cframe = NULL; L->status = LUA_YIELD; return -1; } else { /* Yield from hook: add a pseudo-frame. */ TValue *top = L->top; hook_leave(g); top->u64 = cframe_multres(cf); setcont(top+1, lj_cont_hook); setframe_pc(top+1, cframe_pc(cf)-1); setframe_gc(top+2, obj2gco(L)); setframe_ftsz(top+2, (int)((char *)(top+3)-(char *)L->base)+FRAME_CONT); L->top = L->base = top+3; #if LJ_TARGET_X64 lj_err_throw(L, LUA_YIELD); #else L->cframe = NULL; L->status = LUA_YIELD; lj_vm_unwind_c(cf, LUA_YIELD); #endif } } lj_err_msg(L, LJ_ERR_CYIELD); return 0; /* unreachable */ } LUA_API int lua_resume(lua_State *L, int nargs) { if (L->cframe == NULL && L->status <= LUA_YIELD) return lj_vm_resume(L, L->top - nargs, 0, 0); L->top = L->base; setstrV(L, L->top, lj_err_str(L, LJ_ERR_COSUSP)); incr_top(L); return LUA_ERRRUN; } /* -- GC and memory management -------------------------------------------- */ LUA_API int lua_gc(lua_State *L, int what, int data) { global_State *g = G(L); int res = 0; switch (what) { case LUA_GCSTOP: g->gc.threshold = LJ_MAX_MEM; break; case LUA_GCRESTART: g->gc.threshold = data == -1 ? (g->gc.total/100)*g->gc.pause : g->gc.total; break; case LUA_GCCOLLECT: lj_gc_fullgc(L); break; case LUA_GCCOUNT: res = (int)(g->gc.total >> 10); break; case LUA_GCCOUNTB: res = (int)(g->gc.total & 0x3ff); break; case LUA_GCSTEP: { MSize a = (MSize)data << 10; g->gc.threshold = (a <= g->gc.total) ? (g->gc.total - a) : 0; while (g->gc.total >= g->gc.threshold) if (lj_gc_step(L)) { res = 1; break; } break; } case LUA_GCSETPAUSE: res = (int)(g->gc.pause); g->gc.pause = (MSize)data; break; case LUA_GCSETSTEPMUL: res = (int)(g->gc.stepmul); g->gc.stepmul = (MSize)data; break; default: res = -1; /* Invalid option. */ } return res; } LUA_API lua_Alloc lua_getallocf(lua_State *L, void **ud) { global_State *g = G(L); if (ud) *ud = g->allocd; return g->allocf; } LUA_API void lua_setallocf(lua_State *L, lua_Alloc f, void *ud) { global_State *g = G(L); g->allocd = ud; g->allocf = f; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_arch.h ================================================ /* ** Target architecture selection. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_ARCH_H #define _LJ_ARCH_H #include "lua.h" /* Target endianess. */ #define LUAJIT_LE 0 #define LUAJIT_BE 1 /* Target architectures. */ #define LUAJIT_ARCH_X86 1 #define LUAJIT_ARCH_x86 1 #define LUAJIT_ARCH_X64 2 #define LUAJIT_ARCH_x64 2 #define LUAJIT_ARCH_ARM 3 #define LUAJIT_ARCH_arm 3 #define LUAJIT_ARCH_PPC 4 #define LUAJIT_ARCH_ppc 4 #define LUAJIT_ARCH_PPCSPE 5 #define LUAJIT_ARCH_ppcspe 5 #define LUAJIT_ARCH_MIPS 6 #define LUAJIT_ARCH_mips 6 /* Target OS. */ #define LUAJIT_OS_OTHER 0 #define LUAJIT_OS_WINDOWS 1 #define LUAJIT_OS_LINUX 2 #define LUAJIT_OS_OSX 3 #define LUAJIT_OS_BSD 4 #define LUAJIT_OS_POSIX 5 /* Select native target if no target defined. */ #ifndef LUAJIT_TARGET #if defined(__i386) || defined(__i386__) || defined(_M_IX86) #define LUAJIT_TARGET LUAJIT_ARCH_X86 #elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64) #define LUAJIT_TARGET LUAJIT_ARCH_X64 #elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM) #define LUAJIT_TARGET LUAJIT_ARCH_ARM #elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC) #ifdef __NO_FPRS__ #define LUAJIT_TARGET LUAJIT_ARCH_PPCSPE #else #define LUAJIT_TARGET LUAJIT_ARCH_PPC #endif #elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS) #define LUAJIT_TARGET LUAJIT_ARCH_MIPS #else #error "No support for this architecture (yet)" #endif #endif /* Select native OS if no target OS defined. */ #ifndef LUAJIT_OS #if defined(_WIN32) && !defined(_XBOX_VER) #define LUAJIT_OS LUAJIT_OS_WINDOWS #elif defined(__linux__) #define LUAJIT_OS LUAJIT_OS_LINUX #elif defined(__MACH__) && defined(__APPLE__) #define LUAJIT_OS LUAJIT_OS_OSX #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ defined(__NetBSD__) || defined(__OpenBSD__) #define LUAJIT_OS LUAJIT_OS_BSD #elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__) #define LUAJIT_OS LUAJIT_OS_POSIX #else #define LUAJIT_OS LUAJIT_OS_OTHER #endif #endif /* Set target OS properties. */ #if LUAJIT_OS == LUAJIT_OS_WINDOWS #define LJ_OS_NAME "Windows" #elif LUAJIT_OS == LUAJIT_OS_LINUX #define LJ_OS_NAME "Linux" #elif LUAJIT_OS == LUAJIT_OS_OSX #define LJ_OS_NAME "OSX" #elif LUAJIT_OS == LUAJIT_OS_BSD #define LJ_OS_NAME "BSD" #elif LUAJIT_OS == LUAJIT_OS_POSIX #define LJ_OS_NAME "POSIX" #else #define LJ_OS_NAME "Other" #endif #define LJ_TARGET_WINDOWS (LUAJIT_OS == LUAJIT_OS_WINDOWS) #define LJ_TARGET_LINUX (LUAJIT_OS == LUAJIT_OS_LINUX) #define LJ_TARGET_OSX (LUAJIT_OS == LUAJIT_OS_OSX) #define LJ_TARGET_IOS (LJ_TARGET_OSX && LUAJIT_TARGET == LUAJIT_ARCH_ARM) #define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS) #define LJ_TARGET_DLOPEN LJ_TARGET_POSIX #ifdef __CELLOS_LV2__ #define LJ_TARGET_PS3 1 #define LJ_TARGET_CONSOLE 1 #endif #if _XBOX_VER >= 200 #define LJ_TARGET_XBOX360 1 #define LJ_TARGET_CONSOLE 1 #endif #define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */ #define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */ #define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */ #define LJ_NUMMODE_DUAL_SINGLE 3 /* Default to dual-number mode. */ /* Set target architecture properties. */ #if LUAJIT_TARGET == LUAJIT_ARCH_X86 #define LJ_ARCH_NAME "x86" #define LJ_ARCH_BITS 32 #define LJ_ARCH_ENDIAN LUAJIT_LE #if LJ_TARGET_WINDOWS || __CYGWIN__ #define LJ_ABI_WIN 1 #else #define LJ_ABI_WIN 0 #endif #define LJ_TARGET_X86 1 #define LJ_TARGET_X86ORX64 1 #define LJ_TARGET_EHRETREG 0 #define LJ_TARGET_MASKSHIFT 1 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNALIGNED 1 #define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL #elif LUAJIT_TARGET == LUAJIT_ARCH_X64 #define LJ_ARCH_NAME "x64" #define LJ_ARCH_BITS 64 #define LJ_ARCH_ENDIAN LUAJIT_LE #define LJ_ABI_WIN LJ_TARGET_WINDOWS #define LJ_TARGET_X64 1 #define LJ_TARGET_X86ORX64 1 #define LJ_TARGET_EHRETREG 0 #define LJ_TARGET_JUMPRANGE 31 /* +-2^31 = +-2GB */ #define LJ_TARGET_MASKSHIFT 1 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNALIGNED 1 #define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL #elif LUAJIT_TARGET == LUAJIT_ARCH_ARM #define LJ_ARCH_NAME "arm" #define LJ_ARCH_BITS 32 #define LJ_ARCH_ENDIAN LUAJIT_LE #if !defined(LJ_ARCH_HASFPU) && __SOFTFP__ #define LJ_ARCH_HASFPU 0 #endif #if !defined(LJ_ABI_SOFTFP) && !__ARM_PCS_VFP #define LJ_ABI_SOFTFP 1 #endif #define LJ_ABI_EABI 1 #define LJ_TARGET_ARM 1 #define LJ_TARGET_EHRETREG 0 #define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ #define LJ_TARGET_MASKSHIFT 0 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL #if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ #define LJ_ARCH_VERSION 70 #elif __ARM_ARCH_6T2__ #define LJ_ARCH_VERSION 61 #elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__ #define LJ_ARCH_VERSION 60 #else #define LJ_ARCH_VERSION 50 #endif #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC #define LJ_ARCH_NAME "ppc" #if _LP64 #define LJ_ARCH_BITS 64 #else #define LJ_ARCH_BITS 32 #endif #define LJ_ARCH_ENDIAN LUAJIT_BE #define LJ_TARGET_PPC 1 #define LJ_TARGET_EHRETREG 3 #define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ #define LJ_TARGET_MASKSHIFT 0 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL_SINGLE #if _ARCH_PWR7 #define LJ_ARCH_VERSION 70 #elif _ARCH_PWR6 #define LJ_ARCH_VERSION 60 #elif _ARCH_PWR5X #define LJ_ARCH_VERSION 51 #elif _ARCH_PWR5 #define LJ_ARCH_VERSION 50 #elif _ARCH_PWR4 #define LJ_ARCH_VERSION 40 #else #define LJ_ARCH_VERSION 0 #endif #if __PPC64__ || __powerpc64__ || LJ_TARGET_CONSOLE #define LJ_ARCH_PPC64 1 #define LJ_ARCH_NOFFI 1 #endif #if _ARCH_PPCSQ #define LJ_ARCH_SQRT 1 #endif #if _ARCH_PWR5X #define LJ_ARCH_ROUND 1 #endif #if __PPU__ #define LJ_ARCH_CELL 1 #endif #if LJ_TARGET_XBOX360 #define LJ_ARCH_XENON 1 #endif #elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE #define LJ_ARCH_NAME "ppcspe" #define LJ_ARCH_BITS 32 #define LJ_ARCH_ENDIAN LUAJIT_BE #ifndef LJ_ABI_SOFTFP #define LJ_ABI_SOFTFP 1 #endif #define LJ_ABI_EABI 1 #define LJ_TARGET_PPCSPE 1 #define LJ_TARGET_EHRETREG 3 #define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */ #define LJ_TARGET_MASKSHIFT 0 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */ #define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE #define LJ_ARCH_NOFFI 1 /* NYI: comparisons, calls. */ #define LJ_ARCH_NOJIT 1 #elif LUAJIT_TARGET == LUAJIT_ARCH_MIPS #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) #define LJ_ARCH_NAME "mipsel" #define LJ_ARCH_ENDIAN LUAJIT_LE #else #define LJ_ARCH_NAME "mips" #define LJ_ARCH_ENDIAN LUAJIT_BE #endif #define LJ_ARCH_BITS 32 #define LJ_TARGET_MIPS 1 #define LJ_TARGET_EHRETREG 4 #define LJ_TARGET_JUMPRANGE 27 /* 2*2^27 = 256MB-aligned region */ #define LJ_TARGET_MASKSHIFT 1 #define LJ_TARGET_MASKROT 1 #define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ #define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE #if _MIPS_ARCH_MIPS32R2 #define LJ_ARCH_VERSION 20 #else #define LJ_ARCH_VERSION 10 #endif #else #error "No target architecture defined" #endif #ifndef LJ_PAGESIZE #define LJ_PAGESIZE 4096 #endif /* Check for minimum required compiler versions. */ #if defined(__GNUC__) #if LJ_TARGET_X86 #if (__GNUC__ < 3) || ((__GNUC__ == 3) && __GNUC_MINOR__ < 4) #error "Need at least GCC 3.4 or newer" #endif #elif LJ_TARGET_X64 #if __GNUC__ < 4 #error "Need at least GCC 4.0 or newer" #endif #elif LJ_TARGET_ARM #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2) #error "Need at least GCC 4.2 or newer" #endif #elif !LJ_TARGET_PS3 #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3) #error "Need at least GCC 4.3 or newer" #endif #endif #endif /* Check target-specific constraints. */ #ifndef _BUILDVM_H #if LJ_TARGET_X64 #if __USING_SJLJ_EXCEPTIONS__ #error "Need a C compiler with native exception handling on x64" #endif #elif LJ_TARGET_ARM #if defined(__ARMEB__) #error "No support for big-endian ARM" #endif #if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ #error "No support for Cortex-M CPUs" #endif #if !(__ARM_EABI__ || LJ_TARGET_IOS) #error "Only ARM EABI or iOS 3.0+ ABI is supported" #endif #elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE #if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) #error "No support for PowerPC CPUs without double-precision FPU" #endif #if defined(_LITTLE_ENDIAN) #error "No support for little-endian PowerPC" #endif #if defined(_LP64) #error "No support for PowerPC 64 bit mode" #endif #elif LJ_TARGET_MIPS #if defined(__mips_soft_float) #error "No support for MIPS CPUs without FPU" #endif #endif #endif /* Enable or disable the dual-number mode for the VM. */ #if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \ (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1) #error "No support for this number mode on this architecture" #endif #if LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL || \ (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL_SINGLE && LUAJIT_NUMMODE != 1) || \ (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE_DUAL && LUAJIT_NUMMODE == 2) #define LJ_DUALNUM 1 #else #define LJ_DUALNUM 0 #endif #if LJ_TARGET_IOS || LJ_TARGET_CONSOLE /* Runtime code generation is restricted on iOS. Complain to Apple, not me. */ /* Ditto for the consoles. Complain to Sony or MS, not me. */ #ifndef LUAJIT_ENABLE_JIT #define LJ_OS_NOJIT 1 #endif #endif /* Disable or enable the JIT compiler. */ #if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT) #define LJ_HASJIT 0 #else #define LJ_HASJIT 1 #endif /* Disable or enable the FFI extension. */ #if defined(LUAJIT_DISABLE_FFI) || defined(LJ_ARCH_NOFFI) #define LJ_HASFFI 0 #else #define LJ_HASFFI 1 #endif #ifndef LJ_ARCH_HASFPU #define LJ_ARCH_HASFPU 1 #endif #ifndef LJ_ABI_SOFTFP #define LJ_ABI_SOFTFP 0 #endif #define LJ_SOFTFP (!LJ_ARCH_HASFPU) #if LJ_ARCH_ENDIAN == LUAJIT_BE #define LJ_LE 0 #define LJ_BE 1 #define LJ_ENDIAN_SELECT(le, be) be #define LJ_ENDIAN_LOHI(lo, hi) hi lo #else #define LJ_LE 1 #define LJ_BE 0 #define LJ_ENDIAN_SELECT(le, be) le #define LJ_ENDIAN_LOHI(lo, hi) lo hi #endif #if LJ_ARCH_BITS == 32 #define LJ_32 1 #define LJ_64 0 #else #define LJ_32 0 #define LJ_64 1 #endif #ifndef LJ_TARGET_UNALIGNED #define LJ_TARGET_UNALIGNED 0 #endif /* Various workarounds for embedded operating systems. */ #if (defined(__ANDROID__) && !defined(LJ_TARGET_X86ORX64)) || defined(__symbian__) || LJ_TARGET_XBOX360 #define LUAJIT_NO_LOG2 #endif #if defined(__symbian__) #define LUAJIT_NO_EXP2 #endif #if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 #define LJ_NO_UNWIND 1 #endif /* Compatibility with Lua 5.1 vs. 5.2. */ #ifdef LUAJIT_ENABLE_LUA52COMPAT #define LJ_52 1 #else #define LJ_52 0 #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_asm.c ================================================ /* ** IR assembler (SSA IR -> machine code). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_asm_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_gc.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_frame.h" #if LJ_HASFFI #include "lj_ctype.h" #endif #include "lj_ir.h" #include "lj_jit.h" #include "lj_ircall.h" #include "lj_iropt.h" #include "lj_mcode.h" #include "lj_iropt.h" #include "lj_trace.h" #include "lj_snap.h" #include "lj_asm.h" #include "lj_dispatch.h" #include "lj_vm.h" #include "lj_target.h" /* -- Assembler state and common macros ----------------------------------- */ /* Assembler state. */ typedef struct ASMState { RegCost cost[RID_MAX]; /* Reference and blended allocation cost for regs. */ MCode *mcp; /* Current MCode pointer (grows down). */ MCode *mclim; /* Lower limit for MCode memory + red zone. */ IRIns *ir; /* Copy of pointer to IR instructions/constants. */ jit_State *J; /* JIT compiler state. */ #if LJ_TARGET_X86ORX64 x86ModRM mrm; /* Fused x86 address operand. */ #endif RegSet freeset; /* Set of free registers. */ RegSet modset; /* Set of registers modified inside the loop. */ RegSet weakset; /* Set of weakly referenced registers. */ RegSet phiset; /* Set of PHI registers. */ uint32_t flags; /* Copy of JIT compiler flags. */ int loopinv; /* Loop branch inversion (0:no, 1:yes, 2:yes+CC_P). */ int32_t evenspill; /* Next even spill slot. */ int32_t oddspill; /* Next odd spill slot (or 0). */ IRRef curins; /* Reference of current instruction. */ IRRef stopins; /* Stop assembly before hitting this instruction. */ IRRef orignins; /* Original T->nins. */ IRRef snapref; /* Current snapshot is active after this reference. */ IRRef snaprename; /* Rename highwater mark for snapshot check. */ SnapNo snapno; /* Current snapshot number. */ SnapNo loopsnapno; /* Loop snapshot number. */ IRRef fuseref; /* Fusion limit (loopref, 0 or FUSE_DISABLED). */ IRRef sectref; /* Section base reference (loopref or 0). */ IRRef loopref; /* Reference of LOOP instruction (or 0). */ BCReg topslot; /* Number of slots for stack check (unless 0). */ int32_t gcsteps; /* Accumulated number of GC steps (per section). */ GCtrace *T; /* Trace to assemble. */ GCtrace *parent; /* Parent trace (or NULL). */ MCode *mcbot; /* Bottom of reserved MCode. */ MCode *mctop; /* Top of generated MCode. */ MCode *mcloop; /* Pointer to loop MCode (or NULL). */ MCode *invmcp; /* Points to invertible loop branch (or NULL). */ MCode *flagmcp; /* Pending opportunity to merge flag setting ins. */ MCode *realign; /* Realign loop if not NULL. */ #ifdef RID_NUM_KREF int32_t krefk[RID_NUM_KREF]; #endif IRRef1 phireg[RID_MAX]; /* PHI register references. */ uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */ } ASMState; #define IR(ref) (&as->ir[(ref)]) #define ASMREF_TMP1 REF_TRUE /* Temp. register. */ #define ASMREF_TMP2 REF_FALSE /* Temp. register. */ #define ASMREF_L REF_NIL /* Stores register for L. */ /* Check for variant to invariant references. */ #define iscrossref(as, ref) ((ref) < as->sectref) /* Inhibit memory op fusion from variant to invariant references. */ #define FUSE_DISABLED (~(IRRef)0) #define mayfuse(as, ref) ((ref) > as->fuseref) #define neverfuse(as) (as->fuseref == FUSE_DISABLED) #define canfuse(as, ir) (!neverfuse(as) && !irt_isphi((ir)->t)) #define opisfusableload(o) \ ((o) == IR_ALOAD || (o) == IR_HLOAD || (o) == IR_ULOAD || \ (o) == IR_FLOAD || (o) == IR_XLOAD || (o) == IR_SLOAD || (o) == IR_VLOAD) /* Sparse limit checks using a red zone before the actual limit. */ #define MCLIM_REDZONE 64 #define checkmclim(as) \ if (LJ_UNLIKELY(as->mcp < as->mclim)) asm_mclimit(as) static LJ_NORET LJ_NOINLINE void asm_mclimit(ASMState *as) { lj_mcode_limiterr(as->J, (size_t)(as->mctop - as->mcp + 4*MCLIM_REDZONE)); } #ifdef RID_NUM_KREF #define ra_iskref(ref) ((ref) < RID_NUM_KREF) #define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref))) #define ra_krefk(as, ref) (as->krefk[(ref)]) static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, int32_t k) { IRRef ref = (IRRef)(r - RID_MIN_KREF); as->krefk[ref] = k; as->cost[r] = REGCOST(ref, ref); } #else #define ra_iskref(ref) 0 #define ra_krefreg(ref) RID_MIN_GPR #define ra_krefk(as, ref) 0 #endif /* Arch-specific field offsets. */ static const uint8_t field_ofs[IRFL__MAX+1] = { #define FLOFS(name, ofs) (uint8_t)(ofs), IRFLDEF(FLOFS) #undef FLOFS 0 }; /* -- Target-specific instruction emitter --------------------------------- */ #if LJ_TARGET_X86ORX64 #include "lj_emit_x86.h" #elif LJ_TARGET_ARM #include "lj_emit_arm.h" #elif LJ_TARGET_PPC #include "lj_emit_ppc.h" #elif LJ_TARGET_MIPS #include "lj_emit_mips.h" #else #error "Missing instruction emitter for target CPU" #endif /* -- Register allocator debugging ---------------------------------------- */ /* #define LUAJIT_DEBUG_RA */ #ifdef LUAJIT_DEBUG_RA #include #include #define RIDNAME(name) #name, static const char *const ra_regname[] = { GPRDEF(RIDNAME) FPRDEF(RIDNAME) VRIDDEF(RIDNAME) NULL }; #undef RIDNAME static char ra_dbg_buf[65536]; static char *ra_dbg_p; static char *ra_dbg_merge; static MCode *ra_dbg_mcp; static void ra_dstart(void) { ra_dbg_p = ra_dbg_buf; ra_dbg_merge = NULL; ra_dbg_mcp = NULL; } static void ra_dflush(void) { fwrite(ra_dbg_buf, 1, (size_t)(ra_dbg_p-ra_dbg_buf), stdout); ra_dstart(); } static void ra_dprintf(ASMState *as, const char *fmt, ...) { char *p; va_list argp; va_start(argp, fmt); p = ra_dbg_mcp == as->mcp ? ra_dbg_merge : ra_dbg_p; ra_dbg_mcp = NULL; p += sprintf(p, "%08x \e[36m%04d ", (uintptr_t)as->mcp, as->curins-REF_BIAS); for (;;) { const char *e = strchr(fmt, '$'); if (e == NULL) break; memcpy(p, fmt, (size_t)(e-fmt)); p += e-fmt; if (e[1] == 'r') { Reg r = va_arg(argp, Reg) & RID_MASK; if (r <= RID_MAX) { const char *q; for (q = ra_regname[r]; *q; q++) *p++ = *q >= 'A' && *q <= 'Z' ? *q + 0x20 : *q; } else { *p++ = '?'; lua_assert(0); } } else if (e[1] == 'f' || e[1] == 'i') { IRRef ref; if (e[1] == 'f') ref = va_arg(argp, IRRef); else ref = va_arg(argp, IRIns *) - as->ir; if (ref >= REF_BIAS) p += sprintf(p, "%04d", ref - REF_BIAS); else p += sprintf(p, "K%03d", REF_BIAS - ref); } else if (e[1] == 's') { uint32_t slot = va_arg(argp, uint32_t); p += sprintf(p, "[sp+0x%x]", sps_scale(slot)); } else if (e[1] == 'x') { p += sprintf(p, "%08x", va_arg(argp, int32_t)); } else { lua_assert(0); } fmt = e+2; } va_end(argp); while (*fmt) *p++ = *fmt++; *p++ = '\e'; *p++ = '['; *p++ = 'm'; *p++ = '\n'; if (p > ra_dbg_buf+sizeof(ra_dbg_buf)-256) { fwrite(ra_dbg_buf, 1, (size_t)(p-ra_dbg_buf), stdout); p = ra_dbg_buf; } ra_dbg_p = p; } #define RA_DBG_START() ra_dstart() #define RA_DBG_FLUSH() ra_dflush() #define RA_DBG_REF() \ do { char *_p = ra_dbg_p; ra_dprintf(as, ""); \ ra_dbg_merge = _p; ra_dbg_mcp = as->mcp; } while (0) #define RA_DBGX(x) ra_dprintf x #else #define RA_DBG_START() ((void)0) #define RA_DBG_FLUSH() ((void)0) #define RA_DBG_REF() ((void)0) #define RA_DBGX(x) ((void)0) #endif /* -- Register allocator -------------------------------------------------- */ #define ra_free(as, r) rset_set(as->freeset, (r)) #define ra_modified(as, r) rset_set(as->modset, (r)) #define ra_weak(as, r) rset_set(as->weakset, (r)) #define ra_noweak(as, r) rset_clear(as->weakset, (r)) #define ra_used(ir) (ra_hasreg((ir)->r) || ra_hasspill((ir)->s)) /* Setup register allocator. */ static void ra_setup(ASMState *as) { Reg r; /* Initially all regs (except the stack pointer) are free for use. */ as->freeset = RSET_INIT; as->modset = RSET_EMPTY; as->weakset = RSET_EMPTY; as->phiset = RSET_EMPTY; memset(as->phireg, 0, sizeof(as->phireg)); for (r = RID_MIN_GPR; r < RID_MAX; r++) as->cost[r] = REGCOST(~0u, 0u); } /* Rematerialize constants. */ static Reg ra_rematk(ASMState *as, IRRef ref) { IRIns *ir; Reg r; if (ra_iskref(ref)) { r = ra_krefreg(ref); lua_assert(!rset_test(as->freeset, r)); ra_free(as, r); ra_modified(as, r); emit_loadi(as, r, ra_krefk(as, ref)); return r; } ir = IR(ref); r = ir->r; lua_assert(ra_hasreg(r) && !ra_hasspill(ir->s)); ra_free(as, r); ra_modified(as, r); ir->r = RID_INIT; /* Do not keep any hint. */ RA_DBGX((as, "remat $i $r", ir, r)); #if !LJ_SOFTFP if (ir->o == IR_KNUM) { emit_loadn(as, r, ir_knum(ir)); } else #endif if (emit_canremat(REF_BASE) && ir->o == IR_BASE) { ra_sethint(ir->r, RID_BASE); /* Restore BASE register hint. */ emit_getgl(as, r, jit_base); } else if (emit_canremat(ASMREF_L) && ir->o == IR_KPRI) { lua_assert(irt_isnil(ir->t)); /* REF_NIL stores ASMREF_L register. */ emit_getgl(as, r, jit_L); #if LJ_64 } else if (ir->o == IR_KINT64) { emit_loadu64(as, r, ir_kint64(ir)->u64); #endif } else { lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); emit_loadi(as, r, ir->i); } return r; } /* Force a spill. Allocate a new spill slot if needed. */ static int32_t ra_spill(ASMState *as, IRIns *ir) { int32_t slot = ir->s; if (!ra_hasspill(slot)) { if (irt_is64(ir->t)) { slot = as->evenspill; as->evenspill += 2; } else if (as->oddspill) { slot = as->oddspill; as->oddspill = 0; } else { slot = as->evenspill; as->oddspill = slot+1; as->evenspill += 2; } if (as->evenspill > 256) lj_trace_err(as->J, LJ_TRERR_SPILLOV); ir->s = (uint8_t)slot; } return sps_scale(slot); } /* Release the temporarily allocated register in ASMREF_TMP1/ASMREF_TMP2. */ static Reg ra_releasetmp(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); Reg r = ir->r; lua_assert(ra_hasreg(r) && !ra_hasspill(ir->s)); ra_free(as, r); ra_modified(as, r); ir->r = RID_INIT; return r; } /* Restore a register (marked as free). Rematerialize or force a spill. */ static Reg ra_restore(ASMState *as, IRRef ref) { if (emit_canremat(ref)) { return ra_rematk(as, ref); } else { IRIns *ir = IR(ref); int32_t ofs = ra_spill(as, ir); /* Force a spill slot. */ Reg r = ir->r; lua_assert(ra_hasreg(r)); ra_sethint(ir->r, r); /* Keep hint. */ ra_free(as, r); if (!rset_test(as->weakset, r)) { /* Only restore non-weak references. */ ra_modified(as, r); RA_DBGX((as, "restore $i $r", ir, r)); emit_spload(as, ir, r, ofs); } return r; } } /* Save a register to a spill slot. */ static void ra_save(ASMState *as, IRIns *ir, Reg r) { RA_DBGX((as, "save $i $r", ir, r)); emit_spstore(as, ir, r, sps_scale(ir->s)); } #define MINCOST(name) \ if (rset_test(RSET_ALL, RID_##name) && \ LJ_LIKELY(allow&RID2RSET(RID_##name)) && as->cost[RID_##name] < cost) \ cost = as->cost[RID_##name]; /* Evict the register with the lowest cost, forcing a restore. */ static Reg ra_evict(ASMState *as, RegSet allow) { IRRef ref; RegCost cost = ~(RegCost)0; lua_assert(allow != RSET_EMPTY); if (RID_NUM_FPR == 0 || allow < RID2RSET(RID_MAX_GPR)) { GPRDEF(MINCOST) } else { FPRDEF(MINCOST) } ref = regcost_ref(cost); lua_assert(ra_iskref(ref) || (ref >= as->T->nk && ref < as->T->nins)); /* Preferably pick any weak ref instead of a non-weak, non-const ref. */ if (!irref_isk(ref) && (as->weakset & allow)) { IRIns *ir = IR(ref); if (!rset_test(as->weakset, ir->r)) ref = regcost_ref(as->cost[rset_pickbot((as->weakset & allow))]); } return ra_restore(as, ref); } /* Pick any register (marked as free). Evict on-demand. */ static Reg ra_pick(ASMState *as, RegSet allow) { RegSet pick = as->freeset & allow; if (!pick) return ra_evict(as, allow); else return rset_picktop(pick); } /* Get a scratch register (marked as free). */ static Reg ra_scratch(ASMState *as, RegSet allow) { Reg r = ra_pick(as, allow); ra_modified(as, r); RA_DBGX((as, "scratch $r", r)); return r; } /* Evict all registers from a set (if not free). */ static void ra_evictset(ASMState *as, RegSet drop) { RegSet work; as->modset |= drop; #if !LJ_SOFTFP work = (drop & ~as->freeset) & RSET_FPR; while (work) { Reg r = rset_pickbot(work); ra_restore(as, regcost_ref(as->cost[r])); rset_clear(work, r); checkmclim(as); } #endif work = (drop & ~as->freeset); while (work) { Reg r = rset_pickbot(work); ra_restore(as, regcost_ref(as->cost[r])); rset_clear(work, r); checkmclim(as); } } /* Evict (rematerialize) all registers allocated to constants. */ static void ra_evictk(ASMState *as) { RegSet work; #if !LJ_SOFTFP work = ~as->freeset & RSET_FPR; while (work) { Reg r = rset_pickbot(work); IRRef ref = regcost_ref(as->cost[r]); if (emit_canremat(ref) && irref_isk(ref)) { ra_rematk(as, ref); checkmclim(as); } rset_clear(work, r); } #endif work = ~as->freeset & RSET_GPR; while (work) { Reg r = rset_pickbot(work); IRRef ref = regcost_ref(as->cost[r]); if (emit_canremat(ref) && irref_isk(ref)) { ra_rematk(as, ref); checkmclim(as); } rset_clear(work, r); } } #ifdef RID_NUM_KREF /* Allocate a register for a constant. */ static Reg ra_allock(ASMState *as, int32_t k, RegSet allow) { /* First try to find a register which already holds the same constant. */ RegSet pick, work = ~as->freeset & RSET_GPR; Reg r; while (work) { IRRef ref; r = rset_pickbot(work); ref = regcost_ref(as->cost[r]); if (ref < ASMREF_L && k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i)) return r; rset_clear(work, r); } pick = as->freeset & allow; if (pick) { /* Constants should preferably get unmodified registers. */ if ((pick & ~as->modset)) pick &= ~as->modset; r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */ } else { r = ra_evict(as, allow); } RA_DBGX((as, "allock $x $r", k, r)); ra_setkref(as, r, k); rset_clear(as->freeset, r); ra_noweak(as, r); return r; } /* Allocate a specific register for a constant. */ static void ra_allockreg(ASMState *as, int32_t k, Reg r) { Reg kr = ra_allock(as, k, RID2RSET(r)); if (kr != r) { IRIns irdummy; irdummy.t.irt = IRT_INT; ra_scratch(as, RID2RSET(r)); emit_movrr(as, &irdummy, r, kr); } } #else #define ra_allockreg(as, k, r) emit_loadi(as, (r), (k)) #endif /* Allocate a register for ref from the allowed set of registers. ** Note: this function assumes the ref does NOT have a register yet! ** Picks an optimal register, sets the cost and marks the register as non-free. */ static Reg ra_allocref(ASMState *as, IRRef ref, RegSet allow) { IRIns *ir = IR(ref); RegSet pick = as->freeset & allow; Reg r; lua_assert(ra_noreg(ir->r)); if (pick) { /* First check register hint from propagation or PHI. */ if (ra_hashint(ir->r)) { r = ra_gethint(ir->r); if (rset_test(pick, r)) /* Use hint register if possible. */ goto found; /* Rematerialization is cheaper than missing a hint. */ if (rset_test(allow, r) && emit_canremat(regcost_ref(as->cost[r]))) { ra_rematk(as, regcost_ref(as->cost[r])); goto found; } RA_DBGX((as, "hintmiss $f $r", ref, r)); } /* Invariants should preferably get unmodified registers. */ if (ref < as->loopref && !irt_isphi(ir->t)) { if ((pick & ~as->modset)) pick &= ~as->modset; r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */ } else { /* We've got plenty of regs, so get callee-save regs if possible. */ if (RID_NUM_GPR > 8 && (pick & ~RSET_SCRATCH)) pick &= ~RSET_SCRATCH; r = rset_picktop(pick); } } else { r = ra_evict(as, allow); } found: RA_DBGX((as, "alloc $f $r", ref, r)); ir->r = (uint8_t)r; rset_clear(as->freeset, r); ra_noweak(as, r); as->cost[r] = REGCOST_REF_T(ref, irt_t(ir->t)); return r; } /* Allocate a register on-demand. */ static Reg ra_alloc1(ASMState *as, IRRef ref, RegSet allow) { Reg r = IR(ref)->r; /* Note: allow is ignored if the register is already allocated. */ if (ra_noreg(r)) r = ra_allocref(as, ref, allow); ra_noweak(as, r); return r; } /* Rename register allocation and emit move. */ static void ra_rename(ASMState *as, Reg down, Reg up) { IRRef ren, ref = regcost_ref(as->cost[up] = as->cost[down]); IRIns *ir = IR(ref); ir->r = (uint8_t)up; as->cost[down] = 0; lua_assert((down < RID_MAX_GPR) == (up < RID_MAX_GPR)); lua_assert(!rset_test(as->freeset, down) && rset_test(as->freeset, up)); ra_free(as, down); /* 'down' is free ... */ ra_modified(as, down); rset_clear(as->freeset, up); /* ... and 'up' is now allocated. */ ra_noweak(as, up); RA_DBGX((as, "rename $f $r $r", regcost_ref(as->cost[up]), down, up)); emit_movrr(as, ir, down, up); /* Backwards codegen needs inverse move. */ if (!ra_hasspill(IR(ref)->s)) { /* Add the rename to the IR. */ lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), ref, as->snapno); ren = tref_ref(lj_ir_emit(as->J)); as->ir = as->T->ir; /* The IR may have been reallocated. */ IR(ren)->r = (uint8_t)down; IR(ren)->s = SPS_NONE; } } /* Pick a destination register (marked as free). ** Caveat: allow is ignored if there's already a destination register. ** Use ra_destreg() to get a specific register. */ static Reg ra_dest(ASMState *as, IRIns *ir, RegSet allow) { Reg dest = ir->r; if (ra_hasreg(dest)) { ra_free(as, dest); ra_modified(as, dest); } else { if (ra_hashint(dest) && rset_test((as->freeset&allow), ra_gethint(dest))) { dest = ra_gethint(dest); ra_modified(as, dest); RA_DBGX((as, "dest $r", dest)); } else { dest = ra_scratch(as, allow); } ir->r = dest; } if (LJ_UNLIKELY(ra_hasspill(ir->s))) ra_save(as, ir, dest); return dest; } /* Force a specific destination register (marked as free). */ static void ra_destreg(ASMState *as, IRIns *ir, Reg r) { Reg dest = ra_dest(as, ir, RID2RSET(r)); if (dest != r) { lua_assert(rset_test(as->freeset, r)); ra_modified(as, r); emit_movrr(as, ir, dest, r); } } #if LJ_TARGET_X86ORX64 /* Propagate dest register to left reference. Emit moves as needed. ** This is a required fixup step for all 2-operand machine instructions. */ static void ra_left(ASMState *as, Reg dest, IRRef lref) { IRIns *ir = IR(lref); Reg left = ir->r; if (ra_noreg(left)) { if (irref_isk(lref)) { if (ir->o == IR_KNUM) { cTValue *tv = ir_knum(ir); /* FP remat needs a load except for +0. Still better than eviction. */ if (tvispzero(tv) || !(as->freeset & RSET_FPR)) { emit_loadn(as, dest, tv); return; } #if LJ_64 } else if (ir->o == IR_KINT64) { emit_loadu64(as, dest, ir_kint64(ir)->u64); return; #endif } else { lua_assert(ir->o == IR_KINT || ir->o == IR_KGC || ir->o == IR_KPTR || ir->o == IR_KKPTR || ir->o == IR_KNULL); emit_loadi(as, dest, ir->i); return; } } if (!ra_hashint(left) && !iscrossref(as, lref)) ra_sethint(ir->r, dest); /* Propagate register hint. */ left = ra_allocref(as, lref, dest < RID_MAX_GPR ? RSET_GPR : RSET_FPR); } ra_noweak(as, left); /* Move needed for true 3-operand instruction: y=a+b ==> y=a; y+=b. */ if (dest != left) { /* Use register renaming if dest is the PHI reg. */ if (irt_isphi(ir->t) && as->phireg[dest] == lref) { ra_modified(as, left); ra_rename(as, left, dest); } else { emit_movrr(as, ir, dest, left); } } } #else /* Similar to ra_left, except we override any hints. */ static void ra_leftov(ASMState *as, Reg dest, IRRef lref) { IRIns *ir = IR(lref); Reg left = ir->r; if (ra_noreg(left)) { ra_sethint(ir->r, dest); /* Propagate register hint. */ left = ra_allocref(as, lref, (LJ_SOFTFP || dest < RID_MAX_GPR) ? RSET_GPR : RSET_FPR); } ra_noweak(as, left); if (dest != left) { /* Use register renaming if dest is the PHI reg. */ if (irt_isphi(ir->t) && as->phireg[dest] == lref) { ra_modified(as, left); ra_rename(as, left, dest); } else { emit_movrr(as, ir, dest, left); } } } #endif #if !LJ_64 /* Force a RID_RETLO/RID_RETHI destination register pair (marked as free). */ static void ra_destpair(ASMState *as, IRIns *ir) { Reg destlo = ir->r, desthi = (ir+1)->r; /* First spill unrelated refs blocking the destination registers. */ if (!rset_test(as->freeset, RID_RETLO) && destlo != RID_RETLO && desthi != RID_RETLO) ra_restore(as, regcost_ref(as->cost[RID_RETLO])); if (!rset_test(as->freeset, RID_RETHI) && destlo != RID_RETHI && desthi != RID_RETHI) ra_restore(as, regcost_ref(as->cost[RID_RETHI])); /* Next free the destination registers (if any). */ if (ra_hasreg(destlo)) { ra_free(as, destlo); ra_modified(as, destlo); } else { destlo = RID_RETLO; } if (ra_hasreg(desthi)) { ra_free(as, desthi); ra_modified(as, desthi); } else { desthi = RID_RETHI; } /* Check for conflicts and shuffle the registers as needed. */ if (destlo == RID_RETHI) { if (desthi == RID_RETLO) { #if LJ_TARGET_X86 *--as->mcp = XI_XCHGa + RID_RETHI; #else emit_movrr(as, ir, RID_RETHI, RID_TMP); emit_movrr(as, ir, RID_RETLO, RID_RETHI); emit_movrr(as, ir, RID_TMP, RID_RETLO); #endif } else { emit_movrr(as, ir, RID_RETHI, RID_RETLO); if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI); } } else if (desthi == RID_RETLO) { emit_movrr(as, ir, RID_RETLO, RID_RETHI); if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO); } else { if (desthi != RID_RETHI) emit_movrr(as, ir, desthi, RID_RETHI); if (destlo != RID_RETLO) emit_movrr(as, ir, destlo, RID_RETLO); } /* Restore spill slots (if any). */ if (ra_hasspill((ir+1)->s)) ra_save(as, ir+1, RID_RETHI); if (ra_hasspill(ir->s)) ra_save(as, ir, RID_RETLO); } #endif /* -- Snapshot handling --------- ----------------------------------------- */ /* Can we rematerialize a KNUM instead of forcing a spill? */ static int asm_snap_canremat(ASMState *as) { Reg r; for (r = RID_MIN_FPR; r < RID_MAX_FPR; r++) if (irref_isk(regcost_ref(as->cost[r]))) return 1; return 0; } /* Check whether a sunk store corresponds to an allocation. */ static int asm_sunk_store(ASMState *as, IRIns *ira, IRIns *irs) { if (irs->s == 255) { if (irs->o == IR_ASTORE || irs->o == IR_HSTORE || irs->o == IR_FSTORE || irs->o == IR_XSTORE) { IRIns *irk = IR(irs->op1); if (irk->o == IR_AREF || irk->o == IR_HREFK) irk = IR(irk->op1); return (IR(irk->op1) == ira); } return 0; } else { return (ira + irs->s == irs); /* Quick check. */ } } /* Allocate register or spill slot for a ref that escapes to a snapshot. */ static void asm_snap_alloc1(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); if (!irref_isk(ref) && (!(ra_used(ir) || ir->r == RID_SUNK))) { if (ir->r == RID_SINK) { ir->r = RID_SUNK; #if LJ_HASFFI if (ir->o == IR_CNEWI) { /* Allocate CNEWI value. */ asm_snap_alloc1(as, ir->op2); if (LJ_32 && (ir+1)->o == IR_HIOP) asm_snap_alloc1(as, (ir+1)->op2); } else #endif { /* Allocate stored values for TNEW, TDUP and CNEW. */ IRIns *irs; lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW); for (irs = IR(as->snapref-1); irs > ir; irs--) if (irs->r == RID_SINK && asm_sunk_store(as, ir, irs)) { lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || irs->o == IR_FSTORE || irs->o == IR_XSTORE); asm_snap_alloc1(as, irs->op2); if (LJ_32 && (irs+1)->o == IR_HIOP) asm_snap_alloc1(as, (irs+1)->op2); } } } else { RegSet allow; if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT) { IRIns *irc; for (irc = IR(as->curins); irc > ir; irc--) if ((irc->op1 == ref || irc->op2 == ref) && !(irc->r == RID_SINK || irc->r == RID_SUNK)) goto nosink; /* Don't sink conversion if result is used. */ asm_snap_alloc1(as, ir->op1); return; } nosink: allow = (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR; if ((as->freeset & allow) || (allow == RSET_FPR && asm_snap_canremat(as))) { /* Get a weak register if we have a free one or can rematerialize. */ Reg r = ra_allocref(as, ref, allow); /* Allocate a register. */ if (!irt_isphi(ir->t)) ra_weak(as, r); /* But mark it as weakly referenced. */ checkmclim(as); RA_DBGX((as, "snapreg $f $r", ref, ir->r)); } else { ra_spill(as, ir); /* Otherwise force a spill slot. */ RA_DBGX((as, "snapspill $f $s", ref, ir->s)); } } } } /* Allocate refs escaping to a snapshot. */ static void asm_snap_alloc(ASMState *as) { SnapShot *snap = &as->T->snap[as->snapno]; SnapEntry *map = &as->T->snapmap[snap->mapofs]; MSize n, nent = snap->nent; for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; IRRef ref = snap_ref(sn); if (!irref_isk(ref)) { asm_snap_alloc1(as, ref); if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) { lua_assert(irt_type(IR(ref+1)->t) == IRT_SOFTFP); asm_snap_alloc1(as, ref+1); } } } } /* All guards for a snapshot use the same exitno. This is currently the ** same as the snapshot number. Since the exact origin of the exit cannot ** be determined, all guards for the same snapshot must exit with the same ** RegSP mapping. ** A renamed ref which has been used in a prior guard for the same snapshot ** would cause an inconsistency. The easy way out is to force a spill slot. */ static int asm_snap_checkrename(ASMState *as, IRRef ren) { SnapShot *snap = &as->T->snap[as->snapno]; SnapEntry *map = &as->T->snapmap[snap->mapofs]; MSize n, nent = snap->nent; for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; IRRef ref = snap_ref(sn); if (ref == ren || (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && ++ref == ren)) { IRIns *ir = IR(ref); ra_spill(as, ir); /* Register renamed, so force a spill slot. */ RA_DBGX((as, "snaprensp $f $s", ref, ir->s)); return 1; /* Found. */ } } return 0; /* Not found. */ } /* Prepare snapshot for next guard instruction. */ static void asm_snap_prep(ASMState *as) { if (as->curins < as->snapref) { do { if (as->snapno == 0) return; /* Called by sunk stores before snap #0. */ as->snapno--; as->snapref = as->T->snap[as->snapno].ref; } while (as->curins < as->snapref); asm_snap_alloc(as); as->snaprename = as->T->nins; } else { /* Process any renames above the highwater mark. */ for (; as->snaprename < as->T->nins; as->snaprename++) { IRIns *ir = IR(as->snaprename); if (asm_snap_checkrename(as, ir->op1)) ir->op2 = REF_BIAS-1; /* Kill rename. */ } } } /* -- Miscellaneous helpers ----------------------------------------------- */ /* Collect arguments from CALL* and CARG instructions. */ static void asm_collectargs(ASMState *as, IRIns *ir, const CCallInfo *ci, IRRef *args) { uint32_t n = CCI_NARGS(ci); lua_assert(n <= CCI_NARGS_MAX); if ((ci->flags & CCI_L)) { *args++ = ASMREF_L; n--; } while (n-- > 1) { ir = IR(ir->op1); lua_assert(ir->o == IR_CARG); args[n] = ir->op2 == REF_NIL ? 0 : ir->op2; } args[0] = ir->op1 == REF_NIL ? 0 : ir->op1; lua_assert(IR(ir->op1)->o != IR_CARG); } /* Reconstruct CCallInfo flags for CALLX*. */ static uint32_t asm_callx_flags(ASMState *as, IRIns *ir) { uint32_t nargs = 0; if (ir->op1 != REF_NIL) { /* Count number of arguments first. */ IRIns *ira = IR(ir->op1); nargs++; while (ira->o == IR_CARG) { nargs++; ira = IR(ira->op1); } } #if LJ_HASFFI if (IR(ir->op2)->o == IR_CARG) { /* Copy calling convention info. */ CTypeID id = (CTypeID)IR(IR(ir->op2)->op2)->i; CType *ct = ctype_get(ctype_ctsG(J2G(as->J)), id); nargs |= ((ct->info & CTF_VARARG) ? CCI_VARARG : 0); #if LJ_TARGET_X86 nargs |= (ctype_cconv(ct->info) << CCI_CC_SHIFT); #endif } #endif return (nargs | (ir->t.irt << CCI_OTSHIFT)); } /* Calculate stack adjustment. */ static int32_t asm_stack_adjust(ASMState *as) { if (as->evenspill <= SPS_FIXED) return 0; return sps_scale(sps_align(as->evenspill)); } /* Must match with hash*() in lj_tab.c. */ static uint32_t ir_khash(IRIns *ir) { uint32_t lo, hi; if (irt_isstr(ir->t)) { return ir_kstr(ir)->hash; } else if (irt_isnum(ir->t)) { lo = ir_knum(ir)->u32.lo; hi = ir_knum(ir)->u32.hi << 1; } else if (irt_ispri(ir->t)) { lua_assert(!irt_isnil(ir->t)); return irt_type(ir->t)-IRT_FALSE; } else { lua_assert(irt_isgcv(ir->t)); lo = u32ptr(ir_kgc(ir)); hi = lo + HASH_BIAS; } return hashrot(lo, hi); } /* -- Allocations --------------------------------------------------------- */ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args); static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci); static void asm_snew(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_new]; IRRef args[3]; args[0] = ASMREF_L; /* lua_State *L */ args[1] = ir->op1; /* const char *str */ args[2] = ir->op2; /* size_t len */ as->gcsteps++; asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); } static void asm_tnew(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_new1]; IRRef args[2]; args[0] = ASMREF_L; /* lua_State *L */ args[1] = ASMREF_TMP1; /* uint32_t ahsize */ as->gcsteps++; asm_setupresult(as, ir, ci); /* GCtab * */ asm_gencall(as, ci, args); ra_allockreg(as, ir->op1 | (ir->op2 << 24), ra_releasetmp(as, ASMREF_TMP1)); } static void asm_tdup(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_dup]; IRRef args[2]; args[0] = ASMREF_L; /* lua_State *L */ args[1] = ir->op1; /* const GCtab *kt */ as->gcsteps++; asm_setupresult(as, ir, ci); /* GCtab * */ asm_gencall(as, ci, args); } static void asm_gc_check(ASMState *as); /* Explicit GC step. */ static void asm_gcstep(ASMState *as, IRIns *ir) { IRIns *ira; for (ira = IR(as->stopins+1); ira < ir; ira++) if ((ira->o == IR_TNEW || ira->o == IR_TDUP || (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI))) && ra_used(ira)) as->gcsteps++; if (as->gcsteps) asm_gc_check(as); as->gcsteps = 0x80000000; /* Prevent implicit GC check further up. */ } /* -- PHI and loop handling ----------------------------------------------- */ /* Break a PHI cycle by renaming to a free register (evict if needed). */ static void asm_phi_break(ASMState *as, RegSet blocked, RegSet blockedby, RegSet allow) { RegSet candidates = blocked & allow; if (candidates) { /* If this register file has candidates. */ /* Note: the set for ra_pick cannot be empty, since each register file ** has some registers never allocated to PHIs. */ Reg down, up = ra_pick(as, ~blocked & allow); /* Get a free register. */ if (candidates & ~blockedby) /* Optimize shifts, else it's a cycle. */ candidates = candidates & ~blockedby; down = rset_picktop(candidates); /* Pick candidate PHI register. */ ra_rename(as, down, up); /* And rename it to the free register. */ } } /* PHI register shuffling. ** ** The allocator tries hard to preserve PHI register assignments across ** the loop body. Most of the time this loop does nothing, since there ** are no register mismatches. ** ** If a register mismatch is detected and ... ** - the register is currently free: rename it. ** - the register is blocked by an invariant: restore/remat and rename it. ** - Otherwise the register is used by another PHI, so mark it as blocked. ** ** The renames are order-sensitive, so just retry the loop if a register ** is marked as blocked, but has been freed in the meantime. A cycle is ** detected if all of the blocked registers are allocated. To break the ** cycle rename one of them to a free register and retry. ** ** Note that PHI spill slots are kept in sync and don't need to be shuffled. */ static void asm_phi_shuffle(ASMState *as) { RegSet work; /* Find and resolve PHI register mismatches. */ for (;;) { RegSet blocked = RSET_EMPTY; RegSet blockedby = RSET_EMPTY; RegSet phiset = as->phiset; while (phiset) { /* Check all left PHI operand registers. */ Reg r = rset_pickbot(phiset); IRIns *irl = IR(as->phireg[r]); Reg left = irl->r; if (r != left) { /* Mismatch? */ if (!rset_test(as->freeset, r)) { /* PHI register blocked? */ IRRef ref = regcost_ref(as->cost[r]); /* Blocked by other PHI (w/reg)? */ if (!ra_iskref(ref) && irt_ismarked(IR(ref)->t)) { rset_set(blocked, r); if (ra_hasreg(left)) rset_set(blockedby, left); left = RID_NONE; } else { /* Otherwise grab register from invariant. */ ra_restore(as, ref); checkmclim(as); } } if (ra_hasreg(left)) { ra_rename(as, left, r); checkmclim(as); } } rset_clear(phiset, r); } if (!blocked) break; /* Finished. */ if (!(as->freeset & blocked)) { /* Break cycles if none are free. */ asm_phi_break(as, blocked, blockedby, RSET_GPR); if (!LJ_SOFTFP) asm_phi_break(as, blocked, blockedby, RSET_FPR); checkmclim(as); } /* Else retry some more renames. */ } /* Restore/remat invariants whose registers are modified inside the loop. */ #if !LJ_SOFTFP work = as->modset & ~(as->freeset | as->phiset) & RSET_FPR; while (work) { Reg r = rset_pickbot(work); ra_restore(as, regcost_ref(as->cost[r])); rset_clear(work, r); checkmclim(as); } #endif work = as->modset & ~(as->freeset | as->phiset); while (work) { Reg r = rset_pickbot(work); ra_restore(as, regcost_ref(as->cost[r])); rset_clear(work, r); checkmclim(as); } /* Allocate and save all unsaved PHI regs and clear marks. */ work = as->phiset; while (work) { Reg r = rset_picktop(work); IRRef lref = as->phireg[r]; IRIns *ir = IR(lref); if (ra_hasspill(ir->s)) { /* Left PHI gained a spill slot? */ irt_clearmark(ir->t); /* Handled here, so clear marker now. */ ra_alloc1(as, lref, RID2RSET(r)); ra_save(as, ir, r); /* Save to spill slot inside the loop. */ checkmclim(as); } rset_clear(work, r); } } /* Copy unsynced left/right PHI spill slots. Rarely needed. */ static void asm_phi_copyspill(ASMState *as) { int need = 0; IRIns *ir; for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) if (ra_hasspill(ir->s) && ra_hasspill(IR(ir->op1)->s)) need |= irt_isfp(ir->t) ? 2 : 1; /* Unsynced spill slot? */ if ((need & 1)) { /* Copy integer spill slots. */ #if !LJ_TARGET_X86ORX64 Reg r = RID_TMP; #else Reg r = RID_RET; if ((as->freeset & RSET_GPR)) r = rset_pickbot((as->freeset & RSET_GPR)); else emit_spload(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); #endif for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) { if (ra_hasspill(ir->s)) { IRIns *irl = IR(ir->op1); if (ra_hasspill(irl->s) && !irt_isfp(ir->t)) { emit_spstore(as, irl, r, sps_scale(irl->s)); emit_spload(as, ir, r, sps_scale(ir->s)); } } } #if LJ_TARGET_X86ORX64 if (!rset_test(as->freeset, r)) emit_spstore(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); #endif } #if !LJ_SOFTFP if ((need & 2)) { /* Copy FP spill slots. */ #if LJ_TARGET_X86 Reg r = RID_XMM0; #else Reg r = RID_FPRET; #endif if ((as->freeset & RSET_FPR)) r = rset_pickbot((as->freeset & RSET_FPR)); if (!rset_test(as->freeset, r)) emit_spload(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); for (ir = IR(as->orignins-1); ir->o == IR_PHI; ir--) { if (ra_hasspill(ir->s)) { IRIns *irl = IR(ir->op1); if (ra_hasspill(irl->s) && irt_isfp(ir->t)) { emit_spstore(as, irl, r, sps_scale(irl->s)); emit_spload(as, ir, r, sps_scale(ir->s)); } } } if (!rset_test(as->freeset, r)) emit_spstore(as, IR(regcost_ref(as->cost[r])), r, SPOFS_TMP); } #endif } /* Emit renames for left PHIs which are only spilled outside the loop. */ static void asm_phi_fixup(ASMState *as) { RegSet work = as->phiset; while (work) { Reg r = rset_picktop(work); IRRef lref = as->phireg[r]; IRIns *ir = IR(lref); /* Left PHI gained a spill slot before the loop? */ if (irt_ismarked(ir->t) && ra_hasspill(ir->s)) { IRRef ren; lj_ir_set(as->J, IRT(IR_RENAME, IRT_NIL), lref, as->loopsnapno); ren = tref_ref(lj_ir_emit(as->J)); as->ir = as->T->ir; /* The IR may have been reallocated. */ IR(ren)->r = (uint8_t)r; IR(ren)->s = SPS_NONE; } irt_clearmark(ir->t); /* Always clear marker. */ rset_clear(work, r); } } /* Setup right PHI reference. */ static void asm_phi(ASMState *as, IRIns *ir) { RegSet allow = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & ~as->phiset; RegSet afree = (as->freeset & allow); IRIns *irl = IR(ir->op1); IRIns *irr = IR(ir->op2); if (ir->r == RID_SINK) /* Sink PHI. */ return; /* Spill slot shuffling is not implemented yet (but rarely needed). */ if (ra_hasspill(irl->s) || ra_hasspill(irr->s)) lj_trace_err(as->J, LJ_TRERR_NYIPHI); /* Leave at least one register free for non-PHIs (and PHI cycle breaking). */ if ((afree & (afree-1))) { /* Two or more free registers? */ Reg r; if (ra_noreg(irr->r)) { /* Get a register for the right PHI. */ r = ra_allocref(as, ir->op2, allow); } else { /* Duplicate right PHI, need a copy (rare). */ r = ra_scratch(as, allow); emit_movrr(as, irr, r, irr->r); } ir->r = (uint8_t)r; rset_set(as->phiset, r); as->phireg[r] = (IRRef1)ir->op1; irt_setmark(irl->t); /* Marks left PHIs _with_ register. */ if (ra_noreg(irl->r)) ra_sethint(irl->r, r); /* Set register hint for left PHI. */ } else { /* Otherwise allocate a spill slot. */ /* This is overly restrictive, but it triggers only on synthetic code. */ if (ra_hasreg(irl->r) || ra_hasreg(irr->r)) lj_trace_err(as->J, LJ_TRERR_NYIPHI); ra_spill(as, ir); irr->s = ir->s; /* Set right PHI spill slot. Sync left slot later. */ } } static void asm_loop_fixup(ASMState *as); /* Middle part of a loop. */ static void asm_loop(ASMState *as) { MCode *mcspill; /* LOOP is a guard, so the snapno is up to date. */ as->loopsnapno = as->snapno; if (as->gcsteps) asm_gc_check(as); /* LOOP marks the transition from the variant to the invariant part. */ as->flagmcp = as->invmcp = NULL; as->sectref = 0; if (!neverfuse(as)) as->fuseref = 0; asm_phi_shuffle(as); mcspill = as->mcp; asm_phi_copyspill(as); asm_loop_fixup(as); as->mcloop = as->mcp; RA_DBGX((as, "===== LOOP =====")); if (!as->realign) RA_DBG_FLUSH(); if (as->mcp != mcspill) emit_jmp(as, mcspill); } /* -- Target-specific assembler ------------------------------------------- */ #if LJ_TARGET_X86ORX64 #include "lj_asm_x86.h" #elif LJ_TARGET_ARM #include "lj_asm_arm.h" #elif LJ_TARGET_PPC #include "lj_asm_ppc.h" #elif LJ_TARGET_MIPS #include "lj_asm_mips.h" #else #error "Missing assembler for target CPU" #endif /* -- Head of trace ------------------------------------------------------- */ /* Head of a root trace. */ static void asm_head_root(ASMState *as) { int32_t spadj; asm_head_root_base(as); emit_setvmstate(as, (int32_t)as->T->traceno); spadj = asm_stack_adjust(as); as->T->spadjust = (uint16_t)spadj; emit_spsub(as, spadj); /* Root traces assume a checked stack for the starting proto. */ as->T->topslot = gcref(as->T->startpt)->pt.framesize; } /* Head of a side trace. ** ** The current simplistic algorithm requires that all slots inherited ** from the parent are live in a register between pass 2 and pass 3. This ** avoids the complexity of stack slot shuffling. But of course this may ** overflow the register set in some cases and cause the dreaded error: ** "NYI: register coalescing too complex". A refined algorithm is needed. */ static void asm_head_side(ASMState *as) { IRRef1 sloadins[RID_MAX]; RegSet allow = RSET_ALL; /* Inverse of all coalesced registers. */ RegSet live = RSET_EMPTY; /* Live parent registers. */ IRIns *irp = &as->parent->ir[REF_BASE]; /* Parent base. */ int32_t spadj, spdelta; int pass2 = 0; int pass3 = 0; IRRef i; allow = asm_head_side_base(as, irp, allow); /* Scan all parent SLOADs and collect register dependencies. */ for (i = as->stopins; i > REF_BASE; i--) { IRIns *ir = IR(i); RegSP rs; lua_assert((ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_PARENT)) || (LJ_SOFTFP && ir->o == IR_HIOP) || ir->o == IR_PVAL); rs = as->parentmap[i - REF_FIRST]; if (ra_hasreg(ir->r)) { rset_clear(allow, ir->r); if (ra_hasspill(ir->s)) { ra_save(as, ir, ir->r); checkmclim(as); } } else if (ra_hasspill(ir->s)) { irt_setmark(ir->t); pass2 = 1; } if (ir->r == rs) { /* Coalesce matching registers right now. */ ra_free(as, ir->r); } else if (ra_hasspill(regsp_spill(rs))) { if (ra_hasreg(ir->r)) pass3 = 1; } else if (ra_used(ir)) { sloadins[rs] = (IRRef1)i; rset_set(live, rs); /* Block live parent register. */ } } /* Calculate stack frame adjustment. */ spadj = asm_stack_adjust(as); spdelta = spadj - (int32_t)as->parent->spadjust; if (spdelta < 0) { /* Don't shrink the stack frame. */ spadj = (int32_t)as->parent->spadjust; spdelta = 0; } as->T->spadjust = (uint16_t)spadj; /* Reload spilled target registers. */ if (pass2) { for (i = as->stopins; i > REF_BASE; i--) { IRIns *ir = IR(i); if (irt_ismarked(ir->t)) { RegSet mask; Reg r; RegSP rs; irt_clearmark(ir->t); rs = as->parentmap[i - REF_FIRST]; if (!ra_hasspill(regsp_spill(rs))) ra_sethint(ir->r, rs); /* Hint may be gone, set it again. */ else if (sps_scale(regsp_spill(rs))+spdelta == sps_scale(ir->s)) continue; /* Same spill slot, do nothing. */ mask = ((!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR) & allow; if (mask == RSET_EMPTY) lj_trace_err(as->J, LJ_TRERR_NYICOAL); r = ra_allocref(as, i, mask); ra_save(as, ir, r); rset_clear(allow, r); if (r == rs) { /* Coalesce matching registers right now. */ ra_free(as, r); rset_clear(live, r); } else if (ra_hasspill(regsp_spill(rs))) { pass3 = 1; } checkmclim(as); } } } /* Store trace number and adjust stack frame relative to the parent. */ emit_setvmstate(as, (int32_t)as->T->traceno); emit_spsub(as, spdelta); #if !LJ_TARGET_X86ORX64 /* Restore BASE register from parent spill slot. */ if (ra_hasspill(irp->s)) emit_spload(as, IR(REF_BASE), IR(REF_BASE)->r, sps_scale(irp->s)); #endif /* Restore target registers from parent spill slots. */ if (pass3) { RegSet work = ~as->freeset & RSET_ALL; while (work) { Reg r = rset_pickbot(work); IRRef ref = regcost_ref(as->cost[r]); RegSP rs = as->parentmap[ref - REF_FIRST]; rset_clear(work, r); if (ra_hasspill(regsp_spill(rs))) { int32_t ofs = sps_scale(regsp_spill(rs)); ra_free(as, r); emit_spload(as, IR(ref), r, ofs); checkmclim(as); } } } /* Shuffle registers to match up target regs with parent regs. */ for (;;) { RegSet work; /* Repeatedly coalesce free live registers by moving to their target. */ while ((work = as->freeset & live) != RSET_EMPTY) { Reg rp = rset_pickbot(work); IRIns *ir = IR(sloadins[rp]); rset_clear(live, rp); rset_clear(allow, rp); ra_free(as, ir->r); emit_movrr(as, ir, ir->r, rp); checkmclim(as); } /* We're done if no live registers remain. */ if (live == RSET_EMPTY) break; /* Break cycles by renaming one target to a temp. register. */ if (live & RSET_GPR) { RegSet tmpset = as->freeset & ~live & allow & RSET_GPR; if (tmpset == RSET_EMPTY) lj_trace_err(as->J, LJ_TRERR_NYICOAL); ra_rename(as, rset_pickbot(live & RSET_GPR), rset_pickbot(tmpset)); } if (!LJ_SOFTFP && (live & RSET_FPR)) { RegSet tmpset = as->freeset & ~live & allow & RSET_FPR; if (tmpset == RSET_EMPTY) lj_trace_err(as->J, LJ_TRERR_NYICOAL); ra_rename(as, rset_pickbot(live & RSET_FPR), rset_pickbot(tmpset)); } checkmclim(as); /* Continue with coalescing to fix up the broken cycle(s). */ } /* Inherit top stack slot already checked by parent trace. */ as->T->topslot = as->parent->topslot; if (as->topslot > as->T->topslot) { /* Need to check for higher slot? */ #ifdef EXITSTATE_CHECKEXIT /* Highest exit + 1 indicates stack check. */ ExitNo exitno = as->T->nsnap; #else /* Reuse the parent exit in the context of the parent trace. */ ExitNo exitno = as->J->exitno; #endif as->T->topslot = (uint8_t)as->topslot; /* Remember for child traces. */ asm_stack_check(as, as->topslot, irp, allow & RSET_GPR, exitno); } } /* -- Tail of trace ------------------------------------------------------- */ /* Get base slot for a snapshot. */ static BCReg asm_baseslot(ASMState *as, SnapShot *snap, int *gotframe) { SnapEntry *map = &as->T->snapmap[snap->mapofs]; MSize n; for (n = snap->nent; n > 0; n--) { SnapEntry sn = map[n-1]; if ((sn & SNAP_FRAME)) { *gotframe = 1; return snap_slot(sn); } } return 0; } /* Link to another trace. */ static void asm_tail_link(ASMState *as) { SnapNo snapno = as->T->nsnap-1; /* Last snapshot. */ SnapShot *snap = &as->T->snap[snapno]; int gotframe = 0; BCReg baseslot = asm_baseslot(as, snap, &gotframe); as->topslot = snap->topslot; checkmclim(as); ra_allocref(as, REF_BASE, RID2RSET(RID_BASE)); if (as->T->link == 0) { /* Setup fixed registers for exit to interpreter. */ const BCIns *pc = snap_pc(as->T->snapmap[snap->mapofs + snap->nent]); int32_t mres; if (bc_op(*pc) == BC_JLOOP) { /* NYI: find a better way to do this. */ BCIns *retpc = &traceref(as->J, bc_d(*pc))->startins; if (bc_isret(bc_op(*retpc))) pc = retpc; } ra_allockreg(as, i32ptr(J2GG(as->J)->dispatch), RID_DISPATCH); ra_allockreg(as, i32ptr(pc), RID_LPC); mres = (int32_t)(snap->nslots - baseslot); switch (bc_op(*pc)) { case BC_CALLM: case BC_CALLMT: mres -= (int32_t)(1 + bc_a(*pc) + bc_c(*pc)); break; case BC_RETM: mres -= (int32_t)(bc_a(*pc) + bc_d(*pc)); break; case BC_TSETM: mres -= (int32_t)bc_a(*pc); break; default: if (bc_op(*pc) < BC_FUNCF) mres = 0; break; } ra_allockreg(as, mres, RID_RET); /* Return MULTRES or 0. */ } else if (baseslot) { /* Save modified BASE for linking to trace with higher start frame. */ emit_setgl(as, RID_BASE, jit_base); } emit_addptr(as, RID_BASE, 8*(int32_t)baseslot); /* Sync the interpreter state with the on-trace state. */ asm_stack_restore(as, snap); /* Root traces that add frames need to check the stack at the end. */ if (!as->parent && gotframe) asm_stack_check(as, as->topslot, NULL, as->freeset & RSET_GPR, snapno); } /* -- Trace setup --------------------------------------------------------- */ /* Clear reg/sp for all instructions and add register hints. */ static void asm_setup_regsp(ASMState *as) { GCtrace *T = as->T; int sink = T->sinktags; IRRef nins = T->nins; IRIns *ir, *lastir; int inloop; #if LJ_TARGET_ARM uint32_t rload = 0xa6402a64; #endif ra_setup(as); /* Clear reg/sp for constants. */ for (ir = IR(T->nk), lastir = IR(REF_BASE); ir < lastir; ir++) ir->prev = REGSP_INIT; /* REF_BASE is used for implicit references to the BASE register. */ lastir->prev = REGSP_HINT(RID_BASE); ir = IR(nins-1); if (ir->o == IR_RENAME) { do { ir--; nins--; } while (ir->o == IR_RENAME); T->nins = nins; /* Remove any renames left over from ASM restart. */ } as->snaprename = nins; as->snapref = nins; as->snapno = T->nsnap; as->stopins = REF_BASE; as->orignins = nins; as->curins = nins; /* Setup register hints for parent link instructions. */ ir = IR(REF_FIRST); if (as->parent) { uint16_t *p; lastir = lj_snap_regspmap(as->parent, as->J->exitno, ir); if (lastir - ir > LJ_MAX_JSLOTS) lj_trace_err(as->J, LJ_TRERR_NYICOAL); as->stopins = (IRRef)((lastir-1) - as->ir); for (p = as->parentmap; ir < lastir; ir++) { RegSP rs = ir->prev; *p++ = (uint16_t)rs; /* Copy original parent RegSP to parentmap. */ if (!ra_hasspill(regsp_spill(rs))) ir->prev = (uint16_t)REGSP_HINT(regsp_reg(rs)); else ir->prev = REGSP_INIT; } } inloop = 0; as->evenspill = SPS_FIRST; for (lastir = IR(nins); ir < lastir; ir++) { if (sink) { if (ir->r == RID_SINK) continue; if (ir->r == RID_SUNK) { /* Revert after ASM restart. */ ir->r = RID_SINK; continue; } } switch (ir->o) { case IR_LOOP: inloop = 1; break; #if LJ_TARGET_ARM case IR_SLOAD: if (!((ir->op2 & IRSLOAD_TYPECHECK) || (ir+1)->o == IR_HIOP)) break; /* fallthrough */ case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: if (!LJ_SOFTFP && irt_isnum(ir->t)) break; ir->prev = (uint16_t)REGSP_HINT((rload & 15)); rload = lj_ror(rload, 4); continue; #endif case IR_CALLXS: { CCallInfo ci; ci.flags = asm_callx_flags(as, ir); ir->prev = asm_setup_call_slots(as, ir, &ci); if (inloop) as->modset |= RSET_SCRATCH; continue; } case IR_CALLN: case IR_CALLL: case IR_CALLS: { const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; ir->prev = asm_setup_call_slots(as, ir, ci); if (inloop) as->modset |= (ci->flags & CCI_NOFPRCLOBBER) ? (RSET_SCRATCH & ~RSET_FPR) : RSET_SCRATCH; continue; } #if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) case IR_HIOP: switch ((ir-1)->o) { #if LJ_SOFTFP && LJ_TARGET_ARM case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: if (ra_hashint((ir-1)->r)) { ir->prev = (ir-1)->prev + 1; continue; } break; #endif #if !LJ_SOFTFP && LJ_NEED_FP64 case IR_CONV: if (irt_isfp((ir-1)->t)) { ir->prev = REGSP_HINT(RID_FPRET); continue; } /* fallthrough */ #endif case IR_CALLN: case IR_CALLXS: #if LJ_SOFTFP case IR_MIN: case IR_MAX: #endif (ir-1)->prev = REGSP_HINT(RID_RETLO); ir->prev = REGSP_HINT(RID_RETHI); continue; default: break; } break; #endif #if LJ_SOFTFP case IR_MIN: case IR_MAX: if ((ir+1)->o != IR_HIOP) break; /* fallthrough */ #endif /* C calls evict all scratch regs and return results in RID_RET. */ case IR_SNEW: case IR_XSNEW: case IR_NEWREF: if (REGARG_NUMGPR < 3 && as->evenspill < 3) as->evenspill = 3; /* lj_str_new and lj_tab_newkey need 3 args. */ case IR_TNEW: case IR_TDUP: case IR_CNEW: case IR_CNEWI: case IR_TOSTR: ir->prev = REGSP_HINT(RID_RET); if (inloop) as->modset = RSET_SCRATCH; continue; case IR_STRTO: case IR_OBAR: if (inloop) as->modset = RSET_SCRATCH; break; #if !LJ_TARGET_X86ORX64 && !LJ_SOFTFP case IR_ATAN2: case IR_LDEXP: #endif case IR_POW: if (!LJ_SOFTFP && irt_isnum(ir->t)) { #if LJ_TARGET_X86ORX64 ir->prev = REGSP_HINT(RID_XMM0); if (inloop) as->modset |= RSET_RANGE(RID_XMM0, RID_XMM1+1)|RID2RSET(RID_EAX); #else ir->prev = REGSP_HINT(RID_FPRET); if (inloop) as->modset |= RSET_SCRATCH; #endif continue; } /* fallthrough for integer POW */ case IR_DIV: case IR_MOD: if (!irt_isnum(ir->t)) { ir->prev = REGSP_HINT(RID_RET); if (inloop) as->modset |= (RSET_SCRATCH & RSET_GPR); continue; } break; case IR_FPMATH: #if LJ_TARGET_X86ORX64 if (ir->op2 == IRFPM_EXP2) { /* May be joined to lj_vm_pow_sse. */ ir->prev = REGSP_HINT(RID_XMM0); #if !LJ_64 if (as->evenspill < 4) /* Leave room for 16 byte scratch area. */ as->evenspill = 4; #endif if (inloop) as->modset |= RSET_RANGE(RID_XMM0, RID_XMM2+1)|RID2RSET(RID_EAX); continue; } else if (ir->op2 <= IRFPM_TRUNC && !(as->flags & JIT_F_SSE4_1)) { ir->prev = REGSP_HINT(RID_XMM0); if (inloop) as->modset |= RSET_RANGE(RID_XMM0, RID_XMM3+1)|RID2RSET(RID_EAX); continue; } break; #else ir->prev = REGSP_HINT(RID_FPRET); if (inloop) as->modset |= RSET_SCRATCH; continue; #endif #if LJ_TARGET_X86ORX64 /* Non-constant shift counts need to be in RID_ECX on x86/x64. */ case IR_BSHL: case IR_BSHR: case IR_BSAR: case IR_BROL: case IR_BROR: if (!irref_isk(ir->op2) && !ra_hashint(IR(ir->op2)->r)) { IR(ir->op2)->r = REGSP_HINT(RID_ECX); if (inloop) rset_set(as->modset, RID_ECX); } break; #endif /* Do not propagate hints across type conversions or loads. */ case IR_TOBIT: case IR_XLOAD: #if !LJ_TARGET_ARM case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: #endif break; case IR_CONV: if (irt_isfp(ir->t) || (ir->op2 & IRCONV_SRCMASK) == IRT_NUM || (ir->op2 & IRCONV_SRCMASK) == IRT_FLOAT) break; /* fallthrough */ default: /* Propagate hints across likely 'op reg, imm' or 'op reg'. */ if (irref_isk(ir->op2) && !irref_isk(ir->op1) && ra_hashint(regsp_reg(IR(ir->op1)->prev))) { ir->prev = IR(ir->op1)->prev; continue; } break; } ir->prev = REGSP_INIT; } if ((as->evenspill & 1)) as->oddspill = as->evenspill++; else as->oddspill = 0; } /* -- Assembler core ------------------------------------------------------ */ /* Assemble a trace. */ void lj_asm_trace(jit_State *J, GCtrace *T) { ASMState as_; ASMState *as = &as_; MCode *origtop; /* Ensure an initialized instruction beyond the last one for HIOP checks. */ J->cur.nins = lj_ir_nextins(J); J->cur.ir[J->cur.nins].o = IR_NOP; /* Setup initial state. Copy some fields to reduce indirections. */ as->J = J; as->T = T; as->ir = T->ir; as->flags = J->flags; as->loopref = J->loopref; as->realign = NULL; as->loopinv = 0; as->parent = J->parent ? traceref(J, J->parent) : NULL; /* Reserve MCode memory. */ as->mctop = origtop = lj_mcode_reserve(J, &as->mcbot); as->mcp = as->mctop; as->mclim = as->mcbot + MCLIM_REDZONE; asm_setup_target(as); do { as->mcp = as->mctop; as->curins = T->nins; RA_DBG_START(); RA_DBGX((as, "===== STOP =====")); /* General trace setup. Emit tail of trace. */ asm_tail_prep(as); as->mcloop = NULL; as->flagmcp = NULL; as->topslot = 0; as->gcsteps = 0; as->sectref = as->loopref; as->fuseref = (as->flags & JIT_F_OPT_FUSE) ? as->loopref : FUSE_DISABLED; asm_setup_regsp(as); if (!as->loopref) asm_tail_link(as); /* Assemble a trace in linear backwards order. */ for (as->curins--; as->curins > as->stopins; as->curins--) { IRIns *ir = IR(as->curins); lua_assert(!(LJ_32 && irt_isint64(ir->t))); /* Handled by SPLIT. */ if (!ra_used(ir) && !ir_sideeff(ir) && (as->flags & JIT_F_OPT_DCE)) continue; /* Dead-code elimination can be soooo easy. */ if (irt_isguard(ir->t)) asm_snap_prep(as); RA_DBG_REF(); checkmclim(as); asm_ir(as, ir); } } while (as->realign); /* Retry in case the MCode needs to be realigned. */ /* Emit head of trace. */ RA_DBG_REF(); checkmclim(as); if (as->gcsteps > 0) { as->curins = as->T->snap[0].ref; asm_snap_prep(as); /* The GC check is a guard. */ asm_gc_check(as); } ra_evictk(as); if (as->parent) asm_head_side(as); else asm_head_root(as); asm_phi_fixup(as); RA_DBGX((as, "===== START ====")); RA_DBG_FLUSH(); if (as->freeset != RSET_ALL) lj_trace_err(as->J, LJ_TRERR_BADRA); /* Ouch! Should never happen. */ /* Set trace entry point before fixing up tail to allow link to self. */ T->mcode = as->mcp; T->mcloop = as->mcloop ? (MSize)((char *)as->mcloop - (char *)as->mcp) : 0; if (!as->loopref) asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */ T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp); lj_mcode_sync(T->mcode, origtop); } #undef IR #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_asm.h ================================================ /* ** IR assembler (SSA IR -> machine code). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_ASM_H #define _LJ_ASM_H #include "lj_jit.h" #if LJ_HASJIT LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_asm_arm.h ================================================ /* ** ARM IR assembler (SSA IR -> machine code). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* -- Register allocator extensions --------------------------------------- */ /* Allocate a register with a hint. */ static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) { Reg r = IR(ref)->r; if (ra_noreg(r)) { if (!ra_hashint(r) && !iscrossref(as, ref)) ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ r = ra_allocref(as, ref, allow); } ra_noweak(as, r); return r; } /* Allocate a scratch register pair. */ static Reg ra_scratchpair(ASMState *as, RegSet allow) { RegSet pick1 = as->freeset & allow; RegSet pick2 = pick1 & (pick1 >> 1) & RSET_GPREVEN; Reg r; if (pick2) { r = rset_picktop(pick2); } else { RegSet pick = pick1 & (allow >> 1) & RSET_GPREVEN; if (pick) { r = rset_picktop(pick); ra_restore(as, regcost_ref(as->cost[r+1])); } else { pick = pick1 & (allow << 1) & RSET_GPRODD; if (pick) { r = ra_restore(as, regcost_ref(as->cost[rset_picktop(pick)-1])); } else { r = ra_evict(as, allow & (allow >> 1) & RSET_GPREVEN); ra_restore(as, regcost_ref(as->cost[r+1])); } } } lua_assert(rset_test(RSET_GPREVEN, r)); ra_modified(as, r); ra_modified(as, r+1); RA_DBGX((as, "scratchpair $r $r", r, r+1)); return r; } #if !LJ_SOFTFP /* Allocate two source registers for three-operand instructions. */ static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) { IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); Reg left = irl->r, right = irr->r; if (ra_hasreg(left)) { ra_noweak(as, left); if (ra_noreg(right)) right = ra_allocref(as, ir->op2, rset_exclude(allow, left)); else ra_noweak(as, right); } else if (ra_hasreg(right)) { ra_noweak(as, right); left = ra_allocref(as, ir->op1, rset_exclude(allow, right)); } else if (ra_hashint(right)) { right = ra_allocref(as, ir->op2, allow); left = ra_alloc1(as, ir->op1, rset_exclude(allow, right)); } else { left = ra_allocref(as, ir->op1, allow); right = ra_alloc1(as, ir->op2, rset_exclude(allow, left)); } return left | (right << 8); } #endif /* -- Guard handling ------------------------------------------------------ */ /* Generate an exit stub group at the bottom of the reserved MCode memory. */ static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) { MCode *mxp = as->mcbot; int i; if (mxp + 4*4+4*EXITSTUBS_PER_GROUP >= as->mctop) asm_mclimit(as); /* str lr, [sp]; bl ->vm_exit_handler; .long DISPATCH_address, group. */ *mxp++ = ARMI_STR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_LR)|ARMF_N(RID_SP); *mxp = ARMI_BL|((((MCode *)(void *)lj_vm_exit_handler-mxp)-2)&0x00ffffffu); mxp++; *mxp++ = (MCode)i32ptr(J2GG(as->J)->dispatch); /* DISPATCH address */ *mxp++ = group*EXITSTUBS_PER_GROUP; for (i = 0; i < EXITSTUBS_PER_GROUP; i++) *mxp++ = ARMI_B|((-6-i)&0x00ffffffu); lj_mcode_sync(as->mcbot, mxp); lj_mcode_commitbot(as->J, mxp); as->mcbot = mxp; as->mclim = as->mcbot + MCLIM_REDZONE; return mxp - EXITSTUBS_PER_GROUP; } /* Setup all needed exit stubs. */ static void asm_exitstub_setup(ASMState *as, ExitNo nexits) { ExitNo i; if (nexits >= EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) lj_trace_err(as->J, LJ_TRERR_SNAPOV); for (i = 0; i < (nexits+EXITSTUBS_PER_GROUP-1)/EXITSTUBS_PER_GROUP; i++) if (as->J->exitstubgroup[i] == NULL) as->J->exitstubgroup[i] = asm_exitstub_gen(as, i); } /* Emit conditional branch to exit for guard. */ static void asm_guardcc(ASMState *as, ARMCC cc) { MCode *target = exitstub_addr(as->J, as->snapno); MCode *p = as->mcp; if (LJ_UNLIKELY(p == as->invmcp)) { as->loopinv = 1; *p = ARMI_BL | ((target-p-2) & 0x00ffffffu); emit_branch(as, ARMF_CC(ARMI_B, cc^1), p+1); return; } emit_branch(as, ARMF_CC(ARMI_BL, cc), target); } /* -- Operand fusion ------------------------------------------------------ */ /* Limit linear search to this distance. Avoids O(n^2) behavior. */ #define CONFLICT_SEARCH_LIM 31 /* Check if there's no conflicting instruction between curins and ref. */ static int noconflict(ASMState *as, IRRef ref, IROp conflict) { IRIns *ir = as->ir; IRRef i = as->curins; if (i > ref + CONFLICT_SEARCH_LIM) return 0; /* Give up, ref is too far away. */ while (--i > ref) if (ir[i].o == conflict) return 0; /* Conflict found. */ return 1; /* Ok, no conflict. */ } /* Fuse the array base of colocated arrays. */ static int32_t asm_fuseabase(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) return (int32_t)sizeof(GCtab); return 0; } /* Fuse array/hash/upvalue reference into register+offset operand. */ static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow, int lim) { IRIns *ir = IR(ref); if (ra_noreg(ir->r)) { if (ir->o == IR_AREF) { if (mayfuse(as, ref)) { if (irref_isk(ir->op2)) { IRRef tab = IR(ir->op1)->op1; int32_t ofs = asm_fuseabase(as, tab); IRRef refa = ofs ? tab : ir->op1; ofs += 8*IR(ir->op2)->i; if (ofs > -lim && ofs < lim) { *ofsp = ofs; return ra_alloc1(as, refa, allow); } } } } else if (ir->o == IR_HREFK) { if (mayfuse(as, ref)) { int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); if (ofs < lim) { *ofsp = ofs; return ra_alloc1(as, ir->op1, allow); } } } else if (ir->o == IR_UREFC) { if (irref_isk(ir->op1)) { GCfunc *fn = ir_kfunc(IR(ir->op1)); int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); *ofsp = (ofs & 255); /* Mask out less bits to allow LDRD. */ return ra_allock(as, (ofs & ~255), allow); } } } *ofsp = 0; return ra_alloc1(as, ref, allow); } /* Fuse m operand into arithmetic/logic instructions. */ static uint32_t asm_fuseopm(ASMState *as, ARMIns ai, IRRef ref, RegSet allow) { IRIns *ir = IR(ref); if (ra_hasreg(ir->r)) { ra_noweak(as, ir->r); return ARMF_M(ir->r); } else if (irref_isk(ref)) { uint32_t k = emit_isk12(ai, ir->i); if (k) return k; } else if (mayfuse(as, ref)) { if (ir->o >= IR_BSHL && ir->o <= IR_BROR) { Reg m = ra_alloc1(as, ir->op1, allow); ARMShift sh = ir->o == IR_BSHL ? ARMSH_LSL : ir->o == IR_BSHR ? ARMSH_LSR : ir->o == IR_BSAR ? ARMSH_ASR : ARMSH_ROR; if (irref_isk(ir->op2)) { return m | ARMF_SH(sh, (IR(ir->op2)->i & 31)); } else { Reg s = ra_alloc1(as, ir->op2, rset_exclude(allow, m)); return m | ARMF_RSH(sh, s); } } else if (ir->o == IR_ADD && ir->op1 == ir->op2) { Reg m = ra_alloc1(as, ir->op1, allow); return m | ARMF_SH(ARMSH_LSL, 1); } } return ra_allocref(as, ref, allow); } /* Fuse shifts into loads/stores. Only bother with BSHL 2 => lsl #2. */ static IRRef asm_fuselsl2(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); if (ra_noreg(ir->r) && mayfuse(as, ref) && ir->o == IR_BSHL && irref_isk(ir->op2) && IR(ir->op2)->i == 2) return ir->op1; return 0; /* No fusion. */ } /* Fuse XLOAD/XSTORE reference into load/store operand. */ static void asm_fusexref(ASMState *as, ARMIns ai, Reg rd, IRRef ref, RegSet allow, int32_t ofs) { IRIns *ir = IR(ref); Reg base; if (ra_noreg(ir->r) && canfuse(as, ir)) { int32_t lim = (!LJ_SOFTFP && (ai & 0x08000000)) ? 1024 : (ai & 0x04000000) ? 4096 : 256; if (ir->o == IR_ADD) { int32_t ofs2; if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i) > -lim && ofs2 < lim && (!(!LJ_SOFTFP && (ai & 0x08000000)) || !(ofs2 & 3))) { ofs = ofs2; ref = ir->op1; } else if (ofs == 0 && !(!LJ_SOFTFP && (ai & 0x08000000))) { IRRef lref = ir->op1, rref = ir->op2; Reg rn, rm; if ((ai & 0x04000000)) { IRRef sref = asm_fuselsl2(as, rref); if (sref) { rref = sref; ai |= ARMF_SH(ARMSH_LSL, 2); } else if ((sref = asm_fuselsl2(as, lref)) != 0) { lref = rref; rref = sref; ai |= ARMF_SH(ARMSH_LSL, 2); } } rn = ra_alloc1(as, lref, allow); rm = ra_alloc1(as, rref, rset_exclude(allow, rn)); if ((ai & 0x04000000)) ai |= ARMI_LS_R; emit_dnm(as, ai|ARMI_LS_P|ARMI_LS_U, rd, rn, rm); return; } } else if (ir->o == IR_STRREF && !(!LJ_SOFTFP && (ai & 0x08000000))) { lua_assert(ofs == 0); ofs = (int32_t)sizeof(GCstr); if (irref_isk(ir->op2)) { ofs += IR(ir->op2)->i; ref = ir->op1; } else if (irref_isk(ir->op1)) { ofs += IR(ir->op1)->i; ref = ir->op2; } else { /* NYI: Fuse ADD with constant. */ Reg rn = ra_alloc1(as, ir->op1, allow); uint32_t m = asm_fuseopm(as, 0, ir->op2, rset_exclude(allow, rn)); if ((ai & 0x04000000)) emit_lso(as, ai, rd, rd, ofs); else emit_lsox(as, ai, rd, rd, ofs); emit_dn(as, ARMI_ADD^m, rd, rn); return; } if (ofs <= -lim || ofs >= lim) { Reg rn = ra_alloc1(as, ref, allow); Reg rm = ra_allock(as, ofs, rset_exclude(allow, rn)); if ((ai & 0x04000000)) ai |= ARMI_LS_R; emit_dnm(as, ai|ARMI_LS_P|ARMI_LS_U, rd, rn, rm); return; } } } base = ra_alloc1(as, ref, allow); #if !LJ_SOFTFP if ((ai & 0x08000000)) emit_vlso(as, ai, rd, base, ofs); else #endif if ((ai & 0x04000000)) emit_lso(as, ai, rd, base, ofs); else emit_lsox(as, ai, rd, base, ofs); } #if !LJ_SOFTFP /* Fuse to multiply-add/sub instruction. */ static int asm_fusemadd(ASMState *as, IRIns *ir, ARMIns ai, ARMIns air) { IRRef lref = ir->op1, rref = ir->op2; IRIns *irm; if (lref != rref && ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) && ra_noreg(irm->r)) || (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) && (rref = lref, ai = air, ra_noreg(irm->r))))) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg add = ra_hintalloc(as, rref, dest, RSET_FPR); Reg right, left = ra_alloc2(as, irm, rset_exclude(rset_exclude(RSET_FPR, dest), add)); right = (left >> 8); left &= 255; emit_dnm(as, ai, (dest & 15), (left & 15), (right & 15)); if (dest != add) emit_dm(as, ARMI_VMOV_D, (dest & 15), (add & 15)); return 1; } return 0; } #endif /* -- Calls --------------------------------------------------------------- */ /* Generate a call to a C function. */ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) { uint32_t n, nargs = CCI_NARGS(ci); int32_t ofs = 0; #if LJ_SOFTFP Reg gpr = REGARG_FIRSTGPR; #else Reg gpr, fpr = REGARG_FIRSTFPR, fprodd = 0; #endif if ((void *)ci->func) emit_call(as, (void *)ci->func); #if !LJ_SOFTFP for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) as->cost[gpr] = REGCOST(~0u, ASMREF_L); gpr = REGARG_FIRSTGPR; #endif for (n = 0; n < nargs; n++) { /* Setup args. */ IRRef ref = args[n]; IRIns *ir = IR(ref); #if !LJ_SOFTFP if (ref && irt_isfp(ir->t)) { RegSet of = as->freeset; Reg src; if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) { if (irt_isnum(ir->t)) { if (fpr <= REGARG_LASTFPR) { ra_leftov(as, fpr, ref); fpr++; continue; } } else if (fprodd) { /* Ick. */ src = ra_alloc1(as, ref, RSET_FPR); emit_dm(as, ARMI_VMOV_S, (fprodd & 15), (src & 15) | 0x00400000); fprodd = 0; continue; } else if (fpr <= REGARG_LASTFPR) { ra_leftov(as, fpr, ref); fprodd = fpr++; continue; } /* Workaround to protect argument GPRs from being used for remat. */ as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); src = ra_alloc1(as, ref, RSET_FPR); /* May alloc GPR to remat FPR. */ as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); fprodd = 0; goto stackfp; } /* Workaround to protect argument GPRs from being used for remat. */ as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); src = ra_alloc1(as, ref, RSET_FPR); /* May alloc GPR to remat FPR. */ as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1u; if (gpr <= REGARG_LASTGPR) { lua_assert(rset_test(as->freeset, gpr)); /* Must have been evicted. */ if (irt_isnum(ir->t)) { lua_assert(rset_test(as->freeset, gpr+1)); /* Ditto. */ emit_dnm(as, ARMI_VMOV_RR_D, gpr, gpr+1, (src & 15)); gpr += 2; } else { emit_dn(as, ARMI_VMOV_R_S, gpr, (src & 15)); gpr++; } } else { stackfp: if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; emit_spstore(as, ir, src, ofs); ofs += irt_isnum(ir->t) ? 8 : 4; } } else #endif { if (gpr <= REGARG_LASTGPR) { lua_assert(rset_test(as->freeset, gpr)); /* Must have been evicted. */ if (ref) ra_leftov(as, gpr, ref); gpr++; } else { if (ref) { Reg r = ra_alloc1(as, ref, RSET_GPR); emit_spstore(as, ir, r, ofs); } ofs += 4; } } } } /* Setup result reg/sp for call. Evict scratch regs. */ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) { RegSet drop = RSET_SCRATCH; int hiop = ((ir+1)->o == IR_HIOP); if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ if (hiop && ra_hasreg((ir+1)->r)) rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ ra_evictset(as, drop); /* Evictions must be performed first. */ if (ra_used(ir)) { lua_assert(!irt_ispri(ir->t)); if (!LJ_SOFTFP && irt_isfp(ir->t)) { if (LJ_ABI_SOFTFP || (ci->flags & (CCI_CASTU64|CCI_VARARG))) { Reg dest = (ra_dest(as, ir, RSET_FPR) & 15); if (irt_isnum(ir->t)) emit_dnm(as, ARMI_VMOV_D_RR, RID_RETLO, RID_RETHI, dest); else emit_dn(as, ARMI_VMOV_S_R, RID_RET, dest); } else { ra_destreg(as, ir, RID_FPRET); } } else if (hiop) { ra_destpair(as, ir); } else { ra_destreg(as, ir, RID_RET); } } UNUSED(ci); } static void asm_call(ASMState *as, IRIns *ir) { IRRef args[CCI_NARGS_MAX]; const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; asm_collectargs(as, ir, ci, args); asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } static void asm_callx(ASMState *as, IRIns *ir) { IRRef args[CCI_NARGS_MAX]; CCallInfo ci; IRRef func; IRIns *irf; ci.flags = asm_callx_flags(as, ir); asm_collectargs(as, ir, &ci, args); asm_setupresult(as, ir, &ci); func = ir->op2; irf = IR(func); if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } if (irref_isk(func)) { /* Call to constant address. */ ci.func = (ASMFunction)(void *)(irf->i); } else { /* Need a non-argument register for indirect calls. */ Reg freg = ra_alloc1(as, func, RSET_RANGE(RID_R4, RID_R12+1)); emit_m(as, ARMI_BLXr, freg); ci.func = (ASMFunction)(void *)0; } asm_gencall(as, &ci, args); } /* -- Returns ------------------------------------------------------------- */ /* Return to lower frame. Guard that it goes to the right spot. */ static void asm_retf(ASMState *as, IRIns *ir) { Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); void *pc = ir_kptr(IR(ir->op2)); int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); as->topslot -= (BCReg)delta; if ((int32_t)as->topslot < 0) as->topslot = 0; /* Need to force a spill on REF_BASE now to update the stack slot. */ emit_lso(as, ARMI_STR, base, RID_SP, ra_spill(as, IR(REF_BASE))); emit_setgl(as, base, jit_base); emit_addptr(as, base, -8*delta); asm_guardcc(as, CC_NE); emit_nm(as, ARMI_CMP, RID_TMP, ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); emit_lso(as, ARMI_LDR, RID_TMP, base, -4); } /* -- Type conversions ---------------------------------------------------- */ #if !LJ_SOFTFP static void asm_tointg(ASMState *as, IRIns *ir, Reg left) { Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); Reg dest = ra_dest(as, ir, RSET_GPR); asm_guardcc(as, CC_NE); emit_d(as, ARMI_VMRS, 0); emit_dm(as, ARMI_VCMP_D, (tmp & 15), (left & 15)); emit_dm(as, ARMI_VCVT_F64_S32, (tmp & 15), (tmp & 15)); emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); emit_dm(as, ARMI_VCVT_S32_F64, (tmp & 15), (left & 15)); } static void asm_tobit(ASMState *as, IRIns *ir) { RegSet allow = RSET_FPR; Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, allow); Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); Reg tmp = ra_scratch(as, rset_clear(allow, right)); emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); emit_dnm(as, ARMI_VADD_D, (tmp & 15), (left & 15), (right & 15)); } #endif static void asm_conv(ASMState *as, IRIns *ir) { IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); #if !LJ_SOFTFP int stfp = (st == IRT_NUM || st == IRT_FLOAT); #endif IRRef lref = ir->op1; /* 64 bit integer conversions are handled by SPLIT. */ lua_assert(!irt_isint64(ir->t) && !(st == IRT_I64 || st == IRT_U64)); #if LJ_SOFTFP /* FP conversions are handled by SPLIT. */ lua_assert(!irt_isfp(ir->t) && !(st == IRT_NUM || st == IRT_FLOAT)); /* Can't check for same types: SPLIT uses CONV int.int + BXOR for sfp NEG. */ #else lua_assert(irt_type(ir->t) != st); if (irt_isfp(ir->t)) { Reg dest = ra_dest(as, ir, RSET_FPR); if (stfp) { /* FP to FP conversion. */ emit_dm(as, st == IRT_NUM ? ARMI_VCVT_F32_F64 : ARMI_VCVT_F64_F32, (dest & 15), (ra_alloc1(as, lref, RSET_FPR) & 15)); } else { /* Integer to FP conversion. */ Reg left = ra_alloc1(as, lref, RSET_GPR); ARMIns ai = irt_isfloat(ir->t) ? (st == IRT_INT ? ARMI_VCVT_F32_S32 : ARMI_VCVT_F32_U32) : (st == IRT_INT ? ARMI_VCVT_F64_S32 : ARMI_VCVT_F64_U32); emit_dm(as, ai, (dest & 15), (dest & 15)); emit_dn(as, ARMI_VMOV_S_R, left, (dest & 15)); } } else if (stfp) { /* FP to integer conversion. */ if (irt_isguard(ir->t)) { /* Checked conversions are only supported from number to int. */ lua_assert(irt_isint(ir->t) && st == IRT_NUM); asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, lref, RSET_FPR); Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); ARMIns ai; emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); ai = irt_isint(ir->t) ? (st == IRT_NUM ? ARMI_VCVT_S32_F64 : ARMI_VCVT_S32_F32) : (st == IRT_NUM ? ARMI_VCVT_U32_F64 : ARMI_VCVT_U32_F32); emit_dm(as, ai, (tmp & 15), (left & 15)); } } else #endif { Reg dest = ra_dest(as, ir, RSET_GPR); if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ Reg left = ra_alloc1(as, lref, RSET_GPR); lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); if ((as->flags & JIT_F_ARMV6)) { ARMIns ai = st == IRT_I8 ? ARMI_SXTB : st == IRT_U8 ? ARMI_UXTB : st == IRT_I16 ? ARMI_SXTH : ARMI_UXTH; emit_dm(as, ai, dest, left); } else if (st == IRT_U8) { emit_dn(as, ARMI_AND|ARMI_K12|255, dest, left); } else { uint32_t shift = st == IRT_I8 ? 24 : 16; ARMShift sh = st == IRT_U16 ? ARMSH_LSR : ARMSH_ASR; emit_dm(as, ARMI_MOV|ARMF_SH(sh, shift), dest, RID_TMP); emit_dm(as, ARMI_MOV|ARMF_SH(ARMSH_LSL, shift), RID_TMP, left); } } else { /* Handle 32/32 bit no-op (cast). */ ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ } } } #if !LJ_SOFTFP && LJ_HASFFI static void asm_conv64(ASMState *as, IRIns *ir) { IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); IRCallID id; CCallInfo ci; IRRef args[2]; args[0] = (ir-1)->op1; args[1] = ir->op1; if (st == IRT_NUM || st == IRT_FLOAT) { id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); ir--; } else { id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); } ci = lj_ir_callinfo[id]; #if !LJ_ABI_SOFTFP ci.flags |= CCI_VARARG; /* These calls don't use the hard-float ABI! */ #endif asm_setupresult(as, ir, &ci); asm_gencall(as, &ci, args); } #endif static void asm_strto(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; IRRef args[2]; Reg rlo = 0, rhi = 0, tmp; int destused = ra_used(ir); int32_t ofs = 0; ra_evictset(as, RSET_SCRATCH); #if LJ_SOFTFP if (destused) { if (ra_hasspill(ir->s) && ra_hasspill((ir+1)->s) && (ir->s & 1) == 0 && ir->s + 1 == (ir+1)->s) { int i; for (i = 0; i < 2; i++) { Reg r = (ir+i)->r; if (ra_hasreg(r)) { ra_free(as, r); ra_modified(as, r); emit_spload(as, ir+i, r, sps_scale((ir+i)->s)); } } ofs = sps_scale(ir->s); destused = 0; } else { rhi = ra_dest(as, ir+1, RSET_GPR); rlo = ra_dest(as, ir, rset_exclude(RSET_GPR, rhi)); } } asm_guardcc(as, CC_EQ); if (destused) { emit_lso(as, ARMI_LDR, rhi, RID_SP, 4); emit_lso(as, ARMI_LDR, rlo, RID_SP, 0); } #else UNUSED(rhi); if (destused) { if (ra_hasspill(ir->s)) { ofs = sps_scale(ir->s); destused = 0; if (ra_hasreg(ir->r)) { ra_free(as, ir->r); ra_modified(as, ir->r); emit_spload(as, ir, ir->r, ofs); } } else { rlo = ra_dest(as, ir, RSET_FPR); } } asm_guardcc(as, CC_EQ); if (destused) emit_vlso(as, ARMI_VLDR_D, rlo, RID_SP, 0); #endif emit_n(as, ARMI_CMP|ARMI_K12|0, RID_RET); /* Test return status. */ args[0] = ir->op1; /* GCstr *str */ args[1] = ASMREF_TMP1; /* TValue *n */ asm_gencall(as, ci, args); tmp = ra_releasetmp(as, ASMREF_TMP1); if (ofs == 0) emit_dm(as, ARMI_MOV, tmp, RID_SP); else emit_opk(as, ARMI_ADD, tmp, RID_SP, ofs, RSET_GPR); } /* Get pointer to TValue. */ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) { IRIns *ir = IR(ref); if (irt_isnum(ir->t)) { if (irref_isk(ref)) { /* Use the number constant itself as a TValue. */ ra_allockreg(as, i32ptr(ir_knum(ir)), dest); } else { #if LJ_SOFTFP lua_assert(0); #else /* Otherwise force a spill and use the spill slot. */ emit_opk(as, ARMI_ADD, dest, RID_SP, ra_spill(as, ir), RSET_GPR); #endif } } else { /* Otherwise use [sp] and [sp+4] to hold the TValue. */ RegSet allow = rset_exclude(RSET_GPR, dest); Reg type; emit_dm(as, ARMI_MOV, dest, RID_SP); if (!irt_ispri(ir->t)) { Reg src = ra_alloc1(as, ref, allow); emit_lso(as, ARMI_STR, src, RID_SP, 0); } if ((ir+1)->o == IR_HIOP) type = ra_alloc1(as, ref+1, allow); else type = ra_allock(as, irt_toitype(ir->t), allow); emit_lso(as, ARMI_STR, type, RID_SP, 4); } } static void asm_tostr(ASMState *as, IRIns *ir) { IRRef args[2]; args[0] = ASMREF_L; as->gcsteps++; if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; args[1] = ASMREF_TMP1; /* const lua_Number * */ asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); } else { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; args[1] = ir->op1; /* int32_t k */ asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); } } /* -- Memory references --------------------------------------------------- */ static void asm_aref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg idx, base; if (irref_isk(ir->op2)) { IRRef tab = IR(ir->op1)->op1; int32_t ofs = asm_fuseabase(as, tab); IRRef refa = ofs ? tab : ir->op1; uint32_t k = emit_isk12(ARMI_ADD, ofs + 8*IR(ir->op2)->i); if (k) { base = ra_alloc1(as, refa, RSET_GPR); emit_dn(as, ARMI_ADD^k, dest, base); return; } } base = ra_alloc1(as, ir->op1, RSET_GPR); idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 3), dest, base, idx); } /* Inlined hash lookup. Specialized for key type and for const keys. ** The equivalent C code is: ** Node *n = hashkey(t, key); ** do { ** if (lj_obj_equal(&n->key, key)) return &n->val; ** } while ((n = nextnode(n))); ** return niltv(L); */ static void asm_href(ASMState *as, IRIns *ir, IROp merge) { RegSet allow = RSET_GPR; int destused = ra_used(ir); Reg dest = ra_dest(as, ir, allow); Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); Reg key = 0, keyhi = 0, keynumhi = RID_NONE, tmp = RID_TMP; IRRef refkey = ir->op2; IRIns *irkey = IR(refkey); IRType1 kt = irkey->t; int32_t k = 0, khi = emit_isk12(ARMI_CMP, irt_toitype(kt)); uint32_t khash; MCLabel l_end, l_loop; rset_clear(allow, tab); if (!irref_isk(refkey) || irt_isstr(kt)) { #if LJ_SOFTFP key = ra_alloc1(as, refkey, allow); rset_clear(allow, key); if (irkey[1].o == IR_HIOP) { if (ra_hasreg((irkey+1)->r)) { keynumhi = (irkey+1)->r; keyhi = RID_TMP; ra_noweak(as, keynumhi); } else { keyhi = keynumhi = ra_allocref(as, refkey+1, allow); } rset_clear(allow, keynumhi); khi = 0; } #else if (irt_isnum(kt)) { key = ra_scratch(as, allow); rset_clear(allow, key); keyhi = keynumhi = ra_scratch(as, allow); rset_clear(allow, keyhi); khi = 0; } else { key = ra_alloc1(as, refkey, allow); rset_clear(allow, key); } #endif } else if (irt_isnum(kt)) { int32_t val = (int32_t)ir_knum(irkey)->u32.lo; k = emit_isk12(ARMI_CMP, val); if (!k) { key = ra_allock(as, val, allow); rset_clear(allow, key); } val = (int32_t)ir_knum(irkey)->u32.hi; khi = emit_isk12(ARMI_CMP, val); if (!khi) { keyhi = ra_allock(as, val, allow); rset_clear(allow, keyhi); } } else if (!irt_ispri(kt)) { k = emit_isk12(ARMI_CMP, irkey->i); if (!k) { key = ra_alloc1(as, refkey, allow); rset_clear(allow, key); } } if (!irt_ispri(kt)) tmp = ra_scratchpair(as, allow); /* Key not found in chain: jump to exit (if merged) or load niltv. */ l_end = emit_label(as); as->invmcp = NULL; if (merge == IR_NE) asm_guardcc(as, CC_AL); else if (destused) emit_loada(as, dest, niltvg(J2G(as->J))); /* Follow hash chain until the end. */ l_loop = --as->mcp; emit_n(as, ARMI_CMP|ARMI_K12|0, dest); emit_lso(as, ARMI_LDR, dest, dest, (int32_t)offsetof(Node, next)); /* Type and value comparison. */ if (merge == IR_EQ) asm_guardcc(as, CC_EQ); else emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); if (!irt_ispri(kt)) { emit_nm(as, ARMF_CC(ARMI_CMP, CC_EQ)^k, tmp, key); emit_nm(as, ARMI_CMP^khi, tmp+1, keyhi); emit_lsox(as, ARMI_LDRD, tmp, dest, (int32_t)offsetof(Node, key)); } else { emit_n(as, ARMI_CMP^khi, tmp); emit_lso(as, ARMI_LDR, tmp, dest, (int32_t)offsetof(Node, key.it)); } *l_loop = ARMF_CC(ARMI_B, CC_NE) | ((as->mcp-l_loop-2) & 0x00ffffffu); /* Load main position relative to tab->node into dest. */ khash = irref_isk(refkey) ? ir_khash(irkey) : 1; if (khash == 0) { emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); } else { emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 3), dest, dest, tmp); emit_dnm(as, ARMI_ADD|ARMF_SH(ARMSH_LSL, 1), tmp, tmp, tmp); if (irt_isstr(kt)) { /* Fetch of str->hash is cheaper than ra_allock. */ emit_dnm(as, ARMI_AND, tmp, tmp+1, RID_TMP); emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); emit_lso(as, ARMI_LDR, tmp+1, key, (int32_t)offsetof(GCstr, hash)); emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); } else if (irref_isk(refkey)) { emit_opk(as, ARMI_AND, tmp, RID_TMP, (int32_t)khash, rset_exclude(rset_exclude(RSET_GPR, tab), dest)); emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); } else { /* Must match with hash*() in lj_tab.c. */ if (ra_hasreg(keynumhi)) { /* Canonicalize +-0.0 to 0.0. */ if (keyhi == RID_TMP) emit_dm(as, ARMF_CC(ARMI_MOV, CC_NE), keyhi, keynumhi); emit_d(as, ARMF_CC(ARMI_MOV, CC_EQ)|ARMI_K12|0, keyhi); } emit_dnm(as, ARMI_AND, tmp, tmp, RID_TMP); emit_dnm(as, ARMI_SUB|ARMF_SH(ARMSH_ROR, 32-HASH_ROT3), tmp, tmp, tmp+1); emit_lso(as, ARMI_LDR, dest, tab, (int32_t)offsetof(GCtab, node)); emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_ROR, 32-((HASH_ROT2+HASH_ROT1)&31)), tmp, tmp+1, tmp); emit_lso(as, ARMI_LDR, RID_TMP, tab, (int32_t)offsetof(GCtab, hmask)); emit_dnm(as, ARMI_SUB|ARMF_SH(ARMSH_ROR, 32-HASH_ROT1), tmp+1, tmp+1, tmp); if (ra_hasreg(keynumhi)) { emit_dnm(as, ARMI_EOR, tmp+1, tmp, key); emit_dnm(as, ARMI_ORR|ARMI_S, RID_TMP, tmp, key); /* Test for +-0.0. */ emit_dnm(as, ARMI_ADD, tmp, keynumhi, keynumhi); #if !LJ_SOFTFP emit_dnm(as, ARMI_VMOV_RR_D, key, keynumhi, (ra_alloc1(as, refkey, RSET_FPR) & 15)); #endif } else { emit_dnm(as, ARMI_EOR, tmp+1, tmp, key); emit_opk(as, ARMI_ADD, tmp, key, (int32_t)HASH_BIAS, rset_exclude(rset_exclude(RSET_GPR, tab), key)); } } } } static void asm_hrefk(ASMState *as, IRIns *ir) { IRIns *kslot = IR(ir->op2); IRIns *irkey = IR(kslot->op1); int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); int32_t kofs = ofs + (int32_t)offsetof(Node, key); Reg dest = (ra_used(ir) || ofs > 4095) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; Reg node = ra_alloc1(as, ir->op1, RSET_GPR); Reg key = RID_NONE, type = RID_TMP, idx = node; RegSet allow = rset_exclude(RSET_GPR, node); lua_assert(ofs % sizeof(Node) == 0); if (ofs > 4095) { idx = dest; rset_clear(allow, dest); kofs = (int32_t)offsetof(Node, key); } else if (ra_hasreg(dest)) { emit_opk(as, ARMI_ADD, dest, node, ofs, allow); } asm_guardcc(as, CC_NE); if (!irt_ispri(irkey->t)) { RegSet even = (as->freeset & allow); even = even & (even >> 1) & RSET_GPREVEN; if (even) { key = ra_scratch(as, even); if (rset_test(as->freeset, key+1)) { type = key+1; ra_modified(as, type); } } else { key = ra_scratch(as, allow); } rset_clear(allow, key); } rset_clear(allow, type); if (irt_isnum(irkey->t)) { emit_opk(as, ARMF_CC(ARMI_CMP, CC_EQ), 0, type, (int32_t)ir_knum(irkey)->u32.hi, allow); emit_opk(as, ARMI_CMP, 0, key, (int32_t)ir_knum(irkey)->u32.lo, allow); } else { if (ra_hasreg(key)) emit_opk(as, ARMF_CC(ARMI_CMP, CC_EQ), 0, key, irkey->i, allow); emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype(irkey->t), type); } emit_lso(as, ARMI_LDR, type, idx, kofs+4); if (ra_hasreg(key)) emit_lso(as, ARMI_LDR, key, idx, kofs); if (ofs > 4095) emit_opk(as, ARMI_ADD, dest, node, ofs, RSET_GPR); } static void asm_newref(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; IRRef args[3]; if (ir->r == RID_SINK) return; args[0] = ASMREF_L; /* lua_State *L */ args[1] = ir->op1; /* GCtab *t */ args[2] = ASMREF_TMP1; /* cTValue *key */ asm_setupresult(as, ir, ci); /* TValue * */ asm_gencall(as, ci, args); asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); } static void asm_uref(ASMState *as, IRIns *ir) { /* NYI: Check that UREFO is still open and not aliasing a slot. */ Reg dest = ra_dest(as, ir, RSET_GPR); if (irref_isk(ir->op1)) { GCfunc *fn = ir_kfunc(IR(ir->op1)); MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; emit_lsptr(as, ARMI_LDR, dest, v); } else { Reg uv = ra_scratch(as, RSET_GPR); Reg func = ra_alloc1(as, ir->op1, RSET_GPR); if (ir->o == IR_UREFC) { asm_guardcc(as, CC_NE); emit_n(as, ARMI_CMP|ARMI_K12|1, RID_TMP); emit_opk(as, ARMI_ADD, dest, uv, (int32_t)offsetof(GCupval, tv), RSET_GPR); emit_lso(as, ARMI_LDRB, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); } else { emit_lso(as, ARMI_LDR, dest, uv, (int32_t)offsetof(GCupval, v)); } emit_lso(as, ARMI_LDR, uv, func, (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); } } static void asm_fref(ASMState *as, IRIns *ir) { UNUSED(as); UNUSED(ir); lua_assert(!ra_used(ir)); } static void asm_strref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); IRRef ref = ir->op2, refk = ir->op1; Reg r; if (irref_isk(ref)) { IRRef tmp = refk; refk = ref; ref = tmp; } else if (!irref_isk(refk)) { uint32_t k, m = ARMI_K12|sizeof(GCstr); Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); IRIns *irr = IR(ir->op2); if (ra_hasreg(irr->r)) { ra_noweak(as, irr->r); right = irr->r; } else if (mayfuse(as, irr->op2) && irr->o == IR_ADD && irref_isk(irr->op2) && (k = emit_isk12(ARMI_ADD, (int32_t)sizeof(GCstr) + IR(irr->op2)->i))) { m = k; right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); } else { right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); } emit_dn(as, ARMI_ADD^m, dest, dest); emit_dnm(as, ARMI_ADD, dest, left, right); return; } r = ra_alloc1(as, ref, RSET_GPR); emit_opk(as, ARMI_ADD, dest, r, sizeof(GCstr) + IR(refk)->i, rset_exclude(RSET_GPR, r)); } /* -- Loads and stores ---------------------------------------------------- */ static ARMIns asm_fxloadins(IRIns *ir) { switch (irt_type(ir->t)) { case IRT_I8: return ARMI_LDRSB; case IRT_U8: return ARMI_LDRB; case IRT_I16: return ARMI_LDRSH; case IRT_U16: return ARMI_LDRH; case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VLDR_D; case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VLDR_S; default: return ARMI_LDR; } } static ARMIns asm_fxstoreins(IRIns *ir) { switch (irt_type(ir->t)) { case IRT_I8: case IRT_U8: return ARMI_STRB; case IRT_I16: case IRT_U16: return ARMI_STRH; case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VSTR_D; case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VSTR_S; default: return ARMI_STR; } } static void asm_fload(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); ARMIns ai = asm_fxloadins(ir); int32_t ofs; if (ir->op2 == IRFL_TAB_ARRAY) { ofs = asm_fuseabase(as, ir->op1); if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ emit_dn(as, ARMI_ADD|ARMI_K12|ofs, dest, idx); return; } } ofs = field_ofs[ir->op2]; if ((ai & 0x04000000)) emit_lso(as, ai, dest, idx, ofs); else emit_lsox(as, ai, dest, idx, ofs); } static void asm_fstore(ASMState *as, IRIns *ir) { if (ir->r != RID_SINK) { Reg src = ra_alloc1(as, ir->op2, RSET_GPR); IRIns *irf = IR(ir->op1); Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); int32_t ofs = field_ofs[irf->op2]; ARMIns ai = asm_fxstoreins(ir); if ((ai & 0x04000000)) emit_lso(as, ai, src, idx, ofs); else emit_lsox(as, ai, src, idx, ofs); } } static void asm_xload(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR); lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); } static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) { if (ir->r != RID_SINK) { Reg src = ra_alloc1(as, ir->op2, (!LJ_SOFTFP && irt_isfp(ir->t)) ? RSET_FPR : RSET_GPR); asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, rset_exclude(RSET_GPR, src), ofs); } } static void asm_ahuvload(ASMState *as, IRIns *ir) { int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); IRType t = hiop ? IRT_NUM : irt_type(ir->t); Reg dest = RID_NONE, type = RID_NONE, idx; RegSet allow = RSET_GPR; int32_t ofs = 0; if (hiop && ra_used(ir+1)) { type = ra_dest(as, ir+1, allow); rset_clear(allow, type); } if (ra_used(ir)) { lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) || irt_isint(ir->t) || irt_isaddr(ir->t)); dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow); rset_clear(allow, dest); } idx = asm_fuseahuref(as, ir->op1, &ofs, allow, (!LJ_SOFTFP && t == IRT_NUM) ? 1024 : 4096); if (!hiop || type == RID_NONE) { rset_clear(allow, idx); if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 && rset_test((as->freeset & allow), dest+1)) { type = dest+1; ra_modified(as, type); } else { type = RID_TMP; } } asm_guardcc(as, t == IRT_NUM ? CC_HS : CC_NE); emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype_(t), type); if (ra_hasreg(dest)) { #if !LJ_SOFTFP if (t == IRT_NUM) emit_vlso(as, ARMI_VLDR_D, dest, idx, ofs); else #endif emit_lso(as, ARMI_LDR, dest, idx, ofs); } emit_lso(as, ARMI_LDR, type, idx, ofs+4); } static void asm_ahustore(ASMState *as, IRIns *ir) { if (ir->r != RID_SINK) { RegSet allow = RSET_GPR; Reg idx, src = RID_NONE, type = RID_NONE; int32_t ofs = 0; #if !LJ_SOFTFP if (irt_isnum(ir->t)) { src = ra_alloc1(as, ir->op2, RSET_FPR); idx = asm_fuseahuref(as, ir->op1, &ofs, allow, 1024); emit_vlso(as, ARMI_VSTR_D, src, idx, ofs); } else #endif { int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); if (!irt_ispri(ir->t)) { src = ra_alloc1(as, ir->op2, allow); rset_clear(allow, src); } if (hiop) type = ra_alloc1(as, (ir+1)->op2, allow); else type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); idx = asm_fuseahuref(as, ir->op1, &ofs, rset_exclude(allow, type), 4096); if (ra_hasreg(src)) emit_lso(as, ARMI_STR, src, idx, ofs); emit_lso(as, ARMI_STR, type, idx, ofs+4); } } } static void asm_sload(ASMState *as, IRIns *ir) { int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); int hiop = (LJ_SOFTFP && (ir+1)->o == IR_HIOP); IRType t = hiop ? IRT_NUM : irt_type(ir->t); Reg dest = RID_NONE, type = RID_NONE, base; RegSet allow = RSET_GPR; lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ lua_assert(irt_isguard(ir->t) || !(ir->op2 & IRSLOAD_TYPECHECK)); #if LJ_SOFTFP lua_assert(!(ir->op2 & IRSLOAD_CONVERT)); /* Handled by LJ_SOFTFP SPLIT. */ if (hiop && ra_used(ir+1)) { type = ra_dest(as, ir+1, allow); rset_clear(allow, type); } #else if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(ir->t) && t == IRT_INT) { dest = ra_scratch(as, RSET_FPR); asm_tointg(as, ir, dest); t = IRT_NUM; /* Continue with a regular number type check. */ } else #endif if (ra_used(ir)) { lua_assert((LJ_SOFTFP ? 0 : irt_isnum(ir->t)) || irt_isint(ir->t) || irt_isaddr(ir->t)); dest = ra_dest(as, ir, (!LJ_SOFTFP && t == IRT_NUM) ? RSET_FPR : allow); rset_clear(allow, dest); base = ra_alloc1(as, REF_BASE, allow); if ((ir->op2 & IRSLOAD_CONVERT)) { if (t == IRT_INT) { Reg tmp = ra_scratch(as, RSET_FPR); emit_dn(as, ARMI_VMOV_R_S, dest, (tmp & 15)); emit_dm(as, ARMI_VCVT_S32_F64, (tmp & 15), (tmp & 15)); dest = tmp; t = IRT_NUM; /* Check for original type. */ } else { Reg tmp = ra_scratch(as, RSET_GPR); emit_dm(as, ARMI_VCVT_F64_S32, (dest & 15), (dest & 15)); emit_dn(as, ARMI_VMOV_S_R, tmp, (dest & 15)); dest = tmp; t = IRT_INT; /* Check for original type. */ } } goto dotypecheck; } base = ra_alloc1(as, REF_BASE, allow); dotypecheck: rset_clear(allow, base); if ((ir->op2 & IRSLOAD_TYPECHECK)) { if (ra_noreg(type)) { if (ofs < 256 && ra_hasreg(dest) && (dest & 1) == 0 && rset_test((as->freeset & allow), dest+1)) { type = dest+1; ra_modified(as, type); } else { type = RID_TMP; } } asm_guardcc(as, t == IRT_NUM ? CC_HS : CC_NE); emit_n(as, ARMI_CMN|ARMI_K12|-irt_toitype_(t), type); } if (ra_hasreg(dest)) { #if !LJ_SOFTFP if (t == IRT_NUM) { if (ofs < 1024) { emit_vlso(as, ARMI_VLDR_D, dest, base, ofs); } else { if (ra_hasreg(type)) emit_lso(as, ARMI_LDR, type, base, ofs+4); emit_vlso(as, ARMI_VLDR_D, dest, RID_TMP, 0); emit_opk(as, ARMI_ADD, RID_TMP, base, ofs, allow); return; } } else #endif emit_lso(as, ARMI_LDR, dest, base, ofs); } if (ra_hasreg(type)) emit_lso(as, ARMI_LDR, type, base, ofs+4); } /* -- Allocations --------------------------------------------------------- */ #if LJ_HASFFI static void asm_cnew(ASMState *as, IRIns *ir) { CTState *cts = ctype_ctsG(J2G(as->J)); CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; IRRef args[2]; RegSet allow = (RSET_GPR & ~RSET_SCRATCH); RegSet drop = RSET_SCRATCH; lua_assert(sz != CTSIZE_INVALID); args[0] = ASMREF_L; /* lua_State *L */ args[1] = ASMREF_TMP1; /* MSize size */ as->gcsteps++; if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ ra_evictset(as, drop); if (ra_used(ir)) ra_destreg(as, ir, RID_RET); /* GCcdata * */ /* Initialize immutable cdata object. */ if (ir->o == IR_CNEWI) { int32_t ofs = sizeof(GCcdata); lua_assert(sz == 4 || sz == 8); if (sz == 8) { ofs += 4; ir++; lua_assert(ir->o == IR_HIOP); } for (;;) { Reg r = ra_alloc1(as, ir->op2, allow); emit_lso(as, ARMI_STR, r, RID_RET, ofs); rset_clear(allow, r); if (ofs == sizeof(GCcdata)) break; ofs -= 4; ir--; } } /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ { uint32_t k = emit_isk12(ARMI_MOV, ctypeid); Reg r = k ? RID_R1 : ra_allock(as, ctypeid, allow); emit_lso(as, ARMI_STRB, RID_TMP, RID_RET, offsetof(GCcdata, gct)); emit_lsox(as, ARMI_STRH, r, RID_RET, offsetof(GCcdata, ctypeid)); emit_d(as, ARMI_MOV|ARMI_K12|~LJ_TCDATA, RID_TMP); if (k) emit_d(as, ARMI_MOV^k, RID_R1); } asm_gencall(as, ci, args); ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), ra_releasetmp(as, ASMREF_TMP1)); } #else #define asm_cnew(as, ir) ((void)0) #endif /* -- Write barriers ------------------------------------------------------ */ static void asm_tbar(ASMState *as, IRIns *ir) { Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); Reg link = ra_scratch(as, rset_exclude(RSET_GPR, tab)); Reg gr = ra_allock(as, i32ptr(J2G(as->J)), rset_exclude(rset_exclude(RSET_GPR, tab), link)); Reg mark = RID_TMP; MCLabel l_end = emit_label(as); emit_lso(as, ARMI_STR, link, tab, (int32_t)offsetof(GCtab, gclist)); emit_lso(as, ARMI_STRB, mark, tab, (int32_t)offsetof(GCtab, marked)); emit_lso(as, ARMI_STR, tab, gr, (int32_t)offsetof(global_State, gc.grayagain)); emit_dn(as, ARMI_BIC|ARMI_K12|LJ_GC_BLACK, mark, mark); emit_lso(as, ARMI_LDR, link, gr, (int32_t)offsetof(global_State, gc.grayagain)); emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); emit_n(as, ARMI_TST|ARMI_K12|LJ_GC_BLACK, mark); emit_lso(as, ARMI_LDRB, mark, tab, (int32_t)offsetof(GCtab, marked)); } static void asm_obar(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; IRRef args[2]; MCLabel l_end; Reg obj, val, tmp; /* No need for other object barriers (yet). */ lua_assert(IR(ir->op1)->o == IR_UREFC); ra_evictset(as, RSET_SCRATCH); l_end = emit_label(as); args[0] = ASMREF_TMP1; /* global_State *g */ args[1] = ir->op1; /* TValue *tv */ asm_gencall(as, ci, args); if ((l_end[-1] >> 28) == CC_AL) l_end[-1] = ARMF_CC(l_end[-1], CC_NE); else emit_branch(as, ARMF_CC(ARMI_B, CC_EQ), l_end); ra_allockreg(as, i32ptr(J2G(as->J)), ra_releasetmp(as, ASMREF_TMP1)); obj = IR(ir->op1)->r; tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); emit_n(as, ARMF_CC(ARMI_TST, CC_NE)|ARMI_K12|LJ_GC_BLACK, tmp); emit_n(as, ARMI_TST|ARMI_K12|LJ_GC_WHITES, RID_TMP); val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); emit_lso(as, ARMI_LDRB, tmp, obj, (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); emit_lso(as, ARMI_LDRB, RID_TMP, val, (int32_t)offsetof(GChead, marked)); } /* -- Arithmetic and logic operations ------------------------------------- */ #if !LJ_SOFTFP static void asm_fparith(ASMState *as, IRIns *ir, ARMIns ai) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg right, left = ra_alloc2(as, ir, RSET_FPR); right = (left >> 8); left &= 255; emit_dnm(as, ai, (dest & 15), (left & 15), (right & 15)); } static void asm_fpunary(ASMState *as, IRIns *ir, ARMIns ai) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); emit_dm(as, ai, (dest & 15), (left & 15)); } static int asm_fpjoin_pow(ASMState *as, IRIns *ir) { IRIns *irp = IR(ir->op1); if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { IRIns *irpp = IR(irp->op1); if (irpp == ir-2 && irpp->o == IR_FPMATH && irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; IRRef args[2]; args[0] = irpp->op1; args[1] = irp->op2; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); return 1; } } return 0; } #endif static int asm_swapops(ASMState *as, IRRef lref, IRRef rref) { IRIns *ir; if (irref_isk(rref)) return 0; /* Don't swap constants to the left. */ if (irref_isk(lref)) return 1; /* But swap constants to the right. */ ir = IR(rref); if ((ir->o >= IR_BSHL && ir->o <= IR_BROR) || (ir->o == IR_ADD && ir->op1 == ir->op2)) return 0; /* Don't swap fusable operands to the left. */ ir = IR(lref); if ((ir->o >= IR_BSHL && ir->o <= IR_BROR) || (ir->o == IR_ADD && ir->op1 == ir->op2)) return 1; /* But swap fusable operands to the right. */ return 0; /* Otherwise don't swap. */ } static void asm_intop(ASMState *as, IRIns *ir, ARMIns ai) { IRRef lref = ir->op1, rref = ir->op2; Reg left, dest = ra_dest(as, ir, RSET_GPR); uint32_t m; if (asm_swapops(as, lref, rref)) { IRRef tmp = lref; lref = rref; rref = tmp; if ((ai & ~ARMI_S) == ARMI_SUB || (ai & ~ARMI_S) == ARMI_SBC) ai ^= (ARMI_SUB^ARMI_RSB); } left = ra_hintalloc(as, lref, dest, RSET_GPR); m = asm_fuseopm(as, ai, rref, rset_exclude(RSET_GPR, left)); if (irt_isguard(ir->t)) { /* For IR_ADDOV etc. */ asm_guardcc(as, CC_VS); ai |= ARMI_S; } emit_dn(as, ai^m, dest, left); } static void asm_intop_s(ASMState *as, IRIns *ir, ARMIns ai) { if (as->flagmcp == as->mcp) { /* Drop cmp r, #0. */ as->flagmcp = NULL; as->mcp++; ai |= ARMI_S; } asm_intop(as, ir, ai); } static void asm_bitop(ASMState *as, IRIns *ir, ARMIns ai) { if (as->flagmcp == as->mcp) { /* Try to drop cmp r, #0. */ uint32_t cc = (as->mcp[1] >> 28); as->flagmcp = NULL; if (cc <= CC_NE) { as->mcp++; ai |= ARMI_S; } else if (cc == CC_GE) { *++as->mcp ^= ((CC_GE^CC_PL) << 28); ai |= ARMI_S; } else if (cc == CC_LT) { *++as->mcp ^= ((CC_LT^CC_MI) << 28); ai |= ARMI_S; } /* else: other conds don't work with bit ops. */ } if (ir->op2 == 0) { Reg dest = ra_dest(as, ir, RSET_GPR); uint32_t m = asm_fuseopm(as, ai, ir->op1, RSET_GPR); emit_d(as, ai^m, dest); } else { /* NYI: Turn BAND !k12 into uxtb, uxth or bfc or shl+shr. */ asm_intop(as, ir, ai); } } static void asm_intneg(ASMState *as, IRIns *ir, ARMIns ai) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); emit_dn(as, ai|ARMI_K12|0, dest, left); } /* NYI: use add/shift for MUL(OV) with constants. FOLD only does 2^k. */ static void asm_intmul(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, dest)); Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); Reg tmp = RID_NONE; /* ARMv5 restriction: dest != left and dest_hi != left. */ if (dest == left && left != right) { left = right; right = dest; } if (irt_isguard(ir->t)) { /* IR_MULOV */ if (!(as->flags & JIT_F_ARMV6) && dest == left) tmp = left = ra_scratch(as, rset_exclude(RSET_FPR, left)); asm_guardcc(as, CC_NE); emit_nm(as, ARMI_TEQ|ARMF_SH(ARMSH_ASR, 31), RID_TMP, dest); emit_dnm(as, ARMI_SMULL|ARMF_S(right), dest, RID_TMP, left); } else { if (!(as->flags & JIT_F_ARMV6) && dest == left) tmp = left = RID_TMP; emit_nm(as, ARMI_MUL|ARMF_S(right), dest, left); } /* Only need this for the dest == left == right case. */ if (ra_hasreg(tmp)) emit_dm(as, ARMI_MOV, tmp, right); } static void asm_add(ASMState *as, IRIns *ir) { #if !LJ_SOFTFP if (irt_isnum(ir->t)) { if (!asm_fusemadd(as, ir, ARMI_VMLA_D, ARMI_VMLA_D)) asm_fparith(as, ir, ARMI_VADD_D); return; } #endif asm_intop_s(as, ir, ARMI_ADD); } static void asm_sub(ASMState *as, IRIns *ir) { #if !LJ_SOFTFP if (irt_isnum(ir->t)) { if (!asm_fusemadd(as, ir, ARMI_VNMLS_D, ARMI_VMLS_D)) asm_fparith(as, ir, ARMI_VSUB_D); return; } #endif asm_intop_s(as, ir, ARMI_SUB); } static void asm_mul(ASMState *as, IRIns *ir) { #if !LJ_SOFTFP if (irt_isnum(ir->t)) { asm_fparith(as, ir, ARMI_VMUL_D); return; } #endif asm_intmul(as, ir); } static void asm_neg(ASMState *as, IRIns *ir) { #if !LJ_SOFTFP if (irt_isnum(ir->t)) { asm_fpunary(as, ir, ARMI_VNEG_D); return; } #endif asm_intneg(as, ir, ARMI_RSB); } static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) { const CCallInfo *ci = &lj_ir_callinfo[id]; IRRef args[2]; args[0] = ir->op1; args[1] = ir->op2; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } #if !LJ_SOFTFP static void asm_callround(ASMState *as, IRIns *ir, int id) { /* The modified regs must match with the *.dasc implementation. */ RegSet drop = RID2RSET(RID_R0)|RID2RSET(RID_R1)|RID2RSET(RID_R2)| RID2RSET(RID_R3)|RID2RSET(RID_R12); RegSet of; Reg dest, src; ra_evictset(as, drop); dest = ra_dest(as, ir, RSET_FPR); emit_dnm(as, ARMI_VMOV_D_RR, RID_RETLO, RID_RETHI, (dest & 15)); emit_call(as, id == IRFPM_FLOOR ? (void *)lj_vm_floor_sf : id == IRFPM_CEIL ? (void *)lj_vm_ceil_sf : (void *)lj_vm_trunc_sf); /* Workaround to protect argument GPRs from being used for remat. */ of = as->freeset; as->freeset &= ~RSET_RANGE(RID_R0, RID_R1+1); as->cost[RID_R0] = as->cost[RID_R1] = REGCOST(~0u, ASMREF_L); src = ra_alloc1(as, ir->op1, RSET_FPR); /* May alloc GPR to remat FPR. */ as->freeset |= (of & RSET_RANGE(RID_R0, RID_R1+1)); emit_dnm(as, ARMI_VMOV_RR_D, RID_R0, RID_R1, (src & 15)); } #endif static void asm_bitswap(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, RSET_GPR); if ((as->flags & JIT_F_ARMV6)) { emit_dm(as, ARMI_REV, dest, left); } else { Reg tmp2 = dest; if (tmp2 == left) tmp2 = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, dest), left)); emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_LSR, 8), dest, tmp2, RID_TMP); emit_dm(as, ARMI_MOV|ARMF_SH(ARMSH_ROR, 8), tmp2, left); emit_dn(as, ARMI_BIC|ARMI_K12|256*8|255, RID_TMP, RID_TMP); emit_dnm(as, ARMI_EOR|ARMF_SH(ARMSH_ROR, 16), RID_TMP, left, left); } } static void asm_bitshift(ASMState *as, IRIns *ir, ARMShift sh) { if (irref_isk(ir->op2)) { /* Constant shifts. */ /* NYI: Turn SHL+SHR or BAND+SHR into uxtb, uxth or ubfx. */ /* NYI: Turn SHL+ASR into sxtb, sxth or sbfx. */ Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, RSET_GPR); int32_t shift = (IR(ir->op2)->i & 31); emit_dm(as, ARMI_MOV|ARMF_SH(sh, shift), dest, left); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, RSET_GPR); Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_dm(as, ARMI_MOV|ARMF_RSH(sh, right), dest, left); } } static void asm_intmin_max(ASMState *as, IRIns *ir, int cc) { uint32_t kcmp = 0, kmov = 0; Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); Reg right = 0; if (irref_isk(ir->op2)) { kcmp = emit_isk12(ARMI_CMP, IR(ir->op2)->i); if (kcmp) kmov = emit_isk12(ARMI_MOV, IR(ir->op2)->i); } if (!kmov) { kcmp = 0; right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); } if (kmov || dest != right) { emit_dm(as, ARMF_CC(ARMI_MOV, cc)^kmov, dest, right); cc ^= 1; /* Must use opposite conditions for paired moves. */ } else { cc ^= (CC_LT^CC_GT); /* Otherwise may swap CC_LT <-> CC_GT. */ } if (dest != left) emit_dm(as, ARMF_CC(ARMI_MOV, cc), dest, left); emit_nm(as, ARMI_CMP^kcmp, left, right); } #if LJ_SOFTFP static void asm_sfpmin_max(ASMState *as, IRIns *ir, int cc) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp]; RegSet drop = RSET_SCRATCH; Reg r; IRRef args[4]; args[0] = ir->op1; args[1] = (ir+1)->op1; args[2] = ir->op2; args[3] = (ir+1)->op2; /* __aeabi_cdcmple preserves r0-r3. */ if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); if (ra_hasreg((ir+1)->r)) rset_clear(drop, (ir+1)->r); if (!rset_test(as->freeset, RID_R2) && regcost_ref(as->cost[RID_R2]) == args[2]) rset_clear(drop, RID_R2); if (!rset_test(as->freeset, RID_R3) && regcost_ref(as->cost[RID_R3]) == args[3]) rset_clear(drop, RID_R3); ra_evictset(as, drop); ra_destpair(as, ir); emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETHI, RID_R3); emit_dm(as, ARMF_CC(ARMI_MOV, cc), RID_RETLO, RID_R2); emit_call(as, (void *)ci->func); for (r = RID_R0; r <= RID_R3; r++) ra_leftov(as, r, args[r-RID_R0]); } #else static void asm_fpmin_max(ASMState *as, IRIns *ir, int cc) { Reg dest = (ra_dest(as, ir, RSET_FPR) & 15); Reg right, left = ra_alloc2(as, ir, RSET_FPR); right = ((left >> 8) & 15); left &= 15; if (dest != left) emit_dm(as, ARMF_CC(ARMI_VMOV_D, cc^1), dest, left); if (dest != right) emit_dm(as, ARMF_CC(ARMI_VMOV_D, cc), dest, right); emit_d(as, ARMI_VMRS, 0); emit_dm(as, ARMI_VCMP_D, left, right); } #endif static void asm_min_max(ASMState *as, IRIns *ir, int cc, int fcc) { #if LJ_SOFTFP UNUSED(fcc); #else if (irt_isnum(ir->t)) asm_fpmin_max(as, ir, fcc); else #endif asm_intmin_max(as, ir, cc); } /* -- Comparisons --------------------------------------------------------- */ /* Map of comparisons to flags. ORDER IR. */ static const uint8_t asm_compmap[IR_ABC+1] = { /* op FP swp int cc FP cc */ /* LT */ CC_GE + (CC_HS << 4), /* GE x */ CC_LT + (CC_HI << 4), /* LE */ CC_GT + (CC_HI << 4), /* GT x */ CC_LE + (CC_HS << 4), /* ULT x */ CC_HS + (CC_LS << 4), /* UGE */ CC_LO + (CC_LO << 4), /* ULE x */ CC_HI + (CC_LO << 4), /* UGT */ CC_LS + (CC_LS << 4), /* EQ */ CC_NE + (CC_NE << 4), /* NE */ CC_EQ + (CC_EQ << 4), /* ABC */ CC_LS + (CC_LS << 4) /* Same as UGT. */ }; #if LJ_SOFTFP /* FP comparisons. */ static void asm_sfpcomp(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_softfp_cmp]; RegSet drop = RSET_SCRATCH; Reg r; IRRef args[4]; int swp = (((ir->o ^ (ir->o >> 2)) & ~(ir->o >> 3) & 1) << 1); args[swp^0] = ir->op1; args[swp^1] = (ir+1)->op1; args[swp^2] = ir->op2; args[swp^3] = (ir+1)->op2; /* __aeabi_cdcmple preserves r0-r3. This helps to reduce spills. */ for (r = RID_R0; r <= RID_R3; r++) if (!rset_test(as->freeset, r) && regcost_ref(as->cost[r]) == args[r-RID_R0]) rset_clear(drop, r); ra_evictset(as, drop); asm_guardcc(as, (asm_compmap[ir->o] >> 4)); emit_call(as, (void *)ci->func); for (r = RID_R0; r <= RID_R3; r++) ra_leftov(as, r, args[r-RID_R0]); } #else /* FP comparisons. */ static void asm_fpcomp(ASMState *as, IRIns *ir) { Reg left, right; ARMIns ai; int swp = ((ir->o ^ (ir->o >> 2)) & ~(ir->o >> 3) & 1); if (!swp && irref_isk(ir->op2) && ir_knum(IR(ir->op2))->u64 == 0) { left = (ra_alloc1(as, ir->op1, RSET_FPR) & 15); right = 0; ai = ARMI_VCMPZ_D; } else { left = ra_alloc2(as, ir, RSET_FPR); if (swp) { right = (left & 15); left = ((left >> 8) & 15); } else { right = ((left >> 8) & 15); left &= 15; } ai = ARMI_VCMP_D; } asm_guardcc(as, (asm_compmap[ir->o] >> 4)); emit_d(as, ARMI_VMRS, 0); emit_dm(as, ai, left, right); } #endif /* Integer comparisons. */ static void asm_intcomp(ASMState *as, IRIns *ir) { ARMCC cc = (asm_compmap[ir->o] & 15); IRRef lref = ir->op1, rref = ir->op2; Reg left; uint32_t m; int cmpprev0 = 0; lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); if (asm_swapops(as, lref, rref)) { Reg tmp = lref; lref = rref; rref = tmp; if (cc >= CC_GE) cc ^= 7; /* LT <-> GT, LE <-> GE */ else if (cc > CC_NE) cc ^= 11; /* LO <-> HI, LS <-> HS */ } if (irref_isk(rref) && IR(rref)->i == 0) { IRIns *irl = IR(lref); cmpprev0 = (irl+1 == ir); /* Combine comp(BAND(left, right), 0) into tst left, right. */ if (cmpprev0 && irl->o == IR_BAND && !ra_used(irl)) { IRRef blref = irl->op1, brref = irl->op2; uint32_t m2 = 0; Reg bleft; if (asm_swapops(as, blref, brref)) { Reg tmp = blref; blref = brref; brref = tmp; } if (irref_isk(brref)) { m2 = emit_isk12(ARMI_AND, IR(brref)->i); if ((m2 & (ARMI_AND^ARMI_BIC))) goto notst; /* Not beneficial if we miss a constant operand. */ } if (cc == CC_GE) cc = CC_PL; else if (cc == CC_LT) cc = CC_MI; else if (cc > CC_NE) goto notst; /* Other conds don't work with tst. */ bleft = ra_alloc1(as, blref, RSET_GPR); if (!m2) m2 = asm_fuseopm(as, 0, brref, rset_exclude(RSET_GPR, bleft)); asm_guardcc(as, cc); emit_n(as, ARMI_TST^m2, bleft); return; } } notst: left = ra_alloc1(as, lref, RSET_GPR); m = asm_fuseopm(as, ARMI_CMP, rref, rset_exclude(RSET_GPR, left)); asm_guardcc(as, cc); emit_n(as, ARMI_CMP^m, left); /* Signed comparison with zero and referencing previous ins? */ if (cmpprev0 && (cc <= CC_NE || cc >= CC_GE)) as->flagmcp = as->mcp; /* Allow elimination of the compare. */ } /* 64 bit integer comparisons. */ static void asm_int64comp(ASMState *as, IRIns *ir) { int signedcomp = (ir->o <= IR_GT); ARMCC cclo, cchi; Reg leftlo, lefthi; uint32_t mlo, mhi; RegSet allow = RSET_GPR, oldfree; /* Always use unsigned comparison for loword. */ cclo = asm_compmap[ir->o + (signedcomp ? 4 : 0)] & 15; leftlo = ra_alloc1(as, ir->op1, allow); oldfree = as->freeset; mlo = asm_fuseopm(as, ARMI_CMP, ir->op2, rset_clear(allow, leftlo)); allow &= ~(oldfree & ~as->freeset); /* Update for allocs of asm_fuseopm. */ /* Use signed or unsigned comparison for hiword. */ cchi = asm_compmap[ir->o] & 15; lefthi = ra_alloc1(as, (ir+1)->op1, allow); mhi = asm_fuseopm(as, ARMI_CMP, (ir+1)->op2, rset_clear(allow, lefthi)); /* All register allocations must be performed _before_ this point. */ if (signedcomp) { MCLabel l_around = emit_label(as); asm_guardcc(as, cclo); emit_n(as, ARMI_CMP^mlo, leftlo); emit_branch(as, ARMF_CC(ARMI_B, CC_NE), l_around); if (cchi == CC_GE || cchi == CC_LE) cchi ^= 6; /* GE -> GT, LE -> LT */ asm_guardcc(as, cchi); } else { asm_guardcc(as, cclo); emit_n(as, ARMF_CC(ARMI_CMP, CC_EQ)^mlo, leftlo); } emit_n(as, ARMI_CMP^mhi, lefthi); } /* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ /* Hiword op of a split 64 bit op. Previous op must be the loword op. */ static void asm_hiop(ASMState *as, IRIns *ir) { #if LJ_HASFFI || LJ_SOFTFP /* HIOP is marked as a store because it needs its own DCE logic. */ int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; if ((ir-1)->o <= IR_NE) { /* 64 bit integer or FP comparisons. ORDER IR. */ as->curins--; /* Always skip the loword comparison. */ #if LJ_SOFTFP if (!irt_isint(ir->t)) asm_sfpcomp(as, ir-1); else #endif asm_int64comp(as, ir-1); return; #if LJ_SOFTFP } else if ((ir-1)->o == IR_MIN || (ir-1)->o == IR_MAX) { as->curins--; /* Always skip the loword min/max. */ if (uselo || usehi) asm_sfpmin_max(as, ir-1, (ir-1)->o == IR_MIN ? CC_HI : CC_LO); return; #elif LJ_HASFFI } else if ((ir-1)->o == IR_CONV) { as->curins--; /* Always skip the CONV. */ if (usehi || uselo) asm_conv64(as, ir); return; #endif } else if ((ir-1)->o == IR_XSTORE) { if ((ir-1)->r != RID_SINK) asm_xstore(as, ir, 4); return; } if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ switch ((ir-1)->o) { #if LJ_HASFFI case IR_ADD: as->curins--; asm_intop(as, ir, ARMI_ADC); asm_intop(as, ir-1, ARMI_ADD|ARMI_S); break; case IR_SUB: as->curins--; asm_intop(as, ir, ARMI_SBC); asm_intop(as, ir-1, ARMI_SUB|ARMI_S); break; case IR_NEG: as->curins--; asm_intneg(as, ir, ARMI_RSC); asm_intneg(as, ir-1, ARMI_RSB|ARMI_S); break; #endif #if LJ_SOFTFP case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: case IR_STRTO: if (!uselo) ra_allocref(as, ir->op1, RSET_GPR); /* Mark lo op as used. */ break; #endif case IR_CALLN: case IR_CALLS: case IR_CALLXS: if (!uselo) ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ break; #if LJ_SOFTFP case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_TOSTR: #endif case IR_CNEWI: /* Nothing to do here. Handled by lo op itself. */ break; default: lua_assert(0); break; } #else UNUSED(as); UNUSED(ir); lua_assert(0); #endif } /* -- Stack handling ------------------------------------------------------ */ /* Check Lua stack size for overflow. Use exit handler as fallback. */ static void asm_stack_check(ASMState *as, BCReg topslot, IRIns *irp, RegSet allow, ExitNo exitno) { Reg pbase; uint32_t k; if (irp) { if (!ra_hasspill(irp->s)) { pbase = irp->r; lua_assert(ra_hasreg(pbase)); } else if (allow) { pbase = rset_pickbot(allow); } else { pbase = RID_RET; emit_lso(as, ARMI_LDR, RID_RET, RID_SP, 0); /* Restore temp. register. */ } } else { pbase = RID_BASE; } emit_branch(as, ARMF_CC(ARMI_BL, CC_LS), exitstub_addr(as->J, exitno)); k = emit_isk12(0, (int32_t)(8*topslot)); lua_assert(k); emit_n(as, ARMI_CMP^k, RID_TMP); emit_dnm(as, ARMI_SUB, RID_TMP, RID_TMP, pbase); emit_lso(as, ARMI_LDR, RID_TMP, RID_TMP, (int32_t)offsetof(lua_State, maxstack)); if (irp) { /* Must not spill arbitrary registers in head of side trace. */ int32_t i = i32ptr(&J2G(as->J)->jit_L); if (ra_hasspill(irp->s)) emit_lso(as, ARMI_LDR, pbase, RID_SP, sps_scale(irp->s)); emit_lso(as, ARMI_LDR, RID_TMP, RID_TMP, (i & 4095)); if (ra_hasspill(irp->s) && !allow) emit_lso(as, ARMI_STR, RID_RET, RID_SP, 0); /* Save temp. register. */ emit_loadi(as, RID_TMP, (i & ~4095)); } else { emit_getgl(as, RID_TMP, jit_L); } } /* Restore Lua stack from on-trace state. */ static void asm_stack_restore(ASMState *as, SnapShot *snap) { SnapEntry *map = &as->T->snapmap[snap->mapofs]; SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; MSize n, nent = snap->nent; /* Store the value of all modified slots to the Lua stack. */ for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; BCReg s = snap_slot(sn); int32_t ofs = 8*((int32_t)s-1); IRRef ref = snap_ref(sn); IRIns *ir = IR(ref); if ((sn & SNAP_NORESTORE)) continue; if (irt_isnum(ir->t)) { #if LJ_SOFTFP RegSet odd = rset_exclude(RSET_GPRODD, RID_BASE); Reg tmp; lua_assert(irref_isk(ref)); /* LJ_SOFTFP: must be a number constant. */ tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.lo, rset_exclude(RSET_GPREVEN, RID_BASE)); emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs); if (rset_test(as->freeset, tmp+1)) odd = RID2RSET(tmp+1); tmp = ra_allock(as, (int32_t)ir_knum(ir)->u32.hi, odd); emit_lso(as, ARMI_STR, tmp, RID_BASE, ofs+4); #else Reg src = ra_alloc1(as, ref, RSET_FPR); emit_vlso(as, ARMI_VSTR_D, src, RID_BASE, ofs); #endif } else { RegSet odd = rset_exclude(RSET_GPRODD, RID_BASE); Reg type; lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); if (!irt_ispri(ir->t)) { Reg src = ra_alloc1(as, ref, rset_exclude(RSET_GPREVEN, RID_BASE)); emit_lso(as, ARMI_STR, src, RID_BASE, ofs); if (rset_test(as->freeset, src+1)) odd = RID2RSET(src+1); } if ((sn & (SNAP_CONT|SNAP_FRAME))) { if (s == 0) continue; /* Do not overwrite link to previous frame. */ type = ra_allock(as, (int32_t)(*flinks--), odd); #if LJ_SOFTFP } else if ((sn & SNAP_SOFTFPNUM)) { type = ra_alloc1(as, ref+1, rset_exclude(RSET_GPRODD, RID_BASE)); #endif } else { type = ra_allock(as, (int32_t)irt_toitype(ir->t), odd); } emit_lso(as, ARMI_STR, type, RID_BASE, ofs+4); } checkmclim(as); } lua_assert(map + nent == flinks); } /* -- GC handling --------------------------------------------------------- */ /* Check GC threshold and do one or more GC steps. */ static void asm_gc_check(ASMState *as) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; IRRef args[2]; MCLabel l_end; Reg tmp1, tmp2; ra_evictset(as, RSET_SCRATCH); l_end = emit_label(as); /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ emit_n(as, ARMI_CMP|ARMI_K12|0, RID_RET); args[0] = ASMREF_TMP1; /* global_State *g */ args[1] = ASMREF_TMP2; /* MSize steps */ asm_gencall(as, ci, args); tmp1 = ra_releasetmp(as, ASMREF_TMP1); tmp2 = ra_releasetmp(as, ASMREF_TMP2); emit_loadi(as, tmp2, as->gcsteps); /* Jump around GC step if GC total < GC threshold. */ emit_branch(as, ARMF_CC(ARMI_B, CC_LS), l_end); emit_nm(as, ARMI_CMP, RID_TMP, tmp2); emit_lso(as, ARMI_LDR, tmp2, tmp1, (int32_t)offsetof(global_State, gc.threshold)); emit_lso(as, ARMI_LDR, RID_TMP, tmp1, (int32_t)offsetof(global_State, gc.total)); ra_allockreg(as, i32ptr(J2G(as->J)), tmp1); as->gcsteps = 0; checkmclim(as); } /* -- Loop handling ------------------------------------------------------- */ /* Fixup the loop branch. */ static void asm_loop_fixup(ASMState *as) { MCode *p = as->mctop; MCode *target = as->mcp; if (as->loopinv) { /* Inverted loop branch? */ /* asm_guardcc already inverted the bcc and patched the final bl. */ p[-2] |= ((uint32_t)(target-p) & 0x00ffffffu); } else { p[-1] = ARMI_B | ((uint32_t)((target-p)-1) & 0x00ffffffu); } } /* -- Head of trace ------------------------------------------------------- */ /* Reload L register from g->jit_L. */ static void asm_head_lreg(ASMState *as) { IRIns *ir = IR(ASMREF_L); if (ra_used(ir)) { Reg r = ra_dest(as, ir, RSET_GPR); emit_getgl(as, r, jit_L); ra_evictk(as); } } /* Coalesce BASE register for a root trace. */ static void asm_head_root_base(ASMState *as) { IRIns *ir; asm_head_lreg(as); ir = IR(REF_BASE); if (ra_hasreg(ir->r) && rset_test(as->modset, ir->r)) ra_spill(as, ir); ra_destreg(as, ir, RID_BASE); } /* Coalesce BASE register for a side trace. */ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) { IRIns *ir; asm_head_lreg(as); ir = IR(REF_BASE); if (ra_hasreg(ir->r) && rset_test(as->modset, ir->r)) ra_spill(as, ir); if (ra_hasspill(irp->s)) { rset_clear(allow, ra_dest(as, ir, allow)); } else { Reg r = irp->r; lua_assert(ra_hasreg(r)); rset_clear(allow, r); if (r != ir->r && !rset_test(as->freeset, r)) ra_restore(as, regcost_ref(as->cost[r])); ra_destreg(as, ir, r); } return allow; } /* -- Tail of trace ------------------------------------------------------- */ /* Fixup the tail code. */ static void asm_tail_fixup(ASMState *as, TraceNo lnk) { MCode *p = as->mctop; MCode *target; int32_t spadj = as->T->spadjust; if (spadj == 0) { as->mctop = --p; } else { /* Patch stack adjustment. */ uint32_t k = emit_isk12(ARMI_ADD, spadj); lua_assert(k); p[-2] = (ARMI_ADD^k) | ARMF_D(RID_SP) | ARMF_N(RID_SP); } /* Patch exit branch. */ target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; p[-1] = ARMI_B|(((target-p)-1)&0x00ffffffu); } /* Prepare tail of code. */ static void asm_tail_prep(ASMState *as) { MCode *p = as->mctop - 1; /* Leave room for exit branch. */ if (as->loopref) { as->invmcp = as->mcp = p; } else { as->mcp = p-1; /* Leave room for stack pointer adjustment. */ as->invmcp = NULL; } *p = 0; /* Prevent load/store merging. */ } /* -- Instruction dispatch ------------------------------------------------ */ /* Assemble a single instruction. */ static void asm_ir(ASMState *as, IRIns *ir) { switch ((IROp)ir->o) { /* Miscellaneous ops. */ case IR_LOOP: asm_loop(as); break; case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; case IR_USE: ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; case IR_PHI: asm_phi(as, ir); break; case IR_HIOP: asm_hiop(as, ir); break; case IR_GCSTEP: asm_gcstep(as, ir); break; /* Guarded assertions. */ case IR_EQ: case IR_NE: if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) { as->curins--; asm_href(as, ir-1, (IROp)ir->o); break; } /* fallthrough */ case IR_LT: case IR_GE: case IR_LE: case IR_GT: case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: case IR_ABC: #if !LJ_SOFTFP if (irt_isnum(ir->t)) { asm_fpcomp(as, ir); break; } #endif asm_intcomp(as, ir); break; case IR_RETF: asm_retf(as, ir); break; /* Bit ops. */ case IR_BNOT: asm_bitop(as, ir, ARMI_MVN); break; case IR_BSWAP: asm_bitswap(as, ir); break; case IR_BAND: asm_bitop(as, ir, ARMI_AND); break; case IR_BOR: asm_bitop(as, ir, ARMI_ORR); break; case IR_BXOR: asm_bitop(as, ir, ARMI_EOR); break; case IR_BSHL: asm_bitshift(as, ir, ARMSH_LSL); break; case IR_BSHR: asm_bitshift(as, ir, ARMSH_LSR); break; case IR_BSAR: asm_bitshift(as, ir, ARMSH_ASR); break; case IR_BROR: asm_bitshift(as, ir, ARMSH_ROR); break; case IR_BROL: lua_assert(0); break; /* Arithmetic ops. */ case IR_ADD: case IR_ADDOV: asm_add(as, ir); break; case IR_SUB: case IR_SUBOV: asm_sub(as, ir); break; case IR_MUL: case IR_MULOV: asm_mul(as, ir); break; case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; case IR_NEG: asm_neg(as, ir); break; #if LJ_SOFTFP case IR_DIV: case IR_POW: case IR_ABS: case IR_ATAN2: case IR_LDEXP: case IR_FPMATH: case IR_TOBIT: lua_assert(0); /* Unused for LJ_SOFTFP. */ break; #else case IR_DIV: asm_fparith(as, ir, ARMI_VDIV_D); break; case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; case IR_ABS: asm_fpunary(as, ir, ARMI_VABS_D); break; case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; case IR_FPMATH: if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) break; if (ir->op2 <= IRFPM_TRUNC) asm_callround(as, ir, ir->op2); else if (ir->op2 == IRFPM_SQRT) asm_fpunary(as, ir, ARMI_VSQRT_D); else asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); break; case IR_TOBIT: asm_tobit(as, ir); break; #endif case IR_MIN: asm_min_max(as, ir, CC_GT, CC_HI); break; case IR_MAX: asm_min_max(as, ir, CC_LT, CC_LO); break; /* Memory references. */ case IR_AREF: asm_aref(as, ir); break; case IR_HREF: asm_href(as, ir, 0); break; case IR_HREFK: asm_hrefk(as, ir); break; case IR_NEWREF: asm_newref(as, ir); break; case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; case IR_FREF: asm_fref(as, ir); break; case IR_STRREF: asm_strref(as, ir); break; /* Loads and stores. */ case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: asm_ahuvload(as, ir); break; case IR_FLOAD: asm_fload(as, ir); break; case IR_XLOAD: asm_xload(as, ir); break; case IR_SLOAD: asm_sload(as, ir); break; case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; case IR_FSTORE: asm_fstore(as, ir); break; case IR_XSTORE: asm_xstore(as, ir, 0); break; /* Allocations. */ case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; case IR_TNEW: asm_tnew(as, ir); break; case IR_TDUP: asm_tdup(as, ir); break; case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; /* Write barriers. */ case IR_TBAR: asm_tbar(as, ir); break; case IR_OBAR: asm_obar(as, ir); break; /* Type conversions. */ case IR_CONV: asm_conv(as, ir); break; case IR_TOSTR: asm_tostr(as, ir); break; case IR_STRTO: asm_strto(as, ir); break; /* Calls. */ case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; case IR_CALLXS: asm_callx(as, ir); break; case IR_CARG: break; default: setintV(&as->J->errinfo, ir->o); lj_trace_err_info(as->J, LJ_TRERR_NYIIR); break; } } /* -- Trace setup --------------------------------------------------------- */ /* Ensure there are enough stack slots for call arguments. */ static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) { IRRef args[CCI_NARGS_MAX]; uint32_t i, nargs = (int)CCI_NARGS(ci); int nslots = 0, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR, fprodd = 0; asm_collectargs(as, ir, ci, args); for (i = 0; i < nargs; i++) { if (!LJ_SOFTFP && args[i] && irt_isfp(IR(args[i])->t)) { if (!LJ_ABI_SOFTFP && !(ci->flags & CCI_VARARG)) { if (irt_isnum(IR(args[i])->t)) { if (nfpr > 0) nfpr--; else fprodd = 0, nslots = (nslots + 3) & ~1; } else { if (fprodd) fprodd--; else if (nfpr > 0) fprodd = 1, nfpr--; else nslots++; } } else if (irt_isnum(IR(args[i])->t)) { ngpr &= ~1; if (ngpr > 0) ngpr -= 2; else nslots += 2; } else { if (ngpr > 0) ngpr--; else nslots++; } } else { if (ngpr > 0) ngpr--; else nslots++; } } if (nslots > as->evenspill) /* Leave room for args in stack slots. */ as->evenspill = nslots; return REGSP_HINT(RID_RET); } static void asm_setup_target(ASMState *as) { /* May need extra exit for asm_stack_check on side traces. */ asm_exitstub_setup(as, as->T->nsnap + (as->parent ? 1 : 0)); } /* -- Trace patching ------------------------------------------------------ */ /* Patch exit jumps of existing machine code to a new target. */ void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) { MCode *p = T->mcode; MCode *pe = (MCode *)((char *)p + T->szmcode); MCode *cstart = NULL, *cend = p; MCode *mcarea = lj_mcode_patch(J, p, 0); MCode *px = exitstub_addr(J, exitno) - 2; for (; p < pe; p++) { /* Look for bl_cc exitstub, replace with b_cc target. */ uint32_t ins = *p; if ((ins & 0x0f000000u) == 0x0b000000u && ins < 0xf0000000u && ((ins ^ (px-p)) & 0x00ffffffu) == 0) { *p = (ins & 0xfe000000u) | (((target-p)-2) & 0x00ffffffu); cend = p+1; if (!cstart) cstart = p; } } lua_assert(cstart != NULL); lj_mcode_sync(cstart, cend); lj_mcode_patch(J, mcarea, 1); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_asm_mips.h ================================================ /* ** MIPS IR assembler (SSA IR -> machine code). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* -- Register allocator extensions --------------------------------------- */ /* Allocate a register with a hint. */ static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) { Reg r = IR(ref)->r; if (ra_noreg(r)) { if (!ra_hashint(r) && !iscrossref(as, ref)) ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ r = ra_allocref(as, ref, allow); } ra_noweak(as, r); return r; } /* Allocate a register or RID_ZERO. */ static Reg ra_alloc1z(ASMState *as, IRRef ref, RegSet allow) { Reg r = IR(ref)->r; if (ra_noreg(r)) { if (!(allow & RSET_FPR) && irref_isk(ref) && IR(ref)->i == 0) return RID_ZERO; r = ra_allocref(as, ref, allow); } else { ra_noweak(as, r); } return r; } /* Allocate two source registers for three-operand instructions. */ static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) { IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); Reg left = irl->r, right = irr->r; if (ra_hasreg(left)) { ra_noweak(as, left); if (ra_noreg(right)) right = ra_alloc1z(as, ir->op2, rset_exclude(allow, left)); else ra_noweak(as, right); } else if (ra_hasreg(right)) { ra_noweak(as, right); left = ra_alloc1z(as, ir->op1, rset_exclude(allow, right)); } else if (ra_hashint(right)) { right = ra_alloc1z(as, ir->op2, allow); left = ra_alloc1z(as, ir->op1, rset_exclude(allow, right)); } else { left = ra_alloc1z(as, ir->op1, allow); right = ra_alloc1z(as, ir->op2, rset_exclude(allow, left)); } return left | (right << 8); } /* -- Guard handling ------------------------------------------------------ */ /* Need some spare long-range jump slots, for out-of-range branches. */ #define MIPS_SPAREJUMP 4 /* Setup spare long-range jump slots per mcarea. */ static void asm_sparejump_setup(ASMState *as) { MCode *mxp = as->mcbot; /* Assumes sizeof(MCLink) == 8. */ if (((uintptr_t)mxp & (LJ_PAGESIZE-1)) == 8) { lua_assert(MIPSI_NOP == 0); memset(mxp+2, 0, MIPS_SPAREJUMP*8); mxp += MIPS_SPAREJUMP*2; lua_assert(mxp < as->mctop); lj_mcode_sync(as->mcbot, mxp); lj_mcode_commitbot(as->J, mxp); as->mcbot = mxp; as->mclim = as->mcbot + MCLIM_REDZONE; } } /* Setup exit stub after the end of each trace. */ static void asm_exitstub_setup(ASMState *as) { MCode *mxp = as->mctop; /* sw TMP, 0(sp); j ->vm_exit_handler; li TMP, traceno */ *--mxp = MIPSI_LI|MIPSF_T(RID_TMP)|as->T->traceno; *--mxp = MIPSI_J|((((uintptr_t)(void *)lj_vm_exit_handler)>>2)&0x03ffffffu); lua_assert(((uintptr_t)mxp ^ (uintptr_t)(void *)lj_vm_exit_handler)>>28 == 0); *--mxp = MIPSI_SW|MIPSF_T(RID_TMP)|MIPSF_S(RID_SP)|0; as->mctop = mxp; } /* Keep this in-sync with exitstub_trace_addr(). */ #define asm_exitstub_addr(as) ((as)->mctop) /* Emit conditional branch to exit for guard. */ static void asm_guard(ASMState *as, MIPSIns mi, Reg rs, Reg rt) { MCode *target = asm_exitstub_addr(as); MCode *p = as->mcp; if (LJ_UNLIKELY(p == as->invmcp)) { as->invmcp = NULL; as->loopinv = 1; as->mcp = p+1; mi = mi ^ ((mi>>28) == 1 ? 0x04000000u : 0x00010000u); /* Invert cond. */ target = p; /* Patch target later in asm_loop_fixup. */ } emit_ti(as, MIPSI_LI, RID_TMP, as->snapno); emit_branch(as, mi, rs, rt, target); } /* -- Operand fusion ------------------------------------------------------ */ /* Limit linear search to this distance. Avoids O(n^2) behavior. */ #define CONFLICT_SEARCH_LIM 31 /* Check if there's no conflicting instruction between curins and ref. */ static int noconflict(ASMState *as, IRRef ref, IROp conflict) { IRIns *ir = as->ir; IRRef i = as->curins; if (i > ref + CONFLICT_SEARCH_LIM) return 0; /* Give up, ref is too far away. */ while (--i > ref) if (ir[i].o == conflict) return 0; /* Conflict found. */ return 1; /* Ok, no conflict. */ } /* Fuse the array base of colocated arrays. */ static int32_t asm_fuseabase(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) return (int32_t)sizeof(GCtab); return 0; } /* Fuse array/hash/upvalue reference into register+offset operand. */ static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow) { IRIns *ir = IR(ref); if (ra_noreg(ir->r)) { if (ir->o == IR_AREF) { if (mayfuse(as, ref)) { if (irref_isk(ir->op2)) { IRRef tab = IR(ir->op1)->op1; int32_t ofs = asm_fuseabase(as, tab); IRRef refa = ofs ? tab : ir->op1; ofs += 8*IR(ir->op2)->i; if (checki16(ofs)) { *ofsp = ofs; return ra_alloc1(as, refa, allow); } } } } else if (ir->o == IR_HREFK) { if (mayfuse(as, ref)) { int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); if (checki16(ofs)) { *ofsp = ofs; return ra_alloc1(as, ir->op1, allow); } } } else if (ir->o == IR_UREFC) { if (irref_isk(ir->op1)) { GCfunc *fn = ir_kfunc(IR(ir->op1)); int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); int32_t jgl = (intptr_t)J2G(as->J); if ((uint32_t)(ofs-jgl) < 65536) { *ofsp = ofs-jgl-32768; return RID_JGL; } else { *ofsp = (int16_t)ofs; return ra_allock(as, ofs-(int16_t)ofs, allow); } } } } *ofsp = 0; return ra_alloc1(as, ref, allow); } /* Fuse XLOAD/XSTORE reference into load/store operand. */ static void asm_fusexref(ASMState *as, MIPSIns mi, Reg rt, IRRef ref, RegSet allow, int32_t ofs) { IRIns *ir = IR(ref); Reg base; if (ra_noreg(ir->r) && canfuse(as, ir)) { if (ir->o == IR_ADD) { int32_t ofs2; if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) { ref = ir->op1; ofs = ofs2; } } else if (ir->o == IR_STRREF) { int32_t ofs2 = 65536; lua_assert(ofs == 0); ofs = (int32_t)sizeof(GCstr); if (irref_isk(ir->op2)) { ofs2 = ofs + IR(ir->op2)->i; ref = ir->op1; } else if (irref_isk(ir->op1)) { ofs2 = ofs + IR(ir->op1)->i; ref = ir->op2; } if (!checki16(ofs2)) { /* NYI: Fuse ADD with constant. */ Reg right, left = ra_alloc2(as, ir, allow); right = (left >> 8); left &= 255; emit_hsi(as, mi, rt, RID_TMP, ofs); emit_dst(as, MIPSI_ADDU, RID_TMP, left, right); return; } ofs = ofs2; } } base = ra_alloc1(as, ref, allow); emit_hsi(as, mi, rt, base, ofs); } /* -- Calls --------------------------------------------------------------- */ /* Generate a call to a C function. */ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) { uint32_t n, nargs = CCI_NARGS(ci); int32_t ofs = 16; Reg gpr, fpr = REGARG_FIRSTFPR; if ((void *)ci->func) emit_call(as, (void *)ci->func); for (gpr = REGARG_FIRSTGPR; gpr <= REGARG_LASTGPR; gpr++) as->cost[gpr] = REGCOST(~0u, ASMREF_L); gpr = REGARG_FIRSTGPR; for (n = 0; n < nargs; n++) { /* Setup args. */ IRRef ref = args[n]; if (ref) { IRIns *ir = IR(ref); if (irt_isfp(ir->t) && fpr <= REGARG_LASTFPR && !(ci->flags & CCI_VARARG)) { lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */ ra_leftov(as, fpr, ref); fpr += 2; gpr += irt_isnum(ir->t) ? 2 : 1; } else { fpr = REGARG_LASTFPR+1; if (irt_isnum(ir->t)) gpr = (gpr+1) & ~1; if (gpr <= REGARG_LASTGPR) { lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ if (irt_isfp(ir->t)) { RegSet of = as->freeset; Reg r; /* Workaround to protect argument GPRs from being used for remat. */ as->freeset &= ~RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1); r = ra_alloc1(as, ref, RSET_FPR); as->freeset |= (of & RSET_RANGE(REGARG_FIRSTGPR, REGARG_LASTGPR+1)); if (irt_isnum(ir->t)) { emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?0:1), r+1); emit_tg(as, MIPSI_MFC1, gpr+(LJ_BE?1:0), r); lua_assert(rset_test(as->freeset, gpr+1)); /* Already evicted. */ gpr += 2; } else if (irt_isfloat(ir->t)) { emit_tg(as, MIPSI_MFC1, gpr, r); gpr++; } } else { ra_leftov(as, gpr, ref); gpr++; } } else { Reg r = ra_alloc1z(as, ref, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; emit_spstore(as, ir, r, ofs); ofs += irt_isnum(ir->t) ? 8 : 4; } } } else { fpr = REGARG_LASTFPR+1; if (gpr <= REGARG_LASTGPR) gpr++; else ofs += 4; } } } /* Setup result reg/sp for call. Evict scratch regs. */ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) { RegSet drop = RSET_SCRATCH; int hiop = ((ir+1)->o == IR_HIOP); if ((ci->flags & CCI_NOFPRCLOBBER)) drop &= ~RSET_FPR; if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ if (hiop && ra_hasreg((ir+1)->r)) rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ ra_evictset(as, drop); /* Evictions must be performed first. */ if (ra_used(ir)) { lua_assert(!irt_ispri(ir->t)); if (irt_isfp(ir->t)) { if ((ci->flags & CCI_CASTU64)) { int32_t ofs = sps_scale(ir->s); Reg dest = ir->r; if (ra_hasreg(dest)) { ra_free(as, dest); ra_modified(as, dest); emit_tg(as, MIPSI_MTC1, RID_RETHI, dest+1); emit_tg(as, MIPSI_MTC1, RID_RETLO, dest); } if (ofs) { emit_tsi(as, MIPSI_SW, RID_RETLO, RID_SP, ofs+(LJ_BE?4:0)); emit_tsi(as, MIPSI_SW, RID_RETHI, RID_SP, ofs+(LJ_BE?0:4)); } } else { ra_destreg(as, ir, RID_FPRET); } } else if (hiop) { ra_destpair(as, ir); } else { ra_destreg(as, ir, RID_RET); } } } static void asm_call(ASMState *as, IRIns *ir) { IRRef args[CCI_NARGS_MAX]; const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; asm_collectargs(as, ir, ci, args); asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } static void asm_callx(ASMState *as, IRIns *ir) { IRRef args[CCI_NARGS_MAX]; CCallInfo ci; IRRef func; IRIns *irf; ci.flags = asm_callx_flags(as, ir); asm_collectargs(as, ir, &ci, args); asm_setupresult(as, ir, &ci); func = ir->op2; irf = IR(func); if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } if (irref_isk(func)) { /* Call to constant address. */ ci.func = (ASMFunction)(void *)(irf->i); } else { /* Need specific register for indirect calls. */ Reg r = ra_alloc1(as, func, RID2RSET(RID_CFUNCADDR)); MCode *p = as->mcp; if (r == RID_CFUNCADDR) *--p = MIPSI_NOP; else *--p = MIPSI_MOVE | MIPSF_D(RID_CFUNCADDR) | MIPSF_S(r); *--p = MIPSI_JALR | MIPSF_S(r); as->mcp = p; ci.func = (ASMFunction)(void *)0; } asm_gencall(as, &ci, args); } static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) { const CCallInfo *ci = &lj_ir_callinfo[id]; IRRef args[2]; args[0] = ir->op1; args[1] = ir->op2; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } static void asm_callround(ASMState *as, IRIns *ir, IRCallID id) { /* The modified regs must match with the *.dasc implementation. */ RegSet drop = RID2RSET(RID_R1)|RID2RSET(RID_R12)|RID2RSET(RID_FPRET)| RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(REGARG_FIRSTFPR); if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); ra_evictset(as, drop); ra_destreg(as, ir, RID_FPRET); emit_call(as, (void *)lj_ir_callinfo[id].func); ra_leftov(as, REGARG_FIRSTFPR, ir->op1); } /* -- Returns ------------------------------------------------------------- */ /* Return to lower frame. Guard that it goes to the right spot. */ static void asm_retf(ASMState *as, IRIns *ir) { Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); void *pc = ir_kptr(IR(ir->op2)); int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); as->topslot -= (BCReg)delta; if ((int32_t)as->topslot < 0) as->topslot = 0; emit_setgl(as, base, jit_base); emit_addptr(as, base, -8*delta); asm_guard(as, MIPSI_BNE, RID_TMP, ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); emit_tsi(as, MIPSI_LW, RID_TMP, base, -8); } /* -- Type conversions ---------------------------------------------------- */ static void asm_tointg(ASMState *as, IRIns *ir, Reg left) { Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); Reg dest = ra_dest(as, ir, RSET_GPR); asm_guard(as, MIPSI_BC1F, 0, 0); emit_fgh(as, MIPSI_C_EQ_D, 0, tmp, left); emit_fg(as, MIPSI_CVT_D_W, tmp, tmp); emit_tg(as, MIPSI_MFC1, dest, tmp); emit_fg(as, MIPSI_CVT_W_D, tmp, left); } static void asm_tobit(ASMState *as, IRIns *ir) { RegSet allow = RSET_FPR; Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, allow); Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); Reg tmp = ra_scratch(as, rset_clear(allow, right)); emit_tg(as, MIPSI_MFC1, dest, tmp); emit_fgh(as, MIPSI_ADD_D, tmp, left, right); } static void asm_conv(ASMState *as, IRIns *ir) { IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); int stfp = (st == IRT_NUM || st == IRT_FLOAT); IRRef lref = ir->op1; lua_assert(irt_type(ir->t) != st); lua_assert(!(irt_isint64(ir->t) || (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */ if (irt_isfp(ir->t)) { Reg dest = ra_dest(as, ir, RSET_FPR); if (stfp) { /* FP to FP conversion. */ emit_fg(as, st == IRT_NUM ? MIPSI_CVT_S_D : MIPSI_CVT_D_S, dest, ra_alloc1(as, lref, RSET_FPR)); } else if (st == IRT_U32) { /* U32 to FP conversion. */ /* y = (x ^ 0x8000000) + 2147483648.0 */ Reg left = ra_alloc1(as, lref, RSET_GPR); Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, dest)); emit_fgh(as, irt_isfloat(ir->t) ? MIPSI_ADD_S : MIPSI_ADD_D, dest, dest, tmp); emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W, dest, dest); if (irt_isfloat(ir->t)) emit_lsptr(as, MIPSI_LWC1, (tmp & 31), (void *)lj_ir_k64_find(as->J, U64x(4f000000,4f000000)), RSET_GPR); else emit_lsptr(as, MIPSI_LDC1, (tmp & 31), (void *)lj_ir_k64_find(as->J, U64x(41e00000,00000000)), RSET_GPR); emit_tg(as, MIPSI_MTC1, RID_TMP, dest); emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, left); emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000); } else { /* Integer to FP conversion. */ Reg left = ra_alloc1(as, lref, RSET_GPR); emit_fg(as, irt_isfloat(ir->t) ? MIPSI_CVT_S_W : MIPSI_CVT_D_W, dest, dest); emit_tg(as, MIPSI_MTC1, left, dest); } } else if (stfp) { /* FP to integer conversion. */ if (irt_isguard(ir->t)) { /* Checked conversions are only supported from number to int. */ lua_assert(irt_isint(ir->t) && st == IRT_NUM); asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, lref, RSET_FPR); Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); if (irt_isu32(ir->t)) { /* y = (int)floor(x - 2147483648.0) ^ 0x80000000 */ emit_dst(as, MIPSI_XOR, dest, dest, RID_TMP); emit_ti(as, MIPSI_LUI, RID_TMP, 0x8000); emit_tg(as, MIPSI_MFC1, dest, tmp); emit_fg(as, st == IRT_FLOAT ? MIPSI_FLOOR_W_S : MIPSI_FLOOR_W_D, tmp, tmp); emit_fgh(as, st == IRT_FLOAT ? MIPSI_SUB_S : MIPSI_SUB_D, tmp, left, tmp); if (st == IRT_FLOAT) emit_lsptr(as, MIPSI_LWC1, (tmp & 31), (void *)lj_ir_k64_find(as->J, U64x(4f000000,4f000000)), RSET_GPR); else emit_lsptr(as, MIPSI_LDC1, (tmp & 31), (void *)lj_ir_k64_find(as->J, U64x(41e00000,00000000)), RSET_GPR); } else { emit_tg(as, MIPSI_MFC1, dest, tmp); emit_fg(as, st == IRT_FLOAT ? MIPSI_TRUNC_W_S : MIPSI_TRUNC_W_D, tmp, left); } } } else { Reg dest = ra_dest(as, ir, RSET_GPR); if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ Reg left = ra_alloc1(as, ir->op1, RSET_GPR); lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); if ((ir->op2 & IRCONV_SEXT)) { if ((as->flags & JIT_F_MIPS32R2)) { emit_dst(as, st == IRT_I8 ? MIPSI_SEB : MIPSI_SEH, dest, 0, left); } else { uint32_t shift = st == IRT_I8 ? 24 : 16; emit_dta(as, MIPSI_SRA, dest, dest, shift); emit_dta(as, MIPSI_SLL, dest, left, shift); } } else { emit_tsi(as, MIPSI_ANDI, dest, left, (int32_t)(st == IRT_U8 ? 0xff : 0xffff)); } } else { /* 32/64 bit integer conversions. */ /* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */ ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ } } } #if LJ_HASFFI static void asm_conv64(ASMState *as, IRIns *ir) { IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); IRCallID id; const CCallInfo *ci; IRRef args[2]; args[LJ_BE?0:1] = ir->op1; args[LJ_BE?1:0] = (ir-1)->op1; if (st == IRT_NUM || st == IRT_FLOAT) { id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); ir--; } else { id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); } ci = &lj_ir_callinfo[id]; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } #endif static void asm_strto(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; IRRef args[2]; RegSet drop = RSET_SCRATCH; if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */ ra_evictset(as, drop); asm_guard(as, MIPSI_BEQ, RID_RET, RID_ZERO); /* Test return status. */ args[0] = ir->op1; /* GCstr *str */ args[1] = ASMREF_TMP1; /* TValue *n */ asm_gencall(as, ci, args); /* Store the result to the spill slot or temp slots. */ emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_SP, sps_scale(ir->s)); } /* Get pointer to TValue. */ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) { IRIns *ir = IR(ref); if (irt_isnum(ir->t)) { if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ ra_allockreg(as, i32ptr(ir_knum(ir)), dest); else /* Otherwise force a spill and use the spill slot. */ emit_tsi(as, MIPSI_ADDIU, dest, RID_SP, ra_spill(as, ir)); } else { /* Otherwise use g->tmptv to hold the TValue. */ RegSet allow = rset_exclude(RSET_GPR, dest); Reg type; emit_tsi(as, MIPSI_ADDIU, dest, RID_JGL, offsetof(global_State, tmptv)-32768); if (!irt_ispri(ir->t)) { Reg src = ra_alloc1(as, ref, allow); emit_setgl(as, src, tmptv.gcr); } type = ra_allock(as, irt_toitype(ir->t), allow); emit_setgl(as, type, tmptv.it); } } static void asm_tostr(ASMState *as, IRIns *ir) { IRRef args[2]; args[0] = ASMREF_L; as->gcsteps++; if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; args[1] = ASMREF_TMP1; /* const lua_Number * */ asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); } else { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; args[1] = ir->op1; /* int32_t k */ asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); } } /* -- Memory references --------------------------------------------------- */ static void asm_aref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg idx, base; if (irref_isk(ir->op2)) { IRRef tab = IR(ir->op1)->op1; int32_t ofs = asm_fuseabase(as, tab); IRRef refa = ofs ? tab : ir->op1; ofs += 8*IR(ir->op2)->i; if (checki16(ofs)) { base = ra_alloc1(as, refa, RSET_GPR); emit_tsi(as, MIPSI_ADDIU, dest, base, ofs); return; } } base = ra_alloc1(as, ir->op1, RSET_GPR); idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); emit_dst(as, MIPSI_ADDU, dest, RID_TMP, base); emit_dta(as, MIPSI_SLL, RID_TMP, idx, 3); } /* Inlined hash lookup. Specialized for key type and for const keys. ** The equivalent C code is: ** Node *n = hashkey(t, key); ** do { ** if (lj_obj_equal(&n->key, key)) return &n->val; ** } while ((n = nextnode(n))); ** return niltv(L); */ static void asm_href(ASMState *as, IRIns *ir) { RegSet allow = RSET_GPR; int destused = ra_used(ir); Reg dest = ra_dest(as, ir, allow); Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); Reg key = RID_NONE, type = RID_NONE, tmpnum = RID_NONE, tmp1 = RID_TMP, tmp2; IRRef refkey = ir->op2; IRIns *irkey = IR(refkey); IRType1 kt = irkey->t; uint32_t khash; MCLabel l_end, l_loop, l_next; rset_clear(allow, tab); if (irt_isnum(kt)) { key = ra_alloc1(as, refkey, RSET_FPR); tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key)); } else if (!irt_ispri(kt)) { key = ra_alloc1(as, refkey, allow); rset_clear(allow, key); type = ra_allock(as, irt_toitype(irkey->t), allow); rset_clear(allow, type); } tmp2 = ra_scratch(as, allow); rset_clear(allow, tmp2); /* Key not found in chain: load niltv. */ l_end = emit_label(as); if (destused) emit_loada(as, dest, niltvg(J2G(as->J))); else *--as->mcp = MIPSI_NOP; /* Follow hash chain until the end. */ emit_move(as, dest, tmp1); l_loop = --as->mcp; emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, next)); l_next = emit_label(as); /* Type and value comparison. */ if (irt_isnum(kt)) { emit_branch(as, MIPSI_BC1T, 0, 0, l_end); emit_fgh(as, MIPSI_C_EQ_D, 0, tmpnum, key); emit_tg(as, MIPSI_MFC1, tmp1, key+1); emit_branch(as, MIPSI_BEQ, tmp1, RID_ZERO, l_next); emit_tsi(as, MIPSI_SLTIU, tmp1, tmp1, (int32_t)LJ_TISNUM); emit_hsi(as, MIPSI_LDC1, tmpnum, dest, (int32_t)offsetof(Node, key.n)); } else { if (irt_ispri(kt)) { emit_branch(as, MIPSI_BEQ, tmp1, type, l_end); } else { emit_branch(as, MIPSI_BEQ, tmp2, key, l_end); emit_tsi(as, MIPSI_LW, tmp2, dest, (int32_t)offsetof(Node, key.gcr)); emit_branch(as, MIPSI_BNE, tmp1, type, l_next); } } emit_tsi(as, MIPSI_LW, tmp1, dest, (int32_t)offsetof(Node, key.it)); *l_loop = MIPSI_BNE | MIPSF_S(tmp1) | ((as->mcp-l_loop-1) & 0xffffu); /* Load main position relative to tab->node into dest. */ khash = irref_isk(refkey) ? ir_khash(irkey) : 1; if (khash == 0) { emit_tsi(as, MIPSI_LW, dest, tab, (int32_t)offsetof(GCtab, node)); } else { Reg tmphash = tmp1; if (irref_isk(refkey)) tmphash = ra_allock(as, khash, allow); emit_dst(as, MIPSI_ADDU, dest, dest, tmp1); lua_assert(sizeof(Node) == 24); emit_dst(as, MIPSI_SUBU, tmp1, tmp2, tmp1); emit_dta(as, MIPSI_SLL, tmp1, tmp1, 3); emit_dta(as, MIPSI_SLL, tmp2, tmp1, 5); emit_dst(as, MIPSI_AND, tmp1, tmp2, tmphash); emit_tsi(as, MIPSI_LW, dest, tab, (int32_t)offsetof(GCtab, node)); emit_tsi(as, MIPSI_LW, tmp2, tab, (int32_t)offsetof(GCtab, hmask)); if (irref_isk(refkey)) { /* Nothing to do. */ } else if (irt_isstr(kt)) { emit_tsi(as, MIPSI_LW, tmp1, key, (int32_t)offsetof(GCstr, hash)); } else { /* Must match with hash*() in lj_tab.c. */ emit_dst(as, MIPSI_SUBU, tmp1, tmp1, tmp2); emit_rotr(as, tmp2, tmp2, dest, (-HASH_ROT3)&31); emit_dst(as, MIPSI_XOR, tmp1, tmp1, tmp2); emit_rotr(as, tmp1, tmp1, dest, (-HASH_ROT2-HASH_ROT1)&31); emit_dst(as, MIPSI_SUBU, tmp2, tmp2, dest); if (irt_isnum(kt)) { emit_dst(as, MIPSI_XOR, tmp2, tmp2, tmp1); if ((as->flags & JIT_F_MIPS32R2)) { emit_dta(as, MIPSI_ROTR, dest, tmp1, (-HASH_ROT1)&31); } else { emit_dst(as, MIPSI_OR, dest, dest, tmp1); emit_dta(as, MIPSI_SLL, tmp1, tmp1, HASH_ROT1); emit_dta(as, MIPSI_SRL, dest, tmp1, (-HASH_ROT1)&31); } emit_dst(as, MIPSI_ADDU, tmp1, tmp1, tmp1); emit_tg(as, MIPSI_MFC1, tmp2, key); emit_tg(as, MIPSI_MFC1, tmp1, key+1); } else { emit_dst(as, MIPSI_XOR, tmp2, key, tmp1); emit_rotr(as, dest, tmp1, tmp2, (-HASH_ROT1)&31); emit_dst(as, MIPSI_ADDU, tmp1, key, ra_allock(as, HASH_BIAS, allow)); } } } } static void asm_hrefk(ASMState *as, IRIns *ir) { IRIns *kslot = IR(ir->op2); IRIns *irkey = IR(kslot->op1); int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); int32_t kofs = ofs + (int32_t)offsetof(Node, key); Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; Reg node = ra_alloc1(as, ir->op1, RSET_GPR); Reg key = RID_NONE, type = RID_TMP, idx = node; RegSet allow = rset_exclude(RSET_GPR, node); int32_t lo, hi; lua_assert(ofs % sizeof(Node) == 0); if (ofs > 32736) { idx = dest; rset_clear(allow, dest); kofs = (int32_t)offsetof(Node, key); } else if (ra_hasreg(dest)) { emit_tsi(as, MIPSI_ADDIU, dest, node, ofs); } if (!irt_ispri(irkey->t)) { key = ra_scratch(as, allow); rset_clear(allow, key); } if (irt_isnum(irkey->t)) { lo = (int32_t)ir_knum(irkey)->u32.lo; hi = (int32_t)ir_knum(irkey)->u32.hi; } else { lo = irkey->i; hi = irt_toitype(irkey->t); if (!ra_hasreg(key)) goto nolo; } asm_guard(as, MIPSI_BNE, key, lo ? ra_allock(as, lo, allow) : RID_ZERO); nolo: asm_guard(as, MIPSI_BNE, type, hi ? ra_allock(as, hi, allow) : RID_ZERO); if (ra_hasreg(key)) emit_tsi(as, MIPSI_LW, key, idx, kofs+(LJ_BE?4:0)); emit_tsi(as, MIPSI_LW, type, idx, kofs+(LJ_BE?0:4)); if (ofs > 32736) emit_tsi(as, MIPSI_ADDU, dest, node, ra_allock(as, ofs, allow)); } static void asm_newref(ASMState *as, IRIns *ir) { if (ir->r != RID_SINK) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; IRRef args[3]; args[0] = ASMREF_L; /* lua_State *L */ args[1] = ir->op1; /* GCtab *t */ args[2] = ASMREF_TMP1; /* cTValue *key */ asm_setupresult(as, ir, ci); /* TValue * */ asm_gencall(as, ci, args); asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); } } static void asm_uref(ASMState *as, IRIns *ir) { /* NYI: Check that UREFO is still open and not aliasing a slot. */ Reg dest = ra_dest(as, ir, RSET_GPR); if (irref_isk(ir->op1)) { GCfunc *fn = ir_kfunc(IR(ir->op1)); MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; emit_lsptr(as, MIPSI_LW, dest, v, RSET_GPR); } else { Reg uv = ra_scratch(as, RSET_GPR); Reg func = ra_alloc1(as, ir->op1, RSET_GPR); if (ir->o == IR_UREFC) { asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO); emit_tsi(as, MIPSI_ADDIU, dest, uv, (int32_t)offsetof(GCupval, tv)); emit_tsi(as, MIPSI_LBU, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); } else { emit_tsi(as, MIPSI_LW, dest, uv, (int32_t)offsetof(GCupval, v)); } emit_tsi(as, MIPSI_LW, uv, func, (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); } } static void asm_fref(ASMState *as, IRIns *ir) { UNUSED(as); UNUSED(ir); lua_assert(!ra_used(ir)); } static void asm_strref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); IRRef ref = ir->op2, refk = ir->op1; int32_t ofs = (int32_t)sizeof(GCstr); Reg r; if (irref_isk(ref)) { IRRef tmp = refk; refk = ref; ref = tmp; } else if (!irref_isk(refk)) { Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); IRIns *irr = IR(ir->op2); if (ra_hasreg(irr->r)) { ra_noweak(as, irr->r); right = irr->r; } else if (mayfuse(as, irr->op2) && irr->o == IR_ADD && irref_isk(irr->op2) && checki16(ofs + IR(irr->op2)->i)) { ofs += IR(irr->op2)->i; right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); } else { right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); } emit_tsi(as, MIPSI_ADDIU, dest, dest, ofs); emit_dst(as, MIPSI_ADDU, dest, left, right); return; } r = ra_alloc1(as, ref, RSET_GPR); ofs += IR(refk)->i; if (checki16(ofs)) emit_tsi(as, MIPSI_ADDIU, dest, r, ofs); else emit_dst(as, MIPSI_ADDU, dest, r, ra_allock(as, ofs, rset_exclude(RSET_GPR, r))); } /* -- Loads and stores ---------------------------------------------------- */ static MIPSIns asm_fxloadins(IRIns *ir) { switch (irt_type(ir->t)) { case IRT_I8: return MIPSI_LB; case IRT_U8: return MIPSI_LBU; case IRT_I16: return MIPSI_LH; case IRT_U16: return MIPSI_LHU; case IRT_NUM: return MIPSI_LDC1; case IRT_FLOAT: return MIPSI_LWC1; default: return MIPSI_LW; } } static MIPSIns asm_fxstoreins(IRIns *ir) { switch (irt_type(ir->t)) { case IRT_I8: case IRT_U8: return MIPSI_SB; case IRT_I16: case IRT_U16: return MIPSI_SH; case IRT_NUM: return MIPSI_SDC1; case IRT_FLOAT: return MIPSI_SWC1; default: return MIPSI_SW; } } static void asm_fload(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); MIPSIns mi = asm_fxloadins(ir); int32_t ofs; if (ir->op2 == IRFL_TAB_ARRAY) { ofs = asm_fuseabase(as, ir->op1); if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ emit_tsi(as, MIPSI_ADDIU, dest, idx, ofs); return; } } ofs = field_ofs[ir->op2]; lua_assert(!irt_isfp(ir->t)); emit_tsi(as, mi, dest, idx, ofs); } static void asm_fstore(ASMState *as, IRIns *ir) { if (ir->r != RID_SINK) { Reg src = ra_alloc1z(as, ir->op2, RSET_GPR); IRIns *irf = IR(ir->op1); Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); int32_t ofs = field_ofs[irf->op2]; MIPSIns mi = asm_fxstoreins(ir); lua_assert(!irt_isfp(ir->t)); emit_tsi(as, mi, src, idx, ofs); } } static void asm_xload(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); } static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) { if (ir->r != RID_SINK) { Reg src = ra_alloc1z(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, rset_exclude(RSET_GPR, src), ofs); } } static void asm_ahuvload(ASMState *as, IRIns *ir) { IRType1 t = ir->t; Reg dest = RID_NONE, type = RID_TMP, idx; RegSet allow = RSET_GPR; int32_t ofs = 0; if (ra_used(ir)) { lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); rset_clear(allow, dest); } idx = asm_fuseahuref(as, ir->op1, &ofs, allow); rset_clear(allow, idx); if (irt_isnum(t)) { asm_guard(as, MIPSI_BEQ, type, RID_ZERO); emit_tsi(as, MIPSI_SLTIU, type, type, (int32_t)LJ_TISNUM); if (ra_hasreg(dest)) emit_hsi(as, MIPSI_LDC1, dest, idx, ofs); } else { asm_guard(as, MIPSI_BNE, type, ra_allock(as, irt_toitype(t), allow)); if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, idx, ofs+(LJ_BE?4:0)); } emit_tsi(as, MIPSI_LW, type, idx, ofs+(LJ_BE?0:4)); } static void asm_ahustore(ASMState *as, IRIns *ir) { RegSet allow = RSET_GPR; Reg idx, src = RID_NONE, type = RID_NONE; int32_t ofs = 0; if (ir->r == RID_SINK) return; if (irt_isnum(ir->t)) { src = ra_alloc1(as, ir->op2, RSET_FPR); } else { if (!irt_ispri(ir->t)) { src = ra_alloc1(as, ir->op2, allow); rset_clear(allow, src); } type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); rset_clear(allow, type); } idx = asm_fuseahuref(as, ir->op1, &ofs, allow); if (irt_isnum(ir->t)) { emit_hsi(as, MIPSI_SDC1, src, idx, ofs); } else { if (ra_hasreg(src)) emit_tsi(as, MIPSI_SW, src, idx, ofs+(LJ_BE?4:0)); emit_tsi(as, MIPSI_SW, type, idx, ofs+(LJ_BE?0:4)); } } static void asm_sload(ASMState *as, IRIns *ir) { int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); IRType1 t = ir->t; Reg dest = RID_NONE, type = RID_NONE, base; RegSet allow = RSET_GPR; lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); lua_assert(!irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { dest = ra_scratch(as, RSET_FPR); asm_tointg(as, ir, dest); t.irt = IRT_NUM; /* Continue with a regular number type check. */ } else if (ra_used(ir)) { lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); rset_clear(allow, dest); base = ra_alloc1(as, REF_BASE, allow); rset_clear(allow, base); if ((ir->op2 & IRSLOAD_CONVERT)) { if (irt_isint(t)) { Reg tmp = ra_scratch(as, RSET_FPR); emit_tg(as, MIPSI_MFC1, dest, tmp); emit_fg(as, MIPSI_CVT_W_D, tmp, tmp); dest = tmp; t.irt = IRT_NUM; /* Check for original type. */ } else { Reg tmp = ra_scratch(as, RSET_GPR); emit_fg(as, MIPSI_CVT_D_W, dest, dest); emit_tg(as, MIPSI_MTC1, tmp, dest); dest = tmp; t.irt = IRT_INT; /* Check for original type. */ } } goto dotypecheck; } base = ra_alloc1(as, REF_BASE, allow); rset_clear(allow, base); dotypecheck: if (irt_isnum(t)) { if ((ir->op2 & IRSLOAD_TYPECHECK)) { asm_guard(as, MIPSI_BEQ, RID_TMP, RID_ZERO); emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)LJ_TISNUM); type = RID_TMP; } if (ra_hasreg(dest)) emit_hsi(as, MIPSI_LDC1, dest, base, ofs); } else { if ((ir->op2 & IRSLOAD_TYPECHECK)) { Reg ktype = ra_allock(as, irt_toitype(t), allow); asm_guard(as, MIPSI_BNE, RID_TMP, ktype); type = RID_TMP; } if (ra_hasreg(dest)) emit_tsi(as, MIPSI_LW, dest, base, ofs ^ (LJ_BE?4:0)); } if (ra_hasreg(type)) emit_tsi(as, MIPSI_LW, type, base, ofs ^ (LJ_BE?0:4)); } /* -- Allocations --------------------------------------------------------- */ #if LJ_HASFFI static void asm_cnew(ASMState *as, IRIns *ir) { CTState *cts = ctype_ctsG(J2G(as->J)); CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; IRRef args[2]; RegSet allow = (RSET_GPR & ~RSET_SCRATCH); RegSet drop = RSET_SCRATCH; lua_assert(sz != CTSIZE_INVALID); args[0] = ASMREF_L; /* lua_State *L */ args[1] = ASMREF_TMP1; /* MSize size */ as->gcsteps++; if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ ra_evictset(as, drop); if (ra_used(ir)) ra_destreg(as, ir, RID_RET); /* GCcdata * */ /* Initialize immutable cdata object. */ if (ir->o == IR_CNEWI) { int32_t ofs = sizeof(GCcdata); lua_assert(sz == 4 || sz == 8); if (sz == 8) { ofs += 4; lua_assert((ir+1)->o == IR_HIOP); if (LJ_LE) ir++; } for (;;) { Reg r = ra_alloc1z(as, ir->op2, allow); emit_tsi(as, MIPSI_SW, r, RID_RET, ofs); rset_clear(allow, r); if (ofs == sizeof(GCcdata)) break; ofs -= 4; if (LJ_BE) ir++; else ir--; } } /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ emit_tsi(as, MIPSI_SB, RID_RET+1, RID_RET, offsetof(GCcdata, gct)); emit_tsi(as, MIPSI_SH, RID_TMP, RID_RET, offsetof(GCcdata, ctypeid)); emit_ti(as, MIPSI_LI, RID_RET+1, ~LJ_TCDATA); emit_ti(as, MIPSI_LI, RID_TMP, ctypeid); /* Lower 16 bit used. Sign-ext ok. */ asm_gencall(as, ci, args); ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), ra_releasetmp(as, ASMREF_TMP1)); } #else #define asm_cnew(as, ir) ((void)0) #endif /* -- Write barriers ------------------------------------------------------ */ static void asm_tbar(ASMState *as, IRIns *ir) { Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab)); Reg link = RID_TMP; MCLabel l_end = emit_label(as); emit_tsi(as, MIPSI_SW, link, tab, (int32_t)offsetof(GCtab, gclist)); emit_tsi(as, MIPSI_SB, mark, tab, (int32_t)offsetof(GCtab, marked)); emit_setgl(as, tab, gc.grayagain); emit_getgl(as, link, gc.grayagain); emit_dst(as, MIPSI_XOR, mark, mark, RID_TMP); /* Clear black bit. */ emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); emit_tsi(as, MIPSI_ANDI, RID_TMP, mark, LJ_GC_BLACK); emit_tsi(as, MIPSI_LBU, mark, tab, (int32_t)offsetof(GCtab, marked)); } static void asm_obar(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; IRRef args[2]; MCLabel l_end; Reg obj, val, tmp; /* No need for other object barriers (yet). */ lua_assert(IR(ir->op1)->o == IR_UREFC); ra_evictset(as, RSET_SCRATCH); l_end = emit_label(as); args[0] = ASMREF_TMP1; /* global_State *g */ args[1] = ir->op1; /* TValue *tv */ asm_gencall(as, ci, args); emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); obj = IR(ir->op1)->r; tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); emit_tsi(as, MIPSI_ANDI, tmp, tmp, LJ_GC_BLACK); emit_branch(as, MIPSI_BEQ, RID_TMP, RID_ZERO, l_end); emit_tsi(as, MIPSI_ANDI, RID_TMP, RID_TMP, LJ_GC_WHITES); val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); emit_tsi(as, MIPSI_LBU, tmp, obj, (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); emit_tsi(as, MIPSI_LBU, RID_TMP, val, (int32_t)offsetof(GChead, marked)); } /* -- Arithmetic and logic operations ------------------------------------- */ static void asm_fparith(ASMState *as, IRIns *ir, MIPSIns mi) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg right, left = ra_alloc2(as, ir, RSET_FPR); right = (left >> 8); left &= 255; emit_fgh(as, mi, dest, left, right); } static void asm_fpunary(ASMState *as, IRIns *ir, MIPSIns mi) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); emit_fg(as, mi, dest, left); } static int asm_fpjoin_pow(ASMState *as, IRIns *ir) { IRIns *irp = IR(ir->op1); if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { IRIns *irpp = IR(irp->op1); if (irpp == ir-2 && irpp->o == IR_FPMATH && irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; IRRef args[2]; args[0] = irpp->op1; args[1] = irp->op2; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); return 1; } } return 0; } static void asm_add(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) { asm_fparith(as, ir, MIPSI_ADD_D); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (checki16(k)) { emit_tsi(as, MIPSI_ADDIU, dest, left, k); return; } } right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_dst(as, MIPSI_ADDU, dest, left, right); } } static void asm_sub(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) { asm_fparith(as, ir, MIPSI_SUB_D); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; emit_dst(as, MIPSI_SUBU, dest, left, right); } } static void asm_mul(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) { asm_fparith(as, ir, MIPSI_MUL_D); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; emit_dst(as, MIPSI_MUL, dest, left, right); } } static void asm_neg(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) { asm_fpunary(as, ir, MIPSI_NEG_D); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); } } static void asm_arithov(ASMState *as, IRIns *ir) { Reg right, left, tmp, dest = ra_dest(as, ir, RSET_GPR); if (irref_isk(ir->op2)) { int k = IR(ir->op2)->i; if (ir->o == IR_SUBOV) k = -k; if (checki16(k)) { /* (dest < left) == (k >= 0 ? 1 : 0) */ left = ra_alloc1(as, ir->op1, RSET_GPR); asm_guard(as, k >= 0 ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); emit_dst(as, MIPSI_SLT, RID_TMP, dest, dest == left ? RID_TMP : left); emit_tsi(as, MIPSI_ADDIU, dest, left, k); if (dest == left) emit_move(as, RID_TMP, left); return; } } left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; tmp = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_GPR, left), right), dest)); asm_guard(as, MIPSI_BLTZ, RID_TMP, 0); emit_dst(as, MIPSI_AND, RID_TMP, RID_TMP, tmp); if (ir->o == IR_ADDOV) { /* ((dest^left) & (dest^right)) < 0 */ emit_dst(as, MIPSI_XOR, RID_TMP, dest, dest == right ? RID_TMP : right); } else { /* ((dest^left) & (dest^~right)) < 0 */ emit_dst(as, MIPSI_XOR, RID_TMP, RID_TMP, dest); emit_dst(as, MIPSI_NOR, RID_TMP, dest == right ? RID_TMP : right, RID_ZERO); } emit_dst(as, MIPSI_XOR, tmp, dest, dest == left ? RID_TMP : left); emit_dst(as, ir->o == IR_ADDOV ? MIPSI_ADDU : MIPSI_SUBU, dest, left, right); if (dest == left || dest == right) emit_move(as, RID_TMP, dest == left ? left : right); } static void asm_mulov(ASMState *as, IRIns *ir) { #if LJ_DUALNUM #error "NYI: MULOV" #else UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused in single-number mode. */ #endif } #if LJ_HASFFI static void asm_add64(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (k == 0) { emit_dst(as, MIPSI_ADDU, dest, left, RID_TMP); goto loarith; } else if (checki16(k)) { emit_dst(as, MIPSI_ADDU, dest, dest, RID_TMP); emit_tsi(as, MIPSI_ADDIU, dest, left, k); goto loarith; } } emit_dst(as, MIPSI_ADDU, dest, dest, RID_TMP); right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_dst(as, MIPSI_ADDU, dest, left, right); loarith: ir--; dest = ra_dest(as, ir, RSET_GPR); left = ra_alloc1(as, ir->op1, RSET_GPR); if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (k == 0) { if (dest != left) emit_move(as, dest, left); return; } else if (checki16(k)) { if (dest == left) { Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, left)); emit_move(as, dest, tmp); dest = tmp; } emit_dst(as, MIPSI_SLTU, RID_TMP, dest, left); emit_tsi(as, MIPSI_ADDIU, dest, left, k); return; } } right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); if (dest == left && dest == right) { Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); emit_move(as, dest, tmp); dest = tmp; } emit_dst(as, MIPSI_SLTU, RID_TMP, dest, dest == left ? right : left); emit_dst(as, MIPSI_ADDU, dest, left, right); } static void asm_sub64(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; emit_dst(as, MIPSI_SUBU, dest, dest, RID_TMP); emit_dst(as, MIPSI_SUBU, dest, left, right); ir--; dest = ra_dest(as, ir, RSET_GPR); left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; if (dest == left) { Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); emit_move(as, dest, tmp); dest = tmp; } emit_dst(as, MIPSI_SLTU, RID_TMP, left, dest); emit_dst(as, MIPSI_SUBU, dest, left, right); } static void asm_neg64(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, RSET_GPR); emit_dst(as, MIPSI_SUBU, dest, dest, RID_TMP); emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); ir--; dest = ra_dest(as, ir, RSET_GPR); left = ra_alloc1(as, ir->op1, RSET_GPR); emit_dst(as, MIPSI_SLTU, RID_TMP, RID_ZERO, dest); emit_dst(as, MIPSI_SUBU, dest, RID_ZERO, left); } #endif static void asm_bitnot(ASMState *as, IRIns *ir) { Reg left, right, dest = ra_dest(as, ir, RSET_GPR); IRIns *irl = IR(ir->op1); if (mayfuse(as, ir->op1) && irl->o == IR_BOR) { left = ra_alloc2(as, irl, RSET_GPR); right = (left >> 8); left &= 255; } else { left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); right = RID_ZERO; } emit_dst(as, MIPSI_NOR, dest, left, right); } static void asm_bitswap(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, RSET_GPR); if ((as->flags & JIT_F_MIPS32R2)) { emit_dta(as, MIPSI_ROTR, dest, RID_TMP, 16); emit_dst(as, MIPSI_WSBH, RID_TMP, 0, left); } else { Reg tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), dest)); emit_dst(as, MIPSI_OR, dest, dest, tmp); emit_dst(as, MIPSI_OR, dest, dest, RID_TMP); emit_tsi(as, MIPSI_ANDI, dest, dest, 0xff00); emit_dta(as, MIPSI_SLL, RID_TMP, RID_TMP, 8); emit_dta(as, MIPSI_SRL, dest, left, 8); emit_tsi(as, MIPSI_ANDI, RID_TMP, left, 0xff00); emit_dst(as, MIPSI_OR, tmp, tmp, RID_TMP); emit_dta(as, MIPSI_SRL, tmp, left, 24); emit_dta(as, MIPSI_SLL, RID_TMP, left, 24); } } static void asm_bitop(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (checku16(k)) { emit_tsi(as, mik, dest, left, k); return; } } right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_dst(as, mi, dest, left, right); } static void asm_bitshift(ASMState *as, IRIns *ir, MIPSIns mi, MIPSIns mik) { Reg dest = ra_dest(as, ir, RSET_GPR); if (irref_isk(ir->op2)) { /* Constant shifts. */ uint32_t shift = (uint32_t)(IR(ir->op2)->i & 31); emit_dta(as, mik, dest, ra_hintalloc(as, ir->op1, dest, RSET_GPR), shift); } else { Reg right, left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; emit_dst(as, mi, dest, right, left); /* Shift amount is in rs. */ } } static void asm_bitror(ASMState *as, IRIns *ir) { if ((as->flags & JIT_F_MIPS32R2)) { asm_bitshift(as, ir, MIPSI_ROTRV, MIPSI_ROTR); } else { Reg dest = ra_dest(as, ir, RSET_GPR); if (irref_isk(ir->op2)) { /* Constant shifts. */ uint32_t shift = (uint32_t)(IR(ir->op2)->i & 31); Reg left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); emit_rotr(as, dest, left, RID_TMP, shift); } else { Reg right, left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; emit_dst(as, MIPSI_OR, dest, dest, RID_TMP); emit_dst(as, MIPSI_SRLV, dest, right, left); emit_dst(as, MIPSI_SLLV, RID_TMP, RID_TMP, left); emit_dst(as, MIPSI_SUBU, RID_TMP, ra_allock(as, 32, RSET_GPR), right); } } } static void asm_min_max(ASMState *as, IRIns *ir, int ismax) { if (irt_isnum(ir->t)) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg right, left = ra_alloc2(as, ir, RSET_FPR); right = (left >> 8); left &= 255; if (dest == left) { emit_fg(as, MIPSI_MOVT_D, dest, right); } else { emit_fg(as, MIPSI_MOVF_D, dest, left); if (dest != right) emit_fg(as, MIPSI_MOV_D, dest, right); } emit_fgh(as, MIPSI_C_OLT_D, 0, ismax ? left : right, ismax ? right : left); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; if (dest == left) { emit_dst(as, MIPSI_MOVN, dest, right, RID_TMP); } else { emit_dst(as, MIPSI_MOVZ, dest, left, RID_TMP); if (dest != right) emit_move(as, dest, right); } emit_dst(as, MIPSI_SLT, RID_TMP, ismax ? left : right, ismax ? right : left); } } /* -- Comparisons --------------------------------------------------------- */ static void asm_comp(ASMState *as, IRIns *ir) { /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */ IROp op = ir->o; if (irt_isnum(ir->t)) { Reg right, left = ra_alloc2(as, ir, RSET_FPR); right = (left >> 8); left &= 255; asm_guard(as, (op&1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0); emit_fgh(as, MIPSI_C_OLT_D + ((op&3) ^ ((op>>2)&1)), 0, left, right); } else { Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); if (op == IR_ABC) op = IR_UGT; if ((op&4) == 0 && irref_isk(ir->op2) && IR(ir->op2)->i == 0) { MIPSIns mi = (op&2) ? ((op&1) ? MIPSI_BLEZ : MIPSI_BGTZ) : ((op&1) ? MIPSI_BLTZ : MIPSI_BGEZ); asm_guard(as, mi, left, 0); } else { if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if ((op&2)) k++; if (checki16(k)) { asm_guard(as, (op&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); emit_tsi(as, (op&4) ? MIPSI_SLTIU : MIPSI_SLTI, RID_TMP, left, k); return; } } right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); asm_guard(as, ((op^(op>>1))&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); emit_dst(as, (op&4) ? MIPSI_SLTU : MIPSI_SLT, RID_TMP, (op&2) ? right : left, (op&2) ? left : right); } } } static void asm_compeq(ASMState *as, IRIns *ir) { Reg right, left = ra_alloc2(as, ir, irt_isnum(ir->t) ? RSET_FPR : RSET_GPR); right = (left >> 8); left &= 255; if (irt_isnum(ir->t)) { asm_guard(as, (ir->o & 1) ? MIPSI_BC1T : MIPSI_BC1F, 0, 0); emit_fgh(as, MIPSI_C_EQ_D, 0, left, right); } else { asm_guard(as, (ir->o & 1) ? MIPSI_BEQ : MIPSI_BNE, left, right); } } #if LJ_HASFFI /* 64 bit integer comparisons. */ static void asm_comp64(ASMState *as, IRIns *ir) { /* ORDER IR: LT GE LE GT ULT UGE ULE UGT. */ IROp op = (ir-1)->o; MCLabel l_end; Reg rightlo, leftlo, righthi, lefthi = ra_alloc2(as, ir, RSET_GPR); righthi = (lefthi >> 8); lefthi &= 255; leftlo = ra_alloc2(as, ir-1, rset_exclude(rset_exclude(RSET_GPR, lefthi), righthi)); rightlo = (leftlo >> 8); leftlo &= 255; asm_guard(as, ((op^(op>>1))&1) ? MIPSI_BNE : MIPSI_BEQ, RID_TMP, RID_ZERO); l_end = emit_label(as); if (lefthi != righthi) emit_dst(as, (op&4) ? MIPSI_SLTU : MIPSI_SLT, RID_TMP, (op&2) ? righthi : lefthi, (op&2) ? lefthi : righthi); emit_dst(as, MIPSI_SLTU, RID_TMP, (op&2) ? rightlo : leftlo, (op&2) ? leftlo : rightlo); if (lefthi != righthi) emit_branch(as, MIPSI_BEQ, lefthi, righthi, l_end); } static void asm_comp64eq(ASMState *as, IRIns *ir) { Reg tmp, right, left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; asm_guard(as, ((ir-1)->o & 1) ? MIPSI_BEQ : MIPSI_BNE, RID_TMP, RID_ZERO); tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, left), right)); emit_dst(as, MIPSI_OR, RID_TMP, RID_TMP, tmp); emit_dst(as, MIPSI_XOR, tmp, left, right); left = ra_alloc2(as, ir-1, RSET_GPR); right = (left >> 8); left &= 255; emit_dst(as, MIPSI_XOR, RID_TMP, left, right); } #endif /* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ /* Hiword op of a split 64 bit op. Previous op must be the loword op. */ static void asm_hiop(ASMState *as, IRIns *ir) { #if LJ_HASFFI /* HIOP is marked as a store because it needs its own DCE logic. */ int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ as->curins--; /* Always skip the CONV. */ if (usehi || uselo) asm_conv64(as, ir); return; } else if ((ir-1)->o < IR_EQ) { /* 64 bit integer comparisons. ORDER IR. */ as->curins--; /* Always skip the loword comparison. */ asm_comp64(as, ir); return; } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ as->curins--; /* Always skip the loword comparison. */ asm_comp64eq(as, ir); return; } else if ((ir-1)->o == IR_XSTORE) { as->curins--; /* Handle both stores here. */ if ((ir-1)->r != RID_SINK) { asm_xstore(as, ir, LJ_LE ? 4 : 0); asm_xstore(as, ir-1, LJ_LE ? 0 : 4); } return; } if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ switch ((ir-1)->o) { case IR_ADD: as->curins--; asm_add64(as, ir); break; case IR_SUB: as->curins--; asm_sub64(as, ir); break; case IR_NEG: as->curins--; asm_neg64(as, ir); break; case IR_CALLN: case IR_CALLXS: if (!uselo) ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ break; case IR_CNEWI: /* Nothing to do here. Handled by lo op itself. */ break; default: lua_assert(0); break; } #else UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused without FFI. */ #endif } /* -- Stack handling ------------------------------------------------------ */ /* Check Lua stack size for overflow. Use exit handler as fallback. */ static void asm_stack_check(ASMState *as, BCReg topslot, IRIns *irp, RegSet allow, ExitNo exitno) { /* Try to get an unused temp. register, otherwise spill/restore RID_RET*. */ Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE; ExitNo oldsnap = as->snapno; rset_clear(allow, pbase); tmp = allow ? rset_pickbot(allow) : (pbase == RID_RETHI ? RID_RETLO : RID_RETHI); as->snapno = exitno; asm_guard(as, MIPSI_BNE, RID_TMP, RID_ZERO); as->snapno = oldsnap; if (allow == RSET_EMPTY) /* Restore temp. register. */ emit_tsi(as, MIPSI_LW, tmp, RID_SP, 0); else ra_modified(as, tmp); emit_tsi(as, MIPSI_SLTIU, RID_TMP, RID_TMP, (int32_t)(8*topslot)); emit_dst(as, MIPSI_SUBU, RID_TMP, tmp, pbase); emit_tsi(as, MIPSI_LW, tmp, tmp, offsetof(lua_State, maxstack)); if (pbase == RID_TMP) emit_getgl(as, RID_TMP, jit_base); emit_getgl(as, tmp, jit_L); if (allow == RSET_EMPTY) /* Spill temp. register. */ emit_tsi(as, MIPSI_SW, tmp, RID_SP, 0); } /* Restore Lua stack from on-trace state. */ static void asm_stack_restore(ASMState *as, SnapShot *snap) { SnapEntry *map = &as->T->snapmap[snap->mapofs]; SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; MSize n, nent = snap->nent; /* Store the value of all modified slots to the Lua stack. */ for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; BCReg s = snap_slot(sn); int32_t ofs = 8*((int32_t)s-1); IRRef ref = snap_ref(sn); IRIns *ir = IR(ref); if ((sn & SNAP_NORESTORE)) continue; if (irt_isnum(ir->t)) { Reg src = ra_alloc1(as, ref, RSET_FPR); emit_hsi(as, MIPSI_SDC1, src, RID_BASE, ofs); } else { Reg type; RegSet allow = rset_exclude(RSET_GPR, RID_BASE); lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); if (!irt_ispri(ir->t)) { Reg src = ra_alloc1(as, ref, allow); rset_clear(allow, src); emit_tsi(as, MIPSI_SW, src, RID_BASE, ofs+(LJ_BE?4:0)); } if ((sn & (SNAP_CONT|SNAP_FRAME))) { if (s == 0) continue; /* Do not overwrite link to previous frame. */ type = ra_allock(as, (int32_t)(*flinks--), allow); } else { type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); } emit_tsi(as, MIPSI_SW, type, RID_BASE, ofs+(LJ_BE?0:4)); } checkmclim(as); } lua_assert(map + nent == flinks); } /* -- GC handling --------------------------------------------------------- */ /* Check GC threshold and do one or more GC steps. */ static void asm_gc_check(ASMState *as) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; IRRef args[2]; MCLabel l_end; Reg tmp; ra_evictset(as, RSET_SCRATCH); l_end = emit_label(as); /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ /* Assumes asm_snap_prep() already done. */ asm_guard(as, MIPSI_BNE, RID_RET, RID_ZERO); args[0] = ASMREF_TMP1; /* global_State *g */ args[1] = ASMREF_TMP2; /* MSize steps */ asm_gencall(as, ci, args); emit_tsi(as, MIPSI_ADDIU, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); tmp = ra_releasetmp(as, ASMREF_TMP2); emit_loadi(as, tmp, as->gcsteps); /* Jump around GC step if GC total < GC threshold. */ emit_branch(as, MIPSI_BNE, RID_TMP, RID_ZERO, l_end); emit_dst(as, MIPSI_SLTU, RID_TMP, RID_TMP, tmp); emit_getgl(as, tmp, gc.threshold); emit_getgl(as, RID_TMP, gc.total); as->gcsteps = 0; checkmclim(as); } /* -- Loop handling ------------------------------------------------------- */ /* Fixup the loop branch. */ static void asm_loop_fixup(ASMState *as) { MCode *p = as->mctop; MCode *target = as->mcp; p[-1] = MIPSI_NOP; if (as->loopinv) { /* Inverted loop branch? */ /* asm_guard already inverted the cond branch. Only patch the target. */ p[-3] |= ((target-p+2) & 0x0000ffffu); } else { p[-2] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); } } /* -- Head of trace ------------------------------------------------------- */ /* Coalesce BASE register for a root trace. */ static void asm_head_root_base(ASMState *as) { IRIns *ir = IR(REF_BASE); Reg r = ir->r; if (as->loopinv) as->mctop--; if (ra_hasreg(r)) { ra_free(as, r); if (rset_test(as->modset, r)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (r != RID_BASE) emit_move(as, r, RID_BASE); } } /* Coalesce BASE register for a side trace. */ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) { IRIns *ir = IR(REF_BASE); Reg r = ir->r; if (as->loopinv) as->mctop--; if (ra_hasreg(r)) { ra_free(as, r); if (rset_test(as->modset, r)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (irp->r == r) { rset_clear(allow, r); /* Mark same BASE register as coalesced. */ } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { rset_clear(allow, irp->r); emit_move(as, r, irp->r); /* Move from coalesced parent reg. */ } else { emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ } } return allow; } /* -- Tail of trace ------------------------------------------------------- */ /* Fixup the tail code. */ static void asm_tail_fixup(ASMState *as, TraceNo lnk) { MCode *target = lnk ? traceref(as->J,lnk)->mcode : (MCode *)lj_vm_exit_interp; int32_t spadj = as->T->spadjust; MCode *p = as->mctop-1; *p = spadj ? (MIPSI_ADDIU|MIPSF_T(RID_SP)|MIPSF_S(RID_SP)|spadj) : MIPSI_NOP; p[-1] = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); } /* Prepare tail of code. */ static void asm_tail_prep(ASMState *as) { as->mcp = as->mctop-2; /* Leave room for branch plus nop or stack adj. */ as->invmcp = as->loopref ? as->mcp : NULL; } /* -- Instruction dispatch ------------------------------------------------ */ /* Assemble a single instruction. */ static void asm_ir(ASMState *as, IRIns *ir) { switch ((IROp)ir->o) { /* Miscellaneous ops. */ case IR_LOOP: asm_loop(as); break; case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; case IR_USE: ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; case IR_PHI: asm_phi(as, ir); break; case IR_HIOP: asm_hiop(as, ir); break; case IR_GCSTEP: asm_gcstep(as, ir); break; /* Guarded assertions. */ case IR_EQ: case IR_NE: asm_compeq(as, ir); break; case IR_LT: case IR_GE: case IR_LE: case IR_GT: case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: case IR_ABC: asm_comp(as, ir); break; case IR_RETF: asm_retf(as, ir); break; /* Bit ops. */ case IR_BNOT: asm_bitnot(as, ir); break; case IR_BSWAP: asm_bitswap(as, ir); break; case IR_BAND: asm_bitop(as, ir, MIPSI_AND, MIPSI_ANDI); break; case IR_BOR: asm_bitop(as, ir, MIPSI_OR, MIPSI_ORI); break; case IR_BXOR: asm_bitop(as, ir, MIPSI_XOR, MIPSI_XORI); break; case IR_BSHL: asm_bitshift(as, ir, MIPSI_SLLV, MIPSI_SLL); break; case IR_BSHR: asm_bitshift(as, ir, MIPSI_SRLV, MIPSI_SRL); break; case IR_BSAR: asm_bitshift(as, ir, MIPSI_SRAV, MIPSI_SRA); break; case IR_BROL: lua_assert(0); break; case IR_BROR: asm_bitror(as, ir); break; /* Arithmetic ops. */ case IR_ADD: asm_add(as, ir); break; case IR_SUB: asm_sub(as, ir); break; case IR_MUL: asm_mul(as, ir); break; case IR_DIV: asm_fparith(as, ir, MIPSI_DIV_D); break; case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; case IR_NEG: asm_neg(as, ir); break; case IR_ABS: asm_fpunary(as, ir, MIPSI_ABS_D); break; case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; case IR_MIN: asm_min_max(as, ir, 0); break; case IR_MAX: asm_min_max(as, ir, 1); break; case IR_FPMATH: if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) break; if (ir->op2 <= IRFPM_TRUNC) asm_callround(as, ir, IRCALL_lj_vm_floor + ir->op2); else if (ir->op2 == IRFPM_SQRT) asm_fpunary(as, ir, MIPSI_SQRT_D); else asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); break; /* Overflow-checking arithmetic ops. */ case IR_ADDOV: asm_arithov(as, ir); break; case IR_SUBOV: asm_arithov(as, ir); break; case IR_MULOV: asm_mulov(as, ir); break; /* Memory references. */ case IR_AREF: asm_aref(as, ir); break; case IR_HREF: asm_href(as, ir); break; case IR_HREFK: asm_hrefk(as, ir); break; case IR_NEWREF: asm_newref(as, ir); break; case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; case IR_FREF: asm_fref(as, ir); break; case IR_STRREF: asm_strref(as, ir); break; /* Loads and stores. */ case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: asm_ahuvload(as, ir); break; case IR_FLOAD: asm_fload(as, ir); break; case IR_XLOAD: asm_xload(as, ir); break; case IR_SLOAD: asm_sload(as, ir); break; case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; case IR_FSTORE: asm_fstore(as, ir); break; case IR_XSTORE: asm_xstore(as, ir, 0); break; /* Allocations. */ case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; case IR_TNEW: asm_tnew(as, ir); break; case IR_TDUP: asm_tdup(as, ir); break; case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; /* Write barriers. */ case IR_TBAR: asm_tbar(as, ir); break; case IR_OBAR: asm_obar(as, ir); break; /* Type conversions. */ case IR_CONV: asm_conv(as, ir); break; case IR_TOBIT: asm_tobit(as, ir); break; case IR_TOSTR: asm_tostr(as, ir); break; case IR_STRTO: asm_strto(as, ir); break; /* Calls. */ case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; case IR_CALLXS: asm_callx(as, ir); break; case IR_CARG: break; default: setintV(&as->J->errinfo, ir->o); lj_trace_err_info(as->J, LJ_TRERR_NYIIR); break; } } /* -- Trace setup --------------------------------------------------------- */ /* Ensure there are enough stack slots for call arguments. */ static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) { IRRef args[CCI_NARGS_MAX]; uint32_t i, nargs = (int)CCI_NARGS(ci); int nslots = 4, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; asm_collectargs(as, ir, ci, args); for (i = 0; i < nargs; i++) { if (args[i] && irt_isfp(IR(args[i])->t) && nfpr > 0 && !(ci->flags & CCI_VARARG)) { nfpr--; ngpr -= irt_isnum(IR(args[i])->t) ? 2 : 1; } else if (args[i] && irt_isnum(IR(args[i])->t)) { nfpr = 0; ngpr = ngpr & ~1; if (ngpr > 0) ngpr -= 2; else nslots = (nslots+3) & ~1; } else { nfpr = 0; if (ngpr > 0) ngpr--; else nslots++; } } if (nslots > as->evenspill) /* Leave room for args in stack slots. */ as->evenspill = nslots; return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); } static void asm_setup_target(ASMState *as) { asm_sparejump_setup(as); asm_exitstub_setup(as); } /* -- Trace patching ------------------------------------------------------ */ /* Patch exit jumps of existing machine code to a new target. */ void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) { MCode *p = T->mcode; MCode *pe = (MCode *)((char *)p + T->szmcode); MCode *px = exitstub_trace_addr(T, exitno); MCode *cstart = NULL, *cstop = NULL; MCode *mcarea = lj_mcode_patch(J, p, 0); MCode exitload = MIPSI_LI | MIPSF_T(RID_TMP) | exitno; MCode tjump = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); for (p++; p < pe; p++) { if (*p == exitload) { /* Look for load of exit number. */ if (((p[-1] ^ (px-p)) & 0xffffu) == 0) { /* Look for exitstub branch. */ ptrdiff_t delta = target - p; if (((delta + 0x8000) >> 16) == 0) { /* Patch in-range branch. */ patchbranch: p[-1] = (p[-1] & 0xffff0000u) | (delta & 0xffffu); *p = MIPSI_NOP; /* Replace the load of the exit number. */ cstop = p; if (!cstart) cstart = p-1; } else { /* Branch out of range. Use spare jump slot in mcarea. */ int i; for (i = 2; i < 2+MIPS_SPAREJUMP*2; i += 2) { if (mcarea[i] == tjump) { delta = mcarea+i - p; goto patchbranch; } else if (mcarea[i] == MIPSI_NOP) { mcarea[i] = tjump; cstart = mcarea+i; delta = mcarea+i - p; goto patchbranch; } } /* Ignore jump slot overflow. Child trace is simply not attached. */ } } else if (p+1 == pe) { /* Patch NOP after code for inverted loop branch. Use of J is ok. */ lua_assert(p[1] == MIPSI_NOP); p[1] = tjump; *p = MIPSI_NOP; /* Replace the load of the exit number. */ cstop = p+2; if (!cstart) cstart = p+1; } } } if (cstart) lj_mcode_sync(cstart, cstop); lj_mcode_patch(J, mcarea, 1); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_asm_ppc.h ================================================ /* ** PPC IR assembler (SSA IR -> machine code). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* -- Register allocator extensions --------------------------------------- */ /* Allocate a register with a hint. */ static Reg ra_hintalloc(ASMState *as, IRRef ref, Reg hint, RegSet allow) { Reg r = IR(ref)->r; if (ra_noreg(r)) { if (!ra_hashint(r) && !iscrossref(as, ref)) ra_sethint(IR(ref)->r, hint); /* Propagate register hint. */ r = ra_allocref(as, ref, allow); } ra_noweak(as, r); return r; } /* Allocate two source registers for three-operand instructions. */ static Reg ra_alloc2(ASMState *as, IRIns *ir, RegSet allow) { IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); Reg left = irl->r, right = irr->r; if (ra_hasreg(left)) { ra_noweak(as, left); if (ra_noreg(right)) right = ra_allocref(as, ir->op2, rset_exclude(allow, left)); else ra_noweak(as, right); } else if (ra_hasreg(right)) { ra_noweak(as, right); left = ra_allocref(as, ir->op1, rset_exclude(allow, right)); } else if (ra_hashint(right)) { right = ra_allocref(as, ir->op2, allow); left = ra_alloc1(as, ir->op1, rset_exclude(allow, right)); } else { left = ra_allocref(as, ir->op1, allow); right = ra_alloc1(as, ir->op2, rset_exclude(allow, left)); } return left | (right << 8); } /* -- Guard handling ------------------------------------------------------ */ /* Setup exit stubs after the end of each trace. */ static void asm_exitstub_setup(ASMState *as, ExitNo nexits) { ExitNo i; MCode *mxp = as->mctop; /* 1: mflr r0; bl ->vm_exit_handler; li r0, traceno; bl <1; bl <1; ... */ for (i = nexits-1; (int32_t)i >= 0; i--) *--mxp = PPCI_BL|(((-3-i)&0x00ffffffu)<<2); *--mxp = PPCI_LI|PPCF_T(RID_TMP)|as->T->traceno; /* Read by exit handler. */ mxp--; *mxp = PPCI_BL|((((MCode *)(void *)lj_vm_exit_handler-mxp)&0x00ffffffu)<<2); *--mxp = PPCI_MFLR|PPCF_T(RID_TMP); as->mctop = mxp; } static MCode *asm_exitstub_addr(ASMState *as, ExitNo exitno) { /* Keep this in-sync with exitstub_trace_addr(). */ return as->mctop + exitno + 3; } /* Emit conditional branch to exit for guard. */ static void asm_guardcc(ASMState *as, PPCCC cc) { MCode *target = asm_exitstub_addr(as, as->snapno); MCode *p = as->mcp; if (LJ_UNLIKELY(p == as->invmcp)) { as->loopinv = 1; *p = PPCI_B | (((target-p) & 0x00ffffffu) << 2); emit_condbranch(as, PPCI_BC, cc^4, p); return; } emit_condbranch(as, PPCI_BC, cc, target); } /* -- Operand fusion ------------------------------------------------------ */ /* Limit linear search to this distance. Avoids O(n^2) behavior. */ #define CONFLICT_SEARCH_LIM 31 /* Check if there's no conflicting instruction between curins and ref. */ static int noconflict(ASMState *as, IRRef ref, IROp conflict) { IRIns *ir = as->ir; IRRef i = as->curins; if (i > ref + CONFLICT_SEARCH_LIM) return 0; /* Give up, ref is too far away. */ while (--i > ref) if (ir[i].o == conflict) return 0; /* Conflict found. */ return 1; /* Ok, no conflict. */ } /* Fuse the array base of colocated arrays. */ static int32_t asm_fuseabase(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); if (ir->o == IR_TNEW && ir->op1 <= LJ_MAX_COLOSIZE && !neverfuse(as) && noconflict(as, ref, IR_NEWREF)) return (int32_t)sizeof(GCtab); return 0; } /* Indicates load/store indexed is ok. */ #define AHUREF_LSX ((int32_t)0x80000000) /* Fuse array/hash/upvalue reference into register+offset operand. */ static Reg asm_fuseahuref(ASMState *as, IRRef ref, int32_t *ofsp, RegSet allow) { IRIns *ir = IR(ref); if (ra_noreg(ir->r)) { if (ir->o == IR_AREF) { if (mayfuse(as, ref)) { if (irref_isk(ir->op2)) { IRRef tab = IR(ir->op1)->op1; int32_t ofs = asm_fuseabase(as, tab); IRRef refa = ofs ? tab : ir->op1; ofs += 8*IR(ir->op2)->i; if (checki16(ofs)) { *ofsp = ofs; return ra_alloc1(as, refa, allow); } } if (*ofsp == AHUREF_LSX) { Reg base = ra_alloc1(as, ir->op1, allow); Reg idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); return base | (idx << 8); } } } else if (ir->o == IR_HREFK) { if (mayfuse(as, ref)) { int32_t ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); if (checki16(ofs)) { *ofsp = ofs; return ra_alloc1(as, ir->op1, allow); } } } else if (ir->o == IR_UREFC) { if (irref_isk(ir->op1)) { GCfunc *fn = ir_kfunc(IR(ir->op1)); int32_t ofs = i32ptr(&gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.tv); int32_t jgl = (intptr_t)J2G(as->J); if ((uint32_t)(ofs-jgl) < 65536) { *ofsp = ofs-jgl-32768; return RID_JGL; } else { *ofsp = (int16_t)ofs; return ra_allock(as, ofs-(int16_t)ofs, allow); } } } } *ofsp = 0; return ra_alloc1(as, ref, allow); } /* Fuse XLOAD/XSTORE reference into load/store operand. */ static void asm_fusexref(ASMState *as, PPCIns pi, Reg rt, IRRef ref, RegSet allow, int32_t ofs) { IRIns *ir = IR(ref); Reg base; if (ra_noreg(ir->r) && canfuse(as, ir)) { if (ir->o == IR_ADD) { int32_t ofs2; if (irref_isk(ir->op2) && (ofs2 = ofs + IR(ir->op2)->i, checki16(ofs2))) { ofs = ofs2; ref = ir->op1; } else if (ofs == 0) { Reg right, left = ra_alloc2(as, ir, allow); right = (left >> 8); left &= 255; emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right); return; } } else if (ir->o == IR_STRREF) { lua_assert(ofs == 0); ofs = (int32_t)sizeof(GCstr); if (irref_isk(ir->op2)) { ofs += IR(ir->op2)->i; ref = ir->op1; } else if (irref_isk(ir->op1)) { ofs += IR(ir->op1)->i; ref = ir->op2; } else { /* NYI: Fuse ADD with constant. */ Reg tmp, right, left = ra_alloc2(as, ir, allow); right = (left >> 8); left &= 255; tmp = ra_scratch(as, rset_exclude(rset_exclude(allow, left), right)); emit_fai(as, pi, rt, tmp, ofs); emit_tab(as, PPCI_ADD, tmp, left, right); return; } if (!checki16(ofs)) { Reg left = ra_alloc1(as, ref, allow); Reg right = ra_allock(as, ofs, rset_exclude(allow, left)); emit_fab(as, PPCI_LWZX | ((pi >> 20) & 0x780), rt, left, right); return; } } } base = ra_alloc1(as, ref, allow); emit_fai(as, pi, rt, base, ofs); } /* Fuse XLOAD/XSTORE reference into indexed-only load/store operand. */ static void asm_fusexrefx(ASMState *as, PPCIns pi, Reg rt, IRRef ref, RegSet allow) { IRIns *ira = IR(ref); Reg right, left; if (canfuse(as, ira) && ira->o == IR_ADD && ra_noreg(ira->r)) { left = ra_alloc2(as, ira, allow); right = (left >> 8); left &= 255; } else { right = ra_alloc1(as, ref, allow); left = RID_R0; } emit_tab(as, pi, rt, left, right); } /* Fuse to multiply-add/sub instruction. */ static int asm_fusemadd(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pir) { IRRef lref = ir->op1, rref = ir->op2; IRIns *irm; if (lref != rref && ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) && ra_noreg(irm->r)) || (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) && (rref = lref, pi = pir, ra_noreg(irm->r))))) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg add = ra_alloc1(as, rref, RSET_FPR); Reg right, left = ra_alloc2(as, irm, rset_exclude(RSET_FPR, add)); right = (left >> 8); left &= 255; emit_facb(as, pi, dest, left, right, add); return 1; } return 0; } /* -- Calls --------------------------------------------------------------- */ /* Generate a call to a C function. */ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) { uint32_t n, nargs = CCI_NARGS(ci); int32_t ofs = 8; Reg gpr = REGARG_FIRSTGPR, fpr = REGARG_FIRSTFPR; if ((void *)ci->func) emit_call(as, (void *)ci->func); for (n = 0; n < nargs; n++) { /* Setup args. */ IRRef ref = args[n]; if (ref) { IRIns *ir = IR(ref); if (irt_isfp(ir->t)) { if (fpr <= REGARG_LASTFPR) { lua_assert(rset_test(as->freeset, fpr)); /* Already evicted. */ ra_leftov(as, fpr, ref); fpr++; } else { Reg r = ra_alloc1(as, ref, RSET_FPR); if (irt_isnum(ir->t)) ofs = (ofs + 4) & ~4; emit_spstore(as, ir, r, ofs); ofs += irt_isnum(ir->t) ? 8 : 4; } } else { if (gpr <= REGARG_LASTGPR) { lua_assert(rset_test(as->freeset, gpr)); /* Already evicted. */ ra_leftov(as, gpr, ref); gpr++; } else { Reg r = ra_alloc1(as, ref, RSET_GPR); emit_spstore(as, ir, r, ofs); ofs += 4; } } } else { if (gpr <= REGARG_LASTGPR) gpr++; else ofs += 4; } } if ((ci->flags & CCI_VARARG)) /* Vararg calls need to know about FPR use. */ emit_tab(as, fpr == REGARG_FIRSTFPR ? PPCI_CRXOR : PPCI_CREQV, 6, 6, 6); } /* Setup result reg/sp for call. Evict scratch regs. */ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) { RegSet drop = RSET_SCRATCH; int hiop = ((ir+1)->o == IR_HIOP); if ((ci->flags & CCI_NOFPRCLOBBER)) drop &= ~RSET_FPR; if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ if (hiop && ra_hasreg((ir+1)->r)) rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ ra_evictset(as, drop); /* Evictions must be performed first. */ if (ra_used(ir)) { lua_assert(!irt_ispri(ir->t)); if (irt_isfp(ir->t)) { if ((ci->flags & CCI_CASTU64)) { /* Use spill slot or temp slots. */ int32_t ofs = ir->s ? sps_scale(ir->s) : SPOFS_TMP; Reg dest = ir->r; if (ra_hasreg(dest)) { ra_free(as, dest); ra_modified(as, dest); emit_fai(as, PPCI_LFD, dest, RID_SP, ofs); } emit_tai(as, PPCI_STW, RID_RETHI, RID_SP, ofs); emit_tai(as, PPCI_STW, RID_RETLO, RID_SP, ofs+4); } else { ra_destreg(as, ir, RID_FPRET); } } else if (hiop) { ra_destpair(as, ir); } else { ra_destreg(as, ir, RID_RET); } } } static void asm_call(ASMState *as, IRIns *ir) { IRRef args[CCI_NARGS_MAX]; const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; asm_collectargs(as, ir, ci, args); asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } static void asm_callx(ASMState *as, IRIns *ir) { IRRef args[CCI_NARGS_MAX]; CCallInfo ci; IRRef func; IRIns *irf; ci.flags = asm_callx_flags(as, ir); asm_collectargs(as, ir, &ci, args); asm_setupresult(as, ir, &ci); func = ir->op2; irf = IR(func); if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } if (irref_isk(func)) { /* Call to constant address. */ ci.func = (ASMFunction)(void *)(irf->i); } else { /* Need a non-argument register for indirect calls. */ RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1); Reg freg = ra_alloc1(as, func, allow); *--as->mcp = PPCI_BCTRL; *--as->mcp = PPCI_MTCTR | PPCF_T(freg); ci.func = (ASMFunction)(void *)0; } asm_gencall(as, &ci, args); } static void asm_callid(ASMState *as, IRIns *ir, IRCallID id) { const CCallInfo *ci = &lj_ir_callinfo[id]; IRRef args[2]; args[0] = ir->op1; args[1] = ir->op2; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } /* -- Returns ------------------------------------------------------------- */ /* Return to lower frame. Guard that it goes to the right spot. */ static void asm_retf(ASMState *as, IRIns *ir) { Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); void *pc = ir_kptr(IR(ir->op2)); int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); as->topslot -= (BCReg)delta; if ((int32_t)as->topslot < 0) as->topslot = 0; emit_setgl(as, base, jit_base); emit_addptr(as, base, -8*delta); asm_guardcc(as, CC_NE); emit_ab(as, PPCI_CMPW, RID_TMP, ra_allock(as, i32ptr(pc), rset_exclude(RSET_GPR, base))); emit_tai(as, PPCI_LWZ, RID_TMP, base, -8); } /* -- Type conversions ---------------------------------------------------- */ static void asm_tointg(ASMState *as, IRIns *ir, Reg left) { RegSet allow = RSET_FPR; Reg tmp = ra_scratch(as, rset_clear(allow, left)); Reg fbias = ra_scratch(as, rset_clear(allow, tmp)); Reg dest = ra_dest(as, ir, RSET_GPR); Reg hibias = ra_allock(as, 0x43300000, rset_exclude(RSET_GPR, dest)); asm_guardcc(as, CC_NE); emit_fab(as, PPCI_FCMPU, 0, tmp, left); emit_fab(as, PPCI_FSUB, tmp, tmp, fbias); emit_fai(as, PPCI_LFD, tmp, RID_SP, SPOFS_TMP); emit_tai(as, PPCI_STW, RID_TMP, RID_SP, SPOFS_TMPLO); emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); emit_asi(as, PPCI_XORIS, RID_TMP, dest, 0x8000); emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); emit_lsptr(as, PPCI_LFS, (fbias & 31), (void *)lj_ir_k64_find(as->J, U64x(59800004,59800000)), RSET_GPR); emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); emit_fb(as, PPCI_FCTIWZ, tmp, left); } static void asm_tobit(ASMState *as, IRIns *ir) { RegSet allow = RSET_FPR; Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, allow); Reg right = ra_alloc1(as, ir->op2, rset_clear(allow, left)); Reg tmp = ra_scratch(as, rset_clear(allow, right)); emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); emit_fab(as, PPCI_FADD, tmp, left, right); } static void asm_conv(ASMState *as, IRIns *ir) { IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); int stfp = (st == IRT_NUM || st == IRT_FLOAT); IRRef lref = ir->op1; lua_assert(irt_type(ir->t) != st); lua_assert(!(irt_isint64(ir->t) || (st == IRT_I64 || st == IRT_U64))); /* Handled by SPLIT. */ if (irt_isfp(ir->t)) { Reg dest = ra_dest(as, ir, RSET_FPR); if (stfp) { /* FP to FP conversion. */ if (st == IRT_NUM) /* double -> float conversion. */ emit_fb(as, PPCI_FRSP, dest, ra_alloc1(as, lref, RSET_FPR)); else /* float -> double conversion is a no-op on PPC. */ ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ } else { /* Integer to FP conversion. */ /* IRT_INT: Flip hibit, bias with 2^52, subtract 2^52+2^31. */ /* IRT_U32: Bias with 2^52, subtract 2^52. */ RegSet allow = RSET_GPR; Reg left = ra_alloc1(as, lref, allow); Reg hibias = ra_allock(as, 0x43300000, rset_clear(allow, left)); Reg fbias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); const float *kbias; if (irt_isfloat(ir->t)) emit_fb(as, PPCI_FRSP, dest, dest); emit_fab(as, PPCI_FSUB, dest, dest, fbias); emit_fai(as, PPCI_LFD, dest, RID_SP, SPOFS_TMP); kbias = (const float *)lj_ir_k64_find(as->J, U64x(59800004,59800000)); if (st == IRT_U32) kbias++; emit_lsptr(as, PPCI_LFS, (fbias & 31), (void *)kbias, rset_clear(allow, hibias)); emit_tai(as, PPCI_STW, st == IRT_U32 ? left : RID_TMP, RID_SP, SPOFS_TMPLO); emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); if (st != IRT_U32) emit_asi(as, PPCI_XORIS, RID_TMP, left, 0x8000); } } else if (stfp) { /* FP to integer conversion. */ if (irt_isguard(ir->t)) { /* Checked conversions are only supported from number to int. */ lua_assert(irt_isint(ir->t) && st == IRT_NUM); asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, lref, RSET_FPR); Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); if (irt_isu32(ir->t)) { /* Convert both x and x-2^31 to int and merge results. */ Reg tmpi = ra_scratch(as, rset_exclude(RSET_GPR, dest)); emit_asb(as, PPCI_OR, dest, dest, tmpi); /* Select with mask idiom. */ emit_asb(as, PPCI_AND, tmpi, tmpi, RID_TMP); emit_asb(as, PPCI_ANDC, dest, dest, RID_TMP); emit_tai(as, PPCI_LWZ, tmpi, RID_SP, SPOFS_TMPLO); /* tmp = (int)(x) */ emit_tai(as, PPCI_ADDIS, dest, dest, 0x8000); /* dest += 2^31 */ emit_asb(as, PPCI_SRAWI, RID_TMP, dest, 31); /* mask = -(dest < 0) */ emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); /* dest = (int)(x-2^31) */ emit_fb(as, PPCI_FCTIWZ, tmp, left); emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); emit_fb(as, PPCI_FCTIWZ, tmp, tmp); emit_fab(as, PPCI_FSUB, tmp, left, tmp); emit_lsptr(as, PPCI_LFS, (tmp & 31), (void *)lj_ir_k64_find(as->J, U64x(4f000000,00000000)), RSET_GPR); } else { emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); emit_fai(as, PPCI_STFD, tmp, RID_SP, SPOFS_TMP); emit_fb(as, PPCI_FCTIWZ, tmp, left); } } } else { Reg dest = ra_dest(as, ir, RSET_GPR); if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ Reg left = ra_alloc1(as, ir->op1, RSET_GPR); lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); if ((ir->op2 & IRCONV_SEXT)) emit_as(as, st == IRT_I8 ? PPCI_EXTSB : PPCI_EXTSH, dest, left); else emit_rot(as, PPCI_RLWINM, dest, left, 0, st == IRT_U8 ? 24 : 16, 31); } else { /* 32/64 bit integer conversions. */ /* Only need to handle 32/32 bit no-op (cast) on 32 bit archs. */ ra_leftov(as, dest, lref); /* Do nothing, but may need to move regs. */ } } } #if LJ_HASFFI static void asm_conv64(ASMState *as, IRIns *ir) { IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); IRCallID id; const CCallInfo *ci; IRRef args[2]; args[0] = ir->op1; args[1] = (ir-1)->op1; if (st == IRT_NUM || st == IRT_FLOAT) { id = IRCALL_fp64_d2l + ((st == IRT_FLOAT) ? 2 : 0) + (dt - IRT_I64); ir--; } else { id = IRCALL_fp64_l2d + ((dt == IRT_FLOAT) ? 2 : 0) + (st - IRT_I64); } ci = &lj_ir_callinfo[id]; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } #endif static void asm_strto(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; IRRef args[2]; int32_t ofs; RegSet drop = RSET_SCRATCH; if (ra_hasreg(ir->r)) rset_set(drop, ir->r); /* Spill dest reg (if any). */ ra_evictset(as, drop); asm_guardcc(as, CC_EQ); emit_ai(as, PPCI_CMPWI, RID_RET, 0); /* Test return status. */ args[0] = ir->op1; /* GCstr *str */ args[1] = ASMREF_TMP1; /* TValue *n */ asm_gencall(as, ci, args); /* Store the result to the spill slot or temp slots. */ ofs = ir->s ? sps_scale(ir->s) : SPOFS_TMP; emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_SP, ofs); } /* Get pointer to TValue. */ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref) { IRIns *ir = IR(ref); if (irt_isnum(ir->t)) { if (irref_isk(ref)) /* Use the number constant itself as a TValue. */ ra_allockreg(as, i32ptr(ir_knum(ir)), dest); else /* Otherwise force a spill and use the spill slot. */ emit_tai(as, PPCI_ADDI, dest, RID_SP, ra_spill(as, ir)); } else { /* Otherwise use g->tmptv to hold the TValue. */ RegSet allow = rset_exclude(RSET_GPR, dest); Reg type; emit_tai(as, PPCI_ADDI, dest, RID_JGL, offsetof(global_State, tmptv)-32768); if (!irt_ispri(ir->t)) { Reg src = ra_alloc1(as, ref, allow); emit_setgl(as, src, tmptv.gcr); } type = ra_allock(as, irt_toitype(ir->t), allow); emit_setgl(as, type, tmptv.it); } } static void asm_tostr(ASMState *as, IRIns *ir) { IRRef args[2]; args[0] = ASMREF_L; as->gcsteps++; if (irt_isnum(IR(ir->op1)->t) || (ir+1)->o == IR_HIOP) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; args[1] = ASMREF_TMP1; /* const lua_Number * */ asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1); } else { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; args[1] = ir->op1; /* int32_t k */ asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); } } /* -- Memory references --------------------------------------------------- */ static void asm_aref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg idx, base; if (irref_isk(ir->op2)) { IRRef tab = IR(ir->op1)->op1; int32_t ofs = asm_fuseabase(as, tab); IRRef refa = ofs ? tab : ir->op1; ofs += 8*IR(ir->op2)->i; if (checki16(ofs)) { base = ra_alloc1(as, refa, RSET_GPR); emit_tai(as, PPCI_ADDI, dest, base, ofs); return; } } base = ra_alloc1(as, ir->op1, RSET_GPR); idx = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, base)); emit_tab(as, PPCI_ADD, dest, RID_TMP, base); emit_slwi(as, RID_TMP, idx, 3); } /* Inlined hash lookup. Specialized for key type and for const keys. ** The equivalent C code is: ** Node *n = hashkey(t, key); ** do { ** if (lj_obj_equal(&n->key, key)) return &n->val; ** } while ((n = nextnode(n))); ** return niltv(L); */ static void asm_href(ASMState *as, IRIns *ir, IROp merge) { RegSet allow = RSET_GPR; int destused = ra_used(ir); Reg dest = ra_dest(as, ir, allow); Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); Reg key = RID_NONE, tmp1 = RID_TMP, tmp2; Reg tisnum = RID_NONE, tmpnum = RID_NONE; IRRef refkey = ir->op2; IRIns *irkey = IR(refkey); IRType1 kt = irkey->t; uint32_t khash; MCLabel l_end, l_loop, l_next; rset_clear(allow, tab); if (irt_isnum(kt)) { key = ra_alloc1(as, refkey, RSET_FPR); tmpnum = ra_scratch(as, rset_exclude(RSET_FPR, key)); tisnum = ra_allock(as, (int32_t)LJ_TISNUM, allow); rset_clear(allow, tisnum); } else if (!irt_ispri(kt)) { key = ra_alloc1(as, refkey, allow); rset_clear(allow, key); } tmp2 = ra_scratch(as, allow); rset_clear(allow, tmp2); /* Key not found in chain: jump to exit (if merged) or load niltv. */ l_end = emit_label(as); as->invmcp = NULL; if (merge == IR_NE) asm_guardcc(as, CC_EQ); else if (destused) emit_loada(as, dest, niltvg(J2G(as->J))); /* Follow hash chain until the end. */ l_loop = --as->mcp; emit_ai(as, PPCI_CMPWI, dest, 0); emit_tai(as, PPCI_LWZ, dest, dest, (int32_t)offsetof(Node, next)); l_next = emit_label(as); /* Type and value comparison. */ if (merge == IR_EQ) asm_guardcc(as, CC_EQ); else emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); if (irt_isnum(kt)) { emit_fab(as, PPCI_FCMPU, 0, tmpnum, key); emit_condbranch(as, PPCI_BC, CC_GE, l_next); emit_ab(as, PPCI_CMPLW, tmp1, tisnum); emit_fai(as, PPCI_LFD, tmpnum, dest, (int32_t)offsetof(Node, key.n)); } else { if (!irt_ispri(kt)) { emit_ab(as, PPCI_CMPW, tmp2, key); emit_condbranch(as, PPCI_BC, CC_NE, l_next); } emit_ai(as, PPCI_CMPWI, tmp1, irt_toitype(irkey->t)); if (!irt_ispri(kt)) emit_tai(as, PPCI_LWZ, tmp2, dest, (int32_t)offsetof(Node, key.gcr)); } emit_tai(as, PPCI_LWZ, tmp1, dest, (int32_t)offsetof(Node, key.it)); *l_loop = PPCI_BC | PPCF_Y | PPCF_CC(CC_NE) | (((char *)as->mcp-(char *)l_loop) & 0xffffu); /* Load main position relative to tab->node into dest. */ khash = irref_isk(refkey) ? ir_khash(irkey) : 1; if (khash == 0) { emit_tai(as, PPCI_LWZ, dest, tab, (int32_t)offsetof(GCtab, node)); } else { Reg tmphash = tmp1; if (irref_isk(refkey)) tmphash = ra_allock(as, khash, allow); emit_tab(as, PPCI_ADD, dest, dest, tmp1); emit_tai(as, PPCI_MULLI, tmp1, tmp1, sizeof(Node)); emit_asb(as, PPCI_AND, tmp1, tmp2, tmphash); emit_tai(as, PPCI_LWZ, dest, tab, (int32_t)offsetof(GCtab, node)); emit_tai(as, PPCI_LWZ, tmp2, tab, (int32_t)offsetof(GCtab, hmask)); if (irref_isk(refkey)) { /* Nothing to do. */ } else if (irt_isstr(kt)) { emit_tai(as, PPCI_LWZ, tmp1, key, (int32_t)offsetof(GCstr, hash)); } else { /* Must match with hash*() in lj_tab.c. */ emit_tab(as, PPCI_SUBF, tmp1, tmp2, tmp1); emit_rotlwi(as, tmp2, tmp2, HASH_ROT3); emit_asb(as, PPCI_XOR, tmp1, tmp1, tmp2); emit_rotlwi(as, tmp1, tmp1, (HASH_ROT2+HASH_ROT1)&31); emit_tab(as, PPCI_SUBF, tmp2, dest, tmp2); if (irt_isnum(kt)) { int32_t ofs = ra_spill(as, irkey); emit_asb(as, PPCI_XOR, tmp2, tmp2, tmp1); emit_rotlwi(as, dest, tmp1, HASH_ROT1); emit_tab(as, PPCI_ADD, tmp1, tmp1, tmp1); emit_tai(as, PPCI_LWZ, tmp2, RID_SP, ofs+4); emit_tai(as, PPCI_LWZ, tmp1, RID_SP, ofs); } else { emit_asb(as, PPCI_XOR, tmp2, key, tmp1); emit_rotlwi(as, dest, tmp1, HASH_ROT1); emit_tai(as, PPCI_ADDI, tmp1, tmp2, HASH_BIAS); emit_tai(as, PPCI_ADDIS, tmp2, key, (HASH_BIAS + 32768)>>16); } } } } static void asm_hrefk(ASMState *as, IRIns *ir) { IRIns *kslot = IR(ir->op2); IRIns *irkey = IR(kslot->op1); int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); int32_t kofs = ofs + (int32_t)offsetof(Node, key); Reg dest = (ra_used(ir)||ofs > 32736) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; Reg node = ra_alloc1(as, ir->op1, RSET_GPR); Reg key = RID_NONE, type = RID_TMP, idx = node; RegSet allow = rset_exclude(RSET_GPR, node); lua_assert(ofs % sizeof(Node) == 0); if (ofs > 32736) { idx = dest; rset_clear(allow, dest); kofs = (int32_t)offsetof(Node, key); } else if (ra_hasreg(dest)) { emit_tai(as, PPCI_ADDI, dest, node, ofs); } asm_guardcc(as, CC_NE); if (!irt_ispri(irkey->t)) { key = ra_scratch(as, allow); rset_clear(allow, key); } rset_clear(allow, type); if (irt_isnum(irkey->t)) { emit_cmpi(as, key, (int32_t)ir_knum(irkey)->u32.lo); asm_guardcc(as, CC_NE); emit_cmpi(as, type, (int32_t)ir_knum(irkey)->u32.hi); } else { if (ra_hasreg(key)) { emit_cmpi(as, key, irkey->i); /* May use RID_TMP, i.e. type. */ asm_guardcc(as, CC_NE); } emit_ai(as, PPCI_CMPWI, type, irt_toitype(irkey->t)); } if (ra_hasreg(key)) emit_tai(as, PPCI_LWZ, key, idx, kofs+4); emit_tai(as, PPCI_LWZ, type, idx, kofs); if (ofs > 32736) { emit_tai(as, PPCI_ADDIS, dest, dest, (ofs + 32768) >> 16); emit_tai(as, PPCI_ADDI, dest, node, ofs); } } static void asm_newref(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; IRRef args[3]; if (ir->r == RID_SINK) return; args[0] = ASMREF_L; /* lua_State *L */ args[1] = ir->op1; /* GCtab *t */ args[2] = ASMREF_TMP1; /* cTValue *key */ asm_setupresult(as, ir, ci); /* TValue * */ asm_gencall(as, ci, args); asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op2); } static void asm_uref(ASMState *as, IRIns *ir) { /* NYI: Check that UREFO is still open and not aliasing a slot. */ Reg dest = ra_dest(as, ir, RSET_GPR); if (irref_isk(ir->op1)) { GCfunc *fn = ir_kfunc(IR(ir->op1)); MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; emit_lsptr(as, PPCI_LWZ, dest, v, RSET_GPR); } else { Reg uv = ra_scratch(as, RSET_GPR); Reg func = ra_alloc1(as, ir->op1, RSET_GPR); if (ir->o == IR_UREFC) { asm_guardcc(as, CC_NE); emit_ai(as, PPCI_CMPWI, RID_TMP, 1); emit_tai(as, PPCI_ADDI, dest, uv, (int32_t)offsetof(GCupval, tv)); emit_tai(as, PPCI_LBZ, RID_TMP, uv, (int32_t)offsetof(GCupval, closed)); } else { emit_tai(as, PPCI_LWZ, dest, uv, (int32_t)offsetof(GCupval, v)); } emit_tai(as, PPCI_LWZ, uv, func, (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); } } static void asm_fref(ASMState *as, IRIns *ir) { UNUSED(as); UNUSED(ir); lua_assert(!ra_used(ir)); } static void asm_strref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); IRRef ref = ir->op2, refk = ir->op1; int32_t ofs = (int32_t)sizeof(GCstr); Reg r; if (irref_isk(ref)) { IRRef tmp = refk; refk = ref; ref = tmp; } else if (!irref_isk(refk)) { Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); IRIns *irr = IR(ir->op2); if (ra_hasreg(irr->r)) { ra_noweak(as, irr->r); right = irr->r; } else if (mayfuse(as, irr->op2) && irr->o == IR_ADD && irref_isk(irr->op2) && checki16(ofs + IR(irr->op2)->i)) { ofs += IR(irr->op2)->i; right = ra_alloc1(as, irr->op1, rset_exclude(RSET_GPR, left)); } else { right = ra_allocref(as, ir->op2, rset_exclude(RSET_GPR, left)); } emit_tai(as, PPCI_ADDI, dest, dest, ofs); emit_tab(as, PPCI_ADD, dest, left, right); return; } r = ra_alloc1(as, ref, RSET_GPR); ofs += IR(refk)->i; if (checki16(ofs)) emit_tai(as, PPCI_ADDI, dest, r, ofs); else emit_tab(as, PPCI_ADD, dest, r, ra_allock(as, ofs, rset_exclude(RSET_GPR, r))); } /* -- Loads and stores ---------------------------------------------------- */ static PPCIns asm_fxloadins(IRIns *ir) { switch (irt_type(ir->t)) { case IRT_I8: return PPCI_LBZ; /* Needs sign-extension. */ case IRT_U8: return PPCI_LBZ; case IRT_I16: return PPCI_LHA; case IRT_U16: return PPCI_LHZ; case IRT_NUM: return PPCI_LFD; case IRT_FLOAT: return PPCI_LFS; default: return PPCI_LWZ; } } static PPCIns asm_fxstoreins(IRIns *ir) { switch (irt_type(ir->t)) { case IRT_I8: case IRT_U8: return PPCI_STB; case IRT_I16: case IRT_U16: return PPCI_STH; case IRT_NUM: return PPCI_STFD; case IRT_FLOAT: return PPCI_STFS; default: return PPCI_STW; } } static void asm_fload(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg idx = ra_alloc1(as, ir->op1, RSET_GPR); PPCIns pi = asm_fxloadins(ir); int32_t ofs; if (ir->op2 == IRFL_TAB_ARRAY) { ofs = asm_fuseabase(as, ir->op1); if (ofs) { /* Turn the t->array load into an add for colocated arrays. */ emit_tai(as, PPCI_ADDI, dest, idx, ofs); return; } } ofs = field_ofs[ir->op2]; lua_assert(!irt_isi8(ir->t)); emit_tai(as, pi, dest, idx, ofs); } static void asm_fstore(ASMState *as, IRIns *ir) { if (ir->r != RID_SINK) { Reg src = ra_alloc1(as, ir->op2, RSET_GPR); IRIns *irf = IR(ir->op1); Reg idx = ra_alloc1(as, irf->op1, rset_exclude(RSET_GPR, src)); int32_t ofs = field_ofs[irf->op2]; PPCIns pi = asm_fxstoreins(ir); emit_tai(as, pi, src, idx, ofs); } } static void asm_xload(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); lua_assert(!(ir->op2 & IRXLOAD_UNALIGNED)); if (irt_isi8(ir->t)) emit_as(as, PPCI_EXTSB, dest, dest); asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR, 0); } static void asm_xstore(ASMState *as, IRIns *ir, int32_t ofs) { IRIns *irb; if (ir->r == RID_SINK) return; if (ofs == 0 && mayfuse(as, ir->op2) && (irb = IR(ir->op2))->o == IR_BSWAP && ra_noreg(irb->r) && (irt_isint(ir->t) || irt_isu32(ir->t))) { /* Fuse BSWAP with XSTORE to stwbrx. */ Reg src = ra_alloc1(as, irb->op1, RSET_GPR); asm_fusexrefx(as, PPCI_STWBRX, src, ir->op1, rset_exclude(RSET_GPR, src)); } else { Reg src = ra_alloc1(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1, rset_exclude(RSET_GPR, src), ofs); } } static void asm_ahuvload(ASMState *as, IRIns *ir) { IRType1 t = ir->t; Reg dest = RID_NONE, type = RID_TMP, tmp = RID_TMP, idx; RegSet allow = RSET_GPR; int32_t ofs = AHUREF_LSX; if (ra_used(ir)) { lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); if (!irt_isnum(t)) ofs = 0; dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); rset_clear(allow, dest); } idx = asm_fuseahuref(as, ir->op1, &ofs, allow); if (irt_isnum(t)) { Reg tisnum = ra_allock(as, (int32_t)LJ_TISNUM, rset_exclude(allow, idx)); asm_guardcc(as, CC_GE); emit_ab(as, PPCI_CMPLW, type, tisnum); if (ra_hasreg(dest)) { if (ofs == AHUREF_LSX) { tmp = ra_scratch(as, rset_exclude(rset_exclude(RSET_GPR, (idx&255)), (idx>>8))); emit_fab(as, PPCI_LFDX, dest, (idx&255), tmp); } else { emit_fai(as, PPCI_LFD, dest, idx, ofs); } } } else { asm_guardcc(as, CC_NE); emit_ai(as, PPCI_CMPWI, type, irt_toitype(t)); if (ra_hasreg(dest)) emit_tai(as, PPCI_LWZ, dest, idx, ofs+4); } if (ofs == AHUREF_LSX) { emit_tab(as, PPCI_LWZX, type, (idx&255), tmp); emit_slwi(as, tmp, (idx>>8), 3); } else { emit_tai(as, PPCI_LWZ, type, idx, ofs); } } static void asm_ahustore(ASMState *as, IRIns *ir) { RegSet allow = RSET_GPR; Reg idx, src = RID_NONE, type = RID_NONE; int32_t ofs = AHUREF_LSX; if (ir->r == RID_SINK) return; if (irt_isnum(ir->t)) { src = ra_alloc1(as, ir->op2, RSET_FPR); } else { if (!irt_ispri(ir->t)) { src = ra_alloc1(as, ir->op2, allow); rset_clear(allow, src); ofs = 0; } type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); rset_clear(allow, type); } idx = asm_fuseahuref(as, ir->op1, &ofs, allow); if (irt_isnum(ir->t)) { if (ofs == AHUREF_LSX) { emit_fab(as, PPCI_STFDX, src, (idx&255), RID_TMP); emit_slwi(as, RID_TMP, (idx>>8), 3); } else { emit_fai(as, PPCI_STFD, src, idx, ofs); } } else { if (ra_hasreg(src)) emit_tai(as, PPCI_STW, src, idx, ofs+4); if (ofs == AHUREF_LSX) { emit_tab(as, PPCI_STWX, type, (idx&255), RID_TMP); emit_slwi(as, RID_TMP, (idx>>8), 3); } else { emit_tai(as, PPCI_STW, type, idx, ofs); } } } static void asm_sload(ASMState *as, IRIns *ir) { int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 0 : 4); IRType1 t = ir->t; Reg dest = RID_NONE, type = RID_NONE, base; RegSet allow = RSET_GPR; lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); lua_assert(LJ_DUALNUM || !irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { dest = ra_scratch(as, RSET_FPR); asm_tointg(as, ir, dest); t.irt = IRT_NUM; /* Continue with a regular number type check. */ } else if (ra_used(ir)) { lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); dest = ra_dest(as, ir, irt_isnum(t) ? RSET_FPR : RSET_GPR); rset_clear(allow, dest); base = ra_alloc1(as, REF_BASE, allow); rset_clear(allow, base); if ((ir->op2 & IRSLOAD_CONVERT)) { if (irt_isint(t)) { emit_tai(as, PPCI_LWZ, dest, RID_SP, SPOFS_TMPLO); dest = ra_scratch(as, RSET_FPR); emit_fai(as, PPCI_STFD, dest, RID_SP, SPOFS_TMP); emit_fb(as, PPCI_FCTIWZ, dest, dest); t.irt = IRT_NUM; /* Check for original type. */ } else { Reg tmp = ra_scratch(as, allow); Reg hibias = ra_allock(as, 0x43300000, rset_clear(allow, tmp)); Reg fbias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); emit_fab(as, PPCI_FSUB, dest, dest, fbias); emit_fai(as, PPCI_LFD, dest, RID_SP, SPOFS_TMP); emit_lsptr(as, PPCI_LFS, (fbias & 31), (void *)lj_ir_k64_find(as->J, U64x(59800004,59800000)), rset_clear(allow, hibias)); emit_tai(as, PPCI_STW, tmp, RID_SP, SPOFS_TMPLO); emit_tai(as, PPCI_STW, hibias, RID_SP, SPOFS_TMPHI); emit_asi(as, PPCI_XORIS, tmp, tmp, 0x8000); dest = tmp; t.irt = IRT_INT; /* Check for original type. */ } } goto dotypecheck; } base = ra_alloc1(as, REF_BASE, allow); rset_clear(allow, base); dotypecheck: if (irt_isnum(t)) { if ((ir->op2 & IRSLOAD_TYPECHECK)) { Reg tisnum = ra_allock(as, (int32_t)LJ_TISNUM, allow); asm_guardcc(as, CC_GE); emit_ab(as, PPCI_CMPLW, RID_TMP, tisnum); type = RID_TMP; } if (ra_hasreg(dest)) emit_fai(as, PPCI_LFD, dest, base, ofs-4); } else { if ((ir->op2 & IRSLOAD_TYPECHECK)) { asm_guardcc(as, CC_NE); emit_ai(as, PPCI_CMPWI, RID_TMP, irt_toitype(t)); type = RID_TMP; } if (ra_hasreg(dest)) emit_tai(as, PPCI_LWZ, dest, base, ofs); } if (ra_hasreg(type)) emit_tai(as, PPCI_LWZ, type, base, ofs-4); } /* -- Allocations --------------------------------------------------------- */ #if LJ_HASFFI static void asm_cnew(ASMState *as, IRIns *ir) { CTState *cts = ctype_ctsG(J2G(as->J)); CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; IRRef args[2]; RegSet allow = (RSET_GPR & ~RSET_SCRATCH); RegSet drop = RSET_SCRATCH; lua_assert(sz != CTSIZE_INVALID); args[0] = ASMREF_L; /* lua_State *L */ args[1] = ASMREF_TMP1; /* MSize size */ as->gcsteps++; if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ ra_evictset(as, drop); if (ra_used(ir)) ra_destreg(as, ir, RID_RET); /* GCcdata * */ /* Initialize immutable cdata object. */ if (ir->o == IR_CNEWI) { int32_t ofs = sizeof(GCcdata); lua_assert(sz == 4 || sz == 8); if (sz == 8) { ofs += 4; lua_assert((ir+1)->o == IR_HIOP); } for (;;) { Reg r = ra_alloc1(as, ir->op2, allow); emit_tai(as, PPCI_STW, r, RID_RET, ofs); rset_clear(allow, r); if (ofs == sizeof(GCcdata)) break; ofs -= 4; ir++; } } /* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */ emit_tai(as, PPCI_STB, RID_RET+1, RID_RET, offsetof(GCcdata, gct)); emit_tai(as, PPCI_STH, RID_TMP, RID_RET, offsetof(GCcdata, ctypeid)); emit_ti(as, PPCI_LI, RID_RET+1, ~LJ_TCDATA); emit_ti(as, PPCI_LI, RID_TMP, ctypeid); /* Lower 16 bit used. Sign-ext ok. */ asm_gencall(as, ci, args); ra_allockreg(as, (int32_t)(sz+sizeof(GCcdata)), ra_releasetmp(as, ASMREF_TMP1)); } #else #define asm_cnew(as, ir) ((void)0) #endif /* -- Write barriers ------------------------------------------------------ */ static void asm_tbar(ASMState *as, IRIns *ir) { Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); Reg mark = ra_scratch(as, rset_exclude(RSET_GPR, tab)); Reg link = RID_TMP; MCLabel l_end = emit_label(as); emit_tai(as, PPCI_STW, link, tab, (int32_t)offsetof(GCtab, gclist)); emit_tai(as, PPCI_STB, mark, tab, (int32_t)offsetof(GCtab, marked)); emit_setgl(as, tab, gc.grayagain); lua_assert(LJ_GC_BLACK == 0x04); emit_rot(as, PPCI_RLWINM, mark, mark, 0, 30, 28); /* Clear black bit. */ emit_getgl(as, link, gc.grayagain); emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); emit_asi(as, PPCI_ANDIDOT, RID_TMP, mark, LJ_GC_BLACK); emit_tai(as, PPCI_LBZ, mark, tab, (int32_t)offsetof(GCtab, marked)); } static void asm_obar(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; IRRef args[2]; MCLabel l_end; Reg obj, val, tmp; /* No need for other object barriers (yet). */ lua_assert(IR(ir->op1)->o == IR_UREFC); ra_evictset(as, RSET_SCRATCH); l_end = emit_label(as); args[0] = ASMREF_TMP1; /* global_State *g */ args[1] = ir->op1; /* TValue *tv */ asm_gencall(as, ci, args); emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); obj = IR(ir->op1)->r; tmp = ra_scratch(as, rset_exclude(RSET_GPR, obj)); emit_condbranch(as, PPCI_BC|PPCF_Y, CC_EQ, l_end); emit_asi(as, PPCI_ANDIDOT, tmp, tmp, LJ_GC_BLACK); emit_condbranch(as, PPCI_BC, CC_EQ, l_end); emit_asi(as, PPCI_ANDIDOT, RID_TMP, RID_TMP, LJ_GC_WHITES); val = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, obj)); emit_tai(as, PPCI_LBZ, tmp, obj, (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); emit_tai(as, PPCI_LBZ, RID_TMP, val, (int32_t)offsetof(GChead, marked)); } /* -- Arithmetic and logic operations ------------------------------------- */ static void asm_fparith(ASMState *as, IRIns *ir, PPCIns pi) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg right, left = ra_alloc2(as, ir, RSET_FPR); right = (left >> 8); left &= 255; if (pi == PPCI_FMUL) emit_fac(as, pi, dest, left, right); else emit_fab(as, pi, dest, left, right); } static void asm_fpunary(ASMState *as, IRIns *ir, PPCIns pi) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg left = ra_hintalloc(as, ir->op1, dest, RSET_FPR); emit_fb(as, pi, dest, left); } static int asm_fpjoin_pow(ASMState *as, IRIns *ir) { IRIns *irp = IR(ir->op1); if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { IRIns *irpp = IR(irp->op1); if (irpp == ir-2 && irpp->o == IR_FPMATH && irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_pow]; IRRef args[2]; args[0] = irpp->op1; args[1] = irp->op2; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); return 1; } } return 0; } static void asm_add(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) { if (!asm_fusemadd(as, ir, PPCI_FMADD, PPCI_FMADD)) asm_fparith(as, ir, PPCI_FADD); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); PPCIns pi; if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (checki16(k)) { pi = PPCI_ADDI; /* May fail due to spills/restores above, but simplifies the logic. */ if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; pi = PPCI_ADDICDOT; } emit_tai(as, pi, dest, left, k); return; } else if ((k & 0xffff) == 0) { emit_tai(as, PPCI_ADDIS, dest, left, (k >> 16)); return; } else if (!as->sectref) { emit_tai(as, PPCI_ADDIS, dest, dest, (k + 32768) >> 16); emit_tai(as, PPCI_ADDI, dest, left, k); return; } } pi = PPCI_ADD; /* May fail due to spills/restores above, but simplifies the logic. */ if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; pi |= PPCF_DOT; } right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_tab(as, pi, dest, left, right); } } static void asm_sub(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) { if (!asm_fusemadd(as, ir, PPCI_FMSUB, PPCI_FNMSUB)) asm_fparith(as, ir, PPCI_FSUB); } else { PPCIns pi = PPCI_SUBF; Reg dest = ra_dest(as, ir, RSET_GPR); Reg left, right; if (irref_isk(ir->op1)) { int32_t k = IR(ir->op1)->i; if (checki16(k)) { right = ra_alloc1(as, ir->op2, RSET_GPR); emit_tai(as, PPCI_SUBFIC, dest, right, k); return; } } /* May fail due to spills/restores above, but simplifies the logic. */ if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; pi |= PPCF_DOT; } left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_tab(as, pi, dest, right, left); /* Subtract right _from_ left. */ } } static void asm_mul(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) { asm_fparith(as, ir, PPCI_FMUL); } else { PPCIns pi = PPCI_MULLW; Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (checki16(k)) { emit_tai(as, PPCI_MULLI, dest, left, k); return; } } /* May fail due to spills/restores above, but simplifies the logic. */ if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; pi |= PPCF_DOT; } right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_tab(as, pi, dest, left, right); } } static void asm_neg(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) { asm_fpunary(as, ir, PPCI_FNEG); } else { Reg dest, left; PPCIns pi = PPCI_NEG; if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; pi |= PPCF_DOT; } dest = ra_dest(as, ir, RSET_GPR); left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); emit_tab(as, pi, dest, left, 0); } } static void asm_arithov(ASMState *as, IRIns *ir, PPCIns pi) { Reg dest, left, right; if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; } asm_guardcc(as, CC_SO); dest = ra_dest(as, ir, RSET_GPR); left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; if (pi == PPCI_SUBFO) { Reg tmp = left; left = right; right = tmp; } emit_tab(as, pi|PPCF_DOT, dest, left, right); } #if LJ_HASFFI static void asm_add64(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_alloc1(as, ir->op1, RSET_GPR); PPCIns pi = PPCI_ADDE; if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (k == 0) pi = PPCI_ADDZE; else if (k == -1) pi = PPCI_ADDME; else goto needright; right = 0; } else { needright: right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); } emit_tab(as, pi, dest, left, right); ir--; dest = ra_dest(as, ir, RSET_GPR); left = ra_alloc1(as, ir->op1, RSET_GPR); if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (checki16(k)) { emit_tai(as, PPCI_ADDIC, dest, left, k); return; } } right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_tab(as, PPCI_ADDC, dest, left, right); } static void asm_sub64(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left, right = ra_alloc1(as, ir->op2, RSET_GPR); PPCIns pi = PPCI_SUBFE; if (irref_isk(ir->op1)) { int32_t k = IR(ir->op1)->i; if (k == 0) pi = PPCI_SUBFZE; else if (k == -1) pi = PPCI_SUBFME; else goto needleft; left = 0; } else { needleft: left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, right)); } emit_tab(as, pi, dest, right, left); /* Subtract right _from_ left. */ ir--; dest = ra_dest(as, ir, RSET_GPR); right = ra_alloc1(as, ir->op2, RSET_GPR); if (irref_isk(ir->op1)) { int32_t k = IR(ir->op1)->i; if (checki16(k)) { emit_tai(as, PPCI_SUBFIC, dest, right, k); return; } } left = ra_alloc1(as, ir->op1, rset_exclude(RSET_GPR, right)); emit_tab(as, PPCI_SUBFC, dest, right, left); } static void asm_neg64(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg left = ra_alloc1(as, ir->op1, RSET_GPR); emit_tab(as, PPCI_SUBFZE, dest, left, 0); ir--; dest = ra_dest(as, ir, RSET_GPR); left = ra_alloc1(as, ir->op1, RSET_GPR); emit_tai(as, PPCI_SUBFIC, dest, left, 0); } #endif static void asm_bitnot(ASMState *as, IRIns *ir) { Reg dest, left, right; PPCIns pi = PPCI_NOR; if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; pi |= PPCF_DOT; } dest = ra_dest(as, ir, RSET_GPR); if (mayfuse(as, ir->op1)) { IRIns *irl = IR(ir->op1); if (irl->o == IR_BAND) pi ^= (PPCI_NOR ^ PPCI_NAND); else if (irl->o == IR_BXOR) pi ^= (PPCI_NOR ^ PPCI_EQV); else if (irl->o != IR_BOR) goto nofuse; left = ra_hintalloc(as, irl->op1, dest, RSET_GPR); right = ra_alloc1(as, irl->op2, rset_exclude(RSET_GPR, left)); } else { nofuse: left = right = ra_hintalloc(as, ir->op1, dest, RSET_GPR); } emit_asb(as, pi, dest, left, right); } static void asm_bitswap(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); IRIns *irx; if (mayfuse(as, ir->op1) && (irx = IR(ir->op1))->o == IR_XLOAD && ra_noreg(irx->r) && (irt_isint(irx->t) || irt_isu32(irx->t))) { /* Fuse BSWAP with XLOAD to lwbrx. */ asm_fusexrefx(as, PPCI_LWBRX, dest, irx->op1, RSET_GPR); } else { Reg left = ra_alloc1(as, ir->op1, RSET_GPR); Reg tmp = dest; if (tmp == left) { tmp = RID_TMP; emit_mr(as, dest, RID_TMP); } emit_rot(as, PPCI_RLWIMI, tmp, left, 24, 16, 23); emit_rot(as, PPCI_RLWIMI, tmp, left, 24, 0, 7); emit_rotlwi(as, tmp, left, 8); } } static void asm_bitop(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pik) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg right, left = ra_hintalloc(as, ir->op1, dest, RSET_GPR); if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; Reg tmp = left; if ((checku16(k) || (k & 0xffff) == 0) || (tmp = dest, !as->sectref)) { if (!checku16(k)) { emit_asi(as, pik ^ (PPCI_ORI ^ PPCI_ORIS), dest, tmp, (k >> 16)); if ((k & 0xffff) == 0) return; } emit_asi(as, pik, dest, left, k); return; } } /* May fail due to spills/restores above, but simplifies the logic. */ if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; pi |= PPCF_DOT; } right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_asb(as, pi, dest, left, right); } /* Fuse BAND with contiguous bitmask and a shift to rlwinm. */ static void asm_fuseandsh(ASMState *as, PPCIns pi, int32_t mask, IRRef ref) { IRIns *ir; Reg left; if (mayfuse(as, ref) && (ir = IR(ref), ra_noreg(ir->r)) && irref_isk(ir->op2) && ir->o >= IR_BSHL && ir->o <= IR_BROR) { int32_t sh = (IR(ir->op2)->i & 31); switch (ir->o) { case IR_BSHL: if ((mask & ((1u<>sh))) goto nofuse; sh = ((32-sh)&31); break; case IR_BROL: break; default: goto nofuse; } left = ra_alloc1(as, ir->op1, RSET_GPR); *--as->mcp = pi | PPCF_T(left) | PPCF_B(sh); return; } nofuse: left = ra_alloc1(as, ref, RSET_GPR); *--as->mcp = pi | PPCF_T(left); } static void asm_bitand(ASMState *as, IRIns *ir) { Reg dest, left, right; IRRef lref = ir->op1; PPCIns dot = 0; IRRef op2; if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; dot = PPCF_DOT; } dest = ra_dest(as, ir, RSET_GPR); if (irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (k) { /* First check for a contiguous bitmask as used by rlwinm. */ uint32_t s1 = lj_ffs((uint32_t)k); uint32_t k1 = ((uint32_t)k >> s1); if ((k1 & (k1+1)) == 0) { asm_fuseandsh(as, PPCI_RLWINM|dot | PPCF_A(dest) | PPCF_MB(31-lj_fls((uint32_t)k)) | PPCF_ME(31-s1), k, lref); return; } if (~(uint32_t)k) { uint32_t s2 = lj_ffs(~(uint32_t)k); uint32_t k2 = (~(uint32_t)k >> s2); if ((k2 & (k2+1)) == 0) { asm_fuseandsh(as, PPCI_RLWINM|dot | PPCF_A(dest) | PPCF_MB(32-s2) | PPCF_ME(30-lj_fls(~(uint32_t)k)), k, lref); return; } } } if (checku16(k)) { left = ra_alloc1(as, lref, RSET_GPR); emit_asi(as, PPCI_ANDIDOT, dest, left, k); return; } else if ((k & 0xffff) == 0) { left = ra_alloc1(as, lref, RSET_GPR); emit_asi(as, PPCI_ANDISDOT, dest, left, (k >> 16)); return; } } op2 = ir->op2; if (mayfuse(as, op2) && IR(op2)->o == IR_BNOT && ra_noreg(IR(op2)->r)) { dot ^= (PPCI_AND ^ PPCI_ANDC); op2 = IR(op2)->op1; } left = ra_hintalloc(as, lref, dest, RSET_GPR); right = ra_alloc1(as, op2, rset_exclude(RSET_GPR, left)); emit_asb(as, PPCI_AND ^ dot, dest, left, right); } static void asm_bitshift(ASMState *as, IRIns *ir, PPCIns pi, PPCIns pik) { Reg dest, left; Reg dot = 0; if (as->flagmcp == as->mcp) { as->flagmcp = NULL; as->mcp++; dot = PPCF_DOT; } dest = ra_dest(as, ir, RSET_GPR); left = ra_alloc1(as, ir->op1, RSET_GPR); if (irref_isk(ir->op2)) { /* Constant shifts. */ int32_t shift = (IR(ir->op2)->i & 31); if (pik == 0) /* SLWI */ emit_rot(as, PPCI_RLWINM|dot, dest, left, shift, 0, 31-shift); else if (pik == 1) /* SRWI */ emit_rot(as, PPCI_RLWINM|dot, dest, left, (32-shift)&31, shift, 31); else emit_asb(as, pik|dot, dest, left, shift); } else { Reg right = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, left)); emit_asb(as, pi|dot, dest, left, right); } } static void asm_min_max(ASMState *as, IRIns *ir, int ismax) { if (irt_isnum(ir->t)) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg tmp = dest; Reg right, left = ra_alloc2(as, ir, RSET_FPR); right = (left >> 8); left &= 255; if (tmp == left || tmp == right) tmp = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_FPR, dest), left), right)); emit_facb(as, PPCI_FSEL, dest, tmp, ismax ? left : right, ismax ? right : left); emit_fab(as, PPCI_FSUB, tmp, left, right); } else { Reg dest = ra_dest(as, ir, RSET_GPR); Reg tmp1 = RID_TMP, tmp2 = dest; Reg right, left = ra_alloc2(as, ir, RSET_GPR); right = (left >> 8); left &= 255; if (tmp2 == left || tmp2 == right) tmp2 = ra_scratch(as, rset_exclude(rset_exclude(rset_exclude(RSET_GPR, dest), left), right)); emit_tab(as, PPCI_ADD, dest, tmp2, right); emit_asb(as, ismax ? PPCI_ANDC : PPCI_AND, tmp2, tmp2, tmp1); emit_tab(as, PPCI_SUBFE, tmp1, tmp1, tmp1); emit_tab(as, PPCI_SUBFC, tmp2, tmp2, tmp1); emit_asi(as, PPCI_XORIS, tmp2, right, 0x8000); emit_asi(as, PPCI_XORIS, tmp1, left, 0x8000); } } /* -- Comparisons --------------------------------------------------------- */ #define CC_UNSIGNED 0x08 /* Unsigned integer comparison. */ #define CC_TWO 0x80 /* Check two flags for FP comparison. */ /* Map of comparisons to flags. ORDER IR. */ static const uint8_t asm_compmap[IR_ABC+1] = { /* op int cc FP cc */ /* LT */ CC_GE + (CC_GE<<4), /* GE */ CC_LT + (CC_LE<<4) + CC_TWO, /* LE */ CC_GT + (CC_GE<<4) + CC_TWO, /* GT */ CC_LE + (CC_LE<<4), /* ULT */ CC_GE + CC_UNSIGNED + (CC_GT<<4) + CC_TWO, /* UGE */ CC_LT + CC_UNSIGNED + (CC_LT<<4), /* ULE */ CC_GT + CC_UNSIGNED + (CC_GT<<4), /* UGT */ CC_LE + CC_UNSIGNED + (CC_LT<<4) + CC_TWO, /* EQ */ CC_NE + (CC_NE<<4), /* NE */ CC_EQ + (CC_EQ<<4), /* ABC */ CC_LE + CC_UNSIGNED + (CC_LT<<4) + CC_TWO /* Same as UGT. */ }; static void asm_intcomp_(ASMState *as, IRRef lref, IRRef rref, Reg cr, PPCCC cc) { Reg right, left = ra_alloc1(as, lref, RSET_GPR); if (irref_isk(rref)) { int32_t k = IR(rref)->i; if ((cc & CC_UNSIGNED) == 0) { /* Signed comparison with constant. */ if (checki16(k)) { emit_tai(as, PPCI_CMPWI, cr, left, k); /* Signed comparison with zero and referencing previous ins? */ if (k == 0 && lref == as->curins-1) as->flagmcp = as->mcp; /* Allow elimination of the compare. */ return; } else if ((cc & 3) == (CC_EQ & 3)) { /* Use CMPLWI for EQ or NE. */ if (checku16(k)) { emit_tai(as, PPCI_CMPLWI, cr, left, k); return; } else if (!as->sectref && ra_noreg(IR(rref)->r)) { emit_tai(as, PPCI_CMPLWI, cr, RID_TMP, k); emit_asi(as, PPCI_XORIS, RID_TMP, left, (k >> 16)); return; } } } else { /* Unsigned comparison with constant. */ if (checku16(k)) { emit_tai(as, PPCI_CMPLWI, cr, left, k); return; } } } right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, left)); emit_tab(as, (cc & CC_UNSIGNED) ? PPCI_CMPLW : PPCI_CMPW, cr, left, right); } static void asm_comp(ASMState *as, IRIns *ir) { PPCCC cc = asm_compmap[ir->o]; if (irt_isnum(ir->t)) { Reg right, left = ra_alloc2(as, ir, RSET_FPR); right = (left >> 8); left &= 255; asm_guardcc(as, (cc >> 4)); if ((cc & CC_TWO)) emit_tab(as, PPCI_CROR, ((cc>>4)&3), ((cc>>4)&3), (CC_EQ&3)); emit_fab(as, PPCI_FCMPU, 0, left, right); } else { IRRef lref = ir->op1, rref = ir->op2; if (irref_isk(lref) && !irref_isk(rref)) { /* Swap constants to the right (only for ABC). */ IRRef tmp = lref; lref = rref; rref = tmp; if ((cc & 2) == 0) cc ^= 1; /* LT <-> GT, LE <-> GE */ } asm_guardcc(as, cc); asm_intcomp_(as, lref, rref, 0, cc); } } #if LJ_HASFFI /* 64 bit integer comparisons. */ static void asm_comp64(ASMState *as, IRIns *ir) { PPCCC cc = asm_compmap[(ir-1)->o]; if ((cc&3) == (CC_EQ&3)) { asm_guardcc(as, cc); emit_tab(as, (cc&4) ? PPCI_CRAND : PPCI_CROR, (CC_EQ&3), (CC_EQ&3), 4+(CC_EQ&3)); } else { asm_guardcc(as, CC_EQ); emit_tab(as, PPCI_CROR, (CC_EQ&3), (CC_EQ&3), ((cc^~(cc>>2))&1)); emit_tab(as, (cc&4) ? PPCI_CRAND : PPCI_CRANDC, (CC_EQ&3), (CC_EQ&3), 4+(cc&3)); } /* Loword comparison sets cr1 and is unsigned, except for equality. */ asm_intcomp_(as, (ir-1)->op1, (ir-1)->op2, 4, cc | ((cc&3) == (CC_EQ&3) ? 0 : CC_UNSIGNED)); /* Hiword comparison sets cr0. */ asm_intcomp_(as, ir->op1, ir->op2, 0, cc); as->flagmcp = NULL; /* Doesn't work here. */ } #endif /* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ /* Hiword op of a split 64 bit op. Previous op must be the loword op. */ static void asm_hiop(ASMState *as, IRIns *ir) { #if LJ_HASFFI /* HIOP is marked as a store because it needs its own DCE logic. */ int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ as->curins--; /* Always skip the CONV. */ if (usehi || uselo) asm_conv64(as, ir); return; } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ as->curins--; /* Always skip the loword comparison. */ asm_comp64(as, ir); return; } else if ((ir-1)->o == IR_XSTORE) { as->curins--; /* Handle both stores here. */ if ((ir-1)->r != RID_SINK) { asm_xstore(as, ir, 0); asm_xstore(as, ir-1, 4); } return; } if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ switch ((ir-1)->o) { case IR_ADD: as->curins--; asm_add64(as, ir); break; case IR_SUB: as->curins--; asm_sub64(as, ir); break; case IR_NEG: as->curins--; asm_neg64(as, ir); break; case IR_CALLN: case IR_CALLXS: if (!uselo) ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ break; case IR_CNEWI: /* Nothing to do here. Handled by lo op itself. */ break; default: lua_assert(0); break; } #else UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused without FFI. */ #endif } /* -- Stack handling ------------------------------------------------------ */ /* Check Lua stack size for overflow. Use exit handler as fallback. */ static void asm_stack_check(ASMState *as, BCReg topslot, IRIns *irp, RegSet allow, ExitNo exitno) { /* Try to get an unused temp. register, otherwise spill/restore RID_RET*. */ Reg tmp, pbase = irp ? (ra_hasreg(irp->r) ? irp->r : RID_TMP) : RID_BASE; rset_clear(allow, pbase); tmp = allow ? rset_pickbot(allow) : (pbase == RID_RETHI ? RID_RETLO : RID_RETHI); emit_condbranch(as, PPCI_BC, CC_LT, asm_exitstub_addr(as, exitno)); if (allow == RSET_EMPTY) /* Restore temp. register. */ emit_tai(as, PPCI_LWZ, tmp, RID_SP, SPOFS_TMPW); else ra_modified(as, tmp); emit_ai(as, PPCI_CMPLWI, RID_TMP, (int32_t)(8*topslot)); emit_tab(as, PPCI_SUBF, RID_TMP, pbase, tmp); emit_tai(as, PPCI_LWZ, tmp, tmp, offsetof(lua_State, maxstack)); if (pbase == RID_TMP) emit_getgl(as, RID_TMP, jit_base); emit_getgl(as, tmp, jit_L); if (allow == RSET_EMPTY) /* Spill temp. register. */ emit_tai(as, PPCI_STW, tmp, RID_SP, SPOFS_TMPW); } /* Restore Lua stack from on-trace state. */ static void asm_stack_restore(ASMState *as, SnapShot *snap) { SnapEntry *map = &as->T->snapmap[snap->mapofs]; SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; MSize n, nent = snap->nent; /* Store the value of all modified slots to the Lua stack. */ for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; BCReg s = snap_slot(sn); int32_t ofs = 8*((int32_t)s-1); IRRef ref = snap_ref(sn); IRIns *ir = IR(ref); if ((sn & SNAP_NORESTORE)) continue; if (irt_isnum(ir->t)) { Reg src = ra_alloc1(as, ref, RSET_FPR); emit_fai(as, PPCI_STFD, src, RID_BASE, ofs); } else { Reg type; RegSet allow = rset_exclude(RSET_GPR, RID_BASE); lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || irt_isinteger(ir->t)); if (!irt_ispri(ir->t)) { Reg src = ra_alloc1(as, ref, allow); rset_clear(allow, src); emit_tai(as, PPCI_STW, src, RID_BASE, ofs+4); } if ((sn & (SNAP_CONT|SNAP_FRAME))) { if (s == 0) continue; /* Do not overwrite link to previous frame. */ type = ra_allock(as, (int32_t)(*flinks--), allow); } else { type = ra_allock(as, (int32_t)irt_toitype(ir->t), allow); } emit_tai(as, PPCI_STW, type, RID_BASE, ofs); } checkmclim(as); } lua_assert(map + nent == flinks); } /* -- GC handling --------------------------------------------------------- */ /* Check GC threshold and do one or more GC steps. */ static void asm_gc_check(ASMState *as) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; IRRef args[2]; MCLabel l_end; Reg tmp; ra_evictset(as, RSET_SCRATCH); l_end = emit_label(as); /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ emit_ai(as, PPCI_CMPWI, RID_RET, 0); args[0] = ASMREF_TMP1; /* global_State *g */ args[1] = ASMREF_TMP2; /* MSize steps */ asm_gencall(as, ci, args); emit_tai(as, PPCI_ADDI, ra_releasetmp(as, ASMREF_TMP1), RID_JGL, -32768); tmp = ra_releasetmp(as, ASMREF_TMP2); emit_loadi(as, tmp, as->gcsteps); /* Jump around GC step if GC total < GC threshold. */ emit_condbranch(as, PPCI_BC|PPCF_Y, CC_LT, l_end); emit_ab(as, PPCI_CMPLW, RID_TMP, tmp); emit_getgl(as, tmp, gc.threshold); emit_getgl(as, RID_TMP, gc.total); as->gcsteps = 0; checkmclim(as); } /* -- Loop handling ------------------------------------------------------- */ /* Fixup the loop branch. */ static void asm_loop_fixup(ASMState *as) { MCode *p = as->mctop; MCode *target = as->mcp; if (as->loopinv) { /* Inverted loop branch? */ /* asm_guardcc already inverted the cond branch and patched the final b. */ p[-2] = (p[-2] & (0xffff0000u & ~PPCF_Y)) | (((target-p+2) & 0x3fffu) << 2); } else { p[-1] = PPCI_B|(((target-p+1)&0x00ffffffu)<<2); } } /* -- Head of trace ------------------------------------------------------- */ /* Coalesce BASE register for a root trace. */ static void asm_head_root_base(ASMState *as) { IRIns *ir = IR(REF_BASE); Reg r = ir->r; if (ra_hasreg(r)) { ra_free(as, r); if (rset_test(as->modset, r)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (r != RID_BASE) emit_mr(as, r, RID_BASE); } } /* Coalesce BASE register for a side trace. */ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) { IRIns *ir = IR(REF_BASE); Reg r = ir->r; if (ra_hasreg(r)) { ra_free(as, r); if (rset_test(as->modset, r)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (irp->r == r) { rset_clear(allow, r); /* Mark same BASE register as coalesced. */ } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { rset_clear(allow, irp->r); emit_mr(as, r, irp->r); /* Move from coalesced parent reg. */ } else { emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ } } return allow; } /* -- Tail of trace ------------------------------------------------------- */ /* Fixup the tail code. */ static void asm_tail_fixup(ASMState *as, TraceNo lnk) { MCode *p = as->mctop; MCode *target; int32_t spadj = as->T->spadjust; if (spadj == 0) { *--p = PPCI_NOP; *--p = PPCI_NOP; as->mctop = p; } else { /* Patch stack adjustment. */ lua_assert(checki16(CFRAME_SIZE+spadj)); p[-3] = PPCI_ADDI | PPCF_T(RID_TMP) | PPCF_A(RID_SP) | (CFRAME_SIZE+spadj); p[-2] = PPCI_STWU | PPCF_T(RID_TMP) | PPCF_A(RID_SP) | spadj; } /* Patch exit branch. */ target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; p[-1] = PPCI_B|(((target-p+1)&0x00ffffffu)<<2); } /* Prepare tail of code. */ static void asm_tail_prep(ASMState *as) { MCode *p = as->mctop - 1; /* Leave room for exit branch. */ if (as->loopref) { as->invmcp = as->mcp = p; } else { as->mcp = p-2; /* Leave room for stack pointer adjustment. */ as->invmcp = NULL; } } /* -- Instruction dispatch ------------------------------------------------ */ /* Assemble a single instruction. */ static void asm_ir(ASMState *as, IRIns *ir) { switch ((IROp)ir->o) { /* Miscellaneous ops. */ case IR_LOOP: asm_loop(as); break; case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; case IR_USE: ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; case IR_PHI: asm_phi(as, ir); break; case IR_HIOP: asm_hiop(as, ir); break; case IR_GCSTEP: asm_gcstep(as, ir); break; /* Guarded assertions. */ case IR_EQ: case IR_NE: if ((ir-1)->o == IR_HREF && ir->op1 == as->curins-1) { as->curins--; asm_href(as, ir-1, (IROp)ir->o); break; } /* fallthrough */ case IR_LT: case IR_GE: case IR_LE: case IR_GT: case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: case IR_ABC: asm_comp(as, ir); break; case IR_RETF: asm_retf(as, ir); break; /* Bit ops. */ case IR_BNOT: asm_bitnot(as, ir); break; case IR_BSWAP: asm_bitswap(as, ir); break; case IR_BAND: asm_bitand(as, ir); break; case IR_BOR: asm_bitop(as, ir, PPCI_OR, PPCI_ORI); break; case IR_BXOR: asm_bitop(as, ir, PPCI_XOR, PPCI_XORI); break; case IR_BSHL: asm_bitshift(as, ir, PPCI_SLW, 0); break; case IR_BSHR: asm_bitshift(as, ir, PPCI_SRW, 1); break; case IR_BSAR: asm_bitshift(as, ir, PPCI_SRAW, PPCI_SRAWI); break; case IR_BROL: asm_bitshift(as, ir, PPCI_RLWNM|PPCF_MB(0)|PPCF_ME(31), PPCI_RLWINM|PPCF_MB(0)|PPCF_ME(31)); break; case IR_BROR: lua_assert(0); break; /* Arithmetic ops. */ case IR_ADD: asm_add(as, ir); break; case IR_SUB: asm_sub(as, ir); break; case IR_MUL: asm_mul(as, ir); break; case IR_DIV: asm_fparith(as, ir, PPCI_FDIV); break; case IR_MOD: asm_callid(as, ir, IRCALL_lj_vm_modi); break; case IR_POW: asm_callid(as, ir, IRCALL_lj_vm_powi); break; case IR_NEG: asm_neg(as, ir); break; case IR_ABS: asm_fpunary(as, ir, PPCI_FABS); break; case IR_ATAN2: asm_callid(as, ir, IRCALL_atan2); break; case IR_LDEXP: asm_callid(as, ir, IRCALL_ldexp); break; case IR_MIN: asm_min_max(as, ir, 0); break; case IR_MAX: asm_min_max(as, ir, 1); break; case IR_FPMATH: if (ir->op2 == IRFPM_EXP2 && asm_fpjoin_pow(as, ir)) break; if (ir->op2 == IRFPM_SQRT && (as->flags & JIT_F_SQRT)) asm_fpunary(as, ir, PPCI_FSQRT); else asm_callid(as, ir, IRCALL_lj_vm_floor + ir->op2); break; /* Overflow-checking arithmetic ops. */ case IR_ADDOV: asm_arithov(as, ir, PPCI_ADDO); break; case IR_SUBOV: asm_arithov(as, ir, PPCI_SUBFO); break; case IR_MULOV: asm_arithov(as, ir, PPCI_MULLWO); break; /* Memory references. */ case IR_AREF: asm_aref(as, ir); break; case IR_HREF: asm_href(as, ir, 0); break; case IR_HREFK: asm_hrefk(as, ir); break; case IR_NEWREF: asm_newref(as, ir); break; case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; case IR_FREF: asm_fref(as, ir); break; case IR_STRREF: asm_strref(as, ir); break; /* Loads and stores. */ case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: asm_ahuvload(as, ir); break; case IR_FLOAD: asm_fload(as, ir); break; case IR_XLOAD: asm_xload(as, ir); break; case IR_SLOAD: asm_sload(as, ir); break; case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; case IR_FSTORE: asm_fstore(as, ir); break; case IR_XSTORE: asm_xstore(as, ir, 0); break; /* Allocations. */ case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; case IR_TNEW: asm_tnew(as, ir); break; case IR_TDUP: asm_tdup(as, ir); break; case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; /* Write barriers. */ case IR_TBAR: asm_tbar(as, ir); break; case IR_OBAR: asm_obar(as, ir); break; /* Type conversions. */ case IR_CONV: asm_conv(as, ir); break; case IR_TOBIT: asm_tobit(as, ir); break; case IR_TOSTR: asm_tostr(as, ir); break; case IR_STRTO: asm_strto(as, ir); break; /* Calls. */ case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; case IR_CALLXS: asm_callx(as, ir); break; case IR_CARG: break; default: setintV(&as->J->errinfo, ir->o); lj_trace_err_info(as->J, LJ_TRERR_NYIIR); break; } } /* -- Trace setup --------------------------------------------------------- */ /* Ensure there are enough stack slots for call arguments. */ static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) { IRRef args[CCI_NARGS_MAX]; uint32_t i, nargs = (int)CCI_NARGS(ci); int nslots = 2, ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; asm_collectargs(as, ir, ci, args); for (i = 0; i < nargs; i++) if (args[i] && irt_isfp(IR(args[i])->t)) { if (nfpr > 0) nfpr--; else nslots = (nslots+3) & ~1; } else { if (ngpr > 0) ngpr--; else nslots++; } if (nslots > as->evenspill) /* Leave room for args in stack slots. */ as->evenspill = nslots; return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); } static void asm_setup_target(ASMState *as) { asm_exitstub_setup(as, as->T->nsnap + (as->parent ? 1 : 0)); } /* -- Trace patching ------------------------------------------------------ */ /* Patch exit jumps of existing machine code to a new target. */ void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) { MCode *p = T->mcode; MCode *pe = (MCode *)((char *)p + T->szmcode); MCode *px = exitstub_trace_addr(T, exitno); MCode *cstart = NULL; MCode *mcarea = lj_mcode_patch(J, p, 0); int clearso = 0; for (; p < pe; p++) { /* Look for exitstub branch, try to replace with branch to target. */ uint32_t ins = *p; if ((ins & 0xfc000000u) == 0x40000000u && ((ins ^ ((char *)px-(char *)p)) & 0xffffu) == 0) { ptrdiff_t delta = (char *)target - (char *)p; if (((ins >> 16) & 3) == (CC_SO&3)) { clearso = sizeof(MCode); delta -= sizeof(MCode); } /* Many, but not all short-range branches can be patched directly. */ if (((delta + 0x8000) >> 16) == 0) { *p = (ins & 0xffdf0000u) | ((uint32_t)delta & 0xffffu) | ((delta & 0x8000) * (PPCF_Y/0x8000)); if (!cstart) cstart = p; } } else if ((ins & 0xfc000000u) == PPCI_B && ((ins ^ ((char *)px-(char *)p)) & 0x03ffffffu) == 0) { ptrdiff_t delta = (char *)target - (char *)p; lua_assert(((delta + 0x02000000) >> 26) == 0); *p = PPCI_B | ((uint32_t)delta & 0x03ffffffu); if (!cstart) cstart = p; } } { /* Always patch long-range branch in exit stub itself. */ ptrdiff_t delta = (char *)target - (char *)px - clearso; lua_assert(((delta + 0x02000000) >> 26) == 0); *px = PPCI_B | ((uint32_t)delta & 0x03ffffffu); } if (!cstart) cstart = px; lj_mcode_sync(cstart, px+1); if (clearso) { /* Extend the current trace. Ugly workaround. */ MCode *pp = J->cur.mcode; J->cur.szmcode += sizeof(MCode); *--pp = PPCI_MCRXR; /* Clear SO flag. */ J->cur.mcode = pp; lj_mcode_sync(pp, pp+1); } lj_mcode_patch(J, mcarea, 1); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_asm_x86.h ================================================ /* ** x86/x64 IR assembler (SSA IR -> machine code). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* -- Guard handling ------------------------------------------------------ */ /* Generate an exit stub group at the bottom of the reserved MCode memory. */ static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) { ExitNo i, groupofs = (group*EXITSTUBS_PER_GROUP) & 0xff; MCode *mxp = as->mcbot; MCode *mxpstart = mxp; if (mxp + (2+2)*EXITSTUBS_PER_GROUP+8+5 >= as->mctop) asm_mclimit(as); /* Push low byte of exitno for each exit stub. */ *mxp++ = XI_PUSHi8; *mxp++ = (MCode)groupofs; for (i = 1; i < EXITSTUBS_PER_GROUP; i++) { *mxp++ = XI_JMPs; *mxp++ = (MCode)((2+2)*(EXITSTUBS_PER_GROUP - i) - 2); *mxp++ = XI_PUSHi8; *mxp++ = (MCode)(groupofs + i); } /* Push the high byte of the exitno for each exit stub group. */ *mxp++ = XI_PUSHi8; *mxp++ = (MCode)((group*EXITSTUBS_PER_GROUP)>>8); /* Store DISPATCH at original stack slot 0. Account for the two push ops. */ *mxp++ = XI_MOVmi; *mxp++ = MODRM(XM_OFS8, 0, RID_ESP); *mxp++ = MODRM(XM_SCALE1, RID_ESP, RID_ESP); *mxp++ = 2*sizeof(void *); *(int32_t *)mxp = ptr2addr(J2GG(as->J)->dispatch); mxp += 4; /* Jump to exit handler which fills in the ExitState. */ *mxp++ = XI_JMP; mxp += 4; *((int32_t *)(mxp-4)) = jmprel(mxp, (MCode *)(void *)lj_vm_exit_handler); /* Commit the code for this group (even if assembly fails later on). */ lj_mcode_commitbot(as->J, mxp); as->mcbot = mxp; as->mclim = as->mcbot + MCLIM_REDZONE; return mxpstart; } /* Setup all needed exit stubs. */ static void asm_exitstub_setup(ASMState *as, ExitNo nexits) { ExitNo i; if (nexits >= EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) lj_trace_err(as->J, LJ_TRERR_SNAPOV); for (i = 0; i < (nexits+EXITSTUBS_PER_GROUP-1)/EXITSTUBS_PER_GROUP; i++) if (as->J->exitstubgroup[i] == NULL) as->J->exitstubgroup[i] = asm_exitstub_gen(as, i); } /* Emit conditional branch to exit for guard. ** It's important to emit this *after* all registers have been allocated, ** because rematerializations may invalidate the flags. */ static void asm_guardcc(ASMState *as, int cc) { MCode *target = exitstub_addr(as->J, as->snapno); MCode *p = as->mcp; if (LJ_UNLIKELY(p == as->invmcp)) { as->loopinv = 1; *(int32_t *)(p+1) = jmprel(p+5, target); target = p; cc ^= 1; if (as->realign) { emit_sjcc(as, cc, target); return; } } emit_jcc(as, cc, target); } /* -- Memory operand fusion ----------------------------------------------- */ /* Limit linear search to this distance. Avoids O(n^2) behavior. */ #define CONFLICT_SEARCH_LIM 31 /* Check if a reference is a signed 32 bit constant. */ static int asm_isk32(ASMState *as, IRRef ref, int32_t *k) { if (irref_isk(ref)) { IRIns *ir = IR(ref); if (ir->o != IR_KINT64) { *k = ir->i; return 1; } else if (checki32((int64_t)ir_kint64(ir)->u64)) { *k = (int32_t)ir_kint64(ir)->u64; return 1; } } return 0; } /* Check if there's no conflicting instruction between curins and ref. ** Also avoid fusing loads if there are multiple references. */ static int noconflict(ASMState *as, IRRef ref, IROp conflict, int noload) { IRIns *ir = as->ir; IRRef i = as->curins; if (i > ref + CONFLICT_SEARCH_LIM) return 0; /* Give up, ref is too far away. */ while (--i > ref) { if (ir[i].o == conflict) return 0; /* Conflict found. */ else if (!noload && (ir[i].op1 == ref || ir[i].op2 == ref)) return 0; } return 1; /* Ok, no conflict. */ } /* Fuse array base into memory operand. */ static IRRef asm_fuseabase(ASMState *as, IRRef ref) { IRIns *irb = IR(ref); as->mrm.ofs = 0; if (irb->o == IR_FLOAD) { IRIns *ira = IR(irb->op1); lua_assert(irb->op2 == IRFL_TAB_ARRAY); /* We can avoid the FLOAD of t->array for colocated arrays. */ if (ira->o == IR_TNEW && ira->op1 <= LJ_MAX_COLOSIZE && !neverfuse(as) && noconflict(as, irb->op1, IR_NEWREF, 1)) { as->mrm.ofs = (int32_t)sizeof(GCtab); /* Ofs to colocated array. */ return irb->op1; /* Table obj. */ } } else if (irb->o == IR_ADD && irref_isk(irb->op2)) { /* Fuse base offset (vararg load). */ as->mrm.ofs = IR(irb->op2)->i; return irb->op1; } return ref; /* Otherwise use the given array base. */ } /* Fuse array reference into memory operand. */ static void asm_fusearef(ASMState *as, IRIns *ir, RegSet allow) { IRIns *irx; lua_assert(ir->o == IR_AREF); as->mrm.base = (uint8_t)ra_alloc1(as, asm_fuseabase(as, ir->op1), allow); irx = IR(ir->op2); if (irref_isk(ir->op2)) { as->mrm.ofs += 8*irx->i; as->mrm.idx = RID_NONE; } else { rset_clear(allow, as->mrm.base); as->mrm.scale = XM_SCALE8; /* Fuse a constant ADD (e.g. t[i+1]) into the offset. ** Doesn't help much without ABCelim, but reduces register pressure. */ if (!LJ_64 && /* Has bad effects with negative index on x64. */ mayfuse(as, ir->op2) && ra_noreg(irx->r) && irx->o == IR_ADD && irref_isk(irx->op2)) { as->mrm.ofs += 8*IR(irx->op2)->i; as->mrm.idx = (uint8_t)ra_alloc1(as, irx->op1, allow); } else { as->mrm.idx = (uint8_t)ra_alloc1(as, ir->op2, allow); } } } /* Fuse array/hash/upvalue reference into memory operand. ** Caveat: this may allocate GPRs for the base/idx registers. Be sure to ** pass the final allow mask, excluding any GPRs used for other inputs. ** In particular: 2-operand GPR instructions need to call ra_dest() first! */ static void asm_fuseahuref(ASMState *as, IRRef ref, RegSet allow) { IRIns *ir = IR(ref); if (ra_noreg(ir->r)) { switch ((IROp)ir->o) { case IR_AREF: if (mayfuse(as, ref)) { asm_fusearef(as, ir, allow); return; } break; case IR_HREFK: if (mayfuse(as, ref)) { as->mrm.base = (uint8_t)ra_alloc1(as, ir->op1, allow); as->mrm.ofs = (int32_t)(IR(ir->op2)->op2 * sizeof(Node)); as->mrm.idx = RID_NONE; return; } break; case IR_UREFC: if (irref_isk(ir->op1)) { GCfunc *fn = ir_kfunc(IR(ir->op1)); GCupval *uv = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv; as->mrm.ofs = ptr2addr(&uv->tv); as->mrm.base = as->mrm.idx = RID_NONE; return; } break; default: lua_assert(ir->o == IR_HREF || ir->o == IR_NEWREF || ir->o == IR_UREFO || ir->o == IR_KKPTR); break; } } as->mrm.base = (uint8_t)ra_alloc1(as, ref, allow); as->mrm.ofs = 0; as->mrm.idx = RID_NONE; } /* Fuse FLOAD/FREF reference into memory operand. */ static void asm_fusefref(ASMState *as, IRIns *ir, RegSet allow) { lua_assert(ir->o == IR_FLOAD || ir->o == IR_FREF); as->mrm.ofs = field_ofs[ir->op2]; as->mrm.idx = RID_NONE; if (irref_isk(ir->op1)) { as->mrm.ofs += IR(ir->op1)->i; as->mrm.base = RID_NONE; } else { as->mrm.base = (uint8_t)ra_alloc1(as, ir->op1, allow); } } /* Fuse string reference into memory operand. */ static void asm_fusestrref(ASMState *as, IRIns *ir, RegSet allow) { IRIns *irr; lua_assert(ir->o == IR_STRREF); as->mrm.base = as->mrm.idx = RID_NONE; as->mrm.scale = XM_SCALE1; as->mrm.ofs = sizeof(GCstr); if (irref_isk(ir->op1)) { as->mrm.ofs += IR(ir->op1)->i; } else { Reg r = ra_alloc1(as, ir->op1, allow); rset_clear(allow, r); as->mrm.base = (uint8_t)r; } irr = IR(ir->op2); if (irref_isk(ir->op2)) { as->mrm.ofs += irr->i; } else { Reg r; /* Fuse a constant add into the offset, e.g. string.sub(s, i+10). */ if (!LJ_64 && /* Has bad effects with negative index on x64. */ mayfuse(as, ir->op2) && irr->o == IR_ADD && irref_isk(irr->op2)) { as->mrm.ofs += IR(irr->op2)->i; r = ra_alloc1(as, irr->op1, allow); } else { r = ra_alloc1(as, ir->op2, allow); } if (as->mrm.base == RID_NONE) as->mrm.base = (uint8_t)r; else as->mrm.idx = (uint8_t)r; } } static void asm_fusexref(ASMState *as, IRRef ref, RegSet allow) { IRIns *ir = IR(ref); as->mrm.idx = RID_NONE; if (ir->o == IR_KPTR || ir->o == IR_KKPTR) { as->mrm.ofs = ir->i; as->mrm.base = RID_NONE; } else if (ir->o == IR_STRREF) { asm_fusestrref(as, ir, allow); } else { as->mrm.ofs = 0; if (canfuse(as, ir) && ir->o == IR_ADD && ra_noreg(ir->r)) { /* Gather (base+idx*sz)+ofs as emitted by cdata ptr/array indexing. */ IRIns *irx; IRRef idx; Reg r; if (asm_isk32(as, ir->op2, &as->mrm.ofs)) { /* Recognize x+ofs. */ ref = ir->op1; ir = IR(ref); if (!(ir->o == IR_ADD && canfuse(as, ir) && ra_noreg(ir->r))) goto noadd; } as->mrm.scale = XM_SCALE1; idx = ir->op1; ref = ir->op2; irx = IR(idx); if (!(irx->o == IR_BSHL || irx->o == IR_ADD)) { /* Try other operand. */ idx = ir->op2; ref = ir->op1; irx = IR(idx); } if (canfuse(as, irx) && ra_noreg(irx->r)) { if (irx->o == IR_BSHL && irref_isk(irx->op2) && IR(irx->op2)->i <= 3) { /* Recognize idx<op1; as->mrm.scale = (uint8_t)(IR(irx->op2)->i << 6); } else if (irx->o == IR_ADD && irx->op1 == irx->op2) { /* FOLD does idx*2 ==> idx<<1 ==> idx+idx. */ idx = irx->op1; as->mrm.scale = XM_SCALE2; } } r = ra_alloc1(as, idx, allow); rset_clear(allow, r); as->mrm.idx = (uint8_t)r; } noadd: as->mrm.base = (uint8_t)ra_alloc1(as, ref, allow); } } /* Fuse load into memory operand. */ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow) { IRIns *ir = IR(ref); if (ra_hasreg(ir->r)) { if (allow != RSET_EMPTY) { /* Fast path. */ ra_noweak(as, ir->r); return ir->r; } fusespill: /* Force a spill if only memory operands are allowed (asm_x87load). */ as->mrm.base = RID_ESP; as->mrm.ofs = ra_spill(as, ir); as->mrm.idx = RID_NONE; return RID_MRM; } if (ir->o == IR_KNUM) { RegSet avail = as->freeset & ~as->modset & RSET_FPR; lua_assert(allow != RSET_EMPTY); if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */ as->mrm.ofs = ptr2addr(ir_knum(ir)); as->mrm.base = as->mrm.idx = RID_NONE; return RID_MRM; } } else if (mayfuse(as, ref)) { RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR; if (ir->o == IR_SLOAD) { if (!(ir->op2 & (IRSLOAD_PARENT|IRSLOAD_CONVERT)) && noconflict(as, ref, IR_RETF, 0)) { as->mrm.base = (uint8_t)ra_alloc1(as, REF_BASE, xallow); as->mrm.ofs = 8*((int32_t)ir->op1-1) + ((ir->op2&IRSLOAD_FRAME)?4:0); as->mrm.idx = RID_NONE; return RID_MRM; } } else if (ir->o == IR_FLOAD) { /* Generic fusion is only ok for 32 bit operand (but see asm_comp). */ if ((irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)) && noconflict(as, ref, IR_FSTORE, 0)) { asm_fusefref(as, ir, xallow); return RID_MRM; } } else if (ir->o == IR_ALOAD || ir->o == IR_HLOAD || ir->o == IR_ULOAD) { if (noconflict(as, ref, ir->o + IRDELTA_L2S, 0)) { asm_fuseahuref(as, ir->op1, xallow); return RID_MRM; } } else if (ir->o == IR_XLOAD) { /* Generic fusion is not ok for 8/16 bit operands (but see asm_comp). ** Fusing unaligned memory operands is ok on x86 (except for SIMD types). */ if ((!irt_typerange(ir->t, IRT_I8, IRT_U16)) && noconflict(as, ref, IR_XSTORE, 0)) { asm_fusexref(as, ir->op1, xallow); return RID_MRM; } } else if (ir->o == IR_VLOAD) { asm_fuseahuref(as, ir->op1, xallow); return RID_MRM; } } if (!(as->freeset & allow) && (allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref))) goto fusespill; return ra_allocref(as, ref, allow); } #if LJ_64 /* Don't fuse a 32 bit load into a 64 bit operation. */ static Reg asm_fuseloadm(ASMState *as, IRRef ref, RegSet allow, int is64) { if (is64 && !irt_is64(IR(ref)->t)) return ra_alloc1(as, ref, allow); return asm_fuseload(as, ref, allow); } #else #define asm_fuseloadm(as, ref, allow, is64) asm_fuseload(as, (ref), (allow)) #endif /* -- Calls --------------------------------------------------------------- */ /* Count the required number of stack slots for a call. */ static int asm_count_call_slots(ASMState *as, const CCallInfo *ci, IRRef *args) { uint32_t i, nargs = CCI_NARGS(ci); int nslots = 0; #if LJ_64 if (LJ_ABI_WIN) { nslots = (int)(nargs*2); /* Only matters for more than four args. */ } else { int ngpr = REGARG_NUMGPR, nfpr = REGARG_NUMFPR; for (i = 0; i < nargs; i++) if (args[i] && irt_isfp(IR(args[i])->t)) { if (nfpr > 0) nfpr--; else nslots += 2; } else { if (ngpr > 0) ngpr--; else nslots += 2; } } #else int ngpr = 0; if ((ci->flags & CCI_CC_MASK) == CCI_CC_FASTCALL) ngpr = 2; else if ((ci->flags & CCI_CC_MASK) == CCI_CC_THISCALL) ngpr = 1; for (i = 0; i < nargs; i++) if (args[i] && irt_isfp(IR(args[i])->t)) { nslots += irt_isnum(IR(args[i])->t) ? 2 : 1; } else { if (ngpr > 0) ngpr--; else nslots++; } #endif return nslots; } /* Generate a call to a C function. */ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args) { uint32_t n, nargs = CCI_NARGS(ci); int32_t ofs = STACKARG_OFS; #if LJ_64 uint32_t gprs = REGARG_GPRS; Reg fpr = REGARG_FIRSTFPR; #if !LJ_ABI_WIN MCode *patchnfpr = NULL; #endif #else uint32_t gprs = 0; if ((ci->flags & CCI_CC_MASK) != CCI_CC_CDECL) { if ((ci->flags & CCI_CC_MASK) == CCI_CC_THISCALL) gprs = (REGARG_GPRS & 31); else if ((ci->flags & CCI_CC_MASK) == CCI_CC_FASTCALL) gprs = REGARG_GPRS; } #endif if ((void *)ci->func) emit_call(as, ci->func); #if LJ_64 if ((ci->flags & CCI_VARARG)) { /* Special handling for vararg calls. */ #if LJ_ABI_WIN for (n = 0; n < 4 && n < nargs; n++) { IRIns *ir = IR(args[n]); if (irt_isfp(ir->t)) /* Duplicate FPRs in GPRs. */ emit_rr(as, XO_MOVDto, (irt_isnum(ir->t) ? REX_64 : 0) | (fpr+n), ((gprs >> (n*5)) & 31)); /* Either MOVD or MOVQ. */ } #else patchnfpr = --as->mcp; /* Indicate number of used FPRs in register al. */ *--as->mcp = XI_MOVrib | RID_EAX; #endif } #endif for (n = 0; n < nargs; n++) { /* Setup args. */ IRRef ref = args[n]; IRIns *ir = IR(ref); Reg r; #if LJ_64 && LJ_ABI_WIN /* Windows/x64 argument registers are strictly positional. */ r = irt_isfp(ir->t) ? (fpr <= REGARG_LASTFPR ? fpr : 0) : (gprs & 31); fpr++; gprs >>= 5; #elif LJ_64 /* POSIX/x64 argument registers are used in order of appearance. */ if (irt_isfp(ir->t)) { r = fpr <= REGARG_LASTFPR ? fpr++ : 0; } else { r = gprs & 31; gprs >>= 5; } #else if (ref && irt_isfp(ir->t)) { r = 0; } else { r = gprs & 31; gprs >>= 5; if (!ref) continue; } #endif if (r) { /* Argument is in a register. */ if (r < RID_MAX_GPR && ref < ASMREF_TMP1) { #if LJ_64 if (ir->o == IR_KINT64) emit_loadu64(as, r, ir_kint64(ir)->u64); else #endif emit_loadi(as, r, ir->i); } else { lua_assert(rset_test(as->freeset, r)); /* Must have been evicted. */ if (ra_hasreg(ir->r)) { ra_noweak(as, ir->r); emit_movrr(as, ir, r, ir->r); } else { ra_allocref(as, ref, RID2RSET(r)); } } } else if (irt_isfp(ir->t)) { /* FP argument is on stack. */ lua_assert(!(irt_isfloat(ir->t) && irref_isk(ref))); /* No float k. */ if (LJ_32 && (ofs & 4) && irref_isk(ref)) { /* Split stores for unaligned FP consts. */ emit_movmroi(as, RID_ESP, ofs, (int32_t)ir_knum(ir)->u32.lo); emit_movmroi(as, RID_ESP, ofs+4, (int32_t)ir_knum(ir)->u32.hi); } else { r = ra_alloc1(as, ref, RSET_FPR); emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, r, RID_ESP, ofs); } ofs += (LJ_32 && irt_isfloat(ir->t)) ? 4 : 8; } else { /* Non-FP argument is on stack. */ if (LJ_32 && ref < ASMREF_TMP1) { emit_movmroi(as, RID_ESP, ofs, ir->i); } else { r = ra_alloc1(as, ref, RSET_GPR); emit_movtomro(as, REX_64 + r, RID_ESP, ofs); } ofs += sizeof(intptr_t); } } #if LJ_64 && !LJ_ABI_WIN if (patchnfpr) *patchnfpr = fpr - REGARG_FIRSTFPR; #endif } /* Setup result reg/sp for call. Evict scratch regs. */ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci) { RegSet drop = RSET_SCRATCH; int hiop = (LJ_32 && (ir+1)->o == IR_HIOP); if ((ci->flags & CCI_NOFPRCLOBBER)) drop &= ~RSET_FPR; if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ if (hiop && ra_hasreg((ir+1)->r)) rset_clear(drop, (ir+1)->r); /* Dest reg handled below. */ ra_evictset(as, drop); /* Evictions must be performed first. */ if (ra_used(ir)) { if (irt_isfp(ir->t)) { int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ #if LJ_64 if ((ci->flags & CCI_CASTU64)) { Reg dest = ir->r; if (ra_hasreg(dest)) { ra_free(as, dest); ra_modified(as, dest); emit_rr(as, XO_MOVD, dest|REX_64, RID_RET); /* Really MOVQ. */ } if (ofs) emit_movtomro(as, RID_RET|REX_64, RID_ESP, ofs); } else { ra_destreg(as, ir, RID_FPRET); } #else /* Number result is in x87 st0 for x86 calling convention. */ Reg dest = ir->r; if (ra_hasreg(dest)) { ra_free(as, dest); ra_modified(as, dest); emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, dest, RID_ESP, ofs); } if ((ci->flags & CCI_CASTU64)) { emit_movtomro(as, RID_RETLO, RID_ESP, ofs); emit_movtomro(as, RID_RETHI, RID_ESP, ofs+4); } else { emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); } #endif #if LJ_32 } else if (hiop) { ra_destpair(as, ir); #endif } else { lua_assert(!irt_ispri(ir->t)); ra_destreg(as, ir, RID_RET); } } else if (LJ_32 && irt_isfp(ir->t)) { emit_x87op(as, XI_FPOP); /* Pop unused result from x87 st0. */ } } static void asm_call(ASMState *as, IRIns *ir) { IRRef args[CCI_NARGS_MAX]; const CCallInfo *ci = &lj_ir_callinfo[ir->op2]; asm_collectargs(as, ir, ci, args); asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } /* Return a constant function pointer or NULL for indirect calls. */ static void *asm_callx_func(ASMState *as, IRIns *irf, IRRef func) { #if LJ_32 UNUSED(as); if (irref_isk(func)) return (void *)irf->i; #else if (irref_isk(func)) { MCode *p; if (irf->o == IR_KINT64) p = (MCode *)(void *)ir_k64(irf)->u64; else p = (MCode *)(void *)(uintptr_t)(uint32_t)irf->i; if (p - as->mcp == (int32_t)(p - as->mcp)) return p; /* Call target is still in +-2GB range. */ /* Avoid the indirect case of emit_call(). Try to hoist func addr. */ } #endif return NULL; } static void asm_callx(ASMState *as, IRIns *ir) { IRRef args[CCI_NARGS_MAX]; CCallInfo ci; IRRef func; IRIns *irf; int32_t spadj = 0; ci.flags = asm_callx_flags(as, ir); asm_collectargs(as, ir, &ci, args); asm_setupresult(as, ir, &ci); #if LJ_32 /* Have to readjust stack after non-cdecl calls due to callee cleanup. */ if ((ci.flags & CCI_CC_MASK) != CCI_CC_CDECL) spadj = 4 * asm_count_call_slots(as, &ci, args); #endif func = ir->op2; irf = IR(func); if (irf->o == IR_CARG) { func = irf->op1; irf = IR(func); } ci.func = (ASMFunction)asm_callx_func(as, irf, func); if (!(void *)ci.func) { /* Use a (hoistable) non-scratch register for indirect calls. */ RegSet allow = (RSET_GPR & ~RSET_SCRATCH); Reg r = ra_alloc1(as, func, allow); if (LJ_32) emit_spsub(as, spadj); /* Above code may cause restores! */ emit_rr(as, XO_GROUP5, XOg_CALL, r); } else if (LJ_32) { emit_spsub(as, spadj); } asm_gencall(as, &ci, args); } /* -- Returns ------------------------------------------------------------- */ /* Return to lower frame. Guard that it goes to the right spot. */ static void asm_retf(ASMState *as, IRIns *ir) { Reg base = ra_alloc1(as, REF_BASE, RSET_GPR); void *pc = ir_kptr(IR(ir->op2)); int32_t delta = 1+bc_a(*((const BCIns *)pc - 1)); as->topslot -= (BCReg)delta; if ((int32_t)as->topslot < 0) as->topslot = 0; emit_setgl(as, base, jit_base); emit_addptr(as, base, -8*delta); asm_guardcc(as, CC_NE); emit_gmroi(as, XG_ARITHi(XOg_CMP), base, -4, ptr2addr(pc)); } /* -- Type conversions ---------------------------------------------------- */ static void asm_tointg(ASMState *as, IRIns *ir, Reg left) { Reg tmp = ra_scratch(as, rset_exclude(RSET_FPR, left)); Reg dest = ra_dest(as, ir, RSET_GPR); asm_guardcc(as, CC_P); asm_guardcc(as, CC_NE); emit_rr(as, XO_UCOMISD, left, tmp); emit_rr(as, XO_CVTSI2SD, tmp, dest); if (!(as->flags & JIT_F_SPLIT_XMM)) emit_rr(as, XO_XORPS, tmp, tmp); /* Avoid partial register stall. */ emit_rr(as, XO_CVTTSD2SI, dest, left); /* Can't fuse since left is needed twice. */ } static void asm_tobit(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); Reg tmp = ra_noreg(IR(ir->op1)->r) ? ra_alloc1(as, ir->op1, RSET_FPR) : ra_scratch(as, RSET_FPR); Reg right = asm_fuseload(as, ir->op2, rset_exclude(RSET_FPR, tmp)); emit_rr(as, XO_MOVDto, tmp, dest); emit_mrm(as, XO_ADDSD, tmp, right); ra_left(as, tmp, ir->op1); } static void asm_conv(ASMState *as, IRIns *ir) { IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); int st64 = (st == IRT_I64 || st == IRT_U64 || (LJ_64 && st == IRT_P64)); int stfp = (st == IRT_NUM || st == IRT_FLOAT); IRRef lref = ir->op1; lua_assert(irt_type(ir->t) != st); lua_assert(!(LJ_32 && (irt_isint64(ir->t) || st64))); /* Handled by SPLIT. */ if (irt_isfp(ir->t)) { Reg dest = ra_dest(as, ir, RSET_FPR); if (stfp) { /* FP to FP conversion. */ Reg left = asm_fuseload(as, lref, RSET_FPR); emit_mrm(as, st == IRT_NUM ? XO_CVTSD2SS : XO_CVTSS2SD, dest, left); if (left == dest) return; /* Avoid the XO_XORPS. */ } else if (LJ_32 && st == IRT_U32) { /* U32 to FP conversion on x86. */ /* number = (2^52+2^51 .. u32) - (2^52+2^51) */ cTValue *k = lj_ir_k64_find(as->J, U64x(43380000,00000000)); Reg bias = ra_scratch(as, rset_exclude(RSET_FPR, dest)); if (irt_isfloat(ir->t)) emit_rr(as, XO_CVTSD2SS, dest, dest); emit_rr(as, XO_SUBSD, dest, bias); /* Subtract 2^52+2^51 bias. */ emit_rr(as, XO_XORPS, dest, bias); /* Merge bias and integer. */ emit_loadn(as, bias, k); emit_mrm(as, XO_MOVD, dest, asm_fuseload(as, lref, RSET_GPR)); return; } else { /* Integer to FP conversion. */ Reg left = (LJ_64 && (st == IRT_U32 || st == IRT_U64)) ? ra_alloc1(as, lref, RSET_GPR) : asm_fuseloadm(as, lref, RSET_GPR, st64); if (LJ_64 && st == IRT_U64) { MCLabel l_end = emit_label(as); const void *k = lj_ir_k64_find(as->J, U64x(43f00000,00000000)); emit_rma(as, XO_ADDSD, dest, k); /* Add 2^64 to compensate. */ emit_sjcc(as, CC_NS, l_end); emit_rr(as, XO_TEST, left|REX_64, left); /* Check if u64 >= 2^63. */ } emit_mrm(as, irt_isnum(ir->t) ? XO_CVTSI2SD : XO_CVTSI2SS, dest|((LJ_64 && (st64 || st == IRT_U32)) ? REX_64 : 0), left); } if (!(as->flags & JIT_F_SPLIT_XMM)) emit_rr(as, XO_XORPS, dest, dest); /* Avoid partial register stall. */ } else if (stfp) { /* FP to integer conversion. */ if (irt_isguard(ir->t)) { /* Checked conversions are only supported from number to int. */ lua_assert(irt_isint(ir->t) && st == IRT_NUM); asm_tointg(as, ir, ra_alloc1(as, lref, RSET_FPR)); } else { Reg dest = ra_dest(as, ir, RSET_GPR); x86Op op = st == IRT_NUM ? ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSD2SI : XO_CVTSD2SI) : ((ir->op2 & IRCONV_TRUNC) ? XO_CVTTSS2SI : XO_CVTSS2SI); if (LJ_64 ? irt_isu64(ir->t) : irt_isu32(ir->t)) { /* LJ_64: For inputs >= 2^63 add -2^64, convert again. */ /* LJ_32: For inputs >= 2^31 add -2^31, convert again and add 2^31. */ Reg tmp = ra_noreg(IR(lref)->r) ? ra_alloc1(as, lref, RSET_FPR) : ra_scratch(as, RSET_FPR); MCLabel l_end = emit_label(as); if (LJ_32) emit_gri(as, XG_ARITHi(XOg_ADD), dest, (int32_t)0x80000000); emit_rr(as, op, dest|REX_64, tmp); if (st == IRT_NUM) emit_rma(as, XO_ADDSD, tmp, lj_ir_k64_find(as->J, LJ_64 ? U64x(c3f00000,00000000) : U64x(c1e00000,00000000))); else emit_rma(as, XO_ADDSS, tmp, lj_ir_k64_find(as->J, LJ_64 ? U64x(00000000,df800000) : U64x(00000000,cf000000))); emit_sjcc(as, CC_NS, l_end); emit_rr(as, XO_TEST, dest|REX_64, dest); /* Check if dest negative. */ emit_rr(as, op, dest|REX_64, tmp); ra_left(as, tmp, lref); } else { Reg left = asm_fuseload(as, lref, RSET_FPR); if (LJ_64 && irt_isu32(ir->t)) emit_rr(as, XO_MOV, dest, dest); /* Zero hiword. */ emit_mrm(as, op, dest|((LJ_64 && (irt_is64(ir->t) || irt_isu32(ir->t))) ? REX_64 : 0), left); } } } else if (st >= IRT_I8 && st <= IRT_U16) { /* Extend to 32 bit integer. */ Reg left, dest = ra_dest(as, ir, RSET_GPR); RegSet allow = RSET_GPR; x86Op op; lua_assert(irt_isint(ir->t) || irt_isu32(ir->t)); if (st == IRT_I8) { op = XO_MOVSXb; allow = RSET_GPR8; dest |= FORCE_REX; } else if (st == IRT_U8) { op = XO_MOVZXb; allow = RSET_GPR8; dest |= FORCE_REX; } else if (st == IRT_I16) { op = XO_MOVSXw; } else { op = XO_MOVZXw; } left = asm_fuseload(as, lref, allow); /* Add extra MOV if source is already in wrong register. */ if (!LJ_64 && left != RID_MRM && !rset_test(allow, left)) { Reg tmp = ra_scratch(as, allow); emit_rr(as, op, dest, tmp); emit_rr(as, XO_MOV, tmp, left); } else { emit_mrm(as, op, dest, left); } } else { /* 32/64 bit integer conversions. */ if (LJ_32) { /* Only need to handle 32/32 bit no-op (cast) on x86. */ Reg dest = ra_dest(as, ir, RSET_GPR); ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ } else if (irt_is64(ir->t)) { Reg dest = ra_dest(as, ir, RSET_GPR); if (st64 || !(ir->op2 & IRCONV_SEXT)) { /* 64/64 bit no-op (cast) or 32 to 64 bit zero extension. */ ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ } else { /* 32 to 64 bit sign extension. */ Reg left = asm_fuseload(as, lref, RSET_GPR); emit_mrm(as, XO_MOVSXd, dest|REX_64, left); } } else { Reg dest = ra_dest(as, ir, RSET_GPR); if (st64) { Reg left = asm_fuseload(as, lref, RSET_GPR); /* This is either a 32 bit reg/reg mov which zeroes the hiword ** or a load of the loword from a 64 bit address. */ emit_mrm(as, XO_MOV, dest, left); } else { /* 32/32 bit no-op (cast). */ ra_left(as, dest, lref); /* Do nothing, but may need to move regs. */ } } } } #if LJ_32 && LJ_HASFFI /* No SSE conversions to/from 64 bit on x86, so resort to ugly x87 code. */ /* 64 bit integer to FP conversion in 32 bit mode. */ static void asm_conv_fp_int64(ASMState *as, IRIns *ir) { Reg hi = ra_alloc1(as, ir->op1, RSET_GPR); Reg lo = ra_alloc1(as, (ir-1)->op1, rset_exclude(RSET_GPR, hi)); int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ Reg dest = ir->r; if (ra_hasreg(dest)) { ra_free(as, dest); ra_modified(as, dest); emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, dest, RID_ESP, ofs); } emit_rmro(as, irt_isnum(ir->t) ? XO_FSTPq : XO_FSTPd, irt_isnum(ir->t) ? XOg_FSTPq : XOg_FSTPd, RID_ESP, ofs); if (((ir-1)->op2 & IRCONV_SRCMASK) == IRT_U64) { /* For inputs in [2^63,2^64-1] add 2^64 to compensate. */ MCLabel l_end = emit_label(as); emit_rma(as, XO_FADDq, XOg_FADDq, lj_ir_k64_find(as->J, U64x(43f00000,00000000))); emit_sjcc(as, CC_NS, l_end); emit_rr(as, XO_TEST, hi, hi); /* Check if u64 >= 2^63. */ } else { lua_assert(((ir-1)->op2 & IRCONV_SRCMASK) == IRT_I64); } emit_rmro(as, XO_FILDq, XOg_FILDq, RID_ESP, 0); /* NYI: Avoid narrow-to-wide store-to-load forwarding stall. */ emit_rmro(as, XO_MOVto, hi, RID_ESP, 4); emit_rmro(as, XO_MOVto, lo, RID_ESP, 0); } /* FP to 64 bit integer conversion in 32 bit mode. */ static void asm_conv_int64_fp(ASMState *as, IRIns *ir) { IRType st = (IRType)((ir-1)->op2 & IRCONV_SRCMASK); IRType dt = (((ir-1)->op2 & IRCONV_DSTMASK) >> IRCONV_DSH); Reg lo, hi; lua_assert(st == IRT_NUM || st == IRT_FLOAT); lua_assert(dt == IRT_I64 || dt == IRT_U64); lua_assert(((ir-1)->op2 & IRCONV_TRUNC)); hi = ra_dest(as, ir, RSET_GPR); lo = ra_dest(as, ir-1, rset_exclude(RSET_GPR, hi)); if (ra_used(ir-1)) emit_rmro(as, XO_MOV, lo, RID_ESP, 0); /* NYI: Avoid wide-to-narrow store-to-load forwarding stall. */ if (!(as->flags & JIT_F_SSE3)) { /* Set FPU rounding mode to default. */ emit_rmro(as, XO_FLDCW, XOg_FLDCW, RID_ESP, 4); emit_rmro(as, XO_MOVto, lo, RID_ESP, 4); emit_gri(as, XG_ARITHi(XOg_AND), lo, 0xf3ff); } if (dt == IRT_U64) { /* For inputs in [2^63,2^64-1] add -2^64 and convert again. */ MCLabel l_pop, l_end = emit_label(as); emit_x87op(as, XI_FPOP); l_pop = emit_label(as); emit_sjmp(as, l_end); emit_rmro(as, XO_MOV, hi, RID_ESP, 4); if ((as->flags & JIT_F_SSE3)) emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0); else emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0); emit_rma(as, XO_FADDq, XOg_FADDq, lj_ir_k64_find(as->J, U64x(c3f00000,00000000))); emit_sjcc(as, CC_NS, l_pop); emit_rr(as, XO_TEST, hi, hi); /* Check if out-of-range (2^63). */ } emit_rmro(as, XO_MOV, hi, RID_ESP, 4); if ((as->flags & JIT_F_SSE3)) { /* Truncation is easy with SSE3. */ emit_rmro(as, XO_FISTTPq, XOg_FISTTPq, RID_ESP, 0); } else { /* Otherwise set FPU rounding mode to truncate before the store. */ emit_rmro(as, XO_FISTPq, XOg_FISTPq, RID_ESP, 0); emit_rmro(as, XO_FLDCW, XOg_FLDCW, RID_ESP, 0); emit_rmro(as, XO_MOVtow, lo, RID_ESP, 0); emit_rmro(as, XO_ARITHw(XOg_OR), lo, RID_ESP, 0); emit_loadi(as, lo, 0xc00); emit_rmro(as, XO_FNSTCW, XOg_FNSTCW, RID_ESP, 0); } if (dt == IRT_U64) emit_x87op(as, XI_FDUP); emit_mrm(as, st == IRT_NUM ? XO_FLDq : XO_FLDd, st == IRT_NUM ? XOg_FLDq: XOg_FLDd, asm_fuseload(as, ir->op1, RSET_EMPTY)); } #endif static void asm_strto(ASMState *as, IRIns *ir) { /* Force a spill slot for the destination register (if any). */ const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_strscan_num]; IRRef args[2]; RegSet drop = RSET_SCRATCH; if ((drop & RSET_FPR) != RSET_FPR && ra_hasreg(ir->r)) rset_set(drop, ir->r); /* WIN64 doesn't spill all FPRs. */ ra_evictset(as, drop); asm_guardcc(as, CC_E); emit_rr(as, XO_TEST, RID_RET, RID_RET); /* Test return status. */ args[0] = ir->op1; /* GCstr *str */ args[1] = ASMREF_TMP1; /* TValue *n */ asm_gencall(as, ci, args); /* Store the result to the spill slot or temp slots. */ emit_rmro(as, XO_LEA, ra_releasetmp(as, ASMREF_TMP1)|REX_64, RID_ESP, sps_scale(ir->s)); } static void asm_tostr(ASMState *as, IRIns *ir) { IRIns *irl = IR(ir->op1); IRRef args[2]; args[0] = ASMREF_L; as->gcsteps++; if (irt_isnum(irl->t)) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum]; args[1] = ASMREF_TMP1; /* const lua_Number * */ asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); emit_rmro(as, XO_LEA, ra_releasetmp(as, ASMREF_TMP1)|REX_64, RID_ESP, ra_spill(as, irl)); } else { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint]; args[1] = ir->op1; /* int32_t k */ asm_setupresult(as, ir, ci); /* GCstr * */ asm_gencall(as, ci, args); } } /* -- Memory references --------------------------------------------------- */ static void asm_aref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); asm_fusearef(as, ir, RSET_GPR); if (!(as->mrm.idx == RID_NONE && as->mrm.ofs == 0)) emit_mrm(as, XO_LEA, dest, RID_MRM); else if (as->mrm.base != dest) emit_rr(as, XO_MOV, dest, as->mrm.base); } /* Merge NE(HREF, niltv) check. */ static MCode *merge_href_niltv(ASMState *as, IRIns *ir) { /* Assumes nothing else generates NE of HREF. */ if ((ir[1].o == IR_NE || ir[1].o == IR_EQ) && ir[1].op1 == as->curins && ra_hasreg(ir->r)) { MCode *p = as->mcp; p += (LJ_64 && *p != XI_ARITHi) ? 7+6 : 6+6; /* Ensure no loop branch inversion happened. */ if (p[-6] == 0x0f && p[-5] == XI_JCCn+(CC_NE^(ir[1].o & 1))) { as->mcp = p; /* Kill cmp reg, imm32 + jz exit. */ return p + *(int32_t *)(p-4); /* Return exit address. */ } } return NULL; } /* Inlined hash lookup. Specialized for key type and for const keys. ** The equivalent C code is: ** Node *n = hashkey(t, key); ** do { ** if (lj_obj_equal(&n->key, key)) return &n->val; ** } while ((n = nextnode(n))); ** return niltv(L); */ static void asm_href(ASMState *as, IRIns *ir) { MCode *nilexit = merge_href_niltv(as, ir); /* Do this before any restores. */ RegSet allow = RSET_GPR; Reg dest = ra_dest(as, ir, allow); Reg tab = ra_alloc1(as, ir->op1, rset_clear(allow, dest)); Reg key = RID_NONE, tmp = RID_NONE; IRIns *irkey = IR(ir->op2); int isk = irref_isk(ir->op2); IRType1 kt = irkey->t; uint32_t khash; MCLabel l_end, l_loop, l_next; if (!isk) { rset_clear(allow, tab); key = ra_alloc1(as, ir->op2, irt_isnum(kt) ? RSET_FPR : allow); if (!irt_isstr(kt)) tmp = ra_scratch(as, rset_exclude(allow, key)); } /* Key not found in chain: jump to exit (if merged with NE) or load niltv. */ l_end = emit_label(as); if (nilexit && ir[1].o == IR_NE) { emit_jcc(as, CC_E, nilexit); /* XI_JMP is not found by lj_asm_patchexit. */ nilexit = NULL; } else { emit_loada(as, dest, niltvg(J2G(as->J))); } /* Follow hash chain until the end. */ l_loop = emit_sjcc_label(as, CC_NZ); emit_rr(as, XO_TEST, dest, dest); emit_rmro(as, XO_MOV, dest, dest, offsetof(Node, next)); l_next = emit_label(as); /* Type and value comparison. */ if (nilexit) emit_jcc(as, CC_E, nilexit); else emit_sjcc(as, CC_E, l_end); if (irt_isnum(kt)) { if (isk) { /* Assumes -0.0 is already canonicalized to +0.0. */ emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.u32.lo), (int32_t)ir_knum(irkey)->u32.lo); emit_sjcc(as, CC_NE, l_next); emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.u32.hi), (int32_t)ir_knum(irkey)->u32.hi); } else { emit_sjcc(as, CC_P, l_next); emit_rmro(as, XO_UCOMISD, key, dest, offsetof(Node, key.n)); emit_sjcc(as, CC_AE, l_next); /* The type check avoids NaN penalties and complaints from Valgrind. */ #if LJ_64 emit_u32(as, LJ_TISNUM); emit_rmro(as, XO_ARITHi, XOg_CMP, dest, offsetof(Node, key.it)); #else emit_i8(as, LJ_TISNUM); emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it)); #endif } #if LJ_64 } else if (irt_islightud(kt)) { emit_rmro(as, XO_CMP, key|REX_64, dest, offsetof(Node, key.u64)); #endif } else { if (!irt_ispri(kt)) { lua_assert(irt_isaddr(kt)); if (isk) emit_gmroi(as, XG_ARITHi(XOg_CMP), dest, offsetof(Node, key.gcr), ptr2addr(ir_kgc(irkey))); else emit_rmro(as, XO_CMP, key, dest, offsetof(Node, key.gcr)); emit_sjcc(as, CC_NE, l_next); } lua_assert(!irt_isnil(kt)); emit_i8(as, irt_toitype(kt)); emit_rmro(as, XO_ARITHi8, XOg_CMP, dest, offsetof(Node, key.it)); } emit_sfixup(as, l_loop); checkmclim(as); /* Load main position relative to tab->node into dest. */ khash = isk ? ir_khash(irkey) : 1; if (khash == 0) { emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, node)); } else { emit_rmro(as, XO_ARITH(XOg_ADD), dest, tab, offsetof(GCtab, node)); if ((as->flags & JIT_F_PREFER_IMUL)) { emit_i8(as, sizeof(Node)); emit_rr(as, XO_IMULi8, dest, dest); } else { emit_shifti(as, XOg_SHL, dest, 3); emit_rmrxo(as, XO_LEA, dest, dest, dest, XM_SCALE2, 0); } if (isk) { emit_gri(as, XG_ARITHi(XOg_AND), dest, (int32_t)khash); emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask)); } else if (irt_isstr(kt)) { emit_rmro(as, XO_ARITH(XOg_AND), dest, key, offsetof(GCstr, hash)); emit_rmro(as, XO_MOV, dest, tab, offsetof(GCtab, hmask)); } else { /* Must match with hashrot() in lj_tab.c. */ emit_rmro(as, XO_ARITH(XOg_AND), dest, tab, offsetof(GCtab, hmask)); emit_rr(as, XO_ARITH(XOg_SUB), dest, tmp); emit_shifti(as, XOg_ROL, tmp, HASH_ROT3); emit_rr(as, XO_ARITH(XOg_XOR), dest, tmp); emit_shifti(as, XOg_ROL, dest, HASH_ROT2); emit_rr(as, XO_ARITH(XOg_SUB), tmp, dest); emit_shifti(as, XOg_ROL, dest, HASH_ROT1); emit_rr(as, XO_ARITH(XOg_XOR), tmp, dest); if (irt_isnum(kt)) { emit_rr(as, XO_ARITH(XOg_ADD), dest, dest); #if LJ_64 emit_shifti(as, XOg_SHR|REX_64, dest, 32); emit_rr(as, XO_MOV, tmp, dest); emit_rr(as, XO_MOVDto, key|REX_64, dest); #else emit_rmro(as, XO_MOV, dest, RID_ESP, ra_spill(as, irkey)+4); emit_rr(as, XO_MOVDto, key, tmp); #endif } else { emit_rr(as, XO_MOV, tmp, key); emit_rmro(as, XO_LEA, dest, key, HASH_BIAS); } } } } static void asm_hrefk(ASMState *as, IRIns *ir) { IRIns *kslot = IR(ir->op2); IRIns *irkey = IR(kslot->op1); int32_t ofs = (int32_t)(kslot->op2 * sizeof(Node)); Reg dest = ra_used(ir) ? ra_dest(as, ir, RSET_GPR) : RID_NONE; Reg node = ra_alloc1(as, ir->op1, RSET_GPR); #if !LJ_64 MCLabel l_exit; #endif lua_assert(ofs % sizeof(Node) == 0); if (ra_hasreg(dest)) { if (ofs != 0) { if (dest == node && !(as->flags & JIT_F_LEA_AGU)) emit_gri(as, XG_ARITHi(XOg_ADD), dest, ofs); else emit_rmro(as, XO_LEA, dest, node, ofs); } else if (dest != node) { emit_rr(as, XO_MOV, dest, node); } } asm_guardcc(as, CC_NE); #if LJ_64 if (!irt_ispri(irkey->t)) { Reg key = ra_scratch(as, rset_exclude(RSET_GPR, node)); emit_rmro(as, XO_CMP, key|REX_64, node, ofs + (int32_t)offsetof(Node, key.u64)); lua_assert(irt_isnum(irkey->t) || irt_isgcv(irkey->t)); /* Assumes -0.0 is already canonicalized to +0.0. */ emit_loadu64(as, key, irt_isnum(irkey->t) ? ir_knum(irkey)->u64 : ((uint64_t)irt_toitype(irkey->t) << 32) | (uint64_t)(uint32_t)ptr2addr(ir_kgc(irkey))); } else { lua_assert(!irt_isnil(irkey->t)); emit_i8(as, irt_toitype(irkey->t)); emit_rmro(as, XO_ARITHi8, XOg_CMP, node, ofs + (int32_t)offsetof(Node, key.it)); } #else l_exit = emit_label(as); if (irt_isnum(irkey->t)) { /* Assumes -0.0 is already canonicalized to +0.0. */ emit_gmroi(as, XG_ARITHi(XOg_CMP), node, ofs + (int32_t)offsetof(Node, key.u32.lo), (int32_t)ir_knum(irkey)->u32.lo); emit_sjcc(as, CC_NE, l_exit); emit_gmroi(as, XG_ARITHi(XOg_CMP), node, ofs + (int32_t)offsetof(Node, key.u32.hi), (int32_t)ir_knum(irkey)->u32.hi); } else { if (!irt_ispri(irkey->t)) { lua_assert(irt_isgcv(irkey->t)); emit_gmroi(as, XG_ARITHi(XOg_CMP), node, ofs + (int32_t)offsetof(Node, key.gcr), ptr2addr(ir_kgc(irkey))); emit_sjcc(as, CC_NE, l_exit); } lua_assert(!irt_isnil(irkey->t)); emit_i8(as, irt_toitype(irkey->t)); emit_rmro(as, XO_ARITHi8, XOg_CMP, node, ofs + (int32_t)offsetof(Node, key.it)); } #endif } static void asm_newref(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_tab_newkey]; IRRef args[3]; IRIns *irkey; Reg tmp; if (ir->r == RID_SINK) return; args[0] = ASMREF_L; /* lua_State *L */ args[1] = ir->op1; /* GCtab *t */ args[2] = ASMREF_TMP1; /* cTValue *key */ asm_setupresult(as, ir, ci); /* TValue * */ asm_gencall(as, ci, args); tmp = ra_releasetmp(as, ASMREF_TMP1); irkey = IR(ir->op2); if (irt_isnum(irkey->t)) { /* For numbers use the constant itself or a spill slot as a TValue. */ if (irref_isk(ir->op2)) emit_loada(as, tmp, ir_knum(irkey)); else emit_rmro(as, XO_LEA, tmp|REX_64, RID_ESP, ra_spill(as, irkey)); } else { /* Otherwise use g->tmptv to hold the TValue. */ if (!irref_isk(ir->op2)) { Reg src = ra_alloc1(as, ir->op2, rset_exclude(RSET_GPR, tmp)); emit_movtomro(as, REX_64IR(irkey, src), tmp, 0); } else if (!irt_ispri(irkey->t)) { emit_movmroi(as, tmp, 0, irkey->i); } if (!(LJ_64 && irt_islightud(irkey->t))) emit_movmroi(as, tmp, 4, irt_toitype(irkey->t)); emit_loada(as, tmp, &J2G(as->J)->tmptv); } } static void asm_uref(ASMState *as, IRIns *ir) { /* NYI: Check that UREFO is still open and not aliasing a slot. */ Reg dest = ra_dest(as, ir, RSET_GPR); if (irref_isk(ir->op1)) { GCfunc *fn = ir_kfunc(IR(ir->op1)); MRef *v = &gcref(fn->l.uvptr[(ir->op2 >> 8)])->uv.v; emit_rma(as, XO_MOV, dest, v); } else { Reg uv = ra_scratch(as, RSET_GPR); Reg func = ra_alloc1(as, ir->op1, RSET_GPR); if (ir->o == IR_UREFC) { emit_rmro(as, XO_LEA, dest, uv, offsetof(GCupval, tv)); asm_guardcc(as, CC_NE); emit_i8(as, 1); emit_rmro(as, XO_ARITHib, XOg_CMP, uv, offsetof(GCupval, closed)); } else { emit_rmro(as, XO_MOV, dest, uv, offsetof(GCupval, v)); } emit_rmro(as, XO_MOV, uv, func, (int32_t)offsetof(GCfuncL, uvptr) + 4*(int32_t)(ir->op2 >> 8)); } } static void asm_fref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); asm_fusefref(as, ir, RSET_GPR); emit_mrm(as, XO_LEA, dest, RID_MRM); } static void asm_strref(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); asm_fusestrref(as, ir, RSET_GPR); if (as->mrm.base == RID_NONE) emit_loadi(as, dest, as->mrm.ofs); else if (as->mrm.base == dest && as->mrm.idx == RID_NONE) emit_gri(as, XG_ARITHi(XOg_ADD), dest, as->mrm.ofs); else emit_mrm(as, XO_LEA, dest, RID_MRM); } /* -- Loads and stores ---------------------------------------------------- */ static void asm_fxload(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); x86Op xo; if (ir->o == IR_FLOAD) asm_fusefref(as, ir, RSET_GPR); else asm_fusexref(as, ir->op1, RSET_GPR); /* ir->op2 is ignored -- unaligned loads are ok on x86. */ switch (irt_type(ir->t)) { case IRT_I8: xo = XO_MOVSXb; break; case IRT_U8: xo = XO_MOVZXb; break; case IRT_I16: xo = XO_MOVSXw; break; case IRT_U16: xo = XO_MOVZXw; break; case IRT_NUM: xo = XMM_MOVRM(as); break; case IRT_FLOAT: xo = XO_MOVSS; break; default: if (LJ_64 && irt_is64(ir->t)) dest |= REX_64; else lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); xo = XO_MOV; break; } emit_mrm(as, xo, dest, RID_MRM); } static void asm_fxstore(ASMState *as, IRIns *ir) { RegSet allow = RSET_GPR; Reg src = RID_NONE, osrc = RID_NONE; int32_t k = 0; if (ir->r == RID_SINK) return; /* The IRT_I16/IRT_U16 stores should never be simplified for constant ** values since mov word [mem], imm16 has a length-changing prefix. */ if (irt_isi16(ir->t) || irt_isu16(ir->t) || irt_isfp(ir->t) || !asm_isk32(as, ir->op2, &k)) { RegSet allow8 = irt_isfp(ir->t) ? RSET_FPR : (irt_isi8(ir->t) || irt_isu8(ir->t)) ? RSET_GPR8 : RSET_GPR; src = osrc = ra_alloc1(as, ir->op2, allow8); if (!LJ_64 && !rset_test(allow8, src)) { /* Already in wrong register. */ rset_clear(allow, osrc); src = ra_scratch(as, allow8); } rset_clear(allow, src); } if (ir->o == IR_FSTORE) { asm_fusefref(as, IR(ir->op1), allow); } else { asm_fusexref(as, ir->op1, allow); if (LJ_32 && ir->o == IR_HIOP) as->mrm.ofs += 4; } if (ra_hasreg(src)) { x86Op xo; switch (irt_type(ir->t)) { case IRT_I8: case IRT_U8: xo = XO_MOVtob; src |= FORCE_REX; break; case IRT_I16: case IRT_U16: xo = XO_MOVtow; break; case IRT_NUM: xo = XO_MOVSDto; break; case IRT_FLOAT: xo = XO_MOVSSto; break; #if LJ_64 case IRT_LIGHTUD: lua_assert(0); /* NYI: mask 64 bit lightuserdata. */ #endif default: if (LJ_64 && irt_is64(ir->t)) src |= REX_64; else lua_assert(irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); xo = XO_MOVto; break; } emit_mrm(as, xo, src, RID_MRM); if (!LJ_64 && src != osrc) { ra_noweak(as, osrc); emit_rr(as, XO_MOV, src, osrc); } } else { if (irt_isi8(ir->t) || irt_isu8(ir->t)) { emit_i8(as, k); emit_mrm(as, XO_MOVmib, 0, RID_MRM); } else { lua_assert(irt_is64(ir->t) || irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t)); emit_i32(as, k); emit_mrm(as, XO_MOVmi, REX_64IR(ir, 0), RID_MRM); } } } #if LJ_64 static Reg asm_load_lightud64(ASMState *as, IRIns *ir, int typecheck) { if (ra_used(ir) || typecheck) { Reg dest = ra_dest(as, ir, RSET_GPR); if (typecheck) { Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, dest)); asm_guardcc(as, CC_NE); emit_i8(as, -2); emit_rr(as, XO_ARITHi8, XOg_CMP, tmp); emit_shifti(as, XOg_SAR|REX_64, tmp, 47); emit_rr(as, XO_MOV, tmp|REX_64, dest); } return dest; } else { return RID_NONE; } } #endif static void asm_ahuvload(ASMState *as, IRIns *ir) { lua_assert(irt_isnum(ir->t) || irt_ispri(ir->t) || irt_isaddr(ir->t) || (LJ_DUALNUM && irt_isint(ir->t))); #if LJ_64 if (irt_islightud(ir->t)) { Reg dest = asm_load_lightud64(as, ir, 1); if (ra_hasreg(dest)) { asm_fuseahuref(as, ir->op1, RSET_GPR); emit_mrm(as, XO_MOV, dest|REX_64, RID_MRM); } return; } else #endif if (ra_used(ir)) { RegSet allow = irt_isnum(ir->t) ? RSET_FPR : RSET_GPR; Reg dest = ra_dest(as, ir, allow); asm_fuseahuref(as, ir->op1, RSET_GPR); emit_mrm(as, dest < RID_MAX_GPR ? XO_MOV : XMM_MOVRM(as), dest, RID_MRM); } else { asm_fuseahuref(as, ir->op1, RSET_GPR); } /* Always do the type check, even if the load result is unused. */ as->mrm.ofs += 4; asm_guardcc(as, irt_isnum(ir->t) ? CC_AE : CC_NE); if (LJ_64 && irt_type(ir->t) >= IRT_NUM) { lua_assert(irt_isinteger(ir->t) || irt_isnum(ir->t)); emit_u32(as, LJ_TISNUM); emit_mrm(as, XO_ARITHi, XOg_CMP, RID_MRM); } else { emit_i8(as, irt_toitype(ir->t)); emit_mrm(as, XO_ARITHi8, XOg_CMP, RID_MRM); } } static void asm_ahustore(ASMState *as, IRIns *ir) { if (ir->r == RID_SINK) return; if (irt_isnum(ir->t)) { Reg src = ra_alloc1(as, ir->op2, RSET_FPR); asm_fuseahuref(as, ir->op1, RSET_GPR); emit_mrm(as, XO_MOVSDto, src, RID_MRM); #if LJ_64 } else if (irt_islightud(ir->t)) { Reg src = ra_alloc1(as, ir->op2, RSET_GPR); asm_fuseahuref(as, ir->op1, rset_exclude(RSET_GPR, src)); emit_mrm(as, XO_MOVto, src|REX_64, RID_MRM); #endif } else { IRIns *irr = IR(ir->op2); RegSet allow = RSET_GPR; Reg src = RID_NONE; if (!irref_isk(ir->op2)) { src = ra_alloc1(as, ir->op2, allow); rset_clear(allow, src); } asm_fuseahuref(as, ir->op1, allow); if (ra_hasreg(src)) { emit_mrm(as, XO_MOVto, src, RID_MRM); } else if (!irt_ispri(irr->t)) { lua_assert(irt_isaddr(ir->t) || (LJ_DUALNUM && irt_isinteger(ir->t))); emit_i32(as, irr->i); emit_mrm(as, XO_MOVmi, 0, RID_MRM); } as->mrm.ofs += 4; emit_i32(as, (int32_t)irt_toitype(ir->t)); emit_mrm(as, XO_MOVmi, 0, RID_MRM); } } static void asm_sload(ASMState *as, IRIns *ir) { int32_t ofs = 8*((int32_t)ir->op1-1) + ((ir->op2 & IRSLOAD_FRAME) ? 4 : 0); IRType1 t = ir->t; Reg base; lua_assert(!(ir->op2 & IRSLOAD_PARENT)); /* Handled by asm_head_side(). */ lua_assert(irt_isguard(t) || !(ir->op2 & IRSLOAD_TYPECHECK)); lua_assert(LJ_DUALNUM || !irt_isint(t) || (ir->op2 & (IRSLOAD_CONVERT|IRSLOAD_FRAME))); if ((ir->op2 & IRSLOAD_CONVERT) && irt_isguard(t) && irt_isint(t)) { Reg left = ra_scratch(as, RSET_FPR); asm_tointg(as, ir, left); /* Frees dest reg. Do this before base alloc. */ base = ra_alloc1(as, REF_BASE, RSET_GPR); emit_rmro(as, XMM_MOVRM(as), left, base, ofs); t.irt = IRT_NUM; /* Continue with a regular number type check. */ #if LJ_64 } else if (irt_islightud(t)) { Reg dest = asm_load_lightud64(as, ir, (ir->op2 & IRSLOAD_TYPECHECK)); if (ra_hasreg(dest)) { base = ra_alloc1(as, REF_BASE, RSET_GPR); emit_rmro(as, XO_MOV, dest|REX_64, base, ofs); } return; #endif } else if (ra_used(ir)) { RegSet allow = irt_isnum(t) ? RSET_FPR : RSET_GPR; Reg dest = ra_dest(as, ir, allow); base = ra_alloc1(as, REF_BASE, RSET_GPR); lua_assert(irt_isnum(t) || irt_isint(t) || irt_isaddr(t)); if ((ir->op2 & IRSLOAD_CONVERT)) { t.irt = irt_isint(t) ? IRT_NUM : IRT_INT; /* Check for original type. */ emit_rmro(as, irt_isint(t) ? XO_CVTSI2SD : XO_CVTSD2SI, dest, base, ofs); } else if (irt_isnum(t)) { emit_rmro(as, XMM_MOVRM(as), dest, base, ofs); } else { emit_rmro(as, XO_MOV, dest, base, ofs); } } else { if (!(ir->op2 & IRSLOAD_TYPECHECK)) return; /* No type check: avoid base alloc. */ base = ra_alloc1(as, REF_BASE, RSET_GPR); } if ((ir->op2 & IRSLOAD_TYPECHECK)) { /* Need type check, even if the load result is unused. */ asm_guardcc(as, irt_isnum(t) ? CC_AE : CC_NE); if (LJ_64 && irt_type(t) >= IRT_NUM) { lua_assert(irt_isinteger(t) || irt_isnum(t)); emit_u32(as, LJ_TISNUM); emit_rmro(as, XO_ARITHi, XOg_CMP, base, ofs+4); } else { emit_i8(as, irt_toitype(t)); emit_rmro(as, XO_ARITHi8, XOg_CMP, base, ofs+4); } } } /* -- Allocations --------------------------------------------------------- */ #if LJ_HASFFI static void asm_cnew(ASMState *as, IRIns *ir) { CTState *cts = ctype_ctsG(J2G(as->J)); CTypeID ctypeid = (CTypeID)IR(ir->op1)->i; CTSize sz = (ir->o == IR_CNEWI || ir->op2 == REF_NIL) ? lj_ctype_size(cts, ctypeid) : (CTSize)IR(ir->op2)->i; const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; IRRef args[2]; lua_assert(sz != CTSIZE_INVALID); args[0] = ASMREF_L; /* lua_State *L */ args[1] = ASMREF_TMP1; /* MSize size */ as->gcsteps++; asm_setupresult(as, ir, ci); /* GCcdata * */ /* Initialize immutable cdata object. */ if (ir->o == IR_CNEWI) { RegSet allow = (RSET_GPR & ~RSET_SCRATCH); #if LJ_64 Reg r64 = sz == 8 ? REX_64 : 0; if (irref_isk(ir->op2)) { IRIns *irk = IR(ir->op2); uint64_t k = irk->o == IR_KINT64 ? ir_k64(irk)->u64 : (uint64_t)(uint32_t)irk->i; if (sz == 4 || checki32((int64_t)k)) { emit_i32(as, (int32_t)k); emit_rmro(as, XO_MOVmi, r64, RID_RET, sizeof(GCcdata)); } else { emit_movtomro(as, RID_ECX + r64, RID_RET, sizeof(GCcdata)); emit_loadu64(as, RID_ECX, k); } } else { Reg r = ra_alloc1(as, ir->op2, allow); emit_movtomro(as, r + r64, RID_RET, sizeof(GCcdata)); } #else int32_t ofs = sizeof(GCcdata); if (sz == 8) { ofs += 4; ir++; lua_assert(ir->o == IR_HIOP); } do { if (irref_isk(ir->op2)) { emit_movmroi(as, RID_RET, ofs, IR(ir->op2)->i); } else { Reg r = ra_alloc1(as, ir->op2, allow); emit_movtomro(as, r, RID_RET, ofs); rset_clear(allow, r); } if (ofs == sizeof(GCcdata)) break; ofs -= 4; ir--; } while (1); #endif lua_assert(sz == 4 || sz == 8); } /* Combine initialization of marked, gct and ctypeid. */ emit_movtomro(as, RID_ECX, RID_RET, offsetof(GCcdata, marked)); emit_gri(as, XG_ARITHi(XOg_OR), RID_ECX, (int32_t)((~LJ_TCDATA<<8)+(ctypeid<<16))); emit_gri(as, XG_ARITHi(XOg_AND), RID_ECX, LJ_GC_WHITES); emit_opgl(as, XO_MOVZXb, RID_ECX, gc.currentwhite); asm_gencall(as, ci, args); emit_loadi(as, ra_releasetmp(as, ASMREF_TMP1), (int32_t)(sz+sizeof(GCcdata))); } #else #define asm_cnew(as, ir) ((void)0) #endif /* -- Write barriers ------------------------------------------------------ */ static void asm_tbar(ASMState *as, IRIns *ir) { Reg tab = ra_alloc1(as, ir->op1, RSET_GPR); Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, tab)); MCLabel l_end = emit_label(as); emit_movtomro(as, tmp, tab, offsetof(GCtab, gclist)); emit_setgl(as, tab, gc.grayagain); emit_getgl(as, tmp, gc.grayagain); emit_i8(as, ~LJ_GC_BLACK); emit_rmro(as, XO_ARITHib, XOg_AND, tab, offsetof(GCtab, marked)); emit_sjcc(as, CC_Z, l_end); emit_i8(as, LJ_GC_BLACK); emit_rmro(as, XO_GROUP3b, XOg_TEST, tab, offsetof(GCtab, marked)); } static void asm_obar(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_barrieruv]; IRRef args[2]; MCLabel l_end; Reg obj; /* No need for other object barriers (yet). */ lua_assert(IR(ir->op1)->o == IR_UREFC); ra_evictset(as, RSET_SCRATCH); l_end = emit_label(as); args[0] = ASMREF_TMP1; /* global_State *g */ args[1] = ir->op1; /* TValue *tv */ asm_gencall(as, ci, args); emit_loada(as, ra_releasetmp(as, ASMREF_TMP1), J2G(as->J)); obj = IR(ir->op1)->r; emit_sjcc(as, CC_Z, l_end); emit_i8(as, LJ_GC_WHITES); if (irref_isk(ir->op2)) { GCobj *vp = ir_kgc(IR(ir->op2)); emit_rma(as, XO_GROUP3b, XOg_TEST, &vp->gch.marked); } else { Reg val = ra_alloc1(as, ir->op2, rset_exclude(RSET_SCRATCH&RSET_GPR, obj)); emit_rmro(as, XO_GROUP3b, XOg_TEST, val, (int32_t)offsetof(GChead, marked)); } emit_sjcc(as, CC_Z, l_end); emit_i8(as, LJ_GC_BLACK); emit_rmro(as, XO_GROUP3b, XOg_TEST, obj, (int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)); } /* -- FP/int arithmetic and logic operations ------------------------------ */ /* Load reference onto x87 stack. Force a spill to memory if needed. */ static void asm_x87load(ASMState *as, IRRef ref) { IRIns *ir = IR(ref); if (ir->o == IR_KNUM) { cTValue *tv = ir_knum(ir); if (tvispzero(tv)) /* Use fldz only for +0. */ emit_x87op(as, XI_FLDZ); else if (tvispone(tv)) emit_x87op(as, XI_FLD1); else emit_rma(as, XO_FLDq, XOg_FLDq, tv); } else if (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT && !ra_used(ir) && !irref_isk(ir->op1) && mayfuse(as, ir->op1)) { IRIns *iri = IR(ir->op1); emit_rmro(as, XO_FILDd, XOg_FILDd, RID_ESP, ra_spill(as, iri)); } else { emit_mrm(as, XO_FLDq, XOg_FLDq, asm_fuseload(as, ref, RSET_EMPTY)); } } /* Try to rejoin pow from EXP2, MUL and LOG2 (if still unsplit). */ static int fpmjoin_pow(ASMState *as, IRIns *ir) { IRIns *irp = IR(ir->op1); if (irp == ir-1 && irp->o == IR_MUL && !ra_used(irp)) { IRIns *irpp = IR(irp->op1); if (irpp == ir-2 && irpp->o == IR_FPMATH && irpp->op2 == IRFPM_LOG2 && !ra_used(irpp)) { /* The modified regs must match with the *.dasc implementation. */ RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM2+1)|RID2RSET(RID_EAX); IRIns *irx; if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ ra_evictset(as, drop); ra_destreg(as, ir, RID_XMM0); emit_call(as, lj_vm_pow_sse); irx = IR(irpp->op1); if (ra_noreg(irx->r) && ra_gethint(irx->r) == RID_XMM1) irx->r = RID_INIT; /* Avoid allocating xmm1 for x. */ ra_left(as, RID_XMM0, irpp->op1); ra_left(as, RID_XMM1, irp->op2); return 1; } } return 0; } static void asm_fpmath(ASMState *as, IRIns *ir) { IRFPMathOp fpm = ir->o == IR_FPMATH ? (IRFPMathOp)ir->op2 : IRFPM_OTHER; if (fpm == IRFPM_SQRT) { Reg dest = ra_dest(as, ir, RSET_FPR); Reg left = asm_fuseload(as, ir->op1, RSET_FPR); emit_mrm(as, XO_SQRTSD, dest, left); } else if (fpm <= IRFPM_TRUNC) { if (as->flags & JIT_F_SSE4_1) { /* SSE4.1 has a rounding instruction. */ Reg dest = ra_dest(as, ir, RSET_FPR); Reg left = asm_fuseload(as, ir->op1, RSET_FPR); /* ROUNDSD has a 4-byte opcode which doesn't fit in x86Op. ** Let's pretend it's a 3-byte opcode, and compensate afterwards. ** This is atrocious, but the alternatives are much worse. */ /* Round down/up/trunc == 1001/1010/1011. */ emit_i8(as, 0x09 + fpm); emit_mrm(as, XO_ROUNDSD, dest, left); if (LJ_64 && as->mcp[1] != (MCode)(XO_ROUNDSD >> 16)) { as->mcp[0] = as->mcp[1]; as->mcp[1] = 0x0f; /* Swap 0F and REX. */ } *--as->mcp = 0x66; /* 1st byte of ROUNDSD opcode. */ } else { /* Call helper functions for SSE2 variant. */ /* The modified regs must match with the *.dasc implementation. */ RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM3+1)|RID2RSET(RID_EAX); if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ ra_evictset(as, drop); ra_destreg(as, ir, RID_XMM0); emit_call(as, fpm == IRFPM_FLOOR ? lj_vm_floor_sse : fpm == IRFPM_CEIL ? lj_vm_ceil_sse : lj_vm_trunc_sse); ra_left(as, RID_XMM0, ir->op1); } } else if (fpm == IRFPM_EXP2 && fpmjoin_pow(as, ir)) { /* Rejoined to pow(). */ } else { /* Handle x87 ops. */ int32_t ofs = sps_scale(ir->s); /* Use spill slot or temp slots. */ Reg dest = ir->r; if (ra_hasreg(dest)) { ra_free(as, dest); ra_modified(as, dest); emit_rmro(as, XMM_MOVRM(as), dest, RID_ESP, ofs); } emit_rmro(as, XO_FSTPq, XOg_FSTPq, RID_ESP, ofs); switch (fpm) { /* st0 = lj_vm_*(st0) */ case IRFPM_EXP: emit_call(as, lj_vm_exp_x87); break; case IRFPM_EXP2: emit_call(as, lj_vm_exp2_x87); break; case IRFPM_SIN: emit_x87op(as, XI_FSIN); break; case IRFPM_COS: emit_x87op(as, XI_FCOS); break; case IRFPM_TAN: emit_x87op(as, XI_FPOP); emit_x87op(as, XI_FPTAN); break; case IRFPM_LOG: case IRFPM_LOG2: case IRFPM_LOG10: /* Note: the use of fyl2xp1 would be pointless here. When computing ** log(1.0+eps) the precision is already lost after 1.0 is added. ** Subtracting 1.0 won't recover it. OTOH math.log1p would make sense. */ emit_x87op(as, XI_FYL2X); break; case IRFPM_OTHER: switch (ir->o) { case IR_ATAN2: emit_x87op(as, XI_FPATAN); asm_x87load(as, ir->op2); break; case IR_LDEXP: emit_x87op(as, XI_FPOP1); emit_x87op(as, XI_FSCALE); break; default: lua_assert(0); break; } break; default: lua_assert(0); break; } asm_x87load(as, ir->op1); switch (fpm) { case IRFPM_LOG: emit_x87op(as, XI_FLDLN2); break; case IRFPM_LOG2: emit_x87op(as, XI_FLD1); break; case IRFPM_LOG10: emit_x87op(as, XI_FLDLG2); break; case IRFPM_OTHER: if (ir->o == IR_LDEXP) asm_x87load(as, ir->op2); break; default: break; } } } static void asm_fppowi(ASMState *as, IRIns *ir) { /* The modified regs must match with the *.dasc implementation. */ RegSet drop = RSET_RANGE(RID_XMM0, RID_XMM1+1)|RID2RSET(RID_EAX); if (ra_hasreg(ir->r)) rset_clear(drop, ir->r); /* Dest reg handled below. */ ra_evictset(as, drop); ra_destreg(as, ir, RID_XMM0); emit_call(as, lj_vm_powi_sse); ra_left(as, RID_XMM0, ir->op1); ra_left(as, RID_EAX, ir->op2); } #if LJ_64 && LJ_HASFFI static void asm_arith64(ASMState *as, IRIns *ir, IRCallID id) { const CCallInfo *ci = &lj_ir_callinfo[id]; IRRef args[2]; args[0] = ir->op1; args[1] = ir->op2; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } #endif static void asm_intmod(ASMState *as, IRIns *ir) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_vm_modi]; IRRef args[2]; args[0] = ir->op1; args[1] = ir->op2; asm_setupresult(as, ir, ci); asm_gencall(as, ci, args); } static int asm_swapops(ASMState *as, IRIns *ir) { IRIns *irl = IR(ir->op1); IRIns *irr = IR(ir->op2); lua_assert(ra_noreg(irr->r)); if (!irm_iscomm(lj_ir_mode[ir->o])) return 0; /* Can't swap non-commutative operations. */ if (irref_isk(ir->op2)) return 0; /* Don't swap constants to the left. */ if (ra_hasreg(irl->r)) return 1; /* Swap if left already has a register. */ if (ra_samehint(ir->r, irr->r)) return 1; /* Swap if dest and right have matching hints. */ if (as->curins > as->loopref) { /* In variant part? */ if (ir->op2 < as->loopref && !irt_isphi(irr->t)) return 0; /* Keep invariants on the right. */ if (ir->op1 < as->loopref && !irt_isphi(irl->t)) return 1; /* Swap invariants to the right. */ } if (opisfusableload(irl->o)) return 1; /* Swap fusable loads to the right. */ return 0; /* Otherwise don't swap. */ } static void asm_fparith(ASMState *as, IRIns *ir, x86Op xo) { IRRef lref = ir->op1; IRRef rref = ir->op2; RegSet allow = RSET_FPR; Reg dest; Reg right = IR(rref)->r; if (ra_hasreg(right)) { rset_clear(allow, right); ra_noweak(as, right); } dest = ra_dest(as, ir, allow); if (lref == rref) { right = dest; } else if (ra_noreg(right)) { if (asm_swapops(as, ir)) { IRRef tmp = lref; lref = rref; rref = tmp; } right = asm_fuseload(as, rref, rset_clear(allow, dest)); } emit_mrm(as, xo, dest, right); ra_left(as, dest, lref); } static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa) { IRRef lref = ir->op1; IRRef rref = ir->op2; RegSet allow = RSET_GPR; Reg dest, right; int32_t k = 0; if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */ as->flagmcp = NULL; as->mcp += (LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2; } right = IR(rref)->r; if (ra_hasreg(right)) { rset_clear(allow, right); ra_noweak(as, right); } dest = ra_dest(as, ir, allow); if (lref == rref) { right = dest; } else if (ra_noreg(right) && !asm_isk32(as, rref, &k)) { if (asm_swapops(as, ir)) { IRRef tmp = lref; lref = rref; rref = tmp; } right = asm_fuseloadm(as, rref, rset_clear(allow, dest), irt_is64(ir->t)); } if (irt_isguard(ir->t)) /* For IR_ADDOV etc. */ asm_guardcc(as, CC_O); if (xa != XOg_X_IMUL) { if (ra_hasreg(right)) emit_mrm(as, XO_ARITH(xa), REX_64IR(ir, dest), right); else emit_gri(as, XG_ARITHi(xa), REX_64IR(ir, dest), k); } else if (ra_hasreg(right)) { /* IMUL r, mrm. */ emit_mrm(as, XO_IMUL, REX_64IR(ir, dest), right); } else { /* IMUL r, r, k. */ /* NYI: use lea/shl/add/sub (FOLD only does 2^k) depending on CPU. */ Reg left = asm_fuseloadm(as, lref, RSET_GPR, irt_is64(ir->t)); x86Op xo; if (checki8(k)) { emit_i8(as, k); xo = XO_IMULi8; } else { emit_i32(as, k); xo = XO_IMULi; } emit_mrm(as, xo, REX_64IR(ir, dest), left); return; } ra_left(as, dest, lref); } /* LEA is really a 4-operand ADD with an independent destination register, ** up to two source registers and an immediate. One register can be scaled ** by 1, 2, 4 or 8. This can be used to avoid moves or to fuse several ** instructions. ** ** Currently only a few common cases are supported: ** - 3-operand ADD: y = a+b; y = a+k with a and b already allocated ** - Left ADD fusion: y = (a+b)+k; y = (a+k)+b ** - Right ADD fusion: y = a+(b+k) ** The ommited variants have already been reduced by FOLD. ** ** There are more fusion opportunities, like gathering shifts or joining ** common references. But these are probably not worth the trouble, since ** array indexing is not decomposed and already makes use of all fields ** of the ModRM operand. */ static int asm_lea(ASMState *as, IRIns *ir) { IRIns *irl = IR(ir->op1); IRIns *irr = IR(ir->op2); RegSet allow = RSET_GPR; Reg dest; as->mrm.base = as->mrm.idx = RID_NONE; as->mrm.scale = XM_SCALE1; as->mrm.ofs = 0; if (ra_hasreg(irl->r)) { rset_clear(allow, irl->r); ra_noweak(as, irl->r); as->mrm.base = irl->r; if (irref_isk(ir->op2) || ra_hasreg(irr->r)) { /* The PHI renaming logic does a better job in some cases. */ if (ra_hasreg(ir->r) && ((irt_isphi(irl->t) && as->phireg[ir->r] == ir->op1) || (irt_isphi(irr->t) && as->phireg[ir->r] == ir->op2))) return 0; if (irref_isk(ir->op2)) { as->mrm.ofs = irr->i; } else { rset_clear(allow, irr->r); ra_noweak(as, irr->r); as->mrm.idx = irr->r; } } else if (irr->o == IR_ADD && mayfuse(as, ir->op2) && irref_isk(irr->op2)) { Reg idx = ra_alloc1(as, irr->op1, allow); rset_clear(allow, idx); as->mrm.idx = (uint8_t)idx; as->mrm.ofs = IR(irr->op2)->i; } else { return 0; } } else if (ir->op1 != ir->op2 && irl->o == IR_ADD && mayfuse(as, ir->op1) && (irref_isk(ir->op2) || irref_isk(irl->op2))) { Reg idx, base = ra_alloc1(as, irl->op1, allow); rset_clear(allow, base); as->mrm.base = (uint8_t)base; if (irref_isk(ir->op2)) { as->mrm.ofs = irr->i; idx = ra_alloc1(as, irl->op2, allow); } else { as->mrm.ofs = IR(irl->op2)->i; idx = ra_alloc1(as, ir->op2, allow); } rset_clear(allow, idx); as->mrm.idx = (uint8_t)idx; } else { return 0; } dest = ra_dest(as, ir, allow); emit_mrm(as, XO_LEA, dest, RID_MRM); return 1; /* Success. */ } static void asm_add(ASMState *as, IRIns *ir) { if (irt_isnum(ir->t)) asm_fparith(as, ir, XO_ADDSD); else if ((as->flags & JIT_F_LEA_AGU) || as->flagmcp == as->mcp || irt_is64(ir->t) || !asm_lea(as, ir)) asm_intarith(as, ir, XOg_ADD); } static void asm_neg_not(ASMState *as, IRIns *ir, x86Group3 xg) { Reg dest = ra_dest(as, ir, RSET_GPR); emit_rr(as, XO_GROUP3, REX_64IR(ir, xg), dest); ra_left(as, dest, ir->op1); } static void asm_min_max(ASMState *as, IRIns *ir, int cc) { Reg right, dest = ra_dest(as, ir, RSET_GPR); IRRef lref = ir->op1, rref = ir->op2; if (irref_isk(rref)) { lref = rref; rref = ir->op1; } right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, dest)); emit_rr(as, XO_CMOV + (cc<<24), REX_64IR(ir, dest), right); emit_rr(as, XO_CMP, REX_64IR(ir, dest), right); ra_left(as, dest, lref); } static void asm_bitswap(ASMState *as, IRIns *ir) { Reg dest = ra_dest(as, ir, RSET_GPR); as->mcp = emit_op(XO_BSWAP + ((dest&7) << 24), REX_64IR(ir, 0), dest, 0, as->mcp, 1); ra_left(as, dest, ir->op1); } static void asm_bitshift(ASMState *as, IRIns *ir, x86Shift xs) { IRRef rref = ir->op2; IRIns *irr = IR(rref); Reg dest; if (irref_isk(rref)) { /* Constant shifts. */ int shift; dest = ra_dest(as, ir, RSET_GPR); shift = irr->i & (irt_is64(ir->t) ? 63 : 31); switch (shift) { case 0: break; case 1: emit_rr(as, XO_SHIFT1, REX_64IR(ir, xs), dest); break; default: emit_shifti(as, REX_64IR(ir, xs), dest, shift); break; } } else { /* Variable shifts implicitly use register cl (i.e. ecx). */ Reg right; dest = ra_dest(as, ir, rset_exclude(RSET_GPR, RID_ECX)); if (dest == RID_ECX) { dest = ra_scratch(as, rset_exclude(RSET_GPR, RID_ECX)); emit_rr(as, XO_MOV, RID_ECX, dest); } right = irr->r; if (ra_noreg(right)) right = ra_allocref(as, rref, RID2RSET(RID_ECX)); else if (right != RID_ECX) ra_scratch(as, RID2RSET(RID_ECX)); emit_rr(as, XO_SHIFTcl, REX_64IR(ir, xs), dest); ra_noweak(as, right); if (right != RID_ECX) emit_rr(as, XO_MOV, RID_ECX, right); } ra_left(as, dest, ir->op1); /* ** Note: avoid using the flags resulting from a shift or rotate! ** All of them cause a partial flag stall, except for r,1 shifts ** (but not rotates). And a shift count of 0 leaves the flags unmodified. */ } /* -- Comparisons --------------------------------------------------------- */ /* Virtual flags for unordered FP comparisons. */ #define VCC_U 0x1000 /* Unordered. */ #define VCC_P 0x2000 /* Needs extra CC_P branch. */ #define VCC_S 0x4000 /* Swap avoids CC_P branch. */ #define VCC_PS (VCC_P|VCC_S) /* Map of comparisons to flags. ORDER IR. */ #define COMPFLAGS(ci, cin, cu, cf) ((ci)+((cu)<<4)+((cin)<<8)+(cf)) static const uint16_t asm_compmap[IR_ABC+1] = { /* signed non-eq unsigned flags */ /* LT */ COMPFLAGS(CC_GE, CC_G, CC_AE, VCC_PS), /* GE */ COMPFLAGS(CC_L, CC_L, CC_B, 0), /* LE */ COMPFLAGS(CC_G, CC_G, CC_A, VCC_PS), /* GT */ COMPFLAGS(CC_LE, CC_L, CC_BE, 0), /* ULT */ COMPFLAGS(CC_AE, CC_A, CC_AE, VCC_U), /* UGE */ COMPFLAGS(CC_B, CC_B, CC_B, VCC_U|VCC_PS), /* ULE */ COMPFLAGS(CC_A, CC_A, CC_A, VCC_U), /* UGT */ COMPFLAGS(CC_BE, CC_B, CC_BE, VCC_U|VCC_PS), /* EQ */ COMPFLAGS(CC_NE, CC_NE, CC_NE, VCC_P), /* NE */ COMPFLAGS(CC_E, CC_E, CC_E, VCC_U|VCC_P), /* ABC */ COMPFLAGS(CC_BE, CC_B, CC_BE, VCC_U|VCC_PS) /* Same as UGT. */ }; /* FP and integer comparisons. */ static void asm_comp(ASMState *as, IRIns *ir, uint32_t cc) { if (irt_isnum(ir->t)) { IRRef lref = ir->op1; IRRef rref = ir->op2; Reg left, right; MCLabel l_around; /* ** An extra CC_P branch is required to preserve ordered/unordered ** semantics for FP comparisons. This can be avoided by swapping ** the operands and inverting the condition (except for EQ and UNE). ** So always try to swap if possible. ** ** Another option would be to swap operands to achieve better memory ** operand fusion. But it's unlikely that this outweighs the cost ** of the extra branches. */ if (cc & VCC_S) { /* Swap? */ IRRef tmp = lref; lref = rref; rref = tmp; cc ^= (VCC_PS|(5<<4)); /* A <-> B, AE <-> BE, PS <-> none */ } left = ra_alloc1(as, lref, RSET_FPR); right = asm_fuseload(as, rref, rset_exclude(RSET_FPR, left)); l_around = emit_label(as); asm_guardcc(as, cc >> 4); if (cc & VCC_P) { /* Extra CC_P branch required? */ if (!(cc & VCC_U)) { asm_guardcc(as, CC_P); /* Branch to exit for ordered comparisons. */ } else if (l_around != as->invmcp) { emit_sjcc(as, CC_P, l_around); /* Branch around for unordered. */ } else { /* Patched to mcloop by asm_loop_fixup. */ as->loopinv = 2; if (as->realign) emit_sjcc(as, CC_P, as->mcp); else emit_jcc(as, CC_P, as->mcp); } } emit_mrm(as, XO_UCOMISD, left, right); } else { IRRef lref = ir->op1, rref = ir->op2; IROp leftop = (IROp)(IR(lref)->o); Reg r64 = REX_64IR(ir, 0); int32_t imm = 0; lua_assert(irt_is64(ir->t) || irt_isint(ir->t) || irt_isu32(ir->t) || irt_isaddr(ir->t) || irt_isu8(ir->t)); /* Swap constants (only for ABC) and fusable loads to the right. */ if (irref_isk(lref) || (!irref_isk(rref) && opisfusableload(leftop))) { if ((cc & 0xc) == 0xc) cc ^= 0x53; /* L <-> G, LE <-> GE */ else if ((cc & 0xa) == 0x2) cc ^= 0x55; /* A <-> B, AE <-> BE */ lref = ir->op2; rref = ir->op1; } if (asm_isk32(as, rref, &imm)) { IRIns *irl = IR(lref); /* Check wether we can use test ins. Not for unsigned, since CF=0. */ int usetest = (imm == 0 && (cc & 0xa) != 0x2); if (usetest && irl->o == IR_BAND && irl+1 == ir && !ra_used(irl)) { /* Combine comp(BAND(ref, r/imm), 0) into test mrm, r/imm. */ Reg right, left = RID_NONE; RegSet allow = RSET_GPR; if (!asm_isk32(as, irl->op2, &imm)) { left = ra_alloc1(as, irl->op2, allow); rset_clear(allow, left); } else { /* Try to Fuse IRT_I8/IRT_U8 loads, too. See below. */ IRIns *irll = IR(irl->op1); if (opisfusableload((IROp)irll->o) && (irt_isi8(irll->t) || irt_isu8(irll->t))) { IRType1 origt = irll->t; /* Temporarily flip types. */ irll->t.irt = (irll->t.irt & ~IRT_TYPE) | IRT_INT; as->curins--; /* Skip to BAND to avoid failing in noconflict(). */ right = asm_fuseload(as, irl->op1, RSET_GPR); as->curins++; irll->t = origt; if (right != RID_MRM) goto test_nofuse; /* Fusion succeeded, emit test byte mrm, imm8. */ asm_guardcc(as, cc); emit_i8(as, (imm & 0xff)); emit_mrm(as, XO_GROUP3b, XOg_TEST, RID_MRM); return; } } as->curins--; /* Skip to BAND to avoid failing in noconflict(). */ right = asm_fuseloadm(as, irl->op1, allow, r64); as->curins++; /* Undo the above. */ test_nofuse: asm_guardcc(as, cc); if (ra_noreg(left)) { emit_i32(as, imm); emit_mrm(as, XO_GROUP3, r64 + XOg_TEST, right); } else { emit_mrm(as, XO_TEST, r64 + left, right); } } else { Reg left; if (opisfusableload((IROp)irl->o) && ((irt_isu8(irl->t) && checku8(imm)) || ((irt_isi8(irl->t) || irt_isi16(irl->t)) && checki8(imm)) || (irt_isu16(irl->t) && checku16(imm) && checki8((int16_t)imm)))) { /* Only the IRT_INT case is fused by asm_fuseload. ** The IRT_I8/IRT_U8 loads and some IRT_I16/IRT_U16 loads ** are handled here. ** Note that cmp word [mem], imm16 should not be generated, ** since it has a length-changing prefix. Compares of a word ** against a sign-extended imm8 are ok, however. */ IRType1 origt = irl->t; /* Temporarily flip types. */ irl->t.irt = (irl->t.irt & ~IRT_TYPE) | IRT_INT; left = asm_fuseload(as, lref, RSET_GPR); irl->t = origt; if (left == RID_MRM) { /* Fusion succeeded? */ if (irt_isu8(irl->t) || irt_isu16(irl->t)) cc >>= 4; /* Need unsigned compare. */ asm_guardcc(as, cc); emit_i8(as, imm); emit_mrm(as, (irt_isi8(origt) || irt_isu8(origt)) ? XO_ARITHib : XO_ARITHiw8, r64 + XOg_CMP, RID_MRM); return; } /* Otherwise handle register case as usual. */ } else { left = asm_fuseloadm(as, lref, irt_isu8(ir->t) ? RSET_GPR8 : RSET_GPR, r64); } asm_guardcc(as, cc); if (usetest && left != RID_MRM) { /* Use test r,r instead of cmp r,0. */ x86Op xo = XO_TEST; if (irt_isu8(ir->t)) { lua_assert(ir->o == IR_EQ || ir->o == IR_NE); xo = XO_TESTb; if (!rset_test(RSET_RANGE(RID_EAX, RID_EBX+1), left)) { if (LJ_64) { left |= FORCE_REX; } else { emit_i32(as, 0xff); emit_mrm(as, XO_GROUP3, XOg_TEST, left); return; } } } emit_rr(as, xo, r64 + left, left); if (irl+1 == ir) /* Referencing previous ins? */ as->flagmcp = as->mcp; /* Set flag to drop test r,r if possible. */ } else { emit_gmrmi(as, XG_ARITHi(XOg_CMP), r64 + left, imm); } } } else { Reg left = ra_alloc1(as, lref, RSET_GPR); Reg right = asm_fuseloadm(as, rref, rset_exclude(RSET_GPR, left), r64); asm_guardcc(as, cc); emit_mrm(as, XO_CMP, r64 + left, right); } } } #if LJ_32 && LJ_HASFFI /* 64 bit integer comparisons in 32 bit mode. */ static void asm_comp_int64(ASMState *as, IRIns *ir) { uint32_t cc = asm_compmap[(ir-1)->o]; RegSet allow = RSET_GPR; Reg lefthi = RID_NONE, leftlo = RID_NONE; Reg righthi = RID_NONE, rightlo = RID_NONE; MCLabel l_around; x86ModRM mrm; as->curins--; /* Skip loword ins. Avoids failing in noconflict(), too. */ /* Allocate/fuse hiword operands. */ if (irref_isk(ir->op2)) { lefthi = asm_fuseload(as, ir->op1, allow); } else { lefthi = ra_alloc1(as, ir->op1, allow); righthi = asm_fuseload(as, ir->op2, allow); if (righthi == RID_MRM) { if (as->mrm.base != RID_NONE) rset_clear(allow, as->mrm.base); if (as->mrm.idx != RID_NONE) rset_clear(allow, as->mrm.idx); } else { rset_clear(allow, righthi); } } mrm = as->mrm; /* Save state for hiword instruction. */ /* Allocate/fuse loword operands. */ if (irref_isk((ir-1)->op2)) { leftlo = asm_fuseload(as, (ir-1)->op1, allow); } else { leftlo = ra_alloc1(as, (ir-1)->op1, allow); rightlo = asm_fuseload(as, (ir-1)->op2, allow); if (rightlo == RID_MRM) { if (as->mrm.base != RID_NONE) rset_clear(allow, as->mrm.base); if (as->mrm.idx != RID_NONE) rset_clear(allow, as->mrm.idx); } else { rset_clear(allow, rightlo); } } /* All register allocations must be performed _before_ this point. */ l_around = emit_label(as); as->invmcp = as->flagmcp = NULL; /* Cannot use these optimizations. */ /* Loword comparison and branch. */ asm_guardcc(as, cc >> 4); /* Always use unsigned compare for loword. */ if (ra_noreg(rightlo)) { int32_t imm = IR((ir-1)->op2)->i; if (imm == 0 && ((cc >> 4) & 0xa) != 0x2 && leftlo != RID_MRM) emit_rr(as, XO_TEST, leftlo, leftlo); else emit_gmrmi(as, XG_ARITHi(XOg_CMP), leftlo, imm); } else { emit_mrm(as, XO_CMP, leftlo, rightlo); } /* Hiword comparison and branches. */ if ((cc & 15) != CC_NE) emit_sjcc(as, CC_NE, l_around); /* Hiword unequal: skip loword compare. */ if ((cc & 15) != CC_E) asm_guardcc(as, cc >> 8); /* Hiword compare without equality check. */ as->mrm = mrm; /* Restore state. */ if (ra_noreg(righthi)) { int32_t imm = IR(ir->op2)->i; if (imm == 0 && (cc & 0xa) != 0x2 && lefthi != RID_MRM) emit_rr(as, XO_TEST, lefthi, lefthi); else emit_gmrmi(as, XG_ARITHi(XOg_CMP), lefthi, imm); } else { emit_mrm(as, XO_CMP, lefthi, righthi); } } #endif /* -- Support for 64 bit ops in 32 bit mode ------------------------------- */ /* Hiword op of a split 64 bit op. Previous op must be the loword op. */ static void asm_hiop(ASMState *as, IRIns *ir) { #if LJ_32 && LJ_HASFFI /* HIOP is marked as a store because it needs its own DCE logic. */ int uselo = ra_used(ir-1), usehi = ra_used(ir); /* Loword/hiword used? */ if (LJ_UNLIKELY(!(as->flags & JIT_F_OPT_DCE))) uselo = usehi = 1; if ((ir-1)->o == IR_CONV) { /* Conversions to/from 64 bit. */ if (usehi || uselo) { if (irt_isfp(ir->t)) asm_conv_fp_int64(as, ir); else asm_conv_int64_fp(as, ir); } as->curins--; /* Always skip the CONV. */ return; } else if ((ir-1)->o <= IR_NE) { /* 64 bit integer comparisons. ORDER IR. */ asm_comp_int64(as, ir); return; } else if ((ir-1)->o == IR_XSTORE) { if ((ir-1)->r != RID_SINK) asm_fxstore(as, ir); return; } if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ switch ((ir-1)->o) { case IR_ADD: as->flagmcp = NULL; as->curins--; asm_intarith(as, ir, XOg_ADC); asm_intarith(as, ir-1, XOg_ADD); break; case IR_SUB: as->flagmcp = NULL; as->curins--; asm_intarith(as, ir, XOg_SBB); asm_intarith(as, ir-1, XOg_SUB); break; case IR_NEG: { Reg dest = ra_dest(as, ir, RSET_GPR); emit_rr(as, XO_GROUP3, XOg_NEG, dest); emit_i8(as, 0); emit_rr(as, XO_ARITHi8, XOg_ADC, dest); ra_left(as, dest, ir->op1); as->curins--; asm_neg_not(as, ir-1, XOg_NEG); break; } case IR_CALLN: case IR_CALLXS: if (!uselo) ra_allocref(as, ir->op1, RID2RSET(RID_RETLO)); /* Mark lo op as used. */ break; case IR_CNEWI: /* Nothing to do here. Handled by CNEWI itself. */ break; default: lua_assert(0); break; } #else UNUSED(as); UNUSED(ir); lua_assert(0); /* Unused on x64 or without FFI. */ #endif } /* -- Stack handling ------------------------------------------------------ */ /* Check Lua stack size for overflow. Use exit handler as fallback. */ static void asm_stack_check(ASMState *as, BCReg topslot, IRIns *irp, RegSet allow, ExitNo exitno) { /* Try to get an unused temp. register, otherwise spill/restore eax. */ Reg pbase = irp ? irp->r : RID_BASE; Reg r = allow ? rset_pickbot(allow) : RID_EAX; emit_jcc(as, CC_B, exitstub_addr(as->J, exitno)); if (allow == RSET_EMPTY) /* Restore temp. register. */ emit_rmro(as, XO_MOV, r|REX_64, RID_ESP, 0); else ra_modified(as, r); emit_gri(as, XG_ARITHi(XOg_CMP), r, (int32_t)(8*topslot)); if (ra_hasreg(pbase) && pbase != r) emit_rr(as, XO_ARITH(XOg_SUB), r, pbase); else emit_rmro(as, XO_ARITH(XOg_SUB), r, RID_NONE, ptr2addr(&J2G(as->J)->jit_base)); emit_rmro(as, XO_MOV, r, r, offsetof(lua_State, maxstack)); emit_getgl(as, r, jit_L); if (allow == RSET_EMPTY) /* Spill temp. register. */ emit_rmro(as, XO_MOVto, r|REX_64, RID_ESP, 0); } /* Restore Lua stack from on-trace state. */ static void asm_stack_restore(ASMState *as, SnapShot *snap) { SnapEntry *map = &as->T->snapmap[snap->mapofs]; SnapEntry *flinks = &as->T->snapmap[snap_nextofs(as->T, snap)-1]; MSize n, nent = snap->nent; /* Store the value of all modified slots to the Lua stack. */ for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; BCReg s = snap_slot(sn); int32_t ofs = 8*((int32_t)s-1); IRRef ref = snap_ref(sn); IRIns *ir = IR(ref); if ((sn & SNAP_NORESTORE)) continue; if (irt_isnum(ir->t)) { Reg src = ra_alloc1(as, ref, RSET_FPR); emit_rmro(as, XO_MOVSDto, src, RID_BASE, ofs); } else { lua_assert(irt_ispri(ir->t) || irt_isaddr(ir->t) || (LJ_DUALNUM && irt_isinteger(ir->t))); if (!irref_isk(ref)) { Reg src = ra_alloc1(as, ref, rset_exclude(RSET_GPR, RID_BASE)); emit_movtomro(as, REX_64IR(ir, src), RID_BASE, ofs); } else if (!irt_ispri(ir->t)) { emit_movmroi(as, RID_BASE, ofs, ir->i); } if ((sn & (SNAP_CONT|SNAP_FRAME))) { if (s != 0) /* Do not overwrite link to previous frame. */ emit_movmroi(as, RID_BASE, ofs+4, (int32_t)(*flinks--)); } else { if (!(LJ_64 && irt_islightud(ir->t))) emit_movmroi(as, RID_BASE, ofs+4, irt_toitype(ir->t)); } } checkmclim(as); } lua_assert(map + nent == flinks); } /* -- GC handling --------------------------------------------------------- */ /* Check GC threshold and do one or more GC steps. */ static void asm_gc_check(ASMState *as) { const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_gc_step_jit]; IRRef args[2]; MCLabel l_end; Reg tmp; ra_evictset(as, RSET_SCRATCH); l_end = emit_label(as); /* Exit trace if in GCSatomic or GCSfinalize. Avoids syncing GC objects. */ asm_guardcc(as, CC_NE); /* Assumes asm_snap_prep() already done. */ emit_rr(as, XO_TEST, RID_RET, RID_RET); args[0] = ASMREF_TMP1; /* global_State *g */ args[1] = ASMREF_TMP2; /* MSize steps */ asm_gencall(as, ci, args); tmp = ra_releasetmp(as, ASMREF_TMP1); emit_loada(as, tmp, J2G(as->J)); emit_loadi(as, ra_releasetmp(as, ASMREF_TMP2), as->gcsteps); /* Jump around GC step if GC total < GC threshold. */ emit_sjcc(as, CC_B, l_end); emit_opgl(as, XO_ARITH(XOg_CMP), tmp, gc.threshold); emit_getgl(as, tmp, gc.total); as->gcsteps = 0; checkmclim(as); } /* -- Loop handling ------------------------------------------------------- */ /* Fixup the loop branch. */ static void asm_loop_fixup(ASMState *as) { MCode *p = as->mctop; MCode *target = as->mcp; if (as->realign) { /* Realigned loops use short jumps. */ as->realign = NULL; /* Stop another retry. */ lua_assert(((intptr_t)target & 15) == 0); if (as->loopinv) { /* Inverted loop branch? */ p -= 5; p[0] = XI_JMP; lua_assert(target - p >= -128); p[-1] = (MCode)(target - p); /* Patch sjcc. */ if (as->loopinv == 2) p[-3] = (MCode)(target - p + 2); /* Patch opt. short jp. */ } else { lua_assert(target - p >= -128); p[-1] = (MCode)(int8_t)(target - p); /* Patch short jmp. */ p[-2] = XI_JMPs; } } else { MCode *newloop; p[-5] = XI_JMP; if (as->loopinv) { /* Inverted loop branch? */ /* asm_guardcc already inverted the jcc and patched the jmp. */ p -= 5; newloop = target+4; *(int32_t *)(p-4) = (int32_t)(target - p); /* Patch jcc. */ if (as->loopinv == 2) { *(int32_t *)(p-10) = (int32_t)(target - p + 6); /* Patch opt. jp. */ newloop = target+8; } } else { /* Otherwise just patch jmp. */ *(int32_t *)(p-4) = (int32_t)(target - p); newloop = target+3; } /* Realign small loops and shorten the loop branch. */ if (newloop >= p - 128) { as->realign = newloop; /* Force a retry and remember alignment. */ as->curins = as->stopins; /* Abort asm_trace now. */ as->T->nins = as->orignins; /* Remove any added renames. */ } } } /* -- Head of trace ------------------------------------------------------- */ /* Coalesce BASE register for a root trace. */ static void asm_head_root_base(ASMState *as) { IRIns *ir = IR(REF_BASE); Reg r = ir->r; if (ra_hasreg(r)) { ra_free(as, r); if (rset_test(as->modset, r)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (r != RID_BASE) emit_rr(as, XO_MOV, r, RID_BASE); } } /* Coalesce or reload BASE register for a side trace. */ static RegSet asm_head_side_base(ASMState *as, IRIns *irp, RegSet allow) { IRIns *ir = IR(REF_BASE); Reg r = ir->r; if (ra_hasreg(r)) { ra_free(as, r); if (rset_test(as->modset, r)) ir->r = RID_INIT; /* No inheritance for modified BASE register. */ if (irp->r == r) { rset_clear(allow, r); /* Mark same BASE register as coalesced. */ } else if (ra_hasreg(irp->r) && rset_test(as->freeset, irp->r)) { rset_clear(allow, irp->r); emit_rr(as, XO_MOV, r, irp->r); /* Move from coalesced parent reg. */ } else { emit_getgl(as, r, jit_base); /* Otherwise reload BASE. */ } } return allow; } /* -- Tail of trace ------------------------------------------------------- */ /* Fixup the tail code. */ static void asm_tail_fixup(ASMState *as, TraceNo lnk) { /* Note: don't use as->mcp swap + emit_*: emit_op overwrites more bytes. */ MCode *p = as->mctop; MCode *target, *q; int32_t spadj = as->T->spadjust; if (spadj == 0) { p -= ((as->flags & JIT_F_LEA_AGU) ? 7 : 6) + (LJ_64 ? 1 : 0); } else { MCode *p1; /* Patch stack adjustment. */ if (checki8(spadj)) { p -= 3; p1 = p-6; *p1 = (MCode)spadj; } else { p1 = p-9; *(int32_t *)p1 = spadj; } if ((as->flags & JIT_F_LEA_AGU)) { #if LJ_64 p1[-4] = 0x48; #endif p1[-3] = (MCode)XI_LEA; p1[-2] = MODRM(checki8(spadj) ? XM_OFS8 : XM_OFS32, RID_ESP, RID_ESP); p1[-1] = MODRM(XM_SCALE1, RID_ESP, RID_ESP); } else { #if LJ_64 p1[-3] = 0x48; #endif p1[-2] = (MCode)(checki8(spadj) ? XI_ARITHi8 : XI_ARITHi); p1[-1] = MODRM(XM_REG, XOg_ADD, RID_ESP); } } /* Patch exit branch. */ target = lnk ? traceref(as->J, lnk)->mcode : (MCode *)lj_vm_exit_interp; *(int32_t *)(p-4) = jmprel(p, target); p[-5] = XI_JMP; /* Drop unused mcode tail. Fill with NOPs to make the prefetcher happy. */ for (q = as->mctop-1; q >= p; q--) *q = XI_NOP; as->mctop = p; } /* Prepare tail of code. */ static void asm_tail_prep(ASMState *as) { MCode *p = as->mctop; /* Realign and leave room for backwards loop branch or exit branch. */ if (as->realign) { int i = ((int)(intptr_t)as->realign) & 15; /* Fill unused mcode tail with NOPs to make the prefetcher happy. */ while (i-- > 0) *--p = XI_NOP; as->mctop = p; p -= (as->loopinv ? 5 : 2); /* Space for short/near jmp. */ } else { p -= 5; /* Space for exit branch (near jmp). */ } if (as->loopref) { as->invmcp = as->mcp = p; } else { /* Leave room for ESP adjustment: add esp, imm or lea esp, [esp+imm] */ as->mcp = p - (((as->flags & JIT_F_LEA_AGU) ? 7 : 6) + (LJ_64 ? 1 : 0)); as->invmcp = NULL; } } /* -- Instruction dispatch ------------------------------------------------ */ /* Assemble a single instruction. */ static void asm_ir(ASMState *as, IRIns *ir) { switch ((IROp)ir->o) { /* Miscellaneous ops. */ case IR_LOOP: asm_loop(as); break; case IR_NOP: case IR_XBAR: lua_assert(!ra_used(ir)); break; case IR_USE: ra_alloc1(as, ir->op1, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR); break; case IR_PHI: asm_phi(as, ir); break; case IR_HIOP: asm_hiop(as, ir); break; case IR_GCSTEP: asm_gcstep(as, ir); break; /* Guarded assertions. */ case IR_LT: case IR_GE: case IR_LE: case IR_GT: case IR_ULT: case IR_UGE: case IR_ULE: case IR_UGT: case IR_EQ: case IR_NE: case IR_ABC: asm_comp(as, ir, asm_compmap[ir->o]); break; case IR_RETF: asm_retf(as, ir); break; /* Bit ops. */ case IR_BNOT: asm_neg_not(as, ir, XOg_NOT); break; case IR_BSWAP: asm_bitswap(as, ir); break; case IR_BAND: asm_intarith(as, ir, XOg_AND); break; case IR_BOR: asm_intarith(as, ir, XOg_OR); break; case IR_BXOR: asm_intarith(as, ir, XOg_XOR); break; case IR_BSHL: asm_bitshift(as, ir, XOg_SHL); break; case IR_BSHR: asm_bitshift(as, ir, XOg_SHR); break; case IR_BSAR: asm_bitshift(as, ir, XOg_SAR); break; case IR_BROL: asm_bitshift(as, ir, XOg_ROL); break; case IR_BROR: asm_bitshift(as, ir, XOg_ROR); break; /* Arithmetic ops. */ case IR_ADD: asm_add(as, ir); break; case IR_SUB: if (irt_isnum(ir->t)) asm_fparith(as, ir, XO_SUBSD); else /* Note: no need for LEA trick here. i-k is encoded as i+(-k). */ asm_intarith(as, ir, XOg_SUB); break; case IR_MUL: if (irt_isnum(ir->t)) asm_fparith(as, ir, XO_MULSD); else asm_intarith(as, ir, XOg_X_IMUL); break; case IR_DIV: #if LJ_64 && LJ_HASFFI if (!irt_isnum(ir->t)) asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 : IRCALL_lj_carith_divu64); else #endif asm_fparith(as, ir, XO_DIVSD); break; case IR_MOD: #if LJ_64 && LJ_HASFFI if (!irt_isint(ir->t)) asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 : IRCALL_lj_carith_modu64); else #endif asm_intmod(as, ir); break; case IR_NEG: if (irt_isnum(ir->t)) asm_fparith(as, ir, XO_XORPS); else asm_neg_not(as, ir, XOg_NEG); break; case IR_ABS: asm_fparith(as, ir, XO_ANDPS); break; case IR_MIN: if (irt_isnum(ir->t)) asm_fparith(as, ir, XO_MINSD); else asm_min_max(as, ir, CC_G); break; case IR_MAX: if (irt_isnum(ir->t)) asm_fparith(as, ir, XO_MAXSD); else asm_min_max(as, ir, CC_L); break; case IR_FPMATH: case IR_ATAN2: case IR_LDEXP: asm_fpmath(as, ir); break; case IR_POW: #if LJ_64 && LJ_HASFFI if (!irt_isnum(ir->t)) asm_arith64(as, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 : IRCALL_lj_carith_powu64); else #endif asm_fppowi(as, ir); break; /* Overflow-checking arithmetic ops. Note: don't use LEA here! */ case IR_ADDOV: asm_intarith(as, ir, XOg_ADD); break; case IR_SUBOV: asm_intarith(as, ir, XOg_SUB); break; case IR_MULOV: asm_intarith(as, ir, XOg_X_IMUL); break; /* Memory references. */ case IR_AREF: asm_aref(as, ir); break; case IR_HREF: asm_href(as, ir); break; case IR_HREFK: asm_hrefk(as, ir); break; case IR_NEWREF: asm_newref(as, ir); break; case IR_UREFO: case IR_UREFC: asm_uref(as, ir); break; case IR_FREF: asm_fref(as, ir); break; case IR_STRREF: asm_strref(as, ir); break; /* Loads and stores. */ case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: asm_ahuvload(as, ir); break; case IR_FLOAD: case IR_XLOAD: asm_fxload(as, ir); break; case IR_SLOAD: asm_sload(as, ir); break; case IR_ASTORE: case IR_HSTORE: case IR_USTORE: asm_ahustore(as, ir); break; case IR_FSTORE: case IR_XSTORE: asm_fxstore(as, ir); break; /* Allocations. */ case IR_SNEW: case IR_XSNEW: asm_snew(as, ir); break; case IR_TNEW: asm_tnew(as, ir); break; case IR_TDUP: asm_tdup(as, ir); break; case IR_CNEW: case IR_CNEWI: asm_cnew(as, ir); break; /* Write barriers. */ case IR_TBAR: asm_tbar(as, ir); break; case IR_OBAR: asm_obar(as, ir); break; /* Type conversions. */ case IR_TOBIT: asm_tobit(as, ir); break; case IR_CONV: asm_conv(as, ir); break; case IR_TOSTR: asm_tostr(as, ir); break; case IR_STRTO: asm_strto(as, ir); break; /* Calls. */ case IR_CALLN: case IR_CALLL: case IR_CALLS: asm_call(as, ir); break; case IR_CALLXS: asm_callx(as, ir); break; case IR_CARG: break; default: setintV(&as->J->errinfo, ir->o); lj_trace_err_info(as->J, LJ_TRERR_NYIIR); break; } } /* -- Trace setup --------------------------------------------------------- */ /* Ensure there are enough stack slots for call arguments. */ static Reg asm_setup_call_slots(ASMState *as, IRIns *ir, const CCallInfo *ci) { IRRef args[CCI_NARGS_MAX]; int nslots; asm_collectargs(as, ir, ci, args); nslots = asm_count_call_slots(as, ci, args); if (nslots > as->evenspill) /* Leave room for args in stack slots. */ as->evenspill = nslots; #if LJ_64 return irt_isfp(ir->t) ? REGSP_HINT(RID_FPRET) : REGSP_HINT(RID_RET); #else return irt_isfp(ir->t) ? REGSP_INIT : REGSP_HINT(RID_RET); #endif } /* Target-specific setup. */ static void asm_setup_target(ASMState *as) { asm_exitstub_setup(as, as->T->nsnap); } /* -- Trace patching ------------------------------------------------------ */ /* Patch exit jumps of existing machine code to a new target. */ void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) { MCode *p = T->mcode; MCode *mcarea = lj_mcode_patch(J, p, 0); MSize len = T->szmcode; MCode *px = exitstub_addr(J, exitno) - 6; MCode *pe = p+len-6; uint32_t stateaddr = u32ptr(&J2G(J)->vmstate); if (len > 5 && p[len-5] == XI_JMP && p+len-6 + *(int32_t *)(p+len-4) == px) *(int32_t *)(p+len-4) = jmprel(p+len, target); /* Do not patch parent exit for a stack check. Skip beyond vmstate update. */ for (; p < pe; p++) if (*(uint32_t *)(p+(LJ_64 ? 3 : 2)) == stateaddr && p[0] == XI_MOVmi) { p += LJ_64 ? 11 : 10; break; } lua_assert(p < pe); for (; p < pe; p++) { if ((*(uint16_t *)p & 0xf0ff) == 0x800f && p + *(int32_t *)(p+2) == px) { *(int32_t *)(p+2) = jmprel(p+6, target); p += 5; } } lj_mcode_sync(T->mcode, T->mcode + T->szmcode); lj_mcode_patch(J, mcarea, 1); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_bc.c ================================================ /* ** Bytecode instruction modes. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_bc_c #define LUA_CORE #include "lj_obj.h" #include "lj_bc.h" /* Bytecode offsets and bytecode instruction modes. */ #include "lj_bcdef.h" ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_bc.h ================================================ /* ** Bytecode instruction format. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_BC_H #define _LJ_BC_H #include "lj_def.h" #include "lj_arch.h" /* Bytecode instruction format, 32 bit wide, fields of 8 or 16 bit: ** ** +----+----+----+----+ ** | B | C | A | OP | Format ABC ** +----+----+----+----+ ** | D | A | OP | Format AD ** +-------------------- ** MSB LSB ** ** In-memory instructions are always stored in host byte order. */ /* Operand ranges and related constants. */ #define BCMAX_A 0xff #define BCMAX_B 0xff #define BCMAX_C 0xff #define BCMAX_D 0xffff #define BCBIAS_J 0x8000 #define NO_REG BCMAX_A #define NO_JMP (~(BCPos)0) /* Macros to get instruction fields. */ #define bc_op(i) ((BCOp)((i)&0xff)) #define bc_a(i) ((BCReg)(((i)>>8)&0xff)) #define bc_b(i) ((BCReg)((i)>>24)) #define bc_c(i) ((BCReg)(((i)>>16)&0xff)) #define bc_d(i) ((BCReg)((i)>>16)) #define bc_j(i) ((ptrdiff_t)bc_d(i)-BCBIAS_J) /* Macros to set instruction fields. */ #define setbc_byte(p, x, ofs) \ ((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = (uint8_t)(x) #define setbc_op(p, x) setbc_byte(p, (x), 0) #define setbc_a(p, x) setbc_byte(p, (x), 1) #define setbc_b(p, x) setbc_byte(p, (x), 3) #define setbc_c(p, x) setbc_byte(p, (x), 2) #define setbc_d(p, x) \ ((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = (uint16_t)(x) #define setbc_j(p, x) setbc_d(p, (BCPos)((int32_t)(x)+BCBIAS_J)) /* Macros to compose instructions. */ #define BCINS_ABC(o, a, b, c) \ (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(b)<<24)|((BCIns)(c)<<16)) #define BCINS_AD(o, a, d) \ (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(d)<<16)) #define BCINS_AJ(o, a, j) BCINS_AD(o, a, (BCPos)((int32_t)(j)+BCBIAS_J)) /* Bytecode instruction definition. Order matters, see below. ** ** (name, filler, Amode, Bmode, Cmode or Dmode, metamethod) ** ** The opcode name suffixes specify the type for RB/RC or RD: ** V = variable slot ** S = string const ** N = number const ** P = primitive type (~itype) ** B = unsigned byte literal ** M = multiple args/results */ #define BCDEF(_) \ /* Comparison ops. ORDER OPR. */ \ _(ISLT, var, ___, var, lt) \ _(ISGE, var, ___, var, lt) \ _(ISLE, var, ___, var, le) \ _(ISGT, var, ___, var, le) \ \ _(ISEQV, var, ___, var, eq) \ _(ISNEV, var, ___, var, eq) \ _(ISEQS, var, ___, str, eq) \ _(ISNES, var, ___, str, eq) \ _(ISEQN, var, ___, num, eq) \ _(ISNEN, var, ___, num, eq) \ _(ISEQP, var, ___, pri, eq) \ _(ISNEP, var, ___, pri, eq) \ \ /* Unary test and copy ops. */ \ _(ISTC, dst, ___, var, ___) \ _(ISFC, dst, ___, var, ___) \ _(IST, ___, ___, var, ___) \ _(ISF, ___, ___, var, ___) \ \ /* Unary ops. */ \ _(MOV, dst, ___, var, ___) \ _(NOT, dst, ___, var, ___) \ _(UNM, dst, ___, var, unm) \ _(LEN, dst, ___, var, len) \ \ /* Binary ops. ORDER OPR. VV last, POW must be next. */ \ _(ADDVN, dst, var, num, add) \ _(SUBVN, dst, var, num, sub) \ _(MULVN, dst, var, num, mul) \ _(DIVVN, dst, var, num, div) \ _(MODVN, dst, var, num, mod) \ \ _(ADDNV, dst, var, num, add) \ _(SUBNV, dst, var, num, sub) \ _(MULNV, dst, var, num, mul) \ _(DIVNV, dst, var, num, div) \ _(MODNV, dst, var, num, mod) \ \ _(ADDVV, dst, var, var, add) \ _(SUBVV, dst, var, var, sub) \ _(MULVV, dst, var, var, mul) \ _(DIVVV, dst, var, var, div) \ _(MODVV, dst, var, var, mod) \ \ _(POW, dst, var, var, pow) \ _(CAT, dst, rbase, rbase, concat) \ \ /* Constant ops. */ \ _(KSTR, dst, ___, str, ___) \ _(KCDATA, dst, ___, cdata, ___) \ _(KSHORT, dst, ___, lits, ___) \ _(KNUM, dst, ___, num, ___) \ _(KPRI, dst, ___, pri, ___) \ _(KNIL, base, ___, base, ___) \ \ /* Upvalue and function ops. */ \ _(UGET, dst, ___, uv, ___) \ _(USETV, uv, ___, var, ___) \ _(USETS, uv, ___, str, ___) \ _(USETN, uv, ___, num, ___) \ _(USETP, uv, ___, pri, ___) \ _(UCLO, rbase, ___, jump, ___) \ _(FNEW, dst, ___, func, gc) \ \ /* Table ops. */ \ _(TNEW, dst, ___, lit, gc) \ _(TDUP, dst, ___, tab, gc) \ _(GGET, dst, ___, str, index) \ _(GSET, var, ___, str, newindex) \ _(TGETV, dst, var, var, index) \ _(TGETS, dst, var, str, index) \ _(TGETB, dst, var, lit, index) \ _(TSETV, var, var, var, newindex) \ _(TSETS, var, var, str, newindex) \ _(TSETB, var, var, lit, newindex) \ _(TSETM, base, ___, num, newindex) \ \ /* Calls and vararg handling. T = tail call. */ \ _(CALLM, base, lit, lit, call) \ _(CALL, base, lit, lit, call) \ _(CALLMT, base, ___, lit, call) \ _(CALLT, base, ___, lit, call) \ _(ITERC, base, lit, lit, call) \ _(ITERN, base, lit, lit, call) \ _(VARG, base, lit, lit, ___) \ _(ISNEXT, base, ___, jump, ___) \ \ /* Returns. */ \ _(RETM, base, ___, lit, ___) \ _(RET, rbase, ___, lit, ___) \ _(RET0, rbase, ___, lit, ___) \ _(RET1, rbase, ___, lit, ___) \ \ /* Loops and branches. I/J = interp/JIT, I/C/L = init/call/loop. */ \ _(FORI, base, ___, jump, ___) \ _(JFORI, base, ___, jump, ___) \ \ _(FORL, base, ___, jump, ___) \ _(IFORL, base, ___, jump, ___) \ _(JFORL, base, ___, lit, ___) \ \ _(ITERL, base, ___, jump, ___) \ _(IITERL, base, ___, jump, ___) \ _(JITERL, base, ___, lit, ___) \ \ _(LOOP, rbase, ___, jump, ___) \ _(ILOOP, rbase, ___, jump, ___) \ _(JLOOP, rbase, ___, lit, ___) \ \ _(JMP, rbase, ___, jump, ___) \ \ /* Function headers. I/J = interp/JIT, F/V/C = fixarg/vararg/C func. */ \ _(FUNCF, rbase, ___, ___, ___) \ _(IFUNCF, rbase, ___, ___, ___) \ _(JFUNCF, rbase, ___, lit, ___) \ _(FUNCV, rbase, ___, ___, ___) \ _(IFUNCV, rbase, ___, ___, ___) \ _(JFUNCV, rbase, ___, lit, ___) \ _(FUNCC, rbase, ___, ___, ___) \ _(FUNCCW, rbase, ___, ___, ___) /* Bytecode opcode numbers. */ typedef enum { #define BCENUM(name, ma, mb, mc, mt) BC_##name, BCDEF(BCENUM) #undef BCENUM BC__MAX } BCOp; LJ_STATIC_ASSERT((int)BC_ISEQV+1 == (int)BC_ISNEV); LJ_STATIC_ASSERT(((int)BC_ISEQV^1) == (int)BC_ISNEV); LJ_STATIC_ASSERT(((int)BC_ISEQS^1) == (int)BC_ISNES); LJ_STATIC_ASSERT(((int)BC_ISEQN^1) == (int)BC_ISNEN); LJ_STATIC_ASSERT(((int)BC_ISEQP^1) == (int)BC_ISNEP); LJ_STATIC_ASSERT(((int)BC_ISLT^1) == (int)BC_ISGE); LJ_STATIC_ASSERT(((int)BC_ISLE^1) == (int)BC_ISGT); LJ_STATIC_ASSERT(((int)BC_ISLT^3) == (int)BC_ISGT); LJ_STATIC_ASSERT((int)BC_IST-(int)BC_ISTC == (int)BC_ISF-(int)BC_ISFC); LJ_STATIC_ASSERT((int)BC_CALLT-(int)BC_CALL == (int)BC_CALLMT-(int)BC_CALLM); LJ_STATIC_ASSERT((int)BC_CALLMT + 1 == (int)BC_CALLT); LJ_STATIC_ASSERT((int)BC_RETM + 1 == (int)BC_RET); LJ_STATIC_ASSERT((int)BC_FORL + 1 == (int)BC_IFORL); LJ_STATIC_ASSERT((int)BC_FORL + 2 == (int)BC_JFORL); LJ_STATIC_ASSERT((int)BC_ITERL + 1 == (int)BC_IITERL); LJ_STATIC_ASSERT((int)BC_ITERL + 2 == (int)BC_JITERL); LJ_STATIC_ASSERT((int)BC_LOOP + 1 == (int)BC_ILOOP); LJ_STATIC_ASSERT((int)BC_LOOP + 2 == (int)BC_JLOOP); LJ_STATIC_ASSERT((int)BC_FUNCF + 1 == (int)BC_IFUNCF); LJ_STATIC_ASSERT((int)BC_FUNCF + 2 == (int)BC_JFUNCF); LJ_STATIC_ASSERT((int)BC_FUNCV + 1 == (int)BC_IFUNCV); LJ_STATIC_ASSERT((int)BC_FUNCV + 2 == (int)BC_JFUNCV); /* This solves a circular dependency problem, change as needed. */ #define FF_next_N 4 /* Stack slots used by FORI/FORL, relative to operand A. */ enum { FORL_IDX, FORL_STOP, FORL_STEP, FORL_EXT }; /* Bytecode operand modes. ORDER BCMode */ typedef enum { BCMnone, BCMdst, BCMbase, BCMvar, BCMrbase, BCMuv, /* Mode A must be <= 7 */ BCMlit, BCMlits, BCMpri, BCMnum, BCMstr, BCMtab, BCMfunc, BCMjump, BCMcdata, BCM_max } BCMode; #define BCM___ BCMnone #define bcmode_a(op) ((BCMode)(lj_bc_mode[op] & 7)) #define bcmode_b(op) ((BCMode)((lj_bc_mode[op]>>3) & 15)) #define bcmode_c(op) ((BCMode)((lj_bc_mode[op]>>7) & 15)) #define bcmode_d(op) bcmode_c(op) #define bcmode_hasd(op) ((lj_bc_mode[op] & (15<<3)) == (BCMnone<<3)) #define bcmode_mm(op) ((MMS)(lj_bc_mode[op]>>11)) #define BCMODE(name, ma, mb, mc, mm) \ (BCM##ma|(BCM##mb<<3)|(BCM##mc<<7)|(MM_##mm<<11)), #define BCMODE_FF 0 static LJ_AINLINE int bc_isret(BCOp op) { return (op == BC_RETM || op == BC_RET || op == BC_RET0 || op == BC_RET1); } LJ_DATA const uint16_t lj_bc_mode[]; LJ_DATA const uint16_t lj_bc_ofs[]; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_bcdump.h ================================================ /* ** Bytecode dump definitions. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_BCDUMP_H #define _LJ_BCDUMP_H #include "lj_obj.h" #include "lj_lex.h" /* -- Bytecode dump format ------------------------------------------------ */ /* ** dump = header proto+ 0U ** header = ESC 'L' 'J' versionB flagsU [namelenU nameB*] ** proto = lengthU pdata ** pdata = phead bcinsW* uvdataH* kgc* knum* [debugB*] ** phead = flagsB numparamsB framesizeB numuvB numkgcU numknU numbcU ** [debuglenU [firstlineU numlineU]] ** kgc = kgctypeU { ktab | (loU hiU) | (rloU rhiU iloU ihiU) | strB* } ** knum = intU0 | (loU1 hiU) ** ktab = narrayU nhashU karray* khash* ** karray = ktabk ** khash = ktabk ktabk ** ktabk = ktabtypeU { intU | (loU hiU) | strB* } ** ** B = 8 bit, H = 16 bit, W = 32 bit, U = ULEB128 of W, U0/U1 = ULEB128 of W+1 */ /* Bytecode dump header. */ #define BCDUMP_HEAD1 0x1b #define BCDUMP_HEAD2 0x4c #define BCDUMP_HEAD3 0x4a /* If you perform *any* kind of private modifications to the bytecode itself ** or to the dump format, you *must* set BCDUMP_VERSION to 0x80 or higher. */ #define BCDUMP_VERSION 1 /* Compatibility flags. */ #define BCDUMP_F_BE 0x01 #define BCDUMP_F_STRIP 0x02 #define BCDUMP_F_FFI 0x04 #define BCDUMP_F_KNOWN (BCDUMP_F_FFI*2-1) /* Type codes for the GC constants of a prototype. Plus length for strings. */ enum { BCDUMP_KGC_CHILD, BCDUMP_KGC_TAB, BCDUMP_KGC_I64, BCDUMP_KGC_U64, BCDUMP_KGC_COMPLEX, BCDUMP_KGC_STR }; /* Type codes for the keys/values of a constant table. */ enum { BCDUMP_KTAB_NIL, BCDUMP_KTAB_FALSE, BCDUMP_KTAB_TRUE, BCDUMP_KTAB_INT, BCDUMP_KTAB_NUM, BCDUMP_KTAB_STR }; /* -- Bytecode reader/writer ---------------------------------------------- */ LJ_FUNC int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, void *data, int strip); LJ_FUNC GCproto *lj_bcread(LexState *ls); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_bcread.c ================================================ /* ** Bytecode reader. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_bcread_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_bc.h" #if LJ_HASFFI #include "lj_ctype.h" #include "lj_cdata.h" #include "lualib.h" #endif #include "lj_lex.h" #include "lj_bcdump.h" #include "lj_state.h" /* Reuse some lexer fields for our own purposes. */ #define bcread_flags(ls) ls->level #define bcread_swap(ls) \ ((bcread_flags(ls) & BCDUMP_F_BE) != LJ_BE*BCDUMP_F_BE) #define bcread_oldtop(L, ls) restorestack(L, ls->lastline) #define bcread_savetop(L, ls, top) \ ls->lastline = (BCLine)savestack(L, (top)) /* -- Input buffer handling ----------------------------------------------- */ /* Throw reader error. */ static LJ_NOINLINE void bcread_error(LexState *ls, ErrMsg em) { lua_State *L = ls->L; const char *name = ls->chunkarg; if (*name == BCDUMP_HEAD1) name = "(binary)"; else if (*name == '@' || *name == '=') name++; lj_str_pushf(L, "%s: %s", name, err2msg(em)); lj_err_throw(L, LUA_ERRSYNTAX); } /* Resize input buffer. */ static void bcread_resize(LexState *ls, MSize len) { if (ls->sb.sz < len) { MSize sz = ls->sb.sz * 2; while (len > sz) sz = sz * 2; lj_str_resizebuf(ls->L, &ls->sb, sz); /* Caveat: this may change ls->sb.buf which may affect ls->p. */ } } /* Refill buffer if needed. */ static LJ_NOINLINE void bcread_fill(LexState *ls, MSize len, int need) { lua_assert(len != 0); if (len > LJ_MAX_MEM || ls->current < 0) bcread_error(ls, LJ_ERR_BCBAD); do { const char *buf; size_t size; if (ls->n) { /* Copy remainder to buffer. */ if (ls->sb.n) { /* Move down in buffer. */ lua_assert(ls->p + ls->n == ls->sb.buf + ls->sb.n); if (ls->n != ls->sb.n) memmove(ls->sb.buf, ls->p, ls->n); } else { /* Copy from buffer provided by reader. */ bcread_resize(ls, len); memcpy(ls->sb.buf, ls->p, ls->n); } ls->p = ls->sb.buf; } ls->sb.n = ls->n; buf = ls->rfunc(ls->L, ls->rdata, &size); /* Get more data from reader. */ if (buf == NULL || size == 0) { /* EOF? */ if (need) bcread_error(ls, LJ_ERR_BCBAD); ls->current = -1; /* Only bad if we get called again. */ break; } if (ls->sb.n) { /* Append to buffer. */ MSize n = ls->sb.n + (MSize)size; bcread_resize(ls, n < len ? len : n); memcpy(ls->sb.buf + ls->sb.n, buf, size); ls->n = ls->sb.n = n; ls->p = ls->sb.buf; } else { /* Return buffer provided by reader. */ ls->n = (MSize)size; ls->p = buf; } } while (ls->n < len); } /* Need a certain number of bytes. */ static LJ_AINLINE void bcread_need(LexState *ls, MSize len) { if (LJ_UNLIKELY(ls->n < len)) bcread_fill(ls, len, 1); } /* Want to read up to a certain number of bytes, but may need less. */ static LJ_AINLINE void bcread_want(LexState *ls, MSize len) { if (LJ_UNLIKELY(ls->n < len)) bcread_fill(ls, len, 0); } #define bcread_dec(ls) check_exp(ls->n > 0, ls->n--) #define bcread_consume(ls, len) check_exp(ls->n >= (len), ls->n -= (len)) /* Return memory block from buffer. */ static uint8_t *bcread_mem(LexState *ls, MSize len) { uint8_t *p = (uint8_t *)ls->p; bcread_consume(ls, len); ls->p = (char *)p + len; return p; } /* Copy memory block from buffer. */ static void bcread_block(LexState *ls, void *q, MSize len) { memcpy(q, bcread_mem(ls, len), len); } /* Read byte from buffer. */ static LJ_AINLINE uint32_t bcread_byte(LexState *ls) { bcread_dec(ls); return (uint32_t)(uint8_t)*ls->p++; } /* Read ULEB128 value from buffer. */ static uint32_t bcread_uleb128(LexState *ls) { const uint8_t *p = (const uint8_t *)ls->p; uint32_t v = *p++; if (LJ_UNLIKELY(v >= 0x80)) { int sh = 0; v &= 0x7f; do { v |= ((*p & 0x7f) << (sh += 7)); bcread_dec(ls); } while (*p++ >= 0x80); } bcread_dec(ls); ls->p = (char *)p; return v; } /* Read top 32 bits of 33 bit ULEB128 value from buffer. */ static uint32_t bcread_uleb128_33(LexState *ls) { const uint8_t *p = (const uint8_t *)ls->p; uint32_t v = (*p++ >> 1); if (LJ_UNLIKELY(v >= 0x40)) { int sh = -1; v &= 0x3f; do { v |= ((*p & 0x7f) << (sh += 7)); bcread_dec(ls); } while (*p++ >= 0x80); } bcread_dec(ls); ls->p = (char *)p; return v; } /* -- Bytecode reader ----------------------------------------------------- */ /* Read debug info of a prototype. */ static void bcread_dbg(LexState *ls, GCproto *pt, MSize sizedbg) { void *lineinfo = (void *)proto_lineinfo(pt); bcread_block(ls, lineinfo, sizedbg); /* Swap lineinfo if the endianess differs. */ if (bcread_swap(ls) && pt->numline >= 256) { MSize i, n = pt->sizebc-1; if (pt->numline < 65536) { uint16_t *p = (uint16_t *)lineinfo; for (i = 0; i < n; i++) p[i] = (uint16_t)((p[i] >> 8)|(p[i] << 8)); } else { uint32_t *p = (uint32_t *)lineinfo; for (i = 0; i < n; i++) p[i] = lj_bswap(p[i]); } } } /* Find pointer to varinfo. */ static const void *bcread_varinfo(GCproto *pt) { const uint8_t *p = proto_uvinfo(pt); MSize n = pt->sizeuv; if (n) while (*p++ || --n) ; return p; } /* Read a single constant key/value of a template table. */ static void bcread_ktabk(LexState *ls, TValue *o) { MSize tp = bcread_uleb128(ls); if (tp >= BCDUMP_KTAB_STR) { MSize len = tp - BCDUMP_KTAB_STR; const char *p = (const char *)bcread_mem(ls, len); setstrV(ls->L, o, lj_str_new(ls->L, p, len)); } else if (tp == BCDUMP_KTAB_INT) { setintV(o, (int32_t)bcread_uleb128(ls)); } else if (tp == BCDUMP_KTAB_NUM) { o->u32.lo = bcread_uleb128(ls); o->u32.hi = bcread_uleb128(ls); } else { lua_assert(tp <= BCDUMP_KTAB_TRUE); setitype(o, ~tp); } } /* Read a template table. */ static GCtab *bcread_ktab(LexState *ls) { MSize narray = bcread_uleb128(ls); MSize nhash = bcread_uleb128(ls); GCtab *t = lj_tab_new(ls->L, narray, hsize2hbits(nhash)); if (narray) { /* Read array entries. */ MSize i; TValue *o = tvref(t->array); for (i = 0; i < narray; i++, o++) bcread_ktabk(ls, o); } if (nhash) { /* Read hash entries. */ MSize i; for (i = 0; i < nhash; i++) { TValue key; bcread_ktabk(ls, &key); lua_assert(!tvisnil(&key)); bcread_ktabk(ls, lj_tab_set(ls->L, t, &key)); } } return t; } /* Read GC constants of a prototype. */ static void bcread_kgc(LexState *ls, GCproto *pt, MSize sizekgc) { MSize i; GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc; for (i = 0; i < sizekgc; i++, kr++) { MSize tp = bcread_uleb128(ls); if (tp >= BCDUMP_KGC_STR) { MSize len = tp - BCDUMP_KGC_STR; const char *p = (const char *)bcread_mem(ls, len); setgcref(*kr, obj2gco(lj_str_new(ls->L, p, len))); } else if (tp == BCDUMP_KGC_TAB) { setgcref(*kr, obj2gco(bcread_ktab(ls))); #if LJ_HASFFI } else if (tp != BCDUMP_KGC_CHILD) { CTypeID id = tp == BCDUMP_KGC_COMPLEX ? CTID_COMPLEX_DOUBLE : tp == BCDUMP_KGC_I64 ? CTID_INT64 : CTID_UINT64; CTSize sz = tp == BCDUMP_KGC_COMPLEX ? 16 : 8; GCcdata *cd = lj_cdata_new_(ls->L, id, sz); TValue *p = (TValue *)cdataptr(cd); setgcref(*kr, obj2gco(cd)); p[0].u32.lo = bcread_uleb128(ls); p[0].u32.hi = bcread_uleb128(ls); if (tp == BCDUMP_KGC_COMPLEX) { p[1].u32.lo = bcread_uleb128(ls); p[1].u32.hi = bcread_uleb128(ls); } #endif } else { lua_State *L = ls->L; lua_assert(tp == BCDUMP_KGC_CHILD); if (L->top <= bcread_oldtop(L, ls)) /* Stack underflow? */ bcread_error(ls, LJ_ERR_BCBAD); L->top--; setgcref(*kr, obj2gco(protoV(L->top))); } } } /* Read number constants of a prototype. */ static void bcread_knum(LexState *ls, GCproto *pt, MSize sizekn) { MSize i; TValue *o = mref(pt->k, TValue); for (i = 0; i < sizekn; i++, o++) { int isnum = (ls->p[0] & 1); uint32_t lo = bcread_uleb128_33(ls); if (isnum) { o->u32.lo = lo; o->u32.hi = bcread_uleb128(ls); } else { setintV(o, lo); } } } /* Read bytecode instructions. */ static void bcread_bytecode(LexState *ls, GCproto *pt, MSize sizebc) { BCIns *bc = proto_bc(pt); bc[0] = BCINS_AD((pt->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, pt->framesize, 0); bcread_block(ls, bc+1, (sizebc-1)*(MSize)sizeof(BCIns)); /* Swap bytecode instructions if the endianess differs. */ if (bcread_swap(ls)) { MSize i; for (i = 1; i < sizebc; i++) bc[i] = lj_bswap(bc[i]); } } /* Read upvalue refs. */ static void bcread_uv(LexState *ls, GCproto *pt, MSize sizeuv) { if (sizeuv) { uint16_t *uv = proto_uv(pt); bcread_block(ls, uv, sizeuv*2); /* Swap upvalue refs if the endianess differs. */ if (bcread_swap(ls)) { MSize i; for (i = 0; i < sizeuv; i++) uv[i] = (uint16_t)((uv[i] >> 8)|(uv[i] << 8)); } } } /* Read a prototype. */ static GCproto *bcread_proto(LexState *ls) { GCproto *pt; MSize framesize, numparams, flags, sizeuv, sizekgc, sizekn, sizebc, sizept; MSize ofsk, ofsuv, ofsdbg; MSize sizedbg = 0; BCLine firstline = 0, numline = 0; MSize len, startn; /* Read length. */ if (ls->n > 0 && ls->p[0] == 0) { /* Shortcut EOF. */ ls->n--; ls->p++; return NULL; } bcread_want(ls, 5); len = bcread_uleb128(ls); if (!len) return NULL; /* EOF */ bcread_need(ls, len); startn = ls->n; /* Read prototype header. */ flags = bcread_byte(ls); numparams = bcread_byte(ls); framesize = bcread_byte(ls); sizeuv = bcread_byte(ls); sizekgc = bcread_uleb128(ls); sizekn = bcread_uleb128(ls); sizebc = bcread_uleb128(ls) + 1; if (!(bcread_flags(ls) & BCDUMP_F_STRIP)) { sizedbg = bcread_uleb128(ls); if (sizedbg) { firstline = bcread_uleb128(ls); numline = bcread_uleb128(ls); } } /* Calculate total size of prototype including all colocated arrays. */ sizept = (MSize)sizeof(GCproto) + sizebc*(MSize)sizeof(BCIns) + sizekgc*(MSize)sizeof(GCRef); sizept = (sizept + (MSize)sizeof(TValue)-1) & ~((MSize)sizeof(TValue)-1); ofsk = sizept; sizept += sizekn*(MSize)sizeof(TValue); ofsuv = sizept; sizept += ((sizeuv+1)&~1)*2; ofsdbg = sizept; sizept += sizedbg; /* Allocate prototype object and initialize its fields. */ pt = (GCproto *)lj_mem_newgco(ls->L, (MSize)sizept); pt->gct = ~LJ_TPROTO; pt->numparams = (uint8_t)numparams; pt->framesize = (uint8_t)framesize; pt->sizebc = sizebc; setmref(pt->k, (char *)pt + ofsk); setmref(pt->uv, (char *)pt + ofsuv); pt->sizekgc = 0; /* Set to zero until fully initialized. */ pt->sizekn = sizekn; pt->sizept = sizept; pt->sizeuv = (uint8_t)sizeuv; pt->flags = (uint8_t)flags; pt->trace = 0; setgcref(pt->chunkname, obj2gco(ls->chunkname)); /* Close potentially uninitialized gap between bc and kgc. */ *(uint32_t *)((char *)pt + ofsk - sizeof(GCRef)*(sizekgc+1)) = 0; /* Read bytecode instructions and upvalue refs. */ bcread_bytecode(ls, pt, sizebc); bcread_uv(ls, pt, sizeuv); /* Read constants. */ bcread_kgc(ls, pt, sizekgc); pt->sizekgc = sizekgc; bcread_knum(ls, pt, sizekn); /* Read and initialize debug info. */ pt->firstline = firstline; pt->numline = numline; if (sizedbg) { MSize sizeli = (sizebc-1) << (numline < 256 ? 0 : numline < 65536 ? 1 : 2); setmref(pt->lineinfo, (char *)pt + ofsdbg); setmref(pt->uvinfo, (char *)pt + ofsdbg + sizeli); bcread_dbg(ls, pt, sizedbg); setmref(pt->varinfo, bcread_varinfo(pt)); } else { setmref(pt->lineinfo, NULL); setmref(pt->uvinfo, NULL); setmref(pt->varinfo, NULL); } if (len != startn - ls->n) bcread_error(ls, LJ_ERR_BCBAD); return pt; } /* Read and check header of bytecode dump. */ static int bcread_header(LexState *ls) { uint32_t flags; bcread_want(ls, 3+5+5); if (bcread_byte(ls) != BCDUMP_HEAD2 || bcread_byte(ls) != BCDUMP_HEAD3 || bcread_byte(ls) != BCDUMP_VERSION) return 0; bcread_flags(ls) = flags = bcread_uleb128(ls); if ((flags & ~(BCDUMP_F_KNOWN)) != 0) return 0; if ((flags & BCDUMP_F_FFI)) { #if LJ_HASFFI lua_State *L = ls->L; if (!ctype_ctsG(G(L))) { ptrdiff_t oldtop = savestack(L, L->top); luaopen_ffi(L); /* Load FFI library on-demand. */ L->top = restorestack(L, oldtop); } #else return 0; #endif } if ((flags & BCDUMP_F_STRIP)) { ls->chunkname = lj_str_newz(ls->L, ls->chunkarg); } else { MSize len = bcread_uleb128(ls); bcread_need(ls, len); ls->chunkname = lj_str_new(ls->L, (const char *)bcread_mem(ls, len), len); } return 1; /* Ok. */ } /* Read a bytecode dump. */ GCproto *lj_bcread(LexState *ls) { lua_State *L = ls->L; lua_assert(ls->current == BCDUMP_HEAD1); bcread_savetop(L, ls, L->top); lj_str_resetbuf(&ls->sb); /* Check for a valid bytecode dump header. */ if (!bcread_header(ls)) bcread_error(ls, LJ_ERR_BCFMT); for (;;) { /* Process all prototypes in the bytecode dump. */ GCproto *pt = bcread_proto(ls); if (!pt) break; setprotoV(L, L->top, pt); incr_top(L); } if ((int32_t)ls->n > 0 || L->top-1 != bcread_oldtop(L, ls)) bcread_error(ls, LJ_ERR_BCBAD); /* Pop off last prototype. */ L->top--; return protoV(L->top); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_bcwrite.c ================================================ /* ** Bytecode writer. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_bcwrite_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_str.h" #include "lj_bc.h" #if LJ_HASFFI #include "lj_ctype.h" #endif #if LJ_HASJIT #include "lj_dispatch.h" #include "lj_jit.h" #endif #include "lj_bcdump.h" #include "lj_vm.h" /* Context for bytecode writer. */ typedef struct BCWriteCtx { SBuf sb; /* Output buffer. */ lua_State *L; /* Lua state. */ GCproto *pt; /* Root prototype. */ lua_Writer wfunc; /* Writer callback. */ void *wdata; /* Writer callback data. */ int strip; /* Strip debug info. */ int status; /* Status from writer callback. */ } BCWriteCtx; /* -- Output buffer handling ---------------------------------------------- */ /* Resize buffer if needed. */ static LJ_NOINLINE void bcwrite_resize(BCWriteCtx *ctx, MSize len) { MSize sz = ctx->sb.sz * 2; while (ctx->sb.n + len > sz) sz = sz * 2; lj_str_resizebuf(ctx->L, &ctx->sb, sz); } /* Need a certain amount of buffer space. */ static LJ_AINLINE void bcwrite_need(BCWriteCtx *ctx, MSize len) { if (LJ_UNLIKELY(ctx->sb.n + len > ctx->sb.sz)) bcwrite_resize(ctx, len); } /* Add memory block to buffer. */ static void bcwrite_block(BCWriteCtx *ctx, const void *p, MSize len) { uint8_t *q = (uint8_t *)(ctx->sb.buf + ctx->sb.n); MSize i; ctx->sb.n += len; for (i = 0; i < len; i++) q[i] = ((uint8_t *)p)[i]; } /* Add byte to buffer. */ static LJ_AINLINE void bcwrite_byte(BCWriteCtx *ctx, uint8_t b) { ctx->sb.buf[ctx->sb.n++] = b; } /* Add ULEB128 value to buffer. */ static void bcwrite_uleb128(BCWriteCtx *ctx, uint32_t v) { MSize n = ctx->sb.n; uint8_t *p = (uint8_t *)ctx->sb.buf; for (; v >= 0x80; v >>= 7) p[n++] = (uint8_t)((v & 0x7f) | 0x80); p[n++] = (uint8_t)v; ctx->sb.n = n; } /* -- Bytecode writer ----------------------------------------------------- */ /* Write a single constant key/value of a template table. */ static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow) { bcwrite_need(ctx, 1+10); if (tvisstr(o)) { const GCstr *str = strV(o); MSize len = str->len; bcwrite_need(ctx, 5+len); bcwrite_uleb128(ctx, BCDUMP_KTAB_STR+len); bcwrite_block(ctx, strdata(str), len); } else if (tvisint(o)) { bcwrite_byte(ctx, BCDUMP_KTAB_INT); bcwrite_uleb128(ctx, intV(o)); } else if (tvisnum(o)) { if (!LJ_DUALNUM && narrow) { /* Narrow number constants to integers. */ lua_Number num = numV(o); int32_t k = lj_num2int(num); if (num == (lua_Number)k) { /* -0 is never a constant. */ bcwrite_byte(ctx, BCDUMP_KTAB_INT); bcwrite_uleb128(ctx, k); return; } } bcwrite_byte(ctx, BCDUMP_KTAB_NUM); bcwrite_uleb128(ctx, o->u32.lo); bcwrite_uleb128(ctx, o->u32.hi); } else { lua_assert(tvispri(o)); bcwrite_byte(ctx, BCDUMP_KTAB_NIL+~itype(o)); } } /* Write a template table. */ static void bcwrite_ktab(BCWriteCtx *ctx, const GCtab *t) { MSize narray = 0, nhash = 0; if (t->asize > 0) { /* Determine max. length of array part. */ ptrdiff_t i; TValue *array = tvref(t->array); for (i = (ptrdiff_t)t->asize-1; i >= 0; i--) if (!tvisnil(&array[i])) break; narray = (MSize)(i+1); } if (t->hmask > 0) { /* Count number of used hash slots. */ MSize i, hmask = t->hmask; Node *node = noderef(t->node); for (i = 0; i <= hmask; i++) nhash += !tvisnil(&node[i].val); } /* Write number of array slots and hash slots. */ bcwrite_uleb128(ctx, narray); bcwrite_uleb128(ctx, nhash); if (narray) { /* Write array entries (may contain nil). */ MSize i; TValue *o = tvref(t->array); for (i = 0; i < narray; i++, o++) bcwrite_ktabk(ctx, o, 1); } if (nhash) { /* Write hash entries. */ MSize i = nhash; Node *node = noderef(t->node) + t->hmask; for (;; node--) if (!tvisnil(&node->val)) { bcwrite_ktabk(ctx, &node->key, 0); bcwrite_ktabk(ctx, &node->val, 1); if (--i == 0) break; } } } /* Write GC constants of a prototype. */ static void bcwrite_kgc(BCWriteCtx *ctx, GCproto *pt) { MSize i, sizekgc = pt->sizekgc; GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc; for (i = 0; i < sizekgc; i++, kr++) { GCobj *o = gcref(*kr); MSize tp, need = 1; /* Determine constant type and needed size. */ if (o->gch.gct == ~LJ_TSTR) { tp = BCDUMP_KGC_STR + gco2str(o)->len; need = 5+gco2str(o)->len; } else if (o->gch.gct == ~LJ_TPROTO) { lua_assert((pt->flags & PROTO_CHILD)); tp = BCDUMP_KGC_CHILD; #if LJ_HASFFI } else if (o->gch.gct == ~LJ_TCDATA) { CTypeID id = gco2cd(o)->ctypeid; need = 1+4*5; if (id == CTID_INT64) { tp = BCDUMP_KGC_I64; } else if (id == CTID_UINT64) { tp = BCDUMP_KGC_U64; } else { lua_assert(id == CTID_COMPLEX_DOUBLE); tp = BCDUMP_KGC_COMPLEX; } #endif } else { lua_assert(o->gch.gct == ~LJ_TTAB); tp = BCDUMP_KGC_TAB; need = 1+2*5; } /* Write constant type. */ bcwrite_need(ctx, need); bcwrite_uleb128(ctx, tp); /* Write constant data (if any). */ if (tp >= BCDUMP_KGC_STR) { bcwrite_block(ctx, strdata(gco2str(o)), gco2str(o)->len); } else if (tp == BCDUMP_KGC_TAB) { bcwrite_ktab(ctx, gco2tab(o)); #if LJ_HASFFI } else if (tp != BCDUMP_KGC_CHILD) { cTValue *p = (TValue *)cdataptr(gco2cd(o)); bcwrite_uleb128(ctx, p[0].u32.lo); bcwrite_uleb128(ctx, p[0].u32.hi); if (tp == BCDUMP_KGC_COMPLEX) { bcwrite_uleb128(ctx, p[1].u32.lo); bcwrite_uleb128(ctx, p[1].u32.hi); } #endif } } } /* Write number constants of a prototype. */ static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt) { MSize i, sizekn = pt->sizekn; cTValue *o = mref(pt->k, TValue); bcwrite_need(ctx, 10*sizekn); for (i = 0; i < sizekn; i++, o++) { int32_t k; if (tvisint(o)) { k = intV(o); goto save_int; } else { /* Write a 33 bit ULEB128 for the int (lsb=0) or loword (lsb=1). */ if (!LJ_DUALNUM) { /* Narrow number constants to integers. */ lua_Number num = numV(o); k = lj_num2int(num); if (num == (lua_Number)k) { /* -0 is never a constant. */ save_int: bcwrite_uleb128(ctx, 2*(uint32_t)k | ((uint32_t)k & 0x80000000u)); if (k < 0) { char *p = &ctx->sb.buf[ctx->sb.n-1]; *p = (*p & 7) | ((k>>27) & 0x18); } continue; } } bcwrite_uleb128(ctx, 1+(2*o->u32.lo | (o->u32.lo & 0x80000000u))); if (o->u32.lo >= 0x80000000u) { char *p = &ctx->sb.buf[ctx->sb.n-1]; *p = (*p & 7) | ((o->u32.lo>>27) & 0x18); } bcwrite_uleb128(ctx, o->u32.hi); } } } /* Write bytecode instructions. */ static void bcwrite_bytecode(BCWriteCtx *ctx, GCproto *pt) { MSize nbc = pt->sizebc-1; /* Omit the [JI]FUNC* header. */ #if LJ_HASJIT uint8_t *p = (uint8_t *)&ctx->sb.buf[ctx->sb.n]; #endif bcwrite_block(ctx, proto_bc(pt)+1, nbc*(MSize)sizeof(BCIns)); #if LJ_HASJIT /* Unpatch modified bytecode containing ILOOP/JLOOP etc. */ if ((pt->flags & PROTO_ILOOP) || pt->trace) { jit_State *J = L2J(ctx->L); MSize i; for (i = 0; i < nbc; i++, p += sizeof(BCIns)) { BCOp op = (BCOp)p[LJ_ENDIAN_SELECT(0, 3)]; if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP || op == BC_JFORI) { p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_IFORL+BC_FORL); } else if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) { BCReg rd = p[LJ_ENDIAN_SELECT(2, 1)] + (p[LJ_ENDIAN_SELECT(3, 0)] << 8); BCIns ins = traceref(J, rd)->startins; p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_JFORL+BC_FORL); p[LJ_ENDIAN_SELECT(2, 1)] = bc_c(ins); p[LJ_ENDIAN_SELECT(3, 0)] = bc_b(ins); } } } #endif } /* Write prototype. */ static void bcwrite_proto(BCWriteCtx *ctx, GCproto *pt) { MSize sizedbg = 0; /* Recursively write children of prototype. */ if ((pt->flags & PROTO_CHILD)) { ptrdiff_t i, n = pt->sizekgc; GCRef *kr = mref(pt->k, GCRef) - 1; for (i = 0; i < n; i++, kr--) { GCobj *o = gcref(*kr); if (o->gch.gct == ~LJ_TPROTO) bcwrite_proto(ctx, gco2pt(o)); } } /* Start writing the prototype info to a buffer. */ lj_str_resetbuf(&ctx->sb); ctx->sb.n = 5; /* Leave room for final size. */ bcwrite_need(ctx, 4+6*5+(pt->sizebc-1)*(MSize)sizeof(BCIns)+pt->sizeuv*2); /* Write prototype header. */ bcwrite_byte(ctx, (pt->flags & (PROTO_CHILD|PROTO_VARARG|PROTO_FFI))); bcwrite_byte(ctx, pt->numparams); bcwrite_byte(ctx, pt->framesize); bcwrite_byte(ctx, pt->sizeuv); bcwrite_uleb128(ctx, pt->sizekgc); bcwrite_uleb128(ctx, pt->sizekn); bcwrite_uleb128(ctx, pt->sizebc-1); if (!ctx->strip) { if (proto_lineinfo(pt)) sizedbg = pt->sizept - (MSize)((char *)proto_lineinfo(pt) - (char *)pt); bcwrite_uleb128(ctx, sizedbg); if (sizedbg) { bcwrite_uleb128(ctx, pt->firstline); bcwrite_uleb128(ctx, pt->numline); } } /* Write bytecode instructions and upvalue refs. */ bcwrite_bytecode(ctx, pt); bcwrite_block(ctx, proto_uv(pt), pt->sizeuv*2); /* Write constants. */ bcwrite_kgc(ctx, pt); bcwrite_knum(ctx, pt); /* Write debug info, if not stripped. */ if (sizedbg) { bcwrite_need(ctx, sizedbg); bcwrite_block(ctx, proto_lineinfo(pt), sizedbg); } /* Pass buffer to writer function. */ if (ctx->status == 0) { MSize n = ctx->sb.n - 5; MSize nn = (lj_fls(n)+8)*9 >> 6; ctx->sb.n = 5 - nn; bcwrite_uleb128(ctx, n); /* Fill in final size. */ lua_assert(ctx->sb.n == 5); ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf+5-nn, nn+n, ctx->wdata); } } /* Write header of bytecode dump. */ static void bcwrite_header(BCWriteCtx *ctx) { GCstr *chunkname = proto_chunkname(ctx->pt); const char *name = strdata(chunkname); MSize len = chunkname->len; lj_str_resetbuf(&ctx->sb); bcwrite_need(ctx, 5+5+len); bcwrite_byte(ctx, BCDUMP_HEAD1); bcwrite_byte(ctx, BCDUMP_HEAD2); bcwrite_byte(ctx, BCDUMP_HEAD3); bcwrite_byte(ctx, BCDUMP_VERSION); bcwrite_byte(ctx, (ctx->strip ? BCDUMP_F_STRIP : 0) + (LJ_BE ? BCDUMP_F_BE : 0) + ((ctx->pt->flags & PROTO_FFI) ? BCDUMP_F_FFI : 0)); if (!ctx->strip) { bcwrite_uleb128(ctx, len); bcwrite_block(ctx, name, len); } ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf, ctx->sb.n, ctx->wdata); } /* Write footer of bytecode dump. */ static void bcwrite_footer(BCWriteCtx *ctx) { if (ctx->status == 0) { uint8_t zero = 0; ctx->status = ctx->wfunc(ctx->L, &zero, 1, ctx->wdata); } } /* Protected callback for bytecode writer. */ static TValue *cpwriter(lua_State *L, lua_CFunction dummy, void *ud) { BCWriteCtx *ctx = (BCWriteCtx *)ud; UNUSED(dummy); lj_str_resizebuf(L, &ctx->sb, 1024); /* Avoids resize for most prototypes. */ bcwrite_header(ctx); bcwrite_proto(ctx, ctx->pt); bcwrite_footer(ctx); return NULL; } /* Write bytecode for a prototype. */ int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, void *data, int strip) { BCWriteCtx ctx; int status; ctx.L = L; ctx.pt = pt; ctx.wfunc = writer; ctx.wdata = data; ctx.strip = strip; ctx.status = 0; lj_str_initbuf(&ctx.sb); status = lj_vm_cpcall(L, NULL, &ctx, cpwriter); if (status == 0) status = ctx.status; lj_str_freebuf(G(ctx.L), &ctx.sb); return status; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_carith.c ================================================ /* ** C data arithmetic. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "lj_obj.h" #if LJ_HASFFI #include "lj_gc.h" #include "lj_err.h" #include "lj_tab.h" #include "lj_meta.h" #include "lj_ctype.h" #include "lj_cconv.h" #include "lj_cdata.h" #include "lj_carith.h" /* -- C data arithmetic --------------------------------------------------- */ /* Binary operands of an operator converted to ctypes. */ typedef struct CDArith { uint8_t *p[2]; CType *ct[2]; } CDArith; /* Check arguments for arithmetic metamethods. */ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca) { TValue *o = L->base; int ok = 1; MSize i; if (o+1 >= L->top) lj_err_argt(L, 1, LUA_TCDATA); for (i = 0; i < 2; i++, o++) { if (tviscdata(o)) { GCcdata *cd = cdataV(o); CTypeID id = (CTypeID)cd->ctypeid; CType *ct = ctype_raw(cts, id); uint8_t *p = (uint8_t *)cdataptr(cd); if (ctype_isptr(ct->info)) { p = (uint8_t *)cdata_getptr(p, ct->size); if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); } else if (ctype_isfunc(ct->info)) { p = (uint8_t *)*(void **)p; ct = ctype_get(cts, lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); } if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); ca->ct[i] = ct; ca->p[i] = p; } else if (tvisint(o)) { ca->ct[i] = ctype_get(cts, CTID_INT32); ca->p[i] = (uint8_t *)&o->i; } else if (tvisnum(o)) { ca->ct[i] = ctype_get(cts, CTID_DOUBLE); ca->p[i] = (uint8_t *)&o->n; } else if (tvisnil(o)) { ca->ct[i] = ctype_get(cts, CTID_P_VOID); ca->p[i] = (uint8_t *)0; } else if (tvisstr(o)) { TValue *o2 = i == 0 ? o+1 : o-1; CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid); ca->ct[i] = NULL; ca->p[i] = NULL; ok = 0; if (ctype_isenum(ct->info)) { CTSize ofs; CType *cct = lj_ctype_getfield(cts, ct, strV(o), &ofs); if (cct && ctype_isconstval(cct->info)) { ca->ct[i] = ctype_child(cts, cct); ca->p[i] = (uint8_t *)&cct->size; /* Assumes ct does not grow. */ ok = 1; } else { ca->ct[1-i] = ct; /* Use enum to improve error message. */ ca->p[1-i] = NULL; break; } } } else { ca->ct[i] = NULL; ca->p[i] = NULL; ok = 0; } } return ok; } /* Pointer arithmetic. */ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm) { CType *ctp = ca->ct[0]; uint8_t *pp = ca->p[0]; ptrdiff_t idx; CTSize sz; CTypeID id; GCcdata *cd; if (ctype_isptr(ctp->info) || ctype_isrefarray(ctp->info)) { if ((mm == MM_sub || mm == MM_eq || mm == MM_lt || mm == MM_le) && (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { uint8_t *pp2 = ca->p[1]; if (mm == MM_eq) { /* Pointer equality. Incompatible pointers are ok. */ setboolV(L->top-1, (pp == pp2)); return 1; } if (!lj_cconv_compatptr(cts, ctp, ca->ct[1], CCF_IGNQUAL)) return 0; if (mm == MM_sub) { /* Pointer difference. */ intptr_t diff; sz = lj_ctype_size(cts, ctype_cid(ctp->info)); /* Element size. */ if (sz == 0 || sz == CTSIZE_INVALID) return 0; diff = ((intptr_t)pp - (intptr_t)pp2) / (int32_t)sz; /* All valid pointer differences on x64 are in (-2^47, +2^47), ** which fits into a double without loss of precision. */ setintptrV(L->top-1, (int32_t)diff); return 1; } else if (mm == MM_lt) { /* Pointer comparison (unsigned). */ setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2)); return 1; } else { lua_assert(mm == MM_le); setboolV(L->top-1, ((uintptr_t)pp <= (uintptr_t)pp2)); return 1; } } if (!((mm == MM_add || mm == MM_sub) && ctype_isnum(ca->ct[1]->info))) return 0; lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[1], (uint8_t *)&idx, ca->p[1], 0); if (mm == MM_sub) idx = -idx; } else if (mm == MM_add && ctype_isnum(ctp->info) && (ctype_isptr(ca->ct[1]->info) || ctype_isrefarray(ca->ct[1]->info))) { /* Swap pointer and index. */ ctp = ca->ct[1]; pp = ca->p[1]; lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ca->ct[0], (uint8_t *)&idx, ca->p[0], 0); } else { return 0; } sz = lj_ctype_size(cts, ctype_cid(ctp->info)); /* Element size. */ if (sz == CTSIZE_INVALID) return 0; pp += idx*(int32_t)sz; /* Compute pointer + index. */ id = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ctp->info)), CTSIZE_PTR); cd = lj_cdata_new(cts, id, CTSIZE_PTR); *(uint8_t **)cdataptr(cd) = pp; setcdataV(L, L->top-1, cd); lj_gc_check(L); return 1; } /* 64 bit integer arithmetic. */ static int carith_int64(lua_State *L, CTState *cts, CDArith *ca, MMS mm) { if (ctype_isnum(ca->ct[0]->info) && ca->ct[0]->size <= 8 && ctype_isnum(ca->ct[1]->info) && ca->ct[1]->size <= 8) { CTypeID id = (((ca->ct[0]->info & CTF_UNSIGNED) && ca->ct[0]->size == 8) || ((ca->ct[1]->info & CTF_UNSIGNED) && ca->ct[1]->size == 8)) ? CTID_UINT64 : CTID_INT64; CType *ct = ctype_get(cts, id); GCcdata *cd; uint64_t u0, u1, *up; lj_cconv_ct_ct(cts, ct, ca->ct[0], (uint8_t *)&u0, ca->p[0], 0); if (mm != MM_unm) lj_cconv_ct_ct(cts, ct, ca->ct[1], (uint8_t *)&u1, ca->p[1], 0); switch (mm) { case MM_eq: setboolV(L->top-1, (u0 == u1)); return 1; case MM_lt: setboolV(L->top-1, id == CTID_INT64 ? ((int64_t)u0 < (int64_t)u1) : (u0 < u1)); return 1; case MM_le: setboolV(L->top-1, id == CTID_INT64 ? ((int64_t)u0 <= (int64_t)u1) : (u0 <= u1)); return 1; default: break; } cd = lj_cdata_new(cts, id, 8); up = (uint64_t *)cdataptr(cd); setcdataV(L, L->top-1, cd); switch (mm) { case MM_add: *up = u0 + u1; break; case MM_sub: *up = u0 - u1; break; case MM_mul: *up = u0 * u1; break; case MM_div: if (id == CTID_INT64) *up = (uint64_t)lj_carith_divi64((int64_t)u0, (int64_t)u1); else *up = lj_carith_divu64(u0, u1); break; case MM_mod: if (id == CTID_INT64) *up = (uint64_t)lj_carith_modi64((int64_t)u0, (int64_t)u1); else *up = lj_carith_modu64(u0, u1); break; case MM_pow: if (id == CTID_INT64) *up = (uint64_t)lj_carith_powi64((int64_t)u0, (int64_t)u1); else *up = lj_carith_powu64(u0, u1); break; case MM_unm: *up = (uint64_t)-(int64_t)u0; break; default: lua_assert(0); break; } lj_gc_check(L); return 1; } return 0; } /* Handle ctype arithmetic metamethods. */ static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm) { cTValue *tv = NULL; if (tviscdata(L->base)) { CTypeID id = cdataV(L->base)->ctypeid; CType *ct = ctype_raw(cts, id); if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); tv = lj_ctype_meta(cts, id, mm); } if (!tv && L->base+1 < L->top && tviscdata(L->base+1)) { CTypeID id = cdataV(L->base+1)->ctypeid; CType *ct = ctype_raw(cts, id); if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); tv = lj_ctype_meta(cts, id, mm); } if (!tv) { const char *repr[2]; int i, isenum = -1, isstr = -1; if (mm == MM_eq) { /* Equality checks never raise an error. */ setboolV(L->top-1, 0); return 1; } for (i = 0; i < 2; i++) { if (ca->ct[i]) { if (ctype_isenum(ca->ct[i]->info)) isenum = i; repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); } else { if (tvisstr(&L->base[i])) isstr = i; repr[i] = lj_typename(&L->base[i]); } } if ((isenum ^ isstr) == 1) lj_err_callerv(L, LJ_ERR_FFI_BADCONV, repr[isstr], repr[isenum]); lj_err_callerv(L, mm == MM_len ? LJ_ERR_FFI_BADLEN : mm == MM_concat ? LJ_ERR_FFI_BADCONCAT : mm < MM_add ? LJ_ERR_FFI_BADCOMP : LJ_ERR_FFI_BADARITH, repr[0], repr[1]); } return lj_meta_tailcall(L, tv); } /* Arithmetic operators for cdata. */ int lj_carith_op(lua_State *L, MMS mm) { CTState *cts = ctype_cts(L); CDArith ca; if (carith_checkarg(L, cts, &ca)) { if (carith_int64(L, cts, &ca, mm) || carith_ptr(L, cts, &ca, mm)) { copyTV(L, &G(L)->tmptv2, L->top-1); /* Remember for trace recorder. */ return 1; } } return lj_carith_meta(L, cts, &ca, mm); } /* -- 64 bit integer arithmetic helpers ----------------------------------- */ #if LJ_32 && LJ_HASJIT /* Signed/unsigned 64 bit multiplication. */ int64_t lj_carith_mul64(int64_t a, int64_t b) { return a * b; } #endif /* Unsigned 64 bit division. */ uint64_t lj_carith_divu64(uint64_t a, uint64_t b) { if (b == 0) return U64x(80000000,00000000); return a / b; } /* Signed 64 bit division. */ int64_t lj_carith_divi64(int64_t a, int64_t b) { if (b == 0 || (a == (int64_t)U64x(80000000,00000000) && b == -1)) return U64x(80000000,00000000); return a / b; } /* Unsigned 64 bit modulo. */ uint64_t lj_carith_modu64(uint64_t a, uint64_t b) { if (b == 0) return U64x(80000000,00000000); return a % b; } /* Signed 64 bit modulo. */ int64_t lj_carith_modi64(int64_t a, int64_t b) { if (b == 0) return U64x(80000000,00000000); if (a == (int64_t)U64x(80000000,00000000) && b == -1) return 0; return a % b; } /* Unsigned 64 bit x^k. */ uint64_t lj_carith_powu64(uint64_t x, uint64_t k) { uint64_t y; if (k == 0) return 1; for (; (k & 1) == 0; k >>= 1) x *= x; y = x; if ((k >>= 1) != 0) { for (;;) { x *= x; if (k == 1) break; if (k & 1) y *= x; k >>= 1; } y *= x; } return y; } /* Signed 64 bit x^k. */ int64_t lj_carith_powi64(int64_t x, int64_t k) { if (k == 0) return 1; if (k < 0) { if (x == 0) return U64x(7fffffff,ffffffff); else if (x == 1) return 1; else if (x == -1) return (k & 1) ? -1 : 1; else return 0; } return (int64_t)lj_carith_powu64((uint64_t)x, (uint64_t)k); } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_carith.h ================================================ /* ** C data arithmetic. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CARITH_H #define _LJ_CARITH_H #include "lj_obj.h" #if LJ_HASFFI LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); #if LJ_32 && LJ_HASJIT LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); #endif LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ccall.c ================================================ /* ** FFI C call handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "lj_obj.h" #if LJ_HASFFI #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_ctype.h" #include "lj_cconv.h" #include "lj_cdata.h" #include "lj_ccall.h" #include "lj_trace.h" /* Target-specific handling of register arguments. */ #if LJ_TARGET_X86 /* -- x86 calling conventions --------------------------------------------- */ #if LJ_ABI_WIN #define CCALL_HANDLE_STRUCTRET \ /* Return structs bigger than 8 by reference (on stack only). */ \ cc->retref = (sz > 8); \ if (cc->retref) cc->stack[nsp++] = (GPRArg)dp; #define CCALL_HANDLE_COMPLEXRET CCALL_HANDLE_STRUCTRET #else #define CCALL_HANDLE_STRUCTRET \ cc->retref = 1; /* Return all structs by reference (in reg or on stack). */ \ if (ngpr < maxgpr) \ cc->gpr[ngpr++] = (GPRArg)dp; \ else \ cc->stack[nsp++] = (GPRArg)dp; #define CCALL_HANDLE_COMPLEXRET \ /* Return complex float in GPRs and complex double by reference. */ \ cc->retref = (sz > 8); \ if (cc->retref) { \ if (ngpr < maxgpr) \ cc->gpr[ngpr++] = (GPRArg)dp; \ else \ cc->stack[nsp++] = (GPRArg)dp; \ } #endif #define CCALL_HANDLE_COMPLEXRET2 \ if (!cc->retref) \ *(int64_t *)dp = *(int64_t *)sp; /* Copy complex float from GPRs. */ #define CCALL_HANDLE_STRUCTARG \ ngpr = maxgpr; /* Pass all structs by value on the stack. */ #define CCALL_HANDLE_COMPLEXARG \ isfp = 1; /* Pass complex by value on stack. */ #define CCALL_HANDLE_REGARG \ if (!isfp) { /* Only non-FP values may be passed in registers. */ \ if (n > 1) { /* Anything > 32 bit is passed on the stack. */ \ if (!LJ_ABI_WIN) ngpr = maxgpr; /* Prevent reordering. */ \ } else if (ngpr + 1 <= maxgpr) { \ dp = &cc->gpr[ngpr]; \ ngpr += n; \ goto done; \ } \ } #elif LJ_TARGET_X64 && LJ_ABI_WIN /* -- Windows/x64 calling conventions ------------------------------------- */ #define CCALL_HANDLE_STRUCTRET \ /* Return structs of size 1, 2, 4 or 8 in a GPR. */ \ cc->retref = !(sz == 1 || sz == 2 || sz == 4 || sz == 8); \ if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; #define CCALL_HANDLE_COMPLEXRET CCALL_HANDLE_STRUCTRET #define CCALL_HANDLE_COMPLEXRET2 \ if (!cc->retref) \ *(int64_t *)dp = *(int64_t *)sp; /* Copy complex float from GPRs. */ #define CCALL_HANDLE_STRUCTARG \ /* Pass structs of size 1, 2, 4 or 8 in a GPR by value. */ \ if (!(sz == 1 || sz == 2 || sz == 4 || sz == 8)) { \ rp = cdataptr(lj_cdata_new(cts, did, sz)); \ sz = CTSIZE_PTR; /* Pass all other structs by reference. */ \ } #define CCALL_HANDLE_COMPLEXARG \ /* Pass complex float in a GPR and complex double by reference. */ \ if (sz != 2*sizeof(float)) { \ rp = cdataptr(lj_cdata_new(cts, did, sz)); \ sz = CTSIZE_PTR; \ } /* Windows/x64 argument registers are strictly positional (use ngpr). */ #define CCALL_HANDLE_REGARG \ if (isfp) { \ if (ngpr < 4) { dp = &cc->fpr[ngpr++]; nfpr = ngpr; goto done; } \ } else { \ if (ngpr < 4) { dp = &cc->gpr[ngpr++]; goto done; } \ } #elif LJ_TARGET_X64 /* -- POSIX/x64 calling conventions --------------------------------------- */ #define CCALL_HANDLE_STRUCTRET \ int rcl[2]; rcl[0] = rcl[1] = 0; \ if (ccall_classify_struct(cts, ctr, rcl, 0)) { \ cc->retref = 1; /* Return struct by reference. */ \ cc->gpr[ngpr++] = (GPRArg)dp; \ } else { \ cc->retref = 0; /* Return small structs in registers. */ \ } #define CCALL_HANDLE_STRUCTRET2 \ int rcl[2]; rcl[0] = rcl[1] = 0; \ ccall_classify_struct(cts, ctr, rcl, 0); \ ccall_struct_ret(cc, rcl, dp, ctr->size); #define CCALL_HANDLE_COMPLEXRET \ /* Complex values are returned in one or two FPRs. */ \ cc->retref = 0; #define CCALL_HANDLE_COMPLEXRET2 \ if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPR. */ \ *(int64_t *)dp = cc->fpr[0].l[0]; \ } else { /* Copy non-contiguous complex double from FPRs. */ \ ((int64_t *)dp)[0] = cc->fpr[0].l[0]; \ ((int64_t *)dp)[1] = cc->fpr[1].l[0]; \ } #define CCALL_HANDLE_STRUCTARG \ int rcl[2]; rcl[0] = rcl[1] = 0; \ if (!ccall_classify_struct(cts, d, rcl, 0)) { \ cc->nsp = nsp; cc->ngpr = ngpr; cc->nfpr = nfpr; \ if (ccall_struct_arg(cc, cts, d, rcl, o, narg)) goto err_nyi; \ nsp = cc->nsp; ngpr = cc->ngpr; nfpr = cc->nfpr; \ continue; \ } /* Pass all other structs by value on stack. */ #define CCALL_HANDLE_COMPLEXARG \ isfp = 2; /* Pass complex in FPRs or on stack. Needs postprocessing. */ #define CCALL_HANDLE_REGARG \ if (isfp) { /* Try to pass argument in FPRs. */ \ if (nfpr + n <= CCALL_NARG_FPR) { \ dp = &cc->fpr[nfpr]; \ nfpr += n; \ goto done; \ } \ } else { /* Try to pass argument in GPRs. */ \ /* Note that reordering is explicitly allowed in the x64 ABI. */ \ if (n <= 2 && ngpr + n <= maxgpr) { \ dp = &cc->gpr[ngpr]; \ ngpr += n; \ goto done; \ } \ } #elif LJ_TARGET_ARM /* -- ARM calling conventions --------------------------------------------- */ #if LJ_ABI_SOFTFP #define CCALL_HANDLE_STRUCTRET \ /* Return structs of size <= 4 in a GPR. */ \ cc->retref = !(sz <= 4); \ if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; #define CCALL_HANDLE_COMPLEXRET \ cc->retref = 1; /* Return all complex values by reference. */ \ cc->gpr[ngpr++] = (GPRArg)dp; #define CCALL_HANDLE_COMPLEXRET2 \ UNUSED(dp); /* Nothing to do. */ #define CCALL_HANDLE_STRUCTARG \ /* Pass all structs by value in registers and/or on the stack. */ #define CCALL_HANDLE_COMPLEXARG \ /* Pass complex by value in 2 or 4 GPRs. */ #define CCALL_HANDLE_REGARG_FP1 #define CCALL_HANDLE_REGARG_FP2 #else #define CCALL_HANDLE_STRUCTRET \ cc->retref = !ccall_classify_struct(cts, ctr, ct); \ if (cc->retref) cc->gpr[ngpr++] = (GPRArg)dp; #define CCALL_HANDLE_STRUCTRET2 \ if (ccall_classify_struct(cts, ctr, ct) > 1) sp = (uint8_t *)&cc->fpr[0]; \ memcpy(dp, sp, ctr->size); #define CCALL_HANDLE_COMPLEXRET \ if (!(ct->info & CTF_VARARG)) cc->retref = 0; /* Return complex in FPRs. */ #define CCALL_HANDLE_COMPLEXRET2 \ if (!(ct->info & CTF_VARARG)) memcpy(dp, &cc->fpr[0], ctr->size); #define CCALL_HANDLE_STRUCTARG \ isfp = (ccall_classify_struct(cts, d, ct) > 1); /* Pass all structs by value in registers and/or on the stack. */ #define CCALL_HANDLE_COMPLEXARG \ isfp = 1; /* Pass complex by value in FPRs or on stack. */ #define CCALL_HANDLE_REGARG_FP1 \ if (isfp && !(ct->info & CTF_VARARG)) { \ if ((d->info & CTF_ALIGN) > CTALIGN_PTR) { \ if (nfpr + (n >> 1) <= CCALL_NARG_FPR) { \ dp = &cc->fpr[nfpr]; \ nfpr += (n >> 1); \ goto done; \ } \ } else { \ if (sz > 1 && fprodd != nfpr) fprodd = 0; \ if (fprodd) { \ if (2*nfpr+n <= 2*CCALL_NARG_FPR+1) { \ dp = (void *)&cc->fpr[fprodd-1].f[1]; \ nfpr += (n >> 1); \ if ((n & 1)) fprodd = 0; else fprodd = nfpr-1; \ goto done; \ } \ } else { \ if (2*nfpr+n <= 2*CCALL_NARG_FPR) { \ dp = (void *)&cc->fpr[nfpr]; \ nfpr += (n >> 1); \ if ((n & 1)) fprodd = ++nfpr; else fprodd = 0; \ goto done; \ } \ } \ } \ fprodd = 0; /* No reordering after the first FP value is on stack. */ \ } else { #define CCALL_HANDLE_REGARG_FP2 } #endif #define CCALL_HANDLE_REGARG \ CCALL_HANDLE_REGARG_FP1 \ if ((d->info & CTF_ALIGN) > CTALIGN_PTR) { \ if (ngpr < maxgpr) \ ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ } \ if (ngpr < maxgpr) { \ dp = &cc->gpr[ngpr]; \ if (ngpr + n > maxgpr) { \ nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \ if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \ ngpr = maxgpr; \ } else { \ ngpr += n; \ } \ goto done; \ } CCALL_HANDLE_REGARG_FP2 #define CCALL_HANDLE_RET \ if ((ct->info & CTF_VARARG)) sp = (uint8_t *)&cc->gpr[0]; #elif LJ_TARGET_PPC /* -- PPC calling conventions --------------------------------------------- */ #define CCALL_HANDLE_STRUCTRET \ cc->retref = 1; /* Return all structs by reference. */ \ cc->gpr[ngpr++] = (GPRArg)dp; #define CCALL_HANDLE_COMPLEXRET \ /* Complex values are returned in 2 or 4 GPRs. */ \ cc->retref = 0; #define CCALL_HANDLE_COMPLEXRET2 \ memcpy(dp, sp, ctr->size); /* Copy complex from GPRs. */ #define CCALL_HANDLE_STRUCTARG \ rp = cdataptr(lj_cdata_new(cts, did, sz)); \ sz = CTSIZE_PTR; /* Pass all structs by reference. */ #define CCALL_HANDLE_COMPLEXARG \ /* Pass complex by value in 2 or 4 GPRs. */ #define CCALL_HANDLE_REGARG \ if (isfp) { /* Try to pass argument in FPRs. */ \ if (nfpr + 1 <= CCALL_NARG_FPR) { \ dp = &cc->fpr[nfpr]; \ nfpr += 1; \ d = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ \ goto done; \ } \ } else { /* Try to pass argument in GPRs. */ \ if (n > 1) { \ lua_assert(n == 2 || n == 4); /* int64_t or complex (float). */ \ if (ctype_isinteger(d->info)) \ ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ else if (ngpr + n > maxgpr) \ ngpr = maxgpr; /* Prevent reordering. */ \ } \ if (ngpr + n <= maxgpr) { \ dp = &cc->gpr[ngpr]; \ ngpr += n; \ goto done; \ } \ } #define CCALL_HANDLE_RET \ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ ctr = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ #elif LJ_TARGET_PPCSPE /* -- PPC/SPE calling conventions ----------------------------------------- */ #define CCALL_HANDLE_STRUCTRET \ cc->retref = 1; /* Return all structs by reference. */ \ cc->gpr[ngpr++] = (GPRArg)dp; #define CCALL_HANDLE_COMPLEXRET \ /* Complex values are returned in 2 or 4 GPRs. */ \ cc->retref = 0; #define CCALL_HANDLE_COMPLEXRET2 \ memcpy(dp, sp, ctr->size); /* Copy complex from GPRs. */ #define CCALL_HANDLE_STRUCTARG \ rp = cdataptr(lj_cdata_new(cts, did, sz)); \ sz = CTSIZE_PTR; /* Pass all structs by reference. */ #define CCALL_HANDLE_COMPLEXARG \ /* Pass complex by value in 2 or 4 GPRs. */ /* PPC/SPE has a softfp ABI. */ #define CCALL_HANDLE_REGARG \ if (n > 1) { /* Doesn't fit in a single GPR? */ \ lua_assert(n == 2 || n == 4); /* int64_t, double or complex (float). */ \ if (n == 2) \ ngpr = (ngpr + 1u) & ~1u; /* Only align 64 bit value to regpair. */ \ else if (ngpr + n > maxgpr) \ ngpr = maxgpr; /* Prevent reordering. */ \ } \ if (ngpr + n <= maxgpr) { \ dp = &cc->gpr[ngpr]; \ ngpr += n; \ goto done; \ } #elif LJ_TARGET_MIPS /* -- MIPS calling conventions -------------------------------------------- */ #define CCALL_HANDLE_STRUCTRET \ cc->retref = 1; /* Return all structs by reference. */ \ cc->gpr[ngpr++] = (GPRArg)dp; #define CCALL_HANDLE_COMPLEXRET \ /* Complex values are returned in 1 or 2 FPRs. */ \ cc->retref = 0; #define CCALL_HANDLE_COMPLEXRET2 \ if (ctr->size == 2*sizeof(float)) { /* Copy complex float from FPRs. */ \ ((float *)dp)[0] = cc->fpr[0].f; \ ((float *)dp)[1] = cc->fpr[1].f; \ } else { /* Copy complex double from FPRs. */ \ ((double *)dp)[0] = cc->fpr[0].d; \ ((double *)dp)[1] = cc->fpr[1].d; \ } #define CCALL_HANDLE_STRUCTARG \ /* Pass all structs by value in registers and/or on the stack. */ #define CCALL_HANDLE_COMPLEXARG \ /* Pass complex by value in 2 or 4 GPRs. */ #define CCALL_HANDLE_REGARG \ if (isfp && nfpr < CCALL_NARG_FPR && !(ct->info & CTF_VARARG)) { \ /* Try to pass argument in FPRs. */ \ dp = n == 1 ? (void *)&cc->fpr[nfpr].f : (void *)&cc->fpr[nfpr].d; \ nfpr++; ngpr += n; \ goto done; \ } else { /* Try to pass argument in GPRs. */ \ nfpr = CCALL_NARG_FPR; \ if ((d->info & CTF_ALIGN) > CTALIGN_PTR) \ ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ if (ngpr < maxgpr) { \ dp = &cc->gpr[ngpr]; \ if (ngpr + n > maxgpr) { \ nsp += ngpr + n - maxgpr; /* Assumes contiguous gpr/stack fields. */ \ if (nsp > CCALL_MAXSTACK) goto err_nyi; /* Too many arguments. */ \ ngpr = maxgpr; \ } else { \ ngpr += n; \ } \ goto done; \ } \ } #define CCALL_HANDLE_RET \ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ sp = (uint8_t *)&cc->fpr[0].f; #else #error "Missing calling convention definitions for this architecture" #endif #ifndef CCALL_HANDLE_STRUCTRET2 #define CCALL_HANDLE_STRUCTRET2 \ memcpy(dp, sp, ctr->size); /* Copy struct return value from GPRs. */ #endif /* -- x64 struct classification ------------------------------------------- */ #if LJ_TARGET_X64 && !LJ_ABI_WIN /* Register classes for x64 struct classification. */ #define CCALL_RCL_INT 1 #define CCALL_RCL_SSE 2 #define CCALL_RCL_MEM 4 /* NYI: classify vectors. */ static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs); /* Classify a C type. */ static void ccall_classify_ct(CTState *cts, CType *ct, int *rcl, CTSize ofs) { if (ctype_isarray(ct->info)) { CType *cct = ctype_rawchild(cts, ct); CTSize eofs, esz = cct->size, asz = ct->size; for (eofs = 0; eofs < asz; eofs += esz) ccall_classify_ct(cts, cct, rcl, ofs+eofs); } else if (ctype_isstruct(ct->info)) { ccall_classify_struct(cts, ct, rcl, ofs); } else { int cl = ctype_isfp(ct->info) ? CCALL_RCL_SSE : CCALL_RCL_INT; lua_assert(ctype_hassize(ct->info)); if ((ofs & (ct->size-1))) cl = CCALL_RCL_MEM; /* Unaligned. */ rcl[(ofs >= 8)] |= cl; } } /* Recursively classify a struct based on its fields. */ static int ccall_classify_struct(CTState *cts, CType *ct, int *rcl, CTSize ofs) { if (ct->size > 16) return CCALL_RCL_MEM; /* Too big, gets memory class. */ while (ct->sib) { CTSize fofs; ct = ctype_get(cts, ct->sib); fofs = ofs+ct->size; if (ctype_isfield(ct->info)) ccall_classify_ct(cts, ctype_rawchild(cts, ct), rcl, fofs); else if (ctype_isbitfield(ct->info)) rcl[(fofs >= 8)] |= CCALL_RCL_INT; /* NYI: unaligned bitfields? */ else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) ccall_classify_struct(cts, ctype_rawchild(cts, ct), rcl, fofs); } return ((rcl[0]|rcl[1]) & CCALL_RCL_MEM); /* Memory class? */ } /* Try to split up a small struct into registers. */ static int ccall_struct_reg(CCallState *cc, GPRArg *dp, int *rcl) { MSize ngpr = cc->ngpr, nfpr = cc->nfpr; uint32_t i; for (i = 0; i < 2; i++) { lua_assert(!(rcl[i] & CCALL_RCL_MEM)); if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ if (ngpr >= CCALL_NARG_GPR) return 1; /* Register overflow. */ cc->gpr[ngpr++] = dp[i]; } else if ((rcl[i] & CCALL_RCL_SSE)) { if (nfpr >= CCALL_NARG_FPR) return 1; /* Register overflow. */ cc->fpr[nfpr++].l[0] = dp[i]; } } cc->ngpr = ngpr; cc->nfpr = nfpr; return 0; /* Ok. */ } /* Pass a small struct argument. */ static int ccall_struct_arg(CCallState *cc, CTState *cts, CType *d, int *rcl, TValue *o, int narg) { GPRArg dp[2]; dp[0] = dp[1] = 0; /* Convert to temp. struct. */ lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); if (ccall_struct_reg(cc, dp, rcl)) { /* Register overflow? Pass on stack. */ MSize nsp = cc->nsp, n = rcl[1] ? 2 : 1; if (nsp + n > CCALL_MAXSTACK) return 1; /* Too many arguments. */ cc->nsp = nsp + n; memcpy(&cc->stack[nsp], dp, n*CTSIZE_PTR); } return 0; /* Ok. */ } /* Combine returned small struct. */ static void ccall_struct_ret(CCallState *cc, int *rcl, uint8_t *dp, CTSize sz) { GPRArg sp[2]; MSize ngpr = 0, nfpr = 0; uint32_t i; for (i = 0; i < 2; i++) { if ((rcl[i] & CCALL_RCL_INT)) { /* Integer class takes precedence. */ sp[i] = cc->gpr[ngpr++]; } else if ((rcl[i] & CCALL_RCL_SSE)) { sp[i] = cc->fpr[nfpr++].l[0]; } } memcpy(dp, sp, sz); } #endif /* -- ARM hard-float ABI struct classification ---------------------------- */ #if LJ_TARGET_ARM && !LJ_ABI_SOFTFP /* Classify a struct based on its fields. */ static unsigned int ccall_classify_struct(CTState *cts, CType *ct, CType *ctf) { CTSize sz = ct->size; unsigned int r = 0, n = 0, isu = (ct->info & CTF_UNION); if ((ctf->info & CTF_VARARG)) goto noth; while (ct->sib) { ct = ctype_get(cts, ct->sib); if (ctype_isfield(ct->info)) { CType *sct = ctype_rawchild(cts, ct); if (ctype_isfp(sct->info)) { r |= sct->size; if (!isu) n++; else if (n == 0) n = 1; } else if (ctype_iscomplex(sct->info)) { r |= (sct->size >> 1); if (!isu) n += 2; else if (n < 2) n = 2; } else { goto noth; } } else if (ctype_isbitfield(ct->info)) { goto noth; } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { CType *sct = ctype_rawchild(cts, ct); if (sct->size > 0) { unsigned int s = ccall_classify_struct(cts, sct, ctf); if (s <= 1) goto noth; r |= (s & 255); if (!isu) n += (s >> 8); else if (n < (s >>8)) n = (s >> 8); } } } if ((r == 4 || r == 8) && n <= 4) return r + (n << 8); noth: /* Not a homogeneous float/double aggregate. */ return (sz <= 4); /* Return structs of size <= 4 in a GPR. */ } #endif /* -- Common C call handling ---------------------------------------------- */ /* Infer the destination CTypeID for a vararg argument. */ CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o) { if (tvisnumber(o)) { return CTID_DOUBLE; } else if (tviscdata(o)) { CTypeID id = cdataV(o)->ctypeid; CType *s = ctype_get(cts, id); if (ctype_isrefarray(s->info)) { return lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(s->info)), CTSIZE_PTR); } else if (ctype_isstruct(s->info) || ctype_isfunc(s->info)) { /* NYI: how to pass a struct by value in a vararg argument? */ return lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR); } else if (ctype_isfp(s->info) && s->size == sizeof(float)) { return CTID_DOUBLE; } else { return id; } } else if (tvisstr(o)) { return CTID_P_CCHAR; } else if (tvisbool(o)) { return CTID_BOOL; } else { return CTID_P_VOID; } } /* Setup arguments for C call. */ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct, CCallState *cc) { int gcsteps = 0; TValue *o, *top = L->top; CTypeID fid; CType *ctr; MSize maxgpr, ngpr = 0, nsp = 0, narg; #if CCALL_NARG_FPR MSize nfpr = 0; #if LJ_TARGET_ARM MSize fprodd = 0; #endif #endif /* Clear unused regs to get some determinism in case of misdeclaration. */ memset(cc->gpr, 0, sizeof(cc->gpr)); #if CCALL_NUM_FPR memset(cc->fpr, 0, sizeof(cc->fpr)); #endif #if LJ_TARGET_X86 /* x86 has several different calling conventions. */ cc->resx87 = 0; switch (ctype_cconv(ct->info)) { case CTCC_FASTCALL: maxgpr = 2; break; case CTCC_THISCALL: maxgpr = 1; break; default: maxgpr = 0; break; } #else maxgpr = CCALL_NARG_GPR; #endif /* Perform required setup for some result types. */ ctr = ctype_rawchild(cts, ct); if (ctype_isvector(ctr->info)) { if (!(CCALL_VECTOR_REG && (ctr->size == 8 || ctr->size == 16))) goto err_nyi; } else if (ctype_iscomplex(ctr->info) || ctype_isstruct(ctr->info)) { /* Preallocate cdata object and anchor it after arguments. */ CTSize sz = ctr->size; GCcdata *cd = lj_cdata_new(cts, ctype_cid(ct->info), sz); void *dp = cdataptr(cd); setcdataV(L, L->top++, cd); if (ctype_isstruct(ctr->info)) { CCALL_HANDLE_STRUCTRET } else { CCALL_HANDLE_COMPLEXRET } #if LJ_TARGET_X86 } else if (ctype_isfp(ctr->info)) { cc->resx87 = ctr->size == sizeof(float) ? 1 : 2; #endif } /* Skip initial attributes. */ fid = ct->sib; while (fid) { CType *ctf = ctype_get(cts, fid); if (!ctype_isattrib(ctf->info)) break; fid = ctf->sib; } /* Walk through all passed arguments. */ for (o = L->base+1, narg = 1; o < top; o++, narg++) { CTypeID did; CType *d; CTSize sz; MSize n, isfp = 0, isva = 0; void *dp, *rp = NULL; if (fid) { /* Get argument type from field. */ CType *ctf = ctype_get(cts, fid); fid = ctf->sib; lua_assert(ctype_isfield(ctf->info)); did = ctype_cid(ctf->info); } else { if (!(ct->info & CTF_VARARG)) lj_err_caller(L, LJ_ERR_FFI_NUMARG); /* Too many arguments. */ did = lj_ccall_ctid_vararg(cts, o); /* Infer vararg type. */ isva = 1; } d = ctype_raw(cts, did); sz = d->size; /* Find out how (by value/ref) and where (GPR/FPR) to pass an argument. */ if (ctype_isnum(d->info)) { if (sz > 8) goto err_nyi; if ((d->info & CTF_FP)) isfp = 1; } else if (ctype_isvector(d->info)) { if (CCALL_VECTOR_REG && (sz == 8 || sz == 16)) isfp = 1; else goto err_nyi; } else if (ctype_isstruct(d->info)) { CCALL_HANDLE_STRUCTARG } else if (ctype_iscomplex(d->info)) { CCALL_HANDLE_COMPLEXARG } else { sz = CTSIZE_PTR; } sz = (sz + CTSIZE_PTR-1) & ~(CTSIZE_PTR-1); n = sz / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ CCALL_HANDLE_REGARG /* Handle register arguments. */ /* Otherwise pass argument on stack. */ if (CCALL_ALIGN_STACKARG && !rp && (d->info & CTF_ALIGN) > CTALIGN_PTR) { MSize align = (1u << ctype_align(d->info-CTALIGN_PTR)) -1; nsp = (nsp + align) & ~align; /* Align argument on stack. */ } if (nsp + n > CCALL_MAXSTACK) { /* Too many arguments. */ err_nyi: lj_err_caller(L, LJ_ERR_FFI_NYICALL); } dp = &cc->stack[nsp]; nsp += n; isva = 0; done: if (rp) { /* Pass by reference. */ gcsteps++; *(void **)dp = rp; dp = rp; } lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); /* Extend passed integers to 32 bits at least. */ if (ctype_isinteger_or_bool(d->info) && d->size < 4) { if (d->info & CTF_UNSIGNED) *(uint32_t *)dp = d->size == 1 ? (uint32_t)*(uint8_t *)dp : (uint32_t)*(uint16_t *)dp; else *(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp : (int32_t)*(int16_t *)dp; } #if LJ_TARGET_X64 && LJ_ABI_WIN if (isva) { /* Windows/x64 mirrors varargs in both register sets. */ if (nfpr == ngpr) cc->gpr[ngpr-1] = cc->fpr[ngpr-1].l[0]; else cc->fpr[ngpr-1].l[0] = cc->gpr[ngpr-1]; } #else UNUSED(isva); #endif #if LJ_TARGET_X64 && !LJ_ABI_WIN if (isfp == 2 && n == 2 && (uint8_t *)dp == (uint8_t *)&cc->fpr[nfpr-2]) { cc->fpr[nfpr-1].d[0] = cc->fpr[nfpr-2].d[1]; /* Split complex double. */ cc->fpr[nfpr-2].d[1] = 0; } #else UNUSED(isfp); #endif } if (fid) lj_err_caller(L, LJ_ERR_FFI_NUMARG); /* Too few arguments. */ #if LJ_TARGET_X64 || LJ_TARGET_PPC cc->nfpr = nfpr; /* Required for vararg functions. */ #endif cc->nsp = nsp; cc->spadj = (CCALL_SPS_FREE + CCALL_SPS_EXTRA)*CTSIZE_PTR; if (nsp > CCALL_SPS_FREE) cc->spadj += (((nsp-CCALL_SPS_FREE)*CTSIZE_PTR + 15u) & ~15u); return gcsteps; } /* Get results from C call. */ static int ccall_get_results(lua_State *L, CTState *cts, CType *ct, CCallState *cc, int *ret) { CType *ctr = ctype_rawchild(cts, ct); uint8_t *sp = (uint8_t *)&cc->gpr[0]; if (ctype_isvoid(ctr->info)) { *ret = 0; /* Zero results. */ return 0; /* No additional GC step. */ } *ret = 1; /* One result. */ if (ctype_isstruct(ctr->info)) { /* Return cdata object which is already on top of stack. */ if (!cc->retref) { void *dp = cdataptr(cdataV(L->top-1)); /* Use preallocated object. */ CCALL_HANDLE_STRUCTRET2 } return 1; /* One GC step. */ } if (ctype_iscomplex(ctr->info)) { /* Return cdata object which is already on top of stack. */ void *dp = cdataptr(cdataV(L->top-1)); /* Use preallocated object. */ CCALL_HANDLE_COMPLEXRET2 return 1; /* One GC step. */ } if (LJ_BE && ctype_isinteger_or_bool(ctr->info) && ctr->size < CTSIZE_PTR) sp += (CTSIZE_PTR - ctr->size); #if CCALL_NUM_FPR if (ctype_isfp(ctr->info) || ctype_isvector(ctr->info)) sp = (uint8_t *)&cc->fpr[0]; #endif #ifdef CCALL_HANDLE_RET CCALL_HANDLE_RET #endif /* No reference types end up here, so there's no need for the CTypeID. */ lua_assert(!(ctype_isrefarray(ctr->info) || ctype_isstruct(ctr->info))); return lj_cconv_tv_ct(cts, ctr, 0, L->top-1, sp); } /* Call C function. */ int lj_ccall_func(lua_State *L, GCcdata *cd) { CTState *cts = ctype_cts(L); CType *ct = ctype_raw(cts, cd->ctypeid); CTSize sz = CTSIZE_PTR; if (ctype_isptr(ct->info)) { sz = ct->size; ct = ctype_rawchild(cts, ct); } if (ctype_isfunc(ct->info)) { CCallState cc; int gcsteps, ret; cc.func = (void (*)(void))cdata_getptr(cdataptr(cd), sz); gcsteps = ccall_set_args(L, cts, ct, &cc); ct = (CType *)((intptr_t)ct-(intptr_t)cts->tab); cts->cb.slot = ~0u; lj_vm_ffi_call(&cc); if (cts->cb.slot != ~0u) { /* Blacklist function that called a callback. */ TValue tv; setlightudV(&tv, (void *)cc.func); setboolV(lj_tab_set(L, cts->miscmap, &tv), 1); } ct = (CType *)((intptr_t)ct+(intptr_t)cts->tab); /* May be reallocated. */ gcsteps += ccall_get_results(L, cts, ct, &cc, &ret); #if LJ_TARGET_X86 && LJ_ABI_WIN /* Automatically detect __stdcall and fix up C function declaration. */ if (cc.spadj && ctype_cconv(ct->info) == CTCC_CDECL) { CTF_INSERT(ct->info, CCONV, CTCC_STDCALL); lj_trace_abort(G(L)); } #endif while (gcsteps-- > 0) lj_gc_check(L); return ret; } return -1; /* Not a function. */ } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ccall.h ================================================ /* ** FFI C call handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CCALL_H #define _LJ_CCALL_H #include "lj_obj.h" #include "lj_ctype.h" #if LJ_HASFFI /* -- C calling conventions ----------------------------------------------- */ #if LJ_TARGET_X86ORX64 #if LJ_TARGET_X86 #define CCALL_NARG_GPR 2 /* For fastcall arguments. */ #define CCALL_NARG_FPR 0 #define CCALL_NRET_GPR 2 #define CCALL_NRET_FPR 1 /* For FP results on x87 stack. */ #define CCALL_ALIGN_STACKARG 0 /* Don't align argument on stack. */ #elif LJ_ABI_WIN #define CCALL_NARG_GPR 4 #define CCALL_NARG_FPR 4 #define CCALL_NRET_GPR 1 #define CCALL_NRET_FPR 1 #define CCALL_SPS_EXTRA 4 #else #define CCALL_NARG_GPR 6 #define CCALL_NARG_FPR 8 #define CCALL_NRET_GPR 2 #define CCALL_NRET_FPR 2 #define CCALL_VECTOR_REG 1 /* Pass vectors in registers. */ #endif #define CCALL_SPS_FREE 1 #define CCALL_ALIGN_CALLSTATE 16 typedef LJ_ALIGN(16) union FPRArg { double d[2]; float f[4]; uint8_t b[16]; uint16_t s[8]; int i[4]; int64_t l[2]; } FPRArg; typedef intptr_t GPRArg; #elif LJ_TARGET_ARM #define CCALL_NARG_GPR 4 #define CCALL_NRET_GPR 2 /* For softfp double. */ #if LJ_ABI_SOFTFP #define CCALL_NARG_FPR 0 #define CCALL_NRET_FPR 0 #else #define CCALL_NARG_FPR 8 #define CCALL_NRET_FPR 4 #endif #define CCALL_SPS_FREE 0 typedef intptr_t GPRArg; typedef union FPRArg { double d; float f[2]; } FPRArg; #elif LJ_TARGET_PPC #define CCALL_NARG_GPR 8 #define CCALL_NARG_FPR 8 #define CCALL_NRET_GPR 4 /* For complex double. */ #define CCALL_NRET_FPR 1 #define CCALL_SPS_EXTRA 4 #define CCALL_SPS_FREE 0 typedef intptr_t GPRArg; typedef double FPRArg; #elif LJ_TARGET_PPCSPE #define CCALL_NARG_GPR 8 #define CCALL_NARG_FPR 0 #define CCALL_NRET_GPR 4 /* For softfp complex double. */ #define CCALL_NRET_FPR 0 #define CCALL_SPS_FREE 0 /* NYI */ typedef intptr_t GPRArg; #elif LJ_TARGET_MIPS #define CCALL_NARG_GPR 4 #define CCALL_NARG_FPR 2 #define CCALL_NRET_GPR 2 #define CCALL_NRET_FPR 2 #define CCALL_SPS_EXTRA 7 #define CCALL_SPS_FREE 1 typedef intptr_t GPRArg; typedef union FPRArg { double d; struct { LJ_ENDIAN_LOHI(float f; , float g;) }; } FPRArg; #else #error "Missing calling convention definitions for this architecture" #endif #ifndef CCALL_SPS_EXTRA #define CCALL_SPS_EXTRA 0 #endif #ifndef CCALL_VECTOR_REG #define CCALL_VECTOR_REG 0 #endif #ifndef CCALL_ALIGN_STACKARG #define CCALL_ALIGN_STACKARG 1 #endif #ifndef CCALL_ALIGN_CALLSTATE #define CCALL_ALIGN_CALLSTATE 8 #endif #define CCALL_NUM_GPR \ (CCALL_NARG_GPR > CCALL_NRET_GPR ? CCALL_NARG_GPR : CCALL_NRET_GPR) #define CCALL_NUM_FPR \ (CCALL_NARG_FPR > CCALL_NRET_FPR ? CCALL_NARG_FPR : CCALL_NRET_FPR) /* Check against constants in lj_ctype.h. */ LJ_STATIC_ASSERT(CCALL_NUM_GPR <= CCALL_MAX_GPR); LJ_STATIC_ASSERT(CCALL_NUM_FPR <= CCALL_MAX_FPR); #define CCALL_MAXSTACK 32 /* -- C call state -------------------------------------------------------- */ typedef LJ_ALIGN(CCALL_ALIGN_CALLSTATE) struct CCallState { void (*func)(void); /* Pointer to called function. */ uint32_t spadj; /* Stack pointer adjustment. */ uint8_t nsp; /* Number of stack slots. */ uint8_t retref; /* Return value by reference. */ #if LJ_TARGET_X64 uint8_t ngpr; /* Number of arguments in GPRs. */ uint8_t nfpr; /* Number of arguments in FPRs. */ #elif LJ_TARGET_X86 uint8_t resx87; /* Result on x87 stack: 1:float, 2:double. */ #elif LJ_TARGET_PPC uint8_t nfpr; /* Number of arguments in FPRs. */ #endif #if LJ_32 int32_t align1; #endif #if CCALL_NUM_FPR FPRArg fpr[CCALL_NUM_FPR]; /* Arguments/results in FPRs. */ #endif GPRArg gpr[CCALL_NUM_GPR]; /* Arguments/results in GPRs. */ GPRArg stack[CCALL_MAXSTACK]; /* Stack slots. */ } CCallState; /* -- C call handling ----------------------------------------------------- */ /* Really belongs to lj_vm.h. */ LJ_ASMF void LJ_FASTCALL lj_vm_ffi_call(CCallState *cc); LJ_FUNC CTypeID lj_ccall_ctid_vararg(CTState *cts, cTValue *o); LJ_FUNC int lj_ccall_func(lua_State *L, GCcdata *cd); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ccallback.c ================================================ /* ** FFI C callback handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "lj_obj.h" #if LJ_HASFFI #include "lj_gc.h" #include "lj_err.h" #include "lj_tab.h" #include "lj_state.h" #include "lj_frame.h" #include "lj_ctype.h" #include "lj_cconv.h" #include "lj_ccall.h" #include "lj_ccallback.h" #include "lj_target.h" #include "lj_mcode.h" #include "lj_trace.h" #include "lj_vm.h" /* -- Target-specific handling of callback slots -------------------------- */ #define CALLBACK_MCODE_SIZE (LJ_PAGESIZE * LJ_NUM_CBPAGE) #if LJ_OS_NOJIT /* Disabled callback support. */ #define CALLBACK_SLOT2OFS(slot) (0*(slot)) #define CALLBACK_OFS2SLOT(ofs) (0*(ofs)) #define CALLBACK_MAX_SLOT 0 #elif LJ_TARGET_X86ORX64 #define CALLBACK_MCODE_HEAD (LJ_64 ? 8 : 0) #define CALLBACK_MCODE_GROUP (-2+1+2+5+(LJ_64 ? 6 : 5)) #define CALLBACK_SLOT2OFS(slot) \ (CALLBACK_MCODE_HEAD + CALLBACK_MCODE_GROUP*((slot)/32) + 4*(slot)) static MSize CALLBACK_OFS2SLOT(MSize ofs) { MSize group; ofs -= CALLBACK_MCODE_HEAD; group = ofs / (32*4 + CALLBACK_MCODE_GROUP); return (ofs % (32*4 + CALLBACK_MCODE_GROUP))/4 + group*32; } #define CALLBACK_MAX_SLOT \ (((CALLBACK_MCODE_SIZE-CALLBACK_MCODE_HEAD)/(CALLBACK_MCODE_GROUP+4*32))*32) #elif LJ_TARGET_ARM #define CALLBACK_MCODE_HEAD 32 #define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) #define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) #define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) #elif LJ_TARGET_PPC #define CALLBACK_MCODE_HEAD 24 #define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) #define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) #define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) #elif LJ_TARGET_MIPS #define CALLBACK_MCODE_HEAD 24 #define CALLBACK_SLOT2OFS(slot) (CALLBACK_MCODE_HEAD + 8*(slot)) #define CALLBACK_OFS2SLOT(ofs) (((ofs)-CALLBACK_MCODE_HEAD)/8) #define CALLBACK_MAX_SLOT (CALLBACK_OFS2SLOT(CALLBACK_MCODE_SIZE)) #else /* Missing support for this architecture. */ #define CALLBACK_SLOT2OFS(slot) (0*(slot)) #define CALLBACK_OFS2SLOT(ofs) (0*(ofs)) #define CALLBACK_MAX_SLOT 0 #endif /* Convert callback slot number to callback function pointer. */ static void *callback_slot2ptr(CTState *cts, MSize slot) { return (uint8_t *)cts->cb.mcode + CALLBACK_SLOT2OFS(slot); } /* Convert callback function pointer to slot number. */ MSize lj_ccallback_ptr2slot(CTState *cts, void *p) { uintptr_t ofs = (uintptr_t)((uint8_t *)p -(uint8_t *)cts->cb.mcode); if (ofs < CALLBACK_MCODE_SIZE) { MSize slot = CALLBACK_OFS2SLOT((MSize)ofs); if (CALLBACK_SLOT2OFS(slot) == (MSize)ofs) return slot; } return ~0u; /* Not a known callback function pointer. */ } /* Initialize machine code for callback function pointers. */ #if LJ_OS_NOJIT /* Disabled callback support. */ #define callback_mcode_init(g, p) UNUSED(p) #elif LJ_TARGET_X86ORX64 static void callback_mcode_init(global_State *g, uint8_t *page) { uint8_t *p = page; uint8_t *target = (uint8_t *)(void *)lj_vm_ffi_callback; MSize slot; #if LJ_64 *(void **)p = target; p += 8; #endif for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { /* mov al, slot; jmp group */ *p++ = XI_MOVrib | RID_EAX; *p++ = (uint8_t)slot; if ((slot & 31) == 31 || slot == CALLBACK_MAX_SLOT-1) { /* push ebp/rbp; mov ah, slot>>8; mov ebp, &g. */ *p++ = XI_PUSH + RID_EBP; *p++ = XI_MOVrib | (RID_EAX+4); *p++ = (uint8_t)(slot >> 8); *p++ = XI_MOVri | RID_EBP; *(int32_t *)p = i32ptr(g); p += 4; #if LJ_64 /* jmp [rip-pageofs] where lj_vm_ffi_callback is stored. */ *p++ = XI_GROUP5; *p++ = XM_OFS0 + (XOg_JMP<<3) + RID_EBP; *(int32_t *)p = (int32_t)(page-(p+4)); p += 4; #else /* jmp lj_vm_ffi_callback. */ *p++ = XI_JMP; *(int32_t *)p = target-(p+4); p += 4; #endif } else { *p++ = XI_JMPs; *p++ = (uint8_t)((2+2)*(31-(slot&31)) - 2); } } lua_assert(p - page <= CALLBACK_MCODE_SIZE); } #elif LJ_TARGET_ARM static void callback_mcode_init(global_State *g, uint32_t *page) { uint32_t *p = page; void *target = (void *)lj_vm_ffi_callback; MSize slot; /* This must match with the saveregs macro in buildvm_arm.dasc. */ *p++ = ARMI_SUB|ARMF_D(RID_R12)|ARMF_N(RID_R12)|ARMF_M(RID_PC); *p++ = ARMI_PUSH|ARMF_N(RID_SP)|RSET_RANGE(RID_R4,RID_R11+1)|RID2RSET(RID_LR); *p++ = ARMI_SUB|ARMI_K12|ARMF_D(RID_R12)|ARMF_N(RID_R12)|CALLBACK_MCODE_HEAD; *p++ = ARMI_STR|ARMI_LS_P|ARMI_LS_W|ARMF_D(RID_R12)|ARMF_N(RID_SP)|(CFRAME_SIZE-4*9); *p++ = ARMI_LDR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_R12)|ARMF_N(RID_PC); *p++ = ARMI_LDR|ARMI_LS_P|ARMI_LS_U|ARMF_D(RID_PC)|ARMF_N(RID_PC); *p++ = u32ptr(g); *p++ = u32ptr(target); for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { *p++ = ARMI_MOV|ARMF_D(RID_R12)|ARMF_M(RID_PC); *p = ARMI_B | ((page-p-2) & 0x00ffffffu); p++; } lua_assert(p - page <= CALLBACK_MCODE_SIZE); } #elif LJ_TARGET_PPC static void callback_mcode_init(global_State *g, uint32_t *page) { uint32_t *p = page; void *target = (void *)lj_vm_ffi_callback; MSize slot; *p++ = PPCI_LIS | PPCF_T(RID_TMP) | (u32ptr(target) >> 16); *p++ = PPCI_LIS | PPCF_T(RID_R12) | (u32ptr(g) >> 16); *p++ = PPCI_ORI | PPCF_A(RID_TMP)|PPCF_T(RID_TMP) | (u32ptr(target) & 0xffff); *p++ = PPCI_ORI | PPCF_A(RID_R12)|PPCF_T(RID_R12) | (u32ptr(g) & 0xffff); *p++ = PPCI_MTCTR | PPCF_T(RID_TMP); *p++ = PPCI_BCTR; for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { *p++ = PPCI_LI | PPCF_T(RID_R11) | slot; *p = PPCI_B | (((page-p) & 0x00ffffffu) << 2); p++; } lua_assert(p - page <= CALLBACK_MCODE_SIZE); } #elif LJ_TARGET_MIPS static void callback_mcode_init(global_State *g, uint32_t *page) { uint32_t *p = page; void *target = (void *)lj_vm_ffi_callback; MSize slot; *p++ = MIPSI_SW | MIPSF_T(RID_R1)|MIPSF_S(RID_SP) | 0; *p++ = MIPSI_LUI | MIPSF_T(RID_R3) | (u32ptr(target) >> 16); *p++ = MIPSI_LUI | MIPSF_T(RID_R2) | (u32ptr(g) >> 16); *p++ = MIPSI_ORI | MIPSF_T(RID_R3)|MIPSF_S(RID_R3) |(u32ptr(target)&0xffff); *p++ = MIPSI_JR | MIPSF_S(RID_R3); *p++ = MIPSI_ORI | MIPSF_T(RID_R2)|MIPSF_S(RID_R2) | (u32ptr(g)&0xffff); for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) { *p = MIPSI_B | ((page-p-1) & 0x0000ffffu); p++; *p++ = MIPSI_LI | MIPSF_T(RID_R1) | slot; } lua_assert(p - page <= CALLBACK_MCODE_SIZE); } #else /* Missing support for this architecture. */ #define callback_mcode_init(g, p) UNUSED(p) #endif /* -- Machine code management --------------------------------------------- */ #if LJ_TARGET_WINDOWS #define WIN32_LEAN_AND_MEAN #include #elif LJ_TARGET_POSIX #include #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON #endif #endif /* Allocate and initialize area for callback function pointers. */ static void callback_mcode_new(CTState *cts) { size_t sz = (size_t)CALLBACK_MCODE_SIZE; void *p; if (CALLBACK_MAX_SLOT == 0) lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); #if LJ_TARGET_WINDOWS p = VirtualAlloc(NULL, sz, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); if (!p) lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); #elif LJ_TARGET_POSIX p = mmap(NULL, sz, (PROT_READ|PROT_WRITE), MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); #else /* Fallback allocator. Fails if memory is not executable by default. */ p = lj_mem_new(cts->L, sz); #endif cts->cb.mcode = p; callback_mcode_init(cts->g, p); lj_mcode_sync(p, (char *)p + sz); #if LJ_TARGET_WINDOWS { DWORD oprot; VirtualProtect(p, sz, PAGE_EXECUTE_READ, &oprot); } #elif LJ_TARGET_POSIX mprotect(p, sz, (PROT_READ|PROT_EXEC)); #endif } /* Free area for callback function pointers. */ void lj_ccallback_mcode_free(CTState *cts) { size_t sz = (size_t)CALLBACK_MCODE_SIZE; void *p = cts->cb.mcode; if (p == NULL) return; #if LJ_TARGET_WINDOWS VirtualFree(p, 0, MEM_RELEASE); UNUSED(sz); #elif LJ_TARGET_POSIX munmap(p, sz); #else lj_mem_free(cts->g, p, sz); #endif } /* -- C callback entry ---------------------------------------------------- */ /* Target-specific handling of register arguments. Similar to lj_ccall.c. */ #if LJ_TARGET_X86 #define CALLBACK_HANDLE_REGARG \ if (!isfp) { /* Only non-FP values may be passed in registers. */ \ if (n > 1) { /* Anything > 32 bit is passed on the stack. */ \ if (!LJ_ABI_WIN) ngpr = maxgpr; /* Prevent reordering. */ \ } else if (ngpr + 1 <= maxgpr) { \ sp = &cts->cb.gpr[ngpr]; \ ngpr += n; \ goto done; \ } \ } #elif LJ_TARGET_X64 && LJ_ABI_WIN /* Windows/x64 argument registers are strictly positional (use ngpr). */ #define CALLBACK_HANDLE_REGARG \ if (isfp) { \ if (ngpr < 4) { sp = &cts->cb.fpr[ngpr++]; nfpr = ngpr; goto done; } \ } else { \ if (ngpr < 4) { sp = &cts->cb.gpr[ngpr++]; goto done; } \ } #elif LJ_TARGET_X64 #define CALLBACK_HANDLE_REGARG \ if (isfp) { \ if (nfpr + n <= CCALL_NARG_FPR) { \ sp = &cts->cb.fpr[nfpr]; \ nfpr += n; \ goto done; \ } \ } else { \ if (ngpr + n <= maxgpr) { \ sp = &cts->cb.gpr[ngpr]; \ ngpr += n; \ goto done; \ } \ } #elif LJ_TARGET_ARM #if LJ_ABI_SOFTFP #define CALLBACK_HANDLE_REGARG_FP1 UNUSED(isfp); #define CALLBACK_HANDLE_REGARG_FP2 #else #define CALLBACK_HANDLE_REGARG_FP1 \ if (isfp) { \ if (n == 1) { \ if (fprodd) { \ sp = &cts->cb.fpr[fprodd-1]; \ fprodd = 0; \ goto done; \ } else if (nfpr + 1 <= CCALL_NARG_FPR) { \ sp = &cts->cb.fpr[nfpr++]; \ fprodd = nfpr; \ goto done; \ } \ } else { \ if (nfpr + 1 <= CCALL_NARG_FPR) { \ sp = &cts->cb.fpr[nfpr++]; \ goto done; \ } \ } \ fprodd = 0; /* No reordering after the first FP value is on stack. */ \ } else { #define CALLBACK_HANDLE_REGARG_FP2 } #endif #define CALLBACK_HANDLE_REGARG \ CALLBACK_HANDLE_REGARG_FP1 \ if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ if (ngpr + n <= maxgpr) { \ sp = &cts->cb.gpr[ngpr]; \ ngpr += n; \ goto done; \ } CALLBACK_HANDLE_REGARG_FP2 #elif LJ_TARGET_PPC #define CALLBACK_HANDLE_REGARG \ if (isfp) { \ if (nfpr + 1 <= CCALL_NARG_FPR) { \ sp = &cts->cb.fpr[nfpr++]; \ cta = ctype_get(cts, CTID_DOUBLE); /* FPRs always hold doubles. */ \ goto done; \ } \ } else { /* Try to pass argument in GPRs. */ \ if (n > 1) { \ lua_assert(ctype_isinteger(cta->info) && n == 2); /* int64_t. */ \ ngpr = (ngpr + 1u) & ~1u; /* Align int64_t to regpair. */ \ } \ if (ngpr + n <= maxgpr) { \ sp = &cts->cb.gpr[ngpr]; \ ngpr += n; \ goto done; \ } \ } #define CALLBACK_HANDLE_RET \ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ *(double *)dp = *(float *)dp; /* FPRs always hold doubles. */ #elif LJ_TARGET_MIPS #define CALLBACK_HANDLE_REGARG \ if (isfp && nfpr < CCALL_NARG_FPR) { /* Try to pass argument in FPRs. */ \ sp = (void *)((uint8_t *)&cts->cb.fpr[nfpr] + ((LJ_BE && n==1) ? 4 : 0)); \ nfpr++; ngpr += n; \ goto done; \ } else { /* Try to pass argument in GPRs. */ \ nfpr = CCALL_NARG_FPR; \ if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \ if (ngpr + n <= maxgpr) { \ sp = &cts->cb.gpr[ngpr]; \ ngpr += n; \ goto done; \ } \ } #define CALLBACK_HANDLE_RET \ if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \ ((float *)dp)[1] = *(float *)dp; #else #error "Missing calling convention definitions for this architecture" #endif /* Convert and push callback arguments to Lua stack. */ static void callback_conv_args(CTState *cts, lua_State *L) { TValue *o = L->top; intptr_t *stack = cts->cb.stack; MSize slot = cts->cb.slot; CTypeID id = 0, rid, fid; CType *ct; GCfunc *fn; MSize ngpr = 0, nsp = 0, maxgpr = CCALL_NARG_GPR; #if CCALL_NARG_FPR MSize nfpr = 0; #if LJ_TARGET_ARM MSize fprodd = 0; #endif #endif if (slot < cts->cb.sizeid && (id = cts->cb.cbid[slot]) != 0) { ct = ctype_get(cts, id); rid = ctype_cid(ct->info); fn = funcV(lj_tab_getint(cts->miscmap, (int32_t)slot)); } else { /* Must set up frame first, before throwing the error. */ ct = NULL; rid = 0; fn = (GCfunc *)L; } o->u32.lo = LJ_CONT_FFI_CALLBACK; /* Continuation returns from callback. */ o->u32.hi = rid; /* Return type. x86: +(spadj<<16). */ o++; setframe_gc(o, obj2gco(fn)); setframe_ftsz(o, (int)((char *)(o+1) - (char *)L->base) + FRAME_CONT); L->top = L->base = ++o; if (!ct) lj_err_caller(cts->L, LJ_ERR_FFI_BADCBACK); if (isluafunc(fn)) setcframe_pc(L->cframe, proto_bc(funcproto(fn))+1); lj_state_checkstack(L, LUA_MINSTACK); /* May throw. */ o = L->base; /* Might have been reallocated. */ #if LJ_TARGET_X86 /* x86 has several different calling conventions. */ switch (ctype_cconv(ct->info)) { case CTCC_FASTCALL: maxgpr = 2; break; case CTCC_THISCALL: maxgpr = 1; break; default: maxgpr = 0; break; } #endif fid = ct->sib; while (fid) { CType *ctf = ctype_get(cts, fid); if (!ctype_isattrib(ctf->info)) { CType *cta; void *sp; CTSize sz; int isfp; MSize n; lua_assert(ctype_isfield(ctf->info)); cta = ctype_rawchild(cts, ctf); isfp = ctype_isfp(cta->info); sz = (cta->size + CTSIZE_PTR-1) & ~(CTSIZE_PTR-1); n = sz / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ CALLBACK_HANDLE_REGARG /* Handle register arguments. */ /* Otherwise pass argument on stack. */ if (CCALL_ALIGN_STACKARG && LJ_32 && sz == 8) nsp = (nsp + 1) & ~1u; /* Align 64 bit argument on stack. */ sp = &stack[nsp]; nsp += n; done: if (LJ_BE && cta->size < CTSIZE_PTR) sp = (void *)((uint8_t *)sp + CTSIZE_PTR-cta->size); lj_cconv_tv_ct(cts, cta, 0, o++, sp); } fid = ctf->sib; } L->top = o; #if LJ_TARGET_X86 /* Store stack adjustment for returns from non-cdecl callbacks. */ if (ctype_cconv(ct->info) != CTCC_CDECL) (L->base-2)->u32.hi |= (nsp << (16+2)); #endif } /* Convert Lua object to callback result. */ static void callback_conv_result(CTState *cts, lua_State *L, TValue *o) { CType *ctr = ctype_raw(cts, (uint16_t)(L->base-2)->u32.hi); #if LJ_TARGET_X86 cts->cb.gpr[2] = 0; #endif if (!ctype_isvoid(ctr->info)) { uint8_t *dp = (uint8_t *)&cts->cb.gpr[0]; #if CCALL_NUM_FPR if (ctype_isfp(ctr->info)) dp = (uint8_t *)&cts->cb.fpr[0]; #endif lj_cconv_ct_tv(cts, ctr, dp, o, 0); #ifdef CALLBACK_HANDLE_RET CALLBACK_HANDLE_RET #endif /* Extend returned integers to (at least) 32 bits. */ if (ctype_isinteger_or_bool(ctr->info) && ctr->size < 4) { if (ctr->info & CTF_UNSIGNED) *(uint32_t *)dp = ctr->size == 1 ? (uint32_t)*(uint8_t *)dp : (uint32_t)*(uint16_t *)dp; else *(int32_t *)dp = ctr->size == 1 ? (int32_t)*(int8_t *)dp : (int32_t)*(int16_t *)dp; } #if LJ_TARGET_X86 if (ctype_isfp(ctr->info)) cts->cb.gpr[2] = ctr->size == sizeof(float) ? 1 : 2; #endif } } /* Enter callback. */ lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf) { lua_State *L = cts->L; global_State *g = cts->g; lua_assert(L != NULL); if (gcref(g->jit_L)) { setstrV(L, L->top++, lj_err_str(L, LJ_ERR_FFI_BADCBACK)); if (g->panic) g->panic(L); exit(EXIT_FAILURE); } lj_trace_abort(g); /* Never record across callback. */ /* Setup C frame. */ cframe_prev(cf) = L->cframe; setcframe_L(cf, L); cframe_errfunc(cf) = -1; cframe_nres(cf) = 0; L->cframe = cf; callback_conv_args(cts, L); return L; /* Now call the function on this stack. */ } /* Leave callback. */ void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o) { lua_State *L = cts->L; GCfunc *fn; TValue *obase = L->base; L->base = L->top; /* Keep continuation frame for throwing errors. */ if (o >= L->base) { /* PC of RET* is lost. Point to last line for result conv. errors. */ fn = curr_func(L); if (isluafunc(fn)) { GCproto *pt = funcproto(fn); setcframe_pc(L->cframe, proto_bc(pt)+pt->sizebc+1); } } callback_conv_result(cts, L, o); /* Finally drop C frame and continuation frame. */ L->cframe = cframe_prev(L->cframe); L->top -= 2; L->base = obase; cts->cb.slot = 0; /* Blacklist C function that called the callback. */ } /* -- C callback management ----------------------------------------------- */ /* Get an unused slot in the callback slot table. */ static MSize callback_slot_new(CTState *cts, CType *ct) { CTypeID id = ctype_typeid(cts, ct); CTypeID1 *cbid = cts->cb.cbid; MSize top; for (top = cts->cb.topid; top < cts->cb.sizeid; top++) if (LJ_LIKELY(cbid[top] == 0)) goto found; #if CALLBACK_MAX_SLOT if (top >= CALLBACK_MAX_SLOT) #endif lj_err_caller(cts->L, LJ_ERR_FFI_CBACKOV); if (!cts->cb.mcode) callback_mcode_new(cts); lj_mem_growvec(cts->L, cbid, cts->cb.sizeid, CALLBACK_MAX_SLOT, CTypeID1); cts->cb.cbid = cbid; memset(cbid+top, 0, (cts->cb.sizeid-top)*sizeof(CTypeID1)); found: cbid[top] = id; cts->cb.topid = top+1; return top; } /* Check for function pointer and supported argument/result types. */ static CType *callback_checkfunc(CTState *cts, CType *ct) { int narg = 0; if (!ctype_isptr(ct->info) || (LJ_64 && ct->size != CTSIZE_PTR)) return NULL; ct = ctype_rawchild(cts, ct); if (ctype_isfunc(ct->info)) { CType *ctr = ctype_rawchild(cts, ct); CTypeID fid = ct->sib; if (!(ctype_isvoid(ctr->info) || ctype_isenum(ctr->info) || ctype_isptr(ctr->info) || (ctype_isnum(ctr->info) && ctr->size <= 8))) return NULL; if ((ct->info & CTF_VARARG)) return NULL; while (fid) { CType *ctf = ctype_get(cts, fid); if (!ctype_isattrib(ctf->info)) { CType *cta; lua_assert(ctype_isfield(ctf->info)); cta = ctype_rawchild(cts, ctf); if (!(ctype_isenum(cta->info) || ctype_isptr(cta->info) || (ctype_isnum(cta->info) && cta->size <= 8)) || ++narg >= LUA_MINSTACK-3) return NULL; } fid = ctf->sib; } return ct; } return NULL; } /* Create a new callback and return the callback function pointer. */ void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn) { ct = callback_checkfunc(cts, ct); if (ct) { MSize slot = callback_slot_new(cts, ct); GCtab *t = cts->miscmap; setfuncV(cts->L, lj_tab_setint(cts->L, t, (int32_t)slot), fn); lj_gc_anybarriert(cts->L, t); return callback_slot2ptr(cts, slot); } return NULL; /* Bad conversion. */ } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ccallback.h ================================================ /* ** FFI C callback handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CCALLBACK_H #define _LJ_CCALLBACK_H #include "lj_obj.h" #include "lj_ctype.h" #if LJ_HASFFI /* Really belongs to lj_vm.h. */ LJ_ASMF void lj_vm_ffi_callback(void); LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_cconv.c ================================================ /* ** C type conversions. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "lj_obj.h" #if LJ_HASFFI #include "lj_err.h" #include "lj_tab.h" #include "lj_ctype.h" #include "lj_cdata.h" #include "lj_cconv.h" #include "lj_ccallback.h" /* -- Conversion errors --------------------------------------------------- */ /* Bad conversion. */ LJ_NORET static void cconv_err_conv(CTState *cts, CType *d, CType *s, CTInfo flags) { const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); const char *src; if ((flags & CCF_FROMTV)) src = lj_obj_typename[1+(ctype_isnum(s->info) ? LUA_TNUMBER : ctype_isarray(s->info) ? LUA_TSTRING : LUA_TNIL)]; else src = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, s), NULL)); if (CCF_GETARG(flags)) lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); else lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); } /* Bad conversion from TValue. */ LJ_NORET static void cconv_err_convtv(CTState *cts, CType *d, TValue *o, CTInfo flags) { const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); const char *src = lj_typename(o); if (CCF_GETARG(flags)) lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); else lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); } /* Initializer overflow. */ LJ_NORET static void cconv_err_initov(CTState *cts, CType *d) { const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); lj_err_callerv(cts->L, LJ_ERR_FFI_INITOV, dst); } /* -- C type compatibility checks ----------------------------------------- */ /* Get raw type and qualifiers for a child type. Resolves enums, too. */ static CType *cconv_childqual(CTState *cts, CType *ct, CTInfo *qual) { ct = ctype_child(cts, ct); for (;;) { if (ctype_isattrib(ct->info)) { if (ctype_attrib(ct->info) == CTA_QUAL) *qual |= ct->size; } else if (!ctype_isenum(ct->info)) { break; } ct = ctype_child(cts, ct); } *qual |= (ct->info & CTF_QUAL); return ct; } /* Check for compatible types when converting to a pointer. ** Note: these checks are more relaxed than what C99 mandates. */ int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags) { if (!((flags & CCF_CAST) || d == s)) { CTInfo dqual = 0, squal = 0; d = cconv_childqual(cts, d, &dqual); if (!ctype_isstruct(s->info)) s = cconv_childqual(cts, s, &squal); if ((flags & CCF_SAME)) { if (dqual != squal) return 0; /* Different qualifiers. */ } else if (!(flags & CCF_IGNQUAL)) { if ((dqual & squal) != squal) return 0; /* Discarded qualifiers. */ if (ctype_isvoid(d->info) || ctype_isvoid(s->info)) return 1; /* Converting to/from void * is always ok. */ } if (ctype_type(d->info) != ctype_type(s->info) || d->size != s->size) return 0; /* Different type or different size. */ if (ctype_isnum(d->info)) { if (((d->info ^ s->info) & (CTF_BOOL|CTF_FP))) return 0; /* Different numeric types. */ } else if (ctype_ispointer(d->info)) { /* Check child types for compatibility. */ return lj_cconv_compatptr(cts, d, s, flags|CCF_SAME); } else if (ctype_isstruct(d->info)) { if (d != s) return 0; /* Must be exact same type for struct/union. */ } else if (ctype_isfunc(d->info)) { /* NYI: structural equality of functions. */ } } return 1; /* Types are compatible. */ } /* -- C type to C type conversion ----------------------------------------- */ /* Convert C type to C type. Caveat: expects to get the raw CType! ** ** Note: This is only used by the interpreter and not optimized at all. ** The JIT compiler will do a much better job specializing for each case. */ void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, uint8_t *dp, uint8_t *sp, CTInfo flags) { CTSize dsize = d->size, ssize = s->size; CTInfo dinfo = d->info, sinfo = s->info; void *tmpptr; lua_assert(!ctype_isenum(dinfo) && !ctype_isenum(sinfo)); lua_assert(!ctype_isattrib(dinfo) && !ctype_isattrib(sinfo)); if (ctype_type(dinfo) > CT_MAYCONVERT || ctype_type(sinfo) > CT_MAYCONVERT) goto err_conv; /* Some basic sanity checks. */ lua_assert(!ctype_isnum(dinfo) || dsize > 0); lua_assert(!ctype_isnum(sinfo) || ssize > 0); lua_assert(!ctype_isbool(dinfo) || dsize == 1 || dsize == 4); lua_assert(!ctype_isbool(sinfo) || ssize == 1 || ssize == 4); lua_assert(!ctype_isinteger(dinfo) || (1u< ssize) { /* Zero-extend or sign-extend LSB. */ #if LJ_LE uint8_t fill = (!(sinfo & CTF_UNSIGNED) && (sp[ssize-1]&0x80)) ? 0xff : 0; memcpy(dp, sp, ssize); memset(dp + ssize, fill, dsize-ssize); #else uint8_t fill = (!(sinfo & CTF_UNSIGNED) && (sp[0]&0x80)) ? 0xff : 0; memset(dp, fill, dsize-ssize); memcpy(dp + (dsize-ssize), sp, ssize); #endif } else { /* Copy LSB. */ #if LJ_LE memcpy(dp, sp, dsize); #else memcpy(dp, sp + (ssize-dsize), dsize); #endif } break; case CCX(I, F): { double n; /* Always convert via double. */ conv_I_F: /* Convert source to double. */ if (ssize == sizeof(double)) n = *(double *)sp; else if (ssize == sizeof(float)) n = (double)*(float *)sp; else goto err_conv; /* NYI: long double. */ /* Then convert double to integer. */ /* The conversion must exactly match the semantics of JIT-compiled code! */ if (dsize < 4 || (dsize == 4 && !(dinfo & CTF_UNSIGNED))) { int32_t i = (int32_t)n; if (dsize == 4) *(int32_t *)dp = i; else if (dsize == 2) *(int16_t *)dp = (int16_t)i; else *(int8_t *)dp = (int8_t)i; } else if (dsize == 4) { *(uint32_t *)dp = (uint32_t)n; } else if (dsize == 8) { if (!(dinfo & CTF_UNSIGNED)) *(int64_t *)dp = (int64_t)n; else *(uint64_t *)dp = lj_num2u64(n); } else { goto err_conv; /* NYI: conversion to >64 bit integers. */ } break; } case CCX(I, C): s = ctype_child(cts, s); sinfo = s->info; ssize = s->size; goto conv_I_F; /* Just convert re. */ case CCX(I, P): if (!(flags & CCF_CAST)) goto err_conv; sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); goto conv_I_I; case CCX(I, A): if (!(flags & CCF_CAST)) goto err_conv; sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); ssize = CTSIZE_PTR; tmpptr = sp; sp = (uint8_t *)&tmpptr; goto conv_I_I; /* Destination is a floating-point number. */ case CCX(F, B): case CCX(F, I): { double n; /* Always convert via double. */ conv_F_I: /* First convert source to double. */ /* The conversion must exactly match the semantics of JIT-compiled code! */ if (ssize < 4 || (ssize == 4 && !(sinfo & CTF_UNSIGNED))) { int32_t i; if (ssize == 4) { i = *(int32_t *)sp; } else if (!(sinfo & CTF_UNSIGNED)) { if (ssize == 2) i = *(int16_t *)sp; else i = *(int8_t *)sp; } else { if (ssize == 2) i = *(uint16_t *)sp; else i = *(uint8_t *)sp; } n = (double)i; } else if (ssize == 4) { n = (double)*(uint32_t *)sp; } else if (ssize == 8) { if (!(sinfo & CTF_UNSIGNED)) n = (double)*(int64_t *)sp; else n = (double)*(uint64_t *)sp; } else { goto err_conv; /* NYI: conversion from >64 bit integers. */ } /* Convert double to destination. */ if (dsize == sizeof(double)) *(double *)dp = n; else if (dsize == sizeof(float)) *(float *)dp = (float)n; else goto err_conv; /* NYI: long double. */ break; } case CCX(F, F): { double n; /* Always convert via double. */ conv_F_F: if (ssize == dsize) goto copyval; /* Convert source to double. */ if (ssize == sizeof(double)) n = *(double *)sp; else if (ssize == sizeof(float)) n = (double)*(float *)sp; else goto err_conv; /* NYI: long double. */ /* Convert double to destination. */ if (dsize == sizeof(double)) *(double *)dp = n; else if (dsize == sizeof(float)) *(float *)dp = (float)n; else goto err_conv; /* NYI: long double. */ break; } case CCX(F, C): s = ctype_child(cts, s); sinfo = s->info; ssize = s->size; goto conv_F_F; /* Ignore im, and convert from re. */ /* Destination is a complex number. */ case CCX(C, I): d = ctype_child(cts, d); dinfo = d->info; dsize = d->size; memset(dp + dsize, 0, dsize); /* Clear im. */ goto conv_F_I; /* Convert to re. */ case CCX(C, F): d = ctype_child(cts, d); dinfo = d->info; dsize = d->size; memset(dp + dsize, 0, dsize); /* Clear im. */ goto conv_F_F; /* Convert to re. */ case CCX(C, C): if (dsize != ssize) { /* Different types: convert re/im separately. */ CType *dc = ctype_child(cts, d); CType *sc = ctype_child(cts, s); lj_cconv_ct_ct(cts, dc, sc, dp, sp, flags); lj_cconv_ct_ct(cts, dc, sc, dp + dc->size, sp + sc->size, flags); return; } goto copyval; /* Otherwise this is easy. */ /* Destination is a vector. */ case CCX(V, I): case CCX(V, F): case CCX(V, C): { CType *dc = ctype_child(cts, d); CTSize esize; /* First convert the scalar to the first element. */ lj_cconv_ct_ct(cts, dc, s, dp, sp, flags); /* Then replicate it to the other elements (splat). */ for (sp = dp, esize = dc->size; dsize > esize; dsize -= esize) { dp += esize; memcpy(dp, sp, esize); } break; } case CCX(V, V): /* Copy same-sized vectors, even for different lengths/element-types. */ if (dsize != ssize) goto err_conv; goto copyval; /* Destination is a pointer. */ case CCX(P, I): if (!(flags & CCF_CAST)) goto err_conv; dinfo = CTINFO(CT_NUM, CTF_UNSIGNED); goto conv_I_I; case CCX(P, F): if (!(flags & CCF_CAST) || !(flags & CCF_FROMTV)) goto err_conv; /* The signed conversion is cheaper. x64 really has 47 bit pointers. */ dinfo = CTINFO(CT_NUM, (LJ_64 && dsize == 8) ? 0 : CTF_UNSIGNED); goto conv_I_F; case CCX(P, P): if (!lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; cdata_setptr(dp, dsize, cdata_getptr(sp, ssize)); break; case CCX(P, A): case CCX(P, S): if (!lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; cdata_setptr(dp, dsize, sp); break; /* Destination is an array. */ case CCX(A, A): if ((flags & CCF_CAST) || (d->info & CTF_VLA) || dsize != ssize || d->size == CTSIZE_INVALID || !lj_cconv_compatptr(cts, d, s, flags)) goto err_conv; goto copyval; /* Destination is a struct/union. */ case CCX(S, S): if ((flags & CCF_CAST) || (d->info & CTF_VLA) || d != s) goto err_conv; /* Must be exact same type. */ copyval: /* Copy value. */ lua_assert(dsize == ssize); memcpy(dp, sp, dsize); break; default: err_conv: cconv_err_conv(cts, d, s, flags); } } /* -- C type to TValue conversion ----------------------------------------- */ /* Convert C type to TValue. Caveat: expects to get the raw CType! */ int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, TValue *o, uint8_t *sp) { CTInfo sinfo = s->info; if (ctype_isnum(sinfo)) { if (!ctype_isbool(sinfo)) { if (ctype_isinteger(sinfo) && s->size > 4) goto copyval; if (LJ_DUALNUM && ctype_isinteger(sinfo)) { int32_t i; lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT32), s, (uint8_t *)&i, sp, 0); if ((sinfo & CTF_UNSIGNED) && i < 0) setnumV(o, (lua_Number)(uint32_t)i); else setintV(o, i); } else { lj_cconv_ct_ct(cts, ctype_get(cts, CTID_DOUBLE), s, (uint8_t *)&o->n, sp, 0); /* Numbers are NOT canonicalized here! Beware of uninitialized data. */ lua_assert(tvisnum(o)); } } else { uint32_t b = s->size == 1 ? (*sp != 0) : (*(int *)sp != 0); setboolV(o, b); setboolV(&cts->g->tmptv2, b); /* Remember for trace recorder. */ } return 0; } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { /* Create reference. */ setcdataV(cts->L, o, lj_cdata_newref(cts, sp, sid)); return 1; /* Need GC step. */ } else { GCcdata *cd; CTSize sz; copyval: /* Copy value. */ sz = s->size; lua_assert(sz != CTSIZE_INVALID); /* Attributes are stripped, qualifiers are kept (but mostly ignored). */ cd = lj_cdata_new(cts, ctype_typeid(cts, s), sz); setcdataV(cts->L, o, cd); memcpy(cdataptr(cd), sp, sz); return 1; /* Need GC step. */ } } /* Convert bitfield to TValue. */ int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp) { CTInfo info = s->info; CTSize pos, bsz; uint32_t val; lua_assert(ctype_isbitfield(info)); /* NYI: packed bitfields may cause misaligned reads. */ switch (ctype_bitcsz(info)) { case 4: val = *(uint32_t *)sp; break; case 2: val = *(uint16_t *)sp; break; case 1: val = *(uint8_t *)sp; break; default: lua_assert(0); val = 0; break; } /* Check if a packed bitfield crosses a container boundary. */ pos = ctype_bitpos(info); bsz = ctype_bitbsz(info); lua_assert(pos < 8*ctype_bitcsz(info)); lua_assert(bsz > 0 && bsz <= 8*ctype_bitcsz(info)); if (pos + bsz > 8*ctype_bitcsz(info)) lj_err_caller(cts->L, LJ_ERR_FFI_NYIPACKBIT); if (!(info & CTF_BOOL)) { CTSize shift = 32 - bsz; if (!(info & CTF_UNSIGNED)) { setintV(o, (int32_t)(val << (shift-pos)) >> shift); } else { val = (val << (shift-pos)) >> shift; if (!LJ_DUALNUM || (int32_t)val < 0) setnumV(o, (lua_Number)(uint32_t)val); else setintV(o, (int32_t)val); } } else { lua_assert(bsz == 1); setboolV(o, (val >> pos) & 1); } return 0; /* No GC step needed. */ } /* -- TValue to C type conversion ----------------------------------------- */ /* Convert table to array. */ static void cconv_array_tab(CTState *cts, CType *d, uint8_t *dp, GCtab *t, CTInfo flags) { int32_t i; CType *dc = ctype_rawchild(cts, d); /* Array element type. */ CTSize size = d->size, esize = dc->size, ofs = 0; for (i = 0; ; i++) { TValue *tv = (TValue *)lj_tab_getint(t, i); if (!tv || tvisnil(tv)) { if (i == 0) continue; /* Try again for 1-based tables. */ break; /* Stop at first nil. */ } if (ofs >= size) cconv_err_initov(cts, d); lj_cconv_ct_tv(cts, dc, dp + ofs, tv, flags); ofs += esize; } if (size != CTSIZE_INVALID) { /* Only fill up arrays with known size. */ if (ofs == esize) { /* Replicate a single element. */ for (; ofs < size; ofs += esize) memcpy(dp + ofs, dp, esize); } else { /* Otherwise fill the remainder with zero. */ memset(dp + ofs, 0, size - ofs); } } } /* Convert table to sub-struct/union. */ static void cconv_substruct_tab(CTState *cts, CType *d, uint8_t *dp, GCtab *t, int32_t *ip, CTInfo flags) { CTypeID id = d->sib; while (id) { CType *df = ctype_get(cts, id); id = df->sib; if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { TValue *tv; int32_t i = *ip, iz = i; if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ if (i >= 0) { retry: tv = (TValue *)lj_tab_getint(t, i); if (!tv || tvisnil(tv)) { if (i == 0) { i = 1; goto retry; } /* 1-based tables. */ if (iz == 0) { *ip = i = -1; goto tryname; } /* Init named fields. */ break; /* Stop at first nil. */ } *ip = i + 1; } else { tryname: tv = (TValue *)lj_tab_getstr(t, gco2str(gcref(df->name))); if (!tv || tvisnil(tv)) continue; } if (ctype_isfield(df->info)) lj_cconv_ct_tv(cts, ctype_rawchild(cts, df), dp+df->size, tv, flags); else lj_cconv_bf_tv(cts, df, dp+df->size, tv); if ((d->info & CTF_UNION)) break; } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { cconv_substruct_tab(cts, ctype_rawchild(cts, df), dp+df->size, t, ip, flags); } /* Ignore all other entries in the chain. */ } } /* Convert table to struct/union. */ static void cconv_struct_tab(CTState *cts, CType *d, uint8_t *dp, GCtab *t, CTInfo flags) { int32_t i = 0; memset(dp, 0, d->size); /* Much simpler to clear the struct first. */ cconv_substruct_tab(cts, d, dp, t, &i, flags); } /* Convert TValue to C type. Caveat: expects to get the raw CType! */ void lj_cconv_ct_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o, CTInfo flags) { CTypeID sid = CTID_P_VOID; CType *s; void *tmpptr; uint8_t tmpbool, *sp = (uint8_t *)&tmpptr; if (LJ_LIKELY(tvisint(o))) { sp = (uint8_t *)&o->i; sid = CTID_INT32; flags |= CCF_FROMTV; } else if (LJ_LIKELY(tvisnum(o))) { sp = (uint8_t *)&o->n; sid = CTID_DOUBLE; flags |= CCF_FROMTV; } else if (tviscdata(o)) { sp = cdataptr(cdataV(o)); sid = cdataV(o)->ctypeid; s = ctype_get(cts, sid); if (ctype_isref(s->info)) { /* Resolve reference for value. */ lua_assert(s->size == CTSIZE_PTR); sp = *(void **)sp; sid = ctype_cid(s->info); } s = ctype_raw(cts, sid); if (ctype_isfunc(s->info)) { sid = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|sid), CTSIZE_PTR); } else { if (ctype_isenum(s->info)) s = ctype_child(cts, s); goto doconv; } } else if (tvisstr(o)) { GCstr *str = strV(o); if (ctype_isenum(d->info)) { /* Match string against enum constant. */ CTSize ofs; CType *cct = lj_ctype_getfield(cts, d, str, &ofs); if (!cct || !ctype_isconstval(cct->info)) goto err_conv; lua_assert(d->size == 4); sp = (uint8_t *)&cct->size; sid = ctype_cid(cct->info); } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ CType *dc = ctype_rawchild(cts, d); CTSize sz = str->len+1; if (!ctype_isinteger(dc->info) || dc->size != 1) goto err_conv; if (d->size != 0 && d->size < sz) sz = d->size; memcpy(dp, strdata(str), sz); return; } else { /* Otherwise pass it as a const char[]. */ sp = (uint8_t *)strdata(str); sid = CTID_A_CCHAR; flags |= CCF_FROMTV; } } else if (tvistab(o)) { if (ctype_isarray(d->info)) { cconv_array_tab(cts, d, dp, tabV(o), flags); return; } else if (ctype_isstruct(d->info)) { cconv_struct_tab(cts, d, dp, tabV(o), flags); return; } else { goto err_conv; } } else if (tvisbool(o)) { tmpbool = boolV(o); sp = &tmpbool; sid = CTID_BOOL; } else if (tvisnil(o)) { tmpptr = (void *)0; flags |= CCF_FROMTV; } else if (tvisudata(o)) { GCudata *ud = udataV(o); tmpptr = uddata(ud); if (ud->udtype == UDTYPE_IO_FILE) tmpptr = *(void **)tmpptr; } else if (tvislightud(o)) { tmpptr = lightudV(o); } else if (tvisfunc(o)) { void *p = lj_ccallback_new(cts, d, funcV(o)); if (p) { *(void **)dp = p; return; } goto err_conv; } else { err_conv: cconv_err_convtv(cts, d, o, flags); } s = ctype_get(cts, sid); doconv: if (ctype_isenum(d->info)) d = ctype_child(cts, d); lj_cconv_ct_ct(cts, d, s, dp, sp, flags); } /* Convert TValue to bitfield. */ void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o) { CTInfo info = d->info; CTSize pos, bsz; uint32_t val, mask; lua_assert(ctype_isbitfield(info)); if ((info & CTF_BOOL)) { uint8_t tmpbool; lua_assert(ctype_bitbsz(info) == 1); lj_cconv_ct_tv(cts, ctype_get(cts, CTID_BOOL), &tmpbool, o, 0); val = tmpbool; } else { CTypeID did = (info & CTF_UNSIGNED) ? CTID_UINT32 : CTID_INT32; lj_cconv_ct_tv(cts, ctype_get(cts, did), (uint8_t *)&val, o, 0); } pos = ctype_bitpos(info); bsz = ctype_bitbsz(info); lua_assert(pos < 8*ctype_bitcsz(info)); lua_assert(bsz > 0 && bsz <= 8*ctype_bitcsz(info)); /* Check if a packed bitfield crosses a container boundary. */ if (pos + bsz > 8*ctype_bitcsz(info)) lj_err_caller(cts->L, LJ_ERR_FFI_NYIPACKBIT); mask = ((1u << bsz) - 1u) << pos; val = (val << pos) & mask; /* NYI: packed bitfields may cause misaligned reads/writes. */ switch (ctype_bitcsz(info)) { case 4: *(uint32_t *)dp = (*(uint32_t *)dp & ~mask) | (uint32_t)val; break; case 2: *(uint16_t *)dp = (*(uint16_t *)dp & ~mask) | (uint16_t)val; break; case 1: *(uint8_t *)dp = (*(uint8_t *)dp & ~mask) | (uint8_t)val; break; default: lua_assert(0); break; } } /* -- Initialize C type with TValues -------------------------------------- */ /* Initialize an array with TValues. */ static void cconv_array_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, TValue *o, MSize len) { CType *dc = ctype_rawchild(cts, d); /* Array element type. */ CTSize ofs, esize = dc->size; MSize i; if (len*esize > sz) cconv_err_initov(cts, d); for (i = 0, ofs = 0; i < len; i++, ofs += esize) lj_cconv_ct_tv(cts, dc, dp + ofs, o + i, 0); if (ofs == esize) { /* Replicate a single element. */ for (; ofs < sz; ofs += esize) memcpy(dp + ofs, dp, esize); } else { /* Otherwise fill the remainder with zero. */ memset(dp + ofs, 0, sz - ofs); } } /* Initialize a sub-struct/union with TValues. */ static void cconv_substruct_init(CTState *cts, CType *d, uint8_t *dp, TValue *o, MSize len, MSize *ip) { CTypeID id = d->sib; while (id) { CType *df = ctype_get(cts, id); id = df->sib; if (ctype_isfield(df->info) || ctype_isbitfield(df->info)) { MSize i = *ip; if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ if (i >= len) break; *ip = i + 1; if (ctype_isfield(df->info)) lj_cconv_ct_tv(cts, ctype_rawchild(cts, df), dp+df->size, o + i, 0); else lj_cconv_bf_tv(cts, df, dp+df->size, o + i); if ((d->info & CTF_UNION)) break; } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { cconv_substruct_init(cts, ctype_rawchild(cts, df), dp+df->size, o, len, ip); } /* Ignore all other entries in the chain. */ } } /* Initialize a struct/union with TValues. */ static void cconv_struct_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, TValue *o, MSize len) { MSize i = 0; memset(dp, 0, sz); /* Much simpler to clear the struct first. */ cconv_substruct_init(cts, d, dp, o, len, &i); if (i < len) cconv_err_initov(cts, d); } /* Check whether to use a multi-value initializer. ** This is true if an aggregate is to be initialized with a value. ** Valarrays are treated as values here so ct_tv handles (V|C, I|F). */ int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o) { if (!(ctype_isrefarray(d->info) || ctype_isstruct(d->info))) return 0; /* Destination is not an aggregate. */ if (tvistab(o) || (tvisstr(o) && !ctype_isstruct(d->info))) return 0; /* Initializer is not a value. */ if (tviscdata(o) && lj_ctype_rawref(cts, cdataV(o)->ctypeid) == d) return 0; /* Source and destination are identical aggregates. */ return 1; /* Otherwise the initializer is a value. */ } /* Initialize C type with TValues. Caveat: expects to get the raw CType! */ void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, TValue *o, MSize len) { if (len == 0) memset(dp, 0, sz); else if (len == 1 && !lj_cconv_multi_init(cts, d, o)) lj_cconv_ct_tv(cts, d, dp, o, 0); else if (ctype_isarray(d->info)) /* Also handles valarray init with len>1. */ cconv_array_init(cts, d, sz, dp, o, len); else if (ctype_isstruct(d->info)) cconv_struct_init(cts, d, sz, dp, o, len); else cconv_err_initov(cts, d); } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_cconv.h ================================================ /* ** C type conversions. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CCONV_H #define _LJ_CCONV_H #include "lj_obj.h" #include "lj_ctype.h" #if LJ_HASFFI /* Compressed C type index. ORDER CCX. */ enum { CCX_B, /* Bool. */ CCX_I, /* Integer. */ CCX_F, /* Floating-point number. */ CCX_C, /* Complex. */ CCX_V, /* Vector. */ CCX_P, /* Pointer. */ CCX_A, /* Refarray. */ CCX_S /* Struct/union. */ }; /* Convert C type info to compressed C type index. ORDER CT. ORDER CCX. */ static LJ_AINLINE uint32_t cconv_idx(CTInfo info) { uint32_t idx = ((info >> 26) & 15u); /* Dispatch bits. */ lua_assert(ctype_type(info) <= CT_MAYCONVERT); #if LJ_64 idx = ((U64x(f436fff5,fff7f021) >> 4*idx) & 15u); #else idx = (((idx < 8 ? 0xfff7f021u : 0xf436fff5) >> 4*(idx & 7u)) & 15u); #endif lua_assert(idx < 8); return idx; } #define cconv_idx2(dinfo, sinfo) \ ((cconv_idx((dinfo)) << 3) + cconv_idx((sinfo))) #define CCX(dst, src) ((CCX_##dst << 3) + CCX_##src) /* Conversion flags. */ #define CCF_CAST 0x00000001u #define CCF_FROMTV 0x00000002u #define CCF_SAME 0x00000004u #define CCF_IGNQUAL 0x00000008u #define CCF_ARG_SHIFT 8 #define CCF_ARG(n) ((n) << CCF_ARG_SHIFT) #define CCF_GETARG(f) ((f) >> CCF_ARG_SHIFT) LJ_FUNC int lj_cconv_compatptr(CTState *cts, CType *d, CType *s, CTInfo flags); LJ_FUNC void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, uint8_t *dp, uint8_t *sp, CTInfo flags); LJ_FUNC int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid, TValue *o, uint8_t *sp); LJ_FUNC int lj_cconv_tv_bf(CTState *cts, CType *s, TValue *o, uint8_t *sp); LJ_FUNC void lj_cconv_ct_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o, CTInfo flags); LJ_FUNC void lj_cconv_bf_tv(CTState *cts, CType *d, uint8_t *dp, TValue *o); LJ_FUNC int lj_cconv_multi_init(CTState *cts, CType *d, TValue *o); LJ_FUNC void lj_cconv_ct_init(CTState *cts, CType *d, CTSize sz, uint8_t *dp, TValue *o, MSize len); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_cdata.c ================================================ /* ** C data management. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "lj_obj.h" #if LJ_HASFFI #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_ctype.h" #include "lj_cconv.h" #include "lj_cdata.h" /* -- C data allocation --------------------------------------------------- */ /* Allocate a new C data object holding a reference to another object. */ GCcdata *lj_cdata_newref(CTState *cts, const void *p, CTypeID id) { CTypeID refid = lj_ctype_intern(cts, CTINFO_REF(id), CTSIZE_PTR); GCcdata *cd = lj_cdata_new(cts, refid, CTSIZE_PTR); *(const void **)cdataptr(cd) = p; return cd; } /* Allocate variable-sized or specially aligned C data object. */ GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, CTSize align) { global_State *g; MSize extra = sizeof(GCcdataVar) + sizeof(GCcdata) + (align > CT_MEMALIGN ? (1u<L, extra + sz, char); uintptr_t adata = (uintptr_t)p + sizeof(GCcdataVar) + sizeof(GCcdata); uintptr_t almask = (1u << align) - 1u; GCcdata *cd = (GCcdata *)(((adata + almask) & ~almask) - sizeof(GCcdata)); lua_assert((char *)cd - p < 65536); cdatav(cd)->offset = (uint16_t)((char *)cd - p); cdatav(cd)->extra = extra; cdatav(cd)->len = sz; g = cts->g; setgcrefr(cd->nextgc, g->gc.root); setgcref(g->gc.root, obj2gco(cd)); newwhite(g, obj2gco(cd)); cd->marked |= 0x80; cd->gct = ~LJ_TCDATA; cd->ctypeid = id; return cd; } /* Free a C data object. */ void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd) { if (LJ_UNLIKELY(cd->marked & LJ_GC_CDATA_FIN)) { GCobj *root; makewhite(g, obj2gco(cd)); markfinalized(obj2gco(cd)); if ((root = gcref(g->gc.mmudata)) != NULL) { setgcrefr(cd->nextgc, root->gch.nextgc); setgcref(root->gch.nextgc, obj2gco(cd)); setgcref(g->gc.mmudata, obj2gco(cd)); } else { setgcref(cd->nextgc, obj2gco(cd)); setgcref(g->gc.mmudata, obj2gco(cd)); } } else if (LJ_LIKELY(!cdataisv(cd))) { CType *ct = ctype_raw(ctype_ctsG(g), cd->ctypeid); CTSize sz = ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR; lua_assert(ctype_hassize(ct->info) || ctype_isfunc(ct->info) || ctype_isextern(ct->info)); lj_mem_free(g, cd, sizeof(GCcdata) + sz); } else { lj_mem_free(g, memcdatav(cd), sizecdatav(cd)); } } TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd) { global_State *g = G(L); GCtab *t = ctype_ctsG(g)->finalizer; if (gcref(t->metatable)) { /* Add cdata to finalizer table, if still enabled. */ TValue *tv, tmp; setcdataV(L, &tmp, cd); lj_gc_anybarriert(L, t); tv = lj_tab_set(L, t, &tmp); cd->marked |= LJ_GC_CDATA_FIN; return tv; } else { /* Otherwise return dummy TValue. */ return &g->tmptv; } } /* -- C data indexing ----------------------------------------------------- */ /* Index C data by a TValue. Return CType and pointer. */ CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, uint8_t **pp, CTInfo *qual) { uint8_t *p = (uint8_t *)cdataptr(cd); CType *ct = ctype_get(cts, cd->ctypeid); ptrdiff_t idx; /* Resolve reference for cdata object. */ if (ctype_isref(ct->info)) { lua_assert(ct->size == CTSIZE_PTR); p = *(uint8_t **)p; ct = ctype_child(cts, ct); } collect_attrib: /* Skip attributes and collect qualifiers. */ while (ctype_isattrib(ct->info)) { if (ctype_attrib(ct->info) == CTA_QUAL) *qual |= ct->size; ct = ctype_child(cts, ct); } lua_assert(!ctype_isref(ct->info)); /* Interning rejects refs to refs. */ if (tvisint(key)) { idx = (ptrdiff_t)intV(key); goto integer_key; } else if (tvisnum(key)) { /* Numeric key. */ idx = LJ_64 ? (ptrdiff_t)numV(key) : (ptrdiff_t)lj_num2int(numV(key)); integer_key: if (ctype_ispointer(ct->info)) { CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */ if (sz != CTSIZE_INVALID) { if (ctype_isptr(ct->info)) { p = (uint8_t *)cdata_getptr(p, ct->size); } else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) { if ((ct->info & CTF_COMPLEX)) idx &= 1; *qual |= CTF_CONST; /* Valarray elements are constant. */ } *pp = p + idx*(int32_t)sz; return ct; } } } else if (tviscdata(key)) { /* Integer cdata key. */ GCcdata *cdk = cdataV(key); CType *ctk = ctype_raw(cts, cdk->ctypeid); if (ctype_isenum(ctk->info)) ctk = ctype_child(cts, ctk); if (ctype_isinteger(ctk->info)) { lj_cconv_ct_ct(cts, ctype_get(cts, CTID_INT_PSZ), ctk, (uint8_t *)&idx, cdataptr(cdk), 0); goto integer_key; } } else if (tvisstr(key)) { /* String key. */ GCstr *name = strV(key); if (ctype_isstruct(ct->info)) { CTSize ofs; CType *fct = lj_ctype_getfieldq(cts, ct, name, &ofs, qual); if (fct) { *pp = p + ofs; return fct; } } else if (ctype_iscomplex(ct->info)) { if (name->len == 2) { *qual |= CTF_CONST; /* Complex fields are constant. */ if (strdata(name)[0] == 'r' && strdata(name)[1] == 'e') { *pp = p; return ct; } else if (strdata(name)[0] == 'i' && strdata(name)[1] == 'm') { *pp = p + (ct->size >> 1); return ct; } } } else if (cd->ctypeid == CTID_CTYPEID) { /* Allow indexing a (pointer to) struct constructor to get constants. */ CType *sct = ctype_raw(cts, *(CTypeID *)p); if (ctype_isptr(sct->info)) sct = ctype_rawchild(cts, sct); if (ctype_isstruct(sct->info)) { CTSize ofs; CType *fct = lj_ctype_getfield(cts, sct, name, &ofs); if (fct && ctype_isconstval(fct->info)) return fct; } ct = sct; /* Allow resolving metamethods for constructors, too. */ } } if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ if (ctype_isstruct(ctype_rawchild(cts, ct)->info)) { p = (uint8_t *)cdata_getptr(p, ct->size); ct = ctype_child(cts, ct); goto collect_attrib; } } *qual |= 1; /* Lookup failed. */ return ct; /* But return the resolved raw type. */ } /* -- C data getters ------------------------------------------------------ */ /* Get constant value and convert to TValue. */ static void cdata_getconst(CTState *cts, TValue *o, CType *ct) { CType *ctt = ctype_child(cts, ct); lua_assert(ctype_isinteger(ctt->info) && ctt->size <= 4); /* Constants are already zero-extended/sign-extended to 32 bits. */ if ((ctt->info & CTF_UNSIGNED) && (int32_t)ct->size < 0) setnumV(o, (lua_Number)(uint32_t)ct->size); else setintV(o, (int32_t)ct->size); } /* Get C data value and convert to TValue. */ int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp) { CTypeID sid; if (ctype_isconstval(s->info)) { cdata_getconst(cts, o, s); return 0; /* No GC step needed. */ } else if (ctype_isbitfield(s->info)) { return lj_cconv_tv_bf(cts, s, o, sp); } /* Get child type of pointer/array/field. */ lua_assert(ctype_ispointer(s->info) || ctype_isfield(s->info)); sid = ctype_cid(s->info); s = ctype_get(cts, sid); /* Resolve reference for field. */ if (ctype_isref(s->info)) { lua_assert(s->size == CTSIZE_PTR); sp = *(uint8_t **)sp; sid = ctype_cid(s->info); s = ctype_get(cts, sid); } /* Skip attributes. */ while (ctype_isattrib(s->info)) s = ctype_child(cts, s); return lj_cconv_tv_ct(cts, s, sid, o, sp); } /* -- C data setters ------------------------------------------------------ */ /* Convert TValue and set C data value. */ void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, CTInfo qual) { if (ctype_isconstval(d->info)) { goto err_const; } else if (ctype_isbitfield(d->info)) { if (((d->info|qual) & CTF_CONST)) goto err_const; lj_cconv_bf_tv(cts, d, dp, o); return; } /* Get child type of pointer/array/field. */ lua_assert(ctype_ispointer(d->info) || ctype_isfield(d->info)); d = ctype_child(cts, d); /* Resolve reference for field. */ if (ctype_isref(d->info)) { lua_assert(d->size == CTSIZE_PTR); dp = *(uint8_t **)dp; d = ctype_child(cts, d); } /* Skip attributes and collect qualifiers. */ for (;;) { if (ctype_isattrib(d->info)) { if (ctype_attrib(d->info) == CTA_QUAL) qual |= d->size; } else { break; } d = ctype_child(cts, d); } lua_assert(ctype_hassize(d->info) && !ctype_isvoid(d->info)); if (((d->info|qual) & CTF_CONST)) { err_const: lj_err_caller(cts->L, LJ_ERR_FFI_WRCONST); } lj_cconv_ct_tv(cts, d, dp, o, 0); } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_cdata.h ================================================ /* ** C data management. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CDATA_H #define _LJ_CDATA_H #include "lj_obj.h" #include "lj_gc.h" #include "lj_ctype.h" #if LJ_HASFFI /* Get C data pointer. */ static LJ_AINLINE void *cdata_getptr(void *p, CTSize sz) { if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ return ((void *)(uintptr_t)*(uint32_t *)p); } else { lua_assert(sz == CTSIZE_PTR); return *(void **)p; } } /* Set C data pointer. */ static LJ_AINLINE void cdata_setptr(void *p, CTSize sz, const void *v) { if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */ *(uint32_t *)p = (uint32_t)(uintptr_t)v; } else { lua_assert(sz == CTSIZE_PTR); *(void **)p = (void *)v; } } /* Allocate fixed-size C data object. */ static LJ_AINLINE GCcdata *lj_cdata_new(CTState *cts, CTypeID id, CTSize sz) { GCcdata *cd; #ifdef LUA_USE_ASSERT CType *ct = ctype_raw(cts, id); lua_assert((ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR) == sz); #endif cd = (GCcdata *)lj_mem_newgco(cts->L, sizeof(GCcdata) + sz); cd->gct = ~LJ_TCDATA; cd->ctypeid = ctype_check(cts, id); return cd; } /* Variant which works without a valid CTState. */ static LJ_AINLINE GCcdata *lj_cdata_new_(lua_State *L, CTypeID id, CTSize sz) { GCcdata *cd = (GCcdata *)lj_mem_newgco(L, sizeof(GCcdata) + sz); cd->gct = ~LJ_TCDATA; cd->ctypeid = id; return cd; } LJ_FUNC GCcdata *lj_cdata_newref(CTState *cts, const void *pp, CTypeID id); LJ_FUNC GCcdata *lj_cdata_newv(CTState *cts, CTypeID id, CTSize sz, CTSize align); LJ_FUNC void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd); LJ_FUNCA TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd); LJ_FUNC CType *lj_cdata_index(CTState *cts, GCcdata *cd, cTValue *key, uint8_t **pp, CTInfo *qual); LJ_FUNC int lj_cdata_get(CTState *cts, CType *s, TValue *o, uint8_t *sp); LJ_FUNC void lj_cdata_set(CTState *cts, CType *d, uint8_t *dp, TValue *o, CTInfo qual); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_char.c ================================================ /* ** Character types. ** Donated to the public domain. ** ** This is intended to replace the problematic libc single-byte NLS functions. ** These just don't make sense anymore with UTF-8 locales becoming the norm ** on POSIX systems. It never worked too well on Windows systems since hardly ** anyone bothered to call setlocale(). ** ** This table is hardcoded for ASCII. Identifiers include the characters ** 128-255, too. This allows for the use of all non-ASCII chars as identifiers ** in the lexer. This is a broad definition, but works well in practice ** for both UTF-8 locales and most single-byte locales (such as ISO-8859-*). ** ** If you really need proper character types for UTF-8 strings, please use ** an add-on library such as slnunicode: http://luaforge.net/projects/sln/ */ #define lj_char_c #define LUA_CORE #include "lj_char.h" LJ_DATADEF const uint8_t lj_char_bits[257] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 152,152,152,152,152,152,152,152,152,152, 4, 4, 4, 4, 4, 4, 4,176,176,176,176,176,176,160,160,160,160,160,160,160,160,160, 160,160,160,160,160,160,160,160,160,160,160, 4, 4, 4, 4,132, 4,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192, 4, 4, 4, 4, 1, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 }; ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_char.h ================================================ /* ** Character types. ** Donated to the public domain. */ #ifndef _LJ_CHAR_H #define _LJ_CHAR_H #include "lj_def.h" #define LJ_CHAR_CNTRL 0x01 #define LJ_CHAR_SPACE 0x02 #define LJ_CHAR_PUNCT 0x04 #define LJ_CHAR_DIGIT 0x08 #define LJ_CHAR_XDIGIT 0x10 #define LJ_CHAR_UPPER 0x20 #define LJ_CHAR_LOWER 0x40 #define LJ_CHAR_IDENT 0x80 #define LJ_CHAR_ALPHA (LJ_CHAR_LOWER|LJ_CHAR_UPPER) #define LJ_CHAR_ALNUM (LJ_CHAR_ALPHA|LJ_CHAR_DIGIT) #define LJ_CHAR_GRAPH (LJ_CHAR_ALNUM|LJ_CHAR_PUNCT) /* Only pass -1 or 0..255 to these macros. Never pass a signed char! */ #define lj_char_isa(c, t) ((lj_char_bits+1)[(c)] & t) #define lj_char_iscntrl(c) lj_char_isa((c), LJ_CHAR_CNTRL) #define lj_char_isspace(c) lj_char_isa((c), LJ_CHAR_SPACE) #define lj_char_ispunct(c) lj_char_isa((c), LJ_CHAR_PUNCT) #define lj_char_isdigit(c) lj_char_isa((c), LJ_CHAR_DIGIT) #define lj_char_isxdigit(c) lj_char_isa((c), LJ_CHAR_XDIGIT) #define lj_char_isupper(c) lj_char_isa((c), LJ_CHAR_UPPER) #define lj_char_islower(c) lj_char_isa((c), LJ_CHAR_LOWER) #define lj_char_isident(c) lj_char_isa((c), LJ_CHAR_IDENT) #define lj_char_isalpha(c) lj_char_isa((c), LJ_CHAR_ALPHA) #define lj_char_isalnum(c) lj_char_isa((c), LJ_CHAR_ALNUM) #define lj_char_isgraph(c) lj_char_isa((c), LJ_CHAR_GRAPH) #define lj_char_toupper(c) ((c) - (lj_char_islower(c) >> 1)) #define lj_char_tolower(c) ((c) + lj_char_isupper(c)) LJ_DATA const uint8_t lj_char_bits[257]; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_clib.c ================================================ /* ** FFI C library loader. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "lj_obj.h" #if LJ_HASFFI #include "lj_gc.h" #include "lj_err.h" #include "lj_tab.h" #include "lj_str.h" #include "lj_udata.h" #include "lj_ctype.h" #include "lj_cconv.h" #include "lj_cdata.h" #include "lj_clib.h" /* -- OS-specific functions ----------------------------------------------- */ #if LJ_TARGET_DLOPEN #include #include #if defined(RTLD_DEFAULT) #define CLIB_DEFHANDLE RTLD_DEFAULT #elif LJ_TARGET_OSX || LJ_TARGET_BSD #define CLIB_DEFHANDLE ((void *)(intptr_t)-2) #else #define CLIB_DEFHANDLE NULL #endif LJ_NORET LJ_NOINLINE static void clib_error_(lua_State *L) { lj_err_callermsg(L, dlerror()); } #define clib_error(L, fmt, name) clib_error_(L) #if defined(__CYGWIN__) #define CLIB_SOPREFIX "cyg" #else #define CLIB_SOPREFIX "lib" #endif #if LJ_TARGET_OSX #define CLIB_SOEXT "%s.dylib" #elif defined(__CYGWIN__) #define CLIB_SOEXT "%s.dll" #else #define CLIB_SOEXT "%s.so" #endif static const char *clib_extname(lua_State *L, const char *name) { if (!strchr(name, '/') #ifdef __CYGWIN__ && !strchr(name, '\\') #endif ) { if (!strchr(name, '.')) { name = lj_str_pushf(L, CLIB_SOEXT, name); L->top--; #ifdef __CYGWIN__ } else { return name; #endif } if (!(name[0] == CLIB_SOPREFIX[0] && name[1] == CLIB_SOPREFIX[1] && name[2] == CLIB_SOPREFIX[2])) { name = lj_str_pushf(L, CLIB_SOPREFIX "%s", name); L->top--; } } return name; } /* Check for a recognized ld script line. */ static const char *clib_check_lds(lua_State *L, const char *buf) { char *p, *e; if ((!strncmp(buf, "GROUP", 5) || !strncmp(buf, "INPUT", 5)) && (p = strchr(buf, '('))) { while (*++p == ' ') ; for (e = p; *e && *e != ' ' && *e != ')'; e++) ; return strdata(lj_str_new(L, p, e-p)); } return NULL; } /* Quick and dirty solution to resolve shared library name from ld script. */ static const char *clib_resolve_lds(lua_State *L, const char *name) { FILE *fp = fopen(name, "r"); const char *p = NULL; if (fp) { char buf[256]; if (fgets(buf, sizeof(buf), fp)) { if (!strncmp(buf, "/* GNU ld script", 16)) { /* ld script magic? */ while (fgets(buf, sizeof(buf), fp)) { /* Check all lines. */ p = clib_check_lds(L, buf); if (p) break; } } else { /* Otherwise check only the first line. */ p = clib_check_lds(L, buf); } } fclose(fp); } return p; } static void *clib_loadlib(lua_State *L, const char *name, int global) { void *h = dlopen(clib_extname(L, name), RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); if (!h) { const char *e, *err = dlerror(); if (*err == '/' && (e = strchr(err, ':')) && (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); if (h) return h; err = dlerror(); } lj_err_callermsg(L, err); } return h; } static void clib_unloadlib(CLibrary *cl) { if (cl->handle && cl->handle != CLIB_DEFHANDLE) dlclose(cl->handle); } static void *clib_getsym(CLibrary *cl, const char *name) { void *p = dlsym(cl->handle, name); return p; } #elif LJ_TARGET_WINDOWS #define WIN32_LEAN_AND_MEAN #ifndef WINVER #define WINVER 0x0500 #endif #include #ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS #define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4 #define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2 BOOL WINAPI GetModuleHandleExA(DWORD, LPCSTR, HMODULE*); #endif #define CLIB_DEFHANDLE ((void *)-1) /* Default libraries. */ enum { CLIB_HANDLE_EXE, CLIB_HANDLE_DLL, CLIB_HANDLE_CRT, CLIB_HANDLE_KERNEL32, CLIB_HANDLE_USER32, CLIB_HANDLE_GDI32, CLIB_HANDLE_MAX }; static void *clib_def_handle[CLIB_HANDLE_MAX]; LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt, const char *name) { DWORD err = GetLastError(); char buf[128]; if (!FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof(buf), NULL)) buf[0] = '\0'; lj_err_callermsg(L, lj_str_pushf(L, fmt, name, buf)); } static int clib_needext(const char *s) { while (*s) { if (*s == '/' || *s == '\\' || *s == '.') return 0; s++; } return 1; } static const char *clib_extname(lua_State *L, const char *name) { if (clib_needext(name)) { name = lj_str_pushf(L, "%s.dll", name); L->top--; } return name; } static void *clib_loadlib(lua_State *L, const char *name, int global) { DWORD oldwerr = GetLastError(); void *h = (void *)LoadLibraryA(clib_extname(L, name)); if (!h) clib_error(L, "cannot load module " LUA_QS ": %s", name); SetLastError(oldwerr); UNUSED(global); return h; } static void clib_unloadlib(CLibrary *cl) { if (cl->handle == CLIB_DEFHANDLE) { MSize i; for (i = CLIB_HANDLE_KERNEL32; i < CLIB_HANDLE_MAX; i++) { void *h = clib_def_handle[i]; if (h) { clib_def_handle[i] = NULL; FreeLibrary((HINSTANCE)h); } } } else if (!cl->handle) { FreeLibrary((HINSTANCE)cl->handle); } } static void *clib_getsym(CLibrary *cl, const char *name) { void *p = NULL; if (cl->handle == CLIB_DEFHANDLE) { /* Search default libraries. */ MSize i; for (i = 0; i < CLIB_HANDLE_MAX; i++) { HINSTANCE h = (HINSTANCE)clib_def_handle[i]; if (!(void *)h) { /* Resolve default library handles (once). */ switch (i) { case CLIB_HANDLE_EXE: GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, &h); break; case CLIB_HANDLE_DLL: GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (const char *)clib_def_handle, &h); break; case CLIB_HANDLE_CRT: GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (const char *)&_fmode, &h); break; case CLIB_HANDLE_KERNEL32: h = LoadLibraryA("kernel32.dll"); break; case CLIB_HANDLE_USER32: h = LoadLibraryA("user32.dll"); break; case CLIB_HANDLE_GDI32: h = LoadLibraryA("gdi32.dll"); break; } if (!h) continue; clib_def_handle[i] = (void *)h; } p = (void *)GetProcAddress(h, name); if (p) break; } } else { p = (void *)GetProcAddress((HINSTANCE)cl->handle, name); } return p; } #else #define CLIB_DEFHANDLE NULL LJ_NORET LJ_NOINLINE static void clib_error(lua_State *L, const char *fmt, const char *name) { lj_err_callermsg(L, lj_str_pushf(L, fmt, name, "no support for this OS")); } static void *clib_loadlib(lua_State *L, const char *name, int global) { lj_err_callermsg(L, "no support for loading dynamic libraries for this OS"); UNUSED(name); UNUSED(global); return NULL; } static void clib_unloadlib(CLibrary *cl) { UNUSED(cl); } static void *clib_getsym(CLibrary *cl, const char *name) { UNUSED(cl); UNUSED(name); return NULL; } #endif /* -- C library indexing -------------------------------------------------- */ #if LJ_TARGET_X86 && LJ_ABI_WIN /* Compute argument size for fastcall/stdcall functions. */ static CTSize clib_func_argsize(CTState *cts, CType *ct) { CTSize n = 0; while (ct->sib) { CType *d; ct = ctype_get(cts, ct->sib); if (ctype_isfield(ct->info)) { d = ctype_rawchild(cts, ct); n += ((d->size + 3) & ~3); } } return n; } #endif /* Get redirected or mangled external symbol. */ static const char *clib_extsym(CTState *cts, CType *ct, GCstr *name) { if (ct->sib) { CType *ctf = ctype_get(cts, ct->sib); if (ctype_isxattrib(ctf->info, CTA_REDIR)) return strdata(gco2str(gcref(ctf->name))); } return strdata(name); } /* Index a C library by name. */ TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name) { TValue *tv = lj_tab_setstr(L, cl->cache, name); if (LJ_UNLIKELY(tvisnil(tv))) { CTState *cts = ctype_cts(L); CType *ct; CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); if (!id) lj_err_callerv(L, LJ_ERR_FFI_NODECL, strdata(name)); if (ctype_isconstval(ct->info)) { CType *ctt = ctype_child(cts, ct); lua_assert(ctype_isinteger(ctt->info) && ctt->size <= 4); if ((ctt->info & CTF_UNSIGNED) && (int32_t)ct->size < 0) setnumV(tv, (lua_Number)(uint32_t)ct->size); else setintV(tv, (int32_t)ct->size); } else { const char *sym = clib_extsym(cts, ct, name); #if LJ_TARGET_WINDOWS DWORD oldwerr = GetLastError(); #endif void *p = clib_getsym(cl, sym); GCcdata *cd; lua_assert(ctype_isfunc(ct->info) || ctype_isextern(ct->info)); #if LJ_TARGET_X86 && LJ_ABI_WIN /* Retry with decorated name for fastcall/stdcall functions. */ if (!p && ctype_isfunc(ct->info)) { CTInfo cconv = ctype_cconv(ct->info); if (cconv == CTCC_FASTCALL || cconv == CTCC_STDCALL) { CTSize sz = clib_func_argsize(cts, ct); const char *symd = lj_str_pushf(L, cconv == CTCC_FASTCALL ? "@%s@%d" : "_%s@%d", sym, sz); L->top--; p = clib_getsym(cl, symd); } } #endif if (!p) clib_error(L, "cannot resolve symbol " LUA_QS ": %s", sym); #if LJ_TARGET_WINDOWS SetLastError(oldwerr); #endif cd = lj_cdata_new(cts, id, CTSIZE_PTR); *(void **)cdataptr(cd) = p; setcdataV(L, tv, cd); } } return tv; } /* -- C library management ------------------------------------------------ */ /* Create a new CLibrary object and push it on the stack. */ static CLibrary *clib_new(lua_State *L, GCtab *mt) { GCtab *t = lj_tab_new(L, 0, 0); GCudata *ud = lj_udata_new(L, sizeof(CLibrary), t); CLibrary *cl = (CLibrary *)uddata(ud); cl->cache = t; ud->udtype = UDTYPE_FFI_CLIB; /* NOBARRIER: The GCudata is new (marked white). */ setgcref(ud->metatable, obj2gco(mt)); setudataV(L, L->top++, ud); return cl; } /* Load a C library. */ void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global) { void *handle = clib_loadlib(L, strdata(name), global); CLibrary *cl = clib_new(L, mt); cl->handle = handle; } /* Unload a C library. */ void lj_clib_unload(CLibrary *cl) { clib_unloadlib(cl); cl->handle = NULL; } /* Create the default C library object. */ void lj_clib_default(lua_State *L, GCtab *mt) { CLibrary *cl = clib_new(L, mt); cl->handle = CLIB_DEFHANDLE; } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_clib.h ================================================ /* ** FFI C library loader. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CLIB_H #define _LJ_CLIB_H #include "lj_obj.h" #if LJ_HASFFI /* Namespace for C library indexing. */ #define CLNS_INDEX ((1u<env. */ } CLibrary; LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); LJ_FUNC void lj_clib_unload(CLibrary *cl); LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_cparse.c ================================================ /* ** C declaration parser. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "lj_obj.h" #if LJ_HASFFI #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_ctype.h" #include "lj_cparse.h" #include "lj_frame.h" #include "lj_vm.h" #include "lj_char.h" #include "lj_strscan.h" /* ** Important note: this is NOT a validating C parser! This is a minimal ** C declaration parser, solely for use by the LuaJIT FFI. ** ** It ought to return correct results for properly formed C declarations, ** but it may accept some invalid declarations, too (and return nonsense). ** Also, it shows rather generic error messages to avoid unnecessary bloat. ** If in doubt, please check the input against your favorite C compiler. */ /* -- C lexer ------------------------------------------------------------- */ /* C lexer token names. */ static const char *const ctoknames[] = { #define CTOKSTR(name, str) str, CTOKDEF(CTOKSTR) #undef CTOKSTR NULL }; /* Forward declaration. */ LJ_NORET static void cp_err(CPState *cp, ErrMsg em); static const char *cp_tok2str(CPState *cp, CPToken tok) { lua_assert(tok < CTOK_FIRSTDECL); if (tok > CTOK_OFS) return ctoknames[tok-CTOK_OFS-1]; else if (!lj_char_iscntrl(tok)) return lj_str_pushf(cp->L, "%c", tok); else return lj_str_pushf(cp->L, "char(%d)", tok); } /* End-of-line? */ static LJ_AINLINE int cp_iseol(CPChar c) { return (c == '\n' || c == '\r'); } static LJ_AINLINE CPChar cp_get(CPState *cp); /* Peek next raw character. */ static LJ_AINLINE CPChar cp_rawpeek(CPState *cp) { return (CPChar)(uint8_t)(*cp->p); } /* Transparently skip backslash-escaped line breaks. */ static LJ_NOINLINE CPChar cp_get_bs(CPState *cp) { CPChar c2, c = cp_rawpeek(cp); if (!cp_iseol(c)) return cp->c; cp->p++; c2 = cp_rawpeek(cp); if (cp_iseol(c2) && c2 != c) cp->p++; cp->linenumber++; return cp_get(cp); } /* Get next character. */ static LJ_AINLINE CPChar cp_get(CPState *cp) { cp->c = (CPChar)(uint8_t)(*cp->p++); if (LJ_LIKELY(cp->c != '\\')) return cp->c; return cp_get_bs(cp); } /* Grow save buffer. */ static LJ_NOINLINE void cp_save_grow(CPState *cp, CPChar c) { MSize newsize; if (cp->sb.sz >= CPARSE_MAX_BUF/2) cp_err(cp, LJ_ERR_XELEM); newsize = cp->sb.sz * 2; lj_str_resizebuf(cp->L, &cp->sb, newsize); cp->sb.buf[cp->sb.n++] = (char)c; } /* Save character in buffer. */ static LJ_AINLINE void cp_save(CPState *cp, CPChar c) { if (LJ_UNLIKELY(cp->sb.n + 1 > cp->sb.sz)) cp_save_grow(cp, c); else cp->sb.buf[cp->sb.n++] = (char)c; } /* Skip line break. Handles "\n", "\r", "\r\n" or "\n\r". */ static void cp_newline(CPState *cp) { CPChar c = cp_rawpeek(cp); if (cp_iseol(c) && c != cp->c) cp->p++; cp->linenumber++; } LJ_NORET static void cp_errmsg(CPState *cp, CPToken tok, ErrMsg em, ...) { const char *msg, *tokstr; lua_State *L; va_list argp; if (tok == 0) { tokstr = NULL; } else if (tok == CTOK_IDENT || tok == CTOK_INTEGER || tok == CTOK_STRING || tok >= CTOK_FIRSTDECL) { if (cp->sb.n == 0) cp_save(cp, '$'); cp_save(cp, '\0'); tokstr = cp->sb.buf; } else { tokstr = cp_tok2str(cp, tok); } L = cp->L; va_start(argp, em); msg = lj_str_pushvf(L, err2msg(em), argp); va_end(argp); if (tokstr) msg = lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tokstr); if (cp->linenumber > 1) msg = lj_str_pushf(L, "%s at line %d", msg, cp->linenumber); lj_err_callermsg(L, msg); } LJ_NORET LJ_NOINLINE static void cp_err_token(CPState *cp, CPToken tok) { cp_errmsg(cp, cp->tok, LJ_ERR_XTOKEN, cp_tok2str(cp, tok)); } LJ_NORET LJ_NOINLINE static void cp_err_badidx(CPState *cp, CType *ct) { GCstr *s = lj_ctype_repr(cp->cts->L, ctype_typeid(cp->cts, ct), NULL); cp_errmsg(cp, 0, LJ_ERR_FFI_BADIDX, strdata(s)); } LJ_NORET LJ_NOINLINE static void cp_err(CPState *cp, ErrMsg em) { cp_errmsg(cp, 0, em); } /* -- Main lexical scanner ------------------------------------------------ */ /* Parse number literal. Only handles int32_t/uint32_t right now. */ static CPToken cp_number(CPState *cp) { StrScanFmt fmt; TValue o; do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp))); cp_save(cp, '\0'); fmt = lj_strscan_scan((const uint8_t *)cp->sb.buf, &o, STRSCAN_OPT_C); if (fmt == STRSCAN_INT) cp->val.id = CTID_INT32; else if (fmt == STRSCAN_U32) cp->val.id = CTID_UINT32; else if (!(cp->mode & CPARSE_MODE_SKIP)) cp_errmsg(cp, CTOK_INTEGER, LJ_ERR_XNUMBER); cp->val.u32 = (uint32_t)o.i; return CTOK_INTEGER; } /* Parse identifier or keyword. */ static CPToken cp_ident(CPState *cp) { do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp))); cp->str = lj_str_new(cp->L, cp->sb.buf, cp->sb.n); cp->val.id = lj_ctype_getname(cp->cts, &cp->ct, cp->str, cp->tmask); if (ctype_type(cp->ct->info) == CT_KW) return ctype_cid(cp->ct->info); return CTOK_IDENT; } /* Parse parameter. */ static CPToken cp_param(CPState *cp) { CPChar c = cp_get(cp); TValue *o = cp->param; if (lj_char_isident(c) || c == '$') /* Reserve $xyz for future extensions. */ cp_errmsg(cp, c, LJ_ERR_XSYNTAX); if (!o || o >= cp->L->top) cp_err(cp, LJ_ERR_FFI_NUMPARAM); cp->param = o+1; if (tvisstr(o)) { cp->str = strV(o); cp->val.id = 0; cp->ct = &cp->cts->tab[0]; return CTOK_IDENT; } else if (tvisnumber(o)) { cp->val.i32 = numberVint(o); cp->val.id = CTID_INT32; return CTOK_INTEGER; } else { GCcdata *cd; if (!tviscdata(o)) lj_err_argtype(cp->L, (int)(o-cp->L->base)+1, "type parameter"); cd = cdataV(o); if (cd->ctypeid == CTID_CTYPEID) cp->val.id = *(CTypeID *)cdataptr(cd); else cp->val.id = cd->ctypeid; return '$'; } } /* Parse string or character constant. */ static CPToken cp_string(CPState *cp) { CPChar delim = cp->c; cp_get(cp); while (cp->c != delim) { CPChar c = cp->c; if (c == '\0') cp_errmsg(cp, CTOK_EOF, LJ_ERR_XSTR); if (c == '\\') { c = cp_get(cp); switch (c) { case '\0': cp_errmsg(cp, CTOK_EOF, LJ_ERR_XSTR); break; case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case 'e': c = 27; break; case 'x': c = 0; while (lj_char_isxdigit(cp_get(cp))) c = (c<<4) + (lj_char_isdigit(cp->c) ? cp->c-'0' : (cp->c&15)+9); cp_save(cp, (c & 0xff)); continue; default: if (lj_char_isdigit(c)) { c -= '0'; if (lj_char_isdigit(cp_get(cp))) { c = c*8 + (cp->c - '0'); if (lj_char_isdigit(cp_get(cp))) { c = c*8 + (cp->c - '0'); cp_get(cp); } } cp_save(cp, (c & 0xff)); continue; } break; } } cp_save(cp, c); cp_get(cp); } cp_get(cp); if (delim == '"') { cp->str = lj_str_new(cp->L, cp->sb.buf, cp->sb.n); return CTOK_STRING; } else { if (cp->sb.n != 1) cp_err_token(cp, '\''); cp->val.i32 = (int32_t)(char)cp->sb.buf[0]; cp->val.id = CTID_INT32; return CTOK_INTEGER; } } /* Skip C comment. */ static void cp_comment_c(CPState *cp) { do { if (cp_get(cp) == '*') { do { if (cp_get(cp) == '/') { cp_get(cp); return; } } while (cp->c == '*'); } if (cp_iseol(cp->c)) cp_newline(cp); } while (cp->c != '\0'); } /* Skip C++ comment. */ static void cp_comment_cpp(CPState *cp) { while (!cp_iseol(cp_get(cp)) && cp->c != '\0') ; } /* Lexical scanner for C. Only a minimal subset is implemented. */ static CPToken cp_next_(CPState *cp) { lj_str_resetbuf(&cp->sb); for (;;) { if (lj_char_isident(cp->c)) return lj_char_isdigit(cp->c) ? cp_number(cp) : cp_ident(cp); switch (cp->c) { case '\n': case '\r': cp_newline(cp); /* fallthrough. */ case ' ': case '\t': case '\v': case '\f': cp_get(cp); break; case '"': case '\'': return cp_string(cp); case '/': if (cp_get(cp) == '*') cp_comment_c(cp); else if (cp->c == '/') cp_comment_cpp(cp); else return '/'; break; case '|': if (cp_get(cp) != '|') return '|'; cp_get(cp); return CTOK_OROR; case '&': if (cp_get(cp) != '&') return '&'; cp_get(cp); return CTOK_ANDAND; case '=': if (cp_get(cp) != '=') return '='; cp_get(cp); return CTOK_EQ; case '!': if (cp_get(cp) != '=') return '!'; cp_get(cp); return CTOK_NE; case '<': if (cp_get(cp) == '=') { cp_get(cp); return CTOK_LE; } else if (cp->c == '<') { cp_get(cp); return CTOK_SHL; } return '<'; case '>': if (cp_get(cp) == '=') { cp_get(cp); return CTOK_GE; } else if (cp->c == '>') { cp_get(cp); return CTOK_SHR; } return '>'; case '-': if (cp_get(cp) != '>') return '-'; cp_get(cp); return CTOK_DEREF; case '$': return cp_param(cp); case '\0': return CTOK_EOF; default: { CPToken c = cp->c; cp_get(cp); return c; } } } } static LJ_NOINLINE CPToken cp_next(CPState *cp) { return (cp->tok = cp_next_(cp)); } /* -- C parser ------------------------------------------------------------ */ /* Namespaces for resolving identifiers. */ #define CPNS_DEFAULT \ ((1u<linenumber = 1; cp->depth = 0; cp->curpack = 0; cp->packstack[0] = 255; lj_str_initbuf(&cp->sb); lj_str_resizebuf(cp->L, &cp->sb, LJ_MIN_SBUF); lua_assert(cp->p != NULL); cp_get(cp); /* Read-ahead first char. */ cp->tok = 0; cp->tmask = CPNS_DEFAULT; cp_next(cp); /* Read-ahead first token. */ } /* Cleanup C parser state. */ static void cp_cleanup(CPState *cp) { global_State *g = G(cp->L); lj_str_freebuf(g, &cp->sb); } /* Check and consume optional token. */ static int cp_opt(CPState *cp, CPToken tok) { if (cp->tok == tok) { cp_next(cp); return 1; } return 0; } /* Check and consume token. */ static void cp_check(CPState *cp, CPToken tok) { if (cp->tok != tok) cp_err_token(cp, tok); cp_next(cp); } /* Check if the next token may start a type declaration. */ static int cp_istypedecl(CPState *cp) { if (cp->tok >= CTOK_FIRSTDECL && cp->tok <= CTOK_LASTDECL) return 1; if (cp->tok == CTOK_IDENT && ctype_istypedef(cp->ct->info)) return 1; if (cp->tok == '$') return 1; return 0; } /* -- Constant expression evaluator --------------------------------------- */ /* Forward declarations. */ static void cp_expr_unary(CPState *cp, CPValue *k); static void cp_expr_sub(CPState *cp, CPValue *k, int pri); /* Please note that type handling is very weak here. Most ops simply ** assume integer operands. Accessors are only needed to compute types and ** return synthetic values. The only purpose of the expression evaluator ** is to compute the values of constant expressions one would typically ** find in C header files. And again: this is NOT a validating C parser! */ /* Parse comma separated expression and return last result. */ static void cp_expr_comma(CPState *cp, CPValue *k) { do { cp_expr_sub(cp, k, 0); } while (cp_opt(cp, ',')); } /* Parse sizeof/alignof operator. */ static void cp_expr_sizeof(CPState *cp, CPValue *k, int wantsz) { CTSize sz; CTInfo info; if (cp_opt(cp, '(')) { if (cp_istypedecl(cp)) k->id = cp_decl_abstract(cp); else cp_expr_comma(cp, k); cp_check(cp, ')'); } else { cp_expr_unary(cp, k); } info = lj_ctype_info(cp->cts, k->id, &sz); if (wantsz) { if (sz != CTSIZE_INVALID) k->u32 = sz; else if (k->id != CTID_A_CCHAR) /* Special case for sizeof("string"). */ cp_err(cp, LJ_ERR_FFI_INVSIZE); } else { k->u32 = 1u << ctype_align(info); } k->id = CTID_UINT32; /* Really size_t. */ } /* Parse prefix operators. */ static void cp_expr_prefix(CPState *cp, CPValue *k) { if (cp->tok == CTOK_INTEGER) { *k = cp->val; cp_next(cp); } else if (cp_opt(cp, '+')) { cp_expr_unary(cp, k); /* Nothing to do (well, integer promotion). */ } else if (cp_opt(cp, '-')) { cp_expr_unary(cp, k); k->i32 = -k->i32; } else if (cp_opt(cp, '~')) { cp_expr_unary(cp, k); k->i32 = ~k->i32; } else if (cp_opt(cp, '!')) { cp_expr_unary(cp, k); k->i32 = !k->i32; k->id = CTID_INT32; } else if (cp_opt(cp, '(')) { if (cp_istypedecl(cp)) { /* Cast operator. */ CTypeID id = cp_decl_abstract(cp); cp_check(cp, ')'); cp_expr_unary(cp, k); k->id = id; /* No conversion performed. */ } else { /* Sub-expression. */ cp_expr_comma(cp, k); cp_check(cp, ')'); } } else if (cp_opt(cp, '*')) { /* Indirection. */ CType *ct; cp_expr_unary(cp, k); ct = lj_ctype_rawref(cp->cts, k->id); if (!ctype_ispointer(ct->info)) cp_err_badidx(cp, ct); k->u32 = 0; k->id = ctype_cid(ct->info); } else if (cp_opt(cp, '&')) { /* Address operator. */ cp_expr_unary(cp, k); k->id = lj_ctype_intern(cp->cts, CTINFO(CT_PTR, CTALIGN_PTR+k->id), CTSIZE_PTR); } else if (cp_opt(cp, CTOK_SIZEOF)) { cp_expr_sizeof(cp, k, 1); } else if (cp_opt(cp, CTOK_ALIGNOF)) { cp_expr_sizeof(cp, k, 0); } else if (cp->tok == CTOK_IDENT) { if (ctype_type(cp->ct->info) == CT_CONSTVAL) { k->u32 = cp->ct->size; k->id = ctype_cid(cp->ct->info); } else if (ctype_type(cp->ct->info) == CT_EXTERN) { k->u32 = cp->val.id; k->id = ctype_cid(cp->ct->info); } else if (ctype_type(cp->ct->info) == CT_FUNC) { k->u32 = cp->val.id; k->id = cp->val.id; } else { goto err_expr; } cp_next(cp); } else if (cp->tok == CTOK_STRING) { CTSize sz = cp->str->len; while (cp_next(cp) == CTOK_STRING) sz += cp->str->len; k->u32 = sz + 1; k->id = CTID_A_CCHAR; } else { err_expr: cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); } } /* Parse postfix operators. */ static void cp_expr_postfix(CPState *cp, CPValue *k) { for (;;) { CType *ct; if (cp_opt(cp, '[')) { /* Array/pointer index. */ CPValue k2; cp_expr_comma(cp, &k2); ct = lj_ctype_rawref(cp->cts, k->id); if (!ctype_ispointer(ct->info)) { ct = lj_ctype_rawref(cp->cts, k2.id); if (!ctype_ispointer(ct->info)) cp_err_badidx(cp, ct); } cp_check(cp, ']'); k->u32 = 0; } else if (cp->tok == '.' || cp->tok == CTOK_DEREF) { /* Struct deref. */ CTSize ofs; CType *fct; ct = lj_ctype_rawref(cp->cts, k->id); if (cp->tok == CTOK_DEREF) { if (!ctype_ispointer(ct->info)) cp_err_badidx(cp, ct); ct = lj_ctype_rawref(cp->cts, ctype_cid(ct->info)); } cp_next(cp); if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); if (!ctype_isstruct(ct->info) || ct->size == CTSIZE_INVALID || !(fct = lj_ctype_getfield(cp->cts, ct, cp->str, &ofs)) || ctype_isbitfield(fct->info)) { GCstr *s = lj_ctype_repr(cp->cts->L, ctype_typeid(cp->cts, ct), NULL); cp_errmsg(cp, 0, LJ_ERR_FFI_BADMEMBER, strdata(s), strdata(cp->str)); } ct = fct; k->u32 = ctype_isconstval(ct->info) ? ct->size : 0; cp_next(cp); } else { return; } k->id = ctype_cid(ct->info); } } /* Parse infix operators. */ static void cp_expr_infix(CPState *cp, CPValue *k, int pri) { CPValue k2; k2.u32 = 0; k2.id = 0; /* Silence the compiler. */ for (;;) { switch (pri) { case 0: if (cp_opt(cp, '?')) { CPValue k3; cp_expr_comma(cp, &k2); /* Right-associative. */ cp_check(cp, ':'); cp_expr_sub(cp, &k3, 0); k->u32 = k->u32 ? k2.u32 : k3.u32; k->id = k2.id > k3.id ? k2.id : k3.id; continue; } case 1: if (cp_opt(cp, CTOK_OROR)) { cp_expr_sub(cp, &k2, 2); k->i32 = k->u32 || k2.u32; k->id = CTID_INT32; continue; } case 2: if (cp_opt(cp, CTOK_ANDAND)) { cp_expr_sub(cp, &k2, 3); k->i32 = k->u32 && k2.u32; k->id = CTID_INT32; continue; } case 3: if (cp_opt(cp, '|')) { cp_expr_sub(cp, &k2, 4); k->u32 = k->u32 | k2.u32; goto arith_result; } case 4: if (cp_opt(cp, '^')) { cp_expr_sub(cp, &k2, 5); k->u32 = k->u32 ^ k2.u32; goto arith_result; } case 5: if (cp_opt(cp, '&')) { cp_expr_sub(cp, &k2, 6); k->u32 = k->u32 & k2.u32; goto arith_result; } case 6: if (cp_opt(cp, CTOK_EQ)) { cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 == k2.u32; k->id = CTID_INT32; continue; } else if (cp_opt(cp, CTOK_NE)) { cp_expr_sub(cp, &k2, 7); k->i32 = k->u32 != k2.u32; k->id = CTID_INT32; continue; } case 7: if (cp_opt(cp, '<')) { cp_expr_sub(cp, &k2, 8); if (k->id == CTID_INT32 && k2.id == CTID_INT32) k->i32 = k->i32 < k2.i32; else k->i32 = k->u32 < k2.u32; k->id = CTID_INT32; continue; } else if (cp_opt(cp, '>')) { cp_expr_sub(cp, &k2, 8); if (k->id == CTID_INT32 && k2.id == CTID_INT32) k->i32 = k->i32 > k2.i32; else k->i32 = k->u32 > k2.u32; k->id = CTID_INT32; continue; } else if (cp_opt(cp, CTOK_LE)) { cp_expr_sub(cp, &k2, 8); if (k->id == CTID_INT32 && k2.id == CTID_INT32) k->i32 = k->i32 <= k2.i32; else k->i32 = k->u32 <= k2.u32; k->id = CTID_INT32; continue; } else if (cp_opt(cp, CTOK_GE)) { cp_expr_sub(cp, &k2, 8); if (k->id == CTID_INT32 && k2.id == CTID_INT32) k->i32 = k->i32 >= k2.i32; else k->i32 = k->u32 >= k2.u32; k->id = CTID_INT32; continue; } case 8: if (cp_opt(cp, CTOK_SHL)) { cp_expr_sub(cp, &k2, 9); k->u32 = k->u32 << k2.u32; continue; } else if (cp_opt(cp, CTOK_SHR)) { cp_expr_sub(cp, &k2, 9); if (k->id == CTID_INT32) k->i32 = k->i32 >> k2.i32; else k->u32 = k->u32 >> k2.u32; continue; } case 9: if (cp_opt(cp, '+')) { cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 + k2.u32; arith_result: if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ continue; } else if (cp_opt(cp, '-')) { cp_expr_sub(cp, &k2, 10); k->u32 = k->u32 - k2.u32; goto arith_result; } case 10: if (cp_opt(cp, '*')) { cp_expr_unary(cp, &k2); k->u32 = k->u32 * k2.u32; goto arith_result; } else if (cp_opt(cp, '/')) { cp_expr_unary(cp, &k2); if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ if (k2.u32 == 0 || (k->id == CTID_INT32 && k->u32 == 0x80000000u && k2.i32 == -1)) cp_err(cp, LJ_ERR_BADVAL); if (k->id == CTID_INT32) k->i32 = k->i32 / k2.i32; else k->u32 = k->u32 / k2.u32; continue; } else if (cp_opt(cp, '%')) { cp_expr_unary(cp, &k2); if (k2.id > k->id) k->id = k2.id; /* Trivial promotion to unsigned. */ if (k2.u32 == 0 || (k->id == CTID_INT32 && k->u32 == 0x80000000u && k2.i32 == -1)) cp_err(cp, LJ_ERR_BADVAL); if (k->id == CTID_INT32) k->i32 = k->i32 % k2.i32; else k->u32 = k->u32 % k2.u32; continue; } default: return; } } } /* Parse and evaluate unary expression. */ static void cp_expr_unary(CPState *cp, CPValue *k) { if (++cp->depth > CPARSE_MAX_DECLDEPTH) cp_err(cp, LJ_ERR_XLEVELS); cp_expr_prefix(cp, k); cp_expr_postfix(cp, k); cp->depth--; } /* Parse and evaluate sub-expression. */ static void cp_expr_sub(CPState *cp, CPValue *k, int pri) { cp_expr_unary(cp, k); cp_expr_infix(cp, k, pri); } /* Parse constant integer expression. */ static void cp_expr_kint(CPState *cp, CPValue *k) { CType *ct; cp_expr_sub(cp, k, 0); ct = ctype_raw(cp->cts, k->id); if (!ctype_isinteger(ct->info)) cp_err(cp, LJ_ERR_BADVAL); } /* Parse (non-negative) size expression. */ static CTSize cp_expr_ksize(CPState *cp) { CPValue k; cp_expr_kint(cp, &k); if (k.u32 >= 0x80000000u) cp_err(cp, LJ_ERR_FFI_INVSIZE); return k.u32; } /* -- Type declaration stack management ----------------------------------- */ /* Add declaration element behind the insertion position. */ static CPDeclIdx cp_add(CPDecl *decl, CTInfo info, CTSize size) { CPDeclIdx top = decl->top; if (top >= CPARSE_MAX_DECLSTACK) cp_err(decl->cp, LJ_ERR_XLEVELS); decl->stack[top].info = info; decl->stack[top].size = size; decl->stack[top].sib = 0; setgcrefnull(decl->stack[top].name); decl->stack[top].next = decl->stack[decl->pos].next; decl->stack[decl->pos].next = (CTypeID1)top; decl->top = top+1; return top; } /* Push declaration element before the insertion position. */ static CPDeclIdx cp_push(CPDecl *decl, CTInfo info, CTSize size) { return (decl->pos = cp_add(decl, info, size)); } /* Push or merge attributes. */ static void cp_push_attributes(CPDecl *decl) { CType *ct = &decl->stack[decl->pos]; if (ctype_isfunc(ct->info)) { /* Ok to modify in-place. */ #if LJ_TARGET_X86 if ((decl->fattr & CTFP_CCONV)) ct->info = (ct->info & (CTMASK_NUM|CTF_VARARG|CTMASK_CID)) + (decl->fattr & ~CTMASK_CID); #endif } else { if ((decl->attr & CTFP_ALIGNED) && !(decl->mode & CPARSE_MODE_FIELD)) cp_push(decl, CTINFO(CT_ATTRIB, CTATTRIB(CTA_ALIGN)), ctype_align(decl->attr)); } } /* Push unrolled type to declaration stack and merge qualifiers. */ static void cp_push_type(CPDecl *decl, CTypeID id) { CType *ct = ctype_get(decl->cp->cts, id); CTInfo info = ct->info; CTSize size = ct->size; switch (ctype_type(info)) { case CT_STRUCT: case CT_ENUM: cp_push(decl, CTINFO(CT_TYPEDEF, id), 0); /* Don't copy unique types. */ if ((decl->attr & CTF_QUAL)) { /* Push unmerged qualifiers. */ cp_push(decl, CTINFO(CT_ATTRIB, CTATTRIB(CTA_QUAL)), (decl->attr & CTF_QUAL)); decl->attr &= ~CTF_QUAL; } break; case CT_ATTRIB: if (ctype_isxattrib(info, CTA_QUAL)) decl->attr &= ~size; /* Remove redundant qualifiers. */ cp_push_type(decl, ctype_cid(info)); /* Unroll. */ cp_push(decl, info & ~CTMASK_CID, size); /* Copy type. */ break; case CT_ARRAY: cp_push_type(decl, ctype_cid(info)); /* Unroll. */ cp_push(decl, info & ~CTMASK_CID, size); /* Copy type. */ decl->stack[decl->pos].sib = 1; /* Mark as already checked and sized. */ /* Note: this is not copied to the ct->sib in the C type table. */ break; case CT_FUNC: /* Copy type, link parameters (shared). */ decl->stack[cp_push(decl, info, size)].sib = ct->sib; break; default: /* Copy type, merge common qualifiers. */ cp_push(decl, info|(decl->attr & CTF_QUAL), size); decl->attr &= ~CTF_QUAL; break; } } /* Consume the declaration element chain and intern the C type. */ static CTypeID cp_decl_intern(CPState *cp, CPDecl *decl) { CTypeID id = 0; CPDeclIdx idx = 0; CTSize csize = CTSIZE_INVALID; CTSize cinfo = 0; do { CType *ct = &decl->stack[idx]; CTInfo info = ct->info; CTInfo size = ct->size; /* The cid is already part of info for copies of pointers/functions. */ idx = ct->next; if (ctype_istypedef(info)) { lua_assert(id == 0); id = ctype_cid(info); /* Always refetch info/size, since struct/enum may have been completed. */ cinfo = ctype_get(cp->cts, id)->info; csize = ctype_get(cp->cts, id)->size; lua_assert(ctype_isstruct(cinfo) || ctype_isenum(cinfo)); } else if (ctype_isfunc(info)) { /* Intern function. */ CType *fct; CTypeID fid; CTypeID sib; if (id) { CType *refct = ctype_raw(cp->cts, id); /* Reject function or refarray return types. */ if (ctype_isfunc(refct->info) || ctype_isrefarray(refct->info)) cp_err(cp, LJ_ERR_FFI_INVTYPE); } /* No intervening attributes allowed, skip forward. */ while (idx) { CType *ctn = &decl->stack[idx]; if (!ctype_isattrib(ctn->info)) break; idx = ctn->next; /* Skip attribute. */ } sib = ct->sib; /* Next line may reallocate the C type table. */ fid = lj_ctype_new(cp->cts, &fct); csize = CTSIZE_INVALID; fct->info = cinfo = info + id; fct->size = size; fct->sib = sib; id = fid; } else if (ctype_isattrib(info)) { if (ctype_isxattrib(info, CTA_QUAL)) cinfo |= size; else if (ctype_isxattrib(info, CTA_ALIGN)) CTF_INSERT(cinfo, ALIGN, size); id = lj_ctype_intern(cp->cts, info+id, size); /* Inherit csize/cinfo from original type. */ } else { if (ctype_isnum(info)) { /* Handle mode/vector-size attributes. */ lua_assert(id == 0); if (!(info & CTF_BOOL)) { CTSize msize = ctype_msizeP(decl->attr); CTSize vsize = ctype_vsizeP(decl->attr); if (msize && (!(info & CTF_FP) || (msize == 4 || msize == 8))) { CTSize malign = lj_fls(msize); if (malign > 4) malign = 4; /* Limit alignment. */ CTF_INSERT(info, ALIGN, malign); size = msize; /* Override size via mode. */ } if (vsize) { /* Vector size set? */ CTSize esize = lj_fls(size); if (vsize >= esize) { /* Intern the element type first. */ id = lj_ctype_intern(cp->cts, info, size); /* Then create a vector (array) with vsize alignment. */ size = (1u << vsize); if (vsize > 4) vsize = 4; /* Limit alignment. */ if (ctype_align(info) > vsize) vsize = ctype_align(info); info = CTINFO(CT_ARRAY, (info & CTF_QUAL) + CTF_VECTOR + CTALIGN(vsize)); } } } } else if (ctype_isptr(info)) { /* Reject pointer/ref to ref. */ if (id && ctype_isref(ctype_raw(cp->cts, id)->info)) cp_err(cp, LJ_ERR_FFI_INVTYPE); if (ctype_isref(info)) { info &= ~CTF_VOLATILE; /* Refs are always const, never volatile. */ /* No intervening attributes allowed, skip forward. */ while (idx) { CType *ctn = &decl->stack[idx]; if (!ctype_isattrib(ctn->info)) break; idx = ctn->next; /* Skip attribute. */ } } } else if (ctype_isarray(info)) { /* Check for valid array size etc. */ if (ct->sib == 0) { /* Only check/size arrays not copied by unroll. */ if (ctype_isref(cinfo)) /* Reject arrays of refs. */ cp_err(cp, LJ_ERR_FFI_INVTYPE); /* Reject VLS or unknown-sized types. */ if (ctype_isvltype(cinfo) || csize == CTSIZE_INVALID) cp_err(cp, LJ_ERR_FFI_INVSIZE); /* a[] and a[?] keep their invalid size. */ if (size != CTSIZE_INVALID) { uint64_t xsz = (uint64_t)size * csize; if (xsz >= 0x80000000u) cp_err(cp, LJ_ERR_FFI_INVSIZE); size = (CTSize)xsz; } } if ((cinfo & CTF_ALIGN) > (info & CTF_ALIGN)) /* Find max. align. */ info = (info & ~CTF_ALIGN) | (cinfo & CTF_ALIGN); info |= (cinfo & CTF_QUAL); /* Inherit qual. */ } else { lua_assert(ctype_isvoid(info)); } csize = size; cinfo = info+id; id = lj_ctype_intern(cp->cts, info+id, size); } } while (idx); return id; } /* -- C declaration parser ------------------------------------------------ */ #define H_(le, be) LJ_ENDIAN_SELECT(0x##le, 0x##be) /* Reset declaration state to declaration specifier. */ static void cp_decl_reset(CPDecl *decl) { decl->pos = decl->specpos; decl->top = decl->specpos+1; decl->stack[decl->specpos].next = 0; decl->attr = decl->specattr; decl->fattr = decl->specfattr; decl->name = NULL; decl->redir = NULL; } /* Parse constant initializer. */ /* NYI: FP constants and strings as initializers. */ static CTypeID cp_decl_constinit(CPState *cp, CType **ctp, CTypeID ctypeid) { CType *ctt = ctype_get(cp->cts, ctypeid); CTInfo info; CTSize size; CPValue k; CTypeID constid; while (ctype_isattrib(ctt->info)) { /* Skip attributes. */ ctypeid = ctype_cid(ctt->info); /* Update ID, too. */ ctt = ctype_get(cp->cts, ctypeid); } info = ctt->info; size = ctt->size; if (!ctype_isinteger(info) || !(info & CTF_CONST) || size > 4) cp_err(cp, LJ_ERR_FFI_INVTYPE); cp_check(cp, '='); cp_expr_sub(cp, &k, 0); constid = lj_ctype_new(cp->cts, ctp); (*ctp)->info = CTINFO(CT_CONSTVAL, CTF_CONST|ctypeid); k.u32 <<= 8*(4-size); if ((info & CTF_UNSIGNED)) k.u32 >>= 8*(4-size); else k.u32 = (uint32_t)((int32_t)k.u32 >> 8*(4-size)); (*ctp)->size = k.u32; return constid; } /* Parse size in parentheses as part of attribute. */ static CTSize cp_decl_sizeattr(CPState *cp) { CTSize sz; uint32_t oldtmask = cp->tmask; cp->tmask = CPNS_DEFAULT; /* Required for expression evaluator. */ cp_check(cp, '('); sz = cp_expr_ksize(cp); cp->tmask = oldtmask; cp_check(cp, ')'); return sz; } /* Parse alignment attribute. */ static void cp_decl_align(CPState *cp, CPDecl *decl) { CTSize al = 4; /* Unspecified alignment is 16 bytes. */ if (cp->tok == '(') { al = cp_decl_sizeattr(cp); al = al ? lj_fls(al) : 0; } CTF_INSERT(decl->attr, ALIGN, al); decl->attr |= CTFP_ALIGNED; } /* Parse GCC asm("name") redirect. */ static void cp_decl_asm(CPState *cp, CPDecl *decl) { UNUSED(decl); cp_next(cp); cp_check(cp, '('); if (cp->tok == CTOK_STRING) { GCstr *str = cp->str; while (cp_next(cp) == CTOK_STRING) { lj_str_pushf(cp->L, "%s%s", strdata(str), strdata(cp->str)); cp->L->top--; str = strV(cp->L->top); } decl->redir = str; } cp_check(cp, ')'); } /* Parse GCC __attribute__((mode(...))). */ static void cp_decl_mode(CPState *cp, CPDecl *decl) { cp_check(cp, '('); if (cp->tok == CTOK_IDENT) { const char *s = strdata(cp->str); CTSize sz = 0, vlen = 0; if (s[0] == '_' && s[1] == '_') s += 2; if (*s == 'V') { s++; vlen = *s++ - '0'; if (*s >= '0' && *s <= '9') vlen = vlen*10 + (*s++ - '0'); } switch (*s++) { case 'Q': sz = 1; break; case 'H': sz = 2; break; case 'S': sz = 4; break; case 'D': sz = 8; break; case 'T': sz = 16; break; case 'O': sz = 32; break; default: goto bad_size; } if (*s == 'I' || *s == 'F') { CTF_INSERT(decl->attr, MSIZEP, sz); if (vlen) CTF_INSERT(decl->attr, VSIZEP, lj_fls(vlen*sz)); } bad_size: cp_next(cp); } cp_check(cp, ')'); } /* Parse GCC __attribute__((...)). */ static void cp_decl_gccattribute(CPState *cp, CPDecl *decl) { cp_next(cp); cp_check(cp, '('); cp_check(cp, '('); while (cp->tok != ')') { if (cp->tok == CTOK_IDENT) { GCstr *attrstr = cp->str; cp_next(cp); switch (attrstr->hash) { case H_(64a9208e,8ce14319): case H_(8e6331b2,95a282af): /* aligned */ cp_decl_align(cp, decl); break; case H_(42eb47de,f0ede26c): case H_(29f48a09,cf383e0c): /* packed */ decl->attr |= CTFP_PACKED; break; case H_(0a84eef6,8dfab04c): case H_(995cf92c,d5696591): /* mode */ cp_decl_mode(cp, decl); break; case H_(0ab31997,2d5213fa): case H_(bf875611,200e9990): /* vector_size */ { CTSize vsize = cp_decl_sizeattr(cp); if (vsize) CTF_INSERT(decl->attr, VSIZEP, lj_fls(vsize)); } break; #if LJ_TARGET_X86 case H_(5ad22db8,c689b848): case H_(439150fa,65ea78cb): /* regparm */ CTF_INSERT(decl->fattr, REGPARM, cp_decl_sizeattr(cp)); decl->fattr |= CTFP_CCONV; break; case H_(18fc0b98,7ff4c074): case H_(4e62abed,0a747424): /* cdecl */ CTF_INSERT(decl->fattr, CCONV, CTCC_CDECL); decl->fattr |= CTFP_CCONV; break; case H_(72b2e41b,494c5a44): case H_(f2356d59,f25fc9bd): /* thiscall */ CTF_INSERT(decl->fattr, CCONV, CTCC_THISCALL); decl->fattr |= CTFP_CCONV; break; case H_(0d0ffc42,ab746f88): case H_(21c54ba1,7f0ca7e3): /* fastcall */ CTF_INSERT(decl->fattr, CCONV, CTCC_FASTCALL); decl->fattr |= CTFP_CCONV; break; case H_(ef76b040,9412e06a): case H_(de56697b,c750e6e1): /* stdcall */ CTF_INSERT(decl->fattr, CCONV, CTCC_STDCALL); decl->fattr |= CTFP_CCONV; break; case H_(ea78b622,f234bd8e): case H_(252ffb06,8d50f34b): /* sseregparm */ decl->fattr |= CTF_SSEREGPARM; decl->fattr |= CTFP_CCONV; break; #endif default: /* Skip all other attributes. */ goto skip_attr; } } else if (cp->tok >= CTOK_FIRSTDECL) { /* For __attribute((const)) etc. */ cp_next(cp); skip_attr: if (cp_opt(cp, '(')) { while (cp->tok != ')' && cp->tok != CTOK_EOF) cp_next(cp); cp_check(cp, ')'); } } else { break; } if (!cp_opt(cp, ',')) break; } cp_check(cp, ')'); cp_check(cp, ')'); } /* Parse MSVC __declspec(...). */ static void cp_decl_msvcattribute(CPState *cp, CPDecl *decl) { cp_next(cp); cp_check(cp, '('); while (cp->tok == CTOK_IDENT) { GCstr *attrstr = cp->str; cp_next(cp); switch (attrstr->hash) { case H_(bc2395fa,98f267f8): /* align */ cp_decl_align(cp, decl); break; default: /* Ignore all other attributes. */ if (cp_opt(cp, '(')) { while (cp->tok != ')' && cp->tok != CTOK_EOF) cp_next(cp); cp_check(cp, ')'); } break; } } cp_check(cp, ')'); } /* Parse declaration attributes (and common qualifiers). */ static void cp_decl_attributes(CPState *cp, CPDecl *decl) { for (;;) { switch (cp->tok) { case CTOK_CONST: decl->attr |= CTF_CONST; break; case CTOK_VOLATILE: decl->attr |= CTF_VOLATILE; break; case CTOK_RESTRICT: break; /* Ignore. */ case CTOK_EXTENSION: break; /* Ignore. */ case CTOK_ATTRIBUTE: cp_decl_gccattribute(cp, decl); continue; case CTOK_ASM: cp_decl_asm(cp, decl); continue; case CTOK_DECLSPEC: cp_decl_msvcattribute(cp, decl); continue; case CTOK_CCDECL: #if LJ_TARGET_X86 CTF_INSERT(decl->fattr, CCONV, cp->ct->size); decl->fattr |= CTFP_CCONV; #endif break; case CTOK_PTRSZ: #if LJ_64 CTF_INSERT(decl->attr, MSIZEP, cp->ct->size); #endif break; default: return; } cp_next(cp); } } /* Parse struct/union/enum name. */ static CTypeID cp_struct_name(CPState *cp, CPDecl *sdecl, CTInfo info) { CTypeID sid; CType *ct; cp->tmask = CPNS_STRUCT; cp_next(cp); cp_decl_attributes(cp, sdecl); cp->tmask = CPNS_DEFAULT; if (cp->tok != '{') { if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); if (cp->val.id) { /* Name of existing struct/union/enum. */ sid = cp->val.id; ct = cp->ct; if ((ct->info ^ info) & (CTMASK_NUM|CTF_UNION)) /* Wrong type. */ cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(gco2str(gcref(ct->name)))); } else { /* Create named, incomplete struct/union/enum. */ if ((cp->mode & CPARSE_MODE_NOIMPLICIT)) cp_errmsg(cp, 0, LJ_ERR_FFI_BADTAG, strdata(cp->str)); sid = lj_ctype_new(cp->cts, &ct); ct->info = info; ct->size = CTSIZE_INVALID; ctype_setname(ct, cp->str); lj_ctype_addname(cp->cts, ct, sid); } cp_next(cp); } else { /* Create anonymous, incomplete struct/union/enum. */ sid = lj_ctype_new(cp->cts, &ct); ct->info = info; ct->size = CTSIZE_INVALID; } if (cp->tok == '{') { if (ct->size != CTSIZE_INVALID || ct->sib) cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(gco2str(gcref(ct->name)))); ct->sib = 1; /* Indicate the type is currently being defined. */ } return sid; } /* Determine field alignment. */ static CTSize cp_field_align(CPState *cp, CType *ct, CTInfo info) { CTSize align = ctype_align(info); UNUSED(cp); UNUSED(ct); #if (LJ_TARGET_X86 && !LJ_ABI_WIN) || (LJ_TARGET_ARM && __APPLE__) /* The SYSV i386 and iOS ABIs limit alignment of non-vector fields to 2^2. */ if (align > 2 && !(info & CTFP_ALIGNED)) { if (ctype_isarray(info) && !(info & CTF_VECTOR)) { do { ct = ctype_rawchild(cp->cts, ct); info = ct->info; } while (ctype_isarray(info) && !(info & CTF_VECTOR)); } if (ctype_isnum(info) || ctype_isenum(info)) align = 2; } #endif return align; } /* Layout struct/union fields. */ static void cp_struct_layout(CPState *cp, CTypeID sid, CTInfo sattr) { CTSize bofs = 0, bmaxofs = 0; /* Bit offset and max. bit offset. */ CTSize maxalign = ctype_align(sattr); CType *sct = ctype_get(cp->cts, sid); CTInfo sinfo = sct->info; CTypeID fieldid = sct->sib; while (fieldid) { CType *ct = ctype_get(cp->cts, fieldid); CTInfo attr = ct->size; /* Field declaration attributes (temp.). */ if (ctype_isfield(ct->info) || (ctype_isxattrib(ct->info, CTA_SUBTYPE) && attr)) { CTSize align, amask; /* Alignment (pow2) and alignment mask (bits). */ CTSize sz; CTInfo info = lj_ctype_info(cp->cts, ctype_cid(ct->info), &sz); CTSize bsz, csz = 8*sz; /* Field size and container size (in bits). */ sinfo |= (info & (CTF_QUAL|CTF_VLA)); /* Merge pseudo-qualifiers. */ /* Check for size overflow and determine alignment. */ if (sz >= 0x20000000u || bofs + csz < bofs) { if (!(sz == CTSIZE_INVALID && ctype_isarray(info) && !(sinfo & CTF_UNION))) cp_err(cp, LJ_ERR_FFI_INVSIZE); csz = sz = 0; /* Treat a[] and a[?] as zero-sized. */ } align = cp_field_align(cp, ct, info); if (((attr|sattr) & CTFP_PACKED) || ((attr & CTFP_ALIGNED) && ctype_align(attr) > align)) align = ctype_align(attr); if (cp->packstack[cp->curpack] < align) align = cp->packstack[cp->curpack]; if (align > maxalign) maxalign = align; amask = (8u << align) - 1; bsz = ctype_bitcsz(ct->info); /* Bitfield size (temp.). */ if (bsz == CTBSZ_FIELD || !ctype_isfield(ct->info)) { bsz = csz; /* Regular fields or subtypes always fill the container. */ bofs = (bofs + amask) & ~amask; /* Start new aligned field. */ ct->size = (bofs >> 3); /* Store field offset. */ } else { /* Bitfield. */ if (bsz == 0 || (attr & CTFP_ALIGNED) || (!((attr|sattr) & CTFP_PACKED) && (bofs & amask) + bsz > csz)) bofs = (bofs + amask) & ~amask; /* Start new aligned field. */ /* Prefer regular field over bitfield. */ if (bsz == csz && (bofs & amask) == 0) { ct->info = CTINFO(CT_FIELD, ctype_cid(ct->info)); ct->size = (bofs >> 3); /* Store field offset. */ } else { ct->info = CTINFO(CT_BITFIELD, (info & (CTF_QUAL|CTF_UNSIGNED|CTF_BOOL)) + (csz << (CTSHIFT_BITCSZ-3)) + (bsz << CTSHIFT_BITBSZ)); #if LJ_BE ct->info += ((csz - (bofs & (csz-1)) - bsz) << CTSHIFT_BITPOS); #else ct->info += ((bofs & (csz-1)) << CTSHIFT_BITPOS); #endif ct->size = ((bofs & ~(csz-1)) >> 3); /* Store container offset. */ } } /* Determine next offset or max. offset. */ if ((sinfo & CTF_UNION)) { if (bsz > bmaxofs) bmaxofs = bsz; } else { bofs += bsz; } } /* All other fields in the chain are already set up. */ fieldid = ct->sib; } /* Complete struct/union. */ sct->info = sinfo + CTALIGN(maxalign); bofs = (sinfo & CTF_UNION) ? bmaxofs : bofs; maxalign = (8u << maxalign) - 1; sct->size = (((bofs + maxalign) & ~maxalign) >> 3); } /* Parse struct/union declaration. */ static CTypeID cp_decl_struct(CPState *cp, CPDecl *sdecl, CTInfo sinfo) { CTypeID sid = cp_struct_name(cp, sdecl, sinfo); if (cp_opt(cp, '{')) { /* Struct/union definition. */ CTypeID lastid = sid; int lastdecl = 0; while (cp->tok != '}') { CPDecl decl; CPscl scl = cp_decl_spec(cp, &decl, CDF_STATIC); decl.mode = scl ? CPARSE_MODE_DIRECT : CPARSE_MODE_DIRECT|CPARSE_MODE_ABSTRACT|CPARSE_MODE_FIELD; for (;;) { CTypeID ctypeid; if (lastdecl) cp_err_token(cp, '}'); /* Parse field declarator. */ decl.bits = CTSIZE_INVALID; cp_declarator(cp, &decl); ctypeid = cp_decl_intern(cp, &decl); if ((scl & CDF_STATIC)) { /* Static constant in struct namespace. */ CType *ct; CTypeID fieldid = cp_decl_constinit(cp, &ct, ctypeid); ctype_get(cp->cts, lastid)->sib = fieldid; lastid = fieldid; ctype_setname(ct, decl.name); } else { CTSize bsz = CTBSZ_FIELD; /* Temp. for layout phase. */ CType *ct; CTypeID fieldid = lj_ctype_new(cp->cts, &ct); /* Do this first. */ CType *tct = ctype_raw(cp->cts, ctypeid); if (decl.bits == CTSIZE_INVALID) { /* Regular field. */ if (ctype_isarray(tct->info) && tct->size == CTSIZE_INVALID) lastdecl = 1; /* a[] or a[?] must be the last declared field. */ /* Accept transparent struct/union/enum. */ if (!decl.name) { if (!((ctype_isstruct(tct->info) && !(tct->info & CTF_VLA)) || ctype_isenum(tct->info))) cp_err_token(cp, CTOK_IDENT); ct->info = CTINFO(CT_ATTRIB, CTATTRIB(CTA_SUBTYPE) + ctypeid); ct->size = ctype_isstruct(tct->info) ? (decl.attr|0x80000000u) : 0; /* For layout phase. */ goto add_field; } } else { /* Bitfield. */ bsz = decl.bits; if (!ctype_isinteger_or_bool(tct->info) || (bsz == 0 && decl.name) || 8*tct->size > CTBSZ_MAX || bsz > ((tct->info & CTF_BOOL) ? 1 : 8*tct->size)) cp_errmsg(cp, ':', LJ_ERR_BADVAL); } /* Create temporary field for layout phase. */ ct->info = CTINFO(CT_FIELD, ctypeid + (bsz << CTSHIFT_BITCSZ)); ct->size = decl.attr; if (decl.name) ctype_setname(ct, decl.name); add_field: ctype_get(cp->cts, lastid)->sib = fieldid; lastid = fieldid; } if (!cp_opt(cp, ',')) break; cp_decl_reset(&decl); } cp_check(cp, ';'); } cp_check(cp, '}'); ctype_get(cp->cts, lastid)->sib = 0; /* Drop sib = 1 for empty structs. */ cp_decl_attributes(cp, sdecl); /* Layout phase needs postfix attributes. */ cp_struct_layout(cp, sid, sdecl->attr); } return sid; } /* Parse enum declaration. */ static CTypeID cp_decl_enum(CPState *cp, CPDecl *sdecl) { CTypeID eid = cp_struct_name(cp, sdecl, CTINFO(CT_ENUM, CTID_VOID)); CTInfo einfo = CTINFO(CT_ENUM, CTALIGN(2) + CTID_UINT32); CTSize esize = 4; /* Only 32 bit enums are supported. */ if (cp_opt(cp, '{')) { /* Enum definition. */ CPValue k; CTypeID lastid = eid; k.u32 = 0; k.id = CTID_INT32; do { GCstr *name = cp->str; if (cp->tok != CTOK_IDENT) cp_err_token(cp, CTOK_IDENT); if (cp->val.id) cp_errmsg(cp, 0, LJ_ERR_FFI_REDEF, strdata(name)); cp_next(cp); if (cp_opt(cp, '=')) { cp_expr_kint(cp, &k); if (k.id == CTID_UINT32) { /* C99 says that enum constants are always (signed) integers. ** But since unsigned constants like 0x80000000 are quite common, ** those are left as uint32_t. */ if (k.i32 >= 0) k.id = CTID_INT32; } else { /* OTOH it's common practice and even mandated by some ABIs ** that the enum type itself is unsigned, unless there are any ** negative constants. */ k.id = CTID_INT32; if (k.i32 < 0) einfo = CTINFO(CT_ENUM, CTALIGN(2) + CTID_INT32); } } /* Add named enum constant. */ { CType *ct; CTypeID constid = lj_ctype_new(cp->cts, &ct); ctype_get(cp->cts, lastid)->sib = constid; lastid = constid; ctype_setname(ct, name); ct->info = CTINFO(CT_CONSTVAL, CTF_CONST|k.id); ct->size = k.u32++; if (k.u32 == 0x80000000u) k.id = CTID_UINT32; lj_ctype_addname(cp->cts, ct, constid); } if (!cp_opt(cp, ',')) break; } while (cp->tok != '}'); /* Trailing ',' is ok. */ cp_check(cp, '}'); /* Complete enum. */ ctype_get(cp->cts, eid)->info = einfo; ctype_get(cp->cts, eid)->size = esize; } return eid; } /* Parse declaration specifiers. */ static CPscl cp_decl_spec(CPState *cp, CPDecl *decl, CPscl scl) { uint32_t cds = 0, sz = 0; CTypeID tdef = 0; decl->cp = cp; decl->mode = cp->mode; decl->name = NULL; decl->redir = NULL; decl->attr = 0; decl->fattr = 0; decl->pos = decl->top = 0; decl->stack[0].next = 0; for (;;) { /* Parse basic types. */ cp_decl_attributes(cp, decl); if (cp->tok >= CTOK_FIRSTDECL && cp->tok <= CTOK_LASTDECLFLAG) { uint32_t cbit; if (cp->ct->size) { if (sz) goto end_decl; sz = cp->ct->size; } cbit = (1u << (cp->tok - CTOK_FIRSTDECL)); cds = cds | cbit | ((cbit & cds & CDF_LONG) << 1); if (cp->tok >= CTOK_FIRSTSCL) { if (!(scl & cbit)) cp_errmsg(cp, cp->tok, LJ_ERR_FFI_BADSCL); } else if (tdef) { goto end_decl; } cp_next(cp); continue; } if (sz || tdef || (cds & (CDF_SHORT|CDF_LONG|CDF_SIGNED|CDF_UNSIGNED|CDF_COMPLEX))) break; switch (cp->tok) { case CTOK_STRUCT: tdef = cp_decl_struct(cp, decl, CTINFO(CT_STRUCT, 0)); continue; case CTOK_UNION: tdef = cp_decl_struct(cp, decl, CTINFO(CT_STRUCT, CTF_UNION)); continue; case CTOK_ENUM: tdef = cp_decl_enum(cp, decl); continue; case CTOK_IDENT: if (ctype_istypedef(cp->ct->info)) { tdef = ctype_cid(cp->ct->info); /* Get typedef. */ cp_next(cp); continue; } break; case '$': tdef = cp->val.id; cp_next(cp); continue; default: break; } break; } end_decl: if ((cds & CDF_COMPLEX)) /* Use predefined complex types. */ tdef = sz == 4 ? CTID_COMPLEX_FLOAT : CTID_COMPLEX_DOUBLE; if (tdef) { cp_push_type(decl, tdef); } else if ((cds & CDF_VOID)) { cp_push(decl, CTINFO(CT_VOID, (decl->attr & CTF_QUAL)), CTSIZE_INVALID); decl->attr &= ~CTF_QUAL; } else { /* Determine type info and size. */ CTInfo info = CTINFO(CT_NUM, (cds & CDF_UNSIGNED) ? CTF_UNSIGNED : 0); if ((cds & CDF_BOOL)) { if ((cds & ~(CDF_SCL|CDF_BOOL|CDF_INT|CDF_SIGNED|CDF_UNSIGNED))) cp_errmsg(cp, 0, LJ_ERR_FFI_INVTYPE); info |= CTF_BOOL; if (!(cds & CDF_SIGNED)) info |= CTF_UNSIGNED; if (!sz) { sz = 1; } } else if ((cds & CDF_FP)) { info = CTINFO(CT_NUM, CTF_FP); if ((cds & CDF_LONG)) sz = sizeof(long double); } else if ((cds & CDF_CHAR)) { if ((cds & (CDF_CHAR|CDF_SIGNED|CDF_UNSIGNED)) == CDF_CHAR) info |= CTF_UCHAR; /* Handle platforms where char is unsigned. */ } else if ((cds & CDF_SHORT)) { sz = sizeof(short); } else if ((cds & CDF_LONGLONG)) { sz = 8; } else if ((cds & CDF_LONG)) { info |= CTF_LONG; sz = sizeof(long); } else if (!sz) { if (!(cds & (CDF_SIGNED|CDF_UNSIGNED))) cp_errmsg(cp, cp->tok, LJ_ERR_FFI_DECLSPEC); sz = sizeof(int); } lua_assert(sz != 0); info += CTALIGN(lj_fls(sz)); /* Use natural alignment. */ info += (decl->attr & CTF_QUAL); /* Merge qualifiers. */ cp_push(decl, info, sz); decl->attr &= ~CTF_QUAL; } decl->specpos = decl->pos; decl->specattr = decl->attr; decl->specfattr = decl->fattr; return (cds & CDF_SCL); /* Return storage class. */ } /* Parse array declaration. */ static void cp_decl_array(CPState *cp, CPDecl *decl) { CTInfo info = CTINFO(CT_ARRAY, 0); CTSize nelem = CTSIZE_INVALID; /* Default size for a[] or a[?]. */ cp_decl_attributes(cp, decl); if (cp_opt(cp, '?')) info |= CTF_VLA; /* Create variable-length array a[?]. */ else if (cp->tok != ']') nelem = cp_expr_ksize(cp); cp_check(cp, ']'); cp_add(decl, info, nelem); } /* Parse function declaration. */ static void cp_decl_func(CPState *cp, CPDecl *fdecl) { CTSize nargs = 0; CTInfo info = CTINFO(CT_FUNC, 0); CTypeID lastid = 0, anchor = 0; if (cp->tok != ')') { do { CPDecl decl; CTypeID ctypeid, fieldid; CType *ct; if (cp_opt(cp, '.')) { /* Vararg function. */ cp_check(cp, '.'); /* Workaround for the minimalistic lexer. */ cp_check(cp, '.'); info |= CTF_VARARG; break; } cp_decl_spec(cp, &decl, CDF_REGISTER); decl.mode = CPARSE_MODE_DIRECT|CPARSE_MODE_ABSTRACT; cp_declarator(cp, &decl); ctypeid = cp_decl_intern(cp, &decl); ct = ctype_raw(cp->cts, ctypeid); if (ctype_isvoid(ct->info)) break; else if (ctype_isrefarray(ct->info)) ctypeid = lj_ctype_intern(cp->cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ct->info)), CTSIZE_PTR); else if (ctype_isfunc(ct->info)) ctypeid = lj_ctype_intern(cp->cts, CTINFO(CT_PTR, CTALIGN_PTR|ctypeid), CTSIZE_PTR); /* Add new parameter. */ fieldid = lj_ctype_new(cp->cts, &ct); if (anchor) ctype_get(cp->cts, lastid)->sib = fieldid; else anchor = fieldid; lastid = fieldid; if (decl.name) ctype_setname(ct, decl.name); ct->info = CTINFO(CT_FIELD, ctypeid); ct->size = nargs++; } while (cp_opt(cp, ',')); } cp_check(cp, ')'); if (cp_opt(cp, '{')) { /* Skip function definition. */ int level = 1; cp->mode |= CPARSE_MODE_SKIP; for (;;) { if (cp->tok == '{') level++; else if (cp->tok == '}' && --level == 0) break; else if (cp->tok == CTOK_EOF) cp_err_token(cp, '}'); cp_next(cp); } cp->mode &= ~CPARSE_MODE_SKIP; cp->tok = ';'; /* Ok for cp_decl_multi(), error in cp_decl_single(). */ } info |= (fdecl->fattr & ~CTMASK_CID); fdecl->fattr = 0; fdecl->stack[cp_add(fdecl, info, nargs)].sib = anchor; } /* Parse declarator. */ static void cp_declarator(CPState *cp, CPDecl *decl) { if (++cp->depth > CPARSE_MAX_DECLDEPTH) cp_err(cp, LJ_ERR_XLEVELS); for (;;) { /* Head of declarator. */ if (cp_opt(cp, '*')) { /* Pointer. */ CTSize sz; CTInfo info; cp_decl_attributes(cp, decl); sz = CTSIZE_PTR; info = CTINFO(CT_PTR, CTALIGN_PTR); #if LJ_64 if (ctype_msizeP(decl->attr) == 4) { sz = 4; info = CTINFO(CT_PTR, CTALIGN(2)); } #endif info += (decl->attr & (CTF_QUAL|CTF_REF)); decl->attr &= ~(CTF_QUAL|(CTMASK_MSIZEP<attr &= ~(CTF_QUAL|(CTMASK_MSIZEP<mode & CPARSE_MODE_ABSTRACT) && (cp->tok == ')' || cp_istypedecl(cp))) goto func_decl; pos = decl->pos; cp_declarator(cp, decl); cp_check(cp, ')'); decl->pos = pos; } else if (cp->tok == CTOK_IDENT) { /* Direct declarator. */ if (!(decl->mode & CPARSE_MODE_DIRECT)) cp_err_token(cp, CTOK_EOF); decl->name = cp->str; decl->nameid = cp->val.id; cp_next(cp); } else { /* Abstract declarator. */ if (!(decl->mode & CPARSE_MODE_ABSTRACT)) cp_err_token(cp, CTOK_IDENT); } for (;;) { /* Tail of declarator. */ if (cp_opt(cp, '[')) { /* Array. */ cp_decl_array(cp, decl); } else if (cp_opt(cp, '(')) { /* Function. */ func_decl: cp_decl_func(cp, decl); } else { break; } } if ((decl->mode & CPARSE_MODE_FIELD) && cp_opt(cp, ':')) /* Field width. */ decl->bits = cp_expr_ksize(cp); /* Process postfix attributes. */ cp_decl_attributes(cp, decl); cp_push_attributes(decl); cp->depth--; } /* Parse an abstract type declaration and return it's C type ID. */ static CTypeID cp_decl_abstract(CPState *cp) { CPDecl decl; cp_decl_spec(cp, &decl, 0); decl.mode = CPARSE_MODE_ABSTRACT; cp_declarator(cp, &decl); return cp_decl_intern(cp, &decl); } /* Handle pragmas. */ static void cp_pragma(CPState *cp, BCLine pragmaline) { cp_next(cp); if (cp->tok == CTOK_IDENT && cp->str->hash == H_(e79b999f,42ca3e85)) { /* pack */ cp_next(cp); cp_check(cp, '('); if (cp->tok == CTOK_IDENT) { if (cp->str->hash == H_(738e923c,a1b65954)) { /* push */ if (cp->curpack < CPARSE_MAX_PACKSTACK) { cp->packstack[cp->curpack+1] = cp->packstack[cp->curpack]; cp->curpack++; } } else if (cp->str->hash == H_(6c71cf27,6c71cf27)) { /* pop */ if (cp->curpack > 0) cp->curpack--; } else { cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); } cp_next(cp); if (!cp_opt(cp, ',')) goto end_pack; } if (cp->tok == CTOK_INTEGER) { cp->packstack[cp->curpack] = cp->val.u32 ? lj_fls(cp->val.u32) : 0; cp_next(cp); } else { cp->packstack[cp->curpack] = 255; } end_pack: cp_check(cp, ')'); } else { /* Ignore all other pragmas. */ while (cp->tok != CTOK_EOF && cp->linenumber == pragmaline) cp_next(cp); } } /* Parse multiple C declarations of types or extern identifiers. */ static void cp_decl_multi(CPState *cp) { int first = 1; while (cp->tok != CTOK_EOF) { CPDecl decl; CPscl scl; if (cp_opt(cp, ';')) { /* Skip empty statements. */ first = 0; continue; } if (cp->tok == '#') { /* Workaround, since we have no preprocessor, yet. */ BCLine pragmaline = cp->linenumber; if (!(cp_next(cp) == CTOK_IDENT && cp->str->hash == H_(f5e6b4f8,1d509107))) /* pragma */ cp_errmsg(cp, cp->tok, LJ_ERR_XSYMBOL); cp_pragma(cp, pragmaline); continue; } scl = cp_decl_spec(cp, &decl, CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC); if ((cp->tok == ';' || cp->tok == CTOK_EOF) && ctype_istypedef(decl.stack[0].info)) { CTInfo info = ctype_rawchild(cp->cts, &decl.stack[0])->info; if (ctype_isstruct(info) || ctype_isenum(info)) goto decl_end; /* Accept empty declaration of struct/union/enum. */ } for (;;) { CTypeID ctypeid; cp_declarator(cp, &decl); ctypeid = cp_decl_intern(cp, &decl); if (decl.name && !decl.nameid) { /* NYI: redeclarations are ignored. */ CType *ct; CTypeID id; if ((scl & CDF_TYPEDEF)) { /* Create new typedef. */ id = lj_ctype_new(cp->cts, &ct); ct->info = CTINFO(CT_TYPEDEF, ctypeid); goto noredir; } else if (ctype_isfunc(ctype_get(cp->cts, ctypeid)->info)) { /* Treat both static and extern function declarations as extern. */ ct = ctype_get(cp->cts, ctypeid); /* We always get new anonymous functions (typedefs are copied). */ lua_assert(gcref(ct->name) == NULL); id = ctypeid; /* Just name it. */ } else if ((scl & CDF_STATIC)) { /* Accept static constants. */ id = cp_decl_constinit(cp, &ct, ctypeid); goto noredir; } else { /* External references have extern or no storage class. */ id = lj_ctype_new(cp->cts, &ct); ct->info = CTINFO(CT_EXTERN, ctypeid); } if (decl.redir) { /* Add attribute for redirected symbol name. */ CType *cta; CTypeID aid = lj_ctype_new(cp->cts, &cta); ct = ctype_get(cp->cts, id); /* Table may have been reallocated. */ cta->info = CTINFO(CT_ATTRIB, CTATTRIB(CTA_REDIR)); cta->sib = ct->sib; ct->sib = aid; ctype_setname(cta, decl.redir); } noredir: ctype_setname(ct, decl.name); lj_ctype_addname(cp->cts, ct, id); } if (!cp_opt(cp, ',')) break; cp_decl_reset(&decl); } decl_end: if (cp->tok == CTOK_EOF && first) break; /* May omit ';' for 1 decl. */ first = 0; cp_check(cp, ';'); } } /* Parse a single C type declaration. */ static void cp_decl_single(CPState *cp) { CPDecl decl; cp_decl_spec(cp, &decl, 0); cp_declarator(cp, &decl); cp->val.id = cp_decl_intern(cp, &decl); if (cp->tok != CTOK_EOF) cp_err_token(cp, CTOK_EOF); } #undef H_ /* ------------------------------------------------------------------------ */ /* Protected callback for C parser. */ static TValue *cpcparser(lua_State *L, lua_CFunction dummy, void *ud) { CPState *cp = (CPState *)ud; UNUSED(dummy); cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ cp_init(cp); if ((cp->mode & CPARSE_MODE_MULTI)) cp_decl_multi(cp); else cp_decl_single(cp); if (cp->param && cp->param != cp->L->top) cp_err(cp, LJ_ERR_FFI_NUMPARAM); lua_assert(cp->depth == 0); return NULL; } /* C parser. */ int lj_cparse(CPState *cp) { LJ_CTYPE_SAVE(cp->cts); int errcode = lj_vm_cpcall(cp->L, NULL, cp, cpcparser); if (errcode) LJ_CTYPE_RESTORE(cp->cts); cp_cleanup(cp); return errcode; } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_cparse.h ================================================ /* ** C declaration parser. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CPARSE_H #define _LJ_CPARSE_H #include "lj_obj.h" #include "lj_ctype.h" #if LJ_HASFFI /* C parser limits. */ #define CPARSE_MAX_BUF 32768 /* Max. token buffer size. */ #define CPARSE_MAX_DECLSTACK 100 /* Max. declaration stack depth. */ #define CPARSE_MAX_DECLDEPTH 20 /* Max. recursive declaration depth. */ #define CPARSE_MAX_PACKSTACK 7 /* Max. pack pragma stack depth. */ /* Flags for C parser mode. */ #define CPARSE_MODE_MULTI 1 /* Process multiple declarations. */ #define CPARSE_MODE_ABSTRACT 2 /* Accept abstract declarators. */ #define CPARSE_MODE_DIRECT 4 /* Accept direct declarators. */ #define CPARSE_MODE_FIELD 8 /* Accept field width in bits, too. */ #define CPARSE_MODE_NOIMPLICIT 16 /* Reject implicit declarations. */ #define CPARSE_MODE_SKIP 32 /* Skip definitions, ignore errors. */ typedef int CPChar; /* C parser character. Unsigned ext. from char. */ typedef int CPToken; /* C parser token. */ /* C parser internal value representation. */ typedef struct CPValue { union { int32_t i32; /* Value for CTID_INT32. */ uint32_t u32; /* Value for CTID_UINT32. */ }; CTypeID id; /* C Type ID of the value. */ } CPValue; /* C parser state. */ typedef struct CPState { CPChar c; /* Current character. */ CPToken tok; /* Current token. */ CPValue val; /* Token value. */ GCstr *str; /* Interned string of identifier/keyword. */ CType *ct; /* C type table entry. */ const char *p; /* Current position in input buffer. */ SBuf sb; /* String buffer for tokens. */ lua_State *L; /* Lua state. */ CTState *cts; /* C type state. */ TValue *param; /* C type parameters. */ const char *srcname; /* Current source name. */ BCLine linenumber; /* Input line counter. */ int depth; /* Recursive declaration depth. */ uint32_t tmask; /* Type mask for next identifier. */ uint32_t mode; /* C parser mode. */ uint8_t packstack[CPARSE_MAX_PACKSTACK]; /* Stack for pack pragmas. */ uint8_t curpack; /* Current position in pack pragma stack. */ } CPState; LJ_FUNC int lj_cparse(CPState *cp); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_crecord.c ================================================ /* ** Trace recorder for C data operations. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_ffrecord_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT && LJ_HASFFI #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_frame.h" #include "lj_ctype.h" #include "lj_cdata.h" #include "lj_cparse.h" #include "lj_cconv.h" #include "lj_clib.h" #include "lj_ccall.h" #include "lj_ff.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_ircall.h" #include "lj_iropt.h" #include "lj_trace.h" #include "lj_record.h" #include "lj_ffrecord.h" #include "lj_snap.h" #include "lj_crecord.h" #include "lj_dispatch.h" /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) /* Pass IR on to next optimization in chain (FOLD). */ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) #define emitconv(a, dt, st, flags) \ emitir(IRT(IR_CONV, (dt)), (a), (st)|((dt) << 5)|(flags)) /* -- C type checks ------------------------------------------------------- */ static GCcdata *argv2cdata(jit_State *J, TRef tr, cTValue *o) { GCcdata *cd; TRef trtypeid; if (!tref_iscdata(tr)) lj_trace_err(J, LJ_TRERR_BADTYPE); cd = cdataV(o); /* Specialize to the CTypeID. */ trtypeid = emitir(IRT(IR_FLOAD, IRT_U16), tr, IRFL_CDATA_CTYPEID); emitir(IRTG(IR_EQ, IRT_INT), trtypeid, lj_ir_kint(J, (int32_t)cd->ctypeid)); return cd; } /* Specialize to the CTypeID held by a cdata constructor. */ static CTypeID crec_constructor(jit_State *J, GCcdata *cd, TRef tr) { CTypeID id; lua_assert(tref_iscdata(tr) && cd->ctypeid == CTID_CTYPEID); id = *(CTypeID *)cdataptr(cd); tr = emitir(IRT(IR_FLOAD, IRT_INT), tr, IRFL_CDATA_INT); emitir(IRTG(IR_EQ, IRT_INT), tr, lj_ir_kint(J, (int32_t)id)); return id; } static CTypeID argv2ctype(jit_State *J, TRef tr, cTValue *o) { if (tref_isstr(tr)) { GCstr *s = strV(o); CPState cp; CTypeID oldtop; /* Specialize to the string containing the C type declaration. */ emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, s)); cp.L = J->L; cp.cts = ctype_ctsG(J2G(J)); oldtop = cp.cts->top; cp.srcname = strdata(s); cp.p = strdata(s); cp.param = NULL; cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT; if (lj_cparse(&cp) || cp.cts->top > oldtop) /* Avoid new struct defs. */ lj_trace_err(J, LJ_TRERR_BADTYPE); return cp.val.id; } else { GCcdata *cd = argv2cdata(J, tr, o); return cd->ctypeid == CTID_CTYPEID ? crec_constructor(J, cd, tr) : cd->ctypeid; } } /* Convert CType to IRType (if possible). */ static IRType crec_ct2irt(CTState *cts, CType *ct) { if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); if (LJ_LIKELY(ctype_isnum(ct->info))) { if ((ct->info & CTF_FP)) { if (ct->size == sizeof(double)) return IRT_NUM; else if (ct->size == sizeof(float)) return IRT_FLOAT; } else { uint32_t b = lj_fls(ct->size); if (b <= 3) return IRT_I8 + 2*b + ((ct->info & CTF_UNSIGNED) ? 1 : 0); } } else if (ctype_isptr(ct->info)) { return (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; } else if (ctype_iscomplex(ct->info)) { if (ct->size == 2*sizeof(double)) return IRT_NUM; else if (ct->size == 2*sizeof(float)) return IRT_FLOAT; } return IRT_CDATA; } /* -- Optimized memory fill and copy -------------------------------------- */ /* Maximum length and unroll of inlined copy/fill. */ #define CREC_COPY_MAXUNROLL 16 #define CREC_COPY_MAXLEN 128 #define CREC_FILL_MAXUNROLL 16 #if LJ_TARGET_UNALIGNED #define CREC_FILL_MAXLEN (CTSIZE_PTR * CREC_FILL_MAXUNROLL) #else #define CREC_FILL_MAXLEN CREC_FILL_MAXUNROLL #endif /* Number of windowed registers used for optimized memory copy. */ #if LJ_TARGET_X86 #define CREC_COPY_REGWIN 2 #elif LJ_TARGET_PPC || LJ_TARGET_MIPS #define CREC_COPY_REGWIN 8 #else #define CREC_COPY_REGWIN 4 #endif /* List of memory offsets for copy/fill. */ typedef struct CRecMemList { CTSize ofs; /* Offset in bytes. */ IRType tp; /* Type of load/store. */ TRef trofs; /* TRef of interned offset. */ TRef trval; /* TRef of load value. */ } CRecMemList; /* Generate copy list for element-wise struct copy. */ static MSize crec_copy_struct(CRecMemList *ml, CTState *cts, CType *ct) { CTypeID fid = ct->sib; MSize mlp = 0; while (fid) { CType *df = ctype_get(cts, fid); fid = df->sib; if (ctype_isfield(df->info)) { CType *cct; IRType tp; if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ cct = ctype_rawchild(cts, df); /* Field type. */ tp = crec_ct2irt(cts, cct); if (tp == IRT_CDATA) return 0; /* NYI: aggregates. */ if (mlp >= CREC_COPY_MAXUNROLL) return 0; ml[mlp].ofs = df->size; ml[mlp].tp = tp; mlp++; if (ctype_iscomplex(cct->info)) { if (mlp >= CREC_COPY_MAXUNROLL) return 0; ml[mlp].ofs = df->size + (cct->size >> 1); ml[mlp].tp = tp; mlp++; } } else if (!ctype_isconstval(df->info)) { /* NYI: bitfields and sub-structures. */ return 0; } } return mlp; } /* Generate unrolled copy list, from highest to lowest step size/alignment. */ static MSize crec_copy_unroll(CRecMemList *ml, CTSize len, CTSize step, IRType tp) { CTSize ofs = 0; MSize mlp = 0; if (tp == IRT_CDATA) tp = IRT_U8 + 2*lj_fls(step); do { while (ofs + step <= len) { if (mlp >= CREC_COPY_MAXUNROLL) return 0; ml[mlp].ofs = ofs; ml[mlp].tp = tp; mlp++; ofs += step; } step >>= 1; tp -= 2; } while (ofs < len); return mlp; } /* ** Emit copy list with windowed loads/stores. ** LJ_TARGET_UNALIGNED: may emit unaligned loads/stores (not marked as such). */ static void crec_copy_emit(jit_State *J, CRecMemList *ml, MSize mlp, TRef trdst, TRef trsrc) { MSize i, j, rwin = 0; for (i = 0, j = 0; i < mlp; ) { TRef trofs = lj_ir_kintp(J, ml[i].ofs); TRef trsptr = emitir(IRT(IR_ADD, IRT_PTR), trsrc, trofs); ml[i].trval = emitir(IRT(IR_XLOAD, ml[i].tp), trsptr, 0); ml[i].trofs = trofs; i++; rwin += (LJ_SOFTFP && ml[i].tp == IRT_NUM) ? 2 : 1; if (rwin >= CREC_COPY_REGWIN || i >= mlp) { /* Flush buffered stores. */ rwin = 0; for ( ; j < i; j++) { TRef trdptr = emitir(IRT(IR_ADD, IRT_PTR), trdst, ml[j].trofs); emitir(IRT(IR_XSTORE, ml[j].tp), trdptr, ml[j].trval); } } } } /* Optimized memory copy. */ static void crec_copy(jit_State *J, TRef trdst, TRef trsrc, TRef trlen, CType *ct) { if (tref_isk(trlen)) { /* Length must be constant. */ CRecMemList ml[CREC_COPY_MAXUNROLL]; MSize mlp = 0; CTSize step = 1, len = (CTSize)IR(tref_ref(trlen))->i; IRType tp = IRT_CDATA; int needxbar = 0; if (len == 0) return; /* Shortcut. */ if (len > CREC_COPY_MAXLEN) goto fallback; if (ct) { CTState *cts = ctype_ctsG(J2G(J)); lua_assert(ctype_isarray(ct->info) || ctype_isstruct(ct->info)); if (ctype_isarray(ct->info)) { CType *cct = ctype_rawchild(cts, ct); tp = crec_ct2irt(cts, cct); if (tp == IRT_CDATA) goto rawcopy; step = lj_ir_type_size[tp]; lua_assert((len & (step-1)) == 0); } else if ((ct->info & CTF_UNION)) { step = (1u << ctype_align(ct->info)); goto rawcopy; } else { mlp = crec_copy_struct(ml, cts, ct); goto emitcopy; } } else { rawcopy: needxbar = 1; if (LJ_TARGET_UNALIGNED || step >= CTSIZE_PTR) step = CTSIZE_PTR; } mlp = crec_copy_unroll(ml, len, step, tp); emitcopy: if (mlp) { crec_copy_emit(J, ml, mlp, trdst, trsrc); if (needxbar) emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); return; } } fallback: /* Call memcpy. Always needs a barrier to disable alias analysis. */ lj_ir_call(J, IRCALL_memcpy, trdst, trsrc, trlen); emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); } /* Generate unrolled fill list, from highest to lowest step size/alignment. */ static MSize crec_fill_unroll(CRecMemList *ml, CTSize len, CTSize step) { CTSize ofs = 0; MSize mlp = 0; IRType tp = IRT_U8 + 2*lj_fls(step); do { while (ofs + step <= len) { if (mlp >= CREC_COPY_MAXUNROLL) return 0; ml[mlp].ofs = ofs; ml[mlp].tp = tp; mlp++; ofs += step; } step >>= 1; tp -= 2; } while (ofs < len); return mlp; } /* ** Emit stores for fill list. ** LJ_TARGET_UNALIGNED: may emit unaligned stores (not marked as such). */ static void crec_fill_emit(jit_State *J, CRecMemList *ml, MSize mlp, TRef trdst, TRef trfill) { MSize i; for (i = 0; i < mlp; i++) { TRef trofs = lj_ir_kintp(J, ml[i].ofs); TRef trdptr = emitir(IRT(IR_ADD, IRT_PTR), trdst, trofs); emitir(IRT(IR_XSTORE, ml[i].tp), trdptr, trfill); } } /* Optimized memory fill. */ static void crec_fill(jit_State *J, TRef trdst, TRef trlen, TRef trfill, CTSize step) { if (tref_isk(trlen)) { /* Length must be constant. */ CRecMemList ml[CREC_FILL_MAXUNROLL]; MSize mlp; CTSize len = (CTSize)IR(tref_ref(trlen))->i; if (len == 0) return; /* Shortcut. */ if (len > CREC_FILL_MAXLEN) goto fallback; if (LJ_TARGET_UNALIGNED || step >= CTSIZE_PTR) step = CTSIZE_PTR; mlp = crec_fill_unroll(ml, len, step); if (!mlp) goto fallback; if (tref_isk(trfill) || ml[0].tp != IRT_U8) trfill = emitconv(trfill, IRT_INT, IRT_U8, 0); if (ml[0].tp != IRT_U8) { /* Scatter U8 to U16/U32/U64. */ if (CTSIZE_PTR == 8 && ml[0].tp == IRT_U64) { if (tref_isk(trfill)) /* Pointless on x64 with zero-extended regs. */ trfill = emitconv(trfill, IRT_U64, IRT_U32, 0); trfill = emitir(IRT(IR_MUL, IRT_U64), trfill, lj_ir_kint64(J, U64x(01010101,01010101))); } else { trfill = emitir(IRTI(IR_MUL), trfill, lj_ir_kint(J, ml[0].tp == IRT_U16 ? 0x0101 : 0x01010101)); } } crec_fill_emit(J, ml, mlp, trdst, trfill); } else { fallback: /* Call memset. Always needs a barrier to disable alias analysis. */ lj_ir_call(J, IRCALL_memset, trdst, trfill, trlen); /* Note: arg order! */ } emitir(IRT(IR_XBAR, IRT_NIL), 0, 0); } /* -- Convert C type to C type -------------------------------------------- */ /* ** This code mirrors the code in lj_cconv.c. It performs the same steps ** for the trace recorder that lj_cconv.c does for the interpreter. ** ** One major difference is that we can get away with much fewer checks ** here. E.g. checks for casts, constness or correct types can often be ** omitted, even if they might fail. The interpreter subsequently throws ** an error, which aborts the trace. ** ** All operations are specialized to their C types, so the on-trace ** outcome must be the same as the outcome in the interpreter. If the ** interpreter doesn't throw an error, then the trace is correct, too. ** Care must be taken not to generate invalid (temporary) IR or to ** trigger asserts. */ /* Determine whether a passed number or cdata number is non-zero. */ static int crec_isnonzero(CType *s, void *p) { if (p == (void *)0) return 0; if (p == (void *)1) return 1; if ((s->info & CTF_FP)) { if (s->size == sizeof(float)) return (*(float *)p != 0); else return (*(double *)p != 0); } else { if (s->size == 1) return (*(uint8_t *)p != 0); else if (s->size == 2) return (*(uint16_t *)p != 0); else if (s->size == 4) return (*(uint32_t *)p != 0); else return (*(uint64_t *)p != 0); } } static TRef crec_ct_ct(jit_State *J, CType *d, CType *s, TRef dp, TRef sp, void *svisnz) { IRType dt = crec_ct2irt(ctype_ctsG(J2G(J)), d); IRType st = crec_ct2irt(ctype_ctsG(J2G(J)), s); CTSize dsize = d->size, ssize = s->size; CTInfo dinfo = d->info, sinfo = s->info; if (ctype_type(dinfo) > CT_MAYCONVERT || ctype_type(sinfo) > CT_MAYCONVERT) goto err_conv; /* ** Note: Unlike lj_cconv_ct_ct(), sp holds the _value_ of pointers and ** numbers up to 8 bytes. Otherwise sp holds a pointer. */ switch (cconv_idx2(dinfo, sinfo)) { /* Destination is a bool. */ case CCX(B, B): goto xstore; /* Source operand is already normalized. */ case CCX(B, I): case CCX(B, F): if (st != IRT_CDATA) { /* Specialize to the result of a comparison against 0. */ TRef zero = (st == IRT_NUM || st == IRT_FLOAT) ? lj_ir_knum(J, 0) : (st == IRT_I64 || st == IRT_U64) ? lj_ir_kint64(J, 0) : lj_ir_kint(J, 0); int isnz = crec_isnonzero(s, svisnz); emitir(IRTG(isnz ? IR_NE : IR_EQ, st), sp, zero); sp = lj_ir_kint(J, isnz); goto xstore; } goto err_nyi; /* Destination is an integer. */ case CCX(I, B): case CCX(I, I): conv_I_I: if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; /* Extend 32 to 64 bit integer. */ if (dsize == 8 && ssize < 8 && !(LJ_64 && (sinfo & CTF_UNSIGNED))) sp = emitconv(sp, dt, ssize < 4 ? IRT_INT : st, (sinfo & CTF_UNSIGNED) ? 0 : IRCONV_SEXT); else if (dsize < 8 && ssize == 8) /* Truncate from 64 bit integer. */ sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, 0); else if (st == IRT_INT) sp = lj_opt_narrow_toint(J, sp); xstore: if (dt == IRT_I64 || dt == IRT_U64) lj_needsplit(J); if (dp == 0) return sp; emitir(IRT(IR_XSTORE, dt), dp, sp); break; case CCX(I, C): sp = emitir(IRT(IR_XLOAD, st), sp, 0); /* Load re. */ /* fallthrough */ case CCX(I, F): if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; sp = emitconv(sp, dsize < 4 ? IRT_INT : dt, st, IRCONV_TRUNC|IRCONV_ANY); goto xstore; case CCX(I, P): case CCX(I, A): sinfo = CTINFO(CT_NUM, CTF_UNSIGNED); ssize = CTSIZE_PTR; st = IRT_UINTP; goto conv_I_I; /* Destination is a floating-point number. */ case CCX(F, B): case CCX(F, I): conv_F_I: if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; sp = emitconv(sp, dt, ssize < 4 ? IRT_INT : st, 0); goto xstore; case CCX(F, C): sp = emitir(IRT(IR_XLOAD, st), sp, 0); /* Load re. */ /* fallthrough */ case CCX(F, F): conv_F_F: if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; if (dt != st) sp = emitconv(sp, dt, st, 0); goto xstore; /* Destination is a complex number. */ case CCX(C, I): case CCX(C, F): { /* Clear im. */ TRef ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, (dsize >> 1))); emitir(IRT(IR_XSTORE, dt), ptr, lj_ir_knum(J, 0)); } /* Convert to re. */ if ((sinfo & CTF_FP)) goto conv_F_F; else goto conv_F_I; case CCX(C, C): if (dt == IRT_CDATA || st == IRT_CDATA) goto err_nyi; { TRef re, im, ptr; re = emitir(IRT(IR_XLOAD, st), sp, 0); ptr = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, (ssize >> 1))); im = emitir(IRT(IR_XLOAD, st), ptr, 0); if (dt != st) { re = emitconv(re, dt, st, 0); im = emitconv(im, dt, st, 0); } emitir(IRT(IR_XSTORE, dt), dp, re); ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, (dsize >> 1))); emitir(IRT(IR_XSTORE, dt), ptr, im); } break; /* Destination is a vector. */ case CCX(V, I): case CCX(V, F): case CCX(V, C): case CCX(V, V): goto err_nyi; /* Destination is a pointer. */ case CCX(P, P): case CCX(P, A): case CCX(P, S): /* There are only 32 bit pointers/addresses on 32 bit machines. ** Also ok on x64, since all 32 bit ops clear the upper part of the reg. */ goto xstore; case CCX(P, I): if (st == IRT_CDATA) goto err_nyi; if (!LJ_64 && ssize == 8) /* Truncate from 64 bit integer. */ sp = emitconv(sp, IRT_U32, st, 0); goto xstore; case CCX(P, F): if (st == IRT_CDATA) goto err_nyi; /* The signed conversion is cheaper. x64 really has 47 bit pointers. */ sp = emitconv(sp, (LJ_64 && dsize == 8) ? IRT_I64 : IRT_U32, st, IRCONV_TRUNC|IRCONV_ANY); goto xstore; /* Destination is an array. */ case CCX(A, A): /* Destination is a struct/union. */ case CCX(S, S): if (dp == 0) goto err_conv; crec_copy(J, dp, sp, lj_ir_kint(J, dsize), d); break; default: err_conv: err_nyi: lj_trace_err(J, LJ_TRERR_NYICONV); break; } return 0; } /* -- Convert C type to TValue (load) ------------------------------------- */ static TRef crec_tv_ct(jit_State *J, CType *s, CTypeID sid, TRef sp) { CTState *cts = ctype_ctsG(J2G(J)); IRType t = crec_ct2irt(cts, s); CTInfo sinfo = s->info; if (ctype_isnum(sinfo)) { TRef tr; if (t == IRT_CDATA) goto err_nyi; /* NYI: copyval of >64 bit integers. */ tr = emitir(IRT(IR_XLOAD, t), sp, 0); if (t == IRT_FLOAT || t == IRT_U32) { /* Keep uint32_t/float as numbers. */ return emitconv(tr, IRT_NUM, t, 0); } else if (t == IRT_I64 || t == IRT_U64) { /* Box 64 bit integer. */ sp = tr; lj_needsplit(J); } else if ((sinfo & CTF_BOOL)) { /* Assume not equal to zero. Fixup and emit pending guard later. */ lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0)); J->postproc = LJ_POST_FIXGUARD; return TREF_TRUE; } else { return tr; } } else if (ctype_isptr(sinfo) || ctype_isenum(sinfo)) { sp = emitir(IRT(IR_XLOAD, t), sp, 0); /* Box pointers and enums. */ } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { cts->L = J->L; sid = lj_ctype_intern(cts, CTINFO_REF(sid), CTSIZE_PTR); /* Create ref. */ } else if (ctype_iscomplex(sinfo)) { /* Unbox/box complex. */ ptrdiff_t esz = (ptrdiff_t)(s->size >> 1); TRef ptr, tr1, tr2, dp; dp = emitir(IRTG(IR_CNEW, IRT_CDATA), lj_ir_kint(J, sid), TREF_NIL); tr1 = emitir(IRT(IR_XLOAD, t), sp, 0); ptr = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, esz)); tr2 = emitir(IRT(IR_XLOAD, t), ptr, 0); ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, sizeof(GCcdata))); emitir(IRT(IR_XSTORE, t), ptr, tr1); ptr = emitir(IRT(IR_ADD, IRT_PTR), dp, lj_ir_kintp(J, sizeof(GCcdata)+esz)); emitir(IRT(IR_XSTORE, t), ptr, tr2); return dp; } else { /* NYI: copyval of vectors. */ err_nyi: lj_trace_err(J, LJ_TRERR_NYICONV); } /* Box pointer, ref, enum or 64 bit integer. */ return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, sid), sp); } /* -- Convert TValue to C type (store) ------------------------------------ */ static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval) { CTState *cts = ctype_ctsG(J2G(J)); CTypeID sid = CTID_P_VOID; void *svisnz = 0; CType *s; if (LJ_LIKELY(tref_isinteger(sp))) { sid = CTID_INT32; svisnz = (void *)(intptr_t)(tvisint(sval)?(intV(sval)!=0):!tviszero(sval)); } else if (tref_isnum(sp)) { sid = CTID_DOUBLE; svisnz = (void *)(intptr_t)(tvisint(sval)?(intV(sval)!=0):!tviszero(sval)); } else if (tref_isbool(sp)) { sp = lj_ir_kint(J, tref_istrue(sp) ? 1 : 0); sid = CTID_BOOL; } else if (tref_isnil(sp)) { sp = lj_ir_kptr(J, NULL); } else if (tref_isudata(sp)) { GCudata *ud = udataV(sval); if (ud->udtype == UDTYPE_IO_FILE) { TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), sp, IRFL_UDATA_UDTYPE); emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); sp = emitir(IRT(IR_FLOAD, IRT_PTR), sp, IRFL_UDATA_FILE); } else { sp = emitir(IRT(IR_ADD, IRT_P32), sp, lj_ir_kint(J, sizeof(GCudata))); } } else if (tref_isstr(sp)) { if (ctype_isenum(d->info)) { /* Match string against enum constant. */ GCstr *str = strV(sval); CTSize ofs; CType *cct = lj_ctype_getfield(cts, d, str, &ofs); /* Specialize to the name of the enum constant. */ emitir(IRTG(IR_EQ, IRT_STR), sp, lj_ir_kstr(J, str)); if (cct && ctype_isconstval(cct->info)) { lua_assert(ctype_child(cts, cct)->size == 4); svisnz = (void *)(intptr_t)(ofs != 0); sp = lj_ir_kint(J, (int32_t)ofs); sid = ctype_cid(cct->info); } /* else: interpreter will throw. */ } else if (ctype_isrefarray(d->info)) { /* Copy string to array. */ lj_trace_err(J, LJ_TRERR_BADTYPE); /* NYI */ } else { /* Otherwise pass the string data as a const char[]. */ sp = emitir(IRT(IR_STRREF, IRT_P32), sp, lj_ir_kint(J, 0)); sid = CTID_A_CCHAR; } } else { /* NYI: tref_istab(sp), tref_islightud(sp). */ IRType t; sid = argv2cdata(J, sp, sval)->ctypeid; s = ctype_raw(cts, sid); svisnz = cdataptr(cdataV(sval)); t = crec_ct2irt(cts, s); if (ctype_isptr(s->info)) { sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_PTR); if (ctype_isref(s->info)) { svisnz = *(void **)svisnz; s = ctype_rawchild(cts, s); if (ctype_isenum(s->info)) s = ctype_child(cts, s); t = crec_ct2irt(cts, s); } else { goto doconv; } } else if (t == IRT_I64 || t == IRT_U64) { sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT64); lj_needsplit(J); goto doconv; } else if (t == IRT_INT || t == IRT_U32) { if (ctype_isenum(s->info)) s = ctype_child(cts, s); sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT); goto doconv; } else { sp = emitir(IRT(IR_ADD, IRT_PTR), sp, lj_ir_kintp(J, sizeof(GCcdata))); } if (ctype_isnum(s->info) && t != IRT_CDATA) sp = emitir(IRT(IR_XLOAD, t), sp, 0); /* Load number value. */ goto doconv; } s = ctype_get(cts, sid); doconv: if (ctype_isenum(d->info)) d = ctype_child(cts, d); return crec_ct_ct(J, d, s, dp, sp, svisnz); } /* -- C data metamethods -------------------------------------------------- */ /* This would be rather difficult in FOLD, so do it here: ** (base+k)+(idx*sz)+ofs ==> (base+idx*sz)+(ofs+k) ** (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz) */ static TRef crec_reassoc_ofs(jit_State *J, TRef tr, ptrdiff_t *ofsp, MSize sz) { IRIns *ir = IR(tref_ref(tr)); if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && irref_isk(ir->op2) && (ir->o == IR_ADD || ir->o == IR_ADDOV || ir->o == IR_SUBOV)) { IRIns *irk = IR(ir->op2); ptrdiff_t k; if (LJ_64 && irk->o == IR_KINT64) k = (ptrdiff_t)ir_kint64(irk)->u64 * sz; else k = (ptrdiff_t)irk->i * sz; if (ir->o == IR_SUBOV) *ofsp -= k; else *ofsp += k; tr = ir->op1; /* Not a TRef, but the caller doesn't care. */ } return tr; } /* Record ctype __index/__newindex metamethods. */ static void crec_index_meta(jit_State *J, CTState *cts, CType *ct, RecordFFData *rd) { CTypeID id = ctype_typeid(cts, ct); cTValue *tv = lj_ctype_meta(cts, id, rd->data ? MM_newindex : MM_index); if (!tv) lj_trace_err(J, LJ_TRERR_BADTYPE); if (tvisfunc(tv)) { J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; rd->nres = -1; /* Pending tailcall. */ } else if (rd->data == 0 && tvistab(tv) && tref_isstr(J->base[1])) { /* Specialize to result of __index lookup. */ cTValue *o = lj_tab_get(J->L, tabV(tv), &rd->argv[1]); J->base[0] = lj_record_constify(J, o); if (!J->base[0]) lj_trace_err(J, LJ_TRERR_BADTYPE); /* Always specialize to the key. */ emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); } else { /* NYI: resolving of non-function metamethods. */ /* NYI: non-string keys for __index table. */ /* NYI: stores to __newindex table. */ lj_trace_err(J, LJ_TRERR_BADTYPE); } } void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd) { TRef idx, ptr = J->base[0]; ptrdiff_t ofs = sizeof(GCcdata); GCcdata *cd = argv2cdata(J, ptr, &rd->argv[0]); CTState *cts = ctype_ctsG(J2G(J)); CType *ct = ctype_raw(cts, cd->ctypeid); CTypeID sid = 0; /* Resolve pointer or reference for cdata object. */ if (ctype_isptr(ct->info)) { IRType t = (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); ptr = emitir(IRT(IR_FLOAD, t), ptr, IRFL_CDATA_PTR); ofs = 0; ptr = crec_reassoc_ofs(J, ptr, &ofs, 1); } again: idx = J->base[1]; if (tref_isnumber(idx)) { idx = lj_opt_narrow_cindex(J, idx); if (ctype_ispointer(ct->info)) { CTSize sz; integer_key: if ((ct->info & CTF_COMPLEX)) idx = emitir(IRT(IR_BAND, IRT_INTP), idx, lj_ir_kintp(J, 1)); sz = lj_ctype_size(cts, (sid = ctype_cid(ct->info))); idx = crec_reassoc_ofs(J, idx, &ofs, sz); #if LJ_TARGET_ARM || LJ_TARGET_PPC /* Hoist base add to allow fusion of index/shift into operands. */ if (LJ_LIKELY(J->flags & JIT_F_OPT_LOOP) && ofs #if LJ_TARGET_ARM && (sz == 1 || sz == 4) #endif ) { ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs)); ofs = 0; } #endif idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); } } else if (tref_iscdata(idx)) { GCcdata *cdk = cdataV(&rd->argv[1]); CType *ctk = ctype_raw(cts, cdk->ctypeid); IRType t = crec_ct2irt(cts, ctk); if (ctype_ispointer(ct->info) && t >= IRT_I8 && t <= IRT_U64) { if (ctk->size == 8) { idx = emitir(IRT(IR_FLOAD, t), idx, IRFL_CDATA_INT64); } else if (ctk->size == 4) { idx = emitir(IRT(IR_FLOAD, t), idx, IRFL_CDATA_INT); } else { idx = emitir(IRT(IR_ADD, IRT_PTR), idx, lj_ir_kintp(J, sizeof(GCcdata))); idx = emitir(IRT(IR_XLOAD, t), idx, 0); } if (LJ_64 && ctk->size < sizeof(intptr_t) && !(ctk->info & CTF_UNSIGNED)) idx = emitconv(idx, IRT_INTP, IRT_INT, IRCONV_SEXT); if (!LJ_64 && ctk->size > sizeof(intptr_t)) { idx = emitconv(idx, IRT_INTP, t, 0); lj_needsplit(J); } goto integer_key; } } else if (tref_isstr(idx)) { GCstr *name = strV(&rd->argv[1]); if (cd->ctypeid == CTID_CTYPEID) ct = ctype_raw(cts, crec_constructor(J, cd, ptr)); if (ctype_isstruct(ct->info)) { CTSize fofs; CType *fct; fct = lj_ctype_getfield(cts, ct, name, &fofs); if (fct) { /* Always specialize to the field name. */ emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name)); if (ctype_isconstval(fct->info)) { if (fct->size >= 0x80000000u && (ctype_child(cts, fct)->info & CTF_UNSIGNED)) { J->base[0] = lj_ir_knum(J, (lua_Number)(uint32_t)fct->size); return; } J->base[0] = lj_ir_kint(J, (int32_t)fct->size); return; /* Interpreter will throw for newindex. */ } else if (ctype_isbitfield(fct->info)) { lj_trace_err(J, LJ_TRERR_NYICONV); } else { lua_assert(ctype_isfield(fct->info)); sid = ctype_cid(fct->info); } ofs += (ptrdiff_t)fofs; } } else if (ctype_iscomplex(ct->info)) { if (name->len == 2 && ((strdata(name)[0] == 'r' && strdata(name)[1] == 'e') || (strdata(name)[0] == 'i' && strdata(name)[1] == 'm'))) { /* Always specialize to the field name. */ emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name)); if (strdata(name)[0] == 'i') ofs += (ct->size >> 1); sid = ctype_cid(ct->info); } } } if (!sid) { if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ CType *cct = ctype_rawchild(cts, ct); if (ctype_isstruct(cct->info)) { ct = cct; if (tref_isstr(idx)) goto again; } } crec_index_meta(J, cts, ct, rd); return; } if (ofs) ptr = emitir(IRT(IR_ADD, IRT_PTR), ptr, lj_ir_kintp(J, ofs)); /* Resolve reference for field. */ ct = ctype_get(cts, sid); if (ctype_isref(ct->info)) ptr = emitir(IRT(IR_XLOAD, IRT_PTR), ptr, 0); while (ctype_isattrib(ct->info)) ct = ctype_child(cts, ct); /* Skip attributes. */ if (rd->data == 0) { /* __index metamethod. */ J->base[0] = crec_tv_ct(J, ct, sid, ptr); } else { /* __newindex metamethod. */ rd->nres = 0; J->needsnap = 1; crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]); } } /* Record setting a finalizer. */ static void crec_finalizer(jit_State *J, TRef trcd, cTValue *fin) { TRef trlo = lj_ir_call(J, IRCALL_lj_cdata_setfin, trcd); TRef trhi = emitir(IRT(IR_ADD, IRT_P32), trlo, lj_ir_kint(J, 4)); if (LJ_BE) { TRef tmp = trlo; trlo = trhi; trhi = tmp; } if (tvisfunc(fin)) { emitir(IRT(IR_XSTORE, IRT_P32), trlo, lj_ir_kfunc(J, funcV(fin))); emitir(IRTI(IR_XSTORE), trhi, lj_ir_kint(J, LJ_TFUNC)); } else if (tviscdata(fin)) { emitir(IRT(IR_XSTORE, IRT_P32), trlo, lj_ir_kgc(J, obj2gco(cdataV(fin)), IRT_CDATA)); emitir(IRTI(IR_XSTORE), trhi, lj_ir_kint(J, LJ_TCDATA)); } else { lj_trace_err(J, LJ_TRERR_BADTYPE); } J->needsnap = 1; } /* Record cdata allocation. */ static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id) { CTState *cts = ctype_ctsG(J2G(J)); CTSize sz; CTInfo info = lj_ctype_info(cts, id, &sz); CType *d = ctype_raw(cts, id); TRef trid; if (!sz || sz > 128 || (info & CTF_VLA) || ctype_align(info) > CT_MEMALIGN) lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: large/special allocations. */ trid = lj_ir_kint(J, id); /* Use special instruction to box pointer or 32/64 bit integer. */ if (ctype_isptr(info) || (ctype_isinteger(info) && (sz == 4 || sz == 8))) { TRef sp = J->base[1] ? crec_ct_tv(J, d, 0, J->base[1], &rd->argv[1]) : ctype_isptr(info) ? lj_ir_kptr(J, NULL) : sz == 4 ? lj_ir_kint(J, 0) : (lj_needsplit(J), lj_ir_kint64(J, 0)); J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), trid, sp); } else { TRef trcd = emitir(IRTG(IR_CNEW, IRT_CDATA), trid, TREF_NIL); cTValue *fin; J->base[0] = trcd; if (J->base[1] && !J->base[2] && !lj_cconv_multi_init(cts, d, &rd->argv[1])) { goto single_init; } else if (ctype_isarray(d->info)) { CType *dc = ctype_rawchild(cts, d); /* Array element type. */ CTSize ofs, esize = dc->size; TRef sp = 0; TValue tv; TValue *sval = &tv; MSize i; tv.u64 = 0; if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info))) lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init array of aggregates. */ for (i = 1, ofs = 0; ofs < sz; ofs += esize) { TRef dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, lj_ir_kintp(J, ofs + sizeof(GCcdata))); if (J->base[i]) { sp = J->base[i]; sval = &rd->argv[i]; i++; } else if (i != 2) { sp = ctype_isnum(dc->info) ? lj_ir_kint(J, 0) : TREF_NIL; } crec_ct_tv(J, dc, dp, sp, sval); } } else if (ctype_isstruct(d->info)) { CTypeID fid = d->sib; MSize i = 1; while (fid) { CType *df = ctype_get(cts, fid); fid = df->sib; if (ctype_isfield(df->info)) { CType *dc; TRef sp, dp; TValue tv; TValue *sval = &tv; setintV(&tv, 0); if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ dc = ctype_rawchild(cts, df); /* Field type. */ if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info) || ctype_isenum(dc->info))) lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init aggregates. */ if (J->base[i]) { sp = J->base[i]; sval = &rd->argv[i]; i++; } else { sp = ctype_isptr(dc->info) ? TREF_NIL : lj_ir_kint(J, 0); } dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, lj_ir_kintp(J, df->size + sizeof(GCcdata))); crec_ct_tv(J, dc, dp, sp, sval); } else if (!ctype_isconstval(df->info)) { /* NYI: init bitfields and sub-structures. */ lj_trace_err(J, LJ_TRERR_NYICONV); } } } else { TRef dp; single_init: dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, lj_ir_kintp(J, sizeof(GCcdata))); if (J->base[1]) { crec_ct_tv(J, d, dp, J->base[1], &rd->argv[1]); } else { TValue tv; tv.u64 = 0; crec_ct_tv(J, d, dp, lj_ir_kint(J, 0), &tv); } } /* Handle __gc metamethod. */ fin = lj_ctype_meta(cts, id, MM_gc); if (fin) crec_finalizer(J, trcd, fin); } } /* Record argument conversions. */ static TRef crec_call_args(jit_State *J, RecordFFData *rd, CTState *cts, CType *ct) { TRef args[CCI_NARGS_MAX]; CTypeID fid; MSize i, n; TRef tr, *base; cTValue *o; #if LJ_TARGET_X86 #if LJ_ABI_WIN TRef *arg0 = NULL, *arg1 = NULL; #endif int ngpr = 0; if (ctype_cconv(ct->info) == CTCC_THISCALL) ngpr = 1; else if (ctype_cconv(ct->info) == CTCC_FASTCALL) ngpr = 2; #endif /* Skip initial attributes. */ fid = ct->sib; while (fid) { CType *ctf = ctype_get(cts, fid); if (!ctype_isattrib(ctf->info)) break; fid = ctf->sib; } args[0] = TREF_NIL; for (n = 0, base = J->base+1, o = rd->argv+1; *base; n++, base++, o++) { CTypeID did; CType *d; if (n >= CCI_NARGS_MAX) lj_trace_err(J, LJ_TRERR_NYICALL); if (fid) { /* Get argument type from field. */ CType *ctf = ctype_get(cts, fid); fid = ctf->sib; lua_assert(ctype_isfield(ctf->info)); did = ctype_cid(ctf->info); } else { if (!(ct->info & CTF_VARARG)) lj_trace_err(J, LJ_TRERR_NYICALL); /* Too many arguments. */ did = lj_ccall_ctid_vararg(cts, o); /* Infer vararg type. */ } d = ctype_raw(cts, did); if (!(ctype_isnum(d->info) || ctype_isptr(d->info) || ctype_isenum(d->info))) lj_trace_err(J, LJ_TRERR_NYICALL); tr = crec_ct_tv(J, d, 0, *base, o); if (ctype_isinteger_or_bool(d->info)) { if (d->size < 4) { if ((d->info & CTF_UNSIGNED)) tr = emitconv(tr, IRT_INT, d->size==1 ? IRT_U8 : IRT_U16, 0); else tr = emitconv(tr, IRT_INT, d->size==1 ? IRT_I8 : IRT_I16,IRCONV_SEXT); } } else if (LJ_SOFTFP && ctype_isfp(d->info) && d->size > 4) { lj_needsplit(J); } #if LJ_TARGET_X86 /* 64 bit args must not end up in registers for fastcall/thiscall. */ #if LJ_ABI_WIN if (!ctype_isfp(d->info)) { /* Sigh, the Windows/x86 ABI allows reordering across 64 bit args. */ if (tref_typerange(tr, IRT_I64, IRT_U64)) { if (ngpr) { arg0 = &args[n]; args[n++] = TREF_NIL; ngpr--; if (ngpr) { arg1 = &args[n]; args[n++] = TREF_NIL; ngpr--; } } } else { if (arg0) { *arg0 = tr; arg0 = NULL; n--; continue; } if (arg1) { *arg1 = tr; arg1 = NULL; n--; continue; } if (ngpr) ngpr--; } } #else if (!ctype_isfp(d->info) && ngpr) { if (tref_typerange(tr, IRT_I64, IRT_U64)) { /* No reordering for other x86 ABIs. Simply add alignment args. */ do { args[n++] = TREF_NIL; } while (--ngpr); } else { ngpr--; } } #endif #endif args[n] = tr; } tr = args[0]; for (i = 1; i < n; i++) tr = emitir(IRT(IR_CARG, IRT_NIL), tr, args[i]); return tr; } /* Create a snapshot for the caller, simulating a 'false' return value. */ static void crec_snap_caller(jit_State *J) { lua_State *L = J->L; TValue *base = L->base, *top = L->top; const BCIns *pc = J->pc; TRef ftr = J->base[-1]; ptrdiff_t delta; if (!frame_islua(base-1)) lj_trace_err(J, LJ_TRERR_NYICALL); J->pc = frame_pc(base-1); delta = 1+bc_a(J->pc[-1]); L->top = base; L->base = base - delta; J->base[-1] = TREF_FALSE; J->base -= delta; J->baseslot -= (BCReg)delta; J->maxslot = (BCReg)delta; J->framedepth--; lj_snap_add(J); L->base = base; L->top = top; J->framedepth++; J->maxslot = 1; J->base += delta; J->baseslot += (BCReg)delta; J->base[-1] = ftr; J->pc = pc; } /* Record function call. */ static int crec_call(jit_State *J, RecordFFData *rd, GCcdata *cd) { CTState *cts = ctype_ctsG(J2G(J)); CType *ct = ctype_raw(cts, cd->ctypeid); IRType tp = IRT_PTR; if (ctype_isptr(ct->info)) { tp = (LJ_64 && ct->size == 8) ? IRT_P64 : IRT_P32; ct = ctype_rawchild(cts, ct); } if (ctype_isfunc(ct->info)) { TRef func = emitir(IRT(IR_FLOAD, tp), J->base[0], IRFL_CDATA_PTR); CType *ctr = ctype_rawchild(cts, ct); IRType t = crec_ct2irt(cts, ctr); TRef tr; TValue tv; /* Check for blacklisted C functions that might call a callback. */ setlightudV(&tv, cdata_getptr(cdataptr(cd), (LJ_64 && tp == IRT_P64) ? 8 : 4)); if (tvistrue(lj_tab_get(J->L, cts->miscmap, &tv))) lj_trace_err(J, LJ_TRERR_BLACKL); if (ctype_isvoid(ctr->info)) { t = IRT_NIL; rd->nres = 0; } else if (!(ctype_isnum(ctr->info) || ctype_isptr(ctr->info) || ctype_isenum(ctr->info)) || t == IRT_CDATA) { lj_trace_err(J, LJ_TRERR_NYICALL); } if ((ct->info & CTF_VARARG) #if LJ_TARGET_X86 || ctype_cconv(ct->info) != CTCC_CDECL #endif ) func = emitir(IRT(IR_CARG, IRT_NIL), func, lj_ir_kint(J, ctype_typeid(cts, ct))); tr = emitir(IRT(IR_CALLXS, t), crec_call_args(J, rd, cts, ct), func); if (ctype_isbool(ctr->info)) { if (frame_islua(J->L->base-1) && bc_b(frame_pc(J->L->base-1)[-1]) == 1) { /* Don't check result if ignored. */ tr = TREF_NIL; } else { crec_snap_caller(J); #if LJ_TARGET_X86ORX64 /* Note: only the x86/x64 backend supports U8 and only for EQ(tr, 0). */ lj_ir_set(J, IRTG(IR_NE, IRT_U8), tr, lj_ir_kint(J, 0)); #else lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0)); #endif J->postproc = LJ_POST_FIXGUARDSNAP; tr = TREF_TRUE; } } else if (t == IRT_PTR || (LJ_64 && t == IRT_P32) || t == IRT_I64 || t == IRT_U64 || ctype_isenum(ctr->info)) { TRef trid = lj_ir_kint(J, ctype_cid(ct->info)); tr = emitir(IRTG(IR_CNEWI, IRT_CDATA), trid, tr); if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); } else if (t == IRT_FLOAT || t == IRT_U32) { tr = emitconv(tr, IRT_NUM, t, 0); } else if (t == IRT_I8 || t == IRT_I16) { tr = emitconv(tr, IRT_INT, t, IRCONV_SEXT); } else if (t == IRT_U8 || t == IRT_U16) { tr = emitconv(tr, IRT_INT, t, 0); } J->base[0] = tr; J->needsnap = 1; return 1; } return 0; } void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd) { CTState *cts = ctype_ctsG(J2G(J)); GCcdata *cd = argv2cdata(J, J->base[0], &rd->argv[0]); CTypeID id = cd->ctypeid; CType *ct; cTValue *tv; MMS mm = MM_call; if (id == CTID_CTYPEID) { id = crec_constructor(J, cd, J->base[0]); mm = MM_new; } else if (crec_call(J, rd, cd)) { return; } /* Record ctype __call/__new metamethod. */ ct = ctype_raw(cts, id); tv = lj_ctype_meta(cts, ctype_isptr(ct->info) ? ctype_cid(ct->info) : id, mm); if (tv) { if (tvisfunc(tv)) { J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; rd->nres = -1; /* Pending tailcall. */ return; } } else if (mm == MM_new) { crec_alloc(J, rd, id); return; } /* No metamethod or NYI: non-function metamethods. */ lj_trace_err(J, LJ_TRERR_BADTYPE); } static TRef crec_arith_int64(jit_State *J, TRef *sp, CType **s, MMS mm) { if (ctype_isnum(s[0]->info) && ctype_isnum(s[1]->info)) { IRType dt; CTypeID id; TRef tr; MSize i; IROp op; lj_needsplit(J); if (((s[0]->info & CTF_UNSIGNED) && s[0]->size == 8) || ((s[1]->info & CTF_UNSIGNED) && s[1]->size == 8)) { dt = IRT_U64; id = CTID_UINT64; } else { dt = IRT_I64; id = CTID_INT64; if (mm < MM_add && !((s[0]->info | s[1]->info) & CTF_FP) && s[0]->size == 4 && s[1]->size == 4) { /* Try to narrow comparison. */ if (!((s[0]->info ^ s[1]->info) & CTF_UNSIGNED) || (tref_isk(sp[1]) && IR(tref_ref(sp[1]))->i >= 0)) { dt = (s[0]->info & CTF_UNSIGNED) ? IRT_U32 : IRT_INT; goto comp; } else if (tref_isk(sp[0]) && IR(tref_ref(sp[0]))->i >= 0) { dt = (s[1]->info & CTF_UNSIGNED) ? IRT_U32 : IRT_INT; goto comp; } } } for (i = 0; i < 2; i++) { IRType st = tref_type(sp[i]); if (st == IRT_NUM || st == IRT_FLOAT) sp[i] = emitconv(sp[i], dt, st, IRCONV_TRUNC|IRCONV_ANY); else if (!(st == IRT_I64 || st == IRT_U64)) sp[i] = emitconv(sp[i], dt, IRT_INT, (s[i]->info & CTF_UNSIGNED) ? 0 : IRCONV_SEXT); } if (mm < MM_add) { comp: /* Assume true comparison. Fixup and emit pending guard later. */ if (mm == MM_eq) { op = IR_EQ; } else { op = mm == MM_lt ? IR_LT : IR_LE; if (dt == IRT_U32 || dt == IRT_U64) op += (IR_ULT-IR_LT); } lj_ir_set(J, IRTG(op, dt), sp[0], sp[1]); J->postproc = LJ_POST_FIXGUARD; return TREF_TRUE; } else { tr = emitir(IRT(mm+(int)IR_ADD-(int)MM_add, dt), sp[0], sp[1]); } return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr); } return 0; } static TRef crec_arith_ptr(jit_State *J, TRef *sp, CType **s, MMS mm) { CTState *cts = ctype_ctsG(J2G(J)); CType *ctp = s[0]; if (ctype_isptr(ctp->info) || ctype_isrefarray(ctp->info)) { if ((mm == MM_sub || mm == MM_eq || mm == MM_lt || mm == MM_le) && (ctype_isptr(s[1]->info) || ctype_isrefarray(s[1]->info))) { if (mm == MM_sub) { /* Pointer difference. */ TRef tr; CTSize sz = lj_ctype_size(cts, ctype_cid(ctp->info)); if (sz == 0 || (sz & (sz-1)) != 0) return 0; /* NYI: integer division. */ tr = emitir(IRT(IR_SUB, IRT_INTP), sp[0], sp[1]); tr = emitir(IRT(IR_BSAR, IRT_INTP), tr, lj_ir_kint(J, lj_fls(sz))); #if LJ_64 tr = emitconv(tr, IRT_NUM, IRT_INTP, 0); #endif return tr; } else { /* Pointer comparison (unsigned). */ /* Assume true comparison. Fixup and emit pending guard later. */ IROp op = mm == MM_eq ? IR_EQ : mm == MM_lt ? IR_ULT : IR_ULE; lj_ir_set(J, IRTG(op, IRT_PTR), sp[0], sp[1]); J->postproc = LJ_POST_FIXGUARD; return TREF_TRUE; } } if (!((mm == MM_add || mm == MM_sub) && ctype_isnum(s[1]->info))) return 0; } else if (mm == MM_add && ctype_isnum(ctp->info) && (ctype_isptr(s[1]->info) || ctype_isrefarray(s[1]->info))) { TRef tr = sp[0]; sp[0] = sp[1]; sp[1] = tr; /* Swap pointer and index. */ ctp = s[1]; } else { return 0; } { TRef tr = sp[1]; IRType t = tref_type(tr); CTSize sz = lj_ctype_size(cts, ctype_cid(ctp->info)); CTypeID id; #if LJ_64 if (t == IRT_NUM || t == IRT_FLOAT) tr = emitconv(tr, IRT_INTP, t, IRCONV_TRUNC|IRCONV_ANY); else if (!(t == IRT_I64 || t == IRT_U64)) tr = emitconv(tr, IRT_INTP, IRT_INT, ((t - IRT_I8) & 1) ? 0 : IRCONV_SEXT); #else if (!tref_typerange(sp[1], IRT_I8, IRT_U32)) { tr = emitconv(tr, IRT_INTP, t, (t == IRT_NUM || t == IRT_FLOAT) ? IRCONV_TRUNC|IRCONV_ANY : 0); } #endif tr = emitir(IRT(IR_MUL, IRT_INTP), tr, lj_ir_kintp(J, sz)); tr = emitir(IRT(mm+(int)IR_ADD-(int)MM_add, IRT_PTR), sp[0], tr); id = lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|ctype_cid(ctp->info)), CTSIZE_PTR); return emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, id), tr); } } /* Record ctype arithmetic metamethods. */ static void crec_arith_meta(jit_State *J, CTState *cts, RecordFFData *rd) { cTValue *tv = NULL; if (J->base[0]) { if (tviscdata(&rd->argv[0])) { CTypeID id = argv2cdata(J, J->base[0], &rd->argv[0])->ctypeid; CType *ct = ctype_raw(cts, id); if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); tv = lj_ctype_meta(cts, id, (MMS)rd->data); } if (!tv && J->base[1] && tviscdata(&rd->argv[1])) { CTypeID id = argv2cdata(J, J->base[1], &rd->argv[1])->ctypeid; CType *ct = ctype_raw(cts, id); if (ctype_isptr(ct->info)) id = ctype_cid(ct->info); tv = lj_ctype_meta(cts, id, (MMS)rd->data); } } if (tv) { if (tvisfunc(tv)) { J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; rd->nres = -1; /* Pending tailcall. */ return; } /* NYI: non-function metamethods. */ } else if ((MMS)rd->data == MM_eq) { J->base[0] = TREF_FALSE; return; } lj_trace_err(J, LJ_TRERR_BADTYPE); } void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd) { CTState *cts = ctype_ctsG(J2G(J)); TRef sp[2]; CType *s[2]; MSize i; for (i = 0; i < 2; i++) { TRef tr = J->base[i]; CType *ct = ctype_get(cts, CTID_DOUBLE); if (!tr) { goto trymeta; } else if (tref_iscdata(tr)) { CTypeID id = argv2cdata(J, tr, &rd->argv[i])->ctypeid; IRType t; ct = ctype_raw(cts, id); t = crec_ct2irt(cts, ct); if (ctype_isptr(ct->info)) { /* Resolve pointer or reference. */ tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_PTR); if (ctype_isref(ct->info)) { ct = ctype_rawchild(cts, ct); t = crec_ct2irt(cts, ct); } } else if (t == IRT_I64 || t == IRT_U64) { tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT64); lj_needsplit(J); goto ok; } else if (t == IRT_INT || t == IRT_U32) { tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT); if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); goto ok; } else if (ctype_isfunc(ct->info)) { tr = emitir(IRT(IR_FLOAD, IRT_PTR), tr, IRFL_CDATA_PTR); ct = ctype_get(cts, lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR)); goto ok; } else { tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata))); } if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); if (ctype_isnum(ct->info)) { if (t == IRT_CDATA) goto trymeta; if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); tr = emitir(IRT(IR_XLOAD, t), tr, 0); } else if (!(ctype_isptr(ct->info) || ctype_isrefarray(ct->info))) { goto trymeta; } } else if (tref_isnil(tr)) { tr = lj_ir_kptr(J, NULL); ct = ctype_get(cts, CTID_P_VOID); } else if (tref_isinteger(tr)) { ct = ctype_get(cts, CTID_INT32); } else if (tref_isstr(tr)) { TRef tr2 = J->base[1-i]; CTypeID id = argv2cdata(J, tr2, &rd->argv[1-i])->ctypeid; ct = ctype_raw(cts, id); if (ctype_isenum(ct->info)) { /* Match string against enum constant. */ GCstr *str = strV(&rd->argv[i]); CTSize ofs; CType *cct = lj_ctype_getfield(cts, ct, str, &ofs); if (cct && ctype_isconstval(cct->info)) { /* Specialize to the name of the enum constant. */ emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str)); ct = ctype_child(cts, cct); tr = lj_ir_kint(J, (int32_t)ofs); } /* else: interpreter will throw. */ } /* else: interpreter will throw. */ } else if (!tref_isnum(tr)) { goto trymeta; } ok: s[i] = ct; sp[i] = tr; } { TRef tr; if ((tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) || (tr = crec_arith_ptr(J, sp, s, (MMS)rd->data))) { J->base[0] = tr; /* Fixup cdata comparisons, too. Avoids some cdata escapes. */ if (J->postproc == LJ_POST_FIXGUARD && frame_iscont(J->L->base-1) && !irt_isguard(J->guardemit)) { const BCIns *pc = frame_contpc(J->L->base-1) - 1; if (bc_op(*pc) <= BC_ISNEP) { setframe_pc(&J2G(J)->tmptv, pc); J2G(J)->tmptv.u32.lo = ((tref_istrue(tr) ^ bc_op(*pc)) & 1); J->postproc = LJ_POST_FIXCOMP; } } } else { trymeta: crec_arith_meta(J, cts, rd); } } } /* -- C library namespace metamethods ------------------------------------- */ void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd) { CTState *cts = ctype_ctsG(J2G(J)); if (tref_isudata(J->base[0]) && tref_isstr(J->base[1]) && udataV(&rd->argv[0])->udtype == UDTYPE_FFI_CLIB) { CLibrary *cl = (CLibrary *)uddata(udataV(&rd->argv[0])); GCstr *name = strV(&rd->argv[1]); CType *ct; CTypeID id = lj_ctype_getname(cts, &ct, name, CLNS_INDEX); cTValue *tv = lj_tab_getstr(cl->cache, name); rd->nres = rd->data; if (id && tv && !tvisnil(tv)) { /* Specialize to the symbol name and make the result a constant. */ emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, name)); if (ctype_isconstval(ct->info)) { if (ct->size >= 0x80000000u && (ctype_child(cts, ct)->info & CTF_UNSIGNED)) J->base[0] = lj_ir_knum(J, (lua_Number)(uint32_t)ct->size); else J->base[0] = lj_ir_kint(J, (int32_t)ct->size); } else if (ctype_isextern(ct->info)) { CTypeID sid = ctype_cid(ct->info); void *sp = *(void **)cdataptr(cdataV(tv)); TRef ptr; ct = ctype_raw(cts, sid); if (LJ_64 && !checkptr32(sp)) ptr = lj_ir_kintp(J, (uintptr_t)sp); else ptr = lj_ir_kptr(J, sp); if (rd->data) { J->base[0] = crec_tv_ct(J, ct, sid, ptr); } else { J->needsnap = 1; crec_ct_tv(J, ct, ptr, J->base[2], &rd->argv[2]); } } else { J->base[0] = lj_ir_kgc(J, obj2gco(cdataV(tv)), IRT_CDATA); } } else { lj_trace_err(J, LJ_TRERR_NOCACHE); } } /* else: interpreter will throw. */ } /* -- FFI library functions ----------------------------------------------- */ static TRef crec_toint(jit_State *J, CTState *cts, TRef sp, TValue *sval) { return crec_ct_tv(J, ctype_get(cts, CTID_INT32), 0, sp, sval); } void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd) { crec_alloc(J, rd, argv2ctype(J, J->base[0], &rd->argv[0])); } void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd) { UNUSED(rd); if (J->base[0]) lj_trace_err(J, LJ_TRERR_NYICALL); J->base[0] = lj_ir_call(J, IRCALL_lj_vm_errno); } void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd) { CTState *cts = ctype_ctsG(J2G(J)); TRef tr = J->base[0]; if (tr) { TRef trlen = J->base[1]; if (trlen) { trlen = crec_toint(J, cts, trlen, &rd->argv[1]); tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, tr, &rd->argv[0]); } else { tr = crec_ct_tv(J, ctype_get(cts, CTID_P_CCHAR), 0, tr, &rd->argv[0]); trlen = lj_ir_call(J, IRCALL_strlen, tr); } J->base[0] = emitir(IRT(IR_XSNEW, IRT_STR), tr, trlen); } /* else: interpreter will throw. */ } void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd) { CTState *cts = ctype_ctsG(J2G(J)); TRef trdst = J->base[0], trsrc = J->base[1], trlen = J->base[2]; if (trdst && trsrc && (trlen || tref_isstr(trsrc))) { trdst = crec_ct_tv(J, ctype_get(cts, CTID_P_VOID), 0, trdst, &rd->argv[0]); trsrc = crec_ct_tv(J, ctype_get(cts, CTID_P_CVOID), 0, trsrc, &rd->argv[1]); if (trlen) { trlen = crec_toint(J, cts, trlen, &rd->argv[2]); } else { trlen = emitir(IRTI(IR_FLOAD), J->base[1], IRFL_STR_LEN); trlen = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1)); } rd->nres = 0; crec_copy(J, trdst, trsrc, trlen, NULL); } /* else: interpreter will throw. */ } void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd) { CTState *cts = ctype_ctsG(J2G(J)); TRef trdst = J->base[0], trlen = J->base[1], trfill = J->base[2]; if (trdst && trlen) { CTSize step = 1; if (tviscdata(&rd->argv[0])) { /* Get alignment of original destination. */ CTSize sz; CType *ct = ctype_raw(cts, cdataV(&rd->argv[0])->ctypeid); if (ctype_isptr(ct->info)) ct = ctype_rawchild(cts, ct); step = (1u<argv[0]); trlen = crec_toint(J, cts, trlen, &rd->argv[1]); if (trfill) trfill = crec_toint(J, cts, trfill, &rd->argv[2]); else trfill = lj_ir_kint(J, 0); rd->nres = 0; crec_fill(J, trdst, trlen, trfill, step); } /* else: interpreter will throw. */ } void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd) { if (tref_iscdata(J->base[0])) { TRef trid = lj_ir_kint(J, argv2ctype(J, J->base[0], &rd->argv[0])); J->base[0] = emitir(IRTG(IR_CNEWI, IRT_CDATA), lj_ir_kint(J, CTID_CTYPEID), trid); } else { setfuncV(J->L, &J->errinfo, J->fn); lj_trace_err_info(J, LJ_TRERR_NYIFFU); } } void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd) { argv2ctype(J, J->base[0], &rd->argv[0]); if (tref_iscdata(J->base[1])) { argv2ctype(J, J->base[1], &rd->argv[1]); J->postproc = LJ_POST_FIXBOOL; J->base[0] = TREF_TRUE; } else { J->base[0] = TREF_FALSE; } } void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd) { if (tref_isstr(J->base[0])) { /* Specialize to the ABI string to make the boolean result a constant. */ emitir(IRTG(IR_EQ, IRT_STR), J->base[0], lj_ir_kstr(J, strV(&rd->argv[0]))); J->postproc = LJ_POST_FIXBOOL; J->base[0] = TREF_TRUE; } else { lj_trace_err(J, LJ_TRERR_BADTYPE); } } /* Record ffi.sizeof(), ffi.alignof(), ffi.offsetof(). */ void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd) { CTypeID id = argv2ctype(J, J->base[0], &rd->argv[0]); if (rd->data == FF_ffi_sizeof) { CType *ct = lj_ctype_rawref(ctype_ctsG(J2G(J)), id); if (ctype_isvltype(ct->info)) lj_trace_err(J, LJ_TRERR_BADTYPE); } else if (rd->data == FF_ffi_offsetof) { /* Specialize to the field name. */ if (!tref_isstr(J->base[1])) lj_trace_err(J, LJ_TRERR_BADTYPE); emitir(IRTG(IR_EQ, IRT_STR), J->base[1], lj_ir_kstr(J, strV(&rd->argv[1]))); rd->nres = 3; /* Just in case. */ } J->postproc = LJ_POST_FIXCONST; J->base[0] = J->base[1] = J->base[2] = TREF_NIL; } void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd) { argv2cdata(J, J->base[0], &rd->argv[0]); crec_finalizer(J, J->base[0], &rd->argv[1]); } /* -- Miscellaneous library functions ------------------------------------- */ void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd) { CTState *cts = ctype_ctsG(J2G(J)); CType *d, *ct = lj_ctype_rawref(cts, cdataV(&rd->argv[0])->ctypeid); if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) { if (ctype_isinteger_or_bool(ct->info) && ct->size <= 4 && !(ct->size == 4 && (ct->info & CTF_UNSIGNED))) d = ctype_get(cts, CTID_INT32); else d = ctype_get(cts, CTID_DOUBLE); J->base[0] = crec_ct_tv(J, d, 0, J->base[0], &rd->argv[0]); } else { J->base[0] = TREF_NIL; } } #undef IR #undef emitir #undef emitconv #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_crecord.h ================================================ /* ** Trace recorder for C data operations. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CRECORD_H #define _LJ_CRECORD_H #include "lj_obj.h" #include "lj_jit.h" #include "lj_ffrecord.h" #if LJ_HASJIT && LJ_HASFFI LJ_FUNC void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd); LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ctype.c ================================================ /* ** C type management. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include "lj_obj.h" #if LJ_HASFFI #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_ctype.h" #include "lj_ccallback.h" /* -- C type definitions -------------------------------------------------- */ /* Predefined typedefs. */ #define CTTDDEF(_) \ /* Vararg handling. */ \ _("va_list", P_VOID) \ _("__builtin_va_list", P_VOID) \ _("__gnuc_va_list", P_VOID) \ /* From stddef.h. */ \ _("ptrdiff_t", INT_PSZ) \ _("size_t", UINT_PSZ) \ _("wchar_t", WCHAR) \ /* Subset of stdint.h. */ \ _("int8_t", INT8) \ _("int16_t", INT16) \ _("int32_t", INT32) \ _("int64_t", INT64) \ _("uint8_t", UINT8) \ _("uint16_t", UINT16) \ _("uint32_t", UINT32) \ _("uint64_t", UINT64) \ _("intptr_t", INT_PSZ) \ _("uintptr_t", UINT_PSZ) \ /* End of typedef list. */ /* Keywords (only the ones we actually care for). */ #define CTKWDEF(_) \ /* Type specifiers. */ \ _("void", -1, CTOK_VOID) \ _("_Bool", 0, CTOK_BOOL) \ _("bool", 1, CTOK_BOOL) \ _("char", 1, CTOK_CHAR) \ _("int", 4, CTOK_INT) \ _("__int8", 1, CTOK_INT) \ _("__int16", 2, CTOK_INT) \ _("__int32", 4, CTOK_INT) \ _("__int64", 8, CTOK_INT) \ _("float", 4, CTOK_FP) \ _("double", 8, CTOK_FP) \ _("long", 0, CTOK_LONG) \ _("short", 0, CTOK_SHORT) \ _("_Complex", 0, CTOK_COMPLEX) \ _("complex", 0, CTOK_COMPLEX) \ _("__complex", 0, CTOK_COMPLEX) \ _("__complex__", 0, CTOK_COMPLEX) \ _("signed", 0, CTOK_SIGNED) \ _("__signed", 0, CTOK_SIGNED) \ _("__signed__", 0, CTOK_SIGNED) \ _("unsigned", 0, CTOK_UNSIGNED) \ /* Type qualifiers. */ \ _("const", 0, CTOK_CONST) \ _("__const", 0, CTOK_CONST) \ _("__const__", 0, CTOK_CONST) \ _("volatile", 0, CTOK_VOLATILE) \ _("__volatile", 0, CTOK_VOLATILE) \ _("__volatile__", 0, CTOK_VOLATILE) \ _("restrict", 0, CTOK_RESTRICT) \ _("__restrict", 0, CTOK_RESTRICT) \ _("__restrict__", 0, CTOK_RESTRICT) \ _("inline", 0, CTOK_INLINE) \ _("__inline", 0, CTOK_INLINE) \ _("__inline__", 0, CTOK_INLINE) \ /* Storage class specifiers. */ \ _("typedef", 0, CTOK_TYPEDEF) \ _("extern", 0, CTOK_EXTERN) \ _("static", 0, CTOK_STATIC) \ _("auto", 0, CTOK_AUTO) \ _("register", 0, CTOK_REGISTER) \ /* GCC Attributes. */ \ _("__extension__", 0, CTOK_EXTENSION) \ _("__attribute", 0, CTOK_ATTRIBUTE) \ _("__attribute__", 0, CTOK_ATTRIBUTE) \ _("asm", 0, CTOK_ASM) \ _("__asm", 0, CTOK_ASM) \ _("__asm__", 0, CTOK_ASM) \ /* MSVC Attributes. */ \ _("__declspec", 0, CTOK_DECLSPEC) \ _("__cdecl", CTCC_CDECL, CTOK_CCDECL) \ _("__thiscall", CTCC_THISCALL, CTOK_CCDECL) \ _("__fastcall", CTCC_FASTCALL, CTOK_CCDECL) \ _("__stdcall", CTCC_STDCALL, CTOK_CCDECL) \ _("__ptr32", 4, CTOK_PTRSZ) \ _("__ptr64", 8, CTOK_PTRSZ) \ /* Other type specifiers. */ \ _("struct", 0, CTOK_STRUCT) \ _("union", 0, CTOK_UNION) \ _("enum", 0, CTOK_ENUM) \ /* Operators. */ \ _("sizeof", 0, CTOK_SIZEOF) \ _("__alignof", 0, CTOK_ALIGNOF) \ _("__alignof__", 0, CTOK_ALIGNOF) \ /* End of keyword list. */ /* Type info for predefined types. Size merged in. */ static CTInfo lj_ctype_typeinfo[] = { #define CTTYINFODEF(id, sz, ct, info) CTINFO((ct),(((sz)&0x3fu)<<10)+(info)), #define CTTDINFODEF(name, id) CTINFO(CT_TYPEDEF, CTID_##id), #define CTKWINFODEF(name, sz, kw) CTINFO(CT_KW,(((sz)&0x3fu)<<10)+(kw)), CTTYDEF(CTTYINFODEF) CTTDDEF(CTTDINFODEF) CTKWDEF(CTKWINFODEF) #undef CTTYINFODEF #undef CTTDINFODEF #undef CTKWINFODEF 0 }; /* Predefined type names collected in a single string. */ static const char * const lj_ctype_typenames = #define CTTDNAMEDEF(name, id) name "\0" #define CTKWNAMEDEF(name, sz, cds) name "\0" CTTDDEF(CTTDNAMEDEF) CTKWDEF(CTKWNAMEDEF) #undef CTTDNAMEDEF #undef CTKWNAMEDEF ; #define CTTYPEINFO_NUM (sizeof(lj_ctype_typeinfo)/sizeof(CTInfo)-1) #ifdef LUAJIT_CTYPE_CHECK_ANCHOR #define CTTYPETAB_MIN CTTYPEINFO_NUM #else #define CTTYPETAB_MIN 128 #endif /* -- C type interning ---------------------------------------------------- */ #define ct_hashtype(info, size) (hashrot(info, size) & CTHASH_MASK) #define ct_hashname(name) \ (hashrot(u32ptr(name), u32ptr(name) + HASH_BIAS) & CTHASH_MASK) /* Create new type element. */ CTypeID lj_ctype_new(CTState *cts, CType **ctp) { CTypeID id = cts->top; CType *ct; lua_assert(cts->L); if (LJ_UNLIKELY(id >= cts->sizetab)) { if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); #ifdef LUAJIT_CTYPE_CHECK_ANCHOR ct = lj_mem_newvec(cts->L, id+1, CType); memcpy(ct, cts->tab, id*sizeof(CType)); memset(cts->tab, 0, id*sizeof(CType)); lj_mem_freevec(cts->g, cts->tab, cts->sizetab, CType); cts->tab = ct; cts->sizetab = id+1; #else lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); #endif } cts->top = id+1; *ctp = ct = &cts->tab[id]; ct->info = 0; ct->size = 0; ct->sib = 0; ct->next = 0; setgcrefnull(ct->name); return id; } /* Intern a type element. */ CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size) { uint32_t h = ct_hashtype(info, size); CTypeID id = cts->hash[h]; lua_assert(cts->L); while (id) { CType *ct = ctype_get(cts, id); if (ct->info == info && ct->size == size) return id; id = ct->next; } id = cts->top; if (LJ_UNLIKELY(id >= cts->sizetab)) { if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV); lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType); } cts->top = id+1; cts->tab[id].info = info; cts->tab[id].size = size; cts->tab[id].sib = 0; cts->tab[id].next = cts->hash[h]; setgcrefnull(cts->tab[id].name); cts->hash[h] = (CTypeID1)id; return id; } /* Add type element to hash table. */ static void ctype_addtype(CTState *cts, CType *ct, CTypeID id) { uint32_t h = ct_hashtype(ct->info, ct->size); ct->next = cts->hash[h]; cts->hash[h] = (CTypeID1)id; } /* Add named element to hash table. */ void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id) { uint32_t h = ct_hashname(gcref(ct->name)); ct->next = cts->hash[h]; cts->hash[h] = (CTypeID1)id; } /* Get a C type by name, matching the type mask. */ CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, uint32_t tmask) { CTypeID id = cts->hash[ct_hashname(name)]; while (id) { CType *ct = ctype_get(cts, id); if (gcref(ct->name) == obj2gco(name) && ((tmask >> ctype_type(ct->info)) & 1)) { *ctp = ct; return id; } id = ct->next; } *ctp = &cts->tab[0]; /* Simplify caller logic. ctype_get() would assert. */ return 0; } /* Get a struct/union/enum/function field by name. */ CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, CTSize *ofs, CTInfo *qual) { while (ct->sib) { ct = ctype_get(cts, ct->sib); if (gcref(ct->name) == obj2gco(name)) { *ofs = ct->size; return ct; } if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { CType *fct, *cct = ctype_child(cts, ct); CTInfo q = 0; while (ctype_isattrib(cct->info)) { if (ctype_attrib(cct->info) == CTA_QUAL) q |= cct->size; cct = ctype_child(cts, cct); } fct = lj_ctype_getfieldq(cts, cct, name, ofs, qual); if (fct) { if (qual) *qual |= q; *ofs += ct->size; return fct; } } } return NULL; /* Not found. */ } /* -- C type information -------------------------------------------------- */ /* Follow references and get raw type for a C type ID. */ CType *lj_ctype_rawref(CTState *cts, CTypeID id) { CType *ct = ctype_get(cts, id); while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) ct = ctype_child(cts, ct); return ct; } /* Get size for a C type ID. Does NOT support VLA/VLS. */ CTSize lj_ctype_size(CTState *cts, CTypeID id) { CType *ct = ctype_raw(cts, id); return ctype_hassize(ct->info) ? ct->size : CTSIZE_INVALID; } /* Get size for a variable-length C type. Does NOT support other C types. */ CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem) { uint64_t xsz = 0; if (ctype_isstruct(ct->info)) { CTypeID arrid = 0, fid = ct->sib; xsz = ct->size; /* Add the struct size. */ while (fid) { CType *ctf = ctype_get(cts, fid); if (ctype_type(ctf->info) == CT_FIELD) arrid = ctype_cid(ctf->info); /* Remember last field of VLS. */ fid = ctf->sib; } ct = ctype_raw(cts, arrid); } lua_assert(ctype_isvlarray(ct->info)); /* Must be a VLA. */ ct = ctype_rawchild(cts, ct); /* Get array element. */ lua_assert(ctype_hassize(ct->info)); /* Calculate actual size of VLA and check for overflow. */ xsz += (uint64_t)ct->size * nelem; return xsz < 0x80000000u ? (CTSize)xsz : CTSIZE_INVALID; } /* Get type, qualifiers, size and alignment for a C type ID. */ CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp) { CTInfo qual = 0; CType *ct = ctype_get(cts, id); for (;;) { CTInfo info = ct->info; if (ctype_isenum(info)) { /* Follow child. Need to look at its attributes, too. */ } else if (ctype_isattrib(info)) { if (ctype_isxattrib(info, CTA_QUAL)) qual |= ct->size; else if (ctype_isxattrib(info, CTA_ALIGN) && !(qual & CTFP_ALIGNED)) qual |= CTFP_ALIGNED + CTALIGN(ct->size); } else { if (!(qual & CTFP_ALIGNED)) qual |= (info & CTF_ALIGN); qual |= (info & ~(CTF_ALIGN|CTMASK_CID)); lua_assert(ctype_hassize(info) || ctype_isfunc(info)); *szp = ctype_isfunc(info) ? CTSIZE_INVALID : ct->size; break; } ct = ctype_get(cts, ctype_cid(info)); } return qual; } /* Get ctype metamethod. */ cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm) { CType *ct = ctype_get(cts, id); cTValue *tv; while (ctype_isattrib(ct->info) || ctype_isref(ct->info)) { id = ctype_cid(ct->info); ct = ctype_get(cts, id); } if (ctype_isptr(ct->info) && ctype_isfunc(ctype_get(cts, ctype_cid(ct->info))->info)) tv = lj_tab_getstr(cts->miscmap, &cts->g->strempty); else tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); if (tv && tvistab(tv) && (tv = lj_tab_getstr(tabV(tv), mmname_str(cts->g, mm))) && !tvisnil(tv)) return tv; return NULL; } /* -- C type representation ----------------------------------------------- */ /* Fixed max. length of a C type representation. */ #define CTREPR_MAX 512 typedef struct CTRepr { char *pb, *pe; CTState *cts; lua_State *L; int needsp; int ok; char buf[CTREPR_MAX]; } CTRepr; /* Prepend string. */ static void ctype_prepstr(CTRepr *ctr, const char *str, MSize len) { char *p = ctr->pb; if (ctr->buf + len+1 > p) { ctr->ok = 0; return; } if (ctr->needsp) *--p = ' '; ctr->needsp = 1; p -= len; while (len-- > 0) p[len] = str[len]; ctr->pb = p; } #define ctype_preplit(ctr, str) ctype_prepstr((ctr), "" str, sizeof(str)-1) /* Prepend char. */ static void ctype_prepc(CTRepr *ctr, int c) { if (ctr->buf >= ctr->pb) { ctr->ok = 0; return; } *--ctr->pb = c; } /* Prepend number. */ static void ctype_prepnum(CTRepr *ctr, uint32_t n) { char *p = ctr->pb; if (ctr->buf + 10+1 > p) { ctr->ok = 0; return; } do { *--p = (char)('0' + n % 10); } while (n /= 10); ctr->pb = p; ctr->needsp = 0; } /* Append char. */ static void ctype_appc(CTRepr *ctr, int c) { if (ctr->pe >= ctr->buf + CTREPR_MAX) { ctr->ok = 0; return; } *ctr->pe++ = c; } /* Append number. */ static void ctype_appnum(CTRepr *ctr, uint32_t n) { char buf[10]; char *p = buf+sizeof(buf); char *q = ctr->pe; if (q > ctr->buf + CTREPR_MAX - 10) { ctr->ok = 0; return; } do { *--p = (char)('0' + n % 10); } while (n /= 10); do { *q++ = *p++; } while (p < buf+sizeof(buf)); ctr->pe = q; } /* Prepend qualifiers. */ static void ctype_prepqual(CTRepr *ctr, CTInfo info) { if ((info & CTF_VOLATILE)) ctype_preplit(ctr, "volatile"); if ((info & CTF_CONST)) ctype_preplit(ctr, "const"); } /* Prepend named type. */ static void ctype_preptype(CTRepr *ctr, CType *ct, CTInfo qual, const char *t) { if (gcref(ct->name)) { GCstr *str = gco2str(gcref(ct->name)); ctype_prepstr(ctr, strdata(str), str->len); } else { if (ctr->needsp) ctype_prepc(ctr, ' '); ctype_prepnum(ctr, ctype_typeid(ctr->cts, ct)); ctr->needsp = 1; } ctype_prepstr(ctr, t, (MSize)strlen(t)); ctype_prepqual(ctr, qual); } static void ctype_repr(CTRepr *ctr, CTypeID id) { CType *ct = ctype_get(ctr->cts, id); CTInfo qual = 0; int ptrto = 0; for (;;) { CTInfo info = ct->info; CTSize size = ct->size; switch (ctype_type(info)) { case CT_NUM: if ((info & CTF_BOOL)) { ctype_preplit(ctr, "bool"); } else if ((info & CTF_FP)) { if (size == sizeof(double)) ctype_preplit(ctr, "double"); else if (size == sizeof(float)) ctype_preplit(ctr, "float"); else ctype_preplit(ctr, "long double"); } else if (size == 1) { if (!((info ^ CTF_UCHAR) & CTF_UNSIGNED)) ctype_preplit(ctr, "char"); else if (CTF_UCHAR) ctype_preplit(ctr, "signed char"); else ctype_preplit(ctr, "unsigned char"); } else if (size < 8) { if (size == 4) ctype_preplit(ctr, "int"); else ctype_preplit(ctr, "short"); if ((info & CTF_UNSIGNED)) ctype_preplit(ctr, "unsigned"); } else { ctype_preplit(ctr, "_t"); ctype_prepnum(ctr, size*8); ctype_preplit(ctr, "int"); if ((info & CTF_UNSIGNED)) ctype_prepc(ctr, 'u'); } ctype_prepqual(ctr, (qual|info)); return; case CT_VOID: ctype_preplit(ctr, "void"); ctype_prepqual(ctr, (qual|info)); return; case CT_STRUCT: ctype_preptype(ctr, ct, qual, (info & CTF_UNION) ? "union" : "struct"); return; case CT_ENUM: if (id == CTID_CTYPEID) { ctype_preplit(ctr, "ctype"); return; } ctype_preptype(ctr, ct, qual, "enum"); return; case CT_ATTRIB: if (ctype_attrib(info) == CTA_QUAL) qual |= size; break; case CT_PTR: if ((info & CTF_REF)) { ctype_prepc(ctr, '&'); } else { ctype_prepqual(ctr, (qual|info)); if (LJ_64 && size == 4) ctype_preplit(ctr, "__ptr32"); ctype_prepc(ctr, '*'); } qual = 0; ptrto = 1; ctr->needsp = 1; break; case CT_ARRAY: if (ctype_isrefarray(info)) { ctr->needsp = 1; if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); } ctype_appc(ctr, '['); if (size != CTSIZE_INVALID) { CTSize csize = ctype_child(ctr->cts, ct)->size; ctype_appnum(ctr, csize ? size/csize : 0); } else if ((info & CTF_VLA)) { ctype_appc(ctr, '?'); } ctype_appc(ctr, ']'); } else if ((info & CTF_COMPLEX)) { if (size == 2*sizeof(float)) ctype_preplit(ctr, "float"); ctype_preplit(ctr, "complex"); return; } else { ctype_preplit(ctr, ")))"); ctype_prepnum(ctr, size); ctype_preplit(ctr, "__attribute__((vector_size("); } break; case CT_FUNC: ctr->needsp = 1; if (ptrto) { ptrto = 0; ctype_prepc(ctr, '('); ctype_appc(ctr, ')'); } ctype_appc(ctr, '('); ctype_appc(ctr, ')'); break; default: lua_assert(0); break; } ct = ctype_get(ctr->cts, ctype_cid(info)); } } /* Return a printable representation of a C type. */ GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name) { global_State *g = G(L); CTRepr ctr; ctr.pb = ctr.pe = &ctr.buf[CTREPR_MAX/2]; ctr.cts = ctype_ctsG(g); ctr.L = L; ctr.ok = 1; ctr.needsp = 0; if (name) ctype_prepstr(&ctr, strdata(name), name->len); ctype_repr(&ctr, id); if (LJ_UNLIKELY(!ctr.ok)) return lj_str_newlit(L, "?"); return lj_str_new(L, ctr.pb, ctr.pe - ctr.pb); } /* Convert int64_t/uint64_t to string with 'LL' or 'ULL' suffix. */ GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned) { char buf[1+20+3]; char *p = buf+sizeof(buf); int sign = 0; *--p = 'L'; *--p = 'L'; if (isunsigned) { *--p = 'U'; } else if ((int64_t)n < 0) { n = (uint64_t)-(int64_t)n; sign = 1; } do { *--p = (char)('0' + n % 10); } while (n /= 10); if (sign) *--p = '-'; return lj_str_new(L, p, (size_t)(buf+sizeof(buf)-p)); } /* Convert complex to string with 'i' or 'I' suffix. */ GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size) { char buf[2*LJ_STR_NUMBUF+2+1]; TValue re, im; size_t len; if (size == 2*sizeof(double)) { re.n = *(double *)sp; im.n = ((double *)sp)[1]; } else { re.n = (double)*(float *)sp; im.n = (double)((float *)sp)[1]; } len = lj_str_bufnum(buf, &re); if (!(im.u32.hi & 0x80000000u) || im.n != im.n) buf[len++] = '+'; len += lj_str_bufnum(buf+len, &im); buf[len] = buf[len-1] >= 'a' ? 'I' : 'i'; return lj_str_new(L, buf, len+1); } /* -- C type state -------------------------------------------------------- */ /* Initialize C type table and state. */ CTState *lj_ctype_init(lua_State *L) { CTState *cts = lj_mem_newt(L, sizeof(CTState), CTState); CType *ct = lj_mem_newvec(L, CTTYPETAB_MIN, CType); const char *name = lj_ctype_typenames; CTypeID id; memset(cts, 0, sizeof(CTState)); cts->tab = ct; cts->sizetab = CTTYPETAB_MIN; cts->top = CTTYPEINFO_NUM; cts->L = NULL; cts->g = G(L); for (id = 0; id < CTTYPEINFO_NUM; id++, ct++) { CTInfo info = lj_ctype_typeinfo[id]; ct->size = (CTSize)((int32_t)(info << 16) >> 26); ct->info = info & 0xffff03ffu; ct->sib = 0; if (ctype_type(info) == CT_KW || ctype_istypedef(info)) { size_t len = strlen(name); GCstr *str = lj_str_new(L, name, len); ctype_setname(ct, str); name += len+1; lj_ctype_addname(cts, ct, id); } else { setgcrefnull(ct->name); ct->next = 0; if (!ctype_isenum(info)) ctype_addtype(cts, ct, id); } } setmref(G(L)->ctype_state, cts); return cts; } /* Free C type table and state. */ void lj_ctype_freestate(global_State *g) { CTState *cts = ctype_ctsG(g); if (cts) { lj_ccallback_mcode_free(cts); lj_mem_freevec(g, cts->tab, cts->sizetab, CType); lj_mem_freevec(g, cts->cb.cbid, cts->cb.sizeid, CTypeID1); lj_mem_freet(g, cts); } } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ctype.h ================================================ /* ** C type management. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_CTYPE_H #define _LJ_CTYPE_H #include "lj_obj.h" #include "lj_gc.h" #if LJ_HASFFI /* -- C type definitions -------------------------------------------------- */ /* C type numbers. Highest 4 bits of C type info. ORDER CT. */ enum { /* Externally visible types. */ CT_NUM, /* Integer or floating-point numbers. */ CT_STRUCT, /* Struct or union. */ CT_PTR, /* Pointer or reference. */ CT_ARRAY, /* Array or complex type. */ CT_MAYCONVERT = CT_ARRAY, CT_VOID, /* Void type. */ CT_ENUM, /* Enumeration. */ CT_HASSIZE = CT_ENUM, /* Last type where ct->size holds the actual size. */ CT_FUNC, /* Function. */ CT_TYPEDEF, /* Typedef. */ CT_ATTRIB, /* Miscellaneous attributes. */ /* Internal element types. */ CT_FIELD, /* Struct/union field or function parameter. */ CT_BITFIELD, /* Struct/union bitfield. */ CT_CONSTVAL, /* Constant value. */ CT_EXTERN, /* External reference. */ CT_KW /* Keyword. */ }; LJ_STATIC_ASSERT(((int)CT_PTR & (int)CT_ARRAY) == CT_PTR); LJ_STATIC_ASSERT(((int)CT_STRUCT & (int)CT_ARRAY) == CT_STRUCT); /* ** ---------- info ------------ ** |type flags... A cid | size | sib | next | name | ** +----------------------------+--------+-------+-------+-------+-- ** |NUM BFvcUL.. A | size | | type | | ** |STRUCT ..vcU..V A | size | field | name? | name? | ** |PTR ..vcR... A cid | size | | type | | ** |ARRAY VCvc...V A cid | size | | type | | ** |VOID ..vc.... A | size | | type | | ** |ENUM A cid | size | const | name? | name? | ** |FUNC ....VS.. cc cid | nargs | field | name? | name? | ** |TYPEDEF cid | | | name | name | ** |ATTRIB attrnum cid | attr | sib? | type? | | ** |FIELD cid | offset | field | | name? | ** |BITFIELD B.vcU csz bsz pos | offset | field | | name? | ** |CONSTVAL c cid | value | const | name | name | ** |EXTERN cid | | sib? | name | name | ** |KW tok | size | | name | name | ** +----------------------------+--------+-------+-------+-------+-- ** ^^ ^^--- bits used for C type conversion dispatch */ /* C type info flags. TFFArrrr */ #define CTF_BOOL 0x08000000u /* Boolean: NUM, BITFIELD. */ #define CTF_FP 0x04000000u /* Floating-point: NUM. */ #define CTF_CONST 0x02000000u /* Const qualifier. */ #define CTF_VOLATILE 0x01000000u /* Volatile qualifier. */ #define CTF_UNSIGNED 0x00800000u /* Unsigned: NUM, BITFIELD. */ #define CTF_LONG 0x00400000u /* Long: NUM. */ #define CTF_VLA 0x00100000u /* Variable-length: ARRAY, STRUCT. */ #define CTF_REF 0x00800000u /* Reference: PTR. */ #define CTF_VECTOR 0x08000000u /* Vector: ARRAY. */ #define CTF_COMPLEX 0x04000000u /* Complex: ARRAY. */ #define CTF_UNION 0x00800000u /* Union: STRUCT. */ #define CTF_VARARG 0x00800000u /* Vararg: FUNC. */ #define CTF_SSEREGPARM 0x00400000u /* SSE register parameters: FUNC. */ #define CTF_QUAL (CTF_CONST|CTF_VOLATILE) #define CTF_ALIGN (CTMASK_ALIGN< 0 ? CTF_UNSIGNED : 0) /* Flags used in parser. .F.Ammvf cp->attr */ #define CTFP_ALIGNED 0x00000001u /* cp->attr + ALIGN */ #define CTFP_PACKED 0x00000002u /* cp->attr */ /* ...C...f cp->fattr */ #define CTFP_CCONV 0x00000001u /* cp->fattr + CCONV/[SSE]REGPARM */ /* C type info bitfields. */ #define CTMASK_CID 0x0000ffffu /* Max. 65536 type IDs. */ #define CTMASK_NUM 0xf0000000u /* Max. 16 type numbers. */ #define CTSHIFT_NUM 28 #define CTMASK_ALIGN 15 /* Max. alignment is 2^15. */ #define CTSHIFT_ALIGN 16 #define CTMASK_ATTRIB 255 /* Max. 256 attributes. */ #define CTSHIFT_ATTRIB 16 #define CTMASK_CCONV 3 /* Max. 4 calling conventions. */ #define CTSHIFT_CCONV 16 #define CTMASK_REGPARM 3 /* Max. 0-3 regparms. */ #define CTSHIFT_REGPARM 18 /* Bitfields only used in parser. */ #define CTMASK_VSIZEP 15 /* Max. vector size is 2^15. */ #define CTSHIFT_VSIZEP 4 #define CTMASK_MSIZEP 255 /* Max. type size (via mode) is 128. */ #define CTSHIFT_MSIZEP 8 /* Info bits for BITFIELD. Max. size of bitfield is 64 bits. */ #define CTBSZ_MAX 32 /* Max. size of bitfield is 32 bit. */ #define CTBSZ_FIELD 127 /* Temp. marker for regular field. */ #define CTMASK_BITPOS 127 #define CTMASK_BITBSZ 127 #define CTMASK_BITCSZ 127 #define CTSHIFT_BITPOS 0 #define CTSHIFT_BITBSZ 8 #define CTSHIFT_BITCSZ 16 #define CTF_INSERT(info, field, val) \ info = (info & ~(CTMASK_##field<> CTSHIFT_NUM) #define ctype_cid(info) ((CTypeID)((info) & CTMASK_CID)) #define ctype_align(info) (((info) >> CTSHIFT_ALIGN) & CTMASK_ALIGN) #define ctype_attrib(info) (((info) >> CTSHIFT_ATTRIB) & CTMASK_ATTRIB) #define ctype_bitpos(info) (((info) >> CTSHIFT_BITPOS) & CTMASK_BITPOS) #define ctype_bitbsz(info) (((info) >> CTSHIFT_BITBSZ) & CTMASK_BITBSZ) #define ctype_bitcsz(info) (((info) >> CTSHIFT_BITCSZ) & CTMASK_BITCSZ) #define ctype_vsizeP(info) (((info) >> CTSHIFT_VSIZEP) & CTMASK_VSIZEP) #define ctype_msizeP(info) (((info) >> CTSHIFT_MSIZEP) & CTMASK_MSIZEP) #define ctype_cconv(info) (((info) >> CTSHIFT_CCONV) & CTMASK_CCONV) /* Simple type checks. */ #define ctype_isnum(info) (ctype_type((info)) == CT_NUM) #define ctype_isvoid(info) (ctype_type((info)) == CT_VOID) #define ctype_isptr(info) (ctype_type((info)) == CT_PTR) #define ctype_isarray(info) (ctype_type((info)) == CT_ARRAY) #define ctype_isstruct(info) (ctype_type((info)) == CT_STRUCT) #define ctype_isfunc(info) (ctype_type((info)) == CT_FUNC) #define ctype_isenum(info) (ctype_type((info)) == CT_ENUM) #define ctype_istypedef(info) (ctype_type((info)) == CT_TYPEDEF) #define ctype_isattrib(info) (ctype_type((info)) == CT_ATTRIB) #define ctype_isfield(info) (ctype_type((info)) == CT_FIELD) #define ctype_isbitfield(info) (ctype_type((info)) == CT_BITFIELD) #define ctype_isconstval(info) (ctype_type((info)) == CT_CONSTVAL) #define ctype_isextern(info) (ctype_type((info)) == CT_EXTERN) #define ctype_hassize(info) (ctype_type((info)) <= CT_HASSIZE) /* Combined type and flag checks. */ #define ctype_isinteger(info) \ (((info) & (CTMASK_NUM|CTF_BOOL|CTF_FP)) == CTINFO(CT_NUM, 0)) #define ctype_isinteger_or_bool(info) \ (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, 0)) #define ctype_isbool(info) \ (((info) & (CTMASK_NUM|CTF_BOOL)) == CTINFO(CT_NUM, CTF_BOOL)) #define ctype_isfp(info) \ (((info) & (CTMASK_NUM|CTF_FP)) == CTINFO(CT_NUM, CTF_FP)) #define ctype_ispointer(info) \ ((ctype_type(info) >> 1) == (CT_PTR >> 1)) /* Pointer or array. */ #define ctype_isref(info) \ (((info) & (CTMASK_NUM|CTF_REF)) == CTINFO(CT_PTR, CTF_REF)) #define ctype_isrefarray(info) \ (((info) & (CTMASK_NUM|CTF_VECTOR|CTF_COMPLEX)) == CTINFO(CT_ARRAY, 0)) #define ctype_isvector(info) \ (((info) & (CTMASK_NUM|CTF_VECTOR)) == CTINFO(CT_ARRAY, CTF_VECTOR)) #define ctype_iscomplex(info) \ (((info) & (CTMASK_NUM|CTF_COMPLEX)) == CTINFO(CT_ARRAY, CTF_COMPLEX)) #define ctype_isvltype(info) \ (((info) & ((CTMASK_NUM|CTF_VLA) - (2u<") _(STRING, "") \ _(INTEGER, "") _(EOF, "") \ _(OROR, "||") _(ANDAND, "&&") _(EQ, "==") _(NE, "!=") \ _(LE, "<=") _(GE, ">=") _(SHL, "<<") _(SHR, ">>") _(DEREF, "->") /* Simple declaration specifiers. */ #define CDSDEF(_) \ _(VOID) _(BOOL) _(CHAR) _(INT) _(FP) \ _(LONG) _(LONGLONG) _(SHORT) _(COMPLEX) _(SIGNED) _(UNSIGNED) \ _(CONST) _(VOLATILE) _(RESTRICT) _(INLINE) \ _(TYPEDEF) _(EXTERN) _(STATIC) _(AUTO) _(REGISTER) /* C keywords. */ #define CKWDEF(_) \ CDSDEF(_) _(EXTENSION) _(ASM) _(ATTRIBUTE) \ _(DECLSPEC) _(CCDECL) _(PTRSZ) \ _(STRUCT) _(UNION) _(ENUM) \ _(SIZEOF) _(ALIGNOF) /* C token numbers. */ enum { CTOK_OFS = 255, #define CTOKNUM(name, sym) CTOK_##name, #define CKWNUM(name) CTOK_##name, CTOKDEF(CTOKNUM) CKWDEF(CKWNUM) #undef CTOKNUM #undef CKWNUM CTOK_FIRSTDECL = CTOK_VOID, CTOK_FIRSTSCL = CTOK_TYPEDEF, CTOK_LASTDECLFLAG = CTOK_REGISTER, CTOK_LASTDECL = CTOK_ENUM }; /* Declaration specifier flags. */ enum { #define CDSFLAG(name) CDF_##name = (1u << (CTOK_##name - CTOK_FIRSTDECL)), CDSDEF(CDSFLAG) #undef CDSFLAG CDF__END }; #define CDF_SCL (CDF_TYPEDEF|CDF_EXTERN|CDF_STATIC|CDF_AUTO|CDF_REGISTER) /* -- C type management --------------------------------------------------- */ #define ctype_ctsG(g) (mref((g)->ctype_state, CTState)) /* Get C type state. */ static LJ_AINLINE CTState *ctype_cts(lua_State *L) { CTState *cts = ctype_ctsG(G(L)); cts->L = L; /* Save L for errors and allocations. */ return cts; } /* Save and restore state of C type table. */ #define LJ_CTYPE_SAVE(cts) CTState savects_ = *(cts) #define LJ_CTYPE_RESTORE(cts) \ ((cts)->top = savects_.top, \ memcpy((cts)->hash, savects_.hash, sizeof(savects_.hash))) /* Check C type ID for validity when assertions are enabled. */ static LJ_AINLINE CTypeID ctype_check(CTState *cts, CTypeID id) { lua_assert(id > 0 && id < cts->top); UNUSED(cts); return id; } /* Get C type for C type ID. */ static LJ_AINLINE CType *ctype_get(CTState *cts, CTypeID id) { return &cts->tab[ctype_check(cts, id)]; } /* Get C type ID for a C type. */ #define ctype_typeid(cts, ct) ((CTypeID)((ct) - (cts)->tab)) /* Get child C type. */ static LJ_AINLINE CType *ctype_child(CTState *cts, CType *ct) { lua_assert(!(ctype_isvoid(ct->info) || ctype_isstruct(ct->info) || ctype_isbitfield(ct->info))); /* These don't have children. */ return ctype_get(cts, ctype_cid(ct->info)); } /* Get raw type for a C type ID. */ static LJ_AINLINE CType *ctype_raw(CTState *cts, CTypeID id) { CType *ct = ctype_get(cts, id); while (ctype_isattrib(ct->info)) ct = ctype_child(cts, ct); return ct; } /* Get raw type of the child of a C type. */ static LJ_AINLINE CType *ctype_rawchild(CTState *cts, CType *ct) { do { ct = ctype_child(cts, ct); } while (ctype_isattrib(ct->info)); return ct; } /* Set the name of a C type table element. */ static LJ_AINLINE void ctype_setname(CType *ct, GCstr *s) { /* NOBARRIER: mark string as fixed -- the C type table is never collected. */ fixstring(s); setgcref(ct->name, obj2gco(s)); } LJ_FUNC CTypeID lj_ctype_new(CTState *cts, CType **ctp); LJ_FUNC CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size); LJ_FUNC void lj_ctype_addname(CTState *cts, CType *ct, CTypeID id); LJ_FUNC CTypeID lj_ctype_getname(CTState *cts, CType **ctp, GCstr *name, uint32_t tmask); LJ_FUNC CType *lj_ctype_getfieldq(CTState *cts, CType *ct, GCstr *name, CTSize *ofs, CTInfo *qual); #define lj_ctype_getfield(cts, ct, name, ofs) \ lj_ctype_getfieldq((cts), (ct), (name), (ofs), NULL) LJ_FUNC CType *lj_ctype_rawref(CTState *cts, CTypeID id); LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id); LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem); LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp); LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm); LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name); LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned); LJ_FUNC GCstr *lj_ctype_repr_complex(lua_State *L, void *sp, CTSize size); LJ_FUNC CTState *lj_ctype_init(lua_State *L); LJ_FUNC void lj_ctype_freestate(global_State *g); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_debug.c ================================================ /* ** Debugging and introspection. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_debug_c #define LUA_CORE #include "lj_obj.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_state.h" #include "lj_frame.h" #include "lj_bc.h" #if LJ_HASJIT #include "lj_jit.h" #endif /* -- Frames -------------------------------------------------------------- */ /* Get frame corresponding to a level. */ cTValue *lj_debug_frame(lua_State *L, int level, int *size) { cTValue *frame, *nextframe, *bot = tvref(L->stack); /* Traverse frames backwards. */ for (nextframe = frame = L->base-1; frame > bot; ) { if (frame_gc(frame) == obj2gco(L)) level++; /* Skip dummy frames. See lj_meta_call(). */ if (level-- == 0) { *size = (int)(nextframe - frame); return frame; /* Level found. */ } nextframe = frame; if (frame_islua(frame)) { frame = frame_prevl(frame); } else { if (frame_isvarg(frame)) level++; /* Skip vararg pseudo-frame. */ frame = frame_prevd(frame); } } *size = level; return NULL; /* Level not found. */ } /* Invalid bytecode position. */ #define NO_BCPOS (~(BCPos)0) /* Return bytecode position for function/frame or NO_BCPOS. */ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe) { const BCIns *ins; GCproto *pt; BCPos pos; lua_assert(fn->c.gct == ~LJ_TFUNC || fn->c.gct == ~LJ_TTHREAD); if (!isluafunc(fn)) { /* Cannot derive a PC for non-Lua functions. */ return NO_BCPOS; } else if (nextframe == NULL) { /* Lua function on top. */ void *cf = cframe_raw(L->cframe); if (cf == NULL || (char *)cframe_pc(cf) == (char *)cframe_L(cf)) return NO_BCPOS; ins = cframe_pc(cf); /* Only happens during error/hook handling. */ } else { if (frame_islua(nextframe)) { ins = frame_pc(nextframe); } else if (frame_iscont(nextframe)) { ins = frame_contpc(nextframe); } else { /* Lua function below errfunc/gc/hook: find cframe to get the PC. */ void *cf = cframe_raw(L->cframe); TValue *f = L->base-1; if (cf == NULL) return NO_BCPOS; while (f > nextframe) { if (frame_islua(f)) { f = frame_prevl(f); } else { if (frame_isc(f)) cf = cframe_raw(cframe_prev(cf)); f = frame_prevd(f); } } if (cframe_prev(cf)) cf = cframe_raw(cframe_prev(cf)); ins = cframe_pc(cf); } } pt = funcproto(fn); pos = proto_bcpos(pt, ins) - 1; #if LJ_HASJIT if (pos > pt->sizebc) { /* Undo the effects of lj_trace_exit for JLOOP. */ GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins)); lua_assert(bc_isret(bc_op(ins[-1]))); pos = proto_bcpos(pt, mref(T->startpc, const BCIns)); } #endif return pos; } /* -- Line numbers -------------------------------------------------------- */ /* Get line number for a bytecode position. */ BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc) { const void *lineinfo = proto_lineinfo(pt); if (pc <= pt->sizebc && lineinfo) { BCLine first = pt->firstline; if (pc == pt->sizebc) return first + pt->numline; if (pc-- == 0) return first; if (pt->numline < 256) return first + (BCLine)((const uint8_t *)lineinfo)[pc]; else if (pt->numline < 65536) return first + (BCLine)((const uint16_t *)lineinfo)[pc]; else return first + (BCLine)((const uint32_t *)lineinfo)[pc]; } return 0; } /* Get line number for function/frame. */ static BCLine debug_frameline(lua_State *L, GCfunc *fn, cTValue *nextframe) { BCPos pc = debug_framepc(L, fn, nextframe); if (pc != NO_BCPOS) { GCproto *pt = funcproto(fn); lua_assert(pc <= pt->sizebc); return lj_debug_line(pt, pc); } return -1; } /* -- Variable names ------------------------------------------------------ */ /* Read ULEB128 value. */ static uint32_t debug_read_uleb128(const uint8_t **pp) { const uint8_t *p = *pp; uint32_t v = *p++; if (LJ_UNLIKELY(v >= 0x80)) { int sh = 0; v &= 0x7f; do { v |= ((*p & 0x7f) << (sh += 7)); } while (*p++ >= 0x80); } *pp = p; return v; } /* Get name of a local variable from slot number and PC. */ static const char *debug_varname(const GCproto *pt, BCPos pc, BCReg slot) { const uint8_t *p = proto_varinfo(pt); if (p) { BCPos lastpc = 0; for (;;) { const char *name = (const char *)p; uint32_t vn = *p++; BCPos startpc, endpc; if (vn < VARNAME__MAX) { if (vn == VARNAME_END) break; /* End of varinfo. */ } else { while (*p++) ; /* Skip over variable name string. */ } lastpc = startpc = lastpc + debug_read_uleb128(&p); if (startpc > pc) break; endpc = startpc + debug_read_uleb128(&p); if (pc < endpc && slot-- == 0) { if (vn < VARNAME__MAX) { #define VARNAMESTR(name, str) str "\0" name = VARNAMEDEF(VARNAMESTR); #undef VARNAMESTR if (--vn) while (*name++ || --vn) ; } return name; } } } return NULL; } /* Get name of local variable from 1-based slot number and function/frame. */ static TValue *debug_localname(lua_State *L, const lua_Debug *ar, const char **name, BCReg slot1) { uint32_t offset = (uint32_t)ar->i_ci & 0xffff; uint32_t size = (uint32_t)ar->i_ci >> 16; TValue *frame = tvref(L->stack) + offset; TValue *nextframe = size ? frame + size : NULL; GCfunc *fn = frame_func(frame); BCPos pc = debug_framepc(L, fn, nextframe); if (!nextframe) nextframe = L->top; if ((int)slot1 < 0) { /* Negative slot number is for varargs. */ if (pc != NO_BCPOS) { GCproto *pt = funcproto(fn); if ((pt->flags & PROTO_VARARG)) { slot1 = pt->numparams + (BCReg)(-(int)slot1); if (frame_isvarg(frame)) { /* Vararg frame has been set up? (pc!=0) */ nextframe = frame; frame = frame_prevd(frame); } if (frame + slot1 < nextframe) { *name = "(*vararg)"; return frame+slot1; } } } return NULL; } if (pc != NO_BCPOS && (*name = debug_varname(funcproto(fn), pc, slot1-1)) != NULL) ; else if (slot1 > 0 && frame + slot1 < nextframe) *name = "(*temporary)"; return frame+slot1; } /* Get name of upvalue. */ const char *lj_debug_uvname(GCproto *pt, uint32_t idx) { const uint8_t *p = proto_uvinfo(pt); lua_assert(idx < pt->sizeuv); if (!p) return ""; if (idx) while (*p++ || --idx) ; return (const char *)p; } /* Get name and value of upvalue. */ const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp) { if (tvisfunc(o)) { GCfunc *fn = funcV(o); if (isluafunc(fn)) { GCproto *pt = funcproto(fn); if (idx < pt->sizeuv) { *tvp = uvval(&gcref(fn->l.uvptr[idx])->uv); return lj_debug_uvname(pt, idx); } } else { if (idx < fn->c.nupvalues) { *tvp = &fn->c.upvalue[idx]; return ""; } } } return NULL; } /* Deduce name of an object from slot number and PC. */ const char *lj_debug_slotname(GCproto *pt, const BCIns *ip, BCReg slot, const char **name) { const char *lname; restart: lname = debug_varname(pt, proto_bcpos(pt, ip), slot); if (lname != NULL) { *name = lname; return "local"; } while (--ip > proto_bc(pt)) { BCIns ins = *ip; BCOp op = bc_op(ins); BCReg ra = bc_a(ins); if (bcmode_a(op) == BCMbase) { if (slot >= ra && (op != BC_KNIL || slot <= bc_d(ins))) return NULL; } else if (bcmode_a(op) == BCMdst && ra == slot) { switch (bc_op(ins)) { case BC_MOV: if (ra == slot) { slot = bc_d(ins); goto restart; } break; case BC_GGET: *name = strdata(gco2str(proto_kgc(pt, ~(ptrdiff_t)bc_d(ins)))); return "global"; case BC_TGETS: *name = strdata(gco2str(proto_kgc(pt, ~(ptrdiff_t)bc_c(ins)))); if (ip > proto_bc(pt)) { BCIns insp = ip[-1]; if (bc_op(insp) == BC_MOV && bc_a(insp) == ra+1 && bc_d(insp) == bc_b(ins)) return "method"; } return "field"; case BC_UGET: *name = lj_debug_uvname(pt, bc_d(ins)); return "upvalue"; default: return NULL; } } } return NULL; } /* Deduce function name from caller of a frame. */ const char *lj_debug_funcname(lua_State *L, TValue *frame, const char **name) { TValue *pframe; GCfunc *fn; BCPos pc; if (frame <= tvref(L->stack)) return NULL; if (frame_isvarg(frame)) frame = frame_prevd(frame); pframe = frame_prev(frame); fn = frame_func(pframe); pc = debug_framepc(L, fn, frame); if (pc != NO_BCPOS) { GCproto *pt = funcproto(fn); const BCIns *ip = &proto_bc(pt)[check_exp(pc < pt->sizebc, pc)]; MMS mm = bcmode_mm(bc_op(*ip)); if (mm == MM_call) { BCReg slot = bc_a(*ip); if (bc_op(*ip) == BC_ITERC) slot -= 3; return lj_debug_slotname(pt, ip, slot, name); } else if (mm != MM__MAX) { *name = strdata(mmname_str(G(L), mm)); return "metamethod"; } } return NULL; } /* -- Source code locations ----------------------------------------------- */ /* Generate shortened source name. */ void lj_debug_shortname(char *out, GCstr *str) { const char *src = strdata(str); if (*src == '=') { strncpy(out, src+1, LUA_IDSIZE); /* Remove first char. */ out[LUA_IDSIZE-1] = '\0'; /* Ensures null termination. */ } else if (*src == '@') { /* Output "source", or "...source". */ size_t len = str->len-1; src++; /* Skip the `@' */ if (len >= LUA_IDSIZE) { src += len-(LUA_IDSIZE-4); /* Get last part of file name. */ *out++ = '.'; *out++ = '.'; *out++ = '.'; } strcpy(out, src); } else { /* Output [string "string"]. */ size_t len; /* Length, up to first control char. */ for (len = 0; len < LUA_IDSIZE-12; len++) if (((const unsigned char *)src)[len] < ' ') break; strcpy(out, "[string \""); out += 9; if (src[len] != '\0') { /* Must truncate? */ if (len > LUA_IDSIZE-15) len = LUA_IDSIZE-15; strncpy(out, src, len); out += len; strcpy(out, "..."); out += 3; } else { strcpy(out, src); out += len; } strcpy(out, "\"]"); } } /* Add current location of a frame to error message. */ void lj_debug_addloc(lua_State *L, const char *msg, cTValue *frame, cTValue *nextframe) { if (frame) { GCfunc *fn = frame_func(frame); if (isluafunc(fn)) { BCLine line = debug_frameline(L, fn, nextframe); if (line >= 0) { char buf[LUA_IDSIZE]; lj_debug_shortname(buf, proto_chunkname(funcproto(fn))); lj_str_pushf(L, "%s:%d: %s", buf, line, msg); return; } } } lj_str_pushf(L, "%s", msg); } /* Push location string for a bytecode position to Lua stack. */ void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc) { GCstr *name = proto_chunkname(pt); const char *s = strdata(name); MSize i, len = name->len; BCLine line = lj_debug_line(pt, pc); if (*s == '@') { s++; len--; for (i = len; i > 0; i--) if (s[i] == '/' || s[i] == '\\') { s += i+1; break; } lj_str_pushf(L, "%s:%d", s, line); } else if (len > 40) { lj_str_pushf(L, "%p:%d", pt, line); } else if (*s == '=') { lj_str_pushf(L, "%s:%d", s+1, line); } else { lj_str_pushf(L, "\"%s\":%d", s, line); } } /* -- Public debug API ---------------------------------------------------- */ /* lua_getupvalue() and lua_setupvalue() are in lj_api.c. */ LUA_API const char *lua_getlocal(lua_State *L, const lua_Debug *ar, int n) { const char *name = NULL; if (ar) { TValue *o = debug_localname(L, ar, &name, (BCReg)n); if (name) { copyTV(L, L->top, o); incr_top(L); } } else if (tvisfunc(L->top-1) && isluafunc(funcV(L->top-1))) { name = debug_varname(funcproto(funcV(L->top-1)), 0, (BCReg)n-1); } return name; } LUA_API const char *lua_setlocal(lua_State *L, const lua_Debug *ar, int n) { const char *name = NULL; TValue *o = debug_localname(L, ar, &name, (BCReg)n); if (name) copyTV(L, o, L->top-1); L->top--; return name; } int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext) { int opt_f = 0, opt_L = 0; TValue *frame = NULL; TValue *nextframe = NULL; GCfunc *fn; if (*what == '>') { TValue *func = L->top - 1; api_check(L, tvisfunc(func)); fn = funcV(func); L->top--; what++; } else { uint32_t offset = (uint32_t)ar->i_ci & 0xffff; uint32_t size = (uint32_t)ar->i_ci >> 16; lua_assert(offset != 0); frame = tvref(L->stack) + offset; if (size) nextframe = frame + size; lua_assert(frame <= tvref(L->maxstack) && (!nextframe || nextframe <= tvref(L->maxstack))); fn = frame_func(frame); lua_assert(fn->c.gct == ~LJ_TFUNC); } for (; *what; what++) { if (*what == 'S') { if (isluafunc(fn)) { GCproto *pt = funcproto(fn); BCLine firstline = pt->firstline; GCstr *name = proto_chunkname(pt); ar->source = strdata(name); lj_debug_shortname(ar->short_src, name); ar->linedefined = (int)firstline; ar->lastlinedefined = (int)(firstline + pt->numline); ar->what = firstline ? "Lua" : "main"; } else { ar->source = "=[C]"; ar->short_src[0] = '['; ar->short_src[1] = 'C'; ar->short_src[2] = ']'; ar->short_src[3] = '\0'; ar->linedefined = -1; ar->lastlinedefined = -1; ar->what = "C"; } } else if (*what == 'l') { ar->currentline = frame ? debug_frameline(L, fn, nextframe) : -1; } else if (*what == 'u') { ar->nups = fn->c.nupvalues; if (ext) { if (isluafunc(fn)) { GCproto *pt = funcproto(fn); ar->nparams = pt->numparams; ar->isvararg = !!(pt->flags & PROTO_VARARG); } else { ar->nparams = 0; ar->isvararg = 1; } } } else if (*what == 'n') { ar->namewhat = frame ? lj_debug_funcname(L, frame, &ar->name) : NULL; if (ar->namewhat == NULL) { ar->namewhat = ""; ar->name = NULL; } } else if (*what == 'f') { opt_f = 1; } else if (*what == 'L') { opt_L = 1; } else { return 0; /* Bad option. */ } } if (opt_f) { setfuncV(L, L->top, fn); incr_top(L); } if (opt_L) { if (isluafunc(fn)) { GCtab *t = lj_tab_new(L, 0, 0); GCproto *pt = funcproto(fn); const void *lineinfo = proto_lineinfo(pt); if (lineinfo) { BCLine first = pt->firstline; int sz = pt->numline < 256 ? 1 : pt->numline < 65536 ? 2 : 4; MSize i, szl = pt->sizebc-1; for (i = 0; i < szl; i++) { BCLine line = first + (sz == 1 ? (BCLine)((const uint8_t *)lineinfo)[i] : sz == 2 ? (BCLine)((const uint16_t *)lineinfo)[i] : (BCLine)((const uint32_t *)lineinfo)[i]); setboolV(lj_tab_setint(L, t, line), 1); } } settabV(L, L->top, t); } else { setnilV(L->top); } incr_top(L); } return 1; /* Ok. */ } LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar) { return lj_debug_getinfo(L, what, (lj_Debug *)ar, 0); } LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar) { int size; cTValue *frame = lj_debug_frame(L, level, &size); if (frame) { ar->i_ci = (size << 16) + (int)(frame - tvref(L->stack)); return 1; } else { ar->i_ci = level - size; return 0; } } /* Number of frames for the leading and trailing part of a traceback. */ #define TRACEBACK_LEVELS1 12 #define TRACEBACK_LEVELS2 10 LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, int level) { int top = (int)(L->top - L->base); int lim = TRACEBACK_LEVELS1; lua_Debug ar; if (msg) lua_pushfstring(L, "%s\n", msg); lua_pushliteral(L, "stack traceback:"); while (lua_getstack(L1, level++, &ar)) { GCfunc *fn; if (level > lim) { if (!lua_getstack(L1, level + TRACEBACK_LEVELS2, &ar)) { level--; } else { lua_pushliteral(L, "\n\t..."); lua_getstack(L1, -10, &ar); level = ar.i_ci - TRACEBACK_LEVELS2; } lim = 2147483647; continue; } lua_getinfo(L1, "Snlf", &ar); fn = funcV(L1->top-1); L1->top--; if (isffunc(fn) && !*ar.namewhat) lua_pushfstring(L, "\n\t[builtin#%d]:", fn->c.ffid); else lua_pushfstring(L, "\n\t%s:", ar.short_src); if (ar.currentline > 0) lua_pushfstring(L, "%d:", ar.currentline); if (*ar.namewhat) { lua_pushfstring(L, " in function " LUA_QS, ar.name); } else { if (*ar.what == 'm') { lua_pushliteral(L, " in main chunk"); } else if (*ar.what == 'C') { lua_pushfstring(L, " at %p", fn->c.f); } else { lua_pushfstring(L, " in function <%s:%d>", ar.short_src, ar.linedefined); } } if ((int)(L->top - L->base) - top >= 15) lua_concat(L, (int)(L->top - L->base) - top); } lua_concat(L, (int)(L->top - L->base) - top); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_debug.h ================================================ /* ** Debugging and introspection. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_DEBUG_H #define _LJ_DEBUG_H #include "lj_obj.h" typedef struct lj_Debug { /* Common fields. Must be in the same order as in lua.h. */ int event; const char *name; const char *namewhat; const char *what; const char *source; int currentline; int nups; int linedefined; int lastlinedefined; char short_src[LUA_IDSIZE]; int i_ci; /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/ int nparams; int isvararg; } lj_Debug; LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp); LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, BCReg slot, const char **name); LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame, const char **name); LJ_FUNC void lj_debug_shortname(char *out, GCstr *str); LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg, cTValue *frame, cTValue *nextframe); LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc); LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext); /* Fixed internal variable names. */ #define VARNAMEDEF(_) \ _(FOR_IDX, "(for index)") \ _(FOR_STOP, "(for limit)") \ _(FOR_STEP, "(for step)") \ _(FOR_GEN, "(for generator)") \ _(FOR_STATE, "(for state)") \ _(FOR_CTL, "(for control)") enum { VARNAME_END, #define VARNAMEENUM(name, str) VARNAME_##name, VARNAMEDEF(VARNAMEENUM) #undef VARNAMEENUM VARNAME__MAX }; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_def.h ================================================ /* ** LuaJIT common internal definitions. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_DEF_H #define _LJ_DEF_H #include "lua.h" #if defined(_MSC_VER) /* MSVC is stuck in the last century and doesn't have C99's stdint.h. */ typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; #ifdef _WIN64 typedef __int64 intptr_t; typedef unsigned __int64 uintptr_t; #else typedef __int32 intptr_t; typedef unsigned __int32 uintptr_t; #endif #elif defined(__symbian__) /* Cough. */ typedef signed char int8_t; typedef short int int16_t; typedef int int32_t; typedef long long int64_t; typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedef unsigned long long uint64_t; typedef int intptr_t; typedef unsigned int uintptr_t; #else #include #endif /* Needed everywhere. */ #include #include /* Various VM limits. */ #define LJ_MAX_MEM 0x7fffff00 /* Max. total memory allocation. */ #define LJ_MAX_ALLOC LJ_MAX_MEM /* Max. individual allocation length. */ #define LJ_MAX_STR LJ_MAX_MEM /* Max. string length. */ #define LJ_MAX_UDATA LJ_MAX_MEM /* Max. userdata length. */ #define LJ_MAX_STRTAB (1<<26) /* Max. string table size. */ #define LJ_MAX_HBITS 26 /* Max. hash bits. */ #define LJ_MAX_ABITS 28 /* Max. bits of array key. */ #define LJ_MAX_ASIZE ((1<<(LJ_MAX_ABITS-1))+1) /* Max. array part size. */ #define LJ_MAX_COLOSIZE 16 /* Max. elems for colocated array. */ #define LJ_MAX_LINE LJ_MAX_MEM /* Max. source code line number. */ #define LJ_MAX_XLEVEL 200 /* Max. syntactic nesting level. */ #define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */ #define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */ #define LJ_MAX_LOCVAR 200 /* Max. # of local variables. */ #define LJ_MAX_UPVAL 60 /* Max. # of upvalues. */ #define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */ #define LJ_STACK_EXTRA 5 /* Extra stack space (metamethods). */ #define LJ_NUM_CBPAGE 1 /* Number of FFI callback pages. */ /* Minimum table/buffer sizes. */ #define LJ_MIN_GLOBAL 6 /* Min. global table size (hbits). */ #define LJ_MIN_REGISTRY 2 /* Min. registry size (hbits). */ #define LJ_MIN_STRTAB 256 /* Min. string table size (pow2). */ #define LJ_MIN_SBUF 32 /* Min. string buffer length. */ #define LJ_MIN_VECSZ 8 /* Min. size for growable vectors. */ #define LJ_MIN_IRSZ 32 /* Min. size for growable IR. */ #define LJ_MIN_K64SZ 16 /* Min. size for chained K64Array. */ /* JIT compiler limits. */ #define LJ_MAX_JSLOTS 250 /* Max. # of stack slots for a trace. */ #define LJ_MAX_PHI 64 /* Max. # of PHIs for a loop. */ #define LJ_MAX_EXITSTUBGR 16 /* Max. # of exit stub groups. */ /* Various macros. */ #ifndef UNUSED #define UNUSED(x) ((void)(x)) /* to avoid warnings */ #endif #define U64x(hi, lo) (((uint64_t)0x##hi << 32) + (uint64_t)0x##lo) #define i32ptr(p) ((int32_t)(intptr_t)(void *)(p)) #define u32ptr(p) ((uint32_t)(intptr_t)(void *)(p)) #define checki8(x) ((x) == (int32_t)(int8_t)(x)) #define checku8(x) ((x) == (int32_t)(uint8_t)(x)) #define checki16(x) ((x) == (int32_t)(int16_t)(x)) #define checku16(x) ((x) == (int32_t)(uint16_t)(x)) #define checki32(x) ((x) == (int32_t)(x)) #define checku32(x) ((x) == (uint32_t)(x)) #define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x)) /* Every half-decent C compiler transforms this into a rotate instruction. */ #define lj_rol(x, n) (((x)<<(n)) | ((x)>>(8*sizeof(x)-(n)))) #define lj_ror(x, n) (((x)<<(8*sizeof(x)-(n))) | ((x)>>(n))) /* A really naive Bloom filter. But sufficient for our needs. */ typedef uintptr_t BloomFilter; #define BLOOM_MASK (8*sizeof(BloomFilter) - 1) #define bloombit(x) ((uintptr_t)1 << ((x) & BLOOM_MASK)) #define bloomset(b, x) ((b) |= bloombit((x))) #define bloomtest(b, x) ((b) & bloombit((x))) #if defined(__GNUC__) #define LJ_NORET __attribute__((noreturn)) #define LJ_ALIGN(n) __attribute__((aligned(n))) #define LJ_INLINE inline #define LJ_AINLINE inline __attribute__((always_inline)) #define LJ_NOINLINE __attribute__((noinline)) #if defined(__ELF__) || defined(__MACH__) #if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) #define LJ_NOAPI extern __attribute__((visibility("hidden"))) #endif #endif /* Note: it's only beneficial to use fastcall on x86 and then only for up to ** two non-FP args. The amalgamated compile covers all LJ_FUNC cases. Only ** indirect calls and related tail-called C functions are marked as fastcall. */ #if defined(__i386__) #define LJ_FASTCALL __attribute__((fastcall)) #endif #define LJ_LIKELY(x) __builtin_expect(!!(x), 1) #define LJ_UNLIKELY(x) __builtin_expect(!!(x), 0) #define lj_ffs(x) ((uint32_t)__builtin_ctz(x)) /* Don't ask ... */ #if defined(__INTEL_COMPILER) && (defined(__i386__) || defined(__x86_64__)) static LJ_AINLINE uint32_t lj_fls(uint32_t x) { uint32_t r; __asm__("bsrl %1, %0" : "=r" (r) : "rm" (x) : "cc"); return r; } #else #define lj_fls(x) ((uint32_t)(__builtin_clz(x)^31)) #endif #if defined(__arm__) static LJ_AINLINE uint32_t lj_bswap(uint32_t x) { uint32_t r; #if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ __asm__("rev %0, %1" : "=r" (r) : "r" (x)); return r; #else #ifdef __thumb__ r = x ^ lj_ror(x, 16); #else __asm__("eor %0, %1, %1, ror #16" : "=r" (r) : "r" (x)); #endif return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); #endif } static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) { return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32)); } #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) static LJ_AINLINE uint32_t lj_bswap(uint32_t x) { return (uint32_t)__builtin_bswap32((int32_t)x); } static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) { return (uint64_t)__builtin_bswap64((int64_t)x); } #elif defined(__i386__) || defined(__x86_64__) static LJ_AINLINE uint32_t lj_bswap(uint32_t x) { uint32_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; } #if defined(__i386__) static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) { return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32)); } #else static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) { uint64_t r; __asm__("bswap %0" : "=r" (r) : "0" (x)); return r; } #endif #else static LJ_AINLINE uint32_t lj_bswap(uint32_t x) { return (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24); } static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) { return (uint64_t)lj_bswap((uint32_t)(x >> 32)) | ((uint64_t)lj_bswap((uint32_t)x) << 32); } #endif typedef union __attribute__((packed)) Unaligned16 { uint16_t u; uint8_t b[2]; } Unaligned16; typedef union __attribute__((packed)) Unaligned32 { uint32_t u; uint8_t b[4]; } Unaligned32; /* Unaligned load of uint16_t. */ static LJ_AINLINE uint16_t lj_getu16(const void *p) { return ((const Unaligned16 *)p)->u; } /* Unaligned load of uint32_t. */ static LJ_AINLINE uint32_t lj_getu32(const void *p) { return ((const Unaligned32 *)p)->u; } #elif defined(_MSC_VER) #define LJ_NORET __declspec(noreturn) #define LJ_ALIGN(n) __declspec(align(n)) #define LJ_INLINE __inline #define LJ_AINLINE __forceinline #define LJ_NOINLINE __declspec(noinline) #if defined(_M_IX86) #define LJ_FASTCALL __fastcall #endif #ifdef _M_PPC unsigned int _CountLeadingZeros(long); #pragma intrinsic(_CountLeadingZeros) static LJ_AINLINE uint32_t lj_fls(uint32_t x) { return _CountLeadingZeros(x) ^ 31; } #else unsigned char _BitScanForward(uint32_t *, unsigned long); unsigned char _BitScanReverse(uint32_t *, unsigned long); #pragma intrinsic(_BitScanForward) #pragma intrinsic(_BitScanReverse) static LJ_AINLINE uint32_t lj_ffs(uint32_t x) { uint32_t r; _BitScanForward(&r, x); return r; } static LJ_AINLINE uint32_t lj_fls(uint32_t x) { uint32_t r; _BitScanReverse(&r, x); return r; } #endif unsigned long _byteswap_ulong(unsigned long); uint64_t _byteswap_uint64(uint64_t); #define lj_bswap(x) (_byteswap_ulong((x))) #define lj_bswap64(x) (_byteswap_uint64((x))) #if defined(_M_PPC) && defined(LUAJIT_NO_UNALIGNED) /* ** Replacement for unaligned loads on Xbox 360. Disabled by default since it's ** usually more costly than the occasional stall when crossing a cache-line. */ static LJ_AINLINE uint16_t lj_getu16(const void *v) { const uint8_t *p = (const uint8_t *)v; return (uint16_t)((p[0]<<8) | p[1]); } static LJ_AINLINE uint32_t lj_getu32(const void *v) { const uint8_t *p = (const uint8_t *)v; return (uint32_t)((p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]); } #else /* Unaligned loads are generally ok on x86/x64. */ #define lj_getu16(p) (*(uint16_t *)(p)) #define lj_getu32(p) (*(uint32_t *)(p)) #endif #else #error "missing defines for your compiler" #endif /* Optional defines. */ #ifndef LJ_FASTCALL #define LJ_FASTCALL #endif #ifndef LJ_NORET #define LJ_NORET #endif #ifndef LJ_NOAPI #define LJ_NOAPI extern #endif #ifndef LJ_LIKELY #define LJ_LIKELY(x) (x) #define LJ_UNLIKELY(x) (x) #endif /* Attributes for internal functions. */ #define LJ_DATA LJ_NOAPI #define LJ_DATADEF #define LJ_ASMF LJ_NOAPI #define LJ_FUNCA LJ_NOAPI #if defined(ljamalg_c) #define LJ_FUNC static #else #define LJ_FUNC LJ_NOAPI #endif #define LJ_FUNC_NORET LJ_FUNC LJ_NORET #define LJ_FUNCA_NORET LJ_FUNCA LJ_NORET #define LJ_ASMF_NORET LJ_ASMF LJ_NORET /* Runtime assertions. */ #ifdef lua_assert #define check_exp(c, e) (lua_assert(c), (e)) #define api_check(l, e) lua_assert(e) #else #define lua_assert(c) ((void)0) #define check_exp(c, e) (e) #define api_check luai_apicheck #endif /* Static assertions. */ #define LJ_ASSERT_NAME2(name, line) name ## line #define LJ_ASSERT_NAME(line) LJ_ASSERT_NAME2(lj_assert_, line) #ifdef __COUNTER__ #define LJ_STATIC_ASSERT(cond) \ extern void LJ_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) #else #define LJ_STATIC_ASSERT(cond) \ extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_dispatch.c ================================================ /* ** Instruction dispatch handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_dispatch_c #define LUA_CORE #include "lj_obj.h" #include "lj_err.h" #include "lj_func.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_meta.h" #include "lj_debug.h" #include "lj_state.h" #include "lj_frame.h" #include "lj_bc.h" #include "lj_ff.h" #if LJ_HASJIT #include "lj_jit.h" #endif #if LJ_HASFFI #include "lj_ccallback.h" #endif #include "lj_trace.h" #include "lj_dispatch.h" #include "lj_vm.h" #include "luajit.h" /* Bump GG_NUM_ASMFF in lj_dispatch.h as needed. Ugly. */ LJ_STATIC_ASSERT(GG_NUM_ASMFF == FF_NUM_ASMFUNC); /* -- Dispatch table management ------------------------------------------- */ #if LJ_TARGET_MIPS #include LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co); #define GOTFUNC(name) (ASMFunction)name, static const ASMFunction dispatch_got[] = { GOTDEF(GOTFUNC) }; #undef GOTFUNC #endif /* Initialize instruction dispatch table and hot counters. */ void lj_dispatch_init(GG_State *GG) { uint32_t i; ASMFunction *disp = GG->dispatch; for (i = 0; i < GG_LEN_SDISP; i++) disp[GG_LEN_DDISP+i] = disp[i] = makeasmfunc(lj_bc_ofs[i]); for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) disp[i] = makeasmfunc(lj_bc_ofs[i]); /* The JIT engine is off by default. luaopen_jit() turns it on. */ disp[BC_FORL] = disp[BC_IFORL]; disp[BC_ITERL] = disp[BC_IITERL]; disp[BC_LOOP] = disp[BC_ILOOP]; disp[BC_FUNCF] = disp[BC_IFUNCF]; disp[BC_FUNCV] = disp[BC_IFUNCV]; GG->g.bc_cfunc_ext = GG->g.bc_cfunc_int = BCINS_AD(BC_FUNCC, LUA_MINSTACK, 0); for (i = 0; i < GG_NUM_ASMFF; i++) GG->bcff[i] = BCINS_AD(BC__MAX+i, 0, 0); #if LJ_TARGET_MIPS memcpy(GG->got, dispatch_got, LJ_GOT__MAX*4); #endif } #if LJ_HASJIT /* Initialize hotcount table. */ void lj_dispatch_init_hotcount(global_State *g) { int32_t hotloop = G2J(g)->param[JIT_P_hotloop]; HotCount start = (HotCount)(hotloop*HOTCOUNT_LOOP - 1); HotCount *hotcount = G2GG(g)->hotcount; uint32_t i; for (i = 0; i < HOTCOUNT_SIZE; i++) hotcount[i] = start; } #endif /* Internal dispatch mode bits. */ #define DISPMODE_JIT 0x01 /* JIT compiler on. */ #define DISPMODE_REC 0x02 /* Recording active. */ #define DISPMODE_INS 0x04 /* Override instruction dispatch. */ #define DISPMODE_CALL 0x08 /* Override call dispatch. */ #define DISPMODE_RET 0x10 /* Override return dispatch. */ /* Update dispatch table depending on various flags. */ void lj_dispatch_update(global_State *g) { uint8_t oldmode = g->dispatchmode; uint8_t mode = 0; #if LJ_HASJIT mode |= (G2J(g)->flags & JIT_F_ON) ? DISPMODE_JIT : 0; mode |= G2J(g)->state != LJ_TRACE_IDLE ? (DISPMODE_REC|DISPMODE_INS|DISPMODE_CALL) : 0; #endif mode |= (g->hookmask & (LUA_MASKLINE|LUA_MASKCOUNT)) ? DISPMODE_INS : 0; mode |= (g->hookmask & LUA_MASKCALL) ? DISPMODE_CALL : 0; mode |= (g->hookmask & LUA_MASKRET) ? DISPMODE_RET : 0; if (oldmode != mode) { /* Mode changed? */ ASMFunction *disp = G2GG(g)->dispatch; ASMFunction f_forl, f_iterl, f_loop, f_funcf, f_funcv; g->dispatchmode = mode; /* Hotcount if JIT is on, but not while recording. */ if ((mode & (DISPMODE_JIT|DISPMODE_REC)) == DISPMODE_JIT) { f_forl = makeasmfunc(lj_bc_ofs[BC_FORL]); f_iterl = makeasmfunc(lj_bc_ofs[BC_ITERL]); f_loop = makeasmfunc(lj_bc_ofs[BC_LOOP]); f_funcf = makeasmfunc(lj_bc_ofs[BC_FUNCF]); f_funcv = makeasmfunc(lj_bc_ofs[BC_FUNCV]); } else { /* Otherwise use the non-hotcounting instructions. */ f_forl = disp[GG_LEN_DDISP+BC_IFORL]; f_iterl = disp[GG_LEN_DDISP+BC_IITERL]; f_loop = disp[GG_LEN_DDISP+BC_ILOOP]; f_funcf = makeasmfunc(lj_bc_ofs[BC_IFUNCF]); f_funcv = makeasmfunc(lj_bc_ofs[BC_IFUNCV]); } /* Init static counting instruction dispatch first (may be copied below). */ disp[GG_LEN_DDISP+BC_FORL] = f_forl; disp[GG_LEN_DDISP+BC_ITERL] = f_iterl; disp[GG_LEN_DDISP+BC_LOOP] = f_loop; /* Set dynamic instruction dispatch. */ if ((oldmode ^ mode) & (DISPMODE_REC|DISPMODE_INS)) { /* Need to update the whole table. */ if (!(mode & (DISPMODE_REC|DISPMODE_INS))) { /* No ins dispatch? */ /* Copy static dispatch table to dynamic dispatch table. */ memcpy(&disp[0], &disp[GG_LEN_DDISP], GG_LEN_SDISP*sizeof(ASMFunction)); /* Overwrite with dynamic return dispatch. */ if ((mode & DISPMODE_RET)) { disp[BC_RETM] = lj_vm_rethook; disp[BC_RET] = lj_vm_rethook; disp[BC_RET0] = lj_vm_rethook; disp[BC_RET1] = lj_vm_rethook; } } else { /* The recording dispatch also checks for hooks. */ ASMFunction f = (mode & DISPMODE_REC) ? lj_vm_record : lj_vm_inshook; uint32_t i; for (i = 0; i < GG_LEN_SDISP; i++) disp[i] = f; } } else if (!(mode & (DISPMODE_REC|DISPMODE_INS))) { /* Otherwise set dynamic counting ins. */ disp[BC_FORL] = f_forl; disp[BC_ITERL] = f_iterl; disp[BC_LOOP] = f_loop; /* Set dynamic return dispatch. */ if ((mode & DISPMODE_RET)) { disp[BC_RETM] = lj_vm_rethook; disp[BC_RET] = lj_vm_rethook; disp[BC_RET0] = lj_vm_rethook; disp[BC_RET1] = lj_vm_rethook; } else { disp[BC_RETM] = disp[GG_LEN_DDISP+BC_RETM]; disp[BC_RET] = disp[GG_LEN_DDISP+BC_RET]; disp[BC_RET0] = disp[GG_LEN_DDISP+BC_RET0]; disp[BC_RET1] = disp[GG_LEN_DDISP+BC_RET1]; } } /* Set dynamic call dispatch. */ if ((oldmode ^ mode) & DISPMODE_CALL) { /* Update the whole table? */ uint32_t i; if ((mode & DISPMODE_CALL) == 0) { /* No call hooks? */ for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) disp[i] = makeasmfunc(lj_bc_ofs[i]); } else { for (i = GG_LEN_SDISP; i < GG_LEN_DDISP; i++) disp[i] = lj_vm_callhook; } } if (!(mode & DISPMODE_CALL)) { /* Overwrite dynamic counting ins. */ disp[BC_FUNCF] = f_funcf; disp[BC_FUNCV] = f_funcv; } #if LJ_HASJIT /* Reset hotcounts for JIT off to on transition. */ if ((mode & DISPMODE_JIT) && !(oldmode & DISPMODE_JIT)) lj_dispatch_init_hotcount(g); #endif } } /* -- JIT mode setting ---------------------------------------------------- */ #if LJ_HASJIT /* Set JIT mode for a single prototype. */ static void setptmode(global_State *g, GCproto *pt, int mode) { if ((mode & LUAJIT_MODE_ON)) { /* (Re-)enable JIT compilation. */ pt->flags &= ~PROTO_NOJIT; lj_trace_reenableproto(pt); /* Unpatch all ILOOP etc. bytecodes. */ } else { /* Flush and/or disable JIT compilation. */ if (!(mode & LUAJIT_MODE_FLUSH)) pt->flags |= PROTO_NOJIT; lj_trace_flushproto(g, pt); /* Flush all traces of prototype. */ } } /* Recursively set the JIT mode for all children of a prototype. */ static void setptmode_all(global_State *g, GCproto *pt, int mode) { ptrdiff_t i; if (!(pt->flags & PROTO_CHILD)) return; for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) { GCobj *o = proto_kgc(pt, i); if (o->gch.gct == ~LJ_TPROTO) { setptmode(g, gco2pt(o), mode); setptmode_all(g, gco2pt(o), mode); } } } #endif /* Public API function: control the JIT engine. */ int luaJIT_setmode(lua_State *L, int idx, int mode) { global_State *g = G(L); int mm = mode & LUAJIT_MODE_MASK; lj_trace_abort(g); /* Abort recording on any state change. */ /* Avoid pulling the rug from under our own feet. */ if ((g->hookmask & HOOK_GC)) lj_err_caller(L, LJ_ERR_NOGCMM); switch (mm) { #if LJ_HASJIT case LUAJIT_MODE_ENGINE: if ((mode & LUAJIT_MODE_FLUSH)) { lj_trace_flushall(L); } else { if (!(mode & LUAJIT_MODE_ON)) G2J(g)->flags &= ~(uint32_t)JIT_F_ON; #if LJ_TARGET_X86ORX64 else if ((G2J(g)->flags & JIT_F_SSE2)) G2J(g)->flags |= (uint32_t)JIT_F_ON; else return 0; /* Don't turn on JIT compiler without SSE2 support. */ #else else G2J(g)->flags |= (uint32_t)JIT_F_ON; #endif lj_dispatch_update(g); } break; case LUAJIT_MODE_FUNC: case LUAJIT_MODE_ALLFUNC: case LUAJIT_MODE_ALLSUBFUNC: { cTValue *tv = idx == 0 ? frame_prev(L->base-1) : idx > 0 ? L->base + (idx-1) : L->top + idx; GCproto *pt; if ((idx == 0 || tvisfunc(tv)) && isluafunc(&gcval(tv)->fn)) pt = funcproto(&gcval(tv)->fn); /* Cannot use funcV() for frame slot. */ else if (tvisproto(tv)) pt = protoV(tv); else return 0; /* Failed. */ if (mm != LUAJIT_MODE_ALLSUBFUNC) setptmode(g, pt, mode); if (mm != LUAJIT_MODE_FUNC) setptmode_all(g, pt, mode); break; } case LUAJIT_MODE_TRACE: if (!(mode & LUAJIT_MODE_FLUSH)) return 0; /* Failed. */ lj_trace_flush(G2J(g), idx); break; #else case LUAJIT_MODE_ENGINE: case LUAJIT_MODE_FUNC: case LUAJIT_MODE_ALLFUNC: case LUAJIT_MODE_ALLSUBFUNC: UNUSED(idx); if ((mode & LUAJIT_MODE_ON)) return 0; /* Failed. */ break; #endif case LUAJIT_MODE_WRAPCFUNC: if ((mode & LUAJIT_MODE_ON)) { if (idx != 0) { cTValue *tv = idx > 0 ? L->base + (idx-1) : L->top + idx; if (tvislightud(tv)) g->wrapf = (lua_CFunction)lightudV(tv); else return 0; /* Failed. */ } else { return 0; /* Failed. */ } g->bc_cfunc_ext = BCINS_AD(BC_FUNCCW, 0, 0); } else { g->bc_cfunc_ext = BCINS_AD(BC_FUNCC, 0, 0); } break; default: return 0; /* Failed. */ } return 1; /* OK. */ } /* Enforce (dynamic) linker error for version mismatches. See luajit.c. */ LUA_API void LUAJIT_VERSION_SYM(void) { } /* -- Hooks --------------------------------------------------------------- */ /* This function can be called asynchronously (e.g. during a signal). */ LUA_API int lua_sethook(lua_State *L, lua_Hook func, int mask, int count) { global_State *g = G(L); mask &= HOOK_EVENTMASK; if (func == NULL || mask == 0) { mask = 0; func = NULL; } /* Consistency. */ g->hookf = func; g->hookcount = g->hookcstart = (int32_t)count; g->hookmask = (uint8_t)((g->hookmask & ~HOOK_EVENTMASK) | mask); lj_trace_abort(g); /* Abort recording on any hook change. */ lj_dispatch_update(g); return 1; } LUA_API lua_Hook lua_gethook(lua_State *L) { return G(L)->hookf; } LUA_API int lua_gethookmask(lua_State *L) { return G(L)->hookmask & HOOK_EVENTMASK; } LUA_API int lua_gethookcount(lua_State *L) { return (int)G(L)->hookcstart; } /* Call a hook. */ static void callhook(lua_State *L, int event, BCLine line) { global_State *g = G(L); lua_Hook hookf = g->hookf; if (hookf && !hook_active(g)) { lua_Debug ar; lj_trace_abort(g); /* Abort recording on any hook call. */ ar.event = event; ar.currentline = line; /* Top frame, nextframe = NULL. */ ar.i_ci = (int)((L->base-1) - tvref(L->stack)); lj_state_checkstack(L, 1+LUA_MINSTACK); hook_enter(g); hookf(L, &ar); lua_assert(hook_active(g)); hook_leave(g); } } /* -- Dispatch callbacks -------------------------------------------------- */ /* Calculate number of used stack slots in the current frame. */ static BCReg cur_topslot(GCproto *pt, const BCIns *pc, uint32_t nres) { BCIns ins = pc[-1]; if (bc_op(ins) == BC_UCLO) ins = pc[bc_j(ins)]; switch (bc_op(ins)) { case BC_CALLM: case BC_CALLMT: return bc_a(ins) + bc_c(ins) + nres-1+1; case BC_RETM: return bc_a(ins) + bc_d(ins) + nres-1; case BC_TSETM: return bc_a(ins) + nres-1; default: return pt->framesize; } } /* Instruction dispatch. Used by instr/line/return hooks or when recording. */ void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc) { ERRNO_SAVE GCfunc *fn = curr_func(L); GCproto *pt = funcproto(fn); void *cf = cframe_raw(L->cframe); const BCIns *oldpc = cframe_pc(cf); global_State *g = G(L); BCReg slots; setcframe_pc(cf, pc); slots = cur_topslot(pt, pc, cframe_multres_n(cf)); L->top = L->base + slots; /* Fix top. */ #if LJ_HASJIT { jit_State *J = G2J(g); if (J->state != LJ_TRACE_IDLE) { #ifdef LUA_USE_ASSERT ptrdiff_t delta = L->top - L->base; #endif J->L = L; lj_trace_ins(J, pc-1); /* The interpreter bytecode PC is offset by 1. */ lua_assert(L->top - L->base == delta); } } #endif if ((g->hookmask & LUA_MASKCOUNT) && g->hookcount == 0) { g->hookcount = g->hookcstart; callhook(L, LUA_HOOKCOUNT, -1); L->top = L->base + slots; /* Fix top again. */ } if ((g->hookmask & LUA_MASKLINE)) { BCPos npc = proto_bcpos(pt, pc) - 1; BCPos opc = proto_bcpos(pt, oldpc) - 1; BCLine line = lj_debug_line(pt, npc); if (pc <= oldpc || opc >= pt->sizebc || line != lj_debug_line(pt, opc)) { callhook(L, LUA_HOOKLINE, line); L->top = L->base + slots; /* Fix top again. */ } } if ((g->hookmask & LUA_MASKRET) && bc_isret(bc_op(pc[-1]))) callhook(L, LUA_HOOKRET, -1); ERRNO_RESTORE } /* Initialize call. Ensure stack space and return # of missing parameters. */ static int call_init(lua_State *L, GCfunc *fn) { if (isluafunc(fn)) { GCproto *pt = funcproto(fn); int numparams = pt->numparams; int gotparams = (int)(L->top - L->base); int need = pt->framesize; if ((pt->flags & PROTO_VARARG)) need += 1+gotparams; lj_state_checkstack(L, (MSize)need); numparams -= gotparams; return numparams >= 0 ? numparams : 0; } else { lj_state_checkstack(L, LUA_MINSTACK); return 0; } } /* Call dispatch. Used by call hooks, hot calls or when recording. */ ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns *pc) { ERRNO_SAVE GCfunc *fn = curr_func(L); BCOp op; global_State *g = G(L); #if LJ_HASJIT jit_State *J = G2J(g); #endif int missing = call_init(L, fn); #if LJ_HASJIT J->L = L; if ((uintptr_t)pc & 1) { /* Marker for hot call. */ #ifdef LUA_USE_ASSERT ptrdiff_t delta = L->top - L->base; #endif pc = (const BCIns *)((uintptr_t)pc & ~(uintptr_t)1); lj_trace_hot(J, pc); lua_assert(L->top - L->base == delta); goto out; } else if (J->state != LJ_TRACE_IDLE && !(g->hookmask & (HOOK_GC|HOOK_VMEVENT))) { #ifdef LUA_USE_ASSERT ptrdiff_t delta = L->top - L->base; #endif /* Record the FUNC* bytecodes, too. */ lj_trace_ins(J, pc-1); /* The interpreter bytecode PC is offset by 1. */ lua_assert(L->top - L->base == delta); } #endif if ((g->hookmask & LUA_MASKCALL)) { int i; for (i = 0; i < missing; i++) /* Add missing parameters. */ setnilV(L->top++); callhook(L, LUA_HOOKCALL, -1); /* Preserve modifications of missing parameters by lua_setlocal(). */ while (missing-- > 0 && tvisnil(L->top - 1)) L->top--; } #if LJ_HASJIT out: #endif op = bc_op(pc[-1]); /* Get FUNC* op. */ #if LJ_HASJIT /* Use the non-hotcounting variants if JIT is off or while recording. */ if ((!(J->flags & JIT_F_ON) || J->state != LJ_TRACE_IDLE) && (op == BC_FUNCF || op == BC_FUNCV)) op = (BCOp)((int)op+(int)BC_IFUNCF-(int)BC_FUNCF); #endif ERRNO_RESTORE return makeasmfunc(lj_bc_ofs[op]); /* Return static dispatch target. */ } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_dispatch.h ================================================ /* ** Instruction dispatch handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_DISPATCH_H #define _LJ_DISPATCH_H #include "lj_obj.h" #include "lj_bc.h" #if LJ_HASJIT #include "lj_jit.h" #endif #if LJ_TARGET_MIPS /* Need our own global offset table for the dreaded MIPS calling conventions. */ #if LJ_HASJIT #define JITGOTDEF(_) _(lj_trace_exit) _(lj_trace_hot) #else #define JITGOTDEF(_) #endif #if LJ_HASFFI #define FFIGOTDEF(_) \ _(lj_meta_equal_cd) _(lj_ccallback_enter) _(lj_ccallback_leave) #else #define FFIGOTDEF(_) #endif #define GOTDEF(_) \ _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \ _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \ _(pow) _(fmod) _(ldexp) \ _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) \ _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \ _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \ _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \ _(lj_meta_for) _(lj_meta_len) _(lj_meta_tget) _(lj_meta_tset) \ _(lj_state_growstack) _(lj_str_fromnum) _(lj_str_fromnumber) _(lj_str_new) \ _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) _(lj_tab_new) \ _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \ JITGOTDEF(_) FFIGOTDEF(_) enum { #define GOTENUM(name) LJ_GOT_##name, GOTDEF(GOTENUM) #undef GOTENUM LJ_GOT__MAX }; #endif /* Type of hot counter. Must match the code in the assembler VM. */ /* 16 bits are sufficient. Only 0.0015% overhead with maximum slot penalty. */ typedef uint16_t HotCount; /* Number of hot counter hash table entries (must be a power of two). */ #define HOTCOUNT_SIZE 64 #define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount)) /* Hotcount decrements. */ #define HOTCOUNT_LOOP 2 #define HOTCOUNT_CALL 1 /* This solves a circular dependency problem -- bump as needed. Sigh. */ #define GG_NUM_ASMFF 62 #define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) #define GG_LEN_SDISP BC_FUNCF #define GG_LEN_DISP (GG_LEN_DDISP + GG_LEN_SDISP) /* Global state, main thread and extra fields are allocated together. */ typedef struct GG_State { lua_State L; /* Main thread. */ global_State g; /* Global state. */ #if LJ_TARGET_MIPS ASMFunction got[LJ_GOT__MAX]; /* Global offset table. */ #endif #if LJ_HASJIT jit_State J; /* JIT state. */ HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ #endif ASMFunction dispatch[GG_LEN_DISP]; /* Instruction dispatch tables. */ BCIns bcff[GG_NUM_ASMFF]; /* Bytecode for ASM fast functions. */ } GG_State; #define GG_OFS(field) ((int)offsetof(GG_State, field)) #define G2GG(gl) ((GG_State *)((char *)(gl) - GG_OFS(g))) #define J2GG(j) ((GG_State *)((char *)(j) - GG_OFS(J))) #define L2GG(L) (G2GG(G(L))) #define J2G(J) (&J2GG(J)->g) #define G2J(gl) (&G2GG(gl)->J) #define L2J(L) (&L2GG(L)->J) #define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) #define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) #define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) #define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS(dispatch)) #define GG_DISP2STATIC (GG_LEN_DDISP*(int)sizeof(ASMFunction)) #define hotcount_get(gg, pc) \ (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] #define hotcount_set(gg, pc, val) \ (hotcount_get((gg), (pc)) = (HotCount)(val)) /* Dispatch table management. */ LJ_FUNC void lj_dispatch_init(GG_State *GG); #if LJ_HASJIT LJ_FUNC void lj_dispatch_init_hotcount(global_State *g); #endif LJ_FUNC void lj_dispatch_update(global_State *g); /* Instruction dispatch callback for hooks or when recording. */ LJ_FUNCA void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc); LJ_FUNCA ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns*pc); LJ_FUNCA void LJ_FASTCALL lj_dispatch_return(lua_State *L, const BCIns *pc); #if LJ_HASFFI && !defined(_BUILDVM_H) /* Save/restore errno and GetLastError() around hooks, exits and recording. */ #include #if LJ_TARGET_WINDOWS #define WIN32_LEAN_AND_MEAN #include #define ERRNO_SAVE int olderr = errno; DWORD oldwerr = GetLastError(); #define ERRNO_RESTORE errno = olderr; SetLastError(oldwerr); #else #define ERRNO_SAVE int olderr = errno; #define ERRNO_RESTORE errno = olderr; #endif #else #define ERRNO_SAVE #define ERRNO_RESTORE #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_emit_arm.h ================================================ /* ** ARM instruction emitter. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* -- Constant encoding --------------------------------------------------- */ static uint8_t emit_invai[16] = { /* AND */ (ARMI_AND^ARMI_BIC) >> 21, /* EOR */ 0, /* SUB */ (ARMI_SUB^ARMI_ADD) >> 21, /* RSB */ 0, /* ADD */ (ARMI_ADD^ARMI_SUB) >> 21, /* ADC */ (ARMI_ADC^ARMI_SBC) >> 21, /* SBC */ (ARMI_SBC^ARMI_ADC) >> 21, /* RSC */ 0, /* TST */ 0, /* TEQ */ 0, /* CMP */ (ARMI_CMP^ARMI_CMN) >> 21, /* CMN */ (ARMI_CMN^ARMI_CMP) >> 21, /* ORR */ 0, /* MOV */ (ARMI_MOV^ARMI_MVN) >> 21, /* BIC */ (ARMI_BIC^ARMI_AND) >> 21, /* MVN */ (ARMI_MVN^ARMI_MOV) >> 21 }; /* Encode constant in K12 format for data processing instructions. */ static uint32_t emit_isk12(ARMIns ai, int32_t n) { uint32_t invai, i, m = (uint32_t)n; /* K12: unsigned 8 bit value, rotated in steps of two bits. */ for (i = 0; i < 4096; i += 256, m = lj_rol(m, 2)) if (m <= 255) return ARMI_K12|m|i; /* Otherwise try negation/complement with the inverse instruction. */ invai = emit_invai[((ai >> 21) & 15)]; if (!invai) return 0; /* Failed. No inverse instruction. */ m = ~(uint32_t)n; if (invai == ((ARMI_SUB^ARMI_ADD) >> 21) || invai == (ARMI_CMP^ARMI_CMN) >> 21) m++; for (i = 0; i < 4096; i += 256, m = lj_rol(m, 2)) if (m <= 255) return ARMI_K12|(invai<<21)|m|i; return 0; /* Failed. */ } /* -- Emit basic instructions --------------------------------------------- */ static void emit_dnm(ASMState *as, ARMIns ai, Reg rd, Reg rn, Reg rm) { *--as->mcp = ai | ARMF_D(rd) | ARMF_N(rn) | ARMF_M(rm); } static void emit_dm(ASMState *as, ARMIns ai, Reg rd, Reg rm) { *--as->mcp = ai | ARMF_D(rd) | ARMF_M(rm); } static void emit_dn(ASMState *as, ARMIns ai, Reg rd, Reg rn) { *--as->mcp = ai | ARMF_D(rd) | ARMF_N(rn); } static void emit_nm(ASMState *as, ARMIns ai, Reg rn, Reg rm) { *--as->mcp = ai | ARMF_N(rn) | ARMF_M(rm); } static void emit_d(ASMState *as, ARMIns ai, Reg rd) { *--as->mcp = ai | ARMF_D(rd); } static void emit_n(ASMState *as, ARMIns ai, Reg rn) { *--as->mcp = ai | ARMF_N(rn); } static void emit_m(ASMState *as, ARMIns ai, Reg rm) { *--as->mcp = ai | ARMF_M(rm); } static void emit_lsox(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) { lua_assert(ofs >= -255 && ofs <= 255); if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; *--as->mcp = ai | ARMI_LS_P | ARMI_LSX_I | ARMF_D(rd) | ARMF_N(rn) | ((ofs & 0xf0) << 4) | (ofs & 0x0f); } static void emit_lso(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) { lua_assert(ofs >= -4095 && ofs <= 4095); /* Combine LDR/STR pairs to LDRD/STRD. */ if (*as->mcp == (ai|ARMI_LS_P|ARMI_LS_U|ARMF_D(rd^1)|ARMF_N(rn)|(ofs^4)) && (ai & ~(ARMI_LDR^ARMI_STR)) == ARMI_STR && rd != rn && (uint32_t)ofs <= 252 && !(ofs & 3) && !((rd ^ (ofs >>2)) & 1) && as->mcp != as->mcloop) { as->mcp++; emit_lsox(as, ai == ARMI_LDR ? ARMI_LDRD : ARMI_STRD, rd&~1, rn, ofs&~4); return; } if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; *--as->mcp = ai | ARMI_LS_P | ARMF_D(rd) | ARMF_N(rn) | ofs; } #if !LJ_SOFTFP static void emit_vlso(ASMState *as, ARMIns ai, Reg rd, Reg rn, int32_t ofs) { lua_assert(ofs >= -1020 && ofs <= 1020 && (ofs&3) == 0); if (ofs < 0) ofs = -ofs; else ai |= ARMI_LS_U; *--as->mcp = ai | ARMI_LS_P | ARMF_D(rd & 15) | ARMF_N(rn) | (ofs >> 2); } #endif /* -- Emit loads/stores --------------------------------------------------- */ /* Prefer spills of BASE/L. */ #define emit_canremat(ref) ((ref) < ASMREF_L) /* Try to find a one step delta relative to another constant. */ static int emit_kdelta1(ASMState *as, Reg d, int32_t i) { RegSet work = ~as->freeset & RSET_GPR; while (work) { Reg r = rset_picktop(work); IRRef ref = regcost_ref(as->cost[r]); lua_assert(r != d); if (emit_canremat(ref)) { int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); uint32_t k = emit_isk12(ARMI_ADD, delta); if (k) { if (k == ARMI_K12) emit_dm(as, ARMI_MOV, d, r); else emit_dn(as, ARMI_ADD^k, d, r); return 1; } } rset_clear(work, r); } return 0; /* Failed. */ } /* Try to find a two step delta relative to another constant. */ static int emit_kdelta2(ASMState *as, Reg d, int32_t i) { RegSet work = ~as->freeset & RSET_GPR; while (work) { Reg r = rset_picktop(work); IRRef ref = regcost_ref(as->cost[r]); lua_assert(r != d); if (emit_canremat(ref)) { int32_t other = ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i; if (other) { int32_t delta = i - other; uint32_t sh, inv = 0, k2, k; if (delta < 0) { delta = -delta; inv = ARMI_ADD^ARMI_SUB; } sh = lj_ffs(delta) & ~1; k2 = emit_isk12(0, delta & (255 << sh)); k = emit_isk12(0, delta & ~(255 << sh)); if (k) { emit_dn(as, ARMI_ADD^k2^inv, d, d); emit_dn(as, ARMI_ADD^k^inv, d, r); return 1; } } } rset_clear(work, r); } return 0; /* Failed. */ } /* Load a 32 bit constant into a GPR. */ static void emit_loadi(ASMState *as, Reg r, int32_t i) { uint32_t k = emit_isk12(ARMI_MOV, i); lua_assert(rset_test(as->freeset, r) || r == RID_TMP); if (k) { /* Standard K12 constant. */ emit_d(as, ARMI_MOV^k, r); } else if ((as->flags & JIT_F_ARMV6T2) && (uint32_t)i < 0x00010000u) { /* 16 bit loword constant for ARMv6T2. */ emit_d(as, ARMI_MOVW|(i & 0x0fff)|((i & 0xf000)<<4), r); } else if (emit_kdelta1(as, r, i)) { /* One step delta relative to another constant. */ } else if ((as->flags & JIT_F_ARMV6T2)) { /* 32 bit hiword/loword constant for ARMv6T2. */ emit_d(as, ARMI_MOVT|((i>>16) & 0x0fff)|(((i>>16) & 0xf000)<<4), r); emit_d(as, ARMI_MOVW|(i & 0x0fff)|((i & 0xf000)<<4), r); } else if (emit_kdelta2(as, r, i)) { /* Two step delta relative to another constant. */ } else { /* Otherwise construct the constant with up to 4 instructions. */ /* NYI: use mvn+bic, use pc-relative loads. */ for (;;) { uint32_t sh = lj_ffs(i) & ~1; int32_t m = i & (255 << sh); i &= ~(255 << sh); if (i == 0) { emit_d(as, ARMI_MOV ^ emit_isk12(0, m), r); break; } emit_dn(as, ARMI_ORR ^ emit_isk12(0, m), r, r); } } } #define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); /* Get/set from constant pointer. */ static void emit_lsptr(ASMState *as, ARMIns ai, Reg r, void *p) { int32_t i = i32ptr(p); emit_lso(as, ai, r, ra_allock(as, (i & ~4095), rset_exclude(RSET_GPR, r)), (i & 4095)); } #if !LJ_SOFTFP /* Load a number constant into an FPR. */ static void emit_loadn(ASMState *as, Reg r, cTValue *tv) { int32_t i; if ((as->flags & JIT_F_VFPV3) && !tv->u32.lo) { uint32_t hi = tv->u32.hi; uint32_t b = ((hi >> 22) & 0x1ff); if (!(hi & 0xffff) && (b == 0x100 || b == 0x0ff)) { *--as->mcp = ARMI_VMOVI_D | ARMF_D(r & 15) | ((tv->u32.hi >> 12) & 0x00080000) | ((tv->u32.hi >> 4) & 0x00070000) | ((tv->u32.hi >> 16) & 0x0000000f); return; } } i = i32ptr(tv); emit_vlso(as, ARMI_VLDR_D, r, ra_allock(as, (i & ~1020), RSET_GPR), (i & 1020)); } #endif /* Get/set global_State fields. */ #define emit_getgl(as, r, field) \ emit_lsptr(as, ARMI_LDR, (r), (void *)&J2G(as->J)->field) #define emit_setgl(as, r, field) \ emit_lsptr(as, ARMI_STR, (r), (void *)&J2G(as->J)->field) /* Trace number is determined from pc of exit instruction. */ #define emit_setvmstate(as, i) UNUSED(i) /* -- Emit control-flow instructions -------------------------------------- */ /* Label for internal jumps. */ typedef MCode *MCLabel; /* Return label pointing to current PC. */ #define emit_label(as) ((as)->mcp) static void emit_branch(ASMState *as, ARMIns ai, MCode *target) { MCode *p = as->mcp; ptrdiff_t delta = (target - p) - 1; lua_assert(((delta + 0x00800000) >> 24) == 0); *--p = ai | ((uint32_t)delta & 0x00ffffffu); as->mcp = p; } #define emit_jmp(as, target) emit_branch(as, ARMI_B, (target)) static void emit_call(ASMState *as, void *target) { MCode *p = --as->mcp; ptrdiff_t delta = ((char *)target - (char *)p) - 8; if ((((delta>>2) + 0x00800000) >> 24) == 0) { if ((delta & 1)) *p = ARMI_BLX | ((uint32_t)(delta>>2) & 0x00ffffffu) | ((delta&2) << 27); else *p = ARMI_BL | ((uint32_t)(delta>>2) & 0x00ffffffu); } else { /* Target out of range: need indirect call. But don't use R0-R3. */ Reg r = ra_allock(as, i32ptr(target), RSET_RANGE(RID_R4, RID_R12+1)); *p = ARMI_BLXr | ARMF_M(r); } } /* -- Emit generic operations --------------------------------------------- */ /* Generic move between two regs. */ static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) { #if LJ_SOFTFP lua_assert(!irt_isnum(ir->t)); UNUSED(ir); #else if (dst >= RID_MAX_GPR) { emit_dm(as, irt_isnum(ir->t) ? ARMI_VMOV_D : ARMI_VMOV_S, (dst & 15), (src & 15)); return; } #endif if (as->mcp != as->mcloop) { /* Swap early registers for loads/stores. */ MCode ins = *as->mcp, swp = (src^dst); if ((ins & 0x0c000000) == 0x04000000 && (ins & 0x02000010) != 0x02000010) { if (!((ins ^ (dst << 16)) & 0x000f0000)) *as->mcp = ins ^ (swp << 16); /* Swap N in load/store. */ if (!(ins & 0x00100000) && !((ins ^ (dst << 12)) & 0x0000f000)) *as->mcp = ins ^ (swp << 12); /* Swap D in store. */ } } emit_dm(as, ARMI_MOV, dst, src); } /* Generic load of register from stack slot. */ static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) { #if LJ_SOFTFP lua_assert(!irt_isnum(ir->t)); UNUSED(ir); #else if (r >= RID_MAX_GPR) emit_vlso(as, irt_isnum(ir->t) ? ARMI_VLDR_D : ARMI_VLDR_S, r, RID_SP, ofs); else #endif emit_lso(as, ARMI_LDR, r, RID_SP, ofs); } /* Generic store of register to stack slot. */ static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) { #if LJ_SOFTFP lua_assert(!irt_isnum(ir->t)); UNUSED(ir); #else if (r >= RID_MAX_GPR) emit_vlso(as, irt_isnum(ir->t) ? ARMI_VSTR_D : ARMI_VSTR_S, r, RID_SP, ofs); else #endif emit_lso(as, ARMI_STR, r, RID_SP, ofs); } /* Emit an arithmetic/logic operation with a constant operand. */ static void emit_opk(ASMState *as, ARMIns ai, Reg dest, Reg src, int32_t i, RegSet allow) { uint32_t k = emit_isk12(ai, i); if (k) emit_dn(as, ai^k, dest, src); else emit_dnm(as, ai, dest, src, ra_allock(as, i, allow)); } /* Add offset to pointer. */ static void emit_addptr(ASMState *as, Reg r, int32_t ofs) { if (ofs) emit_opk(as, ARMI_ADD, r, r, ofs, rset_exclude(RSET_GPR, r)); } #define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_emit_mips.h ================================================ /* ** MIPS instruction emitter. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* -- Emit basic instructions --------------------------------------------- */ static void emit_dst(ASMState *as, MIPSIns mi, Reg rd, Reg rs, Reg rt) { *--as->mcp = mi | MIPSF_D(rd) | MIPSF_S(rs) | MIPSF_T(rt); } static void emit_dta(ASMState *as, MIPSIns mi, Reg rd, Reg rt, uint32_t a) { *--as->mcp = mi | MIPSF_D(rd) | MIPSF_T(rt) | MIPSF_A(a); } #define emit_ds(as, mi, rd, rs) emit_dst(as, (mi), (rd), (rs), 0) #define emit_tg(as, mi, rt, rg) emit_dst(as, (mi), (rg)&31, 0, (rt)) static void emit_tsi(ASMState *as, MIPSIns mi, Reg rt, Reg rs, int32_t i) { *--as->mcp = mi | MIPSF_T(rt) | MIPSF_S(rs) | (i & 0xffff); } #define emit_ti(as, mi, rt, i) emit_tsi(as, (mi), (rt), 0, (i)) #define emit_hsi(as, mi, rh, rs, i) emit_tsi(as, (mi), (rh) & 31, (rs), (i)) static void emit_fgh(ASMState *as, MIPSIns mi, Reg rf, Reg rg, Reg rh) { *--as->mcp = mi | MIPSF_F(rf&31) | MIPSF_G(rg&31) | MIPSF_H(rh&31); } #define emit_fg(as, mi, rf, rg) emit_fgh(as, (mi), (rf), (rg), 0) static void emit_rotr(ASMState *as, Reg dest, Reg src, Reg tmp, uint32_t shift) { if ((as->flags & JIT_F_MIPS32R2)) { emit_dta(as, MIPSI_ROTR, dest, src, shift); } else { emit_dst(as, MIPSI_OR, dest, dest, tmp); emit_dta(as, MIPSI_SLL, dest, src, (-shift)&31); emit_dta(as, MIPSI_SRL, tmp, src, shift); } } /* -- Emit loads/stores --------------------------------------------------- */ /* Prefer rematerialization of BASE/L from global_State over spills. */ #define emit_canremat(ref) ((ref) <= REF_BASE) /* Try to find a one step delta relative to another constant. */ static int emit_kdelta1(ASMState *as, Reg t, int32_t i) { RegSet work = ~as->freeset & RSET_GPR; while (work) { Reg r = rset_picktop(work); IRRef ref = regcost_ref(as->cost[r]); lua_assert(r != t); if (ref < ASMREF_L) { int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); if (checki16(delta)) { emit_tsi(as, MIPSI_ADDIU, t, r, delta); return 1; } } rset_clear(work, r); } return 0; /* Failed. */ } /* Load a 32 bit constant into a GPR. */ static void emit_loadi(ASMState *as, Reg r, int32_t i) { if (checki16(i)) { emit_ti(as, MIPSI_LI, r, i); } else { if ((i & 0xffff)) { int32_t jgl = i32ptr(J2G(as->J)); if ((uint32_t)(i-jgl) < 65536) { emit_tsi(as, MIPSI_ADDIU, r, RID_JGL, i-jgl-32768); return; } else if (emit_kdelta1(as, r, i)) { return; } else if ((i >> 16) == 0) { emit_tsi(as, MIPSI_ORI, r, RID_ZERO, i); return; } emit_tsi(as, MIPSI_ORI, r, r, i); } emit_ti(as, MIPSI_LUI, r, (i >> 16)); } } #define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); static void ra_allockreg(ASMState *as, int32_t k, Reg r); /* Get/set from constant pointer. */ static void emit_lsptr(ASMState *as, MIPSIns mi, Reg r, void *p, RegSet allow) { int32_t jgl = i32ptr(J2G(as->J)); int32_t i = i32ptr(p); Reg base; if ((uint32_t)(i-jgl) < 65536) { i = i-jgl-32768; base = RID_JGL; } else { base = ra_allock(as, i-(int16_t)i, allow); } emit_tsi(as, mi, r, base, i); } #define emit_loadn(as, r, tv) \ emit_lsptr(as, MIPSI_LDC1, ((r) & 31), (void *)(tv), RSET_GPR) /* Get/set global_State fields. */ static void emit_lsglptr(ASMState *as, MIPSIns mi, Reg r, int32_t ofs) { emit_tsi(as, mi, r, RID_JGL, ofs-32768); } #define emit_getgl(as, r, field) \ emit_lsglptr(as, MIPSI_LW, (r), (int32_t)offsetof(global_State, field)) #define emit_setgl(as, r, field) \ emit_lsglptr(as, MIPSI_SW, (r), (int32_t)offsetof(global_State, field)) /* Trace number is determined from per-trace exit stubs. */ #define emit_setvmstate(as, i) UNUSED(i) /* -- Emit control-flow instructions -------------------------------------- */ /* Label for internal jumps. */ typedef MCode *MCLabel; /* Return label pointing to current PC. */ #define emit_label(as) ((as)->mcp) static void emit_branch(ASMState *as, MIPSIns mi, Reg rs, Reg rt, MCode *target) { MCode *p = as->mcp; ptrdiff_t delta = target - p; lua_assert(((delta + 0x8000) >> 16) == 0); *--p = mi | MIPSF_S(rs) | MIPSF_T(rt) | ((uint32_t)delta & 0xffffu); as->mcp = p; } static void emit_jmp(ASMState *as, MCode *target) { *--as->mcp = MIPSI_NOP; emit_branch(as, MIPSI_B, RID_ZERO, RID_ZERO, (target)); } static void emit_call(ASMState *as, void *target) { MCode *p = as->mcp; *--p = MIPSI_NOP; if ((((uintptr_t)target ^ (uintptr_t)p) >> 28) == 0) *--p = MIPSI_JAL | (((uintptr_t)target >>2) & 0x03ffffffu); else /* Target out of range: need indirect call. */ *--p = MIPSI_JALR | MIPSF_S(RID_CFUNCADDR); as->mcp = p; ra_allockreg(as, i32ptr(target), RID_CFUNCADDR); } /* -- Emit generic operations --------------------------------------------- */ #define emit_move(as, dst, src) \ emit_ds(as, MIPSI_MOVE, (dst), (src)) /* Generic move between two regs. */ static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) { if (dst < RID_MAX_GPR) emit_move(as, dst, src); else emit_fg(as, irt_isnum(ir->t) ? MIPSI_MOV_D : MIPSI_MOV_S, dst, src); } /* Generic load of register from stack slot. */ static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) { if (r < RID_MAX_GPR) emit_tsi(as, MIPSI_LW, r, RID_SP, ofs); else emit_tsi(as, irt_isnum(ir->t) ? MIPSI_LDC1 : MIPSI_LWC1, (r & 31), RID_SP, ofs); } /* Generic store of register to stack slot. */ static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) { if (r < RID_MAX_GPR) emit_tsi(as, MIPSI_SW, r, RID_SP, ofs); else emit_tsi(as, irt_isnum(ir->t) ? MIPSI_SDC1 : MIPSI_SWC1, (r&31), RID_SP, ofs); } /* Add offset to pointer. */ static void emit_addptr(ASMState *as, Reg r, int32_t ofs) { if (ofs) { lua_assert(checki16(ofs)); emit_tsi(as, MIPSI_ADDIU, r, r, ofs); } } #define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_emit_ppc.h ================================================ /* ** PPC instruction emitter. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* -- Emit basic instructions --------------------------------------------- */ static void emit_tab(ASMState *as, PPCIns pi, Reg rt, Reg ra, Reg rb) { *--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | PPCF_B(rb); } #define emit_asb(as, pi, ra, rs, rb) emit_tab(as, (pi), (rs), (ra), (rb)) #define emit_as(as, pi, ra, rs) emit_tab(as, (pi), (rs), (ra), 0) #define emit_ab(as, pi, ra, rb) emit_tab(as, (pi), 0, (ra), (rb)) static void emit_tai(ASMState *as, PPCIns pi, Reg rt, Reg ra, int32_t i) { *--as->mcp = pi | PPCF_T(rt) | PPCF_A(ra) | (i & 0xffff); } #define emit_ti(as, pi, rt, i) emit_tai(as, (pi), (rt), 0, (i)) #define emit_ai(as, pi, ra, i) emit_tai(as, (pi), 0, (ra), (i)) #define emit_asi(as, pi, ra, rs, i) emit_tai(as, (pi), (rs), (ra), (i)) #define emit_fab(as, pi, rf, ra, rb) \ emit_tab(as, (pi), (rf)&31, (ra)&31, (rb)&31) #define emit_fb(as, pi, rf, rb) emit_tab(as, (pi), (rf)&31, 0, (rb)&31) #define emit_fac(as, pi, rf, ra, rc) \ emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, 0) #define emit_facb(as, pi, rf, ra, rc, rb) \ emit_tab(as, (pi) | PPCF_C((rc) & 31), (rf)&31, (ra)&31, (rb)&31) #define emit_fai(as, pi, rf, ra, i) emit_tai(as, (pi), (rf)&31, (ra), (i)) static void emit_rot(ASMState *as, PPCIns pi, Reg ra, Reg rs, int32_t n, int32_t b, int32_t e) { *--as->mcp = pi | PPCF_T(rs) | PPCF_A(ra) | PPCF_B(n) | PPCF_MB(b) | PPCF_ME(e); } static void emit_slwi(ASMState *as, Reg ra, Reg rs, int32_t n) { lua_assert(n >= 0 && n < 32); emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31-n); } static void emit_rotlwi(ASMState *as, Reg ra, Reg rs, int32_t n) { lua_assert(n >= 0 && n < 32); emit_rot(as, PPCI_RLWINM, ra, rs, n, 0, 31); } /* -- Emit loads/stores --------------------------------------------------- */ /* Prefer rematerialization of BASE/L from global_State over spills. */ #define emit_canremat(ref) ((ref) <= REF_BASE) /* Try to find a one step delta relative to another constant. */ static int emit_kdelta1(ASMState *as, Reg t, int32_t i) { RegSet work = ~as->freeset & RSET_GPR; while (work) { Reg r = rset_picktop(work); IRRef ref = regcost_ref(as->cost[r]); lua_assert(r != t); if (ref < ASMREF_L) { int32_t delta = i - (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i); if (checki16(delta)) { emit_tai(as, PPCI_ADDI, t, r, delta); return 1; } } rset_clear(work, r); } return 0; /* Failed. */ } /* Load a 32 bit constant into a GPR. */ static void emit_loadi(ASMState *as, Reg r, int32_t i) { if (checki16(i)) { emit_ti(as, PPCI_LI, r, i); } else { if ((i & 0xffff)) { int32_t jgl = i32ptr(J2G(as->J)); if ((uint32_t)(i-jgl) < 65536) { emit_tai(as, PPCI_ADDI, r, RID_JGL, i-jgl-32768); return; } else if (emit_kdelta1(as, r, i)) { return; } emit_asi(as, PPCI_ORI, r, r, i); } emit_ti(as, PPCI_LIS, r, (i >> 16)); } } #define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); /* Get/set from constant pointer. */ static void emit_lsptr(ASMState *as, PPCIns pi, Reg r, void *p, RegSet allow) { int32_t jgl = i32ptr(J2G(as->J)); int32_t i = i32ptr(p); Reg base; if ((uint32_t)(i-jgl) < 65536) { i = i-jgl-32768; base = RID_JGL; } else { base = ra_allock(as, i-(int16_t)i, allow); } emit_tai(as, pi, r, base, i); } #define emit_loadn(as, r, tv) \ emit_lsptr(as, PPCI_LFD, ((r) & 31), (void *)(tv), RSET_GPR) /* Get/set global_State fields. */ static void emit_lsglptr(ASMState *as, PPCIns pi, Reg r, int32_t ofs) { emit_tai(as, pi, r, RID_JGL, ofs-32768); } #define emit_getgl(as, r, field) \ emit_lsglptr(as, PPCI_LWZ, (r), (int32_t)offsetof(global_State, field)) #define emit_setgl(as, r, field) \ emit_lsglptr(as, PPCI_STW, (r), (int32_t)offsetof(global_State, field)) /* Trace number is determined from per-trace exit stubs. */ #define emit_setvmstate(as, i) UNUSED(i) /* -- Emit control-flow instructions -------------------------------------- */ /* Label for internal jumps. */ typedef MCode *MCLabel; /* Return label pointing to current PC. */ #define emit_label(as) ((as)->mcp) static void emit_condbranch(ASMState *as, PPCIns pi, PPCCC cc, MCode *target) { MCode *p = --as->mcp; ptrdiff_t delta = (char *)target - (char *)p; lua_assert(((delta + 0x8000) >> 16) == 0); pi ^= (delta & 0x8000) * (PPCF_Y/0x8000); *p = pi | PPCF_CC(cc) | ((uint32_t)delta & 0xffffu); } static void emit_jmp(ASMState *as, MCode *target) { MCode *p = --as->mcp; ptrdiff_t delta = (char *)target - (char *)p; *p = PPCI_B | (delta & 0x03fffffcu); } static void emit_call(ASMState *as, void *target) { MCode *p = --as->mcp; ptrdiff_t delta = (char *)target - (char *)p; if ((((delta>>2) + 0x00800000) >> 24) == 0) { *p = PPCI_BL | (delta & 0x03fffffcu); } else { /* Target out of range: need indirect call. Don't use arg reg. */ RegSet allow = RSET_GPR & ~RSET_RANGE(RID_R0, REGARG_LASTGPR+1); Reg r = ra_allock(as, i32ptr(target), allow); *p = PPCI_BCTRL; p[-1] = PPCI_MTCTR | PPCF_T(r); as->mcp = p-1; } } /* -- Emit generic operations --------------------------------------------- */ #define emit_mr(as, dst, src) \ emit_asb(as, PPCI_MR, (dst), (src), (src)) /* Generic move between two regs. */ static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) { UNUSED(ir); if (dst < RID_MAX_GPR) emit_mr(as, dst, src); else emit_fb(as, PPCI_FMR, dst, src); } /* Generic load of register from stack slot. */ static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) { if (r < RID_MAX_GPR) emit_tai(as, PPCI_LWZ, r, RID_SP, ofs); else emit_fai(as, irt_isnum(ir->t) ? PPCI_LFD : PPCI_LFS, r, RID_SP, ofs); } /* Generic store of register to stack slot. */ static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) { if (r < RID_MAX_GPR) emit_tai(as, PPCI_STW, r, RID_SP, ofs); else emit_fai(as, irt_isnum(ir->t) ? PPCI_STFD : PPCI_STFS, r, RID_SP, ofs); } /* Emit a compare (for equality) with a constant operand. */ static void emit_cmpi(ASMState *as, Reg r, int32_t k) { if (checki16(k)) { emit_ai(as, PPCI_CMPWI, r, k); } else if (checku16(k)) { emit_ai(as, PPCI_CMPLWI, r, k); } else { emit_ai(as, PPCI_CMPLWI, RID_TMP, k); emit_asi(as, PPCI_XORIS, RID_TMP, r, (k >> 16)); } } /* Add offset to pointer. */ static void emit_addptr(ASMState *as, Reg r, int32_t ofs) { if (ofs) { emit_tai(as, PPCI_ADDI, r, r, ofs); if (!checki16(ofs)) emit_tai(as, PPCI_ADDIS, r, r, (ofs + 32768) >> 16); } } static void emit_spsub(ASMState *as, int32_t ofs) { if (ofs) { emit_tai(as, PPCI_STWU, RID_TMP, RID_SP, -ofs); emit_tai(as, PPCI_ADDI, RID_TMP, RID_SP, CFRAME_SIZE + (as->parent ? as->parent->spadjust : 0)); } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_emit_x86.h ================================================ /* ** x86/x64 instruction emitter. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* -- Emit basic instructions --------------------------------------------- */ #define MODRM(mode, r1, r2) ((MCode)((mode)+(((r1)&7)<<3)+((r2)&7))) #if LJ_64 #define REXRB(p, rr, rb) \ { MCode rex = 0x40 + (((rr)>>1)&4) + (((rb)>>3)&1); \ if (rex != 0x40) *--(p) = rex; } #define FORCE_REX 0x200 #define REX_64 (FORCE_REX|0x080000) #else #define REXRB(p, rr, rb) ((void)0) #define FORCE_REX 0 #define REX_64 0 #endif #define emit_i8(as, i) (*--as->mcp = (MCode)(i)) #define emit_i32(as, i) (*(int32_t *)(as->mcp-4) = (i), as->mcp -= 4) #define emit_u32(as, u) (*(uint32_t *)(as->mcp-4) = (u), as->mcp -= 4) #define emit_x87op(as, xo) \ (*(uint16_t *)(as->mcp-2) = (uint16_t)(xo), as->mcp -= 2) /* op */ static LJ_AINLINE MCode *emit_op(x86Op xo, Reg rr, Reg rb, Reg rx, MCode *p, int delta) { int n = (int8_t)xo; #if defined(__GNUC__) if (__builtin_constant_p(xo) && n == -2) p[delta-2] = (MCode)(xo >> 24); else if (__builtin_constant_p(xo) && n == -3) *(uint16_t *)(p+delta-3) = (uint16_t)(xo >> 16); else #endif *(uint32_t *)(p+delta-5) = (uint32_t)xo; p += n + delta; #if LJ_64 { uint32_t rex = 0x40 + ((rr>>1)&(4+(FORCE_REX>>1)))+((rx>>2)&2)+((rb>>3)&1); if (rex != 0x40) { rex |= (rr >> 16); if (n == -4) { *p = (MCode)rex; rex = (MCode)(xo >> 8); } else if ((xo & 0xffffff) == 0x6600fd) { *p = (MCode)rex; rex = 0x66; } *--p = (MCode)rex; } } #else UNUSED(rr); UNUSED(rb); UNUSED(rx); #endif return p; } /* op + modrm */ #define emit_opm(xo, mode, rr, rb, p, delta) \ (p[(delta)-1] = MODRM((mode), (rr), (rb)), \ emit_op((xo), (rr), (rb), 0, (p), (delta))) /* op + modrm + sib */ #define emit_opmx(xo, mode, scale, rr, rb, rx, p) \ (p[-1] = MODRM((scale), (rx), (rb)), \ p[-2] = MODRM((mode), (rr), RID_ESP), \ emit_op((xo), (rr), (rb), (rx), (p), -1)) /* op r1, r2 */ static void emit_rr(ASMState *as, x86Op xo, Reg r1, Reg r2) { MCode *p = as->mcp; as->mcp = emit_opm(xo, XM_REG, r1, r2, p, 0); } #if LJ_64 && defined(LUA_USE_ASSERT) /* [addr] is sign-extended in x64 and must be in lower 2G (not 4G). */ static int32_t ptr2addr(const void *p) { lua_assert((uintptr_t)p < (uintptr_t)0x80000000); return i32ptr(p); } #else #define ptr2addr(p) (i32ptr((p))) #endif /* op r, [addr] */ static void emit_rma(ASMState *as, x86Op xo, Reg rr, const void *addr) { MCode *p = as->mcp; *(int32_t *)(p-4) = ptr2addr(addr); #if LJ_64 p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP); as->mcp = emit_opm(xo, XM_OFS0, rr, RID_ESP, p, -5); #else as->mcp = emit_opm(xo, XM_OFS0, rr, RID_EBP, p, -4); #endif } /* op r, [base+ofs] */ static void emit_rmro(ASMState *as, x86Op xo, Reg rr, Reg rb, int32_t ofs) { MCode *p = as->mcp; x86Mode mode; if (ra_hasreg(rb)) { if (ofs == 0 && (rb&7) != RID_EBP) { mode = XM_OFS0; } else if (checki8(ofs)) { *--p = (MCode)ofs; mode = XM_OFS8; } else { p -= 4; *(int32_t *)p = ofs; mode = XM_OFS32; } if ((rb&7) == RID_ESP) *--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP); } else { *(int32_t *)(p-4) = ofs; #if LJ_64 p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP); p -= 5; rb = RID_ESP; #else p -= 4; rb = RID_EBP; #endif mode = XM_OFS0; } as->mcp = emit_opm(xo, mode, rr, rb, p, 0); } /* op r, [base+idx*scale+ofs] */ static void emit_rmrxo(ASMState *as, x86Op xo, Reg rr, Reg rb, Reg rx, x86Mode scale, int32_t ofs) { MCode *p = as->mcp; x86Mode mode; if (ofs == 0 && (rb&7) != RID_EBP) { mode = XM_OFS0; } else if (checki8(ofs)) { mode = XM_OFS8; *--p = (MCode)ofs; } else { mode = XM_OFS32; p -= 4; *(int32_t *)p = ofs; } as->mcp = emit_opmx(xo, mode, scale, rr, rb, rx, p); } /* op r, i */ static void emit_gri(ASMState *as, x86Group xg, Reg rb, int32_t i) { MCode *p = as->mcp; x86Op xo; if (checki8(i)) { *--p = (MCode)i; xo = XG_TOXOi8(xg); } else { p -= 4; *(int32_t *)p = i; xo = XG_TOXOi(xg); } as->mcp = emit_opm(xo, XM_REG, (Reg)(xg & 7) | (rb & REX_64), rb, p, 0); } /* op [base+ofs], i */ static void emit_gmroi(ASMState *as, x86Group xg, Reg rb, int32_t ofs, int32_t i) { x86Op xo; if (checki8(i)) { emit_i8(as, i); xo = XG_TOXOi8(xg); } else { emit_i32(as, i); xo = XG_TOXOi(xg); } emit_rmro(as, xo, (Reg)(xg & 7), rb, ofs); } #define emit_shifti(as, xg, r, i) \ (emit_i8(as, (i)), emit_rr(as, XO_SHIFTi, (Reg)(xg), (r))) /* op r, rm/mrm */ static void emit_mrm(ASMState *as, x86Op xo, Reg rr, Reg rb) { MCode *p = as->mcp; x86Mode mode = XM_REG; if (rb == RID_MRM) { rb = as->mrm.base; if (rb == RID_NONE) { rb = RID_EBP; mode = XM_OFS0; p -= 4; *(int32_t *)p = as->mrm.ofs; if (as->mrm.idx != RID_NONE) goto mrmidx; #if LJ_64 *--p = MODRM(XM_SCALE1, RID_ESP, RID_EBP); rb = RID_ESP; #endif } else { if (as->mrm.ofs == 0 && (rb&7) != RID_EBP) { mode = XM_OFS0; } else if (checki8(as->mrm.ofs)) { *--p = (MCode)as->mrm.ofs; mode = XM_OFS8; } else { p -= 4; *(int32_t *)p = as->mrm.ofs; mode = XM_OFS32; } if (as->mrm.idx != RID_NONE) { mrmidx: as->mcp = emit_opmx(xo, mode, as->mrm.scale, rr, rb, as->mrm.idx, p); return; } if ((rb&7) == RID_ESP) *--p = MODRM(XM_SCALE1, RID_ESP, RID_ESP); } } as->mcp = emit_opm(xo, mode, rr, rb, p, 0); } /* op rm/mrm, i */ static void emit_gmrmi(ASMState *as, x86Group xg, Reg rb, int32_t i) { x86Op xo; if (checki8(i)) { emit_i8(as, i); xo = XG_TOXOi8(xg); } else { emit_i32(as, i); xo = XG_TOXOi(xg); } emit_mrm(as, xo, (Reg)(xg & 7) | (rb & REX_64), (rb & ~REX_64)); } /* -- Emit loads/stores --------------------------------------------------- */ /* Instruction selection for XMM moves. */ #define XMM_MOVRR(as) ((as->flags & JIT_F_SPLIT_XMM) ? XO_MOVSD : XO_MOVAPS) #define XMM_MOVRM(as) ((as->flags & JIT_F_SPLIT_XMM) ? XO_MOVLPD : XO_MOVSD) /* mov [base+ofs], i */ static void emit_movmroi(ASMState *as, Reg base, int32_t ofs, int32_t i) { emit_i32(as, i); emit_rmro(as, XO_MOVmi, 0, base, ofs); } /* mov [base+ofs], r */ #define emit_movtomro(as, r, base, ofs) \ emit_rmro(as, XO_MOVto, (r), (base), (ofs)) /* Get/set global_State fields. */ #define emit_opgl(as, xo, r, field) \ emit_rma(as, (xo), (r), (void *)&J2G(as->J)->field) #define emit_getgl(as, r, field) emit_opgl(as, XO_MOV, (r), field) #define emit_setgl(as, r, field) emit_opgl(as, XO_MOVto, (r), field) #define emit_setvmstate(as, i) \ (emit_i32(as, i), emit_opgl(as, XO_MOVmi, 0, vmstate)) /* mov r, i / xor r, r */ static void emit_loadi(ASMState *as, Reg r, int32_t i) { /* XOR r,r is shorter, but modifies the flags. This is bad for HIOP. */ if (i == 0 && !(LJ_32 && (IR(as->curins)->o == IR_HIOP || (as->curins+1 < as->T->nins && IR(as->curins+1)->o == IR_HIOP)))) { emit_rr(as, XO_ARITH(XOg_XOR), r, r); } else { MCode *p = as->mcp; *(int32_t *)(p-4) = i; p[-5] = (MCode)(XI_MOVri+(r&7)); p -= 5; REXRB(p, 0, r); as->mcp = p; } } /* mov r, addr */ #define emit_loada(as, r, addr) \ emit_loadi(as, (r), ptr2addr((addr))) #if LJ_64 /* mov r, imm64 or shorter 32 bit extended load. */ static void emit_loadu64(ASMState *as, Reg r, uint64_t u64) { if (checku32(u64)) { /* 32 bit load clears upper 32 bits. */ emit_loadi(as, r, (int32_t)u64); } else if (checki32((int64_t)u64)) { /* Sign-extended 32 bit load. */ MCode *p = as->mcp; *(int32_t *)(p-4) = (int32_t)u64; as->mcp = emit_opm(XO_MOVmi, XM_REG, REX_64, r, p, -4); } else { /* Full-size 64 bit load. */ MCode *p = as->mcp; *(uint64_t *)(p-8) = u64; p[-9] = (MCode)(XI_MOVri+(r&7)); p[-10] = 0x48 + ((r>>3)&1); p -= 10; as->mcp = p; } } #endif /* movsd r, [&tv->n] / xorps r, r */ static void emit_loadn(ASMState *as, Reg r, cTValue *tv) { if (tvispzero(tv)) /* Use xor only for +0. */ emit_rr(as, XO_XORPS, r, r); else emit_rma(as, XMM_MOVRM(as), r, &tv->n); } /* -- Emit control-flow instructions -------------------------------------- */ /* Label for short jumps. */ typedef MCode *MCLabel; #if LJ_32 && LJ_HASFFI /* jmp short target */ static void emit_sjmp(ASMState *as, MCLabel target) { MCode *p = as->mcp; ptrdiff_t delta = target - p; lua_assert(delta == (int8_t)delta); p[-1] = (MCode)(int8_t)delta; p[-2] = XI_JMPs; as->mcp = p - 2; } #endif /* jcc short target */ static void emit_sjcc(ASMState *as, int cc, MCLabel target) { MCode *p = as->mcp; ptrdiff_t delta = target - p; lua_assert(delta == (int8_t)delta); p[-1] = (MCode)(int8_t)delta; p[-2] = (MCode)(XI_JCCs+(cc&15)); as->mcp = p - 2; } /* jcc short (pending target) */ static MCLabel emit_sjcc_label(ASMState *as, int cc) { MCode *p = as->mcp; p[-1] = 0; p[-2] = (MCode)(XI_JCCs+(cc&15)); as->mcp = p - 2; return p; } /* Fixup jcc short target. */ static void emit_sfixup(ASMState *as, MCLabel source) { source[-1] = (MCode)(as->mcp-source); } /* Return label pointing to current PC. */ #define emit_label(as) ((as)->mcp) /* Compute relative 32 bit offset for jump and call instructions. */ static LJ_AINLINE int32_t jmprel(MCode *p, MCode *target) { ptrdiff_t delta = target - p; lua_assert(delta == (int32_t)delta); return (int32_t)delta; } /* jcc target */ static void emit_jcc(ASMState *as, int cc, MCode *target) { MCode *p = as->mcp; *(int32_t *)(p-4) = jmprel(p, target); p[-5] = (MCode)(XI_JCCn+(cc&15)); p[-6] = 0x0f; as->mcp = p - 6; } /* jmp target */ static void emit_jmp(ASMState *as, MCode *target) { MCode *p = as->mcp; *(int32_t *)(p-4) = jmprel(p, target); p[-5] = XI_JMP; as->mcp = p - 5; } /* call target */ static void emit_call_(ASMState *as, MCode *target) { MCode *p = as->mcp; #if LJ_64 if (target-p != (int32_t)(target-p)) { /* Assumes RID_RET is never an argument to calls and always clobbered. */ emit_rr(as, XO_GROUP5, XOg_CALL, RID_RET); emit_loadu64(as, RID_RET, (uint64_t)target); return; } #endif *(int32_t *)(p-4) = jmprel(p, target); p[-5] = XI_CALL; as->mcp = p - 5; } #define emit_call(as, f) emit_call_(as, (MCode *)(void *)(f)) /* -- Emit generic operations --------------------------------------------- */ /* Use 64 bit operations to handle 64 bit IR types. */ #if LJ_64 #define REX_64IR(ir, r) ((r) + (irt_is64((ir)->t) ? REX_64 : 0)) #else #define REX_64IR(ir, r) (r) #endif /* Generic move between two regs. */ static void emit_movrr(ASMState *as, IRIns *ir, Reg dst, Reg src) { UNUSED(ir); if (dst < RID_MAX_GPR) emit_rr(as, XO_MOV, REX_64IR(ir, dst), src); else emit_rr(as, XMM_MOVRR(as), dst, src); } /* Generic load of register from stack slot. */ static void emit_spload(ASMState *as, IRIns *ir, Reg r, int32_t ofs) { if (r < RID_MAX_GPR) emit_rmro(as, XO_MOV, REX_64IR(ir, r), RID_ESP, ofs); else emit_rmro(as, irt_isnum(ir->t) ? XMM_MOVRM(as) : XO_MOVSS, r, RID_ESP, ofs); } /* Generic store of register to stack slot. */ static void emit_spstore(ASMState *as, IRIns *ir, Reg r, int32_t ofs) { if (r < RID_MAX_GPR) emit_rmro(as, XO_MOVto, REX_64IR(ir, r), RID_ESP, ofs); else emit_rmro(as, irt_isnum(ir->t) ? XO_MOVSDto : XO_MOVSSto, r, RID_ESP, ofs); } /* Add offset to pointer. */ static void emit_addptr(ASMState *as, Reg r, int32_t ofs) { if (ofs) { if ((as->flags & JIT_F_LEA_AGU)) emit_rmro(as, XO_LEA, r, r, ofs); else emit_gri(as, XG_ARITHi(XOg_ADD), r, ofs); } } #define emit_spsub(as, ofs) emit_addptr(as, RID_ESP|REX_64, -(ofs)) /* Prefer rematerialization of BASE/L from global_State over spills. */ #define emit_canremat(ref) ((ref) <= REF_BASE) ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_err.c ================================================ /* ** Error handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_err_c #define LUA_CORE #include "lj_obj.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_str.h" #include "lj_func.h" #include "lj_state.h" #include "lj_frame.h" #include "lj_ff.h" #include "lj_trace.h" #include "lj_vm.h" /* ** LuaJIT can either use internal or external frame unwinding: ** ** - Internal frame unwinding (INT) is free-standing and doesn't require ** any OS or library support. ** ** - External frame unwinding (EXT) uses the system-provided unwind handler. ** ** Pros and Cons: ** ** - EXT requires unwind tables for *all* functions on the C stack between ** the pcall/catch and the error/throw. This is the default on x64, ** but needs to be manually enabled on x86/PPC for non-C++ code. ** ** - INT is faster when actually throwing errors (but this happens rarely). ** Setting up error handlers is zero-cost in any case. ** ** - EXT provides full interoperability with C++ exceptions. You can throw ** Lua errors or C++ exceptions through a mix of Lua frames and C++ frames. ** C++ destructors are called as needed. C++ exceptions caught by pcall ** are converted to the string "C++ exception". Lua errors can be caught ** with catch (...) in C++. ** ** - INT has only limited support for automatically catching C++ exceptions ** on POSIX systems using DWARF2 stack unwinding. Other systems may use ** the wrapper function feature. Lua errors thrown through C++ frames ** cannot be caught by C++ code and C++ destructors are not run. ** ** EXT is the default on x64 systems, INT is the default on all other systems. ** ** EXT can be manually enabled on POSIX systems using GCC and DWARF2 stack ** unwinding with -DLUAJIT_UNWIND_EXTERNAL. *All* C code must be compiled ** with -funwind-tables (or -fexceptions). This includes LuaJIT itself (set ** TARGET_CFLAGS), all of your C/Lua binding code, all loadable C modules ** and all C libraries that have callbacks which may be used to call back ** into Lua. C++ code must *not* be compiled with -fno-exceptions. ** ** EXT cannot be enabled on WIN32 since system exceptions use code-driven SEH. ** EXT is mandatory on WIN64 since the calling convention has an abundance ** of callee-saved registers (rbx, rbp, rsi, rdi, r12-r15, xmm6-xmm15). ** EXT is mandatory on POSIX/x64 since the interpreter doesn't save r12/r13. */ #if defined(__GNUC__) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)) #define LJ_UNWIND_EXT 1 #elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS #define LJ_UNWIND_EXT 1 #endif /* -- Error messages ------------------------------------------------------ */ /* Error message strings. */ LJ_DATADEF const char *lj_err_allmsg = #define ERRDEF(name, msg) msg "\0" #include "lj_errmsg.h" ; /* -- Internal frame unwinding -------------------------------------------- */ /* Unwind Lua stack and move error message to new top. */ LJ_NOINLINE static void unwindstack(lua_State *L, TValue *top) { lj_func_closeuv(L, top); if (top < L->top-1) { copyTV(L, top, L->top-1); L->top = top+1; } lj_state_relimitstack(L); } /* Unwind until stop frame. Optionally cleanup frames. */ static void *err_unwind(lua_State *L, void *stopcf, int errcode) { TValue *frame = L->base-1; void *cf = L->cframe; while (cf) { int32_t nres = cframe_nres(cframe_raw(cf)); if (nres < 0) { /* C frame without Lua frame? */ TValue *top = restorestack(L, -nres); if (frame < top) { /* Frame reached? */ if (errcode) { L->cframe = cframe_prev(cf); L->base = frame+1; unwindstack(L, top); } return cf; } } if (frame <= tvref(L->stack)) break; switch (frame_typep(frame)) { case FRAME_LUA: /* Lua frame. */ case FRAME_LUAP: frame = frame_prevl(frame); break; case FRAME_C: /* C frame. */ #if LJ_HASFFI unwind_c: #endif #if LJ_UNWIND_EXT if (errcode) { L->cframe = cframe_prev(cf); L->base = frame_prevd(frame) + 1; unwindstack(L, frame); } else if (cf != stopcf) { cf = cframe_prev(cf); frame = frame_prevd(frame); break; } return NULL; /* Continue unwinding. */ #else UNUSED(stopcf); cf = cframe_prev(cf); frame = frame_prevd(frame); break; #endif case FRAME_CP: /* Protected C frame. */ if (cframe_canyield(cf)) { /* Resume? */ if (errcode) { hook_leave(G(L)); /* Assumes nobody uses coroutines inside hooks. */ L->cframe = NULL; L->status = (uint8_t)errcode; } return cf; } if (errcode) { L->cframe = cframe_prev(cf); L->base = frame_prevd(frame) + 1; unwindstack(L, frame); } return cf; case FRAME_CONT: /* Continuation frame. */ #if LJ_HASFFI if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) goto unwind_c; #endif case FRAME_VARG: /* Vararg frame. */ frame = frame_prevd(frame); break; case FRAME_PCALL: /* FF pcall() frame. */ case FRAME_PCALLH: /* FF pcall() frame inside hook. */ if (errcode) { if (errcode == LUA_YIELD) { frame = frame_prevd(frame); break; } if (frame_typep(frame) == FRAME_PCALL) hook_leave(G(L)); L->cframe = cf; L->base = frame_prevd(frame) + 1; unwindstack(L, L->base); } return (void *)((intptr_t)cf | CFRAME_UNWIND_FF); } } /* No C frame. */ if (errcode) { L->cframe = NULL; L->base = tvref(L->stack)+1; unwindstack(L, L->base); if (G(L)->panic) G(L)->panic(L); exit(EXIT_FAILURE); } return L; /* Anything non-NULL will do. */ } /* -- External frame unwinding -------------------------------------------- */ #if defined(__GNUC__) && !LJ_NO_UNWIND && !LJ_TARGET_WINDOWS /* ** We have to use our own definitions instead of the mandatory (!) unwind.h, ** since various OS, distros and compilers mess up the header installation. */ typedef struct _Unwind_Exception { uint64_t exclass; void (*excleanup)(int, struct _Unwind_Exception); uintptr_t p1, p2; } __attribute__((__aligned__)) _Unwind_Exception; typedef struct _Unwind_Context _Unwind_Context; #define _URC_OK 0 #define _URC_FATAL_PHASE1_ERROR 3 #define _URC_HANDLER_FOUND 6 #define _URC_INSTALL_CONTEXT 7 #define _URC_CONTINUE_UNWIND 8 #define _URC_FAILURE 9 #if !LJ_TARGET_ARM extern uintptr_t _Unwind_GetCFA(_Unwind_Context *); extern void _Unwind_SetGR(_Unwind_Context *, int, uintptr_t); extern void _Unwind_SetIP(_Unwind_Context *, uintptr_t); extern void _Unwind_DeleteException(_Unwind_Exception *); extern int _Unwind_RaiseException(_Unwind_Exception *); #define _UA_SEARCH_PHASE 1 #define _UA_CLEANUP_PHASE 2 #define _UA_HANDLER_FRAME 4 #define _UA_FORCE_UNWIND 8 #define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */ #define LJ_UEXCLASS_MAKE(c) (LJ_UEXCLASS | (uint64_t)(c)) #define LJ_UEXCLASS_CHECK(cl) (((cl) ^ LJ_UEXCLASS) <= 0xff) #define LJ_UEXCLASS_ERRCODE(cl) ((int)((cl) & 0xff)) /* DWARF2 personality handler referenced from interpreter .eh_frame. */ LJ_FUNCA int lj_err_unwind_dwarf(int version, int actions, uint64_t uexclass, _Unwind_Exception *uex, _Unwind_Context *ctx) { void *cf; lua_State *L; if (version != 1) return _URC_FATAL_PHASE1_ERROR; UNUSED(uexclass); cf = (void *)_Unwind_GetCFA(ctx); L = cframe_L(cf); if ((actions & _UA_SEARCH_PHASE)) { #if LJ_UNWIND_EXT if (err_unwind(L, cf, 0) == NULL) return _URC_CONTINUE_UNWIND; #endif if (!LJ_UEXCLASS_CHECK(uexclass)) { setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); } return _URC_HANDLER_FOUND; } if ((actions & _UA_CLEANUP_PHASE)) { int errcode; if (LJ_UEXCLASS_CHECK(uexclass)) { errcode = LJ_UEXCLASS_ERRCODE(uexclass); } else { if ((actions & _UA_HANDLER_FRAME)) _Unwind_DeleteException(uex); errcode = LUA_ERRRUN; } #if LJ_UNWIND_EXT cf = err_unwind(L, cf, errcode); if ((actions & _UA_FORCE_UNWIND)) { return _URC_CONTINUE_UNWIND; } else if (cf) { _Unwind_SetGR(ctx, LJ_TARGET_EHRETREG, errcode); _Unwind_SetIP(ctx, (uintptr_t)(cframe_unwind_ff(cf) ? lj_vm_unwind_ff_eh : lj_vm_unwind_c_eh)); return _URC_INSTALL_CONTEXT; } #if LJ_TARGET_X86ORX64 else if ((actions & _UA_HANDLER_FRAME)) { /* Workaround for ancient libgcc bug. Still present in RHEL 5.5. :-/ ** Real fix: http://gcc.gnu.org/viewcvs/trunk/gcc/unwind-dw2.c?r1=121165&r2=124837&pathrev=153877&diff_format=h */ _Unwind_SetGR(ctx, LJ_TARGET_EHRETREG, errcode); _Unwind_SetIP(ctx, (uintptr_t)lj_vm_unwind_rethrow); return _URC_INSTALL_CONTEXT; } #endif #else /* This is not the proper way to escape from the unwinder. We get away with ** it on non-x64 because the interpreter restores all callee-saved regs. */ lj_err_throw(L, errcode); #endif } return _URC_CONTINUE_UNWIND; } #if LJ_UNWIND_EXT #if LJ_TARGET_OSX || defined(__OpenBSD__) /* Sorry, no thread safety for OSX. Complain to Apple, not me. */ static _Unwind_Exception static_uex; #else static __thread _Unwind_Exception static_uex; #endif /* Raise DWARF2 exception. */ static void err_raise_ext(int errcode) { static_uex.exclass = LJ_UEXCLASS_MAKE(errcode); static_uex.excleanup = NULL; _Unwind_RaiseException(&static_uex); } #endif #else extern void _Unwind_DeleteException(void *); extern int __gnu_unwind_frame (void *, _Unwind_Context *); extern int _Unwind_VRS_Set(_Unwind_Context *, int, uint32_t, int, void *); extern int _Unwind_VRS_Get(_Unwind_Context *, int, uint32_t, int, void *); static inline uint32_t _Unwind_GetGR(_Unwind_Context *ctx, int r) { uint32_t v; _Unwind_VRS_Get(ctx, 0, r, 0, &v); return v; } static inline void _Unwind_SetGR(_Unwind_Context *ctx, int r, uint32_t v) { _Unwind_VRS_Set(ctx, 0, r, 0, &v); } #define _US_VIRTUAL_UNWIND_FRAME 0 #define _US_UNWIND_FRAME_STARTING 1 #define _US_ACTION_MASK 3 #define _US_FORCE_UNWIND 8 /* ARM unwinder personality handler referenced from interpreter .ARM.extab. */ LJ_FUNCA int lj_err_unwind_arm(int state, void *ucb, _Unwind_Context *ctx) { void *cf = (void *)_Unwind_GetGR(ctx, 13); lua_State *L = cframe_L(cf); if ((state & _US_ACTION_MASK) == _US_VIRTUAL_UNWIND_FRAME) { setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); return _URC_HANDLER_FOUND; } if ((state&(_US_ACTION_MASK|_US_FORCE_UNWIND)) == _US_UNWIND_FRAME_STARTING) { _Unwind_DeleteException(ucb); _Unwind_SetGR(ctx, 15, (uint32_t)(void *)lj_err_throw); _Unwind_SetGR(ctx, 0, (uint32_t)L); _Unwind_SetGR(ctx, 1, (uint32_t)LUA_ERRRUN); return _URC_INSTALL_CONTEXT; } if (__gnu_unwind_frame(ucb, ctx) != _URC_OK) return _URC_FAILURE; return _URC_CONTINUE_UNWIND; } #endif #elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS /* ** Someone in Redmond owes me several days of my life. A lot of this is ** undocumented or just plain wrong on MSDN. Some of it can be gathered ** from 3rd party docs or must be found by trial-and-error. They really ** don't want you to write your own language-specific exception handler ** or to interact gracefully with MSVC. :-( ** ** Apparently MSVC doesn't call C++ destructors for foreign exceptions ** unless you compile your C++ code with /EHa. Unfortunately this means ** catch (...) also catches things like access violations. The use of ** _set_se_translator doesn't really help, because it requires /EHa, too. */ #define WIN32_LEAN_AND_MEAN #include /* Taken from: http://www.nynaeve.net/?p=99 */ typedef struct UndocumentedDispatcherContext { ULONG64 ControlPc; ULONG64 ImageBase; PRUNTIME_FUNCTION FunctionEntry; ULONG64 EstablisherFrame; ULONG64 TargetIp; PCONTEXT ContextRecord; PEXCEPTION_ROUTINE LanguageHandler; PVOID HandlerData; PUNWIND_HISTORY_TABLE HistoryTable; ULONG ScopeIndex; ULONG Fill0; } UndocumentedDispatcherContext; #ifdef _MSC_VER /* Another wild guess. */ extern __DestructExceptionObject(EXCEPTION_RECORD *rec, int nothrow); #endif #define LJ_MSVC_EXCODE ((DWORD)0xe06d7363) #define LJ_EXCODE ((DWORD)0xe24c4a00) #define LJ_EXCODE_MAKE(c) (LJ_EXCODE | (DWORD)(c)) #define LJ_EXCODE_CHECK(cl) (((cl) ^ LJ_EXCODE) <= 0xff) #define LJ_EXCODE_ERRCODE(cl) ((int)((cl) & 0xff)) /* Win64 exception handler for interpreter frame. */ LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec, void *cf, CONTEXT *ctx, UndocumentedDispatcherContext *dispatch) { lua_State *L = cframe_L(cf); int errcode = LJ_EXCODE_CHECK(rec->ExceptionCode) ? LJ_EXCODE_ERRCODE(rec->ExceptionCode) : LUA_ERRRUN; if ((rec->ExceptionFlags & 6)) { /* EH_UNWINDING|EH_EXIT_UNWIND */ /* Unwind internal frames. */ err_unwind(L, cf, errcode); } else { void *cf2 = err_unwind(L, cf, 0); if (cf2) { /* We catch it, so start unwinding the upper frames. */ if (rec->ExceptionCode == LJ_MSVC_EXCODE) { #ifdef _MSC_VER __DestructExceptionObject(rec, 1); #endif setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) { /* Don't catch access violations etc. */ return ExceptionContinueSearch; } /* Unwind the stack and call all handlers for all lower C frames ** (including ourselves) again with EH_UNWINDING set. Then set ** rsp = cf, rax = errcode and jump to the specified target. */ RtlUnwindEx(cf, (void *)((cframe_unwind_ff(cf2) && errcode != LUA_YIELD) ? lj_vm_unwind_ff_eh : lj_vm_unwind_c_eh), rec, (void *)errcode, ctx, dispatch->HistoryTable); /* RtlUnwindEx should never return. */ } } return ExceptionContinueSearch; } /* Raise Windows exception. */ static void err_raise_ext(int errcode) { RaiseException(LJ_EXCODE_MAKE(errcode), 1 /* EH_NONCONTINUABLE */, 0, NULL); } #endif /* -- Error handling ------------------------------------------------------ */ /* Throw error. Find catch frame, unwind stack and continue. */ LJ_NOINLINE void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode) { global_State *g = G(L); lj_trace_abort(g); setgcrefnull(g->jit_L); L->status = 0; #if LJ_UNWIND_EXT err_raise_ext(errcode); /* ** A return from this function signals a corrupt C stack that cannot be ** unwound. We have no choice but to call the panic function and exit. ** ** Usually this is caused by a C function without unwind information. ** This should never happen on x64, but may happen if you've manually ** enabled LUAJIT_UNWIND_EXTERNAL and forgot to recompile *every* ** non-C++ file with -funwind-tables. */ if (G(L)->panic) G(L)->panic(L); #else { void *cf = err_unwind(L, NULL, errcode); if (cframe_unwind_ff(cf)) lj_vm_unwind_ff(cframe_raw(cf)); else lj_vm_unwind_c(cframe_raw(cf), errcode); } #endif exit(EXIT_FAILURE); } /* Return string object for error message. */ LJ_NOINLINE GCstr *lj_err_str(lua_State *L, ErrMsg em) { return lj_str_newz(L, err2msg(em)); } /* Out-of-memory error. */ LJ_NOINLINE void lj_err_mem(lua_State *L) { if (L->status == LUA_ERRERR+1) /* Don't touch the stack during lua_open. */ lj_vm_unwind_c(L->cframe, LUA_ERRMEM); setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRMEM)); lj_err_throw(L, LUA_ERRMEM); } /* Find error function for runtime errors. Requires an extra stack traversal. */ static ptrdiff_t finderrfunc(lua_State *L) { cTValue *frame = L->base-1, *bot = tvref(L->stack); void *cf = L->cframe; while (frame > bot) { lua_assert(cf != NULL); while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */ if (frame >= restorestack(L, -cframe_nres(cf))) break; if (cframe_errfunc(cf) >= 0) /* Error handler not inherited (-1)? */ return cframe_errfunc(cf); cf = cframe_prev(cf); /* Else unwind cframe and continue searching. */ if (cf == NULL) return 0; } switch (frame_typep(frame)) { case FRAME_LUA: case FRAME_LUAP: frame = frame_prevl(frame); break; case FRAME_C: cf = cframe_prev(cf); /* fallthrough */ case FRAME_CONT: #if LJ_HASFFI if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) cf = cframe_prev(cf); #endif case FRAME_VARG: frame = frame_prevd(frame); break; case FRAME_CP: if (cframe_canyield(cf)) return 0; if (cframe_errfunc(cf) >= 0) return cframe_errfunc(cf); frame = frame_prevd(frame); break; case FRAME_PCALL: case FRAME_PCALLH: if (frame_ftsz(frame) >= (ptrdiff_t)(2*sizeof(TValue))) /* xpcall? */ return savestack(L, frame-1); /* Point to xpcall's errorfunc. */ return 0; default: lua_assert(0); return 0; } } return 0; } /* Runtime error. */ LJ_NOINLINE void lj_err_run(lua_State *L) { ptrdiff_t ef = finderrfunc(L); if (ef) { TValue *errfunc = restorestack(L, ef); TValue *top = L->top; lj_trace_abort(G(L)); if (!tvisfunc(errfunc) || L->status == LUA_ERRERR) { setstrV(L, top-1, lj_err_str(L, LJ_ERR_ERRERR)); lj_err_throw(L, LUA_ERRERR); } L->status = LUA_ERRERR; copyTV(L, top, top-1); copyTV(L, top-1, errfunc); L->top = top+1; lj_vm_call(L, top, 1+1); /* Stack: |errfunc|msg| -> |msg| */ } lj_err_throw(L, LUA_ERRRUN); } /* Formatted runtime error message. */ LJ_NORET LJ_NOINLINE static void err_msgv(lua_State *L, ErrMsg em, ...) { const char *msg; va_list argp; va_start(argp, em); if (curr_funcisL(L)) L->top = curr_topL(L); msg = lj_str_pushvf(L, err2msg(em), argp); va_end(argp); lj_debug_addloc(L, msg, L->base-1, NULL); lj_err_run(L); } /* Non-vararg variant for better calling conventions. */ LJ_NOINLINE void lj_err_msg(lua_State *L, ErrMsg em) { err_msgv(L, em); } /* Lexer error. */ LJ_NOINLINE void lj_err_lex(lua_State *L, GCstr *src, const char *tok, BCLine line, ErrMsg em, va_list argp) { char buff[LUA_IDSIZE]; const char *msg; lj_debug_shortname(buff, src); msg = lj_str_pushvf(L, err2msg(em), argp); msg = lj_str_pushf(L, "%s:%d: %s", buff, line, msg); if (tok) lj_str_pushf(L, err2msg(LJ_ERR_XNEAR), msg, tok); lj_err_throw(L, LUA_ERRSYNTAX); } /* Typecheck error for operands. */ LJ_NOINLINE void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm) { const char *tname = lj_typename(o); const char *opname = err2msg(opm); if (curr_funcisL(L)) { GCproto *pt = curr_proto(L); const BCIns *pc = cframe_Lpc(L) - 1; const char *oname = NULL; const char *kind = lj_debug_slotname(pt, pc, (BCReg)(o-L->base), &oname); if (kind) err_msgv(L, LJ_ERR_BADOPRT, opname, kind, oname, tname); } err_msgv(L, LJ_ERR_BADOPRV, opname, tname); } /* Typecheck error for ordered comparisons. */ LJ_NOINLINE void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2) { const char *t1 = lj_typename(o1); const char *t2 = lj_typename(o2); err_msgv(L, t1 == t2 ? LJ_ERR_BADCMPV : LJ_ERR_BADCMPT, t1, t2); /* This assumes the two "boolean" entries are commoned by the C compiler. */ } /* Typecheck error for __call. */ LJ_NOINLINE void lj_err_optype_call(lua_State *L, TValue *o) { /* Gross hack if lua_[p]call or pcall/xpcall fail for a non-callable object: ** L->base still points to the caller. So add a dummy frame with L instead ** of a function. See lua_getstack(). */ const BCIns *pc = cframe_Lpc(L); if (((ptrdiff_t)pc & FRAME_TYPE) != FRAME_LUA) { const char *tname = lj_typename(o); setframe_pc(o, pc); setframe_gc(o, obj2gco(L)); L->top = L->base = o+1; err_msgv(L, LJ_ERR_BADCALL, tname); } lj_err_optype(L, o, LJ_ERR_OPCALL); } /* Error in context of caller. */ LJ_NOINLINE void lj_err_callermsg(lua_State *L, const char *msg) { TValue *frame = L->base-1; TValue *pframe = NULL; if (frame_islua(frame)) { pframe = frame_prevl(frame); } else if (frame_iscont(frame)) { #if LJ_HASFFI if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) { pframe = frame; frame = NULL; } else #endif { pframe = frame_prevd(frame); #if LJ_HASFFI /* Remove frame for FFI metamethods. */ if (frame_func(frame)->c.ffid >= FF_ffi_meta___index && frame_func(frame)->c.ffid <= FF_ffi_meta___tostring) { L->base = pframe+1; L->top = frame; setcframe_pc(cframe_raw(L->cframe), frame_contpc(frame)); } #endif } } lj_debug_addloc(L, msg, pframe, frame); lj_err_run(L); } /* Formatted error in context of caller. */ LJ_NOINLINE void lj_err_callerv(lua_State *L, ErrMsg em, ...) { const char *msg; va_list argp; va_start(argp, em); msg = lj_str_pushvf(L, err2msg(em), argp); va_end(argp); lj_err_callermsg(L, msg); } /* Error in context of caller. */ LJ_NOINLINE void lj_err_caller(lua_State *L, ErrMsg em) { lj_err_callermsg(L, err2msg(em)); } /* Argument error message. */ LJ_NORET LJ_NOINLINE static void err_argmsg(lua_State *L, int narg, const char *msg) { const char *fname = "?"; const char *ftype = lj_debug_funcname(L, L->base - 1, &fname); if (narg < 0 && narg > LUA_REGISTRYINDEX) narg = (int)(L->top - L->base) + narg + 1; if (ftype && ftype[3] == 'h' && --narg == 0) /* Check for "method". */ msg = lj_str_pushf(L, err2msg(LJ_ERR_BADSELF), fname, msg); else msg = lj_str_pushf(L, err2msg(LJ_ERR_BADARG), narg, fname, msg); lj_err_callermsg(L, msg); } /* Formatted argument error. */ LJ_NOINLINE void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...) { const char *msg; va_list argp; va_start(argp, em); msg = lj_str_pushvf(L, err2msg(em), argp); va_end(argp); err_argmsg(L, narg, msg); } /* Argument error. */ LJ_NOINLINE void lj_err_arg(lua_State *L, int narg, ErrMsg em) { err_argmsg(L, narg, err2msg(em)); } /* Typecheck error for arguments. */ LJ_NOINLINE void lj_err_argtype(lua_State *L, int narg, const char *xname) { TValue *o = narg < 0 ? L->top + narg : L->base + narg-1; const char *tname = o < L->top ? lj_typename(o) : lj_obj_typename[0]; const char *msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname); err_argmsg(L, narg, msg); } /* Typecheck error for arguments. */ LJ_NOINLINE void lj_err_argt(lua_State *L, int narg, int tt) { lj_err_argtype(L, narg, lj_obj_typename[tt+1]); } /* -- Public error handling API ------------------------------------------- */ LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf) { lua_CFunction old = G(L)->panic; G(L)->panic = panicf; return old; } /* Forwarders for the public API (C calling convention and no LJ_NORET). */ LUA_API int lua_error(lua_State *L) { lj_err_run(L); return 0; /* unreachable */ } LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *msg) { err_argmsg(L, narg, msg); return 0; /* unreachable */ } LUALIB_API int luaL_typerror(lua_State *L, int narg, const char *xname) { lj_err_argtype(L, narg, xname); return 0; /* unreachable */ } LUALIB_API void luaL_where(lua_State *L, int level) { int size; cTValue *frame = lj_debug_frame(L, level, &size); lj_debug_addloc(L, "", frame, size ? frame+size : NULL); } LUALIB_API int luaL_error(lua_State *L, const char *fmt, ...) { const char *msg; va_list argp; va_start(argp, fmt); msg = lj_str_pushvf(L, fmt, argp); va_end(argp); lj_err_callermsg(L, msg); return 0; /* unreachable */ } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_err.h ================================================ /* ** Error handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_ERR_H #define _LJ_ERR_H #include #include "lj_obj.h" typedef enum { #define ERRDEF(name, msg) \ LJ_ERR_##name, LJ_ERR_##name##_ = LJ_ERR_##name + sizeof(msg)-1, #include "lj_errmsg.h" LJ_ERR__MAX } ErrMsg; LJ_DATA const char *lj_err_allmsg; #define err2msg(em) (lj_err_allmsg+(int)(em)) LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em); LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode); LJ_FUNC_NORET void lj_err_mem(lua_State *L); LJ_FUNC_NORET void lj_err_run(lua_State *L); LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em); LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok, BCLine line, ErrMsg em, va_list argp); LJ_FUNC_NORET void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm); LJ_FUNC_NORET void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2); LJ_FUNC_NORET void lj_err_optype_call(lua_State *L, TValue *o); LJ_FUNC_NORET void lj_err_callermsg(lua_State *L, const char *msg); LJ_FUNC_NORET void lj_err_callerv(lua_State *L, ErrMsg em, ...); LJ_FUNC_NORET void lj_err_caller(lua_State *L, ErrMsg em); LJ_FUNC_NORET void lj_err_arg(lua_State *L, int narg, ErrMsg em); LJ_FUNC_NORET void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...); LJ_FUNC_NORET void lj_err_argtype(lua_State *L, int narg, const char *xname); LJ_FUNC_NORET void lj_err_argt(lua_State *L, int narg, int tt); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_errmsg.h ================================================ /* ** VM error messages. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* This file may be included multiple times with different ERRDEF macros. */ /* Basic error handling. */ ERRDEF(ERRMEM, "not enough memory") ERRDEF(ERRERR, "error in error handling") ERRDEF(ERRCPP, "C++ exception") /* Allocations. */ ERRDEF(STROV, "string length overflow") ERRDEF(UDATAOV, "userdata length overflow") ERRDEF(STKOV, "stack overflow") ERRDEF(STKOVM, "stack overflow (%s)") ERRDEF(TABOV, "table overflow") /* Table indexing. */ ERRDEF(NANIDX, "table index is NaN") ERRDEF(NILIDX, "table index is nil") ERRDEF(NEXTIDX, "invalid key to " LUA_QL("next")) /* Metamethod resolving. */ ERRDEF(BADCALL, "attempt to call a %s value") ERRDEF(BADOPRT, "attempt to %s %s " LUA_QS " (a %s value)") ERRDEF(BADOPRV, "attempt to %s a %s value") ERRDEF(BADCMPT, "attempt to compare %s with %s") ERRDEF(BADCMPV, "attempt to compare two %s values") ERRDEF(GETLOOP, "loop in gettable") ERRDEF(SETLOOP, "loop in settable") ERRDEF(OPCALL, "call") ERRDEF(OPINDEX, "index") ERRDEF(OPARITH, "perform arithmetic on") ERRDEF(OPCAT, "concatenate") ERRDEF(OPLEN, "get length of") /* Type checks. */ ERRDEF(BADSELF, "calling " LUA_QS " on bad self (%s)") ERRDEF(BADARG, "bad argument #%d to " LUA_QS " (%s)") ERRDEF(BADTYPE, "%s expected, got %s") ERRDEF(BADVAL, "invalid value") ERRDEF(NOVAL, "value expected") ERRDEF(NOCORO, "coroutine expected") ERRDEF(NOTABN, "nil or table expected") ERRDEF(NOLFUNC, "Lua function expected") ERRDEF(NOFUNCL, "function or level expected") ERRDEF(NOSFT, "string/function/table expected") ERRDEF(NOPROXY, "boolean or proxy expected") ERRDEF(FORINIT, LUA_QL("for") " initial value must be a number") ERRDEF(FORLIM, LUA_QL("for") " limit must be a number") ERRDEF(FORSTEP, LUA_QL("for") " step must be a number") /* C API checks. */ ERRDEF(NOENV, "no calling environment") ERRDEF(CYIELD, "attempt to yield across C-call boundary") ERRDEF(BADLU, "bad light userdata pointer") ERRDEF(NOGCMM, "bad action while in __gc metamethod") #if LJ_TARGET_WINDOWS ERRDEF(BADFPU, "bad FPU precision (use D3DCREATE_FPU_PRESERVE with DirectX)") #endif /* Standard library function errors. */ ERRDEF(ASSERT, "assertion failed!") ERRDEF(PROTMT, "cannot change a protected metatable") ERRDEF(UNPACK, "too many results to unpack") ERRDEF(RDRSTR, "reader function must return a string") ERRDEF(PRTOSTR, LUA_QL("tostring") " must return a string to " LUA_QL("print")) ERRDEF(IDXRNG, "index out of range") ERRDEF(BASERNG, "base out of range") ERRDEF(LVLRNG, "level out of range") ERRDEF(INVLVL, "invalid level") ERRDEF(INVOPT, "invalid option") ERRDEF(INVOPTM, "invalid option " LUA_QS) ERRDEF(INVFMT, "invalid format") ERRDEF(SETFENV, LUA_QL("setfenv") " cannot change environment of given object") ERRDEF(CORUN, "cannot resume running coroutine") ERRDEF(CODEAD, "cannot resume dead coroutine") ERRDEF(COSUSP, "cannot resume non-suspended coroutine") ERRDEF(TABINS, "wrong number of arguments to " LUA_QL("insert")) ERRDEF(TABCAT, "invalid value (%s) at index %d in table for " LUA_QL("concat")) ERRDEF(TABSORT, "invalid order function for sorting") ERRDEF(IOCLFL, "attempt to use a closed file") ERRDEF(IOSTDCL, "standard file is closed") ERRDEF(OSUNIQF, "unable to generate a unique filename") ERRDEF(OSDATEF, "field " LUA_QS " missing in date table") ERRDEF(STRDUMP, "unable to dump given function") ERRDEF(STRSLC, "string slice too long") ERRDEF(STRPATB, "missing " LUA_QL("[") " after " LUA_QL("%f") " in pattern") ERRDEF(STRPATC, "invalid pattern capture") ERRDEF(STRPATE, "malformed pattern (ends with " LUA_QL("%") ")") ERRDEF(STRPATM, "malformed pattern (missing " LUA_QL("]") ")") ERRDEF(STRPATU, "unbalanced pattern") ERRDEF(STRPATX, "pattern too complex") ERRDEF(STRCAPI, "invalid capture index") ERRDEF(STRCAPN, "too many captures") ERRDEF(STRCAPU, "unfinished capture") ERRDEF(STRFMTO, "invalid option " LUA_QL("%%%c") " to " LUA_QL("format")) ERRDEF(STRFMTR, "invalid format (repeated flags)") ERRDEF(STRFMTW, "invalid format (width or precision too long)") ERRDEF(STRGSRV, "invalid replacement value (a %s)") ERRDEF(BADMODN, "name conflict for module " LUA_QS) #if LJ_HASJIT #if LJ_TARGET_X86ORX64 ERRDEF(NOJIT, "JIT compiler disabled, CPU does not support SSE2") #else ERRDEF(NOJIT, "JIT compiler disabled") #endif #elif defined(LJ_ARCH_NOJIT) ERRDEF(NOJIT, "no JIT compiler for this architecture (yet)") #else ERRDEF(NOJIT, "JIT compiler permanently disabled by build option") #endif ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS) /* Lexer/parser errors. */ ERRDEF(XMODE, "attempt to load chunk with wrong mode") ERRDEF(XNEAR, "%s near " LUA_QS) ERRDEF(XELEM, "lexical element too long") ERRDEF(XLINES, "chunk has too many lines") ERRDEF(XLEVELS, "chunk has too many syntax levels") ERRDEF(XNUMBER, "malformed number") ERRDEF(XLSTR, "unfinished long string") ERRDEF(XLCOM, "unfinished long comment") ERRDEF(XSTR, "unfinished string") ERRDEF(XESC, "invalid escape sequence") ERRDEF(XLDELIM, "invalid long string delimiter") ERRDEF(XTOKEN, LUA_QS " expected") ERRDEF(XJUMP, "control structure too long") ERRDEF(XSLOTS, "function or expression too complex") ERRDEF(XLIMC, "chunk has more than %d local variables") ERRDEF(XLIMM, "main function has more than %d %s") ERRDEF(XLIMF, "function at line %d has more than %d %s") ERRDEF(XMATCH, LUA_QS " expected (to close " LUA_QS " at line %d)") ERRDEF(XFIXUP, "function too long for return fixup") ERRDEF(XPARAM, " or " LUA_QL("...") " expected") #if !LJ_52 ERRDEF(XAMBIG, "ambiguous syntax (function call x new statement)") #endif ERRDEF(XFUNARG, "function arguments expected") ERRDEF(XSYMBOL, "unexpected symbol") ERRDEF(XDOTS, "cannot use " LUA_QL("...") " outside a vararg function") ERRDEF(XSYNTAX, "syntax error") ERRDEF(XFOR, LUA_QL("=") " or " LUA_QL("in") " expected") ERRDEF(XBREAK, "no loop to break") ERRDEF(XLUNDEF, "undefined label " LUA_QS) ERRDEF(XLDUP, "duplicate label " LUA_QS) ERRDEF(XGSCOPE, " jumps into the scope of local " LUA_QS) /* Bytecode reader errors. */ ERRDEF(BCFMT, "cannot load incompatible bytecode") ERRDEF(BCBAD, "cannot load malformed bytecode") #if LJ_HASFFI /* FFI errors. */ ERRDEF(FFI_INVTYPE, "invalid C type") ERRDEF(FFI_INVSIZE, "size of C type is unknown or too large") ERRDEF(FFI_BADSCL, "bad storage class") ERRDEF(FFI_DECLSPEC, "declaration specifier expected") ERRDEF(FFI_BADTAG, "undeclared or implicit tag " LUA_QS) ERRDEF(FFI_REDEF, "attempt to redefine " LUA_QS) ERRDEF(FFI_NUMPARAM, "wrong number of type parameters") ERRDEF(FFI_INITOV, "too many initializers for " LUA_QS) ERRDEF(FFI_BADCONV, "cannot convert " LUA_QS " to " LUA_QS) ERRDEF(FFI_BADLEN, "attempt to get length of " LUA_QS) ERRDEF(FFI_BADCONCAT, "attempt to concatenate " LUA_QS " and " LUA_QS) ERRDEF(FFI_BADARITH, "attempt to perform arithmetic on " LUA_QS " and " LUA_QS) ERRDEF(FFI_BADCOMP, "attempt to compare " LUA_QS " with " LUA_QS) ERRDEF(FFI_BADCALL, LUA_QS " is not callable") ERRDEF(FFI_NUMARG, "wrong number of arguments for function call") ERRDEF(FFI_BADMEMBER, LUA_QS " has no member named " LUA_QS) ERRDEF(FFI_BADIDX, LUA_QS " cannot be indexed") ERRDEF(FFI_BADIDXW, LUA_QS " cannot be indexed with " LUA_QS) ERRDEF(FFI_BADMM, LUA_QS " has no " LUA_QS " metamethod") ERRDEF(FFI_WRCONST, "attempt to write to constant location") ERRDEF(FFI_NODECL, "missing declaration for symbol " LUA_QS) ERRDEF(FFI_BADCBACK, "bad callback") #if LJ_OS_NOJIT ERRDEF(FFI_CBACKOV, "no support for callbacks on this OS") #else ERRDEF(FFI_CBACKOV, "too many callbacks") #endif ERRDEF(FFI_NYIPACKBIT, "NYI: packed bit fields") ERRDEF(FFI_NYICALL, "NYI: cannot call this C function (yet)") #endif #undef ERRDEF /* Detecting unused error messages: awk -F, '/^ERRDEF/ { gsub(/ERRDEF./, ""); printf "grep -q LJ_ERR_%s *.[ch] || echo %s\n", $1, $1}' lj_errmsg.h | sh */ ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ff.h ================================================ /* ** Fast function IDs. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_FF_H #define _LJ_FF_H /* Fast function ID. */ typedef enum { FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ FF_C_ = FF_C, /* Regular C function (must be 1). */ #define FFDEF(name) FF_##name, #include "lj_ffdef.h" FF__MAX } FastFunc; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ffrecord.c ================================================ /* ** Fast function call recorder. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_ffrecord_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_frame.h" #include "lj_bc.h" #include "lj_ff.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_ircall.h" #include "lj_iropt.h" #include "lj_trace.h" #include "lj_record.h" #include "lj_ffrecord.h" #include "lj_crecord.h" #include "lj_dispatch.h" #include "lj_vm.h" #include "lj_strscan.h" /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) /* Pass IR on to next optimization in chain (FOLD). */ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) /* -- Fast function recording handlers ------------------------------------ */ /* Conventions for fast function call handlers: ** ** The argument slots start at J->base[0]. All of them are guaranteed to be ** valid and type-specialized references. J->base[J->maxslot] is set to 0 ** as a sentinel. The runtime argument values start at rd->argv[0]. ** ** In general fast functions should check for presence of all of their ** arguments and for the correct argument types. Some simplifications ** are allowed if the interpreter throws instead. But even if recording ** is aborted, the generated IR must be consistent (no zero-refs). ** ** The number of results in rd->nres is set to 1. Handlers that return ** a different number of results need to override it. A negative value ** prevents return processing (e.g. for pending calls). ** ** Results need to be stored starting at J->base[0]. Return processing ** moves them to the right slots later. ** ** The per-ffid auxiliary data is the value of the 2nd part of the ** LJLIB_REC() annotation. This allows handling similar functionality ** in a common handler. */ /* Type of handler to record a fast function. */ typedef void (LJ_FASTCALL *RecordFunc)(jit_State *J, RecordFFData *rd); /* Get runtime value of int argument. */ static int32_t argv2int(jit_State *J, TValue *o) { if (!lj_strscan_numberobj(o)) lj_trace_err(J, LJ_TRERR_BADTYPE); return tvisint(o) ? intV(o) : lj_num2int(numV(o)); } /* Get runtime value of string argument. */ static GCstr *argv2str(jit_State *J, TValue *o) { if (LJ_LIKELY(tvisstr(o))) { return strV(o); } else { GCstr *s; if (!tvisnumber(o)) lj_trace_err(J, LJ_TRERR_BADTYPE); if (tvisint(o)) s = lj_str_fromint(J->L, intV(o)); else s = lj_str_fromnum(J->L, &o->n); setstrV(J->L, o, s); return s; } } /* Return number of results wanted by caller. */ static ptrdiff_t results_wanted(jit_State *J) { TValue *frame = J->L->base-1; if (frame_islua(frame)) return (ptrdiff_t)bc_b(frame_pc(frame)[-1]) - 1; else return -1; } /* Throw error for unsupported variant of fast function. */ LJ_NORET static void recff_nyiu(jit_State *J) { setfuncV(J->L, &J->errinfo, J->fn); lj_trace_err_info(J, LJ_TRERR_NYIFFU); } /* Fallback handler for all fast functions that are not recorded (yet). */ static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd) { setfuncV(J->L, &J->errinfo, J->fn); lj_trace_err_info(J, LJ_TRERR_NYIFF); UNUSED(rd); } /* C functions can have arbitrary side-effects and are not recorded (yet). */ static void LJ_FASTCALL recff_c(jit_State *J, RecordFFData *rd) { setfuncV(J->L, &J->errinfo, J->fn); lj_trace_err_info(J, LJ_TRERR_NYICF); UNUSED(rd); } /* -- Base library fast functions ----------------------------------------- */ static void LJ_FASTCALL recff_assert(jit_State *J, RecordFFData *rd) { /* Arguments already specialized. The interpreter throws for nil/false. */ rd->nres = J->maxslot; /* Pass through all arguments. */ } static void LJ_FASTCALL recff_type(jit_State *J, RecordFFData *rd) { /* Arguments already specialized. Result is a constant string. Neat, huh? */ uint32_t t; if (tvisnumber(&rd->argv[0])) t = ~LJ_TNUMX; else if (LJ_64 && tvislightud(&rd->argv[0])) t = ~LJ_TLIGHTUD; else t = ~itype(&rd->argv[0]); J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[t])); UNUSED(rd); } static void LJ_FASTCALL recff_getmetatable(jit_State *J, RecordFFData *rd) { TRef tr = J->base[0]; if (tr) { RecordIndex ix; ix.tab = tr; copyTV(J->L, &ix.tabv, &rd->argv[0]); if (lj_record_mm_lookup(J, &ix, MM_metatable)) J->base[0] = ix.mobj; else J->base[0] = ix.mt; } /* else: Interpreter will throw. */ } static void LJ_FASTCALL recff_setmetatable(jit_State *J, RecordFFData *rd) { TRef tr = J->base[0]; TRef mt = J->base[1]; if (tref_istab(tr) && (tref_istab(mt) || (mt && tref_isnil(mt)))) { TRef fref, mtref; RecordIndex ix; ix.tab = tr; copyTV(J->L, &ix.tabv, &rd->argv[0]); lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */ fref = emitir(IRT(IR_FREF, IRT_P32), tr, IRFL_TAB_META); mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt; emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref); if (!tref_isnil(mt)) emitir(IRT(IR_TBAR, IRT_TAB), tr, 0); J->base[0] = tr; J->needsnap = 1; } /* else: Interpreter will throw. */ } static void LJ_FASTCALL recff_rawget(jit_State *J, RecordFFData *rd) { RecordIndex ix; ix.tab = J->base[0]; ix.key = J->base[1]; if (tref_istab(ix.tab) && ix.key) { ix.val = 0; ix.idxchain = 0; settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); copyTV(J->L, &ix.keyv, &rd->argv[1]); J->base[0] = lj_record_idx(J, &ix); } /* else: Interpreter will throw. */ } static void LJ_FASTCALL recff_rawset(jit_State *J, RecordFFData *rd) { RecordIndex ix; ix.tab = J->base[0]; ix.key = J->base[1]; ix.val = J->base[2]; if (tref_istab(ix.tab) && ix.key && ix.val) { ix.idxchain = 0; settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); copyTV(J->L, &ix.keyv, &rd->argv[1]); copyTV(J->L, &ix.valv, &rd->argv[2]); lj_record_idx(J, &ix); /* Pass through table at J->base[0] as result. */ } /* else: Interpreter will throw. */ } static void LJ_FASTCALL recff_rawequal(jit_State *J, RecordFFData *rd) { TRef tra = J->base[0]; TRef trb = J->base[1]; if (tra && trb) { int diff = lj_record_objcmp(J, tra, trb, &rd->argv[0], &rd->argv[1]); J->base[0] = diff ? TREF_FALSE : TREF_TRUE; } /* else: Interpreter will throw. */ } #if LJ_52 static void LJ_FASTCALL recff_rawlen(jit_State *J, RecordFFData *rd) { TRef tr = J->base[0]; if (tref_isstr(tr)) J->base[0] = emitir(IRTI(IR_FLOAD), tr, IRFL_STR_LEN); else if (tref_istab(tr)) J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, tr); /* else: Interpreter will throw. */ UNUSED(rd); } #endif /* Determine mode of select() call. */ int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv) { if (tref_isstr(tr) && *strVdata(tv) == '#') { /* select('#', ...) */ if (strV(tv)->len == 1) { emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv))); } else { TRef trptr = emitir(IRT(IR_STRREF, IRT_P32), tr, lj_ir_kint(J, 0)); TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY); emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#')); } return 0; } else { /* select(n, ...) */ int32_t start = argv2int(J, tv); if (start == 0) lj_trace_err(J, LJ_TRERR_BADTYPE); /* A bit misleading. */ return start; } } static void LJ_FASTCALL recff_select(jit_State *J, RecordFFData *rd) { TRef tr = J->base[0]; if (tr) { ptrdiff_t start = lj_ffrecord_select_mode(J, tr, &rd->argv[0]); if (start == 0) { /* select('#', ...) */ J->base[0] = lj_ir_kint(J, J->maxslot - 1); } else if (tref_isk(tr)) { /* select(k, ...) */ ptrdiff_t n = (ptrdiff_t)J->maxslot; if (start < 0) start += n; else if (start > n) start = n; rd->nres = n - start; if (start >= 1) { ptrdiff_t i; for (i = 0; i < n - start; i++) J->base[i] = J->base[start+i]; } /* else: Interpreter will throw. */ } else { recff_nyiu(J); } } /* else: Interpreter will throw. */ } static void LJ_FASTCALL recff_tonumber(jit_State *J, RecordFFData *rd) { TRef tr = J->base[0]; TRef base = J->base[1]; if (tr && base) { base = lj_opt_narrow_toint(J, base); if (!tref_isk(base) || IR(tref_ref(base))->i != 10) recff_nyiu(J); } if (tref_isnumber_str(tr)) { if (tref_isstr(tr)) { TValue tmp; if (!lj_strscan_num(strV(&rd->argv[0]), &tmp)) recff_nyiu(J); /* Would need an inverted STRTO for this case. */ tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); } #if LJ_HASFFI } else if (tref_iscdata(tr)) { lj_crecord_tonumber(J, rd); return; #endif } else { tr = TREF_NIL; } J->base[0] = tr; UNUSED(rd); } static TValue *recff_metacall_cp(lua_State *L, lua_CFunction dummy, void *ud) { jit_State *J = (jit_State *)ud; lj_record_tailcall(J, 0, 1); UNUSED(L); UNUSED(dummy); return NULL; } static int recff_metacall(jit_State *J, RecordFFData *rd, MMS mm) { RecordIndex ix; ix.tab = J->base[0]; copyTV(J->L, &ix.tabv, &rd->argv[0]); if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */ int errcode; TValue argv0; /* Temporarily insert metamethod below object. */ J->base[1] = J->base[0]; J->base[0] = ix.mobj; copyTV(J->L, &argv0, &rd->argv[0]); copyTV(J->L, &rd->argv[1], &rd->argv[0]); copyTV(J->L, &rd->argv[0], &ix.mobjv); /* Need to protect lj_record_tailcall because it may throw. */ errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp); /* Always undo Lua stack changes to avoid confusing the interpreter. */ copyTV(J->L, &rd->argv[0], &argv0); if (errcode) lj_err_throw(J->L, errcode); /* Propagate errors. */ rd->nres = -1; /* Pending call. */ return 1; /* Tailcalled to metamethod. */ } return 0; } static void LJ_FASTCALL recff_tostring(jit_State *J, RecordFFData *rd) { TRef tr = J->base[0]; if (tref_isstr(tr)) { /* Ignore __tostring in the string base metatable. */ /* Pass on result in J->base[0]. */ } else if (!recff_metacall(J, rd, MM_tostring)) { if (tref_isnumber(tr)) { J->base[0] = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0); } else if (tref_ispri(tr)) { J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[tref_type(tr)])); } else { recff_nyiu(J); } } } static void LJ_FASTCALL recff_ipairs_aux(jit_State *J, RecordFFData *rd) { RecordIndex ix; ix.tab = J->base[0]; if (tref_istab(ix.tab)) { if (!tvisnumber(&rd->argv[1])) /* No support for string coercion. */ lj_trace_err(J, LJ_TRERR_BADTYPE); setintV(&ix.keyv, numberVint(&rd->argv[1])+1); settabV(J->L, &ix.tabv, tabV(&rd->argv[0])); ix.val = 0; ix.idxchain = 0; ix.key = lj_opt_narrow_toint(J, J->base[1]); J->base[0] = ix.key = emitir(IRTI(IR_ADD), ix.key, lj_ir_kint(J, 1)); J->base[1] = lj_record_idx(J, &ix); rd->nres = tref_isnil(J->base[1]) ? 0 : 2; } /* else: Interpreter will throw. */ } static void LJ_FASTCALL recff_ipairs(jit_State *J, RecordFFData *rd) { if (!(LJ_52 && recff_metacall(J, rd, MM_ipairs))) { TRef tab = J->base[0]; if (tref_istab(tab)) { J->base[0] = lj_ir_kfunc(J, funcV(&J->fn->c.upvalue[0])); J->base[1] = tab; J->base[2] = lj_ir_kint(J, 0); rd->nres = 3; } /* else: Interpreter will throw. */ } } static void LJ_FASTCALL recff_pcall(jit_State *J, RecordFFData *rd) { if (J->maxslot >= 1) { lj_record_call(J, 0, J->maxslot - 1); rd->nres = -1; /* Pending call. */ } /* else: Interpreter will throw. */ } static TValue *recff_xpcall_cp(lua_State *L, lua_CFunction dummy, void *ud) { jit_State *J = (jit_State *)ud; lj_record_call(J, 1, J->maxslot - 2); UNUSED(L); UNUSED(dummy); return NULL; } static void LJ_FASTCALL recff_xpcall(jit_State *J, RecordFFData *rd) { if (J->maxslot >= 2) { TValue argv0, argv1; TRef tmp; int errcode; /* Swap function and traceback. */ tmp = J->base[0]; J->base[0] = J->base[1]; J->base[1] = tmp; copyTV(J->L, &argv0, &rd->argv[0]); copyTV(J->L, &argv1, &rd->argv[1]); copyTV(J->L, &rd->argv[0], &argv1); copyTV(J->L, &rd->argv[1], &argv0); /* Need to protect lj_record_call because it may throw. */ errcode = lj_vm_cpcall(J->L, NULL, J, recff_xpcall_cp); /* Always undo Lua stack swap to avoid confusing the interpreter. */ copyTV(J->L, &rd->argv[0], &argv0); copyTV(J->L, &rd->argv[1], &argv1); if (errcode) lj_err_throw(J->L, errcode); /* Propagate errors. */ rd->nres = -1; /* Pending call. */ } /* else: Interpreter will throw. */ } /* -- Math library fast functions ----------------------------------------- */ static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd) { TRef tr = lj_ir_tonum(J, J->base[0]); J->base[0] = emitir(IRTN(IR_ABS), tr, lj_ir_knum_abs(J)); UNUSED(rd); } /* Record rounding functions math.floor and math.ceil. */ static void LJ_FASTCALL recff_math_round(jit_State *J, RecordFFData *rd) { TRef tr = J->base[0]; if (!tref_isinteger(tr)) { /* Pass through integers unmodified. */ tr = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, tr), rd->data); /* Result is integral (or NaN/Inf), but may not fit an int32_t. */ if (LJ_DUALNUM) { /* Try to narrow using a guarded conversion to int. */ lua_Number n = lj_vm_foldfpm(numberVnum(&rd->argv[0]), rd->data); if (n == (lua_Number)lj_num2int(n)) tr = emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_CHECK); } J->base[0] = tr; } } /* Record unary math.* functions, mapped to IR_FPMATH opcode. */ static void LJ_FASTCALL recff_math_unary(jit_State *J, RecordFFData *rd) { J->base[0] = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, J->base[0]), rd->data); } /* Record math.log. */ static void LJ_FASTCALL recff_math_log(jit_State *J, RecordFFData *rd) { TRef tr = lj_ir_tonum(J, J->base[0]); if (J->base[1]) { #ifdef LUAJIT_NO_LOG2 uint32_t fpm = IRFPM_LOG; #else uint32_t fpm = IRFPM_LOG2; #endif TRef trb = lj_ir_tonum(J, J->base[1]); tr = emitir(IRTN(IR_FPMATH), tr, fpm); trb = emitir(IRTN(IR_FPMATH), trb, fpm); trb = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), trb); tr = emitir(IRTN(IR_MUL), tr, trb); } else { tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_LOG); } J->base[0] = tr; UNUSED(rd); } /* Record math.atan2. */ static void LJ_FASTCALL recff_math_atan2(jit_State *J, RecordFFData *rd) { TRef tr = lj_ir_tonum(J, J->base[0]); TRef tr2 = lj_ir_tonum(J, J->base[1]); J->base[0] = emitir(IRTN(IR_ATAN2), tr, tr2); UNUSED(rd); } /* Record math.ldexp. */ static void LJ_FASTCALL recff_math_ldexp(jit_State *J, RecordFFData *rd) { TRef tr = lj_ir_tonum(J, J->base[0]); #if LJ_TARGET_X86ORX64 TRef tr2 = lj_ir_tonum(J, J->base[1]); #else TRef tr2 = lj_opt_narrow_toint(J, J->base[1]); #endif J->base[0] = emitir(IRTN(IR_LDEXP), tr, tr2); UNUSED(rd); } /* Record math.asin, math.acos, math.atan. */ static void LJ_FASTCALL recff_math_atrig(jit_State *J, RecordFFData *rd) { TRef y = lj_ir_tonum(J, J->base[0]); TRef x = lj_ir_knum_one(J); uint32_t ffid = rd->data; if (ffid != FF_math_atan) { TRef tmp = emitir(IRTN(IR_MUL), y, y); tmp = emitir(IRTN(IR_SUB), x, tmp); tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_SQRT); if (ffid == FF_math_asin) { x = tmp; } else { x = y; y = tmp; } } J->base[0] = emitir(IRTN(IR_ATAN2), y, x); } static void LJ_FASTCALL recff_math_htrig(jit_State *J, RecordFFData *rd) { TRef tr = lj_ir_tonum(J, J->base[0]); J->base[0] = emitir(IRTN(IR_CALLN), tr, rd->data); } static void LJ_FASTCALL recff_math_modf(jit_State *J, RecordFFData *rd) { TRef tr = J->base[0]; if (tref_isinteger(tr)) { J->base[0] = tr; J->base[1] = lj_ir_kint(J, 0); } else { TRef trt; tr = lj_ir_tonum(J, tr); trt = emitir(IRTN(IR_FPMATH), tr, IRFPM_TRUNC); J->base[0] = trt; J->base[1] = emitir(IRTN(IR_SUB), tr, trt); } rd->nres = 2; } static void LJ_FASTCALL recff_math_degrad(jit_State *J, RecordFFData *rd) { TRef tr = lj_ir_tonum(J, J->base[0]); TRef trm = lj_ir_knum(J, numV(&J->fn->c.upvalue[0])); J->base[0] = emitir(IRTN(IR_MUL), tr, trm); UNUSED(rd); } static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd) { TRef tr = lj_ir_tonum(J, J->base[0]); if (!tref_isnumber_str(J->base[1])) lj_trace_err(J, LJ_TRERR_BADTYPE); J->base[0] = lj_opt_narrow_pow(J, tr, J->base[1], &rd->argv[1]); UNUSED(rd); } static void LJ_FASTCALL recff_math_minmax(jit_State *J, RecordFFData *rd) { TRef tr = lj_ir_tonumber(J, J->base[0]); uint32_t op = rd->data; BCReg i; for (i = 1; J->base[i] != 0; i++) { TRef tr2 = lj_ir_tonumber(J, J->base[i]); IRType t = IRT_INT; if (!(tref_isinteger(tr) && tref_isinteger(tr2))) { if (tref_isinteger(tr)) tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); if (tref_isinteger(tr2)) tr2 = emitir(IRTN(IR_CONV), tr2, IRCONV_NUM_INT); t = IRT_NUM; } tr = emitir(IRT(op, t), tr, tr2); } J->base[0] = tr; } static void LJ_FASTCALL recff_math_random(jit_State *J, RecordFFData *rd) { GCudata *ud = udataV(&J->fn->c.upvalue[0]); TRef tr, one; lj_ir_kgc(J, obj2gco(ud), IRT_UDATA); /* Prevent collection. */ tr = lj_ir_call(J, IRCALL_lj_math_random_step, lj_ir_kptr(J, uddata(ud))); one = lj_ir_knum_one(J); tr = emitir(IRTN(IR_SUB), tr, one); if (J->base[0]) { TRef tr1 = lj_ir_tonum(J, J->base[0]); if (J->base[1]) { /* d = floor(d*(r2-r1+1.0)) + r1 */ TRef tr2 = lj_ir_tonum(J, J->base[1]); tr2 = emitir(IRTN(IR_SUB), tr2, tr1); tr2 = emitir(IRTN(IR_ADD), tr2, one); tr = emitir(IRTN(IR_MUL), tr, tr2); tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR); tr = emitir(IRTN(IR_ADD), tr, tr1); } else { /* d = floor(d*r1) + 1.0 */ tr = emitir(IRTN(IR_MUL), tr, tr1); tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR); tr = emitir(IRTN(IR_ADD), tr, one); } } J->base[0] = tr; UNUSED(rd); } /* -- Bit library fast functions ------------------------------------------ */ /* Record unary bit.tobit, bit.bnot, bit.bswap. */ static void LJ_FASTCALL recff_bit_unary(jit_State *J, RecordFFData *rd) { TRef tr = lj_opt_narrow_tobit(J, J->base[0]); J->base[0] = (rd->data == IR_TOBIT) ? tr : emitir(IRTI(rd->data), tr, 0); } /* Record N-ary bit.band, bit.bor, bit.bxor. */ static void LJ_FASTCALL recff_bit_nary(jit_State *J, RecordFFData *rd) { TRef tr = lj_opt_narrow_tobit(J, J->base[0]); uint32_t op = rd->data; BCReg i; for (i = 1; J->base[i] != 0; i++) tr = emitir(IRTI(op), tr, lj_opt_narrow_tobit(J, J->base[i])); J->base[0] = tr; } /* Record bit shifts. */ static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd) { TRef tr = lj_opt_narrow_tobit(J, J->base[0]); TRef tsh = lj_opt_narrow_tobit(J, J->base[1]); IROp op = (IROp)rd->data; if (!(op < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) && !tref_isk(tsh)) tsh = emitir(IRTI(IR_BAND), tsh, lj_ir_kint(J, 31)); #ifdef LJ_TARGET_UNIFYROT if (op == (LJ_TARGET_UNIFYROT == 1 ? IR_BROR : IR_BROL)) { op = LJ_TARGET_UNIFYROT == 1 ? IR_BROL : IR_BROR; tsh = emitir(IRTI(IR_NEG), tsh, tsh); } #endif J->base[0] = emitir(IRTI(op), tr, tsh); } /* -- String library fast functions --------------------------------------- */ static void LJ_FASTCALL recff_string_len(jit_State *J, RecordFFData *rd) { J->base[0] = emitir(IRTI(IR_FLOAD), lj_ir_tostr(J, J->base[0]), IRFL_STR_LEN); UNUSED(rd); } /* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */ static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd) { TRef trstr = lj_ir_tostr(J, J->base[0]); TRef trlen = emitir(IRTI(IR_FLOAD), trstr, IRFL_STR_LEN); TRef tr0 = lj_ir_kint(J, 0); TRef trstart, trend; GCstr *str = argv2str(J, &rd->argv[0]); int32_t start, end; if (rd->data) { /* string.sub(str, start [,end]) */ start = argv2int(J, &rd->argv[1]); trstart = lj_opt_narrow_toint(J, J->base[1]); trend = J->base[2]; if (tref_isnil(trend)) { trend = lj_ir_kint(J, -1); end = -1; } else { trend = lj_opt_narrow_toint(J, trend); end = argv2int(J, &rd->argv[2]); } } else { /* string.byte(str, [,start [,end]]) */ if (J->base[1]) { start = argv2int(J, &rd->argv[1]); trstart = lj_opt_narrow_toint(J, J->base[1]); trend = J->base[2]; if (tref_isnil(trend)) { trend = trstart; end = start; } else { trend = lj_opt_narrow_toint(J, trend); end = argv2int(J, &rd->argv[2]); } } else { trend = trstart = lj_ir_kint(J, 1); end = start = 1; } } if (end < 0) { emitir(IRTGI(IR_LT), trend, tr0); trend = emitir(IRTI(IR_ADD), emitir(IRTI(IR_ADD), trlen, trend), lj_ir_kint(J, 1)); end = end+(int32_t)str->len+1; } else if ((MSize)end <= str->len) { emitir(IRTGI(IR_ULE), trend, trlen); } else { emitir(IRTGI(IR_GT), trend, trlen); end = (int32_t)str->len; trend = trlen; } if (start < 0) { emitir(IRTGI(IR_LT), trstart, tr0); trstart = emitir(IRTI(IR_ADD), trlen, trstart); start = start+(int32_t)str->len; emitir(start < 0 ? IRTGI(IR_LT) : IRTGI(IR_GE), trstart, tr0); if (start < 0) { trstart = tr0; start = 0; } } else { if (start == 0) { emitir(IRTGI(IR_EQ), trstart, tr0); trstart = tr0; } else { trstart = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, -1)); emitir(IRTGI(IR_GE), trstart, tr0); start--; } } if (rd->data) { /* Return string.sub result. */ if (end - start >= 0) { /* Also handle empty range here, to avoid extra traces. */ TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart); emitir(IRTGI(IR_GE), trslen, tr0); trptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart); J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen); } else { /* Range underflow: return empty string. */ emitir(IRTGI(IR_LT), trend, trstart); J->base[0] = lj_ir_kstr(J, lj_str_new(J->L, strdata(str), 0)); } } else { /* Return string.byte result(s). */ ptrdiff_t i, len = end - start; if (len > 0) { TRef trslen = emitir(IRTI(IR_SUB), trend, trstart); emitir(IRTGI(IR_EQ), trslen, lj_ir_kint(J, (int32_t)len)); if (J->baseslot + len > LJ_MAX_JSLOTS) lj_trace_err_info(J, LJ_TRERR_STACKOV); rd->nres = len; for (i = 0; i < len; i++) { TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i)); tmp = emitir(IRT(IR_STRREF, IRT_P32), trstr, tmp); J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY); } } else { /* Empty range or range underflow: return no results. */ emitir(IRTGI(IR_LE), trend, trstart); rd->nres = 0; } } } /* -- Table library fast functions ---------------------------------------- */ static void LJ_FASTCALL recff_table_getn(jit_State *J, RecordFFData *rd) { if (tref_istab(J->base[0])) J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, J->base[0]); /* else: Interpreter will throw. */ UNUSED(rd); } static void LJ_FASTCALL recff_table_remove(jit_State *J, RecordFFData *rd) { TRef tab = J->base[0]; rd->nres = 0; if (tref_istab(tab)) { if (!J->base[1] || tref_isnil(J->base[1])) { /* Simple pop: t[#t] = nil */ TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, tab); GCtab *t = tabV(&rd->argv[0]); MSize len = lj_tab_len(t); emitir(IRTGI(len ? IR_NE : IR_EQ), trlen, lj_ir_kint(J, 0)); if (len) { RecordIndex ix; ix.tab = tab; ix.key = trlen; settabV(J->L, &ix.tabv, t); setintV(&ix.keyv, len); ix.idxchain = 0; if (results_wanted(J) != 0) { /* Specialize load only if needed. */ ix.val = 0; J->base[0] = lj_record_idx(J, &ix); /* Load previous value. */ rd->nres = 1; /* Assumes ix.key/ix.tab is not modified for raw lj_record_idx(). */ } ix.val = TREF_NIL; lj_record_idx(J, &ix); /* Remove value. */ } } else { /* Complex case: remove in the middle. */ recff_nyiu(J); } } /* else: Interpreter will throw. */ } static void LJ_FASTCALL recff_table_insert(jit_State *J, RecordFFData *rd) { RecordIndex ix; ix.tab = J->base[0]; ix.val = J->base[1]; rd->nres = 0; if (tref_istab(ix.tab) && ix.val) { if (!J->base[2]) { /* Simple push: t[#t+1] = v */ TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, ix.tab); GCtab *t = tabV(&rd->argv[0]); ix.key = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1)); settabV(J->L, &ix.tabv, t); setintV(&ix.keyv, lj_tab_len(t) + 1); ix.idxchain = 0; lj_record_idx(J, &ix); /* Set new value. */ } else { /* Complex case: insert in the middle. */ recff_nyiu(J); } } /* else: Interpreter will throw. */ } /* -- I/O library fast functions ------------------------------------------ */ /* Get FILE* for I/O function. Any I/O error aborts recording, so there's ** no need to encode the alternate cases for any of the guards. */ static TRef recff_io_fp(jit_State *J, TRef *udp, int32_t id) { TRef tr, ud, fp; if (id) { /* io.func() */ tr = lj_ir_kptr(J, &J2G(J)->gcroot[id]); ud = emitir(IRT(IR_XLOAD, IRT_UDATA), tr, 0); } else { /* fp:method() */ ud = J->base[0]; if (!tref_isudata(ud)) lj_trace_err(J, LJ_TRERR_BADTYPE); tr = emitir(IRT(IR_FLOAD, IRT_U8), ud, IRFL_UDATA_UDTYPE); emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); } *udp = ud; fp = emitir(IRT(IR_FLOAD, IRT_PTR), ud, IRFL_UDATA_FILE); emitir(IRTG(IR_NE, IRT_PTR), fp, lj_ir_knull(J, IRT_PTR)); return fp; } static void LJ_FASTCALL recff_io_write(jit_State *J, RecordFFData *rd) { TRef ud, fp = recff_io_fp(J, &ud, rd->data); TRef zero = lj_ir_kint(J, 0); TRef one = lj_ir_kint(J, 1); ptrdiff_t i = rd->data == 0 ? 1 : 0; for (; J->base[i]; i++) { TRef str = lj_ir_tostr(J, J->base[i]); TRef buf = emitir(IRT(IR_STRREF, IRT_P32), str, zero); TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN); if (tref_isk(len) && IR(tref_ref(len))->i == 1) { TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), buf, IRXLOAD_READONLY); tr = lj_ir_call(J, IRCALL_fputc, tr, fp); if (results_wanted(J) != 0) /* Check result only if not ignored. */ emitir(IRTGI(IR_NE), tr, lj_ir_kint(J, -1)); } else { TRef tr = lj_ir_call(J, IRCALL_fwrite, buf, one, len, fp); if (results_wanted(J) != 0) /* Check result only if not ignored. */ emitir(IRTGI(IR_EQ), tr, len); } } J->base[0] = LJ_52 ? ud : TREF_TRUE; } static void LJ_FASTCALL recff_io_flush(jit_State *J, RecordFFData *rd) { TRef ud, fp = recff_io_fp(J, &ud, rd->data); TRef tr = lj_ir_call(J, IRCALL_fflush, fp); if (results_wanted(J) != 0) /* Check result only if not ignored. */ emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0)); J->base[0] = TREF_TRUE; } /* -- Record calls to fast functions -------------------------------------- */ #include "lj_recdef.h" static uint32_t recdef_lookup(GCfunc *fn) { if (fn->c.ffid < sizeof(recff_idmap)/sizeof(recff_idmap[0])) return recff_idmap[fn->c.ffid]; else return 0; } /* Record entry to a fast function or C function. */ void lj_ffrecord_func(jit_State *J) { RecordFFData rd; uint32_t m = recdef_lookup(J->fn); rd.data = m & 0xff; rd.nres = 1; /* Default is one result. */ rd.argv = J->L->base; J->base[J->maxslot] = 0; /* Mark end of arguments. */ (recff_func[m >> 8])(J, &rd); /* Call recff_* handler. */ if (rd.nres >= 0) { if (J->postproc == LJ_POST_NONE) J->postproc = LJ_POST_FFRETRY; lj_record_ret(J, 0, rd.nres); } } #undef IR #undef emitir #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ffrecord.h ================================================ /* ** Fast function call recorder. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_FFRECORD_H #define _LJ_FFRECORD_H #include "lj_obj.h" #include "lj_jit.h" #if LJ_HASJIT /* Data used by handlers to record a fast function. */ typedef struct RecordFFData { TValue *argv; /* Runtime argument values. */ ptrdiff_t nres; /* Number of returned results (defaults to 1). */ uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ } RecordFFData; LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); LJ_FUNC void lj_ffrecord_func(jit_State *J); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_frame.h ================================================ /* ** Stack frames. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_FRAME_H #define _LJ_FRAME_H #include "lj_obj.h" #include "lj_bc.h" /* -- Lua stack frame ----------------------------------------------------- */ /* Frame type markers in callee function slot (callee base-1). */ enum { FRAME_LUA, FRAME_C, FRAME_CONT, FRAME_VARG, FRAME_LUAP, FRAME_CP, FRAME_PCALL, FRAME_PCALLH }; #define FRAME_TYPE 3 #define FRAME_P 4 #define FRAME_TYPEP (FRAME_TYPE|FRAME_P) /* Macros to access and modify Lua frames. */ #define frame_gc(f) (gcref((f)->fr.func)) #define frame_func(f) (&frame_gc(f)->fn) #define frame_ftsz(f) ((f)->fr.tp.ftsz) #define frame_type(f) (frame_ftsz(f) & FRAME_TYPE) #define frame_typep(f) (frame_ftsz(f) & FRAME_TYPEP) #define frame_islua(f) (frame_type(f) == FRAME_LUA) #define frame_isc(f) (frame_type(f) == FRAME_C) #define frame_iscont(f) (frame_typep(f) == FRAME_CONT) #define frame_isvarg(f) (frame_typep(f) == FRAME_VARG) #define frame_ispcall(f) ((frame_ftsz(f) & 6) == FRAME_PCALL) #define frame_pc(f) (mref((f)->fr.tp.pcr, const BCIns)) #define frame_contpc(f) (frame_pc((f)-1)) #if LJ_64 #define frame_contf(f) \ ((ASMFunction)(void *)((intptr_t)lj_vm_asm_begin + \ (intptr_t)(int32_t)((f)-1)->u32.lo)) #else #define frame_contf(f) ((ASMFunction)gcrefp(((f)-1)->gcr, void)) #endif #define frame_delta(f) (frame_ftsz(f) >> 3) #define frame_sized(f) (frame_ftsz(f) & ~FRAME_TYPEP) #define frame_prevl(f) ((f) - (1+bc_a(frame_pc(f)[-1]))) #define frame_prevd(f) ((TValue *)((char *)(f) - frame_sized(f))) #define frame_prev(f) (frame_islua(f)?frame_prevl(f):frame_prevd(f)) /* Note: this macro does not skip over FRAME_VARG. */ #define setframe_pc(f, pc) (setmref((f)->fr.tp.pcr, (pc))) #define setframe_ftsz(f, sz) ((f)->fr.tp.ftsz = (sz)) #define setframe_gc(f, p) (setgcref((f)->fr.func, (p))) /* -- C stack frame ------------------------------------------------------- */ /* Macros to access and modify the C stack frame chain. */ /* These definitions must match with the arch-specific *.dasc files. */ #if LJ_TARGET_X86 #define CFRAME_OFS_ERRF (15*4) #define CFRAME_OFS_NRES (14*4) #define CFRAME_OFS_PREV (13*4) #define CFRAME_OFS_L (12*4) #define CFRAME_OFS_PC (6*4) #define CFRAME_OFS_MULTRES (5*4) #define CFRAME_SIZE (12*4) #define CFRAME_SHIFT_MULTRES 0 #elif LJ_TARGET_X64 #if LJ_ABI_WIN #define CFRAME_OFS_PREV (13*8) #define CFRAME_OFS_PC (25*4) #define CFRAME_OFS_L (24*4) #define CFRAME_OFS_ERRF (23*4) #define CFRAME_OFS_NRES (22*4) #define CFRAME_OFS_MULTRES (21*4) #define CFRAME_SIZE (10*8) #define CFRAME_SIZE_JIT (CFRAME_SIZE + 9*16 + 4*8) #define CFRAME_SHIFT_MULTRES 0 #else #define CFRAME_OFS_PREV (4*8) #define CFRAME_OFS_PC (7*4) #define CFRAME_OFS_L (6*4) #define CFRAME_OFS_ERRF (5*4) #define CFRAME_OFS_NRES (4*4) #define CFRAME_OFS_MULTRES (1*4) #define CFRAME_SIZE (10*8) #define CFRAME_SIZE_JIT (CFRAME_SIZE + 16) #define CFRAME_SHIFT_MULTRES 0 #endif #elif LJ_TARGET_ARM #define CFRAME_OFS_ERRF 24 #define CFRAME_OFS_NRES 20 #define CFRAME_OFS_PREV 16 #define CFRAME_OFS_L 12 #define CFRAME_OFS_PC 8 #define CFRAME_OFS_MULTRES 4 #if LJ_ARCH_HASFPU #define CFRAME_SIZE 128 #else #define CFRAME_SIZE 64 #endif #define CFRAME_SHIFT_MULTRES 3 #elif LJ_TARGET_PPC #if LJ_TARGET_XBOX360 #define CFRAME_OFS_ERRF 424 #define CFRAME_OFS_NRES 420 #define CFRAME_OFS_PREV 400 #define CFRAME_OFS_L 416 #define CFRAME_OFS_PC 412 #define CFRAME_OFS_MULTRES 408 #define CFRAME_SIZE 384 #define CFRAME_SHIFT_MULTRES 3 #elif LJ_ARCH_PPC64 #define CFRAME_OFS_ERRF 472 #define CFRAME_OFS_NRES 468 #define CFRAME_OFS_PREV 448 #define CFRAME_OFS_L 464 #define CFRAME_OFS_PC 460 #define CFRAME_OFS_MULTRES 456 #define CFRAME_SIZE 400 #define CFRAME_SHIFT_MULTRES 3 #else #define CFRAME_OFS_ERRF 48 #define CFRAME_OFS_NRES 44 #define CFRAME_OFS_PREV 40 #define CFRAME_OFS_L 36 #define CFRAME_OFS_PC 32 #define CFRAME_OFS_MULTRES 28 #define CFRAME_SIZE 272 #define CFRAME_SHIFT_MULTRES 3 #endif #elif LJ_TARGET_PPCSPE #define CFRAME_OFS_ERRF 28 #define CFRAME_OFS_NRES 24 #define CFRAME_OFS_PREV 20 #define CFRAME_OFS_L 16 #define CFRAME_OFS_PC 12 #define CFRAME_OFS_MULTRES 8 #define CFRAME_SIZE 184 #define CFRAME_SHIFT_MULTRES 3 #elif LJ_TARGET_MIPS #define CFRAME_OFS_ERRF 124 #define CFRAME_OFS_NRES 120 #define CFRAME_OFS_PREV 116 #define CFRAME_OFS_L 112 #define CFRAME_OFS_PC 20 #define CFRAME_OFS_MULTRES 16 #define CFRAME_SIZE 112 #define CFRAME_SHIFT_MULTRES 3 #else #error "Missing CFRAME_* definitions for this architecture" #endif #ifndef CFRAME_SIZE_JIT #define CFRAME_SIZE_JIT CFRAME_SIZE #endif #define CFRAME_RESUME 1 #define CFRAME_UNWIND_FF 2 /* Only used in unwinder. */ #define CFRAME_RAWMASK (~(intptr_t)(CFRAME_RESUME|CFRAME_UNWIND_FF)) #define cframe_errfunc(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_ERRF)) #define cframe_nres(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_NRES)) #define cframe_prev(cf) (*(void **)(((char *)(cf))+CFRAME_OFS_PREV)) #define cframe_multres(cf) (*(uint32_t *)(((char *)(cf))+CFRAME_OFS_MULTRES)) #define cframe_multres_n(cf) (cframe_multres((cf)) >> CFRAME_SHIFT_MULTRES) #define cframe_L(cf) \ (&gcref(*(GCRef *)(((char *)(cf))+CFRAME_OFS_L))->th) #define cframe_pc(cf) \ (mref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), const BCIns)) #define setcframe_L(cf, L) \ (setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_L), (L))) #define setcframe_pc(cf, pc) \ (setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), (pc))) #define cframe_canyield(cf) ((intptr_t)(cf) & CFRAME_RESUME) #define cframe_unwind_ff(cf) ((intptr_t)(cf) & CFRAME_UNWIND_FF) #define cframe_raw(cf) ((void *)((intptr_t)(cf) & CFRAME_RAWMASK)) #define cframe_Lpc(L) cframe_pc(cframe_raw(L->cframe)) #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_func.c ================================================ /* ** Function handling (prototypes, functions and upvalues). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lj_func_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_func.h" #include "lj_trace.h" #include "lj_vm.h" /* -- Prototypes ---------------------------------------------------------- */ void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt) { lj_mem_free(g, pt, pt->sizept); } /* -- Upvalues ------------------------------------------------------------ */ static void unlinkuv(GCupval *uv) { lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); setgcrefr(uvnext(uv)->prev, uv->prev); setgcrefr(uvprev(uv)->next, uv->next); } /* Find existing open upvalue for a stack slot or create a new one. */ static GCupval *func_finduv(lua_State *L, TValue *slot) { global_State *g = G(L); GCRef *pp = &L->openupval; GCupval *p; GCupval *uv; /* Search the sorted list of open upvalues. */ while (gcref(*pp) != NULL && uvval((p = gco2uv(gcref(*pp)))) >= slot) { lua_assert(!p->closed && uvval(p) != &p->tv); if (uvval(p) == slot) { /* Found open upvalue pointing to same slot? */ if (isdead(g, obj2gco(p))) /* Resurrect it, if it's dead. */ flipwhite(obj2gco(p)); return p; } pp = &p->nextgc; } /* No matching upvalue found. Create a new one. */ uv = lj_mem_newt(L, sizeof(GCupval), GCupval); newwhite(g, uv); uv->gct = ~LJ_TUPVAL; uv->closed = 0; /* Still open. */ setmref(uv->v, slot); /* Pointing to the stack slot. */ /* NOBARRIER: The GCupval is new (marked white) and open. */ setgcrefr(uv->nextgc, *pp); /* Insert into sorted list of open upvalues. */ setgcref(*pp, obj2gco(uv)); setgcref(uv->prev, obj2gco(&g->uvhead)); /* Insert into GC list, too. */ setgcrefr(uv->next, g->uvhead.next); setgcref(uvnext(uv)->prev, obj2gco(uv)); setgcref(g->uvhead.next, obj2gco(uv)); lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); return uv; } /* Create an empty and closed upvalue. */ static GCupval *func_emptyuv(lua_State *L) { GCupval *uv = (GCupval *)lj_mem_newgco(L, sizeof(GCupval)); uv->gct = ~LJ_TUPVAL; uv->closed = 1; setnilV(&uv->tv); setmref(uv->v, &uv->tv); return uv; } /* Close all open upvalues pointing to some stack level or above. */ void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level) { GCupval *uv; global_State *g = G(L); while (gcref(L->openupval) != NULL && uvval((uv = gco2uv(gcref(L->openupval)))) >= level) { GCobj *o = obj2gco(uv); lua_assert(!isblack(o) && !uv->closed && uvval(uv) != &uv->tv); setgcrefr(L->openupval, uv->nextgc); /* No longer in open list. */ if (isdead(g, o)) { lj_func_freeuv(g, uv); } else { unlinkuv(uv); lj_gc_closeuv(g, uv); } } } void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv) { if (!uv->closed) unlinkuv(uv); lj_mem_freet(g, uv); } /* -- Functions (closures) ------------------------------------------------ */ GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env) { GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeCfunc(nelems)); fn->c.gct = ~LJ_TFUNC; fn->c.ffid = FF_C; fn->c.nupvalues = (uint8_t)nelems; /* NOBARRIER: The GCfunc is new (marked white). */ setmref(fn->c.pc, &G(L)->bc_cfunc_ext); setgcref(fn->c.env, obj2gco(env)); return fn; } static GCfunc *func_newL(lua_State *L, GCproto *pt, GCtab *env) { uint32_t count; GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeLfunc((MSize)pt->sizeuv)); fn->l.gct = ~LJ_TFUNC; fn->l.ffid = FF_LUA; fn->l.nupvalues = 0; /* Set to zero until upvalues are initialized. */ /* NOBARRIER: Really a setgcref. But the GCfunc is new (marked white). */ setmref(fn->l.pc, proto_bc(pt)); setgcref(fn->l.env, obj2gco(env)); /* Saturating 3 bit counter (0..7) for created closures. */ count = (uint32_t)pt->flags + PROTO_CLCOUNT; pt->flags = (uint8_t)(count - ((count >> PROTO_CLC_BITS) & PROTO_CLCOUNT)); return fn; } /* Create a new Lua function with empty upvalues. */ GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env) { GCfunc *fn = func_newL(L, pt, env); MSize i, nuv = pt->sizeuv; /* NOBARRIER: The GCfunc is new (marked white). */ for (i = 0; i < nuv; i++) { GCupval *uv = func_emptyuv(L); uv->dhash = (uint32_t)(uintptr_t)pt ^ ((uint32_t)proto_uv(pt)[i] << 24); setgcref(fn->l.uvptr[i], obj2gco(uv)); } fn->l.nupvalues = (uint8_t)nuv; return fn; } /* Do a GC check and create a new Lua function with inherited upvalues. */ GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent) { GCfunc *fn; GCRef *puv; MSize i, nuv; TValue *base; lj_gc_check_fixtop(L); fn = func_newL(L, pt, tabref(parent->env)); /* NOBARRIER: The GCfunc is new (marked white). */ puv = parent->uvptr; nuv = pt->sizeuv; base = L->base; for (i = 0; i < nuv; i++) { uint32_t v = proto_uv(pt)[i]; GCupval *uv; if ((v & PROTO_UV_LOCAL)) { uv = func_finduv(L, base + (v & 0xff)); uv->immutable = ((v / PROTO_UV_IMMUTABLE) & 1); uv->dhash = (uint32_t)(uintptr_t)mref(parent->pc, char) ^ (v << 24); } else { uv = &gcref(puv[v])->uv; } setgcref(fn->l.uvptr[i], obj2gco(uv)); } fn->l.nupvalues = (uint8_t)nuv; return fn; } void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *fn) { MSize size = isluafunc(fn) ? sizeLfunc((MSize)fn->l.nupvalues) : sizeCfunc((MSize)fn->c.nupvalues); lj_mem_free(g, fn, size); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_func.h ================================================ /* ** Function handling (prototypes, functions and upvalues). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_FUNC_H #define _LJ_FUNC_H #include "lj_obj.h" /* Prototypes. */ LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); /* Upvalues. */ LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); /* Functions (closures). */ LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_gc.c ================================================ /* ** Garbage collector. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lj_gc_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_func.h" #include "lj_udata.h" #include "lj_meta.h" #include "lj_state.h" #include "lj_frame.h" #if LJ_HASFFI #include "lj_ctype.h" #include "lj_cdata.h" #endif #include "lj_trace.h" #include "lj_vm.h" #define GCSTEPSIZE 1024u #define GCSWEEPMAX 40 #define GCSWEEPCOST 10 #define GCFINALIZECOST 100 /* Macros to set GCobj colors and flags. */ #define white2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_WHITES) #define gray2black(x) ((x)->gch.marked |= LJ_GC_BLACK) #define isfinalized(u) ((u)->marked & LJ_GC_FINALIZED) /* -- Mark phase ---------------------------------------------------------- */ /* Mark a TValue (if needed). */ #define gc_marktv(g, tv) \ { lua_assert(!tvisgcv(tv) || (~itype(tv) == gcval(tv)->gch.gct)); \ if (tviswhite(tv)) gc_mark(g, gcV(tv)); } /* Mark a GCobj (if needed). */ #define gc_markobj(g, o) \ { if (iswhite(obj2gco(o))) gc_mark(g, obj2gco(o)); } /* Mark a string object. */ #define gc_mark_str(s) ((s)->marked &= (uint8_t)~LJ_GC_WHITES) /* Mark a white GCobj. */ static void gc_mark(global_State *g, GCobj *o) { int gct = o->gch.gct; lua_assert(iswhite(o) && !isdead(g, o)); white2gray(o); if (LJ_UNLIKELY(gct == ~LJ_TUDATA)) { GCtab *mt = tabref(gco2ud(o)->metatable); gray2black(o); /* Userdata are never gray. */ if (mt) gc_markobj(g, mt); gc_markobj(g, tabref(gco2ud(o)->env)); } else if (LJ_UNLIKELY(gct == ~LJ_TUPVAL)) { GCupval *uv = gco2uv(o); gc_marktv(g, uvval(uv)); if (uv->closed) gray2black(o); /* Closed upvalues are never gray. */ } else if (gct != ~LJ_TSTR && gct != ~LJ_TCDATA) { lua_assert(gct == ~LJ_TFUNC || gct == ~LJ_TTAB || gct == ~LJ_TTHREAD || gct == ~LJ_TPROTO); setgcrefr(o->gch.gclist, g->gc.gray); setgcref(g->gc.gray, o); } } /* Mark GC roots. */ static void gc_mark_gcroot(global_State *g) { ptrdiff_t i; for (i = 0; i < GCROOT_MAX; i++) if (gcref(g->gcroot[i]) != NULL) gc_markobj(g, gcref(g->gcroot[i])); } /* Start a GC cycle and mark the root set. */ static void gc_mark_start(global_State *g) { setgcrefnull(g->gc.gray); setgcrefnull(g->gc.grayagain); setgcrefnull(g->gc.weak); gc_markobj(g, mainthread(g)); gc_markobj(g, tabref(mainthread(g)->env)); gc_marktv(g, &g->registrytv); gc_mark_gcroot(g); g->gc.state = GCSpropagate; } /* Mark open upvalues. */ static void gc_mark_uv(global_State *g) { GCupval *uv; for (uv = uvnext(&g->uvhead); uv != &g->uvhead; uv = uvnext(uv)) { lua_assert(uvprev(uvnext(uv)) == uv && uvnext(uvprev(uv)) == uv); if (isgray(obj2gco(uv))) gc_marktv(g, uvval(uv)); } } /* Mark userdata in mmudata list. */ static void gc_mark_mmudata(global_State *g) { GCobj *root = gcref(g->gc.mmudata); GCobj *u = root; if (u) { do { u = gcnext(u); makewhite(g, u); /* Could be from previous GC. */ gc_mark(g, u); } while (u != root); } } /* Separate userdata objects to be finalized to mmudata list. */ size_t lj_gc_separateudata(global_State *g, int all) { size_t m = 0; GCRef *p = &mainthread(g)->nextgc; GCobj *o; while ((o = gcref(*p)) != NULL) { if (!(iswhite(o) || all) || isfinalized(gco2ud(o))) { p = &o->gch.nextgc; /* Nothing to do. */ } else if (!lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc)) { markfinalized(o); /* Done, as there's no __gc metamethod. */ p = &o->gch.nextgc; } else { /* Otherwise move userdata to be finalized to mmudata list. */ m += sizeudata(gco2ud(o)); markfinalized(o); *p = o->gch.nextgc; if (gcref(g->gc.mmudata)) { /* Link to end of mmudata list. */ GCobj *root = gcref(g->gc.mmudata); setgcrefr(o->gch.nextgc, root->gch.nextgc); setgcref(root->gch.nextgc, o); setgcref(g->gc.mmudata, o); } else { /* Create circular list. */ setgcref(o->gch.nextgc, o); setgcref(g->gc.mmudata, o); } } } return m; } /* -- Propagation phase --------------------------------------------------- */ /* Traverse a table. */ static int gc_traverse_tab(global_State *g, GCtab *t) { int weak = 0; cTValue *mode; GCtab *mt = tabref(t->metatable); if (mt) gc_markobj(g, mt); mode = lj_meta_fastg(g, mt, MM_mode); if (mode && tvisstr(mode)) { /* Valid __mode field? */ const char *modestr = strVdata(mode); int c; while ((c = *modestr++)) { if (c == 'k') weak |= LJ_GC_WEAKKEY; else if (c == 'v') weak |= LJ_GC_WEAKVAL; else if (c == 'K') weak = (int)(~0u & ~LJ_GC_WEAKVAL); } if (weak > 0) { /* Weak tables are cleared in the atomic phase. */ t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak); setgcrefr(t->gclist, g->gc.weak); setgcref(g->gc.weak, obj2gco(t)); } } if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */ return 1; if (!(weak & LJ_GC_WEAKVAL)) { /* Mark array part. */ MSize i, asize = t->asize; for (i = 0; i < asize; i++) gc_marktv(g, arrayslot(t, i)); } if (t->hmask > 0) { /* Mark hash part. */ Node *node = noderef(t->node); MSize i, hmask = t->hmask; for (i = 0; i <= hmask; i++) { Node *n = &node[i]; if (!tvisnil(&n->val)) { /* Mark non-empty slot. */ lua_assert(!tvisnil(&n->key)); if (!(weak & LJ_GC_WEAKKEY)) gc_marktv(g, &n->key); if (!(weak & LJ_GC_WEAKVAL)) gc_marktv(g, &n->val); } } } return weak; } /* Traverse a function. */ static void gc_traverse_func(global_State *g, GCfunc *fn) { gc_markobj(g, tabref(fn->c.env)); if (isluafunc(fn)) { uint32_t i; lua_assert(fn->l.nupvalues <= funcproto(fn)->sizeuv); gc_markobj(g, funcproto(fn)); for (i = 0; i < fn->l.nupvalues; i++) /* Mark Lua function upvalues. */ gc_markobj(g, &gcref(fn->l.uvptr[i])->uv); } else { uint32_t i; for (i = 0; i < fn->c.nupvalues; i++) /* Mark C function upvalues. */ gc_marktv(g, &fn->c.upvalue[i]); } } #if LJ_HASJIT /* Mark a trace. */ static void gc_marktrace(global_State *g, TraceNo traceno) { GCobj *o = obj2gco(traceref(G2J(g), traceno)); lua_assert(traceno != G2J(g)->cur.traceno); if (iswhite(o)) { white2gray(o); setgcrefr(o->gch.gclist, g->gc.gray); setgcref(g->gc.gray, o); } } /* Traverse a trace. */ static void gc_traverse_trace(global_State *g, GCtrace *T) { IRRef ref; if (T->traceno == 0) return; for (ref = T->nk; ref < REF_TRUE; ref++) { IRIns *ir = &T->ir[ref]; if (ir->o == IR_KGC) gc_markobj(g, ir_kgc(ir)); } if (T->link) gc_marktrace(g, T->link); if (T->nextroot) gc_marktrace(g, T->nextroot); if (T->nextside) gc_marktrace(g, T->nextside); gc_markobj(g, gcref(T->startpt)); } /* The current trace is a GC root while not anchored in the prototype (yet). */ #define gc_traverse_curtrace(g) gc_traverse_trace(g, &G2J(g)->cur) #else #define gc_traverse_curtrace(g) UNUSED(g) #endif /* Traverse a prototype. */ static void gc_traverse_proto(global_State *g, GCproto *pt) { ptrdiff_t i; gc_mark_str(proto_chunkname(pt)); for (i = -(ptrdiff_t)pt->sizekgc; i < 0; i++) /* Mark collectable consts. */ gc_markobj(g, proto_kgc(pt, i)); #if LJ_HASJIT if (pt->trace) gc_marktrace(g, pt->trace); #endif } /* Traverse the frame structure of a stack. */ static MSize gc_traverse_frames(global_State *g, lua_State *th) { TValue *frame, *top = th->top-1, *bot = tvref(th->stack); /* Note: extra vararg frame not skipped, marks function twice (harmless). */ for (frame = th->base-1; frame > bot; frame = frame_prev(frame)) { GCfunc *fn = frame_func(frame); TValue *ftop = frame; if (isluafunc(fn)) ftop += funcproto(fn)->framesize; if (ftop > top) top = ftop; gc_markobj(g, fn); /* Need to mark hidden function (or L). */ } top++; /* Correct bias of -1 (frame == base-1). */ if (top > tvref(th->maxstack)) top = tvref(th->maxstack); return (MSize)(top - bot); /* Return minimum needed stack size. */ } /* Traverse a thread object. */ static void gc_traverse_thread(global_State *g, lua_State *th) { TValue *o, *top = th->top; for (o = tvref(th->stack)+1; o < top; o++) gc_marktv(g, o); if (g->gc.state == GCSatomic) { top = tvref(th->stack) + th->stacksize; for (; o < top; o++) /* Clear unmarked slots. */ setnilV(o); } gc_markobj(g, tabref(th->env)); lj_state_shrinkstack(th, gc_traverse_frames(g, th)); } /* Propagate one gray object. Traverse it and turn it black. */ static size_t propagatemark(global_State *g) { GCobj *o = gcref(g->gc.gray); int gct = o->gch.gct; lua_assert(isgray(o)); gray2black(o); setgcrefr(g->gc.gray, o->gch.gclist); /* Remove from gray list. */ if (LJ_LIKELY(gct == ~LJ_TTAB)) { GCtab *t = gco2tab(o); if (gc_traverse_tab(g, t) > 0) black2gray(o); /* Keep weak tables gray. */ return sizeof(GCtab) + sizeof(TValue) * t->asize + sizeof(Node) * (t->hmask + 1); } else if (LJ_LIKELY(gct == ~LJ_TFUNC)) { GCfunc *fn = gco2func(o); gc_traverse_func(g, fn); return isluafunc(fn) ? sizeLfunc((MSize)fn->l.nupvalues) : sizeCfunc((MSize)fn->c.nupvalues); } else if (LJ_LIKELY(gct == ~LJ_TPROTO)) { GCproto *pt = gco2pt(o); gc_traverse_proto(g, pt); return pt->sizept; } else if (LJ_LIKELY(gct == ~LJ_TTHREAD)) { lua_State *th = gco2th(o); setgcrefr(th->gclist, g->gc.grayagain); setgcref(g->gc.grayagain, o); black2gray(o); /* Threads are never black. */ gc_traverse_thread(g, th); return sizeof(lua_State) + sizeof(TValue) * th->stacksize; } else { #if LJ_HASJIT GCtrace *T = gco2trace(o); gc_traverse_trace(g, T); return ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry); #else lua_assert(0); return 0; #endif } } /* Propagate all gray objects. */ static size_t gc_propagate_gray(global_State *g) { size_t m = 0; while (gcref(g->gc.gray) != NULL) m += propagatemark(g); return m; } /* -- Sweep phase --------------------------------------------------------- */ /* Try to shrink some common data structures. */ static void gc_shrink(global_State *g, lua_State *L) { if (g->strnum <= (g->strmask >> 2) && g->strmask > LJ_MIN_STRTAB*2-1) lj_str_resize(L, g->strmask >> 1); /* Shrink string table. */ if (g->tmpbuf.sz > LJ_MIN_SBUF*2) lj_str_resizebuf(L, &g->tmpbuf, g->tmpbuf.sz >> 1); /* Shrink temp buf. */ } /* Type of GC free functions. */ typedef void (LJ_FASTCALL *GCFreeFunc)(global_State *g, GCobj *o); /* GC free functions for LJ_TSTR .. LJ_TUDATA. ORDER LJ_T */ static const GCFreeFunc gc_freefunc[] = { (GCFreeFunc)lj_str_free, (GCFreeFunc)lj_func_freeuv, (GCFreeFunc)lj_state_free, (GCFreeFunc)lj_func_freeproto, (GCFreeFunc)lj_func_free, #if LJ_HASJIT (GCFreeFunc)lj_trace_free, #else (GCFreeFunc)0, #endif #if LJ_HASFFI (GCFreeFunc)lj_cdata_free, #else (GCFreeFunc)0, #endif (GCFreeFunc)lj_tab_free, (GCFreeFunc)lj_udata_free }; /* Full sweep of a GC list. */ #define gc_fullsweep(g, p) gc_sweep(g, (p), LJ_MAX_MEM) /* Partial sweep of a GC list. */ static GCRef *gc_sweep(global_State *g, GCRef *p, uint32_t lim) { /* Mask with other white and LJ_GC_FIXED. Or LJ_GC_SFIXED on shutdown. */ int ow = otherwhite(g); GCobj *o; while ((o = gcref(*p)) != NULL && lim-- > 0) { if (o->gch.gct == ~LJ_TTHREAD) /* Need to sweep open upvalues, too. */ gc_fullsweep(g, &gco2th(o)->openupval); if (((o->gch.marked ^ LJ_GC_WHITES) & ow)) { /* Black or current white? */ lua_assert(!isdead(g, o) || (o->gch.marked & LJ_GC_FIXED)); makewhite(g, o); /* Value is alive, change to the current white. */ p = &o->gch.nextgc; } else { /* Otherwise value is dead, free it. */ lua_assert(isdead(g, o) || ow == LJ_GC_SFIXED); setgcrefr(*p, o->gch.nextgc); if (o == gcref(g->gc.root)) setgcrefr(g->gc.root, o->gch.nextgc); /* Adjust list anchor. */ gc_freefunc[o->gch.gct - ~LJ_TSTR](g, o); } } return p; } /* Check whether we can clear a key or a value slot from a table. */ static int gc_mayclear(cTValue *o, int val) { if (tvisgcv(o)) { /* Only collectable objects can be weak references. */ if (tvisstr(o)) { /* But strings cannot be used as weak references. */ gc_mark_str(strV(o)); /* And need to be marked. */ return 0; } if (iswhite(gcV(o))) return 1; /* Object is about to be collected. */ if (tvisudata(o) && val && isfinalized(udataV(o))) return 1; /* Finalized userdata is dropped only from values. */ } return 0; /* Cannot clear. */ } /* Clear collected entries from weak tables. */ static void gc_clearweak(GCobj *o) { while (o) { GCtab *t = gco2tab(o); lua_assert((t->marked & LJ_GC_WEAK)); if ((t->marked & LJ_GC_WEAKVAL)) { MSize i, asize = t->asize; for (i = 0; i < asize; i++) { /* Clear array slot when value is about to be collected. */ TValue *tv = arrayslot(t, i); if (gc_mayclear(tv, 1)) setnilV(tv); } } if (t->hmask > 0) { Node *node = noderef(t->node); MSize i, hmask = t->hmask; for (i = 0; i <= hmask; i++) { Node *n = &node[i]; /* Clear hash slot when key or value is about to be collected. */ if (!tvisnil(&n->val) && (gc_mayclear(&n->key, 0) || gc_mayclear(&n->val, 1))) setnilV(&n->val); } } o = gcref(t->gclist); } } /* Call a userdata or cdata finalizer. */ static void gc_call_finalizer(global_State *g, lua_State *L, cTValue *mo, GCobj *o) { /* Save and restore lots of state around the __gc callback. */ uint8_t oldh = hook_save(g); MSize oldt = g->gc.threshold; int errcode; TValue *top; lj_trace_abort(g); top = L->top; L->top = top+2; hook_entergc(g); /* Disable hooks and new traces during __gc. */ g->gc.threshold = LJ_MAX_MEM; /* Prevent GC steps. */ copyTV(L, top, mo); setgcV(L, top+1, o, ~o->gch.gct); errcode = lj_vm_pcall(L, top+1, 1+0, -1); /* Stack: |mo|o| -> | */ hook_restore(g, oldh); g->gc.threshold = oldt; /* Restore GC threshold. */ if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */ } /* Finalize one userdata or cdata object from the mmudata list. */ static void gc_finalize(lua_State *L) { global_State *g = G(L); GCobj *o = gcnext(gcref(g->gc.mmudata)); cTValue *mo; lua_assert(gcref(g->jit_L) == NULL); /* Must not be called on trace. */ /* Unchain from list of userdata to be finalized. */ if (o == gcref(g->gc.mmudata)) setgcrefnull(g->gc.mmudata); else setgcrefr(gcref(g->gc.mmudata)->gch.nextgc, o->gch.nextgc); #if LJ_HASFFI if (o->gch.gct == ~LJ_TCDATA) { TValue tmp, *tv; /* Add cdata back to the GC list and make it white. */ setgcrefr(o->gch.nextgc, g->gc.root); setgcref(g->gc.root, o); makewhite(g, o); o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; /* Resolve finalizer. */ setcdataV(L, &tmp, gco2cd(o)); tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp); if (!tvisnil(tv)) { copyTV(L, &tmp, tv); setnilV(tv); /* Clear entry in finalizer table. */ gc_call_finalizer(g, L, &tmp, o); } return; } #endif /* Add userdata back to the main userdata list and make it white. */ setgcrefr(o->gch.nextgc, mainthread(g)->nextgc); setgcref(mainthread(g)->nextgc, o); makewhite(g, o); /* Resolve the __gc metamethod. */ mo = lj_meta_fastg(g, tabref(gco2ud(o)->metatable), MM_gc); if (mo) gc_call_finalizer(g, L, mo, o); } /* Finalize all userdata objects from mmudata list. */ void lj_gc_finalize_udata(lua_State *L) { while (gcref(G(L)->gc.mmudata) != NULL) gc_finalize(L); } #if LJ_HASFFI /* Finalize all cdata objects from finalizer table. */ void lj_gc_finalize_cdata(lua_State *L) { global_State *g = G(L); CTState *cts = ctype_ctsG(g); if (cts) { GCtab *t = cts->finalizer; Node *node = noderef(t->node); ptrdiff_t i; setgcrefnull(t->metatable); /* Mark finalizer table as disabled. */ for (i = (ptrdiff_t)t->hmask; i >= 0; i--) if (!tvisnil(&node[i].val) && tviscdata(&node[i].key)) { GCobj *o = gcV(&node[i].key); TValue tmp; makewhite(g, o); o->gch.marked &= (uint8_t)~LJ_GC_CDATA_FIN; copyTV(L, &tmp, &node[i].val); setnilV(&node[i].val); gc_call_finalizer(g, L, &tmp, o); } } } #endif /* Free all remaining GC objects. */ void lj_gc_freeall(global_State *g) { MSize i, strmask; /* Free everything, except super-fixed objects (the main thread). */ g->gc.currentwhite = LJ_GC_WHITES | LJ_GC_SFIXED; gc_fullsweep(g, &g->gc.root); strmask = g->strmask; for (i = 0; i <= strmask; i++) /* Free all string hash chains. */ gc_fullsweep(g, &g->strhash[i]); } /* -- Collector ----------------------------------------------------------- */ /* Atomic part of the GC cycle, transitioning from mark to sweep phase. */ static void atomic(global_State *g, lua_State *L) { size_t udsize; gc_mark_uv(g); /* Need to remark open upvalues (the thread may be dead). */ gc_propagate_gray(g); /* Propagate any left-overs. */ setgcrefr(g->gc.gray, g->gc.weak); /* Empty the list of weak tables. */ setgcrefnull(g->gc.weak); lua_assert(!iswhite(obj2gco(mainthread(g)))); gc_markobj(g, L); /* Mark running thread. */ gc_traverse_curtrace(g); /* Traverse current trace. */ gc_mark_gcroot(g); /* Mark GC roots (again). */ gc_propagate_gray(g); /* Propagate all of the above. */ setgcrefr(g->gc.gray, g->gc.grayagain); /* Empty the 2nd chance list. */ setgcrefnull(g->gc.grayagain); gc_propagate_gray(g); /* Propagate it. */ udsize = lj_gc_separateudata(g, 0); /* Separate userdata to be finalized. */ gc_mark_mmudata(g); /* Mark them. */ udsize += gc_propagate_gray(g); /* And propagate the marks. */ /* All marking done, clear weak tables. */ gc_clearweak(gcref(g->gc.weak)); /* Prepare for sweep phase. */ g->gc.currentwhite = (uint8_t)otherwhite(g); /* Flip current white. */ g->strempty.marked = g->gc.currentwhite; setmref(g->gc.sweep, &g->gc.root); g->gc.estimate = g->gc.total - (MSize)udsize; /* Initial estimate. */ } /* GC state machine. Returns a cost estimate for each step performed. */ static size_t gc_onestep(lua_State *L) { global_State *g = G(L); switch (g->gc.state) { case GCSpause: gc_mark_start(g); /* Start a new GC cycle by marking all GC roots. */ return 0; case GCSpropagate: if (gcref(g->gc.gray) != NULL) return propagatemark(g); /* Propagate one gray object. */ g->gc.state = GCSatomic; /* End of mark phase. */ return 0; case GCSatomic: if (gcref(g->jit_L)) /* Don't run atomic phase on trace. */ return LJ_MAX_MEM; atomic(g, L); g->gc.state = GCSsweepstring; /* Start of sweep phase. */ g->gc.sweepstr = 0; return 0; case GCSsweepstring: { MSize old = g->gc.total; gc_fullsweep(g, &g->strhash[g->gc.sweepstr++]); /* Sweep one chain. */ if (g->gc.sweepstr > g->strmask) g->gc.state = GCSsweep; /* All string hash chains sweeped. */ lua_assert(old >= g->gc.total); g->gc.estimate -= old - g->gc.total; return GCSWEEPCOST; } case GCSsweep: { MSize old = g->gc.total; setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX)); if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) { gc_shrink(g, L); if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ g->gc.state = GCSfinalize; } else { /* Otherwise skip this phase to help the JIT. */ g->gc.state = GCSpause; /* End of GC cycle. */ g->gc.debt = 0; } } lua_assert(old >= g->gc.total); g->gc.estimate -= old - g->gc.total; return GCSWEEPMAX*GCSWEEPCOST; } case GCSfinalize: if (gcref(g->gc.mmudata) != NULL) { if (gcref(g->jit_L)) /* Don't call finalizers on trace. */ return LJ_MAX_MEM; gc_finalize(L); /* Finalize one userdata object. */ if (g->gc.estimate > GCFINALIZECOST) g->gc.estimate -= GCFINALIZECOST; return GCFINALIZECOST; } g->gc.state = GCSpause; /* End of GC cycle. */ g->gc.debt = 0; return 0; default: lua_assert(0); return 0; } } /* Perform a limited amount of incremental GC steps. */ int LJ_FASTCALL lj_gc_step(lua_State *L) { global_State *g = G(L); MSize lim; int32_t ostate = g->vmstate; setvmstate(g, GC); lim = (GCSTEPSIZE/100) * g->gc.stepmul; if (lim == 0) lim = LJ_MAX_MEM; g->gc.debt += g->gc.total - g->gc.threshold; do { lim -= (MSize)gc_onestep(L); if (g->gc.state == GCSpause) { g->gc.threshold = (g->gc.estimate/100) * g->gc.pause; g->vmstate = ostate; return 1; /* Finished a GC cycle. */ } } while ((int32_t)lim > 0); if (g->gc.debt < GCSTEPSIZE) { g->gc.threshold = g->gc.total + GCSTEPSIZE; } else { g->gc.debt -= GCSTEPSIZE; g->gc.threshold = g->gc.total; } g->vmstate = ostate; return 0; } /* Ditto, but fix the stack top first. */ void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L) { if (curr_funcisL(L)) L->top = curr_topL(L); lj_gc_step(L); } #if LJ_HASJIT /* Perform multiple GC steps. Called from JIT-compiled code. */ int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps) { lua_State *L = gco2th(gcref(g->jit_L)); L->base = mref(G(L)->jit_base, TValue); L->top = curr_topL(L); while (steps-- > 0 && lj_gc_step(L) == 0) ; /* Return 1 to force a trace exit. */ return (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize); } #endif /* Perform a full GC cycle. */ void lj_gc_fullgc(lua_State *L) { global_State *g = G(L); int32_t ostate = g->vmstate; setvmstate(g, GC); if (g->gc.state <= GCSatomic) { /* Caught somewhere in the middle. */ setmref(g->gc.sweep, &g->gc.root); /* Sweep everything (preserving it). */ setgcrefnull(g->gc.gray); /* Reset lists from partial propagation. */ setgcrefnull(g->gc.grayagain); setgcrefnull(g->gc.weak); g->gc.state = GCSsweepstring; /* Fast forward to the sweep phase. */ g->gc.sweepstr = 0; } while (g->gc.state == GCSsweepstring || g->gc.state == GCSsweep) gc_onestep(L); /* Finish sweep. */ lua_assert(g->gc.state == GCSfinalize || g->gc.state == GCSpause); /* Now perform a full GC. */ g->gc.state = GCSpause; do { gc_onestep(L); } while (g->gc.state != GCSpause); g->gc.threshold = (g->gc.estimate/100) * g->gc.pause; g->vmstate = ostate; } /* -- Write barriers ------------------------------------------------------ */ /* Move the GC propagation frontier forward. */ void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v) { lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); lua_assert(o->gch.gct != ~LJ_TTAB); /* Preserve invariant during propagation. Otherwise it doesn't matter. */ if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) gc_mark(g, v); /* Move frontier forward. */ else makewhite(g, o); /* Make it white to avoid the following barrier. */ } /* Specialized barrier for closed upvalue. Pass &uv->tv. */ void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv) { #define TV2MARKED(x) \ (*((uint8_t *)(x) - offsetof(GCupval, tv) + offsetof(GCupval, marked))) if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) gc_mark(g, gcV(tv)); else TV2MARKED(tv) = (TV2MARKED(tv) & (uint8_t)~LJ_GC_COLORS) | curwhite(g); #undef TV2MARKED } /* Close upvalue. Also needs a write barrier. */ void lj_gc_closeuv(global_State *g, GCupval *uv) { GCobj *o = obj2gco(uv); /* Copy stack slot to upvalue itself and point to the copy. */ copyTV(mainthread(g), &uv->tv, uvval(uv)); setmref(uv->v, &uv->tv); uv->closed = 1; setgcrefr(o->gch.nextgc, g->gc.root); setgcref(g->gc.root, o); if (isgray(o)) { /* A closed upvalue is never gray, so fix this. */ if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) { gray2black(o); /* Make it black and preserve invariant. */ if (tviswhite(&uv->tv)) lj_gc_barrierf(g, o, gcV(&uv->tv)); } else { makewhite(g, o); /* Make it white, i.e. sweep the upvalue. */ lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); } } } #if LJ_HASJIT /* Mark a trace if it's saved during the propagation phase. */ void lj_gc_barriertrace(global_State *g, uint32_t traceno) { if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic) gc_marktrace(g, traceno); } #endif /* -- Allocator ----------------------------------------------------------- */ /* Call pluggable memory allocator to allocate or resize a fragment. */ void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz) { global_State *g = G(L); lua_assert((osz == 0) == (p == NULL)); p = g->allocf(g->allocd, p, osz, nsz); if (p == NULL && nsz > 0) lj_err_mem(L); lua_assert((nsz == 0) == (p == NULL)); lua_assert(checkptr32(p)); g->gc.total = (g->gc.total - osz) + nsz; return p; } /* Allocate new GC object and link it to the root set. */ void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size) { global_State *g = G(L); GCobj *o = (GCobj *)g->allocf(g->allocd, NULL, 0, size); if (o == NULL) lj_err_mem(L); lua_assert(checkptr32(o)); g->gc.total += size; setgcrefr(o->gch.nextgc, g->gc.root); setgcref(g->gc.root, o); newwhite(g, o); return o; } /* Resize growable vector. */ void *lj_mem_grow(lua_State *L, void *p, MSize *szp, MSize lim, MSize esz) { MSize sz = (*szp) << 1; if (sz < LJ_MIN_VECSZ) sz = LJ_MIN_VECSZ; if (sz > lim) sz = lim; p = lj_mem_realloc(L, p, (*szp)*esz, sz*esz); *szp = sz; return p; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_gc.h ================================================ /* ** Garbage collector. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_GC_H #define _LJ_GC_H #include "lj_obj.h" /* Garbage collector states. Order matters. */ enum { GCSpause, GCSpropagate, GCSatomic, GCSsweepstring, GCSsweep, GCSfinalize }; /* Bitmasks for marked field of GCobj. */ #define LJ_GC_WHITE0 0x01 #define LJ_GC_WHITE1 0x02 #define LJ_GC_BLACK 0x04 #define LJ_GC_FINALIZED 0x08 #define LJ_GC_WEAKKEY 0x08 #define LJ_GC_WEAKVAL 0x10 #define LJ_GC_CDATA_FIN 0x10 #define LJ_GC_FIXED 0x20 #define LJ_GC_SFIXED 0x40 #define LJ_GC_WHITES (LJ_GC_WHITE0 | LJ_GC_WHITE1) #define LJ_GC_COLORS (LJ_GC_WHITES | LJ_GC_BLACK) #define LJ_GC_WEAK (LJ_GC_WEAKKEY | LJ_GC_WEAKVAL) /* Macros to test and set GCobj colors. */ #define iswhite(x) ((x)->gch.marked & LJ_GC_WHITES) #define isblack(x) ((x)->gch.marked & LJ_GC_BLACK) #define isgray(x) (!((x)->gch.marked & (LJ_GC_BLACK|LJ_GC_WHITES))) #define tviswhite(x) (tvisgcv(x) && iswhite(gcV(x))) #define otherwhite(g) (g->gc.currentwhite ^ LJ_GC_WHITES) #define isdead(g, v) ((v)->gch.marked & otherwhite(g) & LJ_GC_WHITES) #define curwhite(g) ((g)->gc.currentwhite & LJ_GC_WHITES) #define newwhite(g, x) (obj2gco(x)->gch.marked = (uint8_t)curwhite(g)) #define makewhite(g, x) \ ((x)->gch.marked = ((x)->gch.marked & (uint8_t)~LJ_GC_COLORS) | curwhite(g)) #define flipwhite(x) ((x)->gch.marked ^= LJ_GC_WHITES) #define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK) #define fixstring(s) ((s)->marked |= LJ_GC_FIXED) #define markfinalized(x) ((x)->gch.marked |= LJ_GC_FINALIZED) /* Collector. */ LJ_FUNC size_t lj_gc_separateudata(global_State *g, int all); LJ_FUNC void lj_gc_finalize_udata(lua_State *L); #if LJ_HASFFI LJ_FUNC void lj_gc_finalize_cdata(lua_State *L); #else #define lj_gc_finalize_cdata(L) UNUSED(L) #endif LJ_FUNC void lj_gc_freeall(global_State *g); LJ_FUNCA int LJ_FASTCALL lj_gc_step(lua_State *L); LJ_FUNCA void LJ_FASTCALL lj_gc_step_fixtop(lua_State *L); #if LJ_HASJIT LJ_FUNC int LJ_FASTCALL lj_gc_step_jit(global_State *g, MSize steps); #endif LJ_FUNC void lj_gc_fullgc(lua_State *L); /* GC check: drive collector forward if the GC threshold has been reached. */ #define lj_gc_check(L) \ { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ lj_gc_step(L); } #define lj_gc_check_fixtop(L) \ { if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \ lj_gc_step_fixtop(L); } /* Write barriers. */ LJ_FUNC void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v); LJ_FUNCA void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv); LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv); #if LJ_HASJIT LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno); #endif /* Move the GC propagation frontier back for tables (make it gray again). */ static LJ_AINLINE void lj_gc_barrierback(global_State *g, GCtab *t) { GCobj *o = obj2gco(t); lua_assert(isblack(o) && !isdead(g, o)); lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); black2gray(o); setgcrefr(t->gclist, g->gc.grayagain); setgcref(g->gc.grayagain, o); } /* Barrier for stores to table objects. TValue and GCobj variant. */ #define lj_gc_anybarriert(L, t) \ { if (LJ_UNLIKELY(isblack(obj2gco(t)))) lj_gc_barrierback(G(L), (t)); } #define lj_gc_barriert(L, t, tv) \ { if (tviswhite(tv) && isblack(obj2gco(t))) \ lj_gc_barrierback(G(L), (t)); } #define lj_gc_objbarriert(L, t, o) \ { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) \ lj_gc_barrierback(G(L), (t)); } /* Barrier for stores to any other object. TValue and GCobj variant. */ #define lj_gc_barrier(L, p, tv) \ { if (tviswhite(tv) && isblack(obj2gco(p))) \ lj_gc_barrierf(G(L), obj2gco(p), gcV(tv)); } #define lj_gc_objbarrier(L, p, o) \ { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ lj_gc_barrierf(G(L), obj2gco(p), obj2gco(o)); } /* Allocator. */ LJ_FUNC void *lj_mem_realloc(lua_State *L, void *p, MSize osz, MSize nsz); LJ_FUNC void * LJ_FASTCALL lj_mem_newgco(lua_State *L, MSize size); LJ_FUNC void *lj_mem_grow(lua_State *L, void *p, MSize *szp, MSize lim, MSize esz); #define lj_mem_new(L, s) lj_mem_realloc(L, NULL, 0, (s)) static LJ_AINLINE void lj_mem_free(global_State *g, void *p, size_t osize) { g->gc.total -= (MSize)osize; g->allocf(g->allocd, p, osize, 0); } #define lj_mem_newvec(L, n, t) ((t *)lj_mem_new(L, (MSize)((n)*sizeof(t)))) #define lj_mem_reallocvec(L, p, on, n, t) \ ((p) = (t *)lj_mem_realloc(L, p, (on)*sizeof(t), (MSize)((n)*sizeof(t)))) #define lj_mem_growvec(L, p, n, m, t) \ ((p) = (t *)lj_mem_grow(L, (p), &(n), (m), (MSize)sizeof(t))) #define lj_mem_freevec(g, p, n, t) lj_mem_free(g, (p), (n)*sizeof(t)) #define lj_mem_newobj(L, t) ((t *)lj_mem_newgco(L, sizeof(t))) #define lj_mem_newt(L, s, t) ((t *)lj_mem_new(L, (s))) #define lj_mem_freet(g, p) lj_mem_free(g, (p), sizeof(*(p))) #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_gdbjit.c ================================================ /* ** Client for the GDB JIT API. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_gdbjit_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_gc.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_frame.h" #include "lj_jit.h" #include "lj_dispatch.h" /* This is not compiled in by default. ** Enable with -DLUAJIT_USE_GDBJIT in the Makefile and recompile everything. */ #ifdef LUAJIT_USE_GDBJIT /* The GDB JIT API allows JIT compilers to pass debug information about ** JIT-compiled code back to GDB. You need at least GDB 7.0 or higher ** to see it in action. ** ** This is a passive API, so it works even when not running under GDB ** or when attaching to an already running process. Alas, this implies ** enabling it always has a non-negligible overhead -- do not use in ** release mode! ** ** The LuaJIT GDB JIT client is rather minimal at the moment. It gives ** each trace a symbol name and adds a source location and frame unwind ** information. Obviously LuaJIT itself and any embedding C application ** should be compiled with debug symbols, too (see the Makefile). ** ** Traces are named TRACE_1, TRACE_2, ... these correspond to the trace ** numbers from -jv or -jdump. Use "break TRACE_1" or "tbreak TRACE_1" etc. ** to set breakpoints on specific traces (even ahead of their creation). ** ** The source location for each trace allows listing the corresponding ** source lines with the GDB command "list" (but only if the Lua source ** has been loaded from a file). Currently this is always set to the ** location where the trace has been started. ** ** Frame unwind information can be inspected with the GDB command ** "info frame". This also allows proper backtraces across JIT-compiled ** code with the GDB command "bt". ** ** You probably want to add the following settings to a .gdbinit file ** (or add them to ~/.gdbinit): ** set disassembly-flavor intel ** set breakpoint pending on ** ** Here's a sample GDB session: ** ------------------------------------------------------------------------ $ cat >x.lua for outer=1,100 do for inner=1,100 do end end ^D $ luajit -jv x.lua [TRACE 1 x.lua:2] [TRACE 2 (1/3) x.lua:1 -> 1] $ gdb --quiet --args luajit x.lua (gdb) tbreak TRACE_1 Function "TRACE_1" not defined. Temporary breakpoint 1 (TRACE_1) pending. (gdb) run Starting program: luajit x.lua Temporary breakpoint 1, TRACE_1 () at x.lua:2 2 for inner=1,100 do end (gdb) list 1 for outer=1,100 do 2 for inner=1,100 do end 3 end (gdb) bt #0 TRACE_1 () at x.lua:2 #1 0x08053690 in lua_pcall [...] [...] #7 0x0806ff90 in main [...] (gdb) disass TRACE_1 Dump of assembler code for function TRACE_1: 0xf7fd9fba : mov DWORD PTR ds:0xf7e0e2a0,0x1 0xf7fd9fc4 : movsd xmm7,QWORD PTR [edx+0x20] [...] 0xf7fd9ff8 : jmp 0xf7fd2014 End of assembler dump. (gdb) tbreak TRACE_2 Function "TRACE_2" not defined. Temporary breakpoint 2 (TRACE_2) pending. (gdb) cont Continuing. Temporary breakpoint 2, TRACE_2 () at x.lua:1 1 for outer=1,100 do (gdb) info frame Stack level 0, frame at 0xffffd7c0: eip = 0xf7fd9f60 in TRACE_2 (x.lua:1); saved eip 0x8053690 called by frame at 0xffffd7e0 source language unknown. Arglist at 0xffffd78c, args: Locals at 0xffffd78c, Previous frame's sp is 0xffffd7c0 Saved registers: ebx at 0xffffd7ac, ebp at 0xffffd7b8, esi at 0xffffd7b0, edi at 0xffffd7b4, eip at 0xffffd7bc (gdb) ** ------------------------------------------------------------------------ */ /* -- GDB JIT API --------------------------------------------------------- */ /* GDB JIT actions. */ enum { GDBJIT_NOACTION = 0, GDBJIT_REGISTER, GDBJIT_UNREGISTER }; /* GDB JIT entry. */ typedef struct GDBJITentry { struct GDBJITentry *next_entry; struct GDBJITentry *prev_entry; const char *symfile_addr; uint64_t symfile_size; } GDBJITentry; /* GDB JIT descriptor. */ typedef struct GDBJITdesc { uint32_t version; uint32_t action_flag; GDBJITentry *relevant_entry; GDBJITentry *first_entry; } GDBJITdesc; GDBJITdesc __jit_debug_descriptor = { 1, GDBJIT_NOACTION, NULL, NULL }; /* GDB sets a breakpoint at this function. */ void LJ_NOINLINE __jit_debug_register_code() { __asm__ __volatile__(""); }; /* -- In-memory ELF object definitions ------------------------------------ */ /* ELF definitions. */ typedef struct ELFheader { uint8_t emagic[4]; uint8_t eclass; uint8_t eendian; uint8_t eversion; uint8_t eosabi; uint8_t eabiversion; uint8_t epad[7]; uint16_t type; uint16_t machine; uint32_t version; uintptr_t entry; uintptr_t phofs; uintptr_t shofs; uint32_t flags; uint16_t ehsize; uint16_t phentsize; uint16_t phnum; uint16_t shentsize; uint16_t shnum; uint16_t shstridx; } ELFheader; typedef struct ELFsectheader { uint32_t name; uint32_t type; uintptr_t flags; uintptr_t addr; uintptr_t ofs; uintptr_t size; uint32_t link; uint32_t info; uintptr_t align; uintptr_t entsize; } ELFsectheader; #define ELFSECT_IDX_ABS 0xfff1 enum { ELFSECT_TYPE_PROGBITS = 1, ELFSECT_TYPE_SYMTAB = 2, ELFSECT_TYPE_STRTAB = 3, ELFSECT_TYPE_NOBITS = 8 }; #define ELFSECT_FLAGS_WRITE 1 #define ELFSECT_FLAGS_ALLOC 2 #define ELFSECT_FLAGS_EXEC 4 typedef struct ELFsymbol { #if LJ_64 uint32_t name; uint8_t info; uint8_t other; uint16_t sectidx; uintptr_t value; uint64_t size; #else uint32_t name; uintptr_t value; uint32_t size; uint8_t info; uint8_t other; uint16_t sectidx; #endif } ELFsymbol; enum { ELFSYM_TYPE_FUNC = 2, ELFSYM_TYPE_FILE = 4, ELFSYM_BIND_LOCAL = 0 << 4, ELFSYM_BIND_GLOBAL = 1 << 4, }; /* DWARF definitions. */ #define DW_CIE_VERSION 1 enum { DW_CFA_nop = 0x0, DW_CFA_offset_extended = 0x5, DW_CFA_def_cfa = 0xc, DW_CFA_def_cfa_offset = 0xe, DW_CFA_offset_extended_sf = 0x11, DW_CFA_advance_loc = 0x40, DW_CFA_offset = 0x80 }; enum { DW_EH_PE_udata4 = 3, DW_EH_PE_textrel = 0x20 }; enum { DW_TAG_compile_unit = 0x11 }; enum { DW_children_no = 0, DW_children_yes = 1 }; enum { DW_AT_name = 0x03, DW_AT_stmt_list = 0x10, DW_AT_low_pc = 0x11, DW_AT_high_pc = 0x12 }; enum { DW_FORM_addr = 0x01, DW_FORM_data4 = 0x06, DW_FORM_string = 0x08 }; enum { DW_LNS_extended_op = 0, DW_LNS_copy = 1, DW_LNS_advance_pc = 2, DW_LNS_advance_line = 3 }; enum { DW_LNE_end_sequence = 1, DW_LNE_set_address = 2 }; enum { #if LJ_TARGET_X86 DW_REG_AX, DW_REG_CX, DW_REG_DX, DW_REG_BX, DW_REG_SP, DW_REG_BP, DW_REG_SI, DW_REG_DI, DW_REG_RA, #elif LJ_TARGET_X64 /* Yes, the order is strange, but correct. */ DW_REG_AX, DW_REG_DX, DW_REG_CX, DW_REG_BX, DW_REG_SI, DW_REG_DI, DW_REG_BP, DW_REG_SP, DW_REG_8, DW_REG_9, DW_REG_10, DW_REG_11, DW_REG_12, DW_REG_13, DW_REG_14, DW_REG_15, DW_REG_RA, #elif LJ_TARGET_ARM DW_REG_SP = 13, DW_REG_RA = 14, #elif LJ_TARGET_PPC DW_REG_SP = 1, DW_REG_RA = 65, DW_REG_CR = 70, #elif LJ_TARGET_MIPS DW_REG_SP = 29, DW_REG_RA = 31, #else #error "Unsupported target architecture" #endif }; /* Minimal list of sections for the in-memory ELF object. */ enum { GDBJIT_SECT_NULL, GDBJIT_SECT_text, GDBJIT_SECT_eh_frame, GDBJIT_SECT_shstrtab, GDBJIT_SECT_strtab, GDBJIT_SECT_symtab, GDBJIT_SECT_debug_info, GDBJIT_SECT_debug_abbrev, GDBJIT_SECT_debug_line, GDBJIT_SECT__MAX }; enum { GDBJIT_SYM_UNDEF, GDBJIT_SYM_FILE, GDBJIT_SYM_FUNC, GDBJIT_SYM__MAX }; /* In-memory ELF object. */ typedef struct GDBJITobj { ELFheader hdr; /* ELF header. */ ELFsectheader sect[GDBJIT_SECT__MAX]; /* ELF sections. */ ELFsymbol sym[GDBJIT_SYM__MAX]; /* ELF symbol table. */ uint8_t space[4096]; /* Space for various section data. */ } GDBJITobj; /* Combined structure for GDB JIT entry and ELF object. */ typedef struct GDBJITentryobj { GDBJITentry entry; size_t sz; GDBJITobj obj; } GDBJITentryobj; /* Template for in-memory ELF header. */ static const ELFheader elfhdr_template = { .emagic = { 0x7f, 'E', 'L', 'F' }, .eclass = LJ_64 ? 2 : 1, .eendian = LJ_ENDIAN_SELECT(1, 2), .eversion = 1, #if LJ_TARGET_LINUX .eosabi = 0, /* Nope, it's not 3. */ #elif defined(__FreeBSD__) .eosabi = 9, #elif defined(__NetBSD__) .eosabi = 2, #elif defined(__OpenBSD__) .eosabi = 12, #elif (defined(__sun__) && defined(__svr4__)) .eosabi = 6, #else .eosabi = 0, #endif .eabiversion = 0, .epad = { 0, 0, 0, 0, 0, 0, 0 }, .type = 1, #if LJ_TARGET_X86 .machine = 3, #elif LJ_TARGET_X64 .machine = 62, #elif LJ_TARGET_ARM .machine = 40, #elif LJ_TARGET_PPC .machine = 20, #elif LJ_TARGET_MIPS .machine = 8, #else #error "Unsupported target architecture" #endif .version = 1, .entry = 0, .phofs = 0, .shofs = offsetof(GDBJITobj, sect), .flags = 0, .ehsize = sizeof(ELFheader), .phentsize = 0, .phnum = 0, .shentsize = sizeof(ELFsectheader), .shnum = GDBJIT_SECT__MAX, .shstridx = GDBJIT_SECT_shstrtab }; /* -- In-memory ELF object generation ------------------------------------- */ /* Context for generating the ELF object for the GDB JIT API. */ typedef struct GDBJITctx { uint8_t *p; /* Pointer to next address in obj.space. */ uint8_t *startp; /* Pointer to start address in obj.space. */ GCtrace *T; /* Generate symbols for this trace. */ uintptr_t mcaddr; /* Machine code address. */ MSize szmcode; /* Size of machine code. */ MSize spadjp; /* Stack adjustment for parent trace or interpreter. */ MSize spadj; /* Stack adjustment for trace itself. */ BCLine lineno; /* Starting line number. */ const char *filename; /* Starting file name. */ size_t objsize; /* Final size of ELF object. */ GDBJITobj obj; /* In-memory ELF object. */ } GDBJITctx; /* Add a zero-terminated string. */ static uint32_t gdbjit_strz(GDBJITctx *ctx, const char *str) { uint8_t *p = ctx->p; uint32_t ofs = (uint32_t)(p - ctx->startp); do { *p++ = (uint8_t)*str; } while (*str++); ctx->p = p; return ofs; } /* Append a decimal number. */ static void gdbjit_catnum(GDBJITctx *ctx, uint32_t n) { if (n >= 10) { uint32_t m = n / 10; n = n % 10; gdbjit_catnum(ctx, m); } *ctx->p++ = '0' + n; } /* Add a ULEB128 value. */ static void gdbjit_uleb128(GDBJITctx *ctx, uint32_t v) { uint8_t *p = ctx->p; for (; v >= 0x80; v >>= 7) *p++ = (uint8_t)((v & 0x7f) | 0x80); *p++ = (uint8_t)v; ctx->p = p; } /* Add a SLEB128 value. */ static void gdbjit_sleb128(GDBJITctx *ctx, int32_t v) { uint8_t *p = ctx->p; for (; (uint32_t)(v+0x40) >= 0x80; v >>= 7) *p++ = (uint8_t)((v & 0x7f) | 0x80); *p++ = (uint8_t)(v & 0x7f); ctx->p = p; } /* Shortcuts to generate DWARF structures. */ #define DB(x) (*p++ = (x)) #define DI8(x) (*(int8_t *)p = (x), p++) #define DU16(x) (*(uint16_t *)p = (x), p += 2) #define DU32(x) (*(uint32_t *)p = (x), p += 4) #define DADDR(x) (*(uintptr_t *)p = (x), p += sizeof(uintptr_t)) #define DUV(x) (ctx->p = p, gdbjit_uleb128(ctx, (x)), p = ctx->p) #define DSV(x) (ctx->p = p, gdbjit_sleb128(ctx, (x)), p = ctx->p) #define DSTR(str) (ctx->p = p, gdbjit_strz(ctx, (str)), p = ctx->p) #define DALIGNNOP(s) while ((uintptr_t)p & ((s)-1)) *p++ = DW_CFA_nop #define DSECT(name, stmt) \ { uint32_t *szp_##name = (uint32_t *)p; p += 4; stmt \ *szp_##name = (uint32_t)((p-(uint8_t *)szp_##name)-4); } \ /* Initialize ELF section headers. */ static void LJ_FASTCALL gdbjit_secthdr(GDBJITctx *ctx) { ELFsectheader *sect; *ctx->p++ = '\0'; /* Empty string at start of string table. */ #define SECTDEF(id, tp, al) \ sect = &ctx->obj.sect[GDBJIT_SECT_##id]; \ sect->name = gdbjit_strz(ctx, "." #id); \ sect->type = ELFSECT_TYPE_##tp; \ sect->align = (al) SECTDEF(text, NOBITS, 16); sect->flags = ELFSECT_FLAGS_ALLOC|ELFSECT_FLAGS_EXEC; sect->addr = ctx->mcaddr; sect->ofs = 0; sect->size = ctx->szmcode; SECTDEF(eh_frame, PROGBITS, sizeof(uintptr_t)); sect->flags = ELFSECT_FLAGS_ALLOC; SECTDEF(shstrtab, STRTAB, 1); SECTDEF(strtab, STRTAB, 1); SECTDEF(symtab, SYMTAB, sizeof(uintptr_t)); sect->ofs = offsetof(GDBJITobj, sym); sect->size = sizeof(ctx->obj.sym); sect->link = GDBJIT_SECT_strtab; sect->entsize = sizeof(ELFsymbol); sect->info = GDBJIT_SYM_FUNC; SECTDEF(debug_info, PROGBITS, 1); SECTDEF(debug_abbrev, PROGBITS, 1); SECTDEF(debug_line, PROGBITS, 1); #undef SECTDEF } /* Initialize symbol table. */ static void LJ_FASTCALL gdbjit_symtab(GDBJITctx *ctx) { ELFsymbol *sym; *ctx->p++ = '\0'; /* Empty string at start of string table. */ sym = &ctx->obj.sym[GDBJIT_SYM_FILE]; sym->name = gdbjit_strz(ctx, "JIT mcode"); sym->sectidx = ELFSECT_IDX_ABS; sym->info = ELFSYM_TYPE_FILE|ELFSYM_BIND_LOCAL; sym = &ctx->obj.sym[GDBJIT_SYM_FUNC]; sym->name = gdbjit_strz(ctx, "TRACE_"); ctx->p--; gdbjit_catnum(ctx, ctx->T->traceno); *ctx->p++ = '\0'; sym->sectidx = GDBJIT_SECT_text; sym->value = 0; sym->size = ctx->szmcode; sym->info = ELFSYM_TYPE_FUNC|ELFSYM_BIND_GLOBAL; } /* Initialize .eh_frame section. */ static void LJ_FASTCALL gdbjit_ehframe(GDBJITctx *ctx) { uint8_t *p = ctx->p; uint8_t *framep = p; /* Emit DWARF EH CIE. */ DSECT(CIE, DU32(0); /* Offset to CIE itself. */ DB(DW_CIE_VERSION); DSTR("zR"); /* Augmentation. */ DUV(1); /* Code alignment factor. */ DSV(-(int32_t)sizeof(uintptr_t)); /* Data alignment factor. */ DB(DW_REG_RA); /* Return address register. */ DB(1); DB(DW_EH_PE_textrel|DW_EH_PE_udata4); /* Augmentation data. */ DB(DW_CFA_def_cfa); DUV(DW_REG_SP); DUV(sizeof(uintptr_t)); #if LJ_TARGET_PPC DB(DW_CFA_offset_extended_sf); DB(DW_REG_RA); DSV(-1); #else DB(DW_CFA_offset|DW_REG_RA); DUV(1); #endif DALIGNNOP(sizeof(uintptr_t)); ) /* Emit DWARF EH FDE. */ DSECT(FDE, DU32((uint32_t)(p-framep)); /* Offset to CIE. */ DU32(0); /* Machine code offset relative to .text. */ DU32(ctx->szmcode); /* Machine code length. */ DB(0); /* Augmentation data. */ /* Registers saved in CFRAME. */ #if LJ_TARGET_X86 DB(DW_CFA_offset|DW_REG_BP); DUV(2); DB(DW_CFA_offset|DW_REG_DI); DUV(3); DB(DW_CFA_offset|DW_REG_SI); DUV(4); DB(DW_CFA_offset|DW_REG_BX); DUV(5); #elif LJ_TARGET_X64 DB(DW_CFA_offset|DW_REG_BP); DUV(2); DB(DW_CFA_offset|DW_REG_BX); DUV(3); DB(DW_CFA_offset|DW_REG_15); DUV(4); DB(DW_CFA_offset|DW_REG_14); DUV(5); /* Extra registers saved for JIT-compiled code. */ DB(DW_CFA_offset|DW_REG_13); DUV(9); DB(DW_CFA_offset|DW_REG_12); DUV(10); #elif LJ_TARGET_ARM { int i; for (i = 11; i >= 4; i--) { DB(DW_CFA_offset|i); DUV(2+(11-i)); } } #elif LJ_TARGET_PPC { int i; DB(DW_CFA_offset_extended); DB(DW_REG_CR); DUV(55); for (i = 14; i <= 31; i++) { DB(DW_CFA_offset|i); DUV(37+(31-i)); DB(DW_CFA_offset|32|i); DUV(2+2*(31-i)); } } #elif LJ_TARGET_MIPS { int i; DB(DW_CFA_offset|30); DUV(2); for (i = 23; i >= 16; i--) { DB(DW_CFA_offset|i); DUV(26-i); } for (i = 30; i >= 20; i -= 2) { DB(DW_CFA_offset|32|i); DUV(42-i); } } #else #error "Unsupported target architecture" #endif if (ctx->spadjp != ctx->spadj) { /* Parent/interpreter stack frame size. */ DB(DW_CFA_def_cfa_offset); DUV(ctx->spadjp); DB(DW_CFA_advance_loc|1); /* Only an approximation. */ } DB(DW_CFA_def_cfa_offset); DUV(ctx->spadj); /* Trace stack frame size. */ DALIGNNOP(sizeof(uintptr_t)); ) ctx->p = p; } /* Initialize .debug_info section. */ static void LJ_FASTCALL gdbjit_debuginfo(GDBJITctx *ctx) { uint8_t *p = ctx->p; DSECT(info, DU16(2); /* DWARF version. */ DU32(0); /* Abbrev offset. */ DB(sizeof(uintptr_t)); /* Pointer size. */ DUV(1); /* Abbrev #1: DW_TAG_compile_unit. */ DSTR(ctx->filename); /* DW_AT_name. */ DADDR(ctx->mcaddr); /* DW_AT_low_pc. */ DADDR(ctx->mcaddr + ctx->szmcode); /* DW_AT_high_pc. */ DU32(0); /* DW_AT_stmt_list. */ ) ctx->p = p; } /* Initialize .debug_abbrev section. */ static void LJ_FASTCALL gdbjit_debugabbrev(GDBJITctx *ctx) { uint8_t *p = ctx->p; /* Abbrev #1: DW_TAG_compile_unit. */ DUV(1); DUV(DW_TAG_compile_unit); DB(DW_children_no); DUV(DW_AT_name); DUV(DW_FORM_string); DUV(DW_AT_low_pc); DUV(DW_FORM_addr); DUV(DW_AT_high_pc); DUV(DW_FORM_addr); DUV(DW_AT_stmt_list); DUV(DW_FORM_data4); DB(0); DB(0); ctx->p = p; } #define DLNE(op, s) (DB(DW_LNS_extended_op), DUV(1+(s)), DB((op))) /* Initialize .debug_line section. */ static void LJ_FASTCALL gdbjit_debugline(GDBJITctx *ctx) { uint8_t *p = ctx->p; DSECT(line, DU16(2); /* DWARF version. */ DSECT(header, DB(1); /* Minimum instruction length. */ DB(1); /* is_stmt. */ DI8(0); /* Line base for special opcodes. */ DB(2); /* Line range for special opcodes. */ DB(3+1); /* Opcode base at DW_LNS_advance_line+1. */ DB(0); DB(1); DB(1); /* Standard opcode lengths. */ /* Directory table. */ DB(0); /* File name table. */ DSTR(ctx->filename); DUV(0); DUV(0); DUV(0); DB(0); ) DLNE(DW_LNE_set_address, sizeof(uintptr_t)); DADDR(ctx->mcaddr); if (ctx->lineno) { DB(DW_LNS_advance_line); DSV(ctx->lineno-1); } DB(DW_LNS_copy); DB(DW_LNS_advance_pc); DUV(ctx->szmcode); DLNE(DW_LNE_end_sequence, 0); ) ctx->p = p; } #undef DLNE /* Undef shortcuts. */ #undef DB #undef DI8 #undef DU16 #undef DU32 #undef DADDR #undef DUV #undef DSV #undef DSTR #undef DALIGNNOP #undef DSECT /* Type of a section initializer callback. */ typedef void (LJ_FASTCALL *GDBJITinitf)(GDBJITctx *ctx); /* Call section initializer and set the section offset and size. */ static void gdbjit_initsect(GDBJITctx *ctx, int sect, GDBJITinitf initf) { ctx->startp = ctx->p; ctx->obj.sect[sect].ofs = (uintptr_t)((char *)ctx->p - (char *)&ctx->obj); initf(ctx); ctx->obj.sect[sect].size = (uintptr_t)(ctx->p - ctx->startp); } #define SECTALIGN(p, a) \ ((p) = (uint8_t *)(((uintptr_t)(p) + ((a)-1)) & ~(uintptr_t)((a)-1))) /* Build in-memory ELF object. */ static void gdbjit_buildobj(GDBJITctx *ctx) { GDBJITobj *obj = &ctx->obj; /* Fill in ELF header and clear structures. */ memcpy(&obj->hdr, &elfhdr_template, sizeof(ELFheader)); memset(&obj->sect, 0, sizeof(ELFsectheader)*GDBJIT_SECT__MAX); memset(&obj->sym, 0, sizeof(ELFsymbol)*GDBJIT_SYM__MAX); /* Initialize sections. */ ctx->p = obj->space; gdbjit_initsect(ctx, GDBJIT_SECT_shstrtab, gdbjit_secthdr); gdbjit_initsect(ctx, GDBJIT_SECT_strtab, gdbjit_symtab); gdbjit_initsect(ctx, GDBJIT_SECT_debug_info, gdbjit_debuginfo); gdbjit_initsect(ctx, GDBJIT_SECT_debug_abbrev, gdbjit_debugabbrev); gdbjit_initsect(ctx, GDBJIT_SECT_debug_line, gdbjit_debugline); SECTALIGN(ctx->p, sizeof(uintptr_t)); gdbjit_initsect(ctx, GDBJIT_SECT_eh_frame, gdbjit_ehframe); ctx->objsize = (size_t)((char *)ctx->p - (char *)obj); lua_assert(ctx->objsize < sizeof(GDBJITobj)); } #undef SECTALIGN /* -- Interface to GDB JIT API -------------------------------------------- */ /* Add new entry to GDB JIT symbol chain. */ static void gdbjit_newentry(lua_State *L, GDBJITctx *ctx) { /* Allocate memory for GDB JIT entry and ELF object. */ MSize sz = (MSize)(sizeof(GDBJITentryobj) - sizeof(GDBJITobj) + ctx->objsize); GDBJITentryobj *eo = lj_mem_newt(L, sz, GDBJITentryobj); memcpy(&eo->obj, &ctx->obj, ctx->objsize); /* Copy ELF object. */ eo->sz = sz; ctx->T->gdbjit_entry = (void *)eo; /* Link new entry to chain and register it. */ eo->entry.prev_entry = NULL; eo->entry.next_entry = __jit_debug_descriptor.first_entry; if (eo->entry.next_entry) eo->entry.next_entry->prev_entry = &eo->entry; eo->entry.symfile_addr = (const char *)&eo->obj; eo->entry.symfile_size = ctx->objsize; __jit_debug_descriptor.first_entry = &eo->entry; __jit_debug_descriptor.relevant_entry = &eo->entry; __jit_debug_descriptor.action_flag = GDBJIT_REGISTER; __jit_debug_register_code(); } /* Add debug info for newly compiled trace and notify GDB. */ void lj_gdbjit_addtrace(jit_State *J, GCtrace *T) { GDBJITctx ctx; GCproto *pt = &gcref(T->startpt)->pt; TraceNo parent = T->ir[REF_BASE].op1; const BCIns *startpc = mref(T->startpc, const BCIns); ctx.T = T; ctx.mcaddr = (uintptr_t)T->mcode; ctx.szmcode = T->szmcode; ctx.spadjp = CFRAME_SIZE_JIT + (MSize)(parent ? traceref(J, parent)->spadjust : 0); ctx.spadj = CFRAME_SIZE_JIT + T->spadjust; lua_assert(startpc >= proto_bc(pt) && startpc < proto_bc(pt) + pt->sizebc); ctx.lineno = lj_debug_line(pt, proto_bcpos(pt, startpc)); ctx.filename = proto_chunknamestr(pt); if (*ctx.filename == '@' || *ctx.filename == '=') ctx.filename++; else ctx.filename = "(string)"; gdbjit_buildobj(&ctx); gdbjit_newentry(J->L, &ctx); } /* Delete debug info for trace and notify GDB. */ void lj_gdbjit_deltrace(jit_State *J, GCtrace *T) { GDBJITentryobj *eo = (GDBJITentryobj *)T->gdbjit_entry; if (eo) { if (eo->entry.prev_entry) eo->entry.prev_entry->next_entry = eo->entry.next_entry; else __jit_debug_descriptor.first_entry = eo->entry.next_entry; if (eo->entry.next_entry) eo->entry.next_entry->prev_entry = eo->entry.prev_entry; __jit_debug_descriptor.relevant_entry = &eo->entry; __jit_debug_descriptor.action_flag = GDBJIT_UNREGISTER; __jit_debug_register_code(); lj_mem_free(J2G(J), eo, eo->sz); } } #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_gdbjit.h ================================================ /* ** Client for the GDB JIT API. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_GDBJIT_H #define _LJ_GDBJIT_H #include "lj_obj.h" #include "lj_jit.h" #if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); #else #define lj_gdbjit_addtrace(J, T) UNUSED(T) #define lj_gdbjit_deltrace(J, T) UNUSED(T) #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ir.c ================================================ /* ** SSA IR (Intermediate Representation) emitter. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_ir_c #define LUA_CORE /* For pointers to libc/libm functions. */ #include #include #include "lj_obj.h" #if LJ_HASJIT #include "lj_gc.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_ircall.h" #include "lj_iropt.h" #include "lj_trace.h" #if LJ_HASFFI #include "lj_ctype.h" #include "lj_cdata.h" #include "lj_carith.h" #endif #include "lj_vm.h" #include "lj_strscan.h" #include "lj_lib.h" /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) #define fins (&J->fold.ins) /* Pass IR on to next optimization in chain (FOLD). */ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) /* -- IR tables ----------------------------------------------------------- */ /* IR instruction modes. */ LJ_DATADEF const uint8_t lj_ir_mode[IR__MAX+1] = { IRDEF(IRMODE) 0 }; /* IR type sizes. */ LJ_DATADEF const uint8_t lj_ir_type_size[IRT__MAX+1] = { #define IRTSIZE(name, size) size, IRTDEF(IRTSIZE) #undef IRTSIZE 0 }; /* C call info for CALL* instructions. */ LJ_DATADEF const CCallInfo lj_ir_callinfo[] = { #define IRCALLCI(cond, name, nargs, kind, type, flags) \ { (ASMFunction)IRCALLCOND_##cond(name), \ (nargs)|(CCI_CALL_##kind)|(IRT_##type<irbuf + J->irbotlim; MSize szins = J->irtoplim - J->irbotlim; if (szins) { baseir = (IRIns *)lj_mem_realloc(J->L, baseir, szins*sizeof(IRIns), 2*szins*sizeof(IRIns)); J->irtoplim = J->irbotlim + 2*szins; } else { baseir = (IRIns *)lj_mem_realloc(J->L, NULL, 0, LJ_MIN_IRSZ*sizeof(IRIns)); J->irbotlim = REF_BASE - LJ_MIN_IRSZ/4; J->irtoplim = J->irbotlim + LJ_MIN_IRSZ; } J->cur.ir = J->irbuf = baseir - J->irbotlim; } /* Grow IR buffer at the bottom or shift it up. */ static void lj_ir_growbot(jit_State *J) { IRIns *baseir = J->irbuf + J->irbotlim; MSize szins = J->irtoplim - J->irbotlim; lua_assert(szins != 0); lua_assert(J->cur.nk == J->irbotlim); if (J->cur.nins + (szins >> 1) < J->irtoplim) { /* More than half of the buffer is free on top: shift up by a quarter. */ MSize ofs = szins >> 2; memmove(baseir + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns)); J->irbotlim -= ofs; J->irtoplim -= ofs; J->cur.ir = J->irbuf = baseir - J->irbotlim; } else { /* Double the buffer size, but split the growth amongst top/bottom. */ IRIns *newbase = lj_mem_newt(J->L, 2*szins*sizeof(IRIns), IRIns); MSize ofs = szins >= 256 ? 128 : (szins >> 1); /* Limit bottom growth. */ memcpy(newbase + ofs, baseir, (J->cur.nins - J->irbotlim)*sizeof(IRIns)); lj_mem_free(G(J->L), baseir, szins*sizeof(IRIns)); J->irbotlim -= ofs; J->irtoplim = J->irbotlim + 2*szins; J->cur.ir = J->irbuf = newbase - J->irbotlim; } } /* Emit IR without any optimizations. */ TRef LJ_FASTCALL lj_ir_emit(jit_State *J) { IRRef ref = lj_ir_nextins(J); IRIns *ir = IR(ref); IROp op = fins->o; ir->prev = J->chain[op]; J->chain[op] = (IRRef1)ref; ir->o = op; ir->op1 = fins->op1; ir->op2 = fins->op2; J->guardemit.irt |= fins->t.irt; return TREF(ref, irt_t((ir->t = fins->t))); } /* Emit call to a C function. */ TRef lj_ir_call(jit_State *J, IRCallID id, ...) { const CCallInfo *ci = &lj_ir_callinfo[id]; uint32_t n = CCI_NARGS(ci); TRef tr = TREF_NIL; va_list argp; va_start(argp, id); if ((ci->flags & CCI_L)) n--; if (n > 0) tr = va_arg(argp, IRRef); while (n-- > 1) tr = emitir(IRT(IR_CARG, IRT_NIL), tr, va_arg(argp, IRRef)); va_end(argp); if (CCI_OP(ci) == IR_CALLS) J->needsnap = 1; /* Need snapshot after call with side effect. */ return emitir(CCI_OPTYPE(ci), tr, id); } /* -- Interning of constants ---------------------------------------------- */ /* ** IR instructions for constants are kept between J->cur.nk >= ref < REF_BIAS. ** They are chained like all other instructions, but grow downwards. ** The are interned (like strings in the VM) to facilitate reference ** comparisons. The same constant must get the same reference. */ /* Get ref of next IR constant and optionally grow IR. ** Note: this may invalidate all IRIns *! */ static LJ_AINLINE IRRef ir_nextk(jit_State *J) { IRRef ref = J->cur.nk; if (LJ_UNLIKELY(ref <= J->irbotlim)) lj_ir_growbot(J); J->cur.nk = --ref; return ref; } /* Intern int32_t constant. */ TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k) { IRIns *ir, *cir = J->cur.ir; IRRef ref; for (ref = J->chain[IR_KINT]; ref; ref = cir[ref].prev) if (cir[ref].i == k) goto found; ref = ir_nextk(J); ir = IR(ref); ir->i = k; ir->t.irt = IRT_INT; ir->o = IR_KINT; ir->prev = J->chain[IR_KINT]; J->chain[IR_KINT] = (IRRef1)ref; found: return TREF(ref, IRT_INT); } /* The MRef inside the KNUM/KINT64 IR instructions holds the address of the ** 64 bit constant. The constants themselves are stored in a chained array ** and shared across traces. ** ** Rationale for choosing this data structure: ** - The address of the constants is embedded in the generated machine code ** and must never move. A resizable array or hash table wouldn't work. ** - Most apps need very few non-32 bit integer constants (less than a dozen). ** - Linear search is hard to beat in terms of speed and low complexity. */ typedef struct K64Array { MRef next; /* Pointer to next list. */ MSize numk; /* Number of used elements in this array. */ TValue k[LJ_MIN_K64SZ]; /* Array of constants. */ } K64Array; /* Free all chained arrays. */ void lj_ir_k64_freeall(jit_State *J) { K64Array *k; for (k = mref(J->k64, K64Array); k; ) { K64Array *next = mref(k->next, K64Array); lj_mem_free(J2G(J), k, sizeof(K64Array)); k = next; } } /* Find 64 bit constant in chained array or add it. */ cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64) { K64Array *k, *kp = NULL; TValue *ntv; MSize idx; /* Search for the constant in the whole chain of arrays. */ for (k = mref(J->k64, K64Array); k; k = mref(k->next, K64Array)) { kp = k; /* Remember previous element in list. */ for (idx = 0; idx < k->numk; idx++) { /* Search one array. */ TValue *tv = &k->k[idx]; if (tv->u64 == u64) /* Needed for +-0/NaN/absmask. */ return tv; } } /* Constant was not found, need to add it. */ if (!(kp && kp->numk < LJ_MIN_K64SZ)) { /* Allocate a new array. */ K64Array *kn = lj_mem_newt(J->L, sizeof(K64Array), K64Array); setmref(kn->next, NULL); kn->numk = 0; if (kp) setmref(kp->next, kn); /* Chain to the end of the list. */ else setmref(J->k64, kn); /* Link first array. */ kp = kn; } ntv = &kp->k[kp->numk++]; /* Add to current array. */ ntv->u64 = u64; return ntv; } /* Intern 64 bit constant, given by its address. */ TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv) { IRIns *ir, *cir = J->cur.ir; IRRef ref; IRType t = op == IR_KNUM ? IRT_NUM : IRT_I64; for (ref = J->chain[op]; ref; ref = cir[ref].prev) if (ir_k64(&cir[ref]) == tv) goto found; ref = ir_nextk(J); ir = IR(ref); lua_assert(checkptr32(tv)); setmref(ir->ptr, tv); ir->t.irt = t; ir->o = op; ir->prev = J->chain[op]; J->chain[op] = (IRRef1)ref; found: return TREF(ref, t); } /* Intern FP constant, given by its 64 bit pattern. */ TRef lj_ir_knum_u64(jit_State *J, uint64_t u64) { return lj_ir_k64(J, IR_KNUM, lj_ir_k64_find(J, u64)); } /* Intern 64 bit integer constant. */ TRef lj_ir_kint64(jit_State *J, uint64_t u64) { return lj_ir_k64(J, IR_KINT64, lj_ir_k64_find(J, u64)); } /* Check whether a number is int and return it. -0 is NOT considered an int. */ static int numistrueint(lua_Number n, int32_t *kp) { int32_t k = lj_num2int(n); if (n == (lua_Number)k) { if (kp) *kp = k; if (k == 0) { /* Special check for -0. */ TValue tv; setnumV(&tv, n); if (tv.u32.hi != 0) return 0; } return 1; } return 0; } /* Intern number as int32_t constant if possible, otherwise as FP constant. */ TRef lj_ir_knumint(jit_State *J, lua_Number n) { int32_t k; if (numistrueint(n, &k)) return lj_ir_kint(J, k); else return lj_ir_knum(J, n); } /* Intern GC object "constant". */ TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t) { IRIns *ir, *cir = J->cur.ir; IRRef ref; lua_assert(!isdead(J2G(J), o)); for (ref = J->chain[IR_KGC]; ref; ref = cir[ref].prev) if (ir_kgc(&cir[ref]) == o) goto found; ref = ir_nextk(J); ir = IR(ref); /* NOBARRIER: Current trace is a GC root. */ setgcref(ir->gcr, o); ir->t.irt = (uint8_t)t; ir->o = IR_KGC; ir->prev = J->chain[IR_KGC]; J->chain[IR_KGC] = (IRRef1)ref; found: return TREF(ref, t); } /* Intern 32 bit pointer constant. */ TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr) { IRIns *ir, *cir = J->cur.ir; IRRef ref; lua_assert((void *)(intptr_t)i32ptr(ptr) == ptr); for (ref = J->chain[op]; ref; ref = cir[ref].prev) if (mref(cir[ref].ptr, void) == ptr) goto found; ref = ir_nextk(J); ir = IR(ref); setmref(ir->ptr, ptr); ir->t.irt = IRT_P32; ir->o = op; ir->prev = J->chain[op]; J->chain[op] = (IRRef1)ref; found: return TREF(ref, IRT_P32); } /* Intern typed NULL constant. */ TRef lj_ir_knull(jit_State *J, IRType t) { IRIns *ir, *cir = J->cur.ir; IRRef ref; for (ref = J->chain[IR_KNULL]; ref; ref = cir[ref].prev) if (irt_t(cir[ref].t) == t) goto found; ref = ir_nextk(J); ir = IR(ref); ir->i = 0; ir->t.irt = (uint8_t)t; ir->o = IR_KNULL; ir->prev = J->chain[IR_KNULL]; J->chain[IR_KNULL] = (IRRef1)ref; found: return TREF(ref, t); } /* Intern key slot. */ TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot) { IRIns *ir, *cir = J->cur.ir; IRRef2 op12 = IRREF2((IRRef1)key, (IRRef1)slot); IRRef ref; /* Const part is not touched by CSE/DCE, so 0-65535 is ok for IRMlit here. */ lua_assert(tref_isk(key) && slot == (IRRef)(IRRef1)slot); for (ref = J->chain[IR_KSLOT]; ref; ref = cir[ref].prev) if (cir[ref].op12 == op12) goto found; ref = ir_nextk(J); ir = IR(ref); ir->op12 = op12; ir->t.irt = IRT_P32; ir->o = IR_KSLOT; ir->prev = J->chain[IR_KSLOT]; J->chain[IR_KSLOT] = (IRRef1)ref; found: return TREF(ref, IRT_P32); } /* -- Access to IR constants ---------------------------------------------- */ /* Copy value of IR constant. */ void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir) { UNUSED(L); lua_assert(ir->o != IR_KSLOT); /* Common mistake. */ switch (ir->o) { case IR_KPRI: setitype(tv, irt_toitype(ir->t)); break; case IR_KINT: setintV(tv, ir->i); break; case IR_KGC: setgcV(L, tv, ir_kgc(ir), irt_toitype(ir->t)); break; case IR_KPTR: case IR_KKPTR: case IR_KNULL: setlightudV(tv, mref(ir->ptr, void)); break; case IR_KNUM: setnumV(tv, ir_knum(ir)->n); break; #if LJ_HASFFI case IR_KINT64: { GCcdata *cd = lj_cdata_new_(L, CTID_INT64, 8); *(uint64_t *)cdataptr(cd) = ir_kint64(ir)->u64; setcdataV(L, tv, cd); break; } #endif default: lua_assert(0); break; } } /* -- Convert IR operand types -------------------------------------------- */ /* Convert from string to number. */ TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr) { if (!tref_isnumber(tr)) { if (tref_isstr(tr)) tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); else lj_trace_err(J, LJ_TRERR_BADTYPE); } return tr; } /* Convert from integer or string to number. */ TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr) { if (!tref_isnum(tr)) { if (tref_isinteger(tr)) tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); else if (tref_isstr(tr)) tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); else lj_trace_err(J, LJ_TRERR_BADTYPE); } return tr; } /* Convert from integer or number to string. */ TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr) { if (!tref_isstr(tr)) { if (!tref_isnumber(tr)) lj_trace_err(J, LJ_TRERR_BADTYPE); tr = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0); } return tr; } /* -- Miscellaneous IR ops ------------------------------------------------ */ /* Evaluate numeric comparison. */ int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op) { switch (op) { case IR_EQ: return (a == b); case IR_NE: return (a != b); case IR_LT: return (a < b); case IR_GE: return (a >= b); case IR_LE: return (a <= b); case IR_GT: return (a > b); case IR_ULT: return !(a >= b); case IR_UGE: return !(a < b); case IR_ULE: return !(a > b); case IR_UGT: return !(a <= b); default: lua_assert(0); return 0; } } /* Evaluate string comparison. */ int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op) { int res = lj_str_cmp(a, b); switch (op) { case IR_LT: return (res < 0); case IR_GE: return (res >= 0); case IR_LE: return (res <= 0); case IR_GT: return (res > 0); default: lua_assert(0); return 0; } } /* Rollback IR to previous state. */ void lj_ir_rollback(jit_State *J, IRRef ref) { IRRef nins = J->cur.nins; while (nins > ref) { IRIns *ir; nins--; ir = IR(nins); J->chain[ir->o] = ir->prev; } J->cur.nins = nins; } #undef IR #undef fins #undef emitir #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ir.h ================================================ /* ** SSA IR (Intermediate Representation) format. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_IR_H #define _LJ_IR_H #include "lj_obj.h" /* -- IR instructions ----------------------------------------------------- */ /* IR instruction definition. Order matters, see below. ORDER IR */ #define IRDEF(_) \ /* Guarded assertions. */ \ /* Must be properly aligned to flip opposites (^1) and (un)ordered (^4). */ \ _(LT, N , ref, ref) \ _(GE, N , ref, ref) \ _(LE, N , ref, ref) \ _(GT, N , ref, ref) \ \ _(ULT, N , ref, ref) \ _(UGE, N , ref, ref) \ _(ULE, N , ref, ref) \ _(UGT, N , ref, ref) \ \ _(EQ, C , ref, ref) \ _(NE, C , ref, ref) \ \ _(ABC, N , ref, ref) \ _(RETF, S , ref, ref) \ \ /* Miscellaneous ops. */ \ _(NOP, N , ___, ___) \ _(BASE, N , lit, lit) \ _(PVAL, N , lit, ___) \ _(GCSTEP, S , ___, ___) \ _(HIOP, S , ref, ref) \ _(LOOP, S , ___, ___) \ _(USE, S , ref, ___) \ _(PHI, S , ref, ref) \ _(RENAME, S , ref, lit) \ \ /* Constants. */ \ _(KPRI, N , ___, ___) \ _(KINT, N , cst, ___) \ _(KGC, N , cst, ___) \ _(KPTR, N , cst, ___) \ _(KKPTR, N , cst, ___) \ _(KNULL, N , cst, ___) \ _(KNUM, N , cst, ___) \ _(KINT64, N , cst, ___) \ _(KSLOT, N , ref, lit) \ \ /* Bit ops. */ \ _(BNOT, N , ref, ___) \ _(BSWAP, N , ref, ___) \ _(BAND, C , ref, ref) \ _(BOR, C , ref, ref) \ _(BXOR, C , ref, ref) \ _(BSHL, N , ref, ref) \ _(BSHR, N , ref, ref) \ _(BSAR, N , ref, ref) \ _(BROL, N , ref, ref) \ _(BROR, N , ref, ref) \ \ /* Arithmetic ops. ORDER ARITH */ \ _(ADD, C , ref, ref) \ _(SUB, N , ref, ref) \ _(MUL, C , ref, ref) \ _(DIV, N , ref, ref) \ _(MOD, N , ref, ref) \ _(POW, N , ref, ref) \ _(NEG, N , ref, ref) \ \ _(ABS, N , ref, ref) \ _(ATAN2, N , ref, ref) \ _(LDEXP, N , ref, ref) \ _(MIN, C , ref, ref) \ _(MAX, C , ref, ref) \ _(FPMATH, N , ref, lit) \ \ /* Overflow-checking arithmetic ops. */ \ _(ADDOV, CW, ref, ref) \ _(SUBOV, NW, ref, ref) \ _(MULOV, CW, ref, ref) \ \ /* Memory ops. A = array, H = hash, U = upvalue, F = field, S = stack. */ \ \ /* Memory references. */ \ _(AREF, R , ref, ref) \ _(HREFK, R , ref, ref) \ _(HREF, L , ref, ref) \ _(NEWREF, S , ref, ref) \ _(UREFO, LW, ref, lit) \ _(UREFC, LW, ref, lit) \ _(FREF, R , ref, lit) \ _(STRREF, N , ref, ref) \ \ /* Loads and Stores. These must be in the same order. */ \ _(ALOAD, L , ref, ___) \ _(HLOAD, L , ref, ___) \ _(ULOAD, L , ref, ___) \ _(FLOAD, L , ref, lit) \ _(XLOAD, L , ref, lit) \ _(SLOAD, L , lit, lit) \ _(VLOAD, L , ref, ___) \ \ _(ASTORE, S , ref, ref) \ _(HSTORE, S , ref, ref) \ _(USTORE, S , ref, ref) \ _(FSTORE, S , ref, ref) \ _(XSTORE, S , ref, ref) \ \ /* Allocations. */ \ _(SNEW, N , ref, ref) /* CSE is ok, not marked as A. */ \ _(XSNEW, A , ref, ref) \ _(TNEW, AW, lit, lit) \ _(TDUP, AW, ref, ___) \ _(CNEW, AW, ref, ref) \ _(CNEWI, NW, ref, ref) /* CSE is ok, not marked as A. */ \ \ /* Barriers. */ \ _(TBAR, S , ref, ___) \ _(OBAR, S , ref, ref) \ _(XBAR, S , ___, ___) \ \ /* Type conversions. */ \ _(CONV, NW, ref, lit) \ _(TOBIT, N , ref, ref) \ _(TOSTR, N , ref, ___) \ _(STRTO, N , ref, ___) \ \ /* Calls. */ \ _(CALLN, N , ref, lit) \ _(CALLL, L , ref, lit) \ _(CALLS, S , ref, lit) \ _(CALLXS, S , ref, ref) \ _(CARG, N , ref, ref) \ \ /* End of list. */ /* IR opcodes (max. 256). */ typedef enum { #define IRENUM(name, m, m1, m2) IR_##name, IRDEF(IRENUM) #undef IRENUM IR__MAX } IROp; /* Stored opcode. */ typedef uint8_t IROp1; LJ_STATIC_ASSERT(((int)IR_EQ^1) == (int)IR_NE); LJ_STATIC_ASSERT(((int)IR_LT^1) == (int)IR_GE); LJ_STATIC_ASSERT(((int)IR_LE^1) == (int)IR_GT); LJ_STATIC_ASSERT(((int)IR_LT^3) == (int)IR_GT); LJ_STATIC_ASSERT(((int)IR_LT^4) == (int)IR_ULT); /* Delta between xLOAD and xSTORE. */ #define IRDELTA_L2S ((int)IR_ASTORE - (int)IR_ALOAD) LJ_STATIC_ASSERT((int)IR_HLOAD + IRDELTA_L2S == (int)IR_HSTORE); LJ_STATIC_ASSERT((int)IR_ULOAD + IRDELTA_L2S == (int)IR_USTORE); LJ_STATIC_ASSERT((int)IR_FLOAD + IRDELTA_L2S == (int)IR_FSTORE); LJ_STATIC_ASSERT((int)IR_XLOAD + IRDELTA_L2S == (int)IR_XSTORE); /* -- Named IR literals --------------------------------------------------- */ /* FPMATH sub-functions. ORDER FPM. */ #define IRFPMDEF(_) \ _(FLOOR) _(CEIL) _(TRUNC) /* Must be first and in this order. */ \ _(SQRT) _(EXP) _(EXP2) _(LOG) _(LOG2) _(LOG10) \ _(SIN) _(COS) _(TAN) \ _(OTHER) typedef enum { #define FPMENUM(name) IRFPM_##name, IRFPMDEF(FPMENUM) #undef FPMENUM IRFPM__MAX } IRFPMathOp; /* FLOAD fields. */ #define IRFLDEF(_) \ _(STR_LEN, offsetof(GCstr, len)) \ _(FUNC_ENV, offsetof(GCfunc, l.env)) \ _(FUNC_PC, offsetof(GCfunc, l.pc)) \ _(TAB_META, offsetof(GCtab, metatable)) \ _(TAB_ARRAY, offsetof(GCtab, array)) \ _(TAB_NODE, offsetof(GCtab, node)) \ _(TAB_ASIZE, offsetof(GCtab, asize)) \ _(TAB_HMASK, offsetof(GCtab, hmask)) \ _(TAB_NOMM, offsetof(GCtab, nomm)) \ _(UDATA_META, offsetof(GCudata, metatable)) \ _(UDATA_UDTYPE, offsetof(GCudata, udtype)) \ _(UDATA_FILE, sizeof(GCudata)) \ _(CDATA_CTYPEID, offsetof(GCcdata, ctypeid)) \ _(CDATA_PTR, sizeof(GCcdata)) \ _(CDATA_INT, sizeof(GCcdata)) \ _(CDATA_INT64, sizeof(GCcdata)) \ _(CDATA_INT64_4, sizeof(GCcdata) + 4) typedef enum { #define FLENUM(name, ofs) IRFL_##name, IRFLDEF(FLENUM) #undef FLENUM IRFL__MAX } IRFieldID; /* SLOAD mode bits, stored in op2. */ #define IRSLOAD_PARENT 0x01 /* Coalesce with parent trace. */ #define IRSLOAD_FRAME 0x02 /* Load hiword of frame. */ #define IRSLOAD_TYPECHECK 0x04 /* Needs type check. */ #define IRSLOAD_CONVERT 0x08 /* Number to integer conversion. */ #define IRSLOAD_READONLY 0x10 /* Read-only, omit slot store. */ #define IRSLOAD_INHERIT 0x20 /* Inherited by exits/side traces. */ /* XLOAD mode, stored in op2. */ #define IRXLOAD_READONLY 1 /* Load from read-only data. */ #define IRXLOAD_VOLATILE 2 /* Load from volatile data. */ #define IRXLOAD_UNALIGNED 4 /* Unaligned load. */ /* CONV mode, stored in op2. */ #define IRCONV_SRCMASK 0x001f /* Source IRType. */ #define IRCONV_DSTMASK 0x03e0 /* Dest. IRType (also in ir->t). */ #define IRCONV_DSH 5 #define IRCONV_NUM_INT ((IRT_NUM<>2)&3)) #define irm_iscomm(m) ((m) & IRM_C) #define irm_kind(m) ((m) & IRM_S) #define IRMODE(name, m, m1, m2) (((IRM##m1)|((IRM##m2)<<2)|(IRM_##m))^IRM_W), LJ_DATA const uint8_t lj_ir_mode[IR__MAX+1]; /* -- IR instruction types ------------------------------------------------ */ /* Map of itypes to non-negative numbers. ORDER LJ_T. ** LJ_TUPVAL/LJ_TTRACE never appear in a TValue. Use these itypes for ** IRT_P32 and IRT_P64, which never escape the IR. ** The various integers are only used in the IR and can only escape to ** a TValue after implicit or explicit conversion. Their types must be ** contiguous and next to IRT_NUM (see the typerange macros below). */ #define IRTDEF(_) \ _(NIL, 4) _(FALSE, 4) _(TRUE, 4) _(LIGHTUD, LJ_64 ? 8 : 4) _(STR, 4) \ _(P32, 4) _(THREAD, 4) _(PROTO, 4) _(FUNC, 4) _(P64, 8) _(CDATA, 4) \ _(TAB, 4) _(UDATA, 4) \ _(FLOAT, 4) _(NUM, 8) _(I8, 1) _(U8, 1) _(I16, 2) _(U16, 2) \ _(INT, 4) _(U32, 4) _(I64, 8) _(U64, 8) \ _(SOFTFP, 4) /* There is room for 9 more types. */ /* IR result type and flags (8 bit). */ typedef enum { #define IRTENUM(name, size) IRT_##name, IRTDEF(IRTENUM) #undef IRTENUM IRT__MAX, /* Native pointer type and the corresponding integer type. */ IRT_PTR = LJ_64 ? IRT_P64 : IRT_P32, IRT_INTP = LJ_64 ? IRT_I64 : IRT_INT, IRT_UINTP = LJ_64 ? IRT_U64 : IRT_U32, /* Additional flags. */ IRT_MARK = 0x20, /* Marker for misc. purposes. */ IRT_ISPHI = 0x40, /* Instruction is left or right PHI operand. */ IRT_GUARD = 0x80, /* Instruction is a guard. */ /* Masks. */ IRT_TYPE = 0x1f, IRT_T = 0xff } IRType; #define irtype_ispri(irt) ((uint32_t)(irt) <= IRT_TRUE) /* Stored IRType. */ typedef struct IRType1 { uint8_t irt; } IRType1; #define IRT(o, t) ((uint32_t)(((o)<<8) | (t))) #define IRTI(o) (IRT((o), IRT_INT)) #define IRTN(o) (IRT((o), IRT_NUM)) #define IRTG(o, t) (IRT((o), IRT_GUARD|(t))) #define IRTGI(o) (IRT((o), IRT_GUARD|IRT_INT)) #define irt_t(t) ((IRType)(t).irt) #define irt_type(t) ((IRType)((t).irt & IRT_TYPE)) #define irt_sametype(t1, t2) ((((t1).irt ^ (t2).irt) & IRT_TYPE) == 0) #define irt_typerange(t, first, last) \ ((uint32_t)((t).irt & IRT_TYPE) - (uint32_t)(first) <= (uint32_t)(last-first)) #define irt_isnil(t) (irt_type(t) == IRT_NIL) #define irt_ispri(t) ((uint32_t)irt_type(t) <= IRT_TRUE) #define irt_islightud(t) (irt_type(t) == IRT_LIGHTUD) #define irt_isstr(t) (irt_type(t) == IRT_STR) #define irt_istab(t) (irt_type(t) == IRT_TAB) #define irt_iscdata(t) (irt_type(t) == IRT_CDATA) #define irt_isfloat(t) (irt_type(t) == IRT_FLOAT) #define irt_isnum(t) (irt_type(t) == IRT_NUM) #define irt_isint(t) (irt_type(t) == IRT_INT) #define irt_isi8(t) (irt_type(t) == IRT_I8) #define irt_isu8(t) (irt_type(t) == IRT_U8) #define irt_isi16(t) (irt_type(t) == IRT_I16) #define irt_isu16(t) (irt_type(t) == IRT_U16) #define irt_isu32(t) (irt_type(t) == IRT_U32) #define irt_isi64(t) (irt_type(t) == IRT_I64) #define irt_isu64(t) (irt_type(t) == IRT_U64) #define irt_isfp(t) (irt_isnum(t) || irt_isfloat(t)) #define irt_isinteger(t) (irt_typerange((t), IRT_I8, IRT_INT)) #define irt_isgcv(t) (irt_typerange((t), IRT_STR, IRT_UDATA)) #define irt_isaddr(t) (irt_typerange((t), IRT_LIGHTUD, IRT_UDATA)) #define irt_isint64(t) (irt_typerange((t), IRT_I64, IRT_U64)) #if LJ_64 #define IRT_IS64 \ ((1u<> irt_type(t)) & 1) #define irt_is64orfp(t) (((IRT_IS64|(1u<>irt_type(t)) & 1) #define irt_size(t) (lj_ir_type_size[irt_t((t))]) LJ_DATA const uint8_t lj_ir_type_size[]; static LJ_AINLINE IRType itype2irt(const TValue *tv) { if (tvisint(tv)) return IRT_INT; else if (tvisnum(tv)) return IRT_NUM; #if LJ_64 else if (tvislightud(tv)) return IRT_LIGHTUD; #endif else return (IRType)~itype(tv); } static LJ_AINLINE uint32_t irt_toitype_(IRType t) { lua_assert(!LJ_64 || t != IRT_LIGHTUD); if (LJ_DUALNUM && t > IRT_NUM) { return LJ_TISNUM; } else { lua_assert(t <= IRT_NUM); return ~(uint32_t)t; } } #define irt_toitype(t) irt_toitype_(irt_type((t))) #define irt_isguard(t) ((t).irt & IRT_GUARD) #define irt_ismarked(t) ((t).irt & IRT_MARK) #define irt_setmark(t) ((t).irt |= IRT_MARK) #define irt_clearmark(t) ((t).irt &= ~IRT_MARK) #define irt_isphi(t) ((t).irt & IRT_ISPHI) #define irt_setphi(t) ((t).irt |= IRT_ISPHI) #define irt_clearphi(t) ((t).irt &= ~IRT_ISPHI) /* Stored combined IR opcode and type. */ typedef uint16_t IROpT; /* -- IR references ------------------------------------------------------- */ /* IR references. */ typedef uint16_t IRRef1; /* One stored reference. */ typedef uint32_t IRRef2; /* Two stored references. */ typedef uint32_t IRRef; /* Used to pass around references. */ /* Fixed references. */ enum { REF_BIAS = 0x8000, REF_TRUE = REF_BIAS-3, REF_FALSE = REF_BIAS-2, REF_NIL = REF_BIAS-1, /* \--- Constants grow downwards. */ REF_BASE = REF_BIAS, /* /--- IR grows upwards. */ REF_FIRST = REF_BIAS+1, REF_DROP = 0xffff }; /* Note: IRMlit operands must be < REF_BIAS, too! ** This allows for fast and uniform manipulation of all operands ** without looking up the operand mode in lj_ir_mode: ** - CSE calculates the maximum reference of two operands. ** This must work with mixed reference/literal operands, too. ** - DCE marking only checks for operand >= REF_BIAS. ** - LOOP needs to substitute reference operands. ** Constant references and literals must not be modified. */ #define IRREF2(lo, hi) ((IRRef2)(lo) | ((IRRef2)(hi) << 16)) #define irref_isk(ref) ((ref) < REF_BIAS) /* Tagged IR references (32 bit). ** ** +-------+-------+---------------+ ** | irt | flags | ref | ** +-------+-------+---------------+ ** ** The tag holds a copy of the IRType and speeds up IR type checks. */ typedef uint32_t TRef; #define TREF_REFMASK 0x0000ffff #define TREF_FRAME 0x00010000 #define TREF_CONT 0x00020000 #define TREF(ref, t) ((TRef)((ref) + ((t)<<24))) #define tref_ref(tr) ((IRRef1)(tr)) #define tref_t(tr) ((IRType)((tr)>>24)) #define tref_type(tr) ((IRType)(((tr)>>24) & IRT_TYPE)) #define tref_typerange(tr, first, last) \ ((((tr)>>24) & IRT_TYPE) - (TRef)(first) <= (TRef)(last-first)) #define tref_istype(tr, t) (((tr) & (IRT_TYPE<<24)) == ((t)<<24)) #define tref_isnil(tr) (tref_istype((tr), IRT_NIL)) #define tref_isfalse(tr) (tref_istype((tr), IRT_FALSE)) #define tref_istrue(tr) (tref_istype((tr), IRT_TRUE)) #define tref_isstr(tr) (tref_istype((tr), IRT_STR)) #define tref_isfunc(tr) (tref_istype((tr), IRT_FUNC)) #define tref_iscdata(tr) (tref_istype((tr), IRT_CDATA)) #define tref_istab(tr) (tref_istype((tr), IRT_TAB)) #define tref_isudata(tr) (tref_istype((tr), IRT_UDATA)) #define tref_isnum(tr) (tref_istype((tr), IRT_NUM)) #define tref_isint(tr) (tref_istype((tr), IRT_INT)) #define tref_isbool(tr) (tref_typerange((tr), IRT_FALSE, IRT_TRUE)) #define tref_ispri(tr) (tref_typerange((tr), IRT_NIL, IRT_TRUE)) #define tref_istruecond(tr) (!tref_typerange((tr), IRT_NIL, IRT_FALSE)) #define tref_isinteger(tr) (tref_typerange((tr), IRT_I8, IRT_INT)) #define tref_isnumber(tr) (tref_typerange((tr), IRT_NUM, IRT_INT)) #define tref_isnumber_str(tr) (tref_isnumber((tr)) || tref_isstr((tr))) #define tref_isgcv(tr) (tref_typerange((tr), IRT_STR, IRT_UDATA)) #define tref_isk(tr) (irref_isk(tref_ref((tr)))) #define tref_isk2(tr1, tr2) (irref_isk(tref_ref((tr1) | (tr2)))) #define TREF_PRI(t) (TREF(REF_NIL-(t), (t))) #define TREF_NIL (TREF_PRI(IRT_NIL)) #define TREF_FALSE (TREF_PRI(IRT_FALSE)) #define TREF_TRUE (TREF_PRI(IRT_TRUE)) /* -- IR format ----------------------------------------------------------- */ /* IR instruction format (64 bit). ** ** 16 16 8 8 8 8 ** +-------+-------+---+---+---+---+ ** | op1 | op2 | t | o | r | s | ** +-------+-------+---+---+---+---+ ** | op12/i/gco | ot | prev | (alternative fields in union) ** +---------------+-------+-------+ ** 32 16 16 ** ** prev is only valid prior to register allocation and then reused for r + s. */ typedef union IRIns { struct { LJ_ENDIAN_LOHI( IRRef1 op1; /* IR operand 1. */ , IRRef1 op2; /* IR operand 2. */ ) IROpT ot; /* IR opcode and type (overlaps t and o). */ IRRef1 prev; /* Previous ins in same chain (overlaps r and s). */ }; struct { IRRef2 op12; /* IR operand 1 and 2 (overlaps op1 and op2). */ LJ_ENDIAN_LOHI( IRType1 t; /* IR type. */ , IROp1 o; /* IR opcode. */ ) LJ_ENDIAN_LOHI( uint8_t r; /* Register allocation (overlaps prev). */ , uint8_t s; /* Spill slot allocation (overlaps prev). */ ) }; int32_t i; /* 32 bit signed integer literal (overlaps op12). */ GCRef gcr; /* GCobj constant (overlaps op12). */ MRef ptr; /* Pointer constant (overlaps op12). */ } IRIns; #define ir_kgc(ir) check_exp((ir)->o == IR_KGC, gcref((ir)->gcr)) #define ir_kstr(ir) (gco2str(ir_kgc((ir)))) #define ir_ktab(ir) (gco2tab(ir_kgc((ir)))) #define ir_kfunc(ir) (gco2func(ir_kgc((ir)))) #define ir_kcdata(ir) (gco2cd(ir_kgc((ir)))) #define ir_knum(ir) check_exp((ir)->o == IR_KNUM, mref((ir)->ptr, cTValue)) #define ir_kint64(ir) check_exp((ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) #define ir_k64(ir) \ check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) #define ir_kptr(ir) \ check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void)) /* A store or any other op with a non-weak guard has a side-effect. */ static LJ_AINLINE int ir_sideeff(IRIns *ir) { return (((ir->t.irt | ~IRT_GUARD) & lj_ir_mode[ir->o]) >= IRM_S); } LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_ircall.h ================================================ /* ** IR CALL* instruction definitions. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_IRCALL_H #define _LJ_IRCALL_H #include "lj_obj.h" #include "lj_ir.h" #include "lj_jit.h" /* C call info for CALL* instructions. */ typedef struct CCallInfo { ASMFunction func; /* Function pointer. */ uint32_t flags; /* Number of arguments and flags. */ } CCallInfo; #define CCI_NARGS(ci) ((ci)->flags & 0xff) /* Extract # of args. */ #define CCI_NARGS_MAX 32 /* Max. # of args. */ #define CCI_OTSHIFT 16 #define CCI_OPTYPE(ci) ((ci)->flags >> CCI_OTSHIFT) /* Get op/type. */ #define CCI_OPSHIFT 24 #define CCI_OP(ci) ((ci)->flags >> CCI_OPSHIFT) /* Get op. */ #define CCI_CALL_N (IR_CALLN << CCI_OPSHIFT) #define CCI_CALL_L (IR_CALLL << CCI_OPSHIFT) #define CCI_CALL_S (IR_CALLS << CCI_OPSHIFT) #define CCI_CALL_FN (CCI_CALL_N|CCI_CC_FASTCALL) #define CCI_CALL_FL (CCI_CALL_L|CCI_CC_FASTCALL) #define CCI_CALL_FS (CCI_CALL_S|CCI_CC_FASTCALL) /* C call info flags. */ #define CCI_L 0x0100 /* Implicit L arg. */ #define CCI_CASTU64 0x0200 /* Cast u64 result to number. */ #define CCI_NOFPRCLOBBER 0x0400 /* Does not clobber any FPRs. */ #define CCI_VARARG 0x0800 /* Vararg function. */ #define CCI_CC_MASK 0x3000 /* Calling convention mask. */ #define CCI_CC_SHIFT 12 /* ORDER CC */ #define CCI_CC_CDECL 0x0000 /* Default cdecl calling convention. */ #define CCI_CC_THISCALL 0x1000 /* Thiscall calling convention. */ #define CCI_CC_FASTCALL 0x2000 /* Fastcall calling convention. */ #define CCI_CC_STDCALL 0x3000 /* Stdcall calling convention. */ /* Helpers for conditional function definitions. */ #define IRCALLCOND_ANY(x) x #if LJ_TARGET_X86ORX64 #define IRCALLCOND_FPMATH(x) NULL #else #define IRCALLCOND_FPMATH(x) x #endif #if LJ_SOFTFP #define IRCALLCOND_SOFTFP(x) x #if LJ_HASFFI #define IRCALLCOND_SOFTFP_FFI(x) x #else #define IRCALLCOND_SOFTFP_FFI(x) NULL #endif #else #define IRCALLCOND_SOFTFP(x) NULL #define IRCALLCOND_SOFTFP_FFI(x) NULL #endif #define LJ_NEED_FP64 (LJ_TARGET_ARM || LJ_TARGET_PPC || LJ_TARGET_MIPS) #if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64) #define IRCALLCOND_FP64_FFI(x) x #else #define IRCALLCOND_FP64_FFI(x) NULL #endif #if LJ_HASFFI #define IRCALLCOND_FFI(x) x #if LJ_32 #define IRCALLCOND_FFI32(x) x #else #define IRCALLCOND_FFI32(x) NULL #endif #else #define IRCALLCOND_FFI(x) NULL #define IRCALLCOND_FFI32(x) NULL #endif #if LJ_SOFTFP #define ARG1_FP 2 /* Treat as 2 32 bit arguments. */ #else #define ARG1_FP 1 #endif #if LJ_32 #define ARG2_64 4 /* Treat as 4 32 bit arguments. */ #else #define ARG2_64 2 #endif /* Function definitions for CALL* instructions. */ #define IRCALLDEF(_) \ _(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \ _(ANY, lj_str_new, 3, S, STR, CCI_L) \ _(ANY, lj_strscan_num, 2, FN, INT, 0) \ _(ANY, lj_str_fromint, 2, FN, STR, CCI_L) \ _(ANY, lj_str_fromnum, 2, FN, STR, CCI_L) \ _(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \ _(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \ _(ANY, lj_tab_newkey, 3, S, P32, CCI_L) \ _(ANY, lj_tab_len, 1, FL, INT, 0) \ _(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \ _(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \ _(ANY, lj_mem_newgco, 2, FS, P32, CCI_L) \ _(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64|CCI_NOFPRCLOBBER) \ _(ANY, lj_vm_modi, 2, FN, INT, 0) \ _(ANY, sinh, ARG1_FP, N, NUM, 0) \ _(ANY, cosh, ARG1_FP, N, NUM, 0) \ _(ANY, tanh, ARG1_FP, N, NUM, 0) \ _(ANY, fputc, 2, S, INT, 0) \ _(ANY, fwrite, 4, S, INT, 0) \ _(ANY, fflush, 1, S, INT, 0) \ /* ORDER FPM */ \ _(FPMATH, lj_vm_floor, ARG1_FP, N, NUM, 0) \ _(FPMATH, lj_vm_ceil, ARG1_FP, N, NUM, 0) \ _(FPMATH, lj_vm_trunc, ARG1_FP, N, NUM, 0) \ _(FPMATH, sqrt, ARG1_FP, N, NUM, 0) \ _(FPMATH, exp, ARG1_FP, N, NUM, 0) \ _(FPMATH, lj_vm_exp2, ARG1_FP, N, NUM, 0) \ _(FPMATH, log, ARG1_FP, N, NUM, 0) \ _(FPMATH, lj_vm_log2, ARG1_FP, N, NUM, 0) \ _(FPMATH, log10, ARG1_FP, N, NUM, 0) \ _(FPMATH, sin, ARG1_FP, N, NUM, 0) \ _(FPMATH, cos, ARG1_FP, N, NUM, 0) \ _(FPMATH, tan, ARG1_FP, N, NUM, 0) \ _(FPMATH, lj_vm_powi, ARG1_FP+1, N, NUM, 0) \ _(FPMATH, pow, ARG1_FP*2, N, NUM, 0) \ _(FPMATH, atan2, ARG1_FP*2, N, NUM, 0) \ _(FPMATH, ldexp, ARG1_FP+1, N, NUM, 0) \ _(SOFTFP, lj_vm_tobit, 2, N, INT, 0) \ _(SOFTFP, softfp_add, 4, N, NUM, 0) \ _(SOFTFP, softfp_sub, 4, N, NUM, 0) \ _(SOFTFP, softfp_mul, 4, N, NUM, 0) \ _(SOFTFP, softfp_div, 4, N, NUM, 0) \ _(SOFTFP, softfp_cmp, 4, N, NIL, 0) \ _(SOFTFP, softfp_i2d, 1, N, NUM, 0) \ _(SOFTFP, softfp_d2i, 2, N, INT, 0) \ _(SOFTFP_FFI, softfp_ui2d, 1, N, NUM, 0) \ _(SOFTFP_FFI, softfp_f2d, 1, N, NUM, 0) \ _(SOFTFP_FFI, softfp_d2ui, 2, N, INT, 0) \ _(SOFTFP_FFI, softfp_d2f, 2, N, FLOAT, 0) \ _(SOFTFP_FFI, softfp_i2f, 1, N, FLOAT, 0) \ _(SOFTFP_FFI, softfp_ui2f, 1, N, FLOAT, 0) \ _(SOFTFP_FFI, softfp_f2i, 1, N, INT, 0) \ _(SOFTFP_FFI, softfp_f2ui, 1, N, INT, 0) \ _(FP64_FFI, fp64_l2d, 2, N, NUM, 0) \ _(FP64_FFI, fp64_ul2d, 2, N, NUM, 0) \ _(FP64_FFI, fp64_l2f, 2, N, FLOAT, 0) \ _(FP64_FFI, fp64_ul2f, 2, N, FLOAT, 0) \ _(FP64_FFI, fp64_d2l, ARG1_FP, N, I64, 0) \ _(FP64_FFI, fp64_d2ul, ARG1_FP, N, U64, 0) \ _(FP64_FFI, fp64_f2l, 1, N, I64, 0) \ _(FP64_FFI, fp64_f2ul, 1, N, U64, 0) \ _(FFI, lj_carith_divi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ _(FFI, lj_carith_divu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ _(FFI, lj_carith_modi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ _(FFI, lj_carith_modu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ _(FFI, lj_carith_powi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ _(FFI, lj_carith_powu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \ _(FFI, lj_cdata_setfin, 2, FN, P32, CCI_L) \ _(FFI, strlen, 1, L, INTP, 0) \ _(FFI, memcpy, 3, S, PTR, 0) \ _(FFI, memset, 3, S, PTR, 0) \ _(FFI, lj_vm_errno, 0, S, INT, CCI_NOFPRCLOBBER) \ _(FFI32, lj_carith_mul64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \ /* End of list. */ typedef enum { #define IRCALLENUM(cond, name, nargs, kind, type, flags) IRCALL_##name, IRCALLDEF(IRCALLENUM) #undef IRCALLENUM IRCALL__MAX } IRCallID; LJ_FUNC TRef lj_ir_call(jit_State *J, IRCallID id, ...); LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1]; /* Soft-float declarations. */ #if LJ_SOFTFP #if LJ_TARGET_ARM #define softfp_add __aeabi_dadd #define softfp_sub __aeabi_dsub #define softfp_mul __aeabi_dmul #define softfp_div __aeabi_ddiv #define softfp_cmp __aeabi_cdcmple #define softfp_i2d __aeabi_i2d #define softfp_d2i __aeabi_d2iz #define softfp_ui2d __aeabi_ui2d #define softfp_f2d __aeabi_f2d #define softfp_d2ui __aeabi_d2uiz #define softfp_d2f __aeabi_d2f #define softfp_i2f __aeabi_i2f #define softfp_ui2f __aeabi_ui2f #define softfp_f2i __aeabi_f2iz #define softfp_f2ui __aeabi_f2uiz #define fp64_l2d __aeabi_l2d #define fp64_ul2d __aeabi_ul2d #define fp64_l2f __aeabi_l2f #define fp64_ul2f __aeabi_ul2f #if LJ_TARGET_IOS #define fp64_d2l __fixdfdi #define fp64_d2ul __fixunsdfdi #define fp64_f2l __fixsfdi #define fp64_f2ul __fixunssfdi #else #define fp64_d2l __aeabi_d2lz #define fp64_d2ul __aeabi_d2ulz #define fp64_f2l __aeabi_f2lz #define fp64_f2ul __aeabi_f2ulz #endif #else #error "Missing soft-float definitions for target architecture" #endif extern double softfp_add(double a, double b); extern double softfp_sub(double a, double b); extern double softfp_mul(double a, double b); extern double softfp_div(double a, double b); extern void softfp_cmp(double a, double b); extern double softfp_i2d(int32_t a); extern int32_t softfp_d2i(double a); #if LJ_HASFFI extern double softfp_ui2d(uint32_t a); extern double softfp_f2d(float a); extern uint32_t softfp_d2ui(double a); extern float softfp_d2f(double a); extern float softfp_i2f(int32_t a); extern float softfp_ui2f(uint32_t a); extern int32_t softfp_f2i(float a); extern uint32_t softfp_f2ui(float a); #endif #endif #if LJ_HASFFI && LJ_NEED_FP64 && !(LJ_TARGET_ARM && LJ_SOFTFP) #ifdef __GNUC__ #define fp64_l2d __floatdidf #define fp64_ul2d __floatundidf #define fp64_l2f __floatdisf #define fp64_ul2f __floatundisf #define fp64_d2l __fixdfdi #define fp64_d2ul __fixunsdfdi #define fp64_f2l __fixsfdi #define fp64_f2ul __fixunssfdi #else #error "Missing fp64 helper definitions for this compiler" #endif #endif #if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64) extern double fp64_l2d(int64_t a); extern double fp64_ul2d(uint64_t a); extern float fp64_l2f(int64_t a); extern float fp64_ul2f(uint64_t a); extern int64_t fp64_d2l(double a); extern uint64_t fp64_d2ul(double a); extern int64_t fp64_f2l(float a); extern uint64_t fp64_f2ul(float a); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_iropt.h ================================================ /* ** Common header for IR emitter and optimizations. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_IROPT_H #define _LJ_IROPT_H #include #include "lj_obj.h" #include "lj_jit.h" #if LJ_HASJIT /* IR emitter. */ LJ_FUNC void LJ_FASTCALL lj_ir_growtop(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_ir_emit(jit_State *J); /* Save current IR in J->fold.ins, but do not emit it (yet). */ static LJ_AINLINE void lj_ir_set_(jit_State *J, uint16_t ot, IRRef1 a, IRRef1 b) { J->fold.ins.ot = ot; J->fold.ins.op1 = a; J->fold.ins.op2 = b; } #define lj_ir_set(J, ot, a, b) \ lj_ir_set_(J, (uint16_t)(ot), (IRRef1)(a), (IRRef1)(b)) /* Get ref of next IR instruction and optionally grow IR. ** Note: this may invalidate all IRIns*! */ static LJ_AINLINE IRRef lj_ir_nextins(jit_State *J) { IRRef ref = J->cur.nins; if (LJ_UNLIKELY(ref >= J->irtoplim)) lj_ir_growtop(J); J->cur.nins = ref + 1; return ref; } /* Interning of constants. */ LJ_FUNC TRef LJ_FASTCALL lj_ir_kint(jit_State *J, int32_t k); LJ_FUNC void lj_ir_k64_freeall(jit_State *J); LJ_FUNC TRef lj_ir_k64(jit_State *J, IROp op, cTValue *tv); LJ_FUNC cTValue *lj_ir_k64_find(jit_State *J, uint64_t u64); LJ_FUNC TRef lj_ir_knum_u64(jit_State *J, uint64_t u64); LJ_FUNC TRef lj_ir_knumint(jit_State *J, lua_Number n); LJ_FUNC TRef lj_ir_kint64(jit_State *J, uint64_t u64); LJ_FUNC TRef lj_ir_kgc(jit_State *J, GCobj *o, IRType t); LJ_FUNC TRef lj_ir_kptr_(jit_State *J, IROp op, void *ptr); LJ_FUNC TRef lj_ir_knull(jit_State *J, IRType t); LJ_FUNC TRef lj_ir_kslot(jit_State *J, TRef key, IRRef slot); #if LJ_64 #define lj_ir_kintp(J, k) lj_ir_kint64(J, (uint64_t)(k)) #else #define lj_ir_kintp(J, k) lj_ir_kint(J, (int32_t)(k)) #endif static LJ_AINLINE TRef lj_ir_knum(jit_State *J, lua_Number n) { TValue tv; tv.n = n; return lj_ir_knum_u64(J, tv.u64); } #define lj_ir_kstr(J, str) lj_ir_kgc(J, obj2gco((str)), IRT_STR) #define lj_ir_ktab(J, tab) lj_ir_kgc(J, obj2gco((tab)), IRT_TAB) #define lj_ir_kfunc(J, func) lj_ir_kgc(J, obj2gco((func)), IRT_FUNC) #define lj_ir_kptr(J, ptr) lj_ir_kptr_(J, IR_KPTR, (ptr)) #define lj_ir_kkptr(J, ptr) lj_ir_kptr_(J, IR_KKPTR, (ptr)) /* Special FP constants. */ #define lj_ir_knum_zero(J) lj_ir_knum_u64(J, U64x(00000000,00000000)) #define lj_ir_knum_one(J) lj_ir_knum_u64(J, U64x(3ff00000,00000000)) #define lj_ir_knum_tobit(J) lj_ir_knum_u64(J, U64x(43380000,00000000)) /* Special 128 bit SIMD constants. */ #define lj_ir_knum_abs(J) lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_ABS)) #define lj_ir_knum_neg(J) lj_ir_k64(J, IR_KNUM, LJ_KSIMD(J, LJ_KSIMD_NEG)) /* Access to constants. */ LJ_FUNC void lj_ir_kvalue(lua_State *L, TValue *tv, const IRIns *ir); /* Convert IR operand types. */ LJ_FUNC TRef LJ_FASTCALL lj_ir_tonumber(jit_State *J, TRef tr); LJ_FUNC TRef LJ_FASTCALL lj_ir_tonum(jit_State *J, TRef tr); LJ_FUNC TRef LJ_FASTCALL lj_ir_tostr(jit_State *J, TRef tr); /* Miscellaneous IR ops. */ LJ_FUNC int lj_ir_numcmp(lua_Number a, lua_Number b, IROp op); LJ_FUNC int lj_ir_strcmp(GCstr *a, GCstr *b, IROp op); LJ_FUNC void lj_ir_rollback(jit_State *J, IRRef ref); /* Emit IR instructions with on-the-fly optimizations. */ LJ_FUNC TRef LJ_FASTCALL lj_opt_fold(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_cse(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_cselim(jit_State *J, IRRef lim); /* Special return values for the fold functions. */ enum { NEXTFOLD, /* Couldn't fold, pass on. */ RETRYFOLD, /* Retry fold with modified fins. */ KINTFOLD, /* Return ref for int constant in fins->i. */ FAILFOLD, /* Guard would always fail. */ DROPFOLD, /* Guard eliminated. */ MAX_FOLD }; #define INTFOLD(k) ((J->fold.ins.i = (k)), (TRef)KINTFOLD) #define INT64FOLD(k) (lj_ir_kint64(J, (k))) #define CONDFOLD(cond) ((TRef)FAILFOLD + (TRef)(cond)) #define LEFTFOLD (J->fold.ins.op1) #define RIGHTFOLD (J->fold.ins.op2) #define CSEFOLD (lj_opt_cse(J)) #define EMITFOLD (lj_ir_emit(J)) /* Load/store forwarding. */ LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_aload(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_fload(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_tab_len(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J); LJ_FUNC int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J); LJ_FUNC int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim); LJ_FUNC int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref); /* Dead-store elimination. */ LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J); /* Narrowing. */ LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J); LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_index(jit_State *J, TRef key); LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_toint(jit_State *J, TRef tr); LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_tobit(jit_State *J, TRef tr); #if LJ_HASFFI LJ_FUNC TRef LJ_FASTCALL lj_opt_narrow_cindex(jit_State *J, TRef key); #endif LJ_FUNC TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, TValue *vb, TValue *vc, IROp op); LJ_FUNC TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc); LJ_FUNC TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vc); LJ_FUNC TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vc); LJ_FUNC IRType lj_opt_narrow_forl(jit_State *J, cTValue *forbase); /* Optimization passes. */ LJ_FUNC void lj_opt_dce(jit_State *J); LJ_FUNC int lj_opt_loop(jit_State *J); #if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) LJ_FUNC void lj_opt_split(jit_State *J); #else #define lj_opt_split(J) UNUSED(J) #endif LJ_FUNC void lj_opt_sink(jit_State *J); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_jit.h ================================================ /* ** Common definitions for the JIT compiler. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_JIT_H #define _LJ_JIT_H #include "lj_obj.h" #include "lj_ir.h" /* JIT engine flags. */ #define JIT_F_ON 0x00000001 /* CPU-specific JIT engine flags. */ #if LJ_TARGET_X86ORX64 #define JIT_F_CMOV 0x00000010 #define JIT_F_SSE2 0x00000020 #define JIT_F_SSE3 0x00000040 #define JIT_F_SSE4_1 0x00000080 #define JIT_F_P4 0x00000100 #define JIT_F_PREFER_IMUL 0x00000200 #define JIT_F_SPLIT_XMM 0x00000400 #define JIT_F_LEA_AGU 0x00000800 /* Names for the CPU-specific flags. Must match the order above. */ #define JIT_F_CPU_FIRST JIT_F_CMOV #define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" #elif LJ_TARGET_ARM #define JIT_F_ARMV6_ 0x00000010 #define JIT_F_ARMV6T2_ 0x00000020 #define JIT_F_ARMV7 0x00000040 #define JIT_F_VFPV2 0x00000080 #define JIT_F_VFPV3 0x00000100 #define JIT_F_ARMV6 (JIT_F_ARMV6_|JIT_F_ARMV6T2_|JIT_F_ARMV7) #define JIT_F_ARMV6T2 (JIT_F_ARMV6T2_|JIT_F_ARMV7) #define JIT_F_VFP (JIT_F_VFPV2|JIT_F_VFPV3) /* Names for the CPU-specific flags. Must match the order above. */ #define JIT_F_CPU_FIRST JIT_F_ARMV6_ #define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7\5VFPv2\5VFPv3" #elif LJ_TARGET_PPC #define JIT_F_SQRT 0x00000010 #define JIT_F_ROUND 0x00000020 /* Names for the CPU-specific flags. Must match the order above. */ #define JIT_F_CPU_FIRST JIT_F_SQRT #define JIT_F_CPUSTRING "\4SQRT\5ROUND" #elif LJ_TARGET_MIPS #define JIT_F_MIPS32R2 0x00000010 /* Names for the CPU-specific flags. Must match the order above. */ #define JIT_F_CPU_FIRST JIT_F_MIPS32R2 #define JIT_F_CPUSTRING "\010MIPS32R2" #else #define JIT_F_CPU_FIRST 0 #define JIT_F_CPUSTRING "" #endif /* Optimization flags. */ #define JIT_F_OPT_MASK 0x0fff0000 #define JIT_F_OPT_FOLD 0x00010000 #define JIT_F_OPT_CSE 0x00020000 #define JIT_F_OPT_DCE 0x00040000 #define JIT_F_OPT_FWD 0x00080000 #define JIT_F_OPT_DSE 0x00100000 #define JIT_F_OPT_NARROW 0x00200000 #define JIT_F_OPT_LOOP 0x00400000 #define JIT_F_OPT_ABC 0x00800000 #define JIT_F_OPT_SINK 0x01000000 #define JIT_F_OPT_FUSE 0x02000000 /* Optimizations names for -O. Must match the order above. */ #define JIT_F_OPT_FIRST JIT_F_OPT_FOLD #define JIT_F_OPTSTRING \ "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse" /* Optimization levels set a fixed combination of flags. */ #define JIT_F_OPT_0 0 #define JIT_F_OPT_1 (JIT_F_OPT_FOLD|JIT_F_OPT_CSE|JIT_F_OPT_DCE) #define JIT_F_OPT_2 (JIT_F_OPT_1|JIT_F_OPT_NARROW|JIT_F_OPT_LOOP) #define JIT_F_OPT_3 (JIT_F_OPT_2|\ JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_SINK|JIT_F_OPT_FUSE) #define JIT_F_OPT_DEFAULT JIT_F_OPT_3 #if LJ_TARGET_WINDOWS || LJ_64 /* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */ #define JIT_P_sizemcode_DEFAULT 64 #else /* Could go as low as 4K, but the mmap() overhead would be rather high. */ #define JIT_P_sizemcode_DEFAULT 32 #endif /* Optimization parameters and their defaults. Length is a char in octal! */ #define JIT_PARAMDEF(_) \ _(\010, maxtrace, 1000) /* Max. # of traces in cache. */ \ _(\011, maxrecord, 4000) /* Max. # of recorded IR instructions. */ \ _(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \ _(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \ _(\007, maxsnap, 500) /* Max. # of snapshots for a trace. */ \ \ _(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \ _(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \ _(\007, tryside, 4) /* # of attempts to compile a side trace. */ \ \ _(\012, instunroll, 4) /* Max. unroll for instable loops. */ \ _(\012, loopunroll, 15) /* Max. unroll for loop ops in side traces. */ \ _(\012, callunroll, 3) /* Max. unroll for recursive calls. */ \ _(\011, recunroll, 2) /* Min. unroll for true recursion. */ \ \ /* Size of each machine code area (in KBytes). */ \ _(\011, sizemcode, JIT_P_sizemcode_DEFAULT) \ /* Max. total size of all machine code areas (in KBytes). */ \ _(\010, maxmcode, 512) \ /* End of list. */ enum { #define JIT_PARAMENUM(len, name, value) JIT_P_##name, JIT_PARAMDEF(JIT_PARAMENUM) #undef JIT_PARAMENUM JIT_P__MAX }; #define JIT_PARAMSTR(len, name, value) #len #name #define JIT_P_STRING JIT_PARAMDEF(JIT_PARAMSTR) /* Trace compiler state. */ typedef enum { LJ_TRACE_IDLE, /* Trace compiler idle. */ LJ_TRACE_ACTIVE = 0x10, LJ_TRACE_RECORD, /* Bytecode recording active. */ LJ_TRACE_START, /* New trace started. */ LJ_TRACE_END, /* End of trace. */ LJ_TRACE_ASM, /* Assemble trace. */ LJ_TRACE_ERR /* Trace aborted with error. */ } TraceState; /* Post-processing action. */ typedef enum { LJ_POST_NONE, /* No action. */ LJ_POST_FIXCOMP, /* Fixup comparison and emit pending guard. */ LJ_POST_FIXGUARD, /* Fixup and emit pending guard. */ LJ_POST_FIXGUARDSNAP, /* Fixup and emit pending guard and snapshot. */ LJ_POST_FIXBOOL, /* Fixup boolean result. */ LJ_POST_FIXCONST, /* Fixup constant results. */ LJ_POST_FFRETRY /* Suppress recording of retried fast functions. */ } PostProc; /* Machine code type. */ #if LJ_TARGET_X86ORX64 typedef uint8_t MCode; #else typedef uint32_t MCode; #endif /* Stack snapshot header. */ typedef struct SnapShot { uint16_t mapofs; /* Offset into snapshot map. */ IRRef1 ref; /* First IR ref for this snapshot. */ uint8_t nslots; /* Number of valid slots. */ uint8_t topslot; /* Maximum frame extent. */ uint8_t nent; /* Number of compressed entries. */ uint8_t count; /* Count of taken exits for this snapshot. */ } SnapShot; #define SNAPCOUNT_DONE 255 /* Already compiled and linked a side trace. */ /* Compressed snapshot entry. */ typedef uint32_t SnapEntry; #define SNAP_FRAME 0x010000 /* Frame slot. */ #define SNAP_CONT 0x020000 /* Continuation slot. */ #define SNAP_NORESTORE 0x040000 /* No need to restore slot. */ #define SNAP_SOFTFPNUM 0x080000 /* Soft-float number. */ LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME); LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT); #define SNAP(slot, flags, ref) (((SnapEntry)(slot) << 24) + (flags) + (ref)) #define SNAP_TR(slot, tr) \ (((SnapEntry)(slot) << 24) + ((tr) & (TREF_CONT|TREF_FRAME|TREF_REFMASK))) #define SNAP_MKPC(pc) ((SnapEntry)u32ptr(pc)) #define SNAP_MKFTSZ(ftsz) ((SnapEntry)(ftsz)) #define snap_ref(sn) ((sn) & 0xffff) #define snap_slot(sn) ((BCReg)((sn) >> 24)) #define snap_isframe(sn) ((sn) & SNAP_FRAME) #define snap_pc(sn) ((const BCIns *)(uintptr_t)(sn)) #define snap_setref(sn, ref) (((sn) & (0xffff0000&~SNAP_NORESTORE)) | (ref)) /* Snapshot and exit numbers. */ typedef uint32_t SnapNo; typedef uint32_t ExitNo; /* Trace number. */ typedef uint32_t TraceNo; /* Used to pass around trace numbers. */ typedef uint16_t TraceNo1; /* Stored trace number. */ /* Type of link. ORDER LJ_TRLINK */ typedef enum { LJ_TRLINK_NONE, /* Incomplete trace. No link, yet. */ LJ_TRLINK_ROOT, /* Link to other root trace. */ LJ_TRLINK_LOOP, /* Loop to same trace. */ LJ_TRLINK_TAILREC, /* Tail-recursion. */ LJ_TRLINK_UPREC, /* Up-recursion. */ LJ_TRLINK_DOWNREC, /* Down-recursion. */ LJ_TRLINK_INTERP, /* Fallback to interpreter. */ LJ_TRLINK_RETURN /* Return to interpreter. */ } TraceLink; /* Trace object. */ typedef struct GCtrace { GCHeader; uint8_t topslot; /* Top stack slot already checked to be allocated. */ uint8_t linktype; /* Type of link. */ IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ GCRef gclist; IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */ IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ uint16_t nsnap; /* Number of snapshots. */ uint16_t nsnapmap; /* Number of snapshot map elements. */ SnapShot *snap; /* Snapshot array. */ SnapEntry *snapmap; /* Snapshot map. */ GCRef startpt; /* Starting prototype. */ MRef startpc; /* Bytecode PC of starting instruction. */ BCIns startins; /* Original bytecode of starting instruction. */ MSize szmcode; /* Size of machine code. */ MCode *mcode; /* Start of machine code. */ MSize mcloop; /* Offset of loop start in machine code. */ uint16_t nchild; /* Number of child traces (root trace only). */ uint16_t spadjust; /* Stack pointer adjustment (offset in bytes). */ TraceNo1 traceno; /* Trace number. */ TraceNo1 link; /* Linked trace (or self for loops). */ TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */ TraceNo1 nextroot; /* Next root trace for same prototype. */ TraceNo1 nextside; /* Next side trace of same root trace. */ uint8_t sinktags; /* Trace has SINK tags. */ uint8_t unused1; #ifdef LUAJIT_USE_GDBJIT void *gdbjit_entry; /* GDB JIT entry. */ #endif } GCtrace; #define gco2trace(o) check_exp((o)->gch.gct == ~LJ_TTRACE, (GCtrace *)(o)) #define traceref(J, n) \ check_exp((n)>0 && (MSize)(n)sizetrace, (GCtrace *)gcref(J->trace[(n)])) LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtrace, gclist)); static LJ_AINLINE MSize snap_nextofs(GCtrace *T, SnapShot *snap) { if (snap+1 == &T->snap[T->nsnap]) return T->nsnapmap; else return (snap+1)->mapofs; } /* Round-robin penalty cache for bytecodes leading to aborted traces. */ typedef struct HotPenalty { MRef pc; /* Starting bytecode PC. */ uint16_t val; /* Penalty value, i.e. hotcount start. */ uint16_t reason; /* Abort reason (really TraceErr). */ } HotPenalty; #define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */ #define PENALTY_MIN (36*2) /* Minimum penalty value. */ #define PENALTY_MAX 60000 /* Maximum penalty value. */ #define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */ /* Round-robin backpropagation cache for narrowing conversions. */ typedef struct BPropEntry { IRRef1 key; /* Key: original reference. */ IRRef1 val; /* Value: reference after conversion. */ IRRef mode; /* Mode for this entry (currently IRCONV_*). */ } BPropEntry; /* Number of slots for the backpropagation cache. Must be a power of 2. */ #define BPROP_SLOTS 16 /* Scalar evolution analysis cache. */ typedef struct ScEvEntry { IRRef1 idx; /* Index reference. */ IRRef1 start; /* Constant start reference. */ IRRef1 stop; /* Constant stop reference. */ IRRef1 step; /* Constant step reference. */ IRType1 t; /* Scalar type. */ uint8_t dir; /* Direction. 1: +, 0: -. */ } ScEvEntry; /* 128 bit SIMD constants. */ enum { LJ_KSIMD_ABS, LJ_KSIMD_NEG, LJ_KSIMD__MAX }; /* Get 16 byte aligned pointer to SIMD constant. */ #define LJ_KSIMD(J, n) \ ((TValue *)(((intptr_t)&J->ksimd[2*(n)] + 15) & ~(intptr_t)15)) /* Set/reset flag to activate the SPLIT pass for the current trace. */ #if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) #define lj_needsplit(J) (J->needsplit = 1) #define lj_resetsplit(J) (J->needsplit = 0) #else #define lj_needsplit(J) UNUSED(J) #define lj_resetsplit(J) UNUSED(J) #endif /* Fold state is used to fold instructions on-the-fly. */ typedef struct FoldState { IRIns ins; /* Currently emitted instruction. */ IRIns left; /* Instruction referenced by left operand. */ IRIns right; /* Instruction referenced by right operand. */ } FoldState; /* JIT compiler state. */ typedef struct jit_State { GCtrace cur; /* Current trace. */ lua_State *L; /* Current Lua state. */ const BCIns *pc; /* Current PC. */ GCfunc *fn; /* Current function. */ GCproto *pt; /* Current prototype. */ TRef *base; /* Current frame base, points into J->slots. */ uint32_t flags; /* JIT engine flags. */ BCReg maxslot; /* Relative to baseslot. */ BCReg baseslot; /* Current frame base, offset into J->slots. */ uint8_t mergesnap; /* Allowed to merge with next snapshot. */ uint8_t needsnap; /* Need snapshot before recording next bytecode. */ IRType1 guardemit; /* Accumulated IRT_GUARD for emitted instructions. */ uint8_t bcskip; /* Number of bytecode instructions to skip. */ FoldState fold; /* Fold state. */ const BCIns *bc_min; /* Start of allowed bytecode range for root trace. */ MSize bc_extent; /* Extent of the range. */ TraceState state; /* Trace compiler state. */ int32_t instunroll; /* Unroll counter for instable loops. */ int32_t loopunroll; /* Unroll counter for loop ops in side traces. */ int32_t tailcalled; /* Number of successive tailcalls. */ int32_t framedepth; /* Current frame depth. */ int32_t retdepth; /* Return frame depth (count of RETF). */ MRef k64; /* Pointer to chained array of 64 bit constants. */ TValue ksimd[LJ_KSIMD__MAX*2+1]; /* 16 byte aligned SIMD constants. */ IRIns *irbuf; /* Temp. IR instruction buffer. Biased with REF_BIAS. */ IRRef irtoplim; /* Upper limit of instuction buffer (biased). */ IRRef irbotlim; /* Lower limit of instuction buffer (biased). */ IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */ MSize sizesnap; /* Size of temp. snapshot buffer. */ SnapShot *snapbuf; /* Temp. snapshot buffer. */ SnapEntry *snapmapbuf; /* Temp. snapshot map buffer. */ MSize sizesnapmap; /* Size of temp. snapshot map buffer. */ PostProc postproc; /* Required post-processing after execution. */ #if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) int needsplit; /* Need SPLIT pass. */ #endif GCRef *trace; /* Array of traces. */ TraceNo freetrace; /* Start of scan for next free trace. */ MSize sizetrace; /* Size of trace array. */ IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */ TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */ int32_t param[JIT_P__MAX]; /* JIT engine parameters. */ MCode *exitstubgroup[LJ_MAX_EXITSTUBGR]; /* Exit stub group addresses. */ HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ uint32_t penaltyslot; /* Round-robin index into penalty slots. */ uint32_t prngstate; /* PRNG state. */ BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ ScEvEntry scev; /* Scalar evolution analysis cache slots. */ const BCIns *startpc; /* Bytecode PC of starting instruction. */ TraceNo parent; /* Parent of current side trace (0 for root traces). */ ExitNo exitno; /* Exit number in parent of current side trace. */ BCIns *patchpc; /* PC for pending re-patch. */ BCIns patchins; /* Instruction for pending re-patch. */ int mcprot; /* Protection of current mcode area. */ MCode *mcarea; /* Base of current mcode area. */ MCode *mctop; /* Top of current mcode area. */ MCode *mcbot; /* Bottom of current mcode area. */ size_t szmcarea; /* Size of current mcode area. */ size_t szallmcarea; /* Total size of all allocated mcode areas. */ TValue errinfo; /* Additional info element for trace errors. */ } #if LJ_TARGET_ARM LJ_ALIGN(16) /* For DISPATCH-relative addresses in assembler part. */ #endif jit_State; /* Trivial PRNG e.g. used for penalty randomization. */ static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) { /* Yes, this LCG is very weak, but that doesn't matter for our use case. */ J->prngstate = J->prngstate * 1103515245 + 12345; return J->prngstate >> (32-bits); } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_lex.c ================================================ /* ** Lexical analyzer. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lj_lex_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #if LJ_HASFFI #include "lj_tab.h" #include "lj_ctype.h" #include "lj_cdata.h" #include "lualib.h" #endif #include "lj_state.h" #include "lj_lex.h" #include "lj_parse.h" #include "lj_char.h" #include "lj_strscan.h" /* Lua lexer token names. */ static const char *const tokennames[] = { #define TKSTR1(name) #name, #define TKSTR2(name, sym) #sym, TKDEF(TKSTR1, TKSTR2) #undef TKSTR1 #undef TKSTR2 NULL }; /* -- Buffer handling ----------------------------------------------------- */ #define char2int(c) ((int)(uint8_t)(c)) #define next(ls) \ (ls->current = (ls->n--) > 0 ? char2int(*ls->p++) : fillbuf(ls)) #define save_and_next(ls) (save(ls, ls->current), next(ls)) #define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') #define END_OF_STREAM (-1) static int fillbuf(LexState *ls) { size_t sz; const char *buf = ls->rfunc(ls->L, ls->rdata, &sz); if (buf == NULL || sz == 0) return END_OF_STREAM; ls->n = (MSize)sz - 1; ls->p = buf; return char2int(*(ls->p++)); } static LJ_NOINLINE void save_grow(LexState *ls, int c) { MSize newsize; if (ls->sb.sz >= LJ_MAX_STR/2) lj_lex_error(ls, 0, LJ_ERR_XELEM); newsize = ls->sb.sz * 2; lj_str_resizebuf(ls->L, &ls->sb, newsize); ls->sb.buf[ls->sb.n++] = (char)c; } static LJ_AINLINE void save(LexState *ls, int c) { if (LJ_UNLIKELY(ls->sb.n + 1 > ls->sb.sz)) save_grow(ls, c); else ls->sb.buf[ls->sb.n++] = (char)c; } static void inclinenumber(LexState *ls) { int old = ls->current; lua_assert(currIsNewline(ls)); next(ls); /* skip `\n' or `\r' */ if (currIsNewline(ls) && ls->current != old) next(ls); /* skip `\n\r' or `\r\n' */ if (++ls->linenumber >= LJ_MAX_LINE) lj_lex_error(ls, ls->token, LJ_ERR_XLINES); } /* -- Scanner for terminals ----------------------------------------------- */ /* Parse a number literal. */ static void lex_number(LexState *ls, TValue *tv) { StrScanFmt fmt; int c, xp = 'e'; lua_assert(lj_char_isdigit(ls->current)); if ((c = ls->current) == '0') { save_and_next(ls); if ((ls->current | 0x20) == 'x') xp = 'p'; } while (lj_char_isident(ls->current) || ls->current == '.' || ((ls->current == '-' || ls->current == '+') && (c | 0x20) == xp)) { c = ls->current; save_and_next(ls); } save(ls, '\0'); fmt = lj_strscan_scan((const uint8_t *)ls->sb.buf, tv, (LJ_DUALNUM ? STRSCAN_OPT_TOINT : STRSCAN_OPT_TONUM) | (LJ_HASFFI ? (STRSCAN_OPT_LL|STRSCAN_OPT_IMAG) : 0)); if (LJ_DUALNUM && fmt == STRSCAN_INT) { setitype(tv, LJ_TISNUM); } else if (fmt == STRSCAN_NUM) { /* Already in correct format. */ #if LJ_HASFFI } else if (fmt != STRSCAN_ERROR) { lua_State *L = ls->L; GCcdata *cd; lua_assert(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG); if (!ctype_ctsG(G(L))) { ptrdiff_t oldtop = savestack(L, L->top); luaopen_ffi(L); /* Load FFI library on-demand. */ L->top = restorestack(L, oldtop); } if (fmt == STRSCAN_IMAG) { cd = lj_cdata_new_(L, CTID_COMPLEX_DOUBLE, 2*sizeof(double)); ((double *)cdataptr(cd))[0] = 0; ((double *)cdataptr(cd))[1] = numV(tv); } else { cd = lj_cdata_new_(L, fmt==STRSCAN_I64 ? CTID_INT64 : CTID_UINT64, 8); *(uint64_t *)cdataptr(cd) = tv->u64; } lj_parse_keepcdata(ls, tv, cd); #endif } else { lua_assert(fmt == STRSCAN_ERROR); lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER); } } static int skip_sep(LexState *ls) { int count = 0; int s = ls->current; lua_assert(s == '[' || s == ']'); save_and_next(ls); while (ls->current == '=') { save_and_next(ls); count++; } return (ls->current == s) ? count : (-count) - 1; } static void read_long_string(LexState *ls, TValue *tv, int sep) { save_and_next(ls); /* skip 2nd `[' */ if (currIsNewline(ls)) /* string starts with a newline? */ inclinenumber(ls); /* skip it */ for (;;) { switch (ls->current) { case END_OF_STREAM: lj_lex_error(ls, TK_eof, tv ? LJ_ERR_XLSTR : LJ_ERR_XLCOM); break; case ']': if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd `]' */ goto endloop; } break; case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); if (!tv) lj_str_resetbuf(&ls->sb); /* avoid wasting space */ break; default: if (tv) save_and_next(ls); else next(ls); break; } } endloop: if (tv) { GCstr *str = lj_parse_keepstr(ls, ls->sb.buf + (2 + (MSize)sep), ls->sb.n - 2*(2 + (MSize)sep)); setstrV(ls->L, tv, str); } } static void read_string(LexState *ls, int delim, TValue *tv) { save_and_next(ls); while (ls->current != delim) { switch (ls->current) { case END_OF_STREAM: lj_lex_error(ls, TK_eof, LJ_ERR_XSTR); continue; case '\n': case '\r': lj_lex_error(ls, TK_string, LJ_ERR_XSTR); continue; case '\\': { int c = next(ls); /* Skip the '\\'. */ switch (c) { case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case 'x': /* Hexadecimal escape '\xXX'. */ c = (next(ls) & 15u) << 4; if (!lj_char_isdigit(ls->current)) { if (!lj_char_isxdigit(ls->current)) goto err_xesc; c += 9 << 4; } c += (next(ls) & 15u); if (!lj_char_isdigit(ls->current)) { if (!lj_char_isxdigit(ls->current)) goto err_xesc; c += 9; } break; case 'z': /* Skip whitespace. */ next(ls); while (lj_char_isspace(ls->current)) if (currIsNewline(ls)) inclinenumber(ls); else next(ls); continue; case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue; case '\\': case '\"': case '\'': break; case END_OF_STREAM: continue; default: if (!lj_char_isdigit(c)) goto err_xesc; c -= '0'; /* Decimal escape '\ddd'. */ if (lj_char_isdigit(next(ls))) { c = c*10 + (ls->current - '0'); if (lj_char_isdigit(next(ls))) { c = c*10 + (ls->current - '0'); if (c > 255) { err_xesc: lj_lex_error(ls, TK_string, LJ_ERR_XESC); } next(ls); } } save(ls, c); continue; } save(ls, c); next(ls); continue; } default: save_and_next(ls); break; } } save_and_next(ls); /* skip delimiter */ setstrV(ls->L, tv, lj_parse_keepstr(ls, ls->sb.buf + 1, ls->sb.n - 2)); } /* -- Main lexical scanner ------------------------------------------------ */ static int llex(LexState *ls, TValue *tv) { lj_str_resetbuf(&ls->sb); for (;;) { if (lj_char_isident(ls->current)) { GCstr *s; if (lj_char_isdigit(ls->current)) { /* Numeric literal. */ lex_number(ls, tv); return TK_number; } /* Identifier or reserved word. */ do { save_and_next(ls); } while (lj_char_isident(ls->current)); s = lj_parse_keepstr(ls, ls->sb.buf, ls->sb.n); setstrV(ls->L, tv, s); if (s->reserved > 0) /* Reserved word? */ return TK_OFS + s->reserved; return TK_name; } switch (ls->current) { case '\n': case '\r': inclinenumber(ls); continue; case ' ': case '\t': case '\v': case '\f': next(ls); continue; case '-': next(ls); if (ls->current != '-') return '-'; /* else is a comment */ next(ls); if (ls->current == '[') { int sep = skip_sep(ls); lj_str_resetbuf(&ls->sb); /* `skip_sep' may dirty the buffer */ if (sep >= 0) { read_long_string(ls, NULL, sep); /* long comment */ lj_str_resetbuf(&ls->sb); continue; } } /* else short comment */ while (!currIsNewline(ls) && ls->current != END_OF_STREAM) next(ls); continue; case '[': { int sep = skip_sep(ls); if (sep >= 0) { read_long_string(ls, tv, sep); return TK_string; } else if (sep == -1) { return '['; } else { lj_lex_error(ls, TK_string, LJ_ERR_XLDELIM); continue; } } case '=': next(ls); if (ls->current != '=') return '='; else { next(ls); return TK_eq; } case '<': next(ls); if (ls->current != '=') return '<'; else { next(ls); return TK_le; } case '>': next(ls); if (ls->current != '=') return '>'; else { next(ls); return TK_ge; } case '~': next(ls); if (ls->current != '=') return '~'; else { next(ls); return TK_ne; } case ':': next(ls); if (ls->current != ':') return ':'; else { next(ls); return TK_label; } case '"': case '\'': read_string(ls, ls->current, tv); return TK_string; case '.': save_and_next(ls); if (ls->current == '.') { next(ls); if (ls->current == '.') { next(ls); return TK_dots; /* ... */ } return TK_concat; /* .. */ } else if (!lj_char_isdigit(ls->current)) { return '.'; } else { lex_number(ls, tv); return TK_number; } case END_OF_STREAM: return TK_eof; default: { int c = ls->current; next(ls); return c; /* Single-char tokens (+ - / ...). */ } } } } /* -- Lexer API ----------------------------------------------------------- */ /* Setup lexer state. */ int lj_lex_setup(lua_State *L, LexState *ls) { int header = 0; ls->L = L; ls->fs = NULL; ls->n = 0; ls->p = NULL; ls->vstack = NULL; ls->sizevstack = 0; ls->vtop = 0; ls->bcstack = NULL; ls->sizebcstack = 0; ls->lookahead = TK_eof; /* No look-ahead token. */ ls->linenumber = 1; ls->lastline = 1; lj_str_resizebuf(ls->L, &ls->sb, LJ_MIN_SBUF); next(ls); /* Read-ahead first char. */ if (ls->current == 0xef && ls->n >= 2 && char2int(ls->p[0]) == 0xbb && char2int(ls->p[1]) == 0xbf) { /* Skip UTF-8 BOM (if buffered). */ ls->n -= 2; ls->p += 2; next(ls); header = 1; } if (ls->current == '#') { /* Skip POSIX #! header line. */ do { next(ls); if (ls->current == END_OF_STREAM) return 0; } while (!currIsNewline(ls)); inclinenumber(ls); header = 1; } if (ls->current == LUA_SIGNATURE[0]) { /* Bytecode dump. */ if (header) { /* ** Loading bytecode with an extra header is disabled for security ** reasons. This may circumvent the usual check for bytecode vs. ** Lua code by looking at the first char. Since this is a potential ** security violation no attempt is made to echo the chunkname either. */ setstrV(L, L->top++, lj_err_str(L, LJ_ERR_BCBAD)); lj_err_throw(L, LUA_ERRSYNTAX); } return 1; } return 0; } /* Cleanup lexer state. */ void lj_lex_cleanup(lua_State *L, LexState *ls) { global_State *g = G(L); lj_mem_freevec(g, ls->bcstack, ls->sizebcstack, BCInsLine); lj_mem_freevec(g, ls->vstack, ls->sizevstack, VarInfo); lj_str_freebuf(g, &ls->sb); } void lj_lex_next(LexState *ls) { ls->lastline = ls->linenumber; if (LJ_LIKELY(ls->lookahead == TK_eof)) { /* No lookahead token? */ ls->token = llex(ls, &ls->tokenval); /* Get next token. */ } else { /* Otherwise return lookahead token. */ ls->token = ls->lookahead; ls->lookahead = TK_eof; ls->tokenval = ls->lookaheadval; } } LexToken lj_lex_lookahead(LexState *ls) { lua_assert(ls->lookahead == TK_eof); ls->lookahead = llex(ls, &ls->lookaheadval); return ls->lookahead; } const char *lj_lex_token2str(LexState *ls, LexToken token) { if (token > TK_OFS) return tokennames[token-TK_OFS-1]; else if (!lj_char_iscntrl(token)) return lj_str_pushf(ls->L, "%c", token); else return lj_str_pushf(ls->L, "char(%d)", token); } void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...) { const char *tok; va_list argp; if (token == 0) { tok = NULL; } else if (token == TK_name || token == TK_string || token == TK_number) { save(ls, '\0'); tok = ls->sb.buf; } else { tok = lj_lex_token2str(ls, token); } va_start(argp, em); lj_err_lex(ls->L, ls->chunkname, tok, ls->linenumber, em, argp); va_end(argp); } void lj_lex_init(lua_State *L) { uint32_t i; for (i = 0; i < TK_RESERVED; i++) { GCstr *s = lj_str_newz(L, tokennames[i]); fixstring(s); /* Reserved words are never collected. */ s->reserved = (uint8_t)(i+1); } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_lex.h ================================================ /* ** Lexical analyzer. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_LEX_H #define _LJ_LEX_H #include #include "lj_obj.h" #include "lj_err.h" /* Lua lexer tokens. */ #define TKDEF(_, __) \ _(and) _(break) _(do) _(else) _(elseif) _(end) _(false) \ _(for) _(function) _(goto) _(if) _(in) _(local) _(nil) _(not) _(or) \ _(repeat) _(return) _(then) _(true) _(until) _(while) \ __(concat, ..) __(dots, ...) __(eq, ==) __(ge, >=) __(le, <=) __(ne, ~=) \ __(label, ::) __(number, ) __(name, ) __(string, ) \ __(eof, ) enum { TK_OFS = 256, #define TKENUM1(name) TK_##name, #define TKENUM2(name, sym) TK_##name, TKDEF(TKENUM1, TKENUM2) #undef TKENUM1 #undef TKENUM2 TK_RESERVED = TK_while - TK_OFS }; typedef int LexToken; /* Combined bytecode ins/line. Only used during bytecode generation. */ typedef struct BCInsLine { BCIns ins; /* Bytecode instruction. */ BCLine line; /* Line number for this bytecode. */ } BCInsLine; /* Info for local variables. Only used during bytecode generation. */ typedef struct VarInfo { GCRef name; /* Local variable name or goto/label name. */ BCPos startpc; /* First point where the local variable is active. */ BCPos endpc; /* First point where the local variable is dead. */ uint8_t slot; /* Variable slot. */ uint8_t info; /* Variable/goto/label info. */ } VarInfo; /* Lua lexer state. */ typedef struct LexState { struct FuncState *fs; /* Current FuncState. Defined in lj_parse.c. */ struct lua_State *L; /* Lua state. */ TValue tokenval; /* Current token value. */ TValue lookaheadval; /* Lookahead token value. */ int current; /* Current character (charint). */ LexToken token; /* Current token. */ LexToken lookahead; /* Lookahead token. */ MSize n; /* Bytes left in input buffer. */ const char *p; /* Current position in input buffer. */ SBuf sb; /* String buffer for tokens. */ lua_Reader rfunc; /* Reader callback. */ void *rdata; /* Reader callback data. */ BCLine linenumber; /* Input line counter. */ BCLine lastline; /* Line of last token. */ GCstr *chunkname; /* Current chunk name (interned string). */ const char *chunkarg; /* Chunk name argument. */ const char *mode; /* Allow loading bytecode (b) and/or source text (t). */ VarInfo *vstack; /* Stack for names and extents of local variables. */ MSize sizevstack; /* Size of variable stack. */ MSize vtop; /* Top of variable stack. */ BCInsLine *bcstack; /* Stack for bytecode instructions/line numbers. */ MSize sizebcstack; /* Size of bytecode stack. */ uint32_t level; /* Syntactical nesting level. */ } LexState; LJ_FUNC int lj_lex_setup(lua_State *L, LexState *ls); LJ_FUNC void lj_lex_cleanup(lua_State *L, LexState *ls); LJ_FUNC void lj_lex_next(LexState *ls); LJ_FUNC LexToken lj_lex_lookahead(LexState *ls); LJ_FUNC const char *lj_lex_token2str(LexState *ls, LexToken token); LJ_FUNC_NORET void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...); LJ_FUNC void lj_lex_init(lua_State *L); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_lib.c ================================================ /* ** Library function support. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_lib_c #define LUA_CORE #include "lauxlib.h" #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_func.h" #include "lj_bc.h" #include "lj_dispatch.h" #include "lj_vm.h" #include "lj_strscan.h" #include "lj_lib.h" /* -- Library initialization ---------------------------------------------- */ static GCtab *lib_create_table(lua_State *L, const char *libname, int hsize) { if (libname) { luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 16); lua_getfield(L, -1, libname); if (!tvistab(L->top-1)) { L->top--; if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, hsize) != NULL) lj_err_callerv(L, LJ_ERR_BADMODN, libname); settabV(L, L->top, tabV(L->top-1)); L->top++; lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ } L->top--; settabV(L, L->top-1, tabV(L->top)); } else { lua_createtable(L, 0, hsize); } return tabV(L->top-1); } void lj_lib_register(lua_State *L, const char *libname, const uint8_t *p, const lua_CFunction *cf) { GCtab *env = tabref(L->env); GCfunc *ofn = NULL; int ffid = *p++; BCIns *bcff = &L2GG(L)->bcff[*p++]; GCtab *tab = lib_create_table(L, libname, *p++); ptrdiff_t tpos = L->top - L->base; /* Avoid barriers further down. */ lj_gc_anybarriert(L, tab); tab->nomm = 0; for (;;) { uint32_t tag = *p++; MSize len = tag & LIBINIT_LENMASK; tag &= LIBINIT_TAGMASK; if (tag != LIBINIT_STRING) { const char *name; MSize nuv = (MSize)(L->top - L->base - tpos); GCfunc *fn = lj_func_newC(L, nuv, env); if (nuv) { L->top = L->base + tpos; memcpy(fn->c.upvalue, L->top, sizeof(TValue)*nuv); } fn->c.ffid = (uint8_t)(ffid++); name = (const char *)p; p += len; if (tag == LIBINIT_CF) setmref(fn->c.pc, &G(L)->bc_cfunc_int); else setmref(fn->c.pc, bcff++); if (tag == LIBINIT_ASM_) fn->c.f = ofn->c.f; /* Copy handler from previous function. */ else fn->c.f = *cf++; /* Get cf or handler from C function table. */ if (len) { /* NOBARRIER: See above for common barrier. */ setfuncV(L, lj_tab_setstr(L, tab, lj_str_new(L, name, len)), fn); } ofn = fn; } else { switch (tag | len) { case LIBINIT_SET: L->top -= 2; if (tvisstr(L->top+1) && strV(L->top+1)->len == 0) env = tabV(L->top); else /* NOBARRIER: See above for common barrier. */ copyTV(L, lj_tab_set(L, tab, L->top+1), L->top); break; case LIBINIT_NUMBER: memcpy(&L->top->n, p, sizeof(double)); L->top++; p += sizeof(double); break; case LIBINIT_COPY: copyTV(L, L->top, L->top - *p++); L->top++; break; case LIBINIT_LASTCL: setfuncV(L, L->top++, ofn); break; case LIBINIT_FFID: ffid++; break; case LIBINIT_END: return; default: setstrV(L, L->top++, lj_str_new(L, (const char *)p, len)); p += len; break; } } } } /* -- Type checks --------------------------------------------------------- */ TValue *lj_lib_checkany(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (o >= L->top) lj_err_arg(L, narg, LJ_ERR_NOVAL); return o; } GCstr *lj_lib_checkstr(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (o < L->top) { if (LJ_LIKELY(tvisstr(o))) { return strV(o); } else if (tvisnumber(o)) { GCstr *s = lj_str_fromnumber(L, o); setstrV(L, o, s); return s; } } lj_err_argt(L, narg, LUA_TSTRING); return NULL; /* unreachable */ } GCstr *lj_lib_optstr(lua_State *L, int narg) { TValue *o = L->base + narg-1; return (o < L->top && !tvisnil(o)) ? lj_lib_checkstr(L, narg) : NULL; } #if LJ_DUALNUM void lj_lib_checknumber(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (!(o < L->top && lj_strscan_numberobj(o))) lj_err_argt(L, narg, LUA_TNUMBER); } #endif lua_Number lj_lib_checknum(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (!(o < L->top && (tvisnumber(o) || (tvisstr(o) && lj_strscan_num(strV(o), o))))) lj_err_argt(L, narg, LUA_TNUMBER); if (LJ_UNLIKELY(tvisint(o))) { lua_Number n = (lua_Number)intV(o); setnumV(o, n); return n; } else { return numV(o); } } int32_t lj_lib_checkint(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (!(o < L->top && lj_strscan_numberobj(o))) lj_err_argt(L, narg, LUA_TNUMBER); if (LJ_LIKELY(tvisint(o))) { return intV(o); } else { int32_t i = lj_num2int(numV(o)); if (LJ_DUALNUM) setintV(o, i); return i; } } int32_t lj_lib_optint(lua_State *L, int narg, int32_t def) { TValue *o = L->base + narg-1; return (o < L->top && !tvisnil(o)) ? lj_lib_checkint(L, narg) : def; } int32_t lj_lib_checkbit(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (!(o < L->top && lj_strscan_numberobj(o))) lj_err_argt(L, narg, LUA_TNUMBER); if (LJ_LIKELY(tvisint(o))) { return intV(o); } else { int32_t i = lj_num2bit(numV(o)); if (LJ_DUALNUM) setintV(o, i); return i; } } GCfunc *lj_lib_checkfunc(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (!(o < L->top && tvisfunc(o))) lj_err_argt(L, narg, LUA_TFUNCTION); return funcV(o); } GCtab *lj_lib_checktab(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (!(o < L->top && tvistab(o))) lj_err_argt(L, narg, LUA_TTABLE); return tabV(o); } GCtab *lj_lib_checktabornil(lua_State *L, int narg) { TValue *o = L->base + narg-1; if (o < L->top) { if (tvistab(o)) return tabV(o); else if (tvisnil(o)) return NULL; } lj_err_arg(L, narg, LJ_ERR_NOTABN); return NULL; /* unreachable */ } int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst) { GCstr *s = def >= 0 ? lj_lib_optstr(L, narg) : lj_lib_checkstr(L, narg); if (s) { const char *opt = strdata(s); MSize len = s->len; int i; for (i = 0; *(const uint8_t *)lst; i++) { if (*(const uint8_t *)lst == len && memcmp(opt, lst+1, len) == 0) return i; lst += 1+*(const uint8_t *)lst; } lj_err_argv(L, narg, LJ_ERR_INVOPTM, opt); } return def; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_lib.h ================================================ /* ** Library function support. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_LIB_H #define _LJ_LIB_H #include "lj_obj.h" /* ** A fallback handler is called by the assembler VM if the fast path fails: ** ** - too few arguments: unrecoverable. ** - wrong argument type: recoverable, if coercion succeeds. ** - bad argument value: unrecoverable. ** - stack overflow: recoverable, if stack reallocation succeeds. ** - extra handling: recoverable. ** ** The unrecoverable cases throw an error with lj_err_arg(), lj_err_argtype(), ** lj_err_caller() or lj_err_callermsg(). ** The recoverable cases return 0 or the number of results + 1. ** The assembler VM retries the fast path only if 0 is returned. ** This time the fallback must not be called again or it gets stuck in a loop. */ /* Return values from fallback handler. */ #define FFH_RETRY 0 #define FFH_UNREACHABLE FFH_RETRY #define FFH_RES(n) ((n)+1) #define FFH_TAILCALL (-1) LJ_FUNC TValue *lj_lib_checkany(lua_State *L, int narg); LJ_FUNC GCstr *lj_lib_checkstr(lua_State *L, int narg); LJ_FUNC GCstr *lj_lib_optstr(lua_State *L, int narg); #if LJ_DUALNUM LJ_FUNC void lj_lib_checknumber(lua_State *L, int narg); #else #define lj_lib_checknumber(L, narg) lj_lib_checknum((L), (narg)) #endif LJ_FUNC lua_Number lj_lib_checknum(lua_State *L, int narg); LJ_FUNC int32_t lj_lib_checkint(lua_State *L, int narg); LJ_FUNC int32_t lj_lib_optint(lua_State *L, int narg, int32_t def); LJ_FUNC int32_t lj_lib_checkbit(lua_State *L, int narg); LJ_FUNC GCfunc *lj_lib_checkfunc(lua_State *L, int narg); LJ_FUNC GCtab *lj_lib_checktab(lua_State *L, int narg); LJ_FUNC GCtab *lj_lib_checktabornil(lua_State *L, int narg); LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); /* Avoid including lj_frame.h. */ #define lj_lib_upvalue(L, n) \ (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) #if LJ_TARGET_WINDOWS #define lj_lib_checkfpu(L) \ do { setnumV(L->top++, (lua_Number)1437217655); \ if (lua_tointeger(L, -1) != 1437217655) lj_err_caller(L, LJ_ERR_BADFPU); \ L->top--; } while (0) #else #define lj_lib_checkfpu(L) UNUSED(L) #endif /* Push internal function on the stack. */ static LJ_AINLINE void lj_lib_pushcc(lua_State *L, lua_CFunction f, int id, int n) { GCfunc *fn; lua_pushcclosure(L, f, n); fn = funcV(L->top-1); fn->c.ffid = (uint8_t)id; setmref(fn->c.pc, &G(L)->bc_cfunc_int); } #define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) /* Library function declarations. Scanned by buildvm. */ #define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) #define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) #define LJLIB_ASM_(name) #define LJLIB_SET(name) #define LJLIB_PUSH(arg) #define LJLIB_REC(handler) #define LJLIB_NOREGUV #define LJLIB_NOREG #define LJ_LIB_REG(L, regname, name) \ lj_lib_register(L, regname, lj_lib_init_##name, lj_lib_cf_##name) LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, const uint8_t *init, const lua_CFunction *cf); /* Library init data tags. */ #define LIBINIT_LENMASK 0x3f #define LIBINIT_TAGMASK 0xc0 #define LIBINIT_CF 0x00 #define LIBINIT_ASM 0x40 #define LIBINIT_ASM_ 0x80 #define LIBINIT_STRING 0xc0 #define LIBINIT_MAXSTR 0x39 #define LIBINIT_SET 0xfa #define LIBINIT_NUMBER 0xfb #define LIBINIT_COPY 0xfc #define LIBINIT_LASTCL 0xfd #define LIBINIT_FFID 0xfe #define LIBINIT_END 0xff /* Exported library functions. */ typedef struct RandomState RandomState; LJ_FUNC uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_load.c ================================================ /* ** Load and dump code. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include #include #define lj_load_c #define LUA_CORE #include "lua.h" #include "lauxlib.h" #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_func.h" #include "lj_frame.h" #include "lj_vm.h" #include "lj_lex.h" #include "lj_bcdump.h" #include "lj_parse.h" /* -- Load Lua source code and bytecode ----------------------------------- */ static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud) { LexState *ls = (LexState *)ud; GCproto *pt; GCfunc *fn; int bc; UNUSED(dummy); cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ bc = lj_lex_setup(L, ls); if (ls->mode && !strchr(ls->mode, bc ? 'b' : 't')) { setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XMODE)); lj_err_throw(L, LUA_ERRSYNTAX); } pt = bc ? lj_bcread(ls) : lj_parse(ls); fn = lj_func_newL_empty(L, pt, tabref(L->env)); /* Don't combine above/below into one statement. */ setfuncV(L, L->top++, fn); return NULL; } LUA_API int lua_loadx(lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode) { LexState ls; int status; ls.rfunc = reader; ls.rdata = data; ls.chunkarg = chunkname ? chunkname : "?"; ls.mode = mode; lj_str_initbuf(&ls.sb); status = lj_vm_cpcall(L, NULL, &ls, cpparser); lj_lex_cleanup(L, &ls); lj_gc_check(L); return status; } LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char *chunkname) { return lua_loadx(L, reader, data, chunkname, NULL); } typedef struct FileReaderCtx { FILE *fp; char buf[LUAL_BUFFERSIZE]; } FileReaderCtx; static const char *reader_file(lua_State *L, void *ud, size_t *size) { FileReaderCtx *ctx = (FileReaderCtx *)ud; UNUSED(L); if (feof(ctx->fp)) return NULL; *size = fread(ctx->buf, 1, sizeof(ctx->buf), ctx->fp); return *size > 0 ? ctx->buf : NULL; } LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode) { FileReaderCtx ctx; int status; const char *chunkname; if (filename) { ctx.fp = fopen(filename, "rb"); if (ctx.fp == NULL) { lua_pushfstring(L, "cannot open %s: %s", filename, strerror(errno)); return LUA_ERRFILE; } chunkname = lua_pushfstring(L, "@%s", filename); } else { ctx.fp = stdin; chunkname = "=stdin"; } status = lua_loadx(L, reader_file, &ctx, chunkname, mode); if (ferror(ctx.fp)) { L->top -= filename ? 2 : 1; lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(errno)); if (filename) fclose(ctx.fp); return LUA_ERRFILE; } if (filename) { L->top--; copyTV(L, L->top-1, L->top); fclose(ctx.fp); } return status; } LUALIB_API int luaL_loadfile(lua_State *L, const char *filename) { return luaL_loadfilex(L, filename, NULL); } typedef struct StringReaderCtx { const char *str; size_t size; } StringReaderCtx; static const char *reader_string(lua_State *L, void *ud, size_t *size) { StringReaderCtx *ctx = (StringReaderCtx *)ud; UNUSED(L); if (ctx->size == 0) return NULL; *size = ctx->size; ctx->size = 0; return ctx->str; } LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buf, size_t size, const char *name, const char *mode) { StringReaderCtx ctx; ctx.str = buf; ctx.size = size; return lua_loadx(L, reader_string, &ctx, name, mode); } LUALIB_API int luaL_loadbuffer(lua_State *L, const char *buf, size_t size, const char *name) { return luaL_loadbufferx(L, buf, size, name, NULL); } LUALIB_API int luaL_loadstring(lua_State *L, const char *s) { return luaL_loadbuffer(L, s, strlen(s), s); } /* -- Dump bytecode ------------------------------------------------------- */ LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data) { cTValue *o = L->top-1; api_check(L, L->top > L->base); if (tvisfunc(o) && isluafunc(funcV(o))) return lj_bcwrite(L, funcproto(funcV(o)), writer, data, 0); else return 1; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_mcode.c ================================================ /* ** Machine code management. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_mcode_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_gc.h" #include "lj_jit.h" #include "lj_mcode.h" #include "lj_trace.h" #include "lj_dispatch.h" #endif #if LJ_HASJIT || LJ_HASFFI #include "lj_vm.h" #endif /* -- OS-specific functions ----------------------------------------------- */ #if LJ_HASJIT || LJ_HASFFI /* Define this if you want to run LuaJIT with Valgrind. */ #ifdef LUAJIT_USE_VALGRIND #include #endif #if LJ_TARGET_IOS void sys_icache_invalidate(void *start, size_t len); #endif /* Synchronize data/instruction cache. */ void lj_mcode_sync(void *start, void *end) { #ifdef LUAJIT_USE_VALGRIND VALGRIND_DISCARD_TRANSLATIONS(start, (char *)end-(char *)start); #endif #if LJ_TARGET_X86ORX64 UNUSED(start); UNUSED(end); #elif LJ_TARGET_IOS sys_icache_invalidate(start, (char *)end-(char *)start); #elif LJ_TARGET_PPC lj_vm_cachesync(start, end); #elif defined(__GNUC__) __clear_cache(start, end); #else #error "Missing builtin to flush instruction cache" #endif } #endif #if LJ_HASJIT #if LJ_TARGET_WINDOWS #define WIN32_LEAN_AND_MEAN #include #define MCPROT_RW PAGE_READWRITE #define MCPROT_RX PAGE_EXECUTE_READ #define MCPROT_RWX PAGE_EXECUTE_READWRITE static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, DWORD prot) { void *p = VirtualAlloc((void *)hint, sz, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, prot); if (!p && !hint) lj_trace_err(J, LJ_TRERR_MCODEAL); return p; } static void mcode_free(jit_State *J, void *p, size_t sz) { UNUSED(J); UNUSED(sz); VirtualFree(p, 0, MEM_RELEASE); } static void mcode_setprot(void *p, size_t sz, DWORD prot) { DWORD oprot; VirtualProtect(p, sz, prot, &oprot); } #elif LJ_TARGET_POSIX #include #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON #endif #define MCPROT_RW (PROT_READ|PROT_WRITE) #define MCPROT_RX (PROT_READ|PROT_EXEC) #define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC) static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot) { void *p = mmap((void *)hint, sz, prot, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { if (!hint) lj_trace_err(J, LJ_TRERR_MCODEAL); p = NULL; } return p; } static void mcode_free(jit_State *J, void *p, size_t sz) { UNUSED(J); munmap(p, sz); } static void mcode_setprot(void *p, size_t sz, int prot) { mprotect(p, sz, prot); } #elif LJ_64 #error "Missing OS support for explicit placement of executable memory" #else /* Fallback allocator. This will fail if memory is not executable by default. */ #define LUAJIT_UNPROTECT_MCODE #define MCPROT_RW 0 #define MCPROT_RX 0 #define MCPROT_RWX 0 static void *mcode_alloc_at(jit_State *J, uintptr_t hint, size_t sz, int prot) { UNUSED(hint); UNUSED(prot); return lj_mem_new(J->L, sz); } static void mcode_free(jit_State *J, void *p, size_t sz) { lj_mem_free(J2G(J), p, sz); } #define mcode_setprot(p, sz, prot) UNUSED(p) #endif /* -- MCode area protection ----------------------------------------------- */ /* Define this ONLY if the page protection twiddling becomes a bottleneck. */ #ifdef LUAJIT_UNPROTECT_MCODE /* It's generally considered to be a potential security risk to have ** pages with simultaneous write *and* execute access in a process. ** ** Do not even think about using this mode for server processes or ** apps handling untrusted external data (such as a browser). ** ** The security risk is not in LuaJIT itself -- but if an adversary finds ** any *other* flaw in your C application logic, then any RWX memory page ** simplifies writing an exploit considerably. */ #define MCPROT_GEN MCPROT_RWX #define MCPROT_RUN MCPROT_RWX static void mcode_protect(jit_State *J, int prot) { UNUSED(J); UNUSED(prot); } #else /* This is the default behaviour and much safer: ** ** Most of the time the memory pages holding machine code are executable, ** but NONE of them is writable. ** ** The current memory area is marked read-write (but NOT executable) only ** during the short time window while the assembler generates machine code. */ #define MCPROT_GEN MCPROT_RW #define MCPROT_RUN MCPROT_RX /* Change protection of MCode area. */ static void mcode_protect(jit_State *J, int prot) { if (J->mcprot != prot) { mcode_setprot(J->mcarea, J->szmcarea, prot); J->mcprot = prot; } } #endif /* -- MCode area allocation ----------------------------------------------- */ #if LJ_TARGET_X64 #define mcode_validptr(p) ((p) && (uintptr_t)(p) < (uintptr_t)1<<47) #else #define mcode_validptr(p) ((p) && (uintptr_t)(p) < 0xffff0000) #endif #ifdef LJ_TARGET_JUMPRANGE /* Get memory within relative jump distance of our code in 64 bit mode. */ static void *mcode_alloc(jit_State *J, size_t sz) { /* Target an address in the static assembler code (64K aligned). ** Try addresses within a distance of target-range/2+1MB..target+range/2-1MB. */ #if LJ_TARGET_MIPS /* Use the middle of the 256MB-aligned region. */ uintptr_t target = ((uintptr_t)(void *)lj_vm_exit_handler & 0xf0000000u) + 0x08000000u; #else uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff; #endif const uintptr_t range = (1u << LJ_TARGET_JUMPRANGE) - (1u << 21); /* First try a contiguous area below the last one. */ uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0; int i; for (i = 0; i < 32; i++) { /* 32 attempts ought to be enough ... */ if (mcode_validptr(hint)) { void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN); if (mcode_validptr(p) && ((uintptr_t)p + sz - target < range || target - (uintptr_t)p < range)) return p; if (p) mcode_free(J, p, sz); /* Free badly placed area. */ } /* Next try probing pseudo-random addresses. */ do { hint = (0x78fb ^ LJ_PRNG_BITS(J, 15)) << 16; /* 64K aligned. */ } while (!(hint + sz < range)); hint = target + hint - (range>>1); } lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */ return NULL; } #else /* All memory addresses are reachable by relative jumps. */ #define mcode_alloc(J, sz) mcode_alloc_at((J), 0, (sz), MCPROT_GEN) #endif /* -- MCode area management ----------------------------------------------- */ /* Linked list of MCode areas. */ typedef struct MCLink { MCode *next; /* Next area. */ size_t size; /* Size of current area. */ } MCLink; /* Allocate a new MCode area. */ static void mcode_allocarea(jit_State *J) { MCode *oldarea = J->mcarea; size_t sz = (size_t)J->param[JIT_P_sizemcode] << 10; sz = (sz + LJ_PAGESIZE-1) & ~(size_t)(LJ_PAGESIZE - 1); J->mcarea = (MCode *)mcode_alloc(J, sz); J->szmcarea = sz; J->mcprot = MCPROT_GEN; J->mctop = (MCode *)((char *)J->mcarea + J->szmcarea); J->mcbot = (MCode *)((char *)J->mcarea + sizeof(MCLink)); ((MCLink *)J->mcarea)->next = oldarea; ((MCLink *)J->mcarea)->size = sz; J->szallmcarea += sz; } /* Free all MCode areas. */ void lj_mcode_free(jit_State *J) { MCode *mc = J->mcarea; J->mcarea = NULL; J->szallmcarea = 0; while (mc) { MCode *next = ((MCLink *)mc)->next; mcode_free(J, mc, ((MCLink *)mc)->size); mc = next; } } /* -- MCode transactions -------------------------------------------------- */ /* Reserve the remainder of the current MCode area. */ MCode *lj_mcode_reserve(jit_State *J, MCode **lim) { if (!J->mcarea) mcode_allocarea(J); else mcode_protect(J, MCPROT_GEN); *lim = J->mcbot; return J->mctop; } /* Commit the top part of the current MCode area. */ void lj_mcode_commit(jit_State *J, MCode *top) { J->mctop = top; mcode_protect(J, MCPROT_RUN); } /* Abort the reservation. */ void lj_mcode_abort(jit_State *J) { mcode_protect(J, MCPROT_RUN); } /* Set/reset protection to allow patching of MCode areas. */ MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish) { #ifdef LUAJIT_UNPROTECT_MCODE UNUSED(J); UNUSED(ptr); UNUSED(finish); return NULL; #else if (finish) { if (J->mcarea == ptr) mcode_protect(J, MCPROT_RUN); else mcode_setprot(ptr, ((MCLink *)ptr)->size, MCPROT_RUN); return NULL; } else { MCode *mc = J->mcarea; /* Try current area first to use the protection cache. */ if (ptr >= mc && ptr < (MCode *)((char *)mc + J->szmcarea)) { mcode_protect(J, MCPROT_GEN); return mc; } /* Otherwise search through the list of MCode areas. */ for (;;) { mc = ((MCLink *)mc)->next; lua_assert(mc != NULL); if (ptr >= mc && ptr < (MCode *)((char *)mc + ((MCLink *)mc)->size)) { mcode_setprot(mc, ((MCLink *)mc)->size, MCPROT_GEN); return mc; } } } #endif } /* Limit of MCode reservation reached. */ void lj_mcode_limiterr(jit_State *J, size_t need) { size_t sizemcode, maxmcode; lj_mcode_abort(J); sizemcode = (size_t)J->param[JIT_P_sizemcode] << 10; sizemcode = (sizemcode + LJ_PAGESIZE-1) & ~(size_t)(LJ_PAGESIZE - 1); maxmcode = (size_t)J->param[JIT_P_maxmcode] << 10; if ((size_t)need > sizemcode) lj_trace_err(J, LJ_TRERR_MCODEOV); /* Too long for any area. */ if (J->szallmcarea + sizemcode > maxmcode) lj_trace_err(J, LJ_TRERR_MCODEAL); mcode_allocarea(J); lj_trace_err(J, LJ_TRERR_MCODELM); /* Retry with new area. */ } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_mcode.h ================================================ /* ** Machine code management. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_MCODE_H #define _LJ_MCODE_H #include "lj_obj.h" #if LJ_HASJIT || LJ_HASFFI LJ_FUNC void lj_mcode_sync(void *start, void *end); #endif #if LJ_HASJIT #include "lj_jit.h" LJ_FUNC void lj_mcode_free(jit_State *J); LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); LJ_FUNC void lj_mcode_abort(jit_State *J); LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); #define lj_mcode_commitbot(J, m) (J->mcbot = (m)) #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_meta.c ================================================ /* ** Metamethod handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lj_meta_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_meta.h" #include "lj_frame.h" #include "lj_bc.h" #include "lj_vm.h" #include "lj_strscan.h" /* -- Metamethod handling ------------------------------------------------- */ /* String interning of metamethod names for fast indexing. */ void lj_meta_init(lua_State *L) { #define MMNAME(name) "__" #name const char *metanames = MMDEF(MMNAME); #undef MMNAME global_State *g = G(L); const char *p, *q; uint32_t mm; for (mm = 0, p = metanames; *p; mm++, p = q) { GCstr *s; for (q = p+2; *q && *q != '_'; q++) ; s = lj_str_new(L, p, (size_t)(q-p)); /* NOBARRIER: g->gcroot[] is a GC root. */ setgcref(g->gcroot[GCROOT_MMNAME+mm], obj2gco(s)); } } /* Negative caching of a few fast metamethods. See the lj_meta_fast() macro. */ cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name) { cTValue *mo = lj_tab_getstr(mt, name); lua_assert(mm <= MM_FAST); if (!mo || tvisnil(mo)) { /* No metamethod? */ mt->nomm |= (uint8_t)(1u<metatable); else if (tvisudata(o)) mt = tabref(udataV(o)->metatable); else mt = tabref(basemt_obj(G(L), o)); if (mt) { cTValue *mo = lj_tab_getstr(mt, mmname_str(G(L), mm)); if (mo) return mo; } return niltv(L); } #if LJ_HASFFI /* Tailcall from C function. */ int lj_meta_tailcall(lua_State *L, cTValue *tv) { TValue *base = L->base; TValue *top = L->top; const BCIns *pc = frame_pc(base-1); /* Preserve old PC from frame. */ copyTV(L, base-1, tv); /* Replace frame with new object. */ top->u32.lo = LJ_CONT_TAILCALL; setframe_pc(top, pc); setframe_gc(top+1, obj2gco(L)); /* Dummy frame object. */ setframe_ftsz(top+1, (int)((char *)(top+2) - (char *)base) + FRAME_CONT); L->base = L->top = top+2; /* ** before: [old_mo|PC] [... ...] ** ^base ^top ** after: [new_mo|itype] [... ...] [NULL|PC] [dummy|delta] ** ^base/top ** tailcall: [new_mo|PC] [... ...] ** ^base ^top */ return 0; } #endif /* Setup call to metamethod to be run by Assembler VM. */ static TValue *mmcall(lua_State *L, ASMFunction cont, cTValue *mo, cTValue *a, cTValue *b) { /* ** |-- framesize -> top top+1 top+2 top+3 ** before: [func slots ...] ** mm setup: [func slots ...] [cont|?] [mo|tmtype] [a] [b] ** in asm: [func slots ...] [cont|PC] [mo|delta] [a] [b] ** ^-- func base ^-- mm base ** after mm: [func slots ...] [result] ** ^-- copy to base[PC_RA] --/ for lj_cont_ra ** istruecond + branch for lj_cont_cond* ** ignore for lj_cont_nop ** next PC: [func slots ...] */ TValue *top = L->top; if (curr_funcisL(L)) top = curr_topL(L); setcont(top, cont); /* Assembler VM stores PC in upper word. */ copyTV(L, top+1, mo); /* Store metamethod and two arguments. */ copyTV(L, top+2, a); copyTV(L, top+3, b); return top+2; /* Return new base. */ } /* -- C helpers for some instructions, called from assembler VM ----------- */ /* Helper for TGET*. __index chain and metamethod. */ cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k) { int loop; for (loop = 0; loop < LJ_MAX_IDXCHAIN; loop++) { cTValue *mo; if (LJ_LIKELY(tvistab(o))) { GCtab *t = tabV(o); cTValue *tv = lj_tab_get(L, t, k); if (!tvisnil(tv) || !(mo = lj_meta_fast(L, tabref(t->metatable), MM_index))) return tv; } else if (tvisnil(mo = lj_meta_lookup(L, o, MM_index))) { lj_err_optype(L, o, LJ_ERR_OPINDEX); return NULL; /* unreachable */ } if (tvisfunc(mo)) { L->top = mmcall(L, lj_cont_ra, mo, o, k); return NULL; /* Trigger metamethod call. */ } o = mo; } lj_err_msg(L, LJ_ERR_GETLOOP); return NULL; /* unreachable */ } /* Helper for TSET*. __newindex chain and metamethod. */ TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k) { TValue tmp; int loop; for (loop = 0; loop < LJ_MAX_IDXCHAIN; loop++) { cTValue *mo; if (LJ_LIKELY(tvistab(o))) { GCtab *t = tabV(o); cTValue *tv = lj_tab_get(L, t, k); if (LJ_LIKELY(!tvisnil(tv))) { t->nomm = 0; /* Invalidate negative metamethod cache. */ lj_gc_anybarriert(L, t); return (TValue *)tv; } else if (!(mo = lj_meta_fast(L, tabref(t->metatable), MM_newindex))) { t->nomm = 0; /* Invalidate negative metamethod cache. */ lj_gc_anybarriert(L, t); if (tv != niltv(L)) return (TValue *)tv; if (tvisnil(k)) lj_err_msg(L, LJ_ERR_NILIDX); else if (tvisint(k)) { setnumV(&tmp, (lua_Number)intV(k)); k = &tmp; } else if (tvisnum(k) && tvisnan(k)) lj_err_msg(L, LJ_ERR_NANIDX); return lj_tab_newkey(L, t, k); } } else if (tvisnil(mo = lj_meta_lookup(L, o, MM_newindex))) { lj_err_optype(L, o, LJ_ERR_OPINDEX); return NULL; /* unreachable */ } if (tvisfunc(mo)) { L->top = mmcall(L, lj_cont_nop, mo, o, k); /* L->top+2 = v filled in by caller. */ return NULL; /* Trigger metamethod call. */ } copyTV(L, &tmp, mo); o = &tmp; } lj_err_msg(L, LJ_ERR_SETLOOP); return NULL; /* unreachable */ } static cTValue *str2num(cTValue *o, TValue *n) { if (tvisnum(o)) return o; else if (tvisint(o)) return (setnumV(n, (lua_Number)intV(o)), n); else if (tvisstr(o) && lj_strscan_num(strV(o), n)) return n; else return NULL; } /* Helper for arithmetic instructions. Coercion, metamethod. */ TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, cTValue *rc, BCReg op) { MMS mm = bcmode_mm(op); TValue tempb, tempc; cTValue *b, *c; if ((b = str2num(rb, &tempb)) != NULL && (c = str2num(rc, &tempc)) != NULL) { /* Try coercion first. */ setnumV(ra, lj_vm_foldarith(numV(b), numV(c), (int)mm-MM_add)); return NULL; } else { cTValue *mo = lj_meta_lookup(L, rb, mm); if (tvisnil(mo)) { mo = lj_meta_lookup(L, rc, mm); if (tvisnil(mo)) { if (str2num(rb, &tempb) == NULL) rc = rb; lj_err_optype(L, rc, LJ_ERR_OPARITH); return NULL; /* unreachable */ } } return mmcall(L, lj_cont_ra, mo, rb, rc); } } /* In-place coercion of a number to a string. */ static LJ_AINLINE int tostring(lua_State *L, TValue *o) { if (tvisstr(o)) { return 1; } else if (tvisnumber(o)) { setstrV(L, o, lj_str_fromnumber(L, o)); return 1; } else { return 0; } } /* Helper for CAT. Coercion, iterative concat, __concat metamethod. */ TValue *lj_meta_cat(lua_State *L, TValue *top, int left) { int fromc = 0; if (left < 0) { left = -left; fromc = 1; } do { int n = 1; if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) { cTValue *mo = lj_meta_lookup(L, top-1, MM_concat); if (tvisnil(mo)) { mo = lj_meta_lookup(L, top, MM_concat); if (tvisnil(mo)) { if (tvisstr(top-1) || tvisnumber(top-1)) top++; lj_err_optype(L, top-1, LJ_ERR_OPCAT); return NULL; /* unreachable */ } } /* One of the top two elements is not a string, call __cat metamethod: ** ** before: [...][CAT stack .........................] ** top-1 top top+1 top+2 ** pick two: [...][CAT stack ...] [o1] [o2] ** setup mm: [...][CAT stack ...] [cont|?] [mo|tmtype] [o1] [o2] ** in asm: [...][CAT stack ...] [cont|PC] [mo|delta] [o1] [o2] ** ^-- func base ^-- mm base ** after mm: [...][CAT stack ...] <--push-- [result] ** next step: [...][CAT stack .............] */ copyTV(L, top+2, top); /* Careful with the order of stack copies! */ copyTV(L, top+1, top-1); copyTV(L, top, mo); setcont(top-1, lj_cont_cat); return top+1; /* Trigger metamethod call. */ } else if (strV(top)->len == 0) { /* Shortcut. */ (void)tostring(L, top-1); } else { /* Pick as many strings as possible from the top and concatenate them: ** ** before: [...][CAT stack ...........................] ** pick str: [...][CAT stack ...] [...... strings ......] ** concat: [...][CAT stack ...] [result] ** next step: [...][CAT stack ............] */ MSize tlen = strV(top)->len; char *buffer; int i; for (n = 1; n <= left && tostring(L, top-n); n++) { MSize len = strV(top-n)->len; if (len >= LJ_MAX_STR - tlen) lj_err_msg(L, LJ_ERR_STROV); tlen += len; } buffer = lj_str_needbuf(L, &G(L)->tmpbuf, tlen); n--; tlen = 0; for (i = n; i >= 0; i--) { MSize len = strV(top-i)->len; memcpy(buffer + tlen, strVdata(top-i), len); tlen += len; } setstrV(L, top-n, lj_str_new(L, buffer, tlen)); } left -= n; top -= n; } while (left >= 1); if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) { if (!fromc) L->top = curr_topL(L); lj_gc_step(L); } return NULL; } /* Helper for LEN. __len metamethod. */ TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o) { cTValue *mo = lj_meta_lookup(L, o, MM_len); if (tvisnil(mo)) { if (LJ_52 && tvistab(o)) tabref(tabV(o)->metatable)->nomm |= (uint8_t)(1u<gch.metatable), MM_eq); if (mo) { TValue *top; uint32_t it; if (tabref(o1->gch.metatable) != tabref(o2->gch.metatable)) { cTValue *mo2 = lj_meta_fast(L, tabref(o2->gch.metatable), MM_eq); if (mo2 == NULL || !lj_obj_equal(mo, mo2)) return (TValue *)(intptr_t)ne; } top = curr_top(L); setcont(top, ne ? lj_cont_condf : lj_cont_condt); copyTV(L, top+1, mo); it = ~(uint32_t)o1->gch.gct; setgcV(L, top+2, o1, it); setgcV(L, top+3, o2, it); return top+2; /* Trigger metamethod call. */ } return (TValue *)(intptr_t)ne; } #if LJ_HASFFI TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins) { ASMFunction cont = (bc_op(ins) & 1) ? lj_cont_condf : lj_cont_condt; int op = (int)bc_op(ins) & ~1; TValue tv; cTValue *mo, *o2, *o1 = &L->base[bc_a(ins)]; cTValue *o1mm = o1; if (op == BC_ISEQV) { o2 = &L->base[bc_d(ins)]; if (!tviscdata(o1mm)) o1mm = o2; } else if (op == BC_ISEQS) { setstrV(L, &tv, gco2str(proto_kgc(curr_proto(L), ~(ptrdiff_t)bc_d(ins)))); o2 = &tv; } else if (op == BC_ISEQN) { o2 = &mref(curr_proto(L)->k, cTValue)[bc_d(ins)]; } else { lua_assert(op == BC_ISEQP); setitype(&tv, ~bc_d(ins)); o2 = &tv; } mo = lj_meta_lookup(L, o1mm, MM_eq); if (LJ_LIKELY(!tvisnil(mo))) return mmcall(L, cont, mo, o1, o2); else return (TValue *)(intptr_t)(bc_op(ins) & 1); } #endif /* Helper for ordered comparisons. String compare, __lt/__le metamethods. */ TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op) { if (LJ_HASFFI && (tviscdata(o1) || tviscdata(o2))) { ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; MMS mm = (op & 2) ? MM_le : MM_lt; cTValue *mo = lj_meta_lookup(L, tviscdata(o1) ? o1 : o2, mm); if (LJ_UNLIKELY(tvisnil(mo))) goto err; return mmcall(L, cont, mo, o1, o2); } else if (LJ_52 || itype(o1) == itype(o2)) { /* Never called with two numbers. */ if (tvisstr(o1) && tvisstr(o2)) { int32_t res = lj_str_cmp(strV(o1), strV(o2)); return (TValue *)(intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1)); } else { trymt: while (1) { ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; MMS mm = (op & 2) ? MM_le : MM_lt; cTValue *mo = lj_meta_lookup(L, o1, mm); #if LJ_52 if (tvisnil(mo) && tvisnil((mo = lj_meta_lookup(L, o2, mm)))) #else cTValue *mo2 = lj_meta_lookup(L, o2, mm); if (tvisnil(mo) || !lj_obj_equal(mo, mo2)) #endif { if (op & 2) { /* MM_le not found: retry with MM_lt. */ cTValue *ot = o1; o1 = o2; o2 = ot; /* Swap operands. */ op ^= 3; /* Use LT and flip condition. */ continue; } goto err; } return mmcall(L, cont, mo, o1, o2); } } } else if (tvisbool(o1) && tvisbool(o2)) { goto trymt; } else { err: lj_err_comp(L, o1, o2); return NULL; } } /* Helper for calls. __call metamethod. */ void lj_meta_call(lua_State *L, TValue *func, TValue *top) { cTValue *mo = lj_meta_lookup(L, func, MM_call); TValue *p; if (!tvisfunc(mo)) lj_err_optype_call(L, func); for (p = top; p > func; p--) copyTV(L, p, p-1); copyTV(L, func, mo); } /* Helper for FORI. Coercion. */ void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o) { if (!lj_strscan_numberobj(o)) lj_err_msg(L, LJ_ERR_FORINIT); if (!lj_strscan_numberobj(o+1)) lj_err_msg(L, LJ_ERR_FORLIM); if (!lj_strscan_numberobj(o+2)) lj_err_msg(L, LJ_ERR_FORSTEP); if (LJ_DUALNUM) { /* Ensure all slots are integers or all slots are numbers. */ int32_t k[3]; int nint = 0; ptrdiff_t i; for (i = 0; i <= 2; i++) { if (tvisint(o+i)) { k[i] = intV(o+i); nint++; } else { k[i] = lj_num2int(numV(o+i)); nint += ((lua_Number)k[i] == numV(o+i)); } } if (nint == 3) { /* Narrow to integers. */ setintV(o, k[0]); setintV(o+1, k[1]); setintV(o+2, k[2]); } else if (nint != 0) { /* Widen to numbers. */ if (tvisint(o)) setnumV(o, (lua_Number)intV(o)); if (tvisint(o+1)) setnumV(o+1, (lua_Number)intV(o+1)); if (tvisint(o+2)) setnumV(o+2, (lua_Number)intV(o+2)); } } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_meta.h ================================================ /* ** Metamethod handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_META_H #define _LJ_META_H #include "lj_obj.h" /* Metamethod handling */ LJ_FUNC void lj_meta_init(lua_State *L); LJ_FUNC cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name); LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm); #if LJ_HASFFI LJ_FUNC int lj_meta_tailcall(lua_State *L, cTValue *tv); #endif #define lj_meta_fastg(g, mt, mm) \ ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ lj_meta_cache(mt, mm, mmname_str(g, mm))) #define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) /* C helpers for some instructions, called from assembler VM. */ LJ_FUNCA cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k); LJ_FUNCA TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k); LJ_FUNCA TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, cTValue *rc, BCReg op); LJ_FUNCA TValue *lj_meta_cat(lua_State *L, TValue *top, int left); LJ_FUNCA TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o); LJ_FUNCA TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne); LJ_FUNCA TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins); LJ_FUNCA TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op); LJ_FUNCA void lj_meta_call(lua_State *L, TValue *func, TValue *top); LJ_FUNCA void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_obj.c ================================================ /* ** Miscellaneous object handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_obj_c #define LUA_CORE #include "lj_obj.h" /* Object type names. */ LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ "no value", "nil", "boolean", "userdata", "number", "string", "table", "function", "userdata", "thread", "proto", "cdata" }; LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", "proto", "function", "trace", "cdata", "table", "userdata", "number" }; /* Compare two objects without calling metamethods. */ int lj_obj_equal(cTValue *o1, cTValue *o2) { if (itype(o1) == itype(o2)) { if (tvispri(o1)) return 1; if (!tvisnum(o1)) return gcrefeq(o1->gcr, o2->gcr); } else if (!tvisnumber(o1) || !tvisnumber(o2)) { return 0; } return numberVnum(o1) == numberVnum(o2); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_obj.h ================================================ /* ** LuaJIT VM tags, values and objects. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #ifndef _LJ_OBJ_H #define _LJ_OBJ_H #include "lua.h" #include "lj_def.h" #include "lj_arch.h" /* -- Memory references (32 bit address space) ---------------------------- */ /* Memory size. */ typedef uint32_t MSize; /* Memory reference */ typedef struct MRef { uint32_t ptr32; /* Pseudo 32 bit pointer. */ } MRef; #define mref(r, t) ((t *)(void *)(uintptr_t)(r).ptr32) #define setmref(r, p) ((r).ptr32 = (uint32_t)(uintptr_t)(void *)(p)) #define setmrefr(r, v) ((r).ptr32 = (v).ptr32) /* -- GC object references (32 bit address space) ------------------------- */ /* GCobj reference */ typedef struct GCRef { uint32_t gcptr32; /* Pseudo 32 bit pointer. */ } GCRef; /* Common GC header for all collectable objects. */ #define GCHeader GCRef nextgc; uint8_t marked; uint8_t gct /* This occupies 6 bytes, so use the next 2 bytes for non-32 bit fields. */ #define gcref(r) ((GCobj *)(uintptr_t)(r).gcptr32) #define gcrefp(r, t) ((t *)(void *)(uintptr_t)(r).gcptr32) #define gcrefu(r) ((r).gcptr32) #define gcrefi(r) ((int32_t)(r).gcptr32) #define gcrefeq(r1, r2) ((r1).gcptr32 == (r2).gcptr32) #define gcnext(gc) (gcref((gc)->gch.nextgc)) #define setgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch) #define setgcrefi(r, i) ((r).gcptr32 = (uint32_t)(i)) #define setgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p)) #define setgcrefnull(r) ((r).gcptr32 = 0) #define setgcrefr(r, v) ((r).gcptr32 = (v).gcptr32) /* IMPORTANT NOTE: ** ** All uses of the setgcref* macros MUST be accompanied with a write barrier. ** ** This is to ensure the integrity of the incremental GC. The invariant ** to preserve is that a black object never points to a white object. ** I.e. never store a white object into a field of a black object. ** ** It's ok to LEAVE OUT the write barrier ONLY in the following cases: ** - The source is not a GC object (NULL). ** - The target is a GC root. I.e. everything in global_State. ** - The target is a lua_State field (threads are never black). ** - The target is a stack slot, see setgcV et al. ** - The target is an open upvalue, i.e. pointing to a stack slot. ** - The target is a newly created object (i.e. marked white). But make ** sure nothing invokes the GC inbetween. ** - The target and the source are the same object (self-reference). ** - The target already contains the object (e.g. moving elements around). ** ** The most common case is a store to a stack slot. All other cases where ** a barrier has been omitted are annotated with a NOBARRIER comment. ** ** The same logic applies for stores to table slots (array part or hash ** part). ALL uses of lj_tab_set* require a barrier for the stored value ** *and* the stored key, based on the above rules. In practice this means ** a barrier is needed if *either* of the key or value are a GC object. ** ** It's ok to LEAVE OUT the write barrier in the following special cases: ** - The stored value is nil. The key doesn't matter because it's either ** not resurrected or lj_tab_newkey() will take care of the key barrier. ** - The key doesn't matter if the *previously* stored value is guaranteed ** to be non-nil (because the key is kept alive in the table). ** - The key doesn't matter if it's guaranteed not to be part of the table, ** since lj_tab_newkey() takes care of the key barrier. This applies ** trivially to new tables, but watch out for resurrected keys. Storing ** a nil value leaves the key in the table! ** ** In case of doubt use lj_gc_anybarriert() as it's rather cheap. It's used ** by the interpreter for all table stores. ** ** Note: In contrast to Lua's GC, LuaJIT's GC does *not* specially mark ** dead keys in tables. The reference is left in, but it's guaranteed to ** be never dereferenced as long as the value is nil. It's ok if the key is ** freed or if any object subsequently gets the same address. ** ** Not destroying dead keys helps to keep key hash slots stable. This avoids ** specialization back-off for HREFK when a value flips between nil and ** non-nil and the GC gets in the way. It also allows safely hoisting ** HREF/HREFK across GC steps. Dead keys are only removed if a table is ** resized (i.e. by NEWREF) and xREF must not be CSEd across a resize. ** ** The trade-off is that a write barrier for tables must take the key into ** account, too. Implicitly resurrecting the key by storing a non-nil value ** may invalidate the incremental GC invariant. */ /* -- Common type definitions --------------------------------------------- */ /* Types for handling bytecodes. Need this here, details in lj_bc.h. */ typedef uint32_t BCIns; /* Bytecode instruction. */ typedef uint32_t BCPos; /* Bytecode position. */ typedef uint32_t BCReg; /* Bytecode register. */ typedef int32_t BCLine; /* Bytecode line number. */ /* Internal assembler functions. Never call these directly from C. */ typedef void (*ASMFunction)(void); /* Resizable string buffer. Need this here, details in lj_str.h. */ typedef struct SBuf { char *buf; /* String buffer base. */ MSize n; /* String buffer length. */ MSize sz; /* String buffer size. */ } SBuf; /* -- Tags and values ----------------------------------------------------- */ /* Frame link. */ typedef union { int32_t ftsz; /* Frame type and size of previous frame. */ MRef pcr; /* Overlaps PC for Lua frames. */ } FrameLink; /* Tagged value. */ typedef LJ_ALIGN(8) union TValue { uint64_t u64; /* 64 bit pattern overlaps number. */ lua_Number n; /* Number object overlaps split tag/value object. */ struct { LJ_ENDIAN_LOHI( union { GCRef gcr; /* GCobj reference (if any). */ int32_t i; /* Integer value. */ }; , uint32_t it; /* Internal object tag. Must overlap MSW of number. */ ) }; struct { LJ_ENDIAN_LOHI( GCRef func; /* Function for next frame (or dummy L). */ , FrameLink tp; /* Link to previous frame. */ ) } fr; struct { LJ_ENDIAN_LOHI( uint32_t lo; /* Lower 32 bits of number. */ , uint32_t hi; /* Upper 32 bits of number. */ ) } u32; } TValue; typedef const TValue cTValue; #define tvref(r) (mref(r, TValue)) /* More external and GCobj tags for internal objects. */ #define LAST_TT LUA_TTHREAD #define LUA_TPROTO (LAST_TT+1) #define LUA_TCDATA (LAST_TT+2) /* Internal object tags. ** ** Internal tags overlap the MSW of a number object (must be a double). ** Interpreted as a double these are special NaNs. The FPU only generates ** one type of NaN (0xfff8_0000_0000_0000). So MSWs > 0xfff80000 are available ** for use as internal tags. Small negative numbers are used to shorten the ** encoding of type comparisons (reg/mem against sign-ext. 8 bit immediate). ** ** ---MSW---.---LSW--- ** primitive types | itype | | ** lightuserdata | itype | void * | (32 bit platforms) ** lightuserdata |ffff| void * | (64 bit platforms, 47 bit pointers) ** GC objects | itype | GCRef | ** int (LJ_DUALNUM)| itype | int | ** number -------double------ ** ** ORDER LJ_T ** Primitive types nil/false/true must be first, lightuserdata next. ** GC objects are at the end, table/userdata must be lowest. ** Also check lj_ir.h for similar ordering constraints. */ #define LJ_TNIL (~0u) #define LJ_TFALSE (~1u) #define LJ_TTRUE (~2u) #define LJ_TLIGHTUD (~3u) #define LJ_TSTR (~4u) #define LJ_TUPVAL (~5u) #define LJ_TTHREAD (~6u) #define LJ_TPROTO (~7u) #define LJ_TFUNC (~8u) #define LJ_TTRACE (~9u) #define LJ_TCDATA (~10u) #define LJ_TTAB (~11u) #define LJ_TUDATA (~12u) /* This is just the canonical number type used in some places. */ #define LJ_TNUMX (~13u) /* Integers have itype == LJ_TISNUM doubles have itype < LJ_TISNUM */ #if LJ_64 #define LJ_TISNUM 0xfffeffffu #else #define LJ_TISNUM LJ_TNUMX #endif #define LJ_TISTRUECOND LJ_TFALSE #define LJ_TISPRI LJ_TTRUE #define LJ_TISGCV (LJ_TSTR+1) #define LJ_TISTABUD LJ_TTAB /* -- String object ------------------------------------------------------- */ /* String object header. String payload follows. */ typedef struct GCstr { GCHeader; uint8_t reserved; /* Used by lexer for fast lookup of reserved words. */ uint8_t unused; MSize hash; /* Hash of string. */ MSize len; /* Size of string. */ } GCstr; #define strref(r) (&gcref((r))->str) #define strdata(s) ((const char *)((s)+1)) #define strdatawr(s) ((char *)((s)+1)) #define strVdata(o) strdata(strV(o)) #define sizestring(s) (sizeof(struct GCstr)+(s)->len+1) /* -- Userdata object ----------------------------------------------------- */ /* Userdata object. Payload follows. */ typedef struct GCudata { GCHeader; uint8_t udtype; /* Userdata type. */ uint8_t unused2; GCRef env; /* Should be at same offset in GCfunc. */ MSize len; /* Size of payload. */ GCRef metatable; /* Must be at same offset in GCtab. */ uint32_t align1; /* To force 8 byte alignment of the payload. */ } GCudata; /* Userdata types. */ enum { UDTYPE_USERDATA, /* Regular userdata. */ UDTYPE_IO_FILE, /* I/O library FILE. */ UDTYPE_FFI_CLIB, /* FFI C library namespace. */ UDTYPE__MAX }; #define uddata(u) ((void *)((u)+1)) #define sizeudata(u) (sizeof(struct GCudata)+(u)->len) /* -- C data object ------------------------------------------------------- */ /* C data object. Payload follows. */ typedef struct GCcdata { GCHeader; uint16_t ctypeid; /* C type ID. */ } GCcdata; /* Prepended to variable-sized or realigned C data objects. */ typedef struct GCcdataVar { uint16_t offset; /* Offset to allocated memory (relative to GCcdata). */ uint16_t extra; /* Extra space allocated (incl. GCcdata + GCcdatav). */ MSize len; /* Size of payload. */ } GCcdataVar; #define cdataptr(cd) ((void *)((cd)+1)) #define cdataisv(cd) ((cd)->marked & 0x80) #define cdatav(cd) ((GCcdataVar *)((char *)(cd) - sizeof(GCcdataVar))) #define cdatavlen(cd) check_exp(cdataisv(cd), cdatav(cd)->len) #define sizecdatav(cd) (cdatavlen(cd) + cdatav(cd)->extra) #define memcdatav(cd) ((void *)((char *)(cd) - cdatav(cd)->offset)) /* -- Prototype object ---------------------------------------------------- */ #define SCALE_NUM_GCO ((int32_t)sizeof(lua_Number)/sizeof(GCRef)) #define round_nkgc(n) (((n) + SCALE_NUM_GCO-1) & ~(SCALE_NUM_GCO-1)) typedef struct GCproto { GCHeader; uint8_t numparams; /* Number of parameters. */ uint8_t framesize; /* Fixed frame size. */ MSize sizebc; /* Number of bytecode instructions. */ GCRef gclist; MRef k; /* Split constant array (points to the middle). */ MRef uv; /* Upvalue list. local slot|0x8000 or parent uv idx. */ MSize sizekgc; /* Number of collectable constants. */ MSize sizekn; /* Number of lua_Number constants. */ MSize sizept; /* Total size including colocated arrays. */ uint8_t sizeuv; /* Number of upvalues. */ uint8_t flags; /* Miscellaneous flags (see below). */ uint16_t trace; /* Anchor for chain of root traces. */ /* ------ The following fields are for debugging/tracebacks only ------ */ GCRef chunkname; /* Name of the chunk this function was defined in. */ BCLine firstline; /* First line of the function definition. */ BCLine numline; /* Number of lines for the function definition. */ MRef lineinfo; /* Compressed map from bytecode ins. to source line. */ MRef uvinfo; /* Upvalue names. */ MRef varinfo; /* Names and compressed extents of local variables. */ } GCproto; /* Flags for prototype. */ #define PROTO_CHILD 0x01 /* Has child prototypes. */ #define PROTO_VARARG 0x02 /* Vararg function. */ #define PROTO_FFI 0x04 /* Uses BC_KCDATA for FFI datatypes. */ #define PROTO_NOJIT 0x08 /* JIT disabled for this function. */ #define PROTO_ILOOP 0x10 /* Patched bytecode with ILOOP etc. */ /* Only used during parsing. */ #define PROTO_HAS_RETURN 0x20 /* Already emitted a return. */ #define PROTO_FIXUP_RETURN 0x40 /* Need to fixup emitted returns. */ /* Top bits used for counting created closures. */ #define PROTO_CLCOUNT 0x20 /* Base of saturating 3 bit counter. */ #define PROTO_CLC_BITS 3 #define PROTO_CLC_POLY (3*PROTO_CLCOUNT) /* Polymorphic threshold. */ #define PROTO_UV_LOCAL 0x8000 /* Upvalue for local slot. */ #define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */ #define proto_kgc(pt, idx) \ check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \ gcref(mref((pt)->k, GCRef)[(idx)])) #define proto_knumtv(pt, idx) \ check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)]) #define proto_bc(pt) ((BCIns *)((char *)(pt) + sizeof(GCproto))) #define proto_bcpos(pt, pc) ((BCPos)((pc) - proto_bc(pt))) #define proto_uv(pt) (mref((pt)->uv, uint16_t)) #define proto_chunkname(pt) (strref((pt)->chunkname)) #define proto_chunknamestr(pt) (strdata(proto_chunkname((pt)))) #define proto_lineinfo(pt) (mref((pt)->lineinfo, const void)) #define proto_uvinfo(pt) (mref((pt)->uvinfo, const uint8_t)) #define proto_varinfo(pt) (mref((pt)->varinfo, const uint8_t)) /* -- Upvalue object ------------------------------------------------------ */ typedef struct GCupval { GCHeader; uint8_t closed; /* Set if closed (i.e. uv->v == &uv->u.value). */ uint8_t immutable; /* Immutable value. */ union { TValue tv; /* If closed: the value itself. */ struct { /* If open: double linked list, anchored at thread. */ GCRef prev; GCRef next; }; }; MRef v; /* Points to stack slot (open) or above (closed). */ uint32_t dhash; /* Disambiguation hash: dh1 != dh2 => cannot alias. */ } GCupval; #define uvprev(uv_) (&gcref((uv_)->prev)->uv) #define uvnext(uv_) (&gcref((uv_)->next)->uv) #define uvval(uv_) (mref((uv_)->v, TValue)) /* -- Function object (closures) ------------------------------------------ */ /* Common header for functions. env should be at same offset in GCudata. */ #define GCfuncHeader \ GCHeader; uint8_t ffid; uint8_t nupvalues; \ GCRef env; GCRef gclist; MRef pc typedef struct GCfuncC { GCfuncHeader; lua_CFunction f; /* C function to be called. */ TValue upvalue[1]; /* Array of upvalues (TValue). */ } GCfuncC; typedef struct GCfuncL { GCfuncHeader; GCRef uvptr[1]; /* Array of _pointers_ to upvalue objects (GCupval). */ } GCfuncL; typedef union GCfunc { GCfuncC c; GCfuncL l; } GCfunc; #define FF_LUA 0 #define FF_C 1 #define isluafunc(fn) ((fn)->c.ffid == FF_LUA) #define iscfunc(fn) ((fn)->c.ffid == FF_C) #define isffunc(fn) ((fn)->c.ffid > FF_C) #define funcproto(fn) \ check_exp(isluafunc(fn), (GCproto *)(mref((fn)->l.pc, char)-sizeof(GCproto))) #define sizeCfunc(n) (sizeof(GCfuncC)-sizeof(TValue)+sizeof(TValue)*(n)) #define sizeLfunc(n) (sizeof(GCfuncL)-sizeof(GCRef)+sizeof(GCRef)*(n)) /* -- Table object -------------------------------------------------------- */ /* Hash node. */ typedef struct Node { TValue val; /* Value object. Must be first field. */ TValue key; /* Key object. */ MRef next; /* Hash chain. */ MRef freetop; /* Top of free elements (stored in t->node[0]). */ } Node; LJ_STATIC_ASSERT(offsetof(Node, val) == 0); typedef struct GCtab { GCHeader; uint8_t nomm; /* Negative cache for fast metamethods. */ int8_t colo; /* Array colocation. */ MRef array; /* Array part. */ GCRef gclist; GCRef metatable; /* Must be at same offset in GCudata. */ MRef node; /* Hash part. */ uint32_t asize; /* Size of array part (keys [0, asize-1]). */ uint32_t hmask; /* Hash part mask (size of hash part - 1). */ } GCtab; #define sizetabcolo(n) ((n)*sizeof(TValue) + sizeof(GCtab)) #define tabref(r) (&gcref((r))->tab) #define noderef(r) (mref((r), Node)) #define nextnode(n) (mref((n)->next, Node)) /* -- State objects ------------------------------------------------------- */ /* VM states. */ enum { LJ_VMST_INTERP, /* Interpreter. */ LJ_VMST_C, /* C function. */ LJ_VMST_GC, /* Garbage collector. */ LJ_VMST_EXIT, /* Trace exit handler. */ LJ_VMST_RECORD, /* Trace recorder. */ LJ_VMST_OPT, /* Optimizer. */ LJ_VMST_ASM, /* Assembler. */ LJ_VMST__MAX }; #define setvmstate(g, st) ((g)->vmstate = ~LJ_VMST_##st) /* Metamethods. ORDER MM */ #ifdef LJ_HASFFI #define MMDEF_FFI(_) _(new) #else #define MMDEF_FFI(_) #endif #if LJ_52 || LJ_HASFFI #define MMDEF_PAIRS(_) _(pairs) _(ipairs) #else #define MMDEF_PAIRS(_) #define MM_pairs 255 #define MM_ipairs 255 #endif #define MMDEF(_) \ _(index) _(newindex) _(gc) _(mode) _(eq) _(len) \ /* Only the above (fast) metamethods are negative cached (max. 8). */ \ _(lt) _(le) _(concat) _(call) \ /* The following must be in ORDER ARITH. */ \ _(add) _(sub) _(mul) _(div) _(mod) _(pow) _(unm) \ /* The following are used in the standard libraries. */ \ _(metatable) _(tostring) MMDEF_FFI(_) MMDEF_PAIRS(_) typedef enum { #define MMENUM(name) MM_##name, MMDEF(MMENUM) #undef MMENUM MM__MAX, MM____ = MM__MAX, MM_FAST = MM_len } MMS; /* GC root IDs. */ typedef enum { GCROOT_MMNAME, /* Metamethod names. */ GCROOT_MMNAME_LAST = GCROOT_MMNAME + MM__MAX-1, GCROOT_BASEMT, /* Metatables for base types. */ GCROOT_BASEMT_NUM = GCROOT_BASEMT + ~LJ_TNUMX, GCROOT_IO_INPUT, /* Userdata for default I/O input file. */ GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */ GCROOT_MAX } GCRootID; #define basemt_it(g, it) ((g)->gcroot[GCROOT_BASEMT+~(it)]) #define basemt_obj(g, o) ((g)->gcroot[GCROOT_BASEMT+itypemap(o)]) #define mmname_str(g, mm) (strref((g)->gcroot[GCROOT_MMNAME+(mm)])) typedef struct GCState { MSize total; /* Memory currently allocated. */ MSize threshold; /* Memory threshold. */ uint8_t currentwhite; /* Current white color. */ uint8_t state; /* GC state. */ uint8_t unused1; uint8_t unused2; MSize sweepstr; /* Sweep position in string table. */ GCRef root; /* List of all collectable objects. */ MRef sweep; /* Sweep position in root list. */ GCRef gray; /* List of gray objects. */ GCRef grayagain; /* List of objects for atomic traversal. */ GCRef weak; /* List of weak tables (to be cleared). */ GCRef mmudata; /* List of userdata (to be finalized). */ MSize stepmul; /* Incremental GC step granularity. */ MSize debt; /* Debt (how much GC is behind schedule). */ MSize estimate; /* Estimate of memory actually in use. */ MSize pause; /* Pause between successive GC cycles. */ } GCState; /* Global state, shared by all threads of a Lua universe. */ typedef struct global_State { GCRef *strhash; /* String hash table (hash chain anchors). */ MSize strmask; /* String hash mask (size of hash table - 1). */ MSize strnum; /* Number of strings in hash table. */ lua_Alloc allocf; /* Memory allocator. */ void *allocd; /* Memory allocator data. */ GCState gc; /* Garbage collector. */ SBuf tmpbuf; /* Temporary buffer for string concatenation. */ Node nilnode; /* Fallback 1-element hash part (nil key and value). */ GCstr strempty; /* Empty string. */ uint8_t stremptyz; /* Zero terminator of empty string. */ uint8_t hookmask; /* Hook mask. */ uint8_t dispatchmode; /* Dispatch mode. */ uint8_t vmevmask; /* VM event mask. */ GCRef mainthref; /* Link to main thread. */ TValue registrytv; /* Anchor for registry. */ TValue tmptv, tmptv2; /* Temporary TValues. */ GCupval uvhead; /* Head of double-linked list of all open upvalues. */ int32_t hookcount; /* Instruction hook countdown. */ int32_t hookcstart; /* Start count for instruction hook counter. */ lua_Hook hookf; /* Hook function. */ lua_CFunction wrapf; /* Wrapper for C function calls. */ lua_CFunction panic; /* Called as a last resort for errors. */ volatile int32_t vmstate; /* VM state or current JIT code trace number. */ BCIns bc_cfunc_int; /* Bytecode for internal C function calls. */ BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */ GCRef jit_L; /* Current JIT code lua_State or NULL. */ MRef jit_base; /* Current JIT code L->base. */ MRef ctype_state; /* Pointer to C type state. */ GCRef gcroot[GCROOT_MAX]; /* GC roots. */ } global_State; #define mainthread(g) (&gcref(g->mainthref)->th) #define niltv(L) \ check_exp(tvisnil(&G(L)->nilnode.val), &G(L)->nilnode.val) #define niltvg(g) \ check_exp(tvisnil(&(g)->nilnode.val), &(g)->nilnode.val) /* Hook management. Hook event masks are defined in lua.h. */ #define HOOK_EVENTMASK 0x0f #define HOOK_ACTIVE 0x10 #define HOOK_ACTIVE_SHIFT 4 #define HOOK_VMEVENT 0x20 #define HOOK_GC 0x40 #define hook_active(g) ((g)->hookmask & HOOK_ACTIVE) #define hook_enter(g) ((g)->hookmask |= HOOK_ACTIVE) #define hook_entergc(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_GC)) #define hook_vmevent(g) ((g)->hookmask |= (HOOK_ACTIVE|HOOK_VMEVENT)) #define hook_leave(g) ((g)->hookmask &= ~HOOK_ACTIVE) #define hook_save(g) ((g)->hookmask & ~HOOK_EVENTMASK) #define hook_restore(g, h) \ ((g)->hookmask = ((g)->hookmask & HOOK_EVENTMASK) | (h)) /* Per-thread state object. */ struct lua_State { GCHeader; uint8_t dummy_ffid; /* Fake FF_C for curr_funcisL() on dummy frames. */ uint8_t status; /* Thread status. */ MRef glref; /* Link to global state. */ GCRef gclist; /* GC chain. */ TValue *base; /* Base of currently executing function. */ TValue *top; /* First free slot in the stack. */ MRef maxstack; /* Last free slot in the stack. */ MRef stack; /* Stack base. */ GCRef openupval; /* List of open upvalues in the stack. */ GCRef env; /* Thread environment (table of globals). */ void *cframe; /* End of C stack frame chain. */ MSize stacksize; /* True stack size (incl. LJ_STACK_EXTRA). */ }; #define G(L) (mref(L->glref, global_State)) #define registry(L) (&G(L)->registrytv) /* Macros to access the currently executing (Lua) function. */ #define curr_func(L) (&gcref((L->base-1)->fr.func)->fn) #define curr_funcisL(L) (isluafunc(curr_func(L))) #define curr_proto(L) (funcproto(curr_func(L))) #define curr_topL(L) (L->base + curr_proto(L)->framesize) #define curr_top(L) (curr_funcisL(L) ? curr_topL(L) : L->top) /* -- GC object definition and conversions -------------------------------- */ /* GC header for generic access to common fields of GC objects. */ typedef struct GChead { GCHeader; uint8_t unused1; uint8_t unused2; GCRef env; GCRef gclist; GCRef metatable; } GChead; /* The env field SHOULD be at the same offset for all GC objects. */ LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCfuncL, env)); LJ_STATIC_ASSERT(offsetof(GChead, env) == offsetof(GCudata, env)); /* The metatable field MUST be at the same offset for all GC objects. */ LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCtab, metatable)); LJ_STATIC_ASSERT(offsetof(GChead, metatable) == offsetof(GCudata, metatable)); /* The gclist field MUST be at the same offset for all GC objects. */ LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(lua_State, gclist)); LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCproto, gclist)); LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCfuncL, gclist)); LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtab, gclist)); typedef union GCobj { GChead gch; GCstr str; GCupval uv; lua_State th; GCproto pt; GCfunc fn; GCcdata cd; GCtab tab; GCudata ud; } GCobj; /* Macros to convert a GCobj pointer into a specific value. */ #define gco2str(o) check_exp((o)->gch.gct == ~LJ_TSTR, &(o)->str) #define gco2uv(o) check_exp((o)->gch.gct == ~LJ_TUPVAL, &(o)->uv) #define gco2th(o) check_exp((o)->gch.gct == ~LJ_TTHREAD, &(o)->th) #define gco2pt(o) check_exp((o)->gch.gct == ~LJ_TPROTO, &(o)->pt) #define gco2func(o) check_exp((o)->gch.gct == ~LJ_TFUNC, &(o)->fn) #define gco2cd(o) check_exp((o)->gch.gct == ~LJ_TCDATA, &(o)->cd) #define gco2tab(o) check_exp((o)->gch.gct == ~LJ_TTAB, &(o)->tab) #define gco2ud(o) check_exp((o)->gch.gct == ~LJ_TUDATA, &(o)->ud) /* Macro to convert any collectable object into a GCobj pointer. */ #define obj2gco(v) ((GCobj *)(v)) /* -- TValue getters/setters ---------------------------------------------- */ #ifdef LUA_USE_ASSERT #include "lj_gc.h" #endif /* Macros to test types. */ #define itype(o) ((o)->it) #define tvisnil(o) (itype(o) == LJ_TNIL) #define tvisfalse(o) (itype(o) == LJ_TFALSE) #define tvistrue(o) (itype(o) == LJ_TTRUE) #define tvisbool(o) (tvisfalse(o) || tvistrue(o)) #if LJ_64 #define tvislightud(o) (((int32_t)itype(o) >> 15) == -2) #else #define tvislightud(o) (itype(o) == LJ_TLIGHTUD) #endif #define tvisstr(o) (itype(o) == LJ_TSTR) #define tvisfunc(o) (itype(o) == LJ_TFUNC) #define tvisthread(o) (itype(o) == LJ_TTHREAD) #define tvisproto(o) (itype(o) == LJ_TPROTO) #define tviscdata(o) (itype(o) == LJ_TCDATA) #define tvistab(o) (itype(o) == LJ_TTAB) #define tvisudata(o) (itype(o) == LJ_TUDATA) #define tvisnumber(o) (itype(o) <= LJ_TISNUM) #define tvisint(o) (LJ_DUALNUM && itype(o) == LJ_TISNUM) #define tvisnum(o) (itype(o) < LJ_TISNUM) #define tvistruecond(o) (itype(o) < LJ_TISTRUECOND) #define tvispri(o) (itype(o) >= LJ_TISPRI) #define tvistabud(o) (itype(o) <= LJ_TISTABUD) /* && !tvisnum() */ #define tvisgcv(o) ((itype(o) - LJ_TISGCV) > (LJ_TNUMX - LJ_TISGCV)) /* Special macros to test numbers for NaN, +0, -0, +1 and raw equality. */ #define tvisnan(o) ((o)->n != (o)->n) #if LJ_64 #define tviszero(o) (((o)->u64 << 1) == 0) #else #define tviszero(o) (((o)->u32.lo | ((o)->u32.hi << 1)) == 0) #endif #define tvispzero(o) ((o)->u64 == 0) #define tvismzero(o) ((o)->u64 == U64x(80000000,00000000)) #define tvispone(o) ((o)->u64 == U64x(3ff00000,00000000)) #define rawnumequal(o1, o2) ((o1)->u64 == (o2)->u64) /* Macros to convert type ids. */ #if LJ_64 #define itypemap(o) \ (tvisnumber(o) ? ~LJ_TNUMX : tvislightud(o) ? ~LJ_TLIGHTUD : ~itype(o)) #else #define itypemap(o) (tvisnumber(o) ? ~LJ_TNUMX : ~itype(o)) #endif /* Macros to get tagged values. */ #define gcval(o) (gcref((o)->gcr)) #define boolV(o) check_exp(tvisbool(o), (LJ_TFALSE - (o)->it)) #if LJ_64 #define lightudV(o) \ check_exp(tvislightud(o), (void *)((o)->u64 & U64x(00007fff,ffffffff))) #else #define lightudV(o) check_exp(tvislightud(o), gcrefp((o)->gcr, void)) #endif #define gcV(o) check_exp(tvisgcv(o), gcval(o)) #define strV(o) check_exp(tvisstr(o), &gcval(o)->str) #define funcV(o) check_exp(tvisfunc(o), &gcval(o)->fn) #define threadV(o) check_exp(tvisthread(o), &gcval(o)->th) #define protoV(o) check_exp(tvisproto(o), &gcval(o)->pt) #define cdataV(o) check_exp(tviscdata(o), &gcval(o)->cd) #define tabV(o) check_exp(tvistab(o), &gcval(o)->tab) #define udataV(o) check_exp(tvisudata(o), &gcval(o)->ud) #define numV(o) check_exp(tvisnum(o), (o)->n) #define intV(o) check_exp(tvisint(o), (int32_t)(o)->i) /* Macros to set tagged values. */ #define setitype(o, i) ((o)->it = (i)) #define setnilV(o) ((o)->it = LJ_TNIL) #define setboolV(o, x) ((o)->it = LJ_TFALSE-(uint32_t)(x)) static LJ_AINLINE void setlightudV(TValue *o, void *p) { #if LJ_64 o->u64 = (uint64_t)p | (((uint64_t)0xffff) << 48); #else setgcrefp(o->gcr, p); setitype(o, LJ_TLIGHTUD); #endif } #if LJ_64 #define checklightudptr(L, p) \ (((uint64_t)(p) >> 47) ? (lj_err_msg(L, LJ_ERR_BADLU), NULL) : (p)) #define setcont(o, f) \ ((o)->u64 = (uint64_t)(void *)(f) - (uint64_t)lj_vm_asm_begin) #else #define checklightudptr(L, p) (p) #define setcont(o, f) setlightudV((o), (void *)(f)) #endif #define tvchecklive(L, o) \ UNUSED(L), lua_assert(!tvisgcv(o) || \ ((~itype(o) == gcval(o)->gch.gct) && !isdead(G(L), gcval(o)))) static LJ_AINLINE void setgcV(lua_State *L, TValue *o, GCobj *v, uint32_t itype) { setgcref(o->gcr, v); setitype(o, itype); tvchecklive(L, o); } #define define_setV(name, type, tag) \ static LJ_AINLINE void name(lua_State *L, TValue *o, type *v) \ { \ setgcV(L, o, obj2gco(v), tag); \ } define_setV(setstrV, GCstr, LJ_TSTR) define_setV(setthreadV, lua_State, LJ_TTHREAD) define_setV(setprotoV, GCproto, LJ_TPROTO) define_setV(setfuncV, GCfunc, LJ_TFUNC) define_setV(setcdataV, GCcdata, LJ_TCDATA) define_setV(settabV, GCtab, LJ_TTAB) define_setV(setudataV, GCudata, LJ_TUDATA) #define setnumV(o, x) ((o)->n = (x)) #define setnanV(o) ((o)->u64 = U64x(fff80000,00000000)) #define setpinfV(o) ((o)->u64 = U64x(7ff00000,00000000)) #define setminfV(o) ((o)->u64 = U64x(fff00000,00000000)) static LJ_AINLINE void setintV(TValue *o, int32_t i) { #if LJ_DUALNUM o->i = (uint32_t)i; setitype(o, LJ_TISNUM); #else o->n = (lua_Number)i; #endif } static LJ_AINLINE void setint64V(TValue *o, int64_t i) { if (LJ_DUALNUM && LJ_LIKELY(i == (int64_t)(int32_t)i)) setintV(o, (int32_t)i); else setnumV(o, (lua_Number)i); } #if LJ_64 #define setintptrV(o, i) setint64V((o), (i)) #else #define setintptrV(o, i) setintV((o), (i)) #endif /* Copy tagged values. */ static LJ_AINLINE void copyTV(lua_State *L, TValue *o1, const TValue *o2) { *o1 = *o2; tvchecklive(L, o1); } /* -- Number to integer conversion ---------------------------------------- */ #if LJ_SOFTFP LJ_ASMF int32_t lj_vm_tobit(double x); #endif static LJ_AINLINE int32_t lj_num2bit(lua_Number n) { #if LJ_SOFTFP return lj_vm_tobit(n); #else TValue o; o.n = n + 6755399441055744.0; /* 2^52 + 2^51 */ return (int32_t)o.u32.lo; #endif } #if LJ_TARGET_X86 && !defined(__SSE2__) #define lj_num2int(n) lj_num2bit((n)) #else #define lj_num2int(n) ((int32_t)(n)) #endif static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) { #ifdef _MSC_VER if (n >= 9223372036854775808.0) /* They think it's a feature. */ return (uint64_t)(int64_t)(n - 18446744073709551616.0); else #endif return (uint64_t)n; } static LJ_AINLINE int32_t numberVint(cTValue *o) { if (LJ_LIKELY(tvisint(o))) return intV(o); else return lj_num2int(numV(o)); } static LJ_AINLINE lua_Number numberVnum(cTValue *o) { if (LJ_UNLIKELY(tvisint(o))) return (lua_Number)intV(o); else return numV(o); } /* -- Miscellaneous object handling --------------------------------------- */ /* Names and maps for internal and external object tags. */ LJ_DATA const char *const lj_obj_typename[1+LUA_TCDATA+1]; LJ_DATA const char *const lj_obj_itypename[~LJ_TNUMX+1]; #define lj_typename(o) (lj_obj_itypename[itypemap(o)]) /* Compare two objects without calling metamethods. */ LJ_FUNC int lj_obj_equal(cTValue *o1, cTValue *o2); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_opt_dce.c ================================================ /* ** DCE: Dead Code Elimination. Pre-LOOP only -- ASM already performs DCE. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_opt_dce_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_ir.h" #include "lj_jit.h" #include "lj_iropt.h" /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) /* Scan through all snapshots and mark all referenced instructions. */ static void dce_marksnap(jit_State *J) { SnapNo i, nsnap = J->cur.nsnap; for (i = 0; i < nsnap; i++) { SnapShot *snap = &J->cur.snap[i]; SnapEntry *map = &J->cur.snapmap[snap->mapofs]; MSize n, nent = snap->nent; for (n = 0; n < nent; n++) { IRRef ref = snap_ref(map[n]); if (ref >= REF_FIRST) irt_setmark(IR(ref)->t); } } } /* Backwards propagate marks. Replace unused instructions with NOPs. */ static void dce_propagate(jit_State *J) { IRRef1 *pchain[IR__MAX]; IRRef ins; uint32_t i; for (i = 0; i < IR__MAX; i++) pchain[i] = &J->chain[i]; for (ins = J->cur.nins-1; ins >= REF_FIRST; ins--) { IRIns *ir = IR(ins); if (irt_ismarked(ir->t)) { irt_clearmark(ir->t); pchain[ir->o] = &ir->prev; } else if (!ir_sideeff(ir)) { *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ ir->t.irt = IRT_NIL; ir->o = IR_NOP; /* Replace instruction with NOP. */ ir->op1 = ir->op2 = 0; ir->prev = 0; continue; } if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); } } /* Dead Code Elimination. ** ** First backpropagate marks for all used instructions. Then replace ** the unused ones with a NOP. Note that compressing the IR to eliminate ** the NOPs does not pay off. */ void lj_opt_dce(jit_State *J) { if ((J->flags & JIT_F_OPT_DCE)) { dce_marksnap(J); dce_propagate(J); } } #undef IR #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_opt_fold.c ================================================ /* ** FOLD: Constant Folding, Algebraic Simplifications and Reassociation. ** ABCelim: Array Bounds Check Elimination. ** CSE: Common-Subexpression Elimination. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_opt_fold_c #define LUA_CORE #include #include "lj_obj.h" #if LJ_HASJIT #include "lj_str.h" #include "lj_tab.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_iropt.h" #include "lj_trace.h" #if LJ_HASFFI #include "lj_ctype.h" #endif #include "lj_carith.h" #include "lj_vm.h" #include "lj_strscan.h" /* Here's a short description how the FOLD engine processes instructions: ** ** The FOLD engine receives a single instruction stored in fins (J->fold.ins). ** The instruction and its operands are used to select matching fold rules. ** These are applied iteratively until a fixed point is reached. ** ** The 8 bit opcode of the instruction itself plus the opcodes of the ** two instructions referenced by its operands form a 24 bit key ** 'ins left right' (unused operands -> 0, literals -> lowest 8 bits). ** ** This key is used for partial matching against the fold rules. The ** left/right operand fields of the key are successively masked with ** the 'any' wildcard, from most specific to least specific: ** ** ins left right ** ins any right ** ins left any ** ins any any ** ** The masked key is used to lookup a matching fold rule in a semi-perfect ** hash table. If a matching rule is found, the related fold function is run. ** Multiple rules can share the same fold function. A fold rule may return ** one of several special values: ** ** - NEXTFOLD means no folding was applied, because an additional test ** inside the fold function failed. Matching continues against less ** specific fold rules. Finally the instruction is passed on to CSE. ** ** - RETRYFOLD means the instruction was modified in-place. Folding is ** retried as if this instruction had just been received. ** ** All other return values are terminal actions -- no further folding is ** applied: ** ** - INTFOLD(i) returns a reference to the integer constant i. ** ** - LEFTFOLD and RIGHTFOLD return the left/right operand reference ** without emitting an instruction. ** ** - CSEFOLD and EMITFOLD pass the instruction directly to CSE or emit ** it without passing through any further optimizations. ** ** - FAILFOLD, DROPFOLD and CONDFOLD only apply to instructions which have ** no result (e.g. guarded assertions): FAILFOLD means the guard would ** always fail, i.e. the current trace is pointless. DROPFOLD means ** the guard is always true and has been eliminated. CONDFOLD is a ** shortcut for FAILFOLD + cond (i.e. drop if true, otherwise fail). ** ** - Any other return value is interpreted as an IRRef or TRef. This ** can be a reference to an existing or a newly created instruction. ** Only the least-significant 16 bits (IRRef1) are used to form a TRef ** which is finally returned to the caller. ** ** The FOLD engine receives instructions both from the trace recorder and ** substituted instructions from LOOP unrolling. This means all types ** of instructions may end up here, even though the recorder bypasses ** FOLD in some cases. Thus all loads, stores and allocations must have ** an any/any rule to avoid being passed on to CSE. ** ** Carefully read the following requirements before adding or modifying ** any fold rules: ** ** Requirement #1: All fold rules must preserve their destination type. ** ** Consistently use INTFOLD() (KINT result) or lj_ir_knum() (KNUM result). ** Never use lj_ir_knumint() which can have either a KINT or KNUM result. ** ** Requirement #2: Fold rules should not create *new* instructions which ** reference operands *across* PHIs. ** ** E.g. a RETRYFOLD with 'fins->op1 = fleft->op1' is invalid if the ** left operand is a PHI. Then fleft->op1 would point across the PHI ** frontier to an invariant instruction. Adding a PHI for this instruction ** would be counterproductive. The solution is to add a barrier which ** prevents folding across PHIs, i.e. 'PHIBARRIER(fleft)' in this case. ** The only exception is for recurrences with high latencies like ** repeated int->num->int conversions. ** ** One could relax this condition a bit if the referenced instruction is ** a PHI, too. But this often leads to worse code due to excessive ** register shuffling. ** ** Note: returning *existing* instructions (e.g. LEFTFOLD) is ok, though. ** Even returning fleft->op1 would be ok, because a new PHI will added, ** if needed. But again, this leads to excessive register shuffling and ** should be avoided. ** ** Requirement #3: The set of all fold rules must be monotonic to guarantee ** termination. ** ** The goal is optimization, so one primarily wants to add strength-reducing ** rules. This means eliminating an instruction or replacing an instruction ** with one or more simpler instructions. Don't add fold rules which point ** into the other direction. ** ** Some rules (like commutativity) do not directly reduce the strength of ** an instruction, but enable other fold rules (e.g. by moving constants ** to the right operand). These rules must be made unidirectional to avoid ** cycles. ** ** Rule of thumb: the trace recorder expands the IR and FOLD shrinks it. */ /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) #define fins (&J->fold.ins) #define fleft (&J->fold.left) #define fright (&J->fold.right) #define knumleft (ir_knum(fleft)->n) #define knumright (ir_knum(fright)->n) /* Pass IR on to next optimization in chain (FOLD). */ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) /* Fold function type. Fastcall on x86 significantly reduces their size. */ typedef IRRef (LJ_FASTCALL *FoldFunc)(jit_State *J); /* Macros for the fold specs, so buildvm can recognize them. */ #define LJFOLD(x) #define LJFOLDX(x) #define LJFOLDF(name) static TRef LJ_FASTCALL fold_##name(jit_State *J) /* Note: They must be at the start of a line or buildvm ignores them! */ /* Barrier to prevent using operands across PHIs. */ #define PHIBARRIER(ir) if (irt_isphi((ir)->t)) return NEXTFOLD /* Barrier to prevent folding across a GC step. ** GC steps can only happen at the head of a trace and at LOOP. ** And the GC is only driven forward if there is at least one allocation. */ #define gcstep_barrier(J, ref) \ ((ref) < J->chain[IR_LOOP] && \ (J->chain[IR_SNEW] || J->chain[IR_XSNEW] || \ J->chain[IR_TNEW] || J->chain[IR_TDUP] || \ J->chain[IR_CNEW] || J->chain[IR_CNEWI] || J->chain[IR_TOSTR])) /* -- Constant folding for FP numbers ------------------------------------- */ LJFOLD(ADD KNUM KNUM) LJFOLD(SUB KNUM KNUM) LJFOLD(MUL KNUM KNUM) LJFOLD(DIV KNUM KNUM) LJFOLD(NEG KNUM KNUM) LJFOLD(ABS KNUM KNUM) LJFOLD(ATAN2 KNUM KNUM) LJFOLD(LDEXP KNUM KNUM) LJFOLD(MIN KNUM KNUM) LJFOLD(MAX KNUM KNUM) LJFOLDF(kfold_numarith) { lua_Number a = knumleft; lua_Number b = knumright; lua_Number y = lj_vm_foldarith(a, b, fins->o - IR_ADD); return lj_ir_knum(J, y); } LJFOLD(LDEXP KNUM KINT) LJFOLDF(kfold_ldexp) { #if LJ_TARGET_X86ORX64 UNUSED(J); return NEXTFOLD; #else return lj_ir_knum(J, ldexp(knumleft, fright->i)); #endif } LJFOLD(FPMATH KNUM any) LJFOLDF(kfold_fpmath) { lua_Number a = knumleft; lua_Number y = lj_vm_foldfpm(a, fins->op2); return lj_ir_knum(J, y); } LJFOLD(POW KNUM KINT) LJFOLDF(kfold_numpow) { lua_Number a = knumleft; lua_Number b = (lua_Number)fright->i; lua_Number y = lj_vm_foldarith(a, b, IR_POW - IR_ADD); return lj_ir_knum(J, y); } /* Must not use kfold_kref for numbers (could be NaN). */ LJFOLD(EQ KNUM KNUM) LJFOLD(NE KNUM KNUM) LJFOLD(LT KNUM KNUM) LJFOLD(GE KNUM KNUM) LJFOLD(LE KNUM KNUM) LJFOLD(GT KNUM KNUM) LJFOLD(ULT KNUM KNUM) LJFOLD(UGE KNUM KNUM) LJFOLD(ULE KNUM KNUM) LJFOLD(UGT KNUM KNUM) LJFOLDF(kfold_numcomp) { return CONDFOLD(lj_ir_numcmp(knumleft, knumright, (IROp)fins->o)); } /* -- Constant folding for 32 bit integers -------------------------------- */ static int32_t kfold_intop(int32_t k1, int32_t k2, IROp op) { switch (op) { case IR_ADD: k1 += k2; break; case IR_SUB: k1 -= k2; break; case IR_MUL: k1 *= k2; break; case IR_MOD: k1 = lj_vm_modi(k1, k2); break; case IR_NEG: k1 = -k1; break; case IR_BAND: k1 &= k2; break; case IR_BOR: k1 |= k2; break; case IR_BXOR: k1 ^= k2; break; case IR_BSHL: k1 <<= (k2 & 31); break; case IR_BSHR: k1 = (int32_t)((uint32_t)k1 >> (k2 & 31)); break; case IR_BSAR: k1 >>= (k2 & 31); break; case IR_BROL: k1 = (int32_t)lj_rol((uint32_t)k1, (k2 & 31)); break; case IR_BROR: k1 = (int32_t)lj_ror((uint32_t)k1, (k2 & 31)); break; case IR_MIN: k1 = k1 < k2 ? k1 : k2; break; case IR_MAX: k1 = k1 > k2 ? k1 : k2; break; default: lua_assert(0); break; } return k1; } LJFOLD(ADD KINT KINT) LJFOLD(SUB KINT KINT) LJFOLD(MUL KINT KINT) LJFOLD(MOD KINT KINT) LJFOLD(NEG KINT KINT) LJFOLD(BAND KINT KINT) LJFOLD(BOR KINT KINT) LJFOLD(BXOR KINT KINT) LJFOLD(BSHL KINT KINT) LJFOLD(BSHR KINT KINT) LJFOLD(BSAR KINT KINT) LJFOLD(BROL KINT KINT) LJFOLD(BROR KINT KINT) LJFOLD(MIN KINT KINT) LJFOLD(MAX KINT KINT) LJFOLDF(kfold_intarith) { return INTFOLD(kfold_intop(fleft->i, fright->i, (IROp)fins->o)); } LJFOLD(ADDOV KINT KINT) LJFOLD(SUBOV KINT KINT) LJFOLD(MULOV KINT KINT) LJFOLDF(kfold_intovarith) { lua_Number n = lj_vm_foldarith((lua_Number)fleft->i, (lua_Number)fright->i, fins->o - IR_ADDOV); int32_t k = lj_num2int(n); if (n != (lua_Number)k) return FAILFOLD; return INTFOLD(k); } LJFOLD(BNOT KINT) LJFOLDF(kfold_bnot) { return INTFOLD(~fleft->i); } LJFOLD(BSWAP KINT) LJFOLDF(kfold_bswap) { return INTFOLD((int32_t)lj_bswap((uint32_t)fleft->i)); } LJFOLD(LT KINT KINT) LJFOLD(GE KINT KINT) LJFOLD(LE KINT KINT) LJFOLD(GT KINT KINT) LJFOLD(ULT KINT KINT) LJFOLD(UGE KINT KINT) LJFOLD(ULE KINT KINT) LJFOLD(UGT KINT KINT) LJFOLD(ABC KINT KINT) LJFOLDF(kfold_intcomp) { int32_t a = fleft->i, b = fright->i; switch ((IROp)fins->o) { case IR_LT: return CONDFOLD(a < b); case IR_GE: return CONDFOLD(a >= b); case IR_LE: return CONDFOLD(a <= b); case IR_GT: return CONDFOLD(a > b); case IR_ULT: return CONDFOLD((uint32_t)a < (uint32_t)b); case IR_UGE: return CONDFOLD((uint32_t)a >= (uint32_t)b); case IR_ULE: return CONDFOLD((uint32_t)a <= (uint32_t)b); case IR_ABC: case IR_UGT: return CONDFOLD((uint32_t)a > (uint32_t)b); default: lua_assert(0); return FAILFOLD; } } LJFOLD(UGE any KINT) LJFOLDF(kfold_intcomp0) { if (fright->i == 0) return DROPFOLD; return NEXTFOLD; } /* -- Constant folding for 64 bit integers -------------------------------- */ static uint64_t kfold_int64arith(uint64_t k1, uint64_t k2, IROp op) { switch (op) { #if LJ_64 || LJ_HASFFI case IR_ADD: k1 += k2; break; case IR_SUB: k1 -= k2; break; #endif #if LJ_HASFFI case IR_MUL: k1 *= k2; break; case IR_BAND: k1 &= k2; break; case IR_BOR: k1 |= k2; break; case IR_BXOR: k1 ^= k2; break; #endif default: UNUSED(k2); lua_assert(0); break; } return k1; } LJFOLD(ADD KINT64 KINT64) LJFOLD(SUB KINT64 KINT64) LJFOLD(MUL KINT64 KINT64) LJFOLD(BAND KINT64 KINT64) LJFOLD(BOR KINT64 KINT64) LJFOLD(BXOR KINT64 KINT64) LJFOLDF(kfold_int64arith) { return INT64FOLD(kfold_int64arith(ir_k64(fleft)->u64, ir_k64(fright)->u64, (IROp)fins->o)); } LJFOLD(DIV KINT64 KINT64) LJFOLD(MOD KINT64 KINT64) LJFOLD(POW KINT64 KINT64) LJFOLDF(kfold_int64arith2) { #if LJ_HASFFI uint64_t k1 = ir_k64(fleft)->u64, k2 = ir_k64(fright)->u64; if (irt_isi64(fins->t)) { k1 = fins->o == IR_DIV ? lj_carith_divi64((int64_t)k1, (int64_t)k2) : fins->o == IR_MOD ? lj_carith_modi64((int64_t)k1, (int64_t)k2) : lj_carith_powi64((int64_t)k1, (int64_t)k2); } else { k1 = fins->o == IR_DIV ? lj_carith_divu64(k1, k2) : fins->o == IR_MOD ? lj_carith_modu64(k1, k2) : lj_carith_powu64(k1, k2); } return INT64FOLD(k1); #else UNUSED(J); lua_assert(0); return FAILFOLD; #endif } LJFOLD(BSHL KINT64 KINT) LJFOLD(BSHR KINT64 KINT) LJFOLD(BSAR KINT64 KINT) LJFOLD(BROL KINT64 KINT) LJFOLD(BROR KINT64 KINT) LJFOLDF(kfold_int64shift) { #if LJ_HASFFI || LJ_64 uint64_t k = ir_k64(fleft)->u64; int32_t sh = (fright->i & 63); switch ((IROp)fins->o) { case IR_BSHL: k <<= sh; break; #if LJ_HASFFI case IR_BSHR: k >>= sh; break; case IR_BSAR: k = (uint64_t)((int64_t)k >> sh); break; case IR_BROL: k = lj_rol(k, sh); break; case IR_BROR: k = lj_ror(k, sh); break; #endif default: lua_assert(0); break; } return INT64FOLD(k); #else UNUSED(J); lua_assert(0); return FAILFOLD; #endif } LJFOLD(BNOT KINT64) LJFOLDF(kfold_bnot64) { #if LJ_HASFFI return INT64FOLD(~ir_k64(fleft)->u64); #else UNUSED(J); lua_assert(0); return FAILFOLD; #endif } LJFOLD(BSWAP KINT64) LJFOLDF(kfold_bswap64) { #if LJ_HASFFI return INT64FOLD(lj_bswap64(ir_k64(fleft)->u64)); #else UNUSED(J); lua_assert(0); return FAILFOLD; #endif } LJFOLD(LT KINT64 KINT64) LJFOLD(GE KINT64 KINT64) LJFOLD(LE KINT64 KINT64) LJFOLD(GT KINT64 KINT64) LJFOLD(ULT KINT64 KINT64) LJFOLD(UGE KINT64 KINT64) LJFOLD(ULE KINT64 KINT64) LJFOLD(UGT KINT64 KINT64) LJFOLDF(kfold_int64comp) { #if LJ_HASFFI uint64_t a = ir_k64(fleft)->u64, b = ir_k64(fright)->u64; switch ((IROp)fins->o) { case IR_LT: return CONDFOLD(a < b); case IR_GE: return CONDFOLD(a >= b); case IR_LE: return CONDFOLD(a <= b); case IR_GT: return CONDFOLD(a > b); case IR_ULT: return CONDFOLD((uint64_t)a < (uint64_t)b); case IR_UGE: return CONDFOLD((uint64_t)a >= (uint64_t)b); case IR_ULE: return CONDFOLD((uint64_t)a <= (uint64_t)b); case IR_UGT: return CONDFOLD((uint64_t)a > (uint64_t)b); default: lua_assert(0); return FAILFOLD; } #else UNUSED(J); lua_assert(0); return FAILFOLD; #endif } LJFOLD(UGE any KINT64) LJFOLDF(kfold_int64comp0) { #if LJ_HASFFI if (ir_k64(fright)->u64 == 0) return DROPFOLD; return NEXTFOLD; #else UNUSED(J); lua_assert(0); return FAILFOLD; #endif } /* -- Constant folding for strings ---------------------------------------- */ LJFOLD(SNEW KKPTR KINT) LJFOLDF(kfold_snew_kptr) { GCstr *s = lj_str_new(J->L, (const char *)ir_kptr(fleft), (size_t)fright->i); return lj_ir_kstr(J, s); } LJFOLD(SNEW any KINT) LJFOLDF(kfold_snew_empty) { if (fright->i == 0) return lj_ir_kstr(J, &J2G(J)->strempty); return NEXTFOLD; } LJFOLD(STRREF KGC KINT) LJFOLDF(kfold_strref) { GCstr *str = ir_kstr(fleft); lua_assert((MSize)fright->i <= str->len); return lj_ir_kkptr(J, (char *)strdata(str) + fright->i); } LJFOLD(STRREF SNEW any) LJFOLDF(kfold_strref_snew) { PHIBARRIER(fleft); if (irref_isk(fins->op2) && fright->i == 0) { return fleft->op1; /* strref(snew(ptr, len), 0) ==> ptr */ } else { /* Reassociate: strref(snew(strref(str, a), len), b) ==> strref(str, a+b) */ IRIns *ir = IR(fleft->op1); IRRef1 str = ir->op1; /* IRIns * is not valid across emitir. */ lua_assert(ir->o == IR_STRREF); PHIBARRIER(ir); fins->op2 = emitir(IRTI(IR_ADD), ir->op2, fins->op2); /* Clobbers fins! */ fins->op1 = str; fins->ot = IRT(IR_STRREF, IRT_P32); return RETRYFOLD; } return NEXTFOLD; } LJFOLD(CALLN CARG IRCALL_lj_str_cmp) LJFOLDF(kfold_strcmp) { if (irref_isk(fleft->op1) && irref_isk(fleft->op2)) { GCstr *a = ir_kstr(IR(fleft->op1)); GCstr *b = ir_kstr(IR(fleft->op2)); return INTFOLD(lj_str_cmp(a, b)); } return NEXTFOLD; } /* -- Constant folding of pointer arithmetic ------------------------------ */ LJFOLD(ADD KGC KINT) LJFOLD(ADD KGC KINT64) LJFOLDF(kfold_add_kgc) { GCobj *o = ir_kgc(fleft); #if LJ_64 ptrdiff_t ofs = (ptrdiff_t)ir_kint64(fright)->u64; #else ptrdiff_t ofs = fright->i; #endif #if LJ_HASFFI if (irt_iscdata(fleft->t)) { CType *ct = ctype_raw(ctype_ctsG(J2G(J)), gco2cd(o)->ctypeid); if (ctype_isnum(ct->info) || ctype_isenum(ct->info) || ctype_isptr(ct->info) || ctype_isfunc(ct->info) || ctype_iscomplex(ct->info) || ctype_isvector(ct->info)) return lj_ir_kkptr(J, (char *)o + ofs); } #endif return lj_ir_kptr(J, (char *)o + ofs); } LJFOLD(ADD KPTR KINT) LJFOLD(ADD KPTR KINT64) LJFOLD(ADD KKPTR KINT) LJFOLD(ADD KKPTR KINT64) LJFOLDF(kfold_add_kptr) { void *p = ir_kptr(fleft); #if LJ_64 ptrdiff_t ofs = (ptrdiff_t)ir_kint64(fright)->u64; #else ptrdiff_t ofs = fright->i; #endif return lj_ir_kptr_(J, fleft->o, (char *)p + ofs); } LJFOLD(ADD any KGC) LJFOLD(ADD any KPTR) LJFOLD(ADD any KKPTR) LJFOLDF(kfold_add_kright) { if (fleft->o == IR_KINT || fleft->o == IR_KINT64) { IRRef1 tmp = fins->op1; fins->op1 = fins->op2; fins->op2 = tmp; return RETRYFOLD; } return NEXTFOLD; } /* -- Constant folding of conversions ------------------------------------- */ LJFOLD(TOBIT KNUM KNUM) LJFOLDF(kfold_tobit) { return INTFOLD(lj_num2bit(knumleft)); } LJFOLD(CONV KINT IRCONV_NUM_INT) LJFOLDF(kfold_conv_kint_num) { return lj_ir_knum(J, (lua_Number)fleft->i); } LJFOLD(CONV KINT IRCONV_NUM_U32) LJFOLDF(kfold_conv_kintu32_num) { return lj_ir_knum(J, (lua_Number)(uint32_t)fleft->i); } LJFOLD(CONV KINT IRCONV_INT_I8) LJFOLD(CONV KINT IRCONV_INT_U8) LJFOLD(CONV KINT IRCONV_INT_I16) LJFOLD(CONV KINT IRCONV_INT_U16) LJFOLDF(kfold_conv_kint_ext) { int32_t k = fleft->i; if ((fins->op2 & IRCONV_SRCMASK) == IRT_I8) k = (int8_t)k; else if ((fins->op2 & IRCONV_SRCMASK) == IRT_U8) k = (uint8_t)k; else if ((fins->op2 & IRCONV_SRCMASK) == IRT_I16) k = (int16_t)k; else k = (uint16_t)k; return INTFOLD(k); } LJFOLD(CONV KINT IRCONV_I64_INT) LJFOLD(CONV KINT IRCONV_U64_INT) LJFOLD(CONV KINT IRCONV_I64_U32) LJFOLD(CONV KINT IRCONV_U64_U32) LJFOLDF(kfold_conv_kint_i64) { if ((fins->op2 & IRCONV_SEXT)) return INT64FOLD((uint64_t)(int64_t)fleft->i); else return INT64FOLD((uint64_t)(int64_t)(uint32_t)fleft->i); } LJFOLD(CONV KINT64 IRCONV_NUM_I64) LJFOLDF(kfold_conv_kint64_num_i64) { return lj_ir_knum(J, (lua_Number)(int64_t)ir_kint64(fleft)->u64); } LJFOLD(CONV KINT64 IRCONV_NUM_U64) LJFOLDF(kfold_conv_kint64_num_u64) { return lj_ir_knum(J, (lua_Number)ir_kint64(fleft)->u64); } LJFOLD(CONV KINT64 IRCONV_INT_I64) LJFOLD(CONV KINT64 IRCONV_U32_I64) LJFOLDF(kfold_conv_kint64_int_i64) { return INTFOLD((int32_t)ir_kint64(fleft)->u64); } LJFOLD(CONV KNUM IRCONV_INT_NUM) LJFOLDF(kfold_conv_knum_int_num) { lua_Number n = knumleft; if (!(fins->op2 & IRCONV_TRUNC)) { int32_t k = lj_num2int(n); if (irt_isguard(fins->t) && n != (lua_Number)k) { /* We're about to create a guard which always fails, like CONV +1.5. ** Some pathological loops cause this during LICM, e.g.: ** local x,k,t = 0,1.5,{1,[1.5]=2} ** for i=1,200 do x = x+ t[k]; k = k == 1 and 1.5 or 1 end ** assert(x == 300) */ return FAILFOLD; } return INTFOLD(k); } else { return INTFOLD((int32_t)n); } } LJFOLD(CONV KNUM IRCONV_U32_NUM) LJFOLDF(kfold_conv_knum_u32_num) { lua_assert((fins->op2 & IRCONV_TRUNC)); #ifdef _MSC_VER { /* Workaround for MSVC bug. */ volatile uint32_t u = (uint32_t)knumleft; return INTFOLD((int32_t)u); } #else return INTFOLD((int32_t)(uint32_t)knumleft); #endif } LJFOLD(CONV KNUM IRCONV_I64_NUM) LJFOLDF(kfold_conv_knum_i64_num) { lua_assert((fins->op2 & IRCONV_TRUNC)); return INT64FOLD((uint64_t)(int64_t)knumleft); } LJFOLD(CONV KNUM IRCONV_U64_NUM) LJFOLDF(kfold_conv_knum_u64_num) { lua_assert((fins->op2 & IRCONV_TRUNC)); return INT64FOLD(lj_num2u64(knumleft)); } LJFOLD(TOSTR KNUM) LJFOLDF(kfold_tostr_knum) { return lj_ir_kstr(J, lj_str_fromnum(J->L, &knumleft)); } LJFOLD(TOSTR KINT) LJFOLDF(kfold_tostr_kint) { return lj_ir_kstr(J, lj_str_fromint(J->L, fleft->i)); } LJFOLD(STRTO KGC) LJFOLDF(kfold_strto) { TValue n; if (lj_strscan_num(ir_kstr(fleft), &n)) return lj_ir_knum(J, numV(&n)); return FAILFOLD; } /* -- Constant folding of equality checks --------------------------------- */ /* Don't constant-fold away FLOAD checks against KNULL. */ LJFOLD(EQ FLOAD KNULL) LJFOLD(NE FLOAD KNULL) LJFOLDX(lj_opt_cse) /* But fold all other KNULL compares, since only KNULL is equal to KNULL. */ LJFOLD(EQ any KNULL) LJFOLD(NE any KNULL) LJFOLD(EQ KNULL any) LJFOLD(NE KNULL any) LJFOLD(EQ KINT KINT) /* Constants are unique, so same refs <==> same value. */ LJFOLD(NE KINT KINT) LJFOLD(EQ KINT64 KINT64) LJFOLD(NE KINT64 KINT64) LJFOLD(EQ KGC KGC) LJFOLD(NE KGC KGC) LJFOLDF(kfold_kref) { return CONDFOLD((fins->op1 == fins->op2) ^ (fins->o == IR_NE)); } /* -- Algebraic shortcuts ------------------------------------------------- */ LJFOLD(FPMATH FPMATH IRFPM_FLOOR) LJFOLD(FPMATH FPMATH IRFPM_CEIL) LJFOLD(FPMATH FPMATH IRFPM_TRUNC) LJFOLDF(shortcut_round) { IRFPMathOp op = (IRFPMathOp)fleft->op2; if (op == IRFPM_FLOOR || op == IRFPM_CEIL || op == IRFPM_TRUNC) return LEFTFOLD; /* round(round_left(x)) = round_left(x) */ return NEXTFOLD; } LJFOLD(ABS ABS KNUM) LJFOLDF(shortcut_left) { return LEFTFOLD; /* f(g(x)) ==> g(x) */ } LJFOLD(ABS NEG KNUM) LJFOLDF(shortcut_dropleft) { PHIBARRIER(fleft); fins->op1 = fleft->op1; /* abs(neg(x)) ==> abs(x) */ return RETRYFOLD; } /* Note: no safe shortcuts with STRTO and TOSTR ("1e2" ==> +100 ==> "100"). */ LJFOLD(NEG NEG any) LJFOLD(BNOT BNOT) LJFOLD(BSWAP BSWAP) LJFOLDF(shortcut_leftleft) { PHIBARRIER(fleft); /* See above. Fold would be ok, but not beneficial. */ return fleft->op1; /* f(g(x)) ==> x */ } /* -- FP algebraic simplifications ---------------------------------------- */ /* FP arithmetic is tricky -- there's not much to simplify. ** Please note the following common pitfalls before sending "improvements": ** x+0 ==> x is INVALID for x=-0 ** 0-x ==> -x is INVALID for x=+0 ** x*0 ==> 0 is INVALID for x=-0, x=+-Inf or x=NaN */ LJFOLD(ADD NEG any) LJFOLDF(simplify_numadd_negx) { PHIBARRIER(fleft); fins->o = IR_SUB; /* (-a) + b ==> b - a */ fins->op1 = fins->op2; fins->op2 = fleft->op1; return RETRYFOLD; } LJFOLD(ADD any NEG) LJFOLDF(simplify_numadd_xneg) { PHIBARRIER(fright); fins->o = IR_SUB; /* a + (-b) ==> a - b */ fins->op2 = fright->op1; return RETRYFOLD; } LJFOLD(SUB any KNUM) LJFOLDF(simplify_numsub_k) { lua_Number n = knumright; if (n == 0.0) /* x - (+-0) ==> x */ return LEFTFOLD; return NEXTFOLD; } LJFOLD(SUB NEG KNUM) LJFOLDF(simplify_numsub_negk) { PHIBARRIER(fleft); fins->op2 = fleft->op1; /* (-x) - k ==> (-k) - x */ fins->op1 = (IRRef1)lj_ir_knum(J, -knumright); return RETRYFOLD; } LJFOLD(SUB any NEG) LJFOLDF(simplify_numsub_xneg) { PHIBARRIER(fright); fins->o = IR_ADD; /* a - (-b) ==> a + b */ fins->op2 = fright->op1; return RETRYFOLD; } LJFOLD(MUL any KNUM) LJFOLD(DIV any KNUM) LJFOLDF(simplify_nummuldiv_k) { lua_Number n = knumright; if (n == 1.0) { /* x o 1 ==> x */ return LEFTFOLD; } else if (n == -1.0) { /* x o -1 ==> -x */ fins->o = IR_NEG; fins->op2 = (IRRef1)lj_ir_knum_neg(J); return RETRYFOLD; } else if (fins->o == IR_MUL && n == 2.0) { /* x * 2 ==> x + x */ fins->o = IR_ADD; fins->op2 = fins->op1; return RETRYFOLD; } else if (fins->o == IR_DIV) { /* x / 2^k ==> x * 2^-k */ uint64_t u = ir_knum(fright)->u64; uint32_t ex = ((uint32_t)(u >> 52) & 0x7ff); if ((u & U64x(000fffff,ffffffff)) == 0 && ex - 1 < 0x7fd) { u = (u & ((uint64_t)1 << 63)) | ((uint64_t)(0x7fe - ex) << 52); fins->o = IR_MUL; /* Multiply by exact reciprocal. */ fins->op2 = lj_ir_knum_u64(J, u); return RETRYFOLD; } } return NEXTFOLD; } LJFOLD(MUL NEG KNUM) LJFOLD(DIV NEG KNUM) LJFOLDF(simplify_nummuldiv_negk) { PHIBARRIER(fleft); fins->op1 = fleft->op1; /* (-a) o k ==> a o (-k) */ fins->op2 = (IRRef1)lj_ir_knum(J, -knumright); return RETRYFOLD; } LJFOLD(MUL NEG NEG) LJFOLD(DIV NEG NEG) LJFOLDF(simplify_nummuldiv_negneg) { PHIBARRIER(fleft); PHIBARRIER(fright); fins->op1 = fleft->op1; /* (-a) o (-b) ==> a o b */ fins->op2 = fright->op1; return RETRYFOLD; } LJFOLD(POW any KINT) LJFOLDF(simplify_numpow_xk) { int32_t k = fright->i; TRef ref = fins->op1; if (k == 0) /* x ^ 0 ==> 1 */ return lj_ir_knum_one(J); /* Result must be a number, not an int. */ if (k == 1) /* x ^ 1 ==> x */ return LEFTFOLD; if ((uint32_t)(k+65536) > 2*65536u) /* Limit code explosion. */ return NEXTFOLD; if (k < 0) { /* x ^ (-k) ==> (1/x) ^ k. */ ref = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), ref); k = -k; } /* Unroll x^k for 1 <= k <= 65536. */ for (; (k & 1) == 0; k >>= 1) /* Handle leading zeros. */ ref = emitir(IRTN(IR_MUL), ref, ref); if ((k >>= 1) != 0) { /* Handle trailing bits. */ TRef tmp = emitir(IRTN(IR_MUL), ref, ref); for (; k != 1; k >>= 1) { if (k & 1) ref = emitir(IRTN(IR_MUL), ref, tmp); tmp = emitir(IRTN(IR_MUL), tmp, tmp); } ref = emitir(IRTN(IR_MUL), ref, tmp); } return ref; } LJFOLD(POW KNUM any) LJFOLDF(simplify_numpow_kx) { lua_Number n = knumleft; if (n == 2.0) { /* 2.0 ^ i ==> ldexp(1.0, tonum(i)) */ fins->o = IR_CONV; #if LJ_TARGET_X86ORX64 fins->op1 = fins->op2; fins->op2 = IRCONV_NUM_INT; fins->op2 = (IRRef1)lj_opt_fold(J); #endif fins->op1 = (IRRef1)lj_ir_knum_one(J); fins->o = IR_LDEXP; return RETRYFOLD; } return NEXTFOLD; } /* -- Simplify conversions ------------------------------------------------ */ LJFOLD(CONV CONV IRCONV_NUM_INT) /* _NUM */ LJFOLDF(shortcut_conv_num_int) { PHIBARRIER(fleft); /* Only safe with a guarded conversion to int. */ if ((fleft->op2 & IRCONV_SRCMASK) == IRT_NUM && irt_isguard(fleft->t)) return fleft->op1; /* f(g(x)) ==> x */ return NEXTFOLD; } LJFOLD(CONV CONV IRCONV_INT_NUM) /* _INT */ LJFOLD(CONV CONV IRCONV_U32_NUM) /* _U32*/ LJFOLDF(simplify_conv_int_num) { /* Fold even across PHI to avoid expensive num->int conversions in loop. */ if ((fleft->op2 & IRCONV_SRCMASK) == ((fins->op2 & IRCONV_DSTMASK) >> IRCONV_DSH)) return fleft->op1; return NEXTFOLD; } LJFOLD(CONV CONV IRCONV_I64_NUM) /* _INT or _U32 */ LJFOLD(CONV CONV IRCONV_U64_NUM) /* _INT or _U32 */ LJFOLDF(simplify_conv_i64_num) { PHIBARRIER(fleft); if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT) { /* Reduce to a sign-extension. */ fins->op1 = fleft->op1; fins->op2 = ((IRT_I64<<5)|IRT_INT|IRCONV_SEXT); return RETRYFOLD; } else if ((fleft->op2 & IRCONV_SRCMASK) == IRT_U32) { #if LJ_TARGET_X64 return fleft->op1; #else /* Reduce to a zero-extension. */ fins->op1 = fleft->op1; fins->op2 = (IRT_I64<<5)|IRT_U32; return RETRYFOLD; #endif } return NEXTFOLD; } LJFOLD(CONV CONV IRCONV_INT_I64) /* _INT or _U32 */ LJFOLD(CONV CONV IRCONV_INT_U64) /* _INT or _U32 */ LJFOLD(CONV CONV IRCONV_U32_I64) /* _INT or _U32 */ LJFOLD(CONV CONV IRCONV_U32_U64) /* _INT or _U32 */ LJFOLDF(simplify_conv_int_i64) { int src; PHIBARRIER(fleft); src = (fleft->op2 & IRCONV_SRCMASK); if (src == IRT_INT || src == IRT_U32) { if (src == ((fins->op2 & IRCONV_DSTMASK) >> IRCONV_DSH)) { return fleft->op1; } else { fins->op2 = ((fins->op2 & IRCONV_DSTMASK) | src); fins->op1 = fleft->op1; return RETRYFOLD; } } return NEXTFOLD; } LJFOLD(CONV CONV IRCONV_FLOAT_NUM) /* _FLOAT */ LJFOLDF(simplify_conv_flt_num) { PHIBARRIER(fleft); if ((fleft->op2 & IRCONV_SRCMASK) == IRT_FLOAT) return fleft->op1; return NEXTFOLD; } /* Shortcut TOBIT + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ LJFOLD(TOBIT CONV KNUM) LJFOLDF(simplify_tobit_conv) { if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT || (fleft->op2 & IRCONV_SRCMASK) == IRT_U32) { /* Fold even across PHI to avoid expensive num->int conversions in loop. */ lua_assert(irt_isnum(fleft->t)); return fleft->op1; } return NEXTFOLD; } /* Shortcut floor/ceil/round + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ LJFOLD(FPMATH CONV IRFPM_FLOOR) LJFOLD(FPMATH CONV IRFPM_CEIL) LJFOLD(FPMATH CONV IRFPM_TRUNC) LJFOLDF(simplify_floor_conv) { if ((fleft->op2 & IRCONV_SRCMASK) == IRT_INT || (fleft->op2 & IRCONV_SRCMASK) == IRT_U32) return LEFTFOLD; return NEXTFOLD; } /* Strength reduction of widening. */ LJFOLD(CONV any IRCONV_I64_INT) LJFOLD(CONV any IRCONV_U64_INT) LJFOLDF(simplify_conv_sext) { IRRef ref = fins->op1; int64_t ofs = 0; if (!(fins->op2 & IRCONV_SEXT)) return NEXTFOLD; PHIBARRIER(fleft); if (fleft->o == IR_XLOAD && (irt_isu8(fleft->t) || irt_isu16(fleft->t))) goto ok_reduce; if (fleft->o == IR_ADD && irref_isk(fleft->op2)) { ofs = (int64_t)IR(fleft->op2)->i; ref = fleft->op1; } /* Use scalar evolution analysis results to strength-reduce sign-extension. */ if (ref == J->scev.idx) { IRRef lo = J->scev.dir ? J->scev.start : J->scev.stop; lua_assert(irt_isint(J->scev.t)); if (lo && IR(lo)->i + ofs >= 0) { ok_reduce: #if LJ_TARGET_X64 /* Eliminate widening. All 32 bit ops do an implicit zero-extension. */ return LEFTFOLD; #else /* Reduce to a (cheaper) zero-extension. */ fins->op2 &= ~IRCONV_SEXT; return RETRYFOLD; #endif } } return NEXTFOLD; } /* Strength reduction of narrowing. */ LJFOLD(CONV ADD IRCONV_INT_I64) LJFOLD(CONV SUB IRCONV_INT_I64) LJFOLD(CONV MUL IRCONV_INT_I64) LJFOLD(CONV ADD IRCONV_INT_U64) LJFOLD(CONV SUB IRCONV_INT_U64) LJFOLD(CONV MUL IRCONV_INT_U64) LJFOLD(CONV ADD IRCONV_U32_I64) LJFOLD(CONV SUB IRCONV_U32_I64) LJFOLD(CONV MUL IRCONV_U32_I64) LJFOLD(CONV ADD IRCONV_U32_U64) LJFOLD(CONV SUB IRCONV_U32_U64) LJFOLD(CONV MUL IRCONV_U32_U64) LJFOLDF(simplify_conv_narrow) { IROp op = (IROp)fleft->o; IRType t = irt_type(fins->t); IRRef op1 = fleft->op1, op2 = fleft->op2, mode = fins->op2; PHIBARRIER(fleft); op1 = emitir(IRTI(IR_CONV), op1, mode); op2 = emitir(IRTI(IR_CONV), op2, mode); fins->ot = IRT(op, t); fins->op1 = op1; fins->op2 = op2; return RETRYFOLD; } /* Special CSE rule for CONV. */ LJFOLD(CONV any any) LJFOLDF(cse_conv) { if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { IRRef op1 = fins->op1, op2 = (fins->op2 & IRCONV_MODEMASK); uint8_t guard = irt_isguard(fins->t); IRRef ref = J->chain[IR_CONV]; while (ref > op1) { IRIns *ir = IR(ref); /* Commoning with stronger checks is ok. */ if (ir->op1 == op1 && (ir->op2 & IRCONV_MODEMASK) == op2 && irt_isguard(ir->t) >= guard) return ref; ref = ir->prev; } } return EMITFOLD; /* No fallthrough to regular CSE. */ } /* FP conversion narrowing. */ LJFOLD(TOBIT ADD KNUM) LJFOLD(TOBIT SUB KNUM) LJFOLD(CONV ADD IRCONV_INT_NUM) LJFOLD(CONV SUB IRCONV_INT_NUM) LJFOLD(CONV ADD IRCONV_I64_NUM) LJFOLD(CONV SUB IRCONV_I64_NUM) LJFOLDF(narrow_convert) { PHIBARRIER(fleft); /* Narrowing ignores PHIs and repeating it inside the loop is not useful. */ if (J->chain[IR_LOOP]) return NEXTFOLD; lua_assert(fins->o != IR_CONV || (fins->op2&IRCONV_CONVMASK) != IRCONV_TOBIT); return lj_opt_narrow_convert(J); } /* -- Integer algebraic simplifications ----------------------------------- */ LJFOLD(ADD any KINT) LJFOLD(ADDOV any KINT) LJFOLD(SUBOV any KINT) LJFOLDF(simplify_intadd_k) { if (fright->i == 0) /* i o 0 ==> i */ return LEFTFOLD; return NEXTFOLD; } LJFOLD(MULOV any KINT) LJFOLDF(simplify_intmul_k) { if (fright->i == 0) /* i * 0 ==> 0 */ return RIGHTFOLD; if (fright->i == 1) /* i * 1 ==> i */ return LEFTFOLD; if (fright->i == 2) { /* i * 2 ==> i + i */ fins->o = IR_ADDOV; fins->op2 = fins->op1; return RETRYFOLD; } return NEXTFOLD; } LJFOLD(SUB any KINT) LJFOLDF(simplify_intsub_k) { if (fright->i == 0) /* i - 0 ==> i */ return LEFTFOLD; fins->o = IR_ADD; /* i - k ==> i + (-k) */ fins->op2 = (IRRef1)lj_ir_kint(J, -fright->i); /* Overflow for -2^31 ok. */ return RETRYFOLD; } LJFOLD(SUB KINT any) LJFOLD(SUB KINT64 any) LJFOLDF(simplify_intsub_kleft) { if (fleft->o == IR_KINT ? (fleft->i == 0) : (ir_kint64(fleft)->u64 == 0)) { fins->o = IR_NEG; /* 0 - i ==> -i */ fins->op1 = fins->op2; return RETRYFOLD; } return NEXTFOLD; } LJFOLD(ADD any KINT64) LJFOLDF(simplify_intadd_k64) { if (ir_kint64(fright)->u64 == 0) /* i + 0 ==> i */ return LEFTFOLD; return NEXTFOLD; } LJFOLD(SUB any KINT64) LJFOLDF(simplify_intsub_k64) { uint64_t k = ir_kint64(fright)->u64; if (k == 0) /* i - 0 ==> i */ return LEFTFOLD; fins->o = IR_ADD; /* i - k ==> i + (-k) */ fins->op2 = (IRRef1)lj_ir_kint64(J, (uint64_t)-(int64_t)k); return RETRYFOLD; } static TRef simplify_intmul_k(jit_State *J, int32_t k) { /* Note: many more simplifications are possible, e.g. 2^k1 +- 2^k2. ** But this is mainly intended for simple address arithmetic. ** Also it's easier for the backend to optimize the original multiplies. */ if (k == 1) { /* i * 1 ==> i */ return LEFTFOLD; } else if ((k & (k-1)) == 0) { /* i * 2^k ==> i << k */ fins->o = IR_BSHL; fins->op2 = lj_ir_kint(J, lj_fls((uint32_t)k)); return RETRYFOLD; } return NEXTFOLD; } LJFOLD(MUL any KINT) LJFOLDF(simplify_intmul_k32) { if (fright->i == 0) /* i * 0 ==> 0 */ return INTFOLD(0); else if (fright->i > 0) return simplify_intmul_k(J, fright->i); return NEXTFOLD; } LJFOLD(MUL any KINT64) LJFOLDF(simplify_intmul_k64) { if (ir_kint64(fright)->u64 == 0) /* i * 0 ==> 0 */ return INT64FOLD(0); #if LJ_64 /* NYI: SPLIT for BSHL and 32 bit backend support. */ else if (ir_kint64(fright)->u64 < 0x80000000u) return simplify_intmul_k(J, (int32_t)ir_kint64(fright)->u64); #endif return NEXTFOLD; } LJFOLD(MOD any KINT) LJFOLDF(simplify_intmod_k) { int32_t k = fright->i; lua_assert(k != 0); if (k > 0 && (k & (k-1)) == 0) { /* i % (2^k) ==> i & (2^k-1) */ fins->o = IR_BAND; fins->op2 = lj_ir_kint(J, k-1); return RETRYFOLD; } return NEXTFOLD; } LJFOLD(MOD KINT any) LJFOLDF(simplify_intmod_kleft) { if (fleft->i == 0) return INTFOLD(0); return NEXTFOLD; } LJFOLD(SUB any any) LJFOLD(SUBOV any any) LJFOLDF(simplify_intsub) { if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) /* i - i ==> 0 */ return irt_is64(fins->t) ? INT64FOLD(0) : INTFOLD(0); return NEXTFOLD; } LJFOLD(SUB ADD any) LJFOLDF(simplify_intsubadd_leftcancel) { if (!irt_isnum(fins->t)) { PHIBARRIER(fleft); if (fins->op2 == fleft->op1) /* (i + j) - i ==> j */ return fleft->op2; if (fins->op2 == fleft->op2) /* (i + j) - j ==> i */ return fleft->op1; } return NEXTFOLD; } LJFOLD(SUB SUB any) LJFOLDF(simplify_intsubsub_leftcancel) { if (!irt_isnum(fins->t)) { PHIBARRIER(fleft); if (fins->op2 == fleft->op1) { /* (i - j) - i ==> 0 - j */ fins->op1 = (IRRef1)lj_ir_kint(J, 0); fins->op2 = fleft->op2; return RETRYFOLD; } } return NEXTFOLD; } LJFOLD(SUB any SUB) LJFOLDF(simplify_intsubsub_rightcancel) { if (!irt_isnum(fins->t)) { PHIBARRIER(fright); if (fins->op1 == fright->op1) /* i - (i - j) ==> j */ return fright->op2; } return NEXTFOLD; } LJFOLD(SUB any ADD) LJFOLDF(simplify_intsubadd_rightcancel) { if (!irt_isnum(fins->t)) { PHIBARRIER(fright); if (fins->op1 == fright->op1) { /* i - (i + j) ==> 0 - j */ fins->op2 = fright->op2; fins->op1 = (IRRef1)lj_ir_kint(J, 0); return RETRYFOLD; } if (fins->op1 == fright->op2) { /* i - (j + i) ==> 0 - j */ fins->op2 = fright->op1; fins->op1 = (IRRef1)lj_ir_kint(J, 0); return RETRYFOLD; } } return NEXTFOLD; } LJFOLD(SUB ADD ADD) LJFOLDF(simplify_intsubaddadd_cancel) { if (!irt_isnum(fins->t)) { PHIBARRIER(fleft); PHIBARRIER(fright); if (fleft->op1 == fright->op1) { /* (i + j1) - (i + j2) ==> j1 - j2 */ fins->op1 = fleft->op2; fins->op2 = fright->op2; return RETRYFOLD; } if (fleft->op1 == fright->op2) { /* (i + j1) - (j2 + i) ==> j1 - j2 */ fins->op1 = fleft->op2; fins->op2 = fright->op1; return RETRYFOLD; } if (fleft->op2 == fright->op1) { /* (j1 + i) - (i + j2) ==> j1 - j2 */ fins->op1 = fleft->op1; fins->op2 = fright->op2; return RETRYFOLD; } if (fleft->op2 == fright->op2) { /* (j1 + i) - (j2 + i) ==> j1 - j2 */ fins->op1 = fleft->op1; fins->op2 = fright->op1; return RETRYFOLD; } } return NEXTFOLD; } LJFOLD(BAND any KINT) LJFOLD(BAND any KINT64) LJFOLDF(simplify_band_k) { int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : (int64_t)ir_k64(fright)->u64; if (k == 0) /* i & 0 ==> 0 */ return RIGHTFOLD; if (k == -1) /* i & -1 ==> i */ return LEFTFOLD; return NEXTFOLD; } LJFOLD(BOR any KINT) LJFOLD(BOR any KINT64) LJFOLDF(simplify_bor_k) { int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : (int64_t)ir_k64(fright)->u64; if (k == 0) /* i | 0 ==> i */ return LEFTFOLD; if (k == -1) /* i | -1 ==> -1 */ return RIGHTFOLD; return NEXTFOLD; } LJFOLD(BXOR any KINT) LJFOLD(BXOR any KINT64) LJFOLDF(simplify_bxor_k) { int64_t k = fright->o == IR_KINT ? (int64_t)fright->i : (int64_t)ir_k64(fright)->u64; if (k == 0) /* i xor 0 ==> i */ return LEFTFOLD; if (k == -1) { /* i xor -1 ==> ~i */ fins->o = IR_BNOT; fins->op2 = 0; return RETRYFOLD; } return NEXTFOLD; } LJFOLD(BSHL any KINT) LJFOLD(BSHR any KINT) LJFOLD(BSAR any KINT) LJFOLD(BROL any KINT) LJFOLD(BROR any KINT) LJFOLDF(simplify_shift_ik) { int32_t mask = irt_is64(fins->t) ? 63 : 31; int32_t k = (fright->i & mask); if (k == 0) /* i o 0 ==> i */ return LEFTFOLD; if (k == 1 && fins->o == IR_BSHL) { /* i << 1 ==> i + i */ fins->o = IR_ADD; fins->op2 = fins->op1; return RETRYFOLD; } if (k != fright->i) { /* i o k ==> i o (k & mask) */ fins->op2 = (IRRef1)lj_ir_kint(J, k); return RETRYFOLD; } #ifndef LJ_TARGET_UNIFYROT if (fins->o == IR_BROR) { /* bror(i, k) ==> brol(i, (-k)&mask) */ fins->o = IR_BROL; fins->op2 = (IRRef1)lj_ir_kint(J, (-k)&mask); return RETRYFOLD; } #endif return NEXTFOLD; } LJFOLD(BSHL any BAND) LJFOLD(BSHR any BAND) LJFOLD(BSAR any BAND) LJFOLD(BROL any BAND) LJFOLD(BROR any BAND) LJFOLDF(simplify_shift_andk) { IRIns *irk = IR(fright->op2); PHIBARRIER(fright); if ((fins->o < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) && irk->o == IR_KINT) { /* i o (j & mask) ==> i o j */ int32_t mask = irt_is64(fins->t) ? 63 : 31; int32_t k = irk->i & mask; if (k == mask) { fins->op2 = fright->op1; return RETRYFOLD; } } return NEXTFOLD; } LJFOLD(BSHL KINT any) LJFOLD(BSHR KINT any) LJFOLD(BSHL KINT64 any) LJFOLD(BSHR KINT64 any) LJFOLDF(simplify_shift1_ki) { int64_t k = fleft->o == IR_KINT ? (int64_t)fleft->i : (int64_t)ir_k64(fleft)->u64; if (k == 0) /* 0 o i ==> 0 */ return LEFTFOLD; return NEXTFOLD; } LJFOLD(BSAR KINT any) LJFOLD(BROL KINT any) LJFOLD(BROR KINT any) LJFOLD(BSAR KINT64 any) LJFOLD(BROL KINT64 any) LJFOLD(BROR KINT64 any) LJFOLDF(simplify_shift2_ki) { int64_t k = fleft->o == IR_KINT ? (int64_t)fleft->i : (int64_t)ir_k64(fleft)->u64; if (k == 0 || k == -1) /* 0 o i ==> 0; -1 o i ==> -1 */ return LEFTFOLD; return NEXTFOLD; } LJFOLD(BSHL BAND KINT) LJFOLD(BSHR BAND KINT) LJFOLD(BROL BAND KINT) LJFOLD(BROR BAND KINT) LJFOLDF(simplify_shiftk_andk) { IRIns *irk = IR(fleft->op2); PHIBARRIER(fleft); if (irk->o == IR_KINT) { /* (i & k1) o k2 ==> (i o k2) & (k1 o k2) */ int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o); fins->op1 = fleft->op1; fins->op1 = (IRRef1)lj_opt_fold(J); fins->op2 = (IRRef1)lj_ir_kint(J, k); fins->ot = IRTI(IR_BAND); return RETRYFOLD; } return NEXTFOLD; } LJFOLD(BAND BSHL KINT) LJFOLD(BAND BSHR KINT) LJFOLDF(simplify_andk_shiftk) { IRIns *irk = IR(fleft->op2); if (irk->o == IR_KINT && kfold_intop(-1, irk->i, (IROp)fleft->o) == fright->i) return LEFTFOLD; /* (i o k1) & k2 ==> i, if (-1 o k1) == k2 */ return NEXTFOLD; } /* -- Reassociation ------------------------------------------------------- */ LJFOLD(ADD ADD KINT) LJFOLD(MUL MUL KINT) LJFOLD(BAND BAND KINT) LJFOLD(BOR BOR KINT) LJFOLD(BXOR BXOR KINT) LJFOLDF(reassoc_intarith_k) { IRIns *irk = IR(fleft->op2); if (irk->o == IR_KINT) { int32_t k = kfold_intop(irk->i, fright->i, (IROp)fins->o); if (k == irk->i) /* (i o k1) o k2 ==> i o k1, if (k1 o k2) == k1. */ return LEFTFOLD; PHIBARRIER(fleft); fins->op1 = fleft->op1; fins->op2 = (IRRef1)lj_ir_kint(J, k); return RETRYFOLD; /* (i o k1) o k2 ==> i o (k1 o k2) */ } return NEXTFOLD; } LJFOLD(ADD ADD KINT64) LJFOLD(MUL MUL KINT64) LJFOLD(BAND BAND KINT64) LJFOLD(BOR BOR KINT64) LJFOLD(BXOR BXOR KINT64) LJFOLDF(reassoc_intarith_k64) { #if LJ_HASFFI || LJ_64 IRIns *irk = IR(fleft->op2); if (irk->o == IR_KINT64) { uint64_t k = kfold_int64arith(ir_k64(irk)->u64, ir_k64(fright)->u64, (IROp)fins->o); PHIBARRIER(fleft); fins->op1 = fleft->op1; fins->op2 = (IRRef1)lj_ir_kint64(J, k); return RETRYFOLD; /* (i o k1) o k2 ==> i o (k1 o k2) */ } return NEXTFOLD; #else UNUSED(J); lua_assert(0); return FAILFOLD; #endif } LJFOLD(MIN MIN any) LJFOLD(MAX MAX any) LJFOLD(BAND BAND any) LJFOLD(BOR BOR any) LJFOLDF(reassoc_dup) { if (fins->op2 == fleft->op1 || fins->op2 == fleft->op2) return LEFTFOLD; /* (a o b) o a ==> a o b; (a o b) o b ==> a o b */ return NEXTFOLD; } LJFOLD(BXOR BXOR any) LJFOLDF(reassoc_bxor) { PHIBARRIER(fleft); if (fins->op2 == fleft->op1) /* (a xor b) xor a ==> b */ return fleft->op2; if (fins->op2 == fleft->op2) /* (a xor b) xor b ==> a */ return fleft->op1; return NEXTFOLD; } LJFOLD(BSHL BSHL KINT) LJFOLD(BSHR BSHR KINT) LJFOLD(BSAR BSAR KINT) LJFOLD(BROL BROL KINT) LJFOLD(BROR BROR KINT) LJFOLDF(reassoc_shift) { IRIns *irk = IR(fleft->op2); PHIBARRIER(fleft); /* The (shift any KINT) rule covers k2 == 0 and more. */ if (irk->o == IR_KINT) { /* (i o k1) o k2 ==> i o (k1 + k2) */ int32_t mask = irt_is64(fins->t) ? 63 : 31; int32_t k = (irk->i & mask) + (fright->i & mask); if (k > mask) { /* Combined shift too wide? */ if (fins->o == IR_BSHL || fins->o == IR_BSHR) return mask == 31 ? INTFOLD(0) : INT64FOLD(0); else if (fins->o == IR_BSAR) k = mask; else k &= mask; } fins->op1 = fleft->op1; fins->op2 = (IRRef1)lj_ir_kint(J, k); return RETRYFOLD; } return NEXTFOLD; } LJFOLD(MIN MIN KNUM) LJFOLD(MAX MAX KNUM) LJFOLD(MIN MIN KINT) LJFOLD(MAX MAX KINT) LJFOLDF(reassoc_minmax_k) { IRIns *irk = IR(fleft->op2); if (irk->o == IR_KNUM) { lua_Number a = ir_knum(irk)->n; lua_Number y = lj_vm_foldarith(a, knumright, fins->o - IR_ADD); if (a == y) /* (x o k1) o k2 ==> x o k1, if (k1 o k2) == k1. */ return LEFTFOLD; PHIBARRIER(fleft); fins->op1 = fleft->op1; fins->op2 = (IRRef1)lj_ir_knum(J, y); return RETRYFOLD; /* (x o k1) o k2 ==> x o (k1 o k2) */ } else if (irk->o == IR_KINT) { int32_t a = irk->i; int32_t y = kfold_intop(a, fright->i, fins->o); if (a == y) /* (x o k1) o k2 ==> x o k1, if (k1 o k2) == k1. */ return LEFTFOLD; PHIBARRIER(fleft); fins->op1 = fleft->op1; fins->op2 = (IRRef1)lj_ir_kint(J, y); return RETRYFOLD; /* (x o k1) o k2 ==> x o (k1 o k2) */ } return NEXTFOLD; } LJFOLD(MIN MAX any) LJFOLD(MAX MIN any) LJFOLDF(reassoc_minmax_left) { if (fins->op2 == fleft->op1 || fins->op2 == fleft->op2) return RIGHTFOLD; /* (b o1 a) o2 b ==> b; (a o1 b) o2 b ==> b */ return NEXTFOLD; } LJFOLD(MIN any MAX) LJFOLD(MAX any MIN) LJFOLDF(reassoc_minmax_right) { if (fins->op1 == fright->op1 || fins->op1 == fright->op2) return LEFTFOLD; /* a o2 (a o1 b) ==> a; a o2 (b o1 a) ==> a */ return NEXTFOLD; } /* -- Array bounds check elimination -------------------------------------- */ /* Eliminate ABC across PHIs to handle t[i-1] forwarding case. ** ABC(asize, (i+k)+(-k)) ==> ABC(asize, i), but only if it already exists. ** Could be generalized to (i+k1)+k2 ==> i+(k1+k2), but needs better disambig. */ LJFOLD(ABC any ADD) LJFOLDF(abc_fwd) { if (LJ_LIKELY(J->flags & JIT_F_OPT_ABC)) { if (irref_isk(fright->op2)) { IRIns *add2 = IR(fright->op1); if (add2->o == IR_ADD && irref_isk(add2->op2) && IR(fright->op2)->i == -IR(add2->op2)->i) { IRRef ref = J->chain[IR_ABC]; IRRef lim = add2->op1; if (fins->op1 > lim) lim = fins->op1; while (ref > lim) { IRIns *ir = IR(ref); if (ir->op1 == fins->op1 && ir->op2 == add2->op1) return DROPFOLD; ref = ir->prev; } } } } return NEXTFOLD; } /* Eliminate ABC for constants. ** ABC(asize, k1), ABC(asize k2) ==> ABC(asize, max(k1, k2)) ** Drop second ABC if k2 is lower. Otherwise patch first ABC with k2. */ LJFOLD(ABC any KINT) LJFOLDF(abc_k) { if (LJ_LIKELY(J->flags & JIT_F_OPT_ABC)) { IRRef ref = J->chain[IR_ABC]; IRRef asize = fins->op1; while (ref > asize) { IRIns *ir = IR(ref); if (ir->op1 == asize && irref_isk(ir->op2)) { int32_t k = IR(ir->op2)->i; if (fright->i > k) ir->op2 = fins->op2; return DROPFOLD; } ref = ir->prev; } return EMITFOLD; /* Already performed CSE. */ } return NEXTFOLD; } /* Eliminate invariant ABC inside loop. */ LJFOLD(ABC any any) LJFOLDF(abc_invar) { if (!irt_isint(fins->t) && J->chain[IR_LOOP]) /* Currently marked as PTR. */ return DROPFOLD; return NEXTFOLD; } /* -- Commutativity ------------------------------------------------------- */ /* The refs of commutative ops are canonicalized. Lower refs go to the right. ** Rationale behind this: ** - It (also) moves constants to the right. ** - It reduces the number of FOLD rules (e.g. (BOR any KINT) suffices). ** - It helps CSE to find more matches. ** - The assembler generates better code with constants at the right. */ LJFOLD(ADD any any) LJFOLD(MUL any any) LJFOLD(ADDOV any any) LJFOLD(MULOV any any) LJFOLDF(comm_swap) { if (fins->op1 < fins->op2) { /* Move lower ref to the right. */ IRRef1 tmp = fins->op1; fins->op1 = fins->op2; fins->op2 = tmp; return RETRYFOLD; } return NEXTFOLD; } LJFOLD(EQ any any) LJFOLD(NE any any) LJFOLDF(comm_equal) { /* For non-numbers only: x == x ==> drop; x ~= x ==> fail */ if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) return CONDFOLD(fins->o == IR_EQ); return fold_comm_swap(J); } LJFOLD(LT any any) LJFOLD(GE any any) LJFOLD(LE any any) LJFOLD(GT any any) LJFOLD(ULT any any) LJFOLD(UGE any any) LJFOLD(ULE any any) LJFOLD(UGT any any) LJFOLDF(comm_comp) { /* For non-numbers only: x <=> x ==> drop; x <> x ==> fail */ if (fins->op1 == fins->op2 && !irt_isnum(fins->t)) return CONDFOLD((fins->o ^ (fins->o >> 1)) & 1); if (fins->op1 < fins->op2) { /* Move lower ref to the right. */ IRRef1 tmp = fins->op1; fins->op1 = fins->op2; fins->op2 = tmp; fins->o ^= 3; /* GT <-> LT, GE <-> LE, does not affect U */ return RETRYFOLD; } return NEXTFOLD; } LJFOLD(BAND any any) LJFOLD(BOR any any) LJFOLD(MIN any any) LJFOLD(MAX any any) LJFOLDF(comm_dup) { if (fins->op1 == fins->op2) /* x o x ==> x */ return LEFTFOLD; return fold_comm_swap(J); } LJFOLD(BXOR any any) LJFOLDF(comm_bxor) { if (fins->op1 == fins->op2) /* i xor i ==> 0 */ return irt_is64(fins->t) ? INT64FOLD(0) : INTFOLD(0); return fold_comm_swap(J); } /* -- Simplification of compound expressions ------------------------------ */ static TRef kfold_xload(jit_State *J, IRIns *ir, const void *p) { int32_t k; switch (irt_type(ir->t)) { case IRT_NUM: return lj_ir_knum_u64(J, *(uint64_t *)p); case IRT_I8: k = (int32_t)*(int8_t *)p; break; case IRT_U8: k = (int32_t)*(uint8_t *)p; break; case IRT_I16: k = (int32_t)(int16_t)lj_getu16(p); break; case IRT_U16: k = (int32_t)(uint16_t)lj_getu16(p); break; case IRT_INT: case IRT_U32: k = (int32_t)lj_getu32(p); break; case IRT_I64: case IRT_U64: return lj_ir_kint64(J, *(uint64_t *)p); default: return 0; } return lj_ir_kint(J, k); } /* Turn: string.sub(str, a, b) == kstr ** into: string.byte(str, a) == string.byte(kstr, 1) etc. ** Note: this creates unaligned XLOADs on x86/x64. */ LJFOLD(EQ SNEW KGC) LJFOLD(NE SNEW KGC) LJFOLDF(merge_eqne_snew_kgc) { GCstr *kstr = ir_kstr(fright); int32_t len = (int32_t)kstr->len; lua_assert(irt_isstr(fins->t)); #if LJ_TARGET_UNALIGNED #define FOLD_SNEW_MAX_LEN 4 /* Handle string lengths 0, 1, 2, 3, 4. */ #define FOLD_SNEW_TYPE8 IRT_I8 /* Creates shorter immediates. */ #else #define FOLD_SNEW_MAX_LEN 1 /* Handle string lengths 0 or 1. */ #define FOLD_SNEW_TYPE8 IRT_U8 /* Prefer unsigned loads. */ #endif if (len <= FOLD_SNEW_MAX_LEN) { IROp op = (IROp)fins->o; IRRef strref = fleft->op1; lua_assert(IR(strref)->o == IR_STRREF); if (op == IR_EQ) { emitir(IRTGI(IR_EQ), fleft->op2, lj_ir_kint(J, len)); /* Caveat: fins/fleft/fright is no longer valid after emitir. */ } else { /* NE is not expanded since this would need an OR of two conds. */ if (!irref_isk(fleft->op2)) /* Only handle the constant length case. */ return NEXTFOLD; if (IR(fleft->op2)->i != len) return DROPFOLD; } if (len > 0) { /* A 4 byte load for length 3 is ok -- all strings have an extra NUL. */ uint16_t ot = (uint16_t)(len == 1 ? IRT(IR_XLOAD, FOLD_SNEW_TYPE8) : len == 2 ? IRT(IR_XLOAD, IRT_U16) : IRTI(IR_XLOAD)); TRef tmp = emitir(ot, strref, IRXLOAD_READONLY | (len > 1 ? IRXLOAD_UNALIGNED : 0)); TRef val = kfold_xload(J, IR(tref_ref(tmp)), strdata(kstr)); if (len == 3) tmp = emitir(IRTI(IR_BAND), tmp, lj_ir_kint(J, LJ_ENDIAN_SELECT(0x00ffffff, 0xffffff00))); fins->op1 = (IRRef1)tmp; fins->op2 = (IRRef1)val; fins->ot = (IROpT)IRTGI(op); return RETRYFOLD; } else { return DROPFOLD; } } return NEXTFOLD; } /* -- Loads --------------------------------------------------------------- */ /* Loads cannot be folded or passed on to CSE in general. ** Alias analysis is needed to check for forwarding opportunities. ** ** Caveat: *all* loads must be listed here or they end up at CSE! */ LJFOLD(ALOAD any) LJFOLDX(lj_opt_fwd_aload) /* From HREF fwd (see below). Must eliminate, not supported by fwd/backend. */ LJFOLD(HLOAD KKPTR) LJFOLDF(kfold_hload_kkptr) { UNUSED(J); lua_assert(ir_kptr(fleft) == niltvg(J2G(J))); return TREF_NIL; } LJFOLD(HLOAD any) LJFOLDX(lj_opt_fwd_hload) LJFOLD(ULOAD any) LJFOLDX(lj_opt_fwd_uload) LJFOLD(CALLL any IRCALL_lj_tab_len) LJFOLDX(lj_opt_fwd_tab_len) /* Upvalue refs are really loads, but there are no corresponding stores. ** So CSE is ok for them, except for UREFO across a GC step (see below). ** If the referenced function is const, its upvalue addresses are const, too. ** This can be used to improve CSE by looking for the same address, ** even if the upvalues originate from a different function. */ LJFOLD(UREFO KGC any) LJFOLD(UREFC KGC any) LJFOLDF(cse_uref) { if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { IRRef ref = J->chain[fins->o]; GCfunc *fn = ir_kfunc(fleft); GCupval *uv = gco2uv(gcref(fn->l.uvptr[(fins->op2 >> 8)])); while (ref > 0) { IRIns *ir = IR(ref); if (irref_isk(ir->op1)) { GCfunc *fn2 = ir_kfunc(IR(ir->op1)); if (gco2uv(gcref(fn2->l.uvptr[(ir->op2 >> 8)])) == uv) { if (fins->o == IR_UREFO && gcstep_barrier(J, ref)) break; return ref; } } ref = ir->prev; } } return EMITFOLD; } LJFOLD(HREFK any any) LJFOLDX(lj_opt_fwd_hrefk) LJFOLD(HREF TNEW any) LJFOLDF(fwd_href_tnew) { if (lj_opt_fwd_href_nokey(J)) return lj_ir_kkptr(J, niltvg(J2G(J))); return NEXTFOLD; } LJFOLD(HREF TDUP KPRI) LJFOLD(HREF TDUP KGC) LJFOLD(HREF TDUP KNUM) LJFOLDF(fwd_href_tdup) { TValue keyv; lj_ir_kvalue(J->L, &keyv, fright); if (lj_tab_get(J->L, ir_ktab(IR(fleft->op1)), &keyv) == niltvg(J2G(J)) && lj_opt_fwd_href_nokey(J)) return lj_ir_kkptr(J, niltvg(J2G(J))); return NEXTFOLD; } /* We can safely FOLD/CSE array/hash refs and field loads, since there ** are no corresponding stores. But we need to check for any NEWREF with ** an aliased table, as it may invalidate all of the pointers and fields. ** Only HREF needs the NEWREF check -- AREF and HREFK already depend on ** FLOADs. And NEWREF itself is treated like a store (see below). */ LJFOLD(FLOAD TNEW IRFL_TAB_ASIZE) LJFOLDF(fload_tab_tnew_asize) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) return INTFOLD(fleft->op1); return NEXTFOLD; } LJFOLD(FLOAD TNEW IRFL_TAB_HMASK) LJFOLDF(fload_tab_tnew_hmask) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) return INTFOLD((1 << fleft->op2)-1); return NEXTFOLD; } LJFOLD(FLOAD TDUP IRFL_TAB_ASIZE) LJFOLDF(fload_tab_tdup_asize) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) return INTFOLD((int32_t)ir_ktab(IR(fleft->op1))->asize); return NEXTFOLD; } LJFOLD(FLOAD TDUP IRFL_TAB_HMASK) LJFOLDF(fload_tab_tdup_hmask) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1)) return INTFOLD((int32_t)ir_ktab(IR(fleft->op1))->hmask); return NEXTFOLD; } LJFOLD(HREF any any) LJFOLD(FLOAD any IRFL_TAB_ARRAY) LJFOLD(FLOAD any IRFL_TAB_NODE) LJFOLD(FLOAD any IRFL_TAB_ASIZE) LJFOLD(FLOAD any IRFL_TAB_HMASK) LJFOLDF(fload_tab_ah) { TRef tr = lj_opt_cse(J); return lj_opt_fwd_tptr(J, tref_ref(tr)) ? tr : EMITFOLD; } /* Strings are immutable, so we can safely FOLD/CSE the related FLOAD. */ LJFOLD(FLOAD KGC IRFL_STR_LEN) LJFOLDF(fload_str_len_kgc) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) return INTFOLD((int32_t)ir_kstr(fleft)->len); return NEXTFOLD; } LJFOLD(FLOAD SNEW IRFL_STR_LEN) LJFOLDF(fload_str_len_snew) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) { PHIBARRIER(fleft); return fleft->op2; } return NEXTFOLD; } /* The C type ID of cdata objects is immutable. */ LJFOLD(FLOAD KGC IRFL_CDATA_CTYPEID) LJFOLDF(fload_cdata_typeid_kgc) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) return INTFOLD((int32_t)ir_kcdata(fleft)->ctypeid); return NEXTFOLD; } /* Get the contents of immutable cdata objects. */ LJFOLD(FLOAD KGC IRFL_CDATA_PTR) LJFOLD(FLOAD KGC IRFL_CDATA_INT) LJFOLD(FLOAD KGC IRFL_CDATA_INT64) LJFOLDF(fload_cdata_int64_kgc) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) { void *p = cdataptr(ir_kcdata(fleft)); if (irt_is64(fins->t)) return INT64FOLD(*(uint64_t *)p); else return INTFOLD(*(int32_t *)p); } return NEXTFOLD; } LJFOLD(FLOAD CNEW IRFL_CDATA_CTYPEID) LJFOLD(FLOAD CNEWI IRFL_CDATA_CTYPEID) LJFOLDF(fload_cdata_typeid_cnew) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) return fleft->op1; /* No PHI barrier needed. CNEW/CNEWI op1 is const. */ return NEXTFOLD; } /* Pointer, int and int64 cdata objects are immutable. */ LJFOLD(FLOAD CNEWI IRFL_CDATA_PTR) LJFOLD(FLOAD CNEWI IRFL_CDATA_INT) LJFOLD(FLOAD CNEWI IRFL_CDATA_INT64) LJFOLDF(fload_cdata_ptr_int64_cnew) { if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD)) return fleft->op2; /* Fold even across PHI to avoid allocations. */ return NEXTFOLD; } LJFOLD(FLOAD any IRFL_STR_LEN) LJFOLD(FLOAD any IRFL_CDATA_CTYPEID) LJFOLD(FLOAD any IRFL_CDATA_PTR) LJFOLD(FLOAD any IRFL_CDATA_INT) LJFOLD(FLOAD any IRFL_CDATA_INT64) LJFOLD(VLOAD any any) /* Vararg loads have no corresponding stores. */ LJFOLDX(lj_opt_cse) /* All other field loads need alias analysis. */ LJFOLD(FLOAD any any) LJFOLDX(lj_opt_fwd_fload) /* This is for LOOP only. Recording handles SLOADs internally. */ LJFOLD(SLOAD any any) LJFOLDF(fwd_sload) { if ((fins->op2 & IRSLOAD_FRAME)) { TRef tr = lj_opt_cse(J); return tref_ref(tr) < J->chain[IR_RETF] ? EMITFOLD : tr; } else { lua_assert(J->slot[fins->op1] != 0); return J->slot[fins->op1]; } } /* Only fold for KKPTR. The pointer _and_ the contents must be const. */ LJFOLD(XLOAD KKPTR any) LJFOLDF(xload_kptr) { TRef tr = kfold_xload(J, fins, ir_kptr(fleft)); return tr ? tr : NEXTFOLD; } LJFOLD(XLOAD any any) LJFOLDX(lj_opt_fwd_xload) /* -- Write barriers ------------------------------------------------------ */ /* Write barriers are amenable to CSE, but not across any incremental ** GC steps. ** ** The same logic applies to open upvalue references, because a stack ** may be resized during a GC step (not the current stack, but maybe that ** of a coroutine). */ LJFOLD(TBAR any) LJFOLD(OBAR any any) LJFOLD(UREFO any any) LJFOLDF(barrier_tab) { TRef tr = lj_opt_cse(J); if (gcstep_barrier(J, tref_ref(tr))) /* CSE across GC step? */ return EMITFOLD; /* Raw emit. Assumes fins is left intact by CSE. */ return tr; } LJFOLD(TBAR TNEW) LJFOLD(TBAR TDUP) LJFOLDF(barrier_tnew_tdup) { /* New tables are always white and never need a barrier. */ if (fins->op1 < J->chain[IR_LOOP]) /* Except across a GC step. */ return NEXTFOLD; return DROPFOLD; } /* -- Stores and allocations ---------------------------------------------- */ /* Stores and allocations cannot be folded or passed on to CSE in general. ** But some stores can be eliminated with dead-store elimination (DSE). ** ** Caveat: *all* stores and allocs must be listed here or they end up at CSE! */ LJFOLD(ASTORE any any) LJFOLD(HSTORE any any) LJFOLDX(lj_opt_dse_ahstore) LJFOLD(USTORE any any) LJFOLDX(lj_opt_dse_ustore) LJFOLD(FSTORE any any) LJFOLDX(lj_opt_dse_fstore) LJFOLD(XSTORE any any) LJFOLDX(lj_opt_dse_xstore) LJFOLD(NEWREF any any) /* Treated like a store. */ LJFOLD(CALLS any any) LJFOLD(CALLL any any) /* Safeguard fallback. */ LJFOLD(CALLXS any any) LJFOLD(XBAR) LJFOLD(RETF any any) /* Modifies BASE. */ LJFOLD(TNEW any any) LJFOLD(TDUP any) LJFOLD(CNEW any any) LJFOLD(XSNEW any any) LJFOLDX(lj_ir_emit) /* ------------------------------------------------------------------------ */ /* Every entry in the generated hash table is a 32 bit pattern: ** ** xxxxxxxx iiiiiii lllllll rrrrrrrrrr ** ** xxxxxxxx = 8 bit index into fold function table ** iiiiiii = 7 bit folded instruction opcode ** lllllll = 7 bit left instruction opcode ** rrrrrrrrrr = 8 bit right instruction opcode or 10 bits from literal field */ #include "lj_folddef.h" /* ------------------------------------------------------------------------ */ /* Fold IR instruction. */ TRef LJ_FASTCALL lj_opt_fold(jit_State *J) { uint32_t key, any; IRRef ref; if (LJ_UNLIKELY((J->flags & JIT_F_OPT_MASK) != JIT_F_OPT_DEFAULT)) { lua_assert(((JIT_F_OPT_FOLD|JIT_F_OPT_FWD|JIT_F_OPT_CSE|JIT_F_OPT_DSE) | JIT_F_OPT_DEFAULT) == JIT_F_OPT_DEFAULT); /* Folding disabled? Chain to CSE, but not for loads/stores/allocs. */ if (!(J->flags & JIT_F_OPT_FOLD) && irm_kind(lj_ir_mode[fins->o]) == IRM_N) return lj_opt_cse(J); /* Forwarding or CSE disabled? Emit raw IR for loads, except for SLOAD. */ if ((J->flags & (JIT_F_OPT_FWD|JIT_F_OPT_CSE)) != (JIT_F_OPT_FWD|JIT_F_OPT_CSE) && irm_kind(lj_ir_mode[fins->o]) == IRM_L && fins->o != IR_SLOAD) return lj_ir_emit(J); /* DSE disabled? Emit raw IR for stores. */ if (!(J->flags & JIT_F_OPT_DSE) && irm_kind(lj_ir_mode[fins->o]) == IRM_S) return lj_ir_emit(J); } /* Fold engine start/retry point. */ retry: /* Construct key from opcode and operand opcodes (unless literal/none). */ key = ((uint32_t)fins->o << 17); if (fins->op1 >= J->cur.nk) { key += (uint32_t)IR(fins->op1)->o << 10; *fleft = *IR(fins->op1); } if (fins->op2 >= J->cur.nk) { key += (uint32_t)IR(fins->op2)->o; *fright = *IR(fins->op2); } else { key += (fins->op2 & 0x3ffu); /* Literal mask. Must include IRCONV_*MASK. */ } /* Check for a match in order from most specific to least specific. */ any = 0; for (;;) { uint32_t k = key | (any & 0x1ffff); uint32_t h = fold_hashkey(k); uint32_t fh = fold_hash[h]; /* Lookup key in semi-perfect hash table. */ if ((fh & 0xffffff) == k || (fh = fold_hash[h+1], (fh & 0xffffff) == k)) { ref = (IRRef)tref_ref(fold_func[fh >> 24](J)); if (ref != NEXTFOLD) break; } if (any == 0xfffff) /* Exhausted folding. Pass on to CSE. */ return lj_opt_cse(J); any = (any | (any >> 10)) ^ 0xffc00; } /* Return value processing, ordered by frequency. */ if (LJ_LIKELY(ref >= MAX_FOLD)) return TREF(ref, irt_t(IR(ref)->t)); if (ref == RETRYFOLD) goto retry; if (ref == KINTFOLD) return lj_ir_kint(J, fins->i); if (ref == FAILFOLD) lj_trace_err(J, LJ_TRERR_GFAIL); lua_assert(ref == DROPFOLD); return REF_DROP; } /* -- Common-Subexpression Elimination ------------------------------------ */ /* CSE an IR instruction. This is very fast due to the skip-list chains. */ TRef LJ_FASTCALL lj_opt_cse(jit_State *J) { /* Avoid narrow to wide store-to-load forwarding stall */ IRRef2 op12 = (IRRef2)fins->op1 + ((IRRef2)fins->op2 << 16); IROp op = fins->o; if (LJ_LIKELY(J->flags & JIT_F_OPT_CSE)) { /* Limited search for same operands in per-opcode chain. */ IRRef ref = J->chain[op]; IRRef lim = fins->op1; if (fins->op2 > lim) lim = fins->op2; /* Relies on lit < REF_BIAS. */ while (ref > lim) { if (IR(ref)->op12 == op12) return TREF(ref, irt_t(IR(ref)->t)); /* Common subexpression found. */ ref = IR(ref)->prev; } } /* Otherwise emit IR (inlined for speed). */ { IRRef ref = lj_ir_nextins(J); IRIns *ir = IR(ref); ir->prev = J->chain[op]; ir->op12 = op12; J->chain[op] = (IRRef1)ref; ir->o = fins->o; J->guardemit.irt |= fins->t.irt; return TREF(ref, irt_t((ir->t = fins->t))); } } /* CSE with explicit search limit. */ TRef LJ_FASTCALL lj_opt_cselim(jit_State *J, IRRef lim) { IRRef ref = J->chain[fins->o]; IRRef2 op12 = (IRRef2)fins->op1 + ((IRRef2)fins->op2 << 16); while (ref > lim) { if (IR(ref)->op12 == op12) return ref; ref = IR(ref)->prev; } return lj_ir_emit(J); } /* ------------------------------------------------------------------------ */ #undef IR #undef fins #undef fleft #undef fright #undef knumleft #undef knumright #undef emitir #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_opt_loop.c ================================================ /* ** LOOP: Loop Optimizations. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_opt_loop_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_err.h" #include "lj_str.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_iropt.h" #include "lj_trace.h" #include "lj_snap.h" #include "lj_vm.h" /* Loop optimization: ** ** Traditional Loop-Invariant Code Motion (LICM) splits the instructions ** of a loop into invariant and variant instructions. The invariant ** instructions are hoisted out of the loop and only the variant ** instructions remain inside the loop body. ** ** Unfortunately LICM is mostly useless for compiling dynamic languages. ** The IR has many guards and most of the subsequent instructions are ** control-dependent on them. The first non-hoistable guard would ** effectively prevent hoisting of all subsequent instructions. ** ** That's why we use a special form of unrolling using copy-substitution, ** combined with redundancy elimination: ** ** The recorded instruction stream is re-emitted to the compiler pipeline ** with substituted operands. The substitution table is filled with the ** refs returned by re-emitting each instruction. This can be done ** on-the-fly, because the IR is in strict SSA form, where every ref is ** defined before its use. ** ** This aproach generates two code sections, separated by the LOOP ** instruction: ** ** 1. The recorded instructions form a kind of pre-roll for the loop. It ** contains a mix of invariant and variant instructions and performs ** exactly one loop iteration (but not necessarily the 1st iteration). ** ** 2. The loop body contains only the variant instructions and performs ** all remaining loop iterations. ** ** On first sight that looks like a waste of space, because the variant ** instructions are present twice. But the key insight is that the ** pre-roll honors the control-dependencies for *both* the pre-roll itself ** *and* the loop body! ** ** It also means one doesn't have to explicitly model control-dependencies ** (which, BTW, wouldn't help LICM much). And it's much easier to ** integrate sparse snapshotting with this approach. ** ** One of the nicest aspects of this approach is that all of the ** optimizations of the compiler pipeline (FOLD, CSE, FWD, etc.) can be ** reused with only minor restrictions (e.g. one should not fold ** instructions across loop-carried dependencies). ** ** But in general all optimizations can be applied which only need to look ** backwards into the generated instruction stream. At any point in time ** during the copy-substitution process this contains both a static loop ** iteration (the pre-roll) and a dynamic one (from the to-be-copied ** instruction up to the end of the partial loop body). ** ** Since control-dependencies are implicitly kept, CSE also applies to all ** kinds of guards. The major advantage is that all invariant guards can ** be hoisted, too. ** ** Load/store forwarding works across loop iterations, too. This is ** important if loop-carried dependencies are kept in upvalues or tables. ** E.g. 'self.idx = self.idx + 1' deep down in some OO-style method may ** become a forwarded loop-recurrence after inlining. ** ** Since the IR is in SSA form, loop-carried dependencies have to be ** modeled with PHI instructions. The potential candidates for PHIs are ** collected on-the-fly during copy-substitution. After eliminating the ** redundant ones, PHI instructions are emitted *below* the loop body. ** ** Note that this departure from traditional SSA form doesn't change the ** semantics of the PHI instructions themselves. But it greatly simplifies ** on-the-fly generation of the IR and the machine code. */ /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) /* Pass IR on to next optimization in chain (FOLD). */ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) /* Emit raw IR without passing through optimizations. */ #define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) /* -- PHI elimination ----------------------------------------------------- */ /* Emit or eliminate collected PHIs. */ static void loop_emit_phi(jit_State *J, IRRef1 *subst, IRRef1 *phi, IRRef nphi, SnapNo onsnap) { int passx = 0; IRRef i, nslots; IRRef invar = J->chain[IR_LOOP]; /* Pass #1: mark redundant and potentially redundant PHIs. */ for (i = 0; i < nphi; i++) { IRRef lref = phi[i]; IRRef rref = subst[lref]; if (lref == rref || rref == REF_DROP) { /* Invariants are redundant. */ irt_setmark(IR(lref)->t); } else if (!(IR(rref)->op1 == lref || IR(rref)->op2 == lref)) { /* Quick check for simple recurrences failed, need pass2. */ irt_setmark(IR(lref)->t); passx = 1; } } /* Pass #2: traverse variant part and clear marks of non-redundant PHIs. */ if (passx) { SnapNo s; for (i = J->cur.nins-1; i > invar; i--) { IRIns *ir = IR(i); if (!irref_isk(ir->op2)) irt_clearmark(IR(ir->op2)->t); if (!irref_isk(ir->op1)) { irt_clearmark(IR(ir->op1)->t); if (ir->op1 < invar && ir->o >= IR_CALLN && ir->o <= IR_CARG) { /* ORDER IR */ ir = IR(ir->op1); while (ir->o == IR_CARG) { if (!irref_isk(ir->op2)) irt_clearmark(IR(ir->op2)->t); if (irref_isk(ir->op1)) break; ir = IR(ir->op1); irt_clearmark(ir->t); } } } } for (s = J->cur.nsnap-1; s >= onsnap; s--) { SnapShot *snap = &J->cur.snap[s]; SnapEntry *map = &J->cur.snapmap[snap->mapofs]; MSize n, nent = snap->nent; for (n = 0; n < nent; n++) { IRRef ref = snap_ref(map[n]); if (!irref_isk(ref)) irt_clearmark(IR(ref)->t); } } } /* Pass #3: add PHIs for variant slots without a corresponding SLOAD. */ nslots = J->baseslot+J->maxslot; for (i = 1; i < nslots; i++) { IRRef ref = tref_ref(J->slot[i]); while (!irref_isk(ref) && ref != subst[ref]) { IRIns *ir = IR(ref); irt_clearmark(ir->t); /* Unmark potential uses, too. */ if (irt_isphi(ir->t) || irt_ispri(ir->t)) break; irt_setphi(ir->t); if (nphi >= LJ_MAX_PHI) lj_trace_err(J, LJ_TRERR_PHIOV); phi[nphi++] = (IRRef1)ref; ref = subst[ref]; if (ref > invar) break; } } /* Pass #4: propagate non-redundant PHIs. */ while (passx) { passx = 0; for (i = 0; i < nphi; i++) { IRRef lref = phi[i]; IRIns *ir = IR(lref); if (!irt_ismarked(ir->t)) { /* Propagate only from unmarked PHIs. */ IRRef rref = subst[lref]; if (lref == rref) { /* Mark redundant PHI. */ irt_setmark(ir->t); } else { IRIns *irr = IR(rref); if (irt_ismarked(irr->t)) { /* Right ref points to other PHI? */ irt_clearmark(irr->t); /* Mark that PHI as non-redundant. */ passx = 1; /* Retry. */ } } } } } /* Pass #5: emit PHI instructions or eliminate PHIs. */ for (i = 0; i < nphi; i++) { IRRef lref = phi[i]; IRIns *ir = IR(lref); if (!irt_ismarked(ir->t)) { /* Emit PHI if not marked. */ IRRef rref = subst[lref]; if (rref > invar) irt_setphi(IR(rref)->t); emitir_raw(IRT(IR_PHI, irt_type(ir->t)), lref, rref); } else { /* Otherwise eliminate PHI. */ irt_clearmark(ir->t); irt_clearphi(ir->t); } } } /* -- Loop unrolling using copy-substitution ------------------------------ */ /* Copy-substitute snapshot. */ static void loop_subst_snap(jit_State *J, SnapShot *osnap, SnapEntry *loopmap, IRRef1 *subst) { SnapEntry *nmap, *omap = &J->cur.snapmap[osnap->mapofs]; SnapEntry *nextmap = &J->cur.snapmap[snap_nextofs(&J->cur, osnap)]; MSize nmapofs; MSize on, ln, nn, onent = osnap->nent; BCReg nslots = osnap->nslots; SnapShot *snap = &J->cur.snap[J->cur.nsnap]; if (irt_isguard(J->guardemit)) { /* Guard inbetween? */ nmapofs = J->cur.nsnapmap; J->cur.nsnap++; /* Add new snapshot. */ } else { /* Otherwise overwrite previous snapshot. */ snap--; nmapofs = snap->mapofs; } J->guardemit.irt = 0; /* Setup new snapshot. */ snap->mapofs = (uint16_t)nmapofs; snap->ref = (IRRef1)J->cur.nins; snap->nslots = nslots; snap->topslot = osnap->topslot; snap->count = 0; nmap = &J->cur.snapmap[nmapofs]; /* Substitute snapshot slots. */ on = ln = nn = 0; while (on < onent) { SnapEntry osn = omap[on], lsn = loopmap[ln]; if (snap_slot(lsn) < snap_slot(osn)) { /* Copy slot from loop map. */ nmap[nn++] = lsn; ln++; } else { /* Copy substituted slot from snapshot map. */ if (snap_slot(lsn) == snap_slot(osn)) ln++; /* Shadowed loop slot. */ if (!irref_isk(snap_ref(osn))) osn = snap_setref(osn, subst[snap_ref(osn)]); nmap[nn++] = osn; on++; } } while (snap_slot(loopmap[ln]) < nslots) /* Copy remaining loop slots. */ nmap[nn++] = loopmap[ln++]; snap->nent = (uint8_t)nn; omap += onent; nmap += nn; while (omap < nextmap) /* Copy PC + frame links. */ *nmap++ = *omap++; J->cur.nsnapmap = (uint16_t)(nmap - J->cur.snapmap); } /* Unroll loop. */ static void loop_unroll(jit_State *J) { IRRef1 phi[LJ_MAX_PHI]; uint32_t nphi = 0; IRRef1 *subst; SnapNo onsnap; SnapShot *osnap, *loopsnap; SnapEntry *loopmap, *psentinel; IRRef ins, invar; /* Use temp buffer for substitution table. ** Only non-constant refs in [REF_BIAS,invar) are valid indexes. ** Caveat: don't call into the VM or run the GC or the buffer may be gone. */ invar = J->cur.nins; subst = (IRRef1 *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf, (invar-REF_BIAS)*sizeof(IRRef1)) - REF_BIAS; subst[REF_BASE] = REF_BASE; /* LOOP separates the pre-roll from the loop body. */ emitir_raw(IRTG(IR_LOOP, IRT_NIL), 0, 0); /* Grow snapshot buffer and map for copy-substituted snapshots. ** Need up to twice the number of snapshots minus #0 and loop snapshot. ** Need up to twice the number of entries plus fallback substitutions ** from the loop snapshot entries for each new snapshot. ** Caveat: both calls may reallocate J->cur.snap and J->cur.snapmap! */ onsnap = J->cur.nsnap; lj_snap_grow_buf(J, 2*onsnap-2); lj_snap_grow_map(J, J->cur.nsnapmap*2+(onsnap-2)*J->cur.snap[onsnap-1].nent); /* The loop snapshot is used for fallback substitutions. */ loopsnap = &J->cur.snap[onsnap-1]; loopmap = &J->cur.snapmap[loopsnap->mapofs]; /* The PC of snapshot #0 and the loop snapshot must match. */ psentinel = &loopmap[loopsnap->nent]; lua_assert(*psentinel == J->cur.snapmap[J->cur.snap[0].nent]); *psentinel = SNAP(255, 0, 0); /* Replace PC with temporary sentinel. */ /* Start substitution with snapshot #1 (#0 is empty for root traces). */ osnap = &J->cur.snap[1]; /* Copy and substitute all recorded instructions and snapshots. */ for (ins = REF_FIRST; ins < invar; ins++) { IRIns *ir; IRRef op1, op2; if (ins >= osnap->ref) /* Instruction belongs to next snapshot? */ loop_subst_snap(J, osnap++, loopmap, subst); /* Copy-substitute it. */ /* Substitute instruction operands. */ ir = IR(ins); op1 = ir->op1; if (!irref_isk(op1)) op1 = subst[op1]; op2 = ir->op2; if (!irref_isk(op2)) op2 = subst[op2]; if (irm_kind(lj_ir_mode[ir->o]) == IRM_N && op1 == ir->op1 && op2 == ir->op2) { /* Regular invariant ins? */ subst[ins] = (IRRef1)ins; /* Shortcut. */ } else { /* Re-emit substituted instruction to the FOLD/CSE/etc. pipeline. */ IRType1 t = ir->t; /* Get this first, since emitir may invalidate ir. */ IRRef ref = tref_ref(emitir(ir->ot & ~IRT_ISPHI, op1, op2)); subst[ins] = (IRRef1)ref; if (ref != ins) { IRIns *irr = IR(ref); if (ref < invar) { /* Loop-carried dependency? */ /* Potential PHI? */ if (!irref_isk(ref) && !irt_isphi(irr->t) && !irt_ispri(irr->t)) { irt_setphi(irr->t); if (nphi >= LJ_MAX_PHI) lj_trace_err(J, LJ_TRERR_PHIOV); phi[nphi++] = (IRRef1)ref; } /* Check all loop-carried dependencies for type instability. */ if (!irt_sametype(t, irr->t)) { if (irt_isinteger(t) && irt_isinteger(irr->t)) continue; else if (irt_isnum(t) && irt_isinteger(irr->t)) /* Fix int->num. */ ref = tref_ref(emitir(IRTN(IR_CONV), ref, IRCONV_NUM_INT)); else if (irt_isnum(irr->t) && irt_isinteger(t)) /* Fix num->int. */ ref = tref_ref(emitir(IRTGI(IR_CONV), ref, IRCONV_INT_NUM|IRCONV_CHECK)); else lj_trace_err(J, LJ_TRERR_TYPEINS); subst[ins] = (IRRef1)ref; irr = IR(ref); goto phiconv; } } else if (ref != REF_DROP && irr->o == IR_CONV && ref > invar && irr->op1 < invar) { /* May need an extra PHI for a CONV. */ ref = irr->op1; irr = IR(ref); phiconv: if (ref < invar && !irref_isk(ref) && !irt_isphi(irr->t)) { irt_setphi(irr->t); if (nphi >= LJ_MAX_PHI) lj_trace_err(J, LJ_TRERR_PHIOV); phi[nphi++] = (IRRef1)ref; } } } } } if (!irt_isguard(J->guardemit)) /* Drop redundant snapshot. */ J->cur.nsnapmap = (uint16_t)J->cur.snap[--J->cur.nsnap].mapofs; lua_assert(J->cur.nsnapmap <= J->sizesnapmap); *psentinel = J->cur.snapmap[J->cur.snap[0].nent]; /* Restore PC. */ loop_emit_phi(J, subst, phi, nphi, onsnap); } /* Undo any partial changes made by the loop optimization. */ static void loop_undo(jit_State *J, IRRef ins, SnapNo nsnap, MSize nsnapmap) { ptrdiff_t i; SnapShot *snap = &J->cur.snap[nsnap-1]; SnapEntry *map = J->cur.snapmap; map[snap->mapofs + snap->nent] = map[J->cur.snap[0].nent]; /* Restore PC. */ J->cur.nsnapmap = (uint16_t)nsnapmap; J->cur.nsnap = nsnap; J->guardemit.irt = 0; lj_ir_rollback(J, ins); for (i = 0; i < BPROP_SLOTS; i++) { /* Remove backprop. cache entries. */ BPropEntry *bp = &J->bpropcache[i]; if (bp->val >= ins) bp->key = 0; } for (ins--; ins >= REF_FIRST; ins--) { /* Remove flags. */ IRIns *ir = IR(ins); irt_clearphi(ir->t); irt_clearmark(ir->t); } } /* Protected callback for loop optimization. */ static TValue *cploop_opt(lua_State *L, lua_CFunction dummy, void *ud) { UNUSED(L); UNUSED(dummy); loop_unroll((jit_State *)ud); return NULL; } /* Loop optimization. */ int lj_opt_loop(jit_State *J) { IRRef nins = J->cur.nins; SnapNo nsnap = J->cur.nsnap; MSize nsnapmap = J->cur.nsnapmap; int errcode = lj_vm_cpcall(J->L, NULL, J, cploop_opt); if (LJ_UNLIKELY(errcode)) { lua_State *L = J->L; if (errcode == LUA_ERRRUN && tvisnumber(L->top-1)) { /* Trace error? */ int32_t e = numberVint(L->top-1); switch ((TraceError)e) { case LJ_TRERR_TYPEINS: /* Type instability. */ case LJ_TRERR_GFAIL: /* Guard would always fail. */ /* Unrolling via recording fixes many cases, e.g. a flipped boolean. */ if (--J->instunroll < 0) /* But do not unroll forever. */ break; L->top--; /* Remove error object. */ loop_undo(J, nins, nsnap, nsnapmap); return 1; /* Loop optimization failed, continue recording. */ default: break; } } lj_err_throw(L, errcode); /* Propagate all other errors. */ } return 0; /* Loop optimization is ok. */ } #undef IR #undef emitir #undef emitir_raw #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_opt_mem.c ================================================ /* ** Memory access optimizations. ** AA: Alias Analysis using high-level semantic disambiguation. ** FWD: Load Forwarding (L2L) + Store Forwarding (S2L). ** DSE: Dead-Store Elimination. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_opt_mem_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_tab.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_iropt.h" /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) #define fins (&J->fold.ins) #define fleft (&J->fold.left) #define fright (&J->fold.right) /* ** Caveat #1: return value is not always a TRef -- only use with tref_ref(). ** Caveat #2: FWD relies on active CSE for xREF operands -- see lj_opt_fold(). */ /* Return values from alias analysis. */ typedef enum { ALIAS_NO, /* The two refs CANNOT alias (exact). */ ALIAS_MAY, /* The two refs MAY alias (inexact). */ ALIAS_MUST /* The two refs MUST alias (exact). */ } AliasRet; /* -- ALOAD/HLOAD forwarding and ASTORE/HSTORE elimination ---------------- */ /* Simplified escape analysis: check for intervening stores. */ static AliasRet aa_escape(jit_State *J, IRIns *ir, IRIns *stop) { IRRef ref = (IRRef)(ir - J->cur.ir); /* The ref that might be stored. */ for (ir++; ir < stop; ir++) if (ir->op2 == ref && (ir->o == IR_ASTORE || ir->o == IR_HSTORE || ir->o == IR_USTORE || ir->o == IR_FSTORE)) return ALIAS_MAY; /* Reference was stored and might alias. */ return ALIAS_NO; /* Reference was not stored. */ } /* Alias analysis for two different table references. */ static AliasRet aa_table(jit_State *J, IRRef ta, IRRef tb) { IRIns *taba = IR(ta), *tabb = IR(tb); int newa, newb; lua_assert(ta != tb); lua_assert(irt_istab(taba->t) && irt_istab(tabb->t)); /* Disambiguate new allocations. */ newa = (taba->o == IR_TNEW || taba->o == IR_TDUP); newb = (tabb->o == IR_TNEW || tabb->o == IR_TDUP); if (newa && newb) return ALIAS_NO; /* Two different allocations never alias. */ if (newb) { /* At least one allocation? */ IRIns *tmp = taba; taba = tabb; tabb = tmp; } else if (!newa) { return ALIAS_MAY; /* Anything else: we just don't know. */ } return aa_escape(J, taba, tabb); } /* Alias analysis for array and hash access using key-based disambiguation. */ static AliasRet aa_ahref(jit_State *J, IRIns *refa, IRIns *refb) { IRRef ka = refa->op2; IRRef kb = refb->op2; IRIns *keya, *keyb; IRRef ta, tb; if (refa == refb) return ALIAS_MUST; /* Shortcut for same refs. */ keya = IR(ka); if (keya->o == IR_KSLOT) { ka = keya->op1; keya = IR(ka); } keyb = IR(kb); if (keyb->o == IR_KSLOT) { kb = keyb->op1; keyb = IR(kb); } ta = (refa->o==IR_HREFK || refa->o==IR_AREF) ? IR(refa->op1)->op1 : refa->op1; tb = (refb->o==IR_HREFK || refb->o==IR_AREF) ? IR(refb->op1)->op1 : refb->op1; if (ka == kb) { /* Same key. Check for same table with different ref (NEWREF vs. HREF). */ if (ta == tb) return ALIAS_MUST; /* Same key, same table. */ else return aa_table(J, ta, tb); /* Same key, possibly different table. */ } if (irref_isk(ka) && irref_isk(kb)) return ALIAS_NO; /* Different constant keys. */ if (refa->o == IR_AREF) { /* Disambiguate array references based on index arithmetic. */ int32_t ofsa = 0, ofsb = 0; IRRef basea = ka, baseb = kb; lua_assert(refb->o == IR_AREF); /* Gather base and offset from t[base] or t[base+-ofs]. */ if (keya->o == IR_ADD && irref_isk(keya->op2)) { basea = keya->op1; ofsa = IR(keya->op2)->i; if (basea == kb && ofsa != 0) return ALIAS_NO; /* t[base+-ofs] vs. t[base]. */ } if (keyb->o == IR_ADD && irref_isk(keyb->op2)) { baseb = keyb->op1; ofsb = IR(keyb->op2)->i; if (ka == baseb && ofsb != 0) return ALIAS_NO; /* t[base] vs. t[base+-ofs]. */ } if (basea == baseb && ofsa != ofsb) return ALIAS_NO; /* t[base+-o1] vs. t[base+-o2] and o1 != o2. */ } else { /* Disambiguate hash references based on the type of their keys. */ lua_assert((refa->o==IR_HREF || refa->o==IR_HREFK || refa->o==IR_NEWREF) && (refb->o==IR_HREF || refb->o==IR_HREFK || refb->o==IR_NEWREF)); if (!irt_sametype(keya->t, keyb->t)) return ALIAS_NO; /* Different key types. */ } if (ta == tb) return ALIAS_MAY; /* Same table, cannot disambiguate keys. */ else return aa_table(J, ta, tb); /* Try to disambiguate tables. */ } /* Array and hash load forwarding. */ static TRef fwd_ahload(jit_State *J, IRRef xref) { IRIns *xr = IR(xref); IRRef lim = xref; /* Search limit. */ IRRef ref; /* Search for conflicting stores. */ ref = J->chain[fins->o+IRDELTA_L2S]; while (ref > xref) { IRIns *store = IR(ref); switch (aa_ahref(J, xr, IR(store->op1))) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ case ALIAS_MUST: return store->op2; /* Store forwarding. */ } ref = store->prev; } /* No conflicting store (yet): const-fold loads from allocations. */ { IRIns *ir = (xr->o == IR_HREFK || xr->o == IR_AREF) ? IR(xr->op1) : xr; IRRef tab = ir->op1; ir = IR(tab); if (ir->o == IR_TNEW || (ir->o == IR_TDUP && irref_isk(xr->op2))) { /* A NEWREF with a number key may end up pointing to the array part. ** But it's referenced from HSTORE and not found in the ASTORE chain. ** For now simply consider this a conflict without forwarding anything. */ if (xr->o == IR_AREF) { IRRef ref2 = J->chain[IR_NEWREF]; while (ref2 > tab) { IRIns *newref = IR(ref2); if (irt_isnum(IR(newref->op2)->t)) goto cselim; ref2 = newref->prev; } } /* NEWREF inhibits CSE for HREF, and dependent FLOADs from HREFK/AREF. ** But the above search for conflicting stores was limited by xref. ** So continue searching, limited by the TNEW/TDUP. Store forwarding ** is ok, too. A conflict does NOT limit the search for a matching load. */ while (ref > tab) { IRIns *store = IR(ref); switch (aa_ahref(J, xr, IR(store->op1))) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: goto cselim; /* Conflicting store. */ case ALIAS_MUST: return store->op2; /* Store forwarding. */ } ref = store->prev; } lua_assert(ir->o != IR_TNEW || irt_isnil(fins->t)); if (irt_ispri(fins->t)) { return TREF_PRI(irt_type(fins->t)); } else if (irt_isnum(fins->t) || (LJ_DUALNUM && irt_isint(fins->t)) || irt_isstr(fins->t)) { TValue keyv; cTValue *tv; IRIns *key = IR(xr->op2); if (key->o == IR_KSLOT) key = IR(key->op1); lj_ir_kvalue(J->L, &keyv, key); tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv); lua_assert(itype2irt(tv) == irt_type(fins->t)); if (irt_isnum(fins->t)) return lj_ir_knum_u64(J, tv->u64); else if (LJ_DUALNUM && irt_isint(fins->t)) return lj_ir_kint(J, intV(tv)); else return lj_ir_kstr(J, strV(tv)); } /* Othwerwise: don't intern as a constant. */ } } cselim: /* Try to find a matching load. Below the conflicting store, if any. */ ref = J->chain[fins->o]; while (ref > lim) { IRIns *load = IR(ref); if (load->op1 == xref) return ref; /* Load forwarding. */ ref = load->prev; } return 0; /* Conflict or no match. */ } /* Reassociate ALOAD across PHIs to handle t[i-1] forwarding case. */ static TRef fwd_aload_reassoc(jit_State *J) { IRIns *irx = IR(fins->op1); IRIns *key = IR(irx->op2); if (key->o == IR_ADD && irref_isk(key->op2)) { IRIns *add2 = IR(key->op1); if (add2->o == IR_ADD && irref_isk(add2->op2) && IR(key->op2)->i == -IR(add2->op2)->i) { IRRef ref = J->chain[IR_AREF]; IRRef lim = add2->op1; if (irx->op1 > lim) lim = irx->op1; while (ref > lim) { IRIns *ir = IR(ref); if (ir->op1 == irx->op1 && ir->op2 == add2->op1) return fwd_ahload(J, ref); ref = ir->prev; } } } return 0; } /* ALOAD forwarding. */ TRef LJ_FASTCALL lj_opt_fwd_aload(jit_State *J) { IRRef ref; if ((ref = fwd_ahload(J, fins->op1)) || (ref = fwd_aload_reassoc(J))) return ref; return EMITFOLD; } /* HLOAD forwarding. */ TRef LJ_FASTCALL lj_opt_fwd_hload(jit_State *J) { IRRef ref = fwd_ahload(J, fins->op1); if (ref) return ref; return EMITFOLD; } /* HREFK forwarding. */ TRef LJ_FASTCALL lj_opt_fwd_hrefk(jit_State *J) { IRRef tab = fleft->op1; IRRef ref = J->chain[IR_NEWREF]; while (ref > tab) { IRIns *newref = IR(ref); if (tab == newref->op1) { if (fright->op1 == newref->op2) return ref; /* Forward from NEWREF. */ else goto docse; } else if (aa_table(J, tab, newref->op1) != ALIAS_NO) { goto docse; } ref = newref->prev; } /* No conflicting NEWREF: key location unchanged for HREFK of TDUP. */ if (IR(tab)->o == IR_TDUP) fins->t.irt &= ~IRT_GUARD; /* Drop HREFK guard. */ docse: return CSEFOLD; } /* Check whether HREF of TNEW/TDUP can be folded to niltv. */ int LJ_FASTCALL lj_opt_fwd_href_nokey(jit_State *J) { IRRef lim = fins->op1; /* Search limit. */ IRRef ref; /* The key for an ASTORE may end up in the hash part after a NEWREF. */ if (irt_isnum(fright->t) && J->chain[IR_NEWREF] > lim) { ref = J->chain[IR_ASTORE]; while (ref > lim) { if (ref < J->chain[IR_NEWREF]) return 0; /* Conflict. */ ref = IR(ref)->prev; } } /* Search for conflicting stores. */ ref = J->chain[IR_HSTORE]; while (ref > lim) { IRIns *store = IR(ref); if (aa_ahref(J, fins, IR(store->op1)) != ALIAS_NO) return 0; /* Conflict. */ ref = store->prev; } return 1; /* No conflict. Can fold to niltv. */ } /* Check whether there's no aliasing NEWREF for the left operand. */ int LJ_FASTCALL lj_opt_fwd_tptr(jit_State *J, IRRef lim) { IRRef ta = fins->op1; IRRef ref = J->chain[IR_NEWREF]; while (ref > lim) { IRIns *newref = IR(ref); if (ta == newref->op1 || aa_table(J, ta, newref->op1) != ALIAS_NO) return 0; /* Conflict. */ ref = newref->prev; } return 1; /* No conflict. Can safely FOLD/CSE. */ } /* ASTORE/HSTORE elimination. */ TRef LJ_FASTCALL lj_opt_dse_ahstore(jit_State *J) { IRRef xref = fins->op1; /* xREF reference. */ IRRef val = fins->op2; /* Stored value reference. */ IRIns *xr = IR(xref); IRRef1 *refp = &J->chain[fins->o]; IRRef ref = *refp; while (ref > xref) { /* Search for redundant or conflicting stores. */ IRIns *store = IR(ref); switch (aa_ahref(J, xr, IR(store->op1))) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: /* Store to MAYBE the same location. */ if (store->op2 != val) /* Conflict if the value is different. */ goto doemit; break; /* Otherwise continue searching. */ case ALIAS_MUST: /* Store to the same location. */ if (store->op2 == val) /* Same value: drop the new store. */ return DROPFOLD; /* Different value: try to eliminate the redundant store. */ if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ IRIns *ir; /* Check for any intervening guards (includes conflicting loads). */ for (ir = IR(J->cur.nins-1); ir > store; ir--) if (irt_isguard(ir->t)) goto doemit; /* No elimination possible. */ /* Remove redundant store from chain and replace with NOP. */ *refp = store->prev; store->o = IR_NOP; store->t.irt = IRT_NIL; store->op1 = store->op2 = 0; store->prev = 0; /* Now emit the new store instead. */ } goto doemit; } ref = *(refp = &store->prev); } doemit: return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ } /* -- ULOAD forwarding ---------------------------------------------------- */ /* The current alias analysis for upvalues is very simplistic. It only ** disambiguates between the unique upvalues of the same function. ** This is good enough for now, since most upvalues are read-only. ** ** A more precise analysis would be feasible with the help of the parser: ** generate a unique key for every upvalue, even across all prototypes. ** Lacking a realistic use-case, it's unclear whether this is beneficial. */ static AliasRet aa_uref(IRIns *refa, IRIns *refb) { if (refa->o != refb->o) return ALIAS_NO; /* Different UREFx type. */ if (refa->op1 == refb->op1) { /* Same function. */ if (refa->op2 == refb->op2) return ALIAS_MUST; /* Same function, same upvalue idx. */ else return ALIAS_NO; /* Same function, different upvalue idx. */ } else { /* Different functions, check disambiguation hash values. */ if (((refa->op2 ^ refb->op2) & 0xff)) return ALIAS_NO; /* Upvalues with different hash values cannot alias. */ else return ALIAS_MAY; /* No conclusion can be drawn for same hash value. */ } } /* ULOAD forwarding. */ TRef LJ_FASTCALL lj_opt_fwd_uload(jit_State *J) { IRRef uref = fins->op1; IRRef lim = uref; /* Search limit. */ IRIns *xr = IR(uref); IRRef ref; /* Search for conflicting stores. */ ref = J->chain[IR_USTORE]; while (ref > uref) { IRIns *store = IR(ref); switch (aa_uref(xr, IR(store->op1))) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ case ALIAS_MUST: return store->op2; /* Store forwarding. */ } ref = store->prev; } cselim: /* Try to find a matching load. Below the conflicting store, if any. */ return lj_opt_cselim(J, lim); } /* USTORE elimination. */ TRef LJ_FASTCALL lj_opt_dse_ustore(jit_State *J) { IRRef xref = fins->op1; /* xREF reference. */ IRRef val = fins->op2; /* Stored value reference. */ IRIns *xr = IR(xref); IRRef1 *refp = &J->chain[IR_USTORE]; IRRef ref = *refp; while (ref > xref) { /* Search for redundant or conflicting stores. */ IRIns *store = IR(ref); switch (aa_uref(xr, IR(store->op1))) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: /* Store to MAYBE the same location. */ if (store->op2 != val) /* Conflict if the value is different. */ goto doemit; break; /* Otherwise continue searching. */ case ALIAS_MUST: /* Store to the same location. */ if (store->op2 == val) /* Same value: drop the new store. */ return DROPFOLD; /* Different value: try to eliminate the redundant store. */ if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ IRIns *ir; /* Check for any intervening guards (includes conflicting loads). */ for (ir = IR(J->cur.nins-1); ir > store; ir--) if (irt_isguard(ir->t)) goto doemit; /* No elimination possible. */ /* Remove redundant store from chain and replace with NOP. */ *refp = store->prev; store->o = IR_NOP; store->t.irt = IRT_NIL; store->op1 = store->op2 = 0; store->prev = 0; if (ref+1 < J->cur.nins && store[1].o == IR_OBAR && store[1].op1 == xref) { IRRef1 *bp = &J->chain[IR_OBAR]; IRIns *obar; for (obar = IR(*bp); *bp > ref+1; obar = IR(*bp)) bp = &obar->prev; /* Remove OBAR, too. */ *bp = obar->prev; obar->o = IR_NOP; obar->t.irt = IRT_NIL; obar->op1 = obar->op2 = 0; obar->prev = 0; } /* Now emit the new store instead. */ } goto doemit; } ref = *(refp = &store->prev); } doemit: return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ } /* -- FLOAD forwarding and FSTORE elimination ----------------------------- */ /* Alias analysis for field access. ** Field loads are cheap and field stores are rare. ** Simple disambiguation based on field types is good enough. */ static AliasRet aa_fref(jit_State *J, IRIns *refa, IRIns *refb) { if (refa->op2 != refb->op2) return ALIAS_NO; /* Different fields. */ if (refa->op1 == refb->op1) return ALIAS_MUST; /* Same field, same object. */ else if (refa->op2 >= IRFL_TAB_META && refa->op2 <= IRFL_TAB_NOMM) return aa_table(J, refa->op1, refb->op1); /* Disambiguate tables. */ else return ALIAS_MAY; /* Same field, possibly different object. */ } /* Only the loads for mutable fields end up here (see FOLD). */ TRef LJ_FASTCALL lj_opt_fwd_fload(jit_State *J) { IRRef oref = fins->op1; /* Object reference. */ IRRef fid = fins->op2; /* Field ID. */ IRRef lim = oref; /* Search limit. */ IRRef ref; /* Search for conflicting stores. */ ref = J->chain[IR_FSTORE]; while (ref > oref) { IRIns *store = IR(ref); switch (aa_fref(J, fins, IR(store->op1))) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ case ALIAS_MUST: return store->op2; /* Store forwarding. */ } ref = store->prev; } /* No conflicting store: const-fold field loads from allocations. */ if (fid == IRFL_TAB_META) { IRIns *ir = IR(oref); if (ir->o == IR_TNEW || ir->o == IR_TDUP) return lj_ir_knull(J, IRT_TAB); } cselim: /* Try to find a matching load. Below the conflicting store, if any. */ return lj_opt_cselim(J, lim); } /* FSTORE elimination. */ TRef LJ_FASTCALL lj_opt_dse_fstore(jit_State *J) { IRRef fref = fins->op1; /* FREF reference. */ IRRef val = fins->op2; /* Stored value reference. */ IRIns *xr = IR(fref); IRRef1 *refp = &J->chain[IR_FSTORE]; IRRef ref = *refp; while (ref > fref) { /* Search for redundant or conflicting stores. */ IRIns *store = IR(ref); switch (aa_fref(J, xr, IR(store->op1))) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: if (store->op2 != val) /* Conflict if the value is different. */ goto doemit; break; /* Otherwise continue searching. */ case ALIAS_MUST: if (store->op2 == val) /* Same value: drop the new store. */ return DROPFOLD; /* Different value: try to eliminate the redundant store. */ if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ IRIns *ir; /* Check for any intervening guards or conflicting loads. */ for (ir = IR(J->cur.nins-1); ir > store; ir--) if (irt_isguard(ir->t) || (ir->o == IR_FLOAD && ir->op2 == xr->op2)) goto doemit; /* No elimination possible. */ /* Remove redundant store from chain and replace with NOP. */ *refp = store->prev; store->o = IR_NOP; store->t.irt = IRT_NIL; store->op1 = store->op2 = 0; store->prev = 0; /* Now emit the new store instead. */ } goto doemit; } ref = *(refp = &store->prev); } doemit: return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ } /* -- XLOAD forwarding and XSTORE elimination ----------------------------- */ /* Find cdata allocation for a reference (if any). */ static IRIns *aa_findcnew(jit_State *J, IRIns *ir) { while (ir->o == IR_ADD) { if (!irref_isk(ir->op1)) { IRIns *ir1 = aa_findcnew(J, IR(ir->op1)); /* Left-recursion. */ if (ir1) return ir1; } if (irref_isk(ir->op2)) return NULL; ir = IR(ir->op2); /* Flatten right-recursion. */ } return ir->o == IR_CNEW ? ir : NULL; } /* Alias analysis for two cdata allocations. */ static AliasRet aa_cnew(jit_State *J, IRIns *refa, IRIns *refb) { IRIns *cnewa = aa_findcnew(J, refa); IRIns *cnewb = aa_findcnew(J, refb); if (cnewa == cnewb) return ALIAS_MAY; /* Same allocation or neither is an allocation. */ if (cnewa && cnewb) return ALIAS_NO; /* Two different allocations never alias. */ if (cnewb) { cnewa = cnewb; refb = refa; } return aa_escape(J, cnewa, refb); } /* Alias analysis for XLOAD/XSTORE. */ static AliasRet aa_xref(jit_State *J, IRIns *refa, IRIns *xa, IRIns *xb) { ptrdiff_t ofsa = 0, ofsb = 0; IRIns *refb = IR(xb->op1); IRIns *basea = refa, *baseb = refb; if (refa == refb && irt_sametype(xa->t, xb->t)) return ALIAS_MUST; /* Shortcut for same refs with identical type. */ /* Offset-based disambiguation. */ if (refa->o == IR_ADD && irref_isk(refa->op2)) { IRIns *irk = IR(refa->op2); basea = IR(refa->op1); ofsa = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : (ptrdiff_t)irk->i; if (basea == refb && ofsa != 0) return ALIAS_NO; /* base+-ofs vs. base. */ } if (refb->o == IR_ADD && irref_isk(refb->op2)) { IRIns *irk = IR(refb->op2); baseb = IR(refb->op1); ofsb = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : (ptrdiff_t)irk->i; if (refa == baseb && ofsb != 0) return ALIAS_NO; /* base vs. base+-ofs. */ } /* This implements (very) strict aliasing rules. ** Different types do NOT alias, except for differences in signedness. ** Type punning through unions is allowed (but forces a reload). */ if (basea == baseb) { ptrdiff_t sza = irt_size(xa->t), szb = irt_size(xb->t); if (ofsa == ofsb) { if (sza == szb && irt_isfp(xa->t) == irt_isfp(xb->t)) return ALIAS_MUST; /* Same-sized, same-kind. May need to convert. */ } else if (ofsa + sza <= ofsb || ofsb + szb <= ofsa) { return ALIAS_NO; /* Non-overlapping base+-o1 vs. base+-o2. */ } /* NYI: extract, extend or reinterpret bits (int <-> fp). */ return ALIAS_MAY; /* Overlapping or type punning: force reload. */ } if (!irt_sametype(xa->t, xb->t) && !(irt_typerange(xa->t, IRT_I8, IRT_U64) && ((xa->t.irt - IRT_I8) ^ (xb->t.irt - IRT_I8)) == 1)) return ALIAS_NO; /* NYI: structural disambiguation. */ return aa_cnew(J, basea, baseb); /* Try to disambiguate allocations. */ } /* Return CSEd reference or 0. Caveat: swaps lower ref to the right! */ static IRRef reassoc_trycse(jit_State *J, IROp op, IRRef op1, IRRef op2) { IRRef ref = J->chain[op]; IRRef lim = op1; if (op2 > lim) { lim = op2; op2 = op1; op1 = lim; } while (ref > lim) { IRIns *ir = IR(ref); if (ir->op1 == op1 && ir->op2 == op2) return ref; ref = ir->prev; } return 0; } /* Reassociate index references. */ static IRRef reassoc_xref(jit_State *J, IRIns *ir) { ptrdiff_t ofs = 0; if (ir->o == IR_ADD && irref_isk(ir->op2)) { /* Get constant offset. */ IRIns *irk = IR(ir->op2); ofs = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 : (ptrdiff_t)irk->i; ir = IR(ir->op1); } if (ir->o == IR_ADD) { /* Add of base + index. */ /* Index ref > base ref for loop-carried dependences. Only check op1. */ IRIns *ir2, *ir1 = IR(ir->op1); int32_t shift = 0; IRRef idxref; /* Determine index shifts. Don't bother with IR_MUL here. */ if (ir1->o == IR_BSHL && irref_isk(ir1->op2)) shift = IR(ir1->op2)->i; else if (ir1->o == IR_ADD && ir1->op1 == ir1->op2) shift = 1; else ir1 = ir; ir2 = IR(ir1->op1); /* A non-reassociated add. Must be a loop-carried dependence. */ if (ir2->o == IR_ADD && irt_isint(ir2->t) && irref_isk(ir2->op2)) ofs += (ptrdiff_t)IR(ir2->op2)->i << shift; else return 0; idxref = ir2->op1; /* Try to CSE the reassociated chain. Give up if not found. */ if (ir1 != ir && !(idxref = reassoc_trycse(J, ir1->o, idxref, ir1->o == IR_BSHL ? ir1->op2 : idxref))) return 0; if (!(idxref = reassoc_trycse(J, IR_ADD, idxref, ir->op2))) return 0; if (ofs != 0) { IRRef refk = tref_ref(lj_ir_kintp(J, ofs)); if (!(idxref = reassoc_trycse(J, IR_ADD, idxref, refk))) return 0; } return idxref; /* Success, found a reassociated index reference. Phew. */ } return 0; /* Failure. */ } /* XLOAD forwarding. */ TRef LJ_FASTCALL lj_opt_fwd_xload(jit_State *J) { IRRef xref = fins->op1; IRIns *xr = IR(xref); IRRef lim = xref; /* Search limit. */ IRRef ref; if ((fins->op2 & IRXLOAD_READONLY)) goto cselim; if ((fins->op2 & IRXLOAD_VOLATILE)) goto doemit; /* Search for conflicting stores. */ ref = J->chain[IR_XSTORE]; retry: if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; while (ref > lim) { IRIns *store = IR(ref); switch (aa_xref(J, xr, fins, store)) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: lim = ref; goto cselim; /* Limit search for load. */ case ALIAS_MUST: /* Emit conversion if the loaded type doesn't match the forwarded type. */ if (!irt_sametype(fins->t, IR(store->op2)->t)) { IRType st = irt_type(fins->t); if (st == IRT_I8 || st == IRT_I16) { /* Trunc + sign-extend. */ st |= IRCONV_SEXT; } else if (st == IRT_U8 || st == IRT_U16) { /* Trunc + zero-extend. */ } else if (st == IRT_INT) { st = irt_type(IR(store->op2)->t); /* Needs dummy CONV.int.*. */ } else { /* I64/U64 are boxed, U32 is hidden behind a CONV.num.u32. */ goto store_fwd; } fins->ot = IRTI(IR_CONV); fins->op1 = store->op2; fins->op2 = (IRT_INT<<5)|st; return RETRYFOLD; } store_fwd: return store->op2; /* Store forwarding. */ } ref = store->prev; } cselim: /* Try to find a matching load. Below the conflicting store, if any. */ ref = J->chain[IR_XLOAD]; while (ref > lim) { /* CSE for XLOAD depends on the type, but not on the IRXLOAD_* flags. */ if (IR(ref)->op1 == xref && irt_sametype(IR(ref)->t, fins->t)) return ref; ref = IR(ref)->prev; } /* Reassociate XLOAD across PHIs to handle a[i-1] forwarding case. */ if (!(fins->op2 & IRXLOAD_READONLY) && J->chain[IR_LOOP] && xref == fins->op1 && (xref = reassoc_xref(J, xr)) != 0) { ref = J->chain[IR_XSTORE]; while (ref > lim) /* Skip stores that have already been checked. */ ref = IR(ref)->prev; lim = xref; xr = IR(xref); goto retry; /* Retry with the reassociated reference. */ } doemit: return EMITFOLD; } /* XSTORE elimination. */ TRef LJ_FASTCALL lj_opt_dse_xstore(jit_State *J) { IRRef xref = fins->op1; IRIns *xr = IR(xref); IRRef lim = xref; /* Search limit. */ IRRef val = fins->op2; /* Stored value reference. */ IRRef1 *refp = &J->chain[IR_XSTORE]; IRRef ref = *refp; if (J->chain[IR_CALLXS] > lim) lim = J->chain[IR_CALLXS]; if (J->chain[IR_XBAR] > lim) lim = J->chain[IR_XBAR]; while (ref > lim) { /* Search for redundant or conflicting stores. */ IRIns *store = IR(ref); switch (aa_xref(J, xr, fins, store)) { case ALIAS_NO: break; /* Continue searching. */ case ALIAS_MAY: if (store->op2 != val) /* Conflict if the value is different. */ goto doemit; break; /* Otherwise continue searching. */ case ALIAS_MUST: if (store->op2 == val) /* Same value: drop the new store. */ return DROPFOLD; /* Different value: try to eliminate the redundant store. */ if (ref > J->chain[IR_LOOP]) { /* Quick check to avoid crossing LOOP. */ IRIns *ir; /* Check for any intervening guards or any XLOADs (no AA performed). */ for (ir = IR(J->cur.nins-1); ir > store; ir--) if (irt_isguard(ir->t) || ir->o == IR_XLOAD) goto doemit; /* No elimination possible. */ /* Remove redundant store from chain and replace with NOP. */ *refp = store->prev; store->o = IR_NOP; store->t.irt = IRT_NIL; store->op1 = store->op2 = 0; store->prev = 0; /* Now emit the new store instead. */ } goto doemit; } ref = *(refp = &store->prev); } doemit: return EMITFOLD; /* Otherwise we have a conflict or simply no match. */ } /* -- Forwarding of lj_tab_len -------------------------------------------- */ /* This is rather simplistic right now, but better than nothing. */ TRef LJ_FASTCALL lj_opt_fwd_tab_len(jit_State *J) { IRRef tab = fins->op1; /* Table reference. */ IRRef lim = tab; /* Search limit. */ IRRef ref; /* Any ASTORE is a conflict and limits the search. */ if (J->chain[IR_ASTORE] > lim) lim = J->chain[IR_ASTORE]; /* Search for conflicting HSTORE with numeric key. */ ref = J->chain[IR_HSTORE]; while (ref > lim) { IRIns *store = IR(ref); IRIns *href = IR(store->op1); IRIns *key = IR(href->op2); if (irt_isnum(key->o == IR_KSLOT ? IR(key->op1)->t : key->t)) { lim = ref; /* Conflicting store found, limits search for TLEN. */ break; } ref = store->prev; } /* Try to find a matching load. Below the conflicting store, if any. */ return lj_opt_cselim(J, lim); } /* -- ASTORE/HSTORE previous type analysis -------------------------------- */ /* Check whether the previous value for a table store is non-nil. ** This can be derived either from a previous store or from a previous ** load (because all loads from tables perform a type check). ** ** The result of the analysis can be used to avoid the metatable check ** and the guard against HREF returning niltv. Both of these are cheap, ** so let's not spend too much effort on the analysis. ** ** A result of 1 is exact: previous value CANNOT be nil. ** A result of 0 is inexact: previous value MAY be nil. */ int lj_opt_fwd_wasnonnil(jit_State *J, IROpT loadop, IRRef xref) { /* First check stores. */ IRRef ref = J->chain[loadop+IRDELTA_L2S]; while (ref > xref) { IRIns *store = IR(ref); if (store->op1 == xref) { /* Same xREF. */ /* A nil store MAY alias, but a non-nil store MUST alias. */ return !irt_isnil(store->t); } else if (irt_isnil(store->t)) { /* Must check any nil store. */ IRRef skref = IR(store->op1)->op2; IRRef xkref = IR(xref)->op2; /* Same key type MAY alias. Need ALOAD check due to multiple int types. */ if (loadop == IR_ALOAD || irt_sametype(IR(skref)->t, IR(xkref)->t)) { if (skref == xkref || !irref_isk(skref) || !irref_isk(xkref)) return 0; /* A nil store with same const key or var key MAY alias. */ /* Different const keys CANNOT alias. */ } /* Different key types CANNOT alias. */ } /* Other non-nil stores MAY alias. */ ref = store->prev; } /* Check loads since nothing could be derived from stores. */ ref = J->chain[loadop]; while (ref > xref) { IRIns *load = IR(ref); if (load->op1 == xref) { /* Same xREF. */ /* A nil load MAY alias, but a non-nil load MUST alias. */ return !irt_isnil(load->t); } /* Other non-nil loads MAY alias. */ ref = load->prev; } return 0; /* Nothing derived at all, previous value MAY be nil. */ } /* ------------------------------------------------------------------------ */ #undef IR #undef fins #undef fleft #undef fright #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_opt_narrow.c ================================================ /* ** NARROW: Narrowing of numbers to integers (double to int32_t). ** STRIPOV: Stripping of overflow checks. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_opt_narrow_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_bc.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_iropt.h" #include "lj_trace.h" #include "lj_vm.h" #include "lj_strscan.h" /* Rationale for narrowing optimizations: ** ** Lua has only a single number type and this is a FP double by default. ** Narrowing doubles to integers does not pay off for the interpreter on a ** current-generation x86/x64 machine. Most FP operations need the same ** amount of execution resources as their integer counterparts, except ** with slightly longer latencies. Longer latencies are a non-issue for ** the interpreter, since they are usually hidden by other overhead. ** ** The total CPU execution bandwidth is the sum of the bandwidth of the FP ** and the integer units, because they execute in parallel. The FP units ** have an equal or higher bandwidth than the integer units. Not using ** them means losing execution bandwidth. Moving work away from them to ** the already quite busy integer units is a losing proposition. ** ** The situation for JIT-compiled code is a bit different: the higher code ** density makes the extra latencies much more visible. Tight loops expose ** the latencies for updating the induction variables. Array indexing ** requires narrowing conversions with high latencies and additional ** guards (to check that the index is really an integer). And many common ** optimizations only work on integers. ** ** One solution would be speculative, eager narrowing of all number loads. ** This causes many problems, like losing -0 or the need to resolve type ** mismatches between traces. It also effectively forces the integer type ** to have overflow-checking semantics. This impedes many basic ** optimizations and requires adding overflow checks to all integer ** arithmetic operations (whereas FP arithmetics can do without). ** ** Always replacing an FP op with an integer op plus an overflow check is ** counter-productive on a current-generation super-scalar CPU. Although ** the overflow check branches are highly predictable, they will clog the ** execution port for the branch unit and tie up reorder buffers. This is ** turning a pure data-flow dependency into a different data-flow ** dependency (with slightly lower latency) *plus* a control dependency. ** In general, you don't want to do this since latencies due to data-flow ** dependencies can be well hidden by out-of-order execution. ** ** A better solution is to keep all numbers as FP values and only narrow ** when it's beneficial to do so. LuaJIT uses predictive narrowing for ** induction variables and demand-driven narrowing for index expressions, ** integer arguments and bit operations. Additionally it can eliminate or ** hoist most of the resulting overflow checks. Regular arithmetic ** computations are never narrowed to integers. ** ** The integer type in the IR has convenient wrap-around semantics and ** ignores overflow. Extra operations have been added for ** overflow-checking arithmetic (ADDOV/SUBOV) instead of an extra type. ** Apart from reducing overall complexity of the compiler, this also ** nicely solves the problem where you want to apply algebraic ** simplifications to ADD, but not to ADDOV. And the x86/x64 assembler can ** use lea instead of an add for integer ADD, but not for ADDOV (lea does ** not affect the flags, but it helps to avoid register moves). ** ** ** All of the above has to be reconsidered for architectures with slow FP ** operations or without a hardware FPU. The dual-number mode of LuaJIT ** addresses this issue. Arithmetic operations are performed on integers ** as far as possible and overflow checks are added as needed. ** ** This implies that narrowing for integer arguments and bit operations ** should also strip overflow checks, e.g. replace ADDOV with ADD. The ** original overflow guards are weak and can be eliminated by DCE, if ** there's no other use. ** ** A slight twist is that it's usually beneficial to use overflow-checked ** integer arithmetics if all inputs are already integers. This is the only ** change that affects the single-number mode, too. */ /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) #define fins (&J->fold.ins) /* Pass IR on to next optimization in chain (FOLD). */ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) #define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) /* -- Elimination of narrowing type conversions --------------------------- */ /* Narrowing of index expressions and bit operations is demand-driven. The ** trace recorder emits a narrowing type conversion (CONV.int.num or TOBIT) ** in all of these cases (e.g. array indexing or string indexing). FOLD ** already takes care of eliminating simple redundant conversions like ** CONV.int.num(CONV.num.int(x)) ==> x. ** ** But the surrounding code is FP-heavy and arithmetic operations are ** performed on FP numbers (for the single-number mode). Consider a common ** example such as 'x=t[i+1]', with 'i' already an integer (due to induction ** variable narrowing). The index expression would be recorded as ** CONV.int.num(ADD(CONV.num.int(i), 1)) ** which is clearly suboptimal. ** ** One can do better by recursively backpropagating the narrowing type ** conversion across FP arithmetic operations. This turns FP ops into ** their corresponding integer counterparts. Depending on the semantics of ** the conversion they also need to check for overflow. Currently only ADD ** and SUB are supported. ** ** The above example can be rewritten as ** ADDOV(CONV.int.num(CONV.num.int(i)), 1) ** and then into ADDOV(i, 1) after folding of the conversions. The original ** FP ops remain in the IR and are eliminated by DCE since all references to ** them are gone. ** ** [In dual-number mode the trace recorder already emits ADDOV etc., but ** this can be further reduced. See below.] ** ** Special care has to be taken to avoid narrowing across an operation ** which is potentially operating on non-integral operands. One obvious ** case is when an expression contains a non-integral constant, but ends ** up as an integer index at runtime (like t[x+1.5] with x=0.5). ** ** Operations with two non-constant operands illustrate a similar problem ** (like t[a+b] with a=1.5 and b=2.5). Backpropagation has to stop there, ** unless it can be proven that either operand is integral (e.g. by CSEing ** a previous conversion). As a not-so-obvious corollary this logic also ** applies for a whole expression tree (e.g. t[(a+1)+(b+1)]). ** ** Correctness of the transformation is guaranteed by avoiding to expand ** the tree by adding more conversions than the one we would need to emit ** if not backpropagating. TOBIT employs a more optimistic rule, because ** the conversion has special semantics, designed to make the life of the ** compiler writer easier. ;-) ** ** Using on-the-fly backpropagation of an expression tree doesn't work ** because it's unknown whether the transform is correct until the end. ** This either requires IR rollback and cache invalidation for every ** subtree or a two-pass algorithm. The former didn't work out too well, ** so the code now combines a recursive collector with a stack-based ** emitter. ** ** [A recursive backpropagation algorithm with backtracking, employing ** skip-list lookup and round-robin caching, emitting stack operations ** on-the-fly for a stack-based interpreter -- and all of that in a meager ** kilobyte? Yep, compilers are a great treasure chest. Throw away your ** textbooks and read the codebase of a compiler today!] ** ** There's another optimization opportunity for array indexing: it's ** always accompanied by an array bounds-check. The outermost overflow ** check may be delegated to the ABC operation. This works because ABC is ** an unsigned comparison and wrap-around due to overflow creates negative ** numbers. ** ** But this optimization is only valid for constants that cannot overflow ** an int32_t into the range of valid array indexes [0..2^27+1). A check ** for +-2^30 is safe since -2^31 - 2^30 wraps to 2^30 and 2^31-1 + 2^30 ** wraps to -2^30-1. ** ** It's also good enough in practice, since e.g. t[i+1] or t[i-10] are ** quite common. So the above example finally ends up as ADD(i, 1)! ** ** Later on, the assembler is able to fuse the whole array reference and ** the ADD into the memory operands of loads and other instructions. This ** is why LuaJIT is able to generate very pretty (and fast) machine code ** for array indexing. And that, my dear, concludes another story about ** one of the hidden secrets of LuaJIT ... */ /* Maximum backpropagation depth and maximum stack size. */ #define NARROW_MAX_BACKPROP 100 #define NARROW_MAX_STACK 256 /* The stack machine has a 32 bit instruction format: [IROpT | IRRef1] ** The lower 16 bits hold a reference (or 0). The upper 16 bits hold ** the IR opcode + type or one of the following special opcodes: */ enum { NARROW_REF, /* Push ref. */ NARROW_CONV, /* Push conversion of ref. */ NARROW_SEXT, /* Push sign-extension of ref. */ NARROW_INT /* Push KINT ref. The next code holds an int32_t. */ }; typedef uint32_t NarrowIns; #define NARROWINS(op, ref) (((op) << 16) + (ref)) #define narrow_op(ins) ((IROpT)((ins) >> 16)) #define narrow_ref(ins) ((IRRef1)(ins)) /* Context used for narrowing of type conversions. */ typedef struct NarrowConv { jit_State *J; /* JIT compiler state. */ NarrowIns *sp; /* Current stack pointer. */ NarrowIns *maxsp; /* Maximum stack pointer minus redzone. */ int lim; /* Limit on the number of emitted conversions. */ IRRef mode; /* Conversion mode (IRCONV_*). */ IRType t; /* Destination type: IRT_INT or IRT_I64. */ NarrowIns stack[NARROW_MAX_STACK]; /* Stack holding stack-machine code. */ } NarrowConv; /* Lookup a reference in the backpropagation cache. */ static BPropEntry *narrow_bpc_get(jit_State *J, IRRef1 key, IRRef mode) { ptrdiff_t i; for (i = 0; i < BPROP_SLOTS; i++) { BPropEntry *bp = &J->bpropcache[i]; /* Stronger checks are ok, too. */ if (bp->key == key && bp->mode >= mode && ((bp->mode ^ mode) & IRCONV_MODEMASK) == 0) return bp; } return NULL; } /* Add an entry to the backpropagation cache. */ static void narrow_bpc_set(jit_State *J, IRRef1 key, IRRef1 val, IRRef mode) { uint32_t slot = J->bpropslot; BPropEntry *bp = &J->bpropcache[slot]; J->bpropslot = (slot + 1) & (BPROP_SLOTS-1); bp->key = key; bp->val = val; bp->mode = mode; } /* Backpropagate overflow stripping. */ static void narrow_stripov_backprop(NarrowConv *nc, IRRef ref, int depth) { jit_State *J = nc->J; IRIns *ir = IR(ref); if (ir->o == IR_ADDOV || ir->o == IR_SUBOV || (ir->o == IR_MULOV && (nc->mode & IRCONV_CONVMASK) == IRCONV_ANY)) { BPropEntry *bp = narrow_bpc_get(nc->J, ref, IRCONV_TOBIT); if (bp) { ref = bp->val; } else if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { narrow_stripov_backprop(nc, ir->op1, depth); narrow_stripov_backprop(nc, ir->op2, depth); *nc->sp++ = NARROWINS(IRT(ir->o - IR_ADDOV + IR_ADD, IRT_INT), ref); return; } } *nc->sp++ = NARROWINS(NARROW_REF, ref); } /* Backpropagate narrowing conversion. Return number of needed conversions. */ static int narrow_conv_backprop(NarrowConv *nc, IRRef ref, int depth) { jit_State *J = nc->J; IRIns *ir = IR(ref); IRRef cref; /* Check the easy cases first. */ if (ir->o == IR_CONV && (ir->op2 & IRCONV_SRCMASK) == IRT_INT) { if ((nc->mode & IRCONV_CONVMASK) <= IRCONV_ANY) narrow_stripov_backprop(nc, ir->op1, depth+1); else *nc->sp++ = NARROWINS(NARROW_REF, ir->op1); /* Undo conversion. */ if (nc->t == IRT_I64) *nc->sp++ = NARROWINS(NARROW_SEXT, 0); /* Sign-extend integer. */ return 0; } else if (ir->o == IR_KNUM) { /* Narrow FP constant. */ lua_Number n = ir_knum(ir)->n; if ((nc->mode & IRCONV_CONVMASK) == IRCONV_TOBIT) { /* Allows a wider range of constants. */ int64_t k64 = (int64_t)n; if (n == (lua_Number)k64) { /* Only if const doesn't lose precision. */ *nc->sp++ = NARROWINS(NARROW_INT, 0); *nc->sp++ = (NarrowIns)k64; /* But always truncate to 32 bits. */ return 0; } } else { int32_t k = lj_num2int(n); /* Only if constant is a small integer. */ if (checki16(k) && n == (lua_Number)k) { *nc->sp++ = NARROWINS(NARROW_INT, 0); *nc->sp++ = (NarrowIns)k; return 0; } } return 10; /* Never narrow other FP constants (this is rare). */ } /* Try to CSE the conversion. Stronger checks are ok, too. */ cref = J->chain[fins->o]; while (cref > ref) { IRIns *cr = IR(cref); if (cr->op1 == ref && (fins->o == IR_TOBIT || ((cr->op2 & IRCONV_MODEMASK) == (nc->mode & IRCONV_MODEMASK) && irt_isguard(cr->t) >= irt_isguard(fins->t)))) { *nc->sp++ = NARROWINS(NARROW_REF, cref); return 0; /* Already there, no additional conversion needed. */ } cref = cr->prev; } /* Backpropagate across ADD/SUB. */ if (ir->o == IR_ADD || ir->o == IR_SUB) { /* Try cache lookup first. */ IRRef mode = nc->mode; BPropEntry *bp; /* Inner conversions need a stronger check. */ if ((mode & IRCONV_CONVMASK) == IRCONV_INDEX && depth > 0) mode += IRCONV_CHECK-IRCONV_INDEX; bp = narrow_bpc_get(nc->J, (IRRef1)ref, mode); if (bp) { *nc->sp++ = NARROWINS(NARROW_REF, bp->val); return 0; } else if (nc->t == IRT_I64) { /* Try sign-extending from an existing (checked) conversion to int. */ mode = (IRT_INT<<5)|IRT_NUM|IRCONV_INDEX; bp = narrow_bpc_get(nc->J, (IRRef1)ref, mode); if (bp) { *nc->sp++ = NARROWINS(NARROW_REF, bp->val); *nc->sp++ = NARROWINS(NARROW_SEXT, 0); return 0; } } if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { NarrowIns *savesp = nc->sp; int count = narrow_conv_backprop(nc, ir->op1, depth); count += narrow_conv_backprop(nc, ir->op2, depth); if (count <= nc->lim) { /* Limit total number of conversions. */ *nc->sp++ = NARROWINS(IRT(ir->o, nc->t), ref); return count; } nc->sp = savesp; /* Too many conversions, need to backtrack. */ } } /* Otherwise add a conversion. */ *nc->sp++ = NARROWINS(NARROW_CONV, ref); return 1; } /* Emit the conversions collected during backpropagation. */ static IRRef narrow_conv_emit(jit_State *J, NarrowConv *nc) { /* The fins fields must be saved now -- emitir() overwrites them. */ IROpT guardot = irt_isguard(fins->t) ? IRTG(IR_ADDOV-IR_ADD, 0) : 0; IROpT convot = fins->ot; IRRef1 convop2 = fins->op2; NarrowIns *next = nc->stack; /* List of instructions from backpropagation. */ NarrowIns *last = nc->sp; NarrowIns *sp = nc->stack; /* Recycle the stack to store operands. */ while (next < last) { /* Simple stack machine to process the ins. list. */ NarrowIns ref = *next++; IROpT op = narrow_op(ref); if (op == NARROW_REF) { *sp++ = ref; } else if (op == NARROW_CONV) { *sp++ = emitir_raw(convot, ref, convop2); /* Raw emit avoids a loop. */ } else if (op == NARROW_SEXT) { lua_assert(sp >= nc->stack+1); sp[-1] = emitir(IRT(IR_CONV, IRT_I64), sp[-1], (IRT_I64<<5)|IRT_INT|IRCONV_SEXT); } else if (op == NARROW_INT) { lua_assert(next < last); *sp++ = nc->t == IRT_I64 ? lj_ir_kint64(J, (int64_t)(int32_t)*next++) : lj_ir_kint(J, *next++); } else { /* Regular IROpT. Pops two operands and pushes one result. */ IRRef mode = nc->mode; lua_assert(sp >= nc->stack+2); sp--; /* Omit some overflow checks for array indexing. See comments above. */ if ((mode & IRCONV_CONVMASK) == IRCONV_INDEX) { if (next == last && irref_isk(narrow_ref(sp[0])) && (uint32_t)IR(narrow_ref(sp[0]))->i + 0x40000000u < 0x80000000u) guardot = 0; else /* Otherwise cache a stronger check. */ mode += IRCONV_CHECK-IRCONV_INDEX; } sp[-1] = emitir(op+guardot, sp[-1], sp[0]); /* Add to cache. */ if (narrow_ref(ref)) narrow_bpc_set(J, narrow_ref(ref), narrow_ref(sp[-1]), mode); } } lua_assert(sp == nc->stack+1); return nc->stack[0]; } /* Narrow a type conversion of an arithmetic operation. */ TRef LJ_FASTCALL lj_opt_narrow_convert(jit_State *J) { if ((J->flags & JIT_F_OPT_NARROW)) { NarrowConv nc; nc.J = J; nc.sp = nc.stack; nc.maxsp = &nc.stack[NARROW_MAX_STACK-4]; nc.t = irt_type(fins->t); if (fins->o == IR_TOBIT) { nc.mode = IRCONV_TOBIT; /* Used only in the backpropagation cache. */ nc.lim = 2; /* TOBIT can use a more optimistic rule. */ } else { nc.mode = fins->op2; nc.lim = 1; } if (narrow_conv_backprop(&nc, fins->op1, 0) <= nc.lim) return narrow_conv_emit(J, &nc); } return NEXTFOLD; } /* -- Narrowing of implicit conversions ----------------------------------- */ /* Recursively strip overflow checks. */ static TRef narrow_stripov(jit_State *J, TRef tr, int lastop, IRRef mode) { IRRef ref = tref_ref(tr); IRIns *ir = IR(ref); int op = ir->o; if (op >= IR_ADDOV && op <= lastop) { BPropEntry *bp = narrow_bpc_get(J, ref, mode); if (bp) { return TREF(bp->val, irt_t(IR(bp->val)->t)); } else { IRRef op1 = ir->op1, op2 = ir->op2; /* The IR may be reallocated. */ op1 = narrow_stripov(J, op1, lastop, mode); op2 = narrow_stripov(J, op2, lastop, mode); tr = emitir(IRT(op - IR_ADDOV + IR_ADD, ((mode & IRCONV_DSTMASK) >> IRCONV_DSH)), op1, op2); narrow_bpc_set(J, ref, tref_ref(tr), mode); } } else if (LJ_64 && (mode & IRCONV_SEXT) && !irt_is64(ir->t)) { tr = emitir(IRT(IR_CONV, IRT_INTP), tr, mode); } return tr; } /* Narrow array index. */ TRef LJ_FASTCALL lj_opt_narrow_index(jit_State *J, TRef tr) { IRIns *ir; lua_assert(tref_isnumber(tr)); if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ return emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_INDEX); /* Omit some overflow checks for array indexing. See comments above. */ ir = IR(tref_ref(tr)); if ((ir->o == IR_ADDOV || ir->o == IR_SUBOV) && irref_isk(ir->op2) && (uint32_t)IR(ir->op2)->i + 0x40000000u < 0x80000000u) return emitir(IRTI(ir->o - IR_ADDOV + IR_ADD), ir->op1, ir->op2); return tr; } /* Narrow conversion to integer operand (overflow undefined). */ TRef LJ_FASTCALL lj_opt_narrow_toint(jit_State *J, TRef tr) { if (tref_isstr(tr)) tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ return emitir(IRTI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_ANY); if (!tref_isinteger(tr)) lj_trace_err(J, LJ_TRERR_BADTYPE); /* ** Undefined overflow semantics allow stripping of ADDOV, SUBOV and MULOV. ** Use IRCONV_TOBIT for the cache entries, since the semantics are the same. */ return narrow_stripov(J, tr, IR_MULOV, (IRT_INT<<5)|IRT_INT|IRCONV_TOBIT); } /* Narrow conversion to bitop operand (overflow wrapped). */ TRef LJ_FASTCALL lj_opt_narrow_tobit(jit_State *J, TRef tr) { if (tref_isstr(tr)) tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0); if (tref_isnum(tr)) /* Conversion may be narrowed, too. See above. */ return emitir(IRTI(IR_TOBIT), tr, lj_ir_knum_tobit(J)); if (!tref_isinteger(tr)) lj_trace_err(J, LJ_TRERR_BADTYPE); /* ** Wrapped overflow semantics allow stripping of ADDOV and SUBOV. ** MULOV cannot be stripped due to precision widening. */ return narrow_stripov(J, tr, IR_SUBOV, (IRT_INT<<5)|IRT_INT|IRCONV_TOBIT); } #if LJ_HASFFI /* Narrow C array index (overflow undefined). */ TRef LJ_FASTCALL lj_opt_narrow_cindex(jit_State *J, TRef tr) { lua_assert(tref_isnumber(tr)); if (tref_isnum(tr)) return emitir(IRT(IR_CONV, IRT_INTP), tr, (IRT_INTP<<5)|IRT_NUM|IRCONV_TRUNC|IRCONV_ANY); /* Undefined overflow semantics allow stripping of ADDOV, SUBOV and MULOV. */ return narrow_stripov(J, tr, IR_MULOV, LJ_64 ? ((IRT_INTP<<5)|IRT_INT|IRCONV_SEXT) : ((IRT_INTP<<5)|IRT_INT|IRCONV_TOBIT)); } #endif /* -- Narrowing of arithmetic operators ----------------------------------- */ /* Check whether a number fits into an int32_t (-0 is ok, too). */ static int numisint(lua_Number n) { return (n == (lua_Number)lj_num2int(n)); } /* Narrowing of arithmetic operations. */ TRef lj_opt_narrow_arith(jit_State *J, TRef rb, TRef rc, TValue *vb, TValue *vc, IROp op) { if (tref_isstr(rb)) { rb = emitir(IRTG(IR_STRTO, IRT_NUM), rb, 0); lj_strscan_num(strV(vb), vb); } if (tref_isstr(rc)) { rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); lj_strscan_num(strV(vc), vc); } /* Must not narrow MUL in non-DUALNUM variant, because it loses -0. */ if ((op >= IR_ADD && op <= (LJ_DUALNUM ? IR_MUL : IR_SUB)) && tref_isinteger(rb) && tref_isinteger(rc) && numisint(lj_vm_foldarith(numberVnum(vb), numberVnum(vc), (int)op - (int)IR_ADD))) return emitir(IRTGI((int)op - (int)IR_ADD + (int)IR_ADDOV), rb, rc); if (!tref_isnum(rb)) rb = emitir(IRTN(IR_CONV), rb, IRCONV_NUM_INT); if (!tref_isnum(rc)) rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); return emitir(IRTN(op), rb, rc); } /* Narrowing of unary minus operator. */ TRef lj_opt_narrow_unm(jit_State *J, TRef rc, TValue *vc) { if (tref_isstr(rc)) { rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); lj_strscan_num(strV(vc), vc); } if (tref_isinteger(rc)) { if ((uint32_t)numberVint(vc) != 0x80000000u) return emitir(IRTGI(IR_SUBOV), lj_ir_kint(J, 0), rc); rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); } return emitir(IRTN(IR_NEG), rc, lj_ir_knum_neg(J)); } /* Narrowing of modulo operator. */ TRef lj_opt_narrow_mod(jit_State *J, TRef rb, TRef rc, TValue *vc) { TRef tmp; if (tvisstr(vc) && !lj_strscan_num(strV(vc), vc)) lj_trace_err(J, LJ_TRERR_BADTYPE); if ((LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) && tref_isinteger(rb) && tref_isinteger(rc) && (tvisint(vc) ? intV(vc) != 0 : !tviszero(vc))) { emitir(IRTGI(IR_NE), rc, lj_ir_kint(J, 0)); return emitir(IRTI(IR_MOD), rb, rc); } /* b % c ==> b - floor(b/c)*c */ rb = lj_ir_tonum(J, rb); rc = lj_ir_tonum(J, rc); tmp = emitir(IRTN(IR_DIV), rb, rc); tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_FLOOR); tmp = emitir(IRTN(IR_MUL), tmp, rc); return emitir(IRTN(IR_SUB), rb, tmp); } /* Narrowing of power operator or math.pow. */ TRef lj_opt_narrow_pow(jit_State *J, TRef rb, TRef rc, TValue *vc) { if (tvisstr(vc) && !lj_strscan_num(strV(vc), vc)) lj_trace_err(J, LJ_TRERR_BADTYPE); /* Narrowing must be unconditional to preserve (-x)^i semantics. */ if (tvisint(vc) || numisint(numV(vc))) { int checkrange = 0; /* Split pow is faster for bigger exponents. But do this only for (+k)^i. */ if (tref_isk(rb) && (int32_t)ir_knum(IR(tref_ref(rb)))->u32.hi >= 0) { int32_t k = numberVint(vc); if (!(k >= -65536 && k <= 65536)) goto split_pow; checkrange = 1; } if (!tref_isinteger(rc)) { if (tref_isstr(rc)) rc = emitir(IRTG(IR_STRTO, IRT_NUM), rc, 0); /* Guarded conversion to integer! */ rc = emitir(IRTGI(IR_CONV), rc, IRCONV_INT_NUM|IRCONV_CHECK); } if (checkrange && !tref_isk(rc)) { /* Range guard: -65536 <= i <= 65536 */ TRef tmp = emitir(IRTI(IR_ADD), rc, lj_ir_kint(J, 65536)); emitir(IRTGI(IR_ULE), tmp, lj_ir_kint(J, 2*65536)); } return emitir(IRTN(IR_POW), rb, rc); } split_pow: /* FOLD covers most cases, but some are easier to do here. */ if (tref_isk(rb) && tvispone(ir_knum(IR(tref_ref(rb))))) return rb; /* 1 ^ x ==> 1 */ rc = lj_ir_tonum(J, rc); if (tref_isk(rc) && ir_knum(IR(tref_ref(rc)))->n == 0.5) return emitir(IRTN(IR_FPMATH), rb, IRFPM_SQRT); /* x ^ 0.5 ==> sqrt(x) */ /* Split up b^c into exp2(c*log2(b)). Assembler may rejoin later. */ rb = emitir(IRTN(IR_FPMATH), rb, IRFPM_LOG2); rc = emitir(IRTN(IR_MUL), rb, rc); return emitir(IRTN(IR_FPMATH), rc, IRFPM_EXP2); } /* -- Predictive narrowing of induction variables ------------------------- */ /* Narrow a single runtime value. */ static int narrow_forl(jit_State *J, cTValue *o) { if (tvisint(o)) return 1; if (LJ_DUALNUM || (J->flags & JIT_F_OPT_NARROW)) return numisint(numV(o)); return 0; } /* Narrow the FORL index type by looking at the runtime values. */ IRType lj_opt_narrow_forl(jit_State *J, cTValue *tv) { lua_assert(tvisnumber(&tv[FORL_IDX]) && tvisnumber(&tv[FORL_STOP]) && tvisnumber(&tv[FORL_STEP])); /* Narrow only if the runtime values of start/stop/step are all integers. */ if (narrow_forl(J, &tv[FORL_IDX]) && narrow_forl(J, &tv[FORL_STOP]) && narrow_forl(J, &tv[FORL_STEP])) { /* And if the loop index can't possibly overflow. */ lua_Number step = numberVnum(&tv[FORL_STEP]); lua_Number sum = numberVnum(&tv[FORL_STOP]) + step; if (0 <= step ? (sum <= 2147483647.0) : (sum >= -2147483648.0)) return IRT_INT; } return IRT_NUM; } #undef IR #undef fins #undef emitir #undef emitir_raw #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_opt_sink.c ================================================ /* ** SINK: Allocation Sinking and Store Sinking. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_opt_sink_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_ir.h" #include "lj_jit.h" #include "lj_iropt.h" #include "lj_target.h" /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) /* Check whether the store ref points to an eligible allocation. */ static IRIns *sink_checkalloc(jit_State *J, IRIns *irs) { IRIns *ir = IR(irs->op1); if (!irref_isk(ir->op2)) return NULL; /* Non-constant key. */ if (ir->o == IR_HREFK || ir->o == IR_AREF) ir = IR(ir->op1); else if (!(ir->o == IR_HREF || ir->o == IR_NEWREF || ir->o == IR_FREF || ir->o == IR_ADD)) return NULL; /* Unhandled reference type (for XSTORE). */ ir = IR(ir->op1); if (!(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW)) return NULL; /* Not an allocation. */ return ir; /* Return allocation. */ } /* Recursively check whether a value depends on a PHI. */ static int sink_phidep(jit_State *J, IRRef ref) { IRIns *ir = IR(ref); if (irt_isphi(ir->t)) return 1; if (ir->op1 >= REF_FIRST && sink_phidep(J, ir->op1)) return 1; if (ir->op2 >= REF_FIRST && sink_phidep(J, ir->op2)) return 1; return 0; } /* Check whether a value is a sinkable PHI or loop-invariant. */ static int sink_checkphi(jit_State *J, IRIns *ira, IRRef ref) { if (ref >= REF_FIRST) { IRIns *ir = IR(ref); if (irt_isphi(ir->t) || (ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT && irt_isphi(IR(ir->op1)->t))) { ira->prev++; return 1; /* Sinkable PHI. */ } /* Otherwise the value must be loop-invariant. */ return ref < J->loopref && !sink_phidep(J, ref); } return 1; /* Constant (non-PHI). */ } /* Mark non-sinkable allocations using single-pass backward propagation. ** ** Roots for the marking process are: ** - Some PHIs or snapshots (see below). ** - Non-PHI, non-constant values stored to PHI allocations. ** - All guards. ** - Any remaining loads not eliminated by store-to-load forwarding. ** - Stores with non-constant keys. ** - All stored values. */ static void sink_mark_ins(jit_State *J) { IRIns *ir, *irlast = IR(J->cur.nins-1); for (ir = irlast ; ; ir--) { switch (ir->o) { case IR_BASE: return; /* Finished. */ case IR_CALLL: /* IRCALL_lj_tab_len */ case IR_ALOAD: case IR_HLOAD: case IR_XLOAD: case IR_TBAR: irt_setmark(IR(ir->op1)->t); /* Mark ref for remaining loads. */ break; case IR_FLOAD: if (irt_ismarked(ir->t) || ir->op2 == IRFL_TAB_META) irt_setmark(IR(ir->op1)->t); /* Mark table for remaining loads. */ break; case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: { IRIns *ira = sink_checkalloc(J, ir); if (!ira || (irt_isphi(ira->t) && !sink_checkphi(J, ira, ir->op2))) irt_setmark(IR(ir->op1)->t); /* Mark ineligible ref. */ irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ break; } #if LJ_HASFFI case IR_CNEWI: if (irt_isphi(ir->t) && (!sink_checkphi(J, ir, ir->op2) || (LJ_32 && ir+1 < irlast && (ir+1)->o == IR_HIOP && !sink_checkphi(J, ir, (ir+1)->op2)))) irt_setmark(ir->t); /* Mark ineligible allocation. */ /* fallthrough */ #endif case IR_USTORE: irt_setmark(IR(ir->op2)->t); /* Mark stored value. */ break; #if LJ_HASFFI case IR_CALLXS: #endif case IR_CALLS: irt_setmark(IR(ir->op1)->t); /* Mark (potentially) stored values. */ break; case IR_PHI: { IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); irl->prev = irr->prev = 0; /* Clear PHI value counts. */ if (irl->o == irr->o && (irl->o == IR_TNEW || irl->o == IR_TDUP || (LJ_HASFFI && (irl->o == IR_CNEW || irl->o == IR_CNEWI)))) break; irt_setmark(irl->t); irt_setmark(irr->t); break; } default: if (irt_ismarked(ir->t) || irt_isguard(ir->t)) { /* Propagate mark. */ if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); } break; } } } /* Mark all instructions referenced by a snapshot. */ static void sink_mark_snap(jit_State *J, SnapShot *snap) { SnapEntry *map = &J->cur.snapmap[snap->mapofs]; MSize n, nent = snap->nent; for (n = 0; n < nent; n++) { IRRef ref = snap_ref(map[n]); if (!irref_isk(ref)) irt_setmark(IR(ref)->t); } } /* Iteratively remark PHI refs with differing marks or PHI value counts. */ static void sink_remark_phi(jit_State *J) { IRIns *ir; int remark; do { remark = 0; for (ir = IR(J->cur.nins-1); ir->o == IR_PHI; ir--) { IRIns *irl = IR(ir->op1), *irr = IR(ir->op2); if (((irl->t.irt ^ irr->t.irt) & IRT_MARK)) remark = 1; else if (irl->prev == irr->prev) continue; irt_setmark(IR(ir->op1)->t); irt_setmark(IR(ir->op2)->t); } } while (remark); } /* Sweep instructions and tag sunken allocations and stores. */ static void sink_sweep_ins(jit_State *J) { IRIns *ir, *irfirst = IR(J->cur.nk); for (ir = IR(J->cur.nins-1) ; ir >= irfirst; ir--) { switch (ir->o) { case IR_ASTORE: case IR_HSTORE: case IR_FSTORE: case IR_XSTORE: { IRIns *ira = sink_checkalloc(J, ir); if (ira && !irt_ismarked(ira->t)) { int delta = (int)(ir - ira); ir->prev = REGSP(RID_SINK, delta > 255 ? 255 : delta); } else { ir->prev = REGSP_INIT; } break; } case IR_NEWREF: if (!irt_ismarked(IR(ir->op1)->t)) { ir->prev = REGSP(RID_SINK, 0); } else { irt_clearmark(ir->t); ir->prev = REGSP_INIT; } break; #if LJ_HASFFI case IR_CNEW: case IR_CNEWI: #endif case IR_TNEW: case IR_TDUP: if (!irt_ismarked(ir->t)) { ir->t.irt &= ~IRT_GUARD; ir->prev = REGSP(RID_SINK, 0); J->cur.sinktags = 1; /* Signal present SINK tags to assembler. */ } else { irt_clearmark(ir->t); ir->prev = REGSP_INIT; } break; case IR_PHI: { IRIns *ira = IR(ir->op2); if (!irt_ismarked(ira->t) && (ira->o == IR_TNEW || ira->o == IR_TDUP || (LJ_HASFFI && (ira->o == IR_CNEW || ira->o == IR_CNEWI)))) { ir->prev = REGSP(RID_SINK, 0); } else { ir->prev = REGSP_INIT; } break; } default: irt_clearmark(ir->t); ir->prev = REGSP_INIT; break; } } } /* Allocation sinking and store sinking. ** ** 1. Mark all non-sinkable allocations. ** 2. Then sink all remaining allocations and the related stores. */ void lj_opt_sink(jit_State *J) { const uint32_t need = (JIT_F_OPT_SINK|JIT_F_OPT_FWD| JIT_F_OPT_DCE|JIT_F_OPT_CSE|JIT_F_OPT_FOLD); if ((J->flags & need) == need && (J->chain[IR_TNEW] || J->chain[IR_TDUP] || (LJ_HASFFI && (J->chain[IR_CNEW] || J->chain[IR_CNEWI])))) { if (!J->loopref) sink_mark_snap(J, &J->cur.snap[J->cur.nsnap-1]); sink_mark_ins(J); if (J->loopref) sink_remark_phi(J); sink_sweep_ins(J); } } #undef IR #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_opt_split.c ================================================ /* ** SPLIT: Split 64 bit IR instructions into 32 bit IR instructions. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_opt_split_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT && (LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) #include "lj_err.h" #include "lj_str.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_ircall.h" #include "lj_iropt.h" #include "lj_vm.h" /* SPLIT pass: ** ** This pass splits up 64 bit IR instructions into multiple 32 bit IR ** instructions. It's only active for soft-float targets or for 32 bit CPUs ** which lack native 64 bit integer operations (the FFI is currently the ** only emitter for 64 bit integer instructions). ** ** Splitting the IR in a separate pass keeps each 32 bit IR assembler ** backend simple. Only a small amount of extra functionality needs to be ** implemented. This is much easier than adding support for allocating ** register pairs to each backend (believe me, I tried). A few simple, but ** important optimizations can be performed by the SPLIT pass, which would ** be tedious to do in the backend. ** ** The basic idea is to replace each 64 bit IR instruction with its 32 bit ** equivalent plus an extra HIOP instruction. The splitted IR is not passed ** through FOLD or any other optimizations, so each HIOP is guaranteed to ** immediately follow it's counterpart. The actual functionality of HIOP is ** inferred from the previous instruction. ** ** The operands of HIOP hold the hiword input references. The output of HIOP ** is the hiword output reference, which is also used to hold the hiword ** register or spill slot information. The register allocator treats this ** instruction independently of any other instruction, which improves code ** quality compared to using fixed register pairs. ** ** It's easier to split up some instructions into two regular 32 bit ** instructions. E.g. XLOAD is split up into two XLOADs with two different ** addresses. Obviously 64 bit constants need to be split up into two 32 bit ** constants, too. Some hiword instructions can be entirely omitted, e.g. ** when zero-extending a 32 bit value to 64 bits. 64 bit arguments for calls ** are split up into two 32 bit arguments each. ** ** On soft-float targets, floating-point instructions are directly converted ** to soft-float calls by the SPLIT pass (except for comparisons and MIN/MAX). ** HIOP for number results has the type IRT_SOFTFP ("sfp" in -jdump). ** ** Here's the IR and x64 machine code for 'x.b = x.a + 1' for a struct with ** two int64_t fields: ** ** 0100 p32 ADD base +8 ** 0101 i64 XLOAD 0100 ** 0102 i64 ADD 0101 +1 ** 0103 p32 ADD base +16 ** 0104 i64 XSTORE 0103 0102 ** ** mov rax, [esi+0x8] ** add rax, +0x01 ** mov [esi+0x10], rax ** ** Here's the transformed IR and the x86 machine code after the SPLIT pass: ** ** 0100 p32 ADD base +8 ** 0101 int XLOAD 0100 ** 0102 p32 ADD base +12 ** 0103 int XLOAD 0102 ** 0104 int ADD 0101 +1 ** 0105 int HIOP 0103 +0 ** 0106 p32 ADD base +16 ** 0107 int XSTORE 0106 0104 ** 0108 int HIOP 0106 0105 ** ** mov eax, [esi+0x8] ** mov ecx, [esi+0xc] ** add eax, +0x01 ** adc ecx, +0x00 ** mov [esi+0x10], eax ** mov [esi+0x14], ecx ** ** You may notice the reassociated hiword address computation, which is ** later fused into the mov operands by the assembler. */ /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) /* Directly emit the transformed IR without updating chains etc. */ static IRRef split_emit(jit_State *J, uint16_t ot, IRRef1 op1, IRRef1 op2) { IRRef nref = lj_ir_nextins(J); IRIns *ir = IR(nref); ir->ot = ot; ir->op1 = op1; ir->op2 = op2; return nref; } #if LJ_SOFTFP /* Emit a (checked) number to integer conversion. */ static IRRef split_num2int(jit_State *J, IRRef lo, IRRef hi, int check) { IRRef tmp, res; #if LJ_LE tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), lo, hi); #else tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hi, lo); #endif res = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_softfp_d2i); if (check) { tmp = split_emit(J, IRTI(IR_CALLN), res, IRCALL_softfp_i2d); split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); split_emit(J, IRTGI(IR_EQ), tmp, lo); split_emit(J, IRTG(IR_HIOP, IRT_SOFTFP), tmp+1, hi); } return res; } /* Emit a CALLN with one split 64 bit argument. */ static IRRef split_call_l(jit_State *J, IRRef1 *hisubst, IRIns *oir, IRIns *ir, IRCallID id) { IRRef tmp, op1 = ir->op1; J->cur.nins--; #if LJ_LE tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); #else tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); #endif ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); return split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); } /* Emit a CALLN with one split 64 bit argument and a 32 bit argument. */ static IRRef split_call_li(jit_State *J, IRRef1 *hisubst, IRIns *oir, IRIns *ir, IRCallID id) { IRRef tmp, op1 = ir->op1, op2 = ir->op2; J->cur.nins--; #if LJ_LE tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); #else tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); #endif tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); return split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); } #endif /* Emit a CALLN with two split 64 bit arguments. */ static IRRef split_call_ll(jit_State *J, IRRef1 *hisubst, IRIns *oir, IRIns *ir, IRCallID id) { IRRef tmp, op1 = ir->op1, op2 = ir->op2; J->cur.nins--; #if LJ_LE tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, hisubst[op2]); #else tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, hisubst[op2]); tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, oir[op2].prev); #endif ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, id); return split_emit(J, IRT(IR_HIOP, (LJ_SOFTFP && irt_isnum(ir->t)) ? IRT_SOFTFP : IRT_INT), tmp, tmp); } /* Get a pointer to the other 32 bit word (LE: hiword, BE: loword). */ static IRRef split_ptr(jit_State *J, IRIns *oir, IRRef ref) { IRRef nref = oir[ref].prev; IRIns *ir = IR(nref); int32_t ofs = 4; if (ir->o == IR_KPTR) return lj_ir_kptr(J, (char *)ir_kptr(ir) + ofs); if (ir->o == IR_ADD && irref_isk(ir->op2) && !irt_isphi(oir[ref].t)) { /* Reassociate address. */ ofs += IR(ir->op2)->i; nref = ir->op1; if (ofs == 0) return nref; } return split_emit(J, IRTI(IR_ADD), nref, lj_ir_kint(J, ofs)); } /* Transform the old IR to the new IR. */ static void split_ir(jit_State *J) { IRRef nins = J->cur.nins, nk = J->cur.nk; MSize irlen = nins - nk; MSize need = (irlen+1)*(sizeof(IRIns) + sizeof(IRRef1)); IRIns *oir = (IRIns *)lj_str_needbuf(J->L, &G(J->L)->tmpbuf, need); IRRef1 *hisubst; IRRef ref; /* Copy old IR to buffer. */ memcpy(oir, IR(nk), irlen*sizeof(IRIns)); /* Bias hiword substitution table and old IR. Loword kept in field prev. */ hisubst = (IRRef1 *)&oir[irlen] - nk; oir -= nk; /* Remove all IR instructions, but retain IR constants. */ J->cur.nins = REF_FIRST; J->loopref = 0; /* Process constants and fixed references. */ for (ref = nk; ref <= REF_BASE; ref++) { IRIns *ir = &oir[ref]; if ((LJ_SOFTFP && ir->o == IR_KNUM) || ir->o == IR_KINT64) { /* Split up 64 bit constant. */ TValue tv = *ir_k64(ir); ir->prev = lj_ir_kint(J, (int32_t)tv.u32.lo); hisubst[ref] = lj_ir_kint(J, (int32_t)tv.u32.hi); } else { ir->prev = ref; /* Identity substitution for loword. */ hisubst[ref] = 0; } } /* Process old IR instructions. */ for (ref = REF_FIRST; ref < nins; ref++) { IRIns *ir = &oir[ref]; IRRef nref = lj_ir_nextins(J); IRIns *nir = IR(nref); IRRef hi = 0; /* Copy-substitute old instruction to new instruction. */ nir->op1 = ir->op1 < nk ? ir->op1 : oir[ir->op1].prev; nir->op2 = ir->op2 < nk ? ir->op2 : oir[ir->op2].prev; ir->prev = nref; /* Loword substitution. */ nir->o = ir->o; nir->t.irt = ir->t.irt & ~(IRT_MARK|IRT_ISPHI); hisubst[ref] = 0; /* Split 64 bit instructions. */ #if LJ_SOFTFP if (irt_isnum(ir->t)) { nir->t.irt = IRT_INT | (nir->t.irt & IRT_GUARD); /* Turn into INT op. */ /* Note: hi ref = lo ref + 1! Required for SNAP_SOFTFPNUM logic. */ switch (ir->o) { case IR_ADD: hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_add); break; case IR_SUB: hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_sub); break; case IR_MUL: hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_mul); break; case IR_DIV: hi = split_call_ll(J, hisubst, oir, ir, IRCALL_softfp_div); break; case IR_POW: hi = split_call_li(J, hisubst, oir, ir, IRCALL_lj_vm_powi); break; case IR_FPMATH: /* Try to rejoin pow from EXP2, MUL and LOG2. */ if (nir->op2 == IRFPM_EXP2 && nir->op1 > J->loopref) { IRIns *irp = IR(nir->op1); if (irp->o == IR_CALLN && irp->op2 == IRCALL_softfp_mul) { IRIns *irm4 = IR(irp->op1); IRIns *irm3 = IR(irm4->op1); IRIns *irm12 = IR(irm3->op1); IRIns *irl1 = IR(irm12->op1); if (irm12->op1 > J->loopref && irl1->o == IR_CALLN && irl1->op2 == IRCALL_lj_vm_log2) { IRRef tmp = irl1->op1; /* Recycle first two args from LOG2. */ IRRef arg3 = irm3->op2, arg4 = irm4->op2; J->cur.nins--; tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, arg3); tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), tmp, arg4); ir->prev = tmp = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_pow); hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), tmp, tmp); break; } } } hi = split_call_l(J, hisubst, oir, ir, IRCALL_lj_vm_floor + ir->op2); break; case IR_ATAN2: hi = split_call_ll(J, hisubst, oir, ir, IRCALL_atan2); break; case IR_LDEXP: hi = split_call_li(J, hisubst, oir, ir, IRCALL_ldexp); break; case IR_NEG: case IR_ABS: nir->o = IR_CONV; /* Pass through loword. */ nir->op2 = (IRT_INT << 5) | IRT_INT; hi = split_emit(J, IRT(ir->o == IR_NEG ? IR_BXOR : IR_BAND, IRT_SOFTFP), hisubst[ir->op1], hisubst[ir->op2]); break; case IR_SLOAD: if ((nir->op2 & IRSLOAD_CONVERT)) { /* Convert from int to number. */ nir->op2 &= ~IRSLOAD_CONVERT; ir->prev = nref = split_emit(J, IRTI(IR_CALLN), nref, IRCALL_softfp_i2d); hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); break; } /* fallthrough */ case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: case IR_STRTO: hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); break; case IR_XLOAD: { IRIns inslo = *nir; /* Save/undo the emit of the lo XLOAD. */ J->cur.nins--; hi = split_ptr(J, oir, ir->op1); /* Insert the hiref ADD. */ nref = lj_ir_nextins(J); nir = IR(nref); *nir = inslo; /* Re-emit lo XLOAD immediately before hi XLOAD. */ hi = split_emit(J, IRT(IR_XLOAD, IRT_SOFTFP), hi, ir->op2); #if LJ_LE ir->prev = nref; #else ir->prev = hi; hi = nref; #endif break; } case IR_ASTORE: case IR_HSTORE: case IR_USTORE: case IR_XSTORE: split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nir->op1, hisubst[ir->op2]); break; case IR_CONV: { /* Conversion to number. Others handled below. */ IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); UNUSED(st); #if LJ_32 && LJ_HASFFI if (st == IRT_I64 || st == IRT_U64) { hi = split_call_l(J, hisubst, oir, ir, st == IRT_I64 ? IRCALL_fp64_l2d : IRCALL_fp64_ul2d); break; } #endif lua_assert(st == IRT_INT || (LJ_32 && LJ_HASFFI && (st == IRT_U32 || st == IRT_FLOAT))); nir->o = IR_CALLN; #if LJ_32 && LJ_HASFFI nir->op2 = st == IRT_INT ? IRCALL_softfp_i2d : st == IRT_FLOAT ? IRCALL_softfp_f2d : IRCALL_softfp_ui2d; #else nir->op2 = IRCALL_softfp_i2d; #endif hi = split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); break; } case IR_CALLN: case IR_CALLL: case IR_CALLS: case IR_CALLXS: goto split_call; case IR_PHI: if (nir->op1 == nir->op2) J->cur.nins--; /* Drop useless PHIs. */ if (hisubst[ir->op1] != hisubst[ir->op2]) split_emit(J, IRT(IR_PHI, IRT_SOFTFP), hisubst[ir->op1], hisubst[ir->op2]); break; case IR_HIOP: J->cur.nins--; /* Drop joining HIOP. */ ir->prev = nir->op1; hi = nir->op2; break; default: lua_assert(ir->o <= IR_NE || ir->o == IR_MIN || ir->o == IR_MAX); hi = split_emit(J, IRTG(IR_HIOP, IRT_SOFTFP), hisubst[ir->op1], hisubst[ir->op2]); break; } } else #endif #if LJ_32 && LJ_HASFFI if (irt_isint64(ir->t)) { IRRef hiref = hisubst[ir->op1]; nir->t.irt = IRT_INT | (nir->t.irt & IRT_GUARD); /* Turn into INT op. */ switch (ir->o) { case IR_ADD: case IR_SUB: /* Use plain op for hiword if loword cannot produce a carry/borrow. */ if (irref_isk(nir->op2) && IR(nir->op2)->i == 0) { ir->prev = nir->op1; /* Pass through loword. */ nir->op1 = hiref; nir->op2 = hisubst[ir->op2]; hi = nref; break; } /* fallthrough */ case IR_NEG: hi = split_emit(J, IRTI(IR_HIOP), hiref, hisubst[ir->op2]); break; case IR_MUL: hi = split_call_ll(J, hisubst, oir, ir, IRCALL_lj_carith_mul64); break; case IR_DIV: hi = split_call_ll(J, hisubst, oir, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_divi64 : IRCALL_lj_carith_divu64); break; case IR_MOD: hi = split_call_ll(J, hisubst, oir, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_modi64 : IRCALL_lj_carith_modu64); break; case IR_POW: hi = split_call_ll(J, hisubst, oir, ir, irt_isi64(ir->t) ? IRCALL_lj_carith_powi64 : IRCALL_lj_carith_powu64); break; case IR_FLOAD: lua_assert(ir->op2 == IRFL_CDATA_INT64); hi = split_emit(J, IRTI(IR_FLOAD), nir->op1, IRFL_CDATA_INT64_4); #if LJ_BE ir->prev = hi; hi = nref; #endif break; case IR_XLOAD: hi = split_emit(J, IRTI(IR_XLOAD), split_ptr(J, oir, ir->op1), ir->op2); #if LJ_BE ir->prev = hi; hi = nref; #endif break; case IR_XSTORE: split_emit(J, IRTI(IR_HIOP), nir->op1, hisubst[ir->op2]); break; case IR_CONV: { /* Conversion to 64 bit integer. Others handled below. */ IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); #if LJ_SOFTFP if (st == IRT_NUM) { /* NUM to 64 bit int conv. */ hi = split_call_l(J, hisubst, oir, ir, irt_isi64(ir->t) ? IRCALL_fp64_d2l : IRCALL_fp64_d2ul); } else if (st == IRT_FLOAT) { /* FLOAT to 64 bit int conv. */ nir->o = IR_CALLN; nir->op2 = irt_isi64(ir->t) ? IRCALL_fp64_f2l : IRCALL_fp64_f2ul; hi = split_emit(J, IRTI(IR_HIOP), nref, nref); } #else if (st == IRT_NUM || st == IRT_FLOAT) { /* FP to 64 bit int conv. */ hi = split_emit(J, IRTI(IR_HIOP), nir->op1, nref); } #endif else if (st == IRT_I64 || st == IRT_U64) { /* 64/64 bit cast. */ /* Drop cast, since assembler doesn't care. */ goto fwdlo; } else if ((ir->op2 & IRCONV_SEXT)) { /* Sign-extend to 64 bit. */ IRRef k31 = lj_ir_kint(J, 31); nir = IR(nref); /* May have been reallocated. */ ir->prev = nir->op1; /* Pass through loword. */ nir->o = IR_BSAR; /* hi = bsar(lo, 31). */ nir->op2 = k31; hi = nref; } else { /* Zero-extend to 64 bit. */ hi = lj_ir_kint(J, 0); goto fwdlo; } break; } case IR_CALLXS: goto split_call; case IR_PHI: { IRRef hiref2; if ((irref_isk(nir->op1) && irref_isk(nir->op2)) || nir->op1 == nir->op2) J->cur.nins--; /* Drop useless PHIs. */ hiref2 = hisubst[ir->op2]; if (!((irref_isk(hiref) && irref_isk(hiref2)) || hiref == hiref2)) split_emit(J, IRTI(IR_PHI), hiref, hiref2); break; } case IR_HIOP: J->cur.nins--; /* Drop joining HIOP. */ ir->prev = nir->op1; hi = nir->op2; break; default: lua_assert(ir->o <= IR_NE); /* Comparisons. */ split_emit(J, IRTGI(IR_HIOP), hiref, hisubst[ir->op2]); break; } } else #endif #if LJ_SOFTFP if (ir->o == IR_SLOAD) { if ((nir->op2 & IRSLOAD_CONVERT)) { /* Convert from number to int. */ nir->op2 &= ~IRSLOAD_CONVERT; if (!(nir->op2 & IRSLOAD_TYPECHECK)) nir->t.irt = IRT_INT; /* Drop guard. */ split_emit(J, IRT(IR_HIOP, IRT_SOFTFP), nref, nref); ir->prev = split_num2int(J, nref, nref+1, irt_isguard(ir->t)); } } else if (ir->o == IR_TOBIT) { IRRef tmp, op1 = ir->op1; J->cur.nins--; #if LJ_LE tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), oir[op1].prev, hisubst[op1]); #else tmp = split_emit(J, IRT(IR_CARG, IRT_NIL), hisubst[op1], oir[op1].prev); #endif ir->prev = split_emit(J, IRTI(IR_CALLN), tmp, IRCALL_lj_vm_tobit); } else if (ir->o == IR_TOSTR) { if (hisubst[ir->op1]) { if (irref_isk(ir->op1)) nir->op1 = ir->op1; else split_emit(J, IRT(IR_HIOP, IRT_NIL), hisubst[ir->op1], nref); } } else if (ir->o == IR_HREF || ir->o == IR_NEWREF) { if (irref_isk(ir->op2) && hisubst[ir->op2]) nir->op2 = ir->op2; } else #endif if (ir->o == IR_CONV) { /* See above, too. */ IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); #if LJ_32 && LJ_HASFFI if (st == IRT_I64 || st == IRT_U64) { /* Conversion from 64 bit int. */ #if LJ_SOFTFP if (irt_isfloat(ir->t)) { split_call_l(J, hisubst, oir, ir, st == IRT_I64 ? IRCALL_fp64_l2f : IRCALL_fp64_ul2f); J->cur.nins--; /* Drop unused HIOP. */ } #else if (irt_isfp(ir->t)) { /* 64 bit integer to FP conversion. */ ir->prev = split_emit(J, IRT(IR_HIOP, irt_type(ir->t)), hisubst[ir->op1], nref); } #endif else { /* Truncate to lower 32 bits. */ fwdlo: ir->prev = nir->op1; /* Forward loword. */ /* Replace with NOP to avoid messing up the snapshot logic. */ nir->ot = IRT(IR_NOP, IRT_NIL); nir->op1 = nir->op2 = 0; } } #endif #if LJ_SOFTFP && LJ_32 && LJ_HASFFI else if (irt_isfloat(ir->t)) { if (st == IRT_NUM) { split_call_l(J, hisubst, oir, ir, IRCALL_softfp_d2f); J->cur.nins--; /* Drop unused HIOP. */ } else { nir->o = IR_CALLN; nir->op2 = st == IRT_INT ? IRCALL_softfp_i2f : IRCALL_softfp_ui2f; } } else if (st == IRT_FLOAT) { nir->o = IR_CALLN; nir->op2 = irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui; } else #endif #if LJ_SOFTFP if (st == IRT_NUM || (LJ_32 && LJ_HASFFI && st == IRT_FLOAT)) { if (irt_isguard(ir->t)) { lua_assert(st == IRT_NUM && irt_isint(ir->t)); J->cur.nins--; ir->prev = split_num2int(J, nir->op1, hisubst[ir->op1], 1); } else { split_call_l(J, hisubst, oir, ir, #if LJ_32 && LJ_HASFFI st == IRT_NUM ? (irt_isint(ir->t) ? IRCALL_softfp_d2i : IRCALL_softfp_d2ui) : (irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui) #else IRCALL_softfp_d2i #endif ); J->cur.nins--; /* Drop unused HIOP. */ } } #endif } else if (ir->o == IR_CALLXS) { IRRef hiref; split_call: hiref = hisubst[ir->op1]; if (hiref) { IROpT ot = nir->ot; IRRef op2 = nir->op2; nir->ot = IRT(IR_CARG, IRT_NIL); #if LJ_LE nir->op2 = hiref; #else nir->op2 = nir->op1; nir->op1 = hiref; #endif ir->prev = nref = split_emit(J, ot, nref, op2); } if (LJ_SOFTFP ? irt_is64(ir->t) : irt_isint64(ir->t)) hi = split_emit(J, IRT(IR_HIOP, (LJ_SOFTFP && irt_isnum(ir->t)) ? IRT_SOFTFP : IRT_INT), nref, nref); } else if (ir->o == IR_CARG) { IRRef hiref = hisubst[ir->op1]; if (hiref) { IRRef op2 = nir->op2; #if LJ_LE nir->op2 = hiref; #else nir->op2 = nir->op1; nir->op1 = hiref; #endif ir->prev = nref = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, op2); nir = IR(nref); } hiref = hisubst[ir->op2]; if (hiref) { #if !LJ_TARGET_X86 int carg = 0; IRIns *cir; for (cir = IR(nir->op1); cir->o == IR_CARG; cir = IR(cir->op1)) carg++; if ((carg & 1) == 0) { /* Align 64 bit arguments. */ IRRef op2 = nir->op2; nir->op2 = REF_NIL; nref = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, op2); nir = IR(nref); } #endif #if LJ_BE { IRRef tmp = nir->op2; nir->op2 = hiref; hiref = tmp; } #endif ir->prev = split_emit(J, IRT(IR_CARG, IRT_NIL), nref, hiref); } } else if (ir->o == IR_CNEWI) { if (hisubst[ir->op2]) split_emit(J, IRT(IR_HIOP, IRT_NIL), nref, hisubst[ir->op2]); } else if (ir->o == IR_LOOP) { J->loopref = nref; /* Needed by assembler. */ } hisubst[ref] = hi; /* Store hiword substitution. */ } /* Add PHI marks. */ for (ref = J->cur.nins-1; ref >= REF_FIRST; ref--) { IRIns *ir = IR(ref); if (ir->o != IR_PHI) break; if (!irref_isk(ir->op1)) irt_setphi(IR(ir->op1)->t); if (ir->op2 > J->loopref) irt_setphi(IR(ir->op2)->t); } /* Substitute snapshot maps. */ oir[nins].prev = J->cur.nins; /* Substitution for last snapshot. */ { SnapNo i, nsnap = J->cur.nsnap; for (i = 0; i < nsnap; i++) { SnapShot *snap = &J->cur.snap[i]; SnapEntry *map = &J->cur.snapmap[snap->mapofs]; MSize n, nent = snap->nent; snap->ref = snap->ref == REF_FIRST ? REF_FIRST : oir[snap->ref].prev; for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; IRIns *ir = &oir[snap_ref(sn)]; if (!(LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && irref_isk(snap_ref(sn)))) map[n] = ((sn & 0xffff0000) | ir->prev); } } } } /* Protected callback for split pass. */ static TValue *cpsplit(lua_State *L, lua_CFunction dummy, void *ud) { jit_State *J = (jit_State *)ud; split_ir(J); UNUSED(L); UNUSED(dummy); return NULL; } #if defined(LUA_USE_ASSERT) || LJ_SOFTFP /* Slow, but sure way to check whether a SPLIT pass is needed. */ static int split_needsplit(jit_State *J) { IRIns *ir, *irend; IRRef ref; for (ir = IR(REF_FIRST), irend = IR(J->cur.nins); ir < irend; ir++) if (LJ_SOFTFP ? irt_is64orfp(ir->t) : irt_isint64(ir->t)) return 1; if (LJ_SOFTFP) { for (ref = J->chain[IR_SLOAD]; ref; ref = IR(ref)->prev) if ((IR(ref)->op2 & IRSLOAD_CONVERT)) return 1; if (J->chain[IR_TOBIT]) return 1; } for (ref = J->chain[IR_CONV]; ref; ref = IR(ref)->prev) { IRType st = (IR(ref)->op2 & IRCONV_SRCMASK); if ((LJ_SOFTFP && (st == IRT_NUM || st == IRT_FLOAT)) || st == IRT_I64 || st == IRT_U64) return 1; } return 0; /* Nope. */ } #endif /* SPLIT pass. */ void lj_opt_split(jit_State *J) { #if LJ_SOFTFP if (!J->needsplit) J->needsplit = split_needsplit(J); #else lua_assert(J->needsplit >= split_needsplit(J)); /* Verify flag. */ #endif if (J->needsplit) { int errcode = lj_vm_cpcall(J->L, NULL, J, cpsplit); if (errcode) { /* Completely reset the trace to avoid inconsistent dump on abort. */ J->cur.nins = J->cur.nk = REF_BASE; J->cur.nsnap = 0; lj_err_throw(J->L, errcode); /* Propagate errors. */ } } } #undef IR #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_parse.c ================================================ /* ** Lua parser (source code -> bytecode). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lj_parse_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_func.h" #include "lj_state.h" #include "lj_bc.h" #if LJ_HASFFI #include "lj_ctype.h" #endif #include "lj_lex.h" #include "lj_parse.h" #include "lj_vm.h" #include "lj_vmevent.h" /* -- Parser structures and definitions ----------------------------------- */ /* Expression kinds. */ typedef enum { /* Constant expressions must be first and in this order: */ VKNIL, VKFALSE, VKTRUE, VKSTR, /* sval = string value */ VKNUM, /* nval = number value */ VKLAST = VKNUM, VKCDATA, /* nval = cdata value, not treated as a constant expression */ /* Non-constant expressions follow: */ VLOCAL, /* info = local register, aux = vstack index */ VUPVAL, /* info = upvalue index, aux = vstack index */ VGLOBAL, /* sval = string value */ VINDEXED, /* info = table register, aux = index reg/byte/string const */ VJMP, /* info = instruction PC */ VRELOCABLE, /* info = instruction PC */ VNONRELOC, /* info = result register */ VCALL, /* info = instruction PC, aux = base */ VVOID } ExpKind; /* Expression descriptor. */ typedef struct ExpDesc { union { struct { uint32_t info; /* Primary info. */ uint32_t aux; /* Secondary info. */ } s; TValue nval; /* Number value. */ GCstr *sval; /* String value. */ } u; ExpKind k; BCPos t; /* True condition jump list. */ BCPos f; /* False condition jump list. */ } ExpDesc; /* Macros for expressions. */ #define expr_hasjump(e) ((e)->t != (e)->f) #define expr_isk(e) ((e)->k <= VKLAST) #define expr_isk_nojump(e) (expr_isk(e) && !expr_hasjump(e)) #define expr_isnumk(e) ((e)->k == VKNUM) #define expr_isnumk_nojump(e) (expr_isnumk(e) && !expr_hasjump(e)) #define expr_isstrk(e) ((e)->k == VKSTR) #define expr_numtv(e) check_exp(expr_isnumk((e)), &(e)->u.nval) #define expr_numberV(e) numberVnum(expr_numtv((e))) /* Initialize expression. */ static LJ_AINLINE void expr_init(ExpDesc *e, ExpKind k, uint32_t info) { e->k = k; e->u.s.info = info; e->f = e->t = NO_JMP; } /* Check number constant for +-0. */ static int expr_numiszero(ExpDesc *e) { TValue *o = expr_numtv(e); return tvisint(o) ? (intV(o) == 0) : tviszero(o); } /* Per-function linked list of scope blocks. */ typedef struct FuncScope { struct FuncScope *prev; /* Link to outer scope. */ MSize vstart; /* Start of block-local variables. */ uint8_t nactvar; /* Number of active vars outside the scope. */ uint8_t flags; /* Scope flags. */ } FuncScope; #define FSCOPE_LOOP 0x01 /* Scope is a (breakable) loop. */ #define FSCOPE_BREAK 0x02 /* Break used in scope. */ #define FSCOPE_GOLA 0x04 /* Goto or label used in scope. */ #define FSCOPE_UPVAL 0x08 /* Upvalue in scope. */ #define FSCOPE_NOCLOSE 0x10 /* Do not close upvalues. */ #define NAME_BREAK ((GCstr *)(uintptr_t)1) /* Index into variable stack. */ typedef uint16_t VarIndex; #define LJ_MAX_VSTACK (65536 - LJ_MAX_UPVAL) /* Variable/goto/label info. */ #define VSTACK_VAR_RW 0x01 /* R/W variable. */ #define VSTACK_GOTO 0x02 /* Pending goto. */ #define VSTACK_LABEL 0x04 /* Label. */ /* Per-function state. */ typedef struct FuncState { GCtab *kt; /* Hash table for constants. */ LexState *ls; /* Lexer state. */ lua_State *L; /* Lua state. */ FuncScope *bl; /* Current scope. */ struct FuncState *prev; /* Enclosing function. */ BCPos pc; /* Next bytecode position. */ BCPos lasttarget; /* Bytecode position of last jump target. */ BCPos jpc; /* Pending jump list to next bytecode. */ BCReg freereg; /* First free register. */ BCReg nactvar; /* Number of active local variables. */ BCReg nkn, nkgc; /* Number of lua_Number/GCobj constants */ BCLine linedefined; /* First line of the function definition. */ BCInsLine *bcbase; /* Base of bytecode stack. */ BCPos bclim; /* Limit of bytecode stack. */ MSize vbase; /* Base of variable stack for this function. */ uint8_t flags; /* Prototype flags. */ uint8_t numparams; /* Number of parameters. */ uint8_t framesize; /* Fixed frame size. */ uint8_t nuv; /* Number of upvalues */ VarIndex varmap[LJ_MAX_LOCVAR]; /* Map from register to variable idx. */ VarIndex uvmap[LJ_MAX_UPVAL]; /* Map from upvalue to variable idx. */ VarIndex uvtmp[LJ_MAX_UPVAL]; /* Temporary upvalue map. */ } FuncState; /* Binary and unary operators. ORDER OPR */ typedef enum BinOpr { OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, /* ORDER ARITH */ OPR_CONCAT, OPR_NE, OPR_EQ, OPR_LT, OPR_GE, OPR_LE, OPR_GT, OPR_AND, OPR_OR, OPR_NOBINOPR } BinOpr; LJ_STATIC_ASSERT((int)BC_ISGE-(int)BC_ISLT == (int)OPR_GE-(int)OPR_LT); LJ_STATIC_ASSERT((int)BC_ISLE-(int)BC_ISLT == (int)OPR_LE-(int)OPR_LT); LJ_STATIC_ASSERT((int)BC_ISGT-(int)BC_ISLT == (int)OPR_GT-(int)OPR_LT); LJ_STATIC_ASSERT((int)BC_SUBVV-(int)BC_ADDVV == (int)OPR_SUB-(int)OPR_ADD); LJ_STATIC_ASSERT((int)BC_MULVV-(int)BC_ADDVV == (int)OPR_MUL-(int)OPR_ADD); LJ_STATIC_ASSERT((int)BC_DIVVV-(int)BC_ADDVV == (int)OPR_DIV-(int)OPR_ADD); LJ_STATIC_ASSERT((int)BC_MODVV-(int)BC_ADDVV == (int)OPR_MOD-(int)OPR_ADD); /* -- Error handling ------------------------------------------------------ */ LJ_NORET LJ_NOINLINE static void err_syntax(LexState *ls, ErrMsg em) { lj_lex_error(ls, ls->token, em); } LJ_NORET LJ_NOINLINE static void err_token(LexState *ls, LexToken token) { lj_lex_error(ls, ls->token, LJ_ERR_XTOKEN, lj_lex_token2str(ls, token)); } LJ_NORET static void err_limit(FuncState *fs, uint32_t limit, const char *what) { if (fs->linedefined == 0) lj_lex_error(fs->ls, 0, LJ_ERR_XLIMM, limit, what); else lj_lex_error(fs->ls, 0, LJ_ERR_XLIMF, fs->linedefined, limit, what); } #define checklimit(fs, v, l, m) if ((v) >= (l)) err_limit(fs, l, m) #define checklimitgt(fs, v, l, m) if ((v) > (l)) err_limit(fs, l, m) #define checkcond(ls, c, em) { if (!(c)) err_syntax(ls, em); } /* -- Management of constants --------------------------------------------- */ /* Return bytecode encoding for primitive constant. */ #define const_pri(e) check_exp((e)->k <= VKTRUE, (e)->k) #define tvhaskslot(o) ((o)->u32.hi == 0) #define tvkslot(o) ((o)->u32.lo) /* Add a number constant. */ static BCReg const_num(FuncState *fs, ExpDesc *e) { lua_State *L = fs->L; TValue *o; lua_assert(expr_isnumk(e)); o = lj_tab_set(L, fs->kt, &e->u.nval); if (tvhaskslot(o)) return tvkslot(o); o->u64 = fs->nkn; return fs->nkn++; } /* Add a GC object constant. */ static BCReg const_gc(FuncState *fs, GCobj *gc, uint32_t itype) { lua_State *L = fs->L; TValue key, *o; setgcV(L, &key, gc, itype); /* NOBARRIER: the key is new or kept alive. */ o = lj_tab_set(L, fs->kt, &key); if (tvhaskslot(o)) return tvkslot(o); o->u64 = fs->nkgc; return fs->nkgc++; } /* Add a string constant. */ static BCReg const_str(FuncState *fs, ExpDesc *e) { lua_assert(expr_isstrk(e) || e->k == VGLOBAL); return const_gc(fs, obj2gco(e->u.sval), LJ_TSTR); } /* Anchor string constant to avoid GC. */ GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t len) { /* NOBARRIER: the key is new or kept alive. */ lua_State *L = ls->L; GCstr *s = lj_str_new(L, str, len); TValue *tv = lj_tab_setstr(L, ls->fs->kt, s); if (tvisnil(tv)) setboolV(tv, 1); lj_gc_check(L); return s; } #if LJ_HASFFI /* Anchor cdata to avoid GC. */ void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd) { /* NOBARRIER: the key is new or kept alive. */ lua_State *L = ls->L; setcdataV(L, tv, cd); setboolV(lj_tab_set(L, ls->fs->kt, tv), 1); } #endif /* -- Jump list handling -------------------------------------------------- */ /* Get next element in jump list. */ static BCPos jmp_next(FuncState *fs, BCPos pc) { ptrdiff_t delta = bc_j(fs->bcbase[pc].ins); if ((BCPos)delta == NO_JMP) return NO_JMP; else return (BCPos)(((ptrdiff_t)pc+1)+delta); } /* Check if any of the instructions on the jump list produce no value. */ static int jmp_novalue(FuncState *fs, BCPos list) { for (; list != NO_JMP; list = jmp_next(fs, list)) { BCIns p = fs->bcbase[list >= 1 ? list-1 : list].ins; if (!(bc_op(p) == BC_ISTC || bc_op(p) == BC_ISFC || bc_a(p) == NO_REG)) return 1; } return 0; } /* Patch register of test instructions. */ static int jmp_patchtestreg(FuncState *fs, BCPos pc, BCReg reg) { BCInsLine *ilp = &fs->bcbase[pc >= 1 ? pc-1 : pc]; BCOp op = bc_op(ilp->ins); if (op == BC_ISTC || op == BC_ISFC) { if (reg != NO_REG && reg != bc_d(ilp->ins)) { setbc_a(&ilp->ins, reg); } else { /* Nothing to store or already in the right register. */ setbc_op(&ilp->ins, op+(BC_IST-BC_ISTC)); setbc_a(&ilp->ins, 0); } } else if (bc_a(ilp->ins) == NO_REG) { if (reg == NO_REG) { ilp->ins = BCINS_AJ(BC_JMP, bc_a(fs->bcbase[pc].ins), 0); } else { setbc_a(&ilp->ins, reg); if (reg >= bc_a(ilp[1].ins)) setbc_a(&ilp[1].ins, reg+1); } } else { return 0; /* Cannot patch other instructions. */ } return 1; } /* Drop values for all instructions on jump list. */ static void jmp_dropval(FuncState *fs, BCPos list) { for (; list != NO_JMP; list = jmp_next(fs, list)) jmp_patchtestreg(fs, list, NO_REG); } /* Patch jump instruction to target. */ static void jmp_patchins(FuncState *fs, BCPos pc, BCPos dest) { BCIns *jmp = &fs->bcbase[pc].ins; BCPos offset = dest-(pc+1)+BCBIAS_J; lua_assert(dest != NO_JMP); if (offset > BCMAX_D) err_syntax(fs->ls, LJ_ERR_XJUMP); setbc_d(jmp, offset); } /* Append to jump list. */ static void jmp_append(FuncState *fs, BCPos *l1, BCPos l2) { if (l2 == NO_JMP) { return; } else if (*l1 == NO_JMP) { *l1 = l2; } else { BCPos list = *l1; BCPos next; while ((next = jmp_next(fs, list)) != NO_JMP) /* Find last element. */ list = next; jmp_patchins(fs, list, l2); } } /* Patch jump list and preserve produced values. */ static void jmp_patchval(FuncState *fs, BCPos list, BCPos vtarget, BCReg reg, BCPos dtarget) { while (list != NO_JMP) { BCPos next = jmp_next(fs, list); if (jmp_patchtestreg(fs, list, reg)) jmp_patchins(fs, list, vtarget); /* Jump to target with value. */ else jmp_patchins(fs, list, dtarget); /* Jump to default target. */ list = next; } } /* Jump to following instruction. Append to list of pending jumps. */ static void jmp_tohere(FuncState *fs, BCPos list) { fs->lasttarget = fs->pc; jmp_append(fs, &fs->jpc, list); } /* Patch jump list to target. */ static void jmp_patch(FuncState *fs, BCPos list, BCPos target) { if (target == fs->pc) { jmp_tohere(fs, list); } else { lua_assert(target < fs->pc); jmp_patchval(fs, list, target, NO_REG, target); } } /* -- Bytecode register allocator ----------------------------------------- */ /* Bump frame size. */ static void bcreg_bump(FuncState *fs, BCReg n) { BCReg sz = fs->freereg + n; if (sz > fs->framesize) { if (sz >= LJ_MAX_SLOTS) err_syntax(fs->ls, LJ_ERR_XSLOTS); fs->framesize = (uint8_t)sz; } } /* Reserve registers. */ static void bcreg_reserve(FuncState *fs, BCReg n) { bcreg_bump(fs, n); fs->freereg += n; } /* Free register. */ static void bcreg_free(FuncState *fs, BCReg reg) { if (reg >= fs->nactvar) { fs->freereg--; lua_assert(reg == fs->freereg); } } /* Free register for expression. */ static void expr_free(FuncState *fs, ExpDesc *e) { if (e->k == VNONRELOC) bcreg_free(fs, e->u.s.info); } /* -- Bytecode emitter ---------------------------------------------------- */ /* Emit bytecode instruction. */ static BCPos bcemit_INS(FuncState *fs, BCIns ins) { BCPos pc = fs->pc; LexState *ls = fs->ls; jmp_patchval(fs, fs->jpc, pc, NO_REG, pc); fs->jpc = NO_JMP; if (LJ_UNLIKELY(pc >= fs->bclim)) { ptrdiff_t base = fs->bcbase - ls->bcstack; checklimit(fs, ls->sizebcstack, LJ_MAX_BCINS, "bytecode instructions"); lj_mem_growvec(fs->L, ls->bcstack, ls->sizebcstack, LJ_MAX_BCINS,BCInsLine); fs->bclim = (BCPos)(ls->sizebcstack - base); fs->bcbase = ls->bcstack + base; } fs->bcbase[pc].ins = ins; fs->bcbase[pc].line = ls->lastline; fs->pc = pc+1; return pc; } #define bcemit_ABC(fs, o, a, b, c) bcemit_INS(fs, BCINS_ABC(o, a, b, c)) #define bcemit_AD(fs, o, a, d) bcemit_INS(fs, BCINS_AD(o, a, d)) #define bcemit_AJ(fs, o, a, j) bcemit_INS(fs, BCINS_AJ(o, a, j)) #define bcptr(fs, e) (&(fs)->bcbase[(e)->u.s.info].ins) /* -- Bytecode emitter for expressions ------------------------------------ */ /* Discharge non-constant expression to any register. */ static void expr_discharge(FuncState *fs, ExpDesc *e) { BCIns ins; if (e->k == VUPVAL) { ins = BCINS_AD(BC_UGET, 0, e->u.s.info); } else if (e->k == VGLOBAL) { ins = BCINS_AD(BC_GGET, 0, const_str(fs, e)); } else if (e->k == VINDEXED) { BCReg rc = e->u.s.aux; if ((int32_t)rc < 0) { ins = BCINS_ABC(BC_TGETS, 0, e->u.s.info, ~rc); } else if (rc > BCMAX_C) { ins = BCINS_ABC(BC_TGETB, 0, e->u.s.info, rc-(BCMAX_C+1)); } else { bcreg_free(fs, rc); ins = BCINS_ABC(BC_TGETV, 0, e->u.s.info, rc); } bcreg_free(fs, e->u.s.info); } else if (e->k == VCALL) { e->u.s.info = e->u.s.aux; e->k = VNONRELOC; return; } else if (e->k == VLOCAL) { e->k = VNONRELOC; return; } else { return; } e->u.s.info = bcemit_INS(fs, ins); e->k = VRELOCABLE; } /* Emit bytecode to set a range of registers to nil. */ static void bcemit_nil(FuncState *fs, BCReg from, BCReg n) { if (fs->pc > fs->lasttarget) { /* No jumps to current position? */ BCIns *ip = &fs->bcbase[fs->pc-1].ins; BCReg pto, pfrom = bc_a(*ip); switch (bc_op(*ip)) { /* Try to merge with the previous instruction. */ case BC_KPRI: if (bc_d(*ip) != ~LJ_TNIL) break; if (from == pfrom) { if (n == 1) return; } else if (from == pfrom+1) { from = pfrom; n++; } else { break; } *ip = BCINS_AD(BC_KNIL, from, from+n-1); /* Replace KPRI. */ return; case BC_KNIL: pto = bc_d(*ip); if (pfrom <= from && from <= pto+1) { /* Can we connect both ranges? */ if (from+n-1 > pto) setbc_d(ip, from+n-1); /* Patch previous instruction range. */ return; } break; default: break; } } /* Emit new instruction or replace old instruction. */ bcemit_INS(fs, n == 1 ? BCINS_AD(BC_KPRI, from, VKNIL) : BCINS_AD(BC_KNIL, from, from+n-1)); } /* Discharge an expression to a specific register. Ignore branches. */ static void expr_toreg_nobranch(FuncState *fs, ExpDesc *e, BCReg reg) { BCIns ins; expr_discharge(fs, e); if (e->k == VKSTR) { ins = BCINS_AD(BC_KSTR, reg, const_str(fs, e)); } else if (e->k == VKNUM) { #if LJ_DUALNUM cTValue *tv = expr_numtv(e); if (tvisint(tv) && checki16(intV(tv))) ins = BCINS_AD(BC_KSHORT, reg, (BCReg)(uint16_t)intV(tv)); else #else lua_Number n = expr_numberV(e); int32_t k = lj_num2int(n); if (checki16(k) && n == (lua_Number)k) ins = BCINS_AD(BC_KSHORT, reg, (BCReg)(uint16_t)k); else #endif ins = BCINS_AD(BC_KNUM, reg, const_num(fs, e)); #if LJ_HASFFI } else if (e->k == VKCDATA) { fs->flags |= PROTO_FFI; ins = BCINS_AD(BC_KCDATA, reg, const_gc(fs, obj2gco(cdataV(&e->u.nval)), LJ_TCDATA)); #endif } else if (e->k == VRELOCABLE) { setbc_a(bcptr(fs, e), reg); goto noins; } else if (e->k == VNONRELOC) { if (reg == e->u.s.info) goto noins; ins = BCINS_AD(BC_MOV, reg, e->u.s.info); } else if (e->k == VKNIL) { bcemit_nil(fs, reg, 1); goto noins; } else if (e->k <= VKTRUE) { ins = BCINS_AD(BC_KPRI, reg, const_pri(e)); } else { lua_assert(e->k == VVOID || e->k == VJMP); return; } bcemit_INS(fs, ins); noins: e->u.s.info = reg; e->k = VNONRELOC; } /* Forward declaration. */ static BCPos bcemit_jmp(FuncState *fs); /* Discharge an expression to a specific register. */ static void expr_toreg(FuncState *fs, ExpDesc *e, BCReg reg) { expr_toreg_nobranch(fs, e, reg); if (e->k == VJMP) jmp_append(fs, &e->t, e->u.s.info); /* Add it to the true jump list. */ if (expr_hasjump(e)) { /* Discharge expression with branches. */ BCPos jend, jfalse = NO_JMP, jtrue = NO_JMP; if (jmp_novalue(fs, e->t) || jmp_novalue(fs, e->f)) { BCPos jval = (e->k == VJMP) ? NO_JMP : bcemit_jmp(fs); jfalse = bcemit_AD(fs, BC_KPRI, reg, VKFALSE); bcemit_AJ(fs, BC_JMP, fs->freereg, 1); jtrue = bcemit_AD(fs, BC_KPRI, reg, VKTRUE); jmp_tohere(fs, jval); } jend = fs->pc; fs->lasttarget = jend; jmp_patchval(fs, e->f, jend, reg, jfalse); jmp_patchval(fs, e->t, jend, reg, jtrue); } e->f = e->t = NO_JMP; e->u.s.info = reg; e->k = VNONRELOC; } /* Discharge an expression to the next free register. */ static void expr_tonextreg(FuncState *fs, ExpDesc *e) { expr_discharge(fs, e); expr_free(fs, e); bcreg_reserve(fs, 1); expr_toreg(fs, e, fs->freereg - 1); } /* Discharge an expression to any register. */ static BCReg expr_toanyreg(FuncState *fs, ExpDesc *e) { expr_discharge(fs, e); if (e->k == VNONRELOC) { if (!expr_hasjump(e)) return e->u.s.info; /* Already in a register. */ if (e->u.s.info >= fs->nactvar) { expr_toreg(fs, e, e->u.s.info); /* Discharge to temp. register. */ return e->u.s.info; } } expr_tonextreg(fs, e); /* Discharge to next register. */ return e->u.s.info; } /* Partially discharge expression to a value. */ static void expr_toval(FuncState *fs, ExpDesc *e) { if (expr_hasjump(e)) expr_toanyreg(fs, e); else expr_discharge(fs, e); } /* Emit store for LHS expression. */ static void bcemit_store(FuncState *fs, ExpDesc *var, ExpDesc *e) { BCIns ins; if (var->k == VLOCAL) { fs->ls->vstack[var->u.s.aux].info |= VSTACK_VAR_RW; expr_free(fs, e); expr_toreg(fs, e, var->u.s.info); return; } else if (var->k == VUPVAL) { fs->ls->vstack[var->u.s.aux].info |= VSTACK_VAR_RW; expr_toval(fs, e); if (e->k <= VKTRUE) ins = BCINS_AD(BC_USETP, var->u.s.info, const_pri(e)); else if (e->k == VKSTR) ins = BCINS_AD(BC_USETS, var->u.s.info, const_str(fs, e)); else if (e->k == VKNUM) ins = BCINS_AD(BC_USETN, var->u.s.info, const_num(fs, e)); else ins = BCINS_AD(BC_USETV, var->u.s.info, expr_toanyreg(fs, e)); } else if (var->k == VGLOBAL) { BCReg ra = expr_toanyreg(fs, e); ins = BCINS_AD(BC_GSET, ra, const_str(fs, var)); } else { BCReg ra, rc; lua_assert(var->k == VINDEXED); ra = expr_toanyreg(fs, e); rc = var->u.s.aux; if ((int32_t)rc < 0) { ins = BCINS_ABC(BC_TSETS, ra, var->u.s.info, ~rc); } else if (rc > BCMAX_C) { ins = BCINS_ABC(BC_TSETB, ra, var->u.s.info, rc-(BCMAX_C+1)); } else { /* Free late alloced key reg to avoid assert on free of value reg. */ /* This can only happen when called from expr_table(). */ lua_assert(e->k != VNONRELOC || ra < fs->nactvar || rc < ra || (bcreg_free(fs, rc),1)); ins = BCINS_ABC(BC_TSETV, ra, var->u.s.info, rc); } } bcemit_INS(fs, ins); expr_free(fs, e); } /* Emit method lookup expression. */ static void bcemit_method(FuncState *fs, ExpDesc *e, ExpDesc *key) { BCReg idx, func, obj = expr_toanyreg(fs, e); expr_free(fs, e); func = fs->freereg; bcemit_AD(fs, BC_MOV, func+1, obj); /* Copy object to first argument. */ lua_assert(expr_isstrk(key)); idx = const_str(fs, key); if (idx <= BCMAX_C) { bcreg_reserve(fs, 2); bcemit_ABC(fs, BC_TGETS, func, obj, idx); } else { bcreg_reserve(fs, 3); bcemit_AD(fs, BC_KSTR, func+2, idx); bcemit_ABC(fs, BC_TGETV, func, obj, func+2); fs->freereg--; } e->u.s.info = func; e->k = VNONRELOC; } /* -- Bytecode emitter for branches --------------------------------------- */ /* Emit unconditional branch. */ static BCPos bcemit_jmp(FuncState *fs) { BCPos jpc = fs->jpc; BCPos j = fs->pc - 1; BCIns *ip = &fs->bcbase[j].ins; fs->jpc = NO_JMP; if ((int32_t)j >= (int32_t)fs->lasttarget && bc_op(*ip) == BC_UCLO) setbc_j(ip, NO_JMP); else j = bcemit_AJ(fs, BC_JMP, fs->freereg, NO_JMP); jmp_append(fs, &j, jpc); return j; } /* Invert branch condition of bytecode instruction. */ static void invertcond(FuncState *fs, ExpDesc *e) { BCIns *ip = &fs->bcbase[e->u.s.info - 1].ins; setbc_op(ip, bc_op(*ip)^1); } /* Emit conditional branch. */ static BCPos bcemit_branch(FuncState *fs, ExpDesc *e, int cond) { BCPos pc; if (e->k == VRELOCABLE) { BCIns *ip = bcptr(fs, e); if (bc_op(*ip) == BC_NOT) { *ip = BCINS_AD(cond ? BC_ISF : BC_IST, 0, bc_d(*ip)); return bcemit_jmp(fs); } } if (e->k != VNONRELOC) { bcreg_reserve(fs, 1); expr_toreg_nobranch(fs, e, fs->freereg-1); } bcemit_AD(fs, cond ? BC_ISTC : BC_ISFC, NO_REG, e->u.s.info); pc = bcemit_jmp(fs); expr_free(fs, e); return pc; } /* Emit branch on true condition. */ static void bcemit_branch_t(FuncState *fs, ExpDesc *e) { BCPos pc; expr_discharge(fs, e); if (e->k == VKSTR || e->k == VKNUM || e->k == VKTRUE) pc = NO_JMP; /* Never jump. */ else if (e->k == VJMP) invertcond(fs, e), pc = e->u.s.info; else if (e->k == VKFALSE || e->k == VKNIL) expr_toreg_nobranch(fs, e, NO_REG), pc = bcemit_jmp(fs); else pc = bcemit_branch(fs, e, 0); jmp_append(fs, &e->f, pc); jmp_tohere(fs, e->t); e->t = NO_JMP; } /* Emit branch on false condition. */ static void bcemit_branch_f(FuncState *fs, ExpDesc *e) { BCPos pc; expr_discharge(fs, e); if (e->k == VKNIL || e->k == VKFALSE) pc = NO_JMP; /* Never jump. */ else if (e->k == VJMP) pc = e->u.s.info; else if (e->k == VKSTR || e->k == VKNUM || e->k == VKTRUE) expr_toreg_nobranch(fs, e, NO_REG), pc = bcemit_jmp(fs); else pc = bcemit_branch(fs, e, 1); jmp_append(fs, &e->t, pc); jmp_tohere(fs, e->f); e->f = NO_JMP; } /* -- Bytecode emitter for operators -------------------------------------- */ /* Try constant-folding of arithmetic operators. */ static int foldarith(BinOpr opr, ExpDesc *e1, ExpDesc *e2) { TValue o; lua_Number n; if (!expr_isnumk_nojump(e1) || !expr_isnumk_nojump(e2)) return 0; n = lj_vm_foldarith(expr_numberV(e1), expr_numberV(e2), (int)opr-OPR_ADD); setnumV(&o, n); if (tvisnan(&o) || tvismzero(&o)) return 0; /* Avoid NaN and -0 as consts. */ if (LJ_DUALNUM) { int32_t k = lj_num2int(n); if ((lua_Number)k == n) { setintV(&e1->u.nval, k); return 1; } } setnumV(&e1->u.nval, n); return 1; } /* Emit arithmetic operator. */ static void bcemit_arith(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) { BCReg rb, rc, t; uint32_t op; if (foldarith(opr, e1, e2)) return; if (opr == OPR_POW) { op = BC_POW; rc = expr_toanyreg(fs, e2); rb = expr_toanyreg(fs, e1); } else { op = opr-OPR_ADD+BC_ADDVV; /* Must discharge 2nd operand first since VINDEXED might free regs. */ expr_toval(fs, e2); if (expr_isnumk(e2) && (rc = const_num(fs, e2)) <= BCMAX_C) op -= BC_ADDVV-BC_ADDVN; else rc = expr_toanyreg(fs, e2); /* 1st operand discharged by bcemit_binop_left, but need KNUM/KSHORT. */ lua_assert(expr_isnumk(e1) || e1->k == VNONRELOC); expr_toval(fs, e1); /* Avoid two consts to satisfy bytecode constraints. */ if (expr_isnumk(e1) && !expr_isnumk(e2) && (t = const_num(fs, e1)) <= BCMAX_B) { rb = rc; rc = t; op -= BC_ADDVV-BC_ADDNV; } else { rb = expr_toanyreg(fs, e1); } } /* Using expr_free might cause asserts if the order is wrong. */ if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; if (e2->k == VNONRELOC && e2->u.s.info >= fs->nactvar) fs->freereg--; e1->u.s.info = bcemit_ABC(fs, op, 0, rb, rc); e1->k = VRELOCABLE; } /* Emit comparison operator. */ static void bcemit_comp(FuncState *fs, BinOpr opr, ExpDesc *e1, ExpDesc *e2) { ExpDesc *eret = e1; BCIns ins; expr_toval(fs, e1); if (opr == OPR_EQ || opr == OPR_NE) { BCOp op = opr == OPR_EQ ? BC_ISEQV : BC_ISNEV; BCReg ra; if (expr_isk(e1)) { e1 = e2; e2 = eret; } /* Need constant in 2nd arg. */ ra = expr_toanyreg(fs, e1); /* First arg must be in a reg. */ expr_toval(fs, e2); switch (e2->k) { case VKNIL: case VKFALSE: case VKTRUE: ins = BCINS_AD(op+(BC_ISEQP-BC_ISEQV), ra, const_pri(e2)); break; case VKSTR: ins = BCINS_AD(op+(BC_ISEQS-BC_ISEQV), ra, const_str(fs, e2)); break; case VKNUM: ins = BCINS_AD(op+(BC_ISEQN-BC_ISEQV), ra, const_num(fs, e2)); break; default: ins = BCINS_AD(op, ra, expr_toanyreg(fs, e2)); break; } } else { uint32_t op = opr-OPR_LT+BC_ISLT; BCReg ra, rd; if ((op-BC_ISLT) & 1) { /* GT -> LT, GE -> LE */ e1 = e2; e2 = eret; /* Swap operands. */ op = ((op-BC_ISLT)^3)+BC_ISLT; expr_toval(fs, e1); } rd = expr_toanyreg(fs, e2); ra = expr_toanyreg(fs, e1); ins = BCINS_AD(op, ra, rd); } /* Using expr_free might cause asserts if the order is wrong. */ if (e1->k == VNONRELOC && e1->u.s.info >= fs->nactvar) fs->freereg--; if (e2->k == VNONRELOC && e2->u.s.info >= fs->nactvar) fs->freereg--; bcemit_INS(fs, ins); eret->u.s.info = bcemit_jmp(fs); eret->k = VJMP; } /* Fixup left side of binary operator. */ static void bcemit_binop_left(FuncState *fs, BinOpr op, ExpDesc *e) { if (op == OPR_AND) { bcemit_branch_t(fs, e); } else if (op == OPR_OR) { bcemit_branch_f(fs, e); } else if (op == OPR_CONCAT) { expr_tonextreg(fs, e); } else if (op == OPR_EQ || op == OPR_NE) { if (!expr_isk_nojump(e)) expr_toanyreg(fs, e); } else { if (!expr_isnumk_nojump(e)) expr_toanyreg(fs, e); } } /* Emit binary operator. */ static void bcemit_binop(FuncState *fs, BinOpr op, ExpDesc *e1, ExpDesc *e2) { if (op <= OPR_POW) { bcemit_arith(fs, op, e1, e2); } else if (op == OPR_AND) { lua_assert(e1->t == NO_JMP); /* List must be closed. */ expr_discharge(fs, e2); jmp_append(fs, &e2->f, e1->f); *e1 = *e2; } else if (op == OPR_OR) { lua_assert(e1->f == NO_JMP); /* List must be closed. */ expr_discharge(fs, e2); jmp_append(fs, &e2->t, e1->t); *e1 = *e2; } else if (op == OPR_CONCAT) { expr_toval(fs, e2); if (e2->k == VRELOCABLE && bc_op(*bcptr(fs, e2)) == BC_CAT) { lua_assert(e1->u.s.info == bc_b(*bcptr(fs, e2))-1); expr_free(fs, e1); setbc_b(bcptr(fs, e2), e1->u.s.info); e1->u.s.info = e2->u.s.info; } else { expr_tonextreg(fs, e2); expr_free(fs, e2); expr_free(fs, e1); e1->u.s.info = bcemit_ABC(fs, BC_CAT, 0, e1->u.s.info, e2->u.s.info); } e1->k = VRELOCABLE; } else { lua_assert(op == OPR_NE || op == OPR_EQ || op == OPR_LT || op == OPR_GE || op == OPR_LE || op == OPR_GT); bcemit_comp(fs, op, e1, e2); } } /* Emit unary operator. */ static void bcemit_unop(FuncState *fs, BCOp op, ExpDesc *e) { if (op == BC_NOT) { /* Swap true and false lists. */ { BCPos temp = e->f; e->f = e->t; e->t = temp; } jmp_dropval(fs, e->f); jmp_dropval(fs, e->t); expr_discharge(fs, e); if (e->k == VKNIL || e->k == VKFALSE) { e->k = VKTRUE; return; } else if (expr_isk(e) || (LJ_HASFFI && e->k == VKCDATA)) { e->k = VKFALSE; return; } else if (e->k == VJMP) { invertcond(fs, e); return; } else if (e->k == VRELOCABLE) { bcreg_reserve(fs, 1); setbc_a(bcptr(fs, e), fs->freereg-1); e->u.s.info = fs->freereg-1; e->k = VNONRELOC; } else { lua_assert(e->k == VNONRELOC); } } else { lua_assert(op == BC_UNM || op == BC_LEN); if (op == BC_UNM && !expr_hasjump(e)) { /* Constant-fold negations. */ #if LJ_HASFFI if (e->k == VKCDATA) { /* Fold in-place since cdata is not interned. */ GCcdata *cd = cdataV(&e->u.nval); int64_t *p = (int64_t *)cdataptr(cd); if (cd->ctypeid == CTID_COMPLEX_DOUBLE) p[1] ^= (int64_t)U64x(80000000,00000000); else *p = -*p; return; } else #endif if (expr_isnumk(e) && !expr_numiszero(e)) { /* Avoid folding to -0. */ TValue *o = expr_numtv(e); if (tvisint(o)) { int32_t k = intV(o); if (k == -k) setnumV(o, -(lua_Number)k); else setintV(o, -k); return; } else { o->u64 ^= U64x(80000000,00000000); return; } } } expr_toanyreg(fs, e); } expr_free(fs, e); e->u.s.info = bcemit_AD(fs, op, 0, e->u.s.info); e->k = VRELOCABLE; } /* -- Lexer support ------------------------------------------------------- */ /* Check and consume optional token. */ static int lex_opt(LexState *ls, LexToken tok) { if (ls->token == tok) { lj_lex_next(ls); return 1; } return 0; } /* Check and consume token. */ static void lex_check(LexState *ls, LexToken tok) { if (ls->token != tok) err_token(ls, tok); lj_lex_next(ls); } /* Check for matching token. */ static void lex_match(LexState *ls, LexToken what, LexToken who, BCLine line) { if (!lex_opt(ls, what)) { if (line == ls->linenumber) { err_token(ls, what); } else { const char *swhat = lj_lex_token2str(ls, what); const char *swho = lj_lex_token2str(ls, who); lj_lex_error(ls, ls->token, LJ_ERR_XMATCH, swhat, swho, line); } } } /* Check for string token. */ static GCstr *lex_str(LexState *ls) { GCstr *s; if (ls->token != TK_name && (LJ_52 || ls->token != TK_goto)) err_token(ls, TK_name); s = strV(&ls->tokenval); lj_lex_next(ls); return s; } /* -- Variable handling --------------------------------------------------- */ #define var_get(ls, fs, i) ((ls)->vstack[(fs)->varmap[(i)]]) /* Define a new local variable. */ static void var_new(LexState *ls, BCReg n, GCstr *name) { FuncState *fs = ls->fs; MSize vtop = ls->vtop; checklimit(fs, fs->nactvar+n, LJ_MAX_LOCVAR, "local variables"); if (LJ_UNLIKELY(vtop >= ls->sizevstack)) { if (ls->sizevstack >= LJ_MAX_VSTACK) lj_lex_error(ls, 0, LJ_ERR_XLIMC, LJ_MAX_VSTACK); lj_mem_growvec(ls->L, ls->vstack, ls->sizevstack, LJ_MAX_VSTACK, VarInfo); } lua_assert((uintptr_t)name < VARNAME__MAX || lj_tab_getstr(fs->kt, name) != NULL); /* NOBARRIER: name is anchored in fs->kt and ls->vstack is not a GCobj. */ setgcref(ls->vstack[vtop].name, obj2gco(name)); fs->varmap[fs->nactvar+n] = (uint16_t)vtop; ls->vtop = vtop+1; } #define var_new_lit(ls, n, v) \ var_new(ls, (n), lj_parse_keepstr(ls, "" v, sizeof(v)-1)) #define var_new_fixed(ls, n, vn) \ var_new(ls, (n), (GCstr *)(uintptr_t)(vn)) /* Add local variables. */ static void var_add(LexState *ls, BCReg nvars) { FuncState *fs = ls->fs; BCReg nactvar = fs->nactvar; while (nvars--) { VarInfo *v = &var_get(ls, fs, nactvar); v->startpc = fs->pc; v->slot = nactvar++; v->info = 0; } fs->nactvar = nactvar; } /* Remove local variables. */ static void var_remove(LexState *ls, BCReg tolevel) { FuncState *fs = ls->fs; while (fs->nactvar > tolevel) var_get(ls, fs, --fs->nactvar).endpc = fs->pc; } /* Lookup local variable name. */ static BCReg var_lookup_local(FuncState *fs, GCstr *n) { int i; for (i = fs->nactvar-1; i >= 0; i--) { if (n == strref(var_get(fs->ls, fs, i).name)) return (BCReg)i; } return (BCReg)-1; /* Not found. */ } /* Lookup or add upvalue index. */ static MSize var_lookup_uv(FuncState *fs, MSize vidx, ExpDesc *e) { MSize i, n = fs->nuv; for (i = 0; i < n; i++) if (fs->uvmap[i] == vidx) return i; /* Already exists. */ /* Otherwise create a new one. */ checklimit(fs, fs->nuv, LJ_MAX_UPVAL, "upvalues"); lua_assert(e->k == VLOCAL || e->k == VUPVAL); fs->uvmap[n] = (uint16_t)vidx; fs->uvtmp[n] = (uint16_t)(e->k == VLOCAL ? vidx : LJ_MAX_VSTACK+e->u.s.info); fs->nuv = n+1; return n; } /* Forward declaration. */ static void fscope_uvmark(FuncState *fs, BCReg level); /* Recursively lookup variables in enclosing functions. */ static MSize var_lookup_(FuncState *fs, GCstr *name, ExpDesc *e, int first) { if (fs) { BCReg reg = var_lookup_local(fs, name); if ((int32_t)reg >= 0) { /* Local in this function? */ expr_init(e, VLOCAL, reg); if (!first) fscope_uvmark(fs, reg); /* Scope now has an upvalue. */ return (MSize)(e->u.s.aux = (uint32_t)fs->varmap[reg]); } else { MSize vidx = var_lookup_(fs->prev, name, e, 0); /* Var in outer func? */ if ((int32_t)vidx >= 0) { /* Yes, make it an upvalue here. */ e->u.s.info = (uint8_t)var_lookup_uv(fs, vidx, e); e->k = VUPVAL; return vidx; } } } else { /* Not found in any function, must be a global. */ expr_init(e, VGLOBAL, 0); e->u.sval = name; } return (MSize)-1; /* Global. */ } /* Lookup variable name. */ #define var_lookup(ls, e) \ var_lookup_((ls)->fs, lex_str(ls), (e), 1) /* -- Goto an label handling ---------------------------------------------- */ /* Add a new goto or label. */ static MSize gola_new(LexState *ls, GCstr *name, uint8_t info, BCPos pc) { FuncState *fs = ls->fs; MSize vtop = ls->vtop; if (LJ_UNLIKELY(vtop >= ls->sizevstack)) { if (ls->sizevstack >= LJ_MAX_VSTACK) lj_lex_error(ls, 0, LJ_ERR_XLIMC, LJ_MAX_VSTACK); lj_mem_growvec(ls->L, ls->vstack, ls->sizevstack, LJ_MAX_VSTACK, VarInfo); } lua_assert(name == NAME_BREAK || lj_tab_getstr(fs->kt, name) != NULL); /* NOBARRIER: name is anchored in fs->kt and ls->vstack is not a GCobj. */ setgcref(ls->vstack[vtop].name, obj2gco(name)); ls->vstack[vtop].startpc = pc; ls->vstack[vtop].slot = (uint8_t)fs->nactvar; ls->vstack[vtop].info = info; ls->vtop = vtop+1; return vtop; } #define gola_isgoto(v) ((v)->info & VSTACK_GOTO) #define gola_islabel(v) ((v)->info & VSTACK_LABEL) #define gola_isgotolabel(v) ((v)->info & (VSTACK_GOTO|VSTACK_LABEL)) /* Patch goto to jump to label. */ static void gola_patch(LexState *ls, VarInfo *vg, VarInfo *vl) { FuncState *fs = ls->fs; BCPos pc = vg->startpc; setgcrefnull(vg->name); /* Invalidate pending goto. */ setbc_a(&fs->bcbase[pc].ins, vl->slot); jmp_patch(fs, pc, vl->startpc); } /* Patch goto to close upvalues. */ static void gola_close(LexState *ls, VarInfo *vg) { FuncState *fs = ls->fs; BCPos pc = vg->startpc; BCIns *ip = &fs->bcbase[pc].ins; lua_assert(gola_isgoto(vg)); lua_assert(bc_op(*ip) == BC_JMP || bc_op(*ip) == BC_UCLO); setbc_a(ip, vg->slot); if (bc_op(*ip) == BC_JMP) { BCPos next = jmp_next(fs, pc); if (next != NO_JMP) jmp_patch(fs, next, pc); /* Jump to UCLO. */ setbc_op(ip, BC_UCLO); /* Turn into UCLO. */ setbc_j(ip, NO_JMP); } } /* Resolve pending forward gotos for label. */ static void gola_resolve(LexState *ls, FuncScope *bl, MSize idx) { VarInfo *vg = ls->vstack + bl->vstart; VarInfo *vl = ls->vstack + idx; for (; vg < vl; vg++) if (gcrefeq(vg->name, vl->name) && gola_isgoto(vg)) { if (vg->slot < vl->slot) { GCstr *name = strref(var_get(ls, ls->fs, vg->slot).name); lua_assert((uintptr_t)name >= VARNAME__MAX); ls->linenumber = ls->fs->bcbase[vg->startpc].line; lua_assert(strref(vg->name) != NAME_BREAK); lj_lex_error(ls, 0, LJ_ERR_XGSCOPE, strdata(strref(vg->name)), strdata(name)); } gola_patch(ls, vg, vl); } } /* Fixup remaining gotos and labels for scope. */ static void gola_fixup(LexState *ls, FuncScope *bl) { VarInfo *v = ls->vstack + bl->vstart; VarInfo *ve = ls->vstack + ls->vtop; for (; v < ve; v++) { GCstr *name = strref(v->name); if (name != NULL) { /* Only consider remaining valid gotos/labels. */ if (gola_islabel(v)) { VarInfo *vg; setgcrefnull(v->name); /* Invalidate label that goes out of scope. */ for (vg = v+1; vg < ve; vg++) /* Resolve pending backward gotos. */ if (strref(vg->name) == name && gola_isgoto(vg)) { if ((bl->flags&FSCOPE_UPVAL) && vg->slot > v->slot) gola_close(ls, vg); gola_patch(ls, vg, v); } } else if (gola_isgoto(v)) { if (bl->prev) { /* Propagate goto or break to outer scope. */ bl->prev->flags |= name == NAME_BREAK ? FSCOPE_BREAK : FSCOPE_GOLA; v->slot = bl->nactvar; if ((bl->flags & FSCOPE_UPVAL)) gola_close(ls, v); } else { /* No outer scope: undefined goto label or no loop. */ ls->linenumber = ls->fs->bcbase[v->startpc].line; if (name == NAME_BREAK) lj_lex_error(ls, 0, LJ_ERR_XBREAK); else lj_lex_error(ls, 0, LJ_ERR_XLUNDEF, strdata(name)); } } } } } /* Find existing label. */ static VarInfo *gola_findlabel(LexState *ls, GCstr *name) { VarInfo *v = ls->vstack + ls->fs->bl->vstart; VarInfo *ve = ls->vstack + ls->vtop; for (; v < ve; v++) if (strref(v->name) == name && gola_islabel(v)) return v; return NULL; } /* -- Scope handling ------------------------------------------------------ */ /* Begin a scope. */ static void fscope_begin(FuncState *fs, FuncScope *bl, int flags) { bl->nactvar = (uint8_t)fs->nactvar; bl->flags = flags; bl->vstart = fs->ls->vtop; bl->prev = fs->bl; fs->bl = bl; lua_assert(fs->freereg == fs->nactvar); } /* End a scope. */ static void fscope_end(FuncState *fs) { FuncScope *bl = fs->bl; LexState *ls = fs->ls; fs->bl = bl->prev; var_remove(ls, bl->nactvar); fs->freereg = fs->nactvar; lua_assert(bl->nactvar == fs->nactvar); if ((bl->flags & (FSCOPE_UPVAL|FSCOPE_NOCLOSE)) == FSCOPE_UPVAL) bcemit_AJ(fs, BC_UCLO, bl->nactvar, 0); if ((bl->flags & FSCOPE_BREAK)) { if ((bl->flags & FSCOPE_LOOP)) { MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc); ls->vtop = idx; /* Drop break label immediately. */ gola_resolve(ls, bl, idx); return; } /* else: need the fixup step to propagate the breaks. */ } else if (!(bl->flags & FSCOPE_GOLA)) { return; } gola_fixup(ls, bl); } /* Mark scope as having an upvalue. */ static void fscope_uvmark(FuncState *fs, BCReg level) { FuncScope *bl; for (bl = fs->bl; bl && bl->nactvar > level; bl = bl->prev) ; if (bl) bl->flags |= FSCOPE_UPVAL; } /* -- Function state management ------------------------------------------- */ /* Fixup bytecode for prototype. */ static void fs_fixup_bc(FuncState *fs, GCproto *pt, BCIns *bc, MSize n) { BCInsLine *base = fs->bcbase; MSize i; pt->sizebc = n; bc[0] = BCINS_AD((fs->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, fs->framesize, 0); for (i = 1; i < n; i++) bc[i] = base[i].ins; } /* Fixup upvalues for child prototype, step #2. */ static void fs_fixup_uv2(FuncState *fs, GCproto *pt) { VarInfo *vstack = fs->ls->vstack; uint16_t *uv = proto_uv(pt); MSize i, n = pt->sizeuv; for (i = 0; i < n; i++) { VarIndex vidx = uv[i]; if (vidx >= LJ_MAX_VSTACK) uv[i] = vidx - LJ_MAX_VSTACK; else if ((vstack[vidx].info & VSTACK_VAR_RW)) uv[i] = vstack[vidx].slot | PROTO_UV_LOCAL; else uv[i] = vstack[vidx].slot | PROTO_UV_LOCAL | PROTO_UV_IMMUTABLE; } } /* Fixup constants for prototype. */ static void fs_fixup_k(FuncState *fs, GCproto *pt, void *kptr) { GCtab *kt; TValue *array; Node *node; MSize i, hmask; checklimitgt(fs, fs->nkn, BCMAX_D+1, "constants"); checklimitgt(fs, fs->nkgc, BCMAX_D+1, "constants"); setmref(pt->k, kptr); pt->sizekn = fs->nkn; pt->sizekgc = fs->nkgc; kt = fs->kt; array = tvref(kt->array); for (i = 0; i < kt->asize; i++) if (tvhaskslot(&array[i])) { TValue *tv = &((TValue *)kptr)[tvkslot(&array[i])]; if (LJ_DUALNUM) setintV(tv, (int32_t)i); else setnumV(tv, (lua_Number)i); } node = noderef(kt->node); hmask = kt->hmask; for (i = 0; i <= hmask; i++) { Node *n = &node[i]; if (tvhaskslot(&n->val)) { ptrdiff_t kidx = (ptrdiff_t)tvkslot(&n->val); lua_assert(!tvisint(&n->key)); if (tvisnum(&n->key)) { TValue *tv = &((TValue *)kptr)[kidx]; if (LJ_DUALNUM) { lua_Number nn = numV(&n->key); int32_t k = lj_num2int(nn); lua_assert(!tvismzero(&n->key)); if ((lua_Number)k == nn) setintV(tv, k); else *tv = n->key; } else { *tv = n->key; } } else { GCobj *o = gcV(&n->key); setgcref(((GCRef *)kptr)[~kidx], o); lj_gc_objbarrier(fs->L, pt, o); if (tvisproto(&n->key)) fs_fixup_uv2(fs, gco2pt(o)); } } } } /* Fixup upvalues for prototype, step #1. */ static void fs_fixup_uv1(FuncState *fs, GCproto *pt, uint16_t *uv) { setmref(pt->uv, uv); pt->sizeuv = fs->nuv; memcpy(uv, fs->uvtmp, fs->nuv*sizeof(VarIndex)); } #ifndef LUAJIT_DISABLE_DEBUGINFO /* Prepare lineinfo for prototype. */ static size_t fs_prep_line(FuncState *fs, BCLine numline) { return (fs->pc-1) << (numline < 256 ? 0 : numline < 65536 ? 1 : 2); } /* Fixup lineinfo for prototype. */ static void fs_fixup_line(FuncState *fs, GCproto *pt, void *lineinfo, BCLine numline) { BCInsLine *base = fs->bcbase + 1; BCLine first = fs->linedefined; MSize i = 0, n = fs->pc-1; pt->firstline = fs->linedefined; pt->numline = numline; setmref(pt->lineinfo, lineinfo); if (LJ_LIKELY(numline < 256)) { uint8_t *li = (uint8_t *)lineinfo; do { BCLine delta = base[i].line - first; lua_assert(delta >= 0 && delta < 256); li[i] = (uint8_t)delta; } while (++i < n); } else if (LJ_LIKELY(numline < 65536)) { uint16_t *li = (uint16_t *)lineinfo; do { BCLine delta = base[i].line - first; lua_assert(delta >= 0 && delta < 65536); li[i] = (uint16_t)delta; } while (++i < n); } else { uint32_t *li = (uint32_t *)lineinfo; do { BCLine delta = base[i].line - first; lua_assert(delta >= 0); li[i] = (uint32_t)delta; } while (++i < n); } } /* Resize buffer if needed. */ static LJ_NOINLINE void fs_buf_resize(LexState *ls, MSize len) { MSize sz = ls->sb.sz * 2; while (ls->sb.n + len > sz) sz = sz * 2; lj_str_resizebuf(ls->L, &ls->sb, sz); } static LJ_AINLINE void fs_buf_need(LexState *ls, MSize len) { if (LJ_UNLIKELY(ls->sb.n + len > ls->sb.sz)) fs_buf_resize(ls, len); } /* Add string to buffer. */ static void fs_buf_str(LexState *ls, const char *str, MSize len) { char *p = ls->sb.buf + ls->sb.n; MSize i; ls->sb.n += len; for (i = 0; i < len; i++) p[i] = str[i]; } /* Add ULEB128 value to buffer. */ static void fs_buf_uleb128(LexState *ls, uint32_t v) { MSize n = ls->sb.n; uint8_t *p = (uint8_t *)ls->sb.buf; for (; v >= 0x80; v >>= 7) p[n++] = (uint8_t)((v & 0x7f) | 0x80); p[n++] = (uint8_t)v; ls->sb.n = n; } /* Prepare variable info for prototype. */ static size_t fs_prep_var(LexState *ls, FuncState *fs, size_t *ofsvar) { VarInfo *vs =ls->vstack, *ve; MSize i, n; BCPos lastpc; lj_str_resetbuf(&ls->sb); /* Copy to temp. string buffer. */ /* Store upvalue names. */ for (i = 0, n = fs->nuv; i < n; i++) { GCstr *s = strref(vs[fs->uvmap[i]].name); MSize len = s->len+1; fs_buf_need(ls, len); fs_buf_str(ls, strdata(s), len); } *ofsvar = ls->sb.n; lastpc = 0; /* Store local variable names and compressed ranges. */ for (ve = vs + ls->vtop, vs += fs->vbase; vs < ve; vs++) { if (!gola_isgotolabel(vs)) { GCstr *s = strref(vs->name); BCPos startpc; if ((uintptr_t)s < VARNAME__MAX) { fs_buf_need(ls, 1 + 2*5); ls->sb.buf[ls->sb.n++] = (uint8_t)(uintptr_t)s; } else { MSize len = s->len+1; fs_buf_need(ls, len + 2*5); fs_buf_str(ls, strdata(s), len); } startpc = vs->startpc; fs_buf_uleb128(ls, startpc-lastpc); fs_buf_uleb128(ls, vs->endpc-startpc); lastpc = startpc; } } fs_buf_need(ls, 1); ls->sb.buf[ls->sb.n++] = '\0'; /* Terminator for varinfo. */ return ls->sb.n; } /* Fixup variable info for prototype. */ static void fs_fixup_var(LexState *ls, GCproto *pt, uint8_t *p, size_t ofsvar) { setmref(pt->uvinfo, p); setmref(pt->varinfo, (char *)p + ofsvar); memcpy(p, ls->sb.buf, ls->sb.n); /* Copy from temp. string buffer. */ } #else /* Initialize with empty debug info, if disabled. */ #define fs_prep_line(fs, numline) (UNUSED(numline), 0) #define fs_fixup_line(fs, pt, li, numline) \ pt->firstline = pt->numline = 0, setmref((pt)->lineinfo, NULL) #define fs_prep_var(ls, fs, ofsvar) (UNUSED(ofsvar), 0) #define fs_fixup_var(ls, pt, p, ofsvar) \ setmref((pt)->uvinfo, NULL), setmref((pt)->varinfo, NULL) #endif /* Check if bytecode op returns. */ static int bcopisret(BCOp op) { switch (op) { case BC_CALLMT: case BC_CALLT: case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: return 1; default: return 0; } } /* Fixup return instruction for prototype. */ static void fs_fixup_ret(FuncState *fs) { BCPos lastpc = fs->pc; if (lastpc <= fs->lasttarget || !bcopisret(bc_op(fs->bcbase[lastpc-1].ins))) { if ((fs->bl->flags & FSCOPE_UPVAL)) bcemit_AJ(fs, BC_UCLO, 0, 0); bcemit_AD(fs, BC_RET0, 0, 1); /* Need final return. */ } fs->bl->flags |= FSCOPE_NOCLOSE; /* Handled above. */ fscope_end(fs); lua_assert(fs->bl == NULL); /* May need to fixup returns encoded before first function was created. */ if (fs->flags & PROTO_FIXUP_RETURN) { BCPos pc; for (pc = 1; pc < lastpc; pc++) { BCIns ins = fs->bcbase[pc].ins; BCPos offset; switch (bc_op(ins)) { case BC_CALLMT: case BC_CALLT: case BC_RETM: case BC_RET: case BC_RET0: case BC_RET1: offset = bcemit_INS(fs, ins)-(pc+1)+BCBIAS_J; /* Copy return ins. */ if (offset > BCMAX_D) err_syntax(fs->ls, LJ_ERR_XFIXUP); /* Replace with UCLO plus branch. */ fs->bcbase[pc].ins = BCINS_AD(BC_UCLO, 0, offset); break; case BC_UCLO: return; /* We're done. */ default: break; } } } } /* Finish a FuncState and return the new prototype. */ static GCproto *fs_finish(LexState *ls, BCLine line) { lua_State *L = ls->L; FuncState *fs = ls->fs; BCLine numline = line - fs->linedefined; size_t sizept, ofsk, ofsuv, ofsli, ofsdbg, ofsvar; GCproto *pt; /* Apply final fixups. */ fs_fixup_ret(fs); /* Calculate total size of prototype including all colocated arrays. */ sizept = sizeof(GCproto) + fs->pc*sizeof(BCIns) + fs->nkgc*sizeof(GCRef); sizept = (sizept + sizeof(TValue)-1) & ~(sizeof(TValue)-1); ofsk = sizept; sizept += fs->nkn*sizeof(TValue); ofsuv = sizept; sizept += ((fs->nuv+1)&~1)*2; ofsli = sizept; sizept += fs_prep_line(fs, numline); ofsdbg = sizept; sizept += fs_prep_var(ls, fs, &ofsvar); /* Allocate prototype and initialize its fields. */ pt = (GCproto *)lj_mem_newgco(L, (MSize)sizept); pt->gct = ~LJ_TPROTO; pt->sizept = (MSize)sizept; pt->trace = 0; pt->flags = (uint8_t)(fs->flags & ~(PROTO_HAS_RETURN|PROTO_FIXUP_RETURN)); pt->numparams = fs->numparams; pt->framesize = fs->framesize; setgcref(pt->chunkname, obj2gco(ls->chunkname)); /* Close potentially uninitialized gap between bc and kgc. */ *(uint32_t *)((char *)pt + ofsk - sizeof(GCRef)*(fs->nkgc+1)) = 0; fs_fixup_bc(fs, pt, (BCIns *)((char *)pt + sizeof(GCproto)), fs->pc); fs_fixup_k(fs, pt, (void *)((char *)pt + ofsk)); fs_fixup_uv1(fs, pt, (uint16_t *)((char *)pt + ofsuv)); fs_fixup_line(fs, pt, (void *)((char *)pt + ofsli), numline); fs_fixup_var(ls, pt, (uint8_t *)((char *)pt + ofsdbg), ofsvar); lj_vmevent_send(L, BC, setprotoV(L, L->top++, pt); ); L->top--; /* Pop table of constants. */ ls->vtop = fs->vbase; /* Reset variable stack. */ ls->fs = fs->prev; lua_assert(ls->fs != NULL || ls->token == TK_eof); return pt; } /* Initialize a new FuncState. */ static void fs_init(LexState *ls, FuncState *fs) { lua_State *L = ls->L; fs->prev = ls->fs; ls->fs = fs; /* Append to list. */ fs->ls = ls; fs->vbase = ls->vtop; fs->L = L; fs->pc = 0; fs->lasttarget = 0; fs->jpc = NO_JMP; fs->freereg = 0; fs->nkgc = 0; fs->nkn = 0; fs->nactvar = 0; fs->nuv = 0; fs->bl = NULL; fs->flags = 0; fs->framesize = 1; /* Minimum frame size. */ fs->kt = lj_tab_new(L, 0, 0); /* Anchor table of constants in stack to avoid being collected. */ settabV(L, L->top, fs->kt); incr_top(L); } /* -- Expressions --------------------------------------------------------- */ /* Forward declaration. */ static void expr(LexState *ls, ExpDesc *v); /* Return string expression. */ static void expr_str(LexState *ls, ExpDesc *e) { expr_init(e, VKSTR, 0); e->u.sval = lex_str(ls); } /* Return index expression. */ static void expr_index(FuncState *fs, ExpDesc *t, ExpDesc *e) { /* Already called: expr_toval(fs, e). */ t->k = VINDEXED; if (expr_isnumk(e)) { #if LJ_DUALNUM if (tvisint(expr_numtv(e))) { int32_t k = intV(expr_numtv(e)); if (checku8(k)) { t->u.s.aux = BCMAX_C+1+(uint32_t)k; /* 256..511: const byte key */ return; } } #else lua_Number n = expr_numberV(e); int32_t k = lj_num2int(n); if (checku8(k) && n == (lua_Number)k) { t->u.s.aux = BCMAX_C+1+(uint32_t)k; /* 256..511: const byte key */ return; } #endif } else if (expr_isstrk(e)) { BCReg idx = const_str(fs, e); if (idx <= BCMAX_C) { t->u.s.aux = ~idx; /* -256..-1: const string key */ return; } } t->u.s.aux = expr_toanyreg(fs, e); /* 0..255: register */ } /* Parse index expression with named field. */ static void expr_field(LexState *ls, ExpDesc *v) { FuncState *fs = ls->fs; ExpDesc key; expr_toanyreg(fs, v); lj_lex_next(ls); /* Skip dot or colon. */ expr_str(ls, &key); expr_index(fs, v, &key); } /* Parse index expression with brackets. */ static void expr_bracket(LexState *ls, ExpDesc *v) { lj_lex_next(ls); /* Skip '['. */ expr(ls, v); expr_toval(ls->fs, v); lex_check(ls, ']'); } /* Get value of constant expression. */ static void expr_kvalue(TValue *v, ExpDesc *e) { if (e->k <= VKTRUE) { setitype(v, ~(uint32_t)e->k); } else if (e->k == VKSTR) { setgcref(v->gcr, obj2gco(e->u.sval)); setitype(v, LJ_TSTR); } else { lua_assert(tvisnumber(expr_numtv(e))); *v = *expr_numtv(e); } } /* Parse table constructor expression. */ static void expr_table(LexState *ls, ExpDesc *e) { FuncState *fs = ls->fs; BCLine line = ls->linenumber; GCtab *t = NULL; int vcall = 0, needarr = 0, fixt = 0; uint32_t narr = 1; /* First array index. */ uint32_t nhash = 0; /* Number of hash entries. */ BCReg freg = fs->freereg; BCPos pc = bcemit_AD(fs, BC_TNEW, freg, 0); expr_init(e, VNONRELOC, freg); bcreg_reserve(fs, 1); freg++; lex_check(ls, '{'); while (ls->token != '}') { ExpDesc key, val; vcall = 0; if (ls->token == '[') { expr_bracket(ls, &key); /* Already calls expr_toval. */ if (!expr_isk(&key)) expr_index(fs, e, &key); if (expr_isnumk(&key) && expr_numiszero(&key)) needarr = 1; else nhash++; lex_check(ls, '='); } else if ((ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) && lj_lex_lookahead(ls) == '=') { expr_str(ls, &key); lex_check(ls, '='); nhash++; } else { expr_init(&key, VKNUM, 0); setintV(&key.u.nval, (int)narr); narr++; needarr = vcall = 1; } expr(ls, &val); if (expr_isk(&key) && key.k != VKNIL && (key.k == VKSTR || expr_isk_nojump(&val))) { TValue k, *v; if (!t) { /* Create template table on demand. */ BCReg kidx; t = lj_tab_new(fs->L, needarr ? narr : 0, hsize2hbits(nhash)); kidx = const_gc(fs, obj2gco(t), LJ_TTAB); fs->bcbase[pc].ins = BCINS_AD(BC_TDUP, freg-1, kidx); } vcall = 0; expr_kvalue(&k, &key); v = lj_tab_set(fs->L, t, &k); lj_gc_anybarriert(fs->L, t); if (expr_isk_nojump(&val)) { /* Add const key/value to template table. */ expr_kvalue(v, &val); } else { /* Otherwise create dummy string key (avoids lj_tab_newkey). */ settabV(fs->L, v, t); /* Preserve key with table itself as value. */ fixt = 1; /* Fix this later, after all resizes. */ goto nonconst; } } else { nonconst: if (val.k != VCALL) { expr_toanyreg(fs, &val); vcall = 0; } if (expr_isk(&key)) expr_index(fs, e, &key); bcemit_store(fs, e, &val); } fs->freereg = freg; if (!lex_opt(ls, ',') && !lex_opt(ls, ';')) break; } lex_match(ls, '}', '{', line); if (vcall) { BCInsLine *ilp = &fs->bcbase[fs->pc-1]; ExpDesc en; lua_assert(bc_a(ilp->ins) == freg && bc_op(ilp->ins) == (narr > 256 ? BC_TSETV : BC_TSETB)); expr_init(&en, VKNUM, 0); en.u.nval.u32.lo = narr-1; en.u.nval.u32.hi = 0x43300000; /* Biased integer to avoid denormals. */ if (narr > 256) { fs->pc--; ilp--; } ilp->ins = BCINS_AD(BC_TSETM, freg, const_num(fs, &en)); setbc_b(&ilp[-1].ins, 0); } if (pc == fs->pc-1) { /* Make expr relocable if possible. */ e->u.s.info = pc; fs->freereg--; e->k = VRELOCABLE; } else { e->k = VNONRELOC; /* May have been changed by expr_index. */ } if (!t) { /* Construct TNEW RD: hhhhhaaaaaaaaaaa. */ BCIns *ip = &fs->bcbase[pc].ins; if (!needarr) narr = 0; else if (narr < 3) narr = 3; else if (narr > 0x7ff) narr = 0x7ff; setbc_d(ip, narr|(hsize2hbits(nhash)<<11)); } else { if (needarr && t->asize < narr) lj_tab_reasize(fs->L, t, narr-1); if (fixt) { /* Fix value for dummy keys in template table. */ Node *node = noderef(t->node); uint32_t i, hmask = t->hmask; for (i = 0; i <= hmask; i++) { Node *n = &node[i]; if (tvistab(&n->val)) { lua_assert(tabV(&n->val) == t); setnilV(&n->val); /* Turn value into nil. */ } } } lj_gc_check(fs->L); } } /* Parse function parameters. */ static BCReg parse_params(LexState *ls, int needself) { FuncState *fs = ls->fs; BCReg nparams = 0; lex_check(ls, '('); if (needself) var_new_lit(ls, nparams++, "self"); if (ls->token != ')') { do { if (ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) { var_new(ls, nparams++, lex_str(ls)); } else if (ls->token == TK_dots) { lj_lex_next(ls); fs->flags |= PROTO_VARARG; break; } else { err_syntax(ls, LJ_ERR_XPARAM); } } while (lex_opt(ls, ',')); } var_add(ls, nparams); lua_assert(fs->nactvar == nparams); bcreg_reserve(fs, nparams); lex_check(ls, ')'); return nparams; } /* Forward declaration. */ static void parse_chunk(LexState *ls); /* Parse body of a function. */ static void parse_body(LexState *ls, ExpDesc *e, int needself, BCLine line) { FuncState fs, *pfs = ls->fs; FuncScope bl; GCproto *pt; ptrdiff_t oldbase = pfs->bcbase - ls->bcstack; fs_init(ls, &fs); fscope_begin(&fs, &bl, 0); fs.linedefined = line; fs.numparams = (uint8_t)parse_params(ls, needself); fs.bcbase = pfs->bcbase + pfs->pc; fs.bclim = pfs->bclim - pfs->pc; bcemit_AD(&fs, BC_FUNCF, 0, 0); /* Placeholder. */ parse_chunk(ls); if (ls->token != TK_end) lex_match(ls, TK_end, TK_function, line); pt = fs_finish(ls, (ls->lastline = ls->linenumber)); pfs->bcbase = ls->bcstack + oldbase; /* May have been reallocated. */ pfs->bclim = (BCPos)(ls->sizebcstack - oldbase); /* Store new prototype in the constant array of the parent. */ expr_init(e, VRELOCABLE, bcemit_AD(pfs, BC_FNEW, 0, const_gc(pfs, obj2gco(pt), LJ_TPROTO))); #if LJ_HASFFI pfs->flags |= (fs.flags & PROTO_FFI); #endif if (!(pfs->flags & PROTO_CHILD)) { if (pfs->flags & PROTO_HAS_RETURN) pfs->flags |= PROTO_FIXUP_RETURN; pfs->flags |= PROTO_CHILD; } lj_lex_next(ls); } /* Parse expression list. Last expression is left open. */ static BCReg expr_list(LexState *ls, ExpDesc *v) { BCReg n = 1; expr(ls, v); while (lex_opt(ls, ',')) { expr_tonextreg(ls->fs, v); expr(ls, v); n++; } return n; } /* Parse function argument list. */ static void parse_args(LexState *ls, ExpDesc *e) { FuncState *fs = ls->fs; ExpDesc args; BCIns ins; BCReg base; BCLine line = ls->linenumber; if (ls->token == '(') { #if !LJ_52 if (line != ls->lastline) err_syntax(ls, LJ_ERR_XAMBIG); #endif lj_lex_next(ls); if (ls->token == ')') { /* f(). */ args.k = VVOID; } else { expr_list(ls, &args); if (args.k == VCALL) /* f(a, b, g()) or f(a, b, ...). */ setbc_b(bcptr(fs, &args), 0); /* Pass on multiple results. */ } lex_match(ls, ')', '(', line); } else if (ls->token == '{') { expr_table(ls, &args); } else if (ls->token == TK_string) { expr_init(&args, VKSTR, 0); args.u.sval = strV(&ls->tokenval); lj_lex_next(ls); } else { err_syntax(ls, LJ_ERR_XFUNARG); return; /* Silence compiler. */ } lua_assert(e->k == VNONRELOC); base = e->u.s.info; /* Base register for call. */ if (args.k == VCALL) { ins = BCINS_ABC(BC_CALLM, base, 2, args.u.s.aux - base - 1); } else { if (args.k != VVOID) expr_tonextreg(fs, &args); ins = BCINS_ABC(BC_CALL, base, 2, fs->freereg - base); } expr_init(e, VCALL, bcemit_INS(fs, ins)); e->u.s.aux = base; fs->bcbase[fs->pc - 1].line = line; fs->freereg = base+1; /* Leave one result by default. */ } /* Parse primary expression. */ static void expr_primary(LexState *ls, ExpDesc *v) { FuncState *fs = ls->fs; /* Parse prefix expression. */ if (ls->token == '(') { BCLine line = ls->linenumber; lj_lex_next(ls); expr(ls, v); lex_match(ls, ')', '(', line); expr_discharge(ls->fs, v); } else if (ls->token == TK_name || (!LJ_52 && ls->token == TK_goto)) { var_lookup(ls, v); } else { err_syntax(ls, LJ_ERR_XSYMBOL); } for (;;) { /* Parse multiple expression suffixes. */ if (ls->token == '.') { expr_field(ls, v); } else if (ls->token == '[') { ExpDesc key; expr_toanyreg(fs, v); expr_bracket(ls, &key); expr_index(fs, v, &key); } else if (ls->token == ':') { ExpDesc key; lj_lex_next(ls); expr_str(ls, &key); bcemit_method(fs, v, &key); parse_args(ls, v); } else if (ls->token == '(' || ls->token == TK_string || ls->token == '{') { expr_tonextreg(fs, v); parse_args(ls, v); } else { break; } } } /* Parse simple expression. */ static void expr_simple(LexState *ls, ExpDesc *v) { switch (ls->token) { case TK_number: expr_init(v, (LJ_HASFFI && tviscdata(&ls->tokenval)) ? VKCDATA : VKNUM, 0); copyTV(ls->L, &v->u.nval, &ls->tokenval); break; case TK_string: expr_init(v, VKSTR, 0); v->u.sval = strV(&ls->tokenval); break; case TK_nil: expr_init(v, VKNIL, 0); break; case TK_true: expr_init(v, VKTRUE, 0); break; case TK_false: expr_init(v, VKFALSE, 0); break; case TK_dots: { /* Vararg. */ FuncState *fs = ls->fs; BCReg base; checkcond(ls, fs->flags & PROTO_VARARG, LJ_ERR_XDOTS); bcreg_reserve(fs, 1); base = fs->freereg-1; expr_init(v, VCALL, bcemit_ABC(fs, BC_VARG, base, 2, fs->numparams)); v->u.s.aux = base; break; } case '{': /* Table constructor. */ expr_table(ls, v); return; case TK_function: lj_lex_next(ls); parse_body(ls, v, 0, ls->linenumber); return; default: expr_primary(ls, v); return; } lj_lex_next(ls); } /* Manage syntactic levels to avoid blowing up the stack. */ static void synlevel_begin(LexState *ls) { if (++ls->level >= LJ_MAX_XLEVEL) lj_lex_error(ls, 0, LJ_ERR_XLEVELS); } #define synlevel_end(ls) ((ls)->level--) /* Convert token to binary operator. */ static BinOpr token2binop(LexToken tok) { switch (tok) { case '+': return OPR_ADD; case '-': return OPR_SUB; case '*': return OPR_MUL; case '/': return OPR_DIV; case '%': return OPR_MOD; case '^': return OPR_POW; case TK_concat: return OPR_CONCAT; case TK_ne: return OPR_NE; case TK_eq: return OPR_EQ; case '<': return OPR_LT; case TK_le: return OPR_LE; case '>': return OPR_GT; case TK_ge: return OPR_GE; case TK_and: return OPR_AND; case TK_or: return OPR_OR; default: return OPR_NOBINOPR; } } /* Priorities for each binary operator. ORDER OPR. */ static const struct { uint8_t left; /* Left priority. */ uint8_t right; /* Right priority. */ } priority[] = { {6,6}, {6,6}, {7,7}, {7,7}, {7,7}, /* ADD SUB MUL DIV MOD */ {10,9}, {5,4}, /* POW CONCAT (right associative) */ {3,3}, {3,3}, /* EQ NE */ {3,3}, {3,3}, {3,3}, {3,3}, /* LT GE GT LE */ {2,2}, {1,1} /* AND OR */ }; #define UNARY_PRIORITY 8 /* Priority for unary operators. */ /* Forward declaration. */ static BinOpr expr_binop(LexState *ls, ExpDesc *v, uint32_t limit); /* Parse unary expression. */ static void expr_unop(LexState *ls, ExpDesc *v) { BCOp op; if (ls->token == TK_not) { op = BC_NOT; } else if (ls->token == '-') { op = BC_UNM; } else if (ls->token == '#') { op = BC_LEN; } else { expr_simple(ls, v); return; } lj_lex_next(ls); expr_binop(ls, v, UNARY_PRIORITY); bcemit_unop(ls->fs, op, v); } /* Parse binary expressions with priority higher than the limit. */ static BinOpr expr_binop(LexState *ls, ExpDesc *v, uint32_t limit) { BinOpr op; synlevel_begin(ls); expr_unop(ls, v); op = token2binop(ls->token); while (op != OPR_NOBINOPR && priority[op].left > limit) { ExpDesc v2; BinOpr nextop; lj_lex_next(ls); bcemit_binop_left(ls->fs, op, v); /* Parse binary expression with higher priority. */ nextop = expr_binop(ls, &v2, priority[op].right); bcemit_binop(ls->fs, op, v, &v2); op = nextop; } synlevel_end(ls); return op; /* Return unconsumed binary operator (if any). */ } /* Parse expression. */ static void expr(LexState *ls, ExpDesc *v) { expr_binop(ls, v, 0); /* Priority 0: parse whole expression. */ } /* Assign expression to the next register. */ static void expr_next(LexState *ls) { ExpDesc e; expr(ls, &e); expr_tonextreg(ls->fs, &e); } /* Parse conditional expression. */ static BCPos expr_cond(LexState *ls) { ExpDesc v; expr(ls, &v); if (v.k == VKNIL) v.k = VKFALSE; bcemit_branch_t(ls->fs, &v); return v.f; } /* -- Assignments --------------------------------------------------------- */ /* List of LHS variables. */ typedef struct LHSVarList { ExpDesc v; /* LHS variable. */ struct LHSVarList *prev; /* Link to previous LHS variable. */ } LHSVarList; /* Eliminate write-after-read hazards for local variable assignment. */ static void assign_hazard(LexState *ls, LHSVarList *lh, const ExpDesc *v) { FuncState *fs = ls->fs; BCReg reg = v->u.s.info; /* Check against this variable. */ BCReg tmp = fs->freereg; /* Rename to this temp. register (if needed). */ int hazard = 0; for (; lh; lh = lh->prev) { if (lh->v.k == VINDEXED) { if (lh->v.u.s.info == reg) { /* t[i], t = 1, 2 */ hazard = 1; lh->v.u.s.info = tmp; } if (lh->v.u.s.aux == reg) { /* t[i], i = 1, 2 */ hazard = 1; lh->v.u.s.aux = tmp; } } } if (hazard) { bcemit_AD(fs, BC_MOV, tmp, reg); /* Rename conflicting variable. */ bcreg_reserve(fs, 1); } } /* Adjust LHS/RHS of an assignment. */ static void assign_adjust(LexState *ls, BCReg nvars, BCReg nexps, ExpDesc *e) { FuncState *fs = ls->fs; int32_t extra = (int32_t)nvars - (int32_t)nexps; if (e->k == VCALL) { extra++; /* Compensate for the VCALL itself. */ if (extra < 0) extra = 0; setbc_b(bcptr(fs, e), extra+1); /* Fixup call results. */ if (extra > 1) bcreg_reserve(fs, (BCReg)extra-1); } else { if (e->k != VVOID) expr_tonextreg(fs, e); /* Close last expression. */ if (extra > 0) { /* Leftover LHS are set to nil. */ BCReg reg = fs->freereg; bcreg_reserve(fs, (BCReg)extra); bcemit_nil(fs, reg, (BCReg)extra); } } } /* Recursively parse assignment statement. */ static void parse_assignment(LexState *ls, LHSVarList *lh, BCReg nvars) { ExpDesc e; checkcond(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, LJ_ERR_XSYNTAX); if (lex_opt(ls, ',')) { /* Collect LHS list and recurse upwards. */ LHSVarList vl; vl.prev = lh; expr_primary(ls, &vl.v); if (vl.v.k == VLOCAL) assign_hazard(ls, lh, &vl.v); checklimit(ls->fs, ls->level + nvars, LJ_MAX_XLEVEL, "variable names"); parse_assignment(ls, &vl, nvars+1); } else { /* Parse RHS. */ BCReg nexps; lex_check(ls, '='); nexps = expr_list(ls, &e); if (nexps == nvars) { if (e.k == VCALL) { if (bc_op(*bcptr(ls->fs, &e)) == BC_VARG) { /* Vararg assignment. */ ls->fs->freereg--; e.k = VRELOCABLE; } else { /* Multiple call results. */ e.u.s.info = e.u.s.aux; /* Base of call is not relocatable. */ e.k = VNONRELOC; } } bcemit_store(ls->fs, &lh->v, &e); return; } assign_adjust(ls, nvars, nexps, &e); if (nexps > nvars) ls->fs->freereg -= nexps - nvars; /* Drop leftover regs. */ } /* Assign RHS to LHS and recurse downwards. */ expr_init(&e, VNONRELOC, ls->fs->freereg-1); bcemit_store(ls->fs, &lh->v, &e); } /* Parse call statement or assignment. */ static void parse_call_assign(LexState *ls) { FuncState *fs = ls->fs; LHSVarList vl; expr_primary(ls, &vl.v); if (vl.v.k == VCALL) { /* Function call statement. */ setbc_b(bcptr(fs, &vl.v), 1); /* No results. */ } else { /* Start of an assignment. */ vl.prev = NULL; parse_assignment(ls, &vl, 1); } } /* Parse 'local' statement. */ static void parse_local(LexState *ls) { if (lex_opt(ls, TK_function)) { /* Local function declaration. */ ExpDesc v, b; FuncState *fs = ls->fs; var_new(ls, 0, lex_str(ls)); expr_init(&v, VLOCAL, fs->freereg); v.u.s.aux = fs->varmap[fs->freereg]; bcreg_reserve(fs, 1); var_add(ls, 1); parse_body(ls, &b, 0, ls->linenumber); /* bcemit_store(fs, &v, &b) without setting VSTACK_VAR_RW. */ expr_free(fs, &b); expr_toreg(fs, &b, v.u.s.info); /* The upvalue is in scope, but the local is only valid after the store. */ var_get(ls, fs, fs->nactvar - 1).startpc = fs->pc; } else { /* Local variable declaration. */ ExpDesc e; BCReg nexps, nvars = 0; do { /* Collect LHS. */ var_new(ls, nvars++, lex_str(ls)); } while (lex_opt(ls, ',')); if (lex_opt(ls, '=')) { /* Optional RHS. */ nexps = expr_list(ls, &e); } else { /* Or implicitly set to nil. */ e.k = VVOID; nexps = 0; } assign_adjust(ls, nvars, nexps, &e); var_add(ls, nvars); } } /* Parse 'function' statement. */ static void parse_func(LexState *ls, BCLine line) { FuncState *fs; ExpDesc v, b; int needself = 0; lj_lex_next(ls); /* Skip 'function'. */ /* Parse function name. */ var_lookup(ls, &v); while (ls->token == '.') /* Multiple dot-separated fields. */ expr_field(ls, &v); if (ls->token == ':') { /* Optional colon to signify method call. */ needself = 1; expr_field(ls, &v); } parse_body(ls, &b, needself, line); fs = ls->fs; bcemit_store(fs, &v, &b); fs->bcbase[fs->pc - 1].line = line; /* Set line for the store. */ } /* -- Control transfer statements ----------------------------------------- */ /* Check for end of block. */ static int endofblock(LexToken token) { switch (token) { case TK_else: case TK_elseif: case TK_end: case TK_until: case TK_eof: return 1; default: return 0; } } /* Parse 'return' statement. */ static void parse_return(LexState *ls) { BCIns ins; FuncState *fs = ls->fs; lj_lex_next(ls); /* Skip 'return'. */ fs->flags |= PROTO_HAS_RETURN; if (endofblock(ls->token) || ls->token == ';') { /* Bare return. */ ins = BCINS_AD(BC_RET0, 0, 1); } else { /* Return with one or more values. */ ExpDesc e; /* Receives the _last_ expression in the list. */ BCReg nret = expr_list(ls, &e); if (nret == 1) { /* Return one result. */ if (e.k == VCALL) { /* Check for tail call. */ BCIns *ip = bcptr(fs, &e); /* It doesn't pay off to add BC_VARGT just for 'return ...'. */ if (bc_op(*ip) == BC_VARG) goto notailcall; fs->pc--; ins = BCINS_AD(bc_op(*ip)-BC_CALL+BC_CALLT, bc_a(*ip), bc_c(*ip)); } else { /* Can return the result from any register. */ ins = BCINS_AD(BC_RET1, expr_toanyreg(fs, &e), 2); } } else { if (e.k == VCALL) { /* Append all results from a call. */ notailcall: setbc_b(bcptr(fs, &e), 0); ins = BCINS_AD(BC_RETM, fs->nactvar, e.u.s.aux - fs->nactvar); } else { expr_tonextreg(fs, &e); /* Force contiguous registers. */ ins = BCINS_AD(BC_RET, fs->nactvar, nret+1); } } } if (fs->flags & PROTO_CHILD) bcemit_AJ(fs, BC_UCLO, 0, 0); /* May need to close upvalues first. */ bcemit_INS(fs, ins); } /* Parse 'break' statement. */ static void parse_break(LexState *ls) { ls->fs->bl->flags |= FSCOPE_BREAK; gola_new(ls, NAME_BREAK, VSTACK_GOTO, bcemit_jmp(ls->fs)); } /* Parse 'goto' statement. */ static void parse_goto(LexState *ls) { FuncState *fs = ls->fs; GCstr *name = lex_str(ls); VarInfo *vl = gola_findlabel(ls, name); if (vl) /* Treat backwards goto within same scope like a loop. */ bcemit_AJ(fs, BC_LOOP, vl->slot, -1); /* No BC range check. */ fs->bl->flags |= FSCOPE_GOLA; gola_new(ls, name, VSTACK_GOTO, bcemit_jmp(fs)); } /* Parse label. */ static void parse_label(LexState *ls) { FuncState *fs = ls->fs; GCstr *name; MSize idx; fs->lasttarget = fs->pc; fs->bl->flags |= FSCOPE_GOLA; lj_lex_next(ls); /* Skip '::'. */ name = lex_str(ls); if (gola_findlabel(ls, name)) lj_lex_error(ls, 0, LJ_ERR_XLDUP, strdata(name)); idx = gola_new(ls, name, VSTACK_LABEL, fs->pc); lex_check(ls, TK_label); /* Recursively parse trailing statements: labels and ';' (Lua 5.2 only). */ for (;;) { if (ls->token == TK_label) { synlevel_begin(ls); parse_label(ls); synlevel_end(ls); } else if (LJ_52 && ls->token == ';') { lj_lex_next(ls); } else { break; } } /* Trailing label is considered to be outside of scope. */ if (endofblock(ls->token) && ls->token != TK_until) ls->vstack[idx].slot = fs->bl->nactvar; gola_resolve(ls, fs->bl, idx); } /* -- Blocks, loops and conditional statements ---------------------------- */ /* Parse a block. */ static void parse_block(LexState *ls) { FuncState *fs = ls->fs; FuncScope bl; fscope_begin(fs, &bl, 0); parse_chunk(ls); fscope_end(fs); } /* Parse 'while' statement. */ static void parse_while(LexState *ls, BCLine line) { FuncState *fs = ls->fs; BCPos start, loop, condexit; FuncScope bl; lj_lex_next(ls); /* Skip 'while'. */ start = fs->lasttarget = fs->pc; condexit = expr_cond(ls); fscope_begin(fs, &bl, FSCOPE_LOOP); lex_check(ls, TK_do); loop = bcemit_AD(fs, BC_LOOP, fs->nactvar, 0); parse_block(ls); jmp_patch(fs, bcemit_jmp(fs), start); lex_match(ls, TK_end, TK_while, line); fscope_end(fs); jmp_tohere(fs, condexit); jmp_patchins(fs, loop, fs->pc); } /* Parse 'repeat' statement. */ static void parse_repeat(LexState *ls, BCLine line) { FuncState *fs = ls->fs; BCPos loop = fs->lasttarget = fs->pc; BCPos condexit; FuncScope bl1, bl2; fscope_begin(fs, &bl1, FSCOPE_LOOP); /* Breakable loop scope. */ fscope_begin(fs, &bl2, 0); /* Inner scope. */ lj_lex_next(ls); /* Skip 'repeat'. */ bcemit_AD(fs, BC_LOOP, fs->nactvar, 0); parse_chunk(ls); lex_match(ls, TK_until, TK_repeat, line); condexit = expr_cond(ls); /* Parse condition (still inside inner scope). */ if (!(bl2.flags & FSCOPE_UPVAL)) { /* No upvalues? Just end inner scope. */ fscope_end(fs); } else { /* Otherwise generate: cond: UCLO+JMP out, !cond: UCLO+JMP loop. */ parse_break(ls); /* Break from loop and close upvalues. */ jmp_tohere(fs, condexit); fscope_end(fs); /* End inner scope and close upvalues. */ condexit = bcemit_jmp(fs); } jmp_patch(fs, condexit, loop); /* Jump backwards if !cond. */ jmp_patchins(fs, loop, fs->pc); fscope_end(fs); /* End loop scope. */ } /* Parse numeric 'for'. */ static void parse_for_num(LexState *ls, GCstr *varname, BCLine line) { FuncState *fs = ls->fs; BCReg base = fs->freereg; FuncScope bl; BCPos loop, loopend; /* Hidden control variables. */ var_new_fixed(ls, FORL_IDX, VARNAME_FOR_IDX); var_new_fixed(ls, FORL_STOP, VARNAME_FOR_STOP); var_new_fixed(ls, FORL_STEP, VARNAME_FOR_STEP); /* Visible copy of index variable. */ var_new(ls, FORL_EXT, varname); lex_check(ls, '='); expr_next(ls); lex_check(ls, ','); expr_next(ls); if (lex_opt(ls, ',')) { expr_next(ls); } else { bcemit_AD(fs, BC_KSHORT, fs->freereg, 1); /* Default step is 1. */ bcreg_reserve(fs, 1); } var_add(ls, 3); /* Hidden control variables. */ lex_check(ls, TK_do); loop = bcemit_AJ(fs, BC_FORI, base, NO_JMP); fscope_begin(fs, &bl, 0); /* Scope for visible variables. */ var_add(ls, 1); bcreg_reserve(fs, 1); parse_block(ls); fscope_end(fs); /* Perform loop inversion. Loop control instructions are at the end. */ loopend = bcemit_AJ(fs, BC_FORL, base, NO_JMP); fs->bcbase[loopend].line = line; /* Fix line for control ins. */ jmp_patchins(fs, loopend, loop+1); jmp_patchins(fs, loop, fs->pc); } /* Try to predict whether the iterator is next() and specialize the bytecode. ** Detecting next() and pairs() by name is simplistic, but quite effective. ** The interpreter backs off if the check for the closure fails at runtime. */ static int predict_next(LexState *ls, FuncState *fs, BCPos pc) { BCIns ins = fs->bcbase[pc].ins; GCstr *name; cTValue *o; switch (bc_op(ins)) { case BC_MOV: name = gco2str(gcref(var_get(ls, fs, bc_d(ins)).name)); break; case BC_UGET: name = gco2str(gcref(ls->vstack[fs->uvmap[bc_d(ins)]].name)); break; case BC_GGET: /* There's no inverse index (yet), so lookup the strings. */ o = lj_tab_getstr(fs->kt, lj_str_newlit(ls->L, "pairs")); if (o && tvhaskslot(o) && tvkslot(o) == bc_d(ins)) return 1; o = lj_tab_getstr(fs->kt, lj_str_newlit(ls->L, "next")); if (o && tvhaskslot(o) && tvkslot(o) == bc_d(ins)) return 1; return 0; default: return 0; } return (name->len == 5 && !strcmp(strdata(name), "pairs")) || (name->len == 4 && !strcmp(strdata(name), "next")); } /* Parse 'for' iterator. */ static void parse_for_iter(LexState *ls, GCstr *indexname) { FuncState *fs = ls->fs; ExpDesc e; BCReg nvars = 0; BCLine line; BCReg base = fs->freereg + 3; BCPos loop, loopend, exprpc = fs->pc; FuncScope bl; int isnext; /* Hidden control variables. */ var_new_fixed(ls, nvars++, VARNAME_FOR_GEN); var_new_fixed(ls, nvars++, VARNAME_FOR_STATE); var_new_fixed(ls, nvars++, VARNAME_FOR_CTL); /* Visible variables returned from iterator. */ var_new(ls, nvars++, indexname); while (lex_opt(ls, ',')) var_new(ls, nvars++, lex_str(ls)); lex_check(ls, TK_in); line = ls->linenumber; assign_adjust(ls, 3, expr_list(ls, &e), &e); bcreg_bump(fs, 3); /* The iterator needs another 3 slots (func + 2 args). */ isnext = (nvars <= 5 && predict_next(ls, fs, exprpc)); var_add(ls, 3); /* Hidden control variables. */ lex_check(ls, TK_do); loop = bcemit_AJ(fs, isnext ? BC_ISNEXT : BC_JMP, base, NO_JMP); fscope_begin(fs, &bl, 0); /* Scope for visible variables. */ var_add(ls, nvars-3); bcreg_reserve(fs, nvars-3); parse_block(ls); fscope_end(fs); /* Perform loop inversion. Loop control instructions are at the end. */ jmp_patchins(fs, loop, fs->pc); bcemit_ABC(fs, isnext ? BC_ITERN : BC_ITERC, base, nvars-3+1, 2+1); loopend = bcemit_AJ(fs, BC_ITERL, base, NO_JMP); fs->bcbase[loopend-1].line = line; /* Fix line for control ins. */ fs->bcbase[loopend].line = line; jmp_patchins(fs, loopend, loop+1); } /* Parse 'for' statement. */ static void parse_for(LexState *ls, BCLine line) { FuncState *fs = ls->fs; GCstr *varname; FuncScope bl; fscope_begin(fs, &bl, FSCOPE_LOOP); lj_lex_next(ls); /* Skip 'for'. */ varname = lex_str(ls); /* Get first variable name. */ if (ls->token == '=') parse_for_num(ls, varname, line); else if (ls->token == ',' || ls->token == TK_in) parse_for_iter(ls, varname); else err_syntax(ls, LJ_ERR_XFOR); lex_match(ls, TK_end, TK_for, line); fscope_end(fs); /* Resolve break list. */ } /* Parse condition and 'then' block. */ static BCPos parse_then(LexState *ls) { BCPos condexit; lj_lex_next(ls); /* Skip 'if' or 'elseif'. */ condexit = expr_cond(ls); lex_check(ls, TK_then); parse_block(ls); return condexit; } /* Parse 'if' statement. */ static void parse_if(LexState *ls, BCLine line) { FuncState *fs = ls->fs; BCPos flist; BCPos escapelist = NO_JMP; flist = parse_then(ls); while (ls->token == TK_elseif) { /* Parse multiple 'elseif' blocks. */ jmp_append(fs, &escapelist, bcemit_jmp(fs)); jmp_tohere(fs, flist); flist = parse_then(ls); } if (ls->token == TK_else) { /* Parse optional 'else' block. */ jmp_append(fs, &escapelist, bcemit_jmp(fs)); jmp_tohere(fs, flist); lj_lex_next(ls); /* Skip 'else'. */ parse_block(ls); } else { jmp_append(fs, &escapelist, flist); } jmp_tohere(fs, escapelist); lex_match(ls, TK_end, TK_if, line); } /* -- Parse statements ---------------------------------------------------- */ /* Parse a statement. Returns 1 if it must be the last one in a chunk. */ static int parse_stmt(LexState *ls) { BCLine line = ls->linenumber; switch (ls->token) { case TK_if: parse_if(ls, line); break; case TK_while: parse_while(ls, line); break; case TK_do: lj_lex_next(ls); parse_block(ls); lex_match(ls, TK_end, TK_do, line); break; case TK_for: parse_for(ls, line); break; case TK_repeat: parse_repeat(ls, line); break; case TK_function: parse_func(ls, line); break; case TK_local: lj_lex_next(ls); parse_local(ls); break; case TK_return: parse_return(ls); return 1; /* Must be last. */ case TK_break: lj_lex_next(ls); parse_break(ls); return !LJ_52; /* Must be last in Lua 5.1. */ #if LJ_52 case ';': lj_lex_next(ls); break; #endif case TK_label: parse_label(ls); break; case TK_goto: if (LJ_52 || lj_lex_lookahead(ls) == TK_name) { lj_lex_next(ls); parse_goto(ls); break; } /* else: fallthrough */ default: parse_call_assign(ls); break; } return 0; } /* A chunk is a list of statements optionally separated by semicolons. */ static void parse_chunk(LexState *ls) { int islast = 0; synlevel_begin(ls); while (!islast && !endofblock(ls->token)) { islast = parse_stmt(ls); lex_opt(ls, ';'); lua_assert(ls->fs->framesize >= ls->fs->freereg && ls->fs->freereg >= ls->fs->nactvar); ls->fs->freereg = ls->fs->nactvar; /* Free registers after each stmt. */ } synlevel_end(ls); } /* Entry point of bytecode parser. */ GCproto *lj_parse(LexState *ls) { FuncState fs; FuncScope bl; GCproto *pt; lua_State *L = ls->L; #ifdef LUAJIT_DISABLE_DEBUGINFO ls->chunkname = lj_str_newlit(L, "="); #else ls->chunkname = lj_str_newz(L, ls->chunkarg); #endif setstrV(L, L->top, ls->chunkname); /* Anchor chunkname string. */ incr_top(L); ls->level = 0; fs_init(ls, &fs); fs.linedefined = 0; fs.numparams = 0; fs.bcbase = NULL; fs.bclim = 0; fs.flags |= PROTO_VARARG; /* Main chunk is always a vararg func. */ fscope_begin(&fs, &bl, 0); bcemit_AD(&fs, BC_FUNCV, 0, 0); /* Placeholder. */ lj_lex_next(ls); /* Read-ahead first token. */ parse_chunk(ls); if (ls->token != TK_eof) err_token(ls, TK_eof); pt = fs_finish(ls, ls->linenumber); L->top--; /* Drop chunkname. */ lua_assert(fs.prev == NULL); lua_assert(ls->fs == NULL); lua_assert(pt->sizeuv == 0); return pt; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_parse.h ================================================ /* ** Lua parser (source code -> bytecode). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_PARSE_H #define _LJ_PARSE_H #include "lj_obj.h" #include "lj_lex.h" LJ_FUNC GCproto *lj_parse(LexState *ls); LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); #if LJ_HASFFI LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_record.c ================================================ /* ** Trace recorder (bytecode -> SSA IR). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_record_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_meta.h" #include "lj_frame.h" #if LJ_HASFFI #include "lj_ctype.h" #endif #include "lj_bc.h" #include "lj_ff.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_ircall.h" #include "lj_iropt.h" #include "lj_trace.h" #include "lj_record.h" #include "lj_ffrecord.h" #include "lj_snap.h" #include "lj_dispatch.h" #include "lj_vm.h" /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) /* Pass IR on to next optimization in chain (FOLD). */ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) /* Emit raw IR without passing through optimizations. */ #define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) /* -- Sanity checks ------------------------------------------------------- */ #ifdef LUA_USE_ASSERT /* Sanity check the whole IR -- sloooow. */ static void rec_check_ir(jit_State *J) { IRRef i, nins = J->cur.nins, nk = J->cur.nk; lua_assert(nk <= REF_BIAS && nins >= REF_BIAS && nins < 65536); for (i = nins-1; i >= nk; i--) { IRIns *ir = IR(i); uint32_t mode = lj_ir_mode[ir->o]; IRRef op1 = ir->op1; IRRef op2 = ir->op2; switch (irm_op1(mode)) { case IRMnone: lua_assert(op1 == 0); break; case IRMref: lua_assert(op1 >= nk); lua_assert(i >= REF_BIAS ? op1 < i : op1 > i); break; case IRMlit: break; case IRMcst: lua_assert(i < REF_BIAS); continue; } switch (irm_op2(mode)) { case IRMnone: lua_assert(op2 == 0); break; case IRMref: lua_assert(op2 >= nk); lua_assert(i >= REF_BIAS ? op2 < i : op2 > i); break; case IRMlit: break; case IRMcst: lua_assert(0); break; } if (ir->prev) { lua_assert(ir->prev >= nk); lua_assert(i >= REF_BIAS ? ir->prev < i : ir->prev > i); lua_assert(ir->o == IR_NOP || IR(ir->prev)->o == ir->o); } } } /* Compare stack slots and frames of the recorder and the VM. */ static void rec_check_slots(jit_State *J) { BCReg s, nslots = J->baseslot + J->maxslot; int32_t depth = 0; cTValue *base = J->L->base - J->baseslot; lua_assert(J->baseslot >= 1 && J->baseslot < LJ_MAX_JSLOTS); lua_assert(J->baseslot == 1 || (J->slot[J->baseslot-1] & TREF_FRAME)); lua_assert(nslots < LJ_MAX_JSLOTS); for (s = 0; s < nslots; s++) { TRef tr = J->slot[s]; if (tr) { cTValue *tv = &base[s]; IRRef ref = tref_ref(tr); IRIns *ir; lua_assert(ref >= J->cur.nk && ref < J->cur.nins); ir = IR(ref); lua_assert(irt_t(ir->t) == tref_t(tr)); if (s == 0) { lua_assert(tref_isfunc(tr)); } else if ((tr & TREF_FRAME)) { GCfunc *fn = gco2func(frame_gc(tv)); BCReg delta = (BCReg)(tv - frame_prev(tv)); lua_assert(tref_isfunc(tr)); if (tref_isk(tr)) lua_assert(fn == ir_kfunc(ir)); lua_assert(s > delta ? (J->slot[s-delta] & TREF_FRAME) : (s == delta)); depth++; } else if ((tr & TREF_CONT)) { lua_assert(ir_kptr(ir) == gcrefp(tv->gcr, void)); lua_assert((J->slot[s+1] & TREF_FRAME)); depth++; } else { if (tvisnumber(tv)) lua_assert(tref_isnumber(tr)); /* Could be IRT_INT etc., too. */ else lua_assert(itype2irt(tv) == tref_type(tr)); if (tref_isk(tr)) { /* Compare constants. */ TValue tvk; lj_ir_kvalue(J->L, &tvk, ir); if (!(tvisnum(&tvk) && tvisnan(&tvk))) lua_assert(lj_obj_equal(tv, &tvk)); else lua_assert(tvisnum(tv) && tvisnan(tv)); } } } } lua_assert(J->framedepth == depth); } #endif /* -- Type handling and specialization ------------------------------------ */ /* Note: these functions return tagged references (TRef). */ /* Specialize a slot to a specific type. Note: slot can be negative! */ static TRef sloadt(jit_State *J, int32_t slot, IRType t, int mode) { /* Caller may set IRT_GUARD in t. */ TRef ref = emitir_raw(IRT(IR_SLOAD, t), (int32_t)J->baseslot+slot, mode); J->base[slot] = ref; return ref; } /* Specialize a slot to the runtime type. Note: slot can be negative! */ static TRef sload(jit_State *J, int32_t slot) { IRType t = itype2irt(&J->L->base[slot]); TRef ref = emitir_raw(IRTG(IR_SLOAD, t), (int32_t)J->baseslot+slot, IRSLOAD_TYPECHECK); if (irtype_ispri(t)) ref = TREF_PRI(t); /* Canonicalize primitive refs. */ J->base[slot] = ref; return ref; } /* Get TRef from slot. Load slot and specialize if not done already. */ #define getslot(J, s) (J->base[(s)] ? J->base[(s)] : sload(J, (int32_t)(s))) /* Get TRef for current function. */ static TRef getcurrf(jit_State *J) { if (J->base[-1]) return J->base[-1]; lua_assert(J->baseslot == 1); return sloadt(J, -1, IRT_FUNC, IRSLOAD_READONLY); } /* Compare for raw object equality. ** Returns 0 if the objects are the same. ** Returns 1 if they are different, but the same type. ** Returns 2 for two different types. ** Comparisons between primitives always return 1 -- no caller cares about it. */ int lj_record_objcmp(jit_State *J, TRef a, TRef b, cTValue *av, cTValue *bv) { int diff = !lj_obj_equal(av, bv); if (!tref_isk2(a, b)) { /* Shortcut, also handles primitives. */ IRType ta = tref_isinteger(a) ? IRT_INT : tref_type(a); IRType tb = tref_isinteger(b) ? IRT_INT : tref_type(b); if (ta != tb) { /* Widen mixed number/int comparisons to number/number comparison. */ if (ta == IRT_INT && tb == IRT_NUM) { a = emitir(IRTN(IR_CONV), a, IRCONV_NUM_INT); ta = IRT_NUM; } else if (ta == IRT_NUM && tb == IRT_INT) { b = emitir(IRTN(IR_CONV), b, IRCONV_NUM_INT); } else { return 2; /* Two different types are never equal. */ } } emitir(IRTG(diff ? IR_NE : IR_EQ, ta), a, b); } return diff; } /* Constify a value. Returns 0 for non-representable object types. */ TRef lj_record_constify(jit_State *J, cTValue *o) { if (tvisgcv(o)) return lj_ir_kgc(J, gcV(o), itype2irt(o)); else if (tvisint(o)) return lj_ir_kint(J, intV(o)); else if (tvisnum(o)) return lj_ir_knumint(J, numV(o)); else if (tvisbool(o)) return TREF_PRI(itype2irt(o)); else return 0; /* Can't represent lightuserdata (pointless). */ } /* -- Record loop ops ----------------------------------------------------- */ /* Loop event. */ typedef enum { LOOPEV_LEAVE, /* Loop is left or not entered. */ LOOPEV_ENTERLO, /* Loop is entered with a low iteration count left. */ LOOPEV_ENTER /* Loop is entered. */ } LoopEvent; /* Canonicalize slots: convert integers to numbers. */ static void canonicalize_slots(jit_State *J) { BCReg s; if (LJ_DUALNUM) return; for (s = J->baseslot+J->maxslot-1; s >= 1; s--) { TRef tr = J->slot[s]; if (tref_isinteger(tr)) { IRIns *ir = IR(tref_ref(tr)); if (!(ir->o == IR_SLOAD && (ir->op2 & IRSLOAD_READONLY))) J->slot[s] = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT); } } } /* Stop recording. */ static void rec_stop(jit_State *J, TraceLink linktype, TraceNo lnk) { lj_trace_end(J); J->cur.linktype = (uint8_t)linktype; J->cur.link = (uint16_t)lnk; /* Looping back at the same stack level? */ if (lnk == J->cur.traceno && J->framedepth + J->retdepth == 0) { if ((J->flags & JIT_F_OPT_LOOP)) /* Shall we try to create a loop? */ goto nocanon; /* Do not canonicalize or we lose the narrowing. */ if (J->cur.root) /* Otherwise ensure we always link to the root trace. */ J->cur.link = J->cur.root; } canonicalize_slots(J); nocanon: /* Note: all loop ops must set J->pc to the following instruction! */ lj_snap_add(J); /* Add loop snapshot. */ J->needsnap = 0; J->mergesnap = 1; /* In case recording continues. */ } /* Search bytecode backwards for a int/num constant slot initializer. */ static TRef find_kinit(jit_State *J, const BCIns *endpc, BCReg slot, IRType t) { /* This algorithm is rather simplistic and assumes quite a bit about ** how the bytecode is generated. It works fine for FORI initializers, ** but it won't necessarily work in other cases (e.g. iterator arguments). ** It doesn't do anything fancy, either (like backpropagating MOVs). */ const BCIns *pc, *startpc = proto_bc(J->pt); for (pc = endpc-1; pc > startpc; pc--) { BCIns ins = *pc; BCOp op = bc_op(ins); /* First try to find the last instruction that stores to this slot. */ if (bcmode_a(op) == BCMbase && bc_a(ins) <= slot) { return 0; /* Multiple results, e.g. from a CALL or KNIL. */ } else if (bcmode_a(op) == BCMdst && bc_a(ins) == slot) { if (op == BC_KSHORT || op == BC_KNUM) { /* Found const. initializer. */ /* Now try to verify there's no forward jump across it. */ const BCIns *kpc = pc; for (; pc > startpc; pc--) if (bc_op(*pc) == BC_JMP) { const BCIns *target = pc+bc_j(*pc)+1; if (target > kpc && target <= endpc) return 0; /* Conditional assignment. */ } if (op == BC_KSHORT) { int32_t k = (int32_t)(int16_t)bc_d(ins); return t == IRT_INT ? lj_ir_kint(J, k) : lj_ir_knum(J, (lua_Number)k); } else { cTValue *tv = proto_knumtv(J->pt, bc_d(ins)); if (t == IRT_INT) { int32_t k = numberVint(tv); if (tvisint(tv) || numV(tv) == (lua_Number)k) /* -0 is ok here. */ return lj_ir_kint(J, k); return 0; /* Type mismatch. */ } else { return lj_ir_knum(J, numberVnum(tv)); } } } return 0; /* Non-constant initializer. */ } } return 0; /* No assignment to this slot found? */ } /* Load and optionally convert a FORI argument from a slot. */ static TRef fori_load(jit_State *J, BCReg slot, IRType t, int mode) { int conv = (tvisint(&J->L->base[slot]) != (t==IRT_INT)) ? IRSLOAD_CONVERT : 0; return sloadt(J, (int32_t)slot, t + (((mode & IRSLOAD_TYPECHECK) || (conv && t == IRT_INT && !(mode >> 16))) ? IRT_GUARD : 0), mode + conv); } /* Peek before FORI to find a const initializer. Otherwise load from slot. */ static TRef fori_arg(jit_State *J, const BCIns *fori, BCReg slot, IRType t, int mode) { TRef tr = J->base[slot]; if (!tr) { tr = find_kinit(J, fori, slot, t); if (!tr) tr = fori_load(J, slot, t, mode); } return tr; } /* Return the direction of the FOR loop iterator. ** It's important to exactly reproduce the semantics of the interpreter. */ static int rec_for_direction(cTValue *o) { return (tvisint(o) ? intV(o) : (int32_t)o->u32.hi) >= 0; } /* Simulate the runtime behavior of the FOR loop iterator. */ static LoopEvent rec_for_iter(IROp *op, cTValue *o, int isforl) { lua_Number stopv = numberVnum(&o[FORL_STOP]); lua_Number idxv = numberVnum(&o[FORL_IDX]); lua_Number stepv = numberVnum(&o[FORL_STEP]); if (isforl) idxv += stepv; if (rec_for_direction(&o[FORL_STEP])) { if (idxv <= stopv) { *op = IR_LE; return idxv + 2*stepv > stopv ? LOOPEV_ENTERLO : LOOPEV_ENTER; } *op = IR_GT; return LOOPEV_LEAVE; } else { if (stopv <= idxv) { *op = IR_GE; return idxv + 2*stepv < stopv ? LOOPEV_ENTERLO : LOOPEV_ENTER; } *op = IR_LT; return LOOPEV_LEAVE; } } /* Record checks for FOR loop overflow and step direction. */ static void rec_for_check(jit_State *J, IRType t, int dir, TRef stop, TRef step, int init) { if (!tref_isk(step)) { /* Non-constant step: need a guard for the direction. */ TRef zero = (t == IRT_INT) ? lj_ir_kint(J, 0) : lj_ir_knum_zero(J); emitir(IRTG(dir ? IR_GE : IR_LT, t), step, zero); /* Add hoistable overflow checks for a narrowed FORL index. */ if (init && t == IRT_INT) { if (tref_isk(stop)) { /* Constant stop: optimize check away or to a range check for step. */ int32_t k = IR(tref_ref(stop))->i; if (dir) { if (k > 0) emitir(IRTGI(IR_LE), step, lj_ir_kint(J, (int32_t)0x7fffffff-k)); } else { if (k < 0) emitir(IRTGI(IR_GE), step, lj_ir_kint(J, (int32_t)0x80000000-k)); } } else { /* Stop+step variable: need full overflow check. */ TRef tr = emitir(IRTGI(IR_ADDOV), step, stop); emitir(IRTI(IR_USE), tr, 0); /* ADDOV is weak. Avoid dead result. */ } } } else if (init && t == IRT_INT && !tref_isk(stop)) { /* Constant step: optimize overflow check to a range check for stop. */ int32_t k = IR(tref_ref(step))->i; k = (int32_t)(dir ? 0x7fffffff : 0x80000000) - k; emitir(IRTGI(dir ? IR_LE : IR_GE), stop, lj_ir_kint(J, k)); } } /* Record a FORL instruction. */ static void rec_for_loop(jit_State *J, const BCIns *fori, ScEvEntry *scev, int init) { BCReg ra = bc_a(*fori); cTValue *tv = &J->L->base[ra]; TRef idx = J->base[ra+FORL_IDX]; IRType t = idx ? tref_type(idx) : (init || LJ_DUALNUM) ? lj_opt_narrow_forl(J, tv) : IRT_NUM; int mode = IRSLOAD_INHERIT + ((!LJ_DUALNUM || tvisint(tv) == (t == IRT_INT)) ? IRSLOAD_READONLY : 0); TRef stop = fori_arg(J, fori, ra+FORL_STOP, t, mode); TRef step = fori_arg(J, fori, ra+FORL_STEP, t, mode); int tc, dir = rec_for_direction(&tv[FORL_STEP]); lua_assert(bc_op(*fori) == BC_FORI || bc_op(*fori) == BC_JFORI); scev->t.irt = t; scev->dir = dir; scev->stop = tref_ref(stop); scev->step = tref_ref(step); rec_for_check(J, t, dir, stop, step, init); scev->start = tref_ref(find_kinit(J, fori, ra+FORL_IDX, IRT_INT)); tc = (LJ_DUALNUM && !(scev->start && irref_isk(scev->stop) && irref_isk(scev->step) && tvisint(&tv[FORL_IDX]) == (t == IRT_INT))) ? IRSLOAD_TYPECHECK : 0; if (tc) { J->base[ra+FORL_STOP] = stop; J->base[ra+FORL_STEP] = step; } if (!idx) idx = fori_load(J, ra+FORL_IDX, t, IRSLOAD_INHERIT + tc + (J->scev.start << 16)); if (!init) J->base[ra+FORL_IDX] = idx = emitir(IRT(IR_ADD, t), idx, step); J->base[ra+FORL_EXT] = idx; scev->idx = tref_ref(idx); J->maxslot = ra+FORL_EXT+1; } /* Record FORL/JFORL or FORI/JFORI. */ static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl) { BCReg ra = bc_a(*fori); TValue *tv = &J->L->base[ra]; TRef *tr = &J->base[ra]; IROp op; LoopEvent ev; TRef stop; IRType t; if (isforl) { /* Handle FORL/JFORL opcodes. */ TRef idx = tr[FORL_IDX]; if (tref_ref(idx) == J->scev.idx) { t = J->scev.t.irt; stop = J->scev.stop; idx = emitir(IRT(IR_ADD, t), idx, J->scev.step); tr[FORL_EXT] = tr[FORL_IDX] = idx; } else { ScEvEntry scev; rec_for_loop(J, fori, &scev, 0); t = scev.t.irt; stop = scev.stop; } } else { /* Handle FORI/JFORI opcodes. */ BCReg i; lj_meta_for(J->L, tv); t = (LJ_DUALNUM || tref_isint(tr[FORL_IDX])) ? lj_opt_narrow_forl(J, tv) : IRT_NUM; for (i = FORL_IDX; i <= FORL_STEP; i++) { if (!tr[i]) sload(J, ra+i); lua_assert(tref_isnumber_str(tr[i])); if (tref_isstr(tr[i])) tr[i] = emitir(IRTG(IR_STRTO, IRT_NUM), tr[i], 0); if (t == IRT_INT) { if (!tref_isinteger(tr[i])) tr[i] = emitir(IRTGI(IR_CONV), tr[i], IRCONV_INT_NUM|IRCONV_CHECK); } else { if (!tref_isnum(tr[i])) tr[i] = emitir(IRTN(IR_CONV), tr[i], IRCONV_NUM_INT); } } tr[FORL_EXT] = tr[FORL_IDX]; stop = tr[FORL_STOP]; rec_for_check(J, t, rec_for_direction(&tv[FORL_STEP]), stop, tr[FORL_STEP], 1); } ev = rec_for_iter(&op, tv, isforl); if (ev == LOOPEV_LEAVE) { J->maxslot = ra+FORL_EXT+1; J->pc = fori+1; } else { J->maxslot = ra; J->pc = fori+bc_j(*fori)+1; } lj_snap_add(J); emitir(IRTG(op, t), tr[FORL_IDX], stop); if (ev == LOOPEV_LEAVE) { J->maxslot = ra; J->pc = fori+bc_j(*fori)+1; } else { J->maxslot = ra+FORL_EXT+1; J->pc = fori+1; } J->needsnap = 1; return ev; } /* Record ITERL/JITERL. */ static LoopEvent rec_iterl(jit_State *J, const BCIns iterins) { BCReg ra = bc_a(iterins); lua_assert(J->base[ra] != 0); if (!tref_isnil(J->base[ra])) { /* Looping back? */ J->base[ra-1] = J->base[ra]; /* Copy result of ITERC to control var. */ J->maxslot = ra-1+bc_b(J->pc[-1]); J->pc += bc_j(iterins)+1; return LOOPEV_ENTER; } else { J->maxslot = ra-3; J->pc++; return LOOPEV_LEAVE; } } /* Record LOOP/JLOOP. Now, that was easy. */ static LoopEvent rec_loop(jit_State *J, BCReg ra) { if (ra < J->maxslot) J->maxslot = ra; J->pc++; return LOOPEV_ENTER; } /* Check if a loop repeatedly failed to trace because it didn't loop back. */ static int innerloopleft(jit_State *J, const BCIns *pc) { ptrdiff_t i; for (i = 0; i < PENALTY_SLOTS; i++) if (mref(J->penalty[i].pc, const BCIns) == pc) { if ((J->penalty[i].reason == LJ_TRERR_LLEAVE || J->penalty[i].reason == LJ_TRERR_LINNER) && J->penalty[i].val >= 2*PENALTY_MIN) return 1; break; } return 0; } /* Handle the case when an interpreted loop op is hit. */ static void rec_loop_interp(jit_State *J, const BCIns *pc, LoopEvent ev) { if (J->parent == 0) { if (pc == J->startpc && J->framedepth + J->retdepth == 0) { /* Same loop? */ if (ev == LOOPEV_LEAVE) /* Must loop back to form a root trace. */ lj_trace_err(J, LJ_TRERR_LLEAVE); rec_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Looping root trace. */ } else if (ev != LOOPEV_LEAVE) { /* Entering inner loop? */ /* It's usually better to abort here and wait until the inner loop ** is traced. But if the inner loop repeatedly didn't loop back, ** this indicates a low trip count. In this case try unrolling ** an inner loop even in a root trace. But it's better to be a bit ** more conservative here and only do it for very short loops. */ if (bc_j(*pc) != -1 && !innerloopleft(J, pc)) lj_trace_err(J, LJ_TRERR_LINNER); /* Root trace hit an inner loop. */ if ((ev != LOOPEV_ENTERLO && J->loopref && J->cur.nins - J->loopref > 24) || --J->loopunroll < 0) lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ J->loopref = J->cur.nins; } } else if (ev != LOOPEV_LEAVE) { /* Side trace enters an inner loop. */ J->loopref = J->cur.nins; if (--J->loopunroll < 0) lj_trace_err(J, LJ_TRERR_LUNROLL); /* Limit loop unrolling. */ } /* Side trace continues across a loop that's left or not entered. */ } /* Handle the case when an already compiled loop op is hit. */ static void rec_loop_jit(jit_State *J, TraceNo lnk, LoopEvent ev) { if (J->parent == 0) { /* Root trace hit an inner loop. */ /* Better let the inner loop spawn a side trace back here. */ lj_trace_err(J, LJ_TRERR_LINNER); } else if (ev != LOOPEV_LEAVE) { /* Side trace enters a compiled loop. */ J->instunroll = 0; /* Cannot continue across a compiled loop op. */ if (J->pc == J->startpc && J->framedepth + J->retdepth == 0) rec_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Form an extra loop. */ else rec_stop(J, LJ_TRLINK_ROOT, lnk); /* Link to the loop. */ } /* Side trace continues across a loop that's left or not entered. */ } /* -- Record calls and returns -------------------------------------------- */ /* Specialize to the runtime value of the called function or its prototype. */ static TRef rec_call_specialize(jit_State *J, GCfunc *fn, TRef tr) { TRef kfunc; if (isluafunc(fn)) { GCproto *pt = funcproto(fn); /* Too many closures created? Probably not a monomorphic function. */ if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */ TRef trpt = emitir(IRT(IR_FLOAD, IRT_P32), tr, IRFL_FUNC_PC); emitir(IRTG(IR_EQ, IRT_P32), trpt, lj_ir_kptr(J, proto_bc(pt))); (void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */ return tr; } } /* Otherwise specialize to the function (closure) value itself. */ kfunc = lj_ir_kfunc(J, fn); emitir(IRTG(IR_EQ, IRT_FUNC), tr, kfunc); return kfunc; } /* Record call setup. */ static void rec_call_setup(jit_State *J, BCReg func, ptrdiff_t nargs) { RecordIndex ix; TValue *functv = &J->L->base[func]; TRef *fbase = &J->base[func]; ptrdiff_t i; for (i = 0; i <= nargs; i++) (void)getslot(J, func+i); /* Ensure func and all args have a reference. */ if (!tref_isfunc(fbase[0])) { /* Resolve __call metamethod. */ ix.tab = fbase[0]; copyTV(J->L, &ix.tabv, functv); if (!lj_record_mm_lookup(J, &ix, MM_call) || !tref_isfunc(ix.mobj)) lj_trace_err(J, LJ_TRERR_NOMM); for (i = ++nargs; i > 0; i--) /* Shift arguments up. */ fbase[i] = fbase[i-1]; fbase[0] = ix.mobj; /* Replace function. */ functv = &ix.mobjv; } fbase[0] = TREF_FRAME | rec_call_specialize(J, funcV(functv), fbase[0]); J->maxslot = (BCReg)nargs; } /* Record call. */ void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs) { rec_call_setup(J, func, nargs); /* Bump frame. */ J->framedepth++; J->base += func+1; J->baseslot += func+1; } /* Record tail call. */ void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs) { rec_call_setup(J, func, nargs); if (frame_isvarg(J->L->base - 1)) { BCReg cbase = (BCReg)frame_delta(J->L->base - 1); if (--J->framedepth < 0) lj_trace_err(J, LJ_TRERR_NYIRETL); J->baseslot -= (BCReg)cbase; J->base -= cbase; func += cbase; } /* Move func + args down. */ memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1)); /* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */ /* Tailcalls can form a loop, so count towards the loop unroll limit. */ if (++J->tailcalled > J->loopunroll) lj_trace_err(J, LJ_TRERR_LUNROLL); } /* Check unroll limits for down-recursion. */ static int check_downrec_unroll(jit_State *J, GCproto *pt) { IRRef ptref; for (ptref = J->chain[IR_KGC]; ptref; ptref = IR(ptref)->prev) if (ir_kgc(IR(ptref)) == obj2gco(pt)) { int count = 0; IRRef ref; for (ref = J->chain[IR_RETF]; ref; ref = IR(ref)->prev) if (IR(ref)->op1 == ptref) count++; if (count) { if (J->pc == J->startpc) { if (count + J->tailcalled > J->param[JIT_P_recunroll]) return 1; } else { lj_trace_err(J, LJ_TRERR_DOWNREC); } } } return 0; } /* Record return. */ void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults) { TValue *frame = J->L->base - 1; ptrdiff_t i; for (i = 0; i < gotresults; i++) (void)getslot(J, rbase+i); /* Ensure all results have a reference. */ while (frame_ispcall(frame)) { /* Immediately resolve pcall() returns. */ BCReg cbase = (BCReg)frame_delta(frame); if (--J->framedepth < 0) lj_trace_err(J, LJ_TRERR_NYIRETL); lua_assert(J->baseslot > 1); gotresults++; rbase += cbase; J->baseslot -= (BCReg)cbase; J->base -= cbase; J->base[--rbase] = TREF_TRUE; /* Prepend true to results. */ frame = frame_prevd(frame); } /* Return to lower frame via interpreter for unhandled cases. */ if (J->framedepth == 0 && J->pt && bc_isret(bc_op(*J->pc)) && (!frame_islua(frame) || (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))))) { /* NYI: specialize to frame type and return directly, not via RET*. */ for (i = -1; i < (ptrdiff_t)rbase; i++) J->base[i] = 0; /* Purge dead slots. */ J->maxslot = rbase + (BCReg)gotresults; rec_stop(J, LJ_TRLINK_RETURN, 0); /* Return to interpreter. */ return; } if (frame_isvarg(frame)) { BCReg cbase = (BCReg)frame_delta(frame); if (--J->framedepth < 0) /* NYI: return of vararg func to lower frame. */ lj_trace_err(J, LJ_TRERR_NYIRETL); lua_assert(J->baseslot > 1); rbase += cbase; J->baseslot -= (BCReg)cbase; J->base -= cbase; frame = frame_prevd(frame); } if (frame_islua(frame)) { /* Return to Lua frame. */ BCIns callins = *(frame_pc(frame)-1); ptrdiff_t nresults = bc_b(callins) ? (ptrdiff_t)bc_b(callins)-1 :gotresults; BCReg cbase = bc_a(callins); GCproto *pt = funcproto(frame_func(frame - (cbase+1))); if (J->framedepth == 0 && J->pt && frame == J->L->base - 1) { if (check_downrec_unroll(J, pt)) { J->maxslot = (BCReg)(rbase + gotresults); lj_snap_purge(J); rec_stop(J, LJ_TRLINK_DOWNREC, J->cur.traceno); /* Down-recursion. */ return; } lj_snap_add(J); } for (i = 0; i < nresults; i++) /* Adjust results. */ J->base[i-1] = i < gotresults ? J->base[rbase+i] : TREF_NIL; J->maxslot = cbase+(BCReg)nresults; if (J->framedepth > 0) { /* Return to a frame that is part of the trace. */ J->framedepth--; lua_assert(J->baseslot > cbase+1); J->baseslot -= cbase+1; J->base -= cbase+1; } else if (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))) { /* Return to lower frame would leave the loop in a root trace. */ lj_trace_err(J, LJ_TRERR_LLEAVE); } else { /* Return to lower frame. Guard for the target we return to. */ TRef trpt = lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); TRef trpc = lj_ir_kptr(J, (void *)frame_pc(frame)); emitir(IRTG(IR_RETF, IRT_P32), trpt, trpc); J->retdepth++; J->needsnap = 1; lua_assert(J->baseslot == 1); /* Shift result slots up and clear the slots of the new frame below. */ memmove(J->base + cbase, J->base-1, sizeof(TRef)*nresults); memset(J->base-1, 0, sizeof(TRef)*(cbase+1)); } } else if (frame_iscont(frame)) { /* Return to continuation frame. */ ASMFunction cont = frame_contf(frame); BCReg cbase = (BCReg)frame_delta(frame); if ((J->framedepth -= 2) < 0) lj_trace_err(J, LJ_TRERR_NYIRETL); J->baseslot -= (BCReg)cbase; J->base -= cbase; J->maxslot = cbase-2; if (cont == lj_cont_ra) { /* Copy result to destination slot. */ BCReg dst = bc_a(*(frame_contpc(frame)-1)); J->base[dst] = gotresults ? J->base[cbase+rbase] : TREF_NIL; if (dst >= J->maxslot) J->maxslot = dst+1; } else if (cont == lj_cont_nop) { /* Nothing to do here. */ } else if (cont == lj_cont_cat) { lua_assert(0); } else { /* Result type already specialized. */ lua_assert(cont == lj_cont_condf || cont == lj_cont_condt); } } else { lj_trace_err(J, LJ_TRERR_NYIRETL); /* NYI: handle return to C frame. */ } lua_assert(J->baseslot >= 1); } /* -- Metamethod handling ------------------------------------------------- */ /* Prepare to record call to metamethod. */ static BCReg rec_mm_prep(jit_State *J, ASMFunction cont) { BCReg s, top = curr_proto(J->L)->framesize; TRef trcont; setcont(&J->L->base[top], cont); #if LJ_64 trcont = lj_ir_kptr(J, (void *)((int64_t)cont - (int64_t)lj_vm_asm_begin)); #else trcont = lj_ir_kptr(J, (void *)cont); #endif J->base[top] = trcont | TREF_CONT; J->framedepth++; for (s = J->maxslot; s < top; s++) J->base[s] = 0; /* Clear frame gap to avoid resurrecting previous refs. */ return top+1; } /* Record metamethod lookup. */ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) { RecordIndex mix; GCtab *mt; if (tref_istab(ix->tab)) { mt = tabref(tabV(&ix->tabv)->metatable); mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_TAB_META); } else if (tref_isudata(ix->tab)) { int udtype = udataV(&ix->tabv)->udtype; mt = tabref(udataV(&ix->tabv)->metatable); /* The metatables of special userdata objects are treated as immutable. */ if (udtype != UDTYPE_USERDATA) { cTValue *mo; if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) { /* Specialize to the C library namespace object. */ emitir(IRTG(IR_EQ, IRT_P32), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv))); } else { /* Specialize to the type of userdata. */ TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE); emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, udtype)); } immutable_mt: mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm)); if (!mo || tvisnil(mo)) return 0; /* No metamethod. */ /* Treat metamethod or index table as immutable, too. */ if (!(tvisfunc(mo) || tvistab(mo))) lj_trace_err(J, LJ_TRERR_BADTYPE); copyTV(J->L, &ix->mobjv, mo); ix->mobj = lj_ir_kgc(J, gcV(mo), tvisfunc(mo) ? IRT_FUNC : IRT_TAB); ix->mtv = mt; ix->mt = TREF_NIL; /* Dummy value for comparison semantics. */ return 1; /* Got metamethod or index table. */ } mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_UDATA_META); } else { /* Specialize to base metatable. Must flush mcode in lua_setmetatable(). */ mt = tabref(basemt_obj(J2G(J), &ix->tabv)); if (mt == NULL) { ix->mt = TREF_NIL; return 0; /* No metamethod. */ } /* The cdata metatable is treated as immutable. */ if (LJ_HASFFI && tref_iscdata(ix->tab)) goto immutable_mt; ix->mt = mix.tab = lj_ir_ktab(J, mt); goto nocheck; } ix->mt = mt ? mix.tab : TREF_NIL; emitir(IRTG(mt ? IR_NE : IR_EQ, IRT_TAB), mix.tab, lj_ir_knull(J, IRT_TAB)); nocheck: if (mt) { GCstr *mmstr = mmname_str(J2G(J), mm); cTValue *mo = lj_tab_getstr(mt, mmstr); if (mo && !tvisnil(mo)) copyTV(J->L, &ix->mobjv, mo); ix->mtv = mt; settabV(J->L, &mix.tabv, mt); setstrV(J->L, &mix.keyv, mmstr); mix.key = lj_ir_kstr(J, mmstr); mix.val = 0; mix.idxchain = 0; ix->mobj = lj_record_idx(J, &mix); return !tref_isnil(ix->mobj); /* 1 if metamethod found, 0 if not. */ } return 0; /* No metamethod. */ } /* Record call to arithmetic metamethod. */ static TRef rec_mm_arith(jit_State *J, RecordIndex *ix, MMS mm) { /* Set up metamethod call first to save ix->tab and ix->tabv. */ BCReg func = rec_mm_prep(J, lj_cont_ra); TRef *base = J->base + func; TValue *basev = J->L->base + func; base[1] = ix->tab; base[2] = ix->key; copyTV(J->L, basev+1, &ix->tabv); copyTV(J->L, basev+2, &ix->keyv); if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ if (mm != MM_unm) { ix->tab = ix->key; copyTV(J->L, &ix->tabv, &ix->keyv); if (lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */ goto ok; } lj_trace_err(J, LJ_TRERR_NOMM); } ok: base[0] = ix->mobj; copyTV(J->L, basev+0, &ix->mobjv); lj_record_call(J, func, 2); return 0; /* No result yet. */ } /* Record call to __len metamethod. */ static TRef rec_mm_len(jit_State *J, TRef tr, TValue *tv) { RecordIndex ix; ix.tab = tr; copyTV(J->L, &ix.tabv, tv); if (lj_record_mm_lookup(J, &ix, MM_len)) { BCReg func = rec_mm_prep(J, lj_cont_ra); TRef *base = J->base + func; TValue *basev = J->L->base + func; base[0] = ix.mobj; copyTV(J->L, basev+0, &ix.mobjv); base[1] = tr; copyTV(J->L, basev+1, tv); #if LJ_52 base[2] = tr; copyTV(J->L, basev+2, tv); #else base[2] = TREF_NIL; setnilV(basev+2); #endif lj_record_call(J, func, 2); } else { if (LJ_52 && tref_istab(tr)) return lj_ir_call(J, IRCALL_lj_tab_len, tr); lj_trace_err(J, LJ_TRERR_NOMM); } return 0; /* No result yet. */ } /* Call a comparison metamethod. */ static void rec_mm_callcomp(jit_State *J, RecordIndex *ix, int op) { BCReg func = rec_mm_prep(J, (op&1) ? lj_cont_condf : lj_cont_condt); TRef *base = J->base + func; TValue *tv = J->L->base + func; base[0] = ix->mobj; base[1] = ix->val; base[2] = ix->key; copyTV(J->L, tv+0, &ix->mobjv); copyTV(J->L, tv+1, &ix->valv); copyTV(J->L, tv+2, &ix->keyv); lj_record_call(J, func, 2); } /* Record call to equality comparison metamethod (for tab and udata only). */ static void rec_mm_equal(jit_State *J, RecordIndex *ix, int op) { ix->tab = ix->val; copyTV(J->L, &ix->tabv, &ix->valv); if (lj_record_mm_lookup(J, ix, MM_eq)) { /* Lookup mm on 1st operand. */ cTValue *bv; TRef mo1 = ix->mobj; TValue mo1v; copyTV(J->L, &mo1v, &ix->mobjv); /* Avoid the 2nd lookup and the objcmp if the metatables are equal. */ bv = &ix->keyv; if (tvistab(bv) && tabref(tabV(bv)->metatable) == ix->mtv) { TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_TAB_META); emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); } else if (tvisudata(bv) && tabref(udataV(bv)->metatable) == ix->mtv) { TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_UDATA_META); emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); } else { /* Lookup metamethod on 2nd operand and compare both. */ ix->tab = ix->key; copyTV(J->L, &ix->tabv, bv); if (!lj_record_mm_lookup(J, ix, MM_eq) || lj_record_objcmp(J, mo1, ix->mobj, &mo1v, &ix->mobjv)) return; } rec_mm_callcomp(J, ix, op); } } /* Record call to ordered comparison metamethods (for arbitrary objects). */ static void rec_mm_comp(jit_State *J, RecordIndex *ix, int op) { ix->tab = ix->val; copyTV(J->L, &ix->tabv, &ix->valv); while (1) { MMS mm = (op & 2) ? MM_le : MM_lt; /* Try __le + __lt or only __lt. */ #if LJ_52 if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ ix->tab = ix->key; copyTV(J->L, &ix->tabv, &ix->keyv); if (!lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */ goto nomatch; } rec_mm_callcomp(J, ix, op); return; #else if (lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */ cTValue *bv; TRef mo1 = ix->mobj; TValue mo1v; copyTV(J->L, &mo1v, &ix->mobjv); /* Avoid the 2nd lookup and the objcmp if the metatables are equal. */ bv = &ix->keyv; if (tvistab(bv) && tabref(tabV(bv)->metatable) == ix->mtv) { TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_TAB_META); emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); } else if (tvisudata(bv) && tabref(udataV(bv)->metatable) == ix->mtv) { TRef mt2 = emitir(IRT(IR_FLOAD, IRT_TAB), ix->key, IRFL_UDATA_META); emitir(IRTG(IR_EQ, IRT_TAB), mt2, ix->mt); } else { /* Lookup metamethod on 2nd operand and compare both. */ ix->tab = ix->key; copyTV(J->L, &ix->tabv, bv); if (!lj_record_mm_lookup(J, ix, mm) || lj_record_objcmp(J, mo1, ix->mobj, &mo1v, &ix->mobjv)) goto nomatch; } rec_mm_callcomp(J, ix, op); return; } #endif nomatch: /* Lookup failed. Retry with __lt and swapped operands. */ if (!(op & 2)) break; /* Already at __lt. Interpreter will throw. */ ix->tab = ix->key; ix->key = ix->val; ix->val = ix->tab; copyTV(J->L, &ix->tabv, &ix->keyv); copyTV(J->L, &ix->keyv, &ix->valv); copyTV(J->L, &ix->valv, &ix->tabv); op ^= 3; } } #if LJ_HASFFI /* Setup call to cdata comparison metamethod. */ static void rec_mm_comp_cdata(jit_State *J, RecordIndex *ix, int op, MMS mm) { lj_snap_add(J); if (tref_iscdata(ix->val)) { ix->tab = ix->val; copyTV(J->L, &ix->tabv, &ix->valv); } else { lua_assert(tref_iscdata(ix->key)); ix->tab = ix->key; copyTV(J->L, &ix->tabv, &ix->keyv); } lj_record_mm_lookup(J, ix, mm); rec_mm_callcomp(J, ix, op); } #endif /* -- Indexed access ------------------------------------------------------ */ /* Record bounds-check. */ static void rec_idx_abc(jit_State *J, TRef asizeref, TRef ikey, uint32_t asize) { /* Try to emit invariant bounds checks. */ if ((J->flags & (JIT_F_OPT_LOOP|JIT_F_OPT_ABC)) == (JIT_F_OPT_LOOP|JIT_F_OPT_ABC)) { IRRef ref = tref_ref(ikey); IRIns *ir = IR(ref); int32_t ofs = 0; IRRef ofsref = 0; /* Handle constant offsets. */ if (ir->o == IR_ADD && irref_isk(ir->op2)) { ofsref = ir->op2; ofs = IR(ofsref)->i; ref = ir->op1; ir = IR(ref); } /* Got scalar evolution analysis results for this reference? */ if (ref == J->scev.idx) { int32_t stop; lua_assert(irt_isint(J->scev.t) && ir->o == IR_SLOAD); stop = numberVint(&(J->L->base - J->baseslot)[ir->op1 + FORL_STOP]); /* Runtime value for stop of loop is within bounds? */ if ((int64_t)stop + ofs < (int64_t)asize) { /* Emit invariant bounds check for stop. */ emitir(IRTG(IR_ABC, IRT_P32), asizeref, ofs == 0 ? J->scev.stop : emitir(IRTI(IR_ADD), J->scev.stop, ofsref)); /* Emit invariant bounds check for start, if not const or negative. */ if (!(J->scev.dir && J->scev.start && (int64_t)IR(J->scev.start)->i + ofs >= 0)) emitir(IRTG(IR_ABC, IRT_P32), asizeref, ikey); return; } } } emitir(IRTGI(IR_ABC), asizeref, ikey); /* Emit regular bounds check. */ } /* Record indexed key lookup. */ static TRef rec_idx_key(jit_State *J, RecordIndex *ix) { TRef key; GCtab *t = tabV(&ix->tabv); ix->oldv = lj_tab_get(J->L, t, &ix->keyv); /* Lookup previous value. */ /* Integer keys are looked up in the array part first. */ key = ix->key; if (tref_isnumber(key)) { int32_t k = numberVint(&ix->keyv); if (!tvisint(&ix->keyv) && numV(&ix->keyv) != (lua_Number)k) k = LJ_MAX_ASIZE; if ((MSize)k < LJ_MAX_ASIZE) { /* Potential array key? */ TRef ikey = lj_opt_narrow_index(J, key); TRef asizeref = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); if ((MSize)k < t->asize) { /* Currently an array key? */ TRef arrayref; rec_idx_abc(J, asizeref, ikey, t->asize); arrayref = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_ARRAY); return emitir(IRT(IR_AREF, IRT_P32), arrayref, ikey); } else { /* Currently not in array (may be an array extension)? */ emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */ if (k == 0 && tref_isk(key)) key = lj_ir_knum_zero(J); /* Canonicalize 0 or +-0.0 to +0.0. */ /* And continue with the hash lookup. */ } } else if (!tref_isk(key)) { /* We can rule out const numbers which failed the integerness test ** above. But all other numbers are potential array keys. */ if (t->asize == 0) { /* True sparse tables have an empty array part. */ /* Guard that the array part stays empty. */ TRef tmp = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_ASIZE); emitir(IRTGI(IR_EQ), tmp, lj_ir_kint(J, 0)); } else { lj_trace_err(J, LJ_TRERR_NYITMIX); } } } /* Otherwise the key is located in the hash part. */ if (t->hmask == 0) { /* Shortcut for empty hash part. */ /* Guard that the hash part stays empty. */ TRef tmp = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); emitir(IRTGI(IR_EQ), tmp, lj_ir_kint(J, 0)); return lj_ir_kkptr(J, niltvg(J2G(J))); } if (tref_isinteger(key)) /* Hash keys are based on numbers, not ints. */ key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); if (tref_isk(key)) { /* Optimize lookup of constant hash keys. */ MSize hslot = (MSize)((char *)ix->oldv - (char *)&noderef(t->node)[0].val); if (t->hmask > 0 && hslot <= t->hmask*(MSize)sizeof(Node) && hslot <= 65535*(MSize)sizeof(Node)) { TRef node, kslot; TRef hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask)); node = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_NODE); kslot = lj_ir_kslot(J, key, hslot / sizeof(Node)); return emitir(IRTG(IR_HREFK, IRT_P32), node, kslot); } } /* Fall back to a regular hash lookup. */ return emitir(IRT(IR_HREF, IRT_P32), ix->tab, key); } /* Determine whether a key is NOT one of the fast metamethod names. */ static int nommstr(jit_State *J, TRef key) { if (tref_isstr(key)) { if (tref_isk(key)) { GCstr *str = ir_kstr(IR(tref_ref(key))); uint32_t mm; for (mm = 0; mm <= MM_FAST; mm++) if (mmname_str(J2G(J), mm) == str) return 0; /* MUST be one the fast metamethod names. */ } else { return 0; /* Variable string key MAY be a metamethod name. */ } } return 1; /* CANNOT be a metamethod name. */ } /* Record indexed load/store. */ TRef lj_record_idx(jit_State *J, RecordIndex *ix) { TRef xref; IROp xrefop, loadop; cTValue *oldv; while (!tref_istab(ix->tab)) { /* Handle non-table lookup. */ /* Never call raw lj_record_idx() on non-table. */ lua_assert(ix->idxchain != 0); if (!lj_record_mm_lookup(J, ix, ix->val ? MM_newindex : MM_index)) lj_trace_err(J, LJ_TRERR_NOMM); handlemm: if (tref_isfunc(ix->mobj)) { /* Handle metamethod call. */ BCReg func = rec_mm_prep(J, ix->val ? lj_cont_nop : lj_cont_ra); TRef *base = J->base + func; TValue *tv = J->L->base + func; base[0] = ix->mobj; base[1] = ix->tab; base[2] = ix->key; setfuncV(J->L, tv+0, funcV(&ix->mobjv)); copyTV(J->L, tv+1, &ix->tabv); copyTV(J->L, tv+2, &ix->keyv); if (ix->val) { base[3] = ix->val; copyTV(J->L, tv+3, &ix->valv); lj_record_call(J, func, 3); /* mobj(tab, key, val) */ return 0; } else { lj_record_call(J, func, 2); /* res = mobj(tab, key) */ return 0; /* No result yet. */ } } /* Otherwise retry lookup with metaobject. */ ix->tab = ix->mobj; copyTV(J->L, &ix->tabv, &ix->mobjv); if (--ix->idxchain == 0) lj_trace_err(J, LJ_TRERR_IDXLOOP); } /* First catch nil and NaN keys for tables. */ if (tvisnil(&ix->keyv) || (tvisnum(&ix->keyv) && tvisnan(&ix->keyv))) { if (ix->val) /* Better fail early. */ lj_trace_err(J, LJ_TRERR_STORENN); if (tref_isk(ix->key)) { if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_index)) goto handlemm; return TREF_NIL; } } /* Record the key lookup. */ xref = rec_idx_key(J, ix); xrefop = IR(tref_ref(xref))->o; loadop = xrefop == IR_AREF ? IR_ALOAD : IR_HLOAD; /* The lj_meta_tset() inconsistency is gone, but better play safe. */ oldv = xrefop == IR_KKPTR ? (cTValue *)ir_kptr(IR(tref_ref(xref))) : ix->oldv; if (ix->val == 0) { /* Indexed load */ IRType t = itype2irt(oldv); TRef res; if (oldv == niltvg(J2G(J))) { emitir(IRTG(IR_EQ, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); res = TREF_NIL; } else { res = emitir(IRTG(loadop, t), xref, 0); } if (t == IRT_NIL && ix->idxchain && lj_record_mm_lookup(J, ix, MM_index)) goto handlemm; if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitives. */ return res; } else { /* Indexed store. */ GCtab *mt = tabref(tabV(&ix->tabv)->metatable); int keybarrier = tref_isgcv(ix->key) && !tref_isnil(ix->val); if (tvisnil(oldv)) { /* Previous value was nil? */ /* Need to duplicate the hasmm check for the early guards. */ int hasmm = 0; if (ix->idxchain && mt) { cTValue *mo = lj_tab_getstr(mt, mmname_str(J2G(J), MM_newindex)); hasmm = mo && !tvisnil(mo); } if (hasmm) emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */ else if (xrefop == IR_HREF) emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) { lua_assert(hasmm); goto handlemm; } lua_assert(!hasmm); if (oldv == niltvg(J2G(J))) { /* Need to insert a new key. */ TRef key = ix->key; if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */ key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key); keybarrier = 0; /* NEWREF already takes care of the key barrier. */ } } else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) { /* Cannot derive that the previous value was non-nil, must do checks. */ if (xrefop == IR_HREF) /* Guard against store to niltv. */ emitir(IRTG(IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); if (ix->idxchain) { /* Metamethod lookup required? */ /* A check for NULL metatable is cheaper (hoistable) than a load. */ if (!mt) { TRef mtref = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_TAB_META); emitir(IRTG(IR_EQ, IRT_TAB), mtref, lj_ir_knull(J, IRT_TAB)); } else { IRType t = itype2irt(oldv); emitir(IRTG(loadop, t), xref, 0); /* Guard for non-nil value. */ } } } else { keybarrier = 0; /* Previous non-nil value kept the key alive. */ } /* Convert int to number before storing. */ if (!LJ_DUALNUM && tref_isinteger(ix->val)) ix->val = emitir(IRTN(IR_CONV), ix->val, IRCONV_NUM_INT); emitir(IRT(loadop+IRDELTA_L2S, tref_type(ix->val)), xref, ix->val); if (keybarrier || tref_isgcv(ix->val)) emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0); /* Invalidate neg. metamethod cache for stores with certain string keys. */ if (!nommstr(J, ix->key)) { TRef fref = emitir(IRT(IR_FREF, IRT_P32), ix->tab, IRFL_TAB_NOMM); emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0)); } J->needsnap = 1; return 0; } } /* -- Upvalue access ------------------------------------------------------ */ /* Check whether upvalue is immutable and ok to constify. */ static int rec_upvalue_constify(jit_State *J, GCupval *uvp) { if (uvp->immutable) { cTValue *o = uvval(uvp); /* Don't constify objects that may retain large amounts of memory. */ #if LJ_HASFFI if (tviscdata(o)) { GCcdata *cd = cdataV(o); if (!cdataisv(cd) && !(cd->marked & LJ_GC_CDATA_FIN)) { CType *ct = ctype_raw(ctype_ctsG(J2G(J)), cd->ctypeid); if (!ctype_hassize(ct->info) || ct->size <= 16) return 1; } return 0; } #else UNUSED(J); #endif if (!(tvistab(o) || tvisudata(o) || tvisthread(o))) return 1; } return 0; } /* Record upvalue load/store. */ static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) { GCupval *uvp = &gcref(J->fn->l.uvptr[uv])->uv; TRef fn = getcurrf(J); IRRef uref; int needbarrier = 0; if (rec_upvalue_constify(J, uvp)) { /* Try to constify immutable upvalue. */ TRef tr, kfunc; lua_assert(val == 0); if (!tref_isk(fn)) { /* Late specialization of current function. */ if (J->pt->flags >= PROTO_CLC_POLY) goto noconstify; kfunc = lj_ir_kfunc(J, J->fn); emitir(IRTG(IR_EQ, IRT_FUNC), fn, kfunc); J->base[-1] = TREF_FRAME | kfunc; fn = kfunc; } tr = lj_record_constify(J, uvval(uvp)); if (tr) return tr; } noconstify: /* Note: this effectively limits LJ_MAX_UPVAL to 127. */ uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff); if (!uvp->closed) { /* In current stack? */ if (uvval(uvp) >= tvref(J->L->stack) && uvval(uvp) < tvref(J->L->maxstack)) { int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot)); if (slot >= 0) { /* Aliases an SSA slot? */ slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */ /* NYI: add IR to guard that it's still aliasing the same slot. */ if (val == 0) { return getslot(J, slot); } else { J->base[slot] = val; if (slot >= (int32_t)J->maxslot) J->maxslot = (BCReg)(slot+1); return 0; } } } uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_P32), fn, uv)); } else { needbarrier = 1; uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_P32), fn, uv)); } if (val == 0) { /* Upvalue load */ IRType t = itype2irt(uvval(uvp)); TRef res = emitir(IRTG(IR_ULOAD, t), uref, 0); if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitive refs. */ return res; } else { /* Upvalue store. */ /* Convert int to number before storing. */ if (!LJ_DUALNUM && tref_isinteger(val)) val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); emitir(IRT(IR_USTORE, tref_type(val)), uref, val); if (needbarrier && tref_isgcv(val)) emitir(IRT(IR_OBAR, IRT_NIL), uref, val); J->needsnap = 1; return 0; } } /* -- Record calls to Lua functions --------------------------------------- */ /* Check unroll limits for calls. */ static void check_call_unroll(jit_State *J, TraceNo lnk) { cTValue *frame = J->L->base - 1; void *pc = mref(frame_func(frame)->l.pc, void); int32_t depth = J->framedepth; int32_t count = 0; if ((J->pt->flags & PROTO_VARARG)) depth--; /* Vararg frame still missing. */ for (; depth > 0; depth--) { /* Count frames with same prototype. */ frame = frame_prev(frame); if (mref(frame_func(frame)->l.pc, void) == pc) count++; } if (J->pc == J->startpc) { if (count + J->tailcalled > J->param[JIT_P_recunroll]) { J->pc++; if (J->framedepth + J->retdepth == 0) rec_stop(J, LJ_TRLINK_TAILREC, J->cur.traceno); /* Tail-recursion. */ else rec_stop(J, LJ_TRLINK_UPREC, J->cur.traceno); /* Up-recursion. */ } } else { if (count > J->param[JIT_P_callunroll]) { if (lnk) { /* Possible tail- or up-recursion. */ lj_trace_flush(J, lnk); /* Flush trace that only returns. */ /* Set a small, pseudo-random hotcount for a quick retry of JFUNC*. */ hotcount_set(J2GG(J), J->pc+1, LJ_PRNG_BITS(J, 4)); } lj_trace_err(J, LJ_TRERR_CUNROLL); } } } /* Record Lua function setup. */ static void rec_func_setup(jit_State *J) { GCproto *pt = J->pt; BCReg s, numparams = pt->numparams; if ((pt->flags & PROTO_NOJIT)) lj_trace_err(J, LJ_TRERR_CJITOFF); if (J->baseslot + pt->framesize >= LJ_MAX_JSLOTS) lj_trace_err(J, LJ_TRERR_STACKOV); /* Fill up missing parameters with nil. */ for (s = J->maxslot; s < numparams; s++) J->base[s] = TREF_NIL; /* The remaining slots should never be read before they are written. */ J->maxslot = numparams; } /* Record Lua vararg function setup. */ static void rec_func_vararg(jit_State *J) { GCproto *pt = J->pt; BCReg s, fixargs, vframe = J->maxslot+1; lua_assert((pt->flags & PROTO_VARARG)); if (J->baseslot + vframe + pt->framesize >= LJ_MAX_JSLOTS) lj_trace_err(J, LJ_TRERR_STACKOV); J->base[vframe-1] = J->base[-1]; /* Copy function up. */ /* Copy fixarg slots up and set their original slots to nil. */ fixargs = pt->numparams < J->maxslot ? pt->numparams : J->maxslot; for (s = 0; s < fixargs; s++) { J->base[vframe+s] = J->base[s]; J->base[s] = TREF_NIL; } J->maxslot = fixargs; J->framedepth++; J->base += vframe; J->baseslot += vframe; } /* Record entry to a Lua function. */ static void rec_func_lua(jit_State *J) { rec_func_setup(J); check_call_unroll(J, 0); } /* Record entry to an already compiled function. */ static void rec_func_jit(jit_State *J, TraceNo lnk) { GCtrace *T; rec_func_setup(J); T = traceref(J, lnk); if (T->linktype == LJ_TRLINK_RETURN) { /* Trace returns to interpreter? */ check_call_unroll(J, lnk); /* Temporarily unpatch JFUNC* to continue recording across function. */ J->patchins = *J->pc; J->patchpc = (BCIns *)J->pc; *J->patchpc = T->startins; return; } J->instunroll = 0; /* Cannot continue across a compiled function. */ if (J->pc == J->startpc && J->framedepth + J->retdepth == 0) rec_stop(J, LJ_TRLINK_TAILREC, J->cur.traceno); /* Extra tail-recursion. */ else rec_stop(J, LJ_TRLINK_ROOT, lnk); /* Link to the function. */ } /* -- Vararg handling ----------------------------------------------------- */ /* Detect y = select(x, ...) idiom. */ static int select_detect(jit_State *J) { BCIns ins = J->pc[1]; if (bc_op(ins) == BC_CALLM && bc_b(ins) == 2 && bc_c(ins) == 1) { cTValue *func = &J->L->base[bc_a(ins)]; if (tvisfunc(func) && funcV(func)->c.ffid == FF_select) return 1; } return 0; } /* Record vararg instruction. */ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) { int32_t numparams = J->pt->numparams; ptrdiff_t nvararg = frame_delta(J->L->base-1) - numparams - 1; lua_assert(frame_isvarg(J->L->base-1)); if (J->framedepth > 0) { /* Simple case: varargs defined on-trace. */ ptrdiff_t i; if (nvararg < 0) nvararg = 0; if (nresults == -1) { nresults = nvararg; J->maxslot = dst + (BCReg)nvararg; } else if (dst + nresults > J->maxslot) { J->maxslot = dst + (BCReg)nresults; } for (i = 0; i < nresults; i++) { J->base[dst+i] = i < nvararg ? J->base[i - nvararg - 1] : TREF_NIL; lua_assert(J->base[dst+i] != 0); } } else { /* Unknown number of varargs passed to trace. */ TRef fr = emitir(IRTI(IR_SLOAD), 0, IRSLOAD_READONLY|IRSLOAD_FRAME); int32_t frofs = 8*(1+numparams)+FRAME_VARG; if (nresults >= 0) { /* Known fixed number of results. */ ptrdiff_t i; if (nvararg > 0) { ptrdiff_t nload = nvararg >= nresults ? nresults : nvararg; TRef vbase; if (nvararg >= nresults) emitir(IRTGI(IR_GE), fr, lj_ir_kint(J, frofs+8*(int32_t)nresults)); else emitir(IRTGI(IR_EQ), fr, lj_ir_kint(J, frame_ftsz(J->L->base-1))); vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); for (i = 0; i < nload; i++) { IRType t = itype2irt(&J->L->base[i-1-nvararg]); TRef aref = emitir(IRT(IR_AREF, IRT_P32), vbase, lj_ir_kint(J, (int32_t)i)); TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0); if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ J->base[dst+i] = tr; } } else { emitir(IRTGI(IR_LE), fr, lj_ir_kint(J, frofs)); nvararg = 0; } for (i = nvararg; i < nresults; i++) J->base[dst+i] = TREF_NIL; if (dst + (BCReg)nresults > J->maxslot) J->maxslot = dst + (BCReg)nresults; } else if (select_detect(J)) { /* y = select(x, ...) */ TRef tridx = J->base[dst-1]; TRef tr = TREF_NIL; ptrdiff_t idx = lj_ffrecord_select_mode(J, tridx, &J->L->base[dst-1]); if (idx < 0) goto nyivarg; if (idx != 0 && !tref_isinteger(tridx)) tridx = emitir(IRTGI(IR_CONV), tridx, IRCONV_INT_NUM|IRCONV_INDEX); if (idx != 0 && tref_isk(tridx)) { emitir(IRTGI(idx <= nvararg ? IR_GE : IR_LT), fr, lj_ir_kint(J, frofs+8*(int32_t)idx)); frofs -= 8; /* Bias for 1-based index. */ } else if (idx <= nvararg) { /* Compute size. */ TRef tmp = emitir(IRTI(IR_ADD), fr, lj_ir_kint(J, -frofs)); if (numparams) emitir(IRTGI(IR_GE), tmp, lj_ir_kint(J, 0)); tr = emitir(IRTI(IR_BSHR), tmp, lj_ir_kint(J, 3)); if (idx != 0) { tridx = emitir(IRTI(IR_ADD), tridx, lj_ir_kint(J, -1)); rec_idx_abc(J, tr, tridx, (uint32_t)nvararg); } } else { TRef tmp = lj_ir_kint(J, frofs); if (idx != 0) { TRef tmp2 = emitir(IRTI(IR_BSHL), tridx, lj_ir_kint(J, 3)); tmp = emitir(IRTI(IR_ADD), tmp2, tmp); } else { tr = lj_ir_kint(J, 0); } emitir(IRTGI(IR_LT), fr, tmp); } if (idx != 0 && idx <= nvararg) { IRType t; TRef aref, vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); t = itype2irt(&J->L->base[idx-2-nvararg]); aref = emitir(IRT(IR_AREF, IRT_P32), vbase, tridx); tr = emitir(IRTG(IR_VLOAD, t), aref, 0); if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ } J->base[dst-2] = tr; J->maxslot = dst-1; J->bcskip = 2; /* Skip CALLM + select. */ } else { nyivarg: setintV(&J->errinfo, BC_VARG); lj_trace_err_info(J, LJ_TRERR_NYIBC); } } } /* -- Record allocations -------------------------------------------------- */ static TRef rec_tnew(jit_State *J, uint32_t ah) { uint32_t asize = ah & 0x7ff; uint32_t hbits = ah >> 11; if (asize == 0x7ff) asize = 0x801; return emitir(IRTG(IR_TNEW, IRT_TAB), asize, hbits); } /* -- Record bytecode ops ------------------------------------------------- */ /* Prepare for comparison. */ static void rec_comp_prep(jit_State *J) { /* Prevent merging with snapshot #0 (GC exit) since we fixup the PC. */ if (J->cur.nsnap == 1 && J->cur.snap[0].ref == J->cur.nins) emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); lj_snap_add(J); } /* Fixup comparison. */ static void rec_comp_fixup(jit_State *J, const BCIns *pc, int cond) { BCIns jmpins = pc[1]; const BCIns *npc = pc + 2 + (cond ? bc_j(jmpins) : 0); SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; /* Set PC to opposite target to avoid re-recording the comp. in side trace. */ J->cur.snapmap[snap->mapofs + snap->nent] = SNAP_MKPC(npc); J->needsnap = 1; if (bc_a(jmpins) < J->maxslot) J->maxslot = bc_a(jmpins); lj_snap_shrink(J); /* Shrink last snapshot if possible. */ } /* Record the next bytecode instruction (_before_ it's executed). */ void lj_record_ins(jit_State *J) { cTValue *lbase; RecordIndex ix; const BCIns *pc; BCIns ins; BCOp op; TRef ra, rb, rc; /* Perform post-processing action before recording the next instruction. */ if (LJ_UNLIKELY(J->postproc != LJ_POST_NONE)) { switch (J->postproc) { case LJ_POST_FIXCOMP: /* Fixup comparison. */ pc = frame_pc(&J2G(J)->tmptv); rec_comp_fixup(J, pc, (!tvistruecond(&J2G(J)->tmptv2) ^ (bc_op(*pc)&1))); /* fallthrough */ case LJ_POST_FIXGUARD: /* Fixup and emit pending guard. */ case LJ_POST_FIXGUARDSNAP: /* Fixup and emit pending guard and snapshot. */ if (!tvistruecond(&J2G(J)->tmptv2)) { J->fold.ins.o ^= 1; /* Flip guard to opposite. */ if (J->postproc == LJ_POST_FIXGUARDSNAP) { SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; J->cur.snapmap[snap->mapofs+snap->nent-1]--; /* False -> true. */ } } lj_opt_fold(J); /* Emit pending guard. */ /* fallthrough */ case LJ_POST_FIXBOOL: if (!tvistruecond(&J2G(J)->tmptv2)) { BCReg s; TValue *tv = J->L->base; for (s = 0; s < J->maxslot; s++) /* Fixup stack slot (if any). */ if (J->base[s] == TREF_TRUE && tvisfalse(&tv[s])) { J->base[s] = TREF_FALSE; break; } } break; case LJ_POST_FIXCONST: { BCReg s; TValue *tv = J->L->base; for (s = 0; s < J->maxslot; s++) /* Constify stack slots (if any). */ if (J->base[s] == TREF_NIL && !tvisnil(&tv[s])) J->base[s] = lj_record_constify(J, &tv[s]); } break; case LJ_POST_FFRETRY: /* Suppress recording of retried fast function. */ if (bc_op(*J->pc) >= BC__MAX) return; break; default: lua_assert(0); break; } J->postproc = LJ_POST_NONE; } /* Need snapshot before recording next bytecode (e.g. after a store). */ if (J->needsnap) { J->needsnap = 0; lj_snap_purge(J); lj_snap_add(J); J->mergesnap = 1; } /* Skip some bytecodes. */ if (LJ_UNLIKELY(J->bcskip > 0)) { J->bcskip--; return; } /* Record only closed loops for root traces. */ pc = J->pc; if (J->framedepth == 0 && (MSize)((char *)pc - (char *)J->bc_min) >= J->bc_extent) lj_trace_err(J, LJ_TRERR_LLEAVE); #ifdef LUA_USE_ASSERT rec_check_slots(J); rec_check_ir(J); #endif /* Keep a copy of the runtime values of var/num/str operands. */ #define rav (&ix.valv) #define rbv (&ix.tabv) #define rcv (&ix.keyv) lbase = J->L->base; ins = *pc; op = bc_op(ins); ra = bc_a(ins); ix.val = 0; switch (bcmode_a(op)) { case BCMvar: copyTV(J->L, rav, &lbase[ra]); ix.val = ra = getslot(J, ra); break; default: break; /* Handled later. */ } rb = bc_b(ins); rc = bc_c(ins); switch (bcmode_b(op)) { case BCMnone: rb = 0; rc = bc_d(ins); break; /* Upgrade rc to 'rd'. */ case BCMvar: copyTV(J->L, rbv, &lbase[rb]); ix.tab = rb = getslot(J, rb); break; default: break; /* Handled later. */ } switch (bcmode_c(op)) { case BCMvar: copyTV(J->L, rcv, &lbase[rc]); ix.key = rc = getslot(J, rc); break; case BCMpri: setitype(rcv, ~rc); ix.key = rc = TREF_PRI(IRT_NIL+rc); break; case BCMnum: { cTValue *tv = proto_knumtv(J->pt, rc); copyTV(J->L, rcv, tv); ix.key = rc = tvisint(tv) ? lj_ir_kint(J, intV(tv)) : lj_ir_knumint(J, numV(tv)); } break; case BCMstr: { GCstr *s = gco2str(proto_kgc(J->pt, ~(ptrdiff_t)rc)); setstrV(J->L, rcv, s); ix.key = rc = lj_ir_kstr(J, s); } break; default: break; /* Handled later. */ } switch (op) { /* -- Comparison ops ---------------------------------------------------- */ case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: #if LJ_HASFFI if (tref_iscdata(ra) || tref_iscdata(rc)) { rec_mm_comp_cdata(J, &ix, op, ((int)op & 2) ? MM_le : MM_lt); break; } #endif /* Emit nothing for two numeric or string consts. */ if (!(tref_isk2(ra,rc) && tref_isnumber_str(ra) && tref_isnumber_str(rc))) { IRType ta = tref_isinteger(ra) ? IRT_INT : tref_type(ra); IRType tc = tref_isinteger(rc) ? IRT_INT : tref_type(rc); int irop; if (ta != tc) { /* Widen mixed number/int comparisons to number/number comparison. */ if (ta == IRT_INT && tc == IRT_NUM) { ra = emitir(IRTN(IR_CONV), ra, IRCONV_NUM_INT); ta = IRT_NUM; } else if (ta == IRT_NUM && tc == IRT_INT) { rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT); } else if (LJ_52) { ta = IRT_NIL; /* Force metamethod for different types. */ } else if (!((ta == IRT_FALSE || ta == IRT_TRUE) && (tc == IRT_FALSE || tc == IRT_TRUE))) { break; /* Interpreter will throw for two different types. */ } } rec_comp_prep(J); irop = (int)op - (int)BC_ISLT + (int)IR_LT; if (ta == IRT_NUM) { if ((irop & 1)) irop ^= 4; /* ISGE/ISGT are unordered. */ if (!lj_ir_numcmp(numberVnum(rav), numberVnum(rcv), (IROp)irop)) irop ^= 5; } else if (ta == IRT_INT) { if (!lj_ir_numcmp(numberVnum(rav), numberVnum(rcv), (IROp)irop)) irop ^= 1; } else if (ta == IRT_STR) { if (!lj_ir_strcmp(strV(rav), strV(rcv), (IROp)irop)) irop ^= 1; ra = lj_ir_call(J, IRCALL_lj_str_cmp, ra, rc); rc = lj_ir_kint(J, 0); ta = IRT_INT; } else { rec_mm_comp(J, &ix, (int)op); break; } emitir(IRTG(irop, ta), ra, rc); rec_comp_fixup(J, J->pc, ((int)op ^ irop) & 1); } break; case BC_ISEQV: case BC_ISNEV: case BC_ISEQS: case BC_ISNES: case BC_ISEQN: case BC_ISNEN: case BC_ISEQP: case BC_ISNEP: #if LJ_HASFFI if (tref_iscdata(ra) || tref_iscdata(rc)) { rec_mm_comp_cdata(J, &ix, op, MM_eq); break; } #endif /* Emit nothing for two non-table, non-udata consts. */ if (!(tref_isk2(ra, rc) && !(tref_istab(ra) || tref_isudata(ra)))) { int diff; rec_comp_prep(J); diff = lj_record_objcmp(J, ra, rc, rav, rcv); if (diff == 2 || !(tref_istab(ra) || tref_isudata(ra))) rec_comp_fixup(J, J->pc, ((int)op & 1) == !diff); else if (diff == 1) /* Only check __eq if different, but same type. */ rec_mm_equal(J, &ix, (int)op); } break; /* -- Unary test and copy ops ------------------------------------------- */ case BC_ISTC: case BC_ISFC: if ((op & 1) == tref_istruecond(rc)) rc = 0; /* Don't store if condition is not true. */ /* fallthrough */ case BC_IST: case BC_ISF: /* Type specialization suffices. */ if (bc_a(pc[1]) < J->maxslot) J->maxslot = bc_a(pc[1]); /* Shrink used slots. */ break; /* -- Unary ops --------------------------------------------------------- */ case BC_NOT: /* Type specialization already forces const result. */ rc = tref_istruecond(rc) ? TREF_FALSE : TREF_TRUE; break; case BC_LEN: if (tref_isstr(rc)) rc = emitir(IRTI(IR_FLOAD), rc, IRFL_STR_LEN); else if (!LJ_52 && tref_istab(rc)) rc = lj_ir_call(J, IRCALL_lj_tab_len, rc); else rc = rec_mm_len(J, rc, rcv); break; /* -- Arithmetic ops ---------------------------------------------------- */ case BC_UNM: if (tref_isnumber_str(rc)) { rc = lj_opt_narrow_unm(J, rc, rcv); } else { ix.tab = rc; copyTV(J->L, &ix.tabv, rcv); rc = rec_mm_arith(J, &ix, MM_unm); } break; case BC_ADDNV: case BC_SUBNV: case BC_MULNV: case BC_DIVNV: case BC_MODNV: /* Swap rb/rc and rbv/rcv. rav is temp. */ ix.tab = rc; ix.key = rc = rb; rb = ix.tab; copyTV(J->L, rav, rbv); copyTV(J->L, rbv, rcv); copyTV(J->L, rcv, rav); if (op == BC_MODNV) goto recmod; /* fallthrough */ case BC_ADDVN: case BC_SUBVN: case BC_MULVN: case BC_DIVVN: case BC_ADDVV: case BC_SUBVV: case BC_MULVV: case BC_DIVVV: { MMS mm = bcmode_mm(op); if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) rc = lj_opt_narrow_arith(J, rb, rc, rbv, rcv, (int)mm - (int)MM_add + (int)IR_ADD); else rc = rec_mm_arith(J, &ix, mm); break; } case BC_MODVN: case BC_MODVV: recmod: if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) rc = lj_opt_narrow_mod(J, rb, rc, rcv); else rc = rec_mm_arith(J, &ix, MM_mod); break; case BC_POW: if (tref_isnumber_str(rb) && tref_isnumber_str(rc)) rc = lj_opt_narrow_pow(J, lj_ir_tonum(J, rb), rc, rcv); else rc = rec_mm_arith(J, &ix, MM_pow); break; /* -- Constant and move ops --------------------------------------------- */ case BC_MOV: /* Clear gap of method call to avoid resurrecting previous refs. */ if (ra > J->maxslot) J->base[ra-1] = 0; break; case BC_KSTR: case BC_KNUM: case BC_KPRI: break; case BC_KSHORT: rc = lj_ir_kint(J, (int32_t)(int16_t)rc); break; case BC_KNIL: while (ra <= rc) J->base[ra++] = TREF_NIL; if (rc >= J->maxslot) J->maxslot = rc+1; break; #if LJ_HASFFI case BC_KCDATA: rc = lj_ir_kgc(J, proto_kgc(J->pt, ~(ptrdiff_t)rc), IRT_CDATA); break; #endif /* -- Upvalue and function ops ------------------------------------------ */ case BC_UGET: rc = rec_upvalue(J, rc, 0); break; case BC_USETV: case BC_USETS: case BC_USETN: case BC_USETP: rec_upvalue(J, ra, rc); break; /* -- Table ops --------------------------------------------------------- */ case BC_GGET: case BC_GSET: settabV(J->L, &ix.tabv, tabref(J->fn->l.env)); ix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), getcurrf(J), IRFL_FUNC_ENV); ix.idxchain = LJ_MAX_IDXCHAIN; rc = lj_record_idx(J, &ix); break; case BC_TGETB: case BC_TSETB: setintV(&ix.keyv, (int32_t)rc); ix.key = lj_ir_kint(J, (int32_t)rc); /* fallthrough */ case BC_TGETV: case BC_TGETS: case BC_TSETV: case BC_TSETS: ix.idxchain = LJ_MAX_IDXCHAIN; rc = lj_record_idx(J, &ix); break; case BC_TNEW: rc = rec_tnew(J, rc); break; case BC_TDUP: rc = emitir(IRTG(IR_TDUP, IRT_TAB), lj_ir_ktab(J, gco2tab(proto_kgc(J->pt, ~(ptrdiff_t)rc))), 0); break; /* -- Calls and vararg handling ----------------------------------------- */ case BC_ITERC: J->base[ra] = getslot(J, ra-3); J->base[ra+1] = getslot(J, ra-2); J->base[ra+2] = getslot(J, ra-1); { /* Do the actual copy now because lj_record_call needs the values. */ TValue *b = &J->L->base[ra]; copyTV(J->L, b, b-3); copyTV(J->L, b+1, b-2); copyTV(J->L, b+2, b-1); } lj_record_call(J, ra, (ptrdiff_t)rc-1); break; /* L->top is set to L->base+ra+rc+NARGS-1+1. See lj_dispatch_ins(). */ case BC_CALLM: rc = (BCReg)(J->L->top - J->L->base) - ra; /* fallthrough */ case BC_CALL: lj_record_call(J, ra, (ptrdiff_t)rc-1); break; case BC_CALLMT: rc = (BCReg)(J->L->top - J->L->base) - ra; /* fallthrough */ case BC_CALLT: lj_record_tailcall(J, ra, (ptrdiff_t)rc-1); break; case BC_VARG: rec_varg(J, ra, (ptrdiff_t)rb-1); break; /* -- Returns ----------------------------------------------------------- */ case BC_RETM: /* L->top is set to L->base+ra+rc+NRESULTS-1, see lj_dispatch_ins(). */ rc = (BCReg)(J->L->top - J->L->base) - ra + 1; /* fallthrough */ case BC_RET: case BC_RET0: case BC_RET1: lj_record_ret(J, ra, (ptrdiff_t)rc-1); break; /* -- Loops and branches ------------------------------------------------ */ case BC_FORI: if (rec_for(J, pc, 0) != LOOPEV_LEAVE) J->loopref = J->cur.nins; break; case BC_JFORI: lua_assert(bc_op(pc[(ptrdiff_t)rc-BCBIAS_J]) == BC_JFORL); if (rec_for(J, pc, 0) != LOOPEV_LEAVE) /* Link to existing loop. */ rec_stop(J, LJ_TRLINK_ROOT, bc_d(pc[(ptrdiff_t)rc-BCBIAS_J])); /* Continue tracing if the loop is not entered. */ break; case BC_FORL: rec_loop_interp(J, pc, rec_for(J, pc+((ptrdiff_t)rc-BCBIAS_J), 1)); break; case BC_ITERL: rec_loop_interp(J, pc, rec_iterl(J, *pc)); break; case BC_LOOP: rec_loop_interp(J, pc, rec_loop(J, ra)); break; case BC_JFORL: rec_loop_jit(J, rc, rec_for(J, pc+bc_j(traceref(J, rc)->startins), 1)); break; case BC_JITERL: rec_loop_jit(J, rc, rec_iterl(J, traceref(J, rc)->startins)); break; case BC_JLOOP: rec_loop_jit(J, rc, rec_loop(J, ra)); break; case BC_IFORL: case BC_IITERL: case BC_ILOOP: case BC_IFUNCF: case BC_IFUNCV: lj_trace_err(J, LJ_TRERR_BLACKL); break; case BC_JMP: if (ra < J->maxslot) J->maxslot = ra; /* Shrink used slots. */ break; /* -- Function headers -------------------------------------------------- */ case BC_FUNCF: rec_func_lua(J); break; case BC_JFUNCF: rec_func_jit(J, rc); break; case BC_FUNCV: rec_func_vararg(J); rec_func_lua(J); break; case BC_JFUNCV: lua_assert(0); /* Cannot happen. No hotcall counting for varag funcs. */ break; case BC_FUNCC: case BC_FUNCCW: lj_ffrecord_func(J); break; default: if (op >= BC__MAX) { lj_ffrecord_func(J); break; } /* fallthrough */ case BC_ITERN: case BC_ISNEXT: case BC_CAT: case BC_UCLO: case BC_FNEW: case BC_TSETM: setintV(&J->errinfo, (int32_t)op); lj_trace_err_info(J, LJ_TRERR_NYIBC); break; } /* rc == 0 if we have no result yet, e.g. pending __index metamethod call. */ if (bcmode_a(op) == BCMdst && rc) { J->base[ra] = rc; if (ra >= J->maxslot) J->maxslot = ra+1; } #undef rav #undef rbv #undef rcv /* Limit the number of recorded IR instructions. */ if (J->cur.nins > REF_FIRST+(IRRef)J->param[JIT_P_maxrecord]) lj_trace_err(J, LJ_TRERR_TRACEOV); } /* -- Recording setup ----------------------------------------------------- */ /* Setup recording for a root trace started by a hot loop. */ static const BCIns *rec_setup_root(jit_State *J) { /* Determine the next PC and the bytecode range for the loop. */ const BCIns *pcj, *pc = J->pc; BCIns ins = *pc; BCReg ra = bc_a(ins); switch (bc_op(ins)) { case BC_FORL: J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); pc += 1+bc_j(ins); J->bc_min = pc; break; case BC_ITERL: lua_assert(bc_op(pc[-1]) == BC_ITERC); J->maxslot = ra + bc_b(pc[-1]) - 1; J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); pc += 1+bc_j(ins); lua_assert(bc_op(pc[-1]) == BC_JMP); J->bc_min = pc; break; case BC_LOOP: /* Only check BC range for real loops, but not for "repeat until true". */ pcj = pc + bc_j(ins); ins = *pcj; if (bc_op(ins) == BC_JMP && bc_j(ins) < 0) { J->bc_min = pcj+1 + bc_j(ins); J->bc_extent = (MSize)(-bc_j(ins))*sizeof(BCIns); } J->maxslot = ra; pc++; break; case BC_RET: case BC_RET0: case BC_RET1: /* No bytecode range check for down-recursive root traces. */ J->maxslot = ra + bc_d(ins); break; case BC_FUNCF: /* No bytecode range check for root traces started by a hot call. */ J->maxslot = J->pt->numparams; pc++; break; default: lua_assert(0); break; } return pc; } /* Setup for recording a new trace. */ void lj_record_setup(jit_State *J) { uint32_t i; /* Initialize state related to current trace. */ memset(J->slot, 0, sizeof(J->slot)); memset(J->chain, 0, sizeof(J->chain)); memset(J->bpropcache, 0, sizeof(J->bpropcache)); J->scev.idx = REF_NIL; J->baseslot = 1; /* Invoking function is at base[-1]. */ J->base = J->slot + J->baseslot; J->maxslot = 0; J->framedepth = 0; J->retdepth = 0; J->instunroll = J->param[JIT_P_instunroll]; J->loopunroll = J->param[JIT_P_loopunroll]; J->tailcalled = 0; J->loopref = 0; J->bc_min = NULL; /* Means no limit. */ J->bc_extent = ~(MSize)0; /* Emit instructions for fixed references. Also triggers initial IR alloc. */ emitir_raw(IRT(IR_BASE, IRT_P32), J->parent, J->exitno); for (i = 0; i <= 2; i++) { IRIns *ir = IR(REF_NIL-i); ir->i = 0; ir->t.irt = (uint8_t)(IRT_NIL+i); ir->o = IR_KPRI; ir->prev = 0; } J->cur.nk = REF_TRUE; J->startpc = J->pc; setmref(J->cur.startpc, J->pc); if (J->parent) { /* Side trace. */ GCtrace *T = traceref(J, J->parent); TraceNo root = T->root ? T->root : J->parent; J->cur.root = (uint16_t)root; J->cur.startins = BCINS_AD(BC_JMP, 0, 0); /* Check whether we could at least potentially form an extra loop. */ if (J->exitno == 0 && T->snap[0].nent == 0) { /* We can narrow a FORL for some side traces, too. */ if (J->pc > proto_bc(J->pt) && bc_op(J->pc[-1]) == BC_JFORI && bc_d(J->pc[bc_j(J->pc[-1])-1]) == root) { lj_snap_add(J); rec_for_loop(J, J->pc-1, &J->scev, 1); goto sidecheck; } } else { J->startpc = NULL; /* Prevent forming an extra loop. */ } lj_snap_replay(J, T); sidecheck: if (traceref(J, J->cur.root)->nchild >= J->param[JIT_P_maxside] || T->snap[J->exitno].count >= J->param[JIT_P_hotexit] + J->param[JIT_P_tryside]) { rec_stop(J, LJ_TRLINK_INTERP, 0); } } else { /* Root trace. */ J->cur.root = 0; J->cur.startins = *J->pc; J->pc = rec_setup_root(J); /* Note: the loop instruction itself is recorded at the end and not ** at the start! So snapshot #0 needs to point to the *next* instruction. */ lj_snap_add(J); if (bc_op(J->cur.startins) == BC_FORL) rec_for_loop(J, J->pc-1, &J->scev, 1); if (1 + J->pt->framesize >= LJ_MAX_JSLOTS) lj_trace_err(J, LJ_TRERR_STACKOV); } #ifdef LUAJIT_ENABLE_CHECKHOOK /* Regularly check for instruction/line hooks from compiled code and ** exit to the interpreter if the hooks are set. ** ** This is a compile-time option and disabled by default, since the ** hook checks may be quite expensive in tight loops. ** ** Note this is only useful if hooks are *not* set most of the time. ** Use this only if you want to *asynchronously* interrupt the execution. ** ** You can set the instruction hook via lua_sethook() with a count of 1 ** from a signal handler or another native thread. Please have a look ** at the first few functions in luajit.c for an example (Ctrl-C handler). */ { TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), lj_ir_kptr(J, &J2G(J)->hookmask), IRXLOAD_VOLATILE); tr = emitir(IRTI(IR_BAND), tr, lj_ir_kint(J, (LUA_MASKLINE|LUA_MASKCOUNT))); emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0)); } #endif } #undef IR #undef emitir_raw #undef emitir #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_record.h ================================================ /* ** Trace recorder (bytecode -> SSA IR). ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_RECORD_H #define _LJ_RECORD_H #include "lj_obj.h" #include "lj_jit.h" #if LJ_HASJIT /* Context for recording an indexed load/store. */ typedef struct RecordIndex { TValue tabv; /* Runtime value of table (or indexed object). */ TValue keyv; /* Runtime value of key. */ TValue valv; /* Runtime value of stored value. */ TValue mobjv; /* Runtime value of metamethod object. */ GCtab *mtv; /* Runtime value of metatable object. */ cTValue *oldv; /* Runtime value of previously stored value. */ TRef tab; /* Table (or indexed object) reference. */ TRef key; /* Key reference. */ TRef val; /* Value reference for a store or 0 for a load. */ TRef mt; /* Metatable reference. */ TRef mobj; /* Metamethod object reference. */ int idxchain; /* Index indirections left or 0 for raw lookup. */ } RecordIndex; LJ_FUNC int lj_record_objcmp(jit_State *J, TRef a, TRef b, cTValue *av, cTValue *bv); LJ_FUNC TRef lj_record_constify(jit_State *J, cTValue *o); LJ_FUNC void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs); LJ_FUNC void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs); LJ_FUNC void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults); LJ_FUNC int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm); LJ_FUNC TRef lj_record_idx(jit_State *J, RecordIndex *ix); LJ_FUNC void lj_record_ins(jit_State *J); LJ_FUNC void lj_record_setup(jit_State *J); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_snap.c ================================================ /* ** Snapshot handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_snap_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_gc.h" #include "lj_tab.h" #include "lj_state.h" #include "lj_frame.h" #include "lj_bc.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_iropt.h" #include "lj_trace.h" #include "lj_snap.h" #include "lj_target.h" #if LJ_HASFFI #include "lj_ctype.h" #include "lj_cdata.h" #endif /* Some local macros to save typing. Undef'd at the end. */ #define IR(ref) (&J->cur.ir[(ref)]) /* Pass IR on to next optimization in chain (FOLD). */ #define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J)) /* Emit raw IR without passing through optimizations. */ #define emitir_raw(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_ir_emit(J)) /* -- Snapshot buffer allocation ------------------------------------------ */ /* Grow snapshot buffer. */ void lj_snap_grow_buf_(jit_State *J, MSize need) { MSize maxsnap = (MSize)J->param[JIT_P_maxsnap]; if (need > maxsnap) lj_trace_err(J, LJ_TRERR_SNAPOV); lj_mem_growvec(J->L, J->snapbuf, J->sizesnap, maxsnap, SnapShot); J->cur.snap = J->snapbuf; } /* Grow snapshot map buffer. */ void lj_snap_grow_map_(jit_State *J, MSize need) { if (need < 2*J->sizesnapmap) need = 2*J->sizesnapmap; else if (need < 64) need = 64; J->snapmapbuf = (SnapEntry *)lj_mem_realloc(J->L, J->snapmapbuf, J->sizesnapmap*sizeof(SnapEntry), need*sizeof(SnapEntry)); J->cur.snapmap = J->snapmapbuf; J->sizesnapmap = need; } /* -- Snapshot generation ------------------------------------------------- */ /* Add all modified slots to the snapshot. */ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots) { IRRef retf = J->chain[IR_RETF]; /* Limits SLOAD restore elimination. */ BCReg s; MSize n = 0; for (s = 0; s < nslots; s++) { TRef tr = J->slot[s]; IRRef ref = tref_ref(tr); if (ref) { SnapEntry sn = SNAP_TR(s, tr); IRIns *ir = IR(ref); if (!(sn & (SNAP_CONT|SNAP_FRAME)) && ir->o == IR_SLOAD && ir->op1 == s && ref > retf) { /* No need to snapshot unmodified non-inherited slots. */ if (!(ir->op2 & IRSLOAD_INHERIT)) continue; /* No need to restore readonly slots and unmodified non-parent slots. */ if (!(LJ_DUALNUM && (ir->op2 & IRSLOAD_CONVERT)) && (ir->op2 & (IRSLOAD_READONLY|IRSLOAD_PARENT)) != IRSLOAD_PARENT) sn |= SNAP_NORESTORE; } if (LJ_SOFTFP && irt_isnum(ir->t)) sn |= SNAP_SOFTFPNUM; map[n++] = sn; } } return n; } /* Add frame links at the end of the snapshot. */ static BCReg snapshot_framelinks(jit_State *J, SnapEntry *map) { cTValue *frame = J->L->base - 1; cTValue *lim = J->L->base - J->baseslot; cTValue *ftop = frame + funcproto(frame_func(frame))->framesize; MSize f = 0; map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */ while (frame > lim) { /* Backwards traversal of all frames above base. */ if (frame_islua(frame)) { map[f++] = SNAP_MKPC(frame_pc(frame)); frame = frame_prevl(frame); if (frame + funcproto(frame_func(frame))->framesize > ftop) ftop = frame + funcproto(frame_func(frame))->framesize; } else if (frame_iscont(frame)) { map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); map[f++] = SNAP_MKPC(frame_contpc(frame)); frame = frame_prevd(frame); } else { lua_assert(!frame_isc(frame)); map[f++] = SNAP_MKFTSZ(frame_ftsz(frame)); frame = frame_prevd(frame); } } lua_assert(f == (MSize)(1 + J->framedepth)); return (BCReg)(ftop - lim); } /* Take a snapshot of the current stack. */ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap) { BCReg nslots = J->baseslot + J->maxslot; MSize nent; SnapEntry *p; /* Conservative estimate. */ lj_snap_grow_map(J, nsnapmap + nslots + (MSize)J->framedepth+1); p = &J->cur.snapmap[nsnapmap]; nent = snapshot_slots(J, p, nslots); snap->topslot = (uint8_t)snapshot_framelinks(J, p + nent); snap->mapofs = (uint16_t)nsnapmap; snap->ref = (IRRef1)J->cur.nins; snap->nent = (uint8_t)nent; snap->nslots = (uint8_t)nslots; snap->count = 0; J->cur.nsnapmap = (uint16_t)(nsnapmap + nent + 1 + J->framedepth); } /* Add or merge a snapshot. */ void lj_snap_add(jit_State *J) { MSize nsnap = J->cur.nsnap; MSize nsnapmap = J->cur.nsnapmap; /* Merge if no ins. inbetween or if requested and no guard inbetween. */ if (J->mergesnap ? !irt_isguard(J->guardemit) : (nsnap > 0 && J->cur.snap[nsnap-1].ref == J->cur.nins)) { if (nsnap == 1) { /* But preserve snap #0 PC. */ emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); goto nomerge; } nsnapmap = J->cur.snap[--nsnap].mapofs; } else { nomerge: lj_snap_grow_buf(J, nsnap+1); J->cur.nsnap = (uint16_t)(nsnap+1); } J->mergesnap = 0; J->guardemit.irt = 0; snapshot_stack(J, &J->cur.snap[nsnap], nsnapmap); } /* -- Snapshot modification ----------------------------------------------- */ #define SNAP_USEDEF_SLOTS (LJ_MAX_JSLOTS+LJ_STACK_EXTRA) /* Find unused slots with reaching-definitions bytecode data-flow analysis. */ static BCReg snap_usedef(jit_State *J, uint8_t *udf, const BCIns *pc, BCReg maxslot) { BCReg s; GCobj *o; if (maxslot == 0) return 0; #ifdef LUAJIT_USE_VALGRIND /* Avoid errors for harmless reads beyond maxslot. */ memset(udf, 1, SNAP_USEDEF_SLOTS); #else memset(udf, 1, maxslot); #endif /* Treat open upvalues as used. */ o = gcref(J->L->openupval); while (o) { if (uvval(gco2uv(o)) < J->L->base) break; udf[uvval(gco2uv(o)) - J->L->base] = 0; o = gcref(o->gch.nextgc); } #define USE_SLOT(s) udf[(s)] &= ~1 #define DEF_SLOT(s) udf[(s)] *= 3 /* Scan through following bytecode and check for uses/defs. */ lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); for (;;) { BCIns ins = *pc++; BCOp op = bc_op(ins); switch (bcmode_b(op)) { case BCMvar: USE_SLOT(bc_b(ins)); break; default: break; } switch (bcmode_c(op)) { case BCMvar: USE_SLOT(bc_c(ins)); break; case BCMrbase: lua_assert(op == BC_CAT); for (s = bc_b(ins); s <= bc_c(ins); s++) USE_SLOT(s); for (; s < maxslot; s++) DEF_SLOT(s); break; case BCMjump: handle_jump: { BCReg minslot = bc_a(ins); if (op >= BC_FORI && op <= BC_JFORL) minslot += FORL_EXT; else if (op >= BC_ITERL && op <= BC_JITERL) minslot += bc_b(pc[-2])-1; else if (op == BC_UCLO) { pc += bc_j(ins); break; } for (s = minslot; s < maxslot; s++) DEF_SLOT(s); return minslot < maxslot ? minslot : maxslot; } case BCMlit: if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) { goto handle_jump; } else if (bc_isret(op)) { BCReg top = op == BC_RETM ? maxslot : (bc_a(ins) + bc_d(ins)-1); for (s = 0; s < bc_a(ins); s++) DEF_SLOT(s); for (; s < top; s++) USE_SLOT(s); for (; s < maxslot; s++) DEF_SLOT(s); return 0; } break; case BCMfunc: return maxslot; /* NYI: will abort, anyway. */ default: break; } switch (bcmode_a(op)) { case BCMvar: USE_SLOT(bc_a(ins)); break; case BCMdst: if (!(op == BC_ISTC || op == BC_ISFC)) DEF_SLOT(bc_a(ins)); break; case BCMbase: if (op >= BC_CALLM && op <= BC_VARG) { BCReg top = (op == BC_CALLM || op == BC_CALLMT || bc_c(ins) == 0) ? maxslot : (bc_a(ins) + bc_c(ins)); s = bc_a(ins) - ((op == BC_ITERC || op == BC_ITERN) ? 3 : 0); for (; s < top; s++) USE_SLOT(s); for (; s < maxslot; s++) DEF_SLOT(s); if (op == BC_CALLT || op == BC_CALLMT) { for (s = 0; s < bc_a(ins); s++) DEF_SLOT(s); return 0; } } else if (op == BC_KNIL) { for (s = bc_a(ins); s <= bc_d(ins); s++) DEF_SLOT(s); } else if (op == BC_TSETM) { for (s = bc_a(ins)-1; s < maxslot; s++) USE_SLOT(s); } break; default: break; } lua_assert(pc >= proto_bc(J->pt) && pc < proto_bc(J->pt) + J->pt->sizebc); } #undef USE_SLOT #undef DEF_SLOT return 0; /* unreachable */ } /* Purge dead slots before the next snapshot. */ void lj_snap_purge(jit_State *J) { uint8_t udf[SNAP_USEDEF_SLOTS]; BCReg maxslot = J->maxslot; BCReg s = snap_usedef(J, udf, J->pc, maxslot); for (; s < maxslot; s++) if (udf[s] != 0) J->base[s] = 0; /* Purge dead slots. */ } /* Shrink last snapshot. */ void lj_snap_shrink(jit_State *J) { SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; SnapEntry *map = &J->cur.snapmap[snap->mapofs]; MSize n, m, nlim, nent = snap->nent; uint8_t udf[SNAP_USEDEF_SLOTS]; BCReg maxslot = J->maxslot; BCReg minslot = snap_usedef(J, udf, snap_pc(map[nent]), maxslot); BCReg baseslot = J->baseslot; maxslot += baseslot; minslot += baseslot; snap->nslots = (uint8_t)maxslot; for (n = m = 0; n < nent; n++) { /* Remove unused slots from snapshot. */ BCReg s = snap_slot(map[n]); if (s < minslot || (s < maxslot && udf[s-baseslot] == 0)) map[m++] = map[n]; /* Only copy used slots. */ } snap->nent = (uint8_t)m; nlim = J->cur.nsnapmap - snap->mapofs - 1; while (n <= nlim) map[m++] = map[n++]; /* Move PC + frame links down. */ J->cur.nsnapmap = (uint16_t)(snap->mapofs + m); /* Free up space in map. */ } /* -- Snapshot access ----------------------------------------------------- */ /* Initialize a Bloom Filter with all renamed refs. ** There are very few renames (often none), so the filter has ** very few bits set. This makes it suitable for negative filtering. */ static BloomFilter snap_renamefilter(GCtrace *T, SnapNo lim) { BloomFilter rfilt = 0; IRIns *ir; for (ir = &T->ir[T->nins-1]; ir->o == IR_RENAME; ir--) if (ir->op2 <= lim) bloomset(rfilt, ir->op1); return rfilt; } /* Process matching renames to find the original RegSP. */ static RegSP snap_renameref(GCtrace *T, SnapNo lim, IRRef ref, RegSP rs) { IRIns *ir; for (ir = &T->ir[T->nins-1]; ir->o == IR_RENAME; ir--) if (ir->op1 == ref && ir->op2 <= lim) rs = ir->prev; return rs; } /* Copy RegSP from parent snapshot to the parent links of the IR. */ IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir) { SnapShot *snap = &T->snap[snapno]; SnapEntry *map = &T->snapmap[snap->mapofs]; BloomFilter rfilt = snap_renamefilter(T, snapno); MSize n = 0; IRRef ref = 0; for ( ; ; ir++) { uint32_t rs; if (ir->o == IR_SLOAD) { if (!(ir->op2 & IRSLOAD_PARENT)) break; for ( ; ; n++) { lua_assert(n < snap->nent); if (snap_slot(map[n]) == ir->op1) { ref = snap_ref(map[n++]); break; } } } else if (LJ_SOFTFP && ir->o == IR_HIOP) { ref++; } else if (ir->o == IR_PVAL) { ref = ir->op1 + REF_BIAS; } else { break; } rs = T->ir[ref].prev; if (bloomtest(rfilt, ref)) rs = snap_renameref(T, snapno, ref, rs); ir->prev = (uint16_t)rs; lua_assert(regsp_used(rs)); } return ir; } /* -- Snapshot replay ----------------------------------------------------- */ /* Replay constant from parent trace. */ static TRef snap_replay_const(jit_State *J, IRIns *ir) { /* Only have to deal with constants that can occur in stack slots. */ switch ((IROp)ir->o) { case IR_KPRI: return TREF_PRI(irt_type(ir->t)); case IR_KINT: return lj_ir_kint(J, ir->i); case IR_KGC: return lj_ir_kgc(J, ir_kgc(ir), irt_t(ir->t)); case IR_KNUM: return lj_ir_k64(J, IR_KNUM, ir_knum(ir)); case IR_KINT64: return lj_ir_k64(J, IR_KINT64, ir_kint64(ir)); case IR_KPTR: return lj_ir_kptr(J, ir_kptr(ir)); /* Continuation. */ default: lua_assert(0); return TREF_NIL; break; } } /* De-duplicate parent reference. */ static TRef snap_dedup(jit_State *J, SnapEntry *map, MSize nmax, IRRef ref) { MSize j; for (j = 0; j < nmax; j++) if (snap_ref(map[j]) == ref) return J->slot[snap_slot(map[j])] & ~(SNAP_CONT|SNAP_FRAME); return 0; } /* Emit parent reference with de-duplication. */ static TRef snap_pref(jit_State *J, GCtrace *T, SnapEntry *map, MSize nmax, BloomFilter seen, IRRef ref) { IRIns *ir = &T->ir[ref]; TRef tr; if (irref_isk(ref)) tr = snap_replay_const(J, ir); else if (!regsp_used(ir->prev)) tr = 0; else if (!bloomtest(seen, ref) || (tr = snap_dedup(J, map, nmax, ref)) == 0) tr = emitir(IRT(IR_PVAL, irt_type(ir->t)), ref - REF_BIAS, 0); return tr; } /* Check whether a sunk store corresponds to an allocation. Slow path. */ static int snap_sunk_store2(jit_State *J, IRIns *ira, IRIns *irs) { if (irs->o == IR_ASTORE || irs->o == IR_HSTORE || irs->o == IR_FSTORE || irs->o == IR_XSTORE) { IRIns *irk = IR(irs->op1); if (irk->o == IR_AREF || irk->o == IR_HREFK) irk = IR(irk->op1); return (IR(irk->op1) == ira); } return 0; } /* Check whether a sunk store corresponds to an allocation. Fast path. */ static LJ_AINLINE int snap_sunk_store(jit_State *J, IRIns *ira, IRIns *irs) { if (irs->s != 255) return (ira + irs->s == irs); /* Fast check. */ return snap_sunk_store2(J, ira, irs); } /* Replay snapshot state to setup side trace. */ void lj_snap_replay(jit_State *J, GCtrace *T) { SnapShot *snap = &T->snap[J->exitno]; SnapEntry *map = &T->snapmap[snap->mapofs]; MSize n, nent = snap->nent; BloomFilter seen = 0; int pass23 = 0; J->framedepth = 0; /* Emit IR for slots inherited from parent snapshot. */ for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; BCReg s = snap_slot(sn); IRRef ref = snap_ref(sn); IRIns *ir = &T->ir[ref]; TRef tr; /* The bloom filter avoids O(nent^2) overhead for de-duping slots. */ if (bloomtest(seen, ref) && (tr = snap_dedup(J, map, n, ref)) != 0) goto setslot; bloomset(seen, ref); if (irref_isk(ref)) { tr = snap_replay_const(J, ir); } else if (!regsp_used(ir->prev)) { pass23 = 1; lua_assert(s != 0); tr = s; } else { IRType t = irt_type(ir->t); uint32_t mode = IRSLOAD_INHERIT|IRSLOAD_PARENT; if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM)) t = IRT_NUM; if (ir->o == IR_SLOAD) mode |= (ir->op2 & IRSLOAD_READONLY); tr = emitir_raw(IRT(IR_SLOAD, t), s, mode); } setslot: J->slot[s] = tr | (sn&(SNAP_CONT|SNAP_FRAME)); /* Same as TREF_* flags. */ J->framedepth += ((sn & (SNAP_CONT|SNAP_FRAME)) && s); if ((sn & SNAP_FRAME)) J->baseslot = s+1; } if (pass23) { IRIns *irlast = &T->ir[snap->ref]; pass23 = 0; /* Emit dependent PVALs. */ for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; IRRef refp = snap_ref(sn); IRIns *ir = &T->ir[refp]; if (regsp_reg(ir->r) == RID_SUNK) { if (J->slot[snap_slot(sn)] != snap_slot(sn)) continue; pass23 = 1; lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW || ir->o == IR_CNEWI); if (ir->op1 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op1); if (ir->op2 >= T->nk) snap_pref(J, T, map, nent, seen, ir->op2); if (LJ_HASFFI && ir->o == IR_CNEWI) { if (LJ_32 && refp+1 < T->nins && (ir+1)->o == IR_HIOP) snap_pref(J, T, map, nent, seen, (ir+1)->op2); } else { IRIns *irs; for (irs = ir+1; irs < irlast; irs++) if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { if (snap_pref(J, T, map, nent, seen, irs->op2) == 0) snap_pref(J, T, map, nent, seen, T->ir[irs->op2].op1); else if ((LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) && irs+1 < irlast && (irs+1)->o == IR_HIOP) snap_pref(J, T, map, nent, seen, (irs+1)->op2); } } } else if (!irref_isk(refp) && !regsp_used(ir->prev)) { lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); J->slot[snap_slot(sn)] = snap_pref(J, T, map, nent, seen, ir->op1); } } /* Replay sunk instructions. */ for (n = 0; pass23 && n < nent; n++) { SnapEntry sn = map[n]; IRRef refp = snap_ref(sn); IRIns *ir = &T->ir[refp]; if (regsp_reg(ir->r) == RID_SUNK) { TRef op1, op2; if (J->slot[snap_slot(sn)] != snap_slot(sn)) { /* De-dup allocs. */ J->slot[snap_slot(sn)] = J->slot[J->slot[snap_slot(sn)]]; continue; } op1 = ir->op1; if (op1 >= T->nk) op1 = snap_pref(J, T, map, nent, seen, op1); op2 = ir->op2; if (op2 >= T->nk) op2 = snap_pref(J, T, map, nent, seen, op2); if (LJ_HASFFI && ir->o == IR_CNEWI) { if (LJ_32 && refp+1 < T->nins && (ir+1)->o == IR_HIOP) { lj_needsplit(J); /* Emit joining HIOP. */ op2 = emitir_raw(IRT(IR_HIOP, IRT_I64), op2, snap_pref(J, T, map, nent, seen, (ir+1)->op2)); } J->slot[snap_slot(sn)] = emitir(ir->ot, op1, op2); } else { IRIns *irs; TRef tr = emitir(ir->ot, op1, op2); J->slot[snap_slot(sn)] = tr; for (irs = ir+1; irs < irlast; irs++) if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { IRIns *irr = &T->ir[irs->op1]; TRef val, key = irr->op2, tmp = tr; if (irr->o != IR_FREF) { IRIns *irk = &T->ir[key]; if (irr->o == IR_HREFK) key = lj_ir_kslot(J, snap_replay_const(J, &T->ir[irk->op1]), irk->op2); else key = snap_replay_const(J, irk); if (irr->o == IR_HREFK || irr->o == IR_AREF) { IRIns *irf = &T->ir[irr->op1]; tmp = emitir(irf->ot, tmp, irf->op2); } } tmp = emitir(irr->ot, tmp, key); val = snap_pref(J, T, map, nent, seen, irs->op2); if (val == 0) { IRIns *irc = &T->ir[irs->op2]; lua_assert(irc->o == IR_CONV && irc->op2 == IRCONV_NUM_INT); val = snap_pref(J, T, map, nent, seen, irc->op1); val = emitir(IRTN(IR_CONV), val, IRCONV_NUM_INT); } else if ((LJ_SOFTFP || (LJ_32 && LJ_HASFFI)) && irs+1 < irlast && (irs+1)->o == IR_HIOP) { IRType t = IRT_I64; if (LJ_SOFTFP && irt_type((irs+1)->t) == IRT_SOFTFP) t = IRT_NUM; lj_needsplit(J); if (irref_isk(irs->op2) && irref_isk((irs+1)->op2)) { uint64_t k = (uint32_t)T->ir[irs->op2].i + ((uint64_t)T->ir[(irs+1)->op2].i << 32); val = lj_ir_k64(J, t == IRT_I64 ? IR_KINT64 : IR_KNUM, lj_ir_k64_find(J, k)); } else { val = emitir_raw(IRT(IR_HIOP, t), val, snap_pref(J, T, map, nent, seen, (irs+1)->op2)); } tmp = emitir(IRT(irs->o, t), tmp, val); continue; } tmp = emitir(irs->ot, tmp, val); } } } } } J->base = J->slot + J->baseslot; J->maxslot = snap->nslots - J->baseslot; lj_snap_add(J); if (pass23) /* Need explicit GC step _after_ initial snapshot. */ emitir_raw(IRTG(IR_GCSTEP, IRT_NIL), 0, 0); } /* -- Snapshot restore ---------------------------------------------------- */ static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, SnapNo snapno, BloomFilter rfilt, IRIns *ir, TValue *o); /* Restore a value from the trace exit state. */ static void snap_restoreval(jit_State *J, GCtrace *T, ExitState *ex, SnapNo snapno, BloomFilter rfilt, IRRef ref, TValue *o) { IRIns *ir = &T->ir[ref]; IRType1 t = ir->t; RegSP rs = ir->prev; if (irref_isk(ref)) { /* Restore constant slot. */ lj_ir_kvalue(J->L, o, ir); return; } if (LJ_UNLIKELY(bloomtest(rfilt, ref))) rs = snap_renameref(T, snapno, ref, rs); if (ra_hasspill(regsp_spill(rs))) { /* Restore from spill slot. */ int32_t *sps = &ex->spill[regsp_spill(rs)]; if (irt_isinteger(t)) { setintV(o, *sps); #if !LJ_SOFTFP } else if (irt_isnum(t)) { o->u64 = *(uint64_t *)sps; #endif } else if (LJ_64 && irt_islightud(t)) { /* 64 bit lightuserdata which may escape already has the tag bits. */ o->u64 = *(uint64_t *)sps; } else { lua_assert(!irt_ispri(t)); /* PRI refs never have a spill slot. */ setgcrefi(o->gcr, *sps); setitype(o, irt_toitype(t)); } } else { /* Restore from register. */ Reg r = regsp_reg(rs); if (ra_noreg(r)) { lua_assert(ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); snap_restoreval(J, T, ex, snapno, rfilt, ir->op1, o); if (LJ_DUALNUM) setnumV(o, (lua_Number)intV(o)); return; } else if (irt_isinteger(t)) { setintV(o, (int32_t)ex->gpr[r-RID_MIN_GPR]); #if !LJ_SOFTFP } else if (irt_isnum(t)) { setnumV(o, ex->fpr[r-RID_MIN_FPR]); #endif } else if (LJ_64 && irt_islightud(t)) { /* 64 bit lightuserdata which may escape already has the tag bits. */ o->u64 = ex->gpr[r-RID_MIN_GPR]; } else { if (!irt_ispri(t)) setgcrefi(o->gcr, ex->gpr[r-RID_MIN_GPR]); setitype(o, irt_toitype(t)); } } } #if LJ_HASFFI /* Restore raw data from the trace exit state. */ static void snap_restoredata(GCtrace *T, ExitState *ex, SnapNo snapno, BloomFilter rfilt, IRRef ref, void *dst, CTSize sz) { IRIns *ir = &T->ir[ref]; RegSP rs = ir->prev; int32_t *src; uint64_t tmp; if (irref_isk(ref)) { if (ir->o == IR_KNUM || ir->o == IR_KINT64) { src = mref(ir->ptr, int32_t); } else if (sz == 8) { tmp = (uint64_t)(uint32_t)ir->i; src = (int32_t *)&tmp; } else { src = &ir->i; } } else { if (LJ_UNLIKELY(bloomtest(rfilt, ref))) rs = snap_renameref(T, snapno, ref, rs); if (ra_hasspill(regsp_spill(rs))) { src = &ex->spill[regsp_spill(rs)]; if (sz == 8 && !irt_is64(ir->t)) { tmp = (uint64_t)(uint32_t)*src; src = (int32_t *)&tmp; } } else { Reg r = regsp_reg(rs); if (ra_noreg(r)) { /* Note: this assumes CNEWI is never used for SOFTFP split numbers. */ lua_assert(sz == 8 && ir->o == IR_CONV && ir->op2 == IRCONV_NUM_INT); snap_restoredata(T, ex, snapno, rfilt, ir->op1, dst, 4); *(lua_Number *)dst = (lua_Number)*(int32_t *)dst; return; } src = (int32_t *)&ex->gpr[r-RID_MIN_GPR]; #if !LJ_SOFTFP if (r >= RID_MAX_GPR) { src = (int32_t *)&ex->fpr[r-RID_MIN_FPR]; #if LJ_TARGET_PPC if (sz == 4) { /* PPC FPRs are always doubles. */ *(float *)dst = (float)*(double *)src; return; } #else if (LJ_BE && sz == 4) src++; #endif } #endif } } lua_assert(sz == 1 || sz == 2 || sz == 4 || sz == 8); if (sz == 4) *(int32_t *)dst = *src; else if (sz == 8) *(int64_t *)dst = *(int64_t *)src; else if (sz == 1) *(int8_t *)dst = (int8_t)*src; else *(int16_t *)dst = (int16_t)*src; } #endif /* Unsink allocation from the trace exit state. Unsink sunk stores. */ static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex, SnapNo snapno, BloomFilter rfilt, IRIns *ir, TValue *o) { lua_assert(ir->o == IR_TNEW || ir->o == IR_TDUP || ir->o == IR_CNEW || ir->o == IR_CNEWI); #if LJ_HASFFI if (ir->o == IR_CNEW || ir->o == IR_CNEWI) { CTState *cts = ctype_ctsG(J2G(J)); CTypeID id = (CTypeID)T->ir[ir->op1].i; CTSize sz = lj_ctype_size(cts, id); GCcdata *cd = lj_cdata_new(cts, id, sz); setcdataV(J->L, o, cd); if (ir->o == IR_CNEWI) { uint8_t *p = (uint8_t *)cdataptr(cd); lua_assert(sz == 4 || sz == 8); if (LJ_32 && sz == 8 && ir+1 < T->ir + T->nins && (ir+1)->o == IR_HIOP) { snap_restoredata(T, ex, snapno, rfilt, (ir+1)->op2, LJ_LE?p+4:p, 4); if (LJ_BE) p += 4; sz = 4; } snap_restoredata(T, ex, snapno, rfilt, ir->op2, p, sz); } else { IRIns *irs, *irlast = &T->ir[T->snap[snapno].ref]; for (irs = ir+1; irs < irlast; irs++) if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { IRIns *iro = &T->ir[T->ir[irs->op1].op2]; uint8_t *p = (uint8_t *)cd; CTSize szs; lua_assert(irs->o == IR_XSTORE && T->ir[irs->op1].o == IR_ADD); lua_assert(iro->o == IR_KINT || iro->o == IR_KINT64); if (irt_is64(irs->t)) szs = 8; else if (irt_isi8(irs->t) || irt_isu8(irs->t)) szs = 1; else if (irt_isi16(irs->t) || irt_isu16(irs->t)) szs = 2; else szs = 4; if (LJ_64 && iro->o == IR_KINT64) p += (int64_t)ir_k64(iro)->u64; else p += iro->i; lua_assert(p >= (uint8_t *)cdataptr(cd) && p + szs <= (uint8_t *)cdataptr(cd) + sz); if (LJ_32 && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { lua_assert(szs == 4); snap_restoredata(T, ex, snapno, rfilt, (irs+1)->op2, LJ_LE?p+4:p,4); if (LJ_BE) p += 4; } snap_restoredata(T, ex, snapno, rfilt, irs->op2, p, szs); } } } else #endif { IRIns *irs, *irlast; GCtab *t = ir->o == IR_TNEW ? lj_tab_new(J->L, ir->op1, ir->op2) : lj_tab_dup(J->L, ir_ktab(&T->ir[ir->op1])); settabV(J->L, o, t); irlast = &T->ir[T->snap[snapno].ref]; for (irs = ir+1; irs < irlast; irs++) if (irs->r == RID_SINK && snap_sunk_store(J, ir, irs)) { IRIns *irk = &T->ir[irs->op1]; TValue tmp, *val; lua_assert(irs->o == IR_ASTORE || irs->o == IR_HSTORE || irs->o == IR_FSTORE); if (irk->o == IR_FREF) { lua_assert(irk->op2 == IRFL_TAB_META); snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, &tmp); /* NOBARRIER: The table is new (marked white). */ setgcref(t->metatable, obj2gco(tabV(&tmp))); } else { irk = &T->ir[irk->op2]; if (irk->o == IR_KSLOT) irk = &T->ir[irk->op1]; lj_ir_kvalue(J->L, &tmp, irk); val = lj_tab_set(J->L, t, &tmp); /* NOBARRIER: The table is new (marked white). */ snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, val); if (LJ_SOFTFP && irs+1 < T->ir + T->nins && (irs+1)->o == IR_HIOP) { snap_restoreval(J, T, ex, snapno, rfilt, (irs+1)->op2, &tmp); val->u32.hi = tmp.u32.lo; } } } } } /* Restore interpreter state from exit state with the help of a snapshot. */ const BCIns *lj_snap_restore(jit_State *J, void *exptr) { ExitState *ex = (ExitState *)exptr; SnapNo snapno = J->exitno; /* For now, snapno == exitno. */ GCtrace *T = traceref(J, J->parent); SnapShot *snap = &T->snap[snapno]; MSize n, nent = snap->nent; SnapEntry *map = &T->snapmap[snap->mapofs]; SnapEntry *flinks = &T->snapmap[snap_nextofs(T, snap)-1]; int32_t ftsz0; TValue *frame; BloomFilter rfilt = snap_renamefilter(T, snapno); const BCIns *pc = snap_pc(map[nent]); lua_State *L = J->L; /* Set interpreter PC to the next PC to get correct error messages. */ setcframe_pc(cframe_raw(L->cframe), pc+1); /* Make sure the stack is big enough for the slots from the snapshot. */ if (LJ_UNLIKELY(L->base + snap->topslot >= tvref(L->maxstack))) { L->top = curr_topL(L); lj_state_growstack(L, snap->topslot - curr_proto(L)->framesize); } /* Fill stack slots with data from the registers and spill slots. */ frame = L->base-1; ftsz0 = frame_ftsz(frame); /* Preserve link to previous frame in slot #0. */ for (n = 0; n < nent; n++) { SnapEntry sn = map[n]; if (!(sn & SNAP_NORESTORE)) { TValue *o = &frame[snap_slot(sn)]; IRRef ref = snap_ref(sn); IRIns *ir = &T->ir[ref]; if (ir->r == RID_SUNK) { MSize j; for (j = 0; j < n; j++) if (snap_ref(map[j]) == ref) { /* De-duplicate sunk allocations. */ copyTV(L, o, &frame[snap_slot(map[j])]); goto dupslot; } snap_unsink(J, T, ex, snapno, rfilt, ir, o); dupslot: continue; } snap_restoreval(J, T, ex, snapno, rfilt, ref, o); if (LJ_SOFTFP && (sn & SNAP_SOFTFPNUM) && tvisint(o)) { TValue tmp; snap_restoreval(J, T, ex, snapno, rfilt, ref+1, &tmp); o->u32.hi = tmp.u32.lo; } else if ((sn & (SNAP_CONT|SNAP_FRAME))) { /* Overwrite tag with frame link. */ o->fr.tp.ftsz = snap_slot(sn) != 0 ? (int32_t)*flinks-- : ftsz0; L->base = o+1; } } } lua_assert(map + nent == flinks); /* Compute current stack top. */ switch (bc_op(*pc)) { case BC_CALLM: case BC_CALLMT: case BC_RETM: case BC_TSETM: L->top = frame + snap->nslots; break; default: L->top = curr_topL(L); break; } return pc; } #undef IR #undef emitir_raw #undef emitir #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_snap.h ================================================ /* ** Snapshot handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_SNAP_H #define _LJ_SNAP_H #include "lj_obj.h" #include "lj_jit.h" #if LJ_HASJIT LJ_FUNC void lj_snap_add(jit_State *J); LJ_FUNC void lj_snap_purge(jit_State *J); LJ_FUNC void lj_snap_shrink(jit_State *J); LJ_FUNC IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir); LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) { if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); } static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) { if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); } #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_state.c ================================================ /* ** State and stack handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lj_state_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_func.h" #include "lj_meta.h" #include "lj_state.h" #include "lj_frame.h" #if LJ_HASFFI #include "lj_ctype.h" #endif #include "lj_trace.h" #include "lj_dispatch.h" #include "lj_vm.h" #include "lj_lex.h" #include "lj_alloc.h" /* -- Stack handling ------------------------------------------------------ */ /* Stack sizes. */ #define LJ_STACK_MIN LUA_MINSTACK /* Min. stack size. */ #define LJ_STACK_MAX LUAI_MAXSTACK /* Max. stack size. */ #define LJ_STACK_START (2*LJ_STACK_MIN) /* Starting stack size. */ #define LJ_STACK_MAXEX (LJ_STACK_MAX + 1 + LJ_STACK_EXTRA) /* Explanation of LJ_STACK_EXTRA: ** ** Calls to metamethods store their arguments beyond the current top ** without checking for the stack limit. This avoids stack resizes which ** would invalidate passed TValue pointers. The stack check is performed ** later by the function header. This can safely resize the stack or raise ** an error. Thus we need some extra slots beyond the current stack limit. ** ** Most metamethods need 4 slots above top (cont, mobj, arg1, arg2) plus ** one extra slot if mobj is not a function. Only lj_meta_tset needs 5 ** slots above top, but then mobj is always a function. So we can get by ** with 5 extra slots. */ /* Resize stack slots and adjust pointers in state. */ static void resizestack(lua_State *L, MSize n) { TValue *st, *oldst = tvref(L->stack); ptrdiff_t delta; MSize oldsize = L->stacksize; MSize realsize = n + 1 + LJ_STACK_EXTRA; GCobj *up; lua_assert((MSize)(tvref(L->maxstack)-oldst)==L->stacksize-LJ_STACK_EXTRA-1); st = (TValue *)lj_mem_realloc(L, tvref(L->stack), (MSize)(L->stacksize*sizeof(TValue)), (MSize)(realsize*sizeof(TValue))); setmref(L->stack, st); delta = (char *)st - (char *)oldst; setmref(L->maxstack, st + n); while (oldsize < realsize) /* Clear new slots. */ setnilV(st + oldsize++); L->stacksize = realsize; L->base = (TValue *)((char *)L->base + delta); L->top = (TValue *)((char *)L->top + delta); for (up = gcref(L->openupval); up != NULL; up = gcnext(up)) setmref(gco2uv(up)->v, (TValue *)((char *)uvval(gco2uv(up)) + delta)); if (obj2gco(L) == gcref(G(L)->jit_L)) setmref(G(L)->jit_base, mref(G(L)->jit_base, char) + delta); } /* Relimit stack after error, in case the limit was overdrawn. */ void lj_state_relimitstack(lua_State *L) { if (L->stacksize > LJ_STACK_MAXEX && L->top-tvref(L->stack) < LJ_STACK_MAX-1) resizestack(L, LJ_STACK_MAX); } /* Try to shrink the stack (called from GC). */ void lj_state_shrinkstack(lua_State *L, MSize used) { if (L->stacksize > LJ_STACK_MAXEX) return; /* Avoid stack shrinking while handling stack overflow. */ if (4*used < L->stacksize && 2*(LJ_STACK_START+LJ_STACK_EXTRA) < L->stacksize && obj2gco(L) != gcref(G(L)->jit_L)) /* Don't shrink stack of live trace. */ resizestack(L, L->stacksize >> 1); } /* Try to grow stack. */ void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need) { MSize n; if (L->stacksize > LJ_STACK_MAXEX) /* Overflow while handling overflow? */ lj_err_throw(L, LUA_ERRERR); n = L->stacksize + need; if (n > LJ_STACK_MAX) { n += 2*LUA_MINSTACK; } else if (n < 2*L->stacksize) { n = 2*L->stacksize; if (n >= LJ_STACK_MAX) n = LJ_STACK_MAX; } resizestack(L, n); if (L->stacksize > LJ_STACK_MAXEX) lj_err_msg(L, LJ_ERR_STKOV); } void LJ_FASTCALL lj_state_growstack1(lua_State *L) { lj_state_growstack(L, 1); } /* Allocate basic stack for new state. */ static void stack_init(lua_State *L1, lua_State *L) { TValue *stend, *st = lj_mem_newvec(L, LJ_STACK_START+LJ_STACK_EXTRA, TValue); setmref(L1->stack, st); L1->stacksize = LJ_STACK_START + LJ_STACK_EXTRA; stend = st + L1->stacksize; setmref(L1->maxstack, stend - LJ_STACK_EXTRA - 1); L1->base = L1->top = st+1; setthreadV(L1, st, L1); /* Needed for curr_funcisL() on empty stack. */ while (st < stend) /* Clear new slots. */ setnilV(st++); } /* -- State handling ------------------------------------------------------ */ /* Open parts that may cause memory-allocation errors. */ static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) { global_State *g = G(L); UNUSED(dummy); UNUSED(ud); stack_init(L, L); /* NOBARRIER: State initialization, all objects are white. */ setgcref(L->env, obj2gco(lj_tab_new(L, 0, LJ_MIN_GLOBAL))); settabV(L, registry(L), lj_tab_new(L, 0, LJ_MIN_REGISTRY)); lj_str_resize(L, LJ_MIN_STRTAB-1); lj_meta_init(L); lj_lex_init(L); fixstring(lj_err_str(L, LJ_ERR_ERRMEM)); /* Preallocate memory error msg. */ g->gc.threshold = 4*g->gc.total; lj_trace_initstate(g); return NULL; } static void close_state(lua_State *L) { global_State *g = G(L); lj_func_closeuv(L, tvref(L->stack)); lj_gc_freeall(g); lua_assert(gcref(g->gc.root) == obj2gco(L)); lua_assert(g->strnum == 0); lj_trace_freestate(g); #if LJ_HASFFI lj_ctype_freestate(g); #endif lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); lj_str_freebuf(g, &g->tmpbuf); lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); lua_assert(g->gc.total == sizeof(GG_State)); #ifndef LUAJIT_USE_SYSMALLOC if (g->allocf == lj_alloc_f) lj_alloc_destroy(g->allocd); else #endif g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); } #if LJ_64 lua_State *lj_state_newstate(lua_Alloc f, void *ud) #else LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) #endif { GG_State *GG = (GG_State *)f(ud, NULL, 0, sizeof(GG_State)); lua_State *L = &GG->L; global_State *g = &GG->g; if (GG == NULL || !checkptr32(GG)) return NULL; memset(GG, 0, sizeof(GG_State)); L->gct = ~LJ_TTHREAD; L->marked = LJ_GC_WHITE0 | LJ_GC_FIXED | LJ_GC_SFIXED; /* Prevent free. */ L->dummy_ffid = FF_C; setmref(L->glref, g); g->gc.currentwhite = LJ_GC_WHITE0 | LJ_GC_FIXED; g->strempty.marked = LJ_GC_WHITE0; g->strempty.gct = ~LJ_TSTR; g->allocf = f; g->allocd = ud; setgcref(g->mainthref, obj2gco(L)); setgcref(g->uvhead.prev, obj2gco(&g->uvhead)); setgcref(g->uvhead.next, obj2gco(&g->uvhead)); g->strmask = ~(MSize)0; setnilV(registry(L)); setnilV(&g->nilnode.val); setnilV(&g->nilnode.key); setmref(g->nilnode.freetop, &g->nilnode); lj_str_initbuf(&g->tmpbuf); g->gc.state = GCSpause; setgcref(g->gc.root, obj2gco(L)); setmref(g->gc.sweep, &g->gc.root); g->gc.total = sizeof(GG_State); g->gc.pause = LUAI_GCPAUSE; g->gc.stepmul = LUAI_GCMUL; lj_dispatch_init((GG_State *)L); L->status = LUA_ERRERR+1; /* Avoid touching the stack upon memory error. */ if (lj_vm_cpcall(L, NULL, NULL, cpluaopen) != 0) { /* Memory allocation error: free partial state. */ close_state(L); return NULL; } L->status = 0; return L; } static TValue *cpfinalize(lua_State *L, lua_CFunction dummy, void *ud) { UNUSED(dummy); UNUSED(ud); lj_gc_finalize_cdata(L); lj_gc_finalize_udata(L); /* Frame pop omitted. */ return NULL; } LUA_API void lua_close(lua_State *L) { global_State *g = G(L); int i; L = mainthread(g); /* Only the main thread can be closed. */ lj_func_closeuv(L, tvref(L->stack)); lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */ #if LJ_HASJIT G2J(g)->flags &= ~JIT_F_ON; G2J(g)->state = LJ_TRACE_IDLE; lj_dispatch_update(g); #endif for (i = 0;;) { hook_enter(g); L->status = 0; L->cframe = NULL; L->base = L->top = tvref(L->stack) + 1; if (lj_vm_cpcall(L, NULL, NULL, cpfinalize) == 0) { if (++i >= 10) break; lj_gc_separateudata(g, 1); /* Separate udata again. */ if (gcref(g->gc.mmudata) == NULL) /* Until nothing is left to do. */ break; } } close_state(L); } lua_State *lj_state_new(lua_State *L) { lua_State *L1 = lj_mem_newobj(L, lua_State); L1->gct = ~LJ_TTHREAD; L1->dummy_ffid = FF_C; L1->status = 0; L1->stacksize = 0; setmref(L1->stack, NULL); L1->cframe = NULL; /* NOBARRIER: The lua_State is new (marked white). */ setgcrefnull(L1->openupval); setmrefr(L1->glref, L->glref); setgcrefr(L1->env, L->env); stack_init(L1, L); /* init stack */ lua_assert(iswhite(obj2gco(L1))); return L1; } void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) { lua_assert(L != mainthread(g)); lj_func_closeuv(L, tvref(L->stack)); lua_assert(gcref(L->openupval) == NULL); lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); lj_mem_freet(g, L); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_state.h ================================================ /* ** State and stack handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_STATE_H #define _LJ_STATE_H #include "lj_obj.h" #define incr_top(L) \ (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) #define savestack(L, p) ((char *)(p) - mref(L->stack, char)) #define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) LJ_FUNC void lj_state_relimitstack(lua_State *L); LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) { if ((mref(L->maxstack, char) - (char *)L->top) <= (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) lj_state_growstack(L, need); } LJ_FUNC lua_State *lj_state_new(lua_State *L); LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); #if LJ_64 LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_str.c ================================================ /* ** String handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #include #define lj_str_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_state.h" #include "lj_char.h" /* -- String interning ---------------------------------------------------- */ /* Ordered compare of strings. Assumes string data is 4-byte aligned. */ int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b) { MSize i, n = a->len > b->len ? b->len : a->len; for (i = 0; i < n; i += 4) { /* Note: innocuous access up to end of string + 3. */ uint32_t va = *(const uint32_t *)(strdata(a)+i); uint32_t vb = *(const uint32_t *)(strdata(b)+i); if (va != vb) { #if LJ_LE va = lj_bswap(va); vb = lj_bswap(vb); #endif i -= n; if ((int32_t)i >= -3) { va >>= 32+(i<<3); vb >>= 32+(i<<3); if (va == vb) break; } return va < vb ? -1 : 1; } } return (int32_t)(a->len - b->len); } /* Fast string data comparison. Caveat: unaligned access to 1st string! */ static LJ_AINLINE int str_fastcmp(const char *a, const char *b, MSize len) { MSize i = 0; lua_assert(len > 0); lua_assert((((uintptr_t)a+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4); do { /* Note: innocuous access up to end of string + 3. */ uint32_t v = lj_getu32(a+i) ^ *(const uint32_t *)(b+i); if (v) { i -= len; #if LJ_LE return (int32_t)i >= -3 ? (v << (32+(i<<3))) : 1; #else return (int32_t)i >= -3 ? (v >> (32+(i<<3))) : 1; #endif } i += 4; } while (i < len); return 0; } /* Resize the string hash table (grow and shrink). */ void lj_str_resize(lua_State *L, MSize newmask) { global_State *g = G(L); GCRef *newhash; MSize i; if (g->gc.state == GCSsweepstring || newmask >= LJ_MAX_STRTAB-1) return; /* No resizing during GC traversal or if already too big. */ newhash = lj_mem_newvec(L, newmask+1, GCRef); memset(newhash, 0, (newmask+1)*sizeof(GCRef)); for (i = g->strmask; i != ~(MSize)0; i--) { /* Rehash old table. */ GCobj *p = gcref(g->strhash[i]); while (p) { /* Follow each hash chain and reinsert all strings. */ MSize h = gco2str(p)->hash & newmask; GCobj *next = gcnext(p); /* NOBARRIER: The string table is a GC root. */ setgcrefr(p->gch.nextgc, newhash[h]); setgcref(newhash[h], p); p = next; } } lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); g->strmask = newmask; g->strhash = newhash; } /* Intern a string and return string object. */ GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) { global_State *g; GCstr *s; GCobj *o; MSize len = (MSize)lenx; MSize a, b, h = len; if (lenx >= LJ_MAX_STR) lj_err_msg(L, LJ_ERR_STROV); g = G(L); /* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */ if (len >= 4) { /* Caveat: unaligned access! */ a = lj_getu32(str); h ^= lj_getu32(str+len-4); b = lj_getu32(str+(len>>1)-2); h ^= b; h -= lj_rol(b, 14); b += lj_getu32(str+(len>>2)-1); } else if (len > 0) { a = *(const uint8_t *)str; h ^= *(const uint8_t *)(str+len-1); b = *(const uint8_t *)(str+(len>>1)); h ^= b; h -= lj_rol(b, 14); } else { return &g->strempty; } a ^= h; a -= lj_rol(h, 11); b ^= a; b -= lj_rol(a, 25); h ^= b; h -= lj_rol(b, 16); /* Check if the string has already been interned. */ o = gcref(g->strhash[h & g->strmask]); if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { while (o != NULL) { GCstr *sx = gco2str(o); if (sx->len == len && str_fastcmp(str, strdata(sx), len) == 0) { /* Resurrect if dead. Can only happen with fixstring() (keywords). */ if (isdead(g, o)) flipwhite(o); return sx; /* Return existing string. */ } o = gcnext(o); } } else { /* Slow path: end of string is too close to a page boundary. */ while (o != NULL) { GCstr *sx = gco2str(o); if (sx->len == len && memcmp(str, strdata(sx), len) == 0) { /* Resurrect if dead. Can only happen with fixstring() (keywords). */ if (isdead(g, o)) flipwhite(o); return sx; /* Return existing string. */ } o = gcnext(o); } } /* Nope, create a new string. */ s = lj_mem_newt(L, sizeof(GCstr)+len+1, GCstr); newwhite(g, s); s->gct = ~LJ_TSTR; s->len = len; s->hash = h; s->reserved = 0; memcpy(strdatawr(s), str, len); strdatawr(s)[len] = '\0'; /* Zero-terminate string. */ /* Add it to string hash table. */ h &= g->strmask; s->nextgc = g->strhash[h]; /* NOBARRIER: The string table is a GC root. */ setgcref(g->strhash[h], obj2gco(s)); if (g->strnum++ > g->strmask) /* Allow a 100% load factor. */ lj_str_resize(L, (g->strmask<<1)+1); /* Grow string table. */ return s; /* Return newly interned string. */ } void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s) { g->strnum--; lj_mem_free(g, s, sizestring(s)); } /* -- Type conversions ---------------------------------------------------- */ /* Print number to buffer. Canonicalizes non-finite values. */ size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o) { if (LJ_LIKELY((o->u32.hi << 1) < 0xffe00000)) { /* Finite? */ lua_Number n = o->n; #if __BIONIC__ if (tvismzero(o)) { s[0] = '-'; s[1] = '0'; return 2; } #endif return (size_t)lua_number2str(s, n); } else if (((o->u32.hi & 0x000fffff) | o->u32.lo) != 0) { s[0] = 'n'; s[1] = 'a'; s[2] = 'n'; return 3; } else if ((o->u32.hi & 0x80000000) == 0) { s[0] = 'i'; s[1] = 'n'; s[2] = 'f'; return 3; } else { s[0] = '-'; s[1] = 'i'; s[2] = 'n'; s[3] = 'f'; return 4; } } /* Print integer to buffer. Returns pointer to start. */ char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k) { uint32_t u = (uint32_t)(k < 0 ? -k : k); p += 1+10; do { *--p = (char)('0' + u % 10); } while (u /= 10); if (k < 0) *--p = '-'; return p; } /* Convert number to string. */ GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np) { char buf[LJ_STR_NUMBUF]; size_t len = lj_str_bufnum(buf, (TValue *)np); return lj_str_new(L, buf, len); } /* Convert integer to string. */ GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k) { char s[1+10]; char *p = lj_str_bufint(s, k); return lj_str_new(L, p, (size_t)(s+sizeof(s)-p)); } GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o) { return tvisint(o) ? lj_str_fromint(L, intV(o)) : lj_str_fromnum(L, &o->n); } /* -- String formatting --------------------------------------------------- */ static void addstr(lua_State *L, SBuf *sb, const char *str, MSize len) { char *p; MSize i; if (sb->n + len > sb->sz) { MSize sz = sb->sz * 2; while (sb->n + len > sz) sz = sz * 2; lj_str_resizebuf(L, sb, sz); } p = sb->buf + sb->n; sb->n += len; for (i = 0; i < len; i++) p[i] = str[i]; } static void addchar(lua_State *L, SBuf *sb, int c) { if (sb->n + 1 > sb->sz) { MSize sz = sb->sz * 2; lj_str_resizebuf(L, sb, sz); } sb->buf[sb->n++] = (char)c; } /* Push formatted message as a string object to Lua stack. va_list variant. */ const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp) { SBuf *sb = &G(L)->tmpbuf; lj_str_needbuf(L, sb, (MSize)strlen(fmt)); lj_str_resetbuf(sb); for (;;) { const char *e = strchr(fmt, '%'); if (e == NULL) break; addstr(L, sb, fmt, (MSize)(e-fmt)); /* This function only handles %s, %c, %d, %f and %p formats. */ switch (e[1]) { case 's': { const char *s = va_arg(argp, char *); if (s == NULL) s = "(null)"; addstr(L, sb, s, (MSize)strlen(s)); break; } case 'c': addchar(L, sb, va_arg(argp, int)); break; case 'd': { char buf[LJ_STR_INTBUF]; char *p = lj_str_bufint(buf, va_arg(argp, int32_t)); addstr(L, sb, p, (MSize)(buf+LJ_STR_INTBUF-p)); break; } case 'f': { char buf[LJ_STR_NUMBUF]; TValue tv; MSize len; tv.n = (lua_Number)(va_arg(argp, LUAI_UACNUMBER)); len = (MSize)lj_str_bufnum(buf, &tv); addstr(L, sb, buf, len); break; } case 'p': { #define FMTP_CHARS (2*sizeof(ptrdiff_t)) char buf[2+FMTP_CHARS]; ptrdiff_t p = (ptrdiff_t)(va_arg(argp, void *)); ptrdiff_t i, lasti = 2+FMTP_CHARS; if (p == 0) { addstr(L, sb, "NULL", 4); break; } #if LJ_64 /* Shorten output for 64 bit pointers. */ lasti = 2+2*4+((p >> 32) ? 2+2*(lj_fls((uint32_t)(p >> 32))>>3) : 0); #endif buf[0] = '0'; buf[1] = 'x'; for (i = lasti-1; i >= 2; i--, p >>= 4) buf[i] = "0123456789abcdef"[(p & 15)]; addstr(L, sb, buf, (MSize)lasti); break; } case '%': addchar(L, sb, '%'); break; default: addchar(L, sb, '%'); addchar(L, sb, e[1]); break; } fmt = e+2; } addstr(L, sb, fmt, (MSize)strlen(fmt)); setstrV(L, L->top, lj_str_new(L, sb->buf, sb->n)); incr_top(L); return strVdata(L->top - 1); } /* Push formatted message as a string object to Lua stack. Vararg variant. */ const char *lj_str_pushf(lua_State *L, const char *fmt, ...) { const char *msg; va_list argp; va_start(argp, fmt); msg = lj_str_pushvf(L, fmt, argp); va_end(argp); return msg; } /* -- Buffer handling ----------------------------------------------------- */ char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz) { if (sz > sb->sz) { if (sz < LJ_MIN_SBUF) sz = LJ_MIN_SBUF; lj_str_resizebuf(L, sb, sz); } return sb->buf; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_str.h ================================================ /* ** String handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_STR_H #define _LJ_STR_H #include #include "lj_obj.h" /* String interning. */ LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) /* Type conversions. */ LJ_FUNC size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o); LJ_FUNC char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k); LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np); LJ_FUNC GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k); LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o); #define LJ_STR_INTBUF (1+10) #define LJ_STR_NUMBUF LUAI_MAXNUMBER2STR /* String formatting. */ LJ_FUNC const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp); LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((format (printf, 2, 3))) #endif ; /* Resizable string buffers. Struct definition in lj_obj.h. */ LJ_FUNC char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz); #define lj_str_initbuf(sb) ((sb)->buf = NULL, (sb)->sz = 0) #define lj_str_resetbuf(sb) ((sb)->n = 0) #define lj_str_resizebuf(L, sb, size) \ ((sb)->buf = (char *)lj_mem_realloc(L, (sb)->buf, (sb)->sz, (size)), \ (sb)->sz = (size)) #define lj_str_freebuf(g, sb) lj_mem_free(g, (void *)(sb)->buf, (sb)->sz) #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_strscan.c ================================================ /* ** String scanning. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include #define lj_strscan_c #define LUA_CORE #include "lj_obj.h" #include "lj_char.h" #include "lj_strscan.h" /* -- Scanning numbers ---------------------------------------------------- */ /* ** Rationale for the builtin string to number conversion library: ** ** It removes a dependency on libc's strtod(), which is a true portability ** nightmare. Mainly due to the plethora of supported OS and toolchain ** combinations. Sadly, the various implementations ** a) are often buggy, incomplete (no hex floats) and/or imprecise, ** b) sometimes crash or hang on certain inputs, ** c) return non-standard NaNs that need to be filtered out, and ** d) fail if the locale-specific decimal separator is not a dot, ** which can only be fixed with atrocious workarounds. ** ** Also, most of the strtod() implementations are hopelessly bloated, ** which is not just an I-cache hog, but a problem for static linkage ** on embedded systems, too. ** ** OTOH the builtin conversion function is very compact. Even though it ** does a lot more, like parsing long longs, octal or imaginary numbers ** and returning the result in different formats: ** a) It needs less than 3 KB (!) of machine code (on x64 with -Os), ** b) it doesn't perform any dynamic allocation and, ** c) it needs only around 600 bytes of stack space. ** ** The builtin function is faster than strtod() for typical inputs, e.g. ** "123", "1.5" or "1e6". Arguably, it's slower for very large exponents, ** which are not very common (this could be fixed, if needed). ** ** And most importantly, the builtin function is equally precise on all ** platforms. It correctly converts and rounds any input to a double. ** If this is not the case, please send a bug report -- but PLEASE verify ** that the implementation you're comparing to is not the culprit! ** ** The implementation quickly pre-scans the entire string first and ** handles simple integers on-the-fly. Otherwise, it dispatches to the ** base-specific parser. Hex and octal is straightforward. ** ** Decimal to binary conversion uses a fixed-length circular buffer in ** base 100. Some simple cases are handled directly. For other cases, the ** number in the buffer is up-scaled or down-scaled until the integer part ** is in the proper range. Then the integer part is rounded and converted ** to a double which is finally rescaled to the result. Denormals need ** special treatment to prevent incorrect 'double rounding'. */ /* Definitions for circular decimal digit buffer (base 100 = 2 digits/byte). */ #define STRSCAN_DIG 1024 #define STRSCAN_MAXDIG 800 /* 772 + extra are sufficient. */ #define STRSCAN_DDIG (STRSCAN_DIG/2) #define STRSCAN_DMASK (STRSCAN_DDIG-1) /* Helpers for circular buffer. */ #define DNEXT(a) (((a)+1) & STRSCAN_DMASK) #define DPREV(a) (((a)-1) & STRSCAN_DMASK) #define DLEN(lo, hi) ((int32_t)(((lo)-(hi)) & STRSCAN_DMASK)) #define casecmp(c, k) (((c) | 0x20) == k) /* Final conversion to double. */ static void strscan_double(uint64_t x, TValue *o, int32_t ex2, int32_t neg) { double n; /* Avoid double rounding for denormals. */ if (LJ_UNLIKELY(ex2 <= -1075 && x != 0)) { /* NYI: all of this generates way too much code on 32 bit CPUs. */ #if defined(__GNUC__) && LJ_64 int32_t b = (int32_t)(__builtin_clzll(x)^63); #else int32_t b = (x>>32) ? 32+(int32_t)lj_fls((uint32_t)(x>>32)) : (int32_t)lj_fls((uint32_t)x); #endif if ((int32_t)b + ex2 <= -1023 && (int32_t)b + ex2 >= -1075) { uint64_t rb = (uint64_t)1 << (-1075-ex2); if ((x & rb) && ((x & (rb+rb+rb-1)))) x += rb+rb; x = (x & ~(rb+rb-1)); } } /* Convert to double using a signed int64_t conversion, then rescale. */ lua_assert((int64_t)x >= 0); n = (double)(int64_t)x; if (neg) n = -n; if (ex2) n = ldexp(n, ex2); o->n = n; } /* Parse hexadecimal number. */ static StrScanFmt strscan_hex(const uint8_t *p, TValue *o, StrScanFmt fmt, uint32_t opt, int32_t ex2, int32_t neg, uint32_t dig) { uint64_t x = 0; uint32_t i; /* Scan hex digits. */ for (i = dig > 16 ? 16 : dig ; i; i--, p++) { uint32_t d = (*p != '.' ? *p : *++p); if (d > '9') d += 9; x = (x << 4) + (d & 15); } /* Summarize rounding-effect of excess digits. */ for (i = 16; i < dig; i++, p++) x |= ((*p != '.' ? *p : *++p) != '0'), ex2 += 4; /* Format-specific handling. */ switch (fmt) { case STRSCAN_INT: if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) { o->i = neg ? -(int32_t)x : (int32_t)x; return STRSCAN_INT; /* Fast path for 32 bit integers. */ } if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; break; } /* fallthrough */ case STRSCAN_U32: if (dig > 8) return STRSCAN_ERROR; o->i = neg ? -(int32_t)x : (int32_t)x; return STRSCAN_U32; case STRSCAN_I64: case STRSCAN_U64: if (dig > 16) return STRSCAN_ERROR; o->u64 = neg ? (uint64_t)-(int64_t)x : x; return fmt; default: break; } /* Reduce range then convert to double. */ if ((x & U64x(c0000000,0000000))) { x = (x >> 2) | (x & 3); ex2 += 2; } strscan_double(x, o, ex2, neg); return fmt; } /* Parse octal number. */ static StrScanFmt strscan_oct(const uint8_t *p, TValue *o, StrScanFmt fmt, int32_t neg, uint32_t dig) { uint64_t x = 0; /* Scan octal digits. */ if (dig > 22 || (dig == 22 && *p > '1')) return STRSCAN_ERROR; while (dig-- > 0) { if (!(*p >= '0' && *p <= '7')) return STRSCAN_ERROR; x = (x << 3) + (*p++ & 7); } /* Format-specific handling. */ switch (fmt) { case STRSCAN_INT: if (x >= 0x80000000u+neg) fmt = STRSCAN_U32; /* fallthrough */ case STRSCAN_U32: if ((x >> 32)) return STRSCAN_ERROR; o->i = neg ? -(int32_t)x : (int32_t)x; break; default: case STRSCAN_I64: case STRSCAN_U64: o->u64 = neg ? (uint64_t)-(int64_t)x : x; break; } return fmt; } /* Parse decimal number. */ static StrScanFmt strscan_dec(const uint8_t *p, TValue *o, StrScanFmt fmt, uint32_t opt, int32_t ex10, int32_t neg, uint32_t dig) { uint8_t xi[STRSCAN_DDIG], *xip = xi; if (dig) { uint32_t i = dig; if (i > STRSCAN_MAXDIG) { ex10 -= (int32_t)(i - STRSCAN_MAXDIG); i = STRSCAN_MAXDIG; } /* Scan unaligned leading digit. */ if (((ex10^i) & 1)) *xip++ = ((*p != '.' ? *p : *++p) & 15), i--, p++; /* Scan aligned double-digits. */ for ( ; i > 1; i -= 2) { uint32_t d = 10 * ((*p != '.' ? *p : *++p) & 15); p++; *xip++ = d + ((*p != '.' ? *p : *++p) & 15); p++; } /* Scan and realign trailing digit. */ if (i) *xip++ = 10 * ((*p != '.' ? *p : *++p) & 15), ex10--, p++; /* Summarize rounding-effect of excess digits. */ if (dig > STRSCAN_MAXDIG) { do { if ((*p != '.' ? *p : *++p) != '0') { xip[-1] |= 1; break; } p++; } while (--dig > STRSCAN_MAXDIG); dig = STRSCAN_MAXDIG; } else { /* Simplify exponent. */ while (ex10 > 0 && dig <= 18) *xip++ = 0, ex10 -= 2, dig += 2; } } else { /* Only got zeros. */ ex10 = 0; xi[0] = 0; } /* Fast path for numbers in integer format (but handles e.g. 1e6, too). */ if (dig <= 20 && ex10 == 0) { uint8_t *xis; uint64_t x = xi[0]; double n; for (xis = xi+1; xis < xip; xis++) x = x * 100 + *xis; if (!(dig == 20 && (xi[0] > 18 || (int64_t)x >= 0))) { /* No overflow? */ /* Format-specific handling. */ switch (fmt) { case STRSCAN_INT: if (!(opt & STRSCAN_OPT_TONUM) && x < 0x80000000u+neg) { o->i = neg ? -(int32_t)x : (int32_t)x; return STRSCAN_INT; /* Fast path for 32 bit integers. */ } if (!(opt & STRSCAN_OPT_C)) { fmt = STRSCAN_NUM; goto plainnumber; } /* fallthrough */ case STRSCAN_U32: if ((x >> 32) != 0) return STRSCAN_ERROR; o->i = neg ? -(int32_t)x : (int32_t)x; return STRSCAN_U32; case STRSCAN_I64: case STRSCAN_U64: o->u64 = neg ? (uint64_t)-(int64_t)x : x; return fmt; default: plainnumber: /* Fast path for plain numbers < 2^63. */ if ((int64_t)x < 0) break; n = (double)(int64_t)x; if (neg) n = -n; o->n = n; return fmt; } } } /* Slow non-integer path. */ if (fmt == STRSCAN_INT) { if ((opt & STRSCAN_OPT_C)) return STRSCAN_ERROR; fmt = STRSCAN_NUM; } else if (fmt > STRSCAN_INT) { return STRSCAN_ERROR; } { uint32_t hi = 0, lo = (uint32_t)(xip-xi); int32_t ex2 = 0, idig = (int32_t)lo + (ex10 >> 1); lua_assert(lo > 0 && (ex10 & 1) == 0); /* Handle simple overflow/underflow. */ if (idig > 310/2) { if (neg) setminfV(o); else setpinfV(o); return fmt; } else if (idig < -326/2) { o->n = neg ? -0.0 : 0.0; return fmt; } /* Scale up until we have at least 17 or 18 integer part digits. */ while (idig < 9 && idig < DLEN(lo, hi)) { uint32_t i, cy = 0; ex2 -= 6; for (i = DPREV(lo); ; i = DPREV(i)) { uint32_t d = (xi[i] << 6) + cy; cy = (((d >> 2) * 5243) >> 17); d = d - cy * 100; /* Div/mod 100. */ xi[i] = (uint8_t)d; if (i == hi) break; if (d == 0 && i == DPREV(lo)) lo = i; } if (cy) { if (xi[DPREV(lo)] == 0) lo = DPREV(lo); else if (hi == lo) { lo = DPREV(lo); xi[DPREV(lo)] |= xi[lo]; } hi = DPREV(hi); xi[hi] = (uint8_t)cy; idig++; } } /* Scale down until no more than 17 or 18 integer part digits remain. */ while (idig > 9) { uint32_t i, cy = 0; ex2 += 6; for (i = hi; i != lo; i = DNEXT(i)) { cy += xi[i]; xi[i] = (cy >> 6); cy = 100 * (cy & 0x3f); if (xi[i] == 0 && i == hi) hi = DNEXT(hi), idig--; } while (cy) { if (hi == lo) { xi[DPREV(lo)] |= 1; break; } xi[lo] = (cy >> 6); lo = DNEXT(lo); cy = 100 * (cy & 0x3f); } } /* Collect integer part digits and convert to rescaled double. */ { uint64_t x = xi[hi]; uint32_t i; for (i = DNEXT(hi); --idig > 0 && i != lo; i = DNEXT(i)) x = x * 100 + xi[i]; if (i == lo) { while (--idig >= 0) x = x * 100; } else { /* Gather round bit from remaining digits. */ x <<= 1; ex2--; do { if (xi[i]) { x |= 1; break; } i = DNEXT(i); } while (i != lo); } strscan_double(x, o, ex2, neg); } } return fmt; } /* Scan string containing a number. Returns format. Returns value in o. */ StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt) { int32_t neg = 0; /* Remove leading space, parse sign and non-numbers. */ if (LJ_UNLIKELY(!lj_char_isdigit(*p))) { while (lj_char_isspace(*p)) p++; if (*p == '+' || *p == '-') neg = (*p++ == '-'); if (LJ_UNLIKELY(*p >= 'A')) { /* Parse "inf", "infinity" or "nan". */ TValue tmp; setnanV(&tmp); if (casecmp(p[0],'i') && casecmp(p[1],'n') && casecmp(p[2],'f')) { if (neg) setminfV(&tmp); else setpinfV(&tmp); p += 3; if (casecmp(p[0],'i') && casecmp(p[1],'n') && casecmp(p[2],'i') && casecmp(p[3],'t') && casecmp(p[4],'y')) p += 5; } else if (casecmp(p[0],'n') && casecmp(p[1],'a') && casecmp(p[2],'n')) { p += 3; } while (lj_char_isspace(*p)) p++; if (*p) return STRSCAN_ERROR; o->u64 = tmp.u64; return STRSCAN_NUM; } } /* Parse regular number. */ { StrScanFmt fmt = STRSCAN_INT; int cmask = LJ_CHAR_DIGIT; int base = (opt & STRSCAN_OPT_C) && *p == '0' ? 0 : 10; const uint8_t *sp, *dp = NULL; uint32_t dig = 0, hasdig = 0, x = 0; int32_t ex = 0; /* Determine base and skip leading zeros. */ if (LJ_UNLIKELY(*p <= '0')) { if (*p == '0' && casecmp(p[1], 'x')) base = 16, cmask = LJ_CHAR_XDIGIT, p += 2; for ( ; ; p++) { if (*p == '0') { hasdig = 1; } else if (*p == '.') { if (dp) return STRSCAN_ERROR; dp = p; } else { break; } } } /* Preliminary digit and decimal point scan. */ for (sp = p; ; p++) { if (LJ_LIKELY(lj_char_isa(*p, cmask))) { x = x * 10 + (*p & 15); /* For fast path below. */ dig++; } else if (*p == '.') { if (dp) return STRSCAN_ERROR; dp = p; } else { break; } } if (!(hasdig | dig)) return STRSCAN_ERROR; /* Handle decimal point. */ if (dp) { fmt = STRSCAN_NUM; if (dig) { ex = (int32_t)(dp-(p-1)); dp = p-1; while (ex < 0 && *dp-- == '0') ex++, dig--; /* Skip trailing zeros. */ if (base == 16) ex *= 4; } } /* Parse exponent. */ if (casecmp(*p, (uint32_t)(base == 16 ? 'p' : 'e'))) { uint32_t xx; int negx = 0; fmt = STRSCAN_NUM; p++; if (*p == '+' || *p == '-') negx = (*p++ == '-'); if (!lj_char_isdigit(*p)) return STRSCAN_ERROR; xx = (*p++ & 15); while (lj_char_isdigit(*p)) { if (xx < 65536) xx = xx * 10 + (*p & 15); p++; } ex += negx ? -(int32_t)xx : (int32_t)xx; } /* Parse suffix. */ if (*p) { /* I (IMAG), U (U32), LL (I64), ULL/LLU (U64), L (long), UL/LU (ulong). */ /* NYI: f (float). Not needed until cp_number() handles non-integers. */ if (casecmp(*p, 'i')) { if (!(opt & STRSCAN_OPT_IMAG)) return STRSCAN_ERROR; p++; fmt = STRSCAN_IMAG; } else if (fmt == STRSCAN_INT) { if (casecmp(*p, 'u')) p++, fmt = STRSCAN_U32; if (casecmp(*p, 'l')) { p++; if (casecmp(*p, 'l')) p++, fmt += STRSCAN_I64 - STRSCAN_INT; else if (!(opt & STRSCAN_OPT_C)) return STRSCAN_ERROR; else if (sizeof(long) == 8) fmt += STRSCAN_I64 - STRSCAN_INT; } if (casecmp(*p, 'u') && (fmt == STRSCAN_INT || fmt == STRSCAN_I64)) p++, fmt += STRSCAN_U32 - STRSCAN_INT; if ((fmt == STRSCAN_U32 && !(opt & STRSCAN_OPT_C)) || (fmt >= STRSCAN_I64 && !(opt & STRSCAN_OPT_LL))) return STRSCAN_ERROR; } while (lj_char_isspace(*p)) p++; if (*p) return STRSCAN_ERROR; } /* Fast path for decimal 32 bit integers. */ if (fmt == STRSCAN_INT && base == 10 && (dig < 10 || (dig == 10 && *sp <= '2' && x < 0x80000000u+neg))) { int32_t y = neg ? -(int32_t)x : (int32_t)x; if ((opt & STRSCAN_OPT_TONUM)) { o->n = (double)y; return STRSCAN_NUM; } else { o->i = y; return STRSCAN_INT; } } /* Dispatch to base-specific parser. */ if (base == 0 && !(fmt == STRSCAN_NUM || fmt == STRSCAN_IMAG)) return strscan_oct(sp, o, fmt, neg, dig); if (base == 16) fmt = strscan_hex(sp, o, fmt, opt, ex, neg, dig); else fmt = strscan_dec(sp, o, fmt, opt, ex, neg, dig); /* Try to convert number to integer, if requested. */ if (fmt == STRSCAN_NUM && (opt & STRSCAN_OPT_TOINT)) { double n = o->n; int32_t i = lj_num2int(n); if (n == (lua_Number)i) { o->i = i; return STRSCAN_INT; } } return fmt; } } int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o) { StrScanFmt fmt = lj_strscan_scan((const uint8_t *)strdata(str), o, STRSCAN_OPT_TONUM); lua_assert(fmt == STRSCAN_ERROR || fmt == STRSCAN_NUM); return (fmt != STRSCAN_ERROR); } #if LJ_DUALNUM int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o) { StrScanFmt fmt = lj_strscan_scan((const uint8_t *)strdata(str), o, STRSCAN_OPT_TOINT); lua_assert(fmt == STRSCAN_ERROR || fmt == STRSCAN_NUM || fmt == STRSCAN_INT); if (fmt == STRSCAN_INT) setitype(o, LJ_TISNUM); return (fmt != STRSCAN_ERROR); } #endif #undef DNEXT #undef DPREV #undef DLEN ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_strscan.h ================================================ /* ** String scanning. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_STRSCAN_H #define _LJ_STRSCAN_H #include "lj_obj.h" /* Options for accepted/returned formats. */ #define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ #define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ #define STRSCAN_OPT_IMAG 0x04 #define STRSCAN_OPT_LL 0x08 #define STRSCAN_OPT_C 0x10 /* Returned format. */ typedef enum { STRSCAN_ERROR, STRSCAN_NUM, STRSCAN_IMAG, STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, } StrScanFmt; LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt); LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); #if LJ_DUALNUM LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); #else #define lj_strscan_number(s, o) lj_strscan_num((s), (o)) #endif /* Check for number or convert string to number/int in-place (!). */ static LJ_AINLINE int lj_strscan_numberobj(TValue *o) { return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_tab.c ================================================ /* ** Table handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #define lj_tab_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_err.h" #include "lj_tab.h" /* -- Object hashing ------------------------------------------------------ */ /* Hash values are masked with the table hash mask and used as an index. */ static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash) { Node *n = noderef(t->node); return &n[hash & t->hmask]; } /* String hashes are precomputed when they are interned. */ #define hashstr(t, s) hashmask(t, (s)->hash) #define hashlohi(t, lo, hi) hashmask((t), hashrot((lo), (hi))) #define hashnum(t, o) hashlohi((t), (o)->u32.lo, ((o)->u32.hi << 1)) #define hashptr(t, p) hashlohi((t), u32ptr(p), u32ptr(p) + HASH_BIAS) #define hashgcref(t, r) hashlohi((t), gcrefu(r), gcrefu(r) + HASH_BIAS) /* Hash an arbitrary key and return its anchor position in the hash table. */ static Node *hashkey(const GCtab *t, cTValue *key) { lua_assert(!tvisint(key)); if (tvisstr(key)) return hashstr(t, strV(key)); else if (tvisnum(key)) return hashnum(t, key); else if (tvisbool(key)) return hashmask(t, boolV(key)); else return hashgcref(t, key->gcr); /* Only hash 32 bits of lightuserdata on a 64 bit CPU. Good enough? */ } /* -- Table creation and destruction -------------------------------------- */ /* Create new hash part for table. */ static LJ_AINLINE void newhpart(lua_State *L, GCtab *t, uint32_t hbits) { uint32_t hsize; Node *node; lua_assert(hbits != 0); if (hbits > LJ_MAX_HBITS) lj_err_msg(L, LJ_ERR_TABOV); hsize = 1u << hbits; node = lj_mem_newvec(L, hsize, Node); setmref(node->freetop, &node[hsize]); setmref(t->node, node); t->hmask = hsize-1; } /* ** Q: Why all of these copies of t->hmask, t->node etc. to local variables? ** A: Because alias analysis for C is _really_ tough. ** Even state-of-the-art C compilers won't produce good code without this. */ /* Clear hash part of table. */ static LJ_AINLINE void clearhpart(GCtab *t) { uint32_t i, hmask = t->hmask; Node *node = noderef(t->node); lua_assert(t->hmask != 0); for (i = 0; i <= hmask; i++) { Node *n = &node[i]; setmref(n->next, NULL); setnilV(&n->key); setnilV(&n->val); } } /* Clear array part of table. */ static LJ_AINLINE void clearapart(GCtab *t) { uint32_t i, asize = t->asize; TValue *array = tvref(t->array); for (i = 0; i < asize; i++) setnilV(&array[i]); } /* Create a new table. Note: the slots are not initialized (yet). */ static GCtab *newtab(lua_State *L, uint32_t asize, uint32_t hbits) { GCtab *t; /* First try to colocate the array part. */ if (LJ_MAX_COLOSIZE != 0 && asize > 0 && asize <= LJ_MAX_COLOSIZE) { lua_assert((sizeof(GCtab) & 7) == 0); t = (GCtab *)lj_mem_newgco(L, sizetabcolo(asize)); t->gct = ~LJ_TTAB; t->nomm = (uint8_t)~0; t->colo = (int8_t)asize; setmref(t->array, (TValue *)((char *)t + sizeof(GCtab))); setgcrefnull(t->metatable); t->asize = asize; t->hmask = 0; setmref(t->node, &G(L)->nilnode); } else { /* Otherwise separately allocate the array part. */ t = lj_mem_newobj(L, GCtab); t->gct = ~LJ_TTAB; t->nomm = (uint8_t)~0; t->colo = 0; setmref(t->array, NULL); setgcrefnull(t->metatable); t->asize = 0; /* In case the array allocation fails. */ t->hmask = 0; setmref(t->node, &G(L)->nilnode); if (asize > 0) { if (asize > LJ_MAX_ASIZE) lj_err_msg(L, LJ_ERR_TABOV); setmref(t->array, lj_mem_newvec(L, asize, TValue)); t->asize = asize; } } if (hbits) newhpart(L, t, hbits); return t; } /* Create a new table. ** ** IMPORTANT NOTE: The API differs from lua_createtable()! ** ** The array size is non-inclusive. E.g. asize=128 creates array slots ** for 0..127, but not for 128. If you need slots 1..128, pass asize=129 ** (slot 0 is wasted in this case). ** ** The hash size is given in hash bits. hbits=0 means no hash part. ** hbits=1 creates 2 hash slots, hbits=2 creates 4 hash slots and so on. */ GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits) { GCtab *t = newtab(L, asize, hbits); clearapart(t); if (t->hmask > 0) clearhpart(t); return t; } #if LJ_HASJIT GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize) { GCtab *t = newtab(L, ahsize & 0xffffff, ahsize >> 24); clearapart(t); if (t->hmask > 0) clearhpart(t); return t; } #endif /* Duplicate a table. */ GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt) { GCtab *t; uint32_t asize, hmask; t = newtab(L, kt->asize, kt->hmask > 0 ? lj_fls(kt->hmask)+1 : 0); lua_assert(kt->asize == t->asize && kt->hmask == t->hmask); t->nomm = 0; /* Keys with metamethod names may be present. */ asize = kt->asize; if (asize > 0) { TValue *array = tvref(t->array); TValue *karray = tvref(kt->array); if (asize < 64) { /* An inlined loop beats memcpy for < 512 bytes. */ uint32_t i; for (i = 0; i < asize; i++) copyTV(L, &array[i], &karray[i]); } else { memcpy(array, karray, asize*sizeof(TValue)); } } hmask = kt->hmask; if (hmask > 0) { uint32_t i; Node *node = noderef(t->node); Node *knode = noderef(kt->node); ptrdiff_t d = (char *)node - (char *)knode; setmref(node->freetop, (Node *)((char *)noderef(knode->freetop) + d)); for (i = 0; i <= hmask; i++) { Node *kn = &knode[i]; Node *n = &node[i]; Node *next = nextnode(kn); /* Don't use copyTV here, since it asserts on a copy of a dead key. */ n->val = kn->val; n->key = kn->key; setmref(n->next, next == NULL? next : (Node *)((char *)next + d)); } } return t; } /* Free a table. */ void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t) { if (t->hmask > 0) lj_mem_freevec(g, noderef(t->node), t->hmask+1, Node); if (t->asize > 0 && LJ_MAX_COLOSIZE != 0 && t->colo <= 0) lj_mem_freevec(g, tvref(t->array), t->asize, TValue); if (LJ_MAX_COLOSIZE != 0 && t->colo) lj_mem_free(g, t, sizetabcolo((uint32_t)t->colo & 0x7f)); else lj_mem_freet(g, t); } /* -- Table resizing ------------------------------------------------------ */ /* Resize a table to fit the new array/hash part sizes. */ static void resizetab(lua_State *L, GCtab *t, uint32_t asize, uint32_t hbits) { Node *oldnode = noderef(t->node); uint32_t oldasize = t->asize; uint32_t oldhmask = t->hmask; if (asize > oldasize) { /* Array part grows? */ TValue *array; uint32_t i; if (asize > LJ_MAX_ASIZE) lj_err_msg(L, LJ_ERR_TABOV); if (LJ_MAX_COLOSIZE != 0 && t->colo > 0) { /* A colocated array must be separated and copied. */ TValue *oarray = tvref(t->array); array = lj_mem_newvec(L, asize, TValue); t->colo = (int8_t)(t->colo | 0x80); /* Mark as separated (colo < 0). */ for (i = 0; i < oldasize; i++) copyTV(L, &array[i], &oarray[i]); } else { array = (TValue *)lj_mem_realloc(L, tvref(t->array), oldasize*sizeof(TValue), asize*sizeof(TValue)); } setmref(t->array, array); t->asize = asize; for (i = oldasize; i < asize; i++) /* Clear newly allocated slots. */ setnilV(&array[i]); } /* Create new (empty) hash part. */ if (hbits) { newhpart(L, t, hbits); clearhpart(t); } else { global_State *g = G(L); setmref(t->node, &g->nilnode); t->hmask = 0; } if (asize < oldasize) { /* Array part shrinks? */ TValue *array = tvref(t->array); uint32_t i; t->asize = asize; /* Note: This 'shrinks' even colocated arrays. */ for (i = asize; i < oldasize; i++) /* Reinsert old array values. */ if (!tvisnil(&array[i])) copyTV(L, lj_tab_setinth(L, t, (int32_t)i), &array[i]); /* Physically shrink only separated arrays. */ if (LJ_MAX_COLOSIZE != 0 && t->colo <= 0) setmref(t->array, lj_mem_realloc(L, array, oldasize*sizeof(TValue), asize*sizeof(TValue))); } if (oldhmask > 0) { /* Reinsert pairs from old hash part. */ global_State *g; uint32_t i; for (i = 0; i <= oldhmask; i++) { Node *n = &oldnode[i]; if (!tvisnil(&n->val)) copyTV(L, lj_tab_set(L, t, &n->key), &n->val); } g = G(L); lj_mem_freevec(g, oldnode, oldhmask+1, Node); } } static uint32_t countint(cTValue *key, uint32_t *bins) { lua_assert(!tvisint(key)); if (tvisnum(key)) { lua_Number nk = numV(key); int32_t k = lj_num2int(nk); if ((uint32_t)k < LJ_MAX_ASIZE && nk == (lua_Number)k) { bins[(k > 2 ? lj_fls((uint32_t)(k-1)) : 0)]++; return 1; } } return 0; } static uint32_t countarray(const GCtab *t, uint32_t *bins) { uint32_t na, b, i; if (t->asize == 0) return 0; for (na = i = b = 0; b < LJ_MAX_ABITS; b++) { uint32_t n, top = 2u << b; TValue *array; if (top >= t->asize) { top = t->asize-1; if (i > top) break; } array = tvref(t->array); for (n = 0; i <= top; i++) if (!tvisnil(&array[i])) n++; bins[b] += n; na += n; } return na; } static uint32_t counthash(const GCtab *t, uint32_t *bins, uint32_t *narray) { uint32_t total, na, i, hmask = t->hmask; Node *node = noderef(t->node); for (total = na = 0, i = 0; i <= hmask; i++) { Node *n = &node[i]; if (!tvisnil(&n->val)) { na += countint(&n->key, bins); total++; } } *narray += na; return total; } static uint32_t bestasize(uint32_t bins[], uint32_t *narray) { uint32_t b, sum, na = 0, sz = 0, nn = *narray; for (b = 0, sum = 0; 2*nn > (1u< 0 && 2*(sum += bins[b]) > (1u<hmask > 0 ? lj_fls(t->hmask)+1 : 0); } /* -- Table getters ------------------------------------------------------- */ cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key) { TValue k; Node *n; k.n = (lua_Number)key; n = hashnum(t, &k); do { if (tvisnum(&n->key) && n->key.n == k.n) return &n->val; } while ((n = nextnode(n))); return NULL; } cTValue *lj_tab_getstr(GCtab *t, GCstr *key) { Node *n = hashstr(t, key); do { if (tvisstr(&n->key) && strV(&n->key) == key) return &n->val; } while ((n = nextnode(n))); return NULL; } cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key) { if (tvisstr(key)) { cTValue *tv = lj_tab_getstr(t, strV(key)); if (tv) return tv; } else if (tvisint(key)) { cTValue *tv = lj_tab_getint(t, intV(key)); if (tv) return tv; } else if (tvisnum(key)) { lua_Number nk = numV(key); int32_t k = lj_num2int(nk); if (nk == (lua_Number)k) { cTValue *tv = lj_tab_getint(t, k); if (tv) return tv; } else { goto genlookup; /* Else use the generic lookup. */ } } else if (!tvisnil(key)) { Node *n; genlookup: n = hashkey(t, key); do { if (lj_obj_equal(&n->key, key)) return &n->val; } while ((n = nextnode(n))); } return niltv(L); } /* -- Table setters ------------------------------------------------------- */ /* Insert new key. Use Brent's variation to optimize the chain length. */ TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key) { Node *n = hashkey(t, key); if (!tvisnil(&n->val) || t->hmask == 0) { Node *nodebase = noderef(t->node); Node *collide, *freenode = noderef(nodebase->freetop); lua_assert(freenode >= nodebase && freenode <= nodebase+t->hmask+1); do { if (freenode == nodebase) { /* No free node found? */ rehashtab(L, t, key); /* Rehash table. */ return lj_tab_set(L, t, key); /* Retry key insertion. */ } } while (!tvisnil(&(--freenode)->key)); setmref(nodebase->freetop, freenode); lua_assert(freenode != &G(L)->nilnode); collide = hashkey(t, &n->key); if (collide != n) { /* Colliding node not the main node? */ while (noderef(collide->next) != n) /* Find predecessor. */ collide = nextnode(collide); setmref(collide->next, freenode); /* Relink chain. */ /* Copy colliding node into free node and free main node. */ freenode->val = n->val; freenode->key = n->key; freenode->next = n->next; setmref(n->next, NULL); setnilV(&n->val); /* Rechain pseudo-resurrected string keys with colliding hashes. */ while (nextnode(freenode)) { Node *nn = nextnode(freenode); if (tvisstr(&nn->key) && !tvisnil(&nn->val) && hashstr(t, strV(&nn->key)) == n) { freenode->next = nn->next; nn->next = n->next; setmref(n->next, nn); } else { freenode = nn; } } } else { /* Otherwise use free node. */ setmrefr(freenode->next, n->next); /* Insert into chain. */ setmref(n->next, freenode); n = freenode; } } n->key.u64 = key->u64; if (LJ_UNLIKELY(tvismzero(&n->key))) n->key.u64 = 0; lj_gc_anybarriert(L, t); lua_assert(tvisnil(&n->val)); return &n->val; } TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key) { TValue k; Node *n; k.n = (lua_Number)key; n = hashnum(t, &k); do { if (tvisnum(&n->key) && n->key.n == k.n) return &n->val; } while ((n = nextnode(n))); return lj_tab_newkey(L, t, &k); } TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key) { TValue k; Node *n = hashstr(t, key); do { if (tvisstr(&n->key) && strV(&n->key) == key) return &n->val; } while ((n = nextnode(n))); setstrV(L, &k, key); return lj_tab_newkey(L, t, &k); } TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key) { Node *n; t->nomm = 0; /* Invalidate negative metamethod cache. */ if (tvisstr(key)) { return lj_tab_setstr(L, t, strV(key)); } else if (tvisint(key)) { return lj_tab_setint(L, t, intV(key)); } else if (tvisnum(key)) { lua_Number nk = numV(key); int32_t k = lj_num2int(nk); if (nk == (lua_Number)k) return lj_tab_setint(L, t, k); if (tvisnan(key)) lj_err_msg(L, LJ_ERR_NANIDX); /* Else use the generic lookup. */ } else if (tvisnil(key)) { lj_err_msg(L, LJ_ERR_NILIDX); } n = hashkey(t, key); do { if (lj_obj_equal(&n->key, key)) return &n->val; } while ((n = nextnode(n))); return lj_tab_newkey(L, t, key); } /* -- Table traversal ----------------------------------------------------- */ /* Get the traversal index of a key. */ static uint32_t keyindex(lua_State *L, GCtab *t, cTValue *key) { TValue tmp; if (tvisint(key)) { int32_t k = intV(key); if ((uint32_t)k < t->asize) return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */ setnumV(&tmp, (lua_Number)k); key = &tmp; } else if (tvisnum(key)) { lua_Number nk = numV(key); int32_t k = lj_num2int(nk); if ((uint32_t)k < t->asize && nk == (lua_Number)k) return (uint32_t)k; /* Array key indexes: [0..t->asize-1] */ } if (!tvisnil(key)) { Node *n = hashkey(t, key); do { if (lj_obj_equal(&n->key, key)) return t->asize + (uint32_t)(n - noderef(t->node)); /* Hash key indexes: [t->asize..t->asize+t->nmask] */ } while ((n = nextnode(n))); if (key->u32.hi == 0xfffe7fff) /* ITERN was despecialized while running. */ return key->u32.lo - 1; lj_err_msg(L, LJ_ERR_NEXTIDX); return 0; /* unreachable */ } return ~0u; /* A nil key starts the traversal. */ } /* Advance to the next step in a table traversal. */ int lj_tab_next(lua_State *L, GCtab *t, TValue *key) { uint32_t i = keyindex(L, t, key); /* Find predecessor key index. */ for (i++; i < t->asize; i++) /* First traverse the array keys. */ if (!tvisnil(arrayslot(t, i))) { setintV(key, i); copyTV(L, key+1, arrayslot(t, i)); return 1; } for (i -= t->asize; i <= t->hmask; i++) { /* Then traverse the hash keys. */ Node *n = &noderef(t->node)[i]; if (!tvisnil(&n->val)) { copyTV(L, key, &n->key); copyTV(L, key+1, &n->val); return 1; } } return 0; /* End of traversal. */ } /* -- Table length calculation -------------------------------------------- */ static MSize unbound_search(GCtab *t, MSize j) { cTValue *tv; MSize i = j; /* i is zero or a present index */ j++; /* find `i' and `j' such that i is present and j is not */ while ((tv = lj_tab_getint(t, (int32_t)j)) && !tvisnil(tv)) { i = j; j *= 2; if (j > (MSize)(INT_MAX-2)) { /* overflow? */ /* table was built with bad purposes: resort to linear search */ i = 1; while ((tv = lj_tab_getint(t, (int32_t)i)) && !tvisnil(tv)) i++; return i - 1; } } /* now do a binary search between them */ while (j - i > 1) { MSize m = (i+j)/2; cTValue *tvb = lj_tab_getint(t, (int32_t)m); if (tvb && !tvisnil(tvb)) i = m; else j = m; } return i; } /* ** Try to find a boundary in table `t'. A `boundary' is an integer index ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). */ MSize LJ_FASTCALL lj_tab_len(GCtab *t) { MSize j = (MSize)t->asize; if (j > 1 && tvisnil(arrayslot(t, j-1))) { MSize i = 1; while (j - i > 1) { MSize m = (i+j)/2; if (tvisnil(arrayslot(t, m-1))) j = m; else i = m; } return i-1; } if (j) j--; if (t->hmask <= 0) return j; return unbound_search(t, j); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_tab.h ================================================ /* ** Table handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_TAB_H #define _LJ_TAB_H #include "lj_obj.h" /* Hash constants. Tuned using a brute force search. */ #define HASH_BIAS (-0x04c11db7) #define HASH_ROT1 14 #define HASH_ROT2 5 #define HASH_ROT3 13 /* Scramble the bits of numbers and pointers. */ static LJ_AINLINE uint32_t hashrot(uint32_t lo, uint32_t hi) { #if LJ_TARGET_X86ORX64 /* Prefer variant that compiles well for a 2-operand CPU. */ lo ^= hi; hi = lj_rol(hi, HASH_ROT1); lo -= hi; hi = lj_rol(hi, HASH_ROT2); hi ^= lo; hi -= lj_rol(lo, HASH_ROT3); #else lo ^= hi; lo = lo - lj_rol(hi, HASH_ROT1); hi = lo ^ lj_rol(hi, HASH_ROT1 + HASH_ROT2); hi = hi - lj_rol(lo, HASH_ROT3); #endif return hi; } #define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); #if LJ_HASJIT LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize); #endif LJ_FUNCA GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt); LJ_FUNC void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t); LJ_FUNCA void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize); /* Caveat: all getters except lj_tab_get() can return NULL! */ LJ_FUNCA cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key); LJ_FUNC cTValue *lj_tab_getstr(GCtab *t, GCstr *key); LJ_FUNCA cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key); /* Caveat: all setters require a write barrier for the stored value. */ LJ_FUNCA TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key); LJ_FUNC TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key); LJ_FUNC TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key); LJ_FUNC TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key); #define inarray(t, key) ((MSize)(key) < (MSize)(t)->asize) #define arrayslot(t, i) (&tvref((t)->array)[(i)]) #define lj_tab_getint(t, key) \ (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_getinth((t), (key))) #define lj_tab_setint(L, t, key) \ (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_setinth(L, (t), (key))) LJ_FUNCA int lj_tab_next(lua_State *L, GCtab *t, TValue *key); LJ_FUNCA MSize LJ_FASTCALL lj_tab_len(GCtab *t); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_target.h ================================================ /* ** Definitions for target CPU. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_TARGET_H #define _LJ_TARGET_H #include "lj_def.h" #include "lj_arch.h" /* -- Registers and spill slots ------------------------------------------- */ /* Register type (uint8_t in ir->r). */ typedef uint32_t Reg; /* The hi-bit is NOT set for an allocated register. This means the value ** can be directly used without masking. The hi-bit is set for a register ** allocation hint or for RID_INIT, RID_SINK or RID_SUNK. */ #define RID_NONE 0x80 #define RID_MASK 0x7f #define RID_INIT (RID_NONE|RID_MASK) #define RID_SINK (RID_INIT-1) #define RID_SUNK (RID_INIT-2) #define ra_noreg(r) ((r) & RID_NONE) #define ra_hasreg(r) (!((r) & RID_NONE)) /* The ra_hashint() macro assumes a previous test for ra_noreg(). */ #define ra_hashint(r) ((r) < RID_SUNK) #define ra_gethint(r) ((Reg)((r) & RID_MASK)) #define ra_sethint(rr, r) rr = (uint8_t)((r)|RID_NONE) #define ra_samehint(r1, r2) (ra_gethint((r1)^(r2)) == 0) /* Spill slot 0 means no spill slot has been allocated. */ #define SPS_NONE 0 #define ra_hasspill(s) ((s) != SPS_NONE) /* Combined register and spill slot (uint16_t in ir->prev). */ typedef uint32_t RegSP; #define REGSP(r, s) ((r) + ((s) << 8)) #define REGSP_HINT(r) ((r)|RID_NONE) #define REGSP_INIT REGSP(RID_INIT, 0) #define regsp_reg(rs) ((rs) & 255) #define regsp_spill(rs) ((rs) >> 8) #define regsp_used(rs) \ (((rs) & ~REGSP(RID_MASK, 0)) != REGSP(RID_NONE, 0)) /* -- Register sets ------------------------------------------------------- */ /* Bitset for registers. 32 registers suffice for most architectures. ** Note that one set holds bits for both GPRs and FPRs. */ #if LJ_TARGET_PPC || LJ_TARGET_MIPS typedef uint64_t RegSet; #else typedef uint32_t RegSet; #endif #define RID2RSET(r) (((RegSet)1) << (r)) #define RSET_EMPTY ((RegSet)0) #define RSET_RANGE(lo, hi) ((RID2RSET((hi)-(lo))-1) << (lo)) #define rset_test(rs, r) ((int)((rs) >> (r)) & 1) #define rset_set(rs, r) (rs |= RID2RSET(r)) #define rset_clear(rs, r) (rs &= ~RID2RSET(r)) #define rset_exclude(rs, r) (rs & ~RID2RSET(r)) #if LJ_TARGET_PPC || LJ_TARGET_MIPS #define rset_picktop(rs) ((Reg)(__builtin_clzll(rs)^63)) #define rset_pickbot(rs) ((Reg)__builtin_ctzll(rs)) #else #define rset_picktop(rs) ((Reg)lj_fls(rs)) #define rset_pickbot(rs) ((Reg)lj_ffs(rs)) #endif /* -- Register allocation cost -------------------------------------------- */ /* The register allocation heuristic keeps track of the cost for allocating ** a specific register: ** ** A free register (obviously) has a cost of 0 and a 1-bit in the free mask. ** ** An already allocated register has the (non-zero) IR reference in the lowest ** bits and the result of a blended cost-model in the higher bits. ** ** The allocator first checks the free mask for a hit. Otherwise an (unrolled) ** linear search for the minimum cost is used. The search doesn't need to ** keep track of the position of the minimum, which makes it very fast. ** The lowest bits of the minimum cost show the desired IR reference whose ** register is the one to evict. ** ** Without the cost-model this degenerates to the standard heuristics for ** (reverse) linear-scan register allocation. Since code generation is done ** in reverse, a live interval extends from the last use to the first def. ** For an SSA IR the IR reference is the first (and only) def and thus ** trivially marks the end of the interval. The LSRA heuristics says to pick ** the register whose live interval has the furthest extent, i.e. the lowest ** IR reference in our case. ** ** A cost-model should take into account other factors, like spill-cost and ** restore- or rematerialization-cost, which depend on the kind of instruction. ** E.g. constants have zero spill costs, variant instructions have higher ** costs than invariants and PHIs should preferably never be spilled. ** ** Here's a first cut at simple, but effective blended cost-model for R-LSRA: ** - Due to careful design of the IR, constants already have lower IR ** references than invariants and invariants have lower IR references ** than variants. ** - The cost in the upper 16 bits is the sum of the IR reference and a ** weighted score. The score currently only takes into account whether ** the IRT_ISPHI bit is set in the instruction type. ** - The PHI weight is the minimum distance (in IR instructions) a PHI ** reference has to be further apart from a non-PHI reference to be spilled. ** - It should be a power of two (for speed) and must be between 2 and 32768. ** Good values for the PHI weight seem to be between 40 and 150. ** - Further study is required. */ #define REGCOST_PHI_WEIGHT 64 /* Cost for allocating a specific register. */ typedef uint32_t RegCost; /* Note: assumes 16 bit IRRef1. */ #define REGCOST(cost, ref) ((RegCost)(ref) + ((RegCost)(cost) << 16)) #define regcost_ref(rc) ((IRRef1)(rc)) #define REGCOST_T(t) \ ((RegCost)((t)&IRT_ISPHI) * (((RegCost)(REGCOST_PHI_WEIGHT)<<16)/IRT_ISPHI)) #define REGCOST_REF_T(ref, t) (REGCOST((ref), (ref)) + REGCOST_T((t))) /* -- Target-specific definitions ----------------------------------------- */ #if LJ_TARGET_X86ORX64 #include "lj_target_x86.h" #elif LJ_TARGET_ARM #include "lj_target_arm.h" #elif LJ_TARGET_PPC #include "lj_target_ppc.h" #elif LJ_TARGET_MIPS #include "lj_target_mips.h" #else #error "Missing include for target CPU" #endif #ifdef EXITSTUBS_PER_GROUP /* Return the address of an exit stub. */ static LJ_AINLINE char *exitstub_addr_(char **group, uint32_t exitno) { lua_assert(group[exitno / EXITSTUBS_PER_GROUP] != NULL); return (char *)group[exitno / EXITSTUBS_PER_GROUP] + EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP); } /* Avoid dependence on lj_jit.h if only including lj_target.h. */ #define exitstub_addr(J, exitno) \ ((MCode *)exitstub_addr_((char **)((J)->exitstubgroup), (exitno))) #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_target_arm.h ================================================ /* ** Definitions for ARM CPUs. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_TARGET_ARM_H #define _LJ_TARGET_ARM_H /* -- Registers IDs ------------------------------------------------------- */ #define GPRDEF(_) \ _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ _(R8) _(R9) _(R10) _(R11) _(R12) _(SP) _(LR) _(PC) #if LJ_SOFTFP #define FPRDEF(_) #else #define FPRDEF(_) \ _(D0) _(D1) _(D2) _(D3) _(D4) _(D5) _(D6) _(D7) \ _(D8) _(D9) _(D10) _(D11) _(D12) _(D13) _(D14) _(D15) #endif #define VRIDDEF(_) #define RIDENUM(name) RID_##name, enum { GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ RID_MAX, RID_TMP = RID_LR, /* Calling conventions. */ RID_RET = RID_R0, RID_RETLO = RID_R0, RID_RETHI = RID_R1, #if LJ_SOFTFP RID_FPRET = RID_R0, #else RID_FPRET = RID_D0, #endif /* These definitions must match with the *.dasc file(s): */ RID_BASE = RID_R9, /* Interpreter BASE. */ RID_LPC = RID_R6, /* Interpreter PC. */ RID_DISPATCH = RID_R7, /* Interpreter DISPATCH table. */ RID_LREG = RID_R8, /* Interpreter L. */ /* Register ranges [min, max) and number of registers. */ RID_MIN_GPR = RID_R0, RID_MAX_GPR = RID_PC+1, RID_MIN_FPR = RID_MAX_GPR, #if LJ_SOFTFP RID_MAX_FPR = RID_MIN_FPR, #else RID_MAX_FPR = RID_D15+1, #endif RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR }; #define RID_NUM_KREF RID_NUM_GPR #define RID_MIN_KREF RID_R0 /* -- Register sets ------------------------------------------------------- */ /* Make use of all registers, except sp, lr and pc. */ #define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_R12+1)) #define RSET_GPREVEN \ (RID2RSET(RID_R0)|RID2RSET(RID_R2)|RID2RSET(RID_R4)|RID2RSET(RID_R6)| \ RID2RSET(RID_R8)|RID2RSET(RID_R10)) #define RSET_GPRODD \ (RID2RSET(RID_R1)|RID2RSET(RID_R3)|RID2RSET(RID_R5)|RID2RSET(RID_R7)| \ RID2RSET(RID_R9)|RID2RSET(RID_R11)) #if LJ_SOFTFP #define RSET_FPR 0 #else #define RSET_FPR (RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)) #endif #define RSET_ALL (RSET_GPR|RSET_FPR) #define RSET_INIT RSET_ALL /* ABI-specific register sets. lr is an implicit scratch register. */ #define RSET_SCRATCH_GPR_ (RSET_RANGE(RID_R0, RID_R3+1)|RID2RSET(RID_R12)) #ifdef __APPLE__ #define RSET_SCRATCH_GPR (RSET_SCRATCH_GPR_|RID2RSET(RID_R9)) #else #define RSET_SCRATCH_GPR RSET_SCRATCH_GPR_ #endif #if LJ_SOFTFP #define RSET_SCRATCH_FPR 0 #else #define RSET_SCRATCH_FPR (RSET_RANGE(RID_D0, RID_D7+1)) #endif #define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) #define REGARG_FIRSTGPR RID_R0 #define REGARG_LASTGPR RID_R3 #define REGARG_NUMGPR 4 #if LJ_ABI_SOFTFP #define REGARG_FIRSTFPR 0 #define REGARG_LASTFPR 0 #define REGARG_NUMFPR 0 #else #define REGARG_FIRSTFPR RID_D0 #define REGARG_LASTFPR RID_D7 #define REGARG_NUMFPR 8 #endif /* -- Spill slots --------------------------------------------------------- */ /* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. ** ** SPS_FIXED: Available fixed spill slots in interpreter frame. ** This definition must match with the *.dasc file(s). ** ** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots. */ #define SPS_FIXED 2 #define SPS_FIRST 2 #define SPOFS_TMP 0 #define sps_scale(slot) (4 * (int32_t)(slot)) #define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1) /* -- Exit state ---------------------------------------------------------- */ /* This definition must match with the *.dasc file(s). */ typedef struct { #if !LJ_SOFTFP lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ #endif int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ int32_t spill[256]; /* Spill slots. */ } ExitState; /* PC after instruction that caused an exit. Used to find the trace number. */ #define EXITSTATE_PCREG RID_PC /* Highest exit + 1 indicates stack check. */ #define EXITSTATE_CHECKEXIT 1 #define EXITSTUB_SPACING 4 #define EXITSTUBS_PER_GROUP 32 /* -- Instructions -------------------------------------------------------- */ /* Instruction fields. */ #define ARMF_CC(ai, cc) (((ai) ^ ARMI_CCAL) | ((cc) << 28)) #define ARMF_N(r) ((r) << 16) #define ARMF_D(r) ((r) << 12) #define ARMF_S(r) ((r) << 8) #define ARMF_M(r) (r) #define ARMF_SH(sh, n) (((sh) << 5) | ((n) << 7)) #define ARMF_RSH(sh, r) (0x10 | ((sh) << 5) | ARMF_S(r)) typedef enum ARMIns { ARMI_CCAL = 0xe0000000, ARMI_S = 0x000100000, ARMI_K12 = 0x02000000, ARMI_KNEG = 0x00200000, ARMI_LS_W = 0x00200000, ARMI_LS_U = 0x00800000, ARMI_LS_P = 0x01000000, ARMI_LS_R = 0x02000000, ARMI_LSX_I = 0x00400000, ARMI_AND = 0xe0000000, ARMI_EOR = 0xe0200000, ARMI_SUB = 0xe0400000, ARMI_RSB = 0xe0600000, ARMI_ADD = 0xe0800000, ARMI_ADC = 0xe0a00000, ARMI_SBC = 0xe0c00000, ARMI_RSC = 0xe0e00000, ARMI_TST = 0xe1100000, ARMI_TEQ = 0xe1300000, ARMI_CMP = 0xe1500000, ARMI_CMN = 0xe1700000, ARMI_ORR = 0xe1800000, ARMI_MOV = 0xe1a00000, ARMI_BIC = 0xe1c00000, ARMI_MVN = 0xe1e00000, ARMI_NOP = 0xe1a00000, ARMI_MUL = 0xe0000090, ARMI_SMULL = 0xe0c00090, ARMI_LDR = 0xe4100000, ARMI_LDRB = 0xe4500000, ARMI_LDRH = 0xe01000b0, ARMI_LDRSB = 0xe01000d0, ARMI_LDRSH = 0xe01000f0, ARMI_LDRD = 0xe00000d0, ARMI_STR = 0xe4000000, ARMI_STRB = 0xe4400000, ARMI_STRH = 0xe00000b0, ARMI_STRD = 0xe00000f0, ARMI_PUSH = 0xe92d0000, ARMI_B = 0xea000000, ARMI_BL = 0xeb000000, ARMI_BLX = 0xfa000000, ARMI_BLXr = 0xe12fff30, /* ARMv6 */ ARMI_REV = 0xe6bf0f30, ARMI_SXTB = 0xe6af0070, ARMI_SXTH = 0xe6bf0070, ARMI_UXTB = 0xe6ef0070, ARMI_UXTH = 0xe6ff0070, /* ARMv6T2 */ ARMI_MOVW = 0xe3000000, ARMI_MOVT = 0xe3400000, /* VFP */ ARMI_VMOV_D = 0xeeb00b40, ARMI_VMOV_S = 0xeeb00a40, ARMI_VMOVI_D = 0xeeb00b00, ARMI_VMOV_R_S = 0xee100a10, ARMI_VMOV_S_R = 0xee000a10, ARMI_VMOV_RR_D = 0xec500b10, ARMI_VMOV_D_RR = 0xec400b10, ARMI_VADD_D = 0xee300b00, ARMI_VSUB_D = 0xee300b40, ARMI_VMUL_D = 0xee200b00, ARMI_VMLA_D = 0xee000b00, ARMI_VMLS_D = 0xee000b40, ARMI_VNMLS_D = 0xee100b00, ARMI_VDIV_D = 0xee800b00, ARMI_VABS_D = 0xeeb00bc0, ARMI_VNEG_D = 0xeeb10b40, ARMI_VSQRT_D = 0xeeb10bc0, ARMI_VCMP_D = 0xeeb40b40, ARMI_VCMPZ_D = 0xeeb50b40, ARMI_VMRS = 0xeef1fa10, ARMI_VCVT_S32_F32 = 0xeebd0ac0, ARMI_VCVT_S32_F64 = 0xeebd0bc0, ARMI_VCVT_U32_F32 = 0xeebc0ac0, ARMI_VCVT_U32_F64 = 0xeebc0bc0, ARMI_VCVTR_S32_F32 = 0xeebd0a40, ARMI_VCVTR_S32_F64 = 0xeebd0b40, ARMI_VCVTR_U32_F32 = 0xeebc0a40, ARMI_VCVTR_U32_F64 = 0xeebc0b40, ARMI_VCVT_F32_S32 = 0xeeb80ac0, ARMI_VCVT_F64_S32 = 0xeeb80bc0, ARMI_VCVT_F32_U32 = 0xeeb80a40, ARMI_VCVT_F64_U32 = 0xeeb80b40, ARMI_VCVT_F32_F64 = 0xeeb70bc0, ARMI_VCVT_F64_F32 = 0xeeb70ac0, ARMI_VLDR_S = 0xed100a00, ARMI_VLDR_D = 0xed100b00, ARMI_VSTR_S = 0xed000a00, ARMI_VSTR_D = 0xed000b00, } ARMIns; typedef enum ARMShift { ARMSH_LSL, ARMSH_LSR, ARMSH_ASR, ARMSH_ROR } ARMShift; /* ARM condition codes. */ typedef enum ARMCC { CC_EQ, CC_NE, CC_CS, CC_CC, CC_MI, CC_PL, CC_VS, CC_VC, CC_HI, CC_LS, CC_GE, CC_LT, CC_GT, CC_LE, CC_AL, CC_HS = CC_CS, CC_LO = CC_CC } ARMCC; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_target_mips.h ================================================ /* ** Definitions for MIPS CPUs. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_TARGET_MIPS_H #define _LJ_TARGET_MIPS_H /* -- Registers IDs ------------------------------------------------------- */ #define GPRDEF(_) \ _(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \ _(R8) _(R9) _(R10) _(R11) _(R12) _(R13) _(R14) _(R15) \ _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ _(R24) _(R25) _(SYS1) _(SYS2) _(R28) _(SP) _(R30) _(RA) #define FPRDEF(_) \ _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ _(F16) _(F17) _(F18) _(F19) _(F20) _(F21) _(F22) _(F23) \ _(F24) _(F25) _(F26) _(F27) _(F28) _(F29) _(F30) _(F31) #define VRIDDEF(_) #define RIDENUM(name) RID_##name, enum { GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ RID_MAX, RID_ZERO = RID_R0, RID_TMP = RID_RA, /* Calling conventions. */ RID_RET = RID_R2, #if LJ_LE RID_RETHI = RID_R3, RID_RETLO = RID_R2, #else RID_RETHI = RID_R2, RID_RETLO = RID_R3, #endif RID_FPRET = RID_F0, RID_CFUNCADDR = RID_R25, /* These definitions must match with the *.dasc file(s): */ RID_BASE = RID_R16, /* Interpreter BASE. */ RID_LPC = RID_R18, /* Interpreter PC. */ RID_DISPATCH = RID_R19, /* Interpreter DISPATCH table. */ RID_LREG = RID_R20, /* Interpreter L. */ RID_JGL = RID_R30, /* On-trace: global_State + 32768. */ /* Register ranges [min, max) and number of registers. */ RID_MIN_GPR = RID_R0, RID_MAX_GPR = RID_RA+1, RID_MIN_FPR = RID_F0, RID_MAX_FPR = RID_F31+1, RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR /* Only even regs are used. */ }; #define RID_NUM_KREF RID_NUM_GPR #define RID_MIN_KREF RID_R0 /* -- Register sets ------------------------------------------------------- */ /* Make use of all registers, except ZERO, TMP, SP, SYS1, SYS2 and JGL. */ #define RSET_FIXED \ (RID2RSET(RID_ZERO)|RID2RSET(RID_TMP)|RID2RSET(RID_SP)|\ RID2RSET(RID_SYS1)|RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)) #define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) #define RSET_FPR \ (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ RID2RSET(RID_F16)|RID2RSET(RID_F18)|RID2RSET(RID_F20)|RID2RSET(RID_F22)|\ RID2RSET(RID_F24)|RID2RSET(RID_F26)|RID2RSET(RID_F28)|RID2RSET(RID_F30)) #define RSET_ALL (RSET_GPR|RSET_FPR) #define RSET_INIT RSET_ALL #define RSET_SCRATCH_GPR \ (RSET_RANGE(RID_R1, RID_R15+1)|\ RID2RSET(RID_R24)|RID2RSET(RID_R25)|RID2RSET(RID_R28)) #define RSET_SCRATCH_FPR \ (RID2RSET(RID_F0)|RID2RSET(RID_F2)|RID2RSET(RID_F4)|RID2RSET(RID_F6)|\ RID2RSET(RID_F8)|RID2RSET(RID_F10)|RID2RSET(RID_F12)|RID2RSET(RID_F14)|\ RID2RSET(RID_F16)|RID2RSET(RID_F18)) #define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) #define REGARG_FIRSTGPR RID_R4 #define REGARG_LASTGPR RID_R7 #define REGARG_NUMGPR 4 #define REGARG_FIRSTFPR RID_F12 #define REGARG_LASTFPR RID_F14 #define REGARG_NUMFPR 2 /* -- Spill slots --------------------------------------------------------- */ /* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. ** ** SPS_FIXED: Available fixed spill slots in interpreter frame. ** This definition must match with the *.dasc file(s). ** ** SPS_FIRST: First spill slot for general use. */ #define SPS_FIXED 5 #define SPS_FIRST 4 #define SPOFS_TMP 0 #define sps_scale(slot) (4 * (int32_t)(slot)) #define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1) /* -- Exit state ---------------------------------------------------------- */ /* This definition must match with the *.dasc file(s). */ typedef struct { lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ int32_t spill[256]; /* Spill slots. */ } ExitState; /* Highest exit + 1 indicates stack check. */ #define EXITSTATE_CHECKEXIT 1 /* Return the address of a per-trace exit stub. */ static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p) { while (*p == 0x00000000) p++; /* Skip MIPSI_NOP. */ return p; } /* Avoid dependence on lj_jit.h if only including lj_target.h. */ #define exitstub_trace_addr(T, exitno) \ exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode)) /* -- Instructions -------------------------------------------------------- */ /* Instruction fields. */ #define MIPSF_S(r) ((r) << 21) #define MIPSF_T(r) ((r) << 16) #define MIPSF_D(r) ((r) << 11) #define MIPSF_R(r) ((r) << 21) #define MIPSF_H(r) ((r) << 16) #define MIPSF_G(r) ((r) << 11) #define MIPSF_F(r) ((r) << 6) #define MIPSF_A(n) ((n) << 6) #define MIPSF_M(n) ((n) << 11) typedef enum MIPSIns { /* Integer instructions. */ MIPSI_MOVE = 0x00000021, MIPSI_NOP = 0x00000000, MIPSI_LI = 0x24000000, MIPSI_LU = 0x34000000, MIPSI_LUI = 0x3c000000, MIPSI_ADDIU = 0x24000000, MIPSI_ANDI = 0x30000000, MIPSI_ORI = 0x34000000, MIPSI_XORI = 0x38000000, MIPSI_SLTI = 0x28000000, MIPSI_SLTIU = 0x2c000000, MIPSI_ADDU = 0x00000021, MIPSI_SUBU = 0x00000023, MIPSI_MUL = 0x70000002, MIPSI_AND = 0x00000024, MIPSI_OR = 0x00000025, MIPSI_XOR = 0x00000026, MIPSI_NOR = 0x00000027, MIPSI_SLT = 0x0000002a, MIPSI_SLTU = 0x0000002b, MIPSI_MOVZ = 0x0000000a, MIPSI_MOVN = 0x0000000b, MIPSI_SLL = 0x00000000, MIPSI_SRL = 0x00000002, MIPSI_SRA = 0x00000003, MIPSI_ROTR = 0x00200002, /* MIPS32R2 */ MIPSI_SLLV = 0x00000004, MIPSI_SRLV = 0x00000006, MIPSI_SRAV = 0x00000007, MIPSI_ROTRV = 0x00000046, /* MIPS32R2 */ MIPSI_SEB = 0x7c000420, /* MIPS32R2 */ MIPSI_SEH = 0x7c000620, /* MIPS32R2 */ MIPSI_WSBH = 0x7c0000a0, /* MIPS32R2 */ MIPSI_B = 0x10000000, MIPSI_J = 0x08000000, MIPSI_JAL = 0x0c000000, MIPSI_JR = 0x00000008, MIPSI_JALR = 0x0000f809, MIPSI_BEQ = 0x10000000, MIPSI_BNE = 0x14000000, MIPSI_BLEZ = 0x18000000, MIPSI_BGTZ = 0x1c000000, MIPSI_BLTZ = 0x04000000, MIPSI_BGEZ = 0x04010000, /* Load/store instructions. */ MIPSI_LW = 0x8c000000, MIPSI_SW = 0xac000000, MIPSI_LB = 0x80000000, MIPSI_SB = 0xa0000000, MIPSI_LH = 0x84000000, MIPSI_SH = 0xa4000000, MIPSI_LBU = 0x90000000, MIPSI_LHU = 0x94000000, MIPSI_LWC1 = 0xc4000000, MIPSI_SWC1 = 0xe4000000, MIPSI_LDC1 = 0xd4000000, MIPSI_SDC1 = 0xf4000000, /* FP instructions. */ MIPSI_MOV_S = 0x46000006, MIPSI_MOV_D = 0x46200006, MIPSI_MOVT_D = 0x46210011, MIPSI_MOVF_D = 0x46200011, MIPSI_ABS_D = 0x46200005, MIPSI_NEG_D = 0x46200007, MIPSI_ADD_D = 0x46200000, MIPSI_SUB_D = 0x46200001, MIPSI_MUL_D = 0x46200002, MIPSI_DIV_D = 0x46200003, MIPSI_SQRT_D = 0x46200004, MIPSI_ADD_S = 0x46000000, MIPSI_SUB_S = 0x46000001, MIPSI_CVT_D_S = 0x46000021, MIPSI_CVT_W_S = 0x46000024, MIPSI_CVT_S_D = 0x46200020, MIPSI_CVT_W_D = 0x46200024, MIPSI_CVT_S_W = 0x46800020, MIPSI_CVT_D_W = 0x46800021, MIPSI_TRUNC_W_S = 0x4600000d, MIPSI_TRUNC_W_D = 0x4620000d, MIPSI_FLOOR_W_S = 0x4600000f, MIPSI_FLOOR_W_D = 0x4620000f, MIPSI_MFC1 = 0x44000000, MIPSI_MTC1 = 0x44800000, MIPSI_BC1F = 0x45000000, MIPSI_BC1T = 0x45010000, MIPSI_C_EQ_D = 0x46200032, MIPSI_C_OLT_D = 0x46200034, MIPSI_C_ULT_D = 0x46200035, MIPSI_C_OLE_D = 0x46200036, MIPSI_C_ULE_D = 0x46200037, } MIPSIns; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_target_ppc.h ================================================ /* ** Definitions for PPC CPUs. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_TARGET_PPC_H #define _LJ_TARGET_PPC_H /* -- Registers IDs ------------------------------------------------------- */ #define GPRDEF(_) \ _(R0) _(SP) _(SYS1) _(R3) _(R4) _(R5) _(R6) _(R7) \ _(R8) _(R9) _(R10) _(R11) _(R12) _(SYS2) _(R14) _(R15) \ _(R16) _(R17) _(R18) _(R19) _(R20) _(R21) _(R22) _(R23) \ _(R24) _(R25) _(R26) _(R27) _(R28) _(R29) _(R30) _(R31) #define FPRDEF(_) \ _(F0) _(F1) _(F2) _(F3) _(F4) _(F5) _(F6) _(F7) \ _(F8) _(F9) _(F10) _(F11) _(F12) _(F13) _(F14) _(F15) \ _(F16) _(F17) _(F18) _(F19) _(F20) _(F21) _(F22) _(F23) \ _(F24) _(F25) _(F26) _(F27) _(F28) _(F29) _(F30) _(F31) #define VRIDDEF(_) #define RIDENUM(name) RID_##name, enum { GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ RID_MAX, RID_TMP = RID_R0, /* Calling conventions. */ RID_RET = RID_R3, RID_RETHI = RID_R3, RID_RETLO = RID_R4, RID_FPRET = RID_F1, /* These definitions must match with the *.dasc file(s): */ RID_BASE = RID_R14, /* Interpreter BASE. */ RID_LPC = RID_R16, /* Interpreter PC. */ RID_DISPATCH = RID_R17, /* Interpreter DISPATCH table. */ RID_LREG = RID_R18, /* Interpreter L. */ RID_JGL = RID_R31, /* On-trace: global_State + 32768. */ /* Register ranges [min, max) and number of registers. */ RID_MIN_GPR = RID_R0, RID_MAX_GPR = RID_R31+1, RID_MIN_FPR = RID_F0, RID_MAX_FPR = RID_F31+1, RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR }; #define RID_NUM_KREF RID_NUM_GPR #define RID_MIN_KREF RID_R0 /* -- Register sets ------------------------------------------------------- */ /* Make use of all registers, except TMP, SP, SYS1, SYS2 and JGL. */ #define RSET_FIXED \ (RID2RSET(RID_TMP)|RID2RSET(RID_SP)|RID2RSET(RID_SYS1)|\ RID2RSET(RID_SYS2)|RID2RSET(RID_JGL)) #define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED) #define RSET_FPR RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR) #define RSET_ALL (RSET_GPR|RSET_FPR) #define RSET_INIT RSET_ALL #define RSET_SCRATCH_GPR (RSET_RANGE(RID_R3, RID_R12+1)) #define RSET_SCRATCH_FPR (RSET_RANGE(RID_F0, RID_F13+1)) #define RSET_SCRATCH (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR) #define REGARG_FIRSTGPR RID_R3 #define REGARG_LASTGPR RID_R10 #define REGARG_NUMGPR 8 #define REGARG_FIRSTFPR RID_F1 #define REGARG_LASTFPR RID_F8 #define REGARG_NUMFPR 8 /* -- Spill slots --------------------------------------------------------- */ /* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. ** ** SPS_FIXED: Available fixed spill slots in interpreter frame. ** This definition must match with the *.dasc file(s). ** ** SPS_FIRST: First spill slot for general use. ** [sp+12] tmplo word \ ** [sp+ 8] tmphi word / tmp dword, parameter area for callee ** [sp+ 4] tmpw, LR of callee ** [sp+ 0] stack chain */ #define SPS_FIXED 7 #define SPS_FIRST 4 /* Stack offsets for temporary slots. Used for FP<->int conversions etc. */ #define SPOFS_TMPW 4 #define SPOFS_TMP 8 #define SPOFS_TMPHI 8 #define SPOFS_TMPLO 12 #define sps_scale(slot) (4 * (int32_t)(slot)) #define sps_align(slot) (((slot) - SPS_FIXED + 3) & ~3) /* -- Exit state ---------------------------------------------------------- */ /* This definition must match with the *.dasc file(s). */ typedef struct { lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ int32_t spill[256]; /* Spill slots. */ } ExitState; /* Highest exit + 1 indicates stack check. */ #define EXITSTATE_CHECKEXIT 1 /* Return the address of a per-trace exit stub. */ static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p, uint32_t exitno) { while (*p == 0x60000000) p++; /* Skip PPCI_NOP. */ return p + 3 + exitno; } /* Avoid dependence on lj_jit.h if only including lj_target.h. */ #define exitstub_trace_addr(T, exitno) \ exitstub_trace_addr_((MCode *)((char *)(T)->mcode + (T)->szmcode), (exitno)) /* -- Instructions -------------------------------------------------------- */ /* Instruction fields. */ #define PPCF_CC(cc) ((((cc) & 3) << 16) | (((cc) & 4) << 22)) #define PPCF_T(r) ((r) << 21) #define PPCF_A(r) ((r) << 16) #define PPCF_B(r) ((r) << 11) #define PPCF_C(r) ((r) << 6) #define PPCF_MB(n) ((n) << 6) #define PPCF_ME(n) ((n) << 1) #define PPCF_Y 0x00200000 #define PPCF_DOT 0x00000001 typedef enum PPCIns { /* Integer instructions. */ PPCI_MR = 0x7c000378, PPCI_NOP = 0x60000000, PPCI_LI = 0x38000000, PPCI_LIS = 0x3c000000, PPCI_ADD = 0x7c000214, PPCI_ADDC = 0x7c000014, PPCI_ADDO = 0x7c000614, PPCI_ADDE = 0x7c000114, PPCI_ADDZE = 0x7c000194, PPCI_ADDME = 0x7c0001d4, PPCI_ADDI = 0x38000000, PPCI_ADDIS = 0x3c000000, PPCI_ADDIC = 0x30000000, PPCI_ADDICDOT = 0x34000000, PPCI_SUBF = 0x7c000050, PPCI_SUBFC = 0x7c000010, PPCI_SUBFO = 0x7c000450, PPCI_SUBFE = 0x7c000110, PPCI_SUBFZE = 0x7c000190, PPCI_SUBFME = 0x7c0001d0, PPCI_SUBFIC = 0x20000000, PPCI_NEG = 0x7c0000d0, PPCI_AND = 0x7c000038, PPCI_ANDC = 0x7c000078, PPCI_NAND = 0x7c0003b8, PPCI_ANDIDOT = 0x70000000, PPCI_ANDISDOT = 0x74000000, PPCI_OR = 0x7c000378, PPCI_NOR = 0x7c0000f8, PPCI_ORI = 0x60000000, PPCI_ORIS = 0x64000000, PPCI_XOR = 0x7c000278, PPCI_EQV = 0x7c000238, PPCI_XORI = 0x68000000, PPCI_XORIS = 0x6c000000, PPCI_CMPW = 0x7c000000, PPCI_CMPLW = 0x7c000040, PPCI_CMPWI = 0x2c000000, PPCI_CMPLWI = 0x28000000, PPCI_MULLW = 0x7c0001d6, PPCI_MULLI = 0x1c000000, PPCI_MULLWO = 0x7c0005d6, PPCI_EXTSB = 0x7c000774, PPCI_EXTSH = 0x7c000734, PPCI_SLW = 0x7c000030, PPCI_SRW = 0x7c000430, PPCI_SRAW = 0x7c000630, PPCI_SRAWI = 0x7c000670, PPCI_RLWNM = 0x5c000000, PPCI_RLWINM = 0x54000000, PPCI_RLWIMI = 0x50000000, PPCI_B = 0x48000000, PPCI_BL = 0x48000001, PPCI_BC = 0x40800000, PPCI_BCL = 0x40800001, PPCI_BCTR = 0x4e800420, PPCI_BCTRL = 0x4e800421, PPCI_CRANDC = 0x4c000102, PPCI_CRXOR = 0x4c000182, PPCI_CRAND = 0x4c000202, PPCI_CREQV = 0x4c000242, PPCI_CRORC = 0x4c000342, PPCI_CROR = 0x4c000382, PPCI_MFLR = 0x7c0802a6, PPCI_MTCTR = 0x7c0903a6, PPCI_MCRXR = 0x7c000400, /* Load/store instructions. */ PPCI_LWZ = 0x80000000, PPCI_LBZ = 0x88000000, PPCI_STW = 0x90000000, PPCI_STB = 0x98000000, PPCI_LHZ = 0xa0000000, PPCI_LHA = 0xa8000000, PPCI_STH = 0xb0000000, PPCI_STWU = 0x94000000, PPCI_LFS = 0xc0000000, PPCI_LFD = 0xc8000000, PPCI_STFS = 0xd0000000, PPCI_STFD = 0xd8000000, PPCI_LWZX = 0x7c00002e, PPCI_LBZX = 0x7c0000ae, PPCI_STWX = 0x7c00012e, PPCI_STBX = 0x7c0001ae, PPCI_LHZX = 0x7c00022e, PPCI_LHAX = 0x7c0002ae, PPCI_STHX = 0x7c00032e, PPCI_LWBRX = 0x7c00042c, PPCI_STWBRX = 0x7c00052c, PPCI_LFSX = 0x7c00042e, PPCI_LFDX = 0x7c0004ae, PPCI_STFSX = 0x7c00052e, PPCI_STFDX = 0x7c0005ae, /* FP instructions. */ PPCI_FMR = 0xfc000090, PPCI_FNEG = 0xfc000050, PPCI_FABS = 0xfc000210, PPCI_FRSP = 0xfc000018, PPCI_FCTIWZ = 0xfc00001e, PPCI_FADD = 0xfc00002a, PPCI_FSUB = 0xfc000028, PPCI_FMUL = 0xfc000032, PPCI_FDIV = 0xfc000024, PPCI_FSQRT = 0xfc00002c, PPCI_FMADD = 0xfc00003a, PPCI_FMSUB = 0xfc000038, PPCI_FNMSUB = 0xfc00003c, PPCI_FCMPU = 0xfc000000, PPCI_FSEL = 0xfc00002e, } PPCIns; typedef enum PPCCC { CC_GE, CC_LE, CC_NE, CC_NS, CC_LT, CC_GT, CC_EQ, CC_SO } PPCCC; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_target_x86.h ================================================ /* ** Definitions for x86 and x64 CPUs. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_TARGET_X86_H #define _LJ_TARGET_X86_H /* -- Registers IDs ------------------------------------------------------- */ #if LJ_64 #define GPRDEF(_) \ _(EAX) _(ECX) _(EDX) _(EBX) _(ESP) _(EBP) _(ESI) _(EDI) \ _(R8D) _(R9D) _(R10D) _(R11D) _(R12D) _(R13D) _(R14D) _(R15D) #define FPRDEF(_) \ _(XMM0) _(XMM1) _(XMM2) _(XMM3) _(XMM4) _(XMM5) _(XMM6) _(XMM7) \ _(XMM8) _(XMM9) _(XMM10) _(XMM11) _(XMM12) _(XMM13) _(XMM14) _(XMM15) #else #define GPRDEF(_) \ _(EAX) _(ECX) _(EDX) _(EBX) _(ESP) _(EBP) _(ESI) _(EDI) #define FPRDEF(_) \ _(XMM0) _(XMM1) _(XMM2) _(XMM3) _(XMM4) _(XMM5) _(XMM6) _(XMM7) #endif #define VRIDDEF(_) \ _(MRM) #define RIDENUM(name) RID_##name, enum { GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */ FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */ RID_MAX, RID_MRM = RID_MAX, /* Pseudo-id for ModRM operand. */ /* Calling conventions. */ RID_RET = RID_EAX, #if LJ_64 RID_FPRET = RID_XMM0, #else RID_RETLO = RID_EAX, RID_RETHI = RID_EDX, #endif /* These definitions must match with the *.dasc file(s): */ RID_BASE = RID_EDX, /* Interpreter BASE. */ #if LJ_64 && !LJ_ABI_WIN RID_LPC = RID_EBX, /* Interpreter PC. */ RID_DISPATCH = RID_R14D, /* Interpreter DISPATCH table. */ #else RID_LPC = RID_ESI, /* Interpreter PC. */ RID_DISPATCH = RID_EBX, /* Interpreter DISPATCH table. */ #endif /* Register ranges [min, max) and number of registers. */ RID_MIN_GPR = RID_EAX, RID_MIN_FPR = RID_XMM0, RID_MAX_GPR = RID_MIN_FPR, RID_MAX_FPR = RID_MAX, RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR, RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR, }; /* -- Register sets ------------------------------------------------------- */ /* Make use of all registers, except the stack pointer. */ #define RSET_GPR (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR)-RID2RSET(RID_ESP)) #define RSET_FPR (RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)) #define RSET_ALL (RSET_GPR|RSET_FPR) #define RSET_INIT RSET_ALL #if LJ_64 /* Note: this requires the use of FORCE_REX! */ #define RSET_GPR8 RSET_GPR #else #define RSET_GPR8 (RSET_RANGE(RID_EAX, RID_EBX+1)) #endif /* ABI-specific register sets. */ #define RSET_ACD (RID2RSET(RID_EAX)|RID2RSET(RID_ECX)|RID2RSET(RID_EDX)) #if LJ_64 #if LJ_ABI_WIN /* Windows x64 ABI. */ #define RSET_SCRATCH \ (RSET_ACD|RSET_RANGE(RID_R8D, RID_R11D+1)|RSET_RANGE(RID_XMM0, RID_XMM5+1)) #define REGARG_GPRS \ (RID_ECX|((RID_EDX|((RID_R8D|(RID_R9D<<5))<<5))<<5)) #define REGARG_NUMGPR 4 #define REGARG_NUMFPR 4 #define REGARG_FIRSTFPR RID_XMM0 #define REGARG_LASTFPR RID_XMM3 #define STACKARG_OFS (4*8) #else /* The rest of the civilized x64 world has a common ABI. */ #define RSET_SCRATCH \ (RSET_ACD|RSET_RANGE(RID_ESI, RID_R11D+1)|RSET_FPR) #define REGARG_GPRS \ (RID_EDI|((RID_ESI|((RID_EDX|((RID_ECX|((RID_R8D|(RID_R9D \ <<5))<<5))<<5))<<5))<<5)) #define REGARG_NUMGPR 6 #define REGARG_NUMFPR 8 #define REGARG_FIRSTFPR RID_XMM0 #define REGARG_LASTFPR RID_XMM7 #define STACKARG_OFS 0 #endif #else /* Common x86 ABI. */ #define RSET_SCRATCH (RSET_ACD|RSET_FPR) #define REGARG_GPRS (RID_ECX|(RID_EDX<<5)) /* Fastcall only. */ #define REGARG_NUMGPR 2 /* Fastcall only. */ #define REGARG_NUMFPR 0 #define STACKARG_OFS 0 #endif #if LJ_64 /* Prefer the low 8 regs of each type to reduce REX prefixes. */ #undef rset_picktop #define rset_picktop(rs) (lj_fls(lj_bswap(rs)) ^ 0x18) #endif /* -- Spill slots --------------------------------------------------------- */ /* Spill slots are 32 bit wide. An even/odd pair is used for FPRs. ** ** SPS_FIXED: Available fixed spill slots in interpreter frame. ** This definition must match with the *.dasc file(s). ** ** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots. */ #if LJ_64 #if LJ_ABI_WIN #define SPS_FIXED (4*2) #define SPS_FIRST (4*2) /* Don't use callee register save area. */ #else #define SPS_FIXED 4 #define SPS_FIRST 2 #endif #else #define SPS_FIXED 6 #define SPS_FIRST 2 #endif #define SPOFS_TMP 0 #define sps_scale(slot) (4 * (int32_t)(slot)) #define sps_align(slot) (((slot) - SPS_FIXED + 3) & ~3) /* -- Exit state ---------------------------------------------------------- */ /* This definition must match with the *.dasc file(s). */ typedef struct { lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */ intptr_t gpr[RID_NUM_GPR]; /* General-purpose registers. */ int32_t spill[256]; /* Spill slots. */ } ExitState; /* Limited by the range of a short fwd jump (127): (2+2)*(32-1)-2 = 122. */ #define EXITSTUB_SPACING (2+2) #define EXITSTUBS_PER_GROUP 32 /* -- x86 ModRM operand encoding ------------------------------------------ */ typedef enum { XM_OFS0 = 0x00, XM_OFS8 = 0x40, XM_OFS32 = 0x80, XM_REG = 0xc0, XM_SCALE1 = 0x00, XM_SCALE2 = 0x40, XM_SCALE4 = 0x80, XM_SCALE8 = 0xc0, XM_MASK = 0xc0 } x86Mode; /* Structure to hold variable ModRM operand. */ typedef struct { int32_t ofs; /* Offset. */ uint8_t base; /* Base register or RID_NONE. */ uint8_t idx; /* Index register or RID_NONE. */ uint8_t scale; /* Index scale (XM_SCALE1 .. XM_SCALE8). */ } x86ModRM; /* -- Opcodes ------------------------------------------------------------- */ /* Macros to construct variable-length x86 opcodes. -(len+1) is in LSB. */ #define XO_(o) ((uint32_t)(0x0000fe + (0x##o<<24))) #define XO_FPU(a,b) ((uint32_t)(0x00fd + (0x##a<<16)+(0x##b<<24))) #define XO_0f(o) ((uint32_t)(0x0f00fd + (0x##o<<24))) #define XO_66(o) ((uint32_t)(0x6600fd + (0x##o<<24))) #define XO_660f(o) ((uint32_t)(0x0f66fc + (0x##o<<24))) #define XO_f20f(o) ((uint32_t)(0x0ff2fc + (0x##o<<24))) #define XO_f30f(o) ((uint32_t)(0x0ff3fc + (0x##o<<24))) /* This list of x86 opcodes is not intended to be complete. Opcodes are only ** included when needed. Take a look at DynASM or jit.dis_x86 to see the ** whole mess. */ typedef enum { /* Fixed length opcodes. XI_* prefix. */ XI_NOP = 0x90, XI_XCHGa = 0x90, XI_CALL = 0xe8, XI_JMP = 0xe9, XI_JMPs = 0xeb, XI_PUSH = 0x50, /* Really 50+r. */ XI_JCCs = 0x70, /* Really 7x. */ XI_JCCn = 0x80, /* Really 0f8x. */ XI_LEA = 0x8d, XI_MOVrib = 0xb0, /* Really b0+r. */ XI_MOVri = 0xb8, /* Really b8+r. */ XI_ARITHib = 0x80, XI_ARITHi = 0x81, XI_ARITHi8 = 0x83, XI_PUSHi8 = 0x6a, XI_TESTb = 0x84, XI_TEST = 0x85, XI_MOVmi = 0xc7, XI_GROUP5 = 0xff, /* Note: little-endian byte-order! */ XI_FLDZ = 0xeed9, XI_FLD1 = 0xe8d9, XI_FLDLG2 = 0xecd9, XI_FLDLN2 = 0xedd9, XI_FDUP = 0xc0d9, /* Really fld st0. */ XI_FPOP = 0xd8dd, /* Really fstp st0. */ XI_FPOP1 = 0xd9dd, /* Really fstp st1. */ XI_FRNDINT = 0xfcd9, XI_FSIN = 0xfed9, XI_FCOS = 0xffd9, XI_FPTAN = 0xf2d9, XI_FPATAN = 0xf3d9, XI_FSCALE = 0xfdd9, XI_FYL2X = 0xf1d9, /* Variable-length opcodes. XO_* prefix. */ XO_MOV = XO_(8b), XO_MOVto = XO_(89), XO_MOVtow = XO_66(89), XO_MOVtob = XO_(88), XO_MOVmi = XO_(c7), XO_MOVmib = XO_(c6), XO_LEA = XO_(8d), XO_ARITHib = XO_(80), XO_ARITHi = XO_(81), XO_ARITHi8 = XO_(83), XO_ARITHiw8 = XO_66(83), XO_SHIFTi = XO_(c1), XO_SHIFT1 = XO_(d1), XO_SHIFTcl = XO_(d3), XO_IMUL = XO_0f(af), XO_IMULi = XO_(69), XO_IMULi8 = XO_(6b), XO_CMP = XO_(3b), XO_TESTb = XO_(84), XO_TEST = XO_(85), XO_GROUP3b = XO_(f6), XO_GROUP3 = XO_(f7), XO_GROUP5b = XO_(fe), XO_GROUP5 = XO_(ff), XO_MOVZXb = XO_0f(b6), XO_MOVZXw = XO_0f(b7), XO_MOVSXb = XO_0f(be), XO_MOVSXw = XO_0f(bf), XO_MOVSXd = XO_(63), XO_BSWAP = XO_0f(c8), XO_CMOV = XO_0f(40), XO_MOVSD = XO_f20f(10), XO_MOVSDto = XO_f20f(11), XO_MOVSS = XO_f30f(10), XO_MOVSSto = XO_f30f(11), XO_MOVLPD = XO_660f(12), XO_MOVAPS = XO_0f(28), XO_XORPS = XO_0f(57), XO_ANDPS = XO_0f(54), XO_ADDSD = XO_f20f(58), XO_SUBSD = XO_f20f(5c), XO_MULSD = XO_f20f(59), XO_DIVSD = XO_f20f(5e), XO_SQRTSD = XO_f20f(51), XO_MINSD = XO_f20f(5d), XO_MAXSD = XO_f20f(5f), XO_ROUNDSD = 0x0b3a0ffc, /* Really 66 0f 3a 0b. See asm_fpmath. */ XO_UCOMISD = XO_660f(2e), XO_CVTSI2SD = XO_f20f(2a), XO_CVTSD2SI = XO_f20f(2d), XO_CVTTSD2SI= XO_f20f(2c), XO_CVTSI2SS = XO_f30f(2a), XO_CVTSS2SI = XO_f30f(2d), XO_CVTTSS2SI= XO_f30f(2c), XO_CVTSS2SD = XO_f30f(5a), XO_CVTSD2SS = XO_f20f(5a), XO_ADDSS = XO_f30f(58), XO_MOVD = XO_660f(6e), XO_MOVDto = XO_660f(7e), XO_FLDd = XO_(d9), XOg_FLDd = 0, XO_FLDq = XO_(dd), XOg_FLDq = 0, XO_FILDd = XO_(db), XOg_FILDd = 0, XO_FILDq = XO_(df), XOg_FILDq = 5, XO_FSTPd = XO_(d9), XOg_FSTPd = 3, XO_FSTPq = XO_(dd), XOg_FSTPq = 3, XO_FISTPq = XO_(df), XOg_FISTPq = 7, XO_FISTTPq = XO_(dd), XOg_FISTTPq = 1, XO_FADDq = XO_(dc), XOg_FADDq = 0, XO_FLDCW = XO_(d9), XOg_FLDCW = 5, XO_FNSTCW = XO_(d9), XOg_FNSTCW = 7 } x86Op; /* x86 opcode groups. */ typedef uint32_t x86Group; #define XG_(i8, i, g) ((x86Group)(((i8) << 16) + ((i) << 8) + (g))) #define XG_ARITHi(g) XG_(XI_ARITHi8, XI_ARITHi, g) #define XG_TOXOi(xg) ((x86Op)(0x000000fe + (((xg)<<16) & 0xff000000))) #define XG_TOXOi8(xg) ((x86Op)(0x000000fe + (((xg)<<8) & 0xff000000))) #define XO_ARITH(a) ((x86Op)(0x030000fe + ((a)<<27))) #define XO_ARITHw(a) ((x86Op)(0x036600fd + ((a)<<27))) typedef enum { XOg_ADD, XOg_OR, XOg_ADC, XOg_SBB, XOg_AND, XOg_SUB, XOg_XOR, XOg_CMP, XOg_X_IMUL } x86Arith; typedef enum { XOg_ROL, XOg_ROR, XOg_RCL, XOg_RCR, XOg_SHL, XOg_SHR, XOg_SAL, XOg_SAR } x86Shift; typedef enum { XOg_TEST, XOg_TEST_, XOg_NOT, XOg_NEG, XOg_MUL, XOg_IMUL, XOg_DIV, XOg_IDIV } x86Group3; typedef enum { XOg_INC, XOg_DEC, XOg_CALL, XOg_CALLfar, XOg_JMP, XOg_JMPfar, XOg_PUSH } x86Group5; /* x86 condition codes. */ typedef enum { CC_O, CC_NO, CC_B, CC_NB, CC_E, CC_NE, CC_BE, CC_NBE, CC_S, CC_NS, CC_P, CC_NP, CC_L, CC_NL, CC_LE, CC_NLE, CC_C = CC_B, CC_NAE = CC_C, CC_NC = CC_NB, CC_AE = CC_NB, CC_Z = CC_E, CC_NZ = CC_NE, CC_NA = CC_BE, CC_A = CC_NBE, CC_PE = CC_P, CC_PO = CC_NP, CC_NGE = CC_L, CC_GE = CC_NL, CC_NG = CC_LE, CC_G = CC_NLE } x86CC; #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_trace.c ================================================ /* ** Trace management. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_trace_c #define LUA_CORE #include "lj_obj.h" #if LJ_HASJIT #include "lj_gc.h" #include "lj_err.h" #include "lj_debug.h" #include "lj_str.h" #include "lj_frame.h" #include "lj_state.h" #include "lj_bc.h" #include "lj_ir.h" #include "lj_jit.h" #include "lj_iropt.h" #include "lj_mcode.h" #include "lj_trace.h" #include "lj_snap.h" #include "lj_gdbjit.h" #include "lj_record.h" #include "lj_asm.h" #include "lj_dispatch.h" #include "lj_vm.h" #include "lj_vmevent.h" #include "lj_target.h" /* -- Error handling ------------------------------------------------------ */ /* Synchronous abort with error message. */ void lj_trace_err(jit_State *J, TraceError e) { setnilV(&J->errinfo); /* No error info. */ setintV(J->L->top++, (int32_t)e); lj_err_throw(J->L, LUA_ERRRUN); } /* Synchronous abort with error message and error info. */ void lj_trace_err_info(jit_State *J, TraceError e) { setintV(J->L->top++, (int32_t)e); lj_err_throw(J->L, LUA_ERRRUN); } /* -- Trace management ---------------------------------------------------- */ /* The current trace is first assembled in J->cur. The variable length ** arrays point to shared, growable buffers (J->irbuf etc.). When trace ** recording ends successfully, the current trace and its data structures ** are copied to a new (compact) GCtrace object. */ /* Find a free trace number. */ static TraceNo trace_findfree(jit_State *J) { MSize osz, lim; if (J->freetrace == 0) J->freetrace = 1; for (; J->freetrace < J->sizetrace; J->freetrace++) if (traceref(J, J->freetrace) == NULL) return J->freetrace++; /* Need to grow trace array. */ lim = (MSize)J->param[JIT_P_maxtrace] + 1; if (lim < 2) lim = 2; else if (lim > 65535) lim = 65535; osz = J->sizetrace; if (osz >= lim) return 0; /* Too many traces. */ lj_mem_growvec(J->L, J->trace, J->sizetrace, lim, GCRef); for (; osz < J->sizetrace; osz++) setgcrefnull(J->trace[osz]); return J->freetrace; } #define TRACE_APPENDVEC(field, szfield, tp) \ T->field = (tp *)p; \ memcpy(p, J->cur.field, J->cur.szfield*sizeof(tp)); \ p += J->cur.szfield*sizeof(tp); #ifdef LUAJIT_USE_PERFTOOLS /* ** Create symbol table of JIT-compiled code. For use with Linux perf tools. ** Example usage: ** perf record -f -e cycles luajit test.lua ** perf report -s symbol ** rm perf.data /tmp/perf-*.map */ #include #include static void perftools_addtrace(GCtrace *T) { static FILE *fp; GCproto *pt = &gcref(T->startpt)->pt; const BCIns *startpc = mref(T->startpc, const BCIns); const char *name = proto_chunknamestr(pt); BCLine lineno; if (name[0] == '@' || name[0] == '=') name++; else name = "(string)"; lua_assert(startpc >= proto_bc(pt) && startpc < proto_bc(pt) + pt->sizebc); lineno = lj_debug_line(pt, proto_bcpos(pt, startpc)); if (!fp) { char fname[40]; sprintf(fname, "/tmp/perf-%d.map", getpid()); if (!(fp = fopen(fname, "w"))) return; setlinebuf(fp); } fprintf(fp, "%lx %x TRACE_%d::%s:%u\n", (long)T->mcode, T->szmcode, T->traceno, name, lineno); } #endif /* Save current trace by copying and compacting it. */ static void trace_save(jit_State *J) { size_t sztr = ((sizeof(GCtrace)+7)&~7); size_t szins = (J->cur.nins-J->cur.nk)*sizeof(IRIns); size_t sz = sztr + szins + J->cur.nsnap*sizeof(SnapShot) + J->cur.nsnapmap*sizeof(SnapEntry); GCtrace *T = lj_mem_newt(J->L, (MSize)sz, GCtrace); char *p = (char *)T + sztr; memcpy(T, &J->cur, sizeof(GCtrace)); setgcrefr(T->nextgc, J2G(J)->gc.root); setgcrefp(J2G(J)->gc.root, T); newwhite(J2G(J), T); T->gct = ~LJ_TTRACE; T->ir = (IRIns *)p - J->cur.nk; memcpy(p, J->cur.ir+J->cur.nk, szins); p += szins; TRACE_APPENDVEC(snap, nsnap, SnapShot) TRACE_APPENDVEC(snapmap, nsnapmap, SnapEntry) J->cur.traceno = 0; setgcrefp(J->trace[T->traceno], T); lj_gc_barriertrace(J2G(J), T->traceno); lj_gdbjit_addtrace(J, T); #ifdef LUAJIT_USE_PERFTOOLS perftools_addtrace(T); #endif } void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T) { jit_State *J = G2J(g); if (T->traceno) { lj_gdbjit_deltrace(J, T); if (T->traceno < J->freetrace) J->freetrace = T->traceno; setgcrefnull(J->trace[T->traceno]); } lj_mem_free(g, T, ((sizeof(GCtrace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry)); } /* Re-enable compiling a prototype by unpatching any modified bytecode. */ void lj_trace_reenableproto(GCproto *pt) { if ((pt->flags & PROTO_ILOOP)) { BCIns *bc = proto_bc(pt); BCPos i, sizebc = pt->sizebc;; pt->flags &= ~PROTO_ILOOP; if (bc_op(bc[0]) == BC_IFUNCF) setbc_op(&bc[0], BC_FUNCF); for (i = 1; i < sizebc; i++) { BCOp op = bc_op(bc[i]); if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP) setbc_op(&bc[i], (int)op+(int)BC_LOOP-(int)BC_ILOOP); } } } /* Unpatch the bytecode modified by a root trace. */ static void trace_unpatch(jit_State *J, GCtrace *T) { BCOp op = bc_op(T->startins); BCIns *pc = mref(T->startpc, BCIns); UNUSED(J); if (op == BC_JMP) return; /* No need to unpatch branches in parent traces (yet). */ switch (bc_op(*pc)) { case BC_JFORL: lua_assert(traceref(J, bc_d(*pc)) == T); *pc = T->startins; pc += bc_j(T->startins); lua_assert(bc_op(*pc) == BC_JFORI); setbc_op(pc, BC_FORI); break; case BC_JITERL: case BC_JLOOP: lua_assert(op == BC_ITERL || op == BC_LOOP || bc_isret(op)); *pc = T->startins; break; case BC_JMP: lua_assert(op == BC_ITERL); pc += bc_j(*pc)+2; if (bc_op(*pc) == BC_JITERL) { lua_assert(traceref(J, bc_d(*pc)) == T); *pc = T->startins; } break; case BC_JFUNCF: lua_assert(op == BC_FUNCF); *pc = T->startins; break; default: /* Already unpatched. */ break; } } /* Flush a root trace. */ static void trace_flushroot(jit_State *J, GCtrace *T) { GCproto *pt = &gcref(T->startpt)->pt; lua_assert(T->root == 0 && pt != NULL); /* First unpatch any modified bytecode. */ trace_unpatch(J, T); /* Unlink root trace from chain anchored in prototype. */ if (pt->trace == T->traceno) { /* Trace is first in chain. Easy. */ pt->trace = T->nextroot; } else if (pt->trace) { /* Otherwise search in chain of root traces. */ GCtrace *T2 = traceref(J, pt->trace); if (T2) { for (; T2->nextroot; T2 = traceref(J, T2->nextroot)) if (T2->nextroot == T->traceno) { T2->nextroot = T->nextroot; /* Unlink from chain. */ break; } } } } /* Flush a trace. Only root traces are considered. */ void lj_trace_flush(jit_State *J, TraceNo traceno) { if (traceno > 0 && traceno < J->sizetrace) { GCtrace *T = traceref(J, traceno); if (T && T->root == 0) trace_flushroot(J, T); } } /* Flush all traces associated with a prototype. */ void lj_trace_flushproto(global_State *g, GCproto *pt) { while (pt->trace != 0) trace_flushroot(G2J(g), traceref(G2J(g), pt->trace)); } /* Flush all traces. */ int lj_trace_flushall(lua_State *L) { jit_State *J = L2J(L); ptrdiff_t i; if ((J2G(J)->hookmask & HOOK_GC)) return 1; for (i = (ptrdiff_t)J->sizetrace-1; i > 0; i--) { GCtrace *T = traceref(J, i); if (T) { if (T->root == 0) trace_flushroot(J, T); lj_gdbjit_deltrace(J, T); T->traceno = 0; setgcrefnull(J->trace[i]); } } J->cur.traceno = 0; J->freetrace = 0; /* Clear penalty cache. */ memset(J->penalty, 0, sizeof(J->penalty)); /* Free the whole machine code and invalidate all exit stub groups. */ lj_mcode_free(J); memset(J->exitstubgroup, 0, sizeof(J->exitstubgroup)); lj_vmevent_send(L, TRACE, setstrV(L, L->top++, lj_str_newlit(L, "flush")); ); return 0; } /* Initialize JIT compiler state. */ void lj_trace_initstate(global_State *g) { jit_State *J = G2J(g); TValue *tv; /* Initialize SIMD constants. */ tv = LJ_KSIMD(J, LJ_KSIMD_ABS); tv[0].u64 = U64x(7fffffff,ffffffff); tv[1].u64 = U64x(7fffffff,ffffffff); tv = LJ_KSIMD(J, LJ_KSIMD_NEG); tv[0].u64 = U64x(80000000,00000000); tv[1].u64 = U64x(80000000,00000000); } /* Free everything associated with the JIT compiler state. */ void lj_trace_freestate(global_State *g) { jit_State *J = G2J(g); #ifdef LUA_USE_ASSERT { /* This assumes all traces have already been freed. */ ptrdiff_t i; for (i = 1; i < (ptrdiff_t)J->sizetrace; i++) lua_assert(i == (ptrdiff_t)J->cur.traceno || traceref(J, i) == NULL); } #endif lj_mcode_free(J); lj_ir_k64_freeall(J); lj_mem_freevec(g, J->snapmapbuf, J->sizesnapmap, SnapEntry); lj_mem_freevec(g, J->snapbuf, J->sizesnap, SnapShot); lj_mem_freevec(g, J->irbuf + J->irbotlim, J->irtoplim - J->irbotlim, IRIns); lj_mem_freevec(g, J->trace, J->sizetrace, GCRef); } /* -- Penalties and blacklisting ------------------------------------------ */ /* Blacklist a bytecode instruction. */ static void blacklist_pc(GCproto *pt, BCIns *pc) { setbc_op(pc, (int)bc_op(*pc)+(int)BC_ILOOP-(int)BC_LOOP); pt->flags |= PROTO_ILOOP; } /* Penalize a bytecode instruction. */ static void penalty_pc(jit_State *J, GCproto *pt, BCIns *pc, TraceError e) { uint32_t i, val = PENALTY_MIN; for (i = 0; i < PENALTY_SLOTS; i++) if (mref(J->penalty[i].pc, const BCIns) == pc) { /* Cache slot found? */ /* First try to bump its hotcount several times. */ val = ((uint32_t)J->penalty[i].val << 1) + LJ_PRNG_BITS(J, PENALTY_RNDBITS); if (val > PENALTY_MAX) { blacklist_pc(pt, pc); /* Blacklist it, if that didn't help. */ return; } goto setpenalty; } /* Assign a new penalty cache slot. */ i = J->penaltyslot; J->penaltyslot = (J->penaltyslot + 1) & (PENALTY_SLOTS-1); setmref(J->penalty[i].pc, pc); setpenalty: J->penalty[i].val = (uint16_t)val; J->penalty[i].reason = e; hotcount_set(J2GG(J), pc+1, val); } /* -- Trace compiler state machine ---------------------------------------- */ /* Start tracing. */ static void trace_start(jit_State *J) { lua_State *L; TraceNo traceno; if ((J->pt->flags & PROTO_NOJIT)) { /* JIT disabled for this proto? */ if (J->parent == 0) { /* Lazy bytecode patching to disable hotcount events. */ lua_assert(bc_op(*J->pc) == BC_FORL || bc_op(*J->pc) == BC_ITERL || bc_op(*J->pc) == BC_LOOP || bc_op(*J->pc) == BC_FUNCF); setbc_op(J->pc, (int)bc_op(*J->pc)+(int)BC_ILOOP-(int)BC_LOOP); J->pt->flags |= PROTO_ILOOP; } J->state = LJ_TRACE_IDLE; /* Silently ignored. */ return; } /* Get a new trace number. */ traceno = trace_findfree(J); if (LJ_UNLIKELY(traceno == 0)) { /* No free trace? */ lua_assert((J2G(J)->hookmask & HOOK_GC) == 0); lj_trace_flushall(J->L); J->state = LJ_TRACE_IDLE; /* Silently ignored. */ return; } setgcrefp(J->trace[traceno], &J->cur); /* Setup enough of the current trace to be able to send the vmevent. */ memset(&J->cur, 0, sizeof(GCtrace)); J->cur.traceno = traceno; J->cur.nins = J->cur.nk = REF_BASE; J->cur.ir = J->irbuf; J->cur.snap = J->snapbuf; J->cur.snapmap = J->snapmapbuf; J->mergesnap = 0; J->needsnap = 0; J->bcskip = 0; J->guardemit.irt = 0; J->postproc = LJ_POST_NONE; lj_resetsplit(J); setgcref(J->cur.startpt, obj2gco(J->pt)); L = J->L; lj_vmevent_send(L, TRACE, setstrV(L, L->top++, lj_str_newlit(L, "start")); setintV(L->top++, traceno); setfuncV(L, L->top++, J->fn); setintV(L->top++, proto_bcpos(J->pt, J->pc)); if (J->parent) { setintV(L->top++, J->parent); setintV(L->top++, J->exitno); } ); lj_record_setup(J); } /* Stop tracing. */ static void trace_stop(jit_State *J) { BCIns *pc = mref(J->cur.startpc, BCIns); BCOp op = bc_op(J->cur.startins); GCproto *pt = &gcref(J->cur.startpt)->pt; TraceNo traceno = J->cur.traceno; lua_State *L; switch (op) { case BC_FORL: setbc_op(pc+bc_j(J->cur.startins), BC_JFORI); /* Patch FORI, too. */ /* fallthrough */ case BC_LOOP: case BC_ITERL: case BC_FUNCF: /* Patch bytecode of starting instruction in root trace. */ setbc_op(pc, (int)op+(int)BC_JLOOP-(int)BC_LOOP); setbc_d(pc, traceno); addroot: /* Add to root trace chain in prototype. */ J->cur.nextroot = pt->trace; pt->trace = (TraceNo1)traceno; break; case BC_RET: case BC_RET0: case BC_RET1: *pc = BCINS_AD(BC_JLOOP, J->cur.snap[0].nslots, traceno); goto addroot; case BC_JMP: /* Patch exit branch in parent to side trace entry. */ lua_assert(J->parent != 0 && J->cur.root != 0); lj_asm_patchexit(J, traceref(J, J->parent), J->exitno, J->cur.mcode); /* Avoid compiling a side trace twice (stack resizing uses parent exit). */ traceref(J, J->parent)->snap[J->exitno].count = SNAPCOUNT_DONE; /* Add to side trace chain in root trace. */ { GCtrace *root = traceref(J, J->cur.root); root->nchild++; J->cur.nextside = root->nextside; root->nextside = (TraceNo1)traceno; } break; default: lua_assert(0); break; } /* Commit new mcode only after all patching is done. */ lj_mcode_commit(J, J->cur.mcode); J->postproc = LJ_POST_NONE; trace_save(J); L = J->L; lj_vmevent_send(L, TRACE, setstrV(L, L->top++, lj_str_newlit(L, "stop")); setintV(L->top++, traceno); ); } /* Start a new root trace for down-recursion. */ static int trace_downrec(jit_State *J) { /* Restart recording at the return instruction. */ lua_assert(J->pt != NULL); lua_assert(bc_isret(bc_op(*J->pc))); if (bc_op(*J->pc) == BC_RETM) return 0; /* NYI: down-recursion with RETM. */ J->parent = 0; J->exitno = 0; J->state = LJ_TRACE_RECORD; trace_start(J); return 1; } /* Abort tracing. */ static int trace_abort(jit_State *J) { lua_State *L = J->L; TraceError e = LJ_TRERR_RECERR; TraceNo traceno; J->postproc = LJ_POST_NONE; lj_mcode_abort(J); if (tvisnumber(L->top-1)) e = (TraceError)numberVint(L->top-1); if (e == LJ_TRERR_MCODELM) { L->top--; /* Remove error object */ J->state = LJ_TRACE_ASM; return 1; /* Retry ASM with new MCode area. */ } /* Penalize or blacklist starting bytecode instruction. */ if (J->parent == 0 && !bc_isret(bc_op(J->cur.startins))) penalty_pc(J, &gcref(J->cur.startpt)->pt, mref(J->cur.startpc, BCIns), e); /* Is there anything to abort? */ traceno = J->cur.traceno; if (traceno) { ptrdiff_t errobj = savestack(L, L->top-1); /* Stack may be resized. */ J->cur.link = 0; J->cur.linktype = LJ_TRLINK_NONE; lj_vmevent_send(L, TRACE, TValue *frame; const BCIns *pc; GCfunc *fn; setstrV(L, L->top++, lj_str_newlit(L, "abort")); setintV(L->top++, traceno); /* Find original Lua function call to generate a better error message. */ frame = J->L->base-1; pc = J->pc; while (!isluafunc(frame_func(frame))) { pc = (frame_iscont(frame) ? frame_contpc(frame) : frame_pc(frame)) - 1; frame = frame_prev(frame); } fn = frame_func(frame); setfuncV(L, L->top++, fn); setintV(L->top++, proto_bcpos(funcproto(fn), pc)); copyTV(L, L->top++, restorestack(L, errobj)); copyTV(L, L->top++, &J->errinfo); ); /* Drop aborted trace after the vmevent (which may still access it). */ setgcrefnull(J->trace[traceno]); if (traceno < J->freetrace) J->freetrace = traceno; J->cur.traceno = 0; } L->top--; /* Remove error object */ if (e == LJ_TRERR_DOWNREC) return trace_downrec(J); else if (e == LJ_TRERR_MCODEAL) lj_trace_flushall(L); return 0; } /* Perform pending re-patch of a bytecode instruction. */ static LJ_AINLINE void trace_pendpatch(jit_State *J, int force) { if (LJ_UNLIKELY(J->patchpc)) { if (force || J->bcskip == 0) { *J->patchpc = J->patchins; J->patchpc = NULL; } else { J->bcskip = 0; } } } /* State machine for the trace compiler. Protected callback. */ static TValue *trace_state(lua_State *L, lua_CFunction dummy, void *ud) { jit_State *J = (jit_State *)ud; UNUSED(dummy); do { retry: switch (J->state) { case LJ_TRACE_START: J->state = LJ_TRACE_RECORD; /* trace_start() may change state. */ trace_start(J); lj_dispatch_update(J2G(J)); break; case LJ_TRACE_RECORD: trace_pendpatch(J, 0); setvmstate(J2G(J), RECORD); lj_vmevent_send_(L, RECORD, /* Save/restore tmptv state for trace recorder. */ TValue savetv = J2G(J)->tmptv; TValue savetv2 = J2G(J)->tmptv2; setintV(L->top++, J->cur.traceno); setfuncV(L, L->top++, J->fn); setintV(L->top++, J->pt ? (int32_t)proto_bcpos(J->pt, J->pc) : -1); setintV(L->top++, J->framedepth); , J2G(J)->tmptv = savetv; J2G(J)->tmptv2 = savetv2; ); lj_record_ins(J); break; case LJ_TRACE_END: trace_pendpatch(J, 1); J->loopref = 0; if ((J->flags & JIT_F_OPT_LOOP) && J->cur.link == J->cur.traceno && J->framedepth + J->retdepth == 0) { setvmstate(J2G(J), OPT); lj_opt_dce(J); if (lj_opt_loop(J)) { /* Loop optimization failed? */ J->cur.link = 0; J->cur.linktype = LJ_TRLINK_NONE; J->loopref = J->cur.nins; J->state = LJ_TRACE_RECORD; /* Try to continue recording. */ break; } J->loopref = J->chain[IR_LOOP]; /* Needed by assembler. */ } lj_opt_split(J); lj_opt_sink(J); J->state = LJ_TRACE_ASM; break; case LJ_TRACE_ASM: setvmstate(J2G(J), ASM); lj_asm_trace(J, &J->cur); trace_stop(J); setvmstate(J2G(J), INTERP); J->state = LJ_TRACE_IDLE; lj_dispatch_update(J2G(J)); return NULL; default: /* Trace aborted asynchronously. */ setintV(L->top++, (int32_t)LJ_TRERR_RECERR); /* fallthrough */ case LJ_TRACE_ERR: trace_pendpatch(J, 1); if (trace_abort(J)) goto retry; setvmstate(J2G(J), INTERP); J->state = LJ_TRACE_IDLE; lj_dispatch_update(J2G(J)); return NULL; } } while (J->state > LJ_TRACE_RECORD); return NULL; } /* -- Event handling ------------------------------------------------------ */ /* A bytecode instruction is about to be executed. Record it. */ void lj_trace_ins(jit_State *J, const BCIns *pc) { /* Note: J->L must already be set. pc is the true bytecode PC here. */ J->pc = pc; J->fn = curr_func(J->L); J->pt = isluafunc(J->fn) ? funcproto(J->fn) : NULL; while (lj_vm_cpcall(J->L, NULL, (void *)J, trace_state) != 0) J->state = LJ_TRACE_ERR; } /* A hotcount triggered. Start recording a root trace. */ void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc) { /* Note: pc is the interpreter bytecode PC here. It's offset by 1. */ ERRNO_SAVE /* Reset hotcount. */ hotcount_set(J2GG(J), pc, J->param[JIT_P_hotloop]*HOTCOUNT_LOOP); /* Only start a new trace if not recording or inside __gc call or vmevent. */ if (J->state == LJ_TRACE_IDLE && !(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT))) { J->parent = 0; /* Root trace. */ J->exitno = 0; J->state = LJ_TRACE_START; lj_trace_ins(J, pc-1); } ERRNO_RESTORE } /* Check for a hot side exit. If yes, start recording a side trace. */ static void trace_hotside(jit_State *J, const BCIns *pc) { SnapShot *snap = &traceref(J, J->parent)->snap[J->exitno]; if (!(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT)) && snap->count != SNAPCOUNT_DONE && ++snap->count >= J->param[JIT_P_hotexit]) { lua_assert(J->state == LJ_TRACE_IDLE); /* J->parent is non-zero for a side trace. */ J->state = LJ_TRACE_START; lj_trace_ins(J, pc); } } /* Tiny struct to pass data to protected call. */ typedef struct ExitDataCP { jit_State *J; void *exptr; /* Pointer to exit state. */ const BCIns *pc; /* Restart interpreter at this PC. */ } ExitDataCP; /* Need to protect lj_snap_restore because it may throw. */ static TValue *trace_exit_cp(lua_State *L, lua_CFunction dummy, void *ud) { ExitDataCP *exd = (ExitDataCP *)ud; cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ exd->pc = lj_snap_restore(exd->J, exd->exptr); UNUSED(dummy); return NULL; } #ifndef LUAJIT_DISABLE_VMEVENT /* Push all registers from exit state. */ static void trace_exit_regs(lua_State *L, ExitState *ex) { int32_t i; setintV(L->top++, RID_NUM_GPR); setintV(L->top++, RID_NUM_FPR); for (i = 0; i < RID_NUM_GPR; i++) { if (sizeof(ex->gpr[i]) == sizeof(int32_t)) setintV(L->top++, (int32_t)ex->gpr[i]); else setnumV(L->top++, (lua_Number)ex->gpr[i]); } #if !LJ_SOFTFP for (i = 0; i < RID_NUM_FPR; i++) { setnumV(L->top, ex->fpr[i]); if (LJ_UNLIKELY(tvisnan(L->top))) setnanV(L->top); L->top++; } #endif } #endif #ifdef EXITSTATE_PCREG /* Determine trace number from pc of exit instruction. */ static TraceNo trace_exit_find(jit_State *J, MCode *pc) { TraceNo traceno; for (traceno = 1; traceno < J->sizetrace; traceno++) { GCtrace *T = traceref(J, traceno); if (T && pc >= T->mcode && pc < (MCode *)((char *)T->mcode + T->szmcode)) return traceno; } lua_assert(0); return 0; } #endif /* A trace exited. Restore interpreter state. */ int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr) { ERRNO_SAVE lua_State *L = J->L; ExitState *ex = (ExitState *)exptr; ExitDataCP exd; int errcode; const BCIns *pc; void *cf; GCtrace *T; #ifdef EXITSTATE_PCREG J->parent = trace_exit_find(J, (MCode *)(intptr_t)ex->gpr[EXITSTATE_PCREG]); #endif T = traceref(J, J->parent); UNUSED(T); #ifdef EXITSTATE_CHECKEXIT if (J->exitno == T->nsnap) { /* Treat stack check like a parent exit. */ lua_assert(T->root != 0); J->exitno = T->ir[REF_BASE].op2; J->parent = T->ir[REF_BASE].op1; T = traceref(J, J->parent); } #endif lua_assert(T != NULL && J->exitno < T->nsnap); exd.J = J; exd.exptr = exptr; errcode = lj_vm_cpcall(L, NULL, &exd, trace_exit_cp); if (errcode) return -errcode; /* Return negated error code. */ lj_vmevent_send(L, TEXIT, lj_state_checkstack(L, 4+RID_NUM_GPR+RID_NUM_FPR+LUA_MINSTACK); setintV(L->top++, J->parent); setintV(L->top++, J->exitno); trace_exit_regs(L, ex); ); pc = exd.pc; cf = cframe_raw(L->cframe); setcframe_pc(cf, pc); if (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize) { if (!(G(L)->hookmask & HOOK_GC)) lj_gc_step(L); /* Exited because of GC: drive GC forward. */ } else { trace_hotside(J, pc); } if (bc_op(*pc) == BC_JLOOP) { BCIns *retpc = &traceref(J, bc_d(*pc))->startins; if (bc_isret(bc_op(*retpc))) { if (J->state == LJ_TRACE_RECORD) { J->patchins = *pc; J->patchpc = (BCIns *)pc; *J->patchpc = *retpc; J->bcskip = 1; } else { pc = retpc; setcframe_pc(cf, pc); } } } /* Return MULTRES or 0. */ ERRNO_RESTORE switch (bc_op(*pc)) { case BC_CALLM: case BC_CALLMT: return (int)((BCReg)(L->top - L->base) - bc_a(*pc) - bc_c(*pc)); case BC_RETM: return (int)((BCReg)(L->top - L->base) + 1 - bc_a(*pc) - bc_d(*pc)); case BC_TSETM: return (int)((BCReg)(L->top - L->base) + 1 - bc_a(*pc)); default: if (bc_op(*pc) >= BC_FUNCF) return (int)((BCReg)(L->top - L->base) + 1); return 0; } } #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_trace.h ================================================ /* ** Trace management. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_TRACE_H #define _LJ_TRACE_H #include "lj_obj.h" #if LJ_HASJIT #include "lj_jit.h" #include "lj_dispatch.h" /* Trace errors. */ typedef enum { #define TREDEF(name, msg) LJ_TRERR_##name, #include "lj_traceerr.h" LJ_TRERR__MAX } TraceError; LJ_FUNC_NORET void lj_trace_err(jit_State *J, TraceError e); LJ_FUNC_NORET void lj_trace_err_info(jit_State *J, TraceError e); /* Trace management. */ LJ_FUNC void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T); LJ_FUNC void lj_trace_reenableproto(GCproto *pt); LJ_FUNC void lj_trace_flushproto(global_State *g, GCproto *pt); LJ_FUNC void lj_trace_flush(jit_State *J, TraceNo traceno); LJ_FUNC int lj_trace_flushall(lua_State *L); LJ_FUNC void lj_trace_initstate(global_State *g); LJ_FUNC void lj_trace_freestate(global_State *g); /* Event handling. */ LJ_FUNC void lj_trace_ins(jit_State *J, const BCIns *pc); LJ_FUNCA void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc); LJ_FUNCA int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr); /* Signal asynchronous abort of trace or end of trace. */ #define lj_trace_abort(g) (G2J(g)->state &= ~LJ_TRACE_ACTIVE) #define lj_trace_end(J) (J->state = LJ_TRACE_END) #else #define lj_trace_flushall(L) (UNUSED(L), 0) #define lj_trace_initstate(g) UNUSED(g) #define lj_trace_freestate(g) UNUSED(g) #define lj_trace_abort(g) UNUSED(g) #define lj_trace_end(J) UNUSED(J) #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_traceerr.h ================================================ /* ** Trace compiler error messages. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* This file may be included multiple times with different TREDEF macros. */ /* Recording. */ TREDEF(RECERR, "error thrown or hook called during recording") TREDEF(TRACEOV, "trace too long") TREDEF(STACKOV, "trace too deep") TREDEF(SNAPOV, "too many snapshots") TREDEF(BLACKL, "blacklisted") TREDEF(NYIBC, "NYI: bytecode %d") /* Recording loop ops. */ TREDEF(LLEAVE, "leaving loop in root trace") TREDEF(LINNER, "inner loop in root trace") TREDEF(LUNROLL, "loop unroll limit reached") /* Recording calls/returns. */ TREDEF(BADTYPE, "bad argument type") TREDEF(CJITOFF, "call to JIT-disabled function") TREDEF(CUNROLL, "call unroll limit reached") TREDEF(DOWNREC, "down-recursion, restarting") TREDEF(NYICF, "NYI: C function %p") TREDEF(NYIFF, "NYI: FastFunc %s") TREDEF(NYIFFU, "NYI: unsupported variant of FastFunc %s") TREDEF(NYIRETL, "NYI: return to lower frame") /* Recording indexed load/store. */ TREDEF(STORENN, "store with nil or NaN key") TREDEF(NOMM, "missing metamethod") TREDEF(IDXLOOP, "looping index lookup") TREDEF(NYITMIX, "NYI: mixed sparse/dense table") /* Recording C data operations. */ TREDEF(NOCACHE, "symbol not in cache") TREDEF(NYICONV, "NYI: unsupported C type conversion") TREDEF(NYICALL, "NYI: unsupported C function type") /* Optimizations. */ TREDEF(GFAIL, "guard would always fail") TREDEF(PHIOV, "too many PHIs") TREDEF(TYPEINS, "persistent type instability") /* Assembler. */ TREDEF(MCODEAL, "failed to allocate mcode memory") TREDEF(MCODEOV, "machine code too long") TREDEF(MCODELM, "hit mcode limit (retrying)") TREDEF(SPILLOV, "too many spill slots") TREDEF(BADRA, "inconsistent register allocation") TREDEF(NYIIR, "NYI: cannot assemble IR instruction %d") TREDEF(NYIPHI, "NYI: PHI shuffling too complex") TREDEF(NYICOAL, "NYI: register coalescing too complex") #undef TREDEF /* Detecting unused error messages: awk -F, '/^TREDEF/ { gsub(/TREDEF./, ""); printf "grep -q LJ_TRERR_%s *.[ch] || echo %s\n", $1, $1}' lj_traceerr.h | sh */ ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_udata.c ================================================ /* ** Userdata handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_udata_c #define LUA_CORE #include "lj_obj.h" #include "lj_gc.h" #include "lj_udata.h" GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) { GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata); global_State *g = G(L); newwhite(g, ud); /* Not finalized. */ ud->gct = ~LJ_TUDATA; ud->udtype = UDTYPE_USERDATA; ud->len = sz; /* NOBARRIER: The GCudata is new (marked white). */ setgcrefnull(ud->metatable); setgcref(ud->env, obj2gco(env)); /* Chain to userdata list (after main thread). */ setgcrefr(ud->nextgc, mainthread(g)->nextgc); setgcref(mainthread(g)->nextgc, obj2gco(ud)); return ud; } void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud) { lj_mem_free(g, ud, sizeudata(ud)); } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_udata.h ================================================ /* ** Userdata handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_UDATA_H #define _LJ_UDATA_H #include "lj_obj.h" LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_vm.h ================================================ /* ** Assembler VM interface definitions. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_VM_H #define _LJ_VM_H #include "lj_obj.h" /* Entry points for ASM parts of VM. */ LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1); LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud); LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp); LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_c(void *cframe, int errcode); LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_ff(void *cframe); LJ_ASMF void lj_vm_unwind_c_eh(void); LJ_ASMF void lj_vm_unwind_ff_eh(void); #if LJ_TARGET_X86ORX64 LJ_ASMF void lj_vm_unwind_rethrow(void); #endif /* Miscellaneous functions. */ #if LJ_TARGET_X86ORX64 LJ_ASMF int lj_vm_cpuid(uint32_t f, uint32_t res[4]); #endif #if LJ_TARGET_PPC void lj_vm_cachesync(void *start, void *end); #endif LJ_ASMF double lj_vm_foldarith(double x, double y, int op); #if LJ_HASJIT LJ_ASMF double lj_vm_foldfpm(double x, int op); #endif #if !LJ_ARCH_HASFPU /* Declared in lj_obj.h: LJ_ASMF int32_t lj_vm_tobit(double x); */ #endif /* Dispatch targets for recording and hooks. */ LJ_ASMF void lj_vm_record(void); LJ_ASMF void lj_vm_inshook(void); LJ_ASMF void lj_vm_rethook(void); LJ_ASMF void lj_vm_callhook(void); /* Trace exit handling. */ LJ_ASMF void lj_vm_exit_handler(void); LJ_ASMF void lj_vm_exit_interp(void); /* Internal math helper functions. */ #if LJ_TARGET_X86ORX64 || LJ_TARGET_PPC #define lj_vm_floor floor #define lj_vm_ceil ceil #else LJ_ASMF double lj_vm_floor(double); LJ_ASMF double lj_vm_ceil(double); #if LJ_TARGET_ARM LJ_ASMF double lj_vm_floor_sf(double); LJ_ASMF double lj_vm_ceil_sf(double); #endif #endif #if defined(LUAJIT_NO_LOG2) || LJ_TARGET_X86ORX64 LJ_ASMF double lj_vm_log2(double); #else #define lj_vm_log2 log2 #endif #if LJ_HASJIT #if LJ_TARGET_X86ORX64 LJ_ASMF void lj_vm_floor_sse(void); LJ_ASMF void lj_vm_ceil_sse(void); LJ_ASMF void lj_vm_trunc_sse(void); LJ_ASMF void lj_vm_exp_x87(void); LJ_ASMF void lj_vm_exp2_x87(void); LJ_ASMF void lj_vm_pow_sse(void); LJ_ASMF void lj_vm_powi_sse(void); #else #if LJ_TARGET_PPC #define lj_vm_trunc trunc #else LJ_ASMF double lj_vm_trunc(double); #if LJ_TARGET_ARM LJ_ASMF double lj_vm_trunc_sf(double); #endif #endif LJ_ASMF double lj_vm_powi(double, int32_t); #ifdef LUAJIT_NO_EXP2 LJ_ASMF double lj_vm_exp2(double); #else #define lj_vm_exp2 exp2 #endif #endif LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t); #if LJ_HASFFI LJ_ASMF int lj_vm_errno(void); #endif #endif /* Continuations for metamethods. */ LJ_ASMF void lj_cont_cat(void); /* Continue with concatenation. */ LJ_ASMF void lj_cont_ra(void); /* Store result in RA from instruction. */ LJ_ASMF void lj_cont_nop(void); /* Do nothing, just continue execution. */ LJ_ASMF void lj_cont_condt(void); /* Branch if result is true. */ LJ_ASMF void lj_cont_condf(void); /* Branch if result is false. */ LJ_ASMF void lj_cont_hook(void); /* Continue from hook yield. */ enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */ /* Start of the ASM code. */ LJ_ASMF char lj_vm_asm_begin[]; /* Bytecode offsets are relative to lj_vm_asm_begin. */ #define makeasmfunc(ofs) ((ASMFunction)(lj_vm_asm_begin + (ofs))) #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_vmevent.c ================================================ /* ** VM event handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #include #define lj_vmevent_c #define LUA_CORE #include "lj_obj.h" #include "lj_str.h" #include "lj_tab.h" #include "lj_state.h" #include "lj_dispatch.h" #include "lj_vm.h" #include "lj_vmevent.h" ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev) { global_State *g = G(L); GCstr *s = lj_str_newlit(L, LJ_VMEVENTS_REGKEY); cTValue *tv = lj_tab_getstr(tabV(registry(L)), s); if (tvistab(tv)) { int hash = VMEVENT_HASH(ev); tv = lj_tab_getint(tabV(tv), hash); if (tv && tvisfunc(tv)) { lj_state_checkstack(L, LUA_MINSTACK); setfuncV(L, L->top++, funcV(tv)); return savestack(L, L->top); } } g->vmevmask &= ~VMEVENT_MASK(ev); /* No handler: cache this fact. */ return 0; } void lj_vmevent_call(lua_State *L, ptrdiff_t argbase) { global_State *g = G(L); uint8_t oldmask = g->vmevmask; uint8_t oldh = hook_save(g); int status; g->vmevmask = 0; /* Disable all events. */ hook_vmevent(g); status = lj_vm_pcall(L, restorestack(L, argbase), 0+1, 0); if (LJ_UNLIKELY(status)) { /* Really shouldn't use stderr here, but where else to complain? */ L->top--; fputs("VM handler failed: ", stderr); fputs(tvisstr(L->top) ? strVdata(L->top) : "?", stderr); fputc('\n', stderr); } hook_restore(g, oldh); if (g->vmevmask != VMEVENT_NOCACHE) g->vmevmask = oldmask; /* Restore event mask, but not if not modified. */ } ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_vmevent.h ================================================ /* ** VM event handling. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LJ_VMEVENT_H #define _LJ_VMEVENT_H #include "lj_obj.h" /* Registry key for VM event handler table. */ #define LJ_VMEVENTS_REGKEY "_VMEVENTS" #define LJ_VMEVENTS_HSIZE 4 #define VMEVENT_MASK(ev) ((uint8_t)1 << ((int)(ev) & 7)) #define VMEVENT_HASH(ev) ((int)(ev) & ~7) #define VMEVENT_HASHIDX(h) ((int)(h) << 3) #define VMEVENT_NOCACHE 255 #define VMEVENT_DEF(name, hash) \ LJ_VMEVENT_##name##_, \ LJ_VMEVENT_##name = ((LJ_VMEVENT_##name##_) & 7)|((hash) << 3) /* VM event IDs. */ typedef enum { VMEVENT_DEF(BC, 0x00003883), VMEVENT_DEF(TRACE, 0xb2d91467), VMEVENT_DEF(RECORD, 0x9284bf4f), VMEVENT_DEF(TEXIT, 0xb29df2b0), LJ_VMEVENT__MAX } VMEvent; #ifdef LUAJIT_DISABLE_VMEVENT #define lj_vmevent_send(L, ev, args) UNUSED(L) #define lj_vmevent_send_(L, ev, args, post) UNUSED(L) #else #define lj_vmevent_send(L, ev, args) \ if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ if (argbase) { \ args \ lj_vmevent_call(L, argbase); \ } \ } #define lj_vmevent_send_(L, ev, args, post) \ if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ if (argbase) { \ args \ lj_vmevent_call(L, argbase); \ post \ } \ } LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lj_vmmath.c ================================================ /* ** Math helper functions for assembler VM. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #define lj_vmmath_c #define LUA_CORE #include #include #include "lj_obj.h" #include "lj_ir.h" #include "lj_vm.h" /* -- Helper functions for generated machine code ------------------------- */ #if LJ_TARGET_X86ORX64 /* Wrapper functions to avoid linker issues on OSX. */ LJ_FUNCA double lj_vm_sinh(double x) { return sinh(x); } LJ_FUNCA double lj_vm_cosh(double x) { return cosh(x); } LJ_FUNCA double lj_vm_tanh(double x) { return tanh(x); } #endif #if !LJ_TARGET_X86ORX64 double lj_vm_foldarith(double x, double y, int op) { switch (op) { case IR_ADD - IR_ADD: return x+y; break; case IR_SUB - IR_ADD: return x-y; break; case IR_MUL - IR_ADD: return x*y; break; case IR_DIV - IR_ADD: return x/y; break; case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break; case IR_POW - IR_ADD: return pow(x, y); break; case IR_NEG - IR_ADD: return -x; break; case IR_ABS - IR_ADD: return fabs(x); break; #if LJ_HASJIT case IR_ATAN2 - IR_ADD: return atan2(x, y); break; case IR_LDEXP - IR_ADD: return ldexp(x, (int)y); break; case IR_MIN - IR_ADD: return x > y ? y : x; break; case IR_MAX - IR_ADD: return x < y ? y : x; break; #endif default: return x; } } #endif #if LJ_HASJIT #ifdef LUAJIT_NO_LOG2 double lj_vm_log2(double a) { return log(a) * 1.4426950408889634074; } #endif #ifdef LUAJIT_NO_EXP2 double lj_vm_exp2(double a) { return exp(a * 0.6931471805599453); } #endif #if !(LJ_TARGET_ARM || LJ_TARGET_PPC) int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) { uint32_t y, ua, ub; lua_assert(b != 0); /* This must be checked before using this function. */ ua = a < 0 ? (uint32_t)-a : (uint32_t)a; ub = b < 0 ? (uint32_t)-b : (uint32_t)b; y = ua % ub; if (y != 0 && (a^b) < 0) y = y - ub; if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; return (int32_t)y; } #endif #if !LJ_TARGET_X86ORX64 /* Unsigned x^k. */ static double lj_vm_powui(double x, uint32_t k) { double y; lua_assert(k != 0); for (; (k & 1) == 0; k >>= 1) x *= x; y = x; if ((k >>= 1) != 0) { for (;;) { x *= x; if (k == 1) break; if (k & 1) y *= x; k >>= 1; } y *= x; } return y; } /* Signed x^k. */ double lj_vm_powi(double x, int32_t k) { if (k > 1) return lj_vm_powui(x, (uint32_t)k); else if (k == 1) return x; else if (k == 0) return 1.0; else return 1.0 / lj_vm_powui(x, (uint32_t)-k); } /* Computes fpm(x) for extended math functions. */ double lj_vm_foldfpm(double x, int fpm) { switch (fpm) { case IRFPM_FLOOR: return lj_vm_floor(x); case IRFPM_CEIL: return lj_vm_ceil(x); case IRFPM_TRUNC: return lj_vm_trunc(x); case IRFPM_SQRT: return sqrt(x); case IRFPM_EXP: return exp(x); case IRFPM_EXP2: return lj_vm_exp2(x); case IRFPM_LOG: return log(x); case IRFPM_LOG2: return lj_vm_log2(x); case IRFPM_LOG10: return log10(x); case IRFPM_SIN: return sin(x); case IRFPM_COS: return cos(x); case IRFPM_TAN: return tan(x); default: lua_assert(0); } return 0; } #endif #if LJ_HASFFI int lj_vm_errno(void) { return errno; } #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/ljamalg.c ================================================ /* ** LuaJIT core and libraries amalgamation. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ /* +--------------------------------------------------------------------------+ | WARNING: Compiling the amalgamation needs a lot of virtual memory | | (around 200 MB with GCC 4.x)! If you don't have enough physical memory | | your machine will start swapping to disk and the compile will not finish | | within a reasonable amount of time. | | So either compile on a bigger machine or use the non-amalgamated build. | +--------------------------------------------------------------------------+ */ #define ljamalg_c #define LUA_CORE /* To get the mremap prototype. Must be defined before any system includes. */ #if defined(__linux__) && !defined(_GNU_SOURCE) #define _GNU_SOURCE #endif #ifndef WINVER #define WINVER 0x0500 #endif #include "lua.h" #include "lauxlib.h" #include "lj_gc.c" #include "lj_err.c" #include "lj_char.c" #include "lj_bc.c" #include "lj_obj.c" #include "lj_str.c" #include "lj_tab.c" #include "lj_func.c" #include "lj_udata.c" #include "lj_meta.c" #include "lj_debug.c" #include "lj_state.c" #include "lj_dispatch.c" #include "lj_vmevent.c" #include "lj_vmmath.c" #include "lj_strscan.c" #include "lj_api.c" #include "lj_lex.c" #include "lj_parse.c" #include "lj_bcread.c" #include "lj_bcwrite.c" #include "lj_load.c" #include "lj_ctype.c" #include "lj_cdata.c" #include "lj_cconv.c" #include "lj_ccall.c" #include "lj_ccallback.c" #include "lj_carith.c" #include "lj_clib.c" #include "lj_cparse.c" #include "lj_lib.c" #include "lj_ir.c" #include "lj_opt_mem.c" #include "lj_opt_fold.c" #include "lj_opt_narrow.c" #include "lj_opt_dce.c" #include "lj_opt_loop.c" #include "lj_opt_split.c" #include "lj_opt_sink.c" #include "lj_mcode.c" #include "lj_snap.c" #include "lj_record.c" #include "lj_crecord.c" #include "lj_ffrecord.c" #include "lj_asm.c" #include "lj_trace.c" #include "lj_gdbjit.c" #include "lj_alloc.c" #include "lib_aux.c" #include "lib_base.c" #include "lib_math.c" #include "lib_string.c" #include "lib_table.c" #include "lib_io.c" #include "lib_os.c" #include "lib_package.c" #include "lib_debug.c" #include "lib_bit.c" #include "lib_jit.c" #include "lib_ffi.c" #include "lib_init.c" ================================================ FILE: cocos2d/external/lua/luajit/src/src/lua.h ================================================ /* ** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ ** Lua - An Extensible Extension Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file */ #ifndef lua_h #define lua_h #include #include #include "luaconf.h" #define LUA_VERSION "Lua 5.1" #define LUA_RELEASE "Lua 5.1.4" #define LUA_VERSION_NUM 501 #define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" /* mark for precompiled code (`Lua') */ #define LUA_SIGNATURE "\033Lua" /* option for multiple returns in `lua_pcall' and `lua_call' */ #define LUA_MULTRET (-1) /* ** pseudo-indices */ #define LUA_REGISTRYINDEX (-10000) #define LUA_ENVIRONINDEX (-10001) #define LUA_GLOBALSINDEX (-10002) #define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) /* thread status; 0 is OK */ #define LUA_YIELD 1 #define LUA_ERRRUN 2 #define LUA_ERRSYNTAX 3 #define LUA_ERRMEM 4 #define LUA_ERRERR 5 typedef struct lua_State lua_State; typedef int (*lua_CFunction) (lua_State *L); /* ** functions that read/write blocks when loading/dumping Lua chunks */ typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); /* ** prototype for memory-allocation functions */ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); /* ** basic types */ #define LUA_TNONE (-1) #define LUA_TNIL 0 #define LUA_TBOOLEAN 1 #define LUA_TLIGHTUSERDATA 2 #define LUA_TNUMBER 3 #define LUA_TSTRING 4 #define LUA_TTABLE 5 #define LUA_TFUNCTION 6 #define LUA_TUSERDATA 7 #define LUA_TTHREAD 8 /* minimum Lua stack available to a C function */ #define LUA_MINSTACK 20 /* ** generic extra include file */ #if defined(LUA_USER_H) #include LUA_USER_H #endif /* type of numbers in Lua */ typedef LUA_NUMBER lua_Number; /* type for integer functions */ typedef LUA_INTEGER lua_Integer; /* ** state manipulation */ LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); LUA_API void (lua_close) (lua_State *L); LUA_API lua_State *(lua_newthread) (lua_State *L); LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); /* ** basic stack manipulation */ LUA_API int (lua_gettop) (lua_State *L); LUA_API void (lua_settop) (lua_State *L, int idx); LUA_API void (lua_pushvalue) (lua_State *L, int idx); LUA_API void (lua_remove) (lua_State *L, int idx); LUA_API void (lua_insert) (lua_State *L, int idx); LUA_API void (lua_replace) (lua_State *L, int idx); LUA_API int (lua_checkstack) (lua_State *L, int sz); LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); /* ** access functions (stack -> C) */ LUA_API int (lua_isnumber) (lua_State *L, int idx); LUA_API int (lua_isstring) (lua_State *L, int idx); LUA_API int (lua_iscfunction) (lua_State *L, int idx); LUA_API int (lua_isuserdata) (lua_State *L, int idx); LUA_API int (lua_type) (lua_State *L, int idx); LUA_API const char *(lua_typename) (lua_State *L, int tp); LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); LUA_API int (lua_toboolean) (lua_State *L, int idx); LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); LUA_API size_t (lua_objlen) (lua_State *L, int idx); LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); LUA_API void *(lua_touserdata) (lua_State *L, int idx); LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); LUA_API const void *(lua_topointer) (lua_State *L, int idx); /* ** push functions (C -> stack) */ LUA_API void (lua_pushnil) (lua_State *L); LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); LUA_API void (lua_pushstring) (lua_State *L, const char *s); LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, va_list argp); LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); LUA_API void (lua_pushboolean) (lua_State *L, int b); LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); LUA_API int (lua_pushthread) (lua_State *L); /* ** get functions (Lua -> stack) */ LUA_API void (lua_gettable) (lua_State *L, int idx); LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); LUA_API void (lua_rawget) (lua_State *L, int idx); LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); LUA_API int (lua_getmetatable) (lua_State *L, int objindex); LUA_API void (lua_getfenv) (lua_State *L, int idx); /* ** set functions (stack -> Lua) */ LUA_API void (lua_settable) (lua_State *L, int idx); LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); LUA_API void (lua_rawset) (lua_State *L, int idx); LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); LUA_API int (lua_setmetatable) (lua_State *L, int objindex); LUA_API int (lua_setfenv) (lua_State *L, int idx); /* ** `load' and `call' functions (load and run Lua code) */ LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, const char *chunkname); LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); /* ** coroutine functions */ LUA_API int (lua_yield) (lua_State *L, int nresults); LUA_API int (lua_resume) (lua_State *L, int narg); LUA_API int (lua_status) (lua_State *L); /* ** garbage-collection function and options */ #define LUA_GCSTOP 0 #define LUA_GCRESTART 1 #define LUA_GCCOLLECT 2 #define LUA_GCCOUNT 3 #define LUA_GCCOUNTB 4 #define LUA_GCSTEP 5 #define LUA_GCSETPAUSE 6 #define LUA_GCSETSTEPMUL 7 LUA_API int (lua_gc) (lua_State *L, int what, int data); /* ** miscellaneous functions */ LUA_API int (lua_error) (lua_State *L); LUA_API int (lua_next) (lua_State *L, int idx); LUA_API void (lua_concat) (lua_State *L, int n); LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); /* ** =============================================================== ** some useful macros ** =============================================================== */ #define lua_pop(L,n) lua_settop(L, -(n)-1) #define lua_newtable(L) lua_createtable(L, 0, 0) #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) #define lua_strlen(L,i) lua_objlen(L, (i)) #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) #define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) #define lua_pushliteral(L, s) \ lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) #define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) #define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) /* ** compatibility macros and functions */ #define lua_open() luaL_newstate() #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) #define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) #define lua_Chunkreader lua_Reader #define lua_Chunkwriter lua_Writer /* hack */ LUA_API void lua_setlevel (lua_State *from, lua_State *to); /* ** {====================================================================== ** Debug API ** ======================================================================= */ /* ** Event codes */ #define LUA_HOOKCALL 0 #define LUA_HOOKRET 1 #define LUA_HOOKLINE 2 #define LUA_HOOKCOUNT 3 #define LUA_HOOKTAILRET 4 /* ** Event masks */ #define LUA_MASKCALL (1 << LUA_HOOKCALL) #define LUA_MASKRET (1 << LUA_HOOKRET) #define LUA_MASKLINE (1 << LUA_HOOKLINE) #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) typedef struct lua_Debug lua_Debug; /* activation record */ /* Functions to be called by the debuger in specific events */ typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); LUA_API lua_Hook lua_gethook (lua_State *L); LUA_API int lua_gethookmask (lua_State *L); LUA_API int lua_gethookcount (lua_State *L); /* From Lua 5.2. */ LUA_API void *lua_upvalueid (lua_State *L, int idx, int n); LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2); LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode); struct lua_Debug { int event; const char *name; /* (n) */ const char *namewhat; /* (n) `global', `local', `field', `method' */ const char *what; /* (S) `Lua', `C', `main', `tail' */ const char *source; /* (S) */ int currentline; /* (l) */ int nups; /* (u) number of upvalues */ int linedefined; /* (S) */ int lastlinedefined; /* (S) */ char short_src[LUA_IDSIZE]; /* (S) */ /* private part */ int i_ci; /* active function */ }; /* }====================================================================== */ /****************************************************************************** * Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. * * 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. ******************************************************************************/ #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lua.hpp ================================================ // C++ wrapper for LuaJIT header files. extern "C" { #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "luajit.h" } ================================================ FILE: cocos2d/external/lua/luajit/src/src/luaconf.h ================================================ /* ** Configuration header. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef luaconf_h #define luaconf_h #include #include /* Default path for loading Lua and C modules with require(). */ #if defined(_WIN32) /* ** In Windows, any exclamation mark ('!') in the path is replaced by the ** path of the directory of the executable file of the current process. */ #define LUA_LDIR "!\\lua\\" #define LUA_CDIR "!\\" #define LUA_PATH_DEFAULT \ ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" #define LUA_CPATH_DEFAULT \ ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" #else /* ** Note to distribution maintainers: do NOT patch the following line! ** Please read ../doc/install.html#distro and pass PREFIX=/usr instead. */ #define LUA_ROOT "/usr/local/" #define LUA_LDIR LUA_ROOT "share/lua/5.1/" #define LUA_CDIR LUA_ROOT "lib/lua/5.1/" #ifdef LUA_XROOT #define LUA_JDIR LUA_XROOT "share/luajit-2.0.1/" #define LUA_XPATH \ ";" LUA_XROOT "share/lua/5.1/?.lua;" LUA_XROOT "share/lua/5.1/?/init.lua" #define LUA_XCPATH LUA_XROOT "lib/lua/5.1/?.so;" #else #define LUA_JDIR LUA_ROOT "share/luajit-2.0.1/" #define LUA_XPATH #define LUA_XCPATH #endif #define LUA_PATH_DEFAULT \ "./?.lua;" LUA_JDIR"?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua" LUA_XPATH #define LUA_CPATH_DEFAULT \ "./?.so;" LUA_CDIR"?.so;" LUA_XCPATH LUA_CDIR"loadall.so" #endif /* Environment variable names for path overrides and initialization code. */ #define LUA_PATH "LUA_PATH" #define LUA_CPATH "LUA_CPATH" #define LUA_INIT "LUA_INIT" /* Special file system characters. */ #if defined(_WIN32) #define LUA_DIRSEP "\\" #else #define LUA_DIRSEP "/" #endif #define LUA_PATHSEP ";" #define LUA_PATH_MARK "?" #define LUA_EXECDIR "!" #define LUA_IGMARK "-" #define LUA_PATH_CONFIG \ LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \ LUA_EXECDIR "\n" LUA_IGMARK /* Quoting in error messages. */ #define LUA_QL(x) "'" x "'" #define LUA_QS LUA_QL("%s") /* Various tunables. */ #define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */ #define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */ #define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */ #define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */ #define LUA_MAXCAPTURES 32 /* Max. pattern captures. */ /* Compatibility with older library function names. */ #define LUA_COMPAT_MOD /* OLD: math.mod, NEW: math.fmod */ #define LUA_COMPAT_GFIND /* OLD: string.gfind, NEW: string.gmatch */ /* Configuration for the frontend (the luajit executable). */ #if defined(luajit_c) #define LUA_PROGNAME "luajit" /* Fallback frontend name. */ #define LUA_PROMPT "> " /* Interactive prompt. */ #define LUA_PROMPT2 ">> " /* Continuation prompt. */ #define LUA_MAXINPUT 512 /* Max. input line length. */ #endif /* Note: changing the following defines breaks the Lua 5.1 ABI. */ #define LUA_INTEGER ptrdiff_t #define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */ /* ** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using ** unreasonable amounts of stack space, but still retain ABI compatibility. ** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it. */ #define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ) /* The following defines are here only for compatibility with luaconf.h ** from the standard Lua distribution. They must not be changed for LuaJIT. */ #define LUA_NUMBER_DOUBLE #define LUA_NUMBER double #define LUAI_UACNUMBER double #define LUA_NUMBER_SCAN "%lf" #define LUA_NUMBER_FMT "%.14g" #define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n)) #define LUAI_MAXNUMBER2STR 32 #define LUA_INTFRMLEN "l" #define LUA_INTFRM_T long /* Linkage of public API functions. */ #if defined(LUA_BUILD_AS_DLL) #if defined(LUA_CORE) || defined(LUA_LIB) #define LUA_API __declspec(dllexport) #else #define LUA_API __declspec(dllimport) #endif #else #define LUA_API extern #endif #define LUALIB_API LUA_API /* Support for internal assertions. */ #if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) #include #endif #ifdef LUA_USE_ASSERT #define lua_assert(x) assert(x) #endif #ifdef LUA_USE_APICHECK #define luai_apicheck(L, o) { (void)L; assert(o); } #else #define luai_apicheck(L, o) { (void)L; } #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/luajit.c ================================================ /* ** LuaJIT frontend. Runs commands, scripts, read-eval-print (REPL) etc. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h */ #include #include #include #define luajit_c #include "lua.h" #include "lauxlib.h" #include "lualib.h" #include "luajit.h" #include "lj_arch.h" #if LJ_TARGET_POSIX #include #define lua_stdin_is_tty() isatty(0) #elif LJ_TARGET_WINDOWS #include #ifdef __BORLANDC__ #define lua_stdin_is_tty() isatty(_fileno(stdin)) #else #define lua_stdin_is_tty() _isatty(_fileno(stdin)) #endif #else #define lua_stdin_is_tty() 1 #endif #if !LJ_TARGET_CONSOLE #include #endif static lua_State *globalL = NULL; static const char *progname = LUA_PROGNAME; #if !LJ_TARGET_CONSOLE static void lstop(lua_State *L, lua_Debug *ar) { (void)ar; /* unused arg. */ lua_sethook(L, NULL, 0, 0); /* Avoid luaL_error -- a C hook doesn't add an extra frame. */ luaL_where(L, 0); lua_pushfstring(L, "%sinterrupted!", lua_tostring(L, -1)); lua_error(L); } static void laction(int i) { signal(i, SIG_DFL); /* if another SIGINT happens before lstop, terminate process (default action) */ lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1); } #endif static void print_usage(void) { fprintf(stderr, "usage: %s [options]... [script [args]...].\n" "Available options are:\n" " -e chunk Execute string " LUA_QL("chunk") ".\n" " -l name Require library " LUA_QL("name") ".\n" " -b ... Save or list bytecode.\n" " -j cmd Perform LuaJIT control command.\n" " -O[opt] Control LuaJIT optimizations.\n" " -i Enter interactive mode after executing " LUA_QL("script") ".\n" " -v Show version information.\n" " -E Ignore environment variables.\n" " -- Stop handling options.\n" " - Execute stdin and stop handling options.\n" , progname); fflush(stderr); } static void l_message(const char *pname, const char *msg) { if (pname) fprintf(stderr, "%s: ", pname); fprintf(stderr, "%s\n", msg); fflush(stderr); } static int report(lua_State *L, int status) { if (status && !lua_isnil(L, -1)) { const char *msg = lua_tostring(L, -1); if (msg == NULL) msg = "(error object is not a string)"; l_message(progname, msg); lua_pop(L, 1); } return status; } static int traceback(lua_State *L) { if (!lua_isstring(L, 1)) { /* Non-string error object? Try metamethod. */ if (lua_isnoneornil(L, 1) || !luaL_callmeta(L, 1, "__tostring") || !lua_isstring(L, -1)) return 1; /* Return non-string error object. */ lua_remove(L, 1); /* Replace object by result of __tostring metamethod. */ } luaL_traceback(L, L, lua_tostring(L, 1), 1); return 1; } static int docall(lua_State *L, int narg, int clear) { int status; int base = lua_gettop(L) - narg; /* function index */ lua_pushcfunction(L, traceback); /* push traceback function */ lua_insert(L, base); /* put it under chunk and args */ #if !LJ_TARGET_CONSOLE signal(SIGINT, laction); #endif status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); #if !LJ_TARGET_CONSOLE signal(SIGINT, SIG_DFL); #endif lua_remove(L, base); /* remove traceback function */ /* force a complete garbage collection in case of errors */ if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); return status; } static void print_version(void) { fputs(LUAJIT_VERSION " -- " LUAJIT_COPYRIGHT ". " LUAJIT_URL "\n", stdout); } static void print_jit_status(lua_State *L) { int n; const char *s; lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ lua_remove(L, -2); lua_getfield(L, -1, "status"); lua_remove(L, -2); n = lua_gettop(L); lua_call(L, 0, LUA_MULTRET); fputs(lua_toboolean(L, n) ? "JIT: ON" : "JIT: OFF", stdout); for (n++; (s = lua_tostring(L, n)); n++) { putc(' ', stdout); fputs(s, stdout); } putc('\n', stdout); } static int getargs(lua_State *L, char **argv, int n) { int narg; int i; int argc = 0; while (argv[argc]) argc++; /* count total number of arguments */ narg = argc - (n + 1); /* number of arguments to the script */ luaL_checkstack(L, narg + 3, "too many arguments to script"); for (i = n+1; i < argc; i++) lua_pushstring(L, argv[i]); lua_createtable(L, narg, n + 1); for (i = 0; i < argc; i++) { lua_pushstring(L, argv[i]); lua_rawseti(L, -2, i - n); } return narg; } static int dofile(lua_State *L, const char *name) { int status = luaL_loadfile(L, name) || docall(L, 0, 1); return report(L, status); } static int dostring(lua_State *L, const char *s, const char *name) { int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1); return report(L, status); } static int dolibrary(lua_State *L, const char *name) { lua_getglobal(L, "require"); lua_pushstring(L, name); return report(L, docall(L, 1, 1)); } static void write_prompt(lua_State *L, int firstline) { const char *p; lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2"); p = lua_tostring(L, -1); if (p == NULL) p = firstline ? LUA_PROMPT : LUA_PROMPT2; fputs(p, stdout); fflush(stdout); lua_pop(L, 1); /* remove global */ } static int incomplete(lua_State *L, int status) { if (status == LUA_ERRSYNTAX) { size_t lmsg; const char *msg = lua_tolstring(L, -1, &lmsg); const char *tp = msg + lmsg - (sizeof(LUA_QL("")) - 1); if (strstr(msg, LUA_QL("")) == tp) { lua_pop(L, 1); return 1; } } return 0; /* else... */ } static int pushline(lua_State *L, int firstline) { char buf[LUA_MAXINPUT]; write_prompt(L, firstline); if (fgets(buf, LUA_MAXINPUT, stdin)) { size_t len = strlen(buf); if (len > 0 && buf[len-1] == '\n') buf[len-1] = '\0'; if (firstline && buf[0] == '=') lua_pushfstring(L, "return %s", buf+1); else lua_pushstring(L, buf); return 1; } return 0; } static int loadline(lua_State *L) { int status; lua_settop(L, 0); if (!pushline(L, 1)) return -1; /* no input */ for (;;) { /* repeat until gets a complete line */ status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); if (!incomplete(L, status)) break; /* cannot try to add lines? */ if (!pushline(L, 0)) /* no more input? */ return -1; lua_pushliteral(L, "\n"); /* add a new line... */ lua_insert(L, -2); /* ...between the two lines */ lua_concat(L, 3); /* join them */ } lua_remove(L, 1); /* remove line */ return status; } static void dotty(lua_State *L) { int status; const char *oldprogname = progname; progname = NULL; while ((status = loadline(L)) != -1) { if (status == 0) status = docall(L, 0, 0); report(L, status); if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ lua_getglobal(L, "print"); lua_insert(L, 1); if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) l_message(progname, lua_pushfstring(L, "error calling " LUA_QL("print") " (%s)", lua_tostring(L, -1))); } } lua_settop(L, 0); /* clear stack */ fputs("\n", stdout); fflush(stdout); progname = oldprogname; } static int handle_script(lua_State *L, char **argv, int n) { int status; const char *fname; int narg = getargs(L, argv, n); /* collect arguments */ lua_setglobal(L, "arg"); fname = argv[n]; if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0) fname = NULL; /* stdin */ status = luaL_loadfile(L, fname); lua_insert(L, -(narg+1)); if (status == 0) status = docall(L, narg, 0); else lua_pop(L, narg); return report(L, status); } /* Load add-on module. */ static int loadjitmodule(lua_State *L) { lua_getglobal(L, "require"); lua_pushliteral(L, "jit."); lua_pushvalue(L, -3); lua_concat(L, 2); if (lua_pcall(L, 1, 1, 0)) { const char *msg = lua_tostring(L, -1); if (msg && !strncmp(msg, "module ", 7)) { err: l_message(progname, "unknown luaJIT command or jit.* modules not installed"); return 1; } else { return report(L, 1); } } lua_getfield(L, -1, "start"); if (lua_isnil(L, -1)) goto err; lua_remove(L, -2); /* Drop module table. */ return 0; } /* Run command with options. */ static int runcmdopt(lua_State *L, const char *opt) { int narg = 0; if (opt && *opt) { for (;;) { /* Split arguments. */ const char *p = strchr(opt, ','); narg++; if (!p) break; if (p == opt) lua_pushnil(L); else lua_pushlstring(L, opt, (size_t)(p - opt)); opt = p + 1; } if (*opt) lua_pushstring(L, opt); else lua_pushnil(L); } return report(L, lua_pcall(L, narg, 0, 0)); } /* JIT engine control command: try jit library first or load add-on module. */ static int dojitcmd(lua_State *L, const char *cmd) { const char *opt = strchr(cmd, '='); lua_pushlstring(L, cmd, opt ? (size_t)(opt - cmd) : strlen(cmd)); lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); lua_getfield(L, -1, "jit"); /* Get jit.* module table. */ lua_remove(L, -2); lua_pushvalue(L, -2); lua_gettable(L, -2); /* Lookup library function. */ if (!lua_isfunction(L, -1)) { lua_pop(L, 2); /* Drop non-function and jit.* table, keep module name. */ if (loadjitmodule(L)) return 1; } else { lua_remove(L, -2); /* Drop jit.* table. */ } lua_remove(L, -2); /* Drop module name. */ return runcmdopt(L, opt ? opt+1 : opt); } /* Optimization flags. */ static int dojitopt(lua_State *L, const char *opt) { lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); lua_getfield(L, -1, "jit.opt"); /* Get jit.opt.* module table. */ lua_remove(L, -2); lua_getfield(L, -1, "start"); lua_remove(L, -2); return runcmdopt(L, opt); } /* Save or list bytecode. */ static int dobytecode(lua_State *L, char **argv) { int narg = 0; lua_pushliteral(L, "bcsave"); if (loadjitmodule(L)) return 1; if (argv[0][2]) { narg++; argv[0][1] = '-'; lua_pushstring(L, argv[0]+1); } for (argv++; *argv != NULL; narg++, argv++) lua_pushstring(L, *argv); return report(L, lua_pcall(L, narg, 0, 0)); } /* check that argument has no extra characters at the end */ #define notail(x) {if ((x)[2] != '\0') return -1;} #define FLAGS_INTERACTIVE 1 #define FLAGS_VERSION 2 #define FLAGS_EXEC 4 #define FLAGS_OPTION 8 #define FLAGS_NOENV 16 static int collectargs(char **argv, int *flags) { int i; for (i = 1; argv[i] != NULL; i++) { if (argv[i][0] != '-') /* Not an option? */ return i; switch (argv[i][1]) { /* Check option. */ case '-': notail(argv[i]); return (argv[i+1] != NULL ? i+1 : 0); case '\0': return i; case 'i': notail(argv[i]); *flags |= FLAGS_INTERACTIVE; /* fallthrough */ case 'v': notail(argv[i]); *flags |= FLAGS_VERSION; break; case 'e': *flags |= FLAGS_EXEC; case 'j': /* LuaJIT extension */ case 'l': *flags |= FLAGS_OPTION; if (argv[i][2] == '\0') { i++; if (argv[i] == NULL) return -1; } break; case 'O': break; /* LuaJIT extension */ case 'b': /* LuaJIT extension */ if (*flags) return -1; *flags |= FLAGS_EXEC; return 0; case 'E': *flags |= FLAGS_NOENV; break; default: return -1; /* invalid option */ } } return 0; } static int runargs(lua_State *L, char **argv, int n) { int i; for (i = 1; i < n; i++) { if (argv[i] == NULL) continue; lua_assert(argv[i][0] == '-'); switch (argv[i][1]) { /* option */ case 'e': { const char *chunk = argv[i] + 2; if (*chunk == '\0') chunk = argv[++i]; lua_assert(chunk != NULL); if (dostring(L, chunk, "=(command line)") != 0) return 1; break; } case 'l': { const char *filename = argv[i] + 2; if (*filename == '\0') filename = argv[++i]; lua_assert(filename != NULL); if (dolibrary(L, filename)) return 1; /* stop if file fails */ break; } case 'j': { /* LuaJIT extension */ const char *cmd = argv[i] + 2; if (*cmd == '\0') cmd = argv[++i]; lua_assert(cmd != NULL); if (dojitcmd(L, cmd)) return 1; break; } case 'O': /* LuaJIT extension */ if (dojitopt(L, argv[i] + 2)) return 1; break; case 'b': /* LuaJIT extension */ return dobytecode(L, argv+i); default: break; } } return 0; } static int handle_luainit(lua_State *L) { #if LJ_TARGET_CONSOLE const char *init = NULL; #else const char *init = getenv(LUA_INIT); #endif if (init == NULL) return 0; /* status OK */ else if (init[0] == '@') return dofile(L, init+1); else return dostring(L, init, "=" LUA_INIT); } struct Smain { char **argv; int argc; int status; }; static int pmain(lua_State *L) { struct Smain *s = (struct Smain *)lua_touserdata(L, 1); char **argv = s->argv; int script; int flags = 0; globalL = L; if (argv[0] && argv[0][0]) progname = argv[0]; LUAJIT_VERSION_SYM(); /* linker-enforced version check */ script = collectargs(argv, &flags); if (script < 0) { /* invalid args? */ print_usage(); s->status = 1; return 0; } if ((flags & FLAGS_NOENV)) { lua_pushboolean(L, 1); lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); } lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ luaL_openlibs(L); /* open libraries */ lua_gc(L, LUA_GCRESTART, -1); if (!(flags & FLAGS_NOENV)) { s->status = handle_luainit(L); if (s->status != 0) return 0; } if ((flags & FLAGS_VERSION)) print_version(); s->status = runargs(L, argv, (script > 0) ? script : s->argc); if (s->status != 0) return 0; if (script) { s->status = handle_script(L, argv, script); if (s->status != 0) return 0; } if ((flags & FLAGS_INTERACTIVE)) { print_jit_status(L); dotty(L); } else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) { if (lua_stdin_is_tty()) { print_version(); print_jit_status(L); dotty(L); } else { dofile(L, NULL); /* executes stdin as a file */ } } return 0; } int main(int argc, char **argv) { int status; struct Smain s; lua_State *L = lua_open(); /* create state */ if (L == NULL) { l_message(argv[0], "cannot create state: not enough memory"); return EXIT_FAILURE; } s.argc = argc; s.argv = argv; status = lua_cpcall(L, pmain, &s); report(L, status); lua_close(L); return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; } ================================================ FILE: cocos2d/external/lua/luajit/src/src/luajit.h ================================================ /* ** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ ** ** Copyright (C) 2005-2013 Mike Pall. All rights reserved. ** ** 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. ** ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] */ #ifndef _LUAJIT_H #define _LUAJIT_H #include "lua.h" #define LUAJIT_VERSION "LuaJIT 2.0.1" #define LUAJIT_VERSION_NUM 20001 /* Version 2.0.1 = 02.00.01. */ #define LUAJIT_VERSION_SYM luaJIT_version_2_0_1 #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2013 Mike Pall" #define LUAJIT_URL "http://luajit.org/" /* Modes for luaJIT_setmode. */ #define LUAJIT_MODE_MASK 0x00ff enum { LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ LUAJIT_MODE_FUNC, /* Change mode for a function. */ LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ LUAJIT_MODE_MAX }; /* Flags or'ed in to the mode. */ #define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ #define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ #define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ /* LuaJIT public C API. */ /* Control the JIT engine. */ LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); /* Enforce (dynamic) linker error for version mismatches. Call from main. */ LUA_API void LUAJIT_VERSION_SYM(void); #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/lualib.h ================================================ /* ** Standard library header. ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h */ #ifndef _LUALIB_H #define _LUALIB_H #include "lua.h" #define LUA_FILEHANDLE "FILE*" #define LUA_COLIBNAME "coroutine" #define LUA_MATHLIBNAME "math" #define LUA_STRLIBNAME "string" #define LUA_TABLIBNAME "table" #define LUA_IOLIBNAME "io" #define LUA_OSLIBNAME "os" #define LUA_LOADLIBNAME "package" #define LUA_DBLIBNAME "debug" #define LUA_BITLIBNAME "bit" #define LUA_JITLIBNAME "jit" #define LUA_FFILIBNAME "ffi" LUALIB_API int luaopen_base(lua_State *L); LUALIB_API int luaopen_math(lua_State *L); LUALIB_API int luaopen_string(lua_State *L); LUALIB_API int luaopen_table(lua_State *L); LUALIB_API int luaopen_io(lua_State *L); LUALIB_API int luaopen_os(lua_State *L); LUALIB_API int luaopen_package(lua_State *L); LUALIB_API int luaopen_debug(lua_State *L); LUALIB_API int luaopen_bit(lua_State *L); LUALIB_API int luaopen_jit(lua_State *L); LUALIB_API int luaopen_ffi(lua_State *L); LUALIB_API void luaL_openlibs(lua_State *L); #ifndef lua_assert #define lua_assert(x) ((void)0) #endif #endif ================================================ FILE: cocos2d/external/lua/luajit/src/src/msvcbuild.bat ================================================ @rem Script to build LuaJIT with MSVC. @rem Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h @rem @rem Either open a "Visual Studio .NET Command Prompt" @rem (Note that the Express Edition does not contain an x64 compiler) @rem -or- @rem Open a "Windows SDK Command Shell" and set the compiler environment: @rem setenv /release /x86 @rem -or- @rem setenv /release /x64 @rem @rem Then cd to this directory and run this script. @if not defined INCLUDE goto :FAIL @setlocal @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE @set LJLINK=link /nologo @set LJMT=mt /nologo @set LJLIB=lib /nologo @set DASMDIR=..\dynasm @set DASM=%DASMDIR%\dynasm.lua @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c %LJCOMPILE% host\minilua.c @if errorlevel 1 goto :BAD %LJLINK% /out:minilua.exe minilua.obj @if errorlevel 1 goto :BAD if exist minilua.exe.manifest^ %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe @set DASMFLAGS=-D WIN -D JIT -D FFI -D P64 @set LJARCH=x64 @minilua @if errorlevel 8 goto :X64 @set DASMFLAGS=-D WIN -D JIT -D FFI @set LJARCH=x86 :X64 minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc @if errorlevel 1 goto :BAD %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c @if errorlevel 1 goto :BAD %LJLINK% /out:buildvm.exe buildvm*.obj @if errorlevel 1 goto :BAD if exist buildvm.exe.manifest^ %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe buildvm -m peobj -o lj_vm.obj @if errorlevel 1 goto :BAD buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m libdef -o lj_libdef.h %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m recdef -o lj_recdef.h %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m folddef -o lj_folddef.h lj_opt_fold.c @if errorlevel 1 goto :BAD @if "%1" neq "debug" goto :NODEBUG @shift @set LJCOMPILE=%LJCOMPILE% /Zi @set LJLINK=%LJLINK% /debug :NODEBUG @if "%1"=="amalg" goto :AMALGDLL @if "%1"=="static" goto :STATIC %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c @if errorlevel 1 goto :BAD %LJLINK% /DLL /out:lua51.dll lj_*.obj lib_*.obj @if errorlevel 1 goto :BAD @goto :MTDLL :STATIC %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c @if errorlevel 1 goto :BAD %LJLIB% /OUT:lua51.lib lj_*.obj lib_*.obj @if errorlevel 1 goto :BAD @goto :MTDLL :AMALGDLL %LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c @if errorlevel 1 goto :BAD %LJLINK% /DLL /out:lua51.dll ljamalg.obj lj_vm.obj @if errorlevel 1 goto :BAD :MTDLL if exist lua51.dll.manifest^ %LJMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2 %LJCOMPILE% luajit.c @if errorlevel 1 goto :BAD %LJLINK% /out:luajit.exe luajit.obj lua51.lib @if errorlevel 1 goto :BAD if exist luajit.exe.manifest^ %LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe @del *.obj *.manifest minilua.exe buildvm.exe @echo. @echo === Successfully built LuaJIT for Windows/%LJARCH% === @goto :END :BAD @echo. @echo ******************************************************* @echo *** Build FAILED -- Please check the error messages *** @echo ******************************************************* @goto :END :FAIL @echo You must open a "Visual Studio .NET Command Prompt" to run this script :END ================================================ FILE: cocos2d/external/lua/luajit/src/src/vm_arm.dasc ================================================ |// Low-level VM code for ARM CPUs. |// Bytecode interpreter, fast functions and helper functions. |// Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h | |.arch arm |.section code_op, code_sub | |.actionlist build_actionlist |.globals GLOB_ |.globalnames globnames |.externnames extnames | |// Note: The ragged indentation of the instructions is intentional. |// The starting columns indicate data dependencies. | |//----------------------------------------------------------------------- | |// Fixed register assignments for the interpreter. | |// The following must be C callee-save. |.define MASKR8, r4 // 255*8 constant for fast bytecode decoding. |.define KBASE, r5 // Constants of current Lua function. |.define PC, r6 // Next PC. |.define DISPATCH, r7 // Opcode dispatch table. |.define LREG, r8 // Register holding lua_State (also in SAVE_L). | |// C callee-save in EABI, but often refetched. Temporary in iOS 3.0+. |.define BASE, r9 // Base of current Lua stack frame. | |// The following temporaries are not saved across C calls, except for RA/RC. |.define RA, r10 // Callee-save. |.define RC, r11 // Callee-save. |.define RB, r12 |.define OP, r12 // Overlaps RB, must not be lr. |.define INS, lr | |// Calling conventions. Also used as temporaries. |.define CARG1, r0 |.define CARG2, r1 |.define CARG3, r2 |.define CARG4, r3 |.define CARG12, r0 // For 1st soft-fp double. |.define CARG34, r2 // For 2nd soft-fp double. | |.define CRET1, r0 |.define CRET2, r1 | |// Stack layout while in interpreter. Must match with lj_frame.h. |.define SAVE_R4, [sp, #28] |.define CFRAME_SPACE, #28 |.define SAVE_ERRF, [sp, #24] |.define SAVE_NRES, [sp, #20] |.define SAVE_CFRAME, [sp, #16] |.define SAVE_L, [sp, #12] |.define SAVE_PC, [sp, #8] |.define SAVE_MULTRES, [sp, #4] |.define ARG5, [sp] | |.define TMPDhi, [sp, #4] |.define TMPDlo, [sp] |.define TMPD, [sp] |.define TMPDp, sp | |.if FPU |.macro saveregs | push {r5, r6, r7, r8, r9, r10, r11, lr} | vpush {d8-d15} | sub sp, sp, CFRAME_SPACE+4 | str r4, SAVE_R4 |.endmacro |.macro restoreregs_ret | ldr r4, SAVE_R4 | add sp, sp, CFRAME_SPACE+4 | vpop {d8-d15} | pop {r5, r6, r7, r8, r9, r10, r11, pc} |.endmacro |.else |.macro saveregs | push {r4, r5, r6, r7, r8, r9, r10, r11, lr} | sub sp, sp, CFRAME_SPACE |.endmacro |.macro restoreregs_ret | add sp, sp, CFRAME_SPACE | pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} |.endmacro |.endif | |// Type definitions. Some of these are only used for documentation. |.type L, lua_State, LREG |.type GL, global_State |.type TVALUE, TValue |.type GCOBJ, GCobj |.type STR, GCstr |.type TAB, GCtab |.type LFUNC, GCfuncL |.type CFUNC, GCfuncC |.type PROTO, GCproto |.type UPVAL, GCupval |.type NODE, Node |.type NARGS8, int |.type TRACE, GCtrace | |//----------------------------------------------------------------------- | |// Trap for not-yet-implemented parts. |.macro NYI; ud; .endmacro | |//----------------------------------------------------------------------- | |// Access to frame relative to BASE. |.define FRAME_FUNC, #-8 |.define FRAME_PC, #-4 | |.macro decode_RA8, dst, ins; and dst, MASKR8, ins, lsr #5; .endmacro |.macro decode_RB8, dst, ins; and dst, MASKR8, ins, lsr #21; .endmacro |.macro decode_RC8, dst, ins; and dst, MASKR8, ins, lsr #13; .endmacro |.macro decode_RD, dst, ins; lsr dst, ins, #16; .endmacro |.macro decode_OP, dst, ins; and dst, ins, #255; .endmacro | |// Instruction fetch. |.macro ins_NEXT1 | ldrb OP, [PC] |.endmacro |.macro ins_NEXT2 | ldr INS, [PC], #4 |.endmacro |// Instruction decode+dispatch. |.macro ins_NEXT3 | ldr OP, [DISPATCH, OP, lsl #2] | decode_RA8 RA, INS | decode_RD RC, INS | bx OP |.endmacro |.macro ins_NEXT | ins_NEXT1 | ins_NEXT2 | ins_NEXT3 |.endmacro | |// Instruction footer. |.if 1 | // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. | .define ins_next, ins_NEXT | .define ins_next_, ins_NEXT | .define ins_next1, ins_NEXT1 | .define ins_next2, ins_NEXT2 | .define ins_next3, ins_NEXT3 |.else | // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. | // Affects only certain kinds of benchmarks (and only with -j off). | .macro ins_next | b ->ins_next | .endmacro | .macro ins_next1 | .endmacro | .macro ins_next2 | .endmacro | .macro ins_next3 | b ->ins_next | .endmacro | .macro ins_next_ | ->ins_next: | ins_NEXT | .endmacro |.endif | |// Avoid register name substitution for field name. #define field_pc pc | |// Call decode and dispatch. |.macro ins_callt | // BASE = new base, CARG3 = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC | ldr PC, LFUNC:CARG3->field_pc | ldrb OP, [PC] // STALL: load PC. early PC. | ldr INS, [PC], #4 | ldr OP, [DISPATCH, OP, lsl #2] // STALL: load OP. early OP. | decode_RA8 RA, INS | add RA, RA, BASE | bx OP |.endmacro | |.macro ins_call | // BASE = new base, CARG3 = LFUNC/CFUNC, RC = nargs*8, PC = caller PC | str PC, [BASE, FRAME_PC] | ins_callt // STALL: locked PC. |.endmacro | |//----------------------------------------------------------------------- | |// Macros to test operand types. |.macro checktp, reg, tp; cmn reg, #-tp; .endmacro |.macro checktpeq, reg, tp; cmneq reg, #-tp; .endmacro |.macro checktpne, reg, tp; cmnne reg, #-tp; .endmacro |.macro checkstr, reg, target; checktp reg, LJ_TSTR; bne target; .endmacro |.macro checktab, reg, target; checktp reg, LJ_TTAB; bne target; .endmacro |.macro checkfunc, reg, target; checktp reg, LJ_TFUNC; bne target; .endmacro | |// Assumes DISPATCH is relative to GL. #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) | #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) | |.macro hotcheck, delta | lsr CARG1, PC, #1 | and CARG1, CARG1, #126 | sub CARG1, CARG1, #-GG_DISP2HOT | ldrh CARG2, [DISPATCH, CARG1] | subs CARG2, CARG2, #delta | strh CARG2, [DISPATCH, CARG1] |.endmacro | |.macro hotloop | hotcheck HOTCOUNT_LOOP | blo ->vm_hotloop |.endmacro | |.macro hotcall | hotcheck HOTCOUNT_CALL | blo ->vm_hotcall |.endmacro | |// Set current VM state. |.macro mv_vmstate, reg, st; mvn reg, #LJ_VMST_..st; .endmacro |.macro st_vmstate, reg; str reg, [DISPATCH, #DISPATCH_GL(vmstate)]; .endmacro | |// Move table write barrier back. Overwrites mark and tmp. |.macro barrierback, tab, mark, tmp | ldr tmp, [DISPATCH, #DISPATCH_GL(gc.grayagain)] | bic mark, mark, #LJ_GC_BLACK // black2gray(tab) | str tab, [DISPATCH, #DISPATCH_GL(gc.grayagain)] | strb mark, tab->marked | str tmp, tab->gclist |.endmacro | |.macro .IOS, a, b |.if IOS | a, b |.endif |.endmacro | |//----------------------------------------------------------------------- #if !LJ_DUALNUM #error "Only dual-number mode supported for ARM target" #endif /* Generate subroutines used by opcodes and other parts of the VM. */ /* The .code_sub section should be last to help static branch prediction. */ static void build_subroutines(BuildCtx *ctx) { |.code_sub | |//----------------------------------------------------------------------- |//-- Return handling ---------------------------------------------------- |//----------------------------------------------------------------------- | |->vm_returnp: | // See vm_return. Also: RB = previous base. | tst PC, #FRAME_P | beq ->cont_dispatch | | // Return from pcall or xpcall fast func. | ldr PC, [RB, FRAME_PC] // Fetch PC of previous frame. | mvn CARG2, #~LJ_TTRUE | mov BASE, RB | // Prepending may overwrite the pcall frame, so do it at the end. | str CARG2, [RA, FRAME_PC] // Prepend true to results. | sub RA, RA, #8 | |->vm_returnc: | adds RC, RC, #8 // RC = (nresults+1)*8. | mov CRET1, #LUA_YIELD | beq ->vm_unwind_c_eh | str RC, SAVE_MULTRES | ands CARG1, PC, #FRAME_TYPE | beq ->BC_RET_Z // Handle regular return to Lua. | |->vm_return: | // BASE = base, RA = resultptr, RC/MULTRES = (nresults+1)*8, PC = return | // CARG1 = PC & FRAME_TYPE | bic RB, PC, #FRAME_TYPEP | cmp CARG1, #FRAME_C | sub RB, BASE, RB // RB = previous base. | bne ->vm_returnp | | str RB, L->base | ldr KBASE, SAVE_NRES | mv_vmstate CARG4, C | sub BASE, BASE, #8 | subs CARG3, RC, #8 | lsl KBASE, KBASE, #3 // KBASE = (nresults_wanted+1)*8 | st_vmstate CARG4 | beq >2 |1: | subs CARG3, CARG3, #8 | ldrd CARG12, [RA], #8 | strd CARG12, [BASE], #8 | bne <1 |2: | cmp KBASE, RC // More/less results wanted? | bne >6 |3: | str BASE, L->top // Store new top. | |->vm_leave_cp: | ldr RC, SAVE_CFRAME // Restore previous C frame. | mov CRET1, #0 // Ok return status for vm_pcall. | str RC, L->cframe | |->vm_leave_unw: | restoreregs_ret | |6: | blt >7 // Less results wanted? | // More results wanted. Check stack size and fill up results with nil. | ldr CARG3, L->maxstack | mvn CARG2, #~LJ_TNIL | cmp BASE, CARG3 | bhs >8 | str CARG2, [BASE, #4] | add RC, RC, #8 | add BASE, BASE, #8 | b <2 | |7: // Less results wanted. | sub CARG1, RC, KBASE | cmp KBASE, #0 // LUA_MULTRET+1 case? | subne BASE, BASE, CARG1 // Either keep top or shrink it. | b <3 | |8: // Corner case: need to grow stack for filling up results. | // This can happen if: | // - A C function grows the stack (a lot). | // - The GC shrinks the stack in between. | // - A return back from a lua_call() with (high) nresults adjustment. | str BASE, L->top // Save current top held in BASE (yes). | mov CARG2, KBASE | mov CARG1, L | bl extern lj_state_growstack // (lua_State *L, int n) | ldr BASE, L->top // Need the (realloced) L->top in BASE. | b <2 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. | // (void *cframe, int errcode) | mov sp, CARG1 | mov CRET1, CARG2 |->vm_unwind_c_eh: // Landing pad for external unwinder. | ldr L, SAVE_L | mv_vmstate CARG4, C | ldr GL:CARG3, L->glref | str CARG4, GL:CARG3->vmstate | b ->vm_leave_unw | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. | // (void *cframe) | bic CARG1, CARG1, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. | mov sp, CARG1 |->vm_unwind_ff_eh: // Landing pad for external unwinder. | ldr L, SAVE_L | mov MASKR8, #255 | mov RC, #16 // 2 results: false + error message. | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. | ldr BASE, L->base | ldr DISPATCH, L->glref // Setup pointer to dispatch table. | mvn CARG1, #~LJ_TFALSE | sub RA, BASE, #8 // Results start at BASE-8. | ldr PC, [BASE, FRAME_PC] // Fetch PC of previous frame. | add DISPATCH, DISPATCH, #GG_G2DISP | mv_vmstate CARG2, INTERP | str CARG1, [BASE, #-4] // Prepend false to error message. | st_vmstate CARG2 | b ->vm_returnc | |//----------------------------------------------------------------------- |//-- Grow stack for calls ----------------------------------------------- |//----------------------------------------------------------------------- | |->vm_growstack_c: // Grow stack for C function. | // CARG1 = L | mov CARG2, #LUA_MINSTACK | b >2 | |->vm_growstack_l: // Grow stack for Lua function. | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC | add RC, BASE, RC | sub RA, RA, BASE | mov CARG1, L | str BASE, L->base | add PC, PC, #4 // Must point after first instruction. | str RC, L->top | lsr CARG3, RA, #3 |2: | // L->base = new base, L->top = top | str PC, SAVE_PC | bl extern lj_state_growstack // (lua_State *L, int n) | ldr BASE, L->base | ldr RC, L->top | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] | sub NARGS8:RC, RC, BASE | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC | ins_callt // Just retry the call. | |//----------------------------------------------------------------------- |//-- Entry points into the assembler VM --------------------------------- |//----------------------------------------------------------------------- | |->vm_resume: // Setup C frame and resume thread. | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) | saveregs | mov L, CARG1 | ldr DISPATCH, L:CARG1->glref // Setup pointer to dispatch table. | mov BASE, CARG2 | add DISPATCH, DISPATCH, #GG_G2DISP | str L, SAVE_L | mov PC, #FRAME_CP | str CARG3, SAVE_NRES | add CARG2, sp, #CFRAME_RESUME | ldrb CARG1, L->status | str CARG3, SAVE_ERRF | str CARG2, L->cframe | str CARG3, SAVE_CFRAME | cmp CARG1, #0 | str L, SAVE_PC // Any value outside of bytecode is ok. | beq >3 | | // Resume after yield (like a return). | mov RA, BASE | ldr BASE, L->base | ldr CARG1, L->top | mov MASKR8, #255 | strb CARG3, L->status | sub RC, CARG1, BASE | ldr PC, [BASE, FRAME_PC] | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. | mv_vmstate CARG2, INTERP | add RC, RC, #8 | ands CARG1, PC, #FRAME_TYPE | st_vmstate CARG2 | str RC, SAVE_MULTRES | beq ->BC_RET_Z | b ->vm_return | |->vm_pcall: // Setup protected C frame and enter VM. | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) | saveregs | mov PC, #FRAME_CP | str CARG4, SAVE_ERRF | b >1 | |->vm_call: // Setup C frame and enter VM. | // (lua_State *L, TValue *base, int nres1) | saveregs | mov PC, #FRAME_C | |1: // Entry point for vm_pcall above (PC = ftype). | ldr RC, L:CARG1->cframe | str CARG3, SAVE_NRES | mov L, CARG1 | str CARG1, SAVE_L | mov BASE, CARG2 | str sp, L->cframe // Add our C frame to cframe chain. | ldr DISPATCH, L->glref // Setup pointer to dispatch table. | str CARG1, SAVE_PC // Any value outside of bytecode is ok. | str RC, SAVE_CFRAME | add DISPATCH, DISPATCH, #GG_G2DISP | |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). | ldr RB, L->base // RB = old base (for vmeta_call). | ldr CARG1, L->top | mov MASKR8, #255 | add PC, PC, BASE | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. | sub PC, PC, RB // PC = frame delta + frame type | mv_vmstate CARG2, INTERP | sub NARGS8:RC, CARG1, BASE | st_vmstate CARG2 | |->vm_call_dispatch: | // RB = old base, BASE = new base, RC = nargs*8, PC = caller PC | ldrd CARG34, [BASE, FRAME_FUNC] | checkfunc CARG4, ->vmeta_call | |->vm_call_dispatch_f: | ins_call | // BASE = new base, CARG3 = func, RC = nargs*8, PC = caller PC | |->vm_cpcall: // Setup protected C frame, call C. | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) | saveregs | mov L, CARG1 | ldr RA, L:CARG1->stack | str CARG1, SAVE_L | ldr RB, L->top | str CARG1, SAVE_PC // Any value outside of bytecode is ok. | ldr RC, L->cframe | sub RA, RA, RB // Compute -savestack(L, L->top). | str sp, L->cframe // Add our C frame to cframe chain. | mov RB, #0 | str RA, SAVE_NRES // Neg. delta means cframe w/o frame. | str RB, SAVE_ERRF // No error function. | str RC, SAVE_CFRAME | blx CARG4 // (lua_State *L, lua_CFunction func, void *ud) | ldr DISPATCH, L->glref // Setup pointer to dispatch table. | movs BASE, CRET1 | mov PC, #FRAME_CP | add DISPATCH, DISPATCH, #GG_G2DISP | bne <3 // Else continue with the call. | b ->vm_leave_cp // No base? Just remove C frame. | |//----------------------------------------------------------------------- |//-- Metamethod handling ------------------------------------------------ |//----------------------------------------------------------------------- | |//-- Continuation dispatch ---------------------------------------------- | |->cont_dispatch: | // BASE = meta base, RA = resultptr, RC = (nresults+1)*8 | ldr LFUNC:CARG3, [RB, FRAME_FUNC] | ldr CARG1, [BASE, #-16] // Get continuation. | mov CARG4, BASE | mov BASE, RB // Restore caller BASE. |.if FFI | cmp CARG1, #1 |.endif | ldr PC, [CARG4, #-12] // Restore PC from [cont|PC]. | ldr CARG3, LFUNC:CARG3->field_pc | mvn INS, #~LJ_TNIL | add CARG2, RA, RC | str INS, [CARG2, #-4] // Ensure one valid arg. |.if FFI | bls >1 |.endif | ldr KBASE, [CARG3, #PC2PROTO(k)] | // BASE = base, RA = resultptr, CARG4 = meta base | bx CARG1 | |.if FFI |1: | beq ->cont_ffi_callback // cont = 1: return from FFI callback. | // cont = 0: tailcall from C function. | ldr CARG3, [BASE, FRAME_FUNC] | sub CARG4, CARG4, #16 | sub RC, CARG4, BASE | b ->vm_call_tail |.endif | |->cont_cat: // RA = resultptr, CARG4 = meta base | ldr INS, [PC, #-4] | sub CARG2, CARG4, #16 | ldrd CARG34, [RA] | str BASE, L->base | decode_RB8 RC, INS | decode_RA8 RA, INS | add CARG1, BASE, RC | subs CARG1, CARG2, CARG1 | strdne CARG34, [CARG2] | movne CARG3, CARG1 | bne ->BC_CAT_Z | strd CARG34, [BASE, RA] | b ->cont_nop | |//-- Table indexing metamethods ----------------------------------------- | |->vmeta_tgets1: | add CARG2, BASE, RB | b >2 | |->vmeta_tgets: | sub CARG2, DISPATCH, #-DISPATCH_GL(tmptv) | mvn CARG4, #~LJ_TTAB | str TAB:RB, [CARG2] | str CARG4, [CARG2, #4] |2: | mvn CARG4, #~LJ_TSTR | str STR:RC, TMPDlo | str CARG4, TMPDhi | mov CARG3, TMPDp | b >1 | |->vmeta_tgetb: // RC = index | decode_RB8 RB, INS | str RC, TMPDlo | mvn CARG4, #~LJ_TISNUM | add CARG2, BASE, RB | str CARG4, TMPDhi | mov CARG3, TMPDp | b >1 | |->vmeta_tgetv: | add CARG2, BASE, RB | add CARG3, BASE, RC |1: | str BASE, L->base | mov CARG1, L | str PC, SAVE_PC | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) | // Returns TValue * (finished) or NULL (metamethod). | .IOS ldr BASE, L->base | cmp CRET1, #0 | beq >3 | ldrd CARG34, [CRET1] | ins_next1 | ins_next2 | strd CARG34, [BASE, RA] | ins_next3 | |3: // Call __index metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k | rsb CARG1, BASE, #FRAME_CONT | ldr BASE, L->top | mov NARGS8:RC, #16 // 2 args for func(t, k). | str PC, [BASE, #-12] // [cont|PC] | add PC, CARG1, BASE | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. | b ->vm_call_dispatch_f | |//----------------------------------------------------------------------- | |->vmeta_tsets1: | add CARG2, BASE, RB | b >2 | |->vmeta_tsets: | sub CARG2, DISPATCH, #-DISPATCH_GL(tmptv) | mvn CARG4, #~LJ_TTAB | str TAB:RB, [CARG2] | str CARG4, [CARG2, #4] |2: | mvn CARG4, #~LJ_TSTR | str STR:RC, TMPDlo | str CARG4, TMPDhi | mov CARG3, TMPDp | b >1 | |->vmeta_tsetb: // RC = index | decode_RB8 RB, INS | str RC, TMPDlo | mvn CARG4, #~LJ_TISNUM | add CARG2, BASE, RB | str CARG4, TMPDhi | mov CARG3, TMPDp | b >1 | |->vmeta_tsetv: | add CARG2, BASE, RB | add CARG3, BASE, RC |1: | str BASE, L->base | mov CARG1, L | str PC, SAVE_PC | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) | // Returns TValue * (finished) or NULL (metamethod). | .IOS ldr BASE, L->base | cmp CRET1, #0 | ldrd CARG34, [BASE, RA] | beq >3 | ins_next1 | // NOBARRIER: lj_meta_tset ensures the table is not black. | strd CARG34, [CRET1] | ins_next2 | ins_next3 | |3: // Call __newindex metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) | rsb CARG1, BASE, #FRAME_CONT | ldr BASE, L->top | mov NARGS8:RC, #24 // 3 args for func(t, k, v). | strd CARG34, [BASE, #16] // Copy value to third argument. | str PC, [BASE, #-12] // [cont|PC] | add PC, CARG1, BASE | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. | b ->vm_call_dispatch_f | |//-- Comparison metamethods --------------------------------------------- | |->vmeta_comp: | mov CARG1, L | sub PC, PC, #4 | mov CARG2, RA | str BASE, L->base | mov CARG3, RC | str PC, SAVE_PC | decode_OP CARG4, INS | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) | // Returns 0/1 or TValue * (metamethod). |3: | .IOS ldr BASE, L->base | cmp CRET1, #1 | bhi ->vmeta_binop |4: | ldrh RB, [PC, #2] | add PC, PC, #4 | add RB, PC, RB, lsl #2 | subhs PC, RB, #0x20000 |->cont_nop: | ins_next | |->cont_ra: // RA = resultptr | ldr INS, [PC, #-4] | ldrd CARG12, [RA] | decode_RA8 CARG3, INS | strd CARG12, [BASE, CARG3] | b ->cont_nop | |->cont_condt: // RA = resultptr | ldr CARG2, [RA, #4] | mvn CARG1, #~LJ_TTRUE | cmp CARG1, CARG2 // Branch if result is true. | b <4 | |->cont_condf: // RA = resultptr | ldr CARG2, [RA, #4] | checktp CARG2, LJ_TFALSE // Branch if result is false. | b <4 | |->vmeta_equal: | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. | sub PC, PC, #4 | str BASE, L->base | mov CARG1, L | str PC, SAVE_PC | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) | // Returns 0/1 or TValue * (metamethod). | b <3 | |->vmeta_equal_cd: |.if FFI | sub PC, PC, #4 | str BASE, L->base | mov CARG1, L | mov CARG2, INS | str PC, SAVE_PC | bl extern lj_meta_equal_cd // (lua_State *L, BCIns op) | // Returns 0/1 or TValue * (metamethod). | b <3 |.endif | |//-- Arithmetic metamethods --------------------------------------------- | |->vmeta_arith_vn: | decode_RB8 RB, INS | decode_RC8 RC, INS | add CARG3, BASE, RB | add CARG4, KBASE, RC | b >1 | |->vmeta_arith_nv: | decode_RB8 RB, INS | decode_RC8 RC, INS | add CARG4, BASE, RB | add CARG3, KBASE, RC | b >1 | |->vmeta_unm: | ldr INS, [PC, #-8] | sub PC, PC, #4 | add CARG3, BASE, RC | add CARG4, BASE, RC | b >1 | |->vmeta_arith_vv: | decode_RB8 RB, INS | decode_RC8 RC, INS | add CARG3, BASE, RB | add CARG4, BASE, RC |1: | decode_OP OP, INS | add CARG2, BASE, RA | str BASE, L->base | mov CARG1, L | str PC, SAVE_PC | str OP, ARG5 | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) | // Returns NULL (finished) or TValue * (metamethod). | .IOS ldr BASE, L->base | cmp CRET1, #0 | beq ->cont_nop | | // Call metamethod for binary op. |->vmeta_binop: | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 | sub CARG2, CRET1, BASE | str PC, [CRET1, #-12] // [cont|PC] | add PC, CARG2, #FRAME_CONT | mov BASE, CRET1 | mov NARGS8:RC, #16 // 2 args for func(o1, o2). | b ->vm_call_dispatch | |->vmeta_len: | add CARG2, BASE, RC | str BASE, L->base | mov CARG1, L | str PC, SAVE_PC | bl extern lj_meta_len // (lua_State *L, TValue *o) | // Returns NULL (retry) or TValue * (metamethod base). | .IOS ldr BASE, L->base #if LJ_52 | cmp CRET1, #0 | bne ->vmeta_binop // Binop call for compatibility. | ldr TAB:CARG1, [BASE, RC] | b ->BC_LEN_Z #else | b ->vmeta_binop // Binop call for compatibility. #endif | |//-- Call metamethod ---------------------------------------------------- | |->vmeta_call: // Resolve and call __call metamethod. | // RB = old base, BASE = new base, RC = nargs*8 | mov CARG1, L | str RB, L->base // This is the callers base! | sub CARG2, BASE, #8 | str PC, SAVE_PC | add CARG3, BASE, NARGS8:RC | .IOS mov RA, BASE | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) | .IOS mov BASE, RA | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. | ins_call | |->vmeta_callt: // Resolve __call for BC_CALLT. | // BASE = old base, RA = new base, RC = nargs*8 | mov CARG1, L | str BASE, L->base | sub CARG2, RA, #8 | str PC, SAVE_PC | add CARG3, RA, NARGS8:RC | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) | .IOS ldr BASE, L->base | ldr LFUNC:CARG3, [RA, FRAME_FUNC] // Guaranteed to be a function here. | ldr PC, [BASE, FRAME_PC] | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. | b ->BC_CALLT2_Z | |//-- Argument coercion for 'for' statement ------------------------------ | |->vmeta_for: | mov CARG1, L | str BASE, L->base | mov CARG2, RA | str PC, SAVE_PC | bl extern lj_meta_for // (lua_State *L, TValue *base) | .IOS ldr BASE, L->base |.if JIT | ldrb OP, [PC, #-4] |.endif | ldr INS, [PC, #-4] |.if JIT | cmp OP, #BC_JFORI |.endif | decode_RA8 RA, INS | decode_RD RC, INS |.if JIT | beq =>BC_JFORI |.endif | b =>BC_FORI | |//----------------------------------------------------------------------- |//-- Fast functions ----------------------------------------------------- |//----------------------------------------------------------------------- | |.macro .ffunc, name |->ff_ .. name: |.endmacro | |.macro .ffunc_1, name |->ff_ .. name: | ldrd CARG12, [BASE] | cmp NARGS8:RC, #8 | blo ->fff_fallback |.endmacro | |.macro .ffunc_2, name |->ff_ .. name: | ldrd CARG12, [BASE] | ldrd CARG34, [BASE, #8] | cmp NARGS8:RC, #16 | blo ->fff_fallback |.endmacro | |.macro .ffunc_n, name | .ffunc_1 name | checktp CARG2, LJ_TISNUM | bhs ->fff_fallback |.endmacro | |.macro .ffunc_nn, name | .ffunc_2 name | checktp CARG2, LJ_TISNUM | cmnlo CARG4, #-LJ_TISNUM | bhs ->fff_fallback |.endmacro | |.macro .ffunc_d, name | .ffunc name | ldr CARG2, [BASE, #4] | cmp NARGS8:RC, #8 | vldr d0, [BASE] | blo ->fff_fallback | checktp CARG2, LJ_TISNUM | bhs ->fff_fallback |.endmacro | |.macro .ffunc_dd, name | .ffunc name | ldr CARG2, [BASE, #4] | ldr CARG4, [BASE, #12] | cmp NARGS8:RC, #16 | vldr d0, [BASE] | vldr d1, [BASE, #8] | blo ->fff_fallback | checktp CARG2, LJ_TISNUM | cmnlo CARG4, #-LJ_TISNUM | bhs ->fff_fallback |.endmacro | |// Inlined GC threshold check. Caveat: uses CARG1 and CARG2. |.macro ffgccheck | ldr CARG1, [DISPATCH, #DISPATCH_GL(gc.total)] | ldr CARG2, [DISPATCH, #DISPATCH_GL(gc.threshold)] | cmp CARG1, CARG2 | blge ->fff_gcstep |.endmacro | |//-- Base library: checks ----------------------------------------------- | |.ffunc_1 assert | checktp CARG2, LJ_TTRUE | bhi ->fff_fallback | ldr PC, [BASE, FRAME_PC] | strd CARG12, [BASE, #-8] | mov RB, BASE | subs RA, NARGS8:RC, #8 | add RC, NARGS8:RC, #8 // Compute (nresults+1)*8. | beq ->fff_res // Done if exactly 1 argument. |1: | ldrd CARG12, [RB, #8] | subs RA, RA, #8 | strd CARG12, [RB], #8 | bne <1 | b ->fff_res | |.ffunc type | ldr CARG2, [BASE, #4] | cmp NARGS8:RC, #8 | blo ->fff_fallback | checktp CARG2, LJ_TISNUM | mvnlo CARG2, #~LJ_TISNUM | rsb CARG4, CARG2, #(int)(offsetof(GCfuncC, upvalue)>>3)-1 | lsl CARG4, CARG4, #3 | ldrd CARG12, [CFUNC:CARG3, CARG4] | b ->fff_restv | |//-- Base library: getters and setters --------------------------------- | |.ffunc_1 getmetatable | checktp CARG2, LJ_TTAB | cmnne CARG2, #-LJ_TUDATA | bne >6 |1: // Field metatable must be at same offset for GCtab and GCudata! | ldr TAB:RB, TAB:CARG1->metatable |2: | mvn CARG2, #~LJ_TNIL | ldr STR:RC, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])] | cmp TAB:RB, #0 | beq ->fff_restv | ldr CARG3, TAB:RB->hmask | ldr CARG4, STR:RC->hash | ldr NODE:INS, TAB:RB->node | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask | add CARG3, CARG3, CARG3, lsl #1 | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 |3: // Rearranged logic, because we expect _not_ to find the key. | ldrd CARG34, NODE:INS->key // STALL: early NODE:INS. | ldrd CARG12, NODE:INS->val | ldr NODE:INS, NODE:INS->next | checktp CARG4, LJ_TSTR | cmpeq CARG3, STR:RC | beq >5 | cmp NODE:INS, #0 | bne <3 |4: | mov CARG1, RB // Use metatable as default result. | mvn CARG2, #~LJ_TTAB | b ->fff_restv |5: | checktp CARG2, LJ_TNIL | bne ->fff_restv | b <4 | |6: | checktp CARG2, LJ_TISNUM | mvnhs CARG2, CARG2 | movlo CARG2, #~LJ_TISNUM | add CARG4, DISPATCH, CARG2, lsl #2 | ldr TAB:RB, [CARG4, #DISPATCH_GL(gcroot[GCROOT_BASEMT])] | b <2 | |.ffunc_2 setmetatable | // Fast path: no mt for table yet and not clearing the mt. | checktp CARG2, LJ_TTAB | ldreq TAB:RB, TAB:CARG1->metatable | checktpeq CARG4, LJ_TTAB | ldrbeq CARG4, TAB:CARG1->marked | cmpeq TAB:RB, #0 | bne ->fff_fallback | tst CARG4, #LJ_GC_BLACK // isblack(table) | str TAB:CARG3, TAB:CARG1->metatable | beq ->fff_restv | barrierback TAB:CARG1, CARG4, CARG3 | b ->fff_restv | |.ffunc rawget | ldrd CARG34, [BASE] | cmp NARGS8:RC, #16 | blo ->fff_fallback | mov CARG2, CARG3 | checktab CARG4, ->fff_fallback | mov CARG1, L | add CARG3, BASE, #8 | .IOS mov RA, BASE | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) | // Returns cTValue *. | .IOS mov BASE, RA | ldrd CARG12, [CRET1] | b ->fff_restv | |//-- Base library: conversions ------------------------------------------ | |.ffunc tonumber | // Only handles the number case inline (without a base argument). | ldrd CARG12, [BASE] | cmp NARGS8:RC, #8 | bne ->fff_fallback | checktp CARG2, LJ_TISNUM | bls ->fff_restv | b ->fff_fallback | |.ffunc_1 tostring | // Only handles the string or number case inline. | checktp CARG2, LJ_TSTR | // A __tostring method in the string base metatable is ignored. | beq ->fff_restv | // Handle numbers inline, unless a number base metatable is present. | ldr CARG4, [DISPATCH, #DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])] | str BASE, L->base | checktp CARG2, LJ_TISNUM | cmpls CARG4, #0 | str PC, SAVE_PC // Redundant (but a defined value). | bhi ->fff_fallback | ffgccheck | mov CARG1, L | mov CARG2, BASE | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) | // Returns GCstr *. | ldr BASE, L->base | mvn CARG2, #~LJ_TSTR | b ->fff_restv | |//-- Base library: iterators ------------------------------------------- | |.ffunc_1 next | mvn CARG4, #~LJ_TNIL | checktab CARG2, ->fff_fallback | strd CARG34, [BASE, NARGS8:RC] // Set missing 2nd arg to nil. | ldr PC, [BASE, FRAME_PC] | mov CARG2, CARG1 | str BASE, L->base // Add frame since C call can throw. | mov CARG1, L | str BASE, L->top // Dummy frame length is ok. | add CARG3, BASE, #8 | str PC, SAVE_PC | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) | // Returns 0 at end of traversal. | .IOS ldr BASE, L->base | cmp CRET1, #0 | mvneq CRET2, #~LJ_TNIL | beq ->fff_restv // End of traversal: return nil. | ldrd CARG12, [BASE, #8] // Copy key and value to results. | ldrd CARG34, [BASE, #16] | mov RC, #(2+1)*8 | strd CARG12, [BASE, #-8] | strd CARG34, [BASE] | b ->fff_res | |.ffunc_1 pairs | checktab CARG2, ->fff_fallback #if LJ_52 | ldr TAB:RB, TAB:CARG1->metatable #endif | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0] | ldr PC, [BASE, FRAME_PC] #if LJ_52 | cmp TAB:RB, #0 | bne ->fff_fallback #endif | mvn CARG2, #~LJ_TNIL | mov RC, #(3+1)*8 | strd CFUNC:CARG34, [BASE, #-8] | str CARG2, [BASE, #12] | b ->fff_res | |.ffunc_2 ipairs_aux | checktp CARG2, LJ_TTAB | checktpeq CARG4, LJ_TISNUM | bne ->fff_fallback | ldr RB, TAB:CARG1->asize | ldr RC, TAB:CARG1->array | add CARG3, CARG3, #1 | ldr PC, [BASE, FRAME_PC] | cmp CARG3, RB | add RC, RC, CARG3, lsl #3 | strd CARG34, [BASE, #-8] | ldrdlo CARG12, [RC] | mov RC, #(0+1)*8 | bhs >2 // Not in array part? |1: | checktp CARG2, LJ_TNIL | movne RC, #(2+1)*8 | strdne CARG12, [BASE] | b ->fff_res |2: // Check for empty hash part first. Otherwise call C function. | ldr RB, TAB:CARG1->hmask | mov CARG2, CARG3 | cmp RB, #0 | beq ->fff_res | .IOS mov RA, BASE | bl extern lj_tab_getinth // (GCtab *t, int32_t key) | // Returns cTValue * or NULL. | .IOS mov BASE, RA | cmp CRET1, #0 | beq ->fff_res | ldrd CARG12, [CRET1] | b <1 | |.ffunc_1 ipairs | checktab CARG2, ->fff_fallback #if LJ_52 | ldr TAB:RB, TAB:CARG1->metatable #endif | ldrd CFUNC:CARG34, CFUNC:CARG3->upvalue[0] | ldr PC, [BASE, FRAME_PC] #if LJ_52 | cmp TAB:RB, #0 | bne ->fff_fallback #endif | mov CARG1, #0 | mvn CARG2, #~LJ_TISNUM | mov RC, #(3+1)*8 | strd CFUNC:CARG34, [BASE, #-8] | strd CARG12, [BASE, #8] | b ->fff_res | |//-- Base library: catch errors ---------------------------------------- | |.ffunc pcall | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] | cmp NARGS8:RC, #8 | blo ->fff_fallback | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. | mov RB, BASE | add BASE, BASE, #8 | moveq PC, #8+FRAME_PCALL | movne PC, #8+FRAME_PCALLH | sub NARGS8:RC, NARGS8:RC, #8 | b ->vm_call_dispatch | |.ffunc_2 xpcall | ldrb RA, [DISPATCH, #DISPATCH_GL(hookmask)] | checkfunc CARG4, ->fff_fallback // Traceback must be a function. | mov RB, BASE | strd CARG12, [BASE, #8] // Swap function and traceback. | strd CARG34, [BASE] | tst RA, #HOOK_ACTIVE // Remember active hook before pcall. | add BASE, BASE, #16 | moveq PC, #16+FRAME_PCALL | movne PC, #16+FRAME_PCALLH | sub NARGS8:RC, NARGS8:RC, #16 | b ->vm_call_dispatch | |//-- Coroutine library -------------------------------------------------- | |.macro coroutine_resume_wrap, resume |.if resume |.ffunc_1 coroutine_resume | checktp CARG2, LJ_TTHREAD | bne ->fff_fallback |.else |.ffunc coroutine_wrap_aux | ldr L:CARG1, CFUNC:CARG3->upvalue[0].gcr |.endif | ldr PC, [BASE, FRAME_PC] | str BASE, L->base | ldr CARG2, L:CARG1->top | ldrb RA, L:CARG1->status | ldr RB, L:CARG1->base | add CARG3, CARG2, NARGS8:RC | add CARG4, CARG2, RA | str PC, SAVE_PC | cmp CARG4, RB | beq ->fff_fallback | ldr CARG4, L:CARG1->maxstack | ldr RB, L:CARG1->cframe | cmp RA, #LUA_YIELD | cmpls CARG3, CARG4 | cmpls RB, #0 | bhi ->fff_fallback |1: |.if resume | sub CARG3, CARG3, #8 // Keep resumed thread in stack for GC. | add BASE, BASE, #8 | sub NARGS8:RC, NARGS8:RC, #8 |.endif | str CARG3, L:CARG1->top | str BASE, L->top |2: // Move args to coroutine. | ldrd CARG34, [BASE, RB] | cmp RB, NARGS8:RC | strdne CARG34, [CARG2, RB] | add RB, RB, #8 | bne <2 | | mov CARG3, #0 | mov L:RA, L:CARG1 | mov CARG4, #0 | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) | // Returns thread status. |4: | ldr CARG3, L:RA->base | mv_vmstate CARG2, INTERP | ldr CARG4, L:RA->top | st_vmstate CARG2 | cmp CRET1, #LUA_YIELD | ldr BASE, L->base | bhi >8 | subs RC, CARG4, CARG3 | ldr CARG1, L->maxstack | add CARG2, BASE, RC | beq >6 // No results? | cmp CARG2, CARG1 | mov RB, #0 | bhi >9 // Need to grow stack? | | sub CARG4, RC, #8 | str CARG3, L:RA->top // Clear coroutine stack. |5: // Move results from coroutine. | ldrd CARG12, [CARG3, RB] | cmp RB, CARG4 | strd CARG12, [BASE, RB] | add RB, RB, #8 | bne <5 |6: |.if resume | mvn CARG3, #~LJ_TTRUE | add RC, RC, #16 |7: | str CARG3, [BASE, #-4] // Prepend true/false to results. | sub RA, BASE, #8 |.else | mov RA, BASE | add RC, RC, #8 |.endif | ands CARG1, PC, #FRAME_TYPE | str PC, SAVE_PC | str RC, SAVE_MULTRES | beq ->BC_RET_Z | b ->vm_return | |8: // Coroutine returned with error (at co->top-1). |.if resume | ldrd CARG12, [CARG4, #-8]! | mvn CARG3, #~LJ_TFALSE | mov RC, #(2+1)*8 | str CARG4, L:RA->top // Remove error from coroutine stack. | strd CARG12, [BASE] // Copy error message. | b <7 |.else | mov CARG1, L | mov CARG2, L:RA | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) | // Never returns. |.endif | |9: // Handle stack expansion on return from yield. | mov CARG1, L | lsr CARG2, RC, #3 | bl extern lj_state_growstack // (lua_State *L, int n) | mov CRET1, #0 | b <4 |.endmacro | | coroutine_resume_wrap 1 // coroutine.resume | coroutine_resume_wrap 0 // coroutine.wrap | |.ffunc coroutine_yield | ldr CARG1, L->cframe | add CARG2, BASE, NARGS8:RC | str BASE, L->base | tst CARG1, #CFRAME_RESUME | str CARG2, L->top | mov CRET1, #LUA_YIELD | mov CARG3, #0 | beq ->fff_fallback | str CARG3, L->cframe | strb CRET1, L->status | b ->vm_leave_unw | |//-- Math library ------------------------------------------------------- | |.macro math_round, func | .ffunc_1 math_ .. func | checktp CARG2, LJ_TISNUM | beq ->fff_restv | bhi ->fff_fallback | // Round FP value and normalize result. | lsl CARG3, CARG2, #1 | adds RB, CARG3, #0x00200000 | bpl >2 // |x| < 1? | mvn CARG4, #0x3e0 | subs RB, CARG4, RB, asr #21 | lsl CARG4, CARG2, #11 | lsl CARG3, CARG1, #11 | orr CARG4, CARG4, #0x80000000 | rsb INS, RB, #32 | orr CARG4, CARG4, CARG1, lsr #21 | bls >3 // |x| >= 2^31? | orr CARG3, CARG3, CARG4, lsl INS | lsr CARG1, CARG4, RB |.if "func" == "floor" | tst CARG3, CARG2, asr #31 | addne CARG1, CARG1, #1 |.else | bics CARG3, CARG3, CARG2, asr #31 | addsne CARG1, CARG1, #1 | ldrdvs CARG12, >9 | bvs ->fff_restv |.endif | cmp CARG2, #0 | rsblt CARG1, CARG1, #0 |1: | mvn CARG2, #~LJ_TISNUM | b ->fff_restv | |2: // |x| < 1 | bcs ->fff_restv // |x| is not finite. | orr CARG3, CARG3, CARG1 // ztest = abs(hi) | lo |.if "func" == "floor" | tst CARG3, CARG2, asr #31 // return (ztest & sign) == 0 ? 0 : -1 | moveq CARG1, #0 | mvnne CARG1, #0 |.else | bics CARG3, CARG3, CARG2, asr #31 // return (ztest & ~sign) == 0 ? 0 : 1 | moveq CARG1, #0 | movne CARG1, #1 |.endif | mvn CARG2, #~LJ_TISNUM | b ->fff_restv | |3: // |x| >= 2^31. Check for x == -(2^31). | cmpeq CARG4, #0x80000000 |.if "func" == "floor" | cmpeq CARG3, #0 |.endif | bne >4 | cmp CARG2, #0 | movmi CARG1, #0x80000000 | bmi <1 |4: | bl ->vm_..func.._sf | b ->fff_restv |.endmacro | | math_round floor | math_round ceil | |.align 8 |9: | .long 0x00000000, 0x41e00000 // 2^31. | |.ffunc_1 math_abs | checktp CARG2, LJ_TISNUM | bhi ->fff_fallback | bicne CARG2, CARG2, #0x80000000 | bne ->fff_restv | cmp CARG1, #0 | rsbslt CARG1, CARG1, #0 | ldrdvs CARG12, <9 | // Fallthrough. | |->fff_restv: | // CARG12 = TValue result. | ldr PC, [BASE, FRAME_PC] | strd CARG12, [BASE, #-8] |->fff_res1: | // PC = return. | mov RC, #(1+1)*8 |->fff_res: | // RC = (nresults+1)*8, PC = return. | ands CARG1, PC, #FRAME_TYPE | ldreq INS, [PC, #-4] | str RC, SAVE_MULTRES | sub RA, BASE, #8 | bne ->vm_return | decode_RB8 RB, INS |5: | cmp RB, RC // More results expected? | bhi >6 | decode_RA8 CARG1, INS | ins_next1 | ins_next2 | // Adjust BASE. KBASE is assumed to be set for the calling frame. | sub BASE, RA, CARG1 | ins_next3 | |6: // Fill up results with nil. | add CARG2, RA, RC | mvn CARG1, #~LJ_TNIL | add RC, RC, #8 | str CARG1, [CARG2, #-4] | b <5 | |.macro math_extern, func |.if HFABI | .ffunc_d math_ .. func |.else | .ffunc_n math_ .. func |.endif | .IOS mov RA, BASE | bl extern func | .IOS mov BASE, RA |.if HFABI | b ->fff_resd |.else | b ->fff_restv |.endif |.endmacro | |.macro math_extern2, func |.if HFABI | .ffunc_dd math_ .. func |.else | .ffunc_nn math_ .. func |.endif | .IOS mov RA, BASE | bl extern func | .IOS mov BASE, RA |.if HFABI | b ->fff_resd |.else | b ->fff_restv |.endif |.endmacro | |.if FPU | .ffunc_d math_sqrt | vsqrt.f64 d0, d0 |->fff_resd: | ldr PC, [BASE, FRAME_PC] | vstr d0, [BASE, #-8] | b ->fff_res1 |.else | math_extern sqrt |.endif | |.ffunc math_log |.if HFABI | ldr CARG2, [BASE, #4] | cmp NARGS8:RC, #8 // Need exactly 1 argument. | vldr d0, [BASE] | bne ->fff_fallback |.else | ldrd CARG12, [BASE] | cmp NARGS8:RC, #8 // Need exactly 1 argument. | bne ->fff_fallback |.endif | checktp CARG2, LJ_TISNUM | bhs ->fff_fallback | .IOS mov RA, BASE | bl extern log | .IOS mov BASE, RA |.if HFABI | b ->fff_resd |.else | b ->fff_restv |.endif | | math_extern log10 | math_extern exp | math_extern sin | math_extern cos | math_extern tan | math_extern asin | math_extern acos | math_extern atan | math_extern sinh | math_extern cosh | math_extern tanh | math_extern2 pow | math_extern2 atan2 | math_extern2 fmod | |->ff_math_deg: |.if FPU | .ffunc_d math_rad | vldr d1, CFUNC:CARG3->upvalue[0] | vmul.f64 d0, d0, d1 | b ->fff_resd |.else | .ffunc_n math_rad | ldrd CARG34, CFUNC:CARG3->upvalue[0] | bl extern __aeabi_dmul | b ->fff_restv |.endif | |.if HFABI | .ffunc math_ldexp | ldr CARG4, [BASE, #4] | ldrd CARG12, [BASE, #8] | cmp NARGS8:RC, #16 | blo ->fff_fallback | vldr d0, [BASE] | checktp CARG4, LJ_TISNUM | bhs ->fff_fallback | checktp CARG2, LJ_TISNUM | bne ->fff_fallback | .IOS mov RA, BASE | bl extern ldexp // (double x, int exp) | .IOS mov BASE, RA | b ->fff_resd |.else |.ffunc_2 math_ldexp | checktp CARG2, LJ_TISNUM | bhs ->fff_fallback | checktp CARG4, LJ_TISNUM | bne ->fff_fallback | .IOS mov RA, BASE | bl extern ldexp // (double x, int exp) | .IOS mov BASE, RA | b ->fff_restv |.endif | |.if HFABI |.ffunc_d math_frexp | mov CARG1, sp | .IOS mov RA, BASE | bl extern frexp | .IOS mov BASE, RA | ldr CARG3, [sp] | mvn CARG4, #~LJ_TISNUM | ldr PC, [BASE, FRAME_PC] | vstr d0, [BASE, #-8] | mov RC, #(2+1)*8 | strd CARG34, [BASE] | b ->fff_res |.else |.ffunc_n math_frexp | mov CARG3, sp | .IOS mov RA, BASE | bl extern frexp | .IOS mov BASE, RA | ldr CARG3, [sp] | mvn CARG4, #~LJ_TISNUM | ldr PC, [BASE, FRAME_PC] | strd CARG12, [BASE, #-8] | mov RC, #(2+1)*8 | strd CARG34, [BASE] | b ->fff_res |.endif | |.if HFABI |.ffunc_d math_modf | sub CARG1, BASE, #8 | ldr PC, [BASE, FRAME_PC] | .IOS mov RA, BASE | bl extern modf | .IOS mov BASE, RA | mov RC, #(2+1)*8 | vstr d0, [BASE] | b ->fff_res |.else |.ffunc_n math_modf | sub CARG3, BASE, #8 | ldr PC, [BASE, FRAME_PC] | .IOS mov RA, BASE | bl extern modf | .IOS mov BASE, RA | mov RC, #(2+1)*8 | strd CARG12, [BASE] | b ->fff_res |.endif | |.macro math_minmax, name, cond, fcond |.if FPU | .ffunc_1 name | add RB, BASE, RC | checktp CARG2, LJ_TISNUM | add RA, BASE, #8 | bne >4 |1: // Handle integers. | ldrd CARG34, [RA] | cmp RA, RB | bhs ->fff_restv | checktp CARG4, LJ_TISNUM | bne >3 | cmp CARG1, CARG3 | add RA, RA, #8 | mov..cond CARG1, CARG3 | b <1 |3: // Convert intermediate result to number and continue below. | vmov s4, CARG1 | bhi ->fff_fallback | vldr d1, [RA] | vcvt.f64.s32 d0, s4 | b >6 | |4: | vldr d0, [BASE] | bhi ->fff_fallback |5: // Handle numbers. | ldrd CARG34, [RA] | vldr d1, [RA] | cmp RA, RB | bhs ->fff_resd | checktp CARG4, LJ_TISNUM | bhs >7 |6: | vcmp.f64 d0, d1 | vmrs | add RA, RA, #8 | vmov..fcond.f64 d0, d1 | b <5 |7: // Convert integer to number and continue above. | vmov s4, CARG3 | bhi ->fff_fallback | vcvt.f64.s32 d1, s4 | b <6 | |.else | | .ffunc_1 name | checktp CARG2, LJ_TISNUM | mov RA, #8 | bne >4 |1: // Handle integers. | ldrd CARG34, [BASE, RA] | cmp RA, RC | bhs ->fff_restv | checktp CARG4, LJ_TISNUM | bne >3 | cmp CARG1, CARG3 | add RA, RA, #8 | mov..cond CARG1, CARG3 | b <1 |3: // Convert intermediate result to number and continue below. | bhi ->fff_fallback | bl extern __aeabi_i2d | ldrd CARG34, [BASE, RA] | b >6 | |4: | bhi ->fff_fallback |5: // Handle numbers. | ldrd CARG34, [BASE, RA] | cmp RA, RC | bhs ->fff_restv | checktp CARG4, LJ_TISNUM | bhs >7 |6: | bl extern __aeabi_cdcmple | add RA, RA, #8 | mov..fcond CARG1, CARG3 | mov..fcond CARG2, CARG4 | b <5 |7: // Convert integer to number and continue above. | bhi ->fff_fallback | strd CARG12, TMPD | mov CARG1, CARG3 | bl extern __aeabi_i2d | ldrd CARG34, TMPD | b <6 |.endif |.endmacro | | math_minmax math_min, gt, hi | math_minmax math_max, lt, lo | |//-- String library ----------------------------------------------------- | |.ffunc_1 string_len | checkstr CARG2, ->fff_fallback | ldr CARG1, STR:CARG1->len | mvn CARG2, #~LJ_TISNUM | b ->fff_restv | |.ffunc string_byte // Only handle the 1-arg case here. | ldrd CARG12, [BASE] | ldr PC, [BASE, FRAME_PC] | cmp NARGS8:RC, #8 | checktpeq CARG2, LJ_TSTR // Need exactly 1 argument. | bne ->fff_fallback | ldr CARG3, STR:CARG1->len | ldrb CARG1, STR:CARG1[1] // Access is always ok (NUL at end). | mvn CARG2, #~LJ_TISNUM | cmp CARG3, #0 | moveq RC, #(0+1)*8 | movne RC, #(1+1)*8 | strd CARG12, [BASE, #-8] | b ->fff_res | |.ffunc string_char // Only handle the 1-arg case here. | ffgccheck | ldrd CARG12, [BASE] | ldr PC, [BASE, FRAME_PC] | cmp NARGS8:RC, #8 // Need exactly 1 argument. | checktpeq CARG2, LJ_TISNUM | bicseq CARG4, CARG1, #255 | mov CARG3, #1 | bne ->fff_fallback | str CARG1, TMPD | mov CARG2, TMPDp // Points to stack. Little-endian. |->fff_newstr: | // CARG2 = str, CARG3 = len. | str BASE, L->base | mov CARG1, L | str PC, SAVE_PC | bl extern lj_str_new // (lua_State *L, char *str, size_t l) | // Returns GCstr *. | ldr BASE, L->base | mvn CARG2, #~LJ_TSTR | b ->fff_restv | |.ffunc string_sub | ffgccheck | ldrd CARG12, [BASE] | ldrd CARG34, [BASE, #16] | cmp NARGS8:RC, #16 | mvn RB, #0 | beq >1 | blo ->fff_fallback | checktp CARG4, LJ_TISNUM | mov RB, CARG3 | bne ->fff_fallback |1: | ldrd CARG34, [BASE, #8] | checktp CARG2, LJ_TSTR | ldreq CARG2, STR:CARG1->len | checktpeq CARG4, LJ_TISNUM | bne ->fff_fallback | // CARG1 = str, CARG2 = str->len, CARG3 = start, RB = end | add CARG4, CARG2, #1 | cmp CARG3, #0 // if (start < 0) start += len+1 | addlt CARG3, CARG3, CARG4 | cmp CARG3, #1 // if (start < 1) start = 1 | movlt CARG3, #1 | cmp RB, #0 // if (end < 0) end += len+1 | addlt RB, RB, CARG4 | bic RB, RB, RB, asr #31 // if (end < 0) end = 0 | cmp RB, CARG2 // if (end > len) end = len | add CARG1, STR:CARG1, #sizeof(GCstr)-1 | movgt RB, CARG2 | add CARG2, CARG1, CARG3 | subs CARG3, RB, CARG3 // len = end - start | add CARG3, CARG3, #1 // len += 1 | bge ->fff_newstr |->fff_emptystr: | sub STR:CARG1, DISPATCH, #-DISPATCH_GL(strempty) | mvn CARG2, #~LJ_TSTR | b ->fff_restv | |.ffunc string_rep // Only handle the 1-char case inline. | ffgccheck | ldrd CARG12, [BASE] | ldrd CARG34, [BASE, #8] | cmp NARGS8:RC, #16 | bne ->fff_fallback // Exactly 2 arguments | checktp CARG2, LJ_TSTR | checktpeq CARG4, LJ_TISNUM | bne ->fff_fallback | subs CARG4, CARG3, #1 | ldr CARG2, STR:CARG1->len | blt ->fff_emptystr // Count <= 0? | cmp CARG2, #1 | blo ->fff_emptystr // Zero-length string? | bne ->fff_fallback // Fallback for > 1-char strings. | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | ldr CARG1, STR:CARG1[1] | cmp RB, CARG3 | blo ->fff_fallback |1: // Fill buffer with char. | strb CARG1, [CARG2, CARG4] | subs CARG4, CARG4, #1 | bge <1 | b ->fff_newstr | |.ffunc string_reverse | ffgccheck | ldrd CARG12, [BASE] | cmp NARGS8:RC, #8 | blo ->fff_fallback | checkstr CARG2, ->fff_fallback | ldr CARG3, STR:CARG1->len | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | mov CARG4, CARG3 | add CARG1, STR:CARG1, #sizeof(GCstr) | cmp RB, CARG3 | blo ->fff_fallback |1: // Reverse string copy. | ldrb RB, [CARG1], #1 | subs CARG4, CARG4, #1 | blt ->fff_newstr | strb RB, [CARG2, CARG4] | b <1 | |.macro ffstring_case, name, lo | .ffunc name | ffgccheck | ldrd CARG12, [BASE] | cmp NARGS8:RC, #8 | blo ->fff_fallback | checkstr CARG2, ->fff_fallback | ldr CARG3, STR:CARG1->len | ldr RB, [DISPATCH, #DISPATCH_GL(tmpbuf.sz)] | ldr CARG2, [DISPATCH, #DISPATCH_GL(tmpbuf.buf)] | mov CARG4, #0 | add CARG1, STR:CARG1, #sizeof(GCstr) | cmp RB, CARG3 | blo ->fff_fallback |1: // ASCII case conversion. | ldrb RB, [CARG1, CARG4] | cmp CARG4, CARG3 | bhs ->fff_newstr | sub RC, RB, #lo | cmp RC, #26 | eorlo RB, RB, #0x20 | strb RB, [CARG2, CARG4] | add CARG4, CARG4, #1 | b <1 |.endmacro | |ffstring_case string_lower, 65 |ffstring_case string_upper, 97 | |//-- Table library ------------------------------------------------------ | |.ffunc_1 table_getn | checktab CARG2, ->fff_fallback | .IOS mov RA, BASE | bl extern lj_tab_len // (GCtab *t) | // Returns uint32_t (but less than 2^31). | .IOS mov BASE, RA | mvn CARG2, #~LJ_TISNUM | b ->fff_restv | |//-- Bit library -------------------------------------------------------- | |// FP number to bit conversion for soft-float. Clobbers r0-r3. |->vm_tobit_fb: | bhi ->fff_fallback |->vm_tobit: | lsl RB, CARG2, #1 | adds RB, RB, #0x00200000 | movpl CARG1, #0 // |x| < 1? | bxpl lr | mvn CARG4, #0x3e0 | subs RB, CARG4, RB, asr #21 | bmi >1 // |x| >= 2^32? | lsl CARG4, CARG2, #11 | orr CARG4, CARG4, #0x80000000 | orr CARG4, CARG4, CARG1, lsr #21 | cmp CARG2, #0 | lsr CARG1, CARG4, RB | rsblt CARG1, CARG1, #0 | bx lr |1: | add RB, RB, #21 | lsr CARG4, CARG1, RB | rsb RB, RB, #20 | lsl CARG1, CARG2, #12 | cmp CARG2, #0 | orr CARG1, CARG4, CARG1, lsl RB | rsblt CARG1, CARG1, #0 | bx lr | |.macro .ffunc_bit, name | .ffunc_1 bit_..name | checktp CARG2, LJ_TISNUM | blne ->vm_tobit_fb |.endmacro | |.ffunc_bit tobit | mvn CARG2, #~LJ_TISNUM | b ->fff_restv | |.macro .ffunc_bit_op, name, ins | .ffunc_bit name | mov CARG3, CARG1 | mov RA, #8 |1: | ldrd CARG12, [BASE, RA] | cmp RA, NARGS8:RC | add RA, RA, #8 | bge >2 | checktp CARG2, LJ_TISNUM | blne ->vm_tobit_fb | ins CARG3, CARG3, CARG1 | b <1 |.endmacro | |.ffunc_bit_op band, and |.ffunc_bit_op bor, orr |.ffunc_bit_op bxor, eor | |2: | mvn CARG4, #~LJ_TISNUM | ldr PC, [BASE, FRAME_PC] | strd CARG34, [BASE, #-8] | b ->fff_res1 | |.ffunc_bit bswap | eor CARG3, CARG1, CARG1, ror #16 | bic CARG3, CARG3, #0x00ff0000 | ror CARG1, CARG1, #8 | mvn CARG2, #~LJ_TISNUM | eor CARG1, CARG1, CARG3, lsr #8 | b ->fff_restv | |.ffunc_bit bnot | mvn CARG1, CARG1 | mvn CARG2, #~LJ_TISNUM | b ->fff_restv | |.macro .ffunc_bit_sh, name, ins, shmod | .ffunc bit_..name | ldrd CARG12, [BASE, #8] | cmp NARGS8:RC, #16 | blo ->fff_fallback | checktp CARG2, LJ_TISNUM | blne ->vm_tobit_fb |.if shmod == 0 | and RA, CARG1, #31 |.else | rsb RA, CARG1, #0 |.endif | ldrd CARG12, [BASE] | checktp CARG2, LJ_TISNUM | blne ->vm_tobit_fb | ins CARG1, CARG1, RA | mvn CARG2, #~LJ_TISNUM | b ->fff_restv |.endmacro | |.ffunc_bit_sh lshift, lsl, 0 |.ffunc_bit_sh rshift, lsr, 0 |.ffunc_bit_sh arshift, asr, 0 |.ffunc_bit_sh rol, ror, 1 |.ffunc_bit_sh ror, ror, 0 | |//----------------------------------------------------------------------- | |->fff_fallback: // Call fast function fallback handler. | // BASE = new base, RC = nargs*8 | ldr CARG3, [BASE, FRAME_FUNC] | ldr CARG2, L->maxstack | add CARG1, BASE, NARGS8:RC | ldr PC, [BASE, FRAME_PC] // Fallback may overwrite PC. | str CARG1, L->top | ldr CARG3, CFUNC:CARG3->f | str BASE, L->base | add CARG1, CARG1, #8*LUA_MINSTACK | str PC, SAVE_PC // Redundant (but a defined value). | cmp CARG1, CARG2 | mov CARG1, L | bhi >5 // Need to grow stack. | blx CARG3 // (lua_State *L) | // Either throws an error, or recovers and returns -1, 0 or nresults+1. | ldr BASE, L->base | cmp CRET1, #0 | lsl RC, CRET1, #3 | sub RA, BASE, #8 | bgt ->fff_res // Returned nresults+1? |1: // Returned 0 or -1: retry fast path. | ldr CARG1, L->top | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] | sub NARGS8:RC, CARG1, BASE | bne ->vm_call_tail // Returned -1? | ins_callt // Returned 0: retry fast path. | |// Reconstruct previous base for vmeta_call during tailcall. |->vm_call_tail: | ands CARG1, PC, #FRAME_TYPE | bic CARG2, PC, #FRAME_TYPEP | ldreq INS, [PC, #-4] | andeq CARG2, MASKR8, INS, lsr #5 // Conditional decode_RA8. | addeq CARG2, CARG2, #8 | sub RB, BASE, CARG2 | b ->vm_call_dispatch // Resolve again for tailcall. | |5: // Grow stack for fallback handler. | mov CARG2, #LUA_MINSTACK | bl extern lj_state_growstack // (lua_State *L, int n) | ldr BASE, L->base | cmp CARG1, CARG1 // Set zero-flag to force retry. | b <1 | |->fff_gcstep: // Call GC step function. | // BASE = new base, RC = nargs*8 | mov RA, lr | str BASE, L->base | add CARG2, BASE, NARGS8:RC | str PC, SAVE_PC // Redundant (but a defined value). | str CARG2, L->top | mov CARG1, L | bl extern lj_gc_step // (lua_State *L) | ldr BASE, L->base | mov lr, RA // Help return address predictor. | ldr CFUNC:CARG3, [BASE, FRAME_FUNC] | bx lr | |//----------------------------------------------------------------------- |//-- Special dispatch targets ------------------------------------------- |//----------------------------------------------------------------------- | |->vm_record: // Dispatch target for recording phase. |.if JIT | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] | tst CARG1, #HOOK_VMEVENT // No recording while in vmevent. | bne >5 | // Decrement the hookcount for consistency, but always do the call. | ldr CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] | tst CARG1, #HOOK_ACTIVE | bne >1 | sub CARG2, CARG2, #1 | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT | strne CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] | b >1 |.endif | |->vm_rethook: // Dispatch target for return hooks. | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] | tst CARG1, #HOOK_ACTIVE // Hook already active? | beq >1 |5: // Re-dispatch to static ins. | decode_OP OP, INS | add OP, DISPATCH, OP, lsl #2 | ldr pc, [OP, #GG_DISP2STATIC] | |->vm_inshook: // Dispatch target for instr/line hooks. | ldrb CARG1, [DISPATCH, #DISPATCH_GL(hookmask)] | ldr CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] | tst CARG1, #HOOK_ACTIVE // Hook already active? | bne <5 | tst CARG1, #LUA_MASKLINE|LUA_MASKCOUNT | beq <5 | subs CARG2, CARG2, #1 | str CARG2, [DISPATCH, #DISPATCH_GL(hookcount)] | beq >1 | tst CARG1, #LUA_MASKLINE | beq <5 |1: | mov CARG1, L | str BASE, L->base | mov CARG2, PC | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) |3: | ldr BASE, L->base |4: // Re-dispatch to static ins. | ldrb OP, [PC, #-4] | ldr INS, [PC, #-4] | add OP, DISPATCH, OP, lsl #2 | ldr OP, [OP, #GG_DISP2STATIC] | decode_RA8 RA, INS | decode_RD RC, INS | bx OP | |->cont_hook: // Continue from hook yield. | ldr CARG1, [CARG4, #-24] | add PC, PC, #4 | str CARG1, SAVE_MULTRES // Restore MULTRES for *M ins. | b <4 | |->vm_hotloop: // Hot loop counter underflow. |.if JIT | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Same as curr_topL(L). | sub CARG1, DISPATCH, #-GG_DISP2J | str PC, SAVE_PC | ldr CARG3, LFUNC:CARG3->field_pc | mov CARG2, PC | str L, [DISPATCH, #DISPATCH_J(L)] | ldrb CARG3, [CARG3, #PC2PROTO(framesize)] | str BASE, L->base | add CARG3, BASE, CARG3, lsl #3 | str CARG3, L->top | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc) | b <3 |.endif | |->vm_callhook: // Dispatch target for call hooks. | mov CARG2, PC |.if JIT | b >1 |.endif | |->vm_hotcall: // Hot call counter underflow. |.if JIT | orr CARG2, PC, #1 |1: |.endif | add CARG4, BASE, RC | str PC, SAVE_PC | mov CARG1, L | str BASE, L->base | sub RA, RA, BASE | str CARG4, L->top | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) | // Returns ASMFunction. | ldr BASE, L->base | ldr CARG4, L->top | mov CARG2, #0 | add RA, BASE, RA | sub NARGS8:RC, CARG4, BASE | str CARG2, SAVE_PC // Invalidate for subsequent line hook. | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] | ldr INS, [PC, #-4] | bx CRET1 | |//----------------------------------------------------------------------- |//-- Trace exit handler ------------------------------------------------- |//----------------------------------------------------------------------- | |->vm_exit_handler: |.if JIT | sub sp, sp, #12 | push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12} | ldr CARG1, [sp, #64] // Load original value of lr. | ldr DISPATCH, [lr] // Load DISPATCH. | add CARG3, sp, #64 // Recompute original value of sp. | mv_vmstate CARG4, EXIT | str CARG3, [sp, #52] // Store sp in RID_SP | st_vmstate CARG4 | ldr CARG2, [CARG1, #-4]! // Get exit instruction. | str CARG1, [sp, #56] // Store exit pc in RID_LR and RID_PC. | str CARG1, [sp, #60] |.if FPU | vpush {d0-d15} |.endif | lsl CARG2, CARG2, #8 | add CARG1, CARG1, CARG2, asr #6 | ldr CARG2, [lr, #4] // Load exit stub group offset. | sub CARG1, CARG1, lr | ldr L, [DISPATCH, #DISPATCH_GL(jit_L)] | add CARG1, CARG2, CARG1, lsr #2 // Compute exit number. | ldr BASE, [DISPATCH, #DISPATCH_GL(jit_base)] | str CARG1, [DISPATCH, #DISPATCH_J(exitno)] | mov CARG4, #0 | str L, [DISPATCH, #DISPATCH_J(L)] | str BASE, L->base | str CARG4, [DISPATCH, #DISPATCH_GL(jit_L)] | sub CARG1, DISPATCH, #-GG_DISP2J | mov CARG2, sp | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) | // Returns MULTRES (unscaled) or negated error code. | ldr CARG2, L->cframe | ldr BASE, L->base | bic CARG2, CARG2, #~CFRAME_RAWMASK // Use two steps: bic sp is deprecated. | mov sp, CARG2 | ldr PC, SAVE_PC // Get SAVE_PC. | str L, SAVE_L // Set SAVE_L (on-trace resume/yield). | b >1 |.endif |->vm_exit_interp: | // CARG1 = MULTRES or negated error code, BASE, PC and DISPATCH set. |.if JIT | ldr L, SAVE_L |1: | cmp CARG1, #0 | blt >3 // Check for error from exit. | lsl RC, CARG1, #3 | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] | str RC, SAVE_MULTRES | mov CARG3, #0 | ldr CARG2, LFUNC:CARG2->field_pc | str CARG3, [DISPATCH, #DISPATCH_GL(jit_L)] | mv_vmstate CARG4, INTERP | ldr KBASE, [CARG2, #PC2PROTO(k)] | // Modified copy of ins_next which handles function header dispatch, too. | ldrb OP, [PC] | mov MASKR8, #255 | ldr INS, [PC], #4 | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. | st_vmstate CARG4 | cmp OP, #BC_FUNCF // Function header? | ldr OP, [DISPATCH, OP, lsl #2] | decode_RA8 RA, INS | lsrlo RC, INS, #16 // No: Decode operands A*8 and D. | subhs RC, RC, #8 | addhs RA, RA, BASE // Yes: RA = BASE+framesize*8, RC = nargs*8 | bx OP | |3: // Rethrow error from the right C frame. | rsb CARG2, CARG1, #0 | mov CARG1, L | bl extern lj_err_throw // (lua_State *L, int errcode) |.endif | |//----------------------------------------------------------------------- |//-- Math helper functions ---------------------------------------------- |//----------------------------------------------------------------------- | |// FP value rounding. Called from JIT code. |// |// double lj_vm_floor/ceil/trunc(double x); |.macro vm_round, func, hf |.if hf == 1 | vmov CARG1, CARG2, d0 |.endif | lsl CARG3, CARG2, #1 | adds RB, CARG3, #0x00200000 | bpl >2 // |x| < 1? | mvn CARG4, #0x3cc | subs RB, CARG4, RB, asr #21 // 2^0: RB = 51, 2^51: RB = 0. | bxlo lr // |x| >= 2^52: done. | mvn CARG4, #1 | bic CARG3, CARG1, CARG4, lsl RB // ztest = lo & ~lomask | and CARG1, CARG1, CARG4, lsl RB // lo &= lomask | subs RB, RB, #32 | bicpl CARG4, CARG2, CARG4, lsl RB // |x| <= 2^20: ztest |= hi & ~himask | orrpl CARG3, CARG3, CARG4 | mvnpl CARG4, #1 | andpl CARG2, CARG2, CARG4, lsl RB // |x| <= 2^20: hi &= himask |.if "func" == "floor" | tst CARG3, CARG2, asr #31 // iszero = ((ztest & signmask) == 0) |.else | bics CARG3, CARG3, CARG2, asr #31 // iszero = ((ztest & ~signmask) == 0) |.endif |.if hf == 1 | vmoveq d0, CARG1, CARG2 |.endif | bxeq lr // iszero: done. | mvn CARG4, #1 | cmp RB, #0 | lslpl CARG3, CARG4, RB | mvnmi CARG3, #0 | add RB, RB, #32 | subs CARG1, CARG1, CARG4, lsl RB // lo = lo-lomask | sbc CARG2, CARG2, CARG3 // hi = hi-himask+carry |.if hf == 1 | vmov d0, CARG1, CARG2 |.endif | bx lr | |2: // |x| < 1: | bxcs lr // |x| is not finite. | orr CARG3, CARG3, CARG1 // ztest = (2*hi) | lo |.if "func" == "floor" | tst CARG3, CARG2, asr #31 // iszero = ((ztest & signmask) == 0) |.else | bics CARG3, CARG3, CARG2, asr #31 // iszero = ((ztest & ~signmask) == 0) |.endif | mov CARG1, #0 // lo = 0 | and CARG2, CARG2, #0x80000000 | ldrne CARG4, <9 // hi = sign(x) | (iszero ? 0.0 : 1.0) | orrne CARG2, CARG2, CARG4 |.if hf == 1 | vmov d0, CARG1, CARG2 |.endif | bx lr |.endmacro | |9: | .long 0x3ff00000 // hiword(+1.0) | |->vm_floor: |.if HFABI | vm_round floor, 1 |.endif |->vm_floor_sf: | vm_round floor, 0 | |->vm_ceil: |.if HFABI | vm_round ceil, 1 |.endif |->vm_ceil_sf: | vm_round ceil, 0 | |.macro vm_trunc, hf |.if JIT |.if hf == 1 | vmov CARG1, CARG2, d0 |.endif | lsl CARG3, CARG2, #1 | adds RB, CARG3, #0x00200000 | andpl CARG2, CARG2, #0x80000000 // |x| < 1? hi = sign(x), lo = 0. | movpl CARG1, #0 |.if hf == 1 | vmovpl d0, CARG1, CARG2 |.endif | bxpl lr | mvn CARG4, #0x3cc | subs RB, CARG4, RB, asr #21 // 2^0: RB = 51, 2^51: RB = 0. | bxlo lr // |x| >= 2^52: already done. | mvn CARG4, #1 | and CARG1, CARG1, CARG4, lsl RB // lo &= lomask | subs RB, RB, #32 | andpl CARG2, CARG2, CARG4, lsl RB // |x| <= 2^20: hi &= himask |.if hf == 1 | vmov d0, CARG1, CARG2 |.endif | bx lr |.endif |.endmacro | |->vm_trunc: |.if HFABI | vm_trunc 1 |.endif |->vm_trunc_sf: | vm_trunc 0 | | // double lj_vm_mod(double dividend, double divisor); |->vm_mod: |.if FPU | // Special calling convention. Also, RC (r11) is not preserved. | vdiv.f64 d0, d6, d7 | mov RC, lr | vmov CARG1, CARG2, d0 | bl ->vm_floor_sf | vmov d0, CARG1, CARG2 | vmul.f64 d0, d0, d7 | mov lr, RC | vsub.f64 d6, d6, d0 | bx lr |.else | push {r0, r1, r2, r3, r4, lr} | bl extern __aeabi_ddiv | bl ->vm_floor_sf | ldrd CARG34, [sp, #8] | bl extern __aeabi_dmul | ldrd CARG34, [sp] | eor CARG2, CARG2, #0x80000000 | bl extern __aeabi_dadd | add sp, sp, #20 | pop {pc} |.endif | | // int lj_vm_modi(int dividend, int divisor); |->vm_modi: | ands RB, CARG1, #0x80000000 | rsbmi CARG1, CARG1, #0 // a = |dividend| | eor RB, RB, CARG2, asr #1 // Keep signdiff and sign(divisor). | cmp CARG2, #0 | rsbmi CARG2, CARG2, #0 // b = |divisor| | subs CARG4, CARG2, #1 | cmpne CARG1, CARG2 | moveq CARG1, #0 // if (b == 1 || a == b) a = 0 | tsthi CARG2, CARG4 | andeq CARG1, CARG1, CARG4 // else if ((b & (b-1)) == 0) a &= b-1 | bls >1 | // Use repeated subtraction to get the remainder. | clz CARG3, CARG1 | clz CARG4, CARG2 | sub CARG4, CARG4, CARG3 | rsbs CARG3, CARG4, #31 // entry = (31-(clz(b)-clz(a)))*8 | addne pc, pc, CARG3, lsl #3 // Duff's device. | nop { int i; for (i = 31; i >= 0; i--) { | cmp CARG1, CARG2, lsl #i | subhs CARG1, CARG1, CARG2, lsl #i } } |1: | cmp CARG1, #0 | cmpne RB, #0 | submi CARG1, CARG1, CARG2 // if (y != 0 && signdiff) y = y - b | eors CARG2, CARG1, RB, lsl #1 | rsbmi CARG1, CARG1, #0 // if (sign(divisor) != sign(y)) y = -y | bx lr | |//----------------------------------------------------------------------- |//-- Miscellaneous functions -------------------------------------------- |//----------------------------------------------------------------------- | |//----------------------------------------------------------------------- |//-- FFI helper functions ----------------------------------------------- |//----------------------------------------------------------------------- | |// Handler for callback functions. |// Saveregs already performed. Callback slot number in [sp], g in r12. |->vm_ffi_callback: |.if FFI |.type CTSTATE, CTState, PC | ldr CTSTATE, GL:r12->ctype_state | add DISPATCH, r12, #GG_G2DISP |.if FPU | str r4, SAVE_R4 | add r4, sp, CFRAME_SPACE+4+8*8 | vstmdb r4!, {d8-d15} |.endif |.if HFABI | add r12, CTSTATE, #offsetof(CTState, cb.fpr[8]) |.endif | strd CARG34, CTSTATE->cb.gpr[2] | strd CARG12, CTSTATE->cb.gpr[0] |.if HFABI | vstmdb r12!, {d0-d7} |.endif | ldr CARG4, [sp] | add CARG3, sp, #CFRAME_SIZE | mov CARG1, CTSTATE | lsr CARG4, CARG4, #3 | str CARG3, CTSTATE->cb.stack | mov CARG2, sp | str CARG4, CTSTATE->cb.slot | str CTSTATE, SAVE_PC // Any value outside of bytecode is ok. | bl extern lj_ccallback_enter // (CTState *cts, void *cf) | // Returns lua_State *. | ldr BASE, L:CRET1->base | mv_vmstate CARG2, INTERP | ldr RC, L:CRET1->top | mov MASKR8, #255 | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] | mov L, CRET1 | sub RC, RC, BASE | lsl MASKR8, MASKR8, #3 // MASKR8 = 255*8. | st_vmstate CARG2 | ins_callt |.endif | |->cont_ffi_callback: // Return from FFI callback. |.if FFI | ldr CTSTATE, [DISPATCH, #DISPATCH_GL(ctype_state)] | str BASE, L->base | str CARG4, L->top | str L, CTSTATE->L | mov CARG1, CTSTATE | mov CARG2, RA | bl extern lj_ccallback_leave // (CTState *cts, TValue *o) | ldrd CARG12, CTSTATE->cb.gpr[0] |.if HFABI | vldr d0, CTSTATE->cb.fpr[0] |.endif | b ->vm_leave_unw |.endif | |->vm_ffi_call: // Call C function via FFI. | // Caveat: needs special frame unwinding, see below. |.if FFI | .type CCSTATE, CCallState, r4 | push {CCSTATE, r5, r11, lr} | mov CCSTATE, CARG1 | ldr CARG1, CCSTATE:CARG1->spadj | ldrb CARG2, CCSTATE->nsp | add CARG3, CCSTATE, #offsetof(CCallState, stack) |.if HFABI | add RB, CCSTATE, #offsetof(CCallState, fpr[0]) |.endif | mov r11, sp | sub sp, sp, CARG1 // Readjust stack. | subs CARG2, CARG2, #1 |.if HFABI | vldm RB, {d0-d7} |.endif | ldr RB, CCSTATE->func | bmi >2 |1: // Copy stack slots. | ldr CARG4, [CARG3, CARG2, lsl #2] | str CARG4, [sp, CARG2, lsl #2] | subs CARG2, CARG2, #1 | bpl <1 |2: | ldrd CARG12, CCSTATE->gpr[0] | ldrd CARG34, CCSTATE->gpr[2] | blx RB | mov sp, r11 |.if HFABI | add r12, CCSTATE, #offsetof(CCallState, fpr[4]) |.endif | strd CRET1, CCSTATE->gpr[0] |.if HFABI | vstmdb r12!, {d0-d3} |.endif | pop {CCSTATE, r5, r11, pc} |.endif |// Note: vm_ffi_call must be the last function in this object file! | |//----------------------------------------------------------------------- } /* Generate the code for a single instruction. */ static void build_ins(BuildCtx *ctx, BCOp op, int defop) { int vk = 0; |=>defop: switch (op) { /* -- Comparison ops ---------------------------------------------------- */ /* Remember: all ops branch for a true comparison, fall through otherwise. */ case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: | // RA = src1*8, RC = src2, JMP with RC = target | lsl RC, RC, #3 | ldrd CARG12, [RA, BASE]! | ldrh RB, [PC, #2] | ldrd CARG34, [RC, BASE]! | add PC, PC, #4 | add RB, PC, RB, lsl #2 | checktp CARG2, LJ_TISNUM | bne >3 | checktp CARG4, LJ_TISNUM | bne >4 | cmp CARG1, CARG3 if (op == BC_ISLT) { | sublt PC, RB, #0x20000 } else if (op == BC_ISGE) { | subge PC, RB, #0x20000 } else if (op == BC_ISLE) { | suble PC, RB, #0x20000 } else { | subgt PC, RB, #0x20000 } |1: | ins_next | |3: // CARG12 is not an integer. |.if FPU | vldr d0, [RA] | bhi ->vmeta_comp | // d0 is a number. | checktp CARG4, LJ_TISNUM | vldr d1, [RC] | blo >5 | bhi ->vmeta_comp | // d0 is a number, CARG3 is an integer. | vmov s4, CARG3 | vcvt.f64.s32 d1, s4 | b >5 |4: // CARG1 is an integer, CARG34 is not an integer. | vldr d1, [RC] | bhi ->vmeta_comp | // CARG1 is an integer, d1 is a number. | vmov s4, CARG1 | vcvt.f64.s32 d0, s4 |5: // d0 and d1 are numbers. | vcmp.f64 d0, d1 | vmrs | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. if (op == BC_ISLT) { | sublo PC, RB, #0x20000 } else if (op == BC_ISGE) { | subhs PC, RB, #0x20000 } else if (op == BC_ISLE) { | subls PC, RB, #0x20000 } else { | subhi PC, RB, #0x20000 } | b <1 |.else | bhi ->vmeta_comp | // CARG12 is a number. | checktp CARG4, LJ_TISNUM | movlo RA, RB // Save RB. | blo >5 | bhi ->vmeta_comp | // CARG12 is a number, CARG3 is an integer. | mov CARG1, CARG3 | mov RC, RA | mov RA, RB // Save RB. | bl extern __aeabi_i2d | mov CARG3, CARG1 | mov CARG4, CARG2 | ldrd CARG12, [RC] // Restore first operand. | b >5 |4: // CARG1 is an integer, CARG34 is not an integer. | bhi ->vmeta_comp | // CARG1 is an integer, CARG34 is a number. | mov RA, RB // Save RB. | bl extern __aeabi_i2d | ldrd CARG34, [RC] // Restore second operand. |5: // CARG12 and CARG34 are numbers. | bl extern __aeabi_cdcmple | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. if (op == BC_ISLT) { | sublo PC, RA, #0x20000 } else if (op == BC_ISGE) { | subhs PC, RA, #0x20000 } else if (op == BC_ISLE) { | subls PC, RA, #0x20000 } else { | subhi PC, RA, #0x20000 } | b <1 |.endif break; case BC_ISEQV: case BC_ISNEV: vk = op == BC_ISEQV; | // RA = src1*8, RC = src2, JMP with RC = target | lsl RC, RC, #3 | ldrd CARG12, [RA, BASE]! | ldrh RB, [PC, #2] | ldrd CARG34, [RC, BASE]! | add PC, PC, #4 | add RB, PC, RB, lsl #2 | checktp CARG2, LJ_TISNUM | cmnls CARG4, #-LJ_TISNUM if (vk) { | bls ->BC_ISEQN_Z } else { | bls ->BC_ISNEN_Z } | // Either or both types are not numbers. |.if FFI | checktp CARG2, LJ_TCDATA | checktpne CARG4, LJ_TCDATA | beq ->vmeta_equal_cd |.endif | cmp CARG2, CARG4 // Compare types. | bne >2 // Not the same type? | checktp CARG2, LJ_TISPRI | bhs >1 // Same type and primitive type? | | // Same types and not a primitive type. Compare GCobj or pvalue. | cmp CARG1, CARG3 if (vk) { | bne >3 // Different GCobjs or pvalues? |1: // Branch if same. | sub PC, RB, #0x20000 |2: // Different. | ins_next |3: | checktp CARG2, LJ_TISTABUD | bhi <2 // Different objects and not table/ud? } else { | beq >1 // Same GCobjs or pvalues? | checktp CARG2, LJ_TISTABUD | bhi >2 // Different objects and not table/ud? } | // Different tables or userdatas. Need to check __eq metamethod. | // Field metatable must be at same offset for GCtab and GCudata! | ldr TAB:RA, TAB:CARG1->metatable | cmp TAB:RA, #0 if (vk) { | beq <2 // No metatable? } else { | beq >2 // No metatable? } | ldrb RA, TAB:RA->nomm | mov CARG4, #1-vk // ne = 0 or 1. | mov CARG2, CARG1 | tst RA, #1<vmeta_equal // 'no __eq' flag not set? if (vk) { | b <2 } else { |2: // Branch if different. | sub PC, RB, #0x20000 |1: // Same. | ins_next } break; case BC_ISEQS: case BC_ISNES: vk = op == BC_ISEQS; | // RA = src*8, RC = str_const (~), JMP with RC = target | mvn RC, RC | ldrd CARG12, [BASE, RA] | ldrh RB, [PC, #2] | ldr STR:CARG3, [KBASE, RC, lsl #2] | add PC, PC, #4 | add RB, PC, RB, lsl #2 | checktp CARG2, LJ_TSTR |.if FFI | bne >7 | cmp CARG1, CARG3 |.else | cmpeq CARG1, CARG3 |.endif if (vk) { | subeq PC, RB, #0x20000 |1: } else { |1: | subne PC, RB, #0x20000 } | ins_next | |.if FFI |7: | checktp CARG2, LJ_TCDATA | bne <1 | b ->vmeta_equal_cd |.endif break; case BC_ISEQN: case BC_ISNEN: vk = op == BC_ISEQN; | // RA = src*8, RC = num_const (~), JMP with RC = target | lsl RC, RC, #3 | ldrd CARG12, [RA, BASE]! | ldrh RB, [PC, #2] | ldrd CARG34, [RC, KBASE]! | add PC, PC, #4 | add RB, PC, RB, lsl #2 if (vk) { |->BC_ISEQN_Z: } else { |->BC_ISNEN_Z: } | checktp CARG2, LJ_TISNUM | bne >3 | checktp CARG4, LJ_TISNUM | bne >4 | cmp CARG1, CARG3 if (vk) { | subeq PC, RB, #0x20000 |1: } else { |1: | subne PC, RB, #0x20000 } |2: | ins_next | |3: // CARG12 is not an integer. |.if FFI | bhi >7 |.else if (!vk) { | subhi PC, RB, #0x20000 } | bhi <2 |.endif |.if FPU | checktp CARG4, LJ_TISNUM | vmov s4, CARG3 | vldr d0, [RA] | vldrlo d1, [RC] | vcvths.f64.s32 d1, s4 | b >5 |4: // CARG1 is an integer, d1 is a number. | vmov s4, CARG1 | vldr d1, [RC] | vcvt.f64.s32 d0, s4 |5: // d0 and d1 are numbers. | vcmp.f64 d0, d1 | vmrs if (vk) { | subeq PC, RB, #0x20000 } else { | subne PC, RB, #0x20000 } | b <2 |.else | // CARG12 is a number. | checktp CARG4, LJ_TISNUM | movlo RA, RB // Save RB. | blo >5 | // CARG12 is a number, CARG3 is an integer. | mov CARG1, CARG3 | mov RC, RA |4: // CARG1 is an integer, CARG34 is a number. | mov RA, RB // Save RB. | bl extern __aeabi_i2d | ldrd CARG34, [RC] // Restore other operand. |5: // CARG12 and CARG34 are numbers. | bl extern __aeabi_cdcmpeq if (vk) { | subeq PC, RA, #0x20000 } else { | subne PC, RA, #0x20000 } | b <2 |.endif | |.if FFI |7: | checktp CARG2, LJ_TCDATA | bne <1 | b ->vmeta_equal_cd |.endif break; case BC_ISEQP: case BC_ISNEP: vk = op == BC_ISEQP; | // RA = src*8, RC = primitive_type (~), JMP with RC = target | ldrd CARG12, [BASE, RA] | ldrh RB, [PC, #2] | add PC, PC, #4 | mvn RC, RC | add RB, PC, RB, lsl #2 |.if FFI | checktp CARG2, LJ_TCDATA | beq ->vmeta_equal_cd |.endif | cmp CARG2, RC if (vk) { | subeq PC, RB, #0x20000 } else { | subne PC, RB, #0x20000 } | ins_next break; /* -- Unary test and copy ops ------------------------------------------- */ case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: | // RA = dst*8 or unused, RC = src, JMP with RC = target | add RC, BASE, RC, lsl #3 | ldrh RB, [PC, #2] | ldrd CARG12, [RC] | add PC, PC, #4 | add RB, PC, RB, lsl #2 | checktp CARG2, LJ_TTRUE if (op == BC_ISTC || op == BC_IST) { | subls PC, RB, #0x20000 if (op == BC_ISTC) { | strdls CARG12, [BASE, RA] } } else { | subhi PC, RB, #0x20000 if (op == BC_ISFC) { | strdhi CARG12, [BASE, RA] } } | ins_next break; /* -- Unary ops --------------------------------------------------------- */ case BC_MOV: | // RA = dst*8, RC = src | lsl RC, RC, #3 | ins_next1 | ldrd CARG12, [BASE, RC] | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 break; case BC_NOT: | // RA = dst*8, RC = src | add RC, BASE, RC, lsl #3 | ins_next1 | ldr CARG1, [RC, #4] | add RA, BASE, RA | ins_next2 | checktp CARG1, LJ_TTRUE | mvnls CARG2, #~LJ_TFALSE | mvnhi CARG2, #~LJ_TTRUE | str CARG2, [RA, #4] | ins_next3 break; case BC_UNM: | // RA = dst*8, RC = src | lsl RC, RC, #3 | ldrd CARG12, [BASE, RC] | ins_next1 | ins_next2 | checktp CARG2, LJ_TISNUM | bhi ->vmeta_unm | eorne CARG2, CARG2, #0x80000000 | bne >5 | rsbseq CARG1, CARG1, #0 | ldrdvs CARG12, >9 |5: | strd CARG12, [BASE, RA] | ins_next3 | |.align 8 |9: | .long 0x00000000, 0x41e00000 // 2^31. break; case BC_LEN: | // RA = dst*8, RC = src | lsl RC, RC, #3 | ldrd CARG12, [BASE, RC] | checkstr CARG2, >2 | ldr CARG1, STR:CARG1->len |1: | mvn CARG2, #~LJ_TISNUM | ins_next1 | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 |2: | checktab CARG2, ->vmeta_len #if LJ_52 | ldr TAB:CARG3, TAB:CARG1->metatable | cmp TAB:CARG3, #0 | bne >9 |3: #endif |->BC_LEN_Z: | .IOS mov RC, BASE | bl extern lj_tab_len // (GCtab *t) | // Returns uint32_t (but less than 2^31). | .IOS mov BASE, RC | b <1 #if LJ_52 |9: | ldrb CARG4, TAB:CARG3->nomm | tst CARG4, #1<vmeta_len #endif break; /* -- Binary ops -------------------------------------------------------- */ |.macro ins_arithcheck, cond, ncond, target ||if (vk == 1) { | cmn CARG4, #-LJ_TISNUM | cmn..cond CARG2, #-LJ_TISNUM ||} else { | cmn CARG2, #-LJ_TISNUM | cmn..cond CARG4, #-LJ_TISNUM ||} | b..ncond target |.endmacro |.macro ins_arithcheck_int, target | ins_arithcheck eq, ne, target |.endmacro |.macro ins_arithcheck_num, target | ins_arithcheck lo, hs, target |.endmacro | |.macro ins_arithpre | decode_RB8 RB, INS | decode_RC8 RC, INS | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); ||switch (vk) { ||case 0: | .if FPU | ldrd CARG12, [RB, BASE]! | ldrd CARG34, [RC, KBASE]! | .else | ldrd CARG12, [BASE, RB] | ldrd CARG34, [KBASE, RC] | .endif || break; ||case 1: | .if FPU | ldrd CARG34, [RB, BASE]! | ldrd CARG12, [RC, KBASE]! | .else | ldrd CARG34, [BASE, RB] | ldrd CARG12, [KBASE, RC] | .endif || break; ||default: | .if FPU | ldrd CARG12, [RB, BASE]! | ldrd CARG34, [RC, BASE]! | .else | ldrd CARG12, [BASE, RB] | ldrd CARG34, [BASE, RC] | .endif || break; ||} |.endmacro | |.macro ins_arithpre_fpu, reg1, reg2 |.if FPU ||if (vk == 1) { | vldr reg2, [RB] | vldr reg1, [RC] ||} else { | vldr reg1, [RB] | vldr reg2, [RC] ||} |.endif |.endmacro | |.macro ins_arithpost_fpu, reg | ins_next1 | add RA, BASE, RA | ins_next2 | vstr reg, [RA] | ins_next3 |.endmacro | |.macro ins_arithfallback, ins ||switch (vk) { ||case 0: | ins ->vmeta_arith_vn || break; ||case 1: | ins ->vmeta_arith_nv || break; ||default: | ins ->vmeta_arith_vv || break; ||} |.endmacro | |.macro ins_arithdn, intins, fpins, fpcall | ins_arithpre |.if "intins" ~= "vm_modi" and not FPU | ins_next1 |.endif | ins_arithcheck_int >5 |.if "intins" == "smull" | smull CARG1, RC, CARG3, CARG1 | cmp RC, CARG1, asr #31 | ins_arithfallback bne |.elif "intins" == "vm_modi" | movs CARG2, CARG3 | ins_arithfallback beq | bl ->vm_modi | mvn CARG2, #~LJ_TISNUM |.else | intins CARG1, CARG1, CARG3 | ins_arithfallback bvs |.endif |4: |.if "intins" == "vm_modi" or FPU | ins_next1 |.endif | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 |5: // FP variant. | ins_arithpre_fpu d6, d7 | ins_arithfallback ins_arithcheck_num |.if FPU |.if "intins" == "vm_modi" | bl fpcall |.else | fpins d6, d6, d7 |.endif | ins_arithpost_fpu d6 |.else | bl fpcall |.if "intins" ~= "vm_modi" | ins_next1 |.endif | b <4 |.endif |.endmacro | |.macro ins_arithfp, fpins, fpcall | ins_arithpre |.if "fpins" ~= "extern" or HFABI | ins_arithpre_fpu d0, d1 |.endif | ins_arithfallback ins_arithcheck_num |.if "fpins" == "extern" | .IOS mov RC, BASE | bl fpcall | .IOS mov BASE, RC |.elif FPU | fpins d0, d0, d1 |.else | bl fpcall |.endif |.if ("fpins" ~= "extern" or HFABI) and FPU | ins_arithpost_fpu d0 |.else | ins_next1 | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 |.endif |.endmacro case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: | ins_arithdn adds, vadd.f64, extern __aeabi_dadd break; case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: | ins_arithdn subs, vsub.f64, extern __aeabi_dsub break; case BC_MULVN: case BC_MULNV: case BC_MULVV: | ins_arithdn smull, vmul.f64, extern __aeabi_dmul break; case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: | ins_arithfp vdiv.f64, extern __aeabi_ddiv break; case BC_MODVN: case BC_MODNV: case BC_MODVV: | ins_arithdn vm_modi, vm_mod, ->vm_mod break; case BC_POW: | // NYI: (partial) integer arithmetic. | ins_arithfp extern, extern pow break; case BC_CAT: | decode_RB8 RC, INS | decode_RC8 RB, INS | // RA = dst*8, RC = src_start*8, RB = src_end*8 (note: RB/RC swapped!) | sub CARG3, RB, RC | str BASE, L->base | add CARG2, BASE, RB |->BC_CAT_Z: | // RA = dst*8, RC = src_start*8, CARG2 = top-1 | mov CARG1, L | str PC, SAVE_PC | lsr CARG3, CARG3, #3 | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) | // Returns NULL (finished) or TValue * (metamethod). | ldr BASE, L->base | cmp CRET1, #0 | bne ->vmeta_binop | ldrd CARG34, [BASE, RC] | ins_next1 | ins_next2 | strd CARG34, [BASE, RA] // Copy result to RA. | ins_next3 break; /* -- Constant ops ------------------------------------------------------ */ case BC_KSTR: | // RA = dst*8, RC = str_const (~) | mvn RC, RC | ins_next1 | ldr CARG1, [KBASE, RC, lsl #2] | mvn CARG2, #~LJ_TSTR | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 break; case BC_KCDATA: |.if FFI | // RA = dst*8, RC = cdata_const (~) | mvn RC, RC | ins_next1 | ldr CARG1, [KBASE, RC, lsl #2] | mvn CARG2, #~LJ_TCDATA | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 |.endif break; case BC_KSHORT: | // RA = dst*8, (RC = int16_literal) | mov CARG1, INS, asr #16 // Refetch sign-extended reg. | mvn CARG2, #~LJ_TISNUM | ins_next1 | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 break; case BC_KNUM: | // RA = dst*8, RC = num_const | lsl RC, RC, #3 | ins_next1 | ldrd CARG12, [KBASE, RC] | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 break; case BC_KPRI: | // RA = dst*8, RC = primitive_type (~) | add RA, BASE, RA | mvn RC, RC | ins_next1 | ins_next2 | str RC, [RA, #4] | ins_next3 break; case BC_KNIL: | // RA = base*8, RC = end | add RA, BASE, RA | add RC, BASE, RC, lsl #3 | mvn CARG1, #~LJ_TNIL | str CARG1, [RA, #4] | add RA, RA, #8 |1: | str CARG1, [RA, #4] | cmp RA, RC | add RA, RA, #8 | blt <1 | ins_next_ break; /* -- Upvalue and function ops ------------------------------------------ */ case BC_UGET: | // RA = dst*8, RC = uvnum | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] | lsl RC, RC, #2 | add RC, RC, #offsetof(GCfuncL, uvptr) | ldr UPVAL:CARG2, [LFUNC:CARG2, RC] | ldr CARG2, UPVAL:CARG2->v | ldrd CARG34, [CARG2] | ins_next1 | ins_next2 | strd CARG34, [BASE, RA] | ins_next3 break; case BC_USETV: | // RA = uvnum*8, RC = src | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] | lsr RA, RA, #1 | add RA, RA, #offsetof(GCfuncL, uvptr) | lsl RC, RC, #3 | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] | ldrd CARG34, [BASE, RC] | ldrb RB, UPVAL:CARG2->marked | ldrb RC, UPVAL:CARG2->closed | ldr CARG2, UPVAL:CARG2->v | tst RB, #LJ_GC_BLACK // isblack(uv) | add RB, CARG4, #-LJ_TISGCV | cmpne RC, #0 | strd CARG34, [CARG2] | bne >2 // Upvalue is closed and black? |1: | ins_next | |2: // Check if new value is collectable. | cmn RB, #-(LJ_TISNUM - LJ_TISGCV) | ldrbhi RC, GCOBJ:CARG3->gch.marked | bls <1 // tvisgcv(v) | sub CARG1, DISPATCH, #-GG_DISP2G | tst RC, #LJ_GC_WHITES | // Crossed a write barrier. Move the barrier forward. |.if IOS | beq <1 | mov RC, BASE | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) | mov BASE, RC |.else | blne extern lj_gc_barrieruv // (global_State *g, TValue *tv) |.endif | b <1 break; case BC_USETS: | // RA = uvnum*8, RC = str_const (~) | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] | lsr RA, RA, #1 | add RA, RA, #offsetof(GCfuncL, uvptr) | mvn RC, RC | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] | ldr STR:CARG3, [KBASE, RC, lsl #2] | mvn CARG4, #~LJ_TSTR | ldrb RB, UPVAL:CARG2->marked | ldr CARG2, UPVAL:CARG2->v | ldrb RC, UPVAL:CARG2->closed | tst RB, #LJ_GC_BLACK // isblack(uv) | ldrb RB, STR:CARG3->marked | strd CARG34, [CARG2] | bne >2 |1: | ins_next | |2: // Check if string is white and ensure upvalue is closed. | tst RB, #LJ_GC_WHITES // iswhite(str) | cmpne RC, #0 | sub CARG1, DISPATCH, #-GG_DISP2G | // Crossed a write barrier. Move the barrier forward. |.if IOS | beq <1 | mov RC, BASE | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) | mov BASE, RC |.else | blne extern lj_gc_barrieruv // (global_State *g, TValue *tv) |.endif | b <1 break; case BC_USETN: | // RA = uvnum*8, RC = num_const | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] | lsr RA, RA, #1 | add RA, RA, #offsetof(GCfuncL, uvptr) | lsl RC, RC, #3 | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] | ldrd CARG34, [KBASE, RC] | ldr CARG2, UPVAL:CARG2->v | ins_next1 | ins_next2 | strd CARG34, [CARG2] | ins_next3 break; case BC_USETP: | // RA = uvnum*8, RC = primitive_type (~) | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] | lsr RA, RA, #1 | add RA, RA, #offsetof(GCfuncL, uvptr) | ldr UPVAL:CARG2, [LFUNC:CARG2, RA] | mvn RC, RC | ldr CARG2, UPVAL:CARG2->v | ins_next1 | ins_next2 | str RC, [CARG2, #4] | ins_next3 break; case BC_UCLO: | // RA = level*8, RC = target | ldr CARG3, L->openupval | add RC, PC, RC, lsl #2 | str BASE, L->base | cmp CARG3, #0 | sub PC, RC, #0x20000 | beq >1 | mov CARG1, L | add CARG2, BASE, RA | bl extern lj_func_closeuv // (lua_State *L, TValue *level) | ldr BASE, L->base |1: | ins_next break; case BC_FNEW: | // RA = dst*8, RC = proto_const (~) (holding function prototype) | mvn RC, RC | str BASE, L->base | ldr CARG2, [KBASE, RC, lsl #2] | str PC, SAVE_PC | ldr CARG3, [BASE, FRAME_FUNC] | mov CARG1, L | // (lua_State *L, GCproto *pt, GCfuncL *parent) | bl extern lj_func_newL_gc | // Returns GCfuncL *. | ldr BASE, L->base | mvn CARG2, #~LJ_TFUNC | ins_next1 | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 break; /* -- Table ops --------------------------------------------------------- */ case BC_TNEW: case BC_TDUP: | // RA = dst*8, RC = (hbits|asize) | tab_const (~) if (op == BC_TDUP) { | mvn RC, RC } | ldr CARG3, [DISPATCH, #DISPATCH_GL(gc.total)] | ldr CARG4, [DISPATCH, #DISPATCH_GL(gc.threshold)] | str BASE, L->base | str PC, SAVE_PC | cmp CARG3, CARG4 | mov CARG1, L | bhs >5 |1: if (op == BC_TNEW) { | lsl CARG2, RC, #21 | lsr CARG3, RC, #11 | asr RC, CARG2, #21 | lsr CARG2, CARG2, #21 | cmn RC, #1 | addeq CARG2, CARG2, #2 | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) | // Returns GCtab *. } else { | ldr CARG2, [KBASE, RC, lsl #2] | bl extern lj_tab_dup // (lua_State *L, Table *kt) | // Returns GCtab *. } | ldr BASE, L->base | mvn CARG2, #~LJ_TTAB | ins_next1 | ins_next2 | strd CARG12, [BASE, RA] | ins_next3 |5: | bl extern lj_gc_step_fixtop // (lua_State *L) | mov CARG1, L | b <1 break; case BC_GGET: | // RA = dst*8, RC = str_const (~) case BC_GSET: | // RA = dst*8, RC = str_const (~) | ldr LFUNC:CARG2, [BASE, FRAME_FUNC] | mvn RC, RC | ldr TAB:CARG1, LFUNC:CARG2->env | ldr STR:RC, [KBASE, RC, lsl #2] if (op == BC_GGET) { | b ->BC_TGETS_Z } else { | b ->BC_TSETS_Z } break; case BC_TGETV: | decode_RB8 RB, INS | decode_RC8 RC, INS | // RA = dst*8, RB = table*8, RC = key*8 | ldrd TAB:CARG12, [BASE, RB] | ldrd CARG34, [BASE, RC] | checktab CARG2, ->vmeta_tgetv // STALL: load CARG12. | checktp CARG4, LJ_TISNUM // Integer key? | ldreq CARG4, TAB:CARG1->array | ldreq CARG2, TAB:CARG1->asize | bne >9 | | add CARG4, CARG4, CARG3, lsl #3 | cmp CARG3, CARG2 // In array part? | ldrdlo CARG34, [CARG4] | bhs ->vmeta_tgetv | ins_next1 // Overwrites RB! | checktp CARG4, LJ_TNIL | beq >5 |1: | ins_next2 | strd CARG34, [BASE, RA] | ins_next3 | |5: // Check for __index if table value is nil. | ldr TAB:CARG2, TAB:CARG1->metatable | cmp TAB:CARG2, #0 | beq <1 // No metatable: done. | ldrb CARG2, TAB:CARG2->nomm | tst CARG2, #1<vmeta_tgetv | |9: | checktp CARG4, LJ_TSTR // String key? | moveq STR:RC, CARG3 | beq ->BC_TGETS_Z | b ->vmeta_tgetv break; case BC_TGETS: | decode_RB8 RB, INS | and RC, RC, #255 | // RA = dst*8, RB = table*8, RC = str_const (~) | ldrd CARG12, [BASE, RB] | mvn RC, RC | ldr STR:RC, [KBASE, RC, lsl #2] // STALL: early RC. | checktab CARG2, ->vmeta_tgets1 |->BC_TGETS_Z: | // (TAB:RB =) TAB:CARG1 = GCtab *, STR:RC = GCstr *, RA = dst*8 | ldr CARG3, TAB:CARG1->hmask | ldr CARG4, STR:RC->hash | ldr NODE:INS, TAB:CARG1->node | mov TAB:RB, TAB:CARG1 | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask | add CARG3, CARG3, CARG3, lsl #1 | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 |1: | ldrd CARG12, NODE:INS->key // STALL: early NODE:INS. | ldrd CARG34, NODE:INS->val | ldr NODE:INS, NODE:INS->next | checktp CARG2, LJ_TSTR | cmpeq CARG1, STR:RC | bne >4 | checktp CARG4, LJ_TNIL | beq >5 |3: | ins_next1 | ins_next2 | strd CARG34, [BASE, RA] | ins_next3 | |4: // Follow hash chain. | cmp NODE:INS, #0 | bne <1 | // End of hash chain: key not found, nil result. | |5: // Check for __index if table value is nil. | ldr TAB:CARG1, TAB:RB->metatable | mov CARG3, #0 // Optional clear of undef. value (during load stall). | mvn CARG4, #~LJ_TNIL | cmp TAB:CARG1, #0 | beq <3 // No metatable: done. | ldrb CARG2, TAB:CARG1->nomm | tst CARG2, #1<vmeta_tgets break; case BC_TGETB: | decode_RB8 RB, INS | and RC, RC, #255 | // RA = dst*8, RB = table*8, RC = index | ldrd CARG12, [BASE, RB] | checktab CARG2, ->vmeta_tgetb // STALL: load CARG12. | ldr CARG3, TAB:CARG1->asize | ldr CARG4, TAB:CARG1->array | lsl CARG2, RC, #3 | cmp RC, CARG3 | ldrdlo CARG34, [CARG4, CARG2] | bhs ->vmeta_tgetb | ins_next1 // Overwrites RB! | checktp CARG4, LJ_TNIL | beq >5 |1: | ins_next2 | strd CARG34, [BASE, RA] | ins_next3 | |5: // Check for __index if table value is nil. | ldr TAB:CARG2, TAB:CARG1->metatable | cmp TAB:CARG2, #0 | beq <1 // No metatable: done. | ldrb CARG2, TAB:CARG2->nomm | tst CARG2, #1<vmeta_tgetb break; case BC_TSETV: | decode_RB8 RB, INS | decode_RC8 RC, INS | // RA = src*8, RB = table*8, RC = key*8 | ldrd TAB:CARG12, [BASE, RB] | ldrd CARG34, [BASE, RC] | checktab CARG2, ->vmeta_tsetv // STALL: load CARG12. | checktp CARG4, LJ_TISNUM // Integer key? | ldreq CARG2, TAB:CARG1->array | ldreq CARG4, TAB:CARG1->asize | bne >9 | | add CARG2, CARG2, CARG3, lsl #3 | cmp CARG3, CARG4 // In array part? | ldrlo INS, [CARG2, #4] | bhs ->vmeta_tsetv | ins_next1 // Overwrites RB! | checktp INS, LJ_TNIL | ldrb INS, TAB:CARG1->marked | ldrd CARG34, [BASE, RA] | beq >5 |1: | tst INS, #LJ_GC_BLACK // isblack(table) | strd CARG34, [CARG2] | bne >7 |2: | ins_next2 | ins_next3 | |5: // Check for __newindex if previous value is nil. | ldr TAB:RA, TAB:CARG1->metatable | cmp TAB:RA, #0 | beq <1 // No metatable: done. | ldrb RA, TAB:RA->nomm | tst RA, #1<vmeta_tsetv | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:CARG1, INS, CARG3 | b <2 | |9: | checktp CARG4, LJ_TSTR // String key? | moveq STR:RC, CARG3 | beq ->BC_TSETS_Z | b ->vmeta_tsetv break; case BC_TSETS: | decode_RB8 RB, INS | and RC, RC, #255 | // RA = src*8, RB = table*8, RC = str_const (~) | ldrd CARG12, [BASE, RB] | mvn RC, RC | ldr STR:RC, [KBASE, RC, lsl #2] // STALL: early RC. | checktab CARG2, ->vmeta_tsets1 |->BC_TSETS_Z: | // (TAB:RB =) TAB:CARG1 = GCtab *, STR:RC = GCstr *, RA = dst*8 | ldr CARG3, TAB:CARG1->hmask | ldr CARG4, STR:RC->hash | ldr NODE:INS, TAB:CARG1->node | mov TAB:RB, TAB:CARG1 | and CARG3, CARG3, CARG4 // idx = str->hash & tab->hmask | add CARG3, CARG3, CARG3, lsl #1 | mov CARG4, #0 | add NODE:INS, NODE:INS, CARG3, lsl #3 // node = tab->node + idx*3*8 | strb CARG4, TAB:RB->nomm // Clear metamethod cache. |1: | ldrd CARG12, NODE:INS->key | ldr CARG4, NODE:INS->val.it | ldr NODE:CARG3, NODE:INS->next | checktp CARG2, LJ_TSTR | cmpeq CARG1, STR:RC | bne >5 | ldrb CARG2, TAB:RB->marked | checktp CARG4, LJ_TNIL // Key found, but nil value? | ldrd CARG34, [BASE, RA] | beq >4 |2: | tst CARG2, #LJ_GC_BLACK // isblack(table) | strd CARG34, NODE:INS->val | bne >7 |3: | ins_next | |4: // Check for __newindex if previous value is nil. | ldr TAB:CARG1, TAB:RB->metatable | cmp TAB:CARG1, #0 | beq <2 // No metatable: done. | ldrb CARG1, TAB:CARG1->nomm | tst CARG1, #1<vmeta_tsets | |5: // Follow hash chain. | movs NODE:INS, NODE:CARG3 | bne <1 | // End of hash chain: key not found, add a new one. | | // But check for __newindex first. | ldr TAB:CARG1, TAB:RB->metatable | mov CARG3, TMPDp | str PC, SAVE_PC | cmp TAB:CARG1, #0 // No metatable: continue. | str BASE, L->base | ldrbne CARG2, TAB:CARG1->nomm | mov CARG1, L | beq >6 | tst CARG2, #1<vmeta_tsets // 'no __newindex' flag NOT set: check. |6: | mvn CARG4, #~LJ_TSTR | str STR:RC, TMPDlo | mov CARG2, TAB:RB | str CARG4, TMPDhi | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) | // Returns TValue *. | ldr BASE, L->base | ldrd CARG34, [BASE, RA] | strd CARG34, [CRET1] | b <3 // No 2nd write barrier needed. | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, CARG2, CARG3 | b <3 break; case BC_TSETB: | decode_RB8 RB, INS | and RC, RC, #255 | // RA = src*8, RB = table*8, RC = index | ldrd CARG12, [BASE, RB] | checktab CARG2, ->vmeta_tsetb // STALL: load CARG12. | ldr CARG3, TAB:CARG1->asize | ldr RB, TAB:CARG1->array | lsl CARG2, RC, #3 | cmp RC, CARG3 | ldrdlo CARG34, [CARG2, RB]! | bhs ->vmeta_tsetb | ins_next1 // Overwrites RB! | checktp CARG4, LJ_TNIL | ldrb INS, TAB:CARG1->marked | ldrd CARG34, [BASE, RA] | beq >5 |1: | tst INS, #LJ_GC_BLACK // isblack(table) | strd CARG34, [CARG2] | bne >7 |2: | ins_next2 | ins_next3 | |5: // Check for __newindex if previous value is nil. | ldr TAB:RA, TAB:CARG1->metatable | cmp TAB:RA, #0 | beq <1 // No metatable: done. | ldrb RA, TAB:RA->nomm | tst RA, #1<vmeta_tsetb | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:CARG1, INS, CARG3 | b <2 break; case BC_TSETM: | // RA = base*8 (table at base-1), RC = num_const (start index) | add RA, BASE, RA |1: | ldr RB, SAVE_MULTRES | ldr TAB:CARG2, [RA, #-8] // Guaranteed to be a table. | ldr CARG1, [KBASE, RC, lsl #3] // Integer constant is in lo-word. | subs RB, RB, #8 | ldr CARG4, TAB:CARG2->asize | beq >4 // Nothing to copy? | add CARG3, CARG1, RB, lsr #3 | cmp CARG3, CARG4 | ldr CARG4, TAB:CARG2->array | add RB, RA, RB | bhi >5 | add INS, CARG4, CARG1, lsl #3 | ldrb CARG1, TAB:CARG2->marked |3: // Copy result slots to table. | ldrd CARG34, [RA], #8 | strd CARG34, [INS], #8 | cmp RA, RB | blo <3 | tst CARG1, #LJ_GC_BLACK // isblack(table) | bne >7 |4: | ins_next | |5: // Need to resize array part. | str BASE, L->base | mov CARG1, L | str PC, SAVE_PC | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) | // Must not reallocate the stack. | .IOS ldr BASE, L->base | b <1 | |7: // Possible table write barrier for any value. Skip valiswhite check. | barrierback TAB:CARG2, CARG1, CARG3 | b <4 break; /* -- Calls and vararg handling ----------------------------------------- */ case BC_CALLM: | // RA = base*8, (RB = nresults+1,) RC = extra_nargs | ldr CARG1, SAVE_MULTRES | decode_RC8 NARGS8:RC, INS | add NARGS8:RC, NARGS8:RC, CARG1 | b ->BC_CALL_Z break; case BC_CALL: | decode_RC8 NARGS8:RC, INS | // RA = base*8, (RB = nresults+1,) RC = (nargs+1)*8 |->BC_CALL_Z: | mov RB, BASE // Save old BASE for vmeta_call. | ldrd CARG34, [BASE, RA]! | sub NARGS8:RC, NARGS8:RC, #8 | add BASE, BASE, #8 | checkfunc CARG4, ->vmeta_call | ins_call break; case BC_CALLMT: | // RA = base*8, (RB = 0,) RC = extra_nargs | ldr CARG1, SAVE_MULTRES | add NARGS8:RC, CARG1, RC, lsl #3 | b ->BC_CALLT1_Z break; case BC_CALLT: | lsl NARGS8:RC, RC, #3 | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 |->BC_CALLT1_Z: | ldrd LFUNC:CARG34, [RA, BASE]! | sub NARGS8:RC, NARGS8:RC, #8 | add RA, RA, #8 | checkfunc CARG4, ->vmeta_callt | ldr PC, [BASE, FRAME_PC] |->BC_CALLT2_Z: | mov RB, #0 | ldrb CARG4, LFUNC:CARG3->ffid | tst PC, #FRAME_TYPE | bne >7 |1: | str LFUNC:CARG3, [BASE, FRAME_FUNC] // Copy function down, but keep PC. | cmp NARGS8:RC, #0 | beq >3 |2: | ldrd CARG12, [RA, RB] | add INS, RB, #8 | cmp INS, NARGS8:RC | strd CARG12, [BASE, RB] | mov RB, INS | bne <2 |3: | cmp CARG4, #1 // (> FF_C) Calling a fast function? | bhi >5 |4: | ins_callt | |5: // Tailcall to a fast function with a Lua frame below. | ldr INS, [PC, #-4] | decode_RA8 RA, INS | sub CARG1, BASE, RA | ldr LFUNC:CARG1, [CARG1, #-16] | ldr CARG1, LFUNC:CARG1->field_pc | ldr KBASE, [CARG1, #PC2PROTO(k)] | b <4 | |7: // Tailcall from a vararg function. | eor PC, PC, #FRAME_VARG | tst PC, #FRAME_TYPEP // Vararg frame below? | movne CARG4, #0 // Clear ffid if no Lua function below. | bne <1 | sub BASE, BASE, PC | ldr PC, [BASE, FRAME_PC] | tst PC, #FRAME_TYPE | movne CARG4, #0 // Clear ffid if no Lua function below. | b <1 break; case BC_ITERC: | // RA = base*8, (RB = nresults+1, RC = nargs+1 (2+1)) | add RA, BASE, RA | mov RB, BASE // Save old BASE for vmeta_call. | ldrd CARG34, [RA, #-16] | ldrd CARG12, [RA, #-8] | add BASE, RA, #8 | strd CARG34, [RA, #8] // Copy state. | strd CARG12, [RA, #16] // Copy control var. | // STALL: locked CARG34. | ldrd LFUNC:CARG34, [RA, #-24] | mov NARGS8:RC, #16 // Iterators get 2 arguments. | // STALL: load CARG34. | strd LFUNC:CARG34, [RA] // Copy callable. | checkfunc CARG4, ->vmeta_call | ins_call break; case BC_ITERN: | // RA = base*8, (RB = nresults+1, RC = nargs+1 (2+1)) |.if JIT | // NYI: add hotloop, record BC_ITERN. |.endif | add RA, BASE, RA | ldr TAB:RB, [RA, #-16] | ldr CARG1, [RA, #-8] // Get index from control var. | ldr INS, TAB:RB->asize | ldr CARG2, TAB:RB->array | add PC, PC, #4 |1: // Traverse array part. | subs RC, CARG1, INS | add CARG3, CARG2, CARG1, lsl #3 | bhs >5 // Index points after array part? | ldrd CARG34, [CARG3] | checktp CARG4, LJ_TNIL | addeq CARG1, CARG1, #1 // Skip holes in array part. | beq <1 | ldrh RC, [PC, #-2] | mvn CARG2, #~LJ_TISNUM | strd CARG34, [RA, #8] | add RC, PC, RC, lsl #2 | add RB, CARG1, #1 | strd CARG12, [RA] | sub PC, RC, #0x20000 | str RB, [RA, #-8] // Update control var. |3: | ins_next | |5: // Traverse hash part. | ldr CARG4, TAB:RB->hmask | ldr NODE:RB, TAB:RB->node |6: | add CARG1, RC, RC, lsl #1 | cmp RC, CARG4 // End of iteration? Branch to ITERL+1. | add NODE:CARG3, NODE:RB, CARG1, lsl #3 // node = tab->node + idx*3*8 | bhi <3 | ldrd CARG12, NODE:CARG3->val | checktp CARG2, LJ_TNIL | add RC, RC, #1 | beq <6 // Skip holes in hash part. | ldrh RB, [PC, #-2] | add RC, RC, INS | ldrd CARG34, NODE:CARG3->key | str RC, [RA, #-8] // Update control var. | strd CARG12, [RA, #8] | add RC, PC, RB, lsl #2 | sub PC, RC, #0x20000 | strd CARG34, [RA] | b <3 break; case BC_ISNEXT: | // RA = base*8, RC = target (points to ITERN) | add RA, BASE, RA | add RC, PC, RC, lsl #2 | ldrd CFUNC:CARG12, [RA, #-24] | ldr CARG3, [RA, #-12] | ldr CARG4, [RA, #-4] | checktp CARG2, LJ_TFUNC | ldrbeq CARG1, CFUNC:CARG1->ffid | checktpeq CARG3, LJ_TTAB | checktpeq CARG4, LJ_TNIL | cmpeq CARG1, #FF_next_N | subeq PC, RC, #0x20000 | bne >5 | ins_next1 | ins_next2 | mov CARG1, #0 | mvn CARG2, #0x00018000 | strd CARG1, [RA, #-8] // Initialize control var. |1: | ins_next3 |5: // Despecialize bytecode if any of the checks fail. | mov CARG1, #BC_JMP | mov OP, #BC_ITERC | strb CARG1, [PC, #-4] | sub PC, RC, #0x20000 | strb OP, [PC] // Subsumes ins_next1. | ins_next2 | b <1 break; case BC_VARG: | decode_RB8 RB, INS | decode_RC8 RC, INS | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 | ldr CARG1, [BASE, FRAME_PC] | add RC, BASE, RC | add RA, BASE, RA | add RC, RC, #FRAME_VARG | add CARG4, RA, RB | sub CARG3, BASE, #8 // CARG3 = vtop | sub RC, RC, CARG1 // RC = vbase | // Note: RC may now be even _above_ BASE if nargs was < numparams. | cmp RB, #0 | sub CARG1, CARG3, RC | beq >5 // Copy all varargs? | sub CARG4, CARG4, #16 |1: // Copy vararg slots to destination slots. | cmp RC, CARG3 | ldrdlo CARG12, [RC], #8 | mvnhs CARG2, #~LJ_TNIL | cmp RA, CARG4 | strd CARG12, [RA], #8 | blo <1 |2: | ins_next | |5: // Copy all varargs. | ldr CARG4, L->maxstack | cmp CARG1, #0 | movle RB, #8 // MULTRES = (0+1)*8 | addgt RB, CARG1, #8 | add CARG2, RA, CARG1 | str RB, SAVE_MULTRES | ble <2 | cmp CARG2, CARG4 | bhi >7 |6: | ldrd CARG12, [RC], #8 | strd CARG12, [RA], #8 | cmp RC, CARG3 | blo <6 | b <2 | |7: // Grow stack for varargs. | lsr CARG2, CARG1, #3 | str RA, L->top | mov CARG1, L | str BASE, L->base | sub RC, RC, BASE // Need delta, because BASE may change. | str PC, SAVE_PC | sub RA, RA, BASE | bl extern lj_state_growstack // (lua_State *L, int n) | ldr BASE, L->base | add RA, BASE, RA | add RC, BASE, RC | sub CARG3, BASE, #8 | b <6 break; /* -- Returns ----------------------------------------------------------- */ case BC_RETM: | // RA = results*8, RC = extra results | ldr CARG1, SAVE_MULTRES | ldr PC, [BASE, FRAME_PC] | add RA, BASE, RA | add RC, CARG1, RC, lsl #3 | b ->BC_RETM_Z break; case BC_RET: | // RA = results*8, RC = nresults+1 | ldr PC, [BASE, FRAME_PC] | lsl RC, RC, #3 | add RA, BASE, RA |->BC_RETM_Z: | str RC, SAVE_MULTRES |1: | ands CARG1, PC, #FRAME_TYPE | eor CARG2, PC, #FRAME_VARG | bne ->BC_RETV2_Z | |->BC_RET_Z: | // BASE = base, RA = resultptr, RC = (nresults+1)*8, PC = return | ldr INS, [PC, #-4] | subs CARG4, RC, #8 | sub CARG3, BASE, #8 | beq >3 |2: | ldrd CARG12, [RA], #8 | add BASE, BASE, #8 | subs CARG4, CARG4, #8 | strd CARG12, [BASE, #-16] | bne <2 |3: | decode_RA8 RA, INS | sub CARG4, CARG3, RA | decode_RB8 RB, INS | ldr LFUNC:CARG1, [CARG4, FRAME_FUNC] |5: | cmp RB, RC // More results expected? | bhi >6 | mov BASE, CARG4 | ldr CARG2, LFUNC:CARG1->field_pc | ins_next1 | ins_next2 | ldr KBASE, [CARG2, #PC2PROTO(k)] | ins_next3 | |6: // Fill up results with nil. | mvn CARG2, #~LJ_TNIL | add BASE, BASE, #8 | add RC, RC, #8 | str CARG2, [BASE, #-12] | b <5 | |->BC_RETV1_Z: // Non-standard return case. | add RA, BASE, RA |->BC_RETV2_Z: | tst CARG2, #FRAME_TYPEP | bne ->vm_return | // Return from vararg function: relocate BASE down. | sub BASE, BASE, CARG2 | ldr PC, [BASE, FRAME_PC] | b <1 break; case BC_RET0: case BC_RET1: | // RA = results*8, RC = nresults+1 | ldr PC, [BASE, FRAME_PC] | lsl RC, RC, #3 | str RC, SAVE_MULTRES | ands CARG1, PC, #FRAME_TYPE | eor CARG2, PC, #FRAME_VARG | ldreq INS, [PC, #-4] | bne ->BC_RETV1_Z if (op == BC_RET1) { | ldrd CARG12, [BASE, RA] } | sub CARG4, BASE, #8 | decode_RA8 RA, INS if (op == BC_RET1) { | strd CARG12, [CARG4] } | sub BASE, CARG4, RA | decode_RB8 RB, INS | ldr LFUNC:CARG1, [BASE, FRAME_FUNC] |5: | cmp RB, RC | bhi >6 | ldr CARG2, LFUNC:CARG1->field_pc | ins_next1 | ins_next2 | ldr KBASE, [CARG2, #PC2PROTO(k)] | ins_next3 | |6: // Fill up results with nil. | sub CARG2, CARG4, #4 | mvn CARG3, #~LJ_TNIL | str CARG3, [CARG2, RC] | add RC, RC, #8 | b <5 break; /* -- Loops and branches ------------------------------------------------ */ |.define FOR_IDX, [RA]; .define FOR_TIDX, [RA, #4] |.define FOR_STOP, [RA, #8]; .define FOR_TSTOP, [RA, #12] |.define FOR_STEP, [RA, #16]; .define FOR_TSTEP, [RA, #20] |.define FOR_EXT, [RA, #24]; .define FOR_TEXT, [RA, #28] case BC_FORL: |.if JIT | hotloop |.endif | // Fall through. Assumes BC_IFORL follows. break; case BC_JFORI: case BC_JFORL: #if !LJ_HASJIT break; #endif case BC_FORI: case BC_IFORL: | // RA = base*8, RC = target (after end of loop or start of loop) vk = (op == BC_IFORL || op == BC_JFORL); | ldrd CARG12, [RA, BASE]! if (op != BC_JFORL) { | add RC, PC, RC, lsl #2 } if (!vk) { | ldrd CARG34, FOR_STOP | checktp CARG2, LJ_TISNUM | ldr RB, FOR_TSTEP | bne >5 | checktp CARG4, LJ_TISNUM | ldr CARG4, FOR_STEP | checktpeq RB, LJ_TISNUM | bne ->vmeta_for | cmp CARG4, #0 | blt >4 | cmp CARG1, CARG3 } else { | ldrd CARG34, FOR_STEP | checktp CARG2, LJ_TISNUM | bne >5 | adds CARG1, CARG1, CARG3 | ldr CARG4, FOR_STOP if (op == BC_IFORL) { | addvs RC, PC, #0x20000 // Overflow: prevent branch. } else { | bvs >2 // Overflow: do not enter mcode. } | cmp CARG3, #0 | blt >4 | cmp CARG1, CARG4 } |1: if (op == BC_FORI) { | subgt PC, RC, #0x20000 } else if (op == BC_JFORI) { | sub PC, RC, #0x20000 | ldrhle RC, [PC, #-2] } else if (op == BC_IFORL) { | suble PC, RC, #0x20000 } if (vk) { | strd CARG12, FOR_IDX } |2: | ins_next1 | ins_next2 | strd CARG12, FOR_EXT if (op == BC_JFORI || op == BC_JFORL) { | ble =>BC_JLOOP } |3: | ins_next3 | |4: // Invert check for negative step. if (!vk) { | cmp CARG3, CARG1 } else { | cmp CARG4, CARG1 } | b <1 | |5: // FP loop. if (!vk) { | cmnlo CARG4, #-LJ_TISNUM | cmnlo RB, #-LJ_TISNUM | bhs ->vmeta_for |.if FPU | vldr d0, FOR_IDX | vldr d1, FOR_STOP | cmp RB, #0 | vstr d0, FOR_EXT |.else | cmp RB, #0 | strd CARG12, FOR_EXT | blt >8 |.endif } else { |.if FPU | vldr d0, FOR_IDX | vldr d2, FOR_STEP | vldr d1, FOR_STOP | cmp CARG4, #0 | vadd.f64 d0, d0, d2 |.else | cmp CARG4, #0 | blt >8 | bl extern __aeabi_dadd | strd CARG12, FOR_IDX | ldrd CARG34, FOR_STOP | strd CARG12, FOR_EXT |.endif } |6: |.if FPU | vcmpge.f64 d0, d1 | vcmplt.f64 d1, d0 | vmrs |.else | bl extern __aeabi_cdcmple |.endif if (vk) { |.if FPU | vstr d0, FOR_IDX | vstr d0, FOR_EXT |.endif } if (op == BC_FORI) { | subhi PC, RC, #0x20000 } else if (op == BC_JFORI) { | sub PC, RC, #0x20000 | ldrhls RC, [PC, #-2] | bls =>BC_JLOOP } else if (op == BC_IFORL) { | subls PC, RC, #0x20000 } else { | bls =>BC_JLOOP } | ins_next1 | ins_next2 | b <3 | |.if not FPU |8: // Invert check for negative step. if (vk) { | bl extern __aeabi_dadd | strd CARG12, FOR_IDX | strd CARG12, FOR_EXT } | mov CARG3, CARG1 | mov CARG4, CARG2 | ldrd CARG12, FOR_STOP | b <6 |.endif break; case BC_ITERL: |.if JIT | hotloop |.endif | // Fall through. Assumes BC_IITERL follows. break; case BC_JITERL: #if !LJ_HASJIT break; #endif case BC_IITERL: | // RA = base*8, RC = target | ldrd CARG12, [RA, BASE]! if (op == BC_JITERL) { | cmn CARG2, #-LJ_TNIL // Stop if iterator returned nil. | strdne CARG12, [RA, #-8] | bne =>BC_JLOOP } else { | add RC, PC, RC, lsl #2 | // STALL: load CARG12. | cmn CARG2, #-LJ_TNIL // Stop if iterator returned nil. | subne PC, RC, #0x20000 // Otherwise save control var + branch. | strdne CARG12, [RA, #-8] } | ins_next break; case BC_LOOP: | // RA = base*8, RC = target (loop extent) | // Note: RA/RC is only used by trace recorder to determine scope/extent | // This opcode does NOT jump, it's only purpose is to detect a hot loop. |.if JIT | hotloop |.endif | // Fall through. Assumes BC_ILOOP follows. break; case BC_ILOOP: | // RA = base*8, RC = target (loop extent) | ins_next break; case BC_JLOOP: |.if JIT | // RA = base (ignored), RC = traceno | ldr CARG1, [DISPATCH, #DISPATCH_J(trace)] | mov CARG2, #0 // Traces on ARM don't store the trace number, so use 0. | ldr TRACE:RC, [CARG1, RC, lsl #2] | st_vmstate CARG2 | ldr RA, TRACE:RC->mcode | str BASE, [DISPATCH, #DISPATCH_GL(jit_base)] | str L, [DISPATCH, #DISPATCH_GL(jit_L)] | bx RA |.endif break; case BC_JMP: | // RA = base*8 (only used by trace recorder), RC = target | add RC, PC, RC, lsl #2 | sub PC, RC, #0x20000 | ins_next break; /* -- Function headers -------------------------------------------------- */ case BC_FUNCF: |.if JIT | hotcall |.endif case BC_FUNCV: /* NYI: compiled vararg functions. */ | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. break; case BC_JFUNCF: #if !LJ_HASJIT break; #endif case BC_IFUNCF: | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8 | ldr CARG1, L->maxstack | ldrb CARG2, [PC, #-4+PC2PROTO(numparams)] | ldr KBASE, [PC, #-4+PC2PROTO(k)] | cmp RA, CARG1 | bhi ->vm_growstack_l if (op != BC_JFUNCF) { | ins_next1 | ins_next2 } |2: | cmp NARGS8:RC, CARG2, lsl #3 // Check for missing parameters. | mvn CARG4, #~LJ_TNIL | blo >3 if (op == BC_JFUNCF) { | decode_RD RC, INS | b =>BC_JLOOP } else { | ins_next3 } | |3: // Clear missing parameters. | strd CARG34, [BASE, NARGS8:RC] | add NARGS8:RC, NARGS8:RC, #8 | b <2 break; case BC_JFUNCV: #if !LJ_HASJIT break; #endif | NYI // NYI: compiled vararg functions break; /* NYI: compiled vararg functions. */ case BC_IFUNCV: | // BASE = new base, RA = BASE+framesize*8, CARG3 = LFUNC, RC = nargs*8 | ldr CARG1, L->maxstack | add CARG4, BASE, RC | add RA, RA, RC | str LFUNC:CARG3, [CARG4] // Store copy of LFUNC. | add CARG2, RC, #8+FRAME_VARG | ldr KBASE, [PC, #-4+PC2PROTO(k)] | cmp RA, CARG1 | str CARG2, [CARG4, #4] // Store delta + FRAME_VARG. | bhs ->vm_growstack_l | ldrb RB, [PC, #-4+PC2PROTO(numparams)] | mov RA, BASE | mov RC, CARG4 | cmp RB, #0 | add BASE, CARG4, #8 | beq >3 | mvn CARG3, #~LJ_TNIL |1: | cmp RA, RC // Less args than parameters? | ldrdlo CARG12, [RA], #8 | movhs CARG2, CARG3 | strlo CARG3, [RA, #-4] // Clear old fixarg slot (help the GC). |2: | subs RB, RB, #1 | strd CARG12, [CARG4, #8]! | bne <1 |3: | ins_next break; case BC_FUNCC: case BC_FUNCCW: | // BASE = new base, RA = BASE+framesize*8, CARG3 = CFUNC, RC = nargs*8 if (op == BC_FUNCC) { | ldr CARG4, CFUNC:CARG3->f } else { | ldr CARG4, [DISPATCH, #DISPATCH_GL(wrapf)] } | add CARG2, RA, NARGS8:RC | ldr CARG1, L->maxstack | add RC, BASE, NARGS8:RC | str BASE, L->base | cmp CARG2, CARG1 | str RC, L->top if (op == BC_FUNCCW) { | ldr CARG2, CFUNC:CARG3->f } | mv_vmstate CARG3, C | mov CARG1, L | bhi ->vm_growstack_c // Need to grow stack. | st_vmstate CARG3 | blx CARG4 // (lua_State *L [, lua_CFunction f]) | // Returns nresults. | ldr BASE, L->base | mv_vmstate CARG3, INTERP | ldr CRET2, L->top | lsl RC, CRET1, #3 | st_vmstate CARG3 | ldr PC, [BASE, FRAME_PC] | sub RA, CRET2, RC // RA = L->top - nresults*8 | b ->vm_returnc break; /* ---------------------------------------------------------------------- */ default: fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); exit(2); break; } } static int build_backend(BuildCtx *ctx) { int op; dasm_growpc(Dst, BC__MAX); build_subroutines(ctx); |.code_op for (op = 0; op < BC__MAX; op++) build_ins(ctx, (BCOp)op, op); return BC__MAX; } /* Emit pseudo frame-info for all assembler functions. */ static void emit_asm_debug(BuildCtx *ctx) { int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); int i; switch (ctx->mode) { case BUILD_elfasm: fprintf(ctx->fp, "\t.section .debug_frame,\"\",%%progbits\n"); fprintf(ctx->fp, ".Lframe0:\n" "\t.long .LECIE0-.LSCIE0\n" ".LSCIE0:\n" "\t.long 0xffffffff\n" "\t.byte 0x1\n" "\t.string \"\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 0xe\n" /* Return address is in lr. */ "\t.byte 0xc\n\t.uleb128 0xd\n\t.uleb128 0\n" /* def_cfa sp */ "\t.align 2\n" ".LECIE0:\n\n"); fprintf(ctx->fp, ".LSFDE0:\n" "\t.long .LEFDE0-.LASFDE0\n" ".LASFDE0:\n" "\t.long .Lframe0\n" "\t.long .Lbegin\n" "\t.long %d\n" "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ "\t.byte 0x8e\n\t.uleb128 1\n", /* offset lr */ fcofs, CFRAME_SIZE); for (i = 11; i >= (LJ_ARCH_HASFPU ? 5 : 4); i--) /* offset r4-r11 */ fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 2+(11-i)); #if LJ_ARCH_HASFPU for (i = 15; i >= 8; i--) /* offset d8-d15 */ fprintf(ctx->fp, "\t.byte 5\n\t.uleb128 %d, %d\n", 64+2*i, 10+2*(15-i)); fprintf(ctx->fp, "\t.byte 0x84\n\t.uleb128 %d\n", 25); /* offset r4 */ #endif fprintf(ctx->fp, "\t.align 2\n" ".LEFDE0:\n\n"); #if LJ_HASFFI fprintf(ctx->fp, ".LSFDE1:\n" "\t.long .LEFDE1-.LASFDE1\n" ".LASFDE1:\n" "\t.long .Lframe0\n" "\t.long lj_vm_ffi_call\n" "\t.long %d\n" "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ "\t.byte 0x8e\n\t.uleb128 1\n" /* offset lr */ "\t.byte 0x8b\n\t.uleb128 2\n" /* offset r11 */ "\t.byte 0x85\n\t.uleb128 3\n" /* offset r5 */ "\t.byte 0x84\n\t.uleb128 4\n" /* offset r4 */ "\t.byte 0xd\n\t.uleb128 0xb\n" /* def_cfa_register r11 */ "\t.align 2\n" ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); #endif break; default: break; } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/vm_mips.dasc ================================================ |// Low-level VM code for MIPS CPUs. |// Bytecode interpreter, fast functions and helper functions. |// Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h | |.arch mips |.section code_op, code_sub | |.actionlist build_actionlist |.globals GLOB_ |.globalnames globnames |.externnames extnames | |// Note: The ragged indentation of the instructions is intentional. |// The starting columns indicate data dependencies. | |//----------------------------------------------------------------------- | |// Fixed register assignments for the interpreter. |// Don't use: r0 = 0, r26/r27 = reserved, r28 = gp, r29 = sp, r31 = ra | |// The following must be C callee-save (but BASE is often refetched). |.define BASE, r16 // Base of current Lua stack frame. |.define KBASE, r17 // Constants of current Lua function. |.define PC, r18 // Next PC. |.define DISPATCH, r19 // Opcode dispatch table. |.define LREG, r20 // Register holding lua_State (also in SAVE_L). |.define MULTRES, r21 // Size of multi-result: (nresults+1)*8. |// NYI: r22 currently unused. | |.define JGL, r30 // On-trace: global_State + 32768. | |// Constants for type-comparisons, stores and conversions. C callee-save. |.define TISNIL, r30 |.define TOBIT, f30 // 2^52 + 2^51. | |// The following temporaries are not saved across C calls, except for RA. |.define RA, r23 // Callee-save. |.define RB, r8 |.define RC, r9 |.define RD, r10 |.define INS, r11 | |.define AT, r1 // Assembler temporary. |.define TMP0, r12 |.define TMP1, r13 |.define TMP2, r14 |.define TMP3, r15 | |// Calling conventions. |.define CFUNCADDR, r25 |.define CARG1, r4 |.define CARG2, r5 |.define CARG3, r6 |.define CARG4, r7 | |.define CRET1, r2 |.define CRET2, r3 | |.define FARG1, f12 |.define FARG2, f14 | |.define FRET1, f0 |.define FRET2, f2 | |// Stack layout while in interpreter. Must match with lj_frame.h. |.define CFRAME_SPACE, 112 // Delta for sp. | |.define SAVE_ERRF, 124(sp) // 32 bit C frame info. |.define SAVE_NRES, 120(sp) |.define SAVE_CFRAME, 116(sp) |.define SAVE_L, 112(sp) |//----- 8 byte aligned, ^^^^ 16 byte register save area, owned by interpreter. |.define SAVE_GPR_, 72 // .. 72+10*4: 32 bit GPR saves. |.define SAVE_FPR_, 24 // .. 24+6*8: 64 bit FPR saves. |.define SAVE_PC, 20(sp) |.define ARG5, 16(sp) |.define CSAVE_4, 12(sp) |.define CSAVE_3, 8(sp) |.define CSAVE_2, 4(sp) |.define CSAVE_1, 0(sp) |//----- 8 byte aligned, ^^^^ 16 byte register save area, owned by callee. | |.define ARG5_OFS, 16 |.define SAVE_MULTRES, ARG5 | |.macro saveregs | addiu sp, sp, -CFRAME_SPACE | sw ra, SAVE_GPR_+9*4(sp) | sw r30, SAVE_GPR_+8*4(sp) | sdc1 f30, SAVE_FPR_+5*8(sp) | sw r23, SAVE_GPR_+7*4(sp) | sw r22, SAVE_GPR_+6*4(sp) | sdc1 f28, SAVE_FPR_+4*8(sp) | sw r21, SAVE_GPR_+5*4(sp) | sw r20, SAVE_GPR_+4*4(sp) | sdc1 f26, SAVE_FPR_+3*8(sp) | sw r19, SAVE_GPR_+3*4(sp) | sw r18, SAVE_GPR_+2*4(sp) | sdc1 f24, SAVE_FPR_+2*8(sp) | sw r17, SAVE_GPR_+1*4(sp) | sw r16, SAVE_GPR_+0*4(sp) | sdc1 f22, SAVE_FPR_+1*8(sp) | sdc1 f20, SAVE_FPR_+0*8(sp) |.endmacro | |.macro restoreregs_ret | lw ra, SAVE_GPR_+9*4(sp) | lw r30, SAVE_GPR_+8*4(sp) | ldc1 f30, SAVE_FPR_+5*8(sp) | lw r23, SAVE_GPR_+7*4(sp) | lw r22, SAVE_GPR_+6*4(sp) | ldc1 f28, SAVE_FPR_+4*8(sp) | lw r21, SAVE_GPR_+5*4(sp) | lw r20, SAVE_GPR_+4*4(sp) | ldc1 f26, SAVE_FPR_+3*8(sp) | lw r19, SAVE_GPR_+3*4(sp) | lw r18, SAVE_GPR_+2*4(sp) | ldc1 f24, SAVE_FPR_+2*8(sp) | lw r17, SAVE_GPR_+1*4(sp) | lw r16, SAVE_GPR_+0*4(sp) | ldc1 f22, SAVE_FPR_+1*8(sp) | ldc1 f20, SAVE_FPR_+0*8(sp) | jr ra | addiu sp, sp, CFRAME_SPACE |.endmacro | |// Type definitions. Some of these are only used for documentation. |.type L, lua_State, LREG |.type GL, global_State |.type TVALUE, TValue |.type GCOBJ, GCobj |.type STR, GCstr |.type TAB, GCtab |.type LFUNC, GCfuncL |.type CFUNC, GCfuncC |.type PROTO, GCproto |.type UPVAL, GCupval |.type NODE, Node |.type NARGS8, int |.type TRACE, GCtrace | |//----------------------------------------------------------------------- | |// Trap for not-yet-implemented parts. |.macro NYI; .long 0xf0f0f0f0; .endmacro | |// Macros to mark delay slots. |.macro ., a; a; .endmacro |.macro ., a,b; a,b; .endmacro |.macro ., a,b,c; a,b,c; .endmacro | |//----------------------------------------------------------------------- | |// Endian-specific defines. |.define FRAME_PC, LJ_ENDIAN_SELECT(-4,-8) |.define FRAME_FUNC, LJ_ENDIAN_SELECT(-8,-4) |.define HI, LJ_ENDIAN_SELECT(4,0) |.define LO, LJ_ENDIAN_SELECT(0,4) |.define OFS_RD, LJ_ENDIAN_SELECT(2,0) |.define OFS_RA, LJ_ENDIAN_SELECT(1,2) |.define OFS_OP, LJ_ENDIAN_SELECT(0,3) | |// Instruction decode. |.macro decode_OP1, dst, ins; andi dst, ins, 0xff; .endmacro |.macro decode_OP4a, dst, ins; andi dst, ins, 0xff; .endmacro |.macro decode_OP4b, dst; sll dst, dst, 2; .endmacro |.macro decode_RC4a, dst, ins; srl dst, ins, 14; .endmacro |.macro decode_RC4b, dst; andi dst, dst, 0x3fc; .endmacro |.macro decode_RD4b, dst; sll dst, dst, 2; .endmacro |.macro decode_RA8a, dst, ins; srl dst, ins, 5; .endmacro |.macro decode_RA8b, dst; andi dst, dst, 0x7f8; .endmacro |.macro decode_RB8a, dst, ins; srl dst, ins, 21; .endmacro |.macro decode_RB8b, dst; andi dst, dst, 0x7f8; .endmacro |.macro decode_RD8a, dst, ins; srl dst, ins, 16; .endmacro |.macro decode_RD8b, dst; sll dst, dst, 3; .endmacro |.macro decode_RDtoRC8, dst, src; andi dst, src, 0x7f8; .endmacro | |// Instruction fetch. |.macro ins_NEXT1 | lw INS, 0(PC) | addiu PC, PC, 4 |.endmacro |// Instruction decode+dispatch. |.macro ins_NEXT2 | decode_OP4a TMP1, INS | decode_OP4b TMP1 | addu TMP0, DISPATCH, TMP1 | decode_RD8a RD, INS | lw AT, 0(TMP0) | decode_RA8a RA, INS | decode_RD8b RD | jr AT | decode_RA8b RA |.endmacro |.macro ins_NEXT | ins_NEXT1 | ins_NEXT2 |.endmacro | |// Instruction footer. |.if 1 | // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. | .define ins_next, ins_NEXT | .define ins_next_, ins_NEXT | .define ins_next1, ins_NEXT1 | .define ins_next2, ins_NEXT2 |.else | // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. | // Affects only certain kinds of benchmarks (and only with -j off). | .macro ins_next | b ->ins_next | .endmacro | .macro ins_next1 | .endmacro | .macro ins_next2 | b ->ins_next | .endmacro | .macro ins_next_ | ->ins_next: | ins_NEXT | .endmacro |.endif | |// Call decode and dispatch. |.macro ins_callt | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC | lw PC, LFUNC:RB->pc | lw INS, 0(PC) | addiu PC, PC, 4 | decode_OP4a TMP1, INS | decode_RA8a RA, INS | decode_OP4b TMP1 | decode_RA8b RA | addu TMP0, DISPATCH, TMP1 | lw TMP0, 0(TMP0) | jr TMP0 | addu RA, RA, BASE |.endmacro | |.macro ins_call | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC | sw PC, FRAME_PC(BASE) | ins_callt |.endmacro | |//----------------------------------------------------------------------- | |.macro branch_RD | srl TMP0, RD, 1 | lui AT, (-(BCBIAS_J*4 >> 16) & 65535) | addu TMP0, TMP0, AT | addu PC, PC, TMP0 |.endmacro | |// Assumes DISPATCH is relative to GL. #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) #define GG_DISP2GOT (GG_OFS(got) - GG_OFS(dispatch)) #define DISPATCH_GOT(name) (GG_DISP2GOT + 4*LJ_GOT_##name) | #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) | |.macro load_got, func | lw CFUNCADDR, DISPATCH_GOT(func)(DISPATCH) |.endmacro |// Much faster. Sadly, there's no easy way to force the required code layout. |// .macro call_intern, func; bal extern func; .endmacro |.macro call_intern, func; jalr CFUNCADDR; .endmacro |.macro call_extern; jalr CFUNCADDR; .endmacro |.macro jmp_extern; jr CFUNCADDR; .endmacro | |.macro hotcheck, delta, target | srl TMP1, PC, 1 | andi TMP1, TMP1, 126 | addu TMP1, TMP1, DISPATCH | lhu TMP2, GG_DISP2HOT(TMP1) | addiu TMP2, TMP2, -delta | bltz TMP2, target |. sh TMP2, GG_DISP2HOT(TMP1) |.endmacro | |.macro hotloop | hotcheck HOTCOUNT_LOOP, ->vm_hotloop |.endmacro | |.macro hotcall | hotcheck HOTCOUNT_CALL, ->vm_hotcall |.endmacro | |// Set current VM state. Uses TMP0. |.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro |.macro st_vmstate; sw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro | |// Move table write barrier back. Overwrites mark and tmp. |.macro barrierback, tab, mark, tmp, target | lw tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) | andi mark, mark, ~LJ_GC_BLACK & 255 // black2gray(tab) | sw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) | sb mark, tab->marked | b target |. sw tmp, tab->gclist |.endmacro | |//----------------------------------------------------------------------- /* Generate subroutines used by opcodes and other parts of the VM. */ /* The .code_sub section should be last to help static branch prediction. */ static void build_subroutines(BuildCtx *ctx) { |.code_sub | |//----------------------------------------------------------------------- |//-- Return handling ---------------------------------------------------- |//----------------------------------------------------------------------- | |->vm_returnp: | // See vm_return. Also: TMP2 = previous base. | andi AT, PC, FRAME_P | beqz AT, ->cont_dispatch |. li TMP1, LJ_TTRUE | | // Return from pcall or xpcall fast func. | lw PC, FRAME_PC(TMP2) // Fetch PC of previous frame. | move BASE, TMP2 // Restore caller base. | // Prepending may overwrite the pcall frame, so do it at the end. | sw TMP1, FRAME_PC(RA) // Prepend true to results. | addiu RA, RA, -8 | |->vm_returnc: | addiu RD, RD, 8 // RD = (nresults+1)*8. | andi TMP0, PC, FRAME_TYPE | beqz RD, ->vm_unwind_c_eh |. li CRET1, LUA_YIELD | beqz TMP0, ->BC_RET_Z // Handle regular return to Lua. |. move MULTRES, RD | |->vm_return: | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return | // TMP0 = PC & FRAME_TYPE | li TMP2, -8 | xori AT, TMP0, FRAME_C | and TMP2, PC, TMP2 | bnez AT, ->vm_returnp | subu TMP2, BASE, TMP2 // TMP2 = previous base. | | addiu TMP1, RD, -8 | sw TMP2, L->base | li_vmstate C | lw TMP2, SAVE_NRES | addiu BASE, BASE, -8 | st_vmstate | beqz TMP1, >2 |. sll TMP2, TMP2, 3 |1: | addiu TMP1, TMP1, -8 | ldc1 f0, 0(RA) | addiu RA, RA, 8 | sdc1 f0, 0(BASE) | bnez TMP1, <1 |. addiu BASE, BASE, 8 | |2: | bne TMP2, RD, >6 |3: |. sw BASE, L->top // Store new top. | |->vm_leave_cp: | lw TMP0, SAVE_CFRAME // Restore previous C frame. | move CRET1, r0 // Ok return status for vm_pcall. | sw TMP0, L->cframe | |->vm_leave_unw: | restoreregs_ret | |6: | lw TMP1, L->maxstack | slt AT, TMP2, RD | bnez AT, >7 // Less results wanted? | // More results wanted. Check stack size and fill up results with nil. |. slt AT, BASE, TMP1 | beqz AT, >8 |. nop | sw TISNIL, HI(BASE) | addiu RD, RD, 8 | b <2 |. addiu BASE, BASE, 8 | |7: // Less results wanted. | subu TMP0, RD, TMP2 | subu TMP0, BASE, TMP0 // Either keep top or shrink it. | b <3 |. movn BASE, TMP0, TMP2 // LUA_MULTRET+1 case? | |8: // Corner case: need to grow stack for filling up results. | // This can happen if: | // - A C function grows the stack (a lot). | // - The GC shrinks the stack in between. | // - A return back from a lua_call() with (high) nresults adjustment. | load_got lj_state_growstack | move MULTRES, RD | move CARG2, TMP2 | call_intern lj_state_growstack // (lua_State *L, int n) |. move CARG1, L | lw TMP2, SAVE_NRES | lw BASE, L->top // Need the (realloced) L->top in BASE. | move RD, MULTRES | b <2 |. sll TMP2, TMP2, 3 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. | // (void *cframe, int errcode) | move sp, CARG1 | move CRET1, CARG2 |->vm_unwind_c_eh: // Landing pad for external unwinder. | lw L, SAVE_L | li TMP0, ~LJ_VMST_C | lw GL:TMP1, L->glref | b ->vm_leave_unw |. sw TMP0, GL:TMP1->vmstate | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. | // (void *cframe) | li AT, -4 | and sp, CARG1, AT |->vm_unwind_ff_eh: // Landing pad for external unwinder. | lw L, SAVE_L | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | li TISNIL, LJ_TNIL | lw BASE, L->base | lw DISPATCH, L->glref // Setup pointer to dispatch table. | mtc1 TMP3, TOBIT | li TMP1, LJ_TFALSE | li_vmstate INTERP | lw PC, FRAME_PC(BASE) // Fetch PC of previous frame. | cvt.d.s TOBIT, TOBIT | addiu RA, BASE, -8 // Results start at BASE-8. | addiu DISPATCH, DISPATCH, GG_G2DISP | sw TMP1, HI(RA) // Prepend false to error message. | st_vmstate | b ->vm_returnc |. li RD, 16 // 2 results: false + error message. | |//----------------------------------------------------------------------- |//-- Grow stack for calls ----------------------------------------------- |//----------------------------------------------------------------------- | |->vm_growstack_c: // Grow stack for C function. | b >2 |. li CARG2, LUA_MINSTACK | |->vm_growstack_l: // Grow stack for Lua function. | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC | addu RC, BASE, RC | subu RA, RA, BASE | sw BASE, L->base | addiu PC, PC, 4 // Must point after first instruction. | sw RC, L->top | srl CARG2, RA, 3 |2: | // L->base = new base, L->top = top | load_got lj_state_growstack | sw PC, SAVE_PC | call_intern lj_state_growstack // (lua_State *L, int n) |. move CARG1, L | lw BASE, L->base | lw RC, L->top | lw LFUNC:RB, FRAME_FUNC(BASE) | subu RC, RC, BASE | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC | ins_callt // Just retry the call. | |//----------------------------------------------------------------------- |//-- Entry points into the assembler VM --------------------------------- |//----------------------------------------------------------------------- | |->vm_resume: // Setup C frame and resume thread. | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) | saveregs | move L, CARG1 | lw DISPATCH, L->glref // Setup pointer to dispatch table. | move BASE, CARG2 | lbu TMP1, L->status | sw L, SAVE_L | li PC, FRAME_CP | addiu TMP0, sp, CFRAME_RESUME | addiu DISPATCH, DISPATCH, GG_G2DISP | sw r0, SAVE_NRES | sw r0, SAVE_ERRF | sw TMP0, L->cframe | sw r0, SAVE_CFRAME | beqz TMP1, >3 |. sw CARG1, SAVE_PC // Any value outside of bytecode is ok. | | // Resume after yield (like a return). | move RA, BASE | lw BASE, L->base | lw TMP1, L->top | lw PC, FRAME_PC(BASE) | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | subu RD, TMP1, BASE | mtc1 TMP3, TOBIT | sb r0, L->status | cvt.d.s TOBIT, TOBIT | li_vmstate INTERP | addiu RD, RD, 8 | st_vmstate | move MULTRES, RD | andi TMP0, PC, FRAME_TYPE | beqz TMP0, ->BC_RET_Z |. li TISNIL, LJ_TNIL | b ->vm_return |. nop | |->vm_pcall: // Setup protected C frame and enter VM. | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) | saveregs | sw CARG4, SAVE_ERRF | b >1 |. li PC, FRAME_CP | |->vm_call: // Setup C frame and enter VM. | // (lua_State *L, TValue *base, int nres1) | saveregs | li PC, FRAME_C | |1: // Entry point for vm_pcall above (PC = ftype). | lw TMP1, L:CARG1->cframe | sw CARG3, SAVE_NRES | move L, CARG1 | sw CARG1, SAVE_L | move BASE, CARG2 | sw sp, L->cframe // Add our C frame to cframe chain. | lw DISPATCH, L->glref // Setup pointer to dispatch table. | sw CARG1, SAVE_PC // Any value outside of bytecode is ok. | sw TMP1, SAVE_CFRAME | addiu DISPATCH, DISPATCH, GG_G2DISP | |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). | lw TMP2, L->base // TMP2 = old base (used in vmeta_call). | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | lw TMP1, L->top | mtc1 TMP3, TOBIT | addu PC, PC, BASE | subu NARGS8:RC, TMP1, BASE | subu PC, PC, TMP2 // PC = frame delta + frame type | cvt.d.s TOBIT, TOBIT | li_vmstate INTERP | li TISNIL, LJ_TNIL | st_vmstate | |->vm_call_dispatch: | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC | lw TMP0, FRAME_PC(BASE) | li AT, LJ_TFUNC | bne TMP0, AT, ->vmeta_call |. lw LFUNC:RB, FRAME_FUNC(BASE) | |->vm_call_dispatch_f: | ins_call | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC | |->vm_cpcall: // Setup protected C frame, call C. | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) | saveregs | move L, CARG1 | lw TMP0, L:CARG1->stack | sw CARG1, SAVE_L | lw TMP1, L->top | sw CARG1, SAVE_PC // Any value outside of bytecode is ok. | subu TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). | lw TMP1, L->cframe | sw sp, L->cframe // Add our C frame to cframe chain. | sw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. | sw r0, SAVE_ERRF // No error function. | move CFUNCADDR, CARG4 | jalr CARG4 // (lua_State *L, lua_CFunction func, void *ud) |. sw TMP1, SAVE_CFRAME | move BASE, CRET1 | lw DISPATCH, L->glref // Setup pointer to dispatch table. | li PC, FRAME_CP | bnez CRET1, <3 // Else continue with the call. |. addiu DISPATCH, DISPATCH, GG_G2DISP | b ->vm_leave_cp // No base? Just remove C frame. |. nop | |//----------------------------------------------------------------------- |//-- Metamethod handling ------------------------------------------------ |//----------------------------------------------------------------------- | |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the |// stack, so BASE doesn't need to be reloaded across these calls. | |//-- Continuation dispatch ---------------------------------------------- | |->cont_dispatch: | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 | lw TMP0, -16+LO(BASE) // Continuation. | move RB, BASE | move BASE, TMP2 // Restore caller BASE. | lw LFUNC:TMP1, FRAME_FUNC(TMP2) |.if FFI | sltiu AT, TMP0, 2 |.endif | lw PC, -16+HI(RB) // Restore PC from [cont|PC]. | addu TMP2, RA, RD | lw TMP1, LFUNC:TMP1->pc |.if FFI | bnez AT, >1 |.endif |. sw TISNIL, -8+HI(TMP2) // Ensure one valid arg. | // BASE = base, RA = resultptr, RB = meta base | jr TMP0 // Jump to continuation. |. lw KBASE, PC2PROTO(k)(TMP1) | |.if FFI |1: | bnez TMP0, ->cont_ffi_callback // cont = 1: return from FFI callback. | // cont = 0: tailcall from C function. |. addiu TMP1, RB, -16 | b ->vm_call_tail |. subu RC, TMP1, BASE |.endif | |->cont_cat: // RA = resultptr, RB = meta base | lw INS, -4(PC) | addiu CARG2, RB, -16 | ldc1 f0, 0(RA) | decode_RB8a MULTRES, INS | decode_RA8a RA, INS | decode_RB8b MULTRES | decode_RA8b RA | addu TMP1, BASE, MULTRES | sw BASE, L->base | subu CARG3, CARG2, TMP1 | bne TMP1, CARG2, ->BC_CAT_Z |. sdc1 f0, 0(CARG2) | addu RA, BASE, RA | b ->cont_nop |. sdc1 f0, 0(RA) | |//-- Table indexing metamethods ----------------------------------------- | |->vmeta_tgets1: | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) | li TMP0, LJ_TSTR | sw STR:RC, LO(CARG3) | b >1 |. sw TMP0, HI(CARG3) | |->vmeta_tgets: | addiu CARG2, DISPATCH, DISPATCH_GL(tmptv) | li TMP0, LJ_TTAB | sw TAB:RB, LO(CARG2) | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv2) | sw TMP0, HI(CARG2) | li TMP1, LJ_TSTR | sw STR:RC, LO(CARG3) | b >1 |. sw TMP1, HI(CARG3) | |->vmeta_tgetb: // TMP0 = index | mtc1 TMP0, f0 | cvt.d.w f0, f0 | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) | sdc1 f0, 0(CARG3) | |->vmeta_tgetv: |1: | load_got lj_meta_tget | sw BASE, L->base | sw PC, SAVE_PC | call_intern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) |. move CARG1, L | // Returns TValue * (finished) or NULL (metamethod). | beqz CRET1, >3 |. addiu TMP1, BASE, -FRAME_CONT | ldc1 f0, 0(CRET1) | ins_next1 | sdc1 f0, 0(RA) | ins_next2 | |3: // Call __index metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k | lw BASE, L->top | sw PC, -16+HI(BASE) // [cont|PC] | subu PC, BASE, TMP1 | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | b ->vm_call_dispatch_f |. li NARGS8:RC, 16 // 2 args for func(t, k). | |//----------------------------------------------------------------------- | |->vmeta_tsets1: | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) | li TMP0, LJ_TSTR | sw STR:RC, LO(CARG3) | b >1 |. sw TMP0, HI(CARG3) | |->vmeta_tsets: | addiu CARG2, DISPATCH, DISPATCH_GL(tmptv) | li TMP0, LJ_TTAB | sw TAB:RB, LO(CARG2) | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv2) | sw TMP0, HI(CARG2) | li TMP1, LJ_TSTR | sw STR:RC, LO(CARG3) | b >1 |. sw TMP1, HI(CARG3) | |->vmeta_tsetb: // TMP0 = index | mtc1 TMP0, f0 | cvt.d.w f0, f0 | addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) | sdc1 f0, 0(CARG3) | |->vmeta_tsetv: |1: | load_got lj_meta_tset | sw BASE, L->base | sw PC, SAVE_PC | call_intern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) |. move CARG1, L | // Returns TValue * (finished) or NULL (metamethod). | beqz CRET1, >3 |. ldc1 f0, 0(RA) | // NOBARRIER: lj_meta_tset ensures the table is not black. | ins_next1 | sdc1 f0, 0(CRET1) | ins_next2 | |3: // Call __newindex metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) | addiu TMP1, BASE, -FRAME_CONT | lw BASE, L->top | sw PC, -16+HI(BASE) // [cont|PC] | subu PC, BASE, TMP1 | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | sdc1 f0, 16(BASE) // Copy value to third argument. | b ->vm_call_dispatch_f |. li NARGS8:RC, 24 // 3 args for func(t, k, v) | |//-- Comparison metamethods --------------------------------------------- | |->vmeta_comp: | // CARG2, CARG3 are already set by BC_ISLT/BC_ISGE/BC_ISLE/BC_ISGT. | load_got lj_meta_comp | addiu PC, PC, -4 | sw BASE, L->base | sw PC, SAVE_PC | decode_OP1 CARG4, INS | call_intern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) |. move CARG1, L | // Returns 0/1 or TValue * (metamethod). |3: | sltiu AT, CRET1, 2 | beqz AT, ->vmeta_binop | negu TMP2, CRET1 |4: | lhu RD, OFS_RD(PC) | addiu PC, PC, 4 | lui TMP1, (-(BCBIAS_J*4 >> 16) & 65535) | sll RD, RD, 2 | addu RD, RD, TMP1 | and RD, RD, TMP2 | addu PC, PC, RD |->cont_nop: | ins_next | |->cont_ra: // RA = resultptr | lbu TMP1, -4+OFS_RA(PC) | ldc1 f0, 0(RA) | sll TMP1, TMP1, 3 | addu TMP1, BASE, TMP1 | b ->cont_nop |. sdc1 f0, 0(TMP1) | |->cont_condt: // RA = resultptr | lw TMP0, HI(RA) | sltiu AT, TMP0, LJ_TISTRUECOND | b <4 |. negu TMP2, AT // Branch if result is true. | |->cont_condf: // RA = resultptr | lw TMP0, HI(RA) | sltiu AT, TMP0, LJ_TISTRUECOND | b <4 |. addiu TMP2, AT, -1 // Branch if result is false. | |->vmeta_equal: | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. | load_got lj_meta_equal | addiu PC, PC, -4 | sw BASE, L->base | sw PC, SAVE_PC | call_intern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) |. move CARG1, L | // Returns 0/1 or TValue * (metamethod). | b <3 |. nop | |->vmeta_equal_cd: |.if FFI | load_got lj_meta_equal_cd | move CARG2, INS | addiu PC, PC, -4 | sw BASE, L->base | sw PC, SAVE_PC | call_intern lj_meta_equal_cd // (lua_State *L, BCIns op) |. move CARG1, L | // Returns 0/1 or TValue * (metamethod). | b <3 |. nop |.endif | |//-- Arithmetic metamethods --------------------------------------------- | |->vmeta_unm: | move CARG4, CARG3 | |->vmeta_arith: | load_got lj_meta_arith | decode_OP1 TMP0, INS | sw BASE, L->base | sw PC, SAVE_PC | move CARG2, RA | sw TMP0, ARG5 | call_intern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) |. move CARG1, L | // Returns NULL (finished) or TValue * (metamethod). | beqz CRET1, ->cont_nop |. nop | | // Call metamethod for binary op. |->vmeta_binop: | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 | subu TMP1, CRET1, BASE | sw PC, -16+HI(CRET1) // [cont|PC] | move TMP2, BASE | addiu PC, TMP1, FRAME_CONT | move BASE, CRET1 | b ->vm_call_dispatch |. li NARGS8:RC, 16 // 2 args for func(o1, o2). | |->vmeta_len: | // CARG2 already set by BC_LEN. #if LJ_52 | move MULTRES, CARG1 #endif | load_got lj_meta_len | sw BASE, L->base | sw PC, SAVE_PC | call_intern lj_meta_len // (lua_State *L, TValue *o) |. move CARG1, L | // Returns NULL (retry) or TValue * (metamethod base). #if LJ_52 | bnez CRET1, ->vmeta_binop // Binop call for compatibility. |. nop | b ->BC_LEN_Z |. move CARG1, MULTRES #else | b ->vmeta_binop // Binop call for compatibility. |. nop #endif | |//-- Call metamethod ---------------------------------------------------- | |->vmeta_call: // Resolve and call __call metamethod. | // TMP2 = old base, BASE = new base, RC = nargs*8 | load_got lj_meta_call | sw TMP2, L->base // This is the callers base! | addiu CARG2, BASE, -8 | sw PC, SAVE_PC | addu CARG3, BASE, RC | move MULTRES, NARGS8:RC | call_intern lj_meta_call // (lua_State *L, TValue *func, TValue *top) |. move CARG1, L | lw LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | addiu NARGS8:RC, MULTRES, 8 // Got one more argument now. | ins_call | |->vmeta_callt: // Resolve __call for BC_CALLT. | // BASE = old base, RA = new base, RC = nargs*8 | load_got lj_meta_call | sw BASE, L->base | addiu CARG2, RA, -8 | sw PC, SAVE_PC | addu CARG3, RA, RC | move MULTRES, NARGS8:RC | call_intern lj_meta_call // (lua_State *L, TValue *func, TValue *top) |. move CARG1, L | lw TMP1, FRAME_PC(BASE) | lw LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. | b ->BC_CALLT_Z |. addiu NARGS8:RC, MULTRES, 8 // Got one more argument now. | |//-- Argument coercion for 'for' statement ------------------------------ | |->vmeta_for: | load_got lj_meta_for | sw BASE, L->base | move CARG2, RA | sw PC, SAVE_PC | move MULTRES, INS | call_intern lj_meta_for // (lua_State *L, TValue *base) |. move CARG1, L |.if JIT | decode_OP1 TMP0, MULTRES | li AT, BC_JFORI |.endif | decode_RA8a RA, MULTRES | decode_RD8a RD, MULTRES | decode_RA8b RA |.if JIT | beq TMP0, AT, =>BC_JFORI |. decode_RD8b RD | b =>BC_FORI |. nop |.else | b =>BC_FORI |. decode_RD8b RD |.endif | |//----------------------------------------------------------------------- |//-- Fast functions ----------------------------------------------------- |//----------------------------------------------------------------------- | |.macro .ffunc, name |->ff_ .. name: |.endmacro | |.macro .ffunc_1, name |->ff_ .. name: | beqz NARGS8:RC, ->fff_fallback |. lw CARG3, HI(BASE) | lw CARG1, LO(BASE) |.endmacro | |.macro .ffunc_2, name |->ff_ .. name: | sltiu AT, NARGS8:RC, 16 | lw CARG3, HI(BASE) | bnez AT, ->fff_fallback |. lw CARG4, 8+HI(BASE) | lw CARG1, LO(BASE) | lw CARG2, 8+LO(BASE) |.endmacro | |.macro .ffunc_n, name // Caveat: has delay slot! |->ff_ .. name: | lw CARG3, HI(BASE) | beqz NARGS8:RC, ->fff_fallback |. ldc1 FARG1, 0(BASE) | sltiu AT, CARG3, LJ_TISNUM | beqz AT, ->fff_fallback |.endmacro | |.macro .ffunc_nn, name // Caveat: has delay slot! |->ff_ .. name: | sltiu AT, NARGS8:RC, 16 | lw CARG3, HI(BASE) | bnez AT, ->fff_fallback |. lw CARG4, 8+HI(BASE) | ldc1 FARG1, 0(BASE) | ldc1 FARG2, 8(BASE) | sltiu TMP0, CARG3, LJ_TISNUM | sltiu TMP1, CARG4, LJ_TISNUM | and TMP0, TMP0, TMP1 | beqz TMP0, ->fff_fallback |.endmacro | |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1 and has delay slot! |.macro ffgccheck | lw TMP0, DISPATCH_GL(gc.total)(DISPATCH) | lw TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) | subu AT, TMP0, TMP1 | bgezal AT, ->fff_gcstep |.endmacro | |//-- Base library: checks ----------------------------------------------- | |.ffunc_1 assert | sltiu AT, CARG3, LJ_TISTRUECOND | beqz AT, ->fff_fallback |. addiu RA, BASE, -8 | lw PC, FRAME_PC(BASE) | addiu RD, NARGS8:RC, 8 // Compute (nresults+1)*8. | addu TMP2, RA, NARGS8:RC | sw CARG3, HI(RA) | addiu TMP1, BASE, 8 | beq BASE, TMP2, ->fff_res // Done if exactly 1 argument. |. sw CARG1, LO(RA) |1: | ldc1 f0, 0(TMP1) | sdc1 f0, -8(TMP1) | bne TMP1, TMP2, <1 |. addiu TMP1, TMP1, 8 | b ->fff_res |. nop | |.ffunc type | lw CARG3, HI(BASE) | li TMP1, LJ_TISNUM | beqz NARGS8:RC, ->fff_fallback |. sltiu TMP0, CARG3, LJ_TISNUM | movz TMP1, CARG3, TMP0 | not TMP1, TMP1 | sll TMP1, TMP1, 3 | addu TMP1, CFUNC:RB, TMP1 | b ->fff_resn |. ldc1 FRET1, CFUNC:TMP1->upvalue | |//-- Base library: getters and setters --------------------------------- | |.ffunc_1 getmetatable | li AT, LJ_TTAB | bne CARG3, AT, >6 |. li AT, LJ_TUDATA |1: // Field metatable must be at same offset for GCtab and GCudata! | lw TAB:CARG1, TAB:CARG1->metatable |2: | lw STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) | beqz TAB:CARG1, ->fff_restv |. li CARG3, LJ_TNIL | lw TMP0, TAB:CARG1->hmask | li CARG3, LJ_TTAB // Use metatable as default result. | lw TMP1, STR:RC->hash | lw NODE:TMP2, TAB:CARG1->node | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | sll TMP0, TMP1, 5 | sll TMP1, TMP1, 3 | subu TMP1, TMP0, TMP1 | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) | li AT, LJ_TSTR |3: // Rearranged logic, because we expect _not_ to find the key. | lw CARG4, offsetof(Node, key)+HI(NODE:TMP2) | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) | lw NODE:TMP3, NODE:TMP2->next | bne CARG4, AT, >4 |. lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) | beq TMP0, STR:RC, >5 |. lw TMP1, offsetof(Node, val)+LO(NODE:TMP2) |4: | beqz NODE:TMP3, ->fff_restv // Not found, keep default result. |. move NODE:TMP2, NODE:TMP3 | b <3 |. nop |5: | beq CARG2, TISNIL, ->fff_restv // Ditto for nil value. |. nop | move CARG3, CARG2 // Return value of mt.__metatable. | b ->fff_restv |. move CARG1, TMP1 | |6: | beq CARG3, AT, <1 |. sltiu TMP0, CARG3, LJ_TISNUM | li TMP1, LJ_TISNUM | movz TMP1, CARG3, TMP0 | not TMP1, TMP1 | sll TMP1, TMP1, 2 | addu TMP1, DISPATCH, TMP1 | b <2 |. lw TAB:CARG1, DISPATCH_GL(gcroot[GCROOT_BASEMT])(TMP1) | |.ffunc_2 setmetatable | // Fast path: no mt for table yet and not clearing the mt. | li AT, LJ_TTAB | bne CARG3, AT, ->fff_fallback |. addiu CARG4, CARG4, -LJ_TTAB | lw TAB:TMP1, TAB:CARG1->metatable | lbu TMP3, TAB:CARG1->marked | or AT, CARG4, TAB:TMP1 | bnez AT, ->fff_fallback |. andi AT, TMP3, LJ_GC_BLACK // isblack(table) | beqz AT, ->fff_restv |. sw TAB:CARG2, TAB:CARG1->metatable | barrierback TAB:CARG1, TMP3, TMP0, ->fff_restv | |.ffunc rawget | lw CARG4, HI(BASE) | sltiu AT, NARGS8:RC, 16 | lw TAB:CARG2, LO(BASE) | load_got lj_tab_get | addiu CARG4, CARG4, -LJ_TTAB | or AT, AT, CARG4 | bnez AT, ->fff_fallback | addiu CARG3, BASE, 8 | call_intern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) |. move CARG1, L | // Returns cTValue *. | b ->fff_resn |. ldc1 FRET1, 0(CRET1) | |//-- Base library: conversions ------------------------------------------ | |.ffunc tonumber | // Only handles the number case inline (without a base argument). | lw CARG1, HI(BASE) | xori AT, NARGS8:RC, 8 | sltiu CARG1, CARG1, LJ_TISNUM | movn CARG1, r0, AT | beqz CARG1, ->fff_fallback // Exactly one number argument. |. ldc1 FRET1, 0(BASE) | b ->fff_resn |. nop | |.ffunc_1 tostring | // Only handles the string or number case inline. | li AT, LJ_TSTR | // A __tostring method in the string base metatable is ignored. | beq CARG3, AT, ->fff_restv // String key? | // Handle numbers inline, unless a number base metatable is present. |. lw TMP1, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) | sltiu TMP0, CARG3, LJ_TISNUM | sltiu TMP1, TMP1, 1 | and TMP0, TMP0, TMP1 | beqz TMP0, ->fff_fallback |. sw BASE, L->base // Add frame since C call can throw. | ffgccheck |. sw PC, SAVE_PC // Redundant (but a defined value). | load_got lj_str_fromnum | move CARG1, L | call_intern lj_str_fromnum // (lua_State *L, lua_Number *np) |. move CARG2, BASE | // Returns GCstr *. | li CARG3, LJ_TSTR | b ->fff_restv |. move CARG1, CRET1 | |//-- Base library: iterators ------------------------------------------- | |.ffunc next | lw CARG1, HI(BASE) | lw TAB:CARG2, LO(BASE) | beqz NARGS8:RC, ->fff_fallback |. addu TMP2, BASE, NARGS8:RC | li AT, LJ_TTAB | sw TISNIL, HI(TMP2) // Set missing 2nd arg to nil. | bne CARG1, AT, ->fff_fallback |. lw PC, FRAME_PC(BASE) | load_got lj_tab_next | sw BASE, L->base // Add frame since C call can throw. | sw BASE, L->top // Dummy frame length is ok. | addiu CARG3, BASE, 8 | sw PC, SAVE_PC | call_intern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) |. move CARG1, L | // Returns 0 at end of traversal. | beqz CRET1, ->fff_restv // End of traversal: return nil. |. li CARG3, LJ_TNIL | ldc1 f0, 8(BASE) // Copy key and value to results. | addiu RA, BASE, -8 | ldc1 f2, 16(BASE) | li RD, (2+1)*8 | sdc1 f0, 0(RA) | b ->fff_res |. sdc1 f2, 8(RA) | |.ffunc_1 pairs | li AT, LJ_TTAB | bne CARG3, AT, ->fff_fallback |. lw PC, FRAME_PC(BASE) #if LJ_52 | lw TAB:TMP2, TAB:CARG1->metatable | ldc1 f0, CFUNC:RB->upvalue[0] | bnez TAB:TMP2, ->fff_fallback #else | ldc1 f0, CFUNC:RB->upvalue[0] #endif |. addiu RA, BASE, -8 | sw TISNIL, 8+HI(BASE) | li RD, (3+1)*8 | b ->fff_res |. sdc1 f0, 0(RA) | |.ffunc ipairs_aux | sltiu AT, NARGS8:RC, 16 | lw CARG3, HI(BASE) | lw TAB:CARG1, LO(BASE) | lw CARG4, 8+HI(BASE) | bnez AT, ->fff_fallback |. ldc1 FARG2, 8(BASE) | addiu CARG3, CARG3, -LJ_TTAB | sltiu AT, CARG4, LJ_TISNUM | li TMP0, 1 | movn AT, r0, CARG3 | mtc1 TMP0, FARG1 | beqz AT, ->fff_fallback |. lw PC, FRAME_PC(BASE) | cvt.w.d FRET1, FARG2 | cvt.d.w FARG1, FARG1 | lw TMP0, TAB:CARG1->asize | lw TMP1, TAB:CARG1->array | mfc1 TMP2, FRET1 | addiu RA, BASE, -8 | add.d FARG2, FARG2, FARG1 | addiu TMP2, TMP2, 1 | sltu AT, TMP2, TMP0 | sll TMP3, TMP2, 3 | addu TMP3, TMP1, TMP3 | beqz AT, >2 // Not in array part? |. sdc1 FARG2, 0(RA) | lw TMP2, HI(TMP3) | ldc1 f0, 0(TMP3) |1: | beq TMP2, TISNIL, ->fff_res // End of iteration, return 0 results. |. li RD, (0+1)*8 | li RD, (2+1)*8 | b ->fff_res |. sdc1 f0, 8(RA) |2: // Check for empty hash part first. Otherwise call C function. | lw TMP0, TAB:CARG1->hmask | load_got lj_tab_getinth | beqz TMP0, ->fff_res |. li RD, (0+1)*8 | call_intern lj_tab_getinth // (GCtab *t, int32_t key) |. move CARG2, TMP2 | // Returns cTValue * or NULL. | beqz CRET1, ->fff_res |. li RD, (0+1)*8 | lw TMP2, HI(CRET1) | b <1 |. ldc1 f0, 0(CRET1) | |.ffunc_1 ipairs | li AT, LJ_TTAB | bne CARG3, AT, ->fff_fallback |. lw PC, FRAME_PC(BASE) #if LJ_52 | lw TAB:TMP2, TAB:CARG1->metatable | ldc1 f0, CFUNC:RB->upvalue[0] | bnez TAB:TMP2, ->fff_fallback #else | ldc1 f0, CFUNC:RB->upvalue[0] #endif |. addiu RA, BASE, -8 | sw r0, 8+HI(BASE) | sw r0, 8+LO(BASE) | li RD, (3+1)*8 | b ->fff_res |. sdc1 f0, 0(RA) | |//-- Base library: catch errors ---------------------------------------- | |.ffunc pcall | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) | beqz NARGS8:RC, ->fff_fallback | move TMP2, BASE | addiu BASE, BASE, 8 | // Remember active hook before pcall. | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT | andi TMP3, TMP3, 1 | addiu PC, TMP3, 8+FRAME_PCALL | b ->vm_call_dispatch |. addiu NARGS8:RC, NARGS8:RC, -8 | |.ffunc xpcall | sltiu AT, NARGS8:RC, 16 | lw CARG4, 8+HI(BASE) | bnez AT, ->fff_fallback |. ldc1 FARG2, 8(BASE) | ldc1 FARG1, 0(BASE) | lbu TMP1, DISPATCH_GL(hookmask)(DISPATCH) | li AT, LJ_TFUNC | move TMP2, BASE | bne CARG4, AT, ->fff_fallback // Traceback must be a function. | addiu BASE, BASE, 16 | // Remember active hook before pcall. | srl TMP3, TMP3, HOOK_ACTIVE_SHIFT | sdc1 FARG2, 0(TMP2) // Swap function and traceback. | andi TMP3, TMP3, 1 | sdc1 FARG1, 8(TMP2) | addiu PC, TMP3, 16+FRAME_PCALL | b ->vm_call_dispatch |. addiu NARGS8:RC, NARGS8:RC, -16 | |//-- Coroutine library -------------------------------------------------- | |.macro coroutine_resume_wrap, resume |.if resume |.ffunc_1 coroutine_resume | li AT, LJ_TTHREAD | bne CARG3, AT, ->fff_fallback |.else |.ffunc coroutine_wrap_aux | lw L:CARG1, CFUNC:RB->upvalue[0].gcr |.endif | lbu TMP0, L:CARG1->status | lw TMP1, L:CARG1->cframe | lw CARG2, L:CARG1->top | lw TMP2, L:CARG1->base | addiu TMP3, TMP0, -LUA_YIELD | bgtz TMP3, ->fff_fallback // st > LUA_YIELD? |. xor TMP2, TMP2, CARG2 | bnez TMP1, ->fff_fallback // cframe != 0? |. or AT, TMP2, TMP0 | lw TMP0, L:CARG1->maxstack | beqz AT, ->fff_fallback // base == top && st == 0? |. lw PC, FRAME_PC(BASE) | addu TMP2, CARG2, NARGS8:RC | sltu AT, TMP0, TMP2 | bnez AT, ->fff_fallback // Stack overflow? |. sw PC, SAVE_PC | sw BASE, L->base |1: |.if resume | addiu BASE, BASE, 8 // Keep resumed thread in stack for GC. | addiu NARGS8:RC, NARGS8:RC, -8 | addiu TMP2, TMP2, -8 |.endif | sw TMP2, L:CARG1->top | addu TMP1, BASE, NARGS8:RC | move CARG3, CARG2 | sw BASE, L->top |2: // Move args to coroutine. | ldc1 f0, 0(BASE) | sltu AT, BASE, TMP1 | beqz AT, >3 |. addiu BASE, BASE, 8 | sdc1 f0, 0(CARG3) | b <2 |. addiu CARG3, CARG3, 8 |3: | bal ->vm_resume // (lua_State *L, TValue *base, 0, 0) |. move L:RA, L:CARG1 | // Returns thread status. |4: | lw TMP2, L:RA->base | sltiu AT, CRET1, LUA_YIELD+1 | lw TMP3, L:RA->top | li_vmstate INTERP | lw BASE, L->base | st_vmstate | beqz AT, >8 |. subu RD, TMP3, TMP2 | lw TMP0, L->maxstack | beqz RD, >6 // No results? |. addu TMP1, BASE, RD | sltu AT, TMP0, TMP1 | bnez AT, >9 // Need to grow stack? |. addu TMP3, TMP2, RD | sw TMP2, L:RA->top // Clear coroutine stack. | move TMP1, BASE |5: // Move results from coroutine. | ldc1 f0, 0(TMP2) | addiu TMP2, TMP2, 8 | sltu AT, TMP2, TMP3 | sdc1 f0, 0(TMP1) | bnez AT, <5 |. addiu TMP1, TMP1, 8 |6: | andi TMP0, PC, FRAME_TYPE |.if resume | li TMP1, LJ_TTRUE | addiu RA, BASE, -8 | sw TMP1, -8+HI(BASE) // Prepend true to results. | addiu RD, RD, 16 |.else | move RA, BASE | addiu RD, RD, 8 |.endif |7: | sw PC, SAVE_PC | beqz TMP0, ->BC_RET_Z |. move MULTRES, RD | b ->vm_return |. nop | |8: // Coroutine returned with error (at co->top-1). |.if resume | addiu TMP3, TMP3, -8 | li TMP1, LJ_TFALSE | ldc1 f0, 0(TMP3) | sw TMP3, L:RA->top // Remove error from coroutine stack. | li RD, (2+1)*8 | sw TMP1, -8+HI(BASE) // Prepend false to results. | addiu RA, BASE, -8 | sdc1 f0, 0(BASE) // Copy error message. | b <7 |. andi TMP0, PC, FRAME_TYPE |.else | load_got lj_ffh_coroutine_wrap_err | move CARG2, L:RA | call_intern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) |. move CARG1, L |.endif | |9: // Handle stack expansion on return from yield. | load_got lj_state_growstack | srl CARG2, RD, 3 | call_intern lj_state_growstack // (lua_State *L, int n) |. move CARG1, L | b <4 |. li CRET1, 0 |.endmacro | | coroutine_resume_wrap 1 // coroutine.resume | coroutine_resume_wrap 0 // coroutine.wrap | |.ffunc coroutine_yield | lw TMP0, L->cframe | addu TMP1, BASE, NARGS8:RC | sw BASE, L->base | andi TMP0, TMP0, CFRAME_RESUME | sw TMP1, L->top | beqz TMP0, ->fff_fallback |. li CRET1, LUA_YIELD | sw r0, L->cframe | b ->vm_leave_unw |. sb CRET1, L->status | |//-- Math library ------------------------------------------------------- | |.ffunc_n math_abs |. abs.d FRET1, FARG1 |->fff_resn: | lw PC, FRAME_PC(BASE) | addiu RA, BASE, -8 | b ->fff_res1 |. sdc1 FRET1, -8(BASE) | |->fff_restv: | // CARG3/CARG1 = TValue result. | lw PC, FRAME_PC(BASE) | sw CARG3, -8+HI(BASE) | addiu RA, BASE, -8 | sw CARG1, -8+LO(BASE) |->fff_res1: | // RA = results, PC = return. | li RD, (1+1)*8 |->fff_res: | // RA = results, RD = (nresults+1)*8, PC = return. | andi TMP0, PC, FRAME_TYPE | bnez TMP0, ->vm_return |. move MULTRES, RD | lw INS, -4(PC) | decode_RB8a RB, INS | decode_RB8b RB |5: | sltu AT, RD, RB | bnez AT, >6 // More results expected? |. decode_RA8a TMP0, INS | decode_RA8b TMP0 | ins_next1 | // Adjust BASE. KBASE is assumed to be set for the calling frame. | subu BASE, RA, TMP0 | ins_next2 | |6: // Fill up results with nil. | addu TMP1, RA, RD | addiu RD, RD, 8 | b <5 |. sw TISNIL, -8+HI(TMP1) | |.macro math_extern, func |->ff_math_ .. func: | lw CARG3, HI(BASE) | beqz NARGS8:RC, ->fff_fallback |. load_got func | sltiu AT, CARG3, LJ_TISNUM | beqz AT, ->fff_fallback |. nop | call_extern |. ldc1 FARG1, 0(BASE) | b ->fff_resn |. nop |.endmacro | |.macro math_extern2, func | .ffunc_nn math_ .. func |. load_got func | call_extern |. nop | b ->fff_resn |. nop |.endmacro | |.macro math_round, func | .ffunc_n math_ .. func |. nop | bal ->vm_ .. func |. nop | b ->fff_resn |. nop |.endmacro | | math_round floor | math_round ceil | |.ffunc math_log | lw CARG3, HI(BASE) | li AT, 8 | bne NARGS8:RC, AT, ->fff_fallback // Exactly 1 argument. |. load_got log | sltiu AT, CARG3, LJ_TISNUM | beqz AT, ->fff_fallback |. nop | call_extern |. ldc1 FARG1, 0(BASE) | b ->fff_resn |. nop | | math_extern log10 | math_extern exp | math_extern sin | math_extern cos | math_extern tan | math_extern asin | math_extern acos | math_extern atan | math_extern sinh | math_extern cosh | math_extern tanh | math_extern2 pow | math_extern2 atan2 | math_extern2 fmod | |.ffunc_n math_sqrt |. sqrt.d FRET1, FARG1 | b ->fff_resn |. nop | |->ff_math_deg: |.ffunc_n math_rad |. ldc1 FARG2, CFUNC:RB->upvalue[0] | b ->fff_resn |. mul.d FRET1, FARG1, FARG2 | |.ffunc_nn math_ldexp | cvt.w.d FARG2, FARG2 | load_got ldexp | mfc1 CARG3, FARG2 | call_extern |. nop | b ->fff_resn |. nop | |.ffunc_n math_frexp | load_got frexp | lw PC, FRAME_PC(BASE) | call_extern |. addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) | lw TMP1, DISPATCH_GL(tmptv)(DISPATCH) | addiu RA, BASE, -8 | mtc1 TMP1, FARG2 | sdc1 FRET1, 0(RA) | cvt.d.w FARG2, FARG2 | sdc1 FARG2, 8(RA) | b ->fff_res |. li RD, (2+1)*8 | |.ffunc_n math_modf | load_got modf | lw PC, FRAME_PC(BASE) | call_extern |. addiu CARG3, BASE, -8 | addiu RA, BASE, -8 | sdc1 FRET1, 0(BASE) | b ->fff_res |. li RD, (2+1)*8 | |.macro math_minmax, name, ismax |->ff_ .. name: | lw CARG3, HI(BASE) | beqz NARGS8:RC, ->fff_fallback |. ldc1 FRET1, 0(BASE) | sltiu AT, CARG3, LJ_TISNUM | beqz AT, ->fff_fallback |. addu TMP2, BASE, NARGS8:RC | addiu TMP1, BASE, 8 | beq TMP1, TMP2, ->fff_resn |1: |. lw CARG3, HI(TMP1) | ldc1 FARG1, 0(TMP1) | addiu TMP1, TMP1, 8 | sltiu AT, CARG3, LJ_TISNUM | beqz AT, ->fff_fallback |.if ismax |. c.olt.d FARG1, FRET1 |.else |. c.olt.d FRET1, FARG1 |.endif | bne TMP1, TMP2, <1 |. movf.d FRET1, FARG1 | b ->fff_resn |. nop |.endmacro | | math_minmax math_min, 0 | math_minmax math_max, 1 | |//-- String library ----------------------------------------------------- | |.ffunc_1 string_len | li AT, LJ_TSTR | bne CARG3, AT, ->fff_fallback |. nop | b ->fff_resi |. lw CRET1, STR:CARG1->len | |.ffunc string_byte // Only handle the 1-arg case here. | lw CARG3, HI(BASE) | lw STR:CARG1, LO(BASE) | xori AT, NARGS8:RC, 8 | addiu CARG3, CARG3, -LJ_TSTR | or AT, AT, CARG3 | bnez AT, ->fff_fallback // Need exactly 1 string argument. |. nop | lw TMP0, STR:CARG1->len | lbu TMP1, STR:CARG1[1] // Access is always ok (NUL at end). | addiu RA, BASE, -8 | sltu RD, r0, TMP0 | mtc1 TMP1, f0 | addiu RD, RD, 1 | cvt.d.w f0, f0 | lw PC, FRAME_PC(BASE) | sll RD, RD, 3 // RD = ((str->len != 0)+1)*8 | b ->fff_res |. sdc1 f0, 0(RA) | |.ffunc string_char // Only handle the 1-arg case here. | ffgccheck | lw CARG3, HI(BASE) | ldc1 FARG1, 0(BASE) | li AT, 8 | bne NARGS8:RC, AT, ->fff_fallback // Exactly 1 argument. |. sltiu AT, CARG3, LJ_TISNUM | beqz AT, ->fff_fallback |. li CARG3, 1 | cvt.w.d FARG1, FARG1 | addiu CARG2, sp, ARG5_OFS | sltiu AT, TMP0, 256 | mfc1 TMP0, FARG1 | beqz AT, ->fff_fallback |. sw TMP0, ARG5 |->fff_newstr: | load_got lj_str_new | sw BASE, L->base | sw PC, SAVE_PC | call_intern lj_str_new // (lua_State *L, char *str, size_t l) |. move CARG1, L | // Returns GCstr *. | lw BASE, L->base | move CARG1, CRET1 | b ->fff_restv |. li CARG3, LJ_TSTR | |.ffunc string_sub | ffgccheck | addiu AT, NARGS8:RC, -16 | lw CARG3, 16+HI(BASE) | ldc1 f0, 16(BASE) | lw TMP0, HI(BASE) | lw STR:CARG1, LO(BASE) | bltz AT, ->fff_fallback | lw CARG2, 8+HI(BASE) | ldc1 f2, 8(BASE) | beqz AT, >1 |. li CARG4, -1 | cvt.w.d f0, f0 | sltiu AT, CARG3, LJ_TISNUM | beqz AT, ->fff_fallback |. mfc1 CARG4, f0 |1: | sltiu AT, CARG2, LJ_TISNUM | beqz AT, ->fff_fallback |. li AT, LJ_TSTR | cvt.w.d f2, f2 | bne TMP0, AT, ->fff_fallback |. lw CARG2, STR:CARG1->len | mfc1 CARG3, f2 | // STR:CARG1 = str, CARG2 = str->len, CARG3 = start, CARG4 = end | slt AT, CARG4, r0 | addiu TMP0, CARG2, 1 | addu TMP1, CARG4, TMP0 | slt TMP3, CARG3, r0 | movn CARG4, TMP1, AT // if (end < 0) end += len+1 | addu TMP1, CARG3, TMP0 | movn CARG3, TMP1, TMP3 // if (start < 0) start += len+1 | li TMP2, 1 | slt AT, CARG4, r0 | slt TMP3, r0, CARG3 | movn CARG4, r0, AT // if (end < 0) end = 0 | movz CARG3, TMP2, TMP3 // if (start < 1) start = 1 | slt AT, CARG2, CARG4 | movn CARG4, CARG2, AT // if (end > len) end = len | addu CARG2, STR:CARG1, CARG3 | subu CARG3, CARG4, CARG3 // len = end - start | addiu CARG2, CARG2, sizeof(GCstr)-1 | bgez CARG3, ->fff_newstr |. addiu CARG3, CARG3, 1 // len++ |->fff_emptystr: // Return empty string. | addiu STR:CARG1, DISPATCH, DISPATCH_GL(strempty) | b ->fff_restv |. li CARG3, LJ_TSTR | |.ffunc string_rep // Only handle the 1-char case inline. | ffgccheck | lw TMP0, HI(BASE) | addiu AT, NARGS8:RC, -16 // Exactly 2 arguments. | lw CARG4, 8+HI(BASE) | lw STR:CARG1, LO(BASE) | addiu TMP0, TMP0, -LJ_TSTR | ldc1 f0, 8(BASE) | or AT, AT, TMP0 | bnez AT, ->fff_fallback |. sltiu AT, CARG4, LJ_TISNUM | cvt.w.d f0, f0 | beqz AT, ->fff_fallback |. lw TMP0, STR:CARG1->len | mfc1 CARG3, f0 | lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | li AT, 1 | blez CARG3, ->fff_emptystr // Count <= 0? |. sltu AT, AT, TMP0 | beqz TMP0, ->fff_emptystr // Zero length string? |. sltu TMP0, TMP1, CARG3 | or AT, AT, TMP0 | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | bnez AT, ->fff_fallback // Fallback for > 1-char strings. |. lbu TMP0, STR:CARG1[1] | addu TMP2, CARG2, CARG3 |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). | addiu TMP2, TMP2, -1 | sltu AT, CARG2, TMP2 | bnez AT, <1 |. sb TMP0, 0(TMP2) | b ->fff_newstr |. nop | |.ffunc string_reverse | ffgccheck | lw CARG3, HI(BASE) | lw STR:CARG1, LO(BASE) | beqz NARGS8:RC, ->fff_fallback |. li AT, LJ_TSTR | bne CARG3, AT, ->fff_fallback |. lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | lw CARG3, STR:CARG1->len | addiu CARG1, STR:CARG1, #STR | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | sltu AT, TMP1, CARG3 | bnez AT, ->fff_fallback |. addu TMP3, CARG1, CARG3 | addu CARG4, CARG2, CARG3 |1: // Reverse string copy. | lbu TMP1, 0(CARG1) | sltu AT, CARG1, TMP3 | beqz AT, ->fff_newstr |. addiu CARG1, CARG1, 1 | addiu CARG4, CARG4, -1 | b <1 | sb TMP1, 0(CARG4) | |.macro ffstring_case, name, lo | .ffunc name | ffgccheck | lw CARG3, HI(BASE) | lw STR:CARG1, LO(BASE) | beqz NARGS8:RC, ->fff_fallback |. li AT, LJ_TSTR | bne CARG3, AT, ->fff_fallback |. lw TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | lw CARG3, STR:CARG1->len | addiu CARG1, STR:CARG1, #STR | lw CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | sltu AT, TMP1, CARG3 | bnez AT, ->fff_fallback |. addu TMP3, CARG1, CARG3 | move CARG4, CARG2 |1: // ASCII case conversion. | lbu TMP1, 0(CARG1) | sltu AT, CARG1, TMP3 | beqz AT, ->fff_newstr |. addiu TMP0, TMP1, -lo | xori TMP2, TMP1, 0x20 | sltiu AT, TMP0, 26 | movn TMP1, TMP2, AT | addiu CARG1, CARG1, 1 | sb TMP1, 0(CARG4) | b <1 |. addiu CARG4, CARG4, 1 |.endmacro | |ffstring_case string_lower, 65 |ffstring_case string_upper, 97 | |//-- Table library ------------------------------------------------------ | |.ffunc_1 table_getn | li AT, LJ_TTAB | bne CARG3, AT, ->fff_fallback |. load_got lj_tab_len | call_intern lj_tab_len // (GCtab *t) |. nop | // Returns uint32_t (but less than 2^31). | b ->fff_resi |. nop | |//-- Bit library -------------------------------------------------------- | |.macro .ffunc_bit, name | .ffunc_n bit_..name |. add.d FARG1, FARG1, TOBIT | mfc1 CRET1, FARG1 |.endmacro | |.macro .ffunc_bit_op, name, ins | .ffunc_bit name | addiu TMP1, BASE, 8 | addu TMP2, BASE, NARGS8:RC |1: | lw CARG4, HI(TMP1) | beq TMP1, TMP2, ->fff_resi |. ldc1 FARG1, 0(TMP1) | sltiu AT, CARG4, LJ_TISNUM | beqz AT, ->fff_fallback | add.d FARG1, FARG1, TOBIT | mfc1 CARG2, FARG1 | ins CRET1, CRET1, CARG2 | b <1 |. addiu TMP1, TMP1, 8 |.endmacro | |.ffunc_bit_op band, and |.ffunc_bit_op bor, or |.ffunc_bit_op bxor, xor | |.ffunc_bit bswap | srl TMP0, CRET1, 24 | srl TMP2, CRET1, 8 | sll TMP1, CRET1, 24 | andi TMP2, TMP2, 0xff00 | or TMP0, TMP0, TMP1 | andi CRET1, CRET1, 0xff00 | or TMP0, TMP0, TMP2 | sll CRET1, CRET1, 8 | b ->fff_resi |. or CRET1, TMP0, CRET1 | |.ffunc_bit bnot | b ->fff_resi |. not CRET1, CRET1 | |.macro .ffunc_bit_sh, name, ins, shmod | .ffunc_nn bit_..name |. add.d FARG1, FARG1, TOBIT | add.d FARG2, FARG2, TOBIT | mfc1 CARG1, FARG1 | mfc1 CARG2, FARG2 |.if shmod == 1 | li AT, 32 | subu TMP0, AT, CARG2 | sllv CARG2, CARG1, CARG2 | srlv CARG1, CARG1, TMP0 |.elif shmod == 2 | li AT, 32 | subu TMP0, AT, CARG2 | srlv CARG2, CARG1, CARG2 | sllv CARG1, CARG1, TMP0 |.endif | b ->fff_resi |. ins CRET1, CARG1, CARG2 |.endmacro | |.ffunc_bit_sh lshift, sllv, 0 |.ffunc_bit_sh rshift, srlv, 0 |.ffunc_bit_sh arshift, srav, 0 |// Can't use rotrv, since it's only in MIPS32R2. |.ffunc_bit_sh rol, or, 1 |.ffunc_bit_sh ror, or, 2 | |.ffunc_bit tobit |->fff_resi: | mtc1 CRET1, FRET1 | b ->fff_resn |. cvt.d.w FRET1, FRET1 | |//----------------------------------------------------------------------- | |->fff_fallback: // Call fast function fallback handler. | // BASE = new base, RB = CFUNC, RC = nargs*8 | lw TMP3, CFUNC:RB->f | addu TMP1, BASE, NARGS8:RC | lw PC, FRAME_PC(BASE) // Fallback may overwrite PC. | addiu TMP0, TMP1, 8*LUA_MINSTACK | lw TMP2, L->maxstack | sw PC, SAVE_PC // Redundant (but a defined value). | sltu AT, TMP2, TMP0 | sw BASE, L->base | sw TMP1, L->top | bnez AT, >5 // Need to grow stack. |. move CFUNCADDR, TMP3 | jalr TMP3 // (lua_State *L) |. move CARG1, L | // Either throws an error, or recovers and returns -1, 0 or nresults+1. | lw BASE, L->base | sll RD, CRET1, 3 | bgtz CRET1, ->fff_res // Returned nresults+1? |. addiu RA, BASE, -8 |1: // Returned 0 or -1: retry fast path. | lw TMP0, L->top | lw LFUNC:RB, FRAME_FUNC(BASE) | bnez CRET1, ->vm_call_tail // Returned -1? |. subu NARGS8:RC, TMP0, BASE | ins_callt // Returned 0: retry fast path. | |// Reconstruct previous base for vmeta_call during tailcall. |->vm_call_tail: | andi TMP0, PC, FRAME_TYPE | li AT, -4 | bnez TMP0, >3 |. and TMP1, PC, AT | lbu TMP1, OFS_RA(PC) | sll TMP1, TMP1, 3 | addiu TMP1, TMP1, 8 |3: | b ->vm_call_dispatch // Resolve again for tailcall. |. subu TMP2, BASE, TMP1 | |5: // Grow stack for fallback handler. | load_got lj_state_growstack | li CARG2, LUA_MINSTACK | call_intern lj_state_growstack // (lua_State *L, int n) |. move CARG1, L | lw BASE, L->base | b <1 |. li CRET1, 0 // Force retry. | |->fff_gcstep: // Call GC step function. | // BASE = new base, RC = nargs*8 | move MULTRES, ra | load_got lj_gc_step | sw BASE, L->base | addu TMP0, BASE, NARGS8:RC | sw PC, SAVE_PC // Redundant (but a defined value). | sw TMP0, L->top | call_intern lj_gc_step // (lua_State *L) |. move CARG1, L | lw BASE, L->base | move ra, MULTRES | lw TMP0, L->top | lw CFUNC:RB, FRAME_FUNC(BASE) | jr ra |. subu NARGS8:RC, TMP0, BASE | |//----------------------------------------------------------------------- |//-- Special dispatch targets ------------------------------------------- |//----------------------------------------------------------------------- | |->vm_record: // Dispatch target for recording phase. |.if JIT | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) | andi AT, TMP3, HOOK_VMEVENT // No recording while in vmevent. | bnez AT, >5 | // Decrement the hookcount for consistency, but always do the call. |. lw TMP2, DISPATCH_GL(hookcount)(DISPATCH) | andi AT, TMP3, HOOK_ACTIVE | bnez AT, >1 |. addiu TMP2, TMP2, -1 | andi AT, TMP3, LUA_MASKLINE|LUA_MASKCOUNT | beqz AT, >1 |. nop | b >1 |. sw TMP2, DISPATCH_GL(hookcount)(DISPATCH) |.endif | |->vm_rethook: // Dispatch target for return hooks. | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) | andi AT, TMP3, HOOK_ACTIVE // Hook already active? | beqz AT, >1 |5: // Re-dispatch to static ins. |. lw AT, GG_DISP2STATIC(TMP0) // Assumes TMP0 holds DISPATCH+OP*4. | jr AT |. nop | |->vm_inshook: // Dispatch target for instr/line hooks. | lbu TMP3, DISPATCH_GL(hookmask)(DISPATCH) | lw TMP2, DISPATCH_GL(hookcount)(DISPATCH) | andi AT, TMP3, HOOK_ACTIVE // Hook already active? | bnez AT, <5 |. andi AT, TMP3, LUA_MASKLINE|LUA_MASKCOUNT | beqz AT, <5 |. addiu TMP2, TMP2, -1 | beqz TMP2, >1 |. sw TMP2, DISPATCH_GL(hookcount)(DISPATCH) | andi AT, TMP3, LUA_MASKLINE | beqz AT, <5 |1: |. load_got lj_dispatch_ins | sw MULTRES, SAVE_MULTRES | move CARG2, PC | sw BASE, L->base | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. | call_intern lj_dispatch_ins // (lua_State *L, const BCIns *pc) |. move CARG1, L |3: | lw BASE, L->base |4: // Re-dispatch to static ins. | lw INS, -4(PC) | decode_OP4a TMP1, INS | decode_OP4b TMP1 | addu TMP0, DISPATCH, TMP1 | decode_RD8a RD, INS | lw AT, GG_DISP2STATIC(TMP0) | decode_RA8a RA, INS | decode_RD8b RD | jr AT | decode_RA8b RA | |->cont_hook: // Continue from hook yield. | addiu PC, PC, 4 | b <4 |. lw MULTRES, -24+LO(RB) // Restore MULTRES for *M ins. | |->vm_hotloop: // Hot loop counter underflow. |.if JIT | lw LFUNC:TMP1, FRAME_FUNC(BASE) | addiu CARG1, DISPATCH, GG_DISP2J | sw PC, SAVE_PC | lw TMP1, LFUNC:TMP1->pc | move CARG2, PC | sw L, DISPATCH_J(L)(DISPATCH) | lbu TMP1, PC2PROTO(framesize)(TMP1) | load_got lj_trace_hot | sw BASE, L->base | sll TMP1, TMP1, 3 | addu TMP1, BASE, TMP1 | call_intern lj_trace_hot // (jit_State *J, const BCIns *pc) |. sw TMP1, L->top | b <3 |. nop |.endif | |->vm_callhook: // Dispatch target for call hooks. |.if JIT | b >1 |.endif |. move CARG2, PC | |->vm_hotcall: // Hot call counter underflow. |.if JIT | ori CARG2, PC, 1 |1: |.endif | load_got lj_dispatch_call | addu TMP0, BASE, RC | sw PC, SAVE_PC | sw BASE, L->base | subu RA, RA, BASE | sw TMP0, L->top | call_intern lj_dispatch_call // (lua_State *L, const BCIns *pc) |. move CARG1, L | // Returns ASMFunction. | lw BASE, L->base | lw TMP0, L->top | sw r0, SAVE_PC // Invalidate for subsequent line hook. | subu NARGS8:RC, TMP0, BASE | addu RA, BASE, RA | lw LFUNC:RB, FRAME_FUNC(BASE) | jr CRET1 |. lw INS, -4(PC) | |//----------------------------------------------------------------------- |//-- Trace exit handler ------------------------------------------------- |//----------------------------------------------------------------------- | |.macro savex_, a, b | sdc1 f..a, 16+a*8(sp) | sw r..a, 16+32*8+a*4(sp) | sw r..b, 16+32*8+b*4(sp) |.endmacro | |->vm_exit_handler: |.if JIT | addiu sp, sp, -(16+32*8+32*4) | savex_ 0, 1 | savex_ 2, 3 | savex_ 4, 5 | savex_ 6, 7 | savex_ 8, 9 | savex_ 10, 11 | savex_ 12, 13 | savex_ 14, 15 | savex_ 16, 17 | savex_ 18, 19 | savex_ 20, 21 | savex_ 22, 23 | savex_ 24, 25 | savex_ 26, 27 | sdc1 f28, 16+28*8(sp) | sw r28, 16+32*8+28*4(sp) | sdc1 f30, 16+30*8(sp) | sw r30, 16+32*8+30*4(sp) | sw r0, 16+32*8+31*4(sp) // Clear RID_TMP. | li_vmstate EXIT | addiu TMP2, sp, 16+32*8+32*4 // Recompute original value of sp. | addiu DISPATCH, JGL, -GG_DISP2G-32768 | lw TMP1, 0(TMP2) // Load exit number. | st_vmstate | sw TMP2, 16+32*8+29*4(sp) // Store sp in RID_SP. | lw L, DISPATCH_GL(jit_L)(DISPATCH) | lw BASE, DISPATCH_GL(jit_base)(DISPATCH) | load_got lj_trace_exit | sw L, DISPATCH_J(L)(DISPATCH) | sw ra, DISPATCH_J(parent)(DISPATCH) // Store trace number. | sw TMP1, DISPATCH_J(exitno)(DISPATCH) // Store exit number. | addiu CARG1, DISPATCH, GG_DISP2J | sw BASE, L->base | call_intern lj_trace_exit // (jit_State *J, ExitState *ex) |. addiu CARG2, sp, 16 | // Returns MULTRES (unscaled) or negated error code. | lw TMP1, L->cframe | li AT, -4 | lw BASE, L->base | and sp, TMP1, AT | lw PC, SAVE_PC // Get SAVE_PC. | b >1 |. sw L, SAVE_L // Set SAVE_L (on-trace resume/yield). |.endif |->vm_exit_interp: |.if JIT | // CRET1 = MULTRES or negated error code, BASE, PC and JGL set. | lw L, SAVE_L | addiu DISPATCH, JGL, -GG_DISP2G-32768 |1: | bltz CRET1, >3 // Check for error from exit. |. lw LFUNC:TMP1, FRAME_FUNC(BASE) | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | sll MULTRES, CRET1, 3 | li TISNIL, LJ_TNIL | sw MULTRES, SAVE_MULTRES | mtc1 TMP3, TOBIT | lw TMP1, LFUNC:TMP1->pc | sw r0, DISPATCH_GL(jit_L)(DISPATCH) | lw KBASE, PC2PROTO(k)(TMP1) | cvt.d.s TOBIT, TOBIT | // Modified copy of ins_next which handles function header dispatch, too. | lw INS, 0(PC) | addiu PC, PC, 4 | // Assumes TISNIL == ~LJ_VMST_INTERP == -1 | sw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) | decode_OP4a TMP1, INS | decode_OP4b TMP1 | sltiu TMP2, TMP1, BC_FUNCF*4 // Function header? | addu TMP0, DISPATCH, TMP1 | decode_RD8a RD, INS | lw AT, 0(TMP0) | decode_RA8a RA, INS | beqz TMP2, >2 |. decode_RA8b RA | jr AT |. decode_RD8b RD |2: | addiu RC, MULTRES, -8 | jr AT |. add RA, RA, BASE | |3: // Rethrow error from the right C frame. | load_got lj_err_throw | negu CARG2, CRET1 | call_intern lj_err_throw // (lua_State *L, int errcode) |. move CARG1, L |.endif | |//----------------------------------------------------------------------- |//-- Math helper functions ---------------------------------------------- |//----------------------------------------------------------------------- | |// Modifies AT, TMP0, FRET1, FRET2, f4. Keeps all others incl. FARG1. |.macro vm_round, func | lui TMP0, 0x4330 // Hiword of 2^52 (double). | mtc1 r0, f4 | mtc1 TMP0, f5 | abs.d FRET2, FARG1 // |x| | mfc1 AT, f13 | c.olt.d 0, FRET2, f4 | add.d FRET1, FRET2, f4 // (|x| + 2^52) - 2^52 | bc1f 0, >1 // Truncate only if |x| < 2^52. |. sub.d FRET1, FRET1, f4 | slt AT, AT, r0 |.if "func" == "ceil" | lui TMP0, 0xbff0 // Hiword of -1 (double). Preserves -0. |.else | lui TMP0, 0x3ff0 // Hiword of +1 (double). |.endif |.if "func" == "trunc" | mtc1 TMP0, f5 | c.olt.d 0, FRET2, FRET1 // |x| < result? | sub.d FRET2, FRET1, f4 | movt.d FRET1, FRET2, 0 // If yes, subtract +1. | neg.d FRET2, FRET1 | jr ra |. movn.d FRET1, FRET2, AT // Merge sign bit back in. |.else | neg.d FRET2, FRET1 | mtc1 TMP0, f5 | movn.d FRET1, FRET2, AT // Merge sign bit back in. |.if "func" == "ceil" | c.olt.d 0, FRET1, FARG1 // x > result? |.else | c.olt.d 0, FARG1, FRET1 // x < result? |.endif | sub.d FRET2, FRET1, f4 // If yes, subtract +-1. | jr ra |. movt.d FRET1, FRET2, 0 |.endif |1: | jr ra |. mov.d FRET1, FARG1 |.endmacro | |->vm_floor: | vm_round floor |->vm_ceil: | vm_round ceil |->vm_trunc: |.if JIT | vm_round trunc |.endif | |//----------------------------------------------------------------------- |//-- Miscellaneous functions -------------------------------------------- |//----------------------------------------------------------------------- | |//----------------------------------------------------------------------- |//-- FFI helper functions ----------------------------------------------- |//----------------------------------------------------------------------- | |// Handler for callback functions. Callback slot number in r1, g in r2. |->vm_ffi_callback: |.if FFI |.type CTSTATE, CTState, PC | saveregs | lw CTSTATE, GL:r2->ctype_state | addiu DISPATCH, r2, GG_G2DISP | load_got lj_ccallback_enter | sw r1, CTSTATE->cb.slot | sw CARG1, CTSTATE->cb.gpr[0] | sw CARG2, CTSTATE->cb.gpr[1] | sdc1 FARG1, CTSTATE->cb.fpr[0] | sw CARG3, CTSTATE->cb.gpr[2] | sw CARG4, CTSTATE->cb.gpr[3] | sdc1 FARG2, CTSTATE->cb.fpr[1] | addiu TMP0, sp, CFRAME_SPACE+16 | sw TMP0, CTSTATE->cb.stack | sw r0, SAVE_PC // Any value outside of bytecode is ok. | move CARG2, sp | call_intern lj_ccallback_enter // (CTState *cts, void *cf) |. move CARG1, CTSTATE | // Returns lua_State *. | lw BASE, L:CRET1->base | lw RC, L:CRET1->top | move L, CRET1 | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | lw LFUNC:RB, FRAME_FUNC(BASE) | mtc1 TMP3, TOBIT | li_vmstate INTERP | li TISNIL, LJ_TNIL | subu RC, RC, BASE | st_vmstate | cvt.d.s TOBIT, TOBIT | ins_callt |.endif | |->cont_ffi_callback: // Return from FFI callback. |.if FFI | load_got lj_ccallback_leave | lw CTSTATE, DISPATCH_GL(ctype_state)(DISPATCH) | sw BASE, L->base | sw RB, L->top | sw L, CTSTATE->L | move CARG2, RA | call_intern lj_ccallback_leave // (CTState *cts, TValue *o) |. move CARG1, CTSTATE | lw CRET1, CTSTATE->cb.gpr[0] | ldc1 FRET1, CTSTATE->cb.fpr[0] | lw CRET2, CTSTATE->cb.gpr[1] | b ->vm_leave_unw |. ldc1 FRET2, CTSTATE->cb.fpr[1] |.endif | |->vm_ffi_call: // Call C function via FFI. | // Caveat: needs special frame unwinding, see below. |.if FFI | .type CCSTATE, CCallState, CARG1 | lw TMP1, CCSTATE->spadj | lbu CARG2, CCSTATE->nsp | move TMP2, sp | subu sp, sp, TMP1 | sw ra, -4(TMP2) | sll CARG2, CARG2, 2 | sw r16, -8(TMP2) | sw CCSTATE, -12(TMP2) | move r16, TMP2 | addiu TMP1, CCSTATE, offsetof(CCallState, stack) | addiu TMP2, sp, 16 | beqz CARG2, >2 |. addu TMP3, TMP1, CARG2 |1: | lw TMP0, 0(TMP1) | addiu TMP1, TMP1, 4 | sltu AT, TMP1, TMP3 | sw TMP0, 0(TMP2) | bnez AT, <1 |. addiu TMP2, TMP2, 4 |2: | lw CFUNCADDR, CCSTATE->func | lw CARG2, CCSTATE->gpr[1] | lw CARG3, CCSTATE->gpr[2] | lw CARG4, CCSTATE->gpr[3] | ldc1 FARG1, CCSTATE->fpr[0] | ldc1 FARG2, CCSTATE->fpr[1] | jalr CFUNCADDR |. lw CARG1, CCSTATE->gpr[0] // Do this last, since CCSTATE is CARG1. | lw CCSTATE:TMP1, -12(r16) | lw TMP2, -8(r16) | lw ra, -4(r16) | sw CRET1, CCSTATE:TMP1->gpr[0] | sw CRET2, CCSTATE:TMP1->gpr[1] | sdc1 FRET1, CCSTATE:TMP1->fpr[0] | sdc1 FRET2, CCSTATE:TMP1->fpr[1] | move sp, r16 | jr ra |. move r16, TMP2 |.endif |// Note: vm_ffi_call must be the last function in this object file! | |//----------------------------------------------------------------------- } /* Generate the code for a single instruction. */ static void build_ins(BuildCtx *ctx, BCOp op, int defop) { int vk = 0; |=>defop: switch (op) { /* -- Comparison ops ---------------------------------------------------- */ /* Remember: all ops branch for a true comparison, fall through otherwise. */ case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: | // RA = src1*8, RD = src2*8, JMP with RD = target | addu CARG2, BASE, RA | addu CARG3, BASE, RD | lw TMP0, HI(CARG2) | lw TMP1, HI(CARG3) | ldc1 f0, 0(CARG2) | ldc1 f2, 0(CARG3) | sltiu TMP0, TMP0, LJ_TISNUM | sltiu TMP1, TMP1, LJ_TISNUM | lhu TMP2, OFS_RD(PC) | and TMP0, TMP0, TMP1 | addiu PC, PC, 4 | beqz TMP0, ->vmeta_comp |. lui TMP1, (-(BCBIAS_J*4 >> 16) & 65535) | decode_RD4b TMP2 | addu TMP2, TMP2, TMP1 if (op == BC_ISLT || op == BC_ISGE) { | c.olt.d f0, f2 } else { | c.ole.d f0, f2 } if (op == BC_ISLT || op == BC_ISLE) { | movf TMP2, r0 } else { | movt TMP2, r0 } | addu PC, PC, TMP2 |1: | ins_next break; case BC_ISEQV: case BC_ISNEV: vk = op == BC_ISEQV; | // RA = src1*8, RD = src2*8, JMP with RD = target | addu RA, BASE, RA | addiu PC, PC, 4 | lw TMP0, HI(RA) | ldc1 f0, 0(RA) | addu RD, BASE, RD | lhu TMP2, -4+OFS_RD(PC) | lw TMP1, HI(RD) | ldc1 f2, 0(RD) | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) | sltiu AT, TMP0, LJ_TISNUM | sltiu CARG1, TMP1, LJ_TISNUM | decode_RD4b TMP2 | and AT, AT, CARG1 | beqz AT, >5 |. addu TMP2, TMP2, TMP3 | c.eq.d f0, f2 if (vk) { | movf TMP2, r0 } else { | movt TMP2, r0 } |1: | addu PC, PC, TMP2 | ins_next |5: // Either or both types are not numbers. | lw CARG2, LO(RA) | lw CARG3, LO(RD) |.if FFI | li TMP3, LJ_TCDATA | beq TMP0, TMP3, ->vmeta_equal_cd |.endif |. sltiu AT, TMP0, LJ_TISPRI // Not a primitive? |.if FFI | beq TMP1, TMP3, ->vmeta_equal_cd |.endif |. xor TMP3, CARG2, CARG3 // Same tv? | xor TMP1, TMP1, TMP0 // Same type? | sltiu CARG1, TMP0, LJ_TISTABUD+1 // Table or userdata? | movz TMP3, r0, AT // Ignore tv if primitive. | movn CARG1, r0, TMP1 // Tab/ud and same type? | or AT, TMP1, TMP3 // Same type && (pri||same tv). | movz CARG1, r0, AT | beqz CARG1, <1 // Done if not tab/ud or not same type or same tv. if (vk) { |. movn TMP2, r0, AT } else { |. movz TMP2, r0, AT } | // Different tables or userdatas. Need to check __eq metamethod. | // Field metatable must be at same offset for GCtab and GCudata! | lw TAB:TMP1, TAB:CARG2->metatable | beqz TAB:TMP1, <1 // No metatable? |. nop | lbu TMP1, TAB:TMP1->nomm | andi TMP1, TMP1, 1<vmeta_equal // Handle __eq metamethod. |. li CARG4, 1-vk // ne = 0 or 1. break; case BC_ISEQS: case BC_ISNES: vk = op == BC_ISEQS; | // RA = src*8, RD = str_const*8 (~), JMP with RD = target | addu RA, BASE, RA | addiu PC, PC, 4 | lw TMP0, HI(RA) | srl RD, RD, 1 | lw STR:TMP3, LO(RA) | subu RD, KBASE, RD | lhu TMP2, -4+OFS_RD(PC) |.if FFI | li AT, LJ_TCDATA | beq TMP0, AT, ->vmeta_equal_cd |.endif |. lw STR:TMP1, -4(RD) // KBASE-4-str_const*4 | addiu TMP0, TMP0, -LJ_TSTR | decode_RD4b TMP2 | xor TMP1, STR:TMP1, STR:TMP3 | or TMP0, TMP0, TMP1 | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) | addu TMP2, TMP2, TMP3 if (vk) { | movn TMP2, r0, TMP0 } else { | movz TMP2, r0, TMP0 } | addu PC, PC, TMP2 | ins_next break; case BC_ISEQN: case BC_ISNEN: vk = op == BC_ISEQN; | // RA = src*8, RD = num_const*8, JMP with RD = target | addu RA, BASE, RA | addiu PC, PC, 4 | lw TMP0, HI(RA) | ldc1 f0, 0(RA) | addu RD, KBASE, RD | lhu TMP2, -4+OFS_RD(PC) | ldc1 f2, 0(RD) | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) | sltiu AT, TMP0, LJ_TISNUM | decode_RD4b TMP2 |.if FFI | beqz AT, >5 |.else | beqz AT, >1 |.endif |. addu TMP2, TMP2, TMP3 | c.eq.d f0, f2 if (vk) { | movf TMP2, r0 | addu PC, PC, TMP2 |1: } else { | movt TMP2, r0 |1: | addu PC, PC, TMP2 } | ins_next |.if FFI |5: | li AT, LJ_TCDATA | beq TMP0, AT, ->vmeta_equal_cd |. nop | b <1 |. nop |.endif break; case BC_ISEQP: case BC_ISNEP: vk = op == BC_ISEQP; | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target | addu RA, BASE, RA | srl TMP1, RD, 3 | lw TMP0, HI(RA) | lhu TMP2, OFS_RD(PC) | not TMP1, TMP1 | addiu PC, PC, 4 |.if FFI | li AT, LJ_TCDATA | beq TMP0, AT, ->vmeta_equal_cd |.endif |. xor TMP0, TMP0, TMP1 | decode_RD4b TMP2 | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) | addu TMP2, TMP2, TMP3 if (vk) { | movn TMP2, r0, TMP0 } else { | movz TMP2, r0, TMP0 } | addu PC, PC, TMP2 | ins_next break; /* -- Unary test and copy ops ------------------------------------------- */ case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: | // RA = dst*8 or unused, RD = src*8, JMP with RD = target | addu RD, BASE, RD | lhu TMP2, OFS_RD(PC) | lw TMP0, HI(RD) | addiu PC, PC, 4 if (op == BC_IST || op == BC_ISF) { | sltiu TMP0, TMP0, LJ_TISTRUECOND | decode_RD4b TMP2 | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) | addu TMP2, TMP2, TMP3 if (op == BC_IST) { | movz TMP2, r0, TMP0 } else { | movn TMP2, r0, TMP0 } | addu PC, PC, TMP2 } else { | sltiu TMP0, TMP0, LJ_TISTRUECOND | ldc1 f0, 0(RD) if (op == BC_ISTC) { | beqz TMP0, >1 } else { | bnez TMP0, >1 } |. addu RA, BASE, RA | decode_RD4b TMP2 | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) | addu TMP2, TMP2, TMP3 | sdc1 f0, 0(RA) | addu PC, PC, TMP2 |1: } | ins_next break; /* -- Unary ops --------------------------------------------------------- */ case BC_MOV: | // RA = dst*8, RD = src*8 | addu RD, BASE, RD | addu RA, BASE, RA | ldc1 f0, 0(RD) | ins_next1 | sdc1 f0, 0(RA) | ins_next2 break; case BC_NOT: | // RA = dst*8, RD = src*8 | addu RD, BASE, RD | addu RA, BASE, RA | lw TMP0, HI(RD) | li TMP1, LJ_TFALSE | sltiu TMP0, TMP0, LJ_TISTRUECOND | addiu TMP1, TMP0, LJ_TTRUE | ins_next1 | sw TMP1, HI(RA) | ins_next2 break; case BC_UNM: | // RA = dst*8, RD = src*8 | addu CARG3, BASE, RD | addu RA, BASE, RA | lw TMP0, HI(CARG3) | ldc1 f0, 0(CARG3) | sltiu AT, TMP0, LJ_TISNUM | beqz AT, ->vmeta_unm |. neg.d f0, f0 | ins_next1 | sdc1 f0, 0(RA) | ins_next2 break; case BC_LEN: | // RA = dst*8, RD = src*8 | addu CARG2, BASE, RD | addu RA, BASE, RA | lw TMP0, HI(CARG2) | lw CARG1, LO(CARG2) | li AT, LJ_TSTR | bne TMP0, AT, >2 |. li AT, LJ_TTAB | lw CRET1, STR:CARG1->len |1: | mtc1 CRET1, f0 | cvt.d.w f0, f0 | ins_next1 | sdc1 f0, 0(RA) | ins_next2 |2: | bne TMP0, AT, ->vmeta_len |. nop #if LJ_52 | lw TAB:TMP2, TAB:CARG1->metatable | bnez TAB:TMP2, >9 |. nop |3: #endif |->BC_LEN_Z: | load_got lj_tab_len | call_intern lj_tab_len // (GCtab *t) |. nop | // Returns uint32_t (but less than 2^31). | b <1 |. nop #if LJ_52 |9: | lbu TMP0, TAB:TMP2->nomm | andi TMP0, TMP0, 1<vmeta_len |. nop #endif break; /* -- Binary ops -------------------------------------------------------- */ |.macro ins_arithpre ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); | decode_RB8a RB, INS | decode_RB8b RB | decode_RDtoRC8 RC, RD | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 ||switch (vk) { ||case 0: | addu CARG3, BASE, RB | addu CARG4, KBASE, RC | lw TMP1, HI(CARG3) | ldc1 f20, 0(CARG3) | ldc1 f22, 0(CARG4) | sltiu AT, TMP1, LJ_TISNUM || break; ||case 1: | addu CARG4, BASE, RB | addu CARG3, KBASE, RC | lw TMP1, HI(CARG4) | ldc1 f22, 0(CARG4) | ldc1 f20, 0(CARG3) | sltiu AT, TMP1, LJ_TISNUM || break; ||default: | addu CARG3, BASE, RB | addu CARG4, BASE, RC | lw TMP1, HI(CARG3) | lw TMP2, HI(CARG4) | ldc1 f20, 0(CARG3) | ldc1 f22, 0(CARG4) | sltiu AT, TMP1, LJ_TISNUM | sltiu TMP0, TMP2, LJ_TISNUM | and AT, AT, TMP0 || break; ||} | beqz AT, ->vmeta_arith |. addu RA, BASE, RA |.endmacro | |.macro fpmod, a, b, c |->BC_MODVN_Z: | bal ->vm_floor // floor(b/c) |. div.d FARG1, b, c | mul.d a, FRET1, c | sub.d a, b, a // b - floor(b/c)*c |.endmacro | |.macro ins_arith, ins | ins_arithpre |.if "ins" == "fpmod_" | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. |. nop |.else | ins f0, f20, f22 | ins_next1 | sdc1 f0, 0(RA) | ins_next2 |.endif |.endmacro case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: | ins_arith add.d break; case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: | ins_arith sub.d break; case BC_MULVN: case BC_MULNV: case BC_MULVV: | ins_arith mul.d break; case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: | ins_arith div.d break; case BC_MODVN: | ins_arith fpmod break; case BC_MODNV: case BC_MODVV: | ins_arith fpmod_ break; case BC_POW: | decode_RB8a RB, INS | decode_RB8b RB | decode_RDtoRC8 RC, RD | addu CARG3, BASE, RB | addu CARG4, BASE, RC | lw TMP1, HI(CARG3) | lw TMP2, HI(CARG4) | ldc1 FARG1, 0(CARG3) | ldc1 FARG2, 0(CARG4) | sltiu AT, TMP1, LJ_TISNUM | sltiu TMP0, TMP2, LJ_TISNUM | and AT, AT, TMP0 | load_got pow | beqz AT, ->vmeta_arith |. addu RA, BASE, RA | call_extern |. nop | ins_next1 | sdc1 FRET1, 0(RA) | ins_next2 break; case BC_CAT: | // RA = dst*8, RB = src_start*8, RC = src_end*8 | decode_RB8a RB, INS | decode_RB8b RB | decode_RDtoRC8 RC, RD | subu CARG3, RC, RB | sw BASE, L->base | addu CARG2, BASE, RC | move MULTRES, RB |->BC_CAT_Z: | load_got lj_meta_cat | srl CARG3, CARG3, 3 | sw PC, SAVE_PC | call_intern lj_meta_cat // (lua_State *L, TValue *top, int left) |. move CARG1, L | // Returns NULL (finished) or TValue * (metamethod). | bnez CRET1, ->vmeta_binop |. lw BASE, L->base | addu RB, BASE, MULTRES | ldc1 f0, 0(RB) | addu RA, BASE, RA | ins_next1 | sdc1 f0, 0(RA) // Copy result from RB to RA. | ins_next2 break; /* -- Constant ops ------------------------------------------------------ */ case BC_KSTR: | // RA = dst*8, RD = str_const*8 (~) | srl TMP1, RD, 1 | subu TMP1, KBASE, TMP1 | ins_next1 | lw TMP0, -4(TMP1) // KBASE-4-str_const*4 | addu RA, BASE, RA | li TMP2, LJ_TSTR | sw TMP0, LO(RA) | sw TMP2, HI(RA) | ins_next2 break; case BC_KCDATA: |.if FFI | // RA = dst*8, RD = cdata_const*8 (~) | srl TMP1, RD, 1 | subu TMP1, KBASE, TMP1 | ins_next1 | lw TMP0, -4(TMP1) // KBASE-4-cdata_const*4 | addu RA, BASE, RA | li TMP2, LJ_TCDATA | sw TMP0, LO(RA) | sw TMP2, HI(RA) | ins_next2 |.endif break; case BC_KSHORT: | // RA = dst*8, RD = int16_literal*8 | sra RD, INS, 16 | mtc1 RD, f0 | addu RA, BASE, RA | cvt.d.w f0, f0 | ins_next1 | sdc1 f0, 0(RA) | ins_next2 break; case BC_KNUM: | // RA = dst*8, RD = num_const*8 | addu RD, KBASE, RD | addu RA, BASE, RA | ldc1 f0, 0(RD) | ins_next1 | sdc1 f0, 0(RA) | ins_next2 break; case BC_KPRI: | // RA = dst*8, RD = primitive_type*8 (~) | srl TMP1, RD, 3 | addu RA, BASE, RA | not TMP0, TMP1 | ins_next1 | sw TMP0, HI(RA) | ins_next2 break; case BC_KNIL: | // RA = base*8, RD = end*8 | addu RA, BASE, RA | sw TISNIL, HI(RA) | addiu RA, RA, 8 | addu RD, BASE, RD |1: | sw TISNIL, HI(RA) | slt AT, RA, RD | bnez AT, <1 |. addiu RA, RA, 8 | ins_next_ break; /* -- Upvalue and function ops ------------------------------------------ */ case BC_UGET: | // RA = dst*8, RD = uvnum*8 | lw LFUNC:RB, FRAME_FUNC(BASE) | srl RD, RD, 1 | addu RD, RD, LFUNC:RB | lw UPVAL:RB, LFUNC:RD->uvptr | ins_next1 | lw TMP1, UPVAL:RB->v | ldc1 f0, 0(TMP1) | addu RA, BASE, RA | sdc1 f0, 0(RA) | ins_next2 break; case BC_USETV: | // RA = uvnum*8, RD = src*8 | lw LFUNC:RB, FRAME_FUNC(BASE) | srl RA, RA, 1 | addu RD, BASE, RD | addu RA, RA, LFUNC:RB | ldc1 f0, 0(RD) | lw UPVAL:RB, LFUNC:RA->uvptr | lbu TMP3, UPVAL:RB->marked | lw CARG2, UPVAL:RB->v | andi TMP3, TMP3, LJ_GC_BLACK // isblack(uv) | lbu TMP0, UPVAL:RB->closed | lw TMP2, HI(RD) | sdc1 f0, 0(CARG2) | li AT, LJ_GC_BLACK|1 | or TMP3, TMP3, TMP0 | beq TMP3, AT, >2 // Upvalue is closed and black? |. addiu TMP2, TMP2, -(LJ_TISNUM+1) |1: | ins_next | |2: // Check if new value is collectable. | sltiu AT, TMP2, LJ_TISGCV - (LJ_TISNUM+1) | beqz AT, <1 // tvisgcv(v) |. lw TMP1, LO(RD) | lbu TMP3, GCOBJ:TMP1->gch.marked | andi TMP3, TMP3, LJ_GC_WHITES // iswhite(v) | beqz TMP3, <1 |. load_got lj_gc_barrieruv | // Crossed a write barrier. Move the barrier forward. | call_intern lj_gc_barrieruv // (global_State *g, TValue *tv) |. addiu CARG1, DISPATCH, GG_DISP2G | b <1 |. nop break; case BC_USETS: | // RA = uvnum*8, RD = str_const*8 (~) | lw LFUNC:RB, FRAME_FUNC(BASE) | srl RA, RA, 1 | srl TMP1, RD, 1 | addu RA, RA, LFUNC:RB | subu TMP1, KBASE, TMP1 | lw UPVAL:RB, LFUNC:RA->uvptr | lw STR:TMP1, -4(TMP1) // KBASE-4-str_const*4 | lbu TMP2, UPVAL:RB->marked | lw CARG2, UPVAL:RB->v | lbu TMP3, STR:TMP1->marked | andi AT, TMP2, LJ_GC_BLACK // isblack(uv) | lbu TMP2, UPVAL:RB->closed | li TMP0, LJ_TSTR | sw STR:TMP1, LO(CARG2) | bnez AT, >2 |. sw TMP0, HI(CARG2) |1: | ins_next | |2: // Check if string is white and ensure upvalue is closed. | beqz TMP2, <1 |. andi AT, TMP3, LJ_GC_WHITES // iswhite(str) | beqz AT, <1 |. load_got lj_gc_barrieruv | // Crossed a write barrier. Move the barrier forward. | call_intern lj_gc_barrieruv // (global_State *g, TValue *tv) |. addiu CARG1, DISPATCH, GG_DISP2G | b <1 |. nop break; case BC_USETN: | // RA = uvnum*8, RD = num_const*8 | lw LFUNC:RB, FRAME_FUNC(BASE) | srl RA, RA, 1 | addu RD, KBASE, RD | addu RA, RA, LFUNC:RB | ldc1 f0, 0(RD) | lw UPVAL:RB, LFUNC:RA->uvptr | ins_next1 | lw TMP1, UPVAL:RB->v | sdc1 f0, 0(TMP1) | ins_next2 break; case BC_USETP: | // RA = uvnum*8, RD = primitive_type*8 (~) | lw LFUNC:RB, FRAME_FUNC(BASE) | srl RA, RA, 1 | srl TMP0, RD, 3 | addu RA, RA, LFUNC:RB | not TMP0, TMP0 | lw UPVAL:RB, LFUNC:RA->uvptr | ins_next1 | lw TMP1, UPVAL:RB->v | sw TMP0, HI(TMP1) | ins_next2 break; case BC_UCLO: | // RA = level*8, RD = target | lw TMP2, L->openupval | branch_RD // Do this first since RD is not saved. | load_got lj_func_closeuv | sw BASE, L->base | beqz TMP2, >1 |. move CARG1, L | call_intern lj_func_closeuv // (lua_State *L, TValue *level) |. addu CARG2, BASE, RA | lw BASE, L->base |1: | ins_next break; case BC_FNEW: | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) | srl TMP1, RD, 1 | load_got lj_func_newL_gc | subu TMP1, KBASE, TMP1 | lw CARG3, FRAME_FUNC(BASE) | lw CARG2, -4(TMP1) // KBASE-4-tab_const*4 | sw BASE, L->base | sw PC, SAVE_PC | // (lua_State *L, GCproto *pt, GCfuncL *parent) | call_intern lj_func_newL_gc |. move CARG1, L | // Returns GCfuncL *. | lw BASE, L->base | li TMP0, LJ_TFUNC | ins_next1 | addu RA, BASE, RA | sw TMP0, HI(RA) | sw LFUNC:CRET1, LO(RA) | ins_next2 break; /* -- Table ops --------------------------------------------------------- */ case BC_TNEW: case BC_TDUP: | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) | lw TMP0, DISPATCH_GL(gc.total)(DISPATCH) | lw TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) | sw BASE, L->base | sw PC, SAVE_PC | sltu AT, TMP0, TMP1 | beqz AT, >5 |1: if (op == BC_TNEW) { | load_got lj_tab_new | srl CARG2, RD, 3 | andi CARG2, CARG2, 0x7ff | li TMP0, 0x801 | addiu AT, CARG2, -0x7ff | srl CARG3, RD, 14 | movz CARG2, TMP0, AT | // (lua_State *L, int32_t asize, uint32_t hbits) | call_intern lj_tab_new |. move CARG1, L | // Returns Table *. } else { | load_got lj_tab_dup | srl TMP1, RD, 1 | subu TMP1, KBASE, TMP1 | move CARG1, L | call_intern lj_tab_dup // (lua_State *L, Table *kt) |. lw CARG2, -4(TMP1) // KBASE-4-str_const*4 | // Returns Table *. } | lw BASE, L->base | ins_next1 | addu RA, BASE, RA | li TMP0, LJ_TTAB | sw TAB:CRET1, LO(RA) | sw TMP0, HI(RA) | ins_next2 |5: | load_got lj_gc_step_fixtop | move MULTRES, RD | call_intern lj_gc_step_fixtop // (lua_State *L) |. move CARG1, L | b <1 |. move RD, MULTRES break; case BC_GGET: | // RA = dst*8, RD = str_const*8 (~) case BC_GSET: | // RA = src*8, RD = str_const*8 (~) | lw LFUNC:TMP2, FRAME_FUNC(BASE) | srl TMP1, RD, 1 | subu TMP1, KBASE, TMP1 | lw TAB:RB, LFUNC:TMP2->env | lw STR:RC, -4(TMP1) // KBASE-4-str_const*4 if (op == BC_GGET) { | b ->BC_TGETS_Z } else { | b ->BC_TSETS_Z } |. addu RA, BASE, RA break; case BC_TGETV: | // RA = dst*8, RB = table*8, RC = key*8 | decode_RB8a RB, INS | decode_RB8b RB | decode_RDtoRC8 RC, RD | addu CARG2, BASE, RB | addu CARG3, BASE, RC | lw TMP1, HI(CARG2) | lw TMP2, HI(CARG3) | lw TAB:RB, LO(CARG2) | li AT, LJ_TTAB | ldc1 f0, 0(CARG3) | bne TMP1, AT, ->vmeta_tgetv |. addu RA, BASE, RA | sltiu AT, TMP2, LJ_TISNUM | beqz AT, >5 |. li AT, LJ_TSTR | | // Convert number key to integer, check for integerness and range. | cvt.w.d f2, f0 | lw TMP0, TAB:RB->asize | mfc1 TMP2, f2 | cvt.d.w f4, f2 | lw TMP1, TAB:RB->array | c.eq.d f0, f4 | sltu AT, TMP2, TMP0 | movf AT, r0 | sll TMP2, TMP2, 3 | beqz AT, ->vmeta_tgetv // Integer key and in array part? |. addu TMP2, TMP1, TMP2 | lw TMP0, HI(TMP2) | beq TMP0, TISNIL, >2 |. ldc1 f0, 0(TMP2) |1: | ins_next1 | sdc1 f0, 0(RA) | ins_next2 | |2: // Check for __index if table value is nil. | lw TAB:TMP2, TAB:RB->metatable | beqz TAB:TMP2, <1 // No metatable: done. |. nop | lbu TMP0, TAB:TMP2->nomm | andi TMP0, TMP0, 1<vmeta_tgetv |. nop | |5: | bne TMP2, AT, ->vmeta_tgetv |. lw STR:RC, LO(CARG3) | b ->BC_TGETS_Z // String key? |. nop break; case BC_TGETS: | // RA = dst*8, RB = table*8, RC = str_const*4 (~) | decode_RB8a RB, INS | decode_RB8b RB | addu CARG2, BASE, RB | decode_RC4a RC, INS | lw TMP0, HI(CARG2) | decode_RC4b RC | li AT, LJ_TTAB | lw TAB:RB, LO(CARG2) | subu CARG3, KBASE, RC | lw STR:RC, -4(CARG3) // KBASE-4-str_const*4 | bne TMP0, AT, ->vmeta_tgets1 |. addu RA, BASE, RA |->BC_TGETS_Z: | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 | lw TMP0, TAB:RB->hmask | lw TMP1, STR:RC->hash | lw NODE:TMP2, TAB:RB->node | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | sll TMP0, TMP1, 5 | sll TMP1, TMP1, 3 | subu TMP1, TMP0, TMP1 | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) |1: | lw CARG1, offsetof(Node, key)+HI(NODE:TMP2) | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) | lw NODE:TMP1, NODE:TMP2->next | lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) | addiu CARG1, CARG1, -LJ_TSTR | xor TMP0, TMP0, STR:RC | or AT, CARG1, TMP0 | bnez AT, >4 |. lw TAB:TMP3, TAB:RB->metatable | beq CARG2, TISNIL, >5 // Key found, but nil value? |. lw CARG1, offsetof(Node, val)+LO(NODE:TMP2) |3: | ins_next1 | sw CARG2, HI(RA) | sw CARG1, LO(RA) | ins_next2 | |4: // Follow hash chain. | bnez NODE:TMP1, <1 |. move NODE:TMP2, NODE:TMP1 | // End of hash chain: key not found, nil result. | |5: // Check for __index if table value is nil. | beqz TAB:TMP3, <3 // No metatable: done. |. li CARG2, LJ_TNIL | lbu TMP0, TAB:TMP3->nomm | andi TMP0, TMP0, 1<vmeta_tgets |. nop break; case BC_TGETB: | // RA = dst*8, RB = table*8, RC = index*8 | decode_RB8a RB, INS | decode_RB8b RB | addu CARG2, BASE, RB | decode_RDtoRC8 RC, RD | lw CARG1, HI(CARG2) | li AT, LJ_TTAB | lw TAB:RB, LO(CARG2) | addu RA, BASE, RA | bne CARG1, AT, ->vmeta_tgetb |. srl TMP0, RC, 3 | lw TMP1, TAB:RB->asize | lw TMP2, TAB:RB->array | sltu AT, TMP0, TMP1 | beqz AT, ->vmeta_tgetb |. addu RC, TMP2, RC | lw TMP1, HI(RC) | beq TMP1, TISNIL, >5 |. ldc1 f0, 0(RC) |1: | ins_next1 | sdc1 f0, 0(RA) | ins_next2 | |5: // Check for __index if table value is nil. | lw TAB:TMP2, TAB:RB->metatable | beqz TAB:TMP2, <1 // No metatable: done. |. nop | lbu TMP1, TAB:TMP2->nomm | andi TMP1, TMP1, 1<vmeta_tgetb // Caveat: preserve TMP0! |. nop break; case BC_TSETV: | // RA = src*8, RB = table*8, RC = key*8 | decode_RB8a RB, INS | decode_RB8b RB | decode_RDtoRC8 RC, RD | addu CARG2, BASE, RB | addu CARG3, BASE, RC | lw TMP1, HI(CARG2) | lw TMP2, HI(CARG3) | lw TAB:RB, LO(CARG2) | li AT, LJ_TTAB | ldc1 f0, 0(CARG3) | bne TMP1, AT, ->vmeta_tsetv |. addu RA, BASE, RA | sltiu AT, TMP2, LJ_TISNUM | beqz AT, >5 |. li AT, LJ_TSTR | | // Convert number key to integer, check for integerness and range. | cvt.w.d f2, f0 | lw TMP0, TAB:RB->asize | mfc1 TMP2, f2 | cvt.d.w f4, f2 | lw TMP1, TAB:RB->array | c.eq.d f0, f4 | sltu AT, TMP2, TMP0 | movf AT, r0 | sll TMP2, TMP2, 3 | beqz AT, ->vmeta_tsetv // Integer key and in array part? |. addu TMP1, TMP1, TMP2 | lbu TMP3, TAB:RB->marked | lw TMP0, HI(TMP1) | beq TMP0, TISNIL, >3 |. ldc1 f0, 0(RA) |1: | andi AT, TMP3, LJ_GC_BLACK // isblack(table) | bnez AT, >7 |. sdc1 f0, 0(TMP1) |2: | ins_next | |3: // Check for __newindex if previous value is nil. | lw TAB:TMP2, TAB:RB->metatable | beqz TAB:TMP2, <1 // No metatable: done. |. nop | lbu TMP2, TAB:TMP2->nomm | andi TMP2, TMP2, 1<vmeta_tsetv |. nop | |5: | bne TMP2, AT, ->vmeta_tsetv |. lw STR:RC, LO(CARG3) | b ->BC_TSETS_Z // String key? |. nop | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0, <2 break; case BC_TSETS: | // RA = src*8, RB = table*8, RC = str_const*8 (~) | decode_RB8a RB, INS | decode_RB8b RB | addu CARG2, BASE, RB | decode_RC4a RC, INS | lw TMP0, HI(CARG2) | decode_RC4b RC | li AT, LJ_TTAB | subu CARG3, KBASE, RC | lw TAB:RB, LO(CARG2) | lw STR:RC, -4(CARG3) // KBASE-4-str_const*4 | bne TMP0, AT, ->vmeta_tsets1 |. addu RA, BASE, RA |->BC_TSETS_Z: | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = BASE+src*8 | lw TMP0, TAB:RB->hmask | lw TMP1, STR:RC->hash | lw NODE:TMP2, TAB:RB->node | sb r0, TAB:RB->nomm // Clear metamethod cache. | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | sll TMP0, TMP1, 5 | sll TMP1, TMP1, 3 | subu TMP1, TMP0, TMP1 | addu NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) | ldc1 f20, 0(RA) |1: | lw CARG1, offsetof(Node, key)+HI(NODE:TMP2) | lw TMP0, offsetof(Node, key)+LO(NODE:TMP2) | li AT, LJ_TSTR | lw NODE:TMP1, NODE:TMP2->next | bne CARG1, AT, >5 |. lw CARG2, offsetof(Node, val)+HI(NODE:TMP2) | bne TMP0, STR:RC, >5 |. lbu TMP3, TAB:RB->marked | beq CARG2, TISNIL, >4 // Key found, but nil value? |. lw TAB:TMP0, TAB:RB->metatable |2: | andi AT, TMP3, LJ_GC_BLACK // isblack(table) | bnez AT, >7 |. sdc1 f20, NODE:TMP2->val |3: | ins_next | |4: // Check for __newindex if previous value is nil. | beqz TAB:TMP0, <2 // No metatable: done. |. nop | lbu TMP0, TAB:TMP0->nomm | andi TMP0, TMP0, 1<vmeta_tsets |. nop | |5: // Follow hash chain. | bnez NODE:TMP1, <1 |. move NODE:TMP2, NODE:TMP1 | // End of hash chain: key not found, add a new one | | // But check for __newindex first. | lw TAB:TMP2, TAB:RB->metatable | beqz TAB:TMP2, >6 // No metatable: continue. |. addiu CARG3, DISPATCH, DISPATCH_GL(tmptv) | lbu TMP0, TAB:TMP2->nomm | andi TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. |. li AT, LJ_TSTR |6: | load_got lj_tab_newkey | sw STR:RC, LO(CARG3) | sw AT, HI(CARG3) | sw BASE, L->base | move CARG2, TAB:RB | sw PC, SAVE_PC | call_intern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k |. move CARG1, L | // Returns TValue *. | lw BASE, L->base | b <3 // No 2nd write barrier needed. |. sdc1 f20, 0(CRET1) | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0, <3 break; case BC_TSETB: | // RA = src*8, RB = table*8, RC = index*8 | decode_RB8a RB, INS | decode_RB8b RB | addu CARG2, BASE, RB | decode_RDtoRC8 RC, RD | lw CARG1, HI(CARG2) | li AT, LJ_TTAB | lw TAB:RB, LO(CARG2) | addu RA, BASE, RA | bne CARG1, AT, ->vmeta_tsetb |. srl TMP0, RC, 3 | lw TMP1, TAB:RB->asize | lw TMP2, TAB:RB->array | sltu AT, TMP0, TMP1 | beqz AT, ->vmeta_tsetb |. addu RC, TMP2, RC | lw TMP1, HI(RC) | lbu TMP3, TAB:RB->marked | beq TMP1, TISNIL, >5 |. ldc1 f0, 0(RA) |1: | andi AT, TMP3, LJ_GC_BLACK // isblack(table) | bnez AT, >7 |. sdc1 f0, 0(RC) |2: | ins_next | |5: // Check for __newindex if previous value is nil. | lw TAB:TMP2, TAB:RB->metatable | beqz TAB:TMP2, <1 // No metatable: done. |. nop | lbu TMP1, TAB:TMP2->nomm | andi TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! |. nop | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0, <2 break; case BC_TSETM: | // RA = base*8 (table at base-1), RD = num_const*8 (start index) | addu RA, BASE, RA |1: | addu TMP3, KBASE, RD | lw TAB:CARG2, -8+LO(RA) // Guaranteed to be a table. | addiu TMP0, MULTRES, -8 | lw TMP3, LO(TMP3) // Integer constant is in lo-word. | beqz TMP0, >4 // Nothing to copy? |. srl CARG3, TMP0, 3 | addu CARG3, CARG3, TMP3 | lw TMP2, TAB:CARG2->asize | sll TMP1, TMP3, 3 | lbu TMP3, TAB:CARG2->marked | lw CARG1, TAB:CARG2->array | sltu AT, TMP2, CARG3 | bnez AT, >5 |. addu TMP2, RA, TMP0 | addu TMP1, TMP1, CARG1 | andi TMP0, TMP3, LJ_GC_BLACK // isblack(table) |3: // Copy result slots to table. | ldc1 f0, 0(RA) | addiu RA, RA, 8 | sltu AT, RA, TMP2 | sdc1 f0, 0(TMP1) | bnez AT, <3 |. addiu TMP1, TMP1, 8 | bnez TMP0, >7 |. nop |4: | ins_next | |5: // Need to resize array part. | load_got lj_tab_reasize | sw BASE, L->base | sw PC, SAVE_PC | move BASE, RD | call_intern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) |. move CARG1, L | // Must not reallocate the stack. | move RD, BASE | b <1 |. lw BASE, L->base // Reload BASE for lack of a saved register. | |7: // Possible table write barrier for any value. Skip valiswhite check. | barrierback TAB:CARG2, TMP3, TMP0, <4 break; /* -- Calls and vararg handling ----------------------------------------- */ case BC_CALLM: | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 | decode_RDtoRC8 NARGS8:RC, RD | b ->BC_CALL_Z |. addu NARGS8:RC, NARGS8:RC, MULTRES break; case BC_CALL: | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 | decode_RDtoRC8 NARGS8:RC, RD |->BC_CALL_Z: | move TMP2, BASE | addu BASE, BASE, RA | li AT, LJ_TFUNC | lw TMP0, HI(BASE) | lw LFUNC:RB, LO(BASE) | addiu BASE, BASE, 8 | bne TMP0, AT, ->vmeta_call |. addiu NARGS8:RC, NARGS8:RC, -8 | ins_call break; case BC_CALLMT: | // RA = base*8, (RB = 0,) RC = extra_nargs*8 | addu NARGS8:RD, NARGS8:RD, MULTRES // BC_CALLT gets RC from RD. | // Fall through. Assumes BC_CALLT follows. break; case BC_CALLT: | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 | addu RA, BASE, RA | li AT, LJ_TFUNC | lw TMP0, HI(RA) | lw LFUNC:RB, LO(RA) | move NARGS8:RC, RD | lw TMP1, FRAME_PC(BASE) | addiu RA, RA, 8 | bne TMP0, AT, ->vmeta_callt |. addiu NARGS8:RC, NARGS8:RC, -8 |->BC_CALLT_Z: | andi TMP0, TMP1, FRAME_TYPE // Caveat: preserve TMP0 until the 'or'. | lbu TMP3, LFUNC:RB->ffid | bnez TMP0, >7 |. xori TMP2, TMP1, FRAME_VARG |1: | sw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. | sltiu AT, TMP3, 2 // (> FF_C) Calling a fast function? | move TMP2, BASE | beqz NARGS8:RC, >3 |. move TMP3, NARGS8:RC |2: | ldc1 f0, 0(RA) | addiu RA, RA, 8 | addiu TMP3, TMP3, -8 | sdc1 f0, 0(TMP2) | bnez TMP3, <2 |. addiu TMP2, TMP2, 8 |3: | or TMP0, TMP0, AT | beqz TMP0, >5 |. nop |4: | ins_callt | |5: // Tailcall to a fast function with a Lua frame below. | lw INS, -4(TMP1) | decode_RA8a RA, INS | decode_RA8b RA | subu TMP1, BASE, RA | lw LFUNC:TMP1, -8+FRAME_FUNC(TMP1) | lw TMP1, LFUNC:TMP1->pc | b <4 |. lw KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. | |7: // Tailcall from a vararg function. | andi AT, TMP2, FRAME_TYPEP | bnez AT, <1 // Vararg frame below? |. subu TMP2, BASE, TMP2 // Relocate BASE down. | move BASE, TMP2 | lw TMP1, FRAME_PC(TMP2) | b <1 |. andi TMP0, TMP1, FRAME_TYPE break; case BC_ITERC: | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) | move TMP2, BASE | addu BASE, BASE, RA | li AT, LJ_TFUNC | lw TMP1, -24+HI(BASE) | lw LFUNC:RB, -24+LO(BASE) | ldc1 f2, -8(BASE) | ldc1 f0, -16(BASE) | sw TMP1, HI(BASE) // Copy callable. | sw LFUNC:RB, LO(BASE) | sdc1 f2, 16(BASE) // Copy control var. | sdc1 f0, 8(BASE) // Copy state. | addiu BASE, BASE, 8 | bne TMP1, AT, ->vmeta_call |. li NARGS8:RC, 16 // Iterators get 2 arguments. | ins_call break; case BC_ITERN: | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) |.if JIT | // NYI: add hotloop, record BC_ITERN. |.endif | addu RA, BASE, RA | lw TAB:RB, -16+LO(RA) | lw RC, -8+LO(RA) // Get index from control var. | lw TMP0, TAB:RB->asize | lw TMP1, TAB:RB->array | addiu PC, PC, 4 |1: // Traverse array part. | sltu AT, RC, TMP0 | beqz AT, >5 // Index points after array part? |. sll TMP3, RC, 3 | addu TMP3, TMP1, TMP3 | lw TMP2, HI(TMP3) | ldc1 f0, 0(TMP3) | mtc1 RC, f2 | lhu RD, -4+OFS_RD(PC) | beq TMP2, TISNIL, <1 // Skip holes in array part. |. addiu RC, RC, 1 | cvt.d.w f2, f2 | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) | sdc1 f0, 8(RA) | decode_RD4b RD | addu RD, RD, TMP3 | sw RC, -8+LO(RA) // Update control var. | addu PC, PC, RD | sdc1 f2, 0(RA) |3: | ins_next | |5: // Traverse hash part. | lw TMP1, TAB:RB->hmask | subu RC, RC, TMP0 | lw TMP2, TAB:RB->node |6: | sltu AT, TMP1, RC // End of iteration? Branch to ITERL+1. | bnez AT, <3 |. sll TMP3, RC, 5 | sll RB, RC, 3 | subu TMP3, TMP3, RB | addu NODE:TMP3, TMP3, TMP2 | lw RB, HI(NODE:TMP3) | ldc1 f0, 0(NODE:TMP3) | lhu RD, -4+OFS_RD(PC) | beq RB, TISNIL, <6 // Skip holes in hash part. |. addiu RC, RC, 1 | ldc1 f2, NODE:TMP3->key | lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535) | sdc1 f0, 8(RA) | addu RC, RC, TMP0 | decode_RD4b RD | addu RD, RD, TMP3 | sdc1 f2, 0(RA) | addu PC, PC, RD | b <3 |. sw RC, -8+LO(RA) // Update control var. break; case BC_ISNEXT: | // RA = base*8, RD = target (points to ITERN) | addu RA, BASE, RA | lw TMP0, -24+HI(RA) | lw CFUNC:TMP1, -24+LO(RA) | lw TMP2, -16+HI(RA) | lw TMP3, -8+HI(RA) | li AT, LJ_TFUNC | bne TMP0, AT, >5 |. addiu TMP2, TMP2, -LJ_TTAB | lbu TMP1, CFUNC:TMP1->ffid | addiu TMP3, TMP3, -LJ_TNIL | srl TMP0, RD, 1 | or TMP2, TMP2, TMP3 | addiu TMP1, TMP1, -FF_next_N | addu TMP0, PC, TMP0 | or TMP1, TMP1, TMP2 | bnez TMP1, >5 |. lui TMP2, (-(BCBIAS_J*4 >> 16) & 65535) | addu PC, TMP0, TMP2 | lui TMP1, 0xfffe | ori TMP1, TMP1, 0x7fff | sw r0, -8+LO(RA) // Initialize control var. | sw TMP1, -8+HI(RA) |1: | ins_next |5: // Despecialize bytecode if any of the checks fail. | li TMP3, BC_JMP | li TMP1, BC_ITERC | sb TMP3, -4+OFS_OP(PC) | addu PC, TMP0, TMP2 | b <1 |. sb TMP1, OFS_OP(PC) break; case BC_VARG: | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 | lw TMP0, FRAME_PC(BASE) | decode_RDtoRC8 RC, RD | decode_RB8a RB, INS | addu RC, BASE, RC | decode_RB8b RB | addu RA, BASE, RA | addiu RC, RC, FRAME_VARG | addu TMP2, RA, RB | addiu TMP3, BASE, -8 // TMP3 = vtop | subu RC, RC, TMP0 // RC = vbase | // Note: RC may now be even _above_ BASE if nargs was < numparams. | beqz RB, >5 // Copy all varargs? |. subu TMP1, TMP3, RC | addiu TMP2, TMP2, -16 |1: // Copy vararg slots to destination slots. | lw CARG1, HI(RC) | sltu AT, RC, TMP3 | lw CARG2, LO(RC) | addiu RC, RC, 8 | movz CARG1, TISNIL, AT | sw CARG1, HI(RA) | sw CARG2, LO(RA) | sltu AT, RA, TMP2 | bnez AT, <1 |. addiu RA, RA, 8 |3: | ins_next | |5: // Copy all varargs. | lw TMP0, L->maxstack | blez TMP1, <3 // No vararg slots? |. li MULTRES, 8 // MULTRES = (0+1)*8 | addu TMP2, RA, TMP1 | sltu AT, TMP0, TMP2 | bnez AT, >7 |. addiu MULTRES, TMP1, 8 |6: | ldc1 f0, 0(RC) | addiu RC, RC, 8 | sdc1 f0, 0(RA) | sltu AT, RC, TMP3 | bnez AT, <6 // More vararg slots? |. addiu RA, RA, 8 | b <3 |. nop | |7: // Grow stack for varargs. | load_got lj_state_growstack | sw RA, L->top | subu RA, RA, BASE | sw BASE, L->base | subu BASE, RC, BASE // Need delta, because BASE may change. | sw PC, SAVE_PC | srl CARG2, TMP1, 3 | call_intern lj_state_growstack // (lua_State *L, int n) |. move CARG1, L | move RC, BASE | lw BASE, L->base | addu RA, BASE, RA | addu RC, BASE, RC | b <6 |. addiu TMP3, BASE, -8 break; /* -- Returns ----------------------------------------------------------- */ case BC_RETM: | // RA = results*8, RD = extra_nresults*8 | addu RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. | // Fall through. Assumes BC_RET follows. break; case BC_RET: | // RA = results*8, RD = (nresults+1)*8 | lw PC, FRAME_PC(BASE) | addu RA, BASE, RA | move MULTRES, RD |1: | andi TMP0, PC, FRAME_TYPE | bnez TMP0, ->BC_RETV_Z |. xori TMP1, PC, FRAME_VARG | |->BC_RET_Z: | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return | lw INS, -4(PC) | addiu TMP2, BASE, -8 | addiu RC, RD, -8 | decode_RA8a TMP0, INS | decode_RB8a RB, INS | decode_RA8b TMP0 | decode_RB8b RB | addu TMP3, TMP2, RB | beqz RC, >3 |. subu BASE, TMP2, TMP0 |2: | ldc1 f0, 0(RA) | addiu RA, RA, 8 | addiu RC, RC, -8 | sdc1 f0, 0(TMP2) | bnez RC, <2 |. addiu TMP2, TMP2, 8 |3: | addiu TMP3, TMP3, -8 |5: | sltu AT, TMP2, TMP3 | bnez AT, >6 |. lw LFUNC:TMP1, FRAME_FUNC(BASE) | ins_next1 | lw TMP1, LFUNC:TMP1->pc | lw KBASE, PC2PROTO(k)(TMP1) | ins_next2 | |6: // Fill up results with nil. | sw TISNIL, HI(TMP2) | b <5 |. addiu TMP2, TMP2, 8 | |->BC_RETV_Z: // Non-standard return case. | andi TMP2, TMP1, FRAME_TYPEP | bnez TMP2, ->vm_return |. nop | // Return from vararg function: relocate BASE down. | subu BASE, BASE, TMP1 | b <1 |. lw PC, FRAME_PC(BASE) break; case BC_RET0: case BC_RET1: | // RA = results*8, RD = (nresults+1)*8 | lw PC, FRAME_PC(BASE) | addu RA, BASE, RA | move MULTRES, RD | andi TMP0, PC, FRAME_TYPE | bnez TMP0, ->BC_RETV_Z |. xori TMP1, PC, FRAME_VARG | | lw INS, -4(PC) | addiu TMP2, BASE, -8 if (op == BC_RET1) { | ldc1 f0, 0(RA) } | decode_RB8a RB, INS | decode_RA8a RA, INS | decode_RB8b RB | decode_RA8b RA if (op == BC_RET1) { | sdc1 f0, 0(TMP2) } | subu BASE, TMP2, RA |5: | sltu AT, RD, RB | bnez AT, >6 |. lw LFUNC:TMP1, FRAME_FUNC(BASE) | ins_next1 | lw TMP1, LFUNC:TMP1->pc | lw KBASE, PC2PROTO(k)(TMP1) | ins_next2 | |6: // Fill up results with nil. | addiu TMP2, TMP2, 8 | addiu RD, RD, 8 | b <5 if (op == BC_RET1) { |. sw TISNIL, HI(TMP2) } else { |. sw TISNIL, -8+HI(TMP2) } break; /* -- Loops and branches ------------------------------------------------ */ case BC_FORL: |.if JIT | hotloop |.endif | // Fall through. Assumes BC_IFORL follows. break; case BC_JFORI: case BC_JFORL: #if !LJ_HASJIT break; #endif case BC_FORI: case BC_IFORL: | // RA = base*8, RD = target (after end of loop or start of loop) vk = (op == BC_IFORL || op == BC_JFORL); | addu RA, BASE, RA if (vk) { | ldc1 f0, FORL_IDX*8(RA) | ldc1 f4, FORL_STEP*8(RA) | ldc1 f2, FORL_STOP*8(RA) | lw TMP3, FORL_STEP*8+HI(RA) | add.d f0, f0, f4 | sdc1 f0, FORL_IDX*8(RA) } else { | lw TMP1, FORL_IDX*8+HI(RA) | lw TMP3, FORL_STEP*8+HI(RA) | lw TMP2, FORL_STOP*8+HI(RA) | sltiu TMP1, TMP1, LJ_TISNUM | sltiu TMP0, TMP3, LJ_TISNUM | sltiu TMP2, TMP2, LJ_TISNUM | and TMP1, TMP1, TMP0 | and TMP1, TMP1, TMP2 | ldc1 f0, FORL_IDX*8(RA) | beqz TMP1, ->vmeta_for |. ldc1 f2, FORL_STOP*8(RA) } if (op != BC_JFORL) { | srl RD, RD, 1 | lui TMP0, (-(BCBIAS_J*4 >> 16) & 65535) } | c.le.d 0, f0, f2 | c.le.d 1, f2, f0 | sdc1 f0, FORL_EXT*8(RA) if (op == BC_JFORI) { | li TMP1, 1 | li TMP2, 1 | addu TMP0, RD, TMP0 | slt TMP3, TMP3, r0 | movf TMP1, r0, 0 | addu PC, PC, TMP0 | movf TMP2, r0, 1 | lhu RD, -4+OFS_RD(PC) | movn TMP1, TMP2, TMP3 | bnez TMP1, =>BC_JLOOP |. decode_RD8b RD } else if (op == BC_JFORL) { | li TMP1, 1 | li TMP2, 1 | slt TMP3, TMP3, r0 | movf TMP1, r0, 0 | movf TMP2, r0, 1 | movn TMP1, TMP2, TMP3 | bnez TMP1, =>BC_JLOOP |. nop } else { | addu TMP1, RD, TMP0 | slt TMP3, TMP3, r0 | move TMP2, TMP1 if (op == BC_FORI) { | movt TMP1, r0, 0 | movt TMP2, r0, 1 } else { | movf TMP1, r0, 0 | movf TMP2, r0, 1 } | movn TMP1, TMP2, TMP3 | addu PC, PC, TMP1 } | ins_next break; case BC_ITERL: |.if JIT | hotloop |.endif | // Fall through. Assumes BC_IITERL follows. break; case BC_JITERL: #if !LJ_HASJIT break; #endif case BC_IITERL: | // RA = base*8, RD = target | addu RA, BASE, RA | lw TMP1, HI(RA) | beq TMP1, TISNIL, >1 // Stop if iterator returned nil. |. lw TMP2, LO(RA) if (op == BC_JITERL) { | sw TMP1, -8+HI(RA) | b =>BC_JLOOP |. sw TMP2, -8+LO(RA) } else { | branch_RD // Otherwise save control var + branch. | sw TMP1, -8+HI(RA) | sw TMP2, -8+LO(RA) } |1: | ins_next break; case BC_LOOP: | // RA = base*8, RD = target (loop extent) | // Note: RA/RD is only used by trace recorder to determine scope/extent | // This opcode does NOT jump, it's only purpose is to detect a hot loop. |.if JIT | hotloop |.endif | // Fall through. Assumes BC_ILOOP follows. break; case BC_ILOOP: | // RA = base*8, RD = target (loop extent) | ins_next break; case BC_JLOOP: |.if JIT | // RA = base*8 (ignored), RD = traceno*8 | lw TMP1, DISPATCH_J(trace)(DISPATCH) | srl RD, RD, 1 | li AT, 0 | addu TMP1, TMP1, RD | // Traces on MIPS don't store the trace number, so use 0. | sw AT, DISPATCH_GL(vmstate)(DISPATCH) | lw TRACE:TMP2, 0(TMP1) | sw BASE, DISPATCH_GL(jit_base)(DISPATCH) | sw L, DISPATCH_GL(jit_L)(DISPATCH) | lw TMP2, TRACE:TMP2->mcode | jr TMP2 |. addiu JGL, DISPATCH, GG_DISP2G+32768 |.endif break; case BC_JMP: | // RA = base*8 (only used by trace recorder), RD = target | branch_RD | ins_next break; /* -- Function headers -------------------------------------------------- */ case BC_FUNCF: |.if JIT | hotcall |.endif case BC_FUNCV: /* NYI: compiled vararg functions. */ | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. break; case BC_JFUNCF: #if !LJ_HASJIT break; #endif case BC_IFUNCF: | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 | lw TMP2, L->maxstack | lbu TMP1, -4+PC2PROTO(numparams)(PC) | lw KBASE, -4+PC2PROTO(k)(PC) | sltu AT, TMP2, RA | bnez AT, ->vm_growstack_l |. sll TMP1, TMP1, 3 if (op != BC_JFUNCF) { | ins_next1 } |2: | sltu AT, NARGS8:RC, TMP1 // Check for missing parameters. | bnez AT, >3 |. addu AT, BASE, NARGS8:RC if (op == BC_JFUNCF) { | decode_RD8a RD, INS | b =>BC_JLOOP |. decode_RD8b RD } else { | ins_next2 } | |3: // Clear missing parameters. | sw TISNIL, HI(AT) | b <2 |. addiu NARGS8:RC, NARGS8:RC, 8 break; case BC_JFUNCV: #if !LJ_HASJIT break; #endif | NYI // NYI: compiled vararg functions break; /* NYI: compiled vararg functions. */ case BC_IFUNCV: | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 | addu TMP1, BASE, RC | lw TMP2, L->maxstack | addu TMP0, RA, RC | sw LFUNC:RB, LO(TMP1) // Store copy of LFUNC. | addiu TMP3, RC, 8+FRAME_VARG | sltu AT, TMP0, TMP2 | lw KBASE, -4+PC2PROTO(k)(PC) | beqz AT, ->vm_growstack_l |. sw TMP3, HI(TMP1) // Store delta + FRAME_VARG. | lbu TMP2, -4+PC2PROTO(numparams)(PC) | move RA, BASE | move RC, TMP1 | ins_next1 | beqz TMP2, >3 |. addiu BASE, TMP1, 8 |1: | lw TMP0, HI(RA) | lw TMP3, LO(RA) | sltu AT, RA, RC // Less args than parameters? | move CARG1, TMP0 | movz TMP0, TISNIL, AT // Clear missing parameters. | movn CARG1, TISNIL, AT // Clear old fixarg slot (help the GC). | sw TMP3, 8+LO(TMP1) | addiu TMP2, TMP2, -1 | sw TMP0, 8+HI(TMP1) | addiu TMP1, TMP1, 8 | sw CARG1, HI(RA) | bnez TMP2, <1 |. addiu RA, RA, 8 |3: | ins_next2 break; case BC_FUNCC: case BC_FUNCCW: | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 if (op == BC_FUNCC) { | lw CFUNCADDR, CFUNC:RB->f } else { | lw CFUNCADDR, DISPATCH_GL(wrapf)(DISPATCH) } | addu TMP1, RA, NARGS8:RC | lw TMP2, L->maxstack | addu RC, BASE, NARGS8:RC | sw BASE, L->base | sltu AT, TMP2, TMP1 | sw RC, L->top | li_vmstate C if (op == BC_FUNCCW) { | lw CARG2, CFUNC:RB->f } | bnez AT, ->vm_growstack_c // Need to grow stack. |. move CARG1, L | jalr CFUNCADDR // (lua_State *L [, lua_CFunction f]) |. st_vmstate | // Returns nresults. | lw BASE, L->base | sll RD, CRET1, 3 | lw TMP1, L->top | li_vmstate INTERP | lw PC, FRAME_PC(BASE) // Fetch PC of caller. | subu RA, TMP1, RD // RA = L->top - nresults*8 | b ->vm_returnc |. st_vmstate break; /* ---------------------------------------------------------------------- */ default: fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); exit(2); break; } } static int build_backend(BuildCtx *ctx) { int op; dasm_growpc(Dst, BC__MAX); build_subroutines(ctx); |.code_op for (op = 0; op < BC__MAX; op++) build_ins(ctx, (BCOp)op, op); return BC__MAX; } /* Emit pseudo frame-info for all assembler functions. */ static void emit_asm_debug(BuildCtx *ctx) { int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); int i; switch (ctx->mode) { case BUILD_elfasm: fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); fprintf(ctx->fp, ".Lframe0:\n" "\t.4byte .LECIE0-.LSCIE0\n" ".LSCIE0:\n" "\t.4byte 0xffffffff\n" "\t.byte 0x1\n" "\t.string \"\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 31\n" "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" "\t.align 2\n" ".LECIE0:\n\n"); fprintf(ctx->fp, ".LSFDE0:\n" "\t.4byte .LEFDE0-.LASFDE0\n" ".LASFDE0:\n" "\t.4byte .Lframe0\n" "\t.4byte .Lbegin\n" "\t.4byte %d\n" "\t.byte 0xe\n\t.uleb128 %d\n" "\t.byte 0x9f\n\t.sleb128 1\n" "\t.byte 0x9e\n\t.sleb128 2\n", fcofs, CFRAME_SIZE); for (i = 23; i >= 16; i--) fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 26-i); for (i = 30; i >= 20; i -= 2) fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i, 42-i); fprintf(ctx->fp, "\t.align 2\n" ".LEFDE0:\n\n"); #if LJ_HASFFI fprintf(ctx->fp, ".LSFDE1:\n" "\t.4byte .LEFDE1-.LASFDE1\n" ".LASFDE1:\n" "\t.4byte .Lframe0\n" "\t.4byte lj_vm_ffi_call\n" "\t.4byte %d\n" "\t.byte 0x9f\n\t.uleb128 1\n" "\t.byte 0x90\n\t.uleb128 2\n" "\t.byte 0xd\n\t.uleb128 0x10\n" "\t.align 2\n" ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); #endif fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); fprintf(ctx->fp, "\t.globl lj_err_unwind_dwarf\n" ".Lframe1:\n" "\t.4byte .LECIE1-.LSCIE1\n" ".LSCIE1:\n" "\t.4byte 0\n" "\t.byte 0x1\n" "\t.string \"zPR\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 31\n" "\t.uleb128 6\n" /* augmentation length */ "\t.byte 0\n" "\t.4byte lj_err_unwind_dwarf\n" "\t.byte 0\n" "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" "\t.align 2\n" ".LECIE1:\n\n"); fprintf(ctx->fp, ".LSFDE2:\n" "\t.4byte .LEFDE2-.LASFDE2\n" ".LASFDE2:\n" "\t.4byte .LASFDE2-.Lframe1\n" "\t.4byte .Lbegin\n" "\t.4byte %d\n" "\t.uleb128 0\n" /* augmentation length */ "\t.byte 0xe\n\t.uleb128 %d\n" "\t.byte 0x9f\n\t.sleb128 1\n" "\t.byte 0x9e\n\t.sleb128 2\n", fcofs, CFRAME_SIZE); for (i = 23; i >= 16; i--) fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 26-i); for (i = 30; i >= 20; i -= 2) fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i, 42-i); fprintf(ctx->fp, "\t.align 2\n" ".LEFDE2:\n\n"); #if LJ_HASFFI fprintf(ctx->fp, ".Lframe2:\n" "\t.4byte .LECIE2-.LSCIE2\n" ".LSCIE2:\n" "\t.4byte 0\n" "\t.byte 0x1\n" "\t.string \"zR\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 31\n" "\t.uleb128 1\n" /* augmentation length */ "\t.byte 0\n" "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n" "\t.align 2\n" ".LECIE2:\n\n"); fprintf(ctx->fp, ".LSFDE3:\n" "\t.4byte .LEFDE3-.LASFDE3\n" ".LASFDE3:\n" "\t.4byte .LASFDE3-.Lframe2\n" "\t.4byte lj_vm_ffi_call\n" "\t.4byte %d\n" "\t.uleb128 0\n" /* augmentation length */ "\t.byte 0x9f\n\t.uleb128 1\n" "\t.byte 0x90\n\t.uleb128 2\n" "\t.byte 0xd\n\t.uleb128 0x10\n" "\t.align 2\n" ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); #endif break; default: break; } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/vm_ppc.dasc ================================================ |// Low-level VM code for PowerPC CPUs. |// Bytecode interpreter, fast functions and helper functions. |// Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h | |.arch ppc |.section code_op, code_sub | |.actionlist build_actionlist |.globals GLOB_ |.globalnames globnames |.externnames extnames | |// Note: The ragged indentation of the instructions is intentional. |// The starting columns indicate data dependencies. | |//----------------------------------------------------------------------- | |// DynASM defines used by the PPC port: |// |// P64 64 bit pointers (only for GPR64 testing). |// Note: a full PPC64 _LP64 port is not planned. |// GPR64 64 bit registers (but possibly 32 bit pointers, e.g. PS3). |// Affects reg saves, stack layout, carry/overflow/dot flags etc. |// FRAME32 Use 32 bit frame layout, even with GPR64 (Xbox 360). |// TOC Need table of contents (64 bit or 32 bit variant, e.g. PS3). |// Function pointers are really a struct: code, TOC, env (optional). |// TOCENV Function pointers have an environment pointer, too (not on PS3). |// PPE Power Processor Element of Cell (PS3) or Xenon (Xbox 360). |// Must avoid (slow) micro-coded instructions. | |.if P64 |.define TOC, 1 |.define TOCENV, 1 |.macro lpx, a, b, c; ldx a, b, c; .endmacro |.macro lp, a, b; ld a, b; .endmacro |.macro stp, a, b; std a, b; .endmacro |.define decode_OPP, decode_OP8 |.if FFI |// Missing: Calling conventions, 64 bit regs, TOC. |.error lib_ffi not yet implemented for PPC64 |.endif |.else |.macro lpx, a, b, c; lwzx a, b, c; .endmacro |.macro lp, a, b; lwz a, b; .endmacro |.macro stp, a, b; stw a, b; .endmacro |.define decode_OPP, decode_OP4 |.endif | |// Convenience macros for TOC handling. |.if TOC |// Linker needs a TOC patch area for every external call relocation. |.macro blex, target; bl extern target; nop; .endmacro |.macro .toc, a, b; a, b; .endmacro |.if P64 |.define TOC_OFS, 8 |.define ENV_OFS, 16 |.else |.define TOC_OFS, 4 |.define ENV_OFS, 8 |.endif |.else // No TOC. |.macro blex, target; bl extern target; .endmacro |.macro .toc, a, b; .endmacro |.endif |.macro .tocenv, a, b; .if TOCENV; a, b; .endif; .endmacro | |.macro .gpr64, a, b; .if GPR64; a, b; .endif; .endmacro | |.macro andix., y, a, i |.if PPE | rlwinm y, a, 0, 31-lj_fls(i), 31-lj_ffs(i) | cmpwi y, 0 |.else | andi. y, a, i |.endif |.endmacro | |//----------------------------------------------------------------------- | |// Fixed register assignments for the interpreter. |// Don't use: r1 = sp, r2 and r13 = reserved (TOC, TLS or SDATA) | |// The following must be C callee-save (but BASE is often refetched). |.define BASE, r14 // Base of current Lua stack frame. |.define KBASE, r15 // Constants of current Lua function. |.define PC, r16 // Next PC. |.define DISPATCH, r17 // Opcode dispatch table. |.define LREG, r18 // Register holding lua_State (also in SAVE_L). |.define MULTRES, r19 // Size of multi-result: (nresults+1)*8. |.define JGL, r31 // On-trace: global_State + 32768. | |// Constants for type-comparisons, stores and conversions. C callee-save. |.define TISNUM, r22 |.define TISNIL, r23 |.define ZERO, r24 |.define TOBIT, f30 // 2^52 + 2^51. |.define TONUM, f31 // 2^52 + 2^51 + 2^31. | |// The following temporaries are not saved across C calls, except for RA. |.define RA, r20 // Callee-save. |.define RB, r10 |.define RC, r11 |.define RD, r12 |.define INS, r7 // Overlaps CARG5. | |.define TMP0, r0 |.define TMP1, r8 |.define TMP2, r9 |.define TMP3, r6 // Overlaps CARG4. | |// Saved temporaries. |.define SAVE0, r21 | |// Calling conventions. |.define CARG1, r3 |.define CARG2, r4 |.define CARG3, r5 |.define CARG4, r6 // Overlaps TMP3. |.define CARG5, r7 // Overlaps INS. | |.define FARG1, f1 |.define FARG2, f2 | |.define CRET1, r3 |.define CRET2, r4 | |.define TOCREG, r2 // TOC register (only used by C code). |.define ENVREG, r11 // Environment pointer (nested C functions). | |// Stack layout while in interpreter. Must match with lj_frame.h. |.if GPR64 |.if FRAME32 | |// 456(sp) // \ 32/64 bit C frame info |.define TONUM_LO, 452(sp) // | |.define TONUM_HI, 448(sp) // | |.define TMPD_LO, 444(sp) // | |.define TMPD_HI, 440(sp) // | |.define SAVE_CR, 432(sp) // | 64 bit CR save. |.define SAVE_ERRF, 424(sp) // > Parameter save area. |.define SAVE_NRES, 420(sp) // | |.define SAVE_L, 416(sp) // | |.define SAVE_PC, 412(sp) // | |.define SAVE_MULTRES, 408(sp) // | |.define SAVE_CFRAME, 400(sp) // / 64 bit C frame chain. |// 392(sp) // Reserved. |.define CFRAME_SPACE, 384 // Delta for sp. |// Back chain for sp: 384(sp) <-- sp entering interpreter |.define SAVE_LR, 376(sp) // 32 bit LR stored in hi-part. |.define SAVE_GPR_, 232 // .. 232+18*8: 64 bit GPR saves. |.define SAVE_FPR_, 88 // .. 88+18*8: 64 bit FPR saves. |// 80(sp) // Needed for 16 byte stack frame alignment. |// 16(sp) // Callee parameter save area (ABI mandated). |// 8(sp) // Reserved |// Back chain for sp: 0(sp) <-- sp while in interpreter |// 32 bit sp stored in hi-part of 0(sp). | |.define TMPD_BLO, 447(sp) |.define TMPD, TMPD_HI |.define TONUM_D, TONUM_HI | |.else | |// 508(sp) // \ 32 bit C frame info. |.define SAVE_ERRF, 472(sp) // | |.define SAVE_NRES, 468(sp) // | |.define SAVE_L, 464(sp) // > Parameter save area. |.define SAVE_PC, 460(sp) // | |.define SAVE_MULTRES, 456(sp) // | |.define SAVE_CFRAME, 448(sp) // / 64 bit C frame chain. |.define SAVE_LR, 416(sp) |.define CFRAME_SPACE, 400 // Delta for sp. |// Back chain for sp: 400(sp) <-- sp entering interpreter |.define SAVE_FPR_, 256 // .. 256+18*8: 64 bit FPR saves. |.define SAVE_GPR_, 112 // .. 112+18*8: 64 bit GPR saves. |// 48(sp) // Callee parameter save area (ABI mandated). |.define SAVE_TOC, 40(sp) // TOC save area. |.define TMPD_LO, 36(sp) // \ Link editor temp (ABI mandated). |.define TMPD_HI, 32(sp) // / |.define TONUM_LO, 28(sp) // \ Compiler temp (ABI mandated). |.define TONUM_HI, 24(sp) // / |// Next frame lr: 16(sp) |.define SAVE_CR, 8(sp) // 64 bit CR save. |// Back chain for sp: 0(sp) <-- sp while in interpreter | |.define TMPD_BLO, 39(sp) |.define TMPD, TMPD_HI |.define TONUM_D, TONUM_HI | |.endif |.else | |.define SAVE_LR, 276(sp) |.define CFRAME_SPACE, 272 // Delta for sp. |// Back chain for sp: 272(sp) <-- sp entering interpreter |.define SAVE_FPR_, 128 // .. 128+18*8: 64 bit FPR saves. |.define SAVE_GPR_, 56 // .. 56+18*4: 32 bit GPR saves. |.define SAVE_CR, 52(sp) // 32 bit CR save. |.define SAVE_ERRF, 48(sp) // 32 bit C frame info. |.define SAVE_NRES, 44(sp) |.define SAVE_CFRAME, 40(sp) |.define SAVE_L, 36(sp) |.define SAVE_PC, 32(sp) |.define SAVE_MULTRES, 28(sp) |.define UNUSED1, 24(sp) |.define TMPD_LO, 20(sp) |.define TMPD_HI, 16(sp) |.define TONUM_LO, 12(sp) |.define TONUM_HI, 8(sp) |// Next frame lr: 4(sp) |// Back chain for sp: 0(sp) <-- sp while in interpreter | |.define TMPD_BLO, 23(sp) |.define TMPD, TMPD_HI |.define TONUM_D, TONUM_HI | |.endif | |.macro save_, reg |.if GPR64 | std r..reg, SAVE_GPR_+(reg-14)*8(sp) |.else | stw r..reg, SAVE_GPR_+(reg-14)*4(sp) |.endif | stfd f..reg, SAVE_FPR_+(reg-14)*8(sp) |.endmacro |.macro rest_, reg |.if GPR64 | ld r..reg, SAVE_GPR_+(reg-14)*8(sp) |.else | lwz r..reg, SAVE_GPR_+(reg-14)*4(sp) |.endif | lfd f..reg, SAVE_FPR_+(reg-14)*8(sp) |.endmacro | |.macro saveregs |.if GPR64 and not FRAME32 | stdu sp, -CFRAME_SPACE(sp) |.else | stwu sp, -CFRAME_SPACE(sp) |.endif | save_ 14; save_ 15; save_ 16 | mflr r0 | save_ 17; save_ 18; save_ 19; save_ 20; save_ 21; save_ 22 |.if GPR64 and not FRAME32 | std r0, SAVE_LR |.else | stw r0, SAVE_LR |.endif | save_ 23; save_ 24; save_ 25 | mfcr r0 | save_ 26; save_ 27; save_ 28; save_ 29; save_ 30; save_ 31 |.if GPR64 | std r0, SAVE_CR |.else | stw r0, SAVE_CR |.endif | .toc std TOCREG, SAVE_TOC |.endmacro | |.macro restoreregs |.if GPR64 and not FRAME32 | ld r0, SAVE_LR |.else | lwz r0, SAVE_LR |.endif |.if GPR64 | ld r12, SAVE_CR |.else | lwz r12, SAVE_CR |.endif | rest_ 14; rest_ 15; rest_ 16; rest_ 17; rest_ 18; rest_ 19 | mtlr r0; |.if PPE; mtocrf 0x20, r12; .else; mtcrf 0x38, r12; .endif | rest_ 20; rest_ 21; rest_ 22; rest_ 23; rest_ 24; rest_ 25 |.if PPE; mtocrf 0x10, r12; .endif | rest_ 26; rest_ 27; rest_ 28; rest_ 29; rest_ 30; rest_ 31 |.if PPE; mtocrf 0x08, r12; .endif | addi sp, sp, CFRAME_SPACE |.endmacro | |// Type definitions. Some of these are only used for documentation. |.type L, lua_State, LREG |.type GL, global_State |.type TVALUE, TValue |.type GCOBJ, GCobj |.type STR, GCstr |.type TAB, GCtab |.type LFUNC, GCfuncL |.type CFUNC, GCfuncC |.type PROTO, GCproto |.type UPVAL, GCupval |.type NODE, Node |.type NARGS8, int |.type TRACE, GCtrace | |//----------------------------------------------------------------------- | |// These basic macros should really be part of DynASM. |.macro srwi, rx, ry, n; rlwinm rx, ry, 32-n, n, 31; .endmacro |.macro slwi, rx, ry, n; rlwinm rx, ry, n, 0, 31-n; .endmacro |.macro rotlwi, rx, ry, n; rlwinm rx, ry, n, 0, 31; .endmacro |.macro rotlw, rx, ry, rn; rlwnm rx, ry, rn, 0, 31; .endmacro |.macro subi, rx, ry, i; addi rx, ry, -i; .endmacro | |// Trap for not-yet-implemented parts. |.macro NYI; tw 4, sp, sp; .endmacro | |// int/FP conversions. |.macro tonum_i, freg, reg | xoris reg, reg, 0x8000 | stw reg, TONUM_LO | lfd freg, TONUM_D | fsub freg, freg, TONUM |.endmacro | |.macro tonum_u, freg, reg | stw reg, TONUM_LO | lfd freg, TONUM_D | fsub freg, freg, TOBIT |.endmacro | |.macro toint, reg, freg, tmpfreg | fctiwz tmpfreg, freg | stfd tmpfreg, TMPD | lwz reg, TMPD_LO |.endmacro | |.macro toint, reg, freg | toint reg, freg, freg |.endmacro | |//----------------------------------------------------------------------- | |// Access to frame relative to BASE. |.define FRAME_PC, -8 |.define FRAME_FUNC, -4 | |// Instruction decode. |.macro decode_OP4, dst, ins; rlwinm dst, ins, 2, 22, 29; .endmacro |.macro decode_OP8, dst, ins; rlwinm dst, ins, 3, 21, 28; .endmacro |.macro decode_RA8, dst, ins; rlwinm dst, ins, 27, 21, 28; .endmacro |.macro decode_RB8, dst, ins; rlwinm dst, ins, 11, 21, 28; .endmacro |.macro decode_RC8, dst, ins; rlwinm dst, ins, 19, 21, 28; .endmacro |.macro decode_RD8, dst, ins; rlwinm dst, ins, 19, 13, 28; .endmacro | |.macro decode_OP1, dst, ins; rlwinm dst, ins, 0, 24, 31; .endmacro |.macro decode_RD4, dst, ins; rlwinm dst, ins, 18, 14, 29; .endmacro | |// Instruction fetch. |.macro ins_NEXT1 | lwz INS, 0(PC) | addi PC, PC, 4 |.endmacro |// Instruction decode+dispatch. Note: optimized for e300! |.macro ins_NEXT2 | decode_OPP TMP1, INS | lpx TMP0, DISPATCH, TMP1 | mtctr TMP0 | decode_RB8 RB, INS | decode_RD8 RD, INS | decode_RA8 RA, INS | decode_RC8 RC, INS | bctr |.endmacro |.macro ins_NEXT | ins_NEXT1 | ins_NEXT2 |.endmacro | |// Instruction footer. |.if 1 | // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. | .define ins_next, ins_NEXT | .define ins_next_, ins_NEXT | .define ins_next1, ins_NEXT1 | .define ins_next2, ins_NEXT2 |.else | // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. | // Affects only certain kinds of benchmarks (and only with -j off). | .macro ins_next | b ->ins_next | .endmacro | .macro ins_next1 | .endmacro | .macro ins_next2 | b ->ins_next | .endmacro | .macro ins_next_ | ->ins_next: | ins_NEXT | .endmacro |.endif | |// Call decode and dispatch. |.macro ins_callt | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC | lwz PC, LFUNC:RB->pc | lwz INS, 0(PC) | addi PC, PC, 4 | decode_OPP TMP1, INS | decode_RA8 RA, INS | lpx TMP0, DISPATCH, TMP1 | add RA, RA, BASE | mtctr TMP0 | bctr |.endmacro | |.macro ins_call | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC | stw PC, FRAME_PC(BASE) | ins_callt |.endmacro | |//----------------------------------------------------------------------- | |// Macros to test operand types. |.macro checknum, reg; cmplw reg, TISNUM; .endmacro |.macro checknum, cr, reg; cmplw cr, reg, TISNUM; .endmacro |.macro checkstr, reg; cmpwi reg, LJ_TSTR; .endmacro |.macro checktab, reg; cmpwi reg, LJ_TTAB; .endmacro |.macro checkfunc, reg; cmpwi reg, LJ_TFUNC; .endmacro |.macro checknil, reg; cmpwi reg, LJ_TNIL; .endmacro | |.macro branch_RD | srwi TMP0, RD, 1 | addis PC, PC, -(BCBIAS_J*4 >> 16) | add PC, PC, TMP0 |.endmacro | |// Assumes DISPATCH is relative to GL. #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) | #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) | |.macro hotcheck, delta, target | rlwinm TMP1, PC, 31, 25, 30 | addi TMP1, TMP1, GG_DISP2HOT | lhzx TMP2, DISPATCH, TMP1 | addic. TMP2, TMP2, -delta | sthx TMP2, DISPATCH, TMP1 | blt target |.endmacro | |.macro hotloop | hotcheck HOTCOUNT_LOOP, ->vm_hotloop |.endmacro | |.macro hotcall | hotcheck HOTCOUNT_CALL, ->vm_hotcall |.endmacro | |// Set current VM state. Uses TMP0. |.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro |.macro st_vmstate; stw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro | |// Move table write barrier back. Overwrites mark and tmp. |.macro barrierback, tab, mark, tmp | lwz tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) | // Assumes LJ_GC_BLACK is 0x04. | rlwinm mark, mark, 0, 30, 28 // black2gray(tab) | stw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) | stb mark, tab->marked | stw tmp, tab->gclist |.endmacro | |//----------------------------------------------------------------------- /* Generate subroutines used by opcodes and other parts of the VM. */ /* The .code_sub section should be last to help static branch prediction. */ static void build_subroutines(BuildCtx *ctx) { |.code_sub | |//----------------------------------------------------------------------- |//-- Return handling ---------------------------------------------------- |//----------------------------------------------------------------------- | |->vm_returnp: | // See vm_return. Also: TMP2 = previous base. | andix. TMP0, PC, FRAME_P | li TMP1, LJ_TTRUE | beq ->cont_dispatch | | // Return from pcall or xpcall fast func. | lwz PC, FRAME_PC(TMP2) // Fetch PC of previous frame. | mr BASE, TMP2 // Restore caller base. | // Prepending may overwrite the pcall frame, so do it at the end. | stwu TMP1, FRAME_PC(RA) // Prepend true to results. | |->vm_returnc: | addi RD, RD, 8 // RD = (nresults+1)*8. | andix. TMP0, PC, FRAME_TYPE | cmpwi cr1, RD, 0 | li CRET1, LUA_YIELD | beq cr1, ->vm_unwind_c_eh | mr MULTRES, RD | beq ->BC_RET_Z // Handle regular return to Lua. | |->vm_return: | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return | // TMP0 = PC & FRAME_TYPE | cmpwi TMP0, FRAME_C | rlwinm TMP2, PC, 0, 0, 28 | li_vmstate C | sub TMP2, BASE, TMP2 // TMP2 = previous base. | bney ->vm_returnp | | addic. TMP1, RD, -8 | stp TMP2, L->base | lwz TMP2, SAVE_NRES | subi BASE, BASE, 8 | st_vmstate | slwi TMP2, TMP2, 3 | beq >2 |1: | addic. TMP1, TMP1, -8 | lfd f0, 0(RA) | addi RA, RA, 8 | stfd f0, 0(BASE) | addi BASE, BASE, 8 | bney <1 | |2: | cmpw TMP2, RD // More/less results wanted? | bne >6 |3: | stp BASE, L->top // Store new top. | |->vm_leave_cp: | lp TMP0, SAVE_CFRAME // Restore previous C frame. | li CRET1, 0 // Ok return status for vm_pcall. | stp TMP0, L->cframe | |->vm_leave_unw: | restoreregs | blr | |6: | ble >7 // Less results wanted? | // More results wanted. Check stack size and fill up results with nil. | lwz TMP1, L->maxstack | cmplw BASE, TMP1 | bge >8 | stw TISNIL, 0(BASE) | addi RD, RD, 8 | addi BASE, BASE, 8 | b <2 | |7: // Less results wanted. | subfic TMP3, TMP2, 0 // LUA_MULTRET+1 case? | sub TMP0, RD, TMP2 | subfe TMP1, TMP1, TMP1 // TMP1 = TMP2 == 0 ? 0 : -1 | and TMP0, TMP0, TMP1 | sub BASE, BASE, TMP0 // Either keep top or shrink it. | b <3 | |8: // Corner case: need to grow stack for filling up results. | // This can happen if: | // - A C function grows the stack (a lot). | // - The GC shrinks the stack in between. | // - A return back from a lua_call() with (high) nresults adjustment. | stp BASE, L->top // Save current top held in BASE (yes). | mr SAVE0, RD | mr CARG2, TMP2 | mr CARG1, L | bl extern lj_state_growstack // (lua_State *L, int n) | lwz TMP2, SAVE_NRES | mr RD, SAVE0 | slwi TMP2, TMP2, 3 | lp BASE, L->top // Need the (realloced) L->top in BASE. | b <2 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. | // (void *cframe, int errcode) | mr sp, CARG1 | mr CRET1, CARG2 |->vm_unwind_c_eh: // Landing pad for external unwinder. | lwz L, SAVE_L | .toc ld TOCREG, SAVE_TOC | li TMP0, ~LJ_VMST_C | lwz GL:TMP1, L->glref | stw TMP0, GL:TMP1->vmstate | b ->vm_leave_unw | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. | // (void *cframe) |.if GPR64 | rldicr sp, CARG1, 0, 61 |.else | rlwinm sp, CARG1, 0, 0, 29 |.endif |->vm_unwind_ff_eh: // Landing pad for external unwinder. | lwz L, SAVE_L | .toc ld TOCREG, SAVE_TOC | li TISNUM, LJ_TISNUM // Setup type comparison constants. | lp BASE, L->base | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | lwz DISPATCH, L->glref // Setup pointer to dispatch table. | li ZERO, 0 | stw TMP3, TMPD | li TMP1, LJ_TFALSE | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). | li TISNIL, LJ_TNIL | li_vmstate INTERP | lfs TOBIT, TMPD | lwz PC, FRAME_PC(BASE) // Fetch PC of previous frame. | la RA, -8(BASE) // Results start at BASE-8. | stw TMP3, TMPD | addi DISPATCH, DISPATCH, GG_G2DISP | stw TMP1, 0(RA) // Prepend false to error message. | li RD, 16 // 2 results: false + error message. | st_vmstate | lfs TONUM, TMPD | b ->vm_returnc | |//----------------------------------------------------------------------- |//-- Grow stack for calls ----------------------------------------------- |//----------------------------------------------------------------------- | |->vm_growstack_c: // Grow stack for C function. | li CARG2, LUA_MINSTACK | b >2 | |->vm_growstack_l: // Grow stack for Lua function. | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC | add RC, BASE, RC | sub RA, RA, BASE | stp BASE, L->base | addi PC, PC, 4 // Must point after first instruction. | stp RC, L->top | srwi CARG2, RA, 3 |2: | // L->base = new base, L->top = top | stw PC, SAVE_PC | mr CARG1, L | bl extern lj_state_growstack // (lua_State *L, int n) | lp BASE, L->base | lp RC, L->top | lwz LFUNC:RB, FRAME_FUNC(BASE) | sub RC, RC, BASE | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC | ins_callt // Just retry the call. | |//----------------------------------------------------------------------- |//-- Entry points into the assembler VM --------------------------------- |//----------------------------------------------------------------------- | |->vm_resume: // Setup C frame and resume thread. | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) | saveregs | mr L, CARG1 | lwz DISPATCH, L->glref // Setup pointer to dispatch table. | mr BASE, CARG2 | lbz TMP1, L->status | stw L, SAVE_L | li PC, FRAME_CP | addi TMP0, sp, CFRAME_RESUME | addi DISPATCH, DISPATCH, GG_G2DISP | stw CARG3, SAVE_NRES | cmplwi TMP1, 0 | stw CARG3, SAVE_ERRF | stp TMP0, L->cframe | stp CARG3, SAVE_CFRAME | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. | beq >3 | | // Resume after yield (like a return). | mr RA, BASE | lp BASE, L->base | li TISNUM, LJ_TISNUM // Setup type comparison constants. | lp TMP1, L->top | lwz PC, FRAME_PC(BASE) | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | stb CARG3, L->status | stw TMP3, TMPD | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). | lfs TOBIT, TMPD | sub RD, TMP1, BASE | stw TMP3, TMPD | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) | addi RD, RD, 8 | stw TMP0, TONUM_HI | li_vmstate INTERP | li ZERO, 0 | st_vmstate | andix. TMP0, PC, FRAME_TYPE | mr MULTRES, RD | lfs TONUM, TMPD | li TISNIL, LJ_TNIL | beq ->BC_RET_Z | b ->vm_return | |->vm_pcall: // Setup protected C frame and enter VM. | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) | saveregs | li PC, FRAME_CP | stw CARG4, SAVE_ERRF | b >1 | |->vm_call: // Setup C frame and enter VM. | // (lua_State *L, TValue *base, int nres1) | saveregs | li PC, FRAME_C | |1: // Entry point for vm_pcall above (PC = ftype). | lp TMP1, L:CARG1->cframe | stw CARG3, SAVE_NRES | mr L, CARG1 | stw CARG1, SAVE_L | mr BASE, CARG2 | stp sp, L->cframe // Add our C frame to cframe chain. | lwz DISPATCH, L->glref // Setup pointer to dispatch table. | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. | stp TMP1, SAVE_CFRAME | addi DISPATCH, DISPATCH, GG_G2DISP | |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). | lp TMP2, L->base // TMP2 = old base (used in vmeta_call). | li TISNUM, LJ_TISNUM // Setup type comparison constants. | lp TMP1, L->top | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | add PC, PC, BASE | stw TMP3, TMPD | li ZERO, 0 | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). | lfs TOBIT, TMPD | sub PC, PC, TMP2 // PC = frame delta + frame type | stw TMP3, TMPD | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) | sub NARGS8:RC, TMP1, BASE | stw TMP0, TONUM_HI | li_vmstate INTERP | lfs TONUM, TMPD | li TISNIL, LJ_TNIL | st_vmstate | |->vm_call_dispatch: | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC | lwz TMP0, FRAME_PC(BASE) | lwz LFUNC:RB, FRAME_FUNC(BASE) | checkfunc TMP0; bne ->vmeta_call | |->vm_call_dispatch_f: | ins_call | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC | |->vm_cpcall: // Setup protected C frame, call C. | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) | saveregs | mr L, CARG1 | lwz TMP0, L:CARG1->stack | stw CARG1, SAVE_L | lp TMP1, L->top | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. | sub TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). | lp TMP1, L->cframe | stp sp, L->cframe // Add our C frame to cframe chain. | .toc lp CARG4, 0(CARG4) | li TMP2, 0 | stw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. | stw TMP2, SAVE_ERRF // No error function. | stp TMP1, SAVE_CFRAME | mtctr CARG4 | bctrl // (lua_State *L, lua_CFunction func, void *ud) |.if PPE | mr BASE, CRET1 | cmpwi CRET1, 0 |.else | mr. BASE, CRET1 |.endif | lwz DISPATCH, L->glref // Setup pointer to dispatch table. | li PC, FRAME_CP | addi DISPATCH, DISPATCH, GG_G2DISP | bne <3 // Else continue with the call. | b ->vm_leave_cp // No base? Just remove C frame. | |//----------------------------------------------------------------------- |//-- Metamethod handling ------------------------------------------------ |//----------------------------------------------------------------------- | |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the |// stack, so BASE doesn't need to be reloaded across these calls. | |//-- Continuation dispatch ---------------------------------------------- | |->cont_dispatch: | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 | lwz TMP0, -12(BASE) // Continuation. | mr RB, BASE | mr BASE, TMP2 // Restore caller BASE. | lwz LFUNC:TMP1, FRAME_FUNC(TMP2) |.if FFI | cmplwi TMP0, 1 |.endif | lwz PC, -16(RB) // Restore PC from [cont|PC]. | subi TMP2, RD, 8 | lwz TMP1, LFUNC:TMP1->pc | stwx TISNIL, RA, TMP2 // Ensure one valid arg. |.if FFI | ble >1 |.endif | lwz KBASE, PC2PROTO(k)(TMP1) | // BASE = base, RA = resultptr, RB = meta base | mtctr TMP0 | bctr // Jump to continuation. | |.if FFI |1: | beq ->cont_ffi_callback // cont = 1: return from FFI callback. | // cont = 0: tailcall from C function. | subi TMP1, RB, 16 | sub RC, TMP1, BASE | b ->vm_call_tail |.endif | |->cont_cat: // RA = resultptr, RB = meta base | lwz INS, -4(PC) | subi CARG2, RB, 16 | decode_RB8 SAVE0, INS | lfd f0, 0(RA) | add TMP1, BASE, SAVE0 | stp BASE, L->base | cmplw TMP1, CARG2 | sub CARG3, CARG2, TMP1 | decode_RA8 RA, INS | stfd f0, 0(CARG2) | bney ->BC_CAT_Z | stfdx f0, BASE, RA | b ->cont_nop | |//-- Table indexing metamethods ----------------------------------------- | |->vmeta_tgets1: | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | li TMP0, LJ_TSTR | decode_RB8 RB, INS | stw STR:RC, 4(CARG3) | add CARG2, BASE, RB | stw TMP0, 0(CARG3) | b >1 | |->vmeta_tgets: | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) | li TMP0, LJ_TTAB | stw TAB:RB, 4(CARG2) | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) | stw TMP0, 0(CARG2) | li TMP1, LJ_TSTR | stw STR:RC, 4(CARG3) | stw TMP1, 0(CARG3) | b >1 | |->vmeta_tgetb: // TMP0 = index |.if not DUALNUM | tonum_u f0, TMP0 |.endif | decode_RB8 RB, INS | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | add CARG2, BASE, RB |.if DUALNUM | stw TISNUM, 0(CARG3) | stw TMP0, 4(CARG3) |.else | stfd f0, 0(CARG3) |.endif | b >1 | |->vmeta_tgetv: | decode_RB8 RB, INS | decode_RC8 RC, INS | add CARG2, BASE, RB | add CARG3, BASE, RC |1: | stp BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) | // Returns TValue * (finished) or NULL (metamethod). | cmplwi CRET1, 0 | beq >3 | lfd f0, 0(CRET1) | ins_next1 | stfdx f0, BASE, RA | ins_next2 | |3: // Call __index metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k | subfic TMP1, BASE, FRAME_CONT | lp BASE, L->top | stw PC, -16(BASE) // [cont|PC] | add PC, TMP1, BASE | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | li NARGS8:RC, 16 // 2 args for func(t, k). | b ->vm_call_dispatch_f | |//----------------------------------------------------------------------- | |->vmeta_tsets1: | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | li TMP0, LJ_TSTR | decode_RB8 RB, INS | stw STR:RC, 4(CARG3) | add CARG2, BASE, RB | stw TMP0, 0(CARG3) | b >1 | |->vmeta_tsets: | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) | li TMP0, LJ_TTAB | stw TAB:RB, 4(CARG2) | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) | stw TMP0, 0(CARG2) | li TMP1, LJ_TSTR | stw STR:RC, 4(CARG3) | stw TMP1, 0(CARG3) | b >1 | |->vmeta_tsetb: // TMP0 = index |.if not DUALNUM | tonum_u f0, TMP0 |.endif | decode_RB8 RB, INS | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | add CARG2, BASE, RB |.if DUALNUM | stw TISNUM, 0(CARG3) | stw TMP0, 4(CARG3) |.else | stfd f0, 0(CARG3) |.endif | b >1 | |->vmeta_tsetv: | decode_RB8 RB, INS | decode_RC8 RC, INS | add CARG2, BASE, RB | add CARG3, BASE, RC |1: | stp BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) | // Returns TValue * (finished) or NULL (metamethod). | cmplwi CRET1, 0 | lfdx f0, BASE, RA | beq >3 | // NOBARRIER: lj_meta_tset ensures the table is not black. | ins_next1 | stfd f0, 0(CRET1) | ins_next2 | |3: // Call __newindex metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) | subfic TMP1, BASE, FRAME_CONT | lp BASE, L->top | stw PC, -16(BASE) // [cont|PC] | add PC, TMP1, BASE | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | li NARGS8:RC, 24 // 3 args for func(t, k, v) | stfd f0, 16(BASE) // Copy value to third argument. | b ->vm_call_dispatch_f | |//-- Comparison metamethods --------------------------------------------- | |->vmeta_comp: | mr CARG1, L | subi PC, PC, 4 |.if DUALNUM | mr CARG2, RA |.else | add CARG2, BASE, RA |.endif | stw PC, SAVE_PC |.if DUALNUM | mr CARG3, RD |.else | add CARG3, BASE, RD |.endif | stp BASE, L->base | decode_OP1 CARG4, INS | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) | // Returns 0/1 or TValue * (metamethod). |3: | cmplwi CRET1, 1 | bgt ->vmeta_binop | subfic CRET1, CRET1, 0 |4: | lwz INS, 0(PC) | addi PC, PC, 4 | decode_RD4 TMP2, INS | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) | and TMP2, TMP2, CRET1 | add PC, PC, TMP2 |->cont_nop: | ins_next | |->cont_ra: // RA = resultptr | lwz INS, -4(PC) | lfd f0, 0(RA) | decode_RA8 TMP1, INS | stfdx f0, BASE, TMP1 | b ->cont_nop | |->cont_condt: // RA = resultptr | lwz TMP0, 0(RA) | .gpr64 extsw TMP0, TMP0 | subfic TMP0, TMP0, LJ_TTRUE // Branch if result is true. | subfe CRET1, CRET1, CRET1 | not CRET1, CRET1 | b <4 | |->cont_condf: // RA = resultptr | lwz TMP0, 0(RA) | .gpr64 extsw TMP0, TMP0 | subfic TMP0, TMP0, LJ_TTRUE // Branch if result is false. | subfe CRET1, CRET1, CRET1 | b <4 | |->vmeta_equal: | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. | subi PC, PC, 4 | stp BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) | // Returns 0/1 or TValue * (metamethod). | b <3 | |->vmeta_equal_cd: |.if FFI | mr CARG2, INS | subi PC, PC, 4 | stp BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_equal_cd // (lua_State *L, BCIns op) | // Returns 0/1 or TValue * (metamethod). | b <3 |.endif | |//-- Arithmetic metamethods --------------------------------------------- | |->vmeta_arith_nv: | add CARG3, KBASE, RC | add CARG4, BASE, RB | b >1 |->vmeta_arith_nv2: |.if DUALNUM | mr CARG3, RC | mr CARG4, RB | b >1 |.endif | |->vmeta_unm: | mr CARG3, RD | mr CARG4, RD | b >1 | |->vmeta_arith_vn: | add CARG3, BASE, RB | add CARG4, KBASE, RC | b >1 | |->vmeta_arith_vv: | add CARG3, BASE, RB | add CARG4, BASE, RC |.if DUALNUM | b >1 |.endif |->vmeta_arith_vn2: |->vmeta_arith_vv2: |.if DUALNUM | mr CARG3, RB | mr CARG4, RC |.endif |1: | add CARG2, BASE, RA | stp BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | decode_OP1 CARG5, INS // Caveat: CARG5 overlaps INS. | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) | // Returns NULL (finished) or TValue * (metamethod). | cmplwi CRET1, 0 | beq ->cont_nop | | // Call metamethod for binary op. |->vmeta_binop: | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 | sub TMP1, CRET1, BASE | stw PC, -16(CRET1) // [cont|PC] | mr TMP2, BASE | addi PC, TMP1, FRAME_CONT | mr BASE, CRET1 | li NARGS8:RC, 16 // 2 args for func(o1, o2). | b ->vm_call_dispatch | |->vmeta_len: #if LJ_52 | mr SAVE0, CARG1 #endif | mr CARG2, RD | stp BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_len // (lua_State *L, TValue *o) | // Returns NULL (retry) or TValue * (metamethod base). #if LJ_52 | cmplwi CRET1, 0 | bne ->vmeta_binop // Binop call for compatibility. | mr CARG1, SAVE0 | b ->BC_LEN_Z #else | b ->vmeta_binop // Binop call for compatibility. #endif | |//-- Call metamethod ---------------------------------------------------- | |->vmeta_call: // Resolve and call __call metamethod. | // TMP2 = old base, BASE = new base, RC = nargs*8 | mr CARG1, L | stp TMP2, L->base // This is the callers base! | subi CARG2, BASE, 8 | stw PC, SAVE_PC | add CARG3, BASE, RC | mr SAVE0, NARGS8:RC | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. | ins_call | |->vmeta_callt: // Resolve __call for BC_CALLT. | // BASE = old base, RA = new base, RC = nargs*8 | mr CARG1, L | stp BASE, L->base | subi CARG2, RA, 8 | stw PC, SAVE_PC | add CARG3, RA, RC | mr SAVE0, NARGS8:RC | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) | lwz TMP1, FRAME_PC(BASE) | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. | lwz LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. | b ->BC_CALLT_Z | |//-- Argument coercion for 'for' statement ------------------------------ | |->vmeta_for: | mr CARG1, L | stp BASE, L->base | mr CARG2, RA | stw PC, SAVE_PC | mr SAVE0, INS | bl extern lj_meta_for // (lua_State *L, TValue *base) |.if JIT | decode_OP1 TMP0, SAVE0 |.endif | decode_RA8 RA, SAVE0 |.if JIT | cmpwi TMP0, BC_JFORI |.endif | decode_RD8 RD, SAVE0 |.if JIT | beqy =>BC_JFORI |.endif | b =>BC_FORI | |//----------------------------------------------------------------------- |//-- Fast functions ----------------------------------------------------- |//----------------------------------------------------------------------- | |.macro .ffunc, name |->ff_ .. name: |.endmacro | |.macro .ffunc_1, name |->ff_ .. name: | cmplwi NARGS8:RC, 8 | lwz CARG3, 0(BASE) | lwz CARG1, 4(BASE) | blt ->fff_fallback |.endmacro | |.macro .ffunc_2, name |->ff_ .. name: | cmplwi NARGS8:RC, 16 | lwz CARG3, 0(BASE) | lwz CARG4, 8(BASE) | lwz CARG1, 4(BASE) | lwz CARG2, 12(BASE) | blt ->fff_fallback |.endmacro | |.macro .ffunc_n, name |->ff_ .. name: | cmplwi NARGS8:RC, 8 | lwz CARG3, 0(BASE) | lfd FARG1, 0(BASE) | blt ->fff_fallback | checknum CARG3; bge ->fff_fallback |.endmacro | |.macro .ffunc_nn, name |->ff_ .. name: | cmplwi NARGS8:RC, 16 | lwz CARG3, 0(BASE) | lfd FARG1, 0(BASE) | lwz CARG4, 8(BASE) | lfd FARG2, 8(BASE) | blt ->fff_fallback | checknum CARG3; bge ->fff_fallback | checknum CARG4; bge ->fff_fallback |.endmacro | |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1. |.macro ffgccheck | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) | cmplw TMP0, TMP1 | bgel ->fff_gcstep |.endmacro | |//-- Base library: checks ----------------------------------------------- | |.ffunc_1 assert | li TMP1, LJ_TFALSE | la RA, -8(BASE) | cmplw cr1, CARG3, TMP1 | lwz PC, FRAME_PC(BASE) | bge cr1, ->fff_fallback | stw CARG3, 0(RA) | addi RD, NARGS8:RC, 8 // Compute (nresults+1)*8. | stw CARG1, 4(RA) | beq ->fff_res // Done if exactly 1 argument. | li TMP1, 8 | subi RC, RC, 8 |1: | cmplw TMP1, RC | lfdx f0, BASE, TMP1 | stfdx f0, RA, TMP1 | addi TMP1, TMP1, 8 | bney <1 | b ->fff_res | |.ffunc type | cmplwi NARGS8:RC, 8 | lwz CARG1, 0(BASE) | blt ->fff_fallback | .gpr64 extsw CARG1, CARG1 | subfc TMP0, TISNUM, CARG1 | subfe TMP2, CARG1, CARG1 | orc TMP1, TMP2, TMP0 | addi TMP1, TMP1, ~LJ_TISNUM+1 | slwi TMP1, TMP1, 3 | la TMP2, CFUNC:RB->upvalue | lfdx FARG1, TMP2, TMP1 | b ->fff_resn | |//-- Base library: getters and setters --------------------------------- | |.ffunc_1 getmetatable | checktab CARG3; bne >6 |1: // Field metatable must be at same offset for GCtab and GCudata! | lwz TAB:CARG1, TAB:CARG1->metatable |2: | li CARG3, LJ_TNIL | cmplwi TAB:CARG1, 0 | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) | beq ->fff_restv | lwz TMP0, TAB:CARG1->hmask | li CARG3, LJ_TTAB // Use metatable as default result. | lwz TMP1, STR:RC->hash | lwz NODE:TMP2, TAB:CARG1->node | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | slwi TMP0, TMP1, 5 | slwi TMP1, TMP1, 3 | sub TMP1, TMP0, TMP1 | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) |3: // Rearranged logic, because we expect _not_ to find the key. | lwz CARG4, NODE:TMP2->key | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) | lwz CARG2, NODE:TMP2->val | lwz TMP1, 4+offsetof(Node, val)(NODE:TMP2) | checkstr CARG4; bne >4 | cmpw TMP0, STR:RC; beq >5 |4: | lwz NODE:TMP2, NODE:TMP2->next | cmplwi NODE:TMP2, 0 | beq ->fff_restv // Not found, keep default result. | b <3 |5: | checknil CARG2 | beq ->fff_restv // Ditto for nil value. | mr CARG3, CARG2 // Return value of mt.__metatable. | mr CARG1, TMP1 | b ->fff_restv | |6: | cmpwi CARG3, LJ_TUDATA; beq <1 | .gpr64 extsw CARG3, CARG3 | subfc TMP0, TISNUM, CARG3 | subfe TMP2, CARG3, CARG3 | orc TMP1, TMP2, TMP0 | addi TMP1, TMP1, ~LJ_TISNUM+1 | slwi TMP1, TMP1, 2 | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) | lwzx TAB:CARG1, TMP2, TMP1 | b <2 | |.ffunc_2 setmetatable | // Fast path: no mt for table yet and not clearing the mt. | checktab CARG3; bne ->fff_fallback | lwz TAB:TMP1, TAB:CARG1->metatable | checktab CARG4; bne ->fff_fallback | cmplwi TAB:TMP1, 0 | lbz TMP3, TAB:CARG1->marked | bne ->fff_fallback | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) | stw TAB:CARG2, TAB:CARG1->metatable | beq ->fff_restv | barrierback TAB:CARG1, TMP3, TMP0 | b ->fff_restv | |.ffunc rawget | cmplwi NARGS8:RC, 16 | lwz CARG4, 0(BASE) | lwz TAB:CARG2, 4(BASE) | blt ->fff_fallback | checktab CARG4; bne ->fff_fallback | la CARG3, 8(BASE) | mr CARG1, L | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) | // Returns cTValue *. | lfd FARG1, 0(CRET1) | b ->fff_resn | |//-- Base library: conversions ------------------------------------------ | |.ffunc tonumber | // Only handles the number case inline (without a base argument). | cmplwi NARGS8:RC, 8 | lwz CARG1, 0(BASE) | lfd FARG1, 0(BASE) | bne ->fff_fallback // Exactly one argument. | checknum CARG1; bgt ->fff_fallback | b ->fff_resn | |.ffunc_1 tostring | // Only handles the string or number case inline. | checkstr CARG3 | // A __tostring method in the string base metatable is ignored. | beq ->fff_restv // String key? | // Handle numbers inline, unless a number base metatable is present. | lwz TMP0, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) | checknum CARG3 | cmplwi cr1, TMP0, 0 | stp BASE, L->base // Add frame since C call can throw. | crorc 4*cr0+eq, 4*cr0+gt, 4*cr1+eq | stw PC, SAVE_PC // Redundant (but a defined value). | beq ->fff_fallback | ffgccheck | mr CARG1, L | mr CARG2, BASE |.if DUALNUM | bl extern lj_str_fromnumber // (lua_State *L, cTValue *o) |.else | bl extern lj_str_fromnum // (lua_State *L, lua_Number *np) |.endif | // Returns GCstr *. | li CARG3, LJ_TSTR | b ->fff_restv | |//-- Base library: iterators ------------------------------------------- | |.ffunc next | cmplwi NARGS8:RC, 8 | lwz CARG1, 0(BASE) | lwz TAB:CARG2, 4(BASE) | blt ->fff_fallback | stwx TISNIL, BASE, NARGS8:RC // Set missing 2nd arg to nil. | checktab CARG1 | lwz PC, FRAME_PC(BASE) | bne ->fff_fallback | stp BASE, L->base // Add frame since C call can throw. | mr CARG1, L | stp BASE, L->top // Dummy frame length is ok. | la CARG3, 8(BASE) | stw PC, SAVE_PC | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) | // Returns 0 at end of traversal. | cmplwi CRET1, 0 | li CARG3, LJ_TNIL | beq ->fff_restv // End of traversal: return nil. | lfd f0, 8(BASE) // Copy key and value to results. | la RA, -8(BASE) | lfd f1, 16(BASE) | stfd f0, 0(RA) | li RD, (2+1)*8 | stfd f1, 8(RA) | b ->fff_res | |.ffunc_1 pairs | checktab CARG3 | lwz PC, FRAME_PC(BASE) | bne ->fff_fallback #if LJ_52 | lwz TAB:TMP2, TAB:CARG1->metatable | lfd f0, CFUNC:RB->upvalue[0] | cmplwi TAB:TMP2, 0 | la RA, -8(BASE) | bne ->fff_fallback #else | lfd f0, CFUNC:RB->upvalue[0] | la RA, -8(BASE) #endif | stw TISNIL, 8(BASE) | li RD, (3+1)*8 | stfd f0, 0(RA) | b ->fff_res | |.ffunc ipairs_aux | cmplwi NARGS8:RC, 16 | lwz CARG3, 0(BASE) | lwz TAB:CARG1, 4(BASE) | lwz CARG4, 8(BASE) |.if DUALNUM | lwz TMP2, 12(BASE) |.else | lfd FARG2, 8(BASE) |.endif | blt ->fff_fallback | checktab CARG3 | checknum cr1, CARG4 | lwz PC, FRAME_PC(BASE) |.if DUALNUM | bne ->fff_fallback | bne cr1, ->fff_fallback |.else | lus TMP0, 0x3ff0 | stw ZERO, TMPD_LO | bne ->fff_fallback | stw TMP0, TMPD_HI | bge cr1, ->fff_fallback | lfd FARG1, TMPD | toint TMP2, FARG2, f0 |.endif | lwz TMP0, TAB:CARG1->asize | lwz TMP1, TAB:CARG1->array |.if not DUALNUM | fadd FARG2, FARG2, FARG1 |.endif | addi TMP2, TMP2, 1 | la RA, -8(BASE) | cmplw TMP0, TMP2 |.if DUALNUM | stw TISNUM, 0(RA) | slwi TMP3, TMP2, 3 | stw TMP2, 4(RA) |.else | slwi TMP3, TMP2, 3 | stfd FARG2, 0(RA) |.endif | ble >2 // Not in array part? | lwzx TMP2, TMP1, TMP3 | lfdx f0, TMP1, TMP3 |1: | checknil TMP2 | li RD, (0+1)*8 | beq ->fff_res // End of iteration, return 0 results. | li RD, (2+1)*8 | stfd f0, 8(RA) | b ->fff_res |2: // Check for empty hash part first. Otherwise call C function. | lwz TMP0, TAB:CARG1->hmask | cmplwi TMP0, 0 | li RD, (0+1)*8 | beq ->fff_res | mr CARG2, TMP2 | bl extern lj_tab_getinth // (GCtab *t, int32_t key) | // Returns cTValue * or NULL. | cmplwi CRET1, 0 | li RD, (0+1)*8 | beq ->fff_res | lwz TMP2, 0(CRET1) | lfd f0, 0(CRET1) | b <1 | |.ffunc_1 ipairs | checktab CARG3 | lwz PC, FRAME_PC(BASE) | bne ->fff_fallback #if LJ_52 | lwz TAB:TMP2, TAB:CARG1->metatable | lfd f0, CFUNC:RB->upvalue[0] | cmplwi TAB:TMP2, 0 | la RA, -8(BASE) | bne ->fff_fallback #else | lfd f0, CFUNC:RB->upvalue[0] | la RA, -8(BASE) #endif |.if DUALNUM | stw TISNUM, 8(BASE) |.else | stw ZERO, 8(BASE) |.endif | stw ZERO, 12(BASE) | li RD, (3+1)*8 | stfd f0, 0(RA) | b ->fff_res | |//-- Base library: catch errors ---------------------------------------- | |.ffunc pcall | cmplwi NARGS8:RC, 8 | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) | blt ->fff_fallback | mr TMP2, BASE | la BASE, 8(BASE) | // Remember active hook before pcall. | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 | subi NARGS8:RC, NARGS8:RC, 8 | addi PC, TMP3, 8+FRAME_PCALL | b ->vm_call_dispatch | |.ffunc xpcall | cmplwi NARGS8:RC, 16 | lwz CARG4, 8(BASE) | lfd FARG2, 8(BASE) | lfd FARG1, 0(BASE) | blt ->fff_fallback | lbz TMP1, DISPATCH_GL(hookmask)(DISPATCH) | mr TMP2, BASE | checkfunc CARG4; bne ->fff_fallback // Traceback must be a function. | la BASE, 16(BASE) | // Remember active hook before pcall. | rlwinm TMP1, TMP1, 32-HOOK_ACTIVE_SHIFT, 31, 31 | stfd FARG2, 0(TMP2) // Swap function and traceback. | subi NARGS8:RC, NARGS8:RC, 16 | stfd FARG1, 8(TMP2) | addi PC, TMP1, 16+FRAME_PCALL | b ->vm_call_dispatch | |//-- Coroutine library -------------------------------------------------- | |.macro coroutine_resume_wrap, resume |.if resume |.ffunc_1 coroutine_resume | cmpwi CARG3, LJ_TTHREAD; bne ->fff_fallback |.else |.ffunc coroutine_wrap_aux | lwz L:CARG1, CFUNC:RB->upvalue[0].gcr |.endif | lbz TMP0, L:CARG1->status | lp TMP1, L:CARG1->cframe | lp CARG2, L:CARG1->top | cmplwi cr0, TMP0, LUA_YIELD | lp TMP2, L:CARG1->base | cmplwi cr1, TMP1, 0 | lwz TMP0, L:CARG1->maxstack | cmplw cr7, CARG2, TMP2 | lwz PC, FRAME_PC(BASE) | crorc 4*cr6+lt, 4*cr0+gt, 4*cr1+eq // st>LUA_YIELD || cframe!=0 | add TMP2, CARG2, NARGS8:RC | crandc 4*cr6+gt, 4*cr7+eq, 4*cr0+eq // base==top && st!=LUA_YIELD | cmplw cr1, TMP2, TMP0 | cror 4*cr6+lt, 4*cr6+lt, 4*cr6+gt | stw PC, SAVE_PC | cror 4*cr6+lt, 4*cr6+lt, 4*cr1+gt // cond1 || cond2 || stackov | stp BASE, L->base | blt cr6, ->fff_fallback |1: |.if resume | addi BASE, BASE, 8 // Keep resumed thread in stack for GC. | subi NARGS8:RC, NARGS8:RC, 8 | subi TMP2, TMP2, 8 |.endif | stp TMP2, L:CARG1->top | li TMP1, 0 | stp BASE, L->top |2: // Move args to coroutine. | cmpw TMP1, NARGS8:RC | lfdx f0, BASE, TMP1 | beq >3 | stfdx f0, CARG2, TMP1 | addi TMP1, TMP1, 8 | b <2 |3: | li CARG3, 0 | mr L:SAVE0, L:CARG1 | li CARG4, 0 | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) | // Returns thread status. |4: | lp TMP2, L:SAVE0->base | cmplwi CRET1, LUA_YIELD | lp TMP3, L:SAVE0->top | li_vmstate INTERP | lp BASE, L->base | st_vmstate | bgt >8 | sub RD, TMP3, TMP2 | lwz TMP0, L->maxstack | cmplwi RD, 0 | add TMP1, BASE, RD | beq >6 // No results? | cmplw TMP1, TMP0 | li TMP1, 0 | bgt >9 // Need to grow stack? | | subi TMP3, RD, 8 | stp TMP2, L:SAVE0->top // Clear coroutine stack. |5: // Move results from coroutine. | cmplw TMP1, TMP3 | lfdx f0, TMP2, TMP1 | stfdx f0, BASE, TMP1 | addi TMP1, TMP1, 8 | bne <5 |6: | andix. TMP0, PC, FRAME_TYPE |.if resume | li TMP1, LJ_TTRUE | la RA, -8(BASE) | stw TMP1, -8(BASE) // Prepend true to results. | addi RD, RD, 16 |.else | mr RA, BASE | addi RD, RD, 8 |.endif |7: | stw PC, SAVE_PC | mr MULTRES, RD | beq ->BC_RET_Z | b ->vm_return | |8: // Coroutine returned with error (at co->top-1). |.if resume | andix. TMP0, PC, FRAME_TYPE | la TMP3, -8(TMP3) | li TMP1, LJ_TFALSE | lfd f0, 0(TMP3) | stp TMP3, L:SAVE0->top // Remove error from coroutine stack. | li RD, (2+1)*8 | stw TMP1, -8(BASE) // Prepend false to results. | la RA, -8(BASE) | stfd f0, 0(BASE) // Copy error message. | b <7 |.else | mr CARG1, L | mr CARG2, L:SAVE0 | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) |.endif | |9: // Handle stack expansion on return from yield. | mr CARG1, L | srwi CARG2, RD, 3 | bl extern lj_state_growstack // (lua_State *L, int n) | li CRET1, 0 | b <4 |.endmacro | | coroutine_resume_wrap 1 // coroutine.resume | coroutine_resume_wrap 0 // coroutine.wrap | |.ffunc coroutine_yield | lp TMP0, L->cframe | add TMP1, BASE, NARGS8:RC | stp BASE, L->base | andix. TMP0, TMP0, CFRAME_RESUME | stp TMP1, L->top | li CRET1, LUA_YIELD | beq ->fff_fallback | stp ZERO, L->cframe | stb CRET1, L->status | b ->vm_leave_unw | |//-- Math library ------------------------------------------------------- | |.ffunc_1 math_abs | checknum CARG3 |.if DUALNUM | bne >2 | srawi TMP1, CARG1, 31 | xor TMP2, TMP1, CARG1 |.if GPR64 | lus TMP0, 0x8000 | sub CARG1, TMP2, TMP1 | cmplw CARG1, TMP0 | beq >1 |.else | sub. CARG1, TMP2, TMP1 | blt >1 |.endif |->fff_resi: | lwz PC, FRAME_PC(BASE) | la RA, -8(BASE) | stw TISNUM, -8(BASE) | stw CRET1, -4(BASE) | b ->fff_res1 |1: | lus CARG3, 0x41e0 // 2^31. | li CARG1, 0 | b ->fff_restv |2: |.endif | bge ->fff_fallback | rlwinm CARG3, CARG3, 0, 1, 31 | // Fallthrough. | |->fff_restv: | // CARG3/CARG1 = TValue result. | lwz PC, FRAME_PC(BASE) | stw CARG3, -8(BASE) | la RA, -8(BASE) | stw CARG1, -4(BASE) |->fff_res1: | // RA = results, PC = return. | li RD, (1+1)*8 |->fff_res: | // RA = results, RD = (nresults+1)*8, PC = return. | andix. TMP0, PC, FRAME_TYPE | mr MULTRES, RD | bney ->vm_return | lwz INS, -4(PC) | decode_RB8 RB, INS |5: | cmplw RB, RD // More results expected? | decode_RA8 TMP0, INS | bgt >6 | ins_next1 | // Adjust BASE. KBASE is assumed to be set for the calling frame. | sub BASE, RA, TMP0 | ins_next2 | |6: // Fill up results with nil. | subi TMP1, RD, 8 | addi RD, RD, 8 | stwx TISNIL, RA, TMP1 | b <5 | |.macro math_extern, func | .ffunc_n math_ .. func | blex func | b ->fff_resn |.endmacro | |.macro math_extern2, func | .ffunc_nn math_ .. func | blex func | b ->fff_resn |.endmacro | |.macro math_round, func | .ffunc_1 math_ .. func | checknum CARG3; beqy ->fff_restv | rlwinm TMP2, CARG3, 12, 21, 31 | bge ->fff_fallback | addic. TMP2, TMP2, -1023 // exp = exponent(x) - 1023 | cmplwi cr1, TMP2, 31 // 0 <= exp < 31? | subfic TMP0, TMP2, 31 | blt >3 | slwi TMP1, CARG3, 11 | srwi TMP3, CARG1, 21 | oris TMP1, TMP1, 0x8000 | addi TMP2, TMP2, 1 | or TMP1, TMP1, TMP3 | slwi CARG2, CARG1, 11 | bge cr1, >4 | slw TMP3, TMP1, TMP2 | srw RD, TMP1, TMP0 | or TMP3, TMP3, CARG2 | srawi TMP2, CARG3, 31 |.if "func" == "floor" | and TMP1, TMP3, TMP2 | addic TMP0, TMP1, -1 | subfe TMP1, TMP0, TMP1 | add CARG1, RD, TMP1 | xor CARG1, CARG1, TMP2 | sub CARG1, CARG1, TMP2 | b ->fff_resi |.else | andc TMP1, TMP3, TMP2 | addic TMP0, TMP1, -1 | subfe TMP1, TMP0, TMP1 | add CARG1, RD, TMP1 | cmpw CARG1, RD | xor CARG1, CARG1, TMP2 | sub CARG1, CARG1, TMP2 | bge ->fff_resi | // Overflow to 2^31. | lus CARG3, 0x41e0 // 2^31. | li CARG1, 0 | b ->fff_restv |.endif |3: // |x| < 1 | slwi TMP2, CARG3, 1 | srawi TMP1, CARG3, 31 | or TMP2, CARG1, TMP2 // ztest = (hi+hi) | lo |.if "func" == "floor" | and TMP1, TMP2, TMP1 // (ztest & sign) == 0 ? 0 : -1 | subfic TMP2, TMP1, 0 | subfe CARG1, CARG1, CARG1 |.else | andc TMP1, TMP2, TMP1 // (ztest & ~sign) == 0 ? 0 : 1 | addic TMP2, TMP1, -1 | subfe CARG1, TMP2, TMP1 |.endif | b ->fff_resi |4: // exp >= 31. Check for -(2^31). | xoris TMP1, TMP1, 0x8000 | srawi TMP2, CARG3, 31 |.if "func" == "floor" | or TMP1, TMP1, CARG2 |.endif |.if PPE | orc TMP1, TMP1, TMP2 | cmpwi TMP1, 0 |.else | orc. TMP1, TMP1, TMP2 |.endif | crand 4*cr0+eq, 4*cr0+eq, 4*cr1+eq | lus CARG1, 0x8000 // -(2^31). | beqy ->fff_resi |5: | lfd FARG1, 0(BASE) | blex func | b ->fff_resn |.endmacro | |.if DUALNUM | math_round floor | math_round ceil |.else | // NYI: use internal implementation. | math_extern floor | math_extern ceil |.endif | |.if SQRT |.ffunc_n math_sqrt | fsqrt FARG1, FARG1 | b ->fff_resn |.else | math_extern sqrt |.endif | |.ffunc math_log | cmplwi NARGS8:RC, 8 | lwz CARG3, 0(BASE) | lfd FARG1, 0(BASE) | bne ->fff_fallback // Need exactly 1 argument. | checknum CARG3; bge ->fff_fallback | blex log | b ->fff_resn | | math_extern log10 | math_extern exp | math_extern sin | math_extern cos | math_extern tan | math_extern asin | math_extern acos | math_extern atan | math_extern sinh | math_extern cosh | math_extern tanh | math_extern2 pow | math_extern2 atan2 | math_extern2 fmod | |->ff_math_deg: |.ffunc_n math_rad | lfd FARG2, CFUNC:RB->upvalue[0] | fmul FARG1, FARG1, FARG2 | b ->fff_resn | |.if DUALNUM |.ffunc math_ldexp | cmplwi NARGS8:RC, 16 | lwz CARG3, 0(BASE) | lfd FARG1, 0(BASE) | lwz CARG4, 8(BASE) |.if GPR64 | lwz CARG2, 12(BASE) |.else | lwz CARG1, 12(BASE) |.endif | blt ->fff_fallback | checknum CARG3; bge ->fff_fallback | checknum CARG4; bne ->fff_fallback |.else |.ffunc_nn math_ldexp |.if GPR64 | toint CARG2, FARG2 |.else | toint CARG1, FARG2 |.endif |.endif | blex ldexp | b ->fff_resn | |.ffunc_n math_frexp |.if GPR64 | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) |.else | la CARG1, DISPATCH_GL(tmptv)(DISPATCH) |.endif | lwz PC, FRAME_PC(BASE) | blex frexp | lwz TMP1, DISPATCH_GL(tmptv)(DISPATCH) | la RA, -8(BASE) |.if not DUALNUM | tonum_i FARG2, TMP1 |.endif | stfd FARG1, 0(RA) | li RD, (2+1)*8 |.if DUALNUM | stw TISNUM, 8(RA) | stw TMP1, 12(RA) |.else | stfd FARG2, 8(RA) |.endif | b ->fff_res | |.ffunc_n math_modf |.if GPR64 | la CARG2, -8(BASE) |.else | la CARG1, -8(BASE) |.endif | lwz PC, FRAME_PC(BASE) | blex modf | la RA, -8(BASE) | stfd FARG1, 0(BASE) | li RD, (2+1)*8 | b ->fff_res | |.macro math_minmax, name, ismax |.if DUALNUM | .ffunc_1 name | checknum CARG3 | addi TMP1, BASE, 8 | add TMP2, BASE, NARGS8:RC | bne >4 |1: // Handle integers. | lwz CARG4, 0(TMP1) | cmplw cr1, TMP1, TMP2 | lwz CARG2, 4(TMP1) | bge cr1, ->fff_resi | checknum CARG4 | xoris TMP0, CARG1, 0x8000 | xoris TMP3, CARG2, 0x8000 | bne >3 | subfc TMP3, TMP3, TMP0 | subfe TMP0, TMP0, TMP0 |.if ismax | andc TMP3, TMP3, TMP0 |.else | and TMP3, TMP3, TMP0 |.endif | add CARG1, TMP3, CARG2 |.if GPR64 | rldicl CARG1, CARG1, 0, 32 |.endif | addi TMP1, TMP1, 8 | b <1 |3: | bge ->fff_fallback | // Convert intermediate result to number and continue below. | tonum_i FARG1, CARG1 | lfd FARG2, 0(TMP1) | b >6 |4: | lfd FARG1, 0(BASE) | bge ->fff_fallback |5: // Handle numbers. | lwz CARG4, 0(TMP1) | cmplw cr1, TMP1, TMP2 | lfd FARG2, 0(TMP1) | bge cr1, ->fff_resn | checknum CARG4; bge >7 |6: | fsub f0, FARG1, FARG2 | addi TMP1, TMP1, 8 |.if ismax | fsel FARG1, f0, FARG1, FARG2 |.else | fsel FARG1, f0, FARG2, FARG1 |.endif | b <5 |7: // Convert integer to number and continue above. | lwz CARG2, 4(TMP1) | bne ->fff_fallback | tonum_i FARG2, CARG2 | b <6 |.else | .ffunc_n name | li TMP1, 8 |1: | lwzx CARG2, BASE, TMP1 | lfdx FARG2, BASE, TMP1 | cmplw cr1, TMP1, NARGS8:RC | checknum CARG2 | bge cr1, ->fff_resn | bge ->fff_fallback | fsub f0, FARG1, FARG2 | addi TMP1, TMP1, 8 |.if ismax | fsel FARG1, f0, FARG1, FARG2 |.else | fsel FARG1, f0, FARG2, FARG1 |.endif | b <1 |.endif |.endmacro | | math_minmax math_min, 0 | math_minmax math_max, 1 | |//-- String library ----------------------------------------------------- | |.ffunc_1 string_len | checkstr CARG3; bne ->fff_fallback | lwz CRET1, STR:CARG1->len | b ->fff_resi | |.ffunc string_byte // Only handle the 1-arg case here. | cmplwi NARGS8:RC, 8 | lwz CARG3, 0(BASE) | lwz STR:CARG1, 4(BASE) | bne ->fff_fallback // Need exactly 1 argument. | checkstr CARG3 | bne ->fff_fallback | lwz TMP0, STR:CARG1->len |.if DUALNUM | lbz CARG1, STR:CARG1[1] // Access is always ok (NUL at end). | li RD, (0+1)*8 | lwz PC, FRAME_PC(BASE) | cmplwi TMP0, 0 | la RA, -8(BASE) | beqy ->fff_res | b ->fff_resi |.else | lbz TMP1, STR:CARG1[1] // Access is always ok (NUL at end). | addic TMP3, TMP0, -1 // RD = ((str->len != 0)+1)*8 | subfe RD, TMP3, TMP0 | stw TMP1, TONUM_LO // Inlined tonum_u f0, TMP1. | addi RD, RD, 1 | lfd f0, TONUM_D | la RA, -8(BASE) | lwz PC, FRAME_PC(BASE) | fsub f0, f0, TOBIT | slwi RD, RD, 3 | stfd f0, 0(RA) | b ->fff_res |.endif | |.ffunc string_char // Only handle the 1-arg case here. | ffgccheck | cmplwi NARGS8:RC, 8 | lwz CARG3, 0(BASE) |.if DUALNUM | lwz TMP0, 4(BASE) | bne ->fff_fallback // Exactly 1 argument. | checknum CARG3; bne ->fff_fallback | la CARG2, 7(BASE) |.else | lfd FARG1, 0(BASE) | bne ->fff_fallback // Exactly 1 argument. | checknum CARG3; bge ->fff_fallback | toint TMP0, FARG1 | la CARG2, TMPD_BLO |.endif | li CARG3, 1 | cmplwi TMP0, 255; bgt ->fff_fallback |->fff_newstr: | mr CARG1, L | stp BASE, L->base | stw PC, SAVE_PC | bl extern lj_str_new // (lua_State *L, char *str, size_t l) | // Returns GCstr *. | lp BASE, L->base | li CARG3, LJ_TSTR | b ->fff_restv | |.ffunc string_sub | ffgccheck | cmplwi NARGS8:RC, 16 | lwz CARG3, 16(BASE) |.if not DUALNUM | lfd f0, 16(BASE) |.endif | lwz TMP0, 0(BASE) | lwz STR:CARG1, 4(BASE) | blt ->fff_fallback | lwz CARG2, 8(BASE) |.if DUALNUM | lwz TMP1, 12(BASE) |.else | lfd f1, 8(BASE) |.endif | li TMP2, -1 | beq >1 |.if DUALNUM | checknum CARG3 | lwz TMP2, 20(BASE) | bne ->fff_fallback |1: | checknum CARG2; bne ->fff_fallback |.else | checknum CARG3; bge ->fff_fallback | toint TMP2, f0 |1: | checknum CARG2; bge ->fff_fallback |.endif | checkstr TMP0; bne ->fff_fallback |.if not DUALNUM | toint TMP1, f1 |.endif | lwz TMP0, STR:CARG1->len | cmplw TMP0, TMP2 // len < end? (unsigned compare) | addi TMP3, TMP2, 1 | blt >5 |2: | cmpwi TMP1, 0 // start <= 0? | add TMP3, TMP1, TMP0 | ble >7 |3: | sub CARG3, TMP2, TMP1 | addi CARG2, STR:CARG1, #STR-1 | srawi TMP0, CARG3, 31 | addi CARG3, CARG3, 1 | add CARG2, CARG2, TMP1 | andc CARG3, CARG3, TMP0 |.if GPR64 | rldicl CARG2, CARG2, 0, 32 | rldicl CARG3, CARG3, 0, 32 |.endif | b ->fff_newstr | |5: // Negative end or overflow. | cmpw TMP0, TMP2 // len >= end? (signed compare) | add TMP2, TMP0, TMP3 // Negative end: end = end+len+1. | bge <2 | mr TMP2, TMP0 // Overflow: end = len. | b <2 | |7: // Negative start or underflow. | .gpr64 extsw TMP1, TMP1 | addic CARG3, TMP1, -1 | subfe CARG3, CARG3, CARG3 | srawi CARG2, TMP3, 31 // Note: modifies carry. | andc TMP3, TMP3, CARG3 | andc TMP1, TMP3, CARG2 | addi TMP1, TMP1, 1 // start = 1 + (start ? start+len : 0) | b <3 | |.ffunc string_rep // Only handle the 1-char case inline. | ffgccheck | cmplwi NARGS8:RC, 16 | lwz TMP0, 0(BASE) | lwz STR:CARG1, 4(BASE) | lwz CARG4, 8(BASE) |.if DUALNUM | lwz CARG3, 12(BASE) |.else | lfd FARG2, 8(BASE) |.endif | bne ->fff_fallback // Exactly 2 arguments. | checkstr TMP0; bne ->fff_fallback |.if DUALNUM | checknum CARG4; bne ->fff_fallback |.else | checknum CARG4; bge ->fff_fallback | toint CARG3, FARG2 |.endif | lwz TMP0, STR:CARG1->len | cmpwi CARG3, 0 | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | ble >2 // Count <= 0? (or non-int) | cmplwi TMP0, 1 | subi TMP2, CARG3, 1 | blt >2 // Zero length string? | cmplw cr1, TMP1, CARG3 | bne ->fff_fallback // Fallback for > 1-char strings. | lbz TMP0, STR:CARG1[1] | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | blt cr1, ->fff_fallback |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). | cmplwi TMP2, 0 | stbx TMP0, CARG2, TMP2 | subi TMP2, TMP2, 1 | bne <1 | b ->fff_newstr |2: // Return empty string. | la STR:CARG1, DISPATCH_GL(strempty)(DISPATCH) | li CARG3, LJ_TSTR | b ->fff_restv | |.ffunc string_reverse | ffgccheck | cmplwi NARGS8:RC, 8 | lwz CARG3, 0(BASE) | lwz STR:CARG1, 4(BASE) | blt ->fff_fallback | checkstr CARG3 | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | bne ->fff_fallback | lwz CARG3, STR:CARG1->len | la CARG1, #STR(STR:CARG1) | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | li TMP2, 0 | cmplw TMP1, CARG3 | subi TMP3, CARG3, 1 | blt ->fff_fallback |1: // Reverse string copy. | cmpwi TMP3, 0 | lbzx TMP1, CARG1, TMP2 | blty ->fff_newstr | stbx TMP1, CARG2, TMP3 | subi TMP3, TMP3, 1 | addi TMP2, TMP2, 1 | b <1 | |.macro ffstring_case, name, lo | .ffunc name | ffgccheck | cmplwi NARGS8:RC, 8 | lwz CARG3, 0(BASE) | lwz STR:CARG1, 4(BASE) | blt ->fff_fallback | checkstr CARG3 | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | bne ->fff_fallback | lwz CARG3, STR:CARG1->len | la CARG1, #STR(STR:CARG1) | lp CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | cmplw TMP1, CARG3 | li TMP2, 0 | blt ->fff_fallback |1: // ASCII case conversion. | cmplw TMP2, CARG3 | lbzx TMP1, CARG1, TMP2 | bgey ->fff_newstr | subi TMP0, TMP1, lo | xori TMP3, TMP1, 0x20 | addic TMP0, TMP0, -26 | subfe TMP3, TMP3, TMP3 | rlwinm TMP3, TMP3, 0, 26, 26 // x &= 0x20. | xor TMP1, TMP1, TMP3 | stbx TMP1, CARG2, TMP2 | addi TMP2, TMP2, 1 | b <1 |.endmacro | |ffstring_case string_lower, 65 |ffstring_case string_upper, 97 | |//-- Table library ------------------------------------------------------ | |.ffunc_1 table_getn | checktab CARG3; bne ->fff_fallback | bl extern lj_tab_len // (GCtab *t) | // Returns uint32_t (but less than 2^31). | b ->fff_resi | |//-- Bit library -------------------------------------------------------- | |.macro .ffunc_bit, name |.if DUALNUM | .ffunc_1 bit_..name | checknum CARG3; bnel ->fff_tobit_fb |.else | .ffunc_n bit_..name | fadd FARG1, FARG1, TOBIT | stfd FARG1, TMPD | lwz CARG1, TMPD_LO |.endif |.endmacro | |.macro .ffunc_bit_op, name, ins | .ffunc_bit name | addi TMP1, BASE, 8 | add TMP2, BASE, NARGS8:RC |1: | lwz CARG4, 0(TMP1) | cmplw cr1, TMP1, TMP2 |.if DUALNUM | lwz CARG2, 4(TMP1) |.else | lfd FARG1, 0(TMP1) |.endif | bgey cr1, ->fff_resi | checknum CARG4 |.if DUALNUM | bnel ->fff_bitop_fb |.else | fadd FARG1, FARG1, TOBIT | bge ->fff_fallback | stfd FARG1, TMPD | lwz CARG2, TMPD_LO |.endif | ins CARG1, CARG1, CARG2 | addi TMP1, TMP1, 8 | b <1 |.endmacro | |.ffunc_bit_op band, and |.ffunc_bit_op bor, or |.ffunc_bit_op bxor, xor | |.ffunc_bit bswap | rotlwi TMP0, CARG1, 8 | rlwimi TMP0, CARG1, 24, 0, 7 | rlwimi TMP0, CARG1, 24, 16, 23 | mr CRET1, TMP0 | b ->fff_resi | |.ffunc_bit bnot | not CRET1, CARG1 | b ->fff_resi | |.macro .ffunc_bit_sh, name, ins, shmod |.if DUALNUM | .ffunc_2 bit_..name | checknum CARG3; bnel ->fff_tobit_fb | // Note: no inline conversion from number for 2nd argument! | checknum CARG4; bne ->fff_fallback |.else | .ffunc_nn bit_..name | fadd FARG1, FARG1, TOBIT | fadd FARG2, FARG2, TOBIT | stfd FARG1, TMPD | lwz CARG1, TMPD_LO | stfd FARG2, TMPD | lwz CARG2, TMPD_LO |.endif |.if shmod == 1 | rlwinm CARG2, CARG2, 0, 27, 31 |.elif shmod == 2 | neg CARG2, CARG2 |.endif | ins CRET1, CARG1, CARG2 | b ->fff_resi |.endmacro | |.ffunc_bit_sh lshift, slw, 1 |.ffunc_bit_sh rshift, srw, 1 |.ffunc_bit_sh arshift, sraw, 1 |.ffunc_bit_sh rol, rotlw, 0 |.ffunc_bit_sh ror, rotlw, 2 | |.ffunc_bit tobit |.if DUALNUM | b ->fff_resi |.else |->fff_resi: | tonum_i FARG1, CRET1 |.endif |->fff_resn: | lwz PC, FRAME_PC(BASE) | la RA, -8(BASE) | stfd FARG1, -8(BASE) | b ->fff_res1 | |// Fallback FP number to bit conversion. |->fff_tobit_fb: |.if DUALNUM | lfd FARG1, 0(BASE) | bgt ->fff_fallback | fadd FARG1, FARG1, TOBIT | stfd FARG1, TMPD | lwz CARG1, TMPD_LO | blr |.endif |->fff_bitop_fb: |.if DUALNUM | lfd FARG1, 0(TMP1) | bgt ->fff_fallback | fadd FARG1, FARG1, TOBIT | stfd FARG1, TMPD | lwz CARG2, TMPD_LO | blr |.endif | |//----------------------------------------------------------------------- | |->fff_fallback: // Call fast function fallback handler. | // BASE = new base, RB = CFUNC, RC = nargs*8 | lp TMP3, CFUNC:RB->f | add TMP1, BASE, NARGS8:RC | lwz PC, FRAME_PC(BASE) // Fallback may overwrite PC. | addi TMP0, TMP1, 8*LUA_MINSTACK | lwz TMP2, L->maxstack | stw PC, SAVE_PC // Redundant (but a defined value). | .toc lp TMP3, 0(TMP3) | cmplw TMP0, TMP2 | stp BASE, L->base | stp TMP1, L->top | mr CARG1, L | bgt >5 // Need to grow stack. | mtctr TMP3 | bctrl // (lua_State *L) | // Either throws an error, or recovers and returns -1, 0 or nresults+1. | lp BASE, L->base | cmpwi CRET1, 0 | slwi RD, CRET1, 3 | la RA, -8(BASE) | bgt ->fff_res // Returned nresults+1? |1: // Returned 0 or -1: retry fast path. | lp TMP0, L->top | lwz LFUNC:RB, FRAME_FUNC(BASE) | sub NARGS8:RC, TMP0, BASE | bne ->vm_call_tail // Returned -1? | ins_callt // Returned 0: retry fast path. | |// Reconstruct previous base for vmeta_call during tailcall. |->vm_call_tail: | andix. TMP0, PC, FRAME_TYPE | rlwinm TMP1, PC, 0, 0, 28 | bne >3 | lwz INS, -4(PC) | decode_RA8 TMP1, INS | addi TMP1, TMP1, 8 |3: | sub TMP2, BASE, TMP1 | b ->vm_call_dispatch // Resolve again for tailcall. | |5: // Grow stack for fallback handler. | li CARG2, LUA_MINSTACK | bl extern lj_state_growstack // (lua_State *L, int n) | lp BASE, L->base | cmpw TMP0, TMP0 // Set 4*cr0+eq to force retry. | b <1 | |->fff_gcstep: // Call GC step function. | // BASE = new base, RC = nargs*8 | mflr SAVE0 | stp BASE, L->base | add TMP0, BASE, NARGS8:RC | stw PC, SAVE_PC // Redundant (but a defined value). | stp TMP0, L->top | mr CARG1, L | bl extern lj_gc_step // (lua_State *L) | lp BASE, L->base | mtlr SAVE0 | lp TMP0, L->top | sub NARGS8:RC, TMP0, BASE | lwz CFUNC:RB, FRAME_FUNC(BASE) | blr | |//----------------------------------------------------------------------- |//-- Special dispatch targets ------------------------------------------- |//----------------------------------------------------------------------- | |->vm_record: // Dispatch target for recording phase. |.if JIT | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) | andix. TMP0, TMP3, HOOK_VMEVENT // No recording while in vmevent. | bne >5 | // Decrement the hookcount for consistency, but always do the call. | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) | andix. TMP0, TMP3, HOOK_ACTIVE | bne >1 | subi TMP2, TMP2, 1 | andi. TMP0, TMP3, LUA_MASKLINE|LUA_MASKCOUNT | beqy >1 | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) | b >1 |.endif | |->vm_rethook: // Dispatch target for return hooks. | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) | andix. TMP0, TMP3, HOOK_ACTIVE // Hook already active? | beq >1 |5: // Re-dispatch to static ins. | addi TMP1, TMP1, GG_DISP2STATIC // Assumes decode_OPP TMP1, INS. | lpx TMP0, DISPATCH, TMP1 | mtctr TMP0 | bctr | |->vm_inshook: // Dispatch target for instr/line hooks. | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) | andix. TMP0, TMP3, HOOK_ACTIVE // Hook already active? | rlwinm TMP0, TMP3, 31-LUA_HOOKLINE, 31, 0 | bne <5 | | cmpwi cr1, TMP0, 0 | addic. TMP2, TMP2, -1 | beq cr1, <5 | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) | beq >1 | bge cr1, <5 |1: | mr CARG1, L | stw MULTRES, SAVE_MULTRES | mr CARG2, PC | stp BASE, L->base | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) |3: | lp BASE, L->base |4: // Re-dispatch to static ins. | lwz INS, -4(PC) | decode_OPP TMP1, INS | decode_RB8 RB, INS | addi TMP1, TMP1, GG_DISP2STATIC | decode_RD8 RD, INS | lpx TMP0, DISPATCH, TMP1 | decode_RA8 RA, INS | decode_RC8 RC, INS | mtctr TMP0 | bctr | |->cont_hook: // Continue from hook yield. | addi PC, PC, 4 | lwz MULTRES, -20(RB) // Restore MULTRES for *M ins. | b <4 | |->vm_hotloop: // Hot loop counter underflow. |.if JIT | lwz LFUNC:TMP1, FRAME_FUNC(BASE) | addi CARG1, DISPATCH, GG_DISP2J | stw PC, SAVE_PC | lwz TMP1, LFUNC:TMP1->pc | mr CARG2, PC | stw L, DISPATCH_J(L)(DISPATCH) | lbz TMP1, PC2PROTO(framesize)(TMP1) | stp BASE, L->base | slwi TMP1, TMP1, 3 | add TMP1, BASE, TMP1 | stp TMP1, L->top | bl extern lj_trace_hot // (jit_State *J, const BCIns *pc) | b <3 |.endif | |->vm_callhook: // Dispatch target for call hooks. | mr CARG2, PC |.if JIT | b >1 |.endif | |->vm_hotcall: // Hot call counter underflow. |.if JIT | ori CARG2, PC, 1 |1: |.endif | add TMP0, BASE, RC | stw PC, SAVE_PC | mr CARG1, L | stp BASE, L->base | sub RA, RA, BASE | stp TMP0, L->top | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) | // Returns ASMFunction. | lp BASE, L->base | lp TMP0, L->top | stw ZERO, SAVE_PC // Invalidate for subsequent line hook. | sub NARGS8:RC, TMP0, BASE | add RA, BASE, RA | lwz LFUNC:RB, FRAME_FUNC(BASE) | lwz INS, -4(PC) | mtctr CRET1 | bctr | |//----------------------------------------------------------------------- |//-- Trace exit handler ------------------------------------------------- |//----------------------------------------------------------------------- | |.macro savex_, a, b, c, d | stfd f..a, 16+a*8(sp) | stfd f..b, 16+b*8(sp) | stfd f..c, 16+c*8(sp) | stfd f..d, 16+d*8(sp) |.endmacro | |->vm_exit_handler: |.if JIT | addi sp, sp, -(16+32*8+32*4) | stmw r2, 16+32*8+2*4(sp) | addi DISPATCH, JGL, -GG_DISP2G-32768 | li CARG2, ~LJ_VMST_EXIT | lwz CARG1, 16+32*8+32*4(sp) // Get stack chain. | stw CARG2, DISPATCH_GL(vmstate)(DISPATCH) | savex_ 0,1,2,3 | stw CARG1, 0(sp) // Store extended stack chain. | mcrxr cr0 // Clear SO flag. | savex_ 4,5,6,7 | addi CARG2, sp, 16+32*8+32*4 // Recompute original value of sp. | savex_ 8,9,10,11 | stw CARG2, 16+32*8+1*4(sp) // Store sp in RID_SP. | savex_ 12,13,14,15 | mflr CARG3 | li TMP1, 0 | savex_ 16,17,18,19 | stw TMP1, 16+32*8+0*4(sp) // Clear RID_TMP. | savex_ 20,21,22,23 | lhz CARG4, 2(CARG3) // Load trace number. | savex_ 24,25,26,27 | lwz L, DISPATCH_GL(jit_L)(DISPATCH) | savex_ 28,29,30,31 | sub CARG3, TMP0, CARG3 // Compute exit number. | lp BASE, DISPATCH_GL(jit_base)(DISPATCH) | srwi CARG3, CARG3, 2 | stw L, DISPATCH_J(L)(DISPATCH) | subi CARG3, CARG3, 2 | stw TMP1, DISPATCH_GL(jit_L)(DISPATCH) | stw CARG4, DISPATCH_J(parent)(DISPATCH) | stp BASE, L->base | addi CARG1, DISPATCH, GG_DISP2J | stw CARG3, DISPATCH_J(exitno)(DISPATCH) | addi CARG2, sp, 16 | bl extern lj_trace_exit // (jit_State *J, ExitState *ex) | // Returns MULTRES (unscaled) or negated error code. | lp TMP1, L->cframe | lwz TMP2, 0(sp) | lp BASE, L->base |.if GPR64 | rldicr sp, TMP1, 0, 61 |.else | rlwinm sp, TMP1, 0, 0, 29 |.endif | lwz PC, SAVE_PC // Get SAVE_PC. | stw TMP2, 0(sp) | stw L, SAVE_L // Set SAVE_L (on-trace resume/yield). | b >1 |.endif |->vm_exit_interp: |.if JIT | // CARG1 = MULTRES or negated error code, BASE, PC and JGL set. | lwz L, SAVE_L | addi DISPATCH, JGL, -GG_DISP2G-32768 |1: | cmpwi CARG1, 0 | blt >3 // Check for error from exit. | lwz LFUNC:TMP1, FRAME_FUNC(BASE) | slwi MULTRES, CARG1, 3 | li TMP2, 0 | stw MULTRES, SAVE_MULTRES | lwz TMP1, LFUNC:TMP1->pc | stw TMP2, DISPATCH_GL(jit_L)(DISPATCH) | lwz KBASE, PC2PROTO(k)(TMP1) | // Setup type comparison constants. | li TISNUM, LJ_TISNUM | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | stw TMP3, TMPD | li ZERO, 0 | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). | lfs TOBIT, TMPD | stw TMP3, TMPD | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) | li TISNIL, LJ_TNIL | stw TMP0, TONUM_HI | lfs TONUM, TMPD | // Modified copy of ins_next which handles function header dispatch, too. | lwz INS, 0(PC) | addi PC, PC, 4 | // Assumes TISNIL == ~LJ_VMST_INTERP == -1. | stw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) | decode_OPP TMP1, INS | decode_RA8 RA, INS | lpx TMP0, DISPATCH, TMP1 | mtctr TMP0 | cmplwi TMP1, BC_FUNCF*4 // Function header? | bge >2 | decode_RB8 RB, INS | decode_RD8 RD, INS | decode_RC8 RC, INS | bctr |2: | subi RC, MULTRES, 8 | add RA, RA, BASE | bctr | |3: // Rethrow error from the right C frame. | neg CARG2, CARG1 | mr CARG1, L | bl extern lj_err_throw // (lua_State *L, int errcode) |.endif | |//----------------------------------------------------------------------- |//-- Math helper functions ---------------------------------------------- |//----------------------------------------------------------------------- | |// NYI: Use internal implementations of floor, ceil, trunc. | |->vm_modi: | divwo. TMP0, CARG1, CARG2 | bso >1 |.if GPR64 | xor CARG3, CARG1, CARG2 | cmpwi CARG3, 0 |.else | xor. CARG3, CARG1, CARG2 |.endif | mullw TMP0, TMP0, CARG2 | sub CARG1, CARG1, TMP0 | bgelr | cmpwi CARG1, 0; beqlr | add CARG1, CARG1, CARG2 | blr |1: | cmpwi CARG2, 0 | li CARG1, 0 | beqlr | mcrxr cr0 // Clear SO for -2147483648 % -1 and return 0. | blr | |//----------------------------------------------------------------------- |//-- Miscellaneous functions -------------------------------------------- |//----------------------------------------------------------------------- | |// void lj_vm_cachesync(void *start, void *end) |// Flush D-Cache and invalidate I-Cache. Assumes 32 byte cache line size. |// This is a good lower bound, except for very ancient PPC models. |->vm_cachesync: |.if JIT or FFI | // Compute start of first cache line and number of cache lines. | rlwinm CARG1, CARG1, 0, 0, 26 | sub CARG2, CARG2, CARG1 | addi CARG2, CARG2, 31 | rlwinm. CARG2, CARG2, 27, 5, 31 | beqlr | mtctr CARG2 | mr CARG3, CARG1 |1: // Flush D-Cache. | dcbst r0, CARG1 | addi CARG1, CARG1, 32 | bdnz <1 | sync | mtctr CARG2 |1: // Invalidate I-Cache. | icbi r0, CARG3 | addi CARG3, CARG3, 32 | bdnz <1 | isync | blr |.endif | |//----------------------------------------------------------------------- |//-- FFI helper functions ----------------------------------------------- |//----------------------------------------------------------------------- | |// Handler for callback functions. Callback slot number in r11, g in r12. |->vm_ffi_callback: |.if FFI |.type CTSTATE, CTState, PC | saveregs | lwz CTSTATE, GL:r12->ctype_state | addi DISPATCH, r12, GG_G2DISP | stw r11, CTSTATE->cb.slot | stw r3, CTSTATE->cb.gpr[0] | stfd f1, CTSTATE->cb.fpr[0] | stw r4, CTSTATE->cb.gpr[1] | stfd f2, CTSTATE->cb.fpr[1] | stw r5, CTSTATE->cb.gpr[2] | stfd f3, CTSTATE->cb.fpr[2] | stw r6, CTSTATE->cb.gpr[3] | stfd f4, CTSTATE->cb.fpr[3] | stw r7, CTSTATE->cb.gpr[4] | stfd f5, CTSTATE->cb.fpr[4] | stw r8, CTSTATE->cb.gpr[5] | stfd f6, CTSTATE->cb.fpr[5] | stw r9, CTSTATE->cb.gpr[6] | stfd f7, CTSTATE->cb.fpr[6] | stw r10, CTSTATE->cb.gpr[7] | stfd f8, CTSTATE->cb.fpr[7] | addi TMP0, sp, CFRAME_SPACE+8 | stw TMP0, CTSTATE->cb.stack | mr CARG1, CTSTATE | stw CTSTATE, SAVE_PC // Any value outside of bytecode is ok. | mr CARG2, sp | bl extern lj_ccallback_enter // (CTState *cts, void *cf) | // Returns lua_State *. | lp BASE, L:CRET1->base | li TISNUM, LJ_TISNUM // Setup type comparison constants. | lp RC, L:CRET1->top | lus TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | li ZERO, 0 | mr L, CRET1 | stw TMP3, TMPD | lus TMP0, 0x4338 // Hiword of 2^52 + 2^51 (double) | lwz LFUNC:RB, FRAME_FUNC(BASE) | ori TMP3, TMP3, 0x0004 // TONUM = 2^52 + 2^51 + 2^31 (float). | stw TMP0, TONUM_HI | li TISNIL, LJ_TNIL | li_vmstate INTERP | lfs TOBIT, TMPD | stw TMP3, TMPD | sub RC, RC, BASE | st_vmstate | lfs TONUM, TMPD | ins_callt |.endif | |->cont_ffi_callback: // Return from FFI callback. |.if FFI | lwz CTSTATE, DISPATCH_GL(ctype_state)(DISPATCH) | stp BASE, L->base | stp RB, L->top | stp L, CTSTATE->L | mr CARG1, CTSTATE | mr CARG2, RA | bl extern lj_ccallback_leave // (CTState *cts, TValue *o) | lwz CRET1, CTSTATE->cb.gpr[0] | lfd FARG1, CTSTATE->cb.fpr[0] | lwz CRET2, CTSTATE->cb.gpr[1] | b ->vm_leave_unw |.endif | |->vm_ffi_call: // Call C function via FFI. | // Caveat: needs special frame unwinding, see below. |.if FFI | .type CCSTATE, CCallState, CARG1 | lwz TMP1, CCSTATE->spadj | mflr TMP0 | lbz CARG2, CCSTATE->nsp | lbz CARG3, CCSTATE->nfpr | neg TMP1, TMP1 | stw TMP0, 4(sp) | cmpwi cr1, CARG3, 0 | mr TMP2, sp | addic. CARG2, CARG2, -1 | stwux sp, sp, TMP1 | crnot 4*cr1+eq, 4*cr1+eq // For vararg calls. | stw r14, -4(TMP2) | stw CCSTATE, -8(TMP2) | mr r14, TMP2 | la TMP1, CCSTATE->stack | slwi CARG2, CARG2, 2 | blty >2 | la TMP2, 8(sp) |1: | lwzx TMP0, TMP1, CARG2 | stwx TMP0, TMP2, CARG2 | addic. CARG2, CARG2, -4 | bge <1 |2: | bney cr1, >3 | lfd f1, CCSTATE->fpr[0] | lfd f2, CCSTATE->fpr[1] | lfd f3, CCSTATE->fpr[2] | lfd f4, CCSTATE->fpr[3] | lfd f5, CCSTATE->fpr[4] | lfd f6, CCSTATE->fpr[5] | lfd f7, CCSTATE->fpr[6] | lfd f8, CCSTATE->fpr[7] |3: | lp TMP0, CCSTATE->func | lwz CARG2, CCSTATE->gpr[1] | lwz CARG3, CCSTATE->gpr[2] | lwz CARG4, CCSTATE->gpr[3] | lwz CARG5, CCSTATE->gpr[4] | mtctr TMP0 | lwz r8, CCSTATE->gpr[5] | lwz r9, CCSTATE->gpr[6] | lwz r10, CCSTATE->gpr[7] | lwz CARG1, CCSTATE->gpr[0] // Do this last, since CCSTATE is CARG1. | bctrl | lwz CCSTATE:TMP1, -8(r14) | lwz TMP2, -4(r14) | lwz TMP0, 4(r14) | stw CARG1, CCSTATE:TMP1->gpr[0] | stfd FARG1, CCSTATE:TMP1->fpr[0] | stw CARG2, CCSTATE:TMP1->gpr[1] | mtlr TMP0 | stw CARG3, CCSTATE:TMP1->gpr[2] | mr sp, r14 | stw CARG4, CCSTATE:TMP1->gpr[3] | mr r14, TMP2 | blr |.endif |// Note: vm_ffi_call must be the last function in this object file! | |//----------------------------------------------------------------------- } /* Generate the code for a single instruction. */ static void build_ins(BuildCtx *ctx, BCOp op, int defop) { int vk = 0; |=>defop: switch (op) { /* -- Comparison ops ---------------------------------------------------- */ /* Remember: all ops branch for a true comparison, fall through otherwise. */ case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: | // RA = src1*8, RD = src2*8, JMP with RD = target |.if DUALNUM | lwzux TMP0, RA, BASE | addi PC, PC, 4 | lwz CARG2, 4(RA) | lwzux TMP1, RD, BASE | lwz TMP2, -4(PC) | checknum cr0, TMP0 | lwz CARG3, 4(RD) | decode_RD4 TMP2, TMP2 | checknum cr1, TMP1 | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) | bne cr0, >7 | bne cr1, >8 | cmpw CARG2, CARG3 if (op == BC_ISLT) { | bge >2 } else if (op == BC_ISGE) { | blt >2 } else if (op == BC_ISLE) { | bgt >2 } else { | ble >2 } |1: | add PC, PC, TMP2 |2: | ins_next | |7: // RA is not an integer. | bgt cr0, ->vmeta_comp | // RA is a number. | lfd f0, 0(RA) | bgt cr1, ->vmeta_comp | blt cr1, >4 | // RA is a number, RD is an integer. | tonum_i f1, CARG3 | b >5 | |8: // RA is an integer, RD is not an integer. | bgt cr1, ->vmeta_comp | // RA is an integer, RD is a number. | tonum_i f0, CARG2 |4: | lfd f1, 0(RD) |5: | fcmpu cr0, f0, f1 if (op == BC_ISLT) { | bge <2 } else if (op == BC_ISGE) { | blt <2 } else if (op == BC_ISLE) { | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq | bge <2 } else { | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq | blt <2 } | b <1 |.else | lwzx TMP0, BASE, RA | addi PC, PC, 4 | lfdx f0, BASE, RA | lwzx TMP1, BASE, RD | checknum cr0, TMP0 | lwz TMP2, -4(PC) | lfdx f1, BASE, RD | checknum cr1, TMP1 | decode_RD4 TMP2, TMP2 | bge cr0, ->vmeta_comp | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) | bge cr1, ->vmeta_comp | fcmpu cr0, f0, f1 if (op == BC_ISLT) { | bge >1 } else if (op == BC_ISGE) { | blt >1 } else if (op == BC_ISLE) { | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq | bge >1 } else { | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+eq | blt >1 } | add PC, PC, TMP2 |1: | ins_next |.endif break; case BC_ISEQV: case BC_ISNEV: vk = op == BC_ISEQV; | // RA = src1*8, RD = src2*8, JMP with RD = target |.if DUALNUM | lwzux TMP0, RA, BASE | addi PC, PC, 4 | lwz CARG2, 4(RA) | lwzux TMP1, RD, BASE | checknum cr0, TMP0 | lwz TMP2, -4(PC) | checknum cr1, TMP1 | decode_RD4 TMP2, TMP2 | lwz CARG3, 4(RD) | cror 4*cr7+gt, 4*cr0+gt, 4*cr1+gt | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) if (vk) { | ble cr7, ->BC_ISEQN_Z } else { | ble cr7, ->BC_ISNEN_Z } |.else | lwzux TMP0, RA, BASE | lwz TMP2, 0(PC) | lfd f0, 0(RA) | addi PC, PC, 4 | lwzux TMP1, RD, BASE | checknum cr0, TMP0 | decode_RD4 TMP2, TMP2 | lfd f1, 0(RD) | checknum cr1, TMP1 | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) | bge cr0, >5 | bge cr1, >5 | fcmpu cr0, f0, f1 if (vk) { | bne >1 | add PC, PC, TMP2 } else { | beq >1 | add PC, PC, TMP2 } |1: | ins_next |.endif |5: // Either or both types are not numbers. |.if not DUALNUM | lwz CARG2, 4(RA) | lwz CARG3, 4(RD) |.endif |.if FFI | cmpwi cr7, TMP0, LJ_TCDATA | cmpwi cr5, TMP1, LJ_TCDATA |.endif | not TMP3, TMP0 | cmplw TMP0, TMP1 | cmplwi cr1, TMP3, ~LJ_TISPRI // Primitive? |.if FFI | cror 4*cr7+eq, 4*cr7+eq, 4*cr5+eq |.endif | cmplwi cr6, TMP3, ~LJ_TISTABUD // Table or userdata? |.if FFI | beq cr7, ->vmeta_equal_cd |.endif | cmplw cr5, CARG2, CARG3 | crandc 4*cr0+gt, 4*cr0+eq, 4*cr1+gt // 2: Same type and primitive. | crorc 4*cr0+lt, 4*cr5+eq, 4*cr0+eq // 1: Same tv or different type. | crand 4*cr0+eq, 4*cr0+eq, 4*cr5+eq // 0: Same type and same tv. | mr SAVE0, PC | cror 4*cr0+eq, 4*cr0+eq, 4*cr0+gt // 0 or 2. | cror 4*cr0+lt, 4*cr0+lt, 4*cr0+gt // 1 or 2. if (vk) { | bne cr0, >6 | add PC, PC, TMP2 |6: } else { | beq cr0, >6 | add PC, PC, TMP2 |6: } |.if DUALNUM | bge cr0, >2 // Done if 1 or 2. |1: | ins_next |2: |.else | blt cr0, <1 // Done if 1 or 2. |.endif | blt cr6, <1 // Done if not tab/ud. | | // Different tables or userdatas. Need to check __eq metamethod. | // Field metatable must be at same offset for GCtab and GCudata! | lwz TAB:TMP2, TAB:CARG2->metatable | li CARG4, 1-vk // ne = 0 or 1. | cmplwi TAB:TMP2, 0 | beq <1 // No metatable? | lbz TMP2, TAB:TMP2->nomm | andix. TMP2, TMP2, 1<vmeta_equal // Handle __eq metamethod. break; case BC_ISEQS: case BC_ISNES: vk = op == BC_ISEQS; | // RA = src*8, RD = str_const*8 (~), JMP with RD = target | lwzux TMP0, RA, BASE | srwi RD, RD, 1 | lwz STR:TMP3, 4(RA) | lwz TMP2, 0(PC) | subfic RD, RD, -4 | addi PC, PC, 4 |.if FFI | cmpwi TMP0, LJ_TCDATA |.endif | lwzx STR:TMP1, KBASE, RD // KBASE-4-str_const*4 | .gpr64 extsw TMP0, TMP0 | subfic TMP0, TMP0, LJ_TSTR |.if FFI | beq ->vmeta_equal_cd |.endif | sub TMP1, STR:TMP1, STR:TMP3 | or TMP0, TMP0, TMP1 | decode_RD4 TMP2, TMP2 | subfic TMP0, TMP0, 0 | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) | subfe TMP1, TMP1, TMP1 if (vk) { | andc TMP2, TMP2, TMP1 } else { | and TMP2, TMP2, TMP1 } | add PC, PC, TMP2 | ins_next break; case BC_ISEQN: case BC_ISNEN: vk = op == BC_ISEQN; | // RA = src*8, RD = num_const*8, JMP with RD = target |.if DUALNUM | lwzux TMP0, RA, BASE | addi PC, PC, 4 | lwz CARG2, 4(RA) | lwzux TMP1, RD, KBASE | checknum cr0, TMP0 | lwz TMP2, -4(PC) | checknum cr1, TMP1 | decode_RD4 TMP2, TMP2 | lwz CARG3, 4(RD) | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) if (vk) { |->BC_ISEQN_Z: } else { |->BC_ISNEN_Z: } | bne cr0, >7 | bne cr1, >8 | cmpw CARG2, CARG3 |4: |.else if (vk) { |->BC_ISEQN_Z: // Dummy label. } else { |->BC_ISNEN_Z: // Dummy label. } | lwzx TMP0, BASE, RA | addi PC, PC, 4 | lfdx f0, BASE, RA | lwz TMP2, -4(PC) | lfdx f1, KBASE, RD | decode_RD4 TMP2, TMP2 | checknum TMP0 | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) | bge >3 | fcmpu cr0, f0, f1 |.endif if (vk) { | bne >1 | add PC, PC, TMP2 |1: |.if not FFI |3: |.endif } else { | beq >2 |1: |.if not FFI |3: |.endif | add PC, PC, TMP2 |2: } | ins_next |.if FFI |3: | cmpwi TMP0, LJ_TCDATA | beq ->vmeta_equal_cd | b <1 |.endif |.if DUALNUM |7: // RA is not an integer. | bge cr0, <3 | // RA is a number. | lfd f0, 0(RA) | blt cr1, >1 | // RA is a number, RD is an integer. | tonum_i f1, CARG3 | b >2 | |8: // RA is an integer, RD is a number. | tonum_i f0, CARG2 |1: | lfd f1, 0(RD) |2: | fcmpu cr0, f0, f1 | b <4 |.endif break; case BC_ISEQP: case BC_ISNEP: vk = op == BC_ISEQP; | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target | lwzx TMP0, BASE, RA | srwi TMP1, RD, 3 | lwz TMP2, 0(PC) | not TMP1, TMP1 | addi PC, PC, 4 |.if FFI | cmpwi TMP0, LJ_TCDATA |.endif | sub TMP0, TMP0, TMP1 |.if FFI | beq ->vmeta_equal_cd |.endif | decode_RD4 TMP2, TMP2 | .gpr64 extsw TMP0, TMP0 | addic TMP0, TMP0, -1 | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) | subfe TMP1, TMP1, TMP1 if (vk) { | and TMP2, TMP2, TMP1 } else { | andc TMP2, TMP2, TMP1 } | add PC, PC, TMP2 | ins_next break; /* -- Unary test and copy ops ------------------------------------------- */ case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: | // RA = dst*8 or unused, RD = src*8, JMP with RD = target | lwzx TMP0, BASE, RD | lwz INS, 0(PC) | addi PC, PC, 4 if (op == BC_IST || op == BC_ISF) { | .gpr64 extsw TMP0, TMP0 | subfic TMP0, TMP0, LJ_TTRUE | decode_RD4 TMP2, INS | subfe TMP1, TMP1, TMP1 | addis TMP2, TMP2, -(BCBIAS_J*4 >> 16) if (op == BC_IST) { | andc TMP2, TMP2, TMP1 } else { | and TMP2, TMP2, TMP1 } | add PC, PC, TMP2 } else { | li TMP1, LJ_TFALSE | lfdx f0, BASE, RD | cmplw TMP0, TMP1 if (op == BC_ISTC) { | bge >1 } else { | blt >1 } | addis PC, PC, -(BCBIAS_J*4 >> 16) | decode_RD4 TMP2, INS | stfdx f0, BASE, RA | add PC, PC, TMP2 |1: } | ins_next break; /* -- Unary ops --------------------------------------------------------- */ case BC_MOV: | // RA = dst*8, RD = src*8 | ins_next1 | lfdx f0, BASE, RD | stfdx f0, BASE, RA | ins_next2 break; case BC_NOT: | // RA = dst*8, RD = src*8 | ins_next1 | lwzx TMP0, BASE, RD | .gpr64 extsw TMP0, TMP0 | subfic TMP1, TMP0, LJ_TTRUE | adde TMP0, TMP0, TMP1 | stwx TMP0, BASE, RA | ins_next2 break; case BC_UNM: | // RA = dst*8, RD = src*8 | lwzux TMP1, RD, BASE | lwz TMP0, 4(RD) | checknum TMP1 |.if DUALNUM | bne >5 |.if GPR64 | lus TMP2, 0x8000 | neg TMP0, TMP0 | cmplw TMP0, TMP2 | beq >4 |.else | nego. TMP0, TMP0 | bso >4 |1: |.endif | ins_next1 | stwux TISNUM, RA, BASE | stw TMP0, 4(RA) |3: | ins_next2 |4: |.if not GPR64 | // Potential overflow. | mcrxr cr0; bley <1 // Ignore unrelated overflow. |.endif | lus TMP1, 0x41e0 // 2^31. | li TMP0, 0 | b >7 |.endif |5: | bge ->vmeta_unm | xoris TMP1, TMP1, 0x8000 |7: | ins_next1 | stwux TMP1, RA, BASE | stw TMP0, 4(RA) |.if DUALNUM | b <3 |.else | ins_next2 |.endif break; case BC_LEN: | // RA = dst*8, RD = src*8 | lwzux TMP0, RD, BASE | lwz CARG1, 4(RD) | checkstr TMP0; bne >2 | lwz CRET1, STR:CARG1->len |1: |.if DUALNUM | ins_next1 | stwux TISNUM, RA, BASE | stw CRET1, 4(RA) |.else | tonum_u f0, CRET1 // Result is a non-negative integer. | ins_next1 | stfdx f0, BASE, RA |.endif | ins_next2 |2: | checktab TMP0; bne ->vmeta_len #if LJ_52 | lwz TAB:TMP2, TAB:CARG1->metatable | cmplwi TAB:TMP2, 0 | bne >9 |3: #endif |->BC_LEN_Z: | bl extern lj_tab_len // (GCtab *t) | // Returns uint32_t (but less than 2^31). | b <1 #if LJ_52 |9: | lbz TMP0, TAB:TMP2->nomm | andix. TMP0, TMP0, 1<vmeta_len #endif break; /* -- Binary ops -------------------------------------------------------- */ |.macro ins_arithpre | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); ||switch (vk) { ||case 0: | lwzx TMP1, BASE, RB | .if DUALNUM | lwzx TMP2, KBASE, RC | .endif | lfdx f14, BASE, RB | lfdx f15, KBASE, RC | .if DUALNUM | checknum cr0, TMP1 | checknum cr1, TMP2 | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt | bge ->vmeta_arith_vn | .else | checknum TMP1; bge ->vmeta_arith_vn | .endif || break; ||case 1: | lwzx TMP1, BASE, RB | .if DUALNUM | lwzx TMP2, KBASE, RC | .endif | lfdx f15, BASE, RB | lfdx f14, KBASE, RC | .if DUALNUM | checknum cr0, TMP1 | checknum cr1, TMP2 | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt | bge ->vmeta_arith_nv | .else | checknum TMP1; bge ->vmeta_arith_nv | .endif || break; ||default: | lwzx TMP1, BASE, RB | lwzx TMP2, BASE, RC | lfdx f14, BASE, RB | lfdx f15, BASE, RC | checknum cr0, TMP1 | checknum cr1, TMP2 | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt | bge ->vmeta_arith_vv || break; ||} |.endmacro | |.macro ins_arithfallback, ins ||switch (vk) { ||case 0: | ins ->vmeta_arith_vn2 || break; ||case 1: | ins ->vmeta_arith_nv2 || break; ||default: | ins ->vmeta_arith_vv2 || break; ||} |.endmacro | |.macro intmod, a, b, c | bl ->vm_modi |.endmacro | |.macro fpmod, a, b, c |->BC_MODVN_Z: | fdiv FARG1, b, c | // NYI: Use internal implementation of floor. | blex floor // floor(b/c) | fmul a, FARG1, c | fsub a, b, a // b - floor(b/c)*c |.endmacro | |.macro ins_arithfp, fpins | ins_arithpre |.if "fpins" == "fpmod_" | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. |.else | fpins f0, f14, f15 | ins_next1 | stfdx f0, BASE, RA | ins_next2 |.endif |.endmacro | |.macro ins_arithdn, intins, fpins | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); ||switch (vk) { ||case 0: | lwzux TMP1, RB, BASE | lwzux TMP2, RC, KBASE | lwz CARG1, 4(RB) | checknum cr0, TMP1 | lwz CARG2, 4(RC) || break; ||case 1: | lwzux TMP1, RB, BASE | lwzux TMP2, RC, KBASE | lwz CARG2, 4(RB) | checknum cr0, TMP1 | lwz CARG1, 4(RC) || break; ||default: | lwzux TMP1, RB, BASE | lwzux TMP2, RC, BASE | lwz CARG1, 4(RB) | checknum cr0, TMP1 | lwz CARG2, 4(RC) || break; ||} | checknum cr1, TMP2 | bne >5 | bne cr1, >5 | intins CARG1, CARG1, CARG2 | bso >4 |1: | ins_next1 | stwux TISNUM, RA, BASE | stw CARG1, 4(RA) |2: | ins_next2 |4: // Overflow. | mcrxr cr0; bley <1 // Ignore unrelated overflow. | ins_arithfallback b |5: // FP variant. ||if (vk == 1) { | lfd f15, 0(RB) | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt | lfd f14, 0(RC) ||} else { | lfd f14, 0(RB) | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt | lfd f15, 0(RC) ||} | ins_arithfallback bge |.if "fpins" == "fpmod_" | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. |.else | fpins f0, f14, f15 | ins_next1 | stfdx f0, BASE, RA | b <2 |.endif |.endmacro | |.macro ins_arith, intins, fpins |.if DUALNUM | ins_arithdn intins, fpins |.else | ins_arithfp fpins |.endif |.endmacro case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: |.if GPR64 |.macro addo32., y, a, b | // Need to check overflow for (a<<32) + (b<<32). | rldicr TMP0, a, 32, 31 | rldicr TMP3, b, 32, 31 | addo. TMP0, TMP0, TMP3 | add y, a, b |.endmacro | ins_arith addo32., fadd |.else | ins_arith addo., fadd |.endif break; case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: |.if GPR64 |.macro subo32., y, a, b | // Need to check overflow for (a<<32) - (b<<32). | rldicr TMP0, a, 32, 31 | rldicr TMP3, b, 32, 31 | subo. TMP0, TMP0, TMP3 | sub y, a, b |.endmacro | ins_arith subo32., fsub |.else | ins_arith subo., fsub |.endif break; case BC_MULVN: case BC_MULNV: case BC_MULVV: | ins_arith mullwo., fmul break; case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: | ins_arithfp fdiv break; case BC_MODVN: | ins_arith intmod, fpmod break; case BC_MODNV: case BC_MODVV: | ins_arith intmod, fpmod_ break; case BC_POW: | // NYI: (partial) integer arithmetic. | lwzx TMP1, BASE, RB | lfdx FARG1, BASE, RB | lwzx TMP2, BASE, RC | lfdx FARG2, BASE, RC | checknum cr0, TMP1 | checknum cr1, TMP2 | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt | bge ->vmeta_arith_vv | blex pow | ins_next1 | stfdx FARG1, BASE, RA | ins_next2 break; case BC_CAT: | // RA = dst*8, RB = src_start*8, RC = src_end*8 | sub CARG3, RC, RB | stp BASE, L->base | add CARG2, BASE, RC | mr SAVE0, RB |->BC_CAT_Z: | stw PC, SAVE_PC | mr CARG1, L | srwi CARG3, CARG3, 3 | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) | // Returns NULL (finished) or TValue * (metamethod). | cmplwi CRET1, 0 | lp BASE, L->base | bne ->vmeta_binop | ins_next1 | lfdx f0, BASE, SAVE0 // Copy result from RB to RA. | stfdx f0, BASE, RA | ins_next2 break; /* -- Constant ops ------------------------------------------------------ */ case BC_KSTR: | // RA = dst*8, RD = str_const*8 (~) | srwi TMP1, RD, 1 | subfic TMP1, TMP1, -4 | ins_next1 | lwzx TMP0, KBASE, TMP1 // KBASE-4-str_const*4 | li TMP2, LJ_TSTR | stwux TMP2, RA, BASE | stw TMP0, 4(RA) | ins_next2 break; case BC_KCDATA: |.if FFI | // RA = dst*8, RD = cdata_const*8 (~) | srwi TMP1, RD, 1 | subfic TMP1, TMP1, -4 | ins_next1 | lwzx TMP0, KBASE, TMP1 // KBASE-4-cdata_const*4 | li TMP2, LJ_TCDATA | stwux TMP2, RA, BASE | stw TMP0, 4(RA) | ins_next2 |.endif break; case BC_KSHORT: | // RA = dst*8, RD = int16_literal*8 |.if DUALNUM | slwi RD, RD, 13 | srawi RD, RD, 16 | ins_next1 | stwux TISNUM, RA, BASE | stw RD, 4(RA) | ins_next2 |.else | // The soft-float approach is faster. | slwi RD, RD, 13 | srawi TMP1, RD, 31 | xor TMP2, TMP1, RD | sub TMP2, TMP2, TMP1 // TMP2 = abs(x) | cntlzw TMP3, TMP2 | subfic TMP1, TMP3, 0x40d // TMP1 = exponent-1 | slw TMP2, TMP2, TMP3 // TMP2 = left aligned mantissa | subfic TMP3, RD, 0 | slwi TMP1, TMP1, 20 | rlwimi RD, TMP2, 21, 1, 31 // hi = sign(x) | (mantissa>>11) | subfe TMP0, TMP0, TMP0 | add RD, RD, TMP1 // hi = hi + exponent-1 | and RD, RD, TMP0 // hi = x == 0 ? 0 : hi | ins_next1 | stwux RD, RA, BASE | stw ZERO, 4(RA) | ins_next2 |.endif break; case BC_KNUM: | // RA = dst*8, RD = num_const*8 | ins_next1 | lfdx f0, KBASE, RD | stfdx f0, BASE, RA | ins_next2 break; case BC_KPRI: | // RA = dst*8, RD = primitive_type*8 (~) | srwi TMP1, RD, 3 | not TMP0, TMP1 | ins_next1 | stwx TMP0, BASE, RA | ins_next2 break; case BC_KNIL: | // RA = base*8, RD = end*8 | stwx TISNIL, BASE, RA | addi RA, RA, 8 |1: | stwx TISNIL, BASE, RA | cmpw RA, RD | addi RA, RA, 8 | blt <1 | ins_next_ break; /* -- Upvalue and function ops ------------------------------------------ */ case BC_UGET: | // RA = dst*8, RD = uvnum*8 | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi RD, RD, 1 | addi RD, RD, offsetof(GCfuncL, uvptr) | lwzx UPVAL:RB, LFUNC:RB, RD | ins_next1 | lwz TMP1, UPVAL:RB->v | lfd f0, 0(TMP1) | stfdx f0, BASE, RA | ins_next2 break; case BC_USETV: | // RA = uvnum*8, RD = src*8 | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi RA, RA, 1 | addi RA, RA, offsetof(GCfuncL, uvptr) | lfdux f0, RD, BASE | lwzx UPVAL:RB, LFUNC:RB, RA | lbz TMP3, UPVAL:RB->marked | lwz CARG2, UPVAL:RB->v | andix. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) | lbz TMP0, UPVAL:RB->closed | lwz TMP2, 0(RD) | stfd f0, 0(CARG2) | cmplwi cr1, TMP0, 0 | lwz TMP1, 4(RD) | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq | subi TMP2, TMP2, (LJ_TISNUM+1) | bne >2 // Upvalue is closed and black? |1: | ins_next | |2: // Check if new value is collectable. | cmplwi TMP2, LJ_TISGCV - (LJ_TISNUM+1) | bge <1 // tvisgcv(v) | lbz TMP3, GCOBJ:TMP1->gch.marked | andix. TMP3, TMP3, LJ_GC_WHITES // iswhite(v) | la CARG1, GG_DISP2G(DISPATCH) | // Crossed a write barrier. Move the barrier forward. | beq <1 | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) | b <1 break; case BC_USETS: | // RA = uvnum*8, RD = str_const*8 (~) | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi TMP1, RD, 1 | srwi RA, RA, 1 | subfic TMP1, TMP1, -4 | addi RA, RA, offsetof(GCfuncL, uvptr) | lwzx STR:TMP1, KBASE, TMP1 // KBASE-4-str_const*4 | lwzx UPVAL:RB, LFUNC:RB, RA | lbz TMP3, UPVAL:RB->marked | lwz CARG2, UPVAL:RB->v | andix. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) | lbz TMP3, STR:TMP1->marked | lbz TMP2, UPVAL:RB->closed | li TMP0, LJ_TSTR | stw STR:TMP1, 4(CARG2) | stw TMP0, 0(CARG2) | bne >2 |1: | ins_next | |2: // Check if string is white and ensure upvalue is closed. | andix. TMP3, TMP3, LJ_GC_WHITES // iswhite(str) | cmplwi cr1, TMP2, 0 | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq | la CARG1, GG_DISP2G(DISPATCH) | // Crossed a write barrier. Move the barrier forward. | beq <1 | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) | b <1 break; case BC_USETN: | // RA = uvnum*8, RD = num_const*8 | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi RA, RA, 1 | addi RA, RA, offsetof(GCfuncL, uvptr) | lfdx f0, KBASE, RD | lwzx UPVAL:RB, LFUNC:RB, RA | ins_next1 | lwz TMP1, UPVAL:RB->v | stfd f0, 0(TMP1) | ins_next2 break; case BC_USETP: | // RA = uvnum*8, RD = primitive_type*8 (~) | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi RA, RA, 1 | srwi TMP0, RD, 3 | addi RA, RA, offsetof(GCfuncL, uvptr) | not TMP0, TMP0 | lwzx UPVAL:RB, LFUNC:RB, RA | ins_next1 | lwz TMP1, UPVAL:RB->v | stw TMP0, 0(TMP1) | ins_next2 break; case BC_UCLO: | // RA = level*8, RD = target | lwz TMP1, L->openupval | branch_RD // Do this first since RD is not saved. | stp BASE, L->base | cmplwi TMP1, 0 | mr CARG1, L | beq >1 | add CARG2, BASE, RA | bl extern lj_func_closeuv // (lua_State *L, TValue *level) | lp BASE, L->base |1: | ins_next break; case BC_FNEW: | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) | srwi TMP1, RD, 1 | stp BASE, L->base | subfic TMP1, TMP1, -4 | stw PC, SAVE_PC | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 | mr CARG1, L | lwz CARG3, FRAME_FUNC(BASE) | // (lua_State *L, GCproto *pt, GCfuncL *parent) | bl extern lj_func_newL_gc | // Returns GCfuncL *. | lp BASE, L->base | li TMP0, LJ_TFUNC | stwux TMP0, RA, BASE | stw LFUNC:CRET1, 4(RA) | ins_next break; /* -- Table ops --------------------------------------------------------- */ case BC_TNEW: case BC_TDUP: | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) | mr CARG1, L | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) | stp BASE, L->base | cmplw TMP0, TMP1 | stw PC, SAVE_PC | bge >5 |1: if (op == BC_TNEW) { | rlwinm CARG2, RD, 29, 21, 31 | rlwinm CARG3, RD, 18, 27, 31 | cmpwi CARG2, 0x7ff; beq >3 |2: | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) | // Returns Table *. } else { | srwi TMP1, RD, 1 | subfic TMP1, TMP1, -4 | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 | bl extern lj_tab_dup // (lua_State *L, Table *kt) | // Returns Table *. } | lp BASE, L->base | li TMP0, LJ_TTAB | stwux TMP0, RA, BASE | stw TAB:CRET1, 4(RA) | ins_next if (op == BC_TNEW) { |3: | li CARG2, 0x801 | b <2 } |5: | mr SAVE0, RD | bl extern lj_gc_step_fixtop // (lua_State *L) | mr RD, SAVE0 | mr CARG1, L | b <1 break; case BC_GGET: | // RA = dst*8, RD = str_const*8 (~) case BC_GSET: | // RA = src*8, RD = str_const*8 (~) | lwz LFUNC:TMP2, FRAME_FUNC(BASE) | srwi TMP1, RD, 1 | lwz TAB:RB, LFUNC:TMP2->env | subfic TMP1, TMP1, -4 | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 if (op == BC_GGET) { | b ->BC_TGETS_Z } else { | b ->BC_TSETS_Z } break; case BC_TGETV: | // RA = dst*8, RB = table*8, RC = key*8 | lwzux CARG1, RB, BASE | lwzux CARG2, RC, BASE | lwz TAB:RB, 4(RB) |.if DUALNUM | lwz RC, 4(RC) |.else | lfd f0, 0(RC) |.endif | checktab CARG1 | checknum cr1, CARG2 | bne ->vmeta_tgetv |.if DUALNUM | lwz TMP0, TAB:RB->asize | bne cr1, >5 | lwz TMP1, TAB:RB->array | cmplw TMP0, RC | slwi TMP2, RC, 3 |.else | bge cr1, >5 | // Convert number key to integer, check for integerness and range. | fctiwz f1, f0 | fadd f2, f0, TOBIT | stfd f1, TMPD | lwz TMP0, TAB:RB->asize | fsub f2, f2, TOBIT | lwz TMP2, TMPD_LO | lwz TMP1, TAB:RB->array | fcmpu cr1, f0, f2 | cmplw cr0, TMP0, TMP2 | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+eq | slwi TMP2, TMP2, 3 |.endif | ble ->vmeta_tgetv // Integer key and in array part? | lwzx TMP0, TMP1, TMP2 | lfdx f14, TMP1, TMP2 | checknil TMP0; beq >2 |1: | ins_next1 | stfdx f14, BASE, RA | ins_next2 | |2: // Check for __index if table value is nil. | lwz TAB:TMP2, TAB:RB->metatable | cmplwi TAB:TMP2, 0 | beq <1 // No metatable: done. | lbz TMP0, TAB:TMP2->nomm | andix. TMP0, TMP0, 1<vmeta_tgetv | |5: | checkstr CARG2; bne ->vmeta_tgetv |.if not DUALNUM | lwz STR:RC, 4(RC) |.endif | b ->BC_TGETS_Z // String key? break; case BC_TGETS: | // RA = dst*8, RB = table*8, RC = str_const*8 (~) | lwzux CARG1, RB, BASE | srwi TMP1, RC, 1 | lwz TAB:RB, 4(RB) | subfic TMP1, TMP1, -4 | checktab CARG1 | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 | bne ->vmeta_tgets1 |->BC_TGETS_Z: | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 | lwz TMP0, TAB:RB->hmask | lwz TMP1, STR:RC->hash | lwz NODE:TMP2, TAB:RB->node | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | slwi TMP0, TMP1, 5 | slwi TMP1, TMP1, 3 | sub TMP1, TMP0, TMP1 | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) |1: | lwz CARG1, NODE:TMP2->key | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) | lwz CARG2, NODE:TMP2->val | lwz TMP1, 4+offsetof(Node, val)(NODE:TMP2) | checkstr CARG1; bne >4 | cmpw TMP0, STR:RC; bne >4 | checknil CARG2; beq >5 // Key found, but nil value? |3: | stwux CARG2, RA, BASE | stw TMP1, 4(RA) | ins_next | |4: // Follow hash chain. | lwz NODE:TMP2, NODE:TMP2->next | cmplwi NODE:TMP2, 0 | bne <1 | // End of hash chain: key not found, nil result. | li CARG2, LJ_TNIL | |5: // Check for __index if table value is nil. | lwz TAB:TMP2, TAB:RB->metatable | cmplwi TAB:TMP2, 0 | beq <3 // No metatable: done. | lbz TMP0, TAB:TMP2->nomm | andix. TMP0, TMP0, 1<vmeta_tgets break; case BC_TGETB: | // RA = dst*8, RB = table*8, RC = index*8 | lwzux CARG1, RB, BASE | srwi TMP0, RC, 3 | lwz TAB:RB, 4(RB) | checktab CARG1; bne ->vmeta_tgetb | lwz TMP1, TAB:RB->asize | lwz TMP2, TAB:RB->array | cmplw TMP0, TMP1; bge ->vmeta_tgetb | lwzx TMP1, TMP2, RC | lfdx f0, TMP2, RC | checknil TMP1; beq >5 |1: | ins_next1 | stfdx f0, BASE, RA | ins_next2 | |5: // Check for __index if table value is nil. | lwz TAB:TMP2, TAB:RB->metatable | cmplwi TAB:TMP2, 0 | beq <1 // No metatable: done. | lbz TMP2, TAB:TMP2->nomm | andix. TMP2, TMP2, 1<vmeta_tgetb // Caveat: preserve TMP0! break; case BC_TSETV: | // RA = src*8, RB = table*8, RC = key*8 | lwzux CARG1, RB, BASE | lwzux CARG2, RC, BASE | lwz TAB:RB, 4(RB) |.if DUALNUM | lwz RC, 4(RC) |.else | lfd f0, 0(RC) |.endif | checktab CARG1 | checknum cr1, CARG2 | bne ->vmeta_tsetv |.if DUALNUM | lwz TMP0, TAB:RB->asize | bne cr1, >5 | lwz TMP1, TAB:RB->array | cmplw TMP0, RC | slwi TMP0, RC, 3 |.else | bge cr1, >5 | // Convert number key to integer, check for integerness and range. | fctiwz f1, f0 | fadd f2, f0, TOBIT | stfd f1, TMPD | lwz TMP0, TAB:RB->asize | fsub f2, f2, TOBIT | lwz TMP2, TMPD_LO | lwz TMP1, TAB:RB->array | fcmpu cr1, f0, f2 | cmplw cr0, TMP0, TMP2 | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+eq | slwi TMP0, TMP2, 3 |.endif | ble ->vmeta_tsetv // Integer key and in array part? | lwzx TMP2, TMP1, TMP0 | lbz TMP3, TAB:RB->marked | lfdx f14, BASE, RA | checknil TMP2; beq >3 |1: | andix. TMP2, TMP3, LJ_GC_BLACK // isblack(table) | stfdx f14, TMP1, TMP0 | bne >7 |2: | ins_next | |3: // Check for __newindex if previous value is nil. | lwz TAB:TMP2, TAB:RB->metatable | cmplwi TAB:TMP2, 0 | beq <1 // No metatable: done. | lbz TMP2, TAB:TMP2->nomm | andix. TMP2, TMP2, 1<vmeta_tsetv | |5: | checkstr CARG2; bne ->vmeta_tsetv |.if not DUALNUM | lwz STR:RC, 4(RC) |.endif | b ->BC_TSETS_Z // String key? | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0 | b <2 break; case BC_TSETS: | // RA = src*8, RB = table*8, RC = str_const*8 (~) | lwzux CARG1, RB, BASE | srwi TMP1, RC, 1 | lwz TAB:RB, 4(RB) | subfic TMP1, TMP1, -4 | checktab CARG1 | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 | bne ->vmeta_tsets1 |->BC_TSETS_Z: | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = src*8 | lwz TMP0, TAB:RB->hmask | lwz TMP1, STR:RC->hash | lwz NODE:TMP2, TAB:RB->node | stb ZERO, TAB:RB->nomm // Clear metamethod cache. | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | lfdx f14, BASE, RA | slwi TMP0, TMP1, 5 | slwi TMP1, TMP1, 3 | sub TMP1, TMP0, TMP1 | lbz TMP3, TAB:RB->marked | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) |1: | lwz CARG1, NODE:TMP2->key | lwz TMP0, 4+offsetof(Node, key)(NODE:TMP2) | lwz CARG2, NODE:TMP2->val | lwz NODE:TMP1, NODE:TMP2->next | checkstr CARG1; bne >5 | cmpw TMP0, STR:RC; bne >5 | checknil CARG2; beq >4 // Key found, but nil value? |2: | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) | stfd f14, NODE:TMP2->val | bne >7 |3: | ins_next | |4: // Check for __newindex if previous value is nil. | lwz TAB:TMP1, TAB:RB->metatable | cmplwi TAB:TMP1, 0 | beq <2 // No metatable: done. | lbz TMP0, TAB:TMP1->nomm | andix. TMP0, TMP0, 1<vmeta_tsets | |5: // Follow hash chain. | cmplwi NODE:TMP1, 0 | mr NODE:TMP2, NODE:TMP1 | bne <1 | // End of hash chain: key not found, add a new one. | | // But check for __newindex first. | lwz TAB:TMP1, TAB:RB->metatable | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | stw PC, SAVE_PC | mr CARG1, L | cmplwi TAB:TMP1, 0 | stp BASE, L->base | beq >6 // No metatable: continue. | lbz TMP0, TAB:TMP1->nomm | andix. TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. |6: | li TMP0, LJ_TSTR | stw STR:RC, 4(CARG3) | mr CARG2, TAB:RB | stw TMP0, 0(CARG3) | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) | // Returns TValue *. | lp BASE, L->base | stfd f14, 0(CRET1) | b <3 // No 2nd write barrier needed. | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0 | b <3 break; case BC_TSETB: | // RA = src*8, RB = table*8, RC = index*8 | lwzux CARG1, RB, BASE | srwi TMP0, RC, 3 | lwz TAB:RB, 4(RB) | checktab CARG1; bne ->vmeta_tsetb | lwz TMP1, TAB:RB->asize | lwz TMP2, TAB:RB->array | lbz TMP3, TAB:RB->marked | cmplw TMP0, TMP1 | lfdx f14, BASE, RA | bge ->vmeta_tsetb | lwzx TMP1, TMP2, RC | checknil TMP1; beq >5 |1: | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) | stfdx f14, TMP2, RC | bne >7 |2: | ins_next | |5: // Check for __newindex if previous value is nil. | lwz TAB:TMP1, TAB:RB->metatable | cmplwi TAB:TMP1, 0 | beq <1 // No metatable: done. | lbz TMP1, TAB:TMP1->nomm | andix. TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0 | b <2 break; case BC_TSETM: | // RA = base*8 (table at base-1), RD = num_const*8 (start index) | add RA, BASE, RA |1: | add TMP3, KBASE, RD | lwz TAB:CARG2, -4(RA) // Guaranteed to be a table. | addic. TMP0, MULTRES, -8 | lwz TMP3, 4(TMP3) // Integer constant is in lo-word. | srwi CARG3, TMP0, 3 | beq >4 // Nothing to copy? | add CARG3, CARG3, TMP3 | lwz TMP2, TAB:CARG2->asize | slwi TMP1, TMP3, 3 | lbz TMP3, TAB:CARG2->marked | cmplw CARG3, TMP2 | add TMP2, RA, TMP0 | lwz TMP0, TAB:CARG2->array | bgt >5 | add TMP1, TMP1, TMP0 | andix. TMP0, TMP3, LJ_GC_BLACK // isblack(table) |3: // Copy result slots to table. | lfd f0, 0(RA) | addi RA, RA, 8 | cmpw cr1, RA, TMP2 | stfd f0, 0(TMP1) | addi TMP1, TMP1, 8 | blt cr1, <3 | bne >7 |4: | ins_next | |5: // Need to resize array part. | stp BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | mr SAVE0, RD | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) | // Must not reallocate the stack. | mr RD, SAVE0 | b <1 | |7: // Possible table write barrier for any value. Skip valiswhite check. | barrierback TAB:CARG2, TMP3, TMP0 | b <4 break; /* -- Calls and vararg handling ----------------------------------------- */ case BC_CALLM: | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 | add NARGS8:RC, NARGS8:RC, MULTRES | // Fall through. Assumes BC_CALL follows. break; case BC_CALL: | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 | mr TMP2, BASE | lwzux TMP0, BASE, RA | lwz LFUNC:RB, 4(BASE) | subi NARGS8:RC, NARGS8:RC, 8 | addi BASE, BASE, 8 | checkfunc TMP0; bne ->vmeta_call | ins_call break; case BC_CALLMT: | // RA = base*8, (RB = 0,) RC = extra_nargs*8 | add NARGS8:RC, NARGS8:RC, MULTRES | // Fall through. Assumes BC_CALLT follows. break; case BC_CALLT: | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 | lwzux TMP0, RA, BASE | lwz LFUNC:RB, 4(RA) | subi NARGS8:RC, NARGS8:RC, 8 | lwz TMP1, FRAME_PC(BASE) | checkfunc TMP0 | addi RA, RA, 8 | bne ->vmeta_callt |->BC_CALLT_Z: | andix. TMP0, TMP1, FRAME_TYPE // Caveat: preserve cr0 until the crand. | lbz TMP3, LFUNC:RB->ffid | xori TMP2, TMP1, FRAME_VARG | cmplwi cr1, NARGS8:RC, 0 | bne >7 |1: | stw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. | li TMP2, 0 | cmplwi cr7, TMP3, 1 // (> FF_C) Calling a fast function? | beq cr1, >3 |2: | addi TMP3, TMP2, 8 | lfdx f0, RA, TMP2 | cmplw cr1, TMP3, NARGS8:RC | stfdx f0, BASE, TMP2 | mr TMP2, TMP3 | bne cr1, <2 |3: | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+gt | beq >5 |4: | ins_callt | |5: // Tailcall to a fast function with a Lua frame below. | lwz INS, -4(TMP1) | decode_RA8 RA, INS | sub TMP1, BASE, RA | lwz LFUNC:TMP1, FRAME_FUNC-8(TMP1) | lwz TMP1, LFUNC:TMP1->pc | lwz KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. | b <4 | |7: // Tailcall from a vararg function. | andix. TMP0, TMP2, FRAME_TYPEP | bne <1 // Vararg frame below? | sub BASE, BASE, TMP2 // Relocate BASE down. | lwz TMP1, FRAME_PC(BASE) | andix. TMP0, TMP1, FRAME_TYPE | b <1 break; case BC_ITERC: | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) | mr TMP2, BASE | add BASE, BASE, RA | lwz TMP1, -24(BASE) | lwz LFUNC:RB, -20(BASE) | lfd f1, -8(BASE) | lfd f0, -16(BASE) | stw TMP1, 0(BASE) // Copy callable. | stw LFUNC:RB, 4(BASE) | checkfunc TMP1 | stfd f1, 16(BASE) // Copy control var. | li NARGS8:RC, 16 // Iterators get 2 arguments. | stfdu f0, 8(BASE) // Copy state. | bne ->vmeta_call | ins_call break; case BC_ITERN: | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) |.if JIT | // NYI: add hotloop, record BC_ITERN. |.endif | add RA, BASE, RA | lwz TAB:RB, -12(RA) | lwz RC, -4(RA) // Get index from control var. | lwz TMP0, TAB:RB->asize | lwz TMP1, TAB:RB->array | addi PC, PC, 4 |1: // Traverse array part. | cmplw RC, TMP0 | slwi TMP3, RC, 3 | bge >5 // Index points after array part? | lwzx TMP2, TMP1, TMP3 | lfdx f0, TMP1, TMP3 | checknil TMP2 | lwz INS, -4(PC) | beq >4 |.if DUALNUM | stw RC, 4(RA) | stw TISNUM, 0(RA) |.else | tonum_u f1, RC |.endif | addi RC, RC, 1 | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | stfd f0, 8(RA) | decode_RD4 TMP1, INS | stw RC, -4(RA) // Update control var. | add PC, TMP1, TMP3 |.if not DUALNUM | stfd f1, 0(RA) |.endif |3: | ins_next | |4: // Skip holes in array part. | addi RC, RC, 1 | b <1 | |5: // Traverse hash part. | lwz TMP1, TAB:RB->hmask | sub RC, RC, TMP0 | lwz TMP2, TAB:RB->node |6: | cmplw RC, TMP1 // End of iteration? Branch to ITERL+1. | slwi TMP3, RC, 5 | bgty <3 | slwi RB, RC, 3 | sub TMP3, TMP3, RB | lwzx RB, TMP2, TMP3 | lfdx f0, TMP2, TMP3 | add NODE:TMP3, TMP2, TMP3 | checknil RB | lwz INS, -4(PC) | beq >7 | lfd f1, NODE:TMP3->key | addis TMP2, PC, -(BCBIAS_J*4 >> 16) | stfd f0, 8(RA) | add RC, RC, TMP0 | decode_RD4 TMP1, INS | stfd f1, 0(RA) | addi RC, RC, 1 | add PC, TMP1, TMP2 | stw RC, -4(RA) // Update control var. | b <3 | |7: // Skip holes in hash part. | addi RC, RC, 1 | b <6 break; case BC_ISNEXT: | // RA = base*8, RD = target (points to ITERN) | add RA, BASE, RA | lwz TMP0, -24(RA) | lwz CFUNC:TMP1, -20(RA) | lwz TMP2, -16(RA) | lwz TMP3, -8(RA) | cmpwi cr0, TMP2, LJ_TTAB | cmpwi cr1, TMP0, LJ_TFUNC | cmpwi cr6, TMP3, LJ_TNIL | bne cr1, >5 | lbz TMP1, CFUNC:TMP1->ffid | crand 4*cr0+eq, 4*cr0+eq, 4*cr6+eq | cmpwi cr7, TMP1, FF_next_N | srwi TMP0, RD, 1 | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq | add TMP3, PC, TMP0 | bne cr0, >5 | lus TMP1, 0xfffe | ori TMP1, TMP1, 0x7fff | stw ZERO, -4(RA) // Initialize control var. | stw TMP1, -8(RA) | addis PC, TMP3, -(BCBIAS_J*4 >> 16) |1: | ins_next |5: // Despecialize bytecode if any of the checks fail. | li TMP0, BC_JMP | li TMP1, BC_ITERC | stb TMP0, -1(PC) | addis PC, TMP3, -(BCBIAS_J*4 >> 16) | stb TMP1, 3(PC) | b <1 break; case BC_VARG: | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 | lwz TMP0, FRAME_PC(BASE) | add RC, BASE, RC | add RA, BASE, RA | addi RC, RC, FRAME_VARG | add TMP2, RA, RB | subi TMP3, BASE, 8 // TMP3 = vtop | sub RC, RC, TMP0 // RC = vbase | // Note: RC may now be even _above_ BASE if nargs was < numparams. | cmplwi cr1, RB, 0 |.if PPE | sub TMP1, TMP3, RC | cmpwi TMP1, 0 |.else | sub. TMP1, TMP3, RC |.endif | beq cr1, >5 // Copy all varargs? | subi TMP2, TMP2, 16 | ble >2 // No vararg slots? |1: // Copy vararg slots to destination slots. | lfd f0, 0(RC) | addi RC, RC, 8 | stfd f0, 0(RA) | cmplw RA, TMP2 | cmplw cr1, RC, TMP3 | bge >3 // All destination slots filled? | addi RA, RA, 8 | blt cr1, <1 // More vararg slots? |2: // Fill up remainder with nil. | stw TISNIL, 0(RA) | cmplw RA, TMP2 | addi RA, RA, 8 | blt <2 |3: | ins_next | |5: // Copy all varargs. | lwz TMP0, L->maxstack | li MULTRES, 8 // MULTRES = (0+1)*8 | bley <3 // No vararg slots? | add TMP2, RA, TMP1 | cmplw TMP2, TMP0 | addi MULTRES, TMP1, 8 | bgt >7 |6: | lfd f0, 0(RC) | addi RC, RC, 8 | stfd f0, 0(RA) | cmplw RC, TMP3 | addi RA, RA, 8 | blt <6 // More vararg slots? | b <3 | |7: // Grow stack for varargs. | mr CARG1, L | stp RA, L->top | sub SAVE0, RC, BASE // Need delta, because BASE may change. | stp BASE, L->base | sub RA, RA, BASE | stw PC, SAVE_PC | srwi CARG2, TMP1, 3 | bl extern lj_state_growstack // (lua_State *L, int n) | lp BASE, L->base | add RA, BASE, RA | add RC, BASE, SAVE0 | subi TMP3, BASE, 8 | b <6 break; /* -- Returns ----------------------------------------------------------- */ case BC_RETM: | // RA = results*8, RD = extra_nresults*8 | add RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. | // Fall through. Assumes BC_RET follows. break; case BC_RET: | // RA = results*8, RD = (nresults+1)*8 | lwz PC, FRAME_PC(BASE) | add RA, BASE, RA | mr MULTRES, RD |1: | andix. TMP0, PC, FRAME_TYPE | xori TMP1, PC, FRAME_VARG | bne ->BC_RETV_Z | |->BC_RET_Z: | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return | lwz INS, -4(PC) | cmpwi RD, 8 | subi TMP2, BASE, 8 | subi RC, RD, 8 | decode_RB8 RB, INS | beq >3 | li TMP1, 0 |2: | addi TMP3, TMP1, 8 | lfdx f0, RA, TMP1 | cmpw TMP3, RC | stfdx f0, TMP2, TMP1 | beq >3 | addi TMP1, TMP3, 8 | lfdx f1, RA, TMP3 | cmpw TMP1, RC | stfdx f1, TMP2, TMP3 | bne <2 |3: |5: | cmplw RB, RD | decode_RA8 RA, INS | bgt >6 | sub BASE, TMP2, RA | lwz LFUNC:TMP1, FRAME_FUNC(BASE) | ins_next1 | lwz TMP1, LFUNC:TMP1->pc | lwz KBASE, PC2PROTO(k)(TMP1) | ins_next2 | |6: // Fill up results with nil. | subi TMP1, RD, 8 | addi RD, RD, 8 | stwx TISNIL, TMP2, TMP1 | b <5 | |->BC_RETV_Z: // Non-standard return case. | andix. TMP2, TMP1, FRAME_TYPEP | bne ->vm_return | // Return from vararg function: relocate BASE down. | sub BASE, BASE, TMP1 | lwz PC, FRAME_PC(BASE) | b <1 break; case BC_RET0: case BC_RET1: | // RA = results*8, RD = (nresults+1)*8 | lwz PC, FRAME_PC(BASE) | add RA, BASE, RA | mr MULTRES, RD | andix. TMP0, PC, FRAME_TYPE | xori TMP1, PC, FRAME_VARG | bney ->BC_RETV_Z | | lwz INS, -4(PC) | subi TMP2, BASE, 8 | decode_RB8 RB, INS if (op == BC_RET1) { | lfd f0, 0(RA) | stfd f0, 0(TMP2) } |5: | cmplw RB, RD | decode_RA8 RA, INS | bgt >6 | sub BASE, TMP2, RA | lwz LFUNC:TMP1, FRAME_FUNC(BASE) | ins_next1 | lwz TMP1, LFUNC:TMP1->pc | lwz KBASE, PC2PROTO(k)(TMP1) | ins_next2 | |6: // Fill up results with nil. | subi TMP1, RD, 8 | addi RD, RD, 8 | stwx TISNIL, TMP2, TMP1 | b <5 break; /* -- Loops and branches ------------------------------------------------ */ case BC_FORL: |.if JIT | hotloop |.endif | // Fall through. Assumes BC_IFORL follows. break; case BC_JFORI: case BC_JFORL: #if !LJ_HASJIT break; #endif case BC_FORI: case BC_IFORL: | // RA = base*8, RD = target (after end of loop or start of loop) vk = (op == BC_IFORL || op == BC_JFORL); |.if DUALNUM | // Integer loop. | lwzux TMP1, RA, BASE | lwz CARG1, FORL_IDX*8+4(RA) | cmplw cr0, TMP1, TISNUM if (vk) { | lwz CARG3, FORL_STEP*8+4(RA) | bne >9 |.if GPR64 | // Need to check overflow for (a<<32) + (b<<32). | rldicr TMP0, CARG1, 32, 31 | rldicr TMP2, CARG3, 32, 31 | add CARG1, CARG1, CARG3 | addo. TMP0, TMP0, TMP2 |.else | addo. CARG1, CARG1, CARG3 |.endif | cmpwi cr6, CARG3, 0 | lwz CARG2, FORL_STOP*8+4(RA) | bso >6 |4: | stw CARG1, FORL_IDX*8+4(RA) } else { | lwz TMP3, FORL_STEP*8(RA) | lwz CARG3, FORL_STEP*8+4(RA) | lwz TMP2, FORL_STOP*8(RA) | lwz CARG2, FORL_STOP*8+4(RA) | cmplw cr7, TMP3, TISNUM | cmplw cr1, TMP2, TISNUM | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq | crand 4*cr0+eq, 4*cr0+eq, 4*cr1+eq | cmpwi cr6, CARG3, 0 | bne >9 } | blt cr6, >5 | cmpw CARG1, CARG2 |1: | stw TISNUM, FORL_EXT*8(RA) if (op != BC_JFORL) { | srwi RD, RD, 1 } | stw CARG1, FORL_EXT*8+4(RA) if (op != BC_JFORL) { | add RD, PC, RD } if (op == BC_FORI) { | bgt >3 // See FP loop below. } else if (op == BC_JFORI) { | addis PC, RD, -(BCBIAS_J*4 >> 16) | bley >7 } else if (op == BC_IFORL) { | bgt >2 | addis PC, RD, -(BCBIAS_J*4 >> 16) } else { | bley =>BC_JLOOP } |2: | ins_next |5: // Invert check for negative step. | cmpw CARG2, CARG1 | b <1 if (vk) { |6: // Potential overflow. | mcrxr cr0; bley <4 // Ignore unrelated overflow. | b <2 } |.endif if (vk) { |.if DUALNUM |9: // FP loop. | lfd f1, FORL_IDX*8(RA) |.else | lfdux f1, RA, BASE |.endif | lfd f3, FORL_STEP*8(RA) | lfd f2, FORL_STOP*8(RA) | lwz TMP3, FORL_STEP*8(RA) | fadd f1, f1, f3 | stfd f1, FORL_IDX*8(RA) } else { |.if DUALNUM |9: // FP loop. |.else | lwzux TMP1, RA, BASE | lwz TMP3, FORL_STEP*8(RA) | lwz TMP2, FORL_STOP*8(RA) | cmplw cr0, TMP1, TISNUM | cmplw cr7, TMP3, TISNUM | cmplw cr1, TMP2, TISNUM |.endif | lfd f1, FORL_IDX*8(RA) | crand 4*cr0+lt, 4*cr0+lt, 4*cr7+lt | crand 4*cr0+lt, 4*cr0+lt, 4*cr1+lt | lfd f2, FORL_STOP*8(RA) | bge ->vmeta_for } | cmpwi cr6, TMP3, 0 if (op != BC_JFORL) { | srwi RD, RD, 1 } | stfd f1, FORL_EXT*8(RA) if (op != BC_JFORL) { | add RD, PC, RD } | fcmpu cr0, f1, f2 if (op == BC_JFORI) { | addis PC, RD, -(BCBIAS_J*4 >> 16) } | blt cr6, >5 if (op == BC_FORI) { | bgt >3 } else if (op == BC_IFORL) { |.if DUALNUM | bgty <2 |.else | bgt >2 |.endif |1: | addis PC, RD, -(BCBIAS_J*4 >> 16) } else if (op == BC_JFORI) { | bley >7 } else { | bley =>BC_JLOOP } |.if DUALNUM | b <2 |.else |2: | ins_next |.endif |5: // Negative step. if (op == BC_FORI) { | bge <2 |3: // Used by integer loop, too. | addis PC, RD, -(BCBIAS_J*4 >> 16) } else if (op == BC_IFORL) { | bgey <1 } else if (op == BC_JFORI) { | bgey >7 } else { | bgey =>BC_JLOOP } | b <2 if (op == BC_JFORI) { |7: | lwz INS, -4(PC) | decode_RD8 RD, INS | b =>BC_JLOOP } break; case BC_ITERL: |.if JIT | hotloop |.endif | // Fall through. Assumes BC_IITERL follows. break; case BC_JITERL: #if !LJ_HASJIT break; #endif case BC_IITERL: | // RA = base*8, RD = target | lwzux TMP1, RA, BASE | lwz TMP2, 4(RA) | checknil TMP1; beq >1 // Stop if iterator returned nil. if (op == BC_JITERL) { | stw TMP1, -8(RA) | stw TMP2, -4(RA) | b =>BC_JLOOP } else { | branch_RD // Otherwise save control var + branch. | stw TMP1, -8(RA) | stw TMP2, -4(RA) } |1: | ins_next break; case BC_LOOP: | // RA = base*8, RD = target (loop extent) | // Note: RA/RD is only used by trace recorder to determine scope/extent | // This opcode does NOT jump, it's only purpose is to detect a hot loop. |.if JIT | hotloop |.endif | // Fall through. Assumes BC_ILOOP follows. break; case BC_ILOOP: | // RA = base*8, RD = target (loop extent) | ins_next break; case BC_JLOOP: |.if JIT | // RA = base*8 (ignored), RD = traceno*8 | lwz TMP1, DISPATCH_J(trace)(DISPATCH) | srwi RD, RD, 1 | // Traces on PPC don't store the trace number, so use 0. | stw ZERO, DISPATCH_GL(vmstate)(DISPATCH) | lwzx TRACE:TMP2, TMP1, RD | mcrxr cr0 // Clear SO flag. | lp TMP2, TRACE:TMP2->mcode | stw BASE, DISPATCH_GL(jit_base)(DISPATCH) | mtctr TMP2 | stw L, DISPATCH_GL(jit_L)(DISPATCH) | addi JGL, DISPATCH, GG_DISP2G+32768 | bctr |.endif break; case BC_JMP: | // RA = base*8 (only used by trace recorder), RD = target | branch_RD | ins_next break; /* -- Function headers -------------------------------------------------- */ case BC_FUNCF: |.if JIT | hotcall |.endif case BC_FUNCV: /* NYI: compiled vararg functions. */ | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. break; case BC_JFUNCF: #if !LJ_HASJIT break; #endif case BC_IFUNCF: | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 | lwz TMP2, L->maxstack | lbz TMP1, -4+PC2PROTO(numparams)(PC) | lwz KBASE, -4+PC2PROTO(k)(PC) | cmplw RA, TMP2 | slwi TMP1, TMP1, 3 | bgt ->vm_growstack_l if (op != BC_JFUNCF) { | ins_next1 } |2: | cmplw NARGS8:RC, TMP1 // Check for missing parameters. | blt >3 if (op == BC_JFUNCF) { | decode_RD8 RD, INS | b =>BC_JLOOP } else { | ins_next2 } | |3: // Clear missing parameters. | stwx TISNIL, BASE, NARGS8:RC | addi NARGS8:RC, NARGS8:RC, 8 | b <2 break; case BC_JFUNCV: #if !LJ_HASJIT break; #endif | NYI // NYI: compiled vararg functions break; /* NYI: compiled vararg functions. */ case BC_IFUNCV: | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 | lwz TMP2, L->maxstack | add TMP1, BASE, RC | add TMP0, RA, RC | stw LFUNC:RB, 4(TMP1) // Store copy of LFUNC. | addi TMP3, RC, 8+FRAME_VARG | lwz KBASE, -4+PC2PROTO(k)(PC) | cmplw TMP0, TMP2 | stw TMP3, 0(TMP1) // Store delta + FRAME_VARG. | bge ->vm_growstack_l | lbz TMP2, -4+PC2PROTO(numparams)(PC) | mr RA, BASE | mr RC, TMP1 | ins_next1 | cmpwi TMP2, 0 | addi BASE, TMP1, 8 | beq >3 |1: | cmplw RA, RC // Less args than parameters? | lwz TMP0, 0(RA) | lwz TMP3, 4(RA) | bge >4 | stw TISNIL, 0(RA) // Clear old fixarg slot (help the GC). | addi RA, RA, 8 |2: | addic. TMP2, TMP2, -1 | stw TMP0, 8(TMP1) | stw TMP3, 12(TMP1) | addi TMP1, TMP1, 8 | bne <1 |3: | ins_next2 | |4: // Clear missing parameters. | li TMP0, LJ_TNIL | b <2 break; case BC_FUNCC: case BC_FUNCCW: | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 if (op == BC_FUNCC) { | lp RD, CFUNC:RB->f } else { | lp RD, DISPATCH_GL(wrapf)(DISPATCH) } | add TMP1, RA, NARGS8:RC | lwz TMP2, L->maxstack | .toc lp TMP3, 0(RD) | add RC, BASE, NARGS8:RC | stp BASE, L->base | cmplw TMP1, TMP2 | stp RC, L->top | li_vmstate C |.if TOC | mtctr TMP3 |.else | mtctr RD |.endif if (op == BC_FUNCCW) { | lp CARG2, CFUNC:RB->f } | mr CARG1, L | bgt ->vm_growstack_c // Need to grow stack. | .toc lp TOCREG, TOC_OFS(RD) | .tocenv lp ENVREG, ENV_OFS(RD) | st_vmstate | bctrl // (lua_State *L [, lua_CFunction f]) | // Returns nresults. | lp BASE, L->base | .toc ld TOCREG, SAVE_TOC | slwi RD, CRET1, 3 | lp TMP1, L->top | li_vmstate INTERP | lwz PC, FRAME_PC(BASE) // Fetch PC of caller. | sub RA, TMP1, RD // RA = L->top - nresults*8 | st_vmstate | b ->vm_returnc break; /* ---------------------------------------------------------------------- */ default: fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); exit(2); break; } } static int build_backend(BuildCtx *ctx) { int op; dasm_growpc(Dst, BC__MAX); build_subroutines(ctx); |.code_op for (op = 0; op < BC__MAX; op++) build_ins(ctx, (BCOp)op, op); return BC__MAX; } /* Emit pseudo frame-info for all assembler functions. */ static void emit_asm_debug(BuildCtx *ctx) { int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); int i; switch (ctx->mode) { case BUILD_elfasm: fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); fprintf(ctx->fp, ".Lframe0:\n" "\t.long .LECIE0-.LSCIE0\n" ".LSCIE0:\n" "\t.long 0xffffffff\n" "\t.byte 0x1\n" "\t.string \"\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 65\n" "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" "\t.align 2\n" ".LECIE0:\n\n"); fprintf(ctx->fp, ".LSFDE0:\n" "\t.long .LEFDE0-.LASFDE0\n" ".LASFDE0:\n" "\t.long .Lframe0\n" "\t.long .Lbegin\n" "\t.long %d\n" "\t.byte 0xe\n\t.uleb128 %d\n" "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" "\t.byte 0x5\n\t.uleb128 70\n\t.uleb128 55\n", fcofs, CFRAME_SIZE); for (i = 14; i <= 31; i++) fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n" "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 37+(31-i), 0x80+32+i, 2+2*(31-i)); fprintf(ctx->fp, "\t.align 2\n" ".LEFDE0:\n\n"); #if LJ_HASFFI fprintf(ctx->fp, ".LSFDE1:\n" "\t.long .LEFDE1-.LASFDE1\n" ".LASFDE1:\n" "\t.long .Lframe0\n" #if LJ_TARGET_PS3 "\t.long .lj_vm_ffi_call\n" #else "\t.long lj_vm_ffi_call\n" #endif "\t.long %d\n" "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" "\t.byte 0x8e\n\t.uleb128 2\n" "\t.byte 0xd\n\t.uleb128 0xe\n" "\t.align 2\n" ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); #endif #if !LJ_NO_UNWIND fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); fprintf(ctx->fp, ".Lframe1:\n" "\t.long .LECIE1-.LSCIE1\n" ".LSCIE1:\n" "\t.long 0\n" "\t.byte 0x1\n" "\t.string \"zPR\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 65\n" "\t.uleb128 6\n" /* augmentation length */ "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.long lj_err_unwind_dwarf-.\n" "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" "\t.align 2\n" ".LECIE1:\n\n"); fprintf(ctx->fp, ".LSFDE2:\n" "\t.long .LEFDE2-.LASFDE2\n" ".LASFDE2:\n" "\t.long .LASFDE2-.Lframe1\n" "\t.long .Lbegin-.\n" "\t.long %d\n" "\t.uleb128 0\n" /* augmentation length */ "\t.byte 0xe\n\t.uleb128 %d\n" "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" "\t.byte 0x5\n\t.uleb128 70\n\t.uleb128 55\n", fcofs, CFRAME_SIZE); for (i = 14; i <= 31; i++) fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n" "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 37+(31-i), 0x80+32+i, 2+2*(31-i)); fprintf(ctx->fp, "\t.align 2\n" ".LEFDE2:\n\n"); #if LJ_HASFFI fprintf(ctx->fp, ".Lframe2:\n" "\t.long .LECIE2-.LSCIE2\n" ".LSCIE2:\n" "\t.long 0\n" "\t.byte 0x1\n" "\t.string \"zR\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 65\n" "\t.uleb128 1\n" /* augmentation length */ "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" "\t.align 2\n" ".LECIE2:\n\n"); fprintf(ctx->fp, ".LSFDE3:\n" "\t.long .LEFDE3-.LASFDE3\n" ".LASFDE3:\n" "\t.long .LASFDE3-.Lframe2\n" "\t.long lj_vm_ffi_call-.\n" "\t.long %d\n" "\t.uleb128 0\n" /* augmentation length */ "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" "\t.byte 0x8e\n\t.uleb128 2\n" "\t.byte 0xd\n\t.uleb128 0xe\n" "\t.align 2\n" ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); #endif #endif break; default: break; } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/vm_ppcspe.dasc ================================================ |// Low-level VM code for PowerPC/e500 CPUs. |// Bytecode interpreter, fast functions and helper functions. |// Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h | |.arch ppc |.section code_op, code_sub | |.actionlist build_actionlist |.globals GLOB_ |.globalnames globnames |.externnames extnames | |// Note: The ragged indentation of the instructions is intentional. |// The starting columns indicate data dependencies. | |//----------------------------------------------------------------------- | |// Fixed register assignments for the interpreter. |// Don't use: r1 = sp, r2 and r13 = reserved and/or small data area ptr | |// The following must be C callee-save (but BASE is often refetched). |.define BASE, r14 // Base of current Lua stack frame. |.define KBASE, r15 // Constants of current Lua function. |.define PC, r16 // Next PC. |.define DISPATCH, r17 // Opcode dispatch table. |.define LREG, r18 // Register holding lua_State (also in SAVE_L). |.define MULTRES, r19 // Size of multi-result: (nresults+1)*8. | |// Constants for vectorized type-comparisons (hi+low GPR). C callee-save. |.define TISNUM, r22 |.define TISSTR, r23 |.define TISTAB, r24 |.define TISFUNC, r25 |.define TISNIL, r26 |.define TOBIT, r27 |.define ZERO, TOBIT // Zero in lo word. | |// The following temporaries are not saved across C calls, except for RA. |.define RA, r20 // Callee-save. |.define RB, r10 |.define RC, r11 |.define RD, r12 |.define INS, r7 // Overlaps CARG5. | |.define TMP0, r0 |.define TMP1, r8 |.define TMP2, r9 |.define TMP3, r6 // Overlaps CARG4. | |// Saved temporaries. |.define SAVE0, r21 | |// Calling conventions. |.define CARG1, r3 |.define CARG2, r4 |.define CARG3, r5 |.define CARG4, r6 // Overlaps TMP3. |.define CARG5, r7 // Overlaps INS. | |.define CRET1, r3 |.define CRET2, r4 | |// Stack layout while in interpreter. Must match with lj_frame.h. |.define SAVE_LR, 188(sp) |.define CFRAME_SPACE, 184 // Delta for sp. |// Back chain for sp: 184(sp) <-- sp entering interpreter |.define SAVE_r31, 176(sp) // 64 bit register saves. |.define SAVE_r30, 168(sp) |.define SAVE_r29, 160(sp) |.define SAVE_r28, 152(sp) |.define SAVE_r27, 144(sp) |.define SAVE_r26, 136(sp) |.define SAVE_r25, 128(sp) |.define SAVE_r24, 120(sp) |.define SAVE_r23, 112(sp) |.define SAVE_r22, 104(sp) |.define SAVE_r21, 96(sp) |.define SAVE_r20, 88(sp) |.define SAVE_r19, 80(sp) |.define SAVE_r18, 72(sp) |.define SAVE_r17, 64(sp) |.define SAVE_r16, 56(sp) |.define SAVE_r15, 48(sp) |.define SAVE_r14, 40(sp) |.define SAVE_CR, 36(sp) |.define UNUSED1, 32(sp) |.define SAVE_ERRF, 28(sp) // 32 bit C frame info. |.define SAVE_NRES, 24(sp) |.define SAVE_CFRAME, 20(sp) |.define SAVE_L, 16(sp) |.define SAVE_PC, 12(sp) |.define SAVE_MULTRES, 8(sp) |// Next frame lr: 4(sp) |// Back chain for sp: 0(sp) <-- sp while in interpreter | |.macro save_, reg; evstdd reg, SAVE_..reg; .endmacro |.macro rest_, reg; evldd reg, SAVE_..reg; .endmacro | |.macro saveregs | stwu sp, -CFRAME_SPACE(sp) | save_ r14; save_ r15; save_ r16; save_ r17; save_ r18; save_ r19 | mflr r0; mfcr r12 | save_ r20; save_ r21; save_ r22; save_ r23; save_ r24; save_ r25 | stw r0, SAVE_LR; stw r12, SAVE_CR | save_ r26; save_ r27; save_ r28; save_ r29; save_ r30; save_ r31 |.endmacro | |.macro restoreregs | lwz r0, SAVE_LR; lwz r12, SAVE_CR | rest_ r14; rest_ r15; rest_ r16; rest_ r17; rest_ r18; rest_ r19 | mtlr r0; mtcrf 0x38, r12 | rest_ r20; rest_ r21; rest_ r22; rest_ r23; rest_ r24; rest_ r25 | rest_ r26; rest_ r27; rest_ r28; rest_ r29; rest_ r30; rest_ r31 | addi sp, sp, CFRAME_SPACE |.endmacro | |// Type definitions. Some of these are only used for documentation. |.type L, lua_State, LREG |.type GL, global_State |.type TVALUE, TValue |.type GCOBJ, GCobj |.type STR, GCstr |.type TAB, GCtab |.type LFUNC, GCfuncL |.type CFUNC, GCfuncC |.type PROTO, GCproto |.type UPVAL, GCupval |.type NODE, Node |.type NARGS8, int |.type TRACE, GCtrace | |//----------------------------------------------------------------------- | |// These basic macros should really be part of DynASM. |.macro srwi, rx, ry, n; rlwinm rx, ry, 32-n, n, 31; .endmacro |.macro slwi, rx, ry, n; rlwinm rx, ry, n, 0, 31-n; .endmacro |.macro rotlwi, rx, ry, n; rlwinm rx, ry, n, 0, 31; .endmacro |.macro rotlw, rx, ry, rn; rlwnm rx, ry, rn, 0, 31; .endmacro |.macro subi, rx, ry, i; addi rx, ry, -i; .endmacro | |// Trap for not-yet-implemented parts. |.macro NYI; tw 4, sp, sp; .endmacro | |//----------------------------------------------------------------------- | |// Access to frame relative to BASE. |.define FRAME_PC, -8 |.define FRAME_FUNC, -4 | |// Instruction decode. |.macro decode_OP4, dst, ins; rlwinm dst, ins, 2, 22, 29; .endmacro |.macro decode_RA8, dst, ins; rlwinm dst, ins, 27, 21, 28; .endmacro |.macro decode_RB8, dst, ins; rlwinm dst, ins, 11, 21, 28; .endmacro |.macro decode_RC8, dst, ins; rlwinm dst, ins, 19, 21, 28; .endmacro |.macro decode_RD8, dst, ins; rlwinm dst, ins, 19, 13, 28; .endmacro | |.macro decode_OP1, dst, ins; rlwinm dst, ins, 0, 24, 31; .endmacro |.macro decode_RD4, dst, ins; rlwinm dst, ins, 18, 14, 29; .endmacro | |// Instruction fetch. |.macro ins_NEXT1 | lwz INS, 0(PC) | addi PC, PC, 4 |.endmacro |// Instruction decode+dispatch. |.macro ins_NEXT2 | decode_OP4 TMP1, INS | decode_RB8 RB, INS | decode_RD8 RD, INS | lwzx TMP0, DISPATCH, TMP1 | decode_RA8 RA, INS | decode_RC8 RC, INS | mtctr TMP0 | bctr |.endmacro |.macro ins_NEXT | ins_NEXT1 | ins_NEXT2 |.endmacro | |// Instruction footer. |.if 1 | // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. | .define ins_next, ins_NEXT | .define ins_next_, ins_NEXT | .define ins_next1, ins_NEXT1 | .define ins_next2, ins_NEXT2 |.else | // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. | // Affects only certain kinds of benchmarks (and only with -j off). | .macro ins_next | b ->ins_next | .endmacro | .macro ins_next1 | .endmacro | .macro ins_next2 | b ->ins_next | .endmacro | .macro ins_next_ | ->ins_next: | ins_NEXT | .endmacro |.endif | |// Call decode and dispatch. |.macro ins_callt | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC | lwz PC, LFUNC:RB->pc | lwz INS, 0(PC) | addi PC, PC, 4 | decode_OP4 TMP1, INS | decode_RA8 RA, INS | lwzx TMP0, DISPATCH, TMP1 | add RA, RA, BASE | mtctr TMP0 | bctr |.endmacro | |.macro ins_call | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, PC = caller PC | stw PC, FRAME_PC(BASE) | ins_callt |.endmacro | |//----------------------------------------------------------------------- | |// Macros to test operand types. |.macro checknum, reg; evcmpltu reg, TISNUM; .endmacro |.macro checkstr, reg; evcmpeq reg, TISSTR; .endmacro |.macro checktab, reg; evcmpeq reg, TISTAB; .endmacro |.macro checkfunc, reg; evcmpeq reg, TISFUNC; .endmacro |.macro checknil, reg; evcmpeq reg, TISNIL; .endmacro |.macro checkok, label; blt label; .endmacro |.macro checkfail, label; bge label; .endmacro |.macro checkanyfail, label; bns label; .endmacro |.macro checkallok, label; bso label; .endmacro | |.macro branch_RD | srwi TMP0, RD, 1 | add PC, PC, TMP0 | addis PC, PC, -(BCBIAS_J*4 >> 16) |.endmacro | |// Assumes DISPATCH is relative to GL. #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) | #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) | |.macro hotloop | NYI |.endmacro | |.macro hotcall | NYI |.endmacro | |// Set current VM state. Uses TMP0. |.macro li_vmstate, st; li TMP0, ~LJ_VMST_..st; .endmacro |.macro st_vmstate; stw TMP0, DISPATCH_GL(vmstate)(DISPATCH); .endmacro | |// Move table write barrier back. Overwrites mark and tmp. |.macro barrierback, tab, mark, tmp | lwz tmp, DISPATCH_GL(gc.grayagain)(DISPATCH) | // Assumes LJ_GC_BLACK is 0x04. | rlwinm mark, mark, 0, 30, 28 // black2gray(tab) | stw tab, DISPATCH_GL(gc.grayagain)(DISPATCH) | stb mark, tab->marked | stw tmp, tab->gclist |.endmacro | |//----------------------------------------------------------------------- /* Generate subroutines used by opcodes and other parts of the VM. */ /* The .code_sub section should be last to help static branch prediction. */ static void build_subroutines(BuildCtx *ctx) { |.code_sub | |//----------------------------------------------------------------------- |//-- Return handling ---------------------------------------------------- |//----------------------------------------------------------------------- | |->vm_returnp: | // See vm_return. Also: TMP2 = previous base. | andi. TMP0, PC, FRAME_P | evsplati TMP1, LJ_TTRUE | beq ->cont_dispatch | | // Return from pcall or xpcall fast func. | lwz PC, FRAME_PC(TMP2) // Fetch PC of previous frame. | mr BASE, TMP2 // Restore caller base. | // Prepending may overwrite the pcall frame, so do it at the end. | stwu TMP1, FRAME_PC(RA) // Prepend true to results. | |->vm_returnc: | addi RD, RD, 8 // RD = (nresults+1)*8. | andi. TMP0, PC, FRAME_TYPE | cmpwi cr1, RD, 0 | li CRET1, LUA_YIELD | beq cr1, ->vm_unwind_c_eh | mr MULTRES, RD | beq ->BC_RET_Z // Handle regular return to Lua. | |->vm_return: | // BASE = base, RA = resultptr, RD/MULTRES = (nresults+1)*8, PC = return | // TMP0 = PC & FRAME_TYPE | cmpwi TMP0, FRAME_C | rlwinm TMP2, PC, 0, 0, 28 | li_vmstate C | sub TMP2, BASE, TMP2 // TMP2 = previous base. | bne ->vm_returnp | | addic. TMP1, RD, -8 | stw TMP2, L->base | lwz TMP2, SAVE_NRES | subi BASE, BASE, 8 | st_vmstate | slwi TMP2, TMP2, 3 | beq >2 |1: | addic. TMP1, TMP1, -8 | evldd TMP0, 0(RA) | addi RA, RA, 8 | evstdd TMP0, 0(BASE) | addi BASE, BASE, 8 | bne <1 | |2: | cmpw TMP2, RD // More/less results wanted? | bne >6 |3: | stw BASE, L->top // Store new top. | |->vm_leave_cp: | lwz TMP0, SAVE_CFRAME // Restore previous C frame. | li CRET1, 0 // Ok return status for vm_pcall. | stw TMP0, L->cframe | |->vm_leave_unw: | restoreregs | blr | |6: | ble >7 // Less results wanted? | // More results wanted. Check stack size and fill up results with nil. | lwz TMP1, L->maxstack | cmplw BASE, TMP1 | bge >8 | evstdd TISNIL, 0(BASE) | addi RD, RD, 8 | addi BASE, BASE, 8 | b <2 | |7: // Less results wanted. | sub TMP0, RD, TMP2 | cmpwi TMP2, 0 // LUA_MULTRET+1 case? | sub TMP0, BASE, TMP0 // Subtract the difference. | iseleq BASE, BASE, TMP0 // Either keep top or shrink it. | b <3 | |8: // Corner case: need to grow stack for filling up results. | // This can happen if: | // - A C function grows the stack (a lot). | // - The GC shrinks the stack in between. | // - A return back from a lua_call() with (high) nresults adjustment. | stw BASE, L->top // Save current top held in BASE (yes). | mr SAVE0, RD | mr CARG2, TMP2 | mr CARG1, L | bl extern lj_state_growstack // (lua_State *L, int n) | lwz TMP2, SAVE_NRES | mr RD, SAVE0 | slwi TMP2, TMP2, 3 | lwz BASE, L->top // Need the (realloced) L->top in BASE. | b <2 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. | // (void *cframe, int errcode) | mr sp, CARG1 | mr CRET1, CARG2 |->vm_unwind_c_eh: // Landing pad for external unwinder. | lwz L, SAVE_L | li TMP0, ~LJ_VMST_C | lwz GL:TMP1, L->glref | stw TMP0, GL:TMP1->vmstate | b ->vm_leave_unw | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. | // (void *cframe) | rlwinm sp, CARG1, 0, 0, 29 |->vm_unwind_ff_eh: // Landing pad for external unwinder. | lwz L, SAVE_L | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. | evsplati TISFUNC, LJ_TFUNC | lus TOBIT, 0x4338 | evsplati TISTAB, LJ_TTAB | li TMP0, 0 | lwz BASE, L->base | evmergelo TOBIT, TOBIT, TMP0 | lwz DISPATCH, L->glref // Setup pointer to dispatch table. | evsplati TISSTR, LJ_TSTR | li TMP1, LJ_TFALSE | evsplati TISNIL, LJ_TNIL | li_vmstate INTERP | lwz PC, FRAME_PC(BASE) // Fetch PC of previous frame. | la RA, -8(BASE) // Results start at BASE-8. | addi DISPATCH, DISPATCH, GG_G2DISP | stw TMP1, 0(RA) // Prepend false to error message. | li RD, 16 // 2 results: false + error message. | st_vmstate | b ->vm_returnc | |//----------------------------------------------------------------------- |//-- Grow stack for calls ----------------------------------------------- |//----------------------------------------------------------------------- | |->vm_growstack_c: // Grow stack for C function. | li CARG2, LUA_MINSTACK | b >2 | |->vm_growstack_l: // Grow stack for Lua function. | // BASE = new base, RA = BASE+framesize*8, RC = nargs*8, PC = first PC | add RC, BASE, RC | sub RA, RA, BASE | stw BASE, L->base | addi PC, PC, 4 // Must point after first instruction. | stw RC, L->top | srwi CARG2, RA, 3 |2: | // L->base = new base, L->top = top | stw PC, SAVE_PC | mr CARG1, L | bl extern lj_state_growstack // (lua_State *L, int n) | lwz BASE, L->base | lwz RC, L->top | lwz LFUNC:RB, FRAME_FUNC(BASE) | sub RC, RC, BASE | // BASE = new base, RB = LFUNC/CFUNC, RC = nargs*8, FRAME_PC(BASE) = PC | ins_callt // Just retry the call. | |//----------------------------------------------------------------------- |//-- Entry points into the assembler VM --------------------------------- |//----------------------------------------------------------------------- | |->vm_resume: // Setup C frame and resume thread. | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) | saveregs | mr L, CARG1 | lwz DISPATCH, L->glref // Setup pointer to dispatch table. | mr BASE, CARG2 | lbz TMP1, L->status | stw L, SAVE_L | li PC, FRAME_CP | addi TMP0, sp, CFRAME_RESUME | addi DISPATCH, DISPATCH, GG_G2DISP | stw CARG3, SAVE_NRES | cmplwi TMP1, 0 | stw CARG3, SAVE_ERRF | stw TMP0, L->cframe | stw CARG3, SAVE_CFRAME | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. | beq >3 | | // Resume after yield (like a return). | mr RA, BASE | lwz BASE, L->base | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. | lwz TMP1, L->top | evsplati TISFUNC, LJ_TFUNC | lus TOBIT, 0x4338 | evsplati TISTAB, LJ_TTAB | lwz PC, FRAME_PC(BASE) | li TMP2, 0 | evsplati TISSTR, LJ_TSTR | sub RD, TMP1, BASE | evmergelo TOBIT, TOBIT, TMP2 | stb CARG3, L->status | andi. TMP0, PC, FRAME_TYPE | li_vmstate INTERP | addi RD, RD, 8 | evsplati TISNIL, LJ_TNIL | mr MULTRES, RD | st_vmstate | beq ->BC_RET_Z | b ->vm_return | |->vm_pcall: // Setup protected C frame and enter VM. | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) | saveregs | li PC, FRAME_CP | stw CARG4, SAVE_ERRF | b >1 | |->vm_call: // Setup C frame and enter VM. | // (lua_State *L, TValue *base, int nres1) | saveregs | li PC, FRAME_C | |1: // Entry point for vm_pcall above (PC = ftype). | lwz TMP1, L:CARG1->cframe | stw CARG3, SAVE_NRES | mr L, CARG1 | stw CARG1, SAVE_L | mr BASE, CARG2 | stw sp, L->cframe // Add our C frame to cframe chain. | lwz DISPATCH, L->glref // Setup pointer to dispatch table. | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. | stw TMP1, SAVE_CFRAME | addi DISPATCH, DISPATCH, GG_G2DISP | |3: // Entry point for vm_cpcall/vm_resume (BASE = base, PC = ftype). | lwz TMP2, L->base // TMP2 = old base (used in vmeta_call). | evsplati TISNUM, LJ_TISNUM+1 // Setup type comparison constants. | lwz TMP1, L->top | evsplati TISFUNC, LJ_TFUNC | add PC, PC, BASE | evsplati TISTAB, LJ_TTAB | lus TOBIT, 0x4338 | li TMP0, 0 | sub PC, PC, TMP2 // PC = frame delta + frame type | evsplati TISSTR, LJ_TSTR | sub NARGS8:RC, TMP1, BASE | evmergelo TOBIT, TOBIT, TMP0 | li_vmstate INTERP | evsplati TISNIL, LJ_TNIL | st_vmstate | |->vm_call_dispatch: | // TMP2 = old base, BASE = new base, RC = nargs*8, PC = caller PC | li TMP0, -8 | evlddx LFUNC:RB, BASE, TMP0 | checkfunc LFUNC:RB | checkfail ->vmeta_call | |->vm_call_dispatch_f: | ins_call | // BASE = new base, RB = func, RC = nargs*8, PC = caller PC | |->vm_cpcall: // Setup protected C frame, call C. | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) | saveregs | mr L, CARG1 | lwz TMP0, L:CARG1->stack | stw CARG1, SAVE_L | lwz TMP1, L->top | stw CARG1, SAVE_PC // Any value outside of bytecode is ok. | sub TMP0, TMP0, TMP1 // Compute -savestack(L, L->top). | lwz TMP1, L->cframe | stw sp, L->cframe // Add our C frame to cframe chain. | li TMP2, 0 | stw TMP0, SAVE_NRES // Neg. delta means cframe w/o frame. | stw TMP2, SAVE_ERRF // No error function. | stw TMP1, SAVE_CFRAME | mtctr CARG4 | bctrl // (lua_State *L, lua_CFunction func, void *ud) | mr. BASE, CRET1 | lwz DISPATCH, L->glref // Setup pointer to dispatch table. | li PC, FRAME_CP | addi DISPATCH, DISPATCH, GG_G2DISP | bne <3 // Else continue with the call. | b ->vm_leave_cp // No base? Just remove C frame. | |//----------------------------------------------------------------------- |//-- Metamethod handling ------------------------------------------------ |//----------------------------------------------------------------------- | |// The lj_meta_* functions (except for lj_meta_cat) don't reallocate the |// stack, so BASE doesn't need to be reloaded across these calls. | |//-- Continuation dispatch ---------------------------------------------- | |->cont_dispatch: | // BASE = meta base, RA = resultptr, RD = (nresults+1)*8 | lwz TMP0, -12(BASE) // Continuation. | mr RB, BASE | mr BASE, TMP2 // Restore caller BASE. | lwz LFUNC:TMP1, FRAME_FUNC(TMP2) | cmplwi TMP0, 0 | lwz PC, -16(RB) // Restore PC from [cont|PC]. | beq >1 | subi TMP2, RD, 8 | lwz TMP1, LFUNC:TMP1->pc | evstddx TISNIL, RA, TMP2 // Ensure one valid arg. | lwz KBASE, PC2PROTO(k)(TMP1) | // BASE = base, RA = resultptr, RB = meta base | mtctr TMP0 | bctr // Jump to continuation. | |1: // Tail call from C function. | subi TMP1, RB, 16 | sub RC, TMP1, BASE | b ->vm_call_tail | |->cont_cat: // RA = resultptr, RB = meta base | lwz INS, -4(PC) | subi CARG2, RB, 16 | decode_RB8 SAVE0, INS | evldd TMP0, 0(RA) | add TMP1, BASE, SAVE0 | stw BASE, L->base | cmplw TMP1, CARG2 | sub CARG3, CARG2, TMP1 | decode_RA8 RA, INS | evstdd TMP0, 0(CARG2) | bne ->BC_CAT_Z | evstddx TMP0, BASE, RA | b ->cont_nop | |//-- Table indexing metamethods ----------------------------------------- | |->vmeta_tgets1: | evmergelo STR:RC, TISSTR, STR:RC | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | decode_RB8 RB, INS | evstdd STR:RC, 0(CARG3) | add CARG2, BASE, RB | b >1 | |->vmeta_tgets: | evmergelo TAB:RB, TISTAB, TAB:RB | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) | evmergelo STR:RC, TISSTR, STR:RC | evstdd TAB:RB, 0(CARG2) | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) | evstdd STR:RC, 0(CARG3) | b >1 | |->vmeta_tgetb: // TMP0 = index | efdcfsi TMP0, TMP0 | decode_RB8 RB, INS | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | add CARG2, BASE, RB | evstdd TMP0, 0(CARG3) | b >1 | |->vmeta_tgetv: | decode_RB8 RB, INS | decode_RC8 RC, INS | add CARG2, BASE, RB | add CARG3, BASE, RC |1: | stw BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) | // Returns TValue * (finished) or NULL (metamethod). | cmplwi CRET1, 0 | beq >3 | evldd TMP0, 0(CRET1) | evstddx TMP0, BASE, RA | ins_next | |3: // Call __index metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k | subfic TMP1, BASE, FRAME_CONT | lwz BASE, L->top | stw PC, -16(BASE) // [cont|PC] | add PC, TMP1, BASE | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | li NARGS8:RC, 16 // 2 args for func(t, k). | b ->vm_call_dispatch_f | |//----------------------------------------------------------------------- | |->vmeta_tsets1: | evmergelo STR:RC, TISSTR, STR:RC | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | decode_RB8 RB, INS | evstdd STR:RC, 0(CARG3) | add CARG2, BASE, RB | b >1 | |->vmeta_tsets: | evmergelo TAB:RB, TISTAB, TAB:RB | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) | evmergelo STR:RC, TISSTR, STR:RC | evstdd TAB:RB, 0(CARG2) | la CARG3, DISPATCH_GL(tmptv2)(DISPATCH) | evstdd STR:RC, 0(CARG3) | b >1 | |->vmeta_tsetb: // TMP0 = index | efdcfsi TMP0, TMP0 | decode_RB8 RB, INS | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | add CARG2, BASE, RB | evstdd TMP0, 0(CARG3) | b >1 | |->vmeta_tsetv: | decode_RB8 RB, INS | decode_RC8 RC, INS | add CARG2, BASE, RB | add CARG3, BASE, RC |1: | stw BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) | // Returns TValue * (finished) or NULL (metamethod). | cmplwi CRET1, 0 | evlddx TMP0, BASE, RA | beq >3 | // NOBARRIER: lj_meta_tset ensures the table is not black. | evstdd TMP0, 0(CRET1) | ins_next | |3: // Call __newindex metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) | subfic TMP1, BASE, FRAME_CONT | lwz BASE, L->top | stw PC, -16(BASE) // [cont|PC] | add PC, TMP1, BASE | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | li NARGS8:RC, 24 // 3 args for func(t, k, v) | evstdd TMP0, 16(BASE) // Copy value to third argument. | b ->vm_call_dispatch_f | |//-- Comparison metamethods --------------------------------------------- | |->vmeta_comp: | mr CARG1, L | subi PC, PC, 4 | add CARG2, BASE, RA | stw PC, SAVE_PC | add CARG3, BASE, RD | stw BASE, L->base | decode_OP1 CARG4, INS | bl extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) | // Returns 0/1 or TValue * (metamethod). |3: | cmplwi CRET1, 1 | bgt ->vmeta_binop |4: | lwz INS, 0(PC) | addi PC, PC, 4 | decode_RD4 TMP2, INS | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | add TMP2, TMP2, TMP3 | isellt PC, PC, TMP2 |->cont_nop: | ins_next | |->cont_ra: // RA = resultptr | lwz INS, -4(PC) | evldd TMP0, 0(RA) | decode_RA8 TMP1, INS | evstddx TMP0, BASE, TMP1 | b ->cont_nop | |->cont_condt: // RA = resultptr | lwz TMP0, 0(RA) | li TMP1, LJ_TTRUE | cmplw TMP1, TMP0 // Branch if result is true. | b <4 | |->cont_condf: // RA = resultptr | lwz TMP0, 0(RA) | li TMP1, LJ_TFALSE | cmplw TMP0, TMP1 // Branch if result is false. | b <4 | |->vmeta_equal: | // CARG2, CARG3, CARG4 are already set by BC_ISEQV/BC_ISNEV. | subi PC, PC, 4 | stw BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) | // Returns 0/1 or TValue * (metamethod). | b <3 | |//-- Arithmetic metamethods --------------------------------------------- | |->vmeta_arith_vn: | add CARG3, BASE, RB | add CARG4, KBASE, RC | b >1 | |->vmeta_arith_nv: | add CARG3, KBASE, RC | add CARG4, BASE, RB | b >1 | |->vmeta_unm: | add CARG3, BASE, RD | mr CARG4, CARG3 | b >1 | |->vmeta_arith_vv: | add CARG3, BASE, RB | add CARG4, BASE, RC |1: | add CARG2, BASE, RA | stw BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | decode_OP1 CARG5, INS // Caveat: CARG5 overlaps INS. | bl extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) | // Returns NULL (finished) or TValue * (metamethod). | cmplwi CRET1, 0 | beq ->cont_nop | | // Call metamethod for binary op. |->vmeta_binop: | // BASE = old base, CRET1 = new base, stack = cont/func/o1/o2 | sub TMP1, CRET1, BASE | stw PC, -16(CRET1) // [cont|PC] | mr TMP2, BASE | addi PC, TMP1, FRAME_CONT | mr BASE, CRET1 | li NARGS8:RC, 16 // 2 args for func(o1, o2). | b ->vm_call_dispatch | |->vmeta_len: #if LJ_52 | mr SAVE0, CARG1 #endif | add CARG2, BASE, RD | stw BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | bl extern lj_meta_len // (lua_State *L, TValue *o) | // Returns NULL (retry) or TValue * (metamethod base). #if LJ_52 | cmplwi CRET1, 0 | bne ->vmeta_binop // Binop call for compatibility. | mr CARG1, SAVE0 | b ->BC_LEN_Z #else | b ->vmeta_binop // Binop call for compatibility. #endif | |//-- Call metamethod ---------------------------------------------------- | |->vmeta_call: // Resolve and call __call metamethod. | // TMP2 = old base, BASE = new base, RC = nargs*8 | mr CARG1, L | stw TMP2, L->base // This is the callers base! | subi CARG2, BASE, 8 | stw PC, SAVE_PC | add CARG3, BASE, RC | mr SAVE0, NARGS8:RC | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) | lwz LFUNC:RB, FRAME_FUNC(BASE) // Guaranteed to be a function here. | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. | ins_call | |->vmeta_callt: // Resolve __call for BC_CALLT. | // BASE = old base, RA = new base, RC = nargs*8 | mr CARG1, L | stw BASE, L->base | subi CARG2, RA, 8 | stw PC, SAVE_PC | add CARG3, RA, RC | mr SAVE0, NARGS8:RC | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) | lwz TMP1, FRAME_PC(BASE) | addi NARGS8:RC, SAVE0, 8 // Got one more argument now. | lwz LFUNC:RB, FRAME_FUNC(RA) // Guaranteed to be a function here. | b ->BC_CALLT_Z | |//-- Argument coercion for 'for' statement ------------------------------ | |->vmeta_for: | mr CARG1, L | stw BASE, L->base | mr CARG2, RA | stw PC, SAVE_PC | mr SAVE0, INS | bl extern lj_meta_for // (lua_State *L, TValue *base) |.if JIT | decode_OP1 TMP0, SAVE0 |.endif | decode_RA8 RA, SAVE0 |.if JIT | cmpwi TMP0, BC_JFORI |.endif | decode_RD8 RD, SAVE0 |.if JIT | beq =>BC_JFORI |.endif | b =>BC_FORI | |//----------------------------------------------------------------------- |//-- Fast functions ----------------------------------------------------- |//----------------------------------------------------------------------- | |.macro .ffunc, name |->ff_ .. name: |.endmacro | |.macro .ffunc_1, name |->ff_ .. name: | cmplwi NARGS8:RC, 8 | evldd CARG1, 0(BASE) | blt ->fff_fallback |.endmacro | |.macro .ffunc_2, name |->ff_ .. name: | cmplwi NARGS8:RC, 16 | evldd CARG1, 0(BASE) | evldd CARG2, 8(BASE) | blt ->fff_fallback |.endmacro | |.macro .ffunc_n, name | .ffunc_1 name | checknum CARG1 | checkfail ->fff_fallback |.endmacro | |.macro .ffunc_nn, name | .ffunc_2 name | evmergehi TMP0, CARG1, CARG2 | checknum TMP0 | checkanyfail ->fff_fallback |.endmacro | |// Inlined GC threshold check. Caveat: uses TMP0 and TMP1. |.macro ffgccheck | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) | cmplw TMP0, TMP1 | bgel ->fff_gcstep |.endmacro | |//-- Base library: checks ----------------------------------------------- | |.ffunc assert | cmplwi NARGS8:RC, 8 | evldd TMP0, 0(BASE) | blt ->fff_fallback | evaddw TMP1, TISNIL, TISNIL // Synthesize LJ_TFALSE. | la RA, -8(BASE) | evcmpltu cr1, TMP0, TMP1 | lwz PC, FRAME_PC(BASE) | bge cr1, ->fff_fallback | evstdd TMP0, 0(RA) | addi RD, NARGS8:RC, 8 // Compute (nresults+1)*8. | beq ->fff_res // Done if exactly 1 argument. | li TMP1, 8 | subi RC, RC, 8 |1: | cmplw TMP1, RC | evlddx TMP0, BASE, TMP1 | evstddx TMP0, RA, TMP1 | addi TMP1, TMP1, 8 | bne <1 | b ->fff_res | |.ffunc type | cmplwi NARGS8:RC, 8 | lwz CARG1, 0(BASE) | blt ->fff_fallback | li TMP2, ~LJ_TNUMX | cmplw CARG1, TISNUM | not TMP1, CARG1 | isellt TMP1, TMP2, TMP1 | slwi TMP1, TMP1, 3 | la TMP2, CFUNC:RB->upvalue | evlddx STR:CRET1, TMP2, TMP1 | b ->fff_restv | |//-- Base library: getters and setters --------------------------------- | |.ffunc_1 getmetatable | checktab CARG1 | evmergehi TMP1, CARG1, CARG1 | checkfail >6 |1: // Field metatable must be at same offset for GCtab and GCudata! | lwz TAB:RB, TAB:CARG1->metatable |2: | evmr CRET1, TISNIL | cmplwi TAB:RB, 0 | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) | beq ->fff_restv | lwz TMP0, TAB:RB->hmask | evmergelo CRET1, TISTAB, TAB:RB // Use metatable as default result. | lwz TMP1, STR:RC->hash | lwz NODE:TMP2, TAB:RB->node | evmergelo STR:RC, TISSTR, STR:RC | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | slwi TMP0, TMP1, 5 | slwi TMP1, TMP1, 3 | sub TMP1, TMP0, TMP1 | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) |3: // Rearranged logic, because we expect _not_ to find the key. | evldd TMP0, NODE:TMP2->key | evldd TMP1, NODE:TMP2->val | evcmpeq TMP0, STR:RC | lwz NODE:TMP2, NODE:TMP2->next | checkallok >5 | cmplwi NODE:TMP2, 0 | beq ->fff_restv // Not found, keep default result. | b <3 |5: | checknil TMP1 | checkok ->fff_restv // Ditto for nil value. | evmr CRET1, TMP1 // Return value of mt.__metatable. | b ->fff_restv | |6: | cmpwi TMP1, LJ_TUDATA | not TMP1, TMP1 | beq <1 | checknum CARG1 | slwi TMP1, TMP1, 2 | li TMP2, 4*~LJ_TNUMX | isellt TMP1, TMP2, TMP1 | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) | lwzx TAB:RB, TMP2, TMP1 | b <2 | |.ffunc_2 setmetatable | // Fast path: no mt for table yet and not clearing the mt. | evmergehi TMP0, TAB:CARG1, TAB:CARG2 | checktab TMP0 | checkanyfail ->fff_fallback | lwz TAB:TMP1, TAB:CARG1->metatable | cmplwi TAB:TMP1, 0 | lbz TMP3, TAB:CARG1->marked | bne ->fff_fallback | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) | stw TAB:CARG2, TAB:CARG1->metatable | beq ->fff_restv | barrierback TAB:CARG1, TMP3, TMP0 | b ->fff_restv | |.ffunc rawget | cmplwi NARGS8:RC, 16 | evldd CARG2, 0(BASE) | blt ->fff_fallback | checktab CARG2 | la CARG3, 8(BASE) | checkfail ->fff_fallback | mr CARG1, L | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) | // Returns cTValue *. | evldd CRET1, 0(CRET1) | b ->fff_restv | |//-- Base library: conversions ------------------------------------------ | |.ffunc tonumber | // Only handles the number case inline (without a base argument). | cmplwi NARGS8:RC, 8 | evldd CARG1, 0(BASE) | bne ->fff_fallback // Exactly one argument. | checknum CARG1 | checkok ->fff_restv | b ->fff_fallback | |.ffunc_1 tostring | // Only handles the string or number case inline. | checkstr CARG1 | // A __tostring method in the string base metatable is ignored. | checkok ->fff_restv // String key? | // Handle numbers inline, unless a number base metatable is present. | lwz TMP0, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])(DISPATCH) | checknum CARG1 | cmplwi cr1, TMP0, 0 | stw BASE, L->base // Add frame since C call can throw. | crand 4*cr0+eq, 4*cr0+lt, 4*cr1+eq | stw PC, SAVE_PC // Redundant (but a defined value). | bne ->fff_fallback | ffgccheck | mr CARG1, L | mr CARG2, BASE | bl extern lj_str_fromnum // (lua_State *L, lua_Number *np) | // Returns GCstr *. | evmergelo STR:CRET1, TISSTR, STR:CRET1 | b ->fff_restv | |//-- Base library: iterators ------------------------------------------- | |.ffunc next | cmplwi NARGS8:RC, 8 | evldd CARG2, 0(BASE) | blt ->fff_fallback | evstddx TISNIL, BASE, NARGS8:RC // Set missing 2nd arg to nil. | checktab TAB:CARG2 | lwz PC, FRAME_PC(BASE) | checkfail ->fff_fallback | stw BASE, L->base // Add frame since C call can throw. | mr CARG1, L | stw BASE, L->top // Dummy frame length is ok. | la CARG3, 8(BASE) | stw PC, SAVE_PC | bl extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) | // Returns 0 at end of traversal. | cmplwi CRET1, 0 | evmr CRET1, TISNIL | beq ->fff_restv // End of traversal: return nil. | evldd TMP0, 8(BASE) // Copy key and value to results. | la RA, -8(BASE) | evldd TMP1, 16(BASE) | evstdd TMP0, 0(RA) | li RD, (2+1)*8 | evstdd TMP1, 8(RA) | b ->fff_res | |.ffunc_1 pairs | checktab TAB:CARG1 | lwz PC, FRAME_PC(BASE) | checkfail ->fff_fallback #if LJ_52 | lwz TAB:TMP2, TAB:CARG1->metatable | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] | cmplwi TAB:TMP2, 0 | la RA, -8(BASE) | bne ->fff_fallback #else | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] | la RA, -8(BASE) #endif | evstdd TISNIL, 8(BASE) | li RD, (3+1)*8 | evstdd CFUNC:TMP0, 0(RA) | b ->fff_res | |.ffunc_2 ipairs_aux | checktab TAB:CARG1 | lwz PC, FRAME_PC(BASE) | checkfail ->fff_fallback | checknum CARG2 | lus TMP3, 0x3ff0 | checkfail ->fff_fallback | efdctsi TMP2, CARG2 | lwz TMP0, TAB:CARG1->asize | evmergelo TMP3, TMP3, ZERO | lwz TMP1, TAB:CARG1->array | efdadd CARG2, CARG2, TMP3 | addi TMP2, TMP2, 1 | la RA, -8(BASE) | cmplw TMP0, TMP2 | slwi TMP3, TMP2, 3 | evstdd CARG2, 0(RA) | ble >2 // Not in array part? | evlddx TMP1, TMP1, TMP3 |1: | checknil TMP1 | li RD, (0+1)*8 | checkok ->fff_res // End of iteration, return 0 results. | li RD, (2+1)*8 | evstdd TMP1, 8(RA) | b ->fff_res |2: // Check for empty hash part first. Otherwise call C function. | lwz TMP0, TAB:CARG1->hmask | cmplwi TMP0, 0 | li RD, (0+1)*8 | beq ->fff_res | mr CARG2, TMP2 | bl extern lj_tab_getinth // (GCtab *t, int32_t key) | // Returns cTValue * or NULL. | cmplwi CRET1, 0 | li RD, (0+1)*8 | beq ->fff_res | evldd TMP1, 0(CRET1) | b <1 | |.ffunc_1 ipairs | checktab TAB:CARG1 | lwz PC, FRAME_PC(BASE) | checkfail ->fff_fallback #if LJ_52 | lwz TAB:TMP2, TAB:CARG1->metatable | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] | cmplwi TAB:TMP2, 0 | la RA, -8(BASE) | bne ->fff_fallback #else | evldd CFUNC:TMP0, CFUNC:RB->upvalue[0] | la RA, -8(BASE) #endif | evsplati TMP1, 0 | li RD, (3+1)*8 | evstdd TMP1, 8(BASE) | evstdd CFUNC:TMP0, 0(RA) | b ->fff_res | |//-- Base library: catch errors ---------------------------------------- | |.ffunc pcall | cmplwi NARGS8:RC, 8 | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) | blt ->fff_fallback | mr TMP2, BASE | la BASE, 8(BASE) | // Remember active hook before pcall. | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 | subi NARGS8:RC, NARGS8:RC, 8 | addi PC, TMP3, 8+FRAME_PCALL | b ->vm_call_dispatch | |.ffunc_2 xpcall | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) | mr TMP2, BASE | checkfunc CARG2 // Traceback must be a function. | checkfail ->fff_fallback | la BASE, 16(BASE) | // Remember active hook before pcall. | rlwinm TMP3, TMP3, 32-HOOK_ACTIVE_SHIFT, 31, 31 | evstdd CARG2, 0(TMP2) // Swap function and traceback. | subi NARGS8:RC, NARGS8:RC, 16 | evstdd CARG1, 8(TMP2) | addi PC, TMP3, 16+FRAME_PCALL | b ->vm_call_dispatch | |//-- Coroutine library -------------------------------------------------- | |.macro coroutine_resume_wrap, resume |.if resume |.ffunc_1 coroutine_resume | evmergehi TMP0, L:CARG1, L:CARG1 |.else |.ffunc coroutine_wrap_aux | lwz L:CARG1, CFUNC:RB->upvalue[0].gcr |.endif |.if resume | cmpwi TMP0, LJ_TTHREAD | bne ->fff_fallback |.endif | lbz TMP0, L:CARG1->status | lwz TMP1, L:CARG1->cframe | lwz CARG2, L:CARG1->top | cmplwi cr0, TMP0, LUA_YIELD | lwz TMP2, L:CARG1->base | cmplwi cr1, TMP1, 0 | lwz TMP0, L:CARG1->maxstack | cmplw cr7, CARG2, TMP2 | lwz PC, FRAME_PC(BASE) | crorc 4*cr6+lt, 4*cr0+gt, 4*cr1+eq // st>LUA_YIELD || cframe!=0 | add TMP2, CARG2, NARGS8:RC | crandc 4*cr6+gt, 4*cr7+eq, 4*cr0+eq // base==top && st!=LUA_YIELD | cmplw cr1, TMP2, TMP0 | cror 4*cr6+lt, 4*cr6+lt, 4*cr6+gt | stw PC, SAVE_PC | cror 4*cr6+lt, 4*cr6+lt, 4*cr1+gt // cond1 || cond2 || stackov | stw BASE, L->base | blt cr6, ->fff_fallback |1: |.if resume | addi BASE, BASE, 8 // Keep resumed thread in stack for GC. | subi NARGS8:RC, NARGS8:RC, 8 | subi TMP2, TMP2, 8 |.endif | stw TMP2, L:CARG1->top | li TMP1, 0 | stw BASE, L->top |2: // Move args to coroutine. | cmpw TMP1, NARGS8:RC | evlddx TMP0, BASE, TMP1 | beq >3 | evstddx TMP0, CARG2, TMP1 | addi TMP1, TMP1, 8 | b <2 |3: | li CARG3, 0 | mr L:SAVE0, L:CARG1 | li CARG4, 0 | bl ->vm_resume // (lua_State *L, TValue *base, 0, 0) | // Returns thread status. |4: | lwz TMP2, L:SAVE0->base | cmplwi CRET1, LUA_YIELD | lwz TMP3, L:SAVE0->top | li_vmstate INTERP | lwz BASE, L->base | st_vmstate | bgt >8 | sub RD, TMP3, TMP2 | lwz TMP0, L->maxstack | cmplwi RD, 0 | add TMP1, BASE, RD | beq >6 // No results? | cmplw TMP1, TMP0 | li TMP1, 0 | bgt >9 // Need to grow stack? | | subi TMP3, RD, 8 | stw TMP2, L:SAVE0->top // Clear coroutine stack. |5: // Move results from coroutine. | cmplw TMP1, TMP3 | evlddx TMP0, TMP2, TMP1 | evstddx TMP0, BASE, TMP1 | addi TMP1, TMP1, 8 | bne <5 |6: | andi. TMP0, PC, FRAME_TYPE |.if resume | li TMP1, LJ_TTRUE | la RA, -8(BASE) | stw TMP1, -8(BASE) // Prepend true to results. | addi RD, RD, 16 |.else | mr RA, BASE | addi RD, RD, 8 |.endif |7: | stw PC, SAVE_PC | mr MULTRES, RD | beq ->BC_RET_Z | b ->vm_return | |8: // Coroutine returned with error (at co->top-1). |.if resume | andi. TMP0, PC, FRAME_TYPE | la TMP3, -8(TMP3) | li TMP1, LJ_TFALSE | evldd TMP0, 0(TMP3) | stw TMP3, L:SAVE0->top // Remove error from coroutine stack. | li RD, (2+1)*8 | stw TMP1, -8(BASE) // Prepend false to results. | la RA, -8(BASE) | evstdd TMP0, 0(BASE) // Copy error message. | b <7 |.else | mr CARG1, L | mr CARG2, L:SAVE0 | bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co) |.endif | |9: // Handle stack expansion on return from yield. | mr CARG1, L | srwi CARG2, RD, 3 | bl extern lj_state_growstack // (lua_State *L, int n) | li CRET1, 0 | b <4 |.endmacro | | coroutine_resume_wrap 1 // coroutine.resume | coroutine_resume_wrap 0 // coroutine.wrap | |.ffunc coroutine_yield | lwz TMP0, L->cframe | add TMP1, BASE, NARGS8:RC | stw BASE, L->base | andi. TMP0, TMP0, CFRAME_RESUME | stw TMP1, L->top | li CRET1, LUA_YIELD | beq ->fff_fallback | stw ZERO, L->cframe | stb CRET1, L->status | b ->vm_leave_unw | |//-- Math library ------------------------------------------------------- | |.ffunc_n math_abs | efdabs CRET1, CARG1 | // Fallthrough. | |->fff_restv: | // CRET1 = TValue result. | lwz PC, FRAME_PC(BASE) | la RA, -8(BASE) | evstdd CRET1, 0(RA) |->fff_res1: | // RA = results, PC = return. | li RD, (1+1)*8 |->fff_res: | // RA = results, RD = (nresults+1)*8, PC = return. | andi. TMP0, PC, FRAME_TYPE | mr MULTRES, RD | bne ->vm_return | lwz INS, -4(PC) | decode_RB8 RB, INS |5: | cmplw RB, RD // More results expected? | decode_RA8 TMP0, INS | bgt >6 | ins_next1 | // Adjust BASE. KBASE is assumed to be set for the calling frame. | sub BASE, RA, TMP0 | ins_next2 | |6: // Fill up results with nil. | subi TMP1, RD, 8 | addi RD, RD, 8 | evstddx TISNIL, RA, TMP1 | b <5 | |.macro math_extern, func | .ffunc math_ .. func | cmplwi NARGS8:RC, 8 | evldd CARG2, 0(BASE) | blt ->fff_fallback | checknum CARG2 | evmergehi CARG1, CARG2, CARG2 | checkfail ->fff_fallback | bl extern func | evmergelo CRET1, CRET1, CRET2 | b ->fff_restv |.endmacro | |.macro math_extern2, func | .ffunc math_ .. func | cmplwi NARGS8:RC, 16 | evldd CARG2, 0(BASE) | evldd CARG4, 8(BASE) | blt ->fff_fallback | evmergehi CARG1, CARG4, CARG2 | checknum CARG1 | evmergehi CARG3, CARG4, CARG4 | checkanyfail ->fff_fallback | bl extern func | evmergelo CRET1, CRET1, CRET2 | b ->fff_restv |.endmacro | |.macro math_round, func | .ffunc math_ .. func | cmplwi NARGS8:RC, 8 | evldd CARG2, 0(BASE) | blt ->fff_fallback | checknum CARG2 | evmergehi CARG1, CARG2, CARG2 | checkfail ->fff_fallback | lwz PC, FRAME_PC(BASE) | bl ->vm_..func.._hilo; | la RA, -8(BASE) | evstdd CRET2, 0(RA) | b ->fff_res1 |.endmacro | | math_round floor | math_round ceil | | math_extern sqrt | |.ffunc math_log | cmplwi NARGS8:RC, 8 | evldd CARG2, 0(BASE) | bne ->fff_fallback // Need exactly 1 argument. | checknum CARG2 | evmergehi CARG1, CARG2, CARG2 | checkfail ->fff_fallback | bl extern log | evmergelo CRET1, CRET1, CRET2 | b ->fff_restv | | math_extern log10 | math_extern exp | math_extern sin | math_extern cos | math_extern tan | math_extern asin | math_extern acos | math_extern atan | math_extern sinh | math_extern cosh | math_extern tanh | math_extern2 pow | math_extern2 atan2 | math_extern2 fmod | |->ff_math_deg: |.ffunc_n math_rad | evldd CARG2, CFUNC:RB->upvalue[0] | efdmul CRET1, CARG1, CARG2 | b ->fff_restv | |.ffunc math_ldexp | cmplwi NARGS8:RC, 16 | evldd CARG2, 0(BASE) | evldd CARG4, 8(BASE) | blt ->fff_fallback | evmergehi CARG1, CARG4, CARG2 | checknum CARG1 | checkanyfail ->fff_fallback | efdctsi CARG3, CARG4 | bl extern ldexp | evmergelo CRET1, CRET1, CRET2 | b ->fff_restv | |.ffunc math_frexp | cmplwi NARGS8:RC, 8 | evldd CARG2, 0(BASE) | blt ->fff_fallback | checknum CARG2 | evmergehi CARG1, CARG2, CARG2 | checkfail ->fff_fallback | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | lwz PC, FRAME_PC(BASE) | bl extern frexp | lwz TMP1, DISPATCH_GL(tmptv)(DISPATCH) | evmergelo CRET1, CRET1, CRET2 | efdcfsi CRET2, TMP1 | la RA, -8(BASE) | evstdd CRET1, 0(RA) | li RD, (2+1)*8 | evstdd CRET2, 8(RA) | b ->fff_res | |.ffunc math_modf | cmplwi NARGS8:RC, 8 | evldd CARG2, 0(BASE) | blt ->fff_fallback | checknum CARG2 | evmergehi CARG1, CARG2, CARG2 | checkfail ->fff_fallback | la CARG3, -8(BASE) | lwz PC, FRAME_PC(BASE) | bl extern modf | evmergelo CRET1, CRET1, CRET2 | la RA, -8(BASE) | evstdd CRET1, 0(BASE) | li RD, (2+1)*8 | b ->fff_res | |.macro math_minmax, name, cmpop | .ffunc_1 name | checknum CARG1 | li TMP1, 8 | checkfail ->fff_fallback |1: | evlddx CARG2, BASE, TMP1 | cmplw cr1, TMP1, NARGS8:RC | checknum CARG2 | bge cr1, ->fff_restv // Ok, since CRET1 = CARG1. | checkfail ->fff_fallback | cmpop CARG2, CARG1 | addi TMP1, TMP1, 8 | crmove 4*cr0+lt, 4*cr0+gt | evsel CARG1, CARG2, CARG1 | b <1 |.endmacro | | math_minmax math_min, efdtstlt | math_minmax math_max, efdtstgt | |//-- String library ----------------------------------------------------- | |.ffunc_1 string_len | checkstr STR:CARG1 | checkfail ->fff_fallback | lwz TMP0, STR:CARG1->len | efdcfsi CRET1, TMP0 | b ->fff_restv | |.ffunc string_byte // Only handle the 1-arg case here. | cmplwi NARGS8:RC, 8 | evldd STR:CARG1, 0(BASE) | bne ->fff_fallback // Need exactly 1 argument. | checkstr STR:CARG1 | la RA, -8(BASE) | checkfail ->fff_fallback | lwz TMP0, STR:CARG1->len | li RD, (0+1)*8 | lbz TMP1, STR:CARG1[1] // Access is always ok (NUL at end). | li TMP2, (1+1)*8 | cmplwi TMP0, 0 | lwz PC, FRAME_PC(BASE) | efdcfsi CRET1, TMP1 | iseleq RD, RD, TMP2 | evstdd CRET1, 0(RA) | b ->fff_res | |.ffunc string_char // Only handle the 1-arg case here. | ffgccheck | cmplwi NARGS8:RC, 8 | evldd CARG1, 0(BASE) | bne ->fff_fallback // Exactly 1 argument. | checknum CARG1 | la CARG2, DISPATCH_GL(tmptv)(DISPATCH) | checkfail ->fff_fallback | efdctsiz TMP0, CARG1 | li CARG3, 1 | cmplwi TMP0, 255 | stb TMP0, 0(CARG2) | bgt ->fff_fallback |->fff_newstr: | mr CARG1, L | stw BASE, L->base | stw PC, SAVE_PC | bl extern lj_str_new // (lua_State *L, char *str, size_t l) | // Returns GCstr *. | lwz BASE, L->base | evmergelo STR:CRET1, TISSTR, STR:CRET1 | b ->fff_restv | |.ffunc string_sub | ffgccheck | cmplwi NARGS8:RC, 16 | evldd CARG3, 16(BASE) | evldd STR:CARG1, 0(BASE) | blt ->fff_fallback | evldd CARG2, 8(BASE) | li TMP2, -1 | beq >1 | checknum CARG3 | checkfail ->fff_fallback | efdctsiz TMP2, CARG3 |1: | checknum CARG2 | checkfail ->fff_fallback | checkstr STR:CARG1 | efdctsiz TMP1, CARG2 | checkfail ->fff_fallback | lwz TMP0, STR:CARG1->len | cmplw TMP0, TMP2 // len < end? (unsigned compare) | add TMP3, TMP2, TMP0 | blt >5 |2: | cmpwi TMP1, 0 // start <= 0? | add TMP3, TMP1, TMP0 | ble >7 |3: | sub. CARG3, TMP2, TMP1 | addi CARG2, STR:CARG1, #STR-1 | addi CARG3, CARG3, 1 | add CARG2, CARG2, TMP1 | isellt CARG3, r0, CARG3 | b ->fff_newstr | |5: // Negative end or overflow. | cmpw TMP0, TMP2 | addi TMP3, TMP3, 1 | iselgt TMP2, TMP3, TMP0 // end = end > len ? len : end+len+1 | b <2 | |7: // Negative start or underflow. | cmpwi cr1, TMP3, 0 | iseleq TMP1, r0, TMP3 | isel TMP1, r0, TMP1, 4*cr1+lt | addi TMP1, TMP1, 1 // start = 1 + (start ? start+len : 0) | b <3 | |.ffunc string_rep // Only handle the 1-char case inline. | ffgccheck | cmplwi NARGS8:RC, 16 | evldd CARG1, 0(BASE) | evldd CARG2, 8(BASE) | bne ->fff_fallback // Exactly 2 arguments. | checknum CARG2 | checkfail ->fff_fallback | checkstr STR:CARG1 | efdctsiz CARG3, CARG2 | checkfail ->fff_fallback | lwz TMP0, STR:CARG1->len | cmpwi CARG3, 0 | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | ble >2 // Count <= 0? (or non-int) | cmplwi TMP0, 1 | subi TMP2, CARG3, 1 | blt >2 // Zero length string? | cmplw cr1, TMP1, CARG3 | bne ->fff_fallback // Fallback for > 1-char strings. | lbz TMP0, STR:CARG1[1] | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | blt cr1, ->fff_fallback |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). | cmplwi TMP2, 0 | stbx TMP0, CARG2, TMP2 | subi TMP2, TMP2, 1 | bne <1 | b ->fff_newstr |2: // Return empty string. | la STR:CRET1, DISPATCH_GL(strempty)(DISPATCH) | evmergelo CRET1, TISSTR, STR:CRET1 | b ->fff_restv | |.ffunc string_reverse | ffgccheck | cmplwi NARGS8:RC, 8 | evldd CARG1, 0(BASE) | blt ->fff_fallback | checkstr STR:CARG1 | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | checkfail ->fff_fallback | lwz CARG3, STR:CARG1->len | la CARG1, #STR(STR:CARG1) | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | li TMP2, 0 | cmplw TMP1, CARG3 | subi TMP3, CARG3, 1 | blt ->fff_fallback |1: // Reverse string copy. | cmpwi TMP3, 0 | lbzx TMP1, CARG1, TMP2 | blt ->fff_newstr | stbx TMP1, CARG2, TMP3 | subi TMP3, TMP3, 1 | addi TMP2, TMP2, 1 | b <1 | |.macro ffstring_case, name, lo | .ffunc name | ffgccheck | cmplwi NARGS8:RC, 8 | evldd CARG1, 0(BASE) | blt ->fff_fallback | checkstr STR:CARG1 | lwz TMP1, DISPATCH_GL(tmpbuf.sz)(DISPATCH) | checkfail ->fff_fallback | lwz CARG3, STR:CARG1->len | la CARG1, #STR(STR:CARG1) | lwz CARG2, DISPATCH_GL(tmpbuf.buf)(DISPATCH) | cmplw TMP1, CARG3 | li TMP2, 0 | blt ->fff_fallback |1: // ASCII case conversion. | cmplw TMP2, CARG3 | lbzx TMP1, CARG1, TMP2 | bge ->fff_newstr | subi TMP0, TMP1, lo | xori TMP3, TMP1, 0x20 | cmplwi TMP0, 26 | isellt TMP1, TMP3, TMP1 | stbx TMP1, CARG2, TMP2 | addi TMP2, TMP2, 1 | b <1 |.endmacro | |ffstring_case string_lower, 65 |ffstring_case string_upper, 97 | |//-- Table library ------------------------------------------------------ | |.ffunc_1 table_getn | checktab CARG1 | checkfail ->fff_fallback | bl extern lj_tab_len // (GCtab *t) | // Returns uint32_t (but less than 2^31). | efdcfsi CRET1, CRET1 | b ->fff_restv | |//-- Bit library -------------------------------------------------------- | |.macro .ffunc_bit, name | .ffunc_n bit_..name | efdadd CARG1, CARG1, TOBIT |.endmacro | |.ffunc_bit tobit |->fff_resbit: | efdcfsi CRET1, CARG1 | b ->fff_restv | |.macro .ffunc_bit_op, name, ins | .ffunc_bit name | li TMP1, 8 |1: | evlddx CARG2, BASE, TMP1 | cmplw cr1, TMP1, NARGS8:RC | checknum CARG2 | bge cr1, ->fff_resbit | checkfail ->fff_fallback | efdadd CARG2, CARG2, TOBIT | ins CARG1, CARG1, CARG2 | addi TMP1, TMP1, 8 | b <1 |.endmacro | |.ffunc_bit_op band, and |.ffunc_bit_op bor, or |.ffunc_bit_op bxor, xor | |.ffunc_bit bswap | rotlwi TMP0, CARG1, 8 | rlwimi TMP0, CARG1, 24, 0, 7 | rlwimi TMP0, CARG1, 24, 16, 23 | efdcfsi CRET1, TMP0 | b ->fff_restv | |.ffunc_bit bnot | not TMP0, CARG1 | efdcfsi CRET1, TMP0 | b ->fff_restv | |.macro .ffunc_bit_sh, name, ins, shmod | .ffunc_nn bit_..name | efdadd CARG2, CARG2, TOBIT | efdadd CARG1, CARG1, TOBIT |.if shmod == 1 | rlwinm CARG2, CARG2, 0, 27, 31 |.elif shmod == 2 | neg CARG2, CARG2 |.endif | ins TMP0, CARG1, CARG2 | efdcfsi CRET1, TMP0 | b ->fff_restv |.endmacro | |.ffunc_bit_sh lshift, slw, 1 |.ffunc_bit_sh rshift, srw, 1 |.ffunc_bit_sh arshift, sraw, 1 |.ffunc_bit_sh rol, rotlw, 0 |.ffunc_bit_sh ror, rotlw, 2 | |//----------------------------------------------------------------------- | |->fff_fallback: // Call fast function fallback handler. | // BASE = new base, RB = CFUNC, RC = nargs*8 | lwz TMP3, CFUNC:RB->f | add TMP1, BASE, NARGS8:RC | lwz PC, FRAME_PC(BASE) // Fallback may overwrite PC. | addi TMP0, TMP1, 8*LUA_MINSTACK | lwz TMP2, L->maxstack | stw PC, SAVE_PC // Redundant (but a defined value). | cmplw TMP0, TMP2 | stw BASE, L->base | stw TMP1, L->top | mr CARG1, L | bgt >5 // Need to grow stack. | mtctr TMP3 | bctrl // (lua_State *L) | // Either throws an error, or recovers and returns -1, 0 or nresults+1. | lwz BASE, L->base | cmpwi CRET1, 0 | slwi RD, CRET1, 3 | la RA, -8(BASE) | bgt ->fff_res // Returned nresults+1? |1: // Returned 0 or -1: retry fast path. | lwz TMP0, L->top | lwz LFUNC:RB, FRAME_FUNC(BASE) | sub NARGS8:RC, TMP0, BASE | bne ->vm_call_tail // Returned -1? | ins_callt // Returned 0: retry fast path. | |// Reconstruct previous base for vmeta_call during tailcall. |->vm_call_tail: | andi. TMP0, PC, FRAME_TYPE | rlwinm TMP1, PC, 0, 0, 28 | bne >3 | lwz INS, -4(PC) | decode_RA8 TMP1, INS | addi TMP1, TMP1, 8 |3: | sub TMP2, BASE, TMP1 | b ->vm_call_dispatch // Resolve again for tailcall. | |5: // Grow stack for fallback handler. | li CARG2, LUA_MINSTACK | bl extern lj_state_growstack // (lua_State *L, int n) | lwz BASE, L->base | cmpw TMP0, TMP0 // Set 4*cr0+eq to force retry. | b <1 | |->fff_gcstep: // Call GC step function. | // BASE = new base, RC = nargs*8 | mflr SAVE0 | stw BASE, L->base | add TMP0, BASE, NARGS8:RC | stw PC, SAVE_PC // Redundant (but a defined value). | stw TMP0, L->top | mr CARG1, L | bl extern lj_gc_step // (lua_State *L) | lwz BASE, L->base | mtlr SAVE0 | lwz TMP0, L->top | sub NARGS8:RC, TMP0, BASE | lwz CFUNC:RB, FRAME_FUNC(BASE) | blr | |//----------------------------------------------------------------------- |//-- Special dispatch targets ------------------------------------------- |//----------------------------------------------------------------------- | |->vm_record: // Dispatch target for recording phase. |.if JIT | NYI |.endif | |->vm_rethook: // Dispatch target for return hooks. | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) | andi. TMP0, TMP3, HOOK_ACTIVE // Hook already active? | beq >1 |5: // Re-dispatch to static ins. | addi TMP1, TMP1, GG_DISP2STATIC // Assumes decode_OP4 TMP1, INS. | lwzx TMP0, DISPATCH, TMP1 | mtctr TMP0 | bctr | |->vm_inshook: // Dispatch target for instr/line hooks. | lbz TMP3, DISPATCH_GL(hookmask)(DISPATCH) | lwz TMP2, DISPATCH_GL(hookcount)(DISPATCH) | andi. TMP0, TMP3, HOOK_ACTIVE // Hook already active? | rlwinm TMP0, TMP3, 31-LUA_HOOKLINE, 31, 0 | bne <5 | | cmpwi cr1, TMP0, 0 | addic. TMP2, TMP2, -1 | beq cr1, <5 | stw TMP2, DISPATCH_GL(hookcount)(DISPATCH) | beq >1 | bge cr1, <5 |1: | mr CARG1, L | stw MULTRES, SAVE_MULTRES | mr CARG2, PC | stw BASE, L->base | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. | bl extern lj_dispatch_ins // (lua_State *L, const BCIns *pc) |3: | lwz BASE, L->base |4: // Re-dispatch to static ins. | lwz INS, -4(PC) | decode_OP4 TMP1, INS | decode_RB8 RB, INS | addi TMP1, TMP1, GG_DISP2STATIC | decode_RD8 RD, INS | lwzx TMP0, DISPATCH, TMP1 | decode_RA8 RA, INS | decode_RC8 RC, INS | mtctr TMP0 | bctr | |->cont_hook: // Continue from hook yield. | addi PC, PC, 4 | lwz MULTRES, -20(RB) // Restore MULTRES for *M ins. | b <4 | |->vm_hotloop: // Hot loop counter underflow. |.if JIT | NYI |.endif | |->vm_callhook: // Dispatch target for call hooks. | mr CARG2, PC |.if JIT | b >1 |.endif | |->vm_hotcall: // Hot call counter underflow. |.if JIT | ori CARG2, PC, 1 |1: |.endif | add TMP0, BASE, RC | stw PC, SAVE_PC | mr CARG1, L | stw BASE, L->base | sub RA, RA, BASE | stw TMP0, L->top | bl extern lj_dispatch_call // (lua_State *L, const BCIns *pc) | // Returns ASMFunction. | lwz BASE, L->base | lwz TMP0, L->top | stw ZERO, SAVE_PC // Invalidate for subsequent line hook. | sub NARGS8:RC, TMP0, BASE | add RA, BASE, RA | lwz LFUNC:RB, FRAME_FUNC(BASE) | mtctr CRET1 | bctr | |//----------------------------------------------------------------------- |//-- Trace exit handler ------------------------------------------------- |//----------------------------------------------------------------------- | |->vm_exit_handler: |.if JIT | NYI |.endif |->vm_exit_interp: |.if JIT | NYI |.endif | |//----------------------------------------------------------------------- |//-- Math helper functions ---------------------------------------------- |//----------------------------------------------------------------------- | |// FP value rounding. Called by math.floor/math.ceil fast functions |// and from JIT code. |// |// This can be inlined if the CPU has the frin/friz/frip/frim instructions. |// The alternative hard-float approaches have a deep dependency chain. |// The resulting latency is at least 3x-7x the double-precision FP latency |// (e500v2: 6cy, e600: 5cy, Cell: 10cy) or around 20-70 cycles. |// |// The soft-float approach is tedious, but much faster (e500v2: ~11cy/~6cy). |// However it relies on a fast way to transfer the FP value to GPRs |// (e500v2: 0cy for lo-word, 1cy for hi-word). |// |.macro vm_round, name, mode | // Used temporaries: TMP0, TMP1, TMP2, TMP3. |->name.._efd: // Input: CARG2, output: CRET2 | evmergehi CARG1, CARG2, CARG2 |->name.._hilo: | // Input: CARG1 (hi), CARG2 (hi, lo), output: CRET2 | rlwinm TMP2, CARG1, 12, 21, 31 | addic. TMP2, TMP2, -1023 // exp = exponent(x) - 1023 | li TMP1, -1 | cmplwi cr1, TMP2, 51 // 0 <= exp <= 51? | subfic TMP0, TMP2, 52 | bgt cr1, >1 | lus TMP3, 0xfff0 | slw TMP0, TMP1, TMP0 // lomask = -1 << (52-exp) | sraw TMP1, TMP3, TMP2 // himask = (int32_t)0xfff00000 >> exp |.if mode == 2 // trunc(x): | evmergelo TMP0, TMP1, TMP0 | evand CRET2, CARG2, TMP0 // hi &= himask, lo &= lomask |.else | andc TMP2, CARG2, TMP0 | andc TMP3, CARG1, TMP1 | or TMP2, TMP2, TMP3 // ztest = (hi&~himask) | (lo&~lomask) | srawi TMP3, CARG1, 31 // signmask = (int32_t)hi >> 31 |.if mode == 0 // floor(x): | and. TMP2, TMP2, TMP3 // iszero = ((ztest & signmask) == 0) |.else // ceil(x): | andc. TMP2, TMP2, TMP3 // iszero = ((ztest & ~signmask) == 0) |.endif | and CARG2, CARG2, TMP0 // lo &= lomask | and CARG1, CARG1, TMP1 // hi &= himask | subc TMP0, CARG2, TMP0 | iseleq TMP0, CARG2, TMP0 // lo = iszero ? lo : lo-lomask | sube TMP1, CARG1, TMP1 | iseleq TMP1, CARG1, TMP1 // hi = iszero ? hi : hi-himask+carry | evmergelo CRET2, TMP1, TMP0 |.endif | blr |1: | bgtlr // Already done if >=2^52, +-inf or nan. |.if mode == 2 // trunc(x): | rlwinm TMP1, CARG1, 0, 0, 0 // hi = sign(x) | li TMP0, 0 | evmergelo CRET2, TMP1, TMP0 |.else | rlwinm TMP2, CARG1, 0, 1, 31 | srawi TMP0, CARG1, 31 // signmask = (int32_t)hi >> 31 | or TMP2, TMP2, CARG2 // ztest = abs(hi) | lo | lus TMP1, 0x3ff0 |.if mode == 0 // floor(x): | and. TMP2, TMP2, TMP0 // iszero = ((ztest & signmask) == 0) |.else // ceil(x): | andc. TMP2, TMP2, TMP0 // iszero = ((ztest & ~signmask) == 0) |.endif | li TMP0, 0 | iseleq TMP1, r0, TMP1 | rlwimi CARG1, TMP1, 0, 1, 31 // hi = sign(x) | (iszero ? 0.0 : 1.0) | evmergelo CRET2, CARG1, TMP0 |.endif | blr |.endmacro | |->vm_floor: | mflr CARG3 | evmergelo CARG2, CARG1, CARG2 | bl ->vm_floor_hilo | mtlr CARG3 | evmergehi CRET1, CRET2, CRET2 | blr | | vm_round vm_floor, 0 | vm_round vm_ceil, 1 |.if JIT | vm_round vm_trunc, 2 |.else |->vm_trunc_efd: |->vm_trunc_hilo: |.endif | |//----------------------------------------------------------------------- |//-- Miscellaneous functions -------------------------------------------- |//----------------------------------------------------------------------- | |//----------------------------------------------------------------------- |//-- FFI helper functions ----------------------------------------------- |//----------------------------------------------------------------------- | |->vm_ffi_call: |.if FFI | NYI |.endif | |//----------------------------------------------------------------------- } /* Generate the code for a single instruction. */ static void build_ins(BuildCtx *ctx, BCOp op, int defop) { int vk = 0; |=>defop: switch (op) { /* -- Comparison ops ---------------------------------------------------- */ /* Remember: all ops branch for a true comparison, fall through otherwise. */ case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: | // RA = src1*8, RD = src2*8, JMP with RD = target | evlddx TMP0, BASE, RA | addi PC, PC, 4 | evlddx TMP1, BASE, RD | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | lwz TMP2, -4(PC) | evmergehi RB, TMP0, TMP1 | decode_RD4 TMP2, TMP2 | checknum RB | add TMP2, TMP2, TMP3 | checkanyfail ->vmeta_comp | efdcmplt TMP0, TMP1 if (op == BC_ISLE || op == BC_ISGT) { | efdcmpeq cr1, TMP0, TMP1 | cror 4*cr0+gt, 4*cr0+gt, 4*cr1+gt } if (op == BC_ISLT || op == BC_ISLE) { | iselgt PC, TMP2, PC } else { | iselgt PC, PC, TMP2 } | ins_next break; case BC_ISEQV: case BC_ISNEV: vk = op == BC_ISEQV; | // RA = src1*8, RD = src2*8, JMP with RD = target | evlddx CARG2, BASE, RA | addi PC, PC, 4 | evlddx CARG3, BASE, RD | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | lwz TMP2, -4(PC) | evmergehi RB, CARG2, CARG3 | decode_RD4 TMP2, TMP2 | checknum RB | add TMP2, TMP2, TMP3 | checkanyfail >5 | efdcmpeq CARG2, CARG3 if (vk) { | iselgt PC, TMP2, PC } else { | iselgt PC, PC, TMP2 } |1: | ins_next | |5: // Either or both types are not numbers. | evcmpeq CARG2, CARG3 | not TMP3, RB | cmplwi cr1, TMP3, ~LJ_TISPRI // Primitive? | crorc 4*cr7+lt, 4*cr0+so, 4*cr0+lt // 1: Same tv or different type. | cmplwi cr6, TMP3, ~LJ_TISTABUD // Table or userdata? | crandc 4*cr7+gt, 4*cr0+lt, 4*cr1+gt // 2: Same type and primitive. | mr SAVE0, PC if (vk) { | isel PC, TMP2, PC, 4*cr7+gt } else { | isel TMP2, PC, TMP2, 4*cr7+gt } | cror 4*cr7+lt, 4*cr7+lt, 4*cr7+gt // 1 or 2. if (vk) { | isel PC, TMP2, PC, 4*cr0+so } else { | isel PC, PC, TMP2, 4*cr0+so } | blt cr7, <1 // Done if 1 or 2. | blt cr6, <1 // Done if not tab/ud. | | // Different tables or userdatas. Need to check __eq metamethod. | // Field metatable must be at same offset for GCtab and GCudata! | lwz TAB:TMP2, TAB:CARG2->metatable | li CARG4, 1-vk // ne = 0 or 1. | cmplwi TAB:TMP2, 0 | beq <1 // No metatable? | lbz TMP2, TAB:TMP2->nomm | andi. TMP2, TMP2, 1<vmeta_equal // Handle __eq metamethod. break; case BC_ISEQS: case BC_ISNES: vk = op == BC_ISEQS; | // RA = src*8, RD = str_const*8 (~), JMP with RD = target | evlddx TMP0, BASE, RA | srwi RD, RD, 1 | lwz INS, 0(PC) | subfic RD, RD, -4 | addi PC, PC, 4 | lwzx STR:TMP1, KBASE, RD // KBASE-4-str_const*4 | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | decode_RD4 TMP2, INS | evmergelo STR:TMP1, TISSTR, STR:TMP1 | add TMP2, TMP2, TMP3 | evcmpeq TMP0, STR:TMP1 if (vk) { | isel PC, TMP2, PC, 4*cr0+so } else { | isel PC, PC, TMP2, 4*cr0+so } | ins_next break; case BC_ISEQN: case BC_ISNEN: vk = op == BC_ISEQN; | // RA = src*8, RD = num_const*8, JMP with RD = target | evlddx TMP0, BASE, RA | addi PC, PC, 4 | evlddx TMP1, KBASE, RD | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | lwz INS, -4(PC) | checknum TMP0 | checkfail >5 | efdcmpeq TMP0, TMP1 |1: | decode_RD4 TMP2, INS | add TMP2, TMP2, TMP3 if (vk) { | iselgt PC, TMP2, PC |5: } else { | iselgt PC, PC, TMP2 } |3: | ins_next if (!vk) { |5: | decode_RD4 TMP2, INS | add PC, TMP2, TMP3 | b <3 } break; case BC_ISEQP: case BC_ISNEP: vk = op == BC_ISEQP; | // RA = src*8, RD = primitive_type*8 (~), JMP with RD = target | lwzx TMP0, BASE, RA | srwi TMP1, RD, 3 | lwz INS, 0(PC) | addi PC, PC, 4 | not TMP1, TMP1 | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | cmplw TMP0, TMP1 | decode_RD4 TMP2, INS | add TMP2, TMP2, TMP3 if (vk) { | iseleq PC, TMP2, PC } else { | iseleq PC, PC, TMP2 } | ins_next break; /* -- Unary test and copy ops ------------------------------------------- */ case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: | // RA = dst*8 or unused, RD = src*8, JMP with RD = target | evlddx TMP0, BASE, RD | evaddw TMP1, TISNIL, TISNIL // Synthesize LJ_TFALSE. | lwz INS, 0(PC) | evcmpltu TMP0, TMP1 | addi PC, PC, 4 if (op == BC_IST || op == BC_ISF) { | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | decode_RD4 TMP2, INS | add TMP2, TMP2, TMP3 if (op == BC_IST) { | isellt PC, TMP2, PC } else { | isellt PC, PC, TMP2 } } else { if (op == BC_ISTC) { | checkfail >1 } else { | checkok >1 } | addis PC, PC, -(BCBIAS_J*4 >> 16) | decode_RD4 TMP2, INS | evstddx TMP0, BASE, RA | add PC, PC, TMP2 |1: } | ins_next break; /* -- Unary ops --------------------------------------------------------- */ case BC_MOV: | // RA = dst*8, RD = src*8 | ins_next1 | evlddx TMP0, BASE, RD | evstddx TMP0, BASE, RA | ins_next2 break; case BC_NOT: | // RA = dst*8, RD = src*8 | ins_next1 | lwzx TMP0, BASE, RD | subfic TMP1, TMP0, LJ_TTRUE | adde TMP0, TMP0, TMP1 | stwx TMP0, BASE, RA | ins_next2 break; case BC_UNM: | // RA = dst*8, RD = src*8 | evlddx TMP0, BASE, RD | checknum TMP0 | checkfail ->vmeta_unm | efdneg TMP0, TMP0 | ins_next1 | evstddx TMP0, BASE, RA | ins_next2 break; case BC_LEN: | // RA = dst*8, RD = src*8 | evlddx CARG1, BASE, RD | checkstr CARG1 | checkfail >2 | lwz CRET1, STR:CARG1->len |1: | ins_next1 | efdcfsi TMP0, CRET1 | evstddx TMP0, BASE, RA | ins_next2 |2: | checktab CARG1 | checkfail ->vmeta_len #if LJ_52 | lwz TAB:TMP2, TAB:CARG1->metatable | cmplwi TAB:TMP2, 0 | bne >9 |3: #endif |->BC_LEN_Z: | bl extern lj_tab_len // (GCtab *t) | // Returns uint32_t (but less than 2^31). | b <1 #if LJ_52 |9: | lbz TMP0, TAB:TMP2->nomm | andi. TMP0, TMP0, 1<vmeta_len #endif break; /* -- Binary ops -------------------------------------------------------- */ |.macro ins_arithpre, t0, t1 | // RA = dst*8, RB = src1*8, RC = src2*8 | num_const*8 ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); ||switch (vk) { ||case 0: | evlddx t0, BASE, RB | checknum t0 | evlddx t1, KBASE, RC | checkfail ->vmeta_arith_vn || break; ||case 1: | evlddx t1, BASE, RB | checknum t1 | evlddx t0, KBASE, RC | checkfail ->vmeta_arith_nv || break; ||default: | evlddx t0, BASE, RB | evlddx t1, BASE, RC | evmergehi TMP2, t0, t1 | checknum TMP2 | checkanyfail ->vmeta_arith_vv || break; ||} |.endmacro | |.macro ins_arith, ins | ins_arithpre TMP0, TMP1 | ins_next1 | ins TMP0, TMP0, TMP1 | evstddx TMP0, BASE, RA | ins_next2 |.endmacro case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: | ins_arith efdadd break; case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: | ins_arith efdsub break; case BC_MULVN: case BC_MULNV: case BC_MULVV: | ins_arith efdmul break; case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: | ins_arith efddiv break; case BC_MODVN: | ins_arithpre RD, SAVE0 |->BC_MODVN_Z: | efddiv CARG2, RD, SAVE0 | bl ->vm_floor_efd // floor(b/c) | efdmul TMP0, CRET2, SAVE0 | ins_next1 | efdsub TMP0, RD, TMP0 // b - floor(b/c)*c | evstddx TMP0, BASE, RA | ins_next2 break; case BC_MODNV: case BC_MODVV: | ins_arithpre RD, SAVE0 | b ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. break; case BC_POW: | evlddx CARG2, BASE, RB | evlddx CARG4, BASE, RC | evmergehi CARG1, CARG4, CARG2 | checknum CARG1 | evmergehi CARG3, CARG4, CARG4 | checkanyfail ->vmeta_arith_vv | bl extern pow | evmergelo CRET2, CRET1, CRET2 | evstddx CRET2, BASE, RA | ins_next break; case BC_CAT: | // RA = dst*8, RB = src_start*8, RC = src_end*8 | sub CARG3, RC, RB | stw BASE, L->base | add CARG2, BASE, RC | mr SAVE0, RB |->BC_CAT_Z: | stw PC, SAVE_PC | mr CARG1, L | srwi CARG3, CARG3, 3 | bl extern lj_meta_cat // (lua_State *L, TValue *top, int left) | // Returns NULL (finished) or TValue * (metamethod). | cmplwi CRET1, 0 | lwz BASE, L->base | bne ->vmeta_binop | evlddx TMP0, BASE, SAVE0 // Copy result from RB to RA. | evstddx TMP0, BASE, RA | ins_next break; /* -- Constant ops ------------------------------------------------------ */ case BC_KSTR: | // RA = dst*8, RD = str_const*8 (~) | ins_next1 | srwi TMP1, RD, 1 | subfic TMP1, TMP1, -4 | lwzx TMP0, KBASE, TMP1 // KBASE-4-str_const*4 | evmergelo TMP0, TISSTR, TMP0 | evstddx TMP0, BASE, RA | ins_next2 break; case BC_KCDATA: |.if FFI | // RA = dst*8, RD = cdata_const*8 (~) | ins_next1 | srwi TMP1, RD, 1 | subfic TMP1, TMP1, -4 | lwzx TMP0, KBASE, TMP1 // KBASE-4-cdata_const*4 | li TMP2, LJ_TCDATA | evmergelo TMP0, TMP2, TMP0 | evstddx TMP0, BASE, RA | ins_next2 |.endif break; case BC_KSHORT: | // RA = dst*8, RD = int16_literal*8 | srwi TMP1, RD, 3 | extsh TMP1, TMP1 | ins_next1 | efdcfsi TMP0, TMP1 | evstddx TMP0, BASE, RA | ins_next2 break; case BC_KNUM: | // RA = dst*8, RD = num_const*8 | evlddx TMP0, KBASE, RD | ins_next1 | evstddx TMP0, BASE, RA | ins_next2 break; case BC_KPRI: | // RA = dst*8, RD = primitive_type*8 (~) | srwi TMP1, RD, 3 | not TMP0, TMP1 | ins_next1 | stwx TMP0, BASE, RA | ins_next2 break; case BC_KNIL: | // RA = base*8, RD = end*8 | evstddx TISNIL, BASE, RA | addi RA, RA, 8 |1: | evstddx TISNIL, BASE, RA | cmpw RA, RD | addi RA, RA, 8 | blt <1 | ins_next_ break; /* -- Upvalue and function ops ------------------------------------------ */ case BC_UGET: | // RA = dst*8, RD = uvnum*8 | ins_next1 | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi RD, RD, 1 | addi RD, RD, offsetof(GCfuncL, uvptr) | lwzx UPVAL:RB, LFUNC:RB, RD | lwz TMP1, UPVAL:RB->v | evldd TMP0, 0(TMP1) | evstddx TMP0, BASE, RA | ins_next2 break; case BC_USETV: | // RA = uvnum*8, RD = src*8 | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi RA, RA, 1 | addi RA, RA, offsetof(GCfuncL, uvptr) | evlddx TMP1, BASE, RD | lwzx UPVAL:RB, LFUNC:RB, RA | lbz TMP3, UPVAL:RB->marked | lwz CARG2, UPVAL:RB->v | andi. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) | lbz TMP0, UPVAL:RB->closed | evmergehi TMP2, TMP1, TMP1 | evstdd TMP1, 0(CARG2) | cmplwi cr1, TMP0, 0 | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq | subi TMP2, TMP2, (LJ_TISNUM+1) | bne >2 // Upvalue is closed and black? |1: | ins_next | |2: // Check if new value is collectable. | cmplwi TMP2, LJ_TISGCV - (LJ_TISNUM+1) | bge <1 // tvisgcv(v) | lbz TMP3, GCOBJ:TMP1->gch.marked | andi. TMP3, TMP3, LJ_GC_WHITES // iswhite(v) | la CARG1, GG_DISP2G(DISPATCH) | // Crossed a write barrier. Move the barrier forward. | beq <1 | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) | b <1 break; case BC_USETS: | // RA = uvnum*8, RD = str_const*8 (~) | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi TMP1, RD, 1 | srwi RA, RA, 1 | subfic TMP1, TMP1, -4 | addi RA, RA, offsetof(GCfuncL, uvptr) | lwzx STR:TMP1, KBASE, TMP1 // KBASE-4-str_const*4 | lwzx UPVAL:RB, LFUNC:RB, RA | evmergelo STR:TMP1, TISSTR, STR:TMP1 | lbz TMP3, UPVAL:RB->marked | lwz CARG2, UPVAL:RB->v | andi. TMP3, TMP3, LJ_GC_BLACK // isblack(uv) | lbz TMP3, STR:TMP1->marked | lbz TMP2, UPVAL:RB->closed | evstdd STR:TMP1, 0(CARG2) | bne >2 |1: | ins_next | |2: // Check if string is white and ensure upvalue is closed. | andi. TMP3, TMP3, LJ_GC_WHITES // iswhite(str) | cmplwi cr1, TMP2, 0 | cror 4*cr0+eq, 4*cr0+eq, 4*cr1+eq | la CARG1, GG_DISP2G(DISPATCH) | // Crossed a write barrier. Move the barrier forward. | beq <1 | bl extern lj_gc_barrieruv // (global_State *g, TValue *tv) | b <1 break; case BC_USETN: | // RA = uvnum*8, RD = num_const*8 | ins_next1 | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi RA, RA, 1 | addi RA, RA, offsetof(GCfuncL, uvptr) | evlddx TMP0, KBASE, RD | lwzx UPVAL:RB, LFUNC:RB, RA | lwz TMP1, UPVAL:RB->v | evstdd TMP0, 0(TMP1) | ins_next2 break; case BC_USETP: | // RA = uvnum*8, RD = primitive_type*8 (~) | ins_next1 | lwz LFUNC:RB, FRAME_FUNC(BASE) | srwi RA, RA, 1 | addi RA, RA, offsetof(GCfuncL, uvptr) | srwi TMP0, RD, 3 | lwzx UPVAL:RB, LFUNC:RB, RA | not TMP0, TMP0 | lwz TMP1, UPVAL:RB->v | stw TMP0, 0(TMP1) | ins_next2 break; case BC_UCLO: | // RA = level*8, RD = target | lwz TMP1, L->openupval | branch_RD // Do this first since RD is not saved. | stw BASE, L->base | cmplwi TMP1, 0 | mr CARG1, L | beq >1 | add CARG2, BASE, RA | bl extern lj_func_closeuv // (lua_State *L, TValue *level) | lwz BASE, L->base |1: | ins_next break; case BC_FNEW: | // RA = dst*8, RD = proto_const*8 (~) (holding function prototype) | srwi TMP1, RD, 1 | stw BASE, L->base | subfic TMP1, TMP1, -4 | stw PC, SAVE_PC | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 | mr CARG1, L | lwz CARG3, FRAME_FUNC(BASE) | // (lua_State *L, GCproto *pt, GCfuncL *parent) | bl extern lj_func_newL_gc | // Returns GCfuncL *. | lwz BASE, L->base | evmergelo LFUNC:CRET1, TISFUNC, LFUNC:CRET1 | evstddx LFUNC:CRET1, BASE, RA | ins_next break; /* -- Table ops --------------------------------------------------------- */ case BC_TNEW: case BC_TDUP: | // RA = dst*8, RD = (hbits|asize)*8 | tab_const*8 (~) | lwz TMP0, DISPATCH_GL(gc.total)(DISPATCH) | mr CARG1, L | lwz TMP1, DISPATCH_GL(gc.threshold)(DISPATCH) | stw BASE, L->base | cmplw TMP0, TMP1 | stw PC, SAVE_PC | bge >5 |1: if (op == BC_TNEW) { | rlwinm CARG2, RD, 29, 21, 31 | rlwinm CARG3, RD, 18, 27, 31 | cmpwi CARG2, 0x7ff | li TMP1, 0x801 | iseleq CARG2, TMP1, CARG2 | bl extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) | // Returns Table *. } else { | srwi TMP1, RD, 1 | subfic TMP1, TMP1, -4 | lwzx CARG2, KBASE, TMP1 // KBASE-4-tab_const*4 | bl extern lj_tab_dup // (lua_State *L, Table *kt) | // Returns Table *. } | lwz BASE, L->base | evmergelo TAB:CRET1, TISTAB, TAB:CRET1 | evstddx TAB:CRET1, BASE, RA | ins_next |5: | mr SAVE0, RD | bl extern lj_gc_step_fixtop // (lua_State *L) | mr RD, SAVE0 | mr CARG1, L | b <1 break; case BC_GGET: | // RA = dst*8, RD = str_const*8 (~) case BC_GSET: | // RA = src*8, RD = str_const*8 (~) | lwz LFUNC:TMP2, FRAME_FUNC(BASE) | srwi TMP1, RD, 1 | lwz TAB:RB, LFUNC:TMP2->env | subfic TMP1, TMP1, -4 | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 if (op == BC_GGET) { | b ->BC_TGETS_Z } else { | b ->BC_TSETS_Z } break; case BC_TGETV: | // RA = dst*8, RB = table*8, RC = key*8 | evlddx TAB:RB, BASE, RB | evlddx RC, BASE, RC | checktab TAB:RB | checkfail ->vmeta_tgetv | checknum RC | checkfail >5 | // Convert number key to integer | efdctsi TMP2, RC | lwz TMP0, TAB:RB->asize | efdcfsi TMP1, TMP2 | cmplw cr0, TMP0, TMP2 | efdcmpeq cr1, RC, TMP1 | lwz TMP1, TAB:RB->array | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+gt | slwi TMP2, TMP2, 3 | ble ->vmeta_tgetv // Integer key and in array part? | evlddx TMP1, TMP1, TMP2 | checknil TMP1 | checkok >2 |1: | evstddx TMP1, BASE, RA | ins_next | |2: // Check for __index if table value is nil. | lwz TAB:TMP2, TAB:RB->metatable | cmplwi TAB:TMP2, 0 | beq <1 // No metatable: done. | lbz TMP0, TAB:TMP2->nomm | andi. TMP0, TMP0, 1<vmeta_tgetv | |5: | checkstr STR:RC // String key? | checkok ->BC_TGETS_Z | b ->vmeta_tgetv break; case BC_TGETS: | // RA = dst*8, RB = table*8, RC = str_const*8 (~) | evlddx TAB:RB, BASE, RB | srwi TMP1, RC, 1 | checktab TAB:RB | subfic TMP1, TMP1, -4 | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 | checkfail ->vmeta_tgets1 |->BC_TGETS_Z: | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = dst*8 | lwz TMP0, TAB:RB->hmask | lwz TMP1, STR:RC->hash | lwz NODE:TMP2, TAB:RB->node | evmergelo STR:RC, TISSTR, STR:RC | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | slwi TMP0, TMP1, 5 | slwi TMP1, TMP1, 3 | sub TMP1, TMP0, TMP1 | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) |1: | evldd TMP0, NODE:TMP2->key | evldd TMP1, NODE:TMP2->val | evcmpeq TMP0, STR:RC | checkanyfail >4 | checknil TMP1 | checkok >5 // Key found, but nil value? |3: | evstddx TMP1, BASE, RA | ins_next | |4: // Follow hash chain. | lwz NODE:TMP2, NODE:TMP2->next | cmplwi NODE:TMP2, 0 | bne <1 | // End of hash chain: key not found, nil result. | evmr TMP1, TISNIL | |5: // Check for __index if table value is nil. | lwz TAB:TMP2, TAB:RB->metatable | cmplwi TAB:TMP2, 0 | beq <3 // No metatable: done. | lbz TMP0, TAB:TMP2->nomm | andi. TMP0, TMP0, 1<vmeta_tgets break; case BC_TGETB: | // RA = dst*8, RB = table*8, RC = index*8 | evlddx TAB:RB, BASE, RB | srwi TMP0, RC, 3 | checktab TAB:RB | checkfail ->vmeta_tgetb | lwz TMP1, TAB:RB->asize | lwz TMP2, TAB:RB->array | cmplw TMP0, TMP1 | bge ->vmeta_tgetb | evlddx TMP1, TMP2, RC | checknil TMP1 | checkok >5 |1: | ins_next1 | evstddx TMP1, BASE, RA | ins_next2 | |5: // Check for __index if table value is nil. | lwz TAB:TMP2, TAB:RB->metatable | cmplwi TAB:TMP2, 0 | beq <1 // No metatable: done. | lbz TMP2, TAB:TMP2->nomm | andi. TMP2, TMP2, 1<vmeta_tgetb // Caveat: preserve TMP0! break; case BC_TSETV: | // RA = src*8, RB = table*8, RC = key*8 | evlddx TAB:RB, BASE, RB | evlddx RC, BASE, RC | checktab TAB:RB | checkfail ->vmeta_tsetv | checknum RC | checkfail >5 | // Convert number key to integer | efdctsi TMP2, RC | evlddx SAVE0, BASE, RA | lwz TMP0, TAB:RB->asize | efdcfsi TMP1, TMP2 | cmplw cr0, TMP0, TMP2 | efdcmpeq cr1, RC, TMP1 | lwz TMP1, TAB:RB->array | crand 4*cr0+gt, 4*cr0+gt, 4*cr1+gt | slwi TMP0, TMP2, 3 | ble ->vmeta_tsetv // Integer key and in array part? | lbz TMP3, TAB:RB->marked | evlddx TMP2, TMP1, TMP0 | checknil TMP2 | checkok >3 |1: | andi. TMP2, TMP3, LJ_GC_BLACK // isblack(table) | evstddx SAVE0, TMP1, TMP0 | bne >7 |2: | ins_next | |3: // Check for __newindex if previous value is nil. | lwz TAB:TMP2, TAB:RB->metatable | cmplwi TAB:TMP2, 0 | beq <1 // No metatable: done. | lbz TMP2, TAB:TMP2->nomm | andi. TMP2, TMP2, 1<vmeta_tsetv | |5: | checkstr STR:RC // String key? | checkok ->BC_TSETS_Z | b ->vmeta_tsetv | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0 | b <2 break; case BC_TSETS: | // RA = src*8, RB = table*8, RC = str_const*8 (~) | evlddx TAB:RB, BASE, RB | srwi TMP1, RC, 1 | checktab TAB:RB | subfic TMP1, TMP1, -4 | lwzx STR:RC, KBASE, TMP1 // KBASE-4-str_const*4 | checkfail ->vmeta_tsets1 |->BC_TSETS_Z: | // TAB:RB = GCtab *, STR:RC = GCstr *, RA = src*8 | lwz TMP0, TAB:RB->hmask | lwz TMP1, STR:RC->hash | lwz NODE:TMP2, TAB:RB->node | evmergelo STR:RC, TISSTR, STR:RC | stb ZERO, TAB:RB->nomm // Clear metamethod cache. | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | evlddx SAVE0, BASE, RA | slwi TMP0, TMP1, 5 | slwi TMP1, TMP1, 3 | sub TMP1, TMP0, TMP1 | lbz TMP3, TAB:RB->marked | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) |1: | evldd TMP0, NODE:TMP2->key | evldd TMP1, NODE:TMP2->val | evcmpeq TMP0, STR:RC | checkanyfail >5 | checknil TMP1 | checkok >4 // Key found, but nil value? |2: | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) | evstdd SAVE0, NODE:TMP2->val | bne >7 |3: | ins_next | |4: // Check for __newindex if previous value is nil. | lwz TAB:TMP1, TAB:RB->metatable | cmplwi TAB:TMP1, 0 | beq <2 // No metatable: done. | lbz TMP0, TAB:TMP1->nomm | andi. TMP0, TMP0, 1<vmeta_tsets | |5: // Follow hash chain. | lwz NODE:TMP2, NODE:TMP2->next | cmplwi NODE:TMP2, 0 | bne <1 | // End of hash chain: key not found, add a new one. | | // But check for __newindex first. | lwz TAB:TMP1, TAB:RB->metatable | la CARG3, DISPATCH_GL(tmptv)(DISPATCH) | stw PC, SAVE_PC | mr CARG1, L | cmplwi TAB:TMP1, 0 | stw BASE, L->base | beq >6 // No metatable: continue. | lbz TMP0, TAB:TMP1->nomm | andi. TMP0, TMP0, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. |6: | mr CARG2, TAB:RB | evstdd STR:RC, 0(CARG3) | bl extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) | // Returns TValue *. | lwz BASE, L->base | evstdd SAVE0, 0(CRET1) | b <3 // No 2nd write barrier needed. | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0 | b <3 break; case BC_TSETB: | // RA = src*8, RB = table*8, RC = index*8 | evlddx TAB:RB, BASE, RB | srwi TMP0, RC, 3 | checktab TAB:RB | checkfail ->vmeta_tsetb | lwz TMP1, TAB:RB->asize | lwz TMP2, TAB:RB->array | lbz TMP3, TAB:RB->marked | cmplw TMP0, TMP1 | evlddx SAVE0, BASE, RA | bge ->vmeta_tsetb | evlddx TMP1, TMP2, RC | checknil TMP1 | checkok >5 |1: | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) | evstddx SAVE0, TMP2, RC | bne >7 |2: | ins_next | |5: // Check for __newindex if previous value is nil. | lwz TAB:TMP1, TAB:RB->metatable | cmplwi TAB:TMP1, 0 | beq <1 // No metatable: done. | lbz TMP1, TAB:TMP1->nomm | andi. TMP1, TMP1, 1<vmeta_tsetb // Caveat: preserve TMP0! | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, TMP3, TMP0 | b <2 break; case BC_TSETM: | // RA = base*8 (table at base-1), RD = num_const*8 (start index) | add RA, BASE, RA |1: | add TMP3, KBASE, RD | lwz TAB:CARG2, -4(RA) // Guaranteed to be a table. | addic. TMP0, MULTRES, -8 | lwz TMP3, 4(TMP3) // Integer constant is in lo-word. | srwi CARG3, TMP0, 3 | beq >4 // Nothing to copy? | add CARG3, CARG3, TMP3 | lwz TMP2, TAB:CARG2->asize | slwi TMP1, TMP3, 3 | lbz TMP3, TAB:CARG2->marked | cmplw CARG3, TMP2 | add TMP2, RA, TMP0 | lwz TMP0, TAB:CARG2->array | bgt >5 | add TMP1, TMP1, TMP0 | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) |3: // Copy result slots to table. | evldd TMP0, 0(RA) | addi RA, RA, 8 | cmpw cr1, RA, TMP2 | evstdd TMP0, 0(TMP1) | addi TMP1, TMP1, 8 | blt cr1, <3 | bne >7 |4: | ins_next | |5: // Need to resize array part. | stw BASE, L->base | mr CARG1, L | stw PC, SAVE_PC | mr SAVE0, RD | bl extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) | // Must not reallocate the stack. | mr RD, SAVE0 | b <1 | |7: // Possible table write barrier for any value. Skip valiswhite check. | barrierback TAB:CARG2, TMP3, TMP0 | b <4 break; /* -- Calls and vararg handling ----------------------------------------- */ case BC_CALLM: | // RA = base*8, (RB = (nresults+1)*8,) RC = extra_nargs*8 | add NARGS8:RC, NARGS8:RC, MULTRES | // Fall through. Assumes BC_CALL follows. break; case BC_CALL: | // RA = base*8, (RB = (nresults+1)*8,) RC = (nargs+1)*8 | evlddx LFUNC:RB, BASE, RA | mr TMP2, BASE | add BASE, BASE, RA | subi NARGS8:RC, NARGS8:RC, 8 | checkfunc LFUNC:RB | addi BASE, BASE, 8 | checkfail ->vmeta_call | ins_call break; case BC_CALLMT: | // RA = base*8, (RB = 0,) RC = extra_nargs*8 | add NARGS8:RC, NARGS8:RC, MULTRES | // Fall through. Assumes BC_CALLT follows. break; case BC_CALLT: | // RA = base*8, (RB = 0,) RC = (nargs+1)*8 | evlddx LFUNC:RB, BASE, RA | add RA, BASE, RA | lwz TMP1, FRAME_PC(BASE) | subi NARGS8:RC, NARGS8:RC, 8 | checkfunc LFUNC:RB | addi RA, RA, 8 | checkfail ->vmeta_callt |->BC_CALLT_Z: | andi. TMP0, TMP1, FRAME_TYPE // Caveat: preserve cr0 until the crand. | lbz TMP3, LFUNC:RB->ffid | xori TMP2, TMP1, FRAME_VARG | cmplwi cr1, NARGS8:RC, 0 | bne >7 |1: | stw LFUNC:RB, FRAME_FUNC(BASE) // Copy function down, but keep PC. | li TMP2, 0 | cmplwi cr7, TMP3, 1 // (> FF_C) Calling a fast function? | beq cr1, >3 |2: | addi TMP3, TMP2, 8 | evlddx TMP0, RA, TMP2 | cmplw cr1, TMP3, NARGS8:RC | evstddx TMP0, BASE, TMP2 | mr TMP2, TMP3 | bne cr1, <2 |3: | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+gt | beq >5 |4: | ins_callt | |5: // Tailcall to a fast function with a Lua frame below. | lwz INS, -4(TMP1) | decode_RA8 RA, INS | sub TMP1, BASE, RA | lwz LFUNC:TMP1, FRAME_FUNC-8(TMP1) | lwz TMP1, LFUNC:TMP1->pc | lwz KBASE, PC2PROTO(k)(TMP1) // Need to prepare KBASE. | b <4 | |7: // Tailcall from a vararg function. | andi. TMP0, TMP2, FRAME_TYPEP | bne <1 // Vararg frame below? | sub BASE, BASE, TMP2 // Relocate BASE down. | lwz TMP1, FRAME_PC(BASE) | andi. TMP0, TMP1, FRAME_TYPE | b <1 break; case BC_ITERC: | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 ((2+1)*8)) | subi RA, RA, 24 // evldd doesn't support neg. offsets. | mr TMP2, BASE | evlddx LFUNC:RB, BASE, RA | add BASE, BASE, RA | evldd TMP0, 8(BASE) | evldd TMP1, 16(BASE) | evstdd LFUNC:RB, 24(BASE) // Copy callable. | checkfunc LFUNC:RB | evstdd TMP0, 32(BASE) // Copy state. | li NARGS8:RC, 16 // Iterators get 2 arguments. | evstdd TMP1, 40(BASE) // Copy control var. | addi BASE, BASE, 32 | checkfail ->vmeta_call | ins_call break; case BC_ITERN: | // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8) |.if JIT | // NYI: add hotloop, record BC_ITERN. |.endif | add RA, BASE, RA | lwz TAB:RB, -12(RA) | lwz RC, -4(RA) // Get index from control var. | lwz TMP0, TAB:RB->asize | lwz TMP1, TAB:RB->array | addi PC, PC, 4 |1: // Traverse array part. | cmplw RC, TMP0 | slwi TMP3, RC, 3 | bge >5 // Index points after array part? | evlddx TMP2, TMP1, TMP3 | checknil TMP2 | lwz INS, -4(PC) | checkok >4 | efdcfsi TMP0, RC | addi RC, RC, 1 | addis TMP3, PC, -(BCBIAS_J*4 >> 16) | evstdd TMP2, 8(RA) | decode_RD4 TMP1, INS | stw RC, -4(RA) // Update control var. | add PC, TMP1, TMP3 | evstdd TMP0, 0(RA) |3: | ins_next | |4: // Skip holes in array part. | addi RC, RC, 1 | b <1 | |5: // Traverse hash part. | lwz TMP1, TAB:RB->hmask | sub RC, RC, TMP0 | lwz TMP2, TAB:RB->node |6: | cmplw RC, TMP1 // End of iteration? Branch to ITERL+1. | slwi TMP3, RC, 5 | bgt <3 | slwi RB, RC, 3 | sub TMP3, TMP3, RB | evlddx RB, TMP2, TMP3 | add NODE:TMP3, TMP2, TMP3 | checknil RB | lwz INS, -4(PC) | checkok >7 | evldd TMP3, NODE:TMP3->key | addis TMP2, PC, -(BCBIAS_J*4 >> 16) | evstdd RB, 8(RA) | add RC, RC, TMP0 | decode_RD4 TMP1, INS | evstdd TMP3, 0(RA) | addi RC, RC, 1 | add PC, TMP1, TMP2 | stw RC, -4(RA) // Update control var. | b <3 | |7: // Skip holes in hash part. | addi RC, RC, 1 | b <6 break; case BC_ISNEXT: | // RA = base*8, RD = target (points to ITERN) | add RA, BASE, RA | li TMP2, -24 | evlddx CFUNC:TMP1, RA, TMP2 | lwz TMP2, -16(RA) | lwz TMP3, -8(RA) | evmergehi TMP0, CFUNC:TMP1, CFUNC:TMP1 | cmpwi cr0, TMP2, LJ_TTAB | cmpwi cr1, TMP0, LJ_TFUNC | cmpwi cr6, TMP3, LJ_TNIL | bne cr1, >5 | lbz TMP1, CFUNC:TMP1->ffid | crand 4*cr0+eq, 4*cr0+eq, 4*cr6+eq | cmpwi cr7, TMP1, FF_next_N | srwi TMP0, RD, 1 | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq | add TMP3, PC, TMP0 | bne cr0, >5 | lus TMP1, 0xfffe | ori TMP1, TMP1, 0x7fff | stw ZERO, -4(RA) // Initialize control var. | stw TMP1, -8(RA) | addis PC, TMP3, -(BCBIAS_J*4 >> 16) |1: | ins_next |5: // Despecialize bytecode if any of the checks fail. | li TMP0, BC_JMP | li TMP1, BC_ITERC | stb TMP0, -1(PC) | addis PC, TMP3, -(BCBIAS_J*4 >> 16) | stb TMP1, 3(PC) | b <1 break; case BC_VARG: | // RA = base*8, RB = (nresults+1)*8, RC = numparams*8 | lwz TMP0, FRAME_PC(BASE) | add RC, BASE, RC | add RA, BASE, RA | addi RC, RC, FRAME_VARG | add TMP2, RA, RB | subi TMP3, BASE, 8 // TMP3 = vtop | sub RC, RC, TMP0 // RC = vbase | // Note: RC may now be even _above_ BASE if nargs was < numparams. | cmplwi cr1, RB, 0 | sub. TMP1, TMP3, RC | beq cr1, >5 // Copy all varargs? | subi TMP2, TMP2, 16 | ble >2 // No vararg slots? |1: // Copy vararg slots to destination slots. | evldd TMP0, 0(RC) | addi RC, RC, 8 | evstdd TMP0, 0(RA) | cmplw RA, TMP2 | cmplw cr1, RC, TMP3 | bge >3 // All destination slots filled? | addi RA, RA, 8 | blt cr1, <1 // More vararg slots? |2: // Fill up remainder with nil. | evstdd TISNIL, 0(RA) | cmplw RA, TMP2 | addi RA, RA, 8 | blt <2 |3: | ins_next | |5: // Copy all varargs. | lwz TMP0, L->maxstack | li MULTRES, 8 // MULTRES = (0+1)*8 | ble <3 // No vararg slots? | add TMP2, RA, TMP1 | cmplw TMP2, TMP0 | addi MULTRES, TMP1, 8 | bgt >7 |6: | evldd TMP0, 0(RC) | addi RC, RC, 8 | evstdd TMP0, 0(RA) | cmplw RC, TMP3 | addi RA, RA, 8 | blt <6 // More vararg slots? | b <3 | |7: // Grow stack for varargs. | mr CARG1, L | stw RA, L->top | sub SAVE0, RC, BASE // Need delta, because BASE may change. | stw BASE, L->base | sub RA, RA, BASE | stw PC, SAVE_PC | srwi CARG2, TMP1, 3 | bl extern lj_state_growstack // (lua_State *L, int n) | lwz BASE, L->base | add RA, BASE, RA | add RC, BASE, SAVE0 | subi TMP3, BASE, 8 | b <6 break; /* -- Returns ----------------------------------------------------------- */ case BC_RETM: | // RA = results*8, RD = extra_nresults*8 | add RD, RD, MULTRES // MULTRES >= 8, so RD >= 8. | // Fall through. Assumes BC_RET follows. break; case BC_RET: | // RA = results*8, RD = (nresults+1)*8 | lwz PC, FRAME_PC(BASE) | add RA, BASE, RA | mr MULTRES, RD |1: | andi. TMP0, PC, FRAME_TYPE | xori TMP1, PC, FRAME_VARG | bne ->BC_RETV_Z | |->BC_RET_Z: | // BASE = base, RA = resultptr, RD = (nresults+1)*8, PC = return | lwz INS, -4(PC) | cmpwi RD, 8 | subi TMP2, BASE, 8 | subi RC, RD, 8 | decode_RB8 RB, INS | beq >3 | li TMP1, 0 |2: | addi TMP3, TMP1, 8 | evlddx TMP0, RA, TMP1 | cmpw TMP3, RC | evstddx TMP0, TMP2, TMP1 | beq >3 | addi TMP1, TMP3, 8 | evlddx TMP0, RA, TMP3 | cmpw TMP1, RC | evstddx TMP0, TMP2, TMP3 | bne <2 |3: |5: | cmplw RB, RD | decode_RA8 RA, INS | bgt >6 | sub BASE, TMP2, RA | lwz LFUNC:TMP1, FRAME_FUNC(BASE) | ins_next1 | lwz TMP1, LFUNC:TMP1->pc | lwz KBASE, PC2PROTO(k)(TMP1) | ins_next2 | |6: // Fill up results with nil. | subi TMP1, RD, 8 | addi RD, RD, 8 | evstddx TISNIL, TMP2, TMP1 | b <5 | |->BC_RETV_Z: // Non-standard return case. | andi. TMP2, TMP1, FRAME_TYPEP | bne ->vm_return | // Return from vararg function: relocate BASE down. | sub BASE, BASE, TMP1 | lwz PC, FRAME_PC(BASE) | b <1 break; case BC_RET0: case BC_RET1: | // RA = results*8, RD = (nresults+1)*8 | lwz PC, FRAME_PC(BASE) | add RA, BASE, RA | mr MULTRES, RD | andi. TMP0, PC, FRAME_TYPE | xori TMP1, PC, FRAME_VARG | bne ->BC_RETV_Z | | lwz INS, -4(PC) | subi TMP2, BASE, 8 | decode_RB8 RB, INS if (op == BC_RET1) { | evldd TMP0, 0(RA) | evstdd TMP0, 0(TMP2) } |5: | cmplw RB, RD | decode_RA8 RA, INS | bgt >6 | sub BASE, TMP2, RA | lwz LFUNC:TMP1, FRAME_FUNC(BASE) | ins_next1 | lwz TMP1, LFUNC:TMP1->pc | lwz KBASE, PC2PROTO(k)(TMP1) | ins_next2 | |6: // Fill up results with nil. | subi TMP1, RD, 8 | addi RD, RD, 8 | evstddx TISNIL, TMP2, TMP1 | b <5 break; /* -- Loops and branches ------------------------------------------------ */ case BC_FORL: |.if JIT | hotloop |.endif | // Fall through. Assumes BC_IFORL follows. break; case BC_JFORI: case BC_JFORL: #if !LJ_HASJIT break; #endif case BC_FORI: case BC_IFORL: | // RA = base*8, RD = target (after end of loop or start of loop) vk = (op == BC_IFORL || op == BC_JFORL); | add RA, BASE, RA | evldd TMP1, FORL_IDX*8(RA) | evldd TMP3, FORL_STEP*8(RA) | evldd TMP2, FORL_STOP*8(RA) if (!vk) { | evcmpgtu cr0, TMP1, TISNUM | evcmpgtu cr7, TMP3, TISNUM | evcmpgtu cr1, TMP2, TISNUM | cror 4*cr0+lt, 4*cr0+lt, 4*cr7+lt | cror 4*cr0+lt, 4*cr0+lt, 4*cr1+lt | blt ->vmeta_for } if (vk) { | efdadd TMP1, TMP1, TMP3 | evstdd TMP1, FORL_IDX*8(RA) } | evcmpgts TMP3, TISNIL | evstdd TMP1, FORL_EXT*8(RA) | bge >2 | efdcmpgt TMP1, TMP2 |1: if (op != BC_JFORL) { | srwi RD, RD, 1 | add RD, PC, RD if (op == BC_JFORI) { | addis PC, RD, -(BCBIAS_J*4 >> 16) } else { | addis RD, RD, -(BCBIAS_J*4 >> 16) } } if (op == BC_FORI) { | iselgt PC, RD, PC } else if (op == BC_IFORL) { | iselgt PC, PC, RD } else { | ble =>BC_JLOOP } | ins_next |2: | efdcmpgt TMP2, TMP1 | b <1 break; case BC_ITERL: |.if JIT | hotloop |.endif | // Fall through. Assumes BC_IITERL follows. break; case BC_JITERL: #if !LJ_HASJIT break; #endif case BC_IITERL: | // RA = base*8, RD = target | evlddx TMP1, BASE, RA | subi RA, RA, 8 | checknil TMP1 | checkok >1 // Stop if iterator returned nil. if (op == BC_JITERL) { | NYI } else { | branch_RD // Otherwise save control var + branch. | evstddx TMP1, BASE, RA } |1: | ins_next break; case BC_LOOP: | // RA = base*8, RD = target (loop extent) | // Note: RA/RD is only used by trace recorder to determine scope/extent | // This opcode does NOT jump, it's only purpose is to detect a hot loop. |.if JIT | hotloop |.endif | // Fall through. Assumes BC_ILOOP follows. break; case BC_ILOOP: | // RA = base*8, RD = target (loop extent) | ins_next break; case BC_JLOOP: |.if JIT | NYI |.endif break; case BC_JMP: | // RA = base*8 (only used by trace recorder), RD = target | branch_RD | ins_next break; /* -- Function headers -------------------------------------------------- */ case BC_FUNCF: |.if JIT | hotcall |.endif case BC_FUNCV: /* NYI: compiled vararg functions. */ | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. break; case BC_JFUNCF: #if !LJ_HASJIT break; #endif case BC_IFUNCF: | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 | lwz TMP2, L->maxstack | lbz TMP1, -4+PC2PROTO(numparams)(PC) | lwz KBASE, -4+PC2PROTO(k)(PC) | cmplw RA, TMP2 | slwi TMP1, TMP1, 3 | bgt ->vm_growstack_l | ins_next1 |2: | cmplw NARGS8:RC, TMP1 // Check for missing parameters. | ble >3 if (op == BC_JFUNCF) { | NYI } else { | ins_next2 } | |3: // Clear missing parameters. | evstddx TISNIL, BASE, NARGS8:RC | addi NARGS8:RC, NARGS8:RC, 8 | b <2 break; case BC_JFUNCV: #if !LJ_HASJIT break; #endif | NYI // NYI: compiled vararg functions break; /* NYI: compiled vararg functions. */ case BC_IFUNCV: | // BASE = new base, RA = BASE+framesize*8, RB = LFUNC, RC = nargs*8 | lwz TMP2, L->maxstack | add TMP1, BASE, RC | add TMP0, RA, RC | stw LFUNC:RB, 4(TMP1) // Store copy of LFUNC. | addi TMP3, RC, 8+FRAME_VARG | lwz KBASE, -4+PC2PROTO(k)(PC) | cmplw TMP0, TMP2 | stw TMP3, 0(TMP1) // Store delta + FRAME_VARG. | bge ->vm_growstack_l | lbz TMP2, -4+PC2PROTO(numparams)(PC) | mr RA, BASE | mr RC, TMP1 | ins_next1 | cmpwi TMP2, 0 | addi BASE, TMP1, 8 | beq >3 |1: | cmplw RA, RC // Less args than parameters? | evldd TMP0, 0(RA) | bge >4 | evstdd TISNIL, 0(RA) // Clear old fixarg slot (help the GC). | addi RA, RA, 8 |2: | addic. TMP2, TMP2, -1 | evstdd TMP0, 8(TMP1) | addi TMP1, TMP1, 8 | bne <1 |3: | ins_next2 | |4: // Clear missing parameters. | evmr TMP0, TISNIL | b <2 break; case BC_FUNCC: case BC_FUNCCW: | // BASE = new base, RA = BASE+framesize*8, RB = CFUNC, RC = nargs*8 if (op == BC_FUNCC) { | lwz TMP3, CFUNC:RB->f } else { | lwz TMP3, DISPATCH_GL(wrapf)(DISPATCH) } | add TMP1, RA, NARGS8:RC | lwz TMP2, L->maxstack | add RC, BASE, NARGS8:RC | stw BASE, L->base | cmplw TMP1, TMP2 | stw RC, L->top | li_vmstate C | mtctr TMP3 if (op == BC_FUNCCW) { | lwz CARG2, CFUNC:RB->f } | mr CARG1, L | bgt ->vm_growstack_c // Need to grow stack. | st_vmstate | bctrl // (lua_State *L [, lua_CFunction f]) | // Returns nresults. | lwz TMP1, L->top | slwi RD, CRET1, 3 | lwz BASE, L->base | li_vmstate INTERP | lwz PC, FRAME_PC(BASE) // Fetch PC of caller. | sub RA, TMP1, RD // RA = L->top - nresults*8 | st_vmstate | b ->vm_returnc break; /* ---------------------------------------------------------------------- */ default: fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); exit(2); break; } } static int build_backend(BuildCtx *ctx) { int op; dasm_growpc(Dst, BC__MAX); build_subroutines(ctx); |.code_op for (op = 0; op < BC__MAX; op++) build_ins(ctx, (BCOp)op, op); return BC__MAX; } /* Emit pseudo frame-info for all assembler functions. */ static void emit_asm_debug(BuildCtx *ctx) { int i; switch (ctx->mode) { case BUILD_elfasm: fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); fprintf(ctx->fp, ".Lframe0:\n" "\t.long .LECIE0-.LSCIE0\n" ".LSCIE0:\n" "\t.long 0xffffffff\n" "\t.byte 0x1\n" "\t.string \"\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 65\n" "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" "\t.align 2\n" ".LECIE0:\n\n"); fprintf(ctx->fp, ".LSFDE0:\n" "\t.long .LEFDE0-.LASFDE0\n" ".LASFDE0:\n" "\t.long .Lframe0\n" "\t.long .Lbegin\n" "\t.long %d\n" "\t.byte 0xe\n\t.uleb128 %d\n" "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n", (int)ctx->codesz, CFRAME_SIZE); for (i = 14; i <= 31; i++) fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n" "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n", 0x80+i, 1+2*(31-i), 1200+i, 2+2*(31-i)); fprintf(ctx->fp, "\t.align 2\n" ".LEFDE0:\n\n"); fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); fprintf(ctx->fp, ".Lframe1:\n" "\t.long .LECIE1-.LSCIE1\n" ".LSCIE1:\n" "\t.long 0\n" "\t.byte 0x1\n" "\t.string \"zPR\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -4\n" "\t.byte 65\n" "\t.uleb128 6\n" /* augmentation length */ "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.long lj_err_unwind_dwarf-.\n" "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n" "\t.align 2\n" ".LECIE1:\n\n"); fprintf(ctx->fp, ".LSFDE1:\n" "\t.long .LEFDE1-.LASFDE1\n" ".LASFDE1:\n" "\t.long .LASFDE1-.Lframe1\n" "\t.long .Lbegin-.\n" "\t.long %d\n" "\t.uleb128 0\n" /* augmentation length */ "\t.byte 0xe\n\t.uleb128 %d\n" "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n" "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n", (int)ctx->codesz, CFRAME_SIZE); for (i = 14; i <= 31; i++) fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n" "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n", 0x80+i, 1+2*(31-i), 1200+i, 2+2*(31-i)); fprintf(ctx->fp, "\t.align 2\n" ".LEFDE1:\n\n"); break; default: break; } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/vm_x86.dasc ================================================ |// Low-level VM code for x86 CPUs. |// Bytecode interpreter, fast functions and helper functions. |// Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h | |.if P64 |.arch x64 |.else |.arch x86 |.endif |.section code_op, code_sub | |.actionlist build_actionlist |.globals GLOB_ |.globalnames globnames |.externnames extnames | |//----------------------------------------------------------------------- | |.if P64 |.define X64, 1 |.define SSE, 1 |.if WIN |.define X64WIN, 1 |.endif |.endif | |// Fixed register assignments for the interpreter. |// This is very fragile and has many dependencies. Caveat emptor. |.define BASE, edx // Not C callee-save, refetched anyway. |.if not X64 |.define KBASE, edi // Must be C callee-save. |.define KBASEa, KBASE |.define PC, esi // Must be C callee-save. |.define PCa, PC |.define DISPATCH, ebx // Must be C callee-save. |.elif X64WIN |.define KBASE, edi // Must be C callee-save. |.define KBASEa, rdi |.define PC, esi // Must be C callee-save. |.define PCa, rsi |.define DISPATCH, ebx // Must be C callee-save. |.else |.define KBASE, r15d // Must be C callee-save. |.define KBASEa, r15 |.define PC, ebx // Must be C callee-save. |.define PCa, rbx |.define DISPATCH, r14d // Must be C callee-save. |.endif | |.define RA, ecx |.define RAH, ch |.define RAL, cl |.define RB, ebp // Must be ebp (C callee-save). |.define RC, eax // Must be eax. |.define RCW, ax |.define RCH, ah |.define RCL, al |.define OP, RB |.define RD, RC |.define RDW, RCW |.define RDL, RCL |.if X64 |.define RAa, rcx |.define RBa, rbp |.define RCa, rax |.define RDa, rax |.else |.define RAa, RA |.define RBa, RB |.define RCa, RC |.define RDa, RD |.endif | |.if not X64 |.define FCARG1, ecx // x86 fastcall arguments. |.define FCARG2, edx |.elif X64WIN |.define CARG1, rcx // x64/WIN64 C call arguments. |.define CARG2, rdx |.define CARG3, r8 |.define CARG4, r9 |.define CARG1d, ecx |.define CARG2d, edx |.define CARG3d, r8d |.define CARG4d, r9d |.define FCARG1, CARG1d // Upwards compatible to x86 fastcall. |.define FCARG2, CARG2d |.else |.define CARG1, rdi // x64/POSIX C call arguments. |.define CARG2, rsi |.define CARG3, rdx |.define CARG4, rcx |.define CARG5, r8 |.define CARG6, r9 |.define CARG1d, edi |.define CARG2d, esi |.define CARG3d, edx |.define CARG4d, ecx |.define CARG5d, r8d |.define CARG6d, r9d |.define FCARG1, CARG1d // Simulate x86 fastcall. |.define FCARG2, CARG2d |.endif | |// Type definitions. Some of these are only used for documentation. |.type L, lua_State |.type GL, global_State |.type TVALUE, TValue |.type GCOBJ, GCobj |.type STR, GCstr |.type TAB, GCtab |.type LFUNC, GCfuncL |.type CFUNC, GCfuncC |.type PROTO, GCproto |.type UPVAL, GCupval |.type NODE, Node |.type NARGS, int |.type TRACE, GCtrace | |// Stack layout while in interpreter. Must match with lj_frame.h. |//----------------------------------------------------------------------- |.if not X64 // x86 stack layout. | |.define CFRAME_SPACE, aword*7 // Delta for esp (see <--). |.macro saveregs_ | push edi; push esi; push ebx | sub esp, CFRAME_SPACE |.endmacro |.macro saveregs | push ebp; saveregs_ |.endmacro |.macro restoreregs | add esp, CFRAME_SPACE | pop ebx; pop esi; pop edi; pop ebp |.endmacro | |.define SAVE_ERRF, aword [esp+aword*15] // vm_pcall/vm_cpcall only. |.define SAVE_NRES, aword [esp+aword*14] |.define SAVE_CFRAME, aword [esp+aword*13] |.define SAVE_L, aword [esp+aword*12] |//----- 16 byte aligned, ^^^ arguments from C caller |.define SAVE_RET, aword [esp+aword*11] //<-- esp entering interpreter. |.define SAVE_R4, aword [esp+aword*10] |.define SAVE_R3, aword [esp+aword*9] |.define SAVE_R2, aword [esp+aword*8] |//----- 16 byte aligned |.define SAVE_R1, aword [esp+aword*7] //<-- esp after register saves. |.define SAVE_PC, aword [esp+aword*6] |.define TMP2, aword [esp+aword*5] |.define TMP1, aword [esp+aword*4] |//----- 16 byte aligned |.define ARG4, aword [esp+aword*3] |.define ARG3, aword [esp+aword*2] |.define ARG2, aword [esp+aword*1] |.define ARG1, aword [esp] //<-- esp while in interpreter. |//----- 16 byte aligned, ^^^ arguments for C callee | |// FPARGx overlaps ARGx and ARG(x+1) on x86. |.define FPARG3, qword [esp+qword*1] |.define FPARG1, qword [esp] |// TMPQ overlaps TMP1/TMP2. ARG5/MULTRES overlap TMP1/TMP2 (and TMPQ). |.define TMPQ, qword [esp+aword*4] |.define TMP3, ARG4 |.define ARG5, TMP1 |.define TMPa, TMP1 |.define MULTRES, TMP2 | |// Arguments for vm_call and vm_pcall. |.define INARG_BASE, SAVE_CFRAME // Overwritten by SAVE_CFRAME! | |// Arguments for vm_cpcall. |.define INARG_CP_CALL, SAVE_ERRF |.define INARG_CP_UD, SAVE_NRES |.define INARG_CP_FUNC, SAVE_CFRAME | |//----------------------------------------------------------------------- |.elif X64WIN // x64/Windows stack layout | |.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). |.macro saveregs_ | push rdi; push rsi; push rbx | sub rsp, CFRAME_SPACE |.endmacro |.macro saveregs | push rbp; saveregs_ |.endmacro |.macro restoreregs | add rsp, CFRAME_SPACE | pop rbx; pop rsi; pop rdi; pop rbp |.endmacro | |.define SAVE_CFRAME, aword [rsp+aword*13] |.define SAVE_PC, dword [rsp+dword*25] |.define SAVE_L, dword [rsp+dword*24] |.define SAVE_ERRF, dword [rsp+dword*23] |.define SAVE_NRES, dword [rsp+dword*22] |.define TMP2, dword [rsp+dword*21] |.define TMP1, dword [rsp+dword*20] |//----- 16 byte aligned, ^^^ 32 byte register save area, owned by interpreter |.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. |.define SAVE_R4, aword [rsp+aword*8] |.define SAVE_R3, aword [rsp+aword*7] |.define SAVE_R2, aword [rsp+aword*6] |.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. |.define ARG5, aword [rsp+aword*4] |.define CSAVE_4, aword [rsp+aword*3] |.define CSAVE_3, aword [rsp+aword*2] |.define CSAVE_2, aword [rsp+aword*1] |.define CSAVE_1, aword [rsp] //<-- rsp while in interpreter. |//----- 16 byte aligned, ^^^ 32 byte register save area, owned by callee | |// TMPQ overlaps TMP1/TMP2. MULTRES overlaps TMP2 (and TMPQ). |.define TMPQ, qword [rsp+aword*10] |.define MULTRES, TMP2 |.define TMPa, ARG5 |.define ARG5d, dword [rsp+aword*4] |.define TMP3, ARG5d | |//----------------------------------------------------------------------- |.else // x64/POSIX stack layout | |.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). |.macro saveregs_ | push rbx; push r15; push r14 | sub rsp, CFRAME_SPACE |.endmacro |.macro saveregs | push rbp; saveregs_ |.endmacro |.macro restoreregs | add rsp, CFRAME_SPACE | pop r14; pop r15; pop rbx; pop rbp |.endmacro | |//----- 16 byte aligned, |.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. |.define SAVE_R4, aword [rsp+aword*8] |.define SAVE_R3, aword [rsp+aword*7] |.define SAVE_R2, aword [rsp+aword*6] |.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. |.define SAVE_CFRAME, aword [rsp+aword*4] |.define SAVE_PC, dword [rsp+dword*7] |.define SAVE_L, dword [rsp+dword*6] |.define SAVE_ERRF, dword [rsp+dword*5] |.define SAVE_NRES, dword [rsp+dword*4] |.define TMPa, aword [rsp+aword*1] |.define TMP2, dword [rsp+dword*1] |.define TMP1, dword [rsp] //<-- rsp while in interpreter. |//----- 16 byte aligned | |// TMPQ overlaps TMP1/TMP2. MULTRES overlaps TMP2 (and TMPQ). |.define TMPQ, qword [rsp] |.define TMP3, dword [rsp+aword*1] |.define MULTRES, TMP2 | |.endif | |//----------------------------------------------------------------------- | |// Instruction headers. |.macro ins_A; .endmacro |.macro ins_AD; .endmacro |.macro ins_AJ; .endmacro |.macro ins_ABC; movzx RB, RCH; movzx RC, RCL; .endmacro |.macro ins_AB_; movzx RB, RCH; .endmacro |.macro ins_A_C; movzx RC, RCL; .endmacro |.macro ins_AND; not RDa; .endmacro | |// Instruction decode+dispatch. Carefully tuned (nope, lodsd is not faster). |.macro ins_NEXT | mov RC, [PC] | movzx RA, RCH | movzx OP, RCL | add PC, 4 | shr RC, 16 |.if X64 | jmp aword [DISPATCH+OP*8] |.else | jmp aword [DISPATCH+OP*4] |.endif |.endmacro | |// Instruction footer. |.if 1 | // Replicated dispatch. Less unpredictable branches, but higher I-Cache use. | .define ins_next, ins_NEXT | .define ins_next_, ins_NEXT |.else | // Common dispatch. Lower I-Cache use, only one (very) unpredictable branch. | // Affects only certain kinds of benchmarks (and only with -j off). | // Around 10%-30% slower on Core2, a lot more slower on P4. | .macro ins_next | jmp ->ins_next | .endmacro | .macro ins_next_ | ->ins_next: | ins_NEXT | .endmacro |.endif | |// Call decode and dispatch. |.macro ins_callt | // BASE = new base, RB = LFUNC, RD = nargs+1, [BASE-4] = PC | mov PC, LFUNC:RB->pc | mov RA, [PC] | movzx OP, RAL | movzx RA, RAH | add PC, 4 |.if X64 | jmp aword [DISPATCH+OP*8] |.else | jmp aword [DISPATCH+OP*4] |.endif |.endmacro | |.macro ins_call | // BASE = new base, RB = LFUNC, RD = nargs+1 | mov [BASE-4], PC | ins_callt |.endmacro | |//----------------------------------------------------------------------- | |// Macros to test operand types. |.macro checktp, reg, tp; cmp dword [BASE+reg*8+4], tp; .endmacro |.macro checknum, reg, target; checktp reg, LJ_TISNUM; jae target; .endmacro |.macro checkint, reg, target; checktp reg, LJ_TISNUM; jne target; .endmacro |.macro checkstr, reg, target; checktp reg, LJ_TSTR; jne target; .endmacro |.macro checktab, reg, target; checktp reg, LJ_TTAB; jne target; .endmacro | |// These operands must be used with movzx. |.define PC_OP, byte [PC-4] |.define PC_RA, byte [PC-3] |.define PC_RB, byte [PC-1] |.define PC_RC, byte [PC-2] |.define PC_RD, word [PC-2] | |.macro branchPC, reg | lea PC, [PC+reg*4-BCBIAS_J*4] |.endmacro | |// Assumes DISPATCH is relative to GL. #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) | #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) | |// Decrement hashed hotcount and trigger trace recorder if zero. |.macro hotloop, reg | mov reg, PC | shr reg, 1 | and reg, HOTCOUNT_PCMASK | sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_LOOP | jb ->vm_hotloop |.endmacro | |.macro hotcall, reg | mov reg, PC | shr reg, 1 | and reg, HOTCOUNT_PCMASK | sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_CALL | jb ->vm_hotcall |.endmacro | |// Set current VM state. |.macro set_vmstate, st | mov dword [DISPATCH+DISPATCH_GL(vmstate)], ~LJ_VMST_..st |.endmacro | |// x87 compares. |.macro fcomparepp // Compare and pop st0 >< st1. | fucomip st1 | fpop |.endmacro | |.macro fdup; fld st0; .endmacro |.macro fpop1; fstp st1; .endmacro | |// Synthesize SSE FP constants. |.macro sseconst_abs, reg, tmp // Synthesize abs mask. |.if X64 | mov64 tmp, U64x(7fffffff,ffffffff); movd reg, tmp |.else | pxor reg, reg; pcmpeqd reg, reg; psrlq reg, 1 |.endif |.endmacro | |.macro sseconst_hi, reg, tmp, val // Synthesize hi-32 bit const. |.if X64 | mov64 tmp, U64x(val,00000000); movd reg, tmp |.else | mov tmp, 0x .. val; movd reg, tmp; pshufd reg, reg, 0x51 |.endif |.endmacro | |.macro sseconst_sign, reg, tmp // Synthesize sign mask. | sseconst_hi reg, tmp, 80000000 |.endmacro |.macro sseconst_1, reg, tmp // Synthesize 1.0. | sseconst_hi reg, tmp, 3ff00000 |.endmacro |.macro sseconst_m1, reg, tmp // Synthesize -1.0. | sseconst_hi reg, tmp, bff00000 |.endmacro |.macro sseconst_2p52, reg, tmp // Synthesize 2^52. | sseconst_hi reg, tmp, 43300000 |.endmacro |.macro sseconst_tobit, reg, tmp // Synthesize 2^52 + 2^51. | sseconst_hi reg, tmp, 43380000 |.endmacro | |// Move table write barrier back. Overwrites reg. |.macro barrierback, tab, reg | and byte tab->marked, (uint8_t)~LJ_GC_BLACK // black2gray(tab) | mov reg, [DISPATCH+DISPATCH_GL(gc.grayagain)] | mov [DISPATCH+DISPATCH_GL(gc.grayagain)], tab | mov tab->gclist, reg |.endmacro | |//----------------------------------------------------------------------- /* Generate subroutines used by opcodes and other parts of the VM. */ /* The .code_sub section should be last to help static branch prediction. */ static void build_subroutines(BuildCtx *ctx) { |.code_sub | |//----------------------------------------------------------------------- |//-- Return handling ---------------------------------------------------- |//----------------------------------------------------------------------- | |->vm_returnp: | test PC, FRAME_P | jz ->cont_dispatch | | // Return from pcall or xpcall fast func. | and PC, -8 | sub BASE, PC // Restore caller base. | lea RAa, [RA+PC-8] // Rebase RA and prepend one result. | mov PC, [BASE-4] // Fetch PC of previous frame. | // Prepending may overwrite the pcall frame, so do it at the end. | mov dword [BASE+RA+4], LJ_TTRUE // Prepend true to results. | |->vm_returnc: | add RD, 1 // RD = nresults+1 | jz ->vm_unwind_yield | mov MULTRES, RD | test PC, FRAME_TYPE | jz ->BC_RET_Z // Handle regular return to Lua. | |->vm_return: | // BASE = base, RA = resultofs, RD = nresults+1 (= MULTRES), PC = return | xor PC, FRAME_C | test PC, FRAME_TYPE | jnz ->vm_returnp | | // Return to C. | set_vmstate C | and PC, -8 | sub PC, BASE | neg PC // Previous base = BASE - delta. | | sub RD, 1 | jz >2 |1: // Move results down. |.if X64 | mov RBa, [BASE+RA] | mov [BASE-8], RBa |.else | mov RB, [BASE+RA] | mov [BASE-8], RB | mov RB, [BASE+RA+4] | mov [BASE-4], RB |.endif | add BASE, 8 | sub RD, 1 | jnz <1 |2: | mov L:RB, SAVE_L | mov L:RB->base, PC |3: | mov RD, MULTRES | mov RA, SAVE_NRES // RA = wanted nresults+1 |4: | cmp RA, RD | jne >6 // More/less results wanted? |5: | sub BASE, 8 | mov L:RB->top, BASE | |->vm_leave_cp: | mov RAa, SAVE_CFRAME // Restore previous C frame. | mov L:RB->cframe, RAa | xor eax, eax // Ok return status for vm_pcall. | |->vm_leave_unw: | restoreregs | ret | |6: | jb >7 // Less results wanted? | // More results wanted. Check stack size and fill up results with nil. | cmp BASE, L:RB->maxstack | ja >8 | mov dword [BASE-4], LJ_TNIL | add BASE, 8 | add RD, 1 | jmp <4 | |7: // Less results wanted. | test RA, RA | jz <5 // But check for LUA_MULTRET+1. | sub RA, RD // Negative result! | lea BASE, [BASE+RA*8] // Correct top. | jmp <5 | |8: // Corner case: need to grow stack for filling up results. | // This can happen if: | // - A C function grows the stack (a lot). | // - The GC shrinks the stack in between. | // - A return back from a lua_call() with (high) nresults adjustment. | mov L:RB->top, BASE // Save current top held in BASE (yes). | mov MULTRES, RD // Need to fill only remainder with nil. | mov FCARG2, RA | mov FCARG1, L:RB | call extern lj_state_growstack@8 // (lua_State *L, int n) | mov BASE, L:RB->top // Need the (realloced) L->top in BASE. | jmp <3 | |->vm_unwind_yield: | mov al, LUA_YIELD | jmp ->vm_unwind_c_eh | |->vm_unwind_c@8: // Unwind C stack, return from vm_pcall. | // (void *cframe, int errcode) |.if X64 | mov eax, CARG2d // Error return status for vm_pcall. | mov rsp, CARG1 |.else | mov eax, FCARG2 // Error return status for vm_pcall. | mov esp, FCARG1 |.endif |->vm_unwind_c_eh: // Landing pad for external unwinder. | mov L:RB, SAVE_L | mov GL:RB, L:RB->glref | mov dword GL:RB->vmstate, ~LJ_VMST_C | jmp ->vm_leave_unw | |->vm_unwind_rethrow: |.if X64 and not X64WIN | mov FCARG1, SAVE_L | mov FCARG2, eax | restoreregs | jmp extern lj_err_throw@8 // (lua_State *L, int errcode) |.endif | |->vm_unwind_ff@4: // Unwind C stack, return from ff pcall. | // (void *cframe) |.if X64 | and CARG1, CFRAME_RAWMASK | mov rsp, CARG1 |.else | and FCARG1, CFRAME_RAWMASK | mov esp, FCARG1 |.endif |->vm_unwind_ff_eh: // Landing pad for external unwinder. | mov L:RB, SAVE_L | mov RAa, -8 // Results start at BASE+RA = BASE-8. | mov RD, 1+1 // Really 1+2 results, incr. later. | mov BASE, L:RB->base | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. | add DISPATCH, GG_G2DISP | mov PC, [BASE-4] // Fetch PC of previous frame. | mov dword [BASE-4], LJ_TFALSE // Prepend false to error message. | set_vmstate INTERP | jmp ->vm_returnc // Increments RD/MULTRES and returns. | |//----------------------------------------------------------------------- |//-- Grow stack for calls ----------------------------------------------- |//----------------------------------------------------------------------- | |->vm_growstack_c: // Grow stack for C function. | mov FCARG2, LUA_MINSTACK | jmp >2 | |->vm_growstack_v: // Grow stack for vararg Lua function. | sub RD, 8 | jmp >1 | |->vm_growstack_f: // Grow stack for fixarg Lua function. | // BASE = new base, RD = nargs+1, RB = L, PC = first PC | lea RD, [BASE+NARGS:RD*8-8] |1: | movzx RA, byte [PC-4+PC2PROTO(framesize)] | add PC, 4 // Must point after first instruction. | mov L:RB->base, BASE | mov L:RB->top, RD | mov SAVE_PC, PC | mov FCARG2, RA |2: | // RB = L, L->base = new base, L->top = top | mov FCARG1, L:RB | call extern lj_state_growstack@8 // (lua_State *L, int n) | mov BASE, L:RB->base | mov RD, L:RB->top | mov LFUNC:RB, [BASE-8] | sub RD, BASE | shr RD, 3 | add NARGS:RD, 1 | // BASE = new base, RB = LFUNC, RD = nargs+1 | ins_callt // Just retry the call. | |//----------------------------------------------------------------------- |//-- Entry points into the assembler VM --------------------------------- |//----------------------------------------------------------------------- | |->vm_resume: // Setup C frame and resume thread. | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) | saveregs |.if X64 | mov L:RB, CARG1d // Caveat: CARG1d may be RA. | mov SAVE_L, CARG1d | mov RA, CARG2d |.else | mov L:RB, SAVE_L | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! |.endif | mov PC, FRAME_CP | xor RD, RD | lea KBASEa, [esp+CFRAME_RESUME] | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. | add DISPATCH, GG_G2DISP | mov L:RB->cframe, KBASEa | mov SAVE_PC, RD // Any value outside of bytecode is ok. | mov SAVE_CFRAME, RDa |.if X64 | mov SAVE_NRES, RD | mov SAVE_ERRF, RD |.endif | cmp byte L:RB->status, RDL | je >3 // Initial resume (like a call). | | // Resume after yield (like a return). | set_vmstate INTERP | mov byte L:RB->status, RDL | mov BASE, L:RB->base | mov RD, L:RB->top | sub RD, RA | shr RD, 3 | add RD, 1 // RD = nresults+1 | sub RA, BASE // RA = resultofs | mov PC, [BASE-4] | mov MULTRES, RD | test PC, FRAME_TYPE | jz ->BC_RET_Z | jmp ->vm_return | |->vm_pcall: // Setup protected C frame and enter VM. | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) | saveregs | mov PC, FRAME_CP |.if X64 | mov SAVE_ERRF, CARG4d |.endif | jmp >1 | |->vm_call: // Setup C frame and enter VM. | // (lua_State *L, TValue *base, int nres1) | saveregs | mov PC, FRAME_C | |1: // Entry point for vm_pcall above (PC = ftype). |.if X64 | mov SAVE_NRES, CARG3d | mov L:RB, CARG1d // Caveat: CARG1d may be RA. | mov SAVE_L, CARG1d | mov RA, CARG2d |.else | mov L:RB, SAVE_L | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! |.endif | | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. | mov SAVE_CFRAME, KBASEa | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. |.if X64 | mov L:RB->cframe, rsp |.else | mov L:RB->cframe, esp |.endif | |2: // Entry point for vm_cpcall below (RA = base, RB = L, PC = ftype). | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. | add DISPATCH, GG_G2DISP | |3: // Entry point for vm_resume above (RA = base, RB = L, PC = ftype). | set_vmstate INTERP | mov BASE, L:RB->base // BASE = old base (used in vmeta_call). | add PC, RA | sub PC, BASE // PC = frame delta + frame type | | mov RD, L:RB->top | sub RD, RA | shr NARGS:RD, 3 | add NARGS:RD, 1 // RD = nargs+1 | |->vm_call_dispatch: | mov LFUNC:RB, [RA-8] | cmp dword [RA-4], LJ_TFUNC | jne ->vmeta_call // Ensure KBASE defined and != BASE. | |->vm_call_dispatch_f: | mov BASE, RA | ins_call | // BASE = new base, RB = func, RD = nargs+1, PC = caller PC | |->vm_cpcall: // Setup protected C frame, call C. | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) | saveregs |.if X64 | mov L:RB, CARG1d // Caveat: CARG1d may be RA. | mov SAVE_L, CARG1d |.else | mov L:RB, SAVE_L | // Caveat: INARG_CP_* and SAVE_CFRAME/SAVE_NRES/SAVE_ERRF overlap! | mov RC, INARG_CP_UD // Get args before they are overwritten. | mov RA, INARG_CP_FUNC | mov BASE, INARG_CP_CALL |.endif | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. | | mov KBASE, L:RB->stack // Compute -savestack(L, L->top). | sub KBASE, L:RB->top | mov SAVE_ERRF, 0 // No error function. | mov SAVE_NRES, KBASE // Neg. delta means cframe w/o frame. | // Handler may change cframe_nres(L->cframe) or cframe_errfunc(L->cframe). | |.if X64 | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. | mov SAVE_CFRAME, KBASEa | mov L:RB->cframe, rsp | | call CARG4 // (lua_State *L, lua_CFunction func, void *ud) |.else | mov ARG3, RC // Have to copy args downwards. | mov ARG2, RA | mov ARG1, L:RB | | mov KBASE, L:RB->cframe // Add our C frame to cframe chain. | mov SAVE_CFRAME, KBASE | mov L:RB->cframe, esp | | call BASE // (lua_State *L, lua_CFunction func, void *ud) |.endif | // TValue * (new base) or NULL returned in eax (RC). | test RC, RC | jz ->vm_leave_cp // No base? Just remove C frame. | mov RA, RC | mov PC, FRAME_CP | jmp <2 // Else continue with the call. | |//----------------------------------------------------------------------- |//-- Metamethod handling ------------------------------------------------ |//----------------------------------------------------------------------- | |//-- Continuation dispatch ---------------------------------------------- | |->cont_dispatch: | // BASE = meta base, RA = resultofs, RD = nresults+1 (also in MULTRES) | add RA, BASE | and PC, -8 | mov RB, BASE | sub BASE, PC // Restore caller BASE. | mov dword [RA+RD*8-4], LJ_TNIL // Ensure one valid arg. | mov RC, RA // ... in [RC] | mov PC, [RB-12] // Restore PC from [cont|PC]. |.if X64 | movsxd RAa, dword [RB-16] // May be negative on WIN64 with debug. |.if FFI | cmp RA, 1 | jbe >1 |.endif | lea KBASEa, qword [=>0] | add RAa, KBASEa |.else | mov RA, dword [RB-16] |.if FFI | cmp RA, 1 | jbe >1 |.endif |.endif | mov LFUNC:KBASE, [BASE-8] | mov KBASE, LFUNC:KBASE->pc | mov KBASE, [KBASE+PC2PROTO(k)] | // BASE = base, RC = result, RB = meta base | jmp RAa // Jump to continuation. | |.if FFI |1: | je ->cont_ffi_callback // cont = 1: return from FFI callback. | // cont = 0: Tail call from C function. | sub RB, BASE | shr RB, 3 | lea RD, [RB-1] | jmp ->vm_call_tail |.endif | |->cont_cat: // BASE = base, RC = result, RB = mbase | movzx RA, PC_RB | sub RB, 16 | lea RA, [BASE+RA*8] | sub RA, RB | je ->cont_ra | neg RA | shr RA, 3 |.if X64WIN | mov CARG3d, RA | mov L:CARG1d, SAVE_L | mov L:CARG1d->base, BASE | mov RCa, [RC] | mov [RB], RCa | mov CARG2d, RB |.elif X64 | mov L:CARG1d, SAVE_L | mov L:CARG1d->base, BASE | mov CARG3d, RA | mov RAa, [RC] | mov [RB], RAa | mov CARG2d, RB |.else | mov ARG3, RA | mov RA, [RC+4] | mov RC, [RC] | mov [RB+4], RA | mov [RB], RC | mov ARG2, RB |.endif | jmp ->BC_CAT_Z | |//-- Table indexing metamethods ----------------------------------------- | |->vmeta_tgets: | mov TMP1, RC // RC = GCstr * | mov TMP2, LJ_TSTR | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. | cmp PC_OP, BC_GGET | jne >1 | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. | mov [RA], TAB:RB // RB = GCtab * | mov dword [RA+4], LJ_TTAB | mov RB, RA | jmp >2 | |->vmeta_tgetb: | movzx RC, PC_RC |.if DUALNUM | mov TMP2, LJ_TISNUM | mov TMP1, RC |.elif SSE | cvtsi2sd xmm0, RC | movsd TMPQ, xmm0 |.else | mov ARG4, RC | fild ARG4 | fstp TMPQ |.endif | lea RCa, TMPQ // Store temp. TValue in TMPQ. | jmp >1 | |->vmeta_tgetv: | movzx RC, PC_RC // Reload TValue *k from RC. | lea RC, [BASE+RC*8] |1: | movzx RB, PC_RB // Reload TValue *t from RB. | lea RB, [BASE+RB*8] |2: |.if X64 | mov L:CARG1d, SAVE_L | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | mov CARG2d, RB | mov CARG3, RCa // May be 64 bit ptr to stack. | mov L:RB, L:CARG1d |.else | mov ARG2, RB | mov L:RB, SAVE_L | mov ARG3, RC | mov ARG1, L:RB | mov L:RB->base, BASE |.endif | mov SAVE_PC, PC | call extern lj_meta_tget // (lua_State *L, TValue *o, TValue *k) | // TValue * (finished) or NULL (metamethod) returned in eax (RC). | mov BASE, L:RB->base | test RC, RC | jz >3 |->cont_ra: // BASE = base, RC = result | movzx RA, PC_RA |.if X64 | mov RBa, [RC] | mov [BASE+RA*8], RBa |.else | mov RB, [RC+4] | mov RC, [RC] | mov [BASE+RA*8+4], RB | mov [BASE+RA*8], RC |.endif | ins_next | |3: // Call __index metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k | mov RA, L:RB->top | mov [RA-12], PC // [cont|PC] | lea PC, [RA+FRAME_CONT] | sub PC, BASE | mov LFUNC:RB, [RA-8] // Guaranteed to be a function here. | mov NARGS:RD, 2+1 // 2 args for func(t, k). | jmp ->vm_call_dispatch_f | |//----------------------------------------------------------------------- | |->vmeta_tsets: | mov TMP1, RC // RC = GCstr * | mov TMP2, LJ_TSTR | lea RCa, TMP1 // Store temp. TValue in TMP1/TMP2. | cmp PC_OP, BC_GSET | jne >1 | lea RA, [DISPATCH+DISPATCH_GL(tmptv)] // Store fn->l.env in g->tmptv. | mov [RA], TAB:RB // RB = GCtab * | mov dword [RA+4], LJ_TTAB | mov RB, RA | jmp >2 | |->vmeta_tsetb: | movzx RC, PC_RC |.if DUALNUM | mov TMP2, LJ_TISNUM | mov TMP1, RC |.elif SSE | cvtsi2sd xmm0, RC | movsd TMPQ, xmm0 |.else | mov ARG4, RC | fild ARG4 | fstp TMPQ |.endif | lea RCa, TMPQ // Store temp. TValue in TMPQ. | jmp >1 | |->vmeta_tsetv: | movzx RC, PC_RC // Reload TValue *k from RC. | lea RC, [BASE+RC*8] |1: | movzx RB, PC_RB // Reload TValue *t from RB. | lea RB, [BASE+RB*8] |2: |.if X64 | mov L:CARG1d, SAVE_L | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | mov CARG2d, RB | mov CARG3, RCa // May be 64 bit ptr to stack. | mov L:RB, L:CARG1d |.else | mov ARG2, RB | mov L:RB, SAVE_L | mov ARG3, RC | mov ARG1, L:RB | mov L:RB->base, BASE |.endif | mov SAVE_PC, PC | call extern lj_meta_tset // (lua_State *L, TValue *o, TValue *k) | // TValue * (finished) or NULL (metamethod) returned in eax (RC). | mov BASE, L:RB->base | test RC, RC | jz >3 | // NOBARRIER: lj_meta_tset ensures the table is not black. | movzx RA, PC_RA |.if X64 | mov RBa, [BASE+RA*8] | mov [RC], RBa |.else | mov RB, [BASE+RA*8+4] | mov RA, [BASE+RA*8] | mov [RC+4], RB | mov [RC], RA |.endif |->cont_nop: // BASE = base, (RC = result) | ins_next | |3: // Call __newindex metamethod. | // BASE = base, L->top = new base, stack = cont/func/t/k/(v) | mov RA, L:RB->top | mov [RA-12], PC // [cont|PC] | movzx RC, PC_RA | // Copy value to third argument. |.if X64 | mov RBa, [BASE+RC*8] | mov [RA+16], RBa |.else | mov RB, [BASE+RC*8+4] | mov RC, [BASE+RC*8] | mov [RA+20], RB | mov [RA+16], RC |.endif | lea PC, [RA+FRAME_CONT] | sub PC, BASE | mov LFUNC:RB, [RA-8] // Guaranteed to be a function here. | mov NARGS:RD, 3+1 // 3 args for func(t, k, v). | jmp ->vm_call_dispatch_f | |//-- Comparison metamethods --------------------------------------------- | |->vmeta_comp: |.if X64 | mov L:RB, SAVE_L | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d == BASE. |.if X64WIN | lea CARG3d, [BASE+RD*8] | lea CARG2d, [BASE+RA*8] |.else | lea CARG2d, [BASE+RA*8] | lea CARG3d, [BASE+RD*8] |.endif | mov CARG1d, L:RB // Caveat: CARG1d/CARG4d == RA. | movzx CARG4d, PC_OP |.else | movzx RB, PC_OP | lea RD, [BASE+RD*8] | lea RA, [BASE+RA*8] | mov ARG4, RB | mov L:RB, SAVE_L | mov ARG3, RD | mov ARG2, RA | mov ARG1, L:RB | mov L:RB->base, BASE |.endif | mov SAVE_PC, PC | call extern lj_meta_comp // (lua_State *L, TValue *o1, *o2, int op) | // 0/1 or TValue * (metamethod) returned in eax (RC). |3: | mov BASE, L:RB->base | cmp RC, 1 | ja ->vmeta_binop |4: | lea PC, [PC+4] | jb >6 |5: | movzx RD, PC_RD | branchPC RD |6: | ins_next | |->cont_condt: // BASE = base, RC = result | add PC, 4 | cmp dword [RC+4], LJ_TISTRUECOND // Branch if result is true. | jb <5 | jmp <6 | |->cont_condf: // BASE = base, RC = result | cmp dword [RC+4], LJ_TISTRUECOND // Branch if result is false. | jmp <4 | |->vmeta_equal: | sub PC, 4 |.if X64WIN | mov CARG3d, RD | mov CARG4d, RB | mov L:RB, SAVE_L | mov L:RB->base, BASE // Caveat: CARG2d == BASE. | mov CARG2d, RA | mov CARG1d, L:RB // Caveat: CARG1d == RA. |.elif X64 | mov CARG2d, RA | mov CARG4d, RB // Caveat: CARG4d == RA. | mov L:RB, SAVE_L | mov L:RB->base, BASE // Caveat: CARG3d == BASE. | mov CARG3d, RD | mov CARG1d, L:RB |.else | mov ARG4, RB | mov L:RB, SAVE_L | mov ARG3, RD | mov ARG2, RA | mov ARG1, L:RB | mov L:RB->base, BASE |.endif | mov SAVE_PC, PC | call extern lj_meta_equal // (lua_State *L, GCobj *o1, *o2, int ne) | // 0/1 or TValue * (metamethod) returned in eax (RC). | jmp <3 | |->vmeta_equal_cd: |.if FFI | sub PC, 4 | mov L:RB, SAVE_L | mov L:RB->base, BASE | mov FCARG1, L:RB | mov FCARG2, dword [PC-4] | mov SAVE_PC, PC | call extern lj_meta_equal_cd@8 // (lua_State *L, BCIns ins) | // 0/1 or TValue * (metamethod) returned in eax (RC). | jmp <3 |.endif | |//-- Arithmetic metamethods --------------------------------------------- | |->vmeta_arith_vno: |.if DUALNUM | movzx RB, PC_RB |.endif |->vmeta_arith_vn: | lea RC, [KBASE+RC*8] | jmp >1 | |->vmeta_arith_nvo: |.if DUALNUM | movzx RC, PC_RC |.endif |->vmeta_arith_nv: | lea RC, [KBASE+RC*8] | lea RB, [BASE+RB*8] | xchg RB, RC | jmp >2 | |->vmeta_unm: | lea RC, [BASE+RD*8] | mov RB, RC | jmp >2 | |->vmeta_arith_vvo: |.if DUALNUM | movzx RB, PC_RB |.endif |->vmeta_arith_vv: | lea RC, [BASE+RC*8] |1: | lea RB, [BASE+RB*8] |2: | lea RA, [BASE+RA*8] |.if X64WIN | mov CARG3d, RB | mov CARG4d, RC | movzx RC, PC_OP | mov ARG5d, RC | mov L:RB, SAVE_L | mov L:RB->base, BASE // Caveat: CARG2d == BASE. | mov CARG2d, RA | mov CARG1d, L:RB // Caveat: CARG1d == RA. |.elif X64 | movzx CARG5d, PC_OP | mov CARG2d, RA | mov CARG4d, RC // Caveat: CARG4d == RA. | mov L:CARG1d, SAVE_L | mov L:CARG1d->base, BASE // Caveat: CARG3d == BASE. | mov CARG3d, RB | mov L:RB, L:CARG1d |.else | mov ARG3, RB | mov L:RB, SAVE_L | mov ARG4, RC | movzx RC, PC_OP | mov ARG2, RA | mov ARG5, RC | mov ARG1, L:RB | mov L:RB->base, BASE |.endif | mov SAVE_PC, PC | call extern lj_meta_arith // (lua_State *L, TValue *ra,*rb,*rc, BCReg op) | // NULL (finished) or TValue * (metamethod) returned in eax (RC). | mov BASE, L:RB->base | test RC, RC | jz ->cont_nop | | // Call metamethod for binary op. |->vmeta_binop: | // BASE = base, RC = new base, stack = cont/func/o1/o2 | mov RA, RC | sub RC, BASE | mov [RA-12], PC // [cont|PC] | lea PC, [RC+FRAME_CONT] | mov NARGS:RD, 2+1 // 2 args for func(o1, o2). | jmp ->vm_call_dispatch | |->vmeta_len: | mov L:RB, SAVE_L | mov L:RB->base, BASE | lea FCARG2, [BASE+RD*8] // Caveat: FCARG2 == BASE | mov L:FCARG1, L:RB | mov SAVE_PC, PC | call extern lj_meta_len@8 // (lua_State *L, TValue *o) | // NULL (retry) or TValue * (metamethod) returned in eax (RC). | mov BASE, L:RB->base #if LJ_52 | test RC, RC | jne ->vmeta_binop // Binop call for compatibility. | movzx RD, PC_RD | mov TAB:FCARG1, [BASE+RD*8] | jmp ->BC_LEN_Z #else | jmp ->vmeta_binop // Binop call for compatibility. #endif | |//-- Call metamethod ---------------------------------------------------- | |->vmeta_call_ra: | lea RA, [BASE+RA*8+8] |->vmeta_call: // Resolve and call __call metamethod. | // BASE = old base, RA = new base, RC = nargs+1, PC = return | mov TMP2, RA // Save RA, RC for us. | mov TMP1, NARGS:RD | sub RA, 8 |.if X64 | mov L:RB, SAVE_L | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | mov CARG2d, RA | lea CARG3d, [RA+NARGS:RD*8] | mov CARG1d, L:RB // Caveat: CARG1d may be RA. |.else | lea RC, [RA+NARGS:RD*8] | mov L:RB, SAVE_L | mov ARG2, RA | mov ARG3, RC | mov ARG1, L:RB | mov L:RB->base, BASE // This is the callers base! |.endif | mov SAVE_PC, PC | call extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) | mov BASE, L:RB->base | mov RA, TMP2 | mov NARGS:RD, TMP1 | mov LFUNC:RB, [RA-8] | add NARGS:RD, 1 | // This is fragile. L->base must not move, KBASE must always be defined. | cmp KBASE, BASE // Continue with CALLT if flag set. | je ->BC_CALLT_Z | mov BASE, RA | ins_call // Otherwise call resolved metamethod. | |//-- Argument coercion for 'for' statement ------------------------------ | |->vmeta_for: | mov L:RB, SAVE_L | mov L:RB->base, BASE | mov FCARG2, RA // Caveat: FCARG2 == BASE | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA | mov SAVE_PC, PC | call extern lj_meta_for@8 // (lua_State *L, TValue *base) | mov BASE, L:RB->base | mov RC, [PC-4] | movzx RA, RCH | movzx OP, RCL | shr RC, 16 |.if X64 | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC] // Retry FORI or JFORI. |.else | jmp aword [DISPATCH+OP*4+GG_DISP2STATIC] // Retry FORI or JFORI. |.endif | |//----------------------------------------------------------------------- |//-- Fast functions ----------------------------------------------------- |//----------------------------------------------------------------------- | |.macro .ffunc, name |->ff_ .. name: |.endmacro | |.macro .ffunc_1, name |->ff_ .. name: | cmp NARGS:RD, 1+1; jb ->fff_fallback |.endmacro | |.macro .ffunc_2, name |->ff_ .. name: | cmp NARGS:RD, 2+1; jb ->fff_fallback |.endmacro | |.macro .ffunc_n, name | .ffunc_1 name | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback | fld qword [BASE] |.endmacro | |.macro .ffunc_n, name, op | .ffunc_1 name | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback | op | fld qword [BASE] |.endmacro | |.macro .ffunc_nsse, name, op | .ffunc_1 name | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback | op xmm0, qword [BASE] |.endmacro | |.macro .ffunc_nsse, name | .ffunc_nsse name, movsd |.endmacro | |.macro .ffunc_nn, name | .ffunc_2 name | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback | fld qword [BASE] | fld qword [BASE+8] |.endmacro | |.macro .ffunc_nnsse, name | .ffunc_2 name | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback | movsd xmm0, qword [BASE] | movsd xmm1, qword [BASE+8] |.endmacro | |.macro .ffunc_nnr, name | .ffunc_2 name | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback | cmp dword [BASE+12], LJ_TISNUM; jae ->fff_fallback | fld qword [BASE+8] | fld qword [BASE] |.endmacro | |// Inlined GC threshold check. Caveat: uses label 1. |.macro ffgccheck | mov RB, [DISPATCH+DISPATCH_GL(gc.total)] | cmp RB, [DISPATCH+DISPATCH_GL(gc.threshold)] | jb >1 | call ->fff_gcstep |1: |.endmacro | |//-- Base library: checks ----------------------------------------------- | |.ffunc_1 assert | mov RB, [BASE+4] | cmp RB, LJ_TISTRUECOND; jae ->fff_fallback | mov PC, [BASE-4] | mov MULTRES, RD | mov [BASE-4], RB | mov RB, [BASE] | mov [BASE-8], RB | sub RD, 2 | jz >2 | mov RA, BASE |1: | add RA, 8 |.if X64 | mov RBa, [RA] | mov [RA-8], RBa |.else | mov RB, [RA+4] | mov [RA-4], RB | mov RB, [RA] | mov [RA-8], RB |.endif | sub RD, 1 | jnz <1 |2: | mov RD, MULTRES | jmp ->fff_res_ | |.ffunc_1 type | mov RB, [BASE+4] |.if X64 | mov RA, RB | sar RA, 15 | cmp RA, -2 | je >3 |.endif | mov RC, ~LJ_TNUMX | not RB | cmp RC, RB | cmova RC, RB |2: | mov CFUNC:RB, [BASE-8] | mov STR:RC, [CFUNC:RB+RC*8+((char *)(&((GCfuncC *)0)->upvalue))] | mov PC, [BASE-4] | mov dword [BASE-4], LJ_TSTR | mov [BASE-8], STR:RC | jmp ->fff_res1 |.if X64 |3: | mov RC, ~LJ_TLIGHTUD | jmp <2 |.endif | |//-- Base library: getters and setters --------------------------------- | |.ffunc_1 getmetatable | mov RB, [BASE+4] | mov PC, [BASE-4] | cmp RB, LJ_TTAB; jne >6 |1: // Field metatable must be at same offset for GCtab and GCudata! | mov TAB:RB, [BASE] | mov TAB:RB, TAB:RB->metatable |2: | test TAB:RB, TAB:RB | mov dword [BASE-4], LJ_TNIL | jz ->fff_res1 | mov STR:RC, [DISPATCH+DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable)] | mov dword [BASE-4], LJ_TTAB // Store metatable as default result. | mov [BASE-8], TAB:RB | mov RA, TAB:RB->hmask | and RA, STR:RC->hash | imul RA, #NODE | add NODE:RA, TAB:RB->node |3: // Rearranged logic, because we expect _not_ to find the key. | cmp dword NODE:RA->key.it, LJ_TSTR | jne >4 | cmp dword NODE:RA->key.gcr, STR:RC | je >5 |4: | mov NODE:RA, NODE:RA->next | test NODE:RA, NODE:RA | jnz <3 | jmp ->fff_res1 // Not found, keep default result. |5: | mov RB, [RA+4] | cmp RB, LJ_TNIL; je ->fff_res1 // Ditto for nil value. | mov RC, [RA] | mov [BASE-4], RB // Return value of mt.__metatable. | mov [BASE-8], RC | jmp ->fff_res1 | |6: | cmp RB, LJ_TUDATA; je <1 |.if X64 | cmp RB, LJ_TNUMX; ja >8 | cmp RB, LJ_TISNUM; jbe >7 | mov RB, LJ_TLIGHTUD | jmp >8 |7: |.else | cmp RB, LJ_TISNUM; ja >8 |.endif | mov RB, LJ_TNUMX |8: | not RB | mov TAB:RB, [DISPATCH+RB*4+DISPATCH_GL(gcroot[GCROOT_BASEMT])] | jmp <2 | |.ffunc_2 setmetatable | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback | // Fast path: no mt for table yet and not clearing the mt. | mov TAB:RB, [BASE] | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback | cmp dword [BASE+12], LJ_TTAB; jne ->fff_fallback | mov TAB:RC, [BASE+8] | mov TAB:RB->metatable, TAB:RC | mov PC, [BASE-4] | mov dword [BASE-4], LJ_TTAB // Return original table. | mov [BASE-8], TAB:RB | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) | jz >1 | // Possible write barrier. Table is black, but skip iswhite(mt) check. | barrierback TAB:RB, RC |1: | jmp ->fff_res1 | |.ffunc_2 rawget | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback |.if X64WIN | mov RB, BASE // Save BASE. | lea CARG3d, [BASE+8] | mov CARG2d, [BASE] // Caveat: CARG2d == BASE. | mov CARG1d, SAVE_L |.elif X64 | mov RB, BASE // Save BASE. | mov CARG2d, [BASE] | lea CARG3d, [BASE+8] // Caveat: CARG3d == BASE. | mov CARG1d, SAVE_L |.else | mov TAB:RD, [BASE] | mov L:RB, SAVE_L | mov ARG2, TAB:RD | mov ARG1, L:RB | mov RB, BASE // Save BASE. | add BASE, 8 | mov ARG3, BASE |.endif | call extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) | // cTValue * returned in eax (RD). | mov BASE, RB // Restore BASE. | // Copy table slot. |.if X64 | mov RBa, [RD] | mov PC, [BASE-4] | mov [BASE-8], RBa |.else | mov RB, [RD] | mov RD, [RD+4] | mov PC, [BASE-4] | mov [BASE-8], RB | mov [BASE-4], RD |.endif | jmp ->fff_res1 | |//-- Base library: conversions ------------------------------------------ | |.ffunc tonumber | // Only handles the number case inline (without a base argument). | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. | cmp dword [BASE+4], LJ_TISNUM |.if DUALNUM | jne >1 | mov RB, dword [BASE]; jmp ->fff_resi |1: | ja ->fff_fallback |.else | jae ->fff_fallback |.endif |.if SSE | movsd xmm0, qword [BASE]; jmp ->fff_resxmm0 |.else | fld qword [BASE]; jmp ->fff_resn |.endif | |.ffunc_1 tostring | // Only handles the string or number case inline. | mov PC, [BASE-4] | cmp dword [BASE+4], LJ_TSTR; jne >3 | // A __tostring method in the string base metatable is ignored. | mov STR:RD, [BASE] |2: | mov dword [BASE-4], LJ_TSTR | mov [BASE-8], STR:RD | jmp ->fff_res1 |3: // Handle numbers inline, unless a number base metatable is present. | cmp dword [BASE+4], LJ_TISNUM; ja ->fff_fallback | cmp dword [DISPATCH+DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM])], 0 | jne ->fff_fallback | ffgccheck // Caveat: uses label 1. | mov L:RB, SAVE_L | mov L:RB->base, BASE // Add frame since C call can throw. | mov SAVE_PC, PC // Redundant (but a defined value). |.if X64 and not X64WIN | mov FCARG2, BASE // Otherwise: FCARG2 == BASE |.endif | mov L:FCARG1, L:RB |.if DUALNUM | call extern lj_str_fromnumber@8 // (lua_State *L, cTValue *o) |.else | call extern lj_str_fromnum@8 // (lua_State *L, lua_Number *np) |.endif | // GCstr returned in eax (RD). | mov BASE, L:RB->base | jmp <2 | |//-- Base library: iterators ------------------------------------------- | |.ffunc_1 next | je >2 // Missing 2nd arg? |1: | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback | mov L:RB, SAVE_L | mov L:RB->base, BASE // Add frame since C call can throw. | mov L:RB->top, BASE // Dummy frame length is ok. | mov PC, [BASE-4] |.if X64WIN | lea CARG3d, [BASE+8] | mov CARG2d, [BASE] // Caveat: CARG2d == BASE. | mov CARG1d, L:RB |.elif X64 | mov CARG2d, [BASE] | lea CARG3d, [BASE+8] // Caveat: CARG3d == BASE. | mov CARG1d, L:RB |.else | mov TAB:RD, [BASE] | mov ARG2, TAB:RD | mov ARG1, L:RB | add BASE, 8 | mov ARG3, BASE |.endif | mov SAVE_PC, PC // Needed for ITERN fallback. | call extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) | // Flag returned in eax (RD). | mov BASE, L:RB->base | test RD, RD; jz >3 // End of traversal? | // Copy key and value to results. |.if X64 | mov RBa, [BASE+8] | mov RDa, [BASE+16] | mov [BASE-8], RBa | mov [BASE], RDa |.else | mov RB, [BASE+8] | mov RD, [BASE+12] | mov [BASE-8], RB | mov [BASE-4], RD | mov RB, [BASE+16] | mov RD, [BASE+20] | mov [BASE], RB | mov [BASE+4], RD |.endif |->fff_res2: | mov RD, 1+2 | jmp ->fff_res |2: // Set missing 2nd arg to nil. | mov dword [BASE+12], LJ_TNIL | jmp <1 |3: // End of traversal: return nil. | mov dword [BASE-4], LJ_TNIL | jmp ->fff_res1 | |.ffunc_1 pairs | mov TAB:RB, [BASE] | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback #if LJ_52 | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback #endif | mov CFUNC:RB, [BASE-8] | mov CFUNC:RD, CFUNC:RB->upvalue[0] | mov PC, [BASE-4] | mov dword [BASE-4], LJ_TFUNC | mov [BASE-8], CFUNC:RD | mov dword [BASE+12], LJ_TNIL | mov RD, 1+3 | jmp ->fff_res | |.ffunc_1 ipairs_aux | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback | cmp dword [BASE+12], LJ_TISNUM |.if DUALNUM | jne ->fff_fallback |.else | jae ->fff_fallback |.endif | mov PC, [BASE-4] |.if DUALNUM | mov RD, dword [BASE+8] | add RD, 1 | mov dword [BASE-4], LJ_TISNUM | mov dword [BASE-8], RD |.elif SSE | movsd xmm0, qword [BASE+8] | sseconst_1 xmm1, RBa | addsd xmm0, xmm1 | cvtsd2si RD, xmm0 | movsd qword [BASE-8], xmm0 |.else | fld qword [BASE+8] | fld1 | faddp st1 | fist ARG1 | fstp qword [BASE-8] | mov RD, ARG1 |.endif | mov TAB:RB, [BASE] | cmp RD, TAB:RB->asize; jae >2 // Not in array part? | shl RD, 3 | add RD, TAB:RB->array |1: | cmp dword [RD+4], LJ_TNIL; je ->fff_res0 | // Copy array slot. |.if X64 | mov RBa, [RD] | mov [BASE], RBa |.else | mov RB, [RD] | mov RD, [RD+4] | mov [BASE], RB | mov [BASE+4], RD |.endif | jmp ->fff_res2 |2: // Check for empty hash part first. Otherwise call C function. | cmp dword TAB:RB->hmask, 0; je ->fff_res0 | mov FCARG1, TAB:RB | mov RB, BASE // Save BASE. | mov FCARG2, RD // Caveat: FCARG2 == BASE | call extern lj_tab_getinth@8 // (GCtab *t, int32_t key) | // cTValue * or NULL returned in eax (RD). | mov BASE, RB | test RD, RD | jnz <1 |->fff_res0: | mov RD, 1+0 | jmp ->fff_res | |.ffunc_1 ipairs | mov TAB:RB, [BASE] | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback #if LJ_52 | cmp dword TAB:RB->metatable, 0; jne ->fff_fallback #endif | mov CFUNC:RB, [BASE-8] | mov CFUNC:RD, CFUNC:RB->upvalue[0] | mov PC, [BASE-4] | mov dword [BASE-4], LJ_TFUNC | mov [BASE-8], CFUNC:RD |.if DUALNUM | mov dword [BASE+12], LJ_TISNUM | mov dword [BASE+8], 0 |.elif SSE | xorps xmm0, xmm0 | movsd qword [BASE+8], xmm0 |.else | fldz | fstp qword [BASE+8] |.endif | mov RD, 1+3 | jmp ->fff_res | |//-- Base library: catch errors ---------------------------------------- | |.ffunc_1 pcall | lea RA, [BASE+8] | sub NARGS:RD, 1 | mov PC, 8+FRAME_PCALL |1: | movzx RB, byte [DISPATCH+DISPATCH_GL(hookmask)] | shr RB, HOOK_ACTIVE_SHIFT | and RB, 1 | add PC, RB // Remember active hook before pcall. | jmp ->vm_call_dispatch | |.ffunc_2 xpcall | cmp dword [BASE+12], LJ_TFUNC; jne ->fff_fallback | mov RB, [BASE+4] // Swap function and traceback. | mov [BASE+12], RB | mov dword [BASE+4], LJ_TFUNC | mov LFUNC:RB, [BASE] | mov PC, [BASE+8] | mov [BASE+8], LFUNC:RB | mov [BASE], PC | lea RA, [BASE+16] | sub NARGS:RD, 2 | mov PC, 16+FRAME_PCALL | jmp <1 | |//-- Coroutine library -------------------------------------------------- | |.macro coroutine_resume_wrap, resume |.if resume |.ffunc_1 coroutine_resume | mov L:RB, [BASE] |.else |.ffunc coroutine_wrap_aux | mov CFUNC:RB, [BASE-8] | mov L:RB, CFUNC:RB->upvalue[0].gcr |.endif | mov PC, [BASE-4] | mov SAVE_PC, PC |.if X64 | mov TMP1, L:RB |.else | mov ARG1, L:RB |.endif |.if resume | cmp dword [BASE+4], LJ_TTHREAD; jne ->fff_fallback |.endif | cmp aword L:RB->cframe, 0; jne ->fff_fallback | cmp byte L:RB->status, LUA_YIELD; ja ->fff_fallback | mov RA, L:RB->top | je >1 // Status != LUA_YIELD (i.e. 0)? | cmp RA, L:RB->base // Check for presence of initial func. | je ->fff_fallback |1: |.if resume | lea PC, [RA+NARGS:RD*8-16] // Check stack space (-1-thread). |.else | lea PC, [RA+NARGS:RD*8-8] // Check stack space (-1). |.endif | cmp PC, L:RB->maxstack; ja ->fff_fallback | mov L:RB->top, PC | | mov L:RB, SAVE_L | mov L:RB->base, BASE |.if resume | add BASE, 8 // Keep resumed thread in stack for GC. |.endif | mov L:RB->top, BASE |.if resume | lea RB, [BASE+NARGS:RD*8-24] // RB = end of source for stack move. |.else | lea RB, [BASE+NARGS:RD*8-16] // RB = end of source for stack move. |.endif | sub RBa, PCa // Relative to PC. | | cmp PC, RA | je >3 |2: // Move args to coroutine. |.if X64 | mov RCa, [PC+RB] | mov [PC-8], RCa |.else | mov RC, [PC+RB+4] | mov [PC-4], RC | mov RC, [PC+RB] | mov [PC-8], RC |.endif | sub PC, 8 | cmp PC, RA | jne <2 |3: |.if X64 | mov CARG2d, RA | mov CARG1d, TMP1 |.else | mov ARG2, RA | xor RA, RA | mov ARG4, RA | mov ARG3, RA |.endif | call ->vm_resume // (lua_State *L, TValue *base, 0, 0) | set_vmstate INTERP | | mov L:RB, SAVE_L |.if X64 | mov L:PC, TMP1 |.else | mov L:PC, ARG1 // The callee doesn't modify SAVE_L. |.endif | mov BASE, L:RB->base | cmp eax, LUA_YIELD | ja >8 |4: | mov RA, L:PC->base | mov KBASE, L:PC->top | mov L:PC->top, RA // Clear coroutine stack. | mov PC, KBASE | sub PC, RA | je >6 // No results? | lea RD, [BASE+PC] | shr PC, 3 | cmp RD, L:RB->maxstack | ja >9 // Need to grow stack? | | mov RB, BASE | sub RBa, RAa |5: // Move results from coroutine. |.if X64 | mov RDa, [RA] | mov [RA+RB], RDa |.else | mov RD, [RA] | mov [RA+RB], RD | mov RD, [RA+4] | mov [RA+RB+4], RD |.endif | add RA, 8 | cmp RA, KBASE | jne <5 |6: |.if resume | lea RD, [PC+2] // nresults+1 = 1 + true + results. | mov dword [BASE-4], LJ_TTRUE // Prepend true to results. |.else | lea RD, [PC+1] // nresults+1 = 1 + results. |.endif |7: | mov PC, SAVE_PC | mov MULTRES, RD |.if resume | mov RAa, -8 |.else | xor RA, RA |.endif | test PC, FRAME_TYPE | jz ->BC_RET_Z | jmp ->vm_return | |8: // Coroutine returned with error (at co->top-1). |.if resume | mov dword [BASE-4], LJ_TFALSE // Prepend false to results. | mov RA, L:PC->top | sub RA, 8 | mov L:PC->top, RA // Clear error from coroutine stack. | // Copy error message. |.if X64 | mov RDa, [RA] | mov [BASE], RDa |.else | mov RD, [RA] | mov [BASE], RD | mov RD, [RA+4] | mov [BASE+4], RD |.endif | mov RD, 1+2 // nresults+1 = 1 + false + error. | jmp <7 |.else | mov FCARG2, L:PC | mov FCARG1, L:RB | call extern lj_ffh_coroutine_wrap_err@8 // (lua_State *L, lua_State *co) | // Error function does not return. |.endif | |9: // Handle stack expansion on return from yield. |.if X64 | mov L:RA, TMP1 |.else | mov L:RA, ARG1 // The callee doesn't modify SAVE_L. |.endif | mov L:RA->top, KBASE // Undo coroutine stack clearing. | mov FCARG2, PC | mov FCARG1, L:RB | call extern lj_state_growstack@8 // (lua_State *L, int n) |.if X64 | mov L:PC, TMP1 |.else | mov L:PC, ARG1 |.endif | mov BASE, L:RB->base | jmp <4 // Retry the stack move. |.endmacro | | coroutine_resume_wrap 1 // coroutine.resume | coroutine_resume_wrap 0 // coroutine.wrap | |.ffunc coroutine_yield | mov L:RB, SAVE_L | test aword L:RB->cframe, CFRAME_RESUME | jz ->fff_fallback | mov L:RB->base, BASE | lea RD, [BASE+NARGS:RD*8-8] | mov L:RB->top, RD | xor RD, RD | mov aword L:RB->cframe, RDa | mov al, LUA_YIELD | mov byte L:RB->status, al | jmp ->vm_leave_unw | |//-- Math library ------------------------------------------------------- | |.if not DUALNUM |->fff_resi: // Dummy. |.endif | |.if SSE |->fff_resn: | mov PC, [BASE-4] | fstp qword [BASE-8] | jmp ->fff_res1 |.endif | | .ffunc_1 math_abs |.if DUALNUM | cmp dword [BASE+4], LJ_TISNUM; jne >2 | mov RB, dword [BASE] | cmp RB, 0; jns ->fff_resi | neg RB; js >1 |->fff_resbit: |->fff_resi: | mov PC, [BASE-4] | mov dword [BASE-4], LJ_TISNUM | mov dword [BASE-8], RB | jmp ->fff_res1 |1: | mov PC, [BASE-4] | mov dword [BASE-4], 0x41e00000 // 2^31. | mov dword [BASE-8], 0 | jmp ->fff_res1 |2: | ja ->fff_fallback |.else | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback |.endif | |.if SSE | movsd xmm0, qword [BASE] | sseconst_abs xmm1, RDa | andps xmm0, xmm1 |->fff_resxmm0: | mov PC, [BASE-4] | movsd qword [BASE-8], xmm0 | // fallthrough |.else | fld qword [BASE] | fabs | // fallthrough |->fff_resxmm0: // Dummy. |->fff_resn: | mov PC, [BASE-4] | fstp qword [BASE-8] |.endif | |->fff_res1: | mov RD, 1+1 |->fff_res: | mov MULTRES, RD |->fff_res_: | test PC, FRAME_TYPE | jnz >7 |5: | cmp PC_RB, RDL // More results expected? | ja >6 | // Adjust BASE. KBASE is assumed to be set for the calling frame. | movzx RA, PC_RA | not RAa // Note: ~RA = -(RA+1) | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 | ins_next | |6: // Fill up results with nil. | mov dword [BASE+RD*8-12], LJ_TNIL | add RD, 1 | jmp <5 | |7: // Non-standard return case. | mov RAa, -8 // Results start at BASE+RA = BASE-8. | jmp ->vm_return | |.macro math_round, func | .ffunc math_ .. func |.if DUALNUM | cmp dword [BASE+4], LJ_TISNUM; jne >1 | mov RB, dword [BASE]; jmp ->fff_resi |1: | ja ->fff_fallback |.else | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback |.endif |.if SSE | movsd xmm0, qword [BASE] | call ->vm_ .. func | .if DUALNUM | cvtsd2si RB, xmm0 | cmp RB, 0x80000000 | jne ->fff_resi | cvtsi2sd xmm1, RB | ucomisd xmm0, xmm1 | jp ->fff_resxmm0 | je ->fff_resi | .endif | jmp ->fff_resxmm0 |.else | fld qword [BASE] | call ->vm_ .. func | .if DUALNUM | fist ARG1 | mov RB, ARG1 | cmp RB, 0x80000000; jne >2 | fdup | fild ARG1 | fcomparepp | jp ->fff_resn | jne ->fff_resn |2: | fpop | jmp ->fff_resi | .else | jmp ->fff_resn | .endif |.endif |.endmacro | | math_round floor | math_round ceil | |.if SSE |.ffunc_nsse math_sqrt, sqrtsd; jmp ->fff_resxmm0 |.else |.ffunc_n math_sqrt; fsqrt; jmp ->fff_resn |.endif | |.ffunc math_log | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback | fldln2; fld qword [BASE]; fyl2x; jmp ->fff_resn | |.ffunc_n math_log10, fldlg2; fyl2x; jmp ->fff_resn |.ffunc_n math_exp; call ->vm_exp_x87; jmp ->fff_resn | |.ffunc_n math_sin; fsin; jmp ->fff_resn |.ffunc_n math_cos; fcos; jmp ->fff_resn |.ffunc_n math_tan; fptan; fpop; jmp ->fff_resn | |.ffunc_n math_asin | fdup; fmul st0; fld1; fsubrp st1; fsqrt; fpatan | jmp ->fff_resn |.ffunc_n math_acos | fdup; fmul st0; fld1; fsubrp st1; fsqrt; fxch; fpatan | jmp ->fff_resn |.ffunc_n math_atan; fld1; fpatan; jmp ->fff_resn | |.macro math_extern, func |.if SSE | .ffunc_nsse math_ .. func | .if not X64 | movsd FPARG1, xmm0 | .endif |.else | .ffunc_n math_ .. func | fstp FPARG1 |.endif | mov RB, BASE | call extern lj_vm_ .. func | mov BASE, RB | .if X64 | jmp ->fff_resxmm0 | .else | jmp ->fff_resn | .endif |.endmacro | | math_extern sinh | math_extern cosh | math_extern tanh | |->ff_math_deg: |.if SSE |.ffunc_nsse math_rad | mov CFUNC:RB, [BASE-8] | mulsd xmm0, qword CFUNC:RB->upvalue[0] | jmp ->fff_resxmm0 |.else |.ffunc_n math_rad | mov CFUNC:RB, [BASE-8] | fmul qword CFUNC:RB->upvalue[0] | jmp ->fff_resn |.endif | |.ffunc_nn math_atan2; fpatan; jmp ->fff_resn |.ffunc_nnr math_ldexp; fscale; fpop1; jmp ->fff_resn | |.ffunc_1 math_frexp | mov RB, [BASE+4] | cmp RB, LJ_TISNUM; jae ->fff_fallback | mov PC, [BASE-4] | mov RC, [BASE] | mov [BASE-4], RB; mov [BASE-8], RC | shl RB, 1; cmp RB, 0xffe00000; jae >3 | or RC, RB; jz >3 | mov RC, 1022 | cmp RB, 0x00200000; jb >4 |1: | shr RB, 21; sub RB, RC // Extract and unbias exponent. |.if SSE | cvtsi2sd xmm0, RB |.else | mov TMP1, RB; fild TMP1 |.endif | mov RB, [BASE-4] | and RB, 0x800fffff // Mask off exponent. | or RB, 0x3fe00000 // Put mantissa in range [0.5,1) or 0. | mov [BASE-4], RB |2: |.if SSE | movsd qword [BASE], xmm0 |.else | fstp qword [BASE] |.endif | mov RD, 1+2 | jmp ->fff_res |3: // Return +-0, +-Inf, NaN unmodified and an exponent of 0. |.if SSE | xorps xmm0, xmm0; jmp <2 |.else | fldz; jmp <2 |.endif |4: // Handle denormals by multiplying with 2^54 and adjusting the bias. |.if SSE | movsd xmm0, qword [BASE] | sseconst_hi xmm1, RBa, 43500000 // 2^54. | mulsd xmm0, xmm1 | movsd qword [BASE-8], xmm0 |.else | fld qword [BASE] | mov TMP1, 0x5a800000; fmul TMP1 // x = x*2^54 | fstp qword [BASE-8] |.endif | mov RB, [BASE-4]; mov RC, 1076; shl RB, 1; jmp <1 | |.if SSE |.ffunc_nsse math_modf |.else |.ffunc_n math_modf |.endif | mov RB, [BASE+4] | mov PC, [BASE-4] | shl RB, 1; cmp RB, 0xffe00000; je >4 // +-Inf? |.if SSE | movaps xmm4, xmm0 | call ->vm_trunc | subsd xmm4, xmm0 |1: | movsd qword [BASE-8], xmm0 | movsd qword [BASE], xmm4 |.else | fdup | call ->vm_trunc | fsub st1, st0 |1: | fstp qword [BASE-8] | fstp qword [BASE] |.endif | mov RC, [BASE-4]; mov RB, [BASE+4] | xor RC, RB; js >3 // Need to adjust sign? |2: | mov RD, 1+2 | jmp ->fff_res |3: | xor RB, 0x80000000; mov [BASE+4], RB // Flip sign of fraction. | jmp <2 |4: |.if SSE | xorps xmm4, xmm4; jmp <1 // Return +-Inf and +-0. |.else | fldz; fxch; jmp <1 // Return +-Inf and +-0. |.endif | |.ffunc_nnr math_fmod |1: ; fprem; fnstsw ax; sahf; jp <1 | fpop1 | jmp ->fff_resn | |.if SSE |.ffunc_nnsse math_pow; call ->vm_pow; jmp ->fff_resxmm0 |.else |.ffunc_nn math_pow; call ->vm_pow; jmp ->fff_resn |.endif | |.macro math_minmax, name, cmovop, fcmovop, sseop | .ffunc name | mov RA, 2 | cmp dword [BASE+4], LJ_TISNUM |.if DUALNUM | jne >4 | mov RB, dword [BASE] |1: // Handle integers. | cmp RA, RD; jae ->fff_resi | cmp dword [BASE+RA*8-4], LJ_TISNUM; jne >3 | cmp RB, dword [BASE+RA*8-8] | cmovop RB, dword [BASE+RA*8-8] | add RA, 1 | jmp <1 |3: | ja ->fff_fallback | // Convert intermediate result to number and continue below. |.if SSE | cvtsi2sd xmm0, RB |.else | mov TMP1, RB | fild TMP1 |.endif | jmp >6 |4: | ja ->fff_fallback |.else | jae ->fff_fallback |.endif | |.if SSE | movsd xmm0, qword [BASE] |5: // Handle numbers or integers. | cmp RA, RD; jae ->fff_resxmm0 | cmp dword [BASE+RA*8-4], LJ_TISNUM |.if DUALNUM | jb >6 | ja ->fff_fallback | cvtsi2sd xmm1, dword [BASE+RA*8-8] | jmp >7 |.else | jae ->fff_fallback |.endif |6: | movsd xmm1, qword [BASE+RA*8-8] |7: | sseop xmm0, xmm1 | add RA, 1 | jmp <5 |.else | fld qword [BASE] |5: // Handle numbers or integers. | cmp RA, RD; jae ->fff_resn | cmp dword [BASE+RA*8-4], LJ_TISNUM |.if DUALNUM | jb >6 | ja >9 | fild dword [BASE+RA*8-8] | jmp >7 |.else | jae >9 |.endif |6: | fld qword [BASE+RA*8-8] |7: | fucomi st1; fcmovop st1; fpop1 | add RA, 1 | jmp <5 |.endif |.endmacro | | math_minmax math_min, cmovg, fcmovnbe, minsd | math_minmax math_max, cmovl, fcmovbe, maxsd |.if not SSE |9: | fpop; jmp ->fff_fallback |.endif | |//-- String library ----------------------------------------------------- | |.ffunc_1 string_len | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | mov STR:RB, [BASE] |.if DUALNUM | mov RB, dword STR:RB->len; jmp ->fff_resi |.elif SSE | cvtsi2sd xmm0, dword STR:RB->len; jmp ->fff_resxmm0 |.else | fild dword STR:RB->len; jmp ->fff_resn |.endif | |.ffunc string_byte // Only handle the 1-arg case here. | cmp NARGS:RD, 1+1; jne ->fff_fallback | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | mov STR:RB, [BASE] | mov PC, [BASE-4] | cmp dword STR:RB->len, 1 | jb ->fff_res0 // Return no results for empty string. | movzx RB, byte STR:RB[1] |.if DUALNUM | jmp ->fff_resi |.elif SSE | cvtsi2sd xmm0, RB; jmp ->fff_resxmm0 |.else | mov TMP1, RB; fild TMP1; jmp ->fff_resn |.endif | |.ffunc string_char // Only handle the 1-arg case here. | ffgccheck | cmp NARGS:RD, 1+1; jne ->fff_fallback // *Exactly* 1 arg. | cmp dword [BASE+4], LJ_TISNUM |.if DUALNUM | jne ->fff_fallback | mov RB, dword [BASE] | cmp RB, 255; ja ->fff_fallback | mov TMP2, RB |.elif SSE | jae ->fff_fallback | cvttsd2si RB, qword [BASE] | cmp RB, 255; ja ->fff_fallback | mov TMP2, RB |.else | jae ->fff_fallback | fld qword [BASE] | fistp TMP2 | cmp TMP2, 255; ja ->fff_fallback |.endif |.if X64 | mov TMP3, 1 |.else | mov ARG3, 1 |.endif | lea RDa, TMP2 // Points to stack. Little-endian. |->fff_newstr: | mov L:RB, SAVE_L | mov L:RB->base, BASE |.if X64 | mov CARG3d, TMP3 // Zero-extended to size_t. | mov CARG2, RDa // May be 64 bit ptr to stack. | mov CARG1d, L:RB |.else | mov ARG2, RD | mov ARG1, L:RB |.endif | mov SAVE_PC, PC | call extern lj_str_new // (lua_State *L, char *str, size_t l) | // GCstr * returned in eax (RD). | mov BASE, L:RB->base | mov PC, [BASE-4] | mov dword [BASE-4], LJ_TSTR | mov [BASE-8], STR:RD | jmp ->fff_res1 | |.ffunc string_sub | ffgccheck | mov TMP2, -1 | cmp NARGS:RD, 1+2; jb ->fff_fallback | jna >1 | cmp dword [BASE+20], LJ_TISNUM |.if DUALNUM | jne ->fff_fallback | mov RB, dword [BASE+16] | mov TMP2, RB |.elif SSE | jae ->fff_fallback | cvttsd2si RB, qword [BASE+16] | mov TMP2, RB |.else | jae ->fff_fallback | fld qword [BASE+16] | fistp TMP2 |.endif |1: | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | cmp dword [BASE+12], LJ_TISNUM |.if DUALNUM | jne ->fff_fallback |.else | jae ->fff_fallback |.endif | mov STR:RB, [BASE] | mov TMP3, STR:RB | mov RB, STR:RB->len |.if DUALNUM | mov RA, dword [BASE+8] |.elif SSE | cvttsd2si RA, qword [BASE+8] |.else | fld qword [BASE+8] | fistp ARG3 | mov RA, ARG3 |.endif | mov RC, TMP2 | cmp RB, RC // len < end? (unsigned compare) | jb >5 |2: | test RA, RA // start <= 0? | jle >7 |3: | mov STR:RB, TMP3 | sub RC, RA // start > end? | jl ->fff_emptystr | lea RB, [STR:RB+RA+#STR-1] | add RC, 1 |4: |.if X64 | mov TMP3, RC |.else | mov ARG3, RC |.endif | mov RD, RB | jmp ->fff_newstr | |5: // Negative end or overflow. | jl >6 | lea RC, [RC+RB+1] // end = end+(len+1) | jmp <2 |6: // Overflow. | mov RC, RB // end = len | jmp <2 | |7: // Negative start or underflow. | je >8 | add RA, RB // start = start+(len+1) | add RA, 1 | jg <3 // start > 0? |8: // Underflow. | mov RA, 1 // start = 1 | jmp <3 | |->fff_emptystr: // Range underflow. | xor RC, RC // Zero length. Any ptr in RB is ok. | jmp <4 | |.ffunc string_rep // Only handle the 1-char case inline. | ffgccheck | cmp NARGS:RD, 2+1; jne ->fff_fallback // Exactly 2 arguments. | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | cmp dword [BASE+12], LJ_TISNUM | mov STR:RB, [BASE] |.if DUALNUM | jne ->fff_fallback | mov RC, dword [BASE+8] |.elif SSE | jae ->fff_fallback | cvttsd2si RC, qword [BASE+8] |.else | jae ->fff_fallback | fld qword [BASE+8] | fistp TMP2 | mov RC, TMP2 |.endif | test RC, RC | jle ->fff_emptystr // Count <= 0? (or non-int) | cmp dword STR:RB->len, 1 | jb ->fff_emptystr // Zero length string? | jne ->fff_fallback_2 // Fallback for > 1-char strings. | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_2 | movzx RA, byte STR:RB[1] | mov RB, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] |.if X64 | mov TMP3, RC |.else | mov ARG3, RC |.endif |1: // Fill buffer with char. Yes, this is suboptimal code (do you care?). | mov [RB], RAL | add RB, 1 | sub RC, 1 | jnz <1 | mov RD, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] | jmp ->fff_newstr | |.ffunc_1 string_reverse | ffgccheck | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | mov STR:RB, [BASE] | mov RC, STR:RB->len | test RC, RC | jz ->fff_emptystr // Zero length string? | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_1 | add RB, #STR | mov TMP2, PC // Need another temp register. |.if X64 | mov TMP3, RC |.else | mov ARG3, RC |.endif | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] |1: | movzx RA, byte [RB] | add RB, 1 | sub RC, 1 | mov [PC+RC], RAL | jnz <1 | mov RD, PC | mov PC, TMP2 | jmp ->fff_newstr | |.macro ffstring_case, name, lo, hi | .ffunc_1 name | ffgccheck | cmp dword [BASE+4], LJ_TSTR; jne ->fff_fallback | mov STR:RB, [BASE] | mov RC, STR:RB->len | cmp [DISPATCH+DISPATCH_GL(tmpbuf.sz)], RC; jb ->fff_fallback_1 | add RB, #STR | mov TMP2, PC // Need another temp register. |.if X64 | mov TMP3, RC |.else | mov ARG3, RC |.endif | mov PC, [DISPATCH+DISPATCH_GL(tmpbuf.buf)] | jmp >3 |1: // ASCII case conversion. Yes, this is suboptimal code (do you care?). | movzx RA, byte [RB+RC] | cmp RA, lo | jb >2 | cmp RA, hi | ja >2 | xor RA, 0x20 |2: | mov [PC+RC], RAL |3: | sub RC, 1 | jns <1 | mov RD, PC | mov PC, TMP2 | jmp ->fff_newstr |.endmacro | |ffstring_case string_lower, 0x41, 0x5a |ffstring_case string_upper, 0x61, 0x7a | |//-- Table library ------------------------------------------------------ | |.ffunc_1 table_getn | cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback | mov RB, BASE // Save BASE. | mov TAB:FCARG1, [BASE] | call extern lj_tab_len@4 // LJ_FASTCALL (GCtab *t) | // Length of table returned in eax (RD). | mov BASE, RB // Restore BASE. |.if DUALNUM | mov RB, RD; jmp ->fff_resi |.elif SSE | cvtsi2sd xmm0, RD; jmp ->fff_resxmm0 |.else | mov ARG1, RD; fild ARG1; jmp ->fff_resn |.endif | |//-- Bit library -------------------------------------------------------- | |.define TOBIT_BIAS, 0x59c00000 // 2^52 + 2^51 (float, not double!). | |.macro .ffunc_bit, name, kind | .ffunc_1 name |.if kind == 2 |.if SSE | sseconst_tobit xmm1, RBa |.else | mov TMP1, TOBIT_BIAS |.endif |.endif | cmp dword [BASE+4], LJ_TISNUM |.if DUALNUM | jne >1 | mov RB, dword [BASE] |.if kind > 0 | jmp >2 |.else | jmp ->fff_resbit |.endif |1: | ja ->fff_fallback |.else | jae ->fff_fallback |.endif |.if SSE | movsd xmm0, qword [BASE] |.if kind < 2 | sseconst_tobit xmm1, RBa |.endif | addsd xmm0, xmm1 | movd RB, xmm0 |.else | fld qword [BASE] |.if kind < 2 | mov TMP1, TOBIT_BIAS |.endif | fadd TMP1 | fstp FPARG1 |.if kind > 0 | mov RB, ARG1 |.endif |.endif |2: |.endmacro | |.ffunc_bit bit_tobit, 0 |.if DUALNUM or SSE |.if not SSE | mov RB, ARG1 |.endif | jmp ->fff_resbit |.else | fild ARG1 | jmp ->fff_resn |.endif | |.macro .ffunc_bit_op, name, ins | .ffunc_bit name, 2 | mov TMP2, NARGS:RD // Save for fallback. | lea RD, [BASE+NARGS:RD*8-16] |1: | cmp RD, BASE | jbe ->fff_resbit | cmp dword [RD+4], LJ_TISNUM |.if DUALNUM | jne >2 | ins RB, dword [RD] | sub RD, 8 | jmp <1 |2: | ja ->fff_fallback_bit_op |.else | jae ->fff_fallback_bit_op |.endif |.if SSE | movsd xmm0, qword [RD] | addsd xmm0, xmm1 | movd RA, xmm0 | ins RB, RA |.else | fld qword [RD] | fadd TMP1 | fstp FPARG1 | ins RB, ARG1 |.endif | sub RD, 8 | jmp <1 |.endmacro | |.ffunc_bit_op bit_band, and |.ffunc_bit_op bit_bor, or |.ffunc_bit_op bit_bxor, xor | |.ffunc_bit bit_bswap, 1 | bswap RB | jmp ->fff_resbit | |.ffunc_bit bit_bnot, 1 | not RB |.if DUALNUM | jmp ->fff_resbit |.elif SSE |->fff_resbit: | cvtsi2sd xmm0, RB | jmp ->fff_resxmm0 |.else |->fff_resbit: | mov ARG1, RB | fild ARG1 | jmp ->fff_resn |.endif | |->fff_fallback_bit_op: | mov NARGS:RD, TMP2 // Restore for fallback | jmp ->fff_fallback | |.macro .ffunc_bit_sh, name, ins |.if DUALNUM | .ffunc_bit name, 1 | // Note: no inline conversion from number for 2nd argument! | cmp dword [BASE+12], LJ_TISNUM; jne ->fff_fallback | mov RA, dword [BASE+8] |.elif SSE | .ffunc_nnsse name | sseconst_tobit xmm2, RBa | addsd xmm0, xmm2 | addsd xmm1, xmm2 | movd RB, xmm0 | movd RA, xmm1 |.else | .ffunc_nn name | mov TMP1, TOBIT_BIAS | fadd TMP1 | fstp FPARG3 | fadd TMP1 | fstp FPARG1 | mov RA, ARG3 | mov RB, ARG1 |.endif | ins RB, cl // Assumes RA is ecx. | jmp ->fff_resbit |.endmacro | |.ffunc_bit_sh bit_lshift, shl |.ffunc_bit_sh bit_rshift, shr |.ffunc_bit_sh bit_arshift, sar |.ffunc_bit_sh bit_rol, rol |.ffunc_bit_sh bit_ror, ror | |//----------------------------------------------------------------------- | |->fff_fallback_2: | mov NARGS:RD, 1+2 // Other args are ignored, anyway. | jmp ->fff_fallback |->fff_fallback_1: | mov NARGS:RD, 1+1 // Other args are ignored, anyway. |->fff_fallback: // Call fast function fallback handler. | // BASE = new base, RD = nargs+1 | mov L:RB, SAVE_L | mov PC, [BASE-4] // Fallback may overwrite PC. | mov SAVE_PC, PC // Redundant (but a defined value). | mov L:RB->base, BASE | lea RD, [BASE+NARGS:RD*8-8] | lea RA, [RD+8*LUA_MINSTACK] // Ensure enough space for handler. | mov L:RB->top, RD | mov CFUNC:RD, [BASE-8] | cmp RA, L:RB->maxstack | ja >5 // Need to grow stack. |.if X64 | mov CARG1d, L:RB |.else | mov ARG1, L:RB |.endif | call aword CFUNC:RD->f // (lua_State *L) | mov BASE, L:RB->base | // Either throws an error, or recovers and returns -1, 0 or nresults+1. | test RD, RD; jg ->fff_res // Returned nresults+1? |1: | mov RA, L:RB->top | sub RA, BASE | shr RA, 3 | test RD, RD | lea NARGS:RD, [RA+1] | mov LFUNC:RB, [BASE-8] | jne ->vm_call_tail // Returned -1? | ins_callt // Returned 0: retry fast path. | |// Reconstruct previous base for vmeta_call during tailcall. |->vm_call_tail: | mov RA, BASE | test PC, FRAME_TYPE | jnz >3 | movzx RB, PC_RA | not RBa // Note: ~RB = -(RB+1) | lea BASE, [BASE+RB*8] // base = base - (RB+1)*8 | jmp ->vm_call_dispatch // Resolve again for tailcall. |3: | mov RB, PC | and RB, -8 | sub BASE, RB | jmp ->vm_call_dispatch // Resolve again for tailcall. | |5: // Grow stack for fallback handler. | mov FCARG2, LUA_MINSTACK | mov FCARG1, L:RB | call extern lj_state_growstack@8 // (lua_State *L, int n) | mov BASE, L:RB->base | xor RD, RD // Simulate a return 0. | jmp <1 // Dumb retry (goes through ff first). | |->fff_gcstep: // Call GC step function. | // BASE = new base, RD = nargs+1 | pop RBa // Must keep stack at same level. | mov TMPa, RBa // Save return address | mov L:RB, SAVE_L | mov SAVE_PC, PC // Redundant (but a defined value). | mov L:RB->base, BASE | lea RD, [BASE+NARGS:RD*8-8] | mov FCARG1, L:RB | mov L:RB->top, RD | call extern lj_gc_step@4 // (lua_State *L) | mov BASE, L:RB->base | mov RD, L:RB->top | sub RD, BASE | shr RD, 3 | add NARGS:RD, 1 | mov RBa, TMPa | push RBa // Restore return address. | ret | |//----------------------------------------------------------------------- |//-- Special dispatch targets ------------------------------------------- |//----------------------------------------------------------------------- | |->vm_record: // Dispatch target for recording phase. |.if JIT | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] | test RDL, HOOK_VMEVENT // No recording while in vmevent. | jnz >5 | // Decrement the hookcount for consistency, but always do the call. | test RDL, HOOK_ACTIVE | jnz >1 | test RDL, LUA_MASKLINE|LUA_MASKCOUNT | jz >1 | dec dword [DISPATCH+DISPATCH_GL(hookcount)] | jmp >1 |.endif | |->vm_rethook: // Dispatch target for return hooks. | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] | test RDL, HOOK_ACTIVE // Hook already active? | jnz >5 | jmp >1 | |->vm_inshook: // Dispatch target for instr/line hooks. | movzx RD, byte [DISPATCH+DISPATCH_GL(hookmask)] | test RDL, HOOK_ACTIVE // Hook already active? | jnz >5 | | test RDL, LUA_MASKLINE|LUA_MASKCOUNT | jz >5 | dec dword [DISPATCH+DISPATCH_GL(hookcount)] | jz >1 | test RDL, LUA_MASKLINE | jz >5 |1: | mov L:RB, SAVE_L | mov L:RB->base, BASE | mov FCARG2, PC // Caveat: FCARG2 == BASE | mov FCARG1, L:RB | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. | call extern lj_dispatch_ins@8 // (lua_State *L, BCIns *pc) |3: | mov BASE, L:RB->base |4: | movzx RA, PC_RA |5: | movzx OP, PC_OP | movzx RD, PC_RD |.if X64 | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC] // Re-dispatch to static ins. |.else | jmp aword [DISPATCH+OP*4+GG_DISP2STATIC] // Re-dispatch to static ins. |.endif | |->cont_hook: // Continue from hook yield. | add PC, 4 | mov RA, [RB-24] | mov MULTRES, RA // Restore MULTRES for *M ins. | jmp <4 | |->vm_hotloop: // Hot loop counter underflow. |.if JIT | mov LFUNC:RB, [BASE-8] // Same as curr_topL(L). | mov RB, LFUNC:RB->pc | movzx RD, byte [RB+PC2PROTO(framesize)] | lea RD, [BASE+RD*8] | mov L:RB, SAVE_L | mov L:RB->base, BASE | mov L:RB->top, RD | mov FCARG2, PC | lea FCARG1, [DISPATCH+GG_DISP2J] | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa | mov SAVE_PC, PC | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) | jmp <3 |.endif | |->vm_callhook: // Dispatch target for call hooks. | mov SAVE_PC, PC |.if JIT | jmp >1 |.endif | |->vm_hotcall: // Hot call counter underflow. |.if JIT | mov SAVE_PC, PC | or PC, 1 // Marker for hot call. |1: |.endif | lea RD, [BASE+NARGS:RD*8-8] | mov L:RB, SAVE_L | mov L:RB->base, BASE | mov L:RB->top, RD | mov FCARG2, PC | mov FCARG1, L:RB | call extern lj_dispatch_call@8 // (lua_State *L, const BCIns *pc) | // ASMFunction returned in eax/rax (RDa). | mov SAVE_PC, 0 // Invalidate for subsequent line hook. |.if JIT | and PC, -2 |.endif | mov BASE, L:RB->base | mov RAa, RDa | mov RD, L:RB->top | sub RD, BASE | mov RBa, RAa | movzx RA, PC_RA | shr RD, 3 | add NARGS:RD, 1 | jmp RBa | |//----------------------------------------------------------------------- |//-- Trace exit handler ------------------------------------------------- |//----------------------------------------------------------------------- | |// Called from an exit stub with the exit number on the stack. |// The 16 bit exit number is stored with two (sign-extended) push imm8. |->vm_exit_handler: |.if JIT |.if X64 | push r13; push r12 | push r11; push r10; push r9; push r8 | push rdi; push rsi; push rbp; lea rbp, [rsp+88]; push rbp | push rbx; push rdx; push rcx; push rax | movzx RC, byte [rbp-8] // Reconstruct exit number. | mov RCH, byte [rbp-16] | mov [rbp-8], r15; mov [rbp-16], r14 |.else | push ebp; lea ebp, [esp+12]; push ebp | push ebx; push edx; push ecx; push eax | movzx RC, byte [ebp-4] // Reconstruct exit number. | mov RCH, byte [ebp-8] | mov [ebp-4], edi; mov [ebp-8], esi |.endif | // Caveat: DISPATCH is ebx. | mov DISPATCH, [ebp] | mov RA, [DISPATCH+DISPATCH_GL(vmstate)] // Get trace number. | set_vmstate EXIT | mov [DISPATCH+DISPATCH_J(exitno)], RC | mov [DISPATCH+DISPATCH_J(parent)], RA |.if X64 |.if X64WIN | sub rsp, 16*8+4*8 // Room for SSE regs + save area. |.else | sub rsp, 16*8 // Room for SSE regs. |.endif | add rbp, -128 | movsd qword [rbp-8], xmm15; movsd qword [rbp-16], xmm14 | movsd qword [rbp-24], xmm13; movsd qword [rbp-32], xmm12 | movsd qword [rbp-40], xmm11; movsd qword [rbp-48], xmm10 | movsd qword [rbp-56], xmm9; movsd qword [rbp-64], xmm8 | movsd qword [rbp-72], xmm7; movsd qword [rbp-80], xmm6 | movsd qword [rbp-88], xmm5; movsd qword [rbp-96], xmm4 | movsd qword [rbp-104], xmm3; movsd qword [rbp-112], xmm2 | movsd qword [rbp-120], xmm1; movsd qword [rbp-128], xmm0 |.else | sub esp, 8*8+16 // Room for SSE regs + args. | movsd qword [ebp-40], xmm7; movsd qword [ebp-48], xmm6 | movsd qword [ebp-56], xmm5; movsd qword [ebp-64], xmm4 | movsd qword [ebp-72], xmm3; movsd qword [ebp-80], xmm2 | movsd qword [ebp-88], xmm1; movsd qword [ebp-96], xmm0 |.endif | // Caveat: RB is ebp. | mov L:RB, [DISPATCH+DISPATCH_GL(jit_L)] | mov BASE, [DISPATCH+DISPATCH_GL(jit_base)] | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa | mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0 | mov L:RB->base, BASE |.if X64WIN | lea CARG2, [rsp+4*8] |.elif X64 | mov CARG2, rsp |.else | lea FCARG2, [esp+16] |.endif | lea FCARG1, [DISPATCH+GG_DISP2J] | call extern lj_trace_exit@8 // (jit_State *J, ExitState *ex) | // MULTRES or negated error code returned in eax (RD). | mov RAa, L:RB->cframe | and RAa, CFRAME_RAWMASK |.if X64WIN | // Reposition stack later. |.elif X64 | mov rsp, RAa // Reposition stack to C frame. |.else | mov esp, RAa // Reposition stack to C frame. |.endif | mov [RAa+CFRAME_OFS_L], L:RB // Set SAVE_L (on-trace resume/yield). | mov BASE, L:RB->base | mov PC, [RAa+CFRAME_OFS_PC] // Get SAVE_PC. |.if X64 | jmp >1 |.endif |.endif |->vm_exit_interp: | // RD = MULTRES or negated error code, BASE, PC and DISPATCH set. |.if JIT |.if X64 | // Restore additional callee-save registers only used in compiled code. |.if X64WIN | lea RAa, [rsp+9*16+4*8] |1: | movdqa xmm15, [RAa-9*16] | movdqa xmm14, [RAa-8*16] | movdqa xmm13, [RAa-7*16] | movdqa xmm12, [RAa-6*16] | movdqa xmm11, [RAa-5*16] | movdqa xmm10, [RAa-4*16] | movdqa xmm9, [RAa-3*16] | movdqa xmm8, [RAa-2*16] | movdqa xmm7, [RAa-1*16] | mov rsp, RAa // Reposition stack to C frame. | movdqa xmm6, [RAa] | mov r15, CSAVE_3 | mov r14, CSAVE_4 |.else | add rsp, 16 // Reposition stack to C frame. |1: |.endif | mov r13, TMPa | mov r12, TMPQ |.endif | test RD, RD; js >3 // Check for error from exit. | mov MULTRES, RD | mov LFUNC:KBASE, [BASE-8] | mov KBASE, LFUNC:KBASE->pc | mov KBASE, [KBASE+PC2PROTO(k)] | mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0 | set_vmstate INTERP | // Modified copy of ins_next which handles function header dispatch, too. | mov RC, [PC] | movzx RA, RCH | movzx OP, RCL | add PC, 4 | shr RC, 16 | cmp OP, BC_FUNCF // Function header? | jb >2 | mov RC, MULTRES // RC/RD holds nres+1. |2: |.if X64 | jmp aword [DISPATCH+OP*8] |.else | jmp aword [DISPATCH+OP*4] |.endif | |3: // Rethrow error from the right C frame. | neg RD | mov FCARG1, L:RB | mov FCARG2, RD | call extern lj_err_throw@8 // (lua_State *L, int errcode) |.endif | |//----------------------------------------------------------------------- |//-- Math helper functions ---------------------------------------------- |//----------------------------------------------------------------------- | |// FP value rounding. Called by math.floor/math.ceil fast functions |// and from JIT code. | |// x87 variant: Arg/ret on x87 stack. No int/xmm registers modified. |.macro vm_round_x87, mode1, mode2 | fnstcw word [esp+4] // Caveat: overwrites ARG1 and ARG2. | mov [esp+8], eax | mov ax, mode1 | or ax, [esp+4] |.if mode2 ~= 0xffff | and ax, mode2 |.endif | mov [esp+6], ax | fldcw word [esp+6] | frndint | fldcw word [esp+4] | mov eax, [esp+8] | ret |.endmacro | |// SSE variant: arg/ret is xmm0. xmm0-xmm3 and RD (eax) modified. |.macro vm_round_sse, mode | sseconst_abs xmm2, RDa | sseconst_2p52 xmm3, RDa | movaps xmm1, xmm0 | andpd xmm1, xmm2 // |x| | ucomisd xmm3, xmm1 // No truncation if 2^52 <= |x|. | jbe >1 | andnpd xmm2, xmm0 // Isolate sign bit. |.if mode == 2 // trunc(x)? | movaps xmm0, xmm1 | addsd xmm1, xmm3 // (|x| + 2^52) - 2^52 | subsd xmm1, xmm3 | sseconst_1 xmm3, RDa | cmpsd xmm0, xmm1, 1 // |x| < result? | andpd xmm0, xmm3 | subsd xmm1, xmm0 // If yes, subtract -1. | orpd xmm1, xmm2 // Merge sign bit back in. |.else | addsd xmm1, xmm3 // (|x| + 2^52) - 2^52 | subsd xmm1, xmm3 | orpd xmm1, xmm2 // Merge sign bit back in. | .if mode == 1 // ceil(x)? | sseconst_m1 xmm2, RDa // Must subtract -1 to preserve -0. | cmpsd xmm0, xmm1, 6 // x > result? | .else // floor(x)? | sseconst_1 xmm2, RDa | cmpsd xmm0, xmm1, 1 // x < result? | .endif | andpd xmm0, xmm2 | subsd xmm1, xmm0 // If yes, subtract +-1. |.endif | movaps xmm0, xmm1 |1: | ret |.endmacro | |.macro vm_round, name, ssemode, mode1, mode2 |->name: |.if not SSE | vm_round_x87 mode1, mode2 |.endif |->name .. _sse: | vm_round_sse ssemode |.endmacro | | vm_round vm_floor, 0, 0x0400, 0xf7ff | vm_round vm_ceil, 1, 0x0800, 0xfbff | vm_round vm_trunc, 2, 0x0c00, 0xffff | |// FP modulo x%y. Called by BC_MOD* and vm_arith. |->vm_mod: |.if SSE |// Args in xmm0/xmm1, return value in xmm0. |// Caveat: xmm0-xmm5 and RC (eax) modified! | movaps xmm5, xmm0 | divsd xmm0, xmm1 | sseconst_abs xmm2, RDa | sseconst_2p52 xmm3, RDa | movaps xmm4, xmm0 | andpd xmm4, xmm2 // |x/y| | ucomisd xmm3, xmm4 // No truncation if 2^52 <= |x/y|. | jbe >1 | andnpd xmm2, xmm0 // Isolate sign bit. | addsd xmm4, xmm3 // (|x/y| + 2^52) - 2^52 | subsd xmm4, xmm3 | orpd xmm4, xmm2 // Merge sign bit back in. | sseconst_1 xmm2, RDa | cmpsd xmm0, xmm4, 1 // x/y < result? | andpd xmm0, xmm2 | subsd xmm4, xmm0 // If yes, subtract 1.0. | movaps xmm0, xmm5 | mulsd xmm1, xmm4 | subsd xmm0, xmm1 | ret |1: | mulsd xmm1, xmm0 | movaps xmm0, xmm5 | subsd xmm0, xmm1 | ret |.else |// Args/ret on x87 stack (y on top). No xmm registers modified. |// Caveat: needs 3 slots on x87 stack! RC (eax) modified! | fld st1 | fdiv st1 | fnstcw word [esp+4] | mov ax, 0x0400 | or ax, [esp+4] | and ax, 0xf7ff | mov [esp+6], ax | fldcw word [esp+6] | frndint | fldcw word [esp+4] | fmulp st1 | fsubp st1 | ret |.endif | |// FP log2(x). Called by math.log(x, base). |->vm_log2: |.if X64WIN | movsd qword [rsp+8], xmm0 // Use scratch area. | fld1 | fld qword [rsp+8] | fyl2x | fstp qword [rsp+8] | movsd xmm0, qword [rsp+8] |.elif X64 | movsd qword [rsp-8], xmm0 // Use red zone. | fld1 | fld qword [rsp-8] | fyl2x | fstp qword [rsp-8] | movsd xmm0, qword [rsp-8] |.else | fld1 | fld qword [esp+4] | fyl2x |.endif | ret | |// FP exponentiation e^x and 2^x. Called by math.exp fast function and |// from JIT code. Arg/ret on x87 stack. No int/xmm regs modified. |// Caveat: needs 3 slots on x87 stack! |->vm_exp_x87: | fldl2e; fmulp st1 // e^x ==> 2^(x*log2(e)) |->vm_exp2_x87: | .if X64WIN | .define expscratch, dword [rsp+8] // Use scratch area. | .elif X64 | .define expscratch, dword [rsp-8] // Use red zone. | .else | .define expscratch, dword [esp+4] // Needs 4 byte scratch area. | .endif | fst expscratch // Caveat: overwrites ARG1. | cmp expscratch, 0x7f800000; je >1 // Special case: e^+Inf = +Inf | cmp expscratch, 0xff800000; je >2 // Special case: e^-Inf = 0 |->vm_exp2raw: // Entry point for vm_pow. Without +-Inf check. | fdup; frndint; fsub st1, st0; fxch // Split into frac/int part. | f2xm1; fld1; faddp st1; fscale; fpop1 // ==> (2^frac-1 +1) << int |1: | ret |2: | fpop; fldz; ret | |// Generic power function x^y. Called by BC_POW, math.pow fast function, |// and vm_arith. |// Args/ret on x87 stack (y on top). RC (eax) modified. |// Caveat: needs 3 slots on x87 stack! |->vm_pow: |.if not SSE | fist dword [esp+4] // Store/reload int before comparison. | fild dword [esp+4] // Integral exponent used in vm_powi. | fucomip st1 | jnz >8 // Branch for FP exponents. | jp >9 // Branch for NaN exponent. | fpop // Pop y and fallthrough to vm_powi. | |// FP/int power function x^i. Arg1/ret on x87 stack. |// Arg2 (int) on C stack. RC (eax) modified. |// Caveat: needs 2 slots on x87 stack! | mov eax, [esp+4] | cmp eax, 1; jle >6 // i<=1? | // Now 1 < (unsigned)i <= 0x80000000. |1: // Handle leading zeros. | test eax, 1; jnz >2 | fmul st0 | shr eax, 1 | jmp <1 |2: | shr eax, 1; jz >5 | fdup |3: // Handle trailing bits. | fmul st0 | shr eax, 1; jz >4 | jnc <3 | fmul st1, st0 | jmp <3 |4: | fmulp st1 |5: | ret |6: | je <5 // x^1 ==> x | jb >7 | fld1; fdivrp st1 | neg eax | cmp eax, 1; je <5 // x^-1 ==> 1/x | jmp <1 // x^-i ==> (1/x)^i |7: | fpop; fld1 // x^0 ==> 1 | ret | |8: // FP/FP power function x^y. | fst dword [esp+4] | fxch | fst dword [esp+8] | mov eax, [esp+4]; shl eax, 1 | cmp eax, 0xff000000; je >2 // x^+-Inf? | mov eax, [esp+8]; shl eax, 1; je >4 // +-0^y? | cmp eax, 0xff000000; je >4 // +-Inf^y? | fyl2x | jmp ->vm_exp2raw | |9: // Handle x^NaN. | fld1 | fucomip st2 | je >1 // 1^NaN ==> 1 | fxch // x^NaN ==> NaN |1: | fpop | ret | |2: // Handle x^+-Inf. | fabs | fld1 | fucomip st1 | je >3 // +-1^+-Inf ==> 1 | fpop; fabs; fldz; mov eax, 0; setc al | ror eax, 1; xor eax, [esp+4]; jns >3 // |x|<>1, x^+-Inf ==> +Inf/0 | fxch |3: | fpop1; fabs | ret | |4: // Handle +-0^y or +-Inf^y. | cmp dword [esp+4], 0; jge <3 // y >= 0, x^y ==> |x| | fpop; fpop | test eax, eax; jz >5 // y < 0, +-0^y ==> +Inf | fldz // y < 0, +-Inf^y ==> 0 | ret |5: | mov dword [esp+4], 0x7f800000 // Return +Inf. | fld dword [esp+4] | ret |.endif | |// Args in xmm0/xmm1. Ret in xmm0. xmm0-xmm2 and RC (eax) modified. |// Needs 16 byte scratch area for x86. Also called from JIT code. |->vm_pow_sse: | cvtsd2si eax, xmm1 | cvtsi2sd xmm2, eax | ucomisd xmm1, xmm2 | jnz >8 // Branch for FP exponents. | jp >9 // Branch for NaN exponent. | // Fallthrough to vm_powi_sse. | |// Args in xmm0/eax. Ret in xmm0. xmm0-xmm1 and eax modified. |->vm_powi_sse: | cmp eax, 1; jle >6 // i<=1? | // Now 1 < (unsigned)i <= 0x80000000. |1: // Handle leading zeros. | test eax, 1; jnz >2 | mulsd xmm0, xmm0 | shr eax, 1 | jmp <1 |2: | shr eax, 1; jz >5 | movaps xmm1, xmm0 |3: // Handle trailing bits. | mulsd xmm0, xmm0 | shr eax, 1; jz >4 | jnc <3 | mulsd xmm1, xmm0 | jmp <3 |4: | mulsd xmm0, xmm1 |5: | ret |6: | je <5 // x^1 ==> x | jb >7 // x^0 ==> 1 | neg eax | call <1 | sseconst_1 xmm1, RDa | divsd xmm1, xmm0 | movaps xmm0, xmm1 | ret |7: | sseconst_1 xmm0, RDa | ret | |8: // FP/FP power function x^y. |.if X64 | movd rax, xmm1; shl rax, 1 | rol rax, 12; cmp rax, 0xffe; je >2 // x^+-Inf? | movd rax, xmm0; shl rax, 1; je >4 // +-0^y? | rol rax, 12; cmp rax, 0xffe; je >5 // +-Inf^y? | .if X64WIN | movsd qword [rsp+16], xmm1 // Use scratch area. | movsd qword [rsp+8], xmm0 | fld qword [rsp+16] | fld qword [rsp+8] | .else | movsd qword [rsp-16], xmm1 // Use red zone. | movsd qword [rsp-8], xmm0 | fld qword [rsp-16] | fld qword [rsp-8] | .endif |.else | movsd qword [esp+12], xmm1 // Needs 16 byte scratch area. | movsd qword [esp+4], xmm0 | cmp dword [esp+12], 0; jne >1 | mov eax, [esp+16]; shl eax, 1 | cmp eax, 0xffe00000; je >2 // x^+-Inf? |1: | cmp dword [esp+4], 0; jne >1 | mov eax, [esp+8]; shl eax, 1; je >4 // +-0^y? | cmp eax, 0xffe00000; je >5 // +-Inf^y? |1: | fld qword [esp+12] | fld qword [esp+4] |.endif | fyl2x // y*log2(x) | fdup; frndint; fsub st1, st0; fxch // Split into frac/int part. | f2xm1; fld1; faddp st1; fscale; fpop1 // ==> (2^frac-1 +1) << int |.if X64WIN | fstp qword [rsp+8] // Use scratch area. | movsd xmm0, qword [rsp+8] |.elif X64 | fstp qword [rsp-8] // Use red zone. | movsd xmm0, qword [rsp-8] |.else | fstp qword [esp+4] // Needs 8 byte scratch area. | movsd xmm0, qword [esp+4] |.endif | ret | |9: // Handle x^NaN. | sseconst_1 xmm2, RDa | ucomisd xmm0, xmm2; je >1 // 1^NaN ==> 1 | movaps xmm0, xmm1 // x^NaN ==> NaN |1: | ret | |2: // Handle x^+-Inf. | sseconst_abs xmm2, RDa | andpd xmm0, xmm2 // |x| | sseconst_1 xmm2, RDa | ucomisd xmm0, xmm2; je <1 // +-1^+-Inf ==> 1 | movmskpd eax, xmm1 | xorps xmm0, xmm0 | mov ah, al; setc al; xor al, ah; jne <1 // |x|<>1, x^+-Inf ==> +Inf/0 |3: | sseconst_hi xmm0, RDa, 7ff00000 // +Inf | ret | |4: // Handle +-0^y. | movmskpd eax, xmm1; test eax, eax; jnz <3 // y < 0, +-0^y ==> +Inf | xorps xmm0, xmm0 // y >= 0, +-0^y ==> 0 | ret | |5: // Handle +-Inf^y. | movmskpd eax, xmm1; test eax, eax; jz <3 // y >= 0, +-Inf^y ==> +Inf | xorps xmm0, xmm0 // y < 0, +-Inf^y ==> 0 | ret | |// Callable from C: double lj_vm_foldfpm(double x, int fpm) |// Computes fpm(x) for extended math functions. ORDER FPM. |->vm_foldfpm: |.if JIT |.if X64 | .if X64WIN | .define fpmop, CARG2d | .else | .define fpmop, CARG1d | .endif | cmp fpmop, 1; jb ->vm_floor; je ->vm_ceil | cmp fpmop, 3; jb ->vm_trunc; ja >2 | sqrtsd xmm0, xmm0; ret |2: | .if X64WIN | movsd qword [rsp+8], xmm0 // Use scratch area. | fld qword [rsp+8] | .else | movsd qword [rsp-8], xmm0 // Use red zone. | fld qword [rsp-8] | .endif | cmp fpmop, 5; ja >2 | .if X64WIN; pop rax; .endif | je >1 | call ->vm_exp_x87 | .if X64WIN; push rax; .endif | jmp >7 |1: | call ->vm_exp2_x87 | .if X64WIN; push rax; .endif | jmp >7 |2: ; cmp fpmop, 7; je >1; ja >2 | fldln2; fxch; fyl2x; jmp >7 |1: ; fld1; fxch; fyl2x; jmp >7 |2: ; cmp fpmop, 9; je >1; ja >2 | fldlg2; fxch; fyl2x; jmp >7 |1: ; fsin; jmp >7 |2: ; cmp fpmop, 11; je >1; ja >9 | fcos; jmp >7 |1: ; fptan; fpop |7: | .if X64WIN | fstp qword [rsp+8] // Use scratch area. | movsd xmm0, qword [rsp+8] | .else | fstp qword [rsp-8] // Use red zone. | movsd xmm0, qword [rsp-8] | .endif | ret |.else // x86 calling convention. | .define fpmop, eax |.if SSE | mov fpmop, [esp+12] | movsd xmm0, qword [esp+4] | cmp fpmop, 1; je >1; ja >2 | call ->vm_floor; jmp >7 |1: ; call ->vm_ceil; jmp >7 |2: ; cmp fpmop, 3; je >1; ja >2 | call ->vm_trunc; jmp >7 |1: | sqrtsd xmm0, xmm0 |7: | movsd qword [esp+4], xmm0 // Overwrite callee-owned args. | fld qword [esp+4] | ret |2: ; fld qword [esp+4] | cmp fpmop, 5; jb ->vm_exp_x87; je ->vm_exp2_x87 |2: ; cmp fpmop, 7; je >1; ja >2 | fldln2; fxch; fyl2x; ret |1: ; fld1; fxch; fyl2x; ret |2: ; cmp fpmop, 9; je >1; ja >2 | fldlg2; fxch; fyl2x; ret |1: ; fsin; ret |2: ; cmp fpmop, 11; je >1; ja >9 | fcos; ret |1: ; fptan; fpop; ret |.else | mov fpmop, [esp+12] | fld qword [esp+4] | cmp fpmop, 1; jb ->vm_floor; je ->vm_ceil | cmp fpmop, 3; jb ->vm_trunc; ja >2 | fsqrt; ret |2: ; cmp fpmop, 5; jb ->vm_exp_x87; je ->vm_exp2_x87 | cmp fpmop, 7; je >1; ja >2 | fldln2; fxch; fyl2x; ret |1: ; fld1; fxch; fyl2x; ret |2: ; cmp fpmop, 9; je >1; ja >2 | fldlg2; fxch; fyl2x; ret |1: ; fsin; ret |2: ; cmp fpmop, 11; je >1; ja >9 | fcos; ret |1: ; fptan; fpop; ret |.endif |.endif |9: ; int3 // Bad fpm. |.endif | |// Callable from C: double lj_vm_foldarith(double x, double y, int op) |// Compute x op y for basic arithmetic operators (+ - * / % ^ and unary -) |// and basic math functions. ORDER ARITH |->vm_foldarith: |.if X64 | | .if X64WIN | .define foldop, CARG3d | .else | .define foldop, CARG1d | .endif | cmp foldop, 1; je >1; ja >2 | addsd xmm0, xmm1; ret |1: ; subsd xmm0, xmm1; ret |2: ; cmp foldop, 3; je >1; ja >2 | mulsd xmm0, xmm1; ret |1: ; divsd xmm0, xmm1; ret |2: ; cmp foldop, 5; jb ->vm_mod; je ->vm_pow | cmp foldop, 7; je >1; ja >2 | sseconst_sign xmm1, RDa; xorps xmm0, xmm1; ret |1: ; sseconst_abs xmm1, RDa; andps xmm0, xmm1; ret |2: ; cmp foldop, 9; ja >2 |.if X64WIN | movsd qword [rsp+8], xmm0 // Use scratch area. | movsd qword [rsp+16], xmm1 | fld qword [rsp+8] | fld qword [rsp+16] |.else | movsd qword [rsp-8], xmm0 // Use red zone. | movsd qword [rsp-16], xmm1 | fld qword [rsp-8] | fld qword [rsp-16] |.endif | je >1 | fpatan |7: |.if X64WIN | fstp qword [rsp+8] // Use scratch area. | movsd xmm0, qword [rsp+8] |.else | fstp qword [rsp-8] // Use red zone. | movsd xmm0, qword [rsp-8] |.endif | ret |1: ; fxch; fscale; fpop1; jmp <7 |2: ; cmp foldop, 11; je >1; ja >9 | minsd xmm0, xmm1; ret |1: ; maxsd xmm0, xmm1; ret |9: ; int3 // Bad op. | |.elif SSE // x86 calling convention with SSE ops. | | .define foldop, eax | mov foldop, [esp+20] | movsd xmm0, qword [esp+4] | movsd xmm1, qword [esp+12] | cmp foldop, 1; je >1; ja >2 | addsd xmm0, xmm1 |7: | movsd qword [esp+4], xmm0 // Overwrite callee-owned args. | fld qword [esp+4] | ret |1: ; subsd xmm0, xmm1; jmp <7 |2: ; cmp foldop, 3; je >1; ja >2 | mulsd xmm0, xmm1; jmp <7 |1: ; divsd xmm0, xmm1; jmp <7 |2: ; cmp foldop, 5 | je >1; ja >2 | call ->vm_mod; jmp <7 |1: ; pop edx; call ->vm_pow; push edx; jmp <7 // Writes to scratch area. |2: ; cmp foldop, 7; je >1; ja >2 | sseconst_sign xmm1, RDa; xorps xmm0, xmm1; jmp <7 |1: ; sseconst_abs xmm1, RDa; andps xmm0, xmm1; jmp <7 |2: ; cmp foldop, 9; ja >2 | fld qword [esp+4] // Reload from stack | fld qword [esp+12] | je >1 | fpatan; ret |1: ; fxch; fscale; fpop1; ret |2: ; cmp foldop, 11; je >1; ja >9 | minsd xmm0, xmm1; jmp <7 |1: ; maxsd xmm0, xmm1; jmp <7 |9: ; int3 // Bad op. | |.else // x86 calling convention with x87 ops. | | mov eax, [esp+20] | fld qword [esp+4] | fld qword [esp+12] | cmp eax, 1; je >1; ja >2 | faddp st1; ret |1: ; fsubp st1; ret |2: ; cmp eax, 3; je >1; ja >2 | fmulp st1; ret |1: ; fdivp st1; ret |2: ; cmp eax, 5; jb ->vm_mod; je ->vm_pow | cmp eax, 7; je >1; ja >2 | fpop; fchs; ret |1: ; fpop; fabs; ret |2: ; cmp eax, 9; je >1; ja >2 | fpatan; ret |1: ; fxch; fscale; fpop1; ret |2: ; cmp eax, 11; je >1; ja >9 | fucomi st1; fcmovnbe st1; fpop1; ret |1: ; fucomi st1; fcmovbe st1; fpop1; ret |9: ; int3 // Bad op. | |.endif | |//----------------------------------------------------------------------- |//-- Miscellaneous functions -------------------------------------------- |//----------------------------------------------------------------------- | |// int lj_vm_cpuid(uint32_t f, uint32_t res[4]) |->vm_cpuid: |.if X64 | mov eax, CARG1d | .if X64WIN; push rsi; mov rsi, CARG2; .endif | push rbx | cpuid | mov [rsi], eax | mov [rsi+4], ebx | mov [rsi+8], ecx | mov [rsi+12], edx | pop rbx | .if X64WIN; pop rsi; .endif | ret |.else | pushfd | pop edx | mov ecx, edx | xor edx, 0x00200000 // Toggle ID bit in flags. | push edx | popfd | pushfd | pop edx | xor eax, eax // Zero means no features supported. | cmp ecx, edx | jz >1 // No ID toggle means no CPUID support. | mov eax, [esp+4] // Argument 1 is function number. | push edi | push ebx | cpuid | mov edi, [esp+16] // Argument 2 is result area. | mov [edi], eax | mov [edi+4], ebx | mov [edi+8], ecx | mov [edi+12], edx | pop ebx | pop edi |1: | ret |.endif | |//----------------------------------------------------------------------- |//-- Assertions --------------------------------------------------------- |//----------------------------------------------------------------------- | |->assert_bad_for_arg_type: #ifdef LUA_USE_ASSERT | int3 #endif | int3 | |//----------------------------------------------------------------------- |//-- FFI helper functions ----------------------------------------------- |//----------------------------------------------------------------------- | |// Handler for callback functions. Callback slot number in ah/al. |->vm_ffi_callback: |.if FFI |.type CTSTATE, CTState, PC |.if not X64 | sub esp, 16 // Leave room for SAVE_ERRF etc. |.endif | saveregs_ // ebp/rbp already saved. ebp now holds global_State *. | lea DISPATCH, [ebp+GG_G2DISP] | mov CTSTATE, GL:ebp->ctype_state | movzx eax, ax | mov CTSTATE->cb.slot, eax |.if X64 | mov CTSTATE->cb.gpr[0], CARG1 | mov CTSTATE->cb.gpr[1], CARG2 | mov CTSTATE->cb.gpr[2], CARG3 | mov CTSTATE->cb.gpr[3], CARG4 | movsd qword CTSTATE->cb.fpr[0], xmm0 | movsd qword CTSTATE->cb.fpr[1], xmm1 | movsd qword CTSTATE->cb.fpr[2], xmm2 | movsd qword CTSTATE->cb.fpr[3], xmm3 |.if X64WIN | lea rax, [rsp+CFRAME_SIZE+4*8] |.else | lea rax, [rsp+CFRAME_SIZE] | mov CTSTATE->cb.gpr[4], CARG5 | mov CTSTATE->cb.gpr[5], CARG6 | movsd qword CTSTATE->cb.fpr[4], xmm4 | movsd qword CTSTATE->cb.fpr[5], xmm5 | movsd qword CTSTATE->cb.fpr[6], xmm6 | movsd qword CTSTATE->cb.fpr[7], xmm7 |.endif | mov CTSTATE->cb.stack, rax | mov CARG2, rsp |.else | lea eax, [esp+CFRAME_SIZE+16] | mov CTSTATE->cb.gpr[0], FCARG1 | mov CTSTATE->cb.gpr[1], FCARG2 | mov CTSTATE->cb.stack, eax | mov FCARG1, [esp+CFRAME_SIZE+12] // Move around misplaced retaddr/ebp. | mov FCARG2, [esp+CFRAME_SIZE+8] | mov SAVE_RET, FCARG1 | mov SAVE_R4, FCARG2 | mov FCARG2, esp |.endif | mov SAVE_PC, CTSTATE // Any value outside of bytecode is ok. | mov FCARG1, CTSTATE | call extern lj_ccallback_enter@8 // (CTState *cts, void *cf) | // lua_State * returned in eax (RD). | set_vmstate INTERP | mov BASE, L:RD->base | mov RD, L:RD->top | sub RD, BASE | mov LFUNC:RB, [BASE-8] | shr RD, 3 | add RD, 1 | ins_callt |.endif | |->cont_ffi_callback: // Return from FFI callback. |.if FFI | mov L:RA, SAVE_L | mov CTSTATE, [DISPATCH+DISPATCH_GL(ctype_state)] | mov aword CTSTATE->L, L:RAa | mov L:RA->base, BASE | mov L:RA->top, RB | mov FCARG1, CTSTATE | mov FCARG2, RC | call extern lj_ccallback_leave@8 // (CTState *cts, TValue *o) |.if X64 | mov rax, CTSTATE->cb.gpr[0] | movsd xmm0, qword CTSTATE->cb.fpr[0] | jmp ->vm_leave_unw |.else | mov L:RB, SAVE_L | mov eax, CTSTATE->cb.gpr[0] | mov edx, CTSTATE->cb.gpr[1] | cmp dword CTSTATE->cb.gpr[2], 1 | jb >7 | je >6 | fld qword CTSTATE->cb.fpr[0].d | jmp >7 |6: | fld dword CTSTATE->cb.fpr[0].f |7: | mov ecx, L:RB->top | movzx ecx, word [ecx+6] // Get stack adjustment and copy up. | mov SAVE_L, ecx // Must be one slot above SAVE_RET | restoreregs | pop ecx // Move return addr from SAVE_RET. | add esp, [esp] // Adjust stack. | add esp, 16 | push ecx | ret |.endif |.endif | |->vm_ffi_call@4: // Call C function via FFI. | // Caveat: needs special frame unwinding, see below. |.if FFI |.if X64 | .type CCSTATE, CCallState, rbx | push rbp; mov rbp, rsp; push rbx; mov CCSTATE, CARG1 |.else | .type CCSTATE, CCallState, ebx | push ebp; mov ebp, esp; push ebx; mov CCSTATE, FCARG1 |.endif | | // Readjust stack. |.if X64 | mov eax, CCSTATE->spadj | sub rsp, rax |.else | sub esp, CCSTATE->spadj |.if WIN | mov CCSTATE->spadj, esp |.endif |.endif | | // Copy stack slots. | movzx ecx, byte CCSTATE->nsp | sub ecx, 1 | js >2 |1: |.if X64 | mov rax, [CCSTATE+rcx*8+offsetof(CCallState, stack)] | mov [rsp+rcx*8+CCALL_SPS_EXTRA*8], rax |.else | mov eax, [CCSTATE+ecx*4+offsetof(CCallState, stack)] | mov [esp+ecx*4], eax |.endif | sub ecx, 1 | jns <1 |2: | |.if X64 | movzx eax, byte CCSTATE->nfpr | mov CARG1, CCSTATE->gpr[0] | mov CARG2, CCSTATE->gpr[1] | mov CARG3, CCSTATE->gpr[2] | mov CARG4, CCSTATE->gpr[3] |.if not X64WIN | mov CARG5, CCSTATE->gpr[4] | mov CARG6, CCSTATE->gpr[5] |.endif | test eax, eax; jz >5 | movaps xmm0, CCSTATE->fpr[0] | movaps xmm1, CCSTATE->fpr[1] | movaps xmm2, CCSTATE->fpr[2] | movaps xmm3, CCSTATE->fpr[3] |.if not X64WIN | cmp eax, 4; jbe >5 | movaps xmm4, CCSTATE->fpr[4] | movaps xmm5, CCSTATE->fpr[5] | movaps xmm6, CCSTATE->fpr[6] | movaps xmm7, CCSTATE->fpr[7] |.endif |5: |.else | mov FCARG1, CCSTATE->gpr[0] | mov FCARG2, CCSTATE->gpr[1] |.endif | | call aword CCSTATE->func | |.if X64 | mov CCSTATE->gpr[0], rax | movaps CCSTATE->fpr[0], xmm0 |.if not X64WIN | mov CCSTATE->gpr[1], rdx | movaps CCSTATE->fpr[1], xmm1 |.endif |.else | mov CCSTATE->gpr[0], eax | mov CCSTATE->gpr[1], edx | cmp byte CCSTATE->resx87, 1 | jb >7 | je >6 | fstp qword CCSTATE->fpr[0].d[0] | jmp >7 |6: | fstp dword CCSTATE->fpr[0].f[0] |7: |.if WIN | sub CCSTATE->spadj, esp |.endif |.endif | |.if X64 | mov rbx, [rbp-8]; leave; ret |.else | mov ebx, [ebp-4]; leave; ret |.endif |.endif |// Note: vm_ffi_call must be the last function in this object file! | |//----------------------------------------------------------------------- } /* Generate the code for a single instruction. */ static void build_ins(BuildCtx *ctx, BCOp op, int defop) { int vk = 0; |// Note: aligning all instructions does not pay off. |=>defop: switch (op) { /* -- Comparison ops ---------------------------------------------------- */ /* Remember: all ops branch for a true comparison, fall through otherwise. */ |.macro jmp_comp, lt, ge, le, gt, target ||switch (op) { ||case BC_ISLT: | lt target ||break; ||case BC_ISGE: | ge target ||break; ||case BC_ISLE: | le target ||break; ||case BC_ISGT: | gt target ||break; ||default: break; /* Shut up GCC. */ ||} |.endmacro case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: | // RA = src1, RD = src2, JMP with RD = target | ins_AD |.if DUALNUM | checkint RA, >7 | checkint RD, >8 | mov RB, dword [BASE+RA*8] | add PC, 4 | cmp RB, dword [BASE+RD*8] | jmp_comp jge, jl, jg, jle, >9 |6: | movzx RD, PC_RD | branchPC RD |9: | ins_next | |7: // RA is not an integer. | ja ->vmeta_comp | // RA is a number. | cmp dword [BASE+RD*8+4], LJ_TISNUM; jb >1; jne ->vmeta_comp | // RA is a number, RD is an integer. |.if SSE | cvtsi2sd xmm0, dword [BASE+RD*8] | jmp >2 |.else | fld qword [BASE+RA*8] | fild dword [BASE+RD*8] | jmp >3 |.endif | |8: // RA is an integer, RD is not an integer. | ja ->vmeta_comp | // RA is an integer, RD is a number. |.if SSE | cvtsi2sd xmm1, dword [BASE+RA*8] | movsd xmm0, qword [BASE+RD*8] | add PC, 4 | ucomisd xmm0, xmm1 | jmp_comp jbe, ja, jb, jae, <9 | jmp <6 |.else | fild dword [BASE+RA*8] | jmp >2 |.endif |.else | checknum RA, ->vmeta_comp | checknum RD, ->vmeta_comp |.endif |.if SSE |1: | movsd xmm0, qword [BASE+RD*8] |2: | add PC, 4 | ucomisd xmm0, qword [BASE+RA*8] |3: |.else |1: | fld qword [BASE+RA*8] // Reverse order, i.e like cmp D, A. |2: | fld qword [BASE+RD*8] |3: | add PC, 4 | fcomparepp |.endif | // Unordered: all of ZF CF PF set, ordered: PF clear. | // To preserve NaN semantics GE/GT branch on unordered, but LT/LE don't. |.if DUALNUM | jmp_comp jbe, ja, jb, jae, <9 | jmp <6 |.else | jmp_comp jbe, ja, jb, jae, >1 | movzx RD, PC_RD | branchPC RD |1: | ins_next |.endif break; case BC_ISEQV: case BC_ISNEV: vk = op == BC_ISEQV; | ins_AD // RA = src1, RD = src2, JMP with RD = target | mov RB, [BASE+RD*8+4] | add PC, 4 |.if DUALNUM | cmp RB, LJ_TISNUM; jne >7 | checkint RA, >8 | mov RB, dword [BASE+RD*8] | cmp RB, dword [BASE+RA*8] if (vk) { | jne >9 } else { | je >9 } | movzx RD, PC_RD | branchPC RD |9: | ins_next | |7: // RD is not an integer. | ja >5 | // RD is a number. | cmp dword [BASE+RA*8+4], LJ_TISNUM; jb >1; jne >5 | // RD is a number, RA is an integer. |.if SSE | cvtsi2sd xmm0, dword [BASE+RA*8] |.else | fild dword [BASE+RA*8] |.endif | jmp >2 | |8: // RD is an integer, RA is not an integer. | ja >5 | // RD is an integer, RA is a number. |.if SSE | cvtsi2sd xmm0, dword [BASE+RD*8] | ucomisd xmm0, qword [BASE+RA*8] |.else | fild dword [BASE+RD*8] | fld qword [BASE+RA*8] |.endif | jmp >4 | |.else | cmp RB, LJ_TISNUM; jae >5 | checknum RA, >5 |.endif |.if SSE |1: | movsd xmm0, qword [BASE+RA*8] |2: | ucomisd xmm0, qword [BASE+RD*8] |4: |.else |1: | fld qword [BASE+RA*8] |2: | fld qword [BASE+RD*8] |4: | fcomparepp |.endif iseqne_fp: if (vk) { | jp >2 // Unordered means not equal. | jne >2 } else { | jp >2 // Unordered means not equal. | je >1 } iseqne_end: if (vk) { |1: // EQ: Branch to the target. | movzx RD, PC_RD | branchPC RD |2: // NE: Fallthrough to next instruction. |.if not FFI |3: |.endif } else { |.if not FFI |3: |.endif |2: // NE: Branch to the target. | movzx RD, PC_RD | branchPC RD |1: // EQ: Fallthrough to next instruction. } if (LJ_DUALNUM && (op == BC_ISEQV || op == BC_ISNEV || op == BC_ISEQN || op == BC_ISNEN)) { | jmp <9 } else { | ins_next } | if (op == BC_ISEQV || op == BC_ISNEV) { |5: // Either or both types are not numbers. |.if FFI | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd | checktp RA, LJ_TCDATA; je ->vmeta_equal_cd |.endif | checktp RA, RB // Compare types. | jne <2 // Not the same type? | cmp RB, LJ_TISPRI | jae <1 // Same type and primitive type? | | // Same types and not a primitive type. Compare GCobj or pvalue. | mov RA, [BASE+RA*8] | mov RD, [BASE+RD*8] | cmp RA, RD | je <1 // Same GCobjs or pvalues? | cmp RB, LJ_TISTABUD | ja <2 // Different objects and not table/ud? |.if X64 | cmp RB, LJ_TUDATA // And not 64 bit lightuserdata. | jb <2 |.endif | | // Different tables or userdatas. Need to check __eq metamethod. | // Field metatable must be at same offset for GCtab and GCudata! | mov TAB:RB, TAB:RA->metatable | test TAB:RB, TAB:RB | jz <2 // No metatable? | test byte TAB:RB->nomm, 1<vmeta_equal // Handle __eq metamethod. } else { |.if FFI |3: | cmp RB, LJ_TCDATA if (LJ_DUALNUM && vk) { | jne <9 } else { | jne <2 } | jmp ->vmeta_equal_cd |.endif } break; case BC_ISEQS: case BC_ISNES: vk = op == BC_ISEQS; | ins_AND // RA = src, RD = str const, JMP with RD = target | mov RB, [BASE+RA*8+4] | add PC, 4 | cmp RB, LJ_TSTR; jne >3 | mov RA, [BASE+RA*8] | cmp RA, [KBASE+RD*4] iseqne_test: if (vk) { | jne >2 } else { | je >1 } goto iseqne_end; case BC_ISEQN: case BC_ISNEN: vk = op == BC_ISEQN; | ins_AD // RA = src, RD = num const, JMP with RD = target | mov RB, [BASE+RA*8+4] | add PC, 4 |.if DUALNUM | cmp RB, LJ_TISNUM; jne >7 | cmp dword [KBASE+RD*8+4], LJ_TISNUM; jne >8 | mov RB, dword [KBASE+RD*8] | cmp RB, dword [BASE+RA*8] if (vk) { | jne >9 } else { | je >9 } | movzx RD, PC_RD | branchPC RD |9: | ins_next | |7: // RA is not an integer. | ja >3 | // RA is a number. | cmp dword [KBASE+RD*8+4], LJ_TISNUM; jb >1 | // RA is a number, RD is an integer. |.if SSE | cvtsi2sd xmm0, dword [KBASE+RD*8] |.else | fild dword [KBASE+RD*8] |.endif | jmp >2 | |8: // RA is an integer, RD is a number. |.if SSE | cvtsi2sd xmm0, dword [BASE+RA*8] | ucomisd xmm0, qword [KBASE+RD*8] |.else | fild dword [BASE+RA*8] | fld qword [KBASE+RD*8] |.endif | jmp >4 |.else | cmp RB, LJ_TISNUM; jae >3 |.endif |.if SSE |1: | movsd xmm0, qword [KBASE+RD*8] |2: | ucomisd xmm0, qword [BASE+RA*8] |4: |.else |1: | fld qword [KBASE+RD*8] |2: | fld qword [BASE+RA*8] |4: | fcomparepp |.endif goto iseqne_fp; case BC_ISEQP: case BC_ISNEP: vk = op == BC_ISEQP; | ins_AND // RA = src, RD = primitive type (~), JMP with RD = target | mov RB, [BASE+RA*8+4] | add PC, 4 | cmp RB, RD if (!LJ_HASFFI) goto iseqne_test; if (vk) { | jne >3 | movzx RD, PC_RD | branchPC RD |2: | ins_next |3: | cmp RB, LJ_TCDATA; jne <2 | jmp ->vmeta_equal_cd } else { | je >2 | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd | movzx RD, PC_RD | branchPC RD |2: | ins_next } break; /* -- Unary test and copy ops ------------------------------------------- */ case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: | ins_AD // RA = dst or unused, RD = src, JMP with RD = target | mov RB, [BASE+RD*8+4] | add PC, 4 | cmp RB, LJ_TISTRUECOND if (op == BC_IST || op == BC_ISTC) { | jae >1 } else { | jb >1 } if (op == BC_ISTC || op == BC_ISFC) { | mov [BASE+RA*8+4], RB | mov RB, [BASE+RD*8] | mov [BASE+RA*8], RB } | movzx RD, PC_RD | branchPC RD |1: // Fallthrough to the next instruction. | ins_next break; /* -- Unary ops --------------------------------------------------------- */ case BC_MOV: | ins_AD // RA = dst, RD = src |.if X64 | mov RBa, [BASE+RD*8] | mov [BASE+RA*8], RBa |.else | mov RB, [BASE+RD*8+4] | mov RD, [BASE+RD*8] | mov [BASE+RA*8+4], RB | mov [BASE+RA*8], RD |.endif | ins_next_ break; case BC_NOT: | ins_AD // RA = dst, RD = src | xor RB, RB | checktp RD, LJ_TISTRUECOND | adc RB, LJ_TTRUE | mov [BASE+RA*8+4], RB | ins_next break; case BC_UNM: | ins_AD // RA = dst, RD = src |.if DUALNUM | checkint RD, >5 | mov RB, [BASE+RD*8] | neg RB | jo >4 | mov dword [BASE+RA*8+4], LJ_TISNUM | mov dword [BASE+RA*8], RB |9: | ins_next |4: | mov dword [BASE+RA*8+4], 0x41e00000 // 2^31. | mov dword [BASE+RA*8], 0 | jmp <9 |5: | ja ->vmeta_unm |.else | checknum RD, ->vmeta_unm |.endif |.if SSE | movsd xmm0, qword [BASE+RD*8] | sseconst_sign xmm1, RDa | xorps xmm0, xmm1 | movsd qword [BASE+RA*8], xmm0 |.else | fld qword [BASE+RD*8] | fchs | fstp qword [BASE+RA*8] |.endif |.if DUALNUM | jmp <9 |.else | ins_next |.endif break; case BC_LEN: | ins_AD // RA = dst, RD = src | checkstr RD, >2 | mov STR:RD, [BASE+RD*8] |.if DUALNUM | mov RD, dword STR:RD->len |1: | mov dword [BASE+RA*8+4], LJ_TISNUM | mov dword [BASE+RA*8], RD |.elif SSE | xorps xmm0, xmm0 | cvtsi2sd xmm0, dword STR:RD->len |1: | movsd qword [BASE+RA*8], xmm0 |.else | fild dword STR:RD->len |1: | fstp qword [BASE+RA*8] |.endif | ins_next |2: | checktab RD, ->vmeta_len | mov TAB:FCARG1, [BASE+RD*8] #if LJ_52 | mov TAB:RB, TAB:FCARG1->metatable | cmp TAB:RB, 0 | jnz >9 |3: #endif |->BC_LEN_Z: | mov RB, BASE // Save BASE. | call extern lj_tab_len@4 // (GCtab *t) | // Length of table returned in eax (RD). |.if DUALNUM | // Nothing to do. |.elif SSE | cvtsi2sd xmm0, RD |.else | mov ARG1, RD | fild ARG1 |.endif | mov BASE, RB // Restore BASE. | movzx RA, PC_RA | jmp <1 #if LJ_52 |9: // Check for __len. | test byte TAB:RB->nomm, 1<vmeta_len // 'no __len' flag NOT set: check. #endif break; /* -- Binary ops -------------------------------------------------------- */ |.macro ins_arithpre, x87ins, sseins, ssereg | ins_ABC ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); ||switch (vk) { ||case 0: | checknum RB, ->vmeta_arith_vn | .if DUALNUM | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jae ->vmeta_arith_vn | .endif | .if SSE | movsd xmm0, qword [BASE+RB*8] | sseins ssereg, qword [KBASE+RC*8] | .else | fld qword [BASE+RB*8] | x87ins qword [KBASE+RC*8] | .endif || break; ||case 1: | checknum RB, ->vmeta_arith_nv | .if DUALNUM | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jae ->vmeta_arith_nv | .endif | .if SSE | movsd xmm0, qword [KBASE+RC*8] | sseins ssereg, qword [BASE+RB*8] | .else | fld qword [KBASE+RC*8] | x87ins qword [BASE+RB*8] | .endif || break; ||default: | checknum RB, ->vmeta_arith_vv | checknum RC, ->vmeta_arith_vv | .if SSE | movsd xmm0, qword [BASE+RB*8] | sseins ssereg, qword [BASE+RC*8] | .else | fld qword [BASE+RB*8] | x87ins qword [BASE+RC*8] | .endif || break; ||} |.endmacro | |.macro ins_arithdn, intins | ins_ABC ||vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); ||switch (vk) { ||case 0: | checkint RB, ->vmeta_arith_vn | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jne ->vmeta_arith_vn | mov RB, [BASE+RB*8] | intins RB, [KBASE+RC*8]; jo ->vmeta_arith_vno || break; ||case 1: | checkint RB, ->vmeta_arith_nv | cmp dword [KBASE+RC*8+4], LJ_TISNUM; jne ->vmeta_arith_nv | mov RC, [KBASE+RC*8] | intins RC, [BASE+RB*8]; jo ->vmeta_arith_nvo || break; ||default: | checkint RB, ->vmeta_arith_vv | checkint RC, ->vmeta_arith_vv | mov RB, [BASE+RB*8] | intins RB, [BASE+RC*8]; jo ->vmeta_arith_vvo || break; ||} | mov dword [BASE+RA*8+4], LJ_TISNUM ||if (vk == 1) { | mov dword [BASE+RA*8], RC ||} else { | mov dword [BASE+RA*8], RB ||} | ins_next |.endmacro | |.macro ins_arithpost |.if SSE | movsd qword [BASE+RA*8], xmm0 |.else | fstp qword [BASE+RA*8] |.endif |.endmacro | |.macro ins_arith, x87ins, sseins | ins_arithpre x87ins, sseins, xmm0 | ins_arithpost | ins_next |.endmacro | |.macro ins_arith, intins, x87ins, sseins |.if DUALNUM | ins_arithdn intins |.else | ins_arith, x87ins, sseins |.endif |.endmacro | // RA = dst, RB = src1 or num const, RC = src2 or num const case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: | ins_arith add, fadd, addsd break; case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: | ins_arith sub, fsub, subsd break; case BC_MULVN: case BC_MULNV: case BC_MULVV: | ins_arith imul, fmul, mulsd break; case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: | ins_arith fdiv, divsd break; case BC_MODVN: | ins_arithpre fld, movsd, xmm1 |->BC_MODVN_Z: | call ->vm_mod | ins_arithpost | ins_next break; case BC_MODNV: case BC_MODVV: | ins_arithpre fld, movsd, xmm1 | jmp ->BC_MODVN_Z // Avoid 3 copies. It's slow anyway. break; case BC_POW: | ins_arithpre fld, movsd, xmm1 | call ->vm_pow | ins_arithpost | ins_next break; case BC_CAT: | ins_ABC // RA = dst, RB = src_start, RC = src_end |.if X64 | mov L:CARG1d, SAVE_L | mov L:CARG1d->base, BASE | lea CARG2d, [BASE+RC*8] | mov CARG3d, RC | sub CARG3d, RB |->BC_CAT_Z: | mov L:RB, L:CARG1d |.else | lea RA, [BASE+RC*8] | sub RC, RB | mov ARG2, RA | mov ARG3, RC |->BC_CAT_Z: | mov L:RB, SAVE_L | mov ARG1, L:RB | mov L:RB->base, BASE |.endif | mov SAVE_PC, PC | call extern lj_meta_cat // (lua_State *L, TValue *top, int left) | // NULL (finished) or TValue * (metamethod) returned in eax (RC). | mov BASE, L:RB->base | test RC, RC | jnz ->vmeta_binop | movzx RB, PC_RB // Copy result to Stk[RA] from Stk[RB]. | movzx RA, PC_RA |.if X64 | mov RCa, [BASE+RB*8] | mov [BASE+RA*8], RCa |.else | mov RC, [BASE+RB*8+4] | mov RB, [BASE+RB*8] | mov [BASE+RA*8+4], RC | mov [BASE+RA*8], RB |.endif | ins_next break; /* -- Constant ops ------------------------------------------------------ */ case BC_KSTR: | ins_AND // RA = dst, RD = str const (~) | mov RD, [KBASE+RD*4] | mov dword [BASE+RA*8+4], LJ_TSTR | mov [BASE+RA*8], RD | ins_next break; case BC_KCDATA: |.if FFI | ins_AND // RA = dst, RD = cdata const (~) | mov RD, [KBASE+RD*4] | mov dword [BASE+RA*8+4], LJ_TCDATA | mov [BASE+RA*8], RD | ins_next |.endif break; case BC_KSHORT: | ins_AD // RA = dst, RD = signed int16 literal |.if DUALNUM | movsx RD, RDW | mov dword [BASE+RA*8+4], LJ_TISNUM | mov dword [BASE+RA*8], RD |.elif SSE | movsx RD, RDW // Sign-extend literal. | cvtsi2sd xmm0, RD | movsd qword [BASE+RA*8], xmm0 |.else | fild PC_RD // Refetch signed RD from instruction. | fstp qword [BASE+RA*8] |.endif | ins_next break; case BC_KNUM: | ins_AD // RA = dst, RD = num const |.if SSE | movsd xmm0, qword [KBASE+RD*8] | movsd qword [BASE+RA*8], xmm0 |.else | fld qword [KBASE+RD*8] | fstp qword [BASE+RA*8] |.endif | ins_next break; case BC_KPRI: | ins_AND // RA = dst, RD = primitive type (~) | mov [BASE+RA*8+4], RD | ins_next break; case BC_KNIL: | ins_AD // RA = dst_start, RD = dst_end | lea RA, [BASE+RA*8+12] | lea RD, [BASE+RD*8+4] | mov RB, LJ_TNIL | mov [RA-8], RB // Sets minimum 2 slots. |1: | mov [RA], RB | add RA, 8 | cmp RA, RD | jbe <1 | ins_next break; /* -- Upvalue and function ops ------------------------------------------ */ case BC_UGET: | ins_AD // RA = dst, RD = upvalue # | mov LFUNC:RB, [BASE-8] | mov UPVAL:RB, [LFUNC:RB+RD*4+offsetof(GCfuncL, uvptr)] | mov RB, UPVAL:RB->v |.if X64 | mov RDa, [RB] | mov [BASE+RA*8], RDa |.else | mov RD, [RB+4] | mov RB, [RB] | mov [BASE+RA*8+4], RD | mov [BASE+RA*8], RB |.endif | ins_next break; case BC_USETV: #define TV2MARKOFS \ ((int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)) | ins_AD // RA = upvalue #, RD = src | mov LFUNC:RB, [BASE-8] | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] | cmp byte UPVAL:RB->closed, 0 | mov RB, UPVAL:RB->v | mov RA, [BASE+RD*8] | mov RD, [BASE+RD*8+4] | mov [RB], RA | mov [RB+4], RD | jz >1 | // Check barrier for closed upvalue. | test byte [RB+TV2MARKOFS], LJ_GC_BLACK // isblack(uv) | jnz >2 |1: | ins_next | |2: // Upvalue is black. Check if new value is collectable and white. | sub RD, LJ_TISGCV | cmp RD, LJ_TISNUM - LJ_TISGCV // tvisgcv(v) | jbe <1 | test byte GCOBJ:RA->gch.marked, LJ_GC_WHITES // iswhite(v) | jz <1 | // Crossed a write barrier. Move the barrier forward. |.if X64 and not X64WIN | mov FCARG2, RB | mov RB, BASE // Save BASE. |.else | xchg FCARG2, RB // Save BASE (FCARG2 == BASE). |.endif | lea GL:FCARG1, [DISPATCH+GG_DISP2G] | call extern lj_gc_barrieruv@8 // (global_State *g, TValue *tv) | mov BASE, RB // Restore BASE. | jmp <1 break; #undef TV2MARKOFS case BC_USETS: | ins_AND // RA = upvalue #, RD = str const (~) | mov LFUNC:RB, [BASE-8] | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] | mov GCOBJ:RA, [KBASE+RD*4] | mov RD, UPVAL:RB->v | mov [RD], GCOBJ:RA | mov dword [RD+4], LJ_TSTR | test byte UPVAL:RB->marked, LJ_GC_BLACK // isblack(uv) | jnz >2 |1: | ins_next | |2: // Check if string is white and ensure upvalue is closed. | test byte GCOBJ:RA->gch.marked, LJ_GC_WHITES // iswhite(str) | jz <1 | cmp byte UPVAL:RB->closed, 0 | jz <1 | // Crossed a write barrier. Move the barrier forward. | mov RB, BASE // Save BASE (FCARG2 == BASE). | mov FCARG2, RD | lea GL:FCARG1, [DISPATCH+GG_DISP2G] | call extern lj_gc_barrieruv@8 // (global_State *g, TValue *tv) | mov BASE, RB // Restore BASE. | jmp <1 break; case BC_USETN: | ins_AD // RA = upvalue #, RD = num const | mov LFUNC:RB, [BASE-8] |.if SSE | movsd xmm0, qword [KBASE+RD*8] |.else | fld qword [KBASE+RD*8] |.endif | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] | mov RA, UPVAL:RB->v |.if SSE | movsd qword [RA], xmm0 |.else | fstp qword [RA] |.endif | ins_next break; case BC_USETP: | ins_AND // RA = upvalue #, RD = primitive type (~) | mov LFUNC:RB, [BASE-8] | mov UPVAL:RB, [LFUNC:RB+RA*4+offsetof(GCfuncL, uvptr)] | mov RA, UPVAL:RB->v | mov [RA+4], RD | ins_next break; case BC_UCLO: | ins_AD // RA = level, RD = target | branchPC RD // Do this first to free RD. | mov L:RB, SAVE_L | cmp dword L:RB->openupval, 0 | je >1 | mov L:RB->base, BASE | lea FCARG2, [BASE+RA*8] // Caveat: FCARG2 == BASE | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA | call extern lj_func_closeuv@8 // (lua_State *L, TValue *level) | mov BASE, L:RB->base |1: | ins_next break; case BC_FNEW: | ins_AND // RA = dst, RD = proto const (~) (holding function prototype) |.if X64 | mov L:RB, SAVE_L | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | mov CARG3d, [BASE-8] | mov CARG2d, [KBASE+RD*4] // Fetch GCproto *. | mov CARG1d, L:RB |.else | mov LFUNC:RA, [BASE-8] | mov PROTO:RD, [KBASE+RD*4] // Fetch GCproto *. | mov L:RB, SAVE_L | mov ARG3, LFUNC:RA | mov ARG2, PROTO:RD | mov ARG1, L:RB | mov L:RB->base, BASE |.endif | mov SAVE_PC, PC | // (lua_State *L, GCproto *pt, GCfuncL *parent) | call extern lj_func_newL_gc | // GCfuncL * returned in eax (RC). | mov BASE, L:RB->base | movzx RA, PC_RA | mov [BASE+RA*8], LFUNC:RC | mov dword [BASE+RA*8+4], LJ_TFUNC | ins_next break; /* -- Table ops --------------------------------------------------------- */ case BC_TNEW: | ins_AD // RA = dst, RD = hbits|asize | mov L:RB, SAVE_L | mov L:RB->base, BASE | mov RA, [DISPATCH+DISPATCH_GL(gc.total)] | cmp RA, [DISPATCH+DISPATCH_GL(gc.threshold)] | mov SAVE_PC, PC | jae >5 |1: |.if X64 | mov CARG3d, RD | and RD, 0x7ff | shr CARG3d, 11 |.else | mov RA, RD | and RD, 0x7ff | shr RA, 11 | mov ARG3, RA |.endif | cmp RD, 0x7ff | je >3 |2: |.if X64 | mov L:CARG1d, L:RB | mov CARG2d, RD |.else | mov ARG1, L:RB | mov ARG2, RD |.endif | call extern lj_tab_new // (lua_State *L, int32_t asize, uint32_t hbits) | // Table * returned in eax (RC). | mov BASE, L:RB->base | movzx RA, PC_RA | mov [BASE+RA*8], TAB:RC | mov dword [BASE+RA*8+4], LJ_TTAB | ins_next |3: // Turn 0x7ff into 0x801. | mov RD, 0x801 | jmp <2 |5: | mov L:FCARG1, L:RB | call extern lj_gc_step_fixtop@4 // (lua_State *L) | movzx RD, PC_RD | jmp <1 break; case BC_TDUP: | ins_AND // RA = dst, RD = table const (~) (holding template table) | mov L:RB, SAVE_L | mov RA, [DISPATCH+DISPATCH_GL(gc.total)] | mov SAVE_PC, PC | cmp RA, [DISPATCH+DISPATCH_GL(gc.threshold)] | mov L:RB->base, BASE | jae >3 |2: | mov TAB:FCARG2, [KBASE+RD*4] // Caveat: FCARG2 == BASE | mov L:FCARG1, L:RB // Caveat: FCARG1 == RA | call extern lj_tab_dup@8 // (lua_State *L, Table *kt) | // Table * returned in eax (RC). | mov BASE, L:RB->base | movzx RA, PC_RA | mov [BASE+RA*8], TAB:RC | mov dword [BASE+RA*8+4], LJ_TTAB | ins_next |3: | mov L:FCARG1, L:RB | call extern lj_gc_step_fixtop@4 // (lua_State *L) | movzx RD, PC_RD // Need to reload RD. | not RDa | jmp <2 break; case BC_GGET: | ins_AND // RA = dst, RD = str const (~) | mov LFUNC:RB, [BASE-8] | mov TAB:RB, LFUNC:RB->env | mov STR:RC, [KBASE+RD*4] | jmp ->BC_TGETS_Z break; case BC_GSET: | ins_AND // RA = src, RD = str const (~) | mov LFUNC:RB, [BASE-8] | mov TAB:RB, LFUNC:RB->env | mov STR:RC, [KBASE+RD*4] | jmp ->BC_TSETS_Z break; case BC_TGETV: | ins_ABC // RA = dst, RB = table, RC = key | checktab RB, ->vmeta_tgetv | mov TAB:RB, [BASE+RB*8] | | // Integer key? |.if DUALNUM | checkint RC, >5 | mov RC, dword [BASE+RC*8] |.else | // Convert number to int and back and compare. | checknum RC, >5 |.if SSE | movsd xmm0, qword [BASE+RC*8] | cvtsd2si RC, xmm0 | cvtsi2sd xmm1, RC | ucomisd xmm0, xmm1 |.else | fld qword [BASE+RC*8] | fist ARG1 | fild ARG1 | fcomparepp | mov RC, ARG1 |.endif | jne ->vmeta_tgetv // Generic numeric key? Use fallback. |.endif | cmp RC, TAB:RB->asize // Takes care of unordered, too. | jae ->vmeta_tgetv // Not in array part? Use fallback. | shl RC, 3 | add RC, TAB:RB->array | cmp dword [RC+4], LJ_TNIL // Avoid overwriting RB in fastpath. | je >2 | // Get array slot. |.if X64 | mov RBa, [RC] | mov [BASE+RA*8], RBa |.else | mov RB, [RC] | mov RC, [RC+4] | mov [BASE+RA*8], RB | mov [BASE+RA*8+4], RC |.endif |1: | ins_next | |2: // Check for __index if table value is nil. | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. | jz >3 | mov TAB:RA, TAB:RB->metatable | test byte TAB:RA->nomm, 1<vmeta_tgetv // 'no __index' flag NOT set: check. | movzx RA, PC_RA // Restore RA. |3: | mov dword [BASE+RA*8+4], LJ_TNIL | jmp <1 | |5: // String key? | checkstr RC, ->vmeta_tgetv | mov STR:RC, [BASE+RC*8] | jmp ->BC_TGETS_Z break; case BC_TGETS: | ins_ABC // RA = dst, RB = table, RC = str const (~) | not RCa | mov STR:RC, [KBASE+RC*4] | checktab RB, ->vmeta_tgets | mov TAB:RB, [BASE+RB*8] |->BC_TGETS_Z: // RB = GCtab *, RC = GCstr *, refetches PC_RA. | mov RA, TAB:RB->hmask | and RA, STR:RC->hash | imul RA, #NODE | add NODE:RA, TAB:RB->node |1: | cmp dword NODE:RA->key.it, LJ_TSTR | jne >4 | cmp dword NODE:RA->key.gcr, STR:RC | jne >4 | // Ok, key found. Assumes: offsetof(Node, val) == 0 | cmp dword [RA+4], LJ_TNIL // Avoid overwriting RB in fastpath. | je >5 // Key found, but nil value? | movzx RC, PC_RA | // Get node value. |.if X64 | mov RBa, [RA] | mov [BASE+RC*8], RBa |.else | mov RB, [RA] | mov RA, [RA+4] | mov [BASE+RC*8], RB | mov [BASE+RC*8+4], RA |.endif |2: | ins_next | |3: | movzx RC, PC_RA | mov dword [BASE+RC*8+4], LJ_TNIL | jmp <2 | |4: // Follow hash chain. | mov NODE:RA, NODE:RA->next | test NODE:RA, NODE:RA | jnz <1 | // End of hash chain: key not found, nil result. | |5: // Check for __index if table value is nil. | mov TAB:RA, TAB:RB->metatable | test TAB:RA, TAB:RA | jz <3 // No metatable: done. | test byte TAB:RA->nomm, 1<vmeta_tgets // Caveat: preserve STR:RC. break; case BC_TGETB: | ins_ABC // RA = dst, RB = table, RC = byte literal | checktab RB, ->vmeta_tgetb | mov TAB:RB, [BASE+RB*8] | cmp RC, TAB:RB->asize | jae ->vmeta_tgetb | shl RC, 3 | add RC, TAB:RB->array | cmp dword [RC+4], LJ_TNIL // Avoid overwriting RB in fastpath. | je >2 | // Get array slot. |.if X64 | mov RBa, [RC] | mov [BASE+RA*8], RBa |.else | mov RB, [RC] | mov RC, [RC+4] | mov [BASE+RA*8], RB | mov [BASE+RA*8+4], RC |.endif |1: | ins_next | |2: // Check for __index if table value is nil. | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. | jz >3 | mov TAB:RA, TAB:RB->metatable | test byte TAB:RA->nomm, 1<vmeta_tgetb // 'no __index' flag NOT set: check. | movzx RA, PC_RA // Restore RA. |3: | mov dword [BASE+RA*8+4], LJ_TNIL | jmp <1 break; case BC_TSETV: | ins_ABC // RA = src, RB = table, RC = key | checktab RB, ->vmeta_tsetv | mov TAB:RB, [BASE+RB*8] | | // Integer key? |.if DUALNUM | checkint RC, >5 | mov RC, dword [BASE+RC*8] |.else | // Convert number to int and back and compare. | checknum RC, >5 |.if SSE | movsd xmm0, qword [BASE+RC*8] | cvtsd2si RC, xmm0 | cvtsi2sd xmm1, RC | ucomisd xmm0, xmm1 |.else | fld qword [BASE+RC*8] | fist ARG1 | fild ARG1 | fcomparepp | mov RC, ARG1 |.endif | jne ->vmeta_tsetv // Generic numeric key? Use fallback. |.endif | cmp RC, TAB:RB->asize // Takes care of unordered, too. | jae ->vmeta_tsetv | shl RC, 3 | add RC, TAB:RB->array | cmp dword [RC+4], LJ_TNIL | je >3 // Previous value is nil? |1: | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) | jnz >7 |2: // Set array slot. |.if X64 | mov RBa, [BASE+RA*8] | mov [RC], RBa |.else | mov RB, [BASE+RA*8+4] | mov RA, [BASE+RA*8] | mov [RC+4], RB | mov [RC], RA |.endif | ins_next | |3: // Check for __newindex if previous value is nil. | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. | jz <1 | mov TAB:RA, TAB:RB->metatable | test byte TAB:RA->nomm, 1<vmeta_tsetv // 'no __newindex' flag NOT set: check. | movzx RA, PC_RA // Restore RA. | jmp <1 | |5: // String key? | checkstr RC, ->vmeta_tsetv | mov STR:RC, [BASE+RC*8] | jmp ->BC_TSETS_Z | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, RA | movzx RA, PC_RA // Restore RA. | jmp <2 break; case BC_TSETS: | ins_ABC // RA = src, RB = table, RC = str const (~) | not RCa | mov STR:RC, [KBASE+RC*4] | checktab RB, ->vmeta_tsets | mov TAB:RB, [BASE+RB*8] |->BC_TSETS_Z: // RB = GCtab *, RC = GCstr *, refetches PC_RA. | mov RA, TAB:RB->hmask | and RA, STR:RC->hash | imul RA, #NODE | mov byte TAB:RB->nomm, 0 // Clear metamethod cache. | add NODE:RA, TAB:RB->node |1: | cmp dword NODE:RA->key.it, LJ_TSTR | jne >5 | cmp dword NODE:RA->key.gcr, STR:RC | jne >5 | // Ok, key found. Assumes: offsetof(Node, val) == 0 | cmp dword [RA+4], LJ_TNIL | je >4 // Previous value is nil? |2: | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) | jnz >7 |3: // Set node value. | movzx RC, PC_RA |.if X64 | mov RBa, [BASE+RC*8] | mov [RA], RBa |.else | mov RB, [BASE+RC*8+4] | mov RC, [BASE+RC*8] | mov [RA+4], RB | mov [RA], RC |.endif | ins_next | |4: // Check for __newindex if previous value is nil. | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. | jz <2 | mov TMP1, RA // Save RA. | mov TAB:RA, TAB:RB->metatable | test byte TAB:RA->nomm, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. | mov RA, TMP1 // Restore RA. | jmp <2 | |5: // Follow hash chain. | mov NODE:RA, NODE:RA->next | test NODE:RA, NODE:RA | jnz <1 | // End of hash chain: key not found, add a new one. | | // But check for __newindex first. | mov TAB:RA, TAB:RB->metatable | test TAB:RA, TAB:RA | jz >6 // No metatable: continue. | test byte TAB:RA->nomm, 1<vmeta_tsets // 'no __newindex' flag NOT set: check. |6: | mov TMP1, STR:RC | mov TMP2, LJ_TSTR | mov TMP3, TAB:RB // Save TAB:RB for us. |.if X64 | mov L:CARG1d, SAVE_L | mov L:CARG1d->base, BASE | lea CARG3, TMP1 | mov CARG2d, TAB:RB | mov L:RB, L:CARG1d |.else | lea RC, TMP1 // Store temp. TValue in TMP1/TMP2. | mov ARG2, TAB:RB | mov L:RB, SAVE_L | mov ARG3, RC | mov ARG1, L:RB | mov L:RB->base, BASE |.endif | mov SAVE_PC, PC | call extern lj_tab_newkey // (lua_State *L, GCtab *t, TValue *k) | // Handles write barrier for the new key. TValue * returned in eax (RC). | mov BASE, L:RB->base | mov TAB:RB, TMP3 // Need TAB:RB for barrier. | mov RA, eax | jmp <2 // Must check write barrier for value. | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, RC // Destroys STR:RC. | jmp <3 break; case BC_TSETB: | ins_ABC // RA = src, RB = table, RC = byte literal | checktab RB, ->vmeta_tsetb | mov TAB:RB, [BASE+RB*8] | cmp RC, TAB:RB->asize | jae ->vmeta_tsetb | shl RC, 3 | add RC, TAB:RB->array | cmp dword [RC+4], LJ_TNIL | je >3 // Previous value is nil? |1: | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) | jnz >7 |2: // Set array slot. |.if X64 | mov RAa, [BASE+RA*8] | mov [RC], RAa |.else | mov RB, [BASE+RA*8+4] | mov RA, [BASE+RA*8] | mov [RC+4], RB | mov [RC], RA |.endif | ins_next | |3: // Check for __newindex if previous value is nil. | cmp dword TAB:RB->metatable, 0 // Shouldn't overwrite RA for fastpath. | jz <1 | mov TAB:RA, TAB:RB->metatable | test byte TAB:RA->nomm, 1<vmeta_tsetb // 'no __newindex' flag NOT set: check. | movzx RA, PC_RA // Restore RA. | jmp <1 | |7: // Possible table write barrier for the value. Skip valiswhite check. | barrierback TAB:RB, RA | movzx RA, PC_RA // Restore RA. | jmp <2 break; case BC_TSETM: | ins_AD // RA = base (table at base-1), RD = num const (start index) | mov TMP1, KBASE // Need one more free register. | mov KBASE, dword [KBASE+RD*8] // Integer constant is in lo-word. |1: | lea RA, [BASE+RA*8] | mov TAB:RB, [RA-8] // Guaranteed to be a table. | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table) | jnz >7 |2: | mov RD, MULTRES | sub RD, 1 | jz >4 // Nothing to copy? | add RD, KBASE // Compute needed size. | cmp RD, TAB:RB->asize | ja >5 // Doesn't fit into array part? | sub RD, KBASE | shl KBASE, 3 | add KBASE, TAB:RB->array |3: // Copy result slots to table. |.if X64 | mov RBa, [RA] | add RA, 8 | mov [KBASE], RBa |.else | mov RB, [RA] | mov [KBASE], RB | mov RB, [RA+4] | add RA, 8 | mov [KBASE+4], RB |.endif | add KBASE, 8 | sub RD, 1 | jnz <3 |4: | mov KBASE, TMP1 | ins_next | |5: // Need to resize array part. |.if X64 | mov L:CARG1d, SAVE_L | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | mov CARG2d, TAB:RB | mov CARG3d, RD | mov L:RB, L:CARG1d |.else | mov ARG2, TAB:RB | mov L:RB, SAVE_L | mov L:RB->base, BASE | mov ARG3, RD | mov ARG1, L:RB |.endif | mov SAVE_PC, PC | call extern lj_tab_reasize // (lua_State *L, GCtab *t, int nasize) | mov BASE, L:RB->base | movzx RA, PC_RA // Restore RA. | jmp <1 // Retry. | |7: // Possible table write barrier for any value. Skip valiswhite check. | barrierback TAB:RB, RD | jmp <2 break; /* -- Calls and vararg handling ----------------------------------------- */ case BC_CALL: case BC_CALLM: | ins_A_C // RA = base, (RB = nresults+1,) RC = nargs+1 | extra_nargs if (op == BC_CALLM) { | add NARGS:RD, MULTRES } | cmp dword [BASE+RA*8+4], LJ_TFUNC | mov LFUNC:RB, [BASE+RA*8] | jne ->vmeta_call_ra | lea BASE, [BASE+RA*8+8] | ins_call break; case BC_CALLMT: | ins_AD // RA = base, RD = extra_nargs | add NARGS:RD, MULTRES | // Fall through. Assumes BC_CALLT follows and ins_AD is a no-op. break; case BC_CALLT: | ins_AD // RA = base, RD = nargs+1 | lea RA, [BASE+RA*8+8] | mov KBASE, BASE // Use KBASE for move + vmeta_call hint. | mov LFUNC:RB, [RA-8] | cmp dword [RA-4], LJ_TFUNC | jne ->vmeta_call |->BC_CALLT_Z: | mov PC, [BASE-4] | test PC, FRAME_TYPE | jnz >7 |1: | mov [BASE-8], LFUNC:RB // Copy function down, reloaded below. | mov MULTRES, NARGS:RD | sub NARGS:RD, 1 | jz >3 |2: // Move args down. |.if X64 | mov RBa, [RA] | add RA, 8 | mov [KBASE], RBa |.else | mov RB, [RA] | mov [KBASE], RB | mov RB, [RA+4] | add RA, 8 | mov [KBASE+4], RB |.endif | add KBASE, 8 | sub NARGS:RD, 1 | jnz <2 | | mov LFUNC:RB, [BASE-8] |3: | mov NARGS:RD, MULTRES | cmp byte LFUNC:RB->ffid, 1 // (> FF_C) Calling a fast function? | ja >5 |4: | ins_callt | |5: // Tailcall to a fast function. | test PC, FRAME_TYPE // Lua frame below? | jnz <4 | movzx RA, PC_RA | not RAa | lea RA, [BASE+RA*8] | mov LFUNC:KBASE, [RA-8] // Need to prepare KBASE. | mov KBASE, LFUNC:KBASE->pc | mov KBASE, [KBASE+PC2PROTO(k)] | jmp <4 | |7: // Tailcall from a vararg function. | sub PC, FRAME_VARG | test PC, FRAME_TYPEP | jnz >8 // Vararg frame below? | sub BASE, PC // Need to relocate BASE/KBASE down. | mov KBASE, BASE | mov PC, [BASE-4] | jmp <1 |8: | add PC, FRAME_VARG | jmp <1 break; case BC_ITERC: | ins_A // RA = base, (RB = nresults+1,) RC = nargs+1 (2+1) | lea RA, [BASE+RA*8+8] // fb = base+1 |.if X64 | mov RBa, [RA-24] // Copy state. fb[0] = fb[-3]. | mov RCa, [RA-16] // Copy control var. fb[1] = fb[-2]. | mov [RA], RBa | mov [RA+8], RCa |.else | mov RB, [RA-24] // Copy state. fb[0] = fb[-3]. | mov RC, [RA-20] | mov [RA], RB | mov [RA+4], RC | mov RB, [RA-16] // Copy control var. fb[1] = fb[-2]. | mov RC, [RA-12] | mov [RA+8], RB | mov [RA+12], RC |.endif | mov LFUNC:RB, [RA-32] // Copy callable. fb[-1] = fb[-4] | mov RC, [RA-28] | mov [RA-8], LFUNC:RB | mov [RA-4], RC | cmp RC, LJ_TFUNC // Handle like a regular 2-arg call. | mov NARGS:RD, 2+1 | jne ->vmeta_call | mov BASE, RA | ins_call break; case BC_ITERN: | ins_A // RA = base, (RB = nresults+1, RC = nargs+1 (2+1)) |.if JIT | // NYI: add hotloop, record BC_ITERN. |.endif | mov TMP1, KBASE // Need two more free registers. | mov TMP2, DISPATCH | mov TAB:RB, [BASE+RA*8-16] | mov RC, [BASE+RA*8-8] // Get index from control var. | mov DISPATCH, TAB:RB->asize | add PC, 4 | mov KBASE, TAB:RB->array |1: // Traverse array part. | cmp RC, DISPATCH; jae >5 // Index points after array part? | cmp dword [KBASE+RC*8+4], LJ_TNIL; je >4 |.if DUALNUM | mov dword [BASE+RA*8+4], LJ_TISNUM | mov dword [BASE+RA*8], RC |.elif SSE | cvtsi2sd xmm0, RC |.else | fild dword [BASE+RA*8-8] |.endif | // Copy array slot to returned value. |.if X64 | mov RBa, [KBASE+RC*8] | mov [BASE+RA*8+8], RBa |.else | mov RB, [KBASE+RC*8+4] | mov [BASE+RA*8+12], RB | mov RB, [KBASE+RC*8] | mov [BASE+RA*8+8], RB |.endif | add RC, 1 | // Return array index as a numeric key. |.if DUALNUM | // See above. |.elif SSE | movsd qword [BASE+RA*8], xmm0 |.else | fstp qword [BASE+RA*8] |.endif | mov [BASE+RA*8-8], RC // Update control var. |2: | movzx RD, PC_RD // Get target from ITERL. | branchPC RD |3: | mov DISPATCH, TMP2 | mov KBASE, TMP1 | ins_next | |4: // Skip holes in array part. | add RC, 1 |.if not (DUALNUM or SSE) | mov [BASE+RA*8-8], RC |.endif | jmp <1 | |5: // Traverse hash part. | sub RC, DISPATCH |6: | cmp RC, TAB:RB->hmask; ja <3 // End of iteration? Branch to ITERL+1. | imul KBASE, RC, #NODE | add NODE:KBASE, TAB:RB->node | cmp dword NODE:KBASE->val.it, LJ_TNIL; je >7 | lea DISPATCH, [RC+DISPATCH+1] | // Copy key and value from hash slot. |.if X64 | mov RBa, NODE:KBASE->key | mov RCa, NODE:KBASE->val | mov [BASE+RA*8], RBa | mov [BASE+RA*8+8], RCa |.else | mov RB, NODE:KBASE->key.gcr | mov RC, NODE:KBASE->key.it | mov [BASE+RA*8], RB | mov [BASE+RA*8+4], RC | mov RB, NODE:KBASE->val.gcr | mov RC, NODE:KBASE->val.it | mov [BASE+RA*8+8], RB | mov [BASE+RA*8+12], RC |.endif | mov [BASE+RA*8-8], DISPATCH | jmp <2 | |7: // Skip holes in hash part. | add RC, 1 | jmp <6 break; case BC_ISNEXT: | ins_AD // RA = base, RD = target (points to ITERN) | cmp dword [BASE+RA*8-20], LJ_TFUNC; jne >5 | mov CFUNC:RB, [BASE+RA*8-24] | cmp dword [BASE+RA*8-12], LJ_TTAB; jne >5 | cmp dword [BASE+RA*8-4], LJ_TNIL; jne >5 | cmp byte CFUNC:RB->ffid, FF_next_N; jne >5 | branchPC RD | mov dword [BASE+RA*8-8], 0 // Initialize control var. | mov dword [BASE+RA*8-4], 0xfffe7fff |1: | ins_next |5: // Despecialize bytecode if any of the checks fail. | mov PC_OP, BC_JMP | branchPC RD | mov byte [PC], BC_ITERC | jmp <1 break; case BC_VARG: | ins_ABC // RA = base, RB = nresults+1, RC = numparams | mov TMP1, KBASE // Need one more free register. | lea KBASE, [BASE+RC*8+(8+FRAME_VARG)] | lea RA, [BASE+RA*8] | sub KBASE, [BASE-4] | // Note: KBASE may now be even _above_ BASE if nargs was < numparams. | test RB, RB | jz >5 // Copy all varargs? | lea RB, [RA+RB*8-8] | cmp KBASE, BASE // No vararg slots? | jnb >2 |1: // Copy vararg slots to destination slots. |.if X64 | mov RCa, [KBASE-8] | add KBASE, 8 | mov [RA], RCa |.else | mov RC, [KBASE-8] | mov [RA], RC | mov RC, [KBASE-4] | add KBASE, 8 | mov [RA+4], RC |.endif | add RA, 8 | cmp RA, RB // All destination slots filled? | jnb >3 | cmp KBASE, BASE // No more vararg slots? | jb <1 |2: // Fill up remainder with nil. | mov dword [RA+4], LJ_TNIL | add RA, 8 | cmp RA, RB | jb <2 |3: | mov KBASE, TMP1 | ins_next | |5: // Copy all varargs. | mov MULTRES, 1 // MULTRES = 0+1 | mov RC, BASE | sub RC, KBASE | jbe <3 // No vararg slots? | mov RB, RC | shr RB, 3 | add RB, 1 | mov MULTRES, RB // MULTRES = #varargs+1 | mov L:RB, SAVE_L | add RC, RA | cmp RC, L:RB->maxstack | ja >7 // Need to grow stack? |6: // Copy all vararg slots. |.if X64 | mov RCa, [KBASE-8] | add KBASE, 8 | mov [RA], RCa |.else | mov RC, [KBASE-8] | mov [RA], RC | mov RC, [KBASE-4] | add KBASE, 8 | mov [RA+4], RC |.endif | add RA, 8 | cmp KBASE, BASE // No more vararg slots? | jb <6 | jmp <3 | |7: // Grow stack for varargs. | mov L:RB->base, BASE | mov L:RB->top, RA | mov SAVE_PC, PC | sub KBASE, BASE // Need delta, because BASE may change. | mov FCARG2, MULTRES | sub FCARG2, 1 | mov FCARG1, L:RB | call extern lj_state_growstack@8 // (lua_State *L, int n) | mov BASE, L:RB->base | mov RA, L:RB->top | add KBASE, BASE | jmp <6 break; /* -- Returns ----------------------------------------------------------- */ case BC_RETM: | ins_AD // RA = results, RD = extra_nresults | add RD, MULTRES // MULTRES >=1, so RD >=1. | // Fall through. Assumes BC_RET follows and ins_AD is a no-op. break; case BC_RET: case BC_RET0: case BC_RET1: | ins_AD // RA = results, RD = nresults+1 if (op != BC_RET0) { | shl RA, 3 } |1: | mov PC, [BASE-4] | mov MULTRES, RD // Save nresults+1. | test PC, FRAME_TYPE // Check frame type marker. | jnz >7 // Not returning to a fixarg Lua func? switch (op) { case BC_RET: |->BC_RET_Z: | mov KBASE, BASE // Use KBASE for result move. | sub RD, 1 | jz >3 |2: // Move results down. |.if X64 | mov RBa, [KBASE+RA] | mov [KBASE-8], RBa |.else | mov RB, [KBASE+RA] | mov [KBASE-8], RB | mov RB, [KBASE+RA+4] | mov [KBASE-4], RB |.endif | add KBASE, 8 | sub RD, 1 | jnz <2 |3: | mov RD, MULTRES // Note: MULTRES may be >255. | movzx RB, PC_RB // So cannot compare with RDL! |5: | cmp RB, RD // More results expected? | ja >6 break; case BC_RET1: |.if X64 | mov RBa, [BASE+RA] | mov [BASE-8], RBa |.else | mov RB, [BASE+RA+4] | mov [BASE-4], RB | mov RB, [BASE+RA] | mov [BASE-8], RB |.endif /* fallthrough */ case BC_RET0: |5: | cmp PC_RB, RDL // More results expected? | ja >6 default: break; } | movzx RA, PC_RA | not RAa // Note: ~RA = -(RA+1) | lea BASE, [BASE+RA*8] // base = base - (RA+1)*8 | mov LFUNC:KBASE, [BASE-8] | mov KBASE, LFUNC:KBASE->pc | mov KBASE, [KBASE+PC2PROTO(k)] | ins_next | |6: // Fill up results with nil. if (op == BC_RET) { | mov dword [KBASE-4], LJ_TNIL // Note: relies on shifted base. | add KBASE, 8 } else { | mov dword [BASE+RD*8-12], LJ_TNIL } | add RD, 1 | jmp <5 | |7: // Non-standard return case. | lea RB, [PC-FRAME_VARG] | test RB, FRAME_TYPEP | jnz ->vm_return | // Return from vararg function: relocate BASE down and RA up. | sub BASE, RB if (op != BC_RET0) { | add RA, RB } | jmp <1 break; /* -- Loops and branches ------------------------------------------------ */ |.define FOR_IDX, [RA]; .define FOR_TIDX, dword [RA+4] |.define FOR_STOP, [RA+8]; .define FOR_TSTOP, dword [RA+12] |.define FOR_STEP, [RA+16]; .define FOR_TSTEP, dword [RA+20] |.define FOR_EXT, [RA+24]; .define FOR_TEXT, dword [RA+28] case BC_FORL: |.if JIT | hotloop RB |.endif | // Fall through. Assumes BC_IFORL follows and ins_AJ is a no-op. break; case BC_JFORI: case BC_JFORL: #if !LJ_HASJIT break; #endif case BC_FORI: case BC_IFORL: vk = (op == BC_IFORL || op == BC_JFORL); | ins_AJ // RA = base, RD = target (after end of loop or start of loop) | lea RA, [BASE+RA*8] if (LJ_DUALNUM) { | cmp FOR_TIDX, LJ_TISNUM; jne >9 if (!vk) { | cmp FOR_TSTOP, LJ_TISNUM; jne ->vmeta_for | cmp FOR_TSTEP, LJ_TISNUM; jne ->vmeta_for | mov RB, dword FOR_IDX | cmp dword FOR_STEP, 0; jl >5 } else { #ifdef LUA_USE_ASSERT | cmp FOR_TSTOP, LJ_TISNUM; jne ->assert_bad_for_arg_type | cmp FOR_TSTEP, LJ_TISNUM; jne ->assert_bad_for_arg_type #endif | mov RB, dword FOR_STEP | test RB, RB; js >5 | add RB, dword FOR_IDX; jo >1 | mov dword FOR_IDX, RB } | cmp RB, dword FOR_STOP | mov FOR_TEXT, LJ_TISNUM | mov dword FOR_EXT, RB if (op == BC_FORI) { | jle >7 |1: |6: | branchPC RD } else if (op == BC_JFORI) { | branchPC RD | movzx RD, PC_RD | jle =>BC_JLOOP |1: |6: } else if (op == BC_IFORL) { | jg >7 |6: | branchPC RD |1: } else { | jle =>BC_JLOOP |1: |6: } |7: | ins_next | |5: // Invert check for negative step. if (vk) { | add RB, dword FOR_IDX; jo <1 | mov dword FOR_IDX, RB } | cmp RB, dword FOR_STOP | mov FOR_TEXT, LJ_TISNUM | mov dword FOR_EXT, RB if (op == BC_FORI) { | jge <7 } else if (op == BC_JFORI) { | branchPC RD | movzx RD, PC_RD | jge =>BC_JLOOP } else if (op == BC_IFORL) { | jl <7 } else { | jge =>BC_JLOOP } | jmp <6 |9: // Fallback to FP variant. } else if (!vk) { | cmp FOR_TIDX, LJ_TISNUM } if (!vk) { | jae ->vmeta_for | cmp FOR_TSTOP, LJ_TISNUM; jae ->vmeta_for } else { #ifdef LUA_USE_ASSERT | cmp FOR_TSTOP, LJ_TISNUM; jae ->assert_bad_for_arg_type | cmp FOR_TSTEP, LJ_TISNUM; jae ->assert_bad_for_arg_type #endif } | mov RB, FOR_TSTEP // Load type/hiword of for step. if (!vk) { | cmp RB, LJ_TISNUM; jae ->vmeta_for } |.if SSE | movsd xmm0, qword FOR_IDX | movsd xmm1, qword FOR_STOP if (vk) { | addsd xmm0, qword FOR_STEP | movsd qword FOR_IDX, xmm0 | test RB, RB; js >3 } else { | jl >3 } | ucomisd xmm1, xmm0 |1: | movsd qword FOR_EXT, xmm0 |.else | fld qword FOR_STOP | fld qword FOR_IDX if (vk) { | fadd qword FOR_STEP // nidx = idx + step | fst qword FOR_IDX | fst qword FOR_EXT | test RB, RB; js >1 } else { | fst qword FOR_EXT | jl >1 } | fxch // Swap lim/(n)idx if step non-negative. |1: | fcomparepp |.endif if (op == BC_FORI) { |.if DUALNUM | jnb <7 |.else | jnb >2 | branchPC RD |.endif } else if (op == BC_JFORI) { | branchPC RD | movzx RD, PC_RD | jnb =>BC_JLOOP } else if (op == BC_IFORL) { |.if DUALNUM | jb <7 |.else | jb >2 | branchPC RD |.endif } else { | jnb =>BC_JLOOP } |.if DUALNUM | jmp <6 |.else |2: | ins_next |.endif |.if SSE |3: // Invert comparison if step is negative. | ucomisd xmm0, xmm1 | jmp <1 |.endif break; case BC_ITERL: |.if JIT | hotloop RB |.endif | // Fall through. Assumes BC_IITERL follows and ins_AJ is a no-op. break; case BC_JITERL: #if !LJ_HASJIT break; #endif case BC_IITERL: | ins_AJ // RA = base, RD = target | lea RA, [BASE+RA*8] | mov RB, [RA+4] | cmp RB, LJ_TNIL; je >1 // Stop if iterator returned nil. if (op == BC_JITERL) { | mov [RA-4], RB | mov RB, [RA] | mov [RA-8], RB | jmp =>BC_JLOOP } else { | branchPC RD // Otherwise save control var + branch. | mov RD, [RA] | mov [RA-4], RB | mov [RA-8], RD } |1: | ins_next break; case BC_LOOP: | ins_A // RA = base, RD = target (loop extent) | // Note: RA/RD is only used by trace recorder to determine scope/extent | // This opcode does NOT jump, it's only purpose is to detect a hot loop. |.if JIT | hotloop RB |.endif | // Fall through. Assumes BC_ILOOP follows and ins_A is a no-op. break; case BC_ILOOP: | ins_A // RA = base, RD = target (loop extent) | ins_next break; case BC_JLOOP: |.if JIT | ins_AD // RA = base (ignored), RD = traceno | mov RA, [DISPATCH+DISPATCH_J(trace)] | mov TRACE:RD, [RA+RD*4] | mov RDa, TRACE:RD->mcode | mov L:RB, SAVE_L | mov [DISPATCH+DISPATCH_GL(jit_base)], BASE | mov [DISPATCH+DISPATCH_GL(jit_L)], L:RB | // Save additional callee-save registers only used in compiled code. |.if X64WIN | mov TMPQ, r12 | mov TMPa, r13 | mov CSAVE_4, r14 | mov CSAVE_3, r15 | mov RAa, rsp | sub rsp, 9*16+4*8 | movdqa [RAa], xmm6 | movdqa [RAa-1*16], xmm7 | movdqa [RAa-2*16], xmm8 | movdqa [RAa-3*16], xmm9 | movdqa [RAa-4*16], xmm10 | movdqa [RAa-5*16], xmm11 | movdqa [RAa-6*16], xmm12 | movdqa [RAa-7*16], xmm13 | movdqa [RAa-8*16], xmm14 | movdqa [RAa-9*16], xmm15 |.elif X64 | mov TMPQ, r12 | mov TMPa, r13 | sub rsp, 16 |.endif | jmp RDa |.endif break; case BC_JMP: | ins_AJ // RA = unused, RD = target | branchPC RD | ins_next break; /* -- Function headers -------------------------------------------------- */ /* ** Reminder: A function may be called with func/args above L->maxstack, ** i.e. occupying EXTRA_STACK slots. And vmeta_call may add one extra slot, ** too. This means all FUNC* ops (including fast functions) must check ** for stack overflow _before_ adding more slots! */ case BC_FUNCF: |.if JIT | hotcall RB |.endif case BC_FUNCV: /* NYI: compiled vararg functions. */ | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow and ins_AD is a no-op. break; case BC_JFUNCF: #if !LJ_HASJIT break; #endif case BC_IFUNCF: | ins_AD // BASE = new base, RA = framesize, RD = nargs+1 | mov KBASE, [PC-4+PC2PROTO(k)] | mov L:RB, SAVE_L | lea RA, [BASE+RA*8] // Top of frame. | cmp RA, L:RB->maxstack | ja ->vm_growstack_f | movzx RA, byte [PC-4+PC2PROTO(numparams)] | cmp NARGS:RD, RA // Check for missing parameters. | jbe >3 |2: if (op == BC_JFUNCF) { | movzx RD, PC_RD | jmp =>BC_JLOOP } else { | ins_next } | |3: // Clear missing parameters. | mov dword [BASE+NARGS:RD*8-4], LJ_TNIL | add NARGS:RD, 1 | cmp NARGS:RD, RA | jbe <3 | jmp <2 break; case BC_JFUNCV: #if !LJ_HASJIT break; #endif | int3 // NYI: compiled vararg functions break; /* NYI: compiled vararg functions. */ case BC_IFUNCV: | ins_AD // BASE = new base, RA = framesize, RD = nargs+1 | lea RB, [NARGS:RD*8+FRAME_VARG] | lea RD, [BASE+NARGS:RD*8] | mov LFUNC:KBASE, [BASE-8] | mov [RD-4], RB // Store delta + FRAME_VARG. | mov [RD-8], LFUNC:KBASE // Store copy of LFUNC. | mov L:RB, SAVE_L | lea RA, [RD+RA*8] | cmp RA, L:RB->maxstack | ja ->vm_growstack_v // Need to grow stack. | mov RA, BASE | mov BASE, RD | movzx RB, byte [PC-4+PC2PROTO(numparams)] | test RB, RB | jz >2 |1: // Copy fixarg slots up to new frame. | add RA, 8 | cmp RA, BASE | jnb >3 // Less args than parameters? | mov KBASE, [RA-8] | mov [RD], KBASE | mov KBASE, [RA-4] | mov [RD+4], KBASE | add RD, 8 | mov dword [RA-4], LJ_TNIL // Clear old fixarg slot (help the GC). | sub RB, 1 | jnz <1 |2: if (op == BC_JFUNCV) { | movzx RD, PC_RD | jmp =>BC_JLOOP } else { | mov KBASE, [PC-4+PC2PROTO(k)] | ins_next } | |3: // Clear missing parameters. | mov dword [RD+4], LJ_TNIL | add RD, 8 | sub RB, 1 | jnz <3 | jmp <2 break; case BC_FUNCC: case BC_FUNCCW: | ins_AD // BASE = new base, RA = ins RA|RD (unused), RD = nargs+1 | mov CFUNC:RB, [BASE-8] | mov KBASEa, CFUNC:RB->f | mov L:RB, SAVE_L | lea RD, [BASE+NARGS:RD*8-8] | mov L:RB->base, BASE | lea RA, [RD+8*LUA_MINSTACK] | cmp RA, L:RB->maxstack | mov L:RB->top, RD if (op == BC_FUNCC) { |.if X64 | mov CARG1d, L:RB // Caveat: CARG1d may be RA. |.else | mov ARG1, L:RB |.endif } else { |.if X64 | mov CARG2, KBASEa | mov CARG1d, L:RB // Caveat: CARG1d may be RA. |.else | mov ARG2, KBASEa | mov ARG1, L:RB |.endif } | ja ->vm_growstack_c // Need to grow stack. | set_vmstate C if (op == BC_FUNCC) { | call KBASEa // (lua_State *L) } else { | // (lua_State *L, lua_CFunction f) | call aword [DISPATCH+DISPATCH_GL(wrapf)] } | set_vmstate INTERP | // nresults returned in eax (RD). | mov BASE, L:RB->base | lea RA, [BASE+RD*8] | neg RA | add RA, L:RB->top // RA = (L->top-(L->base+nresults))*8 | mov PC, [BASE-4] // Fetch PC of caller. | jmp ->vm_returnc break; /* ---------------------------------------------------------------------- */ default: fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); exit(2); break; } } static int build_backend(BuildCtx *ctx) { int op; dasm_growpc(Dst, BC__MAX); build_subroutines(ctx); |.code_op for (op = 0; op < BC__MAX; op++) build_ins(ctx, (BCOp)op, op); return BC__MAX; } /* Emit pseudo frame-info for all assembler functions. */ static void emit_asm_debug(BuildCtx *ctx) { int fcofs = (int)((uint8_t *)ctx->glob[GLOB_vm_ffi_call] - ctx->code); #if LJ_64 #define SZPTR "8" #define BSZPTR "3" #define REG_SP "0x7" #define REG_RA "0x10" #else #define SZPTR "4" #define BSZPTR "2" #define REG_SP "0x4" #define REG_RA "0x8" #endif switch (ctx->mode) { case BUILD_elfasm: fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); fprintf(ctx->fp, ".Lframe0:\n" "\t.long .LECIE0-.LSCIE0\n" ".LSCIE0:\n" "\t.long 0xffffffff\n" "\t.byte 0x1\n" "\t.string \"\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -" SZPTR "\n" "\t.byte " REG_RA "\n" "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" "\t.align " SZPTR "\n" ".LECIE0:\n\n"); fprintf(ctx->fp, ".LSFDE0:\n" "\t.long .LEFDE0-.LASFDE0\n" ".LASFDE0:\n" "\t.long .Lframe0\n" #if LJ_64 "\t.quad .Lbegin\n" "\t.quad %d\n" "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ #else "\t.long .Lbegin\n" "\t.long %d\n" "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ #endif "\t.align " SZPTR "\n" ".LEFDE0:\n\n", fcofs, CFRAME_SIZE); #if LJ_HASFFI fprintf(ctx->fp, ".LSFDE1:\n" "\t.long .LEFDE1-.LASFDE1\n" ".LASFDE1:\n" "\t.long .Lframe0\n" #if LJ_64 "\t.quad lj_vm_ffi_call\n" "\t.quad %d\n" "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ #else "\t.long lj_vm_ffi_call\n" "\t.long %d\n" "\t.byte 0xe\n\t.uleb128 8\n" /* def_cfa_offset */ "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ "\t.byte 0xd\n\t.uleb128 0x5\n" /* def_cfa_register ebp */ "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset ebx */ #endif "\t.align " SZPTR "\n" ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); #endif #if (defined(__sun__) && defined(__svr4__)) fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); #else fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); #endif fprintf(ctx->fp, ".Lframe1:\n" "\t.long .LECIE1-.LSCIE1\n" ".LSCIE1:\n" "\t.long 0\n" "\t.byte 0x1\n" "\t.string \"zPR\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -" SZPTR "\n" "\t.byte " REG_RA "\n" "\t.uleb128 6\n" /* augmentation length */ "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.long lj_err_unwind_dwarf-.\n" "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" "\t.align " SZPTR "\n" ".LECIE1:\n\n"); fprintf(ctx->fp, ".LSFDE2:\n" "\t.long .LEFDE2-.LASFDE2\n" ".LASFDE2:\n" "\t.long .LASFDE2-.Lframe1\n" "\t.long .Lbegin-.\n" "\t.long %d\n" "\t.uleb128 0\n" /* augmentation length */ "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ #if LJ_64 "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ #else "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ #endif "\t.align " SZPTR "\n" ".LEFDE2:\n\n", fcofs, CFRAME_SIZE); #if LJ_HASFFI fprintf(ctx->fp, ".Lframe2:\n" "\t.long .LECIE2-.LSCIE2\n" ".LSCIE2:\n" "\t.long 0\n" "\t.byte 0x1\n" "\t.string \"zR\"\n" "\t.uleb128 0x1\n" "\t.sleb128 -" SZPTR "\n" "\t.byte " REG_RA "\n" "\t.uleb128 1\n" /* augmentation length */ "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" "\t.align " SZPTR "\n" ".LECIE2:\n\n"); fprintf(ctx->fp, ".LSFDE3:\n" "\t.long .LEFDE3-.LASFDE3\n" ".LASFDE3:\n" "\t.long .LASFDE3-.Lframe2\n" "\t.long lj_vm_ffi_call-.\n" "\t.long %d\n" "\t.uleb128 0\n" /* augmentation length */ #if LJ_64 "\t.byte 0xe\n\t.uleb128 16\n" /* def_cfa_offset */ "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ #else "\t.byte 0xe\n\t.uleb128 8\n" /* def_cfa_offset */ "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ "\t.byte 0xd\n\t.uleb128 0x5\n" /* def_cfa_register ebp */ "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset ebx */ #endif "\t.align " SZPTR "\n" ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); #endif break; /* Mental note: never let Apple design an assembler. ** Or a linker. Or a plastic case. But I digress. */ case BUILD_machasm: { #if LJ_HASFFI int fcsize = 0; #endif int i; fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); fprintf(ctx->fp, "EH_frame1:\n" "\t.set L$set$x,LECIEX-LSCIEX\n" "\t.long L$set$x\n" "LSCIEX:\n" "\t.long 0\n" "\t.byte 0x1\n" "\t.ascii \"zPR\\0\"\n" "\t.byte 0x1\n" "\t.byte 128-" SZPTR "\n" "\t.byte " REG_RA "\n" "\t.byte 6\n" /* augmentation length */ "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ #if LJ_64 "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" #else "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ #endif "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" "\t.align " BSZPTR "\n" "LECIEX:\n\n"); for (i = 0; i < ctx->nsym; i++) { const char *name = ctx->sym[i].name; int32_t size = ctx->sym[i+1].ofs - ctx->sym[i].ofs; if (size == 0) continue; #if LJ_HASFFI if (!strcmp(name, "_lj_vm_ffi_call")) { fcsize = size; continue; } #endif fprintf(ctx->fp, "%s.eh:\n" "LSFDE%d:\n" "\t.set L$set$%d,LEFDE%d-LASFDE%d\n" "\t.long L$set$%d\n" "LASFDE%d:\n" "\t.long LASFDE%d-EH_frame1\n" "\t.long %s-.\n" "\t.long %d\n" "\t.byte 0\n" /* augmentation length */ "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ #if LJ_64 "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ "\t.byte 0x8f\n\t.byte 0x4\n" /* offset r15 */ "\t.byte 0x8e\n\t.byte 0x5\n" /* offset r14 */ #else "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ #endif "\t.align " BSZPTR "\n" "LEFDE%d:\n\n", name, i, i, i, i, i, i, i, name, size, CFRAME_SIZE, i); } #if LJ_HASFFI if (fcsize) { fprintf(ctx->fp, "EH_frame2:\n" "\t.set L$set$y,LECIEY-LSCIEY\n" "\t.long L$set$y\n" "LSCIEY:\n" "\t.long 0\n" "\t.byte 0x1\n" "\t.ascii \"zR\\0\"\n" "\t.byte 0x1\n" "\t.byte 128-" SZPTR "\n" "\t.byte " REG_RA "\n" "\t.byte 1\n" /* augmentation length */ #if LJ_64 "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" #else "\t.byte 0x1b\n" /* pcrel|sdata4 */ "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH. */ #endif "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" "\t.align " BSZPTR "\n" "LECIEY:\n\n"); fprintf(ctx->fp, "_lj_vm_ffi_call.eh:\n" "LSFDEY:\n" "\t.set L$set$yy,LEFDEY-LASFDEY\n" "\t.long L$set$yy\n" "LASFDEY:\n" "\t.long LASFDEY-EH_frame2\n" "\t.long _lj_vm_ffi_call-.\n" "\t.long %d\n" "\t.byte 0\n" /* augmentation length */ #if LJ_64 "\t.byte 0xe\n\t.byte 16\n" /* def_cfa_offset */ "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ "\t.byte 0xd\n\t.uleb128 0x6\n" /* def_cfa_register rbp */ "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ #else "\t.byte 0xe\n\t.byte 8\n" /* def_cfa_offset */ "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ "\t.byte 0xd\n\t.uleb128 0x4\n" /* def_cfa_register ebp */ "\t.byte 0x83\n\t.byte 0x3\n" /* offset ebx */ #endif "\t.align " BSZPTR "\n" "LEFDEY:\n\n", fcsize); } #endif #if LJ_64 fprintf(ctx->fp, "\t.subsections_via_symbols\n"); #else fprintf(ctx->fp, "\t.non_lazy_symbol_pointer\n" "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" ".indirect_symbol _lj_err_unwind_dwarf\n" ".long 0\n"); #endif } break; default: /* Difficult for other modes. */ break; } } ================================================ FILE: cocos2d/external/lua/luajit/src/src/xedkbuild.bat ================================================ @rem Script to build LuaJIT with the Xbox 360 SDK. @rem Donated to the public domain. @rem @rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler) @rem Then cd to this directory and run this script. @if not defined INCLUDE goto :FAIL @if not defined XEDK goto :FAIL @setlocal @rem ---- Host compiler ---- @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE @set LJLINK=link /nologo @set LJMT=mt /nologo @set DASMDIR=..\dynasm @set DASM=%DASMDIR%\dynasm.lua @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c %LJCOMPILE% host\minilua.c @if errorlevel 1 goto :BAD %LJLINK% /out:minilua.exe minilua.obj @if errorlevel 1 goto :BAD if exist minilua.exe.manifest^ %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe @rem Error out for 64 bit host compiler @minilua @if errorlevel 8 goto :FAIL @set DASMFLAGS=-D GPR64 -D FRAME32 -D PPE -D SQRT -D DUALNUM minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_ppc.dasc @if errorlevel 1 goto :BAD %LJCOMPILE% /I "." /I %DASMDIR% /D_XBOX_VER=200 /DLUAJIT_TARGET=LUAJIT_ARCH_PPC host\buildvm*.c @if errorlevel 1 goto :BAD %LJLINK% /out:buildvm.exe buildvm*.obj @if errorlevel 1 goto :BAD if exist buildvm.exe.manifest^ %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe buildvm -m peobj -o lj_vm.obj @if errorlevel 1 goto :BAD buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m libdef -o lj_libdef.h %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m recdef -o lj_recdef.h %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% @if errorlevel 1 goto :BAD buildvm -m folddef -o lj_folddef.h lj_opt_fold.c @if errorlevel 1 goto :BAD @rem ---- Cross compiler ---- @set LJCOMPILE="%XEDK%\bin\win32\cl" /nologo /c /MT /O2 /W3 /GF /Gm- /GR- /GS- /Gy /openmp- /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /D_XBOX /D_LIB /DLUAJIT_USE_SYSMALLOC @set LJLIB="%XEDK%\bin\win32\lib" /nologo @set INCLUDE="%XEDK%\include\xbox" @if "%1" neq "debug" goto :NODEBUG @shift @set LJCOMPILE="%LJCOMPILE%" /Zi :NODEBUG @if "%1"=="amalg" goto :AMALG %LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c @if errorlevel 1 goto :BAD %LJLIB% /OUT:luajit20.lib lj_*.obj lib_*.obj @if errorlevel 1 goto :BAD @goto :NOAMALG :AMALG %LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c @if errorlevel 1 goto :BAD %LJLIB% /OUT:luajit20.lib ljamalg.obj lj_vm.obj @if errorlevel 1 goto :BAD :NOAMALG @del *.obj *.manifest minilua.exe buildvm.exe @echo. @echo === Successfully built LuaJIT for Xbox 360 === @goto :END :BAD @echo. @echo ******************************************************* @echo *** Build FAILED -- Please check the error messages *** @echo ******************************************************* @goto :END :FAIL @echo To run this script you must open a "Visual Studio .NET Command Prompt" @echo (32 bit host compiler). The Xbox 360 SDK must be installed, too. :END ================================================ FILE: cocos2d/external/lua/luajit/src/v2.0.1_hotfix1.patch ================================================ Add missing GC steps for io.* functions. MIPS: Fix cache flush/sync for JIT-compiled code jump area. ARM: Fix cache flush/sync for exit stubs of JIT-compiled code. Fix MSVC intrinsics for older versions. Fix memory access check for fast string interning. --- a/src/lib_io.c +++ b/src/lib_io.c @@ -17,6 +17,7 @@ #include "lualib.h" #include "lj_obj.h" +#include "lj_gc.h" #include "lj_err.h" #include "lj_str.h" #include "lj_state.h" @@ -152,6 +153,7 @@ static int io_file_readline(lua_State *L, FILE *fp, MSize chop) if (n >= m - 64) m += m; } setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); return (int)ok; } @@ -163,6 +165,7 @@ static void io_file_readall(lua_State *L, FILE *fp) n += (MSize)fread(buf+n, 1, m-n, fp); if (n != m) { setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); return; } } @@ -174,6 +177,7 @@ static int io_file_readlen(lua_State *L, FILE *fp, MSize m) char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, m); MSize n = (MSize)fread(buf, 1, m, fp); setstrV(L, L->top++, lj_str_new(L, buf, (size_t)n)); + lj_gc_check(L); return (n > 0 || m == 0); } else { int c = getc(fp); --- a/src/lj_asm_arm.h +++ b/src/lj_asm_arm.h @@ -91,6 +91,7 @@ static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) *mxp++ = group*EXITSTUBS_PER_GROUP; for (i = 0; i < EXITSTUBS_PER_GROUP; i++) *mxp++ = ARMI_B|((-6-i)&0x00ffffffu); + lj_mcode_sync(as->mcbot, mxp); lj_mcode_commitbot(as->J, mxp); as->mcbot = mxp; as->mclim = as->mcbot + MCLIM_REDZONE; --- a/src/lj_asm_mips.h +++ b/src/lj_asm_mips.h @@ -71,6 +71,7 @@ static void asm_sparejump_setup(ASMState *as) memset(mxp+2, 0, MIPS_SPAREJUMP*8); mxp += MIPS_SPAREJUMP*2; lua_assert(mxp < as->mctop); + lj_mcode_sync(as->mcbot, mxp); lj_mcode_commitbot(as->J, mxp); as->mcbot = mxp; as->mclim = as->mcbot + MCLIM_REDZONE; --- a/src/lj_def.h +++ b/src/lj_def.h @@ -243,17 +243,17 @@ static LJ_AINLINE uint32_t lj_getu32(const void *p) #endif #ifdef _M_PPC -#pragma intrinsic(_CountLeadingZeros) unsigned int _CountLeadingZeros(long); +#pragma intrinsic(_CountLeadingZeros) static LJ_AINLINE uint32_t lj_fls(uint32_t x) { return _CountLeadingZeros(x) ^ 31; } #else -#pragma intrinsic(_BitScanForward) -#pragma intrinsic(_BitScanReverse) unsigned char _BitScanForward(uint32_t *, unsigned long); unsigned char _BitScanReverse(uint32_t *, unsigned long); +#pragma intrinsic(_BitScanForward) +#pragma intrinsic(_BitScanReverse) static LJ_AINLINE uint32_t lj_ffs(uint32_t x) { --- a/src/lj_str.c +++ b/src/lj_str.c @@ -48,7 +48,7 @@ static LJ_AINLINE int str_fastcmp(const char *a, const char *b, MSize len) { MSize i = 0; lua_assert(len > 0); - lua_assert((((uintptr_t)a + len) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4); + lua_assert((((uintptr_t)a+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4); do { /* Note: innocuous access up to end of string + 3. */ uint32_t v = lj_getu32(a+i) ^ *(const uint32_t *)(b+i); if (v) { @@ -121,7 +121,7 @@ GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) h ^= b; h -= lj_rol(b, 16); /* Check if the string has already been interned. */ o = gcref(g->strhash[h & g->strmask]); - if (LJ_LIKELY((((uintptr_t)str + len) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { + if (LJ_LIKELY((((uintptr_t)str+len-1) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) { while (o != NULL) { GCstr *sx = gco2str(o); if (sx->len == len && str_fastcmp(str, strdata(sx), len) == 0) { ================================================ FILE: cocos2d/external/lua/tolua/CMakeLists.txt ================================================ set(TOLUA_SRC tolua_event.c tolua_is.c tolua_map.c tolua_push.c tolua_to.c ) include_directories( ../lua ) add_library(tolua STATIC ${TOLUA_SRC} ) set_target_properties(tolua PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/external/lua/tolua/tolua++.h ================================================ /* tolua ** Support code for Lua bindings. ** Written by Waldemar Celes ** TeCGraf/PUC-Rio ** Apr 2003 ** $Id: $ */ /* This code is free software; you can redistribute it and/or modify it. ** The software provided hereunder is on an "as is" basis, and ** the author has no obligation to provide maintenance, support, updates, ** enhancements, or modifications. */ #ifndef TOLUA_H #define TOLUA_H #ifndef TOLUA_API #define TOLUA_API extern #endif #define TOLUA_VERSION "tolua++-1.0.93" #ifdef __cplusplus extern "C" { #endif #define tolua_pushcppstring(x,y) tolua_pushstring(x,y.c_str()) #define tolua_iscppstring tolua_isstring #define tolua_iscppstringarray tolua_isstringarray #define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str()) #ifndef TEMPLATE_BIND #define TEMPLATE_BIND(p) #endif #define TOLUA_TEMPLATE_BIND(p) #define TOLUA_PROTECTED_DESTRUCTOR #define TOLUA_PROPERTY_TYPE(p) #define TOLUA_VALUE_ROOT "tolua_value_root" typedef int lua_Object; #include "lua.h" #include "lauxlib.h" struct tolua_Error { int index; int array; const char* type; }; typedef struct tolua_Error tolua_Error; #define TOLUA_NOPEER LUA_REGISTRYINDEX /* for lua 5.1 */ TOLUA_API const char* tolua_typename (lua_State* L, int lo); TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err); TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err); TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err); TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err); TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err); TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err); TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err); TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err); TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err); TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err); TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err); TOLUA_API int tolua_isvaluearray (lua_State* L, int lo, int dim, int def, tolua_Error* err); TOLUA_API int tolua_isbooleanarray (lua_State* L, int lo, int dim, int def, tolua_Error* err); TOLUA_API int tolua_isnumberarray (lua_State* L, int lo, int dim, int def, tolua_Error* err); TOLUA_API int tolua_isstringarray (lua_State* L, int lo, int dim, int def, tolua_Error* err); TOLUA_API int tolua_istablearray (lua_State* L, int lo, int dim, int def, tolua_Error* err); TOLUA_API int tolua_isuserdataarray (lua_State* L, int lo, int dim, int def, tolua_Error* err); TOLUA_API int tolua_isusertypearray (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err); TOLUA_API void tolua_open (lua_State* L); TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size); TOLUA_API int tolua_register_gc (lua_State* L, int lo); TOLUA_API int tolua_default_collect (lua_State* tolua_S); TOLUA_API void tolua_usertype (lua_State* L, const char* type); TOLUA_API void tolua_beginmodule (lua_State* L, const char* name); TOLUA_API void tolua_endmodule (lua_State* L); TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar); TOLUA_API void tolua_class (lua_State* L, const char* name, const char* base); TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col); TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func); TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value); TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set); TOLUA_API void tolua_array (lua_State* L,const char* name, lua_CFunction get, lua_CFunction set); /* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */ TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); TOLUA_API void tolua_pushvalue (lua_State* L, int lo); TOLUA_API void tolua_pushboolean (lua_State* L, int value); TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value); TOLUA_API void tolua_pushstring (lua_State* L, const char* value); TOLUA_API void tolua_pushuserdata (lua_State* L, void* value); TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type); TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type); TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v); TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v); TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v); TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v); TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v); TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type); TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type); TOLUA_API void tolua_pushusertype_and_addtoroot (lua_State* L, void* value, const char* type); TOLUA_API void tolua_add_value_to_root (lua_State* L,void* value); TOLUA_API void tolua_remove_value_from_root (lua_State* L, void* value); TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def); TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def); TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def); TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def); TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def); TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def); TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def); TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def); TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def); TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def); TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def); TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def); TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name); TOLUA_API int class_gc_event (lua_State* L); #ifdef __cplusplus static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) { const char* s = tolua_tostring(L, narg, def); return s?s:""; }; static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) { const char* s = tolua_tofieldstring(L, lo, index, def); return s?s:""; }; #else #define tolua_tocppstring tolua_tostring #define tolua_tofieldcppstring tolua_tofieldstring #endif TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index); #ifndef Mtolua_new #define Mtolua_new(EXP) new EXP #endif #ifndef Mtolua_delete #define Mtolua_delete(EXP) delete EXP #endif #ifndef Mtolua_new_dim #define Mtolua_new_dim(EXP, len) new EXP[len] #endif #ifndef Mtolua_delete_dim #define Mtolua_delete_dim(EXP) delete [] EXP #endif #ifndef tolua_outside #define tolua_outside #endif #ifndef tolua_owned #define tolua_owned #endif #ifdef __cplusplus } #endif #endif ================================================ FILE: cocos2d/external/lua/tolua/tolua_event.c ================================================ /* tolua: event functions ** Support code for Lua bindings. ** Written by Waldemar Celes ** TeCGraf/PUC-Rio ** Apr 2003 ** $Id: $ */ /* This code is free software; you can redistribute it and/or modify it. ** The software provided hereunder is on an "as is" basis, and ** the author has no obligation to provide maintenance, support, updates, ** enhancements, or modifications. */ #include #include "tolua++.h" /* Store at ubox * It stores, creating the corresponding table if needed, * the pair key/value in the corresponding ubox table */ static void storeatubox (lua_State* L, int lo) { #ifdef LUA_VERSION_NUM lua_getfenv(L, lo); if (lua_rawequal(L, -1, TOLUA_NOPEER)) { lua_pop(L, 1); lua_newtable(L); lua_pushvalue(L, -1); lua_setfenv(L, lo); /* stack: k,v,table */ }; lua_insert(L, -3); lua_settable(L, -3); /* on lua 5.1, we trade the "tolua_peers" lookup for a settable call */ lua_pop(L, 1); #else /* stack: key value (to be stored) */ lua_pushstring(L,"tolua_peers"); lua_rawget(L,LUA_REGISTRYINDEX); /* stack: k v ubox */ lua_pushvalue(L,lo); lua_rawget(L,-2); /* stack: k v ubox ubox[u] */ if (!lua_istable(L,-1)) { lua_pop(L,1); /* stack: k v ubox */ lua_newtable(L); /* stack: k v ubox table */ lua_pushvalue(L,1); lua_pushvalue(L,-2); /* stack: k v ubox table u table */ lua_rawset(L,-4); /* stack: k v ubox ubox[u]=table */ } lua_insert(L,-4); /* put table before k */ lua_pop(L,1); /* pop ubox */ lua_rawset(L,-3); /* store at table */ lua_pop(L,1); /* pop ubox[u] */ #endif } /* Module index function */ static int module_index_event (lua_State* L) { lua_pushstring(L,".get"); lua_rawget(L,-3); if (lua_istable(L,-1)) { lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); if (lua_iscfunction(L,-1)) { lua_call(L,0,1); return 1; } else if (lua_istable(L,-1)) return 1; } /* call old index meta event */ if (lua_getmetatable(L,1)) { lua_pushstring(L,"__index"); lua_rawget(L,-2); lua_pushvalue(L,1); lua_pushvalue(L,2); if (lua_isfunction(L,-1)) { lua_call(L,2,1); return 1; } else if (lua_istable(L,-1)) { lua_gettable(L,-3); return 1; } } lua_pushnil(L); return 1; } /* Module newindex function */ static int module_newindex_event (lua_State* L) { lua_pushstring(L,".set"); lua_rawget(L,-4); if (lua_istable(L,-1)) { lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); if (lua_iscfunction(L,-1)) { lua_pushvalue(L,1); /* only to be compatible with non-static vars */ lua_pushvalue(L,3); /* value */ lua_call(L,2,0); return 0; } } /* call old newindex meta event */ if (lua_getmetatable(L,1) && lua_getmetatable(L,-1)) { lua_pushstring(L,"__newindex"); lua_rawget(L,-2); if (lua_isfunction(L,-1)) { lua_pushvalue(L,1); lua_pushvalue(L,2); lua_pushvalue(L,3); lua_call(L,3,0); } } lua_settop(L,3); lua_rawset(L,-3); return 0; } /* Class index function * If the object is a userdata (ie, an object), it searches the field in * the alternative table stored in the corresponding "ubox" table. */ static int class_index_event (lua_State* L) { int t = lua_type(L,1); if (t == LUA_TUSERDATA) { /* Access alternative table */ #ifdef LUA_VERSION_NUM /* new macro on version 5.1 */ lua_getfenv(L,1); if (!lua_rawequal(L, -1, TOLUA_NOPEER)) { lua_pushvalue(L, 2); /* key */ lua_gettable(L, -2); /* on lua 5.1, we trade the "tolua_peers" lookup for a gettable call */ if (!lua_isnil(L, -1)) return 1; }; #else lua_pushstring(L,"tolua_peers"); lua_rawget(L,LUA_REGISTRYINDEX); /* stack: obj key ubox */ lua_pushvalue(L,1); lua_rawget(L,-2); /* stack: obj key ubox ubox[u] */ if (lua_istable(L,-1)) { lua_pushvalue(L,2); /* key */ lua_rawget(L,-2); /* stack: obj key ubox ubox[u] value */ if (!lua_isnil(L,-1)) return 1; } #endif lua_settop(L,2); /* stack: obj key */ /* Try metatables */ lua_pushvalue(L,1); /* stack: obj key obj */ while (lua_getmetatable(L,-1)) { /* stack: obj key obj mt */ lua_remove(L,-2); /* stack: obj key mt */ if (lua_isnumber(L,2)) /* check if key is a numeric value */ { /* try operator[] */ lua_pushstring(L,".geti"); lua_rawget(L,-2); /* stack: obj key mt func */ if (lua_isfunction(L,-1)) { lua_pushvalue(L,1); lua_pushvalue(L,2); lua_call(L,2,1); return 1; } } else { lua_pushvalue(L,2); /* stack: obj key mt key */ lua_rawget(L,-2); /* stack: obj key mt value */ if (!lua_isnil(L,-1)) return 1; else lua_pop(L,1); /* try C/C++ variable */ lua_pushstring(L,".get"); lua_rawget(L,-2); /* stack: obj key mt tget */ if (lua_istable(L,-1)) { lua_pushvalue(L,2); lua_rawget(L,-2); /* stack: obj key mt value */ if (lua_iscfunction(L,-1)) { lua_pushvalue(L,1); lua_pushvalue(L,2); lua_call(L,2,1); return 1; } else if (lua_istable(L,-1)) { /* deal with array: create table to be returned and cache it in ubox */ void* u = *((void**)lua_touserdata(L,1)); lua_newtable(L); /* stack: obj key mt value table */ lua_pushstring(L,".self"); lua_pushlightuserdata(L,u); lua_rawset(L,-3); /* store usertype in ".self" */ lua_insert(L,-2); /* stack: obj key mt table value */ lua_setmetatable(L,-2); /* set stored value as metatable */ lua_pushvalue(L,-1); /* stack: obj key met table table */ lua_pushvalue(L,2); /* stack: obj key mt table table key */ lua_insert(L,-2); /* stack: obj key mt table key table */ storeatubox(L,1); /* stack: obj key mt table */ return 1; } } } lua_settop(L,3); } lua_pushnil(L); return 1; } else if (t== LUA_TTABLE) { module_index_event(L); return 1; } lua_pushnil(L); return 1; } /* Newindex function * It first searches for a C/C++ varaible to be set. * Then, it either stores it in the alternative ubox table (in the case it is * an object) or in the own table (that represents the class or module). */ static int class_newindex_event (lua_State* L) { int t = lua_type(L,1); if (t == LUA_TUSERDATA) { /* Try accessing a C/C++ variable to be set */ lua_getmetatable(L,1); while (lua_istable(L,-1)) /* stack: t k v mt */ { if (lua_isnumber(L,2)) /* check if key is a numeric value */ { /* try operator[] */ lua_pushstring(L,".seti"); lua_rawget(L,-2); /* stack: obj key mt func */ if (lua_isfunction(L,-1)) { lua_pushvalue(L,1); lua_pushvalue(L,2); lua_pushvalue(L,3); lua_call(L,3,0); return 0; } } else { lua_pushstring(L,".set"); lua_rawget(L,-2); /* stack: t k v mt tset */ if (lua_istable(L,-1)) { lua_pushvalue(L,2); lua_rawget(L,-2); /* stack: t k v mt tset func */ if (lua_iscfunction(L,-1)) { lua_pushvalue(L,1); lua_pushvalue(L,3); lua_call(L,2,0); return 0; } lua_pop(L,1); /* stack: t k v mt tset */ } lua_pop(L,1); /* stack: t k v mt */ if (!lua_getmetatable(L,-1)) /* stack: t k v mt mt */ lua_pushnil(L); lua_remove(L,-2); /* stack: t k v mt */ } } lua_settop(L,3); /* stack: t k v */ /* then, store as a new field */ storeatubox(L,1); } else if (t== LUA_TTABLE) { module_newindex_event(L); } return 0; } static int class_call_event(lua_State* L) { if (lua_istable(L, 1)) { lua_pushstring(L, ".call"); lua_rawget(L, 1); if (lua_isfunction(L, -1)) { lua_insert(L, 1); lua_call(L, lua_gettop(L)-1, 1); return 1; }; }; tolua_error(L,"Attempt to call a non-callable object.",NULL); return 0; }; static int do_operator (lua_State* L, const char* op) { if (lua_isuserdata(L,1)) { /* Try metatables */ lua_pushvalue(L,1); /* stack: op1 op2 */ while (lua_getmetatable(L,-1)) { /* stack: op1 op2 op1 mt */ lua_remove(L,-2); /* stack: op1 op2 mt */ lua_pushstring(L,op); /* stack: op1 op2 mt key */ lua_rawget(L,-2); /* stack: obj key mt func */ if (lua_isfunction(L,-1)) { lua_pushvalue(L,1); lua_pushvalue(L,2); lua_call(L,2,1); return 1; } lua_settop(L,3); } } tolua_error(L,"Attempt to perform operation on an invalid operand",NULL); return 0; } static int class_add_event (lua_State* L) { return do_operator(L,".add"); } int class_sub_event (lua_State* L) { return do_operator(L,".sub"); } static int class_mul_event (lua_State* L) { return do_operator(L,".mul"); } static int class_div_event (lua_State* L) { return do_operator(L,".div"); } static int class_lt_event (lua_State* L) { return do_operator(L,".lt"); } static int class_le_event (lua_State* L) { return do_operator(L,".le"); } static int class_eq_event (lua_State* L) { /* copying code from do_operator here to return false when no operator is found */ if (lua_isuserdata(L,1)) { /* Try metatables */ lua_pushvalue(L,1); /* stack: op1 op2 */ while (lua_getmetatable(L,-1)) { /* stack: op1 op2 op1 mt */ lua_remove(L,-2); /* stack: op1 op2 mt */ lua_pushstring(L,".eq"); /* stack: op1 op2 mt key */ lua_rawget(L,-2); /* stack: obj key mt func */ if (lua_isfunction(L,-1)) { lua_pushvalue(L,1); lua_pushvalue(L,2); lua_call(L,2,1); return 1; } lua_settop(L,3); } } lua_settop(L, 3); lua_pushboolean(L, 0); return 1; } /* static int class_gc_event (lua_State* L) { void* u = *((void**)lua_touserdata(L,1)); fprintf(stderr, "collecting: looking at %p\n", u); lua_pushstring(L,"tolua_gc"); lua_rawget(L,LUA_REGISTRYINDEX); lua_pushlightuserdata(L,u); lua_rawget(L,-2); if (lua_isfunction(L,-1)) { lua_pushvalue(L,1); lua_call(L,1,0); lua_pushlightuserdata(L,u); lua_pushnil(L); lua_rawset(L,-3); } lua_pop(L,2); return 0; } */ TOLUA_API int class_gc_event (lua_State* L) { void* u = *((void**)lua_touserdata(L,1)); int top; /*fprintf(stderr, "collecting: looking at %p\n", u);*/ /* lua_pushstring(L,"tolua_gc"); lua_rawget(L,LUA_REGISTRYINDEX); */ lua_pushvalue(L, lua_upvalueindex(1)); lua_pushlightuserdata(L,u); lua_rawget(L,-2); /* stack: gc umt */ lua_getmetatable(L,1); /* stack: gc umt mt */ /*fprintf(stderr, "checking type\n");*/ top = lua_gettop(L); if (tolua_fast_isa(L,top,top-1, lua_upvalueindex(2))) /* make sure we collect correct type */ { /*fprintf(stderr, "Found type!\n");*/ /* get gc function */ lua_pushliteral(L,".collector"); lua_rawget(L,-2); /* stack: gc umt mt collector */ if (lua_isfunction(L,-1)) { /*fprintf(stderr, "Found .collector!\n");*/ } else { lua_pop(L,1); /*fprintf(stderr, "Using default cleanup\n");*/ lua_pushcfunction(L,tolua_default_collect); } lua_pushvalue(L,1); /* stack: gc umt mt collector u */ lua_call(L,1,0); lua_pushlightuserdata(L,u); /* stack: gc umt mt u */ lua_pushnil(L); /* stack: gc umt mt u nil */ lua_rawset(L,-5); /* stack: gc umt mt */ } lua_pop(L,3); return 0; } /* Register module events * It expects the metatable on the top of the stack */ TOLUA_API void tolua_moduleevents (lua_State* L) { lua_pushstring(L,"__index"); lua_pushcfunction(L,module_index_event); lua_rawset(L,-3); lua_pushstring(L,"__newindex"); lua_pushcfunction(L,module_newindex_event); lua_rawset(L,-3); } /* Check if the object on the top has a module metatable */ TOLUA_API int tolua_ismodulemetatable (lua_State* L) { int r = 0; if (lua_getmetatable(L,-1)) { lua_pushstring(L,"__index"); lua_rawget(L,-2); r = (lua_tocfunction(L,-1) == module_index_event); lua_pop(L,2); } return r; } /* Register class events * It expects the metatable on the top of the stack */ TOLUA_API void tolua_classevents (lua_State* L) { lua_pushstring(L,"__index"); lua_pushcfunction(L,class_index_event); lua_rawset(L,-3); lua_pushstring(L,"__newindex"); lua_pushcfunction(L,class_newindex_event); lua_rawset(L,-3); lua_pushstring(L,"__add"); lua_pushcfunction(L,class_add_event); lua_rawset(L,-3); lua_pushstring(L,"__sub"); lua_pushcfunction(L,class_sub_event); lua_rawset(L,-3); lua_pushstring(L,"__mul"); lua_pushcfunction(L,class_mul_event); lua_rawset(L,-3); lua_pushstring(L,"__div"); lua_pushcfunction(L,class_div_event); lua_rawset(L,-3); lua_pushstring(L,"__lt"); lua_pushcfunction(L,class_lt_event); lua_rawset(L,-3); lua_pushstring(L,"__le"); lua_pushcfunction(L,class_le_event); lua_rawset(L,-3); lua_pushstring(L,"__eq"); lua_pushcfunction(L,class_eq_event); lua_rawset(L,-3); lua_pushstring(L,"__call"); lua_pushcfunction(L,class_call_event); lua_rawset(L,-3); lua_pushstring(L,"__gc"); lua_pushstring(L, "tolua_gc_event"); lua_rawget(L, LUA_REGISTRYINDEX); /*lua_pushcfunction(L,class_gc_event);*/ lua_rawset(L,-3); } ================================================ FILE: cocos2d/external/lua/tolua/tolua_event.h ================================================ /* tolua: event functions ** Support code for Lua bindings. ** Written by Waldemar Celes ** TeCGraf/PUC-Rio ** Apr 2003 ** $Id: $ */ /* This code is free software; you can redistribute it and/or modify it. ** The software provided hereunder is on an "as is" basis, and ** the author has no obligation to provide maintenance, support, updates, ** enhancements, or modifications. */ #ifndef TOLUA_EVENT_H #define TOLUA_EVENT_H #include "tolua++.h" TOLUA_API void tolua_moduleevents (lua_State* L); TOLUA_API int tolua_ismodulemetatable (lua_State* L); TOLUA_API void tolua_classevents (lua_State* L); #endif ================================================ FILE: cocos2d/external/lua/tolua/tolua_is.c ================================================ /* tolua: functions to check types. ** Support code for Lua bindings. ** Written by Waldemar Celes ** TeCGraf/PUC-Rio ** Apr 2003 ** $Id: $ */ /* This code is free software; you can redistribute it and/or modify it. ** The software provided hereunder is on an "as is" basis, and ** the author has no obligation to provide maintenance, support, updates, ** enhancements, or modifications. */ #include "tolua++.h" #include "lauxlib.h" #include #include /* a fast check if a is b, without parameter validation i.e. if b is equal to a or a superclass of a. */ TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index) { int result; if (lua_rawequal(L,mt_indexa,mt_indexb)) result = 1; else { if (super_index) { lua_pushvalue(L, super_index); } else { lua_pushliteral(L,"tolua_super"); lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super */ }; lua_pushvalue(L,mt_indexa); /* stack: super mta */ lua_rawget(L,-2); /* stack: super super[mta] */ lua_pushvalue(L,mt_indexb); /* stack: super super[mta] mtb */ lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super super[mta] typenameB */ lua_rawget(L,-2); /* stack: super super[mta] bool */ result = lua_toboolean(L,-1); lua_pop(L,3); } return result; } /* Push and returns the corresponding object typename */ TOLUA_API const char* tolua_typename (lua_State* L, int lo) { int tag = lua_type(L,lo); if (tag == LUA_TNONE) lua_pushstring(L,"[no object]"); else if (tag != LUA_TUSERDATA && tag != LUA_TTABLE) lua_pushstring(L,lua_typename(L,tag)); else if (tag == LUA_TUSERDATA) { if (!lua_getmetatable(L,lo)) lua_pushstring(L,lua_typename(L,tag)); else { lua_rawget(L,LUA_REGISTRYINDEX); if (!lua_isstring(L,-1)) { lua_pop(L,1); lua_pushstring(L,"[undefined]"); } } } else /* is table */ { lua_pushvalue(L,lo); lua_rawget(L,LUA_REGISTRYINDEX); if (!lua_isstring(L,-1)) { lua_pop(L,1); lua_pushstring(L,"table"); } else { lua_pushstring(L,"class "); lua_insert(L,-2); lua_concat(L,2); } } return lua_tostring(L,-1); } TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err) { if (msg[0] == '#') { const char* expected = err->type; const char* provided = tolua_typename(L,err->index); if (msg[1]=='f') { int narg = err->index; if (err->array) luaL_error(L,"%s\n argument #%d is array of '%s'; array of '%s' expected.\n", msg+2,narg,provided,expected); else luaL_error(L,"%s\n argument #%d is '%s'; '%s' expected.\n", msg+2,narg,provided,expected); } else if (msg[1]=='v') { if (err->array) luaL_error(L,"%s\n value is array of '%s'; array of '%s' expected.\n", msg+2,provided,expected); else luaL_error(L,"%s\n value is '%s'; '%s' expected.\n", msg+2,provided,expected); } } else luaL_error(L,msg); } /* the equivalent of lua_is* for usertable */ static int lua_isusertable (lua_State* L, int lo, const char* type) { int r = 0; if (lo < 0) lo = lua_gettop(L)+lo+1; lua_pushvalue(L,lo); lua_rawget(L,LUA_REGISTRYINDEX); /* get registry[t] */ if (lua_isstring(L,-1)) { r = strcmp(lua_tostring(L,-1),type)==0; if (!r) { /* try const */ lua_pushstring(L,"const "); lua_insert(L,-2); lua_concat(L,2); r = lua_isstring(L,-1) && strcmp(lua_tostring(L,-1),type)==0; } } lua_pop(L, 1); return r; } int push_table_instance(lua_State* L, int lo) { if (lua_istable(L, lo)) { lua_pushstring(L, ".c_instance"); lua_gettable(L, lo); if (lua_isuserdata(L, -1)) { lua_replace(L, lo); return 1; } else { lua_pop(L, 1); return 0; }; } else { return 0; }; return 0; }; /* the equivalent of lua_is* for usertype */ int lua_isusertype (lua_State* L, int lo, const char* type) { if (!lua_isuserdata(L,lo)) { if (!push_table_instance(L, lo)) { return 0; }; }; { /* check if it is of the same type */ int r; const char *tn; if (lua_getmetatable(L,lo)) /* if metatable? */ { lua_rawget(L,LUA_REGISTRYINDEX); /* get registry[mt] */ tn = lua_tostring(L,-1); r = tn && (strcmp(tn,type) == 0); lua_pop(L, 1); if (r) return 1; else { /* check if it is a specialized class */ lua_pushstring(L,"tolua_super"); lua_rawget(L,LUA_REGISTRYINDEX); /* get super */ lua_getmetatable(L,lo); lua_rawget(L,-2); /* get super[mt] */ if (lua_istable(L,-1)) { int b; lua_pushstring(L,type); lua_rawget(L,-2); /* get super[mt][type] */ b = lua_toboolean(L,-1); lua_pop(L,3); if (b) return 1; } } } } return 0; } TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err) { if (lua_gettop(L)index = lo; err->array = 0; err->type = "[no object]"; return 0; } TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err) { if (def && lua_gettop(L)index = lo; err->array = 0; err->type = "boolean"; return 0; } TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err) { if (def && lua_gettop(L)index = lo; err->array = 0; err->type = "number"; return 0; } TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err) { if (def && lua_gettop(L)index = lo; err->array = 0; err->type = "string"; return 0; } TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err) { if (def && lua_gettop(L)index = lo; err->array = 0; err->type = "table"; return 0; } TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err) { if (def && lua_gettop(L)index = lo; err->array = 0; err->type = type; return 0; } TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err) { if (def && lua_gettop(L)index = lo; err->array = 0; err->type = "userdata"; return 0; } TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err) { if (lua_gettop(L)index = lo; err->array = 0; err->type = "value"; return 1; }; TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err) { if (def || abs(lo)<=lua_gettop(L)) /* any valid index */ return 1; err->index = lo; err->array = 0; err->type = "value"; return 0; } TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err) { if (def && lua_gettop(L)index = lo; err->array = 0; err->type = type; return 0; } TOLUA_API int tolua_isvaluearray (lua_State* L, int lo, int dim, int def, tolua_Error* err) { if (!tolua_istable(L,lo,def,err)) return 0; else return 1; } TOLUA_API int tolua_isbooleanarray (lua_State* L, int lo, int dim, int def, tolua_Error* err) { if (!tolua_istable(L,lo,def,err)) return 0; else { int i; for (i=1; i<=dim; ++i) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "boolean"; return 0; } lua_pop(L,1); } } return 1; } TOLUA_API int tolua_isnumberarray (lua_State* L, int lo, int dim, int def, tolua_Error* err) { if (!tolua_istable(L,lo,def,err)) return 0; else { int i; for (i=1; i<=dim; ++i) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!lua_isnumber(L,-1) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "number"; return 0; } lua_pop(L,1); } } return 1; } TOLUA_API int tolua_isstringarray (lua_State* L, int lo, int dim, int def, tolua_Error* err) { if (!tolua_istable(L,lo,def,err)) return 0; else { int i; for (i=1; i<=dim; ++i) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "string"; return 0; } lua_pop(L,1); } } return 1; } TOLUA_API int tolua_istablearray (lua_State* L, int lo, int dim, int def, tolua_Error* err) { if (!tolua_istable(L,lo,def,err)) return 0; else { int i; for (i=1; i<=dim; ++i) { lua_pushnumber(L,i); lua_gettable(L,lo); if (! lua_istable(L,-1) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "table"; return 0; } lua_pop(L,1); } } return 1; } TOLUA_API int tolua_isuserdataarray (lua_State* L, int lo, int dim, int def, tolua_Error* err) { if (!tolua_istable(L,lo,def,err)) return 0; else { int i; for (i=1; i<=dim; ++i) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "userdata"; return 0; } lua_pop(L,1); } } return 1; } TOLUA_API int tolua_isusertypearray (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err) { if (!tolua_istable(L,lo,def,err)) return 0; else { int i; for (i=1; i<=dim; ++i) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->type = type; err->array = 1; return 0; } lua_pop(L,1); } } return 1; } #if 0 int tolua_isbooleanfield (lua_State* L, int lo, int i, int def, tolua_Error* err) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "boolean"; return 0; } lua_pop(L,1); return 1; } int tolua_isnumberfield (lua_State* L, int lo, int i, int def, tolua_Error* err) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!lua_isnumber(L,-1) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "number"; return 0; } lua_pop(L,1); return 1; } int tolua_isstringfield (lua_State* L, int lo, int i, int def, tolua_Error* err) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "string"; return 0; } lua_pop(L,1); return 1; } int tolua_istablefield (lua_State* L, int lo, int i, int def, tolua_Error* err) { lua_pushnumber(L,i+1); lua_gettable(L,lo); if (! lua_istable(L,-1) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "table"; return 0; } lua_pop(L,1); } int tolua_isusertablefield (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err) { lua_pushnumber(L,i); lua_gettable(L,lo); if (! lua_isusertable(L,-1,type) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = type; return 0; } lua_pop(L,1); return 1; } int tolua_isuserdatafield (lua_State* L, int lo, int i, int def, tolua_Error* err) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->array = 1; err->type = "userdata"; return 0; } lua_pop(L,1); return 1; } int tolua_isusertypefield (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err) { lua_pushnumber(L,i); lua_gettable(L,lo); if (!(lua_isnil(L,-1) || lua_isusertype(L,-1,type)) && !(def && lua_isnil(L,-1)) ) { err->index = lo; err->type = type; err->array = 1; return 0; } lua_pop(L,1); return 1; } #endif ================================================ FILE: cocos2d/external/lua/tolua/tolua_map.c ================================================ /* tolua: functions to map features ** Support code for Lua bindings. ** Written by Waldemar Celes ** TeCGraf/PUC-Rio ** Apr 2003 ** $Id: $ */ /* This code is free software; you can redistribute it and/or modify it. ** The software provided hereunder is on an "as is" basis, and ** the author has no obligation to provide maintenance, support, updates, ** enhancements, or modifications. */ #include "tolua++.h" #include "tolua_event.h" #include "lauxlib.h" #include #include #include #include /* Create metatable * Create and register new metatable */ static int tolua_newmetatable (lua_State* L, const char* name) { int r = luaL_newmetatable(L,name); #ifdef LUA_VERSION_NUM /* only lua 5.1 */ if (r) { lua_pushvalue(L, -1); lua_pushstring(L, name); lua_settable(L, LUA_REGISTRYINDEX); /* reg[mt] = type_name */ }; #endif if (r) tolua_classevents(L); /* set meta events */ lua_pop(L,1); return r; } /* Map super classes * It sets 'name' as being also a 'base', mapping all super classes of 'base' in 'name' */ static void mapsuper (lua_State* L, const char* name, const char* base) { /* push registry.super */ lua_pushstring(L,"tolua_super"); lua_rawget(L,LUA_REGISTRYINDEX); /* stack: super */ luaL_getmetatable(L,name); /* stack: super mt */ lua_rawget(L,-2); /* stack: super table */ if (lua_isnil(L,-1)) { /* create table */ lua_pop(L,1); lua_newtable(L); /* stack: super table */ luaL_getmetatable(L,name); /* stack: super table mt */ lua_pushvalue(L,-2); /* stack: super table mt table */ lua_rawset(L,-4); /* stack: super table */ } /* set base as super class */ lua_pushstring(L,base); lua_pushboolean(L,1); lua_rawset(L,-3); /* stack: super table */ /* set all super class of base as super class of name */ luaL_getmetatable(L,base); /* stack: super table base_mt */ lua_rawget(L,-3); /* stack: super table base_table */ if (lua_istable(L,-1)) { /* traverse base table */ lua_pushnil(L); /* first key */ while (lua_next(L,-2) != 0) { /* stack: ... base_table key value */ lua_pushvalue(L,-2); /* stack: ... base_table key value key */ lua_insert(L,-2); /* stack: ... base_table key key value */ lua_rawset(L,-5); /* stack: ... base_table key */ } } lua_pop(L,3); /* stack: */ } /* creates a 'tolua_ubox' table for base clases, and // expects the metatable and base metatable on the stack */ static void set_ubox(lua_State* L) { /* mt basemt */ if (!lua_isnil(L, -1)) { lua_pushstring(L, "tolua_ubox"); lua_rawget(L,-2); } else { lua_pushnil(L); }; /* mt basemt base_ubox */ if (!lua_isnil(L,-1)) { lua_pushstring(L, "tolua_ubox"); lua_insert(L, -2); /* mt basemt key ubox */ lua_rawset(L,-4); /* (mt with ubox) basemt */ } else { /* mt basemt nil */ lua_pop(L, 1); lua_pushstring(L,"tolua_ubox"); lua_newtable(L); /* make weak value metatable for ubox table to allow userdata to be garbage-collected */ lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3); /* stack: string ubox mt */ lua_setmetatable(L, -2); /* stack:mt basemt string ubox */ lua_rawset(L,-4); }; }; /* Map inheritance * It sets 'name' as derived from 'base' by setting 'base' as metatable of 'name' */ static void mapinheritance (lua_State* L, const char* name, const char* base) { /* set metatable inheritance */ luaL_getmetatable(L,name); if (base && *base) luaL_getmetatable(L,base); else { if (lua_getmetatable(L, -1)) { /* already has a mt, we don't overwrite it */ lua_pop(L, 2); return; }; luaL_getmetatable(L,"tolua_commonclass"); }; set_ubox(L); lua_setmetatable(L,-2); lua_pop(L,1); } /* Object type */ static int tolua_bnd_type (lua_State* L) { tolua_typename(L,lua_gettop(L)); return 1; } /* Take ownership */ static int tolua_bnd_takeownership (lua_State* L) { int success = 0; if (lua_isuserdata(L,1)) { if (lua_getmetatable(L,1)) /* if metatable? */ { lua_pop(L,1); /* clear metatable off stack */ /* force garbage collection to avoid C to reuse a to-be-collected address */ #ifdef LUA_VERSION_NUM lua_gc(L, LUA_GCCOLLECT, 0); #else lua_setgcthreshold(L,0); #endif success = tolua_register_gc(L,1); } } lua_pushboolean(L,success!=0); return 1; } /* Release ownership */ static int tolua_bnd_releaseownership (lua_State* L) { int done = 0; if (lua_isuserdata(L,1)) { void* u = *((void**)lua_touserdata(L,1)); /* force garbage collection to avoid releasing a to-be-collected address */ #ifdef LUA_VERSION_NUM lua_gc(L, LUA_GCCOLLECT, 0); #else lua_setgcthreshold(L,0); #endif lua_pushstring(L,"tolua_gc"); lua_rawget(L,LUA_REGISTRYINDEX); lua_pushlightuserdata(L,u); lua_rawget(L,-2); lua_getmetatable(L,1); if (lua_rawequal(L,-1,-2)) /* check that we are releasing the correct type */ { lua_pushlightuserdata(L,u); lua_pushnil(L); lua_rawset(L,-5); done = 1; } } lua_pushboolean(L,done!=0); return 1; } /* Type casting */ int tolua_bnd_cast (lua_State* L) { /* // old code void* v = tolua_tousertype(L,1,NULL); const char* s = tolua_tostring(L,2,NULL); if (v && s) tolua_pushusertype(L,v,s); else lua_pushnil(L); return 1; */ void* v; const char* s; if (lua_islightuserdata(L, 1)) { v = tolua_touserdata(L, 1, NULL); } else { v = tolua_tousertype(L, 1, 0); }; s = tolua_tostring(L,2,NULL); if (v && s) tolua_pushusertype(L,v,s); else lua_pushnil(L); return 1; } /* Test userdata is null */ static int tolua_bnd_isnulluserdata (lua_State* L) { void **ud = (void**)lua_touserdata(L, -1); tolua_pushboolean(L, ud == NULL || *ud == NULL); return 1; } /* Inheritance */ static int tolua_bnd_inherit (lua_State* L) { /* stack: lua object, c object */ lua_pushstring(L, ".c_instance"); lua_pushvalue(L, -2); lua_rawset(L, -4); /* l_obj[".c_instance"] = c_obj */ return 0; }; #ifdef LUA_VERSION_NUM /* lua 5.1 */ static int tolua_bnd_setpeer(lua_State* L) { /* stack: userdata, table */ if (!lua_isuserdata(L, -2)) { lua_pushstring(L, "Invalid argument #1 to setpeer: userdata expected."); lua_error(L); }; if (lua_isnil(L, -1)) { lua_pop(L, 1); lua_pushvalue(L, TOLUA_NOPEER); }; lua_setfenv(L, -2); return 0; }; static int tolua_bnd_getpeer(lua_State* L) { /* stack: userdata */ lua_getfenv(L, -1); if (lua_rawequal(L, -1, TOLUA_NOPEER)) { lua_pop(L, 1); lua_pushnil(L); }; return 1; }; #endif /* static int class_gc_event (lua_State* L); */ TOLUA_API void tolua_open (lua_State* L) { int top = lua_gettop(L); lua_pushstring(L,"tolua_opened"); lua_rawget(L,LUA_REGISTRYINDEX); if (!lua_isboolean(L,-1)) { lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX); // create value root table lua_pushstring(L, TOLUA_VALUE_ROOT); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); #ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */ /* create peer object table */ lua_pushstring(L, "tolua_peers"); lua_newtable(L); /* make weak key metatable for peers indexed by userdata object */ lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "k"); lua_rawset(L, -3); /* stack: string peers mt */ lua_setmetatable(L, -2); /* stack: string peers */ lua_rawset(L,LUA_REGISTRYINDEX); #endif /* create object ptr -> udata mapping table */ lua_pushstring(L,"tolua_ubox"); lua_newtable(L); /* make weak value metatable for ubox table to allow userdata to be garbage-collected */ lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3); /* stack: string ubox mt */ lua_setmetatable(L, -2); /* stack: string ubox */ lua_rawset(L,LUA_REGISTRYINDEX); // /* create object ptr -> class type mapping table */ // lua_pushstring(L, "tolua_ptr2type"); // lua_newtable(L); // lua_rawset(L, LUA_REGISTRYINDEX); lua_pushstring(L,"tolua_super"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX); lua_pushstring(L,"tolua_gc"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX); /* create gc_event closure */ lua_pushstring(L, "tolua_gc_event"); lua_pushstring(L, "tolua_gc"); lua_rawget(L, LUA_REGISTRYINDEX); lua_pushstring(L, "tolua_super"); lua_rawget(L, LUA_REGISTRYINDEX); lua_pushcclosure(L, class_gc_event, 2); lua_rawset(L, LUA_REGISTRYINDEX); tolua_newmetatable(L,"tolua_commonclass"); tolua_module(L,NULL,0); tolua_beginmodule(L,NULL); tolua_module(L,"tolua",0); tolua_beginmodule(L,"tolua"); tolua_function(L,"type",tolua_bnd_type); tolua_function(L,"takeownership",tolua_bnd_takeownership); tolua_function(L,"releaseownership",tolua_bnd_releaseownership); tolua_function(L,"cast",tolua_bnd_cast); tolua_function(L,"isnull",tolua_bnd_isnulluserdata); tolua_function(L,"inherit", tolua_bnd_inherit); #ifdef LUA_VERSION_NUM /* lua 5.1 */ tolua_function(L, "setpeer", tolua_bnd_setpeer); tolua_function(L, "getpeer", tolua_bnd_getpeer); #endif tolua_endmodule(L); tolua_endmodule(L); } lua_settop(L,top); } /* Copy a C object */ TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size) { void* clone = (void*)malloc(size); if (clone) memcpy(clone,value,size); else tolua_error(L,"insuficient memory",NULL); return clone; } /* Default collect function */ TOLUA_API int tolua_default_collect (lua_State* tolua_S) { void* self = tolua_tousertype(tolua_S,1,0); free(self); return 0; } /* Do clone */ TOLUA_API int tolua_register_gc (lua_State* L, int lo) { int success = 1; void *value = *(void **)lua_touserdata(L,lo); lua_pushstring(L,"tolua_gc"); lua_rawget(L,LUA_REGISTRYINDEX); lua_pushlightuserdata(L,value); lua_rawget(L,-2); if (!lua_isnil(L,-1)) /* make sure that object is not already owned */ success = 0; else { lua_pushlightuserdata(L,value); lua_getmetatable(L,lo); lua_rawset(L,-4); } lua_pop(L,2); return success; } /* Register a usertype * It creates the correspoding metatable in the registry, for both 'type' and 'const type'. * It maps 'const type' as being also a 'type' */ TOLUA_API void tolua_usertype (lua_State* L, const char* type) { char ctype[128] = "const "; strncat(ctype,type,120); /* create both metatables */ if (tolua_newmetatable(L,ctype) && tolua_newmetatable(L,type)) mapsuper(L,type,ctype); /* 'type' is also a 'const type' */ } /* Begin module * It pushes the module (or class) table on the stack */ TOLUA_API void tolua_beginmodule (lua_State* L, const char* name) { if (name) { lua_pushstring(L,name); lua_rawget(L,-2); } else lua_pushvalue(L,LUA_GLOBALSINDEX); } /* End module * It pops the module (or class) from the stack */ TOLUA_API void tolua_endmodule (lua_State* L) { lua_pop(L,1); } /* Map module * It creates a new module */ #if 1 TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar) { if (name) { /* tolua module */ lua_pushstring(L,name); lua_rawget(L,-2); if (!lua_istable(L,-1)) /* check if module already exists */ { lua_pop(L,1); lua_newtable(L); lua_pushstring(L,name); lua_pushvalue(L,-2); lua_rawset(L,-4); /* assing module into module */ } } else { /* global table */ lua_pushvalue(L,LUA_GLOBALSINDEX); } if (hasvar) { if (!tolua_ismodulemetatable(L)) /* check if it already has a module metatable */ { /* create metatable to get/set C/C++ variable */ lua_newtable(L); tolua_moduleevents(L); if (lua_getmetatable(L,-2)) lua_setmetatable(L,-2); /* set old metatable as metatable of metatable */ lua_setmetatable(L,-2); } } lua_pop(L,1); /* pop module */ } #else TOLUA_API void tolua_module (lua_State* L, const char* name, int hasvar) { if (name) { /* tolua module */ lua_pushstring(L,name); lua_newtable(L); } else { /* global table */ lua_pushvalue(L,LUA_GLOBALSINDEX); } if (hasvar) { /* create metatable to get/set C/C++ variable */ lua_newtable(L); tolua_moduleevents(L); if (lua_getmetatable(L,-2)) lua_setmetatable(L,-2); /* set old metatable as metatable of metatable */ lua_setmetatable(L,-2); } if (name) lua_rawset(L,-3); /* assing module into module */ else lua_pop(L,1); /* pop global table */ } #endif static void push_collector(lua_State* L, const char* type, lua_CFunction col) { /* push collector function, but only if it's not NULL, or if there's no collector already */ if (!col) return; luaL_getmetatable(L,type); lua_pushstring(L,".collector"); /* if (!col) { lua_pushvalue(L, -1); lua_rawget(L, -3); if (!lua_isnil(L, -1)) { lua_pop(L, 3); return; }; lua_pop(L, 1); }; // */ lua_pushcfunction(L,col); lua_rawset(L,-3); lua_pop(L, 1); }; /* Map C class * It maps a C class, setting the appropriate inheritance and super classes. */ TOLUA_API void tolua_cclass (lua_State* L, const char* lname, const char* name, const char* base, lua_CFunction col) { char cname[128] = "const "; char cbase[128] = "const "; strncat(cname,name,120); strncat(cbase,base,120); mapinheritance(L,name,base); mapinheritance(L,cname,name); mapsuper(L,cname,cbase); mapsuper(L,name,base); lua_pushstring(L,lname); push_collector(L, name, col); /* luaL_getmetatable(L,name); lua_pushstring(L,".collector"); lua_pushcfunction(L,col); lua_rawset(L,-3); */ luaL_getmetatable(L,name); lua_rawset(L,-3); /* assign class metatable to module */ /* now we also need to store the collector table for the const instances of the class */ push_collector(L, cname, col); /* luaL_getmetatable(L,cname); lua_pushstring(L,".collector"); lua_pushcfunction(L,col); lua_rawset(L,-3); lua_pop(L,1); */ } /* Add base * It adds additional base classes to a class (for multiple inheritance) * (not for now) */ TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base) { char cname[128] = "const "; char cbase[128] = "const "; strncat(cname,name,120); strncat(cbase,base,120); mapsuper(L,cname,cbase); mapsuper(L,name,base); }; /* Map function * It assigns a function into the current module (or class) */ TOLUA_API void tolua_function (lua_State* L, const char* name, lua_CFunction func) { lua_pushstring(L,name); lua_pushcfunction(L,func); lua_rawset(L,-3); } /* sets the __call event for the class (expects the class' main table on top) */ /* never really worked :( TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type) { lua_getmetatable(L, -1); //luaL_getmetatable(L, type); lua_pushstring(L,"__call"); lua_pushcfunction(L,func); lua_rawset(L,-3); lua_pop(L, 1); }; */ /* Map constant number * It assigns a constant number into the current module (or class) */ TOLUA_API void tolua_constant (lua_State* L, const char* name, lua_Number value) { lua_pushstring(L,name); tolua_pushnumber(L,value); lua_rawset(L,-3); } /* Map variable * It assigns a variable into the current module (or class) */ TOLUA_API void tolua_variable (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set) { /* get func */ lua_pushstring(L,".get"); lua_rawget(L,-2); if (!lua_istable(L,-1)) { /* create .get table, leaving it at the top */ lua_pop(L,1); lua_newtable(L); lua_pushstring(L,".get"); lua_pushvalue(L,-2); lua_rawset(L,-4); } lua_pushstring(L,name); lua_pushcfunction(L,get); lua_rawset(L,-3); /* store variable */ lua_pop(L,1); /* pop .get table */ /* set func */ if (set) { lua_pushstring(L,".set"); lua_rawget(L,-2); if (!lua_istable(L,-1)) { /* create .set table, leaving it at the top */ lua_pop(L,1); lua_newtable(L); lua_pushstring(L,".set"); lua_pushvalue(L,-2); lua_rawset(L,-4); } lua_pushstring(L,name); lua_pushcfunction(L,set); lua_rawset(L,-3); /* store variable */ lua_pop(L,1); /* pop .set table */ } } /* Access const array * It reports an error when trying to write into a const array */ static int const_array (lua_State* L) { luaL_error(L,"value of const array cannot be changed"); return 0; } /* Map an array * It assigns an array into the current module (or class) */ TOLUA_API void tolua_array (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set) { lua_pushstring(L,".get"); lua_rawget(L,-2); if (!lua_istable(L,-1)) { /* create .get table, leaving it at the top */ lua_pop(L,1); lua_newtable(L); lua_pushstring(L,".get"); lua_pushvalue(L,-2); lua_rawset(L,-4); } lua_pushstring(L,name); lua_newtable(L); /* create array metatable */ lua_pushvalue(L,-1); lua_setmetatable(L,-2); /* set the own table as metatable (for modules) */ lua_pushstring(L,"__index"); lua_pushcfunction(L,get); lua_rawset(L,-3); lua_pushstring(L,"__newindex"); lua_pushcfunction(L,set?set:const_array); lua_rawset(L,-3); lua_rawset(L,-3); /* store variable */ lua_pop(L,1); /* pop .get table */ } TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name) { #ifdef LUA_VERSION_NUM /* lua 5.1 */ if (!luaL_loadbuffer(L, B, size, name)) lua_pcall(L, 0, 0, 0); #else lua_dobuffer(L, B, size, name); #endif }; ================================================ FILE: cocos2d/external/lua/tolua/tolua_push.c ================================================ /* tolua: functions to push C values. ** Support code for Lua bindings. ** Written by Waldemar Celes ** TeCGraf/PUC-Rio ** Apr 2003 ** $Id: $ */ /* This code is free software; you can redistribute it and/or modify it. ** The software provided hereunder is on an "as is" basis, and ** the author has no obligation to provide maintenance, support, updates, ** enhancements, or modifications. */ #include "tolua++.h" #include "lauxlib.h" #include void tolua_pushusertype_internal (lua_State* L, void* value, const char* type, int addToRoot) { if (value == NULL) lua_pushnil(L); else { luaL_getmetatable(L, type); /* stack: mt */ if (lua_isnil(L, -1)) { /* NOT FOUND metatable */ lua_pop(L, 1); return; } lua_pushstring(L,"tolua_ubox"); lua_rawget(L,-2); /* stack: mt ubox */ if (lua_isnil(L, -1)) { lua_pop(L, 1); lua_pushstring(L, "tolua_ubox"); lua_rawget(L, LUA_REGISTRYINDEX); }; lua_pushlightuserdata(L,value); /* stack: mt ubox key */ lua_rawget(L,-2); /* stack: mt ubox ubox[value] */ if (lua_isnil(L,-1)) { lua_pop(L,1); /* stack: mt ubox */ lua_pushlightuserdata(L,value); *(void**)lua_newuserdata(L,sizeof(void *)) = value; /* stack: mt ubox value newud */ lua_pushvalue(L,-1); /* stack: mt ubox value newud newud */ lua_insert(L,-4); /* stack: mt newud ubox value newud */ lua_rawset(L,-3); /* ubox[value] = newud, stack: mt newud ubox */ lua_pop(L,1); /* stack: mt newud */ /*luaL_getmetatable(L,type);*/ lua_pushvalue(L, -2); /* stack: mt newud mt */ lua_setmetatable(L,-2); /* update mt, stack: mt newud */ #ifdef LUA_VERSION_NUM lua_pushvalue(L, TOLUA_NOPEER); /* stack: mt newud peer */ lua_setfenv(L, -2); /* stack: mt newud */ #endif } else { /* check the need of updating the metatable to a more specialized class */ lua_insert(L,-2); /* stack: mt ubox[u] ubox */ lua_pop(L,1); /* stack: mt ubox[u] */ lua_pushstring(L,"tolua_super"); lua_rawget(L,LUA_REGISTRYINDEX); /* stack: mt ubox[u] super */ lua_getmetatable(L,-2); /* stack: mt ubox[u] super mt */ lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] */ if (lua_istable(L,-1)) { lua_pushstring(L,type); /* stack: mt ubox[u] super super[mt] type */ lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] flag */ if (lua_toboolean(L,-1) == 1) /* if true */ { lua_pop(L,3); /* mt ubox[u]*/ lua_remove(L, -2); return; } } /* type represents a more specilized type */ /*luaL_getmetatable(L,type); // stack: mt ubox[u] super super[mt] flag mt */ lua_pushvalue(L, -5); /* stack: mt ubox[u] super super[mt] flag mt */ lua_setmetatable(L,-5); /* stack: mt ubox[u] super super[mt] flag */ lua_pop(L,3); /* stack: mt ubox[u] */ } lua_remove(L, -2); /* stack: ubox[u]*/ if (0 != addToRoot) { lua_pushvalue(L, -1); tolua_add_value_to_root(L, value); } } } TOLUA_API void tolua_pushvalue (lua_State* L, int lo) { lua_pushvalue(L,lo); } TOLUA_API void tolua_pushboolean (lua_State* L, int value) { lua_pushboolean(L,value); } TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value) { lua_pushnumber(L,value); } TOLUA_API void tolua_pushstring (lua_State* L, const char* value) { if (value == NULL) lua_pushnil(L); else lua_pushstring(L,value); } TOLUA_API void tolua_pushuserdata (lua_State* L, void* value) { if (value == NULL) lua_pushnil(L); else lua_pushlightuserdata(L,value); } TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type) { tolua_pushusertype_internal(L, value, type, 0); } TOLUA_API void tolua_pushusertype_and_addtoroot (lua_State* L, void* value, const char* type) { tolua_pushusertype_internal(L, value, type, 1); } TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, const char* type) { tolua_pushusertype(L,value,type); tolua_register_gc(L,lua_gettop(L)); } TOLUA_API void tolua_add_value_to_root(lua_State* L, void* ptr) { lua_pushstring(L, TOLUA_VALUE_ROOT); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: value root */ lua_insert(L, -2); /* stack: root value */ lua_pushlightuserdata(L, ptr); /* stack: root value ptr */ lua_insert(L, -2); /* stack: root ptr value */ lua_rawset(L, -3); /* root[ptr] = value, stack: root */ lua_pop(L, 1); /* stack: - */ } TOLUA_API void tolua_remove_value_from_root (lua_State* L, void* ptr) { lua_pushstring(L, TOLUA_VALUE_ROOT); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: root */ lua_pushlightuserdata(L, ptr); /* stack: root ptr */ lua_pushnil(L); /* stack: root ptr nil */ lua_rawset(L, -3); /* root[ptr] = nil, stack: root */ lua_pop(L, 1); } TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v) { lua_pushnumber(L,index); lua_pushvalue(L,v); lua_settable(L,lo); } TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v) { lua_pushnumber(L,index); lua_pushboolean(L,v); lua_settable(L,lo); } TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v) { lua_pushnumber(L,index); tolua_pushnumber(L,v); lua_settable(L,lo); } TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v) { lua_pushnumber(L,index); tolua_pushstring(L,v); lua_settable(L,lo); } TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v) { lua_pushnumber(L,index); tolua_pushuserdata(L,v); lua_settable(L,lo); } TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type) { lua_pushnumber(L,index); tolua_pushusertype(L,v,type); lua_settable(L,lo); } TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type) { lua_pushnumber(L,index); tolua_pushusertype(L,v,type); tolua_register_gc(L,lua_gettop(L)); lua_settable(L,lo); } ================================================ FILE: cocos2d/external/lua/tolua/tolua_to.c ================================================ /* tolua: funcitons to convert to C types ** Support code for Lua bindings. ** Written by Waldemar Celes ** TeCGraf/PUC-Rio ** Apr 2003 ** $Id: $ */ /* This code is free software; you can redistribute it and/or modify it. ** The software provided hereunder is on an "as is" basis, and ** the author has no obligation to provide maintenance, support, updates, ** enhancements, or modifications. */ #include "tolua++.h" #include #include TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def) { return lua_gettop(L) defines should NOT be changed. */ #define PNG_INFO_gAMA 0x0001 #define PNG_INFO_sBIT 0x0002 #define PNG_INFO_cHRM 0x0004 #define PNG_INFO_PLTE 0x0008 #define PNG_INFO_tRNS 0x0010 #define PNG_INFO_bKGD 0x0020 #define PNG_INFO_hIST 0x0040 #define PNG_INFO_pHYs 0x0080 #define PNG_INFO_oFFs 0x0100 #define PNG_INFO_tIME 0x0200 #define PNG_INFO_pCAL 0x0400 #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ #define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using * the routines for other purposes. */ typedef struct png_row_info_struct { png_uint_32 width; /* width of row */ png_size_t rowbytes; /* number of bytes in row */ png_byte color_type; /* color type of row */ png_byte bit_depth; /* bit depth of row */ png_byte channels; /* number of channels (1, 2, 3, or 4) */ png_byte pixel_depth; /* bits per pixel (depth * channels) */ } png_row_info; typedef png_row_info * png_row_infop; typedef png_row_info * * png_row_infopp; /* These are the function types for the I/O functions and for the functions * that allow the user to override the default I/O functions with his or her * own. The png_error_ptr type should match that of user-supplied warning * and error functions, while the png_rw_ptr type should match that of the * user read/write data functions. Note that the 'write' function must not * modify the buffer it is passed. The 'read' function, on the other hand, is * expected to return the read data in the buffer. */ typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, int)); typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, int)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); /* The following callback receives png_uint_32 row_number, int pass for the * png_bytep data of the row. When transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, png_uint_32, int)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, png_bytep)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, png_unknown_chunkp)); #endif #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED /* not used anywhere */ /* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ #endif #ifdef PNG_SETJMP_SUPPORTED /* This must match the function definition in , and the application * must include this before png.h to obtain the definition of jmp_buf. The * function is required to be PNG_NORETURN, but this is not checked. If the * function does return the application will crash via an abort() or similar * system level call. * * If you get a warning here while building the library you may need to make * changes to ensure that pnglibconf.h records the calling convention used by * your compiler. This may be very difficult - try using a different compiler * to build the library! */ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); #endif /* Transform masks for the high-level interface */ #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ /* Added to libpng-1.2.34 */ #define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ /* Added to libpng-1.4.0 */ #define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ /* Added to libpng-1.5.4 */ #define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ #define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 /* NOTE: prior to 1.5 these functions had no 'API' style declaration, * this allowed the zlib default functions to be used on Windows * platforms. In 1.5 the zlib default malloc (which just calls malloc and * ignores the first argument) should be completely compatible with the * following. */ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, png_alloc_size_t)); typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); /* Section 3: exported functions * Here are the function definitions most commonly used. This is not * the place to find out how to use libpng. See libpng-manual.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. * * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in * pngconf.h and in the *.dfn files in the scripts directory. * * PNG_EXPORT(ordinal, type, name, (args)); * * ordinal: ordinal that is used while building * *.def files. The ordinal value is only * relevant when preprocessing png.h with * the *.dfn files for building symbol table * entries, and are removed by pngconf.h. * type: return type of the function * name: function name * args: function arguments, with types * * When we wish to append attributes to a function prototype we use * the PNG_EXPORTA() macro instead. * * PNG_EXPORTA(ordinal, type, name, (args), attributes); * * ordinal, type, name, and args: same as in PNG_EXPORT(). * attributes: function attributes */ /* Returns the version number of the library */ PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); /* Tell lib we have already handled the first magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, png_size_t num_to_check)); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ #define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) /* Allocate and initialize png_ptr struct for reading, and any other memory. */ PNG_EXPORTA(4, png_structp, png_create_read_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); /* Allocate and initialize png_ptr struct for writing, and any other memory */ PNG_EXPORTA(5, png_structp, png_create_write_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, (png_const_structrp png_ptr)); PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, png_size_t size)); /* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp * match up. */ #ifdef PNG_SETJMP_SUPPORTED /* This function returns the jmp_buf built in to *png_ptr. It must be * supplied with an appropriate 'longjmp' function to use on that jmp_buf * unless the default error function is overridden in which case NULL is * acceptable. The size of the jmp_buf is checked against the actual size * allocated by the library - the call will return NULL on a mismatch * indicating an ABI mismatch. */ PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); # define png_jmpbuf(png_ptr) \ (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) #else # define png_jmpbuf(png_ptr) \ (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) #endif /* This function should be used by libpng applications in place of * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it * will use it; otherwise it will call PNG_ABORT(). This function was * added in libpng-1.5.0. */ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), PNG_NORETURN); #ifdef PNG_READ_SUPPORTED /* Reset the compression stream */ PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); #endif /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(11, png_structp, png_create_read_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); PNG_EXPORTA(12, png_structp, png_create_write_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); #endif /* Write the PNG file signature. */ PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); /* Write a PNG chunk - size, type, (optional) data, CRC. */ PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep chunk_name, png_const_bytep data, png_size_t length)); /* Write the start of a PNG chunk - length and chunk name. */ PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, png_const_bytep chunk_name, png_uint_32 length)); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, png_const_bytep data, png_size_t length)); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); /* Allocate and initialize the info structure */ PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), PNG_ALLOCATED); /* DEPRECATED: this function allowed init structures to be created using the * default allocation method (typically malloc). Use is deprecated in 1.6.0 and * the API will be removed in the future. */ PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, png_size_t png_info_struct_size), PNG_DEPRECATED); /* Writes all the PNG information before the image. */ PNG_EXPORT(20, void, png_write_info_before_PLTE, (png_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(21, void, png_write_info, (png_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. */ PNG_EXPORT(22, void, png_read_info, (png_structrp png_ptr, png_inforp info_ptr)); #endif #ifdef PNG_TIME_RFC1123_SUPPORTED /* Convert to a US string format: there is no localization support in this * routine. The original implementation used a 29 character buffer in * png_struct, this will be removed in future versions. */ #if PNG_LIBPNG_VER < 10700 /* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, png_const_timep ptime),PNG_DEPRECATED); #endif PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], png_const_timep ptime)); #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Convert from a struct tm to png_time */ PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, const struct tm * ttime)); /* Convert from time_t to png_time. Uses gmtime() */ PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); #endif /* PNG_CONVERT_tIME_SUPPORTED */ #ifdef PNG_READ_EXPAND_SUPPORTED /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); #endif #ifdef PNG_READ_EXPAND_16_SUPPORTED /* Expand to 16-bit channels, forces conversion of palette to RGB and expansion * of a tRNS chunk if present. */ PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Expand the grayscale to 24-bit RGB if necessary. */ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); #endif #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED /* Reduce RGB to grayscale. */ #define PNG_ERROR_ACTION_NONE 1 #define PNG_ERROR_ACTION_WARN 2 #define PNG_ERROR_ACTION_ERROR 3 #define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, int error_action, double red, double green)) PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)) PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp png_ptr)); #endif #ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, png_colorp palette)); #endif #ifdef PNG_READ_ALPHA_MODE_SUPPORTED /* How the alpha channel is interpreted - this affects how the color channels of * a PNG file are returned when an alpha channel, or tRNS chunk in a palette * file, is present. * * This has no effect on the way pixels are written into a PNG output * datastream. The color samples in a PNG datastream are never premultiplied * with the alpha samples. * * The default is to return data according to the PNG specification: the alpha * channel is a linear measure of the contribution of the pixel to the * corresponding composited pixel. The gamma encoded color channels must be * scaled according to the contribution and to do this it is necessary to undo * the encoding, scale the color values, perform the composition and reencode * the values. This is the 'PNG' mode. * * The alternative is to 'associate' the alpha with the color information by * storing color channel values that have been scaled by the alpha. The * advantage is that the color channels can be resampled (the image can be * scaled) in this form. The disadvantage is that normal practice is to store * linear, not (gamma) encoded, values and this requires 16-bit channels for * still images rather than the 8-bit channels that are just about sufficient if * gamma encoding is used. In addition all non-transparent pixel values, * including completely opaque ones, must be gamma encoded to produce the final * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the * latter being the two common names for associated alpha color channels.) * * Since it is not necessary to perform arithmetic on opaque color values so * long as they are not to be resampled and are in the final color space it is * possible to optimize the handling of alpha by storing the opaque pixels in * the PNG format (adjusted for the output color space) while storing partially * opaque pixels in the standard, linear, format. The accuracy required for * standard alpha composition is relatively low, because the pixels are * isolated, therefore typically the accuracy loss in storing 8-bit linear * values is acceptable. (This is not true if the alpha channel is used to * simulate transparency over large areas - use 16 bits or the PNG mode in * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is * treated as opaque only if the alpha value is equal to the maximum value. * * The final choice is to gamma encode the alpha channel as well. This is * broken because, in practice, no implementation that uses this choice * correctly undoes the encoding before handling alpha composition. Use this * choice only if other serious errors in the software or hardware you use * mandate it; the typical serious error is for dark halos to appear around * opaque areas of the composited PNG image because of arithmetic overflow. * * The API function png_set_alpha_mode specifies which of these choices to use * with an enumerated 'mode' value and the gamma of the required output: */ #define PNG_ALPHA_PNG 0 /* according to the PNG standard */ #define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ #define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ #define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ #define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ #define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, double output_gamma)) PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, int mode, png_fixed_point output_gamma)) #endif #if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) /* The output_gamma value is a screen gamma in libpng terminology: it expresses * how to decode the output values, not how they are encoded. The values used * correspond to the normal numbers used to describe the overall gamma of a * computer display system; for example 2.2 for an sRGB conformant system. The * values are scaled by 100000 in the _fixed version of the API (so 220000 for * sRGB.) * * The inverse of the value is always used to provide a default for the PNG file * encoding if it has no gAMA chunk and if png_set_gamma() has not been called * to override the PNG gamma information. * * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode * opaque pixels however pixels with lower alpha values are not encoded, * regardless of the output gamma setting. * * When the standard Porter Duff handling is requested with mode 1 the output * encoding is set to be linear and the output_gamma value is only relevant * as a default for input data that has no gamma information. The linear output * encoding will be overridden if png_set_gamma() is called - the results may be * highly unexpected! * * The following numbers are derived from the sRGB standard and the research * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing * correction required to take account of any differences in the color * environment of the original scene and the intended display environment; the * value expresses how to *decode* the image for display, not how the original * data was *encoded*. * * sRGB provides a peg for the PNG standard by defining a viewing environment. * sRGB itself, and earlier TV standards, actually use a more complex transform * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is * limited to simple power laws.) By saying that an image for direct display on * an sRGB conformant system should be stored with a gAMA chunk value of 45455 * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification * makes it possible to derive values for other display systems and * environments. * * The Mac value is deduced from the sRGB based on an assumption that the actual * extra viewing correction used in early Mac display systems was implemented as * a power 1.45 lookup table. * * Any system where a programmable lookup table is used or where the behavior of * the final display device characteristics can be changed requires system * specific code to obtain the current characteristic. However this can be * difficult and most PNG gamma correction only requires an approximate value. * * By default, if png_set_alpha_mode() is not called, libpng assumes that all * values are unencoded, linear, values and that the output device also has a * linear characteristic. This is only very rarely correct - it is invariably * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the * default if you don't know what the right answer is! * * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS * 10.6) which used a correction table to implement a somewhat lower gamma on an * otherwise sRGB system. * * Both these values are reserved (not simple gamma values) in order to allow * more precise correction internally in the future. * * NOTE: the following values can be passed to either the fixed or floating * point APIs, but the floating point API will also accept floating point * values. */ #define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ #define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ #define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ #define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ #endif /* The following are examples of calls to png_set_alpha_mode to achieve the * required overall gamma correction and, where necessary, alpha * premultiplication. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * This is the default libpng handling of the alpha channel - it is not * pre-multiplied into the color components. In addition the call states * that the output is for a sRGB system and causes all PNG files without gAMA * chunks to be assumed to be encoded using sRGB. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * In this case the output is assumed to be something like an sRGB conformant * display preceeded by a power-law lookup table of power 1.45. This is how * early Mac systems behaved. * * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); * This is the classic Jim Blinn approach and will work in academic * environments where everything is done by the book. It has the shortcoming * of assuming that input PNG data with no gamma information is linear - this * is unlikely to be correct unless the PNG files where generated locally. * Most of the time the output precision will be so low as to show * significant banding in dark areas of the image. * * png_set_expand_16(pp); * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); * This is a somewhat more realistic Jim Blinn inspired approach. PNG files * are assumed to have the sRGB encoding if not marked with a gamma value and * the output is always 16 bits per component. This permits accurate scaling * and processing of the data. If you know that your input PNG files were * generated locally you might need to replace PNG_DEFAULT_sRGB with the * correct value for your system. * * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); * If you just need to composite the PNG image onto an existing background * and if you control the code that does this you can use the optimization * setting. In this case you just copy completely opaque pixels to the * output. For pixels that are not completely transparent (you just skip * those) you do the composition math using png_composite or png_composite_16 * below then encode the resultant 8-bit or 16-bit values to match the output * encoding. * * Other cases * If neither the PNG nor the standard linear encoding work for you because * of the software or hardware you use then you have a big problem. The PNG * case will probably result in halos around the image. The linear encoding * will probably result in a washed out, too bright, image (it's actually too * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably * substantially reduce the halos. Alternatively try: * * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); * This option will also reduce the halos, but there will be slight dark * halos round the opaque parts of the image where the background is light. * In the OPTIMIZED mode the halos will be light halos where the background * is dark. Take your pick - the halos are unavoidable unless you can get * your hardware/software fixed! (The OPTIMIZED approach is slightly * faster.) * * When the default gamma of PNG files doesn't match the output gamma. * If you have PNG files with no gamma information png_set_alpha_mode allows * you to provide a default gamma, but it also sets the ouput gamma to the * matching value. If you know your PNG files have a gamma that doesn't * match the output you can take advantage of the fact that * png_set_alpha_mode always sets the output gamma but only sets the PNG * default if it is not already set: * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * The first call sets both the default and the output gamma values, the * second call overrides the output gamma without changing the default. This * is easier than achieving the same effect with png_set_gamma. You must use * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will * fire if more than one call to png_set_alpha_mode and png_set_background is * made in the same read operation, however multiple calls with PNG_ALPHA_PNG * are ignored. */ #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ # define PNG_FILLER_BEFORE 0 # define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, png_uint_32 filler, int flags)); #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p true_bits)); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) /* Have the code handle the interlacing. Returns the number of passes. * MUST be called before png_read_update_info or png_start_read_image, * otherwise it will not have the desired effect. Note that it is still * necessary to call png_read_row or png_read_rows png_get_image_height * times for each pass. */ PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED /* Handle alpha and tRNS by replacing with a background color. Prior to * libpng-1.5.4 this API must not be called before the PNG file header has been * read. Doing so will result in unexpected behavior and possible warnings or * errors if the PNG file contains a bKGD chunk. */ PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)) PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)) #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED # define PNG_BACKGROUND_GAMMA_UNKNOWN 0 # define PNG_BACKGROUND_GAMMA_SCREEN 1 # define PNG_BACKGROUND_GAMMA_FILE 2 # define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* Scale a 16-bit depth file down to 8-bit, accurately. */ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ /* Strip the second byte of information from a 16-bit depth file. */ PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_QUANTIZE_SUPPORTED /* Turn on quantizing, and reduce the palette to the number of colors * available. */ PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize)); #endif #ifdef PNG_READ_GAMMA_SUPPORTED /* The threshold on gamma processing is configurable but hard-wired into the * library. The following is the floating point variant. */ #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) /* Handle gamma correction. Screen_gamma=(display_exponent). * NOTE: this API simply sets the screen and file gamma values. It will * therefore override the value for gamma in a PNG file if it is called after * the file header has been read - use with care - call before reading the PNG * file for best results! * * These routines accept the same gamma values as png_set_alpha_mode (described * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either * API (floating point or fixed.) Notice, however, that the 'file_gamma' value * is the inverse of a 'screen gamma' value. */ PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, double screen_gamma, double override_file_gamma)) PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) #endif #ifdef PNG_WRITE_FLUSH_SUPPORTED /* Set how many lines between output flushes - 0 for no flushing */ PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); /* Flush the current PNG output buffer */ PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); #endif /* Optional update palette with requested transformations */ PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); /* Optional call to update the users info structure */ PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. */ PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read a row of data. */ PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, png_bytep display_row)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the whole image into memory at once. */ PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); #endif /* Write a row of image data */ PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, png_const_bytep row)); /* Write a few rows of image data: (*row) is not written; however, the type * is declared as writeable to maintain compatibility with previous versions * of libpng and to allow the 'display_row' array from read_rows to be passed * unchanged to write_rows. */ PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, png_uint_32 num_rows)); /* Write the image data */ PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); /* Write the end of the PNG file. */ PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. */ PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); #endif /* Free any memory associated with the png_info_struct */ PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, png_infopp info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); /* Set the libpng method of handling chunk CRC errors */ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, int ancil_action)); /* Values for png_set_crc_action() say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical * chunk. For versions prior to 0.90, the action was always error/quit, * whereas in version 0.90 and later, the action for CRC errors in ancillary * chunks is warn/discard. These values should NOT be changed. * * value action:critical action:ancillary */ #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ /* These functions give the user control over the scan-line filtering in * libpng and the compression methods used by zlib. These functions are * mainly useful for testing, as the defaults should work with most users. * Those users who are tight on memory or want faster performance at the * expense of compression can modify them. See the compression library * header file (zlib.h) for an explination of the compression functions. */ /* Set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, int filters)); /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types * below, in case they are supplied instead of the #defined constants. * These values should NOT be changed. */ #define PNG_NO_FILTERS 0x00 #define PNG_FILTER_NONE 0x08 #define PNG_FILTER_SUB 0x10 #define PNG_FILTER_UP 0x20 #define PNG_FILTER_AVG 0x40 #define PNG_FILTER_PAETH 0x80 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ PNG_FILTER_AVG | PNG_FILTER_PAETH) /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. * These defines should NOT be changed. */ #define PNG_FILTER_VALUE_NONE 0 #define PNG_FILTER_VALUE_SUB 1 #define PNG_FILTER_VALUE_UP 2 #define PNG_FILTER_VALUE_AVG 3 #define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_LAST 5 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ * defines, either the default (minimum-sum-of-absolute-differences), or * the experimental method (weighted-minimum-sum-of-absolute-differences). * * Weights are factors >= 1.0, indicating how important it is to keep the * filter type consistent between rows. Larger numbers mean the current * filter is that many times as likely to be the same as the "num_weights" * previous filters. This is cumulative for each previous row with a weight. * There needs to be "num_weights" values in "filter_weights", or it can be * NULL if the weights aren't being specified. Weights have no influence on * the selection of the first row filter. Well chosen weights can (in theory) * improve the compression for a given image. * * Costs are factors >= 1.0 indicating the relative decoding costs of a * filter type. Higher costs indicate more decoding expense, and are * therefore less likely to be selected over a filter with lower computational * costs. There needs to be a value in "filter_costs" for each valid filter * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't * setting the costs. Costs try to improve the speed of decompression without * unduly increasing the compressed image size. * * A negative weight or cost indicates the default value is to be used, and * values in the range [0.0, 1.0) indicate the value is to remain unchanged. * The default values for both weights and costs are currently 1.0, but may * change if good general weighting/cost heuristics can be found. If both * the weights and costs are set to 1.0, this degenerates the WEIGHTED method * to the UNWEIGHTED method, but with added encoding time/computation. */ PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_doublep filter_weights, png_const_doublep filter_costs)) PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_fixed_point_p filter_weights, png_const_fixed_point_p filter_costs)) #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be * changed. */ #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ #ifdef PNG_WRITE_SUPPORTED /* Set the library compression level. Currently, valid values range from * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have * shown that zlib compression levels 3-6 usually perform as well as level 9 * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, int method)); #endif #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED /* Also set zlib parameters for compressing non-IDAT chunks */ PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, int method)); #endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and * fprintf(). These functions can be made to use other I/O routines * at run time for those applications that need to handle I/O in a * different manner by calling png_set_???_fn(). See libpng-manual.txt for * more information. */ #ifdef PNG_STDIO_SUPPORTED /* Initialize the input/output for the PNG file to the default functions. */ PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); #endif /* Replace the (error and abort), and warning functions with user * supplied functions. If no messages are to be printed you must still * write and use replacement functions. The replacement error_fn should * still do a longjmp to the last setjmp location if you are using this * method of error handling. If error_fn or warning_fn is NULL, the * default function will be used. */ PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); /* Return the user pointer associated with the error functions */ PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). * It is probably a mistake to use NULL for output_flush_fn if * write_data_fn is not also NULL unless you have built libpng with * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's * default flush function, which uses the standard *FILE structure, will * be used. */ PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); /* Replace the default data input function with a user supplied one. */ PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)); /* Return the user pointer associated with the I/O functions */ PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, png_read_status_ptr read_row_fn)); PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, png_write_status_ptr write_row_fn)); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); /* Return the user pointer associated with the memory functions */ PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn)); #endif #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr write_user_transform_fn)); #endif #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)); /* Return the user pointer associated with the user transform functions */ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED /* Return information about the row currently being processed. Note that these * APIs do not fail but will return unexpected results if called outside a user * transform callback. Also note that when transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); #endif #ifdef PNG_READ_USER_CHUNKS_SUPPORTED /* This callback is called only for *unknown* chunks. If * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known * chunks to be treated as unknown, however in this case the callback must do * any processing required by the chunk (e.g. by calling the appropriate * png_set_ APIs.) * * There is no write support - on write, by default, all the chunks in the * 'unknown' list are written in the specified position. * * The integer return from the callback function is interpreted thus: * * negative: An error occured, png_chunk_error will be called. * zero: The chunk was not handled, the chunk will be saved. A critical * chunk will cause an error at this point unless it is to be saved. * positive: The chunk was handled, libpng will ignore/discard it. * * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about * how this behavior will change in libpng 1.7 */ PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); /* Returns the user pointer associated with the push read functions */ PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structrp png_ptr)); /* Function to be called when data becomes available */ PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)); /* A function which may be called *only* within png_process_data to stop the * processing of any more data. The function returns the number of bytes * remaining, excluding any that libpng has cached internally. A subsequent * call to png_process_data must supply these bytes again. If the argument * 'save' is set to true the routine will first save all the pending data and * will always return 0. */ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); /* A function which may be called *only* outside (after) a call to * png_process_data. It returns the number of bytes of data to skip in the * input. Normally it will return 0, but if it returns a non-zero value the * application must skip than number of bytes of input data and pass the * following data to the next call to png_process_data. */ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); #ifdef PNG_READ_INTERLACING_SUPPORTED /* Function that combines rows. 'new_row' is a flag that should come from * the callback and be non-NULL if anything needs to be done; the library * stores its own version of the new data internally and ignores the passed * in value. */ PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, png_bytep old_row, png_const_bytep new_row)); #endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.4.0 */ PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.2.4 */ PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Frees a pointer allocated by png_malloc() */ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); /* Free data that was allocated internally */ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 free_me, int num)); /* Reassign responsibility for freeing existing data, whether allocated * by libpng or by the application; this works on the png_info structure passed * in, it does not change the state for other png_info structures. * * It is unlikely that this function works correctly as of 1.6.0 and using it * may result either in memory leaks or double free of allocated data. */ PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr, png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED); /* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 /* Flags for png_ptr->free_me and info_ptr->free_me */ #define PNG_FREE_HIST 0x0008 #define PNG_FREE_ICCP 0x0010 #define PNG_FREE_SPLT 0x0020 #define PNG_FREE_ROWS 0x0040 #define PNG_FREE_PCAL 0x0080 #define PNG_FREE_SCAL 0x0100 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED # define PNG_FREE_UNKN 0x0200 #endif /* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */ #define PNG_FREE_PLTE 0x1000 #define PNG_FREE_TRNS 0x2000 #define PNG_FREE_TEXT 0x4000 #define PNG_FREE_ALL 0x7fff #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, png_voidp ptr), PNG_DEPRECATED); #endif #ifdef PNG_ERROR_TEXT_SUPPORTED /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); /* The same, but the chunk name is prepended to the error string. */ PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); #else /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); #endif #ifdef PNG_WARNINGS_SUPPORTED /* Non-fatal error in libpng. Can continue, but may have a problem. */ PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); /* Non-fatal error in libpng, chunk name is prepended to message. */ PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif #ifdef PNG_BENIGN_ERRORS_SUPPORTED /* Benign error in libpng. Can continue, but may have a problem. * User can choose whether to handle as a fatal error or as a warning. */ PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #ifdef PNG_READ_SUPPORTED /* Same, chunk name is prepended to message (only during read) */ PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif PNG_EXPORT(109, void, png_set_benign_errors, (png_structrp png_ptr, int allowed)); #else # ifdef PNG_ALLOW_BENIGN_ERRORS # define png_benign_error png_warning # define png_chunk_benign_error png_chunk_warning # else # define png_benign_error png_error # define png_chunk_benign_error png_chunk_error # endif #endif /* The png_set_ functions are for storing values in the png_info_struct. * Similarly, the png_get_ calls are used to read values from the * png_info_struct, either storing the parameters in the passed variables, or * setting pointers into the png_info_struct where the data is stored. The * png_get_ functions return a non-zero value if the data was available * in info_ptr, or return zero and do not change any of the parameters if the * data was not available. * * These functions should be used instead of directly accessing png_info * to avoid problems with future changes in the size and internal layout of * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* Returns row_pointers, which is an array of pointers to scanlines that was * returned from png_read_png(). */ PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Set row_pointers, which is an array of pointers to scanlines for use * by png_write_png(). */ PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image height in pixels. */ PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image bit_depth. */ PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image color_type. */ PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image filter_type. */ PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image interlace_type. */ PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image compression_type. */ PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, (png_const_structrp png_ptr, png_const_inforp info_ptr)) PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif /* PNG_EASY_ACCESS_SUPPORTED */ #ifdef PNG_READ_SUPPORTED /* Returns pointer to signature string read from PNG header */ PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_16p *background)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_16p background)); #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)) PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, double *green_X, double *green_Y, double *green_Z, double *blue_X, double *blue_Y, double *blue_Z)) PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_white_x, png_fixed_point *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_red_X, png_fixed_point *int_red_Y, png_fixed_point *int_red_Z, png_fixed_point *int_green_X, png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, png_fixed_point *int_blue_Z)) #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)) PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double red_Y, double red_Z, double green_X, double green_Y, double green_Z, double blue_X, double blue_Y, double blue_Z)) PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, png_fixed_point int_blue_y)) PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, png_fixed_point int_blue_X, png_fixed_point int_blue_Y, png_fixed_point int_blue_Z)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *file_gamma)) PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_file_gamma)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)) PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_file_gamma)) #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_16p *hist)); #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist)); #endif PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)); PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_method, int compression_method, int filter_method)); #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); #endif #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)); PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, png_inforp info_ptr, png_const_colorp palette, int num_palette)); #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_8p *sig_bit)); #endif #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_8p sig_bit)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *file_srgb_intent)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_charpp name, int *compression_type, png_bytepp profile, png_uint_32 *proflen)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp name, int compression_type, png_const_bytep profile, png_uint_32 proflen)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_sPLT_tpp entries)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); #endif #ifdef PNG_TEXT_SUPPORTED /* png_get_text also returns the number of text chunks in *num_text */ PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_textp *text_ptr, int *num_text)); #endif /* Note while png_set_text() will accept a structure whose text, * language, and translated keywords are NULL pointers, the structure * returned by png_get_text will always contain regular * zero-terminated C strings. They might be empty strings but * they will never be NULL pointers. */ #ifdef PNG_TEXT_SUPPORTED PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_timep *mod_time)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_timep mod_time)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)); #endif #ifdef PNG_sCAL_SUPPORTED PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)) #if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ defined(PNG_FLOATING_POINT_SUPPORTED) /* NOTE: this API is currently implemented using floating point arithmetic, * consequently it can only be used on systems with floating point support. * In any case the range of values supported by png_fixed_point is small and it * is highly recommended that png_get_sCAL_s be used instead. */ PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height)) #endif PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, double width, double height)) PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_fixed_point width, png_fixed_point height)) PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)); #endif /* PNG_sCAL_SUPPORTED */ #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED /* Provide the default handling for all unknown chunks or, optionally, for * specific unknown chunks. * * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was * ignored and the default was used, the per-chunk setting only had an effect on * write. If you wish to have chunk-specific handling on read in code that must * work on earlier versions you must use a user chunk callback to specify the * desired handling (keep or discard.) * * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The * parameter is interpreted as follows: * * READ: * PNG_HANDLE_CHUNK_AS_DEFAULT: * Known chunks: do normal libpng processing, do not keep the chunk (but * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) * Unknown chunks: for a specific chunk use the global default, when used * as the default discard the chunk data. * PNG_HANDLE_CHUNK_NEVER: * Discard the chunk data. * PNG_HANDLE_CHUNK_IF_SAFE: * Keep the chunk data if the chunk is not critical else raise a chunk * error. * PNG_HANDLE_CHUNK_ALWAYS: * Keep the chunk data. * * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks * it simply resets the behavior to the libpng default. * * INTERACTION WTIH USER CHUNK CALLBACKS: * The per-chunk handling is always used when there is a png_user_chunk_ptr * callback and the callback returns 0; the chunk is then always stored *unless* * it is critical and the per-chunk setting is other than ALWAYS. Notice that * the global default is *not* used in this case. (In effect the per-chunk * value is incremented to at least IF_SAFE.) * * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and * per-chunk defaults will be honored. If you want to preserve the current * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE * as the default - if you don't do this libpng 1.6 will issue a warning. * * If you want unhandled unknown chunks to be discarded in libpng 1.6 and * earlier simply return '1' (handled). * * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: * If this is *not* set known chunks will always be handled by libpng and * will never be stored in the unknown chunk list. Known chunks listed to * png_set_keep_unknown_chunks will have no effect. If it is set then known * chunks listed with a keep other than AS_DEFAULT will *never* be processed * by libpng, in addition critical chunks must either be processed by the * callback or saved. * * The IHDR and IEND chunks must not be listed. Because this turns off the * default handling for chunks that would otherwise be recognized the * behavior of libpng transformations may well become incorrect! * * WRITE: * When writing chunks the options only apply to the chunks specified by * png_set_unknown_chunks (below), libpng will *always* write known chunks * required by png_set_ calls and will always write the core critical chunks * (as required for PLTE). * * Each chunk in the png_set_unknown_chunks list is looked up in the * png_set_keep_unknown_chunks list to find the keep setting, this is then * interpreted as follows: * * PNG_HANDLE_CHUNK_AS_DEFAULT: * Write safe-to-copy chunks and write other chunks if the global * default is set to _ALWAYS, otherwise don't write this chunk. * PNG_HANDLE_CHUNK_NEVER: * Do not write the chunk. * PNG_HANDLE_CHUNK_IF_SAFE: * Write the chunk if it is safe-to-copy, otherwise do not write it. * PNG_HANDLE_CHUNK_ALWAYS: * Write the chunk. * * Note that the default behavior is effectively the opposite of the read case - * in read unknown chunks are not stored by default, in write they are written * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different * - on write the safe-to-copy bit is checked, on read the critical bit is * checked and on read if the chunk is critical an error will be raised. * * num_chunks: * =========== * If num_chunks is positive, then the "keep" parameter specifies the manner * for handling only those chunks appearing in the chunk_list array, * otherwise the chunk list array is ignored. * * If num_chunks is 0 the "keep" parameter specifies the default behavior for * unknown chunks, as described above. * * If num_chunks is negative, then the "keep" parameter specifies the manner * for handling all unknown chunks plus all chunks recognized by libpng * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to * be processed by libpng. */ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks)); /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; * the result is therefore true (non-zero) if special handling is required, * false for the default handling. */ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, png_const_bytep chunk_name)); #endif #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)); /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added * unknowns to the location currently stored in the png_struct. This is * invariably the wrong value on write. To fix this call the following API * for each chunk in the list with the correct location. If you know your * code won't be compiled on earlier versions you can rely on * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing * the correct thing. */ PNG_EXPORT(175, void, png_set_unknown_chunk_location, (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_unknown_chunkpp entries)); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. * If you need to turn it off for a chunk that your application has freed, * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, png_inforp info_ptr, int mask)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* The "params" pointer is currently not used and is for future expansion. */ PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); #endif PNG_EXPORT(180, png_const_charp, png_get_copyright, (png_const_structrp png_ptr)); PNG_EXPORT(181, png_const_charp, png_get_header_ver, (png_const_structrp png_ptr)); PNG_EXPORT(182, png_const_charp, png_get_header_version, (png_const_structrp png_ptr)); PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, (png_const_structrp png_ptr)); #ifdef PNG_MNG_FEATURES_SUPPORTED PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, png_uint_32 mng_features_permitted)); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 #define PNG_HANDLE_CHUNK_LAST 4 /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, png_uint_32 strip_mode)); #endif /* Added in libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); PNG_EXPORT(187, png_uint_32, png_get_user_width_max, (png_const_structrp png_ptr)); PNG_EXPORT(188, png_uint_32, png_get_user_height_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.0 */ PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)); PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.1 */ PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, png_alloc_size_t user_chunk_cache_max)); PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, (png_const_structrp png_ptr)); #endif #if defined(PNG_INCH_CONVERSIONS_SUPPORTED) PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_FP_EXPORT(196, float, png_get_x_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif # ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); # endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ /* Added in libpng-1.4.0 */ #ifdef PNG_IO_STATE_SUPPORTED PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); /* Removed from libpng 1.6; use png_get_io_chunk_type. */ PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), PNG_DEPRECATED) PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, (png_const_structrp png_ptr)); /* The flags returned by png_get_io_state() are the following: */ # define PNG_IO_NONE 0x0000 /* no I/O at this moment */ # define PNG_IO_READING 0x0001 /* currently reading */ # define PNG_IO_WRITING 0x0002 /* currently writing */ # define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ # define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ # define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ # define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ # define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ # define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ #endif /* ?PNG_IO_STATE_SUPPORTED */ /* Interlace support. The following macros are always defined so that if * libpng interlace handling is turned off the macros may be used to handle * interlaced images within the application. */ #define PNG_INTERLACE_ADAM7_PASSES 7 /* Two macros to return the first row and first column of the original, * full, image which appears in a given pass. 'pass' is in the range 0 * to 6 and the result is in the range 0 to 7. */ #define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) #define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) /* A macro to return the offset between pixels in the output row for a pair of * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that * follows. Note that ROW_OFFSET is the offset from one row to the next whereas * COL_OFFSET is from one column to the next, within a row. */ #define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) #define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) /* Two macros to help evaluate the number of rows or columns in each * pass. This is expressed as a shift - effectively log2 of the number or * rows or columns in each 8x8 tile of the original image. */ #define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) #define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) /* Hence two macros to determine the number of rows or columns in a given * pass of an image given its height or width. In fact these macros may * return non-zero even though the sub-image is empty, because the other * dimension may be empty for a small image. */ #define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) #define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) /* For the reader row callbacks (both progressive and sequential) it is * necessary to find the row in the output image given a row in an interlaced * image, so two more macros: */ #define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ (((y_in)<>(((7-(off))-(pass))<<2)) & 0xF) | \ ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) #define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) #define PNG_COL_IN_INTERLACE_PASS(x, pass) \ ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on * most machines. However, it does take more operations than the corresponding * divide method, so it may be slower on a few RISC systems. There are two * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. * * Note that the rounding factors are NOT supposed to be the same! 128 and * 32768 are correct for the NODIV code; 127 and 32767 are correct for the * standard method. * * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] */ /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ # define png_composite(composite, fg, alpha, bg) \ { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ * (png_uint_16)(alpha) \ + (png_uint_16)(bg)*(png_uint_16)(255 \ - (png_uint_16)(alpha)) + 128); \ (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } # define png_composite_16(composite, fg, alpha, bg) \ { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ * (png_uint_32)(alpha) \ + (png_uint_32)(bg)*(65535 \ - (png_uint_32)(alpha)) + 32768); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } #else /* Standard method using integer division */ # define png_composite(composite, fg, alpha, bg) \ (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ 127) / 255) # define png_composite_16(composite, fg, alpha, bg) \ (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ 32767) / 65535) #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); #endif PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, png_const_bytep buf)); /* No png_get_int_16 -- may be added if there's a real need for it. */ /* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); #endif #ifdef PNG_SAVE_INT_32_SUPPORTED PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); #endif /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); /* No png_save_int_16 -- may be added if there's a real need for it. */ #endif #ifdef PNG_USE_READ_MACROS /* Inline macros to do direct reads of bytes from the input buffer. * The png_get_int_32() routine assumes we are using two's complement * format for negative values, which is almost certainly true. */ # define PNG_get_uint_32(buf) \ (((png_uint_32)(*(buf)) << 24) + \ ((png_uint_32)(*((buf) + 1)) << 16) + \ ((png_uint_32)(*((buf) + 2)) << 8) + \ ((png_uint_32)(*((buf) + 3)))) /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the * function) incorrectly returned a value of type png_uint_32. */ # define PNG_get_uint_16(buf) \ ((png_uint_16) \ (((unsigned int)(*(buf)) << 8) + \ ((unsigned int)(*((buf) + 1))))) # define PNG_get_int_32(buf) \ ((png_int_32)((*(buf) & 0x80) \ ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \ : (png_int_32)png_get_uint_32(buf))) /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, * but defining a macro name prefixed with PNG_PREFIX. */ # ifndef PNG_PREFIX # define png_get_uint_32(buf) PNG_get_uint_32(buf) # define png_get_uint_16(buf) PNG_get_uint_16(buf) # define png_get_int_32(buf) PNG_get_int_32(buf) # endif #else # ifdef PNG_PREFIX /* No macros; revert to the (redefined) function */ # define PNG_get_uint_32 (png_get_uint_32) # define PNG_get_uint_16 (png_get_uint_16) # define PNG_get_int_32 (png_get_int_32) # endif #endif /******************************************************************************* * SIMPLIFIED API ******************************************************************************* * * Please read the documentation in libpng-manual.txt (TODO: write said * documentation) if you don't understand what follows. * * The simplified API hides the details of both libpng and the PNG file format * itself. It allows PNG files to be read into a very limited number of * in-memory bitmap formats or to be written from the same formats. If these * formats do not accomodate your needs then you can, and should, use the more * sophisticated APIs above - these support a wide variety of in-memory formats * and a wide variety of sophisticated transformations to those formats as well * as a wide variety of APIs to manipulate ancillary information. * * To read a PNG file using the simplified API: * * 1) Declare a 'png_image' structure (see below) on the stack and set the * version field to PNG_IMAGE_VERSION. * 2) Call the appropriate png_image_begin_read... function. * 3) Set the png_image 'format' member to the required sample format. * 4) Allocate a buffer for the image and, if required, the color-map. * 5) Call png_image_finish_read to read the image and, if required, the * color-map into your buffers. * * There are no restrictions on the format of the PNG input itself; all valid * color types, bit depths, and interlace methods are acceptable, and the * input image is transformed as necessary to the requested in-memory format * during the png_image_finish_read() step. The only caveat is that if you * request a color-mapped image from a PNG that is full-color or makes * complex use of an alpha channel the transformation is extremely lossy and the * result may look terrible. * * To write a PNG file using the simplified API: * * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. * 2) Initialize the members of the structure that describe the image, setting * the 'format' member to the format of the image samples. * 3) Call the appropriate png_image_write... function with a pointer to the * image and, if necessary, the color-map to write the PNG data. * * png_image is a structure that describes the in-memory format of an image * when it is being read or defines the in-memory format of an image that you * need to write: */ #define PNG_IMAGE_VERSION 1 typedef struct png_control *png_controlp; typedef struct { png_controlp opaque; /* Initialize to NULL, free with png_image_free */ png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ png_uint_32 width; /* Image width in pixels (columns) */ png_uint_32 height; /* Image height in pixels (rows) */ png_uint_32 format; /* Image format as defined below */ png_uint_32 flags; /* A bit mask containing informational flags */ png_uint_32 colormap_entries; /* Number of entries in the color-map */ /* In the event of an error or warning the following field will be set to a * non-zero value and the 'message' field will contain a '\0' terminated * string with the libpng error or warning message. If both warnings and * an error were encountered, only the error is recorded. If there * are multiple warnings, only the first one is recorded. * * The upper 30 bits of this value are reserved, the low two bits contain * a value as follows: */ # define PNG_IMAGE_WARNING 1 # define PNG_IMAGE_ERROR 2 /* * The result is a two bit code such that a value more than 1 indicates * a failure in the API just called: * * 0 - no warning or error * 1 - warning * 2 - error * 3 - error preceded by warning */ # define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) png_uint_32 warning_or_error; char message[64]; } png_image, *png_imagep; /* The samples of the image have one to four channels whose components have * original values in the range 0 to 1.0: * * 1: A single gray or luminance channel (G). * 2: A gray/luminance channel and an alpha channel (GA). * 3: Three red, green, blue color channels (RGB). * 4: Three color channels and an alpha channel (RGBA). * * The components are encoded in one of two ways: * * a) As a small integer, value 0..255, contained in a single byte. For the * alpha channel the original value is simply value/255. For the color or * luminance channels the value is encoded according to the sRGB specification * and matches the 8-bit format expected by typical display devices. * * The color/gray channels are not scaled (pre-multiplied) by the alpha * channel and are suitable for passing to color management software. * * b) As a value in the range 0..65535, contained in a 2-byte integer. All * channels can be converted to the original value by dividing by 65535; all * channels are linear. Color channels use the RGB encoding (RGB end-points) of * the sRGB specification. This encoding is identified by the * PNG_FORMAT_FLAG_LINEAR flag below. * * When the simplified API needs to convert between sRGB and linear colorspaces, * the actual sRGB transfer curve defined in the sRGB specification (see the * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 * approximation used elsewhere in libpng. * * When an alpha channel is present it is expected to denote pixel coverage * of the color or luminance channels and is returned as an associated alpha * channel: the color/gray channels are scaled (pre-multiplied) by the alpha * value. * * The samples are either contained directly in the image data, between 1 and 8 * bytes per pixel according to the encoding, or are held in a color-map indexed * by bytes in the image data. In the case of a color-map the color-map entries * are individual samples, encoded as above, and the image data has one byte per * pixel to select the relevant sample from the color-map. */ /* PNG_FORMAT_* * * #defines to be used in png_image::format. Each #define identifies a * particular layout of sample data and, if present, alpha values. There are * separate defines for each of the two component encodings. * * A format is built up using single bit flag values. All combinations are * valid. Formats can be built up from the flag values or you can use one of * the predefined values below. When testing formats always use the FORMAT_FLAG * macros to test for individual features - future versions of the library may * add new flags. * * When reading or writing color-mapped images the format should be set to the * format of the entries in the color-map then png_image_{read,write}_colormap * called to read or write the color-map and set the format correctly for the * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! * * NOTE: libpng can be built with particular features disabled, if you see * compiler errors because the definition of one of the following flags has been * compiled out it is because libpng does not have the required support. It is * possible, however, for the libpng configuration to enable the format on just * read or just write; in that case you may see an error at run time. You can * guard against this by checking for the definition of the appropriate * "_SUPPORTED" macro, one of: * * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED */ #define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ #define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ #define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2 byte channels else 1 byte */ #define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ #ifdef PNG_FORMAT_BGR_SUPPORTED # define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ #endif #ifdef PNG_FORMAT_AFIRST_SUPPORTED # define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ #endif /* Commonly used formats have predefined macros. * * First the single byte (sRGB) formats: */ #define PNG_FORMAT_GRAY 0 #define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA #define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR #define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) #define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) /* Then the linear 2-byte formats. When naming these "Y" is used to * indicate a luminance (gray) channel. */ #define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR #define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) #define PNG_FORMAT_LINEAR_RGB_ALPHA \ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) /* With color-mapped formats the image data is one byte for each pixel, the byte * is an index into the color-map which is formatted as above. To obtain a * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP * to one of the above definitions, or you can use one of the definitions below. */ #define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) /* PNG_IMAGE macros * * These are convenience macros to derive information from a png_image * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the * actual image sample values - either the entries in the color-map or the * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values * for the pixels and will always return 1 for color-mapped formats. The * remaining macros return information about the rows in the image and the * complete image. * * NOTE: All the macros that take a png_image::format parameter are compile time * constants if the format parameter is, itself, a constant. Therefore these * macros can be used in array declarations and case labels where required. * Similarly the macros are also pre-processor constants (sizeof is not used) so * they can be used in #if tests. * * First the information about the samples. */ #define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) /* Return the total number of channels in a given format: 1..4 */ #define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) /* Return the size in bytes of a single component of a pixel or color-map * entry (as appropriate) in the image: 1 or 2. */ #define PNG_IMAGE_SAMPLE_SIZE(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) /* This is the size of the sample data for one sample. If the image is * color-mapped it is the size of one color-map entry (and image pixels are * one byte in size), otherwise it is the size of one image pixel. */ #define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) /* The maximum size of the color-map required by the format expressed in a * count of components. This can be used to compile-time allocate a * color-map: * * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; * * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; * * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the * information from one of the png_image_begin_read_ APIs and dynamically * allocate the required memory. */ /* Corresponding information about the pixels */ #define PNG_IMAGE_PIXEL_(test,fmt)\ (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) #define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) /* The number of separate channels (components) in a pixel; 1 for a * color-mapped image. */ #define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) /* The size, in bytes, of each component in a pixel; 1 for a color-mapped * image. */ #define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ /* Information about the whole row, or whole image */ #define PNG_IMAGE_ROW_STRIDE(image)\ (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) /* Return the total number of components in a single row of the image; this * is the minimum 'row stride', the minimum count of components between each * row. For a color-mapped image this is the minimum number of bytes in a * row. */ #define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) /* Return the size, in bytes, of an image buffer given a png_image and a row * stride - the number of components to leave space for in each row. */ #define PNG_IMAGE_SIZE(image)\ PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) /* Return the size, in bytes, of the image in memory given just a png_image; * the row stride is the minimum stride required for the image. */ #define PNG_IMAGE_COLORMAP_SIZE(image)\ (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) /* Return the size, in bytes, of the color-map of this image. If the image * format is not a color-map format this will return a size sufficient for * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if * you don't want to allocate a color-map in this case. */ /* PNG_IMAGE_FLAG_* * * Flags containing additional information about the image are held in the * 'flags' field of png_image. */ #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 /* This indicates the the RGB values of the in-memory bitmap do not * correspond to the red, green and blue end-points defined by sRGB. */ #define PNG_IMAGE_FLAG_FAST 0x02 /* On write emphasise speed over compression; the resultant PNG file will be * larger but will be produced significantly faster, particular for large * images. Do not use this option for images which will be distributed, only * used it when producing intermediate files that will be read back in * repeatedly. For a typical 24-bit image the option will double the read * speed at the cost of increasing the image size by 25%, however for many * more compressible images the PNG file can be 10 times larger with only a * slight speed gain. */ #define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 /* On read if the image is a 16-bit per component image and there is no gAMA * or sRGB chunk assume that the components are sRGB encoded. Notice that * images output by the simplified API always have gamma information; setting * this flag only affects the interpretation of 16-bit images from an * external source. It is recommended that the application expose this flag * to the user; the user can normally easily recognize the difference between * linear and sRGB encoding. This flag has no effect on write - the data * passed to the write APIs must have the correct encoding (as defined * above.) * * If the flag is not set (the default) input 16-bit per component data is * assumed to be linear. * * NOTE: the flag can only be set after the png_image_begin_read_ call, * because that call initializes the 'flags' field. */ #ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* READ APIs * --------- * * The png_image passed to the read APIs must have been initialized by setting * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) */ #ifdef PNG_STDIO_SUPPORTED PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, const char *file_name)); /* The named file is opened for read and the image header is filled in * from the PNG header in the file. */ PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, FILE* file)); /* The PNG header is read from the stdio FILE object. */ #endif /* PNG_STDIO_SUPPORTED */ PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, png_const_voidp memory, png_size_t size)); /* The PNG header is read from the given memory buffer. */ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, png_const_colorp background, void *buffer, png_int_32 row_stride, void *colormap)); /* Finish reading the image into the supplied buffer and clean up the * png_image structure. * * row_stride is the step, in byte or 2-byte units as appropriate, * between adjacent rows. A positive stride indicates that the top-most row * is first in the buffer - the normal top-down arrangement. A negative * stride indicates that the bottom-most row is first in the buffer. * * background need only be supplied if an alpha channel must be removed from * a png_byte format and the removal is to be done by compositing on a solid * color; otherwise it may be NULL and any composition will be done directly * onto the buffer. The value is an sRGB color to use for the background, * for grayscale output the green channel is used. * * background must be supplied when an alpha channel must be removed from a * single byte color-mapped output format, in other words if: * * 1) The original format from png_image_begin_read_from_* had * PNG_FORMAT_FLAG_ALPHA set. * 2) The format set by the application does not. * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and * PNG_FORMAT_FLAG_LINEAR *not* set. * * For linear output removing the alpha channel is always done by compositing * on black and background is ignored. * * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. * image->colormap_entries will be updated to the actual number of entries * written to the colormap; this may be less than the original value. */ PNG_EXPORT(238, void, png_image_free, (png_imagep image)); /* Free any data allocated by libpng in image->opaque, setting the pointer to * NULL. May be called at any time after the structure is initialized. */ #endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED /* WRITE APIS * ---------- * For write you must initialize a png_image structure to describe the image to * be written. To do this use memset to set the whole structure to 0 then * initialize fields describing your image. * * version: must be set to PNG_IMAGE_VERSION * opaque: must be initialized to NULL * width: image width in pixels * height: image height in rows * format: the format of the data (image and color-map) you wish to write * flags: set to 0 unless one of the defined flags applies; set * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB * values do not correspond to the colors in sRGB. * colormap_entries: set to the number of entries in the color-map (0 to 256) */ PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, const char *file, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the named file. */ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the given (FILE*). */ /* With both write APIs if image is in one of the linear formats with 16-bit * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG * gamma encoded according to the sRGB specification, otherwise a 16-bit linear * encoded PNG file is written. * * With color-mapped data formats the colormap parameter point to a color-map * with at least image->colormap_entries encoded in the specified format. If * the format is linear the written PNG color-map will be converted to sRGB * regardless of the convert_to_8_bit flag. * * With all APIs row_stride is handled as in the read APIs - it is the spacing * from one row to the next in component sized units (1 or 2 bytes) and if * negative indicates a bottom-up row layout in the buffer. * * Note that the write API does not support interlacing or sub-8-bit pixels. */ #endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */ /******************************************************************************* * END OF SIMPLIFIED API ******************************************************************************/ #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED PNG_EXPORT(242, void, png_set_check_for_invalid_index, (png_structrp png_ptr, int allowed)); # ifdef PNG_GET_PALETTE_MAX_SUPPORTED PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, png_const_infop info_ptr)); # endif #endif /* CHECK_FOR_INVALID_INDEX */ /******************************************************************************* * IMPLEMENTATION OPTIONS ******************************************************************************* * * Support for arbitrary implementation-specific optimizations. The API allows * particular options to be turned on or off. 'Option' is the number of the * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given * by the PNG_OPTION_ defines below. * * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, * are detected at run time, however sometimes it may be impossible * to do this in user mode, in which case it is necessary to discover * the capabilities in an OS specific way. Such capabilities are * listed here when libpng has support for them and must be turned * ON by the application if present. * * SOFTWARE: sometimes software optimizations actually result in performance * decrease on some architectures or systems, or with some sets of * PNG images. 'Software' options allow such optimizations to be * selected at run time. */ #ifdef PNG_SET_OPTION_SUPPORTED #ifdef PNG_ARM_NEON_API_SUPPORTED # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ #endif #define PNG_OPTION_NEXT 2 /* Next option - numbers must be even */ /* Return values: NOTE: there are four values and 'off' is *not* zero */ #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ #define PNG_OPTION_INVALID 1 /* Option number out of range */ #define PNG_OPTION_OFF 2 #define PNG_OPTION_ON 3 PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, int onoff)); #endif /******************************************************************************* * END OF HARDWARE OPTIONS ******************************************************************************/ /* Maintainer: Put new public prototypes here ^, in libpng.3, and project * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt */ /* The last ordinal number (this is the *last* one already used; the next * one to use is one more than this.) Maintainer, remember to add an entry to * scripts/symbols.def as well. */ #ifdef PNG_EXPORT_LAST_ORDINAL PNG_EXPORT_LAST_ORDINAL(244); #endif #ifdef __cplusplus } #endif #endif /* PNG_VERSION_INFO_ONLY */ /* Do not put anything past this line */ #endif /* PNG_H */ ================================================ FILE: cocos2d/external/png/include/android/pngconf.h ================================================ /* pngconf.h - machine configurable file for libpng * * libpng version 1.6.2 - April 25, 2013 * * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h * */ /* Any machine specific code is near the front of this file, so if you * are configuring libpng for a machine, you may want to read the section * starting here down to where it starts to typedef png_color, png_text, * and png_info. */ #ifndef PNGCONF_H #define PNGCONF_H /* To do: Do all of this in scripts/pnglibconf.dfa */ #ifdef PNG_SAFE_LIMITS_SUPPORTED # ifdef PNG_USER_WIDTH_MAX # undef PNG_USER_WIDTH_MAX # define PNG_USER_WIDTH_MAX 1000000L # endif # ifdef PNG_USER_HEIGHT_MAX # undef PNG_USER_HEIGHT_MAX # define PNG_USER_HEIGHT_MAX 1000000L # endif # ifdef PNG_USER_CHUNK_MALLOC_MAX # undef PNG_USER_CHUNK_MALLOC_MAX # define PNG_USER_CHUNK_MALLOC_MAX 4000000L # endif # ifdef PNG_USER_CHUNK_CACHE_MAX # undef PNG_USER_CHUNK_CACHE_MAX # define PNG_USER_CHUNK_CACHE_MAX 128 # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C * compiler for correct compilation. The following header files are required by * the standard. If your compiler doesn't provide these header files, or they * do not match the standard, you will need to provide/improve them. */ #include #include /* Library header files. These header files are all defined by ISOC90; libpng * expects conformant implementations, however, an ISOC90 conformant system need * not provide these header files if the functionality cannot be implemented. * In this case it will be necessary to disable the relevant parts of libpng in * the build of pnglibconf.h. * * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not * include this unnecessary header file. */ #ifdef PNG_STDIO_SUPPORTED /* Required for the definition of FILE: */ # include #endif #ifdef PNG_SETJMP_SUPPORTED /* Required for the definition of jmp_buf and the declaration of longjmp: */ # include #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Required for struct tm: */ # include #endif #endif /* PNG_BUILDING_SYMBOL_TABLE */ /* Prior to 1.6.0 it was possible to turn off 'const' in declarations using * PNG_NO_CONST; this is no longer supported except for data declarations which * apparently still cause problems in 2011 on some compilers. */ #define PNG_CONST const /* backward compatibility only */ /* This controls optimization of the reading of 16 and 32 bit values * from PNG files. It can be set on a per-app-file basis - it * just changes whether a macro is used when the function is called. * The library builder sets the default; if read functions are not * built into the library the macro implementation is forced on. */ #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED # define PNG_USE_READ_MACROS #endif #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) # if PNG_DEFAULT_READ_MACROS # define PNG_USE_READ_MACROS # endif #endif /* COMPILER SPECIFIC OPTIONS. * * These options are provided so that a variety of difficult compilers * can be used. Some are fixed at build time (e.g. PNG_API_RULE * below) but still have compiler specific implementations, others * may be changed on a per-file basis when compiling against libpng. */ /* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect * against legacy (pre ISOC90) compilers that did not understand function * prototypes. It is not required for modern C compilers. */ #ifndef PNGARG # define PNGARG(arglist) arglist #endif /* Function calling conventions. * ============================= * Normally it is not necessary to specify to the compiler how to call * a function - it just does it - however on x86 systems derived from * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems * and some others) there are multiple ways to call a function and the * default can be changed on the compiler command line. For this reason * libpng specifies the calling convention of every exported function and * every function called via a user supplied function pointer. This is * done in this file by defining the following macros: * * PNGAPI Calling convention for exported functions. * PNGCBAPI Calling convention for user provided (callback) functions. * PNGCAPI Calling convention used by the ANSI-C library (required * for longjmp callbacks and sometimes used internally to * specify the calling convention for zlib). * * These macros should never be overridden. If it is necessary to * change calling convention in a private build this can be done * by setting PNG_API_RULE (which defaults to 0) to one of the values * below to select the correct 'API' variants. * * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. * This is correct in every known environment. * PNG_API_RULE=1 Use the operating system convention for PNGAPI and * the 'C' calling convention (from PNGCAPI) for * callbacks (PNGCBAPI). This is no longer required * in any known environment - if it has to be used * please post an explanation of the problem to the * libpng mailing list. * * These cases only differ if the operating system does not use the C * calling convention, at present this just means the above cases * (x86 DOS/Windows sytems) and, even then, this does not apply to * Cygwin running on those systems. * * Note that the value must be defined in pnglibconf.h so that what * the application uses to call the library matches the conventions * set when building the library. */ /* Symbol export * ============= * When building a shared library it is almost always necessary to tell * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' * is used to mark the symbols. On some systems these symbols can be * extracted at link time and need no special processing by the compiler, * on other systems the symbols are flagged by the compiler and just * the declaration requires a special tag applied (unfortunately) in a * compiler dependent way. Some systems can do either. * * A small number of older systems also require a symbol from a DLL to * be flagged to the program that calls it. This is a problem because * we do not know in the header file included by application code that * the symbol will come from a shared library, as opposed to a statically * linked one. For this reason the application must tell us by setting * the magic flag PNG_USE_DLL to turn on the special processing before * it includes png.h. * * Four additional macros are used to make this happen: * * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from * the build or imported if PNG_USE_DLL is set - compiler * and system specific. * * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to * 'type', compiler specific. * * PNG_DLL_EXPORT Set to the magic to use during a libpng build to * make a symbol exported from the DLL. Not used in the * public header files; see pngpriv.h for how it is used * in the libpng build. * * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come * from a DLL - used to define PNG_IMPEXP when * PNG_USE_DLL is set. */ /* System specific discovery. * ========================== * This code is used at build time to find PNG_IMPEXP, the API settings * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL * import processing is possible. On Windows systems it also sets * compiler-specific macros to the values required to change the calling * conventions of the various functions. */ #if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or * MinGW on any architecture currently supported by Windows. Also includes * Watcom builds but these need special treatment because they are not * compatible with GCC or Visual C because of different calling conventions. */ # if PNG_API_RULE == 2 /* If this line results in an error, either because __watcall is not * understood or because of a redefine just below you cannot use *this* * build of the library with the compiler you are using. *This* build was * build using Watcom and applications must also be built using Watcom! */ # define PNGCAPI __watcall # endif # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) # define PNGCAPI __cdecl # if PNG_API_RULE == 1 /* If this line results in an error __stdcall is not understood and * PNG_API_RULE should not have been set to '1'. */ # define PNGAPI __stdcall # endif # else /* An older compiler, or one not detected (erroneously) above, * if necessary override on the command line to get the correct * variants for the compiler. */ # ifndef PNGCAPI # define PNGCAPI _cdecl # endif # if PNG_API_RULE == 1 && !defined(PNGAPI) # define PNGAPI _stdcall # endif # endif /* compiler/api */ /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) # error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" # endif # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ (defined(__BORLANDC__) && __BORLANDC__ < 0x500) /* older Borland and MSC * compilers used '__export' and required this to be after * the type. */ # ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP # endif # define PNG_DLL_EXPORT __export # else /* newer compiler */ # define PNG_DLL_EXPORT __declspec(dllexport) # ifndef PNG_DLL_IMPORT # define PNG_DLL_IMPORT __declspec(dllimport) # endif # endif /* compiler */ #else /* !Windows */ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # define PNGAPI _System # else /* !Windows/x86 && !OS/2 */ /* Use the defaults, or define PNG*API on the command line (but * this will have to be done for every compile!) */ # endif /* other system, !OS/2 */ #endif /* !Windows/x86 */ /* Now do all the defaulting . */ #ifndef PNGCAPI # define PNGCAPI #endif #ifndef PNGCBAPI # define PNGCBAPI PNGCAPI #endif #ifndef PNGAPI # define PNGAPI PNGCAPI #endif /* PNG_IMPEXP may be set on the compilation system command line or (if not set) * then in an internal header file when building the library, otherwise (when * using the library) it is set here. */ #ifndef PNG_IMPEXP # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) /* This forces use of a DLL, disallowing static linking */ # define PNG_IMPEXP PNG_DLL_IMPORT # endif # ifndef PNG_IMPEXP # define PNG_IMPEXP # endif #endif /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat * 'attributes' as a storage class - the attributes go at the start of the * function definition, and attributes are always appended regardless of the * compiler. This considerably simplifies these macros but may cause problems * if any compilers both need function attributes and fail to handle them as * a storage class (this is unlikely.) */ #ifndef PNG_FUNCTION # define PNG_FUNCTION(type, name, args, attributes) attributes type name args #endif #ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type #endif /* The ordinal value is only relevant when preprocessing png.h for symbol * table entries, so we discard it here. See the .dfn files in the * scripts directory. */ #ifndef PNG_EXPORTA # define PNG_EXPORTA(ordinal, type, name, args, attributes)\ PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ extern attributes) #endif /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, * so make something non-empty to satisfy the requirement: */ #define PNG_EMPTY /*empty list*/ #define PNG_EXPORT(ordinal, type, name, args)\ PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) /* Use PNG_REMOVED to comment out a removed interface. */ #ifndef PNG_REMOVED # define PNG_REMOVED(ordinal, type, name, args, attributes) #endif #ifndef PNG_CALLBACK # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) #endif /* Support for compiler specific function attributes. These are used * so that where compiler support is available incorrect use of API * functions in png.h will generate compiler warnings. * * Added at libpng-1.2.41. */ #ifndef PNG_NO_PEDANTIC_WARNINGS # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED # define PNG_PEDANTIC_WARNINGS_SUPPORTED # endif #endif #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED /* Support for compiler specific function attributes. These are used * so that where compiler support is available, incorrect use of API * functions in png.h will generate compiler warnings. Added at libpng * version 1.2.41. Disabling these removes the warnings but may also produce * less efficient code. */ # if defined(__GNUC__) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif # ifndef PNG_NORETURN # define PNG_NORETURN __attribute__((__noreturn__)) # endif # if __GNUC__ >= 3 # ifndef PNG_ALLOCATED # define PNG_ALLOCATED __attribute__((__malloc__)) # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __attribute__((__deprecated__)) # endif # ifndef PNG_PRIVATE # if 0 /* Doesn't work so we use deprecated instead*/ # define PNG_PRIVATE \ __attribute__((warning("This function is not exported by libpng."))) # else # define PNG_PRIVATE \ __attribute__((__deprecated__)) # endif # endif # if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* __GNUC__ == 3.0 */ # endif /* __GNUC__ >= 3 */ # elif defined(_MSC_VER) && (_MSC_VER >= 1300) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* not supported */ # endif # ifndef PNG_NORETURN # define PNG_NORETURN __declspec(noreturn) # endif # ifndef PNG_ALLOCATED # if (_MSC_VER >= 1400) # define PNG_ALLOCATED __declspec(restrict) # endif # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __declspec(deprecated) # endif # ifndef PNG_PRIVATE # define PNG_PRIVATE __declspec(deprecated) # endif # ifndef PNG_RESTRICT # if (_MSC_VER >= 1400) # define PNG_RESTRICT __restrict # endif # endif # elif defined(__WATCOMC__) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* _MSC_VER */ #endif /* PNG_PEDANTIC_WARNINGS */ #ifndef PNG_DEPRECATED # define PNG_DEPRECATED /* Use of this function is deprecated */ #endif #ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* The result of this function must be checked */ #endif #ifndef PNG_NORETURN # define PNG_NORETURN /* This function does not return */ #endif #ifndef PNG_ALLOCATED # define PNG_ALLOCATED /* The result of the function is new memory */ #endif #ifndef PNG_PRIVATE # define PNG_PRIVATE /* This is a private libpng function */ #endif #ifndef PNG_RESTRICT # define PNG_RESTRICT /* The C99 "restrict" feature */ #endif #ifndef PNG_FP_EXPORT /* A floating point API. */ # ifdef PNG_FLOATING_POINT_SUPPORTED # define PNG_FP_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No floating point APIs */ # define PNG_FP_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_FIXED_EXPORT /* A fixed point API. */ # ifdef PNG_FIXED_POINT_SUPPORTED # define PNG_FIXED_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No fixed point APIs */ # define PNG_FIXED_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* Some typedefs to get us started. These should be safe on most of the common * platforms. * * png_uint_32 and png_int_32 may, currently, be larger than required to hold a * 32-bit value however this is not normally advisable. * * png_uint_16 and png_int_16 should always be two bytes in size - this is * verified at library build time. * * png_byte must always be one byte in size. * * The checks below use constants from limits.h, as defined by the ISOC90 * standard. */ #if CHAR_BIT == 8 && UCHAR_MAX == 255 typedef unsigned char png_byte; #else # error "libpng requires 8 bit bytes" #endif #if INT_MIN == -32768 && INT_MAX == 32767 typedef int png_int_16; #elif SHRT_MIN == -32768 && SHRT_MAX == 32767 typedef short png_int_16; #else # error "libpng requires a signed 16 bit type" #endif #if UINT_MAX == 65535 typedef unsigned int png_uint_16; #elif USHRT_MAX == 65535 typedef unsigned short png_uint_16; #else # error "libpng requires an unsigned 16 bit type" #endif #if INT_MIN < -2147483646 && INT_MAX > 2147483646 typedef int png_int_32; #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 typedef long int png_int_32; #else # error "libpng requires a signed 32 bit (or more) type" #endif #if UINT_MAX > 4294967294 typedef unsigned int png_uint_32; #elif ULONG_MAX > 4294967294 typedef unsigned long int png_uint_32; #else # error "libpng requires an unsigned 32 bit (or more) type" #endif /* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, * requires an ISOC90 compiler and relies on consistent behavior of sizeof. */ typedef size_t png_size_t; typedef ptrdiff_t png_ptrdiff_t; /* libpng needs to know the maximum value of 'size_t' and this controls the * definition of png_alloc_size_t, below. This maximum value of size_t limits * but does not control the maximum allocations the library makes - there is * direct application control of this through png_set_user_limits(). */ #ifndef PNG_SMALL_SIZE_T /* Compiler specific tests for systems where size_t is known to be less than * 32 bits (some of these systems may no longer work because of the lack of * 'far' support; see above.) */ # if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ (defined(_MSC_VER) && defined(MAXSEG_64K)) # define PNG_SMALL_SIZE_T # endif #endif /* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to * png_alloc_size_t are not necessary; in fact, it is recommended not to use * them at all so that the compiler can complain when something turns out to be * problematic. * * Casts in the other direction (from png_alloc_size_t to png_size_t or * png_uint_32) should be explicitly applied; however, we do not expect to * encounter practical situations that require such conversions. * * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than * 4294967295 - i.e. less than the maximum value of png_uint_32. */ #ifdef PNG_SMALL_SIZE_T typedef png_uint_32 png_alloc_size_t; #else typedef png_size_t png_alloc_size_t; #endif /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler * implementations of Intel CPU specific support of user-mode segmented address * spaces, where 16-bit pointers address more than 65536 bytes of memory using * separate 'segment' registers. The implementation requires two different * types of pointer (only one of which includes the segment value.) * * If required this support is available in version 1.2 of libpng and may be * available in versions through 1.5, although the correctness of the code has * not been verified recently. */ /* Typedef for floating-point numbers that are converted to fixed-point with a * multiple of 100,000, e.g., gamma */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ typedef void * png_voidp; typedef const void * png_const_voidp; typedef png_byte * png_bytep; typedef const png_byte * png_const_bytep; typedef png_uint_32 * png_uint_32p; typedef const png_uint_32 * png_const_uint_32p; typedef png_int_32 * png_int_32p; typedef const png_int_32 * png_const_int_32p; typedef png_uint_16 * png_uint_16p; typedef const png_uint_16 * png_const_uint_16p; typedef png_int_16 * png_int_16p; typedef const png_int_16 * png_const_int_16p; typedef char * png_charp; typedef const char * png_const_charp; typedef png_fixed_point * png_fixed_point_p; typedef const png_fixed_point * png_const_fixed_point_p; typedef png_size_t * png_size_tp; typedef const png_size_t * png_const_size_tp; #ifdef PNG_STDIO_SUPPORTED typedef FILE * png_FILE_p; #endif #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * png_doublep; typedef const double * png_const_doublep; #endif /* Pointers to pointers; i.e. arrays */ typedef png_byte * * png_bytepp; typedef png_uint_32 * * png_uint_32pp; typedef png_int_32 * * png_int_32pp; typedef png_uint_16 * * png_uint_16pp; typedef png_int_16 * * png_int_16pp; typedef const char * * png_const_charpp; typedef char * * png_charpp; typedef png_fixed_point * * png_fixed_point_pp; #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * * png_doublepp; #endif /* Pointers to pointers to pointers; i.e., pointer to array */ typedef char * * * png_charppp; #endif /* PNG_BUILDING_SYMBOL_TABLE */ #endif /* PNGCONF_H */ ================================================ FILE: cocos2d/external/png/include/android/pnglibconf.h ================================================ /* pnglibconf.h - library build configuration */ /* libpng version 1.6.2 - April 25, 2013 */ /* Copyright (c) 1998-2012 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ /* For conditions of distribution and use, see the disclaimer */ /* and license in png.h */ /* pnglibconf.h */ /* Machine generated file: DO NOT EDIT */ /* Derived from: scripts/pnglibconf.dfa */ #ifndef PNGLCONF_H #define PNGLCONF_H /* options */ #define PNG_16BIT_SUPPORTED #define PNG_ALIGNED_MEMORY_SUPPORTED /*#undef PNG_ARM_NEON_API_SUPPORTED*/ /*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ /*#undef PNG_ARM_NEON_SUPPORTED*/ #define PNG_BENIGN_ERRORS_SUPPORTED #define PNG_BENIGN_READ_ERRORS_SUPPORTED /*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_COLORSPACE_SUPPORTED #define PNG_CONSOLE_IO_SUPPORTED #define PNG_CONVERT_tIME_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ #define PNG_ERROR_TEXT_SUPPORTED #define PNG_FIXED_POINT_SUPPORTED #define PNG_FLOATING_ARITHMETIC_SUPPORTED #define PNG_FLOATING_POINT_SUPPORTED #define PNG_FORMAT_AFIRST_SUPPORTED #define PNG_FORMAT_BGR_SUPPORTED #define PNG_GAMMA_SUPPORTED #define PNG_GET_PALETTE_MAX_SUPPORTED #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED #define PNG_INCH_CONVERSIONS_SUPPORTED #define PNG_INFO_IMAGE_SUPPORTED #define PNG_IO_STATE_SUPPORTED #define PNG_MNG_FEATURES_SUPPORTED #define PNG_POINTER_INDEXING_SUPPORTED #define PNG_PROGRESSIVE_READ_SUPPORTED #define PNG_READ_16BIT_SUPPORTED #define PNG_READ_ALPHA_MODE_SUPPORTED #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED #define PNG_READ_BACKGROUND_SUPPORTED #define PNG_READ_BGR_SUPPORTED #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_READ_COMPOSITE_NODIV_SUPPORTED #define PNG_READ_COMPRESSED_TEXT_SUPPORTED #define PNG_READ_EXPAND_16_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_FILLER_SUPPORTED #define PNG_READ_GAMMA_SUPPORTED #define PNG_READ_GET_PALETTE_MAX_SUPPORTED #define PNG_READ_GRAY_TO_RGB_SUPPORTED #define PNG_READ_INTERLACING_SUPPORTED #define PNG_READ_INT_FUNCTIONS_SUPPORTED #define PNG_READ_INVERT_ALPHA_SUPPORTED #define PNG_READ_INVERT_SUPPORTED #define PNG_READ_OPT_PLTE_SUPPORTED #define PNG_READ_PACKSWAP_SUPPORTED #define PNG_READ_PACK_SUPPORTED #define PNG_READ_QUANTIZE_SUPPORTED #define PNG_READ_RGB_TO_GRAY_SUPPORTED #define PNG_READ_SCALE_16_TO_8_SUPPORTED #define PNG_READ_SHIFT_SUPPORTED #define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED #define PNG_READ_SUPPORTED #define PNG_READ_SWAP_ALPHA_SUPPORTED #define PNG_READ_SWAP_SUPPORTED #define PNG_READ_TEXT_SUPPORTED #define PNG_READ_TRANSFORMS_SUPPORTED #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED #define PNG_READ_USER_CHUNKS_SUPPORTED #define PNG_READ_USER_TRANSFORM_SUPPORTED #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED #define PNG_READ_gAMA_SUPPORTED #define PNG_READ_hIST_SUPPORTED #define PNG_READ_iCCP_SUPPORTED #define PNG_READ_iTXt_SUPPORTED #define PNG_READ_oFFs_SUPPORTED #define PNG_READ_pCAL_SUPPORTED #define PNG_READ_pHYs_SUPPORTED #define PNG_READ_sBIT_SUPPORTED #define PNG_READ_sCAL_SUPPORTED #define PNG_READ_sPLT_SUPPORTED #define PNG_READ_sRGB_SUPPORTED #define PNG_READ_tEXt_SUPPORTED #define PNG_READ_tIME_SUPPORTED #define PNG_READ_tRNS_SUPPORTED #define PNG_READ_zTXt_SUPPORTED /*#undef PNG_SAFE_LIMITS_SUPPORTED*/ #define PNG_SAVE_INT_32_SUPPORTED #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SEQUENTIAL_READ_SUPPORTED #define PNG_SETJMP_SUPPORTED #define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED #define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED /*#undef PNG_SET_OPTION_SUPPORTED*/ #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SET_USER_LIMITS_SUPPORTED #define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_READ_BGR_SUPPORTED #define PNG_SIMPLIFIED_READ_SUPPORTED #define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED #define PNG_SIMPLIFIED_WRITE_SUPPORTED #define PNG_STDIO_SUPPORTED #define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_TEXT_SUPPORTED #define PNG_TIME_RFC1123_SUPPORTED #define PNG_UNKNOWN_CHUNKS_SUPPORTED #define PNG_USER_CHUNKS_SUPPORTED #define PNG_USER_LIMITS_SUPPORTED #define PNG_USER_MEM_SUPPORTED #define PNG_USER_TRANSFORM_INFO_SUPPORTED #define PNG_USER_TRANSFORM_PTR_SUPPORTED #define PNG_WARNINGS_SUPPORTED #define PNG_WRITE_16BIT_SUPPORTED #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #define PNG_WRITE_BGR_SUPPORTED #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED #define PNG_WRITE_FILLER_SUPPORTED #define PNG_WRITE_FILTER_SUPPORTED #define PNG_WRITE_FLUSH_SUPPORTED #define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED #define PNG_WRITE_INTERLACING_SUPPORTED #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED #define PNG_WRITE_INVERT_ALPHA_SUPPORTED #define PNG_WRITE_INVERT_SUPPORTED #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED #define PNG_WRITE_PACKSWAP_SUPPORTED #define PNG_WRITE_PACK_SUPPORTED #define PNG_WRITE_SHIFT_SUPPORTED #define PNG_WRITE_SUPPORTED #define PNG_WRITE_SWAP_ALPHA_SUPPORTED #define PNG_WRITE_SWAP_SUPPORTED #define PNG_WRITE_TEXT_SUPPORTED #define PNG_WRITE_TRANSFORMS_SUPPORTED #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_WRITE_USER_TRANSFORM_SUPPORTED #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #define PNG_WRITE_bKGD_SUPPORTED #define PNG_WRITE_cHRM_SUPPORTED #define PNG_WRITE_gAMA_SUPPORTED #define PNG_WRITE_hIST_SUPPORTED #define PNG_WRITE_iCCP_SUPPORTED #define PNG_WRITE_iTXt_SUPPORTED #define PNG_WRITE_oFFs_SUPPORTED #define PNG_WRITE_pCAL_SUPPORTED #define PNG_WRITE_pHYs_SUPPORTED #define PNG_WRITE_sBIT_SUPPORTED #define PNG_WRITE_sCAL_SUPPORTED #define PNG_WRITE_sPLT_SUPPORTED #define PNG_WRITE_sRGB_SUPPORTED #define PNG_WRITE_tEXt_SUPPORTED #define PNG_WRITE_tIME_SUPPORTED #define PNG_WRITE_tRNS_SUPPORTED #define PNG_WRITE_zTXt_SUPPORTED #define PNG_bKGD_SUPPORTED #define PNG_cHRM_SUPPORTED #define PNG_gAMA_SUPPORTED #define PNG_hIST_SUPPORTED #define PNG_iCCP_SUPPORTED #define PNG_iTXt_SUPPORTED #define PNG_oFFs_SUPPORTED #define PNG_pCAL_SUPPORTED #define PNG_pHYs_SUPPORTED #define PNG_sBIT_SUPPORTED #define PNG_sCAL_SUPPORTED #define PNG_sPLT_SUPPORTED #define PNG_sRGB_SUPPORTED #define PNG_tEXt_SUPPORTED #define PNG_tIME_SUPPORTED #define PNG_tRNS_SUPPORTED #define PNG_zTXt_SUPPORTED /* end of options */ /* settings */ #define PNG_API_RULE 0 #define PNG_CALLOC_SUPPORTED #define PNG_COST_SHIFT 3 #define PNG_DEFAULT_READ_MACROS 1 #define PNG_GAMMA_THRESHOLD_FIXED 5000 #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE #define PNG_INFLATE_BUF_SIZE 1024 #define PNG_MAX_GAMMA_8 11 #define PNG_QUANTIZE_BLUE_BITS 5 #define PNG_QUANTIZE_GREEN_BITS 5 #define PNG_QUANTIZE_RED_BITS 5 #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 #define PNG_WEIGHT_SHIFT 8 #define PNG_ZBUF_SIZE 8192 #define PNG_Z_DEFAULT_COMPRESSION (-1) #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 #define PNG_Z_DEFAULT_STRATEGY 1 #define PNG_sCAL_PRECISION 5 #define PNG_sRGB_PROFILE_CHECKS 2 /* end of settings */ #endif /* PNGLCONF_H */ ================================================ FILE: cocos2d/external/png/include/ios/png.h ================================================ /* png.h - header file for PNG reference library * * libpng version 1.6.2 - April 25, 2013 * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license (See LICENSE, below) * * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.6.2 - April 25, 2013: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: * * Due to various miscommunications, unforeseen code incompatibilities * and occasional factors outside the authors' control, version numbering * on the library has not always been consistent and straightforward. * The following table summarizes matters since version 0.89c, which was * the first widely used release: * * source png.h png.h shared-lib * version string int version * ------- ------ ----- ---------- * 0.89c "1.0 beta 3" 0.89 89 1.0.89 * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] * 0.97c 0.97 97 2.0.97 * 0.98 0.98 98 2.0.98 * 0.99 0.99 98 2.0.99 * 0.99a-m 0.99 99 2.0.99 * 1.00 1.00 100 2.1.0 [100 should be 10000] * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] * 1.0.1 png.h string is 10001 2.1.0 * 1.0.1a-e identical to the 10002 from here on, the shared library * 1.0.2 source version) 10002 is 2.V where V is the source code * 1.0.2a-b 10003 version, except as noted. * 1.0.3 10003 * 1.0.3a-d 10004 * 1.0.4 10004 * 1.0.4a-f 10005 * 1.0.5 (+ 2 patches) 10005 * 1.0.5a-d 10006 * 1.0.5e-r 10100 (not source compatible) * 1.0.5s-v 10006 (not binary compatible) * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) * 1.0.6d-f 10007 (still binary incompatible) * 1.0.6g 10007 * 1.0.6h 10007 10.6h (testing xy.z so-numbering) * 1.0.6i 10007 10.6i * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) * 1.0.7 1 10007 (still compatible) * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 * 1.0.8rc1 1 10008 2.1.0.8rc1 * 1.0.8 1 10008 2.1.0.8 * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 * 1.0.9rc1 1 10009 2.1.0.9rc1 * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 * 1.0.9rc2 1 10009 2.1.0.9rc2 * 1.0.9 1 10009 2.1.0.9 * 1.0.10beta1 1 10010 2.1.0.10beta1 * 1.0.10rc1 1 10010 2.1.0.10rc1 * 1.0.10 1 10010 2.1.0.10 * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 * 1.0.11rc1 1 10011 2.1.0.11rc1 * 1.0.11 1 10011 2.1.0.11 * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 * 1.0.12rc1 2 10012 2.1.0.12rc1 * 1.0.12 2 10012 2.1.0.12 * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 * 1.2.0rc1 3 10200 3.1.2.0rc1 * 1.2.0 3 10200 3.1.2.0 * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 * 1.2.1 3 10201 3.1.2.1 * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 * 1.0.13 10 10013 10.so.0.1.0.13 * 1.2.2 12 10202 12.so.0.1.2.2 * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 * 1.2.3 12 10203 12.so.0.1.2.3 * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 * 1.0.14 10 10014 10.so.0.1.0.14 * 1.2.4 13 10204 12.so.0.1.2.4 * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 * 1.0.15 10 10015 10.so.0.1.0.15 * 1.2.5 13 10205 12.so.0.1.2.5 * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 * 1.0.16 10 10016 10.so.0.1.0.16 * 1.2.6 13 10206 12.so.0.1.2.6 * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 * 1.0.17rc1 10 10017 12.so.0.1.0.17rc1 * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 * 1.0.17 10 10017 12.so.0.1.0.17 * 1.2.7 13 10207 12.so.0.1.2.7 * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 * 1.0.18 10 10018 12.so.0.1.0.18 * 1.2.8 13 10208 12.so.0.1.2.8 * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 * 1.2.9beta4-11 13 10209 12.so.0.9[.0] * 1.2.9rc1 13 10209 12.so.0.9[.0] * 1.2.9 13 10209 12.so.0.9[.0] * 1.2.10beta1-7 13 10210 12.so.0.10[.0] * 1.2.10rc1-2 13 10210 12.so.0.10[.0] * 1.2.10 13 10210 12.so.0.10[.0] * 1.4.0beta1-5 14 10400 14.so.0.0[.0] * 1.2.11beta1-4 13 10211 12.so.0.11[.0] * 1.4.0beta7-8 14 10400 14.so.0.0[.0] * 1.2.11 13 10211 12.so.0.11[.0] * 1.2.12 13 10212 12.so.0.12[.0] * 1.4.0beta9-14 14 10400 14.so.0.0[.0] * 1.2.13 13 10213 12.so.0.13[.0] * 1.4.0beta15-36 14 10400 14.so.0.0[.0] * 1.4.0beta37-87 14 10400 14.so.14.0[.0] * 1.4.0rc01 14 10400 14.so.14.0[.0] * 1.4.0beta88-109 14 10400 14.so.14.0[.0] * 1.4.0rc02-08 14 10400 14.so.14.0[.0] * 1.4.0 14 10400 14.so.14.0[.0] * 1.4.1beta01-03 14 10401 14.so.14.1[.0] * 1.4.1rc01 14 10401 14.so.14.1[.0] * 1.4.1beta04-12 14 10401 14.so.14.1[.0] * 1.4.1 14 10401 14.so.14.1[.0] * 1.4.2 14 10402 14.so.14.2[.0] * 1.4.3 14 10403 14.so.14.3[.0] * 1.4.4 14 10404 14.so.14.4[.0] * 1.5.0beta01-58 15 10500 15.so.15.0[.0] * 1.5.0rc01-07 15 10500 15.so.15.0[.0] * 1.5.0 15 10500 15.so.15.0[.0] * 1.5.1beta01-11 15 10501 15.so.15.1[.0] * 1.5.1rc01-02 15 10501 15.so.15.1[.0] * 1.5.1 15 10501 15.so.15.1[.0] * 1.5.2beta01-03 15 10502 15.so.15.2[.0] * 1.5.2rc01-03 15 10502 15.so.15.2[.0] * 1.5.2 15 10502 15.so.15.2[.0] * 1.5.3beta01-10 15 10503 15.so.15.3[.0] * 1.5.3rc01-02 15 10503 15.so.15.3[.0] * 1.5.3beta11 15 10503 15.so.15.3[.0] * 1.5.3 [omitted] * 1.5.4beta01-08 15 10504 15.so.15.4[.0] * 1.5.4rc01 15 10504 15.so.15.4[.0] * 1.5.4 15 10504 15.so.15.4[.0] * 1.5.5beta01-08 15 10505 15.so.15.5[.0] * 1.5.5rc01 15 10505 15.so.15.5[.0] * 1.5.5 15 10505 15.so.15.5[.0] * 1.5.6beta01-07 15 10506 15.so.15.6[.0] * 1.5.6rc01-03 15 10506 15.so.15.6[.0] * 1.5.6 15 10506 15.so.15.6[.0] * 1.5.7beta01-05 15 10507 15.so.15.7[.0] * 1.5.7rc01-03 15 10507 15.so.15.7[.0] * 1.5.7 15 10507 15.so.15.7[.0] * 1.6.0beta01-40 16 10600 16.so.16.0[.0] * 1.6.0rc01-08 16 10600 16.so.16.0[.0] * 1.6.0 16 10600 16.so.16.0[.0] * 1.6.1beta01-09 16 10601 16.so.16.1[.0] * 1.6.1rc01 16 10601 16.so.16.1[.0] * 1.6.1 16 10601 16.so.16.1[.0] * 1.6.2beta01 16 10602 16.so.16.2[.0] * 1.6.2rc01-06 16 10602 16.so.16.2[.0] * 1.6.2 16 10602 16.so.16.2[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. The * PNG_LIBPNG_VER macro, which is not used within libpng but is available * for applications, is an unsigned integer of the form xyyzz corresponding * to the source version x.y.z (leading zeros in y and z). Beta versions * were given the previous public release number plus a letter, until * version 1.0.6j; from then on they were given the upcoming public * release number plus "betaNN" or "rcNN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled * application is loaded with a different version of the library. * * DLLNUM will change each time there are forward or backward changes * in binary compatibility (e.g., when a new feature is added). * * See libpng-manual.txt or libpng.3 for more information. The PNG * specification is available as a W3C Recommendation and as an ISO * Specification, defines should NOT be changed. */ #define PNG_INFO_gAMA 0x0001 #define PNG_INFO_sBIT 0x0002 #define PNG_INFO_cHRM 0x0004 #define PNG_INFO_PLTE 0x0008 #define PNG_INFO_tRNS 0x0010 #define PNG_INFO_bKGD 0x0020 #define PNG_INFO_hIST 0x0040 #define PNG_INFO_pHYs 0x0080 #define PNG_INFO_oFFs 0x0100 #define PNG_INFO_tIME 0x0200 #define PNG_INFO_pCAL 0x0400 #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ #define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using * the routines for other purposes. */ typedef struct png_row_info_struct { png_uint_32 width; /* width of row */ png_size_t rowbytes; /* number of bytes in row */ png_byte color_type; /* color type of row */ png_byte bit_depth; /* bit depth of row */ png_byte channels; /* number of channels (1, 2, 3, or 4) */ png_byte pixel_depth; /* bits per pixel (depth * channels) */ } png_row_info; typedef png_row_info * png_row_infop; typedef png_row_info * * png_row_infopp; /* These are the function types for the I/O functions and for the functions * that allow the user to override the default I/O functions with his or her * own. The png_error_ptr type should match that of user-supplied warning * and error functions, while the png_rw_ptr type should match that of the * user read/write data functions. Note that the 'write' function must not * modify the buffer it is passed. The 'read' function, on the other hand, is * expected to return the read data in the buffer. */ typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, int)); typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, int)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); /* The following callback receives png_uint_32 row_number, int pass for the * png_bytep data of the row. When transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, png_uint_32, int)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, png_bytep)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, png_unknown_chunkp)); #endif #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED /* not used anywhere */ /* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ #endif #ifdef PNG_SETJMP_SUPPORTED /* This must match the function definition in , and the application * must include this before png.h to obtain the definition of jmp_buf. The * function is required to be PNG_NORETURN, but this is not checked. If the * function does return the application will crash via an abort() or similar * system level call. * * If you get a warning here while building the library you may need to make * changes to ensure that pnglibconf.h records the calling convention used by * your compiler. This may be very difficult - try using a different compiler * to build the library! */ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); #endif /* Transform masks for the high-level interface */ #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ /* Added to libpng-1.2.34 */ #define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ /* Added to libpng-1.4.0 */ #define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ /* Added to libpng-1.5.4 */ #define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ #define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 /* NOTE: prior to 1.5 these functions had no 'API' style declaration, * this allowed the zlib default functions to be used on Windows * platforms. In 1.5 the zlib default malloc (which just calls malloc and * ignores the first argument) should be completely compatible with the * following. */ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, png_alloc_size_t)); typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); /* Section 3: exported functions * Here are the function definitions most commonly used. This is not * the place to find out how to use libpng. See libpng-manual.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. * * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in * pngconf.h and in the *.dfn files in the scripts directory. * * PNG_EXPORT(ordinal, type, name, (args)); * * ordinal: ordinal that is used while building * *.def files. The ordinal value is only * relevant when preprocessing png.h with * the *.dfn files for building symbol table * entries, and are removed by pngconf.h. * type: return type of the function * name: function name * args: function arguments, with types * * When we wish to append attributes to a function prototype we use * the PNG_EXPORTA() macro instead. * * PNG_EXPORTA(ordinal, type, name, (args), attributes); * * ordinal, type, name, and args: same as in PNG_EXPORT(). * attributes: function attributes */ /* Returns the version number of the library */ PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); /* Tell lib we have already handled the first magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, png_size_t num_to_check)); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ #define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) /* Allocate and initialize png_ptr struct for reading, and any other memory. */ PNG_EXPORTA(4, png_structp, png_create_read_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); /* Allocate and initialize png_ptr struct for writing, and any other memory */ PNG_EXPORTA(5, png_structp, png_create_write_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, (png_const_structrp png_ptr)); PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, png_size_t size)); /* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp * match up. */ #ifdef PNG_SETJMP_SUPPORTED /* This function returns the jmp_buf built in to *png_ptr. It must be * supplied with an appropriate 'longjmp' function to use on that jmp_buf * unless the default error function is overridden in which case NULL is * acceptable. The size of the jmp_buf is checked against the actual size * allocated by the library - the call will return NULL on a mismatch * indicating an ABI mismatch. */ PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); # define png_jmpbuf(png_ptr) \ (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) #else # define png_jmpbuf(png_ptr) \ (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) #endif /* This function should be used by libpng applications in place of * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it * will use it; otherwise it will call PNG_ABORT(). This function was * added in libpng-1.5.0. */ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), PNG_NORETURN); #ifdef PNG_READ_SUPPORTED /* Reset the compression stream */ PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); #endif /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(11, png_structp, png_create_read_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); PNG_EXPORTA(12, png_structp, png_create_write_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); #endif /* Write the PNG file signature. */ PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); /* Write a PNG chunk - size, type, (optional) data, CRC. */ PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep chunk_name, png_const_bytep data, png_size_t length)); /* Write the start of a PNG chunk - length and chunk name. */ PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, png_const_bytep chunk_name, png_uint_32 length)); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, png_const_bytep data, png_size_t length)); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); /* Allocate and initialize the info structure */ PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), PNG_ALLOCATED); /* DEPRECATED: this function allowed init structures to be created using the * default allocation method (typically malloc). Use is deprecated in 1.6.0 and * the API will be removed in the future. */ PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, png_size_t png_info_struct_size), PNG_DEPRECATED); /* Writes all the PNG information before the image. */ PNG_EXPORT(20, void, png_write_info_before_PLTE, (png_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(21, void, png_write_info, (png_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. */ PNG_EXPORT(22, void, png_read_info, (png_structrp png_ptr, png_inforp info_ptr)); #endif #ifdef PNG_TIME_RFC1123_SUPPORTED /* Convert to a US string format: there is no localization support in this * routine. The original implementation used a 29 character buffer in * png_struct, this will be removed in future versions. */ #if PNG_LIBPNG_VER < 10700 /* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, png_const_timep ptime),PNG_DEPRECATED); #endif PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], png_const_timep ptime)); #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Convert from a struct tm to png_time */ PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, const struct tm * ttime)); /* Convert from time_t to png_time. Uses gmtime() */ PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); #endif /* PNG_CONVERT_tIME_SUPPORTED */ #ifdef PNG_READ_EXPAND_SUPPORTED /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); #endif #ifdef PNG_READ_EXPAND_16_SUPPORTED /* Expand to 16-bit channels, forces conversion of palette to RGB and expansion * of a tRNS chunk if present. */ PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Expand the grayscale to 24-bit RGB if necessary. */ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); #endif #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED /* Reduce RGB to grayscale. */ #define PNG_ERROR_ACTION_NONE 1 #define PNG_ERROR_ACTION_WARN 2 #define PNG_ERROR_ACTION_ERROR 3 #define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, int error_action, double red, double green)) PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)) PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp png_ptr)); #endif #ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, png_colorp palette)); #endif #ifdef PNG_READ_ALPHA_MODE_SUPPORTED /* How the alpha channel is interpreted - this affects how the color channels of * a PNG file are returned when an alpha channel, or tRNS chunk in a palette * file, is present. * * This has no effect on the way pixels are written into a PNG output * datastream. The color samples in a PNG datastream are never premultiplied * with the alpha samples. * * The default is to return data according to the PNG specification: the alpha * channel is a linear measure of the contribution of the pixel to the * corresponding composited pixel. The gamma encoded color channels must be * scaled according to the contribution and to do this it is necessary to undo * the encoding, scale the color values, perform the composition and reencode * the values. This is the 'PNG' mode. * * The alternative is to 'associate' the alpha with the color information by * storing color channel values that have been scaled by the alpha. The * advantage is that the color channels can be resampled (the image can be * scaled) in this form. The disadvantage is that normal practice is to store * linear, not (gamma) encoded, values and this requires 16-bit channels for * still images rather than the 8-bit channels that are just about sufficient if * gamma encoding is used. In addition all non-transparent pixel values, * including completely opaque ones, must be gamma encoded to produce the final * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the * latter being the two common names for associated alpha color channels.) * * Since it is not necessary to perform arithmetic on opaque color values so * long as they are not to be resampled and are in the final color space it is * possible to optimize the handling of alpha by storing the opaque pixels in * the PNG format (adjusted for the output color space) while storing partially * opaque pixels in the standard, linear, format. The accuracy required for * standard alpha composition is relatively low, because the pixels are * isolated, therefore typically the accuracy loss in storing 8-bit linear * values is acceptable. (This is not true if the alpha channel is used to * simulate transparency over large areas - use 16 bits or the PNG mode in * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is * treated as opaque only if the alpha value is equal to the maximum value. * * The final choice is to gamma encode the alpha channel as well. This is * broken because, in practice, no implementation that uses this choice * correctly undoes the encoding before handling alpha composition. Use this * choice only if other serious errors in the software or hardware you use * mandate it; the typical serious error is for dark halos to appear around * opaque areas of the composited PNG image because of arithmetic overflow. * * The API function png_set_alpha_mode specifies which of these choices to use * with an enumerated 'mode' value and the gamma of the required output: */ #define PNG_ALPHA_PNG 0 /* according to the PNG standard */ #define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ #define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ #define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ #define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ #define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, double output_gamma)) PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, int mode, png_fixed_point output_gamma)) #endif #if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) /* The output_gamma value is a screen gamma in libpng terminology: it expresses * how to decode the output values, not how they are encoded. The values used * correspond to the normal numbers used to describe the overall gamma of a * computer display system; for example 2.2 for an sRGB conformant system. The * values are scaled by 100000 in the _fixed version of the API (so 220000 for * sRGB.) * * The inverse of the value is always used to provide a default for the PNG file * encoding if it has no gAMA chunk and if png_set_gamma() has not been called * to override the PNG gamma information. * * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode * opaque pixels however pixels with lower alpha values are not encoded, * regardless of the output gamma setting. * * When the standard Porter Duff handling is requested with mode 1 the output * encoding is set to be linear and the output_gamma value is only relevant * as a default for input data that has no gamma information. The linear output * encoding will be overridden if png_set_gamma() is called - the results may be * highly unexpected! * * The following numbers are derived from the sRGB standard and the research * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing * correction required to take account of any differences in the color * environment of the original scene and the intended display environment; the * value expresses how to *decode* the image for display, not how the original * data was *encoded*. * * sRGB provides a peg for the PNG standard by defining a viewing environment. * sRGB itself, and earlier TV standards, actually use a more complex transform * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is * limited to simple power laws.) By saying that an image for direct display on * an sRGB conformant system should be stored with a gAMA chunk value of 45455 * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification * makes it possible to derive values for other display systems and * environments. * * The Mac value is deduced from the sRGB based on an assumption that the actual * extra viewing correction used in early Mac display systems was implemented as * a power 1.45 lookup table. * * Any system where a programmable lookup table is used or where the behavior of * the final display device characteristics can be changed requires system * specific code to obtain the current characteristic. However this can be * difficult and most PNG gamma correction only requires an approximate value. * * By default, if png_set_alpha_mode() is not called, libpng assumes that all * values are unencoded, linear, values and that the output device also has a * linear characteristic. This is only very rarely correct - it is invariably * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the * default if you don't know what the right answer is! * * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS * 10.6) which used a correction table to implement a somewhat lower gamma on an * otherwise sRGB system. * * Both these values are reserved (not simple gamma values) in order to allow * more precise correction internally in the future. * * NOTE: the following values can be passed to either the fixed or floating * point APIs, but the floating point API will also accept floating point * values. */ #define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ #define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ #define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ #define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ #endif /* The following are examples of calls to png_set_alpha_mode to achieve the * required overall gamma correction and, where necessary, alpha * premultiplication. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * This is the default libpng handling of the alpha channel - it is not * pre-multiplied into the color components. In addition the call states * that the output is for a sRGB system and causes all PNG files without gAMA * chunks to be assumed to be encoded using sRGB. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * In this case the output is assumed to be something like an sRGB conformant * display preceeded by a power-law lookup table of power 1.45. This is how * early Mac systems behaved. * * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); * This is the classic Jim Blinn approach and will work in academic * environments where everything is done by the book. It has the shortcoming * of assuming that input PNG data with no gamma information is linear - this * is unlikely to be correct unless the PNG files where generated locally. * Most of the time the output precision will be so low as to show * significant banding in dark areas of the image. * * png_set_expand_16(pp); * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); * This is a somewhat more realistic Jim Blinn inspired approach. PNG files * are assumed to have the sRGB encoding if not marked with a gamma value and * the output is always 16 bits per component. This permits accurate scaling * and processing of the data. If you know that your input PNG files were * generated locally you might need to replace PNG_DEFAULT_sRGB with the * correct value for your system. * * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); * If you just need to composite the PNG image onto an existing background * and if you control the code that does this you can use the optimization * setting. In this case you just copy completely opaque pixels to the * output. For pixels that are not completely transparent (you just skip * those) you do the composition math using png_composite or png_composite_16 * below then encode the resultant 8-bit or 16-bit values to match the output * encoding. * * Other cases * If neither the PNG nor the standard linear encoding work for you because * of the software or hardware you use then you have a big problem. The PNG * case will probably result in halos around the image. The linear encoding * will probably result in a washed out, too bright, image (it's actually too * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably * substantially reduce the halos. Alternatively try: * * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); * This option will also reduce the halos, but there will be slight dark * halos round the opaque parts of the image where the background is light. * In the OPTIMIZED mode the halos will be light halos where the background * is dark. Take your pick - the halos are unavoidable unless you can get * your hardware/software fixed! (The OPTIMIZED approach is slightly * faster.) * * When the default gamma of PNG files doesn't match the output gamma. * If you have PNG files with no gamma information png_set_alpha_mode allows * you to provide a default gamma, but it also sets the ouput gamma to the * matching value. If you know your PNG files have a gamma that doesn't * match the output you can take advantage of the fact that * png_set_alpha_mode always sets the output gamma but only sets the PNG * default if it is not already set: * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * The first call sets both the default and the output gamma values, the * second call overrides the output gamma without changing the default. This * is easier than achieving the same effect with png_set_gamma. You must use * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will * fire if more than one call to png_set_alpha_mode and png_set_background is * made in the same read operation, however multiple calls with PNG_ALPHA_PNG * are ignored. */ #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ # define PNG_FILLER_BEFORE 0 # define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, png_uint_32 filler, int flags)); #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p true_bits)); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) /* Have the code handle the interlacing. Returns the number of passes. * MUST be called before png_read_update_info or png_start_read_image, * otherwise it will not have the desired effect. Note that it is still * necessary to call png_read_row or png_read_rows png_get_image_height * times for each pass. */ PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED /* Handle alpha and tRNS by replacing with a background color. Prior to * libpng-1.5.4 this API must not be called before the PNG file header has been * read. Doing so will result in unexpected behavior and possible warnings or * errors if the PNG file contains a bKGD chunk. */ PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)) PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)) #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED # define PNG_BACKGROUND_GAMMA_UNKNOWN 0 # define PNG_BACKGROUND_GAMMA_SCREEN 1 # define PNG_BACKGROUND_GAMMA_FILE 2 # define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* Scale a 16-bit depth file down to 8-bit, accurately. */ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ /* Strip the second byte of information from a 16-bit depth file. */ PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_QUANTIZE_SUPPORTED /* Turn on quantizing, and reduce the palette to the number of colors * available. */ PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize)); #endif #ifdef PNG_READ_GAMMA_SUPPORTED /* The threshold on gamma processing is configurable but hard-wired into the * library. The following is the floating point variant. */ #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) /* Handle gamma correction. Screen_gamma=(display_exponent). * NOTE: this API simply sets the screen and file gamma values. It will * therefore override the value for gamma in a PNG file if it is called after * the file header has been read - use with care - call before reading the PNG * file for best results! * * These routines accept the same gamma values as png_set_alpha_mode (described * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either * API (floating point or fixed.) Notice, however, that the 'file_gamma' value * is the inverse of a 'screen gamma' value. */ PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, double screen_gamma, double override_file_gamma)) PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) #endif #ifdef PNG_WRITE_FLUSH_SUPPORTED /* Set how many lines between output flushes - 0 for no flushing */ PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); /* Flush the current PNG output buffer */ PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); #endif /* Optional update palette with requested transformations */ PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); /* Optional call to update the users info structure */ PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. */ PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read a row of data. */ PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, png_bytep display_row)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the whole image into memory at once. */ PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); #endif /* Write a row of image data */ PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, png_const_bytep row)); /* Write a few rows of image data: (*row) is not written; however, the type * is declared as writeable to maintain compatibility with previous versions * of libpng and to allow the 'display_row' array from read_rows to be passed * unchanged to write_rows. */ PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, png_uint_32 num_rows)); /* Write the image data */ PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); /* Write the end of the PNG file. */ PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. */ PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); #endif /* Free any memory associated with the png_info_struct */ PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, png_infopp info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); /* Set the libpng method of handling chunk CRC errors */ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, int ancil_action)); /* Values for png_set_crc_action() say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical * chunk. For versions prior to 0.90, the action was always error/quit, * whereas in version 0.90 and later, the action for CRC errors in ancillary * chunks is warn/discard. These values should NOT be changed. * * value action:critical action:ancillary */ #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ /* These functions give the user control over the scan-line filtering in * libpng and the compression methods used by zlib. These functions are * mainly useful for testing, as the defaults should work with most users. * Those users who are tight on memory or want faster performance at the * expense of compression can modify them. See the compression library * header file (zlib.h) for an explination of the compression functions. */ /* Set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, int filters)); /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types * below, in case they are supplied instead of the #defined constants. * These values should NOT be changed. */ #define PNG_NO_FILTERS 0x00 #define PNG_FILTER_NONE 0x08 #define PNG_FILTER_SUB 0x10 #define PNG_FILTER_UP 0x20 #define PNG_FILTER_AVG 0x40 #define PNG_FILTER_PAETH 0x80 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ PNG_FILTER_AVG | PNG_FILTER_PAETH) /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. * These defines should NOT be changed. */ #define PNG_FILTER_VALUE_NONE 0 #define PNG_FILTER_VALUE_SUB 1 #define PNG_FILTER_VALUE_UP 2 #define PNG_FILTER_VALUE_AVG 3 #define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_LAST 5 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ * defines, either the default (minimum-sum-of-absolute-differences), or * the experimental method (weighted-minimum-sum-of-absolute-differences). * * Weights are factors >= 1.0, indicating how important it is to keep the * filter type consistent between rows. Larger numbers mean the current * filter is that many times as likely to be the same as the "num_weights" * previous filters. This is cumulative for each previous row with a weight. * There needs to be "num_weights" values in "filter_weights", or it can be * NULL if the weights aren't being specified. Weights have no influence on * the selection of the first row filter. Well chosen weights can (in theory) * improve the compression for a given image. * * Costs are factors >= 1.0 indicating the relative decoding costs of a * filter type. Higher costs indicate more decoding expense, and are * therefore less likely to be selected over a filter with lower computational * costs. There needs to be a value in "filter_costs" for each valid filter * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't * setting the costs. Costs try to improve the speed of decompression without * unduly increasing the compressed image size. * * A negative weight or cost indicates the default value is to be used, and * values in the range [0.0, 1.0) indicate the value is to remain unchanged. * The default values for both weights and costs are currently 1.0, but may * change if good general weighting/cost heuristics can be found. If both * the weights and costs are set to 1.0, this degenerates the WEIGHTED method * to the UNWEIGHTED method, but with added encoding time/computation. */ PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_doublep filter_weights, png_const_doublep filter_costs)) PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_fixed_point_p filter_weights, png_const_fixed_point_p filter_costs)) #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be * changed. */ #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ #ifdef PNG_WRITE_SUPPORTED /* Set the library compression level. Currently, valid values range from * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have * shown that zlib compression levels 3-6 usually perform as well as level 9 * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, int method)); #endif #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED /* Also set zlib parameters for compressing non-IDAT chunks */ PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, int method)); #endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and * fprintf(). These functions can be made to use other I/O routines * at run time for those applications that need to handle I/O in a * different manner by calling png_set_???_fn(). See libpng-manual.txt for * more information. */ #ifdef PNG_STDIO_SUPPORTED /* Initialize the input/output for the PNG file to the default functions. */ PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); #endif /* Replace the (error and abort), and warning functions with user * supplied functions. If no messages are to be printed you must still * write and use replacement functions. The replacement error_fn should * still do a longjmp to the last setjmp location if you are using this * method of error handling. If error_fn or warning_fn is NULL, the * default function will be used. */ PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); /* Return the user pointer associated with the error functions */ PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). * It is probably a mistake to use NULL for output_flush_fn if * write_data_fn is not also NULL unless you have built libpng with * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's * default flush function, which uses the standard *FILE structure, will * be used. */ PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); /* Replace the default data input function with a user supplied one. */ PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)); /* Return the user pointer associated with the I/O functions */ PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, png_read_status_ptr read_row_fn)); PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, png_write_status_ptr write_row_fn)); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); /* Return the user pointer associated with the memory functions */ PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn)); #endif #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr write_user_transform_fn)); #endif #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)); /* Return the user pointer associated with the user transform functions */ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED /* Return information about the row currently being processed. Note that these * APIs do not fail but will return unexpected results if called outside a user * transform callback. Also note that when transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); #endif #ifdef PNG_READ_USER_CHUNKS_SUPPORTED /* This callback is called only for *unknown* chunks. If * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known * chunks to be treated as unknown, however in this case the callback must do * any processing required by the chunk (e.g. by calling the appropriate * png_set_ APIs.) * * There is no write support - on write, by default, all the chunks in the * 'unknown' list are written in the specified position. * * The integer return from the callback function is interpreted thus: * * negative: An error occured, png_chunk_error will be called. * zero: The chunk was not handled, the chunk will be saved. A critical * chunk will cause an error at this point unless it is to be saved. * positive: The chunk was handled, libpng will ignore/discard it. * * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about * how this behavior will change in libpng 1.7 */ PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); /* Returns the user pointer associated with the push read functions */ PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structrp png_ptr)); /* Function to be called when data becomes available */ PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)); /* A function which may be called *only* within png_process_data to stop the * processing of any more data. The function returns the number of bytes * remaining, excluding any that libpng has cached internally. A subsequent * call to png_process_data must supply these bytes again. If the argument * 'save' is set to true the routine will first save all the pending data and * will always return 0. */ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); /* A function which may be called *only* outside (after) a call to * png_process_data. It returns the number of bytes of data to skip in the * input. Normally it will return 0, but if it returns a non-zero value the * application must skip than number of bytes of input data and pass the * following data to the next call to png_process_data. */ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); #ifdef PNG_READ_INTERLACING_SUPPORTED /* Function that combines rows. 'new_row' is a flag that should come from * the callback and be non-NULL if anything needs to be done; the library * stores its own version of the new data internally and ignores the passed * in value. */ PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, png_bytep old_row, png_const_bytep new_row)); #endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.4.0 */ PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.2.4 */ PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Frees a pointer allocated by png_malloc() */ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); /* Free data that was allocated internally */ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 free_me, int num)); /* Reassign responsibility for freeing existing data, whether allocated * by libpng or by the application; this works on the png_info structure passed * in, it does not change the state for other png_info structures. * * It is unlikely that this function works correctly as of 1.6.0 and using it * may result either in memory leaks or double free of allocated data. */ PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr, png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED); /* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 /* Flags for png_ptr->free_me and info_ptr->free_me */ #define PNG_FREE_HIST 0x0008 #define PNG_FREE_ICCP 0x0010 #define PNG_FREE_SPLT 0x0020 #define PNG_FREE_ROWS 0x0040 #define PNG_FREE_PCAL 0x0080 #define PNG_FREE_SCAL 0x0100 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED # define PNG_FREE_UNKN 0x0200 #endif /* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */ #define PNG_FREE_PLTE 0x1000 #define PNG_FREE_TRNS 0x2000 #define PNG_FREE_TEXT 0x4000 #define PNG_FREE_ALL 0x7fff #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, png_voidp ptr), PNG_DEPRECATED); #endif #ifdef PNG_ERROR_TEXT_SUPPORTED /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); /* The same, but the chunk name is prepended to the error string. */ PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); #else /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); #endif #ifdef PNG_WARNINGS_SUPPORTED /* Non-fatal error in libpng. Can continue, but may have a problem. */ PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); /* Non-fatal error in libpng, chunk name is prepended to message. */ PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif #ifdef PNG_BENIGN_ERRORS_SUPPORTED /* Benign error in libpng. Can continue, but may have a problem. * User can choose whether to handle as a fatal error or as a warning. */ PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #ifdef PNG_READ_SUPPORTED /* Same, chunk name is prepended to message (only during read) */ PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif PNG_EXPORT(109, void, png_set_benign_errors, (png_structrp png_ptr, int allowed)); #else # ifdef PNG_ALLOW_BENIGN_ERRORS # define png_benign_error png_warning # define png_chunk_benign_error png_chunk_warning # else # define png_benign_error png_error # define png_chunk_benign_error png_chunk_error # endif #endif /* The png_set_ functions are for storing values in the png_info_struct. * Similarly, the png_get_ calls are used to read values from the * png_info_struct, either storing the parameters in the passed variables, or * setting pointers into the png_info_struct where the data is stored. The * png_get_ functions return a non-zero value if the data was available * in info_ptr, or return zero and do not change any of the parameters if the * data was not available. * * These functions should be used instead of directly accessing png_info * to avoid problems with future changes in the size and internal layout of * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* Returns row_pointers, which is an array of pointers to scanlines that was * returned from png_read_png(). */ PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Set row_pointers, which is an array of pointers to scanlines for use * by png_write_png(). */ PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image height in pixels. */ PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image bit_depth. */ PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image color_type. */ PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image filter_type. */ PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image interlace_type. */ PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image compression_type. */ PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, (png_const_structrp png_ptr, png_const_inforp info_ptr)) PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif /* PNG_EASY_ACCESS_SUPPORTED */ #ifdef PNG_READ_SUPPORTED /* Returns pointer to signature string read from PNG header */ PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_16p *background)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_16p background)); #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)) PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, double *green_X, double *green_Y, double *green_Z, double *blue_X, double *blue_Y, double *blue_Z)) PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_white_x, png_fixed_point *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_red_X, png_fixed_point *int_red_Y, png_fixed_point *int_red_Z, png_fixed_point *int_green_X, png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, png_fixed_point *int_blue_Z)) #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)) PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double red_Y, double red_Z, double green_X, double green_Y, double green_Z, double blue_X, double blue_Y, double blue_Z)) PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, png_fixed_point int_blue_y)) PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, png_fixed_point int_blue_X, png_fixed_point int_blue_Y, png_fixed_point int_blue_Z)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *file_gamma)) PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_file_gamma)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)) PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_file_gamma)) #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_16p *hist)); #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist)); #endif PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)); PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_method, int compression_method, int filter_method)); #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); #endif #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)); PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, png_inforp info_ptr, png_const_colorp palette, int num_palette)); #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_8p *sig_bit)); #endif #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_8p sig_bit)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *file_srgb_intent)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_charpp name, int *compression_type, png_bytepp profile, png_uint_32 *proflen)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp name, int compression_type, png_const_bytep profile, png_uint_32 proflen)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_sPLT_tpp entries)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); #endif #ifdef PNG_TEXT_SUPPORTED /* png_get_text also returns the number of text chunks in *num_text */ PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_textp *text_ptr, int *num_text)); #endif /* Note while png_set_text() will accept a structure whose text, * language, and translated keywords are NULL pointers, the structure * returned by png_get_text will always contain regular * zero-terminated C strings. They might be empty strings but * they will never be NULL pointers. */ #ifdef PNG_TEXT_SUPPORTED PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_timep *mod_time)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_timep mod_time)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)); #endif #ifdef PNG_sCAL_SUPPORTED PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)) #if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ defined(PNG_FLOATING_POINT_SUPPORTED) /* NOTE: this API is currently implemented using floating point arithmetic, * consequently it can only be used on systems with floating point support. * In any case the range of values supported by png_fixed_point is small and it * is highly recommended that png_get_sCAL_s be used instead. */ PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height)) #endif PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, double width, double height)) PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_fixed_point width, png_fixed_point height)) PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)); #endif /* PNG_sCAL_SUPPORTED */ #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED /* Provide the default handling for all unknown chunks or, optionally, for * specific unknown chunks. * * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was * ignored and the default was used, the per-chunk setting only had an effect on * write. If you wish to have chunk-specific handling on read in code that must * work on earlier versions you must use a user chunk callback to specify the * desired handling (keep or discard.) * * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The * parameter is interpreted as follows: * * READ: * PNG_HANDLE_CHUNK_AS_DEFAULT: * Known chunks: do normal libpng processing, do not keep the chunk (but * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) * Unknown chunks: for a specific chunk use the global default, when used * as the default discard the chunk data. * PNG_HANDLE_CHUNK_NEVER: * Discard the chunk data. * PNG_HANDLE_CHUNK_IF_SAFE: * Keep the chunk data if the chunk is not critical else raise a chunk * error. * PNG_HANDLE_CHUNK_ALWAYS: * Keep the chunk data. * * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks * it simply resets the behavior to the libpng default. * * INTERACTION WTIH USER CHUNK CALLBACKS: * The per-chunk handling is always used when there is a png_user_chunk_ptr * callback and the callback returns 0; the chunk is then always stored *unless* * it is critical and the per-chunk setting is other than ALWAYS. Notice that * the global default is *not* used in this case. (In effect the per-chunk * value is incremented to at least IF_SAFE.) * * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and * per-chunk defaults will be honored. If you want to preserve the current * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE * as the default - if you don't do this libpng 1.6 will issue a warning. * * If you want unhandled unknown chunks to be discarded in libpng 1.6 and * earlier simply return '1' (handled). * * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: * If this is *not* set known chunks will always be handled by libpng and * will never be stored in the unknown chunk list. Known chunks listed to * png_set_keep_unknown_chunks will have no effect. If it is set then known * chunks listed with a keep other than AS_DEFAULT will *never* be processed * by libpng, in addition critical chunks must either be processed by the * callback or saved. * * The IHDR and IEND chunks must not be listed. Because this turns off the * default handling for chunks that would otherwise be recognized the * behavior of libpng transformations may well become incorrect! * * WRITE: * When writing chunks the options only apply to the chunks specified by * png_set_unknown_chunks (below), libpng will *always* write known chunks * required by png_set_ calls and will always write the core critical chunks * (as required for PLTE). * * Each chunk in the png_set_unknown_chunks list is looked up in the * png_set_keep_unknown_chunks list to find the keep setting, this is then * interpreted as follows: * * PNG_HANDLE_CHUNK_AS_DEFAULT: * Write safe-to-copy chunks and write other chunks if the global * default is set to _ALWAYS, otherwise don't write this chunk. * PNG_HANDLE_CHUNK_NEVER: * Do not write the chunk. * PNG_HANDLE_CHUNK_IF_SAFE: * Write the chunk if it is safe-to-copy, otherwise do not write it. * PNG_HANDLE_CHUNK_ALWAYS: * Write the chunk. * * Note that the default behavior is effectively the opposite of the read case - * in read unknown chunks are not stored by default, in write they are written * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different * - on write the safe-to-copy bit is checked, on read the critical bit is * checked and on read if the chunk is critical an error will be raised. * * num_chunks: * =========== * If num_chunks is positive, then the "keep" parameter specifies the manner * for handling only those chunks appearing in the chunk_list array, * otherwise the chunk list array is ignored. * * If num_chunks is 0 the "keep" parameter specifies the default behavior for * unknown chunks, as described above. * * If num_chunks is negative, then the "keep" parameter specifies the manner * for handling all unknown chunks plus all chunks recognized by libpng * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to * be processed by libpng. */ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks)); /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; * the result is therefore true (non-zero) if special handling is required, * false for the default handling. */ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, png_const_bytep chunk_name)); #endif #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)); /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added * unknowns to the location currently stored in the png_struct. This is * invariably the wrong value on write. To fix this call the following API * for each chunk in the list with the correct location. If you know your * code won't be compiled on earlier versions you can rely on * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing * the correct thing. */ PNG_EXPORT(175, void, png_set_unknown_chunk_location, (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_unknown_chunkpp entries)); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. * If you need to turn it off for a chunk that your application has freed, * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, png_inforp info_ptr, int mask)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* The "params" pointer is currently not used and is for future expansion. */ PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); #endif PNG_EXPORT(180, png_const_charp, png_get_copyright, (png_const_structrp png_ptr)); PNG_EXPORT(181, png_const_charp, png_get_header_ver, (png_const_structrp png_ptr)); PNG_EXPORT(182, png_const_charp, png_get_header_version, (png_const_structrp png_ptr)); PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, (png_const_structrp png_ptr)); #ifdef PNG_MNG_FEATURES_SUPPORTED PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, png_uint_32 mng_features_permitted)); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 #define PNG_HANDLE_CHUNK_LAST 4 /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, png_uint_32 strip_mode)); #endif /* Added in libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); PNG_EXPORT(187, png_uint_32, png_get_user_width_max, (png_const_structrp png_ptr)); PNG_EXPORT(188, png_uint_32, png_get_user_height_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.0 */ PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)); PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.1 */ PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, png_alloc_size_t user_chunk_cache_max)); PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, (png_const_structrp png_ptr)); #endif #if defined(PNG_INCH_CONVERSIONS_SUPPORTED) PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_FP_EXPORT(196, float, png_get_x_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif # ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); # endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ /* Added in libpng-1.4.0 */ #ifdef PNG_IO_STATE_SUPPORTED PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); /* Removed from libpng 1.6; use png_get_io_chunk_type. */ PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), PNG_DEPRECATED) PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, (png_const_structrp png_ptr)); /* The flags returned by png_get_io_state() are the following: */ # define PNG_IO_NONE 0x0000 /* no I/O at this moment */ # define PNG_IO_READING 0x0001 /* currently reading */ # define PNG_IO_WRITING 0x0002 /* currently writing */ # define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ # define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ # define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ # define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ # define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ # define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ #endif /* ?PNG_IO_STATE_SUPPORTED */ /* Interlace support. The following macros are always defined so that if * libpng interlace handling is turned off the macros may be used to handle * interlaced images within the application. */ #define PNG_INTERLACE_ADAM7_PASSES 7 /* Two macros to return the first row and first column of the original, * full, image which appears in a given pass. 'pass' is in the range 0 * to 6 and the result is in the range 0 to 7. */ #define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) #define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) /* A macro to return the offset between pixels in the output row for a pair of * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that * follows. Note that ROW_OFFSET is the offset from one row to the next whereas * COL_OFFSET is from one column to the next, within a row. */ #define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) #define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) /* Two macros to help evaluate the number of rows or columns in each * pass. This is expressed as a shift - effectively log2 of the number or * rows or columns in each 8x8 tile of the original image. */ #define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) #define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) /* Hence two macros to determine the number of rows or columns in a given * pass of an image given its height or width. In fact these macros may * return non-zero even though the sub-image is empty, because the other * dimension may be empty for a small image. */ #define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) #define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) /* For the reader row callbacks (both progressive and sequential) it is * necessary to find the row in the output image given a row in an interlaced * image, so two more macros: */ #define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ (((y_in)<>(((7-(off))-(pass))<<2)) & 0xF) | \ ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) #define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) #define PNG_COL_IN_INTERLACE_PASS(x, pass) \ ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on * most machines. However, it does take more operations than the corresponding * divide method, so it may be slower on a few RISC systems. There are two * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. * * Note that the rounding factors are NOT supposed to be the same! 128 and * 32768 are correct for the NODIV code; 127 and 32767 are correct for the * standard method. * * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] */ /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ # define png_composite(composite, fg, alpha, bg) \ { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ * (png_uint_16)(alpha) \ + (png_uint_16)(bg)*(png_uint_16)(255 \ - (png_uint_16)(alpha)) + 128); \ (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } # define png_composite_16(composite, fg, alpha, bg) \ { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ * (png_uint_32)(alpha) \ + (png_uint_32)(bg)*(65535 \ - (png_uint_32)(alpha)) + 32768); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } #else /* Standard method using integer division */ # define png_composite(composite, fg, alpha, bg) \ (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ 127) / 255) # define png_composite_16(composite, fg, alpha, bg) \ (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ 32767) / 65535) #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); #endif PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, png_const_bytep buf)); /* No png_get_int_16 -- may be added if there's a real need for it. */ /* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); #endif #ifdef PNG_SAVE_INT_32_SUPPORTED PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); #endif /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); /* No png_save_int_16 -- may be added if there's a real need for it. */ #endif #ifdef PNG_USE_READ_MACROS /* Inline macros to do direct reads of bytes from the input buffer. * The png_get_int_32() routine assumes we are using two's complement * format for negative values, which is almost certainly true. */ # define PNG_get_uint_32(buf) \ (((png_uint_32)(*(buf)) << 24) + \ ((png_uint_32)(*((buf) + 1)) << 16) + \ ((png_uint_32)(*((buf) + 2)) << 8) + \ ((png_uint_32)(*((buf) + 3)))) /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the * function) incorrectly returned a value of type png_uint_32. */ # define PNG_get_uint_16(buf) \ ((png_uint_16) \ (((unsigned int)(*(buf)) << 8) + \ ((unsigned int)(*((buf) + 1))))) # define PNG_get_int_32(buf) \ ((png_int_32)((*(buf) & 0x80) \ ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \ : (png_int_32)png_get_uint_32(buf))) /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, * but defining a macro name prefixed with PNG_PREFIX. */ # ifndef PNG_PREFIX # define png_get_uint_32(buf) PNG_get_uint_32(buf) # define png_get_uint_16(buf) PNG_get_uint_16(buf) # define png_get_int_32(buf) PNG_get_int_32(buf) # endif #else # ifdef PNG_PREFIX /* No macros; revert to the (redefined) function */ # define PNG_get_uint_32 (png_get_uint_32) # define PNG_get_uint_16 (png_get_uint_16) # define PNG_get_int_32 (png_get_int_32) # endif #endif /******************************************************************************* * SIMPLIFIED API ******************************************************************************* * * Please read the documentation in libpng-manual.txt (TODO: write said * documentation) if you don't understand what follows. * * The simplified API hides the details of both libpng and the PNG file format * itself. It allows PNG files to be read into a very limited number of * in-memory bitmap formats or to be written from the same formats. If these * formats do not accomodate your needs then you can, and should, use the more * sophisticated APIs above - these support a wide variety of in-memory formats * and a wide variety of sophisticated transformations to those formats as well * as a wide variety of APIs to manipulate ancillary information. * * To read a PNG file using the simplified API: * * 1) Declare a 'png_image' structure (see below) on the stack and set the * version field to PNG_IMAGE_VERSION. * 2) Call the appropriate png_image_begin_read... function. * 3) Set the png_image 'format' member to the required sample format. * 4) Allocate a buffer for the image and, if required, the color-map. * 5) Call png_image_finish_read to read the image and, if required, the * color-map into your buffers. * * There are no restrictions on the format of the PNG input itself; all valid * color types, bit depths, and interlace methods are acceptable, and the * input image is transformed as necessary to the requested in-memory format * during the png_image_finish_read() step. The only caveat is that if you * request a color-mapped image from a PNG that is full-color or makes * complex use of an alpha channel the transformation is extremely lossy and the * result may look terrible. * * To write a PNG file using the simplified API: * * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. * 2) Initialize the members of the structure that describe the image, setting * the 'format' member to the format of the image samples. * 3) Call the appropriate png_image_write... function with a pointer to the * image and, if necessary, the color-map to write the PNG data. * * png_image is a structure that describes the in-memory format of an image * when it is being read or defines the in-memory format of an image that you * need to write: */ #define PNG_IMAGE_VERSION 1 typedef struct png_control *png_controlp; typedef struct { png_controlp opaque; /* Initialize to NULL, free with png_image_free */ png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ png_uint_32 width; /* Image width in pixels (columns) */ png_uint_32 height; /* Image height in pixels (rows) */ png_uint_32 format; /* Image format as defined below */ png_uint_32 flags; /* A bit mask containing informational flags */ png_uint_32 colormap_entries; /* Number of entries in the color-map */ /* In the event of an error or warning the following field will be set to a * non-zero value and the 'message' field will contain a '\0' terminated * string with the libpng error or warning message. If both warnings and * an error were encountered, only the error is recorded. If there * are multiple warnings, only the first one is recorded. * * The upper 30 bits of this value are reserved, the low two bits contain * a value as follows: */ # define PNG_IMAGE_WARNING 1 # define PNG_IMAGE_ERROR 2 /* * The result is a two bit code such that a value more than 1 indicates * a failure in the API just called: * * 0 - no warning or error * 1 - warning * 2 - error * 3 - error preceded by warning */ # define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) png_uint_32 warning_or_error; char message[64]; } png_image, *png_imagep; /* The samples of the image have one to four channels whose components have * original values in the range 0 to 1.0: * * 1: A single gray or luminance channel (G). * 2: A gray/luminance channel and an alpha channel (GA). * 3: Three red, green, blue color channels (RGB). * 4: Three color channels and an alpha channel (RGBA). * * The components are encoded in one of two ways: * * a) As a small integer, value 0..255, contained in a single byte. For the * alpha channel the original value is simply value/255. For the color or * luminance channels the value is encoded according to the sRGB specification * and matches the 8-bit format expected by typical display devices. * * The color/gray channels are not scaled (pre-multiplied) by the alpha * channel and are suitable for passing to color management software. * * b) As a value in the range 0..65535, contained in a 2-byte integer. All * channels can be converted to the original value by dividing by 65535; all * channels are linear. Color channels use the RGB encoding (RGB end-points) of * the sRGB specification. This encoding is identified by the * PNG_FORMAT_FLAG_LINEAR flag below. * * When the simplified API needs to convert between sRGB and linear colorspaces, * the actual sRGB transfer curve defined in the sRGB specification (see the * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 * approximation used elsewhere in libpng. * * When an alpha channel is present it is expected to denote pixel coverage * of the color or luminance channels and is returned as an associated alpha * channel: the color/gray channels are scaled (pre-multiplied) by the alpha * value. * * The samples are either contained directly in the image data, between 1 and 8 * bytes per pixel according to the encoding, or are held in a color-map indexed * by bytes in the image data. In the case of a color-map the color-map entries * are individual samples, encoded as above, and the image data has one byte per * pixel to select the relevant sample from the color-map. */ /* PNG_FORMAT_* * * #defines to be used in png_image::format. Each #define identifies a * particular layout of sample data and, if present, alpha values. There are * separate defines for each of the two component encodings. * * A format is built up using single bit flag values. All combinations are * valid. Formats can be built up from the flag values or you can use one of * the predefined values below. When testing formats always use the FORMAT_FLAG * macros to test for individual features - future versions of the library may * add new flags. * * When reading or writing color-mapped images the format should be set to the * format of the entries in the color-map then png_image_{read,write}_colormap * called to read or write the color-map and set the format correctly for the * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! * * NOTE: libpng can be built with particular features disabled, if you see * compiler errors because the definition of one of the following flags has been * compiled out it is because libpng does not have the required support. It is * possible, however, for the libpng configuration to enable the format on just * read or just write; in that case you may see an error at run time. You can * guard against this by checking for the definition of the appropriate * "_SUPPORTED" macro, one of: * * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED */ #define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ #define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ #define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2 byte channels else 1 byte */ #define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ #ifdef PNG_FORMAT_BGR_SUPPORTED # define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ #endif #ifdef PNG_FORMAT_AFIRST_SUPPORTED # define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ #endif /* Commonly used formats have predefined macros. * * First the single byte (sRGB) formats: */ #define PNG_FORMAT_GRAY 0 #define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA #define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR #define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) #define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) /* Then the linear 2-byte formats. When naming these "Y" is used to * indicate a luminance (gray) channel. */ #define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR #define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) #define PNG_FORMAT_LINEAR_RGB_ALPHA \ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) /* With color-mapped formats the image data is one byte for each pixel, the byte * is an index into the color-map which is formatted as above. To obtain a * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP * to one of the above definitions, or you can use one of the definitions below. */ #define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) /* PNG_IMAGE macros * * These are convenience macros to derive information from a png_image * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the * actual image sample values - either the entries in the color-map or the * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values * for the pixels and will always return 1 for color-mapped formats. The * remaining macros return information about the rows in the image and the * complete image. * * NOTE: All the macros that take a png_image::format parameter are compile time * constants if the format parameter is, itself, a constant. Therefore these * macros can be used in array declarations and case labels where required. * Similarly the macros are also pre-processor constants (sizeof is not used) so * they can be used in #if tests. * * First the information about the samples. */ #define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) /* Return the total number of channels in a given format: 1..4 */ #define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) /* Return the size in bytes of a single component of a pixel or color-map * entry (as appropriate) in the image: 1 or 2. */ #define PNG_IMAGE_SAMPLE_SIZE(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) /* This is the size of the sample data for one sample. If the image is * color-mapped it is the size of one color-map entry (and image pixels are * one byte in size), otherwise it is the size of one image pixel. */ #define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) /* The maximum size of the color-map required by the format expressed in a * count of components. This can be used to compile-time allocate a * color-map: * * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; * * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; * * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the * information from one of the png_image_begin_read_ APIs and dynamically * allocate the required memory. */ /* Corresponding information about the pixels */ #define PNG_IMAGE_PIXEL_(test,fmt)\ (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) #define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) /* The number of separate channels (components) in a pixel; 1 for a * color-mapped image. */ #define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) /* The size, in bytes, of each component in a pixel; 1 for a color-mapped * image. */ #define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ /* Information about the whole row, or whole image */ #define PNG_IMAGE_ROW_STRIDE(image)\ (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) /* Return the total number of components in a single row of the image; this * is the minimum 'row stride', the minimum count of components between each * row. For a color-mapped image this is the minimum number of bytes in a * row. */ #define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) /* Return the size, in bytes, of an image buffer given a png_image and a row * stride - the number of components to leave space for in each row. */ #define PNG_IMAGE_SIZE(image)\ PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) /* Return the size, in bytes, of the image in memory given just a png_image; * the row stride is the minimum stride required for the image. */ #define PNG_IMAGE_COLORMAP_SIZE(image)\ (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) /* Return the size, in bytes, of the color-map of this image. If the image * format is not a color-map format this will return a size sufficient for * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if * you don't want to allocate a color-map in this case. */ /* PNG_IMAGE_FLAG_* * * Flags containing additional information about the image are held in the * 'flags' field of png_image. */ #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 /* This indicates the the RGB values of the in-memory bitmap do not * correspond to the red, green and blue end-points defined by sRGB. */ #define PNG_IMAGE_FLAG_FAST 0x02 /* On write emphasise speed over compression; the resultant PNG file will be * larger but will be produced significantly faster, particular for large * images. Do not use this option for images which will be distributed, only * used it when producing intermediate files that will be read back in * repeatedly. For a typical 24-bit image the option will double the read * speed at the cost of increasing the image size by 25%, however for many * more compressible images the PNG file can be 10 times larger with only a * slight speed gain. */ #define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 /* On read if the image is a 16-bit per component image and there is no gAMA * or sRGB chunk assume that the components are sRGB encoded. Notice that * images output by the simplified API always have gamma information; setting * this flag only affects the interpretation of 16-bit images from an * external source. It is recommended that the application expose this flag * to the user; the user can normally easily recognize the difference between * linear and sRGB encoding. This flag has no effect on write - the data * passed to the write APIs must have the correct encoding (as defined * above.) * * If the flag is not set (the default) input 16-bit per component data is * assumed to be linear. * * NOTE: the flag can only be set after the png_image_begin_read_ call, * because that call initializes the 'flags' field. */ #ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* READ APIs * --------- * * The png_image passed to the read APIs must have been initialized by setting * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) */ #ifdef PNG_STDIO_SUPPORTED PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, const char *file_name)); /* The named file is opened for read and the image header is filled in * from the PNG header in the file. */ PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, FILE* file)); /* The PNG header is read from the stdio FILE object. */ #endif /* PNG_STDIO_SUPPORTED */ PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, png_const_voidp memory, png_size_t size)); /* The PNG header is read from the given memory buffer. */ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, png_const_colorp background, void *buffer, png_int_32 row_stride, void *colormap)); /* Finish reading the image into the supplied buffer and clean up the * png_image structure. * * row_stride is the step, in byte or 2-byte units as appropriate, * between adjacent rows. A positive stride indicates that the top-most row * is first in the buffer - the normal top-down arrangement. A negative * stride indicates that the bottom-most row is first in the buffer. * * background need only be supplied if an alpha channel must be removed from * a png_byte format and the removal is to be done by compositing on a solid * color; otherwise it may be NULL and any composition will be done directly * onto the buffer. The value is an sRGB color to use for the background, * for grayscale output the green channel is used. * * background must be supplied when an alpha channel must be removed from a * single byte color-mapped output format, in other words if: * * 1) The original format from png_image_begin_read_from_* had * PNG_FORMAT_FLAG_ALPHA set. * 2) The format set by the application does not. * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and * PNG_FORMAT_FLAG_LINEAR *not* set. * * For linear output removing the alpha channel is always done by compositing * on black and background is ignored. * * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. * image->colormap_entries will be updated to the actual number of entries * written to the colormap; this may be less than the original value. */ PNG_EXPORT(238, void, png_image_free, (png_imagep image)); /* Free any data allocated by libpng in image->opaque, setting the pointer to * NULL. May be called at any time after the structure is initialized. */ #endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED /* WRITE APIS * ---------- * For write you must initialize a png_image structure to describe the image to * be written. To do this use memset to set the whole structure to 0 then * initialize fields describing your image. * * version: must be set to PNG_IMAGE_VERSION * opaque: must be initialized to NULL * width: image width in pixels * height: image height in rows * format: the format of the data (image and color-map) you wish to write * flags: set to 0 unless one of the defined flags applies; set * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB * values do not correspond to the colors in sRGB. * colormap_entries: set to the number of entries in the color-map (0 to 256) */ PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, const char *file, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the named file. */ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the given (FILE*). */ /* With both write APIs if image is in one of the linear formats with 16-bit * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG * gamma encoded according to the sRGB specification, otherwise a 16-bit linear * encoded PNG file is written. * * With color-mapped data formats the colormap parameter point to a color-map * with at least image->colormap_entries encoded in the specified format. If * the format is linear the written PNG color-map will be converted to sRGB * regardless of the convert_to_8_bit flag. * * With all APIs row_stride is handled as in the read APIs - it is the spacing * from one row to the next in component sized units (1 or 2 bytes) and if * negative indicates a bottom-up row layout in the buffer. * * Note that the write API does not support interlacing or sub-8-bit pixels. */ #endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */ /******************************************************************************* * END OF SIMPLIFIED API ******************************************************************************/ #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED PNG_EXPORT(242, void, png_set_check_for_invalid_index, (png_structrp png_ptr, int allowed)); # ifdef PNG_GET_PALETTE_MAX_SUPPORTED PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, png_const_infop info_ptr)); # endif #endif /* CHECK_FOR_INVALID_INDEX */ /******************************************************************************* * IMPLEMENTATION OPTIONS ******************************************************************************* * * Support for arbitrary implementation-specific optimizations. The API allows * particular options to be turned on or off. 'Option' is the number of the * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given * by the PNG_OPTION_ defines below. * * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, * are detected at run time, however sometimes it may be impossible * to do this in user mode, in which case it is necessary to discover * the capabilities in an OS specific way. Such capabilities are * listed here when libpng has support for them and must be turned * ON by the application if present. * * SOFTWARE: sometimes software optimizations actually result in performance * decrease on some architectures or systems, or with some sets of * PNG images. 'Software' options allow such optimizations to be * selected at run time. */ #ifdef PNG_SET_OPTION_SUPPORTED #ifdef PNG_ARM_NEON_API_SUPPORTED # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ #endif #define PNG_OPTION_NEXT 2 /* Next option - numbers must be even */ /* Return values: NOTE: there are four values and 'off' is *not* zero */ #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ #define PNG_OPTION_INVALID 1 /* Option number out of range */ #define PNG_OPTION_OFF 2 #define PNG_OPTION_ON 3 PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, int onoff)); #endif /******************************************************************************* * END OF HARDWARE OPTIONS ******************************************************************************/ /* Maintainer: Put new public prototypes here ^, in libpng.3, and project * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt */ /* The last ordinal number (this is the *last* one already used; the next * one to use is one more than this.) Maintainer, remember to add an entry to * scripts/symbols.def as well. */ #ifdef PNG_EXPORT_LAST_ORDINAL PNG_EXPORT_LAST_ORDINAL(244); #endif #ifdef __cplusplus } #endif #endif /* PNG_VERSION_INFO_ONLY */ /* Do not put anything past this line */ #endif /* PNG_H */ ================================================ FILE: cocos2d/external/png/include/ios/pngconf.h ================================================ /* pngconf.h - machine configurable file for libpng * * libpng version 1.6.2 - April 25, 2013 * * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h * */ /* Any machine specific code is near the front of this file, so if you * are configuring libpng for a machine, you may want to read the section * starting here down to where it starts to typedef png_color, png_text, * and png_info. */ #ifndef PNGCONF_H #define PNGCONF_H /* To do: Do all of this in scripts/pnglibconf.dfa */ #ifdef PNG_SAFE_LIMITS_SUPPORTED # ifdef PNG_USER_WIDTH_MAX # undef PNG_USER_WIDTH_MAX # define PNG_USER_WIDTH_MAX 1000000L # endif # ifdef PNG_USER_HEIGHT_MAX # undef PNG_USER_HEIGHT_MAX # define PNG_USER_HEIGHT_MAX 1000000L # endif # ifdef PNG_USER_CHUNK_MALLOC_MAX # undef PNG_USER_CHUNK_MALLOC_MAX # define PNG_USER_CHUNK_MALLOC_MAX 4000000L # endif # ifdef PNG_USER_CHUNK_CACHE_MAX # undef PNG_USER_CHUNK_CACHE_MAX # define PNG_USER_CHUNK_CACHE_MAX 128 # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C * compiler for correct compilation. The following header files are required by * the standard. If your compiler doesn't provide these header files, or they * do not match the standard, you will need to provide/improve them. */ #include #include /* Library header files. These header files are all defined by ISOC90; libpng * expects conformant implementations, however, an ISOC90 conformant system need * not provide these header files if the functionality cannot be implemented. * In this case it will be necessary to disable the relevant parts of libpng in * the build of pnglibconf.h. * * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not * include this unnecessary header file. */ #ifdef PNG_STDIO_SUPPORTED /* Required for the definition of FILE: */ # include #endif #ifdef PNG_SETJMP_SUPPORTED /* Required for the definition of jmp_buf and the declaration of longjmp: */ # include #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Required for struct tm: */ # include #endif #endif /* PNG_BUILDING_SYMBOL_TABLE */ /* Prior to 1.6.0 it was possible to turn off 'const' in declarations using * PNG_NO_CONST; this is no longer supported except for data declarations which * apparently still cause problems in 2011 on some compilers. */ #define PNG_CONST const /* backward compatibility only */ /* This controls optimization of the reading of 16 and 32 bit values * from PNG files. It can be set on a per-app-file basis - it * just changes whether a macro is used when the function is called. * The library builder sets the default; if read functions are not * built into the library the macro implementation is forced on. */ #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED # define PNG_USE_READ_MACROS #endif #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) # if PNG_DEFAULT_READ_MACROS # define PNG_USE_READ_MACROS # endif #endif /* COMPILER SPECIFIC OPTIONS. * * These options are provided so that a variety of difficult compilers * can be used. Some are fixed at build time (e.g. PNG_API_RULE * below) but still have compiler specific implementations, others * may be changed on a per-file basis when compiling against libpng. */ /* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect * against legacy (pre ISOC90) compilers that did not understand function * prototypes. It is not required for modern C compilers. */ #ifndef PNGARG # define PNGARG(arglist) arglist #endif /* Function calling conventions. * ============================= * Normally it is not necessary to specify to the compiler how to call * a function - it just does it - however on x86 systems derived from * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems * and some others) there are multiple ways to call a function and the * default can be changed on the compiler command line. For this reason * libpng specifies the calling convention of every exported function and * every function called via a user supplied function pointer. This is * done in this file by defining the following macros: * * PNGAPI Calling convention for exported functions. * PNGCBAPI Calling convention for user provided (callback) functions. * PNGCAPI Calling convention used by the ANSI-C library (required * for longjmp callbacks and sometimes used internally to * specify the calling convention for zlib). * * These macros should never be overridden. If it is necessary to * change calling convention in a private build this can be done * by setting PNG_API_RULE (which defaults to 0) to one of the values * below to select the correct 'API' variants. * * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. * This is correct in every known environment. * PNG_API_RULE=1 Use the operating system convention for PNGAPI and * the 'C' calling convention (from PNGCAPI) for * callbacks (PNGCBAPI). This is no longer required * in any known environment - if it has to be used * please post an explanation of the problem to the * libpng mailing list. * * These cases only differ if the operating system does not use the C * calling convention, at present this just means the above cases * (x86 DOS/Windows sytems) and, even then, this does not apply to * Cygwin running on those systems. * * Note that the value must be defined in pnglibconf.h so that what * the application uses to call the library matches the conventions * set when building the library. */ /* Symbol export * ============= * When building a shared library it is almost always necessary to tell * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' * is used to mark the symbols. On some systems these symbols can be * extracted at link time and need no special processing by the compiler, * on other systems the symbols are flagged by the compiler and just * the declaration requires a special tag applied (unfortunately) in a * compiler dependent way. Some systems can do either. * * A small number of older systems also require a symbol from a DLL to * be flagged to the program that calls it. This is a problem because * we do not know in the header file included by application code that * the symbol will come from a shared library, as opposed to a statically * linked one. For this reason the application must tell us by setting * the magic flag PNG_USE_DLL to turn on the special processing before * it includes png.h. * * Four additional macros are used to make this happen: * * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from * the build or imported if PNG_USE_DLL is set - compiler * and system specific. * * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to * 'type', compiler specific. * * PNG_DLL_EXPORT Set to the magic to use during a libpng build to * make a symbol exported from the DLL. Not used in the * public header files; see pngpriv.h for how it is used * in the libpng build. * * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come * from a DLL - used to define PNG_IMPEXP when * PNG_USE_DLL is set. */ /* System specific discovery. * ========================== * This code is used at build time to find PNG_IMPEXP, the API settings * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL * import processing is possible. On Windows systems it also sets * compiler-specific macros to the values required to change the calling * conventions of the various functions. */ #if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or * MinGW on any architecture currently supported by Windows. Also includes * Watcom builds but these need special treatment because they are not * compatible with GCC or Visual C because of different calling conventions. */ # if PNG_API_RULE == 2 /* If this line results in an error, either because __watcall is not * understood or because of a redefine just below you cannot use *this* * build of the library with the compiler you are using. *This* build was * build using Watcom and applications must also be built using Watcom! */ # define PNGCAPI __watcall # endif # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) # define PNGCAPI __cdecl # if PNG_API_RULE == 1 /* If this line results in an error __stdcall is not understood and * PNG_API_RULE should not have been set to '1'. */ # define PNGAPI __stdcall # endif # else /* An older compiler, or one not detected (erroneously) above, * if necessary override on the command line to get the correct * variants for the compiler. */ # ifndef PNGCAPI # define PNGCAPI _cdecl # endif # if PNG_API_RULE == 1 && !defined(PNGAPI) # define PNGAPI _stdcall # endif # endif /* compiler/api */ /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) # error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" # endif # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ (defined(__BORLANDC__) && __BORLANDC__ < 0x500) /* older Borland and MSC * compilers used '__export' and required this to be after * the type. */ # ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP # endif # define PNG_DLL_EXPORT __export # else /* newer compiler */ # define PNG_DLL_EXPORT __declspec(dllexport) # ifndef PNG_DLL_IMPORT # define PNG_DLL_IMPORT __declspec(dllimport) # endif # endif /* compiler */ #else /* !Windows */ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # define PNGAPI _System # else /* !Windows/x86 && !OS/2 */ /* Use the defaults, or define PNG*API on the command line (but * this will have to be done for every compile!) */ # endif /* other system, !OS/2 */ #endif /* !Windows/x86 */ /* Now do all the defaulting . */ #ifndef PNGCAPI # define PNGCAPI #endif #ifndef PNGCBAPI # define PNGCBAPI PNGCAPI #endif #ifndef PNGAPI # define PNGAPI PNGCAPI #endif /* PNG_IMPEXP may be set on the compilation system command line or (if not set) * then in an internal header file when building the library, otherwise (when * using the library) it is set here. */ #ifndef PNG_IMPEXP # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) /* This forces use of a DLL, disallowing static linking */ # define PNG_IMPEXP PNG_DLL_IMPORT # endif # ifndef PNG_IMPEXP # define PNG_IMPEXP # endif #endif /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat * 'attributes' as a storage class - the attributes go at the start of the * function definition, and attributes are always appended regardless of the * compiler. This considerably simplifies these macros but may cause problems * if any compilers both need function attributes and fail to handle them as * a storage class (this is unlikely.) */ #ifndef PNG_FUNCTION # define PNG_FUNCTION(type, name, args, attributes) attributes type name args #endif #ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type #endif /* The ordinal value is only relevant when preprocessing png.h for symbol * table entries, so we discard it here. See the .dfn files in the * scripts directory. */ #ifndef PNG_EXPORTA # define PNG_EXPORTA(ordinal, type, name, args, attributes)\ PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ extern attributes) #endif /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, * so make something non-empty to satisfy the requirement: */ #define PNG_EMPTY /*empty list*/ #define PNG_EXPORT(ordinal, type, name, args)\ PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) /* Use PNG_REMOVED to comment out a removed interface. */ #ifndef PNG_REMOVED # define PNG_REMOVED(ordinal, type, name, args, attributes) #endif #ifndef PNG_CALLBACK # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) #endif /* Support for compiler specific function attributes. These are used * so that where compiler support is available incorrect use of API * functions in png.h will generate compiler warnings. * * Added at libpng-1.2.41. */ #ifndef PNG_NO_PEDANTIC_WARNINGS # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED # define PNG_PEDANTIC_WARNINGS_SUPPORTED # endif #endif #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED /* Support for compiler specific function attributes. These are used * so that where compiler support is available, incorrect use of API * functions in png.h will generate compiler warnings. Added at libpng * version 1.2.41. Disabling these removes the warnings but may also produce * less efficient code. */ # if defined(__GNUC__) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif # ifndef PNG_NORETURN # define PNG_NORETURN __attribute__((__noreturn__)) # endif # if __GNUC__ >= 3 # ifndef PNG_ALLOCATED # define PNG_ALLOCATED __attribute__((__malloc__)) # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __attribute__((__deprecated__)) # endif # ifndef PNG_PRIVATE # if 0 /* Doesn't work so we use deprecated instead*/ # define PNG_PRIVATE \ __attribute__((warning("This function is not exported by libpng."))) # else # define PNG_PRIVATE \ __attribute__((__deprecated__)) # endif # endif # if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* __GNUC__ == 3.0 */ # endif /* __GNUC__ >= 3 */ # elif defined(_MSC_VER) && (_MSC_VER >= 1300) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* not supported */ # endif # ifndef PNG_NORETURN # define PNG_NORETURN __declspec(noreturn) # endif # ifndef PNG_ALLOCATED # if (_MSC_VER >= 1400) # define PNG_ALLOCATED __declspec(restrict) # endif # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __declspec(deprecated) # endif # ifndef PNG_PRIVATE # define PNG_PRIVATE __declspec(deprecated) # endif # ifndef PNG_RESTRICT # if (_MSC_VER >= 1400) # define PNG_RESTRICT __restrict # endif # endif # elif defined(__WATCOMC__) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* _MSC_VER */ #endif /* PNG_PEDANTIC_WARNINGS */ #ifndef PNG_DEPRECATED # define PNG_DEPRECATED /* Use of this function is deprecated */ #endif #ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* The result of this function must be checked */ #endif #ifndef PNG_NORETURN # define PNG_NORETURN /* This function does not return */ #endif #ifndef PNG_ALLOCATED # define PNG_ALLOCATED /* The result of the function is new memory */ #endif #ifndef PNG_PRIVATE # define PNG_PRIVATE /* This is a private libpng function */ #endif #ifndef PNG_RESTRICT # define PNG_RESTRICT /* The C99 "restrict" feature */ #endif #ifndef PNG_FP_EXPORT /* A floating point API. */ # ifdef PNG_FLOATING_POINT_SUPPORTED # define PNG_FP_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No floating point APIs */ # define PNG_FP_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_FIXED_EXPORT /* A fixed point API. */ # ifdef PNG_FIXED_POINT_SUPPORTED # define PNG_FIXED_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No fixed point APIs */ # define PNG_FIXED_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* Some typedefs to get us started. These should be safe on most of the common * platforms. * * png_uint_32 and png_int_32 may, currently, be larger than required to hold a * 32-bit value however this is not normally advisable. * * png_uint_16 and png_int_16 should always be two bytes in size - this is * verified at library build time. * * png_byte must always be one byte in size. * * The checks below use constants from limits.h, as defined by the ISOC90 * standard. */ #if CHAR_BIT == 8 && UCHAR_MAX == 255 typedef unsigned char png_byte; #else # error "libpng requires 8 bit bytes" #endif #if INT_MIN == -32768 && INT_MAX == 32767 typedef int png_int_16; #elif SHRT_MIN == -32768 && SHRT_MAX == 32767 typedef short png_int_16; #else # error "libpng requires a signed 16 bit type" #endif #if UINT_MAX == 65535 typedef unsigned int png_uint_16; #elif USHRT_MAX == 65535 typedef unsigned short png_uint_16; #else # error "libpng requires an unsigned 16 bit type" #endif #if INT_MIN < -2147483646 && INT_MAX > 2147483646 typedef int png_int_32; #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 typedef long int png_int_32; #else # error "libpng requires a signed 32 bit (or more) type" #endif #if UINT_MAX > 4294967294 typedef unsigned int png_uint_32; #elif ULONG_MAX > 4294967294 typedef unsigned long int png_uint_32; #else # error "libpng requires an unsigned 32 bit (or more) type" #endif /* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, * requires an ISOC90 compiler and relies on consistent behavior of sizeof. */ typedef size_t png_size_t; typedef ptrdiff_t png_ptrdiff_t; /* libpng needs to know the maximum value of 'size_t' and this controls the * definition of png_alloc_size_t, below. This maximum value of size_t limits * but does not control the maximum allocations the library makes - there is * direct application control of this through png_set_user_limits(). */ #ifndef PNG_SMALL_SIZE_T /* Compiler specific tests for systems where size_t is known to be less than * 32 bits (some of these systems may no longer work because of the lack of * 'far' support; see above.) */ # if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ (defined(_MSC_VER) && defined(MAXSEG_64K)) # define PNG_SMALL_SIZE_T # endif #endif /* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to * png_alloc_size_t are not necessary; in fact, it is recommended not to use * them at all so that the compiler can complain when something turns out to be * problematic. * * Casts in the other direction (from png_alloc_size_t to png_size_t or * png_uint_32) should be explicitly applied; however, we do not expect to * encounter practical situations that require such conversions. * * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than * 4294967295 - i.e. less than the maximum value of png_uint_32. */ #ifdef PNG_SMALL_SIZE_T typedef png_uint_32 png_alloc_size_t; #else typedef png_size_t png_alloc_size_t; #endif /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler * implementations of Intel CPU specific support of user-mode segmented address * spaces, where 16-bit pointers address more than 65536 bytes of memory using * separate 'segment' registers. The implementation requires two different * types of pointer (only one of which includes the segment value.) * * If required this support is available in version 1.2 of libpng and may be * available in versions through 1.5, although the correctness of the code has * not been verified recently. */ /* Typedef for floating-point numbers that are converted to fixed-point with a * multiple of 100,000, e.g., gamma */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ typedef void * png_voidp; typedef const void * png_const_voidp; typedef png_byte * png_bytep; typedef const png_byte * png_const_bytep; typedef png_uint_32 * png_uint_32p; typedef const png_uint_32 * png_const_uint_32p; typedef png_int_32 * png_int_32p; typedef const png_int_32 * png_const_int_32p; typedef png_uint_16 * png_uint_16p; typedef const png_uint_16 * png_const_uint_16p; typedef png_int_16 * png_int_16p; typedef const png_int_16 * png_const_int_16p; typedef char * png_charp; typedef const char * png_const_charp; typedef png_fixed_point * png_fixed_point_p; typedef const png_fixed_point * png_const_fixed_point_p; typedef png_size_t * png_size_tp; typedef const png_size_t * png_const_size_tp; #ifdef PNG_STDIO_SUPPORTED typedef FILE * png_FILE_p; #endif #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * png_doublep; typedef const double * png_const_doublep; #endif /* Pointers to pointers; i.e. arrays */ typedef png_byte * * png_bytepp; typedef png_uint_32 * * png_uint_32pp; typedef png_int_32 * * png_int_32pp; typedef png_uint_16 * * png_uint_16pp; typedef png_int_16 * * png_int_16pp; typedef const char * * png_const_charpp; typedef char * * png_charpp; typedef png_fixed_point * * png_fixed_point_pp; #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * * png_doublepp; #endif /* Pointers to pointers to pointers; i.e., pointer to array */ typedef char * * * png_charppp; #endif /* PNG_BUILDING_SYMBOL_TABLE */ #endif /* PNGCONF_H */ ================================================ FILE: cocos2d/external/png/include/ios/pnglibconf.h ================================================ /* pnglibconf.h - library build configuration */ /* libpng version 1.6.2 - April 25, 2013 */ /* Copyright (c) 1998-2012 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ /* For conditions of distribution and use, see the disclaimer */ /* and license in png.h */ /* pnglibconf.h */ /* Machine generated file: DO NOT EDIT */ /* Derived from: scripts/pnglibconf.dfa */ #ifndef PNGLCONF_H #define PNGLCONF_H /* options */ #define PNG_16BIT_SUPPORTED #define PNG_ALIGNED_MEMORY_SUPPORTED /*#undef PNG_ARM_NEON_API_SUPPORTED*/ /*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ /*#undef PNG_ARM_NEON_SUPPORTED*/ #define PNG_BENIGN_ERRORS_SUPPORTED #define PNG_BENIGN_READ_ERRORS_SUPPORTED /*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_COLORSPACE_SUPPORTED #define PNG_CONSOLE_IO_SUPPORTED #define PNG_CONVERT_tIME_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ #define PNG_ERROR_TEXT_SUPPORTED #define PNG_FIXED_POINT_SUPPORTED #define PNG_FLOATING_ARITHMETIC_SUPPORTED #define PNG_FLOATING_POINT_SUPPORTED #define PNG_FORMAT_AFIRST_SUPPORTED #define PNG_FORMAT_BGR_SUPPORTED #define PNG_GAMMA_SUPPORTED #define PNG_GET_PALETTE_MAX_SUPPORTED #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED #define PNG_INCH_CONVERSIONS_SUPPORTED #define PNG_INFO_IMAGE_SUPPORTED #define PNG_IO_STATE_SUPPORTED #define PNG_MNG_FEATURES_SUPPORTED #define PNG_POINTER_INDEXING_SUPPORTED #define PNG_PROGRESSIVE_READ_SUPPORTED #define PNG_READ_16BIT_SUPPORTED #define PNG_READ_ALPHA_MODE_SUPPORTED #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED #define PNG_READ_BACKGROUND_SUPPORTED #define PNG_READ_BGR_SUPPORTED #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_READ_COMPOSITE_NODIV_SUPPORTED #define PNG_READ_COMPRESSED_TEXT_SUPPORTED #define PNG_READ_EXPAND_16_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_FILLER_SUPPORTED #define PNG_READ_GAMMA_SUPPORTED #define PNG_READ_GET_PALETTE_MAX_SUPPORTED #define PNG_READ_GRAY_TO_RGB_SUPPORTED #define PNG_READ_INTERLACING_SUPPORTED #define PNG_READ_INT_FUNCTIONS_SUPPORTED #define PNG_READ_INVERT_ALPHA_SUPPORTED #define PNG_READ_INVERT_SUPPORTED #define PNG_READ_OPT_PLTE_SUPPORTED #define PNG_READ_PACKSWAP_SUPPORTED #define PNG_READ_PACK_SUPPORTED #define PNG_READ_QUANTIZE_SUPPORTED #define PNG_READ_RGB_TO_GRAY_SUPPORTED #define PNG_READ_SCALE_16_TO_8_SUPPORTED #define PNG_READ_SHIFT_SUPPORTED #define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED #define PNG_READ_SUPPORTED #define PNG_READ_SWAP_ALPHA_SUPPORTED #define PNG_READ_SWAP_SUPPORTED #define PNG_READ_TEXT_SUPPORTED #define PNG_READ_TRANSFORMS_SUPPORTED #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED #define PNG_READ_USER_CHUNKS_SUPPORTED #define PNG_READ_USER_TRANSFORM_SUPPORTED #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED #define PNG_READ_gAMA_SUPPORTED #define PNG_READ_hIST_SUPPORTED #define PNG_READ_iCCP_SUPPORTED #define PNG_READ_iTXt_SUPPORTED #define PNG_READ_oFFs_SUPPORTED #define PNG_READ_pCAL_SUPPORTED #define PNG_READ_pHYs_SUPPORTED #define PNG_READ_sBIT_SUPPORTED #define PNG_READ_sCAL_SUPPORTED #define PNG_READ_sPLT_SUPPORTED #define PNG_READ_sRGB_SUPPORTED #define PNG_READ_tEXt_SUPPORTED #define PNG_READ_tIME_SUPPORTED #define PNG_READ_tRNS_SUPPORTED #define PNG_READ_zTXt_SUPPORTED /*#undef PNG_SAFE_LIMITS_SUPPORTED*/ #define PNG_SAVE_INT_32_SUPPORTED #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SEQUENTIAL_READ_SUPPORTED #define PNG_SETJMP_SUPPORTED #define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED #define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED /*#undef PNG_SET_OPTION_SUPPORTED*/ #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SET_USER_LIMITS_SUPPORTED #define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_READ_BGR_SUPPORTED #define PNG_SIMPLIFIED_READ_SUPPORTED #define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED #define PNG_SIMPLIFIED_WRITE_SUPPORTED #define PNG_STDIO_SUPPORTED #define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_TEXT_SUPPORTED #define PNG_TIME_RFC1123_SUPPORTED #define PNG_UNKNOWN_CHUNKS_SUPPORTED #define PNG_USER_CHUNKS_SUPPORTED #define PNG_USER_LIMITS_SUPPORTED #define PNG_USER_MEM_SUPPORTED #define PNG_USER_TRANSFORM_INFO_SUPPORTED #define PNG_USER_TRANSFORM_PTR_SUPPORTED #define PNG_WARNINGS_SUPPORTED #define PNG_WRITE_16BIT_SUPPORTED #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #define PNG_WRITE_BGR_SUPPORTED #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED #define PNG_WRITE_FILLER_SUPPORTED #define PNG_WRITE_FILTER_SUPPORTED #define PNG_WRITE_FLUSH_SUPPORTED #define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED #define PNG_WRITE_INTERLACING_SUPPORTED #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED #define PNG_WRITE_INVERT_ALPHA_SUPPORTED #define PNG_WRITE_INVERT_SUPPORTED #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED #define PNG_WRITE_PACKSWAP_SUPPORTED #define PNG_WRITE_PACK_SUPPORTED #define PNG_WRITE_SHIFT_SUPPORTED #define PNG_WRITE_SUPPORTED #define PNG_WRITE_SWAP_ALPHA_SUPPORTED #define PNG_WRITE_SWAP_SUPPORTED #define PNG_WRITE_TEXT_SUPPORTED #define PNG_WRITE_TRANSFORMS_SUPPORTED #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_WRITE_USER_TRANSFORM_SUPPORTED #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #define PNG_WRITE_bKGD_SUPPORTED #define PNG_WRITE_cHRM_SUPPORTED #define PNG_WRITE_gAMA_SUPPORTED #define PNG_WRITE_hIST_SUPPORTED #define PNG_WRITE_iCCP_SUPPORTED #define PNG_WRITE_iTXt_SUPPORTED #define PNG_WRITE_oFFs_SUPPORTED #define PNG_WRITE_pCAL_SUPPORTED #define PNG_WRITE_pHYs_SUPPORTED #define PNG_WRITE_sBIT_SUPPORTED #define PNG_WRITE_sCAL_SUPPORTED #define PNG_WRITE_sPLT_SUPPORTED #define PNG_WRITE_sRGB_SUPPORTED #define PNG_WRITE_tEXt_SUPPORTED #define PNG_WRITE_tIME_SUPPORTED #define PNG_WRITE_tRNS_SUPPORTED #define PNG_WRITE_zTXt_SUPPORTED #define PNG_bKGD_SUPPORTED #define PNG_cHRM_SUPPORTED #define PNG_gAMA_SUPPORTED #define PNG_hIST_SUPPORTED #define PNG_iCCP_SUPPORTED #define PNG_iTXt_SUPPORTED #define PNG_oFFs_SUPPORTED #define PNG_pCAL_SUPPORTED #define PNG_pHYs_SUPPORTED #define PNG_sBIT_SUPPORTED #define PNG_sCAL_SUPPORTED #define PNG_sPLT_SUPPORTED #define PNG_sRGB_SUPPORTED #define PNG_tEXt_SUPPORTED #define PNG_tIME_SUPPORTED #define PNG_tRNS_SUPPORTED #define PNG_zTXt_SUPPORTED /* end of options */ /* settings */ #define PNG_API_RULE 0 #define PNG_CALLOC_SUPPORTED #define PNG_COST_SHIFT 3 #define PNG_DEFAULT_READ_MACROS 1 #define PNG_GAMMA_THRESHOLD_FIXED 5000 #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE #define PNG_INFLATE_BUF_SIZE 1024 #define PNG_MAX_GAMMA_8 11 #define PNG_QUANTIZE_BLUE_BITS 5 #define PNG_QUANTIZE_GREEN_BITS 5 #define PNG_QUANTIZE_RED_BITS 5 #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 #define PNG_WEIGHT_SHIFT 8 #define PNG_ZBUF_SIZE 8192 #define PNG_Z_DEFAULT_COMPRESSION (-1) #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 #define PNG_Z_DEFAULT_STRATEGY 1 #define PNG_sCAL_PRECISION 5 #define PNG_sRGB_PROFILE_CHECKS 2 /* end of settings */ #endif /* PNGLCONF_H */ ================================================ FILE: cocos2d/external/png/include/mac/png.h ================================================ /* png.h - header file for PNG reference library * * libpng version 1.6.2 - April 25, 2013 * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license (See LICENSE, below) * * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.6.2 - April 25, 2013: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: * * Due to various miscommunications, unforeseen code incompatibilities * and occasional factors outside the authors' control, version numbering * on the library has not always been consistent and straightforward. * The following table summarizes matters since version 0.89c, which was * the first widely used release: * * source png.h png.h shared-lib * version string int version * ------- ------ ----- ---------- * 0.89c "1.0 beta 3" 0.89 89 1.0.89 * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] * 0.97c 0.97 97 2.0.97 * 0.98 0.98 98 2.0.98 * 0.99 0.99 98 2.0.99 * 0.99a-m 0.99 99 2.0.99 * 1.00 1.00 100 2.1.0 [100 should be 10000] * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] * 1.0.1 png.h string is 10001 2.1.0 * 1.0.1a-e identical to the 10002 from here on, the shared library * 1.0.2 source version) 10002 is 2.V where V is the source code * 1.0.2a-b 10003 version, except as noted. * 1.0.3 10003 * 1.0.3a-d 10004 * 1.0.4 10004 * 1.0.4a-f 10005 * 1.0.5 (+ 2 patches) 10005 * 1.0.5a-d 10006 * 1.0.5e-r 10100 (not source compatible) * 1.0.5s-v 10006 (not binary compatible) * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) * 1.0.6d-f 10007 (still binary incompatible) * 1.0.6g 10007 * 1.0.6h 10007 10.6h (testing xy.z so-numbering) * 1.0.6i 10007 10.6i * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) * 1.0.7 1 10007 (still compatible) * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 * 1.0.8rc1 1 10008 2.1.0.8rc1 * 1.0.8 1 10008 2.1.0.8 * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 * 1.0.9rc1 1 10009 2.1.0.9rc1 * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 * 1.0.9rc2 1 10009 2.1.0.9rc2 * 1.0.9 1 10009 2.1.0.9 * 1.0.10beta1 1 10010 2.1.0.10beta1 * 1.0.10rc1 1 10010 2.1.0.10rc1 * 1.0.10 1 10010 2.1.0.10 * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 * 1.0.11rc1 1 10011 2.1.0.11rc1 * 1.0.11 1 10011 2.1.0.11 * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 * 1.0.12rc1 2 10012 2.1.0.12rc1 * 1.0.12 2 10012 2.1.0.12 * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 * 1.2.0rc1 3 10200 3.1.2.0rc1 * 1.2.0 3 10200 3.1.2.0 * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 * 1.2.1 3 10201 3.1.2.1 * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 * 1.0.13 10 10013 10.so.0.1.0.13 * 1.2.2 12 10202 12.so.0.1.2.2 * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 * 1.2.3 12 10203 12.so.0.1.2.3 * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 * 1.0.14 10 10014 10.so.0.1.0.14 * 1.2.4 13 10204 12.so.0.1.2.4 * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 * 1.0.15 10 10015 10.so.0.1.0.15 * 1.2.5 13 10205 12.so.0.1.2.5 * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 * 1.0.16 10 10016 10.so.0.1.0.16 * 1.2.6 13 10206 12.so.0.1.2.6 * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 * 1.0.17rc1 10 10017 12.so.0.1.0.17rc1 * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 * 1.0.17 10 10017 12.so.0.1.0.17 * 1.2.7 13 10207 12.so.0.1.2.7 * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 * 1.0.18 10 10018 12.so.0.1.0.18 * 1.2.8 13 10208 12.so.0.1.2.8 * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 * 1.2.9beta4-11 13 10209 12.so.0.9[.0] * 1.2.9rc1 13 10209 12.so.0.9[.0] * 1.2.9 13 10209 12.so.0.9[.0] * 1.2.10beta1-7 13 10210 12.so.0.10[.0] * 1.2.10rc1-2 13 10210 12.so.0.10[.0] * 1.2.10 13 10210 12.so.0.10[.0] * 1.4.0beta1-5 14 10400 14.so.0.0[.0] * 1.2.11beta1-4 13 10211 12.so.0.11[.0] * 1.4.0beta7-8 14 10400 14.so.0.0[.0] * 1.2.11 13 10211 12.so.0.11[.0] * 1.2.12 13 10212 12.so.0.12[.0] * 1.4.0beta9-14 14 10400 14.so.0.0[.0] * 1.2.13 13 10213 12.so.0.13[.0] * 1.4.0beta15-36 14 10400 14.so.0.0[.0] * 1.4.0beta37-87 14 10400 14.so.14.0[.0] * 1.4.0rc01 14 10400 14.so.14.0[.0] * 1.4.0beta88-109 14 10400 14.so.14.0[.0] * 1.4.0rc02-08 14 10400 14.so.14.0[.0] * 1.4.0 14 10400 14.so.14.0[.0] * 1.4.1beta01-03 14 10401 14.so.14.1[.0] * 1.4.1rc01 14 10401 14.so.14.1[.0] * 1.4.1beta04-12 14 10401 14.so.14.1[.0] * 1.4.1 14 10401 14.so.14.1[.0] * 1.4.2 14 10402 14.so.14.2[.0] * 1.4.3 14 10403 14.so.14.3[.0] * 1.4.4 14 10404 14.so.14.4[.0] * 1.5.0beta01-58 15 10500 15.so.15.0[.0] * 1.5.0rc01-07 15 10500 15.so.15.0[.0] * 1.5.0 15 10500 15.so.15.0[.0] * 1.5.1beta01-11 15 10501 15.so.15.1[.0] * 1.5.1rc01-02 15 10501 15.so.15.1[.0] * 1.5.1 15 10501 15.so.15.1[.0] * 1.5.2beta01-03 15 10502 15.so.15.2[.0] * 1.5.2rc01-03 15 10502 15.so.15.2[.0] * 1.5.2 15 10502 15.so.15.2[.0] * 1.5.3beta01-10 15 10503 15.so.15.3[.0] * 1.5.3rc01-02 15 10503 15.so.15.3[.0] * 1.5.3beta11 15 10503 15.so.15.3[.0] * 1.5.3 [omitted] * 1.5.4beta01-08 15 10504 15.so.15.4[.0] * 1.5.4rc01 15 10504 15.so.15.4[.0] * 1.5.4 15 10504 15.so.15.4[.0] * 1.5.5beta01-08 15 10505 15.so.15.5[.0] * 1.5.5rc01 15 10505 15.so.15.5[.0] * 1.5.5 15 10505 15.so.15.5[.0] * 1.5.6beta01-07 15 10506 15.so.15.6[.0] * 1.5.6rc01-03 15 10506 15.so.15.6[.0] * 1.5.6 15 10506 15.so.15.6[.0] * 1.5.7beta01-05 15 10507 15.so.15.7[.0] * 1.5.7rc01-03 15 10507 15.so.15.7[.0] * 1.5.7 15 10507 15.so.15.7[.0] * 1.6.0beta01-40 16 10600 16.so.16.0[.0] * 1.6.0rc01-08 16 10600 16.so.16.0[.0] * 1.6.0 16 10600 16.so.16.0[.0] * 1.6.1beta01-09 16 10601 16.so.16.1[.0] * 1.6.1rc01 16 10601 16.so.16.1[.0] * 1.6.1 16 10601 16.so.16.1[.0] * 1.6.2beta01 16 10602 16.so.16.2[.0] * 1.6.2rc01-06 16 10602 16.so.16.2[.0] * 1.6.2 16 10602 16.so.16.2[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. The * PNG_LIBPNG_VER macro, which is not used within libpng but is available * for applications, is an unsigned integer of the form xyyzz corresponding * to the source version x.y.z (leading zeros in y and z). Beta versions * were given the previous public release number plus a letter, until * version 1.0.6j; from then on they were given the upcoming public * release number plus "betaNN" or "rcNN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled * application is loaded with a different version of the library. * * DLLNUM will change each time there are forward or backward changes * in binary compatibility (e.g., when a new feature is added). * * See libpng-manual.txt or libpng.3 for more information. The PNG * specification is available as a W3C Recommendation and as an ISO * Specification, defines should NOT be changed. */ #define PNG_INFO_gAMA 0x0001 #define PNG_INFO_sBIT 0x0002 #define PNG_INFO_cHRM 0x0004 #define PNG_INFO_PLTE 0x0008 #define PNG_INFO_tRNS 0x0010 #define PNG_INFO_bKGD 0x0020 #define PNG_INFO_hIST 0x0040 #define PNG_INFO_pHYs 0x0080 #define PNG_INFO_oFFs 0x0100 #define PNG_INFO_tIME 0x0200 #define PNG_INFO_pCAL 0x0400 #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ #define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using * the routines for other purposes. */ typedef struct png_row_info_struct { png_uint_32 width; /* width of row */ png_size_t rowbytes; /* number of bytes in row */ png_byte color_type; /* color type of row */ png_byte bit_depth; /* bit depth of row */ png_byte channels; /* number of channels (1, 2, 3, or 4) */ png_byte pixel_depth; /* bits per pixel (depth * channels) */ } png_row_info; typedef png_row_info * png_row_infop; typedef png_row_info * * png_row_infopp; /* These are the function types for the I/O functions and for the functions * that allow the user to override the default I/O functions with his or her * own. The png_error_ptr type should match that of user-supplied warning * and error functions, while the png_rw_ptr type should match that of the * user read/write data functions. Note that the 'write' function must not * modify the buffer it is passed. The 'read' function, on the other hand, is * expected to return the read data in the buffer. */ typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, int)); typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, int)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); /* The following callback receives png_uint_32 row_number, int pass for the * png_bytep data of the row. When transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, png_uint_32, int)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, png_bytep)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, png_unknown_chunkp)); #endif #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED /* not used anywhere */ /* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ #endif #ifdef PNG_SETJMP_SUPPORTED /* This must match the function definition in , and the application * must include this before png.h to obtain the definition of jmp_buf. The * function is required to be PNG_NORETURN, but this is not checked. If the * function does return the application will crash via an abort() or similar * system level call. * * If you get a warning here while building the library you may need to make * changes to ensure that pnglibconf.h records the calling convention used by * your compiler. This may be very difficult - try using a different compiler * to build the library! */ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); #endif /* Transform masks for the high-level interface */ #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ /* Added to libpng-1.2.34 */ #define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ /* Added to libpng-1.4.0 */ #define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ /* Added to libpng-1.5.4 */ #define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ #define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 /* NOTE: prior to 1.5 these functions had no 'API' style declaration, * this allowed the zlib default functions to be used on Windows * platforms. In 1.5 the zlib default malloc (which just calls malloc and * ignores the first argument) should be completely compatible with the * following. */ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, png_alloc_size_t)); typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); /* Section 3: exported functions * Here are the function definitions most commonly used. This is not * the place to find out how to use libpng. See libpng-manual.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. * * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in * pngconf.h and in the *.dfn files in the scripts directory. * * PNG_EXPORT(ordinal, type, name, (args)); * * ordinal: ordinal that is used while building * *.def files. The ordinal value is only * relevant when preprocessing png.h with * the *.dfn files for building symbol table * entries, and are removed by pngconf.h. * type: return type of the function * name: function name * args: function arguments, with types * * When we wish to append attributes to a function prototype we use * the PNG_EXPORTA() macro instead. * * PNG_EXPORTA(ordinal, type, name, (args), attributes); * * ordinal, type, name, and args: same as in PNG_EXPORT(). * attributes: function attributes */ /* Returns the version number of the library */ PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); /* Tell lib we have already handled the first magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, png_size_t num_to_check)); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ #define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) /* Allocate and initialize png_ptr struct for reading, and any other memory. */ PNG_EXPORTA(4, png_structp, png_create_read_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); /* Allocate and initialize png_ptr struct for writing, and any other memory */ PNG_EXPORTA(5, png_structp, png_create_write_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, (png_const_structrp png_ptr)); PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, png_size_t size)); /* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp * match up. */ #ifdef PNG_SETJMP_SUPPORTED /* This function returns the jmp_buf built in to *png_ptr. It must be * supplied with an appropriate 'longjmp' function to use on that jmp_buf * unless the default error function is overridden in which case NULL is * acceptable. The size of the jmp_buf is checked against the actual size * allocated by the library - the call will return NULL on a mismatch * indicating an ABI mismatch. */ PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); # define png_jmpbuf(png_ptr) \ (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) #else # define png_jmpbuf(png_ptr) \ (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) #endif /* This function should be used by libpng applications in place of * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it * will use it; otherwise it will call PNG_ABORT(). This function was * added in libpng-1.5.0. */ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), PNG_NORETURN); #ifdef PNG_READ_SUPPORTED /* Reset the compression stream */ PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); #endif /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(11, png_structp, png_create_read_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); PNG_EXPORTA(12, png_structp, png_create_write_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); #endif /* Write the PNG file signature. */ PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); /* Write a PNG chunk - size, type, (optional) data, CRC. */ PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep chunk_name, png_const_bytep data, png_size_t length)); /* Write the start of a PNG chunk - length and chunk name. */ PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, png_const_bytep chunk_name, png_uint_32 length)); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, png_const_bytep data, png_size_t length)); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); /* Allocate and initialize the info structure */ PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), PNG_ALLOCATED); /* DEPRECATED: this function allowed init structures to be created using the * default allocation method (typically malloc). Use is deprecated in 1.6.0 and * the API will be removed in the future. */ PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, png_size_t png_info_struct_size), PNG_DEPRECATED); /* Writes all the PNG information before the image. */ PNG_EXPORT(20, void, png_write_info_before_PLTE, (png_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(21, void, png_write_info, (png_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. */ PNG_EXPORT(22, void, png_read_info, (png_structrp png_ptr, png_inforp info_ptr)); #endif #ifdef PNG_TIME_RFC1123_SUPPORTED /* Convert to a US string format: there is no localization support in this * routine. The original implementation used a 29 character buffer in * png_struct, this will be removed in future versions. */ #if PNG_LIBPNG_VER < 10700 /* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, png_const_timep ptime),PNG_DEPRECATED); #endif PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], png_const_timep ptime)); #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Convert from a struct tm to png_time */ PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, const struct tm * ttime)); /* Convert from time_t to png_time. Uses gmtime() */ PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); #endif /* PNG_CONVERT_tIME_SUPPORTED */ #ifdef PNG_READ_EXPAND_SUPPORTED /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); #endif #ifdef PNG_READ_EXPAND_16_SUPPORTED /* Expand to 16-bit channels, forces conversion of palette to RGB and expansion * of a tRNS chunk if present. */ PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Expand the grayscale to 24-bit RGB if necessary. */ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); #endif #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED /* Reduce RGB to grayscale. */ #define PNG_ERROR_ACTION_NONE 1 #define PNG_ERROR_ACTION_WARN 2 #define PNG_ERROR_ACTION_ERROR 3 #define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, int error_action, double red, double green)) PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)) PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp png_ptr)); #endif #ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, png_colorp palette)); #endif #ifdef PNG_READ_ALPHA_MODE_SUPPORTED /* How the alpha channel is interpreted - this affects how the color channels of * a PNG file are returned when an alpha channel, or tRNS chunk in a palette * file, is present. * * This has no effect on the way pixels are written into a PNG output * datastream. The color samples in a PNG datastream are never premultiplied * with the alpha samples. * * The default is to return data according to the PNG specification: the alpha * channel is a linear measure of the contribution of the pixel to the * corresponding composited pixel. The gamma encoded color channels must be * scaled according to the contribution and to do this it is necessary to undo * the encoding, scale the color values, perform the composition and reencode * the values. This is the 'PNG' mode. * * The alternative is to 'associate' the alpha with the color information by * storing color channel values that have been scaled by the alpha. The * advantage is that the color channels can be resampled (the image can be * scaled) in this form. The disadvantage is that normal practice is to store * linear, not (gamma) encoded, values and this requires 16-bit channels for * still images rather than the 8-bit channels that are just about sufficient if * gamma encoding is used. In addition all non-transparent pixel values, * including completely opaque ones, must be gamma encoded to produce the final * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the * latter being the two common names for associated alpha color channels.) * * Since it is not necessary to perform arithmetic on opaque color values so * long as they are not to be resampled and are in the final color space it is * possible to optimize the handling of alpha by storing the opaque pixels in * the PNG format (adjusted for the output color space) while storing partially * opaque pixels in the standard, linear, format. The accuracy required for * standard alpha composition is relatively low, because the pixels are * isolated, therefore typically the accuracy loss in storing 8-bit linear * values is acceptable. (This is not true if the alpha channel is used to * simulate transparency over large areas - use 16 bits or the PNG mode in * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is * treated as opaque only if the alpha value is equal to the maximum value. * * The final choice is to gamma encode the alpha channel as well. This is * broken because, in practice, no implementation that uses this choice * correctly undoes the encoding before handling alpha composition. Use this * choice only if other serious errors in the software or hardware you use * mandate it; the typical serious error is for dark halos to appear around * opaque areas of the composited PNG image because of arithmetic overflow. * * The API function png_set_alpha_mode specifies which of these choices to use * with an enumerated 'mode' value and the gamma of the required output: */ #define PNG_ALPHA_PNG 0 /* according to the PNG standard */ #define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ #define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ #define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ #define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ #define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, double output_gamma)) PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, int mode, png_fixed_point output_gamma)) #endif #if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) /* The output_gamma value is a screen gamma in libpng terminology: it expresses * how to decode the output values, not how they are encoded. The values used * correspond to the normal numbers used to describe the overall gamma of a * computer display system; for example 2.2 for an sRGB conformant system. The * values are scaled by 100000 in the _fixed version of the API (so 220000 for * sRGB.) * * The inverse of the value is always used to provide a default for the PNG file * encoding if it has no gAMA chunk and if png_set_gamma() has not been called * to override the PNG gamma information. * * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode * opaque pixels however pixels with lower alpha values are not encoded, * regardless of the output gamma setting. * * When the standard Porter Duff handling is requested with mode 1 the output * encoding is set to be linear and the output_gamma value is only relevant * as a default for input data that has no gamma information. The linear output * encoding will be overridden if png_set_gamma() is called - the results may be * highly unexpected! * * The following numbers are derived from the sRGB standard and the research * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing * correction required to take account of any differences in the color * environment of the original scene and the intended display environment; the * value expresses how to *decode* the image for display, not how the original * data was *encoded*. * * sRGB provides a peg for the PNG standard by defining a viewing environment. * sRGB itself, and earlier TV standards, actually use a more complex transform * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is * limited to simple power laws.) By saying that an image for direct display on * an sRGB conformant system should be stored with a gAMA chunk value of 45455 * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification * makes it possible to derive values for other display systems and * environments. * * The Mac value is deduced from the sRGB based on an assumption that the actual * extra viewing correction used in early Mac display systems was implemented as * a power 1.45 lookup table. * * Any system where a programmable lookup table is used or where the behavior of * the final display device characteristics can be changed requires system * specific code to obtain the current characteristic. However this can be * difficult and most PNG gamma correction only requires an approximate value. * * By default, if png_set_alpha_mode() is not called, libpng assumes that all * values are unencoded, linear, values and that the output device also has a * linear characteristic. This is only very rarely correct - it is invariably * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the * default if you don't know what the right answer is! * * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS * 10.6) which used a correction table to implement a somewhat lower gamma on an * otherwise sRGB system. * * Both these values are reserved (not simple gamma values) in order to allow * more precise correction internally in the future. * * NOTE: the following values can be passed to either the fixed or floating * point APIs, but the floating point API will also accept floating point * values. */ #define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ #define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ #define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ #define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ #endif /* The following are examples of calls to png_set_alpha_mode to achieve the * required overall gamma correction and, where necessary, alpha * premultiplication. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * This is the default libpng handling of the alpha channel - it is not * pre-multiplied into the color components. In addition the call states * that the output is for a sRGB system and causes all PNG files without gAMA * chunks to be assumed to be encoded using sRGB. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * In this case the output is assumed to be something like an sRGB conformant * display preceeded by a power-law lookup table of power 1.45. This is how * early Mac systems behaved. * * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); * This is the classic Jim Blinn approach and will work in academic * environments where everything is done by the book. It has the shortcoming * of assuming that input PNG data with no gamma information is linear - this * is unlikely to be correct unless the PNG files where generated locally. * Most of the time the output precision will be so low as to show * significant banding in dark areas of the image. * * png_set_expand_16(pp); * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); * This is a somewhat more realistic Jim Blinn inspired approach. PNG files * are assumed to have the sRGB encoding if not marked with a gamma value and * the output is always 16 bits per component. This permits accurate scaling * and processing of the data. If you know that your input PNG files were * generated locally you might need to replace PNG_DEFAULT_sRGB with the * correct value for your system. * * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); * If you just need to composite the PNG image onto an existing background * and if you control the code that does this you can use the optimization * setting. In this case you just copy completely opaque pixels to the * output. For pixels that are not completely transparent (you just skip * those) you do the composition math using png_composite or png_composite_16 * below then encode the resultant 8-bit or 16-bit values to match the output * encoding. * * Other cases * If neither the PNG nor the standard linear encoding work for you because * of the software or hardware you use then you have a big problem. The PNG * case will probably result in halos around the image. The linear encoding * will probably result in a washed out, too bright, image (it's actually too * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably * substantially reduce the halos. Alternatively try: * * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); * This option will also reduce the halos, but there will be slight dark * halos round the opaque parts of the image where the background is light. * In the OPTIMIZED mode the halos will be light halos where the background * is dark. Take your pick - the halos are unavoidable unless you can get * your hardware/software fixed! (The OPTIMIZED approach is slightly * faster.) * * When the default gamma of PNG files doesn't match the output gamma. * If you have PNG files with no gamma information png_set_alpha_mode allows * you to provide a default gamma, but it also sets the ouput gamma to the * matching value. If you know your PNG files have a gamma that doesn't * match the output you can take advantage of the fact that * png_set_alpha_mode always sets the output gamma but only sets the PNG * default if it is not already set: * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * The first call sets both the default and the output gamma values, the * second call overrides the output gamma without changing the default. This * is easier than achieving the same effect with png_set_gamma. You must use * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will * fire if more than one call to png_set_alpha_mode and png_set_background is * made in the same read operation, however multiple calls with PNG_ALPHA_PNG * are ignored. */ #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ # define PNG_FILLER_BEFORE 0 # define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, png_uint_32 filler, int flags)); #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p true_bits)); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) /* Have the code handle the interlacing. Returns the number of passes. * MUST be called before png_read_update_info or png_start_read_image, * otherwise it will not have the desired effect. Note that it is still * necessary to call png_read_row or png_read_rows png_get_image_height * times for each pass. */ PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED /* Handle alpha and tRNS by replacing with a background color. Prior to * libpng-1.5.4 this API must not be called before the PNG file header has been * read. Doing so will result in unexpected behavior and possible warnings or * errors if the PNG file contains a bKGD chunk. */ PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)) PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)) #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED # define PNG_BACKGROUND_GAMMA_UNKNOWN 0 # define PNG_BACKGROUND_GAMMA_SCREEN 1 # define PNG_BACKGROUND_GAMMA_FILE 2 # define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* Scale a 16-bit depth file down to 8-bit, accurately. */ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ /* Strip the second byte of information from a 16-bit depth file. */ PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_QUANTIZE_SUPPORTED /* Turn on quantizing, and reduce the palette to the number of colors * available. */ PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize)); #endif #ifdef PNG_READ_GAMMA_SUPPORTED /* The threshold on gamma processing is configurable but hard-wired into the * library. The following is the floating point variant. */ #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) /* Handle gamma correction. Screen_gamma=(display_exponent). * NOTE: this API simply sets the screen and file gamma values. It will * therefore override the value for gamma in a PNG file if it is called after * the file header has been read - use with care - call before reading the PNG * file for best results! * * These routines accept the same gamma values as png_set_alpha_mode (described * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either * API (floating point or fixed.) Notice, however, that the 'file_gamma' value * is the inverse of a 'screen gamma' value. */ PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, double screen_gamma, double override_file_gamma)) PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) #endif #ifdef PNG_WRITE_FLUSH_SUPPORTED /* Set how many lines between output flushes - 0 for no flushing */ PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); /* Flush the current PNG output buffer */ PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); #endif /* Optional update palette with requested transformations */ PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); /* Optional call to update the users info structure */ PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. */ PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read a row of data. */ PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, png_bytep display_row)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the whole image into memory at once. */ PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); #endif /* Write a row of image data */ PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, png_const_bytep row)); /* Write a few rows of image data: (*row) is not written; however, the type * is declared as writeable to maintain compatibility with previous versions * of libpng and to allow the 'display_row' array from read_rows to be passed * unchanged to write_rows. */ PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, png_uint_32 num_rows)); /* Write the image data */ PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); /* Write the end of the PNG file. */ PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. */ PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); #endif /* Free any memory associated with the png_info_struct */ PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, png_infopp info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); /* Set the libpng method of handling chunk CRC errors */ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, int ancil_action)); /* Values for png_set_crc_action() say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical * chunk. For versions prior to 0.90, the action was always error/quit, * whereas in version 0.90 and later, the action for CRC errors in ancillary * chunks is warn/discard. These values should NOT be changed. * * value action:critical action:ancillary */ #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ /* These functions give the user control over the scan-line filtering in * libpng and the compression methods used by zlib. These functions are * mainly useful for testing, as the defaults should work with most users. * Those users who are tight on memory or want faster performance at the * expense of compression can modify them. See the compression library * header file (zlib.h) for an explination of the compression functions. */ /* Set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, int filters)); /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types * below, in case they are supplied instead of the #defined constants. * These values should NOT be changed. */ #define PNG_NO_FILTERS 0x00 #define PNG_FILTER_NONE 0x08 #define PNG_FILTER_SUB 0x10 #define PNG_FILTER_UP 0x20 #define PNG_FILTER_AVG 0x40 #define PNG_FILTER_PAETH 0x80 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ PNG_FILTER_AVG | PNG_FILTER_PAETH) /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. * These defines should NOT be changed. */ #define PNG_FILTER_VALUE_NONE 0 #define PNG_FILTER_VALUE_SUB 1 #define PNG_FILTER_VALUE_UP 2 #define PNG_FILTER_VALUE_AVG 3 #define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_LAST 5 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ * defines, either the default (minimum-sum-of-absolute-differences), or * the experimental method (weighted-minimum-sum-of-absolute-differences). * * Weights are factors >= 1.0, indicating how important it is to keep the * filter type consistent between rows. Larger numbers mean the current * filter is that many times as likely to be the same as the "num_weights" * previous filters. This is cumulative for each previous row with a weight. * There needs to be "num_weights" values in "filter_weights", or it can be * NULL if the weights aren't being specified. Weights have no influence on * the selection of the first row filter. Well chosen weights can (in theory) * improve the compression for a given image. * * Costs are factors >= 1.0 indicating the relative decoding costs of a * filter type. Higher costs indicate more decoding expense, and are * therefore less likely to be selected over a filter with lower computational * costs. There needs to be a value in "filter_costs" for each valid filter * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't * setting the costs. Costs try to improve the speed of decompression without * unduly increasing the compressed image size. * * A negative weight or cost indicates the default value is to be used, and * values in the range [0.0, 1.0) indicate the value is to remain unchanged. * The default values for both weights and costs are currently 1.0, but may * change if good general weighting/cost heuristics can be found. If both * the weights and costs are set to 1.0, this degenerates the WEIGHTED method * to the UNWEIGHTED method, but with added encoding time/computation. */ PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_doublep filter_weights, png_const_doublep filter_costs)) PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_fixed_point_p filter_weights, png_const_fixed_point_p filter_costs)) #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be * changed. */ #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ #ifdef PNG_WRITE_SUPPORTED /* Set the library compression level. Currently, valid values range from * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have * shown that zlib compression levels 3-6 usually perform as well as level 9 * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, int method)); #endif #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED /* Also set zlib parameters for compressing non-IDAT chunks */ PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, int method)); #endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and * fprintf(). These functions can be made to use other I/O routines * at run time for those applications that need to handle I/O in a * different manner by calling png_set_???_fn(). See libpng-manual.txt for * more information. */ #ifdef PNG_STDIO_SUPPORTED /* Initialize the input/output for the PNG file to the default functions. */ PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); #endif /* Replace the (error and abort), and warning functions with user * supplied functions. If no messages are to be printed you must still * write and use replacement functions. The replacement error_fn should * still do a longjmp to the last setjmp location if you are using this * method of error handling. If error_fn or warning_fn is NULL, the * default function will be used. */ PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); /* Return the user pointer associated with the error functions */ PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). * It is probably a mistake to use NULL for output_flush_fn if * write_data_fn is not also NULL unless you have built libpng with * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's * default flush function, which uses the standard *FILE structure, will * be used. */ PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); /* Replace the default data input function with a user supplied one. */ PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)); /* Return the user pointer associated with the I/O functions */ PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, png_read_status_ptr read_row_fn)); PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, png_write_status_ptr write_row_fn)); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); /* Return the user pointer associated with the memory functions */ PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn)); #endif #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr write_user_transform_fn)); #endif #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)); /* Return the user pointer associated with the user transform functions */ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED /* Return information about the row currently being processed. Note that these * APIs do not fail but will return unexpected results if called outside a user * transform callback. Also note that when transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); #endif #ifdef PNG_READ_USER_CHUNKS_SUPPORTED /* This callback is called only for *unknown* chunks. If * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known * chunks to be treated as unknown, however in this case the callback must do * any processing required by the chunk (e.g. by calling the appropriate * png_set_ APIs.) * * There is no write support - on write, by default, all the chunks in the * 'unknown' list are written in the specified position. * * The integer return from the callback function is interpreted thus: * * negative: An error occured, png_chunk_error will be called. * zero: The chunk was not handled, the chunk will be saved. A critical * chunk will cause an error at this point unless it is to be saved. * positive: The chunk was handled, libpng will ignore/discard it. * * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about * how this behavior will change in libpng 1.7 */ PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); /* Returns the user pointer associated with the push read functions */ PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structrp png_ptr)); /* Function to be called when data becomes available */ PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)); /* A function which may be called *only* within png_process_data to stop the * processing of any more data. The function returns the number of bytes * remaining, excluding any that libpng has cached internally. A subsequent * call to png_process_data must supply these bytes again. If the argument * 'save' is set to true the routine will first save all the pending data and * will always return 0. */ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); /* A function which may be called *only* outside (after) a call to * png_process_data. It returns the number of bytes of data to skip in the * input. Normally it will return 0, but if it returns a non-zero value the * application must skip than number of bytes of input data and pass the * following data to the next call to png_process_data. */ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); #ifdef PNG_READ_INTERLACING_SUPPORTED /* Function that combines rows. 'new_row' is a flag that should come from * the callback and be non-NULL if anything needs to be done; the library * stores its own version of the new data internally and ignores the passed * in value. */ PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, png_bytep old_row, png_const_bytep new_row)); #endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.4.0 */ PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.2.4 */ PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Frees a pointer allocated by png_malloc() */ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); /* Free data that was allocated internally */ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 free_me, int num)); /* Reassign responsibility for freeing existing data, whether allocated * by libpng or by the application; this works on the png_info structure passed * in, it does not change the state for other png_info structures. * * It is unlikely that this function works correctly as of 1.6.0 and using it * may result either in memory leaks or double free of allocated data. */ PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr, png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED); /* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 /* Flags for png_ptr->free_me and info_ptr->free_me */ #define PNG_FREE_HIST 0x0008 #define PNG_FREE_ICCP 0x0010 #define PNG_FREE_SPLT 0x0020 #define PNG_FREE_ROWS 0x0040 #define PNG_FREE_PCAL 0x0080 #define PNG_FREE_SCAL 0x0100 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED # define PNG_FREE_UNKN 0x0200 #endif /* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */ #define PNG_FREE_PLTE 0x1000 #define PNG_FREE_TRNS 0x2000 #define PNG_FREE_TEXT 0x4000 #define PNG_FREE_ALL 0x7fff #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, png_voidp ptr), PNG_DEPRECATED); #endif #ifdef PNG_ERROR_TEXT_SUPPORTED /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); /* The same, but the chunk name is prepended to the error string. */ PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); #else /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); #endif #ifdef PNG_WARNINGS_SUPPORTED /* Non-fatal error in libpng. Can continue, but may have a problem. */ PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); /* Non-fatal error in libpng, chunk name is prepended to message. */ PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif #ifdef PNG_BENIGN_ERRORS_SUPPORTED /* Benign error in libpng. Can continue, but may have a problem. * User can choose whether to handle as a fatal error or as a warning. */ PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #ifdef PNG_READ_SUPPORTED /* Same, chunk name is prepended to message (only during read) */ PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif PNG_EXPORT(109, void, png_set_benign_errors, (png_structrp png_ptr, int allowed)); #else # ifdef PNG_ALLOW_BENIGN_ERRORS # define png_benign_error png_warning # define png_chunk_benign_error png_chunk_warning # else # define png_benign_error png_error # define png_chunk_benign_error png_chunk_error # endif #endif /* The png_set_ functions are for storing values in the png_info_struct. * Similarly, the png_get_ calls are used to read values from the * png_info_struct, either storing the parameters in the passed variables, or * setting pointers into the png_info_struct where the data is stored. The * png_get_ functions return a non-zero value if the data was available * in info_ptr, or return zero and do not change any of the parameters if the * data was not available. * * These functions should be used instead of directly accessing png_info * to avoid problems with future changes in the size and internal layout of * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* Returns row_pointers, which is an array of pointers to scanlines that was * returned from png_read_png(). */ PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Set row_pointers, which is an array of pointers to scanlines for use * by png_write_png(). */ PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image height in pixels. */ PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image bit_depth. */ PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image color_type. */ PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image filter_type. */ PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image interlace_type. */ PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image compression_type. */ PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, (png_const_structrp png_ptr, png_const_inforp info_ptr)) PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif /* PNG_EASY_ACCESS_SUPPORTED */ #ifdef PNG_READ_SUPPORTED /* Returns pointer to signature string read from PNG header */ PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_16p *background)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_16p background)); #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)) PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, double *green_X, double *green_Y, double *green_Z, double *blue_X, double *blue_Y, double *blue_Z)) PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_white_x, png_fixed_point *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_red_X, png_fixed_point *int_red_Y, png_fixed_point *int_red_Z, png_fixed_point *int_green_X, png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, png_fixed_point *int_blue_Z)) #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)) PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double red_Y, double red_Z, double green_X, double green_Y, double green_Z, double blue_X, double blue_Y, double blue_Z)) PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, png_fixed_point int_blue_y)) PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, png_fixed_point int_blue_X, png_fixed_point int_blue_Y, png_fixed_point int_blue_Z)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *file_gamma)) PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_file_gamma)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)) PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_file_gamma)) #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_16p *hist)); #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist)); #endif PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)); PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_method, int compression_method, int filter_method)); #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); #endif #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)); PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, png_inforp info_ptr, png_const_colorp palette, int num_palette)); #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_8p *sig_bit)); #endif #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_8p sig_bit)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *file_srgb_intent)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_charpp name, int *compression_type, png_bytepp profile, png_uint_32 *proflen)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp name, int compression_type, png_const_bytep profile, png_uint_32 proflen)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_sPLT_tpp entries)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); #endif #ifdef PNG_TEXT_SUPPORTED /* png_get_text also returns the number of text chunks in *num_text */ PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_textp *text_ptr, int *num_text)); #endif /* Note while png_set_text() will accept a structure whose text, * language, and translated keywords are NULL pointers, the structure * returned by png_get_text will always contain regular * zero-terminated C strings. They might be empty strings but * they will never be NULL pointers. */ #ifdef PNG_TEXT_SUPPORTED PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_timep *mod_time)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_timep mod_time)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)); #endif #ifdef PNG_sCAL_SUPPORTED PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)) #if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ defined(PNG_FLOATING_POINT_SUPPORTED) /* NOTE: this API is currently implemented using floating point arithmetic, * consequently it can only be used on systems with floating point support. * In any case the range of values supported by png_fixed_point is small and it * is highly recommended that png_get_sCAL_s be used instead. */ PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height)) #endif PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, double width, double height)) PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_fixed_point width, png_fixed_point height)) PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)); #endif /* PNG_sCAL_SUPPORTED */ #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED /* Provide the default handling for all unknown chunks or, optionally, for * specific unknown chunks. * * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was * ignored and the default was used, the per-chunk setting only had an effect on * write. If you wish to have chunk-specific handling on read in code that must * work on earlier versions you must use a user chunk callback to specify the * desired handling (keep or discard.) * * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The * parameter is interpreted as follows: * * READ: * PNG_HANDLE_CHUNK_AS_DEFAULT: * Known chunks: do normal libpng processing, do not keep the chunk (but * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) * Unknown chunks: for a specific chunk use the global default, when used * as the default discard the chunk data. * PNG_HANDLE_CHUNK_NEVER: * Discard the chunk data. * PNG_HANDLE_CHUNK_IF_SAFE: * Keep the chunk data if the chunk is not critical else raise a chunk * error. * PNG_HANDLE_CHUNK_ALWAYS: * Keep the chunk data. * * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks * it simply resets the behavior to the libpng default. * * INTERACTION WTIH USER CHUNK CALLBACKS: * The per-chunk handling is always used when there is a png_user_chunk_ptr * callback and the callback returns 0; the chunk is then always stored *unless* * it is critical and the per-chunk setting is other than ALWAYS. Notice that * the global default is *not* used in this case. (In effect the per-chunk * value is incremented to at least IF_SAFE.) * * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and * per-chunk defaults will be honored. If you want to preserve the current * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE * as the default - if you don't do this libpng 1.6 will issue a warning. * * If you want unhandled unknown chunks to be discarded in libpng 1.6 and * earlier simply return '1' (handled). * * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: * If this is *not* set known chunks will always be handled by libpng and * will never be stored in the unknown chunk list. Known chunks listed to * png_set_keep_unknown_chunks will have no effect. If it is set then known * chunks listed with a keep other than AS_DEFAULT will *never* be processed * by libpng, in addition critical chunks must either be processed by the * callback or saved. * * The IHDR and IEND chunks must not be listed. Because this turns off the * default handling for chunks that would otherwise be recognized the * behavior of libpng transformations may well become incorrect! * * WRITE: * When writing chunks the options only apply to the chunks specified by * png_set_unknown_chunks (below), libpng will *always* write known chunks * required by png_set_ calls and will always write the core critical chunks * (as required for PLTE). * * Each chunk in the png_set_unknown_chunks list is looked up in the * png_set_keep_unknown_chunks list to find the keep setting, this is then * interpreted as follows: * * PNG_HANDLE_CHUNK_AS_DEFAULT: * Write safe-to-copy chunks and write other chunks if the global * default is set to _ALWAYS, otherwise don't write this chunk. * PNG_HANDLE_CHUNK_NEVER: * Do not write the chunk. * PNG_HANDLE_CHUNK_IF_SAFE: * Write the chunk if it is safe-to-copy, otherwise do not write it. * PNG_HANDLE_CHUNK_ALWAYS: * Write the chunk. * * Note that the default behavior is effectively the opposite of the read case - * in read unknown chunks are not stored by default, in write they are written * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different * - on write the safe-to-copy bit is checked, on read the critical bit is * checked and on read if the chunk is critical an error will be raised. * * num_chunks: * =========== * If num_chunks is positive, then the "keep" parameter specifies the manner * for handling only those chunks appearing in the chunk_list array, * otherwise the chunk list array is ignored. * * If num_chunks is 0 the "keep" parameter specifies the default behavior for * unknown chunks, as described above. * * If num_chunks is negative, then the "keep" parameter specifies the manner * for handling all unknown chunks plus all chunks recognized by libpng * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to * be processed by libpng. */ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks)); /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; * the result is therefore true (non-zero) if special handling is required, * false for the default handling. */ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, png_const_bytep chunk_name)); #endif #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)); /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added * unknowns to the location currently stored in the png_struct. This is * invariably the wrong value on write. To fix this call the following API * for each chunk in the list with the correct location. If you know your * code won't be compiled on earlier versions you can rely on * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing * the correct thing. */ PNG_EXPORT(175, void, png_set_unknown_chunk_location, (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_unknown_chunkpp entries)); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. * If you need to turn it off for a chunk that your application has freed, * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, png_inforp info_ptr, int mask)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* The "params" pointer is currently not used and is for future expansion. */ PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); #endif PNG_EXPORT(180, png_const_charp, png_get_copyright, (png_const_structrp png_ptr)); PNG_EXPORT(181, png_const_charp, png_get_header_ver, (png_const_structrp png_ptr)); PNG_EXPORT(182, png_const_charp, png_get_header_version, (png_const_structrp png_ptr)); PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, (png_const_structrp png_ptr)); #ifdef PNG_MNG_FEATURES_SUPPORTED PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, png_uint_32 mng_features_permitted)); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 #define PNG_HANDLE_CHUNK_LAST 4 /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, png_uint_32 strip_mode)); #endif /* Added in libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); PNG_EXPORT(187, png_uint_32, png_get_user_width_max, (png_const_structrp png_ptr)); PNG_EXPORT(188, png_uint_32, png_get_user_height_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.0 */ PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)); PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.1 */ PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, png_alloc_size_t user_chunk_cache_max)); PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, (png_const_structrp png_ptr)); #endif #if defined(PNG_INCH_CONVERSIONS_SUPPORTED) PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_FP_EXPORT(196, float, png_get_x_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif # ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); # endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ /* Added in libpng-1.4.0 */ #ifdef PNG_IO_STATE_SUPPORTED PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); /* Removed from libpng 1.6; use png_get_io_chunk_type. */ PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), PNG_DEPRECATED) PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, (png_const_structrp png_ptr)); /* The flags returned by png_get_io_state() are the following: */ # define PNG_IO_NONE 0x0000 /* no I/O at this moment */ # define PNG_IO_READING 0x0001 /* currently reading */ # define PNG_IO_WRITING 0x0002 /* currently writing */ # define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ # define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ # define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ # define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ # define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ # define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ #endif /* ?PNG_IO_STATE_SUPPORTED */ /* Interlace support. The following macros are always defined so that if * libpng interlace handling is turned off the macros may be used to handle * interlaced images within the application. */ #define PNG_INTERLACE_ADAM7_PASSES 7 /* Two macros to return the first row and first column of the original, * full, image which appears in a given pass. 'pass' is in the range 0 * to 6 and the result is in the range 0 to 7. */ #define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) #define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) /* A macro to return the offset between pixels in the output row for a pair of * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that * follows. Note that ROW_OFFSET is the offset from one row to the next whereas * COL_OFFSET is from one column to the next, within a row. */ #define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) #define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) /* Two macros to help evaluate the number of rows or columns in each * pass. This is expressed as a shift - effectively log2 of the number or * rows or columns in each 8x8 tile of the original image. */ #define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) #define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) /* Hence two macros to determine the number of rows or columns in a given * pass of an image given its height or width. In fact these macros may * return non-zero even though the sub-image is empty, because the other * dimension may be empty for a small image. */ #define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) #define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) /* For the reader row callbacks (both progressive and sequential) it is * necessary to find the row in the output image given a row in an interlaced * image, so two more macros: */ #define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ (((y_in)<>(((7-(off))-(pass))<<2)) & 0xF) | \ ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) #define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) #define PNG_COL_IN_INTERLACE_PASS(x, pass) \ ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on * most machines. However, it does take more operations than the corresponding * divide method, so it may be slower on a few RISC systems. There are two * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. * * Note that the rounding factors are NOT supposed to be the same! 128 and * 32768 are correct for the NODIV code; 127 and 32767 are correct for the * standard method. * * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] */ /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ # define png_composite(composite, fg, alpha, bg) \ { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ * (png_uint_16)(alpha) \ + (png_uint_16)(bg)*(png_uint_16)(255 \ - (png_uint_16)(alpha)) + 128); \ (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } # define png_composite_16(composite, fg, alpha, bg) \ { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ * (png_uint_32)(alpha) \ + (png_uint_32)(bg)*(65535 \ - (png_uint_32)(alpha)) + 32768); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } #else /* Standard method using integer division */ # define png_composite(composite, fg, alpha, bg) \ (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ 127) / 255) # define png_composite_16(composite, fg, alpha, bg) \ (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ 32767) / 65535) #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); #endif PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, png_const_bytep buf)); /* No png_get_int_16 -- may be added if there's a real need for it. */ /* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); #endif #ifdef PNG_SAVE_INT_32_SUPPORTED PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); #endif /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); /* No png_save_int_16 -- may be added if there's a real need for it. */ #endif #ifdef PNG_USE_READ_MACROS /* Inline macros to do direct reads of bytes from the input buffer. * The png_get_int_32() routine assumes we are using two's complement * format for negative values, which is almost certainly true. */ # define PNG_get_uint_32(buf) \ (((png_uint_32)(*(buf)) << 24) + \ ((png_uint_32)(*((buf) + 1)) << 16) + \ ((png_uint_32)(*((buf) + 2)) << 8) + \ ((png_uint_32)(*((buf) + 3)))) /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the * function) incorrectly returned a value of type png_uint_32. */ # define PNG_get_uint_16(buf) \ ((png_uint_16) \ (((unsigned int)(*(buf)) << 8) + \ ((unsigned int)(*((buf) + 1))))) # define PNG_get_int_32(buf) \ ((png_int_32)((*(buf) & 0x80) \ ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \ : (png_int_32)png_get_uint_32(buf))) /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, * but defining a macro name prefixed with PNG_PREFIX. */ # ifndef PNG_PREFIX # define png_get_uint_32(buf) PNG_get_uint_32(buf) # define png_get_uint_16(buf) PNG_get_uint_16(buf) # define png_get_int_32(buf) PNG_get_int_32(buf) # endif #else # ifdef PNG_PREFIX /* No macros; revert to the (redefined) function */ # define PNG_get_uint_32 (png_get_uint_32) # define PNG_get_uint_16 (png_get_uint_16) # define PNG_get_int_32 (png_get_int_32) # endif #endif /******************************************************************************* * SIMPLIFIED API ******************************************************************************* * * Please read the documentation in libpng-manual.txt (TODO: write said * documentation) if you don't understand what follows. * * The simplified API hides the details of both libpng and the PNG file format * itself. It allows PNG files to be read into a very limited number of * in-memory bitmap formats or to be written from the same formats. If these * formats do not accomodate your needs then you can, and should, use the more * sophisticated APIs above - these support a wide variety of in-memory formats * and a wide variety of sophisticated transformations to those formats as well * as a wide variety of APIs to manipulate ancillary information. * * To read a PNG file using the simplified API: * * 1) Declare a 'png_image' structure (see below) on the stack and set the * version field to PNG_IMAGE_VERSION. * 2) Call the appropriate png_image_begin_read... function. * 3) Set the png_image 'format' member to the required sample format. * 4) Allocate a buffer for the image and, if required, the color-map. * 5) Call png_image_finish_read to read the image and, if required, the * color-map into your buffers. * * There are no restrictions on the format of the PNG input itself; all valid * color types, bit depths, and interlace methods are acceptable, and the * input image is transformed as necessary to the requested in-memory format * during the png_image_finish_read() step. The only caveat is that if you * request a color-mapped image from a PNG that is full-color or makes * complex use of an alpha channel the transformation is extremely lossy and the * result may look terrible. * * To write a PNG file using the simplified API: * * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. * 2) Initialize the members of the structure that describe the image, setting * the 'format' member to the format of the image samples. * 3) Call the appropriate png_image_write... function with a pointer to the * image and, if necessary, the color-map to write the PNG data. * * png_image is a structure that describes the in-memory format of an image * when it is being read or defines the in-memory format of an image that you * need to write: */ #define PNG_IMAGE_VERSION 1 typedef struct png_control *png_controlp; typedef struct { png_controlp opaque; /* Initialize to NULL, free with png_image_free */ png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ png_uint_32 width; /* Image width in pixels (columns) */ png_uint_32 height; /* Image height in pixels (rows) */ png_uint_32 format; /* Image format as defined below */ png_uint_32 flags; /* A bit mask containing informational flags */ png_uint_32 colormap_entries; /* Number of entries in the color-map */ /* In the event of an error or warning the following field will be set to a * non-zero value and the 'message' field will contain a '\0' terminated * string with the libpng error or warning message. If both warnings and * an error were encountered, only the error is recorded. If there * are multiple warnings, only the first one is recorded. * * The upper 30 bits of this value are reserved, the low two bits contain * a value as follows: */ # define PNG_IMAGE_WARNING 1 # define PNG_IMAGE_ERROR 2 /* * The result is a two bit code such that a value more than 1 indicates * a failure in the API just called: * * 0 - no warning or error * 1 - warning * 2 - error * 3 - error preceded by warning */ # define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) png_uint_32 warning_or_error; char message[64]; } png_image, *png_imagep; /* The samples of the image have one to four channels whose components have * original values in the range 0 to 1.0: * * 1: A single gray or luminance channel (G). * 2: A gray/luminance channel and an alpha channel (GA). * 3: Three red, green, blue color channels (RGB). * 4: Three color channels and an alpha channel (RGBA). * * The components are encoded in one of two ways: * * a) As a small integer, value 0..255, contained in a single byte. For the * alpha channel the original value is simply value/255. For the color or * luminance channels the value is encoded according to the sRGB specification * and matches the 8-bit format expected by typical display devices. * * The color/gray channels are not scaled (pre-multiplied) by the alpha * channel and are suitable for passing to color management software. * * b) As a value in the range 0..65535, contained in a 2-byte integer. All * channels can be converted to the original value by dividing by 65535; all * channels are linear. Color channels use the RGB encoding (RGB end-points) of * the sRGB specification. This encoding is identified by the * PNG_FORMAT_FLAG_LINEAR flag below. * * When the simplified API needs to convert between sRGB and linear colorspaces, * the actual sRGB transfer curve defined in the sRGB specification (see the * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 * approximation used elsewhere in libpng. * * When an alpha channel is present it is expected to denote pixel coverage * of the color or luminance channels and is returned as an associated alpha * channel: the color/gray channels are scaled (pre-multiplied) by the alpha * value. * * The samples are either contained directly in the image data, between 1 and 8 * bytes per pixel according to the encoding, or are held in a color-map indexed * by bytes in the image data. In the case of a color-map the color-map entries * are individual samples, encoded as above, and the image data has one byte per * pixel to select the relevant sample from the color-map. */ /* PNG_FORMAT_* * * #defines to be used in png_image::format. Each #define identifies a * particular layout of sample data and, if present, alpha values. There are * separate defines for each of the two component encodings. * * A format is built up using single bit flag values. All combinations are * valid. Formats can be built up from the flag values or you can use one of * the predefined values below. When testing formats always use the FORMAT_FLAG * macros to test for individual features - future versions of the library may * add new flags. * * When reading or writing color-mapped images the format should be set to the * format of the entries in the color-map then png_image_{read,write}_colormap * called to read or write the color-map and set the format correctly for the * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! * * NOTE: libpng can be built with particular features disabled, if you see * compiler errors because the definition of one of the following flags has been * compiled out it is because libpng does not have the required support. It is * possible, however, for the libpng configuration to enable the format on just * read or just write; in that case you may see an error at run time. You can * guard against this by checking for the definition of the appropriate * "_SUPPORTED" macro, one of: * * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED */ #define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ #define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ #define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2 byte channels else 1 byte */ #define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ #ifdef PNG_FORMAT_BGR_SUPPORTED # define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ #endif #ifdef PNG_FORMAT_AFIRST_SUPPORTED # define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ #endif /* Commonly used formats have predefined macros. * * First the single byte (sRGB) formats: */ #define PNG_FORMAT_GRAY 0 #define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA #define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR #define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) #define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) /* Then the linear 2-byte formats. When naming these "Y" is used to * indicate a luminance (gray) channel. */ #define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR #define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) #define PNG_FORMAT_LINEAR_RGB_ALPHA \ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) /* With color-mapped formats the image data is one byte for each pixel, the byte * is an index into the color-map which is formatted as above. To obtain a * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP * to one of the above definitions, or you can use one of the definitions below. */ #define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) /* PNG_IMAGE macros * * These are convenience macros to derive information from a png_image * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the * actual image sample values - either the entries in the color-map or the * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values * for the pixels and will always return 1 for color-mapped formats. The * remaining macros return information about the rows in the image and the * complete image. * * NOTE: All the macros that take a png_image::format parameter are compile time * constants if the format parameter is, itself, a constant. Therefore these * macros can be used in array declarations and case labels where required. * Similarly the macros are also pre-processor constants (sizeof is not used) so * they can be used in #if tests. * * First the information about the samples. */ #define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) /* Return the total number of channels in a given format: 1..4 */ #define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) /* Return the size in bytes of a single component of a pixel or color-map * entry (as appropriate) in the image: 1 or 2. */ #define PNG_IMAGE_SAMPLE_SIZE(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) /* This is the size of the sample data for one sample. If the image is * color-mapped it is the size of one color-map entry (and image pixels are * one byte in size), otherwise it is the size of one image pixel. */ #define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) /* The maximum size of the color-map required by the format expressed in a * count of components. This can be used to compile-time allocate a * color-map: * * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; * * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; * * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the * information from one of the png_image_begin_read_ APIs and dynamically * allocate the required memory. */ /* Corresponding information about the pixels */ #define PNG_IMAGE_PIXEL_(test,fmt)\ (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) #define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) /* The number of separate channels (components) in a pixel; 1 for a * color-mapped image. */ #define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) /* The size, in bytes, of each component in a pixel; 1 for a color-mapped * image. */ #define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ /* Information about the whole row, or whole image */ #define PNG_IMAGE_ROW_STRIDE(image)\ (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) /* Return the total number of components in a single row of the image; this * is the minimum 'row stride', the minimum count of components between each * row. For a color-mapped image this is the minimum number of bytes in a * row. */ #define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) /* Return the size, in bytes, of an image buffer given a png_image and a row * stride - the number of components to leave space for in each row. */ #define PNG_IMAGE_SIZE(image)\ PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) /* Return the size, in bytes, of the image in memory given just a png_image; * the row stride is the minimum stride required for the image. */ #define PNG_IMAGE_COLORMAP_SIZE(image)\ (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) /* Return the size, in bytes, of the color-map of this image. If the image * format is not a color-map format this will return a size sufficient for * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if * you don't want to allocate a color-map in this case. */ /* PNG_IMAGE_FLAG_* * * Flags containing additional information about the image are held in the * 'flags' field of png_image. */ #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 /* This indicates the the RGB values of the in-memory bitmap do not * correspond to the red, green and blue end-points defined by sRGB. */ #define PNG_IMAGE_FLAG_FAST 0x02 /* On write emphasise speed over compression; the resultant PNG file will be * larger but will be produced significantly faster, particular for large * images. Do not use this option for images which will be distributed, only * used it when producing intermediate files that will be read back in * repeatedly. For a typical 24-bit image the option will double the read * speed at the cost of increasing the image size by 25%, however for many * more compressible images the PNG file can be 10 times larger with only a * slight speed gain. */ #define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 /* On read if the image is a 16-bit per component image and there is no gAMA * or sRGB chunk assume that the components are sRGB encoded. Notice that * images output by the simplified API always have gamma information; setting * this flag only affects the interpretation of 16-bit images from an * external source. It is recommended that the application expose this flag * to the user; the user can normally easily recognize the difference between * linear and sRGB encoding. This flag has no effect on write - the data * passed to the write APIs must have the correct encoding (as defined * above.) * * If the flag is not set (the default) input 16-bit per component data is * assumed to be linear. * * NOTE: the flag can only be set after the png_image_begin_read_ call, * because that call initializes the 'flags' field. */ #ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* READ APIs * --------- * * The png_image passed to the read APIs must have been initialized by setting * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) */ #ifdef PNG_STDIO_SUPPORTED PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, const char *file_name)); /* The named file is opened for read and the image header is filled in * from the PNG header in the file. */ PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, FILE* file)); /* The PNG header is read from the stdio FILE object. */ #endif /* PNG_STDIO_SUPPORTED */ PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, png_const_voidp memory, png_size_t size)); /* The PNG header is read from the given memory buffer. */ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, png_const_colorp background, void *buffer, png_int_32 row_stride, void *colormap)); /* Finish reading the image into the supplied buffer and clean up the * png_image structure. * * row_stride is the step, in byte or 2-byte units as appropriate, * between adjacent rows. A positive stride indicates that the top-most row * is first in the buffer - the normal top-down arrangement. A negative * stride indicates that the bottom-most row is first in the buffer. * * background need only be supplied if an alpha channel must be removed from * a png_byte format and the removal is to be done by compositing on a solid * color; otherwise it may be NULL and any composition will be done directly * onto the buffer. The value is an sRGB color to use for the background, * for grayscale output the green channel is used. * * background must be supplied when an alpha channel must be removed from a * single byte color-mapped output format, in other words if: * * 1) The original format from png_image_begin_read_from_* had * PNG_FORMAT_FLAG_ALPHA set. * 2) The format set by the application does not. * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and * PNG_FORMAT_FLAG_LINEAR *not* set. * * For linear output removing the alpha channel is always done by compositing * on black and background is ignored. * * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. * image->colormap_entries will be updated to the actual number of entries * written to the colormap; this may be less than the original value. */ PNG_EXPORT(238, void, png_image_free, (png_imagep image)); /* Free any data allocated by libpng in image->opaque, setting the pointer to * NULL. May be called at any time after the structure is initialized. */ #endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED /* WRITE APIS * ---------- * For write you must initialize a png_image structure to describe the image to * be written. To do this use memset to set the whole structure to 0 then * initialize fields describing your image. * * version: must be set to PNG_IMAGE_VERSION * opaque: must be initialized to NULL * width: image width in pixels * height: image height in rows * format: the format of the data (image and color-map) you wish to write * flags: set to 0 unless one of the defined flags applies; set * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB * values do not correspond to the colors in sRGB. * colormap_entries: set to the number of entries in the color-map (0 to 256) */ PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, const char *file, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the named file. */ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the given (FILE*). */ /* With both write APIs if image is in one of the linear formats with 16-bit * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG * gamma encoded according to the sRGB specification, otherwise a 16-bit linear * encoded PNG file is written. * * With color-mapped data formats the colormap parameter point to a color-map * with at least image->colormap_entries encoded in the specified format. If * the format is linear the written PNG color-map will be converted to sRGB * regardless of the convert_to_8_bit flag. * * With all APIs row_stride is handled as in the read APIs - it is the spacing * from one row to the next in component sized units (1 or 2 bytes) and if * negative indicates a bottom-up row layout in the buffer. * * Note that the write API does not support interlacing or sub-8-bit pixels. */ #endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */ /******************************************************************************* * END OF SIMPLIFIED API ******************************************************************************/ #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED PNG_EXPORT(242, void, png_set_check_for_invalid_index, (png_structrp png_ptr, int allowed)); # ifdef PNG_GET_PALETTE_MAX_SUPPORTED PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, png_const_infop info_ptr)); # endif #endif /* CHECK_FOR_INVALID_INDEX */ /******************************************************************************* * IMPLEMENTATION OPTIONS ******************************************************************************* * * Support for arbitrary implementation-specific optimizations. The API allows * particular options to be turned on or off. 'Option' is the number of the * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given * by the PNG_OPTION_ defines below. * * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, * are detected at run time, however sometimes it may be impossible * to do this in user mode, in which case it is necessary to discover * the capabilities in an OS specific way. Such capabilities are * listed here when libpng has support for them and must be turned * ON by the application if present. * * SOFTWARE: sometimes software optimizations actually result in performance * decrease on some architectures or systems, or with some sets of * PNG images. 'Software' options allow such optimizations to be * selected at run time. */ #ifdef PNG_SET_OPTION_SUPPORTED #ifdef PNG_ARM_NEON_API_SUPPORTED # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ #endif #define PNG_OPTION_NEXT 2 /* Next option - numbers must be even */ /* Return values: NOTE: there are four values and 'off' is *not* zero */ #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ #define PNG_OPTION_INVALID 1 /* Option number out of range */ #define PNG_OPTION_OFF 2 #define PNG_OPTION_ON 3 PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, int onoff)); #endif /******************************************************************************* * END OF HARDWARE OPTIONS ******************************************************************************/ /* Maintainer: Put new public prototypes here ^, in libpng.3, and project * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt */ /* The last ordinal number (this is the *last* one already used; the next * one to use is one more than this.) Maintainer, remember to add an entry to * scripts/symbols.def as well. */ #ifdef PNG_EXPORT_LAST_ORDINAL PNG_EXPORT_LAST_ORDINAL(244); #endif #ifdef __cplusplus } #endif #endif /* PNG_VERSION_INFO_ONLY */ /* Do not put anything past this line */ #endif /* PNG_H */ ================================================ FILE: cocos2d/external/png/include/mac/pngconf.h ================================================ /* pngconf.h - machine configurable file for libpng * * libpng version 1.6.2 - April 25, 2013 * * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h * */ /* Any machine specific code is near the front of this file, so if you * are configuring libpng for a machine, you may want to read the section * starting here down to where it starts to typedef png_color, png_text, * and png_info. */ #ifndef PNGCONF_H #define PNGCONF_H /* To do: Do all of this in scripts/pnglibconf.dfa */ #ifdef PNG_SAFE_LIMITS_SUPPORTED # ifdef PNG_USER_WIDTH_MAX # undef PNG_USER_WIDTH_MAX # define PNG_USER_WIDTH_MAX 1000000L # endif # ifdef PNG_USER_HEIGHT_MAX # undef PNG_USER_HEIGHT_MAX # define PNG_USER_HEIGHT_MAX 1000000L # endif # ifdef PNG_USER_CHUNK_MALLOC_MAX # undef PNG_USER_CHUNK_MALLOC_MAX # define PNG_USER_CHUNK_MALLOC_MAX 4000000L # endif # ifdef PNG_USER_CHUNK_CACHE_MAX # undef PNG_USER_CHUNK_CACHE_MAX # define PNG_USER_CHUNK_CACHE_MAX 128 # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C * compiler for correct compilation. The following header files are required by * the standard. If your compiler doesn't provide these header files, or they * do not match the standard, you will need to provide/improve them. */ #include #include /* Library header files. These header files are all defined by ISOC90; libpng * expects conformant implementations, however, an ISOC90 conformant system need * not provide these header files if the functionality cannot be implemented. * In this case it will be necessary to disable the relevant parts of libpng in * the build of pnglibconf.h. * * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not * include this unnecessary header file. */ #ifdef PNG_STDIO_SUPPORTED /* Required for the definition of FILE: */ # include #endif #ifdef PNG_SETJMP_SUPPORTED /* Required for the definition of jmp_buf and the declaration of longjmp: */ # include #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Required for struct tm: */ # include #endif #endif /* PNG_BUILDING_SYMBOL_TABLE */ /* Prior to 1.6.0 it was possible to turn off 'const' in declarations using * PNG_NO_CONST; this is no longer supported except for data declarations which * apparently still cause problems in 2011 on some compilers. */ #define PNG_CONST const /* backward compatibility only */ /* This controls optimization of the reading of 16 and 32 bit values * from PNG files. It can be set on a per-app-file basis - it * just changes whether a macro is used when the function is called. * The library builder sets the default; if read functions are not * built into the library the macro implementation is forced on. */ #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED # define PNG_USE_READ_MACROS #endif #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) # if PNG_DEFAULT_READ_MACROS # define PNG_USE_READ_MACROS # endif #endif /* COMPILER SPECIFIC OPTIONS. * * These options are provided so that a variety of difficult compilers * can be used. Some are fixed at build time (e.g. PNG_API_RULE * below) but still have compiler specific implementations, others * may be changed on a per-file basis when compiling against libpng. */ /* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect * against legacy (pre ISOC90) compilers that did not understand function * prototypes. It is not required for modern C compilers. */ #ifndef PNGARG # define PNGARG(arglist) arglist #endif /* Function calling conventions. * ============================= * Normally it is not necessary to specify to the compiler how to call * a function - it just does it - however on x86 systems derived from * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems * and some others) there are multiple ways to call a function and the * default can be changed on the compiler command line. For this reason * libpng specifies the calling convention of every exported function and * every function called via a user supplied function pointer. This is * done in this file by defining the following macros: * * PNGAPI Calling convention for exported functions. * PNGCBAPI Calling convention for user provided (callback) functions. * PNGCAPI Calling convention used by the ANSI-C library (required * for longjmp callbacks and sometimes used internally to * specify the calling convention for zlib). * * These macros should never be overridden. If it is necessary to * change calling convention in a private build this can be done * by setting PNG_API_RULE (which defaults to 0) to one of the values * below to select the correct 'API' variants. * * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. * This is correct in every known environment. * PNG_API_RULE=1 Use the operating system convention for PNGAPI and * the 'C' calling convention (from PNGCAPI) for * callbacks (PNGCBAPI). This is no longer required * in any known environment - if it has to be used * please post an explanation of the problem to the * libpng mailing list. * * These cases only differ if the operating system does not use the C * calling convention, at present this just means the above cases * (x86 DOS/Windows sytems) and, even then, this does not apply to * Cygwin running on those systems. * * Note that the value must be defined in pnglibconf.h so that what * the application uses to call the library matches the conventions * set when building the library. */ /* Symbol export * ============= * When building a shared library it is almost always necessary to tell * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' * is used to mark the symbols. On some systems these symbols can be * extracted at link time and need no special processing by the compiler, * on other systems the symbols are flagged by the compiler and just * the declaration requires a special tag applied (unfortunately) in a * compiler dependent way. Some systems can do either. * * A small number of older systems also require a symbol from a DLL to * be flagged to the program that calls it. This is a problem because * we do not know in the header file included by application code that * the symbol will come from a shared library, as opposed to a statically * linked one. For this reason the application must tell us by setting * the magic flag PNG_USE_DLL to turn on the special processing before * it includes png.h. * * Four additional macros are used to make this happen: * * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from * the build or imported if PNG_USE_DLL is set - compiler * and system specific. * * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to * 'type', compiler specific. * * PNG_DLL_EXPORT Set to the magic to use during a libpng build to * make a symbol exported from the DLL. Not used in the * public header files; see pngpriv.h for how it is used * in the libpng build. * * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come * from a DLL - used to define PNG_IMPEXP when * PNG_USE_DLL is set. */ /* System specific discovery. * ========================== * This code is used at build time to find PNG_IMPEXP, the API settings * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL * import processing is possible. On Windows systems it also sets * compiler-specific macros to the values required to change the calling * conventions of the various functions. */ #if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or * MinGW on any architecture currently supported by Windows. Also includes * Watcom builds but these need special treatment because they are not * compatible with GCC or Visual C because of different calling conventions. */ # if PNG_API_RULE == 2 /* If this line results in an error, either because __watcall is not * understood or because of a redefine just below you cannot use *this* * build of the library with the compiler you are using. *This* build was * build using Watcom and applications must also be built using Watcom! */ # define PNGCAPI __watcall # endif # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) # define PNGCAPI __cdecl # if PNG_API_RULE == 1 /* If this line results in an error __stdcall is not understood and * PNG_API_RULE should not have been set to '1'. */ # define PNGAPI __stdcall # endif # else /* An older compiler, or one not detected (erroneously) above, * if necessary override on the command line to get the correct * variants for the compiler. */ # ifndef PNGCAPI # define PNGCAPI _cdecl # endif # if PNG_API_RULE == 1 && !defined(PNGAPI) # define PNGAPI _stdcall # endif # endif /* compiler/api */ /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) # error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" # endif # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ (defined(__BORLANDC__) && __BORLANDC__ < 0x500) /* older Borland and MSC * compilers used '__export' and required this to be after * the type. */ # ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP # endif # define PNG_DLL_EXPORT __export # else /* newer compiler */ # define PNG_DLL_EXPORT __declspec(dllexport) # ifndef PNG_DLL_IMPORT # define PNG_DLL_IMPORT __declspec(dllimport) # endif # endif /* compiler */ #else /* !Windows */ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # define PNGAPI _System # else /* !Windows/x86 && !OS/2 */ /* Use the defaults, or define PNG*API on the command line (but * this will have to be done for every compile!) */ # endif /* other system, !OS/2 */ #endif /* !Windows/x86 */ /* Now do all the defaulting . */ #ifndef PNGCAPI # define PNGCAPI #endif #ifndef PNGCBAPI # define PNGCBAPI PNGCAPI #endif #ifndef PNGAPI # define PNGAPI PNGCAPI #endif /* PNG_IMPEXP may be set on the compilation system command line or (if not set) * then in an internal header file when building the library, otherwise (when * using the library) it is set here. */ #ifndef PNG_IMPEXP # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) /* This forces use of a DLL, disallowing static linking */ # define PNG_IMPEXP PNG_DLL_IMPORT # endif # ifndef PNG_IMPEXP # define PNG_IMPEXP # endif #endif /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat * 'attributes' as a storage class - the attributes go at the start of the * function definition, and attributes are always appended regardless of the * compiler. This considerably simplifies these macros but may cause problems * if any compilers both need function attributes and fail to handle them as * a storage class (this is unlikely.) */ #ifndef PNG_FUNCTION # define PNG_FUNCTION(type, name, args, attributes) attributes type name args #endif #ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type #endif /* The ordinal value is only relevant when preprocessing png.h for symbol * table entries, so we discard it here. See the .dfn files in the * scripts directory. */ #ifndef PNG_EXPORTA # define PNG_EXPORTA(ordinal, type, name, args, attributes)\ PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ extern attributes) #endif /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, * so make something non-empty to satisfy the requirement: */ #define PNG_EMPTY /*empty list*/ #define PNG_EXPORT(ordinal, type, name, args)\ PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) /* Use PNG_REMOVED to comment out a removed interface. */ #ifndef PNG_REMOVED # define PNG_REMOVED(ordinal, type, name, args, attributes) #endif #ifndef PNG_CALLBACK # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) #endif /* Support for compiler specific function attributes. These are used * so that where compiler support is available incorrect use of API * functions in png.h will generate compiler warnings. * * Added at libpng-1.2.41. */ #ifndef PNG_NO_PEDANTIC_WARNINGS # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED # define PNG_PEDANTIC_WARNINGS_SUPPORTED # endif #endif #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED /* Support for compiler specific function attributes. These are used * so that where compiler support is available, incorrect use of API * functions in png.h will generate compiler warnings. Added at libpng * version 1.2.41. Disabling these removes the warnings but may also produce * less efficient code. */ # if defined(__GNUC__) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif # ifndef PNG_NORETURN # define PNG_NORETURN __attribute__((__noreturn__)) # endif # if __GNUC__ >= 3 # ifndef PNG_ALLOCATED # define PNG_ALLOCATED __attribute__((__malloc__)) # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __attribute__((__deprecated__)) # endif # ifndef PNG_PRIVATE # if 0 /* Doesn't work so we use deprecated instead*/ # define PNG_PRIVATE \ __attribute__((warning("This function is not exported by libpng."))) # else # define PNG_PRIVATE \ __attribute__((__deprecated__)) # endif # endif # if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* __GNUC__ == 3.0 */ # endif /* __GNUC__ >= 3 */ # elif defined(_MSC_VER) && (_MSC_VER >= 1300) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* not supported */ # endif # ifndef PNG_NORETURN # define PNG_NORETURN __declspec(noreturn) # endif # ifndef PNG_ALLOCATED # if (_MSC_VER >= 1400) # define PNG_ALLOCATED __declspec(restrict) # endif # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __declspec(deprecated) # endif # ifndef PNG_PRIVATE # define PNG_PRIVATE __declspec(deprecated) # endif # ifndef PNG_RESTRICT # if (_MSC_VER >= 1400) # define PNG_RESTRICT __restrict # endif # endif # elif defined(__WATCOMC__) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* _MSC_VER */ #endif /* PNG_PEDANTIC_WARNINGS */ #ifndef PNG_DEPRECATED # define PNG_DEPRECATED /* Use of this function is deprecated */ #endif #ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* The result of this function must be checked */ #endif #ifndef PNG_NORETURN # define PNG_NORETURN /* This function does not return */ #endif #ifndef PNG_ALLOCATED # define PNG_ALLOCATED /* The result of the function is new memory */ #endif #ifndef PNG_PRIVATE # define PNG_PRIVATE /* This is a private libpng function */ #endif #ifndef PNG_RESTRICT # define PNG_RESTRICT /* The C99 "restrict" feature */ #endif #ifndef PNG_FP_EXPORT /* A floating point API. */ # ifdef PNG_FLOATING_POINT_SUPPORTED # define PNG_FP_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No floating point APIs */ # define PNG_FP_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_FIXED_EXPORT /* A fixed point API. */ # ifdef PNG_FIXED_POINT_SUPPORTED # define PNG_FIXED_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No fixed point APIs */ # define PNG_FIXED_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* Some typedefs to get us started. These should be safe on most of the common * platforms. * * png_uint_32 and png_int_32 may, currently, be larger than required to hold a * 32-bit value however this is not normally advisable. * * png_uint_16 and png_int_16 should always be two bytes in size - this is * verified at library build time. * * png_byte must always be one byte in size. * * The checks below use constants from limits.h, as defined by the ISOC90 * standard. */ #if CHAR_BIT == 8 && UCHAR_MAX == 255 typedef unsigned char png_byte; #else # error "libpng requires 8 bit bytes" #endif #if INT_MIN == -32768 && INT_MAX == 32767 typedef int png_int_16; #elif SHRT_MIN == -32768 && SHRT_MAX == 32767 typedef short png_int_16; #else # error "libpng requires a signed 16 bit type" #endif #if UINT_MAX == 65535 typedef unsigned int png_uint_16; #elif USHRT_MAX == 65535 typedef unsigned short png_uint_16; #else # error "libpng requires an unsigned 16 bit type" #endif #if INT_MIN < -2147483646 && INT_MAX > 2147483646 typedef int png_int_32; #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 typedef long int png_int_32; #else # error "libpng requires a signed 32 bit (or more) type" #endif #if UINT_MAX > 4294967294 typedef unsigned int png_uint_32; #elif ULONG_MAX > 4294967294 typedef unsigned long int png_uint_32; #else # error "libpng requires an unsigned 32 bit (or more) type" #endif /* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, * requires an ISOC90 compiler and relies on consistent behavior of sizeof. */ typedef size_t png_size_t; typedef ptrdiff_t png_ptrdiff_t; /* libpng needs to know the maximum value of 'size_t' and this controls the * definition of png_alloc_size_t, below. This maximum value of size_t limits * but does not control the maximum allocations the library makes - there is * direct application control of this through png_set_user_limits(). */ #ifndef PNG_SMALL_SIZE_T /* Compiler specific tests for systems where size_t is known to be less than * 32 bits (some of these systems may no longer work because of the lack of * 'far' support; see above.) */ # if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ (defined(_MSC_VER) && defined(MAXSEG_64K)) # define PNG_SMALL_SIZE_T # endif #endif /* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to * png_alloc_size_t are not necessary; in fact, it is recommended not to use * them at all so that the compiler can complain when something turns out to be * problematic. * * Casts in the other direction (from png_alloc_size_t to png_size_t or * png_uint_32) should be explicitly applied; however, we do not expect to * encounter practical situations that require such conversions. * * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than * 4294967295 - i.e. less than the maximum value of png_uint_32. */ #ifdef PNG_SMALL_SIZE_T typedef png_uint_32 png_alloc_size_t; #else typedef png_size_t png_alloc_size_t; #endif /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler * implementations of Intel CPU specific support of user-mode segmented address * spaces, where 16-bit pointers address more than 65536 bytes of memory using * separate 'segment' registers. The implementation requires two different * types of pointer (only one of which includes the segment value.) * * If required this support is available in version 1.2 of libpng and may be * available in versions through 1.5, although the correctness of the code has * not been verified recently. */ /* Typedef for floating-point numbers that are converted to fixed-point with a * multiple of 100,000, e.g., gamma */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ typedef void * png_voidp; typedef const void * png_const_voidp; typedef png_byte * png_bytep; typedef const png_byte * png_const_bytep; typedef png_uint_32 * png_uint_32p; typedef const png_uint_32 * png_const_uint_32p; typedef png_int_32 * png_int_32p; typedef const png_int_32 * png_const_int_32p; typedef png_uint_16 * png_uint_16p; typedef const png_uint_16 * png_const_uint_16p; typedef png_int_16 * png_int_16p; typedef const png_int_16 * png_const_int_16p; typedef char * png_charp; typedef const char * png_const_charp; typedef png_fixed_point * png_fixed_point_p; typedef const png_fixed_point * png_const_fixed_point_p; typedef png_size_t * png_size_tp; typedef const png_size_t * png_const_size_tp; #ifdef PNG_STDIO_SUPPORTED typedef FILE * png_FILE_p; #endif #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * png_doublep; typedef const double * png_const_doublep; #endif /* Pointers to pointers; i.e. arrays */ typedef png_byte * * png_bytepp; typedef png_uint_32 * * png_uint_32pp; typedef png_int_32 * * png_int_32pp; typedef png_uint_16 * * png_uint_16pp; typedef png_int_16 * * png_int_16pp; typedef const char * * png_const_charpp; typedef char * * png_charpp; typedef png_fixed_point * * png_fixed_point_pp; #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * * png_doublepp; #endif /* Pointers to pointers to pointers; i.e., pointer to array */ typedef char * * * png_charppp; #endif /* PNG_BUILDING_SYMBOL_TABLE */ #endif /* PNGCONF_H */ ================================================ FILE: cocos2d/external/png/include/mac/pnglibconf.h ================================================ /* pnglibconf.h - library build configuration */ /* libpng version 1.6.2 - April 25, 2013 */ /* Copyright (c) 1998-2012 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ /* For conditions of distribution and use, see the disclaimer */ /* and license in png.h */ /* pnglibconf.h */ /* Machine generated file: DO NOT EDIT */ /* Derived from: scripts/pnglibconf.dfa */ #ifndef PNGLCONF_H #define PNGLCONF_H /* options */ #define PNG_16BIT_SUPPORTED #define PNG_ALIGNED_MEMORY_SUPPORTED /*#undef PNG_ARM_NEON_API_SUPPORTED*/ /*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ /*#undef PNG_ARM_NEON_SUPPORTED*/ #define PNG_BENIGN_ERRORS_SUPPORTED #define PNG_BENIGN_READ_ERRORS_SUPPORTED /*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_COLORSPACE_SUPPORTED #define PNG_CONSOLE_IO_SUPPORTED #define PNG_CONVERT_tIME_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ #define PNG_ERROR_TEXT_SUPPORTED #define PNG_FIXED_POINT_SUPPORTED #define PNG_FLOATING_ARITHMETIC_SUPPORTED #define PNG_FLOATING_POINT_SUPPORTED #define PNG_FORMAT_AFIRST_SUPPORTED #define PNG_FORMAT_BGR_SUPPORTED #define PNG_GAMMA_SUPPORTED #define PNG_GET_PALETTE_MAX_SUPPORTED #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED #define PNG_INCH_CONVERSIONS_SUPPORTED #define PNG_INFO_IMAGE_SUPPORTED #define PNG_IO_STATE_SUPPORTED #define PNG_MNG_FEATURES_SUPPORTED #define PNG_POINTER_INDEXING_SUPPORTED #define PNG_PROGRESSIVE_READ_SUPPORTED #define PNG_READ_16BIT_SUPPORTED #define PNG_READ_ALPHA_MODE_SUPPORTED #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED #define PNG_READ_BACKGROUND_SUPPORTED #define PNG_READ_BGR_SUPPORTED #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_READ_COMPOSITE_NODIV_SUPPORTED #define PNG_READ_COMPRESSED_TEXT_SUPPORTED #define PNG_READ_EXPAND_16_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_FILLER_SUPPORTED #define PNG_READ_GAMMA_SUPPORTED #define PNG_READ_GET_PALETTE_MAX_SUPPORTED #define PNG_READ_GRAY_TO_RGB_SUPPORTED #define PNG_READ_INTERLACING_SUPPORTED #define PNG_READ_INT_FUNCTIONS_SUPPORTED #define PNG_READ_INVERT_ALPHA_SUPPORTED #define PNG_READ_INVERT_SUPPORTED #define PNG_READ_OPT_PLTE_SUPPORTED #define PNG_READ_PACKSWAP_SUPPORTED #define PNG_READ_PACK_SUPPORTED #define PNG_READ_QUANTIZE_SUPPORTED #define PNG_READ_RGB_TO_GRAY_SUPPORTED #define PNG_READ_SCALE_16_TO_8_SUPPORTED #define PNG_READ_SHIFT_SUPPORTED #define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED #define PNG_READ_SUPPORTED #define PNG_READ_SWAP_ALPHA_SUPPORTED #define PNG_READ_SWAP_SUPPORTED #define PNG_READ_TEXT_SUPPORTED #define PNG_READ_TRANSFORMS_SUPPORTED #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED #define PNG_READ_USER_CHUNKS_SUPPORTED #define PNG_READ_USER_TRANSFORM_SUPPORTED #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED #define PNG_READ_gAMA_SUPPORTED #define PNG_READ_hIST_SUPPORTED #define PNG_READ_iCCP_SUPPORTED #define PNG_READ_iTXt_SUPPORTED #define PNG_READ_oFFs_SUPPORTED #define PNG_READ_pCAL_SUPPORTED #define PNG_READ_pHYs_SUPPORTED #define PNG_READ_sBIT_SUPPORTED #define PNG_READ_sCAL_SUPPORTED #define PNG_READ_sPLT_SUPPORTED #define PNG_READ_sRGB_SUPPORTED #define PNG_READ_tEXt_SUPPORTED #define PNG_READ_tIME_SUPPORTED #define PNG_READ_tRNS_SUPPORTED #define PNG_READ_zTXt_SUPPORTED /*#undef PNG_SAFE_LIMITS_SUPPORTED*/ #define PNG_SAVE_INT_32_SUPPORTED #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SEQUENTIAL_READ_SUPPORTED #define PNG_SETJMP_SUPPORTED #define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED #define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED /*#undef PNG_SET_OPTION_SUPPORTED*/ #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SET_USER_LIMITS_SUPPORTED #define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_READ_BGR_SUPPORTED #define PNG_SIMPLIFIED_READ_SUPPORTED #define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED #define PNG_SIMPLIFIED_WRITE_SUPPORTED #define PNG_STDIO_SUPPORTED #define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_TEXT_SUPPORTED #define PNG_TIME_RFC1123_SUPPORTED #define PNG_UNKNOWN_CHUNKS_SUPPORTED #define PNG_USER_CHUNKS_SUPPORTED #define PNG_USER_LIMITS_SUPPORTED #define PNG_USER_MEM_SUPPORTED #define PNG_USER_TRANSFORM_INFO_SUPPORTED #define PNG_USER_TRANSFORM_PTR_SUPPORTED #define PNG_WARNINGS_SUPPORTED #define PNG_WRITE_16BIT_SUPPORTED #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #define PNG_WRITE_BGR_SUPPORTED #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED #define PNG_WRITE_FILLER_SUPPORTED #define PNG_WRITE_FILTER_SUPPORTED #define PNG_WRITE_FLUSH_SUPPORTED #define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED #define PNG_WRITE_INTERLACING_SUPPORTED #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED #define PNG_WRITE_INVERT_ALPHA_SUPPORTED #define PNG_WRITE_INVERT_SUPPORTED #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED #define PNG_WRITE_PACKSWAP_SUPPORTED #define PNG_WRITE_PACK_SUPPORTED #define PNG_WRITE_SHIFT_SUPPORTED #define PNG_WRITE_SUPPORTED #define PNG_WRITE_SWAP_ALPHA_SUPPORTED #define PNG_WRITE_SWAP_SUPPORTED #define PNG_WRITE_TEXT_SUPPORTED #define PNG_WRITE_TRANSFORMS_SUPPORTED #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_WRITE_USER_TRANSFORM_SUPPORTED #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #define PNG_WRITE_bKGD_SUPPORTED #define PNG_WRITE_cHRM_SUPPORTED #define PNG_WRITE_gAMA_SUPPORTED #define PNG_WRITE_hIST_SUPPORTED #define PNG_WRITE_iCCP_SUPPORTED #define PNG_WRITE_iTXt_SUPPORTED #define PNG_WRITE_oFFs_SUPPORTED #define PNG_WRITE_pCAL_SUPPORTED #define PNG_WRITE_pHYs_SUPPORTED #define PNG_WRITE_sBIT_SUPPORTED #define PNG_WRITE_sCAL_SUPPORTED #define PNG_WRITE_sPLT_SUPPORTED #define PNG_WRITE_sRGB_SUPPORTED #define PNG_WRITE_tEXt_SUPPORTED #define PNG_WRITE_tIME_SUPPORTED #define PNG_WRITE_tRNS_SUPPORTED #define PNG_WRITE_zTXt_SUPPORTED #define PNG_bKGD_SUPPORTED #define PNG_cHRM_SUPPORTED #define PNG_gAMA_SUPPORTED #define PNG_hIST_SUPPORTED #define PNG_iCCP_SUPPORTED #define PNG_iTXt_SUPPORTED #define PNG_oFFs_SUPPORTED #define PNG_pCAL_SUPPORTED #define PNG_pHYs_SUPPORTED #define PNG_sBIT_SUPPORTED #define PNG_sCAL_SUPPORTED #define PNG_sPLT_SUPPORTED #define PNG_sRGB_SUPPORTED #define PNG_tEXt_SUPPORTED #define PNG_tIME_SUPPORTED #define PNG_tRNS_SUPPORTED #define PNG_zTXt_SUPPORTED /* end of options */ /* settings */ #define PNG_API_RULE 0 #define PNG_CALLOC_SUPPORTED #define PNG_COST_SHIFT 3 #define PNG_DEFAULT_READ_MACROS 1 #define PNG_GAMMA_THRESHOLD_FIXED 5000 #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE #define PNG_INFLATE_BUF_SIZE 1024 #define PNG_MAX_GAMMA_8 11 #define PNG_QUANTIZE_BLUE_BITS 5 #define PNG_QUANTIZE_GREEN_BITS 5 #define PNG_QUANTIZE_RED_BITS 5 #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 #define PNG_WEIGHT_SHIFT 8 #define PNG_ZBUF_SIZE 8192 #define PNG_Z_DEFAULT_COMPRESSION (-1) #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 #define PNG_Z_DEFAULT_STRATEGY 1 #define PNG_sCAL_PRECISION 5 #define PNG_sRGB_PROFILE_CHECKS 2 /* end of settings */ #endif /* PNGLCONF_H */ ================================================ FILE: cocos2d/external/png/include/win32/png.h ================================================ /* png.h - header file for PNG reference library * * libpng version 1.6.2 - April 25, 2013 * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license (See LICENSE, below) * * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.6.2 - April 25, 2013: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: * * Due to various miscommunications, unforeseen code incompatibilities * and occasional factors outside the authors' control, version numbering * on the library has not always been consistent and straightforward. * The following table summarizes matters since version 0.89c, which was * the first widely used release: * * source png.h png.h shared-lib * version string int version * ------- ------ ----- ---------- * 0.89c "1.0 beta 3" 0.89 89 1.0.89 * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] * 0.97c 0.97 97 2.0.97 * 0.98 0.98 98 2.0.98 * 0.99 0.99 98 2.0.99 * 0.99a-m 0.99 99 2.0.99 * 1.00 1.00 100 2.1.0 [100 should be 10000] * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] * 1.0.1 png.h string is 10001 2.1.0 * 1.0.1a-e identical to the 10002 from here on, the shared library * 1.0.2 source version) 10002 is 2.V where V is the source code * 1.0.2a-b 10003 version, except as noted. * 1.0.3 10003 * 1.0.3a-d 10004 * 1.0.4 10004 * 1.0.4a-f 10005 * 1.0.5 (+ 2 patches) 10005 * 1.0.5a-d 10006 * 1.0.5e-r 10100 (not source compatible) * 1.0.5s-v 10006 (not binary compatible) * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) * 1.0.6d-f 10007 (still binary incompatible) * 1.0.6g 10007 * 1.0.6h 10007 10.6h (testing xy.z so-numbering) * 1.0.6i 10007 10.6i * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) * 1.0.7 1 10007 (still compatible) * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 * 1.0.8rc1 1 10008 2.1.0.8rc1 * 1.0.8 1 10008 2.1.0.8 * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 * 1.0.9rc1 1 10009 2.1.0.9rc1 * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 * 1.0.9rc2 1 10009 2.1.0.9rc2 * 1.0.9 1 10009 2.1.0.9 * 1.0.10beta1 1 10010 2.1.0.10beta1 * 1.0.10rc1 1 10010 2.1.0.10rc1 * 1.0.10 1 10010 2.1.0.10 * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 * 1.0.11rc1 1 10011 2.1.0.11rc1 * 1.0.11 1 10011 2.1.0.11 * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 * 1.0.12rc1 2 10012 2.1.0.12rc1 * 1.0.12 2 10012 2.1.0.12 * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 * 1.2.0rc1 3 10200 3.1.2.0rc1 * 1.2.0 3 10200 3.1.2.0 * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 * 1.2.1 3 10201 3.1.2.1 * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 * 1.0.13 10 10013 10.so.0.1.0.13 * 1.2.2 12 10202 12.so.0.1.2.2 * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 * 1.2.3 12 10203 12.so.0.1.2.3 * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 * 1.0.14 10 10014 10.so.0.1.0.14 * 1.2.4 13 10204 12.so.0.1.2.4 * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 * 1.0.15 10 10015 10.so.0.1.0.15 * 1.2.5 13 10205 12.so.0.1.2.5 * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 * 1.0.16 10 10016 10.so.0.1.0.16 * 1.2.6 13 10206 12.so.0.1.2.6 * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 * 1.0.17rc1 10 10017 12.so.0.1.0.17rc1 * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 * 1.0.17 10 10017 12.so.0.1.0.17 * 1.2.7 13 10207 12.so.0.1.2.7 * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 * 1.0.18 10 10018 12.so.0.1.0.18 * 1.2.8 13 10208 12.so.0.1.2.8 * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 * 1.2.9beta4-11 13 10209 12.so.0.9[.0] * 1.2.9rc1 13 10209 12.so.0.9[.0] * 1.2.9 13 10209 12.so.0.9[.0] * 1.2.10beta1-7 13 10210 12.so.0.10[.0] * 1.2.10rc1-2 13 10210 12.so.0.10[.0] * 1.2.10 13 10210 12.so.0.10[.0] * 1.4.0beta1-5 14 10400 14.so.0.0[.0] * 1.2.11beta1-4 13 10211 12.so.0.11[.0] * 1.4.0beta7-8 14 10400 14.so.0.0[.0] * 1.2.11 13 10211 12.so.0.11[.0] * 1.2.12 13 10212 12.so.0.12[.0] * 1.4.0beta9-14 14 10400 14.so.0.0[.0] * 1.2.13 13 10213 12.so.0.13[.0] * 1.4.0beta15-36 14 10400 14.so.0.0[.0] * 1.4.0beta37-87 14 10400 14.so.14.0[.0] * 1.4.0rc01 14 10400 14.so.14.0[.0] * 1.4.0beta88-109 14 10400 14.so.14.0[.0] * 1.4.0rc02-08 14 10400 14.so.14.0[.0] * 1.4.0 14 10400 14.so.14.0[.0] * 1.4.1beta01-03 14 10401 14.so.14.1[.0] * 1.4.1rc01 14 10401 14.so.14.1[.0] * 1.4.1beta04-12 14 10401 14.so.14.1[.0] * 1.4.1 14 10401 14.so.14.1[.0] * 1.4.2 14 10402 14.so.14.2[.0] * 1.4.3 14 10403 14.so.14.3[.0] * 1.4.4 14 10404 14.so.14.4[.0] * 1.5.0beta01-58 15 10500 15.so.15.0[.0] * 1.5.0rc01-07 15 10500 15.so.15.0[.0] * 1.5.0 15 10500 15.so.15.0[.0] * 1.5.1beta01-11 15 10501 15.so.15.1[.0] * 1.5.1rc01-02 15 10501 15.so.15.1[.0] * 1.5.1 15 10501 15.so.15.1[.0] * 1.5.2beta01-03 15 10502 15.so.15.2[.0] * 1.5.2rc01-03 15 10502 15.so.15.2[.0] * 1.5.2 15 10502 15.so.15.2[.0] * 1.5.3beta01-10 15 10503 15.so.15.3[.0] * 1.5.3rc01-02 15 10503 15.so.15.3[.0] * 1.5.3beta11 15 10503 15.so.15.3[.0] * 1.5.3 [omitted] * 1.5.4beta01-08 15 10504 15.so.15.4[.0] * 1.5.4rc01 15 10504 15.so.15.4[.0] * 1.5.4 15 10504 15.so.15.4[.0] * 1.5.5beta01-08 15 10505 15.so.15.5[.0] * 1.5.5rc01 15 10505 15.so.15.5[.0] * 1.5.5 15 10505 15.so.15.5[.0] * 1.5.6beta01-07 15 10506 15.so.15.6[.0] * 1.5.6rc01-03 15 10506 15.so.15.6[.0] * 1.5.6 15 10506 15.so.15.6[.0] * 1.5.7beta01-05 15 10507 15.so.15.7[.0] * 1.5.7rc01-03 15 10507 15.so.15.7[.0] * 1.5.7 15 10507 15.so.15.7[.0] * 1.6.0beta01-40 16 10600 16.so.16.0[.0] * 1.6.0rc01-08 16 10600 16.so.16.0[.0] * 1.6.0 16 10600 16.so.16.0[.0] * 1.6.1beta01-09 16 10601 16.so.16.1[.0] * 1.6.1rc01 16 10601 16.so.16.1[.0] * 1.6.1 16 10601 16.so.16.1[.0] * 1.6.2beta01 16 10602 16.so.16.2[.0] * 1.6.2rc01-06 16 10602 16.so.16.2[.0] * 1.6.2 16 10602 16.so.16.2[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. The * PNG_LIBPNG_VER macro, which is not used within libpng but is available * for applications, is an unsigned integer of the form xyyzz corresponding * to the source version x.y.z (leading zeros in y and z). Beta versions * were given the previous public release number plus a letter, until * version 1.0.6j; from then on they were given the upcoming public * release number plus "betaNN" or "rcNN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled * application is loaded with a different version of the library. * * DLLNUM will change each time there are forward or backward changes * in binary compatibility (e.g., when a new feature is added). * * See libpng-manual.txt or libpng.3 for more information. The PNG * specification is available as a W3C Recommendation and as an ISO * Specification, defines should NOT be changed. */ #define PNG_INFO_gAMA 0x0001 #define PNG_INFO_sBIT 0x0002 #define PNG_INFO_cHRM 0x0004 #define PNG_INFO_PLTE 0x0008 #define PNG_INFO_tRNS 0x0010 #define PNG_INFO_bKGD 0x0020 #define PNG_INFO_hIST 0x0040 #define PNG_INFO_pHYs 0x0080 #define PNG_INFO_oFFs 0x0100 #define PNG_INFO_tIME 0x0200 #define PNG_INFO_pCAL 0x0400 #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ #define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using * the routines for other purposes. */ typedef struct png_row_info_struct { png_uint_32 width; /* width of row */ png_size_t rowbytes; /* number of bytes in row */ png_byte color_type; /* color type of row */ png_byte bit_depth; /* bit depth of row */ png_byte channels; /* number of channels (1, 2, 3, or 4) */ png_byte pixel_depth; /* bits per pixel (depth * channels) */ } png_row_info; typedef png_row_info * png_row_infop; typedef png_row_info * * png_row_infopp; /* These are the function types for the I/O functions and for the functions * that allow the user to override the default I/O functions with his or her * own. The png_error_ptr type should match that of user-supplied warning * and error functions, while the png_rw_ptr type should match that of the * user read/write data functions. Note that the 'write' function must not * modify the buffer it is passed. The 'read' function, on the other hand, is * expected to return the read data in the buffer. */ typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, int)); typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, int)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); /* The following callback receives png_uint_32 row_number, int pass for the * png_bytep data of the row. When transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, png_uint_32, int)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, png_bytep)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, png_unknown_chunkp)); #endif #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED /* not used anywhere */ /* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ #endif #ifdef PNG_SETJMP_SUPPORTED /* This must match the function definition in , and the application * must include this before png.h to obtain the definition of jmp_buf. The * function is required to be PNG_NORETURN, but this is not checked. If the * function does return the application will crash via an abort() or similar * system level call. * * If you get a warning here while building the library you may need to make * changes to ensure that pnglibconf.h records the calling convention used by * your compiler. This may be very difficult - try using a different compiler * to build the library! */ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); #endif /* Transform masks for the high-level interface */ #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ /* Added to libpng-1.2.34 */ #define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ /* Added to libpng-1.4.0 */ #define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ /* Added to libpng-1.5.4 */ #define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ #define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 /* NOTE: prior to 1.5 these functions had no 'API' style declaration, * this allowed the zlib default functions to be used on Windows * platforms. In 1.5 the zlib default malloc (which just calls malloc and * ignores the first argument) should be completely compatible with the * following. */ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, png_alloc_size_t)); typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); /* Section 3: exported functions * Here are the function definitions most commonly used. This is not * the place to find out how to use libpng. See libpng-manual.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. * * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in * pngconf.h and in the *.dfn files in the scripts directory. * * PNG_EXPORT(ordinal, type, name, (args)); * * ordinal: ordinal that is used while building * *.def files. The ordinal value is only * relevant when preprocessing png.h with * the *.dfn files for building symbol table * entries, and are removed by pngconf.h. * type: return type of the function * name: function name * args: function arguments, with types * * When we wish to append attributes to a function prototype we use * the PNG_EXPORTA() macro instead. * * PNG_EXPORTA(ordinal, type, name, (args), attributes); * * ordinal, type, name, and args: same as in PNG_EXPORT(). * attributes: function attributes */ /* Returns the version number of the library */ PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); /* Tell lib we have already handled the first magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, png_size_t num_to_check)); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ #define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) /* Allocate and initialize png_ptr struct for reading, and any other memory. */ PNG_EXPORTA(4, png_structp, png_create_read_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); /* Allocate and initialize png_ptr struct for writing, and any other memory */ PNG_EXPORTA(5, png_structp, png_create_write_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, (png_const_structrp png_ptr)); PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, png_size_t size)); /* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp * match up. */ #ifdef PNG_SETJMP_SUPPORTED /* This function returns the jmp_buf built in to *png_ptr. It must be * supplied with an appropriate 'longjmp' function to use on that jmp_buf * unless the default error function is overridden in which case NULL is * acceptable. The size of the jmp_buf is checked against the actual size * allocated by the library - the call will return NULL on a mismatch * indicating an ABI mismatch. */ PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); # define png_jmpbuf(png_ptr) \ (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) #else # define png_jmpbuf(png_ptr) \ (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) #endif /* This function should be used by libpng applications in place of * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it * will use it; otherwise it will call PNG_ABORT(). This function was * added in libpng-1.5.0. */ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), PNG_NORETURN); #ifdef PNG_READ_SUPPORTED /* Reset the compression stream */ PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); #endif /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(11, png_structp, png_create_read_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); PNG_EXPORTA(12, png_structp, png_create_write_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); #endif /* Write the PNG file signature. */ PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); /* Write a PNG chunk - size, type, (optional) data, CRC. */ PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep chunk_name, png_const_bytep data, png_size_t length)); /* Write the start of a PNG chunk - length and chunk name. */ PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, png_const_bytep chunk_name, png_uint_32 length)); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, png_const_bytep data, png_size_t length)); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); /* Allocate and initialize the info structure */ PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), PNG_ALLOCATED); /* DEPRECATED: this function allowed init structures to be created using the * default allocation method (typically malloc). Use is deprecated in 1.6.0 and * the API will be removed in the future. */ PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, png_size_t png_info_struct_size), PNG_DEPRECATED); /* Writes all the PNG information before the image. */ PNG_EXPORT(20, void, png_write_info_before_PLTE, (png_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(21, void, png_write_info, (png_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. */ PNG_EXPORT(22, void, png_read_info, (png_structrp png_ptr, png_inforp info_ptr)); #endif #ifdef PNG_TIME_RFC1123_SUPPORTED /* Convert to a US string format: there is no localization support in this * routine. The original implementation used a 29 character buffer in * png_struct, this will be removed in future versions. */ #if PNG_LIBPNG_VER < 10700 /* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, png_const_timep ptime),PNG_DEPRECATED); #endif PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], png_const_timep ptime)); #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Convert from a struct tm to png_time */ PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, const struct tm * ttime)); /* Convert from time_t to png_time. Uses gmtime() */ PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); #endif /* PNG_CONVERT_tIME_SUPPORTED */ #ifdef PNG_READ_EXPAND_SUPPORTED /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); #endif #ifdef PNG_READ_EXPAND_16_SUPPORTED /* Expand to 16-bit channels, forces conversion of palette to RGB and expansion * of a tRNS chunk if present. */ PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Expand the grayscale to 24-bit RGB if necessary. */ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); #endif #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED /* Reduce RGB to grayscale. */ #define PNG_ERROR_ACTION_NONE 1 #define PNG_ERROR_ACTION_WARN 2 #define PNG_ERROR_ACTION_ERROR 3 #define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, int error_action, double red, double green)) PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)) PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp png_ptr)); #endif #ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, png_colorp palette)); #endif #ifdef PNG_READ_ALPHA_MODE_SUPPORTED /* How the alpha channel is interpreted - this affects how the color channels of * a PNG file are returned when an alpha channel, or tRNS chunk in a palette * file, is present. * * This has no effect on the way pixels are written into a PNG output * datastream. The color samples in a PNG datastream are never premultiplied * with the alpha samples. * * The default is to return data according to the PNG specification: the alpha * channel is a linear measure of the contribution of the pixel to the * corresponding composited pixel. The gamma encoded color channels must be * scaled according to the contribution and to do this it is necessary to undo * the encoding, scale the color values, perform the composition and reencode * the values. This is the 'PNG' mode. * * The alternative is to 'associate' the alpha with the color information by * storing color channel values that have been scaled by the alpha. The * advantage is that the color channels can be resampled (the image can be * scaled) in this form. The disadvantage is that normal practice is to store * linear, not (gamma) encoded, values and this requires 16-bit channels for * still images rather than the 8-bit channels that are just about sufficient if * gamma encoding is used. In addition all non-transparent pixel values, * including completely opaque ones, must be gamma encoded to produce the final * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the * latter being the two common names for associated alpha color channels.) * * Since it is not necessary to perform arithmetic on opaque color values so * long as they are not to be resampled and are in the final color space it is * possible to optimize the handling of alpha by storing the opaque pixels in * the PNG format (adjusted for the output color space) while storing partially * opaque pixels in the standard, linear, format. The accuracy required for * standard alpha composition is relatively low, because the pixels are * isolated, therefore typically the accuracy loss in storing 8-bit linear * values is acceptable. (This is not true if the alpha channel is used to * simulate transparency over large areas - use 16 bits or the PNG mode in * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is * treated as opaque only if the alpha value is equal to the maximum value. * * The final choice is to gamma encode the alpha channel as well. This is * broken because, in practice, no implementation that uses this choice * correctly undoes the encoding before handling alpha composition. Use this * choice only if other serious errors in the software or hardware you use * mandate it; the typical serious error is for dark halos to appear around * opaque areas of the composited PNG image because of arithmetic overflow. * * The API function png_set_alpha_mode specifies which of these choices to use * with an enumerated 'mode' value and the gamma of the required output: */ #define PNG_ALPHA_PNG 0 /* according to the PNG standard */ #define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ #define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ #define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ #define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ #define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, double output_gamma)) PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, int mode, png_fixed_point output_gamma)) #endif #if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) /* The output_gamma value is a screen gamma in libpng terminology: it expresses * how to decode the output values, not how they are encoded. The values used * correspond to the normal numbers used to describe the overall gamma of a * computer display system; for example 2.2 for an sRGB conformant system. The * values are scaled by 100000 in the _fixed version of the API (so 220000 for * sRGB.) * * The inverse of the value is always used to provide a default for the PNG file * encoding if it has no gAMA chunk and if png_set_gamma() has not been called * to override the PNG gamma information. * * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode * opaque pixels however pixels with lower alpha values are not encoded, * regardless of the output gamma setting. * * When the standard Porter Duff handling is requested with mode 1 the output * encoding is set to be linear and the output_gamma value is only relevant * as a default for input data that has no gamma information. The linear output * encoding will be overridden if png_set_gamma() is called - the results may be * highly unexpected! * * The following numbers are derived from the sRGB standard and the research * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing * correction required to take account of any differences in the color * environment of the original scene and the intended display environment; the * value expresses how to *decode* the image for display, not how the original * data was *encoded*. * * sRGB provides a peg for the PNG standard by defining a viewing environment. * sRGB itself, and earlier TV standards, actually use a more complex transform * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is * limited to simple power laws.) By saying that an image for direct display on * an sRGB conformant system should be stored with a gAMA chunk value of 45455 * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification * makes it possible to derive values for other display systems and * environments. * * The Mac value is deduced from the sRGB based on an assumption that the actual * extra viewing correction used in early Mac display systems was implemented as * a power 1.45 lookup table. * * Any system where a programmable lookup table is used or where the behavior of * the final display device characteristics can be changed requires system * specific code to obtain the current characteristic. However this can be * difficult and most PNG gamma correction only requires an approximate value. * * By default, if png_set_alpha_mode() is not called, libpng assumes that all * values are unencoded, linear, values and that the output device also has a * linear characteristic. This is only very rarely correct - it is invariably * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the * default if you don't know what the right answer is! * * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS * 10.6) which used a correction table to implement a somewhat lower gamma on an * otherwise sRGB system. * * Both these values are reserved (not simple gamma values) in order to allow * more precise correction internally in the future. * * NOTE: the following values can be passed to either the fixed or floating * point APIs, but the floating point API will also accept floating point * values. */ #define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ #define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ #define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ #define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ #endif /* The following are examples of calls to png_set_alpha_mode to achieve the * required overall gamma correction and, where necessary, alpha * premultiplication. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * This is the default libpng handling of the alpha channel - it is not * pre-multiplied into the color components. In addition the call states * that the output is for a sRGB system and causes all PNG files without gAMA * chunks to be assumed to be encoded using sRGB. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * In this case the output is assumed to be something like an sRGB conformant * display preceeded by a power-law lookup table of power 1.45. This is how * early Mac systems behaved. * * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); * This is the classic Jim Blinn approach and will work in academic * environments where everything is done by the book. It has the shortcoming * of assuming that input PNG data with no gamma information is linear - this * is unlikely to be correct unless the PNG files where generated locally. * Most of the time the output precision will be so low as to show * significant banding in dark areas of the image. * * png_set_expand_16(pp); * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); * This is a somewhat more realistic Jim Blinn inspired approach. PNG files * are assumed to have the sRGB encoding if not marked with a gamma value and * the output is always 16 bits per component. This permits accurate scaling * and processing of the data. If you know that your input PNG files were * generated locally you might need to replace PNG_DEFAULT_sRGB with the * correct value for your system. * * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); * If you just need to composite the PNG image onto an existing background * and if you control the code that does this you can use the optimization * setting. In this case you just copy completely opaque pixels to the * output. For pixels that are not completely transparent (you just skip * those) you do the composition math using png_composite or png_composite_16 * below then encode the resultant 8-bit or 16-bit values to match the output * encoding. * * Other cases * If neither the PNG nor the standard linear encoding work for you because * of the software or hardware you use then you have a big problem. The PNG * case will probably result in halos around the image. The linear encoding * will probably result in a washed out, too bright, image (it's actually too * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably * substantially reduce the halos. Alternatively try: * * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); * This option will also reduce the halos, but there will be slight dark * halos round the opaque parts of the image where the background is light. * In the OPTIMIZED mode the halos will be light halos where the background * is dark. Take your pick - the halos are unavoidable unless you can get * your hardware/software fixed! (The OPTIMIZED approach is slightly * faster.) * * When the default gamma of PNG files doesn't match the output gamma. * If you have PNG files with no gamma information png_set_alpha_mode allows * you to provide a default gamma, but it also sets the ouput gamma to the * matching value. If you know your PNG files have a gamma that doesn't * match the output you can take advantage of the fact that * png_set_alpha_mode always sets the output gamma but only sets the PNG * default if it is not already set: * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * The first call sets both the default and the output gamma values, the * second call overrides the output gamma without changing the default. This * is easier than achieving the same effect with png_set_gamma. You must use * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will * fire if more than one call to png_set_alpha_mode and png_set_background is * made in the same read operation, however multiple calls with PNG_ALPHA_PNG * are ignored. */ #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ # define PNG_FILLER_BEFORE 0 # define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, png_uint_32 filler, int flags)); #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p true_bits)); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) /* Have the code handle the interlacing. Returns the number of passes. * MUST be called before png_read_update_info or png_start_read_image, * otherwise it will not have the desired effect. Note that it is still * necessary to call png_read_row or png_read_rows png_get_image_height * times for each pass. */ PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED /* Handle alpha and tRNS by replacing with a background color. Prior to * libpng-1.5.4 this API must not be called before the PNG file header has been * read. Doing so will result in unexpected behavior and possible warnings or * errors if the PNG file contains a bKGD chunk. */ PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)) PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)) #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED # define PNG_BACKGROUND_GAMMA_UNKNOWN 0 # define PNG_BACKGROUND_GAMMA_SCREEN 1 # define PNG_BACKGROUND_GAMMA_FILE 2 # define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* Scale a 16-bit depth file down to 8-bit, accurately. */ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ /* Strip the second byte of information from a 16-bit depth file. */ PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_QUANTIZE_SUPPORTED /* Turn on quantizing, and reduce the palette to the number of colors * available. */ PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize)); #endif #ifdef PNG_READ_GAMMA_SUPPORTED /* The threshold on gamma processing is configurable but hard-wired into the * library. The following is the floating point variant. */ #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) /* Handle gamma correction. Screen_gamma=(display_exponent). * NOTE: this API simply sets the screen and file gamma values. It will * therefore override the value for gamma in a PNG file if it is called after * the file header has been read - use with care - call before reading the PNG * file for best results! * * These routines accept the same gamma values as png_set_alpha_mode (described * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either * API (floating point or fixed.) Notice, however, that the 'file_gamma' value * is the inverse of a 'screen gamma' value. */ PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, double screen_gamma, double override_file_gamma)) PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) #endif #ifdef PNG_WRITE_FLUSH_SUPPORTED /* Set how many lines between output flushes - 0 for no flushing */ PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); /* Flush the current PNG output buffer */ PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); #endif /* Optional update palette with requested transformations */ PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); /* Optional call to update the users info structure */ PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. */ PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read a row of data. */ PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, png_bytep display_row)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the whole image into memory at once. */ PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); #endif /* Write a row of image data */ PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, png_const_bytep row)); /* Write a few rows of image data: (*row) is not written; however, the type * is declared as writeable to maintain compatibility with previous versions * of libpng and to allow the 'display_row' array from read_rows to be passed * unchanged to write_rows. */ PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, png_uint_32 num_rows)); /* Write the image data */ PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); /* Write the end of the PNG file. */ PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. */ PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); #endif /* Free any memory associated with the png_info_struct */ PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, png_infopp info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); /* Set the libpng method of handling chunk CRC errors */ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, int ancil_action)); /* Values for png_set_crc_action() say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical * chunk. For versions prior to 0.90, the action was always error/quit, * whereas in version 0.90 and later, the action for CRC errors in ancillary * chunks is warn/discard. These values should NOT be changed. * * value action:critical action:ancillary */ #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ /* These functions give the user control over the scan-line filtering in * libpng and the compression methods used by zlib. These functions are * mainly useful for testing, as the defaults should work with most users. * Those users who are tight on memory or want faster performance at the * expense of compression can modify them. See the compression library * header file (zlib.h) for an explination of the compression functions. */ /* Set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, int filters)); /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types * below, in case they are supplied instead of the #defined constants. * These values should NOT be changed. */ #define PNG_NO_FILTERS 0x00 #define PNG_FILTER_NONE 0x08 #define PNG_FILTER_SUB 0x10 #define PNG_FILTER_UP 0x20 #define PNG_FILTER_AVG 0x40 #define PNG_FILTER_PAETH 0x80 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ PNG_FILTER_AVG | PNG_FILTER_PAETH) /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. * These defines should NOT be changed. */ #define PNG_FILTER_VALUE_NONE 0 #define PNG_FILTER_VALUE_SUB 1 #define PNG_FILTER_VALUE_UP 2 #define PNG_FILTER_VALUE_AVG 3 #define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_LAST 5 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ * defines, either the default (minimum-sum-of-absolute-differences), or * the experimental method (weighted-minimum-sum-of-absolute-differences). * * Weights are factors >= 1.0, indicating how important it is to keep the * filter type consistent between rows. Larger numbers mean the current * filter is that many times as likely to be the same as the "num_weights" * previous filters. This is cumulative for each previous row with a weight. * There needs to be "num_weights" values in "filter_weights", or it can be * NULL if the weights aren't being specified. Weights have no influence on * the selection of the first row filter. Well chosen weights can (in theory) * improve the compression for a given image. * * Costs are factors >= 1.0 indicating the relative decoding costs of a * filter type. Higher costs indicate more decoding expense, and are * therefore less likely to be selected over a filter with lower computational * costs. There needs to be a value in "filter_costs" for each valid filter * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't * setting the costs. Costs try to improve the speed of decompression without * unduly increasing the compressed image size. * * A negative weight or cost indicates the default value is to be used, and * values in the range [0.0, 1.0) indicate the value is to remain unchanged. * The default values for both weights and costs are currently 1.0, but may * change if good general weighting/cost heuristics can be found. If both * the weights and costs are set to 1.0, this degenerates the WEIGHTED method * to the UNWEIGHTED method, but with added encoding time/computation. */ PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_doublep filter_weights, png_const_doublep filter_costs)) PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_fixed_point_p filter_weights, png_const_fixed_point_p filter_costs)) #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be * changed. */ #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ #ifdef PNG_WRITE_SUPPORTED /* Set the library compression level. Currently, valid values range from * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have * shown that zlib compression levels 3-6 usually perform as well as level 9 * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, int method)); #endif #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED /* Also set zlib parameters for compressing non-IDAT chunks */ PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, int method)); #endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and * fprintf(). These functions can be made to use other I/O routines * at run time for those applications that need to handle I/O in a * different manner by calling png_set_???_fn(). See libpng-manual.txt for * more information. */ #ifdef PNG_STDIO_SUPPORTED /* Initialize the input/output for the PNG file to the default functions. */ PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); #endif /* Replace the (error and abort), and warning functions with user * supplied functions. If no messages are to be printed you must still * write and use replacement functions. The replacement error_fn should * still do a longjmp to the last setjmp location if you are using this * method of error handling. If error_fn or warning_fn is NULL, the * default function will be used. */ PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); /* Return the user pointer associated with the error functions */ PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). * It is probably a mistake to use NULL for output_flush_fn if * write_data_fn is not also NULL unless you have built libpng with * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's * default flush function, which uses the standard *FILE structure, will * be used. */ PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); /* Replace the default data input function with a user supplied one. */ PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)); /* Return the user pointer associated with the I/O functions */ PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, png_read_status_ptr read_row_fn)); PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, png_write_status_ptr write_row_fn)); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); /* Return the user pointer associated with the memory functions */ PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn)); #endif #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr write_user_transform_fn)); #endif #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)); /* Return the user pointer associated with the user transform functions */ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED /* Return information about the row currently being processed. Note that these * APIs do not fail but will return unexpected results if called outside a user * transform callback. Also note that when transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); #endif #ifdef PNG_READ_USER_CHUNKS_SUPPORTED /* This callback is called only for *unknown* chunks. If * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known * chunks to be treated as unknown, however in this case the callback must do * any processing required by the chunk (e.g. by calling the appropriate * png_set_ APIs.) * * There is no write support - on write, by default, all the chunks in the * 'unknown' list are written in the specified position. * * The integer return from the callback function is interpreted thus: * * negative: An error occured, png_chunk_error will be called. * zero: The chunk was not handled, the chunk will be saved. A critical * chunk will cause an error at this point unless it is to be saved. * positive: The chunk was handled, libpng will ignore/discard it. * * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about * how this behavior will change in libpng 1.7 */ PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); /* Returns the user pointer associated with the push read functions */ PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structrp png_ptr)); /* Function to be called when data becomes available */ PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)); /* A function which may be called *only* within png_process_data to stop the * processing of any more data. The function returns the number of bytes * remaining, excluding any that libpng has cached internally. A subsequent * call to png_process_data must supply these bytes again. If the argument * 'save' is set to true the routine will first save all the pending data and * will always return 0. */ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); /* A function which may be called *only* outside (after) a call to * png_process_data. It returns the number of bytes of data to skip in the * input. Normally it will return 0, but if it returns a non-zero value the * application must skip than number of bytes of input data and pass the * following data to the next call to png_process_data. */ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); #ifdef PNG_READ_INTERLACING_SUPPORTED /* Function that combines rows. 'new_row' is a flag that should come from * the callback and be non-NULL if anything needs to be done; the library * stores its own version of the new data internally and ignores the passed * in value. */ PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, png_bytep old_row, png_const_bytep new_row)); #endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.4.0 */ PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.2.4 */ PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Frees a pointer allocated by png_malloc() */ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); /* Free data that was allocated internally */ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 free_me, int num)); /* Reassign responsibility for freeing existing data, whether allocated * by libpng or by the application; this works on the png_info structure passed * in, it does not change the state for other png_info structures. * * It is unlikely that this function works correctly as of 1.6.0 and using it * may result either in memory leaks or double free of allocated data. */ PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr, png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED); /* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 /* Flags for png_ptr->free_me and info_ptr->free_me */ #define PNG_FREE_HIST 0x0008 #define PNG_FREE_ICCP 0x0010 #define PNG_FREE_SPLT 0x0020 #define PNG_FREE_ROWS 0x0040 #define PNG_FREE_PCAL 0x0080 #define PNG_FREE_SCAL 0x0100 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED # define PNG_FREE_UNKN 0x0200 #endif /* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */ #define PNG_FREE_PLTE 0x1000 #define PNG_FREE_TRNS 0x2000 #define PNG_FREE_TEXT 0x4000 #define PNG_FREE_ALL 0x7fff #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, png_voidp ptr), PNG_DEPRECATED); #endif #ifdef PNG_ERROR_TEXT_SUPPORTED /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); /* The same, but the chunk name is prepended to the error string. */ PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); #else /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); #endif #ifdef PNG_WARNINGS_SUPPORTED /* Non-fatal error in libpng. Can continue, but may have a problem. */ PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); /* Non-fatal error in libpng, chunk name is prepended to message. */ PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif #ifdef PNG_BENIGN_ERRORS_SUPPORTED /* Benign error in libpng. Can continue, but may have a problem. * User can choose whether to handle as a fatal error or as a warning. */ PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #ifdef PNG_READ_SUPPORTED /* Same, chunk name is prepended to message (only during read) */ PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif PNG_EXPORT(109, void, png_set_benign_errors, (png_structrp png_ptr, int allowed)); #else # ifdef PNG_ALLOW_BENIGN_ERRORS # define png_benign_error png_warning # define png_chunk_benign_error png_chunk_warning # else # define png_benign_error png_error # define png_chunk_benign_error png_chunk_error # endif #endif /* The png_set_ functions are for storing values in the png_info_struct. * Similarly, the png_get_ calls are used to read values from the * png_info_struct, either storing the parameters in the passed variables, or * setting pointers into the png_info_struct where the data is stored. The * png_get_ functions return a non-zero value if the data was available * in info_ptr, or return zero and do not change any of the parameters if the * data was not available. * * These functions should be used instead of directly accessing png_info * to avoid problems with future changes in the size and internal layout of * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* Returns row_pointers, which is an array of pointers to scanlines that was * returned from png_read_png(). */ PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Set row_pointers, which is an array of pointers to scanlines for use * by png_write_png(). */ PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image height in pixels. */ PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image bit_depth. */ PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image color_type. */ PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image filter_type. */ PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image interlace_type. */ PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image compression_type. */ PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, (png_const_structrp png_ptr, png_const_inforp info_ptr)) PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif /* PNG_EASY_ACCESS_SUPPORTED */ #ifdef PNG_READ_SUPPORTED /* Returns pointer to signature string read from PNG header */ PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_16p *background)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_16p background)); #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)) PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, double *green_X, double *green_Y, double *green_Z, double *blue_X, double *blue_Y, double *blue_Z)) PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_white_x, png_fixed_point *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_red_X, png_fixed_point *int_red_Y, png_fixed_point *int_red_Z, png_fixed_point *int_green_X, png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, png_fixed_point *int_blue_Z)) #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)) PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double red_Y, double red_Z, double green_X, double green_Y, double green_Z, double blue_X, double blue_Y, double blue_Z)) PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, png_fixed_point int_blue_y)) PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, png_fixed_point int_blue_X, png_fixed_point int_blue_Y, png_fixed_point int_blue_Z)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *file_gamma)) PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_file_gamma)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)) PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_file_gamma)) #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_16p *hist)); #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist)); #endif PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)); PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_method, int compression_method, int filter_method)); #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); #endif #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)); PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, png_inforp info_ptr, png_const_colorp palette, int num_palette)); #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_8p *sig_bit)); #endif #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_8p sig_bit)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *file_srgb_intent)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_charpp name, int *compression_type, png_bytepp profile, png_uint_32 *proflen)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp name, int compression_type, png_const_bytep profile, png_uint_32 proflen)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_sPLT_tpp entries)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); #endif #ifdef PNG_TEXT_SUPPORTED /* png_get_text also returns the number of text chunks in *num_text */ PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_textp *text_ptr, int *num_text)); #endif /* Note while png_set_text() will accept a structure whose text, * language, and translated keywords are NULL pointers, the structure * returned by png_get_text will always contain regular * zero-terminated C strings. They might be empty strings but * they will never be NULL pointers. */ #ifdef PNG_TEXT_SUPPORTED PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_timep *mod_time)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_timep mod_time)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)); #endif #ifdef PNG_sCAL_SUPPORTED PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)) #if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ defined(PNG_FLOATING_POINT_SUPPORTED) /* NOTE: this API is currently implemented using floating point arithmetic, * consequently it can only be used on systems with floating point support. * In any case the range of values supported by png_fixed_point is small and it * is highly recommended that png_get_sCAL_s be used instead. */ PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height)) #endif PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, double width, double height)) PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_fixed_point width, png_fixed_point height)) PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)); #endif /* PNG_sCAL_SUPPORTED */ #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED /* Provide the default handling for all unknown chunks or, optionally, for * specific unknown chunks. * * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was * ignored and the default was used, the per-chunk setting only had an effect on * write. If you wish to have chunk-specific handling on read in code that must * work on earlier versions you must use a user chunk callback to specify the * desired handling (keep or discard.) * * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The * parameter is interpreted as follows: * * READ: * PNG_HANDLE_CHUNK_AS_DEFAULT: * Known chunks: do normal libpng processing, do not keep the chunk (but * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) * Unknown chunks: for a specific chunk use the global default, when used * as the default discard the chunk data. * PNG_HANDLE_CHUNK_NEVER: * Discard the chunk data. * PNG_HANDLE_CHUNK_IF_SAFE: * Keep the chunk data if the chunk is not critical else raise a chunk * error. * PNG_HANDLE_CHUNK_ALWAYS: * Keep the chunk data. * * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks * it simply resets the behavior to the libpng default. * * INTERACTION WTIH USER CHUNK CALLBACKS: * The per-chunk handling is always used when there is a png_user_chunk_ptr * callback and the callback returns 0; the chunk is then always stored *unless* * it is critical and the per-chunk setting is other than ALWAYS. Notice that * the global default is *not* used in this case. (In effect the per-chunk * value is incremented to at least IF_SAFE.) * * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and * per-chunk defaults will be honored. If you want to preserve the current * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE * as the default - if you don't do this libpng 1.6 will issue a warning. * * If you want unhandled unknown chunks to be discarded in libpng 1.6 and * earlier simply return '1' (handled). * * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: * If this is *not* set known chunks will always be handled by libpng and * will never be stored in the unknown chunk list. Known chunks listed to * png_set_keep_unknown_chunks will have no effect. If it is set then known * chunks listed with a keep other than AS_DEFAULT will *never* be processed * by libpng, in addition critical chunks must either be processed by the * callback or saved. * * The IHDR and IEND chunks must not be listed. Because this turns off the * default handling for chunks that would otherwise be recognized the * behavior of libpng transformations may well become incorrect! * * WRITE: * When writing chunks the options only apply to the chunks specified by * png_set_unknown_chunks (below), libpng will *always* write known chunks * required by png_set_ calls and will always write the core critical chunks * (as required for PLTE). * * Each chunk in the png_set_unknown_chunks list is looked up in the * png_set_keep_unknown_chunks list to find the keep setting, this is then * interpreted as follows: * * PNG_HANDLE_CHUNK_AS_DEFAULT: * Write safe-to-copy chunks and write other chunks if the global * default is set to _ALWAYS, otherwise don't write this chunk. * PNG_HANDLE_CHUNK_NEVER: * Do not write the chunk. * PNG_HANDLE_CHUNK_IF_SAFE: * Write the chunk if it is safe-to-copy, otherwise do not write it. * PNG_HANDLE_CHUNK_ALWAYS: * Write the chunk. * * Note that the default behavior is effectively the opposite of the read case - * in read unknown chunks are not stored by default, in write they are written * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different * - on write the safe-to-copy bit is checked, on read the critical bit is * checked and on read if the chunk is critical an error will be raised. * * num_chunks: * =========== * If num_chunks is positive, then the "keep" parameter specifies the manner * for handling only those chunks appearing in the chunk_list array, * otherwise the chunk list array is ignored. * * If num_chunks is 0 the "keep" parameter specifies the default behavior for * unknown chunks, as described above. * * If num_chunks is negative, then the "keep" parameter specifies the manner * for handling all unknown chunks plus all chunks recognized by libpng * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to * be processed by libpng. */ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks)); /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; * the result is therefore true (non-zero) if special handling is required, * false for the default handling. */ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, png_const_bytep chunk_name)); #endif #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)); /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added * unknowns to the location currently stored in the png_struct. This is * invariably the wrong value on write. To fix this call the following API * for each chunk in the list with the correct location. If you know your * code won't be compiled on earlier versions you can rely on * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing * the correct thing. */ PNG_EXPORT(175, void, png_set_unknown_chunk_location, (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_unknown_chunkpp entries)); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. * If you need to turn it off for a chunk that your application has freed, * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, png_inforp info_ptr, int mask)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* The "params" pointer is currently not used and is for future expansion. */ PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); #endif PNG_EXPORT(180, png_const_charp, png_get_copyright, (png_const_structrp png_ptr)); PNG_EXPORT(181, png_const_charp, png_get_header_ver, (png_const_structrp png_ptr)); PNG_EXPORT(182, png_const_charp, png_get_header_version, (png_const_structrp png_ptr)); PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, (png_const_structrp png_ptr)); #ifdef PNG_MNG_FEATURES_SUPPORTED PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, png_uint_32 mng_features_permitted)); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 #define PNG_HANDLE_CHUNK_LAST 4 /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, png_uint_32 strip_mode)); #endif /* Added in libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); PNG_EXPORT(187, png_uint_32, png_get_user_width_max, (png_const_structrp png_ptr)); PNG_EXPORT(188, png_uint_32, png_get_user_height_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.0 */ PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)); PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.1 */ PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, png_alloc_size_t user_chunk_cache_max)); PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, (png_const_structrp png_ptr)); #endif #if defined(PNG_INCH_CONVERSIONS_SUPPORTED) PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_FP_EXPORT(196, float, png_get_x_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif # ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); # endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ /* Added in libpng-1.4.0 */ #ifdef PNG_IO_STATE_SUPPORTED PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); /* Removed from libpng 1.6; use png_get_io_chunk_type. */ PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), PNG_DEPRECATED) PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, (png_const_structrp png_ptr)); /* The flags returned by png_get_io_state() are the following: */ # define PNG_IO_NONE 0x0000 /* no I/O at this moment */ # define PNG_IO_READING 0x0001 /* currently reading */ # define PNG_IO_WRITING 0x0002 /* currently writing */ # define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ # define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ # define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ # define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ # define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ # define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ #endif /* ?PNG_IO_STATE_SUPPORTED */ /* Interlace support. The following macros are always defined so that if * libpng interlace handling is turned off the macros may be used to handle * interlaced images within the application. */ #define PNG_INTERLACE_ADAM7_PASSES 7 /* Two macros to return the first row and first column of the original, * full, image which appears in a given pass. 'pass' is in the range 0 * to 6 and the result is in the range 0 to 7. */ #define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) #define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) /* A macro to return the offset between pixels in the output row for a pair of * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that * follows. Note that ROW_OFFSET is the offset from one row to the next whereas * COL_OFFSET is from one column to the next, within a row. */ #define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) #define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) /* Two macros to help evaluate the number of rows or columns in each * pass. This is expressed as a shift - effectively log2 of the number or * rows or columns in each 8x8 tile of the original image. */ #define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) #define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) /* Hence two macros to determine the number of rows or columns in a given * pass of an image given its height or width. In fact these macros may * return non-zero even though the sub-image is empty, because the other * dimension may be empty for a small image. */ #define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) #define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) /* For the reader row callbacks (both progressive and sequential) it is * necessary to find the row in the output image given a row in an interlaced * image, so two more macros: */ #define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ (((y_in)<>(((7-(off))-(pass))<<2)) & 0xF) | \ ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) #define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) #define PNG_COL_IN_INTERLACE_PASS(x, pass) \ ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on * most machines. However, it does take more operations than the corresponding * divide method, so it may be slower on a few RISC systems. There are two * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. * * Note that the rounding factors are NOT supposed to be the same! 128 and * 32768 are correct for the NODIV code; 127 and 32767 are correct for the * standard method. * * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] */ /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ # define png_composite(composite, fg, alpha, bg) \ { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ * (png_uint_16)(alpha) \ + (png_uint_16)(bg)*(png_uint_16)(255 \ - (png_uint_16)(alpha)) + 128); \ (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } # define png_composite_16(composite, fg, alpha, bg) \ { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ * (png_uint_32)(alpha) \ + (png_uint_32)(bg)*(65535 \ - (png_uint_32)(alpha)) + 32768); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } #else /* Standard method using integer division */ # define png_composite(composite, fg, alpha, bg) \ (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ 127) / 255) # define png_composite_16(composite, fg, alpha, bg) \ (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ 32767) / 65535) #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); #endif PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, png_const_bytep buf)); /* No png_get_int_16 -- may be added if there's a real need for it. */ /* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); #endif #ifdef PNG_SAVE_INT_32_SUPPORTED PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); #endif /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); /* No png_save_int_16 -- may be added if there's a real need for it. */ #endif #ifdef PNG_USE_READ_MACROS /* Inline macros to do direct reads of bytes from the input buffer. * The png_get_int_32() routine assumes we are using two's complement * format for negative values, which is almost certainly true. */ # define PNG_get_uint_32(buf) \ (((png_uint_32)(*(buf)) << 24) + \ ((png_uint_32)(*((buf) + 1)) << 16) + \ ((png_uint_32)(*((buf) + 2)) << 8) + \ ((png_uint_32)(*((buf) + 3)))) /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the * function) incorrectly returned a value of type png_uint_32. */ # define PNG_get_uint_16(buf) \ ((png_uint_16) \ (((unsigned int)(*(buf)) << 8) + \ ((unsigned int)(*((buf) + 1))))) # define PNG_get_int_32(buf) \ ((png_int_32)((*(buf) & 0x80) \ ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \ : (png_int_32)png_get_uint_32(buf))) /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, * but defining a macro name prefixed with PNG_PREFIX. */ # ifndef PNG_PREFIX # define png_get_uint_32(buf) PNG_get_uint_32(buf) # define png_get_uint_16(buf) PNG_get_uint_16(buf) # define png_get_int_32(buf) PNG_get_int_32(buf) # endif #else # ifdef PNG_PREFIX /* No macros; revert to the (redefined) function */ # define PNG_get_uint_32 (png_get_uint_32) # define PNG_get_uint_16 (png_get_uint_16) # define PNG_get_int_32 (png_get_int_32) # endif #endif /******************************************************************************* * SIMPLIFIED API ******************************************************************************* * * Please read the documentation in libpng-manual.txt (TODO: write said * documentation) if you don't understand what follows. * * The simplified API hides the details of both libpng and the PNG file format * itself. It allows PNG files to be read into a very limited number of * in-memory bitmap formats or to be written from the same formats. If these * formats do not accomodate your needs then you can, and should, use the more * sophisticated APIs above - these support a wide variety of in-memory formats * and a wide variety of sophisticated transformations to those formats as well * as a wide variety of APIs to manipulate ancillary information. * * To read a PNG file using the simplified API: * * 1) Declare a 'png_image' structure (see below) on the stack and set the * version field to PNG_IMAGE_VERSION. * 2) Call the appropriate png_image_begin_read... function. * 3) Set the png_image 'format' member to the required sample format. * 4) Allocate a buffer for the image and, if required, the color-map. * 5) Call png_image_finish_read to read the image and, if required, the * color-map into your buffers. * * There are no restrictions on the format of the PNG input itself; all valid * color types, bit depths, and interlace methods are acceptable, and the * input image is transformed as necessary to the requested in-memory format * during the png_image_finish_read() step. The only caveat is that if you * request a color-mapped image from a PNG that is full-color or makes * complex use of an alpha channel the transformation is extremely lossy and the * result may look terrible. * * To write a PNG file using the simplified API: * * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. * 2) Initialize the members of the structure that describe the image, setting * the 'format' member to the format of the image samples. * 3) Call the appropriate png_image_write... function with a pointer to the * image and, if necessary, the color-map to write the PNG data. * * png_image is a structure that describes the in-memory format of an image * when it is being read or defines the in-memory format of an image that you * need to write: */ #define PNG_IMAGE_VERSION 1 typedef struct png_control *png_controlp; typedef struct { png_controlp opaque; /* Initialize to NULL, free with png_image_free */ png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ png_uint_32 width; /* Image width in pixels (columns) */ png_uint_32 height; /* Image height in pixels (rows) */ png_uint_32 format; /* Image format as defined below */ png_uint_32 flags; /* A bit mask containing informational flags */ png_uint_32 colormap_entries; /* Number of entries in the color-map */ /* In the event of an error or warning the following field will be set to a * non-zero value and the 'message' field will contain a '\0' terminated * string with the libpng error or warning message. If both warnings and * an error were encountered, only the error is recorded. If there * are multiple warnings, only the first one is recorded. * * The upper 30 bits of this value are reserved, the low two bits contain * a value as follows: */ # define PNG_IMAGE_WARNING 1 # define PNG_IMAGE_ERROR 2 /* * The result is a two bit code such that a value more than 1 indicates * a failure in the API just called: * * 0 - no warning or error * 1 - warning * 2 - error * 3 - error preceded by warning */ # define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) png_uint_32 warning_or_error; char message[64]; } png_image, *png_imagep; /* The samples of the image have one to four channels whose components have * original values in the range 0 to 1.0: * * 1: A single gray or luminance channel (G). * 2: A gray/luminance channel and an alpha channel (GA). * 3: Three red, green, blue color channels (RGB). * 4: Three color channels and an alpha channel (RGBA). * * The components are encoded in one of two ways: * * a) As a small integer, value 0..255, contained in a single byte. For the * alpha channel the original value is simply value/255. For the color or * luminance channels the value is encoded according to the sRGB specification * and matches the 8-bit format expected by typical display devices. * * The color/gray channels are not scaled (pre-multiplied) by the alpha * channel and are suitable for passing to color management software. * * b) As a value in the range 0..65535, contained in a 2-byte integer. All * channels can be converted to the original value by dividing by 65535; all * channels are linear. Color channels use the RGB encoding (RGB end-points) of * the sRGB specification. This encoding is identified by the * PNG_FORMAT_FLAG_LINEAR flag below. * * When the simplified API needs to convert between sRGB and linear colorspaces, * the actual sRGB transfer curve defined in the sRGB specification (see the * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 * approximation used elsewhere in libpng. * * When an alpha channel is present it is expected to denote pixel coverage * of the color or luminance channels and is returned as an associated alpha * channel: the color/gray channels are scaled (pre-multiplied) by the alpha * value. * * The samples are either contained directly in the image data, between 1 and 8 * bytes per pixel according to the encoding, or are held in a color-map indexed * by bytes in the image data. In the case of a color-map the color-map entries * are individual samples, encoded as above, and the image data has one byte per * pixel to select the relevant sample from the color-map. */ /* PNG_FORMAT_* * * #defines to be used in png_image::format. Each #define identifies a * particular layout of sample data and, if present, alpha values. There are * separate defines for each of the two component encodings. * * A format is built up using single bit flag values. All combinations are * valid. Formats can be built up from the flag values or you can use one of * the predefined values below. When testing formats always use the FORMAT_FLAG * macros to test for individual features - future versions of the library may * add new flags. * * When reading or writing color-mapped images the format should be set to the * format of the entries in the color-map then png_image_{read,write}_colormap * called to read or write the color-map and set the format correctly for the * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! * * NOTE: libpng can be built with particular features disabled, if you see * compiler errors because the definition of one of the following flags has been * compiled out it is because libpng does not have the required support. It is * possible, however, for the libpng configuration to enable the format on just * read or just write; in that case you may see an error at run time. You can * guard against this by checking for the definition of the appropriate * "_SUPPORTED" macro, one of: * * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED */ #define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ #define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ #define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2 byte channels else 1 byte */ #define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ #ifdef PNG_FORMAT_BGR_SUPPORTED # define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ #endif #ifdef PNG_FORMAT_AFIRST_SUPPORTED # define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ #endif /* Commonly used formats have predefined macros. * * First the single byte (sRGB) formats: */ #define PNG_FORMAT_GRAY 0 #define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA #define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR #define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) #define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) /* Then the linear 2-byte formats. When naming these "Y" is used to * indicate a luminance (gray) channel. */ #define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR #define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) #define PNG_FORMAT_LINEAR_RGB_ALPHA \ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) /* With color-mapped formats the image data is one byte for each pixel, the byte * is an index into the color-map which is formatted as above. To obtain a * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP * to one of the above definitions, or you can use one of the definitions below. */ #define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) /* PNG_IMAGE macros * * These are convenience macros to derive information from a png_image * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the * actual image sample values - either the entries in the color-map or the * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values * for the pixels and will always return 1 for color-mapped formats. The * remaining macros return information about the rows in the image and the * complete image. * * NOTE: All the macros that take a png_image::format parameter are compile time * constants if the format parameter is, itself, a constant. Therefore these * macros can be used in array declarations and case labels where required. * Similarly the macros are also pre-processor constants (sizeof is not used) so * they can be used in #if tests. * * First the information about the samples. */ #define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) /* Return the total number of channels in a given format: 1..4 */ #define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) /* Return the size in bytes of a single component of a pixel or color-map * entry (as appropriate) in the image: 1 or 2. */ #define PNG_IMAGE_SAMPLE_SIZE(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) /* This is the size of the sample data for one sample. If the image is * color-mapped it is the size of one color-map entry (and image pixels are * one byte in size), otherwise it is the size of one image pixel. */ #define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) /* The maximum size of the color-map required by the format expressed in a * count of components. This can be used to compile-time allocate a * color-map: * * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; * * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; * * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the * information from one of the png_image_begin_read_ APIs and dynamically * allocate the required memory. */ /* Corresponding information about the pixels */ #define PNG_IMAGE_PIXEL_(test,fmt)\ (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) #define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) /* The number of separate channels (components) in a pixel; 1 for a * color-mapped image. */ #define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) /* The size, in bytes, of each component in a pixel; 1 for a color-mapped * image. */ #define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ /* Information about the whole row, or whole image */ #define PNG_IMAGE_ROW_STRIDE(image)\ (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) /* Return the total number of components in a single row of the image; this * is the minimum 'row stride', the minimum count of components between each * row. For a color-mapped image this is the minimum number of bytes in a * row. */ #define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) /* Return the size, in bytes, of an image buffer given a png_image and a row * stride - the number of components to leave space for in each row. */ #define PNG_IMAGE_SIZE(image)\ PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) /* Return the size, in bytes, of the image in memory given just a png_image; * the row stride is the minimum stride required for the image. */ #define PNG_IMAGE_COLORMAP_SIZE(image)\ (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) /* Return the size, in bytes, of the color-map of this image. If the image * format is not a color-map format this will return a size sufficient for * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if * you don't want to allocate a color-map in this case. */ /* PNG_IMAGE_FLAG_* * * Flags containing additional information about the image are held in the * 'flags' field of png_image. */ #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 /* This indicates the the RGB values of the in-memory bitmap do not * correspond to the red, green and blue end-points defined by sRGB. */ #define PNG_IMAGE_FLAG_FAST 0x02 /* On write emphasise speed over compression; the resultant PNG file will be * larger but will be produced significantly faster, particular for large * images. Do not use this option for images which will be distributed, only * used it when producing intermediate files that will be read back in * repeatedly. For a typical 24-bit image the option will double the read * speed at the cost of increasing the image size by 25%, however for many * more compressible images the PNG file can be 10 times larger with only a * slight speed gain. */ #define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 /* On read if the image is a 16-bit per component image and there is no gAMA * or sRGB chunk assume that the components are sRGB encoded. Notice that * images output by the simplified API always have gamma information; setting * this flag only affects the interpretation of 16-bit images from an * external source. It is recommended that the application expose this flag * to the user; the user can normally easily recognize the difference between * linear and sRGB encoding. This flag has no effect on write - the data * passed to the write APIs must have the correct encoding (as defined * above.) * * If the flag is not set (the default) input 16-bit per component data is * assumed to be linear. * * NOTE: the flag can only be set after the png_image_begin_read_ call, * because that call initializes the 'flags' field. */ #ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* READ APIs * --------- * * The png_image passed to the read APIs must have been initialized by setting * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) */ #ifdef PNG_STDIO_SUPPORTED PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, const char *file_name)); /* The named file is opened for read and the image header is filled in * from the PNG header in the file. */ PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, FILE* file)); /* The PNG header is read from the stdio FILE object. */ #endif /* PNG_STDIO_SUPPORTED */ PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, png_const_voidp memory, png_size_t size)); /* The PNG header is read from the given memory buffer. */ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, png_const_colorp background, void *buffer, png_int_32 row_stride, void *colormap)); /* Finish reading the image into the supplied buffer and clean up the * png_image structure. * * row_stride is the step, in byte or 2-byte units as appropriate, * between adjacent rows. A positive stride indicates that the top-most row * is first in the buffer - the normal top-down arrangement. A negative * stride indicates that the bottom-most row is first in the buffer. * * background need only be supplied if an alpha channel must be removed from * a png_byte format and the removal is to be done by compositing on a solid * color; otherwise it may be NULL and any composition will be done directly * onto the buffer. The value is an sRGB color to use for the background, * for grayscale output the green channel is used. * * background must be supplied when an alpha channel must be removed from a * single byte color-mapped output format, in other words if: * * 1) The original format from png_image_begin_read_from_* had * PNG_FORMAT_FLAG_ALPHA set. * 2) The format set by the application does not. * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and * PNG_FORMAT_FLAG_LINEAR *not* set. * * For linear output removing the alpha channel is always done by compositing * on black and background is ignored. * * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. * image->colormap_entries will be updated to the actual number of entries * written to the colormap; this may be less than the original value. */ PNG_EXPORT(238, void, png_image_free, (png_imagep image)); /* Free any data allocated by libpng in image->opaque, setting the pointer to * NULL. May be called at any time after the structure is initialized. */ #endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED /* WRITE APIS * ---------- * For write you must initialize a png_image structure to describe the image to * be written. To do this use memset to set the whole structure to 0 then * initialize fields describing your image. * * version: must be set to PNG_IMAGE_VERSION * opaque: must be initialized to NULL * width: image width in pixels * height: image height in rows * format: the format of the data (image and color-map) you wish to write * flags: set to 0 unless one of the defined flags applies; set * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB * values do not correspond to the colors in sRGB. * colormap_entries: set to the number of entries in the color-map (0 to 256) */ PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, const char *file, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the named file. */ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the given (FILE*). */ /* With both write APIs if image is in one of the linear formats with 16-bit * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG * gamma encoded according to the sRGB specification, otherwise a 16-bit linear * encoded PNG file is written. * * With color-mapped data formats the colormap parameter point to a color-map * with at least image->colormap_entries encoded in the specified format. If * the format is linear the written PNG color-map will be converted to sRGB * regardless of the convert_to_8_bit flag. * * With all APIs row_stride is handled as in the read APIs - it is the spacing * from one row to the next in component sized units (1 or 2 bytes) and if * negative indicates a bottom-up row layout in the buffer. * * Note that the write API does not support interlacing or sub-8-bit pixels. */ #endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */ /******************************************************************************* * END OF SIMPLIFIED API ******************************************************************************/ #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED PNG_EXPORT(242, void, png_set_check_for_invalid_index, (png_structrp png_ptr, int allowed)); # ifdef PNG_GET_PALETTE_MAX_SUPPORTED PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, png_const_infop info_ptr)); # endif #endif /* CHECK_FOR_INVALID_INDEX */ /******************************************************************************* * IMPLEMENTATION OPTIONS ******************************************************************************* * * Support for arbitrary implementation-specific optimizations. The API allows * particular options to be turned on or off. 'Option' is the number of the * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given * by the PNG_OPTION_ defines below. * * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, * are detected at run time, however sometimes it may be impossible * to do this in user mode, in which case it is necessary to discover * the capabilities in an OS specific way. Such capabilities are * listed here when libpng has support for them and must be turned * ON by the application if present. * * SOFTWARE: sometimes software optimizations actually result in performance * decrease on some architectures or systems, or with some sets of * PNG images. 'Software' options allow such optimizations to be * selected at run time. */ #ifdef PNG_SET_OPTION_SUPPORTED #ifdef PNG_ARM_NEON_API_SUPPORTED # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ #endif #define PNG_OPTION_NEXT 2 /* Next option - numbers must be even */ /* Return values: NOTE: there are four values and 'off' is *not* zero */ #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ #define PNG_OPTION_INVALID 1 /* Option number out of range */ #define PNG_OPTION_OFF 2 #define PNG_OPTION_ON 3 PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, int onoff)); #endif /******************************************************************************* * END OF HARDWARE OPTIONS ******************************************************************************/ /* Maintainer: Put new public prototypes here ^, in libpng.3, and project * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt */ /* The last ordinal number (this is the *last* one already used; the next * one to use is one more than this.) Maintainer, remember to add an entry to * scripts/symbols.def as well. */ #ifdef PNG_EXPORT_LAST_ORDINAL PNG_EXPORT_LAST_ORDINAL(244); #endif #ifdef __cplusplus } #endif #endif /* PNG_VERSION_INFO_ONLY */ /* Do not put anything past this line */ #endif /* PNG_H */ ================================================ FILE: cocos2d/external/png/include/win32/pngconf.h ================================================ /* pngconf.h - machine configurable file for libpng * * libpng version 1.6.2 - April 25, 2013 * * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h * */ /* Any machine specific code is near the front of this file, so if you * are configuring libpng for a machine, you may want to read the section * starting here down to where it starts to typedef png_color, png_text, * and png_info. */ #ifndef PNGCONF_H #define PNGCONF_H /* To do: Do all of this in scripts/pnglibconf.dfa */ #ifdef PNG_SAFE_LIMITS_SUPPORTED # ifdef PNG_USER_WIDTH_MAX # undef PNG_USER_WIDTH_MAX # define PNG_USER_WIDTH_MAX 1000000L # endif # ifdef PNG_USER_HEIGHT_MAX # undef PNG_USER_HEIGHT_MAX # define PNG_USER_HEIGHT_MAX 1000000L # endif # ifdef PNG_USER_CHUNK_MALLOC_MAX # undef PNG_USER_CHUNK_MALLOC_MAX # define PNG_USER_CHUNK_MALLOC_MAX 4000000L # endif # ifdef PNG_USER_CHUNK_CACHE_MAX # undef PNG_USER_CHUNK_CACHE_MAX # define PNG_USER_CHUNK_CACHE_MAX 128 # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C * compiler for correct compilation. The following header files are required by * the standard. If your compiler doesn't provide these header files, or they * do not match the standard, you will need to provide/improve them. */ #include #include /* Library header files. These header files are all defined by ISOC90; libpng * expects conformant implementations, however, an ISOC90 conformant system need * not provide these header files if the functionality cannot be implemented. * In this case it will be necessary to disable the relevant parts of libpng in * the build of pnglibconf.h. * * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not * include this unnecessary header file. */ #ifdef PNG_STDIO_SUPPORTED /* Required for the definition of FILE: */ # include #endif #ifdef PNG_SETJMP_SUPPORTED /* Required for the definition of jmp_buf and the declaration of longjmp: */ # include #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Required for struct tm: */ # include #endif #endif /* PNG_BUILDING_SYMBOL_TABLE */ /* Prior to 1.6.0 it was possible to turn off 'const' in declarations using * PNG_NO_CONST; this is no longer supported except for data declarations which * apparently still cause problems in 2011 on some compilers. */ #define PNG_CONST const /* backward compatibility only */ /* This controls optimization of the reading of 16 and 32 bit values * from PNG files. It can be set on a per-app-file basis - it * just changes whether a macro is used when the function is called. * The library builder sets the default; if read functions are not * built into the library the macro implementation is forced on. */ #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED # define PNG_USE_READ_MACROS #endif #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) # if PNG_DEFAULT_READ_MACROS # define PNG_USE_READ_MACROS # endif #endif /* COMPILER SPECIFIC OPTIONS. * * These options are provided so that a variety of difficult compilers * can be used. Some are fixed at build time (e.g. PNG_API_RULE * below) but still have compiler specific implementations, others * may be changed on a per-file basis when compiling against libpng. */ /* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect * against legacy (pre ISOC90) compilers that did not understand function * prototypes. It is not required for modern C compilers. */ #ifndef PNGARG # define PNGARG(arglist) arglist #endif /* Function calling conventions. * ============================= * Normally it is not necessary to specify to the compiler how to call * a function - it just does it - however on x86 systems derived from * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems * and some others) there are multiple ways to call a function and the * default can be changed on the compiler command line. For this reason * libpng specifies the calling convention of every exported function and * every function called via a user supplied function pointer. This is * done in this file by defining the following macros: * * PNGAPI Calling convention for exported functions. * PNGCBAPI Calling convention for user provided (callback) functions. * PNGCAPI Calling convention used by the ANSI-C library (required * for longjmp callbacks and sometimes used internally to * specify the calling convention for zlib). * * These macros should never be overridden. If it is necessary to * change calling convention in a private build this can be done * by setting PNG_API_RULE (which defaults to 0) to one of the values * below to select the correct 'API' variants. * * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. * This is correct in every known environment. * PNG_API_RULE=1 Use the operating system convention for PNGAPI and * the 'C' calling convention (from PNGCAPI) for * callbacks (PNGCBAPI). This is no longer required * in any known environment - if it has to be used * please post an explanation of the problem to the * libpng mailing list. * * These cases only differ if the operating system does not use the C * calling convention, at present this just means the above cases * (x86 DOS/Windows sytems) and, even then, this does not apply to * Cygwin running on those systems. * * Note that the value must be defined in pnglibconf.h so that what * the application uses to call the library matches the conventions * set when building the library. */ /* Symbol export * ============= * When building a shared library it is almost always necessary to tell * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' * is used to mark the symbols. On some systems these symbols can be * extracted at link time and need no special processing by the compiler, * on other systems the symbols are flagged by the compiler and just * the declaration requires a special tag applied (unfortunately) in a * compiler dependent way. Some systems can do either. * * A small number of older systems also require a symbol from a DLL to * be flagged to the program that calls it. This is a problem because * we do not know in the header file included by application code that * the symbol will come from a shared library, as opposed to a statically * linked one. For this reason the application must tell us by setting * the magic flag PNG_USE_DLL to turn on the special processing before * it includes png.h. * * Four additional macros are used to make this happen: * * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from * the build or imported if PNG_USE_DLL is set - compiler * and system specific. * * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to * 'type', compiler specific. * * PNG_DLL_EXPORT Set to the magic to use during a libpng build to * make a symbol exported from the DLL. Not used in the * public header files; see pngpriv.h for how it is used * in the libpng build. * * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come * from a DLL - used to define PNG_IMPEXP when * PNG_USE_DLL is set. */ /* System specific discovery. * ========================== * This code is used at build time to find PNG_IMPEXP, the API settings * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL * import processing is possible. On Windows systems it also sets * compiler-specific macros to the values required to change the calling * conventions of the various functions. */ #if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or * MinGW on any architecture currently supported by Windows. Also includes * Watcom builds but these need special treatment because they are not * compatible with GCC or Visual C because of different calling conventions. */ # if PNG_API_RULE == 2 /* If this line results in an error, either because __watcall is not * understood or because of a redefine just below you cannot use *this* * build of the library with the compiler you are using. *This* build was * build using Watcom and applications must also be built using Watcom! */ # define PNGCAPI __watcall # endif # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) # define PNGCAPI __cdecl # if PNG_API_RULE == 1 /* If this line results in an error __stdcall is not understood and * PNG_API_RULE should not have been set to '1'. */ # define PNGAPI __stdcall # endif # else /* An older compiler, or one not detected (erroneously) above, * if necessary override on the command line to get the correct * variants for the compiler. */ # ifndef PNGCAPI # define PNGCAPI _cdecl # endif # if PNG_API_RULE == 1 && !defined(PNGAPI) # define PNGAPI _stdcall # endif # endif /* compiler/api */ /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) # error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" # endif # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ (defined(__BORLANDC__) && __BORLANDC__ < 0x500) /* older Borland and MSC * compilers used '__export' and required this to be after * the type. */ # ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP # endif # define PNG_DLL_EXPORT __export # else /* newer compiler */ # define PNG_DLL_EXPORT __declspec(dllexport) # ifndef PNG_DLL_IMPORT # define PNG_DLL_IMPORT __declspec(dllimport) # endif # endif /* compiler */ #else /* !Windows */ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # define PNGAPI _System # else /* !Windows/x86 && !OS/2 */ /* Use the defaults, or define PNG*API on the command line (but * this will have to be done for every compile!) */ # endif /* other system, !OS/2 */ #endif /* !Windows/x86 */ /* Now do all the defaulting . */ #ifndef PNGCAPI # define PNGCAPI #endif #ifndef PNGCBAPI # define PNGCBAPI PNGCAPI #endif #ifndef PNGAPI # define PNGAPI PNGCAPI #endif /* PNG_IMPEXP may be set on the compilation system command line or (if not set) * then in an internal header file when building the library, otherwise (when * using the library) it is set here. */ #ifndef PNG_IMPEXP # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) /* This forces use of a DLL, disallowing static linking */ # define PNG_IMPEXP PNG_DLL_IMPORT # endif # ifndef PNG_IMPEXP # define PNG_IMPEXP # endif #endif /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat * 'attributes' as a storage class - the attributes go at the start of the * function definition, and attributes are always appended regardless of the * compiler. This considerably simplifies these macros but may cause problems * if any compilers both need function attributes and fail to handle them as * a storage class (this is unlikely.) */ #ifndef PNG_FUNCTION # define PNG_FUNCTION(type, name, args, attributes) attributes type name args #endif #ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type #endif /* The ordinal value is only relevant when preprocessing png.h for symbol * table entries, so we discard it here. See the .dfn files in the * scripts directory. */ #ifndef PNG_EXPORTA # define PNG_EXPORTA(ordinal, type, name, args, attributes)\ PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ extern attributes) #endif /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, * so make something non-empty to satisfy the requirement: */ #define PNG_EMPTY /*empty list*/ #define PNG_EXPORT(ordinal, type, name, args)\ PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) /* Use PNG_REMOVED to comment out a removed interface. */ #ifndef PNG_REMOVED # define PNG_REMOVED(ordinal, type, name, args, attributes) #endif #ifndef PNG_CALLBACK # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) #endif /* Support for compiler specific function attributes. These are used * so that where compiler support is available incorrect use of API * functions in png.h will generate compiler warnings. * * Added at libpng-1.2.41. */ #ifndef PNG_NO_PEDANTIC_WARNINGS # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED # define PNG_PEDANTIC_WARNINGS_SUPPORTED # endif #endif #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED /* Support for compiler specific function attributes. These are used * so that where compiler support is available, incorrect use of API * functions in png.h will generate compiler warnings. Added at libpng * version 1.2.41. Disabling these removes the warnings but may also produce * less efficient code. */ # if defined(__GNUC__) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif # ifndef PNG_NORETURN # define PNG_NORETURN __attribute__((__noreturn__)) # endif # if __GNUC__ >= 3 # ifndef PNG_ALLOCATED # define PNG_ALLOCATED __attribute__((__malloc__)) # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __attribute__((__deprecated__)) # endif # ifndef PNG_PRIVATE # if 0 /* Doesn't work so we use deprecated instead*/ # define PNG_PRIVATE \ __attribute__((warning("This function is not exported by libpng."))) # else # define PNG_PRIVATE \ __attribute__((__deprecated__)) # endif # endif # if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* __GNUC__ == 3.0 */ # endif /* __GNUC__ >= 3 */ # elif defined(_MSC_VER) && (_MSC_VER >= 1300) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* not supported */ # endif # ifndef PNG_NORETURN # define PNG_NORETURN __declspec(noreturn) # endif # ifndef PNG_ALLOCATED # if (_MSC_VER >= 1400) # define PNG_ALLOCATED __declspec(restrict) # endif # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __declspec(deprecated) # endif # ifndef PNG_PRIVATE # define PNG_PRIVATE __declspec(deprecated) # endif # ifndef PNG_RESTRICT # if (_MSC_VER >= 1400) # define PNG_RESTRICT __restrict # endif # endif # elif defined(__WATCOMC__) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* _MSC_VER */ #endif /* PNG_PEDANTIC_WARNINGS */ #ifndef PNG_DEPRECATED # define PNG_DEPRECATED /* Use of this function is deprecated */ #endif #ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* The result of this function must be checked */ #endif #ifndef PNG_NORETURN # define PNG_NORETURN /* This function does not return */ #endif #ifndef PNG_ALLOCATED # define PNG_ALLOCATED /* The result of the function is new memory */ #endif #ifndef PNG_PRIVATE # define PNG_PRIVATE /* This is a private libpng function */ #endif #ifndef PNG_RESTRICT # define PNG_RESTRICT /* The C99 "restrict" feature */ #endif #ifndef PNG_FP_EXPORT /* A floating point API. */ # ifdef PNG_FLOATING_POINT_SUPPORTED # define PNG_FP_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No floating point APIs */ # define PNG_FP_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_FIXED_EXPORT /* A fixed point API. */ # ifdef PNG_FIXED_POINT_SUPPORTED # define PNG_FIXED_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No fixed point APIs */ # define PNG_FIXED_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* Some typedefs to get us started. These should be safe on most of the common * platforms. * * png_uint_32 and png_int_32 may, currently, be larger than required to hold a * 32-bit value however this is not normally advisable. * * png_uint_16 and png_int_16 should always be two bytes in size - this is * verified at library build time. * * png_byte must always be one byte in size. * * The checks below use constants from limits.h, as defined by the ISOC90 * standard. */ #if CHAR_BIT == 8 && UCHAR_MAX == 255 typedef unsigned char png_byte; #else # error "libpng requires 8 bit bytes" #endif #if INT_MIN == -32768 && INT_MAX == 32767 typedef int png_int_16; #elif SHRT_MIN == -32768 && SHRT_MAX == 32767 typedef short png_int_16; #else # error "libpng requires a signed 16 bit type" #endif #if UINT_MAX == 65535 typedef unsigned int png_uint_16; #elif USHRT_MAX == 65535 typedef unsigned short png_uint_16; #else # error "libpng requires an unsigned 16 bit type" #endif #if INT_MIN < -2147483646 && INT_MAX > 2147483646 typedef int png_int_32; #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 typedef long int png_int_32; #else # error "libpng requires a signed 32 bit (or more) type" #endif #if UINT_MAX > 4294967294 typedef unsigned int png_uint_32; #elif ULONG_MAX > 4294967294 typedef unsigned long int png_uint_32; #else # error "libpng requires an unsigned 32 bit (or more) type" #endif /* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, * requires an ISOC90 compiler and relies on consistent behavior of sizeof. */ typedef size_t png_size_t; typedef ptrdiff_t png_ptrdiff_t; /* libpng needs to know the maximum value of 'size_t' and this controls the * definition of png_alloc_size_t, below. This maximum value of size_t limits * but does not control the maximum allocations the library makes - there is * direct application control of this through png_set_user_limits(). */ #ifndef PNG_SMALL_SIZE_T /* Compiler specific tests for systems where size_t is known to be less than * 32 bits (some of these systems may no longer work because of the lack of * 'far' support; see above.) */ # if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ (defined(_MSC_VER) && defined(MAXSEG_64K)) # define PNG_SMALL_SIZE_T # endif #endif /* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to * png_alloc_size_t are not necessary; in fact, it is recommended not to use * them at all so that the compiler can complain when something turns out to be * problematic. * * Casts in the other direction (from png_alloc_size_t to png_size_t or * png_uint_32) should be explicitly applied; however, we do not expect to * encounter practical situations that require such conversions. * * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than * 4294967295 - i.e. less than the maximum value of png_uint_32. */ #ifdef PNG_SMALL_SIZE_T typedef png_uint_32 png_alloc_size_t; #else typedef png_size_t png_alloc_size_t; #endif /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler * implementations of Intel CPU specific support of user-mode segmented address * spaces, where 16-bit pointers address more than 65536 bytes of memory using * separate 'segment' registers. The implementation requires two different * types of pointer (only one of which includes the segment value.) * * If required this support is available in version 1.2 of libpng and may be * available in versions through 1.5, although the correctness of the code has * not been verified recently. */ /* Typedef for floating-point numbers that are converted to fixed-point with a * multiple of 100,000, e.g., gamma */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ typedef void * png_voidp; typedef const void * png_const_voidp; typedef png_byte * png_bytep; typedef const png_byte * png_const_bytep; typedef png_uint_32 * png_uint_32p; typedef const png_uint_32 * png_const_uint_32p; typedef png_int_32 * png_int_32p; typedef const png_int_32 * png_const_int_32p; typedef png_uint_16 * png_uint_16p; typedef const png_uint_16 * png_const_uint_16p; typedef png_int_16 * png_int_16p; typedef const png_int_16 * png_const_int_16p; typedef char * png_charp; typedef const char * png_const_charp; typedef png_fixed_point * png_fixed_point_p; typedef const png_fixed_point * png_const_fixed_point_p; typedef png_size_t * png_size_tp; typedef const png_size_t * png_const_size_tp; #ifdef PNG_STDIO_SUPPORTED typedef FILE * png_FILE_p; #endif #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * png_doublep; typedef const double * png_const_doublep; #endif /* Pointers to pointers; i.e. arrays */ typedef png_byte * * png_bytepp; typedef png_uint_32 * * png_uint_32pp; typedef png_int_32 * * png_int_32pp; typedef png_uint_16 * * png_uint_16pp; typedef png_int_16 * * png_int_16pp; typedef const char * * png_const_charpp; typedef char * * png_charpp; typedef png_fixed_point * * png_fixed_point_pp; #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * * png_doublepp; #endif /* Pointers to pointers to pointers; i.e., pointer to array */ typedef char * * * png_charppp; #endif /* PNG_BUILDING_SYMBOL_TABLE */ #endif /* PNGCONF_H */ ================================================ FILE: cocos2d/external/png/include/win32/pnglibconf.h ================================================ /* libpng 1.6.2 STANDARD API DEFINITION */ /* pnglibconf.h - library build configuration */ /* Libpng version 1.6.2 - April 25, 2013 */ /* Copyright (c) 1998-2013 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ /* For conditions of distribution and use, see the disclaimer */ /* and license in png.h */ /* pnglibconf.h */ /* Machine generated file: DO NOT EDIT */ /* Derived from: scripts/pnglibconf.dfa */ #ifndef PNGLCONF_H #define PNGLCONF_H /* options */ #define PNG_16BIT_SUPPORTED #define PNG_ALIGNED_MEMORY_SUPPORTED /*#undef PNG_ARM_NEON_API_SUPPORTED*/ /*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ /*#undef PNG_ARM_NEON_SUPPORTED*/ #define PNG_BENIGN_ERRORS_SUPPORTED #define PNG_BENIGN_READ_ERRORS_SUPPORTED /*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_COLORSPACE_SUPPORTED #define PNG_CONSOLE_IO_SUPPORTED #define PNG_CONVERT_tIME_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ #define PNG_ERROR_TEXT_SUPPORTED #define PNG_FIXED_POINT_SUPPORTED #define PNG_FLOATING_ARITHMETIC_SUPPORTED #define PNG_FLOATING_POINT_SUPPORTED #define PNG_FORMAT_AFIRST_SUPPORTED #define PNG_FORMAT_BGR_SUPPORTED #define PNG_GAMMA_SUPPORTED #define PNG_GET_PALETTE_MAX_SUPPORTED #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED #define PNG_INCH_CONVERSIONS_SUPPORTED #define PNG_INFO_IMAGE_SUPPORTED #define PNG_IO_STATE_SUPPORTED #define PNG_MNG_FEATURES_SUPPORTED #define PNG_POINTER_INDEXING_SUPPORTED #define PNG_PROGRESSIVE_READ_SUPPORTED #define PNG_READ_16BIT_SUPPORTED #define PNG_READ_ALPHA_MODE_SUPPORTED #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED #define PNG_READ_BACKGROUND_SUPPORTED #define PNG_READ_BGR_SUPPORTED #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_READ_COMPOSITE_NODIV_SUPPORTED #define PNG_READ_COMPRESSED_TEXT_SUPPORTED #define PNG_READ_EXPAND_16_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_FILLER_SUPPORTED #define PNG_READ_GAMMA_SUPPORTED #define PNG_READ_GET_PALETTE_MAX_SUPPORTED #define PNG_READ_GRAY_TO_RGB_SUPPORTED #define PNG_READ_INTERLACING_SUPPORTED #define PNG_READ_INT_FUNCTIONS_SUPPORTED #define PNG_READ_INVERT_ALPHA_SUPPORTED #define PNG_READ_INVERT_SUPPORTED #define PNG_READ_OPT_PLTE_SUPPORTED #define PNG_READ_PACKSWAP_SUPPORTED #define PNG_READ_PACK_SUPPORTED #define PNG_READ_QUANTIZE_SUPPORTED #define PNG_READ_RGB_TO_GRAY_SUPPORTED #define PNG_READ_SCALE_16_TO_8_SUPPORTED #define PNG_READ_SHIFT_SUPPORTED #define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED #define PNG_READ_SUPPORTED #define PNG_READ_SWAP_ALPHA_SUPPORTED #define PNG_READ_SWAP_SUPPORTED #define PNG_READ_TEXT_SUPPORTED #define PNG_READ_TRANSFORMS_SUPPORTED #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED #define PNG_READ_USER_CHUNKS_SUPPORTED #define PNG_READ_USER_TRANSFORM_SUPPORTED #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED #define PNG_READ_gAMA_SUPPORTED #define PNG_READ_hIST_SUPPORTED #define PNG_READ_iCCP_SUPPORTED #define PNG_READ_iTXt_SUPPORTED #define PNG_READ_oFFs_SUPPORTED #define PNG_READ_pCAL_SUPPORTED #define PNG_READ_pHYs_SUPPORTED #define PNG_READ_sBIT_SUPPORTED #define PNG_READ_sCAL_SUPPORTED #define PNG_READ_sPLT_SUPPORTED #define PNG_READ_sRGB_SUPPORTED #define PNG_READ_tEXt_SUPPORTED #define PNG_READ_tIME_SUPPORTED #define PNG_READ_tRNS_SUPPORTED #define PNG_READ_zTXt_SUPPORTED /*#undef PNG_SAFE_LIMITS_SUPPORTED*/ #define PNG_SAVE_INT_32_SUPPORTED #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SEQUENTIAL_READ_SUPPORTED #define PNG_SETJMP_SUPPORTED #define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED #define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED /*#undef PNG_SET_OPTION_SUPPORTED*/ #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SET_USER_LIMITS_SUPPORTED #define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_READ_BGR_SUPPORTED #define PNG_SIMPLIFIED_READ_SUPPORTED #define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED #define PNG_SIMPLIFIED_WRITE_SUPPORTED #define PNG_STDIO_SUPPORTED #define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_TEXT_SUPPORTED #define PNG_TIME_RFC1123_SUPPORTED #define PNG_UNKNOWN_CHUNKS_SUPPORTED #define PNG_USER_CHUNKS_SUPPORTED #define PNG_USER_LIMITS_SUPPORTED #define PNG_USER_MEM_SUPPORTED #define PNG_USER_TRANSFORM_INFO_SUPPORTED #define PNG_USER_TRANSFORM_PTR_SUPPORTED #define PNG_WARNINGS_SUPPORTED #define PNG_WRITE_16BIT_SUPPORTED #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #define PNG_WRITE_BGR_SUPPORTED #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED #define PNG_WRITE_FILLER_SUPPORTED #define PNG_WRITE_FILTER_SUPPORTED #define PNG_WRITE_FLUSH_SUPPORTED #define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED #define PNG_WRITE_INTERLACING_SUPPORTED #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED #define PNG_WRITE_INVERT_ALPHA_SUPPORTED #define PNG_WRITE_INVERT_SUPPORTED #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED #define PNG_WRITE_PACKSWAP_SUPPORTED #define PNG_WRITE_PACK_SUPPORTED #define PNG_WRITE_SHIFT_SUPPORTED #define PNG_WRITE_SUPPORTED #define PNG_WRITE_SWAP_ALPHA_SUPPORTED #define PNG_WRITE_SWAP_SUPPORTED #define PNG_WRITE_TEXT_SUPPORTED #define PNG_WRITE_TRANSFORMS_SUPPORTED #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_WRITE_USER_TRANSFORM_SUPPORTED #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #define PNG_WRITE_bKGD_SUPPORTED #define PNG_WRITE_cHRM_SUPPORTED #define PNG_WRITE_gAMA_SUPPORTED #define PNG_WRITE_hIST_SUPPORTED #define PNG_WRITE_iCCP_SUPPORTED #define PNG_WRITE_iTXt_SUPPORTED #define PNG_WRITE_oFFs_SUPPORTED #define PNG_WRITE_pCAL_SUPPORTED #define PNG_WRITE_pHYs_SUPPORTED #define PNG_WRITE_sBIT_SUPPORTED #define PNG_WRITE_sCAL_SUPPORTED #define PNG_WRITE_sPLT_SUPPORTED #define PNG_WRITE_sRGB_SUPPORTED #define PNG_WRITE_tEXt_SUPPORTED #define PNG_WRITE_tIME_SUPPORTED #define PNG_WRITE_tRNS_SUPPORTED #define PNG_WRITE_zTXt_SUPPORTED #define PNG_bKGD_SUPPORTED #define PNG_cHRM_SUPPORTED #define PNG_gAMA_SUPPORTED #define PNG_hIST_SUPPORTED #define PNG_iCCP_SUPPORTED #define PNG_iTXt_SUPPORTED #define PNG_oFFs_SUPPORTED #define PNG_pCAL_SUPPORTED #define PNG_pHYs_SUPPORTED #define PNG_sBIT_SUPPORTED #define PNG_sCAL_SUPPORTED #define PNG_sPLT_SUPPORTED #define PNG_sRGB_SUPPORTED #define PNG_tEXt_SUPPORTED #define PNG_tIME_SUPPORTED #define PNG_tRNS_SUPPORTED #define PNG_zTXt_SUPPORTED /* end of options */ /* settings */ #define PNG_API_RULE 0 #define PNG_CALLOC_SUPPORTED #define PNG_COST_SHIFT 3 #define PNG_DEFAULT_READ_MACROS 1 #define PNG_GAMMA_THRESHOLD_FIXED 5000 #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE #define PNG_INFLATE_BUF_SIZE 1024 #define PNG_MAX_GAMMA_8 11 #define PNG_QUANTIZE_BLUE_BITS 5 #define PNG_QUANTIZE_GREEN_BITS 5 #define PNG_QUANTIZE_RED_BITS 5 #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 #define PNG_WEIGHT_SHIFT 8 #define PNG_ZBUF_SIZE 8192 #define PNG_Z_DEFAULT_COMPRESSION (-1) #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 #define PNG_Z_DEFAULT_STRATEGY 1 #define PNG_sCAL_PRECISION 5 #define PNG_sRGB_PROFILE_CHECKS 2 /* end of settings */ #endif /* PNGLCONF_H */ ================================================ FILE: cocos2d/external/png/prebuilt/android/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos_png_static LOCAL_MODULE_FILENAME := png LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libpng.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android include $(PREBUILT_STATIC_LIBRARY) ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/Anchor.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/CallArgs.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 "mozilla/TypeTraits.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); /* Typedef for native functions that may be called in parallel. */ typedef js::ParallelResult (* JSParallelNative)(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp); /* * Typedef for native functions that may be called either in parallel or * sequential execution. */ typedef JSBool (* JSThreadSafeNative)(js::ThreadSafeContext *cx, unsigned argc, JS::Value *vp); /* * Convenience wrappers for passing in ThreadSafeNative to places that expect * a JSNative or a JSParallelNative. */ template inline JSBool JSNativeThreadSafeWrapper(JSContext *cx, unsigned argc, JS::Value *vp); template inline js::ParallelResult JSParallelNativeThreadSafeWrapper(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp); /* * 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); namespace JS { extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; /* * 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.rval().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. */ namespace detail { #ifdef DEBUG extern JS_PUBLIC_API(void) CheckIsValidConstructible(Value v); #endif enum UsedRval { IncludeUsedRval, NoUsedRval }; template class MOZ_STACK_CLASS UsedRvalBase; template<> class MOZ_STACK_CLASS UsedRvalBase { protected: mutable bool usedRval_; void setUsedRval() const { usedRval_ = true; } void clearUsedRval() const { usedRval_ = false; } }; template<> class MOZ_STACK_CLASS UsedRvalBase { protected: void setUsedRval() const {} void clearUsedRval() const {} }; template class MOZ_STACK_CLASS CallReceiverBase : public UsedRvalBase< #ifdef DEBUG WantUsedRval #else NoUsedRval #endif > { protected: 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(!this->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(!this->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]); } Value computeThis(JSContext *cx) const { if (thisv().isObject()) return thisv(); return JS_ComputeThis(cx, base()); } bool isConstructing() const { #ifdef DEBUG if (this->usedRval_) CheckIsValidConstructible(calleev()); #endif return argv_[-1].isMagic(); } /* * 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 { this->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 { this->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 { this->clearUsedRval(); argv_[-2] = aCalleev; } void setThis(Value aThisv) const { argv_[-1] = aThisv; } MutableHandleValue mutableThisv() const { return MutableHandleValue::fromMarkedLocation(&argv_[-1]); } }; } // namespace detail class MOZ_STACK_CLASS CallReceiver : public detail::CallReceiverBase { private: friend CallReceiver CallReceiverFromVp(Value *vp); friend CallReceiver CallReceiverFromArgv(Value *argv); }; 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. */ namespace detail { template class MOZ_STACK_CLASS CallArgsBase : public mozilla::Conditional >::Type { protected: unsigned argc_; public: /* Returns the number of arguments. */ unsigned length() const { return argc_; } /* Returns the i-th zero-indexed argument. */ MutableHandleValue operator[](unsigned i) const { MOZ_ASSERT(i < argc_); return MutableHandleValue::fromMarkedLocation(&this->argv_[i]); } /* * Returns the i-th zero-indexed argument, or |undefined| if there's no * such argument. */ HandleValue get(unsigned i) const { return i < length() ? HandleValue::fromMarkedLocation(&this->argv_[i]) : UndefinedHandleValue; } /* * Returns true if the i-th zero-indexed argument is present and is not * |undefined|. */ bool hasDefined(unsigned i) const { return i < argc_ && !this->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 this->argv_; } Value *end() const { return this->argv_ + argc_; } }; } // namespace detail class MOZ_STACK_CLASS CallArgs : public detail::CallArgsBase { private: 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; } }; 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 /* * 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/CharacterEncoding.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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()); } }; class UTF8Chars : public mozilla::Range { typedef mozilla::Range Base; public: UTF8Chars() : Base() {} UTF8Chars(char *aBytes, size_t aLength) : Base(reinterpret_cast(aBytes), aLength) {} UTF8Chars(const char *aBytes, size_t aLength) : Base(reinterpret_cast(const_cast(aBytes)), aLength) {} }; /* * 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() : Base(NULL, 0) {} 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(js::ThreadSafeContext *cx, TwoByteChars tbchars); extern UTF8CharsZ TwoByteCharsToNewUTF8CharsZ(js::ThreadSafeContext *cx, TwoByteChars tbchars); uint32_t Utf8ToOneUcs4Char(const uint8_t *utf8Buffer, int utf8Length); /* * Inflate bytes in UTF-8 encoding to jschars. * - On error, returns an empty TwoByteCharsZ. * - On success, returns a malloc'd TwoByteCharsZ, and updates |outlen| to hold * its length; the length value excludes the trailing null. */ extern TwoByteCharsZ UTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen); /* * The same as UTF8CharsToNewTwoByteCharsZ(), except that any malformed UTF-8 characters * will be replaced by \uFFFD. No exception will be thrown for malformed UTF-8 * input. */ extern TwoByteCharsZ LossyUTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen); } // 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/Date.h ================================================ /* -*- 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_Date_h #define js_Date_h #include "jstypes.h" namespace JS { // Year is a year, month is 0-11, day is 1-based. The return value is // a number of milliseconds since the epoch. Can return NaN. JS_PUBLIC_API(double) MakeDate(double year, unsigned month, unsigned day); // Takes an integer number of milliseconds since the epoch and returns the // year. Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) YearFromTime(double time); // Takes an integer number of milliseconds since the epoch and returns the // month (0-11). Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) MonthFromTime(double time); // Takes an integer number of milliseconds since the epoch and returns the // day (1-based). Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) DayFromTime(double time); } // namespace JS #endif /* js_Date_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/GCAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_GCAPI_h #define js_GCAPI_h #include "js/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) \ D(OUT_OF_NURSERY) \ D(EVICT_NURSERY) \ D(FULL_STORE_BUFFER) \ \ /* These are reserved for future use. */ \ D(RESERVED0) \ D(RESERVED1) \ D(RESERVED2) \ D(RESERVED3) \ D(RESERVED4) \ D(RESERVED5) \ D(RESERVED6) \ D(RESERVED7) \ D(RESERVED8) \ D(RESERVED9) \ D(RESERVED10) \ D(RESERVED11) \ D(RESERVED12) \ D(RESERVED13) \ D(RESERVED14) \ D(RESERVED15) \ D(RESERVED16) \ D(RESERVED17) \ D(RESERVED18) \ D(RESERVED19) \ \ /* 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(void) EnableGenerationalGC(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 { Heap 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; } void trace(JSTracer *trc, const char *name) { JS_CallHeapObjectTracer(trc, &value, name); } 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); shadow::Runtime *rt = js::gc::GetGCThingRuntime(thing); #ifdef JSGC_GENERATIONAL /* * GC things residing in the nursery cannot be gray: they have no mark bits. * All live objects in the nursery are moved to tenured at the beginning of * each GC slice, so the gray marker never sees nursery things. */ if (uintptr_t(thing) >= rt->gcNurseryStart_ && uintptr_t(thing) < rt->gcNurseryEnd_) return; #endif if (IsIncrementalBarrierNeededOnGCThing(rt, thing, kind)) IncrementalReferenceBarrier(thing, kind); else if (GCThingIsMarkedGray(thing)) UnmarkGrayGCThingRecursively(thing, kind); } static JS_ALWAYS_INLINE void ExposeValueToActiveJS(const Value &v) { if (v.isMarkable()) ExposeGCThingToActiveJS(v.toGCThing(), v.gcKind()); } } /* namespace JS */ #endif /* js_GCAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/HashTable.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_HashTable_h #define js_HashTable_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Casting.h" #include "mozilla/DebugOnly.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/PodOperations.h" #include "mozilla/ReentrancyGuard.h" #include "mozilla/TemplateLib.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.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) {} 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, mozilla::Move(e)); } bool add(AddPtr &p, const Key &k) { Entry e(k, Value()); return impl.add(p, mozilla::Move(e)); } template bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { Entry e(k, v); return impl.relookupOrAdd(p, k, mozilla::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(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf 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, mozilla::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); } // Infallibly rekey one entry, if present. void rekey(const Lookup &old_key, const Key &new_key) { if (old_key != new_key) { if (Ptr p = lookup(old_key)) impl.rekey(p, new_key, new_key); } } // HashMap is movable HashMap(mozilla::MoveRef rhs) : impl(mozilla::Move(rhs->impl)) {} void operator=(mozilla::MoveRef rhs) { impl = mozilla::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) {} 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(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf 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); } // Infallibly rekey one entry, if present. void rekey(const Lookup &old_key, const T &new_key) { if (old_key != new_key) { if (Ptr p = lookup(old_key)) impl.rekey(p, new_key, new_key); } } // HashSet is movable HashSet(mozilla::MoveRef rhs) : impl(mozilla::Move(rhs->impl)) {} void operator=(mozilla::MoveRef rhs) { impl = mozilla::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::value> {}; // 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); uint64_t u = mozilla::BitwiseCast(d); return HashNumber(u ^ (u >> 32)); } static bool match(double lhs, double rhs) { return mozilla::BitwiseCast(lhs) == mozilla::BitwiseCast(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(mozilla::MoveRef rhs) : key(mozilla::Move(rhs->key)), value(mozilla::Move(rhs->value)) { } typedef Key KeyType; typedef Value ValueType; 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 mozilla::RemoveConst::Type 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) { mozilla::Swap(keyHash, other->keyHash); mozilla::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; } 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 mozilla::RemoveConst::Type 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) { table.rekey(*this->cur, l, k); 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(mozilla::MoveRef rhs) : AllocPolicy(*rhs) { mozilla::PodAssign(this, &*rhs); rhs->table = NULL; } void operator=(mozilla::MoveRef rhs) { if (table) destroyTable(*this, table, capacity()); mozilla::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 mozilla::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 = mozilla::tl::BitSize::value; 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, mozilla::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 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(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(table); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } Ptr lookup(const Lookup &l) const { mozilla::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 { mozilla::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) { mozilla::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; { mozilla::ReentrancyGuard g(*this); p.entry_ = &lookup(l, p.keyHash, sCollisionBit); } return p.found() || add(p, u); } void remove(Ptr p) { JS_ASSERT(table); mozilla::ReentrancyGuard g(*this); JS_ASSERT(p.found()); remove(*p.entry_); checkUnderloaded(); } void rekey(Ptr p, const Lookup &l, const Key &k) { JS_ASSERT(table); mozilla::ReentrancyGuard g(*this); JS_ASSERT(p.found()); typename HashTableEntry::NonConstT t(mozilla::Move(*p)); HashPolicy::setKey(t, const_cast(k)); remove(*p.entry_); putNewInfallible(l, mozilla::Move(t)); } #undef METER }; } // namespace detail } // namespace js #endif /* js_HashTable_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/HeapAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_HeapAPI_h #define js_HeapAPI_h #include "jspubtd.h" #include "js/Utility.h" /* These values are private to the JS engine. */ namespace js { namespace gc { const size_t ArenaShift = 12; 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; const size_t ChunkRuntimeOffset = ChunkSize - sizeof(void*); /* * 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 JS::shadow::Runtime * GetGCThingRuntime(const void *thing) { uintptr_t addr = uintptr_t(thing); addr &= ~js::gc::ChunkMask; addr |= js::gc::ChunkRuntimeOffset; 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(shadow::Runtime *rt, void *thing, JSGCTraceKind kind) { if (!rt->needsBarrier_) return false; JS::Zone *zone = GetGCThingZone(thing); return reinterpret_cast(zone)->needsBarrier_; } } /* namespace JS */ #endif /* js_HeapAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/LegacyIntTypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 types. */ #ifndef js_LegacyIntTypes_h #define js_LegacyIntTypes_h #include #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 /* js_LegacyIntTypes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/MemoryMetrics.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 "mozilla/MemoryReporting.h" #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 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 interpreterStack; size_t gcMarker; size_t mathCache; size_t scriptData; size_t scriptSources; CodeSizes code; }; struct ZoneStats { ZoneStats() : extra(NULL), gcHeapArenaAdmin(0), gcHeapUnusedGcThings(0), gcHeapStringsNormal(0), gcHeapStringsShort(0), gcHeapLazyScripts(0), gcHeapTypeObjects(0), gcHeapIonCodes(0), stringCharsNonHuge(0), lazyScripts(0), typeObjects(0), typePool(0), hugeStrings() {} ZoneStats(const ZoneStats &other) : extra(other.extra), gcHeapArenaAdmin(other.gcHeapArenaAdmin), gcHeapUnusedGcThings(other.gcHeapUnusedGcThings), gcHeapStringsNormal(other.gcHeapStringsNormal), gcHeapStringsShort(other.gcHeapStringsShort), gcHeapLazyScripts(other.gcHeapLazyScripts), gcHeapTypeObjects(other.gcHeapTypeObjects), gcHeapIonCodes(other.gcHeapIonCodes), stringCharsNonHuge(other.stringCharsNonHuge), lazyScripts(other.lazyScripts), typeObjects(other.typeObjects), typePool(other.typePool), hugeStrings() { hugeStrings.appendAll(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(gcHeapLazyScripts); ADD(gcHeapTypeObjects); ADD(gcHeapIonCodes); ADD(stringCharsNonHuge); ADD(lazyScripts); ADD(typeObjects); ADD(typePool); #undef ADD hugeStrings.appendAll(other.hugeStrings); } // This field can be used by embedders. void *extra; size_t gcHeapArenaAdmin; size_t gcHeapUnusedGcThings; size_t gcHeapStringsNormal; size_t gcHeapStringsShort; size_t gcHeapLazyScripts; size_t gcHeapTypeObjects; size_t gcHeapIonCodes; size_t stringCharsNonHuge; size_t lazyScripts; 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() : extra(NULL), 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), baselineData(0), baselineStubsFallback(0), baselineStubsOptimized(0), ionData(0), compartmentObject(0), crossCompartmentWrappersTable(0), regexpCompartment(0), debuggeesSet(0), typeInference() {} CompartmentStats(const CompartmentStats &other) : extra(other.extra), 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), baselineData(other.baselineData), baselineStubsFallback(other.baselineStubsFallback), baselineStubsOptimized(other.baselineStubsOptimized), ionData(other.ionData), compartmentObject(other.compartmentObject), crossCompartmentWrappersTable(other.crossCompartmentWrappersTable), regexpCompartment(other.regexpCompartment), debuggeesSet(other.debuggeesSet), typeInference(other.typeInference) { } // This field can be used by embedders. void *extra; // 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 baselineData; size_t baselineStubsFallback; size_t baselineStubsOptimized; 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(baselineData); ADD(baselineStubsFallback); ADD(baselineStubsOptimized); 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(mozilla::MallocSizeOf 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; mozilla::MallocSizeOf 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(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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/PropertyKey.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/RequiredDefines.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/RootingAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_RootingAPI_h #define js_RootingAPI_h #include "mozilla/GuardObjects.h" #include "mozilla/TypeTraits.h" #include "js/Utility.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 |Rooted| 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 three 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. * * - 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 (measured to * be a few nanoseconds on desktop) 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. * * The following diagram explains the list of supported, implicit type * conversions between classes of this family: * * Rooted ----> Handle * | ^ * | | * | | * +---> MutableHandle * (via &) * * All of these types have an implicit conversion to raw pointers. */ namespace js { class Module; class ScriptSourceObject; template struct GCMethods {}; template class RootedBase {}; template class HandleBase {}; template class MutableHandleBase {}; template class HeapBase {}; /* * 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 gc { struct Cell; } /* namespace gc */ } /* 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; }; /* * The Heap class is a C/C++ heap-stored reference to a JS GC thing. All * members of heap classes that refer to GC thing should use Heap (or * possibly TenuredHeap, described below). * * Heap wraps the complex mechanisms required to ensure GC safety for the * contained reference into a C++ class that behaves similarly to a normal * pointer. * * GC references stored on the C/C++ stack must use Rooted/Handle/MutableHandle * instead. * * Requirements for type T: * - Must be one of: Value, jsid, JSObject*, JSString*, JSScript* */ template class Heap : public js::HeapBase { public: Heap() { static_assert(sizeof(T) == sizeof(Heap), "Heap must be binary compatible with T."); init(js::GCMethods::initial()); } explicit Heap(T p) { init(p); } explicit Heap(const Heap &p) { init(p.ptr); } ~Heap() { if (js::GCMethods::needsPostBarrier(ptr)) relocate(); } bool operator==(const Heap &other) { return ptr == other.ptr; } bool operator!=(const Heap &other) { return ptr != other.ptr; } bool operator==(const T &other) const { return ptr == other; } bool operator!=(const T &other) const { return ptr != other; } operator T() const { return ptr; } T operator->() const { return ptr; } const T *address() const { return &ptr; } const T &get() const { return ptr; } T *unsafeGet() { return &ptr; } Heap &operator=(T p) { set(p); return *this; } void set(T newPtr) { JS_ASSERT(!js::GCMethods::poisoned(newPtr)); if (js::GCMethods::needsPostBarrier(newPtr)) { ptr = newPtr; post(); } else if (js::GCMethods::needsPostBarrier(ptr)) { relocate(); /* Called before overwriting ptr. */ ptr = newPtr; } else { ptr = newPtr; } } private: void init(T newPtr) { JS_ASSERT(!js::GCMethods::poisoned(newPtr)); ptr = newPtr; if (js::GCMethods::needsPostBarrier(ptr)) post(); } void post() { #ifdef JSGC_GENERATIONAL JS_ASSERT(js::GCMethods::needsPostBarrier(ptr)); js::GCMethods::postBarrier(&ptr); #endif } void relocate() { #ifdef JSGC_GENERATIONAL js::GCMethods::relocate(&ptr); #endif } T ptr; }; #ifdef DEBUG /* * For generational GC, assert that an object is in the tenured generation as * opposed to being in the nursery. */ extern JS_FRIEND_API(void) AssertGCThingMustBeTenured(JSObject* obj); #else inline void AssertGCThingMustBeTenured(JSObject *obj) {} #endif /* * The TenuredHeap class is similar to the Heap class above in that it * encapsulates the GC concerns of an on-heap reference to a JS object. However, * it has two important differences: * * 1) Pointers which are statically known to only reference "tenured" objects * can avoid the extra overhead of SpiderMonkey's write barriers. * * 2) Objects in the "tenured" heap have stronger alignment restrictions than * those in the "nursery", so it is possible to store flags in the lower * bits of pointers known to be tenured. TenuredHeap wraps a normal tagged * pointer with a nice API for accessing the flag bits and adds various * assertions to ensure that it is not mis-used. * * GC things are said to be "tenured" when they are located in the long-lived * heap: e.g. they have gained tenure as an object by surviving past at least * one GC. For performance, SpiderMonkey allocates some things which are known * to normally be long lived directly into the tenured generation; for example, * global objects. Additionally, SpiderMonkey does not visit individual objects * when deleting non-tenured objects, so object with finalizers are also always * tenured; for instance, this includes most DOM objects. * * The considerations to keep in mind when using a TenuredHeap vs a normal * Heap are: * * - It is invalid for a TenuredHeap to refer to a non-tenured thing. * - It is however valid for a Heap to refer to a tenured thing. * - It is not possible to store flag bits in a Heap. */ template class TenuredHeap : public js::HeapBase { public: TenuredHeap() : bits(0) { static_assert(sizeof(T) == sizeof(TenuredHeap), "TenuredHeap must be binary compatible with T."); } explicit TenuredHeap(T p) : bits(0) { setPtr(p); } explicit TenuredHeap(const TenuredHeap &p) : bits(0) { setPtr(p.ptr); } bool operator==(const TenuredHeap &other) { return bits == other.bits; } bool operator!=(const TenuredHeap &other) { return bits != other.bits; } void setPtr(T newPtr) { JS_ASSERT((reinterpret_cast(newPtr) & flagsMask) == 0); JS_ASSERT(!js::GCMethods::poisoned(newPtr)); if (newPtr) AssertGCThingMustBeTenured(newPtr); bits = (bits & flagsMask) | reinterpret_cast(newPtr); } void setFlags(uintptr_t flagsToSet) { JS_ASSERT((flagsToSet & ~flagsMask) == 0); bits |= flagsToSet; } void unsetFlags(uintptr_t flagsToUnset) { JS_ASSERT((flagsToUnset & ~flagsMask) == 0); bits &= ~flagsToUnset; } bool hasFlag(uintptr_t flag) const { JS_ASSERT((flag & ~flagsMask) == 0); return (bits & flag) != 0; } T getPtr() const { return reinterpret_cast(bits & ~flagsMask); } uintptr_t getFlags() const { return bits & flagsMask; } operator T() const { return getPtr(); } T operator->() const { return getPtr(); } TenuredHeap &operator=(T p) { setPtr(p); return *this; } /* * Set the pointer to a value which will cause a crash if it is * dereferenced. */ void setToCrashOnTouch() { bits = (bits & flagsMask) | crashOnTouchPointer; } bool isSetToCrashOnTouch() { return (bits & ~flagsMask) == crashOnTouchPointer; } private: enum { maskBits = 3, flagsMask = (1 << maskBits) - 1, crashOnTouchPointer = 1 << maskBits }; uintptr_t bits; }; /* * 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 MOZ_NONHEAP_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) { static_assert(sizeof(Handle) == sizeof(T *), "Handle must be binary compatible with T*."); ptr = reinterpret_cast(handle.address()); } /* Create a handle for a NULL pointer. */ Handle(js::NullPtr) { 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) { 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(); } /* * Take care when calling this method! * * This creates a Handle from the raw location of a T. * * It should be called only if the following conditions hold: * * 1) 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. * * 2) the contents of the location are immutable, or at least cannot change * for the lifetime of the handle, as its users may not expect its value * to change underneath them. */ 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(const 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; } const T& get() const { return *ptr; } /* * Return a reference so passing a Handle to something that * takes a |const T&| is not a GC hazard. */ operator const T&() const { return get(); } T operator->() const { return get(); } bool operator!=(const T &other) const { return *ptr != other; } bool operator==(const T &other) const { return *ptr == other; } private: Handle() {} const T *ptr; template void operator=(S v) MOZ_DELETE; }; typedef Handle HandleObject; typedef Handle HandleModule; typedef Handle HandleScriptSource; 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 MOZ_STACK_CLASS MutableHandle : public js::MutableHandleBase { public: inline MutableHandle(Rooted *root); void set(T v) { JS_ASSERT(!js::GCMethods::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; } const T& get() const { return *ptr; } /* * Return a reference so passing a MutableHandle to something that takes * a |const T&| is not a GC hazard. */ operator const T&() const { return get(); } T operator->() const { return get(); } private: MutableHandle() {} T *ptr; template void operator=(S v) MOZ_DELETE; void operator=(MutableHandle other) MOZ_DELETE; }; typedef MutableHandle MutableHandleObject; typedef MutableHandle MutableHandleFunction; typedef MutableHandle MutableHandleScript; typedef MutableHandle MutableHandleString; typedef MutableHandle MutableHandleId; typedef MutableHandle MutableHandleValue; #ifdef JSGC_GENERATIONAL JS_PUBLIC_API(void) HeapCellPostBarrier(js::gc::Cell **cellp); JS_PUBLIC_API(void) HeapCellRelocate(js::gc::Cell **cellp); #endif } /* namespace JS */ namespace js { /* * 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)) {} }; /* * 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 GCMethods { static T *initial() { return NULL; } static ThingRootKind kind() { return RootKind::rootKind(); } static bool poisoned(T *v) { return JS::IsPoisonedPtr(v); } static bool needsPostBarrier(T *v) { return v; } #ifdef JSGC_GENERATIONAL static void postBarrier(T **vp) { JS::HeapCellPostBarrier(reinterpret_cast(vp)); } static void relocate(T **vp) { JS::HeapCellRelocate(reinterpret_cast(vp)); } #endif }; // XXX: Needed for cocos2d JS Bindings //#if defined(DEBUG) /* This helper allows us to assert that Rooted is scoped within a request. */ extern JS_PUBLIC_API(bool) IsInRequest(JSContext *cx); //#endif } /* 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 MOZ_STACK_CLASS Rooted : public js::RootedBase { /* Note: CX is a subclass of either ContextFriendFields or PerThreadDataFriendFields. */ template void init(CX *cx) { #ifdef JSGC_TRACK_EXACT_ROOTS js::ThingRootKind kind = js::GCMethods::kind(); this->stack = &cx->thingGCRooters[kind]; this->prev = *stack; *stack = reinterpret_cast*>(this); JS_ASSERT(!js::GCMethods::poisoned(ptr)); #endif } public: Rooted(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_ASSERT(js::IsInRequest(cx)); init(js::ContextFriendFields::get(cx)); } Rooted(JSContext *cx, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_ASSERT(js::IsInRequest(cx)); init(js::ContextFriendFields::get(cx)); } Rooted(js::ContextFriendFields *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(cx); } Rooted(js::ContextFriendFields *cx, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(cx); } Rooted(js::PerThreadDataFriendFields *pt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(pt); } Rooted(js::PerThreadDataFriendFields *pt, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(pt); } Rooted(JSRuntime *rt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(js::PerThreadDataFriendFields::getMainThread(rt)); } Rooted(JSRuntime *rt, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(js::PerThreadDataFriendFields::getMainThread(rt)); } ~Rooted() { #ifdef JSGC_TRACK_EXACT_ROOTS JS_ASSERT(*stack == reinterpret_cast*>(this)); *stack = prev; #endif } #ifdef JSGC_TRACK_EXACT_ROOTS Rooted *previous() { return prev; } #endif /* * Important: Return a reference here so passing a Rooted to * something that takes a |const T&| is not a GC hazard. */ operator const 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::GCMethods::poisoned(value)); ptr = value; return ptr; } T &operator=(const Rooted &value) { ptr = value; return ptr; } void set(T value) { JS_ASSERT(!js::GCMethods::poisoned(value)); ptr = value; } bool operator!=(const T &other) const { return ptr != other; } bool operator==(const T &other) const { return ptr == other; } private: #ifdef JSGC_TRACK_EXACT_ROOTS 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*); #endif #ifdef JSGC_ROOT_ANALYSIS 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 RootedScriptSource; 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(CX *cx, const T *ptr, size_t count) { SkipRoot **head = &cx->skipGCRooters; this->stack = head; this->prev = *stack; *stack = this; this->start = (const uint8_t *) ptr; this->end = this->start + (sizeof(T) * count); } public: ~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 */ template void init(js::ContextFriendFields *cx, const T *ptr, size_t count) {} public: #endif /* DEBUG && JSGC_ROOT_ANALYSIS */ template SkipRoot(JSContext *cx, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(ContextFriendFields::get(cx), ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template SkipRoot(ContextFriendFields *cx, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(cx, ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template SkipRoot(PerThreadData *pt, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(PerThreadDataFriendFields::get(pt), ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* Interface substitute for Rooted which does not root the variable's memory. */ template class FakeRooted : public RootedBase { public: template FakeRooted(CX *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template FakeRooted(CX *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(!GCMethods::poisoned(value)); ptr = value; return ptr; } bool operator!=(const T &other) const { return ptr != other; } bool operator==(const T &other) const { 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::GCMethods::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) { MOZ_ASSUME_UNREACHABLE("Bad conversion"); } static inline JS::MutableHandle toMutableHandle(MutableHandleType v) { MOZ_ASSUME_UNREACHABLE("Bad conversion"); } }; } /* namespace js */ namespace JS { template template inline Handle::Handle(const 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) { static_assert(sizeof(MutableHandle) == sizeof(T *), "MutableHandle must be binary compatible with T*."); 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 } /* 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 */ #endif /* js_RootingAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/Utility.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_Utility_h #define js_Utility_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/Move.h" #include "mozilla/Scoped.h" #include "mozilla/TemplateLib.h" #include #include #ifdef JS_OOM_DO_BACKTRACES #include #include #endif #include "jstypes.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_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) 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 testing function * oomAfterAllocations COUNT is passed, we fail continuously after the NUM'th * allocation from now. */ extern JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations; /* set in builtins/TestingFunctions.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_calloc(size_t nmemb, size_t size) { JS_OOM_POSSIBLY_FAIL(); return calloc(nmemb, size); } 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_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 void js_delete_poison(T *p) { if (p) { p->~T(); memset(p, 0x3B, sizeof(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 & mozilla::tl::MulOverflowMask::value) return NULL; return (T *)js_malloc(numElems * sizeof(T)); } template static JS_ALWAYS_INLINE T * js_pod_calloc(size_t numElems) { if (numElems & mozilla::tl::MulOverflowMask::value) 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 { /* 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 } } /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/Value.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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(__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(__SUNPRO_CC) && !defined(__xlC__) */ 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(__SUNPRO_CC) && !defined(__xlC__) */ #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) /* 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 jsval_layout JSVAL_TO_IMPL(JS::Value v); static inline JS::Value IMPL_TO_JSVAL(jsval_layout l); namespace JS { /** * Returns a generic quiet NaN value, with all payload bits set to zero. * * Among other properties, this NaN's bit pattern conforms to JS::Value's * bit pattern restrictions. */ static MOZ_ALWAYS_INLINE double GenericNaN() { return mozilla::SpecificNaN(0, 0x8000000000000ULL); } static inline double CanonicalizeNaN(double d) { if (MOZ_UNLIKELY(mozilla::IsNaN(d))) return GenericNaN(); return d; } /* * 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 (mozilla::DoubleIsInt32(d, &i)) { setInt32(i); return true; } 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 /************************************************************************/ #ifdef JSGC_GENERATIONAL namespace JS { JS_PUBLIC_API(void) HeapValuePostBarrier(Value *valuep); JS_PUBLIC_API(void) HeapValueRelocate(Value *valuep); } #endif namespace js { template <> struct GCMethods { 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 GCMethods { 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); } static bool needsPostBarrier(const JS::Value &v) { return v.isMarkable(); } #ifdef JSGC_GENERATIONAL static void postBarrier(JS::Value *v) { JS::HeapValuePostBarrier(v); } static void relocate(JS::Value *v) { JS::HeapValueRelocate(v); } #endif }; template class UnbarrieredMutableValueOperations; 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 UnbarrieredMutableValueOperations; 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(); } uint32_t toPrivateUint32() const { return value()->toPrivateUint32(); } 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 that don't need post barriers. Outer must be * a class inheriting UnbarrieredMutableValueOperations with visible * extractMutable() and extract() methods returning the const Value* and Value* * abstracted by Outer. */ template class UnbarrieredMutableValueOperations : public ValueOperations { friend class MutableValueOperations; 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 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); } }; /* * A class designed for CRTP use in implementing all 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 UnbarrieredMutableValueOperations { public: void setString(JSString *str) { this->value()->setString(str); } void setString(const JS::Anchor &str) { this->value()->setString(str); } void setObject(JSObject &obj) { this->value()->setObject(obj); } void setObjectOrNull(JSObject *arg) { this->value()->setObjectOrNull(arg); } }; /* * Augment the generic Heap interface when T = Value with * type-querying, value-extracting, and mutating operations. */ template <> class HeapBase : public UnbarrieredMutableValueOperations > { typedef JS::Heap Outer; friend class ValueOperations; friend class UnbarrieredMutableValueOperations; const JS::Value * extract() const { return static_cast(this)->address(); } JS::Value * extractMutable() { return static_cast(this)->unsafeGet(); } /* * Setters that potentially change the value to a GC thing from a non-GC * thing must call JS::Heap::set() to trigger the post barrier. * * Changing from a GC thing to a non-GC thing value will leave the heap * value in the store buffer, but it will be ingored so this is not a * problem. */ void setBarriered(const JS::Value &v) { static_cast *>(this)->set(v); } public: void setString(JSString *str) { setBarriered(JS::StringValue(str)); } void setString(const JS::Anchor &str) { setBarriered(JS::StringValue(str.get())); } void setObject(JSObject &obj) { setBarriered(JS::ObjectValue(obj)); } void setObjectOrNull(JSObject *arg) { if (arg) setObject(*arg); else setNull(); } }; /* * 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 UnbarrieredMutableValueOperations >; 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 UnbarrieredMutableValueOperations >; 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; }; static_assert(sizeof(ValueAlignmentTester) == 16, "JS::Value must be 16-byte-aligned"); struct LayoutAlignmentTester { char c; jsval_layout l; }; 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; 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js/Vector.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_Vector_h #define js_Vector_h #include "mozilla/Vector.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; // If we had C++11 template aliases, we could just use this: // // template // using Vector = mozilla::Vector; // // ...and get rid of all the CRTP madness in mozilla::Vector(Base). But we // can't because compiler support's not up to snuff. (Template aliases are in // gcc 4.7 and clang 3.0 and are expected to be in MSVC 2013.) Instead, have a // completely separate class inheriting from mozilla::Vector, and throw CRTP at // the problem til things work. // // This workaround presents a couple issues. First, because js::Vector is a // distinct type from mozilla::Vector, overload resolution, method calls, etc. // are affected. *Hopefully* this won't be too bad in practice. (A bunch of // places had to be fixed when mozilla::Vector was introduced, but it wasn't a // crazy number.) Second, mozilla::Vector's interface has to be made subclass- // ready via CRTP -- or rather, via mozilla::VectorBase, which basically no one // should use. :-) Third, we have to redefine the constructors and the non- // inherited operators. Blech. Happily there aren't too many of these, so it // isn't the end of the world. template class Vector : public mozilla::VectorBase > { typedef typename mozilla::VectorBase Base; public: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} Vector(mozilla::MoveRef vec) : Base(vec) {} Vector &operator=(mozilla::MoveRef vec) { return Base::operator=(vec); } }; } // namespace js #endif /* js_Vector_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js-config.h ================================================ /* -*- 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. */ /* #undef JS_GC_ZEAL */ /* Define to 1 if the header is present and useable. See jscpucfg.h. */ #define JS_HAVE_ENDIAN_H 1 /* 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 */ /* The configure script defines these if it doesn't #define JS_HAVE_STDINT_H. */ #define JS_BYTES_PER_WORD 4 /* MOZILLA JSAPI version number components */ #define MOZJS_MAJOR_VERSION 25 #define MOZJS_MINOR_VERSION 0 #endif /* js_config_h___ */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/js.msg ================================================ /* -*- 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_MISSING_BINARY_DIGITS, 134, 0, JSEXN_SYNTAXERR, "missing binary digits after '0b'") 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_MISSING_OCTAL_DIGITS, 143, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'") 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_RESULTING_STRING_TOO_LARGE, 146, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size") 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_NEGATIVE_REPETITION_COUNT, 170, 0, JSEXN_RANGEERR, "repeat count must be non-negative") 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_BAD_STRICT_ASSIGN, 236, 1, JSEXN_SYNTAXERR, "can't assign to {0} in strict mode") 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_REDEFINE_ARRAY_LENGTH,242, 0, JSEXN_TYPEERR, "can't redefine array length") MSG_DEF(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH,243, 0, JSEXN_TYPEERR, "can't define array index property past the end of an array with non-writable length") 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_DEBUG_CANT_DEBUG_GLOBAL, 263, 0, JSEXN_ERR, "passing non-debuggable global to addDebuggee") 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_DEBUG_RESUMPTION_VALUE_DISALLOWED, 266, 0, JSEXN_TYPEERR, "resumption values are disallowed in this hook") 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_YIELD_WITHOUT_OPERAND, 272, 0, JSEXN_SYNTAXERR, "yield without a value is deprecated, and illegal in ES6 (use 'yield undefined' instead)") 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\" is only meaningful in the Directive Prologue of a function body") 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, 1, JSEXN_ERR, "successfully compiled asm.js code ({0})") 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") MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME,349, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups") MSG_DEF(JSMSG_DEPRECATED_SOURCE_MAP, 350, 0, JSEXN_SYNTAXERR, "Using //@ to indicate source map URL pragmas is deprecated. Use //# instead") MSG_DEF(JSMSG_BAD_DESTRUCT_ASSIGN, 351, 1, JSEXN_SYNTAXERR, "can't assign to {0} using destructuring assignment") MSG_DEF(JSMSG_BINARYDATA_ARRAYTYPE_BAD_ARGS, 352, 0, JSEXN_ERR, "Invalid arguments") MSG_DEF(JSMSG_BINARYDATA_BINARYARRAY_BAD_INDEX, 353, 0, JSEXN_RANGEERR, "invalid or out-of-range index") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_BAD_ARGS, 354, 0, JSEXN_RANGEERR, "invalid field descriptor") MSG_DEF(JSMSG_BINARYDATA_NOT_BINARYSTRUCT, 355, 1, JSEXN_TYPEERR, "{0} is not a BinaryStruct") MSG_DEF(JSMSG_BINARYDATA_SUBARRAY_INTEGER_ARG, 356, 1, JSEXN_ERR, "argument {0} must be an integer") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_EMPTY_DESCRIPTOR, 357, 0, JSEXN_ERR, "field descriptor cannot be empty") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_BAD_FIELD, 358, 1, JSEXN_ERR, "field {0} is not a valid BinaryData Type descriptor") ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsalloc.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* JS allocation policies. */ #ifndef jsalloc_h #define jsalloc_h #include "mozilla/AllocPolicy.h" #include "js/Utility.h" struct JSContext; namespace js { class ContextFriendFields; /* 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 { ContextFriendFields *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_((ContextFriendFields *) cx) {} // :( TempAllocPolicy(ContextFriendFields *cx) : cx_(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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* JavaScript API. */ #ifndef jsapi_h #define jsapi_h #include "mozilla/FloatingPoint.h" #include "mozilla/MemoryReporting.h" #include "mozilla/RangedPtr.h" #include "mozilla/ThreadLocal.h" #include "mozilla/TypeTraits.h" #include #include #include #include #include "js-config.h" #include "jsalloc.h" #include "jspubtd.h" #include "js/CallArgs.h" #include "js/CharacterEncoding.h" #include "js/HashTable.h" #include "js/RootingAPI.h" #include "js/Utility.h" #include "js/Value.h" #include "js/Vector.h" /************************************************************************/ namespace JS { typedef mozilla::RangedPtr CharPtr; class StableCharPtr : public CharPtr { public: StableCharPtr(const StableCharPtr &s) : CharPtr(s) {} StableCharPtr(const mozilla::RangedPtr &s) : CharPtr(s) {} StableCharPtr(const jschar *s, size_t len) : CharPtr(s, len) {} StableCharPtr(const jschar *pos, const jschar *start, size_t len) : CharPtr(pos, start, len) {} }; #if defined JS_THREADSAFE && defined DEBUG class JS_PUBLIC_API(AutoCheckRequestDepth) { JSContext *cx; public: AutoCheckRequestDepth(JSContext *cx); AutoCheckRequestDepth(js::ContextFriendFields *cx); ~AutoCheckRequestDepth(); }; # define CHECK_REQUEST(cx) \ JS::AutoCheckRequestDepth _autoCheckRequestDepth(cx) #else # define CHECK_REQUEST(cx) \ ((void) 0) #endif /* JS_THREADSAFE && DEBUG */ #ifdef DEBUG /* * Assert that we're not doing GC on cx, that we're in a request as * needed, and that the compartments for cx and v are correct. * Also check that GC would be safe at this point. */ JS_PUBLIC_API(void) AssertArgumentsAreSane(JSContext *cx, JS::Handle v); #else inline void AssertArgumentsAreSane(JSContext *cx, JS::Handle v) { /* Do nothing */ } #endif /* DEBUG */ class JS_PUBLIC_API(AutoGCRooter) { public: AutoGCRooter(JSContext *cx, ptrdiff_t tag); AutoGCRooter(js::ContextFriendFields *cx, ptrdiff_t tag); ~AutoGCRooter() { JS_ASSERT(this == *stackTop); *stackTop = down; } /* Implemented in gc/RootMarking.cpp. */ inline void trace(JSTracer *trc); static void traceAll(JSTracer *trc); static void traceAllWrappers(JSTracer *trc); protected: AutoGCRooter * const down; /* * Discriminates actual subclass of this being used. If non-negative, the * subclass roots an array of values of the length stored in this field. * If negative, meaning is indicated by the corresponding value in the enum * below. Any other negative value indicates some deeper problem such as * memory corruption. */ ptrdiff_t tag_; enum { VALARRAY = -2, /* js::AutoValueArray */ PARSER = -3, /* js::frontend::Parser */ SHAPEVECTOR = -4, /* js::AutoShapeVector */ IDARRAY = -6, /* js::AutoIdArray */ DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */ ID = -9, /* js::AutoIdRooter */ VALVECTOR = -10, /* js::AutoValueVector */ DESCRIPTOR = -11, /* js::AutoPropertyDescriptorRooter */ STRING = -12, /* js::AutoStringRooter */ IDVECTOR = -13, /* js::AutoIdVector */ OBJVECTOR = -14, /* js::AutoObjectVector */ STRINGVECTOR =-15, /* js::AutoStringVector */ SCRIPTVECTOR =-16, /* js::AutoScriptVector */ NAMEVECTOR = -17, /* js::AutoNameVector */ HASHABLEVALUE=-18, /* js::HashableValue */ IONMASM = -19, /* js::jit::MacroAssembler */ IONALLOC = -20, /* js::jit::AutoTempAllocatorRooter */ WRAPVECTOR = -21, /* js::AutoWrapperVector */ WRAPPER = -22, /* js::AutoWrapperRooter */ OBJOBJHASHMAP=-23, /* js::AutoObjectObjectHashMap */ OBJU32HASHMAP=-24, /* js::AutoObjectUnsigned32HashMap */ OBJHASHSET = -25, /* js::AutoObjectHashSet */ JSONPARSER = -26, /* js::JSONParser */ CUSTOM = -27, /* js::CustomAutoRooter */ FUNVECTOR = -28 /* js::AutoFunctionVector */ }; private: AutoGCRooter ** const stackTop; /* No copy or assignment semantics. */ AutoGCRooter(AutoGCRooter &ida) MOZ_DELETE; void operator=(AutoGCRooter &ida) MOZ_DELETE; }; class AutoStringRooter : private AutoGCRooter { public: AutoStringRooter(JSContext *cx, JSString *str = NULL MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, STRING), str_(str) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } void setString(JSString *str) { str_ = str; } JSString * string() const { return str_; } JSString ** addr() { return &str_; } JSString * const * addr() const { return &str_; } friend void AutoGCRooter::trace(JSTracer *trc); private: JSString *str_; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoArrayRooter : private AutoGCRooter { public: AutoArrayRooter(JSContext *cx, size_t len, Value *vec MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, len), array(vec), skip(cx, array, len) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; JS_ASSERT(tag_ >= 0); } void changeLength(size_t newLength) { tag_ = ptrdiff_t(newLength); JS_ASSERT(tag_ >= 0); } void changeArray(Value *newArray, size_t newLength) { changeLength(newLength); array = newArray; } Value *array; MutableHandleValue handleAt(size_t i) { JS_ASSERT(i < size_t(tag_)); return MutableHandleValue::fromMarkedLocation(&array[i]); } HandleValue handleAt(size_t i) const { JS_ASSERT(i < size_t(tag_)); return HandleValue::fromMarkedLocation(&array[i]); } friend void AutoGCRooter::trace(JSTracer *trc); private: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER js::SkipRoot skip; }; template class AutoVectorRooter : protected AutoGCRooter { public: explicit AutoVectorRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), vector(cx), vectorRoot(cx, &vector) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } explicit AutoVectorRooter(js::ContextFriendFields *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), vector(cx), vectorRoot(cx, &vector) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef T ElementType; size_t length() const { return vector.length(); } bool empty() const { return vector.empty(); } bool append(const T &v) { return vector.append(v); } bool appendAll(const AutoVectorRooter &other) { return vector.appendAll(other.vector); } bool insert(T *p, const T &val) { return vector.insert(p, val); } /* For use when space has already been reserved. */ void infallibleAppend(const T &v) { vector.infallibleAppend(v); } void popBack() { vector.popBack(); } T popCopy() { return vector.popCopy(); } bool growBy(size_t inc) { size_t oldLength = vector.length(); if (!vector.growByUninitialized(inc)) return false; makeRangeGCSafe(oldLength); return true; } bool resize(size_t newLength) { size_t oldLength = vector.length(); if (newLength <= oldLength) { vector.shrinkBy(oldLength - newLength); return true; } if (!vector.growByUninitialized(newLength - oldLength)) return false; makeRangeGCSafe(oldLength); return true; } void clear() { vector.clear(); } bool reserve(size_t newLength) { return vector.reserve(newLength); } T &operator[](size_t i) { return vector[i]; } const T &operator[](size_t i) const { return vector[i]; } JS::MutableHandle handleAt(size_t i) { return JS::MutableHandle::fromMarkedLocation(&vector[i]); } JS::Handle handleAt(size_t i) const { return JS::Handle::fromMarkedLocation(&vector[i]); } const T *begin() const { return vector.begin(); } T *begin() { return vector.begin(); } const T *end() const { return vector.end(); } T *end() { return vector.end(); } const T &back() const { return vector.back(); } friend void AutoGCRooter::trace(JSTracer *trc); private: void makeRangeGCSafe(size_t oldLength) { T *t = vector.begin() + oldLength; for (size_t i = oldLength; i < vector.length(); ++i, ++t) memset(t, 0, sizeof(T)); } typedef js::Vector VectorImpl; VectorImpl vector; /* Prevent overwriting of inline elements in vector. */ js::SkipRoot vectorRoot; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; template class AutoHashMapRooter : protected AutoGCRooter { private: typedef js::HashMap HashMapImpl; public: explicit AutoHashMapRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), map(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef Key KeyType; typedef Value ValueType; typedef typename HashMapImpl::Lookup Lookup; typedef typename HashMapImpl::Ptr Ptr; typedef typename HashMapImpl::AddPtr AddPtr; bool init(uint32_t len = 16) { return map.init(len); } bool initialized() const { return map.initialized(); } Ptr lookup(const Lookup &l) const { return map.lookup(l); } void remove(Ptr p) { map.remove(p); } AddPtr lookupForAdd(const Lookup &l) const { return map.lookupForAdd(l); } template bool add(AddPtr &p, const KeyInput &k, const ValueInput &v) { return map.add(p, k, v); } bool add(AddPtr &p, const Key &k) { return map.add(p, k); } template bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { return map.relookupOrAdd(p, k, v); } typedef typename HashMapImpl::Range Range; Range all() const { return map.all(); } typedef typename HashMapImpl::Enum Enum; void clear() { map.clear(); } void finish() { map.finish(); } bool empty() const { return map.empty(); } uint32_t count() const { return map.count(); } size_t capacity() const { return map.capacity(); } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfIncludingThis(mallocSizeOf); } unsigned generation() const { return map.generation(); } /************************************************** Shorthand operations */ bool has(const Lookup &l) const { return map.has(l); } template bool put(const KeyInput &k, const ValueInput &v) { return map.put(k, v); } template bool putNew(const KeyInput &k, const ValueInput &v) { return map.putNew(k, v); } Ptr lookupWithDefault(const Key &k, const Value &defaultValue) { return map.lookupWithDefault(k, defaultValue); } void remove(const Lookup &l) { map.remove(l); } friend void AutoGCRooter::trace(JSTracer *trc); private: AutoHashMapRooter(const AutoHashMapRooter &hmr) MOZ_DELETE; AutoHashMapRooter &operator=(const AutoHashMapRooter &hmr) MOZ_DELETE; HashMapImpl map; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; template class AutoHashSetRooter : protected AutoGCRooter { private: typedef js::HashSet HashSetImpl; public: explicit AutoHashSetRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), set(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef typename HashSetImpl::Lookup Lookup; typedef typename HashSetImpl::Ptr Ptr; typedef typename HashSetImpl::AddPtr AddPtr; bool init(uint32_t len = 16) { return set.init(len); } bool initialized() const { return set.initialized(); } Ptr lookup(const Lookup &l) const { return set.lookup(l); } void remove(Ptr p) { set.remove(p); } AddPtr lookupForAdd(const Lookup &l) const { return set.lookupForAdd(l); } bool add(AddPtr &p, const T &t) { return set.add(p, t); } bool relookupOrAdd(AddPtr &p, const Lookup &l, const T &t) { return set.relookupOrAdd(p, l, t); } typedef typename HashSetImpl::Range Range; Range all() const { return set.all(); } typedef typename HashSetImpl::Enum Enum; void clear() { set.clear(); } void finish() { set.finish(); } bool empty() const { return set.empty(); } uint32_t count() const { return set.count(); } size_t capacity() const { return set.capacity(); } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfIncludingThis(mallocSizeOf); } unsigned generation() const { return set.generation(); } /************************************************** Shorthand operations */ bool has(const Lookup &l) const { return set.has(l); } bool put(const T &t) { return set.put(t); } bool putNew(const T &t) { return set.putNew(t); } void remove(const Lookup &l) { set.remove(l); } friend void AutoGCRooter::trace(JSTracer *trc); private: AutoHashSetRooter(const AutoHashSetRooter &hmr) MOZ_DELETE; AutoHashSetRooter &operator=(const AutoHashSetRooter &hmr) MOZ_DELETE; HashSetImpl set; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoValueVector : public AutoVectorRooter { public: explicit AutoValueVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, VALVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoIdVector : public AutoVectorRooter { public: explicit AutoIdVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, IDVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoObjectVector : public AutoVectorRooter { public: explicit AutoObjectVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, OBJVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoFunctionVector : public AutoVectorRooter { public: explicit AutoFunctionVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, FUNVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } explicit AutoFunctionVector(js::ContextFriendFields *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, FUNVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoScriptVector : public AutoVectorRooter { public: explicit AutoScriptVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, SCRIPTVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* * Cutsom rooting behavior for internal and external clients. */ class JS_PUBLIC_API(CustomAutoRooter) : private AutoGCRooter { public: template explicit CustomAutoRooter(CX *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, CUSTOM) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } friend void AutoGCRooter::trace(JSTracer *trc); protected: /* Supplied by derived class to trace roots. */ virtual void trace(JSTracer *trc) = 0; private: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* Returns true if |v| is considered an acceptable this-value. */ typedef bool (*IsAcceptableThis)(const Value &v); /* * Implements the guts of a method; guaranteed to be provided an acceptable * this-value, as determined by a corresponding IsAcceptableThis method. */ typedef bool (*NativeImpl)(JSContext *cx, CallArgs args); namespace detail { /* DON'T CALL THIS DIRECTLY. It's for use only by CallNonGenericMethod! */ extern JS_PUBLIC_API(bool) CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args); } /* namespace detail */ /* * Methods usually act upon |this| objects only from a single global object and * compartment. Sometimes, however, a method must act upon |this| values from * multiple global objects or compartments. In such cases the |this| value a * method might see will be wrapped, such that various access to the object -- * to its class, its private data, its reserved slots, and so on -- will not * work properly without entering that object's compartment. This method * implements a solution to this problem. * * To implement a method that accepts |this| values from multiple compartments, * define two functions. The first function matches the IsAcceptableThis type * and indicates whether the provided value is an acceptable |this| for the * method; it must be a pure function only of its argument. * * static JSClass AnswerClass = { ... }; * * static bool * IsAnswerObject(const Value &v) * { * if (!v.isObject()) * return false; * return JS_GetClass(&v.toObject()) == &AnswerClass; * } * * The second function implements the NativeImpl signature and defines the * behavior of the method when it is provided an acceptable |this| value. * Aside from some typing niceties -- see the CallArgs interface for details -- * its interface is the same as that of JSNative. * * static bool * answer_getAnswer_impl(JSContext *cx, JS::CallArgs args) * { * args.rval().setInt32(42); * return true; * } * * The implementation function is guaranteed to be called *only* with a |this| * value which is considered acceptable. * * Now to implement the actual method, write a JSNative that calls the method * declared below, passing the appropriate template and runtime arguments. * * static JSBool * answer_getAnswer(JSContext *cx, unsigned argc, JS::Value *vp) * { * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); * return JS::CallNonGenericMethod(cx, args); * } * * Note that, because they are used as template arguments, the predicate * and implementation functions must have external linkage. (This is * unfortunate, but GCC wasn't inlining things as one would hope when we * passed them as function arguments.) * * JS::CallNonGenericMethod will test whether |args.thisv()| is acceptable. If * it is, it will call the provided implementation function, which will return * a value and indicate success. If it is not, it will attempt to unwrap * |this| and call the implementation function on the unwrapped |this|. If * that succeeds, all well and good. If it doesn't succeed, a TypeError will * be thrown. * * Note: JS::CallNonGenericMethod will only work correctly if it's called in * tail position in a JSNative. Do not call it from any other place. */ template JS_ALWAYS_INLINE bool CallNonGenericMethod(JSContext *cx, CallArgs args) { const Value &thisv = args.thisv(); if (Test(thisv)) return Impl(cx, args); return detail::CallMethodIfWrapped(cx, Test, Impl, args); } JS_ALWAYS_INLINE bool CallNonGenericMethod(JSContext *cx, IsAcceptableThis Test, NativeImpl Impl, CallArgs args) { const Value &thisv = args.thisv(); if (Test(thisv)) return Impl(cx, args); return detail::CallMethodIfWrapped(cx, Test, Impl, args); } } /* namespace JS */ /************************************************************************/ /* JSClass operation signatures. */ /* * Add or get a property named by id in obj. Note the jsid id type -- id may * be a string (Unicode property identifier) or an int (element index). The * *vp out parameter, on success, is the new property value after the action. */ typedef JSBool (* JSPropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JS::MutableHandle vp); /* * Set a property named by id in obj, treating the assignment as strict * mode code if strict is true. Note the jsid id type -- id may be a string * (Unicode property identifier) or an int (element index). The *vp out * parameter, on success, is the new property value after the * set. */ typedef JSBool (* JSStrictPropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool strict, JS::MutableHandle vp); /* * Delete a property named by id in obj. * * If an error occurred, return false as per normal JSAPI error practice. * * If no error occurred, but the deletion attempt wasn't allowed (perhaps * because the property was non-configurable), set *succeeded to false and * return true. This will cause |delete obj[id]| to evaluate to false in * non-strict mode code, and to throw a TypeError in strict mode code. * * If no error occurred and the deletion wasn't disallowed (this is *not* the * same as saying that a deletion actually occurred -- deleting a non-existent * property, or an inherited property, is allowed -- it's just pointless), * set *succeeded to true and return true. */ typedef JSBool (* JSDeletePropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool *succeeded); /* * This function type is used for callbacks that enumerate the properties of * a JSObject. The behavior depends on the value of enum_op: * * JSENUMERATE_INIT * A new, opaque iterator state should be allocated and stored in *statep. * (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored). * * The number of properties that will be enumerated should be returned as * an integer jsval in *idp, if idp is non-null, and provided the number of * enumerable properties is known. If idp is non-null and the number of * enumerable properties can't be computed in advance, *idp should be set * to JSVAL_ZERO. * * JSENUMERATE_INIT_ALL * Used identically to JSENUMERATE_INIT, but exposes all properties of the * object regardless of enumerability. * * JSENUMERATE_NEXT * A previously allocated opaque iterator state is passed in via statep. * Return the next jsid in the iteration using *idp. The opaque iterator * state pointed at by statep is destroyed and *statep is set to JSVAL_NULL * if there are no properties left to enumerate. * * JSENUMERATE_DESTROY * Destroy the opaque iterator state previously allocated in *statep by a * call to this function when enum_op was JSENUMERATE_INIT or * JSENUMERATE_INIT_ALL. * * The return value is used to indicate success, with a value of JS_FALSE * indicating failure. */ typedef JSBool (* JSNewEnumerateOp)(JSContext *cx, JS::Handle obj, JSIterateOp enum_op, JS::MutableHandle statep, JS::MutableHandleId idp); /* * The old-style JSClass.enumerate op should define all lazy properties not * yet reflected in obj. */ typedef JSBool (* JSEnumerateOp)(JSContext *cx, JS::Handle obj); /* * Resolve a lazy property named by id in obj by defining it directly in obj. * Lazy properties are those reflected from some peer native property space * (e.g., the DOM attributes for a given node reflected as obj) on demand. * * JS looks for a property in an object, and if not found, tries to resolve * the given id. If resolve succeeds, the engine looks again in case resolve * defined obj[id]. If no such property exists directly in obj, the process * is repeated with obj's prototype, etc. * * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties. */ typedef JSBool (* JSResolveOp)(JSContext *cx, JS::Handle obj, JS::Handle id); /* * Like JSResolveOp, but flags provide contextual information as follows: * * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment * * The *objp out parameter, on success, should be null to indicate that id * was not resolved; and non-null, referring to obj or one of its prototypes, * if id was resolved. The hook may assume *objp is null on entry. * * This hook instead of JSResolveOp is called via the JSClass.resolve member * if JSCLASS_NEW_RESOLVE is set in JSClass.flags. */ typedef JSBool (* JSNewResolveOp)(JSContext *cx, JS::Handle obj, JS::Handle id, unsigned flags, JS::MutableHandleObject objp); /* * Convert obj to the given type, returning true with the resulting value in * *vp on success, and returning false on error or exception. */ typedef JSBool (* JSConvertOp)(JSContext *cx, JS::Handle obj, JSType type, JS::MutableHandle vp); typedef struct JSFreeOp JSFreeOp; struct JSFreeOp { private: JSRuntime *runtime_; protected: JSFreeOp(JSRuntime *rt) : runtime_(rt) { } public: JSRuntime *runtime() const { return runtime_; } }; /* * Finalize obj, which the garbage collector has determined to be unreachable * from other live objects or from GC roots. Obviously, finalizers must never * store a reference to obj. */ typedef void (* JSFinalizeOp)(JSFreeOp *fop, JSObject *obj); /* * Finalizes external strings created by JS_NewExternalString. */ typedef struct JSStringFinalizer JSStringFinalizer; struct JSStringFinalizer { void (*finalize)(const JSStringFinalizer *fin, jschar *chars); }; /* * JSClass.checkAccess type: check whether obj[id] may be accessed per mode, * returning false on error/exception, true on success with obj[id]'s last-got * value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id * is either a string or an int jsval. */ typedef JSBool (* JSCheckAccessOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSAccessMode mode, JS::MutableHandle vp); /* * Check whether v is an instance of obj. Return false on error or exception, * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in * *bp otherwise. */ typedef JSBool (* JSHasInstanceOp)(JSContext *cx, JS::Handle obj, JS::MutableHandle vp, JSBool *bp); /* * Function type for trace operation of the class called to enumerate all * traceable things reachable from obj's private data structure. For each such * thing, a trace implementation must call one of the JS_Call*Tracer variants * on the thing. * * JSTraceOp implementation can assume that no other threads mutates object * state. It must not change state of the object or corresponding native * structures. The only exception for this rule is the case when the embedding * needs a tight integration with GC. In that case the embedding can check if * the traversal is a part of the marking phase through calling * JS_IsGCMarkingTracer and apply a special code like emptying caches or * marking its native structures. */ typedef void (* JSTraceOp)(JSTracer *trc, JSObject *obj); /* * Callback that JSTraceOp implementation can provide to return a string * describing the reference traced with JS_CallTracer. */ typedef void (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize); typedef JSObject * (* JSWeakmapKeyDelegateOp)(JSObject *obj); /* Callbacks and their arguments. */ typedef enum JSContextOp { JSCONTEXT_NEW, JSCONTEXT_DESTROY } JSContextOp; /* * The possible values for contextOp when the runtime calls the callback are: * JSCONTEXT_NEW JS_NewContext successfully created a new JSContext * instance. The callback can initialize the instance as * required. If the callback returns false, the instance * will be destroyed and JS_NewContext returns null. In * this case the callback is not called again. * JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The * callback may perform its own cleanup and must always * return true. * Any other value For future compatibility the callback must do nothing * and return true in this case. */ typedef JSBool (* JSContextCallback)(JSContext *cx, unsigned contextOp, void *data); typedef enum JSGCStatus { JSGC_BEGIN, JSGC_END } JSGCStatus; typedef void (* JSGCCallback)(JSRuntime *rt, JSGCStatus status, void *data); typedef enum JSFinalizeStatus { /* * Called when preparing to sweep a group of compartments, before anything * has been swept. The collector will not yield to the mutator before * calling the callback with JSFINALIZE_GROUP_END status. */ JSFINALIZE_GROUP_START, /* * Called when preparing to sweep a group of compartments. Weak references * to unmarked things have been removed and things that are not swept * incrementally have been finalized at this point. The collector may yield * to the mutator after this point. */ JSFINALIZE_GROUP_END, /* * Called at the end of collection when everything has been swept. */ JSFINALIZE_COLLECTION_END } JSFinalizeStatus; typedef void (* JSFinalizeCallback)(JSFreeOp *fop, JSFinalizeStatus status, JSBool isCompartment); /* * Generic trace operation that calls JS_CallTracer on each traceable thing * stored in data. */ typedef void (* JSTraceDataOp)(JSTracer *trc, void *data); typedef JSBool (* JSOperationCallback)(JSContext *cx); typedef void (* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report); #ifdef MOZ_TRACE_JSCALLS typedef void (* JSFunctionCallback)(const JSFunction *fun, const JSScript *scr, const JSContext *cx, int entering); #endif /* * Possible exception types. These types are part of a JSErrorFormatString * structure. They define which error to throw in case of a runtime error. * JSEXN_NONE marks an unthrowable error. */ typedef enum JSExnType { JSEXN_NONE = -1, JSEXN_ERR, JSEXN_INTERNALERR, JSEXN_EVALERR, JSEXN_RANGEERR, JSEXN_REFERENCEERR, JSEXN_SYNTAXERR, JSEXN_TYPEERR, JSEXN_URIERR, JSEXN_LIMIT } JSExnType; typedef struct JSErrorFormatString { /* The error format string in ASCII. */ const char *format; /* The number of arguments to expand in the formatted error message. */ uint16_t argCount; /* One of the JSExnType constants above. */ int16_t exnType; } JSErrorFormatString; typedef const JSErrorFormatString * (* JSErrorCallback)(void *userRef, const char *locale, const unsigned errorNumber); typedef JSBool (* JSLocaleToUpperCase)(JSContext *cx, JS::Handle src, JS::MutableHandle rval); typedef JSBool (* JSLocaleToLowerCase)(JSContext *cx, JS::Handle src, JS::MutableHandle rval); typedef JSBool (* JSLocaleCompare)(JSContext *cx, JS::Handle src1, JS::Handle src2, JS::MutableHandle rval); typedef JSBool (* JSLocaleToUnicode)(JSContext *cx, const char *src, JS::MutableHandle rval); /* * Security protocol types. */ typedef void (* JSDestroyPrincipalsOp)(JSPrincipals *principals); /* * Used to check if a CSP instance wants to disable eval() and friends. * See js_CheckCSPPermitsJSAction() in jsobj. */ typedef JSBool (* JSCSPEvalChecker)(JSContext *cx); /* * Callback used to ask the embedding for the cross compartment wrapper handler * that implements the desired prolicy for this kind of object in the * destination compartment. |obj| is the object to be wrapped. If |existing| is * non-NULL, it will point to an existing wrapper object that should be re-used * if possible. |existing| is guaranteed to be a cross-compartment wrapper with * a lazily-defined prototype and the correct global. It is guaranteed not to * wrap a function. */ typedef JSObject * (* JSWrapObjectCallback)(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj, JS::HandleObject proto, JS::HandleObject parent, unsigned flags); /* * Callback used by the wrap hook to ask the embedding to prepare an object * for wrapping in a context. This might include unwrapping other wrappers * or even finding a more suitable object for the new compartment. */ typedef JSObject * (* JSPreWrapCallback)(JSContext *cx, JS::HandleObject scope, JS::HandleObject obj, unsigned flags); /* * Callback used when wrapping determines that the underlying object is already * in the compartment for which it is being wrapped. This allows consumers to * maintain same-compartment wrapping invariants. * * |obj| is guaranteed to be same-compartment as |cx|, but it may (or may not) * be a security or cross-compartment wrapper. This is an unfortunate contract, * but is important for to avoid unnecessarily recomputing every cross- * compartment wrapper that gets passed to wrap. */ typedef JSObject * (* JSSameCompartmentWrapObjectCallback)(JSContext *cx, JS::HandleObject obj); typedef void (* JSDestroyCompartmentCallback)(JSFreeOp *fop, JSCompartment *compartment); typedef void (* JSCompartmentNameCallback)(JSRuntime *rt, JSCompartment *compartment, char *buf, size_t bufsize); /* * Read structured data from the reader r. This hook is used to read a value * previously serialized by a call to the WriteStructuredCloneOp hook. * * tag and data are the pair of uint32_t values from the header. The callback * may use the JS_Read* APIs to read any other relevant parts of the object * from the reader r. closure is any value passed to the JS_ReadStructuredClone * function. Return the new object on success, NULL on error/exception. */ typedef JSObject *(*ReadStructuredCloneOp)(JSContext *cx, JSStructuredCloneReader *r, uint32_t tag, uint32_t data, void *closure); /* * Structured data serialization hook. The engine can write primitive values, * Objects, Arrays, Dates, RegExps, TypedArrays, and ArrayBuffers. Any other * type of object requires application support. This callback must first use * the JS_WriteUint32Pair API to write an object header, passing a value * greater than JS_SCTAG_USER to the tag parameter. Then it can use the * JS_Write* APIs to write any other relevant parts of the value v to the * writer w. closure is any value passed to the JS_WriteStructuredCLone function. * * Return true on success, false on error/exception. */ typedef JSBool (*WriteStructuredCloneOp)(JSContext *cx, JSStructuredCloneWriter *w, JS::Handle obj, void *closure); /* * This is called when JS_WriteStructuredClone is given an invalid transferable. * To follow HTML5, the application must throw a DATA_CLONE_ERR DOMException * with error set to one of the JS_SCERR_* values. */ typedef void (*StructuredCloneErrorOp)(JSContext *cx, uint32_t errorid); /************************************************************************/ /* * JS constants. For efficiency, prefer predicates (e.g. v.isNull()) and * constructing values from scratch (e.g. Int32Value(0)). These constants are * stored in memory and initialized at startup, so testing against them and * using them requires memory loads and will be correspondingly slow. */ extern JS_PUBLIC_DATA(const jsval) JSVAL_NULL; extern JS_PUBLIC_DATA(const jsval) JSVAL_ZERO; extern JS_PUBLIC_DATA(const jsval) JSVAL_ONE; extern JS_PUBLIC_DATA(const jsval) JSVAL_FALSE; extern JS_PUBLIC_DATA(const jsval) JSVAL_TRUE; extern JS_PUBLIC_DATA(const jsval) JSVAL_VOID; static JS_ALWAYS_INLINE jsval JS_NumberValue(double d) { int32_t i; d = JS::CanonicalizeNaN(d); if (mozilla::DoubleIsInt32(d, &i)) return INT_TO_JSVAL(i); return DOUBLE_TO_JSVAL(d); } /************************************************************************/ /* * A jsid is an identifier for a property or method of an object which is * either a 31-bit signed integer, interned string or object. Also, there is * an additional jsid value, JSID_VOID, which does not occur in JS scripts but * may be used to indicate the absence of a valid jsid. * * A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or * JS_IdToValue must be used instead. */ #define JSID_TYPE_STRING 0x0 #define JSID_TYPE_INT 0x1 #define JSID_TYPE_VOID 0x2 #define JSID_TYPE_OBJECT 0x4 #define JSID_TYPE_MASK 0x7 /* * Avoid using canonical 'id' for jsid parameters since this is a magic word in * Objective-C++ which, apparently, wants to be able to #include jsapi.h. */ #define id iden static JS_ALWAYS_INLINE JSBool JSID_IS_STRING(jsid id) { return (JSID_BITS(id) & JSID_TYPE_MASK) == 0; } static JS_ALWAYS_INLINE JSString * JSID_TO_STRING(jsid id) { JS_ASSERT(JSID_IS_STRING(id)); return (JSString *)JSID_BITS(id); } static JS_ALWAYS_INLINE JSBool JSID_IS_ZERO(jsid id) { return JSID_BITS(id) == 0; } JS_PUBLIC_API(JSBool) JS_StringHasBeenInterned(JSContext *cx, JSString *str); /* * Only JSStrings that have been interned via the JSAPI can be turned into * jsids by API clients. * * N.B. if a jsid is backed by a string which has not been interned, that * string must be appropriately rooted to avoid being collected by the GC. */ JS_PUBLIC_API(jsid) INTERNED_STRING_TO_JSID(JSContext *cx, JSString *str); static JS_ALWAYS_INLINE JSBool JSID_IS_INT(jsid id) { return !!(JSID_BITS(id) & JSID_TYPE_INT); } static JS_ALWAYS_INLINE int32_t JSID_TO_INT(jsid id) { JS_ASSERT(JSID_IS_INT(id)); return ((uint32_t)JSID_BITS(id)) >> 1; } #define JSID_INT_MIN 0 #define JSID_INT_MAX INT32_MAX static JS_ALWAYS_INLINE JSBool INT_FITS_IN_JSID(int32_t i) { return i >= 0; } static JS_ALWAYS_INLINE jsid INT_TO_JSID(int32_t i) { jsid id; JS_ASSERT(INT_FITS_IN_JSID(i)); JSID_BITS(id) = ((i << 1) | JSID_TYPE_INT); return id; } static JS_ALWAYS_INLINE JSBool JSID_IS_OBJECT(jsid id) { return (JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_OBJECT && (size_t)JSID_BITS(id) != JSID_TYPE_OBJECT; } static JS_ALWAYS_INLINE JSObject * JSID_TO_OBJECT(jsid id) { JS_ASSERT(JSID_IS_OBJECT(id)); return (JSObject *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); } static JS_ALWAYS_INLINE jsid OBJECT_TO_JSID(JSObject *obj) { jsid id; JS_ASSERT(obj != NULL); JS_ASSERT(((size_t)obj & JSID_TYPE_MASK) == 0); JSID_BITS(id) = ((size_t)obj | JSID_TYPE_OBJECT); return id; } static JS_ALWAYS_INLINE JSBool JSID_IS_GCTHING(jsid id) { return JSID_IS_STRING(id) || JSID_IS_OBJECT(id); } static JS_ALWAYS_INLINE void * JSID_TO_GCTHING(jsid id) { return (void *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); } /* * A void jsid is not a valid id and only arises as an exceptional API return * value, such as in JS_NextProperty. Embeddings must not pass JSID_VOID into * JSAPI entry points expecting a jsid and do not need to handle JSID_VOID in * hooks receiving a jsid except when explicitly noted in the API contract. */ static JS_ALWAYS_INLINE JSBool JSID_IS_VOID(const jsid id) { JS_ASSERT_IF(((size_t)JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_VOID, JSID_BITS(id) == JSID_TYPE_VOID); return ((size_t)JSID_BITS(id) == JSID_TYPE_VOID); } static JS_ALWAYS_INLINE JSBool JSID_IS_EMPTY(const jsid id) { return ((size_t)JSID_BITS(id) == JSID_TYPE_OBJECT); } #undef id #ifdef JS_USE_JSID_STRUCT_TYPES extern JS_PUBLIC_DATA(const jsid) JSID_VOID; extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY; #else # define JSID_VOID ((jsid)JSID_TYPE_VOID) # define JSID_EMPTY ((jsid)JSID_TYPE_OBJECT) #endif /* * Returns true iff the given jsval is immune to GC and can be used across * multiple JSRuntimes without requiring any conversion API. */ static JS_ALWAYS_INLINE JSBool JSVAL_IS_UNIVERSAL(jsval v) { return !JSVAL_IS_GCTHING(v); } namespace JS { class AutoIdRooter : private AutoGCRooter { public: explicit AutoIdRooter(JSContext *cx, jsid aId = INT_TO_JSID(0) MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, ID), id_(aId) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } jsid id() { return id_; } jsid * addr() { return &id_; } friend void AutoGCRooter::trace(JSTracer *trc); private: jsid id_; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; } /* namespace JS */ /************************************************************************/ /* Property attributes, set in JSPropertySpec and passed to API functions. */ #define JSPROP_ENUMERATE 0x01 /* property is visible to for/in loop */ #define JSPROP_READONLY 0x02 /* not settable: assignment is no-op. This flag is only valid when neither JSPROP_GETTER nor JSPROP_SETTER is set. */ #define JSPROP_PERMANENT 0x04 /* property cannot be deleted */ #define JSPROP_NATIVE_ACCESSORS 0x08 /* set in JSPropertyDescriptor.flags if getters/setters are JSNatives */ #define JSPROP_GETTER 0x10 /* property holds getter function */ #define JSPROP_SETTER 0x20 /* property holds setter function */ #define JSPROP_SHARED 0x40 /* don't allocate a value slot for this property; don't copy the property on set of the same-named property in an object that delegates to a prototype containing this property */ #define JSPROP_INDEX 0x80 /* name is actually (int) index */ #define JSPROP_SHORTID 0x100 /* set in JS_DefineProperty attrs if getters/setters use a shortid */ #define JSFUN_STUB_GSOPS 0x200 /* use JS_PropertyStub getter/setter instead of defaulting to class gsops for property holding function */ #define JSFUN_CONSTRUCTOR 0x400 /* native that can be called as a ctor */ /* * Specify a generic native prototype methods, i.e., methods of a class * prototype that are exposed as static methods taking an extra leading * argument: the generic |this| parameter. * * If you set this flag in a JSFunctionSpec struct's flags initializer, then * that struct must live at least as long as the native static method object * created due to this flag by JS_DefineFunctions or JS_InitClass. Typically * JSFunctionSpec structs are allocated in static arrays. */ #define JSFUN_GENERIC_NATIVE 0x800 #define JSFUN_FLAGS_MASK 0xe00 /* | of all the JSFUN_* flags */ /* * The first call to JS_CallOnce by any thread in a process will call 'func'. * Later calls to JS_CallOnce with the same JSCallOnceType object will be * suppressed. * * Equivalently: each distinct JSCallOnceType object will allow one JS_CallOnce * to invoke its JSInitCallback. */ extern JS_PUBLIC_API(JSBool) JS_CallOnce(JSCallOnceType *once, JSInitCallback func); /* Microseconds since the epoch, midnight, January 1, 1970 UTC. */ extern JS_PUBLIC_API(int64_t) JS_Now(void); /* Don't want to export data, so provide accessors for non-inline jsvals. */ extern JS_PUBLIC_API(jsval) JS_GetNaNValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetNegativeInfinityValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetPositiveInfinityValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetEmptyStringValue(JSContext *cx); extern JS_PUBLIC_API(JSString *) JS_GetEmptyString(JSRuntime *rt); /* * Format is a string of the following characters (spaces are insignificant), * specifying the tabulated type conversions: * * b JSBool Boolean * c uint16_t/jschar ECMA uint16_t, Unicode char * i int32_t ECMA int32_t * u uint32_t ECMA uint32_t * j int32_t Rounded int32_t (coordinate) * d double IEEE double * I double Integral IEEE double * S JSString * Unicode string, accessed by a JSString pointer * W jschar * Unicode character vector, 0-terminated (W for wide) * o JSObject * Object reference * f JSFunction * Function private * v jsval Argument value (no conversion) * * N/A Skip this argument (no vararg) * / N/A End of required arguments * * The variable argument list after format must consist of &b, &c, &s, e.g., * where those variables have the types given above. For the pointer types * char *, JSString *, and JSObject *, the pointed-at memory returned belongs * to the JS runtime, not to the calling native code. The runtime promises * to keep this memory valid so long as argv refers to allocated stack space * (so long as the native function is active). * * Fewer arguments than format specifies may be passed only if there is a / * in format after the last required argument specifier and argc is at least * the number of required arguments. More arguments than format specifies * may be passed without error; it is up to the caller to deal with trailing * unconverted arguments. */ extern JS_PUBLIC_API(JSBool) JS_ConvertArguments(JSContext *cx, unsigned argc, jsval *argv, const char *format, ...); #ifdef va_start extern JS_PUBLIC_API(JSBool) JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *format, va_list ap); #endif extern JS_PUBLIC_API(JSBool) JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_ValueToObject(JSContext *cx, jsval v, JSObject **objp); extern JS_PUBLIC_API(JSFunction *) JS_ValueToFunction(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSFunction *) JS_ValueToConstructor(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToString(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToSource(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSBool) JS_ValueToNumber(JSContext *cx, jsval v, double *dp); namespace js { /* * DO NOT CALL THIS. Use JS::ToNumber */ extern JS_PUBLIC_API(bool) ToNumberSlow(JSContext *cx, JS::Value v, double *dp); /* * DO NOT CALL THIS. Use JS::ToBoolean */ extern JS_PUBLIC_API(bool) ToBooleanSlow(const JS::Value &v); } /* namespace js */ namespace JS { /* ES5 9.3 ToNumber. */ JS_ALWAYS_INLINE bool ToNumber(JSContext *cx, HandleValue v, double *out) { AssertArgumentsAreSane(cx, v); { js::SkipRoot root(cx, &v); js::MaybeCheckStackRoots(cx); } if (v.isNumber()) { *out = v.toNumber(); return true; } return js::ToNumberSlow(cx, v, out); } JS_ALWAYS_INLINE bool ToBoolean(const Value &v) { if (v.isBoolean()) return v.toBoolean(); if (v.isInt32()) return v.toInt32() != 0; if (v.isNullOrUndefined()) return false; if (v.isDouble()) { double d = v.toDouble(); return !mozilla::IsNaN(d) && d != 0; } /* The slow path handles strings and objects. */ return js::ToBooleanSlow(v); } } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_DoubleIsInt32(double d, int32_t *ip); extern JS_PUBLIC_API(int32_t) JS_DoubleToInt32(double d); extern JS_PUBLIC_API(uint32_t) JS_DoubleToUint32(double d); /* * Convert a value to a number, then to an int32_t, according to the ECMA rules * for ToInt32. */ extern JS_PUBLIC_API(JSBool) JS_ValueToECMAInt32(JSContext *cx, jsval v, int32_t *ip); /* * Convert a value to a number, then to an int64_t, according to the WebIDL * rules for ToInt64: http://dev.w3.org/2006/webapi/WebIDL/#es-long-long */ extern JS_PUBLIC_API(JSBool) JS_ValueToInt64(JSContext *cx, jsval v, int64_t *ip); /* * Convert a value to a number, then to an uint64_t, according to the WebIDL * rules for ToUint64: http://dev.w3.org/2006/webapi/WebIDL/#es-unsigned-long-long */ extern JS_PUBLIC_API(JSBool) JS_ValueToUint64(JSContext *cx, jsval v, uint64_t *ip); namespace js { /* DO NOT CALL THIS. Use JS::ToInt16. */ extern JS_PUBLIC_API(bool) ToUint16Slow(JSContext *cx, JS::Handle v, uint16_t *out); /* DO NOT CALL THIS. Use JS::ToInt32. */ extern JS_PUBLIC_API(bool) ToInt32Slow(JSContext *cx, JS::Handle v, int32_t *out); /* DO NOT CALL THIS. Use JS::ToUint32. */ extern JS_PUBLIC_API(bool) ToUint32Slow(JSContext *cx, JS::Handle v, uint32_t *out); /* DO NOT CALL THIS. Use JS::ToInt64. */ extern JS_PUBLIC_API(bool) ToInt64Slow(JSContext *cx, JS::Handle v, int64_t *out); /* DO NOT CALL THIS. Use JS::ToUint64. */ extern JS_PUBLIC_API(bool) ToUint64Slow(JSContext *cx, JS::Handle v, uint64_t *out); } /* namespace js */ namespace JS { JS_ALWAYS_INLINE bool ToUint16(JSContext *cx, JS::Handle v, uint16_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = uint16_t(v.toInt32()); return true; } return js::ToUint16Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToInt32(JSContext *cx, JS::Handle v, int32_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = v.toInt32(); return true; } return js::ToInt32Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToUint32(JSContext *cx, JS::Handle v, uint32_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = uint32_t(v.toInt32()); return true; } return js::ToUint32Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToInt64(JSContext *cx, JS::Handle v, int64_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = int64_t(v.toInt32()); return true; } return js::ToInt64Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToUint64(JSContext *cx, JS::Handle v, uint64_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { /* Account for sign extension of negatives into the longer 64bit space. */ *out = uint64_t(int64_t(v.toInt32())); return true; } return js::ToUint64Slow(cx, v, out); } } /* namespace JS */ /* * Convert a value to a number, then to a uint32_t, according to the ECMA rules * for ToUint32. */ extern JS_PUBLIC_API(JSBool) JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32_t *ip); /* * Convert a value to a number, then to an int32_t if it fits by rounding to * nearest; but failing with an error report if the double is out of range * or unordered. */ extern JS_PUBLIC_API(JSBool) JS_ValueToInt32(JSContext *cx, jsval v, int32_t *ip); /* * ECMA ToUint16, for mapping a jsval to a Unicode point. */ extern JS_PUBLIC_API(JSBool) JS_ValueToUint16(JSContext *cx, jsval v, uint16_t *ip); extern JS_PUBLIC_API(JSBool) JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp); extern JS_PUBLIC_API(JSType) JS_TypeOfValue(JSContext *cx, jsval v); extern JS_PUBLIC_API(const char *) JS_GetTypeName(JSContext *cx, JSType type); extern JS_PUBLIC_API(JSBool) JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); extern JS_PUBLIC_API(JSBool) JS_LooselyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); extern JS_PUBLIC_API(JSBool) JS_SameValue(JSContext *cx, jsval v1, jsval v2, JSBool *same); /* True iff fun is the global eval function. */ extern JS_PUBLIC_API(JSBool) JS_IsBuiltinEvalFunction(JSFunction *fun); /* True iff fun is the Function constructor. */ extern JS_PUBLIC_API(JSBool) JS_IsBuiltinFunctionConstructor(JSFunction *fun); /************************************************************************/ /* * Initialization, locking, contexts, and memory allocation. * * It is important that the first runtime and first context be created in a * single-threaded fashion, otherwise the behavior of the library is undefined. * See: http://developer.mozilla.org/en/docs/Category:JSAPI_Reference */ typedef enum JSUseHelperThreads { JS_NO_HELPER_THREADS, JS_USE_HELPER_THREADS } JSUseHelperThreads; /** * Initialize SpiderMonkey, returning true only if initialization succeeded. * Once this method has succeeded, it is safe to call JS_NewRuntime and other * JSAPI methods. * * This method must be called before any other JSAPI method is used on any * thread. Once it has been used, it is safe to call any JSAPI method, and it * remains safe to do so until JS_ShutDown is correctly called. * * It is currently not possible to initialize SpiderMonkey multiple times (that * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so * again). This restriction may eventually be lifted. */ extern JS_PUBLIC_API(JSBool) JS_Init(void); /** * Destroy free-standing resources allocated by SpiderMonkey, not associated * with any runtime, context, or other structure. * * This method should be called after all other JSAPI data has been properly * cleaned up: every new runtime must have been destroyed, every new context * must have been destroyed, and so on. Calling this method before all other * resources have been destroyed has undefined behavior. * * Failure to call this method, at present, has no adverse effects other than * leaking memory. This may not always be the case; it's recommended that all * embedders call this method when all other JSAPI operations have completed. * * It is currently not possible to initialize SpiderMonkey multiple times (that * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so * again). This restriction may eventually be lifted. */ extern JS_PUBLIC_API(void) JS_ShutDown(void); extern JS_PUBLIC_API(JSRuntime *) JS_NewRuntime(uint32_t maxbytes, JSUseHelperThreads useHelperThreads); extern JS_PUBLIC_API(void) JS_DestroyRuntime(JSRuntime *rt); // These are equivalent to ICU's |UMemAllocFn|, |UMemReallocFn|, and // |UMemFreeFn| types. The first argument (called |context| in the ICU docs) // will always be NULL, and should be ignored. typedef void *(*JS_ICUAllocFn)(const void *, size_t size); typedef void *(*JS_ICUReallocFn)(const void *, void *p, size_t size); typedef void (*JS_ICUFreeFn)(const void *, void *p); // This function can be used to track memory used by ICU. // Do not use it unless you know what you are doing! extern JS_PUBLIC_API(bool) JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn, JS_ICUReallocFn reallocFn, JS_ICUFreeFn freeFn); JS_PUBLIC_API(void *) JS_GetRuntimePrivate(JSRuntime *rt); extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); JS_PUBLIC_API(void) JS_SetRuntimePrivate(JSRuntime *rt, void *data); extern JS_PUBLIC_API(void) JS_BeginRequest(JSContext *cx); extern JS_PUBLIC_API(void) JS_EndRequest(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_IsInRequest(JSRuntime *rt); namespace JS { inline bool IsPoisonedId(jsid iden) { if (JSID_IS_STRING(iden)) return JS::IsPoisonedPtr(JSID_TO_STRING(iden)); if (JSID_IS_OBJECT(iden)) return JS::IsPoisonedPtr(JSID_TO_OBJECT(iden)); return false; } } /* namespace JS */ namespace js { template <> struct GCMethods { static jsid initial() { return JSID_VOID; } static ThingRootKind kind() { return THING_ROOT_ID; } static bool poisoned(jsid id) { return JS::IsPoisonedId(id); } static bool needsPostBarrier(jsid id) { return false; } #ifdef JSGC_GENERATIONAL static void postBarrier(jsid *idp) {} static void relocate(jsid *idp) {} #endif }; } /* namespace js */ class JSAutoRequest { public: JSAutoRequest(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mContext(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; JS_BeginRequest(mContext); } ~JSAutoRequest() { JS_EndRequest(mContext); } protected: JSContext *mContext; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER #if 0 private: static void *operator new(size_t) CPP_THROW_NEW { return 0; }; static void operator delete(void *, size_t) { }; #endif }; class JSAutoCheckRequest { public: JSAutoCheckRequest(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { #if defined JS_THREADSAFE && defined DEBUG mContext = cx; JS_ASSERT(JS_IsInRequest(JS_GetRuntime(cx))); #endif MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~JSAutoCheckRequest() { #if defined JS_THREADSAFE && defined DEBUG JS_ASSERT(JS_IsInRequest(JS_GetRuntime(mContext))); #endif } private: #if defined JS_THREADSAFE && defined DEBUG JSContext *mContext; #endif MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; extern JS_PUBLIC_API(void) JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback, void *data); extern JS_PUBLIC_API(JSContext *) JS_NewContext(JSRuntime *rt, size_t stackChunkSize); extern JS_PUBLIC_API(void) JS_DestroyContext(JSContext *cx); extern JS_PUBLIC_API(void) JS_DestroyContextNoGC(JSContext *cx); extern JS_PUBLIC_API(void *) JS_GetContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetContextPrivate(JSContext *cx, void *data); extern JS_PUBLIC_API(void *) JS_GetSecondContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetSecondContextPrivate(JSContext *cx, void *data); extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); extern JS_PUBLIC_API(JSContext *) JS_ContextIterator(JSRuntime *rt, JSContext **iterp); extern JS_PUBLIC_API(JSVersion) JS_GetVersion(JSContext *cx); // Mutate the version on the compartment. This is generally discouraged, but // necessary to support the version mutation in the js and xpc shell command // set. // // It would be nice to put this in jsfriendapi, but the linkage requirements // of the shells make that impossible. JS_PUBLIC_API(void) JS_SetVersionForCompartment(JSCompartment *compartment, JSVersion version); extern JS_PUBLIC_API(const char *) JS_VersionToString(JSVersion version); extern JS_PUBLIC_API(JSVersion) JS_StringToVersion(const char *string); /* * JS options are orthogonal to version, and may be freely composed with one * another as well as with version. * * JSOPTION_VAROBJFIX is recommended -- see the comments associated with the * prototypes for JS_ExecuteScript, JS_EvaluateScript, etc. */ #define JSOPTION_EXTRA_WARNINGS JS_BIT(0) /* warn on dubious practices */ #define JSOPTION_WERROR JS_BIT(1) /* convert warning to error */ #define JSOPTION_VAROBJFIX JS_BIT(2) /* make JS_EvaluateScript use the last object on its 'obj' param's scope chain as the ECMA 'variables object' */ #define JSOPTION_PRIVATE_IS_NSISUPPORTS \ JS_BIT(3) /* context private data points to an nsISupports subclass */ #define JSOPTION_COMPILE_N_GO JS_BIT(4) /* caller of JS_Compile*Script promises to execute compiled script once only; enables compile-time scope chain resolution of consts. */ /* JS_BIT(5) is currently unused. */ /* JS_BIT(6) is currently unused. */ /* JS_BIT(7) is currently unused. */ #define JSOPTION_DONT_REPORT_UNCAUGHT \ JS_BIT(8) /* When returning from the outermost API call, prevent uncaught exceptions from being converted to error reports */ /* JS_BIT(9) is currently unused. */ /* JS_BIT(10) is currently unused. */ /* JS_BIT(11) is currently unused. */ #define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12) /* A promise to the compiler that a null rval out-param will be passed to each call to JS_ExecuteScript. */ #define JSOPTION_UNROOTED_GLOBAL JS_BIT(13) /* The GC will not root the contexts' default compartment object, leaving that up to the embedding. */ #define JSOPTION_BASELINE JS_BIT(14) /* Baseline compiler. */ #define JSOPTION_TYPE_INFERENCE JS_BIT(16) /* Perform type inference. */ #define JSOPTION_STRICT_MODE JS_BIT(17) /* Provides a way to force strict mode for all code without requiring "use strict" annotations. */ #define JSOPTION_ION JS_BIT(18) /* IonMonkey */ #define JSOPTION_ASMJS JS_BIT(19) /* optimizingasm.js compiler */ #define JSOPTION_MASK JS_BITMASK(20) extern JS_PUBLIC_API(uint32_t) JS_GetOptions(JSContext *cx); extern JS_PUBLIC_API(uint32_t) JS_SetOptions(JSContext *cx, uint32_t options); extern JS_PUBLIC_API(uint32_t) JS_ToggleOptions(JSContext *cx, uint32_t options); extern JS_PUBLIC_API(void) JS_SetJitHardening(JSRuntime *rt, JSBool enabled); extern JS_PUBLIC_API(const char *) JS_GetImplementationVersion(void); extern JS_PUBLIC_API(void) JS_SetDestroyCompartmentCallback(JSRuntime *rt, JSDestroyCompartmentCallback callback); extern JS_PUBLIC_API(void) JS_SetCompartmentNameCallback(JSRuntime *rt, JSCompartmentNameCallback callback); extern JS_PUBLIC_API(JSWrapObjectCallback) JS_SetWrapObjectCallbacks(JSRuntime *rt, JSWrapObjectCallback callback, JSSameCompartmentWrapObjectCallback sccallback, JSPreWrapCallback precallback); extern JS_PUBLIC_API(void) JS_SetCompartmentPrivate(JSCompartment *compartment, void *data); extern JS_PUBLIC_API(void *) JS_GetCompartmentPrivate(JSCompartment *compartment); extern JS_PUBLIC_API(JSBool) JS_WrapObject(JSContext *cx, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_WrapValue(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_WrapId(JSContext *cx, jsid *idp); extern JS_PUBLIC_API(JSObject *) JS_TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target); extern JS_FRIEND_API(JSObject *) js_TransplantObjectWithWrapper(JSContext *cx, JS::HandleObject origobj, JS::HandleObject origwrapper, JS::HandleObject targetobj, JS::HandleObject targetwrapper); extern JS_PUBLIC_API(JSBool) JS_RefreshCrossCompartmentWrappers(JSContext *cx, JSObject *ob); /* * At any time, a JSContext has a current (possibly-NULL) compartment. * Compartments are described in: * * developer.mozilla.org/en-US/docs/SpiderMonkey/SpiderMonkey_compartments * * The current compartment of a context may be changed. The preferred way to do * this is with JSAutoCompartment: * * void foo(JSContext *cx, JSObject *obj) { * // in some compartment 'c' * { * JSAutoCompartment ac(cx, obj); // constructor enters * // in the compartment of 'obj' * } // destructor leaves * // back in compartment 'c' * } * * For more complicated uses that don't neatly fit in a C++ stack frame, the * compartment can entered and left using separate function calls: * * void foo(JSContext *cx, JSObject *obj) { * // in 'oldCompartment' * JSCompartment *oldCompartment = JS_EnterCompartment(cx, obj); * // in the compartment of 'obj' * JS_LeaveCompartment(cx, oldCompartment); * // back in 'oldCompartment' * } * * Note: these calls must still execute in a LIFO manner w.r.t all other * enter/leave calls on the context. Furthermore, only the return value of a * JS_EnterCompartment call may be passed as the 'oldCompartment' argument of * the corresponding JS_LeaveCompartment call. */ class JS_PUBLIC_API(JSAutoCompartment) { JSContext *cx_; JSCompartment *oldCompartment_; public: JSAutoCompartment(JSContext *cx, JSObject *target); JSAutoCompartment(JSContext *cx, JSScript *target); ~JSAutoCompartment(); }; /* NB: This API is infallible; a NULL return value does not indicate error. */ extern JS_PUBLIC_API(JSCompartment *) JS_EnterCompartment(JSContext *cx, JSObject *target); extern JS_PUBLIC_API(void) JS_LeaveCompartment(JSContext *cx, JSCompartment *oldCompartment); typedef void (*JSIterateCompartmentCallback)(JSRuntime *rt, void *data, JSCompartment *compartment); /* * This function calls |compartmentCallback| on every compartment. Beware that * there is no guarantee that the compartment will survive after the callback * returns. */ extern JS_PUBLIC_API(void) JS_IterateCompartments(JSRuntime *rt, void *data, JSIterateCompartmentCallback compartmentCallback); /* * Initialize standard JS class constructors, prototypes, and any top-level * functions and constants associated with the standard classes (e.g. isNaN * for Number). * * NB: This sets cx's global object to obj if it was null. */ extern JS_PUBLIC_API(JSBool) JS_InitStandardClasses(JSContext *cx, JSObject *obj); /* * Resolve id, which must contain either a string or an int, to a standard * class name in obj if possible, defining the class's constructor and/or * prototype and storing true in *resolved. If id does not name a standard * class or a top-level property induced by initializing a standard class, * store false in *resolved and just return true. Return false on error, * as usual for JSBool result-typed API entry points. * * This API can be called directly from a global object class's resolve op, * to define standard classes lazily. The class's enumerate op should call * JS_EnumerateStandardClasses(cx, obj), to define eagerly during for..in * loops any classes not yet resolved lazily. */ extern JS_PUBLIC_API(JSBool) JS_ResolveStandardClass(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool *resolved); extern JS_PUBLIC_API(JSBool) JS_EnumerateStandardClasses(JSContext *cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSBool) JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_GetClassPrototype(JSContext *cx, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSProtoKey) JS_IdentifyClassPrototype(JSContext *cx, JSObject *obj); /* * Returns the original value of |Function.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetFunctionPrototype(JSContext *cx, JSObject *forObj); /* * Returns the original value of |Object.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetObjectPrototype(JSContext *cx, JSObject *forObj); /* * Returns the original value of |Array.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetArrayPrototype(JSContext *cx, JSObject *forObj); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_IsGlobalObject(JSObject *obj); /* * May return NULL, if |c| never had a global (e.g. the atoms compartment), or * if |c|'s global has been collected. */ extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForCompartmentOrNull(JSContext *cx, JSCompartment *c); namespace JS { extern JS_PUBLIC_API(JSObject *) CurrentGlobalOrNull(JSContext *cx); } /* * This method returns the global corresponding to the most recent scripted * frame, which may not match the cx's current compartment. This is extremely * dangerous, because it can bypass compartment security invariants in subtle * ways. To use it safely, the caller must perform a subsequent security * check. There is currently only one consumer of this function in Gecko, and * it should probably stay that way. If you'd like to use it, please consult * the XPConnect module owner first. */ extern JS_PUBLIC_API(JSObject *) JS_GetScriptedGlobal(JSContext *cx); /* * Initialize the 'Reflect' object on a global object. */ extern JS_PUBLIC_API(JSObject *) JS_InitReflect(JSContext *cx, JSObject *global); #ifdef JS_HAS_CTYPES /* * Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes' * object will be sealed. */ extern JS_PUBLIC_API(JSBool) JS_InitCTypesClass(JSContext *cx, JSObject *global); /* * Convert a unicode string 'source' of length 'slen' to the platform native * charset, returning a null-terminated string allocated with JS_malloc. On * failure, this function should report an error. */ typedef char * (* JSCTypesUnicodeToNativeFun)(JSContext *cx, const jschar *source, size_t slen); /* * Set of function pointers that ctypes can use for various internal functions. * See JS_SetCTypesCallbacks below. Providing NULL for a function is safe, * and will result in the applicable ctypes functionality not being available. */ struct JSCTypesCallbacks { JSCTypesUnicodeToNativeFun unicodeToNative; }; typedef struct JSCTypesCallbacks JSCTypesCallbacks; /* * Set the callbacks on the provided 'ctypesObj' object. 'callbacks' should be a * pointer to static data that exists for the lifetime of 'ctypesObj', but it * may safely be altered after calling this function and without having * to call this function again. */ extern JS_PUBLIC_API(void) JS_SetCTypesCallbacks(JSObject *ctypesObj, JSCTypesCallbacks *callbacks); #endif typedef JSBool (* JSEnumerateDiagnosticMemoryCallback)(void *ptr, size_t length); /* * Enumerate memory regions that contain diagnostic information * intended to be included in crash report minidumps. */ extern JS_PUBLIC_API(void) JS_EnumerateDiagnosticMemoryRegions(JSEnumerateDiagnosticMemoryCallback callback); extern JS_PUBLIC_API(void *) JS_malloc(JSContext *cx, size_t nbytes); extern JS_PUBLIC_API(void *) JS_realloc(JSContext *cx, void *p, size_t nbytes); /* * A wrapper for js_free(p) that may delay js_free(p) invocation as a * performance optimization. * cx may be NULL. */ extern JS_PUBLIC_API(void) JS_free(JSContext *cx, void *p); /* * A wrapper for js_free(p) that may delay js_free(p) invocation as a * performance optimization as specified by the given JSFreeOp instance. */ extern JS_PUBLIC_API(void) JS_freeop(JSFreeOp *fop, void *p); extern JS_PUBLIC_API(JSFreeOp *) JS_GetDefaultFreeOp(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_updateMallocCounter(JSContext *cx, size_t nbytes); extern JS_PUBLIC_API(char *) JS_strdup(JSContext *cx, const char *s); /* Duplicate a string. Does not report an error on failure. */ extern JS_PUBLIC_API(char *) JS_strdup(JSRuntime *rt, const char *s); /* * A GC root is a pointer to a jsval, JSObject * or JSString * that itself * points into the GC heap. JS_AddValueRoot takes a pointer to a jsval and * JS_AddGCThingRoot takes a pointer to a JSObject * or JString *. * * Note that, since JS_Add*Root stores the address of a variable (of type * jsval, JSString *, or JSObject *), that variable must live until * JS_Remove*Root is called to remove that variable. For example, after: * * void some_function() { * jsval v; * JS_AddNamedValueRoot(cx, &v, "name"); * * the caller must perform * * JS_RemoveValueRoot(cx, &v); * * before some_function() returns. * * Also, use JS_AddNamed*Root(cx, &structPtr->memberObj, "structPtr->memberObj") * in preference to JS_Add*Root(cx, &structPtr->memberObj), in order to identify * roots by their source callsites. This way, you can find the callsite while * debugging if you should fail to do JS_Remove*Root(cx, &structPtr->memberObj) * before freeing structPtr's memory. */ extern JS_PUBLIC_API(JSBool) JS_AddValueRoot(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_AddStringRoot(JSContext *cx, JSString **rp); extern JS_PUBLIC_API(JSBool) JS_AddObjectRoot(JSContext *cx, JSObject **rp); #ifdef NAME_ALL_GC_ROOTS #define JS_DEFINE_TO_TOKEN(def) #def #define JS_DEFINE_TO_STRING(def) JS_DEFINE_TO_TOKEN(def) #define JS_AddValueRoot(cx,vp) JS_AddNamedValueRoot((cx), (vp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #define JS_AddStringRoot(cx,rp) JS_AddNamedStringRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #define JS_AddObjectRoot(cx,rp) JS_AddNamedObjectRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #endif extern JS_PUBLIC_API(JSBool) JS_AddNamedValueRoot(JSContext *cx, jsval *vp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedValueRootRT(JSRuntime *rt, jsval *vp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedStringRoot(JSContext *cx, JSString **rp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedObjectRoot(JSContext *cx, JSObject **rp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedScriptRoot(JSContext *cx, JSScript **rp, const char *name); extern JS_PUBLIC_API(void) JS_RemoveValueRoot(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(void) JS_RemoveStringRoot(JSContext *cx, JSString **rp); extern JS_PUBLIC_API(void) JS_RemoveObjectRoot(JSContext *cx, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRoot(JSContext *cx, JSScript **rp); extern JS_PUBLIC_API(void) JS_RemoveValueRootRT(JSRuntime *rt, jsval *vp); extern JS_PUBLIC_API(void) JS_RemoveStringRootRT(JSRuntime *rt, JSString **rp); extern JS_PUBLIC_API(void) JS_RemoveObjectRootRT(JSRuntime *rt, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRootRT(JSRuntime *rt, JSScript **rp); /* TODO: remove these APIs */ extern JS_FRIEND_API(void) js_RemoveRoot(JSRuntime *rt, void *rp); /* * C-compatible version of the Anchor class. It should be called after the last * use of the variable it protects. */ extern JS_NEVER_INLINE JS_PUBLIC_API(void) JS_AnchorPtr(void *p); /* * Register externally maintained GC roots. * * traceOp: the trace operation. For each root the implementation should call * JS_CallTracer whenever the root contains a traceable thing. * data: the data argument to pass to each invocation of traceOp. */ extern JS_PUBLIC_API(JSBool) JS_AddExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); /* Undo a call to JS_AddExtraGCRootsTracer. */ extern JS_PUBLIC_API(void) JS_RemoveExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); /* * JS_CallTracer API and related macros for implementors of JSTraceOp, to * enumerate all references to traceable things reachable via a property or * other strong ref identified for debugging purposes by name or index or * a naming callback. * * See the JSTraceOp typedef. */ /* * Use the following macros to check if a particular jsval is a traceable * thing and to extract the thing and its kind to pass to JS_CallTracer. */ static JS_ALWAYS_INLINE JSBool JSVAL_IS_TRACEABLE(jsval v) { return JSVAL_IS_TRACEABLE_IMPL(JSVAL_TO_IMPL(v)); } static JS_ALWAYS_INLINE void * JSVAL_TO_TRACEABLE(jsval v) { return JSVAL_TO_GCTHING(v); } static JS_ALWAYS_INLINE JSGCTraceKind JSVAL_TRACE_KIND(jsval v) { JS_ASSERT(JSVAL_IS_GCTHING(v)); return (JSGCTraceKind) JSVAL_TRACE_KIND_IMPL(JSVAL_TO_IMPL(v)); } /* * Tracer callback, called for each traceable thing directly referenced by a * particular object or runtime structure. It is the callback responsibility * to ensure the traversal of the full object graph via calling eventually * JS_TraceChildren on the passed thing. In this case the callback must be * prepared to deal with cycles in the traversal graph. * * kind argument is one of JSTRACE_OBJECT, JSTRACE_STRING or a tag denoting * internal implementation-specific traversal kind. In the latter case the only * operations on thing that the callback can do is to call JS_TraceChildren or * JS_GetTraceThingInfo. * * If eagerlyTraceWeakMaps is true, when we trace a WeakMap visit all * of its mappings. This should be used in cases where the tracer * wants to use the existing liveness of entries. */ typedef void (* JSTraceCallback)(JSTracer *trc, void **thingp, JSGCTraceKind kind); enum WeakMapTraceKind { DoNotTraceWeakMaps = 0, TraceWeakMapValues = 1, TraceWeakMapKeysValues = 2 }; struct JSTracer { JSRuntime *runtime; JSTraceCallback callback; JSTraceNamePrinter debugPrinter; const void *debugPrintArg; size_t debugPrintIndex; WeakMapTraceKind eagerlyTraceWeakMaps; #ifdef JS_GC_ZEAL void *realLocation; #endif }; /* * Set debugging information about a reference to a traceable thing to prepare * for the following call to JS_CallTracer. * * When printer is null, arg must be const char * or char * C string naming * the reference and index must be either (size_t)-1 indicating that the name * alone describes the reference or it must be an index into some array vector * that stores the reference. * * When printer callback is not null, the arg and index arguments are * available to the callback as debugPrintArg and debugPrintIndex fields * of JSTracer. * * The storage for name or callback's arguments needs to live only until * the following call to JS_CallTracer returns. */ # define JS_SET_TRACING_DETAILS(trc, printer, arg, index) \ JS_BEGIN_MACRO \ (trc)->debugPrinter = (printer); \ (trc)->debugPrintArg = (arg); \ (trc)->debugPrintIndex = (index); \ JS_END_MACRO /* * Sets the real location for a marked reference, when passing the address * directly is not feasable. * * FIXME: This is currently overcomplicated by our need to nest calls for Values * stored as keys in hash tables, but will get simplified once we can rekey * in-place. */ #ifdef JS_GC_ZEAL # define JS_SET_TRACING_LOCATION(trc, location) \ JS_BEGIN_MACRO \ if (!(trc)->realLocation || !(location)) \ (trc)->realLocation = (location); \ JS_END_MACRO # define JS_UNSET_TRACING_LOCATION(trc) \ JS_BEGIN_MACRO \ (trc)->realLocation = NULL; \ JS_END_MACRO #else # define JS_SET_TRACING_LOCATION(trc, location) \ JS_BEGIN_MACRO \ JS_END_MACRO # define JS_UNSET_TRACING_LOCATION(trc) \ JS_BEGIN_MACRO \ JS_END_MACRO #endif /* * Convenience macro to describe the argument of JS_CallTracer using C string * and index. */ # define JS_SET_TRACING_INDEX(trc, name, index) \ JS_SET_TRACING_DETAILS(trc, NULL, name, index) /* * Convenience macro to describe the argument of JS_CallTracer using C string. */ # define JS_SET_TRACING_NAME(trc, name) \ JS_SET_TRACING_DETAILS(trc, NULL, name, (size_t)-1) /* * The JS_Call*Tracer family of functions traces the given GC thing reference. * This performs the tracing action configured on the given JSTracer: * typically calling the JSTracer::callback or marking the thing as live. * * The argument to JS_Call*Tracer is an in-out param: when the function * returns, the garbage collector might have moved the GC thing. In this case, * the reference passed to JS_Call*Tracer will be updated to the object's new * location. Callers of this method are responsible for updating any state * that is dependent on the object's address. For example, if the object's * address is used as a key in a hashtable, then the object must be removed * and re-inserted with the correct hash. */ extern JS_PUBLIC_API(void) JS_CallValueTracer(JSTracer *trc, JS::Value *valuep, const char *name); extern JS_PUBLIC_API(void) JS_CallIdTracer(JSTracer *trc, jsid *idp, const char *name); extern JS_PUBLIC_API(void) JS_CallObjectTracer(JSTracer *trc, JSObject **objp, const char *name); extern JS_PUBLIC_API(void) JS_CallStringTracer(JSTracer *trc, JSString **strp, const char *name); extern JS_PUBLIC_API(void) JS_CallScriptTracer(JSTracer *trc, JSScript **scriptp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapValueTracer(JSTracer *trc, JS::Heap *valuep, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapIdTracer(JSTracer *trc, JS::Heap *idp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapObjectTracer(JSTracer *trc, JS::Heap *objp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapStringTracer(JSTracer *trc, JS::Heap *strp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapScriptTracer(JSTracer *trc, JS::Heap *scriptp, const char *name); template inline void JS_CallHashSetObjectTracer(JSTracer *trc, HashSetEnum &e, JSObject *const &key, const char *name) { JSObject *updated = key; JS_SET_TRACING_LOCATION(trc, reinterpret_cast(&const_cast(key))); JS_CallObjectTracer(trc, &updated, name); if (updated != key) e.rekeyFront(key, updated); } /* * Trace an object that is known to always be tenured. No post barriers are * required in this case. */ extern JS_PUBLIC_API(void) JS_CallTenuredObjectTracer(JSTracer *trc, JS::TenuredHeap *objp, const char *name); /* * API for JSTraceCallback implementations. */ extern JS_PUBLIC_API(void) JS_TracerInit(JSTracer *trc, JSRuntime *rt, JSTraceCallback callback); extern JS_PUBLIC_API(void) JS_TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind); extern JS_PUBLIC_API(void) JS_TraceRuntime(JSTracer *trc); extern JS_PUBLIC_API(void) JS_GetTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing, JSGCTraceKind kind, JSBool includeDetails); extern JS_PUBLIC_API(const char *) JS_GetTraceEdgeName(JSTracer *trc, char *buffer, int bufferSize); #ifdef DEBUG /* * DEBUG-only method to dump the object graph of heap-allocated things. * * fp: file for the dump output. * start: when non-null, dump only things reachable from start * thing. Otherwise dump all things reachable from the * runtime roots. * startKind: trace kind of start if start is not null. Must be * JSTRACE_OBJECT when start is null. * thingToFind: dump only paths in the object graph leading to thingToFind * when non-null. * maxDepth: the upper bound on the number of edges to descend from the * graph roots. * thingToIgnore: thing to ignore during the graph traversal when non-null. */ extern JS_PUBLIC_API(JSBool) JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind kind, void *thingToFind, size_t maxDepth, void *thingToIgnore); #endif /* * Garbage collector API. */ extern JS_PUBLIC_API(void) JS_GC(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_MaybeGC(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetGCCallback(JSRuntime *rt, JSGCCallback cb, void *data); extern JS_PUBLIC_API(void) JS_SetFinalizeCallback(JSRuntime *rt, JSFinalizeCallback cb); extern JS_PUBLIC_API(JSBool) JS_IsGCMarkingTracer(JSTracer *trc); /* * JS_IsAboutToBeFinalized checks if the given object is going to be finalized * at the end of the current GC. When called outside of the context of a GC, * this function will return false. Typically this function is used on weak * references, where the reference should be nulled out or destroyed if the * given object is about to be finalized. * * The argument to JS_IsAboutToBeFinalized is an in-out param: when the * function returns false, the object being referenced is still alive, but the * garbage collector might have moved it. In this case, the reference passed * to JS_IsAboutToBeFinalized will be updated to the object's new location. * Callers of this method are responsible for updating any state that is * dependent on the object's address. For example, if the object's address is * used as a key in a hashtable, then the object must be removed and * re-inserted with the correct hash. */ extern JS_PUBLIC_API(JSBool) JS_IsAboutToBeFinalized(JS::Heap *objp); extern JS_PUBLIC_API(JSBool) JS_IsAboutToBeFinalizedUnbarriered(JSObject **objp); typedef enum JSGCParamKey { /* Maximum nominal heap before last ditch GC. */ JSGC_MAX_BYTES = 0, /* Number of JS_malloc bytes before last ditch GC. */ JSGC_MAX_MALLOC_BYTES = 1, /* Amount of bytes allocated by the GC. */ JSGC_BYTES = 3, /* Number of times when GC was invoked. */ JSGC_NUMBER = 4, /* Max size of the code cache in bytes. */ JSGC_MAX_CODE_CACHE_BYTES = 5, /* Select GC mode. */ JSGC_MODE = 6, /* Number of cached empty GC chunks. */ JSGC_UNUSED_CHUNKS = 7, /* Total number of allocated GC chunks. */ JSGC_TOTAL_CHUNKS = 8, /* Max milliseconds to spend in an incremental GC slice. */ JSGC_SLICE_TIME_BUDGET = 9, /* Maximum size the GC mark stack can grow to. */ JSGC_MARK_STACK_LIMIT = 10, /* * GCs less than this far apart in time will be considered 'high-frequency GCs'. * See setGCLastBytes in jsgc.cpp. */ JSGC_HIGH_FREQUENCY_TIME_LIMIT = 11, /* Start of dynamic heap growth. */ JSGC_HIGH_FREQUENCY_LOW_LIMIT = 12, /* End of dynamic heap growth. */ JSGC_HIGH_FREQUENCY_HIGH_LIMIT = 13, /* Upper bound of heap growth. */ JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX = 14, /* Lower bound of heap growth. */ JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN = 15, /* Heap growth for low frequency GCs. */ JSGC_LOW_FREQUENCY_HEAP_GROWTH = 16, /* * If false, the heap growth factor is fixed at 3. If true, it is determined * based on whether GCs are high- or low- frequency. */ JSGC_DYNAMIC_HEAP_GROWTH = 17, /* If true, high-frequency GCs will use a longer mark slice. */ JSGC_DYNAMIC_MARK_SLICE = 18, /* Number of megabytes of analysis data to allocate before purging. */ JSGC_ANALYSIS_PURGE_TRIGGER = 19, /* Lower limit after which we limit the heap growth. */ JSGC_ALLOCATION_THRESHOLD = 20, /* * We decommit memory lazily. If more than this number of megabytes is * available to be decommitted, then JS_MaybeGC will trigger a shrinking GC * to decommit it. */ JSGC_DECOMMIT_THRESHOLD = 21 } JSGCParamKey; typedef enum JSGCMode { /* Perform only global GCs. */ JSGC_MODE_GLOBAL = 0, /* Perform per-compartment GCs until too much garbage has accumulated. */ JSGC_MODE_COMPARTMENT = 1, /* * Collect in short time slices rather than all at once. Implies * JSGC_MODE_COMPARTMENT. */ JSGC_MODE_INCREMENTAL = 2 } JSGCMode; extern JS_PUBLIC_API(void) JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32_t value); extern JS_PUBLIC_API(uint32_t) JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key); extern JS_PUBLIC_API(void) JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32_t value); extern JS_PUBLIC_API(uint32_t) JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key); /* * Create a new JSString whose chars member refers to external memory, i.e., * memory requiring application-specific finalization. */ extern JS_PUBLIC_API(JSString *) JS_NewExternalString(JSContext *cx, const jschar *chars, size_t length, const JSStringFinalizer *fin); /* * Return whether 'str' was created with JS_NewExternalString or * JS_NewExternalStringWithClosure. */ extern JS_PUBLIC_API(JSBool) JS_IsExternalString(JSString *str); /* * Return the 'closure' arg passed to JS_NewExternalStringWithClosure or NULL * if the external string was created via JS_NewExternalString. */ extern JS_PUBLIC_API(const JSStringFinalizer *) JS_GetExternalStringFinalizer(JSString *str); /* * Set the size of the native stack that should not be exceed. To disable * stack size checking pass 0. */ extern JS_PUBLIC_API(void) JS_SetNativeStackQuota(JSRuntime *cx, size_t stackSize); /************************************************************************/ /* * Classes, objects, and properties. */ typedef void (*JSClassInternal)(); struct JSClass { const char *name; uint32_t flags; /* Mandatory function pointer members. */ JSPropertyOp addProperty; JSDeletePropertyOp delProperty; JSPropertyOp getProperty; JSStrictPropertyOp setProperty; JSEnumerateOp enumerate; JSResolveOp resolve; JSConvertOp convert; /* Optional members (may be null). */ JSFinalizeOp finalize; JSCheckAccessOp checkAccess; JSNative call; JSHasInstanceOp hasInstance; JSNative construct; JSTraceOp trace; void *reserved[40]; }; #define JSCLASS_HAS_PRIVATE (1<<0) /* objects have private slot */ #define JSCLASS_NEW_ENUMERATE (1<<1) /* has JSNewEnumerateOp hook */ #define JSCLASS_NEW_RESOLVE (1<<2) /* has JSNewResolveOp hook */ #define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) /* private is (nsISupports *) */ #define JSCLASS_IS_DOMJSCLASS (1<<4) /* objects are DOM */ #define JSCLASS_IMPLEMENTS_BARRIERS (1<<5) /* Correctly implements GC read and write barriers */ #define JSCLASS_EMULATES_UNDEFINED (1<<6) /* objects of this class act like the value undefined, in some contexts */ #define JSCLASS_USERBIT1 (1<<7) /* Reserved for embeddings. */ /* * To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise-or * JSCLASS_HAS_RESERVED_SLOTS(n) into the initializer for JSClass.flags, where * n is a constant in [1, 255]. Reserved slots are indexed from 0 to n-1. */ #define JSCLASS_RESERVED_SLOTS_SHIFT 8 /* room for 8 flags below */ #define JSCLASS_RESERVED_SLOTS_WIDTH 8 /* and 16 above this field */ #define JSCLASS_RESERVED_SLOTS_MASK JS_BITMASK(JSCLASS_RESERVED_SLOTS_WIDTH) #define JSCLASS_HAS_RESERVED_SLOTS(n) (((n) & JSCLASS_RESERVED_SLOTS_MASK) \ << JSCLASS_RESERVED_SLOTS_SHIFT) #define JSCLASS_RESERVED_SLOTS(clasp) (((clasp)->flags \ >> JSCLASS_RESERVED_SLOTS_SHIFT) \ & JSCLASS_RESERVED_SLOTS_MASK) #define JSCLASS_HIGH_FLAGS_SHIFT (JSCLASS_RESERVED_SLOTS_SHIFT + \ JSCLASS_RESERVED_SLOTS_WIDTH) #define JSCLASS_IS_ANONYMOUS (1<<(JSCLASS_HIGH_FLAGS_SHIFT+0)) #define JSCLASS_IS_GLOBAL (1<<(JSCLASS_HIGH_FLAGS_SHIFT+1)) #define JSCLASS_INTERNAL_FLAG2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2)) #define JSCLASS_INTERNAL_FLAG3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+3)) /* Indicate whether the proto or ctor should be frozen. */ #define JSCLASS_FREEZE_PROTO (1<<(JSCLASS_HIGH_FLAGS_SHIFT+4)) #define JSCLASS_FREEZE_CTOR (1<<(JSCLASS_HIGH_FLAGS_SHIFT+5)) /* Reserved for embeddings. */ #define JSCLASS_USERBIT2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+6)) #define JSCLASS_USERBIT3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+7)) #define JSCLASS_BACKGROUND_FINALIZE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+8)) /* * Bits 26 through 31 are reserved for the CACHED_PROTO_KEY mechanism, see * below. */ /* Global flags. */ #define JSGLOBAL_FLAGS_CLEARED 0x1 /* * ECMA-262 requires that most constructors used internally create objects * with "the original Foo.prototype value" as their [[Prototype]] (__proto__) * member initial value. The "original ... value" verbiage is there because * in ECMA-262, global properties naming class objects are read/write and * deleteable, for the most part. * * Implementing this efficiently requires that global objects have classes * with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS was * prevously allowed, but is now an ES5 violation and thus unsupported. */ #define JSCLASS_GLOBAL_SLOT_COUNT (JSProto_LIMIT * 3 + 25) #define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \ (JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n))) #define JSCLASS_GLOBAL_FLAGS \ JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(0) #define JSCLASS_HAS_GLOBAL_FLAG_AND_SLOTS(clasp) \ (((clasp)->flags & JSCLASS_IS_GLOBAL) \ && JSCLASS_RESERVED_SLOTS(clasp) >= JSCLASS_GLOBAL_SLOT_COUNT) /* Fast access to the original value of each standard class's prototype. */ #define JSCLASS_CACHED_PROTO_SHIFT (JSCLASS_HIGH_FLAGS_SHIFT + 10) #define JSCLASS_CACHED_PROTO_WIDTH 6 #define JSCLASS_CACHED_PROTO_MASK JS_BITMASK(JSCLASS_CACHED_PROTO_WIDTH) #define JSCLASS_HAS_CACHED_PROTO(key) (uint32_t(key) << JSCLASS_CACHED_PROTO_SHIFT) #define JSCLASS_CACHED_PROTO_KEY(clasp) ((JSProtoKey) \ (((clasp)->flags \ >> JSCLASS_CACHED_PROTO_SHIFT) \ & JSCLASS_CACHED_PROTO_MASK)) /* Initializer for unused members of statically initialized JSClass structs. */ #define JSCLASS_NO_INTERNAL_MEMBERS {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} #define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,JSCLASS_NO_INTERNAL_MEMBERS extern JS_PUBLIC_API(int) JS_IdArrayLength(JSContext *cx, JSIdArray *ida); extern JS_PUBLIC_API(jsid) JS_IdArrayGet(JSContext *cx, JSIdArray *ida, int index); extern JS_PUBLIC_API(void) JS_DestroyIdArray(JSContext *cx, JSIdArray *ida); namespace JS { class AutoIdArray : private AutoGCRooter { public: AutoIdArray(JSContext *cx, JSIdArray *ida MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, IDARRAY), context(cx), idArray(ida) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~AutoIdArray() { if (idArray) JS_DestroyIdArray(context, idArray); } bool operator!() { return !idArray; } jsid operator[](size_t i) const { JS_ASSERT(idArray); JS_ASSERT(i < length()); return JS_IdArrayGet(context, idArray, i); } size_t length() const { return JS_IdArrayLength(context, idArray); } friend void AutoGCRooter::trace(JSTracer *trc); JSIdArray *steal() { JSIdArray *copy = idArray; idArray = NULL; return copy; } protected: inline void trace(JSTracer *trc); private: JSContext *context; JSIdArray *idArray; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER /* No copy or assignment semantics. */ AutoIdArray(AutoIdArray &ida) MOZ_DELETE; void operator=(AutoIdArray &ida) MOZ_DELETE; }; } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_ValueToId(JSContext *cx, jsval v, jsid *idp); extern JS_PUBLIC_API(JSBool) JS_IdToValue(JSContext *cx, jsid id, jsval *vp); /* * JSNewResolveOp flag bits. */ #define JSRESOLVE_ASSIGNING 0x01 /* resolve on the left of assignment */ /* * Invoke the [[DefaultValue]] hook (see ES5 8.6.2) with the provided hint on * the specified object, computing a primitive default value for the object. * The hint must be JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_VOID (no hint). On * success the resulting value is stored in *vp. */ extern JS_PUBLIC_API(JSBool) JS_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_PropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_StrictPropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool strict, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool *succeeded); extern JS_PUBLIC_API(JSBool) JS_EnumerateStub(JSContext *cx, JS::Handle obj); extern JS_PUBLIC_API(JSBool) JS_ResolveStub(JSContext *cx, JS::Handle obj, JS::Handle id); extern JS_PUBLIC_API(JSBool) JS_ConvertStub(JSContext *cx, JS::Handle obj, JSType type, JS::MutableHandle vp); struct JSConstDoubleSpec { double dval; const char *name; uint8_t flags; uint8_t spare[3]; }; typedef struct JSJitInfo JSJitInfo; /* * Wrappers to replace {Strict,}PropertyOp for JSPropertySpecs. This will allow * us to pass one JSJitInfo per function with the property spec, without * additional field overhead. */ typedef struct JSStrictPropertyOpWrapper { JSStrictPropertyOp op; const JSJitInfo *info; } JSStrictPropertyOpWrapper; typedef struct JSPropertyOpWrapper { JSPropertyOp op; const JSJitInfo *info; } JSPropertyOpWrapper; /* * Wrapper to do as above, but for JSNatives for JSFunctionSpecs. */ typedef struct JSNativeWrapper { JSNative op; const JSJitInfo *info; } JSNativeWrapper; /* * Macro static initializers which make it easy to pass no JSJitInfo as part of a * JSPropertySpec or JSFunctionSpec. */ #define JSOP_WRAPPER(op) {op, NULL} #define JSOP_NULLWRAPPER JSOP_WRAPPER(NULL) /* * To define an array element rather than a named property member, cast the * element's index to (const char *) and initialize name with it, and set the * JSPROP_INDEX bit in flags. */ struct JSPropertySpec { const char *name; int8_t tinyid; uint8_t flags; JSPropertyOpWrapper getter; JSStrictPropertyOpWrapper setter; }; namespace JS { namespace detail { /* NEVER DEFINED, DON'T USE. For use by JS_CAST_NATIVE_TO only. */ inline int CheckIsNative(JSNative native); } // namespace detail } // namespace JS #define JS_CAST_NATIVE_TO(v, To) \ (static_cast(sizeof(JS::detail::CheckIsNative(v))), \ reinterpret_cast(v)) /* * JSPropertySpec uses JSAPI JSPropertyOp and JSStrictPropertyOp in function * signatures, but with JSPROP_NATIVE_ACCESSORS the actual values must be * JSNatives. To avoid widespread casting, have JS_PSG and JS_PSGS perform * type-safe casts. */ #define JS_PSG(name, getter, flags) \ {name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(getter, JSPropertyOp)), \ JSOP_NULLWRAPPER} #define JS_PSGS(name, getter, setter, flags) \ {name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(getter, JSPropertyOp)), \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(setter, JSStrictPropertyOp))} #define JS_PS_END {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} /* * To define a native function, set call to a JSNativeWrapper. To define a * self-hosted function, set selfHostedName to the name of a function * compiled during JSRuntime::initSelfHosting. */ struct JSFunctionSpec { const char *name; JSNativeWrapper call; uint16_t nargs; uint16_t flags; const char *selfHostedName; }; /* * Terminating sentinel initializer to put at the end of a JSFunctionSpec array * that's passed to JS_DefineFunctions or JS_InitClass. */ #define JS_FS_END JS_FS(NULL,NULL,0,0) /* * Initializer macros for a JSFunctionSpec array element. JS_FN (whose name * pays homage to the old JSNative/JSFastNative split) simply adds the flag * JSFUN_STUB_GSOPS. JS_FNINFO allows the simple adding of JSJitInfos. */ #define JS_FS(name,call,nargs,flags) \ {name, JSOP_WRAPPER(call), nargs, flags} #define JS_FN(name,call,nargs,flags) \ {name, JSOP_WRAPPER(call), nargs, (flags) | JSFUN_STUB_GSOPS} #define JS_FNINFO(name,call,info,nargs,flags) \ {name,{call,info},nargs,flags} extern JS_PUBLIC_API(JSObject *) JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto, JSClass *clasp, JSNative constructor, unsigned nargs, const JSPropertySpec *ps, const JSFunctionSpec *fs, const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs); /* * Set up ctor.prototype = proto and proto.constructor = ctor with the * right property flags. */ extern JS_PUBLIC_API(JSBool) JS_LinkConstructorAndPrototype(JSContext *cx, JSObject *ctor, JSObject *proto); extern JS_PUBLIC_API(JSClass *) JS_GetClass(JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); extern JS_PUBLIC_API(void *) JS_GetPrivate(JSObject *obj); extern JS_PUBLIC_API(void) JS_SetPrivate(JSObject *obj, void *data); extern JS_PUBLIC_API(void *) JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) JS_GetPrototype(JSContext *cx, JS::Handle obj, JS::MutableHandle protop); extern JS_PUBLIC_API(JSBool) JS_SetPrototype(JSContext *cx, JS::Handle obj, JS::Handle proto); extern JS_PUBLIC_API(JSObject *) JS_GetParent(JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent); extern JS_PUBLIC_API(JSObject *) JS_GetConstructor(JSContext *cx, JSObject *proto); /* * Get a unique identifier for obj, good for the lifetime of obj (even if it * is moved by a copying GC). Return false on failure (likely out of memory), * and true with *idp containing the unique id on success. */ extern JS_PUBLIC_API(JSBool) JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp); namespace JS { enum { FreshZone, SystemZone, SpecificZones }; typedef uintptr_t ZoneSpecifier; inline ZoneSpecifier SameZoneAs(JSObject *obj) { JS_ASSERT(uintptr_t(obj) > SpecificZones); return ZoneSpecifier(obj); } struct JS_PUBLIC_API(CompartmentOptions) { ZoneSpecifier zoneSpec; JSVersion version; bool invisibleToDebugger; explicit CompartmentOptions() : zoneSpec(JS::FreshZone) , version(JSVERSION_UNKNOWN) , invisibleToDebugger(false) {} CompartmentOptions &setZone(ZoneSpecifier spec) { zoneSpec = spec; return *this; } CompartmentOptions &setVersion(JSVersion version_) { JS_ASSERT(version_ != JSVERSION_UNKNOWN); version = version_; return *this; } // Certain scopes (i.e. XBL compilation scopes) are implementation details // of the embedding, and references to them should never leak out to script. // This flag causes the this compartment to skip firing onNewGlobalObject // and makes addDebuggee a no-op for this global. CompartmentOptions &setInvisibleToDebugger(bool invisible) { invisibleToDebugger = invisible; return *this; } }; // During global creation, we fire notifications to callbacks registered // via the Debugger API. These callbacks are arbitrary script, and can touch // the global in arbitrary ways. When that happens, the global should not be // in a half-baked state. But this creates a problem for consumers that need // to set slots on the global to put it in a consistent state. // // This API provides a way for consumers to set slots atomically (immediately // after the global is created), before any debugger hooks are fired. It's // unfortunately on the clunky side, but that's the way the cookie crumbles. // // If callers have no additional state on the global to set up, they may pass // |FireOnNewGlobalHook| to JS_NewGlobalObject, which causes that function to // fire the hook as its final act before returning. Otherwise, callers should // pass |DontFireOnNewGlobalHook|, which means that they are responsible for // invoking JS_FireOnNewGlobalObject upon successfully creating the global. If // an error occurs and the operation aborts, callers should skip firing the // hook. But otherwise, callers must take care to fire the hook exactly once // before compiling any script in the global's scope (we have assertions in // place to enforce this). This lets us be sure that debugger clients never miss // breakpoints. enum OnNewGlobalHookOption { FireOnNewGlobalHook, DontFireOnNewGlobalHook }; } /* namespace JS */ extern JS_PUBLIC_API(JSObject *) JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals, JS::OnNewGlobalHookOption hookOption, const JS::CompartmentOptions &options = JS::CompartmentOptions()); extern JS_PUBLIC_API(void) JS_FireOnNewGlobalObject(JSContext *cx, JS::HandleObject global); extern JS_PUBLIC_API(JSObject *) JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); /* Queries the [[Extensible]] property of the object. */ extern JS_PUBLIC_API(JSBool) JS_IsExtensible(JSContext *cx, JS::HandleObject obj, JSBool *extensible); extern JS_PUBLIC_API(JSBool) JS_IsNative(JSObject *obj); extern JS_PUBLIC_API(JSRuntime *) JS_GetObjectRuntime(JSObject *obj); /* * Unlike JS_NewObject, JS_NewObjectWithGivenProto does not compute a default * proto if proto's actual parameter value is null. */ extern JS_PUBLIC_API(JSObject *) JS_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); /* * Freeze obj, and all objects it refers to, recursively. This will not recurse * through non-extensible objects, on the assumption that those are already * deep-frozen. */ extern JS_PUBLIC_API(JSBool) JS_DeepFreezeObject(JSContext *cx, JSObject *obj); /* * Freezes an object; see ES5's Object.freeze(obj) method. */ extern JS_PUBLIC_API(JSBool) JS_FreezeObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_PreventExtensions(JSContext *cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSObject *) JS_New(JSContext *cx, JSObject *ctor, unsigned argc, jsval *argv); extern JS_PUBLIC_API(JSObject *) JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *clasp, JSObject *proto, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefineConstDoubles(JSContext *cx, JSObject *obj, const JSConstDoubleSpec *cds); extern JS_PUBLIC_API(JSBool) JS_DefineProperties(JSContext *cx, JSObject *obj, const JSPropertySpec *ps); extern JS_PUBLIC_API(JSBool) JS_DefineProperty(JSContext *cx, JSObject *obj, const char *name, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer * is not null). */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *obj, const char *name, int8_t tinyid, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, unsigned flags, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject **objp, JS::MutableHandle vp); struct JSPropertyDescriptor { JSObject *obj; unsigned attrs; unsigned shortid; JSPropertyOp getter; JSStrictPropertyOp setter; JS::Value value; JSPropertyDescriptor() : obj(NULL), attrs(0), shortid(0), getter(NULL), setter(NULL), value(JSVAL_VOID) {} void trace(JSTracer *trc); }; namespace JS { template class PropertyDescriptorOperations { const JSPropertyDescriptor * desc() const { return static_cast(this)->extract(); } JSPropertyDescriptor * desc() { return static_cast(this)->extract(); } public: bool isEnumerable() const { return desc()->attrs & JSPROP_ENUMERATE; } bool isReadonly() const { return desc()->attrs & JSPROP_READONLY; } bool isPermanent() const { return desc()->attrs & JSPROP_PERMANENT; } bool hasNativeAccessors() const { return desc()->attrs & JSPROP_NATIVE_ACCESSORS; } bool hasGetterObject() const { return desc()->attrs & JSPROP_GETTER; } bool hasSetterObject() const { return desc()->attrs & JSPROP_SETTER; } bool isShared() const { return desc()->attrs & JSPROP_SHARED; } bool isIndex() const { return desc()->attrs & JSPROP_INDEX; } bool hasShortId() const { return desc()->attrs & JSPROP_SHORTID; } bool hasAttributes(unsigned attrs) const { return desc()->attrs & attrs; } JS::MutableHandleObject object() { return JS::MutableHandleObject::fromMarkedLocation(&desc()->obj); } unsigned attributes() const { return desc()->attrs; } unsigned shortid() const { MOZ_ASSERT(hasShortId()); return desc()->shortid; } JSPropertyOp getter() const { return desc()->getter; } JSStrictPropertyOp setter() const { return desc()->setter; } JS::HandleObject getterObject() const { MOZ_ASSERT(hasGetterObject()); return JS::HandleObject::fromMarkedLocation(reinterpret_cast(&desc()->getter)); } JS::HandleObject setterObject() const { MOZ_ASSERT(hasSetterObject()); return JS::HandleObject::fromMarkedLocation(reinterpret_cast(&desc()->setter)); } JS::MutableHandleValue value() { return JS::MutableHandleValue::fromMarkedLocation(&desc()->value); } void setAttributes(unsigned attrs) { desc()->attrs = attrs; } void setShortId(unsigned id) { desc()->shortid = id; } void setGetter(JSPropertyOp op) { desc()->getter = op; } void setSetter(JSStrictPropertyOp op) { desc()->setter = op; } void setGetterObject(JSObject *obj) { desc()->getter = reinterpret_cast(obj); } void setSetterObject(JSObject *obj) { desc()->setter = reinterpret_cast(obj); } }; } /* namespace JS */ namespace js { template <> struct GCMethods { static JSPropertyDescriptor initial() { return JSPropertyDescriptor(); } static ThingRootKind kind() { return THING_ROOT_PROPERTY_DESCRIPTOR; } static bool poisoned(const JSPropertyDescriptor &desc) { return (desc.obj && JS::IsPoisonedPtr(desc.obj)) || (desc.attrs & JSPROP_GETTER && desc.getter && JS::IsPoisonedPtr(desc.getter)) || (desc.attrs & JSPROP_SETTER && desc.setter && JS::IsPoisonedPtr(desc.setter)) || (desc.value.isGCThing() && JS::IsPoisonedPtr(desc.value.toGCThing())); } }; template <> class RootedBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } JSPropertyDescriptor *extract() { return static_cast*>(this)->address(); } }; template <> class HandleBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } public: JS::HandleValue value() const { return JS::HandleValue::fromMarkedLocation(&extract()->value); } JS::HandleObject obj() const { return JS::HandleObject::fromMarkedLocation(&extract()->obj); } }; template <> class MutableHandleBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } JSPropertyDescriptor *extract() { return static_cast*>(this)->address(); } }; } /* namespace js */ /* * Like JS_GetPropertyAttrsGetterAndSetterById but will return a property on * an object on the prototype chain (returned in objp). If data->obj is null, * then this property was not found on the prototype chain. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSPropertyDescriptor *desc); extern JS_PUBLIC_API(JSBool) JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyDefault(JSContext *cx, JSObject *obj, const char *name, jsval def, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehalfOf, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name); extern JS_PUBLIC_API(JSBool) JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle rval); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle rval); extern JS_PUBLIC_API(JSBool) JS_DefineUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer * is not null). */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, int8_t tinyid, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSBool *vp); extern JS_PUBLIC_API(JSBool) JS_LookupUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_SetUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_DeleteUCProperty2(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle rval); extern JS_PUBLIC_API(JSObject *) JS_NewArrayObject(JSContext *cx, int length, jsval *vector); extern JS_PUBLIC_API(JSBool) JS_IsArrayObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_GetArrayLength(JSContext *cx, JSObject *obj, uint32_t *lengthp); extern JS_PUBLIC_API(JSBool) JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length); extern JS_PUBLIC_API(JSBool) JS_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_GetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp); /* * Get the property with name given by |index|, if it has one. If * not, |*present| will be set to false and the value of |vp| must not * be relied on. */ extern JS_PUBLIC_API(JSBool) JS_GetElementIfPresent(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp, JSBool* present); extern JS_PUBLIC_API(JSBool) JS_SetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_DeleteElement(JSContext *cx, JSObject *obj, uint32_t index); extern JS_PUBLIC_API(JSBool) JS_DeleteElement2(JSContext *cx, JSObject *obj, uint32_t index, jsval *rval); /* * Remove all configurable properties from the given (non-global) object and * assign undefined to all writable data properties. */ JS_PUBLIC_API(void) JS_ClearNonGlobalObject(JSContext *cx, JSObject *objArg); /* * Assign 'undefined' to all of the object's non-reserved slots. Note: this is * done for all slots, regardless of the associated property descriptor. */ JS_PUBLIC_API(void) JS_SetAllNonReservedSlotsToUndefined(JSContext *cx, JSObject *objArg); /* * Create a new array buffer with the given contents, which must have been * returned by JS_AllocateArrayBufferContents or JS_StealArrayBufferContents. * The new array buffer takes ownership. After calling this function, do not * free |contents| or use |contents| from another thread. */ extern JS_PUBLIC_API(JSObject *) JS_NewArrayBufferWithContents(JSContext *cx, void *contents); /* * Steal the contents of the given array buffer. The array buffer has its * length set to 0 and its contents array cleared. The caller takes ownership * of |*contents| and must free it or transfer ownership via * JS_NewArrayBufferWithContents when done using it. * To free |*contents|, call free(). * A pointer to the buffer's data is returned in |*data|. This pointer can * be used until |*contents| is freed or has its ownership transferred. */ extern JS_PUBLIC_API(JSBool) JS_StealArrayBufferContents(JSContext *cx, JSObject *obj, void **contents, uint8_t **data); /* * Allocate memory that may be eventually passed to * JS_NewArrayBufferWithContents. |nbytes| is the number of payload bytes * required. The pointer to pass to JS_NewArrayBufferWithContents is returned * in |contents|. The pointer to the |nbytes| of usable memory is returned in * |data|. (*|contents| will contain a header before |data|.) The only legal * operations on *|contents| is to free it, or pass it to * JS_NewArrayBufferWithContents or JS_ReallocateArrayBufferContents. */ extern JS_PUBLIC_API(JSBool) JS_AllocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void **contents, uint8_t **data); /* * Reallocate memory allocated by JS_AllocateArrayBufferContents, growing or shrinking it * as appropriate. The new data pointer will be returned in data. If *contents is NULL, * behaves like JS_AllocateArrayBufferContents. */ extern JS_PUBLIC_API(JSBool) JS_ReallocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void **contents, uint8_t **data); extern JS_PUBLIC_API(JSIdArray *) JS_Enumerate(JSContext *cx, JSObject *obj); /* * Create an object to iterate over enumerable properties of obj, in arbitrary * property definition order. NB: This differs from longstanding for..in loop * order, which uses order of property definition in obj. */ extern JS_PUBLIC_API(JSObject *) JS_NewPropertyIterator(JSContext *cx, JSObject *obj); /* * Return true on success with *idp containing the id of the next enumerable * property to visit using iterobj, or JSID_IS_VOID if there is no such property * left to visit. Return false on error. */ extern JS_PUBLIC_API(JSBool) JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp); /* * A JSNative that creates and returns a new iterator that iterates over the * elements of |this|, up to |this.length|, in index order. This can be used to * make any array-like object iterable. Just give the object an obj.iterator() * method using this JSNative as the implementation. */ extern JS_PUBLIC_API(JSBool) JS_ArrayIterator(JSContext *cx, unsigned argc, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, jsval *vp, unsigned *attrsp); extern JS_PUBLIC_API(jsval) JS_GetReservedSlot(JSObject *obj, uint32_t index); extern JS_PUBLIC_API(void) JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v); /************************************************************************/ /* * Security protocol. */ struct JSPrincipals { /* Don't call "destroy"; use reference counting macros below. */ int refcount; #ifdef DEBUG /* A helper to facilitate principals debugging. */ uint32_t debugToken; #endif void setDebugToken(uint32_t token) { # ifdef DEBUG debugToken = token; # endif } /* * This is not defined by the JS engine but should be provided by the * embedding. */ JS_PUBLIC_API(void) dump(); }; extern JS_PUBLIC_API(void) JS_HoldPrincipals(JSPrincipals *principals); extern JS_PUBLIC_API(void) JS_DropPrincipals(JSRuntime *rt, JSPrincipals *principals); struct JSSecurityCallbacks { JSCheckAccessOp checkObjectAccess; JSCSPEvalChecker contentSecurityPolicyAllows; }; extern JS_PUBLIC_API(void) JS_SetSecurityCallbacks(JSRuntime *rt, const JSSecurityCallbacks *callbacks); extern JS_PUBLIC_API(const JSSecurityCallbacks *) JS_GetSecurityCallbacks(JSRuntime *rt); /* * Code running with "trusted" principals will be given a deeper stack * allocation than ordinary scripts. This allows trusted script to run after * untrusted script has exhausted the stack. This function sets the * runtime-wide trusted principal. * * This principals is not held (via JS_HoldPrincipals/JS_DropPrincipals) since * there is no available JSContext. Instead, the caller must ensure that the * given principals stays valid for as long as 'rt' may point to it. If the * principals would be destroyed before 'rt', JS_SetTrustedPrincipals must be * called again, passing NULL for 'prin'. */ extern JS_PUBLIC_API(void) JS_SetTrustedPrincipals(JSRuntime *rt, JSPrincipals *prin); /* * Initialize the callback that is called to destroy JSPrincipals instance * when its reference counter drops to zero. The initialization can be done * only once per JS runtime. */ extern JS_PUBLIC_API(void) JS_InitDestroyPrincipalsCallback(JSRuntime *rt, JSDestroyPrincipalsOp destroyPrincipals); /************************************************************************/ /* * Functions and scripts. */ extern JS_PUBLIC_API(JSFunction *) JS_NewFunction(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, JSObject *parent, const char *name); /* * Create the function with the name given by the id. JSID_IS_STRING(id) must * be true. */ extern JS_PUBLIC_API(JSFunction *) JS_NewFunctionById(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, JSObject *parent, jsid id); extern JS_PUBLIC_API(JSObject *) JS_GetFunctionObject(JSFunction *fun); /* * Return the function's identifier as a JSString, or null if fun is unnamed. * The returned string lives as long as fun, so you don't need to root a saved * reference to it if fun is well-connected or rooted, and provided you bound * the use of the saved reference by fun's lifetime. */ extern JS_PUBLIC_API(JSString *) JS_GetFunctionId(JSFunction *fun); /* * Return a function's display name. This is the defined name if one was given * where the function was defined, or it could be an inferred name by the JS * engine in the case that the function was defined to be anonymous. This can * still return NULL if a useful display name could not be inferred. The same * restrictions on rooting as those in JS_GetFunctionId apply. */ extern JS_PUBLIC_API(JSString *) JS_GetFunctionDisplayId(JSFunction *fun); /* * Return the arity (length) of fun. */ extern JS_PUBLIC_API(uint16_t) JS_GetFunctionArity(JSFunction *fun); /* * Infallible predicate to test whether obj is a function object (faster than * comparing obj's class name to "Function", but equivalent unless someone has * overwritten the "Function" identifier with a different constructor and then * created instances using that constructor that might be passed in as obj). */ extern JS_PUBLIC_API(JSBool) JS_ObjectIsFunction(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_ObjectIsCallable(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_IsNativeFunction(JSObject *funobj, JSNative call); /* Return whether the given function is a valid constructor. */ extern JS_PUBLIC_API(JSBool) JS_IsConstructor(JSFunction *fun); /* * Bind the given callable to use the given object as "this". * * If |callable| is not callable, will throw and return NULL. */ extern JS_PUBLIC_API(JSObject*) JS_BindCallable(JSContext *cx, JSObject *callable, JSObject *newThis); extern JS_PUBLIC_API(JSBool) JS_DefineFunctions(JSContext *cx, JSObject *obj, const JSFunctionSpec *fs); extern JS_PUBLIC_API(JSFunction *) JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call, unsigned nargs, unsigned attrs); extern JS_PUBLIC_API(JSFunction *) JS_DefineUCFunction(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSNative call, unsigned nargs, unsigned attrs); extern JS_PUBLIC_API(JSFunction *) JS_DefineFunctionById(JSContext *cx, JSObject *obj, jsid id, JSNative call, unsigned nargs, unsigned attrs); /* * Clone a top-level function into a new scope. This function will dynamically * fail if funobj was lexically nested inside some other function. */ extern JS_PUBLIC_API(JSObject *) JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); /* * Given a buffer, return JS_FALSE if the buffer might become a valid * javascript statement with the addition of more lines. Otherwise return * JS_TRUE. The intent is to support interactive compilation - accumulate * lines in a buffer until JS_BufferIsCompilableUnit is true, then pass it to * the compiler. */ extern JS_PUBLIC_API(JSBool) JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj, const char *utf8, size_t length); extern JS_PUBLIC_API(JSScript *) JS_CompileScript(JSContext *cx, JSObject *obj, const char *ascii, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *ascii, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileUCScript(JSContext *cx, JSObject *obj, const jschar *chars, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalFromScript(JSScript *script); extern JS_PUBLIC_API(JSFunction *) JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSFunction *) JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSFunction *) JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name, unsigned nargs, const char **argnames, const jschar *chars, size_t length, const char *filename, unsigned lineno); namespace JS { /* Options for JavaScript compilation. */ class JS_PUBLIC_API(CompileOptions) { JSPrincipals *principals_; JSPrincipals *originPrincipals_; public: JSPrincipals *principals() const { return principals_; } JSPrincipals *originPrincipals() const; JSVersion version; bool versionSet; bool utf8; const char *filename; unsigned lineno; unsigned column; HandleObject element; bool compileAndGo; bool forEval; bool noScriptRval; bool selfHostingMode; bool canLazilyParse; bool strictOption; bool extraWarningsOption; bool werrorOption; bool asmJSOption; enum SourcePolicy { NO_SOURCE, LAZY_SOURCE, SAVE_SOURCE } sourcePolicy; explicit CompileOptions(JSContext *cx, JSVersion version = JSVERSION_UNKNOWN); CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; } CompileOptions &setOriginPrincipals(JSPrincipals *p) { originPrincipals_ = p; return *this; } CompileOptions &setVersion(JSVersion v) { version = v; versionSet = true; return *this; } CompileOptions &setUTF8(bool u) { utf8 = u; return *this; } CompileOptions &setFileAndLine(const char *f, unsigned l) { filename = f; lineno = l; return *this; } CompileOptions &setColumn(unsigned c) { column = c; return *this; } CompileOptions &setElement(HandleObject e) { element = e; return *this; } CompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; } CompileOptions &setForEval(bool eval) { forEval = eval; return *this; } CompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; } CompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; } CompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; } CompileOptions &setSourcePolicy(SourcePolicy sp) { sourcePolicy = sp; return *this; } }; extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const char *bytes, size_t length); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const jschar *chars, size_t length); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, FILE *file); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const char *filename); extern JS_PUBLIC_API(JSFunction *) CompileFunction(JSContext *cx, JS::Handle obj, CompileOptions options, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length); extern JS_PUBLIC_API(JSFunction *) CompileFunction(JSContext *cx, JS::Handle obj, CompileOptions options, const char *name, unsigned nargs, const char **argnames, const jschar *chars, size_t length); } /* namespace JS */ extern JS_PUBLIC_API(JSString *) JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, unsigned indent); /* * API extension: OR this into indent to avoid pretty-printing the decompiled * source resulting from JS_DecompileFunction{,Body}. */ #define JS_DONT_PRETTY_PRINT ((unsigned)0x8000) extern JS_PUBLIC_API(JSString *) JS_DecompileFunction(JSContext *cx, JSFunction *fun, unsigned indent); extern JS_PUBLIC_API(JSString *) JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, unsigned indent); /* * NB: JS_ExecuteScript and the JS_Evaluate*Script* quadruplets use the obj * parameter as the initial scope chain header, the 'this' keyword value, and * the variables object (ECMA parlance for where 'var' and 'function' bind * names) of the execution context for script. * * Using obj as the variables object is problematic if obj's parent (which is * the scope chain link; see JS_SetParent and JS_NewObject) is not null: in * this case, variables created by 'var x = 0', e.g., go in obj, but variables * created by assignment to an unbound id, 'x = 0', go in the last object on * the scope chain linked by parent. * * ECMA calls that last scoping object the "global object", but note that many * embeddings have several such objects. ECMA requires that "global code" be * executed with the variables object equal to this global object. But these * JS API entry points provide freedom to execute code against a "sub-global", * i.e., a parented or scoped object, in which case the variables object will * differ from the last object on the scope chain, resulting in confusing and * non-ECMA explicit vs. implicit variable creation. * * Caveat embedders: unless you already depend on this buggy variables object * binding behavior, you should call JS_SetOptions(cx, JSOPTION_VAROBJFIX) or * JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_VAROBJFIX) -- the latter if * someone may have set other options on cx already -- for each context in the * application, if you pass parented objects as the obj parameter, or may ever * pass such objects in the future. * * Why a runtime option? The alternative is to add six or so new API entry * points with signatures matching the following six, and that doesn't seem * worth the code bloat cost. Such new entry points would probably have less * obvious names, too, so would not tend to be used. The JS_SetOption call, * OTOH, can be more easily hacked into existing code that does not depend on * the bug; such code can continue to use the familiar JS_EvaluateScript, * etc., entry points. */ extern JS_PUBLIC_API(JSBool) JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_ExecuteScriptVersion(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval, JSVersion version); /* * Execute either the function-defining prolog of a script, or the script's * main body, but not both. */ typedef enum JSExecPart { JSEXEC_PROLOG, JSEXEC_MAIN } JSExecPart; extern JS_PUBLIC_API(JSBool) JS_EvaluateScript(JSContext *cx, JSObject *obj, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScript(JSContext *cx, JSObject *obj, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); /* * JSAPI clients may optionally specify the 'originPrincipals' of a script. * A script's originPrincipals may be retrieved through the debug API (via * JS_GetScriptOriginPrincipals) and the originPrincipals are transitively * assigned to any nested scripts (including scripts dynamically created via * eval and the Function constructor). If originPrincipals is null, then the * value of principals is used as origin principals for the script. */ extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JSObject *obj, JSPrincipals *principals, JSPrincipals *originPrincipals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); namespace JS { extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const jschar *chars, size_t length, jsval *rval); extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const char *bytes, size_t length, jsval *rval); extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const char *filename, jsval *rval); } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, unsigned argc, jsval *argv, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, unsigned argc, jsval *argv, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, unsigned argc, jsval *argv, jsval *rval); namespace JS { static inline bool Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunction(cx, thisObj, fun, argc, argv, rval.address()); } static inline bool Call(JSContext *cx, JSObject *thisObj, const char *name, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunctionName(cx, thisObj, name, argc, argv, rval.address()); } static inline bool Call(JSContext *cx, JSObject *thisObj, jsval fun, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunctionValue(cx, thisObj, fun, argc, argv, rval.address()); } extern JS_PUBLIC_API(bool) Call(JSContext *cx, jsval thisv, jsval fun, unsigned argc, jsval *argv, MutableHandle rval); static inline bool Call(JSContext *cx, jsval thisv, JSObject *funObj, unsigned argc, jsval *argv, MutableHandle rval) { return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval); } } /* namespace JS */ /* * These functions allow setting an operation callback that will be called * from the JS thread some time after any thread triggered the callback using * JS_TriggerOperationCallback(rt). * * To schedule the GC and for other activities the engine internally triggers * operation callbacks. The embedding should thus not rely on callbacks being * triggered through the external API only. * * Important note: Additional callbacks can occur inside the callback handler * if it re-enters the JS engine. The embedding must ensure that the callback * is disconnected before attempting such re-entry. */ extern JS_PUBLIC_API(JSOperationCallback) JS_SetOperationCallback(JSContext *cx, JSOperationCallback callback); extern JS_PUBLIC_API(JSOperationCallback) JS_GetOperationCallback(JSContext *cx); extern JS_PUBLIC_API(void) JS_TriggerOperationCallback(JSRuntime *rt); extern JS_PUBLIC_API(JSBool) JS_IsRunning(JSContext *cx); /* * Saving and restoring frame chains. * * These two functions are used to set aside cx's call stack while that stack * is inactive. After a call to JS_SaveFrameChain, it looks as if there is no * code running on cx. Before calling JS_RestoreFrameChain, cx's call stack * must be balanced and all nested calls to JS_SaveFrameChain must have had * matching JS_RestoreFrameChain calls. * * JS_SaveFrameChain deals with cx not having any code running on it. */ extern JS_PUBLIC_API(JSBool) JS_SaveFrameChain(JSContext *cx); extern JS_PUBLIC_API(void) JS_RestoreFrameChain(JSContext *cx); #ifdef MOZ_TRACE_JSCALLS /* * The callback is expected to be quick and noninvasive. It should not * trigger interrupts, turn on debugging, or produce uncaught JS * exceptions. The state of the stack and registers in the context * cannot be relied upon, since this callback may be invoked directly * from either JIT. The 'entering' field means we are entering a * function if it is positive, leaving a function if it is zero or * negative. */ extern JS_PUBLIC_API(void) JS_SetFunctionCallback(JSContext *cx, JSFunctionCallback fcb); extern JS_PUBLIC_API(JSFunctionCallback) JS_GetFunctionCallback(JSContext *cx); #endif /* MOZ_TRACE_JSCALLS */ /************************************************************************/ /* * Strings. * * NB: JS_NewUCString takes ownership of bytes on success, avoiding a copy; * but on error (signified by null return), it leaves chars owned by the * caller. So the caller must free bytes in the error case, if it has no use * for them. In contrast, all the JS_New*StringCopy* functions do not take * ownership of the character memory passed to them -- they copy it. */ extern JS_PUBLIC_API(JSString *) JS_NewStringCopyN(JSContext *cx, const char *s, size_t n); extern JS_PUBLIC_API(JSString *) JS_NewStringCopyZ(JSContext *cx, const char *s); extern JS_PUBLIC_API(JSString *) JS_InternJSString(JSContext *cx, JSString *str); extern JS_PUBLIC_API(JSString *) JS_InternStringN(JSContext *cx, const char *s, size_t length); extern JS_PUBLIC_API(JSString *) JS_InternString(JSContext *cx, const char *s); extern JS_PUBLIC_API(JSString *) JS_NewUCString(JSContext *cx, jschar *chars, size_t length); extern JS_PUBLIC_API(JSString *) JS_NewUCStringCopyN(JSContext *cx, const jschar *s, size_t n); extern JS_PUBLIC_API(JSString *) JS_NewUCStringCopyZ(JSContext *cx, const jschar *s); extern JS_PUBLIC_API(JSString *) JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length); extern JS_PUBLIC_API(JSString *) JS_InternUCString(JSContext *cx, const jschar *s); extern JS_PUBLIC_API(JSBool) JS_CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32_t *result); extern JS_PUBLIC_API(JSBool) JS_StringEqualsAscii(JSContext *cx, JSString *str, const char *asciiBytes, JSBool *match); extern JS_PUBLIC_API(size_t) JS_PutEscapedString(JSContext *cx, char *buffer, size_t size, JSString *str, char quote); extern JS_PUBLIC_API(JSBool) JS_FileEscapedString(FILE *fp, JSString *str, char quote); /* * Extracting string characters and length. * * While getting the length of a string is infallible, getting the chars can * fail. As indicated by the lack of a JSContext parameter, there are two * special cases where getting the chars is infallible: * * The first case is interned strings, i.e., strings from JS_InternString or * JSID_TO_STRING(id), using JS_GetInternedStringChars*. * * The second case is "flat" strings that have been explicitly prepared in a * fallible context by JS_FlattenString. To catch errors, a separate opaque * JSFlatString type is returned by JS_FlattenString and expected by * JS_GetFlatStringChars. Note, though, that this is purely a syntactic * distinction: the input and output of JS_FlattenString are the same actual * GC-thing so only one needs to be rooted. If a JSString is known to be flat, * JS_ASSERT_STRING_IS_FLAT can be used to make a debug-checked cast. Example: * * // in a fallible context * JSFlatString *fstr = JS_FlattenString(cx, str); * if (!fstr) * return JS_FALSE; * JS_ASSERT(fstr == JS_ASSERT_STRING_IS_FLAT(str)); * * // in an infallible context, for the same 'str' * const jschar *chars = JS_GetFlatStringChars(fstr) * JS_ASSERT(chars); * * The CharsZ APIs guarantee that the returned array has a null character at * chars[length]. This can require additional copying so clients should prefer * APIs without CharsZ if possible. The infallible functions also return * null-terminated arrays. (There is no additional cost or non-Z alternative * for the infallible functions, so 'Z' is left out of the identifier.) */ extern JS_PUBLIC_API(size_t) JS_GetStringLength(JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsAndLength(JSContext *cx, JSString *str, size_t *length); extern JS_PUBLIC_API(const jschar *) JS_GetInternedStringChars(JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetInternedStringCharsAndLength(JSString *str, size_t *length); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsZ(JSContext *cx, JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsZAndLength(JSContext *cx, JSString *str, size_t *length); extern JS_PUBLIC_API(JSFlatString *) JS_FlattenString(JSContext *cx, JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetFlatStringChars(JSFlatString *str); static JS_ALWAYS_INLINE JSFlatString * JSID_TO_FLAT_STRING(jsid id) { JS_ASSERT(JSID_IS_STRING(id)); return (JSFlatString *)(JSID_BITS(id)); } static JS_ALWAYS_INLINE JSFlatString * JS_ASSERT_STRING_IS_FLAT(JSString *str) { JS_ASSERT(JS_GetFlatStringChars((JSFlatString *)str)); return (JSFlatString *)str; } static JS_ALWAYS_INLINE JSString * JS_FORGET_STRING_FLATNESS(JSFlatString *fstr) { return (JSString *)fstr; } /* * Additional APIs that avoid fallibility when given a flat string. */ extern JS_PUBLIC_API(JSBool) JS_FlatStringEqualsAscii(JSFlatString *str, const char *asciiBytes); extern JS_PUBLIC_API(size_t) JS_PutEscapedFlatString(char *buffer, size_t size, JSFlatString *str, char quote); /* * This function is now obsolete and behaves the same as JS_NewUCString. Use * JS_NewUCString instead. */ extern JS_PUBLIC_API(JSString *) JS_NewGrowableString(JSContext *cx, jschar *chars, size_t length); /* * Create a dependent string, i.e., a string that owns no character storage, * but that refers to a slice of another string's chars. Dependent strings * are mutable by definition, so the thread safety comments above apply. */ extern JS_PUBLIC_API(JSString *) JS_NewDependentString(JSContext *cx, JSString *str, size_t start, size_t length); /* * Concatenate two strings, possibly resulting in a rope. * See above for thread safety comments. */ extern JS_PUBLIC_API(JSString *) JS_ConcatStrings(JSContext *cx, JSString *left, JSString *right); /* * For JS_DecodeBytes, set *dstlenp to the size of the destination buffer before * the call; on return, *dstlenp contains the number of jschars actually stored. * To determine the necessary destination buffer size, make a sizing call that * passes NULL for dst. * * On errors, the functions report the error. In that case, *dstlenp contains * the number of characters or bytes transferred so far. If cx is NULL, no * error is reported on failure, and the functions simply return JS_FALSE. * * NB: This function does not store an additional zero byte or jschar after the * transcoded string. */ JS_PUBLIC_API(JSBool) JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst, size_t *dstlenp); /* * A variation on JS_EncodeCharacters where a null terminated string is * returned that you are expected to call JS_free on when done. */ JS_PUBLIC_API(char *) JS_EncodeString(JSContext *cx, JSString *str); /* * Same behavior as JS_EncodeString(), but encode into UTF-8 string */ JS_PUBLIC_API(char *) JS_EncodeStringToUTF8(JSContext *cx, JSString *str); /* * Get number of bytes in the string encoding (without accounting for a * terminating zero bytes. The function returns (size_t) -1 if the string * can not be encoded into bytes and reports an error using cx accordingly. */ JS_PUBLIC_API(size_t) JS_GetStringEncodingLength(JSContext *cx, JSString *str); /* * Encode string into a buffer. The function does not stores an additional * zero byte. The function returns (size_t) -1 if the string can not be * encoded into bytes with no error reported. Otherwise it returns the number * of bytes that are necessary to encode the string. If that exceeds the * length parameter, the string will be cut and only length bytes will be * written into the buffer. */ JS_PUBLIC_API(size_t) JS_EncodeStringToBuffer(JSContext *cx, JSString *str, char *buffer, size_t length); class JSAutoByteString { public: JSAutoByteString(JSContext *cx, JSString *str MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mBytes(JS_EncodeString(cx, str)) { JS_ASSERT(cx); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } JSAutoByteString(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) : mBytes(NULL) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~JSAutoByteString() { js_free(mBytes); } /* Take ownership of the given byte array. */ void initBytes(char *bytes) { JS_ASSERT(!mBytes); mBytes = bytes; } char *encodeLatin1(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); JS_ASSERT(cx); mBytes = JS_EncodeString(cx, str); return mBytes; } char *encodeLatin1(js::ContextFriendFields *cx, JSString *str); char *encodeUtf8(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); JS_ASSERT(cx); mBytes = JS_EncodeStringToUTF8(cx, str); return mBytes; } void clear() { js_free(mBytes); mBytes = NULL; } char *ptr() const { return mBytes; } bool operator!() const { return !mBytes; } size_t length() const { if (!mBytes) return 0; return strlen(mBytes); } private: char *mBytes; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER /* Copy and assignment are not supported. */ JSAutoByteString(const JSAutoByteString &another); JSAutoByteString &operator=(const JSAutoByteString &another); }; /************************************************************************/ /* * JSON functions */ typedef JSBool (* JSONWriteCallback)(const jschar *buf, uint32_t len, void *data); /* * JSON.stringify as specified by ES5. */ JS_PUBLIC_API(JSBool) JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space, JSONWriteCallback callback, void *data); /* * JSON.parse as specified by ES5. */ JS_PUBLIC_API(JSBool) JS_ParseJSON(JSContext *cx, const jschar *chars, uint32_t len, JS::MutableHandle vp); JS_PUBLIC_API(JSBool) JS_ParseJSONWithReviver(JSContext *cx, const jschar *chars, uint32_t len, jsval reviver, jsval *vp); /************************************************************************/ /* API for the HTML5 internal structured cloning algorithm. */ /* The maximum supported structured-clone serialization format version. */ #define JS_STRUCTURED_CLONE_VERSION 2 struct JSStructuredCloneCallbacks { ReadStructuredCloneOp read; WriteStructuredCloneOp write; StructuredCloneErrorOp reportError; }; /* Note: if the *data contains transferable objects, it can be read * only once */ JS_PUBLIC_API(JSBool) JS_ReadStructuredClone(JSContext *cx, uint64_t *data, size_t nbytes, uint32_t version, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure); /* Note: On success, the caller is responsible for calling * JS_ClearStructuredClone(*datap, nbytesp). */ JS_PUBLIC_API(JSBool) JS_WriteStructuredClone(JSContext *cx, jsval v, uint64_t **datap, size_t *nbytesp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure, jsval transferable); JS_PUBLIC_API(JSBool) JS_ClearStructuredClone(const uint64_t *data, size_t nbytes); JS_PUBLIC_API(JSBool) JS_StructuredCloneHasTransferables(const uint64_t *data, size_t nbytes, JSBool *hasTransferable); JS_PUBLIC_API(JSBool) JS_StructuredClone(JSContext *cx, jsval v, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure); /* RAII sugar for JS_WriteStructuredClone. */ class JS_PUBLIC_API(JSAutoStructuredCloneBuffer) { uint64_t *data_; size_t nbytes_; uint32_t version_; public: JSAutoStructuredCloneBuffer() : data_(NULL), nbytes_(0), version_(JS_STRUCTURED_CLONE_VERSION) {} ~JSAutoStructuredCloneBuffer() { clear(); } uint64_t *data() const { return data_; } size_t nbytes() const { return nbytes_; } void clear(); /* Copy some memory. It will be automatically freed by the destructor. */ bool copy(const uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION); /* * Adopt some memory. It will be automatically freed by the destructor. * data must have been allocated by the JS engine (e.g., extracted via * JSAutoStructuredCloneBuffer::steal). */ void adopt(uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION); /* * Remove the buffer so that it will not be automatically freed. * After this, the caller is responsible for feeding the memory back to * JSAutoStructuredCloneBuffer::adopt. */ void steal(uint64_t **datap, size_t *nbytesp, uint32_t *versionp=NULL); bool read(JSContext *cx, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); bool write(JSContext *cx, jsval v, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); bool write(JSContext *cx, jsval v, jsval transferable, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); /** * Swap ownership with another JSAutoStructuredCloneBuffer. */ void swap(JSAutoStructuredCloneBuffer &other); private: /* Copy and assignment are not supported. */ JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer &other); JSAutoStructuredCloneBuffer &operator=(const JSAutoStructuredCloneBuffer &other); }; /* API for implementing custom serialization behavior (for ImageData, File, etc.) */ /* The range of tag values the application may use for its own custom object types. */ #define JS_SCTAG_USER_MIN ((uint32_t) 0xFFFF8000) #define JS_SCTAG_USER_MAX ((uint32_t) 0xFFFFFFFF) #define JS_SCERR_RECURSION 0 #define JS_SCERR_TRANSFERABLE 1 JS_PUBLIC_API(void) JS_SetStructuredCloneCallbacks(JSRuntime *rt, const JSStructuredCloneCallbacks *callbacks); JS_PUBLIC_API(JSBool) JS_ReadUint32Pair(JSStructuredCloneReader *r, uint32_t *p1, uint32_t *p2); JS_PUBLIC_API(JSBool) JS_ReadBytes(JSStructuredCloneReader *r, void *p, size_t len); JS_PUBLIC_API(JSBool) JS_ReadTypedArray(JSStructuredCloneReader *r, jsval *vp); JS_PUBLIC_API(JSBool) JS_WriteUint32Pair(JSStructuredCloneWriter *w, uint32_t tag, uint32_t data); JS_PUBLIC_API(JSBool) JS_WriteBytes(JSStructuredCloneWriter *w, const void *p, size_t len); JS_PUBLIC_API(JSBool) JS_WriteTypedArray(JSStructuredCloneWriter *w, jsval v); /************************************************************************/ /* * The default locale for the ECMAScript Internationalization API * (Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat). * Note that the Internationalization API encourages clients to * specify their own locales. * The locale string remains owned by the caller. */ extern JS_PUBLIC_API(JSBool) JS_SetDefaultLocale(JSRuntime *rt, const char *locale); /* * Reset the default locale to OS defaults. */ extern JS_PUBLIC_API(void) JS_ResetDefaultLocale(JSRuntime *rt); /* * Locale specific string conversion and error message callbacks. */ struct JSLocaleCallbacks { JSLocaleToUpperCase localeToUpperCase; JSLocaleToLowerCase localeToLowerCase; JSLocaleCompare localeCompare; // not used #if ENABLE_INTL_API JSLocaleToUnicode localeToUnicode; JSErrorCallback localeGetErrorMessage; }; /* * Establish locale callbacks. The pointer must persist as long as the * JSRuntime. Passing NULL restores the default behaviour. */ extern JS_PUBLIC_API(void) JS_SetLocaleCallbacks(JSRuntime *rt, JSLocaleCallbacks *callbacks); /* * Return the address of the current locale callbacks struct, which may * be NULL. */ extern JS_PUBLIC_API(JSLocaleCallbacks *) JS_GetLocaleCallbacks(JSRuntime *rt); /************************************************************************/ /* * Error reporting. */ /* * Report an exception represented by the sprintf-like conversion of format * and its arguments. This exception message string is passed to a pre-set * JSErrorReporter function (set by JS_SetErrorReporter). */ extern JS_PUBLIC_API(void) JS_ReportError(JSContext *cx, const char *format, ...); /* * Use an errorNumber to retrieve the format string, args are char * */ extern JS_PUBLIC_API(void) JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); #ifdef va_start extern JS_PUBLIC_API(void) JS_ReportErrorNumberVA(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, va_list ap); #endif /* * Use an errorNumber to retrieve the format string, args are jschar * */ extern JS_PUBLIC_API(void) JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); extern JS_PUBLIC_API(void) JS_ReportErrorNumberUCArray(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, const jschar **args); /* * As above, but report a warning instead (JSREPORT_IS_WARNING(report.flags)). * Return true if there was no error trying to issue the warning, and if the * warning was not converted into an error due to the JSOPTION_WERROR option * being set, false otherwise. */ extern JS_PUBLIC_API(JSBool) JS_ReportWarning(JSContext *cx, const char *format, ...); extern JS_PUBLIC_API(JSBool) JS_ReportErrorFlagsAndNumber(JSContext *cx, unsigned flags, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); extern JS_PUBLIC_API(JSBool) JS_ReportErrorFlagsAndNumberUC(JSContext *cx, unsigned flags, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); /* * Complain when out of memory. */ extern JS_PUBLIC_API(void) JS_ReportOutOfMemory(JSContext *cx); /* * Complain when an allocation size overflows the maximum supported limit. */ extern JS_PUBLIC_API(void) JS_ReportAllocationOverflow(JSContext *cx); struct JSErrorReport { const char *filename; /* source file name, URL, etc., or null */ JSPrincipals *originPrincipals; /* see 'originPrincipals' comment above */ unsigned lineno; /* source line number */ const char *linebuf; /* offending source line without final \n */ const char *tokenptr; /* pointer to error token in linebuf */ const jschar *uclinebuf; /* unicode (original) line buffer */ const jschar *uctokenptr; /* unicode (original) token pointer */ unsigned flags; /* error/warning, etc. */ unsigned errorNumber; /* the error number, e.g. see js.msg */ const jschar *ucmessage; /* the (default) error message */ const jschar **messageArgs; /* arguments for the error message */ int16_t exnType; /* One of the JSExnType constants */ unsigned column; /* zero-based column index in line */ }; /* * JSErrorReport flag values. These may be freely composed. */ #define JSREPORT_ERROR 0x0 /* pseudo-flag for default case */ #define JSREPORT_WARNING 0x1 /* reported via JS_ReportWarning */ #define JSREPORT_EXCEPTION 0x2 /* exception was thrown */ #define JSREPORT_STRICT 0x4 /* error or warning due to strict option */ /* * This condition is an error in strict mode code, a warning if * JS_HAS_STRICT_OPTION(cx), and otherwise should not be reported at * all. We check the strictness of the context's top frame's script; * where that isn't appropriate, the caller should do the right checks * itself instead of using this flag. */ #define JSREPORT_STRICT_MODE_ERROR 0x8 /* * If JSREPORT_EXCEPTION is set, then a JavaScript-catchable exception * has been thrown for this runtime error, and the host should ignore it. * Exception-aware hosts should also check for JS_IsExceptionPending if * JS_ExecuteScript returns failure, and signal or propagate the exception, as * appropriate. */ #define JSREPORT_IS_WARNING(flags) (((flags) & JSREPORT_WARNING) != 0) #define JSREPORT_IS_EXCEPTION(flags) (((flags) & JSREPORT_EXCEPTION) != 0) #define JSREPORT_IS_STRICT(flags) (((flags) & JSREPORT_STRICT) != 0) #define JSREPORT_IS_STRICT_MODE_ERROR(flags) (((flags) & \ JSREPORT_STRICT_MODE_ERROR) != 0) extern JS_PUBLIC_API(JSErrorReporter) JS_GetErrorReporter(JSContext *cx); extern JS_PUBLIC_API(JSErrorReporter) JS_SetErrorReporter(JSContext *cx, JSErrorReporter er); /************************************************************************/ /* * Dates. */ extern JS_PUBLIC_API(JSObject *) JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); extern JS_PUBLIC_API(JSObject *) JS_NewDateObjectMsec(JSContext *cx, double msec); /* * Infallible predicate to test whether obj is a date object. */ extern JS_PUBLIC_API(JSBool) JS_ObjectIsDate(JSContext *cx, JSObject *obj); /* * Clears the cache of calculated local time from each Date object. * Call to propagate a system timezone change. */ extern JS_PUBLIC_API(void) JS_ClearDateCaches(JSContext *cx); /************************************************************************/ /* * Regular Expressions. */ #define JSREG_FOLD 0x01 /* fold uppercase to lowercase */ #define JSREG_GLOB 0x02 /* global exec, creates array of matches */ #define JSREG_MULTILINE 0x04 /* treat ^ and $ as begin and end of line */ #define JSREG_STICKY 0x08 /* only match starting at lastIndex */ extern JS_PUBLIC_API(JSObject *) JS_NewRegExpObject(JSContext *cx, JSObject *obj, char *bytes, size_t length, unsigned flags); extern JS_PUBLIC_API(JSObject *) JS_NewUCRegExpObject(JSContext *cx, JSObject *obj, jschar *chars, size_t length, unsigned flags); extern JS_PUBLIC_API(void) JS_SetRegExpInput(JSContext *cx, JSObject *obj, JSString *input, JSBool multiline); extern JS_PUBLIC_API(void) JS_ClearRegExpStatics(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_ExecuteRegExp(JSContext *cx, JSObject *obj, JSObject *reobj, jschar *chars, size_t length, size_t *indexp, JSBool test, jsval *rval); /* RegExp interface for clients without a global object. */ extern JS_PUBLIC_API(JSObject *) JS_NewRegExpObjectNoStatics(JSContext *cx, char *bytes, size_t length, unsigned flags); extern JS_PUBLIC_API(JSObject *) JS_NewUCRegExpObjectNoStatics(JSContext *cx, jschar *chars, size_t length, unsigned flags); extern JS_PUBLIC_API(JSBool) JS_ExecuteRegExpNoStatics(JSContext *cx, JSObject *reobj, jschar *chars, size_t length, size_t *indexp, JSBool test, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_ObjectIsRegExp(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(unsigned) JS_GetRegExpFlags(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSString *) JS_GetRegExpSource(JSContext *cx, JSObject *obj); /************************************************************************/ extern JS_PUBLIC_API(JSBool) JS_IsExceptionPending(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_GetPendingException(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(void) JS_SetPendingException(JSContext *cx, jsval v); extern JS_PUBLIC_API(void) JS_ClearPendingException(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_ReportPendingException(JSContext *cx); /* * Save the current exception state. This takes a snapshot of cx's current * exception state without making any change to that state. * * The returned state pointer MUST be passed later to JS_RestoreExceptionState * (to restore that saved state, overriding any more recent state) or else to * JS_DropExceptionState (to free the state struct in case it is not correct * or desirable to restore it). Both Restore and Drop free the state struct, * so callers must stop using the pointer returned from Save after calling the * Release or Drop API. */ extern JS_PUBLIC_API(JSExceptionState *) JS_SaveExceptionState(JSContext *cx); extern JS_PUBLIC_API(void) JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state); extern JS_PUBLIC_API(void) JS_DropExceptionState(JSContext *cx, JSExceptionState *state); /* * If the given value is an exception object that originated from an error, * the exception will contain an error report struct, and this API will return * the address of that struct. Otherwise, it returns NULL. The lifetime of * the error report struct that might be returned is the same as the lifetime * of the exception object. */ extern JS_PUBLIC_API(JSErrorReport *) JS_ErrorFromException(JSContext *cx, jsval v); /* * Given a reported error's message and JSErrorReport struct pointer, throw * the corresponding exception on cx. */ extern JS_PUBLIC_API(JSBool) JS_ThrowReportedError(JSContext *cx, const char *message, JSErrorReport *reportp); /* * Throws a StopIteration exception on cx. */ extern JS_PUBLIC_API(JSBool) JS_ThrowStopIteration(JSContext *cx); extern JS_PUBLIC_API(intptr_t) JS_GetCurrentThread(); /* * A JS runtime always has an "owner thread". The owner thread is set when the * runtime is created (to the current thread) and practically all entry points * into the JS engine check that a runtime (or anything contained in the * runtime: context, compartment, object, etc) is only touched by its owner * thread. Embeddings may check this invariant outside the JS engine by calling * JS_AbortIfWrongThread (which will abort if not on the owner thread, even for * non-debug builds). * * It is possible to "move" a runtime between threads. This is accomplished by * calling JS_ClearRuntimeThread on a runtime's owner thread and then calling * JS_SetRuntimeThread on the new owner thread. The runtime must not be * accessed between JS_ClearRuntimeThread and JS_SetRuntimeThread. Also, the * caller is responsible for synchronizing the calls to Set/Clear. */ extern JS_PUBLIC_API(void) JS_AbortIfWrongThread(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_ClearRuntimeThread(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_SetRuntimeThread(JSRuntime *rt); class JSAutoSetRuntimeThread { JSRuntime *runtime_; public: JSAutoSetRuntimeThread(JSRuntime *runtime) : runtime_(runtime) { JS_SetRuntimeThread(runtime_); } ~JSAutoSetRuntimeThread() { JS_ClearRuntimeThread(runtime_); } }; /************************************************************************/ /* * JS_IsConstructing must be called from within a native given the * native's original cx and vp arguments. If JS_IsConstructing is true, * JS_THIS must not be used; the constructor should construct and return a * new object. Otherwise, the native is called as an ordinary function and * JS_THIS may be used. */ static JS_ALWAYS_INLINE JSBool JS_IsConstructing(JSContext *cx, const jsval *vp) { #ifdef DEBUG JSObject *callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)); if (JS_ObjectIsFunction(cx, callee)) { JSFunction *fun = JS_ValueToFunction(cx, JS_CALLEE(cx, vp)); JS_ASSERT(JS_IsConstructor(fun)); } else { JS_ASSERT(JS_GetClass(callee)->construct != NULL); } #else (void)cx; #endif return JSVAL_IS_MAGIC_IMPL(JSVAL_TO_IMPL(vp[1])); } /* * A constructor can request that the JS engine create a default new 'this' * object of the given class, using the callee to determine parentage and * [[Prototype]]. */ extern JS_PUBLIC_API(JSObject *) JS_NewObjectForConstructor(JSContext *cx, JSClass *clasp, const jsval *vp); /************************************************************************/ #ifdef JS_GC_ZEAL #define JS_DEFAULT_ZEAL_FREQ 100 extern JS_PUBLIC_API(void) JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency); extern JS_PUBLIC_API(void) JS_ScheduleGC(JSContext *cx, uint32_t count); #endif extern JS_PUBLIC_API(void) JS_SetParallelCompilationEnabled(JSContext *cx, bool enabled); typedef enum JSCompilerOption { JSCOMPILER_BASELINE_USECOUNT_TRIGGER, JSCOMPILER_ION_USECOUNT_TRIGGER, JSCOMPILER_PJS_ENABLE } JSCompilerOption; extern JS_PUBLIC_API(void) JS_SetGlobalCompilerOption(JSContext *cx, JSCompilerOption opt, uint32_t value); /* * Convert a uint32_t index into a jsid. */ extern JS_PUBLIC_API(JSBool) JS_IndexToId(JSContext *cx, uint32_t index, jsid *id); /* * Convert chars into a jsid. * * |chars| may not be an index. */ extern JS_PUBLIC_API(JSBool) JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, jsid *idp); /* * Test if the given string is a valid ECMAScript identifier */ extern JS_PUBLIC_API(JSBool) JS_IsIdentifier(JSContext *cx, JSString *str, JSBool *isIdentifier); /* * Return the current script and line number of the most currently running * frame. Returns true if a scripted frame was found, false otherwise. */ extern JS_PUBLIC_API(JSBool) JS_DescribeScriptedCaller(JSContext *cx, JSScript **script, unsigned *lineno); /* * Encode/Decode interpreted scripts and functions to/from memory. */ extern JS_PUBLIC_API(void *) JS_EncodeScript(JSContext *cx, JSScript *script, uint32_t *lengthp); extern JS_PUBLIC_API(void *) JS_EncodeInterpretedFunction(JSContext *cx, JSObject *funobj, uint32_t *lengthp); extern JS_PUBLIC_API(JSScript *) JS_DecodeScript(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); extern JS_PUBLIC_API(JSObject *) JS_DecodeInterpretedFunction(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); namespace JS { extern JS_PUBLIC_DATA(const HandleValue) NullHandleValue; extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; extern JS_PUBLIC_DATA(const HandleId) JSID_VOIDHANDLE; extern JS_PUBLIC_DATA(const HandleId) JSID_EMPTYHANDLE; } /* namespace JS */ namespace js { /* * Import some JS:: names into the js namespace so we can make unqualified * references to them. */ using JS::Value; using JS::IsPoisonedValue; using JS::NullValue; using JS::UndefinedValue; using JS::Int32Value; using JS::DoubleValue; using JS::StringValue; using JS::BooleanValue; using JS::ObjectValue; using JS::MagicValue; using JS::NumberValue; using JS::ObjectOrNullValue; using JS::PrivateValue; using JS::PrivateUint32Value; using JS::IsPoisonedPtr; using JS::IsPoisonedId; using JS::StableCharPtr; using JS::TwoByteChars; using JS::Latin1CharsZ; using JS::AutoIdVector; using JS::AutoValueVector; using JS::AutoObjectVector; using JS::AutoFunctionVector; using JS::AutoScriptVector; using JS::AutoIdArray; using JS::AutoGCRooter; using JS::AutoArrayRooter; using JS::AutoVectorRooter; using JS::AutoHashMapRooter; using JS::AutoHashSetRooter; using JS::CallArgs; using JS::IsAcceptableThis; using JS::NativeImpl; using JS::CallReceiver; using JS::CompileOptions; using JS::CallNonGenericMethod; using JS::Rooted; using JS::RootedObject; using JS::RootedModule; using JS::RootedFunction; using JS::RootedScript; using JS::RootedString; using JS::RootedId; using JS::RootedValue; using JS::Handle; using JS::HandleObject; using JS::HandleModule; using JS::HandleFunction; using JS::HandleScript; using JS::HandleString; using JS::HandleId; using JS::HandleValue; using JS::MutableHandle; using JS::MutableHandleObject; using JS::MutableHandleFunction; using JS::MutableHandleScript; using JS::MutableHandleString; using JS::MutableHandleId; using JS::MutableHandleValue; using JS::Zone; } /* namespace js */ #endif /* jsapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsclass.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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" namespace js { class PropertyName; class SpecialId; class PropertyId; // This is equal to JSFunction::class_. Use it in places where you don't want // to #include jsfun.h. extern JS_FRIEND_DATA(js::Class* const) FunctionClassPtr; 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, JSBool *succeeded); typedef JSBool (* DeleteElementOp)(JSContext *cx, HandleObject obj, uint32_t index, JSBool *succeeded); typedef JSBool (* DeleteSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSBool *succeeded); typedef JSObject * (* ObjectOp)(JSContext *cx, HandleObject obj); typedef void (* FinalizeOp)(FreeOp *fop, JSObject *obj); #define JS_CLASS_MEMBERS \ const char *name; \ uint32_t flags; \ \ /* Mandatory function pointer members. */ \ JSPropertyOp addProperty; \ JSDeletePropertyOp delProperty; \ JSPropertyOp getProperty; \ JSStrictPropertyOp setProperty; \ JSEnumerateOp enumerate; \ JSResolveOp resolve; \ JSConvertOp convert; \ \ /* Optional members (may be null). */ \ FinalizeOp finalize; \ 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 pad 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; } bool isCallable() const { return this == js::FunctionClassPtr || call; } 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, ESClass_Date }; /* * 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 GCMethods { static SpecialId initial() { return SpecialId(); } static ThingRootKind kind() { return THING_ROOT_ID; } static bool poisoned(SpecialId id) { return IsPoisonedSpecialId(id); } }; } /* namespace js */ #endif /* jsclass_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsclist.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jscpucfg.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jscpucfg_h #define jscpucfg_h #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_WORD 8 # define JS_BITS_PER_WORD_LOG2 6 # 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_WORD 4 # define JS_BITS_PER_WORD_LOG2 5 #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 /* jscpucfg_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsdbgapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 "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(JSRuntime *rt, 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); /************************************************************************/ // Raw JSScript* because this needs to be callable from a signal handler. extern JS_PUBLIC_API(unsigned) JS_PCToLineNumber(JSContext *cx, JSScript *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_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_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); /* Call the context debug handler on the topmost scripted frame. */ extern JS_FRIEND_API(JSBool) js_CallContextDebugHandler(JSContext *cx); #endif /* jsdbgapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsfriendapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jsfriendapi_h #define jsfriendapi_h #include "mozilla/MemoryReporting.h" #include "jsclass.h" #include "jsprvtd.h" #include "jspubtd.h" #include "js/CallArgs.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) namespace JS { template class Heap; } /* namespace JS */ 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, JSObject *obj); extern JS_FRIEND_API(JSFunction *) JS_GetObjectFunction(JSObject *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(JS::HandleObject 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(JSString *) JS_BasicObjectToString(JSContext *cx, JS::HandleObject obj); extern JS_FRIEND_API(JSBool) js_GetterOnlyPropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool strict, JS::MutableHandleValue vp); JS_FRIEND_API(void) js_ReportOverRecursed(JSContext *maybecx); JS_FRIEND_API(bool) js_ObjectClassIs(JSContext *cx, JS::HandleObject obj, js::ESClassValue classValue); JS_FRIEND_API(const char *) js_ObjectClassName(JSContext *cx, JS::HandleObject obj); JS_FRIEND_API(bool) js_AddObjectRoot(JSRuntime *rt, JSObject **objp); JS_FRIEND_API(void) js_RemoveObjectRoot(JSRuntime *rt, JSObject **objp); #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, JS::HandleObject 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, JS::Handle script, jschar **src, uint32_t *length); extern JS_FRIEND_API(void) JS_SetSourceHook(JSRuntime *rt, JS_SourceHook hook); namespace js { 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); #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); /* * Returns whether we're in a non-strict property set (in that we're in a * non-strict script and the bytecode we're on is a property set). The return * value does NOT indicate any sort of exception was thrown: it's just a * boolean. */ extern JS_FRIEND_API(bool) IsInNonStrictPropertySet(JSContext *cx); 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(mozilla::MallocSizeOf 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; JSObject *_1; 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 { static const size_t LENGTH_SHIFT = 4; size_t lengthAndFlags; const jschar *chars; }; } /* namespace shadow */ // These are equal to |&{Function,Object,OuterWindow}ProxyObject::class_|. Use // them in places where you don't want to #include vm/ProxyObject.h. extern JS_FRIEND_DATA(js::Class* const) FunctionProxyClassPtr; extern JS_FRIEND_DATA(js::Class* const) ObjectProxyClassPtr; extern JS_FRIEND_DATA(js::Class* const) OuterWindowProxyClassPtr; // This is equal to |&JSObject::class_|. Use it in places where you don't want // to #include jsobj.h. extern JS_FRIEND_DATA(js::Class* const) ObjectClassPtr; inline js::Class * GetObjectClass(JSObject *obj) { return reinterpret_cast(obj)->type->clasp; } inline JSClass * GetObjectJSClass(JSObject *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) IsFunctionObject(JSObject *obj); JS_FRIEND_API(bool) IsScopeObject(JSObject *obj); JS_FRIEND_API(bool) IsCallObject(JSObject *obj); inline JSObject * GetObjectParent(JSObject *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(JSObject *obj); JS_FRIEND_API(JSObject *) GetGlobalForObjectCrossCompartment(JSObject *obj); // For legacy consumers only. This whole concept is going away soon. JS_FRIEND_API(JSObject *) DefaultObjectForContextOrNull(JSContext *cx); JS_FRIEND_API(void) SetDefaultObjectForContext(JSContext *cx, JSObject *obj); JS_FRIEND_API(void) NotifyAnimationActivity(JSObject *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, const JSPropertySpec *ps, const JSFunctionSpec *fs, const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs); JS_FRIEND_API(const Value &) GetFunctionNativeReserved(JSObject *fun, size_t which); JS_FRIEND_API(void) SetFunctionNativeReserved(JSObject *fun, size_t which, const Value &val); inline bool GetObjectProto(JSContext *cx, JS::Handle obj, JS::MutableHandle proto) { js::Class *clasp = GetObjectClass(obj); if (clasp == js::ObjectProxyClassPtr || clasp == js::OuterWindowProxyClassPtr || clasp == js::FunctionProxyClassPtr) { return JS_GetPrototype(cx, obj, proto); } proto.set(reinterpret_cast(obj.get())->type->proto); return true; } inline void * GetObjectPrivate(JSObject *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(JSObject *obj, size_t slot) { JS_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); return reinterpret_cast(obj)->slotRef(slot); } JS_FRIEND_API(void) SetReservedSlotWithBarrier(JSObject *obj, size_t slot, const Value &value); inline void SetReservedSlot(JSObject *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(JSObject *obj); inline const Value & GetObjectSlot(JSObject *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 size_t GetAtomLength(JSAtom *atom) { using shadow::Atom; return reinterpret_cast(atom)->lengthAndFlags >> Atom::LENGTH_SHIFT; } inline JSLinearString * AtomToLinearString(JSAtom *atom) { return reinterpret_cast(atom); } static inline js::PropertyOp CastAsJSPropertyOp(JSObject *object) { return JS_DATA_TO_FUNC_PTR(js::PropertyOp, object); } static inline js::StrictPropertyOp CastAsJSStrictPropertyOp(JSObject *object) { return JS_DATA_TO_FUNC_PTR(js::StrictPropertyOp, object); } JS_FRIEND_API(bool) GetPropertyNames(JSContext *cx, JSObject *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(JSObject *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; } inline uintptr_t GetNativeStackLimit(JSContext *cx) { return GetNativeStackLimit(GetRuntime(cx)); } /* * 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(cx), &stackDummy_)) { \ js_ReportOverRecursed(cx); \ onerror; \ } \ JS_END_MACRO #define JS_CHECK_RECURSION_WITH_SP_DONT_REPORT(cx, sp, onerror) \ JS_BEGIN_MACRO \ if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \ 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(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, JSScript *script, void *ip); #ifdef JS_THREADSAFE 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, JS::Handle desc); extern JS_FRIEND_API(AnalysisPurgeCallback) SetAnalysisPurgeCallback(JSRuntime *rt, AnalysisPurgeCallback callback); typedef JSBool (* DOMInstanceClassMatchesProto)(JS::HandleObject 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 DOMProxy proxies in the DOM, for use by ICs. */ /* * The DOMProxyShadowsCheck function will be called to check if the property for * id should be gotten from the prototype, or if there is an own property that * shadows it. * If DoesntShadow is returned then the slot at listBaseExpandoSlot should * either be undefined or point to an expando object that would contain the own * property. * If DoesntShadowUnique is returned then the slot at listBaseExpandoSlot should * contain a private pointer to a ExpandoAndGeneration, which contains a * JS::Value that should either be undefined or point to an expando object, and * a uint32 value. If that value changes then the IC for getting a property will * be invalidated. */ struct ExpandoAndGeneration { ExpandoAndGeneration() : expando(UndefinedValue()), generation(0) {} void Unlink() { ++generation; expando.setUndefined(); } JS::Heap expando; uint32_t generation; }; typedef enum DOMProxyShadowsResult { ShadowCheckFailed, Shadows, DoesntShadow, DoesntShadowUnique } DOMProxyShadowsResult; typedef DOMProxyShadowsResult (* DOMProxyShadowsCheck)(JSContext* cx, JS::HandleObject object, JS::HandleId id); JS_FRIEND_API(void) SetDOMProxyInformation(void *domProxyHandlerFamily, uint32_t domProxyExpandoSlot, DOMProxyShadowsCheck domProxyShadowsCheck); void *GetDOMProxyHandlerFamily(); uint32_t GetDOMProxyExpandoSlot(); DOMProxyShadowsCheck GetDOMProxyShadowsCheck(); } /* 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(JSObject *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 */ /* * A helper for building up an ArrayBuffer object's data * before creating the ArrayBuffer itself. Will do doubling * based reallocation, up to an optional maximum growth given. * * When all the data has been appended, call getArrayBuffer, * passing in the JSContext* for which the ArrayBuffer object * is to be created. This also implicitly resets the builder, * or it can be reset explicitly at any point by calling reset(). */ class ArrayBufferBuilder { void *rawcontents_; uint8_t *dataptr_; uint32_t capacity_; uint32_t length_; public: ArrayBufferBuilder() : rawcontents_(NULL), dataptr_(NULL), capacity_(0), length_(0) { } ~ArrayBufferBuilder() { reset(); } void reset() { if (rawcontents_) JS_free(NULL, rawcontents_); rawcontents_ = dataptr_ = NULL; capacity_ = length_ = 0; } // will truncate if newcap is < length() bool setCapacity(uint32_t newcap) { if (!JS_ReallocateArrayBufferContents(NULL, newcap, &rawcontents_, &dataptr_)) return false; capacity_ = newcap; if (length_ > newcap) length_ = newcap; return true; } // Append datalen bytes from data to the current buffer. If we // need to grow the buffer, grow by doubling the size up to a // maximum of maxgrowth (if given). If datalen is greater than // what the new capacity would end up as, then grow by datalen. // // The data parameter must not overlap with anything beyond the // builder's current valid contents [0..length) bool append(const uint8_t *newdata, uint32_t datalen, uint32_t maxgrowth = 0) { if (length_ + datalen > capacity_) { uint32_t newcap; // double while under maxgrowth or if not specified if (!maxgrowth || capacity_ < maxgrowth) newcap = capacity_ * 2; else newcap = capacity_ + maxgrowth; // but make sure there's always enough to satisfy our request if (newcap < length_ + datalen) newcap = length_ + datalen; // did we overflow? if (newcap < capacity_) return false; if (!setCapacity(newcap)) return false; } // assert that the region isn't overlapping so we can memcpy; JS_ASSERT(!areOverlappingRegions(newdata, datalen, dataptr_ + length_, datalen)); memcpy(dataptr_ + length_, newdata, datalen); length_ += datalen; return true; } uint8_t *data() { return dataptr_; } uint32_t length() { return length_; } uint32_t capacity() { return capacity_; } JSObject* getArrayBuffer(JSContext *cx) { // we need to check for length_ == 0, because nothing may have been // added if (capacity_ > length_ || length_ == 0) { if (!setCapacity(length_)) return NULL; } JSObject* obj = JS_NewArrayBufferWithContents(cx, rawcontents_); if (!obj) return NULL; rawcontents_ = dataptr_ = NULL; length_ = capacity_ = 0; return obj; } protected: static bool areOverlappingRegions(const uint8_t *start1, uint32_t length1, const uint8_t *start2, uint32_t length2) { const uint8_t *end1 = start1 + length1; const uint8_t *end2 = start2 + length2; const uint8_t *max_start = start1 > start2 ? start1 : start2; const uint8_t *min_end = end1 < end2 ? end1 : end2; return max_start < min_end; } }; } /* 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. 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); /* * A class, expected to be passed by value, which represents the CallArgs for a * JSJitGetterOp. */ class JSJitGetterCallArgs : protected JS::MutableHandleValue { public: explicit JSJitGetterCallArgs(const JS::CallArgs& args) : JS::MutableHandleValue(args.rval()) {} explicit JSJitGetterCallArgs(JS::Rooted* rooted) : JS::MutableHandleValue(rooted) {} JS::MutableHandleValue rval() { return *this; } }; /* * A class, expected to be passed by value, which represents the CallArgs for a * JSJitSetterOp. */ class JSJitSetterCallArgs : protected JS::MutableHandleValue { public: explicit JSJitSetterCallArgs(const JS::CallArgs& args) : JS::MutableHandleValue(args[0]) {} JS::MutableHandleValue operator[](unsigned i) { MOZ_ASSERT(i == 0); return *this; } unsigned length() const { return 1; } // Add get() or maybe hasDefined() as needed }; struct JSJitMethodCallArgsTraits; /* * A class, expected to be passed by reference, which represents the CallArgs * for a JSJitMethodOp. */ class JSJitMethodCallArgs : protected JS::detail::CallArgsBase { private: typedef JS::detail::CallArgsBase Base; friend struct JSJitMethodCallArgsTraits; public: explicit JSJitMethodCallArgs(const JS::CallArgs& args) { argv_ = args.array(); argc_ = args.length(); } JS::MutableHandleValue rval() const { return Base::rval(); } unsigned length() const { return Base::length(); } JS::MutableHandleValue operator[](unsigned i) const { return Base::operator[](i); } bool hasDefined(unsigned i) const { return Base::hasDefined(i); } // Add get() as needed }; struct JSJitMethodCallArgsTraits { static const size_t offsetOfArgv = offsetof(JSJitMethodCallArgs, argv_); static const size_t offsetOfArgc = offsetof(JSJitMethodCallArgs, argc_); }; /* * 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 (* JSJitGetterOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, JSJitGetterCallArgs args); typedef bool (* JSJitSetterOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, JSJitSetterCallArgs args); typedef bool (* JSJitMethodOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, const JSJitMethodCallArgs& args); struct JSJitInfo { enum OpType { Getter, Setter, Method, OpType_None }; union { JSJitGetterOp getter; JSJitSetterOp setter; JSJitMethodOp method; }; 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 */ /* An alternative native that's safe to call in parallel mode. */ JSParallelNative parallelNative; }; #define JS_JITINFO_NATIVE_PARALLEL(op) \ {{NULL},0,0,JSJitInfo::OpType_None,false,false,false,JSVAL_TYPE_MISSING,op} static JS_ALWAYS_INLINE const JSJitInfo * FUNCTION_VALUE_TO_JITINFO(const JS::Value& v) { JS_ASSERT(js::GetObjectClass(&v.toObject()) == js::FunctionClassPtr); 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 typedef bool (* ObjectMetadataCallback)(JSContext *cx, JSObject **pmetadata); /* * Specify a callback to invoke when creating each JS object in the current * compartment, which may return a metadata object to associate with the * object. Objects with different metadata have different shape hierarchies, * so for efficiency, objects should generally try to share metadata objects. */ JS_FRIEND_API(void) SetObjectMetadataCallback(JSContext *cx, ObjectMetadataCallback callback); /* Manipulate the metadata associated with an object. */ JS_FRIEND_API(bool) SetObjectMetadata(JSContext *cx, JS::HandleObject obj, JS::HandleObject metadata); JS_FRIEND_API(JSObject *) GetObjectMetadata(JSObject *obj); /* ES5 8.12.8. */ extern JS_FRIEND_API(JSBool) DefaultValue(JSContext *cx, JS::HandleObject obj, JSType hint, MutableHandleValue vp); /* * Helper function. To approximate a call to the [[DefineOwnProperty]] internal * method described in ES5, first call this, then call JS_DefinePropertyById. * * JS_DefinePropertyById by itself does not enforce the invariants on * non-configurable properties when obj->isNative(). This function performs the * relevant checks (specified in ES5 8.12.9 [[DefineOwnProperty]] steps 1-11), * but only if obj is native. * * The reason for the messiness here is that ES5 uses [[DefineOwnProperty]] as * a sort of extension point, but there is no hook in js::Class, * js::ProxyHandler, or the JSAPI with precisely the right semantics for it. */ extern JS_FRIEND_API(bool) CheckDefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, PropertyOp getter, StrictPropertyOp setter, unsigned attrs); } /* 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); #ifdef JSGC_GENERATIONAL extern JS_FRIEND_API(void) JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSObject *key, void *data); extern JS_FRIEND_API(void) JS_StoreStringPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSString *key, void *data); #else inline void JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSObject *key, void *data) {} inline void JS_StoreStringPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSString *key, void *data) {} #endif /* JSGC_GENERATIONAL */ #endif /* jsfriendapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jslock.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jslock_h #define jslock_h #ifdef JS_THREADSAFE # include "jsapi.h" # include "pratom.h" # include "prcvar.h" # include "prinit.h" # include "prlock.h" # include "prthread.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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsperf.h ================================================ /* -*- 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 perf_jsperf_h #define perf_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, JSObject *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 /* perf_jsperf_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsprf.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 #include #include "jstypes.h" /* ** 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsprototypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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) \ macro(Type, 38, js_InitBinaryDataClasses) \ macro(Data, 39, js_InitBinaryDataClasses) \ macro(uint8, 40, js_InitBinaryDataClasses) \ macro(uint16, 41, js_InitBinaryDataClasses) \ macro(uint32, 42, js_InitBinaryDataClasses) \ macro(uint64, 43, js_InitBinaryDataClasses) \ macro(int8, 44, js_InitBinaryDataClasses) \ macro(int16, 45, js_InitBinaryDataClasses) \ macro(int32, 46, js_InitBinaryDataClasses) \ macro(int64, 47, js_InitBinaryDataClasses) \ macro(float32, 48, js_InitBinaryDataClasses) \ macro(float64, 49, js_InitBinaryDataClasses) \ macro(ArrayType, 50, js_InitBinaryDataClasses) \ macro(StructType, 51, js_InitBinaryDataClasses) \ macro(ArrayTypeObject, 52, js_InitBinaryDataClasses) \ #endif /* jsprototypes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsproxy.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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(JSContext *cx, HandleObject proxy, bool *extensible) = 0; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args); virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args); 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 const char *className(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(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) 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 const char *className(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(JSContext *cx, HandleObject proxy, bool *extensible); static bool call(JSContext *cx, HandleObject proxy, const CallArgs &args); static bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args); 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 const char *className(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::ObjectProxyClassPtr || clasp == js::OuterWindowProxyClassPtr; } inline bool IsFunctionProxyClass(const Class *clasp) { return clasp == js::FunctionProxyClassPtr; } inline bool IsProxyClass(const Class *clasp) { return IsObjectProxyClass(clasp) || IsFunctionProxyClass(clasp); } inline bool IsObjectProxy(JSObject *obj) { return IsObjectProxyClass(GetObjectClass(obj)); } inline bool IsFunctionProxy(JSObject *obj) { return IsFunctionProxyClass(GetObjectClass(obj)); } inline bool IsProxy(JSObject *obj) { return IsProxyClass(GetObjectClass(obj)); } /* * These are part of the API. * * NOTE: PROXY_PRIVATE_SLOT 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 PROXY_PRIVATE_SLOT = 0; const uint32_t PROXY_HANDLER_SLOT = 1; const uint32_t PROXY_EXTRA_SLOT = 2; inline BaseProxyHandler * GetProxyHandler(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return (BaseProxyHandler *) GetReservedSlot(obj, PROXY_HANDLER_SLOT).toPrivate(); } inline const Value & GetProxyPrivate(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return GetReservedSlot(obj, PROXY_PRIVATE_SLOT); } inline JSObject * GetProxyTargetObject(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return GetProxyPrivate(obj).toObjectOrNull(); } inline const Value & GetProxyExtra(JSObject *obj, size_t n) { JS_ASSERT(IsProxy(obj)); return GetReservedSlot(obj, PROXY_EXTRA_SLOT + n); } inline void SetProxyHandler(JSObject *obj, BaseProxyHandler *handler) { JS_ASSERT(IsProxy(obj)); SetReservedSlot(obj, PROXY_HANDLER_SLOT, PrivateValue(handler)); } inline void SetProxyExtra(JSObject *obj, size_t n, const Value &extra) { JS_ASSERT(IsProxy(obj)); JS_ASSERT(n <= 1); SetReservedSlot(obj, PROXY_EXTRA_SLOT + n, extra); } enum ProxyCallable { ProxyNotCallable = false, ProxyIsCallable = true }; JS_FRIEND_API(JSObject *) NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue 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, JS::HandleObject obj); #endif /* jsproxy_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsprvtd.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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" #include "js/HashTable.h" #include "js/Vector.h" /* * 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; /* String typedefs. */ class JSDependentString; class JSExtensibleString; class JSExternalString; class JSLinearString; class JSRope; class JSAtom; class JSWrapper; namespace js { struct ArgumentsData; struct Class; class AutoNameVector; class RegExpGuard; class RegExpObject; class RegExpObjectBuilder; class RegExpShared; class RegExpStatics; class MatchPairs; class PropertyName; class LazyScript; enum RegExpFlag { IgnoreCaseFlag = 0x01, GlobalFlag = 0x02, MultilineFlag = 0x04, StickyFlag = 0x08, NoFlags = 0x00, AllFlags = 0x0f }; class StringBuffer; class FrameRegs; class StackFrame; class ScriptFrameIter; class Proxy; class JS_FRIEND_API(AutoEnterPolicy); 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 JSParallelNative ParallelNative; typedef JSThreadSafeNative ThreadSafeNative; typedef JSPropertyOp PropertyOp; typedef JSStrictPropertyOp StrictPropertyOp; typedef JSPropertyDescriptor PropertyDescriptor; struct SourceCompressionToken; namespace frontend { struct BytecodeEmitter; struct Definition; class FullParseHandler; class FunctionBox; class ObjectBox; struct Token; struct TokenPos; class TokenStream; class ParseMapPool; class ParseNode; template class 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 */ /* "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, JS::Handle obj); /* Signature for class initialization ops. */ typedef JSObject * (* JSClassInitializerOp)(JSContext *cx, JS::HandleObject 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, JS::HandleObject obj, JSBool keysonly); #endif /* jsprvtd_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jspubtd.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jspubtd_h #define jspubtd_h /* * JS public API typedefs. */ #include "mozilla/PodOperations.h" #include "jsprototypes.h" #include "jstypes.h" #if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) || defined(DEBUG) # define JSGC_TRACK_EXACT_ROOTS #endif 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; class JS_PUBLIC_API(AutoGCRooter); 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. */ // 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) */ #ifdef WIN32 typedef wchar_t jschar; #else typedef uint16_t jschar; #endif /* * Run-time version enumeration. For compile-time version checking, please use * the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION, * MOZJS_MINOR_VERSION, MOZJS_PATCH_VERSION, and MOZJS_ALPHA definitions. */ 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 see them if * it implements JSTraceCallback. */ JSTRACE_LAZY_SCRIPT, 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; class JSFlatString; class JSFunction; class JSObject; class JSScript; class JSStableString; // long story class JSString; #ifdef JS_THREADSAFE typedef struct PRCallOnceType JSCallOnceType; #else typedef JSBool JSCallOnceType; #endif typedef JSBool (*JSInitCallback)(void); namespace JS { namespace shadow { struct Runtime { /* Restrict zone access during Minor GC. */ bool needsBarrier_; #ifdef JSGC_GENERATIONAL /* Allow inlining of Nursery::isInside. */ uintptr_t gcNurseryStart_; uintptr_t gcNurseryEnd_; #endif Runtime() : needsBarrier_(false) #ifdef JSGC_GENERATIONAL , gcNurseryStart_(0) , gcNurseryEnd_(0) #endif {} }; } /* namespace shadow */ } /* namespace JS */ namespace js { /* * Parallel operations in general can have one of three states. They may * succeed, fail, or "bail", where bail indicates that the code encountered an * unexpected condition and should be re-run sequentially. Different * subcategories of the "bail" state are encoded as variants of TP_RETRY_*. */ enum ParallelResult { TP_SUCCESS, TP_RETRY_SEQUENTIALLY, TP_RETRY_AFTER_GC, TP_FATAL }; struct ThreadSafeContext; struct ForkJoinSlice; class ExclusiveContext; 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_PROPERTY_DESCRIPTOR, 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 {}; template <> struct RootKind : SpecificRootKind {}; struct ContextFriendFields { protected: JSRuntime *const runtime_; /* The current compartment. */ JSCompartment *compartment_; /* The current zone. */ JS::Zone *zone_; public: explicit ContextFriendFields(JSRuntime *rt) : runtime_(rt), compartment_(NULL), zone_(NULL), autoGCRooters(NULL) { #ifdef JSGC_TRACK_EXACT_ROOTS mozilla::PodArrayZero(thingGCRooters); #endif #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) skipGCRooters = NULL; #endif } static const ContextFriendFields *get(const JSContext *cx) { return reinterpret_cast(cx); } static ContextFriendFields *get(JSContext *cx) { return reinterpret_cast(cx); } #ifdef JSGC_TRACK_EXACT_ROOTS /* * 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 /* Stack of thread-stack-allocated GC roots. */ JS::AutoGCRooter *autoGCRooters; friend JSRuntime *GetRuntime(const JSContext *cx); friend JSCompartment *GetContextCompartment(const JSContext *cx); friend JS::Zone *GetContextZone(const JSContext *cx); }; 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 : JS::shadow::Runtime { struct PerThreadDummy { void *field1; uintptr_t field2; #ifdef DEBUG uint64_t field3; #endif } mainThread; }; public: PerThreadDataFriendFields(); #ifdef JSGC_TRACK_EXACT_ROOTS /* * 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 |JS::shadow::Runtime|. // 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 |JS::shadow::Runtime|. // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| return reinterpret_cast( reinterpret_cast(rt) + RuntimeMainThreadOffset); } }; } /* namespace js */ #endif /* jspubtd_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jstypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* ** 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) /*********************************************************************** ** 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsutil.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * PR assertion checker. */ #ifndef jsutil_h #define jsutil_h #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/GuardObjects.h" #ifdef USE_ZLIB #include #endif #include "js/Utility.h" /* 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); } 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 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); } /*****************************************************************************/ /* 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 */ /* 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 MOZ_IS_GCC #if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) # 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 #endif #endif #if !defined(JS_SILENCE_UNUSED_VALUE_IN_EXPR) # define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ JS_BEGIN_MACRO \ expr; \ JS_END_MACRO #endif #endif /* jsutil_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jsversion.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jsversion_h #define jsversion_h /* * Deprecated JS_VERSION handler. */ #ifdef JS_VERSION # if JS_VERSION == 185 # warning "JS_VERSION defined but unsupported (legacy)" # elif JS_VERSION < 185 # error "Unsupported JS_VERSION" # else # error "Unknown JS_VERSION" # endif #endif /* * JS Capability Macros. */ #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 */ /* 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_ASSUME_UNREACHABLE("don't call this! to be used in the new object representation") #endif #endif /* jsversion_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/jswrapper.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 CheckedUnwrap) will throw. Otherwise, they will succeed. */ void setSafeToUnwrap(bool safe) { mSafeToUnwrap = safe; } 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(JSObject *wrapper); static JSObject *wrappedObject(JSObject *wrapper); unsigned flags() const { return mFlags; } explicit Wrapper(unsigned flags, bool hasPrototype = false); virtual ~Wrapper(); static Wrapper singleton; static Wrapper singletonWithPrototype; }; /* 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(JSContext *cx, HandleObject wrapper, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject wrapper, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject wrapper, const CallArgs &args) 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 const char *className(JSContext *cx, HandleObject proxy) 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(JSContext *cx, HandleObject wrapper, bool *extensible) 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 defaultValue(JSContext *cx, HandleObject wrapper, JSType hint, MutableHandleValue vp) 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(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) 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 const char *className(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 bool getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp, bool *present) MOZ_OVERRIDE; virtual bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop) MOZ_OVERRIDE; static DeadObjectProxy singleton; }; extern JSObject * TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject obj, HandleObject wrappedProto, HandleObject 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(JSObject *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 *) UncheckedUnwrap(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 *) CheckedUnwrap(JSObject *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(JSObject *obj, bool stopAtOuter = true); JS_FRIEND_API(bool) IsCrossCompartmentWrapper(JSObject *obj); bool IsDeadProxyObject(JSObject *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 /* jswrapper_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/AllocPolicy.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * An allocation policy concept, usable for structures and algorithms to * control how memory is allocated and how failures are handled. */ #ifndef mozilla_AllocPolicy_h #define mozilla_AllocPolicy_h #include #include namespace mozilla { /* * Allocation policies are used to implement the standard allocation behaviors * in a customizable way. Additionally, custom behaviors may be added to these * behaviors, such as additionally reporting an error through an out-of-band * mechanism when OOM occurs. The concept modeled here is as follows: * * - public copy constructor, assignment, destructor * - void* malloc_(size_t) * Responsible for OOM reporting when null is returned. * - void* calloc_(size_t) * Responsible for OOM reporting when null is returned. * - void* realloc_(void*, size_t, size_t) * Responsible for OOM reporting when null is returned. 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*) * - void reportAllocOverflow() const * Called on allocation overflow (that is, an allocation implicitly tried * to allocate more than the available memory space -- think allocating an * array of large-size objects, where N * size overflows) before null is * returned. * * mfbt provides (and typically uses by default) only MallocAllocPolicy, which * does nothing more than delegate to the malloc/alloc/free functions. */ /* * A policy that straightforwardly uses malloc/calloc/realloc/free and adds no * extra behaviors. */ class MallocAllocPolicy { public: void* malloc_(size_t bytes) { return malloc(bytes); } void* calloc_(size_t bytes) { return calloc(bytes, 1); } void* realloc_(void* p, size_t oldBytes, size_t bytes) { return realloc(p, bytes); } void free_(void* p) { free(p); } void reportAllocOverflow() const {} }; } // namespace mozilla #endif /* mozilla_AllocPolicy_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Array.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 compile-time constant-length array with bounds-checking assertions. */ #ifndef mozilla_Array_h #define mozilla_Array_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include namespace mozilla { template class Array { T arr[Length]; public: T& operator[](size_t i) { MOZ_ASSERT(i < Length); return arr[i]; } const T& operator[](size_t i) const { MOZ_ASSERT(i < Length); return arr[i]; } }; template class Array { public: T& operator[](size_t i) { MOZ_ASSUME_UNREACHABLE("indexing into zero-length array"); } const T& operator[](size_t i) const { MOZ_ASSUME_UNREACHABLE("indexing into zero-length array"); } }; } /* namespace mozilla */ #endif /* mozilla_Array_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Assertions.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "mozilla/Likely.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* in C. * In C++11, static_assert is provided by the compiler to the same effect. * 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 { ... }; * // C * MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0, * "S should be a multiple of word size for efficiency"); * // C++11 * 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. */ #ifndef __cplusplus /* * 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 #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) #else #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) static_assert(!(cond) || (expr), reason) #endif #ifdef __cplusplus extern "C" { #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 or MOZ_CRASH 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 } static MOZ_ALWAYS_INLINE void MOZ_ReportCrash(const char* s, const char* file, int ln) { #ifdef ANDROID __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln); #else fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln); fflush(stderr); #endif } /** * MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH(). You should * call MOZ_CRASH instead. */ #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. * * We follow TerminateProcess() with a call to MOZ_NoReturn() so that the * compiler doesn't hassle us to provide a return statement after a * MOZ_REALLY_CRASH() call. * * (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.) */ __declspec(noreturn) __inline void MOZ_NoReturn() {} # ifdef __cplusplus # define MOZ_REALLY_CRASH() \ do { \ __debugbreak(); \ *((volatile int*) NULL) = 123; \ ::TerminateProcess(::GetCurrentProcess(), 3); \ ::MOZ_NoReturn(); \ } while (0) # else # define MOZ_REALLY_CRASH() \ do { \ __debugbreak(); \ *((volatile int*) NULL) = 123; \ TerminateProcess(GetCurrentProcess(), 3); \ MOZ_NoReturn(); \ } while (0) # endif #else # ifdef __cplusplus # define MOZ_REALLY_CRASH() \ do { \ *((volatile int*) NULL) = 123; \ ::abort(); \ } while (0) # else # define MOZ_REALLY_CRASH() \ do { \ *((volatile int*) NULL) = 123; \ abort(); \ } while (0) # endif #endif /* * MOZ_CRASH([explanation-string]) 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. * * The optional explanation-string, if provided, must be a string literal * explaining why we're crashing. This argument is intended for use with * MOZ_CRASH() calls whose rationale is non-obvious; don't use it if it's * obvious why we're crashing. * * If we're a DEBUG build and we crash at a MOZ_CRASH which provides an * explanation-string, we print the string to stderr. Otherwise, we don't * print anything; this is because we want MOZ_CRASH to be 100% safe in release * builds, and it's hard to print to stderr safely when memory might have been * corrupted. */ #ifndef DEBUG # define MOZ_CRASH(...) MOZ_REALLY_CRASH() #else # define MOZ_CRASH(...) \ do { \ MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \ MOZ_REALLY_CRASH(); \ } while(0) #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 (MOZ_UNLIKELY(!(expr))) { \ MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \ MOZ_REALLY_CRASH(); \ } \ } while (0) /* Now the two-argument form. */ # define MOZ_ASSERT_HELPER2(expr, explain) \ do { \ if (MOZ_UNLIKELY(!(expr))) { \ MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \ MOZ_REALLY_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_ASSUME_UNREACHABLE_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_ASSUME_UNREACHABLE, which uses this when * appropriate. */ #if defined(__clang__) # define MOZ_ASSUME_UNREACHABLE_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_ASSUME_UNREACHABLE_MARKER() __builtin_unreachable() # else # ifdef __cplusplus # define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() # else # define MOZ_ASSUME_UNREACHABLE_MARKER() abort() # endif # endif #elif defined(_MSC_VER) # define MOZ_ASSUME_UNREACHABLE_MARKER() __assume(0) #else # ifdef __cplusplus # define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() # else # define MOZ_ASSUME_UNREACHABLE_MARKER() abort() # endif #endif /* * MOZ_ASSUME_UNREACHABLE([reason]) tells the compiler that it can assume that * the macro call cannot be reached during execution. This lets the compiler * generate better-optimized code under some circumstances, at the expense of * the program's behavior being undefined if control reaches the * MOZ_ASSUME_UNREACHABLE. * * In Gecko, you probably should not use this macro outside of performance- or * size-critical code, because it's unsafe. If you don't care about code size * or performance, you should probably use MOZ_ASSERT or MOZ_CRASH. * * SpiderMonkey is a different beast, and there it's acceptable to use * MOZ_ASSUME_UNREACHABLE more widely. * * Note that MOZ_ASSUME_UNREACHABLE is noreturn, so it's valid not to return a * value following a MOZ_ASSUME_UNREACHABLE call. * * Example usage: * * enum ValueType { * VALUE_STRING, * VALUE_INT, * VALUE_FLOAT * }; * * int ptrToInt(ValueType type, void* value) { * { * // We know for sure that type is either INT or FLOAT, and we want this * // code to run as quickly as possible. * switch (type) { * case VALUE_INT: * return *(int*) value; * case VALUE_FLOAT: * return (int) *(float*) value; * default: * MOZ_ASSUME_UNREACHABLE("can only handle VALUE_INT and VALUE_FLOAT"); * } * } */ #if defined(DEBUG) # define MOZ_ASSUME_UNREACHABLE(...) \ do { \ MOZ_ASSERT(false, "MOZ_ASSUME_UNREACHABLE(" __VA_ARGS__ ")"); \ MOZ_ASSUME_UNREACHABLE_MARKER(); \ } while (0) #else # define MOZ_ASSUME_UNREACHABLE(reason) MOZ_ASSUME_UNREACHABLE_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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Atomics.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 (almost always) lock-free atomic operations. The operations here * are a subset of that which can be found in C++11's header, with a * different API to enforce consistent memory ordering constraints. * * Anyone caught using |volatile| for inter-thread memory safety needs to be * sent a copy of this header and the C++11 standard. */ #ifndef mozilla_Atomics_h #define mozilla_Atomics_h #include "mozilla/Assertions.h" #include "mozilla/TypeTraits.h" #include /* * Our minimum deployment target on clang/OS X is OS X 10.6, whose SDK * does not have . So be sure to check for support * along with C++0x support. */ #if defined(__clang__) /* * clang doesn't like libstdc++'s version of before GCC 4.7, * due to the loose typing of the __sync_* family of functions done by * GCC. We do not have a particularly good way to detect this sort of * case at this point, so just assume that if we're on a Linux system, * we can't use the system's . * * OpenBSD uses an old libstdc++ 4.2.1 and thus doesnt have . */ # if !defined(__linux__) && !defined(__OpenBSD__) && \ (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && \ __has_include() # define MOZ_HAVE_CXX11_ATOMICS # endif /* * Android uses a different C++ standard library that does not provide * support for . * * GCC 4.5.x and 4.6.x's unspecialized std::atomic template doesn't include * inline definitions for the functions declared therein. This oversight * leads to linking errors when using atomic enums. We therefore require * GCC 4.7 or higher. */ #elif defined(__GNUC__) && !defined(__ANDROID__) # include "mozilla/Compiler.h" # if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) && \ MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) # define MOZ_HAVE_CXX11_ATOMICS # endif #elif defined(_MSC_VER) && _MSC_VER >= 1700 # define MOZ_HAVE_CXX11_ATOMICS #endif namespace mozilla { /** * An enum of memory ordering possibilities for atomics. * * Memory ordering is the observable state of distinct values in memory. * (It's a separate concept from atomicity, which concerns whether an * operation can ever be observed in an intermediate state. Don't * conflate the two!) Given a sequence of operations in source code on * memory, it is *not* always the case that, at all times and on all * cores, those operations will appear to have occurred in that exact * sequence. First, the compiler might reorder that sequence, if it * thinks another ordering will be more efficient. Second, the CPU may * not expose so consistent a view of memory. CPUs will often perform * their own instruction reordering, above and beyond that performed by * the compiler. And each core has its own memory caches, and accesses * (reads and writes both) to "memory" may only resolve to out-of-date * cache entries -- not to the "most recently" performed operation in * some global sense. Any access to a value that may be used by * multiple threads, potentially across multiple cores, must therefore * have a memory ordering imposed on it, for all code on all * threads/cores to have a sufficiently coherent worldview. * * http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync and * http://en.cppreference.com/w/cpp/atomic/memory_order go into more * detail on all this, including examples of how each mode works. * * Note that for simplicity and practicality, not all of the modes in * C++11 are supported. The missing C++11 modes are either subsumed by * the modes we provide below, or not relevant for the CPUs we support * in Gecko. These three modes are confusing enough as it is! */ enum MemoryOrdering { /* * Relaxed ordering is the simplest memory ordering: none at all. * When the result of a write is observed, nothing may be inferred * about other memory. Writes ostensibly performed "before" on the * writing thread may not yet be visible. Writes performed "after" on * the writing thread may already be visible, if the compiler or CPU * reordered them. (The latter can happen if reads and/or writes get * held up in per-processor caches.) Relaxed ordering means * operations can always use cached values (as long as the actual * updates to atomic values actually occur, correctly, eventually), so * it's usually the fastest sort of atomic access. For this reason, * *it's also the most dangerous kind of access*. * * Relaxed ordering is good for things like process-wide statistics * counters that don't need to be consistent with anything else, so * long as updates themselves are atomic. (And so long as any * observations of that value can tolerate being out-of-date -- if you * need some sort of up-to-date value, you need some sort of other * synchronizing operation.) It's *not* good for locks, mutexes, * reference counts, etc. that mediate access to other memory, or must * be observably consistent with other memory. * * x86 architectures don't take advantage of the optimization * opportunities that relaxed ordering permits. Thus it's possible * that using relaxed ordering will "work" on x86 but fail elsewhere * (ARM, say, which *does* implement non-sequentially-consistent * relaxed ordering semantics). Be extra-careful using relaxed * ordering if you can't easily test non-x86 architectures! */ Relaxed, /* * When an atomic value is updated with ReleaseAcquire ordering, and * that new value is observed with ReleaseAcquire ordering, prior * writes (atomic or not) are also observable. What ReleaseAcquire * *doesn't* give you is any observable ordering guarantees for * ReleaseAcquire-ordered operations on different objects. For * example, if there are two cores that each perform ReleaseAcquire * operations on separate objects, each core may or may not observe * the operations made by the other core. The only way the cores can * be synchronized with ReleaseAcquire is if they both * ReleaseAcquire-access the same object. This implies that you can't * necessarily describe some global total ordering of ReleaseAcquire * operations. * * ReleaseAcquire ordering is good for (as the name implies) atomic * operations on values controlling ownership of things: reference * counts, mutexes, and the like. However, if you are thinking about * using these to implement your own locks or mutexes, you should take * a good, hard look at actual lock or mutex primitives first. */ ReleaseAcquire, /* * When an atomic value is updated with SequentiallyConsistent * ordering, all writes observable when the update is observed, just * as with ReleaseAcquire ordering. But, furthermore, a global total * ordering of SequentiallyConsistent operations *can* be described. * For example, if two cores perform SequentiallyConsistent operations * on separate objects, one core will observably perform its update * (and all previous operations will have completed), then the other * core will observably perform its update (and all previous * operations will have completed). (Although those previous * operations aren't themselves ordered -- they could be intermixed, * or ordered if they occur on atomic values with ordering * requirements.) SequentiallyConsistent is the *simplest and safest* * ordering of atomic operations -- it's always as if one operation * happens, then another, then another, in some order -- and every * core observes updates to happen in that single order. Because it * has the most synchronization requirements, operations ordered this * way also tend to be slowest. * * SequentiallyConsistent ordering can be desirable when multiple * threads observe objects, and they all have to agree on the * observable order of changes to them. People expect * SequentiallyConsistent ordering, even if they shouldn't, when * writing code, atomic or otherwise. SequentiallyConsistent is also * the ordering of choice when designing lockless data structures. If * you don't know what order to use, use this one. */ SequentiallyConsistent, }; } // namespace mozilla // Build up the underlying intrinsics. #ifdef MOZ_HAVE_CXX11_ATOMICS # include namespace mozilla { namespace detail { /* * We provide CompareExchangeFailureOrder to work around a bug in some * versions of GCC's header. See bug 898491. */ template struct AtomicOrderConstraints; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_relaxed; static const std::memory_order LoadOrder = std::memory_order_relaxed; static const std::memory_order StoreOrder = std::memory_order_relaxed; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_relaxed; }; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_acq_rel; static const std::memory_order LoadOrder = std::memory_order_acquire; static const std::memory_order StoreOrder = std::memory_order_release; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_acquire; }; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_seq_cst; static const std::memory_order LoadOrder = std::memory_order_seq_cst; static const std::memory_order StoreOrder = std::memory_order_seq_cst; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_seq_cst; }; template struct IntrinsicBase { typedef std::atomic ValueType; typedef AtomicOrderConstraints OrderedOp; }; template struct IntrinsicMemoryOps : public IntrinsicBase { typedef IntrinsicBase Base; static T load(const typename Base::ValueType& ptr) { return ptr.load(Base::OrderedOp::LoadOrder); } static void store(typename Base::ValueType& ptr, T val) { ptr.store(val, Base::OrderedOp::StoreOrder); } static T exchange(typename Base::ValueType& ptr, T val) { return ptr.exchange(val, Base::OrderedOp::AtomicRMWOrder); } static bool compareExchange(typename Base::ValueType& ptr, T oldVal, T newVal) { return ptr.compare_exchange_strong(oldVal, newVal, Base::OrderedOp::AtomicRMWOrder, Base::OrderedOp::CompareExchangeFailureOrder); } }; template struct IntrinsicAddSub : public IntrinsicBase { typedef IntrinsicBase Base; static T add(typename Base::ValueType& ptr, T val) { return ptr.fetch_add(val, Base::OrderedOp::AtomicRMWOrder); } static T sub(typename Base::ValueType& ptr, T val) { return ptr.fetch_sub(val, Base::OrderedOp::AtomicRMWOrder); } }; template struct IntrinsicAddSub : public IntrinsicBase { typedef IntrinsicBase Base; static T* add(typename Base::ValueType& ptr, ptrdiff_t val) { return ptr.fetch_add(fixupAddend(val), Base::OrderedOp::AtomicRMWOrder); } static T* sub(typename Base::ValueType& ptr, ptrdiff_t val) { return ptr.fetch_sub(fixupAddend(val), Base::OrderedOp::AtomicRMWOrder); } private: /* * GCC 4.6's header has a bug where adding X to an * atomic is not the same as adding X to a T*. Hence the need * for this function to provide the correct addend. */ static ptrdiff_t fixupAddend(ptrdiff_t val) { #if defined(__clang__) || defined(_MSC_VER) return val; #elif defined(__GNUC__) && MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) && \ !MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) return val * sizeof(T); #else return val; #endif } }; template struct IntrinsicIncDec : public IntrinsicAddSub { typedef IntrinsicBase Base; static T inc(typename Base::ValueType& ptr) { return IntrinsicAddSub::add(ptr, 1); } static T dec(typename Base::ValueType& ptr) { return IntrinsicAddSub::sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { typedef IntrinsicBase Base; static T or_(typename Base::ValueType& ptr, T val) { return ptr.fetch_or(val, Base::OrderedOp::AtomicRMWOrder); } static T xor_(typename Base::ValueType& ptr, T val) { return ptr.fetch_xor(val, Base::OrderedOp::AtomicRMWOrder); } static T and_(typename Base::ValueType& ptr, T val) { return ptr.fetch_and(val, Base::OrderedOp::AtomicRMWOrder); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #elif defined(__GNUC__) namespace mozilla { namespace detail { /* * The __sync_* family of intrinsics is documented here: * * http://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Atomic-Builtins.html * * While these intrinsics are deprecated in favor of the newer __atomic_* * family of intrincs: * * http://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/_005f_005fatomic-Builtins.html * * any GCC version that supports the __atomic_* intrinsics will also support * the header and so will be handled above. We provide a version of * atomics using the __sync_* intrinsics to support older versions of GCC. * * All __sync_* intrinsics that we use below act as full memory barriers, for * both compiler and hardware reordering, except for __sync_lock_test_and_set, * which is a only an acquire barrier. When we call __sync_lock_test_and_set, * we add a barrier above it as appropriate. */ template struct Barrier; /* * Some processors (in particular, x86) don't require quite so many calls to * __sync_sychronize as our specializations of Barrier produce. If * performance turns out to be an issue, defining these specializations * on a per-processor basis would be a good first tuning step. */ template<> struct Barrier { static void beforeLoad() {} static void afterLoad() {} static void beforeStore() {} static void afterStore() {} }; template<> struct Barrier { static void beforeLoad() {} static void afterLoad() { __sync_synchronize(); } static void beforeStore() { __sync_synchronize(); } static void afterStore() {} }; template<> struct Barrier { static void beforeLoad() { __sync_synchronize(); } static void afterLoad() { __sync_synchronize(); } static void beforeStore() { __sync_synchronize(); } static void afterStore() { __sync_synchronize(); } }; template struct IntrinsicMemoryOps { static T load(const T& ptr) { Barrier::beforeLoad(); T val = ptr; Barrier::afterLoad(); return val; } static void store(T& ptr, T val) { Barrier::beforeStore(); ptr = val; Barrier::afterStore(); } static T exchange(T& ptr, T val) { // __sync_lock_test_and_set is only an acquire barrier; loads and stores // can't be moved up from after to before it, but they can be moved down // from before to after it. We may want a stricter ordering, so we need // an explicit barrier. Barrier::beforeStore(); return __sync_lock_test_and_set(&ptr, val); } static bool compareExchange(T& ptr, T oldVal, T newVal) { return __sync_bool_compare_and_swap(&ptr, oldVal, newVal); } }; template struct IntrinsicAddSub { typedef T ValueType; static T add(T& ptr, T val) { return __sync_fetch_and_add(&ptr, val); } static T sub(T& ptr, T val) { return __sync_fetch_and_sub(&ptr, val); } }; template struct IntrinsicAddSub { typedef T* ValueType; /* * The reinterpret_casts are needed so that * __sync_fetch_and_{add,sub} will properly type-check. * * Also, these functions do not provide standard semantics for * pointer types, so we need to adjust the addend. */ static ValueType add(ValueType& ptr, ptrdiff_t val) { ValueType amount = reinterpret_cast(val * sizeof(T)); return __sync_fetch_and_add(&ptr, amount); } static ValueType sub(ValueType& ptr, ptrdiff_t val) { ValueType amount = reinterpret_cast(val * sizeof(T)); return __sync_fetch_and_sub(&ptr, amount); } }; template struct IntrinsicIncDec : public IntrinsicAddSub { static T inc(T& ptr) { return IntrinsicAddSub::add(ptr, 1); } static T dec(T& ptr) { return IntrinsicAddSub::sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { static T or_(T& ptr, T val) { return __sync_fetch_and_or(&ptr, val); } static T xor_(T& ptr, T val) { return __sync_fetch_and_xor(&ptr, val); } static T and_(T& ptr, T val) { return __sync_fetch_and_and(&ptr, val); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #elif defined(_MSC_VER) /* * Windows comes with a full complement of atomic operations. * Unfortunately, most of those aren't available for Windows XP (even if * the compiler supports intrinsics for them), which is the oldest * version of Windows we support. Therefore, we only provide operations * on 32-bit datatypes for 32-bit Windows versions; for 64-bit Windows * versions, we support 64-bit datatypes as well. * * To avoid namespace pollution issues, we declare whatever functions we * need ourselves. */ extern "C" { long __cdecl _InterlockedExchangeAdd(long volatile* dst, long value); long __cdecl _InterlockedOr(long volatile* dst, long value); long __cdecl _InterlockedXor(long volatile* dst, long value); long __cdecl _InterlockedAnd(long volatile* dst, long value); long __cdecl _InterlockedExchange(long volatile *dst, long value); long __cdecl _InterlockedCompareExchange(long volatile *dst, long newVal, long oldVal); } # pragma intrinsic(_InterlockedExchangeAdd) # pragma intrinsic(_InterlockedOr) # pragma intrinsic(_InterlockedXor) # pragma intrinsic(_InterlockedAnd) # pragma intrinsic(_InterlockedExchange) # pragma intrinsic(_InterlockedCompareExchange) namespace mozilla { namespace detail { # if !defined(_M_IX86) && !defined(_M_X64) /* * The implementations below are optimized for x86ish systems. You * will have to modify them if you are porting to Windows on a * different architecture. */ # error "Unknown CPU type" # endif /* * The PrimitiveIntrinsics template should define |Type|, the datatype of size * DataSize upon which we operate, and the following eight functions. * * static Type add(Type* ptr, Type val); * static Type sub(Type* ptr, Type val); * static Type or_(Type* ptr, Type val); * static Type xor_(Type* ptr, Type val); * static Type and_(Type* ptr, Type val); * * These functions perform the obvious operation on the value contained in * |*ptr| combined with |val| and return the value previously stored in * |*ptr|. * * static void store(Type* ptr, Type val); * * This function atomically stores |val| into |*ptr| and must provide a full * memory fence after the store to prevent compiler and hardware instruction * reordering. It should also act as a compiler barrier to prevent reads and * writes from moving to after the store. * * static Type exchange(Type* ptr, Type val); * * This function atomically stores |val| into |*ptr| and returns the previous * contents of *ptr; * * static bool compareExchange(Type* ptr, Type oldVal, Type newVal); * * This function atomically performs the following operation: * * if (*ptr == oldVal) { * *ptr = newVal; * return true; * } else { * return false; * } * */ template struct PrimitiveIntrinsics; template<> struct PrimitiveIntrinsics<4> { typedef long Type; static Type add(Type* ptr, Type val) { return _InterlockedExchangeAdd(ptr, val); } static Type sub(Type* ptr, Type val) { /* * _InterlockedExchangeSubtract isn't available before Windows 7, * and we must support Windows XP. */ return _InterlockedExchangeAdd(ptr, -val); } static Type or_(Type* ptr, Type val) { return _InterlockedOr(ptr, val); } static Type xor_(Type* ptr, Type val) { return _InterlockedXor(ptr, val); } static Type and_(Type* ptr, Type val) { return _InterlockedAnd(ptr, val); } static void store(Type* ptr, Type val) { _InterlockedExchange(ptr, val); } static Type exchange(Type* ptr, Type val) { return _InterlockedExchange(ptr, val); } static bool compareExchange(Type* ptr, Type oldVal, Type newVal) { return _InterlockedCompareExchange(ptr, newVal, oldVal) == oldVal; } }; # if defined(_M_X64) extern "C" { long long __cdecl _InterlockedExchangeAdd64(long long volatile* dst, long long value); long long __cdecl _InterlockedOr64(long long volatile* dst, long long value); long long __cdecl _InterlockedXor64(long long volatile* dst, long long value); long long __cdecl _InterlockedAnd64(long long volatile* dst, long long value); long long __cdecl _InterlockedExchange64(long long volatile* dst, long long value); long long __cdecl _InterlockedCompareExchange64(long long volatile* dst, long long newVal, long long oldVal); } # pragma intrinsic(_InterlockedExchangeAdd64) # pragma intrinsic(_InterlockedOr64) # pragma intrinsic(_InterlockedXor64) # pragma intrinsic(_InterlockedAnd64) # pragma intrinsic(_InterlockedExchange64) # pragma intrinsic(_InterlockedCompareExchange64) template <> struct PrimitiveIntrinsics<8> { typedef __int64 Type; static Type add(Type* ptr, Type val) { return _InterlockedExchangeAdd64(ptr, val); } static Type sub(Type* ptr, Type val) { /* * There is no _InterlockedExchangeSubtract64. */ return _InterlockedExchangeAdd64(ptr, -val); } static Type or_(Type* ptr, Type val) { return _InterlockedOr64(ptr, val); } static Type xor_(Type* ptr, Type val) { return _InterlockedXor64(ptr, val); } static Type and_(Type* ptr, Type val) { return _InterlockedAnd64(ptr, val); } static void store(Type* ptr, Type val) { _InterlockedExchange64(ptr, val); } static Type exchange(Type* ptr, Type val) { return _InterlockedExchange64(ptr, val); } static bool compareExchange(Type* ptr, Type oldVal, Type newVal) { return _InterlockedCompareExchange64(ptr, newVal, oldVal) == oldVal; } }; # endif extern "C" { void _ReadWriteBarrier(); } # pragma intrinsic(_ReadWriteBarrier) template struct Barrier; /* * We do not provide an afterStore method in Barrier, as Relaxed and * ReleaseAcquire orderings do not require one, and the required barrier * for SequentiallyConsistent is handled by PrimitiveIntrinsics. */ template<> struct Barrier { static void beforeLoad() {} static void afterLoad() {} static void beforeStore() {} }; template<> struct Barrier { static void beforeLoad() {} static void afterLoad() { _ReadWriteBarrier(); } static void beforeStore() { _ReadWriteBarrier(); } }; template<> struct Barrier { static void beforeLoad() { _ReadWriteBarrier(); } static void afterLoad() { _ReadWriteBarrier(); } static void beforeStore() { _ReadWriteBarrier(); } }; template struct CastHelper { static PrimType toPrimType(T val) { return static_cast(val); } static T fromPrimType(PrimType val) { return static_cast(val); } }; template struct CastHelper { static PrimType toPrimType(T* val) { return reinterpret_cast(val); } static T* fromPrimType(PrimType val) { return reinterpret_cast(val); } }; template struct IntrinsicBase { typedef T ValueType; typedef PrimitiveIntrinsics Primitives; typedef typename Primitives::Type PrimType; static_assert(sizeof(PrimType) == sizeof(T), "Selection of PrimitiveIntrinsics was wrong"); typedef CastHelper Cast; }; template struct IntrinsicMemoryOps : public IntrinsicBase { static ValueType load(const ValueType& ptr) { Barrier::beforeLoad(); ValueType val = ptr; Barrier::afterLoad(); return val; } static void store(ValueType& ptr, ValueType val) { // For SequentiallyConsistent, Primitives::store() will generate the // proper memory fence. Everything else just needs a barrier before // the store. if (Order == SequentiallyConsistent) { Primitives::store(reinterpret_cast(&ptr), Cast::toPrimType(val)); } else { Barrier::beforeStore(); ptr = val; } } static ValueType exchange(ValueType& ptr, ValueType val) { PrimType oldval = Primitives::exchange(reinterpret_cast(&ptr), Cast::toPrimType(val)); return Cast::fromPrimType(oldval); } static bool compareExchange(ValueType& ptr, ValueType oldVal, ValueType newVal) { return Primitives::compareExchange(reinterpret_cast(&ptr), Cast::toPrimType(oldVal), Cast::toPrimType(newVal)); } }; template struct IntrinsicApplyHelper : public IntrinsicBase { typedef PrimType (*BinaryOp)(PrimType*, PrimType); typedef PrimType (*UnaryOp)(PrimType*); static ValueType applyBinaryFunction(BinaryOp op, ValueType& ptr, ValueType val) { PrimType* primTypePtr = reinterpret_cast(&ptr); PrimType primTypeVal = Cast::toPrimType(val); return Cast::fromPrimType(op(primTypePtr, primTypeVal)); } static ValueType applyUnaryFunction(UnaryOp op, ValueType& ptr) { PrimType* primTypePtr = reinterpret_cast(&ptr); return Cast::fromPrimType(op(primTypePtr)); } }; template struct IntrinsicAddSub : public IntrinsicApplyHelper { static ValueType add(ValueType& ptr, ValueType val) { return applyBinaryFunction(&Primitives::add, ptr, val); } static ValueType sub(ValueType& ptr, ValueType val) { return applyBinaryFunction(&Primitives::sub, ptr, val); } }; template struct IntrinsicAddSub : public IntrinsicApplyHelper { static ValueType add(ValueType& ptr, ptrdiff_t amount) { return applyBinaryFunction(&Primitives::add, ptr, (ValueType)(amount * sizeof(ValueType))); } static ValueType sub(ValueType& ptr, ptrdiff_t amount) { return applyBinaryFunction(&Primitives::sub, ptr, (ValueType)(amount * sizeof(ValueType))); } }; template struct IntrinsicIncDec : public IntrinsicAddSub { static ValueType inc(ValueType& ptr) { return add(ptr, 1); } static ValueType dec(ValueType& ptr) { return sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { static ValueType or_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::or_, ptr, val); } static ValueType xor_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::xor_, ptr, val); } static ValueType and_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::and_, ptr, val); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #else # error "Atomic compiler intrinsics are not supported on your platform" #endif namespace mozilla { namespace detail { template class AtomicBase { // We only support 32-bit types on 32-bit Windows, which constrains our // implementation elsewhere. But we support pointer-sized types everywhere. static_assert(sizeof(T) == 4 || (sizeof(uintptr_t) == 8 && sizeof(T) == 8), "mozilla/Atomics.h only supports 32-bit and pointer-sized types"); protected: typedef typename detail::AtomicIntrinsics Intrinsics; typename Intrinsics::ValueType mValue; public: AtomicBase() : mValue() {} AtomicBase(T aInit) { Intrinsics::store(mValue, aInit); } operator T() const { return Intrinsics::load(mValue); } T operator=(T aValue) { Intrinsics::store(mValue, aValue); return aValue; } /** * Performs an atomic swap operation. aValue is stored and the previous * value of this variable is returned. */ T exchange(T aValue) { return Intrinsics::exchange(mValue, aValue); } /** * Performs an atomic compare-and-swap operation and returns true if it * succeeded. This is equivalent to atomically doing * * if (mValue == aOldValue) { * mValue = aNewValue; * return true; * } else { * return false; * } */ bool compareExchange(T aOldValue, T aNewValue) { return Intrinsics::compareExchange(mValue, aOldValue, aNewValue); } private: template AtomicBase(const AtomicBase& aCopy) MOZ_DELETE; }; template class AtomicBaseIncDec : public AtomicBase { typedef typename detail::AtomicBase Base; public: AtomicBaseIncDec() : Base() {} AtomicBaseIncDec(T aInit) : Base(aInit) {} using Base::operator=; T operator++(int) { return Base::Intrinsics::inc(Base::mValue); } T operator--(int) { return Base::Intrinsics::dec(Base::mValue); } T operator++() { return Base::Intrinsics::inc(Base::mValue) + 1; } T operator--() { return Base::Intrinsics::dec(Base::mValue) - 1; } private: template AtomicBaseIncDec(const AtomicBaseIncDec& aCopy) MOZ_DELETE; }; } // namespace detail /** * A wrapper for a type that enforces that all memory accesses are atomic. * * In general, where a variable |T foo| exists, |Atomic foo| can be used in * its place. Implementations for integral and pointer types are provided * below. * * Atomic accesses are sequentially consistent by default. You should * use the default unless you are tall enough to ride the * memory-ordering roller coaster (if you're not sure, you aren't) and * you have a compelling reason to do otherwise. * * There is one exception to the case of atomic memory accesses: providing an * initial value of the atomic value is not guaranteed to be atomic. This is a * deliberate design choice that enables static atomic variables to be declared * without introducing extra static constructors. */ template class Atomic; /** * Atomic implementation for integral types. * * In addition to atomic store and load operations, compound assignment and * increment/decrement operators are implemented which perform the * corresponding read-modify-write operation atomically. Finally, an atomic * swap method is provided. */ template class Atomic::value>::Type> : public detail::AtomicBaseIncDec { typedef typename detail::AtomicBaseIncDec Base; public: Atomic() : Base() {} Atomic(T aInit) : Base(aInit) {} using Base::operator=; T operator+=(T delta) { return Base::Intrinsics::add(Base::mValue, delta) + delta; } T operator-=(T delta) { return Base::Intrinsics::sub(Base::mValue, delta) - delta; } T operator|=(T val) { return Base::Intrinsics::or_(Base::mValue, val) | val; } T operator^=(T val) { return Base::Intrinsics::xor_(Base::mValue, val) ^ val; } T operator&=(T val) { return Base::Intrinsics::and_(Base::mValue, val) & val; } private: Atomic(Atomic& aOther) MOZ_DELETE; }; /** * Atomic implementation for pointer types. * * An atomic compare-and-swap primitive for pointer variables is provided, as * are atomic increment and decement operators. Also provided are the compound * assignment operators for addition and subtraction. Atomic swap (via * exchange()) is included as well. */ template class Atomic : public detail::AtomicBaseIncDec { typedef typename detail::AtomicBaseIncDec Base; public: Atomic() : Base() {} Atomic(T* aInit) : Base(aInit) {} using Base::operator=; T* operator+=(ptrdiff_t delta) { return Base::Intrinsics::add(Base::mValue, delta) + delta; } T* operator-=(ptrdiff_t delta) { return Base::Intrinsics::sub(Base::mValue, delta) - delta; } private: Atomic(Atomic& aOther) MOZ_DELETE; }; /** * Atomic implementation for enum types. * * The atomic store and load operations and the atomic swap method is provided. */ template class Atomic::value>::Type> : public detail::AtomicBase { typedef typename detail::AtomicBase Base; public: Atomic() : Base() {} Atomic(T aInit) : Base(aInit) {} using Base::operator=; private: Atomic(Atomic& aOther) MOZ_DELETE; }; } // namespace mozilla #endif /* mozilla_Atomics_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Attributes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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). * * The MOZ_ALWAYS_INLINE_EVEN_DEBUG macro is yet stronger. It tells the * compiler to inline even in DEBUG builds. It should be used very rarely. */ #if defined(_MSC_VER) # define MOZ_ALWAYS_INLINE_EVEN_DEBUG __forceinline #elif defined(__GNUC__) # define MOZ_ALWAYS_INLINE_EVEN_DEBUG __attribute__((always_inline)) MOZ_INLINE #else # define MOZ_ALWAYS_INLINE_EVEN_DEBUG MOZ_INLINE #endif #if defined(DEBUG) # define MOZ_ALWAYS_INLINE MOZ_INLINE #else # define MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG #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. * The MOZ_CONSTEXPR_VAR specifier tells a C++11 compiler that a variable's * value may be computed at compile time. It should be prefered to just * marking variables as MOZ_CONSTEXPR because if the compiler does not support * constexpr it will fall back to making the variable const, and some compilers * do not accept variables being marked both const and constexpr. */ #ifdef MOZ_HAVE_CXX11_CONSTEXPR # define MOZ_CONSTEXPR constexpr # define MOZ_CONSTEXPR_VAR constexpr #else # define MOZ_CONSTEXPR /* no support */ # define MOZ_CONSTEXPR_VAR const #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. * MOZ_STACK_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the stack, so it is a compile-time error to use it, or * an array of such objects, as a global or static variable, or as the type of * a new expression (unless placement new is being used). If a member of * another class uses this class, or if another class inherits from this * class, then it is considered to be a stack class as well, although this * attribute need not be provided in such cases. * MOZ_NONHEAP_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the stack or in static storage, so it is a compile-time * error to use it, or an array of such objects, as the type of a new * expression (unless placement new is being used). If a member of another * class uses this class, or if another class inherits from this class, then * it is considered to be a non-heap class as well, although this attribute * need not be provided in such cases. */ #ifdef MOZ_CLANG_PLUGIN # define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override"))) # define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class"))) # define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class"))) #else # define MOZ_MUST_OVERRIDE /* nothing */ # define MOZ_STACK_CLASS /* nothing */ # define MOZ_NONHEAP_CLASS /* nothing */ #endif /* MOZ_CLANG_PLUGIN */ /* * MOZ_THIS_IN_INITIALIZER_LIST is used to avoid a warning when we know that * it's safe to use 'this' in an initializer list. */ #ifdef _MSC_VER # define MOZ_THIS_IN_INITIALIZER_LIST() \ __pragma(warning(push)) \ __pragma(warning(disable:4355)) \ this \ __pragma(warning(pop)) #else # define MOZ_THIS_IN_INITIALIZER_LIST() this #endif #endif /* __cplusplus */ #endif /* mozilla_Attributes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/BloomFilter.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Util.h" #include #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() { 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Casting.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Cast operations to supplement the built-in casting operations. */ #ifndef mozilla_Casting_h #define mozilla_Casting_h #include "mozilla/Assertions.h" #include "mozilla/TypeTraits.h" #include namespace mozilla { /** * Return a value of type |To|, containing the underlying bit pattern of |from|. * * |To| and |From| must be types of the same size; be careful of cross-platform * size differences, or this might fail to compile on some but not all * platforms. */ template inline To BitwiseCast(const From from) { static_assert(sizeof(From) == sizeof(To), "To and From must have the same size"); union { From from; To to; } u; u.from = from; return u.to; } namespace detail { enum ToSignedness { ToIsSigned, ToIsUnsigned }; enum FromSignedness { FromIsSigned, FromIsUnsigned }; template::value ? FromIsSigned : FromIsUnsigned, ToSignedness = IsSigned::value ? ToIsSigned : ToIsUnsigned> struct BoundsCheckImpl; // Implicit conversions on operands to binary operations make this all a bit // hard to verify. Attempt to ease the pain below by *only* comparing values // that are obviously the same type (and will undergo no further conversions), // even when it's not strictly necessary, for explicitness. enum UUComparison { FromIsBigger, FromIsNotBigger }; // Unsigned-to-unsigned range check template sizeof(To)) ? FromIsBigger : FromIsNotBigger> struct UnsignedUnsignedCheck; template struct UnsignedUnsignedCheck { public: static bool checkBounds(const From from) { return from <= From(To(-1)); } }; template struct UnsignedUnsignedCheck { public: static bool checkBounds(const From from) { return true; } }; template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { return UnsignedUnsignedCheck::checkBounds(from); } }; // Signed-to-unsigned range check template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { if (from < 0) return false; if (sizeof(To) >= sizeof(From)) return true; return from <= From(To(-1)); } }; // Unsigned-to-signed range check enum USComparison { FromIsSmaller, FromIsNotSmaller }; template struct UnsignedSignedCheck; template struct UnsignedSignedCheck { public: static bool checkBounds(const From from) { return true; } }; template struct UnsignedSignedCheck { public: static bool checkBounds(const From from) { const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); return from <= From(MaxValue); } }; template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { return UnsignedSignedCheck::checkBounds(from); } }; // Signed-to-signed range check template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { if (sizeof(From) <= sizeof(To)) return true; const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); const To MinValue = -MaxValue - To(1); return From(MinValue) <= from && From(from) <= From(MaxValue); } }; template::value && IsIntegral::value> class BoundsChecker; template class BoundsChecker { public: static bool checkBounds(const From from) { return true; } }; template class BoundsChecker { public: static bool checkBounds(const From from) { return BoundsCheckImpl::checkBounds(from); } }; template inline bool IsInBounds(const From from) { return BoundsChecker::checkBounds(from); } } // namespace detail /** * Cast a value of integral type |From| to a value of integral type |To|, * asserting that the cast will be a safe cast per C++ (that is, that |to| is in * the range of values permitted for the type |From|). */ template inline To SafeCast(const From from) { MOZ_ASSERT((detail::IsInBounds(from))); return static_cast(from); } } // namespace mozilla #endif /* mozilla_Casting_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Char16.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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) static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?"); static_assert(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?"); static_assert(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?"); #endif /* mozilla_Char16_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/CheckedInt.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 #include #ifdef MOZ_CHECKEDINT_USE_MFBT # include "mozilla/Assertions.h" #else # include # 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; }; 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 IsModValidImpl; template inline bool IsModValid(T x, T y) { return IsModValidImpl::run(x, y); } /* * Mod is pretty simple. * For now, let's just use the ANSI C definition: * If x or y are negative, the results are implementation defined. * Consider these invalid. * Undefined for y=0. * The result will never exceed either x or y. * * Checking that x>=0 is a warning when T is unsigned. */ template struct IsModValidImpl { static inline bool run(T x, T y) { return y >= 1; } }; template struct IsModValidImpl { static inline bool run(T x, T y) { if (x < 0) return false; return y >= 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) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); } friend struct 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)) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); } template friend class CheckedInt; template CheckedInt toChecked() const { CheckedInt ret(mValue); ret.mIsValid = ret.mIsValid && mIsValid; return ret; } /** Constructs a valid checked integer with initial value 0 */ CheckedInt() : mValue(0), mIsValid(true) { 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); 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, /) MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mod, %) #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) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); 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(/, /=) 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Compiler.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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__) #define MOZ_IS_GCC 1 /* * 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 #else #define MOZ_IS_GCC 0 #endif #endif /* mozilla_Compiler_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Constants.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/DebugOnly.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Decimal.h ================================================ /* * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "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 COPYRIGHT * OWNER OR CONTRIBUTORS 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. */ /** * Imported from: * http://src.chromium.org/viewvc/blink/trunk/Source/core/platform/Decimal.h * Check hg log for the svn rev of the last update from Blink core. */ #ifndef Decimal_h #define Decimal_h #include "mozilla/Assertions.h" #include #include "mozilla/Types.h" #include #ifndef ASSERT #define DEFINED_ASSERT_FOR_DECIMAL_H 1 #define ASSERT MOZ_ASSERT #endif // To use WTF_MAKE_FAST_ALLOCATED we'd need: // http://src.chromium.org/viewvc/blink/trunk/Source/wtf/FastMalloc.h // Since we don't allocate Decimal objects, no need. #define WTF_MAKE_FAST_ALLOCATED \ void ignore_this_dummy_method() MOZ_DELETE namespace WebCore { namespace DecimalPrivate { class SpecialValueHandler; } // This class represents decimal base floating point number. // // FIXME: Once all C++ compiler support decimal type, we should replace this // class to compiler supported one. See below URI for current status of decimal // type for C++: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1977.html class Decimal { WTF_MAKE_FAST_ALLOCATED; public: enum Sign { Positive, Negative, }; // You should not use EncodedData other than unit testing. class EncodedData { // For accessing FormatClass. friend class Decimal; friend class DecimalPrivate::SpecialValueHandler; public: EncodedData(Sign, int exponent, uint64_t coefficient); bool operator==(const EncodedData&) const; bool operator!=(const EncodedData& another) const { return !operator==(another); } uint64_t coefficient() const { return m_coefficient; } int countDigits() const; int exponent() const { return m_exponent; } bool isFinite() const { return !isSpecial(); } bool isInfinity() const { return m_formatClass == ClassInfinity; } bool isNaN() const { return m_formatClass == ClassNaN; } bool isSpecial() const { return m_formatClass == ClassInfinity || m_formatClass == ClassNaN; } bool isZero() const { return m_formatClass == ClassZero; } Sign sign() const { return m_sign; } void setSign(Sign sign) { m_sign = sign; } private: enum FormatClass { ClassInfinity, ClassNormal, ClassNaN, ClassZero, }; EncodedData(Sign, FormatClass); FormatClass formatClass() const { return m_formatClass; } uint64_t m_coefficient; int16_t m_exponent; FormatClass m_formatClass; Sign m_sign; }; MFBT_API Decimal(int32_t = 0); MFBT_API Decimal(Sign, int exponent, uint64_t coefficient); MFBT_API Decimal(const Decimal&); MFBT_API Decimal& operator=(const Decimal&); MFBT_API Decimal& operator+=(const Decimal&); MFBT_API Decimal& operator-=(const Decimal&); MFBT_API Decimal& operator*=(const Decimal&); MFBT_API Decimal& operator/=(const Decimal&); MFBT_API Decimal operator-() const; MFBT_API bool operator==(const Decimal&) const; MFBT_API bool operator!=(const Decimal&) const; MFBT_API bool operator<(const Decimal&) const; MFBT_API bool operator<=(const Decimal&) const; MFBT_API bool operator>(const Decimal&) const; MFBT_API bool operator>=(const Decimal&) const; MFBT_API Decimal operator+(const Decimal&) const; MFBT_API Decimal operator-(const Decimal&) const; MFBT_API Decimal operator*(const Decimal&) const; MFBT_API Decimal operator/(const Decimal&) const; int exponent() const { ASSERT(isFinite()); return m_data.exponent(); } bool isFinite() const { return m_data.isFinite(); } bool isInfinity() const { return m_data.isInfinity(); } bool isNaN() const { return m_data.isNaN(); } bool isNegative() const { return sign() == Negative; } bool isPositive() const { return sign() == Positive; } bool isSpecial() const { return m_data.isSpecial(); } bool isZero() const { return m_data.isZero(); } MFBT_API Decimal abs() const; MFBT_API Decimal ceiling() const; MFBT_API Decimal floor() const; MFBT_API Decimal remainder(const Decimal&) const; MFBT_API Decimal round() const; MFBT_API double toDouble() const; // Note: toString method supports infinity and nan but fromString not. MFBT_API std::string toString() const; MFBT_API bool toString(char* strBuf, size_t bufLength) const; static MFBT_API Decimal fromDouble(double); // fromString supports following syntax EBNF: // number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)? // | sign? '.' digit+ (exponent-marker sign? digit+)? // sign ::= '+' | '-' // exponent-marker ::= 'e' | 'E' // digit ::= '0' | '1' | ... | '9' // Note: fromString doesn't support "infinity" and "nan". static MFBT_API Decimal fromString(const std::string& aValue); static MFBT_API Decimal infinity(Sign); static MFBT_API Decimal nan(); static MFBT_API Decimal zero(Sign); // You should not use below methods. We expose them for unit testing. MFBT_API explicit Decimal(const EncodedData&); const EncodedData& value() const { return m_data; } private: struct AlignedOperands { uint64_t lhsCoefficient; uint64_t rhsCoefficient; int exponent; }; MFBT_API Decimal(double); MFBT_API Decimal compareTo(const Decimal&) const; static MFBT_API AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs); static inline Sign invertSign(Sign sign) { return sign == Negative ? Positive : Negative; } Sign sign() const { return m_data.sign(); } EncodedData m_data; }; } // namespace WebCore namespace mozilla { typedef WebCore::Decimal Decimal; } #undef WTF_MAKE_FAST_ALLOCATED #ifdef DEFINED_ASSERT_FOR_DECIMAL_H #undef DEFINED_ASSERT_FOR_DECIMAL_H #undef ASSERT #endif #endif // Decimal_h ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Endian.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Functions for reading and writing integers in various endiannesses. */ /* * The classes LittleEndian and BigEndian expose static methods for * reading and writing 16-, 32-, and 64-bit signed and unsigned integers * in their respective endianness. The naming scheme is: * * {Little,Big}Endian::{read,write}{Uint,Int} * * For instance, LittleEndian::readInt32 will read a 32-bit signed * integer from memory in little endian format. Similarly, * BigEndian::writeUint16 will write a 16-bit unsigned integer to memory * in big-endian format. * * The class NativeEndian exposes methods for conversion of existing * data to and from the native endianness. These methods are intended * for cases where data needs to be transferred, serialized, etc. * swap{To,From}{Little,Big}Endian byteswap a single value if necessary. * Bulk conversion functions are also provided which optimize the * no-conversion-needed case: * * - copyAndSwap{To,From}{Little,Big}Endian; * - swap{To,From}{Little,Big}EndianInPlace. * * The *From* variants are intended to be used for reading data and the * *To* variants for writing data. * * Methods on NativeEndian work with integer data of any type. * Floating-point data is not supported. * * For clarity in networking code, "Network" may be used as a synonym * for "Big" in any of the above methods or class names. * * As an example, reading a file format header whose fields are stored * in big-endian format might look like: * * class ExampleHeader * { * private: * uint32_t magic; * uint32_t length; * uint32_t totalRecords; * uint64_t checksum; * * public: * ExampleHeader(const void* data) { * const uint8_t* ptr = static_cast(data); * magic = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * length = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * totalRecords = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * checksum = BigEndian::readUint64(ptr); * } * ... * }; */ #ifndef mozilla_Endian_h #define mozilla_Endian_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/DebugOnly.h" #include "mozilla/TypeTraits.h" #include #include #if defined(_MSC_VER) && _MSC_VER >= 1300 # include # pragma intrinsic(_byteswap_ushort) # pragma intrinsic(_byteswap_ulong) # pragma intrinsic(_byteswap_uint64) #endif #if defined(_WIN64) # if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) # define MOZ_LITTLE_ENDIAN 1 # else # error "CPU type is unknown" # endif #elif defined(_WIN32) # if defined(_M_IX86) # define MOZ_LITTLE_ENDIAN 1 # else # error "CPU type is unknown" # endif #elif defined(__APPLE__) # if __LITTLE_ENDIAN__ # define MOZ_LITTLE_ENDIAN 1 # elif __BIG_ENDIAN__ # define MOZ_BIG_ENDIAN 1 # endif #elif defined(__GNUC__) && \ defined(__BYTE_ORDER__) && \ defined(__ORDER_LITTLE_ENDIAN__) && \ defined(__ORDER_BIG_ENDIAN__) /* * Some versions of GCC provide architecture-independent macros for * this. Yes, there are more than two values for __BYTE_ORDER__. */ # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define MOZ_LITTLE_ENDIAN 1 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define MOZ_BIG_ENDIAN 1 # else # error "Can't handle mixed-endian architectures" # endif /* * We can't include useful headers like or * here because they're not present on all platforms. Instead we have * this big conditional that ideally will catch all the interesting * cases. */ #elif defined(__sparc) || defined(__sparc__) || \ defined(_POWER) || defined(__powerpc__) || \ defined(__ppc__) || defined(__hppa) || \ defined(_MIPSEB) || defined(__ARMEB__) || \ defined(__s390__) || \ (defined(__sh__) && defined(__LITTLE_ENDIAN__)) || \ (defined(__ia64) && defined(__BIG_ENDIAN__)) # define MOZ_BIG_ENDIAN 1 #elif defined(__i386) || defined(__i386__) || \ defined(__x86_64) || defined(__x86_64__) || \ defined(_MIPSEL) || defined(__ARMEL__) || \ defined(__alpha__) || \ (defined(__sh__) && defined(__BIG_ENDIAN__)) || \ (defined(__ia64) && !defined(__BIG_ENDIAN__)) # define MOZ_LITTLE_ENDIAN 1 #endif #if MOZ_BIG_ENDIAN # define MOZ_LITTLE_ENDIAN 0 #elif MOZ_LITTLE_ENDIAN # define MOZ_BIG_ENDIAN 0 #else # error "Cannot determine endianness" #endif #if defined(__clang__) # if __has_builtin(__builtin_bswap16) # define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 # endif #elif defined(__GNUC__) # if MOZ_GCC_VERSION_AT_LEAST(4, 8, 0) # define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 # endif #elif defined(_MSC_VER) # define MOZ_HAVE_BUILTIN_BYTESWAP16 _byteswap_ushort #endif namespace mozilla { namespace detail { /* * We need wrappers here because free functions with default template * arguments and/or partial specialization of function templates are not * supported by all the compilers we use. */ template struct Swapper; template struct Swapper { static T swap(T value) { #if defined(MOZ_HAVE_BUILTIN_BYTESWAP16) return MOZ_HAVE_BUILTIN_BYTESWAP16(value); #else return T(((value & 0x00ff) << 8) | ((value & 0xff00) >> 8)); #endif } }; template struct Swapper { static T swap(T value) { #if defined(__clang__) || defined(__GNUC__) return T(__builtin_bswap32(value)); #elif defined(_MSC_VER) return T(_byteswap_ulong(value)); #else return T(((value & 0x000000ffU) << 24) | ((value & 0x0000ff00U) << 8) | ((value & 0x00ff0000U) >> 8) | ((value & 0xff000000U) >> 24)); #endif } }; template struct Swapper { static inline T swap(T value) { #if defined(__clang__) || defined(__GNUC__) return T(__builtin_bswap64(value)); #elif defined(_MSC_VER) return T(_byteswap_uint64(value)); #else return T(((value & 0x00000000000000ffULL) << 56) | ((value & 0x000000000000ff00ULL) << 40) | ((value & 0x0000000000ff0000ULL) << 24) | ((value & 0x00000000ff000000ULL) << 8) | ((value & 0x000000ff00000000ULL) >> 8) | ((value & 0x0000ff0000000000ULL) >> 24) | ((value & 0x00ff000000000000ULL) >> 40) | ((value & 0xff00000000000000ULL) >> 56)); #endif } }; enum Endianness { Little, Big }; #if MOZ_BIG_ENDIAN # define MOZ_NATIVE_ENDIANNESS detail::Big #else # define MOZ_NATIVE_ENDIANNESS detail::Little #endif class EndianUtils { /** * Assert that the memory regions [dest, dest+count) and [src, src+count] * do not overlap. count is given in bytes. */ static void assertNoOverlap(const void* dest, const void* src, size_t count) { DebugOnly byteDestPtr = static_cast(dest); DebugOnly byteSrcPtr = static_cast(src); MOZ_ASSERT((byteDestPtr < byteSrcPtr && byteDestPtr + count <= byteSrcPtr) || (byteSrcPtr < byteDestPtr && byteSrcPtr + count <= byteDestPtr)); } template static void assertAligned(T* ptr) { MOZ_ASSERT((uintptr_t(ptr) % sizeof(T)) == 0, "Unaligned pointer!"); } protected: /** * Return |value| converted from SourceEndian encoding to DestEndian * encoding. */ template static inline T maybeSwap(T value) { if (SourceEndian == DestEndian) return value; return Swapper::swap(value); } /** * Convert |count| elements at |ptr| from SourceEndian encoding to * DestEndian encoding. */ template static inline void maybeSwapInPlace(T* ptr, size_t count) { assertAligned(ptr); if (SourceEndian == DestEndian) return; for (size_t i = 0; i < count; i++) ptr[i] = Swapper::swap(ptr[i]); } /** * Write |count| elements to the unaligned address |dest| in DestEndian * format, using elements found at |src| in SourceEndian format. */ template static void copyAndSwapTo(void* dest, const T* src, size_t count) { assertNoOverlap(dest, src, count * sizeof(T)); assertAligned(src); if (SourceEndian == DestEndian) { memcpy(dest, src, count * sizeof(T)); return; } uint8_t* byteDestPtr = static_cast(dest); for (size_t i = 0; i < count; ++i) { union { T val; uint8_t buffer[sizeof(T)]; } u; u.val = maybeSwap(src[i]); memcpy(byteDestPtr, u.buffer, sizeof(T)); byteDestPtr += sizeof(T); } } /** * Write |count| elements to |dest| in DestEndian format, using elements * found at the unaligned address |src| in SourceEndian format. */ template static void copyAndSwapFrom(T* dest, const void* src, size_t count) { assertNoOverlap(dest, src, count * sizeof(T)); assertAligned(dest); if (SourceEndian == DestEndian) { memcpy(dest, src, count * sizeof(T)); return; } const uint8_t* byteSrcPtr = static_cast(src); for (size_t i = 0; i < count; ++i) { union { T val; uint8_t buffer[sizeof(T)]; } u; memcpy(u.buffer, byteSrcPtr, sizeof(T)); dest[i] = maybeSwap(u.val); byteSrcPtr += sizeof(T); } } }; template class Endian : private EndianUtils { protected: /** Read a uint16_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint16_t readUint16(const void* p) { return read(p); } /** Read a uint32_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint32_t readUint32(const void* p) { return read(p); } /** Read a uint64_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint64_t readUint64(const void* p) { return read(p); } /** Read an int16_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int16_t readInt16(const void* p) { return read(p); } /** Read an int32_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int32_t readInt32(const void* p) { return read(p); } /** Read an int64_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int64_t readInt64(const void* p) { return read(p); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint16(void* p, uint16_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint32(void* p, uint32_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint64(void* p, uint64_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt16(void* p, int16_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt32(void* p, int32_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt64(void* p, int64_t val) { write(p, val); } /* * Converts a value of type T to little-endian format. * * This function is intended for cases where you have data in your * native-endian format and you need it to appear in little-endian * format for transmission. */ template MOZ_WARN_UNUSED_RESULT static T swapToLittleEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to little-endian format if ThisEndian is Big. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapToLittleEndian(void* dest, const T* src, size_t count) { copyAndSwapTo(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapToLittleEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Converts a value of type T to big-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapToBigEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to big-endian format if ThisEndian is Little. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapToBigEndian(void* dest, const T* src, size_t count) { copyAndSwapTo(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapToBigEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Synonyms for the big-endian functions, for better readability * in network code. */ template MOZ_WARN_UNUSED_RESULT static T swapToNetworkOrder(T value) { return swapToBigEndian(value); } template static void copyAndSwapToNetworkOrder(void* dest, const T* src, size_t count) { copyAndSwapToBigEndian(dest, src, count); } template static void swapToNetworkOrderInPlace(T* p, size_t count) { swapToBigEndianInPlace(p, count); } /* * Converts a value of type T from little-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapFromLittleEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to little-endian format if ThisEndian is Big. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapFromLittleEndian(T* dest, const void* src, size_t count) { copyAndSwapFrom(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapFromLittleEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Converts a value of type T from big-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapFromBigEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to big-endian format if ThisEndian is Little. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapFromBigEndian(T* dest, const void* src, size_t count) { copyAndSwapFrom(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapFromBigEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Synonyms for the big-endian functions, for better readability * in network code. */ template MOZ_WARN_UNUSED_RESULT static T swapFromNetworkOrder(T value) { return swapFromBigEndian(value); } template static void copyAndSwapFromNetworkOrder(T* dest, const void* src, size_t count) { copyAndSwapFromBigEndian(dest, src, count); } template static void swapFromNetworkOrderInPlace(T* p, size_t count) { swapFromBigEndianInPlace(p, count); } private: /** * Read a value of type T, encoded in endianness ThisEndian from |p|. * Return that value encoded in native endianness. */ template static T read(const void* p) { union { T val; uint8_t buffer[sizeof(T)]; } u; memcpy(u.buffer, p, sizeof(T)); return maybeSwap(u.val); } /** * Write a value of type T, in native endianness, to |p|, in ThisEndian * endianness. */ template static void write(void* p, T value) { T tmp = maybeSwap(value); memcpy(p, &tmp, sizeof(T)); } Endian() MOZ_DELETE; Endian(const Endian& other) MOZ_DELETE; void operator=(const Endian& other) MOZ_DELETE; }; template class EndianReadWrite : public Endian { private: typedef Endian super; public: using super::readUint16; using super::readUint32; using super::readUint64; using super::readInt16; using super::readInt32; using super::readInt64; using super::writeUint16; using super::writeUint32; using super::writeUint64; using super::writeInt16; using super::writeInt32; using super::writeInt64; }; } /* namespace detail */ class LittleEndian MOZ_FINAL : public detail::EndianReadWrite {}; class BigEndian MOZ_FINAL : public detail::EndianReadWrite {}; typedef BigEndian NetworkEndian; class NativeEndian MOZ_FINAL : public detail::Endian { private: typedef detail::Endian super; public: /* * These functions are intended for cases where you have data in your * native-endian format and you need the data to appear in the appropriate * endianness for transmission, serialization, etc. */ using super::swapToLittleEndian; using super::copyAndSwapToLittleEndian; using super::swapToLittleEndianInPlace; using super::swapToBigEndian; using super::copyAndSwapToBigEndian; using super::swapToBigEndianInPlace; using super::swapToNetworkOrder; using super::copyAndSwapToNetworkOrder; using super::swapToNetworkOrderInPlace; /* * These functions are intended for cases where you have data in the * given endianness (e.g. reading from disk or a file-format) and you * need the data to appear in native-endian format for processing. */ using super::swapFromLittleEndian; using super::copyAndSwapFromLittleEndian; using super::swapFromLittleEndianInPlace; using super::swapFromBigEndian; using super::copyAndSwapFromBigEndian; using super::swapFromBigEndianInPlace; using super::swapFromNetworkOrder; using super::copyAndSwapFromNetworkOrder; using super::swapFromNetworkOrderInPlace; }; #undef MOZ_NATIVE_ENDIANNESS } /* namespace mozilla */ #endif /* mozilla_Endian_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/EnumSet.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 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_*/ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/FloatingPoint.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Casting.h" #include namespace mozilla { /* * 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. */ /* * 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. */ static_assert(sizeof(double) == sizeof(uint64_t), "double must be 64 bits"); const unsigned DoubleExponentBias = 1023; const unsigned DoubleExponentShift = 52; const uint64_t DoubleSignBit = 0x8000000000000000ULL; const uint64_t DoubleExponentBits = 0x7ff0000000000000ULL; const uint64_t DoubleSignificandBits = 0x000fffffffffffffULL; static_assert((DoubleSignBit & DoubleExponentBits) == 0, "sign bit doesn't overlap exponent bits"); static_assert((DoubleSignBit & DoubleSignificandBits) == 0, "sign bit doesn't overlap significand bits"); static_assert((DoubleExponentBits & DoubleSignificandBits) == 0, "exponent bits don't overlap significand bits"); static_assert((DoubleSignBit | DoubleExponentBits | DoubleSignificandBits) == ~uint64_t(0), "all bits accounted for"); /** Determines whether a double is NaN. */ static MOZ_ALWAYS_INLINE bool IsNaN(double d) { /* * A double is NaN if all exponent bits are 1 and the significand contains at * least one non-zero bit. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleExponentBits) == DoubleExponentBits && (bits & DoubleSignificandBits) != 0; } /** Determines whether a double is +Infinity or -Infinity. */ static MOZ_ALWAYS_INLINE bool IsInfinite(double d) { /* Infinities have all exponent bits set to 1 and an all-0 significand. */ uint64_t bits = BitwiseCast(d); return (bits & ~DoubleSignBit) == DoubleExponentBits; } /** Determines whether a double is not NaN or infinite. */ static MOZ_ALWAYS_INLINE bool IsFinite(double d) { /* * NaN and Infinities are the only non-finite doubles, and both have all * exponent bits set to 1. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleExponentBits) != DoubleExponentBits; } /** * Determines whether a double is negative. It is an error to call this method * on a double which is NaN. */ static MOZ_ALWAYS_INLINE bool IsNegative(double d) { MOZ_ASSERT(!IsNaN(d), "NaN does not have a sign"); /* The sign bit is set if the double is negative. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleSignBit) != 0; } /** Determines whether a double represents -0. */ static MOZ_ALWAYS_INLINE bool IsNegativeZero(double d) { /* Only the sign bit is set if the double is -0. */ uint64_t bits = BitwiseCast(d); return bits == DoubleSignBit; } /** Returns the exponent portion of the double. */ static MOZ_ALWAYS_INLINE int_fast16_t ExponentComponent(double d) { /* * The exponent component of a double is an unsigned number, biased from its * actual value. Subtract the bias to retrieve the actual exponent. */ uint64_t bits = BitwiseCast(d); return int_fast16_t((bits & DoubleExponentBits) >> DoubleExponentShift) - int_fast16_t(DoubleExponentBias); } /** Returns +Infinity. */ static MOZ_ALWAYS_INLINE double PositiveInfinity() { /* * Positive infinity has all exponent bits set, sign bit set to 0, and no * significand. */ return BitwiseCast(DoubleExponentBits); } /** Returns -Infinity. */ static MOZ_ALWAYS_INLINE double NegativeInfinity() { /* * Negative infinity has all exponent bits set, sign bit set to 1, and no * significand. */ return BitwiseCast(DoubleSignBit | DoubleExponentBits); } /** Constructs a NaN value with the specified sign bit and significand bits. */ static MOZ_ALWAYS_INLINE double SpecificNaN(int signbit, uint64_t significand) { MOZ_ASSERT(signbit == 0 || signbit == 1); MOZ_ASSERT((significand & ~DoubleSignificandBits) == 0); MOZ_ASSERT(significand & DoubleSignificandBits); double d = BitwiseCast((signbit ? DoubleSignBit : 0) | DoubleExponentBits | significand); MOZ_ASSERT(IsNaN(d)); return d; } /** Computes the smallest non-zero positive double value. */ static MOZ_ALWAYS_INLINE double MinDoubleValue() { return BitwiseCast(uint64_t(1)); } static MOZ_ALWAYS_INLINE bool DoubleIsInt32(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 !IsNegativeZero(d) && d == (*i = int32_t(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 UnspecifiedNaN() { return SpecificNaN(0, 0xfffffffffffffULL); } /** * Compare two doubles for equality, *without* equating -0 to +0, and equating * any NaN value to any other NaN value. (The normal equality operators equate * -0 with +0, and they equate NaN to no other value.) */ static inline bool DoublesAreIdentical(double d1, double d2) { if (IsNaN(d1)) return IsNaN(d2); return BitwiseCast(d1) == BitwiseCast(d2); } } /* namespace mozilla */ #endif /* mozilla_FloatingPoint_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/GuardObjects.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/NullPtr.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(nullptr) { } ~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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/HashFunctions.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 nsHashKeys.h. */ #ifndef mozilla_HashFunctions_h #define mozilla_HashFunctions_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Types.h" #include #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. */ 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Likely.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/LinkedList.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 != nullptr; o = o->getNext()) * o->observe(topic); * } * }; * */ #ifndef mozilla_LinkedList_h #define mozilla_LinkedList_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/NullPtr.h" #ifdef __cplusplus namespace mozilla { template class LinkedList; template class LinkedListElement { /* * It's convenient that we return nullptr 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; public: LinkedListElement() : next(MOZ_THIS_IN_INITIALIZER_LIST()), prev(MOZ_THIS_IN_INITIALIZER_LIST()), isSentinel(false) { } ~LinkedListElement() { if (!isSentinel && isInList()) remove(); } /* * Get the next element in the list, or nullptr 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 nullptr 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(MOZ_THIS_IN_INITIALIZER_LIST()), prev(MOZ_THIS_IN_INITIALIZER_LIST()), isSentinel(nodeKind == NODE_KIND_SENTINEL) { } /* * Return |this| cast to T* if we're a normal node, or return nullptr if * we're a sentinel node. */ T* asT() { if (isSentinel) return nullptr; return static_cast(this); } const T* asT() const { if (isSentinel) return nullptr; 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 nullptr 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 nullptr 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 nullptr. */ 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 nullptr. */ 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_CRASH("element wasn't found in this list!"); #endif } LinkedList& operator=(const LinkedList& other) MOZ_DELETE; LinkedList(const LinkedList& other) MOZ_DELETE; }; } /* namespace mozilla */ #endif /* __cplusplus */ #endif /* mozilla_LinkedList_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/MathAlgorithms.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/TypeTraits.h" #include #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 #if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) # define MOZ_BITSCAN_WINDOWS extern "C" { unsigned char _BitScanForward(unsigned long* Index, unsigned long mask); unsigned char _BitScanReverse(unsigned long* Index, unsigned long mask); # pragma intrinsic(_BitScanForward, _BitScanReverse) # if defined(_M_AMD64) || defined(_M_X64) # define MOZ_BITSCAN_WINDOWS64 unsigned char _BitScanForward64(unsigned long* index, unsigned __int64 mask); unsigned char _BitScanReverse64(unsigned long* index, unsigned __int64 mask); # pragma intrinsic(_BitScanForward64, _BitScanReverse64) # endif } // extern "C" #endif namespace mozilla { namespace detail { #if defined(MOZ_BITSCAN_WINDOWS) inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { unsigned long index; _BitScanReverse(&index, static_cast(u)); return uint_fast8_t(31 - index); } inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { unsigned long index; _BitScanForward(&index, static_cast(u)); return uint_fast8_t(index); } inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { # if defined(MOZ_BITSCAN_WINDOWS64) unsigned long index; _BitScanReverse64(&index, static_cast(u)); return uint_fast8_t(63 - index); # else uint32_t hi = uint32_t(u >> 32); if (hi != 0) return CountLeadingZeroes32(hi); return 32 + CountLeadingZeroes32(uint32_t(u)); # endif } inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { # if defined(MOZ_BITSCAN_WINDOWS64) unsigned long index; _BitScanForward64(&index, static_cast(u)); return uint_fast8_t(index); # else uint32_t lo = uint32_t(u); if (lo != 0) return CountTrailingZeroes32(lo); return 32 + CountTrailingZeroes32(uint32_t(u >> 32)); # endif } # ifdef MOZ_HAVE_BITSCAN64 # undef MOZ_HAVE_BITSCAN64 # endif #elif defined(__clang__) || defined(__GNUC__) # if defined(__clang__) # if !__has_builtin(__builtin_ctz) || !__has_builtin(__builtin_clz) # error "A clang providing __builtin_c[lt]z is required to build" # endif # else // gcc has had __builtin_clz and friends since 3.4: no need to check. # endif inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { return __builtin_clz(u); } inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { return __builtin_ctz(u); } inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { return __builtin_clzll(u); } inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { return __builtin_ctzll(u); } #else # error "Implement these!" inline uint_fast8_t CountLeadingZeroes32(uint32_t u) MOZ_DELETE; inline uint_fast8_t CountTrailingZeroes32(uint32_t u) MOZ_DELETE; inline uint_fast8_t CountLeadingZeroes64(uint64_t u) MOZ_DELETE; inline uint_fast8_t CountTrailingZeroes64(uint64_t u) MOZ_DELETE; #endif } // namespace detail /** * Compute the number of high-order zero bits in the NON-ZERO number |u|. That * is, looking at the bitwise representation of the number, with the highest- * valued bits at the start, return the number of zeroes before the first one * is observed. * * CountLeadingZeroes32(0xF0FF1000) is 0; * CountLeadingZeroes32(0x7F8F0001) is 1; * CountLeadingZeroes32(0x3FFF0100) is 2; * CountLeadingZeroes32(0x1FF50010) is 3; and so on. */ inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { MOZ_ASSERT(u != 0); return detail::CountLeadingZeroes32(u); } /** * Compute the number of low-order zero bits in the NON-ZERO number |u|. That * is, looking at the bitwise representation of the number, with the lowest- * valued bits at the start, return the number of zeroes before the first one * is observed. * * CountTrailingZeroes32(0x0100FFFF) is 0; * CountTrailingZeroes32(0x7000FFFE) is 1; * CountTrailingZeroes32(0x0080FFFC) is 2; * CountTrailingZeroes32(0x0080FFF8) is 3; and so on. */ inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { MOZ_ASSERT(u != 0); return detail::CountTrailingZeroes32(u); } /** Analogous to CountLeadingZeroes32, but for 64-bit numbers. */ inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { MOZ_ASSERT(u != 0); return detail::CountLeadingZeroes64(u); } /** Analogous to CountTrailingZeroes32, but for 64-bit numbers. */ inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { MOZ_ASSERT(u != 0); return detail::CountTrailingZeroes64(u); } namespace detail { template class CeilingLog2; template class CeilingLog2 { public: static uint_fast8_t compute(const T t) { // Check for <= 1 to avoid the == 0 undefined case. return t <= 1 ? 0 : 32 - CountLeadingZeroes32(t - 1); } }; template class CeilingLog2 { public: static uint_fast8_t compute(const T t) { // Check for <= 1 to avoid the == 0 undefined case. return t <= 1 ? 0 : 64 - CountLeadingZeroes64(t - 1); } }; } // namespace detail /** * Compute the log of the least power of 2 greater than or equal to |t|. * * CeilingLog2(0..1) is 0; * CeilingLog2(2) is 1; * CeilingLog2(3..4) is 2; * CeilingLog2(5..8) is 3; * CeilingLog2(9..16) is 4; and so on. */ template inline uint_fast8_t CeilingLog2(const T t) { return detail::CeilingLog2::compute(t); } /** A CeilingLog2 variant that accepts only size_t. */ inline uint_fast8_t CeilingLog2Size(size_t n) { return CeilingLog2(n); } namespace detail { template class FloorLog2; template class FloorLog2 { public: static uint_fast8_t compute(const T t) { return 31 - CountLeadingZeroes32(t | 1); } }; template class FloorLog2 { public: static uint_fast8_t compute(const T t) { return 63 - CountLeadingZeroes64(t | 1); } }; } // namespace detail /** * Compute the log of the greatest power of 2 less than or equal to |t|. * * FloorLog2(0..1) is 0; * FloorLog2(2..3) is 1; * FloorLog2(4..7) is 2; * FloorLog2(8..15) is 3; and so on. */ template inline uint_fast8_t FloorLog2(const T t) { return detail::FloorLog2::compute(t); } /** A FloorLog2 variant that accepts only size_t. */ inline uint_fast8_t FloorLog2Size(size_t n) { return FloorLog2(n); } /* * Compute the smallest power of 2 greater than or equal to |x|. |x| must not * be so great that the computed value would overflow |size_t|. */ inline size_t RoundUpPow2(size_t x) { MOZ_ASSERT(x <= (size_t(1) << (sizeof(size_t) * CHAR_BIT - 1)), "can't round up -- will overflow!"); return size_t(1) << CeilingLog2(x); } } /* namespace mozilla */ #endif /* mozilla_MathAlgorithms_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/MemoryChecking.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/MemoryReporting.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Memory reporting infrastructure. */ #ifndef mozilla_MemoryReporting_h #define mozilla_MemoryReporting_h #include #ifdef __cplusplus namespace mozilla { /* * This is for functions that are like malloc_usable_size. Such functions are * used for measuring the size of data structures. */ typedef size_t (*MallocSizeOf)(const void* p); } /* namespace mozilla */ #endif /* __cplusplus */ typedef size_t (*MozMallocSizeOf)(const void* p); #endif /* mozilla_MemoryReporting_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Move.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* C++11-style, but C++98-usable, "move references" implementation. */ #ifndef mozilla_Move_h #define mozilla_Move_h namespace mozilla { /* * "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 (although 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 a MoveRef * referring to the same value; that's 1). A 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 a 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 mozilla 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(Move(c->x)), y(Move(c->y)) { } * * than the equivalent: * * C(MoveRef c) { new(&x) X(Move(c->x)); new(&y) Y(Move(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 { T* pointer; public: explicit MoveRef(T& t) : pointer(&t) { } T& operator*() const { return *pointer; } T* operator->() const { return pointer; } operator T& () const { return *pointer; } }; template inline MoveRef Move(T& t) { return MoveRef(t); } template inline MoveRef Move(const T& t) { // With some versions of gcc, for a class C, there's an (incorrect) ambiguity // between the C(const C&) constructor and the default C(C&&) C++11 move // constructor, when the constructor is called with a const C& argument. // // This ambiguity manifests with the Move implementation above when Move is // passed const U& for some class U. Calling Move(const U&) returns a // MoveRef, which is then commonly passed to the U constructor, // triggering an implicit conversion to const U&. gcc doesn't know whether to // call U(const U&) or U(U&&), so it wrongly reports a compile error. // // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50442 has since been fixed, so // this is no longer an issue for up-to-date compilers. But there's no harm // in keeping it around for older compilers, so we might as well. See also // bug 686280. return MoveRef(const_cast(t)); } /** Swap |t| and |u| using move-construction if possible. */ template inline void Swap(T& t, T& u) { T tmp(Move(t)); t = Move(u); u = Move(tmp); } } // namespace mozilla #endif /* mozilla_Move_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/NullPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/PodOperations.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * Operations for zeroing POD types, arrays, and so on. * * These operations are preferable to memset, memcmp, and the like because they * don't require remembering to multiply by sizeof(T), array lengths, and so on * everywhere. */ #ifndef mozilla_PodOperations_h #define mozilla_PodOperations_h #include "mozilla/Attributes.h" #include "mozilla/Util.h" #include namespace mozilla { /** Set the contents of |t| to 0. */ template static void PodZero(T* t) { memset(t, 0, sizeof(T)); } /** Set the contents of |nelem| elements starting at |t| to 0. */ template 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 (&t)[N]) MOZ_DELETE; template static void PodZero(T (&t)[N], size_t nelem) MOZ_DELETE; /** Set the contents of the array |t| to zero. */ template static void PodArrayZero(T (&t)[N]) { memset(t, 0, N * sizeof(T)); } /** * Assign |*src| to |*dst|. The locations must not be the same and must not * overlap. */ template static void PodAssign(T* dst, const T* src) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= 1); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= 1); memcpy(reinterpret_cast(dst), reinterpret_cast(src), sizeof(T)); } /** * Copy |nelem| T elements from |src| to |dst|. The two memory ranges must not * overlap! */ template MOZ_ALWAYS_INLINE static void PodCopy(T* dst, const T* src, size_t nelem) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= nelem); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= 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 MOZ_ALWAYS_INLINE static void PodCopy(volatile T* dst, const volatile T* src, size_t nelem) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= nelem); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= nelem); /* * Volatile |dst| requires extra work, because it's undefined behavior to * modify volatile objects using the mem* functions. Just write out the * loops manually, using operator= rather than memcpy for the same reason, * and let the compiler optimize to the extent it can. */ for (const volatile T* srcend = src + nelem; src < srcend; src++, dst++) *dst = *src; } /* * Copy the contents of the array |src| into the array |dst|, both of size N. * The arrays must not overlap! */ template static void PodArrayCopy(T (&dst)[N], const T (&src)[N]) { PodCopy(dst, src, N); } /** * Determine whether the |len| elements at |one| are memory-identical to the * |len| elements at |two|. */ template MOZ_ALWAYS_INLINE static bool PodEqual(const T* one, const T* two, size_t len) { if (len < 128) { const T* p1end = one + len; const T* p1 = one; const T* p2 = two; for (; p1 < p1end; p1++, p2++) { if (*p1 != *p2) return false; } return true; } return !memcmp(one, two, len * sizeof(T)); } } // namespace mozilla #endif /* mozilla_PodOperations_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Poison.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 poison value that can be used to fill a memory space with * an address that leads to a safe crash when dereferenced. */ #ifndef mozilla_Poison_h #define mozilla_Poison_h #include "mozilla/Assertions.h" #include "mozilla/Types.h" #include MOZ_BEGIN_EXTERN_C extern MFBT_DATA uintptr_t gMozillaPoisonValue; /** * @return the poison value. */ inline uintptr_t mozPoisonValue() { return gMozillaPoisonValue; } /** * Overwrite the memory block of aSize bytes at aPtr with the poison value. * aPtr MUST be aligned at a sizeof(uintptr_t) boundary. * Only an even number of sizeof(uintptr_t) bytes are overwritten, the last * few bytes (if any) is not overwritten. */ inline void mozWritePoison(void* aPtr, size_t aSize) { const uintptr_t POISON = mozPoisonValue(); char* p = (char*)aPtr; char* limit = p + aSize; MOZ_ASSERT((uintptr_t)aPtr % sizeof(uintptr_t) == 0, "bad alignment"); MOZ_ASSERT(aSize >= sizeof(uintptr_t), "poisoning this object has no effect"); for (; p < limit; p += sizeof(uintptr_t)) { *((uintptr_t*)p) = POISON; } } /** * Initialize the poison value. * This should only be called once. */ extern MFBT_API void mozPoisonValueInit(); /* Values annotated by CrashReporter */ extern MFBT_DATA uintptr_t gMozillaPoisonBase; extern MFBT_DATA uintptr_t gMozillaPoisonSize; MOZ_END_EXTERN_C #endif /* mozilla_Poison_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Range.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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]; } const T& operator[](size_t offset) const { return mStart[offset]; } operator ConvertibleToBool() const { return mStart ? &Range::nonNull : 0; } }; } // namespace mozilla #endif /* mozilla_Range_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/RangedPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/NullPtr.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, nullptr, 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/ReentrancyGuard.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Small helper class for asserting uses of a class are non-reentrant. */ #ifndef mozilla_ReentrancyGuard_h #define mozilla_ReentrancyGuard_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/GuardObjects.h" namespace mozilla { /* Useful for implementing containers that assert non-reentrancy */ class ReentrancyGuard { MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER #ifdef DEBUG bool& entered; #endif public: template #ifdef DEBUG ReentrancyGuard(T& obj MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : entered(obj.entered) #else ReentrancyGuard(T& MOZ_GUARD_OBJECT_NOTIFIER_PARAM) #endif { MOZ_GUARD_OBJECT_NOTIFIER_INIT; #ifdef DEBUG MOZ_ASSERT(!entered); entered = true; #endif } ~ReentrancyGuard() { #ifdef DEBUG entered = false; #endif } private: ReentrancyGuard(const ReentrancyGuard&) MOZ_DELETE; void operator=(const ReentrancyGuard&) MOZ_DELETE; }; } // namespace mozilla #endif /* mozilla_ReentrancyGuard_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/RefPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Atomics.h" #include "mozilla/Attributes.h" #include "mozilla/TypeTraits.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). */ namespace detail { #ifdef DEBUG static const int DEAD = 0xffffdead; #endif // This is used WeakPtr.h as well as this file. enum RefCountAtomicity { AtomicRefCount, NonAtomicRefCount }; 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: typename Conditional, int>::Type refCnt; }; } template class RefCounted : public detail::RefCounted { public: ~RefCounted() { static_assert(IsBaseOf::value, "T must derive from RefCounted"); } }; /** * AtomicRefCounted is like RefCounted, with an atomically updated * reference counter. */ template class AtomicRefCounted : public detail::RefCounted { public: ~AtomicRefCounted() { static_assert(IsBaseOf::value, "T must derive from AtomicRefCounted"); } }; /** * 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 #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 #endif /* mozilla_RefPtr_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/SHA1.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Types.h" #include #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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Scoped.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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" #include "mozilla/NullPtr.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 nullptr; } 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 nullptr; } const static void release(type value) { if (value) TypeSpecificDelete(value); } }; SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits) } /* namespace mozilla */ #endif /* mozilla_Scoped_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/SplayTree.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/TemplateLib.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * Reusable template meta-functions on types and compile-time values. Meta- * functions are placed inside the 'tl' namespace to avoid conflict with non- * meta functions of the same name (e.g., mozilla::tl::FloorLog2 vs. * mozilla::FloorLog2). * * When constexpr support becomes universal, we should probably use that instead * of some of these templates, for simplicity. */ #ifndef mozilla_TemplateLib_h #define mozilla_TemplateLib_h #include #include namespace mozilla { namespace tl { /** Compute min/max. */ template struct Min { static const size_t value = I < J ? I : J; }; template struct Max { static const size_t value = I > J ? I : J; }; /** Compute floor(log2(i)). */ template struct FloorLog2 { static const size_t value = 1 + FloorLog2::value; }; template<> struct FloorLog2<0> { /* Error */ }; template<> struct FloorLog2<1> { static const size_t value = 0; }; /** Compute ceiling(log2(i)). */ template struct CeilingLog2 { static const size_t value = FloorLog2<2 * I - 1>::value; }; /** Round up to the nearest power of 2. */ template struct RoundUpPow2 { static const size_t value = size_t(1) << CeilingLog2::value; }; template<> struct RoundUpPow2<0> { static const size_t value = 1; }; /** Compute the number of bits in the given unsigned type. */ template struct BitSize { static const size_t value = sizeof(T) * CHAR_BIT; }; /** * Produce an N-bit mask, where N <= BitSize::value. Handle the * language-undefined edge case when N = BitSize::value. */ 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 |value| to assure // its computation. static const size_t checkPrecondition = 0 / size_t(N < BitSize::value); static const size_t value = (size_t(1) << N) - 1 + checkPrecondition; }; template<> struct NBitMask::value> { static const size_t value = 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 value = ~NBitMask::value - CeilingLog2::value>::value; }; template<> struct MulOverflowMask<0> { /* Error */ }; template<> struct MulOverflowMask<1> { static const size_t value = 0; }; } // namespace tl } // namespace mozilla #endif /* mozilla_TemplateLib_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/ThreadLocal.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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" #include "mozilla/NullPtr.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() { 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, nullptr); #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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/TypeTraits.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 { /* Forward declarations. */ template struct RemoveCV; /* 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] */ namespace detail { template struct IsIntegralHelper : FalseType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; } /* namespace detail */ /** * IsIntegral determines whether a type is an integral type. * * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is false; * mozilla::IsIntegral::value is false; * * Note that the behavior of IsIntegral on char16_t and char32_t is * unspecified. */ template struct IsIntegral : detail::IsIntegralHelper::Type> {}; template struct IsSame; namespace detail { template struct IsFloatingPointHelper : IntegralConstant::value || IsSame::value || IsSame::value> {}; } // namespace detail /** * IsFloatingPoint determines whether a type is a floating point type (float, * double, long double). * * mozilla::IsFloatingPoint::value is false; * mozilla::IsFloatingPoint::value is true; * mozilla::IsFloatingPoint::value is true; * mozilla::IsFloatingPoint::value is false. */ template struct IsFloatingPoint : detail::IsFloatingPointHelper::Type> {}; /** * 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 {}; namespace detail { // __is_enum is a supported extension across all of our supported compilers. template struct IsEnumHelper : IntegralConstant {}; } // namespace detail /** * IsEnum determines whether a type is an enum type. * * mozilla::IsEnum::value is true; * mozilla::IsEnum::value is false; * mozilla::IsEnum::value is false; */ template struct IsEnum : detail::IsEnumHelper::Type> {}; /* 20.9.4.2 Composite type traits [meta.unary.comp] */ /** * IsArithmetic determines whether a type is arithmetic. A type is arithmetic * iff it is an integral type or a floating point type. * * mozilla::IsArithmetic::value is true; * mozilla::IsArithmetic::value is true; * mozilla::IsArithmetic::value is false. */ template struct IsArithmetic : IntegralConstant::value || IsFloatingPoint::value> {}; /* 20.9.4.3 Type properties [meta.unary.prop] */ /** * IsConst determines whether a type is const or not. * * mozilla::IsConst::value is false; * mozilla::IsConst::value is true; * mozilla::IsConst::value is false. */ template struct IsConst : FalseType {}; template struct IsConst : TrueType {}; /** * IsVolatile determines whether a type is volatile or not. * * mozilla::IsVolatile::value is false; * mozilla::IsVolatile::value is true; * mozilla::IsVolatile::value is false. */ template struct IsVolatile : FalseType {}; template struct IsVolatile : TrueType {}; /** * 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 {}; namespace detail { template::value> struct IsSignedHelper; template struct IsSignedHelper : TrueType {}; template struct IsSignedHelper : IntegralConstant::value && T(-1) < T(1)> {}; } // namespace detail /** * IsSigned determines whether a type is a signed arithmetic type. |char| is * considered a signed type if it has the same representation as |signed char|. * * Don't use this if the type might be user-defined! You might or might not get * a compile error, depending. * * mozilla::IsSigned::value is true; * mozilla::IsSigned::value is false; * mozilla::IsSigned::value is false; * mozilla::IsSigned::value is true. */ template struct IsSigned : detail::IsSignedHelper {}; namespace detail { template::value> struct IsUnsignedHelper; template struct IsUnsignedHelper : FalseType {}; template struct IsUnsignedHelper : IntegralConstant::value && (IsSame::Type, bool>::value || T(1) < T(-1))> {}; } // namespace detail /** * IsUnsigned determines whether a type is an unsigned arithmetic type. * * Don't use this if the type might be user-defined! You might or might not get * a compile error, depending. * * mozilla::IsUnsigned::value is false; * mozilla::IsUnsigned::value is true; * mozilla::IsUnsigned::value is true; * mozilla::IsUnsigned::value is false. */ template struct IsUnsigned : detail::IsUnsignedHelper {}; /* 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] */ /** * RemoveConst removes top-level const qualifications on a type. * * mozilla::RemoveConst::Type is int; * mozilla::RemoveConst::Type is int; * mozilla::RemoveConst::Type is const int*; * mozilla::RemoveConst::Type is int*. */ template struct RemoveConst { typedef T Type; }; template struct RemoveConst { typedef T Type; }; /** * RemoveVolatile removes top-level volatile qualifications on a type. * * mozilla::RemoveVolatile::Type is int; * mozilla::RemoveVolatile::Type is int; * mozilla::RemoveVolatile::Type is volatile int*; * mozilla::RemoveVolatile::Type is int*. */ template struct RemoveVolatile { typedef T Type; }; template struct RemoveVolatile { typedef T Type; }; /** * RemoveCV removes top-level const and volatile qualifications on a type. * * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int*. */ template struct RemoveCV { typedef typename RemoveConst::Type>::Type Type; }; /* 20.9.7.2 Reference modifications [meta.trans.ref] */ /* 20.9.7.3 Sign modifications [meta.trans.sign] */ template struct EnableIf; template struct Conditional; namespace detail { template struct WithC : Conditional {}; template struct WithV : Conditional {}; template struct WithCV : WithC::Type> {}; template struct CorrespondingSigned; template<> struct CorrespondingSigned { typedef signed char Type; }; template<> struct CorrespondingSigned { typedef signed char Type; }; template<> struct CorrespondingSigned { typedef short Type; }; template<> struct CorrespondingSigned { typedef int Type; }; template<> struct CorrespondingSigned { typedef long Type; }; template<> struct CorrespondingSigned { typedef long long Type; }; template::Type, bool IsSignedIntegerType = IsSigned::value && !IsSame::value> struct MakeSigned; template struct MakeSigned { typedef T Type; }; template struct MakeSigned : WithCV::value, IsVolatile::value, typename CorrespondingSigned::Type> {}; } // namespace detail /** * MakeSigned produces the corresponding signed integer type for a given * integral type T, with the const/volatile qualifiers of T. T must be a * possibly-const/volatile-qualified integral type that isn't bool. * * If T is already a signed integer type (not including char!), then T is * produced. * * Otherwise, if T is an unsigned integer type, the signed variety of T, with * T's const/volatile qualifiers, is produced. * * Otherwise, the integral type of the same size as T, with the lowest rank, * with T's const/volatile qualifiers, is produced. (This basically only acts * to produce signed char when T = char.) * * mozilla::MakeSigned::Type is signed long; * mozilla::MakeSigned::Type is volatile int; * mozilla::MakeSigned::Type is const signed short; * mozilla::MakeSigned::Type is const signed char; * mozilla::MakeSigned is an error; * mozilla::MakeSigned is an error. */ template struct MakeSigned : EnableIf::value && !IsSame::Type>::value, typename detail::MakeSigned >::Type {}; namespace detail { template struct CorrespondingUnsigned; template<> struct CorrespondingUnsigned { typedef unsigned char Type; }; template<> struct CorrespondingUnsigned { typedef unsigned char Type; }; template<> struct CorrespondingUnsigned { typedef unsigned short Type; }; template<> struct CorrespondingUnsigned { typedef unsigned int Type; }; template<> struct CorrespondingUnsigned { typedef unsigned long Type; }; template<> struct CorrespondingUnsigned { typedef unsigned long long Type; }; template::Type, bool IsUnsignedIntegerType = IsUnsigned::value && !IsSame::value> struct MakeUnsigned; template struct MakeUnsigned { typedef T Type; }; template struct MakeUnsigned : WithCV::value, IsVolatile::value, typename CorrespondingUnsigned::Type> {}; } // namespace detail /** * MakeUnsigned produces the corresponding unsigned integer type for a given * integral type T, with the const/volatile qualifiers of T. T must be a * possibly-const/volatile-qualified integral type that isn't bool. * * If T is already an unsigned integer type (not including char!), then T is * produced. * * Otherwise, if T is an signed integer type, the unsigned variety of T, with * T's const/volatile qualifiers, is produced. * * Otherwise, the unsigned integral type of the same size as T, with the lowest * rank, with T's const/volatile qualifiers, is produced. (This basically only * acts to produce unsigned char when T = char.) * * mozilla::MakeUnsigned::Type is unsigned long; * mozilla::MakeUnsigned::Type is volatile unsigned int; * mozilla::MakeUnsigned::Type is const unsigned short; * mozilla::MakeUnsigned::Type is const unsigned char; * mozilla::MakeUnsigned is an error; * mozilla::MakeUnsigned is an error. */ template struct MakeUnsigned : EnableIf::value && !IsSame::Type>::value, typename detail::MakeUnsigned >::Type {}; /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/TypedEnum.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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. * * MOZ_{BEGIN,END}_ENUM_CLASS doesn't work for defining enum classes nested * inside classes. To define an enum class nested inside another class, use * MOZ_{BEGIN,END}_NESTED_ENUM_CLASS, and place a MOZ_FINISH_NESTED_ENUM_CLASS * in namespace scope to handle bits that can only be implemented with * namespace-scoped code. For example: * * class FooBar { * * MOZ_BEGIN_NESTED_ENUM_CLASS(Enum, int32_t) * A, * B = 6 * MOZ_END_NESTED_ENUM_CLASS(Enum) * * }; * * MOZ_FINISH_NESTED_ENUM_CLASS(FooBar::Enum) */ #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_NESTED_ENUM_CLASS(Name, type) \ enum class Name : type { # define MOZ_END_NESTED_ENUM_CLASS(Name) \ }; # define MOZ_FINISH_NESTED_ENUM_CLASS(Name) /* nothing */ #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_NESTED_ENUM_CLASS(Name, type) \ class Name \ { \ public: \ enum Enum MOZ_ENUM_TYPE(type) \ { # define MOZ_END_NESTED_ENUM_CLASS(Name) \ }; \ Name() {} \ Name(Enum aEnum) : mEnum(aEnum) {} \ explicit Name(int num) : mEnum((Enum)num) {} \ operator Enum() const { return mEnum; } \ private: \ Enum mEnum; \ }; # define MOZ_FINISH_NESTED_ENUM_CLASS(Name) \ 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 # define MOZ_BEGIN_ENUM_CLASS(Name, type) MOZ_BEGIN_NESTED_ENUM_CLASS(Name, type) # define MOZ_END_ENUM_CLASS(Name) \ MOZ_END_NESTED_ENUM_CLASS(Name) \ MOZ_FINISH_NESTED_ENUM_CLASS(Name) #endif /* __cplusplus */ #endif /* mozilla_TypedEnum_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Types.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 types and size_t. */ #include #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 /* * GCC's typeof is available when decltype is not. */ #if defined(__GNUC__) && defined(__cplusplus) && \ !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L # define decltype __typeof__ #endif #endif /* mozilla_Types_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Util.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8, t9); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); 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 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/Vector.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/length-parametrized vector class. */ #ifndef mozilla_Vector_h #define mozilla_Vector_h #include "mozilla/AllocPolicy.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/NullPtr.h" #include "mozilla/ReentrancyGuard.h" #include "mozilla/TemplateLib.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.h" #include // for placement new /* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4345) #endif namespace mozilla { template class VectorBase; namespace detail { /* * 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(VectorBase& v, size_t newCap) { MOZ_ASSERT(!v.usingInlineStorage()); MOZ_ASSERT(!CapacityHasExcessSpace(newCap)); T* newbuf = reinterpret_cast(v.malloc_(newCap * sizeof(T))); if (!newbuf) return false; T* dst = newbuf; T* src = v.beginNoCheck(); for (; 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* end = dst + n; dst < end; ++dst) *dst = t; } static inline bool growTo(VectorBase& v, size_t newCap) { MOZ_ASSERT(!v.usingInlineStorage()); MOZ_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; } }; } // namespace detail /* * A CRTP base class for vector-like classes. Unless you really really want * your own vector class -- and you almost certainly don't -- you should use * mozilla::Vector instead! * * See mozilla::Vector for interface requirements. */ template class VectorBase : private AllocPolicy { /* utilities */ static const bool sElemIsPod = IsPod::value; typedef detail::VectorImpl Impl; friend struct detail::VectorImpl; bool growStorageBy(size_t incr); bool convertToHeapStorage(size_t newCap); /* 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 value = sizeof(T); }; template struct ElemSize<0, Dummy> { static const size_t value = 1; }; static const size_t sInlineCapacity = tl::Min::value>::value; /* Calculate inline buffer size; avoid 0-sized array. */ static const size_t sInlineBytes = tl::Max<1, sInlineCapacity * ElemSize::value>::value; /* 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; /* Number of elements in the vector. */ size_t mLength; /* Max number of elements storable in the vector without resizing. */ size_t mCapacity; #ifdef DEBUG /* Max elements of reserved or used space in this vector. */ size_t mReserved; #endif /* Memory used for inline storage. */ AlignedStorage storage; #ifdef DEBUG friend class ReentrancyGuard; bool entered; #endif /* private accessors */ bool usingInlineStorage() const { return mBegin == const_cast(this)->inlineStorage(); } T* inlineStorage() { return static_cast(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 { MOZ_ASSERT(mReserved <= mCapacity); MOZ_ASSERT(mLength <= mReserved); return mReserved; } #endif /* Append operations guaranteed to succeed due to pre-reserved space. */ template void internalAppend(const U& u); template void internalAppendAll(const VectorBase& u); void internalAppendN(const T& t, size_t n); template void internalAppend(const U* begin, size_t length); public: static const size_t sMaxInlineStorage = N; typedef T ElementType; VectorBase(AllocPolicy = AllocPolicy()); VectorBase(MoveRef); /* Move constructor. */ ThisVector& operator=(MoveRef); /* Move assignment. */ ~VectorBase(); /* 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() { MOZ_ASSERT(!entered); return mBegin; } const T* begin() const { MOZ_ASSERT(!entered); return mBegin; } T* end() { MOZ_ASSERT(!entered); return mBegin + mLength; } const T* end() const { MOZ_ASSERT(!entered); return mBegin + mLength; } T& operator[](size_t i) { MOZ_ASSERT(!entered); MOZ_ASSERT(i < mLength); return begin()[i]; } const T& operator[](size_t i) const { MOZ_ASSERT(!entered); MOZ_ASSERT(i < mLength); return begin()[i]; } T& back() { MOZ_ASSERT(!entered); MOZ_ASSERT(!empty()); return *(end() - 1); } const T& back() const { MOZ_ASSERT(!entered); MOZ_ASSERT(!empty()); return *(end() - 1); } class Range { friend class VectorBase; T* cur_; T* 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() { MOZ_ASSERT(!empty()); ++cur_; } T popCopyFront() { MOZ_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); /** * Increase the length of the vector, but don't initialize the new elements * -- leave them 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 won't reallocate elements storage. * This *doesn't* mean that infallibleAppend may be used! You still must * reserve the extra space, even if this method indicates that appends won't * need to reallocate elements storage. */ 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(const U& u); template bool appendAll(const VectorBase& u); 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); /* * Guaranteed-infallible append operations for use upon vectors whose * memory has been pre-reserved. Don't use this if you haven't reserved the * memory! */ 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, PointerRangeSize(aBegin, aEnd)); } template void infallibleAppend(const U* aBegin, size_t aLength) { internalAppend(aBegin, aLength); } void popBack(); T popCopy(); /** * Transfers ownership of the internal buffer used by this vector to the * caller. (It's the caller's responsibility to properly deallocate this * buffer, in accordance with this vector's AllocPolicy.) 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 nullptr. * * N.B. Although a T*, only the range [0, length()) is constructed. */ T* extractRawBuffer(); /** * Transfer ownership of an array of objects into the vector. The caller * must have allocated the array in accordance with this vector's * AllocPolicy. * * 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'll * be a dangling pointer if reallocation of the vector storage occurred; the * return value should be used instead. On failure, nullptr is returned. * * Example usage: * * if (!(p = vec.insert(p, val))) * * * * This is inherently a linear-time operation. Be careful! */ 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(MallocSizeOf mallocSizeOf) const; /** * Like sizeOfExcludingThis, but also measures the size of the vector * object (which must be heap-allocated) itself. */ size_t sizeOfIncludingThis(MallocSizeOf mallocSizeOf) const; void swap(ThisVector& other); private: VectorBase(const ThisVector&) MOZ_DELETE; void operator=(const ThisVector&) MOZ_DELETE; }; /* This does the re-entrancy check plus several other sanity checks. */ #define MOZ_REENTRANCY_GUARD_ET_AL \ ReentrancyGuard g(*this); \ MOZ_ASSERT_IF(usingInlineStorage(), mCapacity == sInlineCapacity); \ MOZ_ASSERT(reserved() <= mCapacity); \ MOZ_ASSERT(mLength <= reserved()); \ MOZ_ASSERT(mLength <= mCapacity) /* Vector Implementation */ template MOZ_ALWAYS_INLINE VectorBase::VectorBase(AP ap) : AP(ap), mBegin(static_cast(storage.addr())), mLength(0), mCapacity(sInlineCapacity) #ifdef DEBUG , mReserved(sInlineCapacity), entered(false) #endif {} /* Move constructor. */ template MOZ_ALWAYS_INLINE VectorBase::VectorBase(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 = static_cast(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 = static_cast(rhs->storage.addr()); rhs->mCapacity = sInlineCapacity; rhs->mLength = 0; #ifdef DEBUG rhs->mReserved = sInlineCapacity; #endif } } /* Move assignment. */ template MOZ_ALWAYS_INLINE TV& VectorBase::operator=(MoveRef rhs) { TV* tv = static_cast(this); tv->~TV(); new(tv) TV(rhs); return *tv; } template MOZ_ALWAYS_INLINE VectorBase::~VectorBase() { MOZ_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 VectorBase::convertToHeapStorage(size_t newCap) { MOZ_ASSERT(usingInlineStorage()); /* Allocate buffer. */ MOZ_ASSERT(!detail::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 MOZ_NEVER_INLINE bool VectorBase::growStorageBy(size_t incr) { MOZ_ASSERT(mLength + incr > mCapacity); MOZ_ASSERT_IF(!usingInlineStorage(), !detail::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)>::value; 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 * * static_cast(end()) - static_cast(begin()) * * doesn't overflow ptrdiff_t (see bug 510319). */ if (mLength & tl::MulOverflowMask<4 * sizeof(T)>::value) { 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 (detail::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)>::value) { 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 VectorBase::initCapacity(size_t request) { MOZ_ASSERT(empty()); MOZ_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 VectorBase::reserve(size_t request) { MOZ_REENTRANCY_GUARD_ET_AL; if (request > mCapacity && !growStorageBy(request - mLength)) return false; #ifdef DEBUG if (request > mReserved) mReserved = request; MOZ_ASSERT(mLength <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); #endif return true; } template inline void VectorBase::shrinkBy(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; MOZ_ASSERT(incr <= mLength); Impl::destroy(endNoCheck() - incr, endNoCheck()); mLength -= incr; } template MOZ_ALWAYS_INLINE bool VectorBase::growBy(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; if (incr > mCapacity - mLength && !growStorageBy(incr)) return false; MOZ_ASSERT(mLength + incr <= mCapacity); T* newend = endNoCheck() + incr; Impl::initialize(endNoCheck(), newend); mLength += incr; #ifdef DEBUG if (mLength > mReserved) mReserved = mLength; #endif return true; } template MOZ_ALWAYS_INLINE bool VectorBase::growByUninitialized(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; if (incr > mCapacity - mLength && !growStorageBy(incr)) return false; MOZ_ASSERT(mLength + incr <= mCapacity); mLength += incr; #ifdef DEBUG if (mLength > mReserved) mReserved = mLength; #endif return true; } template inline bool VectorBase::resize(size_t newLength) { size_t curLength = mLength; if (newLength > curLength) return growBy(newLength - curLength); shrinkBy(curLength - newLength); return true; } template MOZ_ALWAYS_INLINE bool VectorBase::resizeUninitialized(size_t newLength) { size_t curLength = mLength; if (newLength > curLength) return growByUninitialized(newLength - curLength); shrinkBy(curLength - newLength); return true; } template inline void VectorBase::clear() { MOZ_REENTRANCY_GUARD_ET_AL; Impl::destroy(beginNoCheck(), endNoCheck()); mLength = 0; } template inline void VectorBase::clearAndFree() { clear(); if (usingInlineStorage()) return; this->free_(beginNoCheck()); mBegin = static_cast(storage.addr()); mCapacity = sInlineCapacity; #ifdef DEBUG mReserved = sInlineCapacity; #endif } template inline bool VectorBase::canAppendWithoutRealloc(size_t needed) const { return mLength + needed <= mCapacity; } template template MOZ_ALWAYS_INLINE void VectorBase::internalAppendAll(const VectorBase& other) { internalAppend(other.begin(), other.length()); } template template MOZ_ALWAYS_INLINE void VectorBase::internalAppend(const U& u) { MOZ_ASSERT(mLength + 1 <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); new(endNoCheck()) T(u); ++mLength; } template MOZ_ALWAYS_INLINE bool VectorBase::appendN(const T& t, size_t needed) { MOZ_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 MOZ_ALWAYS_INLINE void VectorBase::internalAppendN(const T& t, size_t needed) { MOZ_ASSERT(mLength + needed <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); Impl::copyConstructN(endNoCheck(), needed, t); mLength += needed; } template inline T* VectorBase::insert(T* p, const T& val) { MOZ_ASSERT(begin() <= p); MOZ_ASSERT(p <= end()); size_t pos = p - begin(); MOZ_ASSERT(pos <= mLength); size_t oldLength = mLength; if (pos == oldLength) { if (!append(val)) return nullptr; } else { T oldBack = back(); if (!append(oldBack)) /* Dup the last element. */ return nullptr; for (size_t i = oldLength; i > pos; --i) (*this)[i] = (*this)[i - 1]; (*this)[pos] = val; } return begin() + pos; } template inline void VectorBase::erase(T* it) { MOZ_ASSERT(begin() <= it); MOZ_ASSERT(it < end()); while (it + 1 < end()) { *it = *(it + 1); ++it; } popBack(); } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U* insBegin, const U* insEnd) { MOZ_REENTRANCY_GUARD_ET_AL; size_t needed = 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 MOZ_ALWAYS_INLINE void VectorBase::internalAppend(const U* insBegin, size_t insLength) { MOZ_ASSERT(mLength + insLength <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); Impl::copyConstruct(endNoCheck(), insBegin, insBegin + insLength); mLength += insLength; } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U& u) { MOZ_REENTRANCY_GUARD_ET_AL; if (mLength == mCapacity && !growStorageBy(1)) return false; #ifdef DEBUG if (mLength + 1 > mReserved) mReserved = mLength + 1; #endif internalAppend(u); return true; } template template MOZ_ALWAYS_INLINE bool VectorBase::appendAll(const VectorBase& other) { return append(other.begin(), other.length()); } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U *insBegin, size_t insLength) { return append(insBegin, insBegin + insLength); } template MOZ_ALWAYS_INLINE void VectorBase::popBack() { MOZ_REENTRANCY_GUARD_ET_AL; MOZ_ASSERT(!empty()); --mLength; endNoCheck()->~T(); } template MOZ_ALWAYS_INLINE T VectorBase::popCopy() { T ret = back(); popBack(); return ret; } template inline T* VectorBase::extractRawBuffer() { T* ret; if (usingInlineStorage()) { ret = reinterpret_cast(this->malloc_(mLength * sizeof(T))); if (!ret) return nullptr; Impl::copyConstruct(ret, beginNoCheck(), endNoCheck()); Impl::destroy(beginNoCheck(), endNoCheck()); /* mBegin, mCapacity are unchanged. */ mLength = 0; } else { ret = mBegin; mBegin = static_cast(storage.addr()); mLength = 0; mCapacity = sInlineCapacity; #ifdef DEBUG mReserved = sInlineCapacity; #endif } return ret; } template inline void VectorBase::replaceRawBuffer(T* p, size_t aLength) { MOZ_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 = static_cast(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 VectorBase::sizeOfExcludingThis(MallocSizeOf mallocSizeOf) const { return usingInlineStorage() ? 0 : mallocSizeOf(beginNoCheck()); } template inline size_t VectorBase::sizeOfIncludingThis(MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } template inline void VectorBase::swap(TV& other) { static_assert(N == 0, "still need to implement this for 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 } /* * 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 AllocPolicy.h (defaults to * mozilla::MallocAllocPolicy) * * Vector is not reentrant: T member functions called during Vector member * functions must not call back into the same object! */ template class Vector : public VectorBase > { typedef VectorBase Base; public: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} Vector(mozilla::MoveRef vec) : Base(vec) {} Vector& operator=(mozilla::MoveRef vec) { return Base::operator=(vec); } }; } // namespace mozilla #ifdef _MSC_VER #pragma warning(pop) #endif #endif /* mozilla_Vector_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/android/mozilla/WeakPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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'. * * AtomicSupportsWeakPtr can be used for a variant with an atomically updated * reference counter. * * 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/Atomics.h" #include "mozilla/NullPtr.h" #include "mozilla/RefPtr.h" #include "mozilla/TypeTraits.h" namespace mozilla { template class WeakPtrBase; template class SupportsWeakPtrBase; namespace detail { // This can live beyond the lifetime of the class derived from SupportsWeakPtrBase. template class WeakReference : public RefCounted, Atomicity> { public: explicit WeakReference(T* p) : ptr(p) {} T* get() const { return ptr; } private: friend class WeakPtrBase; friend class SupportsWeakPtrBase; void detach() { ptr = nullptr; } T* ptr; }; } // namespace detail template class SupportsWeakPtrBase { public: WeakPtrBase asWeakPtr() { if (!weakRef) weakRef = new WeakReference(static_cast(this)); return WeakPtrBase(weakRef); } protected: ~SupportsWeakPtrBase() { static_assert(IsBaseOf, T>::value, "T must derive from SupportsWeakPtrBase"); if (weakRef) weakRef->detach(); } private: friend class WeakPtrBase; RefPtr weakRef; }; template class SupportsWeakPtr : public SupportsWeakPtrBase > { }; template class AtomicSupportsWeakPtr : public SupportsWeakPtrBase > { }; namespace detail { template struct WeakReferenceCount { static const RefCountAtomicity atomicity = IsBaseOf, T>::value ? AtomicRefCount : NonAtomicRefCount; }; } template class WeakPtrBase { public: WeakPtrBase(const WeakPtrBase& o) : ref(o.ref) {} // Ensure that ref is dereferenceable in the uninitialized state WeakPtrBase() : ref(new 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 SupportsWeakPtrBase; explicit WeakPtrBase(const RefPtr &o) : ref(o) {} RefPtr ref; }; template class WeakPtr : public WeakPtrBase::atomicity> > { typedef WeakPtrBase::atomicity> > Base; public: WeakPtr(const WeakPtr& o) : Base(o) {} WeakPtr(const Base& o) : Base(o) {} WeakPtr() {} }; } // namespace mozilla #endif /* mozilla_WeakPtr_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/Anchor.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/CallArgs.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 "mozilla/TypeTraits.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); /* Typedef for native functions that may be called in parallel. */ typedef js::ParallelResult (* JSParallelNative)(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp); /* * Typedef for native functions that may be called either in parallel or * sequential execution. */ typedef JSBool (* JSThreadSafeNative)(js::ThreadSafeContext *cx, unsigned argc, JS::Value *vp); /* * Convenience wrappers for passing in ThreadSafeNative to places that expect * a JSNative or a JSParallelNative. */ template inline JSBool JSNativeThreadSafeWrapper(JSContext *cx, unsigned argc, JS::Value *vp); template inline js::ParallelResult JSParallelNativeThreadSafeWrapper(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp); /* * 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); namespace JS { extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; /* * 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.rval().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. */ namespace detail { #ifdef DEBUG extern JS_PUBLIC_API(void) CheckIsValidConstructible(Value v); #endif enum UsedRval { IncludeUsedRval, NoUsedRval }; template class MOZ_STACK_CLASS UsedRvalBase; template<> class MOZ_STACK_CLASS UsedRvalBase { protected: mutable bool usedRval_; void setUsedRval() const { usedRval_ = true; } void clearUsedRval() const { usedRval_ = false; } }; template<> class MOZ_STACK_CLASS UsedRvalBase { protected: void setUsedRval() const {} void clearUsedRval() const {} }; template class MOZ_STACK_CLASS CallReceiverBase : public UsedRvalBase< #ifdef DEBUG WantUsedRval #else NoUsedRval #endif > { protected: 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(!this->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(!this->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]); } Value computeThis(JSContext *cx) const { if (thisv().isObject()) return thisv(); return JS_ComputeThis(cx, base()); } bool isConstructing() const { #ifdef DEBUG if (this->usedRval_) CheckIsValidConstructible(calleev()); #endif return argv_[-1].isMagic(); } /* * 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 { this->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 { this->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 { this->clearUsedRval(); argv_[-2] = aCalleev; } void setThis(Value aThisv) const { argv_[-1] = aThisv; } MutableHandleValue mutableThisv() const { return MutableHandleValue::fromMarkedLocation(&argv_[-1]); } }; } // namespace detail class MOZ_STACK_CLASS CallReceiver : public detail::CallReceiverBase { private: friend CallReceiver CallReceiverFromVp(Value *vp); friend CallReceiver CallReceiverFromArgv(Value *argv); }; 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. */ namespace detail { template class MOZ_STACK_CLASS CallArgsBase : public mozilla::Conditional >::Type { protected: unsigned argc_; public: /* Returns the number of arguments. */ unsigned length() const { return argc_; } /* Returns the i-th zero-indexed argument. */ MutableHandleValue operator[](unsigned i) const { MOZ_ASSERT(i < argc_); return MutableHandleValue::fromMarkedLocation(&this->argv_[i]); } /* * Returns the i-th zero-indexed argument, or |undefined| if there's no * such argument. */ HandleValue get(unsigned i) const { return i < length() ? HandleValue::fromMarkedLocation(&this->argv_[i]) : UndefinedHandleValue; } /* * Returns true if the i-th zero-indexed argument is present and is not * |undefined|. */ bool hasDefined(unsigned i) const { return i < argc_ && !this->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 this->argv_; } Value *end() const { return this->argv_ + argc_; } }; } // namespace detail class MOZ_STACK_CLASS CallArgs : public detail::CallArgsBase { private: 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; } }; 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 /* * 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/CharacterEncoding.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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()); } }; class UTF8Chars : public mozilla::Range { typedef mozilla::Range Base; public: UTF8Chars() : Base() {} UTF8Chars(char *aBytes, size_t aLength) : Base(reinterpret_cast(aBytes), aLength) {} UTF8Chars(const char *aBytes, size_t aLength) : Base(reinterpret_cast(const_cast(aBytes)), aLength) {} }; /* * 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() : Base(NULL, 0) {} 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(js::ThreadSafeContext *cx, TwoByteChars tbchars); extern UTF8CharsZ TwoByteCharsToNewUTF8CharsZ(js::ThreadSafeContext *cx, TwoByteChars tbchars); uint32_t Utf8ToOneUcs4Char(const uint8_t *utf8Buffer, int utf8Length); /* * Inflate bytes in UTF-8 encoding to jschars. * - On error, returns an empty TwoByteCharsZ. * - On success, returns a malloc'd TwoByteCharsZ, and updates |outlen| to hold * its length; the length value excludes the trailing null. */ extern TwoByteCharsZ UTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen); /* * The same as UTF8CharsToNewTwoByteCharsZ(), except that any malformed UTF-8 characters * will be replaced by \uFFFD. No exception will be thrown for malformed UTF-8 * input. */ extern TwoByteCharsZ LossyUTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen); } // 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/Date.h ================================================ /* -*- 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_Date_h #define js_Date_h #include "jstypes.h" namespace JS { // Year is a year, month is 0-11, day is 1-based. The return value is // a number of milliseconds since the epoch. Can return NaN. JS_PUBLIC_API(double) MakeDate(double year, unsigned month, unsigned day); // Takes an integer number of milliseconds since the epoch and returns the // year. Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) YearFromTime(double time); // Takes an integer number of milliseconds since the epoch and returns the // month (0-11). Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) MonthFromTime(double time); // Takes an integer number of milliseconds since the epoch and returns the // day (1-based). Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) DayFromTime(double time); } // namespace JS #endif /* js_Date_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/GCAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_GCAPI_h #define js_GCAPI_h #include "js/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) \ D(OUT_OF_NURSERY) \ D(EVICT_NURSERY) \ D(FULL_STORE_BUFFER) \ \ /* These are reserved for future use. */ \ D(RESERVED0) \ D(RESERVED1) \ D(RESERVED2) \ D(RESERVED3) \ D(RESERVED4) \ D(RESERVED5) \ D(RESERVED6) \ D(RESERVED7) \ D(RESERVED8) \ D(RESERVED9) \ D(RESERVED10) \ D(RESERVED11) \ D(RESERVED12) \ D(RESERVED13) \ D(RESERVED14) \ D(RESERVED15) \ D(RESERVED16) \ D(RESERVED17) \ D(RESERVED18) \ D(RESERVED19) \ \ /* 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(void) EnableGenerationalGC(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 { Heap 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; } void trace(JSTracer *trc, const char *name) { JS_CallHeapObjectTracer(trc, &value, name); } 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); shadow::Runtime *rt = js::gc::GetGCThingRuntime(thing); #ifdef JSGC_GENERATIONAL /* * GC things residing in the nursery cannot be gray: they have no mark bits. * All live objects in the nursery are moved to tenured at the beginning of * each GC slice, so the gray marker never sees nursery things. */ if (uintptr_t(thing) >= rt->gcNurseryStart_ && uintptr_t(thing) < rt->gcNurseryEnd_) return; #endif if (IsIncrementalBarrierNeededOnGCThing(rt, thing, kind)) IncrementalReferenceBarrier(thing, kind); else if (GCThingIsMarkedGray(thing)) UnmarkGrayGCThingRecursively(thing, kind); } static JS_ALWAYS_INLINE void ExposeValueToActiveJS(const Value &v) { if (v.isMarkable()) ExposeGCThingToActiveJS(v.toGCThing(), v.gcKind()); } } /* namespace JS */ #endif /* js_GCAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/HashTable.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_HashTable_h #define js_HashTable_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Casting.h" #include "mozilla/DebugOnly.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/PodOperations.h" #include "mozilla/ReentrancyGuard.h" #include "mozilla/TemplateLib.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.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) {} 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, mozilla::Move(e)); } bool add(AddPtr &p, const Key &k) { Entry e(k, Value()); return impl.add(p, mozilla::Move(e)); } template bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { Entry e(k, v); return impl.relookupOrAdd(p, k, mozilla::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(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf 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, mozilla::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); } // Infallibly rekey one entry, if present. void rekey(const Lookup &old_key, const Key &new_key) { if (old_key != new_key) { if (Ptr p = lookup(old_key)) impl.rekey(p, new_key, new_key); } } // HashMap is movable HashMap(mozilla::MoveRef rhs) : impl(mozilla::Move(rhs->impl)) {} void operator=(mozilla::MoveRef rhs) { impl = mozilla::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) {} 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(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf 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); } // Infallibly rekey one entry, if present. void rekey(const Lookup &old_key, const T &new_key) { if (old_key != new_key) { if (Ptr p = lookup(old_key)) impl.rekey(p, new_key, new_key); } } // HashSet is movable HashSet(mozilla::MoveRef rhs) : impl(mozilla::Move(rhs->impl)) {} void operator=(mozilla::MoveRef rhs) { impl = mozilla::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::value> {}; // 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); uint64_t u = mozilla::BitwiseCast(d); return HashNumber(u ^ (u >> 32)); } static bool match(double lhs, double rhs) { return mozilla::BitwiseCast(lhs) == mozilla::BitwiseCast(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(mozilla::MoveRef rhs) : key(mozilla::Move(rhs->key)), value(mozilla::Move(rhs->value)) { } typedef Key KeyType; typedef Value ValueType; 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 mozilla::RemoveConst::Type 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) { mozilla::Swap(keyHash, other->keyHash); mozilla::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; } 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 mozilla::RemoveConst::Type 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) { table.rekey(*this->cur, l, k); 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(mozilla::MoveRef rhs) : AllocPolicy(*rhs) { mozilla::PodAssign(this, &*rhs); rhs->table = NULL; } void operator=(mozilla::MoveRef rhs) { if (table) destroyTable(*this, table, capacity()); mozilla::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 mozilla::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 = mozilla::tl::BitSize::value; 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, mozilla::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 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(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(table); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } Ptr lookup(const Lookup &l) const { mozilla::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 { mozilla::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) { mozilla::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; { mozilla::ReentrancyGuard g(*this); p.entry_ = &lookup(l, p.keyHash, sCollisionBit); } return p.found() || add(p, u); } void remove(Ptr p) { JS_ASSERT(table); mozilla::ReentrancyGuard g(*this); JS_ASSERT(p.found()); remove(*p.entry_); checkUnderloaded(); } void rekey(Ptr p, const Lookup &l, const Key &k) { JS_ASSERT(table); mozilla::ReentrancyGuard g(*this); JS_ASSERT(p.found()); typename HashTableEntry::NonConstT t(mozilla::Move(*p)); HashPolicy::setKey(t, const_cast(k)); remove(*p.entry_); putNewInfallible(l, mozilla::Move(t)); } #undef METER }; } // namespace detail } // namespace js #endif /* js_HashTable_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/HeapAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_HeapAPI_h #define js_HeapAPI_h #include "jspubtd.h" #include "js/Utility.h" /* These values are private to the JS engine. */ namespace js { namespace gc { const size_t ArenaShift = 12; 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; const size_t ChunkRuntimeOffset = ChunkSize - sizeof(void*); /* * 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 JS::shadow::Runtime * GetGCThingRuntime(const void *thing) { uintptr_t addr = uintptr_t(thing); addr &= ~js::gc::ChunkMask; addr |= js::gc::ChunkRuntimeOffset; 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(shadow::Runtime *rt, void *thing, JSGCTraceKind kind) { if (!rt->needsBarrier_) return false; JS::Zone *zone = GetGCThingZone(thing); return reinterpret_cast(zone)->needsBarrier_; } } /* namespace JS */ #endif /* js_HeapAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/LegacyIntTypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 types. */ #ifndef js_LegacyIntTypes_h #define js_LegacyIntTypes_h #include #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 /* js_LegacyIntTypes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/MemoryMetrics.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 "mozilla/MemoryReporting.h" #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 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 interpreterStack; size_t gcMarker; size_t mathCache; size_t scriptData; size_t scriptSources; CodeSizes code; }; struct ZoneStats { ZoneStats() : extra(NULL), gcHeapArenaAdmin(0), gcHeapUnusedGcThings(0), gcHeapStringsNormal(0), gcHeapStringsShort(0), gcHeapLazyScripts(0), gcHeapTypeObjects(0), gcHeapIonCodes(0), stringCharsNonHuge(0), lazyScripts(0), typeObjects(0), typePool(0), hugeStrings() {} ZoneStats(const ZoneStats &other) : extra(other.extra), gcHeapArenaAdmin(other.gcHeapArenaAdmin), gcHeapUnusedGcThings(other.gcHeapUnusedGcThings), gcHeapStringsNormal(other.gcHeapStringsNormal), gcHeapStringsShort(other.gcHeapStringsShort), gcHeapLazyScripts(other.gcHeapLazyScripts), gcHeapTypeObjects(other.gcHeapTypeObjects), gcHeapIonCodes(other.gcHeapIonCodes), stringCharsNonHuge(other.stringCharsNonHuge), lazyScripts(other.lazyScripts), typeObjects(other.typeObjects), typePool(other.typePool), hugeStrings() { hugeStrings.appendAll(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(gcHeapLazyScripts); ADD(gcHeapTypeObjects); ADD(gcHeapIonCodes); ADD(stringCharsNonHuge); ADD(lazyScripts); ADD(typeObjects); ADD(typePool); #undef ADD hugeStrings.appendAll(other.hugeStrings); } // This field can be used by embedders. void *extra; size_t gcHeapArenaAdmin; size_t gcHeapUnusedGcThings; size_t gcHeapStringsNormal; size_t gcHeapStringsShort; size_t gcHeapLazyScripts; size_t gcHeapTypeObjects; size_t gcHeapIonCodes; size_t stringCharsNonHuge; size_t lazyScripts; 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() : extra(NULL), 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), baselineData(0), baselineStubsFallback(0), baselineStubsOptimized(0), ionData(0), compartmentObject(0), crossCompartmentWrappersTable(0), regexpCompartment(0), debuggeesSet(0), typeInference() {} CompartmentStats(const CompartmentStats &other) : extra(other.extra), 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), baselineData(other.baselineData), baselineStubsFallback(other.baselineStubsFallback), baselineStubsOptimized(other.baselineStubsOptimized), ionData(other.ionData), compartmentObject(other.compartmentObject), crossCompartmentWrappersTable(other.crossCompartmentWrappersTable), regexpCompartment(other.regexpCompartment), debuggeesSet(other.debuggeesSet), typeInference(other.typeInference) { } // This field can be used by embedders. void *extra; // 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 baselineData; size_t baselineStubsFallback; size_t baselineStubsOptimized; 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(baselineData); ADD(baselineStubsFallback); ADD(baselineStubsOptimized); 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(mozilla::MallocSizeOf 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; mozilla::MallocSizeOf 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(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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/PropertyKey.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/RequiredDefines.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/RootingAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_RootingAPI_h #define js_RootingAPI_h #include "mozilla/GuardObjects.h" #include "mozilla/TypeTraits.h" #include "js/Utility.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 |Rooted| 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 three 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. * * - 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 (measured to * be a few nanoseconds on desktop) 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. * * The following diagram explains the list of supported, implicit type * conversions between classes of this family: * * Rooted ----> Handle * | ^ * | | * | | * +---> MutableHandle * (via &) * * All of these types have an implicit conversion to raw pointers. */ namespace js { class Module; class ScriptSourceObject; template struct GCMethods {}; template class RootedBase {}; template class HandleBase {}; template class MutableHandleBase {}; template class HeapBase {}; /* * 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 gc { struct Cell; } /* namespace gc */ } /* 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; }; /* * The Heap class is a C/C++ heap-stored reference to a JS GC thing. All * members of heap classes that refer to GC thing should use Heap (or * possibly TenuredHeap, described below). * * Heap wraps the complex mechanisms required to ensure GC safety for the * contained reference into a C++ class that behaves similarly to a normal * pointer. * * GC references stored on the C/C++ stack must use Rooted/Handle/MutableHandle * instead. * * Requirements for type T: * - Must be one of: Value, jsid, JSObject*, JSString*, JSScript* */ template class Heap : public js::HeapBase { public: Heap() { static_assert(sizeof(T) == sizeof(Heap), "Heap must be binary compatible with T."); init(js::GCMethods::initial()); } explicit Heap(T p) { init(p); } explicit Heap(const Heap &p) { init(p.ptr); } ~Heap() { if (js::GCMethods::needsPostBarrier(ptr)) relocate(); } bool operator==(const Heap &other) { return ptr == other.ptr; } bool operator!=(const Heap &other) { return ptr != other.ptr; } bool operator==(const T &other) const { return ptr == other; } bool operator!=(const T &other) const { return ptr != other; } operator T() const { return ptr; } T operator->() const { return ptr; } const T *address() const { return &ptr; } const T &get() const { return ptr; } T *unsafeGet() { return &ptr; } Heap &operator=(T p) { set(p); return *this; } void set(T newPtr) { JS_ASSERT(!js::GCMethods::poisoned(newPtr)); if (js::GCMethods::needsPostBarrier(newPtr)) { ptr = newPtr; post(); } else if (js::GCMethods::needsPostBarrier(ptr)) { relocate(); /* Called before overwriting ptr. */ ptr = newPtr; } else { ptr = newPtr; } } private: void init(T newPtr) { JS_ASSERT(!js::GCMethods::poisoned(newPtr)); ptr = newPtr; if (js::GCMethods::needsPostBarrier(ptr)) post(); } void post() { #ifdef JSGC_GENERATIONAL JS_ASSERT(js::GCMethods::needsPostBarrier(ptr)); js::GCMethods::postBarrier(&ptr); #endif } void relocate() { #ifdef JSGC_GENERATIONAL js::GCMethods::relocate(&ptr); #endif } T ptr; }; #ifdef DEBUG /* * For generational GC, assert that an object is in the tenured generation as * opposed to being in the nursery. */ extern JS_FRIEND_API(void) AssertGCThingMustBeTenured(JSObject* obj); #else inline void AssertGCThingMustBeTenured(JSObject *obj) {} #endif /* * The TenuredHeap class is similar to the Heap class above in that it * encapsulates the GC concerns of an on-heap reference to a JS object. However, * it has two important differences: * * 1) Pointers which are statically known to only reference "tenured" objects * can avoid the extra overhead of SpiderMonkey's write barriers. * * 2) Objects in the "tenured" heap have stronger alignment restrictions than * those in the "nursery", so it is possible to store flags in the lower * bits of pointers known to be tenured. TenuredHeap wraps a normal tagged * pointer with a nice API for accessing the flag bits and adds various * assertions to ensure that it is not mis-used. * * GC things are said to be "tenured" when they are located in the long-lived * heap: e.g. they have gained tenure as an object by surviving past at least * one GC. For performance, SpiderMonkey allocates some things which are known * to normally be long lived directly into the tenured generation; for example, * global objects. Additionally, SpiderMonkey does not visit individual objects * when deleting non-tenured objects, so object with finalizers are also always * tenured; for instance, this includes most DOM objects. * * The considerations to keep in mind when using a TenuredHeap vs a normal * Heap are: * * - It is invalid for a TenuredHeap to refer to a non-tenured thing. * - It is however valid for a Heap to refer to a tenured thing. * - It is not possible to store flag bits in a Heap. */ template class TenuredHeap : public js::HeapBase { public: TenuredHeap() : bits(0) { static_assert(sizeof(T) == sizeof(TenuredHeap), "TenuredHeap must be binary compatible with T."); } explicit TenuredHeap(T p) : bits(0) { setPtr(p); } explicit TenuredHeap(const TenuredHeap &p) : bits(0) { setPtr(p.ptr); } bool operator==(const TenuredHeap &other) { return bits == other.bits; } bool operator!=(const TenuredHeap &other) { return bits != other.bits; } void setPtr(T newPtr) { JS_ASSERT((reinterpret_cast(newPtr) & flagsMask) == 0); JS_ASSERT(!js::GCMethods::poisoned(newPtr)); if (newPtr) AssertGCThingMustBeTenured(newPtr); bits = (bits & flagsMask) | reinterpret_cast(newPtr); } void setFlags(uintptr_t flagsToSet) { JS_ASSERT((flagsToSet & ~flagsMask) == 0); bits |= flagsToSet; } void unsetFlags(uintptr_t flagsToUnset) { JS_ASSERT((flagsToUnset & ~flagsMask) == 0); bits &= ~flagsToUnset; } bool hasFlag(uintptr_t flag) const { JS_ASSERT((flag & ~flagsMask) == 0); return (bits & flag) != 0; } T getPtr() const { return reinterpret_cast(bits & ~flagsMask); } uintptr_t getFlags() const { return bits & flagsMask; } operator T() const { return getPtr(); } T operator->() const { return getPtr(); } TenuredHeap &operator=(T p) { setPtr(p); return *this; } /* * Set the pointer to a value which will cause a crash if it is * dereferenced. */ void setToCrashOnTouch() { bits = (bits & flagsMask) | crashOnTouchPointer; } bool isSetToCrashOnTouch() { return (bits & ~flagsMask) == crashOnTouchPointer; } private: enum { maskBits = 3, flagsMask = (1 << maskBits) - 1, crashOnTouchPointer = 1 << maskBits }; uintptr_t bits; }; /* * 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 MOZ_NONHEAP_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) { static_assert(sizeof(Handle) == sizeof(T *), "Handle must be binary compatible with T*."); ptr = reinterpret_cast(handle.address()); } /* Create a handle for a NULL pointer. */ Handle(js::NullPtr) { 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) { 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(); } /* * Take care when calling this method! * * This creates a Handle from the raw location of a T. * * It should be called only if the following conditions hold: * * 1) 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. * * 2) the contents of the location are immutable, or at least cannot change * for the lifetime of the handle, as its users may not expect its value * to change underneath them. */ 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(const 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; } const T& get() const { return *ptr; } /* * Return a reference so passing a Handle to something that * takes a |const T&| is not a GC hazard. */ operator const T&() const { return get(); } T operator->() const { return get(); } bool operator!=(const T &other) const { return *ptr != other; } bool operator==(const T &other) const { return *ptr == other; } private: Handle() {} const T *ptr; template void operator=(S v) MOZ_DELETE; }; typedef Handle HandleObject; typedef Handle HandleModule; typedef Handle HandleScriptSource; 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 MOZ_STACK_CLASS MutableHandle : public js::MutableHandleBase { public: inline MutableHandle(Rooted *root); void set(T v) { JS_ASSERT(!js::GCMethods::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; } const T& get() const { return *ptr; } /* * Return a reference so passing a MutableHandle to something that takes * a |const T&| is not a GC hazard. */ operator const T&() const { return get(); } T operator->() const { return get(); } private: MutableHandle() {} T *ptr; template void operator=(S v) MOZ_DELETE; void operator=(MutableHandle other) MOZ_DELETE; }; typedef MutableHandle MutableHandleObject; typedef MutableHandle MutableHandleFunction; typedef MutableHandle MutableHandleScript; typedef MutableHandle MutableHandleString; typedef MutableHandle MutableHandleId; typedef MutableHandle MutableHandleValue; #ifdef JSGC_GENERATIONAL JS_PUBLIC_API(void) HeapCellPostBarrier(js::gc::Cell **cellp); JS_PUBLIC_API(void) HeapCellRelocate(js::gc::Cell **cellp); #endif } /* namespace JS */ namespace js { /* * 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)) {} }; /* * 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 GCMethods { static T *initial() { return NULL; } static ThingRootKind kind() { return RootKind::rootKind(); } static bool poisoned(T *v) { return JS::IsPoisonedPtr(v); } static bool needsPostBarrier(T *v) { return v; } #ifdef JSGC_GENERATIONAL static void postBarrier(T **vp) { JS::HeapCellPostBarrier(reinterpret_cast(vp)); } static void relocate(T **vp) { JS::HeapCellRelocate(reinterpret_cast(vp)); } #endif }; // XXX: Needed for cocos2d JS Bindings //#if defined(DEBUG) /* This helper allows us to assert that Rooted is scoped within a request. */ extern JS_PUBLIC_API(bool) IsInRequest(JSContext *cx); //#endif } /* 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 MOZ_STACK_CLASS Rooted : public js::RootedBase { /* Note: CX is a subclass of either ContextFriendFields or PerThreadDataFriendFields. */ template void init(CX *cx) { #ifdef JSGC_TRACK_EXACT_ROOTS js::ThingRootKind kind = js::GCMethods::kind(); this->stack = &cx->thingGCRooters[kind]; this->prev = *stack; *stack = reinterpret_cast*>(this); JS_ASSERT(!js::GCMethods::poisoned(ptr)); #endif } public: Rooted(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_ASSERT(js::IsInRequest(cx)); init(js::ContextFriendFields::get(cx)); } Rooted(JSContext *cx, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_ASSERT(js::IsInRequest(cx)); init(js::ContextFriendFields::get(cx)); } Rooted(js::ContextFriendFields *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(cx); } Rooted(js::ContextFriendFields *cx, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(cx); } Rooted(js::PerThreadDataFriendFields *pt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(pt); } Rooted(js::PerThreadDataFriendFields *pt, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(pt); } Rooted(JSRuntime *rt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(js::PerThreadDataFriendFields::getMainThread(rt)); } Rooted(JSRuntime *rt, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(js::PerThreadDataFriendFields::getMainThread(rt)); } ~Rooted() { #ifdef JSGC_TRACK_EXACT_ROOTS JS_ASSERT(*stack == reinterpret_cast*>(this)); *stack = prev; #endif } #ifdef JSGC_TRACK_EXACT_ROOTS Rooted *previous() { return prev; } #endif /* * Important: Return a reference here so passing a Rooted to * something that takes a |const T&| is not a GC hazard. */ operator const 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::GCMethods::poisoned(value)); ptr = value; return ptr; } T &operator=(const Rooted &value) { ptr = value; return ptr; } void set(T value) { JS_ASSERT(!js::GCMethods::poisoned(value)); ptr = value; } bool operator!=(const T &other) const { return ptr != other; } bool operator==(const T &other) const { return ptr == other; } private: #ifdef JSGC_TRACK_EXACT_ROOTS 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*); #endif #ifdef JSGC_ROOT_ANALYSIS 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 RootedScriptSource; 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(CX *cx, const T *ptr, size_t count) { SkipRoot **head = &cx->skipGCRooters; this->stack = head; this->prev = *stack; *stack = this; this->start = (const uint8_t *) ptr; this->end = this->start + (sizeof(T) * count); } public: ~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 */ template void init(js::ContextFriendFields *cx, const T *ptr, size_t count) {} public: #endif /* DEBUG && JSGC_ROOT_ANALYSIS */ template SkipRoot(JSContext *cx, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(ContextFriendFields::get(cx), ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template SkipRoot(ContextFriendFields *cx, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(cx, ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template SkipRoot(PerThreadData *pt, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(PerThreadDataFriendFields::get(pt), ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* Interface substitute for Rooted which does not root the variable's memory. */ template class FakeRooted : public RootedBase { public: template FakeRooted(CX *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template FakeRooted(CX *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(!GCMethods::poisoned(value)); ptr = value; return ptr; } bool operator!=(const T &other) const { return ptr != other; } bool operator==(const T &other) const { 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::GCMethods::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) { MOZ_ASSUME_UNREACHABLE("Bad conversion"); } static inline JS::MutableHandle toMutableHandle(MutableHandleType v) { MOZ_ASSUME_UNREACHABLE("Bad conversion"); } }; } /* namespace js */ namespace JS { template template inline Handle::Handle(const 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) { static_assert(sizeof(MutableHandle) == sizeof(T *), "MutableHandle must be binary compatible with T*."); 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 } /* 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 */ #endif /* js_RootingAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/Utility.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_Utility_h #define js_Utility_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/Move.h" #include "mozilla/Scoped.h" #include "mozilla/TemplateLib.h" #include #include #ifdef JS_OOM_DO_BACKTRACES #include #include #endif #include "jstypes.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_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) 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 testing function * oomAfterAllocations COUNT is passed, we fail continuously after the NUM'th * allocation from now. */ extern JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations; /* set in builtins/TestingFunctions.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_calloc(size_t nmemb, size_t size) { JS_OOM_POSSIBLY_FAIL(); return calloc(nmemb, size); } 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_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 void js_delete_poison(T *p) { if (p) { p->~T(); memset(p, 0x3B, sizeof(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 & mozilla::tl::MulOverflowMask::value) return NULL; return (T *)js_malloc(numElems * sizeof(T)); } template static JS_ALWAYS_INLINE T * js_pod_calloc(size_t numElems) { if (numElems & mozilla::tl::MulOverflowMask::value) 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 { /* 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 } } /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/Value.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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(__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(__SUNPRO_CC) && !defined(__xlC__) */ 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(__SUNPRO_CC) && !defined(__xlC__) */ #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) /* 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 jsval_layout JSVAL_TO_IMPL(JS::Value v); static inline JS::Value IMPL_TO_JSVAL(jsval_layout l); namespace JS { /** * Returns a generic quiet NaN value, with all payload bits set to zero. * * Among other properties, this NaN's bit pattern conforms to JS::Value's * bit pattern restrictions. */ static MOZ_ALWAYS_INLINE double GenericNaN() { return mozilla::SpecificNaN(0, 0x8000000000000ULL); } static inline double CanonicalizeNaN(double d) { if (MOZ_UNLIKELY(mozilla::IsNaN(d))) return GenericNaN(); return d; } /* * 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 (mozilla::DoubleIsInt32(d, &i)) { setInt32(i); return true; } 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 /************************************************************************/ #ifdef JSGC_GENERATIONAL namespace JS { JS_PUBLIC_API(void) HeapValuePostBarrier(Value *valuep); JS_PUBLIC_API(void) HeapValueRelocate(Value *valuep); } #endif namespace js { template <> struct GCMethods { 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 GCMethods { 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); } static bool needsPostBarrier(const JS::Value &v) { return v.isMarkable(); } #ifdef JSGC_GENERATIONAL static void postBarrier(JS::Value *v) { JS::HeapValuePostBarrier(v); } static void relocate(JS::Value *v) { JS::HeapValueRelocate(v); } #endif }; template class UnbarrieredMutableValueOperations; 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 UnbarrieredMutableValueOperations; 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(); } uint32_t toPrivateUint32() const { return value()->toPrivateUint32(); } 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 that don't need post barriers. Outer must be * a class inheriting UnbarrieredMutableValueOperations with visible * extractMutable() and extract() methods returning the const Value* and Value* * abstracted by Outer. */ template class UnbarrieredMutableValueOperations : public ValueOperations { friend class MutableValueOperations; 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 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); } }; /* * A class designed for CRTP use in implementing all 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 UnbarrieredMutableValueOperations { public: void setString(JSString *str) { this->value()->setString(str); } void setString(const JS::Anchor &str) { this->value()->setString(str); } void setObject(JSObject &obj) { this->value()->setObject(obj); } void setObjectOrNull(JSObject *arg) { this->value()->setObjectOrNull(arg); } }; /* * Augment the generic Heap interface when T = Value with * type-querying, value-extracting, and mutating operations. */ template <> class HeapBase : public UnbarrieredMutableValueOperations > { typedef JS::Heap Outer; friend class ValueOperations; friend class UnbarrieredMutableValueOperations; const JS::Value * extract() const { return static_cast(this)->address(); } JS::Value * extractMutable() { return static_cast(this)->unsafeGet(); } /* * Setters that potentially change the value to a GC thing from a non-GC * thing must call JS::Heap::set() to trigger the post barrier. * * Changing from a GC thing to a non-GC thing value will leave the heap * value in the store buffer, but it will be ingored so this is not a * problem. */ void setBarriered(const JS::Value &v) { static_cast *>(this)->set(v); } public: void setString(JSString *str) { setBarriered(JS::StringValue(str)); } void setString(const JS::Anchor &str) { setBarriered(JS::StringValue(str.get())); } void setObject(JSObject &obj) { setBarriered(JS::ObjectValue(obj)); } void setObjectOrNull(JSObject *arg) { if (arg) setObject(*arg); else setNull(); } }; /* * 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 UnbarrieredMutableValueOperations >; 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 UnbarrieredMutableValueOperations >; 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; }; static_assert(sizeof(ValueAlignmentTester) == 16, "JS::Value must be 16-byte-aligned"); struct LayoutAlignmentTester { char c; jsval_layout l; }; 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; 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js/Vector.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_Vector_h #define js_Vector_h #include "mozilla/Vector.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; // If we had C++11 template aliases, we could just use this: // // template // using Vector = mozilla::Vector; // // ...and get rid of all the CRTP madness in mozilla::Vector(Base). But we // can't because compiler support's not up to snuff. (Template aliases are in // gcc 4.7 and clang 3.0 and are expected to be in MSVC 2013.) Instead, have a // completely separate class inheriting from mozilla::Vector, and throw CRTP at // the problem til things work. // // This workaround presents a couple issues. First, because js::Vector is a // distinct type from mozilla::Vector, overload resolution, method calls, etc. // are affected. *Hopefully* this won't be too bad in practice. (A bunch of // places had to be fixed when mozilla::Vector was introduced, but it wasn't a // crazy number.) Second, mozilla::Vector's interface has to be made subclass- // ready via CRTP -- or rather, via mozilla::VectorBase, which basically no one // should use. :-) Third, we have to redefine the constructors and the non- // inherited operators. Blech. Happily there aren't too many of these, so it // isn't the end of the world. template class Vector : public mozilla::VectorBase > { typedef typename mozilla::VectorBase Base; public: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} Vector(mozilla::MoveRef vec) : Base(vec) {} Vector &operator=(mozilla::MoveRef vec) { return Base::operator=(vec); } }; } // namespace js #endif /* js_Vector_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js-config.h ================================================ /* -*- 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. */ /* #undef JS_GC_ZEAL */ /* Define to 1 if the header is present and useable. See jscpucfg.h. */ #define JS_HAVE_ENDIAN_H 1 /* 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 */ /* The configure script defines these if it doesn't #define JS_HAVE_STDINT_H. */ #define JS_BYTES_PER_WORD 4 /* MOZILLA JSAPI version number components */ #define MOZJS_MAJOR_VERSION 25 #define MOZJS_MINOR_VERSION 0 #endif /* js_config_h___ */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/js.msg ================================================ /* -*- 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_MISSING_BINARY_DIGITS, 134, 0, JSEXN_SYNTAXERR, "missing binary digits after '0b'") 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_MISSING_OCTAL_DIGITS, 143, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'") 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_RESULTING_STRING_TOO_LARGE, 146, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size") 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_NEGATIVE_REPETITION_COUNT, 170, 0, JSEXN_RANGEERR, "repeat count must be non-negative") 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_BAD_STRICT_ASSIGN, 236, 1, JSEXN_SYNTAXERR, "can't assign to {0} in strict mode") 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_REDEFINE_ARRAY_LENGTH,242, 0, JSEXN_TYPEERR, "can't redefine array length") MSG_DEF(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH,243, 0, JSEXN_TYPEERR, "can't define array index property past the end of an array with non-writable length") 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_DEBUG_CANT_DEBUG_GLOBAL, 263, 0, JSEXN_ERR, "passing non-debuggable global to addDebuggee") 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_DEBUG_RESUMPTION_VALUE_DISALLOWED, 266, 0, JSEXN_TYPEERR, "resumption values are disallowed in this hook") 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_YIELD_WITHOUT_OPERAND, 272, 0, JSEXN_SYNTAXERR, "yield without a value is deprecated, and illegal in ES6 (use 'yield undefined' instead)") 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\" is only meaningful in the Directive Prologue of a function body") 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, 1, JSEXN_ERR, "successfully compiled asm.js code ({0})") 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") MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME,349, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups") MSG_DEF(JSMSG_DEPRECATED_SOURCE_MAP, 350, 0, JSEXN_SYNTAXERR, "Using //@ to indicate source map URL pragmas is deprecated. Use //# instead") MSG_DEF(JSMSG_BAD_DESTRUCT_ASSIGN, 351, 1, JSEXN_SYNTAXERR, "can't assign to {0} using destructuring assignment") MSG_DEF(JSMSG_BINARYDATA_ARRAYTYPE_BAD_ARGS, 352, 0, JSEXN_ERR, "Invalid arguments") MSG_DEF(JSMSG_BINARYDATA_BINARYARRAY_BAD_INDEX, 353, 0, JSEXN_RANGEERR, "invalid or out-of-range index") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_BAD_ARGS, 354, 0, JSEXN_RANGEERR, "invalid field descriptor") MSG_DEF(JSMSG_BINARYDATA_NOT_BINARYSTRUCT, 355, 1, JSEXN_TYPEERR, "{0} is not a BinaryStruct") MSG_DEF(JSMSG_BINARYDATA_SUBARRAY_INTEGER_ARG, 356, 1, JSEXN_ERR, "argument {0} must be an integer") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_EMPTY_DESCRIPTOR, 357, 0, JSEXN_ERR, "field descriptor cannot be empty") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_BAD_FIELD, 358, 1, JSEXN_ERR, "field {0} is not a valid BinaryData Type descriptor") ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsalloc.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* JS allocation policies. */ #ifndef jsalloc_h #define jsalloc_h #include "mozilla/AllocPolicy.h" #include "js/Utility.h" struct JSContext; namespace js { class ContextFriendFields; /* 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 { ContextFriendFields *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_((ContextFriendFields *) cx) {} // :( TempAllocPolicy(ContextFriendFields *cx) : cx_(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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* JavaScript API. */ #ifndef jsapi_h #define jsapi_h #include "mozilla/FloatingPoint.h" #include "mozilla/MemoryReporting.h" #include "mozilla/RangedPtr.h" #include "mozilla/ThreadLocal.h" #include "mozilla/TypeTraits.h" #include #include #include #include #include "js-config.h" #include "jsalloc.h" #include "jspubtd.h" #include "js/CallArgs.h" #include "js/CharacterEncoding.h" #include "js/HashTable.h" #include "js/RootingAPI.h" #include "js/Utility.h" #include "js/Value.h" #include "js/Vector.h" /************************************************************************/ namespace JS { typedef mozilla::RangedPtr CharPtr; class StableCharPtr : public CharPtr { public: StableCharPtr(const StableCharPtr &s) : CharPtr(s) {} StableCharPtr(const mozilla::RangedPtr &s) : CharPtr(s) {} StableCharPtr(const jschar *s, size_t len) : CharPtr(s, len) {} StableCharPtr(const jschar *pos, const jschar *start, size_t len) : CharPtr(pos, start, len) {} }; #if defined JS_THREADSAFE && defined DEBUG class JS_PUBLIC_API(AutoCheckRequestDepth) { JSContext *cx; public: AutoCheckRequestDepth(JSContext *cx); AutoCheckRequestDepth(js::ContextFriendFields *cx); ~AutoCheckRequestDepth(); }; # define CHECK_REQUEST(cx) \ JS::AutoCheckRequestDepth _autoCheckRequestDepth(cx) #else # define CHECK_REQUEST(cx) \ ((void) 0) #endif /* JS_THREADSAFE && DEBUG */ #ifdef DEBUG /* * Assert that we're not doing GC on cx, that we're in a request as * needed, and that the compartments for cx and v are correct. * Also check that GC would be safe at this point. */ JS_PUBLIC_API(void) AssertArgumentsAreSane(JSContext *cx, JS::Handle v); #else inline void AssertArgumentsAreSane(JSContext *cx, JS::Handle v) { /* Do nothing */ } #endif /* DEBUG */ class JS_PUBLIC_API(AutoGCRooter) { public: AutoGCRooter(JSContext *cx, ptrdiff_t tag); AutoGCRooter(js::ContextFriendFields *cx, ptrdiff_t tag); ~AutoGCRooter() { JS_ASSERT(this == *stackTop); *stackTop = down; } /* Implemented in gc/RootMarking.cpp. */ inline void trace(JSTracer *trc); static void traceAll(JSTracer *trc); static void traceAllWrappers(JSTracer *trc); protected: AutoGCRooter * const down; /* * Discriminates actual subclass of this being used. If non-negative, the * subclass roots an array of values of the length stored in this field. * If negative, meaning is indicated by the corresponding value in the enum * below. Any other negative value indicates some deeper problem such as * memory corruption. */ ptrdiff_t tag_; enum { VALARRAY = -2, /* js::AutoValueArray */ PARSER = -3, /* js::frontend::Parser */ SHAPEVECTOR = -4, /* js::AutoShapeVector */ IDARRAY = -6, /* js::AutoIdArray */ DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */ ID = -9, /* js::AutoIdRooter */ VALVECTOR = -10, /* js::AutoValueVector */ DESCRIPTOR = -11, /* js::AutoPropertyDescriptorRooter */ STRING = -12, /* js::AutoStringRooter */ IDVECTOR = -13, /* js::AutoIdVector */ OBJVECTOR = -14, /* js::AutoObjectVector */ STRINGVECTOR =-15, /* js::AutoStringVector */ SCRIPTVECTOR =-16, /* js::AutoScriptVector */ NAMEVECTOR = -17, /* js::AutoNameVector */ HASHABLEVALUE=-18, /* js::HashableValue */ IONMASM = -19, /* js::jit::MacroAssembler */ IONALLOC = -20, /* js::jit::AutoTempAllocatorRooter */ WRAPVECTOR = -21, /* js::AutoWrapperVector */ WRAPPER = -22, /* js::AutoWrapperRooter */ OBJOBJHASHMAP=-23, /* js::AutoObjectObjectHashMap */ OBJU32HASHMAP=-24, /* js::AutoObjectUnsigned32HashMap */ OBJHASHSET = -25, /* js::AutoObjectHashSet */ JSONPARSER = -26, /* js::JSONParser */ CUSTOM = -27, /* js::CustomAutoRooter */ FUNVECTOR = -28 /* js::AutoFunctionVector */ }; private: AutoGCRooter ** const stackTop; /* No copy or assignment semantics. */ AutoGCRooter(AutoGCRooter &ida) MOZ_DELETE; void operator=(AutoGCRooter &ida) MOZ_DELETE; }; class AutoStringRooter : private AutoGCRooter { public: AutoStringRooter(JSContext *cx, JSString *str = NULL MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, STRING), str_(str) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } void setString(JSString *str) { str_ = str; } JSString * string() const { return str_; } JSString ** addr() { return &str_; } JSString * const * addr() const { return &str_; } friend void AutoGCRooter::trace(JSTracer *trc); private: JSString *str_; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoArrayRooter : private AutoGCRooter { public: AutoArrayRooter(JSContext *cx, size_t len, Value *vec MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, len), array(vec), skip(cx, array, len) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; JS_ASSERT(tag_ >= 0); } void changeLength(size_t newLength) { tag_ = ptrdiff_t(newLength); JS_ASSERT(tag_ >= 0); } void changeArray(Value *newArray, size_t newLength) { changeLength(newLength); array = newArray; } Value *array; MutableHandleValue handleAt(size_t i) { JS_ASSERT(i < size_t(tag_)); return MutableHandleValue::fromMarkedLocation(&array[i]); } HandleValue handleAt(size_t i) const { JS_ASSERT(i < size_t(tag_)); return HandleValue::fromMarkedLocation(&array[i]); } friend void AutoGCRooter::trace(JSTracer *trc); private: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER js::SkipRoot skip; }; template class AutoVectorRooter : protected AutoGCRooter { public: explicit AutoVectorRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), vector(cx), vectorRoot(cx, &vector) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } explicit AutoVectorRooter(js::ContextFriendFields *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), vector(cx), vectorRoot(cx, &vector) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef T ElementType; size_t length() const { return vector.length(); } bool empty() const { return vector.empty(); } bool append(const T &v) { return vector.append(v); } bool appendAll(const AutoVectorRooter &other) { return vector.appendAll(other.vector); } bool insert(T *p, const T &val) { return vector.insert(p, val); } /* For use when space has already been reserved. */ void infallibleAppend(const T &v) { vector.infallibleAppend(v); } void popBack() { vector.popBack(); } T popCopy() { return vector.popCopy(); } bool growBy(size_t inc) { size_t oldLength = vector.length(); if (!vector.growByUninitialized(inc)) return false; makeRangeGCSafe(oldLength); return true; } bool resize(size_t newLength) { size_t oldLength = vector.length(); if (newLength <= oldLength) { vector.shrinkBy(oldLength - newLength); return true; } if (!vector.growByUninitialized(newLength - oldLength)) return false; makeRangeGCSafe(oldLength); return true; } void clear() { vector.clear(); } bool reserve(size_t newLength) { return vector.reserve(newLength); } T &operator[](size_t i) { return vector[i]; } const T &operator[](size_t i) const { return vector[i]; } JS::MutableHandle handleAt(size_t i) { return JS::MutableHandle::fromMarkedLocation(&vector[i]); } JS::Handle handleAt(size_t i) const { return JS::Handle::fromMarkedLocation(&vector[i]); } const T *begin() const { return vector.begin(); } T *begin() { return vector.begin(); } const T *end() const { return vector.end(); } T *end() { return vector.end(); } const T &back() const { return vector.back(); } friend void AutoGCRooter::trace(JSTracer *trc); private: void makeRangeGCSafe(size_t oldLength) { T *t = vector.begin() + oldLength; for (size_t i = oldLength; i < vector.length(); ++i, ++t) memset(t, 0, sizeof(T)); } typedef js::Vector VectorImpl; VectorImpl vector; /* Prevent overwriting of inline elements in vector. */ js::SkipRoot vectorRoot; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; template class AutoHashMapRooter : protected AutoGCRooter { private: typedef js::HashMap HashMapImpl; public: explicit AutoHashMapRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), map(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef Key KeyType; typedef Value ValueType; typedef typename HashMapImpl::Lookup Lookup; typedef typename HashMapImpl::Ptr Ptr; typedef typename HashMapImpl::AddPtr AddPtr; bool init(uint32_t len = 16) { return map.init(len); } bool initialized() const { return map.initialized(); } Ptr lookup(const Lookup &l) const { return map.lookup(l); } void remove(Ptr p) { map.remove(p); } AddPtr lookupForAdd(const Lookup &l) const { return map.lookupForAdd(l); } template bool add(AddPtr &p, const KeyInput &k, const ValueInput &v) { return map.add(p, k, v); } bool add(AddPtr &p, const Key &k) { return map.add(p, k); } template bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { return map.relookupOrAdd(p, k, v); } typedef typename HashMapImpl::Range Range; Range all() const { return map.all(); } typedef typename HashMapImpl::Enum Enum; void clear() { map.clear(); } void finish() { map.finish(); } bool empty() const { return map.empty(); } uint32_t count() const { return map.count(); } size_t capacity() const { return map.capacity(); } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfIncludingThis(mallocSizeOf); } unsigned generation() const { return map.generation(); } /************************************************** Shorthand operations */ bool has(const Lookup &l) const { return map.has(l); } template bool put(const KeyInput &k, const ValueInput &v) { return map.put(k, v); } template bool putNew(const KeyInput &k, const ValueInput &v) { return map.putNew(k, v); } Ptr lookupWithDefault(const Key &k, const Value &defaultValue) { return map.lookupWithDefault(k, defaultValue); } void remove(const Lookup &l) { map.remove(l); } friend void AutoGCRooter::trace(JSTracer *trc); private: AutoHashMapRooter(const AutoHashMapRooter &hmr) MOZ_DELETE; AutoHashMapRooter &operator=(const AutoHashMapRooter &hmr) MOZ_DELETE; HashMapImpl map; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; template class AutoHashSetRooter : protected AutoGCRooter { private: typedef js::HashSet HashSetImpl; public: explicit AutoHashSetRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), set(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef typename HashSetImpl::Lookup Lookup; typedef typename HashSetImpl::Ptr Ptr; typedef typename HashSetImpl::AddPtr AddPtr; bool init(uint32_t len = 16) { return set.init(len); } bool initialized() const { return set.initialized(); } Ptr lookup(const Lookup &l) const { return set.lookup(l); } void remove(Ptr p) { set.remove(p); } AddPtr lookupForAdd(const Lookup &l) const { return set.lookupForAdd(l); } bool add(AddPtr &p, const T &t) { return set.add(p, t); } bool relookupOrAdd(AddPtr &p, const Lookup &l, const T &t) { return set.relookupOrAdd(p, l, t); } typedef typename HashSetImpl::Range Range; Range all() const { return set.all(); } typedef typename HashSetImpl::Enum Enum; void clear() { set.clear(); } void finish() { set.finish(); } bool empty() const { return set.empty(); } uint32_t count() const { return set.count(); } size_t capacity() const { return set.capacity(); } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfIncludingThis(mallocSizeOf); } unsigned generation() const { return set.generation(); } /************************************************** Shorthand operations */ bool has(const Lookup &l) const { return set.has(l); } bool put(const T &t) { return set.put(t); } bool putNew(const T &t) { return set.putNew(t); } void remove(const Lookup &l) { set.remove(l); } friend void AutoGCRooter::trace(JSTracer *trc); private: AutoHashSetRooter(const AutoHashSetRooter &hmr) MOZ_DELETE; AutoHashSetRooter &operator=(const AutoHashSetRooter &hmr) MOZ_DELETE; HashSetImpl set; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoValueVector : public AutoVectorRooter { public: explicit AutoValueVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, VALVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoIdVector : public AutoVectorRooter { public: explicit AutoIdVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, IDVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoObjectVector : public AutoVectorRooter { public: explicit AutoObjectVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, OBJVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoFunctionVector : public AutoVectorRooter { public: explicit AutoFunctionVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, FUNVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } explicit AutoFunctionVector(js::ContextFriendFields *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, FUNVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoScriptVector : public AutoVectorRooter { public: explicit AutoScriptVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, SCRIPTVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* * Cutsom rooting behavior for internal and external clients. */ class JS_PUBLIC_API(CustomAutoRooter) : private AutoGCRooter { public: template explicit CustomAutoRooter(CX *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, CUSTOM) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } friend void AutoGCRooter::trace(JSTracer *trc); protected: /* Supplied by derived class to trace roots. */ virtual void trace(JSTracer *trc) = 0; private: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* Returns true if |v| is considered an acceptable this-value. */ typedef bool (*IsAcceptableThis)(const Value &v); /* * Implements the guts of a method; guaranteed to be provided an acceptable * this-value, as determined by a corresponding IsAcceptableThis method. */ typedef bool (*NativeImpl)(JSContext *cx, CallArgs args); namespace detail { /* DON'T CALL THIS DIRECTLY. It's for use only by CallNonGenericMethod! */ extern JS_PUBLIC_API(bool) CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args); } /* namespace detail */ /* * Methods usually act upon |this| objects only from a single global object and * compartment. Sometimes, however, a method must act upon |this| values from * multiple global objects or compartments. In such cases the |this| value a * method might see will be wrapped, such that various access to the object -- * to its class, its private data, its reserved slots, and so on -- will not * work properly without entering that object's compartment. This method * implements a solution to this problem. * * To implement a method that accepts |this| values from multiple compartments, * define two functions. The first function matches the IsAcceptableThis type * and indicates whether the provided value is an acceptable |this| for the * method; it must be a pure function only of its argument. * * static JSClass AnswerClass = { ... }; * * static bool * IsAnswerObject(const Value &v) * { * if (!v.isObject()) * return false; * return JS_GetClass(&v.toObject()) == &AnswerClass; * } * * The second function implements the NativeImpl signature and defines the * behavior of the method when it is provided an acceptable |this| value. * Aside from some typing niceties -- see the CallArgs interface for details -- * its interface is the same as that of JSNative. * * static bool * answer_getAnswer_impl(JSContext *cx, JS::CallArgs args) * { * args.rval().setInt32(42); * return true; * } * * The implementation function is guaranteed to be called *only* with a |this| * value which is considered acceptable. * * Now to implement the actual method, write a JSNative that calls the method * declared below, passing the appropriate template and runtime arguments. * * static JSBool * answer_getAnswer(JSContext *cx, unsigned argc, JS::Value *vp) * { * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); * return JS::CallNonGenericMethod(cx, args); * } * * Note that, because they are used as template arguments, the predicate * and implementation functions must have external linkage. (This is * unfortunate, but GCC wasn't inlining things as one would hope when we * passed them as function arguments.) * * JS::CallNonGenericMethod will test whether |args.thisv()| is acceptable. If * it is, it will call the provided implementation function, which will return * a value and indicate success. If it is not, it will attempt to unwrap * |this| and call the implementation function on the unwrapped |this|. If * that succeeds, all well and good. If it doesn't succeed, a TypeError will * be thrown. * * Note: JS::CallNonGenericMethod will only work correctly if it's called in * tail position in a JSNative. Do not call it from any other place. */ template JS_ALWAYS_INLINE bool CallNonGenericMethod(JSContext *cx, CallArgs args) { const Value &thisv = args.thisv(); if (Test(thisv)) return Impl(cx, args); return detail::CallMethodIfWrapped(cx, Test, Impl, args); } JS_ALWAYS_INLINE bool CallNonGenericMethod(JSContext *cx, IsAcceptableThis Test, NativeImpl Impl, CallArgs args) { const Value &thisv = args.thisv(); if (Test(thisv)) return Impl(cx, args); return detail::CallMethodIfWrapped(cx, Test, Impl, args); } } /* namespace JS */ /************************************************************************/ /* JSClass operation signatures. */ /* * Add or get a property named by id in obj. Note the jsid id type -- id may * be a string (Unicode property identifier) or an int (element index). The * *vp out parameter, on success, is the new property value after the action. */ typedef JSBool (* JSPropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JS::MutableHandle vp); /* * Set a property named by id in obj, treating the assignment as strict * mode code if strict is true. Note the jsid id type -- id may be a string * (Unicode property identifier) or an int (element index). The *vp out * parameter, on success, is the new property value after the * set. */ typedef JSBool (* JSStrictPropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool strict, JS::MutableHandle vp); /* * Delete a property named by id in obj. * * If an error occurred, return false as per normal JSAPI error practice. * * If no error occurred, but the deletion attempt wasn't allowed (perhaps * because the property was non-configurable), set *succeeded to false and * return true. This will cause |delete obj[id]| to evaluate to false in * non-strict mode code, and to throw a TypeError in strict mode code. * * If no error occurred and the deletion wasn't disallowed (this is *not* the * same as saying that a deletion actually occurred -- deleting a non-existent * property, or an inherited property, is allowed -- it's just pointless), * set *succeeded to true and return true. */ typedef JSBool (* JSDeletePropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool *succeeded); /* * This function type is used for callbacks that enumerate the properties of * a JSObject. The behavior depends on the value of enum_op: * * JSENUMERATE_INIT * A new, opaque iterator state should be allocated and stored in *statep. * (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored). * * The number of properties that will be enumerated should be returned as * an integer jsval in *idp, if idp is non-null, and provided the number of * enumerable properties is known. If idp is non-null and the number of * enumerable properties can't be computed in advance, *idp should be set * to JSVAL_ZERO. * * JSENUMERATE_INIT_ALL * Used identically to JSENUMERATE_INIT, but exposes all properties of the * object regardless of enumerability. * * JSENUMERATE_NEXT * A previously allocated opaque iterator state is passed in via statep. * Return the next jsid in the iteration using *idp. The opaque iterator * state pointed at by statep is destroyed and *statep is set to JSVAL_NULL * if there are no properties left to enumerate. * * JSENUMERATE_DESTROY * Destroy the opaque iterator state previously allocated in *statep by a * call to this function when enum_op was JSENUMERATE_INIT or * JSENUMERATE_INIT_ALL. * * The return value is used to indicate success, with a value of JS_FALSE * indicating failure. */ typedef JSBool (* JSNewEnumerateOp)(JSContext *cx, JS::Handle obj, JSIterateOp enum_op, JS::MutableHandle statep, JS::MutableHandleId idp); /* * The old-style JSClass.enumerate op should define all lazy properties not * yet reflected in obj. */ typedef JSBool (* JSEnumerateOp)(JSContext *cx, JS::Handle obj); /* * Resolve a lazy property named by id in obj by defining it directly in obj. * Lazy properties are those reflected from some peer native property space * (e.g., the DOM attributes for a given node reflected as obj) on demand. * * JS looks for a property in an object, and if not found, tries to resolve * the given id. If resolve succeeds, the engine looks again in case resolve * defined obj[id]. If no such property exists directly in obj, the process * is repeated with obj's prototype, etc. * * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties. */ typedef JSBool (* JSResolveOp)(JSContext *cx, JS::Handle obj, JS::Handle id); /* * Like JSResolveOp, but flags provide contextual information as follows: * * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment * * The *objp out parameter, on success, should be null to indicate that id * was not resolved; and non-null, referring to obj or one of its prototypes, * if id was resolved. The hook may assume *objp is null on entry. * * This hook instead of JSResolveOp is called via the JSClass.resolve member * if JSCLASS_NEW_RESOLVE is set in JSClass.flags. */ typedef JSBool (* JSNewResolveOp)(JSContext *cx, JS::Handle obj, JS::Handle id, unsigned flags, JS::MutableHandleObject objp); /* * Convert obj to the given type, returning true with the resulting value in * *vp on success, and returning false on error or exception. */ typedef JSBool (* JSConvertOp)(JSContext *cx, JS::Handle obj, JSType type, JS::MutableHandle vp); typedef struct JSFreeOp JSFreeOp; struct JSFreeOp { private: JSRuntime *runtime_; protected: JSFreeOp(JSRuntime *rt) : runtime_(rt) { } public: JSRuntime *runtime() const { return runtime_; } }; /* * Finalize obj, which the garbage collector has determined to be unreachable * from other live objects or from GC roots. Obviously, finalizers must never * store a reference to obj. */ typedef void (* JSFinalizeOp)(JSFreeOp *fop, JSObject *obj); /* * Finalizes external strings created by JS_NewExternalString. */ typedef struct JSStringFinalizer JSStringFinalizer; struct JSStringFinalizer { void (*finalize)(const JSStringFinalizer *fin, jschar *chars); }; /* * JSClass.checkAccess type: check whether obj[id] may be accessed per mode, * returning false on error/exception, true on success with obj[id]'s last-got * value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id * is either a string or an int jsval. */ typedef JSBool (* JSCheckAccessOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSAccessMode mode, JS::MutableHandle vp); /* * Check whether v is an instance of obj. Return false on error or exception, * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in * *bp otherwise. */ typedef JSBool (* JSHasInstanceOp)(JSContext *cx, JS::Handle obj, JS::MutableHandle vp, JSBool *bp); /* * Function type for trace operation of the class called to enumerate all * traceable things reachable from obj's private data structure. For each such * thing, a trace implementation must call one of the JS_Call*Tracer variants * on the thing. * * JSTraceOp implementation can assume that no other threads mutates object * state. It must not change state of the object or corresponding native * structures. The only exception for this rule is the case when the embedding * needs a tight integration with GC. In that case the embedding can check if * the traversal is a part of the marking phase through calling * JS_IsGCMarkingTracer and apply a special code like emptying caches or * marking its native structures. */ typedef void (* JSTraceOp)(JSTracer *trc, JSObject *obj); /* * Callback that JSTraceOp implementation can provide to return a string * describing the reference traced with JS_CallTracer. */ typedef void (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize); typedef JSObject * (* JSWeakmapKeyDelegateOp)(JSObject *obj); /* Callbacks and their arguments. */ typedef enum JSContextOp { JSCONTEXT_NEW, JSCONTEXT_DESTROY } JSContextOp; /* * The possible values for contextOp when the runtime calls the callback are: * JSCONTEXT_NEW JS_NewContext successfully created a new JSContext * instance. The callback can initialize the instance as * required. If the callback returns false, the instance * will be destroyed and JS_NewContext returns null. In * this case the callback is not called again. * JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The * callback may perform its own cleanup and must always * return true. * Any other value For future compatibility the callback must do nothing * and return true in this case. */ typedef JSBool (* JSContextCallback)(JSContext *cx, unsigned contextOp, void *data); typedef enum JSGCStatus { JSGC_BEGIN, JSGC_END } JSGCStatus; typedef void (* JSGCCallback)(JSRuntime *rt, JSGCStatus status, void *data); typedef enum JSFinalizeStatus { /* * Called when preparing to sweep a group of compartments, before anything * has been swept. The collector will not yield to the mutator before * calling the callback with JSFINALIZE_GROUP_END status. */ JSFINALIZE_GROUP_START, /* * Called when preparing to sweep a group of compartments. Weak references * to unmarked things have been removed and things that are not swept * incrementally have been finalized at this point. The collector may yield * to the mutator after this point. */ JSFINALIZE_GROUP_END, /* * Called at the end of collection when everything has been swept. */ JSFINALIZE_COLLECTION_END } JSFinalizeStatus; typedef void (* JSFinalizeCallback)(JSFreeOp *fop, JSFinalizeStatus status, JSBool isCompartment); /* * Generic trace operation that calls JS_CallTracer on each traceable thing * stored in data. */ typedef void (* JSTraceDataOp)(JSTracer *trc, void *data); typedef JSBool (* JSOperationCallback)(JSContext *cx); typedef void (* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report); #ifdef MOZ_TRACE_JSCALLS typedef void (* JSFunctionCallback)(const JSFunction *fun, const JSScript *scr, const JSContext *cx, int entering); #endif /* * Possible exception types. These types are part of a JSErrorFormatString * structure. They define which error to throw in case of a runtime error. * JSEXN_NONE marks an unthrowable error. */ typedef enum JSExnType { JSEXN_NONE = -1, JSEXN_ERR, JSEXN_INTERNALERR, JSEXN_EVALERR, JSEXN_RANGEERR, JSEXN_REFERENCEERR, JSEXN_SYNTAXERR, JSEXN_TYPEERR, JSEXN_URIERR, JSEXN_LIMIT } JSExnType; typedef struct JSErrorFormatString { /* The error format string in ASCII. */ const char *format; /* The number of arguments to expand in the formatted error message. */ uint16_t argCount; /* One of the JSExnType constants above. */ int16_t exnType; } JSErrorFormatString; typedef const JSErrorFormatString * (* JSErrorCallback)(void *userRef, const char *locale, const unsigned errorNumber); typedef JSBool (* JSLocaleToUpperCase)(JSContext *cx, JS::Handle src, JS::MutableHandle rval); typedef JSBool (* JSLocaleToLowerCase)(JSContext *cx, JS::Handle src, JS::MutableHandle rval); typedef JSBool (* JSLocaleCompare)(JSContext *cx, JS::Handle src1, JS::Handle src2, JS::MutableHandle rval); typedef JSBool (* JSLocaleToUnicode)(JSContext *cx, const char *src, JS::MutableHandle rval); /* * Security protocol types. */ typedef void (* JSDestroyPrincipalsOp)(JSPrincipals *principals); /* * Used to check if a CSP instance wants to disable eval() and friends. * See js_CheckCSPPermitsJSAction() in jsobj. */ typedef JSBool (* JSCSPEvalChecker)(JSContext *cx); /* * Callback used to ask the embedding for the cross compartment wrapper handler * that implements the desired prolicy for this kind of object in the * destination compartment. |obj| is the object to be wrapped. If |existing| is * non-NULL, it will point to an existing wrapper object that should be re-used * if possible. |existing| is guaranteed to be a cross-compartment wrapper with * a lazily-defined prototype and the correct global. It is guaranteed not to * wrap a function. */ typedef JSObject * (* JSWrapObjectCallback)(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj, JS::HandleObject proto, JS::HandleObject parent, unsigned flags); /* * Callback used by the wrap hook to ask the embedding to prepare an object * for wrapping in a context. This might include unwrapping other wrappers * or even finding a more suitable object for the new compartment. */ typedef JSObject * (* JSPreWrapCallback)(JSContext *cx, JS::HandleObject scope, JS::HandleObject obj, unsigned flags); /* * Callback used when wrapping determines that the underlying object is already * in the compartment for which it is being wrapped. This allows consumers to * maintain same-compartment wrapping invariants. * * |obj| is guaranteed to be same-compartment as |cx|, but it may (or may not) * be a security or cross-compartment wrapper. This is an unfortunate contract, * but is important for to avoid unnecessarily recomputing every cross- * compartment wrapper that gets passed to wrap. */ typedef JSObject * (* JSSameCompartmentWrapObjectCallback)(JSContext *cx, JS::HandleObject obj); typedef void (* JSDestroyCompartmentCallback)(JSFreeOp *fop, JSCompartment *compartment); typedef void (* JSCompartmentNameCallback)(JSRuntime *rt, JSCompartment *compartment, char *buf, size_t bufsize); /* * Read structured data from the reader r. This hook is used to read a value * previously serialized by a call to the WriteStructuredCloneOp hook. * * tag and data are the pair of uint32_t values from the header. The callback * may use the JS_Read* APIs to read any other relevant parts of the object * from the reader r. closure is any value passed to the JS_ReadStructuredClone * function. Return the new object on success, NULL on error/exception. */ typedef JSObject *(*ReadStructuredCloneOp)(JSContext *cx, JSStructuredCloneReader *r, uint32_t tag, uint32_t data, void *closure); /* * Structured data serialization hook. The engine can write primitive values, * Objects, Arrays, Dates, RegExps, TypedArrays, and ArrayBuffers. Any other * type of object requires application support. This callback must first use * the JS_WriteUint32Pair API to write an object header, passing a value * greater than JS_SCTAG_USER to the tag parameter. Then it can use the * JS_Write* APIs to write any other relevant parts of the value v to the * writer w. closure is any value passed to the JS_WriteStructuredCLone function. * * Return true on success, false on error/exception. */ typedef JSBool (*WriteStructuredCloneOp)(JSContext *cx, JSStructuredCloneWriter *w, JS::Handle obj, void *closure); /* * This is called when JS_WriteStructuredClone is given an invalid transferable. * To follow HTML5, the application must throw a DATA_CLONE_ERR DOMException * with error set to one of the JS_SCERR_* values. */ typedef void (*StructuredCloneErrorOp)(JSContext *cx, uint32_t errorid); /************************************************************************/ /* * JS constants. For efficiency, prefer predicates (e.g. v.isNull()) and * constructing values from scratch (e.g. Int32Value(0)). These constants are * stored in memory and initialized at startup, so testing against them and * using them requires memory loads and will be correspondingly slow. */ extern JS_PUBLIC_DATA(const jsval) JSVAL_NULL; extern JS_PUBLIC_DATA(const jsval) JSVAL_ZERO; extern JS_PUBLIC_DATA(const jsval) JSVAL_ONE; extern JS_PUBLIC_DATA(const jsval) JSVAL_FALSE; extern JS_PUBLIC_DATA(const jsval) JSVAL_TRUE; extern JS_PUBLIC_DATA(const jsval) JSVAL_VOID; static JS_ALWAYS_INLINE jsval JS_NumberValue(double d) { int32_t i; d = JS::CanonicalizeNaN(d); if (mozilla::DoubleIsInt32(d, &i)) return INT_TO_JSVAL(i); return DOUBLE_TO_JSVAL(d); } /************************************************************************/ /* * A jsid is an identifier for a property or method of an object which is * either a 31-bit signed integer, interned string or object. Also, there is * an additional jsid value, JSID_VOID, which does not occur in JS scripts but * may be used to indicate the absence of a valid jsid. * * A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or * JS_IdToValue must be used instead. */ #define JSID_TYPE_STRING 0x0 #define JSID_TYPE_INT 0x1 #define JSID_TYPE_VOID 0x2 #define JSID_TYPE_OBJECT 0x4 #define JSID_TYPE_MASK 0x7 /* * Avoid using canonical 'id' for jsid parameters since this is a magic word in * Objective-C++ which, apparently, wants to be able to #include jsapi.h. */ #define id iden static JS_ALWAYS_INLINE JSBool JSID_IS_STRING(jsid id) { return (JSID_BITS(id) & JSID_TYPE_MASK) == 0; } static JS_ALWAYS_INLINE JSString * JSID_TO_STRING(jsid id) { JS_ASSERT(JSID_IS_STRING(id)); return (JSString *)JSID_BITS(id); } static JS_ALWAYS_INLINE JSBool JSID_IS_ZERO(jsid id) { return JSID_BITS(id) == 0; } JS_PUBLIC_API(JSBool) JS_StringHasBeenInterned(JSContext *cx, JSString *str); /* * Only JSStrings that have been interned via the JSAPI can be turned into * jsids by API clients. * * N.B. if a jsid is backed by a string which has not been interned, that * string must be appropriately rooted to avoid being collected by the GC. */ JS_PUBLIC_API(jsid) INTERNED_STRING_TO_JSID(JSContext *cx, JSString *str); static JS_ALWAYS_INLINE JSBool JSID_IS_INT(jsid id) { return !!(JSID_BITS(id) & JSID_TYPE_INT); } static JS_ALWAYS_INLINE int32_t JSID_TO_INT(jsid id) { JS_ASSERT(JSID_IS_INT(id)); return ((uint32_t)JSID_BITS(id)) >> 1; } #define JSID_INT_MIN 0 #define JSID_INT_MAX INT32_MAX static JS_ALWAYS_INLINE JSBool INT_FITS_IN_JSID(int32_t i) { return i >= 0; } static JS_ALWAYS_INLINE jsid INT_TO_JSID(int32_t i) { jsid id; JS_ASSERT(INT_FITS_IN_JSID(i)); JSID_BITS(id) = ((i << 1) | JSID_TYPE_INT); return id; } static JS_ALWAYS_INLINE JSBool JSID_IS_OBJECT(jsid id) { return (JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_OBJECT && (size_t)JSID_BITS(id) != JSID_TYPE_OBJECT; } static JS_ALWAYS_INLINE JSObject * JSID_TO_OBJECT(jsid id) { JS_ASSERT(JSID_IS_OBJECT(id)); return (JSObject *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); } static JS_ALWAYS_INLINE jsid OBJECT_TO_JSID(JSObject *obj) { jsid id; JS_ASSERT(obj != NULL); JS_ASSERT(((size_t)obj & JSID_TYPE_MASK) == 0); JSID_BITS(id) = ((size_t)obj | JSID_TYPE_OBJECT); return id; } static JS_ALWAYS_INLINE JSBool JSID_IS_GCTHING(jsid id) { return JSID_IS_STRING(id) || JSID_IS_OBJECT(id); } static JS_ALWAYS_INLINE void * JSID_TO_GCTHING(jsid id) { return (void *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); } /* * A void jsid is not a valid id and only arises as an exceptional API return * value, such as in JS_NextProperty. Embeddings must not pass JSID_VOID into * JSAPI entry points expecting a jsid and do not need to handle JSID_VOID in * hooks receiving a jsid except when explicitly noted in the API contract. */ static JS_ALWAYS_INLINE JSBool JSID_IS_VOID(const jsid id) { JS_ASSERT_IF(((size_t)JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_VOID, JSID_BITS(id) == JSID_TYPE_VOID); return ((size_t)JSID_BITS(id) == JSID_TYPE_VOID); } static JS_ALWAYS_INLINE JSBool JSID_IS_EMPTY(const jsid id) { return ((size_t)JSID_BITS(id) == JSID_TYPE_OBJECT); } #undef id #ifdef JS_USE_JSID_STRUCT_TYPES extern JS_PUBLIC_DATA(const jsid) JSID_VOID; extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY; #else # define JSID_VOID ((jsid)JSID_TYPE_VOID) # define JSID_EMPTY ((jsid)JSID_TYPE_OBJECT) #endif /* * Returns true iff the given jsval is immune to GC and can be used across * multiple JSRuntimes without requiring any conversion API. */ static JS_ALWAYS_INLINE JSBool JSVAL_IS_UNIVERSAL(jsval v) { return !JSVAL_IS_GCTHING(v); } namespace JS { class AutoIdRooter : private AutoGCRooter { public: explicit AutoIdRooter(JSContext *cx, jsid aId = INT_TO_JSID(0) MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, ID), id_(aId) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } jsid id() { return id_; } jsid * addr() { return &id_; } friend void AutoGCRooter::trace(JSTracer *trc); private: jsid id_; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; } /* namespace JS */ /************************************************************************/ /* Property attributes, set in JSPropertySpec and passed to API functions. */ #define JSPROP_ENUMERATE 0x01 /* property is visible to for/in loop */ #define JSPROP_READONLY 0x02 /* not settable: assignment is no-op. This flag is only valid when neither JSPROP_GETTER nor JSPROP_SETTER is set. */ #define JSPROP_PERMANENT 0x04 /* property cannot be deleted */ #define JSPROP_NATIVE_ACCESSORS 0x08 /* set in JSPropertyDescriptor.flags if getters/setters are JSNatives */ #define JSPROP_GETTER 0x10 /* property holds getter function */ #define JSPROP_SETTER 0x20 /* property holds setter function */ #define JSPROP_SHARED 0x40 /* don't allocate a value slot for this property; don't copy the property on set of the same-named property in an object that delegates to a prototype containing this property */ #define JSPROP_INDEX 0x80 /* name is actually (int) index */ #define JSPROP_SHORTID 0x100 /* set in JS_DefineProperty attrs if getters/setters use a shortid */ #define JSFUN_STUB_GSOPS 0x200 /* use JS_PropertyStub getter/setter instead of defaulting to class gsops for property holding function */ #define JSFUN_CONSTRUCTOR 0x400 /* native that can be called as a ctor */ /* * Specify a generic native prototype methods, i.e., methods of a class * prototype that are exposed as static methods taking an extra leading * argument: the generic |this| parameter. * * If you set this flag in a JSFunctionSpec struct's flags initializer, then * that struct must live at least as long as the native static method object * created due to this flag by JS_DefineFunctions or JS_InitClass. Typically * JSFunctionSpec structs are allocated in static arrays. */ #define JSFUN_GENERIC_NATIVE 0x800 #define JSFUN_FLAGS_MASK 0xe00 /* | of all the JSFUN_* flags */ /* * The first call to JS_CallOnce by any thread in a process will call 'func'. * Later calls to JS_CallOnce with the same JSCallOnceType object will be * suppressed. * * Equivalently: each distinct JSCallOnceType object will allow one JS_CallOnce * to invoke its JSInitCallback. */ extern JS_PUBLIC_API(JSBool) JS_CallOnce(JSCallOnceType *once, JSInitCallback func); /* Microseconds since the epoch, midnight, January 1, 1970 UTC. */ extern JS_PUBLIC_API(int64_t) JS_Now(void); /* Don't want to export data, so provide accessors for non-inline jsvals. */ extern JS_PUBLIC_API(jsval) JS_GetNaNValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetNegativeInfinityValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetPositiveInfinityValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetEmptyStringValue(JSContext *cx); extern JS_PUBLIC_API(JSString *) JS_GetEmptyString(JSRuntime *rt); /* * Format is a string of the following characters (spaces are insignificant), * specifying the tabulated type conversions: * * b JSBool Boolean * c uint16_t/jschar ECMA uint16_t, Unicode char * i int32_t ECMA int32_t * u uint32_t ECMA uint32_t * j int32_t Rounded int32_t (coordinate) * d double IEEE double * I double Integral IEEE double * S JSString * Unicode string, accessed by a JSString pointer * W jschar * Unicode character vector, 0-terminated (W for wide) * o JSObject * Object reference * f JSFunction * Function private * v jsval Argument value (no conversion) * * N/A Skip this argument (no vararg) * / N/A End of required arguments * * The variable argument list after format must consist of &b, &c, &s, e.g., * where those variables have the types given above. For the pointer types * char *, JSString *, and JSObject *, the pointed-at memory returned belongs * to the JS runtime, not to the calling native code. The runtime promises * to keep this memory valid so long as argv refers to allocated stack space * (so long as the native function is active). * * Fewer arguments than format specifies may be passed only if there is a / * in format after the last required argument specifier and argc is at least * the number of required arguments. More arguments than format specifies * may be passed without error; it is up to the caller to deal with trailing * unconverted arguments. */ extern JS_PUBLIC_API(JSBool) JS_ConvertArguments(JSContext *cx, unsigned argc, jsval *argv, const char *format, ...); #ifdef va_start extern JS_PUBLIC_API(JSBool) JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *format, va_list ap); #endif extern JS_PUBLIC_API(JSBool) JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_ValueToObject(JSContext *cx, jsval v, JSObject **objp); extern JS_PUBLIC_API(JSFunction *) JS_ValueToFunction(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSFunction *) JS_ValueToConstructor(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToString(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToSource(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSBool) JS_ValueToNumber(JSContext *cx, jsval v, double *dp); namespace js { /* * DO NOT CALL THIS. Use JS::ToNumber */ extern JS_PUBLIC_API(bool) ToNumberSlow(JSContext *cx, JS::Value v, double *dp); /* * DO NOT CALL THIS. Use JS::ToBoolean */ extern JS_PUBLIC_API(bool) ToBooleanSlow(const JS::Value &v); } /* namespace js */ namespace JS { /* ES5 9.3 ToNumber. */ JS_ALWAYS_INLINE bool ToNumber(JSContext *cx, HandleValue v, double *out) { AssertArgumentsAreSane(cx, v); { js::SkipRoot root(cx, &v); js::MaybeCheckStackRoots(cx); } if (v.isNumber()) { *out = v.toNumber(); return true; } return js::ToNumberSlow(cx, v, out); } JS_ALWAYS_INLINE bool ToBoolean(const Value &v) { if (v.isBoolean()) return v.toBoolean(); if (v.isInt32()) return v.toInt32() != 0; if (v.isNullOrUndefined()) return false; if (v.isDouble()) { double d = v.toDouble(); return !mozilla::IsNaN(d) && d != 0; } /* The slow path handles strings and objects. */ return js::ToBooleanSlow(v); } } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_DoubleIsInt32(double d, int32_t *ip); extern JS_PUBLIC_API(int32_t) JS_DoubleToInt32(double d); extern JS_PUBLIC_API(uint32_t) JS_DoubleToUint32(double d); /* * Convert a value to a number, then to an int32_t, according to the ECMA rules * for ToInt32. */ extern JS_PUBLIC_API(JSBool) JS_ValueToECMAInt32(JSContext *cx, jsval v, int32_t *ip); /* * Convert a value to a number, then to an int64_t, according to the WebIDL * rules for ToInt64: http://dev.w3.org/2006/webapi/WebIDL/#es-long-long */ extern JS_PUBLIC_API(JSBool) JS_ValueToInt64(JSContext *cx, jsval v, int64_t *ip); /* * Convert a value to a number, then to an uint64_t, according to the WebIDL * rules for ToUint64: http://dev.w3.org/2006/webapi/WebIDL/#es-unsigned-long-long */ extern JS_PUBLIC_API(JSBool) JS_ValueToUint64(JSContext *cx, jsval v, uint64_t *ip); namespace js { /* DO NOT CALL THIS. Use JS::ToInt16. */ extern JS_PUBLIC_API(bool) ToUint16Slow(JSContext *cx, JS::Handle v, uint16_t *out); /* DO NOT CALL THIS. Use JS::ToInt32. */ extern JS_PUBLIC_API(bool) ToInt32Slow(JSContext *cx, JS::Handle v, int32_t *out); /* DO NOT CALL THIS. Use JS::ToUint32. */ extern JS_PUBLIC_API(bool) ToUint32Slow(JSContext *cx, JS::Handle v, uint32_t *out); /* DO NOT CALL THIS. Use JS::ToInt64. */ extern JS_PUBLIC_API(bool) ToInt64Slow(JSContext *cx, JS::Handle v, int64_t *out); /* DO NOT CALL THIS. Use JS::ToUint64. */ extern JS_PUBLIC_API(bool) ToUint64Slow(JSContext *cx, JS::Handle v, uint64_t *out); } /* namespace js */ namespace JS { JS_ALWAYS_INLINE bool ToUint16(JSContext *cx, JS::Handle v, uint16_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = uint16_t(v.toInt32()); return true; } return js::ToUint16Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToInt32(JSContext *cx, JS::Handle v, int32_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = v.toInt32(); return true; } return js::ToInt32Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToUint32(JSContext *cx, JS::Handle v, uint32_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = uint32_t(v.toInt32()); return true; } return js::ToUint32Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToInt64(JSContext *cx, JS::Handle v, int64_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = int64_t(v.toInt32()); return true; } return js::ToInt64Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToUint64(JSContext *cx, JS::Handle v, uint64_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { /* Account for sign extension of negatives into the longer 64bit space. */ *out = uint64_t(int64_t(v.toInt32())); return true; } return js::ToUint64Slow(cx, v, out); } } /* namespace JS */ /* * Convert a value to a number, then to a uint32_t, according to the ECMA rules * for ToUint32. */ extern JS_PUBLIC_API(JSBool) JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32_t *ip); /* * Convert a value to a number, then to an int32_t if it fits by rounding to * nearest; but failing with an error report if the double is out of range * or unordered. */ extern JS_PUBLIC_API(JSBool) JS_ValueToInt32(JSContext *cx, jsval v, int32_t *ip); /* * ECMA ToUint16, for mapping a jsval to a Unicode point. */ extern JS_PUBLIC_API(JSBool) JS_ValueToUint16(JSContext *cx, jsval v, uint16_t *ip); extern JS_PUBLIC_API(JSBool) JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp); extern JS_PUBLIC_API(JSType) JS_TypeOfValue(JSContext *cx, jsval v); extern JS_PUBLIC_API(const char *) JS_GetTypeName(JSContext *cx, JSType type); extern JS_PUBLIC_API(JSBool) JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); extern JS_PUBLIC_API(JSBool) JS_LooselyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); extern JS_PUBLIC_API(JSBool) JS_SameValue(JSContext *cx, jsval v1, jsval v2, JSBool *same); /* True iff fun is the global eval function. */ extern JS_PUBLIC_API(JSBool) JS_IsBuiltinEvalFunction(JSFunction *fun); /* True iff fun is the Function constructor. */ extern JS_PUBLIC_API(JSBool) JS_IsBuiltinFunctionConstructor(JSFunction *fun); /************************************************************************/ /* * Initialization, locking, contexts, and memory allocation. * * It is important that the first runtime and first context be created in a * single-threaded fashion, otherwise the behavior of the library is undefined. * See: http://developer.mozilla.org/en/docs/Category:JSAPI_Reference */ typedef enum JSUseHelperThreads { JS_NO_HELPER_THREADS, JS_USE_HELPER_THREADS } JSUseHelperThreads; /** * Initialize SpiderMonkey, returning true only if initialization succeeded. * Once this method has succeeded, it is safe to call JS_NewRuntime and other * JSAPI methods. * * This method must be called before any other JSAPI method is used on any * thread. Once it has been used, it is safe to call any JSAPI method, and it * remains safe to do so until JS_ShutDown is correctly called. * * It is currently not possible to initialize SpiderMonkey multiple times (that * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so * again). This restriction may eventually be lifted. */ extern JS_PUBLIC_API(JSBool) JS_Init(void); /** * Destroy free-standing resources allocated by SpiderMonkey, not associated * with any runtime, context, or other structure. * * This method should be called after all other JSAPI data has been properly * cleaned up: every new runtime must have been destroyed, every new context * must have been destroyed, and so on. Calling this method before all other * resources have been destroyed has undefined behavior. * * Failure to call this method, at present, has no adverse effects other than * leaking memory. This may not always be the case; it's recommended that all * embedders call this method when all other JSAPI operations have completed. * * It is currently not possible to initialize SpiderMonkey multiple times (that * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so * again). This restriction may eventually be lifted. */ extern JS_PUBLIC_API(void) JS_ShutDown(void); extern JS_PUBLIC_API(JSRuntime *) JS_NewRuntime(uint32_t maxbytes, JSUseHelperThreads useHelperThreads); extern JS_PUBLIC_API(void) JS_DestroyRuntime(JSRuntime *rt); // These are equivalent to ICU's |UMemAllocFn|, |UMemReallocFn|, and // |UMemFreeFn| types. The first argument (called |context| in the ICU docs) // will always be NULL, and should be ignored. typedef void *(*JS_ICUAllocFn)(const void *, size_t size); typedef void *(*JS_ICUReallocFn)(const void *, void *p, size_t size); typedef void (*JS_ICUFreeFn)(const void *, void *p); // This function can be used to track memory used by ICU. // Do not use it unless you know what you are doing! extern JS_PUBLIC_API(bool) JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn, JS_ICUReallocFn reallocFn, JS_ICUFreeFn freeFn); JS_PUBLIC_API(void *) JS_GetRuntimePrivate(JSRuntime *rt); extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); JS_PUBLIC_API(void) JS_SetRuntimePrivate(JSRuntime *rt, void *data); extern JS_PUBLIC_API(void) JS_BeginRequest(JSContext *cx); extern JS_PUBLIC_API(void) JS_EndRequest(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_IsInRequest(JSRuntime *rt); namespace JS { inline bool IsPoisonedId(jsid iden) { if (JSID_IS_STRING(iden)) return JS::IsPoisonedPtr(JSID_TO_STRING(iden)); if (JSID_IS_OBJECT(iden)) return JS::IsPoisonedPtr(JSID_TO_OBJECT(iden)); return false; } } /* namespace JS */ namespace js { template <> struct GCMethods { static jsid initial() { return JSID_VOID; } static ThingRootKind kind() { return THING_ROOT_ID; } static bool poisoned(jsid id) { return JS::IsPoisonedId(id); } static bool needsPostBarrier(jsid id) { return false; } #ifdef JSGC_GENERATIONAL static void postBarrier(jsid *idp) {} static void relocate(jsid *idp) {} #endif }; } /* namespace js */ class JSAutoRequest { public: JSAutoRequest(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mContext(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; JS_BeginRequest(mContext); } ~JSAutoRequest() { JS_EndRequest(mContext); } protected: JSContext *mContext; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER #if 0 private: static void *operator new(size_t) CPP_THROW_NEW { return 0; }; static void operator delete(void *, size_t) { }; #endif }; class JSAutoCheckRequest { public: JSAutoCheckRequest(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { #if defined JS_THREADSAFE && defined DEBUG mContext = cx; JS_ASSERT(JS_IsInRequest(JS_GetRuntime(cx))); #endif MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~JSAutoCheckRequest() { #if defined JS_THREADSAFE && defined DEBUG JS_ASSERT(JS_IsInRequest(JS_GetRuntime(mContext))); #endif } private: #if defined JS_THREADSAFE && defined DEBUG JSContext *mContext; #endif MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; extern JS_PUBLIC_API(void) JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback, void *data); extern JS_PUBLIC_API(JSContext *) JS_NewContext(JSRuntime *rt, size_t stackChunkSize); extern JS_PUBLIC_API(void) JS_DestroyContext(JSContext *cx); extern JS_PUBLIC_API(void) JS_DestroyContextNoGC(JSContext *cx); extern JS_PUBLIC_API(void *) JS_GetContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetContextPrivate(JSContext *cx, void *data); extern JS_PUBLIC_API(void *) JS_GetSecondContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetSecondContextPrivate(JSContext *cx, void *data); extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); extern JS_PUBLIC_API(JSContext *) JS_ContextIterator(JSRuntime *rt, JSContext **iterp); extern JS_PUBLIC_API(JSVersion) JS_GetVersion(JSContext *cx); // Mutate the version on the compartment. This is generally discouraged, but // necessary to support the version mutation in the js and xpc shell command // set. // // It would be nice to put this in jsfriendapi, but the linkage requirements // of the shells make that impossible. JS_PUBLIC_API(void) JS_SetVersionForCompartment(JSCompartment *compartment, JSVersion version); extern JS_PUBLIC_API(const char *) JS_VersionToString(JSVersion version); extern JS_PUBLIC_API(JSVersion) JS_StringToVersion(const char *string); /* * JS options are orthogonal to version, and may be freely composed with one * another as well as with version. * * JSOPTION_VAROBJFIX is recommended -- see the comments associated with the * prototypes for JS_ExecuteScript, JS_EvaluateScript, etc. */ #define JSOPTION_EXTRA_WARNINGS JS_BIT(0) /* warn on dubious practices */ #define JSOPTION_WERROR JS_BIT(1) /* convert warning to error */ #define JSOPTION_VAROBJFIX JS_BIT(2) /* make JS_EvaluateScript use the last object on its 'obj' param's scope chain as the ECMA 'variables object' */ #define JSOPTION_PRIVATE_IS_NSISUPPORTS \ JS_BIT(3) /* context private data points to an nsISupports subclass */ #define JSOPTION_COMPILE_N_GO JS_BIT(4) /* caller of JS_Compile*Script promises to execute compiled script once only; enables compile-time scope chain resolution of consts. */ /* JS_BIT(5) is currently unused. */ /* JS_BIT(6) is currently unused. */ /* JS_BIT(7) is currently unused. */ #define JSOPTION_DONT_REPORT_UNCAUGHT \ JS_BIT(8) /* When returning from the outermost API call, prevent uncaught exceptions from being converted to error reports */ /* JS_BIT(9) is currently unused. */ /* JS_BIT(10) is currently unused. */ /* JS_BIT(11) is currently unused. */ #define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12) /* A promise to the compiler that a null rval out-param will be passed to each call to JS_ExecuteScript. */ #define JSOPTION_UNROOTED_GLOBAL JS_BIT(13) /* The GC will not root the contexts' default compartment object, leaving that up to the embedding. */ #define JSOPTION_BASELINE JS_BIT(14) /* Baseline compiler. */ #define JSOPTION_TYPE_INFERENCE JS_BIT(16) /* Perform type inference. */ #define JSOPTION_STRICT_MODE JS_BIT(17) /* Provides a way to force strict mode for all code without requiring "use strict" annotations. */ #define JSOPTION_ION JS_BIT(18) /* IonMonkey */ #define JSOPTION_ASMJS JS_BIT(19) /* optimizingasm.js compiler */ #define JSOPTION_MASK JS_BITMASK(20) extern JS_PUBLIC_API(uint32_t) JS_GetOptions(JSContext *cx); extern JS_PUBLIC_API(uint32_t) JS_SetOptions(JSContext *cx, uint32_t options); extern JS_PUBLIC_API(uint32_t) JS_ToggleOptions(JSContext *cx, uint32_t options); extern JS_PUBLIC_API(void) JS_SetJitHardening(JSRuntime *rt, JSBool enabled); extern JS_PUBLIC_API(const char *) JS_GetImplementationVersion(void); extern JS_PUBLIC_API(void) JS_SetDestroyCompartmentCallback(JSRuntime *rt, JSDestroyCompartmentCallback callback); extern JS_PUBLIC_API(void) JS_SetCompartmentNameCallback(JSRuntime *rt, JSCompartmentNameCallback callback); extern JS_PUBLIC_API(JSWrapObjectCallback) JS_SetWrapObjectCallbacks(JSRuntime *rt, JSWrapObjectCallback callback, JSSameCompartmentWrapObjectCallback sccallback, JSPreWrapCallback precallback); extern JS_PUBLIC_API(void) JS_SetCompartmentPrivate(JSCompartment *compartment, void *data); extern JS_PUBLIC_API(void *) JS_GetCompartmentPrivate(JSCompartment *compartment); extern JS_PUBLIC_API(JSBool) JS_WrapObject(JSContext *cx, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_WrapValue(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_WrapId(JSContext *cx, jsid *idp); extern JS_PUBLIC_API(JSObject *) JS_TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target); extern JS_FRIEND_API(JSObject *) js_TransplantObjectWithWrapper(JSContext *cx, JS::HandleObject origobj, JS::HandleObject origwrapper, JS::HandleObject targetobj, JS::HandleObject targetwrapper); extern JS_PUBLIC_API(JSBool) JS_RefreshCrossCompartmentWrappers(JSContext *cx, JSObject *ob); /* * At any time, a JSContext has a current (possibly-NULL) compartment. * Compartments are described in: * * developer.mozilla.org/en-US/docs/SpiderMonkey/SpiderMonkey_compartments * * The current compartment of a context may be changed. The preferred way to do * this is with JSAutoCompartment: * * void foo(JSContext *cx, JSObject *obj) { * // in some compartment 'c' * { * JSAutoCompartment ac(cx, obj); // constructor enters * // in the compartment of 'obj' * } // destructor leaves * // back in compartment 'c' * } * * For more complicated uses that don't neatly fit in a C++ stack frame, the * compartment can entered and left using separate function calls: * * void foo(JSContext *cx, JSObject *obj) { * // in 'oldCompartment' * JSCompartment *oldCompartment = JS_EnterCompartment(cx, obj); * // in the compartment of 'obj' * JS_LeaveCompartment(cx, oldCompartment); * // back in 'oldCompartment' * } * * Note: these calls must still execute in a LIFO manner w.r.t all other * enter/leave calls on the context. Furthermore, only the return value of a * JS_EnterCompartment call may be passed as the 'oldCompartment' argument of * the corresponding JS_LeaveCompartment call. */ class JS_PUBLIC_API(JSAutoCompartment) { JSContext *cx_; JSCompartment *oldCompartment_; public: JSAutoCompartment(JSContext *cx, JSObject *target); JSAutoCompartment(JSContext *cx, JSScript *target); ~JSAutoCompartment(); }; /* NB: This API is infallible; a NULL return value does not indicate error. */ extern JS_PUBLIC_API(JSCompartment *) JS_EnterCompartment(JSContext *cx, JSObject *target); extern JS_PUBLIC_API(void) JS_LeaveCompartment(JSContext *cx, JSCompartment *oldCompartment); typedef void (*JSIterateCompartmentCallback)(JSRuntime *rt, void *data, JSCompartment *compartment); /* * This function calls |compartmentCallback| on every compartment. Beware that * there is no guarantee that the compartment will survive after the callback * returns. */ extern JS_PUBLIC_API(void) JS_IterateCompartments(JSRuntime *rt, void *data, JSIterateCompartmentCallback compartmentCallback); /* * Initialize standard JS class constructors, prototypes, and any top-level * functions and constants associated with the standard classes (e.g. isNaN * for Number). * * NB: This sets cx's global object to obj if it was null. */ extern JS_PUBLIC_API(JSBool) JS_InitStandardClasses(JSContext *cx, JSObject *obj); /* * Resolve id, which must contain either a string or an int, to a standard * class name in obj if possible, defining the class's constructor and/or * prototype and storing true in *resolved. If id does not name a standard * class or a top-level property induced by initializing a standard class, * store false in *resolved and just return true. Return false on error, * as usual for JSBool result-typed API entry points. * * This API can be called directly from a global object class's resolve op, * to define standard classes lazily. The class's enumerate op should call * JS_EnumerateStandardClasses(cx, obj), to define eagerly during for..in * loops any classes not yet resolved lazily. */ extern JS_PUBLIC_API(JSBool) JS_ResolveStandardClass(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool *resolved); extern JS_PUBLIC_API(JSBool) JS_EnumerateStandardClasses(JSContext *cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSBool) JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_GetClassPrototype(JSContext *cx, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSProtoKey) JS_IdentifyClassPrototype(JSContext *cx, JSObject *obj); /* * Returns the original value of |Function.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetFunctionPrototype(JSContext *cx, JSObject *forObj); /* * Returns the original value of |Object.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetObjectPrototype(JSContext *cx, JSObject *forObj); /* * Returns the original value of |Array.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetArrayPrototype(JSContext *cx, JSObject *forObj); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_IsGlobalObject(JSObject *obj); /* * May return NULL, if |c| never had a global (e.g. the atoms compartment), or * if |c|'s global has been collected. */ extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForCompartmentOrNull(JSContext *cx, JSCompartment *c); namespace JS { extern JS_PUBLIC_API(JSObject *) CurrentGlobalOrNull(JSContext *cx); } /* * This method returns the global corresponding to the most recent scripted * frame, which may not match the cx's current compartment. This is extremely * dangerous, because it can bypass compartment security invariants in subtle * ways. To use it safely, the caller must perform a subsequent security * check. There is currently only one consumer of this function in Gecko, and * it should probably stay that way. If you'd like to use it, please consult * the XPConnect module owner first. */ extern JS_PUBLIC_API(JSObject *) JS_GetScriptedGlobal(JSContext *cx); /* * Initialize the 'Reflect' object on a global object. */ extern JS_PUBLIC_API(JSObject *) JS_InitReflect(JSContext *cx, JSObject *global); #ifdef JS_HAS_CTYPES /* * Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes' * object will be sealed. */ extern JS_PUBLIC_API(JSBool) JS_InitCTypesClass(JSContext *cx, JSObject *global); /* * Convert a unicode string 'source' of length 'slen' to the platform native * charset, returning a null-terminated string allocated with JS_malloc. On * failure, this function should report an error. */ typedef char * (* JSCTypesUnicodeToNativeFun)(JSContext *cx, const jschar *source, size_t slen); /* * Set of function pointers that ctypes can use for various internal functions. * See JS_SetCTypesCallbacks below. Providing NULL for a function is safe, * and will result in the applicable ctypes functionality not being available. */ struct JSCTypesCallbacks { JSCTypesUnicodeToNativeFun unicodeToNative; }; typedef struct JSCTypesCallbacks JSCTypesCallbacks; /* * Set the callbacks on the provided 'ctypesObj' object. 'callbacks' should be a * pointer to static data that exists for the lifetime of 'ctypesObj', but it * may safely be altered after calling this function and without having * to call this function again. */ extern JS_PUBLIC_API(void) JS_SetCTypesCallbacks(JSObject *ctypesObj, JSCTypesCallbacks *callbacks); #endif typedef JSBool (* JSEnumerateDiagnosticMemoryCallback)(void *ptr, size_t length); /* * Enumerate memory regions that contain diagnostic information * intended to be included in crash report minidumps. */ extern JS_PUBLIC_API(void) JS_EnumerateDiagnosticMemoryRegions(JSEnumerateDiagnosticMemoryCallback callback); extern JS_PUBLIC_API(void *) JS_malloc(JSContext *cx, size_t nbytes); extern JS_PUBLIC_API(void *) JS_realloc(JSContext *cx, void *p, size_t nbytes); /* * A wrapper for js_free(p) that may delay js_free(p) invocation as a * performance optimization. * cx may be NULL. */ extern JS_PUBLIC_API(void) JS_free(JSContext *cx, void *p); /* * A wrapper for js_free(p) that may delay js_free(p) invocation as a * performance optimization as specified by the given JSFreeOp instance. */ extern JS_PUBLIC_API(void) JS_freeop(JSFreeOp *fop, void *p); extern JS_PUBLIC_API(JSFreeOp *) JS_GetDefaultFreeOp(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_updateMallocCounter(JSContext *cx, size_t nbytes); extern JS_PUBLIC_API(char *) JS_strdup(JSContext *cx, const char *s); /* Duplicate a string. Does not report an error on failure. */ extern JS_PUBLIC_API(char *) JS_strdup(JSRuntime *rt, const char *s); /* * A GC root is a pointer to a jsval, JSObject * or JSString * that itself * points into the GC heap. JS_AddValueRoot takes a pointer to a jsval and * JS_AddGCThingRoot takes a pointer to a JSObject * or JString *. * * Note that, since JS_Add*Root stores the address of a variable (of type * jsval, JSString *, or JSObject *), that variable must live until * JS_Remove*Root is called to remove that variable. For example, after: * * void some_function() { * jsval v; * JS_AddNamedValueRoot(cx, &v, "name"); * * the caller must perform * * JS_RemoveValueRoot(cx, &v); * * before some_function() returns. * * Also, use JS_AddNamed*Root(cx, &structPtr->memberObj, "structPtr->memberObj") * in preference to JS_Add*Root(cx, &structPtr->memberObj), in order to identify * roots by their source callsites. This way, you can find the callsite while * debugging if you should fail to do JS_Remove*Root(cx, &structPtr->memberObj) * before freeing structPtr's memory. */ extern JS_PUBLIC_API(JSBool) JS_AddValueRoot(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_AddStringRoot(JSContext *cx, JSString **rp); extern JS_PUBLIC_API(JSBool) JS_AddObjectRoot(JSContext *cx, JSObject **rp); #ifdef NAME_ALL_GC_ROOTS #define JS_DEFINE_TO_TOKEN(def) #def #define JS_DEFINE_TO_STRING(def) JS_DEFINE_TO_TOKEN(def) #define JS_AddValueRoot(cx,vp) JS_AddNamedValueRoot((cx), (vp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #define JS_AddStringRoot(cx,rp) JS_AddNamedStringRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #define JS_AddObjectRoot(cx,rp) JS_AddNamedObjectRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #endif extern JS_PUBLIC_API(JSBool) JS_AddNamedValueRoot(JSContext *cx, jsval *vp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedValueRootRT(JSRuntime *rt, jsval *vp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedStringRoot(JSContext *cx, JSString **rp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedObjectRoot(JSContext *cx, JSObject **rp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedScriptRoot(JSContext *cx, JSScript **rp, const char *name); extern JS_PUBLIC_API(void) JS_RemoveValueRoot(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(void) JS_RemoveStringRoot(JSContext *cx, JSString **rp); extern JS_PUBLIC_API(void) JS_RemoveObjectRoot(JSContext *cx, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRoot(JSContext *cx, JSScript **rp); extern JS_PUBLIC_API(void) JS_RemoveValueRootRT(JSRuntime *rt, jsval *vp); extern JS_PUBLIC_API(void) JS_RemoveStringRootRT(JSRuntime *rt, JSString **rp); extern JS_PUBLIC_API(void) JS_RemoveObjectRootRT(JSRuntime *rt, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRootRT(JSRuntime *rt, JSScript **rp); /* TODO: remove these APIs */ extern JS_FRIEND_API(void) js_RemoveRoot(JSRuntime *rt, void *rp); /* * C-compatible version of the Anchor class. It should be called after the last * use of the variable it protects. */ extern JS_NEVER_INLINE JS_PUBLIC_API(void) JS_AnchorPtr(void *p); /* * Register externally maintained GC roots. * * traceOp: the trace operation. For each root the implementation should call * JS_CallTracer whenever the root contains a traceable thing. * data: the data argument to pass to each invocation of traceOp. */ extern JS_PUBLIC_API(JSBool) JS_AddExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); /* Undo a call to JS_AddExtraGCRootsTracer. */ extern JS_PUBLIC_API(void) JS_RemoveExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); /* * JS_CallTracer API and related macros for implementors of JSTraceOp, to * enumerate all references to traceable things reachable via a property or * other strong ref identified for debugging purposes by name or index or * a naming callback. * * See the JSTraceOp typedef. */ /* * Use the following macros to check if a particular jsval is a traceable * thing and to extract the thing and its kind to pass to JS_CallTracer. */ static JS_ALWAYS_INLINE JSBool JSVAL_IS_TRACEABLE(jsval v) { return JSVAL_IS_TRACEABLE_IMPL(JSVAL_TO_IMPL(v)); } static JS_ALWAYS_INLINE void * JSVAL_TO_TRACEABLE(jsval v) { return JSVAL_TO_GCTHING(v); } static JS_ALWAYS_INLINE JSGCTraceKind JSVAL_TRACE_KIND(jsval v) { JS_ASSERT(JSVAL_IS_GCTHING(v)); return (JSGCTraceKind) JSVAL_TRACE_KIND_IMPL(JSVAL_TO_IMPL(v)); } /* * Tracer callback, called for each traceable thing directly referenced by a * particular object or runtime structure. It is the callback responsibility * to ensure the traversal of the full object graph via calling eventually * JS_TraceChildren on the passed thing. In this case the callback must be * prepared to deal with cycles in the traversal graph. * * kind argument is one of JSTRACE_OBJECT, JSTRACE_STRING or a tag denoting * internal implementation-specific traversal kind. In the latter case the only * operations on thing that the callback can do is to call JS_TraceChildren or * JS_GetTraceThingInfo. * * If eagerlyTraceWeakMaps is true, when we trace a WeakMap visit all * of its mappings. This should be used in cases where the tracer * wants to use the existing liveness of entries. */ typedef void (* JSTraceCallback)(JSTracer *trc, void **thingp, JSGCTraceKind kind); enum WeakMapTraceKind { DoNotTraceWeakMaps = 0, TraceWeakMapValues = 1, TraceWeakMapKeysValues = 2 }; struct JSTracer { JSRuntime *runtime; JSTraceCallback callback; JSTraceNamePrinter debugPrinter; const void *debugPrintArg; size_t debugPrintIndex; WeakMapTraceKind eagerlyTraceWeakMaps; #ifdef JS_GC_ZEAL void *realLocation; #endif }; /* * Set debugging information about a reference to a traceable thing to prepare * for the following call to JS_CallTracer. * * When printer is null, arg must be const char * or char * C string naming * the reference and index must be either (size_t)-1 indicating that the name * alone describes the reference or it must be an index into some array vector * that stores the reference. * * When printer callback is not null, the arg and index arguments are * available to the callback as debugPrintArg and debugPrintIndex fields * of JSTracer. * * The storage for name or callback's arguments needs to live only until * the following call to JS_CallTracer returns. */ # define JS_SET_TRACING_DETAILS(trc, printer, arg, index) \ JS_BEGIN_MACRO \ (trc)->debugPrinter = (printer); \ (trc)->debugPrintArg = (arg); \ (trc)->debugPrintIndex = (index); \ JS_END_MACRO /* * Sets the real location for a marked reference, when passing the address * directly is not feasable. * * FIXME: This is currently overcomplicated by our need to nest calls for Values * stored as keys in hash tables, but will get simplified once we can rekey * in-place. */ #ifdef JS_GC_ZEAL # define JS_SET_TRACING_LOCATION(trc, location) \ JS_BEGIN_MACRO \ if (!(trc)->realLocation || !(location)) \ (trc)->realLocation = (location); \ JS_END_MACRO # define JS_UNSET_TRACING_LOCATION(trc) \ JS_BEGIN_MACRO \ (trc)->realLocation = NULL; \ JS_END_MACRO #else # define JS_SET_TRACING_LOCATION(trc, location) \ JS_BEGIN_MACRO \ JS_END_MACRO # define JS_UNSET_TRACING_LOCATION(trc) \ JS_BEGIN_MACRO \ JS_END_MACRO #endif /* * Convenience macro to describe the argument of JS_CallTracer using C string * and index. */ # define JS_SET_TRACING_INDEX(trc, name, index) \ JS_SET_TRACING_DETAILS(trc, NULL, name, index) /* * Convenience macro to describe the argument of JS_CallTracer using C string. */ # define JS_SET_TRACING_NAME(trc, name) \ JS_SET_TRACING_DETAILS(trc, NULL, name, (size_t)-1) /* * The JS_Call*Tracer family of functions traces the given GC thing reference. * This performs the tracing action configured on the given JSTracer: * typically calling the JSTracer::callback or marking the thing as live. * * The argument to JS_Call*Tracer is an in-out param: when the function * returns, the garbage collector might have moved the GC thing. In this case, * the reference passed to JS_Call*Tracer will be updated to the object's new * location. Callers of this method are responsible for updating any state * that is dependent on the object's address. For example, if the object's * address is used as a key in a hashtable, then the object must be removed * and re-inserted with the correct hash. */ extern JS_PUBLIC_API(void) JS_CallValueTracer(JSTracer *trc, JS::Value *valuep, const char *name); extern JS_PUBLIC_API(void) JS_CallIdTracer(JSTracer *trc, jsid *idp, const char *name); extern JS_PUBLIC_API(void) JS_CallObjectTracer(JSTracer *trc, JSObject **objp, const char *name); extern JS_PUBLIC_API(void) JS_CallStringTracer(JSTracer *trc, JSString **strp, const char *name); extern JS_PUBLIC_API(void) JS_CallScriptTracer(JSTracer *trc, JSScript **scriptp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapValueTracer(JSTracer *trc, JS::Heap *valuep, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapIdTracer(JSTracer *trc, JS::Heap *idp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapObjectTracer(JSTracer *trc, JS::Heap *objp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapStringTracer(JSTracer *trc, JS::Heap *strp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapScriptTracer(JSTracer *trc, JS::Heap *scriptp, const char *name); template inline void JS_CallHashSetObjectTracer(JSTracer *trc, HashSetEnum &e, JSObject *const &key, const char *name) { JSObject *updated = key; JS_SET_TRACING_LOCATION(trc, reinterpret_cast(&const_cast(key))); JS_CallObjectTracer(trc, &updated, name); if (updated != key) e.rekeyFront(key, updated); } /* * Trace an object that is known to always be tenured. No post barriers are * required in this case. */ extern JS_PUBLIC_API(void) JS_CallTenuredObjectTracer(JSTracer *trc, JS::TenuredHeap *objp, const char *name); /* * API for JSTraceCallback implementations. */ extern JS_PUBLIC_API(void) JS_TracerInit(JSTracer *trc, JSRuntime *rt, JSTraceCallback callback); extern JS_PUBLIC_API(void) JS_TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind); extern JS_PUBLIC_API(void) JS_TraceRuntime(JSTracer *trc); extern JS_PUBLIC_API(void) JS_GetTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing, JSGCTraceKind kind, JSBool includeDetails); extern JS_PUBLIC_API(const char *) JS_GetTraceEdgeName(JSTracer *trc, char *buffer, int bufferSize); #ifdef DEBUG /* * DEBUG-only method to dump the object graph of heap-allocated things. * * fp: file for the dump output. * start: when non-null, dump only things reachable from start * thing. Otherwise dump all things reachable from the * runtime roots. * startKind: trace kind of start if start is not null. Must be * JSTRACE_OBJECT when start is null. * thingToFind: dump only paths in the object graph leading to thingToFind * when non-null. * maxDepth: the upper bound on the number of edges to descend from the * graph roots. * thingToIgnore: thing to ignore during the graph traversal when non-null. */ extern JS_PUBLIC_API(JSBool) JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind kind, void *thingToFind, size_t maxDepth, void *thingToIgnore); #endif /* * Garbage collector API. */ extern JS_PUBLIC_API(void) JS_GC(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_MaybeGC(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetGCCallback(JSRuntime *rt, JSGCCallback cb, void *data); extern JS_PUBLIC_API(void) JS_SetFinalizeCallback(JSRuntime *rt, JSFinalizeCallback cb); extern JS_PUBLIC_API(JSBool) JS_IsGCMarkingTracer(JSTracer *trc); /* * JS_IsAboutToBeFinalized checks if the given object is going to be finalized * at the end of the current GC. When called outside of the context of a GC, * this function will return false. Typically this function is used on weak * references, where the reference should be nulled out or destroyed if the * given object is about to be finalized. * * The argument to JS_IsAboutToBeFinalized is an in-out param: when the * function returns false, the object being referenced is still alive, but the * garbage collector might have moved it. In this case, the reference passed * to JS_IsAboutToBeFinalized will be updated to the object's new location. * Callers of this method are responsible for updating any state that is * dependent on the object's address. For example, if the object's address is * used as a key in a hashtable, then the object must be removed and * re-inserted with the correct hash. */ extern JS_PUBLIC_API(JSBool) JS_IsAboutToBeFinalized(JS::Heap *objp); extern JS_PUBLIC_API(JSBool) JS_IsAboutToBeFinalizedUnbarriered(JSObject **objp); typedef enum JSGCParamKey { /* Maximum nominal heap before last ditch GC. */ JSGC_MAX_BYTES = 0, /* Number of JS_malloc bytes before last ditch GC. */ JSGC_MAX_MALLOC_BYTES = 1, /* Amount of bytes allocated by the GC. */ JSGC_BYTES = 3, /* Number of times when GC was invoked. */ JSGC_NUMBER = 4, /* Max size of the code cache in bytes. */ JSGC_MAX_CODE_CACHE_BYTES = 5, /* Select GC mode. */ JSGC_MODE = 6, /* Number of cached empty GC chunks. */ JSGC_UNUSED_CHUNKS = 7, /* Total number of allocated GC chunks. */ JSGC_TOTAL_CHUNKS = 8, /* Max milliseconds to spend in an incremental GC slice. */ JSGC_SLICE_TIME_BUDGET = 9, /* Maximum size the GC mark stack can grow to. */ JSGC_MARK_STACK_LIMIT = 10, /* * GCs less than this far apart in time will be considered 'high-frequency GCs'. * See setGCLastBytes in jsgc.cpp. */ JSGC_HIGH_FREQUENCY_TIME_LIMIT = 11, /* Start of dynamic heap growth. */ JSGC_HIGH_FREQUENCY_LOW_LIMIT = 12, /* End of dynamic heap growth. */ JSGC_HIGH_FREQUENCY_HIGH_LIMIT = 13, /* Upper bound of heap growth. */ JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX = 14, /* Lower bound of heap growth. */ JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN = 15, /* Heap growth for low frequency GCs. */ JSGC_LOW_FREQUENCY_HEAP_GROWTH = 16, /* * If false, the heap growth factor is fixed at 3. If true, it is determined * based on whether GCs are high- or low- frequency. */ JSGC_DYNAMIC_HEAP_GROWTH = 17, /* If true, high-frequency GCs will use a longer mark slice. */ JSGC_DYNAMIC_MARK_SLICE = 18, /* Number of megabytes of analysis data to allocate before purging. */ JSGC_ANALYSIS_PURGE_TRIGGER = 19, /* Lower limit after which we limit the heap growth. */ JSGC_ALLOCATION_THRESHOLD = 20, /* * We decommit memory lazily. If more than this number of megabytes is * available to be decommitted, then JS_MaybeGC will trigger a shrinking GC * to decommit it. */ JSGC_DECOMMIT_THRESHOLD = 21 } JSGCParamKey; typedef enum JSGCMode { /* Perform only global GCs. */ JSGC_MODE_GLOBAL = 0, /* Perform per-compartment GCs until too much garbage has accumulated. */ JSGC_MODE_COMPARTMENT = 1, /* * Collect in short time slices rather than all at once. Implies * JSGC_MODE_COMPARTMENT. */ JSGC_MODE_INCREMENTAL = 2 } JSGCMode; extern JS_PUBLIC_API(void) JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32_t value); extern JS_PUBLIC_API(uint32_t) JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key); extern JS_PUBLIC_API(void) JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32_t value); extern JS_PUBLIC_API(uint32_t) JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key); /* * Create a new JSString whose chars member refers to external memory, i.e., * memory requiring application-specific finalization. */ extern JS_PUBLIC_API(JSString *) JS_NewExternalString(JSContext *cx, const jschar *chars, size_t length, const JSStringFinalizer *fin); /* * Return whether 'str' was created with JS_NewExternalString or * JS_NewExternalStringWithClosure. */ extern JS_PUBLIC_API(JSBool) JS_IsExternalString(JSString *str); /* * Return the 'closure' arg passed to JS_NewExternalStringWithClosure or NULL * if the external string was created via JS_NewExternalString. */ extern JS_PUBLIC_API(const JSStringFinalizer *) JS_GetExternalStringFinalizer(JSString *str); /* * Set the size of the native stack that should not be exceed. To disable * stack size checking pass 0. */ extern JS_PUBLIC_API(void) JS_SetNativeStackQuota(JSRuntime *cx, size_t stackSize); /************************************************************************/ /* * Classes, objects, and properties. */ typedef void (*JSClassInternal)(); struct JSClass { const char *name; uint32_t flags; /* Mandatory function pointer members. */ JSPropertyOp addProperty; JSDeletePropertyOp delProperty; JSPropertyOp getProperty; JSStrictPropertyOp setProperty; JSEnumerateOp enumerate; JSResolveOp resolve; JSConvertOp convert; /* Optional members (may be null). */ JSFinalizeOp finalize; JSCheckAccessOp checkAccess; JSNative call; JSHasInstanceOp hasInstance; JSNative construct; JSTraceOp trace; void *reserved[40]; }; #define JSCLASS_HAS_PRIVATE (1<<0) /* objects have private slot */ #define JSCLASS_NEW_ENUMERATE (1<<1) /* has JSNewEnumerateOp hook */ #define JSCLASS_NEW_RESOLVE (1<<2) /* has JSNewResolveOp hook */ #define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) /* private is (nsISupports *) */ #define JSCLASS_IS_DOMJSCLASS (1<<4) /* objects are DOM */ #define JSCLASS_IMPLEMENTS_BARRIERS (1<<5) /* Correctly implements GC read and write barriers */ #define JSCLASS_EMULATES_UNDEFINED (1<<6) /* objects of this class act like the value undefined, in some contexts */ #define JSCLASS_USERBIT1 (1<<7) /* Reserved for embeddings. */ /* * To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise-or * JSCLASS_HAS_RESERVED_SLOTS(n) into the initializer for JSClass.flags, where * n is a constant in [1, 255]. Reserved slots are indexed from 0 to n-1. */ #define JSCLASS_RESERVED_SLOTS_SHIFT 8 /* room for 8 flags below */ #define JSCLASS_RESERVED_SLOTS_WIDTH 8 /* and 16 above this field */ #define JSCLASS_RESERVED_SLOTS_MASK JS_BITMASK(JSCLASS_RESERVED_SLOTS_WIDTH) #define JSCLASS_HAS_RESERVED_SLOTS(n) (((n) & JSCLASS_RESERVED_SLOTS_MASK) \ << JSCLASS_RESERVED_SLOTS_SHIFT) #define JSCLASS_RESERVED_SLOTS(clasp) (((clasp)->flags \ >> JSCLASS_RESERVED_SLOTS_SHIFT) \ & JSCLASS_RESERVED_SLOTS_MASK) #define JSCLASS_HIGH_FLAGS_SHIFT (JSCLASS_RESERVED_SLOTS_SHIFT + \ JSCLASS_RESERVED_SLOTS_WIDTH) #define JSCLASS_IS_ANONYMOUS (1<<(JSCLASS_HIGH_FLAGS_SHIFT+0)) #define JSCLASS_IS_GLOBAL (1<<(JSCLASS_HIGH_FLAGS_SHIFT+1)) #define JSCLASS_INTERNAL_FLAG2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2)) #define JSCLASS_INTERNAL_FLAG3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+3)) /* Indicate whether the proto or ctor should be frozen. */ #define JSCLASS_FREEZE_PROTO (1<<(JSCLASS_HIGH_FLAGS_SHIFT+4)) #define JSCLASS_FREEZE_CTOR (1<<(JSCLASS_HIGH_FLAGS_SHIFT+5)) /* Reserved for embeddings. */ #define JSCLASS_USERBIT2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+6)) #define JSCLASS_USERBIT3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+7)) #define JSCLASS_BACKGROUND_FINALIZE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+8)) /* * Bits 26 through 31 are reserved for the CACHED_PROTO_KEY mechanism, see * below. */ /* Global flags. */ #define JSGLOBAL_FLAGS_CLEARED 0x1 /* * ECMA-262 requires that most constructors used internally create objects * with "the original Foo.prototype value" as their [[Prototype]] (__proto__) * member initial value. The "original ... value" verbiage is there because * in ECMA-262, global properties naming class objects are read/write and * deleteable, for the most part. * * Implementing this efficiently requires that global objects have classes * with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS was * prevously allowed, but is now an ES5 violation and thus unsupported. */ #define JSCLASS_GLOBAL_SLOT_COUNT (JSProto_LIMIT * 3 + 25) #define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \ (JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n))) #define JSCLASS_GLOBAL_FLAGS \ JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(0) #define JSCLASS_HAS_GLOBAL_FLAG_AND_SLOTS(clasp) \ (((clasp)->flags & JSCLASS_IS_GLOBAL) \ && JSCLASS_RESERVED_SLOTS(clasp) >= JSCLASS_GLOBAL_SLOT_COUNT) /* Fast access to the original value of each standard class's prototype. */ #define JSCLASS_CACHED_PROTO_SHIFT (JSCLASS_HIGH_FLAGS_SHIFT + 10) #define JSCLASS_CACHED_PROTO_WIDTH 6 #define JSCLASS_CACHED_PROTO_MASK JS_BITMASK(JSCLASS_CACHED_PROTO_WIDTH) #define JSCLASS_HAS_CACHED_PROTO(key) (uint32_t(key) << JSCLASS_CACHED_PROTO_SHIFT) #define JSCLASS_CACHED_PROTO_KEY(clasp) ((JSProtoKey) \ (((clasp)->flags \ >> JSCLASS_CACHED_PROTO_SHIFT) \ & JSCLASS_CACHED_PROTO_MASK)) /* Initializer for unused members of statically initialized JSClass structs. */ #define JSCLASS_NO_INTERNAL_MEMBERS {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} #define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,JSCLASS_NO_INTERNAL_MEMBERS extern JS_PUBLIC_API(int) JS_IdArrayLength(JSContext *cx, JSIdArray *ida); extern JS_PUBLIC_API(jsid) JS_IdArrayGet(JSContext *cx, JSIdArray *ida, int index); extern JS_PUBLIC_API(void) JS_DestroyIdArray(JSContext *cx, JSIdArray *ida); namespace JS { class AutoIdArray : private AutoGCRooter { public: AutoIdArray(JSContext *cx, JSIdArray *ida MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, IDARRAY), context(cx), idArray(ida) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~AutoIdArray() { if (idArray) JS_DestroyIdArray(context, idArray); } bool operator!() { return !idArray; } jsid operator[](size_t i) const { JS_ASSERT(idArray); JS_ASSERT(i < length()); return JS_IdArrayGet(context, idArray, i); } size_t length() const { return JS_IdArrayLength(context, idArray); } friend void AutoGCRooter::trace(JSTracer *trc); JSIdArray *steal() { JSIdArray *copy = idArray; idArray = NULL; return copy; } protected: inline void trace(JSTracer *trc); private: JSContext *context; JSIdArray *idArray; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER /* No copy or assignment semantics. */ AutoIdArray(AutoIdArray &ida) MOZ_DELETE; void operator=(AutoIdArray &ida) MOZ_DELETE; }; } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_ValueToId(JSContext *cx, jsval v, jsid *idp); extern JS_PUBLIC_API(JSBool) JS_IdToValue(JSContext *cx, jsid id, jsval *vp); /* * JSNewResolveOp flag bits. */ #define JSRESOLVE_ASSIGNING 0x01 /* resolve on the left of assignment */ /* * Invoke the [[DefaultValue]] hook (see ES5 8.6.2) with the provided hint on * the specified object, computing a primitive default value for the object. * The hint must be JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_VOID (no hint). On * success the resulting value is stored in *vp. */ extern JS_PUBLIC_API(JSBool) JS_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_PropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_StrictPropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool strict, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool *succeeded); extern JS_PUBLIC_API(JSBool) JS_EnumerateStub(JSContext *cx, JS::Handle obj); extern JS_PUBLIC_API(JSBool) JS_ResolveStub(JSContext *cx, JS::Handle obj, JS::Handle id); extern JS_PUBLIC_API(JSBool) JS_ConvertStub(JSContext *cx, JS::Handle obj, JSType type, JS::MutableHandle vp); struct JSConstDoubleSpec { double dval; const char *name; uint8_t flags; uint8_t spare[3]; }; typedef struct JSJitInfo JSJitInfo; /* * Wrappers to replace {Strict,}PropertyOp for JSPropertySpecs. This will allow * us to pass one JSJitInfo per function with the property spec, without * additional field overhead. */ typedef struct JSStrictPropertyOpWrapper { JSStrictPropertyOp op; const JSJitInfo *info; } JSStrictPropertyOpWrapper; typedef struct JSPropertyOpWrapper { JSPropertyOp op; const JSJitInfo *info; } JSPropertyOpWrapper; /* * Wrapper to do as above, but for JSNatives for JSFunctionSpecs. */ typedef struct JSNativeWrapper { JSNative op; const JSJitInfo *info; } JSNativeWrapper; /* * Macro static initializers which make it easy to pass no JSJitInfo as part of a * JSPropertySpec or JSFunctionSpec. */ #define JSOP_WRAPPER(op) {op, NULL} #define JSOP_NULLWRAPPER JSOP_WRAPPER(NULL) /* * To define an array element rather than a named property member, cast the * element's index to (const char *) and initialize name with it, and set the * JSPROP_INDEX bit in flags. */ struct JSPropertySpec { const char *name; int8_t tinyid; uint8_t flags; JSPropertyOpWrapper getter; JSStrictPropertyOpWrapper setter; }; namespace JS { namespace detail { /* NEVER DEFINED, DON'T USE. For use by JS_CAST_NATIVE_TO only. */ inline int CheckIsNative(JSNative native); } // namespace detail } // namespace JS #define JS_CAST_NATIVE_TO(v, To) \ (static_cast(sizeof(JS::detail::CheckIsNative(v))), \ reinterpret_cast(v)) /* * JSPropertySpec uses JSAPI JSPropertyOp and JSStrictPropertyOp in function * signatures, but with JSPROP_NATIVE_ACCESSORS the actual values must be * JSNatives. To avoid widespread casting, have JS_PSG and JS_PSGS perform * type-safe casts. */ #define JS_PSG(name, getter, flags) \ {name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(getter, JSPropertyOp)), \ JSOP_NULLWRAPPER} #define JS_PSGS(name, getter, setter, flags) \ {name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(getter, JSPropertyOp)), \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(setter, JSStrictPropertyOp))} #define JS_PS_END {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} /* * To define a native function, set call to a JSNativeWrapper. To define a * self-hosted function, set selfHostedName to the name of a function * compiled during JSRuntime::initSelfHosting. */ struct JSFunctionSpec { const char *name; JSNativeWrapper call; uint16_t nargs; uint16_t flags; const char *selfHostedName; }; /* * Terminating sentinel initializer to put at the end of a JSFunctionSpec array * that's passed to JS_DefineFunctions or JS_InitClass. */ #define JS_FS_END JS_FS(NULL,NULL,0,0) /* * Initializer macros for a JSFunctionSpec array element. JS_FN (whose name * pays homage to the old JSNative/JSFastNative split) simply adds the flag * JSFUN_STUB_GSOPS. JS_FNINFO allows the simple adding of JSJitInfos. */ #define JS_FS(name,call,nargs,flags) \ {name, JSOP_WRAPPER(call), nargs, flags} #define JS_FN(name,call,nargs,flags) \ {name, JSOP_WRAPPER(call), nargs, (flags) | JSFUN_STUB_GSOPS} #define JS_FNINFO(name,call,info,nargs,flags) \ {name,{call,info},nargs,flags} extern JS_PUBLIC_API(JSObject *) JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto, JSClass *clasp, JSNative constructor, unsigned nargs, const JSPropertySpec *ps, const JSFunctionSpec *fs, const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs); /* * Set up ctor.prototype = proto and proto.constructor = ctor with the * right property flags. */ extern JS_PUBLIC_API(JSBool) JS_LinkConstructorAndPrototype(JSContext *cx, JSObject *ctor, JSObject *proto); extern JS_PUBLIC_API(JSClass *) JS_GetClass(JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); extern JS_PUBLIC_API(void *) JS_GetPrivate(JSObject *obj); extern JS_PUBLIC_API(void) JS_SetPrivate(JSObject *obj, void *data); extern JS_PUBLIC_API(void *) JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) JS_GetPrototype(JSContext *cx, JS::Handle obj, JS::MutableHandle protop); extern JS_PUBLIC_API(JSBool) JS_SetPrototype(JSContext *cx, JS::Handle obj, JS::Handle proto); extern JS_PUBLIC_API(JSObject *) JS_GetParent(JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent); extern JS_PUBLIC_API(JSObject *) JS_GetConstructor(JSContext *cx, JSObject *proto); /* * Get a unique identifier for obj, good for the lifetime of obj (even if it * is moved by a copying GC). Return false on failure (likely out of memory), * and true with *idp containing the unique id on success. */ extern JS_PUBLIC_API(JSBool) JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp); namespace JS { enum { FreshZone, SystemZone, SpecificZones }; typedef uintptr_t ZoneSpecifier; inline ZoneSpecifier SameZoneAs(JSObject *obj) { JS_ASSERT(uintptr_t(obj) > SpecificZones); return ZoneSpecifier(obj); } struct JS_PUBLIC_API(CompartmentOptions) { ZoneSpecifier zoneSpec; JSVersion version; bool invisibleToDebugger; explicit CompartmentOptions() : zoneSpec(JS::FreshZone) , version(JSVERSION_UNKNOWN) , invisibleToDebugger(false) {} CompartmentOptions &setZone(ZoneSpecifier spec) { zoneSpec = spec; return *this; } CompartmentOptions &setVersion(JSVersion version_) { JS_ASSERT(version_ != JSVERSION_UNKNOWN); version = version_; return *this; } // Certain scopes (i.e. XBL compilation scopes) are implementation details // of the embedding, and references to them should never leak out to script. // This flag causes the this compartment to skip firing onNewGlobalObject // and makes addDebuggee a no-op for this global. CompartmentOptions &setInvisibleToDebugger(bool invisible) { invisibleToDebugger = invisible; return *this; } }; // During global creation, we fire notifications to callbacks registered // via the Debugger API. These callbacks are arbitrary script, and can touch // the global in arbitrary ways. When that happens, the global should not be // in a half-baked state. But this creates a problem for consumers that need // to set slots on the global to put it in a consistent state. // // This API provides a way for consumers to set slots atomically (immediately // after the global is created), before any debugger hooks are fired. It's // unfortunately on the clunky side, but that's the way the cookie crumbles. // // If callers have no additional state on the global to set up, they may pass // |FireOnNewGlobalHook| to JS_NewGlobalObject, which causes that function to // fire the hook as its final act before returning. Otherwise, callers should // pass |DontFireOnNewGlobalHook|, which means that they are responsible for // invoking JS_FireOnNewGlobalObject upon successfully creating the global. If // an error occurs and the operation aborts, callers should skip firing the // hook. But otherwise, callers must take care to fire the hook exactly once // before compiling any script in the global's scope (we have assertions in // place to enforce this). This lets us be sure that debugger clients never miss // breakpoints. enum OnNewGlobalHookOption { FireOnNewGlobalHook, DontFireOnNewGlobalHook }; } /* namespace JS */ extern JS_PUBLIC_API(JSObject *) JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals, JS::OnNewGlobalHookOption hookOption, const JS::CompartmentOptions &options = JS::CompartmentOptions()); extern JS_PUBLIC_API(void) JS_FireOnNewGlobalObject(JSContext *cx, JS::HandleObject global); extern JS_PUBLIC_API(JSObject *) JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); /* Queries the [[Extensible]] property of the object. */ extern JS_PUBLIC_API(JSBool) JS_IsExtensible(JSContext *cx, JS::HandleObject obj, JSBool *extensible); extern JS_PUBLIC_API(JSBool) JS_IsNative(JSObject *obj); extern JS_PUBLIC_API(JSRuntime *) JS_GetObjectRuntime(JSObject *obj); /* * Unlike JS_NewObject, JS_NewObjectWithGivenProto does not compute a default * proto if proto's actual parameter value is null. */ extern JS_PUBLIC_API(JSObject *) JS_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); /* * Freeze obj, and all objects it refers to, recursively. This will not recurse * through non-extensible objects, on the assumption that those are already * deep-frozen. */ extern JS_PUBLIC_API(JSBool) JS_DeepFreezeObject(JSContext *cx, JSObject *obj); /* * Freezes an object; see ES5's Object.freeze(obj) method. */ extern JS_PUBLIC_API(JSBool) JS_FreezeObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_PreventExtensions(JSContext *cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSObject *) JS_New(JSContext *cx, JSObject *ctor, unsigned argc, jsval *argv); extern JS_PUBLIC_API(JSObject *) JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *clasp, JSObject *proto, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefineConstDoubles(JSContext *cx, JSObject *obj, const JSConstDoubleSpec *cds); extern JS_PUBLIC_API(JSBool) JS_DefineProperties(JSContext *cx, JSObject *obj, const JSPropertySpec *ps); extern JS_PUBLIC_API(JSBool) JS_DefineProperty(JSContext *cx, JSObject *obj, const char *name, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer * is not null). */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *obj, const char *name, int8_t tinyid, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, unsigned flags, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject **objp, JS::MutableHandle vp); struct JSPropertyDescriptor { JSObject *obj; unsigned attrs; unsigned shortid; JSPropertyOp getter; JSStrictPropertyOp setter; JS::Value value; JSPropertyDescriptor() : obj(NULL), attrs(0), shortid(0), getter(NULL), setter(NULL), value(JSVAL_VOID) {} void trace(JSTracer *trc); }; namespace JS { template class PropertyDescriptorOperations { const JSPropertyDescriptor * desc() const { return static_cast(this)->extract(); } JSPropertyDescriptor * desc() { return static_cast(this)->extract(); } public: bool isEnumerable() const { return desc()->attrs & JSPROP_ENUMERATE; } bool isReadonly() const { return desc()->attrs & JSPROP_READONLY; } bool isPermanent() const { return desc()->attrs & JSPROP_PERMANENT; } bool hasNativeAccessors() const { return desc()->attrs & JSPROP_NATIVE_ACCESSORS; } bool hasGetterObject() const { return desc()->attrs & JSPROP_GETTER; } bool hasSetterObject() const { return desc()->attrs & JSPROP_SETTER; } bool isShared() const { return desc()->attrs & JSPROP_SHARED; } bool isIndex() const { return desc()->attrs & JSPROP_INDEX; } bool hasShortId() const { return desc()->attrs & JSPROP_SHORTID; } bool hasAttributes(unsigned attrs) const { return desc()->attrs & attrs; } JS::MutableHandleObject object() { return JS::MutableHandleObject::fromMarkedLocation(&desc()->obj); } unsigned attributes() const { return desc()->attrs; } unsigned shortid() const { MOZ_ASSERT(hasShortId()); return desc()->shortid; } JSPropertyOp getter() const { return desc()->getter; } JSStrictPropertyOp setter() const { return desc()->setter; } JS::HandleObject getterObject() const { MOZ_ASSERT(hasGetterObject()); return JS::HandleObject::fromMarkedLocation(reinterpret_cast(&desc()->getter)); } JS::HandleObject setterObject() const { MOZ_ASSERT(hasSetterObject()); return JS::HandleObject::fromMarkedLocation(reinterpret_cast(&desc()->setter)); } JS::MutableHandleValue value() { return JS::MutableHandleValue::fromMarkedLocation(&desc()->value); } void setAttributes(unsigned attrs) { desc()->attrs = attrs; } void setShortId(unsigned id) { desc()->shortid = id; } void setGetter(JSPropertyOp op) { desc()->getter = op; } void setSetter(JSStrictPropertyOp op) { desc()->setter = op; } void setGetterObject(JSObject *obj) { desc()->getter = reinterpret_cast(obj); } void setSetterObject(JSObject *obj) { desc()->setter = reinterpret_cast(obj); } }; } /* namespace JS */ namespace js { template <> struct GCMethods { static JSPropertyDescriptor initial() { return JSPropertyDescriptor(); } static ThingRootKind kind() { return THING_ROOT_PROPERTY_DESCRIPTOR; } static bool poisoned(const JSPropertyDescriptor &desc) { return (desc.obj && JS::IsPoisonedPtr(desc.obj)) || (desc.attrs & JSPROP_GETTER && desc.getter && JS::IsPoisonedPtr(desc.getter)) || (desc.attrs & JSPROP_SETTER && desc.setter && JS::IsPoisonedPtr(desc.setter)) || (desc.value.isGCThing() && JS::IsPoisonedPtr(desc.value.toGCThing())); } }; template <> class RootedBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } JSPropertyDescriptor *extract() { return static_cast*>(this)->address(); } }; template <> class HandleBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } public: JS::HandleValue value() const { return JS::HandleValue::fromMarkedLocation(&extract()->value); } JS::HandleObject obj() const { return JS::HandleObject::fromMarkedLocation(&extract()->obj); } }; template <> class MutableHandleBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } JSPropertyDescriptor *extract() { return static_cast*>(this)->address(); } }; } /* namespace js */ /* * Like JS_GetPropertyAttrsGetterAndSetterById but will return a property on * an object on the prototype chain (returned in objp). If data->obj is null, * then this property was not found on the prototype chain. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSPropertyDescriptor *desc); extern JS_PUBLIC_API(JSBool) JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyDefault(JSContext *cx, JSObject *obj, const char *name, jsval def, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehalfOf, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name); extern JS_PUBLIC_API(JSBool) JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle rval); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle rval); extern JS_PUBLIC_API(JSBool) JS_DefineUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer * is not null). */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, int8_t tinyid, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSBool *vp); extern JS_PUBLIC_API(JSBool) JS_LookupUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_SetUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_DeleteUCProperty2(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle rval); extern JS_PUBLIC_API(JSObject *) JS_NewArrayObject(JSContext *cx, int length, jsval *vector); extern JS_PUBLIC_API(JSBool) JS_IsArrayObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_GetArrayLength(JSContext *cx, JSObject *obj, uint32_t *lengthp); extern JS_PUBLIC_API(JSBool) JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length); extern JS_PUBLIC_API(JSBool) JS_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_GetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp); /* * Get the property with name given by |index|, if it has one. If * not, |*present| will be set to false and the value of |vp| must not * be relied on. */ extern JS_PUBLIC_API(JSBool) JS_GetElementIfPresent(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp, JSBool* present); extern JS_PUBLIC_API(JSBool) JS_SetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_DeleteElement(JSContext *cx, JSObject *obj, uint32_t index); extern JS_PUBLIC_API(JSBool) JS_DeleteElement2(JSContext *cx, JSObject *obj, uint32_t index, jsval *rval); /* * Remove all configurable properties from the given (non-global) object and * assign undefined to all writable data properties. */ JS_PUBLIC_API(void) JS_ClearNonGlobalObject(JSContext *cx, JSObject *objArg); /* * Assign 'undefined' to all of the object's non-reserved slots. Note: this is * done for all slots, regardless of the associated property descriptor. */ JS_PUBLIC_API(void) JS_SetAllNonReservedSlotsToUndefined(JSContext *cx, JSObject *objArg); /* * Create a new array buffer with the given contents, which must have been * returned by JS_AllocateArrayBufferContents or JS_StealArrayBufferContents. * The new array buffer takes ownership. After calling this function, do not * free |contents| or use |contents| from another thread. */ extern JS_PUBLIC_API(JSObject *) JS_NewArrayBufferWithContents(JSContext *cx, void *contents); /* * Steal the contents of the given array buffer. The array buffer has its * length set to 0 and its contents array cleared. The caller takes ownership * of |*contents| and must free it or transfer ownership via * JS_NewArrayBufferWithContents when done using it. * To free |*contents|, call free(). * A pointer to the buffer's data is returned in |*data|. This pointer can * be used until |*contents| is freed or has its ownership transferred. */ extern JS_PUBLIC_API(JSBool) JS_StealArrayBufferContents(JSContext *cx, JSObject *obj, void **contents, uint8_t **data); /* * Allocate memory that may be eventually passed to * JS_NewArrayBufferWithContents. |nbytes| is the number of payload bytes * required. The pointer to pass to JS_NewArrayBufferWithContents is returned * in |contents|. The pointer to the |nbytes| of usable memory is returned in * |data|. (*|contents| will contain a header before |data|.) The only legal * operations on *|contents| is to free it, or pass it to * JS_NewArrayBufferWithContents or JS_ReallocateArrayBufferContents. */ extern JS_PUBLIC_API(JSBool) JS_AllocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void **contents, uint8_t **data); /* * Reallocate memory allocated by JS_AllocateArrayBufferContents, growing or shrinking it * as appropriate. The new data pointer will be returned in data. If *contents is NULL, * behaves like JS_AllocateArrayBufferContents. */ extern JS_PUBLIC_API(JSBool) JS_ReallocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void **contents, uint8_t **data); extern JS_PUBLIC_API(JSIdArray *) JS_Enumerate(JSContext *cx, JSObject *obj); /* * Create an object to iterate over enumerable properties of obj, in arbitrary * property definition order. NB: This differs from longstanding for..in loop * order, which uses order of property definition in obj. */ extern JS_PUBLIC_API(JSObject *) JS_NewPropertyIterator(JSContext *cx, JSObject *obj); /* * Return true on success with *idp containing the id of the next enumerable * property to visit using iterobj, or JSID_IS_VOID if there is no such property * left to visit. Return false on error. */ extern JS_PUBLIC_API(JSBool) JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp); /* * A JSNative that creates and returns a new iterator that iterates over the * elements of |this|, up to |this.length|, in index order. This can be used to * make any array-like object iterable. Just give the object an obj.iterator() * method using this JSNative as the implementation. */ extern JS_PUBLIC_API(JSBool) JS_ArrayIterator(JSContext *cx, unsigned argc, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, jsval *vp, unsigned *attrsp); extern JS_PUBLIC_API(jsval) JS_GetReservedSlot(JSObject *obj, uint32_t index); extern JS_PUBLIC_API(void) JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v); /************************************************************************/ /* * Security protocol. */ struct JSPrincipals { /* Don't call "destroy"; use reference counting macros below. */ int refcount; #ifdef DEBUG /* A helper to facilitate principals debugging. */ uint32_t debugToken; #endif void setDebugToken(uint32_t token) { # ifdef DEBUG debugToken = token; # endif } /* * This is not defined by the JS engine but should be provided by the * embedding. */ JS_PUBLIC_API(void) dump(); }; extern JS_PUBLIC_API(void) JS_HoldPrincipals(JSPrincipals *principals); extern JS_PUBLIC_API(void) JS_DropPrincipals(JSRuntime *rt, JSPrincipals *principals); struct JSSecurityCallbacks { JSCheckAccessOp checkObjectAccess; JSCSPEvalChecker contentSecurityPolicyAllows; }; extern JS_PUBLIC_API(void) JS_SetSecurityCallbacks(JSRuntime *rt, const JSSecurityCallbacks *callbacks); extern JS_PUBLIC_API(const JSSecurityCallbacks *) JS_GetSecurityCallbacks(JSRuntime *rt); /* * Code running with "trusted" principals will be given a deeper stack * allocation than ordinary scripts. This allows trusted script to run after * untrusted script has exhausted the stack. This function sets the * runtime-wide trusted principal. * * This principals is not held (via JS_HoldPrincipals/JS_DropPrincipals) since * there is no available JSContext. Instead, the caller must ensure that the * given principals stays valid for as long as 'rt' may point to it. If the * principals would be destroyed before 'rt', JS_SetTrustedPrincipals must be * called again, passing NULL for 'prin'. */ extern JS_PUBLIC_API(void) JS_SetTrustedPrincipals(JSRuntime *rt, JSPrincipals *prin); /* * Initialize the callback that is called to destroy JSPrincipals instance * when its reference counter drops to zero. The initialization can be done * only once per JS runtime. */ extern JS_PUBLIC_API(void) JS_InitDestroyPrincipalsCallback(JSRuntime *rt, JSDestroyPrincipalsOp destroyPrincipals); /************************************************************************/ /* * Functions and scripts. */ extern JS_PUBLIC_API(JSFunction *) JS_NewFunction(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, JSObject *parent, const char *name); /* * Create the function with the name given by the id. JSID_IS_STRING(id) must * be true. */ extern JS_PUBLIC_API(JSFunction *) JS_NewFunctionById(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, JSObject *parent, jsid id); extern JS_PUBLIC_API(JSObject *) JS_GetFunctionObject(JSFunction *fun); /* * Return the function's identifier as a JSString, or null if fun is unnamed. * The returned string lives as long as fun, so you don't need to root a saved * reference to it if fun is well-connected or rooted, and provided you bound * the use of the saved reference by fun's lifetime. */ extern JS_PUBLIC_API(JSString *) JS_GetFunctionId(JSFunction *fun); /* * Return a function's display name. This is the defined name if one was given * where the function was defined, or it could be an inferred name by the JS * engine in the case that the function was defined to be anonymous. This can * still return NULL if a useful display name could not be inferred. The same * restrictions on rooting as those in JS_GetFunctionId apply. */ extern JS_PUBLIC_API(JSString *) JS_GetFunctionDisplayId(JSFunction *fun); /* * Return the arity (length) of fun. */ extern JS_PUBLIC_API(uint16_t) JS_GetFunctionArity(JSFunction *fun); /* * Infallible predicate to test whether obj is a function object (faster than * comparing obj's class name to "Function", but equivalent unless someone has * overwritten the "Function" identifier with a different constructor and then * created instances using that constructor that might be passed in as obj). */ extern JS_PUBLIC_API(JSBool) JS_ObjectIsFunction(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_ObjectIsCallable(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_IsNativeFunction(JSObject *funobj, JSNative call); /* Return whether the given function is a valid constructor. */ extern JS_PUBLIC_API(JSBool) JS_IsConstructor(JSFunction *fun); /* * Bind the given callable to use the given object as "this". * * If |callable| is not callable, will throw and return NULL. */ extern JS_PUBLIC_API(JSObject*) JS_BindCallable(JSContext *cx, JSObject *callable, JSObject *newThis); extern JS_PUBLIC_API(JSBool) JS_DefineFunctions(JSContext *cx, JSObject *obj, const JSFunctionSpec *fs); extern JS_PUBLIC_API(JSFunction *) JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call, unsigned nargs, unsigned attrs); extern JS_PUBLIC_API(JSFunction *) JS_DefineUCFunction(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSNative call, unsigned nargs, unsigned attrs); extern JS_PUBLIC_API(JSFunction *) JS_DefineFunctionById(JSContext *cx, JSObject *obj, jsid id, JSNative call, unsigned nargs, unsigned attrs); /* * Clone a top-level function into a new scope. This function will dynamically * fail if funobj was lexically nested inside some other function. */ extern JS_PUBLIC_API(JSObject *) JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); /* * Given a buffer, return JS_FALSE if the buffer might become a valid * javascript statement with the addition of more lines. Otherwise return * JS_TRUE. The intent is to support interactive compilation - accumulate * lines in a buffer until JS_BufferIsCompilableUnit is true, then pass it to * the compiler. */ extern JS_PUBLIC_API(JSBool) JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj, const char *utf8, size_t length); extern JS_PUBLIC_API(JSScript *) JS_CompileScript(JSContext *cx, JSObject *obj, const char *ascii, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *ascii, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileUCScript(JSContext *cx, JSObject *obj, const jschar *chars, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalFromScript(JSScript *script); extern JS_PUBLIC_API(JSFunction *) JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSFunction *) JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSFunction *) JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name, unsigned nargs, const char **argnames, const jschar *chars, size_t length, const char *filename, unsigned lineno); namespace JS { /* Options for JavaScript compilation. */ class JS_PUBLIC_API(CompileOptions) { JSPrincipals *principals_; JSPrincipals *originPrincipals_; public: JSPrincipals *principals() const { return principals_; } JSPrincipals *originPrincipals() const; JSVersion version; bool versionSet; bool utf8; const char *filename; unsigned lineno; unsigned column; HandleObject element; bool compileAndGo; bool forEval; bool noScriptRval; bool selfHostingMode; bool canLazilyParse; bool strictOption; bool extraWarningsOption; bool werrorOption; bool asmJSOption; enum SourcePolicy { NO_SOURCE, LAZY_SOURCE, SAVE_SOURCE } sourcePolicy; explicit CompileOptions(JSContext *cx, JSVersion version = JSVERSION_UNKNOWN); CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; } CompileOptions &setOriginPrincipals(JSPrincipals *p) { originPrincipals_ = p; return *this; } CompileOptions &setVersion(JSVersion v) { version = v; versionSet = true; return *this; } CompileOptions &setUTF8(bool u) { utf8 = u; return *this; } CompileOptions &setFileAndLine(const char *f, unsigned l) { filename = f; lineno = l; return *this; } CompileOptions &setColumn(unsigned c) { column = c; return *this; } CompileOptions &setElement(HandleObject e) { element = e; return *this; } CompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; } CompileOptions &setForEval(bool eval) { forEval = eval; return *this; } CompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; } CompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; } CompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; } CompileOptions &setSourcePolicy(SourcePolicy sp) { sourcePolicy = sp; return *this; } }; extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const char *bytes, size_t length); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const jschar *chars, size_t length); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, FILE *file); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const char *filename); extern JS_PUBLIC_API(JSFunction *) CompileFunction(JSContext *cx, JS::Handle obj, CompileOptions options, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length); extern JS_PUBLIC_API(JSFunction *) CompileFunction(JSContext *cx, JS::Handle obj, CompileOptions options, const char *name, unsigned nargs, const char **argnames, const jschar *chars, size_t length); } /* namespace JS */ extern JS_PUBLIC_API(JSString *) JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, unsigned indent); /* * API extension: OR this into indent to avoid pretty-printing the decompiled * source resulting from JS_DecompileFunction{,Body}. */ #define JS_DONT_PRETTY_PRINT ((unsigned)0x8000) extern JS_PUBLIC_API(JSString *) JS_DecompileFunction(JSContext *cx, JSFunction *fun, unsigned indent); extern JS_PUBLIC_API(JSString *) JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, unsigned indent); /* * NB: JS_ExecuteScript and the JS_Evaluate*Script* quadruplets use the obj * parameter as the initial scope chain header, the 'this' keyword value, and * the variables object (ECMA parlance for where 'var' and 'function' bind * names) of the execution context for script. * * Using obj as the variables object is problematic if obj's parent (which is * the scope chain link; see JS_SetParent and JS_NewObject) is not null: in * this case, variables created by 'var x = 0', e.g., go in obj, but variables * created by assignment to an unbound id, 'x = 0', go in the last object on * the scope chain linked by parent. * * ECMA calls that last scoping object the "global object", but note that many * embeddings have several such objects. ECMA requires that "global code" be * executed with the variables object equal to this global object. But these * JS API entry points provide freedom to execute code against a "sub-global", * i.e., a parented or scoped object, in which case the variables object will * differ from the last object on the scope chain, resulting in confusing and * non-ECMA explicit vs. implicit variable creation. * * Caveat embedders: unless you already depend on this buggy variables object * binding behavior, you should call JS_SetOptions(cx, JSOPTION_VAROBJFIX) or * JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_VAROBJFIX) -- the latter if * someone may have set other options on cx already -- for each context in the * application, if you pass parented objects as the obj parameter, or may ever * pass such objects in the future. * * Why a runtime option? The alternative is to add six or so new API entry * points with signatures matching the following six, and that doesn't seem * worth the code bloat cost. Such new entry points would probably have less * obvious names, too, so would not tend to be used. The JS_SetOption call, * OTOH, can be more easily hacked into existing code that does not depend on * the bug; such code can continue to use the familiar JS_EvaluateScript, * etc., entry points. */ extern JS_PUBLIC_API(JSBool) JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_ExecuteScriptVersion(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval, JSVersion version); /* * Execute either the function-defining prolog of a script, or the script's * main body, but not both. */ typedef enum JSExecPart { JSEXEC_PROLOG, JSEXEC_MAIN } JSExecPart; extern JS_PUBLIC_API(JSBool) JS_EvaluateScript(JSContext *cx, JSObject *obj, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScript(JSContext *cx, JSObject *obj, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); /* * JSAPI clients may optionally specify the 'originPrincipals' of a script. * A script's originPrincipals may be retrieved through the debug API (via * JS_GetScriptOriginPrincipals) and the originPrincipals are transitively * assigned to any nested scripts (including scripts dynamically created via * eval and the Function constructor). If originPrincipals is null, then the * value of principals is used as origin principals for the script. */ extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JSObject *obj, JSPrincipals *principals, JSPrincipals *originPrincipals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); namespace JS { extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const jschar *chars, size_t length, jsval *rval); extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const char *bytes, size_t length, jsval *rval); extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const char *filename, jsval *rval); } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, unsigned argc, jsval *argv, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, unsigned argc, jsval *argv, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, unsigned argc, jsval *argv, jsval *rval); namespace JS { static inline bool Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunction(cx, thisObj, fun, argc, argv, rval.address()); } static inline bool Call(JSContext *cx, JSObject *thisObj, const char *name, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunctionName(cx, thisObj, name, argc, argv, rval.address()); } static inline bool Call(JSContext *cx, JSObject *thisObj, jsval fun, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunctionValue(cx, thisObj, fun, argc, argv, rval.address()); } extern JS_PUBLIC_API(bool) Call(JSContext *cx, jsval thisv, jsval fun, unsigned argc, jsval *argv, MutableHandle rval); static inline bool Call(JSContext *cx, jsval thisv, JSObject *funObj, unsigned argc, jsval *argv, MutableHandle rval) { return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval); } } /* namespace JS */ /* * These functions allow setting an operation callback that will be called * from the JS thread some time after any thread triggered the callback using * JS_TriggerOperationCallback(rt). * * To schedule the GC and for other activities the engine internally triggers * operation callbacks. The embedding should thus not rely on callbacks being * triggered through the external API only. * * Important note: Additional callbacks can occur inside the callback handler * if it re-enters the JS engine. The embedding must ensure that the callback * is disconnected before attempting such re-entry. */ extern JS_PUBLIC_API(JSOperationCallback) JS_SetOperationCallback(JSContext *cx, JSOperationCallback callback); extern JS_PUBLIC_API(JSOperationCallback) JS_GetOperationCallback(JSContext *cx); extern JS_PUBLIC_API(void) JS_TriggerOperationCallback(JSRuntime *rt); extern JS_PUBLIC_API(JSBool) JS_IsRunning(JSContext *cx); /* * Saving and restoring frame chains. * * These two functions are used to set aside cx's call stack while that stack * is inactive. After a call to JS_SaveFrameChain, it looks as if there is no * code running on cx. Before calling JS_RestoreFrameChain, cx's call stack * must be balanced and all nested calls to JS_SaveFrameChain must have had * matching JS_RestoreFrameChain calls. * * JS_SaveFrameChain deals with cx not having any code running on it. */ extern JS_PUBLIC_API(JSBool) JS_SaveFrameChain(JSContext *cx); extern JS_PUBLIC_API(void) JS_RestoreFrameChain(JSContext *cx); #ifdef MOZ_TRACE_JSCALLS /* * The callback is expected to be quick and noninvasive. It should not * trigger interrupts, turn on debugging, or produce uncaught JS * exceptions. The state of the stack and registers in the context * cannot be relied upon, since this callback may be invoked directly * from either JIT. The 'entering' field means we are entering a * function if it is positive, leaving a function if it is zero or * negative. */ extern JS_PUBLIC_API(void) JS_SetFunctionCallback(JSContext *cx, JSFunctionCallback fcb); extern JS_PUBLIC_API(JSFunctionCallback) JS_GetFunctionCallback(JSContext *cx); #endif /* MOZ_TRACE_JSCALLS */ /************************************************************************/ /* * Strings. * * NB: JS_NewUCString takes ownership of bytes on success, avoiding a copy; * but on error (signified by null return), it leaves chars owned by the * caller. So the caller must free bytes in the error case, if it has no use * for them. In contrast, all the JS_New*StringCopy* functions do not take * ownership of the character memory passed to them -- they copy it. */ extern JS_PUBLIC_API(JSString *) JS_NewStringCopyN(JSContext *cx, const char *s, size_t n); extern JS_PUBLIC_API(JSString *) JS_NewStringCopyZ(JSContext *cx, const char *s); extern JS_PUBLIC_API(JSString *) JS_InternJSString(JSContext *cx, JSString *str); extern JS_PUBLIC_API(JSString *) JS_InternStringN(JSContext *cx, const char *s, size_t length); extern JS_PUBLIC_API(JSString *) JS_InternString(JSContext *cx, const char *s); extern JS_PUBLIC_API(JSString *) JS_NewUCString(JSContext *cx, jschar *chars, size_t length); extern JS_PUBLIC_API(JSString *) JS_NewUCStringCopyN(JSContext *cx, const jschar *s, size_t n); extern JS_PUBLIC_API(JSString *) JS_NewUCStringCopyZ(JSContext *cx, const jschar *s); extern JS_PUBLIC_API(JSString *) JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length); extern JS_PUBLIC_API(JSString *) JS_InternUCString(JSContext *cx, const jschar *s); extern JS_PUBLIC_API(JSBool) JS_CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32_t *result); extern JS_PUBLIC_API(JSBool) JS_StringEqualsAscii(JSContext *cx, JSString *str, const char *asciiBytes, JSBool *match); extern JS_PUBLIC_API(size_t) JS_PutEscapedString(JSContext *cx, char *buffer, size_t size, JSString *str, char quote); extern JS_PUBLIC_API(JSBool) JS_FileEscapedString(FILE *fp, JSString *str, char quote); /* * Extracting string characters and length. * * While getting the length of a string is infallible, getting the chars can * fail. As indicated by the lack of a JSContext parameter, there are two * special cases where getting the chars is infallible: * * The first case is interned strings, i.e., strings from JS_InternString or * JSID_TO_STRING(id), using JS_GetInternedStringChars*. * * The second case is "flat" strings that have been explicitly prepared in a * fallible context by JS_FlattenString. To catch errors, a separate opaque * JSFlatString type is returned by JS_FlattenString and expected by * JS_GetFlatStringChars. Note, though, that this is purely a syntactic * distinction: the input and output of JS_FlattenString are the same actual * GC-thing so only one needs to be rooted. If a JSString is known to be flat, * JS_ASSERT_STRING_IS_FLAT can be used to make a debug-checked cast. Example: * * // in a fallible context * JSFlatString *fstr = JS_FlattenString(cx, str); * if (!fstr) * return JS_FALSE; * JS_ASSERT(fstr == JS_ASSERT_STRING_IS_FLAT(str)); * * // in an infallible context, for the same 'str' * const jschar *chars = JS_GetFlatStringChars(fstr) * JS_ASSERT(chars); * * The CharsZ APIs guarantee that the returned array has a null character at * chars[length]. This can require additional copying so clients should prefer * APIs without CharsZ if possible. The infallible functions also return * null-terminated arrays. (There is no additional cost or non-Z alternative * for the infallible functions, so 'Z' is left out of the identifier.) */ extern JS_PUBLIC_API(size_t) JS_GetStringLength(JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsAndLength(JSContext *cx, JSString *str, size_t *length); extern JS_PUBLIC_API(const jschar *) JS_GetInternedStringChars(JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetInternedStringCharsAndLength(JSString *str, size_t *length); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsZ(JSContext *cx, JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsZAndLength(JSContext *cx, JSString *str, size_t *length); extern JS_PUBLIC_API(JSFlatString *) JS_FlattenString(JSContext *cx, JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetFlatStringChars(JSFlatString *str); static JS_ALWAYS_INLINE JSFlatString * JSID_TO_FLAT_STRING(jsid id) { JS_ASSERT(JSID_IS_STRING(id)); return (JSFlatString *)(JSID_BITS(id)); } static JS_ALWAYS_INLINE JSFlatString * JS_ASSERT_STRING_IS_FLAT(JSString *str) { JS_ASSERT(JS_GetFlatStringChars((JSFlatString *)str)); return (JSFlatString *)str; } static JS_ALWAYS_INLINE JSString * JS_FORGET_STRING_FLATNESS(JSFlatString *fstr) { return (JSString *)fstr; } /* * Additional APIs that avoid fallibility when given a flat string. */ extern JS_PUBLIC_API(JSBool) JS_FlatStringEqualsAscii(JSFlatString *str, const char *asciiBytes); extern JS_PUBLIC_API(size_t) JS_PutEscapedFlatString(char *buffer, size_t size, JSFlatString *str, char quote); /* * This function is now obsolete and behaves the same as JS_NewUCString. Use * JS_NewUCString instead. */ extern JS_PUBLIC_API(JSString *) JS_NewGrowableString(JSContext *cx, jschar *chars, size_t length); /* * Create a dependent string, i.e., a string that owns no character storage, * but that refers to a slice of another string's chars. Dependent strings * are mutable by definition, so the thread safety comments above apply. */ extern JS_PUBLIC_API(JSString *) JS_NewDependentString(JSContext *cx, JSString *str, size_t start, size_t length); /* * Concatenate two strings, possibly resulting in a rope. * See above for thread safety comments. */ extern JS_PUBLIC_API(JSString *) JS_ConcatStrings(JSContext *cx, JSString *left, JSString *right); /* * For JS_DecodeBytes, set *dstlenp to the size of the destination buffer before * the call; on return, *dstlenp contains the number of jschars actually stored. * To determine the necessary destination buffer size, make a sizing call that * passes NULL for dst. * * On errors, the functions report the error. In that case, *dstlenp contains * the number of characters or bytes transferred so far. If cx is NULL, no * error is reported on failure, and the functions simply return JS_FALSE. * * NB: This function does not store an additional zero byte or jschar after the * transcoded string. */ JS_PUBLIC_API(JSBool) JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst, size_t *dstlenp); /* * A variation on JS_EncodeCharacters where a null terminated string is * returned that you are expected to call JS_free on when done. */ JS_PUBLIC_API(char *) JS_EncodeString(JSContext *cx, JSString *str); /* * Same behavior as JS_EncodeString(), but encode into UTF-8 string */ JS_PUBLIC_API(char *) JS_EncodeStringToUTF8(JSContext *cx, JSString *str); /* * Get number of bytes in the string encoding (without accounting for a * terminating zero bytes. The function returns (size_t) -1 if the string * can not be encoded into bytes and reports an error using cx accordingly. */ JS_PUBLIC_API(size_t) JS_GetStringEncodingLength(JSContext *cx, JSString *str); /* * Encode string into a buffer. The function does not stores an additional * zero byte. The function returns (size_t) -1 if the string can not be * encoded into bytes with no error reported. Otherwise it returns the number * of bytes that are necessary to encode the string. If that exceeds the * length parameter, the string will be cut and only length bytes will be * written into the buffer. */ JS_PUBLIC_API(size_t) JS_EncodeStringToBuffer(JSContext *cx, JSString *str, char *buffer, size_t length); class JSAutoByteString { public: JSAutoByteString(JSContext *cx, JSString *str MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mBytes(JS_EncodeString(cx, str)) { JS_ASSERT(cx); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } JSAutoByteString(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) : mBytes(NULL) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~JSAutoByteString() { js_free(mBytes); } /* Take ownership of the given byte array. */ void initBytes(char *bytes) { JS_ASSERT(!mBytes); mBytes = bytes; } char *encodeLatin1(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); JS_ASSERT(cx); mBytes = JS_EncodeString(cx, str); return mBytes; } char *encodeLatin1(js::ContextFriendFields *cx, JSString *str); char *encodeUtf8(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); JS_ASSERT(cx); mBytes = JS_EncodeStringToUTF8(cx, str); return mBytes; } void clear() { js_free(mBytes); mBytes = NULL; } char *ptr() const { return mBytes; } bool operator!() const { return !mBytes; } size_t length() const { if (!mBytes) return 0; return strlen(mBytes); } private: char *mBytes; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER /* Copy and assignment are not supported. */ JSAutoByteString(const JSAutoByteString &another); JSAutoByteString &operator=(const JSAutoByteString &another); }; /************************************************************************/ /* * JSON functions */ typedef JSBool (* JSONWriteCallback)(const jschar *buf, uint32_t len, void *data); /* * JSON.stringify as specified by ES5. */ JS_PUBLIC_API(JSBool) JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space, JSONWriteCallback callback, void *data); /* * JSON.parse as specified by ES5. */ JS_PUBLIC_API(JSBool) JS_ParseJSON(JSContext *cx, const jschar *chars, uint32_t len, JS::MutableHandle vp); JS_PUBLIC_API(JSBool) JS_ParseJSONWithReviver(JSContext *cx, const jschar *chars, uint32_t len, jsval reviver, jsval *vp); /************************************************************************/ /* API for the HTML5 internal structured cloning algorithm. */ /* The maximum supported structured-clone serialization format version. */ #define JS_STRUCTURED_CLONE_VERSION 2 struct JSStructuredCloneCallbacks { ReadStructuredCloneOp read; WriteStructuredCloneOp write; StructuredCloneErrorOp reportError; }; /* Note: if the *data contains transferable objects, it can be read * only once */ JS_PUBLIC_API(JSBool) JS_ReadStructuredClone(JSContext *cx, uint64_t *data, size_t nbytes, uint32_t version, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure); /* Note: On success, the caller is responsible for calling * JS_ClearStructuredClone(*datap, nbytesp). */ JS_PUBLIC_API(JSBool) JS_WriteStructuredClone(JSContext *cx, jsval v, uint64_t **datap, size_t *nbytesp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure, jsval transferable); JS_PUBLIC_API(JSBool) JS_ClearStructuredClone(const uint64_t *data, size_t nbytes); JS_PUBLIC_API(JSBool) JS_StructuredCloneHasTransferables(const uint64_t *data, size_t nbytes, JSBool *hasTransferable); JS_PUBLIC_API(JSBool) JS_StructuredClone(JSContext *cx, jsval v, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure); /* RAII sugar for JS_WriteStructuredClone. */ class JS_PUBLIC_API(JSAutoStructuredCloneBuffer) { uint64_t *data_; size_t nbytes_; uint32_t version_; public: JSAutoStructuredCloneBuffer() : data_(NULL), nbytes_(0), version_(JS_STRUCTURED_CLONE_VERSION) {} ~JSAutoStructuredCloneBuffer() { clear(); } uint64_t *data() const { return data_; } size_t nbytes() const { return nbytes_; } void clear(); /* Copy some memory. It will be automatically freed by the destructor. */ bool copy(const uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION); /* * Adopt some memory. It will be automatically freed by the destructor. * data must have been allocated by the JS engine (e.g., extracted via * JSAutoStructuredCloneBuffer::steal). */ void adopt(uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION); /* * Remove the buffer so that it will not be automatically freed. * After this, the caller is responsible for feeding the memory back to * JSAutoStructuredCloneBuffer::adopt. */ void steal(uint64_t **datap, size_t *nbytesp, uint32_t *versionp=NULL); bool read(JSContext *cx, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); bool write(JSContext *cx, jsval v, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); bool write(JSContext *cx, jsval v, jsval transferable, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); /** * Swap ownership with another JSAutoStructuredCloneBuffer. */ void swap(JSAutoStructuredCloneBuffer &other); private: /* Copy and assignment are not supported. */ JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer &other); JSAutoStructuredCloneBuffer &operator=(const JSAutoStructuredCloneBuffer &other); }; /* API for implementing custom serialization behavior (for ImageData, File, etc.) */ /* The range of tag values the application may use for its own custom object types. */ #define JS_SCTAG_USER_MIN ((uint32_t) 0xFFFF8000) #define JS_SCTAG_USER_MAX ((uint32_t) 0xFFFFFFFF) #define JS_SCERR_RECURSION 0 #define JS_SCERR_TRANSFERABLE 1 JS_PUBLIC_API(void) JS_SetStructuredCloneCallbacks(JSRuntime *rt, const JSStructuredCloneCallbacks *callbacks); JS_PUBLIC_API(JSBool) JS_ReadUint32Pair(JSStructuredCloneReader *r, uint32_t *p1, uint32_t *p2); JS_PUBLIC_API(JSBool) JS_ReadBytes(JSStructuredCloneReader *r, void *p, size_t len); JS_PUBLIC_API(JSBool) JS_ReadTypedArray(JSStructuredCloneReader *r, jsval *vp); JS_PUBLIC_API(JSBool) JS_WriteUint32Pair(JSStructuredCloneWriter *w, uint32_t tag, uint32_t data); JS_PUBLIC_API(JSBool) JS_WriteBytes(JSStructuredCloneWriter *w, const void *p, size_t len); JS_PUBLIC_API(JSBool) JS_WriteTypedArray(JSStructuredCloneWriter *w, jsval v); /************************************************************************/ /* * The default locale for the ECMAScript Internationalization API * (Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat). * Note that the Internationalization API encourages clients to * specify their own locales. * The locale string remains owned by the caller. */ extern JS_PUBLIC_API(JSBool) JS_SetDefaultLocale(JSRuntime *rt, const char *locale); /* * Reset the default locale to OS defaults. */ extern JS_PUBLIC_API(void) JS_ResetDefaultLocale(JSRuntime *rt); /* * Locale specific string conversion and error message callbacks. */ struct JSLocaleCallbacks { JSLocaleToUpperCase localeToUpperCase; JSLocaleToLowerCase localeToLowerCase; JSLocaleCompare localeCompare; // not used #if ENABLE_INTL_API JSLocaleToUnicode localeToUnicode; JSErrorCallback localeGetErrorMessage; }; /* * Establish locale callbacks. The pointer must persist as long as the * JSRuntime. Passing NULL restores the default behaviour. */ extern JS_PUBLIC_API(void) JS_SetLocaleCallbacks(JSRuntime *rt, JSLocaleCallbacks *callbacks); /* * Return the address of the current locale callbacks struct, which may * be NULL. */ extern JS_PUBLIC_API(JSLocaleCallbacks *) JS_GetLocaleCallbacks(JSRuntime *rt); /************************************************************************/ /* * Error reporting. */ /* * Report an exception represented by the sprintf-like conversion of format * and its arguments. This exception message string is passed to a pre-set * JSErrorReporter function (set by JS_SetErrorReporter). */ extern JS_PUBLIC_API(void) JS_ReportError(JSContext *cx, const char *format, ...); /* * Use an errorNumber to retrieve the format string, args are char * */ extern JS_PUBLIC_API(void) JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); #ifdef va_start extern JS_PUBLIC_API(void) JS_ReportErrorNumberVA(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, va_list ap); #endif /* * Use an errorNumber to retrieve the format string, args are jschar * */ extern JS_PUBLIC_API(void) JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); extern JS_PUBLIC_API(void) JS_ReportErrorNumberUCArray(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, const jschar **args); /* * As above, but report a warning instead (JSREPORT_IS_WARNING(report.flags)). * Return true if there was no error trying to issue the warning, and if the * warning was not converted into an error due to the JSOPTION_WERROR option * being set, false otherwise. */ extern JS_PUBLIC_API(JSBool) JS_ReportWarning(JSContext *cx, const char *format, ...); extern JS_PUBLIC_API(JSBool) JS_ReportErrorFlagsAndNumber(JSContext *cx, unsigned flags, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); extern JS_PUBLIC_API(JSBool) JS_ReportErrorFlagsAndNumberUC(JSContext *cx, unsigned flags, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); /* * Complain when out of memory. */ extern JS_PUBLIC_API(void) JS_ReportOutOfMemory(JSContext *cx); /* * Complain when an allocation size overflows the maximum supported limit. */ extern JS_PUBLIC_API(void) JS_ReportAllocationOverflow(JSContext *cx); struct JSErrorReport { const char *filename; /* source file name, URL, etc., or null */ JSPrincipals *originPrincipals; /* see 'originPrincipals' comment above */ unsigned lineno; /* source line number */ const char *linebuf; /* offending source line without final \n */ const char *tokenptr; /* pointer to error token in linebuf */ const jschar *uclinebuf; /* unicode (original) line buffer */ const jschar *uctokenptr; /* unicode (original) token pointer */ unsigned flags; /* error/warning, etc. */ unsigned errorNumber; /* the error number, e.g. see js.msg */ const jschar *ucmessage; /* the (default) error message */ const jschar **messageArgs; /* arguments for the error message */ int16_t exnType; /* One of the JSExnType constants */ unsigned column; /* zero-based column index in line */ }; /* * JSErrorReport flag values. These may be freely composed. */ #define JSREPORT_ERROR 0x0 /* pseudo-flag for default case */ #define JSREPORT_WARNING 0x1 /* reported via JS_ReportWarning */ #define JSREPORT_EXCEPTION 0x2 /* exception was thrown */ #define JSREPORT_STRICT 0x4 /* error or warning due to strict option */ /* * This condition is an error in strict mode code, a warning if * JS_HAS_STRICT_OPTION(cx), and otherwise should not be reported at * all. We check the strictness of the context's top frame's script; * where that isn't appropriate, the caller should do the right checks * itself instead of using this flag. */ #define JSREPORT_STRICT_MODE_ERROR 0x8 /* * If JSREPORT_EXCEPTION is set, then a JavaScript-catchable exception * has been thrown for this runtime error, and the host should ignore it. * Exception-aware hosts should also check for JS_IsExceptionPending if * JS_ExecuteScript returns failure, and signal or propagate the exception, as * appropriate. */ #define JSREPORT_IS_WARNING(flags) (((flags) & JSREPORT_WARNING) != 0) #define JSREPORT_IS_EXCEPTION(flags) (((flags) & JSREPORT_EXCEPTION) != 0) #define JSREPORT_IS_STRICT(flags) (((flags) & JSREPORT_STRICT) != 0) #define JSREPORT_IS_STRICT_MODE_ERROR(flags) (((flags) & \ JSREPORT_STRICT_MODE_ERROR) != 0) extern JS_PUBLIC_API(JSErrorReporter) JS_GetErrorReporter(JSContext *cx); extern JS_PUBLIC_API(JSErrorReporter) JS_SetErrorReporter(JSContext *cx, JSErrorReporter er); /************************************************************************/ /* * Dates. */ extern JS_PUBLIC_API(JSObject *) JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); extern JS_PUBLIC_API(JSObject *) JS_NewDateObjectMsec(JSContext *cx, double msec); /* * Infallible predicate to test whether obj is a date object. */ extern JS_PUBLIC_API(JSBool) JS_ObjectIsDate(JSContext *cx, JSObject *obj); /* * Clears the cache of calculated local time from each Date object. * Call to propagate a system timezone change. */ extern JS_PUBLIC_API(void) JS_ClearDateCaches(JSContext *cx); /************************************************************************/ /* * Regular Expressions. */ #define JSREG_FOLD 0x01 /* fold uppercase to lowercase */ #define JSREG_GLOB 0x02 /* global exec, creates array of matches */ #define JSREG_MULTILINE 0x04 /* treat ^ and $ as begin and end of line */ #define JSREG_STICKY 0x08 /* only match starting at lastIndex */ extern JS_PUBLIC_API(JSObject *) JS_NewRegExpObject(JSContext *cx, JSObject *obj, char *bytes, size_t length, unsigned flags); extern JS_PUBLIC_API(JSObject *) JS_NewUCRegExpObject(JSContext *cx, JSObject *obj, jschar *chars, size_t length, unsigned flags); extern JS_PUBLIC_API(void) JS_SetRegExpInput(JSContext *cx, JSObject *obj, JSString *input, JSBool multiline); extern JS_PUBLIC_API(void) JS_ClearRegExpStatics(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_ExecuteRegExp(JSContext *cx, JSObject *obj, JSObject *reobj, jschar *chars, size_t length, size_t *indexp, JSBool test, jsval *rval); /* RegExp interface for clients without a global object. */ extern JS_PUBLIC_API(JSObject *) JS_NewRegExpObjectNoStatics(JSContext *cx, char *bytes, size_t length, unsigned flags); extern JS_PUBLIC_API(JSObject *) JS_NewUCRegExpObjectNoStatics(JSContext *cx, jschar *chars, size_t length, unsigned flags); extern JS_PUBLIC_API(JSBool) JS_ExecuteRegExpNoStatics(JSContext *cx, JSObject *reobj, jschar *chars, size_t length, size_t *indexp, JSBool test, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_ObjectIsRegExp(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(unsigned) JS_GetRegExpFlags(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSString *) JS_GetRegExpSource(JSContext *cx, JSObject *obj); /************************************************************************/ extern JS_PUBLIC_API(JSBool) JS_IsExceptionPending(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_GetPendingException(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(void) JS_SetPendingException(JSContext *cx, jsval v); extern JS_PUBLIC_API(void) JS_ClearPendingException(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_ReportPendingException(JSContext *cx); /* * Save the current exception state. This takes a snapshot of cx's current * exception state without making any change to that state. * * The returned state pointer MUST be passed later to JS_RestoreExceptionState * (to restore that saved state, overriding any more recent state) or else to * JS_DropExceptionState (to free the state struct in case it is not correct * or desirable to restore it). Both Restore and Drop free the state struct, * so callers must stop using the pointer returned from Save after calling the * Release or Drop API. */ extern JS_PUBLIC_API(JSExceptionState *) JS_SaveExceptionState(JSContext *cx); extern JS_PUBLIC_API(void) JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state); extern JS_PUBLIC_API(void) JS_DropExceptionState(JSContext *cx, JSExceptionState *state); /* * If the given value is an exception object that originated from an error, * the exception will contain an error report struct, and this API will return * the address of that struct. Otherwise, it returns NULL. The lifetime of * the error report struct that might be returned is the same as the lifetime * of the exception object. */ extern JS_PUBLIC_API(JSErrorReport *) JS_ErrorFromException(JSContext *cx, jsval v); /* * Given a reported error's message and JSErrorReport struct pointer, throw * the corresponding exception on cx. */ extern JS_PUBLIC_API(JSBool) JS_ThrowReportedError(JSContext *cx, const char *message, JSErrorReport *reportp); /* * Throws a StopIteration exception on cx. */ extern JS_PUBLIC_API(JSBool) JS_ThrowStopIteration(JSContext *cx); extern JS_PUBLIC_API(intptr_t) JS_GetCurrentThread(); /* * A JS runtime always has an "owner thread". The owner thread is set when the * runtime is created (to the current thread) and practically all entry points * into the JS engine check that a runtime (or anything contained in the * runtime: context, compartment, object, etc) is only touched by its owner * thread. Embeddings may check this invariant outside the JS engine by calling * JS_AbortIfWrongThread (which will abort if not on the owner thread, even for * non-debug builds). * * It is possible to "move" a runtime between threads. This is accomplished by * calling JS_ClearRuntimeThread on a runtime's owner thread and then calling * JS_SetRuntimeThread on the new owner thread. The runtime must not be * accessed between JS_ClearRuntimeThread and JS_SetRuntimeThread. Also, the * caller is responsible for synchronizing the calls to Set/Clear. */ extern JS_PUBLIC_API(void) JS_AbortIfWrongThread(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_ClearRuntimeThread(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_SetRuntimeThread(JSRuntime *rt); class JSAutoSetRuntimeThread { JSRuntime *runtime_; public: JSAutoSetRuntimeThread(JSRuntime *runtime) : runtime_(runtime) { JS_SetRuntimeThread(runtime_); } ~JSAutoSetRuntimeThread() { JS_ClearRuntimeThread(runtime_); } }; /************************************************************************/ /* * JS_IsConstructing must be called from within a native given the * native's original cx and vp arguments. If JS_IsConstructing is true, * JS_THIS must not be used; the constructor should construct and return a * new object. Otherwise, the native is called as an ordinary function and * JS_THIS may be used. */ static JS_ALWAYS_INLINE JSBool JS_IsConstructing(JSContext *cx, const jsval *vp) { #ifdef DEBUG JSObject *callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)); if (JS_ObjectIsFunction(cx, callee)) { JSFunction *fun = JS_ValueToFunction(cx, JS_CALLEE(cx, vp)); JS_ASSERT(JS_IsConstructor(fun)); } else { JS_ASSERT(JS_GetClass(callee)->construct != NULL); } #else (void)cx; #endif return JSVAL_IS_MAGIC_IMPL(JSVAL_TO_IMPL(vp[1])); } /* * A constructor can request that the JS engine create a default new 'this' * object of the given class, using the callee to determine parentage and * [[Prototype]]. */ extern JS_PUBLIC_API(JSObject *) JS_NewObjectForConstructor(JSContext *cx, JSClass *clasp, const jsval *vp); /************************************************************************/ #ifdef JS_GC_ZEAL #define JS_DEFAULT_ZEAL_FREQ 100 extern JS_PUBLIC_API(void) JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency); extern JS_PUBLIC_API(void) JS_ScheduleGC(JSContext *cx, uint32_t count); #endif extern JS_PUBLIC_API(void) JS_SetParallelCompilationEnabled(JSContext *cx, bool enabled); typedef enum JSCompilerOption { JSCOMPILER_BASELINE_USECOUNT_TRIGGER, JSCOMPILER_ION_USECOUNT_TRIGGER, JSCOMPILER_PJS_ENABLE } JSCompilerOption; extern JS_PUBLIC_API(void) JS_SetGlobalCompilerOption(JSContext *cx, JSCompilerOption opt, uint32_t value); /* * Convert a uint32_t index into a jsid. */ extern JS_PUBLIC_API(JSBool) JS_IndexToId(JSContext *cx, uint32_t index, jsid *id); /* * Convert chars into a jsid. * * |chars| may not be an index. */ extern JS_PUBLIC_API(JSBool) JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, jsid *idp); /* * Test if the given string is a valid ECMAScript identifier */ extern JS_PUBLIC_API(JSBool) JS_IsIdentifier(JSContext *cx, JSString *str, JSBool *isIdentifier); /* * Return the current script and line number of the most currently running * frame. Returns true if a scripted frame was found, false otherwise. */ extern JS_PUBLIC_API(JSBool) JS_DescribeScriptedCaller(JSContext *cx, JSScript **script, unsigned *lineno); /* * Encode/Decode interpreted scripts and functions to/from memory. */ extern JS_PUBLIC_API(void *) JS_EncodeScript(JSContext *cx, JSScript *script, uint32_t *lengthp); extern JS_PUBLIC_API(void *) JS_EncodeInterpretedFunction(JSContext *cx, JSObject *funobj, uint32_t *lengthp); extern JS_PUBLIC_API(JSScript *) JS_DecodeScript(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); extern JS_PUBLIC_API(JSObject *) JS_DecodeInterpretedFunction(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); namespace JS { extern JS_PUBLIC_DATA(const HandleValue) NullHandleValue; extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; extern JS_PUBLIC_DATA(const HandleId) JSID_VOIDHANDLE; extern JS_PUBLIC_DATA(const HandleId) JSID_EMPTYHANDLE; } /* namespace JS */ namespace js { /* * Import some JS:: names into the js namespace so we can make unqualified * references to them. */ using JS::Value; using JS::IsPoisonedValue; using JS::NullValue; using JS::UndefinedValue; using JS::Int32Value; using JS::DoubleValue; using JS::StringValue; using JS::BooleanValue; using JS::ObjectValue; using JS::MagicValue; using JS::NumberValue; using JS::ObjectOrNullValue; using JS::PrivateValue; using JS::PrivateUint32Value; using JS::IsPoisonedPtr; using JS::IsPoisonedId; using JS::StableCharPtr; using JS::TwoByteChars; using JS::Latin1CharsZ; using JS::AutoIdVector; using JS::AutoValueVector; using JS::AutoObjectVector; using JS::AutoFunctionVector; using JS::AutoScriptVector; using JS::AutoIdArray; using JS::AutoGCRooter; using JS::AutoArrayRooter; using JS::AutoVectorRooter; using JS::AutoHashMapRooter; using JS::AutoHashSetRooter; using JS::CallArgs; using JS::IsAcceptableThis; using JS::NativeImpl; using JS::CallReceiver; using JS::CompileOptions; using JS::CallNonGenericMethod; using JS::Rooted; using JS::RootedObject; using JS::RootedModule; using JS::RootedFunction; using JS::RootedScript; using JS::RootedString; using JS::RootedId; using JS::RootedValue; using JS::Handle; using JS::HandleObject; using JS::HandleModule; using JS::HandleFunction; using JS::HandleScript; using JS::HandleString; using JS::HandleId; using JS::HandleValue; using JS::MutableHandle; using JS::MutableHandleObject; using JS::MutableHandleFunction; using JS::MutableHandleScript; using JS::MutableHandleString; using JS::MutableHandleId; using JS::MutableHandleValue; using JS::Zone; } /* namespace js */ #endif /* jsapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsclass.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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" namespace js { class PropertyName; class SpecialId; class PropertyId; // This is equal to JSFunction::class_. Use it in places where you don't want // to #include jsfun.h. extern JS_FRIEND_DATA(js::Class* const) FunctionClassPtr; 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, JSBool *succeeded); typedef JSBool (* DeleteElementOp)(JSContext *cx, HandleObject obj, uint32_t index, JSBool *succeeded); typedef JSBool (* DeleteSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSBool *succeeded); typedef JSObject * (* ObjectOp)(JSContext *cx, HandleObject obj); typedef void (* FinalizeOp)(FreeOp *fop, JSObject *obj); #define JS_CLASS_MEMBERS \ const char *name; \ uint32_t flags; \ \ /* Mandatory function pointer members. */ \ JSPropertyOp addProperty; \ JSDeletePropertyOp delProperty; \ JSPropertyOp getProperty; \ JSStrictPropertyOp setProperty; \ JSEnumerateOp enumerate; \ JSResolveOp resolve; \ JSConvertOp convert; \ \ /* Optional members (may be null). */ \ FinalizeOp finalize; \ 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 pad 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; } bool isCallable() const { return this == js::FunctionClassPtr || call; } 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, ESClass_Date }; /* * 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 GCMethods { static SpecialId initial() { return SpecialId(); } static ThingRootKind kind() { return THING_ROOT_ID; } static bool poisoned(SpecialId id) { return IsPoisonedSpecialId(id); } }; } /* namespace js */ #endif /* jsclass_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsclist.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jscpucfg.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jscpucfg_h #define jscpucfg_h #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_WORD 8 # define JS_BITS_PER_WORD_LOG2 6 # 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_WORD 4 # define JS_BITS_PER_WORD_LOG2 5 #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 /* jscpucfg_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsdbgapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 "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(JSRuntime *rt, 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); /************************************************************************/ // Raw JSScript* because this needs to be callable from a signal handler. extern JS_PUBLIC_API(unsigned) JS_PCToLineNumber(JSContext *cx, JSScript *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_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_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); /* Call the context debug handler on the topmost scripted frame. */ extern JS_FRIEND_API(JSBool) js_CallContextDebugHandler(JSContext *cx); #endif /* jsdbgapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsfriendapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jsfriendapi_h #define jsfriendapi_h #include "mozilla/MemoryReporting.h" #include "jsclass.h" #include "jsprvtd.h" #include "jspubtd.h" #include "js/CallArgs.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) namespace JS { template class Heap; } /* namespace JS */ 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, JSObject *obj); extern JS_FRIEND_API(JSFunction *) JS_GetObjectFunction(JSObject *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(JS::HandleObject 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(JSString *) JS_BasicObjectToString(JSContext *cx, JS::HandleObject obj); extern JS_FRIEND_API(JSBool) js_GetterOnlyPropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool strict, JS::MutableHandleValue vp); JS_FRIEND_API(void) js_ReportOverRecursed(JSContext *maybecx); JS_FRIEND_API(bool) js_ObjectClassIs(JSContext *cx, JS::HandleObject obj, js::ESClassValue classValue); JS_FRIEND_API(const char *) js_ObjectClassName(JSContext *cx, JS::HandleObject obj); JS_FRIEND_API(bool) js_AddObjectRoot(JSRuntime *rt, JSObject **objp); JS_FRIEND_API(void) js_RemoveObjectRoot(JSRuntime *rt, JSObject **objp); #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, JS::HandleObject 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, JS::Handle script, jschar **src, uint32_t *length); extern JS_FRIEND_API(void) JS_SetSourceHook(JSRuntime *rt, JS_SourceHook hook); namespace js { 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); #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); /* * Returns whether we're in a non-strict property set (in that we're in a * non-strict script and the bytecode we're on is a property set). The return * value does NOT indicate any sort of exception was thrown: it's just a * boolean. */ extern JS_FRIEND_API(bool) IsInNonStrictPropertySet(JSContext *cx); 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(mozilla::MallocSizeOf 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; JSObject *_1; 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 { static const size_t LENGTH_SHIFT = 4; size_t lengthAndFlags; const jschar *chars; }; } /* namespace shadow */ // These are equal to |&{Function,Object,OuterWindow}ProxyObject::class_|. Use // them in places where you don't want to #include vm/ProxyObject.h. extern JS_FRIEND_DATA(js::Class* const) FunctionProxyClassPtr; extern JS_FRIEND_DATA(js::Class* const) ObjectProxyClassPtr; extern JS_FRIEND_DATA(js::Class* const) OuterWindowProxyClassPtr; // This is equal to |&JSObject::class_|. Use it in places where you don't want // to #include jsobj.h. extern JS_FRIEND_DATA(js::Class* const) ObjectClassPtr; inline js::Class * GetObjectClass(JSObject *obj) { return reinterpret_cast(obj)->type->clasp; } inline JSClass * GetObjectJSClass(JSObject *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) IsFunctionObject(JSObject *obj); JS_FRIEND_API(bool) IsScopeObject(JSObject *obj); JS_FRIEND_API(bool) IsCallObject(JSObject *obj); inline JSObject * GetObjectParent(JSObject *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(JSObject *obj); JS_FRIEND_API(JSObject *) GetGlobalForObjectCrossCompartment(JSObject *obj); // For legacy consumers only. This whole concept is going away soon. JS_FRIEND_API(JSObject *) DefaultObjectForContextOrNull(JSContext *cx); JS_FRIEND_API(void) SetDefaultObjectForContext(JSContext *cx, JSObject *obj); JS_FRIEND_API(void) NotifyAnimationActivity(JSObject *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, const JSPropertySpec *ps, const JSFunctionSpec *fs, const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs); JS_FRIEND_API(const Value &) GetFunctionNativeReserved(JSObject *fun, size_t which); JS_FRIEND_API(void) SetFunctionNativeReserved(JSObject *fun, size_t which, const Value &val); inline bool GetObjectProto(JSContext *cx, JS::Handle obj, JS::MutableHandle proto) { js::Class *clasp = GetObjectClass(obj); if (clasp == js::ObjectProxyClassPtr || clasp == js::OuterWindowProxyClassPtr || clasp == js::FunctionProxyClassPtr) { return JS_GetPrototype(cx, obj, proto); } proto.set(reinterpret_cast(obj.get())->type->proto); return true; } inline void * GetObjectPrivate(JSObject *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(JSObject *obj, size_t slot) { JS_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); return reinterpret_cast(obj)->slotRef(slot); } JS_FRIEND_API(void) SetReservedSlotWithBarrier(JSObject *obj, size_t slot, const Value &value); inline void SetReservedSlot(JSObject *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(JSObject *obj); inline const Value & GetObjectSlot(JSObject *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 size_t GetAtomLength(JSAtom *atom) { using shadow::Atom; return reinterpret_cast(atom)->lengthAndFlags >> Atom::LENGTH_SHIFT; } inline JSLinearString * AtomToLinearString(JSAtom *atom) { return reinterpret_cast(atom); } static inline js::PropertyOp CastAsJSPropertyOp(JSObject *object) { return JS_DATA_TO_FUNC_PTR(js::PropertyOp, object); } static inline js::StrictPropertyOp CastAsJSStrictPropertyOp(JSObject *object) { return JS_DATA_TO_FUNC_PTR(js::StrictPropertyOp, object); } JS_FRIEND_API(bool) GetPropertyNames(JSContext *cx, JSObject *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(JSObject *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; } inline uintptr_t GetNativeStackLimit(JSContext *cx) { return GetNativeStackLimit(GetRuntime(cx)); } /* * 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(cx), &stackDummy_)) { \ js_ReportOverRecursed(cx); \ onerror; \ } \ JS_END_MACRO #define JS_CHECK_RECURSION_WITH_SP_DONT_REPORT(cx, sp, onerror) \ JS_BEGIN_MACRO \ if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \ 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(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, JSScript *script, void *ip); #ifdef JS_THREADSAFE 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, JS::Handle desc); extern JS_FRIEND_API(AnalysisPurgeCallback) SetAnalysisPurgeCallback(JSRuntime *rt, AnalysisPurgeCallback callback); typedef JSBool (* DOMInstanceClassMatchesProto)(JS::HandleObject 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 DOMProxy proxies in the DOM, for use by ICs. */ /* * The DOMProxyShadowsCheck function will be called to check if the property for * id should be gotten from the prototype, or if there is an own property that * shadows it. * If DoesntShadow is returned then the slot at listBaseExpandoSlot should * either be undefined or point to an expando object that would contain the own * property. * If DoesntShadowUnique is returned then the slot at listBaseExpandoSlot should * contain a private pointer to a ExpandoAndGeneration, which contains a * JS::Value that should either be undefined or point to an expando object, and * a uint32 value. If that value changes then the IC for getting a property will * be invalidated. */ struct ExpandoAndGeneration { ExpandoAndGeneration() : expando(UndefinedValue()), generation(0) {} void Unlink() { ++generation; expando.setUndefined(); } JS::Heap expando; uint32_t generation; }; typedef enum DOMProxyShadowsResult { ShadowCheckFailed, Shadows, DoesntShadow, DoesntShadowUnique } DOMProxyShadowsResult; typedef DOMProxyShadowsResult (* DOMProxyShadowsCheck)(JSContext* cx, JS::HandleObject object, JS::HandleId id); JS_FRIEND_API(void) SetDOMProxyInformation(void *domProxyHandlerFamily, uint32_t domProxyExpandoSlot, DOMProxyShadowsCheck domProxyShadowsCheck); void *GetDOMProxyHandlerFamily(); uint32_t GetDOMProxyExpandoSlot(); DOMProxyShadowsCheck GetDOMProxyShadowsCheck(); } /* 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(JSObject *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 */ /* * A helper for building up an ArrayBuffer object's data * before creating the ArrayBuffer itself. Will do doubling * based reallocation, up to an optional maximum growth given. * * When all the data has been appended, call getArrayBuffer, * passing in the JSContext* for which the ArrayBuffer object * is to be created. This also implicitly resets the builder, * or it can be reset explicitly at any point by calling reset(). */ class ArrayBufferBuilder { void *rawcontents_; uint8_t *dataptr_; uint32_t capacity_; uint32_t length_; public: ArrayBufferBuilder() : rawcontents_(NULL), dataptr_(NULL), capacity_(0), length_(0) { } ~ArrayBufferBuilder() { reset(); } void reset() { if (rawcontents_) JS_free(NULL, rawcontents_); rawcontents_ = dataptr_ = NULL; capacity_ = length_ = 0; } // will truncate if newcap is < length() bool setCapacity(uint32_t newcap) { if (!JS_ReallocateArrayBufferContents(NULL, newcap, &rawcontents_, &dataptr_)) return false; capacity_ = newcap; if (length_ > newcap) length_ = newcap; return true; } // Append datalen bytes from data to the current buffer. If we // need to grow the buffer, grow by doubling the size up to a // maximum of maxgrowth (if given). If datalen is greater than // what the new capacity would end up as, then grow by datalen. // // The data parameter must not overlap with anything beyond the // builder's current valid contents [0..length) bool append(const uint8_t *newdata, uint32_t datalen, uint32_t maxgrowth = 0) { if (length_ + datalen > capacity_) { uint32_t newcap; // double while under maxgrowth or if not specified if (!maxgrowth || capacity_ < maxgrowth) newcap = capacity_ * 2; else newcap = capacity_ + maxgrowth; // but make sure there's always enough to satisfy our request if (newcap < length_ + datalen) newcap = length_ + datalen; // did we overflow? if (newcap < capacity_) return false; if (!setCapacity(newcap)) return false; } // assert that the region isn't overlapping so we can memcpy; JS_ASSERT(!areOverlappingRegions(newdata, datalen, dataptr_ + length_, datalen)); memcpy(dataptr_ + length_, newdata, datalen); length_ += datalen; return true; } uint8_t *data() { return dataptr_; } uint32_t length() { return length_; } uint32_t capacity() { return capacity_; } JSObject* getArrayBuffer(JSContext *cx) { // we need to check for length_ == 0, because nothing may have been // added if (capacity_ > length_ || length_ == 0) { if (!setCapacity(length_)) return NULL; } JSObject* obj = JS_NewArrayBufferWithContents(cx, rawcontents_); if (!obj) return NULL; rawcontents_ = dataptr_ = NULL; length_ = capacity_ = 0; return obj; } protected: static bool areOverlappingRegions(const uint8_t *start1, uint32_t length1, const uint8_t *start2, uint32_t length2) { const uint8_t *end1 = start1 + length1; const uint8_t *end2 = start2 + length2; const uint8_t *max_start = start1 > start2 ? start1 : start2; const uint8_t *min_end = end1 < end2 ? end1 : end2; return max_start < min_end; } }; } /* 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. 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); /* * A class, expected to be passed by value, which represents the CallArgs for a * JSJitGetterOp. */ class JSJitGetterCallArgs : protected JS::MutableHandleValue { public: explicit JSJitGetterCallArgs(const JS::CallArgs& args) : JS::MutableHandleValue(args.rval()) {} explicit JSJitGetterCallArgs(JS::Rooted* rooted) : JS::MutableHandleValue(rooted) {} JS::MutableHandleValue rval() { return *this; } }; /* * A class, expected to be passed by value, which represents the CallArgs for a * JSJitSetterOp. */ class JSJitSetterCallArgs : protected JS::MutableHandleValue { public: explicit JSJitSetterCallArgs(const JS::CallArgs& args) : JS::MutableHandleValue(args[0]) {} JS::MutableHandleValue operator[](unsigned i) { MOZ_ASSERT(i == 0); return *this; } unsigned length() const { return 1; } // Add get() or maybe hasDefined() as needed }; struct JSJitMethodCallArgsTraits; /* * A class, expected to be passed by reference, which represents the CallArgs * for a JSJitMethodOp. */ class JSJitMethodCallArgs : protected JS::detail::CallArgsBase { private: typedef JS::detail::CallArgsBase Base; friend struct JSJitMethodCallArgsTraits; public: explicit JSJitMethodCallArgs(const JS::CallArgs& args) { argv_ = args.array(); argc_ = args.length(); } JS::MutableHandleValue rval() const { return Base::rval(); } unsigned length() const { return Base::length(); } JS::MutableHandleValue operator[](unsigned i) const { return Base::operator[](i); } bool hasDefined(unsigned i) const { return Base::hasDefined(i); } // Add get() as needed }; struct JSJitMethodCallArgsTraits { static const size_t offsetOfArgv = offsetof(JSJitMethodCallArgs, argv_); static const size_t offsetOfArgc = offsetof(JSJitMethodCallArgs, argc_); }; /* * 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 (* JSJitGetterOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, JSJitGetterCallArgs args); typedef bool (* JSJitSetterOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, JSJitSetterCallArgs args); typedef bool (* JSJitMethodOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, const JSJitMethodCallArgs& args); struct JSJitInfo { enum OpType { Getter, Setter, Method, OpType_None }; union { JSJitGetterOp getter; JSJitSetterOp setter; JSJitMethodOp method; }; 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 */ /* An alternative native that's safe to call in parallel mode. */ JSParallelNative parallelNative; }; #define JS_JITINFO_NATIVE_PARALLEL(op) \ {{NULL},0,0,JSJitInfo::OpType_None,false,false,false,JSVAL_TYPE_MISSING,op} static JS_ALWAYS_INLINE const JSJitInfo * FUNCTION_VALUE_TO_JITINFO(const JS::Value& v) { JS_ASSERT(js::GetObjectClass(&v.toObject()) == js::FunctionClassPtr); 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 typedef bool (* ObjectMetadataCallback)(JSContext *cx, JSObject **pmetadata); /* * Specify a callback to invoke when creating each JS object in the current * compartment, which may return a metadata object to associate with the * object. Objects with different metadata have different shape hierarchies, * so for efficiency, objects should generally try to share metadata objects. */ JS_FRIEND_API(void) SetObjectMetadataCallback(JSContext *cx, ObjectMetadataCallback callback); /* Manipulate the metadata associated with an object. */ JS_FRIEND_API(bool) SetObjectMetadata(JSContext *cx, JS::HandleObject obj, JS::HandleObject metadata); JS_FRIEND_API(JSObject *) GetObjectMetadata(JSObject *obj); /* ES5 8.12.8. */ extern JS_FRIEND_API(JSBool) DefaultValue(JSContext *cx, JS::HandleObject obj, JSType hint, MutableHandleValue vp); /* * Helper function. To approximate a call to the [[DefineOwnProperty]] internal * method described in ES5, first call this, then call JS_DefinePropertyById. * * JS_DefinePropertyById by itself does not enforce the invariants on * non-configurable properties when obj->isNative(). This function performs the * relevant checks (specified in ES5 8.12.9 [[DefineOwnProperty]] steps 1-11), * but only if obj is native. * * The reason for the messiness here is that ES5 uses [[DefineOwnProperty]] as * a sort of extension point, but there is no hook in js::Class, * js::ProxyHandler, or the JSAPI with precisely the right semantics for it. */ extern JS_FRIEND_API(bool) CheckDefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, PropertyOp getter, StrictPropertyOp setter, unsigned attrs); } /* 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); #ifdef JSGC_GENERATIONAL extern JS_FRIEND_API(void) JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSObject *key, void *data); extern JS_FRIEND_API(void) JS_StoreStringPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSString *key, void *data); #else inline void JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSObject *key, void *data) {} inline void JS_StoreStringPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSString *key, void *data) {} #endif /* JSGC_GENERATIONAL */ #endif /* jsfriendapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jslock.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jslock_h #define jslock_h #ifdef JS_THREADSAFE # include "jsapi.h" # include "pratom.h" # include "prcvar.h" # include "prinit.h" # include "prlock.h" # include "prthread.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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsperf.h ================================================ /* -*- 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 perf_jsperf_h #define perf_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, JSObject *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 /* perf_jsperf_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsprf.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 #include #include "jstypes.h" /* ** 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsprototypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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) \ macro(Type, 38, js_InitBinaryDataClasses) \ macro(Data, 39, js_InitBinaryDataClasses) \ macro(uint8, 40, js_InitBinaryDataClasses) \ macro(uint16, 41, js_InitBinaryDataClasses) \ macro(uint32, 42, js_InitBinaryDataClasses) \ macro(uint64, 43, js_InitBinaryDataClasses) \ macro(int8, 44, js_InitBinaryDataClasses) \ macro(int16, 45, js_InitBinaryDataClasses) \ macro(int32, 46, js_InitBinaryDataClasses) \ macro(int64, 47, js_InitBinaryDataClasses) \ macro(float32, 48, js_InitBinaryDataClasses) \ macro(float64, 49, js_InitBinaryDataClasses) \ macro(ArrayType, 50, js_InitBinaryDataClasses) \ macro(StructType, 51, js_InitBinaryDataClasses) \ macro(ArrayTypeObject, 52, js_InitBinaryDataClasses) \ #endif /* jsprototypes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsproxy.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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(JSContext *cx, HandleObject proxy, bool *extensible) = 0; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args); virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args); 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 const char *className(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(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) 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 const char *className(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(JSContext *cx, HandleObject proxy, bool *extensible); static bool call(JSContext *cx, HandleObject proxy, const CallArgs &args); static bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args); 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 const char *className(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::ObjectProxyClassPtr || clasp == js::OuterWindowProxyClassPtr; } inline bool IsFunctionProxyClass(const Class *clasp) { return clasp == js::FunctionProxyClassPtr; } inline bool IsProxyClass(const Class *clasp) { return IsObjectProxyClass(clasp) || IsFunctionProxyClass(clasp); } inline bool IsObjectProxy(JSObject *obj) { return IsObjectProxyClass(GetObjectClass(obj)); } inline bool IsFunctionProxy(JSObject *obj) { return IsFunctionProxyClass(GetObjectClass(obj)); } inline bool IsProxy(JSObject *obj) { return IsProxyClass(GetObjectClass(obj)); } /* * These are part of the API. * * NOTE: PROXY_PRIVATE_SLOT 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 PROXY_PRIVATE_SLOT = 0; const uint32_t PROXY_HANDLER_SLOT = 1; const uint32_t PROXY_EXTRA_SLOT = 2; inline BaseProxyHandler * GetProxyHandler(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return (BaseProxyHandler *) GetReservedSlot(obj, PROXY_HANDLER_SLOT).toPrivate(); } inline const Value & GetProxyPrivate(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return GetReservedSlot(obj, PROXY_PRIVATE_SLOT); } inline JSObject * GetProxyTargetObject(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return GetProxyPrivate(obj).toObjectOrNull(); } inline const Value & GetProxyExtra(JSObject *obj, size_t n) { JS_ASSERT(IsProxy(obj)); return GetReservedSlot(obj, PROXY_EXTRA_SLOT + n); } inline void SetProxyHandler(JSObject *obj, BaseProxyHandler *handler) { JS_ASSERT(IsProxy(obj)); SetReservedSlot(obj, PROXY_HANDLER_SLOT, PrivateValue(handler)); } inline void SetProxyExtra(JSObject *obj, size_t n, const Value &extra) { JS_ASSERT(IsProxy(obj)); JS_ASSERT(n <= 1); SetReservedSlot(obj, PROXY_EXTRA_SLOT + n, extra); } enum ProxyCallable { ProxyNotCallable = false, ProxyIsCallable = true }; JS_FRIEND_API(JSObject *) NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue 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, JS::HandleObject obj); #endif /* jsproxy_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsprvtd.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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" #include "js/HashTable.h" #include "js/Vector.h" /* * 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; /* String typedefs. */ class JSDependentString; class JSExtensibleString; class JSExternalString; class JSLinearString; class JSRope; class JSAtom; class JSWrapper; namespace js { struct ArgumentsData; struct Class; class AutoNameVector; class RegExpGuard; class RegExpObject; class RegExpObjectBuilder; class RegExpShared; class RegExpStatics; class MatchPairs; class PropertyName; class LazyScript; enum RegExpFlag { IgnoreCaseFlag = 0x01, GlobalFlag = 0x02, MultilineFlag = 0x04, StickyFlag = 0x08, NoFlags = 0x00, AllFlags = 0x0f }; class StringBuffer; class FrameRegs; class StackFrame; class ScriptFrameIter; class Proxy; class JS_FRIEND_API(AutoEnterPolicy); 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 JSParallelNative ParallelNative; typedef JSThreadSafeNative ThreadSafeNative; typedef JSPropertyOp PropertyOp; typedef JSStrictPropertyOp StrictPropertyOp; typedef JSPropertyDescriptor PropertyDescriptor; struct SourceCompressionToken; namespace frontend { struct BytecodeEmitter; struct Definition; class FullParseHandler; class FunctionBox; class ObjectBox; struct Token; struct TokenPos; class TokenStream; class ParseMapPool; class ParseNode; template class 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 */ /* "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, JS::Handle obj); /* Signature for class initialization ops. */ typedef JSObject * (* JSClassInitializerOp)(JSContext *cx, JS::HandleObject 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, JS::HandleObject obj, JSBool keysonly); #endif /* jsprvtd_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jspubtd.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jspubtd_h #define jspubtd_h /* * JS public API typedefs. */ #include "mozilla/PodOperations.h" #include "jsprototypes.h" #include "jstypes.h" #if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) || defined(DEBUG) # define JSGC_TRACK_EXACT_ROOTS #endif 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; class JS_PUBLIC_API(AutoGCRooter); 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. */ // 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) */ #ifdef WIN32 typedef wchar_t jschar; #else typedef uint16_t jschar; #endif /* * Run-time version enumeration. For compile-time version checking, please use * the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION, * MOZJS_MINOR_VERSION, MOZJS_PATCH_VERSION, and MOZJS_ALPHA definitions. */ 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 see them if * it implements JSTraceCallback. */ JSTRACE_LAZY_SCRIPT, 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; class JSFlatString; class JSFunction; class JSObject; class JSScript; class JSStableString; // long story class JSString; #ifdef JS_THREADSAFE typedef struct PRCallOnceType JSCallOnceType; #else typedef JSBool JSCallOnceType; #endif typedef JSBool (*JSInitCallback)(void); namespace JS { namespace shadow { struct Runtime { /* Restrict zone access during Minor GC. */ bool needsBarrier_; #ifdef JSGC_GENERATIONAL /* Allow inlining of Nursery::isInside. */ uintptr_t gcNurseryStart_; uintptr_t gcNurseryEnd_; #endif Runtime() : needsBarrier_(false) #ifdef JSGC_GENERATIONAL , gcNurseryStart_(0) , gcNurseryEnd_(0) #endif {} }; } /* namespace shadow */ } /* namespace JS */ namespace js { /* * Parallel operations in general can have one of three states. They may * succeed, fail, or "bail", where bail indicates that the code encountered an * unexpected condition and should be re-run sequentially. Different * subcategories of the "bail" state are encoded as variants of TP_RETRY_*. */ enum ParallelResult { TP_SUCCESS, TP_RETRY_SEQUENTIALLY, TP_RETRY_AFTER_GC, TP_FATAL }; struct ThreadSafeContext; struct ForkJoinSlice; class ExclusiveContext; 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_PROPERTY_DESCRIPTOR, 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 {}; template <> struct RootKind : SpecificRootKind {}; struct ContextFriendFields { protected: JSRuntime *const runtime_; /* The current compartment. */ JSCompartment *compartment_; /* The current zone. */ JS::Zone *zone_; public: explicit ContextFriendFields(JSRuntime *rt) : runtime_(rt), compartment_(NULL), zone_(NULL), autoGCRooters(NULL) { #ifdef JSGC_TRACK_EXACT_ROOTS mozilla::PodArrayZero(thingGCRooters); #endif #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) skipGCRooters = NULL; #endif } static const ContextFriendFields *get(const JSContext *cx) { return reinterpret_cast(cx); } static ContextFriendFields *get(JSContext *cx) { return reinterpret_cast(cx); } #ifdef JSGC_TRACK_EXACT_ROOTS /* * 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 /* Stack of thread-stack-allocated GC roots. */ JS::AutoGCRooter *autoGCRooters; friend JSRuntime *GetRuntime(const JSContext *cx); friend JSCompartment *GetContextCompartment(const JSContext *cx); friend JS::Zone *GetContextZone(const JSContext *cx); }; 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 : JS::shadow::Runtime { struct PerThreadDummy { void *field1; uintptr_t field2; #ifdef DEBUG uint64_t field3; #endif } mainThread; }; public: PerThreadDataFriendFields(); #ifdef JSGC_TRACK_EXACT_ROOTS /* * 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 |JS::shadow::Runtime|. // 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 |JS::shadow::Runtime|. // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| return reinterpret_cast( reinterpret_cast(rt) + RuntimeMainThreadOffset); } }; } /* namespace js */ #endif /* jspubtd_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jstypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* ** 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) /*********************************************************************** ** 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsutil.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * PR assertion checker. */ #ifndef jsutil_h #define jsutil_h #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/GuardObjects.h" #ifdef USE_ZLIB #include #endif #include "js/Utility.h" /* 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); } 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 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); } /*****************************************************************************/ /* 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 */ /* 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 MOZ_IS_GCC #if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) # 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 #endif #endif #if !defined(JS_SILENCE_UNUSED_VALUE_IN_EXPR) # define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ JS_BEGIN_MACRO \ expr; \ JS_END_MACRO #endif #endif /* jsutil_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jsversion.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jsversion_h #define jsversion_h /* * Deprecated JS_VERSION handler. */ #ifdef JS_VERSION # if JS_VERSION == 185 # warning "JS_VERSION defined but unsupported (legacy)" # elif JS_VERSION < 185 # error "Unsupported JS_VERSION" # else # error "Unknown JS_VERSION" # endif #endif /* * JS Capability Macros. */ #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 */ /* 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_ASSUME_UNREACHABLE("don't call this! to be used in the new object representation") #endif #endif /* jsversion_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/jswrapper.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 CheckedUnwrap) will throw. Otherwise, they will succeed. */ void setSafeToUnwrap(bool safe) { mSafeToUnwrap = safe; } 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(JSObject *wrapper); static JSObject *wrappedObject(JSObject *wrapper); unsigned flags() const { return mFlags; } explicit Wrapper(unsigned flags, bool hasPrototype = false); virtual ~Wrapper(); static Wrapper singleton; static Wrapper singletonWithPrototype; }; /* 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(JSContext *cx, HandleObject wrapper, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject wrapper, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject wrapper, const CallArgs &args) 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 const char *className(JSContext *cx, HandleObject proxy) 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(JSContext *cx, HandleObject wrapper, bool *extensible) 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 defaultValue(JSContext *cx, HandleObject wrapper, JSType hint, MutableHandleValue vp) 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(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) 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 const char *className(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 bool getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp, bool *present) MOZ_OVERRIDE; virtual bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop) MOZ_OVERRIDE; static DeadObjectProxy singleton; }; extern JSObject * TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject obj, HandleObject wrappedProto, HandleObject 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(JSObject *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 *) UncheckedUnwrap(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 *) CheckedUnwrap(JSObject *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(JSObject *obj, bool stopAtOuter = true); JS_FRIEND_API(bool) IsCrossCompartmentWrapper(JSObject *obj); bool IsDeadProxyObject(JSObject *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 /* jswrapper_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/AllocPolicy.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * An allocation policy concept, usable for structures and algorithms to * control how memory is allocated and how failures are handled. */ #ifndef mozilla_AllocPolicy_h #define mozilla_AllocPolicy_h #include #include namespace mozilla { /* * Allocation policies are used to implement the standard allocation behaviors * in a customizable way. Additionally, custom behaviors may be added to these * behaviors, such as additionally reporting an error through an out-of-band * mechanism when OOM occurs. The concept modeled here is as follows: * * - public copy constructor, assignment, destructor * - void* malloc_(size_t) * Responsible for OOM reporting when null is returned. * - void* calloc_(size_t) * Responsible for OOM reporting when null is returned. * - void* realloc_(void*, size_t, size_t) * Responsible for OOM reporting when null is returned. 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*) * - void reportAllocOverflow() const * Called on allocation overflow (that is, an allocation implicitly tried * to allocate more than the available memory space -- think allocating an * array of large-size objects, where N * size overflows) before null is * returned. * * mfbt provides (and typically uses by default) only MallocAllocPolicy, which * does nothing more than delegate to the malloc/alloc/free functions. */ /* * A policy that straightforwardly uses malloc/calloc/realloc/free and adds no * extra behaviors. */ class MallocAllocPolicy { public: void* malloc_(size_t bytes) { return malloc(bytes); } void* calloc_(size_t bytes) { return calloc(bytes, 1); } void* realloc_(void* p, size_t oldBytes, size_t bytes) { return realloc(p, bytes); } void free_(void* p) { free(p); } void reportAllocOverflow() const {} }; } // namespace mozilla #endif /* mozilla_AllocPolicy_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Array.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 compile-time constant-length array with bounds-checking assertions. */ #ifndef mozilla_Array_h #define mozilla_Array_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include namespace mozilla { template class Array { T arr[Length]; public: T& operator[](size_t i) { MOZ_ASSERT(i < Length); return arr[i]; } const T& operator[](size_t i) const { MOZ_ASSERT(i < Length); return arr[i]; } }; template class Array { public: T& operator[](size_t i) { MOZ_ASSUME_UNREACHABLE("indexing into zero-length array"); } const T& operator[](size_t i) const { MOZ_ASSUME_UNREACHABLE("indexing into zero-length array"); } }; } /* namespace mozilla */ #endif /* mozilla_Array_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Assertions.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "mozilla/Likely.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* in C. * In C++11, static_assert is provided by the compiler to the same effect. * 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 { ... }; * // C * MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0, * "S should be a multiple of word size for efficiency"); * // C++11 * 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. */ #ifndef __cplusplus /* * 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 #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) #else #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) static_assert(!(cond) || (expr), reason) #endif #ifdef __cplusplus extern "C" { #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 or MOZ_CRASH 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 } static MOZ_ALWAYS_INLINE void MOZ_ReportCrash(const char* s, const char* file, int ln) { #ifdef ANDROID __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln); #else fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln); fflush(stderr); #endif } /** * MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH(). You should * call MOZ_CRASH instead. */ #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. * * We follow TerminateProcess() with a call to MOZ_NoReturn() so that the * compiler doesn't hassle us to provide a return statement after a * MOZ_REALLY_CRASH() call. * * (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.) */ __declspec(noreturn) __inline void MOZ_NoReturn() {} # ifdef __cplusplus # define MOZ_REALLY_CRASH() \ do { \ __debugbreak(); \ *((volatile int*) NULL) = 123; \ ::TerminateProcess(::GetCurrentProcess(), 3); \ ::MOZ_NoReturn(); \ } while (0) # else # define MOZ_REALLY_CRASH() \ do { \ __debugbreak(); \ *((volatile int*) NULL) = 123; \ TerminateProcess(GetCurrentProcess(), 3); \ MOZ_NoReturn(); \ } while (0) # endif #else # ifdef __cplusplus # define MOZ_REALLY_CRASH() \ do { \ *((volatile int*) NULL) = 123; \ ::abort(); \ } while (0) # else # define MOZ_REALLY_CRASH() \ do { \ *((volatile int*) NULL) = 123; \ abort(); \ } while (0) # endif #endif /* * MOZ_CRASH([explanation-string]) 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. * * The optional explanation-string, if provided, must be a string literal * explaining why we're crashing. This argument is intended for use with * MOZ_CRASH() calls whose rationale is non-obvious; don't use it if it's * obvious why we're crashing. * * If we're a DEBUG build and we crash at a MOZ_CRASH which provides an * explanation-string, we print the string to stderr. Otherwise, we don't * print anything; this is because we want MOZ_CRASH to be 100% safe in release * builds, and it's hard to print to stderr safely when memory might have been * corrupted. */ #ifndef DEBUG # define MOZ_CRASH(...) MOZ_REALLY_CRASH() #else # define MOZ_CRASH(...) \ do { \ MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \ MOZ_REALLY_CRASH(); \ } while(0) #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 (MOZ_UNLIKELY(!(expr))) { \ MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \ MOZ_REALLY_CRASH(); \ } \ } while (0) /* Now the two-argument form. */ # define MOZ_ASSERT_HELPER2(expr, explain) \ do { \ if (MOZ_UNLIKELY(!(expr))) { \ MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \ MOZ_REALLY_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_ASSUME_UNREACHABLE_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_ASSUME_UNREACHABLE, which uses this when * appropriate. */ #if defined(__clang__) # define MOZ_ASSUME_UNREACHABLE_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_ASSUME_UNREACHABLE_MARKER() __builtin_unreachable() # else # ifdef __cplusplus # define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() # else # define MOZ_ASSUME_UNREACHABLE_MARKER() abort() # endif # endif #elif defined(_MSC_VER) # define MOZ_ASSUME_UNREACHABLE_MARKER() __assume(0) #else # ifdef __cplusplus # define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() # else # define MOZ_ASSUME_UNREACHABLE_MARKER() abort() # endif #endif /* * MOZ_ASSUME_UNREACHABLE([reason]) tells the compiler that it can assume that * the macro call cannot be reached during execution. This lets the compiler * generate better-optimized code under some circumstances, at the expense of * the program's behavior being undefined if control reaches the * MOZ_ASSUME_UNREACHABLE. * * In Gecko, you probably should not use this macro outside of performance- or * size-critical code, because it's unsafe. If you don't care about code size * or performance, you should probably use MOZ_ASSERT or MOZ_CRASH. * * SpiderMonkey is a different beast, and there it's acceptable to use * MOZ_ASSUME_UNREACHABLE more widely. * * Note that MOZ_ASSUME_UNREACHABLE is noreturn, so it's valid not to return a * value following a MOZ_ASSUME_UNREACHABLE call. * * Example usage: * * enum ValueType { * VALUE_STRING, * VALUE_INT, * VALUE_FLOAT * }; * * int ptrToInt(ValueType type, void* value) { * { * // We know for sure that type is either INT or FLOAT, and we want this * // code to run as quickly as possible. * switch (type) { * case VALUE_INT: * return *(int*) value; * case VALUE_FLOAT: * return (int) *(float*) value; * default: * MOZ_ASSUME_UNREACHABLE("can only handle VALUE_INT and VALUE_FLOAT"); * } * } */ #if defined(DEBUG) # define MOZ_ASSUME_UNREACHABLE(...) \ do { \ MOZ_ASSERT(false, "MOZ_ASSUME_UNREACHABLE(" __VA_ARGS__ ")"); \ MOZ_ASSUME_UNREACHABLE_MARKER(); \ } while (0) #else # define MOZ_ASSUME_UNREACHABLE(reason) MOZ_ASSUME_UNREACHABLE_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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Atomics.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 (almost always) lock-free atomic operations. The operations here * are a subset of that which can be found in C++11's header, with a * different API to enforce consistent memory ordering constraints. * * Anyone caught using |volatile| for inter-thread memory safety needs to be * sent a copy of this header and the C++11 standard. */ #ifndef mozilla_Atomics_h #define mozilla_Atomics_h #include "mozilla/Assertions.h" #include "mozilla/TypeTraits.h" #include /* * Our minimum deployment target on clang/OS X is OS X 10.6, whose SDK * does not have . So be sure to check for support * along with C++0x support. */ #if defined(__clang__) /* * clang doesn't like libstdc++'s version of before GCC 4.7, * due to the loose typing of the __sync_* family of functions done by * GCC. We do not have a particularly good way to detect this sort of * case at this point, so just assume that if we're on a Linux system, * we can't use the system's . * * OpenBSD uses an old libstdc++ 4.2.1 and thus doesnt have . */ # if !defined(__linux__) && !defined(__OpenBSD__) && \ (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && \ __has_include() # define MOZ_HAVE_CXX11_ATOMICS # endif /* * Android uses a different C++ standard library that does not provide * support for . * * GCC 4.5.x and 4.6.x's unspecialized std::atomic template doesn't include * inline definitions for the functions declared therein. This oversight * leads to linking errors when using atomic enums. We therefore require * GCC 4.7 or higher. */ #elif defined(__GNUC__) && !defined(__ANDROID__) # include "mozilla/Compiler.h" # if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) && \ MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) # define MOZ_HAVE_CXX11_ATOMICS # endif #elif defined(_MSC_VER) && _MSC_VER >= 1700 # define MOZ_HAVE_CXX11_ATOMICS #endif namespace mozilla { /** * An enum of memory ordering possibilities for atomics. * * Memory ordering is the observable state of distinct values in memory. * (It's a separate concept from atomicity, which concerns whether an * operation can ever be observed in an intermediate state. Don't * conflate the two!) Given a sequence of operations in source code on * memory, it is *not* always the case that, at all times and on all * cores, those operations will appear to have occurred in that exact * sequence. First, the compiler might reorder that sequence, if it * thinks another ordering will be more efficient. Second, the CPU may * not expose so consistent a view of memory. CPUs will often perform * their own instruction reordering, above and beyond that performed by * the compiler. And each core has its own memory caches, and accesses * (reads and writes both) to "memory" may only resolve to out-of-date * cache entries -- not to the "most recently" performed operation in * some global sense. Any access to a value that may be used by * multiple threads, potentially across multiple cores, must therefore * have a memory ordering imposed on it, for all code on all * threads/cores to have a sufficiently coherent worldview. * * http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync and * http://en.cppreference.com/w/cpp/atomic/memory_order go into more * detail on all this, including examples of how each mode works. * * Note that for simplicity and practicality, not all of the modes in * C++11 are supported. The missing C++11 modes are either subsumed by * the modes we provide below, or not relevant for the CPUs we support * in Gecko. These three modes are confusing enough as it is! */ enum MemoryOrdering { /* * Relaxed ordering is the simplest memory ordering: none at all. * When the result of a write is observed, nothing may be inferred * about other memory. Writes ostensibly performed "before" on the * writing thread may not yet be visible. Writes performed "after" on * the writing thread may already be visible, if the compiler or CPU * reordered them. (The latter can happen if reads and/or writes get * held up in per-processor caches.) Relaxed ordering means * operations can always use cached values (as long as the actual * updates to atomic values actually occur, correctly, eventually), so * it's usually the fastest sort of atomic access. For this reason, * *it's also the most dangerous kind of access*. * * Relaxed ordering is good for things like process-wide statistics * counters that don't need to be consistent with anything else, so * long as updates themselves are atomic. (And so long as any * observations of that value can tolerate being out-of-date -- if you * need some sort of up-to-date value, you need some sort of other * synchronizing operation.) It's *not* good for locks, mutexes, * reference counts, etc. that mediate access to other memory, or must * be observably consistent with other memory. * * x86 architectures don't take advantage of the optimization * opportunities that relaxed ordering permits. Thus it's possible * that using relaxed ordering will "work" on x86 but fail elsewhere * (ARM, say, which *does* implement non-sequentially-consistent * relaxed ordering semantics). Be extra-careful using relaxed * ordering if you can't easily test non-x86 architectures! */ Relaxed, /* * When an atomic value is updated with ReleaseAcquire ordering, and * that new value is observed with ReleaseAcquire ordering, prior * writes (atomic or not) are also observable. What ReleaseAcquire * *doesn't* give you is any observable ordering guarantees for * ReleaseAcquire-ordered operations on different objects. For * example, if there are two cores that each perform ReleaseAcquire * operations on separate objects, each core may or may not observe * the operations made by the other core. The only way the cores can * be synchronized with ReleaseAcquire is if they both * ReleaseAcquire-access the same object. This implies that you can't * necessarily describe some global total ordering of ReleaseAcquire * operations. * * ReleaseAcquire ordering is good for (as the name implies) atomic * operations on values controlling ownership of things: reference * counts, mutexes, and the like. However, if you are thinking about * using these to implement your own locks or mutexes, you should take * a good, hard look at actual lock or mutex primitives first. */ ReleaseAcquire, /* * When an atomic value is updated with SequentiallyConsistent * ordering, all writes observable when the update is observed, just * as with ReleaseAcquire ordering. But, furthermore, a global total * ordering of SequentiallyConsistent operations *can* be described. * For example, if two cores perform SequentiallyConsistent operations * on separate objects, one core will observably perform its update * (and all previous operations will have completed), then the other * core will observably perform its update (and all previous * operations will have completed). (Although those previous * operations aren't themselves ordered -- they could be intermixed, * or ordered if they occur on atomic values with ordering * requirements.) SequentiallyConsistent is the *simplest and safest* * ordering of atomic operations -- it's always as if one operation * happens, then another, then another, in some order -- and every * core observes updates to happen in that single order. Because it * has the most synchronization requirements, operations ordered this * way also tend to be slowest. * * SequentiallyConsistent ordering can be desirable when multiple * threads observe objects, and they all have to agree on the * observable order of changes to them. People expect * SequentiallyConsistent ordering, even if they shouldn't, when * writing code, atomic or otherwise. SequentiallyConsistent is also * the ordering of choice when designing lockless data structures. If * you don't know what order to use, use this one. */ SequentiallyConsistent, }; } // namespace mozilla // Build up the underlying intrinsics. #ifdef MOZ_HAVE_CXX11_ATOMICS # include namespace mozilla { namespace detail { /* * We provide CompareExchangeFailureOrder to work around a bug in some * versions of GCC's header. See bug 898491. */ template struct AtomicOrderConstraints; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_relaxed; static const std::memory_order LoadOrder = std::memory_order_relaxed; static const std::memory_order StoreOrder = std::memory_order_relaxed; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_relaxed; }; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_acq_rel; static const std::memory_order LoadOrder = std::memory_order_acquire; static const std::memory_order StoreOrder = std::memory_order_release; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_acquire; }; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_seq_cst; static const std::memory_order LoadOrder = std::memory_order_seq_cst; static const std::memory_order StoreOrder = std::memory_order_seq_cst; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_seq_cst; }; template struct IntrinsicBase { typedef std::atomic ValueType; typedef AtomicOrderConstraints OrderedOp; }; template struct IntrinsicMemoryOps : public IntrinsicBase { typedef IntrinsicBase Base; static T load(const typename Base::ValueType& ptr) { return ptr.load(Base::OrderedOp::LoadOrder); } static void store(typename Base::ValueType& ptr, T val) { ptr.store(val, Base::OrderedOp::StoreOrder); } static T exchange(typename Base::ValueType& ptr, T val) { return ptr.exchange(val, Base::OrderedOp::AtomicRMWOrder); } static bool compareExchange(typename Base::ValueType& ptr, T oldVal, T newVal) { return ptr.compare_exchange_strong(oldVal, newVal, Base::OrderedOp::AtomicRMWOrder, Base::OrderedOp::CompareExchangeFailureOrder); } }; template struct IntrinsicAddSub : public IntrinsicBase { typedef IntrinsicBase Base; static T add(typename Base::ValueType& ptr, T val) { return ptr.fetch_add(val, Base::OrderedOp::AtomicRMWOrder); } static T sub(typename Base::ValueType& ptr, T val) { return ptr.fetch_sub(val, Base::OrderedOp::AtomicRMWOrder); } }; template struct IntrinsicAddSub : public IntrinsicBase { typedef IntrinsicBase Base; static T* add(typename Base::ValueType& ptr, ptrdiff_t val) { return ptr.fetch_add(fixupAddend(val), Base::OrderedOp::AtomicRMWOrder); } static T* sub(typename Base::ValueType& ptr, ptrdiff_t val) { return ptr.fetch_sub(fixupAddend(val), Base::OrderedOp::AtomicRMWOrder); } private: /* * GCC 4.6's header has a bug where adding X to an * atomic is not the same as adding X to a T*. Hence the need * for this function to provide the correct addend. */ static ptrdiff_t fixupAddend(ptrdiff_t val) { #if defined(__clang__) || defined(_MSC_VER) return val; #elif defined(__GNUC__) && MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) && \ !MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) return val * sizeof(T); #else return val; #endif } }; template struct IntrinsicIncDec : public IntrinsicAddSub { typedef IntrinsicBase Base; static T inc(typename Base::ValueType& ptr) { return IntrinsicAddSub::add(ptr, 1); } static T dec(typename Base::ValueType& ptr) { return IntrinsicAddSub::sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { typedef IntrinsicBase Base; static T or_(typename Base::ValueType& ptr, T val) { return ptr.fetch_or(val, Base::OrderedOp::AtomicRMWOrder); } static T xor_(typename Base::ValueType& ptr, T val) { return ptr.fetch_xor(val, Base::OrderedOp::AtomicRMWOrder); } static T and_(typename Base::ValueType& ptr, T val) { return ptr.fetch_and(val, Base::OrderedOp::AtomicRMWOrder); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #elif defined(__GNUC__) namespace mozilla { namespace detail { /* * The __sync_* family of intrinsics is documented here: * * http://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Atomic-Builtins.html * * While these intrinsics are deprecated in favor of the newer __atomic_* * family of intrincs: * * http://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/_005f_005fatomic-Builtins.html * * any GCC version that supports the __atomic_* intrinsics will also support * the header and so will be handled above. We provide a version of * atomics using the __sync_* intrinsics to support older versions of GCC. * * All __sync_* intrinsics that we use below act as full memory barriers, for * both compiler and hardware reordering, except for __sync_lock_test_and_set, * which is a only an acquire barrier. When we call __sync_lock_test_and_set, * we add a barrier above it as appropriate. */ template struct Barrier; /* * Some processors (in particular, x86) don't require quite so many calls to * __sync_sychronize as our specializations of Barrier produce. If * performance turns out to be an issue, defining these specializations * on a per-processor basis would be a good first tuning step. */ template<> struct Barrier { static void beforeLoad() {} static void afterLoad() {} static void beforeStore() {} static void afterStore() {} }; template<> struct Barrier { static void beforeLoad() {} static void afterLoad() { __sync_synchronize(); } static void beforeStore() { __sync_synchronize(); } static void afterStore() {} }; template<> struct Barrier { static void beforeLoad() { __sync_synchronize(); } static void afterLoad() { __sync_synchronize(); } static void beforeStore() { __sync_synchronize(); } static void afterStore() { __sync_synchronize(); } }; template struct IntrinsicMemoryOps { static T load(const T& ptr) { Barrier::beforeLoad(); T val = ptr; Barrier::afterLoad(); return val; } static void store(T& ptr, T val) { Barrier::beforeStore(); ptr = val; Barrier::afterStore(); } static T exchange(T& ptr, T val) { // __sync_lock_test_and_set is only an acquire barrier; loads and stores // can't be moved up from after to before it, but they can be moved down // from before to after it. We may want a stricter ordering, so we need // an explicit barrier. Barrier::beforeStore(); return __sync_lock_test_and_set(&ptr, val); } static bool compareExchange(T& ptr, T oldVal, T newVal) { return __sync_bool_compare_and_swap(&ptr, oldVal, newVal); } }; template struct IntrinsicAddSub { typedef T ValueType; static T add(T& ptr, T val) { return __sync_fetch_and_add(&ptr, val); } static T sub(T& ptr, T val) { return __sync_fetch_and_sub(&ptr, val); } }; template struct IntrinsicAddSub { typedef T* ValueType; /* * The reinterpret_casts are needed so that * __sync_fetch_and_{add,sub} will properly type-check. * * Also, these functions do not provide standard semantics for * pointer types, so we need to adjust the addend. */ static ValueType add(ValueType& ptr, ptrdiff_t val) { ValueType amount = reinterpret_cast(val * sizeof(T)); return __sync_fetch_and_add(&ptr, amount); } static ValueType sub(ValueType& ptr, ptrdiff_t val) { ValueType amount = reinterpret_cast(val * sizeof(T)); return __sync_fetch_and_sub(&ptr, amount); } }; template struct IntrinsicIncDec : public IntrinsicAddSub { static T inc(T& ptr) { return IntrinsicAddSub::add(ptr, 1); } static T dec(T& ptr) { return IntrinsicAddSub::sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { static T or_(T& ptr, T val) { return __sync_fetch_and_or(&ptr, val); } static T xor_(T& ptr, T val) { return __sync_fetch_and_xor(&ptr, val); } static T and_(T& ptr, T val) { return __sync_fetch_and_and(&ptr, val); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #elif defined(_MSC_VER) /* * Windows comes with a full complement of atomic operations. * Unfortunately, most of those aren't available for Windows XP (even if * the compiler supports intrinsics for them), which is the oldest * version of Windows we support. Therefore, we only provide operations * on 32-bit datatypes for 32-bit Windows versions; for 64-bit Windows * versions, we support 64-bit datatypes as well. * * To avoid namespace pollution issues, we declare whatever functions we * need ourselves. */ extern "C" { long __cdecl _InterlockedExchangeAdd(long volatile* dst, long value); long __cdecl _InterlockedOr(long volatile* dst, long value); long __cdecl _InterlockedXor(long volatile* dst, long value); long __cdecl _InterlockedAnd(long volatile* dst, long value); long __cdecl _InterlockedExchange(long volatile *dst, long value); long __cdecl _InterlockedCompareExchange(long volatile *dst, long newVal, long oldVal); } # pragma intrinsic(_InterlockedExchangeAdd) # pragma intrinsic(_InterlockedOr) # pragma intrinsic(_InterlockedXor) # pragma intrinsic(_InterlockedAnd) # pragma intrinsic(_InterlockedExchange) # pragma intrinsic(_InterlockedCompareExchange) namespace mozilla { namespace detail { # if !defined(_M_IX86) && !defined(_M_X64) /* * The implementations below are optimized for x86ish systems. You * will have to modify them if you are porting to Windows on a * different architecture. */ # error "Unknown CPU type" # endif /* * The PrimitiveIntrinsics template should define |Type|, the datatype of size * DataSize upon which we operate, and the following eight functions. * * static Type add(Type* ptr, Type val); * static Type sub(Type* ptr, Type val); * static Type or_(Type* ptr, Type val); * static Type xor_(Type* ptr, Type val); * static Type and_(Type* ptr, Type val); * * These functions perform the obvious operation on the value contained in * |*ptr| combined with |val| and return the value previously stored in * |*ptr|. * * static void store(Type* ptr, Type val); * * This function atomically stores |val| into |*ptr| and must provide a full * memory fence after the store to prevent compiler and hardware instruction * reordering. It should also act as a compiler barrier to prevent reads and * writes from moving to after the store. * * static Type exchange(Type* ptr, Type val); * * This function atomically stores |val| into |*ptr| and returns the previous * contents of *ptr; * * static bool compareExchange(Type* ptr, Type oldVal, Type newVal); * * This function atomically performs the following operation: * * if (*ptr == oldVal) { * *ptr = newVal; * return true; * } else { * return false; * } * */ template struct PrimitiveIntrinsics; template<> struct PrimitiveIntrinsics<4> { typedef long Type; static Type add(Type* ptr, Type val) { return _InterlockedExchangeAdd(ptr, val); } static Type sub(Type* ptr, Type val) { /* * _InterlockedExchangeSubtract isn't available before Windows 7, * and we must support Windows XP. */ return _InterlockedExchangeAdd(ptr, -val); } static Type or_(Type* ptr, Type val) { return _InterlockedOr(ptr, val); } static Type xor_(Type* ptr, Type val) { return _InterlockedXor(ptr, val); } static Type and_(Type* ptr, Type val) { return _InterlockedAnd(ptr, val); } static void store(Type* ptr, Type val) { _InterlockedExchange(ptr, val); } static Type exchange(Type* ptr, Type val) { return _InterlockedExchange(ptr, val); } static bool compareExchange(Type* ptr, Type oldVal, Type newVal) { return _InterlockedCompareExchange(ptr, newVal, oldVal) == oldVal; } }; # if defined(_M_X64) extern "C" { long long __cdecl _InterlockedExchangeAdd64(long long volatile* dst, long long value); long long __cdecl _InterlockedOr64(long long volatile* dst, long long value); long long __cdecl _InterlockedXor64(long long volatile* dst, long long value); long long __cdecl _InterlockedAnd64(long long volatile* dst, long long value); long long __cdecl _InterlockedExchange64(long long volatile* dst, long long value); long long __cdecl _InterlockedCompareExchange64(long long volatile* dst, long long newVal, long long oldVal); } # pragma intrinsic(_InterlockedExchangeAdd64) # pragma intrinsic(_InterlockedOr64) # pragma intrinsic(_InterlockedXor64) # pragma intrinsic(_InterlockedAnd64) # pragma intrinsic(_InterlockedExchange64) # pragma intrinsic(_InterlockedCompareExchange64) template <> struct PrimitiveIntrinsics<8> { typedef __int64 Type; static Type add(Type* ptr, Type val) { return _InterlockedExchangeAdd64(ptr, val); } static Type sub(Type* ptr, Type val) { /* * There is no _InterlockedExchangeSubtract64. */ return _InterlockedExchangeAdd64(ptr, -val); } static Type or_(Type* ptr, Type val) { return _InterlockedOr64(ptr, val); } static Type xor_(Type* ptr, Type val) { return _InterlockedXor64(ptr, val); } static Type and_(Type* ptr, Type val) { return _InterlockedAnd64(ptr, val); } static void store(Type* ptr, Type val) { _InterlockedExchange64(ptr, val); } static Type exchange(Type* ptr, Type val) { return _InterlockedExchange64(ptr, val); } static bool compareExchange(Type* ptr, Type oldVal, Type newVal) { return _InterlockedCompareExchange64(ptr, newVal, oldVal) == oldVal; } }; # endif extern "C" { void _ReadWriteBarrier(); } # pragma intrinsic(_ReadWriteBarrier) template struct Barrier; /* * We do not provide an afterStore method in Barrier, as Relaxed and * ReleaseAcquire orderings do not require one, and the required barrier * for SequentiallyConsistent is handled by PrimitiveIntrinsics. */ template<> struct Barrier { static void beforeLoad() {} static void afterLoad() {} static void beforeStore() {} }; template<> struct Barrier { static void beforeLoad() {} static void afterLoad() { _ReadWriteBarrier(); } static void beforeStore() { _ReadWriteBarrier(); } }; template<> struct Barrier { static void beforeLoad() { _ReadWriteBarrier(); } static void afterLoad() { _ReadWriteBarrier(); } static void beforeStore() { _ReadWriteBarrier(); } }; template struct CastHelper { static PrimType toPrimType(T val) { return static_cast(val); } static T fromPrimType(PrimType val) { return static_cast(val); } }; template struct CastHelper { static PrimType toPrimType(T* val) { return reinterpret_cast(val); } static T* fromPrimType(PrimType val) { return reinterpret_cast(val); } }; template struct IntrinsicBase { typedef T ValueType; typedef PrimitiveIntrinsics Primitives; typedef typename Primitives::Type PrimType; static_assert(sizeof(PrimType) == sizeof(T), "Selection of PrimitiveIntrinsics was wrong"); typedef CastHelper Cast; }; template struct IntrinsicMemoryOps : public IntrinsicBase { static ValueType load(const ValueType& ptr) { Barrier::beforeLoad(); ValueType val = ptr; Barrier::afterLoad(); return val; } static void store(ValueType& ptr, ValueType val) { // For SequentiallyConsistent, Primitives::store() will generate the // proper memory fence. Everything else just needs a barrier before // the store. if (Order == SequentiallyConsistent) { Primitives::store(reinterpret_cast(&ptr), Cast::toPrimType(val)); } else { Barrier::beforeStore(); ptr = val; } } static ValueType exchange(ValueType& ptr, ValueType val) { PrimType oldval = Primitives::exchange(reinterpret_cast(&ptr), Cast::toPrimType(val)); return Cast::fromPrimType(oldval); } static bool compareExchange(ValueType& ptr, ValueType oldVal, ValueType newVal) { return Primitives::compareExchange(reinterpret_cast(&ptr), Cast::toPrimType(oldVal), Cast::toPrimType(newVal)); } }; template struct IntrinsicApplyHelper : public IntrinsicBase { typedef PrimType (*BinaryOp)(PrimType*, PrimType); typedef PrimType (*UnaryOp)(PrimType*); static ValueType applyBinaryFunction(BinaryOp op, ValueType& ptr, ValueType val) { PrimType* primTypePtr = reinterpret_cast(&ptr); PrimType primTypeVal = Cast::toPrimType(val); return Cast::fromPrimType(op(primTypePtr, primTypeVal)); } static ValueType applyUnaryFunction(UnaryOp op, ValueType& ptr) { PrimType* primTypePtr = reinterpret_cast(&ptr); return Cast::fromPrimType(op(primTypePtr)); } }; template struct IntrinsicAddSub : public IntrinsicApplyHelper { static ValueType add(ValueType& ptr, ValueType val) { return applyBinaryFunction(&Primitives::add, ptr, val); } static ValueType sub(ValueType& ptr, ValueType val) { return applyBinaryFunction(&Primitives::sub, ptr, val); } }; template struct IntrinsicAddSub : public IntrinsicApplyHelper { static ValueType add(ValueType& ptr, ptrdiff_t amount) { return applyBinaryFunction(&Primitives::add, ptr, (ValueType)(amount * sizeof(ValueType))); } static ValueType sub(ValueType& ptr, ptrdiff_t amount) { return applyBinaryFunction(&Primitives::sub, ptr, (ValueType)(amount * sizeof(ValueType))); } }; template struct IntrinsicIncDec : public IntrinsicAddSub { static ValueType inc(ValueType& ptr) { return add(ptr, 1); } static ValueType dec(ValueType& ptr) { return sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { static ValueType or_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::or_, ptr, val); } static ValueType xor_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::xor_, ptr, val); } static ValueType and_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::and_, ptr, val); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #else # error "Atomic compiler intrinsics are not supported on your platform" #endif namespace mozilla { namespace detail { template class AtomicBase { // We only support 32-bit types on 32-bit Windows, which constrains our // implementation elsewhere. But we support pointer-sized types everywhere. static_assert(sizeof(T) == 4 || (sizeof(uintptr_t) == 8 && sizeof(T) == 8), "mozilla/Atomics.h only supports 32-bit and pointer-sized types"); protected: typedef typename detail::AtomicIntrinsics Intrinsics; typename Intrinsics::ValueType mValue; public: AtomicBase() : mValue() {} AtomicBase(T aInit) { Intrinsics::store(mValue, aInit); } operator T() const { return Intrinsics::load(mValue); } T operator=(T aValue) { Intrinsics::store(mValue, aValue); return aValue; } /** * Performs an atomic swap operation. aValue is stored and the previous * value of this variable is returned. */ T exchange(T aValue) { return Intrinsics::exchange(mValue, aValue); } /** * Performs an atomic compare-and-swap operation and returns true if it * succeeded. This is equivalent to atomically doing * * if (mValue == aOldValue) { * mValue = aNewValue; * return true; * } else { * return false; * } */ bool compareExchange(T aOldValue, T aNewValue) { return Intrinsics::compareExchange(mValue, aOldValue, aNewValue); } private: template AtomicBase(const AtomicBase& aCopy) MOZ_DELETE; }; template class AtomicBaseIncDec : public AtomicBase { typedef typename detail::AtomicBase Base; public: AtomicBaseIncDec() : Base() {} AtomicBaseIncDec(T aInit) : Base(aInit) {} using Base::operator=; T operator++(int) { return Base::Intrinsics::inc(Base::mValue); } T operator--(int) { return Base::Intrinsics::dec(Base::mValue); } T operator++() { return Base::Intrinsics::inc(Base::mValue) + 1; } T operator--() { return Base::Intrinsics::dec(Base::mValue) - 1; } private: template AtomicBaseIncDec(const AtomicBaseIncDec& aCopy) MOZ_DELETE; }; } // namespace detail /** * A wrapper for a type that enforces that all memory accesses are atomic. * * In general, where a variable |T foo| exists, |Atomic foo| can be used in * its place. Implementations for integral and pointer types are provided * below. * * Atomic accesses are sequentially consistent by default. You should * use the default unless you are tall enough to ride the * memory-ordering roller coaster (if you're not sure, you aren't) and * you have a compelling reason to do otherwise. * * There is one exception to the case of atomic memory accesses: providing an * initial value of the atomic value is not guaranteed to be atomic. This is a * deliberate design choice that enables static atomic variables to be declared * without introducing extra static constructors. */ template class Atomic; /** * Atomic implementation for integral types. * * In addition to atomic store and load operations, compound assignment and * increment/decrement operators are implemented which perform the * corresponding read-modify-write operation atomically. Finally, an atomic * swap method is provided. */ template class Atomic::value>::Type> : public detail::AtomicBaseIncDec { typedef typename detail::AtomicBaseIncDec Base; public: Atomic() : Base() {} Atomic(T aInit) : Base(aInit) {} using Base::operator=; T operator+=(T delta) { return Base::Intrinsics::add(Base::mValue, delta) + delta; } T operator-=(T delta) { return Base::Intrinsics::sub(Base::mValue, delta) - delta; } T operator|=(T val) { return Base::Intrinsics::or_(Base::mValue, val) | val; } T operator^=(T val) { return Base::Intrinsics::xor_(Base::mValue, val) ^ val; } T operator&=(T val) { return Base::Intrinsics::and_(Base::mValue, val) & val; } private: Atomic(Atomic& aOther) MOZ_DELETE; }; /** * Atomic implementation for pointer types. * * An atomic compare-and-swap primitive for pointer variables is provided, as * are atomic increment and decement operators. Also provided are the compound * assignment operators for addition and subtraction. Atomic swap (via * exchange()) is included as well. */ template class Atomic : public detail::AtomicBaseIncDec { typedef typename detail::AtomicBaseIncDec Base; public: Atomic() : Base() {} Atomic(T* aInit) : Base(aInit) {} using Base::operator=; T* operator+=(ptrdiff_t delta) { return Base::Intrinsics::add(Base::mValue, delta) + delta; } T* operator-=(ptrdiff_t delta) { return Base::Intrinsics::sub(Base::mValue, delta) - delta; } private: Atomic(Atomic& aOther) MOZ_DELETE; }; /** * Atomic implementation for enum types. * * The atomic store and load operations and the atomic swap method is provided. */ template class Atomic::value>::Type> : public detail::AtomicBase { typedef typename detail::AtomicBase Base; public: Atomic() : Base() {} Atomic(T aInit) : Base(aInit) {} using Base::operator=; private: Atomic(Atomic& aOther) MOZ_DELETE; }; } // namespace mozilla #endif /* mozilla_Atomics_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Attributes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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). * * The MOZ_ALWAYS_INLINE_EVEN_DEBUG macro is yet stronger. It tells the * compiler to inline even in DEBUG builds. It should be used very rarely. */ #if defined(_MSC_VER) # define MOZ_ALWAYS_INLINE_EVEN_DEBUG __forceinline #elif defined(__GNUC__) # define MOZ_ALWAYS_INLINE_EVEN_DEBUG __attribute__((always_inline)) MOZ_INLINE #else # define MOZ_ALWAYS_INLINE_EVEN_DEBUG MOZ_INLINE #endif #if defined(DEBUG) # define MOZ_ALWAYS_INLINE MOZ_INLINE #else # define MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG #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. * The MOZ_CONSTEXPR_VAR specifier tells a C++11 compiler that a variable's * value may be computed at compile time. It should be prefered to just * marking variables as MOZ_CONSTEXPR because if the compiler does not support * constexpr it will fall back to making the variable const, and some compilers * do not accept variables being marked both const and constexpr. */ #ifdef MOZ_HAVE_CXX11_CONSTEXPR # define MOZ_CONSTEXPR constexpr # define MOZ_CONSTEXPR_VAR constexpr #else # define MOZ_CONSTEXPR /* no support */ # define MOZ_CONSTEXPR_VAR const #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. * MOZ_STACK_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the stack, so it is a compile-time error to use it, or * an array of such objects, as a global or static variable, or as the type of * a new expression (unless placement new is being used). If a member of * another class uses this class, or if another class inherits from this * class, then it is considered to be a stack class as well, although this * attribute need not be provided in such cases. * MOZ_NONHEAP_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the stack or in static storage, so it is a compile-time * error to use it, or an array of such objects, as the type of a new * expression (unless placement new is being used). If a member of another * class uses this class, or if another class inherits from this class, then * it is considered to be a non-heap class as well, although this attribute * need not be provided in such cases. */ #ifdef MOZ_CLANG_PLUGIN # define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override"))) # define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class"))) # define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class"))) #else # define MOZ_MUST_OVERRIDE /* nothing */ # define MOZ_STACK_CLASS /* nothing */ # define MOZ_NONHEAP_CLASS /* nothing */ #endif /* MOZ_CLANG_PLUGIN */ /* * MOZ_THIS_IN_INITIALIZER_LIST is used to avoid a warning when we know that * it's safe to use 'this' in an initializer list. */ #ifdef _MSC_VER # define MOZ_THIS_IN_INITIALIZER_LIST() \ __pragma(warning(push)) \ __pragma(warning(disable:4355)) \ this \ __pragma(warning(pop)) #else # define MOZ_THIS_IN_INITIALIZER_LIST() this #endif #endif /* __cplusplus */ #endif /* mozilla_Attributes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/BloomFilter.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Util.h" #include #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() { 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Casting.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Cast operations to supplement the built-in casting operations. */ #ifndef mozilla_Casting_h #define mozilla_Casting_h #include "mozilla/Assertions.h" #include "mozilla/TypeTraits.h" #include namespace mozilla { /** * Return a value of type |To|, containing the underlying bit pattern of |from|. * * |To| and |From| must be types of the same size; be careful of cross-platform * size differences, or this might fail to compile on some but not all * platforms. */ template inline To BitwiseCast(const From from) { static_assert(sizeof(From) == sizeof(To), "To and From must have the same size"); union { From from; To to; } u; u.from = from; return u.to; } namespace detail { enum ToSignedness { ToIsSigned, ToIsUnsigned }; enum FromSignedness { FromIsSigned, FromIsUnsigned }; template::value ? FromIsSigned : FromIsUnsigned, ToSignedness = IsSigned::value ? ToIsSigned : ToIsUnsigned> struct BoundsCheckImpl; // Implicit conversions on operands to binary operations make this all a bit // hard to verify. Attempt to ease the pain below by *only* comparing values // that are obviously the same type (and will undergo no further conversions), // even when it's not strictly necessary, for explicitness. enum UUComparison { FromIsBigger, FromIsNotBigger }; // Unsigned-to-unsigned range check template sizeof(To)) ? FromIsBigger : FromIsNotBigger> struct UnsignedUnsignedCheck; template struct UnsignedUnsignedCheck { public: static bool checkBounds(const From from) { return from <= From(To(-1)); } }; template struct UnsignedUnsignedCheck { public: static bool checkBounds(const From from) { return true; } }; template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { return UnsignedUnsignedCheck::checkBounds(from); } }; // Signed-to-unsigned range check template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { if (from < 0) return false; if (sizeof(To) >= sizeof(From)) return true; return from <= From(To(-1)); } }; // Unsigned-to-signed range check enum USComparison { FromIsSmaller, FromIsNotSmaller }; template struct UnsignedSignedCheck; template struct UnsignedSignedCheck { public: static bool checkBounds(const From from) { return true; } }; template struct UnsignedSignedCheck { public: static bool checkBounds(const From from) { const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); return from <= From(MaxValue); } }; template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { return UnsignedSignedCheck::checkBounds(from); } }; // Signed-to-signed range check template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { if (sizeof(From) <= sizeof(To)) return true; const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); const To MinValue = -MaxValue - To(1); return From(MinValue) <= from && From(from) <= From(MaxValue); } }; template::value && IsIntegral::value> class BoundsChecker; template class BoundsChecker { public: static bool checkBounds(const From from) { return true; } }; template class BoundsChecker { public: static bool checkBounds(const From from) { return BoundsCheckImpl::checkBounds(from); } }; template inline bool IsInBounds(const From from) { return BoundsChecker::checkBounds(from); } } // namespace detail /** * Cast a value of integral type |From| to a value of integral type |To|, * asserting that the cast will be a safe cast per C++ (that is, that |to| is in * the range of values permitted for the type |From|). */ template inline To SafeCast(const From from) { MOZ_ASSERT((detail::IsInBounds(from))); return static_cast(from); } } // namespace mozilla #endif /* mozilla_Casting_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Char16.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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) static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?"); static_assert(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?"); static_assert(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?"); #endif /* mozilla_Char16_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/CheckedInt.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 #include #ifdef MOZ_CHECKEDINT_USE_MFBT # include "mozilla/Assertions.h" #else # include # 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; }; 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 IsModValidImpl; template inline bool IsModValid(T x, T y) { return IsModValidImpl::run(x, y); } /* * Mod is pretty simple. * For now, let's just use the ANSI C definition: * If x or y are negative, the results are implementation defined. * Consider these invalid. * Undefined for y=0. * The result will never exceed either x or y. * * Checking that x>=0 is a warning when T is unsigned. */ template struct IsModValidImpl { static inline bool run(T x, T y) { return y >= 1; } }; template struct IsModValidImpl { static inline bool run(T x, T y) { if (x < 0) return false; return y >= 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) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); } friend struct 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)) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); } template friend class CheckedInt; template CheckedInt toChecked() const { CheckedInt ret(mValue); ret.mIsValid = ret.mIsValid && mIsValid; return ret; } /** Constructs a valid checked integer with initial value 0 */ CheckedInt() : mValue(0), mIsValid(true) { 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); 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, /) MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mod, %) #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) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); 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(/, /=) 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Compiler.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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__) #define MOZ_IS_GCC 1 /* * 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 #else #define MOZ_IS_GCC 0 #endif #endif /* mozilla_Compiler_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Constants.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/DebugOnly.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Decimal.h ================================================ /* * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "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 COPYRIGHT * OWNER OR CONTRIBUTORS 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. */ /** * Imported from: * http://src.chromium.org/viewvc/blink/trunk/Source/core/platform/Decimal.h * Check hg log for the svn rev of the last update from Blink core. */ #ifndef Decimal_h #define Decimal_h #include "mozilla/Assertions.h" #include #include "mozilla/Types.h" #include #ifndef ASSERT #define DEFINED_ASSERT_FOR_DECIMAL_H 1 #define ASSERT MOZ_ASSERT #endif // To use WTF_MAKE_FAST_ALLOCATED we'd need: // http://src.chromium.org/viewvc/blink/trunk/Source/wtf/FastMalloc.h // Since we don't allocate Decimal objects, no need. #define WTF_MAKE_FAST_ALLOCATED \ void ignore_this_dummy_method() MOZ_DELETE namespace WebCore { namespace DecimalPrivate { class SpecialValueHandler; } // This class represents decimal base floating point number. // // FIXME: Once all C++ compiler support decimal type, we should replace this // class to compiler supported one. See below URI for current status of decimal // type for C++: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1977.html class Decimal { WTF_MAKE_FAST_ALLOCATED; public: enum Sign { Positive, Negative, }; // You should not use EncodedData other than unit testing. class EncodedData { // For accessing FormatClass. friend class Decimal; friend class DecimalPrivate::SpecialValueHandler; public: EncodedData(Sign, int exponent, uint64_t coefficient); bool operator==(const EncodedData&) const; bool operator!=(const EncodedData& another) const { return !operator==(another); } uint64_t coefficient() const { return m_coefficient; } int countDigits() const; int exponent() const { return m_exponent; } bool isFinite() const { return !isSpecial(); } bool isInfinity() const { return m_formatClass == ClassInfinity; } bool isNaN() const { return m_formatClass == ClassNaN; } bool isSpecial() const { return m_formatClass == ClassInfinity || m_formatClass == ClassNaN; } bool isZero() const { return m_formatClass == ClassZero; } Sign sign() const { return m_sign; } void setSign(Sign sign) { m_sign = sign; } private: enum FormatClass { ClassInfinity, ClassNormal, ClassNaN, ClassZero, }; EncodedData(Sign, FormatClass); FormatClass formatClass() const { return m_formatClass; } uint64_t m_coefficient; int16_t m_exponent; FormatClass m_formatClass; Sign m_sign; }; MFBT_API Decimal(int32_t = 0); MFBT_API Decimal(Sign, int exponent, uint64_t coefficient); MFBT_API Decimal(const Decimal&); MFBT_API Decimal& operator=(const Decimal&); MFBT_API Decimal& operator+=(const Decimal&); MFBT_API Decimal& operator-=(const Decimal&); MFBT_API Decimal& operator*=(const Decimal&); MFBT_API Decimal& operator/=(const Decimal&); MFBT_API Decimal operator-() const; MFBT_API bool operator==(const Decimal&) const; MFBT_API bool operator!=(const Decimal&) const; MFBT_API bool operator<(const Decimal&) const; MFBT_API bool operator<=(const Decimal&) const; MFBT_API bool operator>(const Decimal&) const; MFBT_API bool operator>=(const Decimal&) const; MFBT_API Decimal operator+(const Decimal&) const; MFBT_API Decimal operator-(const Decimal&) const; MFBT_API Decimal operator*(const Decimal&) const; MFBT_API Decimal operator/(const Decimal&) const; int exponent() const { ASSERT(isFinite()); return m_data.exponent(); } bool isFinite() const { return m_data.isFinite(); } bool isInfinity() const { return m_data.isInfinity(); } bool isNaN() const { return m_data.isNaN(); } bool isNegative() const { return sign() == Negative; } bool isPositive() const { return sign() == Positive; } bool isSpecial() const { return m_data.isSpecial(); } bool isZero() const { return m_data.isZero(); } MFBT_API Decimal abs() const; MFBT_API Decimal ceiling() const; MFBT_API Decimal floor() const; MFBT_API Decimal remainder(const Decimal&) const; MFBT_API Decimal round() const; MFBT_API double toDouble() const; // Note: toString method supports infinity and nan but fromString not. MFBT_API std::string toString() const; MFBT_API bool toString(char* strBuf, size_t bufLength) const; static MFBT_API Decimal fromDouble(double); // fromString supports following syntax EBNF: // number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)? // | sign? '.' digit+ (exponent-marker sign? digit+)? // sign ::= '+' | '-' // exponent-marker ::= 'e' | 'E' // digit ::= '0' | '1' | ... | '9' // Note: fromString doesn't support "infinity" and "nan". static MFBT_API Decimal fromString(const std::string& aValue); static MFBT_API Decimal infinity(Sign); static MFBT_API Decimal nan(); static MFBT_API Decimal zero(Sign); // You should not use below methods. We expose them for unit testing. MFBT_API explicit Decimal(const EncodedData&); const EncodedData& value() const { return m_data; } private: struct AlignedOperands { uint64_t lhsCoefficient; uint64_t rhsCoefficient; int exponent; }; MFBT_API Decimal(double); MFBT_API Decimal compareTo(const Decimal&) const; static MFBT_API AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs); static inline Sign invertSign(Sign sign) { return sign == Negative ? Positive : Negative; } Sign sign() const { return m_data.sign(); } EncodedData m_data; }; } // namespace WebCore namespace mozilla { typedef WebCore::Decimal Decimal; } #undef WTF_MAKE_FAST_ALLOCATED #ifdef DEFINED_ASSERT_FOR_DECIMAL_H #undef DEFINED_ASSERT_FOR_DECIMAL_H #undef ASSERT #endif #endif // Decimal_h ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Endian.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Functions for reading and writing integers in various endiannesses. */ /* * The classes LittleEndian and BigEndian expose static methods for * reading and writing 16-, 32-, and 64-bit signed and unsigned integers * in their respective endianness. The naming scheme is: * * {Little,Big}Endian::{read,write}{Uint,Int} * * For instance, LittleEndian::readInt32 will read a 32-bit signed * integer from memory in little endian format. Similarly, * BigEndian::writeUint16 will write a 16-bit unsigned integer to memory * in big-endian format. * * The class NativeEndian exposes methods for conversion of existing * data to and from the native endianness. These methods are intended * for cases where data needs to be transferred, serialized, etc. * swap{To,From}{Little,Big}Endian byteswap a single value if necessary. * Bulk conversion functions are also provided which optimize the * no-conversion-needed case: * * - copyAndSwap{To,From}{Little,Big}Endian; * - swap{To,From}{Little,Big}EndianInPlace. * * The *From* variants are intended to be used for reading data and the * *To* variants for writing data. * * Methods on NativeEndian work with integer data of any type. * Floating-point data is not supported. * * For clarity in networking code, "Network" may be used as a synonym * for "Big" in any of the above methods or class names. * * As an example, reading a file format header whose fields are stored * in big-endian format might look like: * * class ExampleHeader * { * private: * uint32_t magic; * uint32_t length; * uint32_t totalRecords; * uint64_t checksum; * * public: * ExampleHeader(const void* data) { * const uint8_t* ptr = static_cast(data); * magic = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * length = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * totalRecords = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * checksum = BigEndian::readUint64(ptr); * } * ... * }; */ #ifndef mozilla_Endian_h #define mozilla_Endian_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/DebugOnly.h" #include "mozilla/TypeTraits.h" #include #include #if defined(_MSC_VER) && _MSC_VER >= 1300 # include # pragma intrinsic(_byteswap_ushort) # pragma intrinsic(_byteswap_ulong) # pragma intrinsic(_byteswap_uint64) #endif #if defined(_WIN64) # if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) # define MOZ_LITTLE_ENDIAN 1 # else # error "CPU type is unknown" # endif #elif defined(_WIN32) # if defined(_M_IX86) # define MOZ_LITTLE_ENDIAN 1 # else # error "CPU type is unknown" # endif #elif defined(__APPLE__) # if __LITTLE_ENDIAN__ # define MOZ_LITTLE_ENDIAN 1 # elif __BIG_ENDIAN__ # define MOZ_BIG_ENDIAN 1 # endif #elif defined(__GNUC__) && \ defined(__BYTE_ORDER__) && \ defined(__ORDER_LITTLE_ENDIAN__) && \ defined(__ORDER_BIG_ENDIAN__) /* * Some versions of GCC provide architecture-independent macros for * this. Yes, there are more than two values for __BYTE_ORDER__. */ # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define MOZ_LITTLE_ENDIAN 1 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define MOZ_BIG_ENDIAN 1 # else # error "Can't handle mixed-endian architectures" # endif /* * We can't include useful headers like or * here because they're not present on all platforms. Instead we have * this big conditional that ideally will catch all the interesting * cases. */ #elif defined(__sparc) || defined(__sparc__) || \ defined(_POWER) || defined(__powerpc__) || \ defined(__ppc__) || defined(__hppa) || \ defined(_MIPSEB) || defined(__ARMEB__) || \ defined(__s390__) || \ (defined(__sh__) && defined(__LITTLE_ENDIAN__)) || \ (defined(__ia64) && defined(__BIG_ENDIAN__)) # define MOZ_BIG_ENDIAN 1 #elif defined(__i386) || defined(__i386__) || \ defined(__x86_64) || defined(__x86_64__) || \ defined(_MIPSEL) || defined(__ARMEL__) || \ defined(__alpha__) || \ (defined(__sh__) && defined(__BIG_ENDIAN__)) || \ (defined(__ia64) && !defined(__BIG_ENDIAN__)) # define MOZ_LITTLE_ENDIAN 1 #endif #if MOZ_BIG_ENDIAN # define MOZ_LITTLE_ENDIAN 0 #elif MOZ_LITTLE_ENDIAN # define MOZ_BIG_ENDIAN 0 #else # error "Cannot determine endianness" #endif #if defined(__clang__) # if __has_builtin(__builtin_bswap16) # define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 # endif #elif defined(__GNUC__) # if MOZ_GCC_VERSION_AT_LEAST(4, 8, 0) # define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 # endif #elif defined(_MSC_VER) # define MOZ_HAVE_BUILTIN_BYTESWAP16 _byteswap_ushort #endif namespace mozilla { namespace detail { /* * We need wrappers here because free functions with default template * arguments and/or partial specialization of function templates are not * supported by all the compilers we use. */ template struct Swapper; template struct Swapper { static T swap(T value) { #if defined(MOZ_HAVE_BUILTIN_BYTESWAP16) return MOZ_HAVE_BUILTIN_BYTESWAP16(value); #else return T(((value & 0x00ff) << 8) | ((value & 0xff00) >> 8)); #endif } }; template struct Swapper { static T swap(T value) { #if defined(__clang__) || defined(__GNUC__) return T(__builtin_bswap32(value)); #elif defined(_MSC_VER) return T(_byteswap_ulong(value)); #else return T(((value & 0x000000ffU) << 24) | ((value & 0x0000ff00U) << 8) | ((value & 0x00ff0000U) >> 8) | ((value & 0xff000000U) >> 24)); #endif } }; template struct Swapper { static inline T swap(T value) { #if defined(__clang__) || defined(__GNUC__) return T(__builtin_bswap64(value)); #elif defined(_MSC_VER) return T(_byteswap_uint64(value)); #else return T(((value & 0x00000000000000ffULL) << 56) | ((value & 0x000000000000ff00ULL) << 40) | ((value & 0x0000000000ff0000ULL) << 24) | ((value & 0x00000000ff000000ULL) << 8) | ((value & 0x000000ff00000000ULL) >> 8) | ((value & 0x0000ff0000000000ULL) >> 24) | ((value & 0x00ff000000000000ULL) >> 40) | ((value & 0xff00000000000000ULL) >> 56)); #endif } }; enum Endianness { Little, Big }; #if MOZ_BIG_ENDIAN # define MOZ_NATIVE_ENDIANNESS detail::Big #else # define MOZ_NATIVE_ENDIANNESS detail::Little #endif class EndianUtils { /** * Assert that the memory regions [dest, dest+count) and [src, src+count] * do not overlap. count is given in bytes. */ static void assertNoOverlap(const void* dest, const void* src, size_t count) { DebugOnly byteDestPtr = static_cast(dest); DebugOnly byteSrcPtr = static_cast(src); MOZ_ASSERT((byteDestPtr < byteSrcPtr && byteDestPtr + count <= byteSrcPtr) || (byteSrcPtr < byteDestPtr && byteSrcPtr + count <= byteDestPtr)); } template static void assertAligned(T* ptr) { MOZ_ASSERT((uintptr_t(ptr) % sizeof(T)) == 0, "Unaligned pointer!"); } protected: /** * Return |value| converted from SourceEndian encoding to DestEndian * encoding. */ template static inline T maybeSwap(T value) { if (SourceEndian == DestEndian) return value; return Swapper::swap(value); } /** * Convert |count| elements at |ptr| from SourceEndian encoding to * DestEndian encoding. */ template static inline void maybeSwapInPlace(T* ptr, size_t count) { assertAligned(ptr); if (SourceEndian == DestEndian) return; for (size_t i = 0; i < count; i++) ptr[i] = Swapper::swap(ptr[i]); } /** * Write |count| elements to the unaligned address |dest| in DestEndian * format, using elements found at |src| in SourceEndian format. */ template static void copyAndSwapTo(void* dest, const T* src, size_t count) { assertNoOverlap(dest, src, count * sizeof(T)); assertAligned(src); if (SourceEndian == DestEndian) { memcpy(dest, src, count * sizeof(T)); return; } uint8_t* byteDestPtr = static_cast(dest); for (size_t i = 0; i < count; ++i) { union { T val; uint8_t buffer[sizeof(T)]; } u; u.val = maybeSwap(src[i]); memcpy(byteDestPtr, u.buffer, sizeof(T)); byteDestPtr += sizeof(T); } } /** * Write |count| elements to |dest| in DestEndian format, using elements * found at the unaligned address |src| in SourceEndian format. */ template static void copyAndSwapFrom(T* dest, const void* src, size_t count) { assertNoOverlap(dest, src, count * sizeof(T)); assertAligned(dest); if (SourceEndian == DestEndian) { memcpy(dest, src, count * sizeof(T)); return; } const uint8_t* byteSrcPtr = static_cast(src); for (size_t i = 0; i < count; ++i) { union { T val; uint8_t buffer[sizeof(T)]; } u; memcpy(u.buffer, byteSrcPtr, sizeof(T)); dest[i] = maybeSwap(u.val); byteSrcPtr += sizeof(T); } } }; template class Endian : private EndianUtils { protected: /** Read a uint16_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint16_t readUint16(const void* p) { return read(p); } /** Read a uint32_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint32_t readUint32(const void* p) { return read(p); } /** Read a uint64_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint64_t readUint64(const void* p) { return read(p); } /** Read an int16_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int16_t readInt16(const void* p) { return read(p); } /** Read an int32_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int32_t readInt32(const void* p) { return read(p); } /** Read an int64_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int64_t readInt64(const void* p) { return read(p); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint16(void* p, uint16_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint32(void* p, uint32_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint64(void* p, uint64_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt16(void* p, int16_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt32(void* p, int32_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt64(void* p, int64_t val) { write(p, val); } /* * Converts a value of type T to little-endian format. * * This function is intended for cases where you have data in your * native-endian format and you need it to appear in little-endian * format for transmission. */ template MOZ_WARN_UNUSED_RESULT static T swapToLittleEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to little-endian format if ThisEndian is Big. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapToLittleEndian(void* dest, const T* src, size_t count) { copyAndSwapTo(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapToLittleEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Converts a value of type T to big-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapToBigEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to big-endian format if ThisEndian is Little. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapToBigEndian(void* dest, const T* src, size_t count) { copyAndSwapTo(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapToBigEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Synonyms for the big-endian functions, for better readability * in network code. */ template MOZ_WARN_UNUSED_RESULT static T swapToNetworkOrder(T value) { return swapToBigEndian(value); } template static void copyAndSwapToNetworkOrder(void* dest, const T* src, size_t count) { copyAndSwapToBigEndian(dest, src, count); } template static void swapToNetworkOrderInPlace(T* p, size_t count) { swapToBigEndianInPlace(p, count); } /* * Converts a value of type T from little-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapFromLittleEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to little-endian format if ThisEndian is Big. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapFromLittleEndian(T* dest, const void* src, size_t count) { copyAndSwapFrom(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapFromLittleEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Converts a value of type T from big-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapFromBigEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to big-endian format if ThisEndian is Little. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapFromBigEndian(T* dest, const void* src, size_t count) { copyAndSwapFrom(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapFromBigEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Synonyms for the big-endian functions, for better readability * in network code. */ template MOZ_WARN_UNUSED_RESULT static T swapFromNetworkOrder(T value) { return swapFromBigEndian(value); } template static void copyAndSwapFromNetworkOrder(T* dest, const void* src, size_t count) { copyAndSwapFromBigEndian(dest, src, count); } template static void swapFromNetworkOrderInPlace(T* p, size_t count) { swapFromBigEndianInPlace(p, count); } private: /** * Read a value of type T, encoded in endianness ThisEndian from |p|. * Return that value encoded in native endianness. */ template static T read(const void* p) { union { T val; uint8_t buffer[sizeof(T)]; } u; memcpy(u.buffer, p, sizeof(T)); return maybeSwap(u.val); } /** * Write a value of type T, in native endianness, to |p|, in ThisEndian * endianness. */ template static void write(void* p, T value) { T tmp = maybeSwap(value); memcpy(p, &tmp, sizeof(T)); } Endian() MOZ_DELETE; Endian(const Endian& other) MOZ_DELETE; void operator=(const Endian& other) MOZ_DELETE; }; template class EndianReadWrite : public Endian { private: typedef Endian super; public: using super::readUint16; using super::readUint32; using super::readUint64; using super::readInt16; using super::readInt32; using super::readInt64; using super::writeUint16; using super::writeUint32; using super::writeUint64; using super::writeInt16; using super::writeInt32; using super::writeInt64; }; } /* namespace detail */ class LittleEndian MOZ_FINAL : public detail::EndianReadWrite {}; class BigEndian MOZ_FINAL : public detail::EndianReadWrite {}; typedef BigEndian NetworkEndian; class NativeEndian MOZ_FINAL : public detail::Endian { private: typedef detail::Endian super; public: /* * These functions are intended for cases where you have data in your * native-endian format and you need the data to appear in the appropriate * endianness for transmission, serialization, etc. */ using super::swapToLittleEndian; using super::copyAndSwapToLittleEndian; using super::swapToLittleEndianInPlace; using super::swapToBigEndian; using super::copyAndSwapToBigEndian; using super::swapToBigEndianInPlace; using super::swapToNetworkOrder; using super::copyAndSwapToNetworkOrder; using super::swapToNetworkOrderInPlace; /* * These functions are intended for cases where you have data in the * given endianness (e.g. reading from disk or a file-format) and you * need the data to appear in native-endian format for processing. */ using super::swapFromLittleEndian; using super::copyAndSwapFromLittleEndian; using super::swapFromLittleEndianInPlace; using super::swapFromBigEndian; using super::copyAndSwapFromBigEndian; using super::swapFromBigEndianInPlace; using super::swapFromNetworkOrder; using super::copyAndSwapFromNetworkOrder; using super::swapFromNetworkOrderInPlace; }; #undef MOZ_NATIVE_ENDIANNESS } /* namespace mozilla */ #endif /* mozilla_Endian_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/EnumSet.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 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_*/ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/FloatingPoint.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Casting.h" #include namespace mozilla { /* * 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. */ /* * 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. */ static_assert(sizeof(double) == sizeof(uint64_t), "double must be 64 bits"); const unsigned DoubleExponentBias = 1023; const unsigned DoubleExponentShift = 52; const uint64_t DoubleSignBit = 0x8000000000000000ULL; const uint64_t DoubleExponentBits = 0x7ff0000000000000ULL; const uint64_t DoubleSignificandBits = 0x000fffffffffffffULL; static_assert((DoubleSignBit & DoubleExponentBits) == 0, "sign bit doesn't overlap exponent bits"); static_assert((DoubleSignBit & DoubleSignificandBits) == 0, "sign bit doesn't overlap significand bits"); static_assert((DoubleExponentBits & DoubleSignificandBits) == 0, "exponent bits don't overlap significand bits"); static_assert((DoubleSignBit | DoubleExponentBits | DoubleSignificandBits) == ~uint64_t(0), "all bits accounted for"); /** Determines whether a double is NaN. */ static MOZ_ALWAYS_INLINE bool IsNaN(double d) { /* * A double is NaN if all exponent bits are 1 and the significand contains at * least one non-zero bit. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleExponentBits) == DoubleExponentBits && (bits & DoubleSignificandBits) != 0; } /** Determines whether a double is +Infinity or -Infinity. */ static MOZ_ALWAYS_INLINE bool IsInfinite(double d) { /* Infinities have all exponent bits set to 1 and an all-0 significand. */ uint64_t bits = BitwiseCast(d); return (bits & ~DoubleSignBit) == DoubleExponentBits; } /** Determines whether a double is not NaN or infinite. */ static MOZ_ALWAYS_INLINE bool IsFinite(double d) { /* * NaN and Infinities are the only non-finite doubles, and both have all * exponent bits set to 1. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleExponentBits) != DoubleExponentBits; } /** * Determines whether a double is negative. It is an error to call this method * on a double which is NaN. */ static MOZ_ALWAYS_INLINE bool IsNegative(double d) { MOZ_ASSERT(!IsNaN(d), "NaN does not have a sign"); /* The sign bit is set if the double is negative. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleSignBit) != 0; } /** Determines whether a double represents -0. */ static MOZ_ALWAYS_INLINE bool IsNegativeZero(double d) { /* Only the sign bit is set if the double is -0. */ uint64_t bits = BitwiseCast(d); return bits == DoubleSignBit; } /** Returns the exponent portion of the double. */ static MOZ_ALWAYS_INLINE int_fast16_t ExponentComponent(double d) { /* * The exponent component of a double is an unsigned number, biased from its * actual value. Subtract the bias to retrieve the actual exponent. */ uint64_t bits = BitwiseCast(d); return int_fast16_t((bits & DoubleExponentBits) >> DoubleExponentShift) - int_fast16_t(DoubleExponentBias); } /** Returns +Infinity. */ static MOZ_ALWAYS_INLINE double PositiveInfinity() { /* * Positive infinity has all exponent bits set, sign bit set to 0, and no * significand. */ return BitwiseCast(DoubleExponentBits); } /** Returns -Infinity. */ static MOZ_ALWAYS_INLINE double NegativeInfinity() { /* * Negative infinity has all exponent bits set, sign bit set to 1, and no * significand. */ return BitwiseCast(DoubleSignBit | DoubleExponentBits); } /** Constructs a NaN value with the specified sign bit and significand bits. */ static MOZ_ALWAYS_INLINE double SpecificNaN(int signbit, uint64_t significand) { MOZ_ASSERT(signbit == 0 || signbit == 1); MOZ_ASSERT((significand & ~DoubleSignificandBits) == 0); MOZ_ASSERT(significand & DoubleSignificandBits); double d = BitwiseCast((signbit ? DoubleSignBit : 0) | DoubleExponentBits | significand); MOZ_ASSERT(IsNaN(d)); return d; } /** Computes the smallest non-zero positive double value. */ static MOZ_ALWAYS_INLINE double MinDoubleValue() { return BitwiseCast(uint64_t(1)); } static MOZ_ALWAYS_INLINE bool DoubleIsInt32(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 !IsNegativeZero(d) && d == (*i = int32_t(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 UnspecifiedNaN() { return SpecificNaN(0, 0xfffffffffffffULL); } /** * Compare two doubles for equality, *without* equating -0 to +0, and equating * any NaN value to any other NaN value. (The normal equality operators equate * -0 with +0, and they equate NaN to no other value.) */ static inline bool DoublesAreIdentical(double d1, double d2) { if (IsNaN(d1)) return IsNaN(d2); return BitwiseCast(d1) == BitwiseCast(d2); } } /* namespace mozilla */ #endif /* mozilla_FloatingPoint_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/GuardObjects.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/NullPtr.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(nullptr) { } ~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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/HashFunctions.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 nsHashKeys.h. */ #ifndef mozilla_HashFunctions_h #define mozilla_HashFunctions_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Types.h" #include #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. */ 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Likely.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/LinkedList.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 != nullptr; o = o->getNext()) * o->observe(topic); * } * }; * */ #ifndef mozilla_LinkedList_h #define mozilla_LinkedList_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/NullPtr.h" #ifdef __cplusplus namespace mozilla { template class LinkedList; template class LinkedListElement { /* * It's convenient that we return nullptr 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; public: LinkedListElement() : next(MOZ_THIS_IN_INITIALIZER_LIST()), prev(MOZ_THIS_IN_INITIALIZER_LIST()), isSentinel(false) { } ~LinkedListElement() { if (!isSentinel && isInList()) remove(); } /* * Get the next element in the list, or nullptr 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 nullptr 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(MOZ_THIS_IN_INITIALIZER_LIST()), prev(MOZ_THIS_IN_INITIALIZER_LIST()), isSentinel(nodeKind == NODE_KIND_SENTINEL) { } /* * Return |this| cast to T* if we're a normal node, or return nullptr if * we're a sentinel node. */ T* asT() { if (isSentinel) return nullptr; return static_cast(this); } const T* asT() const { if (isSentinel) return nullptr; 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 nullptr 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 nullptr 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 nullptr. */ 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 nullptr. */ 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_CRASH("element wasn't found in this list!"); #endif } LinkedList& operator=(const LinkedList& other) MOZ_DELETE; LinkedList(const LinkedList& other) MOZ_DELETE; }; } /* namespace mozilla */ #endif /* __cplusplus */ #endif /* mozilla_LinkedList_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/MathAlgorithms.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/TypeTraits.h" #include #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 #if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) # define MOZ_BITSCAN_WINDOWS extern "C" { unsigned char _BitScanForward(unsigned long* Index, unsigned long mask); unsigned char _BitScanReverse(unsigned long* Index, unsigned long mask); # pragma intrinsic(_BitScanForward, _BitScanReverse) # if defined(_M_AMD64) || defined(_M_X64) # define MOZ_BITSCAN_WINDOWS64 unsigned char _BitScanForward64(unsigned long* index, unsigned __int64 mask); unsigned char _BitScanReverse64(unsigned long* index, unsigned __int64 mask); # pragma intrinsic(_BitScanForward64, _BitScanReverse64) # endif } // extern "C" #endif namespace mozilla { namespace detail { #if defined(MOZ_BITSCAN_WINDOWS) inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { unsigned long index; _BitScanReverse(&index, static_cast(u)); return uint_fast8_t(31 - index); } inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { unsigned long index; _BitScanForward(&index, static_cast(u)); return uint_fast8_t(index); } inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { # if defined(MOZ_BITSCAN_WINDOWS64) unsigned long index; _BitScanReverse64(&index, static_cast(u)); return uint_fast8_t(63 - index); # else uint32_t hi = uint32_t(u >> 32); if (hi != 0) return CountLeadingZeroes32(hi); return 32 + CountLeadingZeroes32(uint32_t(u)); # endif } inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { # if defined(MOZ_BITSCAN_WINDOWS64) unsigned long index; _BitScanForward64(&index, static_cast(u)); return uint_fast8_t(index); # else uint32_t lo = uint32_t(u); if (lo != 0) return CountTrailingZeroes32(lo); return 32 + CountTrailingZeroes32(uint32_t(u >> 32)); # endif } # ifdef MOZ_HAVE_BITSCAN64 # undef MOZ_HAVE_BITSCAN64 # endif #elif defined(__clang__) || defined(__GNUC__) # if defined(__clang__) # if !__has_builtin(__builtin_ctz) || !__has_builtin(__builtin_clz) # error "A clang providing __builtin_c[lt]z is required to build" # endif # else // gcc has had __builtin_clz and friends since 3.4: no need to check. # endif inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { return __builtin_clz(u); } inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { return __builtin_ctz(u); } inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { return __builtin_clzll(u); } inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { return __builtin_ctzll(u); } #else # error "Implement these!" inline uint_fast8_t CountLeadingZeroes32(uint32_t u) MOZ_DELETE; inline uint_fast8_t CountTrailingZeroes32(uint32_t u) MOZ_DELETE; inline uint_fast8_t CountLeadingZeroes64(uint64_t u) MOZ_DELETE; inline uint_fast8_t CountTrailingZeroes64(uint64_t u) MOZ_DELETE; #endif } // namespace detail /** * Compute the number of high-order zero bits in the NON-ZERO number |u|. That * is, looking at the bitwise representation of the number, with the highest- * valued bits at the start, return the number of zeroes before the first one * is observed. * * CountLeadingZeroes32(0xF0FF1000) is 0; * CountLeadingZeroes32(0x7F8F0001) is 1; * CountLeadingZeroes32(0x3FFF0100) is 2; * CountLeadingZeroes32(0x1FF50010) is 3; and so on. */ inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { MOZ_ASSERT(u != 0); return detail::CountLeadingZeroes32(u); } /** * Compute the number of low-order zero bits in the NON-ZERO number |u|. That * is, looking at the bitwise representation of the number, with the lowest- * valued bits at the start, return the number of zeroes before the first one * is observed. * * CountTrailingZeroes32(0x0100FFFF) is 0; * CountTrailingZeroes32(0x7000FFFE) is 1; * CountTrailingZeroes32(0x0080FFFC) is 2; * CountTrailingZeroes32(0x0080FFF8) is 3; and so on. */ inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { MOZ_ASSERT(u != 0); return detail::CountTrailingZeroes32(u); } /** Analogous to CountLeadingZeroes32, but for 64-bit numbers. */ inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { MOZ_ASSERT(u != 0); return detail::CountLeadingZeroes64(u); } /** Analogous to CountTrailingZeroes32, but for 64-bit numbers. */ inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { MOZ_ASSERT(u != 0); return detail::CountTrailingZeroes64(u); } namespace detail { template class CeilingLog2; template class CeilingLog2 { public: static uint_fast8_t compute(const T t) { // Check for <= 1 to avoid the == 0 undefined case. return t <= 1 ? 0 : 32 - CountLeadingZeroes32(t - 1); } }; template class CeilingLog2 { public: static uint_fast8_t compute(const T t) { // Check for <= 1 to avoid the == 0 undefined case. return t <= 1 ? 0 : 64 - CountLeadingZeroes64(t - 1); } }; } // namespace detail /** * Compute the log of the least power of 2 greater than or equal to |t|. * * CeilingLog2(0..1) is 0; * CeilingLog2(2) is 1; * CeilingLog2(3..4) is 2; * CeilingLog2(5..8) is 3; * CeilingLog2(9..16) is 4; and so on. */ template inline uint_fast8_t CeilingLog2(const T t) { return detail::CeilingLog2::compute(t); } /** A CeilingLog2 variant that accepts only size_t. */ inline uint_fast8_t CeilingLog2Size(size_t n) { return CeilingLog2(n); } namespace detail { template class FloorLog2; template class FloorLog2 { public: static uint_fast8_t compute(const T t) { return 31 - CountLeadingZeroes32(t | 1); } }; template class FloorLog2 { public: static uint_fast8_t compute(const T t) { return 63 - CountLeadingZeroes64(t | 1); } }; } // namespace detail /** * Compute the log of the greatest power of 2 less than or equal to |t|. * * FloorLog2(0..1) is 0; * FloorLog2(2..3) is 1; * FloorLog2(4..7) is 2; * FloorLog2(8..15) is 3; and so on. */ template inline uint_fast8_t FloorLog2(const T t) { return detail::FloorLog2::compute(t); } /** A FloorLog2 variant that accepts only size_t. */ inline uint_fast8_t FloorLog2Size(size_t n) { return FloorLog2(n); } /* * Compute the smallest power of 2 greater than or equal to |x|. |x| must not * be so great that the computed value would overflow |size_t|. */ inline size_t RoundUpPow2(size_t x) { MOZ_ASSERT(x <= (size_t(1) << (sizeof(size_t) * CHAR_BIT - 1)), "can't round up -- will overflow!"); return size_t(1) << CeilingLog2(x); } } /* namespace mozilla */ #endif /* mozilla_MathAlgorithms_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/MemoryChecking.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/MemoryReporting.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Memory reporting infrastructure. */ #ifndef mozilla_MemoryReporting_h #define mozilla_MemoryReporting_h #include #ifdef __cplusplus namespace mozilla { /* * This is for functions that are like malloc_usable_size. Such functions are * used for measuring the size of data structures. */ typedef size_t (*MallocSizeOf)(const void* p); } /* namespace mozilla */ #endif /* __cplusplus */ typedef size_t (*MozMallocSizeOf)(const void* p); #endif /* mozilla_MemoryReporting_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Move.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* C++11-style, but C++98-usable, "move references" implementation. */ #ifndef mozilla_Move_h #define mozilla_Move_h namespace mozilla { /* * "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 (although 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 a MoveRef * referring to the same value; that's 1). A 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 a 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 mozilla 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(Move(c->x)), y(Move(c->y)) { } * * than the equivalent: * * C(MoveRef c) { new(&x) X(Move(c->x)); new(&y) Y(Move(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 { T* pointer; public: explicit MoveRef(T& t) : pointer(&t) { } T& operator*() const { return *pointer; } T* operator->() const { return pointer; } operator T& () const { return *pointer; } }; template inline MoveRef Move(T& t) { return MoveRef(t); } template inline MoveRef Move(const T& t) { // With some versions of gcc, for a class C, there's an (incorrect) ambiguity // between the C(const C&) constructor and the default C(C&&) C++11 move // constructor, when the constructor is called with a const C& argument. // // This ambiguity manifests with the Move implementation above when Move is // passed const U& for some class U. Calling Move(const U&) returns a // MoveRef, which is then commonly passed to the U constructor, // triggering an implicit conversion to const U&. gcc doesn't know whether to // call U(const U&) or U(U&&), so it wrongly reports a compile error. // // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50442 has since been fixed, so // this is no longer an issue for up-to-date compilers. But there's no harm // in keeping it around for older compilers, so we might as well. See also // bug 686280. return MoveRef(const_cast(t)); } /** Swap |t| and |u| using move-construction if possible. */ template inline void Swap(T& t, T& u) { T tmp(Move(t)); t = Move(u); u = Move(tmp); } } // namespace mozilla #endif /* mozilla_Move_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/NullPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/PodOperations.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * Operations for zeroing POD types, arrays, and so on. * * These operations are preferable to memset, memcmp, and the like because they * don't require remembering to multiply by sizeof(T), array lengths, and so on * everywhere. */ #ifndef mozilla_PodOperations_h #define mozilla_PodOperations_h #include "mozilla/Attributes.h" #include "mozilla/Util.h" #include namespace mozilla { /** Set the contents of |t| to 0. */ template static void PodZero(T* t) { memset(t, 0, sizeof(T)); } /** Set the contents of |nelem| elements starting at |t| to 0. */ template 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 (&t)[N]) MOZ_DELETE; template static void PodZero(T (&t)[N], size_t nelem) MOZ_DELETE; /** Set the contents of the array |t| to zero. */ template static void PodArrayZero(T (&t)[N]) { memset(t, 0, N * sizeof(T)); } /** * Assign |*src| to |*dst|. The locations must not be the same and must not * overlap. */ template static void PodAssign(T* dst, const T* src) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= 1); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= 1); memcpy(reinterpret_cast(dst), reinterpret_cast(src), sizeof(T)); } /** * Copy |nelem| T elements from |src| to |dst|. The two memory ranges must not * overlap! */ template MOZ_ALWAYS_INLINE static void PodCopy(T* dst, const T* src, size_t nelem) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= nelem); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= 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 MOZ_ALWAYS_INLINE static void PodCopy(volatile T* dst, const volatile T* src, size_t nelem) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= nelem); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= nelem); /* * Volatile |dst| requires extra work, because it's undefined behavior to * modify volatile objects using the mem* functions. Just write out the * loops manually, using operator= rather than memcpy for the same reason, * and let the compiler optimize to the extent it can. */ for (const volatile T* srcend = src + nelem; src < srcend; src++, dst++) *dst = *src; } /* * Copy the contents of the array |src| into the array |dst|, both of size N. * The arrays must not overlap! */ template static void PodArrayCopy(T (&dst)[N], const T (&src)[N]) { PodCopy(dst, src, N); } /** * Determine whether the |len| elements at |one| are memory-identical to the * |len| elements at |two|. */ template MOZ_ALWAYS_INLINE static bool PodEqual(const T* one, const T* two, size_t len) { if (len < 128) { const T* p1end = one + len; const T* p1 = one; const T* p2 = two; for (; p1 < p1end; p1++, p2++) { if (*p1 != *p2) return false; } return true; } return !memcmp(one, two, len * sizeof(T)); } } // namespace mozilla #endif /* mozilla_PodOperations_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Poison.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 poison value that can be used to fill a memory space with * an address that leads to a safe crash when dereferenced. */ #ifndef mozilla_Poison_h #define mozilla_Poison_h #include "mozilla/Assertions.h" #include "mozilla/Types.h" #include MOZ_BEGIN_EXTERN_C extern MFBT_DATA uintptr_t gMozillaPoisonValue; /** * @return the poison value. */ inline uintptr_t mozPoisonValue() { return gMozillaPoisonValue; } /** * Overwrite the memory block of aSize bytes at aPtr with the poison value. * aPtr MUST be aligned at a sizeof(uintptr_t) boundary. * Only an even number of sizeof(uintptr_t) bytes are overwritten, the last * few bytes (if any) is not overwritten. */ inline void mozWritePoison(void* aPtr, size_t aSize) { const uintptr_t POISON = mozPoisonValue(); char* p = (char*)aPtr; char* limit = p + aSize; MOZ_ASSERT((uintptr_t)aPtr % sizeof(uintptr_t) == 0, "bad alignment"); MOZ_ASSERT(aSize >= sizeof(uintptr_t), "poisoning this object has no effect"); for (; p < limit; p += sizeof(uintptr_t)) { *((uintptr_t*)p) = POISON; } } /** * Initialize the poison value. * This should only be called once. */ extern MFBT_API void mozPoisonValueInit(); /* Values annotated by CrashReporter */ extern MFBT_DATA uintptr_t gMozillaPoisonBase; extern MFBT_DATA uintptr_t gMozillaPoisonSize; MOZ_END_EXTERN_C #endif /* mozilla_Poison_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Range.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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]; } const T& operator[](size_t offset) const { return mStart[offset]; } operator ConvertibleToBool() const { return mStart ? &Range::nonNull : 0; } }; } // namespace mozilla #endif /* mozilla_Range_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/RangedPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/NullPtr.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, nullptr, 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/ReentrancyGuard.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Small helper class for asserting uses of a class are non-reentrant. */ #ifndef mozilla_ReentrancyGuard_h #define mozilla_ReentrancyGuard_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/GuardObjects.h" namespace mozilla { /* Useful for implementing containers that assert non-reentrancy */ class ReentrancyGuard { MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER #ifdef DEBUG bool& entered; #endif public: template #ifdef DEBUG ReentrancyGuard(T& obj MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : entered(obj.entered) #else ReentrancyGuard(T& MOZ_GUARD_OBJECT_NOTIFIER_PARAM) #endif { MOZ_GUARD_OBJECT_NOTIFIER_INIT; #ifdef DEBUG MOZ_ASSERT(!entered); entered = true; #endif } ~ReentrancyGuard() { #ifdef DEBUG entered = false; #endif } private: ReentrancyGuard(const ReentrancyGuard&) MOZ_DELETE; void operator=(const ReentrancyGuard&) MOZ_DELETE; }; } // namespace mozilla #endif /* mozilla_ReentrancyGuard_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/RefPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Atomics.h" #include "mozilla/Attributes.h" #include "mozilla/TypeTraits.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). */ namespace detail { #ifdef DEBUG static const int DEAD = 0xffffdead; #endif // This is used WeakPtr.h as well as this file. enum RefCountAtomicity { AtomicRefCount, NonAtomicRefCount }; 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: typename Conditional, int>::Type refCnt; }; } template class RefCounted : public detail::RefCounted { public: ~RefCounted() { static_assert(IsBaseOf::value, "T must derive from RefCounted"); } }; /** * AtomicRefCounted is like RefCounted, with an atomically updated * reference counter. */ template class AtomicRefCounted : public detail::RefCounted { public: ~AtomicRefCounted() { static_assert(IsBaseOf::value, "T must derive from AtomicRefCounted"); } }; /** * 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 #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 #endif /* mozilla_RefPtr_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/SHA1.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Types.h" #include #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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Scoped.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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" #include "mozilla/NullPtr.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 nullptr; } 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 nullptr; } const static void release(type value) { if (value) TypeSpecificDelete(value); } }; SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits) } /* namespace mozilla */ #endif /* mozilla_Scoped_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/SplayTree.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/TemplateLib.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * Reusable template meta-functions on types and compile-time values. Meta- * functions are placed inside the 'tl' namespace to avoid conflict with non- * meta functions of the same name (e.g., mozilla::tl::FloorLog2 vs. * mozilla::FloorLog2). * * When constexpr support becomes universal, we should probably use that instead * of some of these templates, for simplicity. */ #ifndef mozilla_TemplateLib_h #define mozilla_TemplateLib_h #include #include namespace mozilla { namespace tl { /** Compute min/max. */ template struct Min { static const size_t value = I < J ? I : J; }; template struct Max { static const size_t value = I > J ? I : J; }; /** Compute floor(log2(i)). */ template struct FloorLog2 { static const size_t value = 1 + FloorLog2::value; }; template<> struct FloorLog2<0> { /* Error */ }; template<> struct FloorLog2<1> { static const size_t value = 0; }; /** Compute ceiling(log2(i)). */ template struct CeilingLog2 { static const size_t value = FloorLog2<2 * I - 1>::value; }; /** Round up to the nearest power of 2. */ template struct RoundUpPow2 { static const size_t value = size_t(1) << CeilingLog2::value; }; template<> struct RoundUpPow2<0> { static const size_t value = 1; }; /** Compute the number of bits in the given unsigned type. */ template struct BitSize { static const size_t value = sizeof(T) * CHAR_BIT; }; /** * Produce an N-bit mask, where N <= BitSize::value. Handle the * language-undefined edge case when N = BitSize::value. */ 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 |value| to assure // its computation. static const size_t checkPrecondition = 0 / size_t(N < BitSize::value); static const size_t value = (size_t(1) << N) - 1 + checkPrecondition; }; template<> struct NBitMask::value> { static const size_t value = 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 value = ~NBitMask::value - CeilingLog2::value>::value; }; template<> struct MulOverflowMask<0> { /* Error */ }; template<> struct MulOverflowMask<1> { static const size_t value = 0; }; } // namespace tl } // namespace mozilla #endif /* mozilla_TemplateLib_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/ThreadLocal.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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" #include "mozilla/NullPtr.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() { 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, nullptr); #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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/TypeTraits.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 { /* Forward declarations. */ template struct RemoveCV; /* 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] */ namespace detail { template struct IsIntegralHelper : FalseType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; } /* namespace detail */ /** * IsIntegral determines whether a type is an integral type. * * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is false; * mozilla::IsIntegral::value is false; * * Note that the behavior of IsIntegral on char16_t and char32_t is * unspecified. */ template struct IsIntegral : detail::IsIntegralHelper::Type> {}; template struct IsSame; namespace detail { template struct IsFloatingPointHelper : IntegralConstant::value || IsSame::value || IsSame::value> {}; } // namespace detail /** * IsFloatingPoint determines whether a type is a floating point type (float, * double, long double). * * mozilla::IsFloatingPoint::value is false; * mozilla::IsFloatingPoint::value is true; * mozilla::IsFloatingPoint::value is true; * mozilla::IsFloatingPoint::value is false. */ template struct IsFloatingPoint : detail::IsFloatingPointHelper::Type> {}; /** * 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 {}; namespace detail { // __is_enum is a supported extension across all of our supported compilers. template struct IsEnumHelper : IntegralConstant {}; } // namespace detail /** * IsEnum determines whether a type is an enum type. * * mozilla::IsEnum::value is true; * mozilla::IsEnum::value is false; * mozilla::IsEnum::value is false; */ template struct IsEnum : detail::IsEnumHelper::Type> {}; /* 20.9.4.2 Composite type traits [meta.unary.comp] */ /** * IsArithmetic determines whether a type is arithmetic. A type is arithmetic * iff it is an integral type or a floating point type. * * mozilla::IsArithmetic::value is true; * mozilla::IsArithmetic::value is true; * mozilla::IsArithmetic::value is false. */ template struct IsArithmetic : IntegralConstant::value || IsFloatingPoint::value> {}; /* 20.9.4.3 Type properties [meta.unary.prop] */ /** * IsConst determines whether a type is const or not. * * mozilla::IsConst::value is false; * mozilla::IsConst::value is true; * mozilla::IsConst::value is false. */ template struct IsConst : FalseType {}; template struct IsConst : TrueType {}; /** * IsVolatile determines whether a type is volatile or not. * * mozilla::IsVolatile::value is false; * mozilla::IsVolatile::value is true; * mozilla::IsVolatile::value is false. */ template struct IsVolatile : FalseType {}; template struct IsVolatile : TrueType {}; /** * 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 {}; namespace detail { template::value> struct IsSignedHelper; template struct IsSignedHelper : TrueType {}; template struct IsSignedHelper : IntegralConstant::value && T(-1) < T(1)> {}; } // namespace detail /** * IsSigned determines whether a type is a signed arithmetic type. |char| is * considered a signed type if it has the same representation as |signed char|. * * Don't use this if the type might be user-defined! You might or might not get * a compile error, depending. * * mozilla::IsSigned::value is true; * mozilla::IsSigned::value is false; * mozilla::IsSigned::value is false; * mozilla::IsSigned::value is true. */ template struct IsSigned : detail::IsSignedHelper {}; namespace detail { template::value> struct IsUnsignedHelper; template struct IsUnsignedHelper : FalseType {}; template struct IsUnsignedHelper : IntegralConstant::value && (IsSame::Type, bool>::value || T(1) < T(-1))> {}; } // namespace detail /** * IsUnsigned determines whether a type is an unsigned arithmetic type. * * Don't use this if the type might be user-defined! You might or might not get * a compile error, depending. * * mozilla::IsUnsigned::value is false; * mozilla::IsUnsigned::value is true; * mozilla::IsUnsigned::value is true; * mozilla::IsUnsigned::value is false. */ template struct IsUnsigned : detail::IsUnsignedHelper {}; /* 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] */ /** * RemoveConst removes top-level const qualifications on a type. * * mozilla::RemoveConst::Type is int; * mozilla::RemoveConst::Type is int; * mozilla::RemoveConst::Type is const int*; * mozilla::RemoveConst::Type is int*. */ template struct RemoveConst { typedef T Type; }; template struct RemoveConst { typedef T Type; }; /** * RemoveVolatile removes top-level volatile qualifications on a type. * * mozilla::RemoveVolatile::Type is int; * mozilla::RemoveVolatile::Type is int; * mozilla::RemoveVolatile::Type is volatile int*; * mozilla::RemoveVolatile::Type is int*. */ template struct RemoveVolatile { typedef T Type; }; template struct RemoveVolatile { typedef T Type; }; /** * RemoveCV removes top-level const and volatile qualifications on a type. * * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int*. */ template struct RemoveCV { typedef typename RemoveConst::Type>::Type Type; }; /* 20.9.7.2 Reference modifications [meta.trans.ref] */ /* 20.9.7.3 Sign modifications [meta.trans.sign] */ template struct EnableIf; template struct Conditional; namespace detail { template struct WithC : Conditional {}; template struct WithV : Conditional {}; template struct WithCV : WithC::Type> {}; template struct CorrespondingSigned; template<> struct CorrespondingSigned { typedef signed char Type; }; template<> struct CorrespondingSigned { typedef signed char Type; }; template<> struct CorrespondingSigned { typedef short Type; }; template<> struct CorrespondingSigned { typedef int Type; }; template<> struct CorrespondingSigned { typedef long Type; }; template<> struct CorrespondingSigned { typedef long long Type; }; template::Type, bool IsSignedIntegerType = IsSigned::value && !IsSame::value> struct MakeSigned; template struct MakeSigned { typedef T Type; }; template struct MakeSigned : WithCV::value, IsVolatile::value, typename CorrespondingSigned::Type> {}; } // namespace detail /** * MakeSigned produces the corresponding signed integer type for a given * integral type T, with the const/volatile qualifiers of T. T must be a * possibly-const/volatile-qualified integral type that isn't bool. * * If T is already a signed integer type (not including char!), then T is * produced. * * Otherwise, if T is an unsigned integer type, the signed variety of T, with * T's const/volatile qualifiers, is produced. * * Otherwise, the integral type of the same size as T, with the lowest rank, * with T's const/volatile qualifiers, is produced. (This basically only acts * to produce signed char when T = char.) * * mozilla::MakeSigned::Type is signed long; * mozilla::MakeSigned::Type is volatile int; * mozilla::MakeSigned::Type is const signed short; * mozilla::MakeSigned::Type is const signed char; * mozilla::MakeSigned is an error; * mozilla::MakeSigned is an error. */ template struct MakeSigned : EnableIf::value && !IsSame::Type>::value, typename detail::MakeSigned >::Type {}; namespace detail { template struct CorrespondingUnsigned; template<> struct CorrespondingUnsigned { typedef unsigned char Type; }; template<> struct CorrespondingUnsigned { typedef unsigned char Type; }; template<> struct CorrespondingUnsigned { typedef unsigned short Type; }; template<> struct CorrespondingUnsigned { typedef unsigned int Type; }; template<> struct CorrespondingUnsigned { typedef unsigned long Type; }; template<> struct CorrespondingUnsigned { typedef unsigned long long Type; }; template::Type, bool IsUnsignedIntegerType = IsUnsigned::value && !IsSame::value> struct MakeUnsigned; template struct MakeUnsigned { typedef T Type; }; template struct MakeUnsigned : WithCV::value, IsVolatile::value, typename CorrespondingUnsigned::Type> {}; } // namespace detail /** * MakeUnsigned produces the corresponding unsigned integer type for a given * integral type T, with the const/volatile qualifiers of T. T must be a * possibly-const/volatile-qualified integral type that isn't bool. * * If T is already an unsigned integer type (not including char!), then T is * produced. * * Otherwise, if T is an signed integer type, the unsigned variety of T, with * T's const/volatile qualifiers, is produced. * * Otherwise, the unsigned integral type of the same size as T, with the lowest * rank, with T's const/volatile qualifiers, is produced. (This basically only * acts to produce unsigned char when T = char.) * * mozilla::MakeUnsigned::Type is unsigned long; * mozilla::MakeUnsigned::Type is volatile unsigned int; * mozilla::MakeUnsigned::Type is const unsigned short; * mozilla::MakeUnsigned::Type is const unsigned char; * mozilla::MakeUnsigned is an error; * mozilla::MakeUnsigned is an error. */ template struct MakeUnsigned : EnableIf::value && !IsSame::Type>::value, typename detail::MakeUnsigned >::Type {}; /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/TypedEnum.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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. * * MOZ_{BEGIN,END}_ENUM_CLASS doesn't work for defining enum classes nested * inside classes. To define an enum class nested inside another class, use * MOZ_{BEGIN,END}_NESTED_ENUM_CLASS, and place a MOZ_FINISH_NESTED_ENUM_CLASS * in namespace scope to handle bits that can only be implemented with * namespace-scoped code. For example: * * class FooBar { * * MOZ_BEGIN_NESTED_ENUM_CLASS(Enum, int32_t) * A, * B = 6 * MOZ_END_NESTED_ENUM_CLASS(Enum) * * }; * * MOZ_FINISH_NESTED_ENUM_CLASS(FooBar::Enum) */ #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_NESTED_ENUM_CLASS(Name, type) \ enum class Name : type { # define MOZ_END_NESTED_ENUM_CLASS(Name) \ }; # define MOZ_FINISH_NESTED_ENUM_CLASS(Name) /* nothing */ #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_NESTED_ENUM_CLASS(Name, type) \ class Name \ { \ public: \ enum Enum MOZ_ENUM_TYPE(type) \ { # define MOZ_END_NESTED_ENUM_CLASS(Name) \ }; \ Name() {} \ Name(Enum aEnum) : mEnum(aEnum) {} \ explicit Name(int num) : mEnum((Enum)num) {} \ operator Enum() const { return mEnum; } \ private: \ Enum mEnum; \ }; # define MOZ_FINISH_NESTED_ENUM_CLASS(Name) \ 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 # define MOZ_BEGIN_ENUM_CLASS(Name, type) MOZ_BEGIN_NESTED_ENUM_CLASS(Name, type) # define MOZ_END_ENUM_CLASS(Name) \ MOZ_END_NESTED_ENUM_CLASS(Name) \ MOZ_FINISH_NESTED_ENUM_CLASS(Name) #endif /* __cplusplus */ #endif /* mozilla_TypedEnum_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Types.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 types and size_t. */ #include #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 /* * GCC's typeof is available when decltype is not. */ #if defined(__GNUC__) && defined(__cplusplus) && \ !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L # define decltype __typeof__ #endif #endif /* mozilla_Types_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Util.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8, t9); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); 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 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/Vector.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/length-parametrized vector class. */ #ifndef mozilla_Vector_h #define mozilla_Vector_h #include "mozilla/AllocPolicy.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/NullPtr.h" #include "mozilla/ReentrancyGuard.h" #include "mozilla/TemplateLib.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.h" #include // for placement new /* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4345) #endif namespace mozilla { template class VectorBase; namespace detail { /* * 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(VectorBase& v, size_t newCap) { MOZ_ASSERT(!v.usingInlineStorage()); MOZ_ASSERT(!CapacityHasExcessSpace(newCap)); T* newbuf = reinterpret_cast(v.malloc_(newCap * sizeof(T))); if (!newbuf) return false; T* dst = newbuf; T* src = v.beginNoCheck(); for (; 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* end = dst + n; dst < end; ++dst) *dst = t; } static inline bool growTo(VectorBase& v, size_t newCap) { MOZ_ASSERT(!v.usingInlineStorage()); MOZ_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; } }; } // namespace detail /* * A CRTP base class for vector-like classes. Unless you really really want * your own vector class -- and you almost certainly don't -- you should use * mozilla::Vector instead! * * See mozilla::Vector for interface requirements. */ template class VectorBase : private AllocPolicy { /* utilities */ static const bool sElemIsPod = IsPod::value; typedef detail::VectorImpl Impl; friend struct detail::VectorImpl; bool growStorageBy(size_t incr); bool convertToHeapStorage(size_t newCap); /* 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 value = sizeof(T); }; template struct ElemSize<0, Dummy> { static const size_t value = 1; }; static const size_t sInlineCapacity = tl::Min::value>::value; /* Calculate inline buffer size; avoid 0-sized array. */ static const size_t sInlineBytes = tl::Max<1, sInlineCapacity * ElemSize::value>::value; /* 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; /* Number of elements in the vector. */ size_t mLength; /* Max number of elements storable in the vector without resizing. */ size_t mCapacity; #ifdef DEBUG /* Max elements of reserved or used space in this vector. */ size_t mReserved; #endif /* Memory used for inline storage. */ AlignedStorage storage; #ifdef DEBUG friend class ReentrancyGuard; bool entered; #endif /* private accessors */ bool usingInlineStorage() const { return mBegin == const_cast(this)->inlineStorage(); } T* inlineStorage() { return static_cast(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 { MOZ_ASSERT(mReserved <= mCapacity); MOZ_ASSERT(mLength <= mReserved); return mReserved; } #endif /* Append operations guaranteed to succeed due to pre-reserved space. */ template void internalAppend(const U& u); template void internalAppendAll(const VectorBase& u); void internalAppendN(const T& t, size_t n); template void internalAppend(const U* begin, size_t length); public: static const size_t sMaxInlineStorage = N; typedef T ElementType; VectorBase(AllocPolicy = AllocPolicy()); VectorBase(MoveRef); /* Move constructor. */ ThisVector& operator=(MoveRef); /* Move assignment. */ ~VectorBase(); /* 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() { MOZ_ASSERT(!entered); return mBegin; } const T* begin() const { MOZ_ASSERT(!entered); return mBegin; } T* end() { MOZ_ASSERT(!entered); return mBegin + mLength; } const T* end() const { MOZ_ASSERT(!entered); return mBegin + mLength; } T& operator[](size_t i) { MOZ_ASSERT(!entered); MOZ_ASSERT(i < mLength); return begin()[i]; } const T& operator[](size_t i) const { MOZ_ASSERT(!entered); MOZ_ASSERT(i < mLength); return begin()[i]; } T& back() { MOZ_ASSERT(!entered); MOZ_ASSERT(!empty()); return *(end() - 1); } const T& back() const { MOZ_ASSERT(!entered); MOZ_ASSERT(!empty()); return *(end() - 1); } class Range { friend class VectorBase; T* cur_; T* 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() { MOZ_ASSERT(!empty()); ++cur_; } T popCopyFront() { MOZ_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); /** * Increase the length of the vector, but don't initialize the new elements * -- leave them 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 won't reallocate elements storage. * This *doesn't* mean that infallibleAppend may be used! You still must * reserve the extra space, even if this method indicates that appends won't * need to reallocate elements storage. */ 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(const U& u); template bool appendAll(const VectorBase& u); 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); /* * Guaranteed-infallible append operations for use upon vectors whose * memory has been pre-reserved. Don't use this if you haven't reserved the * memory! */ 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, PointerRangeSize(aBegin, aEnd)); } template void infallibleAppend(const U* aBegin, size_t aLength) { internalAppend(aBegin, aLength); } void popBack(); T popCopy(); /** * Transfers ownership of the internal buffer used by this vector to the * caller. (It's the caller's responsibility to properly deallocate this * buffer, in accordance with this vector's AllocPolicy.) 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 nullptr. * * N.B. Although a T*, only the range [0, length()) is constructed. */ T* extractRawBuffer(); /** * Transfer ownership of an array of objects into the vector. The caller * must have allocated the array in accordance with this vector's * AllocPolicy. * * 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'll * be a dangling pointer if reallocation of the vector storage occurred; the * return value should be used instead. On failure, nullptr is returned. * * Example usage: * * if (!(p = vec.insert(p, val))) * * * * This is inherently a linear-time operation. Be careful! */ 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(MallocSizeOf mallocSizeOf) const; /** * Like sizeOfExcludingThis, but also measures the size of the vector * object (which must be heap-allocated) itself. */ size_t sizeOfIncludingThis(MallocSizeOf mallocSizeOf) const; void swap(ThisVector& other); private: VectorBase(const ThisVector&) MOZ_DELETE; void operator=(const ThisVector&) MOZ_DELETE; }; /* This does the re-entrancy check plus several other sanity checks. */ #define MOZ_REENTRANCY_GUARD_ET_AL \ ReentrancyGuard g(*this); \ MOZ_ASSERT_IF(usingInlineStorage(), mCapacity == sInlineCapacity); \ MOZ_ASSERT(reserved() <= mCapacity); \ MOZ_ASSERT(mLength <= reserved()); \ MOZ_ASSERT(mLength <= mCapacity) /* Vector Implementation */ template MOZ_ALWAYS_INLINE VectorBase::VectorBase(AP ap) : AP(ap), mBegin(static_cast(storage.addr())), mLength(0), mCapacity(sInlineCapacity) #ifdef DEBUG , mReserved(sInlineCapacity), entered(false) #endif {} /* Move constructor. */ template MOZ_ALWAYS_INLINE VectorBase::VectorBase(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 = static_cast(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 = static_cast(rhs->storage.addr()); rhs->mCapacity = sInlineCapacity; rhs->mLength = 0; #ifdef DEBUG rhs->mReserved = sInlineCapacity; #endif } } /* Move assignment. */ template MOZ_ALWAYS_INLINE TV& VectorBase::operator=(MoveRef rhs) { TV* tv = static_cast(this); tv->~TV(); new(tv) TV(rhs); return *tv; } template MOZ_ALWAYS_INLINE VectorBase::~VectorBase() { MOZ_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 VectorBase::convertToHeapStorage(size_t newCap) { MOZ_ASSERT(usingInlineStorage()); /* Allocate buffer. */ MOZ_ASSERT(!detail::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 MOZ_NEVER_INLINE bool VectorBase::growStorageBy(size_t incr) { MOZ_ASSERT(mLength + incr > mCapacity); MOZ_ASSERT_IF(!usingInlineStorage(), !detail::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)>::value; 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 * * static_cast(end()) - static_cast(begin()) * * doesn't overflow ptrdiff_t (see bug 510319). */ if (mLength & tl::MulOverflowMask<4 * sizeof(T)>::value) { 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 (detail::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)>::value) { 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 VectorBase::initCapacity(size_t request) { MOZ_ASSERT(empty()); MOZ_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 VectorBase::reserve(size_t request) { MOZ_REENTRANCY_GUARD_ET_AL; if (request > mCapacity && !growStorageBy(request - mLength)) return false; #ifdef DEBUG if (request > mReserved) mReserved = request; MOZ_ASSERT(mLength <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); #endif return true; } template inline void VectorBase::shrinkBy(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; MOZ_ASSERT(incr <= mLength); Impl::destroy(endNoCheck() - incr, endNoCheck()); mLength -= incr; } template MOZ_ALWAYS_INLINE bool VectorBase::growBy(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; if (incr > mCapacity - mLength && !growStorageBy(incr)) return false; MOZ_ASSERT(mLength + incr <= mCapacity); T* newend = endNoCheck() + incr; Impl::initialize(endNoCheck(), newend); mLength += incr; #ifdef DEBUG if (mLength > mReserved) mReserved = mLength; #endif return true; } template MOZ_ALWAYS_INLINE bool VectorBase::growByUninitialized(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; if (incr > mCapacity - mLength && !growStorageBy(incr)) return false; MOZ_ASSERT(mLength + incr <= mCapacity); mLength += incr; #ifdef DEBUG if (mLength > mReserved) mReserved = mLength; #endif return true; } template inline bool VectorBase::resize(size_t newLength) { size_t curLength = mLength; if (newLength > curLength) return growBy(newLength - curLength); shrinkBy(curLength - newLength); return true; } template MOZ_ALWAYS_INLINE bool VectorBase::resizeUninitialized(size_t newLength) { size_t curLength = mLength; if (newLength > curLength) return growByUninitialized(newLength - curLength); shrinkBy(curLength - newLength); return true; } template inline void VectorBase::clear() { MOZ_REENTRANCY_GUARD_ET_AL; Impl::destroy(beginNoCheck(), endNoCheck()); mLength = 0; } template inline void VectorBase::clearAndFree() { clear(); if (usingInlineStorage()) return; this->free_(beginNoCheck()); mBegin = static_cast(storage.addr()); mCapacity = sInlineCapacity; #ifdef DEBUG mReserved = sInlineCapacity; #endif } template inline bool VectorBase::canAppendWithoutRealloc(size_t needed) const { return mLength + needed <= mCapacity; } template template MOZ_ALWAYS_INLINE void VectorBase::internalAppendAll(const VectorBase& other) { internalAppend(other.begin(), other.length()); } template template MOZ_ALWAYS_INLINE void VectorBase::internalAppend(const U& u) { MOZ_ASSERT(mLength + 1 <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); new(endNoCheck()) T(u); ++mLength; } template MOZ_ALWAYS_INLINE bool VectorBase::appendN(const T& t, size_t needed) { MOZ_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 MOZ_ALWAYS_INLINE void VectorBase::internalAppendN(const T& t, size_t needed) { MOZ_ASSERT(mLength + needed <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); Impl::copyConstructN(endNoCheck(), needed, t); mLength += needed; } template inline T* VectorBase::insert(T* p, const T& val) { MOZ_ASSERT(begin() <= p); MOZ_ASSERT(p <= end()); size_t pos = p - begin(); MOZ_ASSERT(pos <= mLength); size_t oldLength = mLength; if (pos == oldLength) { if (!append(val)) return nullptr; } else { T oldBack = back(); if (!append(oldBack)) /* Dup the last element. */ return nullptr; for (size_t i = oldLength; i > pos; --i) (*this)[i] = (*this)[i - 1]; (*this)[pos] = val; } return begin() + pos; } template inline void VectorBase::erase(T* it) { MOZ_ASSERT(begin() <= it); MOZ_ASSERT(it < end()); while (it + 1 < end()) { *it = *(it + 1); ++it; } popBack(); } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U* insBegin, const U* insEnd) { MOZ_REENTRANCY_GUARD_ET_AL; size_t needed = 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 MOZ_ALWAYS_INLINE void VectorBase::internalAppend(const U* insBegin, size_t insLength) { MOZ_ASSERT(mLength + insLength <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); Impl::copyConstruct(endNoCheck(), insBegin, insBegin + insLength); mLength += insLength; } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U& u) { MOZ_REENTRANCY_GUARD_ET_AL; if (mLength == mCapacity && !growStorageBy(1)) return false; #ifdef DEBUG if (mLength + 1 > mReserved) mReserved = mLength + 1; #endif internalAppend(u); return true; } template template MOZ_ALWAYS_INLINE bool VectorBase::appendAll(const VectorBase& other) { return append(other.begin(), other.length()); } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U *insBegin, size_t insLength) { return append(insBegin, insBegin + insLength); } template MOZ_ALWAYS_INLINE void VectorBase::popBack() { MOZ_REENTRANCY_GUARD_ET_AL; MOZ_ASSERT(!empty()); --mLength; endNoCheck()->~T(); } template MOZ_ALWAYS_INLINE T VectorBase::popCopy() { T ret = back(); popBack(); return ret; } template inline T* VectorBase::extractRawBuffer() { T* ret; if (usingInlineStorage()) { ret = reinterpret_cast(this->malloc_(mLength * sizeof(T))); if (!ret) return nullptr; Impl::copyConstruct(ret, beginNoCheck(), endNoCheck()); Impl::destroy(beginNoCheck(), endNoCheck()); /* mBegin, mCapacity are unchanged. */ mLength = 0; } else { ret = mBegin; mBegin = static_cast(storage.addr()); mLength = 0; mCapacity = sInlineCapacity; #ifdef DEBUG mReserved = sInlineCapacity; #endif } return ret; } template inline void VectorBase::replaceRawBuffer(T* p, size_t aLength) { MOZ_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 = static_cast(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 VectorBase::sizeOfExcludingThis(MallocSizeOf mallocSizeOf) const { return usingInlineStorage() ? 0 : mallocSizeOf(beginNoCheck()); } template inline size_t VectorBase::sizeOfIncludingThis(MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } template inline void VectorBase::swap(TV& other) { static_assert(N == 0, "still need to implement this for 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 } /* * 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 AllocPolicy.h (defaults to * mozilla::MallocAllocPolicy) * * Vector is not reentrant: T member functions called during Vector member * functions must not call back into the same object! */ template class Vector : public VectorBase > { typedef VectorBase Base; public: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} Vector(mozilla::MoveRef vec) : Base(vec) {} Vector& operator=(mozilla::MoveRef vec) { return Base::operator=(vec); } }; } // namespace mozilla #ifdef _MSC_VER #pragma warning(pop) #endif #endif /* mozilla_Vector_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/ios/mozilla/WeakPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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'. * * AtomicSupportsWeakPtr can be used for a variant with an atomically updated * reference counter. * * 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/Atomics.h" #include "mozilla/NullPtr.h" #include "mozilla/RefPtr.h" #include "mozilla/TypeTraits.h" namespace mozilla { template class WeakPtrBase; template class SupportsWeakPtrBase; namespace detail { // This can live beyond the lifetime of the class derived from SupportsWeakPtrBase. template class WeakReference : public RefCounted, Atomicity> { public: explicit WeakReference(T* p) : ptr(p) {} T* get() const { return ptr; } private: friend class WeakPtrBase; friend class SupportsWeakPtrBase; void detach() { ptr = nullptr; } T* ptr; }; } // namespace detail template class SupportsWeakPtrBase { public: WeakPtrBase asWeakPtr() { if (!weakRef) weakRef = new WeakReference(static_cast(this)); return WeakPtrBase(weakRef); } protected: ~SupportsWeakPtrBase() { static_assert(IsBaseOf, T>::value, "T must derive from SupportsWeakPtrBase"); if (weakRef) weakRef->detach(); } private: friend class WeakPtrBase; RefPtr weakRef; }; template class SupportsWeakPtr : public SupportsWeakPtrBase > { }; template class AtomicSupportsWeakPtr : public SupportsWeakPtrBase > { }; namespace detail { template struct WeakReferenceCount { static const RefCountAtomicity atomicity = IsBaseOf, T>::value ? AtomicRefCount : NonAtomicRefCount; }; } template class WeakPtrBase { public: WeakPtrBase(const WeakPtrBase& o) : ref(o.ref) {} // Ensure that ref is dereferenceable in the uninitialized state WeakPtrBase() : ref(new 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 SupportsWeakPtrBase; explicit WeakPtrBase(const RefPtr &o) : ref(o) {} RefPtr ref; }; template class WeakPtr : public WeakPtrBase::atomicity> > { typedef WeakPtrBase::atomicity> > Base; public: WeakPtr(const WeakPtr& o) : Base(o) {} WeakPtr(const Base& o) : Base(o) {} WeakPtr() {} }; } // namespace mozilla #endif /* mozilla_WeakPtr_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/Anchor.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/CallArgs.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 "mozilla/TypeTraits.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); /* Typedef for native functions that may be called in parallel. */ typedef js::ParallelResult (* JSParallelNative)(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp); /* * Typedef for native functions that may be called either in parallel or * sequential execution. */ typedef JSBool (* JSThreadSafeNative)(js::ThreadSafeContext *cx, unsigned argc, JS::Value *vp); /* * Convenience wrappers for passing in ThreadSafeNative to places that expect * a JSNative or a JSParallelNative. */ template inline JSBool JSNativeThreadSafeWrapper(JSContext *cx, unsigned argc, JS::Value *vp); template inline js::ParallelResult JSParallelNativeThreadSafeWrapper(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp); /* * 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); namespace JS { extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; /* * 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.rval().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. */ namespace detail { #ifdef DEBUG extern JS_PUBLIC_API(void) CheckIsValidConstructible(Value v); #endif enum UsedRval { IncludeUsedRval, NoUsedRval }; template class MOZ_STACK_CLASS UsedRvalBase; template<> class MOZ_STACK_CLASS UsedRvalBase { protected: mutable bool usedRval_; void setUsedRval() const { usedRval_ = true; } void clearUsedRval() const { usedRval_ = false; } }; template<> class MOZ_STACK_CLASS UsedRvalBase { protected: void setUsedRval() const {} void clearUsedRval() const {} }; template class MOZ_STACK_CLASS CallReceiverBase : public UsedRvalBase< #ifdef DEBUG WantUsedRval #else NoUsedRval #endif > { protected: 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(!this->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(!this->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]); } Value computeThis(JSContext *cx) const { if (thisv().isObject()) return thisv(); return JS_ComputeThis(cx, base()); } bool isConstructing() const { #ifdef DEBUG if (this->usedRval_) CheckIsValidConstructible(calleev()); #endif return argv_[-1].isMagic(); } /* * 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 { this->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 { this->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 { this->clearUsedRval(); argv_[-2] = aCalleev; } void setThis(Value aThisv) const { argv_[-1] = aThisv; } MutableHandleValue mutableThisv() const { return MutableHandleValue::fromMarkedLocation(&argv_[-1]); } }; } // namespace detail class MOZ_STACK_CLASS CallReceiver : public detail::CallReceiverBase { private: friend CallReceiver CallReceiverFromVp(Value *vp); friend CallReceiver CallReceiverFromArgv(Value *argv); }; 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. */ namespace detail { template class MOZ_STACK_CLASS CallArgsBase : public mozilla::Conditional >::Type { protected: unsigned argc_; public: /* Returns the number of arguments. */ unsigned length() const { return argc_; } /* Returns the i-th zero-indexed argument. */ MutableHandleValue operator[](unsigned i) const { MOZ_ASSERT(i < argc_); return MutableHandleValue::fromMarkedLocation(&this->argv_[i]); } /* * Returns the i-th zero-indexed argument, or |undefined| if there's no * such argument. */ HandleValue get(unsigned i) const { return i < length() ? HandleValue::fromMarkedLocation(&this->argv_[i]) : UndefinedHandleValue; } /* * Returns true if the i-th zero-indexed argument is present and is not * |undefined|. */ bool hasDefined(unsigned i) const { return i < argc_ && !this->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 this->argv_; } Value *end() const { return this->argv_ + argc_; } }; } // namespace detail class MOZ_STACK_CLASS CallArgs : public detail::CallArgsBase { private: 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; } }; 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 /* * 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/CharacterEncoding.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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()); } }; class UTF8Chars : public mozilla::Range { typedef mozilla::Range Base; public: UTF8Chars() : Base() {} UTF8Chars(char *aBytes, size_t aLength) : Base(reinterpret_cast(aBytes), aLength) {} UTF8Chars(const char *aBytes, size_t aLength) : Base(reinterpret_cast(const_cast(aBytes)), aLength) {} }; /* * 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() : Base(NULL, 0) {} 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(js::ThreadSafeContext *cx, TwoByteChars tbchars); extern UTF8CharsZ TwoByteCharsToNewUTF8CharsZ(js::ThreadSafeContext *cx, TwoByteChars tbchars); uint32_t Utf8ToOneUcs4Char(const uint8_t *utf8Buffer, int utf8Length); /* * Inflate bytes in UTF-8 encoding to jschars. * - On error, returns an empty TwoByteCharsZ. * - On success, returns a malloc'd TwoByteCharsZ, and updates |outlen| to hold * its length; the length value excludes the trailing null. */ extern TwoByteCharsZ UTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen); /* * The same as UTF8CharsToNewTwoByteCharsZ(), except that any malformed UTF-8 characters * will be replaced by \uFFFD. No exception will be thrown for malformed UTF-8 * input. */ extern TwoByteCharsZ LossyUTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen); } // 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/Date.h ================================================ /* -*- 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_Date_h #define js_Date_h #include "jstypes.h" namespace JS { // Year is a year, month is 0-11, day is 1-based. The return value is // a number of milliseconds since the epoch. Can return NaN. JS_PUBLIC_API(double) MakeDate(double year, unsigned month, unsigned day); // Takes an integer number of milliseconds since the epoch and returns the // year. Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) YearFromTime(double time); // Takes an integer number of milliseconds since the epoch and returns the // month (0-11). Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) MonthFromTime(double time); // Takes an integer number of milliseconds since the epoch and returns the // day (1-based). Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) DayFromTime(double time); } // namespace JS #endif /* js_Date_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/GCAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_GCAPI_h #define js_GCAPI_h #include "js/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) \ D(OUT_OF_NURSERY) \ D(EVICT_NURSERY) \ D(FULL_STORE_BUFFER) \ \ /* These are reserved for future use. */ \ D(RESERVED0) \ D(RESERVED1) \ D(RESERVED2) \ D(RESERVED3) \ D(RESERVED4) \ D(RESERVED5) \ D(RESERVED6) \ D(RESERVED7) \ D(RESERVED8) \ D(RESERVED9) \ D(RESERVED10) \ D(RESERVED11) \ D(RESERVED12) \ D(RESERVED13) \ D(RESERVED14) \ D(RESERVED15) \ D(RESERVED16) \ D(RESERVED17) \ D(RESERVED18) \ D(RESERVED19) \ \ /* 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(void) EnableGenerationalGC(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 { Heap 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; } void trace(JSTracer *trc, const char *name) { JS_CallHeapObjectTracer(trc, &value, name); } 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); shadow::Runtime *rt = js::gc::GetGCThingRuntime(thing); #ifdef JSGC_GENERATIONAL /* * GC things residing in the nursery cannot be gray: they have no mark bits. * All live objects in the nursery are moved to tenured at the beginning of * each GC slice, so the gray marker never sees nursery things. */ if (uintptr_t(thing) >= rt->gcNurseryStart_ && uintptr_t(thing) < rt->gcNurseryEnd_) return; #endif if (IsIncrementalBarrierNeededOnGCThing(rt, thing, kind)) IncrementalReferenceBarrier(thing, kind); else if (GCThingIsMarkedGray(thing)) UnmarkGrayGCThingRecursively(thing, kind); } static JS_ALWAYS_INLINE void ExposeValueToActiveJS(const Value &v) { if (v.isMarkable()) ExposeGCThingToActiveJS(v.toGCThing(), v.gcKind()); } } /* namespace JS */ #endif /* js_GCAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/HashTable.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_HashTable_h #define js_HashTable_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Casting.h" #include "mozilla/DebugOnly.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/PodOperations.h" #include "mozilla/ReentrancyGuard.h" #include "mozilla/TemplateLib.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.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) {} 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, mozilla::Move(e)); } bool add(AddPtr &p, const Key &k) { Entry e(k, Value()); return impl.add(p, mozilla::Move(e)); } template bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { Entry e(k, v); return impl.relookupOrAdd(p, k, mozilla::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(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf 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, mozilla::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); } // Infallibly rekey one entry, if present. void rekey(const Lookup &old_key, const Key &new_key) { if (old_key != new_key) { if (Ptr p = lookup(old_key)) impl.rekey(p, new_key, new_key); } } // HashMap is movable HashMap(mozilla::MoveRef rhs) : impl(mozilla::Move(rhs->impl)) {} void operator=(mozilla::MoveRef rhs) { impl = mozilla::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) {} 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(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf 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); } // Infallibly rekey one entry, if present. void rekey(const Lookup &old_key, const T &new_key) { if (old_key != new_key) { if (Ptr p = lookup(old_key)) impl.rekey(p, new_key, new_key); } } // HashSet is movable HashSet(mozilla::MoveRef rhs) : impl(mozilla::Move(rhs->impl)) {} void operator=(mozilla::MoveRef rhs) { impl = mozilla::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::value> {}; // 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); uint64_t u = mozilla::BitwiseCast(d); return HashNumber(u ^ (u >> 32)); } static bool match(double lhs, double rhs) { return mozilla::BitwiseCast(lhs) == mozilla::BitwiseCast(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(mozilla::MoveRef rhs) : key(mozilla::Move(rhs->key)), value(mozilla::Move(rhs->value)) { } typedef Key KeyType; typedef Value ValueType; 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 mozilla::RemoveConst::Type 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) { mozilla::Swap(keyHash, other->keyHash); mozilla::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; } 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 mozilla::RemoveConst::Type 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) { table.rekey(*this->cur, l, k); 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(mozilla::MoveRef rhs) : AllocPolicy(*rhs) { mozilla::PodAssign(this, &*rhs); rhs->table = NULL; } void operator=(mozilla::MoveRef rhs) { if (table) destroyTable(*this, table, capacity()); mozilla::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 mozilla::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 = mozilla::tl::BitSize::value; 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, mozilla::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 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(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(table); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } Ptr lookup(const Lookup &l) const { mozilla::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 { mozilla::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) { mozilla::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; { mozilla::ReentrancyGuard g(*this); p.entry_ = &lookup(l, p.keyHash, sCollisionBit); } return p.found() || add(p, u); } void remove(Ptr p) { JS_ASSERT(table); mozilla::ReentrancyGuard g(*this); JS_ASSERT(p.found()); remove(*p.entry_); checkUnderloaded(); } void rekey(Ptr p, const Lookup &l, const Key &k) { JS_ASSERT(table); mozilla::ReentrancyGuard g(*this); JS_ASSERT(p.found()); typename HashTableEntry::NonConstT t(mozilla::Move(*p)); HashPolicy::setKey(t, const_cast(k)); remove(*p.entry_); putNewInfallible(l, mozilla::Move(t)); } #undef METER }; } // namespace detail } // namespace js #endif /* js_HashTable_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/HeapAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_HeapAPI_h #define js_HeapAPI_h #include "jspubtd.h" #include "js/Utility.h" /* These values are private to the JS engine. */ namespace js { namespace gc { const size_t ArenaShift = 12; 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; const size_t ChunkRuntimeOffset = ChunkSize - sizeof(void*); /* * 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 JS::shadow::Runtime * GetGCThingRuntime(const void *thing) { uintptr_t addr = uintptr_t(thing); addr &= ~js::gc::ChunkMask; addr |= js::gc::ChunkRuntimeOffset; 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(shadow::Runtime *rt, void *thing, JSGCTraceKind kind) { if (!rt->needsBarrier_) return false; JS::Zone *zone = GetGCThingZone(thing); return reinterpret_cast(zone)->needsBarrier_; } } /* namespace JS */ #endif /* js_HeapAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/LegacyIntTypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 types. */ #ifndef js_LegacyIntTypes_h #define js_LegacyIntTypes_h #include #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 /* js_LegacyIntTypes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/MemoryMetrics.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 "mozilla/MemoryReporting.h" #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 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 interpreterStack; size_t gcMarker; size_t mathCache; size_t scriptData; size_t scriptSources; CodeSizes code; }; struct ZoneStats { ZoneStats() : extra(NULL), gcHeapArenaAdmin(0), gcHeapUnusedGcThings(0), gcHeapStringsNormal(0), gcHeapStringsShort(0), gcHeapLazyScripts(0), gcHeapTypeObjects(0), gcHeapIonCodes(0), stringCharsNonHuge(0), lazyScripts(0), typeObjects(0), typePool(0), hugeStrings() {} ZoneStats(const ZoneStats &other) : extra(other.extra), gcHeapArenaAdmin(other.gcHeapArenaAdmin), gcHeapUnusedGcThings(other.gcHeapUnusedGcThings), gcHeapStringsNormal(other.gcHeapStringsNormal), gcHeapStringsShort(other.gcHeapStringsShort), gcHeapLazyScripts(other.gcHeapLazyScripts), gcHeapTypeObjects(other.gcHeapTypeObjects), gcHeapIonCodes(other.gcHeapIonCodes), stringCharsNonHuge(other.stringCharsNonHuge), lazyScripts(other.lazyScripts), typeObjects(other.typeObjects), typePool(other.typePool), hugeStrings() { hugeStrings.appendAll(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(gcHeapLazyScripts); ADD(gcHeapTypeObjects); ADD(gcHeapIonCodes); ADD(stringCharsNonHuge); ADD(lazyScripts); ADD(typeObjects); ADD(typePool); #undef ADD hugeStrings.appendAll(other.hugeStrings); } // This field can be used by embedders. void *extra; size_t gcHeapArenaAdmin; size_t gcHeapUnusedGcThings; size_t gcHeapStringsNormal; size_t gcHeapStringsShort; size_t gcHeapLazyScripts; size_t gcHeapTypeObjects; size_t gcHeapIonCodes; size_t stringCharsNonHuge; size_t lazyScripts; 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() : extra(NULL), 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), baselineData(0), baselineStubsFallback(0), baselineStubsOptimized(0), ionData(0), compartmentObject(0), crossCompartmentWrappersTable(0), regexpCompartment(0), debuggeesSet(0), typeInference() {} CompartmentStats(const CompartmentStats &other) : extra(other.extra), 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), baselineData(other.baselineData), baselineStubsFallback(other.baselineStubsFallback), baselineStubsOptimized(other.baselineStubsOptimized), ionData(other.ionData), compartmentObject(other.compartmentObject), crossCompartmentWrappersTable(other.crossCompartmentWrappersTable), regexpCompartment(other.regexpCompartment), debuggeesSet(other.debuggeesSet), typeInference(other.typeInference) { } // This field can be used by embedders. void *extra; // 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 baselineData; size_t baselineStubsFallback; size_t baselineStubsOptimized; 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(baselineData); ADD(baselineStubsFallback); ADD(baselineStubsOptimized); 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(mozilla::MallocSizeOf 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; mozilla::MallocSizeOf 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(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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/PropertyKey.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/RequiredDefines.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/RootingAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_RootingAPI_h #define js_RootingAPI_h #include "mozilla/GuardObjects.h" #include "mozilla/TypeTraits.h" #include "js/Utility.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 |Rooted| 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 three 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. * * - 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 (measured to * be a few nanoseconds on desktop) 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. * * The following diagram explains the list of supported, implicit type * conversions between classes of this family: * * Rooted ----> Handle * | ^ * | | * | | * +---> MutableHandle * (via &) * * All of these types have an implicit conversion to raw pointers. */ namespace js { class Module; class ScriptSourceObject; template struct GCMethods {}; template class RootedBase {}; template class HandleBase {}; template class MutableHandleBase {}; template class HeapBase {}; /* * 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 gc { struct Cell; } /* namespace gc */ } /* 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; }; /* * The Heap class is a C/C++ heap-stored reference to a JS GC thing. All * members of heap classes that refer to GC thing should use Heap (or * possibly TenuredHeap, described below). * * Heap wraps the complex mechanisms required to ensure GC safety for the * contained reference into a C++ class that behaves similarly to a normal * pointer. * * GC references stored on the C/C++ stack must use Rooted/Handle/MutableHandle * instead. * * Requirements for type T: * - Must be one of: Value, jsid, JSObject*, JSString*, JSScript* */ template class Heap : public js::HeapBase { public: Heap() { static_assert(sizeof(T) == sizeof(Heap), "Heap must be binary compatible with T."); init(js::GCMethods::initial()); } explicit Heap(T p) { init(p); } explicit Heap(const Heap &p) { init(p.ptr); } ~Heap() { if (js::GCMethods::needsPostBarrier(ptr)) relocate(); } bool operator==(const Heap &other) { return ptr == other.ptr; } bool operator!=(const Heap &other) { return ptr != other.ptr; } bool operator==(const T &other) const { return ptr == other; } bool operator!=(const T &other) const { return ptr != other; } operator T() const { return ptr; } T operator->() const { return ptr; } const T *address() const { return &ptr; } const T &get() const { return ptr; } T *unsafeGet() { return &ptr; } Heap &operator=(T p) { set(p); return *this; } void set(T newPtr) { JS_ASSERT(!js::GCMethods::poisoned(newPtr)); if (js::GCMethods::needsPostBarrier(newPtr)) { ptr = newPtr; post(); } else if (js::GCMethods::needsPostBarrier(ptr)) { relocate(); /* Called before overwriting ptr. */ ptr = newPtr; } else { ptr = newPtr; } } private: void init(T newPtr) { JS_ASSERT(!js::GCMethods::poisoned(newPtr)); ptr = newPtr; if (js::GCMethods::needsPostBarrier(ptr)) post(); } void post() { #ifdef JSGC_GENERATIONAL JS_ASSERT(js::GCMethods::needsPostBarrier(ptr)); js::GCMethods::postBarrier(&ptr); #endif } void relocate() { #ifdef JSGC_GENERATIONAL js::GCMethods::relocate(&ptr); #endif } T ptr; }; #ifdef DEBUG /* * For generational GC, assert that an object is in the tenured generation as * opposed to being in the nursery. */ extern JS_FRIEND_API(void) AssertGCThingMustBeTenured(JSObject* obj); #else inline void AssertGCThingMustBeTenured(JSObject *obj) {} #endif /* * The TenuredHeap class is similar to the Heap class above in that it * encapsulates the GC concerns of an on-heap reference to a JS object. However, * it has two important differences: * * 1) Pointers which are statically known to only reference "tenured" objects * can avoid the extra overhead of SpiderMonkey's write barriers. * * 2) Objects in the "tenured" heap have stronger alignment restrictions than * those in the "nursery", so it is possible to store flags in the lower * bits of pointers known to be tenured. TenuredHeap wraps a normal tagged * pointer with a nice API for accessing the flag bits and adds various * assertions to ensure that it is not mis-used. * * GC things are said to be "tenured" when they are located in the long-lived * heap: e.g. they have gained tenure as an object by surviving past at least * one GC. For performance, SpiderMonkey allocates some things which are known * to normally be long lived directly into the tenured generation; for example, * global objects. Additionally, SpiderMonkey does not visit individual objects * when deleting non-tenured objects, so object with finalizers are also always * tenured; for instance, this includes most DOM objects. * * The considerations to keep in mind when using a TenuredHeap vs a normal * Heap are: * * - It is invalid for a TenuredHeap to refer to a non-tenured thing. * - It is however valid for a Heap to refer to a tenured thing. * - It is not possible to store flag bits in a Heap. */ template class TenuredHeap : public js::HeapBase { public: TenuredHeap() : bits(0) { static_assert(sizeof(T) == sizeof(TenuredHeap), "TenuredHeap must be binary compatible with T."); } explicit TenuredHeap(T p) : bits(0) { setPtr(p); } explicit TenuredHeap(const TenuredHeap &p) : bits(0) { setPtr(p.ptr); } bool operator==(const TenuredHeap &other) { return bits == other.bits; } bool operator!=(const TenuredHeap &other) { return bits != other.bits; } void setPtr(T newPtr) { JS_ASSERT((reinterpret_cast(newPtr) & flagsMask) == 0); JS_ASSERT(!js::GCMethods::poisoned(newPtr)); if (newPtr) AssertGCThingMustBeTenured(newPtr); bits = (bits & flagsMask) | reinterpret_cast(newPtr); } void setFlags(uintptr_t flagsToSet) { JS_ASSERT((flagsToSet & ~flagsMask) == 0); bits |= flagsToSet; } void unsetFlags(uintptr_t flagsToUnset) { JS_ASSERT((flagsToUnset & ~flagsMask) == 0); bits &= ~flagsToUnset; } bool hasFlag(uintptr_t flag) const { JS_ASSERT((flag & ~flagsMask) == 0); return (bits & flag) != 0; } T getPtr() const { return reinterpret_cast(bits & ~flagsMask); } uintptr_t getFlags() const { return bits & flagsMask; } operator T() const { return getPtr(); } T operator->() const { return getPtr(); } TenuredHeap &operator=(T p) { setPtr(p); return *this; } /* * Set the pointer to a value which will cause a crash if it is * dereferenced. */ void setToCrashOnTouch() { bits = (bits & flagsMask) | crashOnTouchPointer; } bool isSetToCrashOnTouch() { return (bits & ~flagsMask) == crashOnTouchPointer; } private: enum { maskBits = 3, flagsMask = (1 << maskBits) - 1, crashOnTouchPointer = 1 << maskBits }; uintptr_t bits; }; /* * 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 MOZ_NONHEAP_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) { static_assert(sizeof(Handle) == sizeof(T *), "Handle must be binary compatible with T*."); ptr = reinterpret_cast(handle.address()); } /* Create a handle for a NULL pointer. */ Handle(js::NullPtr) { 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) { 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(); } /* * Take care when calling this method! * * This creates a Handle from the raw location of a T. * * It should be called only if the following conditions hold: * * 1) 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. * * 2) the contents of the location are immutable, or at least cannot change * for the lifetime of the handle, as its users may not expect its value * to change underneath them. */ 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(const 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; } const T& get() const { return *ptr; } /* * Return a reference so passing a Handle to something that * takes a |const T&| is not a GC hazard. */ operator const T&() const { return get(); } T operator->() const { return get(); } bool operator!=(const T &other) const { return *ptr != other; } bool operator==(const T &other) const { return *ptr == other; } private: Handle() {} const T *ptr; template void operator=(S v) MOZ_DELETE; }; typedef Handle HandleObject; typedef Handle HandleModule; typedef Handle HandleScriptSource; 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 MOZ_STACK_CLASS MutableHandle : public js::MutableHandleBase { public: inline MutableHandle(Rooted *root); void set(T v) { JS_ASSERT(!js::GCMethods::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; } const T& get() const { return *ptr; } /* * Return a reference so passing a MutableHandle to something that takes * a |const T&| is not a GC hazard. */ operator const T&() const { return get(); } T operator->() const { return get(); } private: MutableHandle() {} T *ptr; template void operator=(S v) MOZ_DELETE; void operator=(MutableHandle other) MOZ_DELETE; }; typedef MutableHandle MutableHandleObject; typedef MutableHandle MutableHandleFunction; typedef MutableHandle MutableHandleScript; typedef MutableHandle MutableHandleString; typedef MutableHandle MutableHandleId; typedef MutableHandle MutableHandleValue; #ifdef JSGC_GENERATIONAL JS_PUBLIC_API(void) HeapCellPostBarrier(js::gc::Cell **cellp); JS_PUBLIC_API(void) HeapCellRelocate(js::gc::Cell **cellp); #endif } /* namespace JS */ namespace js { /* * 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)) {} }; /* * 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 GCMethods { static T *initial() { return NULL; } static ThingRootKind kind() { return RootKind::rootKind(); } static bool poisoned(T *v) { return JS::IsPoisonedPtr(v); } static bool needsPostBarrier(T *v) { return v; } #ifdef JSGC_GENERATIONAL static void postBarrier(T **vp) { JS::HeapCellPostBarrier(reinterpret_cast(vp)); } static void relocate(T **vp) { JS::HeapCellRelocate(reinterpret_cast(vp)); } #endif }; // XXX: Needed for cocos2d JS Bindings //#if defined(DEBUG) /* This helper allows us to assert that Rooted is scoped within a request. */ extern JS_PUBLIC_API(bool) IsInRequest(JSContext *cx); //#endif } /* 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 MOZ_STACK_CLASS Rooted : public js::RootedBase { /* Note: CX is a subclass of either ContextFriendFields or PerThreadDataFriendFields. */ template void init(CX *cx) { #ifdef JSGC_TRACK_EXACT_ROOTS js::ThingRootKind kind = js::GCMethods::kind(); this->stack = &cx->thingGCRooters[kind]; this->prev = *stack; *stack = reinterpret_cast*>(this); JS_ASSERT(!js::GCMethods::poisoned(ptr)); #endif } public: Rooted(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_ASSERT(js::IsInRequest(cx)); init(js::ContextFriendFields::get(cx)); } Rooted(JSContext *cx, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_ASSERT(js::IsInRequest(cx)); init(js::ContextFriendFields::get(cx)); } Rooted(js::ContextFriendFields *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(cx); } Rooted(js::ContextFriendFields *cx, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(cx); } Rooted(js::PerThreadDataFriendFields *pt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(pt); } Rooted(js::PerThreadDataFriendFields *pt, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(pt); } Rooted(JSRuntime *rt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(js::PerThreadDataFriendFields::getMainThread(rt)); } Rooted(JSRuntime *rt, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(js::PerThreadDataFriendFields::getMainThread(rt)); } ~Rooted() { #ifdef JSGC_TRACK_EXACT_ROOTS JS_ASSERT(*stack == reinterpret_cast*>(this)); *stack = prev; #endif } #ifdef JSGC_TRACK_EXACT_ROOTS Rooted *previous() { return prev; } #endif /* * Important: Return a reference here so passing a Rooted to * something that takes a |const T&| is not a GC hazard. */ operator const 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::GCMethods::poisoned(value)); ptr = value; return ptr; } T &operator=(const Rooted &value) { ptr = value; return ptr; } void set(T value) { JS_ASSERT(!js::GCMethods::poisoned(value)); ptr = value; } bool operator!=(const T &other) const { return ptr != other; } bool operator==(const T &other) const { return ptr == other; } private: #ifdef JSGC_TRACK_EXACT_ROOTS 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*); #endif #ifdef JSGC_ROOT_ANALYSIS 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 RootedScriptSource; 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(CX *cx, const T *ptr, size_t count) { SkipRoot **head = &cx->skipGCRooters; this->stack = head; this->prev = *stack; *stack = this; this->start = (const uint8_t *) ptr; this->end = this->start + (sizeof(T) * count); } public: ~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 */ template void init(js::ContextFriendFields *cx, const T *ptr, size_t count) {} public: #endif /* DEBUG && JSGC_ROOT_ANALYSIS */ template SkipRoot(JSContext *cx, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(ContextFriendFields::get(cx), ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template SkipRoot(ContextFriendFields *cx, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(cx, ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template SkipRoot(PerThreadData *pt, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(PerThreadDataFriendFields::get(pt), ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* Interface substitute for Rooted which does not root the variable's memory. */ template class FakeRooted : public RootedBase { public: template FakeRooted(CX *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template FakeRooted(CX *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(!GCMethods::poisoned(value)); ptr = value; return ptr; } bool operator!=(const T &other) const { return ptr != other; } bool operator==(const T &other) const { 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::GCMethods::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) { MOZ_ASSUME_UNREACHABLE("Bad conversion"); } static inline JS::MutableHandle toMutableHandle(MutableHandleType v) { MOZ_ASSUME_UNREACHABLE("Bad conversion"); } }; } /* namespace js */ namespace JS { template template inline Handle::Handle(const 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) { static_assert(sizeof(MutableHandle) == sizeof(T *), "MutableHandle must be binary compatible with T*."); 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 } /* 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 */ #endif /* js_RootingAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/Utility.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_Utility_h #define js_Utility_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/Move.h" #include "mozilla/Scoped.h" #include "mozilla/TemplateLib.h" #include #include #ifdef JS_OOM_DO_BACKTRACES #include #include #endif #include "jstypes.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_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) 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 testing function * oomAfterAllocations COUNT is passed, we fail continuously after the NUM'th * allocation from now. */ extern JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations; /* set in builtins/TestingFunctions.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_calloc(size_t nmemb, size_t size) { JS_OOM_POSSIBLY_FAIL(); return calloc(nmemb, size); } 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_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 void js_delete_poison(T *p) { if (p) { p->~T(); memset(p, 0x3B, sizeof(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 & mozilla::tl::MulOverflowMask::value) return NULL; return (T *)js_malloc(numElems * sizeof(T)); } template static JS_ALWAYS_INLINE T * js_pod_calloc(size_t numElems) { if (numElems & mozilla::tl::MulOverflowMask::value) 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 { /* 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 } } /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/Value.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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(__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(__SUNPRO_CC) && !defined(__xlC__) */ 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(__SUNPRO_CC) && !defined(__xlC__) */ #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) /* 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 jsval_layout JSVAL_TO_IMPL(JS::Value v); static inline JS::Value IMPL_TO_JSVAL(jsval_layout l); namespace JS { /** * Returns a generic quiet NaN value, with all payload bits set to zero. * * Among other properties, this NaN's bit pattern conforms to JS::Value's * bit pattern restrictions. */ static MOZ_ALWAYS_INLINE double GenericNaN() { return mozilla::SpecificNaN(0, 0x8000000000000ULL); } static inline double CanonicalizeNaN(double d) { if (MOZ_UNLIKELY(mozilla::IsNaN(d))) return GenericNaN(); return d; } /* * 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 (mozilla::DoubleIsInt32(d, &i)) { setInt32(i); return true; } 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 /************************************************************************/ #ifdef JSGC_GENERATIONAL namespace JS { JS_PUBLIC_API(void) HeapValuePostBarrier(Value *valuep); JS_PUBLIC_API(void) HeapValueRelocate(Value *valuep); } #endif namespace js { template <> struct GCMethods { 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 GCMethods { 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); } static bool needsPostBarrier(const JS::Value &v) { return v.isMarkable(); } #ifdef JSGC_GENERATIONAL static void postBarrier(JS::Value *v) { JS::HeapValuePostBarrier(v); } static void relocate(JS::Value *v) { JS::HeapValueRelocate(v); } #endif }; template class UnbarrieredMutableValueOperations; 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 UnbarrieredMutableValueOperations; 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(); } uint32_t toPrivateUint32() const { return value()->toPrivateUint32(); } 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 that don't need post barriers. Outer must be * a class inheriting UnbarrieredMutableValueOperations with visible * extractMutable() and extract() methods returning the const Value* and Value* * abstracted by Outer. */ template class UnbarrieredMutableValueOperations : public ValueOperations { friend class MutableValueOperations; 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 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); } }; /* * A class designed for CRTP use in implementing all 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 UnbarrieredMutableValueOperations { public: void setString(JSString *str) { this->value()->setString(str); } void setString(const JS::Anchor &str) { this->value()->setString(str); } void setObject(JSObject &obj) { this->value()->setObject(obj); } void setObjectOrNull(JSObject *arg) { this->value()->setObjectOrNull(arg); } }; /* * Augment the generic Heap interface when T = Value with * type-querying, value-extracting, and mutating operations. */ template <> class HeapBase : public UnbarrieredMutableValueOperations > { typedef JS::Heap Outer; friend class ValueOperations; friend class UnbarrieredMutableValueOperations; const JS::Value * extract() const { return static_cast(this)->address(); } JS::Value * extractMutable() { return static_cast(this)->unsafeGet(); } /* * Setters that potentially change the value to a GC thing from a non-GC * thing must call JS::Heap::set() to trigger the post barrier. * * Changing from a GC thing to a non-GC thing value will leave the heap * value in the store buffer, but it will be ingored so this is not a * problem. */ void setBarriered(const JS::Value &v) { static_cast *>(this)->set(v); } public: void setString(JSString *str) { setBarriered(JS::StringValue(str)); } void setString(const JS::Anchor &str) { setBarriered(JS::StringValue(str.get())); } void setObject(JSObject &obj) { setBarriered(JS::ObjectValue(obj)); } void setObjectOrNull(JSObject *arg) { if (arg) setObject(*arg); else setNull(); } }; /* * 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 UnbarrieredMutableValueOperations >; 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 UnbarrieredMutableValueOperations >; 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; }; static_assert(sizeof(ValueAlignmentTester) == 16, "JS::Value must be 16-byte-aligned"); struct LayoutAlignmentTester { char c; jsval_layout l; }; 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; 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js/Vector.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_Vector_h #define js_Vector_h #include "mozilla/Vector.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; // If we had C++11 template aliases, we could just use this: // // template // using Vector = mozilla::Vector; // // ...and get rid of all the CRTP madness in mozilla::Vector(Base). But we // can't because compiler support's not up to snuff. (Template aliases are in // gcc 4.7 and clang 3.0 and are expected to be in MSVC 2013.) Instead, have a // completely separate class inheriting from mozilla::Vector, and throw CRTP at // the problem til things work. // // This workaround presents a couple issues. First, because js::Vector is a // distinct type from mozilla::Vector, overload resolution, method calls, etc. // are affected. *Hopefully* this won't be too bad in practice. (A bunch of // places had to be fixed when mozilla::Vector was introduced, but it wasn't a // crazy number.) Second, mozilla::Vector's interface has to be made subclass- // ready via CRTP -- or rather, via mozilla::VectorBase, which basically no one // should use. :-) Third, we have to redefine the constructors and the non- // inherited operators. Blech. Happily there aren't too many of these, so it // isn't the end of the world. template class Vector : public mozilla::VectorBase > { typedef typename mozilla::VectorBase Base; public: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} Vector(mozilla::MoveRef vec) : Base(vec) {} Vector &operator=(mozilla::MoveRef vec) { return Base::operator=(vec); } }; } // namespace js #endif /* js_Vector_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js-config.h ================================================ /* -*- 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. */ /* #undef JS_GC_ZEAL */ /* 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 */ /* The configure script defines these if it doesn't #define JS_HAVE_STDINT_H. */ #define JS_BYTES_PER_WORD 8 /* MOZILLA JSAPI version number components */ #define MOZJS_MAJOR_VERSION 25 #define MOZJS_MINOR_VERSION 0 #endif /* js_config_h___ */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/js.msg ================================================ /* -*- 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_MISSING_BINARY_DIGITS, 134, 0, JSEXN_SYNTAXERR, "missing binary digits after '0b'") 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_MISSING_OCTAL_DIGITS, 143, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'") 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_RESULTING_STRING_TOO_LARGE, 146, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size") 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_NEGATIVE_REPETITION_COUNT, 170, 0, JSEXN_RANGEERR, "repeat count must be non-negative") 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_BAD_STRICT_ASSIGN, 236, 1, JSEXN_SYNTAXERR, "can't assign to {0} in strict mode") 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_REDEFINE_ARRAY_LENGTH,242, 0, JSEXN_TYPEERR, "can't redefine array length") MSG_DEF(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH,243, 0, JSEXN_TYPEERR, "can't define array index property past the end of an array with non-writable length") 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_DEBUG_CANT_DEBUG_GLOBAL, 263, 0, JSEXN_ERR, "passing non-debuggable global to addDebuggee") 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_DEBUG_RESUMPTION_VALUE_DISALLOWED, 266, 0, JSEXN_TYPEERR, "resumption values are disallowed in this hook") 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_YIELD_WITHOUT_OPERAND, 272, 0, JSEXN_SYNTAXERR, "yield without a value is deprecated, and illegal in ES6 (use 'yield undefined' instead)") 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\" is only meaningful in the Directive Prologue of a function body") 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, 1, JSEXN_ERR, "successfully compiled asm.js code ({0})") 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") MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME,349, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups") MSG_DEF(JSMSG_DEPRECATED_SOURCE_MAP, 350, 0, JSEXN_SYNTAXERR, "Using //@ to indicate source map URL pragmas is deprecated. Use //# instead") MSG_DEF(JSMSG_BAD_DESTRUCT_ASSIGN, 351, 1, JSEXN_SYNTAXERR, "can't assign to {0} using destructuring assignment") MSG_DEF(JSMSG_BINARYDATA_ARRAYTYPE_BAD_ARGS, 352, 0, JSEXN_ERR, "Invalid arguments") MSG_DEF(JSMSG_BINARYDATA_BINARYARRAY_BAD_INDEX, 353, 0, JSEXN_RANGEERR, "invalid or out-of-range index") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_BAD_ARGS, 354, 0, JSEXN_RANGEERR, "invalid field descriptor") MSG_DEF(JSMSG_BINARYDATA_NOT_BINARYSTRUCT, 355, 1, JSEXN_TYPEERR, "{0} is not a BinaryStruct") MSG_DEF(JSMSG_BINARYDATA_SUBARRAY_INTEGER_ARG, 356, 1, JSEXN_ERR, "argument {0} must be an integer") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_EMPTY_DESCRIPTOR, 357, 0, JSEXN_ERR, "field descriptor cannot be empty") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_BAD_FIELD, 358, 1, JSEXN_ERR, "field {0} is not a valid BinaryData Type descriptor") ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsalloc.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* JS allocation policies. */ #ifndef jsalloc_h #define jsalloc_h #include "mozilla/AllocPolicy.h" #include "js/Utility.h" struct JSContext; namespace js { class ContextFriendFields; /* 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 { ContextFriendFields *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_((ContextFriendFields *) cx) {} // :( TempAllocPolicy(ContextFriendFields *cx) : cx_(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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* JavaScript API. */ #ifndef jsapi_h #define jsapi_h #include "mozilla/FloatingPoint.h" #include "mozilla/MemoryReporting.h" #include "mozilla/RangedPtr.h" #include "mozilla/ThreadLocal.h" #include "mozilla/TypeTraits.h" #include #include #include #include #include "js-config.h" #include "jsalloc.h" #include "jspubtd.h" #include "js/CallArgs.h" #include "js/CharacterEncoding.h" #include "js/HashTable.h" #include "js/RootingAPI.h" #include "js/Utility.h" #include "js/Value.h" #include "js/Vector.h" /************************************************************************/ namespace JS { typedef mozilla::RangedPtr CharPtr; class StableCharPtr : public CharPtr { public: StableCharPtr(const StableCharPtr &s) : CharPtr(s) {} StableCharPtr(const mozilla::RangedPtr &s) : CharPtr(s) {} StableCharPtr(const jschar *s, size_t len) : CharPtr(s, len) {} StableCharPtr(const jschar *pos, const jschar *start, size_t len) : CharPtr(pos, start, len) {} }; #if defined JS_THREADSAFE && defined DEBUG class JS_PUBLIC_API(AutoCheckRequestDepth) { JSContext *cx; public: AutoCheckRequestDepth(JSContext *cx); AutoCheckRequestDepth(js::ContextFriendFields *cx); ~AutoCheckRequestDepth(); }; # define CHECK_REQUEST(cx) \ JS::AutoCheckRequestDepth _autoCheckRequestDepth(cx) #else # define CHECK_REQUEST(cx) \ ((void) 0) #endif /* JS_THREADSAFE && DEBUG */ #ifdef DEBUG /* * Assert that we're not doing GC on cx, that we're in a request as * needed, and that the compartments for cx and v are correct. * Also check that GC would be safe at this point. */ JS_PUBLIC_API(void) AssertArgumentsAreSane(JSContext *cx, JS::Handle v); #else inline void AssertArgumentsAreSane(JSContext *cx, JS::Handle v) { /* Do nothing */ } #endif /* DEBUG */ class JS_PUBLIC_API(AutoGCRooter) { public: AutoGCRooter(JSContext *cx, ptrdiff_t tag); AutoGCRooter(js::ContextFriendFields *cx, ptrdiff_t tag); ~AutoGCRooter() { JS_ASSERT(this == *stackTop); *stackTop = down; } /* Implemented in gc/RootMarking.cpp. */ inline void trace(JSTracer *trc); static void traceAll(JSTracer *trc); static void traceAllWrappers(JSTracer *trc); protected: AutoGCRooter * const down; /* * Discriminates actual subclass of this being used. If non-negative, the * subclass roots an array of values of the length stored in this field. * If negative, meaning is indicated by the corresponding value in the enum * below. Any other negative value indicates some deeper problem such as * memory corruption. */ ptrdiff_t tag_; enum { VALARRAY = -2, /* js::AutoValueArray */ PARSER = -3, /* js::frontend::Parser */ SHAPEVECTOR = -4, /* js::AutoShapeVector */ IDARRAY = -6, /* js::AutoIdArray */ DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */ ID = -9, /* js::AutoIdRooter */ VALVECTOR = -10, /* js::AutoValueVector */ DESCRIPTOR = -11, /* js::AutoPropertyDescriptorRooter */ STRING = -12, /* js::AutoStringRooter */ IDVECTOR = -13, /* js::AutoIdVector */ OBJVECTOR = -14, /* js::AutoObjectVector */ STRINGVECTOR =-15, /* js::AutoStringVector */ SCRIPTVECTOR =-16, /* js::AutoScriptVector */ NAMEVECTOR = -17, /* js::AutoNameVector */ HASHABLEVALUE=-18, /* js::HashableValue */ IONMASM = -19, /* js::jit::MacroAssembler */ IONALLOC = -20, /* js::jit::AutoTempAllocatorRooter */ WRAPVECTOR = -21, /* js::AutoWrapperVector */ WRAPPER = -22, /* js::AutoWrapperRooter */ OBJOBJHASHMAP=-23, /* js::AutoObjectObjectHashMap */ OBJU32HASHMAP=-24, /* js::AutoObjectUnsigned32HashMap */ OBJHASHSET = -25, /* js::AutoObjectHashSet */ JSONPARSER = -26, /* js::JSONParser */ CUSTOM = -27, /* js::CustomAutoRooter */ FUNVECTOR = -28 /* js::AutoFunctionVector */ }; private: AutoGCRooter ** const stackTop; /* No copy or assignment semantics. */ AutoGCRooter(AutoGCRooter &ida) MOZ_DELETE; void operator=(AutoGCRooter &ida) MOZ_DELETE; }; class AutoStringRooter : private AutoGCRooter { public: AutoStringRooter(JSContext *cx, JSString *str = NULL MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, STRING), str_(str) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } void setString(JSString *str) { str_ = str; } JSString * string() const { return str_; } JSString ** addr() { return &str_; } JSString * const * addr() const { return &str_; } friend void AutoGCRooter::trace(JSTracer *trc); private: JSString *str_; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoArrayRooter : private AutoGCRooter { public: AutoArrayRooter(JSContext *cx, size_t len, Value *vec MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, len), array(vec), skip(cx, array, len) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; JS_ASSERT(tag_ >= 0); } void changeLength(size_t newLength) { tag_ = ptrdiff_t(newLength); JS_ASSERT(tag_ >= 0); } void changeArray(Value *newArray, size_t newLength) { changeLength(newLength); array = newArray; } Value *array; MutableHandleValue handleAt(size_t i) { JS_ASSERT(i < size_t(tag_)); return MutableHandleValue::fromMarkedLocation(&array[i]); } HandleValue handleAt(size_t i) const { JS_ASSERT(i < size_t(tag_)); return HandleValue::fromMarkedLocation(&array[i]); } friend void AutoGCRooter::trace(JSTracer *trc); private: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER js::SkipRoot skip; }; template class AutoVectorRooter : protected AutoGCRooter { public: explicit AutoVectorRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), vector(cx), vectorRoot(cx, &vector) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } explicit AutoVectorRooter(js::ContextFriendFields *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), vector(cx), vectorRoot(cx, &vector) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef T ElementType; size_t length() const { return vector.length(); } bool empty() const { return vector.empty(); } bool append(const T &v) { return vector.append(v); } bool appendAll(const AutoVectorRooter &other) { return vector.appendAll(other.vector); } bool insert(T *p, const T &val) { return vector.insert(p, val); } /* For use when space has already been reserved. */ void infallibleAppend(const T &v) { vector.infallibleAppend(v); } void popBack() { vector.popBack(); } T popCopy() { return vector.popCopy(); } bool growBy(size_t inc) { size_t oldLength = vector.length(); if (!vector.growByUninitialized(inc)) return false; makeRangeGCSafe(oldLength); return true; } bool resize(size_t newLength) { size_t oldLength = vector.length(); if (newLength <= oldLength) { vector.shrinkBy(oldLength - newLength); return true; } if (!vector.growByUninitialized(newLength - oldLength)) return false; makeRangeGCSafe(oldLength); return true; } void clear() { vector.clear(); } bool reserve(size_t newLength) { return vector.reserve(newLength); } T &operator[](size_t i) { return vector[i]; } const T &operator[](size_t i) const { return vector[i]; } JS::MutableHandle handleAt(size_t i) { return JS::MutableHandle::fromMarkedLocation(&vector[i]); } JS::Handle handleAt(size_t i) const { return JS::Handle::fromMarkedLocation(&vector[i]); } const T *begin() const { return vector.begin(); } T *begin() { return vector.begin(); } const T *end() const { return vector.end(); } T *end() { return vector.end(); } const T &back() const { return vector.back(); } friend void AutoGCRooter::trace(JSTracer *trc); private: void makeRangeGCSafe(size_t oldLength) { T *t = vector.begin() + oldLength; for (size_t i = oldLength; i < vector.length(); ++i, ++t) memset(t, 0, sizeof(T)); } typedef js::Vector VectorImpl; VectorImpl vector; /* Prevent overwriting of inline elements in vector. */ js::SkipRoot vectorRoot; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; template class AutoHashMapRooter : protected AutoGCRooter { private: typedef js::HashMap HashMapImpl; public: explicit AutoHashMapRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), map(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef Key KeyType; typedef Value ValueType; typedef typename HashMapImpl::Lookup Lookup; typedef typename HashMapImpl::Ptr Ptr; typedef typename HashMapImpl::AddPtr AddPtr; bool init(uint32_t len = 16) { return map.init(len); } bool initialized() const { return map.initialized(); } Ptr lookup(const Lookup &l) const { return map.lookup(l); } void remove(Ptr p) { map.remove(p); } AddPtr lookupForAdd(const Lookup &l) const { return map.lookupForAdd(l); } template bool add(AddPtr &p, const KeyInput &k, const ValueInput &v) { return map.add(p, k, v); } bool add(AddPtr &p, const Key &k) { return map.add(p, k); } template bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { return map.relookupOrAdd(p, k, v); } typedef typename HashMapImpl::Range Range; Range all() const { return map.all(); } typedef typename HashMapImpl::Enum Enum; void clear() { map.clear(); } void finish() { map.finish(); } bool empty() const { return map.empty(); } uint32_t count() const { return map.count(); } size_t capacity() const { return map.capacity(); } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfIncludingThis(mallocSizeOf); } unsigned generation() const { return map.generation(); } /************************************************** Shorthand operations */ bool has(const Lookup &l) const { return map.has(l); } template bool put(const KeyInput &k, const ValueInput &v) { return map.put(k, v); } template bool putNew(const KeyInput &k, const ValueInput &v) { return map.putNew(k, v); } Ptr lookupWithDefault(const Key &k, const Value &defaultValue) { return map.lookupWithDefault(k, defaultValue); } void remove(const Lookup &l) { map.remove(l); } friend void AutoGCRooter::trace(JSTracer *trc); private: AutoHashMapRooter(const AutoHashMapRooter &hmr) MOZ_DELETE; AutoHashMapRooter &operator=(const AutoHashMapRooter &hmr) MOZ_DELETE; HashMapImpl map; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; template class AutoHashSetRooter : protected AutoGCRooter { private: typedef js::HashSet HashSetImpl; public: explicit AutoHashSetRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), set(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef typename HashSetImpl::Lookup Lookup; typedef typename HashSetImpl::Ptr Ptr; typedef typename HashSetImpl::AddPtr AddPtr; bool init(uint32_t len = 16) { return set.init(len); } bool initialized() const { return set.initialized(); } Ptr lookup(const Lookup &l) const { return set.lookup(l); } void remove(Ptr p) { set.remove(p); } AddPtr lookupForAdd(const Lookup &l) const { return set.lookupForAdd(l); } bool add(AddPtr &p, const T &t) { return set.add(p, t); } bool relookupOrAdd(AddPtr &p, const Lookup &l, const T &t) { return set.relookupOrAdd(p, l, t); } typedef typename HashSetImpl::Range Range; Range all() const { return set.all(); } typedef typename HashSetImpl::Enum Enum; void clear() { set.clear(); } void finish() { set.finish(); } bool empty() const { return set.empty(); } uint32_t count() const { return set.count(); } size_t capacity() const { return set.capacity(); } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfIncludingThis(mallocSizeOf); } unsigned generation() const { return set.generation(); } /************************************************** Shorthand operations */ bool has(const Lookup &l) const { return set.has(l); } bool put(const T &t) { return set.put(t); } bool putNew(const T &t) { return set.putNew(t); } void remove(const Lookup &l) { set.remove(l); } friend void AutoGCRooter::trace(JSTracer *trc); private: AutoHashSetRooter(const AutoHashSetRooter &hmr) MOZ_DELETE; AutoHashSetRooter &operator=(const AutoHashSetRooter &hmr) MOZ_DELETE; HashSetImpl set; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoValueVector : public AutoVectorRooter { public: explicit AutoValueVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, VALVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoIdVector : public AutoVectorRooter { public: explicit AutoIdVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, IDVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoObjectVector : public AutoVectorRooter { public: explicit AutoObjectVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, OBJVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoFunctionVector : public AutoVectorRooter { public: explicit AutoFunctionVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, FUNVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } explicit AutoFunctionVector(js::ContextFriendFields *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, FUNVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoScriptVector : public AutoVectorRooter { public: explicit AutoScriptVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, SCRIPTVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* * Cutsom rooting behavior for internal and external clients. */ class JS_PUBLIC_API(CustomAutoRooter) : private AutoGCRooter { public: template explicit CustomAutoRooter(CX *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, CUSTOM) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } friend void AutoGCRooter::trace(JSTracer *trc); protected: /* Supplied by derived class to trace roots. */ virtual void trace(JSTracer *trc) = 0; private: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* Returns true if |v| is considered an acceptable this-value. */ typedef bool (*IsAcceptableThis)(const Value &v); /* * Implements the guts of a method; guaranteed to be provided an acceptable * this-value, as determined by a corresponding IsAcceptableThis method. */ typedef bool (*NativeImpl)(JSContext *cx, CallArgs args); namespace detail { /* DON'T CALL THIS DIRECTLY. It's for use only by CallNonGenericMethod! */ extern JS_PUBLIC_API(bool) CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args); } /* namespace detail */ /* * Methods usually act upon |this| objects only from a single global object and * compartment. Sometimes, however, a method must act upon |this| values from * multiple global objects or compartments. In such cases the |this| value a * method might see will be wrapped, such that various access to the object -- * to its class, its private data, its reserved slots, and so on -- will not * work properly without entering that object's compartment. This method * implements a solution to this problem. * * To implement a method that accepts |this| values from multiple compartments, * define two functions. The first function matches the IsAcceptableThis type * and indicates whether the provided value is an acceptable |this| for the * method; it must be a pure function only of its argument. * * static JSClass AnswerClass = { ... }; * * static bool * IsAnswerObject(const Value &v) * { * if (!v.isObject()) * return false; * return JS_GetClass(&v.toObject()) == &AnswerClass; * } * * The second function implements the NativeImpl signature and defines the * behavior of the method when it is provided an acceptable |this| value. * Aside from some typing niceties -- see the CallArgs interface for details -- * its interface is the same as that of JSNative. * * static bool * answer_getAnswer_impl(JSContext *cx, JS::CallArgs args) * { * args.rval().setInt32(42); * return true; * } * * The implementation function is guaranteed to be called *only* with a |this| * value which is considered acceptable. * * Now to implement the actual method, write a JSNative that calls the method * declared below, passing the appropriate template and runtime arguments. * * static JSBool * answer_getAnswer(JSContext *cx, unsigned argc, JS::Value *vp) * { * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); * return JS::CallNonGenericMethod(cx, args); * } * * Note that, because they are used as template arguments, the predicate * and implementation functions must have external linkage. (This is * unfortunate, but GCC wasn't inlining things as one would hope when we * passed them as function arguments.) * * JS::CallNonGenericMethod will test whether |args.thisv()| is acceptable. If * it is, it will call the provided implementation function, which will return * a value and indicate success. If it is not, it will attempt to unwrap * |this| and call the implementation function on the unwrapped |this|. If * that succeeds, all well and good. If it doesn't succeed, a TypeError will * be thrown. * * Note: JS::CallNonGenericMethod will only work correctly if it's called in * tail position in a JSNative. Do not call it from any other place. */ template JS_ALWAYS_INLINE bool CallNonGenericMethod(JSContext *cx, CallArgs args) { const Value &thisv = args.thisv(); if (Test(thisv)) return Impl(cx, args); return detail::CallMethodIfWrapped(cx, Test, Impl, args); } JS_ALWAYS_INLINE bool CallNonGenericMethod(JSContext *cx, IsAcceptableThis Test, NativeImpl Impl, CallArgs args) { const Value &thisv = args.thisv(); if (Test(thisv)) return Impl(cx, args); return detail::CallMethodIfWrapped(cx, Test, Impl, args); } } /* namespace JS */ /************************************************************************/ /* JSClass operation signatures. */ /* * Add or get a property named by id in obj. Note the jsid id type -- id may * be a string (Unicode property identifier) or an int (element index). The * *vp out parameter, on success, is the new property value after the action. */ typedef JSBool (* JSPropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JS::MutableHandle vp); /* * Set a property named by id in obj, treating the assignment as strict * mode code if strict is true. Note the jsid id type -- id may be a string * (Unicode property identifier) or an int (element index). The *vp out * parameter, on success, is the new property value after the * set. */ typedef JSBool (* JSStrictPropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool strict, JS::MutableHandle vp); /* * Delete a property named by id in obj. * * If an error occurred, return false as per normal JSAPI error practice. * * If no error occurred, but the deletion attempt wasn't allowed (perhaps * because the property was non-configurable), set *succeeded to false and * return true. This will cause |delete obj[id]| to evaluate to false in * non-strict mode code, and to throw a TypeError in strict mode code. * * If no error occurred and the deletion wasn't disallowed (this is *not* the * same as saying that a deletion actually occurred -- deleting a non-existent * property, or an inherited property, is allowed -- it's just pointless), * set *succeeded to true and return true. */ typedef JSBool (* JSDeletePropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool *succeeded); /* * This function type is used for callbacks that enumerate the properties of * a JSObject. The behavior depends on the value of enum_op: * * JSENUMERATE_INIT * A new, opaque iterator state should be allocated and stored in *statep. * (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored). * * The number of properties that will be enumerated should be returned as * an integer jsval in *idp, if idp is non-null, and provided the number of * enumerable properties is known. If idp is non-null and the number of * enumerable properties can't be computed in advance, *idp should be set * to JSVAL_ZERO. * * JSENUMERATE_INIT_ALL * Used identically to JSENUMERATE_INIT, but exposes all properties of the * object regardless of enumerability. * * JSENUMERATE_NEXT * A previously allocated opaque iterator state is passed in via statep. * Return the next jsid in the iteration using *idp. The opaque iterator * state pointed at by statep is destroyed and *statep is set to JSVAL_NULL * if there are no properties left to enumerate. * * JSENUMERATE_DESTROY * Destroy the opaque iterator state previously allocated in *statep by a * call to this function when enum_op was JSENUMERATE_INIT or * JSENUMERATE_INIT_ALL. * * The return value is used to indicate success, with a value of JS_FALSE * indicating failure. */ typedef JSBool (* JSNewEnumerateOp)(JSContext *cx, JS::Handle obj, JSIterateOp enum_op, JS::MutableHandle statep, JS::MutableHandleId idp); /* * The old-style JSClass.enumerate op should define all lazy properties not * yet reflected in obj. */ typedef JSBool (* JSEnumerateOp)(JSContext *cx, JS::Handle obj); /* * Resolve a lazy property named by id in obj by defining it directly in obj. * Lazy properties are those reflected from some peer native property space * (e.g., the DOM attributes for a given node reflected as obj) on demand. * * JS looks for a property in an object, and if not found, tries to resolve * the given id. If resolve succeeds, the engine looks again in case resolve * defined obj[id]. If no such property exists directly in obj, the process * is repeated with obj's prototype, etc. * * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties. */ typedef JSBool (* JSResolveOp)(JSContext *cx, JS::Handle obj, JS::Handle id); /* * Like JSResolveOp, but flags provide contextual information as follows: * * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment * * The *objp out parameter, on success, should be null to indicate that id * was not resolved; and non-null, referring to obj or one of its prototypes, * if id was resolved. The hook may assume *objp is null on entry. * * This hook instead of JSResolveOp is called via the JSClass.resolve member * if JSCLASS_NEW_RESOLVE is set in JSClass.flags. */ typedef JSBool (* JSNewResolveOp)(JSContext *cx, JS::Handle obj, JS::Handle id, unsigned flags, JS::MutableHandleObject objp); /* * Convert obj to the given type, returning true with the resulting value in * *vp on success, and returning false on error or exception. */ typedef JSBool (* JSConvertOp)(JSContext *cx, JS::Handle obj, JSType type, JS::MutableHandle vp); typedef struct JSFreeOp JSFreeOp; struct JSFreeOp { private: JSRuntime *runtime_; protected: JSFreeOp(JSRuntime *rt) : runtime_(rt) { } public: JSRuntime *runtime() const { return runtime_; } }; /* * Finalize obj, which the garbage collector has determined to be unreachable * from other live objects or from GC roots. Obviously, finalizers must never * store a reference to obj. */ typedef void (* JSFinalizeOp)(JSFreeOp *fop, JSObject *obj); /* * Finalizes external strings created by JS_NewExternalString. */ typedef struct JSStringFinalizer JSStringFinalizer; struct JSStringFinalizer { void (*finalize)(const JSStringFinalizer *fin, jschar *chars); }; /* * JSClass.checkAccess type: check whether obj[id] may be accessed per mode, * returning false on error/exception, true on success with obj[id]'s last-got * value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id * is either a string or an int jsval. */ typedef JSBool (* JSCheckAccessOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSAccessMode mode, JS::MutableHandle vp); /* * Check whether v is an instance of obj. Return false on error or exception, * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in * *bp otherwise. */ typedef JSBool (* JSHasInstanceOp)(JSContext *cx, JS::Handle obj, JS::MutableHandle vp, JSBool *bp); /* * Function type for trace operation of the class called to enumerate all * traceable things reachable from obj's private data structure. For each such * thing, a trace implementation must call one of the JS_Call*Tracer variants * on the thing. * * JSTraceOp implementation can assume that no other threads mutates object * state. It must not change state of the object or corresponding native * structures. The only exception for this rule is the case when the embedding * needs a tight integration with GC. In that case the embedding can check if * the traversal is a part of the marking phase through calling * JS_IsGCMarkingTracer and apply a special code like emptying caches or * marking its native structures. */ typedef void (* JSTraceOp)(JSTracer *trc, JSObject *obj); /* * Callback that JSTraceOp implementation can provide to return a string * describing the reference traced with JS_CallTracer. */ typedef void (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize); typedef JSObject * (* JSWeakmapKeyDelegateOp)(JSObject *obj); /* Callbacks and their arguments. */ typedef enum JSContextOp { JSCONTEXT_NEW, JSCONTEXT_DESTROY } JSContextOp; /* * The possible values for contextOp when the runtime calls the callback are: * JSCONTEXT_NEW JS_NewContext successfully created a new JSContext * instance. The callback can initialize the instance as * required. If the callback returns false, the instance * will be destroyed and JS_NewContext returns null. In * this case the callback is not called again. * JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The * callback may perform its own cleanup and must always * return true. * Any other value For future compatibility the callback must do nothing * and return true in this case. */ typedef JSBool (* JSContextCallback)(JSContext *cx, unsigned contextOp, void *data); typedef enum JSGCStatus { JSGC_BEGIN, JSGC_END } JSGCStatus; typedef void (* JSGCCallback)(JSRuntime *rt, JSGCStatus status, void *data); typedef enum JSFinalizeStatus { /* * Called when preparing to sweep a group of compartments, before anything * has been swept. The collector will not yield to the mutator before * calling the callback with JSFINALIZE_GROUP_END status. */ JSFINALIZE_GROUP_START, /* * Called when preparing to sweep a group of compartments. Weak references * to unmarked things have been removed and things that are not swept * incrementally have been finalized at this point. The collector may yield * to the mutator after this point. */ JSFINALIZE_GROUP_END, /* * Called at the end of collection when everything has been swept. */ JSFINALIZE_COLLECTION_END } JSFinalizeStatus; typedef void (* JSFinalizeCallback)(JSFreeOp *fop, JSFinalizeStatus status, JSBool isCompartment); /* * Generic trace operation that calls JS_CallTracer on each traceable thing * stored in data. */ typedef void (* JSTraceDataOp)(JSTracer *trc, void *data); typedef JSBool (* JSOperationCallback)(JSContext *cx); typedef void (* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report); #ifdef MOZ_TRACE_JSCALLS typedef void (* JSFunctionCallback)(const JSFunction *fun, const JSScript *scr, const JSContext *cx, int entering); #endif /* * Possible exception types. These types are part of a JSErrorFormatString * structure. They define which error to throw in case of a runtime error. * JSEXN_NONE marks an unthrowable error. */ typedef enum JSExnType { JSEXN_NONE = -1, JSEXN_ERR, JSEXN_INTERNALERR, JSEXN_EVALERR, JSEXN_RANGEERR, JSEXN_REFERENCEERR, JSEXN_SYNTAXERR, JSEXN_TYPEERR, JSEXN_URIERR, JSEXN_LIMIT } JSExnType; typedef struct JSErrorFormatString { /* The error format string in ASCII. */ const char *format; /* The number of arguments to expand in the formatted error message. */ uint16_t argCount; /* One of the JSExnType constants above. */ int16_t exnType; } JSErrorFormatString; typedef const JSErrorFormatString * (* JSErrorCallback)(void *userRef, const char *locale, const unsigned errorNumber); typedef JSBool (* JSLocaleToUpperCase)(JSContext *cx, JS::Handle src, JS::MutableHandle rval); typedef JSBool (* JSLocaleToLowerCase)(JSContext *cx, JS::Handle src, JS::MutableHandle rval); typedef JSBool (* JSLocaleCompare)(JSContext *cx, JS::Handle src1, JS::Handle src2, JS::MutableHandle rval); typedef JSBool (* JSLocaleToUnicode)(JSContext *cx, const char *src, JS::MutableHandle rval); /* * Security protocol types. */ typedef void (* JSDestroyPrincipalsOp)(JSPrincipals *principals); /* * Used to check if a CSP instance wants to disable eval() and friends. * See js_CheckCSPPermitsJSAction() in jsobj. */ typedef JSBool (* JSCSPEvalChecker)(JSContext *cx); /* * Callback used to ask the embedding for the cross compartment wrapper handler * that implements the desired prolicy for this kind of object in the * destination compartment. |obj| is the object to be wrapped. If |existing| is * non-NULL, it will point to an existing wrapper object that should be re-used * if possible. |existing| is guaranteed to be a cross-compartment wrapper with * a lazily-defined prototype and the correct global. It is guaranteed not to * wrap a function. */ typedef JSObject * (* JSWrapObjectCallback)(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj, JS::HandleObject proto, JS::HandleObject parent, unsigned flags); /* * Callback used by the wrap hook to ask the embedding to prepare an object * for wrapping in a context. This might include unwrapping other wrappers * or even finding a more suitable object for the new compartment. */ typedef JSObject * (* JSPreWrapCallback)(JSContext *cx, JS::HandleObject scope, JS::HandleObject obj, unsigned flags); /* * Callback used when wrapping determines that the underlying object is already * in the compartment for which it is being wrapped. This allows consumers to * maintain same-compartment wrapping invariants. * * |obj| is guaranteed to be same-compartment as |cx|, but it may (or may not) * be a security or cross-compartment wrapper. This is an unfortunate contract, * but is important for to avoid unnecessarily recomputing every cross- * compartment wrapper that gets passed to wrap. */ typedef JSObject * (* JSSameCompartmentWrapObjectCallback)(JSContext *cx, JS::HandleObject obj); typedef void (* JSDestroyCompartmentCallback)(JSFreeOp *fop, JSCompartment *compartment); typedef void (* JSCompartmentNameCallback)(JSRuntime *rt, JSCompartment *compartment, char *buf, size_t bufsize); /* * Read structured data from the reader r. This hook is used to read a value * previously serialized by a call to the WriteStructuredCloneOp hook. * * tag and data are the pair of uint32_t values from the header. The callback * may use the JS_Read* APIs to read any other relevant parts of the object * from the reader r. closure is any value passed to the JS_ReadStructuredClone * function. Return the new object on success, NULL on error/exception. */ typedef JSObject *(*ReadStructuredCloneOp)(JSContext *cx, JSStructuredCloneReader *r, uint32_t tag, uint32_t data, void *closure); /* * Structured data serialization hook. The engine can write primitive values, * Objects, Arrays, Dates, RegExps, TypedArrays, and ArrayBuffers. Any other * type of object requires application support. This callback must first use * the JS_WriteUint32Pair API to write an object header, passing a value * greater than JS_SCTAG_USER to the tag parameter. Then it can use the * JS_Write* APIs to write any other relevant parts of the value v to the * writer w. closure is any value passed to the JS_WriteStructuredCLone function. * * Return true on success, false on error/exception. */ typedef JSBool (*WriteStructuredCloneOp)(JSContext *cx, JSStructuredCloneWriter *w, JS::Handle obj, void *closure); /* * This is called when JS_WriteStructuredClone is given an invalid transferable. * To follow HTML5, the application must throw a DATA_CLONE_ERR DOMException * with error set to one of the JS_SCERR_* values. */ typedef void (*StructuredCloneErrorOp)(JSContext *cx, uint32_t errorid); /************************************************************************/ /* * JS constants. For efficiency, prefer predicates (e.g. v.isNull()) and * constructing values from scratch (e.g. Int32Value(0)). These constants are * stored in memory and initialized at startup, so testing against them and * using them requires memory loads and will be correspondingly slow. */ extern JS_PUBLIC_DATA(const jsval) JSVAL_NULL; extern JS_PUBLIC_DATA(const jsval) JSVAL_ZERO; extern JS_PUBLIC_DATA(const jsval) JSVAL_ONE; extern JS_PUBLIC_DATA(const jsval) JSVAL_FALSE; extern JS_PUBLIC_DATA(const jsval) JSVAL_TRUE; extern JS_PUBLIC_DATA(const jsval) JSVAL_VOID; static JS_ALWAYS_INLINE jsval JS_NumberValue(double d) { int32_t i; d = JS::CanonicalizeNaN(d); if (mozilla::DoubleIsInt32(d, &i)) return INT_TO_JSVAL(i); return DOUBLE_TO_JSVAL(d); } /************************************************************************/ /* * A jsid is an identifier for a property or method of an object which is * either a 31-bit signed integer, interned string or object. Also, there is * an additional jsid value, JSID_VOID, which does not occur in JS scripts but * may be used to indicate the absence of a valid jsid. * * A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or * JS_IdToValue must be used instead. */ #define JSID_TYPE_STRING 0x0 #define JSID_TYPE_INT 0x1 #define JSID_TYPE_VOID 0x2 #define JSID_TYPE_OBJECT 0x4 #define JSID_TYPE_MASK 0x7 /* * Avoid using canonical 'id' for jsid parameters since this is a magic word in * Objective-C++ which, apparently, wants to be able to #include jsapi.h. */ #define id iden static JS_ALWAYS_INLINE JSBool JSID_IS_STRING(jsid id) { return (JSID_BITS(id) & JSID_TYPE_MASK) == 0; } static JS_ALWAYS_INLINE JSString * JSID_TO_STRING(jsid id) { JS_ASSERT(JSID_IS_STRING(id)); return (JSString *)JSID_BITS(id); } static JS_ALWAYS_INLINE JSBool JSID_IS_ZERO(jsid id) { return JSID_BITS(id) == 0; } JS_PUBLIC_API(JSBool) JS_StringHasBeenInterned(JSContext *cx, JSString *str); /* * Only JSStrings that have been interned via the JSAPI can be turned into * jsids by API clients. * * N.B. if a jsid is backed by a string which has not been interned, that * string must be appropriately rooted to avoid being collected by the GC. */ JS_PUBLIC_API(jsid) INTERNED_STRING_TO_JSID(JSContext *cx, JSString *str); static JS_ALWAYS_INLINE JSBool JSID_IS_INT(jsid id) { return !!(JSID_BITS(id) & JSID_TYPE_INT); } static JS_ALWAYS_INLINE int32_t JSID_TO_INT(jsid id) { JS_ASSERT(JSID_IS_INT(id)); return ((uint32_t)JSID_BITS(id)) >> 1; } #define JSID_INT_MIN 0 #define JSID_INT_MAX INT32_MAX static JS_ALWAYS_INLINE JSBool INT_FITS_IN_JSID(int32_t i) { return i >= 0; } static JS_ALWAYS_INLINE jsid INT_TO_JSID(int32_t i) { jsid id; JS_ASSERT(INT_FITS_IN_JSID(i)); JSID_BITS(id) = ((i << 1) | JSID_TYPE_INT); return id; } static JS_ALWAYS_INLINE JSBool JSID_IS_OBJECT(jsid id) { return (JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_OBJECT && (size_t)JSID_BITS(id) != JSID_TYPE_OBJECT; } static JS_ALWAYS_INLINE JSObject * JSID_TO_OBJECT(jsid id) { JS_ASSERT(JSID_IS_OBJECT(id)); return (JSObject *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); } static JS_ALWAYS_INLINE jsid OBJECT_TO_JSID(JSObject *obj) { jsid id; JS_ASSERT(obj != NULL); JS_ASSERT(((size_t)obj & JSID_TYPE_MASK) == 0); JSID_BITS(id) = ((size_t)obj | JSID_TYPE_OBJECT); return id; } static JS_ALWAYS_INLINE JSBool JSID_IS_GCTHING(jsid id) { return JSID_IS_STRING(id) || JSID_IS_OBJECT(id); } static JS_ALWAYS_INLINE void * JSID_TO_GCTHING(jsid id) { return (void *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); } /* * A void jsid is not a valid id and only arises as an exceptional API return * value, such as in JS_NextProperty. Embeddings must not pass JSID_VOID into * JSAPI entry points expecting a jsid and do not need to handle JSID_VOID in * hooks receiving a jsid except when explicitly noted in the API contract. */ static JS_ALWAYS_INLINE JSBool JSID_IS_VOID(const jsid id) { JS_ASSERT_IF(((size_t)JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_VOID, JSID_BITS(id) == JSID_TYPE_VOID); return ((size_t)JSID_BITS(id) == JSID_TYPE_VOID); } static JS_ALWAYS_INLINE JSBool JSID_IS_EMPTY(const jsid id) { return ((size_t)JSID_BITS(id) == JSID_TYPE_OBJECT); } #undef id #ifdef JS_USE_JSID_STRUCT_TYPES extern JS_PUBLIC_DATA(const jsid) JSID_VOID; extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY; #else # define JSID_VOID ((jsid)JSID_TYPE_VOID) # define JSID_EMPTY ((jsid)JSID_TYPE_OBJECT) #endif /* * Returns true iff the given jsval is immune to GC and can be used across * multiple JSRuntimes without requiring any conversion API. */ static JS_ALWAYS_INLINE JSBool JSVAL_IS_UNIVERSAL(jsval v) { return !JSVAL_IS_GCTHING(v); } namespace JS { class AutoIdRooter : private AutoGCRooter { public: explicit AutoIdRooter(JSContext *cx, jsid aId = INT_TO_JSID(0) MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, ID), id_(aId) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } jsid id() { return id_; } jsid * addr() { return &id_; } friend void AutoGCRooter::trace(JSTracer *trc); private: jsid id_; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; } /* namespace JS */ /************************************************************************/ /* Property attributes, set in JSPropertySpec and passed to API functions. */ #define JSPROP_ENUMERATE 0x01 /* property is visible to for/in loop */ #define JSPROP_READONLY 0x02 /* not settable: assignment is no-op. This flag is only valid when neither JSPROP_GETTER nor JSPROP_SETTER is set. */ #define JSPROP_PERMANENT 0x04 /* property cannot be deleted */ #define JSPROP_NATIVE_ACCESSORS 0x08 /* set in JSPropertyDescriptor.flags if getters/setters are JSNatives */ #define JSPROP_GETTER 0x10 /* property holds getter function */ #define JSPROP_SETTER 0x20 /* property holds setter function */ #define JSPROP_SHARED 0x40 /* don't allocate a value slot for this property; don't copy the property on set of the same-named property in an object that delegates to a prototype containing this property */ #define JSPROP_INDEX 0x80 /* name is actually (int) index */ #define JSPROP_SHORTID 0x100 /* set in JS_DefineProperty attrs if getters/setters use a shortid */ #define JSFUN_STUB_GSOPS 0x200 /* use JS_PropertyStub getter/setter instead of defaulting to class gsops for property holding function */ #define JSFUN_CONSTRUCTOR 0x400 /* native that can be called as a ctor */ /* * Specify a generic native prototype methods, i.e., methods of a class * prototype that are exposed as static methods taking an extra leading * argument: the generic |this| parameter. * * If you set this flag in a JSFunctionSpec struct's flags initializer, then * that struct must live at least as long as the native static method object * created due to this flag by JS_DefineFunctions or JS_InitClass. Typically * JSFunctionSpec structs are allocated in static arrays. */ #define JSFUN_GENERIC_NATIVE 0x800 #define JSFUN_FLAGS_MASK 0xe00 /* | of all the JSFUN_* flags */ /* * The first call to JS_CallOnce by any thread in a process will call 'func'. * Later calls to JS_CallOnce with the same JSCallOnceType object will be * suppressed. * * Equivalently: each distinct JSCallOnceType object will allow one JS_CallOnce * to invoke its JSInitCallback. */ extern JS_PUBLIC_API(JSBool) JS_CallOnce(JSCallOnceType *once, JSInitCallback func); /* Microseconds since the epoch, midnight, January 1, 1970 UTC. */ extern JS_PUBLIC_API(int64_t) JS_Now(void); /* Don't want to export data, so provide accessors for non-inline jsvals. */ extern JS_PUBLIC_API(jsval) JS_GetNaNValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetNegativeInfinityValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetPositiveInfinityValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetEmptyStringValue(JSContext *cx); extern JS_PUBLIC_API(JSString *) JS_GetEmptyString(JSRuntime *rt); /* * Format is a string of the following characters (spaces are insignificant), * specifying the tabulated type conversions: * * b JSBool Boolean * c uint16_t/jschar ECMA uint16_t, Unicode char * i int32_t ECMA int32_t * u uint32_t ECMA uint32_t * j int32_t Rounded int32_t (coordinate) * d double IEEE double * I double Integral IEEE double * S JSString * Unicode string, accessed by a JSString pointer * W jschar * Unicode character vector, 0-terminated (W for wide) * o JSObject * Object reference * f JSFunction * Function private * v jsval Argument value (no conversion) * * N/A Skip this argument (no vararg) * / N/A End of required arguments * * The variable argument list after format must consist of &b, &c, &s, e.g., * where those variables have the types given above. For the pointer types * char *, JSString *, and JSObject *, the pointed-at memory returned belongs * to the JS runtime, not to the calling native code. The runtime promises * to keep this memory valid so long as argv refers to allocated stack space * (so long as the native function is active). * * Fewer arguments than format specifies may be passed only if there is a / * in format after the last required argument specifier and argc is at least * the number of required arguments. More arguments than format specifies * may be passed without error; it is up to the caller to deal with trailing * unconverted arguments. */ extern JS_PUBLIC_API(JSBool) JS_ConvertArguments(JSContext *cx, unsigned argc, jsval *argv, const char *format, ...); #ifdef va_start extern JS_PUBLIC_API(JSBool) JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *format, va_list ap); #endif extern JS_PUBLIC_API(JSBool) JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_ValueToObject(JSContext *cx, jsval v, JSObject **objp); extern JS_PUBLIC_API(JSFunction *) JS_ValueToFunction(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSFunction *) JS_ValueToConstructor(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToString(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToSource(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSBool) JS_ValueToNumber(JSContext *cx, jsval v, double *dp); namespace js { /* * DO NOT CALL THIS. Use JS::ToNumber */ extern JS_PUBLIC_API(bool) ToNumberSlow(JSContext *cx, JS::Value v, double *dp); /* * DO NOT CALL THIS. Use JS::ToBoolean */ extern JS_PUBLIC_API(bool) ToBooleanSlow(const JS::Value &v); } /* namespace js */ namespace JS { /* ES5 9.3 ToNumber. */ JS_ALWAYS_INLINE bool ToNumber(JSContext *cx, HandleValue v, double *out) { AssertArgumentsAreSane(cx, v); { js::SkipRoot root(cx, &v); js::MaybeCheckStackRoots(cx); } if (v.isNumber()) { *out = v.toNumber(); return true; } return js::ToNumberSlow(cx, v, out); } JS_ALWAYS_INLINE bool ToBoolean(const Value &v) { if (v.isBoolean()) return v.toBoolean(); if (v.isInt32()) return v.toInt32() != 0; if (v.isNullOrUndefined()) return false; if (v.isDouble()) { double d = v.toDouble(); return !mozilla::IsNaN(d) && d != 0; } /* The slow path handles strings and objects. */ return js::ToBooleanSlow(v); } } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_DoubleIsInt32(double d, int32_t *ip); extern JS_PUBLIC_API(int32_t) JS_DoubleToInt32(double d); extern JS_PUBLIC_API(uint32_t) JS_DoubleToUint32(double d); /* * Convert a value to a number, then to an int32_t, according to the ECMA rules * for ToInt32. */ extern JS_PUBLIC_API(JSBool) JS_ValueToECMAInt32(JSContext *cx, jsval v, int32_t *ip); /* * Convert a value to a number, then to an int64_t, according to the WebIDL * rules for ToInt64: http://dev.w3.org/2006/webapi/WebIDL/#es-long-long */ extern JS_PUBLIC_API(JSBool) JS_ValueToInt64(JSContext *cx, jsval v, int64_t *ip); /* * Convert a value to a number, then to an uint64_t, according to the WebIDL * rules for ToUint64: http://dev.w3.org/2006/webapi/WebIDL/#es-unsigned-long-long */ extern JS_PUBLIC_API(JSBool) JS_ValueToUint64(JSContext *cx, jsval v, uint64_t *ip); namespace js { /* DO NOT CALL THIS. Use JS::ToInt16. */ extern JS_PUBLIC_API(bool) ToUint16Slow(JSContext *cx, JS::Handle v, uint16_t *out); /* DO NOT CALL THIS. Use JS::ToInt32. */ extern JS_PUBLIC_API(bool) ToInt32Slow(JSContext *cx, JS::Handle v, int32_t *out); /* DO NOT CALL THIS. Use JS::ToUint32. */ extern JS_PUBLIC_API(bool) ToUint32Slow(JSContext *cx, JS::Handle v, uint32_t *out); /* DO NOT CALL THIS. Use JS::ToInt64. */ extern JS_PUBLIC_API(bool) ToInt64Slow(JSContext *cx, JS::Handle v, int64_t *out); /* DO NOT CALL THIS. Use JS::ToUint64. */ extern JS_PUBLIC_API(bool) ToUint64Slow(JSContext *cx, JS::Handle v, uint64_t *out); } /* namespace js */ namespace JS { JS_ALWAYS_INLINE bool ToUint16(JSContext *cx, JS::Handle v, uint16_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = uint16_t(v.toInt32()); return true; } return js::ToUint16Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToInt32(JSContext *cx, JS::Handle v, int32_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = v.toInt32(); return true; } return js::ToInt32Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToUint32(JSContext *cx, JS::Handle v, uint32_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = uint32_t(v.toInt32()); return true; } return js::ToUint32Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToInt64(JSContext *cx, JS::Handle v, int64_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = int64_t(v.toInt32()); return true; } return js::ToInt64Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToUint64(JSContext *cx, JS::Handle v, uint64_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { /* Account for sign extension of negatives into the longer 64bit space. */ *out = uint64_t(int64_t(v.toInt32())); return true; } return js::ToUint64Slow(cx, v, out); } } /* namespace JS */ /* * Convert a value to a number, then to a uint32_t, according to the ECMA rules * for ToUint32. */ extern JS_PUBLIC_API(JSBool) JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32_t *ip); /* * Convert a value to a number, then to an int32_t if it fits by rounding to * nearest; but failing with an error report if the double is out of range * or unordered. */ extern JS_PUBLIC_API(JSBool) JS_ValueToInt32(JSContext *cx, jsval v, int32_t *ip); /* * ECMA ToUint16, for mapping a jsval to a Unicode point. */ extern JS_PUBLIC_API(JSBool) JS_ValueToUint16(JSContext *cx, jsval v, uint16_t *ip); extern JS_PUBLIC_API(JSBool) JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp); extern JS_PUBLIC_API(JSType) JS_TypeOfValue(JSContext *cx, jsval v); extern JS_PUBLIC_API(const char *) JS_GetTypeName(JSContext *cx, JSType type); extern JS_PUBLIC_API(JSBool) JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); extern JS_PUBLIC_API(JSBool) JS_LooselyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); extern JS_PUBLIC_API(JSBool) JS_SameValue(JSContext *cx, jsval v1, jsval v2, JSBool *same); /* True iff fun is the global eval function. */ extern JS_PUBLIC_API(JSBool) JS_IsBuiltinEvalFunction(JSFunction *fun); /* True iff fun is the Function constructor. */ extern JS_PUBLIC_API(JSBool) JS_IsBuiltinFunctionConstructor(JSFunction *fun); /************************************************************************/ /* * Initialization, locking, contexts, and memory allocation. * * It is important that the first runtime and first context be created in a * single-threaded fashion, otherwise the behavior of the library is undefined. * See: http://developer.mozilla.org/en/docs/Category:JSAPI_Reference */ typedef enum JSUseHelperThreads { JS_NO_HELPER_THREADS, JS_USE_HELPER_THREADS } JSUseHelperThreads; /** * Initialize SpiderMonkey, returning true only if initialization succeeded. * Once this method has succeeded, it is safe to call JS_NewRuntime and other * JSAPI methods. * * This method must be called before any other JSAPI method is used on any * thread. Once it has been used, it is safe to call any JSAPI method, and it * remains safe to do so until JS_ShutDown is correctly called. * * It is currently not possible to initialize SpiderMonkey multiple times (that * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so * again). This restriction may eventually be lifted. */ extern JS_PUBLIC_API(JSBool) JS_Init(void); /** * Destroy free-standing resources allocated by SpiderMonkey, not associated * with any runtime, context, or other structure. * * This method should be called after all other JSAPI data has been properly * cleaned up: every new runtime must have been destroyed, every new context * must have been destroyed, and so on. Calling this method before all other * resources have been destroyed has undefined behavior. * * Failure to call this method, at present, has no adverse effects other than * leaking memory. This may not always be the case; it's recommended that all * embedders call this method when all other JSAPI operations have completed. * * It is currently not possible to initialize SpiderMonkey multiple times (that * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so * again). This restriction may eventually be lifted. */ extern JS_PUBLIC_API(void) JS_ShutDown(void); extern JS_PUBLIC_API(JSRuntime *) JS_NewRuntime(uint32_t maxbytes, JSUseHelperThreads useHelperThreads); extern JS_PUBLIC_API(void) JS_DestroyRuntime(JSRuntime *rt); // These are equivalent to ICU's |UMemAllocFn|, |UMemReallocFn|, and // |UMemFreeFn| types. The first argument (called |context| in the ICU docs) // will always be NULL, and should be ignored. typedef void *(*JS_ICUAllocFn)(const void *, size_t size); typedef void *(*JS_ICUReallocFn)(const void *, void *p, size_t size); typedef void (*JS_ICUFreeFn)(const void *, void *p); // This function can be used to track memory used by ICU. // Do not use it unless you know what you are doing! extern JS_PUBLIC_API(bool) JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn, JS_ICUReallocFn reallocFn, JS_ICUFreeFn freeFn); JS_PUBLIC_API(void *) JS_GetRuntimePrivate(JSRuntime *rt); extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); JS_PUBLIC_API(void) JS_SetRuntimePrivate(JSRuntime *rt, void *data); extern JS_PUBLIC_API(void) JS_BeginRequest(JSContext *cx); extern JS_PUBLIC_API(void) JS_EndRequest(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_IsInRequest(JSRuntime *rt); namespace JS { inline bool IsPoisonedId(jsid iden) { if (JSID_IS_STRING(iden)) return JS::IsPoisonedPtr(JSID_TO_STRING(iden)); if (JSID_IS_OBJECT(iden)) return JS::IsPoisonedPtr(JSID_TO_OBJECT(iden)); return false; } } /* namespace JS */ namespace js { template <> struct GCMethods { static jsid initial() { return JSID_VOID; } static ThingRootKind kind() { return THING_ROOT_ID; } static bool poisoned(jsid id) { return JS::IsPoisonedId(id); } static bool needsPostBarrier(jsid id) { return false; } #ifdef JSGC_GENERATIONAL static void postBarrier(jsid *idp) {} static void relocate(jsid *idp) {} #endif }; } /* namespace js */ class JSAutoRequest { public: JSAutoRequest(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mContext(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; JS_BeginRequest(mContext); } ~JSAutoRequest() { JS_EndRequest(mContext); } protected: JSContext *mContext; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER #if 0 private: static void *operator new(size_t) CPP_THROW_NEW { return 0; }; static void operator delete(void *, size_t) { }; #endif }; class JSAutoCheckRequest { public: JSAutoCheckRequest(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { #if defined JS_THREADSAFE && defined DEBUG mContext = cx; JS_ASSERT(JS_IsInRequest(JS_GetRuntime(cx))); #endif MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~JSAutoCheckRequest() { #if defined JS_THREADSAFE && defined DEBUG JS_ASSERT(JS_IsInRequest(JS_GetRuntime(mContext))); #endif } private: #if defined JS_THREADSAFE && defined DEBUG JSContext *mContext; #endif MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; extern JS_PUBLIC_API(void) JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback, void *data); extern JS_PUBLIC_API(JSContext *) JS_NewContext(JSRuntime *rt, size_t stackChunkSize); extern JS_PUBLIC_API(void) JS_DestroyContext(JSContext *cx); extern JS_PUBLIC_API(void) JS_DestroyContextNoGC(JSContext *cx); extern JS_PUBLIC_API(void *) JS_GetContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetContextPrivate(JSContext *cx, void *data); extern JS_PUBLIC_API(void *) JS_GetSecondContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetSecondContextPrivate(JSContext *cx, void *data); extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); extern JS_PUBLIC_API(JSContext *) JS_ContextIterator(JSRuntime *rt, JSContext **iterp); extern JS_PUBLIC_API(JSVersion) JS_GetVersion(JSContext *cx); // Mutate the version on the compartment. This is generally discouraged, but // necessary to support the version mutation in the js and xpc shell command // set. // // It would be nice to put this in jsfriendapi, but the linkage requirements // of the shells make that impossible. JS_PUBLIC_API(void) JS_SetVersionForCompartment(JSCompartment *compartment, JSVersion version); extern JS_PUBLIC_API(const char *) JS_VersionToString(JSVersion version); extern JS_PUBLIC_API(JSVersion) JS_StringToVersion(const char *string); /* * JS options are orthogonal to version, and may be freely composed with one * another as well as with version. * * JSOPTION_VAROBJFIX is recommended -- see the comments associated with the * prototypes for JS_ExecuteScript, JS_EvaluateScript, etc. */ #define JSOPTION_EXTRA_WARNINGS JS_BIT(0) /* warn on dubious practices */ #define JSOPTION_WERROR JS_BIT(1) /* convert warning to error */ #define JSOPTION_VAROBJFIX JS_BIT(2) /* make JS_EvaluateScript use the last object on its 'obj' param's scope chain as the ECMA 'variables object' */ #define JSOPTION_PRIVATE_IS_NSISUPPORTS \ JS_BIT(3) /* context private data points to an nsISupports subclass */ #define JSOPTION_COMPILE_N_GO JS_BIT(4) /* caller of JS_Compile*Script promises to execute compiled script once only; enables compile-time scope chain resolution of consts. */ /* JS_BIT(5) is currently unused. */ /* JS_BIT(6) is currently unused. */ /* JS_BIT(7) is currently unused. */ #define JSOPTION_DONT_REPORT_UNCAUGHT \ JS_BIT(8) /* When returning from the outermost API call, prevent uncaught exceptions from being converted to error reports */ /* JS_BIT(9) is currently unused. */ /* JS_BIT(10) is currently unused. */ /* JS_BIT(11) is currently unused. */ #define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12) /* A promise to the compiler that a null rval out-param will be passed to each call to JS_ExecuteScript. */ #define JSOPTION_UNROOTED_GLOBAL JS_BIT(13) /* The GC will not root the contexts' default compartment object, leaving that up to the embedding. */ #define JSOPTION_BASELINE JS_BIT(14) /* Baseline compiler. */ #define JSOPTION_TYPE_INFERENCE JS_BIT(16) /* Perform type inference. */ #define JSOPTION_STRICT_MODE JS_BIT(17) /* Provides a way to force strict mode for all code without requiring "use strict" annotations. */ #define JSOPTION_ION JS_BIT(18) /* IonMonkey */ #define JSOPTION_ASMJS JS_BIT(19) /* optimizingasm.js compiler */ #define JSOPTION_MASK JS_BITMASK(20) extern JS_PUBLIC_API(uint32_t) JS_GetOptions(JSContext *cx); extern JS_PUBLIC_API(uint32_t) JS_SetOptions(JSContext *cx, uint32_t options); extern JS_PUBLIC_API(uint32_t) JS_ToggleOptions(JSContext *cx, uint32_t options); extern JS_PUBLIC_API(void) JS_SetJitHardening(JSRuntime *rt, JSBool enabled); extern JS_PUBLIC_API(const char *) JS_GetImplementationVersion(void); extern JS_PUBLIC_API(void) JS_SetDestroyCompartmentCallback(JSRuntime *rt, JSDestroyCompartmentCallback callback); extern JS_PUBLIC_API(void) JS_SetCompartmentNameCallback(JSRuntime *rt, JSCompartmentNameCallback callback); extern JS_PUBLIC_API(JSWrapObjectCallback) JS_SetWrapObjectCallbacks(JSRuntime *rt, JSWrapObjectCallback callback, JSSameCompartmentWrapObjectCallback sccallback, JSPreWrapCallback precallback); extern JS_PUBLIC_API(void) JS_SetCompartmentPrivate(JSCompartment *compartment, void *data); extern JS_PUBLIC_API(void *) JS_GetCompartmentPrivate(JSCompartment *compartment); extern JS_PUBLIC_API(JSBool) JS_WrapObject(JSContext *cx, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_WrapValue(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_WrapId(JSContext *cx, jsid *idp); extern JS_PUBLIC_API(JSObject *) JS_TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target); extern JS_FRIEND_API(JSObject *) js_TransplantObjectWithWrapper(JSContext *cx, JS::HandleObject origobj, JS::HandleObject origwrapper, JS::HandleObject targetobj, JS::HandleObject targetwrapper); extern JS_PUBLIC_API(JSBool) JS_RefreshCrossCompartmentWrappers(JSContext *cx, JSObject *ob); /* * At any time, a JSContext has a current (possibly-NULL) compartment. * Compartments are described in: * * developer.mozilla.org/en-US/docs/SpiderMonkey/SpiderMonkey_compartments * * The current compartment of a context may be changed. The preferred way to do * this is with JSAutoCompartment: * * void foo(JSContext *cx, JSObject *obj) { * // in some compartment 'c' * { * JSAutoCompartment ac(cx, obj); // constructor enters * // in the compartment of 'obj' * } // destructor leaves * // back in compartment 'c' * } * * For more complicated uses that don't neatly fit in a C++ stack frame, the * compartment can entered and left using separate function calls: * * void foo(JSContext *cx, JSObject *obj) { * // in 'oldCompartment' * JSCompartment *oldCompartment = JS_EnterCompartment(cx, obj); * // in the compartment of 'obj' * JS_LeaveCompartment(cx, oldCompartment); * // back in 'oldCompartment' * } * * Note: these calls must still execute in a LIFO manner w.r.t all other * enter/leave calls on the context. Furthermore, only the return value of a * JS_EnterCompartment call may be passed as the 'oldCompartment' argument of * the corresponding JS_LeaveCompartment call. */ class JS_PUBLIC_API(JSAutoCompartment) { JSContext *cx_; JSCompartment *oldCompartment_; public: JSAutoCompartment(JSContext *cx, JSObject *target); JSAutoCompartment(JSContext *cx, JSScript *target); ~JSAutoCompartment(); }; /* NB: This API is infallible; a NULL return value does not indicate error. */ extern JS_PUBLIC_API(JSCompartment *) JS_EnterCompartment(JSContext *cx, JSObject *target); extern JS_PUBLIC_API(void) JS_LeaveCompartment(JSContext *cx, JSCompartment *oldCompartment); typedef void (*JSIterateCompartmentCallback)(JSRuntime *rt, void *data, JSCompartment *compartment); /* * This function calls |compartmentCallback| on every compartment. Beware that * there is no guarantee that the compartment will survive after the callback * returns. */ extern JS_PUBLIC_API(void) JS_IterateCompartments(JSRuntime *rt, void *data, JSIterateCompartmentCallback compartmentCallback); /* * Initialize standard JS class constructors, prototypes, and any top-level * functions and constants associated with the standard classes (e.g. isNaN * for Number). * * NB: This sets cx's global object to obj if it was null. */ extern JS_PUBLIC_API(JSBool) JS_InitStandardClasses(JSContext *cx, JSObject *obj); /* * Resolve id, which must contain either a string or an int, to a standard * class name in obj if possible, defining the class's constructor and/or * prototype and storing true in *resolved. If id does not name a standard * class or a top-level property induced by initializing a standard class, * store false in *resolved and just return true. Return false on error, * as usual for JSBool result-typed API entry points. * * This API can be called directly from a global object class's resolve op, * to define standard classes lazily. The class's enumerate op should call * JS_EnumerateStandardClasses(cx, obj), to define eagerly during for..in * loops any classes not yet resolved lazily. */ extern JS_PUBLIC_API(JSBool) JS_ResolveStandardClass(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool *resolved); extern JS_PUBLIC_API(JSBool) JS_EnumerateStandardClasses(JSContext *cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSBool) JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_GetClassPrototype(JSContext *cx, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSProtoKey) JS_IdentifyClassPrototype(JSContext *cx, JSObject *obj); /* * Returns the original value of |Function.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetFunctionPrototype(JSContext *cx, JSObject *forObj); /* * Returns the original value of |Object.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetObjectPrototype(JSContext *cx, JSObject *forObj); /* * Returns the original value of |Array.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetArrayPrototype(JSContext *cx, JSObject *forObj); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_IsGlobalObject(JSObject *obj); /* * May return NULL, if |c| never had a global (e.g. the atoms compartment), or * if |c|'s global has been collected. */ extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForCompartmentOrNull(JSContext *cx, JSCompartment *c); namespace JS { extern JS_PUBLIC_API(JSObject *) CurrentGlobalOrNull(JSContext *cx); } /* * This method returns the global corresponding to the most recent scripted * frame, which may not match the cx's current compartment. This is extremely * dangerous, because it can bypass compartment security invariants in subtle * ways. To use it safely, the caller must perform a subsequent security * check. There is currently only one consumer of this function in Gecko, and * it should probably stay that way. If you'd like to use it, please consult * the XPConnect module owner first. */ extern JS_PUBLIC_API(JSObject *) JS_GetScriptedGlobal(JSContext *cx); /* * Initialize the 'Reflect' object on a global object. */ extern JS_PUBLIC_API(JSObject *) JS_InitReflect(JSContext *cx, JSObject *global); #ifdef JS_HAS_CTYPES /* * Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes' * object will be sealed. */ extern JS_PUBLIC_API(JSBool) JS_InitCTypesClass(JSContext *cx, JSObject *global); /* * Convert a unicode string 'source' of length 'slen' to the platform native * charset, returning a null-terminated string allocated with JS_malloc. On * failure, this function should report an error. */ typedef char * (* JSCTypesUnicodeToNativeFun)(JSContext *cx, const jschar *source, size_t slen); /* * Set of function pointers that ctypes can use for various internal functions. * See JS_SetCTypesCallbacks below. Providing NULL for a function is safe, * and will result in the applicable ctypes functionality not being available. */ struct JSCTypesCallbacks { JSCTypesUnicodeToNativeFun unicodeToNative; }; typedef struct JSCTypesCallbacks JSCTypesCallbacks; /* * Set the callbacks on the provided 'ctypesObj' object. 'callbacks' should be a * pointer to static data that exists for the lifetime of 'ctypesObj', but it * may safely be altered after calling this function and without having * to call this function again. */ extern JS_PUBLIC_API(void) JS_SetCTypesCallbacks(JSObject *ctypesObj, JSCTypesCallbacks *callbacks); #endif typedef JSBool (* JSEnumerateDiagnosticMemoryCallback)(void *ptr, size_t length); /* * Enumerate memory regions that contain diagnostic information * intended to be included in crash report minidumps. */ extern JS_PUBLIC_API(void) JS_EnumerateDiagnosticMemoryRegions(JSEnumerateDiagnosticMemoryCallback callback); extern JS_PUBLIC_API(void *) JS_malloc(JSContext *cx, size_t nbytes); extern JS_PUBLIC_API(void *) JS_realloc(JSContext *cx, void *p, size_t nbytes); /* * A wrapper for js_free(p) that may delay js_free(p) invocation as a * performance optimization. * cx may be NULL. */ extern JS_PUBLIC_API(void) JS_free(JSContext *cx, void *p); /* * A wrapper for js_free(p) that may delay js_free(p) invocation as a * performance optimization as specified by the given JSFreeOp instance. */ extern JS_PUBLIC_API(void) JS_freeop(JSFreeOp *fop, void *p); extern JS_PUBLIC_API(JSFreeOp *) JS_GetDefaultFreeOp(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_updateMallocCounter(JSContext *cx, size_t nbytes); extern JS_PUBLIC_API(char *) JS_strdup(JSContext *cx, const char *s); /* Duplicate a string. Does not report an error on failure. */ extern JS_PUBLIC_API(char *) JS_strdup(JSRuntime *rt, const char *s); /* * A GC root is a pointer to a jsval, JSObject * or JSString * that itself * points into the GC heap. JS_AddValueRoot takes a pointer to a jsval and * JS_AddGCThingRoot takes a pointer to a JSObject * or JString *. * * Note that, since JS_Add*Root stores the address of a variable (of type * jsval, JSString *, or JSObject *), that variable must live until * JS_Remove*Root is called to remove that variable. For example, after: * * void some_function() { * jsval v; * JS_AddNamedValueRoot(cx, &v, "name"); * * the caller must perform * * JS_RemoveValueRoot(cx, &v); * * before some_function() returns. * * Also, use JS_AddNamed*Root(cx, &structPtr->memberObj, "structPtr->memberObj") * in preference to JS_Add*Root(cx, &structPtr->memberObj), in order to identify * roots by their source callsites. This way, you can find the callsite while * debugging if you should fail to do JS_Remove*Root(cx, &structPtr->memberObj) * before freeing structPtr's memory. */ extern JS_PUBLIC_API(JSBool) JS_AddValueRoot(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_AddStringRoot(JSContext *cx, JSString **rp); extern JS_PUBLIC_API(JSBool) JS_AddObjectRoot(JSContext *cx, JSObject **rp); #ifdef NAME_ALL_GC_ROOTS #define JS_DEFINE_TO_TOKEN(def) #def #define JS_DEFINE_TO_STRING(def) JS_DEFINE_TO_TOKEN(def) #define JS_AddValueRoot(cx,vp) JS_AddNamedValueRoot((cx), (vp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #define JS_AddStringRoot(cx,rp) JS_AddNamedStringRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #define JS_AddObjectRoot(cx,rp) JS_AddNamedObjectRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #endif extern JS_PUBLIC_API(JSBool) JS_AddNamedValueRoot(JSContext *cx, jsval *vp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedValueRootRT(JSRuntime *rt, jsval *vp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedStringRoot(JSContext *cx, JSString **rp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedObjectRoot(JSContext *cx, JSObject **rp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedScriptRoot(JSContext *cx, JSScript **rp, const char *name); extern JS_PUBLIC_API(void) JS_RemoveValueRoot(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(void) JS_RemoveStringRoot(JSContext *cx, JSString **rp); extern JS_PUBLIC_API(void) JS_RemoveObjectRoot(JSContext *cx, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRoot(JSContext *cx, JSScript **rp); extern JS_PUBLIC_API(void) JS_RemoveValueRootRT(JSRuntime *rt, jsval *vp); extern JS_PUBLIC_API(void) JS_RemoveStringRootRT(JSRuntime *rt, JSString **rp); extern JS_PUBLIC_API(void) JS_RemoveObjectRootRT(JSRuntime *rt, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRootRT(JSRuntime *rt, JSScript **rp); /* TODO: remove these APIs */ extern JS_FRIEND_API(void) js_RemoveRoot(JSRuntime *rt, void *rp); /* * C-compatible version of the Anchor class. It should be called after the last * use of the variable it protects. */ extern JS_NEVER_INLINE JS_PUBLIC_API(void) JS_AnchorPtr(void *p); /* * Register externally maintained GC roots. * * traceOp: the trace operation. For each root the implementation should call * JS_CallTracer whenever the root contains a traceable thing. * data: the data argument to pass to each invocation of traceOp. */ extern JS_PUBLIC_API(JSBool) JS_AddExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); /* Undo a call to JS_AddExtraGCRootsTracer. */ extern JS_PUBLIC_API(void) JS_RemoveExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); /* * JS_CallTracer API and related macros for implementors of JSTraceOp, to * enumerate all references to traceable things reachable via a property or * other strong ref identified for debugging purposes by name or index or * a naming callback. * * See the JSTraceOp typedef. */ /* * Use the following macros to check if a particular jsval is a traceable * thing and to extract the thing and its kind to pass to JS_CallTracer. */ static JS_ALWAYS_INLINE JSBool JSVAL_IS_TRACEABLE(jsval v) { return JSVAL_IS_TRACEABLE_IMPL(JSVAL_TO_IMPL(v)); } static JS_ALWAYS_INLINE void * JSVAL_TO_TRACEABLE(jsval v) { return JSVAL_TO_GCTHING(v); } static JS_ALWAYS_INLINE JSGCTraceKind JSVAL_TRACE_KIND(jsval v) { JS_ASSERT(JSVAL_IS_GCTHING(v)); return (JSGCTraceKind) JSVAL_TRACE_KIND_IMPL(JSVAL_TO_IMPL(v)); } /* * Tracer callback, called for each traceable thing directly referenced by a * particular object or runtime structure. It is the callback responsibility * to ensure the traversal of the full object graph via calling eventually * JS_TraceChildren on the passed thing. In this case the callback must be * prepared to deal with cycles in the traversal graph. * * kind argument is one of JSTRACE_OBJECT, JSTRACE_STRING or a tag denoting * internal implementation-specific traversal kind. In the latter case the only * operations on thing that the callback can do is to call JS_TraceChildren or * JS_GetTraceThingInfo. * * If eagerlyTraceWeakMaps is true, when we trace a WeakMap visit all * of its mappings. This should be used in cases where the tracer * wants to use the existing liveness of entries. */ typedef void (* JSTraceCallback)(JSTracer *trc, void **thingp, JSGCTraceKind kind); enum WeakMapTraceKind { DoNotTraceWeakMaps = 0, TraceWeakMapValues = 1, TraceWeakMapKeysValues = 2 }; struct JSTracer { JSRuntime *runtime; JSTraceCallback callback; JSTraceNamePrinter debugPrinter; const void *debugPrintArg; size_t debugPrintIndex; WeakMapTraceKind eagerlyTraceWeakMaps; #ifdef JS_GC_ZEAL void *realLocation; #endif }; /* * Set debugging information about a reference to a traceable thing to prepare * for the following call to JS_CallTracer. * * When printer is null, arg must be const char * or char * C string naming * the reference and index must be either (size_t)-1 indicating that the name * alone describes the reference or it must be an index into some array vector * that stores the reference. * * When printer callback is not null, the arg and index arguments are * available to the callback as debugPrintArg and debugPrintIndex fields * of JSTracer. * * The storage for name or callback's arguments needs to live only until * the following call to JS_CallTracer returns. */ # define JS_SET_TRACING_DETAILS(trc, printer, arg, index) \ JS_BEGIN_MACRO \ (trc)->debugPrinter = (printer); \ (trc)->debugPrintArg = (arg); \ (trc)->debugPrintIndex = (index); \ JS_END_MACRO /* * Sets the real location for a marked reference, when passing the address * directly is not feasable. * * FIXME: This is currently overcomplicated by our need to nest calls for Values * stored as keys in hash tables, but will get simplified once we can rekey * in-place. */ #ifdef JS_GC_ZEAL # define JS_SET_TRACING_LOCATION(trc, location) \ JS_BEGIN_MACRO \ if (!(trc)->realLocation || !(location)) \ (trc)->realLocation = (location); \ JS_END_MACRO # define JS_UNSET_TRACING_LOCATION(trc) \ JS_BEGIN_MACRO \ (trc)->realLocation = NULL; \ JS_END_MACRO #else # define JS_SET_TRACING_LOCATION(trc, location) \ JS_BEGIN_MACRO \ JS_END_MACRO # define JS_UNSET_TRACING_LOCATION(trc) \ JS_BEGIN_MACRO \ JS_END_MACRO #endif /* * Convenience macro to describe the argument of JS_CallTracer using C string * and index. */ # define JS_SET_TRACING_INDEX(trc, name, index) \ JS_SET_TRACING_DETAILS(trc, NULL, name, index) /* * Convenience macro to describe the argument of JS_CallTracer using C string. */ # define JS_SET_TRACING_NAME(trc, name) \ JS_SET_TRACING_DETAILS(trc, NULL, name, (size_t)-1) /* * The JS_Call*Tracer family of functions traces the given GC thing reference. * This performs the tracing action configured on the given JSTracer: * typically calling the JSTracer::callback or marking the thing as live. * * The argument to JS_Call*Tracer is an in-out param: when the function * returns, the garbage collector might have moved the GC thing. In this case, * the reference passed to JS_Call*Tracer will be updated to the object's new * location. Callers of this method are responsible for updating any state * that is dependent on the object's address. For example, if the object's * address is used as a key in a hashtable, then the object must be removed * and re-inserted with the correct hash. */ extern JS_PUBLIC_API(void) JS_CallValueTracer(JSTracer *trc, JS::Value *valuep, const char *name); extern JS_PUBLIC_API(void) JS_CallIdTracer(JSTracer *trc, jsid *idp, const char *name); extern JS_PUBLIC_API(void) JS_CallObjectTracer(JSTracer *trc, JSObject **objp, const char *name); extern JS_PUBLIC_API(void) JS_CallStringTracer(JSTracer *trc, JSString **strp, const char *name); extern JS_PUBLIC_API(void) JS_CallScriptTracer(JSTracer *trc, JSScript **scriptp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapValueTracer(JSTracer *trc, JS::Heap *valuep, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapIdTracer(JSTracer *trc, JS::Heap *idp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapObjectTracer(JSTracer *trc, JS::Heap *objp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapStringTracer(JSTracer *trc, JS::Heap *strp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapScriptTracer(JSTracer *trc, JS::Heap *scriptp, const char *name); template inline void JS_CallHashSetObjectTracer(JSTracer *trc, HashSetEnum &e, JSObject *const &key, const char *name) { JSObject *updated = key; JS_SET_TRACING_LOCATION(trc, reinterpret_cast(&const_cast(key))); JS_CallObjectTracer(trc, &updated, name); if (updated != key) e.rekeyFront(key, updated); } /* * Trace an object that is known to always be tenured. No post barriers are * required in this case. */ extern JS_PUBLIC_API(void) JS_CallTenuredObjectTracer(JSTracer *trc, JS::TenuredHeap *objp, const char *name); /* * API for JSTraceCallback implementations. */ extern JS_PUBLIC_API(void) JS_TracerInit(JSTracer *trc, JSRuntime *rt, JSTraceCallback callback); extern JS_PUBLIC_API(void) JS_TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind); extern JS_PUBLIC_API(void) JS_TraceRuntime(JSTracer *trc); extern JS_PUBLIC_API(void) JS_GetTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing, JSGCTraceKind kind, JSBool includeDetails); extern JS_PUBLIC_API(const char *) JS_GetTraceEdgeName(JSTracer *trc, char *buffer, int bufferSize); #ifdef DEBUG /* * DEBUG-only method to dump the object graph of heap-allocated things. * * fp: file for the dump output. * start: when non-null, dump only things reachable from start * thing. Otherwise dump all things reachable from the * runtime roots. * startKind: trace kind of start if start is not null. Must be * JSTRACE_OBJECT when start is null. * thingToFind: dump only paths in the object graph leading to thingToFind * when non-null. * maxDepth: the upper bound on the number of edges to descend from the * graph roots. * thingToIgnore: thing to ignore during the graph traversal when non-null. */ extern JS_PUBLIC_API(JSBool) JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind kind, void *thingToFind, size_t maxDepth, void *thingToIgnore); #endif /* * Garbage collector API. */ extern JS_PUBLIC_API(void) JS_GC(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_MaybeGC(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetGCCallback(JSRuntime *rt, JSGCCallback cb, void *data); extern JS_PUBLIC_API(void) JS_SetFinalizeCallback(JSRuntime *rt, JSFinalizeCallback cb); extern JS_PUBLIC_API(JSBool) JS_IsGCMarkingTracer(JSTracer *trc); /* * JS_IsAboutToBeFinalized checks if the given object is going to be finalized * at the end of the current GC. When called outside of the context of a GC, * this function will return false. Typically this function is used on weak * references, where the reference should be nulled out or destroyed if the * given object is about to be finalized. * * The argument to JS_IsAboutToBeFinalized is an in-out param: when the * function returns false, the object being referenced is still alive, but the * garbage collector might have moved it. In this case, the reference passed * to JS_IsAboutToBeFinalized will be updated to the object's new location. * Callers of this method are responsible for updating any state that is * dependent on the object's address. For example, if the object's address is * used as a key in a hashtable, then the object must be removed and * re-inserted with the correct hash. */ extern JS_PUBLIC_API(JSBool) JS_IsAboutToBeFinalized(JS::Heap *objp); extern JS_PUBLIC_API(JSBool) JS_IsAboutToBeFinalizedUnbarriered(JSObject **objp); typedef enum JSGCParamKey { /* Maximum nominal heap before last ditch GC. */ JSGC_MAX_BYTES = 0, /* Number of JS_malloc bytes before last ditch GC. */ JSGC_MAX_MALLOC_BYTES = 1, /* Amount of bytes allocated by the GC. */ JSGC_BYTES = 3, /* Number of times when GC was invoked. */ JSGC_NUMBER = 4, /* Max size of the code cache in bytes. */ JSGC_MAX_CODE_CACHE_BYTES = 5, /* Select GC mode. */ JSGC_MODE = 6, /* Number of cached empty GC chunks. */ JSGC_UNUSED_CHUNKS = 7, /* Total number of allocated GC chunks. */ JSGC_TOTAL_CHUNKS = 8, /* Max milliseconds to spend in an incremental GC slice. */ JSGC_SLICE_TIME_BUDGET = 9, /* Maximum size the GC mark stack can grow to. */ JSGC_MARK_STACK_LIMIT = 10, /* * GCs less than this far apart in time will be considered 'high-frequency GCs'. * See setGCLastBytes in jsgc.cpp. */ JSGC_HIGH_FREQUENCY_TIME_LIMIT = 11, /* Start of dynamic heap growth. */ JSGC_HIGH_FREQUENCY_LOW_LIMIT = 12, /* End of dynamic heap growth. */ JSGC_HIGH_FREQUENCY_HIGH_LIMIT = 13, /* Upper bound of heap growth. */ JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX = 14, /* Lower bound of heap growth. */ JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN = 15, /* Heap growth for low frequency GCs. */ JSGC_LOW_FREQUENCY_HEAP_GROWTH = 16, /* * If false, the heap growth factor is fixed at 3. If true, it is determined * based on whether GCs are high- or low- frequency. */ JSGC_DYNAMIC_HEAP_GROWTH = 17, /* If true, high-frequency GCs will use a longer mark slice. */ JSGC_DYNAMIC_MARK_SLICE = 18, /* Number of megabytes of analysis data to allocate before purging. */ JSGC_ANALYSIS_PURGE_TRIGGER = 19, /* Lower limit after which we limit the heap growth. */ JSGC_ALLOCATION_THRESHOLD = 20, /* * We decommit memory lazily. If more than this number of megabytes is * available to be decommitted, then JS_MaybeGC will trigger a shrinking GC * to decommit it. */ JSGC_DECOMMIT_THRESHOLD = 21 } JSGCParamKey; typedef enum JSGCMode { /* Perform only global GCs. */ JSGC_MODE_GLOBAL = 0, /* Perform per-compartment GCs until too much garbage has accumulated. */ JSGC_MODE_COMPARTMENT = 1, /* * Collect in short time slices rather than all at once. Implies * JSGC_MODE_COMPARTMENT. */ JSGC_MODE_INCREMENTAL = 2 } JSGCMode; extern JS_PUBLIC_API(void) JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32_t value); extern JS_PUBLIC_API(uint32_t) JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key); extern JS_PUBLIC_API(void) JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32_t value); extern JS_PUBLIC_API(uint32_t) JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key); /* * Create a new JSString whose chars member refers to external memory, i.e., * memory requiring application-specific finalization. */ extern JS_PUBLIC_API(JSString *) JS_NewExternalString(JSContext *cx, const jschar *chars, size_t length, const JSStringFinalizer *fin); /* * Return whether 'str' was created with JS_NewExternalString or * JS_NewExternalStringWithClosure. */ extern JS_PUBLIC_API(JSBool) JS_IsExternalString(JSString *str); /* * Return the 'closure' arg passed to JS_NewExternalStringWithClosure or NULL * if the external string was created via JS_NewExternalString. */ extern JS_PUBLIC_API(const JSStringFinalizer *) JS_GetExternalStringFinalizer(JSString *str); /* * Set the size of the native stack that should not be exceed. To disable * stack size checking pass 0. */ extern JS_PUBLIC_API(void) JS_SetNativeStackQuota(JSRuntime *cx, size_t stackSize); /************************************************************************/ /* * Classes, objects, and properties. */ typedef void (*JSClassInternal)(); struct JSClass { const char *name; uint32_t flags; /* Mandatory function pointer members. */ JSPropertyOp addProperty; JSDeletePropertyOp delProperty; JSPropertyOp getProperty; JSStrictPropertyOp setProperty; JSEnumerateOp enumerate; JSResolveOp resolve; JSConvertOp convert; /* Optional members (may be null). */ JSFinalizeOp finalize; JSCheckAccessOp checkAccess; JSNative call; JSHasInstanceOp hasInstance; JSNative construct; JSTraceOp trace; void *reserved[40]; }; #define JSCLASS_HAS_PRIVATE (1<<0) /* objects have private slot */ #define JSCLASS_NEW_ENUMERATE (1<<1) /* has JSNewEnumerateOp hook */ #define JSCLASS_NEW_RESOLVE (1<<2) /* has JSNewResolveOp hook */ #define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) /* private is (nsISupports *) */ #define JSCLASS_IS_DOMJSCLASS (1<<4) /* objects are DOM */ #define JSCLASS_IMPLEMENTS_BARRIERS (1<<5) /* Correctly implements GC read and write barriers */ #define JSCLASS_EMULATES_UNDEFINED (1<<6) /* objects of this class act like the value undefined, in some contexts */ #define JSCLASS_USERBIT1 (1<<7) /* Reserved for embeddings. */ /* * To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise-or * JSCLASS_HAS_RESERVED_SLOTS(n) into the initializer for JSClass.flags, where * n is a constant in [1, 255]. Reserved slots are indexed from 0 to n-1. */ #define JSCLASS_RESERVED_SLOTS_SHIFT 8 /* room for 8 flags below */ #define JSCLASS_RESERVED_SLOTS_WIDTH 8 /* and 16 above this field */ #define JSCLASS_RESERVED_SLOTS_MASK JS_BITMASK(JSCLASS_RESERVED_SLOTS_WIDTH) #define JSCLASS_HAS_RESERVED_SLOTS(n) (((n) & JSCLASS_RESERVED_SLOTS_MASK) \ << JSCLASS_RESERVED_SLOTS_SHIFT) #define JSCLASS_RESERVED_SLOTS(clasp) (((clasp)->flags \ >> JSCLASS_RESERVED_SLOTS_SHIFT) \ & JSCLASS_RESERVED_SLOTS_MASK) #define JSCLASS_HIGH_FLAGS_SHIFT (JSCLASS_RESERVED_SLOTS_SHIFT + \ JSCLASS_RESERVED_SLOTS_WIDTH) #define JSCLASS_IS_ANONYMOUS (1<<(JSCLASS_HIGH_FLAGS_SHIFT+0)) #define JSCLASS_IS_GLOBAL (1<<(JSCLASS_HIGH_FLAGS_SHIFT+1)) #define JSCLASS_INTERNAL_FLAG2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2)) #define JSCLASS_INTERNAL_FLAG3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+3)) /* Indicate whether the proto or ctor should be frozen. */ #define JSCLASS_FREEZE_PROTO (1<<(JSCLASS_HIGH_FLAGS_SHIFT+4)) #define JSCLASS_FREEZE_CTOR (1<<(JSCLASS_HIGH_FLAGS_SHIFT+5)) /* Reserved for embeddings. */ #define JSCLASS_USERBIT2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+6)) #define JSCLASS_USERBIT3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+7)) #define JSCLASS_BACKGROUND_FINALIZE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+8)) /* * Bits 26 through 31 are reserved for the CACHED_PROTO_KEY mechanism, see * below. */ /* Global flags. */ #define JSGLOBAL_FLAGS_CLEARED 0x1 /* * ECMA-262 requires that most constructors used internally create objects * with "the original Foo.prototype value" as their [[Prototype]] (__proto__) * member initial value. The "original ... value" verbiage is there because * in ECMA-262, global properties naming class objects are read/write and * deleteable, for the most part. * * Implementing this efficiently requires that global objects have classes * with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS was * prevously allowed, but is now an ES5 violation and thus unsupported. */ #define JSCLASS_GLOBAL_SLOT_COUNT (JSProto_LIMIT * 3 + 25) #define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \ (JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n))) #define JSCLASS_GLOBAL_FLAGS \ JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(0) #define JSCLASS_HAS_GLOBAL_FLAG_AND_SLOTS(clasp) \ (((clasp)->flags & JSCLASS_IS_GLOBAL) \ && JSCLASS_RESERVED_SLOTS(clasp) >= JSCLASS_GLOBAL_SLOT_COUNT) /* Fast access to the original value of each standard class's prototype. */ #define JSCLASS_CACHED_PROTO_SHIFT (JSCLASS_HIGH_FLAGS_SHIFT + 10) #define JSCLASS_CACHED_PROTO_WIDTH 6 #define JSCLASS_CACHED_PROTO_MASK JS_BITMASK(JSCLASS_CACHED_PROTO_WIDTH) #define JSCLASS_HAS_CACHED_PROTO(key) (uint32_t(key) << JSCLASS_CACHED_PROTO_SHIFT) #define JSCLASS_CACHED_PROTO_KEY(clasp) ((JSProtoKey) \ (((clasp)->flags \ >> JSCLASS_CACHED_PROTO_SHIFT) \ & JSCLASS_CACHED_PROTO_MASK)) /* Initializer for unused members of statically initialized JSClass structs. */ #define JSCLASS_NO_INTERNAL_MEMBERS {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} #define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,JSCLASS_NO_INTERNAL_MEMBERS extern JS_PUBLIC_API(int) JS_IdArrayLength(JSContext *cx, JSIdArray *ida); extern JS_PUBLIC_API(jsid) JS_IdArrayGet(JSContext *cx, JSIdArray *ida, int index); extern JS_PUBLIC_API(void) JS_DestroyIdArray(JSContext *cx, JSIdArray *ida); namespace JS { class AutoIdArray : private AutoGCRooter { public: AutoIdArray(JSContext *cx, JSIdArray *ida MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, IDARRAY), context(cx), idArray(ida) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~AutoIdArray() { if (idArray) JS_DestroyIdArray(context, idArray); } bool operator!() { return !idArray; } jsid operator[](size_t i) const { JS_ASSERT(idArray); JS_ASSERT(i < length()); return JS_IdArrayGet(context, idArray, i); } size_t length() const { return JS_IdArrayLength(context, idArray); } friend void AutoGCRooter::trace(JSTracer *trc); JSIdArray *steal() { JSIdArray *copy = idArray; idArray = NULL; return copy; } protected: inline void trace(JSTracer *trc); private: JSContext *context; JSIdArray *idArray; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER /* No copy or assignment semantics. */ AutoIdArray(AutoIdArray &ida) MOZ_DELETE; void operator=(AutoIdArray &ida) MOZ_DELETE; }; } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_ValueToId(JSContext *cx, jsval v, jsid *idp); extern JS_PUBLIC_API(JSBool) JS_IdToValue(JSContext *cx, jsid id, jsval *vp); /* * JSNewResolveOp flag bits. */ #define JSRESOLVE_ASSIGNING 0x01 /* resolve on the left of assignment */ /* * Invoke the [[DefaultValue]] hook (see ES5 8.6.2) with the provided hint on * the specified object, computing a primitive default value for the object. * The hint must be JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_VOID (no hint). On * success the resulting value is stored in *vp. */ extern JS_PUBLIC_API(JSBool) JS_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_PropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_StrictPropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool strict, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool *succeeded); extern JS_PUBLIC_API(JSBool) JS_EnumerateStub(JSContext *cx, JS::Handle obj); extern JS_PUBLIC_API(JSBool) JS_ResolveStub(JSContext *cx, JS::Handle obj, JS::Handle id); extern JS_PUBLIC_API(JSBool) JS_ConvertStub(JSContext *cx, JS::Handle obj, JSType type, JS::MutableHandle vp); struct JSConstDoubleSpec { double dval; const char *name; uint8_t flags; uint8_t spare[3]; }; typedef struct JSJitInfo JSJitInfo; /* * Wrappers to replace {Strict,}PropertyOp for JSPropertySpecs. This will allow * us to pass one JSJitInfo per function with the property spec, without * additional field overhead. */ typedef struct JSStrictPropertyOpWrapper { JSStrictPropertyOp op; const JSJitInfo *info; } JSStrictPropertyOpWrapper; typedef struct JSPropertyOpWrapper { JSPropertyOp op; const JSJitInfo *info; } JSPropertyOpWrapper; /* * Wrapper to do as above, but for JSNatives for JSFunctionSpecs. */ typedef struct JSNativeWrapper { JSNative op; const JSJitInfo *info; } JSNativeWrapper; /* * Macro static initializers which make it easy to pass no JSJitInfo as part of a * JSPropertySpec or JSFunctionSpec. */ #define JSOP_WRAPPER(op) {op, NULL} #define JSOP_NULLWRAPPER JSOP_WRAPPER(NULL) /* * To define an array element rather than a named property member, cast the * element's index to (const char *) and initialize name with it, and set the * JSPROP_INDEX bit in flags. */ struct JSPropertySpec { const char *name; int8_t tinyid; uint8_t flags; JSPropertyOpWrapper getter; JSStrictPropertyOpWrapper setter; }; namespace JS { namespace detail { /* NEVER DEFINED, DON'T USE. For use by JS_CAST_NATIVE_TO only. */ inline int CheckIsNative(JSNative native); } // namespace detail } // namespace JS #define JS_CAST_NATIVE_TO(v, To) \ (static_cast(sizeof(JS::detail::CheckIsNative(v))), \ reinterpret_cast(v)) /* * JSPropertySpec uses JSAPI JSPropertyOp and JSStrictPropertyOp in function * signatures, but with JSPROP_NATIVE_ACCESSORS the actual values must be * JSNatives. To avoid widespread casting, have JS_PSG and JS_PSGS perform * type-safe casts. */ #define JS_PSG(name, getter, flags) \ {name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(getter, JSPropertyOp)), \ JSOP_NULLWRAPPER} #define JS_PSGS(name, getter, setter, flags) \ {name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(getter, JSPropertyOp)), \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(setter, JSStrictPropertyOp))} #define JS_PS_END {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} /* * To define a native function, set call to a JSNativeWrapper. To define a * self-hosted function, set selfHostedName to the name of a function * compiled during JSRuntime::initSelfHosting. */ struct JSFunctionSpec { const char *name; JSNativeWrapper call; uint16_t nargs; uint16_t flags; const char *selfHostedName; }; /* * Terminating sentinel initializer to put at the end of a JSFunctionSpec array * that's passed to JS_DefineFunctions or JS_InitClass. */ #define JS_FS_END JS_FS(NULL,NULL,0,0) /* * Initializer macros for a JSFunctionSpec array element. JS_FN (whose name * pays homage to the old JSNative/JSFastNative split) simply adds the flag * JSFUN_STUB_GSOPS. JS_FNINFO allows the simple adding of JSJitInfos. */ #define JS_FS(name,call,nargs,flags) \ {name, JSOP_WRAPPER(call), nargs, flags} #define JS_FN(name,call,nargs,flags) \ {name, JSOP_WRAPPER(call), nargs, (flags) | JSFUN_STUB_GSOPS} #define JS_FNINFO(name,call,info,nargs,flags) \ {name,{call,info},nargs,flags} extern JS_PUBLIC_API(JSObject *) JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto, JSClass *clasp, JSNative constructor, unsigned nargs, const JSPropertySpec *ps, const JSFunctionSpec *fs, const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs); /* * Set up ctor.prototype = proto and proto.constructor = ctor with the * right property flags. */ extern JS_PUBLIC_API(JSBool) JS_LinkConstructorAndPrototype(JSContext *cx, JSObject *ctor, JSObject *proto); extern JS_PUBLIC_API(JSClass *) JS_GetClass(JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); extern JS_PUBLIC_API(void *) JS_GetPrivate(JSObject *obj); extern JS_PUBLIC_API(void) JS_SetPrivate(JSObject *obj, void *data); extern JS_PUBLIC_API(void *) JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) JS_GetPrototype(JSContext *cx, JS::Handle obj, JS::MutableHandle protop); extern JS_PUBLIC_API(JSBool) JS_SetPrototype(JSContext *cx, JS::Handle obj, JS::Handle proto); extern JS_PUBLIC_API(JSObject *) JS_GetParent(JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent); extern JS_PUBLIC_API(JSObject *) JS_GetConstructor(JSContext *cx, JSObject *proto); /* * Get a unique identifier for obj, good for the lifetime of obj (even if it * is moved by a copying GC). Return false on failure (likely out of memory), * and true with *idp containing the unique id on success. */ extern JS_PUBLIC_API(JSBool) JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp); namespace JS { enum { FreshZone, SystemZone, SpecificZones }; typedef uintptr_t ZoneSpecifier; inline ZoneSpecifier SameZoneAs(JSObject *obj) { JS_ASSERT(uintptr_t(obj) > SpecificZones); return ZoneSpecifier(obj); } struct JS_PUBLIC_API(CompartmentOptions) { ZoneSpecifier zoneSpec; JSVersion version; bool invisibleToDebugger; explicit CompartmentOptions() : zoneSpec(JS::FreshZone) , version(JSVERSION_UNKNOWN) , invisibleToDebugger(false) {} CompartmentOptions &setZone(ZoneSpecifier spec) { zoneSpec = spec; return *this; } CompartmentOptions &setVersion(JSVersion version_) { JS_ASSERT(version_ != JSVERSION_UNKNOWN); version = version_; return *this; } // Certain scopes (i.e. XBL compilation scopes) are implementation details // of the embedding, and references to them should never leak out to script. // This flag causes the this compartment to skip firing onNewGlobalObject // and makes addDebuggee a no-op for this global. CompartmentOptions &setInvisibleToDebugger(bool invisible) { invisibleToDebugger = invisible; return *this; } }; // During global creation, we fire notifications to callbacks registered // via the Debugger API. These callbacks are arbitrary script, and can touch // the global in arbitrary ways. When that happens, the global should not be // in a half-baked state. But this creates a problem for consumers that need // to set slots on the global to put it in a consistent state. // // This API provides a way for consumers to set slots atomically (immediately // after the global is created), before any debugger hooks are fired. It's // unfortunately on the clunky side, but that's the way the cookie crumbles. // // If callers have no additional state on the global to set up, they may pass // |FireOnNewGlobalHook| to JS_NewGlobalObject, which causes that function to // fire the hook as its final act before returning. Otherwise, callers should // pass |DontFireOnNewGlobalHook|, which means that they are responsible for // invoking JS_FireOnNewGlobalObject upon successfully creating the global. If // an error occurs and the operation aborts, callers should skip firing the // hook. But otherwise, callers must take care to fire the hook exactly once // before compiling any script in the global's scope (we have assertions in // place to enforce this). This lets us be sure that debugger clients never miss // breakpoints. enum OnNewGlobalHookOption { FireOnNewGlobalHook, DontFireOnNewGlobalHook }; } /* namespace JS */ extern JS_PUBLIC_API(JSObject *) JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals, JS::OnNewGlobalHookOption hookOption, const JS::CompartmentOptions &options = JS::CompartmentOptions()); extern JS_PUBLIC_API(void) JS_FireOnNewGlobalObject(JSContext *cx, JS::HandleObject global); extern JS_PUBLIC_API(JSObject *) JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); /* Queries the [[Extensible]] property of the object. */ extern JS_PUBLIC_API(JSBool) JS_IsExtensible(JSContext *cx, JS::HandleObject obj, JSBool *extensible); extern JS_PUBLIC_API(JSBool) JS_IsNative(JSObject *obj); extern JS_PUBLIC_API(JSRuntime *) JS_GetObjectRuntime(JSObject *obj); /* * Unlike JS_NewObject, JS_NewObjectWithGivenProto does not compute a default * proto if proto's actual parameter value is null. */ extern JS_PUBLIC_API(JSObject *) JS_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); /* * Freeze obj, and all objects it refers to, recursively. This will not recurse * through non-extensible objects, on the assumption that those are already * deep-frozen. */ extern JS_PUBLIC_API(JSBool) JS_DeepFreezeObject(JSContext *cx, JSObject *obj); /* * Freezes an object; see ES5's Object.freeze(obj) method. */ extern JS_PUBLIC_API(JSBool) JS_FreezeObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_PreventExtensions(JSContext *cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSObject *) JS_New(JSContext *cx, JSObject *ctor, unsigned argc, jsval *argv); extern JS_PUBLIC_API(JSObject *) JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *clasp, JSObject *proto, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefineConstDoubles(JSContext *cx, JSObject *obj, const JSConstDoubleSpec *cds); extern JS_PUBLIC_API(JSBool) JS_DefineProperties(JSContext *cx, JSObject *obj, const JSPropertySpec *ps); extern JS_PUBLIC_API(JSBool) JS_DefineProperty(JSContext *cx, JSObject *obj, const char *name, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer * is not null). */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *obj, const char *name, int8_t tinyid, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, unsigned flags, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject **objp, JS::MutableHandle vp); struct JSPropertyDescriptor { JSObject *obj; unsigned attrs; unsigned shortid; JSPropertyOp getter; JSStrictPropertyOp setter; JS::Value value; JSPropertyDescriptor() : obj(NULL), attrs(0), shortid(0), getter(NULL), setter(NULL), value(JSVAL_VOID) {} void trace(JSTracer *trc); }; namespace JS { template class PropertyDescriptorOperations { const JSPropertyDescriptor * desc() const { return static_cast(this)->extract(); } JSPropertyDescriptor * desc() { return static_cast(this)->extract(); } public: bool isEnumerable() const { return desc()->attrs & JSPROP_ENUMERATE; } bool isReadonly() const { return desc()->attrs & JSPROP_READONLY; } bool isPermanent() const { return desc()->attrs & JSPROP_PERMANENT; } bool hasNativeAccessors() const { return desc()->attrs & JSPROP_NATIVE_ACCESSORS; } bool hasGetterObject() const { return desc()->attrs & JSPROP_GETTER; } bool hasSetterObject() const { return desc()->attrs & JSPROP_SETTER; } bool isShared() const { return desc()->attrs & JSPROP_SHARED; } bool isIndex() const { return desc()->attrs & JSPROP_INDEX; } bool hasShortId() const { return desc()->attrs & JSPROP_SHORTID; } bool hasAttributes(unsigned attrs) const { return desc()->attrs & attrs; } JS::MutableHandleObject object() { return JS::MutableHandleObject::fromMarkedLocation(&desc()->obj); } unsigned attributes() const { return desc()->attrs; } unsigned shortid() const { MOZ_ASSERT(hasShortId()); return desc()->shortid; } JSPropertyOp getter() const { return desc()->getter; } JSStrictPropertyOp setter() const { return desc()->setter; } JS::HandleObject getterObject() const { MOZ_ASSERT(hasGetterObject()); return JS::HandleObject::fromMarkedLocation(reinterpret_cast(&desc()->getter)); } JS::HandleObject setterObject() const { MOZ_ASSERT(hasSetterObject()); return JS::HandleObject::fromMarkedLocation(reinterpret_cast(&desc()->setter)); } JS::MutableHandleValue value() { return JS::MutableHandleValue::fromMarkedLocation(&desc()->value); } void setAttributes(unsigned attrs) { desc()->attrs = attrs; } void setShortId(unsigned id) { desc()->shortid = id; } void setGetter(JSPropertyOp op) { desc()->getter = op; } void setSetter(JSStrictPropertyOp op) { desc()->setter = op; } void setGetterObject(JSObject *obj) { desc()->getter = reinterpret_cast(obj); } void setSetterObject(JSObject *obj) { desc()->setter = reinterpret_cast(obj); } }; } /* namespace JS */ namespace js { template <> struct GCMethods { static JSPropertyDescriptor initial() { return JSPropertyDescriptor(); } static ThingRootKind kind() { return THING_ROOT_PROPERTY_DESCRIPTOR; } static bool poisoned(const JSPropertyDescriptor &desc) { return (desc.obj && JS::IsPoisonedPtr(desc.obj)) || (desc.attrs & JSPROP_GETTER && desc.getter && JS::IsPoisonedPtr(desc.getter)) || (desc.attrs & JSPROP_SETTER && desc.setter && JS::IsPoisonedPtr(desc.setter)) || (desc.value.isGCThing() && JS::IsPoisonedPtr(desc.value.toGCThing())); } }; template <> class RootedBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } JSPropertyDescriptor *extract() { return static_cast*>(this)->address(); } }; template <> class HandleBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } public: JS::HandleValue value() const { return JS::HandleValue::fromMarkedLocation(&extract()->value); } JS::HandleObject obj() const { return JS::HandleObject::fromMarkedLocation(&extract()->obj); } }; template <> class MutableHandleBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } JSPropertyDescriptor *extract() { return static_cast*>(this)->address(); } }; } /* namespace js */ /* * Like JS_GetPropertyAttrsGetterAndSetterById but will return a property on * an object on the prototype chain (returned in objp). If data->obj is null, * then this property was not found on the prototype chain. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSPropertyDescriptor *desc); extern JS_PUBLIC_API(JSBool) JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyDefault(JSContext *cx, JSObject *obj, const char *name, jsval def, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehalfOf, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name); extern JS_PUBLIC_API(JSBool) JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle rval); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle rval); extern JS_PUBLIC_API(JSBool) JS_DefineUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer * is not null). */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, int8_t tinyid, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSBool *vp); extern JS_PUBLIC_API(JSBool) JS_LookupUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_SetUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_DeleteUCProperty2(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle rval); extern JS_PUBLIC_API(JSObject *) JS_NewArrayObject(JSContext *cx, int length, jsval *vector); extern JS_PUBLIC_API(JSBool) JS_IsArrayObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_GetArrayLength(JSContext *cx, JSObject *obj, uint32_t *lengthp); extern JS_PUBLIC_API(JSBool) JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length); extern JS_PUBLIC_API(JSBool) JS_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_GetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp); /* * Get the property with name given by |index|, if it has one. If * not, |*present| will be set to false and the value of |vp| must not * be relied on. */ extern JS_PUBLIC_API(JSBool) JS_GetElementIfPresent(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp, JSBool* present); extern JS_PUBLIC_API(JSBool) JS_SetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_DeleteElement(JSContext *cx, JSObject *obj, uint32_t index); extern JS_PUBLIC_API(JSBool) JS_DeleteElement2(JSContext *cx, JSObject *obj, uint32_t index, jsval *rval); /* * Remove all configurable properties from the given (non-global) object and * assign undefined to all writable data properties. */ JS_PUBLIC_API(void) JS_ClearNonGlobalObject(JSContext *cx, JSObject *objArg); /* * Assign 'undefined' to all of the object's non-reserved slots. Note: this is * done for all slots, regardless of the associated property descriptor. */ JS_PUBLIC_API(void) JS_SetAllNonReservedSlotsToUndefined(JSContext *cx, JSObject *objArg); /* * Create a new array buffer with the given contents, which must have been * returned by JS_AllocateArrayBufferContents or JS_StealArrayBufferContents. * The new array buffer takes ownership. After calling this function, do not * free |contents| or use |contents| from another thread. */ extern JS_PUBLIC_API(JSObject *) JS_NewArrayBufferWithContents(JSContext *cx, void *contents); /* * Steal the contents of the given array buffer. The array buffer has its * length set to 0 and its contents array cleared. The caller takes ownership * of |*contents| and must free it or transfer ownership via * JS_NewArrayBufferWithContents when done using it. * To free |*contents|, call free(). * A pointer to the buffer's data is returned in |*data|. This pointer can * be used until |*contents| is freed or has its ownership transferred. */ extern JS_PUBLIC_API(JSBool) JS_StealArrayBufferContents(JSContext *cx, JSObject *obj, void **contents, uint8_t **data); /* * Allocate memory that may be eventually passed to * JS_NewArrayBufferWithContents. |nbytes| is the number of payload bytes * required. The pointer to pass to JS_NewArrayBufferWithContents is returned * in |contents|. The pointer to the |nbytes| of usable memory is returned in * |data|. (*|contents| will contain a header before |data|.) The only legal * operations on *|contents| is to free it, or pass it to * JS_NewArrayBufferWithContents or JS_ReallocateArrayBufferContents. */ extern JS_PUBLIC_API(JSBool) JS_AllocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void **contents, uint8_t **data); /* * Reallocate memory allocated by JS_AllocateArrayBufferContents, growing or shrinking it * as appropriate. The new data pointer will be returned in data. If *contents is NULL, * behaves like JS_AllocateArrayBufferContents. */ extern JS_PUBLIC_API(JSBool) JS_ReallocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void **contents, uint8_t **data); extern JS_PUBLIC_API(JSIdArray *) JS_Enumerate(JSContext *cx, JSObject *obj); /* * Create an object to iterate over enumerable properties of obj, in arbitrary * property definition order. NB: This differs from longstanding for..in loop * order, which uses order of property definition in obj. */ extern JS_PUBLIC_API(JSObject *) JS_NewPropertyIterator(JSContext *cx, JSObject *obj); /* * Return true on success with *idp containing the id of the next enumerable * property to visit using iterobj, or JSID_IS_VOID if there is no such property * left to visit. Return false on error. */ extern JS_PUBLIC_API(JSBool) JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp); /* * A JSNative that creates and returns a new iterator that iterates over the * elements of |this|, up to |this.length|, in index order. This can be used to * make any array-like object iterable. Just give the object an obj.iterator() * method using this JSNative as the implementation. */ extern JS_PUBLIC_API(JSBool) JS_ArrayIterator(JSContext *cx, unsigned argc, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, jsval *vp, unsigned *attrsp); extern JS_PUBLIC_API(jsval) JS_GetReservedSlot(JSObject *obj, uint32_t index); extern JS_PUBLIC_API(void) JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v); /************************************************************************/ /* * Security protocol. */ struct JSPrincipals { /* Don't call "destroy"; use reference counting macros below. */ int refcount; #ifdef DEBUG /* A helper to facilitate principals debugging. */ uint32_t debugToken; #endif void setDebugToken(uint32_t token) { # ifdef DEBUG debugToken = token; # endif } /* * This is not defined by the JS engine but should be provided by the * embedding. */ JS_PUBLIC_API(void) dump(); }; extern JS_PUBLIC_API(void) JS_HoldPrincipals(JSPrincipals *principals); extern JS_PUBLIC_API(void) JS_DropPrincipals(JSRuntime *rt, JSPrincipals *principals); struct JSSecurityCallbacks { JSCheckAccessOp checkObjectAccess; JSCSPEvalChecker contentSecurityPolicyAllows; }; extern JS_PUBLIC_API(void) JS_SetSecurityCallbacks(JSRuntime *rt, const JSSecurityCallbacks *callbacks); extern JS_PUBLIC_API(const JSSecurityCallbacks *) JS_GetSecurityCallbacks(JSRuntime *rt); /* * Code running with "trusted" principals will be given a deeper stack * allocation than ordinary scripts. This allows trusted script to run after * untrusted script has exhausted the stack. This function sets the * runtime-wide trusted principal. * * This principals is not held (via JS_HoldPrincipals/JS_DropPrincipals) since * there is no available JSContext. Instead, the caller must ensure that the * given principals stays valid for as long as 'rt' may point to it. If the * principals would be destroyed before 'rt', JS_SetTrustedPrincipals must be * called again, passing NULL for 'prin'. */ extern JS_PUBLIC_API(void) JS_SetTrustedPrincipals(JSRuntime *rt, JSPrincipals *prin); /* * Initialize the callback that is called to destroy JSPrincipals instance * when its reference counter drops to zero. The initialization can be done * only once per JS runtime. */ extern JS_PUBLIC_API(void) JS_InitDestroyPrincipalsCallback(JSRuntime *rt, JSDestroyPrincipalsOp destroyPrincipals); /************************************************************************/ /* * Functions and scripts. */ extern JS_PUBLIC_API(JSFunction *) JS_NewFunction(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, JSObject *parent, const char *name); /* * Create the function with the name given by the id. JSID_IS_STRING(id) must * be true. */ extern JS_PUBLIC_API(JSFunction *) JS_NewFunctionById(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, JSObject *parent, jsid id); extern JS_PUBLIC_API(JSObject *) JS_GetFunctionObject(JSFunction *fun); /* * Return the function's identifier as a JSString, or null if fun is unnamed. * The returned string lives as long as fun, so you don't need to root a saved * reference to it if fun is well-connected or rooted, and provided you bound * the use of the saved reference by fun's lifetime. */ extern JS_PUBLIC_API(JSString *) JS_GetFunctionId(JSFunction *fun); /* * Return a function's display name. This is the defined name if one was given * where the function was defined, or it could be an inferred name by the JS * engine in the case that the function was defined to be anonymous. This can * still return NULL if a useful display name could not be inferred. The same * restrictions on rooting as those in JS_GetFunctionId apply. */ extern JS_PUBLIC_API(JSString *) JS_GetFunctionDisplayId(JSFunction *fun); /* * Return the arity (length) of fun. */ extern JS_PUBLIC_API(uint16_t) JS_GetFunctionArity(JSFunction *fun); /* * Infallible predicate to test whether obj is a function object (faster than * comparing obj's class name to "Function", but equivalent unless someone has * overwritten the "Function" identifier with a different constructor and then * created instances using that constructor that might be passed in as obj). */ extern JS_PUBLIC_API(JSBool) JS_ObjectIsFunction(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_ObjectIsCallable(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_IsNativeFunction(JSObject *funobj, JSNative call); /* Return whether the given function is a valid constructor. */ extern JS_PUBLIC_API(JSBool) JS_IsConstructor(JSFunction *fun); /* * Bind the given callable to use the given object as "this". * * If |callable| is not callable, will throw and return NULL. */ extern JS_PUBLIC_API(JSObject*) JS_BindCallable(JSContext *cx, JSObject *callable, JSObject *newThis); extern JS_PUBLIC_API(JSBool) JS_DefineFunctions(JSContext *cx, JSObject *obj, const JSFunctionSpec *fs); extern JS_PUBLIC_API(JSFunction *) JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call, unsigned nargs, unsigned attrs); extern JS_PUBLIC_API(JSFunction *) JS_DefineUCFunction(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSNative call, unsigned nargs, unsigned attrs); extern JS_PUBLIC_API(JSFunction *) JS_DefineFunctionById(JSContext *cx, JSObject *obj, jsid id, JSNative call, unsigned nargs, unsigned attrs); /* * Clone a top-level function into a new scope. This function will dynamically * fail if funobj was lexically nested inside some other function. */ extern JS_PUBLIC_API(JSObject *) JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); /* * Given a buffer, return JS_FALSE if the buffer might become a valid * javascript statement with the addition of more lines. Otherwise return * JS_TRUE. The intent is to support interactive compilation - accumulate * lines in a buffer until JS_BufferIsCompilableUnit is true, then pass it to * the compiler. */ extern JS_PUBLIC_API(JSBool) JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj, const char *utf8, size_t length); extern JS_PUBLIC_API(JSScript *) JS_CompileScript(JSContext *cx, JSObject *obj, const char *ascii, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *ascii, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileUCScript(JSContext *cx, JSObject *obj, const jschar *chars, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalFromScript(JSScript *script); extern JS_PUBLIC_API(JSFunction *) JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSFunction *) JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSFunction *) JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name, unsigned nargs, const char **argnames, const jschar *chars, size_t length, const char *filename, unsigned lineno); namespace JS { /* Options for JavaScript compilation. */ class JS_PUBLIC_API(CompileOptions) { JSPrincipals *principals_; JSPrincipals *originPrincipals_; public: JSPrincipals *principals() const { return principals_; } JSPrincipals *originPrincipals() const; JSVersion version; bool versionSet; bool utf8; const char *filename; unsigned lineno; unsigned column; HandleObject element; bool compileAndGo; bool forEval; bool noScriptRval; bool selfHostingMode; bool canLazilyParse; bool strictOption; bool extraWarningsOption; bool werrorOption; bool asmJSOption; enum SourcePolicy { NO_SOURCE, LAZY_SOURCE, SAVE_SOURCE } sourcePolicy; explicit CompileOptions(JSContext *cx, JSVersion version = JSVERSION_UNKNOWN); CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; } CompileOptions &setOriginPrincipals(JSPrincipals *p) { originPrincipals_ = p; return *this; } CompileOptions &setVersion(JSVersion v) { version = v; versionSet = true; return *this; } CompileOptions &setUTF8(bool u) { utf8 = u; return *this; } CompileOptions &setFileAndLine(const char *f, unsigned l) { filename = f; lineno = l; return *this; } CompileOptions &setColumn(unsigned c) { column = c; return *this; } CompileOptions &setElement(HandleObject e) { element = e; return *this; } CompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; } CompileOptions &setForEval(bool eval) { forEval = eval; return *this; } CompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; } CompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; } CompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; } CompileOptions &setSourcePolicy(SourcePolicy sp) { sourcePolicy = sp; return *this; } }; extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const char *bytes, size_t length); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const jschar *chars, size_t length); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, FILE *file); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const char *filename); extern JS_PUBLIC_API(JSFunction *) CompileFunction(JSContext *cx, JS::Handle obj, CompileOptions options, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length); extern JS_PUBLIC_API(JSFunction *) CompileFunction(JSContext *cx, JS::Handle obj, CompileOptions options, const char *name, unsigned nargs, const char **argnames, const jschar *chars, size_t length); } /* namespace JS */ extern JS_PUBLIC_API(JSString *) JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, unsigned indent); /* * API extension: OR this into indent to avoid pretty-printing the decompiled * source resulting from JS_DecompileFunction{,Body}. */ #define JS_DONT_PRETTY_PRINT ((unsigned)0x8000) extern JS_PUBLIC_API(JSString *) JS_DecompileFunction(JSContext *cx, JSFunction *fun, unsigned indent); extern JS_PUBLIC_API(JSString *) JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, unsigned indent); /* * NB: JS_ExecuteScript and the JS_Evaluate*Script* quadruplets use the obj * parameter as the initial scope chain header, the 'this' keyword value, and * the variables object (ECMA parlance for where 'var' and 'function' bind * names) of the execution context for script. * * Using obj as the variables object is problematic if obj's parent (which is * the scope chain link; see JS_SetParent and JS_NewObject) is not null: in * this case, variables created by 'var x = 0', e.g., go in obj, but variables * created by assignment to an unbound id, 'x = 0', go in the last object on * the scope chain linked by parent. * * ECMA calls that last scoping object the "global object", but note that many * embeddings have several such objects. ECMA requires that "global code" be * executed with the variables object equal to this global object. But these * JS API entry points provide freedom to execute code against a "sub-global", * i.e., a parented or scoped object, in which case the variables object will * differ from the last object on the scope chain, resulting in confusing and * non-ECMA explicit vs. implicit variable creation. * * Caveat embedders: unless you already depend on this buggy variables object * binding behavior, you should call JS_SetOptions(cx, JSOPTION_VAROBJFIX) or * JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_VAROBJFIX) -- the latter if * someone may have set other options on cx already -- for each context in the * application, if you pass parented objects as the obj parameter, or may ever * pass such objects in the future. * * Why a runtime option? The alternative is to add six or so new API entry * points with signatures matching the following six, and that doesn't seem * worth the code bloat cost. Such new entry points would probably have less * obvious names, too, so would not tend to be used. The JS_SetOption call, * OTOH, can be more easily hacked into existing code that does not depend on * the bug; such code can continue to use the familiar JS_EvaluateScript, * etc., entry points. */ extern JS_PUBLIC_API(JSBool) JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_ExecuteScriptVersion(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval, JSVersion version); /* * Execute either the function-defining prolog of a script, or the script's * main body, but not both. */ typedef enum JSExecPart { JSEXEC_PROLOG, JSEXEC_MAIN } JSExecPart; extern JS_PUBLIC_API(JSBool) JS_EvaluateScript(JSContext *cx, JSObject *obj, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScript(JSContext *cx, JSObject *obj, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); /* * JSAPI clients may optionally specify the 'originPrincipals' of a script. * A script's originPrincipals may be retrieved through the debug API (via * JS_GetScriptOriginPrincipals) and the originPrincipals are transitively * assigned to any nested scripts (including scripts dynamically created via * eval and the Function constructor). If originPrincipals is null, then the * value of principals is used as origin principals for the script. */ extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JSObject *obj, JSPrincipals *principals, JSPrincipals *originPrincipals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); namespace JS { extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const jschar *chars, size_t length, jsval *rval); extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const char *bytes, size_t length, jsval *rval); extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const char *filename, jsval *rval); } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, unsigned argc, jsval *argv, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, unsigned argc, jsval *argv, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, unsigned argc, jsval *argv, jsval *rval); namespace JS { static inline bool Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunction(cx, thisObj, fun, argc, argv, rval.address()); } static inline bool Call(JSContext *cx, JSObject *thisObj, const char *name, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunctionName(cx, thisObj, name, argc, argv, rval.address()); } static inline bool Call(JSContext *cx, JSObject *thisObj, jsval fun, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunctionValue(cx, thisObj, fun, argc, argv, rval.address()); } extern JS_PUBLIC_API(bool) Call(JSContext *cx, jsval thisv, jsval fun, unsigned argc, jsval *argv, MutableHandle rval); static inline bool Call(JSContext *cx, jsval thisv, JSObject *funObj, unsigned argc, jsval *argv, MutableHandle rval) { return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval); } } /* namespace JS */ /* * These functions allow setting an operation callback that will be called * from the JS thread some time after any thread triggered the callback using * JS_TriggerOperationCallback(rt). * * To schedule the GC and for other activities the engine internally triggers * operation callbacks. The embedding should thus not rely on callbacks being * triggered through the external API only. * * Important note: Additional callbacks can occur inside the callback handler * if it re-enters the JS engine. The embedding must ensure that the callback * is disconnected before attempting such re-entry. */ extern JS_PUBLIC_API(JSOperationCallback) JS_SetOperationCallback(JSContext *cx, JSOperationCallback callback); extern JS_PUBLIC_API(JSOperationCallback) JS_GetOperationCallback(JSContext *cx); extern JS_PUBLIC_API(void) JS_TriggerOperationCallback(JSRuntime *rt); extern JS_PUBLIC_API(JSBool) JS_IsRunning(JSContext *cx); /* * Saving and restoring frame chains. * * These two functions are used to set aside cx's call stack while that stack * is inactive. After a call to JS_SaveFrameChain, it looks as if there is no * code running on cx. Before calling JS_RestoreFrameChain, cx's call stack * must be balanced and all nested calls to JS_SaveFrameChain must have had * matching JS_RestoreFrameChain calls. * * JS_SaveFrameChain deals with cx not having any code running on it. */ extern JS_PUBLIC_API(JSBool) JS_SaveFrameChain(JSContext *cx); extern JS_PUBLIC_API(void) JS_RestoreFrameChain(JSContext *cx); #ifdef MOZ_TRACE_JSCALLS /* * The callback is expected to be quick and noninvasive. It should not * trigger interrupts, turn on debugging, or produce uncaught JS * exceptions. The state of the stack and registers in the context * cannot be relied upon, since this callback may be invoked directly * from either JIT. The 'entering' field means we are entering a * function if it is positive, leaving a function if it is zero or * negative. */ extern JS_PUBLIC_API(void) JS_SetFunctionCallback(JSContext *cx, JSFunctionCallback fcb); extern JS_PUBLIC_API(JSFunctionCallback) JS_GetFunctionCallback(JSContext *cx); #endif /* MOZ_TRACE_JSCALLS */ /************************************************************************/ /* * Strings. * * NB: JS_NewUCString takes ownership of bytes on success, avoiding a copy; * but on error (signified by null return), it leaves chars owned by the * caller. So the caller must free bytes in the error case, if it has no use * for them. In contrast, all the JS_New*StringCopy* functions do not take * ownership of the character memory passed to them -- they copy it. */ extern JS_PUBLIC_API(JSString *) JS_NewStringCopyN(JSContext *cx, const char *s, size_t n); extern JS_PUBLIC_API(JSString *) JS_NewStringCopyZ(JSContext *cx, const char *s); extern JS_PUBLIC_API(JSString *) JS_InternJSString(JSContext *cx, JSString *str); extern JS_PUBLIC_API(JSString *) JS_InternStringN(JSContext *cx, const char *s, size_t length); extern JS_PUBLIC_API(JSString *) JS_InternString(JSContext *cx, const char *s); extern JS_PUBLIC_API(JSString *) JS_NewUCString(JSContext *cx, jschar *chars, size_t length); extern JS_PUBLIC_API(JSString *) JS_NewUCStringCopyN(JSContext *cx, const jschar *s, size_t n); extern JS_PUBLIC_API(JSString *) JS_NewUCStringCopyZ(JSContext *cx, const jschar *s); extern JS_PUBLIC_API(JSString *) JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length); extern JS_PUBLIC_API(JSString *) JS_InternUCString(JSContext *cx, const jschar *s); extern JS_PUBLIC_API(JSBool) JS_CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32_t *result); extern JS_PUBLIC_API(JSBool) JS_StringEqualsAscii(JSContext *cx, JSString *str, const char *asciiBytes, JSBool *match); extern JS_PUBLIC_API(size_t) JS_PutEscapedString(JSContext *cx, char *buffer, size_t size, JSString *str, char quote); extern JS_PUBLIC_API(JSBool) JS_FileEscapedString(FILE *fp, JSString *str, char quote); /* * Extracting string characters and length. * * While getting the length of a string is infallible, getting the chars can * fail. As indicated by the lack of a JSContext parameter, there are two * special cases where getting the chars is infallible: * * The first case is interned strings, i.e., strings from JS_InternString or * JSID_TO_STRING(id), using JS_GetInternedStringChars*. * * The second case is "flat" strings that have been explicitly prepared in a * fallible context by JS_FlattenString. To catch errors, a separate opaque * JSFlatString type is returned by JS_FlattenString and expected by * JS_GetFlatStringChars. Note, though, that this is purely a syntactic * distinction: the input and output of JS_FlattenString are the same actual * GC-thing so only one needs to be rooted. If a JSString is known to be flat, * JS_ASSERT_STRING_IS_FLAT can be used to make a debug-checked cast. Example: * * // in a fallible context * JSFlatString *fstr = JS_FlattenString(cx, str); * if (!fstr) * return JS_FALSE; * JS_ASSERT(fstr == JS_ASSERT_STRING_IS_FLAT(str)); * * // in an infallible context, for the same 'str' * const jschar *chars = JS_GetFlatStringChars(fstr) * JS_ASSERT(chars); * * The CharsZ APIs guarantee that the returned array has a null character at * chars[length]. This can require additional copying so clients should prefer * APIs without CharsZ if possible. The infallible functions also return * null-terminated arrays. (There is no additional cost or non-Z alternative * for the infallible functions, so 'Z' is left out of the identifier.) */ extern JS_PUBLIC_API(size_t) JS_GetStringLength(JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsAndLength(JSContext *cx, JSString *str, size_t *length); extern JS_PUBLIC_API(const jschar *) JS_GetInternedStringChars(JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetInternedStringCharsAndLength(JSString *str, size_t *length); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsZ(JSContext *cx, JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsZAndLength(JSContext *cx, JSString *str, size_t *length); extern JS_PUBLIC_API(JSFlatString *) JS_FlattenString(JSContext *cx, JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetFlatStringChars(JSFlatString *str); static JS_ALWAYS_INLINE JSFlatString * JSID_TO_FLAT_STRING(jsid id) { JS_ASSERT(JSID_IS_STRING(id)); return (JSFlatString *)(JSID_BITS(id)); } static JS_ALWAYS_INLINE JSFlatString * JS_ASSERT_STRING_IS_FLAT(JSString *str) { JS_ASSERT(JS_GetFlatStringChars((JSFlatString *)str)); return (JSFlatString *)str; } static JS_ALWAYS_INLINE JSString * JS_FORGET_STRING_FLATNESS(JSFlatString *fstr) { return (JSString *)fstr; } /* * Additional APIs that avoid fallibility when given a flat string. */ extern JS_PUBLIC_API(JSBool) JS_FlatStringEqualsAscii(JSFlatString *str, const char *asciiBytes); extern JS_PUBLIC_API(size_t) JS_PutEscapedFlatString(char *buffer, size_t size, JSFlatString *str, char quote); /* * This function is now obsolete and behaves the same as JS_NewUCString. Use * JS_NewUCString instead. */ extern JS_PUBLIC_API(JSString *) JS_NewGrowableString(JSContext *cx, jschar *chars, size_t length); /* * Create a dependent string, i.e., a string that owns no character storage, * but that refers to a slice of another string's chars. Dependent strings * are mutable by definition, so the thread safety comments above apply. */ extern JS_PUBLIC_API(JSString *) JS_NewDependentString(JSContext *cx, JSString *str, size_t start, size_t length); /* * Concatenate two strings, possibly resulting in a rope. * See above for thread safety comments. */ extern JS_PUBLIC_API(JSString *) JS_ConcatStrings(JSContext *cx, JSString *left, JSString *right); /* * For JS_DecodeBytes, set *dstlenp to the size of the destination buffer before * the call; on return, *dstlenp contains the number of jschars actually stored. * To determine the necessary destination buffer size, make a sizing call that * passes NULL for dst. * * On errors, the functions report the error. In that case, *dstlenp contains * the number of characters or bytes transferred so far. If cx is NULL, no * error is reported on failure, and the functions simply return JS_FALSE. * * NB: This function does not store an additional zero byte or jschar after the * transcoded string. */ JS_PUBLIC_API(JSBool) JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst, size_t *dstlenp); /* * A variation on JS_EncodeCharacters where a null terminated string is * returned that you are expected to call JS_free on when done. */ JS_PUBLIC_API(char *) JS_EncodeString(JSContext *cx, JSString *str); /* * Same behavior as JS_EncodeString(), but encode into UTF-8 string */ JS_PUBLIC_API(char *) JS_EncodeStringToUTF8(JSContext *cx, JSString *str); /* * Get number of bytes in the string encoding (without accounting for a * terminating zero bytes. The function returns (size_t) -1 if the string * can not be encoded into bytes and reports an error using cx accordingly. */ JS_PUBLIC_API(size_t) JS_GetStringEncodingLength(JSContext *cx, JSString *str); /* * Encode string into a buffer. The function does not stores an additional * zero byte. The function returns (size_t) -1 if the string can not be * encoded into bytes with no error reported. Otherwise it returns the number * of bytes that are necessary to encode the string. If that exceeds the * length parameter, the string will be cut and only length bytes will be * written into the buffer. */ JS_PUBLIC_API(size_t) JS_EncodeStringToBuffer(JSContext *cx, JSString *str, char *buffer, size_t length); class JSAutoByteString { public: JSAutoByteString(JSContext *cx, JSString *str MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mBytes(JS_EncodeString(cx, str)) { JS_ASSERT(cx); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } JSAutoByteString(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) : mBytes(NULL) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~JSAutoByteString() { js_free(mBytes); } /* Take ownership of the given byte array. */ void initBytes(char *bytes) { JS_ASSERT(!mBytes); mBytes = bytes; } char *encodeLatin1(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); JS_ASSERT(cx); mBytes = JS_EncodeString(cx, str); return mBytes; } char *encodeLatin1(js::ContextFriendFields *cx, JSString *str); char *encodeUtf8(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); JS_ASSERT(cx); mBytes = JS_EncodeStringToUTF8(cx, str); return mBytes; } void clear() { js_free(mBytes); mBytes = NULL; } char *ptr() const { return mBytes; } bool operator!() const { return !mBytes; } size_t length() const { if (!mBytes) return 0; return strlen(mBytes); } private: char *mBytes; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER /* Copy and assignment are not supported. */ JSAutoByteString(const JSAutoByteString &another); JSAutoByteString &operator=(const JSAutoByteString &another); }; /************************************************************************/ /* * JSON functions */ typedef JSBool (* JSONWriteCallback)(const jschar *buf, uint32_t len, void *data); /* * JSON.stringify as specified by ES5. */ JS_PUBLIC_API(JSBool) JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space, JSONWriteCallback callback, void *data); /* * JSON.parse as specified by ES5. */ JS_PUBLIC_API(JSBool) JS_ParseJSON(JSContext *cx, const jschar *chars, uint32_t len, JS::MutableHandle vp); JS_PUBLIC_API(JSBool) JS_ParseJSONWithReviver(JSContext *cx, const jschar *chars, uint32_t len, jsval reviver, jsval *vp); /************************************************************************/ /* API for the HTML5 internal structured cloning algorithm. */ /* The maximum supported structured-clone serialization format version. */ #define JS_STRUCTURED_CLONE_VERSION 2 struct JSStructuredCloneCallbacks { ReadStructuredCloneOp read; WriteStructuredCloneOp write; StructuredCloneErrorOp reportError; }; /* Note: if the *data contains transferable objects, it can be read * only once */ JS_PUBLIC_API(JSBool) JS_ReadStructuredClone(JSContext *cx, uint64_t *data, size_t nbytes, uint32_t version, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure); /* Note: On success, the caller is responsible for calling * JS_ClearStructuredClone(*datap, nbytesp). */ JS_PUBLIC_API(JSBool) JS_WriteStructuredClone(JSContext *cx, jsval v, uint64_t **datap, size_t *nbytesp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure, jsval transferable); JS_PUBLIC_API(JSBool) JS_ClearStructuredClone(const uint64_t *data, size_t nbytes); JS_PUBLIC_API(JSBool) JS_StructuredCloneHasTransferables(const uint64_t *data, size_t nbytes, JSBool *hasTransferable); JS_PUBLIC_API(JSBool) JS_StructuredClone(JSContext *cx, jsval v, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure); /* RAII sugar for JS_WriteStructuredClone. */ class JS_PUBLIC_API(JSAutoStructuredCloneBuffer) { uint64_t *data_; size_t nbytes_; uint32_t version_; public: JSAutoStructuredCloneBuffer() : data_(NULL), nbytes_(0), version_(JS_STRUCTURED_CLONE_VERSION) {} ~JSAutoStructuredCloneBuffer() { clear(); } uint64_t *data() const { return data_; } size_t nbytes() const { return nbytes_; } void clear(); /* Copy some memory. It will be automatically freed by the destructor. */ bool copy(const uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION); /* * Adopt some memory. It will be automatically freed by the destructor. * data must have been allocated by the JS engine (e.g., extracted via * JSAutoStructuredCloneBuffer::steal). */ void adopt(uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION); /* * Remove the buffer so that it will not be automatically freed. * After this, the caller is responsible for feeding the memory back to * JSAutoStructuredCloneBuffer::adopt. */ void steal(uint64_t **datap, size_t *nbytesp, uint32_t *versionp=NULL); bool read(JSContext *cx, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); bool write(JSContext *cx, jsval v, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); bool write(JSContext *cx, jsval v, jsval transferable, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); /** * Swap ownership with another JSAutoStructuredCloneBuffer. */ void swap(JSAutoStructuredCloneBuffer &other); private: /* Copy and assignment are not supported. */ JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer &other); JSAutoStructuredCloneBuffer &operator=(const JSAutoStructuredCloneBuffer &other); }; /* API for implementing custom serialization behavior (for ImageData, File, etc.) */ /* The range of tag values the application may use for its own custom object types. */ #define JS_SCTAG_USER_MIN ((uint32_t) 0xFFFF8000) #define JS_SCTAG_USER_MAX ((uint32_t) 0xFFFFFFFF) #define JS_SCERR_RECURSION 0 #define JS_SCERR_TRANSFERABLE 1 JS_PUBLIC_API(void) JS_SetStructuredCloneCallbacks(JSRuntime *rt, const JSStructuredCloneCallbacks *callbacks); JS_PUBLIC_API(JSBool) JS_ReadUint32Pair(JSStructuredCloneReader *r, uint32_t *p1, uint32_t *p2); JS_PUBLIC_API(JSBool) JS_ReadBytes(JSStructuredCloneReader *r, void *p, size_t len); JS_PUBLIC_API(JSBool) JS_ReadTypedArray(JSStructuredCloneReader *r, jsval *vp); JS_PUBLIC_API(JSBool) JS_WriteUint32Pair(JSStructuredCloneWriter *w, uint32_t tag, uint32_t data); JS_PUBLIC_API(JSBool) JS_WriteBytes(JSStructuredCloneWriter *w, const void *p, size_t len); JS_PUBLIC_API(JSBool) JS_WriteTypedArray(JSStructuredCloneWriter *w, jsval v); /************************************************************************/ /* * The default locale for the ECMAScript Internationalization API * (Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat). * Note that the Internationalization API encourages clients to * specify their own locales. * The locale string remains owned by the caller. */ extern JS_PUBLIC_API(JSBool) JS_SetDefaultLocale(JSRuntime *rt, const char *locale); /* * Reset the default locale to OS defaults. */ extern JS_PUBLIC_API(void) JS_ResetDefaultLocale(JSRuntime *rt); /* * Locale specific string conversion and error message callbacks. */ struct JSLocaleCallbacks { JSLocaleToUpperCase localeToUpperCase; JSLocaleToLowerCase localeToLowerCase; JSLocaleCompare localeCompare; // not used #if ENABLE_INTL_API JSLocaleToUnicode localeToUnicode; JSErrorCallback localeGetErrorMessage; }; /* * Establish locale callbacks. The pointer must persist as long as the * JSRuntime. Passing NULL restores the default behaviour. */ extern JS_PUBLIC_API(void) JS_SetLocaleCallbacks(JSRuntime *rt, JSLocaleCallbacks *callbacks); /* * Return the address of the current locale callbacks struct, which may * be NULL. */ extern JS_PUBLIC_API(JSLocaleCallbacks *) JS_GetLocaleCallbacks(JSRuntime *rt); /************************************************************************/ /* * Error reporting. */ /* * Report an exception represented by the sprintf-like conversion of format * and its arguments. This exception message string is passed to a pre-set * JSErrorReporter function (set by JS_SetErrorReporter). */ extern JS_PUBLIC_API(void) JS_ReportError(JSContext *cx, const char *format, ...); /* * Use an errorNumber to retrieve the format string, args are char * */ extern JS_PUBLIC_API(void) JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); #ifdef va_start extern JS_PUBLIC_API(void) JS_ReportErrorNumberVA(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, va_list ap); #endif /* * Use an errorNumber to retrieve the format string, args are jschar * */ extern JS_PUBLIC_API(void) JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); extern JS_PUBLIC_API(void) JS_ReportErrorNumberUCArray(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, const jschar **args); /* * As above, but report a warning instead (JSREPORT_IS_WARNING(report.flags)). * Return true if there was no error trying to issue the warning, and if the * warning was not converted into an error due to the JSOPTION_WERROR option * being set, false otherwise. */ extern JS_PUBLIC_API(JSBool) JS_ReportWarning(JSContext *cx, const char *format, ...); extern JS_PUBLIC_API(JSBool) JS_ReportErrorFlagsAndNumber(JSContext *cx, unsigned flags, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); extern JS_PUBLIC_API(JSBool) JS_ReportErrorFlagsAndNumberUC(JSContext *cx, unsigned flags, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); /* * Complain when out of memory. */ extern JS_PUBLIC_API(void) JS_ReportOutOfMemory(JSContext *cx); /* * Complain when an allocation size overflows the maximum supported limit. */ extern JS_PUBLIC_API(void) JS_ReportAllocationOverflow(JSContext *cx); struct JSErrorReport { const char *filename; /* source file name, URL, etc., or null */ JSPrincipals *originPrincipals; /* see 'originPrincipals' comment above */ unsigned lineno; /* source line number */ const char *linebuf; /* offending source line without final \n */ const char *tokenptr; /* pointer to error token in linebuf */ const jschar *uclinebuf; /* unicode (original) line buffer */ const jschar *uctokenptr; /* unicode (original) token pointer */ unsigned flags; /* error/warning, etc. */ unsigned errorNumber; /* the error number, e.g. see js.msg */ const jschar *ucmessage; /* the (default) error message */ const jschar **messageArgs; /* arguments for the error message */ int16_t exnType; /* One of the JSExnType constants */ unsigned column; /* zero-based column index in line */ }; /* * JSErrorReport flag values. These may be freely composed. */ #define JSREPORT_ERROR 0x0 /* pseudo-flag for default case */ #define JSREPORT_WARNING 0x1 /* reported via JS_ReportWarning */ #define JSREPORT_EXCEPTION 0x2 /* exception was thrown */ #define JSREPORT_STRICT 0x4 /* error or warning due to strict option */ /* * This condition is an error in strict mode code, a warning if * JS_HAS_STRICT_OPTION(cx), and otherwise should not be reported at * all. We check the strictness of the context's top frame's script; * where that isn't appropriate, the caller should do the right checks * itself instead of using this flag. */ #define JSREPORT_STRICT_MODE_ERROR 0x8 /* * If JSREPORT_EXCEPTION is set, then a JavaScript-catchable exception * has been thrown for this runtime error, and the host should ignore it. * Exception-aware hosts should also check for JS_IsExceptionPending if * JS_ExecuteScript returns failure, and signal or propagate the exception, as * appropriate. */ #define JSREPORT_IS_WARNING(flags) (((flags) & JSREPORT_WARNING) != 0) #define JSREPORT_IS_EXCEPTION(flags) (((flags) & JSREPORT_EXCEPTION) != 0) #define JSREPORT_IS_STRICT(flags) (((flags) & JSREPORT_STRICT) != 0) #define JSREPORT_IS_STRICT_MODE_ERROR(flags) (((flags) & \ JSREPORT_STRICT_MODE_ERROR) != 0) extern JS_PUBLIC_API(JSErrorReporter) JS_GetErrorReporter(JSContext *cx); extern JS_PUBLIC_API(JSErrorReporter) JS_SetErrorReporter(JSContext *cx, JSErrorReporter er); /************************************************************************/ /* * Dates. */ extern JS_PUBLIC_API(JSObject *) JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); extern JS_PUBLIC_API(JSObject *) JS_NewDateObjectMsec(JSContext *cx, double msec); /* * Infallible predicate to test whether obj is a date object. */ extern JS_PUBLIC_API(JSBool) JS_ObjectIsDate(JSContext *cx, JSObject *obj); /* * Clears the cache of calculated local time from each Date object. * Call to propagate a system timezone change. */ extern JS_PUBLIC_API(void) JS_ClearDateCaches(JSContext *cx); /************************************************************************/ /* * Regular Expressions. */ #define JSREG_FOLD 0x01 /* fold uppercase to lowercase */ #define JSREG_GLOB 0x02 /* global exec, creates array of matches */ #define JSREG_MULTILINE 0x04 /* treat ^ and $ as begin and end of line */ #define JSREG_STICKY 0x08 /* only match starting at lastIndex */ extern JS_PUBLIC_API(JSObject *) JS_NewRegExpObject(JSContext *cx, JSObject *obj, char *bytes, size_t length, unsigned flags); extern JS_PUBLIC_API(JSObject *) JS_NewUCRegExpObject(JSContext *cx, JSObject *obj, jschar *chars, size_t length, unsigned flags); extern JS_PUBLIC_API(void) JS_SetRegExpInput(JSContext *cx, JSObject *obj, JSString *input, JSBool multiline); extern JS_PUBLIC_API(void) JS_ClearRegExpStatics(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_ExecuteRegExp(JSContext *cx, JSObject *obj, JSObject *reobj, jschar *chars, size_t length, size_t *indexp, JSBool test, jsval *rval); /* RegExp interface for clients without a global object. */ extern JS_PUBLIC_API(JSObject *) JS_NewRegExpObjectNoStatics(JSContext *cx, char *bytes, size_t length, unsigned flags); extern JS_PUBLIC_API(JSObject *) JS_NewUCRegExpObjectNoStatics(JSContext *cx, jschar *chars, size_t length, unsigned flags); extern JS_PUBLIC_API(JSBool) JS_ExecuteRegExpNoStatics(JSContext *cx, JSObject *reobj, jschar *chars, size_t length, size_t *indexp, JSBool test, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_ObjectIsRegExp(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(unsigned) JS_GetRegExpFlags(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSString *) JS_GetRegExpSource(JSContext *cx, JSObject *obj); /************************************************************************/ extern JS_PUBLIC_API(JSBool) JS_IsExceptionPending(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_GetPendingException(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(void) JS_SetPendingException(JSContext *cx, jsval v); extern JS_PUBLIC_API(void) JS_ClearPendingException(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_ReportPendingException(JSContext *cx); /* * Save the current exception state. This takes a snapshot of cx's current * exception state without making any change to that state. * * The returned state pointer MUST be passed later to JS_RestoreExceptionState * (to restore that saved state, overriding any more recent state) or else to * JS_DropExceptionState (to free the state struct in case it is not correct * or desirable to restore it). Both Restore and Drop free the state struct, * so callers must stop using the pointer returned from Save after calling the * Release or Drop API. */ extern JS_PUBLIC_API(JSExceptionState *) JS_SaveExceptionState(JSContext *cx); extern JS_PUBLIC_API(void) JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state); extern JS_PUBLIC_API(void) JS_DropExceptionState(JSContext *cx, JSExceptionState *state); /* * If the given value is an exception object that originated from an error, * the exception will contain an error report struct, and this API will return * the address of that struct. Otherwise, it returns NULL. The lifetime of * the error report struct that might be returned is the same as the lifetime * of the exception object. */ extern JS_PUBLIC_API(JSErrorReport *) JS_ErrorFromException(JSContext *cx, jsval v); /* * Given a reported error's message and JSErrorReport struct pointer, throw * the corresponding exception on cx. */ extern JS_PUBLIC_API(JSBool) JS_ThrowReportedError(JSContext *cx, const char *message, JSErrorReport *reportp); /* * Throws a StopIteration exception on cx. */ extern JS_PUBLIC_API(JSBool) JS_ThrowStopIteration(JSContext *cx); extern JS_PUBLIC_API(intptr_t) JS_GetCurrentThread(); /* * A JS runtime always has an "owner thread". The owner thread is set when the * runtime is created (to the current thread) and practically all entry points * into the JS engine check that a runtime (or anything contained in the * runtime: context, compartment, object, etc) is only touched by its owner * thread. Embeddings may check this invariant outside the JS engine by calling * JS_AbortIfWrongThread (which will abort if not on the owner thread, even for * non-debug builds). * * It is possible to "move" a runtime between threads. This is accomplished by * calling JS_ClearRuntimeThread on a runtime's owner thread and then calling * JS_SetRuntimeThread on the new owner thread. The runtime must not be * accessed between JS_ClearRuntimeThread and JS_SetRuntimeThread. Also, the * caller is responsible for synchronizing the calls to Set/Clear. */ extern JS_PUBLIC_API(void) JS_AbortIfWrongThread(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_ClearRuntimeThread(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_SetRuntimeThread(JSRuntime *rt); class JSAutoSetRuntimeThread { JSRuntime *runtime_; public: JSAutoSetRuntimeThread(JSRuntime *runtime) : runtime_(runtime) { JS_SetRuntimeThread(runtime_); } ~JSAutoSetRuntimeThread() { JS_ClearRuntimeThread(runtime_); } }; /************************************************************************/ /* * JS_IsConstructing must be called from within a native given the * native's original cx and vp arguments. If JS_IsConstructing is true, * JS_THIS must not be used; the constructor should construct and return a * new object. Otherwise, the native is called as an ordinary function and * JS_THIS may be used. */ static JS_ALWAYS_INLINE JSBool JS_IsConstructing(JSContext *cx, const jsval *vp) { #ifdef DEBUG JSObject *callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)); if (JS_ObjectIsFunction(cx, callee)) { JSFunction *fun = JS_ValueToFunction(cx, JS_CALLEE(cx, vp)); JS_ASSERT(JS_IsConstructor(fun)); } else { JS_ASSERT(JS_GetClass(callee)->construct != NULL); } #else (void)cx; #endif return JSVAL_IS_MAGIC_IMPL(JSVAL_TO_IMPL(vp[1])); } /* * A constructor can request that the JS engine create a default new 'this' * object of the given class, using the callee to determine parentage and * [[Prototype]]. */ extern JS_PUBLIC_API(JSObject *) JS_NewObjectForConstructor(JSContext *cx, JSClass *clasp, const jsval *vp); /************************************************************************/ #ifdef JS_GC_ZEAL #define JS_DEFAULT_ZEAL_FREQ 100 extern JS_PUBLIC_API(void) JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency); extern JS_PUBLIC_API(void) JS_ScheduleGC(JSContext *cx, uint32_t count); #endif extern JS_PUBLIC_API(void) JS_SetParallelCompilationEnabled(JSContext *cx, bool enabled); typedef enum JSCompilerOption { JSCOMPILER_BASELINE_USECOUNT_TRIGGER, JSCOMPILER_ION_USECOUNT_TRIGGER, JSCOMPILER_PJS_ENABLE } JSCompilerOption; extern JS_PUBLIC_API(void) JS_SetGlobalCompilerOption(JSContext *cx, JSCompilerOption opt, uint32_t value); /* * Convert a uint32_t index into a jsid. */ extern JS_PUBLIC_API(JSBool) JS_IndexToId(JSContext *cx, uint32_t index, jsid *id); /* * Convert chars into a jsid. * * |chars| may not be an index. */ extern JS_PUBLIC_API(JSBool) JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, jsid *idp); /* * Test if the given string is a valid ECMAScript identifier */ extern JS_PUBLIC_API(JSBool) JS_IsIdentifier(JSContext *cx, JSString *str, JSBool *isIdentifier); /* * Return the current script and line number of the most currently running * frame. Returns true if a scripted frame was found, false otherwise. */ extern JS_PUBLIC_API(JSBool) JS_DescribeScriptedCaller(JSContext *cx, JSScript **script, unsigned *lineno); /* * Encode/Decode interpreted scripts and functions to/from memory. */ extern JS_PUBLIC_API(void *) JS_EncodeScript(JSContext *cx, JSScript *script, uint32_t *lengthp); extern JS_PUBLIC_API(void *) JS_EncodeInterpretedFunction(JSContext *cx, JSObject *funobj, uint32_t *lengthp); extern JS_PUBLIC_API(JSScript *) JS_DecodeScript(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); extern JS_PUBLIC_API(JSObject *) JS_DecodeInterpretedFunction(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); namespace JS { extern JS_PUBLIC_DATA(const HandleValue) NullHandleValue; extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; extern JS_PUBLIC_DATA(const HandleId) JSID_VOIDHANDLE; extern JS_PUBLIC_DATA(const HandleId) JSID_EMPTYHANDLE; } /* namespace JS */ namespace js { /* * Import some JS:: names into the js namespace so we can make unqualified * references to them. */ using JS::Value; using JS::IsPoisonedValue; using JS::NullValue; using JS::UndefinedValue; using JS::Int32Value; using JS::DoubleValue; using JS::StringValue; using JS::BooleanValue; using JS::ObjectValue; using JS::MagicValue; using JS::NumberValue; using JS::ObjectOrNullValue; using JS::PrivateValue; using JS::PrivateUint32Value; using JS::IsPoisonedPtr; using JS::IsPoisonedId; using JS::StableCharPtr; using JS::TwoByteChars; using JS::Latin1CharsZ; using JS::AutoIdVector; using JS::AutoValueVector; using JS::AutoObjectVector; using JS::AutoFunctionVector; using JS::AutoScriptVector; using JS::AutoIdArray; using JS::AutoGCRooter; using JS::AutoArrayRooter; using JS::AutoVectorRooter; using JS::AutoHashMapRooter; using JS::AutoHashSetRooter; using JS::CallArgs; using JS::IsAcceptableThis; using JS::NativeImpl; using JS::CallReceiver; using JS::CompileOptions; using JS::CallNonGenericMethod; using JS::Rooted; using JS::RootedObject; using JS::RootedModule; using JS::RootedFunction; using JS::RootedScript; using JS::RootedString; using JS::RootedId; using JS::RootedValue; using JS::Handle; using JS::HandleObject; using JS::HandleModule; using JS::HandleFunction; using JS::HandleScript; using JS::HandleString; using JS::HandleId; using JS::HandleValue; using JS::MutableHandle; using JS::MutableHandleObject; using JS::MutableHandleFunction; using JS::MutableHandleScript; using JS::MutableHandleString; using JS::MutableHandleId; using JS::MutableHandleValue; using JS::Zone; } /* namespace js */ #endif /* jsapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsclass.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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" namespace js { class PropertyName; class SpecialId; class PropertyId; // This is equal to JSFunction::class_. Use it in places where you don't want // to #include jsfun.h. extern JS_FRIEND_DATA(js::Class* const) FunctionClassPtr; 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, JSBool *succeeded); typedef JSBool (* DeleteElementOp)(JSContext *cx, HandleObject obj, uint32_t index, JSBool *succeeded); typedef JSBool (* DeleteSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSBool *succeeded); typedef JSObject * (* ObjectOp)(JSContext *cx, HandleObject obj); typedef void (* FinalizeOp)(FreeOp *fop, JSObject *obj); #define JS_CLASS_MEMBERS \ const char *name; \ uint32_t flags; \ \ /* Mandatory function pointer members. */ \ JSPropertyOp addProperty; \ JSDeletePropertyOp delProperty; \ JSPropertyOp getProperty; \ JSStrictPropertyOp setProperty; \ JSEnumerateOp enumerate; \ JSResolveOp resolve; \ JSConvertOp convert; \ \ /* Optional members (may be null). */ \ FinalizeOp finalize; \ 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 pad 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; } bool isCallable() const { return this == js::FunctionClassPtr || call; } 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, ESClass_Date }; /* * 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 GCMethods { static SpecialId initial() { return SpecialId(); } static ThingRootKind kind() { return THING_ROOT_ID; } static bool poisoned(SpecialId id) { return IsPoisonedSpecialId(id); } }; } /* namespace js */ #endif /* jsclass_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsclist.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jscpucfg.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jscpucfg_h #define jscpucfg_h #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_WORD 8 # define JS_BITS_PER_WORD_LOG2 6 # 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_WORD 4 # define JS_BITS_PER_WORD_LOG2 5 #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 /* jscpucfg_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsdbgapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 "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(JSRuntime *rt, 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); /************************************************************************/ // Raw JSScript* because this needs to be callable from a signal handler. extern JS_PUBLIC_API(unsigned) JS_PCToLineNumber(JSContext *cx, JSScript *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_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_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); /* Call the context debug handler on the topmost scripted frame. */ extern JS_FRIEND_API(JSBool) js_CallContextDebugHandler(JSContext *cx); #endif /* jsdbgapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsfriendapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jsfriendapi_h #define jsfriendapi_h #include "mozilla/MemoryReporting.h" #include "jsclass.h" #include "jsprvtd.h" #include "jspubtd.h" #include "js/CallArgs.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) namespace JS { template class Heap; } /* namespace JS */ 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, JSObject *obj); extern JS_FRIEND_API(JSFunction *) JS_GetObjectFunction(JSObject *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(JS::HandleObject 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(JSString *) JS_BasicObjectToString(JSContext *cx, JS::HandleObject obj); extern JS_FRIEND_API(JSBool) js_GetterOnlyPropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool strict, JS::MutableHandleValue vp); JS_FRIEND_API(void) js_ReportOverRecursed(JSContext *maybecx); JS_FRIEND_API(bool) js_ObjectClassIs(JSContext *cx, JS::HandleObject obj, js::ESClassValue classValue); JS_FRIEND_API(const char *) js_ObjectClassName(JSContext *cx, JS::HandleObject obj); JS_FRIEND_API(bool) js_AddObjectRoot(JSRuntime *rt, JSObject **objp); JS_FRIEND_API(void) js_RemoveObjectRoot(JSRuntime *rt, JSObject **objp); #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, JS::HandleObject 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, JS::Handle script, jschar **src, uint32_t *length); extern JS_FRIEND_API(void) JS_SetSourceHook(JSRuntime *rt, JS_SourceHook hook); namespace js { 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); #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); /* * Returns whether we're in a non-strict property set (in that we're in a * non-strict script and the bytecode we're on is a property set). The return * value does NOT indicate any sort of exception was thrown: it's just a * boolean. */ extern JS_FRIEND_API(bool) IsInNonStrictPropertySet(JSContext *cx); 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(mozilla::MallocSizeOf 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; JSObject *_1; 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 { static const size_t LENGTH_SHIFT = 4; size_t lengthAndFlags; const jschar *chars; }; } /* namespace shadow */ // These are equal to |&{Function,Object,OuterWindow}ProxyObject::class_|. Use // them in places where you don't want to #include vm/ProxyObject.h. extern JS_FRIEND_DATA(js::Class* const) FunctionProxyClassPtr; extern JS_FRIEND_DATA(js::Class* const) ObjectProxyClassPtr; extern JS_FRIEND_DATA(js::Class* const) OuterWindowProxyClassPtr; // This is equal to |&JSObject::class_|. Use it in places where you don't want // to #include jsobj.h. extern JS_FRIEND_DATA(js::Class* const) ObjectClassPtr; inline js::Class * GetObjectClass(JSObject *obj) { return reinterpret_cast(obj)->type->clasp; } inline JSClass * GetObjectJSClass(JSObject *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) IsFunctionObject(JSObject *obj); JS_FRIEND_API(bool) IsScopeObject(JSObject *obj); JS_FRIEND_API(bool) IsCallObject(JSObject *obj); inline JSObject * GetObjectParent(JSObject *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(JSObject *obj); JS_FRIEND_API(JSObject *) GetGlobalForObjectCrossCompartment(JSObject *obj); // For legacy consumers only. This whole concept is going away soon. JS_FRIEND_API(JSObject *) DefaultObjectForContextOrNull(JSContext *cx); JS_FRIEND_API(void) SetDefaultObjectForContext(JSContext *cx, JSObject *obj); JS_FRIEND_API(void) NotifyAnimationActivity(JSObject *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, const JSPropertySpec *ps, const JSFunctionSpec *fs, const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs); JS_FRIEND_API(const Value &) GetFunctionNativeReserved(JSObject *fun, size_t which); JS_FRIEND_API(void) SetFunctionNativeReserved(JSObject *fun, size_t which, const Value &val); inline bool GetObjectProto(JSContext *cx, JS::Handle obj, JS::MutableHandle proto) { js::Class *clasp = GetObjectClass(obj); if (clasp == js::ObjectProxyClassPtr || clasp == js::OuterWindowProxyClassPtr || clasp == js::FunctionProxyClassPtr) { return JS_GetPrototype(cx, obj, proto); } proto.set(reinterpret_cast(obj.get())->type->proto); return true; } inline void * GetObjectPrivate(JSObject *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(JSObject *obj, size_t slot) { JS_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); return reinterpret_cast(obj)->slotRef(slot); } JS_FRIEND_API(void) SetReservedSlotWithBarrier(JSObject *obj, size_t slot, const Value &value); inline void SetReservedSlot(JSObject *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(JSObject *obj); inline const Value & GetObjectSlot(JSObject *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 size_t GetAtomLength(JSAtom *atom) { using shadow::Atom; return reinterpret_cast(atom)->lengthAndFlags >> Atom::LENGTH_SHIFT; } inline JSLinearString * AtomToLinearString(JSAtom *atom) { return reinterpret_cast(atom); } static inline js::PropertyOp CastAsJSPropertyOp(JSObject *object) { return JS_DATA_TO_FUNC_PTR(js::PropertyOp, object); } static inline js::StrictPropertyOp CastAsJSStrictPropertyOp(JSObject *object) { return JS_DATA_TO_FUNC_PTR(js::StrictPropertyOp, object); } JS_FRIEND_API(bool) GetPropertyNames(JSContext *cx, JSObject *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(JSObject *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; } inline uintptr_t GetNativeStackLimit(JSContext *cx) { return GetNativeStackLimit(GetRuntime(cx)); } /* * 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(cx), &stackDummy_)) { \ js_ReportOverRecursed(cx); \ onerror; \ } \ JS_END_MACRO #define JS_CHECK_RECURSION_WITH_SP_DONT_REPORT(cx, sp, onerror) \ JS_BEGIN_MACRO \ if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \ 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(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, JSScript *script, void *ip); #ifdef JS_THREADSAFE 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, JS::Handle desc); extern JS_FRIEND_API(AnalysisPurgeCallback) SetAnalysisPurgeCallback(JSRuntime *rt, AnalysisPurgeCallback callback); typedef JSBool (* DOMInstanceClassMatchesProto)(JS::HandleObject 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 DOMProxy proxies in the DOM, for use by ICs. */ /* * The DOMProxyShadowsCheck function will be called to check if the property for * id should be gotten from the prototype, or if there is an own property that * shadows it. * If DoesntShadow is returned then the slot at listBaseExpandoSlot should * either be undefined or point to an expando object that would contain the own * property. * If DoesntShadowUnique is returned then the slot at listBaseExpandoSlot should * contain a private pointer to a ExpandoAndGeneration, which contains a * JS::Value that should either be undefined or point to an expando object, and * a uint32 value. If that value changes then the IC for getting a property will * be invalidated. */ struct ExpandoAndGeneration { ExpandoAndGeneration() : expando(UndefinedValue()), generation(0) {} void Unlink() { ++generation; expando.setUndefined(); } JS::Heap expando; uint32_t generation; }; typedef enum DOMProxyShadowsResult { ShadowCheckFailed, Shadows, DoesntShadow, DoesntShadowUnique } DOMProxyShadowsResult; typedef DOMProxyShadowsResult (* DOMProxyShadowsCheck)(JSContext* cx, JS::HandleObject object, JS::HandleId id); JS_FRIEND_API(void) SetDOMProxyInformation(void *domProxyHandlerFamily, uint32_t domProxyExpandoSlot, DOMProxyShadowsCheck domProxyShadowsCheck); void *GetDOMProxyHandlerFamily(); uint32_t GetDOMProxyExpandoSlot(); DOMProxyShadowsCheck GetDOMProxyShadowsCheck(); } /* 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(JSObject *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 */ /* * A helper for building up an ArrayBuffer object's data * before creating the ArrayBuffer itself. Will do doubling * based reallocation, up to an optional maximum growth given. * * When all the data has been appended, call getArrayBuffer, * passing in the JSContext* for which the ArrayBuffer object * is to be created. This also implicitly resets the builder, * or it can be reset explicitly at any point by calling reset(). */ class ArrayBufferBuilder { void *rawcontents_; uint8_t *dataptr_; uint32_t capacity_; uint32_t length_; public: ArrayBufferBuilder() : rawcontents_(NULL), dataptr_(NULL), capacity_(0), length_(0) { } ~ArrayBufferBuilder() { reset(); } void reset() { if (rawcontents_) JS_free(NULL, rawcontents_); rawcontents_ = dataptr_ = NULL; capacity_ = length_ = 0; } // will truncate if newcap is < length() bool setCapacity(uint32_t newcap) { if (!JS_ReallocateArrayBufferContents(NULL, newcap, &rawcontents_, &dataptr_)) return false; capacity_ = newcap; if (length_ > newcap) length_ = newcap; return true; } // Append datalen bytes from data to the current buffer. If we // need to grow the buffer, grow by doubling the size up to a // maximum of maxgrowth (if given). If datalen is greater than // what the new capacity would end up as, then grow by datalen. // // The data parameter must not overlap with anything beyond the // builder's current valid contents [0..length) bool append(const uint8_t *newdata, uint32_t datalen, uint32_t maxgrowth = 0) { if (length_ + datalen > capacity_) { uint32_t newcap; // double while under maxgrowth or if not specified if (!maxgrowth || capacity_ < maxgrowth) newcap = capacity_ * 2; else newcap = capacity_ + maxgrowth; // but make sure there's always enough to satisfy our request if (newcap < length_ + datalen) newcap = length_ + datalen; // did we overflow? if (newcap < capacity_) return false; if (!setCapacity(newcap)) return false; } // assert that the region isn't overlapping so we can memcpy; JS_ASSERT(!areOverlappingRegions(newdata, datalen, dataptr_ + length_, datalen)); memcpy(dataptr_ + length_, newdata, datalen); length_ += datalen; return true; } uint8_t *data() { return dataptr_; } uint32_t length() { return length_; } uint32_t capacity() { return capacity_; } JSObject* getArrayBuffer(JSContext *cx) { // we need to check for length_ == 0, because nothing may have been // added if (capacity_ > length_ || length_ == 0) { if (!setCapacity(length_)) return NULL; } JSObject* obj = JS_NewArrayBufferWithContents(cx, rawcontents_); if (!obj) return NULL; rawcontents_ = dataptr_ = NULL; length_ = capacity_ = 0; return obj; } protected: static bool areOverlappingRegions(const uint8_t *start1, uint32_t length1, const uint8_t *start2, uint32_t length2) { const uint8_t *end1 = start1 + length1; const uint8_t *end2 = start2 + length2; const uint8_t *max_start = start1 > start2 ? start1 : start2; const uint8_t *min_end = end1 < end2 ? end1 : end2; return max_start < min_end; } }; } /* 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. 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); /* * A class, expected to be passed by value, which represents the CallArgs for a * JSJitGetterOp. */ class JSJitGetterCallArgs : protected JS::MutableHandleValue { public: explicit JSJitGetterCallArgs(const JS::CallArgs& args) : JS::MutableHandleValue(args.rval()) {} explicit JSJitGetterCallArgs(JS::Rooted* rooted) : JS::MutableHandleValue(rooted) {} JS::MutableHandleValue rval() { return *this; } }; /* * A class, expected to be passed by value, which represents the CallArgs for a * JSJitSetterOp. */ class JSJitSetterCallArgs : protected JS::MutableHandleValue { public: explicit JSJitSetterCallArgs(const JS::CallArgs& args) : JS::MutableHandleValue(args[0]) {} JS::MutableHandleValue operator[](unsigned i) { MOZ_ASSERT(i == 0); return *this; } unsigned length() const { return 1; } // Add get() or maybe hasDefined() as needed }; struct JSJitMethodCallArgsTraits; /* * A class, expected to be passed by reference, which represents the CallArgs * for a JSJitMethodOp. */ class JSJitMethodCallArgs : protected JS::detail::CallArgsBase { private: typedef JS::detail::CallArgsBase Base; friend struct JSJitMethodCallArgsTraits; public: explicit JSJitMethodCallArgs(const JS::CallArgs& args) { argv_ = args.array(); argc_ = args.length(); } JS::MutableHandleValue rval() const { return Base::rval(); } unsigned length() const { return Base::length(); } JS::MutableHandleValue operator[](unsigned i) const { return Base::operator[](i); } bool hasDefined(unsigned i) const { return Base::hasDefined(i); } // Add get() as needed }; struct JSJitMethodCallArgsTraits { static const size_t offsetOfArgv = offsetof(JSJitMethodCallArgs, argv_); static const size_t offsetOfArgc = offsetof(JSJitMethodCallArgs, argc_); }; /* * 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 (* JSJitGetterOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, JSJitGetterCallArgs args); typedef bool (* JSJitSetterOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, JSJitSetterCallArgs args); typedef bool (* JSJitMethodOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, const JSJitMethodCallArgs& args); struct JSJitInfo { enum OpType { Getter, Setter, Method, OpType_None }; union { JSJitGetterOp getter; JSJitSetterOp setter; JSJitMethodOp method; }; 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 */ /* An alternative native that's safe to call in parallel mode. */ JSParallelNative parallelNative; }; #define JS_JITINFO_NATIVE_PARALLEL(op) \ {{NULL},0,0,JSJitInfo::OpType_None,false,false,false,JSVAL_TYPE_MISSING,op} static JS_ALWAYS_INLINE const JSJitInfo * FUNCTION_VALUE_TO_JITINFO(const JS::Value& v) { JS_ASSERT(js::GetObjectClass(&v.toObject()) == js::FunctionClassPtr); 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 typedef bool (* ObjectMetadataCallback)(JSContext *cx, JSObject **pmetadata); /* * Specify a callback to invoke when creating each JS object in the current * compartment, which may return a metadata object to associate with the * object. Objects with different metadata have different shape hierarchies, * so for efficiency, objects should generally try to share metadata objects. */ JS_FRIEND_API(void) SetObjectMetadataCallback(JSContext *cx, ObjectMetadataCallback callback); /* Manipulate the metadata associated with an object. */ JS_FRIEND_API(bool) SetObjectMetadata(JSContext *cx, JS::HandleObject obj, JS::HandleObject metadata); JS_FRIEND_API(JSObject *) GetObjectMetadata(JSObject *obj); /* ES5 8.12.8. */ extern JS_FRIEND_API(JSBool) DefaultValue(JSContext *cx, JS::HandleObject obj, JSType hint, MutableHandleValue vp); /* * Helper function. To approximate a call to the [[DefineOwnProperty]] internal * method described in ES5, first call this, then call JS_DefinePropertyById. * * JS_DefinePropertyById by itself does not enforce the invariants on * non-configurable properties when obj->isNative(). This function performs the * relevant checks (specified in ES5 8.12.9 [[DefineOwnProperty]] steps 1-11), * but only if obj is native. * * The reason for the messiness here is that ES5 uses [[DefineOwnProperty]] as * a sort of extension point, but there is no hook in js::Class, * js::ProxyHandler, or the JSAPI with precisely the right semantics for it. */ extern JS_FRIEND_API(bool) CheckDefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, PropertyOp getter, StrictPropertyOp setter, unsigned attrs); } /* 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); #ifdef JSGC_GENERATIONAL extern JS_FRIEND_API(void) JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSObject *key, void *data); extern JS_FRIEND_API(void) JS_StoreStringPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSString *key, void *data); #else inline void JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSObject *key, void *data) {} inline void JS_StoreStringPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSString *key, void *data) {} #endif /* JSGC_GENERATIONAL */ #endif /* jsfriendapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jslock.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jslock_h #define jslock_h #ifdef JS_THREADSAFE # include "jsapi.h" # include "pratom.h" # include "prcvar.h" # include "prinit.h" # include "prlock.h" # include "prthread.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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsperf.h ================================================ /* -*- 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 perf_jsperf_h #define perf_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, JSObject *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 /* perf_jsperf_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsprf.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 #include #include "jstypes.h" /* ** 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsprototypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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) \ macro(Type, 38, js_InitBinaryDataClasses) \ macro(Data, 39, js_InitBinaryDataClasses) \ macro(uint8, 40, js_InitBinaryDataClasses) \ macro(uint16, 41, js_InitBinaryDataClasses) \ macro(uint32, 42, js_InitBinaryDataClasses) \ macro(uint64, 43, js_InitBinaryDataClasses) \ macro(int8, 44, js_InitBinaryDataClasses) \ macro(int16, 45, js_InitBinaryDataClasses) \ macro(int32, 46, js_InitBinaryDataClasses) \ macro(int64, 47, js_InitBinaryDataClasses) \ macro(float32, 48, js_InitBinaryDataClasses) \ macro(float64, 49, js_InitBinaryDataClasses) \ macro(ArrayType, 50, js_InitBinaryDataClasses) \ macro(StructType, 51, js_InitBinaryDataClasses) \ macro(ArrayTypeObject, 52, js_InitBinaryDataClasses) \ #endif /* jsprototypes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsproxy.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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(JSContext *cx, HandleObject proxy, bool *extensible) = 0; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args); virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args); 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 const char *className(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(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) 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 const char *className(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(JSContext *cx, HandleObject proxy, bool *extensible); static bool call(JSContext *cx, HandleObject proxy, const CallArgs &args); static bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args); 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 const char *className(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::ObjectProxyClassPtr || clasp == js::OuterWindowProxyClassPtr; } inline bool IsFunctionProxyClass(const Class *clasp) { return clasp == js::FunctionProxyClassPtr; } inline bool IsProxyClass(const Class *clasp) { return IsObjectProxyClass(clasp) || IsFunctionProxyClass(clasp); } inline bool IsObjectProxy(JSObject *obj) { return IsObjectProxyClass(GetObjectClass(obj)); } inline bool IsFunctionProxy(JSObject *obj) { return IsFunctionProxyClass(GetObjectClass(obj)); } inline bool IsProxy(JSObject *obj) { return IsProxyClass(GetObjectClass(obj)); } /* * These are part of the API. * * NOTE: PROXY_PRIVATE_SLOT 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 PROXY_PRIVATE_SLOT = 0; const uint32_t PROXY_HANDLER_SLOT = 1; const uint32_t PROXY_EXTRA_SLOT = 2; inline BaseProxyHandler * GetProxyHandler(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return (BaseProxyHandler *) GetReservedSlot(obj, PROXY_HANDLER_SLOT).toPrivate(); } inline const Value & GetProxyPrivate(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return GetReservedSlot(obj, PROXY_PRIVATE_SLOT); } inline JSObject * GetProxyTargetObject(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return GetProxyPrivate(obj).toObjectOrNull(); } inline const Value & GetProxyExtra(JSObject *obj, size_t n) { JS_ASSERT(IsProxy(obj)); return GetReservedSlot(obj, PROXY_EXTRA_SLOT + n); } inline void SetProxyHandler(JSObject *obj, BaseProxyHandler *handler) { JS_ASSERT(IsProxy(obj)); SetReservedSlot(obj, PROXY_HANDLER_SLOT, PrivateValue(handler)); } inline void SetProxyExtra(JSObject *obj, size_t n, const Value &extra) { JS_ASSERT(IsProxy(obj)); JS_ASSERT(n <= 1); SetReservedSlot(obj, PROXY_EXTRA_SLOT + n, extra); } enum ProxyCallable { ProxyNotCallable = false, ProxyIsCallable = true }; JS_FRIEND_API(JSObject *) NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue 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, JS::HandleObject obj); #endif /* jsproxy_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsprvtd.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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" #include "js/HashTable.h" #include "js/Vector.h" /* * 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; /* String typedefs. */ class JSDependentString; class JSExtensibleString; class JSExternalString; class JSLinearString; class JSRope; class JSAtom; class JSWrapper; namespace js { struct ArgumentsData; struct Class; class AutoNameVector; class RegExpGuard; class RegExpObject; class RegExpObjectBuilder; class RegExpShared; class RegExpStatics; class MatchPairs; class PropertyName; class LazyScript; enum RegExpFlag { IgnoreCaseFlag = 0x01, GlobalFlag = 0x02, MultilineFlag = 0x04, StickyFlag = 0x08, NoFlags = 0x00, AllFlags = 0x0f }; class StringBuffer; class FrameRegs; class StackFrame; class ScriptFrameIter; class Proxy; class JS_FRIEND_API(AutoEnterPolicy); 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 JSParallelNative ParallelNative; typedef JSThreadSafeNative ThreadSafeNative; typedef JSPropertyOp PropertyOp; typedef JSStrictPropertyOp StrictPropertyOp; typedef JSPropertyDescriptor PropertyDescriptor; struct SourceCompressionToken; namespace frontend { struct BytecodeEmitter; struct Definition; class FullParseHandler; class FunctionBox; class ObjectBox; struct Token; struct TokenPos; class TokenStream; class ParseMapPool; class ParseNode; template class 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 */ /* "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, JS::Handle obj); /* Signature for class initialization ops. */ typedef JSObject * (* JSClassInitializerOp)(JSContext *cx, JS::HandleObject 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, JS::HandleObject obj, JSBool keysonly); #endif /* jsprvtd_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jspubtd.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jspubtd_h #define jspubtd_h /* * JS public API typedefs. */ #include "mozilla/PodOperations.h" #include "jsprototypes.h" #include "jstypes.h" #if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) || defined(DEBUG) # define JSGC_TRACK_EXACT_ROOTS #endif 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; class JS_PUBLIC_API(AutoGCRooter); 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. */ // 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) */ #ifdef WIN32 typedef wchar_t jschar; #else typedef uint16_t jschar; #endif /* * Run-time version enumeration. For compile-time version checking, please use * the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION, * MOZJS_MINOR_VERSION, MOZJS_PATCH_VERSION, and MOZJS_ALPHA definitions. */ 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 see them if * it implements JSTraceCallback. */ JSTRACE_LAZY_SCRIPT, 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; class JSFlatString; class JSFunction; class JSObject; class JSScript; class JSStableString; // long story class JSString; #ifdef JS_THREADSAFE typedef struct PRCallOnceType JSCallOnceType; #else typedef JSBool JSCallOnceType; #endif typedef JSBool (*JSInitCallback)(void); namespace JS { namespace shadow { struct Runtime { /* Restrict zone access during Minor GC. */ bool needsBarrier_; #ifdef JSGC_GENERATIONAL /* Allow inlining of Nursery::isInside. */ uintptr_t gcNurseryStart_; uintptr_t gcNurseryEnd_; #endif Runtime() : needsBarrier_(false) #ifdef JSGC_GENERATIONAL , gcNurseryStart_(0) , gcNurseryEnd_(0) #endif {} }; } /* namespace shadow */ } /* namespace JS */ namespace js { /* * Parallel operations in general can have one of three states. They may * succeed, fail, or "bail", where bail indicates that the code encountered an * unexpected condition and should be re-run sequentially. Different * subcategories of the "bail" state are encoded as variants of TP_RETRY_*. */ enum ParallelResult { TP_SUCCESS, TP_RETRY_SEQUENTIALLY, TP_RETRY_AFTER_GC, TP_FATAL }; struct ThreadSafeContext; struct ForkJoinSlice; class ExclusiveContext; 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_PROPERTY_DESCRIPTOR, 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 {}; template <> struct RootKind : SpecificRootKind {}; struct ContextFriendFields { protected: JSRuntime *const runtime_; /* The current compartment. */ JSCompartment *compartment_; /* The current zone. */ JS::Zone *zone_; public: explicit ContextFriendFields(JSRuntime *rt) : runtime_(rt), compartment_(NULL), zone_(NULL), autoGCRooters(NULL) { #ifdef JSGC_TRACK_EXACT_ROOTS mozilla::PodArrayZero(thingGCRooters); #endif #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) skipGCRooters = NULL; #endif } static const ContextFriendFields *get(const JSContext *cx) { return reinterpret_cast(cx); } static ContextFriendFields *get(JSContext *cx) { return reinterpret_cast(cx); } #ifdef JSGC_TRACK_EXACT_ROOTS /* * 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 /* Stack of thread-stack-allocated GC roots. */ JS::AutoGCRooter *autoGCRooters; friend JSRuntime *GetRuntime(const JSContext *cx); friend JSCompartment *GetContextCompartment(const JSContext *cx); friend JS::Zone *GetContextZone(const JSContext *cx); }; 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 : JS::shadow::Runtime { struct PerThreadDummy { void *field1; uintptr_t field2; #ifdef DEBUG uint64_t field3; #endif } mainThread; }; public: PerThreadDataFriendFields(); #ifdef JSGC_TRACK_EXACT_ROOTS /* * 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 |JS::shadow::Runtime|. // 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 |JS::shadow::Runtime|. // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| return reinterpret_cast( reinterpret_cast(rt) + RuntimeMainThreadOffset); } }; } /* namespace js */ #endif /* jspubtd_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jstypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* ** 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) /*********************************************************************** ** 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsutil.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * PR assertion checker. */ #ifndef jsutil_h #define jsutil_h #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/GuardObjects.h" #ifdef USE_ZLIB #include #endif #include "js/Utility.h" /* 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); } 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 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); } /*****************************************************************************/ /* 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 */ /* 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 MOZ_IS_GCC #if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) # 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 #endif #endif #if !defined(JS_SILENCE_UNUSED_VALUE_IN_EXPR) # define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ JS_BEGIN_MACRO \ expr; \ JS_END_MACRO #endif #endif /* jsutil_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jsversion.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jsversion_h #define jsversion_h /* * Deprecated JS_VERSION handler. */ #ifdef JS_VERSION # if JS_VERSION == 185 # warning "JS_VERSION defined but unsupported (legacy)" # elif JS_VERSION < 185 # error "Unsupported JS_VERSION" # else # error "Unknown JS_VERSION" # endif #endif /* * JS Capability Macros. */ #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 */ /* 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_ASSUME_UNREACHABLE("don't call this! to be used in the new object representation") #endif #endif /* jsversion_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/jswrapper.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 CheckedUnwrap) will throw. Otherwise, they will succeed. */ void setSafeToUnwrap(bool safe) { mSafeToUnwrap = safe; } 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(JSObject *wrapper); static JSObject *wrappedObject(JSObject *wrapper); unsigned flags() const { return mFlags; } explicit Wrapper(unsigned flags, bool hasPrototype = false); virtual ~Wrapper(); static Wrapper singleton; static Wrapper singletonWithPrototype; }; /* 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(JSContext *cx, HandleObject wrapper, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject wrapper, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject wrapper, const CallArgs &args) 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 const char *className(JSContext *cx, HandleObject proxy) 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(JSContext *cx, HandleObject wrapper, bool *extensible) 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 defaultValue(JSContext *cx, HandleObject wrapper, JSType hint, MutableHandleValue vp) 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(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) 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 const char *className(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 bool getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp, bool *present) MOZ_OVERRIDE; virtual bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop) MOZ_OVERRIDE; static DeadObjectProxy singleton; }; extern JSObject * TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject obj, HandleObject wrappedProto, HandleObject 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(JSObject *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 *) UncheckedUnwrap(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 *) CheckedUnwrap(JSObject *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(JSObject *obj, bool stopAtOuter = true); JS_FRIEND_API(bool) IsCrossCompartmentWrapper(JSObject *obj); bool IsDeadProxyObject(JSObject *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 /* jswrapper_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/AllocPolicy.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * An allocation policy concept, usable for structures and algorithms to * control how memory is allocated and how failures are handled. */ #ifndef mozilla_AllocPolicy_h #define mozilla_AllocPolicy_h #include #include namespace mozilla { /* * Allocation policies are used to implement the standard allocation behaviors * in a customizable way. Additionally, custom behaviors may be added to these * behaviors, such as additionally reporting an error through an out-of-band * mechanism when OOM occurs. The concept modeled here is as follows: * * - public copy constructor, assignment, destructor * - void* malloc_(size_t) * Responsible for OOM reporting when null is returned. * - void* calloc_(size_t) * Responsible for OOM reporting when null is returned. * - void* realloc_(void*, size_t, size_t) * Responsible for OOM reporting when null is returned. 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*) * - void reportAllocOverflow() const * Called on allocation overflow (that is, an allocation implicitly tried * to allocate more than the available memory space -- think allocating an * array of large-size objects, where N * size overflows) before null is * returned. * * mfbt provides (and typically uses by default) only MallocAllocPolicy, which * does nothing more than delegate to the malloc/alloc/free functions. */ /* * A policy that straightforwardly uses malloc/calloc/realloc/free and adds no * extra behaviors. */ class MallocAllocPolicy { public: void* malloc_(size_t bytes) { return malloc(bytes); } void* calloc_(size_t bytes) { return calloc(bytes, 1); } void* realloc_(void* p, size_t oldBytes, size_t bytes) { return realloc(p, bytes); } void free_(void* p) { free(p); } void reportAllocOverflow() const {} }; } // namespace mozilla #endif /* mozilla_AllocPolicy_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Array.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 compile-time constant-length array with bounds-checking assertions. */ #ifndef mozilla_Array_h #define mozilla_Array_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include namespace mozilla { template class Array { T arr[Length]; public: T& operator[](size_t i) { MOZ_ASSERT(i < Length); return arr[i]; } const T& operator[](size_t i) const { MOZ_ASSERT(i < Length); return arr[i]; } }; template class Array { public: T& operator[](size_t i) { MOZ_ASSUME_UNREACHABLE("indexing into zero-length array"); } const T& operator[](size_t i) const { MOZ_ASSUME_UNREACHABLE("indexing into zero-length array"); } }; } /* namespace mozilla */ #endif /* mozilla_Array_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Assertions.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "mozilla/Likely.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* in C. * In C++11, static_assert is provided by the compiler to the same effect. * 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 { ... }; * // C * MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0, * "S should be a multiple of word size for efficiency"); * // C++11 * 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. */ #ifndef __cplusplus /* * 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 #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) #else #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) static_assert(!(cond) || (expr), reason) #endif #ifdef __cplusplus extern "C" { #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 or MOZ_CRASH 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 } static MOZ_ALWAYS_INLINE void MOZ_ReportCrash(const char* s, const char* file, int ln) { #ifdef ANDROID __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln); #else fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln); fflush(stderr); #endif } /** * MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH(). You should * call MOZ_CRASH instead. */ #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. * * We follow TerminateProcess() with a call to MOZ_NoReturn() so that the * compiler doesn't hassle us to provide a return statement after a * MOZ_REALLY_CRASH() call. * * (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.) */ __declspec(noreturn) __inline void MOZ_NoReturn() {} # ifdef __cplusplus # define MOZ_REALLY_CRASH() \ do { \ __debugbreak(); \ *((volatile int*) NULL) = 123; \ ::TerminateProcess(::GetCurrentProcess(), 3); \ ::MOZ_NoReturn(); \ } while (0) # else # define MOZ_REALLY_CRASH() \ do { \ __debugbreak(); \ *((volatile int*) NULL) = 123; \ TerminateProcess(GetCurrentProcess(), 3); \ MOZ_NoReturn(); \ } while (0) # endif #else # ifdef __cplusplus # define MOZ_REALLY_CRASH() \ do { \ *((volatile int*) NULL) = 123; \ ::abort(); \ } while (0) # else # define MOZ_REALLY_CRASH() \ do { \ *((volatile int*) NULL) = 123; \ abort(); \ } while (0) # endif #endif /* * MOZ_CRASH([explanation-string]) 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. * * The optional explanation-string, if provided, must be a string literal * explaining why we're crashing. This argument is intended for use with * MOZ_CRASH() calls whose rationale is non-obvious; don't use it if it's * obvious why we're crashing. * * If we're a DEBUG build and we crash at a MOZ_CRASH which provides an * explanation-string, we print the string to stderr. Otherwise, we don't * print anything; this is because we want MOZ_CRASH to be 100% safe in release * builds, and it's hard to print to stderr safely when memory might have been * corrupted. */ #ifndef DEBUG # define MOZ_CRASH(...) MOZ_REALLY_CRASH() #else # define MOZ_CRASH(...) \ do { \ MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \ MOZ_REALLY_CRASH(); \ } while(0) #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 (MOZ_UNLIKELY(!(expr))) { \ MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \ MOZ_REALLY_CRASH(); \ } \ } while (0) /* Now the two-argument form. */ # define MOZ_ASSERT_HELPER2(expr, explain) \ do { \ if (MOZ_UNLIKELY(!(expr))) { \ MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \ MOZ_REALLY_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_ASSUME_UNREACHABLE_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_ASSUME_UNREACHABLE, which uses this when * appropriate. */ #if defined(__clang__) # define MOZ_ASSUME_UNREACHABLE_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_ASSUME_UNREACHABLE_MARKER() __builtin_unreachable() # else # ifdef __cplusplus # define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() # else # define MOZ_ASSUME_UNREACHABLE_MARKER() abort() # endif # endif #elif defined(_MSC_VER) # define MOZ_ASSUME_UNREACHABLE_MARKER() __assume(0) #else # ifdef __cplusplus # define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() # else # define MOZ_ASSUME_UNREACHABLE_MARKER() abort() # endif #endif /* * MOZ_ASSUME_UNREACHABLE([reason]) tells the compiler that it can assume that * the macro call cannot be reached during execution. This lets the compiler * generate better-optimized code under some circumstances, at the expense of * the program's behavior being undefined if control reaches the * MOZ_ASSUME_UNREACHABLE. * * In Gecko, you probably should not use this macro outside of performance- or * size-critical code, because it's unsafe. If you don't care about code size * or performance, you should probably use MOZ_ASSERT or MOZ_CRASH. * * SpiderMonkey is a different beast, and there it's acceptable to use * MOZ_ASSUME_UNREACHABLE more widely. * * Note that MOZ_ASSUME_UNREACHABLE is noreturn, so it's valid not to return a * value following a MOZ_ASSUME_UNREACHABLE call. * * Example usage: * * enum ValueType { * VALUE_STRING, * VALUE_INT, * VALUE_FLOAT * }; * * int ptrToInt(ValueType type, void* value) { * { * // We know for sure that type is either INT or FLOAT, and we want this * // code to run as quickly as possible. * switch (type) { * case VALUE_INT: * return *(int*) value; * case VALUE_FLOAT: * return (int) *(float*) value; * default: * MOZ_ASSUME_UNREACHABLE("can only handle VALUE_INT and VALUE_FLOAT"); * } * } */ #if defined(DEBUG) # define MOZ_ASSUME_UNREACHABLE(...) \ do { \ MOZ_ASSERT(false, "MOZ_ASSUME_UNREACHABLE(" __VA_ARGS__ ")"); \ MOZ_ASSUME_UNREACHABLE_MARKER(); \ } while (0) #else # define MOZ_ASSUME_UNREACHABLE(reason) MOZ_ASSUME_UNREACHABLE_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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Atomics.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 (almost always) lock-free atomic operations. The operations here * are a subset of that which can be found in C++11's header, with a * different API to enforce consistent memory ordering constraints. * * Anyone caught using |volatile| for inter-thread memory safety needs to be * sent a copy of this header and the C++11 standard. */ #ifndef mozilla_Atomics_h #define mozilla_Atomics_h #include "mozilla/Assertions.h" #include "mozilla/TypeTraits.h" #include /* * Our minimum deployment target on clang/OS X is OS X 10.6, whose SDK * does not have . So be sure to check for support * along with C++0x support. */ #if defined(__clang__) /* * clang doesn't like libstdc++'s version of before GCC 4.7, * due to the loose typing of the __sync_* family of functions done by * GCC. We do not have a particularly good way to detect this sort of * case at this point, so just assume that if we're on a Linux system, * we can't use the system's . * * OpenBSD uses an old libstdc++ 4.2.1 and thus doesnt have . */ # if !defined(__linux__) && !defined(__OpenBSD__) && \ (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && \ __has_include() # define MOZ_HAVE_CXX11_ATOMICS # endif /* * Android uses a different C++ standard library that does not provide * support for . * * GCC 4.5.x and 4.6.x's unspecialized std::atomic template doesn't include * inline definitions for the functions declared therein. This oversight * leads to linking errors when using atomic enums. We therefore require * GCC 4.7 or higher. */ #elif defined(__GNUC__) && !defined(__ANDROID__) # include "mozilla/Compiler.h" # if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) && \ MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) # define MOZ_HAVE_CXX11_ATOMICS # endif #elif defined(_MSC_VER) && _MSC_VER >= 1700 # define MOZ_HAVE_CXX11_ATOMICS #endif namespace mozilla { /** * An enum of memory ordering possibilities for atomics. * * Memory ordering is the observable state of distinct values in memory. * (It's a separate concept from atomicity, which concerns whether an * operation can ever be observed in an intermediate state. Don't * conflate the two!) Given a sequence of operations in source code on * memory, it is *not* always the case that, at all times and on all * cores, those operations will appear to have occurred in that exact * sequence. First, the compiler might reorder that sequence, if it * thinks another ordering will be more efficient. Second, the CPU may * not expose so consistent a view of memory. CPUs will often perform * their own instruction reordering, above and beyond that performed by * the compiler. And each core has its own memory caches, and accesses * (reads and writes both) to "memory" may only resolve to out-of-date * cache entries -- not to the "most recently" performed operation in * some global sense. Any access to a value that may be used by * multiple threads, potentially across multiple cores, must therefore * have a memory ordering imposed on it, for all code on all * threads/cores to have a sufficiently coherent worldview. * * http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync and * http://en.cppreference.com/w/cpp/atomic/memory_order go into more * detail on all this, including examples of how each mode works. * * Note that for simplicity and practicality, not all of the modes in * C++11 are supported. The missing C++11 modes are either subsumed by * the modes we provide below, or not relevant for the CPUs we support * in Gecko. These three modes are confusing enough as it is! */ enum MemoryOrdering { /* * Relaxed ordering is the simplest memory ordering: none at all. * When the result of a write is observed, nothing may be inferred * about other memory. Writes ostensibly performed "before" on the * writing thread may not yet be visible. Writes performed "after" on * the writing thread may already be visible, if the compiler or CPU * reordered them. (The latter can happen if reads and/or writes get * held up in per-processor caches.) Relaxed ordering means * operations can always use cached values (as long as the actual * updates to atomic values actually occur, correctly, eventually), so * it's usually the fastest sort of atomic access. For this reason, * *it's also the most dangerous kind of access*. * * Relaxed ordering is good for things like process-wide statistics * counters that don't need to be consistent with anything else, so * long as updates themselves are atomic. (And so long as any * observations of that value can tolerate being out-of-date -- if you * need some sort of up-to-date value, you need some sort of other * synchronizing operation.) It's *not* good for locks, mutexes, * reference counts, etc. that mediate access to other memory, or must * be observably consistent with other memory. * * x86 architectures don't take advantage of the optimization * opportunities that relaxed ordering permits. Thus it's possible * that using relaxed ordering will "work" on x86 but fail elsewhere * (ARM, say, which *does* implement non-sequentially-consistent * relaxed ordering semantics). Be extra-careful using relaxed * ordering if you can't easily test non-x86 architectures! */ Relaxed, /* * When an atomic value is updated with ReleaseAcquire ordering, and * that new value is observed with ReleaseAcquire ordering, prior * writes (atomic or not) are also observable. What ReleaseAcquire * *doesn't* give you is any observable ordering guarantees for * ReleaseAcquire-ordered operations on different objects. For * example, if there are two cores that each perform ReleaseAcquire * operations on separate objects, each core may or may not observe * the operations made by the other core. The only way the cores can * be synchronized with ReleaseAcquire is if they both * ReleaseAcquire-access the same object. This implies that you can't * necessarily describe some global total ordering of ReleaseAcquire * operations. * * ReleaseAcquire ordering is good for (as the name implies) atomic * operations on values controlling ownership of things: reference * counts, mutexes, and the like. However, if you are thinking about * using these to implement your own locks or mutexes, you should take * a good, hard look at actual lock or mutex primitives first. */ ReleaseAcquire, /* * When an atomic value is updated with SequentiallyConsistent * ordering, all writes observable when the update is observed, just * as with ReleaseAcquire ordering. But, furthermore, a global total * ordering of SequentiallyConsistent operations *can* be described. * For example, if two cores perform SequentiallyConsistent operations * on separate objects, one core will observably perform its update * (and all previous operations will have completed), then the other * core will observably perform its update (and all previous * operations will have completed). (Although those previous * operations aren't themselves ordered -- they could be intermixed, * or ordered if they occur on atomic values with ordering * requirements.) SequentiallyConsistent is the *simplest and safest* * ordering of atomic operations -- it's always as if one operation * happens, then another, then another, in some order -- and every * core observes updates to happen in that single order. Because it * has the most synchronization requirements, operations ordered this * way also tend to be slowest. * * SequentiallyConsistent ordering can be desirable when multiple * threads observe objects, and they all have to agree on the * observable order of changes to them. People expect * SequentiallyConsistent ordering, even if they shouldn't, when * writing code, atomic or otherwise. SequentiallyConsistent is also * the ordering of choice when designing lockless data structures. If * you don't know what order to use, use this one. */ SequentiallyConsistent, }; } // namespace mozilla // Build up the underlying intrinsics. #ifdef MOZ_HAVE_CXX11_ATOMICS # include namespace mozilla { namespace detail { /* * We provide CompareExchangeFailureOrder to work around a bug in some * versions of GCC's header. See bug 898491. */ template struct AtomicOrderConstraints; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_relaxed; static const std::memory_order LoadOrder = std::memory_order_relaxed; static const std::memory_order StoreOrder = std::memory_order_relaxed; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_relaxed; }; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_acq_rel; static const std::memory_order LoadOrder = std::memory_order_acquire; static const std::memory_order StoreOrder = std::memory_order_release; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_acquire; }; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_seq_cst; static const std::memory_order LoadOrder = std::memory_order_seq_cst; static const std::memory_order StoreOrder = std::memory_order_seq_cst; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_seq_cst; }; template struct IntrinsicBase { typedef std::atomic ValueType; typedef AtomicOrderConstraints OrderedOp; }; template struct IntrinsicMemoryOps : public IntrinsicBase { typedef IntrinsicBase Base; static T load(const typename Base::ValueType& ptr) { return ptr.load(Base::OrderedOp::LoadOrder); } static void store(typename Base::ValueType& ptr, T val) { ptr.store(val, Base::OrderedOp::StoreOrder); } static T exchange(typename Base::ValueType& ptr, T val) { return ptr.exchange(val, Base::OrderedOp::AtomicRMWOrder); } static bool compareExchange(typename Base::ValueType& ptr, T oldVal, T newVal) { return ptr.compare_exchange_strong(oldVal, newVal, Base::OrderedOp::AtomicRMWOrder, Base::OrderedOp::CompareExchangeFailureOrder); } }; template struct IntrinsicAddSub : public IntrinsicBase { typedef IntrinsicBase Base; static T add(typename Base::ValueType& ptr, T val) { return ptr.fetch_add(val, Base::OrderedOp::AtomicRMWOrder); } static T sub(typename Base::ValueType& ptr, T val) { return ptr.fetch_sub(val, Base::OrderedOp::AtomicRMWOrder); } }; template struct IntrinsicAddSub : public IntrinsicBase { typedef IntrinsicBase Base; static T* add(typename Base::ValueType& ptr, ptrdiff_t val) { return ptr.fetch_add(fixupAddend(val), Base::OrderedOp::AtomicRMWOrder); } static T* sub(typename Base::ValueType& ptr, ptrdiff_t val) { return ptr.fetch_sub(fixupAddend(val), Base::OrderedOp::AtomicRMWOrder); } private: /* * GCC 4.6's header has a bug where adding X to an * atomic is not the same as adding X to a T*. Hence the need * for this function to provide the correct addend. */ static ptrdiff_t fixupAddend(ptrdiff_t val) { #if defined(__clang__) || defined(_MSC_VER) return val; #elif defined(__GNUC__) && MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) && \ !MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) return val * sizeof(T); #else return val; #endif } }; template struct IntrinsicIncDec : public IntrinsicAddSub { typedef IntrinsicBase Base; static T inc(typename Base::ValueType& ptr) { return IntrinsicAddSub::add(ptr, 1); } static T dec(typename Base::ValueType& ptr) { return IntrinsicAddSub::sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { typedef IntrinsicBase Base; static T or_(typename Base::ValueType& ptr, T val) { return ptr.fetch_or(val, Base::OrderedOp::AtomicRMWOrder); } static T xor_(typename Base::ValueType& ptr, T val) { return ptr.fetch_xor(val, Base::OrderedOp::AtomicRMWOrder); } static T and_(typename Base::ValueType& ptr, T val) { return ptr.fetch_and(val, Base::OrderedOp::AtomicRMWOrder); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #elif defined(__GNUC__) namespace mozilla { namespace detail { /* * The __sync_* family of intrinsics is documented here: * * http://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Atomic-Builtins.html * * While these intrinsics are deprecated in favor of the newer __atomic_* * family of intrincs: * * http://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/_005f_005fatomic-Builtins.html * * any GCC version that supports the __atomic_* intrinsics will also support * the header and so will be handled above. We provide a version of * atomics using the __sync_* intrinsics to support older versions of GCC. * * All __sync_* intrinsics that we use below act as full memory barriers, for * both compiler and hardware reordering, except for __sync_lock_test_and_set, * which is a only an acquire barrier. When we call __sync_lock_test_and_set, * we add a barrier above it as appropriate. */ template struct Barrier; /* * Some processors (in particular, x86) don't require quite so many calls to * __sync_sychronize as our specializations of Barrier produce. If * performance turns out to be an issue, defining these specializations * on a per-processor basis would be a good first tuning step. */ template<> struct Barrier { static void beforeLoad() {} static void afterLoad() {} static void beforeStore() {} static void afterStore() {} }; template<> struct Barrier { static void beforeLoad() {} static void afterLoad() { __sync_synchronize(); } static void beforeStore() { __sync_synchronize(); } static void afterStore() {} }; template<> struct Barrier { static void beforeLoad() { __sync_synchronize(); } static void afterLoad() { __sync_synchronize(); } static void beforeStore() { __sync_synchronize(); } static void afterStore() { __sync_synchronize(); } }; template struct IntrinsicMemoryOps { static T load(const T& ptr) { Barrier::beforeLoad(); T val = ptr; Barrier::afterLoad(); return val; } static void store(T& ptr, T val) { Barrier::beforeStore(); ptr = val; Barrier::afterStore(); } static T exchange(T& ptr, T val) { // __sync_lock_test_and_set is only an acquire barrier; loads and stores // can't be moved up from after to before it, but they can be moved down // from before to after it. We may want a stricter ordering, so we need // an explicit barrier. Barrier::beforeStore(); return __sync_lock_test_and_set(&ptr, val); } static bool compareExchange(T& ptr, T oldVal, T newVal) { return __sync_bool_compare_and_swap(&ptr, oldVal, newVal); } }; template struct IntrinsicAddSub { typedef T ValueType; static T add(T& ptr, T val) { return __sync_fetch_and_add(&ptr, val); } static T sub(T& ptr, T val) { return __sync_fetch_and_sub(&ptr, val); } }; template struct IntrinsicAddSub { typedef T* ValueType; /* * The reinterpret_casts are needed so that * __sync_fetch_and_{add,sub} will properly type-check. * * Also, these functions do not provide standard semantics for * pointer types, so we need to adjust the addend. */ static ValueType add(ValueType& ptr, ptrdiff_t val) { ValueType amount = reinterpret_cast(val * sizeof(T)); return __sync_fetch_and_add(&ptr, amount); } static ValueType sub(ValueType& ptr, ptrdiff_t val) { ValueType amount = reinterpret_cast(val * sizeof(T)); return __sync_fetch_and_sub(&ptr, amount); } }; template struct IntrinsicIncDec : public IntrinsicAddSub { static T inc(T& ptr) { return IntrinsicAddSub::add(ptr, 1); } static T dec(T& ptr) { return IntrinsicAddSub::sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { static T or_(T& ptr, T val) { return __sync_fetch_and_or(&ptr, val); } static T xor_(T& ptr, T val) { return __sync_fetch_and_xor(&ptr, val); } static T and_(T& ptr, T val) { return __sync_fetch_and_and(&ptr, val); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #elif defined(_MSC_VER) /* * Windows comes with a full complement of atomic operations. * Unfortunately, most of those aren't available for Windows XP (even if * the compiler supports intrinsics for them), which is the oldest * version of Windows we support. Therefore, we only provide operations * on 32-bit datatypes for 32-bit Windows versions; for 64-bit Windows * versions, we support 64-bit datatypes as well. * * To avoid namespace pollution issues, we declare whatever functions we * need ourselves. */ extern "C" { long __cdecl _InterlockedExchangeAdd(long volatile* dst, long value); long __cdecl _InterlockedOr(long volatile* dst, long value); long __cdecl _InterlockedXor(long volatile* dst, long value); long __cdecl _InterlockedAnd(long volatile* dst, long value); long __cdecl _InterlockedExchange(long volatile *dst, long value); long __cdecl _InterlockedCompareExchange(long volatile *dst, long newVal, long oldVal); } # pragma intrinsic(_InterlockedExchangeAdd) # pragma intrinsic(_InterlockedOr) # pragma intrinsic(_InterlockedXor) # pragma intrinsic(_InterlockedAnd) # pragma intrinsic(_InterlockedExchange) # pragma intrinsic(_InterlockedCompareExchange) namespace mozilla { namespace detail { # if !defined(_M_IX86) && !defined(_M_X64) /* * The implementations below are optimized for x86ish systems. You * will have to modify them if you are porting to Windows on a * different architecture. */ # error "Unknown CPU type" # endif /* * The PrimitiveIntrinsics template should define |Type|, the datatype of size * DataSize upon which we operate, and the following eight functions. * * static Type add(Type* ptr, Type val); * static Type sub(Type* ptr, Type val); * static Type or_(Type* ptr, Type val); * static Type xor_(Type* ptr, Type val); * static Type and_(Type* ptr, Type val); * * These functions perform the obvious operation on the value contained in * |*ptr| combined with |val| and return the value previously stored in * |*ptr|. * * static void store(Type* ptr, Type val); * * This function atomically stores |val| into |*ptr| and must provide a full * memory fence after the store to prevent compiler and hardware instruction * reordering. It should also act as a compiler barrier to prevent reads and * writes from moving to after the store. * * static Type exchange(Type* ptr, Type val); * * This function atomically stores |val| into |*ptr| and returns the previous * contents of *ptr; * * static bool compareExchange(Type* ptr, Type oldVal, Type newVal); * * This function atomically performs the following operation: * * if (*ptr == oldVal) { * *ptr = newVal; * return true; * } else { * return false; * } * */ template struct PrimitiveIntrinsics; template<> struct PrimitiveIntrinsics<4> { typedef long Type; static Type add(Type* ptr, Type val) { return _InterlockedExchangeAdd(ptr, val); } static Type sub(Type* ptr, Type val) { /* * _InterlockedExchangeSubtract isn't available before Windows 7, * and we must support Windows XP. */ return _InterlockedExchangeAdd(ptr, -val); } static Type or_(Type* ptr, Type val) { return _InterlockedOr(ptr, val); } static Type xor_(Type* ptr, Type val) { return _InterlockedXor(ptr, val); } static Type and_(Type* ptr, Type val) { return _InterlockedAnd(ptr, val); } static void store(Type* ptr, Type val) { _InterlockedExchange(ptr, val); } static Type exchange(Type* ptr, Type val) { return _InterlockedExchange(ptr, val); } static bool compareExchange(Type* ptr, Type oldVal, Type newVal) { return _InterlockedCompareExchange(ptr, newVal, oldVal) == oldVal; } }; # if defined(_M_X64) extern "C" { long long __cdecl _InterlockedExchangeAdd64(long long volatile* dst, long long value); long long __cdecl _InterlockedOr64(long long volatile* dst, long long value); long long __cdecl _InterlockedXor64(long long volatile* dst, long long value); long long __cdecl _InterlockedAnd64(long long volatile* dst, long long value); long long __cdecl _InterlockedExchange64(long long volatile* dst, long long value); long long __cdecl _InterlockedCompareExchange64(long long volatile* dst, long long newVal, long long oldVal); } # pragma intrinsic(_InterlockedExchangeAdd64) # pragma intrinsic(_InterlockedOr64) # pragma intrinsic(_InterlockedXor64) # pragma intrinsic(_InterlockedAnd64) # pragma intrinsic(_InterlockedExchange64) # pragma intrinsic(_InterlockedCompareExchange64) template <> struct PrimitiveIntrinsics<8> { typedef __int64 Type; static Type add(Type* ptr, Type val) { return _InterlockedExchangeAdd64(ptr, val); } static Type sub(Type* ptr, Type val) { /* * There is no _InterlockedExchangeSubtract64. */ return _InterlockedExchangeAdd64(ptr, -val); } static Type or_(Type* ptr, Type val) { return _InterlockedOr64(ptr, val); } static Type xor_(Type* ptr, Type val) { return _InterlockedXor64(ptr, val); } static Type and_(Type* ptr, Type val) { return _InterlockedAnd64(ptr, val); } static void store(Type* ptr, Type val) { _InterlockedExchange64(ptr, val); } static Type exchange(Type* ptr, Type val) { return _InterlockedExchange64(ptr, val); } static bool compareExchange(Type* ptr, Type oldVal, Type newVal) { return _InterlockedCompareExchange64(ptr, newVal, oldVal) == oldVal; } }; # endif extern "C" { void _ReadWriteBarrier(); } # pragma intrinsic(_ReadWriteBarrier) template struct Barrier; /* * We do not provide an afterStore method in Barrier, as Relaxed and * ReleaseAcquire orderings do not require one, and the required barrier * for SequentiallyConsistent is handled by PrimitiveIntrinsics. */ template<> struct Barrier { static void beforeLoad() {} static void afterLoad() {} static void beforeStore() {} }; template<> struct Barrier { static void beforeLoad() {} static void afterLoad() { _ReadWriteBarrier(); } static void beforeStore() { _ReadWriteBarrier(); } }; template<> struct Barrier { static void beforeLoad() { _ReadWriteBarrier(); } static void afterLoad() { _ReadWriteBarrier(); } static void beforeStore() { _ReadWriteBarrier(); } }; template struct CastHelper { static PrimType toPrimType(T val) { return static_cast(val); } static T fromPrimType(PrimType val) { return static_cast(val); } }; template struct CastHelper { static PrimType toPrimType(T* val) { return reinterpret_cast(val); } static T* fromPrimType(PrimType val) { return reinterpret_cast(val); } }; template struct IntrinsicBase { typedef T ValueType; typedef PrimitiveIntrinsics Primitives; typedef typename Primitives::Type PrimType; static_assert(sizeof(PrimType) == sizeof(T), "Selection of PrimitiveIntrinsics was wrong"); typedef CastHelper Cast; }; template struct IntrinsicMemoryOps : public IntrinsicBase { static ValueType load(const ValueType& ptr) { Barrier::beforeLoad(); ValueType val = ptr; Barrier::afterLoad(); return val; } static void store(ValueType& ptr, ValueType val) { // For SequentiallyConsistent, Primitives::store() will generate the // proper memory fence. Everything else just needs a barrier before // the store. if (Order == SequentiallyConsistent) { Primitives::store(reinterpret_cast(&ptr), Cast::toPrimType(val)); } else { Barrier::beforeStore(); ptr = val; } } static ValueType exchange(ValueType& ptr, ValueType val) { PrimType oldval = Primitives::exchange(reinterpret_cast(&ptr), Cast::toPrimType(val)); return Cast::fromPrimType(oldval); } static bool compareExchange(ValueType& ptr, ValueType oldVal, ValueType newVal) { return Primitives::compareExchange(reinterpret_cast(&ptr), Cast::toPrimType(oldVal), Cast::toPrimType(newVal)); } }; template struct IntrinsicApplyHelper : public IntrinsicBase { typedef PrimType (*BinaryOp)(PrimType*, PrimType); typedef PrimType (*UnaryOp)(PrimType*); static ValueType applyBinaryFunction(BinaryOp op, ValueType& ptr, ValueType val) { PrimType* primTypePtr = reinterpret_cast(&ptr); PrimType primTypeVal = Cast::toPrimType(val); return Cast::fromPrimType(op(primTypePtr, primTypeVal)); } static ValueType applyUnaryFunction(UnaryOp op, ValueType& ptr) { PrimType* primTypePtr = reinterpret_cast(&ptr); return Cast::fromPrimType(op(primTypePtr)); } }; template struct IntrinsicAddSub : public IntrinsicApplyHelper { static ValueType add(ValueType& ptr, ValueType val) { return applyBinaryFunction(&Primitives::add, ptr, val); } static ValueType sub(ValueType& ptr, ValueType val) { return applyBinaryFunction(&Primitives::sub, ptr, val); } }; template struct IntrinsicAddSub : public IntrinsicApplyHelper { static ValueType add(ValueType& ptr, ptrdiff_t amount) { return applyBinaryFunction(&Primitives::add, ptr, (ValueType)(amount * sizeof(ValueType))); } static ValueType sub(ValueType& ptr, ptrdiff_t amount) { return applyBinaryFunction(&Primitives::sub, ptr, (ValueType)(amount * sizeof(ValueType))); } }; template struct IntrinsicIncDec : public IntrinsicAddSub { static ValueType inc(ValueType& ptr) { return add(ptr, 1); } static ValueType dec(ValueType& ptr) { return sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { static ValueType or_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::or_, ptr, val); } static ValueType xor_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::xor_, ptr, val); } static ValueType and_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::and_, ptr, val); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #else # error "Atomic compiler intrinsics are not supported on your platform" #endif namespace mozilla { namespace detail { template class AtomicBase { // We only support 32-bit types on 32-bit Windows, which constrains our // implementation elsewhere. But we support pointer-sized types everywhere. static_assert(sizeof(T) == 4 || (sizeof(uintptr_t) == 8 && sizeof(T) == 8), "mozilla/Atomics.h only supports 32-bit and pointer-sized types"); protected: typedef typename detail::AtomicIntrinsics Intrinsics; typename Intrinsics::ValueType mValue; public: AtomicBase() : mValue() {} AtomicBase(T aInit) { Intrinsics::store(mValue, aInit); } operator T() const { return Intrinsics::load(mValue); } T operator=(T aValue) { Intrinsics::store(mValue, aValue); return aValue; } /** * Performs an atomic swap operation. aValue is stored and the previous * value of this variable is returned. */ T exchange(T aValue) { return Intrinsics::exchange(mValue, aValue); } /** * Performs an atomic compare-and-swap operation and returns true if it * succeeded. This is equivalent to atomically doing * * if (mValue == aOldValue) { * mValue = aNewValue; * return true; * } else { * return false; * } */ bool compareExchange(T aOldValue, T aNewValue) { return Intrinsics::compareExchange(mValue, aOldValue, aNewValue); } private: template AtomicBase(const AtomicBase& aCopy) MOZ_DELETE; }; template class AtomicBaseIncDec : public AtomicBase { typedef typename detail::AtomicBase Base; public: AtomicBaseIncDec() : Base() {} AtomicBaseIncDec(T aInit) : Base(aInit) {} using Base::operator=; T operator++(int) { return Base::Intrinsics::inc(Base::mValue); } T operator--(int) { return Base::Intrinsics::dec(Base::mValue); } T operator++() { return Base::Intrinsics::inc(Base::mValue) + 1; } T operator--() { return Base::Intrinsics::dec(Base::mValue) - 1; } private: template AtomicBaseIncDec(const AtomicBaseIncDec& aCopy) MOZ_DELETE; }; } // namespace detail /** * A wrapper for a type that enforces that all memory accesses are atomic. * * In general, where a variable |T foo| exists, |Atomic foo| can be used in * its place. Implementations for integral and pointer types are provided * below. * * Atomic accesses are sequentially consistent by default. You should * use the default unless you are tall enough to ride the * memory-ordering roller coaster (if you're not sure, you aren't) and * you have a compelling reason to do otherwise. * * There is one exception to the case of atomic memory accesses: providing an * initial value of the atomic value is not guaranteed to be atomic. This is a * deliberate design choice that enables static atomic variables to be declared * without introducing extra static constructors. */ template class Atomic; /** * Atomic implementation for integral types. * * In addition to atomic store and load operations, compound assignment and * increment/decrement operators are implemented which perform the * corresponding read-modify-write operation atomically. Finally, an atomic * swap method is provided. */ template class Atomic::value>::Type> : public detail::AtomicBaseIncDec { typedef typename detail::AtomicBaseIncDec Base; public: Atomic() : Base() {} Atomic(T aInit) : Base(aInit) {} using Base::operator=; T operator+=(T delta) { return Base::Intrinsics::add(Base::mValue, delta) + delta; } T operator-=(T delta) { return Base::Intrinsics::sub(Base::mValue, delta) - delta; } T operator|=(T val) { return Base::Intrinsics::or_(Base::mValue, val) | val; } T operator^=(T val) { return Base::Intrinsics::xor_(Base::mValue, val) ^ val; } T operator&=(T val) { return Base::Intrinsics::and_(Base::mValue, val) & val; } private: Atomic(Atomic& aOther) MOZ_DELETE; }; /** * Atomic implementation for pointer types. * * An atomic compare-and-swap primitive for pointer variables is provided, as * are atomic increment and decement operators. Also provided are the compound * assignment operators for addition and subtraction. Atomic swap (via * exchange()) is included as well. */ template class Atomic : public detail::AtomicBaseIncDec { typedef typename detail::AtomicBaseIncDec Base; public: Atomic() : Base() {} Atomic(T* aInit) : Base(aInit) {} using Base::operator=; T* operator+=(ptrdiff_t delta) { return Base::Intrinsics::add(Base::mValue, delta) + delta; } T* operator-=(ptrdiff_t delta) { return Base::Intrinsics::sub(Base::mValue, delta) - delta; } private: Atomic(Atomic& aOther) MOZ_DELETE; }; /** * Atomic implementation for enum types. * * The atomic store and load operations and the atomic swap method is provided. */ template class Atomic::value>::Type> : public detail::AtomicBase { typedef typename detail::AtomicBase Base; public: Atomic() : Base() {} Atomic(T aInit) : Base(aInit) {} using Base::operator=; private: Atomic(Atomic& aOther) MOZ_DELETE; }; } // namespace mozilla #endif /* mozilla_Atomics_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Attributes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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). * * The MOZ_ALWAYS_INLINE_EVEN_DEBUG macro is yet stronger. It tells the * compiler to inline even in DEBUG builds. It should be used very rarely. */ #if defined(_MSC_VER) # define MOZ_ALWAYS_INLINE_EVEN_DEBUG __forceinline #elif defined(__GNUC__) # define MOZ_ALWAYS_INLINE_EVEN_DEBUG __attribute__((always_inline)) MOZ_INLINE #else # define MOZ_ALWAYS_INLINE_EVEN_DEBUG MOZ_INLINE #endif #if defined(DEBUG) # define MOZ_ALWAYS_INLINE MOZ_INLINE #else # define MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG #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. * The MOZ_CONSTEXPR_VAR specifier tells a C++11 compiler that a variable's * value may be computed at compile time. It should be prefered to just * marking variables as MOZ_CONSTEXPR because if the compiler does not support * constexpr it will fall back to making the variable const, and some compilers * do not accept variables being marked both const and constexpr. */ #ifdef MOZ_HAVE_CXX11_CONSTEXPR # define MOZ_CONSTEXPR constexpr # define MOZ_CONSTEXPR_VAR constexpr #else # define MOZ_CONSTEXPR /* no support */ # define MOZ_CONSTEXPR_VAR const #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. * MOZ_STACK_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the stack, so it is a compile-time error to use it, or * an array of such objects, as a global or static variable, or as the type of * a new expression (unless placement new is being used). If a member of * another class uses this class, or if another class inherits from this * class, then it is considered to be a stack class as well, although this * attribute need not be provided in such cases. * MOZ_NONHEAP_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the stack or in static storage, so it is a compile-time * error to use it, or an array of such objects, as the type of a new * expression (unless placement new is being used). If a member of another * class uses this class, or if another class inherits from this class, then * it is considered to be a non-heap class as well, although this attribute * need not be provided in such cases. */ #ifdef MOZ_CLANG_PLUGIN # define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override"))) # define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class"))) # define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class"))) #else # define MOZ_MUST_OVERRIDE /* nothing */ # define MOZ_STACK_CLASS /* nothing */ # define MOZ_NONHEAP_CLASS /* nothing */ #endif /* MOZ_CLANG_PLUGIN */ /* * MOZ_THIS_IN_INITIALIZER_LIST is used to avoid a warning when we know that * it's safe to use 'this' in an initializer list. */ #ifdef _MSC_VER # define MOZ_THIS_IN_INITIALIZER_LIST() \ __pragma(warning(push)) \ __pragma(warning(disable:4355)) \ this \ __pragma(warning(pop)) #else # define MOZ_THIS_IN_INITIALIZER_LIST() this #endif #endif /* __cplusplus */ #endif /* mozilla_Attributes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/BloomFilter.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Util.h" #include #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() { 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Casting.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Cast operations to supplement the built-in casting operations. */ #ifndef mozilla_Casting_h #define mozilla_Casting_h #include "mozilla/Assertions.h" #include "mozilla/TypeTraits.h" #include namespace mozilla { /** * Return a value of type |To|, containing the underlying bit pattern of |from|. * * |To| and |From| must be types of the same size; be careful of cross-platform * size differences, or this might fail to compile on some but not all * platforms. */ template inline To BitwiseCast(const From from) { static_assert(sizeof(From) == sizeof(To), "To and From must have the same size"); union { From from; To to; } u; u.from = from; return u.to; } namespace detail { enum ToSignedness { ToIsSigned, ToIsUnsigned }; enum FromSignedness { FromIsSigned, FromIsUnsigned }; template::value ? FromIsSigned : FromIsUnsigned, ToSignedness = IsSigned::value ? ToIsSigned : ToIsUnsigned> struct BoundsCheckImpl; // Implicit conversions on operands to binary operations make this all a bit // hard to verify. Attempt to ease the pain below by *only* comparing values // that are obviously the same type (and will undergo no further conversions), // even when it's not strictly necessary, for explicitness. enum UUComparison { FromIsBigger, FromIsNotBigger }; // Unsigned-to-unsigned range check template sizeof(To)) ? FromIsBigger : FromIsNotBigger> struct UnsignedUnsignedCheck; template struct UnsignedUnsignedCheck { public: static bool checkBounds(const From from) { return from <= From(To(-1)); } }; template struct UnsignedUnsignedCheck { public: static bool checkBounds(const From from) { return true; } }; template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { return UnsignedUnsignedCheck::checkBounds(from); } }; // Signed-to-unsigned range check template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { if (from < 0) return false; if (sizeof(To) >= sizeof(From)) return true; return from <= From(To(-1)); } }; // Unsigned-to-signed range check enum USComparison { FromIsSmaller, FromIsNotSmaller }; template struct UnsignedSignedCheck; template struct UnsignedSignedCheck { public: static bool checkBounds(const From from) { return true; } }; template struct UnsignedSignedCheck { public: static bool checkBounds(const From from) { const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); return from <= From(MaxValue); } }; template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { return UnsignedSignedCheck::checkBounds(from); } }; // Signed-to-signed range check template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { if (sizeof(From) <= sizeof(To)) return true; const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); const To MinValue = -MaxValue - To(1); return From(MinValue) <= from && From(from) <= From(MaxValue); } }; template::value && IsIntegral::value> class BoundsChecker; template class BoundsChecker { public: static bool checkBounds(const From from) { return true; } }; template class BoundsChecker { public: static bool checkBounds(const From from) { return BoundsCheckImpl::checkBounds(from); } }; template inline bool IsInBounds(const From from) { return BoundsChecker::checkBounds(from); } } // namespace detail /** * Cast a value of integral type |From| to a value of integral type |To|, * asserting that the cast will be a safe cast per C++ (that is, that |to| is in * the range of values permitted for the type |From|). */ template inline To SafeCast(const From from) { MOZ_ASSERT((detail::IsInBounds(from))); return static_cast(from); } } // namespace mozilla #endif /* mozilla_Casting_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Char16.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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) static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?"); static_assert(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?"); static_assert(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?"); #endif /* mozilla_Char16_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/CheckedInt.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 #include #ifdef MOZ_CHECKEDINT_USE_MFBT # include "mozilla/Assertions.h" #else # include # 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; }; 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 IsModValidImpl; template inline bool IsModValid(T x, T y) { return IsModValidImpl::run(x, y); } /* * Mod is pretty simple. * For now, let's just use the ANSI C definition: * If x or y are negative, the results are implementation defined. * Consider these invalid. * Undefined for y=0. * The result will never exceed either x or y. * * Checking that x>=0 is a warning when T is unsigned. */ template struct IsModValidImpl { static inline bool run(T x, T y) { return y >= 1; } }; template struct IsModValidImpl { static inline bool run(T x, T y) { if (x < 0) return false; return y >= 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) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); } friend struct 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)) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); } template friend class CheckedInt; template CheckedInt toChecked() const { CheckedInt ret(mValue); ret.mIsValid = ret.mIsValid && mIsValid; return ret; } /** Constructs a valid checked integer with initial value 0 */ CheckedInt() : mValue(0), mIsValid(true) { 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); 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, /) MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mod, %) #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) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); 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(/, /=) 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Compiler.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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__) #define MOZ_IS_GCC 1 /* * 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 #else #define MOZ_IS_GCC 0 #endif #endif /* mozilla_Compiler_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Constants.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/DebugOnly.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Decimal.h ================================================ /* * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "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 COPYRIGHT * OWNER OR CONTRIBUTORS 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. */ /** * Imported from: * http://src.chromium.org/viewvc/blink/trunk/Source/core/platform/Decimal.h * Check hg log for the svn rev of the last update from Blink core. */ #ifndef Decimal_h #define Decimal_h #include "mozilla/Assertions.h" #include #include "mozilla/Types.h" #include #ifndef ASSERT #define DEFINED_ASSERT_FOR_DECIMAL_H 1 #define ASSERT MOZ_ASSERT #endif // To use WTF_MAKE_FAST_ALLOCATED we'd need: // http://src.chromium.org/viewvc/blink/trunk/Source/wtf/FastMalloc.h // Since we don't allocate Decimal objects, no need. #define WTF_MAKE_FAST_ALLOCATED \ void ignore_this_dummy_method() MOZ_DELETE namespace WebCore { namespace DecimalPrivate { class SpecialValueHandler; } // This class represents decimal base floating point number. // // FIXME: Once all C++ compiler support decimal type, we should replace this // class to compiler supported one. See below URI for current status of decimal // type for C++: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1977.html class Decimal { WTF_MAKE_FAST_ALLOCATED; public: enum Sign { Positive, Negative, }; // You should not use EncodedData other than unit testing. class EncodedData { // For accessing FormatClass. friend class Decimal; friend class DecimalPrivate::SpecialValueHandler; public: EncodedData(Sign, int exponent, uint64_t coefficient); bool operator==(const EncodedData&) const; bool operator!=(const EncodedData& another) const { return !operator==(another); } uint64_t coefficient() const { return m_coefficient; } int countDigits() const; int exponent() const { return m_exponent; } bool isFinite() const { return !isSpecial(); } bool isInfinity() const { return m_formatClass == ClassInfinity; } bool isNaN() const { return m_formatClass == ClassNaN; } bool isSpecial() const { return m_formatClass == ClassInfinity || m_formatClass == ClassNaN; } bool isZero() const { return m_formatClass == ClassZero; } Sign sign() const { return m_sign; } void setSign(Sign sign) { m_sign = sign; } private: enum FormatClass { ClassInfinity, ClassNormal, ClassNaN, ClassZero, }; EncodedData(Sign, FormatClass); FormatClass formatClass() const { return m_formatClass; } uint64_t m_coefficient; int16_t m_exponent; FormatClass m_formatClass; Sign m_sign; }; MFBT_API Decimal(int32_t = 0); MFBT_API Decimal(Sign, int exponent, uint64_t coefficient); MFBT_API Decimal(const Decimal&); MFBT_API Decimal& operator=(const Decimal&); MFBT_API Decimal& operator+=(const Decimal&); MFBT_API Decimal& operator-=(const Decimal&); MFBT_API Decimal& operator*=(const Decimal&); MFBT_API Decimal& operator/=(const Decimal&); MFBT_API Decimal operator-() const; MFBT_API bool operator==(const Decimal&) const; MFBT_API bool operator!=(const Decimal&) const; MFBT_API bool operator<(const Decimal&) const; MFBT_API bool operator<=(const Decimal&) const; MFBT_API bool operator>(const Decimal&) const; MFBT_API bool operator>=(const Decimal&) const; MFBT_API Decimal operator+(const Decimal&) const; MFBT_API Decimal operator-(const Decimal&) const; MFBT_API Decimal operator*(const Decimal&) const; MFBT_API Decimal operator/(const Decimal&) const; int exponent() const { ASSERT(isFinite()); return m_data.exponent(); } bool isFinite() const { return m_data.isFinite(); } bool isInfinity() const { return m_data.isInfinity(); } bool isNaN() const { return m_data.isNaN(); } bool isNegative() const { return sign() == Negative; } bool isPositive() const { return sign() == Positive; } bool isSpecial() const { return m_data.isSpecial(); } bool isZero() const { return m_data.isZero(); } MFBT_API Decimal abs() const; MFBT_API Decimal ceiling() const; MFBT_API Decimal floor() const; MFBT_API Decimal remainder(const Decimal&) const; MFBT_API Decimal round() const; MFBT_API double toDouble() const; // Note: toString method supports infinity and nan but fromString not. MFBT_API std::string toString() const; MFBT_API bool toString(char* strBuf, size_t bufLength) const; static MFBT_API Decimal fromDouble(double); // fromString supports following syntax EBNF: // number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)? // | sign? '.' digit+ (exponent-marker sign? digit+)? // sign ::= '+' | '-' // exponent-marker ::= 'e' | 'E' // digit ::= '0' | '1' | ... | '9' // Note: fromString doesn't support "infinity" and "nan". static MFBT_API Decimal fromString(const std::string& aValue); static MFBT_API Decimal infinity(Sign); static MFBT_API Decimal nan(); static MFBT_API Decimal zero(Sign); // You should not use below methods. We expose them for unit testing. MFBT_API explicit Decimal(const EncodedData&); const EncodedData& value() const { return m_data; } private: struct AlignedOperands { uint64_t lhsCoefficient; uint64_t rhsCoefficient; int exponent; }; MFBT_API Decimal(double); MFBT_API Decimal compareTo(const Decimal&) const; static MFBT_API AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs); static inline Sign invertSign(Sign sign) { return sign == Negative ? Positive : Negative; } Sign sign() const { return m_data.sign(); } EncodedData m_data; }; } // namespace WebCore namespace mozilla { typedef WebCore::Decimal Decimal; } #undef WTF_MAKE_FAST_ALLOCATED #ifdef DEFINED_ASSERT_FOR_DECIMAL_H #undef DEFINED_ASSERT_FOR_DECIMAL_H #undef ASSERT #endif #endif // Decimal_h ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Endian.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Functions for reading and writing integers in various endiannesses. */ /* * The classes LittleEndian and BigEndian expose static methods for * reading and writing 16-, 32-, and 64-bit signed and unsigned integers * in their respective endianness. The naming scheme is: * * {Little,Big}Endian::{read,write}{Uint,Int} * * For instance, LittleEndian::readInt32 will read a 32-bit signed * integer from memory in little endian format. Similarly, * BigEndian::writeUint16 will write a 16-bit unsigned integer to memory * in big-endian format. * * The class NativeEndian exposes methods for conversion of existing * data to and from the native endianness. These methods are intended * for cases where data needs to be transferred, serialized, etc. * swap{To,From}{Little,Big}Endian byteswap a single value if necessary. * Bulk conversion functions are also provided which optimize the * no-conversion-needed case: * * - copyAndSwap{To,From}{Little,Big}Endian; * - swap{To,From}{Little,Big}EndianInPlace. * * The *From* variants are intended to be used for reading data and the * *To* variants for writing data. * * Methods on NativeEndian work with integer data of any type. * Floating-point data is not supported. * * For clarity in networking code, "Network" may be used as a synonym * for "Big" in any of the above methods or class names. * * As an example, reading a file format header whose fields are stored * in big-endian format might look like: * * class ExampleHeader * { * private: * uint32_t magic; * uint32_t length; * uint32_t totalRecords; * uint64_t checksum; * * public: * ExampleHeader(const void* data) { * const uint8_t* ptr = static_cast(data); * magic = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * length = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * totalRecords = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * checksum = BigEndian::readUint64(ptr); * } * ... * }; */ #ifndef mozilla_Endian_h #define mozilla_Endian_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/DebugOnly.h" #include "mozilla/TypeTraits.h" #include #include #if defined(_MSC_VER) && _MSC_VER >= 1300 # include # pragma intrinsic(_byteswap_ushort) # pragma intrinsic(_byteswap_ulong) # pragma intrinsic(_byteswap_uint64) #endif #if defined(_WIN64) # if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) # define MOZ_LITTLE_ENDIAN 1 # else # error "CPU type is unknown" # endif #elif defined(_WIN32) # if defined(_M_IX86) # define MOZ_LITTLE_ENDIAN 1 # else # error "CPU type is unknown" # endif #elif defined(__APPLE__) # if __LITTLE_ENDIAN__ # define MOZ_LITTLE_ENDIAN 1 # elif __BIG_ENDIAN__ # define MOZ_BIG_ENDIAN 1 # endif #elif defined(__GNUC__) && \ defined(__BYTE_ORDER__) && \ defined(__ORDER_LITTLE_ENDIAN__) && \ defined(__ORDER_BIG_ENDIAN__) /* * Some versions of GCC provide architecture-independent macros for * this. Yes, there are more than two values for __BYTE_ORDER__. */ # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define MOZ_LITTLE_ENDIAN 1 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define MOZ_BIG_ENDIAN 1 # else # error "Can't handle mixed-endian architectures" # endif /* * We can't include useful headers like or * here because they're not present on all platforms. Instead we have * this big conditional that ideally will catch all the interesting * cases. */ #elif defined(__sparc) || defined(__sparc__) || \ defined(_POWER) || defined(__powerpc__) || \ defined(__ppc__) || defined(__hppa) || \ defined(_MIPSEB) || defined(__ARMEB__) || \ defined(__s390__) || \ (defined(__sh__) && defined(__LITTLE_ENDIAN__)) || \ (defined(__ia64) && defined(__BIG_ENDIAN__)) # define MOZ_BIG_ENDIAN 1 #elif defined(__i386) || defined(__i386__) || \ defined(__x86_64) || defined(__x86_64__) || \ defined(_MIPSEL) || defined(__ARMEL__) || \ defined(__alpha__) || \ (defined(__sh__) && defined(__BIG_ENDIAN__)) || \ (defined(__ia64) && !defined(__BIG_ENDIAN__)) # define MOZ_LITTLE_ENDIAN 1 #endif #if MOZ_BIG_ENDIAN # define MOZ_LITTLE_ENDIAN 0 #elif MOZ_LITTLE_ENDIAN # define MOZ_BIG_ENDIAN 0 #else # error "Cannot determine endianness" #endif #if defined(__clang__) # if __has_builtin(__builtin_bswap16) # define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 # endif #elif defined(__GNUC__) # if MOZ_GCC_VERSION_AT_LEAST(4, 8, 0) # define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 # endif #elif defined(_MSC_VER) # define MOZ_HAVE_BUILTIN_BYTESWAP16 _byteswap_ushort #endif namespace mozilla { namespace detail { /* * We need wrappers here because free functions with default template * arguments and/or partial specialization of function templates are not * supported by all the compilers we use. */ template struct Swapper; template struct Swapper { static T swap(T value) { #if defined(MOZ_HAVE_BUILTIN_BYTESWAP16) return MOZ_HAVE_BUILTIN_BYTESWAP16(value); #else return T(((value & 0x00ff) << 8) | ((value & 0xff00) >> 8)); #endif } }; template struct Swapper { static T swap(T value) { #if defined(__clang__) || defined(__GNUC__) return T(__builtin_bswap32(value)); #elif defined(_MSC_VER) return T(_byteswap_ulong(value)); #else return T(((value & 0x000000ffU) << 24) | ((value & 0x0000ff00U) << 8) | ((value & 0x00ff0000U) >> 8) | ((value & 0xff000000U) >> 24)); #endif } }; template struct Swapper { static inline T swap(T value) { #if defined(__clang__) || defined(__GNUC__) return T(__builtin_bswap64(value)); #elif defined(_MSC_VER) return T(_byteswap_uint64(value)); #else return T(((value & 0x00000000000000ffULL) << 56) | ((value & 0x000000000000ff00ULL) << 40) | ((value & 0x0000000000ff0000ULL) << 24) | ((value & 0x00000000ff000000ULL) << 8) | ((value & 0x000000ff00000000ULL) >> 8) | ((value & 0x0000ff0000000000ULL) >> 24) | ((value & 0x00ff000000000000ULL) >> 40) | ((value & 0xff00000000000000ULL) >> 56)); #endif } }; enum Endianness { Little, Big }; #if MOZ_BIG_ENDIAN # define MOZ_NATIVE_ENDIANNESS detail::Big #else # define MOZ_NATIVE_ENDIANNESS detail::Little #endif class EndianUtils { /** * Assert that the memory regions [dest, dest+count) and [src, src+count] * do not overlap. count is given in bytes. */ static void assertNoOverlap(const void* dest, const void* src, size_t count) { DebugOnly byteDestPtr = static_cast(dest); DebugOnly byteSrcPtr = static_cast(src); MOZ_ASSERT((byteDestPtr < byteSrcPtr && byteDestPtr + count <= byteSrcPtr) || (byteSrcPtr < byteDestPtr && byteSrcPtr + count <= byteDestPtr)); } template static void assertAligned(T* ptr) { MOZ_ASSERT((uintptr_t(ptr) % sizeof(T)) == 0, "Unaligned pointer!"); } protected: /** * Return |value| converted from SourceEndian encoding to DestEndian * encoding. */ template static inline T maybeSwap(T value) { if (SourceEndian == DestEndian) return value; return Swapper::swap(value); } /** * Convert |count| elements at |ptr| from SourceEndian encoding to * DestEndian encoding. */ template static inline void maybeSwapInPlace(T* ptr, size_t count) { assertAligned(ptr); if (SourceEndian == DestEndian) return; for (size_t i = 0; i < count; i++) ptr[i] = Swapper::swap(ptr[i]); } /** * Write |count| elements to the unaligned address |dest| in DestEndian * format, using elements found at |src| in SourceEndian format. */ template static void copyAndSwapTo(void* dest, const T* src, size_t count) { assertNoOverlap(dest, src, count * sizeof(T)); assertAligned(src); if (SourceEndian == DestEndian) { memcpy(dest, src, count * sizeof(T)); return; } uint8_t* byteDestPtr = static_cast(dest); for (size_t i = 0; i < count; ++i) { union { T val; uint8_t buffer[sizeof(T)]; } u; u.val = maybeSwap(src[i]); memcpy(byteDestPtr, u.buffer, sizeof(T)); byteDestPtr += sizeof(T); } } /** * Write |count| elements to |dest| in DestEndian format, using elements * found at the unaligned address |src| in SourceEndian format. */ template static void copyAndSwapFrom(T* dest, const void* src, size_t count) { assertNoOverlap(dest, src, count * sizeof(T)); assertAligned(dest); if (SourceEndian == DestEndian) { memcpy(dest, src, count * sizeof(T)); return; } const uint8_t* byteSrcPtr = static_cast(src); for (size_t i = 0; i < count; ++i) { union { T val; uint8_t buffer[sizeof(T)]; } u; memcpy(u.buffer, byteSrcPtr, sizeof(T)); dest[i] = maybeSwap(u.val); byteSrcPtr += sizeof(T); } } }; template class Endian : private EndianUtils { protected: /** Read a uint16_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint16_t readUint16(const void* p) { return read(p); } /** Read a uint32_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint32_t readUint32(const void* p) { return read(p); } /** Read a uint64_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint64_t readUint64(const void* p) { return read(p); } /** Read an int16_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int16_t readInt16(const void* p) { return read(p); } /** Read an int32_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int32_t readInt32(const void* p) { return read(p); } /** Read an int64_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int64_t readInt64(const void* p) { return read(p); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint16(void* p, uint16_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint32(void* p, uint32_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint64(void* p, uint64_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt16(void* p, int16_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt32(void* p, int32_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt64(void* p, int64_t val) { write(p, val); } /* * Converts a value of type T to little-endian format. * * This function is intended for cases where you have data in your * native-endian format and you need it to appear in little-endian * format for transmission. */ template MOZ_WARN_UNUSED_RESULT static T swapToLittleEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to little-endian format if ThisEndian is Big. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapToLittleEndian(void* dest, const T* src, size_t count) { copyAndSwapTo(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapToLittleEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Converts a value of type T to big-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapToBigEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to big-endian format if ThisEndian is Little. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapToBigEndian(void* dest, const T* src, size_t count) { copyAndSwapTo(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapToBigEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Synonyms for the big-endian functions, for better readability * in network code. */ template MOZ_WARN_UNUSED_RESULT static T swapToNetworkOrder(T value) { return swapToBigEndian(value); } template static void copyAndSwapToNetworkOrder(void* dest, const T* src, size_t count) { copyAndSwapToBigEndian(dest, src, count); } template static void swapToNetworkOrderInPlace(T* p, size_t count) { swapToBigEndianInPlace(p, count); } /* * Converts a value of type T from little-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapFromLittleEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to little-endian format if ThisEndian is Big. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapFromLittleEndian(T* dest, const void* src, size_t count) { copyAndSwapFrom(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapFromLittleEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Converts a value of type T from big-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapFromBigEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to big-endian format if ThisEndian is Little. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapFromBigEndian(T* dest, const void* src, size_t count) { copyAndSwapFrom(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapFromBigEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Synonyms for the big-endian functions, for better readability * in network code. */ template MOZ_WARN_UNUSED_RESULT static T swapFromNetworkOrder(T value) { return swapFromBigEndian(value); } template static void copyAndSwapFromNetworkOrder(T* dest, const void* src, size_t count) { copyAndSwapFromBigEndian(dest, src, count); } template static void swapFromNetworkOrderInPlace(T* p, size_t count) { swapFromBigEndianInPlace(p, count); } private: /** * Read a value of type T, encoded in endianness ThisEndian from |p|. * Return that value encoded in native endianness. */ template static T read(const void* p) { union { T val; uint8_t buffer[sizeof(T)]; } u; memcpy(u.buffer, p, sizeof(T)); return maybeSwap(u.val); } /** * Write a value of type T, in native endianness, to |p|, in ThisEndian * endianness. */ template static void write(void* p, T value) { T tmp = maybeSwap(value); memcpy(p, &tmp, sizeof(T)); } Endian() MOZ_DELETE; Endian(const Endian& other) MOZ_DELETE; void operator=(const Endian& other) MOZ_DELETE; }; template class EndianReadWrite : public Endian { private: typedef Endian super; public: using super::readUint16; using super::readUint32; using super::readUint64; using super::readInt16; using super::readInt32; using super::readInt64; using super::writeUint16; using super::writeUint32; using super::writeUint64; using super::writeInt16; using super::writeInt32; using super::writeInt64; }; } /* namespace detail */ class LittleEndian MOZ_FINAL : public detail::EndianReadWrite {}; class BigEndian MOZ_FINAL : public detail::EndianReadWrite {}; typedef BigEndian NetworkEndian; class NativeEndian MOZ_FINAL : public detail::Endian { private: typedef detail::Endian super; public: /* * These functions are intended for cases where you have data in your * native-endian format and you need the data to appear in the appropriate * endianness for transmission, serialization, etc. */ using super::swapToLittleEndian; using super::copyAndSwapToLittleEndian; using super::swapToLittleEndianInPlace; using super::swapToBigEndian; using super::copyAndSwapToBigEndian; using super::swapToBigEndianInPlace; using super::swapToNetworkOrder; using super::copyAndSwapToNetworkOrder; using super::swapToNetworkOrderInPlace; /* * These functions are intended for cases where you have data in the * given endianness (e.g. reading from disk or a file-format) and you * need the data to appear in native-endian format for processing. */ using super::swapFromLittleEndian; using super::copyAndSwapFromLittleEndian; using super::swapFromLittleEndianInPlace; using super::swapFromBigEndian; using super::copyAndSwapFromBigEndian; using super::swapFromBigEndianInPlace; using super::swapFromNetworkOrder; using super::copyAndSwapFromNetworkOrder; using super::swapFromNetworkOrderInPlace; }; #undef MOZ_NATIVE_ENDIANNESS } /* namespace mozilla */ #endif /* mozilla_Endian_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/EnumSet.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 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_*/ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/FloatingPoint.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Casting.h" #include namespace mozilla { /* * 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. */ /* * 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. */ static_assert(sizeof(double) == sizeof(uint64_t), "double must be 64 bits"); const unsigned DoubleExponentBias = 1023; const unsigned DoubleExponentShift = 52; const uint64_t DoubleSignBit = 0x8000000000000000ULL; const uint64_t DoubleExponentBits = 0x7ff0000000000000ULL; const uint64_t DoubleSignificandBits = 0x000fffffffffffffULL; static_assert((DoubleSignBit & DoubleExponentBits) == 0, "sign bit doesn't overlap exponent bits"); static_assert((DoubleSignBit & DoubleSignificandBits) == 0, "sign bit doesn't overlap significand bits"); static_assert((DoubleExponentBits & DoubleSignificandBits) == 0, "exponent bits don't overlap significand bits"); static_assert((DoubleSignBit | DoubleExponentBits | DoubleSignificandBits) == ~uint64_t(0), "all bits accounted for"); /** Determines whether a double is NaN. */ static MOZ_ALWAYS_INLINE bool IsNaN(double d) { /* * A double is NaN if all exponent bits are 1 and the significand contains at * least one non-zero bit. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleExponentBits) == DoubleExponentBits && (bits & DoubleSignificandBits) != 0; } /** Determines whether a double is +Infinity or -Infinity. */ static MOZ_ALWAYS_INLINE bool IsInfinite(double d) { /* Infinities have all exponent bits set to 1 and an all-0 significand. */ uint64_t bits = BitwiseCast(d); return (bits & ~DoubleSignBit) == DoubleExponentBits; } /** Determines whether a double is not NaN or infinite. */ static MOZ_ALWAYS_INLINE bool IsFinite(double d) { /* * NaN and Infinities are the only non-finite doubles, and both have all * exponent bits set to 1. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleExponentBits) != DoubleExponentBits; } /** * Determines whether a double is negative. It is an error to call this method * on a double which is NaN. */ static MOZ_ALWAYS_INLINE bool IsNegative(double d) { MOZ_ASSERT(!IsNaN(d), "NaN does not have a sign"); /* The sign bit is set if the double is negative. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleSignBit) != 0; } /** Determines whether a double represents -0. */ static MOZ_ALWAYS_INLINE bool IsNegativeZero(double d) { /* Only the sign bit is set if the double is -0. */ uint64_t bits = BitwiseCast(d); return bits == DoubleSignBit; } /** Returns the exponent portion of the double. */ static MOZ_ALWAYS_INLINE int_fast16_t ExponentComponent(double d) { /* * The exponent component of a double is an unsigned number, biased from its * actual value. Subtract the bias to retrieve the actual exponent. */ uint64_t bits = BitwiseCast(d); return int_fast16_t((bits & DoubleExponentBits) >> DoubleExponentShift) - int_fast16_t(DoubleExponentBias); } /** Returns +Infinity. */ static MOZ_ALWAYS_INLINE double PositiveInfinity() { /* * Positive infinity has all exponent bits set, sign bit set to 0, and no * significand. */ return BitwiseCast(DoubleExponentBits); } /** Returns -Infinity. */ static MOZ_ALWAYS_INLINE double NegativeInfinity() { /* * Negative infinity has all exponent bits set, sign bit set to 1, and no * significand. */ return BitwiseCast(DoubleSignBit | DoubleExponentBits); } /** Constructs a NaN value with the specified sign bit and significand bits. */ static MOZ_ALWAYS_INLINE double SpecificNaN(int signbit, uint64_t significand) { MOZ_ASSERT(signbit == 0 || signbit == 1); MOZ_ASSERT((significand & ~DoubleSignificandBits) == 0); MOZ_ASSERT(significand & DoubleSignificandBits); double d = BitwiseCast((signbit ? DoubleSignBit : 0) | DoubleExponentBits | significand); MOZ_ASSERT(IsNaN(d)); return d; } /** Computes the smallest non-zero positive double value. */ static MOZ_ALWAYS_INLINE double MinDoubleValue() { return BitwiseCast(uint64_t(1)); } static MOZ_ALWAYS_INLINE bool DoubleIsInt32(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 !IsNegativeZero(d) && d == (*i = int32_t(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 UnspecifiedNaN() { return SpecificNaN(0, 0xfffffffffffffULL); } /** * Compare two doubles for equality, *without* equating -0 to +0, and equating * any NaN value to any other NaN value. (The normal equality operators equate * -0 with +0, and they equate NaN to no other value.) */ static inline bool DoublesAreIdentical(double d1, double d2) { if (IsNaN(d1)) return IsNaN(d2); return BitwiseCast(d1) == BitwiseCast(d2); } } /* namespace mozilla */ #endif /* mozilla_FloatingPoint_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/GuardObjects.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/NullPtr.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(nullptr) { } ~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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/HashFunctions.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 nsHashKeys.h. */ #ifndef mozilla_HashFunctions_h #define mozilla_HashFunctions_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Types.h" #include #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. */ 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Likely.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/LinkedList.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 != nullptr; o = o->getNext()) * o->observe(topic); * } * }; * */ #ifndef mozilla_LinkedList_h #define mozilla_LinkedList_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/NullPtr.h" #ifdef __cplusplus namespace mozilla { template class LinkedList; template class LinkedListElement { /* * It's convenient that we return nullptr 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; public: LinkedListElement() : next(MOZ_THIS_IN_INITIALIZER_LIST()), prev(MOZ_THIS_IN_INITIALIZER_LIST()), isSentinel(false) { } ~LinkedListElement() { if (!isSentinel && isInList()) remove(); } /* * Get the next element in the list, or nullptr 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 nullptr 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(MOZ_THIS_IN_INITIALIZER_LIST()), prev(MOZ_THIS_IN_INITIALIZER_LIST()), isSentinel(nodeKind == NODE_KIND_SENTINEL) { } /* * Return |this| cast to T* if we're a normal node, or return nullptr if * we're a sentinel node. */ T* asT() { if (isSentinel) return nullptr; return static_cast(this); } const T* asT() const { if (isSentinel) return nullptr; 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 nullptr 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 nullptr 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 nullptr. */ 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 nullptr. */ 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_CRASH("element wasn't found in this list!"); #endif } LinkedList& operator=(const LinkedList& other) MOZ_DELETE; LinkedList(const LinkedList& other) MOZ_DELETE; }; } /* namespace mozilla */ #endif /* __cplusplus */ #endif /* mozilla_LinkedList_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/MathAlgorithms.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/TypeTraits.h" #include #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 #if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) # define MOZ_BITSCAN_WINDOWS extern "C" { unsigned char _BitScanForward(unsigned long* Index, unsigned long mask); unsigned char _BitScanReverse(unsigned long* Index, unsigned long mask); # pragma intrinsic(_BitScanForward, _BitScanReverse) # if defined(_M_AMD64) || defined(_M_X64) # define MOZ_BITSCAN_WINDOWS64 unsigned char _BitScanForward64(unsigned long* index, unsigned __int64 mask); unsigned char _BitScanReverse64(unsigned long* index, unsigned __int64 mask); # pragma intrinsic(_BitScanForward64, _BitScanReverse64) # endif } // extern "C" #endif namespace mozilla { namespace detail { #if defined(MOZ_BITSCAN_WINDOWS) inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { unsigned long index; _BitScanReverse(&index, static_cast(u)); return uint_fast8_t(31 - index); } inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { unsigned long index; _BitScanForward(&index, static_cast(u)); return uint_fast8_t(index); } inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { # if defined(MOZ_BITSCAN_WINDOWS64) unsigned long index; _BitScanReverse64(&index, static_cast(u)); return uint_fast8_t(63 - index); # else uint32_t hi = uint32_t(u >> 32); if (hi != 0) return CountLeadingZeroes32(hi); return 32 + CountLeadingZeroes32(uint32_t(u)); # endif } inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { # if defined(MOZ_BITSCAN_WINDOWS64) unsigned long index; _BitScanForward64(&index, static_cast(u)); return uint_fast8_t(index); # else uint32_t lo = uint32_t(u); if (lo != 0) return CountTrailingZeroes32(lo); return 32 + CountTrailingZeroes32(uint32_t(u >> 32)); # endif } # ifdef MOZ_HAVE_BITSCAN64 # undef MOZ_HAVE_BITSCAN64 # endif #elif defined(__clang__) || defined(__GNUC__) # if defined(__clang__) # if !__has_builtin(__builtin_ctz) || !__has_builtin(__builtin_clz) # error "A clang providing __builtin_c[lt]z is required to build" # endif # else // gcc has had __builtin_clz and friends since 3.4: no need to check. # endif inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { return __builtin_clz(u); } inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { return __builtin_ctz(u); } inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { return __builtin_clzll(u); } inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { return __builtin_ctzll(u); } #else # error "Implement these!" inline uint_fast8_t CountLeadingZeroes32(uint32_t u) MOZ_DELETE; inline uint_fast8_t CountTrailingZeroes32(uint32_t u) MOZ_DELETE; inline uint_fast8_t CountLeadingZeroes64(uint64_t u) MOZ_DELETE; inline uint_fast8_t CountTrailingZeroes64(uint64_t u) MOZ_DELETE; #endif } // namespace detail /** * Compute the number of high-order zero bits in the NON-ZERO number |u|. That * is, looking at the bitwise representation of the number, with the highest- * valued bits at the start, return the number of zeroes before the first one * is observed. * * CountLeadingZeroes32(0xF0FF1000) is 0; * CountLeadingZeroes32(0x7F8F0001) is 1; * CountLeadingZeroes32(0x3FFF0100) is 2; * CountLeadingZeroes32(0x1FF50010) is 3; and so on. */ inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { MOZ_ASSERT(u != 0); return detail::CountLeadingZeroes32(u); } /** * Compute the number of low-order zero bits in the NON-ZERO number |u|. That * is, looking at the bitwise representation of the number, with the lowest- * valued bits at the start, return the number of zeroes before the first one * is observed. * * CountTrailingZeroes32(0x0100FFFF) is 0; * CountTrailingZeroes32(0x7000FFFE) is 1; * CountTrailingZeroes32(0x0080FFFC) is 2; * CountTrailingZeroes32(0x0080FFF8) is 3; and so on. */ inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { MOZ_ASSERT(u != 0); return detail::CountTrailingZeroes32(u); } /** Analogous to CountLeadingZeroes32, but for 64-bit numbers. */ inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { MOZ_ASSERT(u != 0); return detail::CountLeadingZeroes64(u); } /** Analogous to CountTrailingZeroes32, but for 64-bit numbers. */ inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { MOZ_ASSERT(u != 0); return detail::CountTrailingZeroes64(u); } namespace detail { template class CeilingLog2; template class CeilingLog2 { public: static uint_fast8_t compute(const T t) { // Check for <= 1 to avoid the == 0 undefined case. return t <= 1 ? 0 : 32 - CountLeadingZeroes32(t - 1); } }; template class CeilingLog2 { public: static uint_fast8_t compute(const T t) { // Check for <= 1 to avoid the == 0 undefined case. return t <= 1 ? 0 : 64 - CountLeadingZeroes64(t - 1); } }; } // namespace detail /** * Compute the log of the least power of 2 greater than or equal to |t|. * * CeilingLog2(0..1) is 0; * CeilingLog2(2) is 1; * CeilingLog2(3..4) is 2; * CeilingLog2(5..8) is 3; * CeilingLog2(9..16) is 4; and so on. */ template inline uint_fast8_t CeilingLog2(const T t) { return detail::CeilingLog2::compute(t); } /** A CeilingLog2 variant that accepts only size_t. */ inline uint_fast8_t CeilingLog2Size(size_t n) { return CeilingLog2(n); } namespace detail { template class FloorLog2; template class FloorLog2 { public: static uint_fast8_t compute(const T t) { return 31 - CountLeadingZeroes32(t | 1); } }; template class FloorLog2 { public: static uint_fast8_t compute(const T t) { return 63 - CountLeadingZeroes64(t | 1); } }; } // namespace detail /** * Compute the log of the greatest power of 2 less than or equal to |t|. * * FloorLog2(0..1) is 0; * FloorLog2(2..3) is 1; * FloorLog2(4..7) is 2; * FloorLog2(8..15) is 3; and so on. */ template inline uint_fast8_t FloorLog2(const T t) { return detail::FloorLog2::compute(t); } /** A FloorLog2 variant that accepts only size_t. */ inline uint_fast8_t FloorLog2Size(size_t n) { return FloorLog2(n); } /* * Compute the smallest power of 2 greater than or equal to |x|. |x| must not * be so great that the computed value would overflow |size_t|. */ inline size_t RoundUpPow2(size_t x) { MOZ_ASSERT(x <= (size_t(1) << (sizeof(size_t) * CHAR_BIT - 1)), "can't round up -- will overflow!"); return size_t(1) << CeilingLog2(x); } } /* namespace mozilla */ #endif /* mozilla_MathAlgorithms_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/MemoryChecking.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/MemoryReporting.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Memory reporting infrastructure. */ #ifndef mozilla_MemoryReporting_h #define mozilla_MemoryReporting_h #include #ifdef __cplusplus namespace mozilla { /* * This is for functions that are like malloc_usable_size. Such functions are * used for measuring the size of data structures. */ typedef size_t (*MallocSizeOf)(const void* p); } /* namespace mozilla */ #endif /* __cplusplus */ typedef size_t (*MozMallocSizeOf)(const void* p); #endif /* mozilla_MemoryReporting_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Move.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* C++11-style, but C++98-usable, "move references" implementation. */ #ifndef mozilla_Move_h #define mozilla_Move_h namespace mozilla { /* * "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 (although 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 a MoveRef * referring to the same value; that's 1). A 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 a 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 mozilla 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(Move(c->x)), y(Move(c->y)) { } * * than the equivalent: * * C(MoveRef c) { new(&x) X(Move(c->x)); new(&y) Y(Move(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 { T* pointer; public: explicit MoveRef(T& t) : pointer(&t) { } T& operator*() const { return *pointer; } T* operator->() const { return pointer; } operator T& () const { return *pointer; } }; template inline MoveRef Move(T& t) { return MoveRef(t); } template inline MoveRef Move(const T& t) { // With some versions of gcc, for a class C, there's an (incorrect) ambiguity // between the C(const C&) constructor and the default C(C&&) C++11 move // constructor, when the constructor is called with a const C& argument. // // This ambiguity manifests with the Move implementation above when Move is // passed const U& for some class U. Calling Move(const U&) returns a // MoveRef, which is then commonly passed to the U constructor, // triggering an implicit conversion to const U&. gcc doesn't know whether to // call U(const U&) or U(U&&), so it wrongly reports a compile error. // // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50442 has since been fixed, so // this is no longer an issue for up-to-date compilers. But there's no harm // in keeping it around for older compilers, so we might as well. See also // bug 686280. return MoveRef(const_cast(t)); } /** Swap |t| and |u| using move-construction if possible. */ template inline void Swap(T& t, T& u) { T tmp(Move(t)); t = Move(u); u = Move(tmp); } } // namespace mozilla #endif /* mozilla_Move_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/NullPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/PodOperations.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * Operations for zeroing POD types, arrays, and so on. * * These operations are preferable to memset, memcmp, and the like because they * don't require remembering to multiply by sizeof(T), array lengths, and so on * everywhere. */ #ifndef mozilla_PodOperations_h #define mozilla_PodOperations_h #include "mozilla/Attributes.h" #include "mozilla/Util.h" #include namespace mozilla { /** Set the contents of |t| to 0. */ template static void PodZero(T* t) { memset(t, 0, sizeof(T)); } /** Set the contents of |nelem| elements starting at |t| to 0. */ template 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 (&t)[N]) MOZ_DELETE; template static void PodZero(T (&t)[N], size_t nelem) MOZ_DELETE; /** Set the contents of the array |t| to zero. */ template static void PodArrayZero(T (&t)[N]) { memset(t, 0, N * sizeof(T)); } /** * Assign |*src| to |*dst|. The locations must not be the same and must not * overlap. */ template static void PodAssign(T* dst, const T* src) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= 1); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= 1); memcpy(reinterpret_cast(dst), reinterpret_cast(src), sizeof(T)); } /** * Copy |nelem| T elements from |src| to |dst|. The two memory ranges must not * overlap! */ template MOZ_ALWAYS_INLINE static void PodCopy(T* dst, const T* src, size_t nelem) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= nelem); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= 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 MOZ_ALWAYS_INLINE static void PodCopy(volatile T* dst, const volatile T* src, size_t nelem) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= nelem); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= nelem); /* * Volatile |dst| requires extra work, because it's undefined behavior to * modify volatile objects using the mem* functions. Just write out the * loops manually, using operator= rather than memcpy for the same reason, * and let the compiler optimize to the extent it can. */ for (const volatile T* srcend = src + nelem; src < srcend; src++, dst++) *dst = *src; } /* * Copy the contents of the array |src| into the array |dst|, both of size N. * The arrays must not overlap! */ template static void PodArrayCopy(T (&dst)[N], const T (&src)[N]) { PodCopy(dst, src, N); } /** * Determine whether the |len| elements at |one| are memory-identical to the * |len| elements at |two|. */ template MOZ_ALWAYS_INLINE static bool PodEqual(const T* one, const T* two, size_t len) { if (len < 128) { const T* p1end = one + len; const T* p1 = one; const T* p2 = two; for (; p1 < p1end; p1++, p2++) { if (*p1 != *p2) return false; } return true; } return !memcmp(one, two, len * sizeof(T)); } } // namespace mozilla #endif /* mozilla_PodOperations_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Poison.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 poison value that can be used to fill a memory space with * an address that leads to a safe crash when dereferenced. */ #ifndef mozilla_Poison_h #define mozilla_Poison_h #include "mozilla/Assertions.h" #include "mozilla/Types.h" #include MOZ_BEGIN_EXTERN_C extern MFBT_DATA uintptr_t gMozillaPoisonValue; /** * @return the poison value. */ inline uintptr_t mozPoisonValue() { return gMozillaPoisonValue; } /** * Overwrite the memory block of aSize bytes at aPtr with the poison value. * aPtr MUST be aligned at a sizeof(uintptr_t) boundary. * Only an even number of sizeof(uintptr_t) bytes are overwritten, the last * few bytes (if any) is not overwritten. */ inline void mozWritePoison(void* aPtr, size_t aSize) { const uintptr_t POISON = mozPoisonValue(); char* p = (char*)aPtr; char* limit = p + aSize; MOZ_ASSERT((uintptr_t)aPtr % sizeof(uintptr_t) == 0, "bad alignment"); MOZ_ASSERT(aSize >= sizeof(uintptr_t), "poisoning this object has no effect"); for (; p < limit; p += sizeof(uintptr_t)) { *((uintptr_t*)p) = POISON; } } /** * Initialize the poison value. * This should only be called once. */ extern MFBT_API void mozPoisonValueInit(); /* Values annotated by CrashReporter */ extern MFBT_DATA uintptr_t gMozillaPoisonBase; extern MFBT_DATA uintptr_t gMozillaPoisonSize; MOZ_END_EXTERN_C #endif /* mozilla_Poison_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Range.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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]; } const T& operator[](size_t offset) const { return mStart[offset]; } operator ConvertibleToBool() const { return mStart ? &Range::nonNull : 0; } }; } // namespace mozilla #endif /* mozilla_Range_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/RangedPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/NullPtr.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, nullptr, 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/ReentrancyGuard.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Small helper class for asserting uses of a class are non-reentrant. */ #ifndef mozilla_ReentrancyGuard_h #define mozilla_ReentrancyGuard_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/GuardObjects.h" namespace mozilla { /* Useful for implementing containers that assert non-reentrancy */ class ReentrancyGuard { MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER #ifdef DEBUG bool& entered; #endif public: template #ifdef DEBUG ReentrancyGuard(T& obj MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : entered(obj.entered) #else ReentrancyGuard(T& MOZ_GUARD_OBJECT_NOTIFIER_PARAM) #endif { MOZ_GUARD_OBJECT_NOTIFIER_INIT; #ifdef DEBUG MOZ_ASSERT(!entered); entered = true; #endif } ~ReentrancyGuard() { #ifdef DEBUG entered = false; #endif } private: ReentrancyGuard(const ReentrancyGuard&) MOZ_DELETE; void operator=(const ReentrancyGuard&) MOZ_DELETE; }; } // namespace mozilla #endif /* mozilla_ReentrancyGuard_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/RefPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Atomics.h" #include "mozilla/Attributes.h" #include "mozilla/TypeTraits.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). */ namespace detail { #ifdef DEBUG static const int DEAD = 0xffffdead; #endif // This is used WeakPtr.h as well as this file. enum RefCountAtomicity { AtomicRefCount, NonAtomicRefCount }; 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: typename Conditional, int>::Type refCnt; }; } template class RefCounted : public detail::RefCounted { public: ~RefCounted() { static_assert(IsBaseOf::value, "T must derive from RefCounted"); } }; /** * AtomicRefCounted is like RefCounted, with an atomically updated * reference counter. */ template class AtomicRefCounted : public detail::RefCounted { public: ~AtomicRefCounted() { static_assert(IsBaseOf::value, "T must derive from AtomicRefCounted"); } }; /** * 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 #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 #endif /* mozilla_RefPtr_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/SHA1.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Types.h" #include #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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Scoped.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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" #include "mozilla/NullPtr.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 nullptr; } 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 nullptr; } const static void release(type value) { if (value) TypeSpecificDelete(value); } }; SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits) } /* namespace mozilla */ #endif /* mozilla_Scoped_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/SplayTree.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/TemplateLib.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * Reusable template meta-functions on types and compile-time values. Meta- * functions are placed inside the 'tl' namespace to avoid conflict with non- * meta functions of the same name (e.g., mozilla::tl::FloorLog2 vs. * mozilla::FloorLog2). * * When constexpr support becomes universal, we should probably use that instead * of some of these templates, for simplicity. */ #ifndef mozilla_TemplateLib_h #define mozilla_TemplateLib_h #include #include namespace mozilla { namespace tl { /** Compute min/max. */ template struct Min { static const size_t value = I < J ? I : J; }; template struct Max { static const size_t value = I > J ? I : J; }; /** Compute floor(log2(i)). */ template struct FloorLog2 { static const size_t value = 1 + FloorLog2::value; }; template<> struct FloorLog2<0> { /* Error */ }; template<> struct FloorLog2<1> { static const size_t value = 0; }; /** Compute ceiling(log2(i)). */ template struct CeilingLog2 { static const size_t value = FloorLog2<2 * I - 1>::value; }; /** Round up to the nearest power of 2. */ template struct RoundUpPow2 { static const size_t value = size_t(1) << CeilingLog2::value; }; template<> struct RoundUpPow2<0> { static const size_t value = 1; }; /** Compute the number of bits in the given unsigned type. */ template struct BitSize { static const size_t value = sizeof(T) * CHAR_BIT; }; /** * Produce an N-bit mask, where N <= BitSize::value. Handle the * language-undefined edge case when N = BitSize::value. */ 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 |value| to assure // its computation. static const size_t checkPrecondition = 0 / size_t(N < BitSize::value); static const size_t value = (size_t(1) << N) - 1 + checkPrecondition; }; template<> struct NBitMask::value> { static const size_t value = 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 value = ~NBitMask::value - CeilingLog2::value>::value; }; template<> struct MulOverflowMask<0> { /* Error */ }; template<> struct MulOverflowMask<1> { static const size_t value = 0; }; } // namespace tl } // namespace mozilla #endif /* mozilla_TemplateLib_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/ThreadLocal.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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" #include "mozilla/NullPtr.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() { 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, nullptr); #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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/TypeTraits.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 { /* Forward declarations. */ template struct RemoveCV; /* 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] */ namespace detail { template struct IsIntegralHelper : FalseType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; } /* namespace detail */ /** * IsIntegral determines whether a type is an integral type. * * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is false; * mozilla::IsIntegral::value is false; * * Note that the behavior of IsIntegral on char16_t and char32_t is * unspecified. */ template struct IsIntegral : detail::IsIntegralHelper::Type> {}; template struct IsSame; namespace detail { template struct IsFloatingPointHelper : IntegralConstant::value || IsSame::value || IsSame::value> {}; } // namespace detail /** * IsFloatingPoint determines whether a type is a floating point type (float, * double, long double). * * mozilla::IsFloatingPoint::value is false; * mozilla::IsFloatingPoint::value is true; * mozilla::IsFloatingPoint::value is true; * mozilla::IsFloatingPoint::value is false. */ template struct IsFloatingPoint : detail::IsFloatingPointHelper::Type> {}; /** * 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 {}; namespace detail { // __is_enum is a supported extension across all of our supported compilers. template struct IsEnumHelper : IntegralConstant {}; } // namespace detail /** * IsEnum determines whether a type is an enum type. * * mozilla::IsEnum::value is true; * mozilla::IsEnum::value is false; * mozilla::IsEnum::value is false; */ template struct IsEnum : detail::IsEnumHelper::Type> {}; /* 20.9.4.2 Composite type traits [meta.unary.comp] */ /** * IsArithmetic determines whether a type is arithmetic. A type is arithmetic * iff it is an integral type or a floating point type. * * mozilla::IsArithmetic::value is true; * mozilla::IsArithmetic::value is true; * mozilla::IsArithmetic::value is false. */ template struct IsArithmetic : IntegralConstant::value || IsFloatingPoint::value> {}; /* 20.9.4.3 Type properties [meta.unary.prop] */ /** * IsConst determines whether a type is const or not. * * mozilla::IsConst::value is false; * mozilla::IsConst::value is true; * mozilla::IsConst::value is false. */ template struct IsConst : FalseType {}; template struct IsConst : TrueType {}; /** * IsVolatile determines whether a type is volatile or not. * * mozilla::IsVolatile::value is false; * mozilla::IsVolatile::value is true; * mozilla::IsVolatile::value is false. */ template struct IsVolatile : FalseType {}; template struct IsVolatile : TrueType {}; /** * 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 {}; namespace detail { template::value> struct IsSignedHelper; template struct IsSignedHelper : TrueType {}; template struct IsSignedHelper : IntegralConstant::value && T(-1) < T(1)> {}; } // namespace detail /** * IsSigned determines whether a type is a signed arithmetic type. |char| is * considered a signed type if it has the same representation as |signed char|. * * Don't use this if the type might be user-defined! You might or might not get * a compile error, depending. * * mozilla::IsSigned::value is true; * mozilla::IsSigned::value is false; * mozilla::IsSigned::value is false; * mozilla::IsSigned::value is true. */ template struct IsSigned : detail::IsSignedHelper {}; namespace detail { template::value> struct IsUnsignedHelper; template struct IsUnsignedHelper : FalseType {}; template struct IsUnsignedHelper : IntegralConstant::value && (IsSame::Type, bool>::value || T(1) < T(-1))> {}; } // namespace detail /** * IsUnsigned determines whether a type is an unsigned arithmetic type. * * Don't use this if the type might be user-defined! You might or might not get * a compile error, depending. * * mozilla::IsUnsigned::value is false; * mozilla::IsUnsigned::value is true; * mozilla::IsUnsigned::value is true; * mozilla::IsUnsigned::value is false. */ template struct IsUnsigned : detail::IsUnsignedHelper {}; /* 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] */ /** * RemoveConst removes top-level const qualifications on a type. * * mozilla::RemoveConst::Type is int; * mozilla::RemoveConst::Type is int; * mozilla::RemoveConst::Type is const int*; * mozilla::RemoveConst::Type is int*. */ template struct RemoveConst { typedef T Type; }; template struct RemoveConst { typedef T Type; }; /** * RemoveVolatile removes top-level volatile qualifications on a type. * * mozilla::RemoveVolatile::Type is int; * mozilla::RemoveVolatile::Type is int; * mozilla::RemoveVolatile::Type is volatile int*; * mozilla::RemoveVolatile::Type is int*. */ template struct RemoveVolatile { typedef T Type; }; template struct RemoveVolatile { typedef T Type; }; /** * RemoveCV removes top-level const and volatile qualifications on a type. * * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int*. */ template struct RemoveCV { typedef typename RemoveConst::Type>::Type Type; }; /* 20.9.7.2 Reference modifications [meta.trans.ref] */ /* 20.9.7.3 Sign modifications [meta.trans.sign] */ template struct EnableIf; template struct Conditional; namespace detail { template struct WithC : Conditional {}; template struct WithV : Conditional {}; template struct WithCV : WithC::Type> {}; template struct CorrespondingSigned; template<> struct CorrespondingSigned { typedef signed char Type; }; template<> struct CorrespondingSigned { typedef signed char Type; }; template<> struct CorrespondingSigned { typedef short Type; }; template<> struct CorrespondingSigned { typedef int Type; }; template<> struct CorrespondingSigned { typedef long Type; }; template<> struct CorrespondingSigned { typedef long long Type; }; template::Type, bool IsSignedIntegerType = IsSigned::value && !IsSame::value> struct MakeSigned; template struct MakeSigned { typedef T Type; }; template struct MakeSigned : WithCV::value, IsVolatile::value, typename CorrespondingSigned::Type> {}; } // namespace detail /** * MakeSigned produces the corresponding signed integer type for a given * integral type T, with the const/volatile qualifiers of T. T must be a * possibly-const/volatile-qualified integral type that isn't bool. * * If T is already a signed integer type (not including char!), then T is * produced. * * Otherwise, if T is an unsigned integer type, the signed variety of T, with * T's const/volatile qualifiers, is produced. * * Otherwise, the integral type of the same size as T, with the lowest rank, * with T's const/volatile qualifiers, is produced. (This basically only acts * to produce signed char when T = char.) * * mozilla::MakeSigned::Type is signed long; * mozilla::MakeSigned::Type is volatile int; * mozilla::MakeSigned::Type is const signed short; * mozilla::MakeSigned::Type is const signed char; * mozilla::MakeSigned is an error; * mozilla::MakeSigned is an error. */ template struct MakeSigned : EnableIf::value && !IsSame::Type>::value, typename detail::MakeSigned >::Type {}; namespace detail { template struct CorrespondingUnsigned; template<> struct CorrespondingUnsigned { typedef unsigned char Type; }; template<> struct CorrespondingUnsigned { typedef unsigned char Type; }; template<> struct CorrespondingUnsigned { typedef unsigned short Type; }; template<> struct CorrespondingUnsigned { typedef unsigned int Type; }; template<> struct CorrespondingUnsigned { typedef unsigned long Type; }; template<> struct CorrespondingUnsigned { typedef unsigned long long Type; }; template::Type, bool IsUnsignedIntegerType = IsUnsigned::value && !IsSame::value> struct MakeUnsigned; template struct MakeUnsigned { typedef T Type; }; template struct MakeUnsigned : WithCV::value, IsVolatile::value, typename CorrespondingUnsigned::Type> {}; } // namespace detail /** * MakeUnsigned produces the corresponding unsigned integer type for a given * integral type T, with the const/volatile qualifiers of T. T must be a * possibly-const/volatile-qualified integral type that isn't bool. * * If T is already an unsigned integer type (not including char!), then T is * produced. * * Otherwise, if T is an signed integer type, the unsigned variety of T, with * T's const/volatile qualifiers, is produced. * * Otherwise, the unsigned integral type of the same size as T, with the lowest * rank, with T's const/volatile qualifiers, is produced. (This basically only * acts to produce unsigned char when T = char.) * * mozilla::MakeUnsigned::Type is unsigned long; * mozilla::MakeUnsigned::Type is volatile unsigned int; * mozilla::MakeUnsigned::Type is const unsigned short; * mozilla::MakeUnsigned::Type is const unsigned char; * mozilla::MakeUnsigned is an error; * mozilla::MakeUnsigned is an error. */ template struct MakeUnsigned : EnableIf::value && !IsSame::Type>::value, typename detail::MakeUnsigned >::Type {}; /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/TypedEnum.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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. * * MOZ_{BEGIN,END}_ENUM_CLASS doesn't work for defining enum classes nested * inside classes. To define an enum class nested inside another class, use * MOZ_{BEGIN,END}_NESTED_ENUM_CLASS, and place a MOZ_FINISH_NESTED_ENUM_CLASS * in namespace scope to handle bits that can only be implemented with * namespace-scoped code. For example: * * class FooBar { * * MOZ_BEGIN_NESTED_ENUM_CLASS(Enum, int32_t) * A, * B = 6 * MOZ_END_NESTED_ENUM_CLASS(Enum) * * }; * * MOZ_FINISH_NESTED_ENUM_CLASS(FooBar::Enum) */ #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_NESTED_ENUM_CLASS(Name, type) \ enum class Name : type { # define MOZ_END_NESTED_ENUM_CLASS(Name) \ }; # define MOZ_FINISH_NESTED_ENUM_CLASS(Name) /* nothing */ #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_NESTED_ENUM_CLASS(Name, type) \ class Name \ { \ public: \ enum Enum MOZ_ENUM_TYPE(type) \ { # define MOZ_END_NESTED_ENUM_CLASS(Name) \ }; \ Name() {} \ Name(Enum aEnum) : mEnum(aEnum) {} \ explicit Name(int num) : mEnum((Enum)num) {} \ operator Enum() const { return mEnum; } \ private: \ Enum mEnum; \ }; # define MOZ_FINISH_NESTED_ENUM_CLASS(Name) \ 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 # define MOZ_BEGIN_ENUM_CLASS(Name, type) MOZ_BEGIN_NESTED_ENUM_CLASS(Name, type) # define MOZ_END_ENUM_CLASS(Name) \ MOZ_END_NESTED_ENUM_CLASS(Name) \ MOZ_FINISH_NESTED_ENUM_CLASS(Name) #endif /* __cplusplus */ #endif /* mozilla_TypedEnum_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Types.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 types and size_t. */ #include #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 /* * GCC's typeof is available when decltype is not. */ #if defined(__GNUC__) && defined(__cplusplus) && \ !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L # define decltype __typeof__ #endif #endif /* mozilla_Types_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Util.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8, t9); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); 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 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/Vector.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/length-parametrized vector class. */ #ifndef mozilla_Vector_h #define mozilla_Vector_h #include "mozilla/AllocPolicy.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/NullPtr.h" #include "mozilla/ReentrancyGuard.h" #include "mozilla/TemplateLib.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.h" #include // for placement new /* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4345) #endif namespace mozilla { template class VectorBase; namespace detail { /* * 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(VectorBase& v, size_t newCap) { MOZ_ASSERT(!v.usingInlineStorage()); MOZ_ASSERT(!CapacityHasExcessSpace(newCap)); T* newbuf = reinterpret_cast(v.malloc_(newCap * sizeof(T))); if (!newbuf) return false; T* dst = newbuf; T* src = v.beginNoCheck(); for (; 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* end = dst + n; dst < end; ++dst) *dst = t; } static inline bool growTo(VectorBase& v, size_t newCap) { MOZ_ASSERT(!v.usingInlineStorage()); MOZ_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; } }; } // namespace detail /* * A CRTP base class for vector-like classes. Unless you really really want * your own vector class -- and you almost certainly don't -- you should use * mozilla::Vector instead! * * See mozilla::Vector for interface requirements. */ template class VectorBase : private AllocPolicy { /* utilities */ static const bool sElemIsPod = IsPod::value; typedef detail::VectorImpl Impl; friend struct detail::VectorImpl; bool growStorageBy(size_t incr); bool convertToHeapStorage(size_t newCap); /* 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 value = sizeof(T); }; template struct ElemSize<0, Dummy> { static const size_t value = 1; }; static const size_t sInlineCapacity = tl::Min::value>::value; /* Calculate inline buffer size; avoid 0-sized array. */ static const size_t sInlineBytes = tl::Max<1, sInlineCapacity * ElemSize::value>::value; /* 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; /* Number of elements in the vector. */ size_t mLength; /* Max number of elements storable in the vector without resizing. */ size_t mCapacity; #ifdef DEBUG /* Max elements of reserved or used space in this vector. */ size_t mReserved; #endif /* Memory used for inline storage. */ AlignedStorage storage; #ifdef DEBUG friend class ReentrancyGuard; bool entered; #endif /* private accessors */ bool usingInlineStorage() const { return mBegin == const_cast(this)->inlineStorage(); } T* inlineStorage() { return static_cast(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 { MOZ_ASSERT(mReserved <= mCapacity); MOZ_ASSERT(mLength <= mReserved); return mReserved; } #endif /* Append operations guaranteed to succeed due to pre-reserved space. */ template void internalAppend(const U& u); template void internalAppendAll(const VectorBase& u); void internalAppendN(const T& t, size_t n); template void internalAppend(const U* begin, size_t length); public: static const size_t sMaxInlineStorage = N; typedef T ElementType; VectorBase(AllocPolicy = AllocPolicy()); VectorBase(MoveRef); /* Move constructor. */ ThisVector& operator=(MoveRef); /* Move assignment. */ ~VectorBase(); /* 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() { MOZ_ASSERT(!entered); return mBegin; } const T* begin() const { MOZ_ASSERT(!entered); return mBegin; } T* end() { MOZ_ASSERT(!entered); return mBegin + mLength; } const T* end() const { MOZ_ASSERT(!entered); return mBegin + mLength; } T& operator[](size_t i) { MOZ_ASSERT(!entered); MOZ_ASSERT(i < mLength); return begin()[i]; } const T& operator[](size_t i) const { MOZ_ASSERT(!entered); MOZ_ASSERT(i < mLength); return begin()[i]; } T& back() { MOZ_ASSERT(!entered); MOZ_ASSERT(!empty()); return *(end() - 1); } const T& back() const { MOZ_ASSERT(!entered); MOZ_ASSERT(!empty()); return *(end() - 1); } class Range { friend class VectorBase; T* cur_; T* 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() { MOZ_ASSERT(!empty()); ++cur_; } T popCopyFront() { MOZ_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); /** * Increase the length of the vector, but don't initialize the new elements * -- leave them 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 won't reallocate elements storage. * This *doesn't* mean that infallibleAppend may be used! You still must * reserve the extra space, even if this method indicates that appends won't * need to reallocate elements storage. */ 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(const U& u); template bool appendAll(const VectorBase& u); 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); /* * Guaranteed-infallible append operations for use upon vectors whose * memory has been pre-reserved. Don't use this if you haven't reserved the * memory! */ 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, PointerRangeSize(aBegin, aEnd)); } template void infallibleAppend(const U* aBegin, size_t aLength) { internalAppend(aBegin, aLength); } void popBack(); T popCopy(); /** * Transfers ownership of the internal buffer used by this vector to the * caller. (It's the caller's responsibility to properly deallocate this * buffer, in accordance with this vector's AllocPolicy.) 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 nullptr. * * N.B. Although a T*, only the range [0, length()) is constructed. */ T* extractRawBuffer(); /** * Transfer ownership of an array of objects into the vector. The caller * must have allocated the array in accordance with this vector's * AllocPolicy. * * 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'll * be a dangling pointer if reallocation of the vector storage occurred; the * return value should be used instead. On failure, nullptr is returned. * * Example usage: * * if (!(p = vec.insert(p, val))) * * * * This is inherently a linear-time operation. Be careful! */ 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(MallocSizeOf mallocSizeOf) const; /** * Like sizeOfExcludingThis, but also measures the size of the vector * object (which must be heap-allocated) itself. */ size_t sizeOfIncludingThis(MallocSizeOf mallocSizeOf) const; void swap(ThisVector& other); private: VectorBase(const ThisVector&) MOZ_DELETE; void operator=(const ThisVector&) MOZ_DELETE; }; /* This does the re-entrancy check plus several other sanity checks. */ #define MOZ_REENTRANCY_GUARD_ET_AL \ ReentrancyGuard g(*this); \ MOZ_ASSERT_IF(usingInlineStorage(), mCapacity == sInlineCapacity); \ MOZ_ASSERT(reserved() <= mCapacity); \ MOZ_ASSERT(mLength <= reserved()); \ MOZ_ASSERT(mLength <= mCapacity) /* Vector Implementation */ template MOZ_ALWAYS_INLINE VectorBase::VectorBase(AP ap) : AP(ap), mBegin(static_cast(storage.addr())), mLength(0), mCapacity(sInlineCapacity) #ifdef DEBUG , mReserved(sInlineCapacity), entered(false) #endif {} /* Move constructor. */ template MOZ_ALWAYS_INLINE VectorBase::VectorBase(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 = static_cast(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 = static_cast(rhs->storage.addr()); rhs->mCapacity = sInlineCapacity; rhs->mLength = 0; #ifdef DEBUG rhs->mReserved = sInlineCapacity; #endif } } /* Move assignment. */ template MOZ_ALWAYS_INLINE TV& VectorBase::operator=(MoveRef rhs) { TV* tv = static_cast(this); tv->~TV(); new(tv) TV(rhs); return *tv; } template MOZ_ALWAYS_INLINE VectorBase::~VectorBase() { MOZ_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 VectorBase::convertToHeapStorage(size_t newCap) { MOZ_ASSERT(usingInlineStorage()); /* Allocate buffer. */ MOZ_ASSERT(!detail::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 MOZ_NEVER_INLINE bool VectorBase::growStorageBy(size_t incr) { MOZ_ASSERT(mLength + incr > mCapacity); MOZ_ASSERT_IF(!usingInlineStorage(), !detail::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)>::value; 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 * * static_cast(end()) - static_cast(begin()) * * doesn't overflow ptrdiff_t (see bug 510319). */ if (mLength & tl::MulOverflowMask<4 * sizeof(T)>::value) { 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 (detail::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)>::value) { 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 VectorBase::initCapacity(size_t request) { MOZ_ASSERT(empty()); MOZ_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 VectorBase::reserve(size_t request) { MOZ_REENTRANCY_GUARD_ET_AL; if (request > mCapacity && !growStorageBy(request - mLength)) return false; #ifdef DEBUG if (request > mReserved) mReserved = request; MOZ_ASSERT(mLength <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); #endif return true; } template inline void VectorBase::shrinkBy(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; MOZ_ASSERT(incr <= mLength); Impl::destroy(endNoCheck() - incr, endNoCheck()); mLength -= incr; } template MOZ_ALWAYS_INLINE bool VectorBase::growBy(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; if (incr > mCapacity - mLength && !growStorageBy(incr)) return false; MOZ_ASSERT(mLength + incr <= mCapacity); T* newend = endNoCheck() + incr; Impl::initialize(endNoCheck(), newend); mLength += incr; #ifdef DEBUG if (mLength > mReserved) mReserved = mLength; #endif return true; } template MOZ_ALWAYS_INLINE bool VectorBase::growByUninitialized(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; if (incr > mCapacity - mLength && !growStorageBy(incr)) return false; MOZ_ASSERT(mLength + incr <= mCapacity); mLength += incr; #ifdef DEBUG if (mLength > mReserved) mReserved = mLength; #endif return true; } template inline bool VectorBase::resize(size_t newLength) { size_t curLength = mLength; if (newLength > curLength) return growBy(newLength - curLength); shrinkBy(curLength - newLength); return true; } template MOZ_ALWAYS_INLINE bool VectorBase::resizeUninitialized(size_t newLength) { size_t curLength = mLength; if (newLength > curLength) return growByUninitialized(newLength - curLength); shrinkBy(curLength - newLength); return true; } template inline void VectorBase::clear() { MOZ_REENTRANCY_GUARD_ET_AL; Impl::destroy(beginNoCheck(), endNoCheck()); mLength = 0; } template inline void VectorBase::clearAndFree() { clear(); if (usingInlineStorage()) return; this->free_(beginNoCheck()); mBegin = static_cast(storage.addr()); mCapacity = sInlineCapacity; #ifdef DEBUG mReserved = sInlineCapacity; #endif } template inline bool VectorBase::canAppendWithoutRealloc(size_t needed) const { return mLength + needed <= mCapacity; } template template MOZ_ALWAYS_INLINE void VectorBase::internalAppendAll(const VectorBase& other) { internalAppend(other.begin(), other.length()); } template template MOZ_ALWAYS_INLINE void VectorBase::internalAppend(const U& u) { MOZ_ASSERT(mLength + 1 <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); new(endNoCheck()) T(u); ++mLength; } template MOZ_ALWAYS_INLINE bool VectorBase::appendN(const T& t, size_t needed) { MOZ_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 MOZ_ALWAYS_INLINE void VectorBase::internalAppendN(const T& t, size_t needed) { MOZ_ASSERT(mLength + needed <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); Impl::copyConstructN(endNoCheck(), needed, t); mLength += needed; } template inline T* VectorBase::insert(T* p, const T& val) { MOZ_ASSERT(begin() <= p); MOZ_ASSERT(p <= end()); size_t pos = p - begin(); MOZ_ASSERT(pos <= mLength); size_t oldLength = mLength; if (pos == oldLength) { if (!append(val)) return nullptr; } else { T oldBack = back(); if (!append(oldBack)) /* Dup the last element. */ return nullptr; for (size_t i = oldLength; i > pos; --i) (*this)[i] = (*this)[i - 1]; (*this)[pos] = val; } return begin() + pos; } template inline void VectorBase::erase(T* it) { MOZ_ASSERT(begin() <= it); MOZ_ASSERT(it < end()); while (it + 1 < end()) { *it = *(it + 1); ++it; } popBack(); } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U* insBegin, const U* insEnd) { MOZ_REENTRANCY_GUARD_ET_AL; size_t needed = 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 MOZ_ALWAYS_INLINE void VectorBase::internalAppend(const U* insBegin, size_t insLength) { MOZ_ASSERT(mLength + insLength <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); Impl::copyConstruct(endNoCheck(), insBegin, insBegin + insLength); mLength += insLength; } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U& u) { MOZ_REENTRANCY_GUARD_ET_AL; if (mLength == mCapacity && !growStorageBy(1)) return false; #ifdef DEBUG if (mLength + 1 > mReserved) mReserved = mLength + 1; #endif internalAppend(u); return true; } template template MOZ_ALWAYS_INLINE bool VectorBase::appendAll(const VectorBase& other) { return append(other.begin(), other.length()); } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U *insBegin, size_t insLength) { return append(insBegin, insBegin + insLength); } template MOZ_ALWAYS_INLINE void VectorBase::popBack() { MOZ_REENTRANCY_GUARD_ET_AL; MOZ_ASSERT(!empty()); --mLength; endNoCheck()->~T(); } template MOZ_ALWAYS_INLINE T VectorBase::popCopy() { T ret = back(); popBack(); return ret; } template inline T* VectorBase::extractRawBuffer() { T* ret; if (usingInlineStorage()) { ret = reinterpret_cast(this->malloc_(mLength * sizeof(T))); if (!ret) return nullptr; Impl::copyConstruct(ret, beginNoCheck(), endNoCheck()); Impl::destroy(beginNoCheck(), endNoCheck()); /* mBegin, mCapacity are unchanged. */ mLength = 0; } else { ret = mBegin; mBegin = static_cast(storage.addr()); mLength = 0; mCapacity = sInlineCapacity; #ifdef DEBUG mReserved = sInlineCapacity; #endif } return ret; } template inline void VectorBase::replaceRawBuffer(T* p, size_t aLength) { MOZ_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 = static_cast(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 VectorBase::sizeOfExcludingThis(MallocSizeOf mallocSizeOf) const { return usingInlineStorage() ? 0 : mallocSizeOf(beginNoCheck()); } template inline size_t VectorBase::sizeOfIncludingThis(MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } template inline void VectorBase::swap(TV& other) { static_assert(N == 0, "still need to implement this for 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 } /* * 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 AllocPolicy.h (defaults to * mozilla::MallocAllocPolicy) * * Vector is not reentrant: T member functions called during Vector member * functions must not call back into the same object! */ template class Vector : public VectorBase > { typedef VectorBase Base; public: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} Vector(mozilla::MoveRef vec) : Base(vec) {} Vector& operator=(mozilla::MoveRef vec) { return Base::operator=(vec); } }; } // namespace mozilla #ifdef _MSC_VER #pragma warning(pop) #endif #endif /* mozilla_Vector_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/mac/mozilla/WeakPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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'. * * AtomicSupportsWeakPtr can be used for a variant with an atomically updated * reference counter. * * 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/Atomics.h" #include "mozilla/NullPtr.h" #include "mozilla/RefPtr.h" #include "mozilla/TypeTraits.h" namespace mozilla { template class WeakPtrBase; template class SupportsWeakPtrBase; namespace detail { // This can live beyond the lifetime of the class derived from SupportsWeakPtrBase. template class WeakReference : public RefCounted, Atomicity> { public: explicit WeakReference(T* p) : ptr(p) {} T* get() const { return ptr; } private: friend class WeakPtrBase; friend class SupportsWeakPtrBase; void detach() { ptr = nullptr; } T* ptr; }; } // namespace detail template class SupportsWeakPtrBase { public: WeakPtrBase asWeakPtr() { if (!weakRef) weakRef = new WeakReference(static_cast(this)); return WeakPtrBase(weakRef); } protected: ~SupportsWeakPtrBase() { static_assert(IsBaseOf, T>::value, "T must derive from SupportsWeakPtrBase"); if (weakRef) weakRef->detach(); } private: friend class WeakPtrBase; RefPtr weakRef; }; template class SupportsWeakPtr : public SupportsWeakPtrBase > { }; template class AtomicSupportsWeakPtr : public SupportsWeakPtrBase > { }; namespace detail { template struct WeakReferenceCount { static const RefCountAtomicity atomicity = IsBaseOf, T>::value ? AtomicRefCount : NonAtomicRefCount; }; } template class WeakPtrBase { public: WeakPtrBase(const WeakPtrBase& o) : ref(o.ref) {} // Ensure that ref is dereferenceable in the uninitialized state WeakPtrBase() : ref(new 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 SupportsWeakPtrBase; explicit WeakPtrBase(const RefPtr &o) : ref(o) {} RefPtr ref; }; template class WeakPtr : public WeakPtrBase::atomicity> > { typedef WeakPtrBase::atomicity> > Base; public: WeakPtr(const WeakPtr& o) : Base(o) {} WeakPtr(const Base& o) : Base(o) {} WeakPtr() {} }; } // namespace mozilla #endif /* mozilla_WeakPtr_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/Anchor.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/CallArgs.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 "mozilla/TypeTraits.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); /* Typedef for native functions that may be called in parallel. */ typedef js::ParallelResult (* JSParallelNative)(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp); /* * Typedef for native functions that may be called either in parallel or * sequential execution. */ typedef JSBool (* JSThreadSafeNative)(js::ThreadSafeContext *cx, unsigned argc, JS::Value *vp); /* * Convenience wrappers for passing in ThreadSafeNative to places that expect * a JSNative or a JSParallelNative. */ template inline JSBool JSNativeThreadSafeWrapper(JSContext *cx, unsigned argc, JS::Value *vp); template inline js::ParallelResult JSParallelNativeThreadSafeWrapper(js::ForkJoinSlice *slice, unsigned argc, JS::Value *vp); /* * 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); namespace JS { extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; /* * 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.rval().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. */ namespace detail { #ifdef DEBUG extern JS_PUBLIC_API(void) CheckIsValidConstructible(Value v); #endif enum UsedRval { IncludeUsedRval, NoUsedRval }; template class MOZ_STACK_CLASS UsedRvalBase; template<> class MOZ_STACK_CLASS UsedRvalBase { protected: mutable bool usedRval_; void setUsedRval() const { usedRval_ = true; } void clearUsedRval() const { usedRval_ = false; } }; template<> class MOZ_STACK_CLASS UsedRvalBase { protected: void setUsedRval() const {} void clearUsedRval() const {} }; template class MOZ_STACK_CLASS CallReceiverBase : public UsedRvalBase< #ifdef DEBUG WantUsedRval #else NoUsedRval #endif > { protected: 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(!this->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(!this->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]); } Value computeThis(JSContext *cx) const { if (thisv().isObject()) return thisv(); return JS_ComputeThis(cx, base()); } bool isConstructing() const { #ifdef DEBUG if (this->usedRval_) CheckIsValidConstructible(calleev()); #endif return argv_[-1].isMagic(); } /* * 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 { this->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 { this->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 { this->clearUsedRval(); argv_[-2] = aCalleev; } void setThis(Value aThisv) const { argv_[-1] = aThisv; } MutableHandleValue mutableThisv() const { return MutableHandleValue::fromMarkedLocation(&argv_[-1]); } }; } // namespace detail class MOZ_STACK_CLASS CallReceiver : public detail::CallReceiverBase { private: friend CallReceiver CallReceiverFromVp(Value *vp); friend CallReceiver CallReceiverFromArgv(Value *argv); }; 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. */ namespace detail { template class MOZ_STACK_CLASS CallArgsBase : public mozilla::Conditional >::Type { protected: unsigned argc_; public: /* Returns the number of arguments. */ unsigned length() const { return argc_; } /* Returns the i-th zero-indexed argument. */ MutableHandleValue operator[](unsigned i) const { MOZ_ASSERT(i < argc_); return MutableHandleValue::fromMarkedLocation(&this->argv_[i]); } /* * Returns the i-th zero-indexed argument, or |undefined| if there's no * such argument. */ HandleValue get(unsigned i) const { return i < length() ? HandleValue::fromMarkedLocation(&this->argv_[i]) : UndefinedHandleValue; } /* * Returns true if the i-th zero-indexed argument is present and is not * |undefined|. */ bool hasDefined(unsigned i) const { return i < argc_ && !this->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 this->argv_; } Value *end() const { return this->argv_ + argc_; } }; } // namespace detail class MOZ_STACK_CLASS CallArgs : public detail::CallArgsBase { private: 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; } }; 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 /* * 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/CharacterEncoding.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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()); } }; class UTF8Chars : public mozilla::Range { typedef mozilla::Range Base; public: UTF8Chars() : Base() {} UTF8Chars(char *aBytes, size_t aLength) : Base(reinterpret_cast(aBytes), aLength) {} UTF8Chars(const char *aBytes, size_t aLength) : Base(reinterpret_cast(const_cast(aBytes)), aLength) {} }; /* * 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() : Base(NULL, 0) {} 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(js::ThreadSafeContext *cx, TwoByteChars tbchars); extern UTF8CharsZ TwoByteCharsToNewUTF8CharsZ(js::ThreadSafeContext *cx, TwoByteChars tbchars); uint32_t Utf8ToOneUcs4Char(const uint8_t *utf8Buffer, int utf8Length); /* * Inflate bytes in UTF-8 encoding to jschars. * - On error, returns an empty TwoByteCharsZ. * - On success, returns a malloc'd TwoByteCharsZ, and updates |outlen| to hold * its length; the length value excludes the trailing null. */ extern TwoByteCharsZ UTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen); /* * The same as UTF8CharsToNewTwoByteCharsZ(), except that any malformed UTF-8 characters * will be replaced by \uFFFD. No exception will be thrown for malformed UTF-8 * input. */ extern TwoByteCharsZ LossyUTF8CharsToNewTwoByteCharsZ(JSContext *cx, const UTF8Chars utf8, size_t *outlen); } // 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/Date.h ================================================ /* -*- 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_Date_h #define js_Date_h #include "jstypes.h" namespace JS { // Year is a year, month is 0-11, day is 1-based. The return value is // a number of milliseconds since the epoch. Can return NaN. JS_PUBLIC_API(double) MakeDate(double year, unsigned month, unsigned day); // Takes an integer number of milliseconds since the epoch and returns the // year. Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) YearFromTime(double time); // Takes an integer number of milliseconds since the epoch and returns the // month (0-11). Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) MonthFromTime(double time); // Takes an integer number of milliseconds since the epoch and returns the // day (1-based). Can return NaN, and will do so if NaN is passed in. JS_PUBLIC_API(double) DayFromTime(double time); } // namespace JS #endif /* js_Date_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/GCAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_GCAPI_h #define js_GCAPI_h #include "js/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) \ D(OUT_OF_NURSERY) \ D(EVICT_NURSERY) \ D(FULL_STORE_BUFFER) \ \ /* These are reserved for future use. */ \ D(RESERVED0) \ D(RESERVED1) \ D(RESERVED2) \ D(RESERVED3) \ D(RESERVED4) \ D(RESERVED5) \ D(RESERVED6) \ D(RESERVED7) \ D(RESERVED8) \ D(RESERVED9) \ D(RESERVED10) \ D(RESERVED11) \ D(RESERVED12) \ D(RESERVED13) \ D(RESERVED14) \ D(RESERVED15) \ D(RESERVED16) \ D(RESERVED17) \ D(RESERVED18) \ D(RESERVED19) \ \ /* 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(void) EnableGenerationalGC(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 { Heap 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; } void trace(JSTracer *trc, const char *name) { JS_CallHeapObjectTracer(trc, &value, name); } 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); shadow::Runtime *rt = js::gc::GetGCThingRuntime(thing); #ifdef JSGC_GENERATIONAL /* * GC things residing in the nursery cannot be gray: they have no mark bits. * All live objects in the nursery are moved to tenured at the beginning of * each GC slice, so the gray marker never sees nursery things. */ if (uintptr_t(thing) >= rt->gcNurseryStart_ && uintptr_t(thing) < rt->gcNurseryEnd_) return; #endif if (IsIncrementalBarrierNeededOnGCThing(rt, thing, kind)) IncrementalReferenceBarrier(thing, kind); else if (GCThingIsMarkedGray(thing)) UnmarkGrayGCThingRecursively(thing, kind); } static JS_ALWAYS_INLINE void ExposeValueToActiveJS(const Value &v) { if (v.isMarkable()) ExposeGCThingToActiveJS(v.toGCThing(), v.gcKind()); } } /* namespace JS */ #endif /* js_GCAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/HashTable.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_HashTable_h #define js_HashTable_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Casting.h" #include "mozilla/DebugOnly.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/PodOperations.h" #include "mozilla/ReentrancyGuard.h" #include "mozilla/TemplateLib.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.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) {} 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, mozilla::Move(e)); } bool add(AddPtr &p, const Key &k) { Entry e(k, Value()); return impl.add(p, mozilla::Move(e)); } template bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { Entry e(k, v); return impl.relookupOrAdd(p, k, mozilla::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(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf 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, mozilla::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); } // Infallibly rekey one entry, if present. void rekey(const Lookup &old_key, const Key &new_key) { if (old_key != new_key) { if (Ptr p = lookup(old_key)) impl.rekey(p, new_key, new_key); } } // HashMap is movable HashMap(mozilla::MoveRef rhs) : impl(mozilla::Move(rhs->impl)) {} void operator=(mozilla::MoveRef rhs) { impl = mozilla::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) {} 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(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf 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); } // Infallibly rekey one entry, if present. void rekey(const Lookup &old_key, const T &new_key) { if (old_key != new_key) { if (Ptr p = lookup(old_key)) impl.rekey(p, new_key, new_key); } } // HashSet is movable HashSet(mozilla::MoveRef rhs) : impl(mozilla::Move(rhs->impl)) {} void operator=(mozilla::MoveRef rhs) { impl = mozilla::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::value> {}; // 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); uint64_t u = mozilla::BitwiseCast(d); return HashNumber(u ^ (u >> 32)); } static bool match(double lhs, double rhs) { return mozilla::BitwiseCast(lhs) == mozilla::BitwiseCast(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(mozilla::MoveRef rhs) : key(mozilla::Move(rhs->key)), value(mozilla::Move(rhs->value)) { } typedef Key KeyType; typedef Value ValueType; 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 mozilla::RemoveConst::Type 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) { mozilla::Swap(keyHash, other->keyHash); mozilla::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; } 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 mozilla::RemoveConst::Type 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) { table.rekey(*this->cur, l, k); 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(mozilla::MoveRef rhs) : AllocPolicy(*rhs) { mozilla::PodAssign(this, &*rhs); rhs->table = NULL; } void operator=(mozilla::MoveRef rhs) { if (table) destroyTable(*this, table, capacity()); mozilla::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 mozilla::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 = mozilla::tl::BitSize::value; 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, mozilla::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 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(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(table); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } Ptr lookup(const Lookup &l) const { mozilla::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 { mozilla::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) { mozilla::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; { mozilla::ReentrancyGuard g(*this); p.entry_ = &lookup(l, p.keyHash, sCollisionBit); } return p.found() || add(p, u); } void remove(Ptr p) { JS_ASSERT(table); mozilla::ReentrancyGuard g(*this); JS_ASSERT(p.found()); remove(*p.entry_); checkUnderloaded(); } void rekey(Ptr p, const Lookup &l, const Key &k) { JS_ASSERT(table); mozilla::ReentrancyGuard g(*this); JS_ASSERT(p.found()); typename HashTableEntry::NonConstT t(mozilla::Move(*p)); HashPolicy::setKey(t, const_cast(k)); remove(*p.entry_); putNewInfallible(l, mozilla::Move(t)); } #undef METER }; } // namespace detail } // namespace js #endif /* js_HashTable_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/HeapAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_HeapAPI_h #define js_HeapAPI_h #include "jspubtd.h" #include "js/Utility.h" /* These values are private to the JS engine. */ namespace js { namespace gc { const size_t ArenaShift = 12; 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; const size_t ChunkRuntimeOffset = ChunkSize - sizeof(void*); /* * 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 JS::shadow::Runtime * GetGCThingRuntime(const void *thing) { uintptr_t addr = uintptr_t(thing); addr &= ~js::gc::ChunkMask; addr |= js::gc::ChunkRuntimeOffset; 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(shadow::Runtime *rt, void *thing, JSGCTraceKind kind) { if (!rt->needsBarrier_) return false; JS::Zone *zone = GetGCThingZone(thing); return reinterpret_cast(zone)->needsBarrier_; } } /* namespace JS */ #endif /* js_HeapAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/LegacyIntTypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 types. */ #ifndef js_LegacyIntTypes_h #define js_LegacyIntTypes_h #include #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 /* js_LegacyIntTypes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/MemoryMetrics.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 "mozilla/MemoryReporting.h" #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 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 interpreterStack; size_t gcMarker; size_t mathCache; size_t scriptData; size_t scriptSources; CodeSizes code; }; struct ZoneStats { ZoneStats() : extra(NULL), gcHeapArenaAdmin(0), gcHeapUnusedGcThings(0), gcHeapStringsNormal(0), gcHeapStringsShort(0), gcHeapLazyScripts(0), gcHeapTypeObjects(0), gcHeapIonCodes(0), stringCharsNonHuge(0), lazyScripts(0), typeObjects(0), typePool(0), hugeStrings() {} ZoneStats(const ZoneStats &other) : extra(other.extra), gcHeapArenaAdmin(other.gcHeapArenaAdmin), gcHeapUnusedGcThings(other.gcHeapUnusedGcThings), gcHeapStringsNormal(other.gcHeapStringsNormal), gcHeapStringsShort(other.gcHeapStringsShort), gcHeapLazyScripts(other.gcHeapLazyScripts), gcHeapTypeObjects(other.gcHeapTypeObjects), gcHeapIonCodes(other.gcHeapIonCodes), stringCharsNonHuge(other.stringCharsNonHuge), lazyScripts(other.lazyScripts), typeObjects(other.typeObjects), typePool(other.typePool), hugeStrings() { hugeStrings.appendAll(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(gcHeapLazyScripts); ADD(gcHeapTypeObjects); ADD(gcHeapIonCodes); ADD(stringCharsNonHuge); ADD(lazyScripts); ADD(typeObjects); ADD(typePool); #undef ADD hugeStrings.appendAll(other.hugeStrings); } // This field can be used by embedders. void *extra; size_t gcHeapArenaAdmin; size_t gcHeapUnusedGcThings; size_t gcHeapStringsNormal; size_t gcHeapStringsShort; size_t gcHeapLazyScripts; size_t gcHeapTypeObjects; size_t gcHeapIonCodes; size_t stringCharsNonHuge; size_t lazyScripts; 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() : extra(NULL), 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), baselineData(0), baselineStubsFallback(0), baselineStubsOptimized(0), ionData(0), compartmentObject(0), crossCompartmentWrappersTable(0), regexpCompartment(0), debuggeesSet(0), typeInference() {} CompartmentStats(const CompartmentStats &other) : extra(other.extra), 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), baselineData(other.baselineData), baselineStubsFallback(other.baselineStubsFallback), baselineStubsOptimized(other.baselineStubsOptimized), ionData(other.ionData), compartmentObject(other.compartmentObject), crossCompartmentWrappersTable(other.crossCompartmentWrappersTable), regexpCompartment(other.regexpCompartment), debuggeesSet(other.debuggeesSet), typeInference(other.typeInference) { } // This field can be used by embedders. void *extra; // 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 baselineData; size_t baselineStubsFallback; size_t baselineStubsOptimized; 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(baselineData); ADD(baselineStubsFallback); ADD(baselineStubsOptimized); 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(mozilla::MallocSizeOf 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; mozilla::MallocSizeOf 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(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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/PropertyKey.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/RequiredDefines.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/RootingAPI.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_RootingAPI_h #define js_RootingAPI_h #include "mozilla/GuardObjects.h" #include "mozilla/TypeTraits.h" #include "js/Utility.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 |Rooted| 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 three 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. * * - 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 (measured to * be a few nanoseconds on desktop) 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. * * The following diagram explains the list of supported, implicit type * conversions between classes of this family: * * Rooted ----> Handle * | ^ * | | * | | * +---> MutableHandle * (via &) * * All of these types have an implicit conversion to raw pointers. */ namespace js { class Module; class ScriptSourceObject; template struct GCMethods {}; template class RootedBase {}; template class HandleBase {}; template class MutableHandleBase {}; template class HeapBase {}; /* * 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 gc { struct Cell; } /* namespace gc */ } /* 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; }; /* * The Heap class is a C/C++ heap-stored reference to a JS GC thing. All * members of heap classes that refer to GC thing should use Heap (or * possibly TenuredHeap, described below). * * Heap wraps the complex mechanisms required to ensure GC safety for the * contained reference into a C++ class that behaves similarly to a normal * pointer. * * GC references stored on the C/C++ stack must use Rooted/Handle/MutableHandle * instead. * * Requirements for type T: * - Must be one of: Value, jsid, JSObject*, JSString*, JSScript* */ template class Heap : public js::HeapBase { public: Heap() { static_assert(sizeof(T) == sizeof(Heap), "Heap must be binary compatible with T."); init(js::GCMethods::initial()); } explicit Heap(T p) { init(p); } explicit Heap(const Heap &p) { init(p.ptr); } ~Heap() { if (js::GCMethods::needsPostBarrier(ptr)) relocate(); } bool operator==(const Heap &other) { return ptr == other.ptr; } bool operator!=(const Heap &other) { return ptr != other.ptr; } bool operator==(const T &other) const { return ptr == other; } bool operator!=(const T &other) const { return ptr != other; } operator T() const { return ptr; } T operator->() const { return ptr; } const T *address() const { return &ptr; } const T &get() const { return ptr; } T *unsafeGet() { return &ptr; } Heap &operator=(T p) { set(p); return *this; } void set(T newPtr) { JS_ASSERT(!js::GCMethods::poisoned(newPtr)); if (js::GCMethods::needsPostBarrier(newPtr)) { ptr = newPtr; post(); } else if (js::GCMethods::needsPostBarrier(ptr)) { relocate(); /* Called before overwriting ptr. */ ptr = newPtr; } else { ptr = newPtr; } } private: void init(T newPtr) { JS_ASSERT(!js::GCMethods::poisoned(newPtr)); ptr = newPtr; if (js::GCMethods::needsPostBarrier(ptr)) post(); } void post() { #ifdef JSGC_GENERATIONAL JS_ASSERT(js::GCMethods::needsPostBarrier(ptr)); js::GCMethods::postBarrier(&ptr); #endif } void relocate() { #ifdef JSGC_GENERATIONAL js::GCMethods::relocate(&ptr); #endif } T ptr; }; #ifdef DEBUG /* * For generational GC, assert that an object is in the tenured generation as * opposed to being in the nursery. */ extern JS_FRIEND_API(void) AssertGCThingMustBeTenured(JSObject* obj); #else inline void AssertGCThingMustBeTenured(JSObject *obj) {} #endif /* * The TenuredHeap class is similar to the Heap class above in that it * encapsulates the GC concerns of an on-heap reference to a JS object. However, * it has two important differences: * * 1) Pointers which are statically known to only reference "tenured" objects * can avoid the extra overhead of SpiderMonkey's write barriers. * * 2) Objects in the "tenured" heap have stronger alignment restrictions than * those in the "nursery", so it is possible to store flags in the lower * bits of pointers known to be tenured. TenuredHeap wraps a normal tagged * pointer with a nice API for accessing the flag bits and adds various * assertions to ensure that it is not mis-used. * * GC things are said to be "tenured" when they are located in the long-lived * heap: e.g. they have gained tenure as an object by surviving past at least * one GC. For performance, SpiderMonkey allocates some things which are known * to normally be long lived directly into the tenured generation; for example, * global objects. Additionally, SpiderMonkey does not visit individual objects * when deleting non-tenured objects, so object with finalizers are also always * tenured; for instance, this includes most DOM objects. * * The considerations to keep in mind when using a TenuredHeap vs a normal * Heap are: * * - It is invalid for a TenuredHeap to refer to a non-tenured thing. * - It is however valid for a Heap to refer to a tenured thing. * - It is not possible to store flag bits in a Heap. */ template class TenuredHeap : public js::HeapBase { public: TenuredHeap() : bits(0) { static_assert(sizeof(T) == sizeof(TenuredHeap), "TenuredHeap must be binary compatible with T."); } explicit TenuredHeap(T p) : bits(0) { setPtr(p); } explicit TenuredHeap(const TenuredHeap &p) : bits(0) { setPtr(p.ptr); } bool operator==(const TenuredHeap &other) { return bits == other.bits; } bool operator!=(const TenuredHeap &other) { return bits != other.bits; } void setPtr(T newPtr) { JS_ASSERT((reinterpret_cast(newPtr) & flagsMask) == 0); JS_ASSERT(!js::GCMethods::poisoned(newPtr)); if (newPtr) AssertGCThingMustBeTenured(newPtr); bits = (bits & flagsMask) | reinterpret_cast(newPtr); } void setFlags(uintptr_t flagsToSet) { JS_ASSERT((flagsToSet & ~flagsMask) == 0); bits |= flagsToSet; } void unsetFlags(uintptr_t flagsToUnset) { JS_ASSERT((flagsToUnset & ~flagsMask) == 0); bits &= ~flagsToUnset; } bool hasFlag(uintptr_t flag) const { JS_ASSERT((flag & ~flagsMask) == 0); return (bits & flag) != 0; } T getPtr() const { return reinterpret_cast(bits & ~flagsMask); } uintptr_t getFlags() const { return bits & flagsMask; } operator T() const { return getPtr(); } T operator->() const { return getPtr(); } TenuredHeap &operator=(T p) { setPtr(p); return *this; } /* * Set the pointer to a value which will cause a crash if it is * dereferenced. */ void setToCrashOnTouch() { bits = (bits & flagsMask) | crashOnTouchPointer; } bool isSetToCrashOnTouch() { return (bits & ~flagsMask) == crashOnTouchPointer; } private: enum { maskBits = 3, flagsMask = (1 << maskBits) - 1, crashOnTouchPointer = 1 << maskBits }; uintptr_t bits; }; /* * 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 MOZ_NONHEAP_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) { static_assert(sizeof(Handle) == sizeof(T *), "Handle must be binary compatible with T*."); ptr = reinterpret_cast(handle.address()); } /* Create a handle for a NULL pointer. */ Handle(js::NullPtr) { 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) { 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(); } /* * Take care when calling this method! * * This creates a Handle from the raw location of a T. * * It should be called only if the following conditions hold: * * 1) 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. * * 2) the contents of the location are immutable, or at least cannot change * for the lifetime of the handle, as its users may not expect its value * to change underneath them. */ 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(const 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; } const T& get() const { return *ptr; } /* * Return a reference so passing a Handle to something that * takes a |const T&| is not a GC hazard. */ operator const T&() const { return get(); } T operator->() const { return get(); } bool operator!=(const T &other) const { return *ptr != other; } bool operator==(const T &other) const { return *ptr == other; } private: Handle() {} const T *ptr; template void operator=(S v) MOZ_DELETE; }; typedef Handle HandleObject; typedef Handle HandleModule; typedef Handle HandleScriptSource; 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 MOZ_STACK_CLASS MutableHandle : public js::MutableHandleBase { public: inline MutableHandle(Rooted *root); void set(T v) { JS_ASSERT(!js::GCMethods::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; } const T& get() const { return *ptr; } /* * Return a reference so passing a MutableHandle to something that takes * a |const T&| is not a GC hazard. */ operator const T&() const { return get(); } T operator->() const { return get(); } private: MutableHandle() {} T *ptr; template void operator=(S v) MOZ_DELETE; void operator=(MutableHandle other) MOZ_DELETE; }; typedef MutableHandle MutableHandleObject; typedef MutableHandle MutableHandleFunction; typedef MutableHandle MutableHandleScript; typedef MutableHandle MutableHandleString; typedef MutableHandle MutableHandleId; typedef MutableHandle MutableHandleValue; #ifdef JSGC_GENERATIONAL JS_PUBLIC_API(void) HeapCellPostBarrier(js::gc::Cell **cellp); JS_PUBLIC_API(void) HeapCellRelocate(js::gc::Cell **cellp); #endif } /* namespace JS */ namespace js { /* * 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)) {} }; /* * 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 GCMethods { static T *initial() { return NULL; } static ThingRootKind kind() { return RootKind::rootKind(); } static bool poisoned(T *v) { return JS::IsPoisonedPtr(v); } static bool needsPostBarrier(T *v) { return v; } #ifdef JSGC_GENERATIONAL static void postBarrier(T **vp) { JS::HeapCellPostBarrier(reinterpret_cast(vp)); } static void relocate(T **vp) { JS::HeapCellRelocate(reinterpret_cast(vp)); } #endif }; // XXX: Needed for cocos2d JS Bindings //#if defined(DEBUG) /* This helper allows us to assert that Rooted is scoped within a request. */ extern JS_PUBLIC_API(bool) IsInRequest(JSContext *cx); //#endif } /* 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 MOZ_STACK_CLASS Rooted : public js::RootedBase { /* Note: CX is a subclass of either ContextFriendFields or PerThreadDataFriendFields. */ template void init(CX *cx) { #ifdef JSGC_TRACK_EXACT_ROOTS js::ThingRootKind kind = js::GCMethods::kind(); this->stack = &cx->thingGCRooters[kind]; this->prev = *stack; *stack = reinterpret_cast*>(this); JS_ASSERT(!js::GCMethods::poisoned(ptr)); #endif } public: Rooted(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_ASSERT(js::IsInRequest(cx)); init(js::ContextFriendFields::get(cx)); } Rooted(JSContext *cx, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_ASSERT(js::IsInRequest(cx)); init(js::ContextFriendFields::get(cx)); } Rooted(js::ContextFriendFields *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(cx); } Rooted(js::ContextFriendFields *cx, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(cx); } Rooted(js::PerThreadDataFriendFields *pt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(pt); } Rooted(js::PerThreadDataFriendFields *pt, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(pt); } Rooted(JSRuntime *rt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(js::GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(js::PerThreadDataFriendFields::getMainThread(rt)); } Rooted(JSRuntime *rt, T initial MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(initial) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; init(js::PerThreadDataFriendFields::getMainThread(rt)); } ~Rooted() { #ifdef JSGC_TRACK_EXACT_ROOTS JS_ASSERT(*stack == reinterpret_cast*>(this)); *stack = prev; #endif } #ifdef JSGC_TRACK_EXACT_ROOTS Rooted *previous() { return prev; } #endif /* * Important: Return a reference here so passing a Rooted to * something that takes a |const T&| is not a GC hazard. */ operator const 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::GCMethods::poisoned(value)); ptr = value; return ptr; } T &operator=(const Rooted &value) { ptr = value; return ptr; } void set(T value) { JS_ASSERT(!js::GCMethods::poisoned(value)); ptr = value; } bool operator!=(const T &other) const { return ptr != other; } bool operator==(const T &other) const { return ptr == other; } private: #ifdef JSGC_TRACK_EXACT_ROOTS 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*); #endif #ifdef JSGC_ROOT_ANALYSIS 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 RootedScriptSource; 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(CX *cx, const T *ptr, size_t count) { SkipRoot **head = &cx->skipGCRooters; this->stack = head; this->prev = *stack; *stack = this; this->start = (const uint8_t *) ptr; this->end = this->start + (sizeof(T) * count); } public: ~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 */ template void init(js::ContextFriendFields *cx, const T *ptr, size_t count) {} public: #endif /* DEBUG && JSGC_ROOT_ANALYSIS */ template SkipRoot(JSContext *cx, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(ContextFriendFields::get(cx), ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template SkipRoot(ContextFriendFields *cx, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(cx, ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template SkipRoot(PerThreadData *pt, const T *ptr, size_t count = 1 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { init(PerThreadDataFriendFields::get(pt), ptr, count); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* Interface substitute for Rooted which does not root the variable's memory. */ template class FakeRooted : public RootedBase { public: template FakeRooted(CX *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : ptr(GCMethods::initial()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } template FakeRooted(CX *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(!GCMethods::poisoned(value)); ptr = value; return ptr; } bool operator!=(const T &other) const { return ptr != other; } bool operator==(const T &other) const { 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::GCMethods::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) { MOZ_ASSUME_UNREACHABLE("Bad conversion"); } static inline JS::MutableHandle toMutableHandle(MutableHandleType v) { MOZ_ASSUME_UNREACHABLE("Bad conversion"); } }; } /* namespace js */ namespace JS { template template inline Handle::Handle(const 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) { static_assert(sizeof(MutableHandle) == sizeof(T *), "MutableHandle must be binary compatible with T*."); 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 } /* 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 */ #endif /* js_RootingAPI_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/Utility.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_Utility_h #define js_Utility_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/Move.h" #include "mozilla/Scoped.h" #include "mozilla/TemplateLib.h" #include #include #ifdef JS_OOM_DO_BACKTRACES #include #include #endif #include "jstypes.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_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) 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 testing function * oomAfterAllocations COUNT is passed, we fail continuously after the NUM'th * allocation from now. */ extern JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations; /* set in builtins/TestingFunctions.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_calloc(size_t nmemb, size_t size) { JS_OOM_POSSIBLY_FAIL(); return calloc(nmemb, size); } 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_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 void js_delete_poison(T *p) { if (p) { p->~T(); memset(p, 0x3B, sizeof(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 & mozilla::tl::MulOverflowMask::value) return NULL; return (T *)js_malloc(numElems * sizeof(T)); } template static JS_ALWAYS_INLINE T * js_pod_calloc(size_t numElems) { if (numElems & mozilla::tl::MulOverflowMask::value) 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 { /* 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 } } /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/Value.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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(__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(__SUNPRO_CC) && !defined(__xlC__) */ 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(__SUNPRO_CC) && !defined(__xlC__) */ #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) /* 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 jsval_layout JSVAL_TO_IMPL(JS::Value v); static inline JS::Value IMPL_TO_JSVAL(jsval_layout l); namespace JS { /** * Returns a generic quiet NaN value, with all payload bits set to zero. * * Among other properties, this NaN's bit pattern conforms to JS::Value's * bit pattern restrictions. */ static MOZ_ALWAYS_INLINE double GenericNaN() { return mozilla::SpecificNaN(0, 0x8000000000000ULL); } static inline double CanonicalizeNaN(double d) { if (MOZ_UNLIKELY(mozilla::IsNaN(d))) return GenericNaN(); return d; } /* * 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 (mozilla::DoubleIsInt32(d, &i)) { setInt32(i); return true; } 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 /************************************************************************/ #ifdef JSGC_GENERATIONAL namespace JS { JS_PUBLIC_API(void) HeapValuePostBarrier(Value *valuep); JS_PUBLIC_API(void) HeapValueRelocate(Value *valuep); } #endif namespace js { template <> struct GCMethods { 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 GCMethods { 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); } static bool needsPostBarrier(const JS::Value &v) { return v.isMarkable(); } #ifdef JSGC_GENERATIONAL static void postBarrier(JS::Value *v) { JS::HeapValuePostBarrier(v); } static void relocate(JS::Value *v) { JS::HeapValueRelocate(v); } #endif }; template class UnbarrieredMutableValueOperations; 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 UnbarrieredMutableValueOperations; 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(); } uint32_t toPrivateUint32() const { return value()->toPrivateUint32(); } 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 that don't need post barriers. Outer must be * a class inheriting UnbarrieredMutableValueOperations with visible * extractMutable() and extract() methods returning the const Value* and Value* * abstracted by Outer. */ template class UnbarrieredMutableValueOperations : public ValueOperations { friend class MutableValueOperations; 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 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); } }; /* * A class designed for CRTP use in implementing all 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 UnbarrieredMutableValueOperations { public: void setString(JSString *str) { this->value()->setString(str); } void setString(const JS::Anchor &str) { this->value()->setString(str); } void setObject(JSObject &obj) { this->value()->setObject(obj); } void setObjectOrNull(JSObject *arg) { this->value()->setObjectOrNull(arg); } }; /* * Augment the generic Heap interface when T = Value with * type-querying, value-extracting, and mutating operations. */ template <> class HeapBase : public UnbarrieredMutableValueOperations > { typedef JS::Heap Outer; friend class ValueOperations; friend class UnbarrieredMutableValueOperations; const JS::Value * extract() const { return static_cast(this)->address(); } JS::Value * extractMutable() { return static_cast(this)->unsafeGet(); } /* * Setters that potentially change the value to a GC thing from a non-GC * thing must call JS::Heap::set() to trigger the post barrier. * * Changing from a GC thing to a non-GC thing value will leave the heap * value in the store buffer, but it will be ingored so this is not a * problem. */ void setBarriered(const JS::Value &v) { static_cast *>(this)->set(v); } public: void setString(JSString *str) { setBarriered(JS::StringValue(str)); } void setString(const JS::Anchor &str) { setBarriered(JS::StringValue(str.get())); } void setObject(JSObject &obj) { setBarriered(JS::ObjectValue(obj)); } void setObjectOrNull(JSObject *arg) { if (arg) setObject(*arg); else setNull(); } }; /* * 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 UnbarrieredMutableValueOperations >; 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 UnbarrieredMutableValueOperations >; 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; }; static_assert(sizeof(ValueAlignmentTester) == 16, "JS::Value must be 16-byte-aligned"); struct LayoutAlignmentTester { char c; jsval_layout l; }; 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; 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js/Vector.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 js_Vector_h #define js_Vector_h #include "mozilla/Vector.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; // If we had C++11 template aliases, we could just use this: // // template // using Vector = mozilla::Vector; // // ...and get rid of all the CRTP madness in mozilla::Vector(Base). But we // can't because compiler support's not up to snuff. (Template aliases are in // gcc 4.7 and clang 3.0 and are expected to be in MSVC 2013.) Instead, have a // completely separate class inheriting from mozilla::Vector, and throw CRTP at // the problem til things work. // // This workaround presents a couple issues. First, because js::Vector is a // distinct type from mozilla::Vector, overload resolution, method calls, etc. // are affected. *Hopefully* this won't be too bad in practice. (A bunch of // places had to be fixed when mozilla::Vector was introduced, but it wasn't a // crazy number.) Second, mozilla::Vector's interface has to be made subclass- // ready via CRTP -- or rather, via mozilla::VectorBase, which basically no one // should use. :-) Third, we have to redefine the constructors and the non- // inherited operators. Blech. Happily there aren't too many of these, so it // isn't the end of the world. template class Vector : public mozilla::VectorBase > { typedef typename mozilla::VectorBase Base; public: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} Vector(mozilla::MoveRef vec) : Base(vec) {} Vector &operator=(mozilla::MoveRef vec) { return Base::operator=(vec); } }; } // namespace js #endif /* js_Vector_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js-config.h ================================================ /* -*- 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. */ /* #undef JS_GC_ZEAL */ /* 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. */ /* #undef JS_HAVE_MACHINE_ENDIAN_H */ /* Define to 1 if the header is present and useable. See jscpucfg.h. */ /* #undef JS_HAVE_SYS_ISA_DEFS_H */ /* The configure script defines these if it doesn't #define JS_HAVE_STDINT_H. */ /* #undef JS_BYTES_PER_WORD */ /* MOZILLA JSAPI version number components */ #define MOZJS_MAJOR_VERSION 25 #define MOZJS_MINOR_VERSION 0 #endif /* js_config_h___ */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/js.msg ================================================ /* -*- 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_MISSING_BINARY_DIGITS, 134, 0, JSEXN_SYNTAXERR, "missing binary digits after '0b'") 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_MISSING_OCTAL_DIGITS, 143, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'") 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_RESULTING_STRING_TOO_LARGE, 146, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size") 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_NEGATIVE_REPETITION_COUNT, 170, 0, JSEXN_RANGEERR, "repeat count must be non-negative") 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_BAD_STRICT_ASSIGN, 236, 1, JSEXN_SYNTAXERR, "can't assign to {0} in strict mode") 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_REDEFINE_ARRAY_LENGTH,242, 0, JSEXN_TYPEERR, "can't redefine array length") MSG_DEF(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH,243, 0, JSEXN_TYPEERR, "can't define array index property past the end of an array with non-writable length") 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_DEBUG_CANT_DEBUG_GLOBAL, 263, 0, JSEXN_ERR, "passing non-debuggable global to addDebuggee") 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_DEBUG_RESUMPTION_VALUE_DISALLOWED, 266, 0, JSEXN_TYPEERR, "resumption values are disallowed in this hook") 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_YIELD_WITHOUT_OPERAND, 272, 0, JSEXN_SYNTAXERR, "yield without a value is deprecated, and illegal in ES6 (use 'yield undefined' instead)") 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\" is only meaningful in the Directive Prologue of a function body") 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, 1, JSEXN_ERR, "successfully compiled asm.js code ({0})") 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") MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME,349, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups") MSG_DEF(JSMSG_DEPRECATED_SOURCE_MAP, 350, 0, JSEXN_SYNTAXERR, "Using //@ to indicate source map URL pragmas is deprecated. Use //# instead") MSG_DEF(JSMSG_BAD_DESTRUCT_ASSIGN, 351, 1, JSEXN_SYNTAXERR, "can't assign to {0} using destructuring assignment") MSG_DEF(JSMSG_BINARYDATA_ARRAYTYPE_BAD_ARGS, 352, 0, JSEXN_ERR, "Invalid arguments") MSG_DEF(JSMSG_BINARYDATA_BINARYARRAY_BAD_INDEX, 353, 0, JSEXN_RANGEERR, "invalid or out-of-range index") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_BAD_ARGS, 354, 0, JSEXN_RANGEERR, "invalid field descriptor") MSG_DEF(JSMSG_BINARYDATA_NOT_BINARYSTRUCT, 355, 1, JSEXN_TYPEERR, "{0} is not a BinaryStruct") MSG_DEF(JSMSG_BINARYDATA_SUBARRAY_INTEGER_ARG, 356, 1, JSEXN_ERR, "argument {0} must be an integer") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_EMPTY_DESCRIPTOR, 357, 0, JSEXN_ERR, "field descriptor cannot be empty") MSG_DEF(JSMSG_BINARYDATA_STRUCTTYPE_BAD_FIELD, 358, 1, JSEXN_ERR, "field {0} is not a valid BinaryData Type descriptor") ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsalloc.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* JS allocation policies. */ #ifndef jsalloc_h #define jsalloc_h #include "mozilla/AllocPolicy.h" #include "js/Utility.h" struct JSContext; namespace js { class ContextFriendFields; /* 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 { ContextFriendFields *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_((ContextFriendFields *) cx) {} // :( TempAllocPolicy(ContextFriendFields *cx) : cx_(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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* JavaScript API. */ #ifndef jsapi_h #define jsapi_h #include "mozilla/FloatingPoint.h" #include "mozilla/MemoryReporting.h" #include "mozilla/RangedPtr.h" #include "mozilla/ThreadLocal.h" #include "mozilla/TypeTraits.h" #include #include #include #include #include "js-config.h" #include "jsalloc.h" #include "jspubtd.h" #include "js/CallArgs.h" #include "js/CharacterEncoding.h" #include "js/HashTable.h" #include "js/RootingAPI.h" #include "js/Utility.h" #include "js/Value.h" #include "js/Vector.h" /************************************************************************/ namespace JS { typedef mozilla::RangedPtr CharPtr; class StableCharPtr : public CharPtr { public: StableCharPtr(const StableCharPtr &s) : CharPtr(s) {} StableCharPtr(const mozilla::RangedPtr &s) : CharPtr(s) {} StableCharPtr(const jschar *s, size_t len) : CharPtr(s, len) {} StableCharPtr(const jschar *pos, const jschar *start, size_t len) : CharPtr(pos, start, len) {} }; #if defined JS_THREADSAFE && defined DEBUG class JS_PUBLIC_API(AutoCheckRequestDepth) { JSContext *cx; public: AutoCheckRequestDepth(JSContext *cx); AutoCheckRequestDepth(js::ContextFriendFields *cx); ~AutoCheckRequestDepth(); }; # define CHECK_REQUEST(cx) \ JS::AutoCheckRequestDepth _autoCheckRequestDepth(cx) #else # define CHECK_REQUEST(cx) \ ((void) 0) #endif /* JS_THREADSAFE && DEBUG */ #ifdef DEBUG /* * Assert that we're not doing GC on cx, that we're in a request as * needed, and that the compartments for cx and v are correct. * Also check that GC would be safe at this point. */ JS_PUBLIC_API(void) AssertArgumentsAreSane(JSContext *cx, JS::Handle v); #else inline void AssertArgumentsAreSane(JSContext *cx, JS::Handle v) { /* Do nothing */ } #endif /* DEBUG */ class JS_PUBLIC_API(AutoGCRooter) { public: AutoGCRooter(JSContext *cx, ptrdiff_t tag); AutoGCRooter(js::ContextFriendFields *cx, ptrdiff_t tag); ~AutoGCRooter() { JS_ASSERT(this == *stackTop); *stackTop = down; } /* Implemented in gc/RootMarking.cpp. */ inline void trace(JSTracer *trc); static void traceAll(JSTracer *trc); static void traceAllWrappers(JSTracer *trc); protected: AutoGCRooter * const down; /* * Discriminates actual subclass of this being used. If non-negative, the * subclass roots an array of values of the length stored in this field. * If negative, meaning is indicated by the corresponding value in the enum * below. Any other negative value indicates some deeper problem such as * memory corruption. */ ptrdiff_t tag_; enum { VALARRAY = -2, /* js::AutoValueArray */ PARSER = -3, /* js::frontend::Parser */ SHAPEVECTOR = -4, /* js::AutoShapeVector */ IDARRAY = -6, /* js::AutoIdArray */ DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */ ID = -9, /* js::AutoIdRooter */ VALVECTOR = -10, /* js::AutoValueVector */ DESCRIPTOR = -11, /* js::AutoPropertyDescriptorRooter */ STRING = -12, /* js::AutoStringRooter */ IDVECTOR = -13, /* js::AutoIdVector */ OBJVECTOR = -14, /* js::AutoObjectVector */ STRINGVECTOR =-15, /* js::AutoStringVector */ SCRIPTVECTOR =-16, /* js::AutoScriptVector */ NAMEVECTOR = -17, /* js::AutoNameVector */ HASHABLEVALUE=-18, /* js::HashableValue */ IONMASM = -19, /* js::jit::MacroAssembler */ IONALLOC = -20, /* js::jit::AutoTempAllocatorRooter */ WRAPVECTOR = -21, /* js::AutoWrapperVector */ WRAPPER = -22, /* js::AutoWrapperRooter */ OBJOBJHASHMAP=-23, /* js::AutoObjectObjectHashMap */ OBJU32HASHMAP=-24, /* js::AutoObjectUnsigned32HashMap */ OBJHASHSET = -25, /* js::AutoObjectHashSet */ JSONPARSER = -26, /* js::JSONParser */ CUSTOM = -27, /* js::CustomAutoRooter */ FUNVECTOR = -28 /* js::AutoFunctionVector */ }; private: AutoGCRooter ** const stackTop; /* No copy or assignment semantics. */ AutoGCRooter(AutoGCRooter &ida) MOZ_DELETE; void operator=(AutoGCRooter &ida) MOZ_DELETE; }; class AutoStringRooter : private AutoGCRooter { public: AutoStringRooter(JSContext *cx, JSString *str = NULL MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, STRING), str_(str) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } void setString(JSString *str) { str_ = str; } JSString * string() const { return str_; } JSString ** addr() { return &str_; } JSString * const * addr() const { return &str_; } friend void AutoGCRooter::trace(JSTracer *trc); private: JSString *str_; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoArrayRooter : private AutoGCRooter { public: AutoArrayRooter(JSContext *cx, size_t len, Value *vec MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, len), array(vec), skip(cx, array, len) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; JS_ASSERT(tag_ >= 0); } void changeLength(size_t newLength) { tag_ = ptrdiff_t(newLength); JS_ASSERT(tag_ >= 0); } void changeArray(Value *newArray, size_t newLength) { changeLength(newLength); array = newArray; } Value *array; MutableHandleValue handleAt(size_t i) { JS_ASSERT(i < size_t(tag_)); return MutableHandleValue::fromMarkedLocation(&array[i]); } HandleValue handleAt(size_t i) const { JS_ASSERT(i < size_t(tag_)); return HandleValue::fromMarkedLocation(&array[i]); } friend void AutoGCRooter::trace(JSTracer *trc); private: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER js::SkipRoot skip; }; template class AutoVectorRooter : protected AutoGCRooter { public: explicit AutoVectorRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), vector(cx), vectorRoot(cx, &vector) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } explicit AutoVectorRooter(js::ContextFriendFields *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), vector(cx), vectorRoot(cx, &vector) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef T ElementType; size_t length() const { return vector.length(); } bool empty() const { return vector.empty(); } bool append(const T &v) { return vector.append(v); } bool appendAll(const AutoVectorRooter &other) { return vector.appendAll(other.vector); } bool insert(T *p, const T &val) { return vector.insert(p, val); } /* For use when space has already been reserved. */ void infallibleAppend(const T &v) { vector.infallibleAppend(v); } void popBack() { vector.popBack(); } T popCopy() { return vector.popCopy(); } bool growBy(size_t inc) { size_t oldLength = vector.length(); if (!vector.growByUninitialized(inc)) return false; makeRangeGCSafe(oldLength); return true; } bool resize(size_t newLength) { size_t oldLength = vector.length(); if (newLength <= oldLength) { vector.shrinkBy(oldLength - newLength); return true; } if (!vector.growByUninitialized(newLength - oldLength)) return false; makeRangeGCSafe(oldLength); return true; } void clear() { vector.clear(); } bool reserve(size_t newLength) { return vector.reserve(newLength); } T &operator[](size_t i) { return vector[i]; } const T &operator[](size_t i) const { return vector[i]; } JS::MutableHandle handleAt(size_t i) { return JS::MutableHandle::fromMarkedLocation(&vector[i]); } JS::Handle handleAt(size_t i) const { return JS::Handle::fromMarkedLocation(&vector[i]); } const T *begin() const { return vector.begin(); } T *begin() { return vector.begin(); } const T *end() const { return vector.end(); } T *end() { return vector.end(); } const T &back() const { return vector.back(); } friend void AutoGCRooter::trace(JSTracer *trc); private: void makeRangeGCSafe(size_t oldLength) { T *t = vector.begin() + oldLength; for (size_t i = oldLength; i < vector.length(); ++i, ++t) memset(t, 0, sizeof(T)); } typedef js::Vector VectorImpl; VectorImpl vector; /* Prevent overwriting of inline elements in vector. */ js::SkipRoot vectorRoot; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; template class AutoHashMapRooter : protected AutoGCRooter { private: typedef js::HashMap HashMapImpl; public: explicit AutoHashMapRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), map(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef Key KeyType; typedef Value ValueType; typedef typename HashMapImpl::Lookup Lookup; typedef typename HashMapImpl::Ptr Ptr; typedef typename HashMapImpl::AddPtr AddPtr; bool init(uint32_t len = 16) { return map.init(len); } bool initialized() const { return map.initialized(); } Ptr lookup(const Lookup &l) const { return map.lookup(l); } void remove(Ptr p) { map.remove(p); } AddPtr lookupForAdd(const Lookup &l) const { return map.lookupForAdd(l); } template bool add(AddPtr &p, const KeyInput &k, const ValueInput &v) { return map.add(p, k, v); } bool add(AddPtr &p, const Key &k) { return map.add(p, k); } template bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { return map.relookupOrAdd(p, k, v); } typedef typename HashMapImpl::Range Range; Range all() const { return map.all(); } typedef typename HashMapImpl::Enum Enum; void clear() { map.clear(); } void finish() { map.finish(); } bool empty() const { return map.empty(); } uint32_t count() const { return map.count(); } size_t capacity() const { return map.capacity(); } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfIncludingThis(mallocSizeOf); } unsigned generation() const { return map.generation(); } /************************************************** Shorthand operations */ bool has(const Lookup &l) const { return map.has(l); } template bool put(const KeyInput &k, const ValueInput &v) { return map.put(k, v); } template bool putNew(const KeyInput &k, const ValueInput &v) { return map.putNew(k, v); } Ptr lookupWithDefault(const Key &k, const Value &defaultValue) { return map.lookupWithDefault(k, defaultValue); } void remove(const Lookup &l) { map.remove(l); } friend void AutoGCRooter::trace(JSTracer *trc); private: AutoHashMapRooter(const AutoHashMapRooter &hmr) MOZ_DELETE; AutoHashMapRooter &operator=(const AutoHashMapRooter &hmr) MOZ_DELETE; HashMapImpl map; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; template class AutoHashSetRooter : protected AutoGCRooter { private: typedef js::HashSet HashSetImpl; public: explicit AutoHashSetRooter(JSContext *cx, ptrdiff_t tag MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, tag), set(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } typedef typename HashSetImpl::Lookup Lookup; typedef typename HashSetImpl::Ptr Ptr; typedef typename HashSetImpl::AddPtr AddPtr; bool init(uint32_t len = 16) { return set.init(len); } bool initialized() const { return set.initialized(); } Ptr lookup(const Lookup &l) const { return set.lookup(l); } void remove(Ptr p) { set.remove(p); } AddPtr lookupForAdd(const Lookup &l) const { return set.lookupForAdd(l); } bool add(AddPtr &p, const T &t) { return set.add(p, t); } bool relookupOrAdd(AddPtr &p, const Lookup &l, const T &t) { return set.relookupOrAdd(p, l, t); } typedef typename HashSetImpl::Range Range; Range all() const { return set.all(); } typedef typename HashSetImpl::Enum Enum; void clear() { set.clear(); } void finish() { set.finish(); } bool empty() const { return set.empty(); } uint32_t count() const { return set.count(); } size_t capacity() const { return set.capacity(); } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfExcludingThis(mallocSizeOf); } size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfIncludingThis(mallocSizeOf); } unsigned generation() const { return set.generation(); } /************************************************** Shorthand operations */ bool has(const Lookup &l) const { return set.has(l); } bool put(const T &t) { return set.put(t); } bool putNew(const T &t) { return set.putNew(t); } void remove(const Lookup &l) { set.remove(l); } friend void AutoGCRooter::trace(JSTracer *trc); private: AutoHashSetRooter(const AutoHashSetRooter &hmr) MOZ_DELETE; AutoHashSetRooter &operator=(const AutoHashSetRooter &hmr) MOZ_DELETE; HashSetImpl set; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoValueVector : public AutoVectorRooter { public: explicit AutoValueVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, VALVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoIdVector : public AutoVectorRooter { public: explicit AutoIdVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, IDVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoObjectVector : public AutoVectorRooter { public: explicit AutoObjectVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, OBJVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoFunctionVector : public AutoVectorRooter { public: explicit AutoFunctionVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, FUNVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } explicit AutoFunctionVector(js::ContextFriendFields *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, FUNVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; class AutoScriptVector : public AutoVectorRooter { public: explicit AutoScriptVector(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoVectorRooter(cx, SCRIPTVECTOR) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* * Cutsom rooting behavior for internal and external clients. */ class JS_PUBLIC_API(CustomAutoRooter) : private AutoGCRooter { public: template explicit CustomAutoRooter(CX *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, CUSTOM) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } friend void AutoGCRooter::trace(JSTracer *trc); protected: /* Supplied by derived class to trace roots. */ virtual void trace(JSTracer *trc) = 0; private: MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; /* Returns true if |v| is considered an acceptable this-value. */ typedef bool (*IsAcceptableThis)(const Value &v); /* * Implements the guts of a method; guaranteed to be provided an acceptable * this-value, as determined by a corresponding IsAcceptableThis method. */ typedef bool (*NativeImpl)(JSContext *cx, CallArgs args); namespace detail { /* DON'T CALL THIS DIRECTLY. It's for use only by CallNonGenericMethod! */ extern JS_PUBLIC_API(bool) CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl, CallArgs args); } /* namespace detail */ /* * Methods usually act upon |this| objects only from a single global object and * compartment. Sometimes, however, a method must act upon |this| values from * multiple global objects or compartments. In such cases the |this| value a * method might see will be wrapped, such that various access to the object -- * to its class, its private data, its reserved slots, and so on -- will not * work properly without entering that object's compartment. This method * implements a solution to this problem. * * To implement a method that accepts |this| values from multiple compartments, * define two functions. The first function matches the IsAcceptableThis type * and indicates whether the provided value is an acceptable |this| for the * method; it must be a pure function only of its argument. * * static JSClass AnswerClass = { ... }; * * static bool * IsAnswerObject(const Value &v) * { * if (!v.isObject()) * return false; * return JS_GetClass(&v.toObject()) == &AnswerClass; * } * * The second function implements the NativeImpl signature and defines the * behavior of the method when it is provided an acceptable |this| value. * Aside from some typing niceties -- see the CallArgs interface for details -- * its interface is the same as that of JSNative. * * static bool * answer_getAnswer_impl(JSContext *cx, JS::CallArgs args) * { * args.rval().setInt32(42); * return true; * } * * The implementation function is guaranteed to be called *only* with a |this| * value which is considered acceptable. * * Now to implement the actual method, write a JSNative that calls the method * declared below, passing the appropriate template and runtime arguments. * * static JSBool * answer_getAnswer(JSContext *cx, unsigned argc, JS::Value *vp) * { * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); * return JS::CallNonGenericMethod(cx, args); * } * * Note that, because they are used as template arguments, the predicate * and implementation functions must have external linkage. (This is * unfortunate, but GCC wasn't inlining things as one would hope when we * passed them as function arguments.) * * JS::CallNonGenericMethod will test whether |args.thisv()| is acceptable. If * it is, it will call the provided implementation function, which will return * a value and indicate success. If it is not, it will attempt to unwrap * |this| and call the implementation function on the unwrapped |this|. If * that succeeds, all well and good. If it doesn't succeed, a TypeError will * be thrown. * * Note: JS::CallNonGenericMethod will only work correctly if it's called in * tail position in a JSNative. Do not call it from any other place. */ template JS_ALWAYS_INLINE bool CallNonGenericMethod(JSContext *cx, CallArgs args) { const Value &thisv = args.thisv(); if (Test(thisv)) return Impl(cx, args); return detail::CallMethodIfWrapped(cx, Test, Impl, args); } JS_ALWAYS_INLINE bool CallNonGenericMethod(JSContext *cx, IsAcceptableThis Test, NativeImpl Impl, CallArgs args) { const Value &thisv = args.thisv(); if (Test(thisv)) return Impl(cx, args); return detail::CallMethodIfWrapped(cx, Test, Impl, args); } } /* namespace JS */ /************************************************************************/ /* JSClass operation signatures. */ /* * Add or get a property named by id in obj. Note the jsid id type -- id may * be a string (Unicode property identifier) or an int (element index). The * *vp out parameter, on success, is the new property value after the action. */ typedef JSBool (* JSPropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JS::MutableHandle vp); /* * Set a property named by id in obj, treating the assignment as strict * mode code if strict is true. Note the jsid id type -- id may be a string * (Unicode property identifier) or an int (element index). The *vp out * parameter, on success, is the new property value after the * set. */ typedef JSBool (* JSStrictPropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool strict, JS::MutableHandle vp); /* * Delete a property named by id in obj. * * If an error occurred, return false as per normal JSAPI error practice. * * If no error occurred, but the deletion attempt wasn't allowed (perhaps * because the property was non-configurable), set *succeeded to false and * return true. This will cause |delete obj[id]| to evaluate to false in * non-strict mode code, and to throw a TypeError in strict mode code. * * If no error occurred and the deletion wasn't disallowed (this is *not* the * same as saying that a deletion actually occurred -- deleting a non-existent * property, or an inherited property, is allowed -- it's just pointless), * set *succeeded to true and return true. */ typedef JSBool (* JSDeletePropertyOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool *succeeded); /* * This function type is used for callbacks that enumerate the properties of * a JSObject. The behavior depends on the value of enum_op: * * JSENUMERATE_INIT * A new, opaque iterator state should be allocated and stored in *statep. * (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored). * * The number of properties that will be enumerated should be returned as * an integer jsval in *idp, if idp is non-null, and provided the number of * enumerable properties is known. If idp is non-null and the number of * enumerable properties can't be computed in advance, *idp should be set * to JSVAL_ZERO. * * JSENUMERATE_INIT_ALL * Used identically to JSENUMERATE_INIT, but exposes all properties of the * object regardless of enumerability. * * JSENUMERATE_NEXT * A previously allocated opaque iterator state is passed in via statep. * Return the next jsid in the iteration using *idp. The opaque iterator * state pointed at by statep is destroyed and *statep is set to JSVAL_NULL * if there are no properties left to enumerate. * * JSENUMERATE_DESTROY * Destroy the opaque iterator state previously allocated in *statep by a * call to this function when enum_op was JSENUMERATE_INIT or * JSENUMERATE_INIT_ALL. * * The return value is used to indicate success, with a value of JS_FALSE * indicating failure. */ typedef JSBool (* JSNewEnumerateOp)(JSContext *cx, JS::Handle obj, JSIterateOp enum_op, JS::MutableHandle statep, JS::MutableHandleId idp); /* * The old-style JSClass.enumerate op should define all lazy properties not * yet reflected in obj. */ typedef JSBool (* JSEnumerateOp)(JSContext *cx, JS::Handle obj); /* * Resolve a lazy property named by id in obj by defining it directly in obj. * Lazy properties are those reflected from some peer native property space * (e.g., the DOM attributes for a given node reflected as obj) on demand. * * JS looks for a property in an object, and if not found, tries to resolve * the given id. If resolve succeeds, the engine looks again in case resolve * defined obj[id]. If no such property exists directly in obj, the process * is repeated with obj's prototype, etc. * * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties. */ typedef JSBool (* JSResolveOp)(JSContext *cx, JS::Handle obj, JS::Handle id); /* * Like JSResolveOp, but flags provide contextual information as follows: * * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment * * The *objp out parameter, on success, should be null to indicate that id * was not resolved; and non-null, referring to obj or one of its prototypes, * if id was resolved. The hook may assume *objp is null on entry. * * This hook instead of JSResolveOp is called via the JSClass.resolve member * if JSCLASS_NEW_RESOLVE is set in JSClass.flags. */ typedef JSBool (* JSNewResolveOp)(JSContext *cx, JS::Handle obj, JS::Handle id, unsigned flags, JS::MutableHandleObject objp); /* * Convert obj to the given type, returning true with the resulting value in * *vp on success, and returning false on error or exception. */ typedef JSBool (* JSConvertOp)(JSContext *cx, JS::Handle obj, JSType type, JS::MutableHandle vp); typedef struct JSFreeOp JSFreeOp; struct JSFreeOp { private: JSRuntime *runtime_; protected: JSFreeOp(JSRuntime *rt) : runtime_(rt) { } public: JSRuntime *runtime() const { return runtime_; } }; /* * Finalize obj, which the garbage collector has determined to be unreachable * from other live objects or from GC roots. Obviously, finalizers must never * store a reference to obj. */ typedef void (* JSFinalizeOp)(JSFreeOp *fop, JSObject *obj); /* * Finalizes external strings created by JS_NewExternalString. */ typedef struct JSStringFinalizer JSStringFinalizer; struct JSStringFinalizer { void (*finalize)(const JSStringFinalizer *fin, jschar *chars); }; /* * JSClass.checkAccess type: check whether obj[id] may be accessed per mode, * returning false on error/exception, true on success with obj[id]'s last-got * value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id * is either a string or an int jsval. */ typedef JSBool (* JSCheckAccessOp)(JSContext *cx, JS::Handle obj, JS::Handle id, JSAccessMode mode, JS::MutableHandle vp); /* * Check whether v is an instance of obj. Return false on error or exception, * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in * *bp otherwise. */ typedef JSBool (* JSHasInstanceOp)(JSContext *cx, JS::Handle obj, JS::MutableHandle vp, JSBool *bp); /* * Function type for trace operation of the class called to enumerate all * traceable things reachable from obj's private data structure. For each such * thing, a trace implementation must call one of the JS_Call*Tracer variants * on the thing. * * JSTraceOp implementation can assume that no other threads mutates object * state. It must not change state of the object or corresponding native * structures. The only exception for this rule is the case when the embedding * needs a tight integration with GC. In that case the embedding can check if * the traversal is a part of the marking phase through calling * JS_IsGCMarkingTracer and apply a special code like emptying caches or * marking its native structures. */ typedef void (* JSTraceOp)(JSTracer *trc, JSObject *obj); /* * Callback that JSTraceOp implementation can provide to return a string * describing the reference traced with JS_CallTracer. */ typedef void (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize); typedef JSObject * (* JSWeakmapKeyDelegateOp)(JSObject *obj); /* Callbacks and their arguments. */ typedef enum JSContextOp { JSCONTEXT_NEW, JSCONTEXT_DESTROY } JSContextOp; /* * The possible values for contextOp when the runtime calls the callback are: * JSCONTEXT_NEW JS_NewContext successfully created a new JSContext * instance. The callback can initialize the instance as * required. If the callback returns false, the instance * will be destroyed and JS_NewContext returns null. In * this case the callback is not called again. * JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The * callback may perform its own cleanup and must always * return true. * Any other value For future compatibility the callback must do nothing * and return true in this case. */ typedef JSBool (* JSContextCallback)(JSContext *cx, unsigned contextOp, void *data); typedef enum JSGCStatus { JSGC_BEGIN, JSGC_END } JSGCStatus; typedef void (* JSGCCallback)(JSRuntime *rt, JSGCStatus status, void *data); typedef enum JSFinalizeStatus { /* * Called when preparing to sweep a group of compartments, before anything * has been swept. The collector will not yield to the mutator before * calling the callback with JSFINALIZE_GROUP_END status. */ JSFINALIZE_GROUP_START, /* * Called when preparing to sweep a group of compartments. Weak references * to unmarked things have been removed and things that are not swept * incrementally have been finalized at this point. The collector may yield * to the mutator after this point. */ JSFINALIZE_GROUP_END, /* * Called at the end of collection when everything has been swept. */ JSFINALIZE_COLLECTION_END } JSFinalizeStatus; typedef void (* JSFinalizeCallback)(JSFreeOp *fop, JSFinalizeStatus status, JSBool isCompartment); /* * Generic trace operation that calls JS_CallTracer on each traceable thing * stored in data. */ typedef void (* JSTraceDataOp)(JSTracer *trc, void *data); typedef JSBool (* JSOperationCallback)(JSContext *cx); typedef void (* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report); #ifdef MOZ_TRACE_JSCALLS typedef void (* JSFunctionCallback)(const JSFunction *fun, const JSScript *scr, const JSContext *cx, int entering); #endif /* * Possible exception types. These types are part of a JSErrorFormatString * structure. They define which error to throw in case of a runtime error. * JSEXN_NONE marks an unthrowable error. */ typedef enum JSExnType { JSEXN_NONE = -1, JSEXN_ERR, JSEXN_INTERNALERR, JSEXN_EVALERR, JSEXN_RANGEERR, JSEXN_REFERENCEERR, JSEXN_SYNTAXERR, JSEXN_TYPEERR, JSEXN_URIERR, JSEXN_LIMIT } JSExnType; typedef struct JSErrorFormatString { /* The error format string in ASCII. */ const char *format; /* The number of arguments to expand in the formatted error message. */ uint16_t argCount; /* One of the JSExnType constants above. */ int16_t exnType; } JSErrorFormatString; typedef const JSErrorFormatString * (* JSErrorCallback)(void *userRef, const char *locale, const unsigned errorNumber); typedef JSBool (* JSLocaleToUpperCase)(JSContext *cx, JS::Handle src, JS::MutableHandle rval); typedef JSBool (* JSLocaleToLowerCase)(JSContext *cx, JS::Handle src, JS::MutableHandle rval); typedef JSBool (* JSLocaleCompare)(JSContext *cx, JS::Handle src1, JS::Handle src2, JS::MutableHandle rval); typedef JSBool (* JSLocaleToUnicode)(JSContext *cx, const char *src, JS::MutableHandle rval); /* * Security protocol types. */ typedef void (* JSDestroyPrincipalsOp)(JSPrincipals *principals); /* * Used to check if a CSP instance wants to disable eval() and friends. * See js_CheckCSPPermitsJSAction() in jsobj. */ typedef JSBool (* JSCSPEvalChecker)(JSContext *cx); /* * Callback used to ask the embedding for the cross compartment wrapper handler * that implements the desired prolicy for this kind of object in the * destination compartment. |obj| is the object to be wrapped. If |existing| is * non-NULL, it will point to an existing wrapper object that should be re-used * if possible. |existing| is guaranteed to be a cross-compartment wrapper with * a lazily-defined prototype and the correct global. It is guaranteed not to * wrap a function. */ typedef JSObject * (* JSWrapObjectCallback)(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj, JS::HandleObject proto, JS::HandleObject parent, unsigned flags); /* * Callback used by the wrap hook to ask the embedding to prepare an object * for wrapping in a context. This might include unwrapping other wrappers * or even finding a more suitable object for the new compartment. */ typedef JSObject * (* JSPreWrapCallback)(JSContext *cx, JS::HandleObject scope, JS::HandleObject obj, unsigned flags); /* * Callback used when wrapping determines that the underlying object is already * in the compartment for which it is being wrapped. This allows consumers to * maintain same-compartment wrapping invariants. * * |obj| is guaranteed to be same-compartment as |cx|, but it may (or may not) * be a security or cross-compartment wrapper. This is an unfortunate contract, * but is important for to avoid unnecessarily recomputing every cross- * compartment wrapper that gets passed to wrap. */ typedef JSObject * (* JSSameCompartmentWrapObjectCallback)(JSContext *cx, JS::HandleObject obj); typedef void (* JSDestroyCompartmentCallback)(JSFreeOp *fop, JSCompartment *compartment); typedef void (* JSCompartmentNameCallback)(JSRuntime *rt, JSCompartment *compartment, char *buf, size_t bufsize); /* * Read structured data from the reader r. This hook is used to read a value * previously serialized by a call to the WriteStructuredCloneOp hook. * * tag and data are the pair of uint32_t values from the header. The callback * may use the JS_Read* APIs to read any other relevant parts of the object * from the reader r. closure is any value passed to the JS_ReadStructuredClone * function. Return the new object on success, NULL on error/exception. */ typedef JSObject *(*ReadStructuredCloneOp)(JSContext *cx, JSStructuredCloneReader *r, uint32_t tag, uint32_t data, void *closure); /* * Structured data serialization hook. The engine can write primitive values, * Objects, Arrays, Dates, RegExps, TypedArrays, and ArrayBuffers. Any other * type of object requires application support. This callback must first use * the JS_WriteUint32Pair API to write an object header, passing a value * greater than JS_SCTAG_USER to the tag parameter. Then it can use the * JS_Write* APIs to write any other relevant parts of the value v to the * writer w. closure is any value passed to the JS_WriteStructuredCLone function. * * Return true on success, false on error/exception. */ typedef JSBool (*WriteStructuredCloneOp)(JSContext *cx, JSStructuredCloneWriter *w, JS::Handle obj, void *closure); /* * This is called when JS_WriteStructuredClone is given an invalid transferable. * To follow HTML5, the application must throw a DATA_CLONE_ERR DOMException * with error set to one of the JS_SCERR_* values. */ typedef void (*StructuredCloneErrorOp)(JSContext *cx, uint32_t errorid); /************************************************************************/ /* * JS constants. For efficiency, prefer predicates (e.g. v.isNull()) and * constructing values from scratch (e.g. Int32Value(0)). These constants are * stored in memory and initialized at startup, so testing against them and * using them requires memory loads and will be correspondingly slow. */ extern JS_PUBLIC_DATA(const jsval) JSVAL_NULL; extern JS_PUBLIC_DATA(const jsval) JSVAL_ZERO; extern JS_PUBLIC_DATA(const jsval) JSVAL_ONE; extern JS_PUBLIC_DATA(const jsval) JSVAL_FALSE; extern JS_PUBLIC_DATA(const jsval) JSVAL_TRUE; extern JS_PUBLIC_DATA(const jsval) JSVAL_VOID; static JS_ALWAYS_INLINE jsval JS_NumberValue(double d) { int32_t i; d = JS::CanonicalizeNaN(d); if (mozilla::DoubleIsInt32(d, &i)) return INT_TO_JSVAL(i); return DOUBLE_TO_JSVAL(d); } /************************************************************************/ /* * A jsid is an identifier for a property or method of an object which is * either a 31-bit signed integer, interned string or object. Also, there is * an additional jsid value, JSID_VOID, which does not occur in JS scripts but * may be used to indicate the absence of a valid jsid. * * A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or * JS_IdToValue must be used instead. */ #define JSID_TYPE_STRING 0x0 #define JSID_TYPE_INT 0x1 #define JSID_TYPE_VOID 0x2 #define JSID_TYPE_OBJECT 0x4 #define JSID_TYPE_MASK 0x7 /* * Avoid using canonical 'id' for jsid parameters since this is a magic word in * Objective-C++ which, apparently, wants to be able to #include jsapi.h. */ #define id iden static JS_ALWAYS_INLINE JSBool JSID_IS_STRING(jsid id) { return (JSID_BITS(id) & JSID_TYPE_MASK) == 0; } static JS_ALWAYS_INLINE JSString * JSID_TO_STRING(jsid id) { JS_ASSERT(JSID_IS_STRING(id)); return (JSString *)JSID_BITS(id); } static JS_ALWAYS_INLINE JSBool JSID_IS_ZERO(jsid id) { return JSID_BITS(id) == 0; } JS_PUBLIC_API(JSBool) JS_StringHasBeenInterned(JSContext *cx, JSString *str); /* * Only JSStrings that have been interned via the JSAPI can be turned into * jsids by API clients. * * N.B. if a jsid is backed by a string which has not been interned, that * string must be appropriately rooted to avoid being collected by the GC. */ JS_PUBLIC_API(jsid) INTERNED_STRING_TO_JSID(JSContext *cx, JSString *str); static JS_ALWAYS_INLINE JSBool JSID_IS_INT(jsid id) { return !!(JSID_BITS(id) & JSID_TYPE_INT); } static JS_ALWAYS_INLINE int32_t JSID_TO_INT(jsid id) { JS_ASSERT(JSID_IS_INT(id)); return ((uint32_t)JSID_BITS(id)) >> 1; } #define JSID_INT_MIN 0 #define JSID_INT_MAX INT32_MAX static JS_ALWAYS_INLINE JSBool INT_FITS_IN_JSID(int32_t i) { return i >= 0; } static JS_ALWAYS_INLINE jsid INT_TO_JSID(int32_t i) { jsid id; JS_ASSERT(INT_FITS_IN_JSID(i)); JSID_BITS(id) = ((i << 1) | JSID_TYPE_INT); return id; } static JS_ALWAYS_INLINE JSBool JSID_IS_OBJECT(jsid id) { return (JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_OBJECT && (size_t)JSID_BITS(id) != JSID_TYPE_OBJECT; } static JS_ALWAYS_INLINE JSObject * JSID_TO_OBJECT(jsid id) { JS_ASSERT(JSID_IS_OBJECT(id)); return (JSObject *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); } static JS_ALWAYS_INLINE jsid OBJECT_TO_JSID(JSObject *obj) { jsid id; JS_ASSERT(obj != NULL); JS_ASSERT(((size_t)obj & JSID_TYPE_MASK) == 0); JSID_BITS(id) = ((size_t)obj | JSID_TYPE_OBJECT); return id; } static JS_ALWAYS_INLINE JSBool JSID_IS_GCTHING(jsid id) { return JSID_IS_STRING(id) || JSID_IS_OBJECT(id); } static JS_ALWAYS_INLINE void * JSID_TO_GCTHING(jsid id) { return (void *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); } /* * A void jsid is not a valid id and only arises as an exceptional API return * value, such as in JS_NextProperty. Embeddings must not pass JSID_VOID into * JSAPI entry points expecting a jsid and do not need to handle JSID_VOID in * hooks receiving a jsid except when explicitly noted in the API contract. */ static JS_ALWAYS_INLINE JSBool JSID_IS_VOID(const jsid id) { JS_ASSERT_IF(((size_t)JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_VOID, JSID_BITS(id) == JSID_TYPE_VOID); return ((size_t)JSID_BITS(id) == JSID_TYPE_VOID); } static JS_ALWAYS_INLINE JSBool JSID_IS_EMPTY(const jsid id) { return ((size_t)JSID_BITS(id) == JSID_TYPE_OBJECT); } #undef id #ifdef JS_USE_JSID_STRUCT_TYPES extern JS_PUBLIC_DATA(const jsid) JSID_VOID; extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY; #else # define JSID_VOID ((jsid)JSID_TYPE_VOID) # define JSID_EMPTY ((jsid)JSID_TYPE_OBJECT) #endif /* * Returns true iff the given jsval is immune to GC and can be used across * multiple JSRuntimes without requiring any conversion API. */ static JS_ALWAYS_INLINE JSBool JSVAL_IS_UNIVERSAL(jsval v) { return !JSVAL_IS_GCTHING(v); } namespace JS { class AutoIdRooter : private AutoGCRooter { public: explicit AutoIdRooter(JSContext *cx, jsid aId = INT_TO_JSID(0) MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, ID), id_(aId) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } jsid id() { return id_; } jsid * addr() { return &id_; } friend void AutoGCRooter::trace(JSTracer *trc); private: jsid id_; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; } /* namespace JS */ /************************************************************************/ /* Property attributes, set in JSPropertySpec and passed to API functions. */ #define JSPROP_ENUMERATE 0x01 /* property is visible to for/in loop */ #define JSPROP_READONLY 0x02 /* not settable: assignment is no-op. This flag is only valid when neither JSPROP_GETTER nor JSPROP_SETTER is set. */ #define JSPROP_PERMANENT 0x04 /* property cannot be deleted */ #define JSPROP_NATIVE_ACCESSORS 0x08 /* set in JSPropertyDescriptor.flags if getters/setters are JSNatives */ #define JSPROP_GETTER 0x10 /* property holds getter function */ #define JSPROP_SETTER 0x20 /* property holds setter function */ #define JSPROP_SHARED 0x40 /* don't allocate a value slot for this property; don't copy the property on set of the same-named property in an object that delegates to a prototype containing this property */ #define JSPROP_INDEX 0x80 /* name is actually (int) index */ #define JSPROP_SHORTID 0x100 /* set in JS_DefineProperty attrs if getters/setters use a shortid */ #define JSFUN_STUB_GSOPS 0x200 /* use JS_PropertyStub getter/setter instead of defaulting to class gsops for property holding function */ #define JSFUN_CONSTRUCTOR 0x400 /* native that can be called as a ctor */ /* * Specify a generic native prototype methods, i.e., methods of a class * prototype that are exposed as static methods taking an extra leading * argument: the generic |this| parameter. * * If you set this flag in a JSFunctionSpec struct's flags initializer, then * that struct must live at least as long as the native static method object * created due to this flag by JS_DefineFunctions or JS_InitClass. Typically * JSFunctionSpec structs are allocated in static arrays. */ #define JSFUN_GENERIC_NATIVE 0x800 #define JSFUN_FLAGS_MASK 0xe00 /* | of all the JSFUN_* flags */ /* * The first call to JS_CallOnce by any thread in a process will call 'func'. * Later calls to JS_CallOnce with the same JSCallOnceType object will be * suppressed. * * Equivalently: each distinct JSCallOnceType object will allow one JS_CallOnce * to invoke its JSInitCallback. */ extern JS_PUBLIC_API(JSBool) JS_CallOnce(JSCallOnceType *once, JSInitCallback func); /* Microseconds since the epoch, midnight, January 1, 1970 UTC. */ extern JS_PUBLIC_API(int64_t) JS_Now(void); /* Don't want to export data, so provide accessors for non-inline jsvals. */ extern JS_PUBLIC_API(jsval) JS_GetNaNValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetNegativeInfinityValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetPositiveInfinityValue(JSContext *cx); extern JS_PUBLIC_API(jsval) JS_GetEmptyStringValue(JSContext *cx); extern JS_PUBLIC_API(JSString *) JS_GetEmptyString(JSRuntime *rt); /* * Format is a string of the following characters (spaces are insignificant), * specifying the tabulated type conversions: * * b JSBool Boolean * c uint16_t/jschar ECMA uint16_t, Unicode char * i int32_t ECMA int32_t * u uint32_t ECMA uint32_t * j int32_t Rounded int32_t (coordinate) * d double IEEE double * I double Integral IEEE double * S JSString * Unicode string, accessed by a JSString pointer * W jschar * Unicode character vector, 0-terminated (W for wide) * o JSObject * Object reference * f JSFunction * Function private * v jsval Argument value (no conversion) * * N/A Skip this argument (no vararg) * / N/A End of required arguments * * The variable argument list after format must consist of &b, &c, &s, e.g., * where those variables have the types given above. For the pointer types * char *, JSString *, and JSObject *, the pointed-at memory returned belongs * to the JS runtime, not to the calling native code. The runtime promises * to keep this memory valid so long as argv refers to allocated stack space * (so long as the native function is active). * * Fewer arguments than format specifies may be passed only if there is a / * in format after the last required argument specifier and argc is at least * the number of required arguments. More arguments than format specifies * may be passed without error; it is up to the caller to deal with trailing * unconverted arguments. */ extern JS_PUBLIC_API(JSBool) JS_ConvertArguments(JSContext *cx, unsigned argc, jsval *argv, const char *format, ...); #ifdef va_start extern JS_PUBLIC_API(JSBool) JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *format, va_list ap); #endif extern JS_PUBLIC_API(JSBool) JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_ValueToObject(JSContext *cx, jsval v, JSObject **objp); extern JS_PUBLIC_API(JSFunction *) JS_ValueToFunction(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSFunction *) JS_ValueToConstructor(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToString(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSString *) JS_ValueToSource(JSContext *cx, jsval v); extern JS_PUBLIC_API(JSBool) JS_ValueToNumber(JSContext *cx, jsval v, double *dp); namespace js { /* * DO NOT CALL THIS. Use JS::ToNumber */ extern JS_PUBLIC_API(bool) ToNumberSlow(JSContext *cx, JS::Value v, double *dp); /* * DO NOT CALL THIS. Use JS::ToBoolean */ extern JS_PUBLIC_API(bool) ToBooleanSlow(const JS::Value &v); } /* namespace js */ namespace JS { /* ES5 9.3 ToNumber. */ JS_ALWAYS_INLINE bool ToNumber(JSContext *cx, HandleValue v, double *out) { AssertArgumentsAreSane(cx, v); { js::SkipRoot root(cx, &v); js::MaybeCheckStackRoots(cx); } if (v.isNumber()) { *out = v.toNumber(); return true; } return js::ToNumberSlow(cx, v, out); } JS_ALWAYS_INLINE bool ToBoolean(const Value &v) { if (v.isBoolean()) return v.toBoolean(); if (v.isInt32()) return v.toInt32() != 0; if (v.isNullOrUndefined()) return false; if (v.isDouble()) { double d = v.toDouble(); return !mozilla::IsNaN(d) && d != 0; } /* The slow path handles strings and objects. */ return js::ToBooleanSlow(v); } } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_DoubleIsInt32(double d, int32_t *ip); extern JS_PUBLIC_API(int32_t) JS_DoubleToInt32(double d); extern JS_PUBLIC_API(uint32_t) JS_DoubleToUint32(double d); /* * Convert a value to a number, then to an int32_t, according to the ECMA rules * for ToInt32. */ extern JS_PUBLIC_API(JSBool) JS_ValueToECMAInt32(JSContext *cx, jsval v, int32_t *ip); /* * Convert a value to a number, then to an int64_t, according to the WebIDL * rules for ToInt64: http://dev.w3.org/2006/webapi/WebIDL/#es-long-long */ extern JS_PUBLIC_API(JSBool) JS_ValueToInt64(JSContext *cx, jsval v, int64_t *ip); /* * Convert a value to a number, then to an uint64_t, according to the WebIDL * rules for ToUint64: http://dev.w3.org/2006/webapi/WebIDL/#es-unsigned-long-long */ extern JS_PUBLIC_API(JSBool) JS_ValueToUint64(JSContext *cx, jsval v, uint64_t *ip); namespace js { /* DO NOT CALL THIS. Use JS::ToInt16. */ extern JS_PUBLIC_API(bool) ToUint16Slow(JSContext *cx, JS::Handle v, uint16_t *out); /* DO NOT CALL THIS. Use JS::ToInt32. */ extern JS_PUBLIC_API(bool) ToInt32Slow(JSContext *cx, JS::Handle v, int32_t *out); /* DO NOT CALL THIS. Use JS::ToUint32. */ extern JS_PUBLIC_API(bool) ToUint32Slow(JSContext *cx, JS::Handle v, uint32_t *out); /* DO NOT CALL THIS. Use JS::ToInt64. */ extern JS_PUBLIC_API(bool) ToInt64Slow(JSContext *cx, JS::Handle v, int64_t *out); /* DO NOT CALL THIS. Use JS::ToUint64. */ extern JS_PUBLIC_API(bool) ToUint64Slow(JSContext *cx, JS::Handle v, uint64_t *out); } /* namespace js */ namespace JS { JS_ALWAYS_INLINE bool ToUint16(JSContext *cx, JS::Handle v, uint16_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = uint16_t(v.toInt32()); return true; } return js::ToUint16Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToInt32(JSContext *cx, JS::Handle v, int32_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = v.toInt32(); return true; } return js::ToInt32Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToUint32(JSContext *cx, JS::Handle v, uint32_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = uint32_t(v.toInt32()); return true; } return js::ToUint32Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToInt64(JSContext *cx, JS::Handle v, int64_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { *out = int64_t(v.toInt32()); return true; } return js::ToInt64Slow(cx, v, out); } JS_ALWAYS_INLINE bool ToUint64(JSContext *cx, JS::Handle v, uint64_t *out) { AssertArgumentsAreSane(cx, v); js::MaybeCheckStackRoots(cx); if (v.isInt32()) { /* Account for sign extension of negatives into the longer 64bit space. */ *out = uint64_t(int64_t(v.toInt32())); return true; } return js::ToUint64Slow(cx, v, out); } } /* namespace JS */ /* * Convert a value to a number, then to a uint32_t, according to the ECMA rules * for ToUint32. */ extern JS_PUBLIC_API(JSBool) JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32_t *ip); /* * Convert a value to a number, then to an int32_t if it fits by rounding to * nearest; but failing with an error report if the double is out of range * or unordered. */ extern JS_PUBLIC_API(JSBool) JS_ValueToInt32(JSContext *cx, jsval v, int32_t *ip); /* * ECMA ToUint16, for mapping a jsval to a Unicode point. */ extern JS_PUBLIC_API(JSBool) JS_ValueToUint16(JSContext *cx, jsval v, uint16_t *ip); extern JS_PUBLIC_API(JSBool) JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp); extern JS_PUBLIC_API(JSType) JS_TypeOfValue(JSContext *cx, jsval v); extern JS_PUBLIC_API(const char *) JS_GetTypeName(JSContext *cx, JSType type); extern JS_PUBLIC_API(JSBool) JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); extern JS_PUBLIC_API(JSBool) JS_LooselyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal); extern JS_PUBLIC_API(JSBool) JS_SameValue(JSContext *cx, jsval v1, jsval v2, JSBool *same); /* True iff fun is the global eval function. */ extern JS_PUBLIC_API(JSBool) JS_IsBuiltinEvalFunction(JSFunction *fun); /* True iff fun is the Function constructor. */ extern JS_PUBLIC_API(JSBool) JS_IsBuiltinFunctionConstructor(JSFunction *fun); /************************************************************************/ /* * Initialization, locking, contexts, and memory allocation. * * It is important that the first runtime and first context be created in a * single-threaded fashion, otherwise the behavior of the library is undefined. * See: http://developer.mozilla.org/en/docs/Category:JSAPI_Reference */ typedef enum JSUseHelperThreads { JS_NO_HELPER_THREADS, JS_USE_HELPER_THREADS } JSUseHelperThreads; /** * Initialize SpiderMonkey, returning true only if initialization succeeded. * Once this method has succeeded, it is safe to call JS_NewRuntime and other * JSAPI methods. * * This method must be called before any other JSAPI method is used on any * thread. Once it has been used, it is safe to call any JSAPI method, and it * remains safe to do so until JS_ShutDown is correctly called. * * It is currently not possible to initialize SpiderMonkey multiple times (that * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so * again). This restriction may eventually be lifted. */ extern JS_PUBLIC_API(JSBool) JS_Init(void); /** * Destroy free-standing resources allocated by SpiderMonkey, not associated * with any runtime, context, or other structure. * * This method should be called after all other JSAPI data has been properly * cleaned up: every new runtime must have been destroyed, every new context * must have been destroyed, and so on. Calling this method before all other * resources have been destroyed has undefined behavior. * * Failure to call this method, at present, has no adverse effects other than * leaking memory. This may not always be the case; it's recommended that all * embedders call this method when all other JSAPI operations have completed. * * It is currently not possible to initialize SpiderMonkey multiple times (that * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so * again). This restriction may eventually be lifted. */ extern JS_PUBLIC_API(void) JS_ShutDown(void); extern JS_PUBLIC_API(JSRuntime *) JS_NewRuntime(uint32_t maxbytes, JSUseHelperThreads useHelperThreads); extern JS_PUBLIC_API(void) JS_DestroyRuntime(JSRuntime *rt); // These are equivalent to ICU's |UMemAllocFn|, |UMemReallocFn|, and // |UMemFreeFn| types. The first argument (called |context| in the ICU docs) // will always be NULL, and should be ignored. typedef void *(*JS_ICUAllocFn)(const void *, size_t size); typedef void *(*JS_ICUReallocFn)(const void *, void *p, size_t size); typedef void (*JS_ICUFreeFn)(const void *, void *p); // This function can be used to track memory used by ICU. // Do not use it unless you know what you are doing! extern JS_PUBLIC_API(bool) JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn, JS_ICUReallocFn reallocFn, JS_ICUFreeFn freeFn); JS_PUBLIC_API(void *) JS_GetRuntimePrivate(JSRuntime *rt); extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); JS_PUBLIC_API(void) JS_SetRuntimePrivate(JSRuntime *rt, void *data); extern JS_PUBLIC_API(void) JS_BeginRequest(JSContext *cx); extern JS_PUBLIC_API(void) JS_EndRequest(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_IsInRequest(JSRuntime *rt); namespace JS { inline bool IsPoisonedId(jsid iden) { if (JSID_IS_STRING(iden)) return JS::IsPoisonedPtr(JSID_TO_STRING(iden)); if (JSID_IS_OBJECT(iden)) return JS::IsPoisonedPtr(JSID_TO_OBJECT(iden)); return false; } } /* namespace JS */ namespace js { template <> struct GCMethods { static jsid initial() { return JSID_VOID; } static ThingRootKind kind() { return THING_ROOT_ID; } static bool poisoned(jsid id) { return JS::IsPoisonedId(id); } static bool needsPostBarrier(jsid id) { return false; } #ifdef JSGC_GENERATIONAL static void postBarrier(jsid *idp) {} static void relocate(jsid *idp) {} #endif }; } /* namespace js */ class JSAutoRequest { public: JSAutoRequest(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mContext(cx) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; JS_BeginRequest(mContext); } ~JSAutoRequest() { JS_EndRequest(mContext); } protected: JSContext *mContext; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER #if 0 private: static void *operator new(size_t) CPP_THROW_NEW { return 0; }; static void operator delete(void *, size_t) { }; #endif }; class JSAutoCheckRequest { public: JSAutoCheckRequest(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { #if defined JS_THREADSAFE && defined DEBUG mContext = cx; JS_ASSERT(JS_IsInRequest(JS_GetRuntime(cx))); #endif MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~JSAutoCheckRequest() { #if defined JS_THREADSAFE && defined DEBUG JS_ASSERT(JS_IsInRequest(JS_GetRuntime(mContext))); #endif } private: #if defined JS_THREADSAFE && defined DEBUG JSContext *mContext; #endif MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; extern JS_PUBLIC_API(void) JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback, void *data); extern JS_PUBLIC_API(JSContext *) JS_NewContext(JSRuntime *rt, size_t stackChunkSize); extern JS_PUBLIC_API(void) JS_DestroyContext(JSContext *cx); extern JS_PUBLIC_API(void) JS_DestroyContextNoGC(JSContext *cx); extern JS_PUBLIC_API(void *) JS_GetContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetContextPrivate(JSContext *cx, void *data); extern JS_PUBLIC_API(void *) JS_GetSecondContextPrivate(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetSecondContextPrivate(JSContext *cx, void *data); extern JS_PUBLIC_API(JSRuntime *) JS_GetRuntime(JSContext *cx); extern JS_PUBLIC_API(JSContext *) JS_ContextIterator(JSRuntime *rt, JSContext **iterp); extern JS_PUBLIC_API(JSVersion) JS_GetVersion(JSContext *cx); // Mutate the version on the compartment. This is generally discouraged, but // necessary to support the version mutation in the js and xpc shell command // set. // // It would be nice to put this in jsfriendapi, but the linkage requirements // of the shells make that impossible. JS_PUBLIC_API(void) JS_SetVersionForCompartment(JSCompartment *compartment, JSVersion version); extern JS_PUBLIC_API(const char *) JS_VersionToString(JSVersion version); extern JS_PUBLIC_API(JSVersion) JS_StringToVersion(const char *string); /* * JS options are orthogonal to version, and may be freely composed with one * another as well as with version. * * JSOPTION_VAROBJFIX is recommended -- see the comments associated with the * prototypes for JS_ExecuteScript, JS_EvaluateScript, etc. */ #define JSOPTION_EXTRA_WARNINGS JS_BIT(0) /* warn on dubious practices */ #define JSOPTION_WERROR JS_BIT(1) /* convert warning to error */ #define JSOPTION_VAROBJFIX JS_BIT(2) /* make JS_EvaluateScript use the last object on its 'obj' param's scope chain as the ECMA 'variables object' */ #define JSOPTION_PRIVATE_IS_NSISUPPORTS \ JS_BIT(3) /* context private data points to an nsISupports subclass */ #define JSOPTION_COMPILE_N_GO JS_BIT(4) /* caller of JS_Compile*Script promises to execute compiled script once only; enables compile-time scope chain resolution of consts. */ /* JS_BIT(5) is currently unused. */ /* JS_BIT(6) is currently unused. */ /* JS_BIT(7) is currently unused. */ #define JSOPTION_DONT_REPORT_UNCAUGHT \ JS_BIT(8) /* When returning from the outermost API call, prevent uncaught exceptions from being converted to error reports */ /* JS_BIT(9) is currently unused. */ /* JS_BIT(10) is currently unused. */ /* JS_BIT(11) is currently unused. */ #define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12) /* A promise to the compiler that a null rval out-param will be passed to each call to JS_ExecuteScript. */ #define JSOPTION_UNROOTED_GLOBAL JS_BIT(13) /* The GC will not root the contexts' default compartment object, leaving that up to the embedding. */ #define JSOPTION_BASELINE JS_BIT(14) /* Baseline compiler. */ #define JSOPTION_TYPE_INFERENCE JS_BIT(16) /* Perform type inference. */ #define JSOPTION_STRICT_MODE JS_BIT(17) /* Provides a way to force strict mode for all code without requiring "use strict" annotations. */ #define JSOPTION_ION JS_BIT(18) /* IonMonkey */ #define JSOPTION_ASMJS JS_BIT(19) /* optimizingasm.js compiler */ #define JSOPTION_MASK JS_BITMASK(20) extern JS_PUBLIC_API(uint32_t) JS_GetOptions(JSContext *cx); extern JS_PUBLIC_API(uint32_t) JS_SetOptions(JSContext *cx, uint32_t options); extern JS_PUBLIC_API(uint32_t) JS_ToggleOptions(JSContext *cx, uint32_t options); extern JS_PUBLIC_API(void) JS_SetJitHardening(JSRuntime *rt, JSBool enabled); extern JS_PUBLIC_API(const char *) JS_GetImplementationVersion(void); extern JS_PUBLIC_API(void) JS_SetDestroyCompartmentCallback(JSRuntime *rt, JSDestroyCompartmentCallback callback); extern JS_PUBLIC_API(void) JS_SetCompartmentNameCallback(JSRuntime *rt, JSCompartmentNameCallback callback); extern JS_PUBLIC_API(JSWrapObjectCallback) JS_SetWrapObjectCallbacks(JSRuntime *rt, JSWrapObjectCallback callback, JSSameCompartmentWrapObjectCallback sccallback, JSPreWrapCallback precallback); extern JS_PUBLIC_API(void) JS_SetCompartmentPrivate(JSCompartment *compartment, void *data); extern JS_PUBLIC_API(void *) JS_GetCompartmentPrivate(JSCompartment *compartment); extern JS_PUBLIC_API(JSBool) JS_WrapObject(JSContext *cx, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_WrapValue(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_WrapId(JSContext *cx, jsid *idp); extern JS_PUBLIC_API(JSObject *) JS_TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target); extern JS_FRIEND_API(JSObject *) js_TransplantObjectWithWrapper(JSContext *cx, JS::HandleObject origobj, JS::HandleObject origwrapper, JS::HandleObject targetobj, JS::HandleObject targetwrapper); extern JS_PUBLIC_API(JSBool) JS_RefreshCrossCompartmentWrappers(JSContext *cx, JSObject *ob); /* * At any time, a JSContext has a current (possibly-NULL) compartment. * Compartments are described in: * * developer.mozilla.org/en-US/docs/SpiderMonkey/SpiderMonkey_compartments * * The current compartment of a context may be changed. The preferred way to do * this is with JSAutoCompartment: * * void foo(JSContext *cx, JSObject *obj) { * // in some compartment 'c' * { * JSAutoCompartment ac(cx, obj); // constructor enters * // in the compartment of 'obj' * } // destructor leaves * // back in compartment 'c' * } * * For more complicated uses that don't neatly fit in a C++ stack frame, the * compartment can entered and left using separate function calls: * * void foo(JSContext *cx, JSObject *obj) { * // in 'oldCompartment' * JSCompartment *oldCompartment = JS_EnterCompartment(cx, obj); * // in the compartment of 'obj' * JS_LeaveCompartment(cx, oldCompartment); * // back in 'oldCompartment' * } * * Note: these calls must still execute in a LIFO manner w.r.t all other * enter/leave calls on the context. Furthermore, only the return value of a * JS_EnterCompartment call may be passed as the 'oldCompartment' argument of * the corresponding JS_LeaveCompartment call. */ class JS_PUBLIC_API(JSAutoCompartment) { JSContext *cx_; JSCompartment *oldCompartment_; public: JSAutoCompartment(JSContext *cx, JSObject *target); JSAutoCompartment(JSContext *cx, JSScript *target); ~JSAutoCompartment(); }; /* NB: This API is infallible; a NULL return value does not indicate error. */ extern JS_PUBLIC_API(JSCompartment *) JS_EnterCompartment(JSContext *cx, JSObject *target); extern JS_PUBLIC_API(void) JS_LeaveCompartment(JSContext *cx, JSCompartment *oldCompartment); typedef void (*JSIterateCompartmentCallback)(JSRuntime *rt, void *data, JSCompartment *compartment); /* * This function calls |compartmentCallback| on every compartment. Beware that * there is no guarantee that the compartment will survive after the callback * returns. */ extern JS_PUBLIC_API(void) JS_IterateCompartments(JSRuntime *rt, void *data, JSIterateCompartmentCallback compartmentCallback); /* * Initialize standard JS class constructors, prototypes, and any top-level * functions and constants associated with the standard classes (e.g. isNaN * for Number). * * NB: This sets cx's global object to obj if it was null. */ extern JS_PUBLIC_API(JSBool) JS_InitStandardClasses(JSContext *cx, JSObject *obj); /* * Resolve id, which must contain either a string or an int, to a standard * class name in obj if possible, defining the class's constructor and/or * prototype and storing true in *resolved. If id does not name a standard * class or a top-level property induced by initializing a standard class, * store false in *resolved and just return true. Return false on error, * as usual for JSBool result-typed API entry points. * * This API can be called directly from a global object class's resolve op, * to define standard classes lazily. The class's enumerate op should call * JS_EnumerateStandardClasses(cx, obj), to define eagerly during for..in * loops any classes not yet resolved lazily. */ extern JS_PUBLIC_API(JSBool) JS_ResolveStandardClass(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool *resolved); extern JS_PUBLIC_API(JSBool) JS_EnumerateStandardClasses(JSContext *cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSBool) JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSBool) JS_GetClassPrototype(JSContext *cx, JSProtoKey key, JSObject **objp); extern JS_PUBLIC_API(JSProtoKey) JS_IdentifyClassPrototype(JSContext *cx, JSObject *obj); /* * Returns the original value of |Function.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetFunctionPrototype(JSContext *cx, JSObject *forObj); /* * Returns the original value of |Object.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetObjectPrototype(JSContext *cx, JSObject *forObj); /* * Returns the original value of |Array.prototype| from the global object in * which |forObj| was created. */ extern JS_PUBLIC_API(JSObject *) JS_GetArrayPrototype(JSContext *cx, JSObject *forObj); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_IsGlobalObject(JSObject *obj); /* * May return NULL, if |c| never had a global (e.g. the atoms compartment), or * if |c|'s global has been collected. */ extern JS_PUBLIC_API(JSObject *) JS_GetGlobalForCompartmentOrNull(JSContext *cx, JSCompartment *c); namespace JS { extern JS_PUBLIC_API(JSObject *) CurrentGlobalOrNull(JSContext *cx); } /* * This method returns the global corresponding to the most recent scripted * frame, which may not match the cx's current compartment. This is extremely * dangerous, because it can bypass compartment security invariants in subtle * ways. To use it safely, the caller must perform a subsequent security * check. There is currently only one consumer of this function in Gecko, and * it should probably stay that way. If you'd like to use it, please consult * the XPConnect module owner first. */ extern JS_PUBLIC_API(JSObject *) JS_GetScriptedGlobal(JSContext *cx); /* * Initialize the 'Reflect' object on a global object. */ extern JS_PUBLIC_API(JSObject *) JS_InitReflect(JSContext *cx, JSObject *global); #ifdef JS_HAS_CTYPES /* * Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes' * object will be sealed. */ extern JS_PUBLIC_API(JSBool) JS_InitCTypesClass(JSContext *cx, JSObject *global); /* * Convert a unicode string 'source' of length 'slen' to the platform native * charset, returning a null-terminated string allocated with JS_malloc. On * failure, this function should report an error. */ typedef char * (* JSCTypesUnicodeToNativeFun)(JSContext *cx, const jschar *source, size_t slen); /* * Set of function pointers that ctypes can use for various internal functions. * See JS_SetCTypesCallbacks below. Providing NULL for a function is safe, * and will result in the applicable ctypes functionality not being available. */ struct JSCTypesCallbacks { JSCTypesUnicodeToNativeFun unicodeToNative; }; typedef struct JSCTypesCallbacks JSCTypesCallbacks; /* * Set the callbacks on the provided 'ctypesObj' object. 'callbacks' should be a * pointer to static data that exists for the lifetime of 'ctypesObj', but it * may safely be altered after calling this function and without having * to call this function again. */ extern JS_PUBLIC_API(void) JS_SetCTypesCallbacks(JSObject *ctypesObj, JSCTypesCallbacks *callbacks); #endif typedef JSBool (* JSEnumerateDiagnosticMemoryCallback)(void *ptr, size_t length); /* * Enumerate memory regions that contain diagnostic information * intended to be included in crash report minidumps. */ extern JS_PUBLIC_API(void) JS_EnumerateDiagnosticMemoryRegions(JSEnumerateDiagnosticMemoryCallback callback); extern JS_PUBLIC_API(void *) JS_malloc(JSContext *cx, size_t nbytes); extern JS_PUBLIC_API(void *) JS_realloc(JSContext *cx, void *p, size_t nbytes); /* * A wrapper for js_free(p) that may delay js_free(p) invocation as a * performance optimization. * cx may be NULL. */ extern JS_PUBLIC_API(void) JS_free(JSContext *cx, void *p); /* * A wrapper for js_free(p) that may delay js_free(p) invocation as a * performance optimization as specified by the given JSFreeOp instance. */ extern JS_PUBLIC_API(void) JS_freeop(JSFreeOp *fop, void *p); extern JS_PUBLIC_API(JSFreeOp *) JS_GetDefaultFreeOp(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_updateMallocCounter(JSContext *cx, size_t nbytes); extern JS_PUBLIC_API(char *) JS_strdup(JSContext *cx, const char *s); /* Duplicate a string. Does not report an error on failure. */ extern JS_PUBLIC_API(char *) JS_strdup(JSRuntime *rt, const char *s); /* * A GC root is a pointer to a jsval, JSObject * or JSString * that itself * points into the GC heap. JS_AddValueRoot takes a pointer to a jsval and * JS_AddGCThingRoot takes a pointer to a JSObject * or JString *. * * Note that, since JS_Add*Root stores the address of a variable (of type * jsval, JSString *, or JSObject *), that variable must live until * JS_Remove*Root is called to remove that variable. For example, after: * * void some_function() { * jsval v; * JS_AddNamedValueRoot(cx, &v, "name"); * * the caller must perform * * JS_RemoveValueRoot(cx, &v); * * before some_function() returns. * * Also, use JS_AddNamed*Root(cx, &structPtr->memberObj, "structPtr->memberObj") * in preference to JS_Add*Root(cx, &structPtr->memberObj), in order to identify * roots by their source callsites. This way, you can find the callsite while * debugging if you should fail to do JS_Remove*Root(cx, &structPtr->memberObj) * before freeing structPtr's memory. */ extern JS_PUBLIC_API(JSBool) JS_AddValueRoot(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_AddStringRoot(JSContext *cx, JSString **rp); extern JS_PUBLIC_API(JSBool) JS_AddObjectRoot(JSContext *cx, JSObject **rp); #ifdef NAME_ALL_GC_ROOTS #define JS_DEFINE_TO_TOKEN(def) #def #define JS_DEFINE_TO_STRING(def) JS_DEFINE_TO_TOKEN(def) #define JS_AddValueRoot(cx,vp) JS_AddNamedValueRoot((cx), (vp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #define JS_AddStringRoot(cx,rp) JS_AddNamedStringRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #define JS_AddObjectRoot(cx,rp) JS_AddNamedObjectRoot((cx), (rp), (__FILE__ ":" JS_TOKEN_TO_STRING(__LINE__)) #endif extern JS_PUBLIC_API(JSBool) JS_AddNamedValueRoot(JSContext *cx, jsval *vp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedValueRootRT(JSRuntime *rt, jsval *vp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedStringRoot(JSContext *cx, JSString **rp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedObjectRoot(JSContext *cx, JSObject **rp, const char *name); extern JS_PUBLIC_API(JSBool) JS_AddNamedScriptRoot(JSContext *cx, JSScript **rp, const char *name); extern JS_PUBLIC_API(void) JS_RemoveValueRoot(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(void) JS_RemoveStringRoot(JSContext *cx, JSString **rp); extern JS_PUBLIC_API(void) JS_RemoveObjectRoot(JSContext *cx, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRoot(JSContext *cx, JSScript **rp); extern JS_PUBLIC_API(void) JS_RemoveValueRootRT(JSRuntime *rt, jsval *vp); extern JS_PUBLIC_API(void) JS_RemoveStringRootRT(JSRuntime *rt, JSString **rp); extern JS_PUBLIC_API(void) JS_RemoveObjectRootRT(JSRuntime *rt, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRootRT(JSRuntime *rt, JSScript **rp); /* TODO: remove these APIs */ extern JS_FRIEND_API(void) js_RemoveRoot(JSRuntime *rt, void *rp); /* * C-compatible version of the Anchor class. It should be called after the last * use of the variable it protects. */ extern JS_NEVER_INLINE JS_PUBLIC_API(void) JS_AnchorPtr(void *p); /* * Register externally maintained GC roots. * * traceOp: the trace operation. For each root the implementation should call * JS_CallTracer whenever the root contains a traceable thing. * data: the data argument to pass to each invocation of traceOp. */ extern JS_PUBLIC_API(JSBool) JS_AddExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); /* Undo a call to JS_AddExtraGCRootsTracer. */ extern JS_PUBLIC_API(void) JS_RemoveExtraGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); /* * JS_CallTracer API and related macros for implementors of JSTraceOp, to * enumerate all references to traceable things reachable via a property or * other strong ref identified for debugging purposes by name or index or * a naming callback. * * See the JSTraceOp typedef. */ /* * Use the following macros to check if a particular jsval is a traceable * thing and to extract the thing and its kind to pass to JS_CallTracer. */ static JS_ALWAYS_INLINE JSBool JSVAL_IS_TRACEABLE(jsval v) { return JSVAL_IS_TRACEABLE_IMPL(JSVAL_TO_IMPL(v)); } static JS_ALWAYS_INLINE void * JSVAL_TO_TRACEABLE(jsval v) { return JSVAL_TO_GCTHING(v); } static JS_ALWAYS_INLINE JSGCTraceKind JSVAL_TRACE_KIND(jsval v) { JS_ASSERT(JSVAL_IS_GCTHING(v)); return (JSGCTraceKind) JSVAL_TRACE_KIND_IMPL(JSVAL_TO_IMPL(v)); } /* * Tracer callback, called for each traceable thing directly referenced by a * particular object or runtime structure. It is the callback responsibility * to ensure the traversal of the full object graph via calling eventually * JS_TraceChildren on the passed thing. In this case the callback must be * prepared to deal with cycles in the traversal graph. * * kind argument is one of JSTRACE_OBJECT, JSTRACE_STRING or a tag denoting * internal implementation-specific traversal kind. In the latter case the only * operations on thing that the callback can do is to call JS_TraceChildren or * JS_GetTraceThingInfo. * * If eagerlyTraceWeakMaps is true, when we trace a WeakMap visit all * of its mappings. This should be used in cases where the tracer * wants to use the existing liveness of entries. */ typedef void (* JSTraceCallback)(JSTracer *trc, void **thingp, JSGCTraceKind kind); enum WeakMapTraceKind { DoNotTraceWeakMaps = 0, TraceWeakMapValues = 1, TraceWeakMapKeysValues = 2 }; struct JSTracer { JSRuntime *runtime; JSTraceCallback callback; JSTraceNamePrinter debugPrinter; const void *debugPrintArg; size_t debugPrintIndex; WeakMapTraceKind eagerlyTraceWeakMaps; #ifdef JS_GC_ZEAL void *realLocation; #endif }; /* * Set debugging information about a reference to a traceable thing to prepare * for the following call to JS_CallTracer. * * When printer is null, arg must be const char * or char * C string naming * the reference and index must be either (size_t)-1 indicating that the name * alone describes the reference or it must be an index into some array vector * that stores the reference. * * When printer callback is not null, the arg and index arguments are * available to the callback as debugPrintArg and debugPrintIndex fields * of JSTracer. * * The storage for name or callback's arguments needs to live only until * the following call to JS_CallTracer returns. */ # define JS_SET_TRACING_DETAILS(trc, printer, arg, index) \ JS_BEGIN_MACRO \ (trc)->debugPrinter = (printer); \ (trc)->debugPrintArg = (arg); \ (trc)->debugPrintIndex = (index); \ JS_END_MACRO /* * Sets the real location for a marked reference, when passing the address * directly is not feasable. * * FIXME: This is currently overcomplicated by our need to nest calls for Values * stored as keys in hash tables, but will get simplified once we can rekey * in-place. */ #ifdef JS_GC_ZEAL # define JS_SET_TRACING_LOCATION(trc, location) \ JS_BEGIN_MACRO \ if (!(trc)->realLocation || !(location)) \ (trc)->realLocation = (location); \ JS_END_MACRO # define JS_UNSET_TRACING_LOCATION(trc) \ JS_BEGIN_MACRO \ (trc)->realLocation = NULL; \ JS_END_MACRO #else # define JS_SET_TRACING_LOCATION(trc, location) \ JS_BEGIN_MACRO \ JS_END_MACRO # define JS_UNSET_TRACING_LOCATION(trc) \ JS_BEGIN_MACRO \ JS_END_MACRO #endif /* * Convenience macro to describe the argument of JS_CallTracer using C string * and index. */ # define JS_SET_TRACING_INDEX(trc, name, index) \ JS_SET_TRACING_DETAILS(trc, NULL, name, index) /* * Convenience macro to describe the argument of JS_CallTracer using C string. */ # define JS_SET_TRACING_NAME(trc, name) \ JS_SET_TRACING_DETAILS(trc, NULL, name, (size_t)-1) /* * The JS_Call*Tracer family of functions traces the given GC thing reference. * This performs the tracing action configured on the given JSTracer: * typically calling the JSTracer::callback or marking the thing as live. * * The argument to JS_Call*Tracer is an in-out param: when the function * returns, the garbage collector might have moved the GC thing. In this case, * the reference passed to JS_Call*Tracer will be updated to the object's new * location. Callers of this method are responsible for updating any state * that is dependent on the object's address. For example, if the object's * address is used as a key in a hashtable, then the object must be removed * and re-inserted with the correct hash. */ extern JS_PUBLIC_API(void) JS_CallValueTracer(JSTracer *trc, JS::Value *valuep, const char *name); extern JS_PUBLIC_API(void) JS_CallIdTracer(JSTracer *trc, jsid *idp, const char *name); extern JS_PUBLIC_API(void) JS_CallObjectTracer(JSTracer *trc, JSObject **objp, const char *name); extern JS_PUBLIC_API(void) JS_CallStringTracer(JSTracer *trc, JSString **strp, const char *name); extern JS_PUBLIC_API(void) JS_CallScriptTracer(JSTracer *trc, JSScript **scriptp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapValueTracer(JSTracer *trc, JS::Heap *valuep, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapIdTracer(JSTracer *trc, JS::Heap *idp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapObjectTracer(JSTracer *trc, JS::Heap *objp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapStringTracer(JSTracer *trc, JS::Heap *strp, const char *name); extern JS_PUBLIC_API(void) JS_CallHeapScriptTracer(JSTracer *trc, JS::Heap *scriptp, const char *name); template inline void JS_CallHashSetObjectTracer(JSTracer *trc, HashSetEnum &e, JSObject *const &key, const char *name) { JSObject *updated = key; JS_SET_TRACING_LOCATION(trc, reinterpret_cast(&const_cast(key))); JS_CallObjectTracer(trc, &updated, name); if (updated != key) e.rekeyFront(key, updated); } /* * Trace an object that is known to always be tenured. No post barriers are * required in this case. */ extern JS_PUBLIC_API(void) JS_CallTenuredObjectTracer(JSTracer *trc, JS::TenuredHeap *objp, const char *name); /* * API for JSTraceCallback implementations. */ extern JS_PUBLIC_API(void) JS_TracerInit(JSTracer *trc, JSRuntime *rt, JSTraceCallback callback); extern JS_PUBLIC_API(void) JS_TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind); extern JS_PUBLIC_API(void) JS_TraceRuntime(JSTracer *trc); extern JS_PUBLIC_API(void) JS_GetTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing, JSGCTraceKind kind, JSBool includeDetails); extern JS_PUBLIC_API(const char *) JS_GetTraceEdgeName(JSTracer *trc, char *buffer, int bufferSize); #ifdef DEBUG /* * DEBUG-only method to dump the object graph of heap-allocated things. * * fp: file for the dump output. * start: when non-null, dump only things reachable from start * thing. Otherwise dump all things reachable from the * runtime roots. * startKind: trace kind of start if start is not null. Must be * JSTRACE_OBJECT when start is null. * thingToFind: dump only paths in the object graph leading to thingToFind * when non-null. * maxDepth: the upper bound on the number of edges to descend from the * graph roots. * thingToIgnore: thing to ignore during the graph traversal when non-null. */ extern JS_PUBLIC_API(JSBool) JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind kind, void *thingToFind, size_t maxDepth, void *thingToIgnore); #endif /* * Garbage collector API. */ extern JS_PUBLIC_API(void) JS_GC(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_MaybeGC(JSContext *cx); extern JS_PUBLIC_API(void) JS_SetGCCallback(JSRuntime *rt, JSGCCallback cb, void *data); extern JS_PUBLIC_API(void) JS_SetFinalizeCallback(JSRuntime *rt, JSFinalizeCallback cb); extern JS_PUBLIC_API(JSBool) JS_IsGCMarkingTracer(JSTracer *trc); /* * JS_IsAboutToBeFinalized checks if the given object is going to be finalized * at the end of the current GC. When called outside of the context of a GC, * this function will return false. Typically this function is used on weak * references, where the reference should be nulled out or destroyed if the * given object is about to be finalized. * * The argument to JS_IsAboutToBeFinalized is an in-out param: when the * function returns false, the object being referenced is still alive, but the * garbage collector might have moved it. In this case, the reference passed * to JS_IsAboutToBeFinalized will be updated to the object's new location. * Callers of this method are responsible for updating any state that is * dependent on the object's address. For example, if the object's address is * used as a key in a hashtable, then the object must be removed and * re-inserted with the correct hash. */ extern JS_PUBLIC_API(JSBool) JS_IsAboutToBeFinalized(JS::Heap *objp); extern JS_PUBLIC_API(JSBool) JS_IsAboutToBeFinalizedUnbarriered(JSObject **objp); typedef enum JSGCParamKey { /* Maximum nominal heap before last ditch GC. */ JSGC_MAX_BYTES = 0, /* Number of JS_malloc bytes before last ditch GC. */ JSGC_MAX_MALLOC_BYTES = 1, /* Amount of bytes allocated by the GC. */ JSGC_BYTES = 3, /* Number of times when GC was invoked. */ JSGC_NUMBER = 4, /* Max size of the code cache in bytes. */ JSGC_MAX_CODE_CACHE_BYTES = 5, /* Select GC mode. */ JSGC_MODE = 6, /* Number of cached empty GC chunks. */ JSGC_UNUSED_CHUNKS = 7, /* Total number of allocated GC chunks. */ JSGC_TOTAL_CHUNKS = 8, /* Max milliseconds to spend in an incremental GC slice. */ JSGC_SLICE_TIME_BUDGET = 9, /* Maximum size the GC mark stack can grow to. */ JSGC_MARK_STACK_LIMIT = 10, /* * GCs less than this far apart in time will be considered 'high-frequency GCs'. * See setGCLastBytes in jsgc.cpp. */ JSGC_HIGH_FREQUENCY_TIME_LIMIT = 11, /* Start of dynamic heap growth. */ JSGC_HIGH_FREQUENCY_LOW_LIMIT = 12, /* End of dynamic heap growth. */ JSGC_HIGH_FREQUENCY_HIGH_LIMIT = 13, /* Upper bound of heap growth. */ JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX = 14, /* Lower bound of heap growth. */ JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN = 15, /* Heap growth for low frequency GCs. */ JSGC_LOW_FREQUENCY_HEAP_GROWTH = 16, /* * If false, the heap growth factor is fixed at 3. If true, it is determined * based on whether GCs are high- or low- frequency. */ JSGC_DYNAMIC_HEAP_GROWTH = 17, /* If true, high-frequency GCs will use a longer mark slice. */ JSGC_DYNAMIC_MARK_SLICE = 18, /* Number of megabytes of analysis data to allocate before purging. */ JSGC_ANALYSIS_PURGE_TRIGGER = 19, /* Lower limit after which we limit the heap growth. */ JSGC_ALLOCATION_THRESHOLD = 20, /* * We decommit memory lazily. If more than this number of megabytes is * available to be decommitted, then JS_MaybeGC will trigger a shrinking GC * to decommit it. */ JSGC_DECOMMIT_THRESHOLD = 21 } JSGCParamKey; typedef enum JSGCMode { /* Perform only global GCs. */ JSGC_MODE_GLOBAL = 0, /* Perform per-compartment GCs until too much garbage has accumulated. */ JSGC_MODE_COMPARTMENT = 1, /* * Collect in short time slices rather than all at once. Implies * JSGC_MODE_COMPARTMENT. */ JSGC_MODE_INCREMENTAL = 2 } JSGCMode; extern JS_PUBLIC_API(void) JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32_t value); extern JS_PUBLIC_API(uint32_t) JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key); extern JS_PUBLIC_API(void) JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32_t value); extern JS_PUBLIC_API(uint32_t) JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key); /* * Create a new JSString whose chars member refers to external memory, i.e., * memory requiring application-specific finalization. */ extern JS_PUBLIC_API(JSString *) JS_NewExternalString(JSContext *cx, const jschar *chars, size_t length, const JSStringFinalizer *fin); /* * Return whether 'str' was created with JS_NewExternalString or * JS_NewExternalStringWithClosure. */ extern JS_PUBLIC_API(JSBool) JS_IsExternalString(JSString *str); /* * Return the 'closure' arg passed to JS_NewExternalStringWithClosure or NULL * if the external string was created via JS_NewExternalString. */ extern JS_PUBLIC_API(const JSStringFinalizer *) JS_GetExternalStringFinalizer(JSString *str); /* * Set the size of the native stack that should not be exceed. To disable * stack size checking pass 0. */ extern JS_PUBLIC_API(void) JS_SetNativeStackQuota(JSRuntime *cx, size_t stackSize); /************************************************************************/ /* * Classes, objects, and properties. */ typedef void (*JSClassInternal)(); struct JSClass { const char *name; uint32_t flags; /* Mandatory function pointer members. */ JSPropertyOp addProperty; JSDeletePropertyOp delProperty; JSPropertyOp getProperty; JSStrictPropertyOp setProperty; JSEnumerateOp enumerate; JSResolveOp resolve; JSConvertOp convert; /* Optional members (may be null). */ JSFinalizeOp finalize; JSCheckAccessOp checkAccess; JSNative call; JSHasInstanceOp hasInstance; JSNative construct; JSTraceOp trace; void *reserved[40]; }; #define JSCLASS_HAS_PRIVATE (1<<0) /* objects have private slot */ #define JSCLASS_NEW_ENUMERATE (1<<1) /* has JSNewEnumerateOp hook */ #define JSCLASS_NEW_RESOLVE (1<<2) /* has JSNewResolveOp hook */ #define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) /* private is (nsISupports *) */ #define JSCLASS_IS_DOMJSCLASS (1<<4) /* objects are DOM */ #define JSCLASS_IMPLEMENTS_BARRIERS (1<<5) /* Correctly implements GC read and write barriers */ #define JSCLASS_EMULATES_UNDEFINED (1<<6) /* objects of this class act like the value undefined, in some contexts */ #define JSCLASS_USERBIT1 (1<<7) /* Reserved for embeddings. */ /* * To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise-or * JSCLASS_HAS_RESERVED_SLOTS(n) into the initializer for JSClass.flags, where * n is a constant in [1, 255]. Reserved slots are indexed from 0 to n-1. */ #define JSCLASS_RESERVED_SLOTS_SHIFT 8 /* room for 8 flags below */ #define JSCLASS_RESERVED_SLOTS_WIDTH 8 /* and 16 above this field */ #define JSCLASS_RESERVED_SLOTS_MASK JS_BITMASK(JSCLASS_RESERVED_SLOTS_WIDTH) #define JSCLASS_HAS_RESERVED_SLOTS(n) (((n) & JSCLASS_RESERVED_SLOTS_MASK) \ << JSCLASS_RESERVED_SLOTS_SHIFT) #define JSCLASS_RESERVED_SLOTS(clasp) (((clasp)->flags \ >> JSCLASS_RESERVED_SLOTS_SHIFT) \ & JSCLASS_RESERVED_SLOTS_MASK) #define JSCLASS_HIGH_FLAGS_SHIFT (JSCLASS_RESERVED_SLOTS_SHIFT + \ JSCLASS_RESERVED_SLOTS_WIDTH) #define JSCLASS_IS_ANONYMOUS (1<<(JSCLASS_HIGH_FLAGS_SHIFT+0)) #define JSCLASS_IS_GLOBAL (1<<(JSCLASS_HIGH_FLAGS_SHIFT+1)) #define JSCLASS_INTERNAL_FLAG2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2)) #define JSCLASS_INTERNAL_FLAG3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+3)) /* Indicate whether the proto or ctor should be frozen. */ #define JSCLASS_FREEZE_PROTO (1<<(JSCLASS_HIGH_FLAGS_SHIFT+4)) #define JSCLASS_FREEZE_CTOR (1<<(JSCLASS_HIGH_FLAGS_SHIFT+5)) /* Reserved for embeddings. */ #define JSCLASS_USERBIT2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+6)) #define JSCLASS_USERBIT3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+7)) #define JSCLASS_BACKGROUND_FINALIZE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+8)) /* * Bits 26 through 31 are reserved for the CACHED_PROTO_KEY mechanism, see * below. */ /* Global flags. */ #define JSGLOBAL_FLAGS_CLEARED 0x1 /* * ECMA-262 requires that most constructors used internally create objects * with "the original Foo.prototype value" as their [[Prototype]] (__proto__) * member initial value. The "original ... value" verbiage is there because * in ECMA-262, global properties naming class objects are read/write and * deleteable, for the most part. * * Implementing this efficiently requires that global objects have classes * with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS was * prevously allowed, but is now an ES5 violation and thus unsupported. */ #define JSCLASS_GLOBAL_SLOT_COUNT (JSProto_LIMIT * 3 + 25) #define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \ (JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n))) #define JSCLASS_GLOBAL_FLAGS \ JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(0) #define JSCLASS_HAS_GLOBAL_FLAG_AND_SLOTS(clasp) \ (((clasp)->flags & JSCLASS_IS_GLOBAL) \ && JSCLASS_RESERVED_SLOTS(clasp) >= JSCLASS_GLOBAL_SLOT_COUNT) /* Fast access to the original value of each standard class's prototype. */ #define JSCLASS_CACHED_PROTO_SHIFT (JSCLASS_HIGH_FLAGS_SHIFT + 10) #define JSCLASS_CACHED_PROTO_WIDTH 6 #define JSCLASS_CACHED_PROTO_MASK JS_BITMASK(JSCLASS_CACHED_PROTO_WIDTH) #define JSCLASS_HAS_CACHED_PROTO(key) (uint32_t(key) << JSCLASS_CACHED_PROTO_SHIFT) #define JSCLASS_CACHED_PROTO_KEY(clasp) ((JSProtoKey) \ (((clasp)->flags \ >> JSCLASS_CACHED_PROTO_SHIFT) \ & JSCLASS_CACHED_PROTO_MASK)) /* Initializer for unused members of statically initialized JSClass structs. */ #define JSCLASS_NO_INTERNAL_MEMBERS {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} #define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,JSCLASS_NO_INTERNAL_MEMBERS extern JS_PUBLIC_API(int) JS_IdArrayLength(JSContext *cx, JSIdArray *ida); extern JS_PUBLIC_API(jsid) JS_IdArrayGet(JSContext *cx, JSIdArray *ida, int index); extern JS_PUBLIC_API(void) JS_DestroyIdArray(JSContext *cx, JSIdArray *ida); namespace JS { class AutoIdArray : private AutoGCRooter { public: AutoIdArray(JSContext *cx, JSIdArray *ida MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, IDARRAY), context(cx), idArray(ida) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~AutoIdArray() { if (idArray) JS_DestroyIdArray(context, idArray); } bool operator!() { return !idArray; } jsid operator[](size_t i) const { JS_ASSERT(idArray); JS_ASSERT(i < length()); return JS_IdArrayGet(context, idArray, i); } size_t length() const { return JS_IdArrayLength(context, idArray); } friend void AutoGCRooter::trace(JSTracer *trc); JSIdArray *steal() { JSIdArray *copy = idArray; idArray = NULL; return copy; } protected: inline void trace(JSTracer *trc); private: JSContext *context; JSIdArray *idArray; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER /* No copy or assignment semantics. */ AutoIdArray(AutoIdArray &ida) MOZ_DELETE; void operator=(AutoIdArray &ida) MOZ_DELETE; }; } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_ValueToId(JSContext *cx, jsval v, jsid *idp); extern JS_PUBLIC_API(JSBool) JS_IdToValue(JSContext *cx, jsid id, jsval *vp); /* * JSNewResolveOp flag bits. */ #define JSRESOLVE_ASSIGNING 0x01 /* resolve on the left of assignment */ /* * Invoke the [[DefaultValue]] hook (see ES5 8.6.2) with the provided hint on * the specified object, computing a primitive default value for the object. * The hint must be JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_VOID (no hint). On * success the resulting value is stored in *vp. */ extern JS_PUBLIC_API(JSBool) JS_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_PropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_StrictPropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool strict, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyStub(JSContext *cx, JS::Handle obj, JS::Handle id, JSBool *succeeded); extern JS_PUBLIC_API(JSBool) JS_EnumerateStub(JSContext *cx, JS::Handle obj); extern JS_PUBLIC_API(JSBool) JS_ResolveStub(JSContext *cx, JS::Handle obj, JS::Handle id); extern JS_PUBLIC_API(JSBool) JS_ConvertStub(JSContext *cx, JS::Handle obj, JSType type, JS::MutableHandle vp); struct JSConstDoubleSpec { double dval; const char *name; uint8_t flags; uint8_t spare[3]; }; typedef struct JSJitInfo JSJitInfo; /* * Wrappers to replace {Strict,}PropertyOp for JSPropertySpecs. This will allow * us to pass one JSJitInfo per function with the property spec, without * additional field overhead. */ typedef struct JSStrictPropertyOpWrapper { JSStrictPropertyOp op; const JSJitInfo *info; } JSStrictPropertyOpWrapper; typedef struct JSPropertyOpWrapper { JSPropertyOp op; const JSJitInfo *info; } JSPropertyOpWrapper; /* * Wrapper to do as above, but for JSNatives for JSFunctionSpecs. */ typedef struct JSNativeWrapper { JSNative op; const JSJitInfo *info; } JSNativeWrapper; /* * Macro static initializers which make it easy to pass no JSJitInfo as part of a * JSPropertySpec or JSFunctionSpec. */ #define JSOP_WRAPPER(op) {op, NULL} #define JSOP_NULLWRAPPER JSOP_WRAPPER(NULL) /* * To define an array element rather than a named property member, cast the * element's index to (const char *) and initialize name with it, and set the * JSPROP_INDEX bit in flags. */ struct JSPropertySpec { const char *name; int8_t tinyid; uint8_t flags; JSPropertyOpWrapper getter; JSStrictPropertyOpWrapper setter; }; namespace JS { namespace detail { /* NEVER DEFINED, DON'T USE. For use by JS_CAST_NATIVE_TO only. */ inline int CheckIsNative(JSNative native); } // namespace detail } // namespace JS #define JS_CAST_NATIVE_TO(v, To) \ (static_cast(sizeof(JS::detail::CheckIsNative(v))), \ reinterpret_cast(v)) /* * JSPropertySpec uses JSAPI JSPropertyOp and JSStrictPropertyOp in function * signatures, but with JSPROP_NATIVE_ACCESSORS the actual values must be * JSNatives. To avoid widespread casting, have JS_PSG and JS_PSGS perform * type-safe casts. */ #define JS_PSG(name, getter, flags) \ {name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(getter, JSPropertyOp)), \ JSOP_NULLWRAPPER} #define JS_PSGS(name, getter, setter, flags) \ {name, 0, (flags) | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS, \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(getter, JSPropertyOp)), \ JSOP_WRAPPER(JS_CAST_NATIVE_TO(setter, JSStrictPropertyOp))} #define JS_PS_END {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} /* * To define a native function, set call to a JSNativeWrapper. To define a * self-hosted function, set selfHostedName to the name of a function * compiled during JSRuntime::initSelfHosting. */ struct JSFunctionSpec { const char *name; JSNativeWrapper call; uint16_t nargs; uint16_t flags; const char *selfHostedName; }; /* * Terminating sentinel initializer to put at the end of a JSFunctionSpec array * that's passed to JS_DefineFunctions or JS_InitClass. */ #define JS_FS_END JS_FS(NULL,NULL,0,0) /* * Initializer macros for a JSFunctionSpec array element. JS_FN (whose name * pays homage to the old JSNative/JSFastNative split) simply adds the flag * JSFUN_STUB_GSOPS. JS_FNINFO allows the simple adding of JSJitInfos. */ #define JS_FS(name,call,nargs,flags) \ {name, JSOP_WRAPPER(call), nargs, flags} #define JS_FN(name,call,nargs,flags) \ {name, JSOP_WRAPPER(call), nargs, (flags) | JSFUN_STUB_GSOPS} #define JS_FNINFO(name,call,info,nargs,flags) \ {name,{call,info},nargs,flags} extern JS_PUBLIC_API(JSObject *) JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto, JSClass *clasp, JSNative constructor, unsigned nargs, const JSPropertySpec *ps, const JSFunctionSpec *fs, const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs); /* * Set up ctor.prototype = proto and proto.constructor = ctor with the * right property flags. */ extern JS_PUBLIC_API(JSBool) JS_LinkConstructorAndPrototype(JSContext *cx, JSObject *ctor, JSObject *proto); extern JS_PUBLIC_API(JSClass *) JS_GetClass(JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); extern JS_PUBLIC_API(void *) JS_GetPrivate(JSObject *obj); extern JS_PUBLIC_API(void) JS_SetPrivate(JSObject *obj, void *data); extern JS_PUBLIC_API(void *) JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) JS_GetPrototype(JSContext *cx, JS::Handle obj, JS::MutableHandle protop); extern JS_PUBLIC_API(JSBool) JS_SetPrototype(JSContext *cx, JS::Handle obj, JS::Handle proto); extern JS_PUBLIC_API(JSObject *) JS_GetParent(JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent); extern JS_PUBLIC_API(JSObject *) JS_GetConstructor(JSContext *cx, JSObject *proto); /* * Get a unique identifier for obj, good for the lifetime of obj (even if it * is moved by a copying GC). Return false on failure (likely out of memory), * and true with *idp containing the unique id on success. */ extern JS_PUBLIC_API(JSBool) JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp); namespace JS { enum { FreshZone, SystemZone, SpecificZones }; typedef uintptr_t ZoneSpecifier; inline ZoneSpecifier SameZoneAs(JSObject *obj) { JS_ASSERT(uintptr_t(obj) > SpecificZones); return ZoneSpecifier(obj); } struct JS_PUBLIC_API(CompartmentOptions) { ZoneSpecifier zoneSpec; JSVersion version; bool invisibleToDebugger; explicit CompartmentOptions() : zoneSpec(JS::FreshZone) , version(JSVERSION_UNKNOWN) , invisibleToDebugger(false) {} CompartmentOptions &setZone(ZoneSpecifier spec) { zoneSpec = spec; return *this; } CompartmentOptions &setVersion(JSVersion version_) { JS_ASSERT(version_ != JSVERSION_UNKNOWN); version = version_; return *this; } // Certain scopes (i.e. XBL compilation scopes) are implementation details // of the embedding, and references to them should never leak out to script. // This flag causes the this compartment to skip firing onNewGlobalObject // and makes addDebuggee a no-op for this global. CompartmentOptions &setInvisibleToDebugger(bool invisible) { invisibleToDebugger = invisible; return *this; } }; // During global creation, we fire notifications to callbacks registered // via the Debugger API. These callbacks are arbitrary script, and can touch // the global in arbitrary ways. When that happens, the global should not be // in a half-baked state. But this creates a problem for consumers that need // to set slots on the global to put it in a consistent state. // // This API provides a way for consumers to set slots atomically (immediately // after the global is created), before any debugger hooks are fired. It's // unfortunately on the clunky side, but that's the way the cookie crumbles. // // If callers have no additional state on the global to set up, they may pass // |FireOnNewGlobalHook| to JS_NewGlobalObject, which causes that function to // fire the hook as its final act before returning. Otherwise, callers should // pass |DontFireOnNewGlobalHook|, which means that they are responsible for // invoking JS_FireOnNewGlobalObject upon successfully creating the global. If // an error occurs and the operation aborts, callers should skip firing the // hook. But otherwise, callers must take care to fire the hook exactly once // before compiling any script in the global's scope (we have assertions in // place to enforce this). This lets us be sure that debugger clients never miss // breakpoints. enum OnNewGlobalHookOption { FireOnNewGlobalHook, DontFireOnNewGlobalHook }; } /* namespace JS */ extern JS_PUBLIC_API(JSObject *) JS_NewGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals, JS::OnNewGlobalHookOption hookOption, const JS::CompartmentOptions &options = JS::CompartmentOptions()); extern JS_PUBLIC_API(void) JS_FireOnNewGlobalObject(JSContext *cx, JS::HandleObject global); extern JS_PUBLIC_API(JSObject *) JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); /* Queries the [[Extensible]] property of the object. */ extern JS_PUBLIC_API(JSBool) JS_IsExtensible(JSContext *cx, JS::HandleObject obj, JSBool *extensible); extern JS_PUBLIC_API(JSBool) JS_IsNative(JSObject *obj); extern JS_PUBLIC_API(JSRuntime *) JS_GetObjectRuntime(JSObject *obj); /* * Unlike JS_NewObject, JS_NewObjectWithGivenProto does not compute a default * proto if proto's actual parameter value is null. */ extern JS_PUBLIC_API(JSObject *) JS_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); /* * Freeze obj, and all objects it refers to, recursively. This will not recurse * through non-extensible objects, on the assumption that those are already * deep-frozen. */ extern JS_PUBLIC_API(JSBool) JS_DeepFreezeObject(JSContext *cx, JSObject *obj); /* * Freezes an object; see ES5's Object.freeze(obj) method. */ extern JS_PUBLIC_API(JSBool) JS_FreezeObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_PreventExtensions(JSContext *cx, JS::HandleObject obj); extern JS_PUBLIC_API(JSObject *) JS_New(JSContext *cx, JSObject *ctor, unsigned argc, jsval *argv); extern JS_PUBLIC_API(JSObject *) JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *clasp, JSObject *proto, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefineConstDoubles(JSContext *cx, JSObject *obj, const JSConstDoubleSpec *cds); extern JS_PUBLIC_API(JSBool) JS_DefineProperties(JSContext *cx, JSObject *obj, const JSPropertySpec *ps); extern JS_PUBLIC_API(JSBool) JS_DefineProperty(JSContext *cx, JSObject *obj, const char *name, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer * is not null). */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, const char *name, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *obj, const char *name, int8_t tinyid, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name, unsigned flags, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSObject **objp, JS::MutableHandle vp); struct JSPropertyDescriptor { JSObject *obj; unsigned attrs; unsigned shortid; JSPropertyOp getter; JSStrictPropertyOp setter; JS::Value value; JSPropertyDescriptor() : obj(NULL), attrs(0), shortid(0), getter(NULL), setter(NULL), value(JSVAL_VOID) {} void trace(JSTracer *trc); }; namespace JS { template class PropertyDescriptorOperations { const JSPropertyDescriptor * desc() const { return static_cast(this)->extract(); } JSPropertyDescriptor * desc() { return static_cast(this)->extract(); } public: bool isEnumerable() const { return desc()->attrs & JSPROP_ENUMERATE; } bool isReadonly() const { return desc()->attrs & JSPROP_READONLY; } bool isPermanent() const { return desc()->attrs & JSPROP_PERMANENT; } bool hasNativeAccessors() const { return desc()->attrs & JSPROP_NATIVE_ACCESSORS; } bool hasGetterObject() const { return desc()->attrs & JSPROP_GETTER; } bool hasSetterObject() const { return desc()->attrs & JSPROP_SETTER; } bool isShared() const { return desc()->attrs & JSPROP_SHARED; } bool isIndex() const { return desc()->attrs & JSPROP_INDEX; } bool hasShortId() const { return desc()->attrs & JSPROP_SHORTID; } bool hasAttributes(unsigned attrs) const { return desc()->attrs & attrs; } JS::MutableHandleObject object() { return JS::MutableHandleObject::fromMarkedLocation(&desc()->obj); } unsigned attributes() const { return desc()->attrs; } unsigned shortid() const { MOZ_ASSERT(hasShortId()); return desc()->shortid; } JSPropertyOp getter() const { return desc()->getter; } JSStrictPropertyOp setter() const { return desc()->setter; } JS::HandleObject getterObject() const { MOZ_ASSERT(hasGetterObject()); return JS::HandleObject::fromMarkedLocation(reinterpret_cast(&desc()->getter)); } JS::HandleObject setterObject() const { MOZ_ASSERT(hasSetterObject()); return JS::HandleObject::fromMarkedLocation(reinterpret_cast(&desc()->setter)); } JS::MutableHandleValue value() { return JS::MutableHandleValue::fromMarkedLocation(&desc()->value); } void setAttributes(unsigned attrs) { desc()->attrs = attrs; } void setShortId(unsigned id) { desc()->shortid = id; } void setGetter(JSPropertyOp op) { desc()->getter = op; } void setSetter(JSStrictPropertyOp op) { desc()->setter = op; } void setGetterObject(JSObject *obj) { desc()->getter = reinterpret_cast(obj); } void setSetterObject(JSObject *obj) { desc()->setter = reinterpret_cast(obj); } }; } /* namespace JS */ namespace js { template <> struct GCMethods { static JSPropertyDescriptor initial() { return JSPropertyDescriptor(); } static ThingRootKind kind() { return THING_ROOT_PROPERTY_DESCRIPTOR; } static bool poisoned(const JSPropertyDescriptor &desc) { return (desc.obj && JS::IsPoisonedPtr(desc.obj)) || (desc.attrs & JSPROP_GETTER && desc.getter && JS::IsPoisonedPtr(desc.getter)) || (desc.attrs & JSPROP_SETTER && desc.setter && JS::IsPoisonedPtr(desc.setter)) || (desc.value.isGCThing() && JS::IsPoisonedPtr(desc.value.toGCThing())); } }; template <> class RootedBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } JSPropertyDescriptor *extract() { return static_cast*>(this)->address(); } }; template <> class HandleBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } public: JS::HandleValue value() const { return JS::HandleValue::fromMarkedLocation(&extract()->value); } JS::HandleObject obj() const { return JS::HandleObject::fromMarkedLocation(&extract()->obj); } }; template <> class MutableHandleBase : public JS::PropertyDescriptorOperations > { friend class JS::PropertyDescriptorOperations >; const JSPropertyDescriptor *extract() const { return static_cast*>(this)->address(); } JSPropertyDescriptor *extract() { return static_cast*>(this)->address(); } }; } /* namespace js */ /* * Like JS_GetPropertyAttrsGetterAndSetterById but will return a property on * an object on the prototype chain (returned in objp). If data->obj is null, * then this property was not found on the prototype chain. */ extern JS_PUBLIC_API(JSBool) JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, unsigned flags, JSPropertyDescriptor *desc); extern JS_PUBLIC_API(JSBool) JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyDefault(JSContext *cx, JSObject *obj, const char *name, jsval def, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehalfOf, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name); extern JS_PUBLIC_API(JSBool) JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandle rval); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id); extern JS_PUBLIC_API(JSBool) JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandle rval); extern JS_PUBLIC_API(JSBool) JS_DefineUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); /* * Determine the attributes (JSPROP_* flags) of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and the value of *attrsp is undefined. */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp); /* * The same, but if the property is native, return its getter and setter via * *getterp and *setterp, respectively (and only if the out parameter pointer * is not null). */ extern JS_PUBLIC_API(JSBool) JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned *attrsp, JSBool *foundp, JSPropertyOp *getterp, JSStrictPropertyOp *setterp); /* * Set the attributes of a property on a given object. * * If the object does not have a property by that name, *foundp will be * JS_FALSE and nothing will be altered. */ extern JS_PUBLIC_API(JSBool) JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, unsigned attrs, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, int8_t tinyid, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSBool *vp); extern JS_PUBLIC_API(JSBool) JS_LookupUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_GetUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle vp); extern JS_PUBLIC_API(JSBool) JS_SetUCProperty(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::Handle v); extern JS_PUBLIC_API(JSBool) JS_DeleteUCProperty2(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JS::MutableHandle rval); extern JS_PUBLIC_API(JSObject *) JS_NewArrayObject(JSContext *cx, int length, jsval *vector); extern JS_PUBLIC_API(JSBool) JS_IsArrayObject(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_GetArrayLength(JSContext *cx, JSObject *obj, uint32_t *lengthp); extern JS_PUBLIC_API(JSBool) JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length); extern JS_PUBLIC_API(JSBool) JS_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, jsval value, JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs); extern JS_PUBLIC_API(JSBool) JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_HasElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp); extern JS_PUBLIC_API(JSBool) JS_LookupElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_GetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp); /* * Get the property with name given by |index|, if it has one. If * not, |*present| will be set to false and the value of |vp| must not * be relied on. */ extern JS_PUBLIC_API(JSBool) JS_GetElementIfPresent(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, jsval *vp, JSBool* present); extern JS_PUBLIC_API(JSBool) JS_SetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_DeleteElement(JSContext *cx, JSObject *obj, uint32_t index); extern JS_PUBLIC_API(JSBool) JS_DeleteElement2(JSContext *cx, JSObject *obj, uint32_t index, jsval *rval); /* * Remove all configurable properties from the given (non-global) object and * assign undefined to all writable data properties. */ JS_PUBLIC_API(void) JS_ClearNonGlobalObject(JSContext *cx, JSObject *objArg); /* * Assign 'undefined' to all of the object's non-reserved slots. Note: this is * done for all slots, regardless of the associated property descriptor. */ JS_PUBLIC_API(void) JS_SetAllNonReservedSlotsToUndefined(JSContext *cx, JSObject *objArg); /* * Create a new array buffer with the given contents, which must have been * returned by JS_AllocateArrayBufferContents or JS_StealArrayBufferContents. * The new array buffer takes ownership. After calling this function, do not * free |contents| or use |contents| from another thread. */ extern JS_PUBLIC_API(JSObject *) JS_NewArrayBufferWithContents(JSContext *cx, void *contents); /* * Steal the contents of the given array buffer. The array buffer has its * length set to 0 and its contents array cleared. The caller takes ownership * of |*contents| and must free it or transfer ownership via * JS_NewArrayBufferWithContents when done using it. * To free |*contents|, call free(). * A pointer to the buffer's data is returned in |*data|. This pointer can * be used until |*contents| is freed or has its ownership transferred. */ extern JS_PUBLIC_API(JSBool) JS_StealArrayBufferContents(JSContext *cx, JSObject *obj, void **contents, uint8_t **data); /* * Allocate memory that may be eventually passed to * JS_NewArrayBufferWithContents. |nbytes| is the number of payload bytes * required. The pointer to pass to JS_NewArrayBufferWithContents is returned * in |contents|. The pointer to the |nbytes| of usable memory is returned in * |data|. (*|contents| will contain a header before |data|.) The only legal * operations on *|contents| is to free it, or pass it to * JS_NewArrayBufferWithContents or JS_ReallocateArrayBufferContents. */ extern JS_PUBLIC_API(JSBool) JS_AllocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void **contents, uint8_t **data); /* * Reallocate memory allocated by JS_AllocateArrayBufferContents, growing or shrinking it * as appropriate. The new data pointer will be returned in data. If *contents is NULL, * behaves like JS_AllocateArrayBufferContents. */ extern JS_PUBLIC_API(JSBool) JS_ReallocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void **contents, uint8_t **data); extern JS_PUBLIC_API(JSIdArray *) JS_Enumerate(JSContext *cx, JSObject *obj); /* * Create an object to iterate over enumerable properties of obj, in arbitrary * property definition order. NB: This differs from longstanding for..in loop * order, which uses order of property definition in obj. */ extern JS_PUBLIC_API(JSObject *) JS_NewPropertyIterator(JSContext *cx, JSObject *obj); /* * Return true on success with *idp containing the id of the next enumerable * property to visit using iterobj, or JSID_IS_VOID if there is no such property * left to visit. Return false on error. */ extern JS_PUBLIC_API(JSBool) JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp); /* * A JSNative that creates and returns a new iterator that iterates over the * elements of |this|, up to |this.length|, in index order. This can be used to * make any array-like object iterable. Just give the object an obj.iterator() * method using this JSNative as the implementation. */ extern JS_PUBLIC_API(JSBool) JS_ArrayIterator(JSContext *cx, unsigned argc, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, jsval *vp, unsigned *attrsp); extern JS_PUBLIC_API(jsval) JS_GetReservedSlot(JSObject *obj, uint32_t index); extern JS_PUBLIC_API(void) JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v); /************************************************************************/ /* * Security protocol. */ struct JSPrincipals { /* Don't call "destroy"; use reference counting macros below. */ int refcount; #ifdef DEBUG /* A helper to facilitate principals debugging. */ uint32_t debugToken; #endif void setDebugToken(uint32_t token) { # ifdef DEBUG debugToken = token; # endif } /* * This is not defined by the JS engine but should be provided by the * embedding. */ JS_PUBLIC_API(void) dump(); }; extern JS_PUBLIC_API(void) JS_HoldPrincipals(JSPrincipals *principals); extern JS_PUBLIC_API(void) JS_DropPrincipals(JSRuntime *rt, JSPrincipals *principals); struct JSSecurityCallbacks { JSCheckAccessOp checkObjectAccess; JSCSPEvalChecker contentSecurityPolicyAllows; }; extern JS_PUBLIC_API(void) JS_SetSecurityCallbacks(JSRuntime *rt, const JSSecurityCallbacks *callbacks); extern JS_PUBLIC_API(const JSSecurityCallbacks *) JS_GetSecurityCallbacks(JSRuntime *rt); /* * Code running with "trusted" principals will be given a deeper stack * allocation than ordinary scripts. This allows trusted script to run after * untrusted script has exhausted the stack. This function sets the * runtime-wide trusted principal. * * This principals is not held (via JS_HoldPrincipals/JS_DropPrincipals) since * there is no available JSContext. Instead, the caller must ensure that the * given principals stays valid for as long as 'rt' may point to it. If the * principals would be destroyed before 'rt', JS_SetTrustedPrincipals must be * called again, passing NULL for 'prin'. */ extern JS_PUBLIC_API(void) JS_SetTrustedPrincipals(JSRuntime *rt, JSPrincipals *prin); /* * Initialize the callback that is called to destroy JSPrincipals instance * when its reference counter drops to zero. The initialization can be done * only once per JS runtime. */ extern JS_PUBLIC_API(void) JS_InitDestroyPrincipalsCallback(JSRuntime *rt, JSDestroyPrincipalsOp destroyPrincipals); /************************************************************************/ /* * Functions and scripts. */ extern JS_PUBLIC_API(JSFunction *) JS_NewFunction(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, JSObject *parent, const char *name); /* * Create the function with the name given by the id. JSID_IS_STRING(id) must * be true. */ extern JS_PUBLIC_API(JSFunction *) JS_NewFunctionById(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, JSObject *parent, jsid id); extern JS_PUBLIC_API(JSObject *) JS_GetFunctionObject(JSFunction *fun); /* * Return the function's identifier as a JSString, or null if fun is unnamed. * The returned string lives as long as fun, so you don't need to root a saved * reference to it if fun is well-connected or rooted, and provided you bound * the use of the saved reference by fun's lifetime. */ extern JS_PUBLIC_API(JSString *) JS_GetFunctionId(JSFunction *fun); /* * Return a function's display name. This is the defined name if one was given * where the function was defined, or it could be an inferred name by the JS * engine in the case that the function was defined to be anonymous. This can * still return NULL if a useful display name could not be inferred. The same * restrictions on rooting as those in JS_GetFunctionId apply. */ extern JS_PUBLIC_API(JSString *) JS_GetFunctionDisplayId(JSFunction *fun); /* * Return the arity (length) of fun. */ extern JS_PUBLIC_API(uint16_t) JS_GetFunctionArity(JSFunction *fun); /* * Infallible predicate to test whether obj is a function object (faster than * comparing obj's class name to "Function", but equivalent unless someone has * overwritten the "Function" identifier with a different constructor and then * created instances using that constructor that might be passed in as obj). */ extern JS_PUBLIC_API(JSBool) JS_ObjectIsFunction(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_ObjectIsCallable(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_IsNativeFunction(JSObject *funobj, JSNative call); /* Return whether the given function is a valid constructor. */ extern JS_PUBLIC_API(JSBool) JS_IsConstructor(JSFunction *fun); /* * Bind the given callable to use the given object as "this". * * If |callable| is not callable, will throw and return NULL. */ extern JS_PUBLIC_API(JSObject*) JS_BindCallable(JSContext *cx, JSObject *callable, JSObject *newThis); extern JS_PUBLIC_API(JSBool) JS_DefineFunctions(JSContext *cx, JSObject *obj, const JSFunctionSpec *fs); extern JS_PUBLIC_API(JSFunction *) JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call, unsigned nargs, unsigned attrs); extern JS_PUBLIC_API(JSFunction *) JS_DefineUCFunction(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSNative call, unsigned nargs, unsigned attrs); extern JS_PUBLIC_API(JSFunction *) JS_DefineFunctionById(JSContext *cx, JSObject *obj, jsid id, JSNative call, unsigned nargs, unsigned attrs); /* * Clone a top-level function into a new scope. This function will dynamically * fail if funobj was lexically nested inside some other function. */ extern JS_PUBLIC_API(JSObject *) JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); /* * Given a buffer, return JS_FALSE if the buffer might become a valid * javascript statement with the addition of more lines. Otherwise return * JS_TRUE. The intent is to support interactive compilation - accumulate * lines in a buffer until JS_BufferIsCompilableUnit is true, then pass it to * the compiler. */ extern JS_PUBLIC_API(JSBool) JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj, const char *utf8, size_t length); extern JS_PUBLIC_API(JSScript *) JS_CompileScript(JSContext *cx, JSObject *obj, const char *ascii, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *ascii, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileUCScript(JSContext *cx, JSObject *obj, const jschar *chars, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSScript *) JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalFromScript(JSScript *script); extern JS_PUBLIC_API(JSFunction *) JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSFunction *) JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length, const char *filename, unsigned lineno); extern JS_PUBLIC_API(JSFunction *) JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name, unsigned nargs, const char **argnames, const jschar *chars, size_t length, const char *filename, unsigned lineno); namespace JS { /* Options for JavaScript compilation. */ class JS_PUBLIC_API(CompileOptions) { JSPrincipals *principals_; JSPrincipals *originPrincipals_; public: JSPrincipals *principals() const { return principals_; } JSPrincipals *originPrincipals() const; JSVersion version; bool versionSet; bool utf8; const char *filename; unsigned lineno; unsigned column; HandleObject element; bool compileAndGo; bool forEval; bool noScriptRval; bool selfHostingMode; bool canLazilyParse; bool strictOption; bool extraWarningsOption; bool werrorOption; bool asmJSOption; enum SourcePolicy { NO_SOURCE, LAZY_SOURCE, SAVE_SOURCE } sourcePolicy; explicit CompileOptions(JSContext *cx, JSVersion version = JSVERSION_UNKNOWN); CompileOptions &setPrincipals(JSPrincipals *p) { principals_ = p; return *this; } CompileOptions &setOriginPrincipals(JSPrincipals *p) { originPrincipals_ = p; return *this; } CompileOptions &setVersion(JSVersion v) { version = v; versionSet = true; return *this; } CompileOptions &setUTF8(bool u) { utf8 = u; return *this; } CompileOptions &setFileAndLine(const char *f, unsigned l) { filename = f; lineno = l; return *this; } CompileOptions &setColumn(unsigned c) { column = c; return *this; } CompileOptions &setElement(HandleObject e) { element = e; return *this; } CompileOptions &setCompileAndGo(bool cng) { compileAndGo = cng; return *this; } CompileOptions &setForEval(bool eval) { forEval = eval; return *this; } CompileOptions &setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; } CompileOptions &setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; } CompileOptions &setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; } CompileOptions &setSourcePolicy(SourcePolicy sp) { sourcePolicy = sp; return *this; } }; extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const char *bytes, size_t length); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const jschar *chars, size_t length); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, FILE *file); extern JS_PUBLIC_API(JSScript *) Compile(JSContext *cx, JS::Handle obj, CompileOptions options, const char *filename); extern JS_PUBLIC_API(JSFunction *) CompileFunction(JSContext *cx, JS::Handle obj, CompileOptions options, const char *name, unsigned nargs, const char **argnames, const char *bytes, size_t length); extern JS_PUBLIC_API(JSFunction *) CompileFunction(JSContext *cx, JS::Handle obj, CompileOptions options, const char *name, unsigned nargs, const char **argnames, const jschar *chars, size_t length); } /* namespace JS */ extern JS_PUBLIC_API(JSString *) JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, unsigned indent); /* * API extension: OR this into indent to avoid pretty-printing the decompiled * source resulting from JS_DecompileFunction{,Body}. */ #define JS_DONT_PRETTY_PRINT ((unsigned)0x8000) extern JS_PUBLIC_API(JSString *) JS_DecompileFunction(JSContext *cx, JSFunction *fun, unsigned indent); extern JS_PUBLIC_API(JSString *) JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, unsigned indent); /* * NB: JS_ExecuteScript and the JS_Evaluate*Script* quadruplets use the obj * parameter as the initial scope chain header, the 'this' keyword value, and * the variables object (ECMA parlance for where 'var' and 'function' bind * names) of the execution context for script. * * Using obj as the variables object is problematic if obj's parent (which is * the scope chain link; see JS_SetParent and JS_NewObject) is not null: in * this case, variables created by 'var x = 0', e.g., go in obj, but variables * created by assignment to an unbound id, 'x = 0', go in the last object on * the scope chain linked by parent. * * ECMA calls that last scoping object the "global object", but note that many * embeddings have several such objects. ECMA requires that "global code" be * executed with the variables object equal to this global object. But these * JS API entry points provide freedom to execute code against a "sub-global", * i.e., a parented or scoped object, in which case the variables object will * differ from the last object on the scope chain, resulting in confusing and * non-ECMA explicit vs. implicit variable creation. * * Caveat embedders: unless you already depend on this buggy variables object * binding behavior, you should call JS_SetOptions(cx, JSOPTION_VAROBJFIX) or * JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_VAROBJFIX) -- the latter if * someone may have set other options on cx already -- for each context in the * application, if you pass parented objects as the obj parameter, or may ever * pass such objects in the future. * * Why a runtime option? The alternative is to add six or so new API entry * points with signatures matching the following six, and that doesn't seem * worth the code bloat cost. Such new entry points would probably have less * obvious names, too, so would not tend to be used. The JS_SetOption call, * OTOH, can be more easily hacked into existing code that does not depend on * the bug; such code can continue to use the familiar JS_EvaluateScript, * etc., entry points. */ extern JS_PUBLIC_API(JSBool) JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_ExecuteScriptVersion(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval, JSVersion version); /* * Execute either the function-defining prolog of a script, or the script's * main body, but not both. */ typedef enum JSExecPart { JSEXEC_PROLOG, JSEXEC_MAIN } JSExecPart; extern JS_PUBLIC_API(JSBool) JS_EvaluateScript(JSContext *cx, JSObject *obj, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *bytes, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScript(JSContext *cx, JSObject *obj, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); /* * JSAPI clients may optionally specify the 'originPrincipals' of a script. * A script's originPrincipals may be retrieved through the debug API (via * JS_GetScriptOriginPrincipals) and the originPrincipals are transitively * assigned to any nested scripts (including scripts dynamically created via * eval and the Function constructor). If originPrincipals is null, then the * value of principals is used as origin principals for the script. */ extern JS_PUBLIC_API(JSBool) JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JSObject *obj, JSPrincipals *principals, JSPrincipals *originPrincipals, const jschar *chars, unsigned length, const char *filename, unsigned lineno, jsval *rval, JSVersion version); namespace JS { extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const jschar *chars, size_t length, jsval *rval); extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const char *bytes, size_t length, jsval *rval); extern JS_PUBLIC_API(bool) Evaluate(JSContext *cx, JS::Handle obj, CompileOptions options, const char *filename, jsval *rval); } /* namespace JS */ extern JS_PUBLIC_API(JSBool) JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, unsigned argc, jsval *argv, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, unsigned argc, jsval *argv, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, unsigned argc, jsval *argv, jsval *rval); namespace JS { static inline bool Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunction(cx, thisObj, fun, argc, argv, rval.address()); } static inline bool Call(JSContext *cx, JSObject *thisObj, const char *name, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunctionName(cx, thisObj, name, argc, argv, rval.address()); } static inline bool Call(JSContext *cx, JSObject *thisObj, jsval fun, unsigned argc, jsval *argv, MutableHandle rval) { return !!JS_CallFunctionValue(cx, thisObj, fun, argc, argv, rval.address()); } extern JS_PUBLIC_API(bool) Call(JSContext *cx, jsval thisv, jsval fun, unsigned argc, jsval *argv, MutableHandle rval); static inline bool Call(JSContext *cx, jsval thisv, JSObject *funObj, unsigned argc, jsval *argv, MutableHandle rval) { return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval); } } /* namespace JS */ /* * These functions allow setting an operation callback that will be called * from the JS thread some time after any thread triggered the callback using * JS_TriggerOperationCallback(rt). * * To schedule the GC and for other activities the engine internally triggers * operation callbacks. The embedding should thus not rely on callbacks being * triggered through the external API only. * * Important note: Additional callbacks can occur inside the callback handler * if it re-enters the JS engine. The embedding must ensure that the callback * is disconnected before attempting such re-entry. */ extern JS_PUBLIC_API(JSOperationCallback) JS_SetOperationCallback(JSContext *cx, JSOperationCallback callback); extern JS_PUBLIC_API(JSOperationCallback) JS_GetOperationCallback(JSContext *cx); extern JS_PUBLIC_API(void) JS_TriggerOperationCallback(JSRuntime *rt); extern JS_PUBLIC_API(JSBool) JS_IsRunning(JSContext *cx); /* * Saving and restoring frame chains. * * These two functions are used to set aside cx's call stack while that stack * is inactive. After a call to JS_SaveFrameChain, it looks as if there is no * code running on cx. Before calling JS_RestoreFrameChain, cx's call stack * must be balanced and all nested calls to JS_SaveFrameChain must have had * matching JS_RestoreFrameChain calls. * * JS_SaveFrameChain deals with cx not having any code running on it. */ extern JS_PUBLIC_API(JSBool) JS_SaveFrameChain(JSContext *cx); extern JS_PUBLIC_API(void) JS_RestoreFrameChain(JSContext *cx); #ifdef MOZ_TRACE_JSCALLS /* * The callback is expected to be quick and noninvasive. It should not * trigger interrupts, turn on debugging, or produce uncaught JS * exceptions. The state of the stack and registers in the context * cannot be relied upon, since this callback may be invoked directly * from either JIT. The 'entering' field means we are entering a * function if it is positive, leaving a function if it is zero or * negative. */ extern JS_PUBLIC_API(void) JS_SetFunctionCallback(JSContext *cx, JSFunctionCallback fcb); extern JS_PUBLIC_API(JSFunctionCallback) JS_GetFunctionCallback(JSContext *cx); #endif /* MOZ_TRACE_JSCALLS */ /************************************************************************/ /* * Strings. * * NB: JS_NewUCString takes ownership of bytes on success, avoiding a copy; * but on error (signified by null return), it leaves chars owned by the * caller. So the caller must free bytes in the error case, if it has no use * for them. In contrast, all the JS_New*StringCopy* functions do not take * ownership of the character memory passed to them -- they copy it. */ extern JS_PUBLIC_API(JSString *) JS_NewStringCopyN(JSContext *cx, const char *s, size_t n); extern JS_PUBLIC_API(JSString *) JS_NewStringCopyZ(JSContext *cx, const char *s); extern JS_PUBLIC_API(JSString *) JS_InternJSString(JSContext *cx, JSString *str); extern JS_PUBLIC_API(JSString *) JS_InternStringN(JSContext *cx, const char *s, size_t length); extern JS_PUBLIC_API(JSString *) JS_InternString(JSContext *cx, const char *s); extern JS_PUBLIC_API(JSString *) JS_NewUCString(JSContext *cx, jschar *chars, size_t length); extern JS_PUBLIC_API(JSString *) JS_NewUCStringCopyN(JSContext *cx, const jschar *s, size_t n); extern JS_PUBLIC_API(JSString *) JS_NewUCStringCopyZ(JSContext *cx, const jschar *s); extern JS_PUBLIC_API(JSString *) JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length); extern JS_PUBLIC_API(JSString *) JS_InternUCString(JSContext *cx, const jschar *s); extern JS_PUBLIC_API(JSBool) JS_CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32_t *result); extern JS_PUBLIC_API(JSBool) JS_StringEqualsAscii(JSContext *cx, JSString *str, const char *asciiBytes, JSBool *match); extern JS_PUBLIC_API(size_t) JS_PutEscapedString(JSContext *cx, char *buffer, size_t size, JSString *str, char quote); extern JS_PUBLIC_API(JSBool) JS_FileEscapedString(FILE *fp, JSString *str, char quote); /* * Extracting string characters and length. * * While getting the length of a string is infallible, getting the chars can * fail. As indicated by the lack of a JSContext parameter, there are two * special cases where getting the chars is infallible: * * The first case is interned strings, i.e., strings from JS_InternString or * JSID_TO_STRING(id), using JS_GetInternedStringChars*. * * The second case is "flat" strings that have been explicitly prepared in a * fallible context by JS_FlattenString. To catch errors, a separate opaque * JSFlatString type is returned by JS_FlattenString and expected by * JS_GetFlatStringChars. Note, though, that this is purely a syntactic * distinction: the input and output of JS_FlattenString are the same actual * GC-thing so only one needs to be rooted. If a JSString is known to be flat, * JS_ASSERT_STRING_IS_FLAT can be used to make a debug-checked cast. Example: * * // in a fallible context * JSFlatString *fstr = JS_FlattenString(cx, str); * if (!fstr) * return JS_FALSE; * JS_ASSERT(fstr == JS_ASSERT_STRING_IS_FLAT(str)); * * // in an infallible context, for the same 'str' * const jschar *chars = JS_GetFlatStringChars(fstr) * JS_ASSERT(chars); * * The CharsZ APIs guarantee that the returned array has a null character at * chars[length]. This can require additional copying so clients should prefer * APIs without CharsZ if possible. The infallible functions also return * null-terminated arrays. (There is no additional cost or non-Z alternative * for the infallible functions, so 'Z' is left out of the identifier.) */ extern JS_PUBLIC_API(size_t) JS_GetStringLength(JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsAndLength(JSContext *cx, JSString *str, size_t *length); extern JS_PUBLIC_API(const jschar *) JS_GetInternedStringChars(JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetInternedStringCharsAndLength(JSString *str, size_t *length); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsZ(JSContext *cx, JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetStringCharsZAndLength(JSContext *cx, JSString *str, size_t *length); extern JS_PUBLIC_API(JSFlatString *) JS_FlattenString(JSContext *cx, JSString *str); extern JS_PUBLIC_API(const jschar *) JS_GetFlatStringChars(JSFlatString *str); static JS_ALWAYS_INLINE JSFlatString * JSID_TO_FLAT_STRING(jsid id) { JS_ASSERT(JSID_IS_STRING(id)); return (JSFlatString *)(JSID_BITS(id)); } static JS_ALWAYS_INLINE JSFlatString * JS_ASSERT_STRING_IS_FLAT(JSString *str) { JS_ASSERT(JS_GetFlatStringChars((JSFlatString *)str)); return (JSFlatString *)str; } static JS_ALWAYS_INLINE JSString * JS_FORGET_STRING_FLATNESS(JSFlatString *fstr) { return (JSString *)fstr; } /* * Additional APIs that avoid fallibility when given a flat string. */ extern JS_PUBLIC_API(JSBool) JS_FlatStringEqualsAscii(JSFlatString *str, const char *asciiBytes); extern JS_PUBLIC_API(size_t) JS_PutEscapedFlatString(char *buffer, size_t size, JSFlatString *str, char quote); /* * This function is now obsolete and behaves the same as JS_NewUCString. Use * JS_NewUCString instead. */ extern JS_PUBLIC_API(JSString *) JS_NewGrowableString(JSContext *cx, jschar *chars, size_t length); /* * Create a dependent string, i.e., a string that owns no character storage, * but that refers to a slice of another string's chars. Dependent strings * are mutable by definition, so the thread safety comments above apply. */ extern JS_PUBLIC_API(JSString *) JS_NewDependentString(JSContext *cx, JSString *str, size_t start, size_t length); /* * Concatenate two strings, possibly resulting in a rope. * See above for thread safety comments. */ extern JS_PUBLIC_API(JSString *) JS_ConcatStrings(JSContext *cx, JSString *left, JSString *right); /* * For JS_DecodeBytes, set *dstlenp to the size of the destination buffer before * the call; on return, *dstlenp contains the number of jschars actually stored. * To determine the necessary destination buffer size, make a sizing call that * passes NULL for dst. * * On errors, the functions report the error. In that case, *dstlenp contains * the number of characters or bytes transferred so far. If cx is NULL, no * error is reported on failure, and the functions simply return JS_FALSE. * * NB: This function does not store an additional zero byte or jschar after the * transcoded string. */ JS_PUBLIC_API(JSBool) JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst, size_t *dstlenp); /* * A variation on JS_EncodeCharacters where a null terminated string is * returned that you are expected to call JS_free on when done. */ JS_PUBLIC_API(char *) JS_EncodeString(JSContext *cx, JSString *str); /* * Same behavior as JS_EncodeString(), but encode into UTF-8 string */ JS_PUBLIC_API(char *) JS_EncodeStringToUTF8(JSContext *cx, JSString *str); /* * Get number of bytes in the string encoding (without accounting for a * terminating zero bytes. The function returns (size_t) -1 if the string * can not be encoded into bytes and reports an error using cx accordingly. */ JS_PUBLIC_API(size_t) JS_GetStringEncodingLength(JSContext *cx, JSString *str); /* * Encode string into a buffer. The function does not stores an additional * zero byte. The function returns (size_t) -1 if the string can not be * encoded into bytes with no error reported. Otherwise it returns the number * of bytes that are necessary to encode the string. If that exceeds the * length parameter, the string will be cut and only length bytes will be * written into the buffer. */ JS_PUBLIC_API(size_t) JS_EncodeStringToBuffer(JSContext *cx, JSString *str, char *buffer, size_t length); class JSAutoByteString { public: JSAutoByteString(JSContext *cx, JSString *str MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mBytes(JS_EncodeString(cx, str)) { JS_ASSERT(cx); MOZ_GUARD_OBJECT_NOTIFIER_INIT; } JSAutoByteString(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) : mBytes(NULL) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; } ~JSAutoByteString() { js_free(mBytes); } /* Take ownership of the given byte array. */ void initBytes(char *bytes) { JS_ASSERT(!mBytes); mBytes = bytes; } char *encodeLatin1(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); JS_ASSERT(cx); mBytes = JS_EncodeString(cx, str); return mBytes; } char *encodeLatin1(js::ContextFriendFields *cx, JSString *str); char *encodeUtf8(JSContext *cx, JSString *str) { JS_ASSERT(!mBytes); JS_ASSERT(cx); mBytes = JS_EncodeStringToUTF8(cx, str); return mBytes; } void clear() { js_free(mBytes); mBytes = NULL; } char *ptr() const { return mBytes; } bool operator!() const { return !mBytes; } size_t length() const { if (!mBytes) return 0; return strlen(mBytes); } private: char *mBytes; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER /* Copy and assignment are not supported. */ JSAutoByteString(const JSAutoByteString &another); JSAutoByteString &operator=(const JSAutoByteString &another); }; /************************************************************************/ /* * JSON functions */ typedef JSBool (* JSONWriteCallback)(const jschar *buf, uint32_t len, void *data); /* * JSON.stringify as specified by ES5. */ JS_PUBLIC_API(JSBool) JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space, JSONWriteCallback callback, void *data); /* * JSON.parse as specified by ES5. */ JS_PUBLIC_API(JSBool) JS_ParseJSON(JSContext *cx, const jschar *chars, uint32_t len, JS::MutableHandle vp); JS_PUBLIC_API(JSBool) JS_ParseJSONWithReviver(JSContext *cx, const jschar *chars, uint32_t len, jsval reviver, jsval *vp); /************************************************************************/ /* API for the HTML5 internal structured cloning algorithm. */ /* The maximum supported structured-clone serialization format version. */ #define JS_STRUCTURED_CLONE_VERSION 2 struct JSStructuredCloneCallbacks { ReadStructuredCloneOp read; WriteStructuredCloneOp write; StructuredCloneErrorOp reportError; }; /* Note: if the *data contains transferable objects, it can be read * only once */ JS_PUBLIC_API(JSBool) JS_ReadStructuredClone(JSContext *cx, uint64_t *data, size_t nbytes, uint32_t version, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure); /* Note: On success, the caller is responsible for calling * JS_ClearStructuredClone(*datap, nbytesp). */ JS_PUBLIC_API(JSBool) JS_WriteStructuredClone(JSContext *cx, jsval v, uint64_t **datap, size_t *nbytesp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure, jsval transferable); JS_PUBLIC_API(JSBool) JS_ClearStructuredClone(const uint64_t *data, size_t nbytes); JS_PUBLIC_API(JSBool) JS_StructuredCloneHasTransferables(const uint64_t *data, size_t nbytes, JSBool *hasTransferable); JS_PUBLIC_API(JSBool) JS_StructuredClone(JSContext *cx, jsval v, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks, void *closure); /* RAII sugar for JS_WriteStructuredClone. */ class JS_PUBLIC_API(JSAutoStructuredCloneBuffer) { uint64_t *data_; size_t nbytes_; uint32_t version_; public: JSAutoStructuredCloneBuffer() : data_(NULL), nbytes_(0), version_(JS_STRUCTURED_CLONE_VERSION) {} ~JSAutoStructuredCloneBuffer() { clear(); } uint64_t *data() const { return data_; } size_t nbytes() const { return nbytes_; } void clear(); /* Copy some memory. It will be automatically freed by the destructor. */ bool copy(const uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION); /* * Adopt some memory. It will be automatically freed by the destructor. * data must have been allocated by the JS engine (e.g., extracted via * JSAutoStructuredCloneBuffer::steal). */ void adopt(uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION); /* * Remove the buffer so that it will not be automatically freed. * After this, the caller is responsible for feeding the memory back to * JSAutoStructuredCloneBuffer::adopt. */ void steal(uint64_t **datap, size_t *nbytesp, uint32_t *versionp=NULL); bool read(JSContext *cx, jsval *vp, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); bool write(JSContext *cx, jsval v, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); bool write(JSContext *cx, jsval v, jsval transferable, const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL); /** * Swap ownership with another JSAutoStructuredCloneBuffer. */ void swap(JSAutoStructuredCloneBuffer &other); private: /* Copy and assignment are not supported. */ JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer &other); JSAutoStructuredCloneBuffer &operator=(const JSAutoStructuredCloneBuffer &other); }; /* API for implementing custom serialization behavior (for ImageData, File, etc.) */ /* The range of tag values the application may use for its own custom object types. */ #define JS_SCTAG_USER_MIN ((uint32_t) 0xFFFF8000) #define JS_SCTAG_USER_MAX ((uint32_t) 0xFFFFFFFF) #define JS_SCERR_RECURSION 0 #define JS_SCERR_TRANSFERABLE 1 JS_PUBLIC_API(void) JS_SetStructuredCloneCallbacks(JSRuntime *rt, const JSStructuredCloneCallbacks *callbacks); JS_PUBLIC_API(JSBool) JS_ReadUint32Pair(JSStructuredCloneReader *r, uint32_t *p1, uint32_t *p2); JS_PUBLIC_API(JSBool) JS_ReadBytes(JSStructuredCloneReader *r, void *p, size_t len); JS_PUBLIC_API(JSBool) JS_ReadTypedArray(JSStructuredCloneReader *r, jsval *vp); JS_PUBLIC_API(JSBool) JS_WriteUint32Pair(JSStructuredCloneWriter *w, uint32_t tag, uint32_t data); JS_PUBLIC_API(JSBool) JS_WriteBytes(JSStructuredCloneWriter *w, const void *p, size_t len); JS_PUBLIC_API(JSBool) JS_WriteTypedArray(JSStructuredCloneWriter *w, jsval v); /************************************************************************/ /* * The default locale for the ECMAScript Internationalization API * (Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat). * Note that the Internationalization API encourages clients to * specify their own locales. * The locale string remains owned by the caller. */ extern JS_PUBLIC_API(JSBool) JS_SetDefaultLocale(JSRuntime *rt, const char *locale); /* * Reset the default locale to OS defaults. */ extern JS_PUBLIC_API(void) JS_ResetDefaultLocale(JSRuntime *rt); /* * Locale specific string conversion and error message callbacks. */ struct JSLocaleCallbacks { JSLocaleToUpperCase localeToUpperCase; JSLocaleToLowerCase localeToLowerCase; JSLocaleCompare localeCompare; // not used #if ENABLE_INTL_API JSLocaleToUnicode localeToUnicode; JSErrorCallback localeGetErrorMessage; }; /* * Establish locale callbacks. The pointer must persist as long as the * JSRuntime. Passing NULL restores the default behaviour. */ extern JS_PUBLIC_API(void) JS_SetLocaleCallbacks(JSRuntime *rt, JSLocaleCallbacks *callbacks); /* * Return the address of the current locale callbacks struct, which may * be NULL. */ extern JS_PUBLIC_API(JSLocaleCallbacks *) JS_GetLocaleCallbacks(JSRuntime *rt); /************************************************************************/ /* * Error reporting. */ /* * Report an exception represented by the sprintf-like conversion of format * and its arguments. This exception message string is passed to a pre-set * JSErrorReporter function (set by JS_SetErrorReporter). */ extern JS_PUBLIC_API(void) JS_ReportError(JSContext *cx, const char *format, ...); /* * Use an errorNumber to retrieve the format string, args are char * */ extern JS_PUBLIC_API(void) JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); #ifdef va_start extern JS_PUBLIC_API(void) JS_ReportErrorNumberVA(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, va_list ap); #endif /* * Use an errorNumber to retrieve the format string, args are jschar * */ extern JS_PUBLIC_API(void) JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); extern JS_PUBLIC_API(void) JS_ReportErrorNumberUCArray(JSContext *cx, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, const jschar **args); /* * As above, but report a warning instead (JSREPORT_IS_WARNING(report.flags)). * Return true if there was no error trying to issue the warning, and if the * warning was not converted into an error due to the JSOPTION_WERROR option * being set, false otherwise. */ extern JS_PUBLIC_API(JSBool) JS_ReportWarning(JSContext *cx, const char *format, ...); extern JS_PUBLIC_API(JSBool) JS_ReportErrorFlagsAndNumber(JSContext *cx, unsigned flags, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); extern JS_PUBLIC_API(JSBool) JS_ReportErrorFlagsAndNumberUC(JSContext *cx, unsigned flags, JSErrorCallback errorCallback, void *userRef, const unsigned errorNumber, ...); /* * Complain when out of memory. */ extern JS_PUBLIC_API(void) JS_ReportOutOfMemory(JSContext *cx); /* * Complain when an allocation size overflows the maximum supported limit. */ extern JS_PUBLIC_API(void) JS_ReportAllocationOverflow(JSContext *cx); struct JSErrorReport { const char *filename; /* source file name, URL, etc., or null */ JSPrincipals *originPrincipals; /* see 'originPrincipals' comment above */ unsigned lineno; /* source line number */ const char *linebuf; /* offending source line without final \n */ const char *tokenptr; /* pointer to error token in linebuf */ const jschar *uclinebuf; /* unicode (original) line buffer */ const jschar *uctokenptr; /* unicode (original) token pointer */ unsigned flags; /* error/warning, etc. */ unsigned errorNumber; /* the error number, e.g. see js.msg */ const jschar *ucmessage; /* the (default) error message */ const jschar **messageArgs; /* arguments for the error message */ int16_t exnType; /* One of the JSExnType constants */ unsigned column; /* zero-based column index in line */ }; /* * JSErrorReport flag values. These may be freely composed. */ #define JSREPORT_ERROR 0x0 /* pseudo-flag for default case */ #define JSREPORT_WARNING 0x1 /* reported via JS_ReportWarning */ #define JSREPORT_EXCEPTION 0x2 /* exception was thrown */ #define JSREPORT_STRICT 0x4 /* error or warning due to strict option */ /* * This condition is an error in strict mode code, a warning if * JS_HAS_STRICT_OPTION(cx), and otherwise should not be reported at * all. We check the strictness of the context's top frame's script; * where that isn't appropriate, the caller should do the right checks * itself instead of using this flag. */ #define JSREPORT_STRICT_MODE_ERROR 0x8 /* * If JSREPORT_EXCEPTION is set, then a JavaScript-catchable exception * has been thrown for this runtime error, and the host should ignore it. * Exception-aware hosts should also check for JS_IsExceptionPending if * JS_ExecuteScript returns failure, and signal or propagate the exception, as * appropriate. */ #define JSREPORT_IS_WARNING(flags) (((flags) & JSREPORT_WARNING) != 0) #define JSREPORT_IS_EXCEPTION(flags) (((flags) & JSREPORT_EXCEPTION) != 0) #define JSREPORT_IS_STRICT(flags) (((flags) & JSREPORT_STRICT) != 0) #define JSREPORT_IS_STRICT_MODE_ERROR(flags) (((flags) & \ JSREPORT_STRICT_MODE_ERROR) != 0) extern JS_PUBLIC_API(JSErrorReporter) JS_GetErrorReporter(JSContext *cx); extern JS_PUBLIC_API(JSErrorReporter) JS_SetErrorReporter(JSContext *cx, JSErrorReporter er); /************************************************************************/ /* * Dates. */ extern JS_PUBLIC_API(JSObject *) JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec); extern JS_PUBLIC_API(JSObject *) JS_NewDateObjectMsec(JSContext *cx, double msec); /* * Infallible predicate to test whether obj is a date object. */ extern JS_PUBLIC_API(JSBool) JS_ObjectIsDate(JSContext *cx, JSObject *obj); /* * Clears the cache of calculated local time from each Date object. * Call to propagate a system timezone change. */ extern JS_PUBLIC_API(void) JS_ClearDateCaches(JSContext *cx); /************************************************************************/ /* * Regular Expressions. */ #define JSREG_FOLD 0x01 /* fold uppercase to lowercase */ #define JSREG_GLOB 0x02 /* global exec, creates array of matches */ #define JSREG_MULTILINE 0x04 /* treat ^ and $ as begin and end of line */ #define JSREG_STICKY 0x08 /* only match starting at lastIndex */ extern JS_PUBLIC_API(JSObject *) JS_NewRegExpObject(JSContext *cx, JSObject *obj, char *bytes, size_t length, unsigned flags); extern JS_PUBLIC_API(JSObject *) JS_NewUCRegExpObject(JSContext *cx, JSObject *obj, jschar *chars, size_t length, unsigned flags); extern JS_PUBLIC_API(void) JS_SetRegExpInput(JSContext *cx, JSObject *obj, JSString *input, JSBool multiline); extern JS_PUBLIC_API(void) JS_ClearRegExpStatics(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSBool) JS_ExecuteRegExp(JSContext *cx, JSObject *obj, JSObject *reobj, jschar *chars, size_t length, size_t *indexp, JSBool test, jsval *rval); /* RegExp interface for clients without a global object. */ extern JS_PUBLIC_API(JSObject *) JS_NewRegExpObjectNoStatics(JSContext *cx, char *bytes, size_t length, unsigned flags); extern JS_PUBLIC_API(JSObject *) JS_NewUCRegExpObjectNoStatics(JSContext *cx, jschar *chars, size_t length, unsigned flags); extern JS_PUBLIC_API(JSBool) JS_ExecuteRegExpNoStatics(JSContext *cx, JSObject *reobj, jschar *chars, size_t length, size_t *indexp, JSBool test, jsval *rval); extern JS_PUBLIC_API(JSBool) JS_ObjectIsRegExp(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(unsigned) JS_GetRegExpFlags(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(JSString *) JS_GetRegExpSource(JSContext *cx, JSObject *obj); /************************************************************************/ extern JS_PUBLIC_API(JSBool) JS_IsExceptionPending(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_GetPendingException(JSContext *cx, jsval *vp); extern JS_PUBLIC_API(void) JS_SetPendingException(JSContext *cx, jsval v); extern JS_PUBLIC_API(void) JS_ClearPendingException(JSContext *cx); extern JS_PUBLIC_API(JSBool) JS_ReportPendingException(JSContext *cx); /* * Save the current exception state. This takes a snapshot of cx's current * exception state without making any change to that state. * * The returned state pointer MUST be passed later to JS_RestoreExceptionState * (to restore that saved state, overriding any more recent state) or else to * JS_DropExceptionState (to free the state struct in case it is not correct * or desirable to restore it). Both Restore and Drop free the state struct, * so callers must stop using the pointer returned from Save after calling the * Release or Drop API. */ extern JS_PUBLIC_API(JSExceptionState *) JS_SaveExceptionState(JSContext *cx); extern JS_PUBLIC_API(void) JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state); extern JS_PUBLIC_API(void) JS_DropExceptionState(JSContext *cx, JSExceptionState *state); /* * If the given value is an exception object that originated from an error, * the exception will contain an error report struct, and this API will return * the address of that struct. Otherwise, it returns NULL. The lifetime of * the error report struct that might be returned is the same as the lifetime * of the exception object. */ extern JS_PUBLIC_API(JSErrorReport *) JS_ErrorFromException(JSContext *cx, jsval v); /* * Given a reported error's message and JSErrorReport struct pointer, throw * the corresponding exception on cx. */ extern JS_PUBLIC_API(JSBool) JS_ThrowReportedError(JSContext *cx, const char *message, JSErrorReport *reportp); /* * Throws a StopIteration exception on cx. */ extern JS_PUBLIC_API(JSBool) JS_ThrowStopIteration(JSContext *cx); extern JS_PUBLIC_API(intptr_t) JS_GetCurrentThread(); /* * A JS runtime always has an "owner thread". The owner thread is set when the * runtime is created (to the current thread) and practically all entry points * into the JS engine check that a runtime (or anything contained in the * runtime: context, compartment, object, etc) is only touched by its owner * thread. Embeddings may check this invariant outside the JS engine by calling * JS_AbortIfWrongThread (which will abort if not on the owner thread, even for * non-debug builds). * * It is possible to "move" a runtime between threads. This is accomplished by * calling JS_ClearRuntimeThread on a runtime's owner thread and then calling * JS_SetRuntimeThread on the new owner thread. The runtime must not be * accessed between JS_ClearRuntimeThread and JS_SetRuntimeThread. Also, the * caller is responsible for synchronizing the calls to Set/Clear. */ extern JS_PUBLIC_API(void) JS_AbortIfWrongThread(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_ClearRuntimeThread(JSRuntime *rt); extern JS_PUBLIC_API(void) JS_SetRuntimeThread(JSRuntime *rt); class JSAutoSetRuntimeThread { JSRuntime *runtime_; public: JSAutoSetRuntimeThread(JSRuntime *runtime) : runtime_(runtime) { JS_SetRuntimeThread(runtime_); } ~JSAutoSetRuntimeThread() { JS_ClearRuntimeThread(runtime_); } }; /************************************************************************/ /* * JS_IsConstructing must be called from within a native given the * native's original cx and vp arguments. If JS_IsConstructing is true, * JS_THIS must not be used; the constructor should construct and return a * new object. Otherwise, the native is called as an ordinary function and * JS_THIS may be used. */ static JS_ALWAYS_INLINE JSBool JS_IsConstructing(JSContext *cx, const jsval *vp) { #ifdef DEBUG JSObject *callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)); if (JS_ObjectIsFunction(cx, callee)) { JSFunction *fun = JS_ValueToFunction(cx, JS_CALLEE(cx, vp)); JS_ASSERT(JS_IsConstructor(fun)); } else { JS_ASSERT(JS_GetClass(callee)->construct != NULL); } #else (void)cx; #endif return JSVAL_IS_MAGIC_IMPL(JSVAL_TO_IMPL(vp[1])); } /* * A constructor can request that the JS engine create a default new 'this' * object of the given class, using the callee to determine parentage and * [[Prototype]]. */ extern JS_PUBLIC_API(JSObject *) JS_NewObjectForConstructor(JSContext *cx, JSClass *clasp, const jsval *vp); /************************************************************************/ #ifdef JS_GC_ZEAL #define JS_DEFAULT_ZEAL_FREQ 100 extern JS_PUBLIC_API(void) JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency); extern JS_PUBLIC_API(void) JS_ScheduleGC(JSContext *cx, uint32_t count); #endif extern JS_PUBLIC_API(void) JS_SetParallelCompilationEnabled(JSContext *cx, bool enabled); typedef enum JSCompilerOption { JSCOMPILER_BASELINE_USECOUNT_TRIGGER, JSCOMPILER_ION_USECOUNT_TRIGGER, JSCOMPILER_PJS_ENABLE } JSCompilerOption; extern JS_PUBLIC_API(void) JS_SetGlobalCompilerOption(JSContext *cx, JSCompilerOption opt, uint32_t value); /* * Convert a uint32_t index into a jsid. */ extern JS_PUBLIC_API(JSBool) JS_IndexToId(JSContext *cx, uint32_t index, jsid *id); /* * Convert chars into a jsid. * * |chars| may not be an index. */ extern JS_PUBLIC_API(JSBool) JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, jsid *idp); /* * Test if the given string is a valid ECMAScript identifier */ extern JS_PUBLIC_API(JSBool) JS_IsIdentifier(JSContext *cx, JSString *str, JSBool *isIdentifier); /* * Return the current script and line number of the most currently running * frame. Returns true if a scripted frame was found, false otherwise. */ extern JS_PUBLIC_API(JSBool) JS_DescribeScriptedCaller(JSContext *cx, JSScript **script, unsigned *lineno); /* * Encode/Decode interpreted scripts and functions to/from memory. */ extern JS_PUBLIC_API(void *) JS_EncodeScript(JSContext *cx, JSScript *script, uint32_t *lengthp); extern JS_PUBLIC_API(void *) JS_EncodeInterpretedFunction(JSContext *cx, JSObject *funobj, uint32_t *lengthp); extern JS_PUBLIC_API(JSScript *) JS_DecodeScript(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); extern JS_PUBLIC_API(JSObject *) JS_DecodeInterpretedFunction(JSContext *cx, const void *data, uint32_t length, JSPrincipals *principals, JSPrincipals *originPrincipals); namespace JS { extern JS_PUBLIC_DATA(const HandleValue) NullHandleValue; extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; extern JS_PUBLIC_DATA(const HandleId) JSID_VOIDHANDLE; extern JS_PUBLIC_DATA(const HandleId) JSID_EMPTYHANDLE; } /* namespace JS */ namespace js { /* * Import some JS:: names into the js namespace so we can make unqualified * references to them. */ using JS::Value; using JS::IsPoisonedValue; using JS::NullValue; using JS::UndefinedValue; using JS::Int32Value; using JS::DoubleValue; using JS::StringValue; using JS::BooleanValue; using JS::ObjectValue; using JS::MagicValue; using JS::NumberValue; using JS::ObjectOrNullValue; using JS::PrivateValue; using JS::PrivateUint32Value; using JS::IsPoisonedPtr; using JS::IsPoisonedId; using JS::StableCharPtr; using JS::TwoByteChars; using JS::Latin1CharsZ; using JS::AutoIdVector; using JS::AutoValueVector; using JS::AutoObjectVector; using JS::AutoFunctionVector; using JS::AutoScriptVector; using JS::AutoIdArray; using JS::AutoGCRooter; using JS::AutoArrayRooter; using JS::AutoVectorRooter; using JS::AutoHashMapRooter; using JS::AutoHashSetRooter; using JS::CallArgs; using JS::IsAcceptableThis; using JS::NativeImpl; using JS::CallReceiver; using JS::CompileOptions; using JS::CallNonGenericMethod; using JS::Rooted; using JS::RootedObject; using JS::RootedModule; using JS::RootedFunction; using JS::RootedScript; using JS::RootedString; using JS::RootedId; using JS::RootedValue; using JS::Handle; using JS::HandleObject; using JS::HandleModule; using JS::HandleFunction; using JS::HandleScript; using JS::HandleString; using JS::HandleId; using JS::HandleValue; using JS::MutableHandle; using JS::MutableHandleObject; using JS::MutableHandleFunction; using JS::MutableHandleScript; using JS::MutableHandleString; using JS::MutableHandleId; using JS::MutableHandleValue; using JS::Zone; } /* namespace js */ #endif /* jsapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsclass.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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" namespace js { class PropertyName; class SpecialId; class PropertyId; // This is equal to JSFunction::class_. Use it in places where you don't want // to #include jsfun.h. extern JS_FRIEND_DATA(js::Class* const) FunctionClassPtr; 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, JSBool *succeeded); typedef JSBool (* DeleteElementOp)(JSContext *cx, HandleObject obj, uint32_t index, JSBool *succeeded); typedef JSBool (* DeleteSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSBool *succeeded); typedef JSObject * (* ObjectOp)(JSContext *cx, HandleObject obj); typedef void (* FinalizeOp)(FreeOp *fop, JSObject *obj); #define JS_CLASS_MEMBERS \ const char *name; \ uint32_t flags; \ \ /* Mandatory function pointer members. */ \ JSPropertyOp addProperty; \ JSDeletePropertyOp delProperty; \ JSPropertyOp getProperty; \ JSStrictPropertyOp setProperty; \ JSEnumerateOp enumerate; \ JSResolveOp resolve; \ JSConvertOp convert; \ \ /* Optional members (may be null). */ \ FinalizeOp finalize; \ 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 pad 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; } bool isCallable() const { return this == js::FunctionClassPtr || call; } 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, ESClass_Date }; /* * 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 GCMethods { static SpecialId initial() { return SpecialId(); } static ThingRootKind kind() { return THING_ROOT_ID; } static bool poisoned(SpecialId id) { return IsPoisonedSpecialId(id); } }; } /* namespace js */ #endif /* jsclass_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsclist.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jscpucfg.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jscpucfg_h #define jscpucfg_h #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_WORD 8 # define JS_BITS_PER_WORD_LOG2 6 # 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_WORD 4 # define JS_BITS_PER_WORD_LOG2 5 #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 /* jscpucfg_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsdbgapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 "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(JSRuntime *rt, 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); /************************************************************************/ // Raw JSScript* because this needs to be callable from a signal handler. extern JS_PUBLIC_API(unsigned) JS_PCToLineNumber(JSContext *cx, JSScript *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_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_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); /* Call the context debug handler on the topmost scripted frame. */ extern JS_FRIEND_API(JSBool) js_CallContextDebugHandler(JSContext *cx); #endif /* jsdbgapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsfriendapi.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jsfriendapi_h #define jsfriendapi_h #include "mozilla/MemoryReporting.h" #include "jsclass.h" #include "jsprvtd.h" #include "jspubtd.h" #include "js/CallArgs.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) namespace JS { template class Heap; } /* namespace JS */ 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, JSObject *obj); extern JS_FRIEND_API(JSFunction *) JS_GetObjectFunction(JSObject *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(JS::HandleObject 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(JSString *) JS_BasicObjectToString(JSContext *cx, JS::HandleObject obj); extern JS_FRIEND_API(JSBool) js_GetterOnlyPropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JSBool strict, JS::MutableHandleValue vp); JS_FRIEND_API(void) js_ReportOverRecursed(JSContext *maybecx); JS_FRIEND_API(bool) js_ObjectClassIs(JSContext *cx, JS::HandleObject obj, js::ESClassValue classValue); JS_FRIEND_API(const char *) js_ObjectClassName(JSContext *cx, JS::HandleObject obj); JS_FRIEND_API(bool) js_AddObjectRoot(JSRuntime *rt, JSObject **objp); JS_FRIEND_API(void) js_RemoveObjectRoot(JSRuntime *rt, JSObject **objp); #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, JS::HandleObject 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, JS::Handle script, jschar **src, uint32_t *length); extern JS_FRIEND_API(void) JS_SetSourceHook(JSRuntime *rt, JS_SourceHook hook); namespace js { 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); #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); /* * Returns whether we're in a non-strict property set (in that we're in a * non-strict script and the bytecode we're on is a property set). The return * value does NOT indicate any sort of exception was thrown: it's just a * boolean. */ extern JS_FRIEND_API(bool) IsInNonStrictPropertySet(JSContext *cx); 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(mozilla::MallocSizeOf 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; JSObject *_1; 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 { static const size_t LENGTH_SHIFT = 4; size_t lengthAndFlags; const jschar *chars; }; } /* namespace shadow */ // These are equal to |&{Function,Object,OuterWindow}ProxyObject::class_|. Use // them in places where you don't want to #include vm/ProxyObject.h. extern JS_FRIEND_DATA(js::Class* const) FunctionProxyClassPtr; extern JS_FRIEND_DATA(js::Class* const) ObjectProxyClassPtr; extern JS_FRIEND_DATA(js::Class* const) OuterWindowProxyClassPtr; // This is equal to |&JSObject::class_|. Use it in places where you don't want // to #include jsobj.h. extern JS_FRIEND_DATA(js::Class* const) ObjectClassPtr; inline js::Class * GetObjectClass(JSObject *obj) { return reinterpret_cast(obj)->type->clasp; } inline JSClass * GetObjectJSClass(JSObject *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) IsFunctionObject(JSObject *obj); JS_FRIEND_API(bool) IsScopeObject(JSObject *obj); JS_FRIEND_API(bool) IsCallObject(JSObject *obj); inline JSObject * GetObjectParent(JSObject *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(JSObject *obj); JS_FRIEND_API(JSObject *) GetGlobalForObjectCrossCompartment(JSObject *obj); // For legacy consumers only. This whole concept is going away soon. JS_FRIEND_API(JSObject *) DefaultObjectForContextOrNull(JSContext *cx); JS_FRIEND_API(void) SetDefaultObjectForContext(JSContext *cx, JSObject *obj); JS_FRIEND_API(void) NotifyAnimationActivity(JSObject *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, const JSPropertySpec *ps, const JSFunctionSpec *fs, const JSPropertySpec *static_ps, const JSFunctionSpec *static_fs); JS_FRIEND_API(const Value &) GetFunctionNativeReserved(JSObject *fun, size_t which); JS_FRIEND_API(void) SetFunctionNativeReserved(JSObject *fun, size_t which, const Value &val); inline bool GetObjectProto(JSContext *cx, JS::Handle obj, JS::MutableHandle proto) { js::Class *clasp = GetObjectClass(obj); if (clasp == js::ObjectProxyClassPtr || clasp == js::OuterWindowProxyClassPtr || clasp == js::FunctionProxyClassPtr) { return JS_GetPrototype(cx, obj, proto); } proto.set(reinterpret_cast(obj.get())->type->proto); return true; } inline void * GetObjectPrivate(JSObject *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(JSObject *obj, size_t slot) { JS_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); return reinterpret_cast(obj)->slotRef(slot); } JS_FRIEND_API(void) SetReservedSlotWithBarrier(JSObject *obj, size_t slot, const Value &value); inline void SetReservedSlot(JSObject *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(JSObject *obj); inline const Value & GetObjectSlot(JSObject *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 size_t GetAtomLength(JSAtom *atom) { using shadow::Atom; return reinterpret_cast(atom)->lengthAndFlags >> Atom::LENGTH_SHIFT; } inline JSLinearString * AtomToLinearString(JSAtom *atom) { return reinterpret_cast(atom); } static inline js::PropertyOp CastAsJSPropertyOp(JSObject *object) { return JS_DATA_TO_FUNC_PTR(js::PropertyOp, object); } static inline js::StrictPropertyOp CastAsJSStrictPropertyOp(JSObject *object) { return JS_DATA_TO_FUNC_PTR(js::StrictPropertyOp, object); } JS_FRIEND_API(bool) GetPropertyNames(JSContext *cx, JSObject *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(JSObject *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; } inline uintptr_t GetNativeStackLimit(JSContext *cx) { return GetNativeStackLimit(GetRuntime(cx)); } /* * 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(cx), &stackDummy_)) { \ js_ReportOverRecursed(cx); \ onerror; \ } \ JS_END_MACRO #define JS_CHECK_RECURSION_WITH_SP_DONT_REPORT(cx, sp, onerror) \ JS_BEGIN_MACRO \ if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \ 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(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, JSScript *script, void *ip); #ifdef JS_THREADSAFE 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, JS::Handle desc); extern JS_FRIEND_API(AnalysisPurgeCallback) SetAnalysisPurgeCallback(JSRuntime *rt, AnalysisPurgeCallback callback); typedef JSBool (* DOMInstanceClassMatchesProto)(JS::HandleObject 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 DOMProxy proxies in the DOM, for use by ICs. */ /* * The DOMProxyShadowsCheck function will be called to check if the property for * id should be gotten from the prototype, or if there is an own property that * shadows it. * If DoesntShadow is returned then the slot at listBaseExpandoSlot should * either be undefined or point to an expando object that would contain the own * property. * If DoesntShadowUnique is returned then the slot at listBaseExpandoSlot should * contain a private pointer to a ExpandoAndGeneration, which contains a * JS::Value that should either be undefined or point to an expando object, and * a uint32 value. If that value changes then the IC for getting a property will * be invalidated. */ struct ExpandoAndGeneration { ExpandoAndGeneration() : expando(UndefinedValue()), generation(0) {} void Unlink() { ++generation; expando.setUndefined(); } JS::Heap expando; uint32_t generation; }; typedef enum DOMProxyShadowsResult { ShadowCheckFailed, Shadows, DoesntShadow, DoesntShadowUnique } DOMProxyShadowsResult; typedef DOMProxyShadowsResult (* DOMProxyShadowsCheck)(JSContext* cx, JS::HandleObject object, JS::HandleId id); JS_FRIEND_API(void) SetDOMProxyInformation(void *domProxyHandlerFamily, uint32_t domProxyExpandoSlot, DOMProxyShadowsCheck domProxyShadowsCheck); void *GetDOMProxyHandlerFamily(); uint32_t GetDOMProxyExpandoSlot(); DOMProxyShadowsCheck GetDOMProxyShadowsCheck(); } /* 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(JSObject *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 */ /* * A helper for building up an ArrayBuffer object's data * before creating the ArrayBuffer itself. Will do doubling * based reallocation, up to an optional maximum growth given. * * When all the data has been appended, call getArrayBuffer, * passing in the JSContext* for which the ArrayBuffer object * is to be created. This also implicitly resets the builder, * or it can be reset explicitly at any point by calling reset(). */ class ArrayBufferBuilder { void *rawcontents_; uint8_t *dataptr_; uint32_t capacity_; uint32_t length_; public: ArrayBufferBuilder() : rawcontents_(NULL), dataptr_(NULL), capacity_(0), length_(0) { } ~ArrayBufferBuilder() { reset(); } void reset() { if (rawcontents_) JS_free(NULL, rawcontents_); rawcontents_ = dataptr_ = NULL; capacity_ = length_ = 0; } // will truncate if newcap is < length() bool setCapacity(uint32_t newcap) { if (!JS_ReallocateArrayBufferContents(NULL, newcap, &rawcontents_, &dataptr_)) return false; capacity_ = newcap; if (length_ > newcap) length_ = newcap; return true; } // Append datalen bytes from data to the current buffer. If we // need to grow the buffer, grow by doubling the size up to a // maximum of maxgrowth (if given). If datalen is greater than // what the new capacity would end up as, then grow by datalen. // // The data parameter must not overlap with anything beyond the // builder's current valid contents [0..length) bool append(const uint8_t *newdata, uint32_t datalen, uint32_t maxgrowth = 0) { if (length_ + datalen > capacity_) { uint32_t newcap; // double while under maxgrowth or if not specified if (!maxgrowth || capacity_ < maxgrowth) newcap = capacity_ * 2; else newcap = capacity_ + maxgrowth; // but make sure there's always enough to satisfy our request if (newcap < length_ + datalen) newcap = length_ + datalen; // did we overflow? if (newcap < capacity_) return false; if (!setCapacity(newcap)) return false; } // assert that the region isn't overlapping so we can memcpy; JS_ASSERT(!areOverlappingRegions(newdata, datalen, dataptr_ + length_, datalen)); memcpy(dataptr_ + length_, newdata, datalen); length_ += datalen; return true; } uint8_t *data() { return dataptr_; } uint32_t length() { return length_; } uint32_t capacity() { return capacity_; } JSObject* getArrayBuffer(JSContext *cx) { // we need to check for length_ == 0, because nothing may have been // added if (capacity_ > length_ || length_ == 0) { if (!setCapacity(length_)) return NULL; } JSObject* obj = JS_NewArrayBufferWithContents(cx, rawcontents_); if (!obj) return NULL; rawcontents_ = dataptr_ = NULL; length_ = capacity_ = 0; return obj; } protected: static bool areOverlappingRegions(const uint8_t *start1, uint32_t length1, const uint8_t *start2, uint32_t length2) { const uint8_t *end1 = start1 + length1; const uint8_t *end2 = start2 + length2; const uint8_t *max_start = start1 > start2 ? start1 : start2; const uint8_t *min_end = end1 < end2 ? end1 : end2; return max_start < min_end; } }; } /* 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. 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); /* * A class, expected to be passed by value, which represents the CallArgs for a * JSJitGetterOp. */ class JSJitGetterCallArgs : protected JS::MutableHandleValue { public: explicit JSJitGetterCallArgs(const JS::CallArgs& args) : JS::MutableHandleValue(args.rval()) {} explicit JSJitGetterCallArgs(JS::Rooted* rooted) : JS::MutableHandleValue(rooted) {} JS::MutableHandleValue rval() { return *this; } }; /* * A class, expected to be passed by value, which represents the CallArgs for a * JSJitSetterOp. */ class JSJitSetterCallArgs : protected JS::MutableHandleValue { public: explicit JSJitSetterCallArgs(const JS::CallArgs& args) : JS::MutableHandleValue(args[0]) {} JS::MutableHandleValue operator[](unsigned i) { MOZ_ASSERT(i == 0); return *this; } unsigned length() const { return 1; } // Add get() or maybe hasDefined() as needed }; struct JSJitMethodCallArgsTraits; /* * A class, expected to be passed by reference, which represents the CallArgs * for a JSJitMethodOp. */ class JSJitMethodCallArgs : protected JS::detail::CallArgsBase { private: typedef JS::detail::CallArgsBase Base; friend struct JSJitMethodCallArgsTraits; public: explicit JSJitMethodCallArgs(const JS::CallArgs& args) { argv_ = args.array(); argc_ = args.length(); } JS::MutableHandleValue rval() const { return Base::rval(); } unsigned length() const { return Base::length(); } JS::MutableHandleValue operator[](unsigned i) const { return Base::operator[](i); } bool hasDefined(unsigned i) const { return Base::hasDefined(i); } // Add get() as needed }; struct JSJitMethodCallArgsTraits { static const size_t offsetOfArgv = offsetof(JSJitMethodCallArgs, argv_); static const size_t offsetOfArgc = offsetof(JSJitMethodCallArgs, argc_); }; /* * 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 (* JSJitGetterOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, JSJitGetterCallArgs args); typedef bool (* JSJitSetterOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, JSJitSetterCallArgs args); typedef bool (* JSJitMethodOp)(JSContext *cx, JS::HandleObject thisObj, void *specializedThis, const JSJitMethodCallArgs& args); struct JSJitInfo { enum OpType { Getter, Setter, Method, OpType_None }; union { JSJitGetterOp getter; JSJitSetterOp setter; JSJitMethodOp method; }; 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 */ /* An alternative native that's safe to call in parallel mode. */ JSParallelNative parallelNative; }; #define JS_JITINFO_NATIVE_PARALLEL(op) \ {{NULL},0,0,JSJitInfo::OpType_None,false,false,false,JSVAL_TYPE_MISSING,op} static JS_ALWAYS_INLINE const JSJitInfo * FUNCTION_VALUE_TO_JITINFO(const JS::Value& v) { JS_ASSERT(js::GetObjectClass(&v.toObject()) == js::FunctionClassPtr); 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 typedef bool (* ObjectMetadataCallback)(JSContext *cx, JSObject **pmetadata); /* * Specify a callback to invoke when creating each JS object in the current * compartment, which may return a metadata object to associate with the * object. Objects with different metadata have different shape hierarchies, * so for efficiency, objects should generally try to share metadata objects. */ JS_FRIEND_API(void) SetObjectMetadataCallback(JSContext *cx, ObjectMetadataCallback callback); /* Manipulate the metadata associated with an object. */ JS_FRIEND_API(bool) SetObjectMetadata(JSContext *cx, JS::HandleObject obj, JS::HandleObject metadata); JS_FRIEND_API(JSObject *) GetObjectMetadata(JSObject *obj); /* ES5 8.12.8. */ extern JS_FRIEND_API(JSBool) DefaultValue(JSContext *cx, JS::HandleObject obj, JSType hint, MutableHandleValue vp); /* * Helper function. To approximate a call to the [[DefineOwnProperty]] internal * method described in ES5, first call this, then call JS_DefinePropertyById. * * JS_DefinePropertyById by itself does not enforce the invariants on * non-configurable properties when obj->isNative(). This function performs the * relevant checks (specified in ES5 8.12.9 [[DefineOwnProperty]] steps 1-11), * but only if obj is native. * * The reason for the messiness here is that ES5 uses [[DefineOwnProperty]] as * a sort of extension point, but there is no hook in js::Class, * js::ProxyHandler, or the JSAPI with precisely the right semantics for it. */ extern JS_FRIEND_API(bool) CheckDefineProperty(JSContext *cx, HandleObject obj, HandleId id, HandleValue value, PropertyOp getter, StrictPropertyOp setter, unsigned attrs); } /* 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); #ifdef JSGC_GENERATIONAL extern JS_FRIEND_API(void) JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSObject *key, void *data); extern JS_FRIEND_API(void) JS_StoreStringPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSString *key, void *data); #else inline void JS_StoreObjectPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSObject *key, void *data) {} inline void JS_StoreStringPostBarrierCallback(JSContext* cx, void (*callback)(JSTracer *trc, void *key, void *data), JSString *key, void *data) {} #endif /* JSGC_GENERATIONAL */ #endif /* jsfriendapi_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jslock.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jslock_h #define jslock_h #ifdef JS_THREADSAFE # include "jsapi.h" # include "pratom.h" # include "prcvar.h" # include "prinit.h" # include "prlock.h" # include "prthread.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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsperf.h ================================================ /* -*- 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 perf_jsperf_h #define perf_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, JSObject *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 /* perf_jsperf_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsprf.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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 #include #include "jstypes.h" /* ** 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsprototypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* 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) \ macro(Type, 38, js_InitBinaryDataClasses) \ macro(Data, 39, js_InitBinaryDataClasses) \ macro(uint8, 40, js_InitBinaryDataClasses) \ macro(uint16, 41, js_InitBinaryDataClasses) \ macro(uint32, 42, js_InitBinaryDataClasses) \ macro(uint64, 43, js_InitBinaryDataClasses) \ macro(int8, 44, js_InitBinaryDataClasses) \ macro(int16, 45, js_InitBinaryDataClasses) \ macro(int32, 46, js_InitBinaryDataClasses) \ macro(int64, 47, js_InitBinaryDataClasses) \ macro(float32, 48, js_InitBinaryDataClasses) \ macro(float64, 49, js_InitBinaryDataClasses) \ macro(ArrayType, 50, js_InitBinaryDataClasses) \ macro(StructType, 51, js_InitBinaryDataClasses) \ macro(ArrayTypeObject, 52, js_InitBinaryDataClasses) \ #endif /* jsprototypes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsproxy.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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(JSContext *cx, HandleObject proxy, bool *extensible) = 0; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args); virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args); 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 const char *className(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(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) 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 const char *className(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(JSContext *cx, HandleObject proxy, bool *extensible); static bool call(JSContext *cx, HandleObject proxy, const CallArgs &args); static bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args); 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 const char *className(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::ObjectProxyClassPtr || clasp == js::OuterWindowProxyClassPtr; } inline bool IsFunctionProxyClass(const Class *clasp) { return clasp == js::FunctionProxyClassPtr; } inline bool IsProxyClass(const Class *clasp) { return IsObjectProxyClass(clasp) || IsFunctionProxyClass(clasp); } inline bool IsObjectProxy(JSObject *obj) { return IsObjectProxyClass(GetObjectClass(obj)); } inline bool IsFunctionProxy(JSObject *obj) { return IsFunctionProxyClass(GetObjectClass(obj)); } inline bool IsProxy(JSObject *obj) { return IsProxyClass(GetObjectClass(obj)); } /* * These are part of the API. * * NOTE: PROXY_PRIVATE_SLOT 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 PROXY_PRIVATE_SLOT = 0; const uint32_t PROXY_HANDLER_SLOT = 1; const uint32_t PROXY_EXTRA_SLOT = 2; inline BaseProxyHandler * GetProxyHandler(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return (BaseProxyHandler *) GetReservedSlot(obj, PROXY_HANDLER_SLOT).toPrivate(); } inline const Value & GetProxyPrivate(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return GetReservedSlot(obj, PROXY_PRIVATE_SLOT); } inline JSObject * GetProxyTargetObject(JSObject *obj) { JS_ASSERT(IsProxy(obj)); return GetProxyPrivate(obj).toObjectOrNull(); } inline const Value & GetProxyExtra(JSObject *obj, size_t n) { JS_ASSERT(IsProxy(obj)); return GetReservedSlot(obj, PROXY_EXTRA_SLOT + n); } inline void SetProxyHandler(JSObject *obj, BaseProxyHandler *handler) { JS_ASSERT(IsProxy(obj)); SetReservedSlot(obj, PROXY_HANDLER_SLOT, PrivateValue(handler)); } inline void SetProxyExtra(JSObject *obj, size_t n, const Value &extra) { JS_ASSERT(IsProxy(obj)); JS_ASSERT(n <= 1); SetReservedSlot(obj, PROXY_EXTRA_SLOT + n, extra); } enum ProxyCallable { ProxyNotCallable = false, ProxyIsCallable = true }; JS_FRIEND_API(JSObject *) NewProxyObject(JSContext *cx, BaseProxyHandler *handler, HandleValue 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, JS::HandleObject obj); #endif /* jsproxy_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsprvtd.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 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" #include "js/HashTable.h" #include "js/Vector.h" /* * 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; /* String typedefs. */ class JSDependentString; class JSExtensibleString; class JSExternalString; class JSLinearString; class JSRope; class JSAtom; class JSWrapper; namespace js { struct ArgumentsData; struct Class; class AutoNameVector; class RegExpGuard; class RegExpObject; class RegExpObjectBuilder; class RegExpShared; class RegExpStatics; class MatchPairs; class PropertyName; class LazyScript; enum RegExpFlag { IgnoreCaseFlag = 0x01, GlobalFlag = 0x02, MultilineFlag = 0x04, StickyFlag = 0x08, NoFlags = 0x00, AllFlags = 0x0f }; class StringBuffer; class FrameRegs; class StackFrame; class ScriptFrameIter; class Proxy; class JS_FRIEND_API(AutoEnterPolicy); 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 JSParallelNative ParallelNative; typedef JSThreadSafeNative ThreadSafeNative; typedef JSPropertyOp PropertyOp; typedef JSStrictPropertyOp StrictPropertyOp; typedef JSPropertyDescriptor PropertyDescriptor; struct SourceCompressionToken; namespace frontend { struct BytecodeEmitter; struct Definition; class FullParseHandler; class FunctionBox; class ObjectBox; struct Token; struct TokenPos; class TokenStream; class ParseMapPool; class ParseNode; template class 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 */ /* "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, JS::Handle obj); /* Signature for class initialization ops. */ typedef JSObject * (* JSClassInitializerOp)(JSContext *cx, JS::HandleObject 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, JS::HandleObject obj, JSBool keysonly); #endif /* jsprvtd_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jspubtd.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jspubtd_h #define jspubtd_h /* * JS public API typedefs. */ #include "mozilla/PodOperations.h" #include "jsprototypes.h" #include "jstypes.h" #if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING) || (defined(DEBUG) && !defined(_WIN32)) # define JSGC_TRACK_EXACT_ROOTS #endif 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; class JS_PUBLIC_API(AutoGCRooter); 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. */ // 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) */ #ifdef WIN32 typedef wchar_t jschar; #else typedef uint16_t jschar; #endif /* * Run-time version enumeration. For compile-time version checking, please use * the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION, * MOZJS_MINOR_VERSION, MOZJS_PATCH_VERSION, and MOZJS_ALPHA definitions. */ 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 see them if * it implements JSTraceCallback. */ JSTRACE_LAZY_SCRIPT, 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; class JSFlatString; class JSFunction; class JSObject; class JSScript; class JSStableString; // long story class JSString; #ifdef JS_THREADSAFE typedef struct PRCallOnceType JSCallOnceType; #else typedef JSBool JSCallOnceType; #endif typedef JSBool (*JSInitCallback)(void); namespace JS { namespace shadow { struct Runtime { /* Restrict zone access during Minor GC. */ bool needsBarrier_; #ifdef JSGC_GENERATIONAL /* Allow inlining of Nursery::isInside. */ uintptr_t gcNurseryStart_; uintptr_t gcNurseryEnd_; #endif Runtime() : needsBarrier_(false) #ifdef JSGC_GENERATIONAL , gcNurseryStart_(0) , gcNurseryEnd_(0) #endif {} }; } /* namespace shadow */ } /* namespace JS */ namespace js { /* * Parallel operations in general can have one of three states. They may * succeed, fail, or "bail", where bail indicates that the code encountered an * unexpected condition and should be re-run sequentially. Different * subcategories of the "bail" state are encoded as variants of TP_RETRY_*. */ enum ParallelResult { TP_SUCCESS, TP_RETRY_SEQUENTIALLY, TP_RETRY_AFTER_GC, TP_FATAL }; struct ThreadSafeContext; struct ForkJoinSlice; class ExclusiveContext; 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_PROPERTY_DESCRIPTOR, 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 {}; template <> struct RootKind : SpecificRootKind {}; struct ContextFriendFields { protected: JSRuntime *const runtime_; /* The current compartment. */ JSCompartment *compartment_; /* The current zone. */ JS::Zone *zone_; public: explicit ContextFriendFields(JSRuntime *rt) : runtime_(rt), compartment_(NULL), zone_(NULL), autoGCRooters(NULL) { #ifdef JSGC_TRACK_EXACT_ROOTS mozilla::PodArrayZero(thingGCRooters); #endif #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) skipGCRooters = NULL; #endif } static const ContextFriendFields *get(const JSContext *cx) { return reinterpret_cast(cx); } static ContextFriendFields *get(JSContext *cx) { return reinterpret_cast(cx); } #ifdef JSGC_TRACK_EXACT_ROOTS /* * 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 /* Stack of thread-stack-allocated GC roots. */ JS::AutoGCRooter *autoGCRooters; friend JSRuntime *GetRuntime(const JSContext *cx); friend JSCompartment *GetContextCompartment(const JSContext *cx); friend JS::Zone *GetContextZone(const JSContext *cx); }; 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 : JS::shadow::Runtime { struct PerThreadDummy { void *field1; uintptr_t field2; #ifdef DEBUG uint64_t field3; #endif } mainThread; }; public: PerThreadDataFriendFields(); #ifdef JSGC_TRACK_EXACT_ROOTS /* * 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 |JS::shadow::Runtime|. // 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 |JS::shadow::Runtime|. // Tested by a JS_STATIC_ASSERT in |jsfriendapi.cpp| return reinterpret_cast( reinterpret_cast(rt) + RuntimeMainThreadOffset); } }; } /* namespace js */ #endif /* jspubtd_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jstypes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* ** 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) /*********************************************************************** ** 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsutil.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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/. */ /* * PR assertion checker. */ #ifndef jsutil_h #define jsutil_h #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/GuardObjects.h" #ifdef USE_ZLIB #include #endif #include "js/Utility.h" /* 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); } 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 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); } /*****************************************************************************/ /* 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 */ /* 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 MOZ_IS_GCC #if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) # 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 #endif #endif #if !defined(JS_SILENCE_UNUSED_VALUE_IN_EXPR) # define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ JS_BEGIN_MACRO \ expr; \ JS_END_MACRO #endif #endif /* jsutil_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jsversion.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 jsversion_h #define jsversion_h /* * Deprecated JS_VERSION handler. */ #ifdef JS_VERSION # if JS_VERSION == 185 # warning "JS_VERSION defined but unsupported (legacy)" # elif JS_VERSION < 185 # error "Unsupported JS_VERSION" # else # error "Unknown JS_VERSION" # endif #endif /* * JS Capability Macros. */ #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 */ /* 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_ASSUME_UNREACHABLE("don't call this! to be used in the new object representation") #endif #endif /* jsversion_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/jswrapper.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 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 CheckedUnwrap) will throw. Otherwise, they will succeed. */ void setSafeToUnwrap(bool safe) { mSafeToUnwrap = safe; } 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(JSObject *wrapper); static JSObject *wrappedObject(JSObject *wrapper); unsigned flags() const { return mFlags; } explicit Wrapper(unsigned flags, bool hasPrototype = false); virtual ~Wrapper(); static Wrapper singleton; static Wrapper singletonWithPrototype; }; /* 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(JSContext *cx, HandleObject wrapper, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject wrapper, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject wrapper, const CallArgs &args) 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 const char *className(JSContext *cx, HandleObject proxy) 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(JSContext *cx, HandleObject wrapper, bool *extensible) 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 defaultValue(JSContext *cx, HandleObject wrapper, JSType hint, MutableHandleValue vp) 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(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE; virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE; virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) 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 const char *className(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 bool getElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index, MutableHandleValue vp, bool *present) MOZ_OVERRIDE; virtual bool getPrototypeOf(JSContext *cx, HandleObject proxy, MutableHandleObject protop) MOZ_OVERRIDE; static DeadObjectProxy singleton; }; extern JSObject * TransparentObjectWrapper(JSContext *cx, HandleObject existing, HandleObject obj, HandleObject wrappedProto, HandleObject 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(JSObject *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 *) UncheckedUnwrap(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 *) CheckedUnwrap(JSObject *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(JSObject *obj, bool stopAtOuter = true); JS_FRIEND_API(bool) IsCrossCompartmentWrapper(JSObject *obj); bool IsDeadProxyObject(JSObject *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 /* jswrapper_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/AllocPolicy.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * An allocation policy concept, usable for structures and algorithms to * control how memory is allocated and how failures are handled. */ #ifndef mozilla_AllocPolicy_h #define mozilla_AllocPolicy_h #include #include namespace mozilla { /* * Allocation policies are used to implement the standard allocation behaviors * in a customizable way. Additionally, custom behaviors may be added to these * behaviors, such as additionally reporting an error through an out-of-band * mechanism when OOM occurs. The concept modeled here is as follows: * * - public copy constructor, assignment, destructor * - void* malloc_(size_t) * Responsible for OOM reporting when null is returned. * - void* calloc_(size_t) * Responsible for OOM reporting when null is returned. * - void* realloc_(void*, size_t, size_t) * Responsible for OOM reporting when null is returned. 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*) * - void reportAllocOverflow() const * Called on allocation overflow (that is, an allocation implicitly tried * to allocate more than the available memory space -- think allocating an * array of large-size objects, where N * size overflows) before null is * returned. * * mfbt provides (and typically uses by default) only MallocAllocPolicy, which * does nothing more than delegate to the malloc/alloc/free functions. */ /* * A policy that straightforwardly uses malloc/calloc/realloc/free and adds no * extra behaviors. */ class MallocAllocPolicy { public: void* malloc_(size_t bytes) { return malloc(bytes); } void* calloc_(size_t bytes) { return calloc(bytes, 1); } void* realloc_(void* p, size_t oldBytes, size_t bytes) { return realloc(p, bytes); } void free_(void* p) { free(p); } void reportAllocOverflow() const {} }; } // namespace mozilla #endif /* mozilla_AllocPolicy_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Array.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 compile-time constant-length array with bounds-checking assertions. */ #ifndef mozilla_Array_h #define mozilla_Array_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include namespace mozilla { template class Array { T arr[Length]; public: T& operator[](size_t i) { MOZ_ASSERT(i < Length); return arr[i]; } const T& operator[](size_t i) const { MOZ_ASSERT(i < Length); return arr[i]; } }; template class Array { public: T& operator[](size_t i) { MOZ_ASSUME_UNREACHABLE("indexing into zero-length array"); } const T& operator[](size_t i) const { MOZ_ASSUME_UNREACHABLE("indexing into zero-length array"); } }; } /* namespace mozilla */ #endif /* mozilla_Array_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Assertions.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "mozilla/Likely.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* in C. * In C++11, static_assert is provided by the compiler to the same effect. * 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 { ... }; * // C * MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0, * "S should be a multiple of word size for efficiency"); * // C++11 * 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. */ #ifndef __cplusplus /* * 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 #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) #else #define MOZ_STATIC_ASSERT_IF(cond, expr, reason) static_assert(!(cond) || (expr), reason) #endif #ifdef __cplusplus extern "C" { #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 or MOZ_CRASH 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 } static MOZ_ALWAYS_INLINE void MOZ_ReportCrash(const char* s, const char* file, int ln) { #ifdef ANDROID __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln); #else fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln); fflush(stderr); #endif } /** * MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH(). You should * call MOZ_CRASH instead. */ #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. * * We follow TerminateProcess() with a call to MOZ_NoReturn() so that the * compiler doesn't hassle us to provide a return statement after a * MOZ_REALLY_CRASH() call. * * (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.) */ __declspec(noreturn) __inline void MOZ_NoReturn() {} # ifdef __cplusplus # define MOZ_REALLY_CRASH() \ do { \ __debugbreak(); \ *((volatile int*) NULL) = 123; \ ::TerminateProcess(::GetCurrentProcess(), 3); \ ::MOZ_NoReturn(); \ } while (0) # else # define MOZ_REALLY_CRASH() \ do { \ __debugbreak(); \ *((volatile int*) NULL) = 123; \ TerminateProcess(GetCurrentProcess(), 3); \ MOZ_NoReturn(); \ } while (0) # endif #else # ifdef __cplusplus # define MOZ_REALLY_CRASH() \ do { \ *((volatile int*) NULL) = 123; \ ::abort(); \ } while (0) # else # define MOZ_REALLY_CRASH() \ do { \ *((volatile int*) NULL) = 123; \ abort(); \ } while (0) # endif #endif /* * MOZ_CRASH([explanation-string]) 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. * * The optional explanation-string, if provided, must be a string literal * explaining why we're crashing. This argument is intended for use with * MOZ_CRASH() calls whose rationale is non-obvious; don't use it if it's * obvious why we're crashing. * * If we're a DEBUG build and we crash at a MOZ_CRASH which provides an * explanation-string, we print the string to stderr. Otherwise, we don't * print anything; this is because we want MOZ_CRASH to be 100% safe in release * builds, and it's hard to print to stderr safely when memory might have been * corrupted. */ #ifndef DEBUG # define MOZ_CRASH(...) MOZ_REALLY_CRASH() #else # define MOZ_CRASH(...) \ do { \ MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \ MOZ_REALLY_CRASH(); \ } while(0) #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 (MOZ_UNLIKELY(!(expr))) { \ MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \ MOZ_REALLY_CRASH(); \ } \ } while (0) /* Now the two-argument form. */ # define MOZ_ASSERT_HELPER2(expr, explain) \ do { \ if (MOZ_UNLIKELY(!(expr))) { \ MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \ MOZ_REALLY_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_ASSUME_UNREACHABLE_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_ASSUME_UNREACHABLE, which uses this when * appropriate. */ #if defined(__clang__) # define MOZ_ASSUME_UNREACHABLE_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_ASSUME_UNREACHABLE_MARKER() __builtin_unreachable() # else # ifdef __cplusplus # define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() # else # define MOZ_ASSUME_UNREACHABLE_MARKER() abort() # endif # endif #elif defined(_MSC_VER) # define MOZ_ASSUME_UNREACHABLE_MARKER() __assume(0) #else # ifdef __cplusplus # define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() # else # define MOZ_ASSUME_UNREACHABLE_MARKER() abort() # endif #endif /* * MOZ_ASSUME_UNREACHABLE([reason]) tells the compiler that it can assume that * the macro call cannot be reached during execution. This lets the compiler * generate better-optimized code under some circumstances, at the expense of * the program's behavior being undefined if control reaches the * MOZ_ASSUME_UNREACHABLE. * * In Gecko, you probably should not use this macro outside of performance- or * size-critical code, because it's unsafe. If you don't care about code size * or performance, you should probably use MOZ_ASSERT or MOZ_CRASH. * * SpiderMonkey is a different beast, and there it's acceptable to use * MOZ_ASSUME_UNREACHABLE more widely. * * Note that MOZ_ASSUME_UNREACHABLE is noreturn, so it's valid not to return a * value following a MOZ_ASSUME_UNREACHABLE call. * * Example usage: * * enum ValueType { * VALUE_STRING, * VALUE_INT, * VALUE_FLOAT * }; * * int ptrToInt(ValueType type, void* value) { * { * // We know for sure that type is either INT or FLOAT, and we want this * // code to run as quickly as possible. * switch (type) { * case VALUE_INT: * return *(int*) value; * case VALUE_FLOAT: * return (int) *(float*) value; * default: * MOZ_ASSUME_UNREACHABLE("can only handle VALUE_INT and VALUE_FLOAT"); * } * } */ #if defined(DEBUG) # define MOZ_ASSUME_UNREACHABLE(...) \ do { \ MOZ_ASSERT(false, "MOZ_ASSUME_UNREACHABLE(" __VA_ARGS__ ")"); \ MOZ_ASSUME_UNREACHABLE_MARKER(); \ } while (0) #else # define MOZ_ASSUME_UNREACHABLE(reason) MOZ_ASSUME_UNREACHABLE_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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Atomics.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 (almost always) lock-free atomic operations. The operations here * are a subset of that which can be found in C++11's header, with a * different API to enforce consistent memory ordering constraints. * * Anyone caught using |volatile| for inter-thread memory safety needs to be * sent a copy of this header and the C++11 standard. */ #ifndef mozilla_Atomics_h #define mozilla_Atomics_h #include "mozilla/Assertions.h" #include "mozilla/TypeTraits.h" #include /* * Our minimum deployment target on clang/OS X is OS X 10.6, whose SDK * does not have . So be sure to check for support * along with C++0x support. */ #if defined(__clang__) /* * clang doesn't like libstdc++'s version of before GCC 4.7, * due to the loose typing of the __sync_* family of functions done by * GCC. We do not have a particularly good way to detect this sort of * case at this point, so just assume that if we're on a Linux system, * we can't use the system's . * * OpenBSD uses an old libstdc++ 4.2.1 and thus doesnt have . */ # if !defined(__linux__) && !defined(__OpenBSD__) && \ (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && \ __has_include() # define MOZ_HAVE_CXX11_ATOMICS # endif /* * Android uses a different C++ standard library that does not provide * support for . * * GCC 4.5.x and 4.6.x's unspecialized std::atomic template doesn't include * inline definitions for the functions declared therein. This oversight * leads to linking errors when using atomic enums. We therefore require * GCC 4.7 or higher. */ #elif defined(__GNUC__) && !defined(__ANDROID__) # include "mozilla/Compiler.h" # if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) && \ MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) # define MOZ_HAVE_CXX11_ATOMICS # endif #elif defined(_MSC_VER) && _MSC_VER >= 1700 # define MOZ_HAVE_CXX11_ATOMICS #endif namespace mozilla { /** * An enum of memory ordering possibilities for atomics. * * Memory ordering is the observable state of distinct values in memory. * (It's a separate concept from atomicity, which concerns whether an * operation can ever be observed in an intermediate state. Don't * conflate the two!) Given a sequence of operations in source code on * memory, it is *not* always the case that, at all times and on all * cores, those operations will appear to have occurred in that exact * sequence. First, the compiler might reorder that sequence, if it * thinks another ordering will be more efficient. Second, the CPU may * not expose so consistent a view of memory. CPUs will often perform * their own instruction reordering, above and beyond that performed by * the compiler. And each core has its own memory caches, and accesses * (reads and writes both) to "memory" may only resolve to out-of-date * cache entries -- not to the "most recently" performed operation in * some global sense. Any access to a value that may be used by * multiple threads, potentially across multiple cores, must therefore * have a memory ordering imposed on it, for all code on all * threads/cores to have a sufficiently coherent worldview. * * http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync and * http://en.cppreference.com/w/cpp/atomic/memory_order go into more * detail on all this, including examples of how each mode works. * * Note that for simplicity and practicality, not all of the modes in * C++11 are supported. The missing C++11 modes are either subsumed by * the modes we provide below, or not relevant for the CPUs we support * in Gecko. These three modes are confusing enough as it is! */ enum MemoryOrdering { /* * Relaxed ordering is the simplest memory ordering: none at all. * When the result of a write is observed, nothing may be inferred * about other memory. Writes ostensibly performed "before" on the * writing thread may not yet be visible. Writes performed "after" on * the writing thread may already be visible, if the compiler or CPU * reordered them. (The latter can happen if reads and/or writes get * held up in per-processor caches.) Relaxed ordering means * operations can always use cached values (as long as the actual * updates to atomic values actually occur, correctly, eventually), so * it's usually the fastest sort of atomic access. For this reason, * *it's also the most dangerous kind of access*. * * Relaxed ordering is good for things like process-wide statistics * counters that don't need to be consistent with anything else, so * long as updates themselves are atomic. (And so long as any * observations of that value can tolerate being out-of-date -- if you * need some sort of up-to-date value, you need some sort of other * synchronizing operation.) It's *not* good for locks, mutexes, * reference counts, etc. that mediate access to other memory, or must * be observably consistent with other memory. * * x86 architectures don't take advantage of the optimization * opportunities that relaxed ordering permits. Thus it's possible * that using relaxed ordering will "work" on x86 but fail elsewhere * (ARM, say, which *does* implement non-sequentially-consistent * relaxed ordering semantics). Be extra-careful using relaxed * ordering if you can't easily test non-x86 architectures! */ Relaxed, /* * When an atomic value is updated with ReleaseAcquire ordering, and * that new value is observed with ReleaseAcquire ordering, prior * writes (atomic or not) are also observable. What ReleaseAcquire * *doesn't* give you is any observable ordering guarantees for * ReleaseAcquire-ordered operations on different objects. For * example, if there are two cores that each perform ReleaseAcquire * operations on separate objects, each core may or may not observe * the operations made by the other core. The only way the cores can * be synchronized with ReleaseAcquire is if they both * ReleaseAcquire-access the same object. This implies that you can't * necessarily describe some global total ordering of ReleaseAcquire * operations. * * ReleaseAcquire ordering is good for (as the name implies) atomic * operations on values controlling ownership of things: reference * counts, mutexes, and the like. However, if you are thinking about * using these to implement your own locks or mutexes, you should take * a good, hard look at actual lock or mutex primitives first. */ ReleaseAcquire, /* * When an atomic value is updated with SequentiallyConsistent * ordering, all writes observable when the update is observed, just * as with ReleaseAcquire ordering. But, furthermore, a global total * ordering of SequentiallyConsistent operations *can* be described. * For example, if two cores perform SequentiallyConsistent operations * on separate objects, one core will observably perform its update * (and all previous operations will have completed), then the other * core will observably perform its update (and all previous * operations will have completed). (Although those previous * operations aren't themselves ordered -- they could be intermixed, * or ordered if they occur on atomic values with ordering * requirements.) SequentiallyConsistent is the *simplest and safest* * ordering of atomic operations -- it's always as if one operation * happens, then another, then another, in some order -- and every * core observes updates to happen in that single order. Because it * has the most synchronization requirements, operations ordered this * way also tend to be slowest. * * SequentiallyConsistent ordering can be desirable when multiple * threads observe objects, and they all have to agree on the * observable order of changes to them. People expect * SequentiallyConsistent ordering, even if they shouldn't, when * writing code, atomic or otherwise. SequentiallyConsistent is also * the ordering of choice when designing lockless data structures. If * you don't know what order to use, use this one. */ SequentiallyConsistent, }; } // namespace mozilla // Build up the underlying intrinsics. #ifdef MOZ_HAVE_CXX11_ATOMICS # include namespace mozilla { namespace detail { /* * We provide CompareExchangeFailureOrder to work around a bug in some * versions of GCC's header. See bug 898491. */ template struct AtomicOrderConstraints; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_relaxed; static const std::memory_order LoadOrder = std::memory_order_relaxed; static const std::memory_order StoreOrder = std::memory_order_relaxed; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_relaxed; }; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_acq_rel; static const std::memory_order LoadOrder = std::memory_order_acquire; static const std::memory_order StoreOrder = std::memory_order_release; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_acquire; }; template<> struct AtomicOrderConstraints { static const std::memory_order AtomicRMWOrder = std::memory_order_seq_cst; static const std::memory_order LoadOrder = std::memory_order_seq_cst; static const std::memory_order StoreOrder = std::memory_order_seq_cst; static const std::memory_order CompareExchangeFailureOrder = std::memory_order_seq_cst; }; template struct IntrinsicBase { typedef std::atomic ValueType; typedef AtomicOrderConstraints OrderedOp; }; template struct IntrinsicMemoryOps : public IntrinsicBase { typedef IntrinsicBase Base; static T load(const typename Base::ValueType& ptr) { return ptr.load(Base::OrderedOp::LoadOrder); } static void store(typename Base::ValueType& ptr, T val) { ptr.store(val, Base::OrderedOp::StoreOrder); } static T exchange(typename Base::ValueType& ptr, T val) { return ptr.exchange(val, Base::OrderedOp::AtomicRMWOrder); } static bool compareExchange(typename Base::ValueType& ptr, T oldVal, T newVal) { return ptr.compare_exchange_strong(oldVal, newVal, Base::OrderedOp::AtomicRMWOrder, Base::OrderedOp::CompareExchangeFailureOrder); } }; template struct IntrinsicAddSub : public IntrinsicBase { typedef IntrinsicBase Base; static T add(typename Base::ValueType& ptr, T val) { return ptr.fetch_add(val, Base::OrderedOp::AtomicRMWOrder); } static T sub(typename Base::ValueType& ptr, T val) { return ptr.fetch_sub(val, Base::OrderedOp::AtomicRMWOrder); } }; template struct IntrinsicAddSub : public IntrinsicBase { typedef IntrinsicBase Base; static T* add(typename Base::ValueType& ptr, ptrdiff_t val) { return ptr.fetch_add(fixupAddend(val), Base::OrderedOp::AtomicRMWOrder); } static T* sub(typename Base::ValueType& ptr, ptrdiff_t val) { return ptr.fetch_sub(fixupAddend(val), Base::OrderedOp::AtomicRMWOrder); } private: /* * GCC 4.6's header has a bug where adding X to an * atomic is not the same as adding X to a T*. Hence the need * for this function to provide the correct addend. */ static ptrdiff_t fixupAddend(ptrdiff_t val) { #if defined(__clang__) || defined(_MSC_VER) return val; #elif defined(__GNUC__) && MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) && \ !MOZ_GCC_VERSION_AT_LEAST(4, 7, 0) return val * sizeof(T); #else return val; #endif } }; template struct IntrinsicIncDec : public IntrinsicAddSub { typedef IntrinsicBase Base; static T inc(typename Base::ValueType& ptr) { return IntrinsicAddSub::add(ptr, 1); } static T dec(typename Base::ValueType& ptr) { return IntrinsicAddSub::sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { typedef IntrinsicBase Base; static T or_(typename Base::ValueType& ptr, T val) { return ptr.fetch_or(val, Base::OrderedOp::AtomicRMWOrder); } static T xor_(typename Base::ValueType& ptr, T val) { return ptr.fetch_xor(val, Base::OrderedOp::AtomicRMWOrder); } static T and_(typename Base::ValueType& ptr, T val) { return ptr.fetch_and(val, Base::OrderedOp::AtomicRMWOrder); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #elif defined(__GNUC__) namespace mozilla { namespace detail { /* * The __sync_* family of intrinsics is documented here: * * http://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Atomic-Builtins.html * * While these intrinsics are deprecated in favor of the newer __atomic_* * family of intrincs: * * http://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/_005f_005fatomic-Builtins.html * * any GCC version that supports the __atomic_* intrinsics will also support * the header and so will be handled above. We provide a version of * atomics using the __sync_* intrinsics to support older versions of GCC. * * All __sync_* intrinsics that we use below act as full memory barriers, for * both compiler and hardware reordering, except for __sync_lock_test_and_set, * which is a only an acquire barrier. When we call __sync_lock_test_and_set, * we add a barrier above it as appropriate. */ template struct Barrier; /* * Some processors (in particular, x86) don't require quite so many calls to * __sync_sychronize as our specializations of Barrier produce. If * performance turns out to be an issue, defining these specializations * on a per-processor basis would be a good first tuning step. */ template<> struct Barrier { static void beforeLoad() {} static void afterLoad() {} static void beforeStore() {} static void afterStore() {} }; template<> struct Barrier { static void beforeLoad() {} static void afterLoad() { __sync_synchronize(); } static void beforeStore() { __sync_synchronize(); } static void afterStore() {} }; template<> struct Barrier { static void beforeLoad() { __sync_synchronize(); } static void afterLoad() { __sync_synchronize(); } static void beforeStore() { __sync_synchronize(); } static void afterStore() { __sync_synchronize(); } }; template struct IntrinsicMemoryOps { static T load(const T& ptr) { Barrier::beforeLoad(); T val = ptr; Barrier::afterLoad(); return val; } static void store(T& ptr, T val) { Barrier::beforeStore(); ptr = val; Barrier::afterStore(); } static T exchange(T& ptr, T val) { // __sync_lock_test_and_set is only an acquire barrier; loads and stores // can't be moved up from after to before it, but they can be moved down // from before to after it. We may want a stricter ordering, so we need // an explicit barrier. Barrier::beforeStore(); return __sync_lock_test_and_set(&ptr, val); } static bool compareExchange(T& ptr, T oldVal, T newVal) { return __sync_bool_compare_and_swap(&ptr, oldVal, newVal); } }; template struct IntrinsicAddSub { typedef T ValueType; static T add(T& ptr, T val) { return __sync_fetch_and_add(&ptr, val); } static T sub(T& ptr, T val) { return __sync_fetch_and_sub(&ptr, val); } }; template struct IntrinsicAddSub { typedef T* ValueType; /* * The reinterpret_casts are needed so that * __sync_fetch_and_{add,sub} will properly type-check. * * Also, these functions do not provide standard semantics for * pointer types, so we need to adjust the addend. */ static ValueType add(ValueType& ptr, ptrdiff_t val) { ValueType amount = reinterpret_cast(val * sizeof(T)); return __sync_fetch_and_add(&ptr, amount); } static ValueType sub(ValueType& ptr, ptrdiff_t val) { ValueType amount = reinterpret_cast(val * sizeof(T)); return __sync_fetch_and_sub(&ptr, amount); } }; template struct IntrinsicIncDec : public IntrinsicAddSub { static T inc(T& ptr) { return IntrinsicAddSub::add(ptr, 1); } static T dec(T& ptr) { return IntrinsicAddSub::sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { static T or_(T& ptr, T val) { return __sync_fetch_and_or(&ptr, val); } static T xor_(T& ptr, T val) { return __sync_fetch_and_xor(&ptr, val); } static T and_(T& ptr, T val) { return __sync_fetch_and_and(&ptr, val); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #elif defined(_MSC_VER) /* * Windows comes with a full complement of atomic operations. * Unfortunately, most of those aren't available for Windows XP (even if * the compiler supports intrinsics for them), which is the oldest * version of Windows we support. Therefore, we only provide operations * on 32-bit datatypes for 32-bit Windows versions; for 64-bit Windows * versions, we support 64-bit datatypes as well. * * To avoid namespace pollution issues, we declare whatever functions we * need ourselves. */ extern "C" { long __cdecl _InterlockedExchangeAdd(long volatile* dst, long value); long __cdecl _InterlockedOr(long volatile* dst, long value); long __cdecl _InterlockedXor(long volatile* dst, long value); long __cdecl _InterlockedAnd(long volatile* dst, long value); long __cdecl _InterlockedExchange(long volatile *dst, long value); long __cdecl _InterlockedCompareExchange(long volatile *dst, long newVal, long oldVal); } # pragma intrinsic(_InterlockedExchangeAdd) # pragma intrinsic(_InterlockedOr) # pragma intrinsic(_InterlockedXor) # pragma intrinsic(_InterlockedAnd) # pragma intrinsic(_InterlockedExchange) # pragma intrinsic(_InterlockedCompareExchange) namespace mozilla { namespace detail { # if !defined(_M_IX86) && !defined(_M_X64) /* * The implementations below are optimized for x86ish systems. You * will have to modify them if you are porting to Windows on a * different architecture. */ # error "Unknown CPU type" # endif /* * The PrimitiveIntrinsics template should define |Type|, the datatype of size * DataSize upon which we operate, and the following eight functions. * * static Type add(Type* ptr, Type val); * static Type sub(Type* ptr, Type val); * static Type or_(Type* ptr, Type val); * static Type xor_(Type* ptr, Type val); * static Type and_(Type* ptr, Type val); * * These functions perform the obvious operation on the value contained in * |*ptr| combined with |val| and return the value previously stored in * |*ptr|. * * static void store(Type* ptr, Type val); * * This function atomically stores |val| into |*ptr| and must provide a full * memory fence after the store to prevent compiler and hardware instruction * reordering. It should also act as a compiler barrier to prevent reads and * writes from moving to after the store. * * static Type exchange(Type* ptr, Type val); * * This function atomically stores |val| into |*ptr| and returns the previous * contents of *ptr; * * static bool compareExchange(Type* ptr, Type oldVal, Type newVal); * * This function atomically performs the following operation: * * if (*ptr == oldVal) { * *ptr = newVal; * return true; * } else { * return false; * } * */ template struct PrimitiveIntrinsics; template<> struct PrimitiveIntrinsics<4> { typedef long Type; static Type add(Type* ptr, Type val) { return _InterlockedExchangeAdd(ptr, val); } static Type sub(Type* ptr, Type val) { /* * _InterlockedExchangeSubtract isn't available before Windows 7, * and we must support Windows XP. */ return _InterlockedExchangeAdd(ptr, -val); } static Type or_(Type* ptr, Type val) { return _InterlockedOr(ptr, val); } static Type xor_(Type* ptr, Type val) { return _InterlockedXor(ptr, val); } static Type and_(Type* ptr, Type val) { return _InterlockedAnd(ptr, val); } static void store(Type* ptr, Type val) { _InterlockedExchange(ptr, val); } static Type exchange(Type* ptr, Type val) { return _InterlockedExchange(ptr, val); } static bool compareExchange(Type* ptr, Type oldVal, Type newVal) { return _InterlockedCompareExchange(ptr, newVal, oldVal) == oldVal; } }; # if defined(_M_X64) extern "C" { long long __cdecl _InterlockedExchangeAdd64(long long volatile* dst, long long value); long long __cdecl _InterlockedOr64(long long volatile* dst, long long value); long long __cdecl _InterlockedXor64(long long volatile* dst, long long value); long long __cdecl _InterlockedAnd64(long long volatile* dst, long long value); long long __cdecl _InterlockedExchange64(long long volatile* dst, long long value); long long __cdecl _InterlockedCompareExchange64(long long volatile* dst, long long newVal, long long oldVal); } # pragma intrinsic(_InterlockedExchangeAdd64) # pragma intrinsic(_InterlockedOr64) # pragma intrinsic(_InterlockedXor64) # pragma intrinsic(_InterlockedAnd64) # pragma intrinsic(_InterlockedExchange64) # pragma intrinsic(_InterlockedCompareExchange64) template <> struct PrimitiveIntrinsics<8> { typedef __int64 Type; static Type add(Type* ptr, Type val) { return _InterlockedExchangeAdd64(ptr, val); } static Type sub(Type* ptr, Type val) { /* * There is no _InterlockedExchangeSubtract64. */ return _InterlockedExchangeAdd64(ptr, -val); } static Type or_(Type* ptr, Type val) { return _InterlockedOr64(ptr, val); } static Type xor_(Type* ptr, Type val) { return _InterlockedXor64(ptr, val); } static Type and_(Type* ptr, Type val) { return _InterlockedAnd64(ptr, val); } static void store(Type* ptr, Type val) { _InterlockedExchange64(ptr, val); } static Type exchange(Type* ptr, Type val) { return _InterlockedExchange64(ptr, val); } static bool compareExchange(Type* ptr, Type oldVal, Type newVal) { return _InterlockedCompareExchange64(ptr, newVal, oldVal) == oldVal; } }; # endif extern "C" { void _ReadWriteBarrier(); } # pragma intrinsic(_ReadWriteBarrier) template struct Barrier; /* * We do not provide an afterStore method in Barrier, as Relaxed and * ReleaseAcquire orderings do not require one, and the required barrier * for SequentiallyConsistent is handled by PrimitiveIntrinsics. */ template<> struct Barrier { static void beforeLoad() {} static void afterLoad() {} static void beforeStore() {} }; template<> struct Barrier { static void beforeLoad() {} static void afterLoad() { _ReadWriteBarrier(); } static void beforeStore() { _ReadWriteBarrier(); } }; template<> struct Barrier { static void beforeLoad() { _ReadWriteBarrier(); } static void afterLoad() { _ReadWriteBarrier(); } static void beforeStore() { _ReadWriteBarrier(); } }; template struct CastHelper { static PrimType toPrimType(T val) { return static_cast(val); } static T fromPrimType(PrimType val) { return static_cast(val); } }; template struct CastHelper { static PrimType toPrimType(T* val) { return reinterpret_cast(val); } static T* fromPrimType(PrimType val) { return reinterpret_cast(val); } }; template struct IntrinsicBase { typedef T ValueType; typedef PrimitiveIntrinsics Primitives; typedef typename Primitives::Type PrimType; static_assert(sizeof(PrimType) == sizeof(T), "Selection of PrimitiveIntrinsics was wrong"); typedef CastHelper Cast; }; template struct IntrinsicMemoryOps : public IntrinsicBase { static ValueType load(const ValueType& ptr) { Barrier::beforeLoad(); ValueType val = ptr; Barrier::afterLoad(); return val; } static void store(ValueType& ptr, ValueType val) { // For SequentiallyConsistent, Primitives::store() will generate the // proper memory fence. Everything else just needs a barrier before // the store. if (Order == SequentiallyConsistent) { Primitives::store(reinterpret_cast(&ptr), Cast::toPrimType(val)); } else { Barrier::beforeStore(); ptr = val; } } static ValueType exchange(ValueType& ptr, ValueType val) { PrimType oldval = Primitives::exchange(reinterpret_cast(&ptr), Cast::toPrimType(val)); return Cast::fromPrimType(oldval); } static bool compareExchange(ValueType& ptr, ValueType oldVal, ValueType newVal) { return Primitives::compareExchange(reinterpret_cast(&ptr), Cast::toPrimType(oldVal), Cast::toPrimType(newVal)); } }; template struct IntrinsicApplyHelper : public IntrinsicBase { typedef PrimType (*BinaryOp)(PrimType*, PrimType); typedef PrimType (*UnaryOp)(PrimType*); static ValueType applyBinaryFunction(BinaryOp op, ValueType& ptr, ValueType val) { PrimType* primTypePtr = reinterpret_cast(&ptr); PrimType primTypeVal = Cast::toPrimType(val); return Cast::fromPrimType(op(primTypePtr, primTypeVal)); } static ValueType applyUnaryFunction(UnaryOp op, ValueType& ptr) { PrimType* primTypePtr = reinterpret_cast(&ptr); return Cast::fromPrimType(op(primTypePtr)); } }; template struct IntrinsicAddSub : public IntrinsicApplyHelper { static ValueType add(ValueType& ptr, ValueType val) { return applyBinaryFunction(&Primitives::add, ptr, val); } static ValueType sub(ValueType& ptr, ValueType val) { return applyBinaryFunction(&Primitives::sub, ptr, val); } }; template struct IntrinsicAddSub : public IntrinsicApplyHelper { static ValueType add(ValueType& ptr, ptrdiff_t amount) { return applyBinaryFunction(&Primitives::add, ptr, (ValueType)(amount * sizeof(ValueType))); } static ValueType sub(ValueType& ptr, ptrdiff_t amount) { return applyBinaryFunction(&Primitives::sub, ptr, (ValueType)(amount * sizeof(ValueType))); } }; template struct IntrinsicIncDec : public IntrinsicAddSub { static ValueType inc(ValueType& ptr) { return add(ptr, 1); } static ValueType dec(ValueType& ptr) { return sub(ptr, 1); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { static ValueType or_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::or_, ptr, val); } static ValueType xor_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::xor_, ptr, val); } static ValueType and_(ValueType& ptr, T val) { return applyBinaryFunction(&Primitives::and_, ptr, val); } }; template struct AtomicIntrinsics : public IntrinsicMemoryOps, public IntrinsicIncDec { }; } // namespace detail } // namespace mozilla #else # error "Atomic compiler intrinsics are not supported on your platform" #endif namespace mozilla { namespace detail { template class AtomicBase { // We only support 32-bit types on 32-bit Windows, which constrains our // implementation elsewhere. But we support pointer-sized types everywhere. static_assert(sizeof(T) == 4 || (sizeof(uintptr_t) == 8 && sizeof(T) == 8), "mozilla/Atomics.h only supports 32-bit and pointer-sized types"); protected: typedef typename detail::AtomicIntrinsics Intrinsics; typename Intrinsics::ValueType mValue; public: AtomicBase() : mValue() {} AtomicBase(T aInit) { Intrinsics::store(mValue, aInit); } operator T() const { return Intrinsics::load(mValue); } T operator=(T aValue) { Intrinsics::store(mValue, aValue); return aValue; } /** * Performs an atomic swap operation. aValue is stored and the previous * value of this variable is returned. */ T exchange(T aValue) { return Intrinsics::exchange(mValue, aValue); } /** * Performs an atomic compare-and-swap operation and returns true if it * succeeded. This is equivalent to atomically doing * * if (mValue == aOldValue) { * mValue = aNewValue; * return true; * } else { * return false; * } */ bool compareExchange(T aOldValue, T aNewValue) { return Intrinsics::compareExchange(mValue, aOldValue, aNewValue); } private: template AtomicBase(const AtomicBase& aCopy) MOZ_DELETE; }; template class AtomicBaseIncDec : public AtomicBase { typedef typename detail::AtomicBase Base; public: AtomicBaseIncDec() : Base() {} AtomicBaseIncDec(T aInit) : Base(aInit) {} using Base::operator=; T operator++(int) { return Base::Intrinsics::inc(Base::mValue); } T operator--(int) { return Base::Intrinsics::dec(Base::mValue); } T operator++() { return Base::Intrinsics::inc(Base::mValue) + 1; } T operator--() { return Base::Intrinsics::dec(Base::mValue) - 1; } private: template AtomicBaseIncDec(const AtomicBaseIncDec& aCopy) MOZ_DELETE; }; } // namespace detail /** * A wrapper for a type that enforces that all memory accesses are atomic. * * In general, where a variable |T foo| exists, |Atomic foo| can be used in * its place. Implementations for integral and pointer types are provided * below. * * Atomic accesses are sequentially consistent by default. You should * use the default unless you are tall enough to ride the * memory-ordering roller coaster (if you're not sure, you aren't) and * you have a compelling reason to do otherwise. * * There is one exception to the case of atomic memory accesses: providing an * initial value of the atomic value is not guaranteed to be atomic. This is a * deliberate design choice that enables static atomic variables to be declared * without introducing extra static constructors. */ template class Atomic; /** * Atomic implementation for integral types. * * In addition to atomic store and load operations, compound assignment and * increment/decrement operators are implemented which perform the * corresponding read-modify-write operation atomically. Finally, an atomic * swap method is provided. */ template class Atomic::value>::Type> : public detail::AtomicBaseIncDec { typedef typename detail::AtomicBaseIncDec Base; public: Atomic() : Base() {} Atomic(T aInit) : Base(aInit) {} using Base::operator=; T operator+=(T delta) { return Base::Intrinsics::add(Base::mValue, delta) + delta; } T operator-=(T delta) { return Base::Intrinsics::sub(Base::mValue, delta) - delta; } T operator|=(T val) { return Base::Intrinsics::or_(Base::mValue, val) | val; } T operator^=(T val) { return Base::Intrinsics::xor_(Base::mValue, val) ^ val; } T operator&=(T val) { return Base::Intrinsics::and_(Base::mValue, val) & val; } private: Atomic(Atomic& aOther) MOZ_DELETE; }; /** * Atomic implementation for pointer types. * * An atomic compare-and-swap primitive for pointer variables is provided, as * are atomic increment and decement operators. Also provided are the compound * assignment operators for addition and subtraction. Atomic swap (via * exchange()) is included as well. */ template class Atomic : public detail::AtomicBaseIncDec { typedef typename detail::AtomicBaseIncDec Base; public: Atomic() : Base() {} Atomic(T* aInit) : Base(aInit) {} using Base::operator=; T* operator+=(ptrdiff_t delta) { return Base::Intrinsics::add(Base::mValue, delta) + delta; } T* operator-=(ptrdiff_t delta) { return Base::Intrinsics::sub(Base::mValue, delta) - delta; } private: Atomic(Atomic& aOther) MOZ_DELETE; }; /** * Atomic implementation for enum types. * * The atomic store and load operations and the atomic swap method is provided. */ template class Atomic::value>::Type> : public detail::AtomicBase { typedef typename detail::AtomicBase Base; public: Atomic() : Base() {} Atomic(T aInit) : Base(aInit) {} using Base::operator=; private: Atomic(Atomic& aOther) MOZ_DELETE; }; } // namespace mozilla #endif /* mozilla_Atomics_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Attributes.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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). * * The MOZ_ALWAYS_INLINE_EVEN_DEBUG macro is yet stronger. It tells the * compiler to inline even in DEBUG builds. It should be used very rarely. */ #if defined(_MSC_VER) # define MOZ_ALWAYS_INLINE_EVEN_DEBUG __forceinline #elif defined(__GNUC__) # define MOZ_ALWAYS_INLINE_EVEN_DEBUG __attribute__((always_inline)) MOZ_INLINE #else # define MOZ_ALWAYS_INLINE_EVEN_DEBUG MOZ_INLINE #endif #if defined(DEBUG) # define MOZ_ALWAYS_INLINE MOZ_INLINE #else # define MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG #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. * The MOZ_CONSTEXPR_VAR specifier tells a C++11 compiler that a variable's * value may be computed at compile time. It should be prefered to just * marking variables as MOZ_CONSTEXPR because if the compiler does not support * constexpr it will fall back to making the variable const, and some compilers * do not accept variables being marked both const and constexpr. */ #ifdef MOZ_HAVE_CXX11_CONSTEXPR # define MOZ_CONSTEXPR constexpr # define MOZ_CONSTEXPR_VAR constexpr #else # define MOZ_CONSTEXPR /* no support */ # define MOZ_CONSTEXPR_VAR const #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. * MOZ_STACK_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the stack, so it is a compile-time error to use it, or * an array of such objects, as a global or static variable, or as the type of * a new expression (unless placement new is being used). If a member of * another class uses this class, or if another class inherits from this * class, then it is considered to be a stack class as well, although this * attribute need not be provided in such cases. * MOZ_NONHEAP_CLASS: Applies to all classes. Any class with this annotation is * expected to live on the stack or in static storage, so it is a compile-time * error to use it, or an array of such objects, as the type of a new * expression (unless placement new is being used). If a member of another * class uses this class, or if another class inherits from this class, then * it is considered to be a non-heap class as well, although this attribute * need not be provided in such cases. */ #ifdef MOZ_CLANG_PLUGIN # define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override"))) # define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class"))) # define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class"))) #else # define MOZ_MUST_OVERRIDE /* nothing */ # define MOZ_STACK_CLASS /* nothing */ # define MOZ_NONHEAP_CLASS /* nothing */ #endif /* MOZ_CLANG_PLUGIN */ /* * MOZ_THIS_IN_INITIALIZER_LIST is used to avoid a warning when we know that * it's safe to use 'this' in an initializer list. */ #ifdef _MSC_VER # define MOZ_THIS_IN_INITIALIZER_LIST() \ __pragma(warning(push)) \ __pragma(warning(disable:4355)) \ this \ __pragma(warning(pop)) #else # define MOZ_THIS_IN_INITIALIZER_LIST() this #endif #endif /* __cplusplus */ #endif /* mozilla_Attributes_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/BloomFilter.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Util.h" #include #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() { 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Casting.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Cast operations to supplement the built-in casting operations. */ #ifndef mozilla_Casting_h #define mozilla_Casting_h #include "mozilla/Assertions.h" #include "mozilla/TypeTraits.h" #include namespace mozilla { /** * Return a value of type |To|, containing the underlying bit pattern of |from|. * * |To| and |From| must be types of the same size; be careful of cross-platform * size differences, or this might fail to compile on some but not all * platforms. */ template inline To BitwiseCast(const From from) { static_assert(sizeof(From) == sizeof(To), "To and From must have the same size"); union { From from; To to; } u; u.from = from; return u.to; } namespace detail { enum ToSignedness { ToIsSigned, ToIsUnsigned }; enum FromSignedness { FromIsSigned, FromIsUnsigned }; template::value ? FromIsSigned : FromIsUnsigned, ToSignedness = IsSigned::value ? ToIsSigned : ToIsUnsigned> struct BoundsCheckImpl; // Implicit conversions on operands to binary operations make this all a bit // hard to verify. Attempt to ease the pain below by *only* comparing values // that are obviously the same type (and will undergo no further conversions), // even when it's not strictly necessary, for explicitness. enum UUComparison { FromIsBigger, FromIsNotBigger }; // Unsigned-to-unsigned range check template sizeof(To)) ? FromIsBigger : FromIsNotBigger> struct UnsignedUnsignedCheck; template struct UnsignedUnsignedCheck { public: static bool checkBounds(const From from) { return from <= From(To(-1)); } }; template struct UnsignedUnsignedCheck { public: static bool checkBounds(const From from) { return true; } }; template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { return UnsignedUnsignedCheck::checkBounds(from); } }; // Signed-to-unsigned range check template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { if (from < 0) return false; if (sizeof(To) >= sizeof(From)) return true; return from <= From(To(-1)); } }; // Unsigned-to-signed range check enum USComparison { FromIsSmaller, FromIsNotSmaller }; template struct UnsignedSignedCheck; template struct UnsignedSignedCheck { public: static bool checkBounds(const From from) { return true; } }; template struct UnsignedSignedCheck { public: static bool checkBounds(const From from) { const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); return from <= From(MaxValue); } }; template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { return UnsignedSignedCheck::checkBounds(from); } }; // Signed-to-signed range check template struct BoundsCheckImpl { public: static bool checkBounds(const From from) { if (sizeof(From) <= sizeof(To)) return true; const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); const To MinValue = -MaxValue - To(1); return From(MinValue) <= from && From(from) <= From(MaxValue); } }; template::value && IsIntegral::value> class BoundsChecker; template class BoundsChecker { public: static bool checkBounds(const From from) { return true; } }; template class BoundsChecker { public: static bool checkBounds(const From from) { return BoundsCheckImpl::checkBounds(from); } }; template inline bool IsInBounds(const From from) { return BoundsChecker::checkBounds(from); } } // namespace detail /** * Cast a value of integral type |From| to a value of integral type |To|, * asserting that the cast will be a safe cast per C++ (that is, that |to| is in * the range of values permitted for the type |From|). */ template inline To SafeCast(const From from) { MOZ_ASSERT((detail::IsInBounds(from))); return static_cast(from); } } // namespace mozilla #endif /* mozilla_Casting_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Char16.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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) static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?"); static_assert(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?"); static_assert(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?"); #endif /* mozilla_Char16_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/CheckedInt.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 #include #ifdef MOZ_CHECKEDINT_USE_MFBT # include "mozilla/Assertions.h" #else # include # 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; }; 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 IsModValidImpl; template inline bool IsModValid(T x, T y) { return IsModValidImpl::run(x, y); } /* * Mod is pretty simple. * For now, let's just use the ANSI C definition: * If x or y are negative, the results are implementation defined. * Consider these invalid. * Undefined for y=0. * The result will never exceed either x or y. * * Checking that x>=0 is a warning when T is unsigned. */ template struct IsModValidImpl { static inline bool run(T x, T y) { return y >= 1; } }; template struct IsModValidImpl { static inline bool run(T x, T y) { if (x < 0) return false; return y >= 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) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); } friend struct 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)) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); } template friend class CheckedInt; template CheckedInt toChecked() const { CheckedInt ret(mValue); ret.mIsValid = ret.mIsValid && mIsValid; return ret; } /** Constructs a valid checked integer with initial value 0 */ CheckedInt() : mValue(0), mIsValid(true) { 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); 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, /) MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mod, %) #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) { static_assert(detail::IsSupported::value && detail::IsSupported::value, "This type is not supported by CheckedInt"); 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(/, /=) 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Compiler.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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__) #define MOZ_IS_GCC 1 /* * 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 #else #define MOZ_IS_GCC 0 #endif #endif /* mozilla_Compiler_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Constants.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/DebugOnly.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Decimal.h ================================================ /* * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "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 COPYRIGHT * OWNER OR CONTRIBUTORS 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. */ /** * Imported from: * http://src.chromium.org/viewvc/blink/trunk/Source/core/platform/Decimal.h * Check hg log for the svn rev of the last update from Blink core. */ #ifndef Decimal_h #define Decimal_h #include "mozilla/Assertions.h" #include #include "mozilla/Types.h" #include #ifndef ASSERT #define DEFINED_ASSERT_FOR_DECIMAL_H 1 #define ASSERT MOZ_ASSERT #endif // To use WTF_MAKE_FAST_ALLOCATED we'd need: // http://src.chromium.org/viewvc/blink/trunk/Source/wtf/FastMalloc.h // Since we don't allocate Decimal objects, no need. #define WTF_MAKE_FAST_ALLOCATED \ void ignore_this_dummy_method() MOZ_DELETE namespace WebCore { namespace DecimalPrivate { class SpecialValueHandler; } // This class represents decimal base floating point number. // // FIXME: Once all C++ compiler support decimal type, we should replace this // class to compiler supported one. See below URI for current status of decimal // type for C++: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1977.html class Decimal { WTF_MAKE_FAST_ALLOCATED; public: enum Sign { Positive, Negative, }; // You should not use EncodedData other than unit testing. class EncodedData { // For accessing FormatClass. friend class Decimal; friend class DecimalPrivate::SpecialValueHandler; public: EncodedData(Sign, int exponent, uint64_t coefficient); bool operator==(const EncodedData&) const; bool operator!=(const EncodedData& another) const { return !operator==(another); } uint64_t coefficient() const { return m_coefficient; } int countDigits() const; int exponent() const { return m_exponent; } bool isFinite() const { return !isSpecial(); } bool isInfinity() const { return m_formatClass == ClassInfinity; } bool isNaN() const { return m_formatClass == ClassNaN; } bool isSpecial() const { return m_formatClass == ClassInfinity || m_formatClass == ClassNaN; } bool isZero() const { return m_formatClass == ClassZero; } Sign sign() const { return m_sign; } void setSign(Sign sign) { m_sign = sign; } private: enum FormatClass { ClassInfinity, ClassNormal, ClassNaN, ClassZero, }; EncodedData(Sign, FormatClass); FormatClass formatClass() const { return m_formatClass; } uint64_t m_coefficient; int16_t m_exponent; FormatClass m_formatClass; Sign m_sign; }; MFBT_API Decimal(int32_t = 0); MFBT_API Decimal(Sign, int exponent, uint64_t coefficient); MFBT_API Decimal(const Decimal&); MFBT_API Decimal& operator=(const Decimal&); MFBT_API Decimal& operator+=(const Decimal&); MFBT_API Decimal& operator-=(const Decimal&); MFBT_API Decimal& operator*=(const Decimal&); MFBT_API Decimal& operator/=(const Decimal&); MFBT_API Decimal operator-() const; MFBT_API bool operator==(const Decimal&) const; MFBT_API bool operator!=(const Decimal&) const; MFBT_API bool operator<(const Decimal&) const; MFBT_API bool operator<=(const Decimal&) const; MFBT_API bool operator>(const Decimal&) const; MFBT_API bool operator>=(const Decimal&) const; MFBT_API Decimal operator+(const Decimal&) const; MFBT_API Decimal operator-(const Decimal&) const; MFBT_API Decimal operator*(const Decimal&) const; MFBT_API Decimal operator/(const Decimal&) const; int exponent() const { ASSERT(isFinite()); return m_data.exponent(); } bool isFinite() const { return m_data.isFinite(); } bool isInfinity() const { return m_data.isInfinity(); } bool isNaN() const { return m_data.isNaN(); } bool isNegative() const { return sign() == Negative; } bool isPositive() const { return sign() == Positive; } bool isSpecial() const { return m_data.isSpecial(); } bool isZero() const { return m_data.isZero(); } MFBT_API Decimal abs() const; MFBT_API Decimal ceiling() const; MFBT_API Decimal floor() const; MFBT_API Decimal remainder(const Decimal&) const; MFBT_API Decimal round() const; MFBT_API double toDouble() const; // Note: toString method supports infinity and nan but fromString not. MFBT_API std::string toString() const; MFBT_API bool toString(char* strBuf, size_t bufLength) const; static MFBT_API Decimal fromDouble(double); // fromString supports following syntax EBNF: // number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)? // | sign? '.' digit+ (exponent-marker sign? digit+)? // sign ::= '+' | '-' // exponent-marker ::= 'e' | 'E' // digit ::= '0' | '1' | ... | '9' // Note: fromString doesn't support "infinity" and "nan". static MFBT_API Decimal fromString(const std::string& aValue); static MFBT_API Decimal infinity(Sign); static MFBT_API Decimal nan(); static MFBT_API Decimal zero(Sign); // You should not use below methods. We expose them for unit testing. MFBT_API explicit Decimal(const EncodedData&); const EncodedData& value() const { return m_data; } private: struct AlignedOperands { uint64_t lhsCoefficient; uint64_t rhsCoefficient; int exponent; }; MFBT_API Decimal(double); MFBT_API Decimal compareTo(const Decimal&) const; static MFBT_API AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs); static inline Sign invertSign(Sign sign) { return sign == Negative ? Positive : Negative; } Sign sign() const { return m_data.sign(); } EncodedData m_data; }; } // namespace WebCore namespace mozilla { typedef WebCore::Decimal Decimal; } #undef WTF_MAKE_FAST_ALLOCATED #ifdef DEFINED_ASSERT_FOR_DECIMAL_H #undef DEFINED_ASSERT_FOR_DECIMAL_H #undef ASSERT #endif #endif // Decimal_h ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Endian.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Functions for reading and writing integers in various endiannesses. */ /* * The classes LittleEndian and BigEndian expose static methods for * reading and writing 16-, 32-, and 64-bit signed and unsigned integers * in their respective endianness. The naming scheme is: * * {Little,Big}Endian::{read,write}{Uint,Int} * * For instance, LittleEndian::readInt32 will read a 32-bit signed * integer from memory in little endian format. Similarly, * BigEndian::writeUint16 will write a 16-bit unsigned integer to memory * in big-endian format. * * The class NativeEndian exposes methods for conversion of existing * data to and from the native endianness. These methods are intended * for cases where data needs to be transferred, serialized, etc. * swap{To,From}{Little,Big}Endian byteswap a single value if necessary. * Bulk conversion functions are also provided which optimize the * no-conversion-needed case: * * - copyAndSwap{To,From}{Little,Big}Endian; * - swap{To,From}{Little,Big}EndianInPlace. * * The *From* variants are intended to be used for reading data and the * *To* variants for writing data. * * Methods on NativeEndian work with integer data of any type. * Floating-point data is not supported. * * For clarity in networking code, "Network" may be used as a synonym * for "Big" in any of the above methods or class names. * * As an example, reading a file format header whose fields are stored * in big-endian format might look like: * * class ExampleHeader * { * private: * uint32_t magic; * uint32_t length; * uint32_t totalRecords; * uint64_t checksum; * * public: * ExampleHeader(const void* data) { * const uint8_t* ptr = static_cast(data); * magic = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * length = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * totalRecords = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); * checksum = BigEndian::readUint64(ptr); * } * ... * }; */ #ifndef mozilla_Endian_h #define mozilla_Endian_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Compiler.h" #include "mozilla/DebugOnly.h" #include "mozilla/TypeTraits.h" #include #include #if defined(_MSC_VER) && _MSC_VER >= 1300 # include # pragma intrinsic(_byteswap_ushort) # pragma intrinsic(_byteswap_ulong) # pragma intrinsic(_byteswap_uint64) #endif #if defined(_WIN64) # if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) # define MOZ_LITTLE_ENDIAN 1 # else # error "CPU type is unknown" # endif #elif defined(_WIN32) # if defined(_M_IX86) # define MOZ_LITTLE_ENDIAN 1 # else # error "CPU type is unknown" # endif #elif defined(__APPLE__) # if __LITTLE_ENDIAN__ # define MOZ_LITTLE_ENDIAN 1 # elif __BIG_ENDIAN__ # define MOZ_BIG_ENDIAN 1 # endif #elif defined(__GNUC__) && \ defined(__BYTE_ORDER__) && \ defined(__ORDER_LITTLE_ENDIAN__) && \ defined(__ORDER_BIG_ENDIAN__) /* * Some versions of GCC provide architecture-independent macros for * this. Yes, there are more than two values for __BYTE_ORDER__. */ # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define MOZ_LITTLE_ENDIAN 1 # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define MOZ_BIG_ENDIAN 1 # else # error "Can't handle mixed-endian architectures" # endif /* * We can't include useful headers like or * here because they're not present on all platforms. Instead we have * this big conditional that ideally will catch all the interesting * cases. */ #elif defined(__sparc) || defined(__sparc__) || \ defined(_POWER) || defined(__powerpc__) || \ defined(__ppc__) || defined(__hppa) || \ defined(_MIPSEB) || defined(__ARMEB__) || \ defined(__s390__) || \ (defined(__sh__) && defined(__LITTLE_ENDIAN__)) || \ (defined(__ia64) && defined(__BIG_ENDIAN__)) # define MOZ_BIG_ENDIAN 1 #elif defined(__i386) || defined(__i386__) || \ defined(__x86_64) || defined(__x86_64__) || \ defined(_MIPSEL) || defined(__ARMEL__) || \ defined(__alpha__) || \ (defined(__sh__) && defined(__BIG_ENDIAN__)) || \ (defined(__ia64) && !defined(__BIG_ENDIAN__)) # define MOZ_LITTLE_ENDIAN 1 #endif #if MOZ_BIG_ENDIAN # define MOZ_LITTLE_ENDIAN 0 #elif MOZ_LITTLE_ENDIAN # define MOZ_BIG_ENDIAN 0 #else # error "Cannot determine endianness" #endif #if defined(__clang__) # if __has_builtin(__builtin_bswap16) # define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 # endif #elif defined(__GNUC__) # if MOZ_GCC_VERSION_AT_LEAST(4, 8, 0) # define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 # endif #elif defined(_MSC_VER) # define MOZ_HAVE_BUILTIN_BYTESWAP16 _byteswap_ushort #endif namespace mozilla { namespace detail { /* * We need wrappers here because free functions with default template * arguments and/or partial specialization of function templates are not * supported by all the compilers we use. */ template struct Swapper; template struct Swapper { static T swap(T value) { #if defined(MOZ_HAVE_BUILTIN_BYTESWAP16) return MOZ_HAVE_BUILTIN_BYTESWAP16(value); #else return T(((value & 0x00ff) << 8) | ((value & 0xff00) >> 8)); #endif } }; template struct Swapper { static T swap(T value) { #if defined(__clang__) || defined(__GNUC__) return T(__builtin_bswap32(value)); #elif defined(_MSC_VER) return T(_byteswap_ulong(value)); #else return T(((value & 0x000000ffU) << 24) | ((value & 0x0000ff00U) << 8) | ((value & 0x00ff0000U) >> 8) | ((value & 0xff000000U) >> 24)); #endif } }; template struct Swapper { static inline T swap(T value) { #if defined(__clang__) || defined(__GNUC__) return T(__builtin_bswap64(value)); #elif defined(_MSC_VER) return T(_byteswap_uint64(value)); #else return T(((value & 0x00000000000000ffULL) << 56) | ((value & 0x000000000000ff00ULL) << 40) | ((value & 0x0000000000ff0000ULL) << 24) | ((value & 0x00000000ff000000ULL) << 8) | ((value & 0x000000ff00000000ULL) >> 8) | ((value & 0x0000ff0000000000ULL) >> 24) | ((value & 0x00ff000000000000ULL) >> 40) | ((value & 0xff00000000000000ULL) >> 56)); #endif } }; enum Endianness { Little, Big }; #if MOZ_BIG_ENDIAN # define MOZ_NATIVE_ENDIANNESS detail::Big #else # define MOZ_NATIVE_ENDIANNESS detail::Little #endif class EndianUtils { /** * Assert that the memory regions [dest, dest+count) and [src, src+count] * do not overlap. count is given in bytes. */ static void assertNoOverlap(const void* dest, const void* src, size_t count) { DebugOnly byteDestPtr = static_cast(dest); DebugOnly byteSrcPtr = static_cast(src); MOZ_ASSERT((byteDestPtr < byteSrcPtr && byteDestPtr + count <= byteSrcPtr) || (byteSrcPtr < byteDestPtr && byteSrcPtr + count <= byteDestPtr)); } template static void assertAligned(T* ptr) { MOZ_ASSERT((uintptr_t(ptr) % sizeof(T)) == 0, "Unaligned pointer!"); } protected: /** * Return |value| converted from SourceEndian encoding to DestEndian * encoding. */ template static inline T maybeSwap(T value) { if (SourceEndian == DestEndian) return value; return Swapper::swap(value); } /** * Convert |count| elements at |ptr| from SourceEndian encoding to * DestEndian encoding. */ template static inline void maybeSwapInPlace(T* ptr, size_t count) { assertAligned(ptr); if (SourceEndian == DestEndian) return; for (size_t i = 0; i < count; i++) ptr[i] = Swapper::swap(ptr[i]); } /** * Write |count| elements to the unaligned address |dest| in DestEndian * format, using elements found at |src| in SourceEndian format. */ template static void copyAndSwapTo(void* dest, const T* src, size_t count) { assertNoOverlap(dest, src, count * sizeof(T)); assertAligned(src); if (SourceEndian == DestEndian) { memcpy(dest, src, count * sizeof(T)); return; } uint8_t* byteDestPtr = static_cast(dest); for (size_t i = 0; i < count; ++i) { union { T val; uint8_t buffer[sizeof(T)]; } u; u.val = maybeSwap(src[i]); memcpy(byteDestPtr, u.buffer, sizeof(T)); byteDestPtr += sizeof(T); } } /** * Write |count| elements to |dest| in DestEndian format, using elements * found at the unaligned address |src| in SourceEndian format. */ template static void copyAndSwapFrom(T* dest, const void* src, size_t count) { assertNoOverlap(dest, src, count * sizeof(T)); assertAligned(dest); if (SourceEndian == DestEndian) { memcpy(dest, src, count * sizeof(T)); return; } const uint8_t* byteSrcPtr = static_cast(src); for (size_t i = 0; i < count; ++i) { union { T val; uint8_t buffer[sizeof(T)]; } u; memcpy(u.buffer, byteSrcPtr, sizeof(T)); dest[i] = maybeSwap(u.val); byteSrcPtr += sizeof(T); } } }; template class Endian : private EndianUtils { protected: /** Read a uint16_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint16_t readUint16(const void* p) { return read(p); } /** Read a uint32_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint32_t readUint32(const void* p) { return read(p); } /** Read a uint64_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT uint64_t readUint64(const void* p) { return read(p); } /** Read an int16_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int16_t readInt16(const void* p) { return read(p); } /** Read an int32_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int32_t readInt32(const void* p) { return read(p); } /** Read an int64_t in ThisEndian endianness from |p| and return it. */ static MOZ_WARN_UNUSED_RESULT int64_t readInt64(const void* p) { return read(p); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint16(void* p, uint16_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint32(void* p, uint32_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeUint64(void* p, uint64_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt16(void* p, int16_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt32(void* p, int32_t val) { write(p, val); } /** Write |val| to |p| using ThisEndian endianness. */ static void writeInt64(void* p, int64_t val) { write(p, val); } /* * Converts a value of type T to little-endian format. * * This function is intended for cases where you have data in your * native-endian format and you need it to appear in little-endian * format for transmission. */ template MOZ_WARN_UNUSED_RESULT static T swapToLittleEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to little-endian format if ThisEndian is Big. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapToLittleEndian(void* dest, const T* src, size_t count) { copyAndSwapTo(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapToLittleEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Converts a value of type T to big-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapToBigEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to big-endian format if ThisEndian is Little. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapToBigEndian(void* dest, const T* src, size_t count) { copyAndSwapTo(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapToBigEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Synonyms for the big-endian functions, for better readability * in network code. */ template MOZ_WARN_UNUSED_RESULT static T swapToNetworkOrder(T value) { return swapToBigEndian(value); } template static void copyAndSwapToNetworkOrder(void* dest, const T* src, size_t count) { copyAndSwapToBigEndian(dest, src, count); } template static void swapToNetworkOrderInPlace(T* p, size_t count) { swapToBigEndianInPlace(p, count); } /* * Converts a value of type T from little-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapFromLittleEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to little-endian format if ThisEndian is Big. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapFromLittleEndian(T* dest, const void* src, size_t count) { copyAndSwapFrom(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapFromLittleEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Converts a value of type T from big-endian format. */ template MOZ_WARN_UNUSED_RESULT static T swapFromBigEndian(T value) { return maybeSwap(value); } /* * Copies count values of type T starting at src to dest, converting * them to big-endian format if ThisEndian is Little. * As with memcpy, dest and src must not overlap. */ template static void copyAndSwapFromBigEndian(T* dest, const void* src, size_t count) { copyAndSwapFrom(dest, src, count); } /* * Likewise, but converts values in place. */ template static void swapFromBigEndianInPlace(T* p, size_t count) { maybeSwapInPlace(p, count); } /* * Synonyms for the big-endian functions, for better readability * in network code. */ template MOZ_WARN_UNUSED_RESULT static T swapFromNetworkOrder(T value) { return swapFromBigEndian(value); } template static void copyAndSwapFromNetworkOrder(T* dest, const void* src, size_t count) { copyAndSwapFromBigEndian(dest, src, count); } template static void swapFromNetworkOrderInPlace(T* p, size_t count) { swapFromBigEndianInPlace(p, count); } private: /** * Read a value of type T, encoded in endianness ThisEndian from |p|. * Return that value encoded in native endianness. */ template static T read(const void* p) { union { T val; uint8_t buffer[sizeof(T)]; } u; memcpy(u.buffer, p, sizeof(T)); return maybeSwap(u.val); } /** * Write a value of type T, in native endianness, to |p|, in ThisEndian * endianness. */ template static void write(void* p, T value) { T tmp = maybeSwap(value); memcpy(p, &tmp, sizeof(T)); } Endian() MOZ_DELETE; Endian(const Endian& other) MOZ_DELETE; void operator=(const Endian& other) MOZ_DELETE; }; template class EndianReadWrite : public Endian { private: typedef Endian super; public: using super::readUint16; using super::readUint32; using super::readUint64; using super::readInt16; using super::readInt32; using super::readInt64; using super::writeUint16; using super::writeUint32; using super::writeUint64; using super::writeInt16; using super::writeInt32; using super::writeInt64; }; } /* namespace detail */ class LittleEndian MOZ_FINAL : public detail::EndianReadWrite {}; class BigEndian MOZ_FINAL : public detail::EndianReadWrite {}; typedef BigEndian NetworkEndian; class NativeEndian MOZ_FINAL : public detail::Endian { private: typedef detail::Endian super; public: /* * These functions are intended for cases where you have data in your * native-endian format and you need the data to appear in the appropriate * endianness for transmission, serialization, etc. */ using super::swapToLittleEndian; using super::copyAndSwapToLittleEndian; using super::swapToLittleEndianInPlace; using super::swapToBigEndian; using super::copyAndSwapToBigEndian; using super::swapToBigEndianInPlace; using super::swapToNetworkOrder; using super::copyAndSwapToNetworkOrder; using super::swapToNetworkOrderInPlace; /* * These functions are intended for cases where you have data in the * given endianness (e.g. reading from disk or a file-format) and you * need the data to appear in native-endian format for processing. */ using super::swapFromLittleEndian; using super::copyAndSwapFromLittleEndian; using super::swapFromLittleEndianInPlace; using super::swapFromBigEndian; using super::copyAndSwapFromBigEndian; using super::swapFromBigEndianInPlace; using super::swapFromNetworkOrder; using super::copyAndSwapFromNetworkOrder; using super::swapFromNetworkOrderInPlace; }; #undef MOZ_NATIVE_ENDIANNESS } /* namespace mozilla */ #endif /* mozilla_Endian_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/EnumSet.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 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_*/ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/FloatingPoint.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Casting.h" #include namespace mozilla { /* * 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. */ /* * 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. */ static_assert(sizeof(double) == sizeof(uint64_t), "double must be 64 bits"); const unsigned DoubleExponentBias = 1023; const unsigned DoubleExponentShift = 52; const uint64_t DoubleSignBit = 0x8000000000000000ULL; const uint64_t DoubleExponentBits = 0x7ff0000000000000ULL; const uint64_t DoubleSignificandBits = 0x000fffffffffffffULL; static_assert((DoubleSignBit & DoubleExponentBits) == 0, "sign bit doesn't overlap exponent bits"); static_assert((DoubleSignBit & DoubleSignificandBits) == 0, "sign bit doesn't overlap significand bits"); static_assert((DoubleExponentBits & DoubleSignificandBits) == 0, "exponent bits don't overlap significand bits"); static_assert((DoubleSignBit | DoubleExponentBits | DoubleSignificandBits) == ~uint64_t(0), "all bits accounted for"); /** Determines whether a double is NaN. */ static MOZ_ALWAYS_INLINE bool IsNaN(double d) { /* * A double is NaN if all exponent bits are 1 and the significand contains at * least one non-zero bit. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleExponentBits) == DoubleExponentBits && (bits & DoubleSignificandBits) != 0; } /** Determines whether a double is +Infinity or -Infinity. */ static MOZ_ALWAYS_INLINE bool IsInfinite(double d) { /* Infinities have all exponent bits set to 1 and an all-0 significand. */ uint64_t bits = BitwiseCast(d); return (bits & ~DoubleSignBit) == DoubleExponentBits; } /** Determines whether a double is not NaN or infinite. */ static MOZ_ALWAYS_INLINE bool IsFinite(double d) { /* * NaN and Infinities are the only non-finite doubles, and both have all * exponent bits set to 1. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleExponentBits) != DoubleExponentBits; } /** * Determines whether a double is negative. It is an error to call this method * on a double which is NaN. */ static MOZ_ALWAYS_INLINE bool IsNegative(double d) { MOZ_ASSERT(!IsNaN(d), "NaN does not have a sign"); /* The sign bit is set if the double is negative. */ uint64_t bits = BitwiseCast(d); return (bits & DoubleSignBit) != 0; } /** Determines whether a double represents -0. */ static MOZ_ALWAYS_INLINE bool IsNegativeZero(double d) { /* Only the sign bit is set if the double is -0. */ uint64_t bits = BitwiseCast(d); return bits == DoubleSignBit; } /** Returns the exponent portion of the double. */ static MOZ_ALWAYS_INLINE int_fast16_t ExponentComponent(double d) { /* * The exponent component of a double is an unsigned number, biased from its * actual value. Subtract the bias to retrieve the actual exponent. */ uint64_t bits = BitwiseCast(d); return int_fast16_t((bits & DoubleExponentBits) >> DoubleExponentShift) - int_fast16_t(DoubleExponentBias); } /** Returns +Infinity. */ static MOZ_ALWAYS_INLINE double PositiveInfinity() { /* * Positive infinity has all exponent bits set, sign bit set to 0, and no * significand. */ return BitwiseCast(DoubleExponentBits); } /** Returns -Infinity. */ static MOZ_ALWAYS_INLINE double NegativeInfinity() { /* * Negative infinity has all exponent bits set, sign bit set to 1, and no * significand. */ return BitwiseCast(DoubleSignBit | DoubleExponentBits); } /** Constructs a NaN value with the specified sign bit and significand bits. */ static MOZ_ALWAYS_INLINE double SpecificNaN(int signbit, uint64_t significand) { MOZ_ASSERT(signbit == 0 || signbit == 1); MOZ_ASSERT((significand & ~DoubleSignificandBits) == 0); MOZ_ASSERT(significand & DoubleSignificandBits); double d = BitwiseCast((signbit ? DoubleSignBit : 0) | DoubleExponentBits | significand); MOZ_ASSERT(IsNaN(d)); return d; } /** Computes the smallest non-zero positive double value. */ static MOZ_ALWAYS_INLINE double MinDoubleValue() { return BitwiseCast(uint64_t(1)); } static MOZ_ALWAYS_INLINE bool DoubleIsInt32(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 !IsNegativeZero(d) && d == (*i = int32_t(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 UnspecifiedNaN() { return SpecificNaN(0, 0xfffffffffffffULL); } /** * Compare two doubles for equality, *without* equating -0 to +0, and equating * any NaN value to any other NaN value. (The normal equality operators equate * -0 with +0, and they equate NaN to no other value.) */ static inline bool DoublesAreIdentical(double d1, double d2) { if (IsNaN(d1)) return IsNaN(d2); return BitwiseCast(d1) == BitwiseCast(d2); } } /* namespace mozilla */ #endif /* mozilla_FloatingPoint_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/GuardObjects.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/NullPtr.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(nullptr) { } ~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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/HashFunctions.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 nsHashKeys.h. */ #ifndef mozilla_HashFunctions_h #define mozilla_HashFunctions_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/Types.h" #include #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. */ 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Likely.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/LinkedList.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 != nullptr; o = o->getNext()) * o->observe(topic); * } * }; * */ #ifndef mozilla_LinkedList_h #define mozilla_LinkedList_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/NullPtr.h" #ifdef __cplusplus namespace mozilla { template class LinkedList; template class LinkedListElement { /* * It's convenient that we return nullptr 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; public: LinkedListElement() : next(MOZ_THIS_IN_INITIALIZER_LIST()), prev(MOZ_THIS_IN_INITIALIZER_LIST()), isSentinel(false) { } ~LinkedListElement() { if (!isSentinel && isInList()) remove(); } /* * Get the next element in the list, or nullptr 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 nullptr 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(MOZ_THIS_IN_INITIALIZER_LIST()), prev(MOZ_THIS_IN_INITIALIZER_LIST()), isSentinel(nodeKind == NODE_KIND_SENTINEL) { } /* * Return |this| cast to T* if we're a normal node, or return nullptr if * we're a sentinel node. */ T* asT() { if (isSentinel) return nullptr; return static_cast(this); } const T* asT() const { if (isSentinel) return nullptr; 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 nullptr 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 nullptr 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 nullptr. */ 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 nullptr. */ 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_CRASH("element wasn't found in this list!"); #endif } LinkedList& operator=(const LinkedList& other) MOZ_DELETE; LinkedList(const LinkedList& other) MOZ_DELETE; }; } /* namespace mozilla */ #endif /* __cplusplus */ #endif /* mozilla_LinkedList_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/MathAlgorithms.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/TypeTraits.h" #include #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 #if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) # define MOZ_BITSCAN_WINDOWS extern "C" { unsigned char _BitScanForward(unsigned long* Index, unsigned long mask); unsigned char _BitScanReverse(unsigned long* Index, unsigned long mask); # pragma intrinsic(_BitScanForward, _BitScanReverse) # if defined(_M_AMD64) || defined(_M_X64) # define MOZ_BITSCAN_WINDOWS64 unsigned char _BitScanForward64(unsigned long* index, unsigned __int64 mask); unsigned char _BitScanReverse64(unsigned long* index, unsigned __int64 mask); # pragma intrinsic(_BitScanForward64, _BitScanReverse64) # endif } // extern "C" #endif namespace mozilla { namespace detail { #if defined(MOZ_BITSCAN_WINDOWS) inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { unsigned long index; _BitScanReverse(&index, static_cast(u)); return uint_fast8_t(31 - index); } inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { unsigned long index; _BitScanForward(&index, static_cast(u)); return uint_fast8_t(index); } inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { # if defined(MOZ_BITSCAN_WINDOWS64) unsigned long index; _BitScanReverse64(&index, static_cast(u)); return uint_fast8_t(63 - index); # else uint32_t hi = uint32_t(u >> 32); if (hi != 0) return CountLeadingZeroes32(hi); return 32 + CountLeadingZeroes32(uint32_t(u)); # endif } inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { # if defined(MOZ_BITSCAN_WINDOWS64) unsigned long index; _BitScanForward64(&index, static_cast(u)); return uint_fast8_t(index); # else uint32_t lo = uint32_t(u); if (lo != 0) return CountTrailingZeroes32(lo); return 32 + CountTrailingZeroes32(uint32_t(u >> 32)); # endif } # ifdef MOZ_HAVE_BITSCAN64 # undef MOZ_HAVE_BITSCAN64 # endif #elif defined(__clang__) || defined(__GNUC__) # if defined(__clang__) # if !__has_builtin(__builtin_ctz) || !__has_builtin(__builtin_clz) # error "A clang providing __builtin_c[lt]z is required to build" # endif # else // gcc has had __builtin_clz and friends since 3.4: no need to check. # endif inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { return __builtin_clz(u); } inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { return __builtin_ctz(u); } inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { return __builtin_clzll(u); } inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { return __builtin_ctzll(u); } #else # error "Implement these!" inline uint_fast8_t CountLeadingZeroes32(uint32_t u) MOZ_DELETE; inline uint_fast8_t CountTrailingZeroes32(uint32_t u) MOZ_DELETE; inline uint_fast8_t CountLeadingZeroes64(uint64_t u) MOZ_DELETE; inline uint_fast8_t CountTrailingZeroes64(uint64_t u) MOZ_DELETE; #endif } // namespace detail /** * Compute the number of high-order zero bits in the NON-ZERO number |u|. That * is, looking at the bitwise representation of the number, with the highest- * valued bits at the start, return the number of zeroes before the first one * is observed. * * CountLeadingZeroes32(0xF0FF1000) is 0; * CountLeadingZeroes32(0x7F8F0001) is 1; * CountLeadingZeroes32(0x3FFF0100) is 2; * CountLeadingZeroes32(0x1FF50010) is 3; and so on. */ inline uint_fast8_t CountLeadingZeroes32(uint32_t u) { MOZ_ASSERT(u != 0); return detail::CountLeadingZeroes32(u); } /** * Compute the number of low-order zero bits in the NON-ZERO number |u|. That * is, looking at the bitwise representation of the number, with the lowest- * valued bits at the start, return the number of zeroes before the first one * is observed. * * CountTrailingZeroes32(0x0100FFFF) is 0; * CountTrailingZeroes32(0x7000FFFE) is 1; * CountTrailingZeroes32(0x0080FFFC) is 2; * CountTrailingZeroes32(0x0080FFF8) is 3; and so on. */ inline uint_fast8_t CountTrailingZeroes32(uint32_t u) { MOZ_ASSERT(u != 0); return detail::CountTrailingZeroes32(u); } /** Analogous to CountLeadingZeroes32, but for 64-bit numbers. */ inline uint_fast8_t CountLeadingZeroes64(uint64_t u) { MOZ_ASSERT(u != 0); return detail::CountLeadingZeroes64(u); } /** Analogous to CountTrailingZeroes32, but for 64-bit numbers. */ inline uint_fast8_t CountTrailingZeroes64(uint64_t u) { MOZ_ASSERT(u != 0); return detail::CountTrailingZeroes64(u); } namespace detail { template class CeilingLog2; template class CeilingLog2 { public: static uint_fast8_t compute(const T t) { // Check for <= 1 to avoid the == 0 undefined case. return t <= 1 ? 0 : 32 - CountLeadingZeroes32(t - 1); } }; template class CeilingLog2 { public: static uint_fast8_t compute(const T t) { // Check for <= 1 to avoid the == 0 undefined case. return t <= 1 ? 0 : 64 - CountLeadingZeroes64(t - 1); } }; } // namespace detail /** * Compute the log of the least power of 2 greater than or equal to |t|. * * CeilingLog2(0..1) is 0; * CeilingLog2(2) is 1; * CeilingLog2(3..4) is 2; * CeilingLog2(5..8) is 3; * CeilingLog2(9..16) is 4; and so on. */ template inline uint_fast8_t CeilingLog2(const T t) { return detail::CeilingLog2::compute(t); } /** A CeilingLog2 variant that accepts only size_t. */ inline uint_fast8_t CeilingLog2Size(size_t n) { return CeilingLog2(n); } namespace detail { template class FloorLog2; template class FloorLog2 { public: static uint_fast8_t compute(const T t) { return 31 - CountLeadingZeroes32(t | 1); } }; template class FloorLog2 { public: static uint_fast8_t compute(const T t) { return 63 - CountLeadingZeroes64(t | 1); } }; } // namespace detail /** * Compute the log of the greatest power of 2 less than or equal to |t|. * * FloorLog2(0..1) is 0; * FloorLog2(2..3) is 1; * FloorLog2(4..7) is 2; * FloorLog2(8..15) is 3; and so on. */ template inline uint_fast8_t FloorLog2(const T t) { return detail::FloorLog2::compute(t); } /** A FloorLog2 variant that accepts only size_t. */ inline uint_fast8_t FloorLog2Size(size_t n) { return FloorLog2(n); } /* * Compute the smallest power of 2 greater than or equal to |x|. |x| must not * be so great that the computed value would overflow |size_t|. */ inline size_t RoundUpPow2(size_t x) { MOZ_ASSERT(x <= (size_t(1) << (sizeof(size_t) * CHAR_BIT - 1)), "can't round up -- will overflow!"); return size_t(1) << CeilingLog2(x); } } /* namespace mozilla */ #endif /* mozilla_MathAlgorithms_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/MemoryChecking.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/MemoryReporting.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Memory reporting infrastructure. */ #ifndef mozilla_MemoryReporting_h #define mozilla_MemoryReporting_h #include #ifdef __cplusplus namespace mozilla { /* * This is for functions that are like malloc_usable_size. Such functions are * used for measuring the size of data structures. */ typedef size_t (*MallocSizeOf)(const void* p); } /* namespace mozilla */ #endif /* __cplusplus */ typedef size_t (*MozMallocSizeOf)(const void* p); #endif /* mozilla_MemoryReporting_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Move.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* C++11-style, but C++98-usable, "move references" implementation. */ #ifndef mozilla_Move_h #define mozilla_Move_h namespace mozilla { /* * "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 (although 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 a MoveRef * referring to the same value; that's 1). A 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 a 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 mozilla 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(Move(c->x)), y(Move(c->y)) { } * * than the equivalent: * * C(MoveRef c) { new(&x) X(Move(c->x)); new(&y) Y(Move(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 { T* pointer; public: explicit MoveRef(T& t) : pointer(&t) { } T& operator*() const { return *pointer; } T* operator->() const { return pointer; } operator T& () const { return *pointer; } }; template inline MoveRef Move(T& t) { return MoveRef(t); } template inline MoveRef Move(const T& t) { // With some versions of gcc, for a class C, there's an (incorrect) ambiguity // between the C(const C&) constructor and the default C(C&&) C++11 move // constructor, when the constructor is called with a const C& argument. // // This ambiguity manifests with the Move implementation above when Move is // passed const U& for some class U. Calling Move(const U&) returns a // MoveRef, which is then commonly passed to the U constructor, // triggering an implicit conversion to const U&. gcc doesn't know whether to // call U(const U&) or U(U&&), so it wrongly reports a compile error. // // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50442 has since been fixed, so // this is no longer an issue for up-to-date compilers. But there's no harm // in keeping it around for older compilers, so we might as well. See also // bug 686280. return MoveRef(const_cast(t)); } /** Swap |t| and |u| using move-construction if possible. */ template inline void Swap(T& t, T& u) { T tmp(Move(t)); t = Move(u); u = Move(tmp); } } // namespace mozilla #endif /* mozilla_Move_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/NullPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/PodOperations.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * Operations for zeroing POD types, arrays, and so on. * * These operations are preferable to memset, memcmp, and the like because they * don't require remembering to multiply by sizeof(T), array lengths, and so on * everywhere. */ #ifndef mozilla_PodOperations_h #define mozilla_PodOperations_h #include "mozilla/Attributes.h" #include "mozilla/Util.h" #include namespace mozilla { /** Set the contents of |t| to 0. */ template static void PodZero(T* t) { memset(t, 0, sizeof(T)); } /** Set the contents of |nelem| elements starting at |t| to 0. */ template 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 (&t)[N]) MOZ_DELETE; template static void PodZero(T (&t)[N], size_t nelem) MOZ_DELETE; /** Set the contents of the array |t| to zero. */ template static void PodArrayZero(T (&t)[N]) { memset(t, 0, N * sizeof(T)); } /** * Assign |*src| to |*dst|. The locations must not be the same and must not * overlap. */ template static void PodAssign(T* dst, const T* src) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= 1); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= 1); memcpy(reinterpret_cast(dst), reinterpret_cast(src), sizeof(T)); } /** * Copy |nelem| T elements from |src| to |dst|. The two memory ranges must not * overlap! */ template MOZ_ALWAYS_INLINE static void PodCopy(T* dst, const T* src, size_t nelem) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= nelem); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= 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 MOZ_ALWAYS_INLINE static void PodCopy(volatile T* dst, const volatile T* src, size_t nelem) { MOZ_ASSERT(dst != src); MOZ_ASSERT_IF(src < dst, PointerRangeSize(src, static_cast(dst)) >= nelem); MOZ_ASSERT_IF(dst < src, PointerRangeSize(static_cast(dst), src) >= nelem); /* * Volatile |dst| requires extra work, because it's undefined behavior to * modify volatile objects using the mem* functions. Just write out the * loops manually, using operator= rather than memcpy for the same reason, * and let the compiler optimize to the extent it can. */ for (const volatile T* srcend = src + nelem; src < srcend; src++, dst++) *dst = *src; } /* * Copy the contents of the array |src| into the array |dst|, both of size N. * The arrays must not overlap! */ template static void PodArrayCopy(T (&dst)[N], const T (&src)[N]) { PodCopy(dst, src, N); } /** * Determine whether the |len| elements at |one| are memory-identical to the * |len| elements at |two|. */ template MOZ_ALWAYS_INLINE static bool PodEqual(const T* one, const T* two, size_t len) { if (len < 128) { const T* p1end = one + len; const T* p1 = one; const T* p2 = two; for (; p1 < p1end; p1++, p2++) { if (*p1 != *p2) return false; } return true; } return !memcmp(one, two, len * sizeof(T)); } } // namespace mozilla #endif /* mozilla_PodOperations_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Poison.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 poison value that can be used to fill a memory space with * an address that leads to a safe crash when dereferenced. */ #ifndef mozilla_Poison_h #define mozilla_Poison_h #include "mozilla/Assertions.h" #include "mozilla/Types.h" #include MOZ_BEGIN_EXTERN_C extern MFBT_DATA uintptr_t gMozillaPoisonValue; /** * @return the poison value. */ inline uintptr_t mozPoisonValue() { return gMozillaPoisonValue; } /** * Overwrite the memory block of aSize bytes at aPtr with the poison value. * aPtr MUST be aligned at a sizeof(uintptr_t) boundary. * Only an even number of sizeof(uintptr_t) bytes are overwritten, the last * few bytes (if any) is not overwritten. */ inline void mozWritePoison(void* aPtr, size_t aSize) { const uintptr_t POISON = mozPoisonValue(); char* p = (char*)aPtr; char* limit = p + aSize; MOZ_ASSERT((uintptr_t)aPtr % sizeof(uintptr_t) == 0, "bad alignment"); MOZ_ASSERT(aSize >= sizeof(uintptr_t), "poisoning this object has no effect"); for (; p < limit; p += sizeof(uintptr_t)) { *((uintptr_t*)p) = POISON; } } /** * Initialize the poison value. * This should only be called once. */ extern MFBT_API void mozPoisonValueInit(); /* Values annotated by CrashReporter */ extern MFBT_DATA uintptr_t gMozillaPoisonBase; extern MFBT_DATA uintptr_t gMozillaPoisonSize; MOZ_END_EXTERN_C #endif /* mozilla_Poison_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Range.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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]; } const T& operator[](size_t offset) const { return mStart[offset]; } operator ConvertibleToBool() const { return mStart ? &Range::nonNull : 0; } }; } // namespace mozilla #endif /* mozilla_Range_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/RangedPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/NullPtr.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, nullptr, 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/ReentrancyGuard.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* Small helper class for asserting uses of a class are non-reentrant. */ #ifndef mozilla_ReentrancyGuard_h #define mozilla_ReentrancyGuard_h #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/GuardObjects.h" namespace mozilla { /* Useful for implementing containers that assert non-reentrancy */ class ReentrancyGuard { MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER #ifdef DEBUG bool& entered; #endif public: template #ifdef DEBUG ReentrancyGuard(T& obj MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : entered(obj.entered) #else ReentrancyGuard(T& MOZ_GUARD_OBJECT_NOTIFIER_PARAM) #endif { MOZ_GUARD_OBJECT_NOTIFIER_INIT; #ifdef DEBUG MOZ_ASSERT(!entered); entered = true; #endif } ~ReentrancyGuard() { #ifdef DEBUG entered = false; #endif } private: ReentrancyGuard(const ReentrancyGuard&) MOZ_DELETE; void operator=(const ReentrancyGuard&) MOZ_DELETE; }; } // namespace mozilla #endif /* mozilla_ReentrancyGuard_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/RefPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Atomics.h" #include "mozilla/Attributes.h" #include "mozilla/TypeTraits.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). */ namespace detail { #ifdef DEBUG static const int DEAD = 0xffffdead; #endif // This is used WeakPtr.h as well as this file. enum RefCountAtomicity { AtomicRefCount, NonAtomicRefCount }; 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: typename Conditional, int>::Type refCnt; }; } template class RefCounted : public detail::RefCounted { public: ~RefCounted() { static_assert(IsBaseOf::value, "T must derive from RefCounted"); } }; /** * AtomicRefCounted is like RefCounted, with an atomically updated * reference counter. */ template class AtomicRefCounted : public detail::RefCounted { public: ~AtomicRefCounted() { static_assert(IsBaseOf::value, "T must derive from AtomicRefCounted"); } }; /** * 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 #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 #endif /* mozilla_RefPtr_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/SHA1.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/Types.h" #include #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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Scoped.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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" #include "mozilla/NullPtr.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 nullptr; } 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 nullptr; } const static void release(type value) { if (value) TypeSpecificDelete(value); } }; SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits) } /* namespace mozilla */ #endif /* mozilla_Scoped_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/SplayTree.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/TemplateLib.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ /* * Reusable template meta-functions on types and compile-time values. Meta- * functions are placed inside the 'tl' namespace to avoid conflict with non- * meta functions of the same name (e.g., mozilla::tl::FloorLog2 vs. * mozilla::FloorLog2). * * When constexpr support becomes universal, we should probably use that instead * of some of these templates, for simplicity. */ #ifndef mozilla_TemplateLib_h #define mozilla_TemplateLib_h #include #include namespace mozilla { namespace tl { /** Compute min/max. */ template struct Min { static const size_t value = I < J ? I : J; }; template struct Max { static const size_t value = I > J ? I : J; }; /** Compute floor(log2(i)). */ template struct FloorLog2 { static const size_t value = 1 + FloorLog2::value; }; template<> struct FloorLog2<0> { /* Error */ }; template<> struct FloorLog2<1> { static const size_t value = 0; }; /** Compute ceiling(log2(i)). */ template struct CeilingLog2 { static const size_t value = FloorLog2<2 * I - 1>::value; }; /** Round up to the nearest power of 2. */ template struct RoundUpPow2 { static const size_t value = size_t(1) << CeilingLog2::value; }; template<> struct RoundUpPow2<0> { static const size_t value = 1; }; /** Compute the number of bits in the given unsigned type. */ template struct BitSize { static const size_t value = sizeof(T) * CHAR_BIT; }; /** * Produce an N-bit mask, where N <= BitSize::value. Handle the * language-undefined edge case when N = BitSize::value. */ 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 |value| to assure // its computation. static const size_t checkPrecondition = 0 / size_t(N < BitSize::value); static const size_t value = (size_t(1) << N) - 1 + checkPrecondition; }; template<> struct NBitMask::value> { static const size_t value = 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 value = ~NBitMask::value - CeilingLog2::value>::value; }; template<> struct MulOverflowMask<0> { /* Error */ }; template<> struct MulOverflowMask<1> { static const size_t value = 0; }; } // namespace tl } // namespace mozilla #endif /* mozilla_TemplateLib_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/ThreadLocal.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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" #include "mozilla/NullPtr.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() { 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, nullptr); #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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/TypeTraits.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 { /* Forward declarations. */ template struct RemoveCV; /* 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] */ namespace detail { template struct IsIntegralHelper : FalseType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; template<> struct IsIntegralHelper : TrueType {}; } /* namespace detail */ /** * IsIntegral determines whether a type is an integral type. * * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is true; * mozilla::IsIntegral::value is false; * mozilla::IsIntegral::value is false; * * Note that the behavior of IsIntegral on char16_t and char32_t is * unspecified. */ template struct IsIntegral : detail::IsIntegralHelper::Type> {}; template struct IsSame; namespace detail { template struct IsFloatingPointHelper : IntegralConstant::value || IsSame::value || IsSame::value> {}; } // namespace detail /** * IsFloatingPoint determines whether a type is a floating point type (float, * double, long double). * * mozilla::IsFloatingPoint::value is false; * mozilla::IsFloatingPoint::value is true; * mozilla::IsFloatingPoint::value is true; * mozilla::IsFloatingPoint::value is false. */ template struct IsFloatingPoint : detail::IsFloatingPointHelper::Type> {}; /** * 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 {}; namespace detail { // __is_enum is a supported extension across all of our supported compilers. template struct IsEnumHelper : IntegralConstant {}; } // namespace detail /** * IsEnum determines whether a type is an enum type. * * mozilla::IsEnum::value is true; * mozilla::IsEnum::value is false; * mozilla::IsEnum::value is false; */ template struct IsEnum : detail::IsEnumHelper::Type> {}; /* 20.9.4.2 Composite type traits [meta.unary.comp] */ /** * IsArithmetic determines whether a type is arithmetic. A type is arithmetic * iff it is an integral type or a floating point type. * * mozilla::IsArithmetic::value is true; * mozilla::IsArithmetic::value is true; * mozilla::IsArithmetic::value is false. */ template struct IsArithmetic : IntegralConstant::value || IsFloatingPoint::value> {}; /* 20.9.4.3 Type properties [meta.unary.prop] */ /** * IsConst determines whether a type is const or not. * * mozilla::IsConst::value is false; * mozilla::IsConst::value is true; * mozilla::IsConst::value is false. */ template struct IsConst : FalseType {}; template struct IsConst : TrueType {}; /** * IsVolatile determines whether a type is volatile or not. * * mozilla::IsVolatile::value is false; * mozilla::IsVolatile::value is true; * mozilla::IsVolatile::value is false. */ template struct IsVolatile : FalseType {}; template struct IsVolatile : TrueType {}; /** * 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 {}; namespace detail { template::value> struct IsSignedHelper; template struct IsSignedHelper : TrueType {}; template struct IsSignedHelper : IntegralConstant::value && T(-1) < T(1)> {}; } // namespace detail /** * IsSigned determines whether a type is a signed arithmetic type. |char| is * considered a signed type if it has the same representation as |signed char|. * * Don't use this if the type might be user-defined! You might or might not get * a compile error, depending. * * mozilla::IsSigned::value is true; * mozilla::IsSigned::value is false; * mozilla::IsSigned::value is false; * mozilla::IsSigned::value is true. */ template struct IsSigned : detail::IsSignedHelper {}; namespace detail { template::value> struct IsUnsignedHelper; template struct IsUnsignedHelper : FalseType {}; template struct IsUnsignedHelper : IntegralConstant::value && (IsSame::Type, bool>::value || T(1) < T(-1))> {}; } // namespace detail /** * IsUnsigned determines whether a type is an unsigned arithmetic type. * * Don't use this if the type might be user-defined! You might or might not get * a compile error, depending. * * mozilla::IsUnsigned::value is false; * mozilla::IsUnsigned::value is true; * mozilla::IsUnsigned::value is true; * mozilla::IsUnsigned::value is false. */ template struct IsUnsigned : detail::IsUnsignedHelper {}; /* 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] */ /** * RemoveConst removes top-level const qualifications on a type. * * mozilla::RemoveConst::Type is int; * mozilla::RemoveConst::Type is int; * mozilla::RemoveConst::Type is const int*; * mozilla::RemoveConst::Type is int*. */ template struct RemoveConst { typedef T Type; }; template struct RemoveConst { typedef T Type; }; /** * RemoveVolatile removes top-level volatile qualifications on a type. * * mozilla::RemoveVolatile::Type is int; * mozilla::RemoveVolatile::Type is int; * mozilla::RemoveVolatile::Type is volatile int*; * mozilla::RemoveVolatile::Type is int*. */ template struct RemoveVolatile { typedef T Type; }; template struct RemoveVolatile { typedef T Type; }; /** * RemoveCV removes top-level const and volatile qualifications on a type. * * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int; * mozilla::RemoveCV::Type is int*. */ template struct RemoveCV { typedef typename RemoveConst::Type>::Type Type; }; /* 20.9.7.2 Reference modifications [meta.trans.ref] */ /* 20.9.7.3 Sign modifications [meta.trans.sign] */ template struct EnableIf; template struct Conditional; namespace detail { template struct WithC : Conditional {}; template struct WithV : Conditional {}; template struct WithCV : WithC::Type> {}; template struct CorrespondingSigned; template<> struct CorrespondingSigned { typedef signed char Type; }; template<> struct CorrespondingSigned { typedef signed char Type; }; template<> struct CorrespondingSigned { typedef short Type; }; template<> struct CorrespondingSigned { typedef int Type; }; template<> struct CorrespondingSigned { typedef long Type; }; template<> struct CorrespondingSigned { typedef long long Type; }; template::Type, bool IsSignedIntegerType = IsSigned::value && !IsSame::value> struct MakeSigned; template struct MakeSigned { typedef T Type; }; template struct MakeSigned : WithCV::value, IsVolatile::value, typename CorrespondingSigned::Type> {}; } // namespace detail /** * MakeSigned produces the corresponding signed integer type for a given * integral type T, with the const/volatile qualifiers of T. T must be a * possibly-const/volatile-qualified integral type that isn't bool. * * If T is already a signed integer type (not including char!), then T is * produced. * * Otherwise, if T is an unsigned integer type, the signed variety of T, with * T's const/volatile qualifiers, is produced. * * Otherwise, the integral type of the same size as T, with the lowest rank, * with T's const/volatile qualifiers, is produced. (This basically only acts * to produce signed char when T = char.) * * mozilla::MakeSigned::Type is signed long; * mozilla::MakeSigned::Type is volatile int; * mozilla::MakeSigned::Type is const signed short; * mozilla::MakeSigned::Type is const signed char; * mozilla::MakeSigned is an error; * mozilla::MakeSigned is an error. */ template struct MakeSigned : EnableIf::value && !IsSame::Type>::value, typename detail::MakeSigned >::Type {}; namespace detail { template struct CorrespondingUnsigned; template<> struct CorrespondingUnsigned { typedef unsigned char Type; }; template<> struct CorrespondingUnsigned { typedef unsigned char Type; }; template<> struct CorrespondingUnsigned { typedef unsigned short Type; }; template<> struct CorrespondingUnsigned { typedef unsigned int Type; }; template<> struct CorrespondingUnsigned { typedef unsigned long Type; }; template<> struct CorrespondingUnsigned { typedef unsigned long long Type; }; template::Type, bool IsUnsignedIntegerType = IsUnsigned::value && !IsSame::value> struct MakeUnsigned; template struct MakeUnsigned { typedef T Type; }; template struct MakeUnsigned : WithCV::value, IsVolatile::value, typename CorrespondingUnsigned::Type> {}; } // namespace detail /** * MakeUnsigned produces the corresponding unsigned integer type for a given * integral type T, with the const/volatile qualifiers of T. T must be a * possibly-const/volatile-qualified integral type that isn't bool. * * If T is already an unsigned integer type (not including char!), then T is * produced. * * Otherwise, if T is an signed integer type, the unsigned variety of T, with * T's const/volatile qualifiers, is produced. * * Otherwise, the unsigned integral type of the same size as T, with the lowest * rank, with T's const/volatile qualifiers, is produced. (This basically only * acts to produce unsigned char when T = char.) * * mozilla::MakeUnsigned::Type is unsigned long; * mozilla::MakeUnsigned::Type is volatile unsigned int; * mozilla::MakeUnsigned::Type is const unsigned short; * mozilla::MakeUnsigned::Type is const unsigned char; * mozilla::MakeUnsigned is an error; * mozilla::MakeUnsigned is an error. */ template struct MakeUnsigned : EnableIf::value && !IsSame::Type>::value, typename detail::MakeUnsigned >::Type {}; /* 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/TypedEnum.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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. * * MOZ_{BEGIN,END}_ENUM_CLASS doesn't work for defining enum classes nested * inside classes. To define an enum class nested inside another class, use * MOZ_{BEGIN,END}_NESTED_ENUM_CLASS, and place a MOZ_FINISH_NESTED_ENUM_CLASS * in namespace scope to handle bits that can only be implemented with * namespace-scoped code. For example: * * class FooBar { * * MOZ_BEGIN_NESTED_ENUM_CLASS(Enum, int32_t) * A, * B = 6 * MOZ_END_NESTED_ENUM_CLASS(Enum) * * }; * * MOZ_FINISH_NESTED_ENUM_CLASS(FooBar::Enum) */ #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_NESTED_ENUM_CLASS(Name, type) \ enum class Name : type { # define MOZ_END_NESTED_ENUM_CLASS(Name) \ }; # define MOZ_FINISH_NESTED_ENUM_CLASS(Name) /* nothing */ #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_NESTED_ENUM_CLASS(Name, type) \ class Name \ { \ public: \ enum Enum MOZ_ENUM_TYPE(type) \ { # define MOZ_END_NESTED_ENUM_CLASS(Name) \ }; \ Name() {} \ Name(Enum aEnum) : mEnum(aEnum) {} \ explicit Name(int num) : mEnum((Enum)num) {} \ operator Enum() const { return mEnum; } \ private: \ Enum mEnum; \ }; # define MOZ_FINISH_NESTED_ENUM_CLASS(Name) \ 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 # define MOZ_BEGIN_ENUM_CLASS(Name, type) MOZ_BEGIN_NESTED_ENUM_CLASS(Name, type) # define MOZ_END_ENUM_CLASS(Name) \ MOZ_END_NESTED_ENUM_CLASS(Name) \ MOZ_FINISH_NESTED_ENUM_CLASS(Name) #endif /* __cplusplus */ #endif /* mozilla_TypedEnum_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Types.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 types and size_t. */ #include #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 /* * GCC's typeof is available when decltype is not. */ #if defined(__GNUC__) && defined(__cplusplus) && \ !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L # define decltype __typeof__ #endif #endif /* mozilla_Types_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Util.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8, t9); constructed = true; } template void construct(const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9, const T10& t10) { MOZ_ASSERT(!constructed); ::new (storage.addr()) T(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); 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 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 */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/Vector.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/length-parametrized vector class. */ #ifndef mozilla_Vector_h #define mozilla_Vector_h #include "mozilla/AllocPolicy.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/NullPtr.h" #include "mozilla/ReentrancyGuard.h" #include "mozilla/TemplateLib.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.h" #include // for placement new /* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4345) #endif namespace mozilla { template class VectorBase; namespace detail { /* * 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(VectorBase& v, size_t newCap) { MOZ_ASSERT(!v.usingInlineStorage()); MOZ_ASSERT(!CapacityHasExcessSpace(newCap)); T* newbuf = reinterpret_cast(v.malloc_(newCap * sizeof(T))); if (!newbuf) return false; T* dst = newbuf; T* src = v.beginNoCheck(); for (; 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* end = dst + n; dst < end; ++dst) *dst = t; } static inline bool growTo(VectorBase& v, size_t newCap) { MOZ_ASSERT(!v.usingInlineStorage()); MOZ_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; } }; } // namespace detail /* * A CRTP base class for vector-like classes. Unless you really really want * your own vector class -- and you almost certainly don't -- you should use * mozilla::Vector instead! * * See mozilla::Vector for interface requirements. */ template class VectorBase : private AllocPolicy { /* utilities */ static const bool sElemIsPod = IsPod::value; typedef detail::VectorImpl Impl; friend struct detail::VectorImpl; bool growStorageBy(size_t incr); bool convertToHeapStorage(size_t newCap); /* 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 value = sizeof(T); }; template struct ElemSize<0, Dummy> { static const size_t value = 1; }; static const size_t sInlineCapacity = tl::Min::value>::value; /* Calculate inline buffer size; avoid 0-sized array. */ static const size_t sInlineBytes = tl::Max<1, sInlineCapacity * ElemSize::value>::value; /* 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; /* Number of elements in the vector. */ size_t mLength; /* Max number of elements storable in the vector without resizing. */ size_t mCapacity; #ifdef DEBUG /* Max elements of reserved or used space in this vector. */ size_t mReserved; #endif /* Memory used for inline storage. */ AlignedStorage storage; #ifdef DEBUG friend class ReentrancyGuard; bool entered; #endif /* private accessors */ bool usingInlineStorage() const { return mBegin == const_cast(this)->inlineStorage(); } T* inlineStorage() { return static_cast(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 { MOZ_ASSERT(mReserved <= mCapacity); MOZ_ASSERT(mLength <= mReserved); return mReserved; } #endif /* Append operations guaranteed to succeed due to pre-reserved space. */ template void internalAppend(const U& u); template void internalAppendAll(const VectorBase& u); void internalAppendN(const T& t, size_t n); template void internalAppend(const U* begin, size_t length); public: static const size_t sMaxInlineStorage = N; typedef T ElementType; VectorBase(AllocPolicy = AllocPolicy()); VectorBase(MoveRef); /* Move constructor. */ ThisVector& operator=(MoveRef); /* Move assignment. */ ~VectorBase(); /* 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() { MOZ_ASSERT(!entered); return mBegin; } const T* begin() const { MOZ_ASSERT(!entered); return mBegin; } T* end() { MOZ_ASSERT(!entered); return mBegin + mLength; } const T* end() const { MOZ_ASSERT(!entered); return mBegin + mLength; } T& operator[](size_t i) { MOZ_ASSERT(!entered); MOZ_ASSERT(i < mLength); return begin()[i]; } const T& operator[](size_t i) const { MOZ_ASSERT(!entered); MOZ_ASSERT(i < mLength); return begin()[i]; } T& back() { MOZ_ASSERT(!entered); MOZ_ASSERT(!empty()); return *(end() - 1); } const T& back() const { MOZ_ASSERT(!entered); MOZ_ASSERT(!empty()); return *(end() - 1); } class Range { friend class VectorBase; T* cur_; T* 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() { MOZ_ASSERT(!empty()); ++cur_; } T popCopyFront() { MOZ_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); /** * Increase the length of the vector, but don't initialize the new elements * -- leave them 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 won't reallocate elements storage. * This *doesn't* mean that infallibleAppend may be used! You still must * reserve the extra space, even if this method indicates that appends won't * need to reallocate elements storage. */ 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(const U& u); template bool appendAll(const VectorBase& u); 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); /* * Guaranteed-infallible append operations for use upon vectors whose * memory has been pre-reserved. Don't use this if you haven't reserved the * memory! */ 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, PointerRangeSize(aBegin, aEnd)); } template void infallibleAppend(const U* aBegin, size_t aLength) { internalAppend(aBegin, aLength); } void popBack(); T popCopy(); /** * Transfers ownership of the internal buffer used by this vector to the * caller. (It's the caller's responsibility to properly deallocate this * buffer, in accordance with this vector's AllocPolicy.) 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 nullptr. * * N.B. Although a T*, only the range [0, length()) is constructed. */ T* extractRawBuffer(); /** * Transfer ownership of an array of objects into the vector. The caller * must have allocated the array in accordance with this vector's * AllocPolicy. * * 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'll * be a dangling pointer if reallocation of the vector storage occurred; the * return value should be used instead. On failure, nullptr is returned. * * Example usage: * * if (!(p = vec.insert(p, val))) * * * * This is inherently a linear-time operation. Be careful! */ 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(MallocSizeOf mallocSizeOf) const; /** * Like sizeOfExcludingThis, but also measures the size of the vector * object (which must be heap-allocated) itself. */ size_t sizeOfIncludingThis(MallocSizeOf mallocSizeOf) const; void swap(ThisVector& other); private: VectorBase(const ThisVector&) MOZ_DELETE; void operator=(const ThisVector&) MOZ_DELETE; }; /* This does the re-entrancy check plus several other sanity checks. */ #define MOZ_REENTRANCY_GUARD_ET_AL \ ReentrancyGuard g(*this); \ MOZ_ASSERT_IF(usingInlineStorage(), mCapacity == sInlineCapacity); \ MOZ_ASSERT(reserved() <= mCapacity); \ MOZ_ASSERT(mLength <= reserved()); \ MOZ_ASSERT(mLength <= mCapacity) /* Vector Implementation */ template MOZ_ALWAYS_INLINE VectorBase::VectorBase(AP ap) : AP(ap), mBegin(static_cast(storage.addr())), mLength(0), mCapacity(sInlineCapacity) #ifdef DEBUG , mReserved(sInlineCapacity), entered(false) #endif {} /* Move constructor. */ template MOZ_ALWAYS_INLINE VectorBase::VectorBase(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 = static_cast(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 = static_cast(rhs->storage.addr()); rhs->mCapacity = sInlineCapacity; rhs->mLength = 0; #ifdef DEBUG rhs->mReserved = sInlineCapacity; #endif } } /* Move assignment. */ template MOZ_ALWAYS_INLINE TV& VectorBase::operator=(MoveRef rhs) { TV* tv = static_cast(this); tv->~TV(); new(tv) TV(rhs); return *tv; } template MOZ_ALWAYS_INLINE VectorBase::~VectorBase() { MOZ_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 VectorBase::convertToHeapStorage(size_t newCap) { MOZ_ASSERT(usingInlineStorage()); /* Allocate buffer. */ MOZ_ASSERT(!detail::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 MOZ_NEVER_INLINE bool VectorBase::growStorageBy(size_t incr) { MOZ_ASSERT(mLength + incr > mCapacity); MOZ_ASSERT_IF(!usingInlineStorage(), !detail::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)>::value; 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 * * static_cast(end()) - static_cast(begin()) * * doesn't overflow ptrdiff_t (see bug 510319). */ if (mLength & tl::MulOverflowMask<4 * sizeof(T)>::value) { 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 (detail::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)>::value) { 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 VectorBase::initCapacity(size_t request) { MOZ_ASSERT(empty()); MOZ_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 VectorBase::reserve(size_t request) { MOZ_REENTRANCY_GUARD_ET_AL; if (request > mCapacity && !growStorageBy(request - mLength)) return false; #ifdef DEBUG if (request > mReserved) mReserved = request; MOZ_ASSERT(mLength <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); #endif return true; } template inline void VectorBase::shrinkBy(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; MOZ_ASSERT(incr <= mLength); Impl::destroy(endNoCheck() - incr, endNoCheck()); mLength -= incr; } template MOZ_ALWAYS_INLINE bool VectorBase::growBy(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; if (incr > mCapacity - mLength && !growStorageBy(incr)) return false; MOZ_ASSERT(mLength + incr <= mCapacity); T* newend = endNoCheck() + incr; Impl::initialize(endNoCheck(), newend); mLength += incr; #ifdef DEBUG if (mLength > mReserved) mReserved = mLength; #endif return true; } template MOZ_ALWAYS_INLINE bool VectorBase::growByUninitialized(size_t incr) { MOZ_REENTRANCY_GUARD_ET_AL; if (incr > mCapacity - mLength && !growStorageBy(incr)) return false; MOZ_ASSERT(mLength + incr <= mCapacity); mLength += incr; #ifdef DEBUG if (mLength > mReserved) mReserved = mLength; #endif return true; } template inline bool VectorBase::resize(size_t newLength) { size_t curLength = mLength; if (newLength > curLength) return growBy(newLength - curLength); shrinkBy(curLength - newLength); return true; } template MOZ_ALWAYS_INLINE bool VectorBase::resizeUninitialized(size_t newLength) { size_t curLength = mLength; if (newLength > curLength) return growByUninitialized(newLength - curLength); shrinkBy(curLength - newLength); return true; } template inline void VectorBase::clear() { MOZ_REENTRANCY_GUARD_ET_AL; Impl::destroy(beginNoCheck(), endNoCheck()); mLength = 0; } template inline void VectorBase::clearAndFree() { clear(); if (usingInlineStorage()) return; this->free_(beginNoCheck()); mBegin = static_cast(storage.addr()); mCapacity = sInlineCapacity; #ifdef DEBUG mReserved = sInlineCapacity; #endif } template inline bool VectorBase::canAppendWithoutRealloc(size_t needed) const { return mLength + needed <= mCapacity; } template template MOZ_ALWAYS_INLINE void VectorBase::internalAppendAll(const VectorBase& other) { internalAppend(other.begin(), other.length()); } template template MOZ_ALWAYS_INLINE void VectorBase::internalAppend(const U& u) { MOZ_ASSERT(mLength + 1 <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); new(endNoCheck()) T(u); ++mLength; } template MOZ_ALWAYS_INLINE bool VectorBase::appendN(const T& t, size_t needed) { MOZ_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 MOZ_ALWAYS_INLINE void VectorBase::internalAppendN(const T& t, size_t needed) { MOZ_ASSERT(mLength + needed <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); Impl::copyConstructN(endNoCheck(), needed, t); mLength += needed; } template inline T* VectorBase::insert(T* p, const T& val) { MOZ_ASSERT(begin() <= p); MOZ_ASSERT(p <= end()); size_t pos = p - begin(); MOZ_ASSERT(pos <= mLength); size_t oldLength = mLength; if (pos == oldLength) { if (!append(val)) return nullptr; } else { T oldBack = back(); if (!append(oldBack)) /* Dup the last element. */ return nullptr; for (size_t i = oldLength; i > pos; --i) (*this)[i] = (*this)[i - 1]; (*this)[pos] = val; } return begin() + pos; } template inline void VectorBase::erase(T* it) { MOZ_ASSERT(begin() <= it); MOZ_ASSERT(it < end()); while (it + 1 < end()) { *it = *(it + 1); ++it; } popBack(); } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U* insBegin, const U* insEnd) { MOZ_REENTRANCY_GUARD_ET_AL; size_t needed = 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 MOZ_ALWAYS_INLINE void VectorBase::internalAppend(const U* insBegin, size_t insLength) { MOZ_ASSERT(mLength + insLength <= mReserved); MOZ_ASSERT(mReserved <= mCapacity); Impl::copyConstruct(endNoCheck(), insBegin, insBegin + insLength); mLength += insLength; } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U& u) { MOZ_REENTRANCY_GUARD_ET_AL; if (mLength == mCapacity && !growStorageBy(1)) return false; #ifdef DEBUG if (mLength + 1 > mReserved) mReserved = mLength + 1; #endif internalAppend(u); return true; } template template MOZ_ALWAYS_INLINE bool VectorBase::appendAll(const VectorBase& other) { return append(other.begin(), other.length()); } template template MOZ_ALWAYS_INLINE bool VectorBase::append(const U *insBegin, size_t insLength) { return append(insBegin, insBegin + insLength); } template MOZ_ALWAYS_INLINE void VectorBase::popBack() { MOZ_REENTRANCY_GUARD_ET_AL; MOZ_ASSERT(!empty()); --mLength; endNoCheck()->~T(); } template MOZ_ALWAYS_INLINE T VectorBase::popCopy() { T ret = back(); popBack(); return ret; } template inline T* VectorBase::extractRawBuffer() { T* ret; if (usingInlineStorage()) { ret = reinterpret_cast(this->malloc_(mLength * sizeof(T))); if (!ret) return nullptr; Impl::copyConstruct(ret, beginNoCheck(), endNoCheck()); Impl::destroy(beginNoCheck(), endNoCheck()); /* mBegin, mCapacity are unchanged. */ mLength = 0; } else { ret = mBegin; mBegin = static_cast(storage.addr()); mLength = 0; mCapacity = sInlineCapacity; #ifdef DEBUG mReserved = sInlineCapacity; #endif } return ret; } template inline void VectorBase::replaceRawBuffer(T* p, size_t aLength) { MOZ_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 = static_cast(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 VectorBase::sizeOfExcludingThis(MallocSizeOf mallocSizeOf) const { return usingInlineStorage() ? 0 : mallocSizeOf(beginNoCheck()); } template inline size_t VectorBase::sizeOfIncludingThis(MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } template inline void VectorBase::swap(TV& other) { static_assert(N == 0, "still need to implement this for 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 } /* * 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 AllocPolicy.h (defaults to * mozilla::MallocAllocPolicy) * * Vector is not reentrant: T member functions called during Vector member * functions must not call back into the same object! */ template class Vector : public VectorBase > { typedef VectorBase Base; public: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} Vector(mozilla::MoveRef vec) : Base(vec) {} Vector& operator=(mozilla::MoveRef vec) { return Base::operator=(vec); } }; } // namespace mozilla #ifdef _MSC_VER #pragma warning(pop) #endif #endif /* mozilla_Vector_h */ ================================================ FILE: cocos2d/external/spidermonkey/include/win32/mozilla/WeakPtr.h ================================================ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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'. * * AtomicSupportsWeakPtr can be used for a variant with an atomically updated * reference counter. * * 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/Atomics.h" #include "mozilla/NullPtr.h" #include "mozilla/RefPtr.h" #include "mozilla/TypeTraits.h" namespace mozilla { template class WeakPtrBase; template class SupportsWeakPtrBase; namespace detail { // This can live beyond the lifetime of the class derived from SupportsWeakPtrBase. template class WeakReference : public RefCounted, Atomicity> { public: explicit WeakReference(T* p) : ptr(p) {} T* get() const { return ptr; } private: friend class WeakPtrBase; friend class SupportsWeakPtrBase; void detach() { ptr = nullptr; } T* ptr; }; } // namespace detail template class SupportsWeakPtrBase { public: WeakPtrBase asWeakPtr() { if (!weakRef) weakRef = new WeakReference(static_cast(this)); return WeakPtrBase(weakRef); } protected: ~SupportsWeakPtrBase() { static_assert(IsBaseOf, T>::value, "T must derive from SupportsWeakPtrBase"); if (weakRef) weakRef->detach(); } private: friend class WeakPtrBase; RefPtr weakRef; }; template class SupportsWeakPtr : public SupportsWeakPtrBase > { }; template class AtomicSupportsWeakPtr : public SupportsWeakPtrBase > { }; namespace detail { template struct WeakReferenceCount { static const RefCountAtomicity atomicity = IsBaseOf, T>::value ? AtomicRefCount : NonAtomicRefCount; }; } template class WeakPtrBase { public: WeakPtrBase(const WeakPtrBase& o) : ref(o.ref) {} // Ensure that ref is dereferenceable in the uninitialized state WeakPtrBase() : ref(new 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 SupportsWeakPtrBase; explicit WeakPtrBase(const RefPtr &o) : ref(o) {} RefPtr ref; }; template class WeakPtr : public WeakPtrBase::atomicity> > { typedef WeakPtrBase::atomicity> > Base; public: WeakPtr(const WeakPtr& o) : Base(o) {} WeakPtr(const Base& o) : Base(o) {} WeakPtr() {} }; } // namespace mozilla #endif /* mozilla_WeakPtr_h */ ================================================ FILE: cocos2d/external/spidermonkey/prebuilt/android/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := spidermonkey_static LOCAL_MODULE_FILENAME := js_static LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libjs_static.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android LOCAL_CPPFLAGS := -D__STDC_LIMIT_MACROS=1 -Wno-invalid-offsetof LOCAL_EXPORT_CPPFLAGS := -D__STDC_LIMIT_MACROS=1 -Wno-invalid-offsetof include $(PREBUILT_STATIC_LIBRARY) ================================================ FILE: cocos2d/external/spidermonkey/prebuilt/android/armeabi/libjs_static.a ================================================ [File too large to display: 10.5 MB] ================================================ FILE: cocos2d/external/spidermonkey/prebuilt/android/armeabi-v7a/libjs_static.a ================================================ [File too large to display: 10.5 MB] ================================================ FILE: cocos2d/external/spidermonkey/prebuilt/android/x86/libjs_static.a ================================================ [File too large to display: 12.4 MB] ================================================ FILE: cocos2d/external/spidermonkey/prebuilt/ios/libjs_static.a ================================================ [File too large to display: 11.3 MB] ================================================ FILE: cocos2d/external/spidermonkey/prebuilt/mac/libjs_static.a ================================================ [File too large to display: 10.3 MB] ================================================ FILE: cocos2d/external/sqlite3/Android.mk ================================================ ================================================ FILE: cocos2d/external/sqlite3/include/sqlite3.h ================================================ /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. If a C-function, structure, datatype, ** or constant definition does not appear in this file, then it is ** not a published API of SQLite, is subject to change without ** notice, and should not be referenced by programs that use SQLite. ** ** Some of the definitions that are in this file are marked as ** "experimental". Experimental interfaces are normally new ** features recently added to SQLite. We do not anticipate changes ** to experimental interfaces but reserve the right to make minor changes ** if experience from use "in the wild" suggest such changes are prudent. ** ** The official C-language API documentation for SQLite is derived ** from comments in this file. This file is the authoritative source ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. */ #ifdef __cplusplus extern "C" { #endif /* ** Add the ability to override 'extern' */ #ifndef SQLITE_EXTERN # define SQLITE_EXTERN extern #endif #ifndef SQLITE_API # define SQLITE_API #endif /* ** These no-op macros are used in front of interfaces to mark those ** interfaces as either deprecated or experimental. New applications ** should not use deprecated interfaces - they are support for backwards ** compatibility only. Application writers should be aware that ** experimental interfaces are subject to change in point releases. ** ** These macros used to resolve to various kinds of compiler magic that ** would generate warning messages when they were used. But that ** compiler magic ended up generating such a flurry of bug reports ** that we have taken it all out and gone back to using simple ** noop macros. */ #define SQLITE_DEPRECATED #define SQLITE_EXPERIMENTAL /* ** Ensure these symbols were not defined by some previous header file. */ #ifdef SQLITE_VERSION # undef SQLITE_VERSION #endif #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif /* ** CAPI3REF: Compile-Time Library Version Numbers ** ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header ** evaluates to a string literal that is the SQLite version in the ** format "X.Y.Z" where X is the major version number (always 3 for ** SQLite3) and Y is the minor version number and Z is the release number.)^ ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same ** numbers used in [SQLITE_VERSION].)^ ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also ** be larger than the release from which it is derived. Either Y will ** be held constant and Z will be incremented or else Y will be incremented ** and Z will be reset to zero. ** ** Since version 3.6.18, SQLite source code has been stored in the ** Fossil configuration management ** system. ^The SQLITE_SOURCE_ID macro evaluates to ** a string which identifies a particular check-in of SQLite ** within its configuration management system. ^The SQLITE_SOURCE_ID ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.7.15.1" #define SQLITE_VERSION_NUMBER 3007015 #define SQLITE_SOURCE_ID "2012-12-19 20:39:10 6b85b767d0ff7975146156a99ad673f2c1a23318" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version, sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros ** but are associated with the library instead of the header file. ^(Cautious ** programmers might include assert() statements in their application to ** verify that values returned by these interfaces match the macros in ** the header, and thus insure that the application is ** compiled with matching library and header files. ** **
** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
** 
)^ ** ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] ** macro. ^The sqlite3_libversion() function returns a pointer to the ** to the sqlite3_version[] string constant. The sqlite3_libversion() ** function is provided for use in DLLs since DLL users usually do not have ** direct access to string constants within the DLL. ^The ** sqlite3_libversion_number() function returns an integer equal to ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function returns ** a pointer to a string constant whose value is the same as the ** [SQLITE_SOURCE_ID] C preprocessor macro. ** ** See also: [sqlite_version()] and [sqlite_source_id()]. */ SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; SQLITE_API const char *sqlite3_libversion(void); SQLITE_API const char *sqlite3_sourceid(void); SQLITE_API int sqlite3_libversion_number(void); /* ** CAPI3REF: Run-Time Library Compilation Options Diagnostics ** ** ^The sqlite3_compileoption_used() function returns 0 or 1 ** indicating whether the specified option was defined at ** compile time. ^The SQLITE_ prefix may be omitted from the ** option name passed to sqlite3_compileoption_used(). ** ** ^The sqlite3_compileoption_get() function allows iterating ** over the list of options that were defined at compile time by ** returning the N-th compile time option string. ^If N is out of range, ** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_ ** prefix is omitted from any strings returned by ** sqlite3_compileoption_get(). ** ** ^Support for the diagnostic functions sqlite3_compileoption_used() ** and sqlite3_compileoption_get() may be omitted by specifying the ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time. ** ** See also: SQL functions [sqlite_compileoption_used()] and ** [sqlite_compileoption_get()] and the [compile_options pragma]. */ #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS SQLITE_API int sqlite3_compileoption_used(const char *zOptName); SQLITE_API const char *sqlite3_compileoption_get(int N); #endif /* ** CAPI3REF: Test To See If The Library Is Threadsafe ** ** ^The sqlite3_threadsafe() function returns zero if and only if ** SQLite was compiled with mutexing code omitted due to the ** [SQLITE_THREADSAFE] compile-time option being set to 0. ** ** SQLite can be compiled with or without mutexes. When ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes ** are enabled and SQLite is threadsafe. When the ** [SQLITE_THREADSAFE] macro is 0, ** the mutexes are omitted. Without the mutexes, it is not safe ** to use SQLite concurrently from more than one thread. ** ** Enabling mutexes incurs a measurable performance penalty. ** So if speed is of utmost importance, it makes sense to disable ** the mutexes. But for maximum safety, mutexes should be enabled. ** ^The default behavior is for mutexes to be enabled. ** ** This interface can be used by an application to make sure that the ** version of SQLite that it is linking against was compiled with ** the desired setting of the [SQLITE_THREADSAFE] macro. ** ** This interface only reports on the compile-time mutex setting ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but ** can be fully or partially disabled using a call to [sqlite3_config()] ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the ** sqlite3_threadsafe() function shows only the compile-time setting of ** thread safety, not any run-time changes to that setting made by ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() ** is unchanged by calls to sqlite3_config().)^ ** ** See the [threading mode] documentation for additional information. */ SQLITE_API int sqlite3_threadsafe(void); /* ** CAPI3REF: Database Connection Handle ** KEYWORDS: {database connection} {database connections} ** ** Each open SQLite database is represented by a pointer to an instance of ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] ** and [sqlite3_close_v2()] are its destructors. There are many other ** interfaces (such as ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and ** [sqlite3_busy_timeout()] to name but three) that are methods on an ** sqlite3 object. */ typedef struct sqlite3 sqlite3; /* ** CAPI3REF: 64-Bit Integer Types ** KEYWORDS: sqlite_int64 sqlite_uint64 ** ** Because there is no cross-platform way to specify 64-bit integer types ** SQLite includes typedefs for 64-bit signed and unsigned integers. ** ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. ** The sqlite_int64 and sqlite_uint64 types are supported for backwards ** compatibility only. ** ** ^The sqlite3_int64 and sqlite_int64 types can store integer values ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The ** sqlite3_uint64 and sqlite_uint64 types can store integer values ** between 0 and +18446744073709551615 inclusive. */ #ifdef SQLITE_INT64_TYPE typedef SQLITE_INT64_TYPE sqlite_int64; typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; #elif defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 sqlite_int64; typedef unsigned __int64 sqlite_uint64; #else typedef long long int sqlite_int64; typedef unsigned long long int sqlite_uint64; #endif typedef sqlite_int64 sqlite3_int64; typedef sqlite_uint64 sqlite3_uint64; /* ** If compiling for a processor that lacks floating point support, ** substitute integer for floating-point. */ #ifdef SQLITE_OMIT_FLOATING_POINT # define double sqlite3_int64 #endif /* ** CAPI3REF: Closing A Database Connection ** ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors ** for the [sqlite3] object. ** ^Calls to sqlite3_close() and sqlite3_close_v2() return SQLITE_OK if ** the [sqlite3] object is successfully destroyed and all associated ** resources are deallocated. ** ** ^If the database connection is associated with unfinalized prepared ** statements or unfinished sqlite3_backup objects then sqlite3_close() ** will leave the database connection open and return [SQLITE_BUSY]. ** ^If sqlite3_close_v2() is called with unfinalized prepared statements ** and unfinished sqlite3_backups, then the database connection becomes ** an unusable "zombie" which will automatically be deallocated when the ** last prepared statement is finalized or the last sqlite3_backup is ** finished. The sqlite3_close_v2() interface is intended for use with ** host languages that are garbage collected, and where the order in which ** destructors are called is arbitrary. ** ** Applications should [sqlite3_finalize | finalize] all [prepared statements], ** [sqlite3_blob_close | close] all [BLOB handles], and ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated ** with the [sqlite3] object prior to attempting to close the object. ^If ** sqlite3_close() is called on a [database connection] that still has ** outstanding [prepared statements], [BLOB handles], and/or ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation ** of resources is deferred until all [prepared statements], [BLOB handles], ** and [sqlite3_backup] objects are also destroyed. ** ** ^If an [sqlite3] object is destroyed while a transaction is open, ** the transaction is automatically rolled back. ** ** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)] ** must be either a NULL ** pointer or an [sqlite3] object pointer obtained ** from [sqlite3_open()], [sqlite3_open16()], or ** [sqlite3_open_v2()], and not previously closed. ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer ** argument is a harmless no-op. */ SQLITE_API int sqlite3_close(sqlite3*); SQLITE_API int sqlite3_close_v2(sqlite3*); /* ** The type for a callback function. ** This is legacy and deprecated. It is included for historical ** compatibility and is not documented. */ typedef int (*sqlite3_callback)(void*,int,char**, char**); /* ** CAPI3REF: One-Step Query Execution Interface ** ** The sqlite3_exec() interface is a convenience wrapper around ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], ** that allows an application to run multiple statements of SQL ** without having to use a lot of C code. ** ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, ** semicolon-separate SQL statements passed into its 2nd argument, ** in the context of the [database connection] passed in as its 1st ** argument. ^If the callback function of the 3rd argument to ** sqlite3_exec() is not NULL, then it is invoked for each result row ** coming out of the evaluated SQL statements. ^The 4th argument to ** sqlite3_exec() is relayed through to the 1st argument of each ** callback invocation. ^If the callback pointer to sqlite3_exec() ** is NULL, then no callback is ever invoked and result rows are ** ignored. ** ** ^If an error occurs while evaluating the SQL statements passed into ** sqlite3_exec(), then execution of the current statement stops and ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() ** is not NULL then any error message is written into memory obtained ** from [sqlite3_malloc()] and passed back through the 5th parameter. ** To avoid memory leaks, the application should invoke [sqlite3_free()] ** on error message strings returned through the 5th parameter of ** of sqlite3_exec() after the error message string is no longer needed. ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to ** NULL before returning. ** ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() ** routine returns SQLITE_ABORT without invoking the callback again and ** without running any subsequent SQL statements. ** ** ^The 2nd argument to the sqlite3_exec() callback function is the ** number of columns in the result. ^The 3rd argument to the sqlite3_exec() ** callback is an array of pointers to strings obtained as if from ** [sqlite3_column_text()], one for each column. ^If an element of a ** result row is NULL then the corresponding string pointer for the ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the ** sqlite3_exec() callback is an array of pointers to strings where each ** entry represents the name of corresponding result column as obtained ** from [sqlite3_column_name()]. ** ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer ** to an empty string, or a pointer that contains only whitespace and/or ** SQL comments, then no SQL statements are evaluated and the database ** is not changed. ** ** Restrictions: ** **
    **
  • The application must insure that the 1st parameter to sqlite3_exec() ** is a valid and open [database connection]. **
  • The application must not close [database connection] specified by ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. **
  • The application must not modify the SQL statement text passed into ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. **
*/ SQLITE_API int sqlite3_exec( sqlite3*, /* An open database */ const char *sql, /* SQL to be evaluated */ int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); /* ** CAPI3REF: Result Codes ** KEYWORDS: SQLITE_OK {error code} {error codes} ** KEYWORDS: {result code} {result codes} ** ** Many SQLite functions return an integer result code from the set shown ** here in order to indicate success or failure. ** ** New error codes may be added in future versions of SQLite. ** ** See also: [SQLITE_IOERR_READ | extended result codes], ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes]. */ #define SQLITE_OK 0 /* Successful result */ /* beginning-of-error-codes */ #define SQLITE_ERROR 1 /* SQL error or missing database */ #define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ #define SQLITE_PERM 3 /* Access permission denied */ #define SQLITE_ABORT 4 /* Callback routine requested an abort */ #define SQLITE_BUSY 5 /* The database file is locked */ #define SQLITE_LOCKED 6 /* A table in the database is locked */ #define SQLITE_NOMEM 7 /* A malloc() failed */ #define SQLITE_READONLY 8 /* Attempt to write a readonly database */ #define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ #define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ #define SQLITE_CORRUPT 11 /* The database disk image is malformed */ #define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */ #define SQLITE_FULL 13 /* Insertion failed because database is full */ #define SQLITE_CANTOPEN 14 /* Unable to open the database file */ #define SQLITE_PROTOCOL 15 /* Database lock protocol error */ #define SQLITE_EMPTY 16 /* Database is empty */ #define SQLITE_SCHEMA 17 /* The database schema changed */ #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ #define SQLITE_MISMATCH 20 /* Data type mismatch */ #define SQLITE_MISUSE 21 /* Library used incorrectly */ #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ #define SQLITE_AUTH 23 /* Authorization denied */ #define SQLITE_FORMAT 24 /* Auxiliary database format error */ #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ #define SQLITE_NOTADB 26 /* File opened that is not a database file */ #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ /* end-of-error-codes */ /* ** CAPI3REF: Extended Result Codes ** KEYWORDS: {extended error code} {extended error codes} ** KEYWORDS: {extended result code} {extended result codes} ** ** In its default configuration, SQLite API routines return one of 26 integer ** [SQLITE_OK | result codes]. However, experience has shown that many of ** these result codes are too coarse-grained. They do not provide as ** much information about problems as programmers might like. In an effort to ** address this, newer versions of SQLite (version 3.3.8 and later) include ** support for additional result codes that provide more detailed information ** about errors. The extended result codes are enabled or disabled ** on a per database connection basis using the ** [sqlite3_extended_result_codes()] API. ** ** Some of the available extended result codes are listed here. ** One may expect the number of extended result codes will be expand ** over time. Software that uses extended result codes should expect ** to see new result codes in future releases of SQLite. ** ** The SQLITE_OK result code will never be extended. It will always ** be exactly zero. */ #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) #define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) #define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) #define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) #define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) #define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) #define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) #define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) #define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) #define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8)) /* ** CAPI3REF: Flags For File Open Operations ** ** These bit values are intended for use in the ** 3rd parameter to the [sqlite3_open_v2()] interface and ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. */ #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ #define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ #define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ #define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ #define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ #define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ #define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ #define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ #define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ #define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ #define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ /* Reserved: 0x00F00000 */ /* ** CAPI3REF: Device Characteristics ** ** The xDeviceCharacteristics method of the [sqlite3_io_methods] ** object returns an integer which is a vector of these ** bit values expressing I/O characteristics of the mass storage ** device that holds the file that the [sqlite3_io_methods] ** refers to. ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values ** mean that writes of blocks that are nnn bytes in size and ** are aligned to an address which is an integer multiple of ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means ** that when data is appended to a file, the data is appended ** first then the size of the file is extended, never the other ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that ** information is written to disk in the same order as calls ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that ** after reboot following a crash or power loss, the only bytes in a ** file that were written at the application level might have changed ** and that adjacent bytes, even bytes within the same sector are ** guaranteed to be unchanged. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 #define SQLITE_IOCAP_ATOMIC1K 0x00000004 #define SQLITE_IOCAP_ATOMIC2K 0x00000008 #define SQLITE_IOCAP_ATOMIC4K 0x00000010 #define SQLITE_IOCAP_ATOMIC8K 0x00000020 #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 /* ** CAPI3REF: File Locking Levels ** ** SQLite uses one of these integer values as the second ** argument to calls it makes to the xLock() and xUnlock() methods ** of an [sqlite3_io_methods] object. */ #define SQLITE_LOCK_NONE 0 #define SQLITE_LOCK_SHARED 1 #define SQLITE_LOCK_RESERVED 2 #define SQLITE_LOCK_PENDING 3 #define SQLITE_LOCK_EXCLUSIVE 4 /* ** CAPI3REF: Synchronization Type Flags ** ** When SQLite invokes the xSync() method of an ** [sqlite3_io_methods] object it uses a combination of ** these integer values as the second argument. ** ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the ** sync operation only needs to flush data to mass storage. Inode ** information need not be flushed. If the lower four bits of the flag ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. ** If the lower four bits equal SQLITE_SYNC_FULL, that means ** to use Mac OS X style fullsync instead of fsync(). ** ** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags ** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL ** settings. The [synchronous pragma] determines when calls to the ** xSync VFS method occur and applies uniformly across all platforms. ** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how ** energetic or rigorous or forceful the sync operations are and ** only make a difference on Mac OSX for the default SQLite code. ** (Third-party VFS implementations might also make the distinction ** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the ** operating systems natively supported by SQLite, only Mac OSX ** cares about the difference.) */ #define SQLITE_SYNC_NORMAL 0x00002 #define SQLITE_SYNC_FULL 0x00003 #define SQLITE_SYNC_DATAONLY 0x00010 /* ** CAPI3REF: OS Interface Open File Handle ** ** An [sqlite3_file] object represents an open file in the ** [sqlite3_vfs | OS interface layer]. Individual OS interface ** implementations will ** want to subclass this object by appending additional fields ** for their own use. The pMethods entry is a pointer to an ** [sqlite3_io_methods] object that defines methods for performing ** I/O operations on the open file. */ typedef struct sqlite3_file sqlite3_file; struct sqlite3_file { const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ }; /* ** CAPI3REF: OS Interface File Virtual Methods Object ** ** Every file opened by the [sqlite3_vfs.xOpen] method populates an ** [sqlite3_file] object (or, more commonly, a subclass of the ** [sqlite3_file] object) with a pointer to an instance of this object. ** This object defines the methods used to perform various operations ** against the open file represented by the [sqlite3_file] object. ** ** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method ** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The ** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen] ** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element ** to NULL. ** ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or ** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). ** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] ** flag may be ORed in to indicate that only the data of the file ** and not its inode needs to be synced. ** ** The integer values to xLock() and xUnlock() are one of **
    **
  • [SQLITE_LOCK_NONE], **
  • [SQLITE_LOCK_SHARED], **
  • [SQLITE_LOCK_RESERVED], **
  • [SQLITE_LOCK_PENDING], or **
  • [SQLITE_LOCK_EXCLUSIVE]. **
** xLock() increases the lock. xUnlock() decreases the lock. ** The xCheckReservedLock() method checks whether any database connection, ** either in this process or in some other process, is holding a RESERVED, ** PENDING, or EXCLUSIVE lock on the file. It returns true ** if such a lock exists and false otherwise. ** ** The xFileControl() method is a generic interface that allows custom ** VFS implementations to directly control an open file using the ** [sqlite3_file_control()] interface. The second "op" argument is an ** integer opcode. The third argument is a generic pointer intended to ** point to a structure that may contain arguments or space in which to ** write return values. Potential uses for xFileControl() might be ** functions to enable blocking locks with timeouts, to change the ** locking strategy (for example to use dot-file locks), to inquire ** about the status of a lock, or to break stale locks. The SQLite ** core reserves all opcodes less than 100 for its own use. ** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available. ** Applications that define a custom xFileControl method should use opcodes ** greater than 100 to avoid conflicts. VFS implementations should ** return [SQLITE_NOTFOUND] for file control opcodes that they do not ** recognize. ** ** The xSectorSize() method returns the sector size of the ** device that underlies the file. The sector size is the ** minimum write that can be performed without disturbing ** other bytes in the file. The xDeviceCharacteristics() ** method returns a bit vector describing behaviors of the ** underlying device: ** **
    **
  • [SQLITE_IOCAP_ATOMIC] **
  • [SQLITE_IOCAP_ATOMIC512] **
  • [SQLITE_IOCAP_ATOMIC1K] **
  • [SQLITE_IOCAP_ATOMIC2K] **
  • [SQLITE_IOCAP_ATOMIC4K] **
  • [SQLITE_IOCAP_ATOMIC8K] **
  • [SQLITE_IOCAP_ATOMIC16K] **
  • [SQLITE_IOCAP_ATOMIC32K] **
  • [SQLITE_IOCAP_ATOMIC64K] **
  • [SQLITE_IOCAP_SAFE_APPEND] **
  • [SQLITE_IOCAP_SEQUENTIAL] **
** ** The SQLITE_IOCAP_ATOMIC property means that all writes of ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values ** mean that writes of blocks that are nnn bytes in size and ** are aligned to an address which is an integer multiple of ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means ** that when data is appended to a file, the data is appended ** first then the size of the file is extended, never the other ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that ** information is written to disk in the same order as calls ** to xWrite(). ** ** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill ** in the unread portions of the buffer with zeros. A VFS that ** fails to zero-fill short reads might seem to work. However, ** failure to zero-fill short reads will eventually lead to ** database corruption. */ typedef struct sqlite3_io_methods sqlite3_io_methods; struct sqlite3_io_methods { int iVersion; int (*xClose)(sqlite3_file*); int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); int (*xSync)(sqlite3_file*, int flags); int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); int (*xLock)(sqlite3_file*, int); int (*xUnlock)(sqlite3_file*, int); int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); int (*xFileControl)(sqlite3_file*, int op, void *pArg); int (*xSectorSize)(sqlite3_file*); int (*xDeviceCharacteristics)(sqlite3_file*); /* Methods above are valid for version 1 */ int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**); int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); void (*xShmBarrier)(sqlite3_file*); int (*xShmUnmap)(sqlite3_file*, int deleteFlag); /* Methods above are valid for version 2 */ /* Additional methods may be added in future releases */ }; /* ** CAPI3REF: Standard File Control Opcodes ** ** These integer constants are opcodes for the xFileControl method ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] ** interface. ** ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This ** opcode causes the xFileControl method to write the current state of ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) ** into an integer that the pArg argument points to. This capability ** is used during testing and only needs to be supported when SQLITE_TEST ** is defined. **
    **
  • [[SQLITE_FCNTL_SIZE_HINT]] ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS ** layer a hint of how large the database file will grow to be during the ** current transaction. This hint is not guaranteed to be accurate but it ** is often close. The underlying VFS might choose to preallocate database ** file space based on this hint in order to help writes to the database ** file run faster. ** **
  • [[SQLITE_FCNTL_CHUNK_SIZE]] ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS ** extends and truncates the database file in chunks of a size specified ** by the user. The fourth argument to [sqlite3_file_control()] should ** point to an integer (type int) containing the new chunk-size to use ** for the nominated database. Allocating database file space in large ** chunks (say 1MB at a time), may reduce file-system fragmentation and ** improve performance on some systems. ** **
  • [[SQLITE_FCNTL_FILE_POINTER]] ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer ** to the [sqlite3_file] object associated with a particular database ** connection. See the [sqlite3_file_control()] documentation for ** additional information. ** **
  • [[SQLITE_FCNTL_SYNC_OMITTED]] ** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by ** SQLite and sent to all VFSes in place of a call to the xSync method ** when the database connection has [PRAGMA synchronous] set to OFF.)^ ** Some specialized VFSes need this signal in order to operate correctly ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most ** VFSes do not need this signal and should silently ignore this opcode. ** Applications should not call [sqlite3_file_control()] with this ** opcode as doing so may disrupt the operation of the specialized VFSes ** that do require it. ** **
  • [[SQLITE_FCNTL_WIN32_AV_RETRY]] ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic ** retry counts and intervals for certain disk I/O operations for the ** windows [VFS] in order to provide robustness in the presence of ** anti-virus programs. By default, the windows VFS will retry file read, ** file write, and file delete operations up to 10 times, with a delay ** of 25 milliseconds before the first retry and with the delay increasing ** by an additional 25 milliseconds with each subsequent retry. This ** opcode allows these two values (10 retries and 25 milliseconds of delay) ** to be adjusted. The values are changed for all database connections ** within the same process. The argument is a pointer to an array of two ** integers where the first integer i the new retry count and the second ** integer is the delay. If either integer is negative, then the setting ** is not changed but instead the prior value of that setting is written ** into the array entry, allowing the current retry settings to be ** interrogated. The zDbName parameter is ignored. ** **
  • [[SQLITE_FCNTL_PERSIST_WAL]] ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the ** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary ** write ahead log and shared memory files used for transaction control ** are automatically deleted when the latest connection to the database ** closes. Setting persistent WAL mode causes those files to persist after ** close. Persisting the files is useful when other processes that do not ** have write permission on the directory containing the database file want ** to read the database file, as the WAL and shared memory files must exist ** in order for the database to be readable. The fourth parameter to ** [sqlite3_file_control()] for this opcode should be a pointer to an integer. ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent ** WAL mode. If the integer is -1, then it is overwritten with the current ** WAL persistence setting. ** **
  • [[SQLITE_FCNTL_POWERSAFE_OVERWRITE]] ** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the ** persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting ** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the ** xDeviceCharacteristics methods. The fourth parameter to ** [sqlite3_file_control()] for this opcode should be a pointer to an integer. ** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage ** mode. If the integer is -1, then it is overwritten with the current ** zero-damage mode setting. ** **
  • [[SQLITE_FCNTL_OVERWRITE]] ** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening ** a write transaction to indicate that, unless it is rolled back for some ** reason, the entire database file will be overwritten by the current ** transaction. This is used by VACUUM operations. ** **
  • [[SQLITE_FCNTL_VFSNAME]] ** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of ** all [VFSes] in the VFS stack. The names are of all VFS shims and the ** final bottom-level VFS are written into memory obtained from ** [sqlite3_malloc()] and the result is stored in the char* variable ** that the fourth parameter of [sqlite3_file_control()] points to. ** The caller is responsible for freeing the memory when done. As with ** all file-control actions, there is no guarantee that this will actually ** do anything. Callers should initialize the char* variable to a NULL ** pointer in case this file-control is not implemented. This file-control ** is intended for diagnostic use only. ** **
  • [[SQLITE_FCNTL_PRAGMA]] ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] ** file control is sent to the open [sqlite3_file] object corresponding ** to the database file to which the pragma statement refers. ^The argument ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of ** pointers to strings (char**) in which the second element of the array ** is the name of the pragma and the third element is the argument to the ** pragma or NULL if the pragma has no argument. ^The handler for an ** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element ** of the char** argument point to a string obtained from [sqlite3_mprintf()] ** or the equivalent and that string will become the result of the pragma or ** the error message if the pragma fails. ^If the ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] ** file control returns [SQLITE_OK], then the parser assumes that the ** VFS has handled the PRAGMA itself and the parser generates a no-op ** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means ** that the VFS encountered an error while handling the [PRAGMA] and the ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] ** file control occurs at the beginning of pragma statement analysis and so ** it is able to override built-in [PRAGMA] statements. ** **
  • [[SQLITE_FCNTL_BUSYHANDLER]] ** ^This file-control may be invoked by SQLite on the database file handle ** shortly after it is opened in order to provide a custom VFS with access ** to the connections busy-handler callback. The argument is of type (void **) ** - an array of two (void *) values. The first (void *) actually points ** to a function of type (int (*)(void *)). In order to invoke the connections ** busy-handler, this function should be invoked with the second (void *) in ** the array as the only argument. If it returns non-zero, then the operation ** should be retried. If it returns zero, the custom VFS should abandon the ** current operation. ** **
  • [[SQLITE_FCNTL_TEMPFILENAME]] ** ^Application can invoke this file-control to have SQLite generate a ** temporary filename using the same algorithm that is followed to generate ** temporary filenames for TEMP tables and other internal uses. The ** argument should be a char** which will be filled with the filename ** written into memory obtained from [sqlite3_malloc()]. The caller should ** invoke [sqlite3_free()] on the result to avoid a memory leak. ** **
*/ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_GET_LOCKPROXYFILE 2 #define SQLITE_SET_LOCKPROXYFILE 3 #define SQLITE_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 #define SQLITE_FCNTL_CHUNK_SIZE 6 #define SQLITE_FCNTL_FILE_POINTER 7 #define SQLITE_FCNTL_SYNC_OMITTED 8 #define SQLITE_FCNTL_WIN32_AV_RETRY 9 #define SQLITE_FCNTL_PERSIST_WAL 10 #define SQLITE_FCNTL_OVERWRITE 11 #define SQLITE_FCNTL_VFSNAME 12 #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13 #define SQLITE_FCNTL_PRAGMA 14 #define SQLITE_FCNTL_BUSYHANDLER 15 #define SQLITE_FCNTL_TEMPFILENAME 16 /* ** CAPI3REF: Mutex Handle ** ** The mutex module within SQLite defines [sqlite3_mutex] to be an ** abstract type for a mutex object. The SQLite core never looks ** at the internal representation of an [sqlite3_mutex]. It only ** deals with pointers to the [sqlite3_mutex] object. ** ** Mutexes are created using [sqlite3_mutex_alloc()]. */ typedef struct sqlite3_mutex sqlite3_mutex; /* ** CAPI3REF: OS Interface Object ** ** An instance of the sqlite3_vfs object defines the interface between ** the SQLite core and the underlying operating system. The "vfs" ** in the name of the object stands for "virtual file system". See ** the [VFS | VFS documentation] for further information. ** ** The value of the iVersion field is initially 1 but may be larger in ** future versions of SQLite. Additional fields may be appended to this ** object when the iVersion value is increased. Note that the structure ** of the sqlite3_vfs object changes in the transaction between ** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not ** modified. ** ** The szOsFile field is the size of the subclassed [sqlite3_file] ** structure used by this VFS. mxPathname is the maximum length of ** a pathname in this VFS. ** ** Registered sqlite3_vfs objects are kept on a linked list formed by ** the pNext pointer. The [sqlite3_vfs_register()] ** and [sqlite3_vfs_unregister()] interfaces manage this list ** in a thread-safe way. The [sqlite3_vfs_find()] interface ** searches the list. Neither the application code nor the VFS ** implementation should use the pNext pointer. ** ** The pNext field is the only field in the sqlite3_vfs ** structure that SQLite will ever modify. SQLite will only access ** or modify this field while holding a particular static mutex. ** The application should never modify anything within the sqlite3_vfs ** object once the object has been registered. ** ** The zName field holds the name of the VFS module. The name must ** be unique across all VFS modules. ** ** [[sqlite3_vfs.xOpen]] ** ^SQLite guarantees that the zFilename parameter to xOpen ** is either a NULL pointer or string obtained ** from xFullPathname() with an optional suffix added. ** ^If a suffix is added to the zFilename parameter, it will ** consist of a single "-" character followed by no more than ** 11 alphanumeric and/or "-" characters. ** ^SQLite further guarantees that ** the string will be valid and unchanged until xClose() is ** called. Because of the previous sentence, ** the [sqlite3_file] can safely store a pointer to the ** filename if it needs to remember the filename for some reason. ** If the zFilename parameter to xOpen is a NULL pointer then xOpen ** must invent its own temporary name for the file. ^Whenever the ** xFilename parameter is NULL it will also be the case that the ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. ** ** The flags argument to xOpen() includes all bits set in ** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] ** or [sqlite3_open16()] is used, then flags includes at least ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. ** If xOpen() opens a file read-only then it sets *pOutFlags to ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. ** ** ^(SQLite will also add one of the following flags to the xOpen() ** call, depending on the object being opened: ** **
    **
  • [SQLITE_OPEN_MAIN_DB] **
  • [SQLITE_OPEN_MAIN_JOURNAL] **
  • [SQLITE_OPEN_TEMP_DB] **
  • [SQLITE_OPEN_TEMP_JOURNAL] **
  • [SQLITE_OPEN_TRANSIENT_DB] **
  • [SQLITE_OPEN_SUBJOURNAL] **
  • [SQLITE_OPEN_MASTER_JOURNAL] **
  • [SQLITE_OPEN_WAL] **
)^ ** ** The file I/O implementation can use the object type flags to ** change the way it deals with files. For example, an application ** that does not care about crash recovery or rollback might make ** the open of a journal file a no-op. Writes to this journal would ** also be no-ops, and any attempt to read the journal would return ** SQLITE_IOERR. Or the implementation might recognize that a database ** file will be doing page-aligned sector reads and writes in a random ** order and set up its I/O subsystem accordingly. ** ** SQLite might also add one of the following flags to the xOpen method: ** **
    **
  • [SQLITE_OPEN_DELETEONCLOSE] **
  • [SQLITE_OPEN_EXCLUSIVE] **
** ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] ** will be set for TEMP databases and their journals, transient ** databases, and subjournals. ** ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction ** with the [SQLITE_OPEN_CREATE] flag, which are both directly ** analogous to the O_EXCL and O_CREAT flags of the POSIX open() ** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the ** SQLITE_OPEN_CREATE, is used to indicate that file should always ** be created, and that it is an error if it already exists. ** It is not used to indicate the file should be opened ** for exclusive access. ** ** ^At least szOsFile bytes of memory are allocated by SQLite ** to hold the [sqlite3_file] structure passed as the third ** argument to xOpen. The xOpen method does not have to ** allocate the structure; it should just fill it in. Note that ** the xOpen method must set the sqlite3_file.pMethods to either ** a valid [sqlite3_io_methods] object or to NULL. xOpen must do ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods ** element will be valid after xOpen returns regardless of the success ** or failure of the xOpen call. ** ** [[sqlite3_vfs.xAccess]] ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] ** to test whether a file is at least readable. The file can be a ** directory. ** ** ^SQLite will always allocate at least mxPathname+1 bytes for the ** output buffer xFullPathname. The exact size of the output buffer ** is also passed as a parameter to both methods. If the output buffer ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is ** handled as a fatal error by SQLite, vfs implementations should endeavor ** to prevent this by setting mxPathname to a sufficiently large value. ** ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() ** interfaces are not strictly a part of the filesystem, but they are ** included in the VFS structure for completeness. ** The xRandomness() function attempts to return nBytes bytes ** of good-quality randomness into zOut. The return value is ** the actual number of bytes of randomness obtained. ** The xSleep() method causes the calling thread to sleep for at ** least the number of microseconds given. ^The xCurrentTime() ** method returns a Julian Day Number for the current date and time as ** a floating point value. ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian ** Day Number multiplied by 86400000 (the number of milliseconds in ** a 24-hour day). ** ^SQLite will use the xCurrentTimeInt64() method to get the current ** date and time if that method is available (if iVersion is 2 or ** greater and the function pointer is not NULL) and will fall back ** to xCurrentTime() if xCurrentTimeInt64() is unavailable. ** ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces ** are not used by the SQLite core. These optional interfaces are provided ** by some VFSes to facilitate testing of the VFS code. By overriding ** system calls with functions under its control, a test program can ** simulate faults and error conditions that would otherwise be difficult ** or impossible to induce. The set of system calls that can be overridden ** varies from one VFS to another, and from one version of the same VFS to the ** next. Applications that use these interfaces must be prepared for any ** or all of these interfaces to be NULL or for their behavior to change ** from one release to the next. Applications must not attempt to access ** any of these methods if the iVersion of the VFS is less than 3. */ typedef struct sqlite3_vfs sqlite3_vfs; typedef void (*sqlite3_syscall_ptr)(void); struct sqlite3_vfs { int iVersion; /* Structure version number (currently 3) */ int szOsFile; /* Size of subclassed sqlite3_file */ int mxPathname; /* Maximum file pathname length */ sqlite3_vfs *pNext; /* Next registered VFS */ const char *zName; /* Name of this virtual file system */ void *pAppData; /* Pointer to application-specific data */ int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, int flags, int *pOutFlags); int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); void (*xDlClose)(sqlite3_vfs*, void*); int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); int (*xSleep)(sqlite3_vfs*, int microseconds); int (*xCurrentTime)(sqlite3_vfs*, double*); int (*xGetLastError)(sqlite3_vfs*, int, char *); /* ** The methods above are in version 1 of the sqlite_vfs object ** definition. Those that follow are added in version 2 or later */ int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*); /* ** The methods above are in versions 1 and 2 of the sqlite_vfs object. ** Those below are for version 3 and greater. */ int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr); sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName); const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName); /* ** The methods above are in versions 1 through 3 of the sqlite_vfs object. ** New fields may be appended in figure versions. The iVersion ** value will increment whenever this happens. */ }; /* ** CAPI3REF: Flags for the xAccess VFS method ** ** These integer constants can be used as the third parameter to ** the xAccess method of an [sqlite3_vfs] object. They determine ** what kind of permissions the xAccess method is looking for. ** With SQLITE_ACCESS_EXISTS, the xAccess method ** simply checks whether the file exists. ** With SQLITE_ACCESS_READWRITE, the xAccess method ** checks whether the named directory is both readable and writable ** (in other words, if files can be added, removed, and renamed within ** the directory). ** The SQLITE_ACCESS_READWRITE constant is currently used only by the ** [temp_store_directory pragma], though this could change in a future ** release of SQLite. ** With SQLITE_ACCESS_READ, the xAccess method ** checks whether the file is readable. The SQLITE_ACCESS_READ constant is ** currently unused, though it might be used in a future release of ** SQLite. */ #define SQLITE_ACCESS_EXISTS 0 #define SQLITE_ACCESS_READWRITE 1 /* Used by PRAGMA temp_store_directory */ #define SQLITE_ACCESS_READ 2 /* Unused */ /* ** CAPI3REF: Flags for the xShmLock VFS method ** ** These integer constants define the various locking operations ** allowed by the xShmLock method of [sqlite3_io_methods]. The ** following are the only legal combinations of flags to the ** xShmLock method: ** **
    **
  • SQLITE_SHM_LOCK | SQLITE_SHM_SHARED **
  • SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED **
  • SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE **
** ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as ** was given no the corresponding lock. ** ** The xShmLock method can transition between unlocked and SHARED or ** between unlocked and EXCLUSIVE. It cannot transition between SHARED ** and EXCLUSIVE. */ #define SQLITE_SHM_UNLOCK 1 #define SQLITE_SHM_LOCK 2 #define SQLITE_SHM_SHARED 4 #define SQLITE_SHM_EXCLUSIVE 8 /* ** CAPI3REF: Maximum xShmLock index ** ** The xShmLock method on [sqlite3_io_methods] may use values ** between 0 and this upper bound as its "offset" argument. ** The SQLite core will never attempt to acquire or release a ** lock outside of this range */ #define SQLITE_SHM_NLOCK 8 /* ** CAPI3REF: Initialize The SQLite Library ** ** ^The sqlite3_initialize() routine initializes the ** SQLite library. ^The sqlite3_shutdown() routine ** deallocates any resources that were allocated by sqlite3_initialize(). ** These routines are designed to aid in process initialization and ** shutdown on embedded systems. Workstation applications using ** SQLite normally do not need to invoke either of these routines. ** ** A call to sqlite3_initialize() is an "effective" call if it is ** the first time sqlite3_initialize() is invoked during the lifetime of ** the process, or if it is the first time sqlite3_initialize() is invoked ** following a call to sqlite3_shutdown(). ^(Only an effective call ** of sqlite3_initialize() does any initialization. All other calls ** are harmless no-ops.)^ ** ** A call to sqlite3_shutdown() is an "effective" call if it is the first ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only ** an effective call to sqlite3_shutdown() does any deinitialization. ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ ** ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() ** is not. The sqlite3_shutdown() interface must only be called from a ** single thread. All open [database connections] must be closed and all ** other SQLite resources must be deallocated prior to invoking ** sqlite3_shutdown(). ** ** Among other things, ^sqlite3_initialize() will invoke ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown() ** will invoke sqlite3_os_end(). ** ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. ** ^If for some reason, sqlite3_initialize() is unable to initialize ** the library (perhaps it is unable to allocate a needed resource such ** as a mutex) it returns an [error code] other than [SQLITE_OK]. ** ** ^The sqlite3_initialize() routine is called internally by many other ** SQLite interfaces so that an application usually does not need to ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] ** calls sqlite3_initialize() so the SQLite library will be automatically ** initialized when [sqlite3_open()] is called if it has not be initialized ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] ** compile-time option, then the automatic calls to sqlite3_initialize() ** are omitted and the application must call sqlite3_initialize() directly ** prior to using any other SQLite interface. For maximum portability, ** it is recommended that applications always invoke sqlite3_initialize() ** directly prior to using any other SQLite interface. Future releases ** of SQLite may require this. In other words, the behavior exhibited ** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the ** default behavior in some future release of SQLite. ** ** The sqlite3_os_init() routine does operating-system specific ** initialization of the SQLite library. The sqlite3_os_end() ** routine undoes the effect of sqlite3_os_init(). Typical tasks ** performed by these routines include allocation or deallocation ** of static resources, initialization of global variables, ** setting up a default [sqlite3_vfs] module, or setting up ** a default configuration using [sqlite3_config()]. ** ** The application should never invoke either sqlite3_os_init() ** or sqlite3_os_end() directly. The application should only invoke ** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() ** interface is called automatically by sqlite3_initialize() and ** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate ** implementations for sqlite3_os_init() and sqlite3_os_end() ** are built into SQLite when it is compiled for Unix, Windows, or OS/2. ** When [custom builds | built for other platforms] ** (using the [SQLITE_OS_OTHER=1] compile-time ** option) the application must supply a suitable implementation for ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied ** implementation of sqlite3_os_init() or sqlite3_os_end() ** must return [SQLITE_OK] on success and some other [error code] upon ** failure. */ SQLITE_API int sqlite3_initialize(void); SQLITE_API int sqlite3_shutdown(void); SQLITE_API int sqlite3_os_init(void); SQLITE_API int sqlite3_os_end(void); /* ** CAPI3REF: Configuring The SQLite Library ** ** The sqlite3_config() interface is used to make global configuration ** changes to SQLite in order to tune SQLite to the specific needs of ** the application. The default configuration is recommended for most ** applications and so this routine is usually not necessary. It is ** provided to support rare applications with unusual needs. ** ** The sqlite3_config() interface is not threadsafe. The application ** must insure that no other SQLite interfaces are invoked by other ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() ** may only be invoked prior to library initialization using ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE. ** Note, however, that ^sqlite3_config() can be called as part of the ** implementation of an application-defined [sqlite3_os_init()]. ** ** The first argument to sqlite3_config() is an integer ** [configuration option] that determines ** what property of SQLite is to be configured. Subsequent arguments ** vary depending on the [configuration option] ** in the first argument. ** ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. ** ^If the option is unknown or SQLite is unable to set the option ** then this routine returns a non-zero [error code]. */ SQLITE_API int sqlite3_config(int, ...); /* ** CAPI3REF: Configure database connections ** ** The sqlite3_db_config() interface is used to make configuration ** changes to a [database connection]. The interface is similar to ** [sqlite3_config()] except that the changes apply to a single ** [database connection] (specified in the first argument). ** ** The second argument to sqlite3_db_config(D,V,...) is the ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code ** that indicates what aspect of the [database connection] is being configured. ** Subsequent arguments vary depending on the configuration verb. ** ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if ** the call is considered successful. */ SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); /* ** CAPI3REF: Memory Allocation Routines ** ** An instance of this object defines the interface between SQLite ** and low-level memory allocation routines. ** ** This object is used in only one place in the SQLite interface. ** A pointer to an instance of this object is the argument to ** [sqlite3_config()] when the configuration option is ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. ** By creating an instance of this object ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) ** during configuration, an application can specify an alternative ** memory allocation subsystem for SQLite to use for all of its ** dynamic memory needs. ** ** Note that SQLite comes with several [built-in memory allocators] ** that are perfectly adequate for the overwhelming majority of applications ** and that this object is only useful to a tiny minority of applications ** with specialized memory allocation requirements. This object is ** also used during testing of SQLite in order to specify an alternative ** memory allocator that simulates memory out-of-memory conditions in ** order to verify that SQLite recovers gracefully from such ** conditions. ** ** The xMalloc, xRealloc, and xFree methods must work like the ** malloc(), realloc() and free() functions from the standard C library. ** ^SQLite guarantees that the second argument to ** xRealloc is always a value returned by a prior call to xRoundup. ** ** xSize should return the allocated size of a memory allocation ** previously obtained from xMalloc or xRealloc. The allocated size ** is always at least as big as the requested size but may be larger. ** ** The xRoundup method returns what would be the allocated size of ** a memory allocation given a particular requested size. Most memory ** allocators round up memory allocations at least to the next multiple ** of 8. Some allocators round up to a larger multiple or to a power of 2. ** Every memory allocation request coming in through [sqlite3_malloc()] ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, ** that causes the corresponding memory allocation to fail. ** ** The xInit method initializes the memory allocator. (For example, ** it might allocate any require mutexes or initialize internal data ** structures. The xShutdown method is invoked (indirectly) by ** [sqlite3_shutdown()] and should deallocate any resources acquired ** by xInit. The pAppData pointer is used as the only parameter to ** xInit and xShutdown. ** ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes ** the xInit method, so the xInit method need not be threadsafe. The ** xShutdown method is only called from [sqlite3_shutdown()] so it does ** not need to be threadsafe either. For all other methods, SQLite ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which ** it is by default) and so the methods are automatically serialized. ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other ** methods must be threadsafe or else make their own arrangements for ** serialization. ** ** SQLite will never invoke xInit() more than once without an intervening ** call to xShutdown(). */ typedef struct sqlite3_mem_methods sqlite3_mem_methods; struct sqlite3_mem_methods { void *(*xMalloc)(int); /* Memory allocation function */ void (*xFree)(void*); /* Free a prior allocation */ void *(*xRealloc)(void*,int); /* Resize an allocation */ int (*xSize)(void*); /* Return the size of an allocation */ int (*xRoundup)(int); /* Round up request size to allocation size */ int (*xInit)(void*); /* Initialize the memory allocator */ void (*xShutdown)(void*); /* Deinitialize the memory allocator */ void *pAppData; /* Argument to xInit() and xShutdown() */ }; /* ** CAPI3REF: Configuration Options ** KEYWORDS: {configuration option} ** ** These constants are the available integer configuration options that ** can be passed as the first argument to the [sqlite3_config()] interface. ** ** New configuration options may be added in future releases of SQLite. ** Existing configuration options might be discontinued. Applications ** should check the return code from [sqlite3_config()] to make sure that ** the call worked. The [sqlite3_config()] interface will return a ** non-zero [error code] if a discontinued or unsupported configuration option ** is invoked. ** **
** [[SQLITE_CONFIG_SINGLETHREAD]]
SQLITE_CONFIG_SINGLETHREAD
**
There are no arguments to this option. ^This option sets the ** [threading mode] to Single-thread. In other words, it disables ** all mutexing and puts SQLite into a mode where it can only be used ** by a single thread. ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** it is not possible to change the [threading mode] from its default ** value of Single-thread and so [sqlite3_config()] will return ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD ** configuration option.
** ** [[SQLITE_CONFIG_MULTITHREAD]]
SQLITE_CONFIG_MULTITHREAD
**
There are no arguments to this option. ^This option sets the ** [threading mode] to Multi-thread. In other words, it disables ** mutexing on [database connection] and [prepared statement] objects. ** The application is responsible for serializing access to ** [database connections] and [prepared statements]. But other mutexes ** are enabled so that SQLite will be safe to use in a multi-threaded ** environment as long as no two threads attempt to use the same ** [database connection] at the same time. ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** it is not possible to set the Multi-thread [threading mode] and ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the ** SQLITE_CONFIG_MULTITHREAD configuration option.
** ** [[SQLITE_CONFIG_SERIALIZED]]
SQLITE_CONFIG_SERIALIZED
**
There are no arguments to this option. ^This option sets the ** [threading mode] to Serialized. In other words, this option enables ** all mutexes including the recursive ** mutexes on [database connection] and [prepared statement] objects. ** In this mode (which is the default when SQLite is compiled with ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access ** to [database connections] and [prepared statements] so that the ** application is free to use the same [database connection] or the ** same [prepared statement] in different threads at the same time. ** ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** it is not possible to set the Serialized [threading mode] and ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the ** SQLITE_CONFIG_SERIALIZED configuration option.
** ** [[SQLITE_CONFIG_MALLOC]]
SQLITE_CONFIG_MALLOC
**
^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mem_methods] structure. The argument specifies ** alternative low-level memory allocation routines to be used in place of ** the memory allocation routines built into SQLite.)^ ^SQLite makes ** its own private copy of the content of the [sqlite3_mem_methods] structure ** before the [sqlite3_config()] call returns.
** ** [[SQLITE_CONFIG_GETMALLOC]]
SQLITE_CONFIG_GETMALLOC
**
^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines.)^ ** This option can be used to overload the default memory allocation ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example.
** ** [[SQLITE_CONFIG_MEMSTATUS]]
SQLITE_CONFIG_MEMSTATUS
**
^This option takes single argument of type int, interpreted as a ** boolean, which enables or disables the collection of memory allocation ** statistics. ^(When memory allocation statistics are disabled, the ** following SQLite interfaces become non-operational: **
    **
  • [sqlite3_memory_used()] **
  • [sqlite3_memory_highwater()] **
  • [sqlite3_soft_heap_limit64()] **
  • [sqlite3_status()] **
)^ ** ^Memory allocation statistics are enabled by default unless SQLite is ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory ** allocation statistics are disabled by default. **
** ** [[SQLITE_CONFIG_SCRATCH]]
SQLITE_CONFIG_SCRATCH
**
^This option specifies a static memory buffer that SQLite can use for ** scratch memory. There are three arguments: A pointer an 8-byte ** aligned memory buffer from which the scratch allocations will be ** drawn, the size of each scratch allocation (sz), ** and the maximum number of scratch allocations (N). The sz ** argument must be a multiple of 16. ** The first argument must be a pointer to an 8-byte aligned buffer ** of at least sz*N bytes of memory. ** ^SQLite will use no more than two scratch buffers per thread. So ** N should be set to twice the expected maximum number of threads. ** ^SQLite will never require a scratch buffer that is more than 6 ** times the database page size. ^If SQLite needs needs additional ** scratch memory beyond what is provided by this configuration option, then ** [sqlite3_malloc()] will be used to obtain the memory needed.
** ** [[SQLITE_CONFIG_PAGECACHE]]
SQLITE_CONFIG_PAGECACHE
**
^This option specifies a static memory buffer that SQLite can use for ** the database page cache with the default page cache implementation. ** This configuration should not be used if an application-define page ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option. ** There are three arguments to this option: A pointer to 8-byte aligned ** memory, the size of each page buffer (sz), and the number of pages (N). ** The sz argument should be the size of the largest database page ** (a power of two between 512 and 32768) plus a little extra for each ** page header. ^The page header size is 20 to 40 bytes depending on ** the host architecture. ^It is harmless, apart from the wasted memory, ** to make sz a little too large. The first ** argument should point to an allocation of at least sz*N bytes of memory. ** ^SQLite will use the memory provided by the first argument to satisfy its ** memory needs for the first N pages that it adds to cache. ^If additional ** page cache memory is needed beyond what is provided by this option, then ** SQLite goes to [sqlite3_malloc()] for the additional storage space. ** The pointer in the first argument must ** be aligned to an 8-byte boundary or subsequent behavior of SQLite ** will be undefined.
** ** [[SQLITE_CONFIG_HEAP]]
SQLITE_CONFIG_HEAP
**
^This option specifies a static memory buffer that SQLite will use ** for all of its dynamic memory allocation needs beyond those provided ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. ** There are three arguments: An 8-byte aligned pointer to the memory, ** the number of bytes in the memory buffer, and the minimum allocation size. ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts ** to using its default memory allocator (the system malloc() implementation), ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory ** allocator is engaged to handle all of SQLites memory allocation needs. ** The first pointer (the memory pointer) must be aligned to an 8-byte ** boundary or subsequent behavior of SQLite will be undefined. ** The minimum allocation size is capped at 2**12. Reasonable values ** for the minimum allocation size are 2**5 through 2**8.
** ** [[SQLITE_CONFIG_MUTEX]]
SQLITE_CONFIG_MUTEX
**
^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The argument specifies ** alternative low-level mutex routines to be used in place ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the ** content of the [sqlite3_mutex_methods] structure before the call to ** [sqlite3_config()] returns. ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** the entire mutexing subsystem is omitted from the build and hence calls to ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will ** return [SQLITE_ERROR].
** ** [[SQLITE_CONFIG_GETMUTEX]]
SQLITE_CONFIG_GETMUTEX
**
^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The ** [sqlite3_mutex_methods] ** structure is filled with the currently defined mutex routines.)^ ** This option can be used to overload the default mutex allocation ** routines with a wrapper used to track mutex usage for performance ** profiling or testing, for example. ^If SQLite is compiled with ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then ** the entire mutexing subsystem is omitted from the build and hence calls to ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will ** return [SQLITE_ERROR].
** ** [[SQLITE_CONFIG_LOOKASIDE]]
SQLITE_CONFIG_LOOKASIDE
**
^(This option takes two arguments that determine the default ** memory allocation for the lookaside memory allocator on each ** [database connection]. The first argument is the ** size of each lookaside buffer slot and the second is the number of ** slots allocated to each database connection.)^ ^(This option sets the ** default lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] ** verb to [sqlite3_db_config()] can be used to change the lookaside ** configuration on individual connections.)^
** ** [[SQLITE_CONFIG_PCACHE2]]
SQLITE_CONFIG_PCACHE2
**
^(This option takes a single argument which is a pointer to ** an [sqlite3_pcache_methods2] object. This object specifies the interface ** to a custom page cache implementation.)^ ^SQLite makes a copy of the ** object and uses it for page cache memory allocations.
** ** [[SQLITE_CONFIG_GETPCACHE2]]
SQLITE_CONFIG_GETPCACHE2
**
^(This option takes a single argument which is a pointer to an ** [sqlite3_pcache_methods2] object. SQLite copies of the current ** page cache implementation into that object.)^
** ** [[SQLITE_CONFIG_LOG]]
SQLITE_CONFIG_LOG
**
^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a ** function with a call signature of void(*)(void*,int,const char*), ** and a pointer to void. ^If the function pointer is not NULL, it is ** invoked by [sqlite3_log()] to process each logging event. ^If the ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is ** passed through as the first parameter to the application-defined logger ** function whenever that function is invoked. ^The second parameter to ** the logger function is a copy of the first parameter to the corresponding ** [sqlite3_log()] call and is intended to be a [result code] or an ** [extended result code]. ^The third parameter passed to the logger is ** log message after formatting via [sqlite3_snprintf()]. ** The SQLite logging interface is not reentrant; the logger function ** supplied by the application must not invoke any SQLite interface. ** In a multi-threaded application, the application-defined logger ** function must be threadsafe.
** ** [[SQLITE_CONFIG_URI]]
SQLITE_CONFIG_URI **
This option takes a single argument of type int. If non-zero, then ** URI handling is globally enabled. If the parameter is zero, then URI handling ** is globally disabled. If URI handling is globally enabled, all filenames ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or ** specified as part of [ATTACH] commands are interpreted as URIs, regardless ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database ** connection is opened. If it is globally disabled, filenames are ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the ** database connection is opened. By default, URI handling is globally ** disabled. The default value may be changed by compiling with the ** [SQLITE_USE_URI] symbol defined. ** ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]]
SQLITE_CONFIG_COVERING_INDEX_SCAN **
This option takes a single integer argument which is interpreted as ** a boolean in order to enable or disable the use of covering indices for ** full table scans in the query optimizer. The default setting is determined ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on" ** if that compile-time option is omitted. ** The ability to disable the use of covering indices for full table scans ** is because some incorrectly coded legacy applications might malfunction ** malfunction when the optimization is enabled. Providing the ability to ** disable the optimization allows the older, buggy application code to work ** without change even with newer versions of SQLite. ** ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]] **
SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE **
These options are obsolete and should not be used by new code. ** They are retained for backwards compatibility but are now no-ops. **
** ** [[SQLITE_CONFIG_SQLLOG]] **
SQLITE_CONFIG_SQLLOG **
This option is only available if sqlite is compiled with the ** SQLITE_ENABLE_SQLLOG pre-processor macro defined. The first argument should ** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int). ** The second should be of type (void*). The callback is invoked by the library ** in three separate circumstances, identified by the value passed as the ** fourth parameter. If the fourth parameter is 0, then the database connection ** passed as the second argument has just been opened. The third argument ** points to a buffer containing the name of the main database file. If the ** fourth parameter is 1, then the SQL statement that the third parameter ** points to has just been executed. Or, if the fourth parameter is 2, then ** the connection being passed as the second parameter is being closed. The ** third parameter is passed NULL In this case. ** */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ #define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ #define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ #define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ #define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ #define SQLITE_CONFIG_PCACHE 14 /* no-op */ #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ #define SQLITE_CONFIG_URI 17 /* int */ #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */ #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */ #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** ** New configuration options may be added in future releases of SQLite. ** Existing configuration options might be discontinued. Applications ** should check the return code from [sqlite3_db_config()] to make sure that ** the call worked. ^The [sqlite3_db_config()] interface will return a ** non-zero [error code] if a discontinued or unsupported configuration option ** is invoked. ** **
**
SQLITE_DBCONFIG_LOOKASIDE
**
^This option takes three additional arguments that determine the ** [lookaside memory allocator] configuration for the [database connection]. ** ^The first argument (the third parameter to [sqlite3_db_config()] is a ** pointer to a memory buffer to use for lookaside memory. ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb ** may be NULL in which case SQLite will allocate the ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the ** size of each lookaside buffer slot. ^The third argument is the number of ** slots. The size of the buffer in the first argument must be greater than ** or equal to the product of the second and third arguments. The buffer ** must be aligned to an 8-byte boundary. ^If the second argument to ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally ** rounded down to the next smaller multiple of 8. ^(The lookaside memory ** configuration for a database connection can only be changed when that ** connection is not currently using lookaside memory, or in other words ** when the "current value" returned by ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. ** Any attempt to change the lookaside memory configuration when lookaside ** memory is in use leaves the configuration unchanged and returns ** [SQLITE_BUSY].)^
** **
SQLITE_DBCONFIG_ENABLE_FKEY
**
^This option is used to enable or disable the enforcement of ** [foreign key constraints]. There should be two additional arguments. ** The first argument is an integer which is 0 to disable FK enforcement, ** positive to enable FK enforcement or negative to leave FK enforcement ** unchanged. The second parameter is a pointer to an integer into which ** is written 0 or 1 to indicate whether FK enforcement is off or on ** following this call. The second parameter may be a NULL pointer, in ** which case the FK enforcement setting is not reported back.
** **
SQLITE_DBCONFIG_ENABLE_TRIGGER
**
^This option is used to enable or disable [CREATE TRIGGER | triggers]. ** There should be two additional arguments. ** The first argument is an integer which is 0 to disable triggers, ** positive to enable triggers or negative to leave the setting unchanged. ** The second parameter is a pointer to an integer into which ** is written 0 or 1 to indicate whether triggers are disabled or enabled ** following this call. The second parameter may be a NULL pointer, in ** which case the trigger setting is not reported back.
** **
*/ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes ** ** ^The sqlite3_extended_result_codes() routine enables or disables the ** [extended result codes] feature of SQLite. ^The extended result ** codes are disabled by default for historical compatibility. */ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); /* ** CAPI3REF: Last Insert Rowid ** ** ^Each entry in an SQLite table has a unique 64-bit signed ** integer key called the [ROWID | "rowid"]. ^The rowid is always available ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those ** names are not also used by explicitly declared columns. ^If ** the table has a column of type [INTEGER PRIMARY KEY] then that column ** is another alias for the rowid. ** ** ^This routine returns the [rowid] of the most recent ** successful [INSERT] into the database from the [database connection] ** in the first argument. ^As of SQLite version 3.7.7, this routines ** records the last insert rowid of both ordinary tables and [virtual tables]. ** ^If no successful [INSERT]s ** have ever occurred on that database connection, zero is returned. ** ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] ** method, then this routine will return the [rowid] of the inserted ** row as long as the trigger or virtual table method is running. ** But once the trigger or virtual table method ends, the value returned ** by this routine reverts to what it was before the trigger or virtual ** table method began.)^ ** ** ^An [INSERT] that fails due to a constraint violation is not a ** successful [INSERT] and does not change the value returned by this ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, ** and INSERT OR ABORT make no changes to the return value of this ** routine when their insertion fails. ^(When INSERT OR REPLACE ** encounters a constraint violation, it does not fail. The ** INSERT continues to completion after deleting rows that caused ** the constraint problem so INSERT OR REPLACE will always change ** the return value of this interface.)^ ** ** ^For the purposes of this routine, an [INSERT] is considered to ** be successful even if it is subsequently rolled back. ** ** This function is accessible to SQL statements via the ** [last_insert_rowid() SQL function]. ** ** If a separate thread performs a new [INSERT] on the same ** database connection while the [sqlite3_last_insert_rowid()] ** function is running and thus changes the last insert [rowid], ** then the value returned by [sqlite3_last_insert_rowid()] is ** unpredictable and might not equal either the old or the new ** last insert [rowid]. */ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); /* ** CAPI3REF: Count The Number Of Rows Modified ** ** ^This function returns the number of database rows that were changed ** or inserted or deleted by the most recently completed SQL statement ** on the [database connection] specified by the first parameter. ** ^(Only changes that are directly specified by the [INSERT], [UPDATE], ** or [DELETE] statement are counted. Auxiliary changes caused by ** triggers or [foreign key actions] are not counted.)^ Use the ** [sqlite3_total_changes()] function to find the total number of changes ** including changes caused by triggers and foreign key actions. ** ** ^Changes to a view that are simulated by an [INSTEAD OF trigger] ** are not counted. Only real table changes are counted. ** ** ^(A "row change" is a change to a single row of a single table ** caused by an INSERT, DELETE, or UPDATE statement. Rows that ** are changed as side effects of [REPLACE] constraint resolution, ** rollback, ABORT processing, [DROP TABLE], or by any other ** mechanisms do not count as direct row changes.)^ ** ** A "trigger context" is a scope of execution that begins and ** ends with the script of a [CREATE TRIGGER | trigger]. ** Most SQL statements are ** evaluated outside of any trigger. This is the "top level" ** trigger context. If a trigger fires from the top level, a ** new trigger context is entered for the duration of that one ** trigger. Subtriggers create subcontexts for their duration. ** ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does ** not create a new trigger context. ** ** ^This function returns the number of direct row changes in the ** most recent INSERT, UPDATE, or DELETE statement within the same ** trigger context. ** ** ^Thus, when called from the top level, this function returns the ** number of changes in the most recent INSERT, UPDATE, or DELETE ** that also occurred at the top level. ^(Within the body of a trigger, ** the sqlite3_changes() interface can be called to find the number of ** changes in the most recently completed INSERT, UPDATE, or DELETE ** statement within the body of the same trigger. ** However, the number returned does not include changes ** caused by subtriggers since those have their own context.)^ ** ** See also the [sqlite3_total_changes()] interface, the ** [count_changes pragma], and the [changes() SQL function]. ** ** If a separate thread makes changes on the same database connection ** while [sqlite3_changes()] is running then the value returned ** is unpredictable and not meaningful. */ SQLITE_API int sqlite3_changes(sqlite3*); /* ** CAPI3REF: Total Number Of Rows Modified ** ** ^This function returns the number of row changes caused by [INSERT], ** [UPDATE] or [DELETE] statements since the [database connection] was opened. ** ^(The count returned by sqlite3_total_changes() includes all changes ** from all [CREATE TRIGGER | trigger] contexts and changes made by ** [foreign key actions]. However, ** the count does not include changes used to implement [REPLACE] constraints, ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The ** count does not include rows of views that fire an [INSTEAD OF trigger], ** though if the INSTEAD OF trigger makes changes of its own, those changes ** are counted.)^ ** ^The sqlite3_total_changes() function counts the changes as soon as ** the statement that makes them is completed (when the statement handle ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]). ** ** See also the [sqlite3_changes()] interface, the ** [count_changes pragma], and the [total_changes() SQL function]. ** ** If a separate thread makes changes on the same database connection ** while [sqlite3_total_changes()] is running then the value ** returned is unpredictable and not meaningful. */ SQLITE_API int sqlite3_total_changes(sqlite3*); /* ** CAPI3REF: Interrupt A Long-Running Query ** ** ^This function causes any pending database operation to abort and ** return at its earliest opportunity. This routine is typically ** called in response to a user action such as pressing "Cancel" ** or Ctrl-C where the user wants a long query operation to halt ** immediately. ** ** ^It is safe to call this routine from a thread different from the ** thread that is currently running the database operation. But it ** is not safe to call this routine with a [database connection] that ** is closed or might close before sqlite3_interrupt() returns. ** ** ^If an SQL operation is very nearly finished at the time when ** sqlite3_interrupt() is called, then it might not have an opportunity ** to be interrupted and might continue to completion. ** ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE ** that is inside an explicit transaction, then the entire transaction ** will be rolled back automatically. ** ** ^The sqlite3_interrupt(D) call is in effect until all currently running ** SQL statements on [database connection] D complete. ^Any new SQL statements ** that are started after the sqlite3_interrupt() call and before the ** running statements reaches zero are interrupted as if they had been ** running prior to the sqlite3_interrupt() call. ^New SQL statements ** that are started after the running statement count reaches zero are ** not effected by the sqlite3_interrupt(). ** ^A call to sqlite3_interrupt(D) that occurs when there are no running ** SQL statements is a no-op and has no effect on SQL statements ** that are started after the sqlite3_interrupt() call returns. ** ** If the database connection closes while [sqlite3_interrupt()] ** is running then bad things will likely happen. */ SQLITE_API void sqlite3_interrupt(sqlite3*); /* ** CAPI3REF: Determine If An SQL Statement Is Complete ** ** These routines are useful during command-line input to determine if the ** currently entered text seems to form a complete SQL statement or ** if additional input is needed before sending the text into ** SQLite for parsing. ^These routines return 1 if the input string ** appears to be a complete SQL statement. ^A statement is judged to be ** complete if it ends with a semicolon token and is not a prefix of a ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within ** string literals or quoted identifier names or comments are not ** independent tokens (they are part of the token in which they are ** embedded) and thus do not count as a statement terminator. ^Whitespace ** and comments that follow the final semicolon are ignored. ** ** ^These routines return 0 if the statement is incomplete. ^If a ** memory allocation fails, then SQLITE_NOMEM is returned. ** ** ^These routines do not parse the SQL statements thus ** will not detect syntactically incorrect SQL. ** ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked ** automatically by sqlite3_complete16(). If that initialization fails, ** then the return value from sqlite3_complete16() will be non-zero ** regardless of whether or not the input SQL is complete.)^ ** ** The input to [sqlite3_complete()] must be a zero-terminated ** UTF-8 string. ** ** The input to [sqlite3_complete16()] must be a zero-terminated ** UTF-16 string in native byte order. */ SQLITE_API int sqlite3_complete(const char *sql); SQLITE_API int sqlite3_complete16(const void *sql); /* ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors ** ** ^This routine sets a callback function that might be invoked whenever ** an attempt is made to open a database table that another thread ** or process has locked. ** ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] ** is returned immediately upon encountering the lock. ^If the busy callback ** is not NULL, then the callback might be invoked with two arguments. ** ** ^The first argument to the busy handler is a copy of the void* pointer which ** is the third argument to sqlite3_busy_handler(). ^The second argument to ** the busy handler callback is the number of times that the busy handler has ** been invoked for this locking event. ^If the ** busy callback returns 0, then no additional attempts are made to ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. ** ^If the callback returns non-zero, then another attempt ** is made to open the database for reading and the cycle repeats. ** ** The presence of a busy handler does not guarantee that it will be invoked ** when there is lock contention. ^If SQLite determines that invoking the busy ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. ** Consider a scenario where one process is holding a read lock that ** it is trying to promote to a reserved lock and ** a second process is holding a reserved lock that it is trying ** to promote to an exclusive lock. The first process cannot proceed ** because it is blocked by the second and the second process cannot ** proceed because it is blocked by the first. If both processes ** invoke the busy handlers, neither will make any progress. Therefore, ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this ** will induce the first process to release its read lock and allow ** the second process to proceed. ** ** ^The default busy callback is NULL. ** ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] ** when SQLite is in the middle of a large transaction where all the ** changes will not fit into the in-memory cache. SQLite will ** already hold a RESERVED lock on the database file, but it needs ** to promote this lock to EXCLUSIVE so that it can spill cache ** pages into the database file without harm to concurrent ** readers. ^If it is unable to promote the lock, then the in-memory ** cache will be left in an inconsistent state and so the error ** code is promoted from the relatively benign [SQLITE_BUSY] to ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion ** forces an automatic rollback of the changes. See the ** ** CorruptionFollowingBusyError wiki page for a discussion of why ** this is important. ** ** ^(There can only be a single busy handler defined for each ** [database connection]. Setting a new busy handler clears any ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] ** will also set or clear the busy handler. ** ** The busy callback should not take any actions which modify the ** database connection that invoked the busy handler. Any such actions ** result in undefined behavior. ** ** A busy handler must not close the database connection ** or [prepared statement] that invoked the busy handler. */ SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); /* ** CAPI3REF: Set A Busy Timeout ** ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps ** for a specified amount of time when a table is locked. ^The handler ** will sleep multiple times until at least "ms" milliseconds of sleeping ** have accumulated. ^After at least "ms" milliseconds of sleeping, ** the handler returns 0 which causes [sqlite3_step()] to return ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. ** ** ^Calling this routine with an argument less than or equal to zero ** turns off all busy handlers. ** ** ^(There can only be a single busy handler for a particular ** [database connection] any any given moment. If another busy handler ** was defined (using [sqlite3_busy_handler()]) prior to calling ** this routine, that other busy handler is cleared.)^ */ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); /* ** CAPI3REF: Convenience Routines For Running Queries ** ** This is a legacy interface that is preserved for backwards compatibility. ** Use of this interface is not recommended. ** ** Definition: A result table is memory data structure created by the ** [sqlite3_get_table()] interface. A result table records the ** complete query results from one or more queries. ** ** The table conceptually has a number of rows and columns. But ** these numbers are not part of the result table itself. These ** numbers are obtained separately. Let N be the number of rows ** and M be the number of columns. ** ** A result table is an array of pointers to zero-terminated UTF-8 strings. ** There are (N+1)*M elements in the array. The first M pointers point ** to zero-terminated strings that contain the names of the columns. ** The remaining entries all point to query results. NULL values result ** in NULL pointers. All other values are in their UTF-8 zero-terminated ** string representation as returned by [sqlite3_column_text()]. ** ** A result table might consist of one or more memory allocations. ** It is not safe to pass a result table directly to [sqlite3_free()]. ** A result table should be deallocated using [sqlite3_free_table()]. ** ** ^(As an example of the result table format, suppose a query result ** is as follows: ** **
**        Name        | Age
**        -----------------------
**        Alice       | 43
**        Bob         | 28
**        Cindy       | 21
** 
** ** There are two column (M==2) and three rows (N==3). Thus the ** result table has 8 entries. Suppose the result table is stored ** in an array names azResult. Then azResult holds this content: ** **
**        azResult[0] = "Name";
**        azResult[1] = "Age";
**        azResult[2] = "Alice";
**        azResult[3] = "43";
**        azResult[4] = "Bob";
**        azResult[5] = "28";
**        azResult[6] = "Cindy";
**        azResult[7] = "21";
** 
)^ ** ** ^The sqlite3_get_table() function evaluates one or more ** semicolon-separated SQL statements in the zero-terminated UTF-8 ** string of its 2nd parameter and returns a result table to the ** pointer given in its 3rd parameter. ** ** After the application has finished with the result from sqlite3_get_table(), ** it must pass the result table pointer to sqlite3_free_table() in order to ** release the memory that was malloced. Because of the way the ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling ** function must not try to call [sqlite3_free()] directly. Only ** [sqlite3_free_table()] is able to release the memory properly and safely. ** ** The sqlite3_get_table() interface is implemented as a wrapper around ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access ** to any internal data structures of SQLite. It uses only the public ** interface defined here. As a consequence, errors that occur in the ** wrapper layer outside of the internal [sqlite3_exec()] call are not ** reflected in subsequent calls to [sqlite3_errcode()] or ** [sqlite3_errmsg()]. */ SQLITE_API int sqlite3_get_table( sqlite3 *db, /* An open database */ const char *zSql, /* SQL to be evaluated */ char ***pazResult, /* Results of the query */ int *pnRow, /* Number of result rows written here */ int *pnColumn, /* Number of result columns written here */ char **pzErrmsg /* Error msg written here */ ); SQLITE_API void sqlite3_free_table(char **result); /* ** CAPI3REF: Formatted String Printing Functions ** ** These routines are work-alikes of the "printf()" family of functions ** from the standard C library. ** ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their ** results into memory obtained from [sqlite3_malloc()]. ** The strings returned by these two routines should be ** released by [sqlite3_free()]. ^Both routines return a ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough ** memory to hold the resulting string. ** ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from ** the standard C library. The result is written into the ** buffer supplied as the second parameter whose size is given by ** the first parameter. Note that the order of the ** first two parameters is reversed from snprintf().)^ This is an ** historical accident that cannot be fixed without breaking ** backwards compatibility. ^(Note also that sqlite3_snprintf() ** returns a pointer to its buffer instead of the number of ** characters actually written into the buffer.)^ We admit that ** the number of characters written would be a more useful return ** value but we cannot change the implementation of sqlite3_snprintf() ** now without breaking compatibility. ** ** ^As long as the buffer size is greater than zero, sqlite3_snprintf() ** guarantees that the buffer is always zero-terminated. ^The first ** parameter "n" is the total size of the buffer, including space for ** the zero terminator. So the longest string that can be completely ** written will be n-1 characters. ** ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). ** ** These routines all implement some additional formatting ** options that are useful for constructing SQL statements. ** All of the usual printf() formatting options apply. In addition, there ** is are "%q", "%Q", and "%z" options. ** ** ^(The %q option works like %s in that it substitutes a nul-terminated ** string from the argument list. But %q also doubles every '\'' character. ** %q is designed for use inside a string literal.)^ By doubling each '\'' ** character it escapes that character and allows it to be inserted into ** the string. ** ** For example, assume the string variable zText contains text as follows: ** **
**  char *zText = "It's a happy day!";
** 
** ** One can use this text in an SQL statement as follows: ** **
**  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
**  sqlite3_exec(db, zSQL, 0, 0, 0);
**  sqlite3_free(zSQL);
** 
** ** Because the %q format string is used, the '\'' character in zText ** is escaped and the SQL generated is as follows: ** **
**  INSERT INTO table1 VALUES('It''s a happy day!')
** 
** ** This is correct. Had we used %s instead of %q, the generated SQL ** would have looked like this: ** **
**  INSERT INTO table1 VALUES('It's a happy day!');
** 
** ** This second example is an SQL syntax error. As a general rule you should ** always use %q instead of %s when inserting text into a string literal. ** ** ^(The %Q option works like %q except it also adds single quotes around ** the outside of the total string. Additionally, if the parameter in the ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without ** single quotes).)^ So, for example, one could say: ** **
**  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
**  sqlite3_exec(db, zSQL, 0, 0, 0);
**  sqlite3_free(zSQL);
** 
** ** The code above will render a correct SQL statement in the zSQL ** variable even if the zText variable is a NULL pointer. ** ** ^(The "%z" formatting option works like "%s" but with the ** addition that after the string has been read and copied into ** the result, [sqlite3_free()] is called on the input string.)^ */ SQLITE_API char *sqlite3_mprintf(const char*,...); SQLITE_API char *sqlite3_vmprintf(const char*, va_list); SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); /* ** CAPI3REF: Memory Allocation Subsystem ** ** The SQLite core uses these three routines for all of its own ** internal memory allocation needs. "Core" in the previous sentence ** does not include operating-system specific VFS implementation. The ** Windows VFS uses native malloc() and free() for some operations. ** ** ^The sqlite3_malloc() routine returns a pointer to a block ** of memory at least N bytes in length, where N is the parameter. ** ^If sqlite3_malloc() is unable to obtain sufficient free ** memory, it returns a NULL pointer. ^If the parameter N to ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns ** a NULL pointer. ** ** ^Calling sqlite3_free() with a pointer previously returned ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so ** that it might be reused. ^The sqlite3_free() routine is ** a no-op if is called with a NULL pointer. Passing a NULL pointer ** to sqlite3_free() is harmless. After being freed, memory ** should neither be read nor written. Even reading previously freed ** memory might result in a segmentation fault or other severe error. ** Memory corruption, a segmentation fault, or other severe error ** might result if sqlite3_free() is called with a non-NULL pointer that ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). ** ** ^(The sqlite3_realloc() interface attempts to resize a ** prior memory allocation to be at least N bytes, where N is the ** second parameter. The memory allocation to be resized is the first ** parameter.)^ ^ If the first parameter to sqlite3_realloc() ** is a NULL pointer then its behavior is identical to calling ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). ** ^If the second parameter to sqlite3_realloc() is zero or ** negative then the behavior is exactly the same as calling ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). ** ^sqlite3_realloc() returns a pointer to a memory allocation ** of at least N bytes in size or NULL if sufficient memory is unavailable. ** ^If M is the size of the prior allocation, then min(N,M) bytes ** of the prior allocation are copied into the beginning of buffer returned ** by sqlite3_realloc() and the prior allocation is freed. ** ^If sqlite3_realloc() returns NULL, then the prior allocation ** is not freed. ** ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc() ** is always aligned to at least an 8 byte boundary, or to a ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time ** option is used. ** ** In SQLite version 3.5.0 and 3.5.1, it was possible to define ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in ** implementation of these routines to be omitted. That capability ** is no longer provided. Only built-in memory allocators can be used. ** ** Prior to SQLite version 3.7.10, the Windows OS interface layer called ** the system malloc() and free() directly when converting ** filenames between the UTF-8 encoding used by SQLite ** and whatever filename encoding is used by the particular Windows ** installation. Memory allocation errors were detected, but ** they were reported back as [SQLITE_CANTOPEN] or ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. ** ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] ** must be either NULL or else pointers obtained from a prior ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have ** not yet been released. ** ** The application must not read or write any part of ** a block of memory after it has been released using ** [sqlite3_free()] or [sqlite3_realloc()]. */ SQLITE_API void *sqlite3_malloc(int); SQLITE_API void *sqlite3_realloc(void*, int); SQLITE_API void sqlite3_free(void*); /* ** CAPI3REF: Memory Allocator Statistics ** ** SQLite provides these two interfaces for reporting on the status ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] ** routines, which form the built-in memory allocation subsystem. ** ** ^The [sqlite3_memory_used()] routine returns the number of bytes ** of memory currently outstanding (malloced but not freed). ** ^The [sqlite3_memory_highwater()] routine returns the maximum ** value of [sqlite3_memory_used()] since the high-water mark ** was last reset. ^The values returned by [sqlite3_memory_used()] and ** [sqlite3_memory_highwater()] include any overhead ** added by SQLite in its implementation of [sqlite3_malloc()], ** but not overhead added by the any underlying system library ** routines that [sqlite3_malloc()] may call. ** ** ^The memory high-water mark is reset to the current value of ** [sqlite3_memory_used()] if and only if the parameter to ** [sqlite3_memory_highwater()] is true. ^The value returned ** by [sqlite3_memory_highwater(1)] is the high-water mark ** prior to the reset. */ SQLITE_API sqlite3_int64 sqlite3_memory_used(void); SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); /* ** CAPI3REF: Pseudo-Random Number Generator ** ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to ** select random [ROWID | ROWIDs] when inserting new records into a table that ** already uses the largest possible [ROWID]. The PRNG is also used for ** the build-in random() and randomblob() SQL functions. This interface allows ** applications to access the same PRNG for other purposes. ** ** ^A call to this routine stores N bytes of randomness into buffer P. ** ** ^The first time this routine is invoked (either internally or by ** the application) the PRNG is seeded using randomness obtained ** from the xRandomness method of the default [sqlite3_vfs] object. ** ^On all subsequent invocations, the pseudo-randomness is generated ** internally and without recourse to the [sqlite3_vfs] xRandomness ** method. */ SQLITE_API void sqlite3_randomness(int N, void *P); /* ** CAPI3REF: Compile-Time Authorization Callbacks ** ** ^This routine registers an authorizer callback with a particular ** [database connection], supplied in the first argument. ** ^The authorizer callback is invoked as SQL statements are being compiled ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various ** points during the compilation process, as logic is being created ** to perform various actions, the authorizer callback is invoked to ** see if those actions are allowed. ^The authorizer callback should ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the ** specific action but allow the SQL statement to continue to be ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be ** rejected with an error. ^If the authorizer callback returns ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] ** then the [sqlite3_prepare_v2()] or equivalent call that triggered ** the authorizer will fail with an error message. ** ** When the callback returns [SQLITE_OK], that means the operation ** requested is ok. ^When the callback returns [SQLITE_DENY], the ** [sqlite3_prepare_v2()] or equivalent call that triggered the ** authorizer will fail with an error message explaining that ** access is denied. ** ** ^The first parameter to the authorizer callback is a copy of the third ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter ** to the callback is an integer [SQLITE_COPY | action code] that specifies ** the particular action to be authorized. ^The third through sixth parameters ** to the callback are zero-terminated strings that contain additional ** details about the action to be authorized. ** ** ^If the action code is [SQLITE_READ] ** and the callback returns [SQLITE_IGNORE] then the ** [prepared statement] statement is constructed to substitute ** a NULL value in place of the table column that would have ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] ** return can be used to deny an untrusted user access to individual ** columns of a table. ** ^If the action code is [SQLITE_DELETE] and the callback returns ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the ** [truncate optimization] is disabled and all rows are deleted individually. ** ** An authorizer is used when [sqlite3_prepare | preparing] ** SQL statements from an untrusted source, to ensure that the SQL statements ** do not try to access data they are not allowed to see, or that they do not ** try to execute malicious statements that damage the database. For ** example, an application may allow a user to enter arbitrary ** SQL queries for evaluation by a database. But the application does ** not want the user to be able to make arbitrary changes to the ** database. An authorizer could then be put in place while the ** user-entered SQL is being [sqlite3_prepare | prepared] that ** disallows everything except [SELECT] statements. ** ** Applications that need to process SQL from untrusted sources ** might also consider lowering resource limits using [sqlite3_limit()] ** and limiting database size using the [max_page_count] [PRAGMA] ** in addition to using an authorizer. ** ** ^(Only a single authorizer can be in place on a database connection ** at a time. Each call to sqlite3_set_authorizer overrides the ** previous call.)^ ^Disable the authorizer by installing a NULL callback. ** The authorizer is disabled by default. ** ** The authorizer callback must not do anything that will modify ** the database connection that invoked the authorizer callback. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** database connections for the meaning of "modify" in this paragraph. ** ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the ** statement might be re-prepared during [sqlite3_step()] due to a ** schema change. Hence, the application should ensure that the ** correct authorizer callback remains in place during the [sqlite3_step()]. ** ** ^Note that the authorizer callback is invoked only during ** [sqlite3_prepare()] or its variants. Authorization is not ** performed during statement evaluation in [sqlite3_step()], unless ** as stated in the previous paragraph, sqlite3_step() invokes ** sqlite3_prepare_v2() to reprepare a statement after a schema change. */ SQLITE_API int sqlite3_set_authorizer( sqlite3*, int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), void *pUserData ); /* ** CAPI3REF: Authorizer Return Codes ** ** The [sqlite3_set_authorizer | authorizer callback function] must ** return either [SQLITE_OK] or one of these two constants in order ** to signal SQLite whether or not the action is permitted. See the ** [sqlite3_set_authorizer | authorizer documentation] for additional ** information. ** ** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code] ** from the [sqlite3_vtab_on_conflict()] interface. */ #define SQLITE_DENY 1 /* Abort the SQL statement with an error */ #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ /* ** CAPI3REF: Authorizer Action Codes ** ** The [sqlite3_set_authorizer()] interface registers a callback function ** that is invoked to authorize certain SQL statement actions. The ** second parameter to the callback is an integer code that specifies ** what action is being authorized. These are the integer action codes that ** the authorizer callback may be passed. ** ** These action code values signify what kind of operation is to be ** authorized. The 3rd and 4th parameters to the authorization ** callback function will be parameters or NULL depending on which of these ** codes is used as the second parameter. ^(The 5th parameter to the ** authorizer callback is the name of the database ("main", "temp", ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback ** is the name of the inner-most trigger or view that is responsible for ** the access attempt or NULL if this access attempt is directly from ** top-level SQL code. */ /******************************************* 3rd ************ 4th ***********/ #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ #define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ #define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ #define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ #define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ #define SQLITE_CREATE_VIEW 8 /* View Name NULL */ #define SQLITE_DELETE 9 /* Table Name NULL */ #define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ #define SQLITE_DROP_TABLE 11 /* Table Name NULL */ #define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ #define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ #define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ #define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ #define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ #define SQLITE_DROP_VIEW 17 /* View Name NULL */ #define SQLITE_INSERT 18 /* Table Name NULL */ #define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ #define SQLITE_READ 20 /* Table Name Column Name */ #define SQLITE_SELECT 21 /* NULL NULL */ #define SQLITE_TRANSACTION 22 /* Operation NULL */ #define SQLITE_UPDATE 23 /* Table Name Column Name */ #define SQLITE_ATTACH 24 /* Filename NULL */ #define SQLITE_DETACH 25 /* Database Name NULL */ #define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ #define SQLITE_REINDEX 27 /* Index Name NULL */ #define SQLITE_ANALYZE 28 /* Table Name NULL */ #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ #define SQLITE_FUNCTION 31 /* NULL Function Name */ #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ #define SQLITE_COPY 0 /* No longer used */ /* ** CAPI3REF: Tracing And Profiling Functions ** ** These routines register callback functions that can be used for ** tracing and profiling the execution of SQL statements. ** ** ^The callback function registered by sqlite3_trace() is invoked at ** various times when an SQL statement is being run by [sqlite3_step()]. ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the ** SQL statement text as the statement first begins executing. ** ^(Additional sqlite3_trace() callbacks might occur ** as each triggered subprogram is entered. The callbacks for triggers ** contain a UTF-8 SQL comment that identifies the trigger.)^ ** ** ^The callback function registered by sqlite3_profile() is invoked ** as each SQL statement finishes. ^The profile callback contains ** the original statement text and an estimate of wall-clock time ** of how long that statement took to run. ^The profile callback ** time is in units of nanoseconds, however the current implementation ** is only capable of millisecond resolution so the six least significant ** digits in the time are meaningless. Future versions of SQLite ** might provide greater resolution on the profiler callback. The ** sqlite3_profile() function is considered experimental and is ** subject to change in future versions of SQLite. */ SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, void(*xProfile)(void*,const char*,sqlite3_uint64), void*); /* ** CAPI3REF: Query Progress Callbacks ** ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback ** function X to be invoked periodically during long running calls to ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for ** database connection D. An example use for this ** interface is to keep a GUI updated during a large query. ** ** ^The parameter P is passed through as the only parameter to the ** callback function X. ^The parameter N is the number of ** [virtual machine instructions] that are evaluated between successive ** invocations of the callback X. ** ** ^Only a single progress handler may be defined at one time per ** [database connection]; setting a new progress handler cancels the ** old one. ^Setting parameter X to NULL disables the progress handler. ** ^The progress handler is also disabled by setting N to a value less ** than 1. ** ** ^If the progress callback returns non-zero, the operation is ** interrupted. This feature can be used to implement a ** "Cancel" button on a GUI progress dialog box. ** ** The progress handler callback must not do anything that will modify ** the database connection that invoked the progress handler. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** database connections for the meaning of "modify" in this paragraph. ** */ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); /* ** CAPI3REF: Opening A New Database Connection ** ** ^These routines open an SQLite database file as specified by the ** filename argument. ^The filename argument is interpreted as UTF-8 for ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte ** order for sqlite3_open16(). ^(A [database connection] handle is usually ** returned in *ppDb, even if an error occurs. The only exception is that ** if SQLite is unable to allocate memory to hold the [sqlite3] object, ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] ** object.)^ ^(If the database is opened (and/or created) successfully, then ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain ** an English language description of the error following a failure of any ** of the sqlite3_open() routines. ** ** ^The default encoding for the database will be UTF-8 if ** sqlite3_open() or sqlite3_open_v2() is called and ** UTF-16 in the native byte order if sqlite3_open16() is used. ** ** Whether or not an error occurs when it is opened, resources ** associated with the [database connection] handle should be released by ** passing it to [sqlite3_close()] when it is no longer required. ** ** The sqlite3_open_v2() interface works like sqlite3_open() ** except that it accepts two additional parameters for additional control ** over the new database connection. ^(The flags parameter to ** sqlite3_open_v2() can take one of ** the following three values, optionally combined with the ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ ** **
** ^(
[SQLITE_OPEN_READONLY]
**
The database is opened in read-only mode. If the database does not ** already exist, an error is returned.
)^ ** ** ^(
[SQLITE_OPEN_READWRITE]
**
The database is opened for reading and writing if possible, or reading ** only if the file is write protected by the operating system. In either ** case the database must already exist, otherwise an error is returned.
)^ ** ** ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
**
The database is opened for reading and writing, and is created if ** it does not already exist. This is the behavior that is always used for ** sqlite3_open() and sqlite3_open16().
)^ **
** ** If the 3rd parameter to sqlite3_open_v2() is not one of the ** combinations shown above optionally combined with other ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] ** then the behavior is undefined. ** ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection ** opens in the multi-thread [threading mode] as long as the single-thread ** mode has not been set at compile-time or start-time. ^If the ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens ** in the serialized [threading mode] unless single-thread was ** previously selected at compile-time or start-time. ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be ** eligible to use [shared cache mode], regardless of whether or not shared ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not ** participate in [shared cache mode] even if it is enabled. ** ** ^The fourth parameter to sqlite3_open_v2() is the name of the ** [sqlite3_vfs] object that defines the operating system interface that ** the new database connection should use. ^If the fourth parameter is ** a NULL pointer then the default [sqlite3_vfs] object is used. ** ** ^If the filename is ":memory:", then a private, temporary in-memory database ** is created for the connection. ^This in-memory database will vanish when ** the database connection is closed. Future versions of SQLite might ** make use of additional special filenames that begin with the ":" character. ** It is recommended that when a database filename actually does begin with ** a ":" character you should prefix the filename with a pathname such as ** "./" to avoid ambiguity. ** ** ^If the filename is an empty string, then a private, temporary ** on-disk database will be created. ^This private database will be ** automatically deleted as soon as the database connection is closed. ** ** [[URI filenames in sqlite3_open()]]

URI Filenames

** ** ^If [URI filename] interpretation is enabled, and the filename argument ** begins with "file:", then the filename is interpreted as a URI. ^URI ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is ** set in the fourth argument to sqlite3_open_v2(), or if it has ** been enabled globally using the [SQLITE_CONFIG_URI] option with the ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. ** As of SQLite version 3.7.7, URI filename interpretation is turned off ** by default, but future releases of SQLite might enable URI filename ** interpretation by default. See "[URI filenames]" for additional ** information. ** ** URI filenames are parsed according to RFC 3986. ^If the URI contains an ** authority, then it must be either an empty string or the string ** "localhost". ^If the authority is not an empty string or "localhost", an ** error is returned to the caller. ^The fragment component of a URI, if ** present, is ignored. ** ** ^SQLite uses the path component of the URI as the name of the disk file ** which contains the database. ^If the path begins with a '/' character, ** then it is interpreted as an absolute path. ^If the path does not begin ** with a '/' (meaning that the authority section is omitted from the URI) ** then the path is interpreted as a relative path. ** ^On windows, the first component of an absolute path ** is a drive specification (e.g. "C:"). ** ** [[core URI query parameters]] ** The query component of a URI may contain parameters that are interpreted ** either by SQLite itself, or by a [VFS | custom VFS implementation]. ** SQLite interprets the following three query parameters: ** **
    **
  • vfs: ^The "vfs" parameter may be used to specify the name of ** a VFS object that provides the operating system interface that should ** be used to access the database file on disk. ^If this option is set to ** an empty string the default VFS object is used. ^Specifying an unknown ** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is ** present, then the VFS specified by the option takes precedence over ** the value passed as the fourth parameter to sqlite3_open_v2(). ** **
  • mode: ^(The mode parameter may be set to either "ro", "rw", ** "rwc", or "memory". Attempting to set it to any other value is ** an error)^. ** ^If "ro" is specified, then the database is opened for read-only ** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the ** third argument to sqlite3_open_v2(). ^If the mode option is set to ** "rw", then the database is opened for read-write (but not create) ** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had ** been set. ^Value "rwc" is equivalent to setting both ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is ** set to "memory" then a pure [in-memory database] that never reads ** or writes from disk is used. ^It is an error to specify a value for ** the mode parameter that is less restrictive than that specified by ** the flags passed in the third parameter to sqlite3_open_v2(). ** **
  • cache: ^The cache parameter may be set to either "shared" or ** "private". ^Setting it to "shared" is equivalent to setting the ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in ** a URI filename, its value overrides any behaviour requested by setting ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. **
** ** ^Specifying an unknown parameter in the query component of a URI is not an ** error. Future versions of SQLite might understand additional query ** parameters. See "[query parameters with special meaning to SQLite]" for ** additional information. ** ** [[URI filename examples]]

URI filename examples

** ** **
URI filenames Results **
file:data.db ** Open the file "data.db" in the current directory. **
file:/home/fred/data.db
** file:///home/fred/data.db
** file://localhost/home/fred/data.db
** Open the database file "/home/fred/data.db". **
file://darkstar/home/fred/data.db ** An error. "darkstar" is not a recognized authority. **
** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db ** Windows only: Open the file "data.db" on fred's desktop on drive ** C:. Note that the %20 escaping in this example is not strictly ** necessary - space characters can be used literally ** in URI filenames. **
file:data.db?mode=ro&cache=private ** Open file "data.db" in the current directory for read-only access. ** Regardless of whether or not shared-cache mode is enabled by ** default, use a private cache. **
file:/home/fred/data.db?vfs=unix-nolock ** Open file "/home/fred/data.db". Use the special VFS "unix-nolock". **
file:data.db?mode=readonly ** An error. "readonly" is not a valid option for the "mode" parameter. **
** ** ^URI hexadecimal escape sequences (%HH) are supported within the path and ** query components of a URI. A hexadecimal escape sequence consists of a ** percent sign - "%" - followed by exactly two hexadecimal digits ** specifying an octet value. ^Before the path or query components of a ** URI filename are interpreted, they are encoded using UTF-8 and all ** hexadecimal escape sequences replaced by a single byte containing the ** corresponding octet. If this process generates an invalid UTF-8 encoding, ** the results are undefined. ** ** Note to Windows users: The encoding used for the filename argument ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever ** codepage is currently defined. Filenames containing international ** characters must be converted to UTF-8 prior to passing them into ** sqlite3_open() or sqlite3_open_v2(). ** ** Note to Windows Runtime users: The temporary directory must be set ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various ** features that require the use of temporary files may fail. ** ** See also: [sqlite3_temp_directory] */ SQLITE_API int sqlite3_open( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); SQLITE_API int sqlite3_open16( const void *filename, /* Database filename (UTF-16) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); SQLITE_API int sqlite3_open_v2( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb, /* OUT: SQLite db handle */ int flags, /* Flags */ const char *zVfs /* Name of VFS module to use */ ); /* ** CAPI3REF: Obtain Values For URI Parameters ** ** These are utility routines, useful to VFS implementations, that check ** to see if a database file was a URI that contained a specific query ** parameter, and if so obtains the value of that query parameter. ** ** If F is the database filename pointer passed into the xOpen() method of ** a VFS implementation when the flags parameter to xOpen() has one or ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and ** P is the name of the query parameter, then ** sqlite3_uri_parameter(F,P) returns the value of the P ** parameter if it exists or a NULL pointer if P does not appear as a ** query parameter on F. If P is a query parameter of F ** has no explicit value, then sqlite3_uri_parameter(F,P) returns ** a pointer to an empty string. ** ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean ** parameter and returns true (1) or false (0) according to the value ** of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the ** value of query parameter P is one of "yes", "true", or "on" in any ** case or if the value begins with a non-zero number. The ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of ** query parameter P is one of "no", "false", or "off" in any case or ** if the value begins with a numeric zero. If P is not a query ** parameter on F or if the value of P is does not match any of the ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). ** ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a ** 64-bit signed integer and returns that integer, or D if P does not ** exist. If the value of P is something other than an integer, then ** zero is returned. ** ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and ** is not a database file pathname pointer that SQLite passed into the xOpen ** VFS method, then the behavior of this routine is undefined and probably ** undesirable. */ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); /* ** CAPI3REF: Error Codes And Messages ** ** ^The sqlite3_errcode() interface returns the numeric [result code] or ** [extended result code] for the most recent failed sqlite3_* API call ** associated with a [database connection]. If a prior API call failed ** but the most recent API call succeeded, the return value from ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() ** interface is the same except that it always returns the ** [extended result code] even when extended result codes are ** disabled. ** ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language ** text that describes the error, as either UTF-8 or UTF-16 respectively. ** ^(Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by ** subsequent calls to other SQLite interface functions.)^ ** ** ^The sqlite3_errstr() interface returns the English-language text ** that describes the [result code], as UTF-8. ** ^(Memory to hold the error message string is managed internally ** and must not be freed by the application)^. ** ** When the serialized [threading mode] is in use, it might be the ** case that a second error occurs on a separate thread in between ** the time of the first error and the call to these interfaces. ** When that happens, the second error will be reported since these ** interfaces always report the most recent result. To avoid ** this, each thread can obtain exclusive use of the [database connection] D ** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after ** all calls to the interfaces listed here are completed. ** ** If an interface fails with SQLITE_MISUSE, that means the interface ** was invoked incorrectly by the application. In that case, the ** error code and message may or may not be set. */ SQLITE_API int sqlite3_errcode(sqlite3 *db); SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); SQLITE_API const char *sqlite3_errmsg(sqlite3*); SQLITE_API const void *sqlite3_errmsg16(sqlite3*); SQLITE_API const char *sqlite3_errstr(int); /* ** CAPI3REF: SQL Statement Object ** KEYWORDS: {prepared statement} {prepared statements} ** ** An instance of this object represents a single SQL statement. ** This object is variously known as a "prepared statement" or a ** "compiled SQL statement" or simply as a "statement". ** ** The life of a statement object goes something like this: ** **
    **
  1. Create the object using [sqlite3_prepare_v2()] or a related ** function. **
  2. Bind values to [host parameters] using the sqlite3_bind_*() ** interfaces. **
  3. Run the SQL by calling [sqlite3_step()] one or more times. **
  4. Reset the statement using [sqlite3_reset()] then go back ** to step 2. Do this zero or more times. **
  5. Destroy the object using [sqlite3_finalize()]. **
** ** Refer to documentation on individual methods above for additional ** information. */ typedef struct sqlite3_stmt sqlite3_stmt; /* ** CAPI3REF: Run-time Limits ** ** ^(This interface allows the size of various constructs to be limited ** on a connection by connection basis. The first parameter is the ** [database connection] whose limit is to be set or queried. The ** second parameter is one of the [limit categories] that define a ** class of constructs to be size limited. The third parameter is the ** new limit for that construct.)^ ** ** ^If the new limit is a negative number, the limit is unchanged. ** ^(For each limit category SQLITE_LIMIT_NAME there is a ** [limits | hard upper bound] ** set at compile-time by a C preprocessor macro called ** [limits | SQLITE_MAX_NAME]. ** (The "_LIMIT_" in the name is changed to "_MAX_".))^ ** ^Attempts to increase a limit above its hard upper bound are ** silently truncated to the hard upper bound. ** ** ^Regardless of whether or not the limit was changed, the ** [sqlite3_limit()] interface returns the prior value of the limit. ** ^Hence, to find the current value of a limit without changing it, ** simply invoke this interface with the third parameter set to -1. ** ** Run-time limits are intended for use in applications that manage ** both their own internal database and also databases that are controlled ** by untrusted external sources. An example application might be a ** web browser that has its own databases for storing history and ** separate databases controlled by JavaScript applications downloaded ** off the Internet. The internal databases can be given the ** large, default limits. Databases managed by external sources can ** be given much smaller limits designed to prevent a denial of service ** attack. Developers might also want to use the [sqlite3_set_authorizer()] ** interface to further control untrusted SQL. The size of the database ** created by an untrusted script can be contained using the ** [max_page_count] [PRAGMA]. ** ** New run-time limit categories may be added in future releases. */ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); /* ** CAPI3REF: Run-Time Limit Categories ** KEYWORDS: {limit category} {*limit categories} ** ** These constants define various performance limits ** that can be lowered at run-time using [sqlite3_limit()]. ** The synopsis of the meanings of the various limits is shown below. ** Additional information is available at [limits | Limits in SQLite]. ** **
** [[SQLITE_LIMIT_LENGTH]] ^(
SQLITE_LIMIT_LENGTH
**
The maximum size of any string or BLOB or table row, in bytes.
)^ ** ** [[SQLITE_LIMIT_SQL_LENGTH]] ^(
SQLITE_LIMIT_SQL_LENGTH
**
The maximum length of an SQL statement, in bytes.
)^ ** ** [[SQLITE_LIMIT_COLUMN]] ^(
SQLITE_LIMIT_COLUMN
**
The maximum number of columns in a table definition or in the ** result set of a [SELECT] or the maximum number of columns in an index ** or in an ORDER BY or GROUP BY clause.
)^ ** ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(
SQLITE_LIMIT_EXPR_DEPTH
**
The maximum depth of the parse tree on any expression.
)^ ** ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(
SQLITE_LIMIT_COMPOUND_SELECT
**
The maximum number of terms in a compound SELECT statement.
)^ ** ** [[SQLITE_LIMIT_VDBE_OP]] ^(
SQLITE_LIMIT_VDBE_OP
**
The maximum number of instructions in a virtual machine program ** used to implement an SQL statement. This limit is not currently ** enforced, though that might be added in some future release of ** SQLite.
)^ ** ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(
SQLITE_LIMIT_FUNCTION_ARG
**
The maximum number of arguments on a function.
)^ ** ** [[SQLITE_LIMIT_ATTACHED]] ^(
SQLITE_LIMIT_ATTACHED
**
The maximum number of [ATTACH | attached databases].)^
** ** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]] ** ^(
SQLITE_LIMIT_LIKE_PATTERN_LENGTH
**
The maximum length of the pattern argument to the [LIKE] or ** [GLOB] operators.
)^ ** ** [[SQLITE_LIMIT_VARIABLE_NUMBER]] ** ^(
SQLITE_LIMIT_VARIABLE_NUMBER
**
The maximum index number of any [parameter] in an SQL statement.)^ ** ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(
SQLITE_LIMIT_TRIGGER_DEPTH
**
The maximum depth of recursion for triggers.
)^ **
*/ #define SQLITE_LIMIT_LENGTH 0 #define SQLITE_LIMIT_SQL_LENGTH 1 #define SQLITE_LIMIT_COLUMN 2 #define SQLITE_LIMIT_EXPR_DEPTH 3 #define SQLITE_LIMIT_COMPOUND_SELECT 4 #define SQLITE_LIMIT_VDBE_OP 5 #define SQLITE_LIMIT_FUNCTION_ARG 6 #define SQLITE_LIMIT_ATTACHED 7 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 #define SQLITE_LIMIT_VARIABLE_NUMBER 9 #define SQLITE_LIMIT_TRIGGER_DEPTH 10 /* ** CAPI3REF: Compiling An SQL Statement ** KEYWORDS: {SQL statement compiler} ** ** To execute an SQL query, it must first be compiled into a byte-code ** program using one of these routines. ** ** The first argument, "db", is a [database connection] obtained from a ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or ** [sqlite3_open16()]. The database connection must not have been closed. ** ** The second argument, "zSql", is the statement to be compiled, encoded ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() ** use UTF-16. ** ** ^If the nByte argument is less than zero, then zSql is read up to the ** first zero terminator. ^If nByte is non-negative, then it is the maximum ** number of bytes read from zSql. ^When nByte is non-negative, the ** zSql string ends at either the first '\000' or '\u0000' character or ** the nByte-th byte, whichever comes first. If the caller knows ** that the supplied string is nul-terminated, then there is a small ** performance advantage to be gained by passing an nByte parameter that ** is equal to the number of bytes in the input string including ** the nul-terminator bytes as this saves SQLite from having to ** make a copy of the input string. ** ** ^If pzTail is not NULL then *pzTail is made to point to the first byte ** past the end of the first SQL statement in zSql. These routines only ** compile the first statement in zSql, so *pzTail is left pointing to ** what remains uncompiled. ** ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set ** to NULL. ^If the input text contains no SQL (if the input is an empty ** string or a comment) then *ppStmt is set to NULL. ** The calling procedure is responsible for deleting the compiled ** SQL statement using [sqlite3_finalize()] after it has finished with it. ** ppStmt may not be NULL. ** ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; ** otherwise an [error code] is returned. ** ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are ** recommended for all new programs. The two older interfaces are retained ** for backwards compatibility, but their use is discouraged. ** ^In the "v2" interfaces, the prepared statement ** that is returned (the [sqlite3_stmt] object) contains a copy of the ** original SQL text. This causes the [sqlite3_step()] interface to ** behave differently in three ways: ** **
    **
  1. ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it ** always used to do, [sqlite3_step()] will automatically recompile the SQL ** statement and try to run it again. **
  2. ** **
  3. ** ^When an error occurs, [sqlite3_step()] will return one of the detailed ** [error codes] or [extended error codes]. ^The legacy behavior was that ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code ** and the application would have to make a second call to [sqlite3_reset()] ** in order to find the underlying cause of the problem. With the "v2" prepare ** interfaces, the underlying reason for the error is returned immediately. **
  4. ** **
  5. ** ^If the specific value bound to [parameter | host parameter] in the ** WHERE clause might influence the choice of query plan for a statement, ** then the statement will be automatically recompiled, as if there had been ** a schema change, on the first [sqlite3_step()] call following any change ** to the [sqlite3_bind_text | bindings] of that [parameter]. ** ^The specific value of WHERE-clause [parameter] might influence the ** choice of query plan if the parameter is the left-hand side of a [LIKE] ** or [GLOB] operator or if the parameter is compared to an indexed column ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. ** the **
  6. **
*/ SQLITE_API int sqlite3_prepare( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare_v2( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); SQLITE_API int sqlite3_prepare16_v2( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); /* ** CAPI3REF: Retrieving Statement SQL ** ** ^This interface can be used to retrieve a saved copy of the original ** SQL text used to create a [prepared statement] if that statement was ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. */ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); /* ** CAPI3REF: Determine If An SQL Statement Writes The Database ** ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if ** and only if the [prepared statement] X makes no direct changes to ** the content of the database file. ** ** Note that [application-defined SQL functions] or ** [virtual tables] might change the database indirectly as a side effect. ** ^(For example, if an application defines a function "eval()" that ** calls [sqlite3_exec()], then the following SQL statement would ** change the database file through side-effects: ** **
**    SELECT eval('DELETE FROM t1') FROM t2;
** 
** ** But because the [SELECT] statement does not change the database file ** directly, sqlite3_stmt_readonly() would still return true.)^ ** ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, ** since the statements themselves do not actually modify the database but ** rather they control the timing of when other statements modify the ** database. ^The [ATTACH] and [DETACH] statements also cause ** sqlite3_stmt_readonly() to return true since, while those statements ** change the configuration of a database connection, they do not make ** changes to the content of the database files on disk. */ SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); /* ** CAPI3REF: Determine If A Prepared Statement Has Been Reset ** ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the ** [prepared statement] S has been stepped at least once using ** [sqlite3_step(S)] but has not run to completion and/or has not ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S) ** interface returns false if S is a NULL pointer. If S is not a ** NULL pointer and is not a pointer to a valid [prepared statement] ** object, then the behavior is undefined and probably undesirable. ** ** This interface can be used in combination [sqlite3_next_stmt()] ** to locate all prepared statements associated with a database ** connection that are in need of being reset. This can be used, ** for example, in diagnostic routines to search for prepared ** statements that are holding a transaction open. */ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*); /* ** CAPI3REF: Dynamically Typed Value Object ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} ** ** SQLite uses the sqlite3_value object to represent all values ** that can be stored in a database table. SQLite uses dynamic typing ** for the values it stores. ^Values stored in sqlite3_value objects ** can be integers, floating point values, strings, BLOBs, or NULL. ** ** An sqlite3_value object may be either "protected" or "unprotected". ** Some interfaces require a protected sqlite3_value. Other interfaces ** will accept either a protected or an unprotected sqlite3_value. ** Every interface that accepts sqlite3_value arguments specifies ** whether or not it requires a protected sqlite3_value. ** ** The terms "protected" and "unprotected" refer to whether or not ** a mutex is held. An internal mutex is held for a protected ** sqlite3_value object but no mutex is held for an unprotected ** sqlite3_value object. If SQLite is compiled to be single-threaded ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) ** or if SQLite is run in one of reduced mutex modes ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] ** then there is no distinction between protected and unprotected ** sqlite3_value objects and they can be used interchangeably. However, ** for maximum code portability it is recommended that applications ** still make the distinction between protected and unprotected ** sqlite3_value objects even when not strictly required. ** ** ^The sqlite3_value objects that are passed as parameters into the ** implementation of [application-defined SQL functions] are protected. ** ^The sqlite3_value object returned by ** [sqlite3_column_value()] is unprotected. ** Unprotected sqlite3_value objects may only be used with ** [sqlite3_result_value()] and [sqlite3_bind_value()]. ** The [sqlite3_value_blob | sqlite3_value_type()] family of ** interfaces require protected sqlite3_value objects. */ typedef struct Mem sqlite3_value; /* ** CAPI3REF: SQL Function Context Object ** ** The context in which an SQL function executes is stored in an ** sqlite3_context object. ^A pointer to an sqlite3_context object ** is always first parameter to [application-defined SQL functions]. ** The application-defined SQL function implementation will pass this ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], ** [sqlite3_aggregate_context()], [sqlite3_user_data()], ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], ** and/or [sqlite3_set_auxdata()]. */ typedef struct sqlite3_context sqlite3_context; /* ** CAPI3REF: Binding Values To Prepared Statements ** KEYWORDS: {host parameter} {host parameters} {host parameter name} ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} ** ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, ** literals may be replaced by a [parameter] that matches one of following ** templates: ** **
    **
  • ? **
  • ?NNN **
  • :VVV **
  • @VVV **
  • $VVV **
** ** In the templates above, NNN represents an integer literal, ** and VVV represents an alphanumeric identifier.)^ ^The values of these ** parameters (also called "host parameter names" or "SQL parameters") ** can be set using the sqlite3_bind_*() routines defined here. ** ** ^The first argument to the sqlite3_bind_*() routines is always ** a pointer to the [sqlite3_stmt] object returned from ** [sqlite3_prepare_v2()] or its variants. ** ** ^The second argument is the index of the SQL parameter to be set. ** ^The leftmost SQL parameter has an index of 1. ^When the same named ** SQL parameter is used more than once, second and subsequent ** occurrences have the same index as the first occurrence. ** ^The index for named parameters can be looked up using the ** [sqlite3_bind_parameter_index()] API if desired. ^The index ** for "?NNN" parameters is the value of NNN. ** ^The NNN value must be between 1 and the [sqlite3_limit()] ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). ** ** ^The third argument is the value to bind to the parameter. ** ** ^(In those routines that have a fourth argument, its value is the ** number of bytes in the parameter. To be clear: the value is the ** number of bytes in the value, not the number of characters.)^ ** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16() ** is negative, then the length of the string is ** the number of bytes up to the first zero terminator. ** If the fourth parameter to sqlite3_bind_blob() is negative, then ** the behavior is undefined. ** If a non-negative fourth parameter is provided to sqlite3_bind_text() ** or sqlite3_bind_text16() then that parameter must be the byte offset ** where the NUL terminator would occur assuming the string were NUL ** terminated. If any NUL characters occur at byte offsets less than ** the value of the fourth parameter then the resulting string value will ** contain embedded NULs. The result of expressions involving strings ** with embedded NULs is undefined. ** ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or ** string after SQLite has finished with it. ^The destructor is called ** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(), ** sqlite3_bind_text(), or sqlite3_bind_text16() fails. ** ^If the fifth argument is ** the special value [SQLITE_STATIC], then SQLite assumes that the ** information is in static, unmanaged space and does not need to be freed. ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then ** SQLite makes its own private copy of the data immediately, before ** the sqlite3_bind_*() routine returns. ** ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory ** (just an integer to hold its size) while it is being processed. ** Zeroblobs are intended to serve as placeholders for BLOBs whose ** content is later written using ** [sqlite3_blob_open | incremental BLOB I/O] routines. ** ^A negative value for the zeroblob results in a zero-length BLOB. ** ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer ** for the [prepared statement] or with a prepared statement for which ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() ** routine is passed a [prepared statement] that has been finalized, the ** result is undefined and probably harmful. ** ** ^Bindings are not cleared by the [sqlite3_reset()] routine. ** ^Unbound parameters are interpreted as NULL. ** ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an ** [error code] if anything goes wrong. ** ^[SQLITE_RANGE] is returned if the parameter ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. ** ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. */ SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*)); SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); /* ** CAPI3REF: Number Of SQL Parameters ** ** ^This routine can be used to find the number of [SQL parameters] ** in a [prepared statement]. SQL parameters are tokens of the ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as ** placeholders for values that are [sqlite3_bind_blob | bound] ** to the parameters at a later time. ** ** ^(This routine actually returns the index of the largest (rightmost) ** parameter. For all forms except ?NNN, this will correspond to the ** number of unique parameters. If parameters of the ?NNN form are used, ** there may be gaps in the list.)^ ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_name()], and ** [sqlite3_bind_parameter_index()]. */ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); /* ** CAPI3REF: Name Of A Host Parameter ** ** ^The sqlite3_bind_parameter_name(P,N) interface returns ** the name of the N-th [SQL parameter] in the [prepared statement] P. ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" ** respectively. ** In other words, the initial ":" or "$" or "@" or "?" ** is included as part of the name.)^ ** ^Parameters of the form "?" without a following integer have no name ** and are referred to as "nameless" or "anonymous parameters". ** ** ^The first host parameter has an index of 1, not 0. ** ** ^If the value N is out of range or if the N-th parameter is ** nameless, then NULL is returned. ^The returned string is ** always in UTF-8 encoding even if the named parameter was ** originally specified as UTF-16 in [sqlite3_prepare16()] or ** [sqlite3_prepare16_v2()]. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. */ SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); /* ** CAPI3REF: Index Of A Parameter With A Given Name ** ** ^Return the index of an SQL parameter given its name. ^The ** index value returned is suitable for use as the second ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero ** is returned if no matching parameter is found. ^The parameter ** name must be given in UTF-8 even if the original statement ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. ** ** See also: [sqlite3_bind_blob|sqlite3_bind()], ** [sqlite3_bind_parameter_count()], and ** [sqlite3_bind_parameter_index()]. */ SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); /* ** CAPI3REF: Reset All Bindings On A Prepared Statement ** ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset ** the [sqlite3_bind_blob | bindings] on a [prepared statement]. ** ^Use this routine to reset all host parameters to NULL. */ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); /* ** CAPI3REF: Number Of Columns In A Result Set ** ** ^Return the number of columns in the result set returned by the ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL ** statement that does not return data (for example an [UPDATE]). ** ** See also: [sqlite3_data_count()] */ SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Column Names In A Result Set ** ** ^These routines return the name assigned to a particular column ** in the result set of a [SELECT] statement. ^The sqlite3_column_name() ** interface returns a pointer to a zero-terminated UTF-8 string ** and sqlite3_column_name16() returns a pointer to a zero-terminated ** UTF-16 string. ^The first parameter is the [prepared statement] ** that implements the [SELECT] statement. ^The second parameter is the ** column number. ^The leftmost column is number 0. ** ** ^The returned string pointer is valid until either the [prepared statement] ** is destroyed by [sqlite3_finalize()] or until the statement is automatically ** reprepared by the first call to [sqlite3_step()] for a particular run ** or until the next call to ** sqlite3_column_name() or sqlite3_column_name16() on the same column. ** ** ^If sqlite3_malloc() fails during the processing of either routine ** (for example during a conversion from UTF-8 to UTF-16) then a ** NULL pointer is returned. ** ** ^The name of a result column is the value of the "AS" clause for ** that column, if there is an AS clause. If there is no AS clause ** then the name of the column is unspecified and may change from ** one release of SQLite to the next. */ SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); /* ** CAPI3REF: Source Of Data In A Query Result ** ** ^These routines provide a means to determine the database, table, and ** table column that is the origin of a particular result column in ** [SELECT] statement. ** ^The name of the database or table or column can be returned as ** either a UTF-8 or UTF-16 string. ^The _database_ routines return ** the database name, the _table_ routines return the table name, and ** the origin_ routines return the column name. ** ^The returned string is valid until the [prepared statement] is destroyed ** using [sqlite3_finalize()] or until the statement is automatically ** reprepared by the first call to [sqlite3_step()] for a particular run ** or until the same information is requested ** again in a different encoding. ** ** ^The names returned are the original un-aliased names of the ** database, table, and column. ** ** ^The first argument to these interfaces is a [prepared statement]. ** ^These functions return information about the Nth result column returned by ** the statement, where N is the second function argument. ** ^The left-most column is column 0 for these routines. ** ** ^If the Nth column returned by the statement is an expression or ** subquery and is not a column value, then all of these functions return ** NULL. ^These routine might also return NULL if a memory allocation error ** occurs. ^Otherwise, they return the name of the attached database, table, ** or column that query result column was extracted from. ** ** ^As with all other SQLite APIs, those whose names end with "16" return ** UTF-16 encoded strings and the other functions return UTF-8. ** ** ^These APIs are only available if the library was compiled with the ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. ** ** If two or more threads call one or more of these routines against the same ** prepared statement and column at the same time then the results are ** undefined. ** ** If two or more threads call one or more ** [sqlite3_column_database_name | column metadata interfaces] ** for the same [prepared statement] and result column ** at the same time then the results are undefined. */ SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); /* ** CAPI3REF: Declared Datatype Of A Query Result ** ** ^(The first parameter is a [prepared statement]. ** If this statement is a [SELECT] statement and the Nth column of the ** returned result set of that [SELECT] is a table column (not an ** expression or subquery) then the declared type of the table ** column is returned.)^ ^If the Nth column of the result set is an ** expression or subquery, then a NULL pointer is returned. ** ^The returned string is always UTF-8 encoded. ** ** ^(For example, given the database schema: ** ** CREATE TABLE t1(c1 VARIANT); ** ** and the following statement to be compiled: ** ** SELECT c1 + 1, c1 FROM t1; ** ** this routine would return the string "VARIANT" for the second result ** column (i==1), and a NULL pointer for the first result column (i==0).)^ ** ** ^SQLite uses dynamic run-time typing. ^So just because a column ** is declared to contain a particular type does not mean that the ** data stored in that column is of the declared type. SQLite is ** strongly typed, but the typing is dynamic not static. ^Type ** is associated with individual values, not with the containers ** used to hold those values. */ SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); /* ** CAPI3REF: Evaluate An SQL Statement ** ** After a [prepared statement] has been prepared using either ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function ** must be called one or more times to evaluate the statement. ** ** The details of the behavior of the sqlite3_step() interface depend ** on whether the statement was prepared using the newer "v2" interface ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the ** new "v2" interface is recommended for new applications but the legacy ** interface will continue to be supported. ** ** ^In the legacy interface, the return value will be either [SQLITE_BUSY], ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. ** ^With the "v2" interface, any of the other [result codes] or ** [extended result codes] might be returned as well. ** ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the ** database locks it needs to do its job. ^If the statement is a [COMMIT] ** or occurs outside of an explicit transaction, then you can retry the ** statement. If the statement is not a [COMMIT] and occurs within an ** explicit transaction then you should rollback the transaction before ** continuing. ** ** ^[SQLITE_DONE] means that the statement has finished executing ** successfully. sqlite3_step() should not be called again on this virtual ** machine without first calling [sqlite3_reset()] to reset the virtual ** machine back to its initial state. ** ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW] ** is returned each time a new row of data is ready for processing by the ** caller. The values may be accessed using the [column access functions]. ** sqlite3_step() is called again to retrieve the next row of data. ** ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint ** violation) has occurred. sqlite3_step() should not be called again on ** the VM. More information may be found by calling [sqlite3_errmsg()]. ** ^With the legacy interface, a more specific error code (for example, ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) ** can be obtained by calling [sqlite3_reset()] on the ** [prepared statement]. ^In the "v2" interface, ** the more specific error code is returned directly by sqlite3_step(). ** ** [SQLITE_MISUSE] means that the this routine was called inappropriately. ** Perhaps it was called on a [prepared statement] that has ** already been [sqlite3_finalize | finalized] or on one that had ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could ** be the case that the same database connection is being used by two or ** more threads at the same moment in time. ** ** For all versions of SQLite up to and including 3.6.23.1, a call to ** [sqlite3_reset()] was required after sqlite3_step() returned anything ** other than [SQLITE_ROW] before any subsequent invocation of ** sqlite3_step(). Failure to reset the prepared statement using ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from ** sqlite3_step(). But after version 3.6.23.1, sqlite3_step() began ** calling [sqlite3_reset()] automatically in this circumstance rather ** than returning [SQLITE_MISUSE]. This is not considered a compatibility ** break because any application that ever receives an SQLITE_MISUSE error ** is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option ** can be used to restore the legacy behavior. ** ** Goofy Interface Alert: In the legacy interface, the sqlite3_step() ** API always returns a generic error code, [SQLITE_ERROR], following any ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the ** specific [error codes] that better describes the error. ** We admit that this is a goofy design. The problem has been fixed ** with the "v2" interface. If you prepare all of your SQL statements ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, ** then the more specific [error codes] are returned directly ** by sqlite3_step(). The use of the "v2" interface is recommended. */ SQLITE_API int sqlite3_step(sqlite3_stmt*); /* ** CAPI3REF: Number of columns in a result set ** ** ^The sqlite3_data_count(P) interface returns the number of columns in the ** current row of the result set of [prepared statement] P. ** ^If prepared statement P does not have results ready to return ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of ** interfaces) then sqlite3_data_count(P) returns 0. ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) ** will return non-zero if previous call to [sqlite3_step](P) returned ** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum] ** where it always returns zero since each step of that multi-step ** pragma returns 0 columns of data. ** ** See also: [sqlite3_column_count()] */ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); /* ** CAPI3REF: Fundamental Datatypes ** KEYWORDS: SQLITE_TEXT ** ** ^(Every value in SQLite has one of five fundamental datatypes: ** **
    **
  • 64-bit signed integer **
  • 64-bit IEEE floating point number **
  • string **
  • BLOB **
  • NULL **
)^ ** ** These constants are codes for each of those types. ** ** Note that the SQLITE_TEXT constant was also used in SQLite version 2 ** for a completely different meaning. Software that links against both ** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not ** SQLITE_TEXT. */ #define SQLITE_INTEGER 1 #define SQLITE_FLOAT 2 #define SQLITE_BLOB 4 #define SQLITE_NULL 5 #ifdef SQLITE_TEXT # undef SQLITE_TEXT #else # define SQLITE_TEXT 3 #endif #define SQLITE3_TEXT 3 /* ** CAPI3REF: Result Values From A Query ** KEYWORDS: {column access functions} ** ** These routines form the "result set" interface. ** ** ^These routines return information about a single column of the current ** result row of a query. ^In every case the first argument is a pointer ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] ** that was returned from [sqlite3_prepare_v2()] or one of its variants) ** and the second argument is the index of the column for which information ** should be returned. ^The leftmost column of the result set has the index 0. ** ^The number of columns in the result can be determined using ** [sqlite3_column_count()]. ** ** If the SQL statement does not currently point to a valid row, or if the ** column index is out of range, the result is undefined. ** These routines may only be called when the most recent call to ** [sqlite3_step()] has returned [SQLITE_ROW] and neither ** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. ** If any of these routines are called after [sqlite3_reset()] or ** [sqlite3_finalize()] or after [sqlite3_step()] has returned ** something other than [SQLITE_ROW], the results are undefined. ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] ** are called from a different thread while any of these routines ** are pending, then the results are undefined. ** ** ^The sqlite3_column_type() routine returns the ** [SQLITE_INTEGER | datatype code] for the initial data type ** of the result column. ^The returned value is one of [SQLITE_INTEGER], ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value ** returned by sqlite3_column_type() is only meaningful if no type ** conversions have occurred as described below. After a type conversion, ** the value returned by sqlite3_column_type() is undefined. Future ** versions of SQLite may change the behavior of sqlite3_column_type() ** following a type conversion. ** ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() ** routine returns the number of bytes in that BLOB or string. ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts ** the string to UTF-8 and then returns the number of bytes. ** ^If the result is a numeric value then sqlite3_column_bytes() uses ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns ** the number of bytes in that string. ** ^If the result is NULL, then sqlite3_column_bytes() returns zero. ** ** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() ** routine returns the number of bytes in that BLOB or string. ** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts ** the string to UTF-16 and then returns the number of bytes. ** ^If the result is a numeric value then sqlite3_column_bytes16() uses ** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns ** the number of bytes in that string. ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero. ** ** ^The values returned by [sqlite3_column_bytes()] and ** [sqlite3_column_bytes16()] do not include the zero terminators at the end ** of the string. ^For clarity: the values returned by ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of ** bytes in the string, not the number of characters. ** ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), ** even empty strings, are always zero-terminated. ^The return ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. ** ** ^The object returned by [sqlite3_column_value()] is an ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. ** If the [unprotected sqlite3_value] object returned by ** [sqlite3_column_value()] is used in any other way, including calls ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], ** or [sqlite3_value_bytes()], then the behavior is undefined. ** ** These routines attempt to convert the value where appropriate. ^For ** example, if the internal representation is FLOAT and a text result ** is requested, [sqlite3_snprintf()] is used internally to perform the ** conversion automatically. ^(The following table details the conversions ** that are applied: ** **
** **
Internal
Type
Requested
Type
Conversion ** **
NULL INTEGER Result is 0 **
NULL FLOAT Result is 0.0 **
NULL TEXT Result is NULL pointer **
NULL BLOB Result is NULL pointer **
INTEGER FLOAT Convert from integer to float **
INTEGER TEXT ASCII rendering of the integer **
INTEGER BLOB Same as INTEGER->TEXT **
FLOAT INTEGER Convert from float to integer **
FLOAT TEXT ASCII rendering of the float **
FLOAT BLOB Same as FLOAT->TEXT **
TEXT INTEGER Use atoi() **
TEXT FLOAT Use atof() **
TEXT BLOB No change **
BLOB INTEGER Convert to TEXT then use atoi() **
BLOB FLOAT Convert to TEXT then use atof() **
BLOB TEXT Add a zero terminator if needed **
**
)^ ** ** The table above makes reference to standard C library functions atoi() ** and atof(). SQLite does not really use these functions. It has its ** own equivalent internal routines. The atoi() and atof() names are ** used in the table for brevity and because they are familiar to most ** C programmers. ** ** Note that when type conversions occur, pointers returned by prior ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or ** sqlite3_column_text16() may be invalidated. ** Type conversions and pointer invalidations might occur ** in the following cases: ** **
    **
  • The initial content is a BLOB and sqlite3_column_text() or ** sqlite3_column_text16() is called. A zero-terminator might ** need to be added to the string.
  • **
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or ** sqlite3_column_text16() is called. The content must be converted ** to UTF-16.
  • **
  • The initial content is UTF-16 text and sqlite3_column_bytes() or ** sqlite3_column_text() is called. The content must be converted ** to UTF-8.
  • **
** ** ^Conversions between UTF-16be and UTF-16le are always done in place and do ** not invalidate a prior pointer, though of course the content of the buffer ** that the prior pointer references will have been modified. Other kinds ** of conversion are done in place when it is possible, but sometimes they ** are not possible and in those cases prior pointers are invalidated. ** ** The safest and easiest to remember policy is to invoke these routines ** in one of the following ways: ** **
    **
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • **
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • **
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • **
** ** In other words, you should call sqlite3_column_text(), ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result ** into the desired format, then invoke sqlite3_column_bytes() or ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls ** to sqlite3_column_text() or sqlite3_column_blob() with calls to ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() ** with calls to sqlite3_column_bytes(). ** ** ^The pointers returned are valid until a type conversion occurs as ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or ** [sqlite3_finalize()] is called. ^The memory space used to hold strings ** and BLOBs is freed automatically. Do not pass the pointers returned ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into ** [sqlite3_free()]. ** ** ^(If a memory allocation error occurs during the evaluation of any ** of these routines, a default value is returned. The default value ** is either the integer 0, the floating point number 0.0, or a NULL ** pointer. Subsequent calls to [sqlite3_errcode()] will return ** [SQLITE_NOMEM].)^ */ SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); /* ** CAPI3REF: Destroy A Prepared Statement Object ** ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. ** ^If the most recent evaluation of the statement encountered no errors ** or if the statement is never been evaluated, then sqlite3_finalize() returns ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then ** sqlite3_finalize(S) returns the appropriate [error code] or ** [extended error code]. ** ** ^The sqlite3_finalize(S) routine can be called at any point during ** the life cycle of [prepared statement] S: ** before statement S is ever evaluated, after ** one or more calls to [sqlite3_reset()], or after any call ** to [sqlite3_step()] regardless of whether or not the statement has ** completed execution. ** ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. ** ** The application must finalize every [prepared statement] in order to avoid ** resource leaks. It is a grievous error for the application to try to use ** a prepared statement after it has been finalized. Any use of a prepared ** statement after it has been finalized can result in undefined and ** undesirable behavior such as segfaults and heap corruption. */ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); /* ** CAPI3REF: Reset A Prepared Statement Object ** ** The sqlite3_reset() function is called to reset a [prepared statement] ** object back to its initial state, ready to be re-executed. ** ^Any SQL statement variables that had values bound to them using ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. ** Use [sqlite3_clear_bindings()] to reset the bindings. ** ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S ** back to the beginning of its program. ** ** ^If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], ** or if [sqlite3_step(S)] has never before been called on S, ** then [sqlite3_reset(S)] returns [SQLITE_OK]. ** ** ^If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S indicated an error, then ** [sqlite3_reset(S)] returns an appropriate [error code]. ** ** ^The [sqlite3_reset(S)] interface does not change the values ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. */ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); /* ** CAPI3REF: Create Or Redefine SQL Functions ** KEYWORDS: {function creation routines} ** KEYWORDS: {application-defined SQL function} ** KEYWORDS: {application-defined SQL functions} ** ** ^These functions (collectively known as "function creation routines") ** are used to add SQL functions or aggregates or to redefine the behavior ** of existing SQL functions or aggregates. The only differences between ** these routines are the text encoding expected for ** the second parameter (the name of the function being created) ** and the presence or absence of a destructor callback for ** the application data pointer. ** ** ^The first parameter is the [database connection] to which the SQL ** function is to be added. ^If an application uses more than one database ** connection then application-defined SQL functions must be added ** to each database connection separately. ** ** ^The second parameter is the name of the SQL function to be created or ** redefined. ^The length of the name is limited to 255 bytes in a UTF-8 ** representation, exclusive of the zero-terminator. ^Note that the name ** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. ** ^Any attempt to create a function with a longer name ** will result in [SQLITE_MISUSE] being returned. ** ** ^The third parameter (nArg) ** is the number of arguments that the SQL function or ** aggregate takes. ^If this parameter is -1, then the SQL function or ** aggregate may take any number of arguments between 0 and the limit ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third ** parameter is less than -1 or greater than 127 then the behavior is ** undefined. ** ** ^The fourth parameter, eTextRep, specifies what ** [SQLITE_UTF8 | text encoding] this SQL function prefers for ** its parameters. Every SQL function implementation must be able to work ** with UTF-8, UTF-16le, or UTF-16be. But some implementations may be ** more efficient with one encoding than another. ^An application may ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple ** times with the same function but with different values of eTextRep. ** ^When multiple implementations of the same function are available, SQLite ** will pick the one that involves the least amount of data conversion. ** If there is only a single implementation which does not care what text ** encoding is used, then the fourth argument should be [SQLITE_ANY]. ** ** ^(The fifth parameter is an arbitrary pointer. The implementation of the ** function can gain access to this pointer using [sqlite3_user_data()].)^ ** ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are ** pointers to C-language functions that implement the SQL function or ** aggregate. ^A scalar SQL function requires an implementation of the xFunc ** callback only; NULL pointers must be passed as the xStep and xFinal ** parameters. ^An aggregate SQL function requires an implementation of xStep ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing ** SQL function or aggregate, pass NULL pointers for all three function ** callbacks. ** ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL, ** then it is destructor for the application data pointer. ** The destructor is invoked when the function is deleted, either by being ** overloaded or when the database connection closes.)^ ** ^The destructor is also invoked if the call to ** sqlite3_create_function_v2() fails. ** ^When the destructor callback of the tenth parameter is invoked, it ** is passed a single argument which is a copy of the application data ** pointer which was the fifth parameter to sqlite3_create_function_v2(). ** ** ^It is permitted to register multiple implementations of the same ** functions with the same name but with either differing numbers of ** arguments or differing preferred text encodings. ^SQLite will use ** the implementation that most closely matches the way in which the ** SQL function is used. ^A function implementation with a non-negative ** nArg parameter is a better match than a function implementation with ** a negative nArg. ^A function where the preferred text encoding ** matches the database encoding is a better ** match than a function where the encoding is different. ** ^A function where the encoding difference is between UTF16le and UTF16be ** is a closer match than a function where the encoding difference is ** between UTF8 and UTF16. ** ** ^Built-in functions may be overloaded by new application-defined functions. ** ** ^An application-defined function is permitted to call other ** SQLite interfaces. However, such calls must not ** close the database connection nor finalize or reset the prepared ** statement in which the function is running. */ SQLITE_API int sqlite3_create_function( sqlite3 *db, const char *zFunctionName, int nArg, int eTextRep, void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ); SQLITE_API int sqlite3_create_function16( sqlite3 *db, const void *zFunctionName, int nArg, int eTextRep, void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*) ); SQLITE_API int sqlite3_create_function_v2( sqlite3 *db, const char *zFunctionName, int nArg, int eTextRep, void *pApp, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*), void(*xDestroy)(void*) ); /* ** CAPI3REF: Text Encodings ** ** These constant define integer codes that represent the various ** text encodings supported by SQLite. */ #define SQLITE_UTF8 1 #define SQLITE_UTF16LE 2 #define SQLITE_UTF16BE 3 #define SQLITE_UTF16 4 /* Use native byte order */ #define SQLITE_ANY 5 /* sqlite3_create_function only */ #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ /* ** CAPI3REF: Deprecated Functions ** DEPRECATED ** ** These functions are [deprecated]. In order to maintain ** backwards compatibility with older code, these functions continue ** to be supported. However, new applications should avoid ** the use of these functions. To help encourage people to avoid ** using these functions, we are not going to tell you what they do. */ #ifndef SQLITE_OMIT_DEPRECATED SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); #endif /* ** CAPI3REF: Obtaining SQL Function Parameter Values ** ** The C-language implementation of SQL functions and aggregates uses ** this set of interface routines to access the parameter values on ** the function or aggregate. ** ** The xFunc (for scalar functions) or xStep (for aggregates) parameters ** to [sqlite3_create_function()] and [sqlite3_create_function16()] ** define callbacks that implement the SQL functions and aggregates. ** The 3rd parameter to these callbacks is an array of pointers to ** [protected sqlite3_value] objects. There is one [sqlite3_value] object for ** each parameter to the SQL function. These routines are used to ** extract values from the [sqlite3_value] objects. ** ** These routines work only with [protected sqlite3_value] objects. ** Any attempt to use these routines on an [unprotected sqlite3_value] ** object results in undefined behavior. ** ** ^These routines work just like the corresponding [column access functions] ** except that these routines take a single [protected sqlite3_value] object ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. ** ** ^The sqlite3_value_text16() interface extracts a UTF-16 string ** in the native byte-order of the host machine. ^The ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces ** extract UTF-16 strings as big-endian and little-endian respectively. ** ** ^(The sqlite3_value_numeric_type() interface attempts to apply ** numeric affinity to the value. This means that an attempt is ** made to convert the value to an integer or floating point. If ** such a conversion is possible without loss of information (in other ** words, if the value is a string that looks like a number) ** then the conversion is performed. Otherwise no conversion occurs. ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or ** [sqlite3_value_text16()] can be invalidated by a subsequent call to ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], ** or [sqlite3_value_text16()]. ** ** These routines must be called from the same thread as ** the SQL function that supplied the [sqlite3_value*] parameters. */ SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); SQLITE_API int sqlite3_value_bytes(sqlite3_value*); SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); SQLITE_API double sqlite3_value_double(sqlite3_value*); SQLITE_API int sqlite3_value_int(sqlite3_value*); SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); SQLITE_API int sqlite3_value_type(sqlite3_value*); SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); /* ** CAPI3REF: Obtain Aggregate Function Context ** ** Implementations of aggregate SQL functions use this ** routine to allocate memory for storing their state. ** ** ^The first time the sqlite3_aggregate_context(C,N) routine is called ** for a particular aggregate function, SQLite ** allocates N of memory, zeroes out that memory, and returns a pointer ** to the new memory. ^On second and subsequent calls to ** sqlite3_aggregate_context() for the same aggregate function instance, ** the same buffer is returned. Sqlite3_aggregate_context() is normally ** called once for each invocation of the xStep callback and then one ** last time when the xFinal callback is invoked. ^(When no rows match ** an aggregate query, the xStep() callback of the aggregate function ** implementation is never called and xFinal() is called exactly once. ** In those cases, sqlite3_aggregate_context() might be called for the ** first time from within xFinal().)^ ** ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is ** less than or equal to zero or if a memory allocate error occurs. ** ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is ** determined by the N parameter on first successful call. Changing the ** value of N in subsequent call to sqlite3_aggregate_context() within ** the same aggregate function instance will not resize the memory ** allocation.)^ ** ** ^SQLite automatically frees the memory allocated by ** sqlite3_aggregate_context() when the aggregate query concludes. ** ** The first parameter must be a copy of the ** [sqlite3_context | SQL function context] that is the first parameter ** to the xStep or xFinal callback routine that implements the aggregate ** function. ** ** This routine must be called from the same thread in which ** the aggregate SQL function is running. */ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); /* ** CAPI3REF: User Data For Functions ** ** ^The sqlite3_user_data() interface returns a copy of ** the pointer that was the pUserData parameter (the 5th parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. ** ** This routine must be called from the same thread in which ** the application-defined function is running. */ SQLITE_API void *sqlite3_user_data(sqlite3_context*); /* ** CAPI3REF: Database Connection For Functions ** ** ^The sqlite3_context_db_handle() interface returns a copy of ** the pointer to the [database connection] (the 1st parameter) ** of the [sqlite3_create_function()] ** and [sqlite3_create_function16()] routines that originally ** registered the application defined function. */ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); /* ** CAPI3REF: Function Auxiliary Data ** ** The following two functions may be used by scalar SQL functions to ** associate metadata with argument values. If the same value is passed to ** multiple invocations of the same SQL function during query execution, under ** some circumstances the associated metadata may be preserved. This may ** be used, for example, to add a regular-expression matching scalar ** function. The compiled version of the regular expression is stored as ** metadata associated with the SQL value passed as the regular expression ** pattern. The compiled regular expression can be reused on multiple ** invocations of the same function so that the original pattern string ** does not need to be recompiled on each invocation. ** ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata ** associated by the sqlite3_set_auxdata() function with the Nth argument ** value to the application-defined function. ^If no metadata has been ever ** been set for the Nth argument of the function, or if the corresponding ** function parameter has changed since the meta-data was set, ** then sqlite3_get_auxdata() returns a NULL pointer. ** ** ^The sqlite3_set_auxdata() interface saves the metadata ** pointed to by its 3rd parameter as the metadata for the N-th ** argument of the application-defined function. Subsequent ** calls to sqlite3_get_auxdata() might return this data, if it has ** not been destroyed. ** ^If it is not NULL, SQLite will invoke the destructor ** function given by the 4th parameter to sqlite3_set_auxdata() on ** the metadata when the corresponding function parameter changes ** or when the SQL statement completes, whichever comes first. ** ** SQLite is free to call the destructor and drop metadata on any ** parameter of any function at any time. ^The only guarantee is that ** the destructor will be called before the metadata is dropped. ** ** ^(In practice, metadata is preserved between function calls for ** expressions that are constant at compile time. This includes literal ** values and [parameters].)^ ** ** These routines must be called from the same thread in which ** the SQL function is running. */ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); /* ** CAPI3REF: Constants Defining Special Destructor Behavior ** ** These are special values for the destructor that is passed in as the ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor ** argument is SQLITE_STATIC, it means that the content pointer is constant ** and will never change. It does not need to be destroyed. ^The ** SQLITE_TRANSIENT value means that the content will likely change in ** the near future and that SQLite should make its own private copy of ** the content before returning. ** ** The typedef is necessary to work around problems in certain ** C++ compilers. See ticket #2191. */ typedef void (*sqlite3_destructor_type)(void*); #define SQLITE_STATIC ((sqlite3_destructor_type)0) #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) /* ** CAPI3REF: Setting The Result Of An SQL Function ** ** These routines are used by the xFunc or xFinal callbacks that ** implement SQL functions and aggregates. See ** [sqlite3_create_function()] and [sqlite3_create_function16()] ** for additional information. ** ** These functions work very much like the [parameter binding] family of ** functions used to bind values to host parameters in prepared statements. ** Refer to the [SQL parameter] documentation for additional information. ** ** ^The sqlite3_result_blob() interface sets the result from ** an application-defined function to be the BLOB whose content is pointed ** to by the second parameter and which is N bytes long where N is the ** third parameter. ** ** ^The sqlite3_result_zeroblob() interfaces set the result of ** the application-defined function to be a BLOB containing all zero ** bytes and N bytes in size, where N is the value of the 2nd parameter. ** ** ^The sqlite3_result_double() interface sets the result from ** an application-defined function to be a floating point value specified ** by its 2nd argument. ** ** ^The sqlite3_result_error() and sqlite3_result_error16() functions ** cause the implemented SQL function to throw an exception. ** ^SQLite uses the string pointed to by the ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() ** as the text of an error message. ^SQLite interprets the error ** message string from sqlite3_result_error() as UTF-8. ^SQLite ** interprets the string from sqlite3_result_error16() as UTF-16 in native ** byte order. ^If the third parameter to sqlite3_result_error() ** or sqlite3_result_error16() is negative then SQLite takes as the error ** message all text up through the first zero character. ** ^If the third parameter to sqlite3_result_error() or ** sqlite3_result_error16() is non-negative then SQLite takes that many ** bytes (not characters) from the 2nd parameter as the error message. ** ^The sqlite3_result_error() and sqlite3_result_error16() ** routines make a private copy of the error message text before ** they return. Hence, the calling function can deallocate or ** modify the text after they return without harm. ** ^The sqlite3_result_error_code() function changes the error code ** returned by SQLite as a result of an error in a function. ^By default, ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. ** ** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an ** error indicating that a string or BLOB is too long to represent. ** ** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an ** error indicating that a memory allocation failed. ** ** ^The sqlite3_result_int() interface sets the return value ** of the application-defined function to be the 32-bit signed integer ** value given in the 2nd argument. ** ^The sqlite3_result_int64() interface sets the return value ** of the application-defined function to be the 64-bit signed integer ** value given in the 2nd argument. ** ** ^The sqlite3_result_null() interface sets the return value ** of the application-defined function to be NULL. ** ** ^The sqlite3_result_text(), sqlite3_result_text16(), ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces ** set the return value of the application-defined function to be ** a text string which is represented as UTF-8, UTF-16 native byte order, ** UTF-16 little endian, or UTF-16 big endian, respectively. ** ^SQLite takes the text result from the application from ** the 2nd parameter of the sqlite3_result_text* interfaces. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is negative, then SQLite takes result text from the 2nd parameter ** through the first zero character. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is non-negative, then as many bytes (not characters) of the text ** pointed to by the 2nd parameter are taken as the application-defined ** function result. If the 3rd parameter is non-negative, then it ** must be the byte offset into the string where the NUL terminator would ** appear if the string where NUL terminated. If any NUL characters occur ** in the string at a byte offset that is less than the value of the 3rd ** parameter, then the resulting string will contain embedded NULs and the ** result of expressions operating on strings with embedded NULs is undefined. ** ^If the 4th parameter to the sqlite3_result_text* interfaces ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that ** function as the destructor on the text or BLOB result when it has ** finished using that result. ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite ** assumes that the text or BLOB result is in constant space and does not ** copy the content of the parameter nor call a destructor on the content ** when it has finished using that result. ** ^If the 4th parameter to the sqlite3_result_text* interfaces ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT ** then SQLite makes a copy of the result into space obtained from ** from [sqlite3_malloc()] before it returns. ** ** ^The sqlite3_result_value() interface sets the result of ** the application-defined function to be a copy the ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] ** so that the [sqlite3_value] specified in the parameter may change or ** be deallocated after sqlite3_result_value() returns without harm. ** ^A [protected sqlite3_value] object may always be used where an ** [unprotected sqlite3_value] object is required, so either ** kind of [sqlite3_value] object can be used with this interface. ** ** If these routines are called from within the different thread ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. */ SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); SQLITE_API void sqlite3_result_double(sqlite3_context*, double); SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); SQLITE_API void sqlite3_result_int(sqlite3_context*, int); SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); SQLITE_API void sqlite3_result_null(sqlite3_context*); SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); /* ** CAPI3REF: Define New Collating Sequences ** ** ^These functions add, remove, or modify a [collation] associated ** with the [database connection] specified as the first argument. ** ** ^The name of the collation is a UTF-8 string ** for sqlite3_create_collation() and sqlite3_create_collation_v2() ** and a UTF-16 string in native byte order for sqlite3_create_collation16(). ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are ** considered to be the same name. ** ** ^(The third argument (eTextRep) must be one of the constants: **
    **
  • [SQLITE_UTF8], **
  • [SQLITE_UTF16LE], **
  • [SQLITE_UTF16BE], **
  • [SQLITE_UTF16], or **
  • [SQLITE_UTF16_ALIGNED]. **
)^ ** ^The eTextRep argument determines the encoding of strings passed ** to the collating function callback, xCallback. ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep ** force strings to be UTF16 with native byte order. ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin ** on an even byte address. ** ** ^The fourth argument, pArg, is an application data pointer that is passed ** through as the first argument to the collating function callback. ** ** ^The fifth argument, xCallback, is a pointer to the collating function. ** ^Multiple collating functions can be registered using the same name but ** with different eTextRep parameters and SQLite will use whichever ** function requires the least amount of data transformation. ** ^If the xCallback argument is NULL then the collating function is ** deleted. ^When all collating functions having the same name are deleted, ** that collation is no longer usable. ** ** ^The collating function callback is invoked with a copy of the pArg ** application data pointer and with two strings in the encoding specified ** by the eTextRep argument. The collating function must return an ** integer that is negative, zero, or positive ** if the first string is less than, equal to, or greater than the second, ** respectively. A collating function must always return the same answer ** given the same inputs. If two or more collating functions are registered ** to the same collation name (using different eTextRep values) then all ** must give an equivalent answer when invoked with equivalent strings. ** The collating function must obey the following properties for all ** strings A, B, and C: ** **
    **
  1. If A==B then B==A. **
  2. If A==B and B==C then A==C. **
  3. If A<B THEN B>A. **
  4. If A<B and B<C then A<C. **
** ** If a collating function fails any of the above constraints and that ** collating function is registered and used, then the behavior of SQLite ** is undefined. ** ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() ** with the addition that the xDestroy callback is invoked on pArg when ** the collating function is deleted. ** ^Collating functions are deleted when they are overridden by later ** calls to the collation creation functions or when the ** [database connection] is closed using [sqlite3_close()]. ** ** ^The xDestroy callback is not called if the ** sqlite3_create_collation_v2() function fails. Applications that invoke ** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should ** check the return code and dispose of the application data pointer ** themselves rather than expecting SQLite to deal with it for them. ** This is different from every other SQLite interface. The inconsistency ** is unfortunate but cannot be changed without breaking backwards ** compatibility. ** ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. */ SQLITE_API int sqlite3_create_collation( sqlite3*, const char *zName, int eTextRep, void *pArg, int(*xCompare)(void*,int,const void*,int,const void*) ); SQLITE_API int sqlite3_create_collation_v2( sqlite3*, const char *zName, int eTextRep, void *pArg, int(*xCompare)(void*,int,const void*,int,const void*), void(*xDestroy)(void*) ); SQLITE_API int sqlite3_create_collation16( sqlite3*, const void *zName, int eTextRep, void *pArg, int(*xCompare)(void*,int,const void*,int,const void*) ); /* ** CAPI3REF: Collation Needed Callbacks ** ** ^To avoid having to register all collation sequences before a database ** can be used, a single callback function may be registered with the ** [database connection] to be invoked whenever an undefined collation ** sequence is required. ** ** ^If the function is registered using the sqlite3_collation_needed() API, ** then it is passed the names of undefined collation sequences as strings ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, ** the names are passed as UTF-16 in machine native byte order. ** ^A call to either function replaces the existing collation-needed callback. ** ** ^(When the callback is invoked, the first argument passed is a copy ** of the second argument to sqlite3_collation_needed() or ** sqlite3_collation_needed16(). The second argument is the database ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation ** sequence function required. The fourth parameter is the name of the ** required collation sequence.)^ ** ** The callback function should register the desired collation using ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or ** [sqlite3_create_collation_v2()]. */ SQLITE_API int sqlite3_collation_needed( sqlite3*, void*, void(*)(void*,sqlite3*,int eTextRep,const char*) ); SQLITE_API int sqlite3_collation_needed16( sqlite3*, void*, void(*)(void*,sqlite3*,int eTextRep,const void*) ); #ifdef SQLITE_HAS_CODEC /* ** Specify the key for an encrypted database. This routine should be ** called right after sqlite3_open(). ** ** The code to implement this API is not available in the public release ** of SQLite. */ SQLITE_API int sqlite3_key( sqlite3 *db, /* Database to be rekeyed */ const void *pKey, int nKey /* The key */ ); /* ** Change the key on an open database. If the current database is not ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the ** database is decrypted. ** ** The code to implement this API is not available in the public release ** of SQLite. */ SQLITE_API int sqlite3_rekey( sqlite3 *db, /* Database to be rekeyed */ const void *pKey, int nKey /* The new key */ ); /* ** Specify the activation key for a SEE database. Unless ** activated, none of the SEE routines will work. */ SQLITE_API void sqlite3_activate_see( const char *zPassPhrase /* Activation phrase */ ); #endif #ifdef SQLITE_ENABLE_CEROD /* ** Specify the activation key for a CEROD database. Unless ** activated, none of the CEROD routines will work. */ SQLITE_API void sqlite3_activate_cerod( const char *zPassPhrase /* Activation phrase */ ); #endif /* ** CAPI3REF: Suspend Execution For A Short Time ** ** The sqlite3_sleep() function causes the current thread to suspend execution ** for at least a number of milliseconds specified in its parameter. ** ** If the operating system does not support sleep requests with ** millisecond time resolution, then the time will be rounded up to ** the nearest second. The number of milliseconds of sleep actually ** requested from the operating system is returned. ** ** ^SQLite implements this interface by calling the xSleep() ** method of the default [sqlite3_vfs] object. If the xSleep() method ** of the default VFS is not implemented correctly, or not implemented at ** all, then the behavior of sqlite3_sleep() may deviate from the description ** in the previous paragraphs. */ SQLITE_API int sqlite3_sleep(int); /* ** CAPI3REF: Name Of The Folder Holding Temporary Files ** ** ^(If this global variable is made to point to a string which is ** the name of a folder (a.k.a. directory), then all temporary files ** created by SQLite when using a built-in [sqlite3_vfs | VFS] ** will be placed in that directory.)^ ^If this variable ** is a NULL pointer, then SQLite performs a search for an appropriate ** temporary file directory. ** ** It is not safe to read or modify this variable in more than one ** thread at a time. It is not safe to read or modify this variable ** if a [database connection] is being used at the same time in a separate ** thread. ** It is intended that this variable be set once ** as part of process initialization and before any SQLite interface ** routines have been called and that this variable remain unchanged ** thereafter. ** ** ^The [temp_store_directory pragma] may modify this variable and cause ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, ** the [temp_store_directory pragma] always assumes that any string ** that this variable points to is held in memory obtained from ** [sqlite3_malloc] and the pragma may attempt to free that memory ** using [sqlite3_free]. ** Hence, if this variable is modified directly, either it should be ** made NULL or made to point to memory obtained from [sqlite3_malloc] ** or else the use of the [temp_store_directory pragma] should be avoided. ** ** Note to Windows Runtime users: The temporary directory must be set ** prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various ** features that require the use of temporary files may fail. Here is an ** example of how to do this using C++ with the Windows Runtime: ** **
** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
**       TemporaryFolder->Path->Data();
** char zPathBuf[MAX_PATH + 1];
** memset(zPathBuf, 0, sizeof(zPathBuf));
** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
**       NULL, NULL);
** sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
** 
*/ SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; /* ** CAPI3REF: Name Of The Folder Holding Database Files ** ** ^(If this global variable is made to point to a string which is ** the name of a folder (a.k.a. directory), then all database files ** specified with a relative pathname and created or accessed by ** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed ** to be relative to that directory.)^ ^If this variable is a NULL ** pointer, then SQLite assumes that all database files specified ** with a relative pathname are relative to the current directory ** for the process. Only the windows VFS makes use of this global ** variable; it is ignored by the unix VFS. ** ** Changing the value of this variable while a database connection is ** open can result in a corrupt database. ** ** It is not safe to read or modify this variable in more than one ** thread at a time. It is not safe to read or modify this variable ** if a [database connection] is being used at the same time in a separate ** thread. ** It is intended that this variable be set once ** as part of process initialization and before any SQLite interface ** routines have been called and that this variable remain unchanged ** thereafter. ** ** ^The [data_store_directory pragma] may modify this variable and cause ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, ** the [data_store_directory pragma] always assumes that any string ** that this variable points to is held in memory obtained from ** [sqlite3_malloc] and the pragma may attempt to free that memory ** using [sqlite3_free]. ** Hence, if this variable is modified directly, either it should be ** made NULL or made to point to memory obtained from [sqlite3_malloc] ** or else the use of the [data_store_directory pragma] should be avoided. */ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory; /* ** CAPI3REF: Test For Auto-Commit Mode ** KEYWORDS: {autocommit mode} ** ** ^The sqlite3_get_autocommit() interface returns non-zero or ** zero if the given database connection is or is not in autocommit mode, ** respectively. ^Autocommit mode is on by default. ** ^Autocommit mode is disabled by a [BEGIN] statement. ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. ** ** If certain kinds of errors occur on a statement within a multi-statement ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the ** transaction might be rolled back automatically. The only way to ** find out whether SQLite automatically rolled back the transaction after ** an error is to use this function. ** ** If another thread changes the autocommit status of the database ** connection while this routine is running, then the return value ** is undefined. */ SQLITE_API int sqlite3_get_autocommit(sqlite3*); /* ** CAPI3REF: Find The Database Handle Of A Prepared Statement ** ** ^The sqlite3_db_handle interface returns the [database connection] handle ** to which a [prepared statement] belongs. ^The [database connection] ** returned by sqlite3_db_handle is the same [database connection] ** that was the first argument ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to ** create the statement in the first place. */ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); /* ** CAPI3REF: Return The Filename For A Database Connection ** ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename ** associated with database N of connection D. ^The main database file ** has the name "main". If there is no attached database N on the database ** connection D, or if database N is a temporary or in-memory database, then ** a NULL pointer is returned. ** ** ^The filename returned by this function is the output of the ** xFullPathname method of the [VFS]. ^In other words, the filename ** will be an absolute pathname, even if the filename used ** to open the database originally was a URI or relative pathname. */ SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); /* ** CAPI3REF: Determine if a database is read-only ** ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N ** of connection D is read-only, 0 if it is read/write, or -1 if N is not ** the name of a database on connection D. */ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); /* ** CAPI3REF: Find the next prepared statement ** ** ^This interface returns a pointer to the next [prepared statement] after ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL ** then this interface returns a pointer to the first prepared statement ** associated with the database connection pDb. ^If no prepared statement ** satisfies the conditions of this routine, it returns NULL. ** ** The [database connection] pointer D in a call to ** [sqlite3_next_stmt(D,S)] must refer to an open database ** connection and in particular must not be a NULL pointer. */ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); /* ** CAPI3REF: Commit And Rollback Notification Callbacks ** ** ^The sqlite3_commit_hook() interface registers a callback ** function to be invoked whenever a transaction is [COMMIT | committed]. ** ^Any callback set by a previous call to sqlite3_commit_hook() ** for the same database connection is overridden. ** ^The sqlite3_rollback_hook() interface registers a callback ** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. ** ^Any callback set by a previous call to sqlite3_rollback_hook() ** for the same database connection is overridden. ** ^The pArg argument is passed through to the callback. ** ^If the callback on a commit hook function returns non-zero, ** then the commit is converted into a rollback. ** ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions ** return the P argument from the previous call of the same function ** on the same [database connection] D, or NULL for ** the first call for each function on D. ** ** The commit and rollback hook callbacks are not reentrant. ** The callback implementation must not do anything that will modify ** the database connection that invoked the callback. Any actions ** to modify the database connection must be deferred until after the ** completion of the [sqlite3_step()] call that triggered the commit ** or rollback hook in the first place. ** Note that running any other SQL statements, including SELECT statements, ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify ** the database connections for the meaning of "modify" in this paragraph. ** ** ^Registering a NULL function disables the callback. ** ** ^When the commit hook callback routine returns zero, the [COMMIT] ** operation is allowed to continue normally. ^If the commit hook ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. ** ^The rollback hook is invoked on a rollback that results from a commit ** hook returning non-zero, just as it would be with any other rollback. ** ** ^For the purposes of this API, a transaction is said to have been ** rolled back if an explicit "ROLLBACK" statement is executed, or ** an error or constraint causes an implicit rollback to occur. ** ^The rollback callback is not invoked if a transaction is ** automatically rolled back because the database connection is closed. ** ** See also the [sqlite3_update_hook()] interface. */ SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); /* ** CAPI3REF: Data Change Notification Callbacks ** ** ^The sqlite3_update_hook() interface registers a callback function ** with the [database connection] identified by the first argument ** to be invoked whenever a row is updated, inserted or deleted. ** ^Any callback set by a previous call to this function ** for the same database connection is overridden. ** ** ^The second argument is a pointer to the function to invoke when a ** row is updated, inserted or deleted. ** ^The first argument to the callback is a copy of the third argument ** to sqlite3_update_hook(). ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], ** or [SQLITE_UPDATE], depending on the operation that caused the callback ** to be invoked. ** ^The third and fourth arguments to the callback contain pointers to the ** database and table name containing the affected row. ** ^The final callback parameter is the [rowid] of the row. ** ^In the case of an update, this is the [rowid] after the update takes place. ** ** ^(The update hook is not invoked when internal system tables are ** modified (i.e. sqlite_master and sqlite_sequence).)^ ** ** ^In the current implementation, the update hook ** is not invoked when duplication rows are deleted because of an ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook ** invoked when rows are deleted using the [truncate optimization]. ** The exceptions defined in this paragraph might change in a future ** release of SQLite. ** ** The update hook implementation must not do anything that will modify ** the database connection that invoked the update hook. Any actions ** to modify the database connection must be deferred until after the ** completion of the [sqlite3_step()] call that triggered the update hook. ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their ** database connections for the meaning of "modify" in this paragraph. ** ** ^The sqlite3_update_hook(D,C,P) function ** returns the P argument from the previous call ** on the same [database connection] D, or NULL for ** the first call on D. ** ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] ** interfaces. */ SQLITE_API void *sqlite3_update_hook( sqlite3*, void(*)(void *,int ,char const *,char const *,sqlite3_int64), void* ); /* ** CAPI3REF: Enable Or Disable Shared Pager Cache ** ** ^(This routine enables or disables the sharing of the database cache ** and schema data structures between [database connection | connections] ** to the same database. Sharing is enabled if the argument is true ** and disabled if the argument is false.)^ ** ** ^Cache sharing is enabled and disabled for an entire process. ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, ** sharing was enabled or disabled for each thread separately. ** ** ^(The cache sharing mode set by this interface effects all subsequent ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. ** Existing database connections continue use the sharing mode ** that was in effect at the time they were opened.)^ ** ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled ** successfully. An [error code] is returned otherwise.)^ ** ** ^Shared cache is disabled by default. But this might change in ** future releases of SQLite. Applications that care about shared ** cache setting should set it explicitly. ** ** This interface is threadsafe on processors where writing a ** 32-bit integer is atomic. ** ** See Also: [SQLite Shared-Cache Mode] */ SQLITE_API int sqlite3_enable_shared_cache(int); /* ** CAPI3REF: Attempt To Free Heap Memory ** ** ^The sqlite3_release_memory() interface attempts to free N bytes ** of heap memory by deallocating non-essential memory allocations ** held by the database library. Memory used to cache database ** pages to improve performance is an example of non-essential memory. ** ^sqlite3_release_memory() returns the number of bytes actually freed, ** which might be more or less than the amount requested. ** ^The sqlite3_release_memory() routine is a no-op returning zero ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. ** ** See also: [sqlite3_db_release_memory()] */ SQLITE_API int sqlite3_release_memory(int); /* ** CAPI3REF: Free Memory Used By A Database Connection ** ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap ** memory as possible from database connection D. Unlike the ** [sqlite3_release_memory()] interface, this interface is effect even ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is ** omitted. ** ** See also: [sqlite3_release_memory()] */ SQLITE_API int sqlite3_db_release_memory(sqlite3*); /* ** CAPI3REF: Impose A Limit On Heap Size ** ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the ** soft limit on the amount of heap memory that may be allocated by SQLite. ** ^SQLite strives to keep heap memory utilization below the soft heap ** limit by reducing the number of pages held in the page cache ** as heap memory usages approaches the limit. ** ^The soft heap limit is "soft" because even though SQLite strives to stay ** below the limit, it will exceed the limit rather than generate ** an [SQLITE_NOMEM] error. In other words, the soft heap limit ** is advisory only. ** ** ^The return value from sqlite3_soft_heap_limit64() is the size of ** the soft heap limit prior to the call, or negative in the case of an ** error. ^If the argument N is negative ** then no change is made to the soft heap limit. Hence, the current ** size of the soft heap limit can be determined by invoking ** sqlite3_soft_heap_limit64() with a negative argument. ** ** ^If the argument N is zero then the soft heap limit is disabled. ** ** ^(The soft heap limit is not enforced in the current implementation ** if one or more of following conditions are true: ** **
    **
  • The soft heap limit is set to zero. **
  • Memory accounting is disabled using a combination of the ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. **
  • An alternative page cache implementation is specified using ** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...). **
  • The page cache allocates from its own memory pool supplied ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than ** from the heap. **
)^ ** ** Beginning with SQLite version 3.7.3, the soft heap limit is enforced ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] ** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], ** the soft heap limit is enforced on every memory allocation. Without ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced ** when memory is allocated by the page cache. Testing suggests that because ** the page cache is the predominate memory user in SQLite, most ** applications will achieve adequate soft heap limit enforcement without ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. ** ** The circumstances under which SQLite will enforce the soft heap limit may ** changes in future releases of SQLite. */ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); /* ** CAPI3REF: Deprecated Soft Heap Limit Interface ** DEPRECATED ** ** This is a deprecated version of the [sqlite3_soft_heap_limit64()] ** interface. This routine is provided for historical compatibility ** only. All new applications should use the ** [sqlite3_soft_heap_limit64()] interface rather than this one. */ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); /* ** CAPI3REF: Extract Metadata About A Column Of A Table ** ** ^This routine returns metadata about a specific column of a specific ** database table accessible using the [database connection] handle ** passed as the first function argument. ** ** ^The column is identified by the second, third and fourth parameters to ** this function. ^The second parameter is either the name of the database ** (i.e. "main", "temp", or an attached database) containing the specified ** table or NULL. ^If it is NULL, then all attached databases are searched ** for the table using the same algorithm used by the database engine to ** resolve unqualified table references. ** ** ^The third and fourth parameters to this function are the table and column ** name of the desired column, respectively. Neither of these parameters ** may be NULL. ** ** ^Metadata is returned by writing to the memory locations passed as the 5th ** and subsequent parameters to this function. ^Any of these arguments may be ** NULL, in which case the corresponding element of metadata is omitted. ** ** ^(
** **
Parameter Output
Type
Description ** **
5th const char* Data type **
6th const char* Name of default collation sequence **
7th int True if column has a NOT NULL constraint **
8th int True if column is part of the PRIMARY KEY **
9th int True if column is [AUTOINCREMENT] **
**
)^ ** ** ^The memory pointed to by the character pointers returned for the ** declaration type and collation sequence is valid only until the next ** call to any SQLite API function. ** ** ^If the specified table is actually a view, an [error code] is returned. ** ** ^If the specified column is "rowid", "oid" or "_rowid_" and an ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output ** parameters are set for the explicitly declared column. ^(If there is no ** explicitly declared [INTEGER PRIMARY KEY] column, then the output ** parameters are set as follows: ** **
**     data type: "INTEGER"
**     collation sequence: "BINARY"
**     not null: 0
**     primary key: 1
**     auto increment: 0
** 
)^ ** ** ^(This function may load one or more schemas from database files. If an ** error occurs during this process, or if the requested table or column ** cannot be found, an [error code] is returned and an error message left ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^ ** ** ^This API is only available if the library was compiled with the ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. */ SQLITE_API int sqlite3_table_column_metadata( sqlite3 *db, /* Connection handle */ const char *zDbName, /* Database name or NULL */ const char *zTableName, /* Table name */ const char *zColumnName, /* Column name */ char const **pzDataType, /* OUTPUT: Declared data type */ char const **pzCollSeq, /* OUTPUT: Collation sequence name */ int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ int *pPrimaryKey, /* OUTPUT: True if column part of PK */ int *pAutoinc /* OUTPUT: True if column is auto-increment */ ); /* ** CAPI3REF: Load An Extension ** ** ^This interface loads an SQLite extension library from the named file. ** ** ^The sqlite3_load_extension() interface attempts to load an ** SQLite extension library contained in the file zFile. ** ** ^The entry point is zProc. ** ^zProc may be 0, in which case the name of the entry point ** defaults to "sqlite3_extension_init". ** ^The sqlite3_load_extension() interface returns ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. ** ^If an error occurs and pzErrMsg is not 0, then the ** [sqlite3_load_extension()] interface shall attempt to ** fill *pzErrMsg with error message text stored in memory ** obtained from [sqlite3_malloc()]. The calling function ** should free this memory by calling [sqlite3_free()]. ** ** ^Extension loading must be enabled using ** [sqlite3_enable_load_extension()] prior to calling this API, ** otherwise an error will be returned. ** ** See also the [load_extension() SQL function]. */ SQLITE_API int sqlite3_load_extension( sqlite3 *db, /* Load the extension into this database connection */ const char *zFile, /* Name of the shared library containing extension */ const char *zProc, /* Entry point. Derived from zFile if 0 */ char **pzErrMsg /* Put error message here if not 0 */ ); /* ** CAPI3REF: Enable Or Disable Extension Loading ** ** ^So as not to open security holes in older applications that are ** unprepared to deal with extension loading, and as a means of disabling ** extension loading while evaluating user-entered SQL, the following API ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. ** ** ^Extension loading is off by default. See ticket #1863. ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 ** to turn extension loading on and call it with onoff==0 to turn ** it back off again. */ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); /* ** CAPI3REF: Automatically Load Statically Linked Extensions ** ** ^This interface causes the xEntryPoint() function to be invoked for ** each new [database connection] that is created. The idea here is that ** xEntryPoint() is the entry point for a statically linked SQLite extension ** that is to be automatically loaded into all new database connections. ** ** ^(Even though the function prototype shows that xEntryPoint() takes ** no arguments and returns void, SQLite invokes xEntryPoint() with three ** arguments and expects and integer result as if the signature of the ** entry point where as follows: ** **
**    int xEntryPoint(
**      sqlite3 *db,
**      const char **pzErrMsg,
**      const struct sqlite3_api_routines *pThunk
**    );
** 
)^ ** ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg ** point to an appropriate error message (obtained from [sqlite3_mprintf()]) ** and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg ** is NULL before calling the xEntryPoint(). ^SQLite will invoke ** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], ** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. ** ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already ** on the list of automatic extensions is a harmless no-op. ^No entry point ** will be called more than once for each database connection that is opened. ** ** See also: [sqlite3_reset_auto_extension()]. */ SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); /* ** CAPI3REF: Reset Automatic Extension Loading ** ** ^This interface disables all automatic extensions previously ** registered using [sqlite3_auto_extension()]. */ SQLITE_API void sqlite3_reset_auto_extension(void); /* ** The interface to the virtual-table mechanism is currently considered ** to be experimental. The interface might change in incompatible ways. ** If this is a problem for you, do not use the interface at this time. ** ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. */ /* ** Structures used by the virtual table interface */ typedef struct sqlite3_vtab sqlite3_vtab; typedef struct sqlite3_index_info sqlite3_index_info; typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; typedef struct sqlite3_module sqlite3_module; /* ** CAPI3REF: Virtual Table Object ** KEYWORDS: sqlite3_module {virtual table module} ** ** This structure, sometimes called a "virtual table module", ** defines the implementation of a [virtual tables]. ** This structure consists mostly of methods for the module. ** ** ^A virtual table module is created by filling in a persistent ** instance of this structure and passing a pointer to that instance ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. ** ^The registration remains valid until it is replaced by a different ** module or until the [database connection] closes. The content ** of this structure must not change while it is registered with ** any database connection. */ struct sqlite3_module { int iVersion; int (*xCreate)(sqlite3*, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVTab, char**); int (*xConnect)(sqlite3*, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVTab, char**); int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); int (*xDisconnect)(sqlite3_vtab *pVTab); int (*xDestroy)(sqlite3_vtab *pVTab); int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); int (*xClose)(sqlite3_vtab_cursor*); int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, int argc, sqlite3_value **argv); int (*xNext)(sqlite3_vtab_cursor*); int (*xEof)(sqlite3_vtab_cursor*); int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); int (*xBegin)(sqlite3_vtab *pVTab); int (*xSync)(sqlite3_vtab *pVTab); int (*xCommit)(sqlite3_vtab *pVTab); int (*xRollback)(sqlite3_vtab *pVTab); int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg); int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); /* The methods above are in version 1 of the sqlite_module object. Those ** below are for version 2 and greater. */ int (*xSavepoint)(sqlite3_vtab *pVTab, int); int (*xRelease)(sqlite3_vtab *pVTab, int); int (*xRollbackTo)(sqlite3_vtab *pVTab, int); }; /* ** CAPI3REF: Virtual Table Indexing Information ** KEYWORDS: sqlite3_index_info ** ** The sqlite3_index_info structure and its substructures is used as part ** of the [virtual table] interface to ** pass information into and receive the reply from the [xBestIndex] ** method of a [virtual table module]. The fields under **Inputs** are the ** inputs to xBestIndex and are read-only. xBestIndex inserts its ** results into the **Outputs** fields. ** ** ^(The aConstraint[] array records WHERE clause constraints of the form: ** **
column OP expr
** ** where OP is =, <, <=, >, or >=.)^ ^(The particular operator is ** stored in aConstraint[].op using one of the ** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ ** ^(The index of the column is stored in ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the ** expr on the right-hand side can be evaluated (and thus the constraint ** is usable) and false if it cannot.)^ ** ** ^The optimizer automatically inverts terms of the form "expr OP column" ** and makes other simplifications to the WHERE clause in an attempt to ** get as many WHERE clause terms into the form shown above as possible. ** ^The aConstraint[] array only reports WHERE clause terms that are ** relevant to the particular virtual table being queried. ** ** ^Information about the ORDER BY clause is stored in aOrderBy[]. ** ^Each term of aOrderBy records a column of the ORDER BY clause. ** ** The [xBestIndex] method must fill aConstraintUsage[] with information ** about what parameters to pass to xFilter. ^If argvIndex>0 then ** the right-hand side of the corresponding aConstraint[] is evaluated ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit ** is true, then the constraint is assumed to be fully handled by the ** virtual table and is not checked again by SQLite.)^ ** ** ^The idxNum and idxPtr values are recorded and passed into the ** [xFilter] method. ** ^[sqlite3_free()] is used to free idxPtr if and only if ** needToFreeIdxPtr is true. ** ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in ** the correct order to satisfy the ORDER BY clause so that no separate ** sorting step is required. ** ** ^The estimatedCost value is an estimate of the cost of doing the ** particular lookup. A full scan of a table with N entries should have ** a cost of N. A binary search of a table of N entries should have a ** cost of approximately log(N). */ struct sqlite3_index_info { /* Inputs */ int nConstraint; /* Number of entries in aConstraint */ struct sqlite3_index_constraint { int iColumn; /* Column on left-hand side of constraint */ unsigned char op; /* Constraint operator */ unsigned char usable; /* True if this constraint is usable */ int iTermOffset; /* Used internally - xBestIndex should ignore */ } *aConstraint; /* Table of WHERE clause constraints */ int nOrderBy; /* Number of terms in the ORDER BY clause */ struct sqlite3_index_orderby { int iColumn; /* Column number */ unsigned char desc; /* True for DESC. False for ASC. */ } *aOrderBy; /* The ORDER BY clause */ /* Outputs */ struct sqlite3_index_constraint_usage { int argvIndex; /* if >0, constraint is part of argv to xFilter */ unsigned char omit; /* Do not code a test for this constraint */ } *aConstraintUsage; int idxNum; /* Number used to identify the index */ char *idxStr; /* String, possibly obtained from sqlite3_malloc */ int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ int orderByConsumed; /* True if output is already ordered */ double estimatedCost; /* Estimated cost of using this index */ }; /* ** CAPI3REF: Virtual Table Constraint Operator Codes ** ** These macros defined the allowed values for the ** [sqlite3_index_info].aConstraint[].op field. Each value represents ** an operator that is part of a constraint term in the wHERE clause of ** a query that uses a [virtual table]. */ #define SQLITE_INDEX_CONSTRAINT_EQ 2 #define SQLITE_INDEX_CONSTRAINT_GT 4 #define SQLITE_INDEX_CONSTRAINT_LE 8 #define SQLITE_INDEX_CONSTRAINT_LT 16 #define SQLITE_INDEX_CONSTRAINT_GE 32 #define SQLITE_INDEX_CONSTRAINT_MATCH 64 /* ** CAPI3REF: Register A Virtual Table Implementation ** ** ^These routines are used to register a new [virtual table module] name. ** ^Module names must be registered before ** creating a new [virtual table] using the module and before using a ** preexisting [virtual table] for the module. ** ** ^The module name is registered on the [database connection] specified ** by the first parameter. ^The name of the module is given by the ** second parameter. ^The third parameter is a pointer to ** the implementation of the [virtual table module]. ^The fourth ** parameter is an arbitrary client data pointer that is passed through ** into the [xCreate] and [xConnect] methods of the virtual table module ** when a new virtual table is be being created or reinitialized. ** ** ^The sqlite3_create_module_v2() interface has a fifth parameter which ** is a pointer to a destructor for the pClientData. ^SQLite will ** invoke the destructor function (if it is not NULL) when SQLite ** no longer needs the pClientData pointer. ^The destructor will also ** be invoked if the call to sqlite3_create_module_v2() fails. ** ^The sqlite3_create_module() ** interface is equivalent to sqlite3_create_module_v2() with a NULL ** destructor. */ SQLITE_API int sqlite3_create_module( sqlite3 *db, /* SQLite connection to register module with */ const char *zName, /* Name of the module */ const sqlite3_module *p, /* Methods for the module */ void *pClientData /* Client data for xCreate/xConnect */ ); SQLITE_API int sqlite3_create_module_v2( sqlite3 *db, /* SQLite connection to register module with */ const char *zName, /* Name of the module */ const sqlite3_module *p, /* Methods for the module */ void *pClientData, /* Client data for xCreate/xConnect */ void(*xDestroy)(void*) /* Module destructor function */ ); /* ** CAPI3REF: Virtual Table Instance Object ** KEYWORDS: sqlite3_vtab ** ** Every [virtual table module] implementation uses a subclass ** of this object to describe a particular instance ** of the [virtual table]. Each subclass will ** be tailored to the specific needs of the module implementation. ** The purpose of this superclass is to define certain fields that are ** common to all module implementations. ** ** ^Virtual tables methods can set an error message by assigning a ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should ** take care that any prior string is freed by a call to [sqlite3_free()] ** prior to assigning a new string to zErrMsg. ^After the error message ** is delivered up to the client application, the string will be automatically ** freed by sqlite3_free() and the zErrMsg field will be zeroed. */ struct sqlite3_vtab { const sqlite3_module *pModule; /* The module for this virtual table */ int nRef; /* NO LONGER USED */ char *zErrMsg; /* Error message from sqlite3_mprintf() */ /* Virtual table implementations will typically add additional fields */ }; /* ** CAPI3REF: Virtual Table Cursor Object ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} ** ** Every [virtual table module] implementation uses a subclass of the ** following structure to describe cursors that point into the ** [virtual table] and are used ** to loop through the virtual table. Cursors are created using the ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed ** by the [sqlite3_module.xClose | xClose] method. Cursors are used ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods ** of the module. Each module implementation will define ** the content of a cursor structure to suit its own needs. ** ** This superclass exists in order to define fields of the cursor that ** are common to all implementations. */ struct sqlite3_vtab_cursor { sqlite3_vtab *pVtab; /* Virtual table of this cursor */ /* Virtual table implementations will typically add additional fields */ }; /* ** CAPI3REF: Declare The Schema Of A Virtual Table ** ** ^The [xCreate] and [xConnect] methods of a ** [virtual table module] call this interface ** to declare the format (the names and datatypes of the columns) of ** the virtual tables they implement. */ SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL); /* ** CAPI3REF: Overload A Function For A Virtual Table ** ** ^(Virtual tables can provide alternative implementations of functions ** using the [xFindFunction] method of the [virtual table module]. ** But global versions of those functions ** must exist in order to be overloaded.)^ ** ** ^(This API makes sure a global version of a function with a particular ** name and number of parameters exists. If no such function exists ** before this API is called, a new function is created.)^ ^The implementation ** of the new function always causes an exception to be thrown. So ** the new function is not good for anything by itself. Its only ** purpose is to be a placeholder function that can be overloaded ** by a [virtual table]. */ SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); /* ** The interface to the virtual-table mechanism defined above (back up ** to a comment remarkably similar to this one) is currently considered ** to be experimental. The interface might change in incompatible ways. ** If this is a problem for you, do not use the interface at this time. ** ** When the virtual-table mechanism stabilizes, we will declare the ** interface fixed, support it indefinitely, and remove this comment. */ /* ** CAPI3REF: A Handle To An Open BLOB ** KEYWORDS: {BLOB handle} {BLOB handles} ** ** An instance of this object represents an open BLOB on which ** [sqlite3_blob_open | incremental BLOB I/O] can be performed. ** ^Objects of this type are created by [sqlite3_blob_open()] ** and destroyed by [sqlite3_blob_close()]. ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces ** can be used to read or write small subsections of the BLOB. ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. */ typedef struct sqlite3_blob sqlite3_blob; /* ** CAPI3REF: Open A BLOB For Incremental I/O ** ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located ** in row iRow, column zColumn, table zTable in database zDb; ** in other words, the same BLOB that would be selected by: ** **
**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
** 
)^ ** ** ^If the flags parameter is non-zero, then the BLOB is opened for read ** and write access. ^If it is zero, the BLOB is opened for read access. ** ^It is not possible to open a column that is part of an index or primary ** key for writing. ^If [foreign key constraints] are enabled, it is ** not possible to open a column that is part of a [child key] for writing. ** ** ^Note that the database name is not the filename that contains ** the database but rather the symbolic name of the database that ** appears after the AS keyword when the database is connected using [ATTACH]. ** ^For the main database file, the database name is "main". ** ^For TEMP tables, the database name is "temp". ** ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set ** to be a null pointer.)^ ** ^This function sets the [database connection] error code and message ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related ** functions. ^Note that the *ppBlob variable is always initialized in a ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob ** regardless of the success or failure of this routine. ** ** ^(If the row that a BLOB handle points to is modified by an ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects ** then the BLOB handle is marked as "expired". ** This is true if any column of the row is changed, even a column ** other than the one the BLOB handle is open on.)^ ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for ** an expired BLOB handle fail with a return code of [SQLITE_ABORT]. ** ^(Changes written into a BLOB prior to the BLOB expiring are not ** rolled back by the expiration of the BLOB. Such changes will eventually ** commit if the transaction continues to completion.)^ ** ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of ** the opened blob. ^The size of a blob may not be changed by this ** interface. Use the [UPDATE] SQL command to change the size of a ** blob. ** ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces ** and the built-in [zeroblob] SQL function can be used, if desired, ** to create an empty, zero-filled blob in which to read or write using ** this interface. ** ** To avoid a resource leak, every open [BLOB handle] should eventually ** be released by a call to [sqlite3_blob_close()]. */ SQLITE_API int sqlite3_blob_open( sqlite3*, const char *zDb, const char *zTable, const char *zColumn, sqlite3_int64 iRow, int flags, sqlite3_blob **ppBlob ); /* ** CAPI3REF: Move a BLOB Handle to a New Row ** ** ^This function is used to move an existing blob handle so that it points ** to a different row of the same database table. ^The new row is identified ** by the rowid value passed as the second argument. Only the row can be ** changed. ^The database, table and column on which the blob handle is open ** remain the same. Moving an existing blob handle to a new row can be ** faster than closing the existing handle and opening a new one. ** ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - ** it must exist and there must be either a blob or text value stored in ** the nominated column.)^ ^If the new row is not present in the table, or if ** it does not contain a blob or text value, or if another error occurs, an ** SQLite error code is returned and the blob handle is considered aborted. ** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle ** always returns zero. ** ** ^This function sets the database handle error code and message. */ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); /* ** CAPI3REF: Close A BLOB Handle ** ** ^Closes an open [BLOB handle]. ** ** ^Closing a BLOB shall cause the current transaction to commit ** if there are no other BLOBs, no pending prepared statements, and the ** database connection is in [autocommit mode]. ** ^If any writes were made to the BLOB, they might be held in cache ** until the close operation if they will fit. ** ** ^(Closing the BLOB often forces the changes ** out to disk and so if any I/O errors occur, they will likely occur ** at the time when the BLOB is closed. Any errors that occur during ** closing are reported as a non-zero return value.)^ ** ** ^(The BLOB is closed unconditionally. Even if this routine returns ** an error code, the BLOB is still closed.)^ ** ** ^Calling this routine with a null pointer (such as would be returned ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op. */ SQLITE_API int sqlite3_blob_close(sqlite3_blob *); /* ** CAPI3REF: Return The Size Of An Open BLOB ** ** ^Returns the size in bytes of the BLOB accessible via the ** successfully opened [BLOB handle] in its only argument. ^The ** incremental blob I/O routines can only read or overwriting existing ** blob content; they cannot change the size of a blob. ** ** This routine only works on a [BLOB handle] which has been created ** by a prior successful call to [sqlite3_blob_open()] and which has not ** been closed by [sqlite3_blob_close()]. Passing any other pointer in ** to this routine results in undefined and probably undesirable behavior. */ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); /* ** CAPI3REF: Read Data From A BLOB Incrementally ** ** ^(This function is used to read data from an open [BLOB handle] into a ** caller-supplied buffer. N bytes of data are copied into buffer Z ** from the open BLOB, starting at offset iOffset.)^ ** ** ^If offset iOffset is less than N bytes from the end of the BLOB, ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is ** less than zero, [SQLITE_ERROR] is returned and no data is read. ** ^The size of the blob (and hence the maximum value of N+iOffset) ** can be determined using the [sqlite3_blob_bytes()] interface. ** ** ^An attempt to read from an expired [BLOB handle] fails with an ** error code of [SQLITE_ABORT]. ** ** ^(On success, sqlite3_blob_read() returns SQLITE_OK. ** Otherwise, an [error code] or an [extended error code] is returned.)^ ** ** This routine only works on a [BLOB handle] which has been created ** by a prior successful call to [sqlite3_blob_open()] and which has not ** been closed by [sqlite3_blob_close()]. Passing any other pointer in ** to this routine results in undefined and probably undesirable behavior. ** ** See also: [sqlite3_blob_write()]. */ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); /* ** CAPI3REF: Write Data Into A BLOB Incrementally ** ** ^This function is used to write data into an open [BLOB handle] from a ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z ** into the open BLOB, starting at offset iOffset. ** ** ^If the [BLOB handle] passed as the first argument was not opened for ** writing (the flags parameter to [sqlite3_blob_open()] was zero), ** this function returns [SQLITE_READONLY]. ** ** ^This function may only modify the contents of the BLOB; it is ** not possible to increase the size of a BLOB using this API. ** ^If offset iOffset is less than N bytes from the end of the BLOB, ** [SQLITE_ERROR] is returned and no data is written. ^If N is ** less than zero [SQLITE_ERROR] is returned and no data is written. ** The size of the BLOB (and hence the maximum value of N+iOffset) ** can be determined using the [sqlite3_blob_bytes()] interface. ** ** ^An attempt to write to an expired [BLOB handle] fails with an ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred ** before the [BLOB handle] expired are not rolled back by the ** expiration of the handle, though of course those changes might ** have been overwritten by the statement that expired the BLOB handle ** or by other independent statements. ** ** ^(On success, sqlite3_blob_write() returns SQLITE_OK. ** Otherwise, an [error code] or an [extended error code] is returned.)^ ** ** This routine only works on a [BLOB handle] which has been created ** by a prior successful call to [sqlite3_blob_open()] and which has not ** been closed by [sqlite3_blob_close()]. Passing any other pointer in ** to this routine results in undefined and probably undesirable behavior. ** ** See also: [sqlite3_blob_read()]. */ SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); /* ** CAPI3REF: Virtual File System Objects ** ** A virtual filesystem (VFS) is an [sqlite3_vfs] object ** that SQLite uses to interact ** with the underlying operating system. Most SQLite builds come with a ** single default VFS that is appropriate for the host computer. ** New VFSes can be registered and existing VFSes can be unregistered. ** The following interfaces are provided. ** ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. ** ^Names are case sensitive. ** ^Names are zero-terminated UTF-8 strings. ** ^If there is no match, a NULL pointer is returned. ** ^If zVfsName is NULL then the default VFS is returned. ** ** ^New VFSes are registered with sqlite3_vfs_register(). ** ^Each new VFS becomes the default VFS if the makeDflt flag is set. ** ^The same VFS can be registered multiple times without injury. ** ^To make an existing VFS into the default VFS, register it again ** with the makeDflt flag set. If two different VFSes with the ** same name are registered, the behavior is undefined. If a ** VFS is registered with a name that is NULL or an empty string, ** then the behavior is undefined. ** ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. ** ^(If the default VFS is unregistered, another VFS is chosen as ** the default. The choice for the new VFS is arbitrary.)^ */ SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); /* ** CAPI3REF: Mutexes ** ** The SQLite core uses these routines for thread ** synchronization. Though they are intended for internal ** use by SQLite, code that links against SQLite is ** permitted to use any of these routines. ** ** The SQLite source code contains multiple implementations ** of these mutex routines. An appropriate implementation ** is selected automatically at compile-time. ^(The following ** implementations are available in the SQLite core: ** **
    **
  • SQLITE_MUTEX_PTHREADS **
  • SQLITE_MUTEX_W32 **
  • SQLITE_MUTEX_NOOP **
)^ ** ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines ** that does no real locking and is appropriate for use in ** a single-threaded application. ^The SQLITE_MUTEX_PTHREADS and ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix ** and Windows. ** ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex ** implementation is included with the library. In this case the ** application must supply a custom mutex implementation using the ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function ** before calling sqlite3_initialize() or any other public sqlite3_ ** function that calls sqlite3_initialize().)^ ** ** ^The sqlite3_mutex_alloc() routine allocates a new ** mutex and returns a pointer to it. ^If it returns NULL ** that means that a mutex could not be allocated. ^SQLite ** will unwind its stack and return an error. ^(The argument ** to sqlite3_mutex_alloc() is one of these integer constants: ** **
    **
  • SQLITE_MUTEX_FAST **
  • SQLITE_MUTEX_RECURSIVE **
  • SQLITE_MUTEX_STATIC_MASTER **
  • SQLITE_MUTEX_STATIC_MEM **
  • SQLITE_MUTEX_STATIC_MEM2 **
  • SQLITE_MUTEX_STATIC_PRNG **
  • SQLITE_MUTEX_STATIC_LRU **
  • SQLITE_MUTEX_STATIC_LRU2 **
)^ ** ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) ** cause sqlite3_mutex_alloc() to create ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. ** The mutex implementation does not need to make a distinction ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does ** not want to. ^SQLite will only request a recursive mutex in ** cases where it really needs one. ^If a faster non-recursive mutex ** implementation is available on the host platform, the mutex subsystem ** might return such a mutex in response to SQLITE_MUTEX_FAST. ** ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return ** a pointer to a static preexisting mutex. ^Six static mutexes are ** used by the current version of SQLite. Future versions of SQLite ** may add additional static mutexes. Static mutexes are for internal ** use by SQLite only. Applications that use SQLite mutexes should ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or ** SQLITE_MUTEX_RECURSIVE. ** ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() ** returns a different mutex on every call. ^But for the static ** mutex types, the same mutex is returned on every call that has ** the same type number. ** ** ^The sqlite3_mutex_free() routine deallocates a previously ** allocated dynamic mutex. ^SQLite is careful to deallocate every ** dynamic mutex that it allocates. The dynamic mutexes must not be in ** use when they are deallocated. Attempting to deallocate a static ** mutex results in undefined behavior. ^SQLite never deallocates ** a static mutex. ** ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt ** to enter a mutex. ^If another thread is already within the mutex, ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] ** upon successful entry. ^(Mutexes created using ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. ** In such cases the, ** mutex must be exited an equal number of times before another thread ** can enter.)^ ^(If the same thread tries to enter any other ** kind of mutex more than once, the behavior is undefined. ** SQLite will never exhibit ** such behavior in its own use of mutexes.)^ ** ** ^(Some systems (for example, Windows 95) do not support the operation ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() ** will always return SQLITE_BUSY. The SQLite core only ever uses ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^ ** ** ^The sqlite3_mutex_leave() routine exits a mutex that was ** previously entered by the same thread. ^(The behavior ** is undefined if the mutex is not currently entered by the ** calling thread or is not currently allocated. SQLite will ** never do either.)^ ** ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or ** sqlite3_mutex_leave() is a NULL pointer, then all three routines ** behave as no-ops. ** ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. */ SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); /* ** CAPI3REF: Mutex Methods Object ** ** An instance of this structure defines the low-level routines ** used to allocate and use mutexes. ** ** Usually, the default mutex implementations provided by SQLite are ** sufficient, however the user has the option of substituting a custom ** implementation for specialized deployments or systems for which SQLite ** does not provide a suitable implementation. In this case, the user ** creates and populates an instance of this structure to pass ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. ** Additionally, an instance of this structure can be used as an ** output variable when querying the system for the current mutex ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. ** ** ^The xMutexInit method defined by this structure is invoked as ** part of system initialization by the sqlite3_initialize() function. ** ^The xMutexInit routine is called by SQLite exactly once for each ** effective call to [sqlite3_initialize()]. ** ** ^The xMutexEnd method defined by this structure is invoked as ** part of system shutdown by the sqlite3_shutdown() function. The ** implementation of this method is expected to release all outstanding ** resources obtained by the mutex methods implementation, especially ** those obtained by the xMutexInit method. ^The xMutexEnd() ** interface is invoked exactly once for each call to [sqlite3_shutdown()]. ** ** ^(The remaining seven methods defined by this structure (xMutexAlloc, ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and ** xMutexNotheld) implement the following interfaces (respectively): ** **
    **
  • [sqlite3_mutex_alloc()]
  • **
  • [sqlite3_mutex_free()]
  • **
  • [sqlite3_mutex_enter()]
  • **
  • [sqlite3_mutex_try()]
  • **
  • [sqlite3_mutex_leave()]
  • **
  • [sqlite3_mutex_held()]
  • **
  • [sqlite3_mutex_notheld()]
  • **
)^ ** ** The only difference is that the public sqlite3_XXX functions enumerated ** above silently ignore any invocations that pass a NULL pointer instead ** of a valid mutex handle. The implementations of the methods defined ** by this structure are not required to handle this case, the results ** of passing a NULL pointer instead of a valid mutex handle are undefined ** (i.e. it is acceptable to provide an implementation that segfaults if ** it is passed a NULL pointer). ** ** The xMutexInit() method must be threadsafe. ^It must be harmless to ** invoke xMutexInit() multiple times within the same process and without ** intervening calls to xMutexEnd(). Second and subsequent calls to ** xMutexInit() must be no-ops. ** ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite ** memory allocation for a fast or recursive mutex. ** ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is ** called, but only if the prior call to xMutexInit returned SQLITE_OK. ** If xMutexInit fails in any way, it is expected to clean up after itself ** prior to returning. */ typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; struct sqlite3_mutex_methods { int (*xMutexInit)(void); int (*xMutexEnd)(void); sqlite3_mutex *(*xMutexAlloc)(int); void (*xMutexFree)(sqlite3_mutex *); void (*xMutexEnter)(sqlite3_mutex *); int (*xMutexTry)(sqlite3_mutex *); void (*xMutexLeave)(sqlite3_mutex *); int (*xMutexHeld)(sqlite3_mutex *); int (*xMutexNotheld)(sqlite3_mutex *); }; /* ** CAPI3REF: Mutex Verification Routines ** ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines ** are intended for use inside assert() statements. ^The SQLite core ** never uses these routines except inside an assert() and applications ** are advised to follow the lead of the core. ^The SQLite core only ** provides implementations for these routines when it is compiled ** with the SQLITE_DEBUG flag. ^External mutex implementations ** are only required to provide these routines if SQLITE_DEBUG is ** defined and if NDEBUG is not defined. ** ** ^These routines should return true if the mutex in their argument ** is held or not held, respectively, by the calling thread. ** ** ^The implementation is not required to provide versions of these ** routines that actually work. If the implementation does not provide working ** versions of these routines, it should at least provide stubs that always ** return true so that one does not get spurious assertion failures. ** ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then ** the routine should return 1. This seems counter-intuitive since ** clearly the mutex cannot be held if it does not exist. But ** the reason the mutex does not exist is because the build is not ** using mutexes. And we do not want the assert() containing the ** call to sqlite3_mutex_held() to fail, so a non-zero return is ** the appropriate thing to do. ^The sqlite3_mutex_notheld() ** interface should also return 1 when given a NULL pointer. */ #ifndef NDEBUG SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); #endif /* ** CAPI3REF: Mutex Types ** ** The [sqlite3_mutex_alloc()] interface takes a single argument ** which is one of these integer constants. ** ** The set of static mutexes may change from one SQLite release to the ** next. Applications that override the built-in mutex logic must be ** prepared to accommodate additional static mutexes. */ #define SQLITE_MUTEX_FAST 0 #define SQLITE_MUTEX_RECURSIVE 1 #define SQLITE_MUTEX_STATIC_MASTER 2 #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ #define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ #define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ #define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ /* ** CAPI3REF: Retrieve the mutex for a database connection ** ** ^This interface returns a pointer the [sqlite3_mutex] object that ** serializes access to the [database connection] given in the argument ** when the [threading mode] is Serialized. ** ^If the [threading mode] is Single-thread or Multi-thread then this ** routine returns a NULL pointer. */ SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); /* ** CAPI3REF: Low-Level Control Of Database Files ** ** ^The [sqlite3_file_control()] interface makes a direct call to the ** xFileControl method for the [sqlite3_io_methods] object associated ** with a particular database identified by the second argument. ^The ** name of the database is "main" for the main database or "temp" for the ** TEMP database, or the name that appears after the AS keyword for ** databases that are added using the [ATTACH] SQL command. ** ^A NULL pointer can be used in place of "main" to refer to the ** main database file. ** ^The third and fourth parameters to this routine ** are passed directly through to the second and third parameters of ** the xFileControl method. ^The return value of the xFileControl ** method becomes the return value of this routine. ** ** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes ** a pointer to the underlying [sqlite3_file] object to be written into ** the space pointed to by the 4th parameter. ^The SQLITE_FCNTL_FILE_POINTER ** case is a short-circuit path which does not actually invoke the ** underlying sqlite3_io_methods.xFileControl method. ** ** ^If the second parameter (zDbName) does not match the name of any ** open database file, then SQLITE_ERROR is returned. ^This error ** code is not remembered and will not be recalled by [sqlite3_errcode()] ** or [sqlite3_errmsg()]. The underlying xFileControl method might ** also return SQLITE_ERROR. There is no way to distinguish between ** an incorrect zDbName and an SQLITE_ERROR return from the underlying ** xFileControl method. ** ** See also: [SQLITE_FCNTL_LOCKSTATE] */ SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); /* ** CAPI3REF: Testing Interface ** ** ^The sqlite3_test_control() interface is used to read out internal ** state of SQLite and to inject faults into SQLite for testing ** purposes. ^The first parameter is an operation code that determines ** the number, meaning, and operation of all subsequent parameters. ** ** This interface is not for use by applications. It exists solely ** for verifying the correct operation of the SQLite library. Depending ** on how the SQLite library is compiled, this interface might not exist. ** ** The details of the operation codes, their meanings, the parameters ** they take, and what they do are all subject to change without notice. ** Unlike most of the SQLite API, this function is not guaranteed to ** operate consistently from one release to the next. */ SQLITE_API int sqlite3_test_control(int op, ...); /* ** CAPI3REF: Testing Interface Operation Codes ** ** These constants are the valid operation code parameters used ** as the first argument to [sqlite3_test_control()]. ** ** These parameters and their meanings are subject to change ** without notice. These values are for testing purposes only. ** Applications should not use any of these parameters or the ** [sqlite3_test_control()] interface. */ #define SQLITE_TESTCTRL_FIRST 5 #define SQLITE_TESTCTRL_PRNG_SAVE 5 #define SQLITE_TESTCTRL_PRNG_RESTORE 6 #define SQLITE_TESTCTRL_PRNG_RESET 7 #define SQLITE_TESTCTRL_BITVEC_TEST 8 #define SQLITE_TESTCTRL_FAULT_INSTALL 9 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 #define SQLITE_TESTCTRL_PENDING_BYTE 11 #define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_RESERVE 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 #define SQLITE_TESTCTRL_LAST 19 /* ** CAPI3REF: SQLite Runtime Status ** ** ^This interface is used to retrieve runtime status information ** about the performance of SQLite, and optionally to reset various ** highwater marks. ^The first argument is an integer code for ** the specific parameter to measure. ^(Recognized integer codes ** are of the form [status parameters | SQLITE_STATUS_...].)^ ** ^The current value of the parameter is returned into *pCurrent. ** ^The highest recorded value is returned in *pHighwater. ^If the ** resetFlag is true, then the highest record value is reset after ** *pHighwater is written. ^(Some parameters do not record the highest ** value. For those parameters ** nothing is written into *pHighwater and the resetFlag is ignored.)^ ** ^(Other parameters record only the highwater mark and not the current ** value. For these latter parameters nothing is written into *pCurrent.)^ ** ** ^The sqlite3_status() routine returns SQLITE_OK on success and a ** non-zero [error code] on failure. ** ** This routine is threadsafe but is not atomic. This routine can be ** called while other threads are running the same or different SQLite ** interfaces. However the values returned in *pCurrent and ** *pHighwater reflect the status of SQLite at different points in time ** and it is possible that another thread might change the parameter ** in between the times when *pCurrent and *pHighwater are written. ** ** See also: [sqlite3_db_status()] */ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); /* ** CAPI3REF: Status Parameters ** KEYWORDS: {status parameters} ** ** These integer constants designate various run-time status parameters ** that can be returned by [sqlite3_status()]. ** **
** [[SQLITE_STATUS_MEMORY_USED]] ^(
SQLITE_STATUS_MEMORY_USED
**
This parameter is the current amount of memory checked out ** using [sqlite3_malloc()], either directly or indirectly. The ** figure includes calls made to [sqlite3_malloc()] by the application ** and internal memory usage by the SQLite library. Scratch memory ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in ** this parameter. The amount returned is the sum of the allocation ** sizes as reported by the xSize method in [sqlite3_mem_methods].
)^ ** ** [[SQLITE_STATUS_MALLOC_SIZE]] ^(
SQLITE_STATUS_MALLOC_SIZE
**
This parameter records the largest memory allocation request ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their ** internal equivalents). Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
)^ ** ** [[SQLITE_STATUS_MALLOC_COUNT]] ^(
SQLITE_STATUS_MALLOC_COUNT
**
This parameter records the number of separate memory allocations ** currently checked out.
)^ ** ** [[SQLITE_STATUS_PAGECACHE_USED]] ^(
SQLITE_STATUS_PAGECACHE_USED
**
This parameter returns the number of pages used out of the ** [pagecache memory allocator] that was configured using ** [SQLITE_CONFIG_PAGECACHE]. The ** value returned is in pages, not in bytes.
)^ ** ** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] ** ^(
SQLITE_STATUS_PAGECACHE_OVERFLOW
**
This parameter returns the number of bytes of page cache ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] ** buffer and where forced to overflow to [sqlite3_malloc()]. The ** returned value includes allocations that overflowed because they ** where too large (they were larger than the "sz" parameter to ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because ** no space was left in the page cache.
)^ ** ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
SQLITE_STATUS_PAGECACHE_SIZE
**
This parameter records the largest memory allocation request ** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
)^ ** ** [[SQLITE_STATUS_SCRATCH_USED]] ^(
SQLITE_STATUS_SCRATCH_USED
**
This parameter returns the number of allocations used out of the ** [scratch memory allocator] configured using ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not ** in bytes. Since a single thread may only have one scratch allocation ** outstanding at time, this parameter also reports the number of threads ** using scratch memory at the same time.
)^ ** ** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(
SQLITE_STATUS_SCRATCH_OVERFLOW
**
This parameter returns the number of bytes of scratch memory ** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH] ** buffer and where forced to overflow to [sqlite3_malloc()]. The values ** returned include overflows because the requested allocation was too ** larger (that is, because the requested allocation was larger than the ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer ** slots were available. **
)^ ** ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(
SQLITE_STATUS_SCRATCH_SIZE
**
This parameter records the largest memory allocation request ** handed to [scratch memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
)^ ** ** [[SQLITE_STATUS_PARSER_STACK]] ^(
SQLITE_STATUS_PARSER_STACK
**
This parameter records the deepest parser stack. It is only ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
)^ **
** ** New status parameters may be added from time to time. */ #define SQLITE_STATUS_MEMORY_USED 0 #define SQLITE_STATUS_PAGECACHE_USED 1 #define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 #define SQLITE_STATUS_SCRATCH_USED 3 #define SQLITE_STATUS_SCRATCH_OVERFLOW 4 #define SQLITE_STATUS_MALLOC_SIZE 5 #define SQLITE_STATUS_PARSER_STACK 6 #define SQLITE_STATUS_PAGECACHE_SIZE 7 #define SQLITE_STATUS_SCRATCH_SIZE 8 #define SQLITE_STATUS_MALLOC_COUNT 9 /* ** CAPI3REF: Database Connection Status ** ** ^This interface is used to retrieve runtime status information ** about a single [database connection]. ^The first argument is the ** database connection object to be interrogated. ^The second argument ** is an integer constant, taken from the set of ** [SQLITE_DBSTATUS options], that ** determines the parameter to interrogate. The set of ** [SQLITE_DBSTATUS options] is likely ** to grow in future releases of SQLite. ** ** ^The current value of the requested parameter is written into *pCur ** and the highest instantaneous value is written into *pHiwtr. ^If ** the resetFlg is true, then the highest instantaneous value is ** reset back down to the current value. ** ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a ** non-zero [error code] on failure. ** ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. */ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); /* ** CAPI3REF: Status Parameters for database connections ** KEYWORDS: {SQLITE_DBSTATUS options} ** ** These constants are the available integer "verbs" that can be passed as ** the second argument to the [sqlite3_db_status()] interface. ** ** New verbs may be added in future releases of SQLite. Existing verbs ** might be discontinued. Applications should check the return code from ** [sqlite3_db_status()] to make sure that the call worked. ** The [sqlite3_db_status()] interface will return a non-zero error code ** if a discontinued or unsupported verb is invoked. ** **
** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(
SQLITE_DBSTATUS_LOOKASIDE_USED
**
This parameter returns the number of lookaside memory slots currently ** checked out.
)^ ** ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
SQLITE_DBSTATUS_LOOKASIDE_HIT
**
This parameter returns the number malloc attempts that were ** satisfied using lookaside memory. Only the high-water value is meaningful; ** the current value is always zero.)^ ** ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
**
This parameter returns the number malloc attempts that might have ** been satisfied using lookaside memory but failed due to the amount of ** memory requested being larger than the lookaside slot size. ** Only the high-water value is meaningful; ** the current value is always zero.)^ ** ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] ** ^(
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
**
This parameter returns the number malloc attempts that might have ** been satisfied using lookaside memory but failed due to all lookaside ** memory already being in use. ** Only the high-water value is meaningful; ** the current value is always zero.)^ ** ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(
SQLITE_DBSTATUS_CACHE_USED
**
This parameter returns the approximate number of of bytes of heap ** memory used by all pager caches associated with the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. ** ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
SQLITE_DBSTATUS_SCHEMA_USED
**
This parameter returns the approximate number of of bytes of heap ** memory used to store the schema for all databases associated ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ ** ^The full amount of memory used by the schemas is reported, even if the ** schema memory is shared with other database connections due to ** [shared cache mode] being enabled. ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. ** ** [[SQLITE_DBSTATUS_STMT_USED]] ^(
SQLITE_DBSTATUS_STMT_USED
**
This parameter returns the approximate number of of bytes of heap ** and lookaside memory used by all prepared statements associated with ** the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. **
** ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(
SQLITE_DBSTATUS_CACHE_HIT
**
This parameter returns the number of pager cache hits that have ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT ** is always 0. **
** ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(
SQLITE_DBSTATUS_CACHE_MISS
**
This parameter returns the number of pager cache misses that have ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS ** is always 0. **
** ** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(
SQLITE_DBSTATUS_CACHE_WRITE
**
This parameter returns the number of dirty cache entries that have ** been written to disk. Specifically, the number of pages written to the ** wal file in wal mode databases, or the number of pages written to the ** database file in rollback mode databases. Any pages written as part of ** transaction rollback or database recovery operations are not included. ** If an IO or other error occurs while writing a page to disk, the effect ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0. **
**
*/ #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 #define SQLITE_DBSTATUS_CACHE_USED 1 #define SQLITE_DBSTATUS_SCHEMA_USED 2 #define SQLITE_DBSTATUS_STMT_USED 3 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 #define SQLITE_DBSTATUS_CACHE_HIT 7 #define SQLITE_DBSTATUS_CACHE_MISS 8 #define SQLITE_DBSTATUS_CACHE_WRITE 9 #define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */ /* ** CAPI3REF: Prepared Statement Status ** ** ^(Each prepared statement maintains various ** [SQLITE_STMTSTATUS counters] that measure the number ** of times it has performed specific operations.)^ These counters can ** be used to monitor the performance characteristics of the prepared ** statements. For example, if the number of table steps greatly exceeds ** the number of table searches or result rows, that would tend to indicate ** that the prepared statement is using a full table scan rather than ** an index. ** ** ^(This interface is used to retrieve and reset counter values from ** a [prepared statement]. The first argument is the prepared statement ** object to be interrogated. The second argument ** is an integer code for a specific [SQLITE_STMTSTATUS counter] ** to be interrogated.)^ ** ^The current value of the requested counter is returned. ** ^If the resetFlg is true, then the counter is reset to zero after this ** interface call returns. ** ** See also: [sqlite3_status()] and [sqlite3_db_status()]. */ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); /* ** CAPI3REF: Status Parameters for prepared statements ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} ** ** These preprocessor macros define integer codes that name counter ** values associated with the [sqlite3_stmt_status()] interface. ** The meanings of the various counters are as follows: ** **
** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]]
SQLITE_STMTSTATUS_FULLSCAN_STEP
**
^This is the number of times that SQLite has stepped forward in ** a table as part of a full table scan. Large numbers for this counter ** may indicate opportunities for performance improvement through ** careful use of indices.
** ** [[SQLITE_STMTSTATUS_SORT]]
SQLITE_STMTSTATUS_SORT
**
^This is the number of sort operations that have occurred. ** A non-zero value in this counter may indicate an opportunity to ** improvement performance through careful use of indices.
** ** [[SQLITE_STMTSTATUS_AUTOINDEX]]
SQLITE_STMTSTATUS_AUTOINDEX
**
^This is the number of rows inserted into transient indices that ** were created automatically in order to help joins run faster. ** A non-zero value in this counter may indicate an opportunity to ** improvement performance by adding permanent indices that do not ** need to be reinitialized each time the statement is run.
**
*/ #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 #define SQLITE_STMTSTATUS_SORT 2 #define SQLITE_STMTSTATUS_AUTOINDEX 3 /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache type is opaque. It is implemented by ** the pluggable module. The SQLite core has no knowledge of ** its size or internal structure and never deals with the ** sqlite3_pcache object except by holding and passing pointers ** to the object. ** ** See [sqlite3_pcache_methods2] for additional information. */ typedef struct sqlite3_pcache sqlite3_pcache; /* ** CAPI3REF: Custom Page Cache Object ** ** The sqlite3_pcache_page object represents a single page in the ** page cache. The page cache will allocate instances of this ** object. Various methods of the page cache use pointers to instances ** of this object as parameters or as their return value. ** ** See [sqlite3_pcache_methods2] for additional information. */ typedef struct sqlite3_pcache_page sqlite3_pcache_page; struct sqlite3_pcache_page { void *pBuf; /* The content of the page */ void *pExtra; /* Extra information associated with the page */ }; /* ** CAPI3REF: Application Defined Page Cache. ** KEYWORDS: {page cache} ** ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can ** register an alternative page cache implementation by passing in an ** instance of the sqlite3_pcache_methods2 structure.)^ ** In many applications, most of the heap memory allocated by ** SQLite is used for the page cache. ** By implementing a ** custom page cache using this API, an application can better control ** the amount of memory consumed by SQLite, the way in which ** that memory is allocated and released, and the policies used to ** determine exactly which parts of a database file are cached and for ** how long. ** ** The alternative page cache mechanism is an ** extreme measure that is only needed by the most demanding applications. ** The built-in page cache is recommended for most uses. ** ** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an ** internal buffer by SQLite within the call to [sqlite3_config]. Hence ** the application may discard the parameter after the call to ** [sqlite3_config()] returns.)^ ** ** [[the xInit() page cache method]] ** ^(The xInit() method is called once for each effective ** call to [sqlite3_initialize()])^ ** (usually only once during the lifetime of the process). ^(The xInit() ** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ ** The intent of the xInit() method is to set up global data structures ** required by the custom page cache implementation. ** ^(If the xInit() method is NULL, then the ** built-in default page cache is used instead of the application defined ** page cache.)^ ** ** [[the xShutdown() page cache method]] ** ^The xShutdown() method is called by [sqlite3_shutdown()]. ** It can be used to clean up ** any outstanding resources before process shutdown, if required. ** ^The xShutdown() method may be NULL. ** ** ^SQLite automatically serializes calls to the xInit method, ** so the xInit method need not be threadsafe. ^The ** xShutdown method is only called from [sqlite3_shutdown()] so it does ** not need to be threadsafe either. All other methods must be threadsafe ** in multithreaded applications. ** ** ^SQLite will never invoke xInit() more than once without an intervening ** call to xShutdown(). ** ** [[the xCreate() page cache methods]] ** ^SQLite invokes the xCreate() method to construct a new cache instance. ** SQLite will typically create one cache instance for each open database file, ** though this is not guaranteed. ^The ** first parameter, szPage, is the size in bytes of the pages that must ** be allocated by the cache. ^szPage will always a power of two. ^The ** second parameter szExtra is a number of bytes of extra storage ** associated with each page cache entry. ^The szExtra parameter will ** a number less than 250. SQLite will use the ** extra szExtra bytes on each page to store metadata about the underlying ** database page on disk. The value passed into szExtra depends ** on the SQLite version, the target platform, and how SQLite was compiled. ** ^The third argument to xCreate(), bPurgeable, is true if the cache being ** created will be used to cache database pages of a file stored on disk, or ** false if it is used for an in-memory database. The cache implementation ** does not have to do anything special based with the value of bPurgeable; ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will ** never invoke xUnpin() except to deliberately delete a page. ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to ** false will always have the "discard" flag set to true. ** ^Hence, a cache created with bPurgeable false will ** never contain any unpinned pages. ** ** [[the xCachesize() page cache method]] ** ^(The xCachesize() method may be called at any time by SQLite to set the ** suggested maximum cache-size (number of pages stored by) the cache ** instance passed as the first argument. This is the value configured using ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable ** parameter, the implementation is not required to do anything with this ** value; it is advisory only. ** ** [[the xPagecount() page cache methods]] ** The xPagecount() method must return the number of pages currently ** stored in the cache, both pinned and unpinned. ** ** [[the xFetch() page cache methods]] ** The xFetch() method locates a page in the cache and returns a pointer to ** an sqlite3_pcache_page object associated with that page, or a NULL pointer. ** The pBuf element of the returned sqlite3_pcache_page object will be a ** pointer to a buffer of szPage bytes used to store the content of a ** single database page. The pExtra element of sqlite3_pcache_page will be ** a pointer to the szExtra bytes of extra storage that SQLite has requested ** for each entry in the page cache. ** ** The page to be fetched is determined by the key. ^The minimum key value ** is 1. After it has been retrieved using xFetch, the page is considered ** to be "pinned". ** ** If the requested page is already in the page cache, then the page cache ** implementation must return a pointer to the page buffer with its content ** intact. If the requested page is not already in the cache, then the ** cache implementation should use the value of the createFlag ** parameter to help it determined what action to take: ** ** **
createFlag Behaviour when page is not already in cache **
0 Do not allocate a new page. Return NULL. **
1 Allocate a new page if it easy and convenient to do so. ** Otherwise return NULL. **
2 Make every effort to allocate a new page. Only return ** NULL if allocating a new page is effectively impossible. **
** ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite ** will only use a createFlag of 2 after a prior call with a createFlag of 1 ** failed.)^ In between the to xFetch() calls, SQLite may ** attempt to unpin one or more cache pages by spilling the content of ** pinned pages to disk and synching the operating system disk cache. ** ** [[the xUnpin() page cache method]] ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page ** as its second argument. If the third parameter, discard, is non-zero, ** then the page must be evicted from the cache. ** ^If the discard parameter is ** zero, then the page may be discarded or retained at the discretion of ** page cache implementation. ^The page cache implementation ** may choose to evict unpinned pages at any time. ** ** The cache must not perform any reference counting. A single ** call to xUnpin() unpins the page regardless of the number of prior calls ** to xFetch(). ** ** [[the xRekey() page cache methods]] ** The xRekey() method is used to change the key value associated with the ** page passed as the second argument. If the cache ** previously contains an entry associated with newKey, it must be ** discarded. ^Any prior cache entry associated with newKey is guaranteed not ** to be pinned. ** ** When SQLite calls the xTruncate() method, the cache must discard all ** existing cache entries with page numbers (keys) greater than or equal ** to the value of the iLimit parameter passed to xTruncate(). If any ** of these pages are pinned, they are implicitly unpinned, meaning that ** they can be safely discarded. ** ** [[the xDestroy() page cache method]] ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). ** All resources associated with the specified cache should be freed. ^After ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] ** handle invalid, and will not use it with any other sqlite3_pcache_methods2 ** functions. ** ** [[the xShrink() page cache method]] ** ^SQLite invokes the xShrink() method when it wants the page cache to ** free up as much of heap memory as possible. The page cache implementation ** is not obligated to free any memory, but well-behaved implementations should ** do their best. */ typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2; struct sqlite3_pcache_methods2 { int iVersion; void *pArg; int (*xInit)(void*); void (*xShutdown)(void*); sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable); void (*xCachesize)(sqlite3_pcache*, int nCachesize); int (*xPagecount)(sqlite3_pcache*); sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard); void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, unsigned oldKey, unsigned newKey); void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); void (*xDestroy)(sqlite3_pcache*); void (*xShrink)(sqlite3_pcache*); }; /* ** This is the obsolete pcache_methods object that has now been replaced ** by sqlite3_pcache_methods2. This object is not used by SQLite. It is ** retained in the header file for backwards compatibility only. */ typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; struct sqlite3_pcache_methods { void *pArg; int (*xInit)(void*); void (*xShutdown)(void*); sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); void (*xCachesize)(sqlite3_pcache*, int nCachesize); int (*xPagecount)(sqlite3_pcache*); void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); void (*xUnpin)(sqlite3_pcache*, void*, int discard); void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); void (*xDestroy)(sqlite3_pcache*); }; /* ** CAPI3REF: Online Backup Object ** ** The sqlite3_backup object records state information about an ongoing ** online backup operation. ^The sqlite3_backup object is created by ** a call to [sqlite3_backup_init()] and is destroyed by a call to ** [sqlite3_backup_finish()]. ** ** See Also: [Using the SQLite Online Backup API] */ typedef struct sqlite3_backup sqlite3_backup; /* ** CAPI3REF: Online Backup API. ** ** The backup API copies the content of one database into another. ** It is useful either for creating backups of databases or ** for copying in-memory databases to or from persistent files. ** ** See Also: [Using the SQLite Online Backup API] ** ** ^SQLite holds a write transaction open on the destination database file ** for the duration of the backup operation. ** ^The source database is read-locked only while it is being read; ** it is not locked continuously for the entire backup operation. ** ^Thus, the backup may be performed on a live source database without ** preventing other database connections from ** reading or writing to the source database while the backup is underway. ** ** ^(To perform a backup operation: **
    **
  1. sqlite3_backup_init() is called once to initialize the ** backup, **
  2. sqlite3_backup_step() is called one or more times to transfer ** the data between the two databases, and finally **
  3. sqlite3_backup_finish() is called to release all resources ** associated with the backup operation. **
)^ ** There should be exactly one call to sqlite3_backup_finish() for each ** successful call to sqlite3_backup_init(). ** ** [[sqlite3_backup_init()]] sqlite3_backup_init() ** ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the ** [database connection] associated with the destination database ** and the database name, respectively. ** ^The database name is "main" for the main database, "temp" for the ** temporary database, or the name specified after the AS keyword in ** an [ATTACH] statement for an attached database. ** ^The S and M arguments passed to ** sqlite3_backup_init(D,N,S,M) identify the [database connection] ** and database name of the source database, respectively. ** ^The source and destination [database connections] (parameters S and D) ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with ** an error. ** ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is ** returned and an error code and error message are stored in the ** destination [database connection] D. ** ^The error code and message for the failed call to sqlite3_backup_init() ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or ** [sqlite3_errmsg16()] functions. ** ^A successful call to sqlite3_backup_init() returns a pointer to an ** [sqlite3_backup] object. ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and ** sqlite3_backup_finish() functions to perform the specified backup ** operation. ** ** [[sqlite3_backup_step()]] sqlite3_backup_step() ** ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between ** the source and destination databases specified by [sqlite3_backup] object B. ** ^If N is negative, all remaining source pages are copied. ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there ** are still more pages to be copied, then the function returns [SQLITE_OK]. ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages ** from source to destination, then it returns [SQLITE_DONE]. ** ^If an error occurs while running sqlite3_backup_step(B,N), ** then an [error code] is returned. ^As well as [SQLITE_OK] and ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. ** ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if **
    **
  1. the destination database was opened read-only, or **
  2. the destination database is using write-ahead-log journaling ** and the destination and source page sizes differ, or **
  3. the destination database is an in-memory database and the ** destination and source page sizes differ. **
)^ ** ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then ** the [sqlite3_busy_handler | busy-handler function] ** is invoked (if one is specified). ^If the ** busy-handler returns non-zero before the lock is available, then ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to ** sqlite3_backup_step() can be retried later. ^If the source ** [database connection] ** is being used to write to the source database when sqlite3_backup_step() ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this ** case the call to sqlite3_backup_step() can be retried later on. ^(If ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or ** [SQLITE_READONLY] is returned, then ** there is no point in retrying the call to sqlite3_backup_step(). These ** errors are considered fatal.)^ The application must accept ** that the backup operation has failed and pass the backup operation handle ** to the sqlite3_backup_finish() to release associated resources. ** ** ^The first call to sqlite3_backup_step() obtains an exclusive lock ** on the destination file. ^The exclusive lock is not released until either ** sqlite3_backup_finish() is called or the backup operation is complete ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to ** sqlite3_backup_step() obtains a [shared lock] on the source database that ** lasts for the duration of the sqlite3_backup_step() call. ** ^Because the source database is not locked between calls to ** sqlite3_backup_step(), the source database may be modified mid-way ** through the backup process. ^If the source database is modified by an ** external process or via a database connection other than the one being ** used by the backup operation, then the backup will be automatically ** restarted by the next call to sqlite3_backup_step(). ^If the source ** database is modified by the using the same database connection as is used ** by the backup operation, then the backup database is automatically ** updated at the same time. ** ** [[sqlite3_backup_finish()]] sqlite3_backup_finish() ** ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the ** application wishes to abandon the backup operation, the application ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). ** ^The sqlite3_backup_finish() interfaces releases all ** resources associated with the [sqlite3_backup] object. ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any ** active write-transaction on the destination database is rolled back. ** The [sqlite3_backup] object is invalid ** and may not be used following a call to sqlite3_backup_finish(). ** ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no ** sqlite3_backup_step() errors occurred, regardless or whether or not ** sqlite3_backup_step() completed. ** ^If an out-of-memory condition or IO error occurred during any prior ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then ** sqlite3_backup_finish() returns the corresponding [error code]. ** ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() ** is not a permanent error and does not affect the return value of ** sqlite3_backup_finish(). ** ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] ** sqlite3_backup_remaining() and sqlite3_backup_pagecount() ** ** ^Each call to sqlite3_backup_step() sets two values inside ** the [sqlite3_backup] object: the number of pages still to be backed ** up and the total number of pages in the source database file. ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces ** retrieve these two values, respectively. ** ** ^The values returned by these functions are only updated by ** sqlite3_backup_step(). ^If the source database is modified during a backup ** operation, then the values are not updated to account for any extra ** pages that need to be updated or the size of the source database file ** changing. ** ** Concurrent Usage of Database Handles ** ** ^The source [database connection] may be used by the application for other ** purposes while a backup operation is underway or being initialized. ** ^If SQLite is compiled and configured to support threadsafe database ** connections, then the source database connection may be used concurrently ** from within other threads. ** ** However, the application must guarantee that the destination ** [database connection] is not passed to any other API (by any thread) after ** sqlite3_backup_init() is called and before the corresponding call to ** sqlite3_backup_finish(). SQLite does not currently check to see ** if the application incorrectly accesses the destination [database connection] ** and so no error code is reported, but the operations may malfunction ** nevertheless. Use of the destination database connection while a ** backup is in progress might also also cause a mutex deadlock. ** ** If running in [shared cache mode], the application must ** guarantee that the shared cache used by the destination database ** is not accessed while the backup is running. In practice this means ** that the application must guarantee that the disk file being ** backed up to is not accessed by any connection within the process, ** not just the specific connection that was passed to sqlite3_backup_init(). ** ** The [sqlite3_backup] object itself is partially threadsafe. Multiple ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() ** APIs are not strictly speaking threadsafe. If they are invoked at the ** same time as another thread is invoking sqlite3_backup_step() it is ** possible that they return invalid values. */ SQLITE_API sqlite3_backup *sqlite3_backup_init( sqlite3 *pDest, /* Destination database handle */ const char *zDestName, /* Destination database name */ sqlite3 *pSource, /* Source database handle */ const char *zSourceName /* Source database name */ ); SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); /* ** CAPI3REF: Unlock Notification ** ** ^When running in shared-cache mode, a database operation may fail with ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or ** individual tables within the shared-cache cannot be obtained. See ** [SQLite Shared-Cache Mode] for a description of shared-cache locking. ** ^This API may be used to register a callback that SQLite will invoke ** when the connection currently holding the required lock relinquishes it. ** ^This API is only available if the library was compiled with the ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. ** ** See Also: [Using the SQLite Unlock Notification Feature]. ** ** ^Shared-cache locks are released when a database connection concludes ** its current transaction, either by committing it or rolling it back. ** ** ^When a connection (known as the blocked connection) fails to obtain a ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the ** identity of the database connection (the blocking connection) that ** has locked the required resource is stored internally. ^After an ** application receives an SQLITE_LOCKED error, it may call the ** sqlite3_unlock_notify() method with the blocked connection handle as ** the first argument to register for a callback that will be invoked ** when the blocking connections current transaction is concluded. ^The ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] ** call that concludes the blocking connections transaction. ** ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, ** there is a chance that the blocking connection will have already ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. ** If this happens, then the specified callback is invoked immediately, ** from within the call to sqlite3_unlock_notify().)^ ** ** ^If the blocked connection is attempting to obtain a write-lock on a ** shared-cache table, and more than one other connection currently holds ** a read-lock on the same table, then SQLite arbitrarily selects one of ** the other connections to use as the blocking connection. ** ** ^(There may be at most one unlock-notify callback registered by a ** blocked connection. If sqlite3_unlock_notify() is called when the ** blocked connection already has a registered unlock-notify callback, ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is ** called with a NULL pointer as its second argument, then any existing ** unlock-notify callback is canceled. ^The blocked connections ** unlock-notify callback may also be canceled by closing the blocked ** connection using [sqlite3_close()]. ** ** The unlock-notify callback is not reentrant. If an application invokes ** any sqlite3_xxx API functions from within an unlock-notify callback, a ** crash or deadlock may be the result. ** ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always ** returns SQLITE_OK. ** ** Callback Invocation Details ** ** When an unlock-notify callback is registered, the application provides a ** single void* pointer that is passed to the callback when it is invoked. ** However, the signature of the callback function allows SQLite to pass ** it an array of void* context pointers. The first argument passed to ** an unlock-notify callback is a pointer to an array of void* pointers, ** and the second is the number of entries in the array. ** ** When a blocking connections transaction is concluded, there may be ** more than one blocked connection that has registered for an unlock-notify ** callback. ^If two or more such blocked connections have specified the ** same callback function, then instead of invoking the callback function ** multiple times, it is invoked once with the set of void* context pointers ** specified by the blocked connections bundled together into an array. ** This gives the application an opportunity to prioritize any actions ** related to the set of unblocked database connections. ** ** Deadlock Detection ** ** Assuming that after registering for an unlock-notify callback a ** database waits for the callback to be issued before taking any further ** action (a reasonable assumption), then using this API may cause the ** application to deadlock. For example, if connection X is waiting for ** connection Y's transaction to be concluded, and similarly connection ** Y is waiting on connection X's transaction, then neither connection ** will proceed and the system may remain deadlocked indefinitely. ** ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock ** detection. ^If a given call to sqlite3_unlock_notify() would put the ** system in a deadlocked state, then SQLITE_LOCKED is returned and no ** unlock-notify callback is registered. The system is said to be in ** a deadlocked state if connection A has registered for an unlock-notify ** callback on the conclusion of connection B's transaction, and connection ** B has itself registered for an unlock-notify callback when connection ** A's transaction is concluded. ^Indirect deadlock is also detected, so ** the system is also considered to be deadlocked if connection B has ** registered for an unlock-notify callback on the conclusion of connection ** C's transaction, where connection C is waiting on connection A. ^Any ** number of levels of indirection are allowed. ** ** The "DROP TABLE" Exception ** ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost ** always appropriate to call sqlite3_unlock_notify(). There is however, ** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, ** SQLite checks if there are any currently executing SELECT statements ** that belong to the same connection. If there are, SQLITE_LOCKED is ** returned. In this case there is no "blocking connection", so invoking ** sqlite3_unlock_notify() results in the unlock-notify callback being ** invoked immediately. If the application then re-attempts the "DROP TABLE" ** or "DROP INDEX" query, an infinite loop might be the result. ** ** One way around this problem is to check the extended error code returned ** by an sqlite3_step() call. ^(If there is a blocking connection, then the ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in ** the special "DROP TABLE/INDEX" case, the extended error code is just ** SQLITE_LOCKED.)^ */ SQLITE_API int sqlite3_unlock_notify( sqlite3 *pBlocked, /* Waiting connection */ void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ void *pNotifyArg /* Argument to pass to xNotify */ ); /* ** CAPI3REF: String Comparison ** ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications ** and extensions to compare the contents of two buffers containing UTF-8 ** strings in a case-independent fashion, using the same definition of "case ** independence" that SQLite uses internally when comparing identifiers. */ SQLITE_API int sqlite3_stricmp(const char *, const char *); SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); /* ** CAPI3REF: Error Logging Interface ** ** ^The [sqlite3_log()] interface writes a message into the error log ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. ** ^If logging is enabled, the zFormat string and subsequent arguments are ** used with [sqlite3_snprintf()] to generate the final output string. ** ** The sqlite3_log() interface is intended for use by extensions such as ** virtual tables, collating functions, and SQL functions. While there is ** nothing to prevent an application from calling sqlite3_log(), doing so ** is considered bad form. ** ** The zFormat string must not be NULL. ** ** To avoid deadlocks and other threading problems, the sqlite3_log() routine ** will not use dynamically allocated memory. The log message is stored in ** a fixed-length buffer on the stack. If the log message is longer than ** a few hundred characters, it will be truncated to the length of the ** buffer. */ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...); /* ** CAPI3REF: Write-Ahead Log Commit Hook ** ** ^The [sqlite3_wal_hook()] function is used to register a callback that ** will be invoked each time a database connection commits data to a ** [write-ahead log] (i.e. whenever a transaction is committed in ** [journal_mode | journal_mode=WAL mode]). ** ** ^The callback is invoked by SQLite after the commit has taken place and ** the associated write-lock on the database released, so the implementation ** may read, write or [checkpoint] the database as required. ** ** ^The first parameter passed to the callback function when it is invoked ** is a copy of the third parameter passed to sqlite3_wal_hook() when ** registering the callback. ^The second is a copy of the database handle. ** ^The third parameter is the name of the database that was written to - ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter ** is the number of pages currently in the write-ahead log file, ** including those that were just committed. ** ** The callback function should normally return [SQLITE_OK]. ^If an error ** code is returned, that error will propagate back up through the ** SQLite code base to cause the statement that provoked the callback ** to report an error, though the commit will have still occurred. If the ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value ** that does not correspond to any valid SQLite error code, the results ** are undefined. ** ** A single database handle may have at most a single write-ahead log callback ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any ** previously registered write-ahead log callback. ^Note that the ** [sqlite3_wal_autocheckpoint()] interface and the ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will ** those overwrite any prior [sqlite3_wal_hook()] settings. */ SQLITE_API void *sqlite3_wal_hook( sqlite3*, int(*)(void *,sqlite3*,const char*,int), void* ); /* ** CAPI3REF: Configure an auto-checkpoint ** ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around ** [sqlite3_wal_hook()] that causes any database on [database connection] D ** to automatically [checkpoint] ** after committing a transaction if there are N or ** more frames in the [write-ahead log] file. ^Passing zero or ** a negative value as the nFrame parameter disables automatic ** checkpoints entirely. ** ** ^The callback registered by this function replaces any existing callback ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism ** configured by this function. ** ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface ** from SQL. ** ** ^Every new [database connection] defaults to having the auto-checkpoint ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] ** pages. The use of this interface ** is only necessary if the default setting is found to be suboptimal ** for a particular application. */ SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); /* ** CAPI3REF: Checkpoint a database ** ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X ** on [database connection] D to be [checkpointed]. ^If X is NULL or an ** empty string, then a checkpoint is run on all databases of ** connection D. ^If the database connection D is not in ** [WAL | write-ahead log mode] then this interface is a harmless no-op. ** ** ^The [wal_checkpoint pragma] can be used to invoke this interface ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the ** [wal_autocheckpoint pragma] can be used to cause this interface to be ** run whenever the WAL reaches a certain size threshold. ** ** See also: [sqlite3_wal_checkpoint_v2()] */ SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); /* ** CAPI3REF: Checkpoint a database ** ** Run a checkpoint operation on WAL database zDb attached to database ** handle db. The specific operation is determined by the value of the ** eMode parameter: ** **
**
SQLITE_CHECKPOINT_PASSIVE
** Checkpoint as many frames as possible without waiting for any database ** readers or writers to finish. Sync the db file if all frames in the log ** are checkpointed. This mode is the same as calling ** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked. ** **
SQLITE_CHECKPOINT_FULL
** This mode blocks (calls the busy-handler callback) until there is no ** database writer and all readers are reading from the most recent database ** snapshot. It then checkpoints all frames in the log file and syncs the ** database file. This call blocks database writers while it is running, ** but not database readers. ** **
SQLITE_CHECKPOINT_RESTART
** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after ** checkpointing the log file it blocks (calls the busy-handler callback) ** until all readers are reading from the database file only. This ensures ** that the next client to write to the database file restarts the log file ** from the beginning. This call blocks database writers while it is running, ** but not database readers. **
** ** If pnLog is not NULL, then *pnLog is set to the total number of frames in ** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to ** the total number of checkpointed frames (including any that were already ** checkpointed when this function is called). *pnLog and *pnCkpt may be ** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK. ** If no values are available because of an error, they are both set to -1 ** before returning to communicate this to the caller. ** ** All calls obtain an exclusive "checkpoint" lock on the database file. If ** any other process is running a checkpoint operation at the same time, the ** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a ** busy-handler configured, it will not be invoked in this case. ** ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive ** "writer" lock on the database file. If the writer lock cannot be obtained ** immediately, and a busy-handler is configured, it is invoked and the writer ** lock retried until either the busy-handler returns 0 or the lock is ** successfully obtained. The busy-handler is also invoked while waiting for ** database readers as described above. If the busy-handler returns 0 before ** the writer lock is obtained or while waiting for database readers, the ** checkpoint operation proceeds from that point in the same way as ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible ** without blocking any further. SQLITE_BUSY is returned in this case. ** ** If parameter zDb is NULL or points to a zero length string, then the ** specified operation is attempted on all WAL databases. In this case the ** values written to output parameters *pnLog and *pnCkpt are undefined. If ** an SQLITE_BUSY error is encountered when processing one or more of the ** attached WAL databases, the operation is still attempted on any remaining ** attached databases and SQLITE_BUSY is returned to the caller. If any other ** error occurs while processing an attached database, processing is abandoned ** and the error code returned to the caller immediately. If no error ** (SQLITE_BUSY or otherwise) is encountered while processing the attached ** databases, SQLITE_OK is returned. ** ** If database zDb is the name of an attached database that is not in WAL ** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If ** zDb is not NULL (or a zero length string) and is not the name of any ** attached database, SQLITE_ERROR is returned to the caller. */ SQLITE_API int sqlite3_wal_checkpoint_v2( sqlite3 *db, /* Database handle */ const char *zDb, /* Name of attached database (or NULL) */ int eMode, /* SQLITE_CHECKPOINT_* value */ int *pnLog, /* OUT: Size of WAL log in frames */ int *pnCkpt /* OUT: Total number of frames checkpointed */ ); /* ** CAPI3REF: Checkpoint operation parameters ** ** These constants can be used as the 3rd parameter to ** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()] ** documentation for additional information about the meaning and use of ** each of these values. */ #define SQLITE_CHECKPOINT_PASSIVE 0 #define SQLITE_CHECKPOINT_FULL 1 #define SQLITE_CHECKPOINT_RESTART 2 /* ** CAPI3REF: Virtual Table Interface Configuration ** ** This function may be called by either the [xConnect] or [xCreate] method ** of a [virtual table] implementation to configure ** various facets of the virtual table interface. ** ** If this interface is invoked outside the context of an xConnect or ** xCreate virtual table method then the behavior is undefined. ** ** At present, there is only one option that may be configured using ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options ** may be added in the future. */ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); /* ** CAPI3REF: Virtual Table Configuration Options ** ** These macros define the various options to the ** [sqlite3_vtab_config()] interface that [virtual table] implementations ** can use to customize and optimize their behavior. ** **
**
SQLITE_VTAB_CONSTRAINT_SUPPORT **
Calls of the form ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, ** where X is an integer. If X is zero, then the [virtual table] whose ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not ** support constraints. In this configuration (which is the default) if ** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire ** statement is rolled back as if [ON CONFLICT | OR ABORT] had been ** specified as part of the users SQL statement, regardless of the actual ** ON CONFLICT mode specified. ** ** If X is non-zero, then the virtual table implementation guarantees ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before ** any modifications to internal or persistent data structures have been made. ** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite ** is able to roll back a statement or database transaction, and abandon ** or continue processing the current SQL statement as appropriate. ** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode ** had been ABORT. ** ** Virtual table implementations that are required to handle OR REPLACE ** must do so within the [xUpdate] method. If a call to the ** [sqlite3_vtab_on_conflict()] function indicates that the current ON ** CONFLICT policy is REPLACE, the virtual table implementation should ** silently replace the appropriate rows within the xUpdate callback and ** return SQLITE_OK. Or, if this is not possible, it may return ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT ** constraint handling. **
*/ #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 /* ** CAPI3REF: Determine The Virtual Table Conflict Policy ** ** This function may only be called from within a call to the [xUpdate] method ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode ** of the SQL statement that triggered the call to the [xUpdate] method of the ** [virtual table]. */ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *); /* ** CAPI3REF: Conflict resolution modes ** ** These constants are returned by [sqlite3_vtab_on_conflict()] to ** inform a [virtual table] implementation what the [ON CONFLICT] mode ** is for the SQL statement being evaluated. ** ** Note that the [SQLITE_IGNORE] constant is also used as a potential ** return value from the [sqlite3_set_authorizer()] callback and that ** [SQLITE_ABORT] is also a [result code]. */ #define SQLITE_ROLLBACK 1 /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */ #define SQLITE_FAIL 3 /* #define SQLITE_ABORT 4 // Also an error code */ #define SQLITE_REPLACE 5 /* ** Undo the hack that converts floating point types to integer for ** builds on processors without floating point support. */ #ifdef SQLITE_OMIT_FLOATING_POINT # undef double #endif #ifdef __cplusplus } /* End of the 'extern "C"' block */ #endif #endif /* ** 2010 August 30 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* */ #ifndef _SQLITE3RTREE_H_ #define _SQLITE3RTREE_H_ #ifdef __cplusplus extern "C" { #endif typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; /* ** Register a geometry callback named zGeom that can be used as part of an ** R-Tree geometry query as follows: ** ** SELECT ... FROM WHERE MATCH $zGeom(... params ...) */ SQLITE_API int sqlite3_rtree_geometry_callback( sqlite3 *db, const char *zGeom, #ifdef SQLITE_RTREE_INT_ONLY int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes), #else int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes), #endif void *pContext ); /* ** A pointer to a structure of the following type is passed as the first ** argument to callbacks registered using rtree_geometry_callback(). */ struct sqlite3_rtree_geometry { void *pContext; /* Copy of pContext passed to s_r_g_c() */ int nParam; /* Size of array aParam[] */ double *aParam; /* Parameters passed to SQL geom function */ void *pUser; /* Callback implementation user data */ void (*xDelUser)(void *); /* Called by SQLite to clean up pUser */ }; #ifdef __cplusplus } /* end of the 'extern "C"' block */ #endif #endif /* ifndef _SQLITE3RTREE_H_ */ ================================================ FILE: cocos2d/external/sqlite3/include/sqlite3ext.h ================================================ /* ** 2006 June 7 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the SQLite interface for use by ** shared libraries that want to be imported as extensions into ** an SQLite instance. Shared libraries that intend to be loaded ** as extensions by SQLite should #include this file instead of ** sqlite3.h. */ #ifndef _SQLITE3EXT_H_ #define _SQLITE3EXT_H_ #include "sqlite3.h" typedef struct sqlite3_api_routines sqlite3_api_routines; /* ** The following structure holds pointers to all of the SQLite API ** routines. ** ** WARNING: In order to maintain backwards compatibility, add new ** interfaces to the end of this structure only. If you insert new ** interfaces in the middle of this structure, then older different ** versions of SQLite will not be able to load each others' shared ** libraries! */ struct sqlite3_api_routines { void * (*aggregate_context)(sqlite3_context*,int nBytes); int (*aggregate_count)(sqlite3_context*); int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); int (*bind_double)(sqlite3_stmt*,int,double); int (*bind_int)(sqlite3_stmt*,int,int); int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64); int (*bind_null)(sqlite3_stmt*,int); int (*bind_parameter_count)(sqlite3_stmt*); int (*bind_parameter_index)(sqlite3_stmt*,const char*zName); const char * (*bind_parameter_name)(sqlite3_stmt*,int); int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*)); int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*)); int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*); int (*busy_handler)(sqlite3*,int(*)(void*,int),void*); int (*busy_timeout)(sqlite3*,int ms); int (*changes)(sqlite3*); int (*close)(sqlite3*); int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*, int eTextRep,const char*)); int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*, int eTextRep,const void*)); const void * (*column_blob)(sqlite3_stmt*,int iCol); int (*column_bytes)(sqlite3_stmt*,int iCol); int (*column_bytes16)(sqlite3_stmt*,int iCol); int (*column_count)(sqlite3_stmt*pStmt); const char * (*column_database_name)(sqlite3_stmt*,int); const void * (*column_database_name16)(sqlite3_stmt*,int); const char * (*column_decltype)(sqlite3_stmt*,int i); const void * (*column_decltype16)(sqlite3_stmt*,int); double (*column_double)(sqlite3_stmt*,int iCol); int (*column_int)(sqlite3_stmt*,int iCol); sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol); const char * (*column_name)(sqlite3_stmt*,int); const void * (*column_name16)(sqlite3_stmt*,int); const char * (*column_origin_name)(sqlite3_stmt*,int); const void * (*column_origin_name16)(sqlite3_stmt*,int); const char * (*column_table_name)(sqlite3_stmt*,int); const void * (*column_table_name16)(sqlite3_stmt*,int); const unsigned char * (*column_text)(sqlite3_stmt*,int iCol); const void * (*column_text16)(sqlite3_stmt*,int iCol); int (*column_type)(sqlite3_stmt*,int iCol); sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol); void * (*commit_hook)(sqlite3*,int(*)(void*),void*); int (*complete)(const char*sql); int (*complete16)(const void*sql); int (*create_collation)(sqlite3*,const char*,int,void*, int(*)(void*,int,const void*,int,const void*)); int (*create_collation16)(sqlite3*,const void*,int,void*, int(*)(void*,int,const void*,int,const void*)); int (*create_function)(sqlite3*,const char*,int,int,void*, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*)); int (*create_function16)(sqlite3*,const void*,int,int,void*, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*)); int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); int (*data_count)(sqlite3_stmt*pStmt); sqlite3 * (*db_handle)(sqlite3_stmt*); int (*declare_vtab)(sqlite3*,const char*); int (*enable_shared_cache)(int); int (*errcode)(sqlite3*db); const char * (*errmsg)(sqlite3*); const void * (*errmsg16)(sqlite3*); int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**); int (*expired)(sqlite3_stmt*); int (*finalize)(sqlite3_stmt*pStmt); void (*free)(void*); void (*free_table)(char**result); int (*get_autocommit)(sqlite3*); void * (*get_auxdata)(sqlite3_context*,int); int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**); int (*global_recover)(void); void (*interruptx)(sqlite3*); sqlite_int64 (*last_insert_rowid)(sqlite3*); const char * (*libversion)(void); int (*libversion_number)(void); void *(*malloc)(int); char * (*mprintf)(const char*,...); int (*open)(const char*,sqlite3**); int (*open16)(const void*,sqlite3**); int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*); void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); void *(*realloc)(void*,int); int (*reset)(sqlite3_stmt*pStmt); void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_double)(sqlite3_context*,double); void (*result_error)(sqlite3_context*,const char*,int); void (*result_error16)(sqlite3_context*,const void*,int); void (*result_int)(sqlite3_context*,int); void (*result_int64)(sqlite3_context*,sqlite_int64); void (*result_null)(sqlite3_context*); void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*)); void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_value)(sqlite3_context*,sqlite3_value*); void * (*rollback_hook)(sqlite3*,void(*)(void*),void*); int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*, const char*,const char*),void*); void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*)); char * (*snprintf)(int,char*,const char*,...); int (*step)(sqlite3_stmt*); int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*, char const**,char const**,int*,int*,int*); void (*thread_cleanup)(void); int (*total_changes)(sqlite3*); void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*); int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*); void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*, sqlite_int64),void*); void * (*user_data)(sqlite3_context*); const void * (*value_blob)(sqlite3_value*); int (*value_bytes)(sqlite3_value*); int (*value_bytes16)(sqlite3_value*); double (*value_double)(sqlite3_value*); int (*value_int)(sqlite3_value*); sqlite_int64 (*value_int64)(sqlite3_value*); int (*value_numeric_type)(sqlite3_value*); const unsigned char * (*value_text)(sqlite3_value*); const void * (*value_text16)(sqlite3_value*); const void * (*value_text16be)(sqlite3_value*); const void * (*value_text16le)(sqlite3_value*); int (*value_type)(sqlite3_value*); char *(*vmprintf)(const char*,va_list); /* Added ??? */ int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); /* Added by 3.3.13 */ int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); int (*clear_bindings)(sqlite3_stmt*); /* Added by 3.4.1 */ int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*, void (*xDestroy)(void *)); /* Added by 3.5.0 */ int (*bind_zeroblob)(sqlite3_stmt*,int,int); int (*blob_bytes)(sqlite3_blob*); int (*blob_close)(sqlite3_blob*); int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64, int,sqlite3_blob**); int (*blob_read)(sqlite3_blob*,void*,int,int); int (*blob_write)(sqlite3_blob*,const void*,int,int); int (*create_collation_v2)(sqlite3*,const char*,int,void*, int(*)(void*,int,const void*,int,const void*), void(*)(void*)); int (*file_control)(sqlite3*,const char*,int,void*); sqlite3_int64 (*memory_highwater)(int); sqlite3_int64 (*memory_used)(void); sqlite3_mutex *(*mutex_alloc)(int); void (*mutex_enter)(sqlite3_mutex*); void (*mutex_free)(sqlite3_mutex*); void (*mutex_leave)(sqlite3_mutex*); int (*mutex_try)(sqlite3_mutex*); int (*open_v2)(const char*,sqlite3**,int,const char*); int (*release_memory)(int); void (*result_error_nomem)(sqlite3_context*); void (*result_error_toobig)(sqlite3_context*); int (*sleep)(int); void (*soft_heap_limit)(int); sqlite3_vfs *(*vfs_find)(const char*); int (*vfs_register)(sqlite3_vfs*,int); int (*vfs_unregister)(sqlite3_vfs*); int (*xthreadsafe)(void); void (*result_zeroblob)(sqlite3_context*,int); void (*result_error_code)(sqlite3_context*,int); int (*test_control)(int, ...); void (*randomness)(int,void*); sqlite3 *(*context_db_handle)(sqlite3_context*); int (*extended_result_codes)(sqlite3*,int); int (*limit)(sqlite3*,int,int); sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*); const char *(*sql)(sqlite3_stmt*); int (*status)(int,int*,int*,int); int (*backup_finish)(sqlite3_backup*); sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*); int (*backup_pagecount)(sqlite3_backup*); int (*backup_remaining)(sqlite3_backup*); int (*backup_step)(sqlite3_backup*,int); const char *(*compileoption_get)(int); int (*compileoption_used)(const char*); int (*create_function_v2)(sqlite3*,const char*,int,int,void*, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*), void(*xDestroy)(void*)); int (*db_config)(sqlite3*,int,...); sqlite3_mutex *(*db_mutex)(sqlite3*); int (*db_status)(sqlite3*,int,int*,int*,int); int (*extended_errcode)(sqlite3*); void (*log)(int,const char*,...); sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64); const char *(*sourceid)(void); int (*stmt_status)(sqlite3_stmt*,int,int); int (*strnicmp)(const char*,const char*,int); int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*); int (*wal_autocheckpoint)(sqlite3*,int); int (*wal_checkpoint)(sqlite3*,const char*); void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*); int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); int (*vtab_config)(sqlite3*,int op,...); int (*vtab_on_conflict)(sqlite3*); }; /* ** The following macros redefine the API routines so that they are ** redirected throught the global sqlite3_api structure. ** ** This header file is also used by the loadext.c source file ** (part of the main SQLite library - not an extension) so that ** it can get access to the sqlite3_api_routines structure ** definition. But the main library does not want to redefine ** the API. So the redefinition macros are only valid if the ** SQLITE_CORE macros is undefined. */ #ifndef SQLITE_CORE #define sqlite3_aggregate_context sqlite3_api->aggregate_context #ifndef SQLITE_OMIT_DEPRECATED #define sqlite3_aggregate_count sqlite3_api->aggregate_count #endif #define sqlite3_bind_blob sqlite3_api->bind_blob #define sqlite3_bind_double sqlite3_api->bind_double #define sqlite3_bind_int sqlite3_api->bind_int #define sqlite3_bind_int64 sqlite3_api->bind_int64 #define sqlite3_bind_null sqlite3_api->bind_null #define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count #define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index #define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name #define sqlite3_bind_text sqlite3_api->bind_text #define sqlite3_bind_text16 sqlite3_api->bind_text16 #define sqlite3_bind_value sqlite3_api->bind_value #define sqlite3_busy_handler sqlite3_api->busy_handler #define sqlite3_busy_timeout sqlite3_api->busy_timeout #define sqlite3_changes sqlite3_api->changes #define sqlite3_close sqlite3_api->close #define sqlite3_collation_needed sqlite3_api->collation_needed #define sqlite3_collation_needed16 sqlite3_api->collation_needed16 #define sqlite3_column_blob sqlite3_api->column_blob #define sqlite3_column_bytes sqlite3_api->column_bytes #define sqlite3_column_bytes16 sqlite3_api->column_bytes16 #define sqlite3_column_count sqlite3_api->column_count #define sqlite3_column_database_name sqlite3_api->column_database_name #define sqlite3_column_database_name16 sqlite3_api->column_database_name16 #define sqlite3_column_decltype sqlite3_api->column_decltype #define sqlite3_column_decltype16 sqlite3_api->column_decltype16 #define sqlite3_column_double sqlite3_api->column_double #define sqlite3_column_int sqlite3_api->column_int #define sqlite3_column_int64 sqlite3_api->column_int64 #define sqlite3_column_name sqlite3_api->column_name #define sqlite3_column_name16 sqlite3_api->column_name16 #define sqlite3_column_origin_name sqlite3_api->column_origin_name #define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16 #define sqlite3_column_table_name sqlite3_api->column_table_name #define sqlite3_column_table_name16 sqlite3_api->column_table_name16 #define sqlite3_column_text sqlite3_api->column_text #define sqlite3_column_text16 sqlite3_api->column_text16 #define sqlite3_column_type sqlite3_api->column_type #define sqlite3_column_value sqlite3_api->column_value #define sqlite3_commit_hook sqlite3_api->commit_hook #define sqlite3_complete sqlite3_api->complete #define sqlite3_complete16 sqlite3_api->complete16 #define sqlite3_create_collation sqlite3_api->create_collation #define sqlite3_create_collation16 sqlite3_api->create_collation16 #define sqlite3_create_function sqlite3_api->create_function #define sqlite3_create_function16 sqlite3_api->create_function16 #define sqlite3_create_module sqlite3_api->create_module #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 #define sqlite3_data_count sqlite3_api->data_count #define sqlite3_db_handle sqlite3_api->db_handle #define sqlite3_declare_vtab sqlite3_api->declare_vtab #define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache #define sqlite3_errcode sqlite3_api->errcode #define sqlite3_errmsg sqlite3_api->errmsg #define sqlite3_errmsg16 sqlite3_api->errmsg16 #define sqlite3_exec sqlite3_api->exec #ifndef SQLITE_OMIT_DEPRECATED #define sqlite3_expired sqlite3_api->expired #endif #define sqlite3_finalize sqlite3_api->finalize #define sqlite3_free sqlite3_api->free #define sqlite3_free_table sqlite3_api->free_table #define sqlite3_get_autocommit sqlite3_api->get_autocommit #define sqlite3_get_auxdata sqlite3_api->get_auxdata #define sqlite3_get_table sqlite3_api->get_table #ifndef SQLITE_OMIT_DEPRECATED #define sqlite3_global_recover sqlite3_api->global_recover #endif #define sqlite3_interrupt sqlite3_api->interruptx #define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid #define sqlite3_libversion sqlite3_api->libversion #define sqlite3_libversion_number sqlite3_api->libversion_number #define sqlite3_malloc sqlite3_api->malloc #define sqlite3_mprintf sqlite3_api->mprintf #define sqlite3_open sqlite3_api->open #define sqlite3_open16 sqlite3_api->open16 #define sqlite3_prepare sqlite3_api->prepare #define sqlite3_prepare16 sqlite3_api->prepare16 #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 #define sqlite3_profile sqlite3_api->profile #define sqlite3_progress_handler sqlite3_api->progress_handler #define sqlite3_realloc sqlite3_api->realloc #define sqlite3_reset sqlite3_api->reset #define sqlite3_result_blob sqlite3_api->result_blob #define sqlite3_result_double sqlite3_api->result_double #define sqlite3_result_error sqlite3_api->result_error #define sqlite3_result_error16 sqlite3_api->result_error16 #define sqlite3_result_int sqlite3_api->result_int #define sqlite3_result_int64 sqlite3_api->result_int64 #define sqlite3_result_null sqlite3_api->result_null #define sqlite3_result_text sqlite3_api->result_text #define sqlite3_result_text16 sqlite3_api->result_text16 #define sqlite3_result_text16be sqlite3_api->result_text16be #define sqlite3_result_text16le sqlite3_api->result_text16le #define sqlite3_result_value sqlite3_api->result_value #define sqlite3_rollback_hook sqlite3_api->rollback_hook #define sqlite3_set_authorizer sqlite3_api->set_authorizer #define sqlite3_set_auxdata sqlite3_api->set_auxdata #define sqlite3_snprintf sqlite3_api->snprintf #define sqlite3_step sqlite3_api->step #define sqlite3_table_column_metadata sqlite3_api->table_column_metadata #define sqlite3_thread_cleanup sqlite3_api->thread_cleanup #define sqlite3_total_changes sqlite3_api->total_changes #define sqlite3_trace sqlite3_api->trace #ifndef SQLITE_OMIT_DEPRECATED #define sqlite3_transfer_bindings sqlite3_api->transfer_bindings #endif #define sqlite3_update_hook sqlite3_api->update_hook #define sqlite3_user_data sqlite3_api->user_data #define sqlite3_value_blob sqlite3_api->value_blob #define sqlite3_value_bytes sqlite3_api->value_bytes #define sqlite3_value_bytes16 sqlite3_api->value_bytes16 #define sqlite3_value_double sqlite3_api->value_double #define sqlite3_value_int sqlite3_api->value_int #define sqlite3_value_int64 sqlite3_api->value_int64 #define sqlite3_value_numeric_type sqlite3_api->value_numeric_type #define sqlite3_value_text sqlite3_api->value_text #define sqlite3_value_text16 sqlite3_api->value_text16 #define sqlite3_value_text16be sqlite3_api->value_text16be #define sqlite3_value_text16le sqlite3_api->value_text16le #define sqlite3_value_type sqlite3_api->value_type #define sqlite3_vmprintf sqlite3_api->vmprintf #define sqlite3_overload_function sqlite3_api->overload_function #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 #define sqlite3_clear_bindings sqlite3_api->clear_bindings #define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob #define sqlite3_blob_bytes sqlite3_api->blob_bytes #define sqlite3_blob_close sqlite3_api->blob_close #define sqlite3_blob_open sqlite3_api->blob_open #define sqlite3_blob_read sqlite3_api->blob_read #define sqlite3_blob_write sqlite3_api->blob_write #define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2 #define sqlite3_file_control sqlite3_api->file_control #define sqlite3_memory_highwater sqlite3_api->memory_highwater #define sqlite3_memory_used sqlite3_api->memory_used #define sqlite3_mutex_alloc sqlite3_api->mutex_alloc #define sqlite3_mutex_enter sqlite3_api->mutex_enter #define sqlite3_mutex_free sqlite3_api->mutex_free #define sqlite3_mutex_leave sqlite3_api->mutex_leave #define sqlite3_mutex_try sqlite3_api->mutex_try #define sqlite3_open_v2 sqlite3_api->open_v2 #define sqlite3_release_memory sqlite3_api->release_memory #define sqlite3_result_error_nomem sqlite3_api->result_error_nomem #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig #define sqlite3_sleep sqlite3_api->sleep #define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit #define sqlite3_vfs_find sqlite3_api->vfs_find #define sqlite3_vfs_register sqlite3_api->vfs_register #define sqlite3_vfs_unregister sqlite3_api->vfs_unregister #define sqlite3_threadsafe sqlite3_api->xthreadsafe #define sqlite3_result_zeroblob sqlite3_api->result_zeroblob #define sqlite3_result_error_code sqlite3_api->result_error_code #define sqlite3_test_control sqlite3_api->test_control #define sqlite3_randomness sqlite3_api->randomness #define sqlite3_context_db_handle sqlite3_api->context_db_handle #define sqlite3_extended_result_codes sqlite3_api->extended_result_codes #define sqlite3_limit sqlite3_api->limit #define sqlite3_next_stmt sqlite3_api->next_stmt #define sqlite3_sql sqlite3_api->sql #define sqlite3_status sqlite3_api->status #define sqlite3_backup_finish sqlite3_api->backup_finish #define sqlite3_backup_init sqlite3_api->backup_init #define sqlite3_backup_pagecount sqlite3_api->backup_pagecount #define sqlite3_backup_remaining sqlite3_api->backup_remaining #define sqlite3_backup_step sqlite3_api->backup_step #define sqlite3_compileoption_get sqlite3_api->compileoption_get #define sqlite3_compileoption_used sqlite3_api->compileoption_used #define sqlite3_create_function_v2 sqlite3_api->create_function_v2 #define sqlite3_db_config sqlite3_api->db_config #define sqlite3_db_mutex sqlite3_api->db_mutex #define sqlite3_db_status sqlite3_api->db_status #define sqlite3_extended_errcode sqlite3_api->extended_errcode #define sqlite3_log sqlite3_api->log #define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64 #define sqlite3_sourceid sqlite3_api->sourceid #define sqlite3_stmt_status sqlite3_api->stmt_status #define sqlite3_strnicmp sqlite3_api->strnicmp #define sqlite3_unlock_notify sqlite3_api->unlock_notify #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint #define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint #define sqlite3_wal_hook sqlite3_api->wal_hook #define sqlite3_blob_reopen sqlite3_api->blob_reopen #define sqlite3_vtab_config sqlite3_api->vtab_config #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict #endif /* SQLITE_CORE */ #define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0; #define SQLITE_EXTENSION_INIT2(v) sqlite3_api = v; #endif /* _SQLITE3EXT_H_ */ ================================================ FILE: cocos2d/external/tiff/include/android/tiff.h ================================================ /* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ #define _TIFF_ #include "tiffconf.h" /* * Tag Image File Format (TIFF) * * Based on Rev 6.0 from: * Developer's Desk * Aldus Corporation * 411 First Ave. South * Suite 200 * Seattle, WA 98104 * 206-622-5500 * * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) * * For BigTIFF design notes see the following links * http://www.remotesensing.org/libtiff/bigtiffdesign.html * http://www.awaresystems.be/imaging/tiff/bigtiff.html */ #define TIFF_VERSION_CLASSIC 42 #define TIFF_VERSION_BIG 43 #define TIFF_BIGENDIAN 0x4d4d #define TIFF_LITTLEENDIAN 0x4949 #define MDI_LITTLEENDIAN 0x5045 #define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * * 8-bit quantities int8/uint8 * 16-bit quantities int16/uint16 * 32-bit quantities int32/uint32 * 64-bit quantities int64/uint64 * strings unsigned char* */ typedef TIFF_INT8_T int8; typedef TIFF_UINT8_T uint8; typedef TIFF_INT16_T int16; typedef TIFF_UINT16_T uint16; typedef TIFF_INT32_T int32; typedef TIFF_UINT32_T uint32; typedef TIFF_INT64_T int64; typedef TIFF_UINT64_T uint64; /* * Some types as promoted in a variable argument list * We use uint16_vap rather then directly using int, because this way * we document the type we actually want to pass through, conceptually, * rather then confusing the issue by merely stating the type it gets * promoted to */ typedef int uint16_vap; /* * TIFF header. */ typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ } TIFFHeaderCommon; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint32 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint16 tiff_offsetsize; /* size of offsets, should be 8 */ uint16 tiff_unused; /* unused word, should be 0 */ uint64 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderBig; /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, * - items marked with a ! are introduced in revision 6.0. * - items marked with a % are introduced post revision 6.0. * - items marked with a $ are obsoleted by revision 6.0. * - items marked with a & are introduced by Adobe DNG specification. */ /* * Tag data type information. * * Note: RATIONALs are the ratio of two 32-bit integer values. */ typedef enum { TIFF_NOTYPE = 0, /* placeholder */ TIFF_BYTE = 1, /* 8-bit unsigned integer */ TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ TIFF_SHORT = 3, /* 16-bit unsigned integer */ TIFF_LONG = 4, /* 32-bit unsigned integer */ TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ TIFF_SBYTE = 6, /* !8-bit signed integer */ TIFF_UNDEFINED = 7, /* !8-bit untyped data */ TIFF_SSHORT = 8, /* !16-bit signed integer */ TIFF_SLONG = 9, /* !32-bit signed integer */ TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* * TIFF Tag Definitions. */ #define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ #define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ #define FILETYPE_PAGE 0x2 /* one page of many */ #define FILETYPE_MASK 0x4 /* transparency mask */ #define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ #define OFILETYPE_IMAGE 1 /* full resolution image data */ #define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ #define OFILETYPE_PAGE 3 /* one page of many */ #define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ #define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ #define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ #define TIFFTAG_COMPRESSION 259 /* data compression technique */ #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ #define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ #define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ #define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ #define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ #define COMPRESSION_JBIG 34661 /* ISO JBIG */ #define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ #define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ #define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ #define COMPRESSION_LZMA 34925 /* LZMA2 */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ #define PHOTOMETRIC_RGB 2 /* RGB color model */ #define PHOTOMETRIC_PALETTE 3 /* color map indexed */ #define PHOTOMETRIC_MASK 4 /* $holdout mask */ #define PHOTOMETRIC_SEPARATED 5 /* !color separations */ #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ #define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ #define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ #define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ #define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ #define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ #define THRESHHOLD_BILEVEL 1 /* b&w art scan */ #define THRESHHOLD_HALFTONE 2 /* or dithered scan */ #define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ #define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ #define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ #define TIFFTAG_FILLORDER 266 /* data order within a byte */ #define FILLORDER_MSB2LSB 1 /* most significant -> least */ #define FILLORDER_LSB2MSB 2 /* least significant -> most */ #define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ #define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ #define TIFFTAG_MAKE 271 /* scanner manufacturer name */ #define TIFFTAG_MODEL 272 /* scanner model name/number */ #define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ #define TIFFTAG_ORIENTATION 274 /* +image orientation */ #define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ #define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ #define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ #define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ #define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ #define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ #define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ #define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ #define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ #define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ #define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ #define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ #define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ #define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ #define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ #define TIFFTAG_PLANARCONFIG 284 /* storage organization */ #define PLANARCONFIG_CONTIG 1 /* single image plane */ #define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ #define TIFFTAG_PAGENAME 285 /* page name image is from */ #define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ #define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ #define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ #define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ #define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ #define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ #define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ #define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ #define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ #define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ #define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ #define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ #define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ #define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ #define RESUNIT_NONE 1 /* no meaningful units */ #define RESUNIT_INCH 2 /* english */ #define RESUNIT_CENTIMETER 3 /* metric */ #define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ #define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ #define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ #define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ #define TIFFTAG_SOFTWARE 305 /* name & release */ #define TIFFTAG_DATETIME 306 /* creation date and time */ #define TIFFTAG_ARTIST 315 /* creator of image */ #define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ #define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ #define PREDICTOR_NONE 1 /* no prediction scheme used */ #define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ #define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ #define TIFFTAG_WHITEPOINT 318 /* image white point */ #define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ #define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ #define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ #define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ #define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ #define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ #define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ #define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ #define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ #define CLEANFAXDATA_CLEAN 0 /* no errors detected */ #define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ #define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ #define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ #define TIFFTAG_SUBIFD 330 /* subimage descriptors */ #define TIFFTAG_INKSET 332 /* !inks in separated image */ #define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ #define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ #define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ #define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ #define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ #define TIFFTAG_TARGETPRINTER 337 /* !separation target */ #define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ #define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ #define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ #define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ #define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ #define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ #define SAMPLEFORMAT_INT 2 /* !signed integer data */ #define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ #define SAMPLEFORMAT_VOID 4 /* !untyped data */ #define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ #define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ #define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ #define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ #define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */ #define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ /* Tags 400-435 are from the TIFF/FX spec */ #define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ #define TIFFTAG_PROFILETYPE 401 /* ! */ #define PROFILETYPE_UNSPECIFIED 0 /* ! */ #define PROFILETYPE_G3_FAX 1 /* ! */ #define TIFFTAG_FAXPROFILE 402 /* ! */ #define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ #define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ #define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ #define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ #define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ #define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ #define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ #define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ #define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ #define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ #define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ #define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ #define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ #define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ #define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ #define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ #define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ #define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. */ #define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ #define JPEGPROC_BASELINE 1 /* !baseline sequential */ #define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ #define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ #define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ #define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ #define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ #define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ #define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ #define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ #define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ #define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ #define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ #define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ #define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ #define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */ /* tags 32952-32956 are private tags registered to Island Graphics */ #define TIFFTAG_REFPTS 32953 /* image reference points */ #define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ #define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ #define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ #define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ #define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ #define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ #define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ #define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ #define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ /* Tags 33302-33306 are used to identify special image modes and data * used by Pixar's texture formats. */ #define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ #define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ #define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ #define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 /* tag 33405 is a private tag registered to Eastman Kodak */ #define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ #define TIFFTAG_COPYRIGHT 33432 /* copyright string */ /* IPTC TAG from RichTIFF specifications */ #define TIFFTAG_RICHTIFFIPTC 33723 /* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ #define TIFFTAG_STONITS 37439 /* Sample value to Nits */ /* tag 34929 is a private tag registered to FedEx */ #define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ #define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ /* Adobe Digital Negative (DNG) format tags */ #define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ #define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ #define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ #define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name */ #define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */ #define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ #define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ #define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */ #define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ #define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */ #define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */ #define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */ #define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ #define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */ #define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */ #define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */ #define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */ #define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ #define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ #define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */ #define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */ #define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/ #define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */ #define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */ #define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */ #define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ #define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */ #define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of the green pixels in the blue/green rows track the values of the green pixels in the red/green rows */ #define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ #define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ #define TIFFTAG_LENSINFO 50736 /* info about the lens */ #define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ #define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */ #define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ #define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ #define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */ #define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ #define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ #define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ #define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */ #define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file */ #define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */ #define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */ #define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */ #define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ #define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */ #define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ #define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ /* tag 65535 is an undefined tag used by Eastman Kodak */ #define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ /* * The following are ``pseudo tags'' that can be used to control * codec-specific functionality. These tags are not written to file. * Note that these values start at 0xffff+1 so that they'll never * collide with Aldus-assigned tags. * * If you want your private pseudo tags ``registered'' (i.e. added to * this file), please post a bug report via the tracking system at * http://www.remotesensing.org/libtiff/bugs.html with the appropriate * C definitions to add. */ #define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ #define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ #define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ #define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ #define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ #define FAXMODE_WORDALIGN 0x0008 /* word align row */ #define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ #define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ #define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ #define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ #define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ #define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ #define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ #define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ #define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ #define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ #define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ #define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ #define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ #define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ #define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ #define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ /* 65550-65556 are allocated to Oceana Matrix */ #define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ #define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ #define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ #define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ #define DCSIMAGERFILTER_IR 0 /* infrared filter */ #define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ #define DCSIMAGERFILTER_CFA 2 /* color filter array */ #define DCSIMAGERFILTER_OTHER 3 /* other filter */ #define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ #define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ #define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ #define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ #define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ #define TIFFTAG_DCSGAMMA 65554 /* gamma value */ #define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ #define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ /* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ #define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ #define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ /* 65559 is allocated to Oceana Matrix */ #define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ #define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ #define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ #define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ #define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ #define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ #define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ #define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ #define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ #define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ #define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ #define PERSAMPLE_MERGED 0 /* present as a single value */ #define PERSAMPLE_MULTI 1 /* present as multiple values */ /* * EXIF tags */ #define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ #define EXIFTAG_FNUMBER 33437 /* F number */ #define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ #define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ #define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ #define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ #define EXIFTAG_EXIFVERSION 36864 /* Exif version */ #define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ #define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */ #define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ #define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ #define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ #define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ #define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ #define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ #define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ #define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ #define EXIFTAG_METERINGMODE 37383 /* Metering mode */ #define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ #define EXIFTAG_FLASH 37385 /* Flash */ #define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ #define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ #define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ #define EXIFTAG_USERCOMMENT 37510 /* User comments */ #define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ #define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ #define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ #define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ #define EXIFTAG_COLORSPACE 40961 /* Color space information */ #define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ #define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ #define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ #define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ #define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ #define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ #define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ #define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ #define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ #define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ #define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ #define EXIFTAG_FILESOURCE 41728 /* File source */ #define EXIFTAG_SCENETYPE 41729 /* Scene type */ #define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ #define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ #define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ #define EXIFTAG_WHITEBALANCE 41987 /* White balance */ #define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ #define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ #define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_CONTRAST 41992 /* Contrast */ #define EXIFTAG_SATURATION 41993 /* Saturation */ #define EXIFTAG_SHARPNESS 41994 /* Sharpness */ #define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ #define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/android/tiffconf.h ================================================ /* libtiff/tiffconf.h. Generated from tiffconf.h.in by configure. */ /* Configuration defines for installed libtiff. This file maintained for backward compatibility. Do not use definitions from this file in your programs. */ #ifndef _TIFFCONF_ #define _TIFFCONF_ /* Signed 16-bit type */ #define TIFF_INT16_T signed short /* Signed 32-bit type */ #define TIFF_INT32_T signed int /* Signed 64-bit type */ #define TIFF_INT64_T signed long long /* Signed 8-bit type */ #define TIFF_INT8_T signed char /* Unsigned 16-bit type */ #define TIFF_UINT16_T unsigned short /* Unsigned 32-bit type */ #define TIFF_UINT32_T unsigned int /* Unsigned 64-bit type */ #define TIFF_UINT64_T unsigned long long /* Unsigned 8-bit type */ #define TIFF_UINT8_T unsigned char /* Signed size type */ #define TIFF_SSIZE_T signed long /* Pointer difference type */ #define TIFF_PTRDIFF_T ptrdiff_t /* Define to 1 if the system has the type `int16'. */ /* #undef HAVE_INT16 */ /* Define to 1 if the system has the type `int32'. */ /* #undef HAVE_INT32 */ /* Define to 1 if the system has the type `int8'. */ /* #undef HAVE_INT8 */ /* Compatibility stuff. */ /* Define as 0 or 1 according to the floating point format suported by the machine */ #define HAVE_IEEEFP 1 /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ #define HOST_FILLORDER FILLORDER_MSB2LSB /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ #define HOST_BIGENDIAN 0 /* Support CCITT Group 3 & 4 algorithms */ #define CCITT_SUPPORT 1 /* Support JPEG compression (requires IJG JPEG library) */ /* #undef JPEG_SUPPORT */ /* Support JBIG compression (requires JBIG-KIT library) */ /* #undef JBIG_SUPPORT */ /* Support LogLuv high dynamic range encoding */ #define LOGLUV_SUPPORT 1 /* Support LZW algorithm */ #define LZW_SUPPORT 1 /* Support NeXT 2-bit RLE algorithm */ #define NEXT_SUPPORT 1 /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation fails with unpatched IJG JPEG library) */ /* #undef OJPEG_SUPPORT */ /* Support Macintosh PackBits algorithm */ #define PACKBITS_SUPPORT 1 /* Support Pixar log-format algorithm (requires Zlib) */ #define PIXARLOG_SUPPORT 1 /* Support ThunderScan 4-bit RLE algorithm */ #define THUNDER_SUPPORT 1 /* Support Deflate compression */ #define ZIP_SUPPORT 1 /* Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage) */ #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* Enable SubIFD tag (330) support */ #define SUBIFD_SUPPORT 1 /* Treat extra sample as alpha (default enabled). The RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly. */ #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 /* Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled). */ #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 /* Support MS MDI magic number files as TIFF */ #define MDI_SUPPORT 1 /* * Feature support definitions. * XXX: These macros are obsoleted. Don't use them in your apps! * Macros stays here for backward compatibility and should be always defined. */ #define COLORIMETRY_SUPPORT #define YCBCR_SUPPORT #define CMYK_SUPPORT #define ICC_SUPPORT #define PHOTOSHOP_SUPPORT #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ ================================================ FILE: cocos2d/external/tiff/include/android/tiffio.h ================================================ /* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIO_ #define _TIFFIO_ /* * TIFF I/O Library Definitions. */ #include "tiff.h" #include "tiffvers.h" /* * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ typedef struct tiff TIFF; /* * The following typedefs define the intrinsic size of * data types used in the *exported* interfaces. These * definitions depend on the proper definition of types * in tiff.h. Note also that the varargs interface used * to pass tag types and values uses the types defined in * tiff.h directly. * * NB: ttag_t is unsigned int and not unsigned short because * ANSI C requires that the type before the ellipsis be a * promoted type (i.e. one of int, unsigned int, pointer, * or double) and because we defined pseudo-tags that are * outside the range of legal Aldus-assigned tags. * NB: tsize_t is int32 and not uint32 because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at * 32-bit file offsets, and BigTIFF maxes out at 64-bit * offsets being the most important, and to ensure use of * a consistently unsigned type across architectures. * Prior to libtiff 4.0, this was an unsigned 32 bit type. */ /* * this is the machine addressing size type, only it's signed, so make it * int32 on 32bit machines, int64 on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; typedef uint64 toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ typedef uint32 ttag_t; /* directory tag */ typedef uint16 tdir_t; /* directory index */ typedef uint16 tsample_t; /* sample number */ typedef uint32 tstrile_t; /* strip or tile number */ typedef tstrile_t tstrip_t; /* strip number */ typedef tstrile_t ttile_t; /* tile number */ typedef tmsize_t tsize_t; /* i/o size in bytes */ typedef void* tdata_t; /* image data ref */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ #endif /* * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). * * By default tif_unix.c is assumed. */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) # define AVOID_WIN32_FILEIO # endif #endif #if defined(USE_WIN32_FILEIO) # define VC_EXTRALEAN # include # ifdef __WIN32__ DECLARE_HANDLE(thandle_t); /* Win32 file handle */ # else typedef HFILE thandle_t; /* client data handle */ # endif /* __WIN32__ */ #else typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ /* * Colour conversion stuff */ /* reference white */ #define D65_X0 (95.0470F) #define D65_Y0 (100.0F) #define D65_Z0 (108.8827F) #define D50_X0 (96.4250F) #define D50_Y0 (100.0F) #define D50_Z0 (82.4680F) /* Structure for holding information about a display device. */ typedef unsigned char TIFFRGBValue; /* 8-bit samples */ typedef struct { float d_mat[3][3]; /* XYZ -> luminance matrix */ float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; uint32 d_Vrwr; /* Pixel values for ref. white */ uint32 d_Vrwg; uint32 d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; float d_gammaR; /* Gamma values for the three guns */ float d_gammaG; float d_gammaB; } TIFFDisplay; typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; int32* Cr_g_tab; int32* Cb_g_tab; int32* Y_tab; } TIFFYCbCrToRGB; typedef struct { /* CIE Lab 1976->RGB support */ int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 float rstep, gstep, bstep; float X0, Y0, Z0; /* Reference white point */ TIFFDisplay display; float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* * RGBA-style image support. */ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*); typedef void (*tileSeparateRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ struct _TIFFRGBAImage { TIFF* tif; /* image handle */ int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ uint32 width; /* image width */ uint32 height; /* image height */ uint16 bitspersample; /* image bits/sample */ uint16 samplesperpixel; /* image samples/pixel */ uint16 orientation; /* image orientation */ uint16 req_orientation; /* requested orientation */ uint16 photometric; /* image photometric interp */ uint16* redcmap; /* colormap pallete */ uint16* greencmap; uint16* bluecmap; /* get image data routine */ int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); /* put decoded strip/tile */ union { void (*any)(TIFFRGBAImage*); tileContigRoutine contig; tileSeparateRoutine separate; } put; TIFFRGBValue* Map; /* sample mapping array */ uint32** BWmap; /* black&white map */ uint32** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */ uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ int row_offset; int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ #define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) /* * A CODEC is a software package that implements decoding, * encoding, or decoding+encoding of a compression algorithm. * The library provides a collection of builtin codecs. * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; uint16 scheme; TIFFInitMethod init; } TIFFCodec; #include #include /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC #define LOGLUV_PUBLIC 1 #endif #if !defined(__GNUC__) && !defined(__attribute__) # define __attribute__(x) /*nothing*/ #endif #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); extern const TIFFCodec* TIFFFindCODEC(uint16); extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); extern int TIFFIsCODECConfigured(uint16); extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* * Auxiliary functions. */ extern void* _TIFFmalloc(tmsize_t s); extern void* _TIFFrealloc(void* p, tmsize_t s); extern void _TIFFmemset(void* p, int v, tmsize_t c); extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); extern void _TIFFfree(void* p); /* ** Stuff, related to tag handling and creating custom tags. */ extern int TIFFGetTagListCount( TIFF * ); extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ #define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ #define FIELD_CUSTOM 65 typedef struct _TIFFField TIFFField; typedef struct _TIFFFieldArray TIFFFieldArray; extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); extern uint32 TIFFFieldTag(const TIFFField*); extern const char* TIFFFieldName(const TIFFField*); extern TIFFDataType TIFFFieldDataType(const TIFFField*); extern int TIFFFieldPassCount(const TIFFField*); extern int TIFFFieldReadCount(const TIFFField*); extern int TIFFFieldWriteCount(const TIFFField*); typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef struct { TIFFVSetMethod vsetfield; /* tag set routine */ TIFFVGetMethod vgetfield; /* tag get routine */ TIFFPrintMethod printdir; /* directory print routine */ } TIFFTagMethods; extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); extern void *TIFFGetClientInfo(TIFF *, const char *); extern void TIFFSetClientInfo(TIFF *, void *, const char *); extern void TIFFCleanup(TIFF* tif); extern void TIFFClose(TIFF* tif); extern int TIFFFlush(TIFF* tif); extern int TIFFFlushData(TIFF* tif); extern int TIFFGetField(TIFF* tif, uint32 tag, ...); extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); extern int TIFFReadDirectory(TIFF* tif); extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); extern uint64 TIFFScanlineSize64(TIFF* tif); extern tmsize_t TIFFScanlineSize(TIFF* tif); extern uint64 TIFFRasterScanlineSize64(TIFF* tif); extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); extern uint64 TIFFStripSize64(TIFF* tif); extern tmsize_t TIFFStripSize(TIFF* tif); extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); extern uint64 TIFFTileRowSize64(TIFF* tif); extern tmsize_t TIFFTileRowSize(TIFF* tif); extern uint64 TIFFTileSize64(TIFF* tif); extern tmsize_t TIFFTileSize(TIFF* tif); extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); extern int TIFFFileno(TIFF*); extern int TIFFSetFileno(TIFF*, int); extern thandle_t TIFFClientdata(TIFF*); extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); extern int TIFFGetMode(TIFF*); extern int TIFFSetMode(TIFF*, int); extern int TIFFIsTiled(TIFF*); extern int TIFFIsByteSwapped(TIFF*); extern int TIFFIsUpSampled(TIFF*); extern int TIFFIsMSB2LSB(TIFF*); extern int TIFFIsBigEndian(TIFF*); extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); extern TIFFSeekProc TIFFGetSeekProc(TIFF*); extern TIFFCloseProc TIFFGetCloseProc(TIFF*); extern TIFFSizeProc TIFFGetSizeProc(TIFF*); extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); extern uint32 TIFFCurrentRow(TIFF*); extern uint16 TIFFCurrentDirectory(TIFF*); extern uint16 TIFFNumberOfDirectories(TIFF*); extern uint64 TIFFCurrentDirOffset(TIFF*); extern uint32 TIFFCurrentStrip(TIFF*); extern uint32 TIFFCurrentTile(TIFF* tif); extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFSetupStrips(TIFF *); extern int TIFFWriteCheck(TIFF*, int, const char *); extern void TIFFFreeDirectory(TIFF*); extern int TIFFCreateDirectory(TIFF*); extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); extern int TIFFSetDirectory(TIFF*, uint16); extern int TIFFSetSubDirectory(TIFF*, uint64); extern int TIFFUnlinkDirectory(TIFF*, uint16); extern int TIFFSetField(TIFF*, uint32, ...); extern int TIFFVSetField(TIFF*, uint32, va_list); extern int TIFFUnsetField(TIFF*, uint32); extern int TIFFWriteDirectory(TIFF *); extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int = ORIENTATION_BOTLEFT, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); #endif extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); # ifdef __WIN32__ extern TIFF* TIFFOpenW(const wchar_t*, const char*); # endif /* __WIN32__ */ extern TIFF* TIFFFdOpen(int, const char*, const char*); extern TIFF* TIFFClientOpen(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); extern const char* TIFFFileName(TIFF*); extern const char* TIFFSetFileName(TIFF*, const char *); extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFNumberOfTiles(TIFF*); extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); extern uint32 TIFFNumberOfStrips(TIFF*); extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); extern void TIFFSwabShort(uint16*); extern void TIFFSwabLong(uint32*); extern void TIFFSwabLong8(uint64*); extern void TIFFSwabFloat(float*); extern void TIFFSwabDouble(double*); extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); extern void TIFFReverseBits(uint8* cp, tmsize_t n); extern const unsigned char* TIFFGetBitRevTable(int); #ifdef LOGLUV_PUBLIC #define U_NEU 0.210526316 #define V_NEU 0.473684211 #define UVSCALE 410. extern double LogL16toY(int); extern double LogL10toY(int); extern void XYZtoRGB24(float*, uint8*); extern int uv_decode(double*, double*, int); extern void LogLuv24toXYZ(uint32, float*); extern void LogLuv32toXYZ(uint32, float*); #if defined(c_plusplus) || defined(__cplusplus) extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); #else extern int LogL16fromY(double, int); extern int LogL10fromY(double, int); extern int uv_encode(double, double, int); extern uint32 LogLuv24fromXYZ(float*, int); extern uint32 LogLuv32fromXYZ(float*, int); #endif #endif /* LOGLUV_PUBLIC */ extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, float *, float *, float *); extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32 *, uint32 *, uint32 *); extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, uint32 *, uint32 *, uint32 *); /**************************************************************************** * O B S O L E T E D I N T E R F A C E S * * Don't use this stuff in your applications, it may be removed in the future * libtiff versions. ****************************************************************************/ typedef struct { ttag_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ short field_writecount; /* write count/TIFF_VARIABLE */ TIFFDataType field_type; /* type of associated data */ unsigned short field_bit; /* bit in fieldsset bit vector */ unsigned char field_oktochange; /* if true, can change while writing */ unsigned char field_passcount; /* if true, pass dir count on set */ char *field_name; /* ASCII name */ } TIFFFieldInfo; extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); #if defined(c_plusplus) || defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/android/tiffvers.h ================================================ #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a * version or versions of the library. Runtime * version checking should be done based on the * string returned by TIFFGetVersion. */ #define TIFFLIB_VERSION 20120922 ================================================ FILE: cocos2d/external/tiff/include/ios/tiff.h ================================================ /* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ #define _TIFF_ #include "tiffconf.h" /* * Tag Image File Format (TIFF) * * Based on Rev 6.0 from: * Developer's Desk * Aldus Corporation * 411 First Ave. South * Suite 200 * Seattle, WA 98104 * 206-622-5500 * * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) * * For BigTIFF design notes see the following links * http://www.remotesensing.org/libtiff/bigtiffdesign.html * http://www.awaresystems.be/imaging/tiff/bigtiff.html */ #define TIFF_VERSION_CLASSIC 42 #define TIFF_VERSION_BIG 43 #define TIFF_BIGENDIAN 0x4d4d #define TIFF_LITTLEENDIAN 0x4949 #define MDI_LITTLEENDIAN 0x5045 #define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * * 8-bit quantities int8/uint8 * 16-bit quantities int16/uint16 * 32-bit quantities int32/uint32 * 64-bit quantities int64/uint64 * strings unsigned char* */ typedef TIFF_INT8_T int8; typedef TIFF_UINT8_T uint8; typedef TIFF_INT16_T int16; typedef TIFF_UINT16_T uint16; typedef TIFF_INT32_T int32; typedef TIFF_UINT32_T uint32; typedef TIFF_INT64_T int64; typedef TIFF_UINT64_T uint64; /* * Some types as promoted in a variable argument list * We use uint16_vap rather then directly using int, because this way * we document the type we actually want to pass through, conceptually, * rather then confusing the issue by merely stating the type it gets * promoted to */ typedef int uint16_vap; /* * TIFF header. */ typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ } TIFFHeaderCommon; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint32 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint16 tiff_offsetsize; /* size of offsets, should be 8 */ uint16 tiff_unused; /* unused word, should be 0 */ uint64 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderBig; /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, * - items marked with a ! are introduced in revision 6.0. * - items marked with a % are introduced post revision 6.0. * - items marked with a $ are obsoleted by revision 6.0. * - items marked with a & are introduced by Adobe DNG specification. */ /* * Tag data type information. * * Note: RATIONALs are the ratio of two 32-bit integer values. */ typedef enum { TIFF_NOTYPE = 0, /* placeholder */ TIFF_BYTE = 1, /* 8-bit unsigned integer */ TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ TIFF_SHORT = 3, /* 16-bit unsigned integer */ TIFF_LONG = 4, /* 32-bit unsigned integer */ TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ TIFF_SBYTE = 6, /* !8-bit signed integer */ TIFF_UNDEFINED = 7, /* !8-bit untyped data */ TIFF_SSHORT = 8, /* !16-bit signed integer */ TIFF_SLONG = 9, /* !32-bit signed integer */ TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* * TIFF Tag Definitions. */ #define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ #define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ #define FILETYPE_PAGE 0x2 /* one page of many */ #define FILETYPE_MASK 0x4 /* transparency mask */ #define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ #define OFILETYPE_IMAGE 1 /* full resolution image data */ #define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ #define OFILETYPE_PAGE 3 /* one page of many */ #define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ #define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ #define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ #define TIFFTAG_COMPRESSION 259 /* data compression technique */ #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ #define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ #define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ #define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ #define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ #define COMPRESSION_JBIG 34661 /* ISO JBIG */ #define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ #define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ #define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ #define COMPRESSION_LZMA 34925 /* LZMA2 */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ #define PHOTOMETRIC_RGB 2 /* RGB color model */ #define PHOTOMETRIC_PALETTE 3 /* color map indexed */ #define PHOTOMETRIC_MASK 4 /* $holdout mask */ #define PHOTOMETRIC_SEPARATED 5 /* !color separations */ #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ #define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ #define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ #define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ #define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ #define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ #define THRESHHOLD_BILEVEL 1 /* b&w art scan */ #define THRESHHOLD_HALFTONE 2 /* or dithered scan */ #define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ #define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ #define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ #define TIFFTAG_FILLORDER 266 /* data order within a byte */ #define FILLORDER_MSB2LSB 1 /* most significant -> least */ #define FILLORDER_LSB2MSB 2 /* least significant -> most */ #define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ #define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ #define TIFFTAG_MAKE 271 /* scanner manufacturer name */ #define TIFFTAG_MODEL 272 /* scanner model name/number */ #define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ #define TIFFTAG_ORIENTATION 274 /* +image orientation */ #define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ #define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ #define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ #define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ #define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ #define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ #define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ #define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ #define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ #define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ #define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ #define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ #define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ #define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ #define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ #define TIFFTAG_PLANARCONFIG 284 /* storage organization */ #define PLANARCONFIG_CONTIG 1 /* single image plane */ #define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ #define TIFFTAG_PAGENAME 285 /* page name image is from */ #define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ #define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ #define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ #define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ #define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ #define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ #define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ #define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ #define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ #define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ #define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ #define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ #define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ #define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ #define RESUNIT_NONE 1 /* no meaningful units */ #define RESUNIT_INCH 2 /* english */ #define RESUNIT_CENTIMETER 3 /* metric */ #define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ #define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ #define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ #define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ #define TIFFTAG_SOFTWARE 305 /* name & release */ #define TIFFTAG_DATETIME 306 /* creation date and time */ #define TIFFTAG_ARTIST 315 /* creator of image */ #define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ #define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ #define PREDICTOR_NONE 1 /* no prediction scheme used */ #define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ #define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ #define TIFFTAG_WHITEPOINT 318 /* image white point */ #define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ #define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ #define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ #define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ #define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ #define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ #define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ #define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ #define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ #define CLEANFAXDATA_CLEAN 0 /* no errors detected */ #define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ #define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ #define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ #define TIFFTAG_SUBIFD 330 /* subimage descriptors */ #define TIFFTAG_INKSET 332 /* !inks in separated image */ #define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ #define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ #define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ #define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ #define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ #define TIFFTAG_TARGETPRINTER 337 /* !separation target */ #define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ #define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ #define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ #define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ #define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ #define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ #define SAMPLEFORMAT_INT 2 /* !signed integer data */ #define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ #define SAMPLEFORMAT_VOID 4 /* !untyped data */ #define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ #define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ #define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ #define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ #define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */ #define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ /* Tags 400-435 are from the TIFF/FX spec */ #define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ #define TIFFTAG_PROFILETYPE 401 /* ! */ #define PROFILETYPE_UNSPECIFIED 0 /* ! */ #define PROFILETYPE_G3_FAX 1 /* ! */ #define TIFFTAG_FAXPROFILE 402 /* ! */ #define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ #define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ #define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ #define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ #define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ #define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ #define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ #define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ #define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ #define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ #define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ #define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ #define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ #define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ #define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ #define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ #define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ #define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. */ #define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ #define JPEGPROC_BASELINE 1 /* !baseline sequential */ #define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ #define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ #define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ #define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ #define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ #define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ #define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ #define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ #define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ #define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ #define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ #define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ #define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ #define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */ /* tags 32952-32956 are private tags registered to Island Graphics */ #define TIFFTAG_REFPTS 32953 /* image reference points */ #define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ #define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ #define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ #define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ #define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ #define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ #define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ #define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ #define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ /* Tags 33302-33306 are used to identify special image modes and data * used by Pixar's texture formats. */ #define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ #define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ #define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ #define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 /* tag 33405 is a private tag registered to Eastman Kodak */ #define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ #define TIFFTAG_COPYRIGHT 33432 /* copyright string */ /* IPTC TAG from RichTIFF specifications */ #define TIFFTAG_RICHTIFFIPTC 33723 /* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ #define TIFFTAG_STONITS 37439 /* Sample value to Nits */ /* tag 34929 is a private tag registered to FedEx */ #define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ #define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ /* Adobe Digital Negative (DNG) format tags */ #define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ #define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ #define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ #define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name */ #define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */ #define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ #define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ #define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */ #define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ #define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */ #define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */ #define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */ #define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ #define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */ #define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */ #define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */ #define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */ #define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ #define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ #define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */ #define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */ #define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/ #define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */ #define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */ #define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */ #define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ #define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */ #define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of the green pixels in the blue/green rows track the values of the green pixels in the red/green rows */ #define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ #define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ #define TIFFTAG_LENSINFO 50736 /* info about the lens */ #define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ #define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */ #define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ #define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ #define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */ #define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ #define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ #define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ #define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */ #define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file */ #define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */ #define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */ #define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */ #define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ #define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */ #define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ #define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ /* tag 65535 is an undefined tag used by Eastman Kodak */ #define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ /* * The following are ``pseudo tags'' that can be used to control * codec-specific functionality. These tags are not written to file. * Note that these values start at 0xffff+1 so that they'll never * collide with Aldus-assigned tags. * * If you want your private pseudo tags ``registered'' (i.e. added to * this file), please post a bug report via the tracking system at * http://www.remotesensing.org/libtiff/bugs.html with the appropriate * C definitions to add. */ #define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ #define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ #define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ #define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ #define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ #define FAXMODE_WORDALIGN 0x0008 /* word align row */ #define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ #define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ #define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ #define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ #define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ #define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ #define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ #define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ #define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ #define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ #define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ #define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ #define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ #define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ #define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ #define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ /* 65550-65556 are allocated to Oceana Matrix */ #define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ #define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ #define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ #define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ #define DCSIMAGERFILTER_IR 0 /* infrared filter */ #define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ #define DCSIMAGERFILTER_CFA 2 /* color filter array */ #define DCSIMAGERFILTER_OTHER 3 /* other filter */ #define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ #define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ #define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ #define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ #define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ #define TIFFTAG_DCSGAMMA 65554 /* gamma value */ #define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ #define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ /* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ #define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ #define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ /* 65559 is allocated to Oceana Matrix */ #define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ #define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ #define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ #define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ #define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ #define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ #define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ #define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ #define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ #define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ #define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ #define PERSAMPLE_MERGED 0 /* present as a single value */ #define PERSAMPLE_MULTI 1 /* present as multiple values */ /* * EXIF tags */ #define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ #define EXIFTAG_FNUMBER 33437 /* F number */ #define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ #define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ #define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ #define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ #define EXIFTAG_EXIFVERSION 36864 /* Exif version */ #define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ #define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */ #define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ #define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ #define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ #define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ #define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ #define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ #define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ #define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ #define EXIFTAG_METERINGMODE 37383 /* Metering mode */ #define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ #define EXIFTAG_FLASH 37385 /* Flash */ #define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ #define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ #define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ #define EXIFTAG_USERCOMMENT 37510 /* User comments */ #define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ #define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ #define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ #define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ #define EXIFTAG_COLORSPACE 40961 /* Color space information */ #define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ #define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ #define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ #define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ #define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ #define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ #define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ #define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ #define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ #define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ #define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ #define EXIFTAG_FILESOURCE 41728 /* File source */ #define EXIFTAG_SCENETYPE 41729 /* Scene type */ #define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ #define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ #define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ #define EXIFTAG_WHITEBALANCE 41987 /* White balance */ #define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ #define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ #define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_CONTRAST 41992 /* Contrast */ #define EXIFTAG_SATURATION 41993 /* Saturation */ #define EXIFTAG_SHARPNESS 41994 /* Sharpness */ #define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ #define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/ios/tiffconf.h ================================================ /* libtiff/tiffconf.h. Generated from tiffconf.h.in by configure. */ /* Configuration defines for installed libtiff. This file maintained for backward compatibility. Do not use definitions from this file in your programs. */ #ifndef _TIFFCONF_ #define _TIFFCONF_ /* Signed 16-bit type */ #define TIFF_INT16_T signed short /* Signed 32-bit type */ #define TIFF_INT32_T signed int /* Signed 64-bit type */ #define TIFF_INT64_T signed long long /* Signed 8-bit type */ #define TIFF_INT8_T signed char /* Unsigned 16-bit type */ #define TIFF_UINT16_T unsigned short /* Unsigned 32-bit type */ #define TIFF_UINT32_T unsigned int /* Unsigned 64-bit type */ #define TIFF_UINT64_T unsigned long long /* Unsigned 8-bit type */ #define TIFF_UINT8_T unsigned char /* Signed size type */ #define TIFF_SSIZE_T signed long /* Pointer difference type */ #define TIFF_PTRDIFF_T ptrdiff_t /* Define to 1 if the system has the type `int16'. */ /* #undef HAVE_INT16 */ /* Define to 1 if the system has the type `int32'. */ /* #undef HAVE_INT32 */ /* Define to 1 if the system has the type `int8'. */ /* #undef HAVE_INT8 */ /* Compatibility stuff. */ /* Define as 0 or 1 according to the floating point format suported by the machine */ #define HAVE_IEEEFP 1 /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ #define HOST_FILLORDER FILLORDER_MSB2LSB /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ #define HOST_BIGENDIAN 0 /* Support CCITT Group 3 & 4 algorithms */ #define CCITT_SUPPORT 1 /* Support JPEG compression (requires IJG JPEG library) */ /* #undef JPEG_SUPPORT */ /* Support JBIG compression (requires JBIG-KIT library) */ /* #undef JBIG_SUPPORT */ /* Support LogLuv high dynamic range encoding */ #define LOGLUV_SUPPORT 1 /* Support LZW algorithm */ #define LZW_SUPPORT 1 /* Support NeXT 2-bit RLE algorithm */ #define NEXT_SUPPORT 1 /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation fails with unpatched IJG JPEG library) */ /* #undef OJPEG_SUPPORT */ /* Support Macintosh PackBits algorithm */ #define PACKBITS_SUPPORT 1 /* Support Pixar log-format algorithm (requires Zlib) */ #define PIXARLOG_SUPPORT 1 /* Support ThunderScan 4-bit RLE algorithm */ #define THUNDER_SUPPORT 1 /* Support Deflate compression */ #define ZIP_SUPPORT 1 /* Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage) */ #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* Enable SubIFD tag (330) support */ #define SUBIFD_SUPPORT 1 /* Treat extra sample as alpha (default enabled). The RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly. */ #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 /* Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled). */ #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 /* Support MS MDI magic number files as TIFF */ #define MDI_SUPPORT 1 /* * Feature support definitions. * XXX: These macros are obsoleted. Don't use them in your apps! * Macros stays here for backward compatibility and should be always defined. */ #define COLORIMETRY_SUPPORT #define YCBCR_SUPPORT #define CMYK_SUPPORT #define ICC_SUPPORT #define PHOTOSHOP_SUPPORT #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ ================================================ FILE: cocos2d/external/tiff/include/ios/tiffio.h ================================================ /* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIO_ #define _TIFFIO_ /* * TIFF I/O Library Definitions. */ #include "tiff.h" #include "tiffvers.h" /* * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ typedef struct tiff TIFF; /* * The following typedefs define the intrinsic size of * data types used in the *exported* interfaces. These * definitions depend on the proper definition of types * in tiff.h. Note also that the varargs interface used * to pass tag types and values uses the types defined in * tiff.h directly. * * NB: ttag_t is unsigned int and not unsigned short because * ANSI C requires that the type before the ellipsis be a * promoted type (i.e. one of int, unsigned int, pointer, * or double) and because we defined pseudo-tags that are * outside the range of legal Aldus-assigned tags. * NB: tsize_t is int32 and not uint32 because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at * 32-bit file offsets, and BigTIFF maxes out at 64-bit * offsets being the most important, and to ensure use of * a consistently unsigned type across architectures. * Prior to libtiff 4.0, this was an unsigned 32 bit type. */ /* * this is the machine addressing size type, only it's signed, so make it * int32 on 32bit machines, int64 on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; typedef uint64 toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ typedef uint32 ttag_t; /* directory tag */ typedef uint16 tdir_t; /* directory index */ typedef uint16 tsample_t; /* sample number */ typedef uint32 tstrile_t; /* strip or tile number */ typedef tstrile_t tstrip_t; /* strip number */ typedef tstrile_t ttile_t; /* tile number */ typedef tmsize_t tsize_t; /* i/o size in bytes */ typedef void* tdata_t; /* image data ref */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ #endif /* * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). * * By default tif_unix.c is assumed. */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) # define AVOID_WIN32_FILEIO # endif #endif #if defined(USE_WIN32_FILEIO) # define VC_EXTRALEAN # include # ifdef __WIN32__ DECLARE_HANDLE(thandle_t); /* Win32 file handle */ # else typedef HFILE thandle_t; /* client data handle */ # endif /* __WIN32__ */ #else typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ /* * Colour conversion stuff */ /* reference white */ #define D65_X0 (95.0470F) #define D65_Y0 (100.0F) #define D65_Z0 (108.8827F) #define D50_X0 (96.4250F) #define D50_Y0 (100.0F) #define D50_Z0 (82.4680F) /* Structure for holding information about a display device. */ typedef unsigned char TIFFRGBValue; /* 8-bit samples */ typedef struct { float d_mat[3][3]; /* XYZ -> luminance matrix */ float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; uint32 d_Vrwr; /* Pixel values for ref. white */ uint32 d_Vrwg; uint32 d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; float d_gammaR; /* Gamma values for the three guns */ float d_gammaG; float d_gammaB; } TIFFDisplay; typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; int32* Cr_g_tab; int32* Cb_g_tab; int32* Y_tab; } TIFFYCbCrToRGB; typedef struct { /* CIE Lab 1976->RGB support */ int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 float rstep, gstep, bstep; float X0, Y0, Z0; /* Reference white point */ TIFFDisplay display; float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* * RGBA-style image support. */ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*); typedef void (*tileSeparateRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ struct _TIFFRGBAImage { TIFF* tif; /* image handle */ int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ uint32 width; /* image width */ uint32 height; /* image height */ uint16 bitspersample; /* image bits/sample */ uint16 samplesperpixel; /* image samples/pixel */ uint16 orientation; /* image orientation */ uint16 req_orientation; /* requested orientation */ uint16 photometric; /* image photometric interp */ uint16* redcmap; /* colormap pallete */ uint16* greencmap; uint16* bluecmap; /* get image data routine */ int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); /* put decoded strip/tile */ union { void (*any)(TIFFRGBAImage*); tileContigRoutine contig; tileSeparateRoutine separate; } put; TIFFRGBValue* Map; /* sample mapping array */ uint32** BWmap; /* black&white map */ uint32** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */ uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ int row_offset; int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ #define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) /* * A CODEC is a software package that implements decoding, * encoding, or decoding+encoding of a compression algorithm. * The library provides a collection of builtin codecs. * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; uint16 scheme; TIFFInitMethod init; } TIFFCodec; #include #include /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC #define LOGLUV_PUBLIC 1 #endif #if !defined(__GNUC__) && !defined(__attribute__) # define __attribute__(x) /*nothing*/ #endif #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); extern const TIFFCodec* TIFFFindCODEC(uint16); extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); extern int TIFFIsCODECConfigured(uint16); extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* * Auxiliary functions. */ extern void* _TIFFmalloc(tmsize_t s); extern void* _TIFFrealloc(void* p, tmsize_t s); extern void _TIFFmemset(void* p, int v, tmsize_t c); extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); extern void _TIFFfree(void* p); /* ** Stuff, related to tag handling and creating custom tags. */ extern int TIFFGetTagListCount( TIFF * ); extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ #define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ #define FIELD_CUSTOM 65 typedef struct _TIFFField TIFFField; typedef struct _TIFFFieldArray TIFFFieldArray; extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); extern uint32 TIFFFieldTag(const TIFFField*); extern const char* TIFFFieldName(const TIFFField*); extern TIFFDataType TIFFFieldDataType(const TIFFField*); extern int TIFFFieldPassCount(const TIFFField*); extern int TIFFFieldReadCount(const TIFFField*); extern int TIFFFieldWriteCount(const TIFFField*); typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef struct { TIFFVSetMethod vsetfield; /* tag set routine */ TIFFVGetMethod vgetfield; /* tag get routine */ TIFFPrintMethod printdir; /* directory print routine */ } TIFFTagMethods; extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); extern void *TIFFGetClientInfo(TIFF *, const char *); extern void TIFFSetClientInfo(TIFF *, void *, const char *); extern void TIFFCleanup(TIFF* tif); extern void TIFFClose(TIFF* tif); extern int TIFFFlush(TIFF* tif); extern int TIFFFlushData(TIFF* tif); extern int TIFFGetField(TIFF* tif, uint32 tag, ...); extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); extern int TIFFReadDirectory(TIFF* tif); extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); extern uint64 TIFFScanlineSize64(TIFF* tif); extern tmsize_t TIFFScanlineSize(TIFF* tif); extern uint64 TIFFRasterScanlineSize64(TIFF* tif); extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); extern uint64 TIFFStripSize64(TIFF* tif); extern tmsize_t TIFFStripSize(TIFF* tif); extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); extern uint64 TIFFTileRowSize64(TIFF* tif); extern tmsize_t TIFFTileRowSize(TIFF* tif); extern uint64 TIFFTileSize64(TIFF* tif); extern tmsize_t TIFFTileSize(TIFF* tif); extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); extern int TIFFFileno(TIFF*); extern int TIFFSetFileno(TIFF*, int); extern thandle_t TIFFClientdata(TIFF*); extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); extern int TIFFGetMode(TIFF*); extern int TIFFSetMode(TIFF*, int); extern int TIFFIsTiled(TIFF*); extern int TIFFIsByteSwapped(TIFF*); extern int TIFFIsUpSampled(TIFF*); extern int TIFFIsMSB2LSB(TIFF*); extern int TIFFIsBigEndian(TIFF*); extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); extern TIFFSeekProc TIFFGetSeekProc(TIFF*); extern TIFFCloseProc TIFFGetCloseProc(TIFF*); extern TIFFSizeProc TIFFGetSizeProc(TIFF*); extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); extern uint32 TIFFCurrentRow(TIFF*); extern uint16 TIFFCurrentDirectory(TIFF*); extern uint16 TIFFNumberOfDirectories(TIFF*); extern uint64 TIFFCurrentDirOffset(TIFF*); extern uint32 TIFFCurrentStrip(TIFF*); extern uint32 TIFFCurrentTile(TIFF* tif); extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFSetupStrips(TIFF *); extern int TIFFWriteCheck(TIFF*, int, const char *); extern void TIFFFreeDirectory(TIFF*); extern int TIFFCreateDirectory(TIFF*); extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); extern int TIFFSetDirectory(TIFF*, uint16); extern int TIFFSetSubDirectory(TIFF*, uint64); extern int TIFFUnlinkDirectory(TIFF*, uint16); extern int TIFFSetField(TIFF*, uint32, ...); extern int TIFFVSetField(TIFF*, uint32, va_list); extern int TIFFUnsetField(TIFF*, uint32); extern int TIFFWriteDirectory(TIFF *); extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int = ORIENTATION_BOTLEFT, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); #endif extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); # ifdef __WIN32__ extern TIFF* TIFFOpenW(const wchar_t*, const char*); # endif /* __WIN32__ */ extern TIFF* TIFFFdOpen(int, const char*, const char*); extern TIFF* TIFFClientOpen(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); extern const char* TIFFFileName(TIFF*); extern const char* TIFFSetFileName(TIFF*, const char *); extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFNumberOfTiles(TIFF*); extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); extern uint32 TIFFNumberOfStrips(TIFF*); extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); extern void TIFFSwabShort(uint16*); extern void TIFFSwabLong(uint32*); extern void TIFFSwabLong8(uint64*); extern void TIFFSwabFloat(float*); extern void TIFFSwabDouble(double*); extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); extern void TIFFReverseBits(uint8* cp, tmsize_t n); extern const unsigned char* TIFFGetBitRevTable(int); #ifdef LOGLUV_PUBLIC #define U_NEU 0.210526316 #define V_NEU 0.473684211 #define UVSCALE 410. extern double LogL16toY(int); extern double LogL10toY(int); extern void XYZtoRGB24(float*, uint8*); extern int uv_decode(double*, double*, int); extern void LogLuv24toXYZ(uint32, float*); extern void LogLuv32toXYZ(uint32, float*); #if defined(c_plusplus) || defined(__cplusplus) extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); #else extern int LogL16fromY(double, int); extern int LogL10fromY(double, int); extern int uv_encode(double, double, int); extern uint32 LogLuv24fromXYZ(float*, int); extern uint32 LogLuv32fromXYZ(float*, int); #endif #endif /* LOGLUV_PUBLIC */ extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, float *, float *, float *); extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32 *, uint32 *, uint32 *); extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, uint32 *, uint32 *, uint32 *); /**************************************************************************** * O B S O L E T E D I N T E R F A C E S * * Don't use this stuff in your applications, it may be removed in the future * libtiff versions. ****************************************************************************/ typedef struct { ttag_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ short field_writecount; /* write count/TIFF_VARIABLE */ TIFFDataType field_type; /* type of associated data */ unsigned short field_bit; /* bit in fieldsset bit vector */ unsigned char field_oktochange; /* if true, can change while writing */ unsigned char field_passcount; /* if true, pass dir count on set */ char *field_name; /* ASCII name */ } TIFFFieldInfo; extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); #if defined(c_plusplus) || defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/ios/tiffvers.h ================================================ #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a * version or versions of the library. Runtime * version checking should be done based on the * string returned by TIFFGetVersion. */ #define TIFFLIB_VERSION 20120922 ================================================ FILE: cocos2d/external/tiff/include/linux/tiff.h ================================================ /* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ #define _TIFF_ #include "tiffconf.h" /* * Tag Image File Format (TIFF) * * Based on Rev 6.0 from: * Developer's Desk * Aldus Corporation * 411 First Ave. South * Suite 200 * Seattle, WA 98104 * 206-622-5500 * * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) * * For BigTIFF design notes see the following links * http://www.remotesensing.org/libtiff/bigtiffdesign.html * http://www.awaresystems.be/imaging/tiff/bigtiff.html */ #define TIFF_VERSION_CLASSIC 42 #define TIFF_VERSION_BIG 43 #define TIFF_BIGENDIAN 0x4d4d #define TIFF_LITTLEENDIAN 0x4949 #define MDI_LITTLEENDIAN 0x5045 #define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * * 8-bit quantities int8/uint8 * 16-bit quantities int16/uint16 * 32-bit quantities int32/uint32 * 64-bit quantities int64/uint64 * strings unsigned char* */ typedef TIFF_INT8_T int8; typedef TIFF_UINT8_T uint8; typedef TIFF_INT16_T int16; typedef TIFF_UINT16_T uint16; typedef TIFF_INT32_T int32; typedef TIFF_UINT32_T uint32; typedef TIFF_INT64_T int64; typedef TIFF_UINT64_T uint64; /* * Some types as promoted in a variable argument list * We use uint16_vap rather then directly using int, because this way * we document the type we actually want to pass through, conceptually, * rather then confusing the issue by merely stating the type it gets * promoted to */ typedef int uint16_vap; /* * TIFF header. */ typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ } TIFFHeaderCommon; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint32 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint16 tiff_offsetsize; /* size of offsets, should be 8 */ uint16 tiff_unused; /* unused word, should be 0 */ uint64 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderBig; /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, * - items marked with a ! are introduced in revision 6.0. * - items marked with a % are introduced post revision 6.0. * - items marked with a $ are obsoleted by revision 6.0. * - items marked with a & are introduced by Adobe DNG specification. */ /* * Tag data type information. * * Note: RATIONALs are the ratio of two 32-bit integer values. */ typedef enum { TIFF_NOTYPE = 0, /* placeholder */ TIFF_BYTE = 1, /* 8-bit unsigned integer */ TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ TIFF_SHORT = 3, /* 16-bit unsigned integer */ TIFF_LONG = 4, /* 32-bit unsigned integer */ TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ TIFF_SBYTE = 6, /* !8-bit signed integer */ TIFF_UNDEFINED = 7, /* !8-bit untyped data */ TIFF_SSHORT = 8, /* !16-bit signed integer */ TIFF_SLONG = 9, /* !32-bit signed integer */ TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* * TIFF Tag Definitions. */ #define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ #define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ #define FILETYPE_PAGE 0x2 /* one page of many */ #define FILETYPE_MASK 0x4 /* transparency mask */ #define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ #define OFILETYPE_IMAGE 1 /* full resolution image data */ #define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ #define OFILETYPE_PAGE 3 /* one page of many */ #define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ #define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ #define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ #define TIFFTAG_COMPRESSION 259 /* data compression technique */ #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ #define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ #define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ #define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ #define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ #define COMPRESSION_JBIG 34661 /* ISO JBIG */ #define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ #define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ #define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ #define COMPRESSION_LZMA 34925 /* LZMA2 */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ #define PHOTOMETRIC_RGB 2 /* RGB color model */ #define PHOTOMETRIC_PALETTE 3 /* color map indexed */ #define PHOTOMETRIC_MASK 4 /* $holdout mask */ #define PHOTOMETRIC_SEPARATED 5 /* !color separations */ #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ #define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ #define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ #define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ #define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ #define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ #define THRESHHOLD_BILEVEL 1 /* b&w art scan */ #define THRESHHOLD_HALFTONE 2 /* or dithered scan */ #define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ #define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ #define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ #define TIFFTAG_FILLORDER 266 /* data order within a byte */ #define FILLORDER_MSB2LSB 1 /* most significant -> least */ #define FILLORDER_LSB2MSB 2 /* least significant -> most */ #define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ #define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ #define TIFFTAG_MAKE 271 /* scanner manufacturer name */ #define TIFFTAG_MODEL 272 /* scanner model name/number */ #define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ #define TIFFTAG_ORIENTATION 274 /* +image orientation */ #define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ #define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ #define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ #define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ #define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ #define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ #define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ #define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ #define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ #define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ #define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ #define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ #define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ #define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ #define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ #define TIFFTAG_PLANARCONFIG 284 /* storage organization */ #define PLANARCONFIG_CONTIG 1 /* single image plane */ #define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ #define TIFFTAG_PAGENAME 285 /* page name image is from */ #define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ #define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ #define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ #define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ #define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ #define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ #define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ #define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ #define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ #define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ #define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ #define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ #define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ #define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ #define RESUNIT_NONE 1 /* no meaningful units */ #define RESUNIT_INCH 2 /* english */ #define RESUNIT_CENTIMETER 3 /* metric */ #define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ #define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ #define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ #define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ #define TIFFTAG_SOFTWARE 305 /* name & release */ #define TIFFTAG_DATETIME 306 /* creation date and time */ #define TIFFTAG_ARTIST 315 /* creator of image */ #define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ #define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ #define PREDICTOR_NONE 1 /* no prediction scheme used */ #define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ #define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ #define TIFFTAG_WHITEPOINT 318 /* image white point */ #define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ #define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ #define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ #define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ #define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ #define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ #define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ #define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ #define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ #define CLEANFAXDATA_CLEAN 0 /* no errors detected */ #define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ #define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ #define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ #define TIFFTAG_SUBIFD 330 /* subimage descriptors */ #define TIFFTAG_INKSET 332 /* !inks in separated image */ #define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ #define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ #define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ #define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ #define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ #define TIFFTAG_TARGETPRINTER 337 /* !separation target */ #define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ #define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ #define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ #define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ #define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ #define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ #define SAMPLEFORMAT_INT 2 /* !signed integer data */ #define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ #define SAMPLEFORMAT_VOID 4 /* !untyped data */ #define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ #define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ #define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ #define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ #define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */ #define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ /* Tags 400-435 are from the TIFF/FX spec */ #define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ #define TIFFTAG_PROFILETYPE 401 /* ! */ #define PROFILETYPE_UNSPECIFIED 0 /* ! */ #define PROFILETYPE_G3_FAX 1 /* ! */ #define TIFFTAG_FAXPROFILE 402 /* ! */ #define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ #define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ #define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ #define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ #define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ #define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ #define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ #define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ #define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ #define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ #define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ #define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ #define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ #define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ #define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ #define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ #define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ #define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. */ #define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ #define JPEGPROC_BASELINE 1 /* !baseline sequential */ #define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ #define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ #define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ #define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ #define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ #define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ #define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ #define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ #define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ #define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ #define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ #define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ #define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ #define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */ /* tags 32952-32956 are private tags registered to Island Graphics */ #define TIFFTAG_REFPTS 32953 /* image reference points */ #define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ #define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ #define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ #define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ #define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ #define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ #define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ #define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ #define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ /* Tags 33302-33306 are used to identify special image modes and data * used by Pixar's texture formats. */ #define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ #define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ #define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ #define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 /* tag 33405 is a private tag registered to Eastman Kodak */ #define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ #define TIFFTAG_COPYRIGHT 33432 /* copyright string */ /* IPTC TAG from RichTIFF specifications */ #define TIFFTAG_RICHTIFFIPTC 33723 /* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ #define TIFFTAG_STONITS 37439 /* Sample value to Nits */ /* tag 34929 is a private tag registered to FedEx */ #define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ #define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ /* Adobe Digital Negative (DNG) format tags */ #define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ #define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ #define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ #define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name */ #define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */ #define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ #define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ #define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */ #define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ #define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */ #define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */ #define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */ #define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ #define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */ #define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */ #define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */ #define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */ #define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ #define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ #define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */ #define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */ #define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/ #define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */ #define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */ #define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */ #define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ #define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */ #define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of the green pixels in the blue/green rows track the values of the green pixels in the red/green rows */ #define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ #define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ #define TIFFTAG_LENSINFO 50736 /* info about the lens */ #define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ #define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */ #define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ #define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ #define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */ #define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ #define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ #define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ #define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */ #define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file */ #define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */ #define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */ #define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */ #define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ #define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */ #define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ #define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ /* tag 65535 is an undefined tag used by Eastman Kodak */ #define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ /* * The following are ``pseudo tags'' that can be used to control * codec-specific functionality. These tags are not written to file. * Note that these values start at 0xffff+1 so that they'll never * collide with Aldus-assigned tags. * * If you want your private pseudo tags ``registered'' (i.e. added to * this file), please post a bug report via the tracking system at * http://www.remotesensing.org/libtiff/bugs.html with the appropriate * C definitions to add. */ #define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ #define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ #define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ #define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ #define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ #define FAXMODE_WORDALIGN 0x0008 /* word align row */ #define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ #define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ #define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ #define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ #define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ #define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ #define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ #define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ #define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ #define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ #define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ #define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ #define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ #define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ #define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ #define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ /* 65550-65556 are allocated to Oceana Matrix */ #define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ #define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ #define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ #define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ #define DCSIMAGERFILTER_IR 0 /* infrared filter */ #define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ #define DCSIMAGERFILTER_CFA 2 /* color filter array */ #define DCSIMAGERFILTER_OTHER 3 /* other filter */ #define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ #define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ #define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ #define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ #define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ #define TIFFTAG_DCSGAMMA 65554 /* gamma value */ #define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ #define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ /* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ #define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ #define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ /* 65559 is allocated to Oceana Matrix */ #define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ #define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ #define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ #define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ #define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ #define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ #define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ #define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ #define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ #define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ #define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ #define PERSAMPLE_MERGED 0 /* present as a single value */ #define PERSAMPLE_MULTI 1 /* present as multiple values */ /* * EXIF tags */ #define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ #define EXIFTAG_FNUMBER 33437 /* F number */ #define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ #define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ #define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ #define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ #define EXIFTAG_EXIFVERSION 36864 /* Exif version */ #define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ #define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */ #define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ #define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ #define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ #define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ #define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ #define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ #define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ #define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ #define EXIFTAG_METERINGMODE 37383 /* Metering mode */ #define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ #define EXIFTAG_FLASH 37385 /* Flash */ #define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ #define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ #define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ #define EXIFTAG_USERCOMMENT 37510 /* User comments */ #define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ #define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ #define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ #define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ #define EXIFTAG_COLORSPACE 40961 /* Color space information */ #define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ #define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ #define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ #define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ #define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ #define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ #define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ #define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ #define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ #define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ #define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ #define EXIFTAG_FILESOURCE 41728 /* File source */ #define EXIFTAG_SCENETYPE 41729 /* Scene type */ #define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ #define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ #define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ #define EXIFTAG_WHITEBALANCE 41987 /* White balance */ #define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ #define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ #define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_CONTRAST 41992 /* Contrast */ #define EXIFTAG_SATURATION 41993 /* Saturation */ #define EXIFTAG_SHARPNESS 41994 /* Sharpness */ #define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ #define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/linux/tiffconf.h ================================================ /* libtiff/tiffconf.h. Generated from tiffconf.h.in by configure. */ /* Configuration defines for installed libtiff. This file maintained for backward compatibility. Do not use definitions from this file in your programs. */ #ifndef _TIFFCONF_ #define _TIFFCONF_ /* Signed 16-bit type */ #define TIFF_INT16_T signed short /* Signed 32-bit type */ #define TIFF_INT32_T signed int /* Signed 64-bit type */ #define TIFF_INT64_T signed long long /* Signed 8-bit type */ #define TIFF_INT8_T signed char /* Unsigned 16-bit type */ #define TIFF_UINT16_T unsigned short /* Unsigned 32-bit type */ #define TIFF_UINT32_T unsigned int /* Unsigned 64-bit type */ #define TIFF_UINT64_T unsigned long long /* Unsigned 8-bit type */ #define TIFF_UINT8_T unsigned char /* Signed size type */ #define TIFF_SSIZE_T signed long /* Pointer difference type */ #define TIFF_PTRDIFF_T ptrdiff_t /* Define to 1 if the system has the type `int16'. */ /* #undef HAVE_INT16 */ /* Define to 1 if the system has the type `int32'. */ /* #undef HAVE_INT32 */ /* Define to 1 if the system has the type `int8'. */ /* #undef HAVE_INT8 */ /* Compatibility stuff. */ /* Define as 0 or 1 according to the floating point format suported by the machine */ #define HAVE_IEEEFP 1 /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ #define HOST_FILLORDER FILLORDER_LSB2MSB /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ #define HOST_BIGENDIAN 0 /* Support CCITT Group 3 & 4 algorithms */ #define CCITT_SUPPORT 1 /* Support JPEG compression (requires IJG JPEG library) */ /* #undef JPEG_SUPPORT */ /* Support JBIG compression (requires JBIG-KIT library) */ /* #undef JBIG_SUPPORT */ /* Support LogLuv high dynamic range encoding */ #define LOGLUV_SUPPORT 1 /* Support LZW algorithm */ #define LZW_SUPPORT 1 /* Support NeXT 2-bit RLE algorithm */ #define NEXT_SUPPORT 1 /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation fails with unpatched IJG JPEG library) */ /* #undef OJPEG_SUPPORT */ /* Support Macintosh PackBits algorithm */ #define PACKBITS_SUPPORT 1 /* Support Pixar log-format algorithm (requires Zlib) */ #define PIXARLOG_SUPPORT 1 /* Support ThunderScan 4-bit RLE algorithm */ #define THUNDER_SUPPORT 1 /* Support Deflate compression */ #define ZIP_SUPPORT 1 /* Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage) */ #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* Enable SubIFD tag (330) support */ #define SUBIFD_SUPPORT 1 /* Treat extra sample as alpha (default enabled). The RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly. */ #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 /* Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled). */ #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 /* Support MS MDI magic number files as TIFF */ #define MDI_SUPPORT 1 /* * Feature support definitions. * XXX: These macros are obsoleted. Don't use them in your apps! * Macros stays here for backward compatibility and should be always defined. */ #define COLORIMETRY_SUPPORT #define YCBCR_SUPPORT #define CMYK_SUPPORT #define ICC_SUPPORT #define PHOTOSHOP_SUPPORT #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ ================================================ FILE: cocos2d/external/tiff/include/linux/tiffio.h ================================================ /* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIO_ #define _TIFFIO_ /* * TIFF I/O Library Definitions. */ #include "tiff.h" #include "tiffvers.h" /* * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ typedef struct tiff TIFF; /* * The following typedefs define the intrinsic size of * data types used in the *exported* interfaces. These * definitions depend on the proper definition of types * in tiff.h. Note also that the varargs interface used * to pass tag types and values uses the types defined in * tiff.h directly. * * NB: ttag_t is unsigned int and not unsigned short because * ANSI C requires that the type before the ellipsis be a * promoted type (i.e. one of int, unsigned int, pointer, * or double) and because we defined pseudo-tags that are * outside the range of legal Aldus-assigned tags. * NB: tsize_t is int32 and not uint32 because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at * 32-bit file offsets, and BigTIFF maxes out at 64-bit * offsets being the most important, and to ensure use of * a consistently unsigned type across architectures. * Prior to libtiff 4.0, this was an unsigned 32 bit type. */ /* * this is the machine addressing size type, only it's signed, so make it * int32 on 32bit machines, int64 on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; typedef uint64 toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ typedef uint32 ttag_t; /* directory tag */ typedef uint16 tdir_t; /* directory index */ typedef uint16 tsample_t; /* sample number */ typedef uint32 tstrile_t; /* strip or tile number */ typedef tstrile_t tstrip_t; /* strip number */ typedef tstrile_t ttile_t; /* tile number */ typedef tmsize_t tsize_t; /* i/o size in bytes */ typedef void* tdata_t; /* image data ref */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ #endif /* * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). * * By default tif_unix.c is assumed. */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) # define AVOID_WIN32_FILEIO # endif #endif #if defined(USE_WIN32_FILEIO) # define VC_EXTRALEAN # include # ifdef __WIN32__ DECLARE_HANDLE(thandle_t); /* Win32 file handle */ # else typedef HFILE thandle_t; /* client data handle */ # endif /* __WIN32__ */ #else typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ /* * Colour conversion stuff */ /* reference white */ #define D65_X0 (95.0470F) #define D65_Y0 (100.0F) #define D65_Z0 (108.8827F) #define D50_X0 (96.4250F) #define D50_Y0 (100.0F) #define D50_Z0 (82.4680F) /* Structure for holding information about a display device. */ typedef unsigned char TIFFRGBValue; /* 8-bit samples */ typedef struct { float d_mat[3][3]; /* XYZ -> luminance matrix */ float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; uint32 d_Vrwr; /* Pixel values for ref. white */ uint32 d_Vrwg; uint32 d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; float d_gammaR; /* Gamma values for the three guns */ float d_gammaG; float d_gammaB; } TIFFDisplay; typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; int32* Cr_g_tab; int32* Cb_g_tab; int32* Y_tab; } TIFFYCbCrToRGB; typedef struct { /* CIE Lab 1976->RGB support */ int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 float rstep, gstep, bstep; float X0, Y0, Z0; /* Reference white point */ TIFFDisplay display; float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* * RGBA-style image support. */ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*); typedef void (*tileSeparateRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ struct _TIFFRGBAImage { TIFF* tif; /* image handle */ int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ uint32 width; /* image width */ uint32 height; /* image height */ uint16 bitspersample; /* image bits/sample */ uint16 samplesperpixel; /* image samples/pixel */ uint16 orientation; /* image orientation */ uint16 req_orientation; /* requested orientation */ uint16 photometric; /* image photometric interp */ uint16* redcmap; /* colormap pallete */ uint16* greencmap; uint16* bluecmap; /* get image data routine */ int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); /* put decoded strip/tile */ union { void (*any)(TIFFRGBAImage*); tileContigRoutine contig; tileSeparateRoutine separate; } put; TIFFRGBValue* Map; /* sample mapping array */ uint32** BWmap; /* black&white map */ uint32** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */ uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ int row_offset; int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ #define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) /* * A CODEC is a software package that implements decoding, * encoding, or decoding+encoding of a compression algorithm. * The library provides a collection of builtin codecs. * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; uint16 scheme; TIFFInitMethod init; } TIFFCodec; #include #include /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC #define LOGLUV_PUBLIC 1 #endif #if !defined(__GNUC__) && !defined(__attribute__) # define __attribute__(x) /*nothing*/ #endif #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); extern const TIFFCodec* TIFFFindCODEC(uint16); extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); extern int TIFFIsCODECConfigured(uint16); extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* * Auxiliary functions. */ extern void* _TIFFmalloc(tmsize_t s); extern void* _TIFFrealloc(void* p, tmsize_t s); extern void _TIFFmemset(void* p, int v, tmsize_t c); extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); extern void _TIFFfree(void* p); /* ** Stuff, related to tag handling and creating custom tags. */ extern int TIFFGetTagListCount( TIFF * ); extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ #define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ #define FIELD_CUSTOM 65 typedef struct _TIFFField TIFFField; typedef struct _TIFFFieldArray TIFFFieldArray; extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); extern uint32 TIFFFieldTag(const TIFFField*); extern const char* TIFFFieldName(const TIFFField*); extern TIFFDataType TIFFFieldDataType(const TIFFField*); extern int TIFFFieldPassCount(const TIFFField*); extern int TIFFFieldReadCount(const TIFFField*); extern int TIFFFieldWriteCount(const TIFFField*); typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef struct { TIFFVSetMethod vsetfield; /* tag set routine */ TIFFVGetMethod vgetfield; /* tag get routine */ TIFFPrintMethod printdir; /* directory print routine */ } TIFFTagMethods; extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); extern void *TIFFGetClientInfo(TIFF *, const char *); extern void TIFFSetClientInfo(TIFF *, void *, const char *); extern void TIFFCleanup(TIFF* tif); extern void TIFFClose(TIFF* tif); extern int TIFFFlush(TIFF* tif); extern int TIFFFlushData(TIFF* tif); extern int TIFFGetField(TIFF* tif, uint32 tag, ...); extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); extern int TIFFReadDirectory(TIFF* tif); extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); extern uint64 TIFFScanlineSize64(TIFF* tif); extern tmsize_t TIFFScanlineSize(TIFF* tif); extern uint64 TIFFRasterScanlineSize64(TIFF* tif); extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); extern uint64 TIFFStripSize64(TIFF* tif); extern tmsize_t TIFFStripSize(TIFF* tif); extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); extern uint64 TIFFTileRowSize64(TIFF* tif); extern tmsize_t TIFFTileRowSize(TIFF* tif); extern uint64 TIFFTileSize64(TIFF* tif); extern tmsize_t TIFFTileSize(TIFF* tif); extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); extern int TIFFFileno(TIFF*); extern int TIFFSetFileno(TIFF*, int); extern thandle_t TIFFClientdata(TIFF*); extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); extern int TIFFGetMode(TIFF*); extern int TIFFSetMode(TIFF*, int); extern int TIFFIsTiled(TIFF*); extern int TIFFIsByteSwapped(TIFF*); extern int TIFFIsUpSampled(TIFF*); extern int TIFFIsMSB2LSB(TIFF*); extern int TIFFIsBigEndian(TIFF*); extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); extern TIFFSeekProc TIFFGetSeekProc(TIFF*); extern TIFFCloseProc TIFFGetCloseProc(TIFF*); extern TIFFSizeProc TIFFGetSizeProc(TIFF*); extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); extern uint32 TIFFCurrentRow(TIFF*); extern uint16 TIFFCurrentDirectory(TIFF*); extern uint16 TIFFNumberOfDirectories(TIFF*); extern uint64 TIFFCurrentDirOffset(TIFF*); extern uint32 TIFFCurrentStrip(TIFF*); extern uint32 TIFFCurrentTile(TIFF* tif); extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFSetupStrips(TIFF *); extern int TIFFWriteCheck(TIFF*, int, const char *); extern void TIFFFreeDirectory(TIFF*); extern int TIFFCreateDirectory(TIFF*); extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); extern int TIFFSetDirectory(TIFF*, uint16); extern int TIFFSetSubDirectory(TIFF*, uint64); extern int TIFFUnlinkDirectory(TIFF*, uint16); extern int TIFFSetField(TIFF*, uint32, ...); extern int TIFFVSetField(TIFF*, uint32, va_list); extern int TIFFUnsetField(TIFF*, uint32); extern int TIFFWriteDirectory(TIFF *); extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int = ORIENTATION_BOTLEFT, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); #endif extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); # ifdef __WIN32__ extern TIFF* TIFFOpenW(const wchar_t*, const char*); # endif /* __WIN32__ */ extern TIFF* TIFFFdOpen(int, const char*, const char*); extern TIFF* TIFFClientOpen(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); extern const char* TIFFFileName(TIFF*); extern const char* TIFFSetFileName(TIFF*, const char *); extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFNumberOfTiles(TIFF*); extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); extern uint32 TIFFNumberOfStrips(TIFF*); extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); extern void TIFFSwabShort(uint16*); extern void TIFFSwabLong(uint32*); extern void TIFFSwabLong8(uint64*); extern void TIFFSwabFloat(float*); extern void TIFFSwabDouble(double*); extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); extern void TIFFReverseBits(uint8* cp, tmsize_t n); extern const unsigned char* TIFFGetBitRevTable(int); #ifdef LOGLUV_PUBLIC #define U_NEU 0.210526316 #define V_NEU 0.473684211 #define UVSCALE 410. extern double LogL16toY(int); extern double LogL10toY(int); extern void XYZtoRGB24(float*, uint8*); extern int uv_decode(double*, double*, int); extern void LogLuv24toXYZ(uint32, float*); extern void LogLuv32toXYZ(uint32, float*); #if defined(c_plusplus) || defined(__cplusplus) extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); #else extern int LogL16fromY(double, int); extern int LogL10fromY(double, int); extern int uv_encode(double, double, int); extern uint32 LogLuv24fromXYZ(float*, int); extern uint32 LogLuv32fromXYZ(float*, int); #endif #endif /* LOGLUV_PUBLIC */ extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, float *, float *, float *); extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32 *, uint32 *, uint32 *); extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, uint32 *, uint32 *, uint32 *); /**************************************************************************** * O B S O L E T E D I N T E R F A C E S * * Don't use this stuff in your applications, it may be removed in the future * libtiff versions. ****************************************************************************/ typedef struct { ttag_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ short field_writecount; /* write count/TIFF_VARIABLE */ TIFFDataType field_type; /* type of associated data */ unsigned short field_bit; /* bit in fieldsset bit vector */ unsigned char field_oktochange; /* if true, can change while writing */ unsigned char field_passcount; /* if true, pass dir count on set */ char *field_name; /* ASCII name */ } TIFFFieldInfo; extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); #if defined(c_plusplus) || defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/linux/tiffvers.h ================================================ #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a * version or versions of the library. Runtime * version checking should be done based on the * string returned by TIFFGetVersion. */ #define TIFFLIB_VERSION 20120922 ================================================ FILE: cocos2d/external/tiff/include/mac/tiff.h ================================================ /* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ #define _TIFF_ #include "tiffconf.h" /* * Tag Image File Format (TIFF) * * Based on Rev 6.0 from: * Developer's Desk * Aldus Corporation * 411 First Ave. South * Suite 200 * Seattle, WA 98104 * 206-622-5500 * * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) * * For BigTIFF design notes see the following links * http://www.remotesensing.org/libtiff/bigtiffdesign.html * http://www.awaresystems.be/imaging/tiff/bigtiff.html */ #define TIFF_VERSION_CLASSIC 42 #define TIFF_VERSION_BIG 43 #define TIFF_BIGENDIAN 0x4d4d #define TIFF_LITTLEENDIAN 0x4949 #define MDI_LITTLEENDIAN 0x5045 #define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * * 8-bit quantities int8/uint8 * 16-bit quantities int16/uint16 * 32-bit quantities int32/uint32 * 64-bit quantities int64/uint64 * strings unsigned char* */ typedef TIFF_INT8_T int8; typedef TIFF_UINT8_T uint8; typedef TIFF_INT16_T int16; typedef TIFF_UINT16_T uint16; typedef TIFF_INT32_T int32; typedef TIFF_UINT32_T uint32; typedef TIFF_INT64_T int64; typedef TIFF_UINT64_T uint64; /* * Some types as promoted in a variable argument list * We use uint16_vap rather then directly using int, because this way * we document the type we actually want to pass through, conceptually, * rather then confusing the issue by merely stating the type it gets * promoted to */ typedef int uint16_vap; /* * TIFF header. */ typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ } TIFFHeaderCommon; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint32 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint16 tiff_offsetsize; /* size of offsets, should be 8 */ uint16 tiff_unused; /* unused word, should be 0 */ uint64 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderBig; /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, * - items marked with a ! are introduced in revision 6.0. * - items marked with a % are introduced post revision 6.0. * - items marked with a $ are obsoleted by revision 6.0. * - items marked with a & are introduced by Adobe DNG specification. */ /* * Tag data type information. * * Note: RATIONALs are the ratio of two 32-bit integer values. */ typedef enum { TIFF_NOTYPE = 0, /* placeholder */ TIFF_BYTE = 1, /* 8-bit unsigned integer */ TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ TIFF_SHORT = 3, /* 16-bit unsigned integer */ TIFF_LONG = 4, /* 32-bit unsigned integer */ TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ TIFF_SBYTE = 6, /* !8-bit signed integer */ TIFF_UNDEFINED = 7, /* !8-bit untyped data */ TIFF_SSHORT = 8, /* !16-bit signed integer */ TIFF_SLONG = 9, /* !32-bit signed integer */ TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* * TIFF Tag Definitions. */ #define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ #define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ #define FILETYPE_PAGE 0x2 /* one page of many */ #define FILETYPE_MASK 0x4 /* transparency mask */ #define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ #define OFILETYPE_IMAGE 1 /* full resolution image data */ #define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ #define OFILETYPE_PAGE 3 /* one page of many */ #define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ #define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ #define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ #define TIFFTAG_COMPRESSION 259 /* data compression technique */ #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ #define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ #define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ #define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ #define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ #define COMPRESSION_JBIG 34661 /* ISO JBIG */ #define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ #define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ #define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ #define COMPRESSION_LZMA 34925 /* LZMA2 */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ #define PHOTOMETRIC_RGB 2 /* RGB color model */ #define PHOTOMETRIC_PALETTE 3 /* color map indexed */ #define PHOTOMETRIC_MASK 4 /* $holdout mask */ #define PHOTOMETRIC_SEPARATED 5 /* !color separations */ #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ #define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ #define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ #define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ #define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ #define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ #define THRESHHOLD_BILEVEL 1 /* b&w art scan */ #define THRESHHOLD_HALFTONE 2 /* or dithered scan */ #define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ #define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ #define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ #define TIFFTAG_FILLORDER 266 /* data order within a byte */ #define FILLORDER_MSB2LSB 1 /* most significant -> least */ #define FILLORDER_LSB2MSB 2 /* least significant -> most */ #define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ #define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ #define TIFFTAG_MAKE 271 /* scanner manufacturer name */ #define TIFFTAG_MODEL 272 /* scanner model name/number */ #define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ #define TIFFTAG_ORIENTATION 274 /* +image orientation */ #define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ #define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ #define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ #define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ #define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ #define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ #define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ #define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ #define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ #define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ #define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ #define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ #define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ #define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ #define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ #define TIFFTAG_PLANARCONFIG 284 /* storage organization */ #define PLANARCONFIG_CONTIG 1 /* single image plane */ #define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ #define TIFFTAG_PAGENAME 285 /* page name image is from */ #define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ #define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ #define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ #define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ #define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ #define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ #define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ #define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ #define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ #define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ #define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ #define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ #define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ #define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ #define RESUNIT_NONE 1 /* no meaningful units */ #define RESUNIT_INCH 2 /* english */ #define RESUNIT_CENTIMETER 3 /* metric */ #define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ #define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ #define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ #define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ #define TIFFTAG_SOFTWARE 305 /* name & release */ #define TIFFTAG_DATETIME 306 /* creation date and time */ #define TIFFTAG_ARTIST 315 /* creator of image */ #define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ #define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ #define PREDICTOR_NONE 1 /* no prediction scheme used */ #define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ #define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ #define TIFFTAG_WHITEPOINT 318 /* image white point */ #define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ #define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ #define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ #define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ #define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ #define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ #define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ #define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ #define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ #define CLEANFAXDATA_CLEAN 0 /* no errors detected */ #define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ #define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ #define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ #define TIFFTAG_SUBIFD 330 /* subimage descriptors */ #define TIFFTAG_INKSET 332 /* !inks in separated image */ #define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ #define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ #define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ #define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ #define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ #define TIFFTAG_TARGETPRINTER 337 /* !separation target */ #define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ #define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ #define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ #define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ #define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ #define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ #define SAMPLEFORMAT_INT 2 /* !signed integer data */ #define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ #define SAMPLEFORMAT_VOID 4 /* !untyped data */ #define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ #define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ #define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ #define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ #define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */ #define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ /* Tags 400-435 are from the TIFF/FX spec */ #define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ #define TIFFTAG_PROFILETYPE 401 /* ! */ #define PROFILETYPE_UNSPECIFIED 0 /* ! */ #define PROFILETYPE_G3_FAX 1 /* ! */ #define TIFFTAG_FAXPROFILE 402 /* ! */ #define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ #define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ #define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ #define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ #define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ #define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ #define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ #define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ #define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ #define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ #define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ #define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ #define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ #define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ #define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ #define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ #define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ #define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. */ #define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ #define JPEGPROC_BASELINE 1 /* !baseline sequential */ #define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ #define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ #define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ #define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ #define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ #define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ #define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ #define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ #define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ #define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ #define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ #define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ #define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ #define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */ /* tags 32952-32956 are private tags registered to Island Graphics */ #define TIFFTAG_REFPTS 32953 /* image reference points */ #define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ #define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ #define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ #define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ #define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ #define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ #define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ #define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ #define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ /* Tags 33302-33306 are used to identify special image modes and data * used by Pixar's texture formats. */ #define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ #define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ #define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ #define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 /* tag 33405 is a private tag registered to Eastman Kodak */ #define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ #define TIFFTAG_COPYRIGHT 33432 /* copyright string */ /* IPTC TAG from RichTIFF specifications */ #define TIFFTAG_RICHTIFFIPTC 33723 /* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ #define TIFFTAG_STONITS 37439 /* Sample value to Nits */ /* tag 34929 is a private tag registered to FedEx */ #define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ #define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ /* Adobe Digital Negative (DNG) format tags */ #define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ #define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ #define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ #define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name */ #define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */ #define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ #define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ #define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */ #define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ #define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */ #define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */ #define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */ #define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ #define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */ #define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */ #define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */ #define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */ #define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ #define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ #define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */ #define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */ #define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/ #define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */ #define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */ #define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */ #define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ #define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */ #define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of the green pixels in the blue/green rows track the values of the green pixels in the red/green rows */ #define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ #define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ #define TIFFTAG_LENSINFO 50736 /* info about the lens */ #define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ #define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */ #define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ #define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ #define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */ #define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ #define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ #define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ #define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */ #define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file */ #define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */ #define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */ #define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */ #define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ #define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */ #define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ #define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ /* tag 65535 is an undefined tag used by Eastman Kodak */ #define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ /* * The following are ``pseudo tags'' that can be used to control * codec-specific functionality. These tags are not written to file. * Note that these values start at 0xffff+1 so that they'll never * collide with Aldus-assigned tags. * * If you want your private pseudo tags ``registered'' (i.e. added to * this file), please post a bug report via the tracking system at * http://www.remotesensing.org/libtiff/bugs.html with the appropriate * C definitions to add. */ #define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ #define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ #define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ #define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ #define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ #define FAXMODE_WORDALIGN 0x0008 /* word align row */ #define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ #define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ #define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ #define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ #define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ #define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ #define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ #define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ #define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ #define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ #define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ #define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ #define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ #define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ #define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ #define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ /* 65550-65556 are allocated to Oceana Matrix */ #define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ #define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ #define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ #define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ #define DCSIMAGERFILTER_IR 0 /* infrared filter */ #define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ #define DCSIMAGERFILTER_CFA 2 /* color filter array */ #define DCSIMAGERFILTER_OTHER 3 /* other filter */ #define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ #define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ #define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ #define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ #define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ #define TIFFTAG_DCSGAMMA 65554 /* gamma value */ #define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ #define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ /* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ #define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ #define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ /* 65559 is allocated to Oceana Matrix */ #define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ #define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ #define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ #define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ #define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ #define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ #define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ #define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ #define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ #define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ #define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ #define PERSAMPLE_MERGED 0 /* present as a single value */ #define PERSAMPLE_MULTI 1 /* present as multiple values */ /* * EXIF tags */ #define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ #define EXIFTAG_FNUMBER 33437 /* F number */ #define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ #define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ #define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ #define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ #define EXIFTAG_EXIFVERSION 36864 /* Exif version */ #define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ #define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */ #define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ #define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ #define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ #define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ #define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ #define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ #define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ #define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ #define EXIFTAG_METERINGMODE 37383 /* Metering mode */ #define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ #define EXIFTAG_FLASH 37385 /* Flash */ #define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ #define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ #define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ #define EXIFTAG_USERCOMMENT 37510 /* User comments */ #define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ #define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ #define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ #define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ #define EXIFTAG_COLORSPACE 40961 /* Color space information */ #define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ #define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ #define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ #define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ #define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ #define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ #define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ #define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ #define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ #define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ #define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ #define EXIFTAG_FILESOURCE 41728 /* File source */ #define EXIFTAG_SCENETYPE 41729 /* Scene type */ #define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ #define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ #define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ #define EXIFTAG_WHITEBALANCE 41987 /* White balance */ #define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ #define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ #define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_CONTRAST 41992 /* Contrast */ #define EXIFTAG_SATURATION 41993 /* Saturation */ #define EXIFTAG_SHARPNESS 41994 /* Sharpness */ #define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ #define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/mac/tiffconf.h ================================================ /* libtiff/tiffconf.h. Generated from tiffconf.h.in by configure. */ /* Configuration defines for installed libtiff. This file maintained for backward compatibility. Do not use definitions from this file in your programs. */ #ifndef _TIFFCONF_ #define _TIFFCONF_ /* Signed 16-bit type */ #define TIFF_INT16_T signed short /* Signed 32-bit type */ #define TIFF_INT32_T signed int /* Signed 64-bit type */ #define TIFF_INT64_T signed long long /* Signed 8-bit type */ #define TIFF_INT8_T signed char /* Unsigned 16-bit type */ #define TIFF_UINT16_T unsigned short /* Unsigned 32-bit type */ #define TIFF_UINT32_T unsigned int /* Unsigned 64-bit type */ #define TIFF_UINT64_T unsigned long long /* Unsigned 8-bit type */ #define TIFF_UINT8_T unsigned char /* Signed size type */ #define TIFF_SSIZE_T signed long long /* Pointer difference type */ #define TIFF_PTRDIFF_T ptrdiff_t /* Define to 1 if the system has the type `int16'. */ /* #undef HAVE_INT16 */ /* Define to 1 if the system has the type `int32'. */ /* #undef HAVE_INT32 */ /* Define to 1 if the system has the type `int8'. */ /* #undef HAVE_INT8 */ /* Compatibility stuff. */ /* Define as 0 or 1 according to the floating point format suported by the machine */ #define HAVE_IEEEFP 1 /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ #define HOST_FILLORDER FILLORDER_LSB2MSB /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ #define HOST_BIGENDIAN 0 /* Support CCITT Group 3 & 4 algorithms */ #define CCITT_SUPPORT 1 /* Support JPEG compression (requires IJG JPEG library) */ #define JPEG_SUPPORT 1 /* Support JBIG compression (requires JBIG-KIT library) */ /* #undef JBIG_SUPPORT */ /* Support LogLuv high dynamic range encoding */ #define LOGLUV_SUPPORT 1 /* Support LZW algorithm */ #define LZW_SUPPORT 1 /* Support NeXT 2-bit RLE algorithm */ #define NEXT_SUPPORT 1 /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation fails with unpatched IJG JPEG library) */ #define OJPEG_SUPPORT 1 /* Support Macintosh PackBits algorithm */ #define PACKBITS_SUPPORT 1 /* Support Pixar log-format algorithm (requires Zlib) */ #define PIXARLOG_SUPPORT 1 /* Support ThunderScan 4-bit RLE algorithm */ #define THUNDER_SUPPORT 1 /* Support Deflate compression */ #define ZIP_SUPPORT 1 /* Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage) */ #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* Enable SubIFD tag (330) support */ #define SUBIFD_SUPPORT 1 /* Treat extra sample as alpha (default enabled). The RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly. */ #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 /* Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled). */ #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 /* Support MS MDI magic number files as TIFF */ #define MDI_SUPPORT 1 /* * Feature support definitions. * XXX: These macros are obsoleted. Don't use them in your apps! * Macros stays here for backward compatibility and should be always defined. */ #define COLORIMETRY_SUPPORT #define YCBCR_SUPPORT #define CMYK_SUPPORT #define ICC_SUPPORT #define PHOTOSHOP_SUPPORT #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ ================================================ FILE: cocos2d/external/tiff/include/mac/tiffio.h ================================================ /* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIO_ #define _TIFFIO_ /* * TIFF I/O Library Definitions. */ #include "tiff.h" #include "tiffvers.h" /* * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ typedef struct tiff TIFF; /* * The following typedefs define the intrinsic size of * data types used in the *exported* interfaces. These * definitions depend on the proper definition of types * in tiff.h. Note also that the varargs interface used * to pass tag types and values uses the types defined in * tiff.h directly. * * NB: ttag_t is unsigned int and not unsigned short because * ANSI C requires that the type before the ellipsis be a * promoted type (i.e. one of int, unsigned int, pointer, * or double) and because we defined pseudo-tags that are * outside the range of legal Aldus-assigned tags. * NB: tsize_t is int32 and not uint32 because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at * 32-bit file offsets, and BigTIFF maxes out at 64-bit * offsets being the most important, and to ensure use of * a consistently unsigned type across architectures. * Prior to libtiff 4.0, this was an unsigned 32 bit type. */ /* * this is the machine addressing size type, only it's signed, so make it * int32 on 32bit machines, int64 on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; typedef uint64 toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ typedef uint32 ttag_t; /* directory tag */ typedef uint16 tdir_t; /* directory index */ typedef uint16 tsample_t; /* sample number */ typedef uint32 tstrile_t; /* strip or tile number */ typedef tstrile_t tstrip_t; /* strip number */ typedef tstrile_t ttile_t; /* tile number */ typedef tmsize_t tsize_t; /* i/o size in bytes */ typedef void* tdata_t; /* image data ref */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ #endif /* * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). * * By default tif_unix.c is assumed. */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) # define AVOID_WIN32_FILEIO # endif #endif #if defined(USE_WIN32_FILEIO) # define VC_EXTRALEAN # include # ifdef __WIN32__ DECLARE_HANDLE(thandle_t); /* Win32 file handle */ # else typedef HFILE thandle_t; /* client data handle */ # endif /* __WIN32__ */ #else typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ /* * Colour conversion stuff */ /* reference white */ #define D65_X0 (95.0470F) #define D65_Y0 (100.0F) #define D65_Z0 (108.8827F) #define D50_X0 (96.4250F) #define D50_Y0 (100.0F) #define D50_Z0 (82.4680F) /* Structure for holding information about a display device. */ typedef unsigned char TIFFRGBValue; /* 8-bit samples */ typedef struct { float d_mat[3][3]; /* XYZ -> luminance matrix */ float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; uint32 d_Vrwr; /* Pixel values for ref. white */ uint32 d_Vrwg; uint32 d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; float d_gammaR; /* Gamma values for the three guns */ float d_gammaG; float d_gammaB; } TIFFDisplay; typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; int32* Cr_g_tab; int32* Cb_g_tab; int32* Y_tab; } TIFFYCbCrToRGB; typedef struct { /* CIE Lab 1976->RGB support */ int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 float rstep, gstep, bstep; float X0, Y0, Z0; /* Reference white point */ TIFFDisplay display; float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* * RGBA-style image support. */ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*); typedef void (*tileSeparateRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ struct _TIFFRGBAImage { TIFF* tif; /* image handle */ int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ uint32 width; /* image width */ uint32 height; /* image height */ uint16 bitspersample; /* image bits/sample */ uint16 samplesperpixel; /* image samples/pixel */ uint16 orientation; /* image orientation */ uint16 req_orientation; /* requested orientation */ uint16 photometric; /* image photometric interp */ uint16* redcmap; /* colormap pallete */ uint16* greencmap; uint16* bluecmap; /* get image data routine */ int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); /* put decoded strip/tile */ union { void (*any)(TIFFRGBAImage*); tileContigRoutine contig; tileSeparateRoutine separate; } put; TIFFRGBValue* Map; /* sample mapping array */ uint32** BWmap; /* black&white map */ uint32** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */ uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ int row_offset; int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ #define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) /* * A CODEC is a software package that implements decoding, * encoding, or decoding+encoding of a compression algorithm. * The library provides a collection of builtin codecs. * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; uint16 scheme; TIFFInitMethod init; } TIFFCodec; #include #include /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC #define LOGLUV_PUBLIC 1 #endif #if !defined(__GNUC__) && !defined(__attribute__) # define __attribute__(x) /*nothing*/ #endif #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); extern const TIFFCodec* TIFFFindCODEC(uint16); extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); extern int TIFFIsCODECConfigured(uint16); extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* * Auxiliary functions. */ extern void* _TIFFmalloc(tmsize_t s); extern void* _TIFFrealloc(void* p, tmsize_t s); extern void _TIFFmemset(void* p, int v, tmsize_t c); extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); extern void _TIFFfree(void* p); /* ** Stuff, related to tag handling and creating custom tags. */ extern int TIFFGetTagListCount( TIFF * ); extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ #define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ #define FIELD_CUSTOM 65 typedef struct _TIFFField TIFFField; typedef struct _TIFFFieldArray TIFFFieldArray; extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); extern uint32 TIFFFieldTag(const TIFFField*); extern const char* TIFFFieldName(const TIFFField*); extern TIFFDataType TIFFFieldDataType(const TIFFField*); extern int TIFFFieldPassCount(const TIFFField*); extern int TIFFFieldReadCount(const TIFFField*); extern int TIFFFieldWriteCount(const TIFFField*); typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef struct { TIFFVSetMethod vsetfield; /* tag set routine */ TIFFVGetMethod vgetfield; /* tag get routine */ TIFFPrintMethod printdir; /* directory print routine */ } TIFFTagMethods; extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); extern void *TIFFGetClientInfo(TIFF *, const char *); extern void TIFFSetClientInfo(TIFF *, void *, const char *); extern void TIFFCleanup(TIFF* tif); extern void TIFFClose(TIFF* tif); extern int TIFFFlush(TIFF* tif); extern int TIFFFlushData(TIFF* tif); extern int TIFFGetField(TIFF* tif, uint32 tag, ...); extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); extern int TIFFReadDirectory(TIFF* tif); extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); extern uint64 TIFFScanlineSize64(TIFF* tif); extern tmsize_t TIFFScanlineSize(TIFF* tif); extern uint64 TIFFRasterScanlineSize64(TIFF* tif); extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); extern uint64 TIFFStripSize64(TIFF* tif); extern tmsize_t TIFFStripSize(TIFF* tif); extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); extern uint64 TIFFTileRowSize64(TIFF* tif); extern tmsize_t TIFFTileRowSize(TIFF* tif); extern uint64 TIFFTileSize64(TIFF* tif); extern tmsize_t TIFFTileSize(TIFF* tif); extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); extern int TIFFFileno(TIFF*); extern int TIFFSetFileno(TIFF*, int); extern thandle_t TIFFClientdata(TIFF*); extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); extern int TIFFGetMode(TIFF*); extern int TIFFSetMode(TIFF*, int); extern int TIFFIsTiled(TIFF*); extern int TIFFIsByteSwapped(TIFF*); extern int TIFFIsUpSampled(TIFF*); extern int TIFFIsMSB2LSB(TIFF*); extern int TIFFIsBigEndian(TIFF*); extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); extern TIFFSeekProc TIFFGetSeekProc(TIFF*); extern TIFFCloseProc TIFFGetCloseProc(TIFF*); extern TIFFSizeProc TIFFGetSizeProc(TIFF*); extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); extern uint32 TIFFCurrentRow(TIFF*); extern uint16 TIFFCurrentDirectory(TIFF*); extern uint16 TIFFNumberOfDirectories(TIFF*); extern uint64 TIFFCurrentDirOffset(TIFF*); extern uint32 TIFFCurrentStrip(TIFF*); extern uint32 TIFFCurrentTile(TIFF* tif); extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFSetupStrips(TIFF *); extern int TIFFWriteCheck(TIFF*, int, const char *); extern void TIFFFreeDirectory(TIFF*); extern int TIFFCreateDirectory(TIFF*); extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); extern int TIFFSetDirectory(TIFF*, uint16); extern int TIFFSetSubDirectory(TIFF*, uint64); extern int TIFFUnlinkDirectory(TIFF*, uint16); extern int TIFFSetField(TIFF*, uint32, ...); extern int TIFFVSetField(TIFF*, uint32, va_list); extern int TIFFUnsetField(TIFF*, uint32); extern int TIFFWriteDirectory(TIFF *); extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int = ORIENTATION_BOTLEFT, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); #endif extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); # ifdef __WIN32__ extern TIFF* TIFFOpenW(const wchar_t*, const char*); # endif /* __WIN32__ */ extern TIFF* TIFFFdOpen(int, const char*, const char*); extern TIFF* TIFFClientOpen(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); extern const char* TIFFFileName(TIFF*); extern const char* TIFFSetFileName(TIFF*, const char *); extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFNumberOfTiles(TIFF*); extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); extern uint32 TIFFNumberOfStrips(TIFF*); extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); extern void TIFFSwabShort(uint16*); extern void TIFFSwabLong(uint32*); extern void TIFFSwabLong8(uint64*); extern void TIFFSwabFloat(float*); extern void TIFFSwabDouble(double*); extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); extern void TIFFReverseBits(uint8* cp, tmsize_t n); extern const unsigned char* TIFFGetBitRevTable(int); #ifdef LOGLUV_PUBLIC #define U_NEU 0.210526316 #define V_NEU 0.473684211 #define UVSCALE 410. extern double LogL16toY(int); extern double LogL10toY(int); extern void XYZtoRGB24(float*, uint8*); extern int uv_decode(double*, double*, int); extern void LogLuv24toXYZ(uint32, float*); extern void LogLuv32toXYZ(uint32, float*); #if defined(c_plusplus) || defined(__cplusplus) extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); #else extern int LogL16fromY(double, int); extern int LogL10fromY(double, int); extern int uv_encode(double, double, int); extern uint32 LogLuv24fromXYZ(float*, int); extern uint32 LogLuv32fromXYZ(float*, int); #endif #endif /* LOGLUV_PUBLIC */ extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, float *, float *, float *); extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32 *, uint32 *, uint32 *); extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, uint32 *, uint32 *, uint32 *); /**************************************************************************** * O B S O L E T E D I N T E R F A C E S * * Don't use this stuff in your applications, it may be removed in the future * libtiff versions. ****************************************************************************/ typedef struct { ttag_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ short field_writecount; /* write count/TIFF_VARIABLE */ TIFFDataType field_type; /* type of associated data */ unsigned short field_bit; /* bit in fieldsset bit vector */ unsigned char field_oktochange; /* if true, can change while writing */ unsigned char field_passcount; /* if true, pass dir count on set */ char *field_name; /* ASCII name */ } TIFFFieldInfo; extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); #if defined(c_plusplus) || defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/mac/tiffvers.h ================================================ #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a * version or versions of the library. Runtime * version checking should be done based on the * string returned by TIFFGetVersion. */ #define TIFFLIB_VERSION 20120922 ================================================ FILE: cocos2d/external/tiff/include/win32/tiff.h ================================================ /* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ #define _TIFF_ #include "tiffconf.h" /* * Tag Image File Format (TIFF) * * Based on Rev 6.0 from: * Developer's Desk * Aldus Corporation * 411 First Ave. South * Suite 200 * Seattle, WA 98104 * 206-622-5500 * * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) * * For BigTIFF design notes see the following links * http://www.remotesensing.org/libtiff/bigtiffdesign.html * http://www.awaresystems.be/imaging/tiff/bigtiff.html */ #define TIFF_VERSION_CLASSIC 42 #define TIFF_VERSION_BIG 43 #define TIFF_BIGENDIAN 0x4d4d #define TIFF_LITTLEENDIAN 0x4949 #define MDI_LITTLEENDIAN 0x5045 #define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * * 8-bit quantities int8/uint8 * 16-bit quantities int16/uint16 * 32-bit quantities int32/uint32 * 64-bit quantities int64/uint64 * strings unsigned char* */ typedef TIFF_INT8_T int8; typedef TIFF_UINT8_T uint8; typedef TIFF_INT16_T int16; typedef TIFF_UINT16_T uint16; typedef TIFF_INT32_T int32; typedef TIFF_UINT32_T uint32; typedef TIFF_INT64_T int64; typedef TIFF_UINT64_T uint64; /* * Some types as promoted in a variable argument list * We use uint16_vap rather then directly using int, because this way * we document the type we actually want to pass through, conceptually, * rather then confusing the issue by merely stating the type it gets * promoted to */ typedef int uint16_vap; /* * TIFF header. */ typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ } TIFFHeaderCommon; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint32 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint16 tiff_offsetsize; /* size of offsets, should be 8 */ uint16 tiff_unused; /* unused word, should be 0 */ uint64 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderBig; /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, * - items marked with a ! are introduced in revision 6.0. * - items marked with a % are introduced post revision 6.0. * - items marked with a $ are obsoleted by revision 6.0. * - items marked with a & are introduced by Adobe DNG specification. */ /* * Tag data type information. * * Note: RATIONALs are the ratio of two 32-bit integer values. */ typedef enum { TIFF_NOTYPE = 0, /* placeholder */ TIFF_BYTE = 1, /* 8-bit unsigned integer */ TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ TIFF_SHORT = 3, /* 16-bit unsigned integer */ TIFF_LONG = 4, /* 32-bit unsigned integer */ TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ TIFF_SBYTE = 6, /* !8-bit signed integer */ TIFF_UNDEFINED = 7, /* !8-bit untyped data */ TIFF_SSHORT = 8, /* !16-bit signed integer */ TIFF_SLONG = 9, /* !32-bit signed integer */ TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* * TIFF Tag Definitions. */ #define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ #define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ #define FILETYPE_PAGE 0x2 /* one page of many */ #define FILETYPE_MASK 0x4 /* transparency mask */ #define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ #define OFILETYPE_IMAGE 1 /* full resolution image data */ #define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ #define OFILETYPE_PAGE 3 /* one page of many */ #define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ #define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ #define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ #define TIFFTAG_COMPRESSION 259 /* data compression technique */ #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ #define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ #define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ #define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ #define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ #define COMPRESSION_JBIG 34661 /* ISO JBIG */ #define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ #define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ #define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ #define COMPRESSION_LZMA 34925 /* LZMA2 */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ #define PHOTOMETRIC_RGB 2 /* RGB color model */ #define PHOTOMETRIC_PALETTE 3 /* color map indexed */ #define PHOTOMETRIC_MASK 4 /* $holdout mask */ #define PHOTOMETRIC_SEPARATED 5 /* !color separations */ #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ #define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ #define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ #define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ #define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ #define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ #define THRESHHOLD_BILEVEL 1 /* b&w art scan */ #define THRESHHOLD_HALFTONE 2 /* or dithered scan */ #define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ #define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ #define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ #define TIFFTAG_FILLORDER 266 /* data order within a byte */ #define FILLORDER_MSB2LSB 1 /* most significant -> least */ #define FILLORDER_LSB2MSB 2 /* least significant -> most */ #define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ #define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ #define TIFFTAG_MAKE 271 /* scanner manufacturer name */ #define TIFFTAG_MODEL 272 /* scanner model name/number */ #define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ #define TIFFTAG_ORIENTATION 274 /* +image orientation */ #define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ #define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ #define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ #define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ #define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ #define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ #define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ #define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ #define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ #define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ #define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ #define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ #define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ #define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ #define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ #define TIFFTAG_PLANARCONFIG 284 /* storage organization */ #define PLANARCONFIG_CONTIG 1 /* single image plane */ #define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ #define TIFFTAG_PAGENAME 285 /* page name image is from */ #define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ #define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ #define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ #define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ #define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ #define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ #define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ #define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ #define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ #define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ #define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ #define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ #define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ #define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ #define RESUNIT_NONE 1 /* no meaningful units */ #define RESUNIT_INCH 2 /* english */ #define RESUNIT_CENTIMETER 3 /* metric */ #define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ #define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ #define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ #define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ #define TIFFTAG_SOFTWARE 305 /* name & release */ #define TIFFTAG_DATETIME 306 /* creation date and time */ #define TIFFTAG_ARTIST 315 /* creator of image */ #define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ #define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ #define PREDICTOR_NONE 1 /* no prediction scheme used */ #define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ #define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ #define TIFFTAG_WHITEPOINT 318 /* image white point */ #define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ #define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ #define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ #define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ #define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ #define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ #define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ #define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ #define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ #define CLEANFAXDATA_CLEAN 0 /* no errors detected */ #define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ #define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ #define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ #define TIFFTAG_SUBIFD 330 /* subimage descriptors */ #define TIFFTAG_INKSET 332 /* !inks in separated image */ #define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ #define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ #define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ #define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ #define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ #define TIFFTAG_TARGETPRINTER 337 /* !separation target */ #define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ #define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ #define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ #define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ #define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ #define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ #define SAMPLEFORMAT_INT 2 /* !signed integer data */ #define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ #define SAMPLEFORMAT_VOID 4 /* !untyped data */ #define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ #define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ #define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ #define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ #define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */ #define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ /* Tags 400-435 are from the TIFF/FX spec */ #define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ #define TIFFTAG_PROFILETYPE 401 /* ! */ #define PROFILETYPE_UNSPECIFIED 0 /* ! */ #define PROFILETYPE_G3_FAX 1 /* ! */ #define TIFFTAG_FAXPROFILE 402 /* ! */ #define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ #define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ #define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ #define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ #define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ #define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ #define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ #define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ #define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ #define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ #define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ #define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ #define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ #define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ #define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ #define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ #define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ #define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. */ #define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ #define JPEGPROC_BASELINE 1 /* !baseline sequential */ #define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ #define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ #define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ #define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ #define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ #define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ #define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ #define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ #define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ #define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ #define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ #define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ #define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ #define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */ /* tags 32952-32956 are private tags registered to Island Graphics */ #define TIFFTAG_REFPTS 32953 /* image reference points */ #define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ #define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ #define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ #define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ #define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ #define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ #define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ #define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ #define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ /* Tags 33302-33306 are used to identify special image modes and data * used by Pixar's texture formats. */ #define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ #define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ #define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ #define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 /* tag 33405 is a private tag registered to Eastman Kodak */ #define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ #define TIFFTAG_COPYRIGHT 33432 /* copyright string */ /* IPTC TAG from RichTIFF specifications */ #define TIFFTAG_RICHTIFFIPTC 33723 /* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ #define TIFFTAG_STONITS 37439 /* Sample value to Nits */ /* tag 34929 is a private tag registered to FedEx */ #define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ #define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ /* Adobe Digital Negative (DNG) format tags */ #define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ #define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ #define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ #define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name */ #define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */ #define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ #define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ #define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */ #define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ #define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */ #define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */ #define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */ #define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ #define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */ #define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */ #define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */ #define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */ #define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ #define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ #define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */ #define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */ #define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/ #define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */ #define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */ #define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */ #define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ #define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */ #define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of the green pixels in the blue/green rows track the values of the green pixels in the red/green rows */ #define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ #define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ #define TIFFTAG_LENSINFO 50736 /* info about the lens */ #define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ #define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */ #define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ #define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ #define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */ #define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ #define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ #define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ #define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */ #define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file */ #define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */ #define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */ #define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */ #define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ #define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */ #define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ #define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ /* tag 65535 is an undefined tag used by Eastman Kodak */ #define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ /* * The following are ``pseudo tags'' that can be used to control * codec-specific functionality. These tags are not written to file. * Note that these values start at 0xffff+1 so that they'll never * collide with Aldus-assigned tags. * * If you want your private pseudo tags ``registered'' (i.e. added to * this file), please post a bug report via the tracking system at * http://www.remotesensing.org/libtiff/bugs.html with the appropriate * C definitions to add. */ #define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ #define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ #define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ #define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ #define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ #define FAXMODE_WORDALIGN 0x0008 /* word align row */ #define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ #define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ #define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ #define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ #define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ #define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ #define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ #define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ #define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ #define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ #define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ #define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ #define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ #define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ #define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ #define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ /* 65550-65556 are allocated to Oceana Matrix */ #define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ #define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ #define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ #define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ #define DCSIMAGERFILTER_IR 0 /* infrared filter */ #define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ #define DCSIMAGERFILTER_CFA 2 /* color filter array */ #define DCSIMAGERFILTER_OTHER 3 /* other filter */ #define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ #define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ #define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ #define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ #define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ #define TIFFTAG_DCSGAMMA 65554 /* gamma value */ #define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ #define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ /* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ #define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ #define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ /* 65559 is allocated to Oceana Matrix */ #define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ #define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ #define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ #define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ #define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ #define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ #define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ #define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ #define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ #define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ #define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ #define PERSAMPLE_MERGED 0 /* present as a single value */ #define PERSAMPLE_MULTI 1 /* present as multiple values */ /* * EXIF tags */ #define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ #define EXIFTAG_FNUMBER 33437 /* F number */ #define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ #define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ #define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ #define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ #define EXIFTAG_EXIFVERSION 36864 /* Exif version */ #define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ #define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */ #define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ #define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ #define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ #define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ #define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ #define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ #define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ #define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ #define EXIFTAG_METERINGMODE 37383 /* Metering mode */ #define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ #define EXIFTAG_FLASH 37385 /* Flash */ #define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ #define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ #define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ #define EXIFTAG_USERCOMMENT 37510 /* User comments */ #define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ #define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ #define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ #define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ #define EXIFTAG_COLORSPACE 40961 /* Color space information */ #define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ #define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ #define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ #define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ #define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ #define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ #define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ #define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ #define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ #define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ #define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ #define EXIFTAG_FILESOURCE 41728 /* File source */ #define EXIFTAG_SCENETYPE 41729 /* Scene type */ #define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ #define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ #define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ #define EXIFTAG_WHITEBALANCE 41987 /* White balance */ #define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ #define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ #define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_CONTRAST 41992 /* Contrast */ #define EXIFTAG_SATURATION 41993 /* Saturation */ #define EXIFTAG_SHARPNESS 41994 /* Sharpness */ #define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ #define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/win32/tiffconf.h ================================================ /* Configuration defines for installed libtiff. This file maintained for backward compatibility. Do not use definitions from this file in your programs. */ #ifndef _TIFFCONF_ #define _TIFFCONF_ /* Define to 1 if the system has the type `int16'. */ /* #undef HAVE_INT16 */ /* Define to 1 if the system has the type `int32'. */ /* #undef HAVE_INT32 */ /* Define to 1 if the system has the type `int8'. */ /* #undef HAVE_INT8 */ /* The size of a `int', as computed by sizeof. */ #define SIZEOF_INT 4 /* Signed 8-bit type */ #define TIFF_INT8_T signed char /* Unsigned 8-bit type */ #define TIFF_UINT8_T unsigned char /* Signed 16-bit type */ #define TIFF_INT16_T signed short /* Unsigned 16-bit type */ #define TIFF_UINT16_T unsigned short /* Signed 32-bit type formatter */ #define TIFF_INT32_FORMAT "%d" /* Signed 32-bit type */ #define TIFF_INT32_T signed int /* Unsigned 32-bit type formatter */ #define TIFF_UINT32_FORMAT "%u" /* Unsigned 32-bit type */ #define TIFF_UINT32_T unsigned int /* Signed 64-bit type formatter */ #define TIFF_INT64_FORMAT "%I64d" /* Signed 64-bit type */ #define TIFF_INT64_T signed __int64 /* Unsigned 64-bit type formatter */ #define TIFF_UINT64_FORMAT "%I64u" /* Unsigned 64-bit type */ #define TIFF_UINT64_T unsigned __int64 /* Signed size type */ #if defined(_WIN64) #define TIFF_SSIZE_T signed __int64 #else #define TIFF_SSIZE_T signed int #endif /* Signed size type formatter */ #if defined(_WIN64) #define TIFF_SSIZE_FORMAT "%I64d" #else #define TIFF_SSIZE_FORMAT "%ld" #endif /* Pointer difference type */ #define TIFF_PTRDIFF_T long /* Compatibility stuff. */ /* Define as 0 or 1 according to the floating point format suported by the machine */ #define HAVE_IEEEFP 1 /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ #define HOST_FILLORDER FILLORDER_LSB2MSB /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ #define HOST_BIGENDIAN 0 /* Support CCITT Group 3 & 4 algorithms */ #define CCITT_SUPPORT 1 /* Support JPEG compression (requires IJG JPEG library) */ /* #undef JPEG_SUPPORT */ /* Support JBIG compression (requires JBIG-KIT library) */ /* #undef JBIG_SUPPORT */ /* Support LogLuv high dynamic range encoding */ #define LOGLUV_SUPPORT 1 /* Support LZW algorithm */ #define LZW_SUPPORT 1 /* Support NeXT 2-bit RLE algorithm */ #define NEXT_SUPPORT 1 /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation fails with unpatched IJG JPEG library) */ /* #undef OJPEG_SUPPORT */ /* Support Macintosh PackBits algorithm */ #define PACKBITS_SUPPORT 1 /* Support Pixar log-format algorithm (requires Zlib) */ /* #undef PIXARLOG_SUPPORT */ /* Support ThunderScan 4-bit RLE algorithm */ #define THUNDER_SUPPORT 1 /* Support Deflate compression */ /* #undef ZIP_SUPPORT */ /* Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage) */ #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* Enable SubIFD tag (330) support */ #define SUBIFD_SUPPORT 1 /* Treat extra sample as alpha (default enabled). The RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly. */ #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 /* Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled). */ #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 /* Support MS MDI magic number files as TIFF */ /* #undef MDI_SUPPORT */ /* * Feature support definitions. * XXX: These macros are obsoleted. Don't use them in your apps! * Macros stays here for backward compatibility and should be always defined. */ #define COLORIMETRY_SUPPORT #define YCBCR_SUPPORT #define CMYK_SUPPORT #define ICC_SUPPORT #define PHOTOSHOP_SUPPORT #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/win32/tiffio.h ================================================ /* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIO_ #define _TIFFIO_ /* * TIFF I/O Library Definitions. */ #include "tiff.h" #include "tiffvers.h" /* * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ typedef struct tiff TIFF; /* * The following typedefs define the intrinsic size of * data types used in the *exported* interfaces. These * definitions depend on the proper definition of types * in tiff.h. Note also that the varargs interface used * to pass tag types and values uses the types defined in * tiff.h directly. * * NB: ttag_t is unsigned int and not unsigned short because * ANSI C requires that the type before the ellipsis be a * promoted type (i.e. one of int, unsigned int, pointer, * or double) and because we defined pseudo-tags that are * outside the range of legal Aldus-assigned tags. * NB: tsize_t is int32 and not uint32 because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at * 32-bit file offsets, and BigTIFF maxes out at 64-bit * offsets being the most important, and to ensure use of * a consistently unsigned type across architectures. * Prior to libtiff 4.0, this was an unsigned 32 bit type. */ /* * this is the machine addressing size type, only it's signed, so make it * int32 on 32bit machines, int64 on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; typedef uint64 toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ typedef uint32 ttag_t; /* directory tag */ typedef uint16 tdir_t; /* directory index */ typedef uint16 tsample_t; /* sample number */ typedef uint32 tstrile_t; /* strip or tile number */ typedef tstrile_t tstrip_t; /* strip number */ typedef tstrile_t ttile_t; /* tile number */ typedef tmsize_t tsize_t; /* i/o size in bytes */ typedef void* tdata_t; /* image data ref */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ #endif /* * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). * * By default tif_unix.c is assumed. */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) # define AVOID_WIN32_FILEIO # endif #endif #if defined(USE_WIN32_FILEIO) # define VC_EXTRALEAN # include # ifdef __WIN32__ DECLARE_HANDLE(thandle_t); /* Win32 file handle */ # else typedef HFILE thandle_t; /* client data handle */ # endif /* __WIN32__ */ #else typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ /* * Colour conversion stuff */ /* reference white */ #define D65_X0 (95.0470F) #define D65_Y0 (100.0F) #define D65_Z0 (108.8827F) #define D50_X0 (96.4250F) #define D50_Y0 (100.0F) #define D50_Z0 (82.4680F) /* Structure for holding information about a display device. */ typedef unsigned char TIFFRGBValue; /* 8-bit samples */ typedef struct { float d_mat[3][3]; /* XYZ -> luminance matrix */ float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; uint32 d_Vrwr; /* Pixel values for ref. white */ uint32 d_Vrwg; uint32 d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; float d_gammaR; /* Gamma values for the three guns */ float d_gammaG; float d_gammaB; } TIFFDisplay; typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; int32* Cr_g_tab; int32* Cb_g_tab; int32* Y_tab; } TIFFYCbCrToRGB; typedef struct { /* CIE Lab 1976->RGB support */ int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 float rstep, gstep, bstep; float X0, Y0, Z0; /* Reference white point */ TIFFDisplay display; float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* * RGBA-style image support. */ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*); typedef void (*tileSeparateRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ struct _TIFFRGBAImage { TIFF* tif; /* image handle */ int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ uint32 width; /* image width */ uint32 height; /* image height */ uint16 bitspersample; /* image bits/sample */ uint16 samplesperpixel; /* image samples/pixel */ uint16 orientation; /* image orientation */ uint16 req_orientation; /* requested orientation */ uint16 photometric; /* image photometric interp */ uint16* redcmap; /* colormap pallete */ uint16* greencmap; uint16* bluecmap; /* get image data routine */ int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); /* put decoded strip/tile */ union { void (*any)(TIFFRGBAImage*); tileContigRoutine contig; tileSeparateRoutine separate; } put; TIFFRGBValue* Map; /* sample mapping array */ uint32** BWmap; /* black&white map */ uint32** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */ uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ int row_offset; int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ #define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) /* * A CODEC is a software package that implements decoding, * encoding, or decoding+encoding of a compression algorithm. * The library provides a collection of builtin codecs. * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; uint16 scheme; TIFFInitMethod init; } TIFFCodec; #include #include /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC #define LOGLUV_PUBLIC 1 #endif #if !defined(__GNUC__) && !defined(__attribute__) # define __attribute__(x) /*nothing*/ #endif #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); extern const TIFFCodec* TIFFFindCODEC(uint16); extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); extern int TIFFIsCODECConfigured(uint16); extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* * Auxiliary functions. */ extern void* _TIFFmalloc(tmsize_t s); extern void* _TIFFrealloc(void* p, tmsize_t s); extern void _TIFFmemset(void* p, int v, tmsize_t c); extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); extern void _TIFFfree(void* p); /* ** Stuff, related to tag handling and creating custom tags. */ extern int TIFFGetTagListCount( TIFF * ); extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ #define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ #define FIELD_CUSTOM 65 typedef struct _TIFFField TIFFField; typedef struct _TIFFFieldArray TIFFFieldArray; extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); extern uint32 TIFFFieldTag(const TIFFField*); extern const char* TIFFFieldName(const TIFFField*); extern TIFFDataType TIFFFieldDataType(const TIFFField*); extern int TIFFFieldPassCount(const TIFFField*); extern int TIFFFieldReadCount(const TIFFField*); extern int TIFFFieldWriteCount(const TIFFField*); typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef struct { TIFFVSetMethod vsetfield; /* tag set routine */ TIFFVGetMethod vgetfield; /* tag get routine */ TIFFPrintMethod printdir; /* directory print routine */ } TIFFTagMethods; extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); extern void *TIFFGetClientInfo(TIFF *, const char *); extern void TIFFSetClientInfo(TIFF *, void *, const char *); extern void TIFFCleanup(TIFF* tif); extern void TIFFClose(TIFF* tif); extern int TIFFFlush(TIFF* tif); extern int TIFFFlushData(TIFF* tif); extern int TIFFGetField(TIFF* tif, uint32 tag, ...); extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); extern int TIFFReadDirectory(TIFF* tif); extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); extern uint64 TIFFScanlineSize64(TIFF* tif); extern tmsize_t TIFFScanlineSize(TIFF* tif); extern uint64 TIFFRasterScanlineSize64(TIFF* tif); extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); extern uint64 TIFFStripSize64(TIFF* tif); extern tmsize_t TIFFStripSize(TIFF* tif); extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); extern uint64 TIFFTileRowSize64(TIFF* tif); extern tmsize_t TIFFTileRowSize(TIFF* tif); extern uint64 TIFFTileSize64(TIFF* tif); extern tmsize_t TIFFTileSize(TIFF* tif); extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); extern int TIFFFileno(TIFF*); extern int TIFFSetFileno(TIFF*, int); extern thandle_t TIFFClientdata(TIFF*); extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); extern int TIFFGetMode(TIFF*); extern int TIFFSetMode(TIFF*, int); extern int TIFFIsTiled(TIFF*); extern int TIFFIsByteSwapped(TIFF*); extern int TIFFIsUpSampled(TIFF*); extern int TIFFIsMSB2LSB(TIFF*); extern int TIFFIsBigEndian(TIFF*); extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); extern TIFFSeekProc TIFFGetSeekProc(TIFF*); extern TIFFCloseProc TIFFGetCloseProc(TIFF*); extern TIFFSizeProc TIFFGetSizeProc(TIFF*); extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); extern uint32 TIFFCurrentRow(TIFF*); extern uint16 TIFFCurrentDirectory(TIFF*); extern uint16 TIFFNumberOfDirectories(TIFF*); extern uint64 TIFFCurrentDirOffset(TIFF*); extern uint32 TIFFCurrentStrip(TIFF*); extern uint32 TIFFCurrentTile(TIFF* tif); extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFSetupStrips(TIFF *); extern int TIFFWriteCheck(TIFF*, int, const char *); extern void TIFFFreeDirectory(TIFF*); extern int TIFFCreateDirectory(TIFF*); extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); extern int TIFFSetDirectory(TIFF*, uint16); extern int TIFFSetSubDirectory(TIFF*, uint64); extern int TIFFUnlinkDirectory(TIFF*, uint16); extern int TIFFSetField(TIFF*, uint32, ...); extern int TIFFVSetField(TIFF*, uint32, va_list); extern int TIFFUnsetField(TIFF*, uint32); extern int TIFFWriteDirectory(TIFF *); extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int = ORIENTATION_BOTLEFT, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); #endif extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); # ifdef __WIN32__ extern TIFF* TIFFOpenW(const wchar_t*, const char*); # endif /* __WIN32__ */ extern TIFF* TIFFFdOpen(int, const char*, const char*); extern TIFF* TIFFClientOpen(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); extern const char* TIFFFileName(TIFF*); extern const char* TIFFSetFileName(TIFF*, const char *); extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFNumberOfTiles(TIFF*); extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); extern uint32 TIFFNumberOfStrips(TIFF*); extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); extern void TIFFSwabShort(uint16*); extern void TIFFSwabLong(uint32*); extern void TIFFSwabLong8(uint64*); extern void TIFFSwabFloat(float*); extern void TIFFSwabDouble(double*); extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); extern void TIFFReverseBits(uint8* cp, tmsize_t n); extern const unsigned char* TIFFGetBitRevTable(int); #ifdef LOGLUV_PUBLIC #define U_NEU 0.210526316 #define V_NEU 0.473684211 #define UVSCALE 410. extern double LogL16toY(int); extern double LogL10toY(int); extern void XYZtoRGB24(float*, uint8*); extern int uv_decode(double*, double*, int); extern void LogLuv24toXYZ(uint32, float*); extern void LogLuv32toXYZ(uint32, float*); #if defined(c_plusplus) || defined(__cplusplus) extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); #else extern int LogL16fromY(double, int); extern int LogL10fromY(double, int); extern int uv_encode(double, double, int); extern uint32 LogLuv24fromXYZ(float*, int); extern uint32 LogLuv32fromXYZ(float*, int); #endif #endif /* LOGLUV_PUBLIC */ extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, float *, float *, float *); extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32 *, uint32 *, uint32 *); extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, uint32 *, uint32 *, uint32 *); /**************************************************************************** * O B S O L E T E D I N T E R F A C E S * * Don't use this stuff in your applications, it may be removed in the future * libtiff versions. ****************************************************************************/ typedef struct { ttag_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ short field_writecount; /* write count/TIFF_VARIABLE */ TIFFDataType field_type; /* type of associated data */ unsigned short field_bit; /* bit in fieldsset bit vector */ unsigned char field_oktochange; /* if true, can change while writing */ unsigned char field_passcount; /* if true, pass dir count on set */ char *field_name; /* ASCII name */ } TIFFFieldInfo; extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); #if defined(c_plusplus) || defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ ================================================ FILE: cocos2d/external/tiff/include/win32/tiffvers.h ================================================ #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a * version or versions of the library. Runtime * version checking should be done based on the * string returned by TIFFGetVersion. */ #define TIFFLIB_VERSION 20120922 ================================================ FILE: cocos2d/external/tiff/prebuilt/android/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos_tiff_static LOCAL_MODULE_FILENAME := tiff LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libtiff.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android include $(PREBUILT_STATIC_LIBRARY) ================================================ FILE: cocos2d/external/tinyxml2/CMakeLists.txt ================================================ set(TINYXML2_SRC tinyxml2.cpp ) add_library(tinyxml2 STATIC ${TINYXML2_SRC} ) set_target_properties(tinyxml2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/external/tinyxml2/tinyxml2.cpp ================================================ /* Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "tinyxml2.h" #include // yes, this one new style header, is in the Android SDK. # if defined(ANDROID_NDK) || (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY) # include #else # include #endif static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF static const char LF = LINE_FEED; static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out static const char CR = CARRIAGE_RETURN; static const char SINGLE_QUOTE = '\''; static const char DOUBLE_QUOTE = '\"'; // Bunch of unicode info at: // http://www.unicode.org/faq/utf_bom.html // ef bb bf (Microsoft "lead bytes") - designates UTF-8 static const unsigned char TIXML_UTF_LEAD_0 = 0xefU; static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; #define DELETE_NODE( node ) { \ if ( node ) { \ MemPool* pool = node->_memPool; \ node->~XMLNode(); \ pool->Free( node ); \ } \ } #define DELETE_ATTRIBUTE( attrib ) { \ if ( attrib ) { \ MemPool* pool = attrib->_memPool; \ attrib->~XMLAttribute(); \ pool->Free( attrib ); \ } \ } namespace tinyxml2 { struct Entity { const char* pattern; int length; char value; }; static const int NUM_ENTITIES = 5; static const Entity entities[NUM_ENTITIES] = { { "quot", 4, DOUBLE_QUOTE }, { "amp", 3, '&' }, { "apos", 4, SINGLE_QUOTE }, { "lt", 2, '<' }, { "gt", 2, '>' } }; StrPair::~StrPair() { Reset(); } void StrPair::Reset() { if ( _flags & NEEDS_DELETE ) { delete [] _start; } _flags = 0; _start = 0; _end = 0; } void StrPair::SetStr( const char* str, int flags ) { Reset(); size_t len = strlen( str ); _start = new char[ len+1 ]; memcpy( _start, str, len+1 ); _end = _start + len; _flags = flags | NEEDS_DELETE; } char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) { TIXMLASSERT( endTag && *endTag ); char* start = p; // fixme: hides a member char endChar = *endTag; size_t length = strlen( endTag ); // Inner loop of text parsing. while ( *p ) { if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) { Set( start, p, strFlags ); return p + length; } ++p; } return 0; } char* StrPair::ParseName( char* p ) { char* start = p; if ( !start || !(*start) ) { return 0; } while( *p && ( XMLUtil::IsAlphaNum( (unsigned char) *p ) || *p == '_' || *p == ':' || (*p == '-' && p>start ) // can be in a name, but not lead it. || (*p == '.' && p>start ) )) { // can be in a name, but not lead it. ++p; } if ( p > start ) { Set( start, p, 0 ); return p; } return 0; } void StrPair::CollapseWhitespace() { // Trim leading space. _start = XMLUtil::SkipWhiteSpace( _start ); if ( _start && *_start ) { char* p = _start; // the read pointer char* q = _start; // the write pointer while( *p ) { if ( XMLUtil::IsWhiteSpace( *p )) { p = XMLUtil::SkipWhiteSpace( p ); if ( *p == 0 ) { break; // don't write to q; this trims the trailing space. } *q = ' '; ++q; } *q = *p; ++q; ++p; } *q = 0; } } const char* StrPair::GetStr() { if ( _flags & NEEDS_FLUSH ) { *_end = 0; _flags ^= NEEDS_FLUSH; if ( _flags ) { char* p = _start; // the read pointer char* q = _start; // the write pointer while( p < _end ) { if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) { // CR-LF pair becomes LF // CR alone becomes LF // LF-CR becomes LF if ( *(p+1) == LF ) { p += 2; } else { ++p; } *q++ = LF; } else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) { if ( *(p+1) == CR ) { p += 2; } else { ++p; } *q++ = LF; } else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) { // Entities handled by tinyXML2: // - special entities in the entity table [in/out] // - numeric character reference [in] // 中 or 中 if ( *(p+1) == '#' ) { char buf[10] = { 0 }; int len; p = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); for( int i=0; i(p); // Check for BOM: if ( *(pu+0) == TIXML_UTF_LEAD_0 && *(pu+1) == TIXML_UTF_LEAD_1 && *(pu+2) == TIXML_UTF_LEAD_2 ) { *bom = true; p += 3; } return p; } void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) { const unsigned long BYTE_MASK = 0xBF; const unsigned long BYTE_MARK = 0x80; const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; if (input < 0x80) { *length = 1; } else if ( input < 0x800 ) { *length = 2; } else if ( input < 0x10000 ) { *length = 3; } else if ( input < 0x200000 ) { *length = 4; } else { *length = 0; // This code won't covert this correctly anyway. return; } output += *length; // Scary scary fall throughs. switch (*length) { case 4: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 3: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 2: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 1: --output; *output = (char)(input | FIRST_BYTE_MARK[*length]); default: break; } } const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) { // Presume an entity, and pull it out. *length = 0; if ( *(p+1) == '#' && *(p+2) ) { unsigned long ucs = 0; ptrdiff_t delta = 0; unsigned mult = 1; if ( *(p+2) == 'x' ) { // Hexadecimal. if ( !*(p+3) ) { return 0; } const char* q = p+3; q = strchr( q, ';' ); if ( !q || !*q ) { return 0; } delta = q-p; --q; while ( *q != 'x' ) { if ( *q >= '0' && *q <= '9' ) { ucs += mult * (*q - '0'); } else if ( *q >= 'a' && *q <= 'f' ) { ucs += mult * (*q - 'a' + 10); } else if ( *q >= 'A' && *q <= 'F' ) { ucs += mult * (*q - 'A' + 10 ); } else { return 0; } mult *= 16; --q; } } else { // Decimal. if ( !*(p+2) ) { return 0; } const char* q = p+2; q = strchr( q, ';' ); if ( !q || !*q ) { return 0; } delta = q-p; --q; while ( *q != '#' ) { if ( *q >= '0' && *q <= '9' ) { ucs += mult * (*q - '0'); } else { return 0; } mult *= 10; --q; } } // convert the UCS to UTF-8 ConvertUTF32ToUTF8( ucs, value, length ); return p + delta + 1; } return p+1; } void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%d", v ); } void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%u", v ); } void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 ); } void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%g", v ); } void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) { TIXML_SNPRINTF( buffer, bufferSize, "%g", v ); } bool XMLUtil::ToInt( const char* str, int* value ) { if ( TIXML_SSCANF( str, "%d", value ) == 1 ) { return true; } return false; } bool XMLUtil::ToUnsigned( const char* str, unsigned *value ) { if ( TIXML_SSCANF( str, "%u", value ) == 1 ) { return true; } return false; } bool XMLUtil::ToBool( const char* str, bool* value ) { int ival = 0; if ( ToInt( str, &ival )) { *value = (ival==0) ? false : true; return true; } if ( StringEqual( str, "true" ) ) { *value = true; return true; } else if ( StringEqual( str, "false" ) ) { *value = false; return true; } return false; } bool XMLUtil::ToFloat( const char* str, float* value ) { if ( TIXML_SSCANF( str, "%f", value ) == 1 ) { return true; } return false; } bool XMLUtil::ToDouble( const char* str, double* value ) { if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) { return true; } return false; } char* XMLDocument::Identify( char* p, XMLNode** node ) { XMLNode* returnNode = 0; char* start = p; p = XMLUtil::SkipWhiteSpace( p ); if( !p || !*p ) { return p; } // What is this thing? // - Elements start with a letter or underscore, but xml is reserved. // - Comments: // // With a special case: // // // // // Where the closing element (/foo) *must* be the next thing after the opening // element, and the names must match. BUT the tricky bit is that the closing // element will be read by the child. // // 'endTag' is the end tag for this node, it is returned by a call to a child. // 'parentEnd' is the end tag for the parent, which is filled in and returned. while( p && *p ) { XMLNode* node = 0; p = _document->Identify( p, &node ); if ( p == 0 || node == 0 ) { break; } StrPair endTag; p = node->ParseDeep( p, &endTag ); if ( !p ) { DELETE_NODE( node ); node = 0; if ( !_document->Error() ) { _document->SetError( XML_ERROR_PARSING, 0, 0 ); } break; } // We read the end tag. Return it to the parent. if ( node->ToElement() && node->ToElement()->ClosingType() == XMLElement::CLOSING ) { if ( parentEnd ) { *parentEnd = static_cast(node)->_value; } node->_memPool->SetTracked(); // created and then immediately deleted. DELETE_NODE( node ); return p; } // Handle an end tag returned to this level. // And handle a bunch of annoying errors. XMLElement* ele = node->ToElement(); if ( ele ) { if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) { _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); p = 0; } else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) { _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); p = 0; } else if ( !endTag.Empty() ) { if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) { _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); p = 0; } } } if ( p == 0 ) { DELETE_NODE( node ); node = 0; } if ( node ) { this->InsertEndChild( node ); } } return 0; } // --------- XMLText ---------- // char* XMLText::ParseDeep( char* p, StrPair* ) { const char* start = p; if ( this->CData() ) { p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); if ( !p ) { _document->SetError( XML_ERROR_PARSING_CDATA, start, 0 ); } return p; } else { int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES; if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) { flags |= StrPair::COLLAPSE_WHITESPACE; } p = _value.ParseText( p, "<", flags ); if ( !p ) { _document->SetError( XML_ERROR_PARSING_TEXT, start, 0 ); } if ( p && *p ) { return p-1; } } return 0; } XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const { if ( !doc ) { doc = _document; } XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern? text->SetCData( this->CData() ); return text; } bool XMLText::ShallowEqual( const XMLNode* compare ) const { return ( compare->ToText() && XMLUtil::StringEqual( compare->ToText()->Value(), Value() )); } bool XMLText::Accept( XMLVisitor* visitor ) const { return visitor->Visit( *this ); } // --------- XMLComment ---------- // XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc ) { } XMLComment::~XMLComment() { } char* XMLComment::ParseDeep( char* p, StrPair* ) { // Comment parses as text. const char* start = p; p = _value.ParseText( p, "-->", StrPair::COMMENT ); if ( p == 0 ) { _document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 ); } return p; } XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const { if ( !doc ) { doc = _document; } XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern? return comment; } bool XMLComment::ShallowEqual( const XMLNode* compare ) const { return ( compare->ToComment() && XMLUtil::StringEqual( compare->ToComment()->Value(), Value() )); } bool XMLComment::Accept( XMLVisitor* visitor ) const { return visitor->Visit( *this ); } // --------- XMLDeclaration ---------- // XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc ) { } XMLDeclaration::~XMLDeclaration() { //printf( "~XMLDeclaration\n" ); } char* XMLDeclaration::ParseDeep( char* p, StrPair* ) { // Declaration parses as text. const char* start = p; p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); if ( p == 0 ) { _document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 ); } return p; } XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const { if ( !doc ) { doc = _document; } XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern? return dec; } bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const { return ( compare->ToDeclaration() && XMLUtil::StringEqual( compare->ToDeclaration()->Value(), Value() )); } bool XMLDeclaration::Accept( XMLVisitor* visitor ) const { return visitor->Visit( *this ); } // --------- XMLUnknown ---------- // XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc ) { } XMLUnknown::~XMLUnknown() { } char* XMLUnknown::ParseDeep( char* p, StrPair* ) { // Unknown parses as text. const char* start = p; p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION ); if ( !p ) { _document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 ); } return p; } XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const { if ( !doc ) { doc = _document; } XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern? return text; } bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const { return ( compare->ToUnknown() && XMLUtil::StringEqual( compare->ToUnknown()->Value(), Value() )); } bool XMLUnknown::Accept( XMLVisitor* visitor ) const { return visitor->Visit( *this ); } // --------- XMLAttribute ---------- // char* XMLAttribute::ParseDeep( char* p, bool processEntities ) { // Parse using the name rules: bug fix, was using ParseText before p = _name.ParseName( p ); if ( !p || !*p ) { return 0; } // Skip white space before = p = XMLUtil::SkipWhiteSpace( p ); if ( !p || *p != '=' ) { return 0; } ++p; // move up to opening quote p = XMLUtil::SkipWhiteSpace( p ); if ( *p != '\"' && *p != '\'' ) { return 0; } char endTag[2] = { *p, 0 }; ++p; // move past opening quote p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES ); return p; } void XMLAttribute::SetName( const char* n ) { _name.SetStr( n ); } XMLError XMLAttribute::QueryIntValue( int* value ) const { if ( XMLUtil::ToInt( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const { if ( XMLUtil::ToUnsigned( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } XMLError XMLAttribute::QueryBoolValue( bool* value ) const { if ( XMLUtil::ToBool( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } XMLError XMLAttribute::QueryFloatValue( float* value ) const { if ( XMLUtil::ToFloat( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } XMLError XMLAttribute::QueryDoubleValue( double* value ) const { if ( XMLUtil::ToDouble( Value(), value )) { return XML_NO_ERROR; } return XML_WRONG_ATTRIBUTE_TYPE; } void XMLAttribute::SetAttribute( const char* v ) { _value.SetStr( v ); } void XMLAttribute::SetAttribute( int v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } void XMLAttribute::SetAttribute( unsigned v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } void XMLAttribute::SetAttribute( bool v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } void XMLAttribute::SetAttribute( double v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } void XMLAttribute::SetAttribute( float v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); _value.SetStr( buf ); } // --------- XMLElement ---------- // XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ), _closingType( 0 ), _rootAttribute( 0 ) { } XMLElement::~XMLElement() { while( _rootAttribute ) { XMLAttribute* next = _rootAttribute->_next; DELETE_ATTRIBUTE( _rootAttribute ); _rootAttribute = next; } } XMLAttribute* XMLElement::FindAttribute( const char* name ) { XMLAttribute* a = 0; for( a=_rootAttribute; a; a = a->_next ) { if ( XMLUtil::StringEqual( a->Name(), name ) ) { return a; } } return 0; } const XMLAttribute* XMLElement::FindAttribute( const char* name ) const { XMLAttribute* a = 0; for( a=_rootAttribute; a; a = a->_next ) { if ( XMLUtil::StringEqual( a->Name(), name ) ) { return a; } } return 0; } const char* XMLElement::Attribute( const char* name, const char* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return 0; } if ( !value || XMLUtil::StringEqual( a->Value(), value )) { return a->Value(); } return 0; } const char* XMLElement::GetText() const { if ( FirstChild() && FirstChild()->ToText() ) { return FirstChild()->ToText()->Value(); } return 0; } XMLError XMLElement::QueryIntText( int* ival ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToInt( t, ival ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToUnsigned( t, uval ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLError XMLElement::QueryBoolText( bool* bval ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToBool( t, bval ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLError XMLElement::QueryDoubleText( double* dval ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToDouble( t, dval ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLError XMLElement::QueryFloatText( float* fval ) const { if ( FirstChild() && FirstChild()->ToText() ) { const char* t = FirstChild()->ToText()->Value(); if ( XMLUtil::ToFloat( t, fval ) ) { return XML_SUCCESS; } return XML_CAN_NOT_CONVERT_TEXT; } return XML_NO_TEXT_NODE; } XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) { XMLAttribute* last = 0; XMLAttribute* attrib = 0; for( attrib = _rootAttribute; attrib; last = attrib, attrib = attrib->_next ) { if ( XMLUtil::StringEqual( attrib->Name(), name ) ) { break; } } if ( !attrib ) { attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); attrib->_memPool = &_document->_attributePool; if ( last ) { last->_next = attrib; } else { _rootAttribute = attrib; } attrib->SetName( name ); attrib->_memPool->SetTracked(); // always created and linked. } return attrib; } void XMLElement::DeleteAttribute( const char* name ) { XMLAttribute* prev = 0; for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) { if ( XMLUtil::StringEqual( name, a->Name() ) ) { if ( prev ) { prev->_next = a->_next; } else { _rootAttribute = a->_next; } DELETE_ATTRIBUTE( a ); break; } prev = a; } } char* XMLElement::ParseAttributes( char* p ) { const char* start = p; XMLAttribute* prevAttribute = 0; // Read the attributes. while( p ) { p = XMLUtil::SkipWhiteSpace( p ); if ( !p || !(*p) ) { _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() ); return 0; } // attribute. if ( XMLUtil::IsAlpha( *p ) ) { XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); attrib->_memPool = &_document->_attributePool; attrib->_memPool->SetTracked(); p = attrib->ParseDeep( p, _document->ProcessEntities() ); if ( !p || Attribute( attrib->Name() ) ) { DELETE_ATTRIBUTE( attrib ); _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p ); return 0; } // There is a minor bug here: if the attribute in the source xml // document is duplicated, it will not be detected and the // attribute will be doubly added. However, tracking the 'prevAttribute' // avoids re-scanning the attribute list. Preferring performance for // now, may reconsider in the future. if ( prevAttribute ) { prevAttribute->_next = attrib; } else { _rootAttribute = attrib; } prevAttribute = attrib; } // end of the tag else if ( *p == '/' && *(p+1) == '>' ) { _closingType = CLOSED; return p+2; // done; sealed element. } // end of the tag else if ( *p == '>' ) { ++p; break; } else { _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p ); return 0; } } return p; } // // // foobar // char* XMLElement::ParseDeep( char* p, StrPair* strPair ) { // Read the element name. p = XMLUtil::SkipWhiteSpace( p ); if ( !p ) { return 0; } // The closing element is the form. It is // parsed just like a regular element then deleted from // the DOM. if ( *p == '/' ) { _closingType = CLOSING; ++p; } p = _value.ParseName( p ); if ( _value.Empty() ) { return 0; } p = ParseAttributes( p ); if ( !p || !*p || _closingType ) { return p; } p = XMLNode::ParseDeep( p, strPair ); return p; } XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const { if ( !doc ) { doc = _document; } XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern? for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) { element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern? } return element; } bool XMLElement::ShallowEqual( const XMLNode* compare ) const { const XMLElement* other = compare->ToElement(); if ( other && XMLUtil::StringEqual( other->Value(), Value() )) { const XMLAttribute* a=FirstAttribute(); const XMLAttribute* b=other->FirstAttribute(); while ( a && b ) { if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) { return false; } a = a->Next(); b = b->Next(); } if ( a || b ) { // different count return false; } return true; } return false; } bool XMLElement::Accept( XMLVisitor* visitor ) const { if ( visitor->VisitEnter( *this, _rootAttribute ) ) { for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { if ( !node->Accept( visitor ) ) { break; } } } return visitor->VisitExit( *this ); } // --------- XMLDocument ----------- // XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) : XMLNode( 0 ), _writeBOM( false ), _processEntities( processEntities ), _errorID( XML_NO_ERROR ), _whitespace( whitespace ), _errorStr1( 0 ), _errorStr2( 0 ), _charBuffer( 0 ) { _document = this; // avoid warning about 'this' in initializer list } XMLDocument::~XMLDocument() { DeleteChildren(); delete [] _charBuffer; #if 0 textPool.Trace( "text" ); elementPool.Trace( "element" ); commentPool.Trace( "comment" ); attributePool.Trace( "attribute" ); #endif #ifdef DEBUG if ( Error() == false ) { TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() ); TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() ); } #endif } void XMLDocument::InitDocument() { _errorID = XML_NO_ERROR; _errorStr1 = 0; _errorStr2 = 0; delete [] _charBuffer; _charBuffer = 0; } XMLElement* XMLDocument::NewElement( const char* name ) { XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this ); ele->_memPool = &_elementPool; ele->SetName( name ); return ele; } XMLComment* XMLDocument::NewComment( const char* str ) { XMLComment* comment = new (_commentPool.Alloc()) XMLComment( this ); comment->_memPool = &_commentPool; comment->SetValue( str ); return comment; } XMLText* XMLDocument::NewText( const char* str ) { XMLText* text = new (_textPool.Alloc()) XMLText( this ); text->_memPool = &_textPool; text->SetValue( str ); return text; } XMLDeclaration* XMLDocument::NewDeclaration( const char* str ) { XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration( this ); dec->_memPool = &_commentPool; dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); return dec; } XMLUnknown* XMLDocument::NewUnknown( const char* str ) { XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this ); unk->_memPool = &_commentPool; unk->SetValue( str ); return unk; } XMLError XMLDocument::LoadFile( const char* filename ) { DeleteChildren(); InitDocument(); FILE* fp = 0; #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) errno_t err = fopen_s(&fp, filename, "rb" ); if ( !fp || err) { #else fp = fopen( filename, "rb" ); if ( !fp) { #endif SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 ); return _errorID; } LoadFile( fp ); fclose( fp ); return _errorID; } XMLError XMLDocument::LoadFile( FILE* fp ) { DeleteChildren(); InitDocument(); fseek( fp, 0, SEEK_END ); size_t size = ftell( fp ); fseek( fp, 0, SEEK_SET ); if ( size == 0 ) { return _errorID; } _charBuffer = new char[size+1]; size_t read = fread( _charBuffer, 1, size, fp ); if ( read != size ) { SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); return _errorID; } _charBuffer[size] = 0; const char* p = _charBuffer; p = XMLUtil::SkipWhiteSpace( p ); p = XMLUtil::ReadBOM( p, &_writeBOM ); if ( !p || !*p ) { SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); return _errorID; } ParseDeep( _charBuffer + (p-_charBuffer), 0 ); return _errorID; } XMLError XMLDocument::SaveFile( const char* filename, bool compact ) { FILE* fp = 0; #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) errno_t err = fopen_s(&fp, filename, "w" ); if ( !fp || err) { #else fp = fopen( filename, "w" ); if ( !fp) { #endif SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 ); return _errorID; } SaveFile(fp, compact); fclose( fp ); return _errorID; } XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) { XMLPrinter stream( fp, compact ); Print( &stream ); return _errorID; } XMLError XMLDocument::Parse( const char* p, size_t len ) { DeleteChildren(); InitDocument(); if ( !p || !*p ) { SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); return _errorID; } if ( len == (size_t)(-1) ) { len = strlen( p ); } _charBuffer = new char[ len+1 ]; memcpy( _charBuffer, p, len ); _charBuffer[len] = 0; p = XMLUtil::SkipWhiteSpace( p ); p = XMLUtil::ReadBOM( p, &_writeBOM ); if ( !p || !*p ) { SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); return _errorID; } ParseDeep( _charBuffer, 0 ); return _errorID; } void XMLDocument::Print( XMLPrinter* streamer ) { XMLPrinter stdStreamer( stdout ); if ( !streamer ) { streamer = &stdStreamer; } Accept( streamer ); } void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 ) { _errorID = error; _errorStr1 = str1; _errorStr2 = str2; } void XMLDocument::PrintError() const { if ( _errorID ) { static const int LEN = 20; char buf1[LEN] = { 0 }; char buf2[LEN] = { 0 }; if ( _errorStr1 ) { TIXML_SNPRINTF( buf1, LEN, "%s", _errorStr1 ); } if ( _errorStr2 ) { TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 ); } printf( "XMLDocument error id=%d str1=%s str2=%s\n", _errorID, buf1, buf2 ); } } XMLPrinter::XMLPrinter( FILE* file, bool compact ) : _elementJustOpened( false ), _firstElement( true ), _fp( file ), _depth( 0 ), _textDepth( -1 ), _processEntities( true ), _compactMode( compact ) { for( int i=0; i'] = true; // not required, but consistency is nice _buffer.Push( 0 ); } void XMLPrinter::Print( const char* format, ... ) { va_list va; va_start( va, format ); if ( _fp ) { vfprintf( _fp, format, va ); } else { // This seems brutally complex. Haven't figured out a better // way on windows. #if defined _MSC_VER && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) int len = -1; int expand = 1000; while ( len < 0 ) { len = vsnprintf_s( _accumulator.Mem(), _accumulator.Capacity(), _TRUNCATE, format, va ); if ( len < 0 ) { expand *= 3/2; _accumulator.PushArr( expand ); } } char* p = _buffer.PushArr( len ) - 1; memcpy( p, _accumulator.Mem(), len+1 ); #else int len = vsnprintf( 0, 0, format, va ); // Close out and re-start the va-args va_end( va ); va_start( va, format ); char* p = _buffer.PushArr( len ) - 1; vsnprintf( p, len+1, format, va ); #endif } va_end( va ); } void XMLPrinter::PrintSpace( int depth ) { for( int i=0; i 0 && *q < ENTITY_RANGE ) { // Check for entities. If one is found, flush // the stream up until the entity, write the // entity, and keep looking. if ( flag[(unsigned)(*q)] ) { while ( p < q ) { Print( "%c", *p ); ++p; } for( int i=0; i 0) ) { Print( "%s", p ); } } void XMLPrinter::PushHeader( bool writeBOM, bool writeDec ) { static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 }; if ( writeBOM ) { Print( "%s", bom ); } if ( writeDec ) { PushDeclaration( "xml version=\"1.0\"" ); } } void XMLPrinter::OpenElement( const char* name ) { if ( _elementJustOpened ) { SealElement(); } _stack.Push( name ); if ( _textDepth < 0 && !_firstElement && !_compactMode ) { Print( "\n" ); PrintSpace( _depth ); } Print( "<%s", name ); _elementJustOpened = true; _firstElement = false; ++_depth; } void XMLPrinter::PushAttribute( const char* name, const char* value ) { TIXMLASSERT( _elementJustOpened ); Print( " %s=\"", name ); PrintString( value, false ); Print( "\"" ); } void XMLPrinter::PushAttribute( const char* name, int v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); PushAttribute( name, buf ); } void XMLPrinter::PushAttribute( const char* name, unsigned v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); PushAttribute( name, buf ); } void XMLPrinter::PushAttribute( const char* name, bool v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); PushAttribute( name, buf ); } void XMLPrinter::PushAttribute( const char* name, double v ) { char buf[BUF_SIZE]; XMLUtil::ToStr( v, buf, BUF_SIZE ); PushAttribute( name, buf ); } void XMLPrinter::CloseElement() { --_depth; const char* name = _stack.Pop(); if ( _elementJustOpened ) { Print( "/>" ); } else { if ( _textDepth < 0 && !_compactMode) { Print( "\n" ); PrintSpace( _depth ); } Print( "", name ); } if ( _textDepth == _depth ) { _textDepth = -1; } if ( _depth == 0 && !_compactMode) { Print( "\n" ); } _elementJustOpened = false; } void XMLPrinter::SealElement() { _elementJustOpened = false; Print( ">" ); } void XMLPrinter::PushText( const char* text, bool cdata ) { _textDepth = _depth-1; if ( _elementJustOpened ) { SealElement(); } if ( cdata ) { Print( "" ); } else { PrintString( text, true ); } } void XMLPrinter::PushText( int value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushText( unsigned value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushText( bool value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushText( float value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushText( double value ) { char buf[BUF_SIZE]; XMLUtil::ToStr( value, buf, BUF_SIZE ); PushText( buf, false ); } void XMLPrinter::PushComment( const char* comment ) { if ( _elementJustOpened ) { SealElement(); } if ( _textDepth < 0 && !_firstElement && !_compactMode) { Print( "\n" ); PrintSpace( _depth ); } _firstElement = false; Print( "", comment ); } void XMLPrinter::PushDeclaration( const char* value ) { if ( _elementJustOpened ) { SealElement(); } if ( _textDepth < 0 && !_firstElement && !_compactMode) { Print( "\n" ); PrintSpace( _depth ); } _firstElement = false; Print( "", value ); } void XMLPrinter::PushUnknown( const char* value ) { if ( _elementJustOpened ) { SealElement(); } if ( _textDepth < 0 && !_firstElement && !_compactMode) { Print( "\n" ); PrintSpace( _depth ); } _firstElement = false; Print( "", value ); } bool XMLPrinter::VisitEnter( const XMLDocument& doc ) { _processEntities = doc.ProcessEntities(); if ( doc.HasBOM() ) { PushHeader( true, false ); } return true; } bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) { OpenElement( element.Name() ); while ( attribute ) { PushAttribute( attribute->Name(), attribute->Value() ); attribute = attribute->Next(); } return true; } bool XMLPrinter::VisitExit( const XMLElement& ) { CloseElement(); return true; } bool XMLPrinter::Visit( const XMLText& text ) { PushText( text.Value(), text.CData() ); return true; } bool XMLPrinter::Visit( const XMLComment& comment ) { PushComment( comment.Value() ); return true; } bool XMLPrinter::Visit( const XMLDeclaration& declaration ) { PushDeclaration( declaration.Value() ); return true; } bool XMLPrinter::Visit( const XMLUnknown& unknown ) { PushUnknown( unknown.Value() ); return true; } } // namespace tinyxml2 ================================================ FILE: cocos2d/external/tinyxml2/tinyxml2.h ================================================ /* Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef TINYXML2_INCLUDED #define TINYXML2_INCLUDED #include "CCPlatformConfig.h" #include "CCPlatformMacros.h" #if defined(ANDROID_NDK) || defined(__BORLANDC__) || (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY) # include # include # include # include # include # include #else # include # include # include # include # include # include #endif /* TODO: intern strings instead of allocation. */ /* gcc: g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe Formatting, Artistic Style: AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h */ #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) # ifndef DEBUG # define DEBUG # endif #endif #if defined(DEBUG) # if defined(_MSC_VER) # define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak() # elif defined (ANDROID_NDK) # include # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } # else # include # define TIXMLASSERT assert # endif # else # define TIXMLASSERT( x ) {} #endif #if (defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)) // Microsoft visual studio, version 2005 and higher. /*int _snprintf_s( char *buffer, size_t sizeOfBuffer, size_t count, const char *format [, argument] ... );*/ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) { va_list va; va_start( va, format ); int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); va_end( va ); return result; } #define TIXML_SSCANF sscanf_s #else // GCC version 3 and higher //#warning( "Using sn* functions." ) #define TIXML_SNPRINTF snprintf #define TIXML_SSCANF sscanf #endif static const int TIXML2_MAJOR_VERSION = 1; static const int TIXML2_MINOR_VERSION = 0; static const int TIXML2_PATCH_VERSION = 9; namespace tinyxml2 { class XMLDocument; class XMLElement; class XMLAttribute; class XMLComment; class XMLNode; class XMLText; class XMLDeclaration; class XMLUnknown; class XMLPrinter; /* A class that wraps strings. Normally stores the start and end pointers into the XML file itself, and will apply normalization and entity translation if actually read. Can also store (and memory manage) a traditional char[] */ class CC_DLL StrPair { public: enum { NEEDS_ENTITY_PROCESSING = 0x01, NEEDS_NEWLINE_NORMALIZATION = 0x02, COLLAPSE_WHITESPACE = 0x04, TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, ATTRIBUTE_NAME = 0, ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, COMMENT = NEEDS_NEWLINE_NORMALIZATION }; StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} ~StrPair(); void Set( char* start, char* end, int flags ) { Reset(); _start = start; _end = end; _flags = flags | NEEDS_FLUSH; } const char* GetStr(); bool Empty() const { return _start == _end; } void SetInternedStr( const char* str ) { Reset(); _start = const_cast(str); } void SetStr( const char* str, int flags=0 ); char* ParseText( char* in, const char* endTag, int strFlags ); char* ParseName( char* in ); private: void Reset(); void CollapseWhitespace(); enum { NEEDS_FLUSH = 0x100, NEEDS_DELETE = 0x200 }; // After parsing, if *end != 0, it can be set to zero. int _flags; char* _start; char* _end; }; /* A dynamic array of Plain Old Data. Doesn't support constructors, etc. Has a small initial memory pool, so that low or no usage will not cause a call to new/delete */ template class CC_DLL DynArray { public: DynArray< T, INIT >() { _mem = _pool; _allocated = INIT; _size = 0; } ~DynArray() { if ( _mem != _pool ) { delete [] _mem; } } void Push( T t ) { EnsureCapacity( _size+1 ); _mem[_size++] = t; } T* PushArr( int count ) { EnsureCapacity( _size+count ); T* ret = &_mem[_size]; _size += count; return ret; } T Pop() { return _mem[--_size]; } void PopArr( int count ) { TIXMLASSERT( _size >= count ); _size -= count; } bool Empty() const { return _size == 0; } T& operator[](int i) { TIXMLASSERT( i>= 0 && i < _size ); return _mem[i]; } const T& operator[](int i) const { TIXMLASSERT( i>= 0 && i < _size ); return _mem[i]; } int Size() const { return _size; } int Capacity() const { return _allocated; } const T* Mem() const { return _mem; } T* Mem() { return _mem; } private: void EnsureCapacity( int cap ) { if ( cap > _allocated ) { int newAllocated = cap * 2; T* newMem = new T[newAllocated]; memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs if ( _mem != _pool ) { delete [] _mem; } _mem = newMem; _allocated = newAllocated; } } T* _mem; T _pool[INIT]; int _allocated; // objects allocated int _size; // number objects in use }; /* Parent virtual class of a pool for fast allocation and deallocation of objects. */ class CC_DLL MemPool { public: MemPool() {} virtual ~MemPool() {} virtual int ItemSize() const = 0; virtual void* Alloc() = 0; virtual void Free( void* ) = 0; virtual void SetTracked() = 0; }; /* Template child class to create pools of the correct type. */ template< int SIZE > class CC_DLL MemPoolT : public MemPool { public: MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} ~MemPoolT() { // Delete the blocks. for( int i=0; i<_blockPtrs.Size(); ++i ) { delete _blockPtrs[i]; } } virtual int ItemSize() const { return SIZE; } int CurrentAllocs() const { return _currentAllocs; } virtual void* Alloc() { if ( !_root ) { // Need a new block. Block* block = new Block(); _blockPtrs.Push( block ); for( int i=0; ichunk[i].next = &block->chunk[i+1]; } block->chunk[COUNT-1].next = 0; _root = block->chunk; } void* result = _root; _root = _root->next; ++_currentAllocs; if ( _currentAllocs > _maxAllocs ) { _maxAllocs = _currentAllocs; } _nAllocs++; _nUntracked++; return result; } virtual void Free( void* mem ) { if ( !mem ) { return; } --_currentAllocs; Chunk* chunk = (Chunk*)mem; #ifdef DEBUG memset( chunk, 0xfe, sizeof(Chunk) ); #endif chunk->next = _root; _root = chunk; } void Trace( const char* name ) { printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() ); } void SetTracked() { _nUntracked--; } int Untracked() const { return _nUntracked; } enum { COUNT = 1024/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private private: union Chunk { Chunk* next; char mem[SIZE]; }; struct Block { Chunk chunk[COUNT]; }; DynArray< Block*, 10 > _blockPtrs; Chunk* _root; int _currentAllocs; int _nAllocs; int _maxAllocs; int _nUntracked; }; /** Implements the interface to the "Visitor pattern" (see the Accept() method.) If you call the Accept() method, it requires being passed a XMLVisitor class to handle callbacks. For nodes that contain other nodes (Document, Element) you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs are simply called with Visit(). If you return 'true' from a Visit method, recursive parsing will continue. If you return false, no children of this node or its sibilings will be visited. All flavors of Visit methods have a default implementation that returns 'true' (continue visiting). You need to only override methods that are interesting to you. Generally Accept() is called on the TiXmlDocument, although all nodes support visiting. You should never change the document from a callback. @sa XMLNode::Accept() */ class CC_DLL XMLVisitor { public: virtual ~XMLVisitor() {} /// Visit a document. virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { return true; } /// Visit a document. virtual bool VisitExit( const XMLDocument& /*doc*/ ) { return true; } /// Visit an element. virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { return true; } /// Visit an element. virtual bool VisitExit( const XMLElement& /*element*/ ) { return true; } /// Visit a declaration. virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { return true; } /// Visit a text node. virtual bool Visit( const XMLText& /*text*/ ) { return true; } /// Visit a comment node. virtual bool Visit( const XMLComment& /*comment*/ ) { return true; } /// Visit an unknown node. virtual bool Visit( const XMLUnknown& /*unknown*/ ) { return true; } }; /* Utility functionality. */ class CC_DLL XMLUtil { public: // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't // correct, but simple, and usually works. static const char* SkipWhiteSpace( const char* p ) { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) { ++p; } return p; } static char* SkipWhiteSpace( char* p ) { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) { ++p; } return p; } static bool IsWhiteSpace( char p ) { return !IsUTF8Continuation(p) && isspace( static_cast(p) ); } inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { int n = 0; if ( p == q ) { return true; } while( *p && *q && *p == *q && n(const_cast(this)->FirstChildElement( value )); } /// Get the last child node, or null if none exists. const XMLNode* LastChild() const { return _lastChild; } XMLNode* LastChild() { return const_cast(const_cast(this)->LastChild() ); } /** Get the last child element or optionally the last child element with the specified name. */ const XMLElement* LastChildElement( const char* value=0 ) const; XMLElement* LastChildElement( const char* value=0 ) { return const_cast(const_cast(this)->LastChildElement(value) ); } /// Get the previous (left) sibling node of this node. const XMLNode* PreviousSibling() const { return _prev; } XMLNode* PreviousSibling() { return _prev; } /// Get the previous (left) sibling element of this node, with an opitionally supplied name. const XMLElement* PreviousSiblingElement( const char* value=0 ) const ; XMLElement* PreviousSiblingElement( const char* value=0 ) { return const_cast(const_cast(this)->PreviousSiblingElement( value ) ); } /// Get the next (right) sibling node of this node. const XMLNode* NextSibling() const { return _next; } XMLNode* NextSibling() { return _next; } /// Get the next (right) sibling element of this node, with an opitionally supplied name. const XMLElement* NextSiblingElement( const char* value=0 ) const; XMLElement* NextSiblingElement( const char* value=0 ) { return const_cast(const_cast(this)->NextSiblingElement( value ) ); } /** Add a child node as the last (right) child. */ XMLNode* InsertEndChild( XMLNode* addThis ); XMLNode* LinkEndChild( XMLNode* addThis ) { return InsertEndChild( addThis ); } /** Add a child node as the first (left) child. */ XMLNode* InsertFirstChild( XMLNode* addThis ); /** Add a node after the specified child node. */ XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ); /** Delete all the children of this node. */ void DeleteChildren(); /** Delete a child of this node. */ void DeleteChild( XMLNode* node ); /** Make a copy of this node, but not its children. You may pass in a Document pointer that will be the owner of the new Node. If the 'document' is null, then the node returned will be allocated from the current Document. (this->GetDocument()) Note: if called on a XMLDocument, this will return null. */ virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; /** Test if 2 nodes are the same, but don't test children. The 2 nodes do not need to be in the same Document. Note: if called on a XMLDocument, this will return false. */ virtual bool ShallowEqual( const XMLNode* compare ) const = 0; /** Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface. This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.) The interface has been based on ideas from: - http://www.saxproject.org/ - http://c2.com/cgi/wiki?HierarchicalVisitorPattern Which are both good references for "visiting". An example of using Accept(): @verbatim TiXmlPrinter printer; tinyxmlDoc.Accept( &printer ); const char* xmlcstr = printer.CStr(); @endverbatim */ virtual bool Accept( XMLVisitor* visitor ) const = 0; // internal virtual char* ParseDeep( char*, StrPair* ); protected: XMLNode( XMLDocument* ); virtual ~XMLNode(); XMLNode( const XMLNode& ); // not supported XMLNode& operator=( const XMLNode& ); // not supported XMLDocument* _document; XMLNode* _parent; mutable StrPair _value; XMLNode* _firstChild; XMLNode* _lastChild; XMLNode* _prev; XMLNode* _next; private: MemPool* _memPool; void Unlink( XMLNode* child ); }; /** XML text. Note that a text node can have child element nodes, for example: @verbatim This is bold @endverbatim A text node can have 2 ways to output the next. "normal" output and CDATA. It will default to the mode it was parsed from the XML file and you generally want to leave it alone, but you can change the output mode with SetCDATA() and query it with CDATA(). */ class CC_DLL XMLText : public XMLNode { friend class XMLBase; friend class XMLDocument; public: virtual bool Accept( XMLVisitor* visitor ) const; virtual XMLText* ToText() { return this; } virtual const XMLText* ToText() const { return this; } /// Declare whether this should be CDATA or standard text. void SetCData( bool isCData ) { _isCData = isCData; } /// Returns true if this is a CDATA text element. bool CData() const { return _isCData; } char* ParseDeep( char*, StrPair* endTag ); virtual XMLNode* ShallowClone( XMLDocument* document ) const; virtual bool ShallowEqual( const XMLNode* compare ) const; protected: XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} virtual ~XMLText() {} XMLText( const XMLText& ); // not supported XMLText& operator=( const XMLText& ); // not supported private: bool _isCData; }; /** An XML Comment. */ class CC_DLL XMLComment : public XMLNode { friend class XMLDocument; public: virtual XMLComment* ToComment() { return this; } virtual const XMLComment* ToComment() const { return this; } virtual bool Accept( XMLVisitor* visitor ) const; char* ParseDeep( char*, StrPair* endTag ); virtual XMLNode* ShallowClone( XMLDocument* document ) const; virtual bool ShallowEqual( const XMLNode* compare ) const; protected: XMLComment( XMLDocument* doc ); virtual ~XMLComment(); XMLComment( const XMLComment& ); // not supported XMLComment& operator=( const XMLComment& ); // not supported private: }; /** In correct XML the declaration is the first entry in the file. @verbatim @endverbatim TinyXML2 will happily read or write files without a declaration, however. The text of the declaration isn't interpreted. It is parsed and written as a string. */ class CC_DLL XMLDeclaration : public XMLNode { friend class XMLDocument; public: virtual XMLDeclaration* ToDeclaration() { return this; } virtual const XMLDeclaration* ToDeclaration() const { return this; } virtual bool Accept( XMLVisitor* visitor ) const; char* ParseDeep( char*, StrPair* endTag ); virtual XMLNode* ShallowClone( XMLDocument* document ) const; virtual bool ShallowEqual( const XMLNode* compare ) const; protected: XMLDeclaration( XMLDocument* doc ); virtual ~XMLDeclaration(); XMLDeclaration( const XMLDeclaration& ); // not supported XMLDeclaration& operator=( const XMLDeclaration& ); // not supported }; /** Any tag that tinyXml doesn't recognize is saved as an unknown. It is a tag of text, but should not be modified. It will be written back to the XML, unchanged, when the file is saved. DTD tags get thrown into TiXmlUnknowns. */ class CC_DLL XMLUnknown : public XMLNode { friend class XMLDocument; public: virtual XMLUnknown* ToUnknown() { return this; } virtual const XMLUnknown* ToUnknown() const { return this; } virtual bool Accept( XMLVisitor* visitor ) const; char* ParseDeep( char*, StrPair* endTag ); virtual XMLNode* ShallowClone( XMLDocument* document ) const; virtual bool ShallowEqual( const XMLNode* compare ) const; protected: XMLUnknown( XMLDocument* doc ); virtual ~XMLUnknown(); XMLUnknown( const XMLUnknown& ); // not supported XMLUnknown& operator=( const XMLUnknown& ); // not supported }; enum XMLError { XML_NO_ERROR = 0, XML_SUCCESS = 0, XML_NO_ATTRIBUTE, XML_WRONG_ATTRIBUTE_TYPE, XML_ERROR_FILE_NOT_FOUND, XML_ERROR_FILE_COULD_NOT_BE_OPENED, XML_ERROR_FILE_READ_ERROR, XML_ERROR_ELEMENT_MISMATCH, XML_ERROR_PARSING_ELEMENT, XML_ERROR_PARSING_ATTRIBUTE, XML_ERROR_IDENTIFYING_TAG, XML_ERROR_PARSING_TEXT, XML_ERROR_PARSING_CDATA, XML_ERROR_PARSING_COMMENT, XML_ERROR_PARSING_DECLARATION, XML_ERROR_PARSING_UNKNOWN, XML_ERROR_EMPTY_DOCUMENT, XML_ERROR_MISMATCHED_ELEMENT, XML_ERROR_PARSING, XML_CAN_NOT_CONVERT_TEXT, XML_NO_TEXT_NODE }; /** An attribute is a name-value pair. Elements have an arbitrary number of attributes, each with a unique name. @note The attributes are not XMLNodes. You may only query the Next() attribute in a list. */ class CC_DLL XMLAttribute { friend class XMLElement; public: /// The name of the attribute. const char* Name() const { return _name.GetStr(); } /// The value of the attribute. const char* Value() const { return _value.GetStr(); } /// The next attribute in the list. const XMLAttribute* Next() const { return _next; } /** IntAttribute interprets the attribute as an integer, and returns the value. If the value isn't an integer, 0 will be returned. There is no error checking; use QueryIntAttribute() if you need error checking. */ int IntValue() const { int i=0; QueryIntValue( &i ); return i; } /// Query as an unsigned integer. See IntAttribute() unsigned UnsignedValue() const { unsigned i=0; QueryUnsignedValue( &i ); return i; } /// Query as a boolean. See IntAttribute() bool BoolValue() const { bool b=false; QueryBoolValue( &b ); return b; } /// Query as a double. See IntAttribute() double DoubleValue() const { double d=0; QueryDoubleValue( &d ); return d; } /// Query as a float. See IntAttribute() float FloatValue() const { float f=0; QueryFloatValue( &f ); return f; } /** QueryIntAttribute interprets the attribute as an integer, and returns the value in the provided paremeter. The function will return XML_NO_ERROR on success, and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. */ XMLError QueryIntValue( int* value ) const; /// See QueryIntAttribute XMLError QueryUnsignedValue( unsigned int* value ) const; /// See QueryIntAttribute XMLError QueryBoolValue( bool* value ) const; /// See QueryIntAttribute XMLError QueryDoubleValue( double* value ) const; /// See QueryIntAttribute XMLError QueryFloatValue( float* value ) const; /// Set the attribute to a string value. void SetAttribute( const char* value ); /// Set the attribute to value. void SetAttribute( int value ); /// Set the attribute to value. void SetAttribute( unsigned value ); /// Set the attribute to value. void SetAttribute( bool value ); /// Set the attribute to value. void SetAttribute( double value ); /// Set the attribute to value. void SetAttribute( float value ); private: enum { BUF_SIZE = 200 }; XMLAttribute() : _next( 0 ) {} virtual ~XMLAttribute() {} XMLAttribute( const XMLAttribute& ); // not supported void operator=( const XMLAttribute& ); // not supported void SetName( const char* name ); char* ParseDeep( char* p, bool processEntities ); mutable StrPair _name; mutable StrPair _value; XMLAttribute* _next; MemPool* _memPool; }; /** The element is a container class. It has a value, the element name, and can contain other elements, text, comments, and unknowns. Elements also contain an arbitrary number of attributes. */ class CC_DLL XMLElement : public XMLNode { friend class XMLBase; friend class XMLDocument; public: /// Get the name of an element (which is the Value() of the node.) const char* Name() const { return Value(); } /// Set the name of the element. void SetName( const char* str, bool staticMem=false ) { SetValue( str, staticMem ); } virtual XMLElement* ToElement() { return this; } virtual const XMLElement* ToElement() const { return this; } virtual bool Accept( XMLVisitor* visitor ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. For example: @verbatim const char* value = ele->Attribute( "foo" ); @endverbatim The 'value' parameter is normally null. However, if specified, the attribute will only be returned if the 'name' and 'value' match. This allow you to write code: @verbatim if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); @endverbatim rather than: @verbatim if ( ele->Attribute( "foo" ) ) { if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); } @endverbatim */ const char* Attribute( const char* name, const char* value=0 ) const; /** Given an attribute name, IntAttribute() returns the value of the attribute interpreted as an integer. 0 will be returned if there is an error. For a method with error checking, see QueryIntAttribute() */ int IntAttribute( const char* name ) const { int i=0; QueryIntAttribute( name, &i ); return i; } /// See IntAttribute() unsigned UnsignedAttribute( const char* name ) const { unsigned i=0; QueryUnsignedAttribute( name, &i ); return i; } /// See IntAttribute() bool BoolAttribute( const char* name ) const { bool b=false; QueryBoolAttribute( name, &b ); return b; } /// See IntAttribute() double DoubleAttribute( const char* name ) const { double d=0; QueryDoubleAttribute( name, &d ); return d; } /// See IntAttribute() float FloatAttribute( const char* name ) const { float f=0; QueryFloatAttribute( name, &f ); return f; } /** Given an attribute name, QueryIntAttribute() returns XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion can't be performed, or XML_NO_ATTRIBUTE if the attribute doesn't exist. If successful, the result of the conversion will be written to 'value'. If not successful, nothing will be written to 'value'. This allows you to provide default value: @verbatim int value = 10; QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 @endverbatim */ XMLError QueryIntAttribute( const char* name, int* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryIntValue( value ); } /// See QueryIntAttribute() XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryUnsignedValue( value ); } /// See QueryIntAttribute() XMLError QueryBoolAttribute( const char* name, bool* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryBoolValue( value ); } /// See QueryIntAttribute() XMLError QueryDoubleAttribute( const char* name, double* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryDoubleValue( value ); } /// See QueryIntAttribute() XMLError QueryFloatAttribute( const char* name, float* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { return XML_NO_ATTRIBUTE; } return a->QueryFloatValue( value ); } /// Sets the named attribute to value. void SetAttribute( const char* name, const char* value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( value ); } /// Sets the named attribute to value. void SetAttribute( const char* name, int value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( value ); } /// Sets the named attribute to value. void SetAttribute( const char* name, unsigned value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( value ); } /// Sets the named attribute to value. void SetAttribute( const char* name, bool value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( value ); } /// Sets the named attribute to value. void SetAttribute( const char* name, double value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( value ); } /** Delete an attribute. */ void DeleteAttribute( const char* name ); /// Return the first attribute in the list. const XMLAttribute* FirstAttribute() const { return _rootAttribute; } /// Query a specific attribute in the list. const XMLAttribute* FindAttribute( const char* name ) const; /** Convenience function for easy access to the text inside an element. Although easy and concise, GetText() is limited compared to getting the TiXmlText child and accessing it directly. If the first child of 'this' is a TiXmlText, the GetText() returns the character string of the Text node, else null is returned. This is a convenient method for getting the text of simple contained text: @verbatim This is text const char* str = fooElement->GetText(); @endverbatim 'str' will be a pointer to "This is text". Note that this function can be misleading. If the element foo was created from this XML: @verbatim This is text @endverbatim then the value of str would be null. The first child node isn't a text node, it is another element. From this XML: @verbatim This is text @endverbatim GetText() will return "This is ". */ const char* GetText() const; /** Convenience method to query the value of a child text node. This is probably best shown by example. Given you have a document is this form: @verbatim 1 1.4 @endverbatim The QueryIntText() and similar functions provide a safe and easier way to get to the "value" of x and y. @verbatim int x = 0; float y = 0; // types of x and y are contrived for example const XMLElement* xElement = pointElement->FirstChildElement( "x" ); const XMLElement* yElement = pointElement->FirstChildElement( "y" ); xElement->QueryIntText( &x ); yElement->QueryFloatText( &y ); @endverbatim @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. */ XMLError QueryIntText( int* ival ) const; /// See QueryIntText() XMLError QueryUnsignedText( unsigned* uval ) const; /// See QueryIntText() XMLError QueryBoolText( bool* bval ) const; /// See QueryIntText() XMLError QueryDoubleText( double* dval ) const; /// See QueryIntText() XMLError QueryFloatText( float* fval ) const; // internal: enum { OPEN, // CLOSED, // CLOSING // }; int ClosingType() const { return _closingType; } char* ParseDeep( char* p, StrPair* endTag ); virtual XMLNode* ShallowClone( XMLDocument* document ) const; virtual bool ShallowEqual( const XMLNode* compare ) const; private: XMLElement( XMLDocument* doc ); virtual ~XMLElement(); XMLElement( const XMLElement& ); // not supported void operator=( const XMLElement& ); // not supported XMLAttribute* FindAttribute( const char* name ); XMLAttribute* FindOrCreateAttribute( const char* name ); //void LinkAttribute( XMLAttribute* attrib ); char* ParseAttributes( char* p ); int _closingType; // The attribute list is ordered; there is no 'lastAttribute' // because the list needs to be scanned for dupes before adding // a new attribute. XMLAttribute* _rootAttribute; }; enum Whitespace { PRESERVE_WHITESPACE, COLLAPSE_WHITESPACE }; /** A Document binds together all the functionality. It can be saved, loaded, and printed to the screen. All Nodes are connected and allocated to a Document. If the Document is deleted, all its Nodes are also deleted. */ class CC_DLL XMLDocument : public XMLNode { friend class XMLElement; public: /// constructor XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); ~XMLDocument(); virtual XMLDocument* ToDocument() { return this; } virtual const XMLDocument* ToDocument() const { return this; } /** Parse an XML file from a character string. Returns XML_NO_ERROR (0) on success, or an errorID. You may optionally pass in the 'nBytes', which is the number of bytes which will be parsed. If not specified, TinyXML will assume 'xml' points to a null terminated string. */ XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); /** Load an XML file from disk. Returns XML_NO_ERROR (0) on success, or an errorID. */ XMLError LoadFile( const char* filename ); /** Load an XML file from disk. You are responsible for providing and closing the FILE*. Returns XML_NO_ERROR (0) on success, or an errorID. */ XMLError LoadFile( FILE* ); /** Save the XML file to disk. Returns XML_NO_ERROR (0) on success, or an errorID. */ XMLError SaveFile( const char* filename, bool compact = false ); /** Save the XML file to disk. You are responsible for providing and closing the FILE*. Returns XML_NO_ERROR (0) on success, or an errorID. */ XMLError SaveFile( FILE* fp, bool compact = false ); bool ProcessEntities() const { return _processEntities; } Whitespace WhitespaceMode() const { return _whitespace; } /** Returns true if this document has a leading Byte Order Mark of UTF8. */ bool HasBOM() const { return _writeBOM; } /** Sets whether to write the BOM when writing the file. */ void SetBOM( bool useBOM ) { _writeBOM = useBOM; } /** Return the root element of DOM. Equivalent to FirstChildElement(). To get the first node, use FirstChild(). */ XMLElement* RootElement() { return FirstChildElement(); } const XMLElement* RootElement() const { return FirstChildElement(); } /** Print the Document. If the Printer is not provided, it will print to stdout. If you provide Printer, this can print to a file: @verbatim XMLPrinter printer( fp ); doc.Print( &printer ); @endverbatim Or you can use a printer to print to memory: @verbatim XMLPrinter printer; doc->Print( &printer ); // printer.CStr() has a const char* to the XML @endverbatim */ void Print( XMLPrinter* streamer=0 ); virtual bool Accept( XMLVisitor* visitor ) const; /** Create a new Element associated with this Document. The memory for the Element is managed by the Document. */ XMLElement* NewElement( const char* name ); /** Create a new Comment associated with this Document. The memory for the Comment is managed by the Document. */ XMLComment* NewComment( const char* comment ); /** Create a new Text associated with this Document. The memory for the Text is managed by the Document. */ XMLText* NewText( const char* text ); /** Create a new Declaration associated with this Document. The memory for the object is managed by the Document. If the 'text' param is null, the standard declaration is used.: @verbatim @endverbatim */ XMLDeclaration* NewDeclaration( const char* text=0 ); /** Create a new Unknown associated with this Document. The memory forthe object is managed by the Document. */ XMLUnknown* NewUnknown( const char* text ); /** Delete a node associated with this document. It will be unlinked from the DOM. */ void DeleteNode( XMLNode* node ) { node->_parent->DeleteChild( node ); } void SetError( XMLError error, const char* str1, const char* str2 ); /// Return true if there was an error parsing the document. bool Error() const { return _errorID != XML_NO_ERROR; } /// Return the errorID. XMLError ErrorID() const { return _errorID; } /// Return a possibly helpful diagnostic location or string. const char* GetErrorStr1() const { return _errorStr1; } /// Return a possibly helpful secondary diagnostic location or string. const char* GetErrorStr2() const { return _errorStr2; } /// If there is an error, print it to stdout. void PrintError() const; // internal char* Identify( char* p, XMLNode** node ); virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { return 0; } virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { return false; } private: XMLDocument( const XMLDocument& ); // not supported void operator=( const XMLDocument& ); // not supported void InitDocument(); bool _writeBOM; bool _processEntities; XMLError _errorID; Whitespace _whitespace; const char* _errorStr1; const char* _errorStr2; char* _charBuffer; MemPoolT< sizeof(XMLElement) > _elementPool; MemPoolT< sizeof(XMLAttribute) > _attributePool; MemPoolT< sizeof(XMLText) > _textPool; MemPoolT< sizeof(XMLComment) > _commentPool; }; /** A XMLHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing. Note that XMLHandle is not part of the TinyXML DOM structure. It is a separate utility class. Take an example: @verbatim @endverbatim Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very easy to write a *lot* of code that looks like: @verbatim XMLElement* root = document.FirstChildElement( "Document" ); if ( root ) { XMLElement* element = root->FirstChildElement( "Element" ); if ( element ) { XMLElement* child = element->FirstChildElement( "Child" ); if ( child ) { XMLElement* child2 = child->NextSiblingElement( "Child" ); if ( child2 ) { // Finally do something useful. @endverbatim And that doesn't even cover "else" cases. XMLHandle addresses the verbosity of such code. A XMLHandle checks for null pointers so it is perfectly safe and correct to use: @verbatim XMLHandle docHandle( &document ); XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement(); if ( child2 ) { // do something useful @endverbatim Which is MUCH more concise and useful. It is also safe to copy handles - internally they are nothing more than node pointers. @verbatim XMLHandle handleCopy = handle; @endverbatim See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects. */ class CC_DLL XMLHandle { public: /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. XMLHandle( XMLNode* node ) { _node = node; } /// Create a handle from a node. XMLHandle( XMLNode& node ) { _node = &node; } /// Copy constructor XMLHandle( const XMLHandle& ref ) { _node = ref._node; } /// Assignment XMLHandle& operator=( const XMLHandle& ref ) { _node = ref._node; return *this; } /// Get the first child of this handle. XMLHandle FirstChild() { return XMLHandle( _node ? _node->FirstChild() : 0 ); } /// Get the first child element of this handle. XMLHandle FirstChildElement( const char* value=0 ) { return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 ); } /// Get the last child of this handle. XMLHandle LastChild() { return XMLHandle( _node ? _node->LastChild() : 0 ); } /// Get the last child element of this handle. XMLHandle LastChildElement( const char* _value=0 ) { return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 ); } /// Get the previous sibling of this handle. XMLHandle PreviousSibling() { return XMLHandle( _node ? _node->PreviousSibling() : 0 ); } /// Get the previous sibling element of this handle. XMLHandle PreviousSiblingElement( const char* _value=0 ) { return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 ); } /// Get the next sibling of this handle. XMLHandle NextSibling() { return XMLHandle( _node ? _node->NextSibling() : 0 ); } /// Get the next sibling element of this handle. XMLHandle NextSiblingElement( const char* _value=0 ) { return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 ); } /// Safe cast to XMLNode. This can return null. XMLNode* ToNode() { return _node; } /// Safe cast to XMLElement. This can return null. XMLElement* ToElement() { return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 ); } /// Safe cast to XMLText. This can return null. XMLText* ToText() { return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 ); } /// Safe cast to XMLUnknown. This can return null. XMLUnknown* ToUnknown() { return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 ); } /// Safe cast to XMLDeclaration. This can return null. XMLDeclaration* ToDeclaration() { return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 ); } private: XMLNode* _node; }; /** A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the same in all regards, except for the 'const' qualifiers. See XMLHandle for API. */ class CC_DLL XMLConstHandle { public: XMLConstHandle( const XMLNode* node ) { _node = node; } XMLConstHandle( const XMLNode& node ) { _node = &node; } XMLConstHandle( const XMLConstHandle& ref ) { _node = ref._node; } XMLConstHandle& operator=( const XMLConstHandle& ref ) { _node = ref._node; return *this; } const XMLConstHandle FirstChild() const { return XMLConstHandle( _node ? _node->FirstChild() : 0 ); } const XMLConstHandle FirstChildElement( const char* value=0 ) const { return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 ); } const XMLConstHandle LastChild() const { return XMLConstHandle( _node ? _node->LastChild() : 0 ); } const XMLConstHandle LastChildElement( const char* _value=0 ) const { return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 ); } const XMLConstHandle PreviousSibling() const { return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); } const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const { return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 ); } const XMLConstHandle NextSibling() const { return XMLConstHandle( _node ? _node->NextSibling() : 0 ); } const XMLConstHandle NextSiblingElement( const char* _value=0 ) const { return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 ); } const XMLNode* ToNode() const { return _node; } const XMLElement* ToElement() const { return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 ); } const XMLText* ToText() const { return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 ); } const XMLUnknown* ToUnknown() const { return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 ); } const XMLDeclaration* ToDeclaration() const { return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 ); } private: const XMLNode* _node; }; /** Printing functionality. The XMLPrinter gives you more options than the XMLDocument::Print() method. It can: -# Print to memory. -# Print to a file you provide. -# Print XML without a XMLDocument. Print to Memory @verbatim XMLPrinter printer; doc->Print( &printer ); SomeFunction( printer.CStr() ); @endverbatim Print to a File You provide the file pointer. @verbatim XMLPrinter printer( fp ); doc.Print( &printer ); @endverbatim Print without a XMLDocument When loading, an XML parser is very useful. However, sometimes when saving, it just gets in the way. The code is often set up for streaming, and constructing the DOM is just overhead. The Printer supports the streaming case. The following code prints out a trivially simple XML file without ever creating an XML document. @verbatim XMLPrinter printer( fp ); printer.OpenElement( "foo" ); printer.PushAttribute( "foo", "bar" ); printer.CloseElement(); @endverbatim */ class CC_DLL XMLPrinter : public XMLVisitor { public: /** Construct the printer. If the FILE* is specified, this will print to the FILE. Else it will print to memory, and the result is available in CStr(). If 'compact' is set to true, then output is created with only required whitespace and newlines. */ XMLPrinter( FILE* file=0, bool compact = false ); ~XMLPrinter() {} /** If streaming, write the BOM and declaration. */ void PushHeader( bool writeBOM, bool writeDeclaration ); /** If streaming, start writing an element. The element must be closed with CloseElement() */ void OpenElement( const char* name ); /// If streaming, add an attribute to an open element. void PushAttribute( const char* name, const char* value ); void PushAttribute( const char* name, int value ); void PushAttribute( const char* name, unsigned value ); void PushAttribute( const char* name, bool value ); void PushAttribute( const char* name, double value ); /// If streaming, close the Element. void CloseElement(); /// Add a text node. void PushText( const char* text, bool cdata=false ); /// Add a text node from an integer. void PushText( int value ); /// Add a text node from an unsigned. void PushText( unsigned value ); /// Add a text node from a bool. void PushText( bool value ); /// Add a text node from a float. void PushText( float value ); /// Add a text node from a double. void PushText( double value ); /// Add a comment void PushComment( const char* comment ); void PushDeclaration( const char* value ); void PushUnknown( const char* value ); virtual bool VisitEnter( const XMLDocument& /*doc*/ ); virtual bool VisitExit( const XMLDocument& /*doc*/ ) { return true; } virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); virtual bool VisitExit( const XMLElement& element ); virtual bool Visit( const XMLText& text ); virtual bool Visit( const XMLComment& comment ); virtual bool Visit( const XMLDeclaration& declaration ); virtual bool Visit( const XMLUnknown& unknown ); /** If in print to memory mode, return a pointer to the XML file in memory. */ const char* CStr() const { return _buffer.Mem(); } /** If in print to memory mode, return the size of the XML file in memory. (Note the size returned includes the terminating null.) */ int CStrSize() const { return _buffer.Size(); } private: void SealElement(); void PrintSpace( int depth ); void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. void Print( const char* format, ... ); bool _elementJustOpened; bool _firstElement; FILE* _fp; int _depth; int _textDepth; bool _processEntities; bool _compactMode; enum { ENTITY_RANGE = 64, BUF_SIZE = 200 }; bool _entityFlag[ENTITY_RANGE]; bool _restrictedEntityFlag[ENTITY_RANGE]; DynArray< const char*, 10 > _stack; DynArray< char, 20 > _buffer; #ifdef _MSC_VER DynArray< char, 20 > _accumulator; #endif }; } // tinyxml2 #endif // TINYXML2_INCLUDED ================================================ FILE: cocos2d/external/unzip/CMakeLists.txt ================================================ set(UNZIP_SRC ioapi.cpp unzip.cpp ) add_library(unzip STATIC ${UNZIP_SRC} ) set_target_properties(unzip PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) ================================================ FILE: cocos2d/external/unzip/ioapi.cpp ================================================ /* ioapi.h -- IO base function header for compress/uncompress .zip part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) Modifications for Zip64 support Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) For more info read MiniZip_info.txt */ #include "ioapi.h" namespace cocos2d { voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) { if (pfilefunc->zfile_func64.zopen64_file != NULL) return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); else { return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); } } long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) { if (pfilefunc->zfile_func64.zseek64_file != NULL) return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); else { uLong offsetTruncated = (uLong)offset; if (offsetTruncated != offset) return -1; else return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); } } ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) { if (pfilefunc->zfile_func64.zseek64_file != NULL) return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); else { uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); if ((tell_uLong) == ((uLong)-1)) return (ZPOS64_T)-1; else return tell_uLong; } } void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) { p_filefunc64_32->zfile_func64.zopen64_file = NULL; p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; p_filefunc64_32->zfile_func64.ztell64_file = NULL; p_filefunc64_32->zfile_func64.zseek64_file = NULL; p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque; p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; } static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) { FILE* file = NULL; const char* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) mode_fopen = "rb"; else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) mode_fopen = "r+b"; else if (mode & ZLIB_FILEFUNC_MODE_CREATE) mode_fopen = "wb"; if ((filename!=NULL) && (mode_fopen != NULL)) file = fopen(filename, mode_fopen); return file; } static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) { FILE* file = NULL; const char* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) mode_fopen = "rb"; else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) mode_fopen = "r+b"; else if (mode & ZLIB_FILEFUNC_MODE_CREATE) mode_fopen = "wb"; if ((filename!=NULL) && (mode_fopen != NULL)) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL || CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN) file = NULL; #else file = fopen64((const char*)filename, mode_fopen); #endif } return file; } static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) { uLong ret; ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); return ret; } static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) { uLong ret; ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); return ret; } static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) { long ret; ret = ftell((FILE *)stream); return ret; } static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) { ZPOS64_T ret; #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL || CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN) ret = 0; #else ret = ftello64((FILE *)stream); #endif return ret; } static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) { int fseek_origin=0; long ret; switch (origin) { case ZLIB_FILEFUNC_SEEK_CUR : fseek_origin = SEEK_CUR; break; case ZLIB_FILEFUNC_SEEK_END : fseek_origin = SEEK_END; break; case ZLIB_FILEFUNC_SEEK_SET : fseek_origin = SEEK_SET; break; default: return -1; } ret = 0; if (fseek((FILE *)stream, offset, fseek_origin) != 0) ret = -1; return ret; } static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL || CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN) return -1; #else int fseek_origin=0; switch (origin) { case ZLIB_FILEFUNC_SEEK_CUR : fseek_origin = SEEK_CUR; break; case ZLIB_FILEFUNC_SEEK_END : fseek_origin = SEEK_END; break; case ZLIB_FILEFUNC_SEEK_SET : fseek_origin = SEEK_SET; break; default: return -1; } if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) return -1; return 0; #endif } static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) { int ret; ret = fclose((FILE *)stream); return ret; } static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) { int ret; ret = ferror((FILE *)stream); return ret; } void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func; pzlib_filefunc_def->ztell_file = ftell_file_func; pzlib_filefunc_def->zseek_file = fseek_file_func; pzlib_filefunc_def->zclose_file = fclose_file_func; pzlib_filefunc_def->zerror_file = ferror_file_func; pzlib_filefunc_def->opaque = NULL; } void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen64_file = fopen64_file_func; pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func; pzlib_filefunc_def->ztell64_file = ftell64_file_func; pzlib_filefunc_def->zseek64_file = fseek64_file_func; pzlib_filefunc_def->zclose_file = fclose_file_func; pzlib_filefunc_def->zerror_file = ferror_file_func; pzlib_filefunc_def->opaque = NULL; } } // end of namespace cocos2d ================================================ FILE: cocos2d/external/unzip/ioapi.h ================================================ /* ioapi.h -- IO base function header for compress/uncompress .zip part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) Modifications for Zip64 support Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) For more info read MiniZip_info.txt Changes Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. More if/def section may be needed to support other platforms Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. (but you should use iowin32.c for windows instead) */ #ifndef _ZLIBIOAPI64_H #define _ZLIBIOAPI64_H #include "CCPlatformConfig.h" #if (!defined(_WIN32)) && (!defined(WIN32)) // Linux needs this to support file operation on files larger then 4+GB // But might need better if/def to select just the platforms that needs them. #ifndef __USE_FILE_OFFSET64 #define __USE_FILE_OFFSET64 #endif #ifndef __USE_LARGEFILE64 #define __USE_LARGEFILE64 #endif #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif #ifndef _FILE_OFFSET_BIT #define _FILE_OFFSET_BIT 64 #endif #endif #include #include #include "zlib.h" namespace cocos2d { #ifndef OF #define OF _Z_OF #endif #if defined(USE_FILE32API) #define fopen64 fopen #define ftello64 ftell #define fseeko64 fseek #else #ifdef _MSC_VER #define fopen64 fopen #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) #define ftello64 _ftelli64 #define fseeko64 _fseeki64 #else // old MSC #define ftello64 ftell #define fseeko64 fseek #endif #endif #endif /* #ifndef ZPOS64_T #ifdef _WIN32 #define ZPOS64_T fpos_t #else #include #define ZPOS64_T uint64_t #endif #endif */ #ifdef HAVE_MINIZIP64_CONF_H #include "mz64conf.h" #endif /* a type chosen by DEFINE */ #ifdef HAVE_64BIT_INT_CUSTOM typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; #else #ifdef HAS_STDINT_H #include "stdint.h" typedef uint64_t ZPOS64_T; #else #if defined(_MSC_VER) || defined(__BORLANDC__) typedef unsigned __int64 ZPOS64_T; #else typedef unsigned long long int ZPOS64_T; #endif #endif #endif #define ZLIB_FILEFUNC_SEEK_CUR (1) #define ZLIB_FILEFUNC_SEEK_END (2) #define ZLIB_FILEFUNC_SEEK_SET (0) #define ZLIB_FILEFUNC_MODE_READ (1) #define ZLIB_FILEFUNC_MODE_WRITE (2) #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) #define ZLIB_FILEFUNC_MODE_EXISTING (4) #define ZLIB_FILEFUNC_MODE_CREATE (8) #ifndef ZCALLBACK #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) #define ZCALLBACK CALLBACK #else #define ZCALLBACK #endif #endif typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); /* here is the "old" 32 bits structure structure */ typedef struct zlib_filefunc_def_s { open_file_func zopen_file; read_file_func zread_file; write_file_func zwrite_file; tell_file_func ztell_file; seek_file_func zseek_file; close_file_func zclose_file; testerror_file_func zerror_file; voidpf opaque; } zlib_filefunc_def; typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); typedef struct zlib_filefunc64_def_s { open64_file_func zopen64_file; read_file_func zread_file; write_file_func zwrite_file; tell64_file_func ztell64_file; seek64_file_func zseek64_file; close_file_func zclose_file; testerror_file_func zerror_file; voidpf opaque; } zlib_filefunc64_def; void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); /* now internal definition, only for zip.c and unzip.h */ typedef struct zlib_filefunc64_32_def_s { zlib_filefunc64_def zfile_func64; open_file_func zopen32_file; tell_file_func ztell32_file; seek_file_func zseek32_file; } zlib_filefunc64_32_def; #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) } // end of namespace cocos2d #endif ================================================ FILE: cocos2d/external/unzip/unzip.cpp ================================================ /* unzip.c -- IO for uncompress .zip files using zlib Version 1.1, February 14h, 2010 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) Modifications of Unzip for Zip64 Copyright (C) 2007-2008 Even Rouault Modifications for Zip64 support on both zip and unzip Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) For more info read MiniZip_info.txt ------------------------------------------------------------------------------------ Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of compatibility with older software. The following is from the original crypt.c. Code woven in by Terry Thorsen 1/2003. Copyright (c) 1990-2000 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2000-Apr-09 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] The encryption/decryption parts of this source code (as opposed to the non-echoing password parts) were originally written in Europe. The whole source package can be freely distributed, including from the USA. (Prior to January 2000, re-export from the US was a violation of US law.) This encryption code is a direct transcription of the algorithm from Roger Schlafly, described by Phil Katz in the file appnote.txt. This file (appnote.txt) is distributed with the PKZIP program (even in the version without encryption capabilities). ------------------------------------------------------------------------------------ Changes in unzip.c 2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos 2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz* 2007-2008 - Even Rouault - Remove old C style function prototypes 2007-2008 - Even Rouault - Add unzip support for ZIP64 Copyright (C) 2007-2008 Even Rouault Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G should only read the compressed/uncompressed size from the Zip64 format if the size from normal header was 0xFFFFFFFF Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required) Patch created by Daniel Borca Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson */ #include #include #include #ifndef NOUNCRYPT #define NOUNCRYPT #endif #include "zlib.h" #include "unzip.h" #ifdef STDC # include # include # include #endif #ifdef NO_ERRNO_H extern int errno; #else # include #endif namespace cocos2d { #ifndef local # define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ #ifndef CASESENSITIVITYDEFAULT_NO # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) # define CASESENSITIVITYDEFAULT_NO # endif #endif #ifndef UNZ_BUFSIZE #define UNZ_BUFSIZE (16384) #endif #ifndef UNZ_MAXFILENAMEINZIP #define UNZ_MAXFILENAMEINZIP (256) #endif #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif #ifndef TRYFREE # define TRYFREE(p) {if (p) free(p);} #endif #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) const char unz_copyright[] = " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; /* unz_file_info_interntal contain internal info about a file in zipfile*/ typedef struct unz_file_info64_internal_s { ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */ } unz_file_info64_internal; /* file_in_zip_read_info_s contain internal information about a file in zipfile, when reading and decompress it */ typedef struct { char *read_buffer; /* internal buffer for compressed data */ z_stream stream; /* zLib stream structure for inflate */ #ifdef HAVE_BZIP2 bz_stream bstream; /* bzLib stream structure for bziped */ #endif ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ uLong stream_initialised; /* flag set if stream structure is initialized*/ ZPOS64_T offset_local_extrafield;/* offset of the local extra field */ uInt size_local_extrafield;/* size of the local extra field */ ZPOS64_T pos_local_extrafield; /* position in the local extra field in read*/ ZPOS64_T total_out_64; uLong crc32; /* crc32 of all data uncompressed */ uLong crc32_wait; /* crc32 we must obtain after decompress all */ ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ zlib_filefunc64_32_def z_filefunc; voidpf filestream; /* io structure of the zipfile */ uLong compression_method; /* compression method (0==store) */ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ int raw; } file_in_zip64_read_info_s; /* unz64_s contain internal information about the zipfile */ typedef struct { zlib_filefunc64_32_def z_filefunc; int is64bitOpenFunction; voidpf filestream; /* io structure of the zipfile */ unz_global_info64 gi; /* public global information */ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ ZPOS64_T num_file; /* number of the current file in the zipfile*/ ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/ ZPOS64_T current_file_ok; /* flag about the usability of the current file*/ ZPOS64_T central_pos; /* position of the beginning of the central dir*/ ZPOS64_T size_central_dir; /* size of the central directory */ ZPOS64_T offset_central_dir; /* offset of start of central directory with respect to the starting disk number */ unz_file_info64 cur_file_info; /* public info about the current file in zip*/ unz_file_info64_internal cur_file_info_internal; /* private info about it*/ file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current file if we are decompressing it */ int encrypted; int isZip64; # ifndef NOUNCRYPT unsigned long keys[3]; /* keys defining the pseudo-random sequence */ const unsigned long* pcrc_32_tab; # endif } unz64_s; #ifndef NOUNCRYPT #include "crypt.h" #endif /* =========================================================================== Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. IN assertion: the stream s has been successfully opened for reading. */ local int unz64local_getByte OF(( const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi) { unsigned char c; int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); if (err==1) { *pi = (int)c; return UNZ_OK; } else { if (ZERROR64(*pzlib_filefunc_def,filestream)) return UNZ_ERRNO; else return UNZ_EOF; } } /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ local int unz64local_getShort OF(( const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX) { uLong x ; int i = 0; int err; err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((uLong)i)<<8; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } local int unz64local_getLong OF(( const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX) { uLong x ; int i = 0; int err; err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((uLong)i)<<8; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((uLong)i)<<16; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<24; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } local int unz64local_getLong64 OF(( const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)); local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) { ZPOS64_T x ; int i = 0; int err; err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x = (ZPOS64_T)i; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((ZPOS64_T)i)<<8; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((ZPOS64_T)i)<<16; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((ZPOS64_T)i)<<24; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((ZPOS64_T)i)<<32; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((ZPOS64_T)i)<<40; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((ZPOS64_T)i)<<48; if (err==UNZ_OK) err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x |= ((ZPOS64_T)i)<<56; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } /* My own strcmpi / strcasecmp */ local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2) { for (;;) { char c1=*(fileName1++); char c2=*(fileName2++); if ((c1>='a') && (c1<='z')) c1 -= 0x20; if ((c2>='a') && (c2<='z')) c2 -= 0x20; if (c1=='\0') return ((c2=='\0') ? 0 : -1); if (c2=='\0') return 1; if (c1c2) return 1; } } #ifdef CASESENSITIVITYDEFAULT_NO #define CASESENSITIVITYDEFAULTVALUE 2 #else #define CASESENSITIVITYDEFAULTVALUE 1 #endif #ifndef STRCMPCASENOSENTIVEFUNCTION #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal #endif /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is default of your operating system (like 1 on Unix, 2 on Windows) */ int ZEXPORT unzStringFileNameCompare (const char* fileName1, const char* fileName2, int iCaseSensitivity) { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; if (iCaseSensitivity==1) return strcmp(fileName1,fileName2); return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); } #ifndef BUFREADCOMMENT #define BUFREADCOMMENT (0x400) #endif /* Locate the Central directory of a zipfile (at the end, just before the global comment) */ local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ ZPOS64_T uPosFound=0; if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) return 0; uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); if (buf==NULL) return 0; uBackRead = 4; while (uBackReaduMaxBack) uBackRead = uMaxBack; else uBackRead+=BUFREADCOMMENT; uReadPos = uSizeFile-uBackRead ; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) break; if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) break; for (i=(int)uReadSize-3; (i--)>0;) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { uPosFound = uReadPos+i; break; } if (uPosFound!=0) break; } TRYFREE(buf); return uPosFound; } /* Locate the Central directory 64 of a zipfile (at the end, just before the global comment) */ local ZPOS64_T unz64local_SearchCentralDir64 OF(( const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { unsigned char* buf; ZPOS64_T uSizeFile; ZPOS64_T uBackRead; ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ ZPOS64_T uPosFound=0; uLong uL; ZPOS64_T relativeOffset; if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) return 0; uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); if (buf==NULL) return 0; uBackRead = 4; while (uBackReaduMaxBack) uBackRead = uMaxBack; else uBackRead+=BUFREADCOMMENT; uReadPos = uSizeFile-uBackRead ; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) break; if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) break; for (i=(int)uReadSize-3; (i--)>0;) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) { uPosFound = uReadPos+i; break; } if (uPosFound!=0) break; } TRYFREE(buf); if (uPosFound == 0) return 0; /* Zip64 end of central directory locator */ if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) return 0; /* the signature, already checked */ if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) return 0; /* number of the disk with the start of the zip64 end of central directory */ if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) return 0; if (uL != 0) return 0; /* relative offset of the zip64 end of central directory record */ if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK) return 0; /* total number of disks */ if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) return 0; if (uL != 1) return 0; /* Goto end of central directory record */ if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) return 0; /* the signature */ if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) return 0; if (uL != 0x06064b50) return 0; return relativeOffset; } /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer "zlib/zlib114.zip". If the zipfile cannot be opened (file doesn't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ local unzFile unzOpenInternal (const void *path, zlib_filefunc64_32_def* pzlib_filefunc64_32_def, int is64bitOpenFunction) { unz64_s us; unz64_s *s; ZPOS64_T central_pos; uLong uL; uLong number_disk; /* number of the current dist, used for spanning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP, unsupported, always 0*/ ZPOS64_T number_entry_CD; /* total number of entries in the central dir (same than number_entry on nospan) */ int err=UNZ_OK; if (unz_copyright[0]!=' ') return NULL; us.z_filefunc.zseek32_file = NULL; us.z_filefunc.ztell32_file = NULL; if (pzlib_filefunc64_32_def==NULL) fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); else us.z_filefunc = *pzlib_filefunc64_32_def; us.is64bitOpenFunction = is64bitOpenFunction; us.filestream = ZOPEN64(us.z_filefunc, path, ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING); if (us.filestream==NULL) return NULL; central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream); if (central_pos) { uLong uS; ZPOS64_T uL64; us.isZip64 = 1; if (ZSEEK64(us.z_filefunc, us.filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; /* the signature, already checked */ if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; /* size of zip64 end of central directory record */ if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK) err=UNZ_ERRNO; /* version made by */ if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) err=UNZ_ERRNO; /* version needed to extract */ if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) err=UNZ_ERRNO; /* number of this disk */ if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) err=UNZ_ERRNO; /* number of the disk with the start of the central directory */ if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central directory on this disk */ if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central directory */ if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) err=UNZ_ERRNO; if ((number_entry_CD!=us.gi.number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) err=UNZ_BADZIPFILE; /* size of the central directory */ if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) err=UNZ_ERRNO; /* offset of start of central directory with respect to the starting disk number */ if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) err=UNZ_ERRNO; us.gi.size_comment = 0; } else { central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream); if (central_pos==0) err=UNZ_ERRNO; us.isZip64 = 0; if (ZSEEK64(us.z_filefunc, us.filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; /* the signature, already checked */ if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; /* number of this disk */ if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) err=UNZ_ERRNO; /* number of the disk with the start of the central directory */ if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central dir on this disk */ if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; us.gi.number_entry = uL; /* total number of entries in the central dir */ if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; number_entry_CD = uL; if ((number_entry_CD!=us.gi.number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) err=UNZ_BADZIPFILE; /* size of the central directory */ if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; us.size_central_dir = uL; /* offset of start of central directory with respect to the starting disk number */ if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; us.offset_central_dir = uL; /* zipfile comment length */ if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) err=UNZ_ERRNO; } if ((central_pospfile_in_zip_read!=NULL) unzCloseCurrentFile(file); ZCLOSE64(s->z_filefunc, s->filestream); TRYFREE(s); return UNZ_OK; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info) { unz64_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; *pglobal_info=s->gi; return UNZ_OK; } int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32) { unz64_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; /* to do : check if number_entry is not truncated */ pglobal_info32->number_entry = (uLong)s->gi.number_entry; pglobal_info32->size_comment = s->gi.size_comment; return UNZ_OK; } /* Translate date/time from Dos format to tm_unz (readable more easily) */ local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) { ZPOS64_T uDate; uDate = (ZPOS64_T)(ulDosDate>>16); ptm->tm_mday = (uInt)(uDate&0x1f) ; ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; } /* Get Info about the current file in the zipfile, with internal only info */ local int unz64local_GetCurrentFileInfoInternal OF((unzFile file, unz_file_info64 *pfile_info, unz_file_info64_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); local int unz64local_GetCurrentFileInfoInternal (unzFile file, unz_file_info64 *pfile_info, unz_file_info64_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize) { unz64_s* s; unz_file_info64 file_info; unz_file_info64_internal file_info_internal; int err=UNZ_OK; uLong uMagic; long lSeek=0; uLong uL; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; if (ZSEEK64(s->z_filefunc, s->filestream, s->pos_in_central_dir+s->byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; /* we check the magic */ if (err==UNZ_OK) { if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x02014b50) err=UNZ_BADZIPFILE; } if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) err=UNZ_ERRNO; unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) err=UNZ_ERRNO; file_info.compressed_size = uL; if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) err=UNZ_ERRNO; file_info.uncompressed_size = uL; if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) err=UNZ_ERRNO; // relative offset of local header if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) err=UNZ_ERRNO; file_info_internal.offset_curfile = uL; lSeek+=file_info.size_filename; if ((err==UNZ_OK) && (szFileName!=NULL)) { uLong uSizeRead ; if (file_info.size_filename0) && (fileNameBufferSize>0)) if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; lSeek -= uSizeRead; } // Read extrafield if ((err==UNZ_OK) && (extraField!=NULL)) { ZPOS64_T uSizeRead ; if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; } if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead) err=UNZ_ERRNO; lSeek += file_info.size_file_extra - (uLong)uSizeRead; } else lSeek += file_info.size_file_extra; if ((err==UNZ_OK) && (file_info.size_file_extra != 0)) { uLong acc = 0; // since lSeek now points to after the extra field we need to move back lSeek -= file_info.size_file_extra; if (lSeek!=0) { if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; } while(acc < file_info.size_file_extra) { uLong headerId; uLong dataSize; if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK) err=UNZ_ERRNO; /* ZIP64 extra fields */ if (headerId == 0x0001) { uLong uL2; if (file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1) { if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) err=UNZ_ERRNO; } if (file_info.compressed_size == (ZPOS64_T)(unsigned long)-1) { if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) err=UNZ_ERRNO; } if (file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1) { /* Relative Header offset */ if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) err=UNZ_ERRNO; } if(file_info.disk_num_start == (unsigned long)-1) { /* Disk Start Number */ if (unz64local_getLong(&s->z_filefunc, s->filestream, &uL2) != UNZ_OK) err=UNZ_ERRNO; } } else { if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) err=UNZ_ERRNO; } acc += 2 + 2 + dataSize; } } if ((err==UNZ_OK) && (szComment!=NULL)) { uLong uSizeRead ; if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) { //lSeek=0; } else err=UNZ_ERRNO; } if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; //lSeek+=file_info.size_file_comment - uSizeRead; } //else // lSeek+=file_info.size_file_comment; if ((err==UNZ_OK) && (pfile_info!=NULL)) *pfile_info=file_info; if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) *pfile_info_internal=file_info_internal; return err; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ int ZEXPORT unzGetCurrentFileInfo64 (unzFile file, unz_file_info64 * pfile_info, char * szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char* szComment, uLong commentBufferSize) { return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, szFileName,fileNameBufferSize, extraField,extraFieldBufferSize, szComment,commentBufferSize); } int ZEXPORT unzGetCurrentFileInfo (unzFile file, unz_file_info * pfile_info, char * szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char* szComment, uLong commentBufferSize) { int err; unz_file_info64 file_info64; err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, szFileName,fileNameBufferSize, extraField,extraFieldBufferSize, szComment,commentBufferSize); if (err==UNZ_OK) { pfile_info->version = file_info64.version; pfile_info->version_needed = file_info64.version_needed; pfile_info->flag = file_info64.flag; pfile_info->compression_method = file_info64.compression_method; pfile_info->dosDate = file_info64.dosDate; pfile_info->crc = file_info64.crc; pfile_info->size_filename = file_info64.size_filename; pfile_info->size_file_extra = file_info64.size_file_extra; pfile_info->size_file_comment = file_info64.size_file_comment; pfile_info->disk_num_start = file_info64.disk_num_start; pfile_info->internal_fa = file_info64.internal_fa; pfile_info->external_fa = file_info64.external_fa; pfile_info->tmu_date = file_info64.tmu_date, pfile_info->compressed_size = (uLong)file_info64.compressed_size; pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; } return err; } /* Set the current file of the zipfile to the first file with retrieving an information about the file. return UNZ_OK if there is no problem */ int ZEXPORT unzGoToFirstFile64 (unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize) { int err=UNZ_OK; unz64_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; s->pos_in_central_dir=s->offset_central_dir; s->num_file=0; err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, szFileName,fileNameBufferSize,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); if (pfile_info) *pfile_info = s->cur_file_info; return err; } /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ int ZEXPORT unzGoToFirstFile (unzFile file) { return unzGoToFirstFile64(file, NULL, NULL, 0); } /* Set the current file of the zipfile to the next file with retrieving an information about the file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ int ZEXPORT unzGoToNextFile64 (unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize) { unz64_s* s; int err; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ if (s->num_file+1==s->gi.number_entry) return UNZ_END_OF_LIST_OF_FILE; s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; s->num_file++; err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, szFileName,fileNameBufferSize,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); if (pfile_info) *pfile_info = s->cur_file_info; return err; } /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ int ZEXPORT unzGoToNextFile (unzFile file) { return unzGoToNextFile64(file, NULL, NULL, 0); } /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzipStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) { unz64_s* s; int err; /* We remember the 'current' position in the file so that we can jump * back there if we fail. */ unz_file_info64 cur_file_infoSaved; unz_file_info64_internal cur_file_info_internalSaved; ZPOS64_T num_fileSaved; ZPOS64_T pos_in_central_dirSaved; if (file==NULL) return UNZ_PARAMERROR; if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) return UNZ_PARAMERROR; s=(unz64_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; /* Save the current state */ num_fileSaved = s->num_file; pos_in_central_dirSaved = s->pos_in_central_dir; cur_file_infoSaved = s->cur_file_info; cur_file_info_internalSaved = s->cur_file_info_internal; err = unzGoToFirstFile(file); while (err == UNZ_OK) { char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; err = unzGetCurrentFileInfo64(file,NULL, szCurrentFileName,sizeof(szCurrentFileName)-1, NULL,0,NULL,0); if (err == UNZ_OK) { if (unzStringFileNameCompare(szCurrentFileName, szFileName,iCaseSensitivity)==0) return UNZ_OK; err = unzGoToNextFile(file); } } /* We failed, so restore the state of the 'current file' to where we * were. */ s->num_file = num_fileSaved ; s->pos_in_central_dir = pos_in_central_dirSaved ; s->cur_file_info = cur_file_infoSaved; s->cur_file_info_internal = cur_file_info_internalSaved; return err; } /* /////////////////////////////////////////// // Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) // I need random access // // Further optimization could be realized by adding an ability // to cache the directory in memory. The goal being a single // comprehensive file read to put the file I need in a memory. */ /* typedef struct unz_file_pos_s { ZPOS64_T pos_in_zip_directory; // offset in file ZPOS64_T num_of_file; // # of file } unz_file_pos; */ int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) { unz64_s* s; if (file==NULL || file_pos==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; file_pos->pos_in_zip_directory = s->pos_in_central_dir; file_pos->num_of_file = s->num_file; return UNZ_OK; } int ZEXPORT unzGetFilePos( unzFile file, unz_file_pos* file_pos) { unz64_file_pos file_pos64; int err = unzGetFilePos64(file,&file_pos64); if (err==UNZ_OK) { file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory; file_pos->num_of_file = (uLong)file_pos64.num_of_file; } return err; } int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) { unz64_s* s; int err; if (file==NULL || file_pos==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; /* jump to the right spot */ s->pos_in_central_dir = file_pos->pos_in_zip_directory; s->num_file = file_pos->num_of_file; /* set the current file */ err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); /* return results */ s->current_file_ok = (err == UNZ_OK); return err; } int ZEXPORT unzGoToFilePos( unzFile file, unz_file_pos* file_pos) { unz64_file_pos file_pos64; if (file_pos == NULL) return UNZ_PARAMERROR; file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; file_pos64.num_of_file = file_pos->num_of_file; return unzGoToFilePos64(file,&file_pos64); } /* // Unzip Helper Functions - should be here? /////////////////////////////////////////// */ /* Read the local header of the current zipfile Check the coherency of the local header and info in the end of central directory about this file store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */ local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar, ZPOS64_T * poffset_local_extrafield, uInt * psize_local_extrafield) { uLong uMagic,uData,uFlags; uLong size_filename; uLong size_extra_field; int err=UNZ_OK; *piSizeVar = 0; *poffset_local_extrafield = 0; *psize_local_extrafield = 0; if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (err==UNZ_OK) { if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) err=UNZ_BADZIPFILE; } if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) err=UNZ_ERRNO; /* else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) err=UNZ_BADZIPFILE; */ if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) err=UNZ_ERRNO; if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) err=UNZ_BADZIPFILE; if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && /* #ifdef HAVE_BZIP2 */ (s->cur_file_info.compression_method!=Z_BZIP2ED) && /* #endif */ (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ err=UNZ_ERRNO; if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ err=UNZ_ERRNO; else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ err=UNZ_ERRNO; else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) err=UNZ_BADZIPFILE; *piSizeVar += (uInt)size_filename; if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) err=UNZ_ERRNO; *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + size_filename; *psize_local_extrafield = (uInt)size_extra_field; *piSizeVar += (uInt)size_extra_field; return err; } /* Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, int* level, int raw, const char* password) { int err=UNZ_OK; uInt iSizeVar; unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ uInt size_local_extrafield; /* size of the local extra field */ # ifndef NOUNCRYPT char source[12]; # else if (password != NULL) return UNZ_PARAMERROR; # endif if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; if (!s->current_file_ok) return UNZ_PARAMERROR; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) return UNZ_BADZIPFILE; pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s)); if (pfile_in_zip_read_info==NULL) return UNZ_INTERNALERROR; pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; pfile_in_zip_read_info->pos_local_extrafield=0; pfile_in_zip_read_info->raw=raw; if (pfile_in_zip_read_info->read_buffer==NULL) { TRYFREE(pfile_in_zip_read_info); return UNZ_INTERNALERROR; } pfile_in_zip_read_info->stream_initialised=0; if (method!=NULL) *method = (int)s->cur_file_info.compression_method; if (level!=NULL) { *level = 6; switch (s->cur_file_info.flag & 0x06) { case 6 : *level = 1; break; case 4 : *level = 2; break; case 2 : *level = 9; break; } } if ((s->cur_file_info.compression_method!=0) && /* #ifdef HAVE_BZIP2 */ (s->cur_file_info.compression_method!=Z_BZIP2ED) && /* #endif */ (s->cur_file_info.compression_method!=Z_DEFLATED)) { //err=UNZ_BADZIPFILE; } pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; pfile_in_zip_read_info->crc32=0; pfile_in_zip_read_info->total_out_64=0; pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; pfile_in_zip_read_info->filestream=s->filestream; pfile_in_zip_read_info->z_filefunc=s->z_filefunc; pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; pfile_in_zip_read_info->stream.total_out = 0; if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw)) { #ifdef HAVE_BZIP2 pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0; pfile_in_zip_read_info->bstream.bzfree = (free_func)0; pfile_in_zip_read_info->bstream.opaque = (voidpf)0; pfile_in_zip_read_info->bstream.state = (voidpf)0; pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; pfile_in_zip_read_info->stream.zfree = (free_func)0; pfile_in_zip_read_info->stream.opaque = (voidpf)0; pfile_in_zip_read_info->stream.next_in = (voidpf)0; pfile_in_zip_read_info->stream.avail_in = 0; err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0); if (err == Z_OK) pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; else { TRYFREE(pfile_in_zip_read_info); return err; } #else pfile_in_zip_read_info->raw=1; #endif } else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) { pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; pfile_in_zip_read_info->stream.zfree = (free_func)0; pfile_in_zip_read_info->stream.opaque = (voidpf)0; pfile_in_zip_read_info->stream.next_in = 0; pfile_in_zip_read_info->stream.avail_in = 0; err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); if (err == Z_OK) pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; else { TRYFREE(pfile_in_zip_read_info); return err; } /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and * return Z_STREAM_END. * In unzip, i don't wait absolutely Z_STREAM_END because I known the * size of both compressed and uncompressed data */ } pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size ; pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size ; pfile_in_zip_read_info->pos_in_zipfile = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + iSizeVar; pfile_in_zip_read_info->stream.avail_in = (uInt)0; s->pfile_in_zip_read = pfile_in_zip_read_info; s->encrypted = 0; # ifndef NOUNCRYPT if (password != NULL) { int i; s->pcrc_32_tab = get_crc_table(); init_keys(password,s->keys,s->pcrc_32_tab); if (ZSEEK64(s->z_filefunc, s->filestream, s->pfile_in_zip_read->pos_in_zipfile + s->pfile_in_zip_read->byte_before_the_zipfile, SEEK_SET)!=0) return UNZ_INTERNALERROR; if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12) return UNZ_INTERNALERROR; for (i = 0; i<12; i++) zdecode(s->keys,s->pcrc_32_tab,source[i]); s->pfile_in_zip_read->pos_in_zipfile+=12; s->encrypted=1; } # endif return UNZ_OK; } int ZEXPORT unzOpenCurrentFile (unzFile file) { return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); } int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password) { return unzOpenCurrentFile3(file, NULL, NULL, 0, password); } int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw) { return unzOpenCurrentFile3(file, method, level, raw, NULL); } /** Addition for GDAL : START */ ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; s=(unz64_s*)file; if (file==NULL) return 0; //UNZ_PARAMERROR; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return 0; //UNZ_PARAMERROR; return pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile; } /** Addition for GDAL : END */ /* Read bytes from the current file. buf contain buffer where data must be copied len the size of buf. return the number of byte copied if some bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) { int err=UNZ_OK; uInt iRead = 0; unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->read_buffer == NULL) return UNZ_END_OF_LIST_OF_FILE; if (len==0) return 0; pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; pfile_in_zip_read_info->stream.avail_out = (uInt)len; if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && (!(pfile_in_zip_read_info->raw))) pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed; if ((len>pfile_in_zip_read_info->rest_read_compressed+ pfile_in_zip_read_info->stream.avail_in) && (pfile_in_zip_read_info->raw)) pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_compressed+ pfile_in_zip_read_info->stream.avail_in; while (pfile_in_zip_read_info->stream.avail_out>0) { if ((pfile_in_zip_read_info->stream.avail_in==0) && (pfile_in_zip_read_info->rest_read_compressed>0)) { uInt uReadThis = UNZ_BUFSIZE; if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; if (uReadThis == 0) return UNZ_EOF; if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (ZREAD64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->read_buffer, uReadThis)!=uReadThis) return UNZ_ERRNO; # ifndef NOUNCRYPT if(s->encrypted) { uInt i; for(i=0;iread_buffer[i] = zdecode(s->keys,s->pcrc_32_tab, pfile_in_zip_read_info->read_buffer[i]); } # endif pfile_in_zip_read_info->pos_in_zipfile += uReadThis; pfile_in_zip_read_info->rest_read_compressed-=uReadThis; pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->read_buffer; pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; } if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) { uInt uDoCopy,i ; if ((pfile_in_zip_read_info->stream.avail_in == 0) && (pfile_in_zip_read_info->rest_read_compressed == 0)) return (iRead==0) ? UNZ_EOF : iRead; if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) uDoCopy = pfile_in_zip_read_info->stream.avail_out ; else uDoCopy = pfile_in_zip_read_info->stream.avail_in ; for (i=0;istream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy; pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, pfile_in_zip_read_info->stream.next_out, uDoCopy); pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; pfile_in_zip_read_info->stream.avail_in -= uDoCopy; pfile_in_zip_read_info->stream.avail_out -= uDoCopy; pfile_in_zip_read_info->stream.next_out += uDoCopy; pfile_in_zip_read_info->stream.next_in += uDoCopy; pfile_in_zip_read_info->stream.total_out += uDoCopy; iRead += uDoCopy; } else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { #ifdef HAVE_BZIP2 uLong uTotalOutBefore,uTotalOutAfter; const Bytef *bufBefore; uLong uOutThis; pfile_in_zip_read_info->bstream.next_in = (char*)pfile_in_zip_read_info->stream.next_in; pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in; pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in; pfile_in_zip_read_info->bstream.total_in_hi32 = 0; pfile_in_zip_read_info->bstream.next_out = (char*)pfile_in_zip_read_info->stream.next_out; pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out; pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out; pfile_in_zip_read_info->bstream.total_out_hi32 = 0; uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32; bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out; err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream); uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32; uOutThis = uTotalOutAfter-uTotalOutBefore; pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in; pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in; pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32; pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out; pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out; pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32; if (err==BZ_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead; if (err!=BZ_OK) break; #endif } // end Z_BZIP2ED else { ZPOS64_T uTotalOutBefore,uTotalOutAfter; const Bytef *bufBefore; ZPOS64_T uOutThis; int flush=Z_SYNC_FLUSH; uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; bufBefore = pfile_in_zip_read_info->stream.next_out; /* if ((pfile_in_zip_read_info->rest_read_uncompressed == pfile_in_zip_read_info->stream.avail_out) && (pfile_in_zip_read_info->rest_read_compressed == 0)) flush = Z_FINISH; */ err=inflate(&pfile_in_zip_read_info->stream,flush); if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) err = Z_DATA_ERROR; uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uOutThis = uTotalOutAfter-uTotalOutBefore; pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); if (err==Z_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead; if (err!=Z_OK) break; } } if (err==Z_OK) return iRead; return err; } /* Give the current position in uncompressed data */ z_off_t ZEXPORT unztell (unzFile file) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; return (z_off_t)pfile_in_zip_read_info->stream.total_out; } ZPOS64_T ZEXPORT unztell64 (unzFile file) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return (ZPOS64_T)-1; s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return (ZPOS64_T)-1; return pfile_in_zip_read_info->total_out_64; } /* return 1 if the end of file was reached, 0 elsewhere */ int ZEXPORT unzeof (unzFile file) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->rest_read_uncompressed == 0) return 1; else return 0; } /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field that can be read if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len) { unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; uInt read_now; ZPOS64_T size_to_read; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; size_to_read = (pfile_in_zip_read_info->size_local_extrafield - pfile_in_zip_read_info->pos_local_extrafield); if (buf==NULL) return (int)size_to_read; if (len>size_to_read) read_now = (uInt)size_to_read; else read_now = (uInt)len ; if (read_now==0) return 0; if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield, ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (ZREAD64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, buf,read_now)!=read_now) return UNZ_ERRNO; return (int)read_now; } /* Close the file in zip opened with unzipOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ int ZEXPORT unzCloseCurrentFile (unzFile file) { int err=UNZ_OK; unz64_s* s; file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && (!pfile_in_zip_read_info->raw)) { if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) err=UNZ_CRCERROR; } TRYFREE(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) inflateEnd(&pfile_in_zip_read_info->stream); #ifdef HAVE_BZIP2 else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); #endif pfile_in_zip_read_info->stream_initialised = 0; TRYFREE(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; return err; } /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf) { unz64_s* s; uLong uReadThis ; if (file==NULL) return (int)UNZ_PARAMERROR; s=(unz64_s*)file; uReadThis = uSizeBuf; if (uReadThis>s->gi.size_comment) uReadThis = s->gi.size_comment; if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (uReadThis>0) { *szComment='\0'; if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) return UNZ_ERRNO; } if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) *(szComment+s->gi.size_comment)='\0'; return (int)uReadThis; } /* Additions by RX '2004 */ ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) { unz64_s* s; if (file==NULL) return 0; //UNZ_PARAMERROR; s=(unz64_s*)file; if (!s->current_file_ok) return 0; if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) if (s->num_file==s->gi.number_entry) return 0; return s->pos_in_central_dir; } uLong ZEXPORT unzGetOffset (unzFile file) { ZPOS64_T offset64; if (file==NULL) return 0; //UNZ_PARAMERROR; offset64 = unzGetOffset64(file); return (uLong)offset64; } int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) { unz64_s* s; int err; if (file==NULL) return UNZ_PARAMERROR; s=(unz64_s*)file; s->pos_in_central_dir = pos; s->num_file = s->gi.number_entry; /* hack */ err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } int ZEXPORT unzSetOffset (unzFile file, uLong pos) { return unzSetOffset64(file,pos); } } // end of namespace cocos2d ================================================ FILE: cocos2d/external/unzip/unzip.h ================================================ /* unzip.h -- IO for uncompress .zip files using zlib Version 1.1, February 14h, 2010 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) Modifications of Unzip for Zip64 Copyright (C) 2007-2008 Even Rouault Modifications for Zip64 support on both zip and unzip Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) For more info read MiniZip_info.txt --------------------------------------------------------------------------------- Condition of use and distribution are the same than zlib : This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. --------------------------------------------------------------------------------- Changes See header of unzip64.c */ #ifndef _unz64_H #define _unz64_H #include "CCPlatformDefine.h" #ifndef _ZLIB_H #include "zlib.h" #endif #ifndef _ZLIBIOAPI_H #include "ioapi.h" #endif #ifdef HAVE_BZIP2 #include "bzlib.h" #endif #define Z_BZIP2ED 12 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ typedef struct TagunzFile__ { int unused; } unzFile__; typedef unzFile__ *unzFile; #else typedef voidp unzFile; #endif #define UNZ_OK (0) #define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_ERRNO (Z_ERRNO) #define UNZ_EOF (0) #define UNZ_PARAMERROR (-102) #define UNZ_BADZIPFILE (-103) #define UNZ_INTERNALERROR (-104) #define UNZ_CRCERROR (-105) namespace cocos2d { /* tm_unz contain date/time info */ typedef struct tm_unz_s { uInt tm_sec; /* seconds after the minute - [0,59] */ uInt tm_min; /* minutes after the hour - [0,59] */ uInt tm_hour; /* hours since midnight - [0,23] */ uInt tm_mday; /* day of the month - [1,31] */ uInt tm_mon; /* months since January - [0,11] */ uInt tm_year; /* years - [1980..2044] */ } tm_unz; /* unz_global_info structure contain global data about the ZIPfile These data comes from the end of central dir */ typedef struct unz_global_info64_s { ZPOS64_T number_entry; /* total number of entries in the central dir on this disk */ uLong size_comment; /* size of the global comment of the zipfile */ } unz_global_info64; typedef struct unz_global_info_s { uLong number_entry; /* total number of entries in the central dir on this disk */ uLong size_comment; /* size of the global comment of the zipfile */ } unz_global_info; /* unz_file_info contain information about a file in the zipfile */ typedef struct unz_file_info64_s { uLong version; /* version made by 2 bytes */ uLong version_needed; /* version needed to extract 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */ uLong compression_method; /* compression method 2 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong crc; /* crc-32 4 bytes */ ZPOS64_T compressed_size; /* compressed size 8 bytes */ ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */ uLong size_filename; /* filename length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_comment; /* file comment length 2 bytes */ uLong disk_num_start; /* disk number start 2 bytes */ uLong internal_fa; /* internal file attributes 2 bytes */ uLong external_fa; /* external file attributes 4 bytes */ tm_unz tmu_date; } unz_file_info64; typedef struct unz_file_info_s { uLong version; /* version made by 2 bytes */ uLong version_needed; /* version needed to extract 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */ uLong compression_method; /* compression method 2 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong crc; /* crc-32 4 bytes */ uLong compressed_size; /* compressed size 4 bytes */ uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong size_filename; /* filename length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_comment; /* file comment length 2 bytes */ uLong disk_num_start; /* disk number start 2 bytes */ uLong internal_fa; /* internal file attributes 2 bytes */ uLong external_fa; /* external file attributes 4 bytes */ tm_unz tmu_date; } unz_file_info; int CC_DLL unzStringFileNameCompare OF ((const char* fileName1, const char* fileName2, int iCaseSensitivity)); /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is default of your operating system (like 1 on Unix, 2 on Windows) */ unzFile CC_DLL unzOpen OF((const char *path)); unzFile CC_DLL unzOpen64 OF((const void *path)); /* Open a Zip file. path contain the full pathname (by example, on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip". If the zipfile cannot be opened (file don't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. the "64" function take a const void* pointer, because the path is just the value passed to the open64_file_func callback. Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* does not describe the reality */ unzFile CC_DLL unzOpen2 OF((const char *path, zlib_filefunc_def* pzlib_filefunc_def)); /* Open a Zip file, like unzOpen, but provide a set of file low level API for read/write the zip file (see ioapi.h) */ unzFile CC_DLL unzOpen2_64 OF((const void *path, zlib_filefunc64_def* pzlib_filefunc_def)); /* Open a Zip file, like unz64Open, but provide a set of file low level API for read/write the zip file (see ioapi.h) */ int CC_DLL unzClose OF((unzFile file)); /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ int CC_DLL unzGetGlobalInfo OF((unzFile file, unz_global_info *pglobal_info)); int CC_DLL unzGetGlobalInfo64 OF((unzFile file, unz_global_info64 *pglobal_info)); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ int CC_DLL unzGetGlobalComment OF((unzFile file, char *szComment, uLong uSizeBuf)); /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ /***************************************************************************/ /* Unzip package allow you browse the directory of the zipfile */ int CC_DLL unzGoToFirstFile OF((unzFile file)); /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ int CC_DLL unzGoToFirstFile64 OF((unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize)); /* Set the current file of the zipfile to the first file with retrieving an information about the file. return UNZ_OK if there is no problem */ int CC_DLL unzGoToNextFile OF((unzFile file)); /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ int CC_DLL unzGoToNextFile64 OF((unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize)); /* Set the current file of the zipfile to the next file with retrieving an information about the file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ int CC_DLL unzLocateFile OF((unzFile file, const char *szFileName, int iCaseSensitivity)); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ /* ****************************************** */ /* Ryan supplied functions */ /* unz_file_info contain information about a file in the zipfile */ typedef struct unz_file_pos_s { uLong pos_in_zip_directory; /* offset in zip file directory */ uLong num_of_file; /* # of file */ } unz_file_pos; int CC_DLL unzGetFilePos( unzFile file, unz_file_pos* file_pos); int CC_DLL unzGoToFilePos( unzFile file, unz_file_pos* file_pos); typedef struct unz64_file_pos_s { ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */ ZPOS64_T num_of_file; /* # of file */ } unz64_file_pos; int CC_DLL unzGetFilePos64( unzFile file, unz64_file_pos* file_pos); int CC_DLL unzGoToFilePos64( unzFile file, const unz64_file_pos* file_pos); /* ****************************************** */ int CC_DLL unzGetCurrentFileInfo64 OF((unzFile file, unz_file_info64 *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); int CC_DLL unzGetCurrentFileInfo OF((unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); /* Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain some info about the current file if szFileName!=NULL, the filename string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). This is the Central-header version of the extra field if szComment!=NULL, the comment string of the file will be copied in szComment (commentBufferSize is the size of the buffer) */ /** Addition for GDAL : START */ ZPOS64_T CC_DLL unzGetCurrentFileZStreamPos64 OF((unzFile file)); /** Addition for GDAL : END */ /***************************************************************************/ /* for reading the content of the current zipfile, you can open it, read data from it, and close it (you can close it before reading all the file) */ int CC_DLL unzOpenCurrentFile OF((unzFile file)); /* Open for reading data the current file in the zipfile. If there is no error, the return value is UNZ_OK. */ int CC_DLL unzOpenCurrentFilePassword OF((unzFile file, const char* password)); /* Open for reading data the current file in the zipfile. password is a crypting password If there is no error, the return value is UNZ_OK. */ int CC_DLL unzOpenCurrentFile2 OF((unzFile file, int* method, int* level, int raw)); /* Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) if raw==1 *method will receive method of compression, *level will receive level of compression note : you can set level parameter as NULL (if you did not want known level, but you CANNOT set method parameter as NULL */ int CC_DLL unzOpenCurrentFile3 OF((unzFile file, int* method, int* level, int raw, const char* password)); /* Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) if raw==1 *method will receive method of compression, *level will receive level of compression note : you can set level parameter as NULL (if you did not want known level, but you CANNOT set method parameter as NULL */ int CC_DLL unzCloseCurrentFile OF((unzFile file)); /* Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ int CC_DLL unzReadCurrentFile OF((unzFile file, voidp buf, unsigned len)); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied len the size of buf. return the number of byte copied if some bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ z_off_t CC_DLL unztell OF((unzFile file)); ZPOS64_T CC_DLL unztell64 OF((unzFile file)); /* Give the current position in uncompressed data */ int CC_DLL unzeof OF((unzFile file)); /* return 1 if the end of file was reached, 0 elsewhere */ int CC_DLL unzGetLocalExtrafield OF((unzFile file, voidp buf, unsigned len)); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ /***************************************************************************/ /* Get the current file offset */ ZPOS64_T CC_DLL unzGetOffset64 (unzFile file); uLong CC_DLL unzGetOffset (unzFile file); /* Set the current file offset */ int CC_DLL unzSetOffset64 (unzFile file, ZPOS64_T pos); int CC_DLL unzSetOffset (unzFile file, uLong pos); } // end of namespace cocos2d #endif /* _unz64_H */ ================================================ FILE: cocos2d/external/webp/include/android/decode.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Main decoding functions for WebP images. // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_DECODE_H_ #define WEBP_WEBP_DECODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_DECODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the decoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetDecoderVersion(void); // Retrieve basic header information: width, height. // This function will also validate the header and return 0 in // case of formatting error. // Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size, int* width, int* height); // Decodes WebP images pointed to by 'data' and returns RGBA samples, along // with the dimensions in *width and *height. The ordering of samples in // memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). // The returned pointer should be deleted calling free(). // Returns NULL in case of error. WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. // If the bitstream contains transparency, it is ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size, int* width, int* height); // Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer // returned is the Y samples buffer. Upon return, *u and *v will point to // the U and V chroma data. These U and V buffers need NOT be free()'d, // unlike the returned Y luma one. The dimension of the U and V planes // are both (*width + 1) / 2 and (*height + 1)/ 2. // Upon return, the Y buffer has a stride returned as '*stride', while U and V // have a common stride returned as '*uv_stride'. // Return NULL in case of error. // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size, int* width, int* height, uint8_t** u, uint8_t** v, int* stride, int* uv_stride); // These five functions are variants of the above ones, that decode the image // directly into a pre-allocated buffer 'output_buffer'. The maximum storage // available in this buffer is indicated by 'output_buffer_size'. If this // storage is not sufficient (or an error occurred), NULL is returned. // Otherwise, output_buffer is returned, for convenience. // The parameter 'output_stride' specifies the distance (in bytes) // between scanlines. Hence, output_buffer_size is expected to be at least // output_stride x picture-height. WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // RGB and BGR variants. Here too the transparency information, if present, // will be dropped and ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly // into pre-allocated luma/chroma plane buffers. This function requires the // strides to be passed: one for the luma plane and one for each of the // chroma ones. The size of each plane buffer is passed as 'luma_size', // 'u_size' and 'v_size' respectively. // Pointer to the luma plane ('*luma') is returned or NULL if an error occurred // during decoding (or because some buffers were found to be too small). WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto( const uint8_t* data, size_t data_size, uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); //------------------------------------------------------------------------------ // Output colorspaces and buffer // Colorspaces // Note: the naming describes the byte-ordering of packed samples in memory. // For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,... // Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels. // RGB-565 and RGBA-4444 are also endian-agnostic and byte-oriented. typedef enum { MODE_RGB = 0, MODE_RGBA = 1, MODE_BGR = 2, MODE_BGRA = 3, MODE_ARGB = 4, MODE_RGBA_4444 = 5, MODE_RGB_565 = 6, // RGB-premultiplied transparent modes (alpha value is preserved) MODE_rgbA = 7, MODE_bgrA = 8, MODE_Argb = 9, MODE_rgbA_4444 = 10, // YUV modes must come after RGB ones. MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0 MODE_LAST = 13 } WEBP_CSP_MODE; // Some useful macros: static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) { return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb || mode == MODE_rgbA_4444); } static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) { return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB || mode == MODE_RGBA_4444 || mode == MODE_YUVA || WebPIsPremultipliedMode(mode)); } static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) { return (mode < MODE_YUV); } //------------------------------------------------------------------------------ // WebPDecBuffer: Generic structure for describing the output sample buffer. typedef struct { // view as RGBA uint8_t* rgba; // pointer to RGBA samples int stride; // stride in bytes from one scanline to the next. size_t size; // total size of the *rgba buffer. } WebPRGBABuffer; typedef struct { // view as YUVA uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples int y_stride; // luma stride int u_stride, v_stride; // chroma strides int a_stride; // alpha stride size_t y_size; // luma plane size size_t u_size, v_size; // chroma planes size size_t a_size; // alpha-plane size } WebPYUVABuffer; // Output buffer typedef struct { WEBP_CSP_MODE colorspace; // Colorspace. int width, height; // Dimensions. int is_external_memory; // If true, 'internal_memory' pointer is not used. union { WebPRGBABuffer RGBA; WebPYUVABuffer YUVA; } u; // Nameless union of buffer parameters. uint32_t pad[4]; // padding for later use uint8_t* private_memory; // Internally allocated memory (only when // is_external_memory is false). Should not be used // externally, but accessed via the buffer union. } WebPDecBuffer; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int); // Initialize the structure as empty. Must be called before any other use. // Returns false in case of version mismatch static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) { return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION); } // Free any memory associated with the buffer. Must always be called last. // Note: doesn't free the 'buffer' structure itself. WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer); //------------------------------------------------------------------------------ // Enumeration of the status codes typedef enum { VP8_STATUS_OK = 0, VP8_STATUS_OUT_OF_MEMORY, VP8_STATUS_INVALID_PARAM, VP8_STATUS_BITSTREAM_ERROR, VP8_STATUS_UNSUPPORTED_FEATURE, VP8_STATUS_SUSPENDED, VP8_STATUS_USER_ABORT, VP8_STATUS_NOT_ENOUGH_DATA } VP8StatusCode; //------------------------------------------------------------------------------ // Incremental decoding // // This API allows streamlined decoding of partial data. // Picture can be incrementally decoded as data become available thanks to the // WebPIDecoder object. This object can be left in a SUSPENDED state if the // picture is only partially decoded, pending additional input. // Code example: // // WebPInitDecBuffer(&buffer); // buffer.colorspace = mode; // ... // WebPIDecoder* idec = WebPINewDecoder(&buffer); // while (has_more_data) { // // ... (get additional data) // status = WebPIAppend(idec, new_data, new_data_size); // if (status != VP8_STATUS_SUSPENDED || // break; // } // // // The above call decodes the current available buffer. // // Part of the image can now be refreshed by calling to // // WebPIDecGetRGB()/WebPIDecGetYUVA() etc. // } // WebPIDelete(idec); typedef struct WebPIDecoder WebPIDecoder; // Creates a new incremental decoder with the supplied buffer parameter. // This output_buffer can be passed NULL, in which case a default output buffer // is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' // is kept, which means that the lifespan of 'output_buffer' must be larger than // that of the returned WebPIDecoder object. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer); // This function allocates and initializes an incremental-decoder object, which // will output the RGB/A samples specified by 'csp' into a preallocated // buffer 'output_buffer'. The size of this buffer is at least // 'output_buffer_size' and the stride (distance in bytes between two scanlines) // is specified by 'output_stride'. Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewRGB( WEBP_CSP_MODE csp, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // This function allocates and initializes an incremental-decoder object, which // will output the raw luma/chroma samples into a preallocated planes. The luma // plane is specified by its pointer 'luma', its size 'luma_size' and its stride // 'luma_stride'. Similarly, the chroma-u plane is specified by the 'u', // 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v' // and 'v_size'. And same for the alpha-plane. The 'a' pointer can be pass // NULL in case one is not interested in the transparency plane. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewYUVA( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride, uint8_t* a, size_t a_size, int a_stride); // Deprecated version of the above, without the alpha plane. // Kept for backward compatibility. WEBP_EXTERN(WebPIDecoder*) WebPINewYUV( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); // Deletes the WebPIDecoder object and associated memory. Must always be called // if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded. WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec); // Copies and decodes the next available data. Returns VP8_STATUS_OK when // the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more // data is expected. Returns error in other cases. WEBP_EXTERN(VP8StatusCode) WebPIAppend( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // A variant of the above function to be used when data buffer contains // partial data from the beginning. In this case data buffer is not copied // to the internal memory. // Note that the value of the 'data' pointer can change between calls to // WebPIUpdate, for instance when the data buffer is resized to fit larger data. WEBP_EXTERN(VP8StatusCode) WebPIUpdate( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // Returns the RGB/A image decoded so far. Returns NULL if output params // are not initialized yet. The RGB/A output type corresponds to the colorspace // specified during call to WebPINewDecoder() or WebPINewRGB(). // *last_y is the index of last decoded row in raster scan order. Some pointers // (*last_y, *width etc.) can be NULL if corresponding information is not // needed. WEBP_EXTERN(uint8_t*) WebPIDecGetRGB( const WebPIDecoder* idec, int* last_y, int* width, int* height, int* stride); // Same as above function to get a YUVA image. Returns pointer to the luma // plane or NULL in case of error. If there is no alpha information // the alpha pointer '*a' will be returned NULL. WEBP_EXTERN(uint8_t*) WebPIDecGetYUVA( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, uint8_t** a, int* width, int* height, int* stride, int* uv_stride, int* a_stride); // Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the // alpha information (if present). Kept for backward compatibility. static WEBP_INLINE uint8_t* WebPIDecGetYUV( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, int* width, int* height, int* stride, int* uv_stride) { return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height, stride, uv_stride, NULL); } // Generic call to retrieve information about the displayable area. // If non NULL, the left/right/width/height pointers are filled with the visible // rectangular area so far. // Returns NULL in case the incremental decoder object is in an invalid state. // Otherwise returns the pointer to the internal representation. This structure // is read-only, tied to WebPIDecoder's lifespan and should not be modified. WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea( const WebPIDecoder* idec, int* left, int* top, int* width, int* height); //------------------------------------------------------------------------------ // Advanced decoding parametrization // // Code sample for using the advanced decoding API /* // A) Init a configuration object WebPDecoderConfig config; CHECK(WebPInitDecoderConfig(&config)); // B) optional: retrieve the bitstream's features. CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK); // C) Adjust 'config', if needed config.no_fancy = 1; config.output.colorspace = MODE_BGRA; // etc. // Note that you can also make config.output point to an externally // supplied memory buffer, provided it's big enough to store the decoded // picture. Otherwise, config.output will just be used to allocate memory // and store the decoded picture. // D) Decode! CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK); // E) Decoded image is now in config.output (and config.output.u.RGBA) // F) Reclaim memory allocated in config's object. It's safe to call // this function even if the memory is external and wasn't allocated // by WebPDecode(). WebPFreeDecBuffer(&config.output); */ // Features gathered from the bitstream typedef struct { int width; // Width in pixels, as read from the bitstream. int height; // Height in pixels, as read from the bitstream. int has_alpha; // True if the bitstream contains an alpha channel. // Unused for now: int bitstream_version; // should be 0 for now. TODO(later) int no_incremental_decoding; // if true, using incremental decoding is not // recommended. int rotate; // TODO(later) int uv_sampling; // should be 0 for now. TODO(later) uint32_t pad[3]; // padding for later use } WebPBitstreamFeatures; // Internal, version-checked, entry point WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal( const uint8_t*, size_t, WebPBitstreamFeatures*, int); // Retrieve features from the bitstream. The *features structure is filled // with information gathered from the bitstream. // Returns false in case of error or version mismatch. // In case of error, features->bitstream_status will reflect the error code. static WEBP_INLINE VP8StatusCode WebPGetFeatures( const uint8_t* data, size_t data_size, WebPBitstreamFeatures* features) { return WebPGetFeaturesInternal(data, data_size, features, WEBP_DECODER_ABI_VERSION); } // Decoding options typedef struct { int bypass_filtering; // if true, skip the in-loop filtering int no_fancy_upsampling; // if true, use faster pointwise upsampler int use_cropping; // if true, cropping is applied _first_ int crop_left, crop_top; // top-left position for cropping. // Will be snapped to even values. int crop_width, crop_height; // dimension of the cropping area int use_scaling; // if true, scaling is applied _afterward_ int scaled_width, scaled_height; // final resolution int use_threads; // if true, use multi-threaded decoding // Unused for now: int force_rotation; // forced rotation (to be applied _last_) int no_enhancement; // if true, discard enhancement layer uint32_t pad[6]; // padding for later use } WebPDecoderOptions; // Main object storing the configuration for advanced decoding. typedef struct { WebPBitstreamFeatures input; // Immutable bitstream features (optional) WebPDecBuffer output; // Output buffer (can point to external mem) WebPDecoderOptions options; // Decoding options } WebPDecoderConfig; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int); // Initialize the configuration as empty. This function must always be // called first, unless WebPGetFeatures() is to be called. // Returns false in case of mismatched version. static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) { return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION); } // Instantiate a new incremental decoder object with the requested // configuration. The bitstream can be passed using 'data' and 'data_size' // parameter, in which case the features will be parsed and stored into // config->input. Otherwise, 'data' can be NULL and no parsing will occur. // Note that 'config' can be NULL too, in which case a default configuration // is used. // The return WebPIDecoder object must always be deleted calling WebPIDelete(). // Returns NULL in case of error (and config->status will then reflect // the error condition). WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); // Non-incremental version. This version decodes the full data at once, taking // 'config' into account. Returns decoding status (which should be VP8_STATUS_OK // if the decoding was successful). WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_DECODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/android/encode.h ================================================ // Copyright 2011 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // WebP encoder: main interface // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_ENCODE_H_ #define WEBP_WEBP_ENCODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_ENCODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the encoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetEncoderVersion(void); //------------------------------------------------------------------------------ // One-stop-shop call! No questions asked: // Returns the size of the compressed data (pointed to by *output), or 0 if // an error occurred. The compressed data must be released by the caller // using the call 'free(*output)'. // These functions compress using the lossy format, and the quality_factor // can go from 0 (smaller output, lower quality) to 100 (best quality, // larger output). WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride, float quality_factor, uint8_t** output); // These functions are the equivalent of the above, but compressing in a // lossless manner. Files are usually larger than lossy format, but will // not suffer any compression loss. WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height, int stride, uint8_t** output); //------------------------------------------------------------------------------ // Coding parameters // Image characteristics hint for the underlying encoder. typedef enum { WEBP_HINT_DEFAULT = 0, // default preset. WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). WEBP_HINT_LAST } WebPImageHint; typedef struct { int lossless; // Lossless encoding (0=lossy(default), 1=lossless). float quality; // between 0 (smallest file) and 100 (biggest) int method; // quality/speed trade-off (0=fast, 6=slower-better) WebPImageHint image_hint; // Hint for image type (lossless only for now). // Parameters related to lossy compression only: int target_size; // if non-zero, set the desired target size in bytes. // Takes precedence over the 'compression' parameter. float target_PSNR; // if non-zero, specifies the minimal distortion to // try to achieve. Takes precedence over target_size. int segments; // maximum number of segments to use, in [1..4] int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum. int filter_strength; // range: [0 = off .. 100 = strongest] int filter_sharpness; // range: [0 = off .. 7 = least sharp] int filter_type; // filtering type: 0 = simple, 1 = strong (only used // if filter_strength > 0 or autofilter > 0) int autofilter; // Auto adjust filter's strength [0 = off, 1 = on] int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, // 1 = compressed with WebP lossless). Default is 1. int alpha_filtering; // Predictive filtering method for alpha plane. // 0: none, 1: fast, 2: best. Default if 1. int alpha_quality; // Between 0 (smallest size) and 100 (lossless). // Default is 100. int pass; // number of entropy-analysis passes (in [1..10]). int show_compressed; // if true, export the compressed picture back. // In-loop filtering is not applied. int preprocessing; // preprocessing filter (0=none, 1=segment-smooth) int partitions; // log2(number of token partitions) in [0..3]. Default // is set to 0 for easier progressive decoding. int partition_limit; // quality degradation allowed to fit the 512k limit // on prediction modes coding (0: no degradation, // 100: maximum possible degradation). uint32_t pad[8]; // padding for later use } WebPConfig; // Enumerate some predefined settings for WebPConfig, depending on the type // of source picture. These presets are used when calling WebPConfigPreset(). typedef enum { WEBP_PRESET_DEFAULT = 0, // default preset. WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details WEBP_PRESET_ICON, // small-sized colorful images WEBP_PRESET_TEXT // text-like } WebPPreset; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int); // Should always be called, to initialize a fresh WebPConfig structure before // modification. Returns false in case of version mismatch. WebPConfigInit() // must have succeeded before using the 'config' object. // Note that the default values are lossless=0 and quality=75. static WEBP_INLINE int WebPConfigInit(WebPConfig* config) { return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, WEBP_ENCODER_ABI_VERSION); } // This function will initialize the configuration according to a predefined // set of parameters (referred to by 'preset') and a given quality factor. // This function can be called as a replacement to WebPConfigInit(). Will // return false in case of error. static WEBP_INLINE int WebPConfigPreset(WebPConfig* config, WebPPreset preset, float quality) { return WebPConfigInitInternal(config, preset, quality, WEBP_ENCODER_ABI_VERSION); } // Returns true if 'config' is non-NULL and all configuration parameters are // within their valid ranges. WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config); //------------------------------------------------------------------------------ // Input / Output typedef struct WebPPicture WebPPicture; // main structure for I/O // Structure for storing auxiliary statistics (mostly for lossy encoding). typedef struct { int coded_size; // final size float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha int block_count[3]; // number of intra4/intra16/skipped macroblocks int header_bytes[2]; // approximate number of bytes spent for header // and mode-partition #0 int residual_bytes[3][4]; // approximate number of bytes spent for // DC/AC/uv coefficients for each (0..3) segments. int segment_size[4]; // number of macroblocks in each segments int segment_quant[4]; // quantizer values for each segments int segment_level[4]; // filtering strength for each segments [0..63] int alpha_data_size; // size of the transparency data int layer_data_size; // size of the enhancement layer data // lossless encoder statistics uint32_t lossless_features; // bit0:predictor bit1:cross-color transform // bit2:subtract-green bit3:color indexing int histogram_bits; // number of precision bits of histogram int transform_bits; // precision bits for transform int cache_bits; // number of bits for color cache lookup int palette_size; // number of color in palette, if used int lossless_size; // final lossless size uint32_t pad[4]; // padding for later use } WebPAuxStats; // Signature for output function. Should return true if writing was successful. // data/data_size is the segment of data to write, and 'picture' is for // reference (and so one can make use of picture->custom_ptr). typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size, const WebPPicture* picture); // WebPMemoryWrite: a special WebPWriterFunction that writes to memory using // the following WebPMemoryWriter object (to be set as a custom_ptr). typedef struct { uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). size_t size; // final size size_t max_size; // total capacity uint32_t pad[1]; // padding for later use } WebPMemoryWriter; // The following must be called first before any use. WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer); // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon // completion, writer.mem and writer.size will hold the coded data. WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, const WebPPicture* picture); // Progress hook, called from time to time to report progress. It can return // false to request an abort of the encoding process, or true otherwise if // everything is OK. typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture); typedef enum { // chroma sampling WEBP_YUV420 = 0, // 4:2:0 WEBP_YUV422 = 1, // 4:2:2 WEBP_YUV444 = 2, // 4:4:4 WEBP_YUV400 = 3, // grayscale WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors // alpha channel variants WEBP_YUV420A = 4, WEBP_YUV422A = 5, WEBP_YUV444A = 6, WEBP_YUV400A = 7, // grayscale + alpha WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present } WebPEncCSP; // Encoding error conditions. typedef enum { VP8_ENC_OK = 0, VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G VP8_ENC_ERROR_USER_ABORT, // abort request by user VP8_ENC_ERROR_LAST // list terminator. always last. } WebPEncodingError; // maximum width/height allowed (inclusive), in pixels #define WEBP_MAX_DIMENSION 16383 // Main exchange structure (input samples, output bytes, statistics) struct WebPPicture { // INPUT ////////////// // Main flag for encoder selecting between ARGB or YUV input. // It is recommended to use ARGB input (*argb, argb_stride) for lossless // compression, and YUV input (*y, *u, *v, etc.) for lossy compression // since these are the respective native colorspace for these formats. int use_argb; // YUV input (mostly used for input to lossy compression) WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION) uint8_t *y, *u, *v; // pointers to luma/chroma planes. int y_stride, uv_stride; // luma/chroma strides. uint8_t* a; // pointer to the alpha plane int a_stride; // stride of the alpha plane uint32_t pad1[2]; // padding for later use // ARGB input (mostly used for input to lossless compression) uint32_t* argb; // Pointer to argb (32 bit) plane. int argb_stride; // This is stride in pixels units, not bytes. uint32_t pad2[3]; // padding for later use // OUTPUT /////////////// // Byte-emission hook, to store compressed bytes as they are ready. WebPWriterFunction writer; // can be NULL void* custom_ptr; // can be used by the writer. // map for extra information (only for lossy compression mode) int extra_info_type; // 1: intra type, 2: segment, 3: quant // 4: intra-16 prediction mode, // 5: chroma prediction mode, // 6: bit cost, 7: distortion uint8_t* extra_info; // if not NULL, points to an array of size // ((width + 15) / 16) * ((height + 15) / 16) that // will be filled with a macroblock map, depending // on extra_info_type. // STATS AND REPORTS /////////////////////////// // Pointer to side statistics (updated only if not NULL) WebPAuxStats* stats; // Error code for the latest error encountered during encoding WebPEncodingError error_code; // If not NULL, report progress during encoding. WebPProgressHook progress_hook; void* user_data; // this field is free to be set to any value and // used during callbacks (like progress-report e.g.). uint32_t pad3[3]; // padding for later use // Unused for now: original samples (for non-YUV420 modes) uint8_t *u0, *v0; int uv0_stride; uint32_t pad4[7]; // padding for later use // PRIVATE FIELDS //////////////////// void* memory_; // row chunk of memory for yuva planes void* memory_argb_; // and for argb too. void* pad5[2]; // padding for later use }; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int); // Should always be called, to initialize the structure. Returns false in case // of version mismatch. WebPPictureInit() must have succeeded before using the // 'picture' object. // Note that, by default, use_argb is false and colorspace is WEBP_YUV420. static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) { return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); } //------------------------------------------------------------------------------ // WebPPicture utils // Convenience allocation / deallocation based on picture->width/height: // Allocate y/u/v buffers as per colorspace/width/height specification. // Note! This function will free the previous buffer if needed. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture); // Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). // Note that this function does _not_ free the memory used by the 'picture' // object itself. // Besides memory (which is reclaimed) all other fields of 'picture' are // preserved. WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture); // Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, // *dst will fully own the copied pixels (this is not a view). // Returns false in case of memory allocation error. WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); // Compute PSNR or SSIM distortion between two pictures. // Result is in dB, stores in result[] in the Y/U/V/Alpha/All order. // Returns false in case of error (pic1 and pic2 don't have same dimension, ...) // Warning: this function is rather CPU-intensive. WEBP_EXTERN(int) WebPPictureDistortion( const WebPPicture* pic1, const WebPPicture* pic2, int metric_type, // 0 = PSNR, 1 = SSIM float result[5]); // self-crops a picture to the rectangle defined by top/left/width/height. // Returns false in case of memory allocation error, or if the rectangle is // outside of the source picture. // The rectangle for the view is defined by the top-left corner pixel // coordinates (left, top) as well as its width and height. This rectangle // must be fully be comprised inside the 'src' source picture. If the source // picture uses the YUV420 colorspace, the top and left coordinates will be // snapped to even values. WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture, int left, int top, int width, int height); // Extracts a view from 'src' picture into 'dst'. The rectangle for the view // is defined by the top-left corner pixel coordinates (left, top) as well // as its width and height. This rectangle must be fully be comprised inside // the 'src' source picture. If the source picture uses the YUV420 colorspace, // the top and left coordinates will be snapped to even values. // Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed // ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, // the original dimension will be lost). // Returns false in case of memory allocation error or invalid parameters. WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src, int left, int top, int width, int height, WebPPicture* dst); // Returns true if the 'picture' is actually a view and therefore does // not own the memory for pixels. WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture); // Rescale a picture to new dimension width x height. // Now gamma correction is applied. // Returns false in case of error (invalid parameter or insufficient memory). WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height); // Colorspace conversion function to import RGB samples. // Previous buffer will be free'd, if any. // *rgb buffer should have a size of at least height * rgb_stride. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureImportRGB( WebPPicture* picture, const uint8_t* rgb, int rgb_stride); // Same, but for RGBA buffer. WEBP_EXTERN(int) WebPPictureImportRGBA( WebPPicture* picture, const uint8_t* rgba, int rgba_stride); // Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format // input buffer ignoring the alpha channel. Avoids needing to copy the data // to a temporary 24-bit RGB buffer to import the RGB only. WEBP_EXTERN(int) WebPPictureImportRGBX( WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); // Variants of the above, but taking BGR(A|X) input. WEBP_EXTERN(int) WebPPictureImportBGR( WebPPicture* picture, const uint8_t* bgr, int bgr_stride); WEBP_EXTERN(int) WebPPictureImportBGRA( WebPPicture* picture, const uint8_t* bgra, int bgra_stride); WEBP_EXTERN(int) WebPPictureImportBGRX( WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); // Converts picture->argb data to the YUVA format specified by 'colorspace'. // Upon return, picture->use_argb is set to false. The presence of real // non-opaque transparent values is detected, and 'colorspace' will be // adjusted accordingly. Note that this method is lossy. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace); // Converts picture->yuv to picture->argb and sets picture->use_argb to true. // The input format must be YUV_420 or YUV_420A. // Note that the use of this method is discouraged if one has access to the // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the // conversion from YUV420 to ARGB incurs a small loss too. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); // Helper function: given a width x height plane of YUV(A) samples // (with stride 'stride'), clean-up the YUV samples under fully transparent // area, to help compressibility (no guarantee, though). WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); // Scan the picture 'picture' for the presence of non fully opaque alpha values. // Returns true in such case. Otherwise returns false (indicating that the // alpha plane can be ignored altogether e.g.). WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); //------------------------------------------------------------------------------ // Main call // Main encoding call, after config and picture have been initialized. // 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), // and the 'config' object must be a valid one. // Returns false in case of error, true otherwise. // In case of error, picture->error_code is updated accordingly. // 'picture' can hold the source samples in both YUV(A) or ARGB input, depending // on the value of 'picture->use_argb'. It is highly recommended to use // the former for lossy encoding, and the latter for lossless encoding // (when config.lossless is true). Automatic conversion from one format to // another is provided but they both incur some loss. WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_ENCODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/android/types.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Common types // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_TYPES_H_ #define WEBP_WEBP_TYPES_H_ #include // for size_t #ifndef _MSC_VER #include #ifdef __STRICT_ANSI__ #define WEBP_INLINE #else /* __STRICT_ANSI__ */ #define WEBP_INLINE inline #endif #else typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef unsigned long long int uint64_t; typedef long long int int64_t; #define WEBP_INLINE __forceinline #endif /* _MSC_VER */ #ifndef WEBP_EXTERN // This explicitly marks library functions and allows for changing the // signature for e.g., Windows DLL builds. #define WEBP_EXTERN(type) extern type #endif /* WEBP_EXTERN */ // Macro to check ABI compatibility (same major revision number) #define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8)) #endif /* WEBP_WEBP_TYPES_H_ */ ================================================ FILE: cocos2d/external/webp/include/ios/decode.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Main decoding functions for WebP images. // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_DECODE_H_ #define WEBP_WEBP_DECODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_DECODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the decoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetDecoderVersion(void); // Retrieve basic header information: width, height. // This function will also validate the header and return 0 in // case of formatting error. // Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size, int* width, int* height); // Decodes WebP images pointed to by 'data' and returns RGBA samples, along // with the dimensions in *width and *height. The ordering of samples in // memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). // The returned pointer should be deleted calling free(). // Returns NULL in case of error. WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. // If the bitstream contains transparency, it is ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size, int* width, int* height); // Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer // returned is the Y samples buffer. Upon return, *u and *v will point to // the U and V chroma data. These U and V buffers need NOT be free()'d, // unlike the returned Y luma one. The dimension of the U and V planes // are both (*width + 1) / 2 and (*height + 1)/ 2. // Upon return, the Y buffer has a stride returned as '*stride', while U and V // have a common stride returned as '*uv_stride'. // Return NULL in case of error. // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size, int* width, int* height, uint8_t** u, uint8_t** v, int* stride, int* uv_stride); // These five functions are variants of the above ones, that decode the image // directly into a pre-allocated buffer 'output_buffer'. The maximum storage // available in this buffer is indicated by 'output_buffer_size'. If this // storage is not sufficient (or an error occurred), NULL is returned. // Otherwise, output_buffer is returned, for convenience. // The parameter 'output_stride' specifies the distance (in bytes) // between scanlines. Hence, output_buffer_size is expected to be at least // output_stride x picture-height. WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // RGB and BGR variants. Here too the transparency information, if present, // will be dropped and ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly // into pre-allocated luma/chroma plane buffers. This function requires the // strides to be passed: one for the luma plane and one for each of the // chroma ones. The size of each plane buffer is passed as 'luma_size', // 'u_size' and 'v_size' respectively. // Pointer to the luma plane ('*luma') is returned or NULL if an error occurred // during decoding (or because some buffers were found to be too small). WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto( const uint8_t* data, size_t data_size, uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); //------------------------------------------------------------------------------ // Output colorspaces and buffer // Colorspaces // Note: the naming describes the byte-ordering of packed samples in memory. // For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,... // Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels. // RGB-565 and RGBA-4444 are also endian-agnostic and byte-oriented. typedef enum { MODE_RGB = 0, MODE_RGBA = 1, MODE_BGR = 2, MODE_BGRA = 3, MODE_ARGB = 4, MODE_RGBA_4444 = 5, MODE_RGB_565 = 6, // RGB-premultiplied transparent modes (alpha value is preserved) MODE_rgbA = 7, MODE_bgrA = 8, MODE_Argb = 9, MODE_rgbA_4444 = 10, // YUV modes must come after RGB ones. MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0 MODE_LAST = 13 } WEBP_CSP_MODE; // Some useful macros: static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) { return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb || mode == MODE_rgbA_4444); } static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) { return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB || mode == MODE_RGBA_4444 || mode == MODE_YUVA || WebPIsPremultipliedMode(mode)); } static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) { return (mode < MODE_YUV); } //------------------------------------------------------------------------------ // WebPDecBuffer: Generic structure for describing the output sample buffer. typedef struct { // view as RGBA uint8_t* rgba; // pointer to RGBA samples int stride; // stride in bytes from one scanline to the next. size_t size; // total size of the *rgba buffer. } WebPRGBABuffer; typedef struct { // view as YUVA uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples int y_stride; // luma stride int u_stride, v_stride; // chroma strides int a_stride; // alpha stride size_t y_size; // luma plane size size_t u_size, v_size; // chroma planes size size_t a_size; // alpha-plane size } WebPYUVABuffer; // Output buffer typedef struct { WEBP_CSP_MODE colorspace; // Colorspace. int width, height; // Dimensions. int is_external_memory; // If true, 'internal_memory' pointer is not used. union { WebPRGBABuffer RGBA; WebPYUVABuffer YUVA; } u; // Nameless union of buffer parameters. uint32_t pad[4]; // padding for later use uint8_t* private_memory; // Internally allocated memory (only when // is_external_memory is false). Should not be used // externally, but accessed via the buffer union. } WebPDecBuffer; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int); // Initialize the structure as empty. Must be called before any other use. // Returns false in case of version mismatch static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) { return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION); } // Free any memory associated with the buffer. Must always be called last. // Note: doesn't free the 'buffer' structure itself. WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer); //------------------------------------------------------------------------------ // Enumeration of the status codes typedef enum { VP8_STATUS_OK = 0, VP8_STATUS_OUT_OF_MEMORY, VP8_STATUS_INVALID_PARAM, VP8_STATUS_BITSTREAM_ERROR, VP8_STATUS_UNSUPPORTED_FEATURE, VP8_STATUS_SUSPENDED, VP8_STATUS_USER_ABORT, VP8_STATUS_NOT_ENOUGH_DATA } VP8StatusCode; //------------------------------------------------------------------------------ // Incremental decoding // // This API allows streamlined decoding of partial data. // Picture can be incrementally decoded as data become available thanks to the // WebPIDecoder object. This object can be left in a SUSPENDED state if the // picture is only partially decoded, pending additional input. // Code example: // // WebPInitDecBuffer(&buffer); // buffer.colorspace = mode; // ... // WebPIDecoder* idec = WebPINewDecoder(&buffer); // while (has_more_data) { // // ... (get additional data) // status = WebPIAppend(idec, new_data, new_data_size); // if (status != VP8_STATUS_SUSPENDED || // break; // } // // // The above call decodes the current available buffer. // // Part of the image can now be refreshed by calling to // // WebPIDecGetRGB()/WebPIDecGetYUVA() etc. // } // WebPIDelete(idec); typedef struct WebPIDecoder WebPIDecoder; // Creates a new incremental decoder with the supplied buffer parameter. // This output_buffer can be passed NULL, in which case a default output buffer // is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' // is kept, which means that the lifespan of 'output_buffer' must be larger than // that of the returned WebPIDecoder object. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer); // This function allocates and initializes an incremental-decoder object, which // will output the RGB/A samples specified by 'csp' into a preallocated // buffer 'output_buffer'. The size of this buffer is at least // 'output_buffer_size' and the stride (distance in bytes between two scanlines) // is specified by 'output_stride'. Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewRGB( WEBP_CSP_MODE csp, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // This function allocates and initializes an incremental-decoder object, which // will output the raw luma/chroma samples into a preallocated planes. The luma // plane is specified by its pointer 'luma', its size 'luma_size' and its stride // 'luma_stride'. Similarly, the chroma-u plane is specified by the 'u', // 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v' // and 'v_size'. And same for the alpha-plane. The 'a' pointer can be pass // NULL in case one is not interested in the transparency plane. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewYUVA( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride, uint8_t* a, size_t a_size, int a_stride); // Deprecated version of the above, without the alpha plane. // Kept for backward compatibility. WEBP_EXTERN(WebPIDecoder*) WebPINewYUV( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); // Deletes the WebPIDecoder object and associated memory. Must always be called // if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded. WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec); // Copies and decodes the next available data. Returns VP8_STATUS_OK when // the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more // data is expected. Returns error in other cases. WEBP_EXTERN(VP8StatusCode) WebPIAppend( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // A variant of the above function to be used when data buffer contains // partial data from the beginning. In this case data buffer is not copied // to the internal memory. // Note that the value of the 'data' pointer can change between calls to // WebPIUpdate, for instance when the data buffer is resized to fit larger data. WEBP_EXTERN(VP8StatusCode) WebPIUpdate( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // Returns the RGB/A image decoded so far. Returns NULL if output params // are not initialized yet. The RGB/A output type corresponds to the colorspace // specified during call to WebPINewDecoder() or WebPINewRGB(). // *last_y is the index of last decoded row in raster scan order. Some pointers // (*last_y, *width etc.) can be NULL if corresponding information is not // needed. WEBP_EXTERN(uint8_t*) WebPIDecGetRGB( const WebPIDecoder* idec, int* last_y, int* width, int* height, int* stride); // Same as above function to get a YUVA image. Returns pointer to the luma // plane or NULL in case of error. If there is no alpha information // the alpha pointer '*a' will be returned NULL. WEBP_EXTERN(uint8_t*) WebPIDecGetYUVA( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, uint8_t** a, int* width, int* height, int* stride, int* uv_stride, int* a_stride); // Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the // alpha information (if present). Kept for backward compatibility. static WEBP_INLINE uint8_t* WebPIDecGetYUV( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, int* width, int* height, int* stride, int* uv_stride) { return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height, stride, uv_stride, NULL); } // Generic call to retrieve information about the displayable area. // If non NULL, the left/right/width/height pointers are filled with the visible // rectangular area so far. // Returns NULL in case the incremental decoder object is in an invalid state. // Otherwise returns the pointer to the internal representation. This structure // is read-only, tied to WebPIDecoder's lifespan and should not be modified. WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea( const WebPIDecoder* idec, int* left, int* top, int* width, int* height); //------------------------------------------------------------------------------ // Advanced decoding parametrization // // Code sample for using the advanced decoding API /* // A) Init a configuration object WebPDecoderConfig config; CHECK(WebPInitDecoderConfig(&config)); // B) optional: retrieve the bitstream's features. CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK); // C) Adjust 'config', if needed config.no_fancy = 1; config.output.colorspace = MODE_BGRA; // etc. // Note that you can also make config.output point to an externally // supplied memory buffer, provided it's big enough to store the decoded // picture. Otherwise, config.output will just be used to allocate memory // and store the decoded picture. // D) Decode! CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK); // E) Decoded image is now in config.output (and config.output.u.RGBA) // F) Reclaim memory allocated in config's object. It's safe to call // this function even if the memory is external and wasn't allocated // by WebPDecode(). WebPFreeDecBuffer(&config.output); */ // Features gathered from the bitstream typedef struct { int width; // Width in pixels, as read from the bitstream. int height; // Height in pixels, as read from the bitstream. int has_alpha; // True if the bitstream contains an alpha channel. // Unused for now: int bitstream_version; // should be 0 for now. TODO(later) int no_incremental_decoding; // if true, using incremental decoding is not // recommended. int rotate; // TODO(later) int uv_sampling; // should be 0 for now. TODO(later) uint32_t pad[3]; // padding for later use } WebPBitstreamFeatures; // Internal, version-checked, entry point WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal( const uint8_t*, size_t, WebPBitstreamFeatures*, int); // Retrieve features from the bitstream. The *features structure is filled // with information gathered from the bitstream. // Returns false in case of error or version mismatch. // In case of error, features->bitstream_status will reflect the error code. static WEBP_INLINE VP8StatusCode WebPGetFeatures( const uint8_t* data, size_t data_size, WebPBitstreamFeatures* features) { return WebPGetFeaturesInternal(data, data_size, features, WEBP_DECODER_ABI_VERSION); } // Decoding options typedef struct { int bypass_filtering; // if true, skip the in-loop filtering int no_fancy_upsampling; // if true, use faster pointwise upsampler int use_cropping; // if true, cropping is applied _first_ int crop_left, crop_top; // top-left position for cropping. // Will be snapped to even values. int crop_width, crop_height; // dimension of the cropping area int use_scaling; // if true, scaling is applied _afterward_ int scaled_width, scaled_height; // final resolution int use_threads; // if true, use multi-threaded decoding // Unused for now: int force_rotation; // forced rotation (to be applied _last_) int no_enhancement; // if true, discard enhancement layer uint32_t pad[6]; // padding for later use } WebPDecoderOptions; // Main object storing the configuration for advanced decoding. typedef struct { WebPBitstreamFeatures input; // Immutable bitstream features (optional) WebPDecBuffer output; // Output buffer (can point to external mem) WebPDecoderOptions options; // Decoding options } WebPDecoderConfig; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int); // Initialize the configuration as empty. This function must always be // called first, unless WebPGetFeatures() is to be called. // Returns false in case of mismatched version. static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) { return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION); } // Instantiate a new incremental decoder object with the requested // configuration. The bitstream can be passed using 'data' and 'data_size' // parameter, in which case the features will be parsed and stored into // config->input. Otherwise, 'data' can be NULL and no parsing will occur. // Note that 'config' can be NULL too, in which case a default configuration // is used. // The return WebPIDecoder object must always be deleted calling WebPIDelete(). // Returns NULL in case of error (and config->status will then reflect // the error condition). WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); // Non-incremental version. This version decodes the full data at once, taking // 'config' into account. Returns decoding status (which should be VP8_STATUS_OK // if the decoding was successful). WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_DECODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/ios/encode.h ================================================ // Copyright 2011 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // WebP encoder: main interface // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_ENCODE_H_ #define WEBP_WEBP_ENCODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_ENCODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the encoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetEncoderVersion(void); //------------------------------------------------------------------------------ // One-stop-shop call! No questions asked: // Returns the size of the compressed data (pointed to by *output), or 0 if // an error occurred. The compressed data must be released by the caller // using the call 'free(*output)'. // These functions compress using the lossy format, and the quality_factor // can go from 0 (smaller output, lower quality) to 100 (best quality, // larger output). WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride, float quality_factor, uint8_t** output); // These functions are the equivalent of the above, but compressing in a // lossless manner. Files are usually larger than lossy format, but will // not suffer any compression loss. WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height, int stride, uint8_t** output); //------------------------------------------------------------------------------ // Coding parameters // Image characteristics hint for the underlying encoder. typedef enum { WEBP_HINT_DEFAULT = 0, // default preset. WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). WEBP_HINT_LAST } WebPImageHint; typedef struct { int lossless; // Lossless encoding (0=lossy(default), 1=lossless). float quality; // between 0 (smallest file) and 100 (biggest) int method; // quality/speed trade-off (0=fast, 6=slower-better) WebPImageHint image_hint; // Hint for image type (lossless only for now). // Parameters related to lossy compression only: int target_size; // if non-zero, set the desired target size in bytes. // Takes precedence over the 'compression' parameter. float target_PSNR; // if non-zero, specifies the minimal distortion to // try to achieve. Takes precedence over target_size. int segments; // maximum number of segments to use, in [1..4] int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum. int filter_strength; // range: [0 = off .. 100 = strongest] int filter_sharpness; // range: [0 = off .. 7 = least sharp] int filter_type; // filtering type: 0 = simple, 1 = strong (only used // if filter_strength > 0 or autofilter > 0) int autofilter; // Auto adjust filter's strength [0 = off, 1 = on] int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, // 1 = compressed with WebP lossless). Default is 1. int alpha_filtering; // Predictive filtering method for alpha plane. // 0: none, 1: fast, 2: best. Default if 1. int alpha_quality; // Between 0 (smallest size) and 100 (lossless). // Default is 100. int pass; // number of entropy-analysis passes (in [1..10]). int show_compressed; // if true, export the compressed picture back. // In-loop filtering is not applied. int preprocessing; // preprocessing filter (0=none, 1=segment-smooth) int partitions; // log2(number of token partitions) in [0..3]. Default // is set to 0 for easier progressive decoding. int partition_limit; // quality degradation allowed to fit the 512k limit // on prediction modes coding (0: no degradation, // 100: maximum possible degradation). uint32_t pad[8]; // padding for later use } WebPConfig; // Enumerate some predefined settings for WebPConfig, depending on the type // of source picture. These presets are used when calling WebPConfigPreset(). typedef enum { WEBP_PRESET_DEFAULT = 0, // default preset. WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details WEBP_PRESET_ICON, // small-sized colorful images WEBP_PRESET_TEXT // text-like } WebPPreset; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int); // Should always be called, to initialize a fresh WebPConfig structure before // modification. Returns false in case of version mismatch. WebPConfigInit() // must have succeeded before using the 'config' object. // Note that the default values are lossless=0 and quality=75. static WEBP_INLINE int WebPConfigInit(WebPConfig* config) { return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, WEBP_ENCODER_ABI_VERSION); } // This function will initialize the configuration according to a predefined // set of parameters (referred to by 'preset') and a given quality factor. // This function can be called as a replacement to WebPConfigInit(). Will // return false in case of error. static WEBP_INLINE int WebPConfigPreset(WebPConfig* config, WebPPreset preset, float quality) { return WebPConfigInitInternal(config, preset, quality, WEBP_ENCODER_ABI_VERSION); } // Returns true if 'config' is non-NULL and all configuration parameters are // within their valid ranges. WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config); //------------------------------------------------------------------------------ // Input / Output typedef struct WebPPicture WebPPicture; // main structure for I/O // Structure for storing auxiliary statistics (mostly for lossy encoding). typedef struct { int coded_size; // final size float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha int block_count[3]; // number of intra4/intra16/skipped macroblocks int header_bytes[2]; // approximate number of bytes spent for header // and mode-partition #0 int residual_bytes[3][4]; // approximate number of bytes spent for // DC/AC/uv coefficients for each (0..3) segments. int segment_size[4]; // number of macroblocks in each segments int segment_quant[4]; // quantizer values for each segments int segment_level[4]; // filtering strength for each segments [0..63] int alpha_data_size; // size of the transparency data int layer_data_size; // size of the enhancement layer data // lossless encoder statistics uint32_t lossless_features; // bit0:predictor bit1:cross-color transform // bit2:subtract-green bit3:color indexing int histogram_bits; // number of precision bits of histogram int transform_bits; // precision bits for transform int cache_bits; // number of bits for color cache lookup int palette_size; // number of color in palette, if used int lossless_size; // final lossless size uint32_t pad[4]; // padding for later use } WebPAuxStats; // Signature for output function. Should return true if writing was successful. // data/data_size is the segment of data to write, and 'picture' is for // reference (and so one can make use of picture->custom_ptr). typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size, const WebPPicture* picture); // WebPMemoryWrite: a special WebPWriterFunction that writes to memory using // the following WebPMemoryWriter object (to be set as a custom_ptr). typedef struct { uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). size_t size; // final size size_t max_size; // total capacity uint32_t pad[1]; // padding for later use } WebPMemoryWriter; // The following must be called first before any use. WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer); // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon // completion, writer.mem and writer.size will hold the coded data. WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, const WebPPicture* picture); // Progress hook, called from time to time to report progress. It can return // false to request an abort of the encoding process, or true otherwise if // everything is OK. typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture); typedef enum { // chroma sampling WEBP_YUV420 = 0, // 4:2:0 WEBP_YUV422 = 1, // 4:2:2 WEBP_YUV444 = 2, // 4:4:4 WEBP_YUV400 = 3, // grayscale WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors // alpha channel variants WEBP_YUV420A = 4, WEBP_YUV422A = 5, WEBP_YUV444A = 6, WEBP_YUV400A = 7, // grayscale + alpha WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present } WebPEncCSP; // Encoding error conditions. typedef enum { VP8_ENC_OK = 0, VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G VP8_ENC_ERROR_USER_ABORT, // abort request by user VP8_ENC_ERROR_LAST // list terminator. always last. } WebPEncodingError; // maximum width/height allowed (inclusive), in pixels #define WEBP_MAX_DIMENSION 16383 // Main exchange structure (input samples, output bytes, statistics) struct WebPPicture { // INPUT ////////////// // Main flag for encoder selecting between ARGB or YUV input. // It is recommended to use ARGB input (*argb, argb_stride) for lossless // compression, and YUV input (*y, *u, *v, etc.) for lossy compression // since these are the respective native colorspace for these formats. int use_argb; // YUV input (mostly used for input to lossy compression) WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION) uint8_t *y, *u, *v; // pointers to luma/chroma planes. int y_stride, uv_stride; // luma/chroma strides. uint8_t* a; // pointer to the alpha plane int a_stride; // stride of the alpha plane uint32_t pad1[2]; // padding for later use // ARGB input (mostly used for input to lossless compression) uint32_t* argb; // Pointer to argb (32 bit) plane. int argb_stride; // This is stride in pixels units, not bytes. uint32_t pad2[3]; // padding for later use // OUTPUT /////////////// // Byte-emission hook, to store compressed bytes as they are ready. WebPWriterFunction writer; // can be NULL void* custom_ptr; // can be used by the writer. // map for extra information (only for lossy compression mode) int extra_info_type; // 1: intra type, 2: segment, 3: quant // 4: intra-16 prediction mode, // 5: chroma prediction mode, // 6: bit cost, 7: distortion uint8_t* extra_info; // if not NULL, points to an array of size // ((width + 15) / 16) * ((height + 15) / 16) that // will be filled with a macroblock map, depending // on extra_info_type. // STATS AND REPORTS /////////////////////////// // Pointer to side statistics (updated only if not NULL) WebPAuxStats* stats; // Error code for the latest error encountered during encoding WebPEncodingError error_code; // If not NULL, report progress during encoding. WebPProgressHook progress_hook; void* user_data; // this field is free to be set to any value and // used during callbacks (like progress-report e.g.). uint32_t pad3[3]; // padding for later use // Unused for now: original samples (for non-YUV420 modes) uint8_t *u0, *v0; int uv0_stride; uint32_t pad4[7]; // padding for later use // PRIVATE FIELDS //////////////////// void* memory_; // row chunk of memory for yuva planes void* memory_argb_; // and for argb too. void* pad5[2]; // padding for later use }; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int); // Should always be called, to initialize the structure. Returns false in case // of version mismatch. WebPPictureInit() must have succeeded before using the // 'picture' object. // Note that, by default, use_argb is false and colorspace is WEBP_YUV420. static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) { return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); } //------------------------------------------------------------------------------ // WebPPicture utils // Convenience allocation / deallocation based on picture->width/height: // Allocate y/u/v buffers as per colorspace/width/height specification. // Note! This function will free the previous buffer if needed. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture); // Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). // Note that this function does _not_ free the memory used by the 'picture' // object itself. // Besides memory (which is reclaimed) all other fields of 'picture' are // preserved. WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture); // Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, // *dst will fully own the copied pixels (this is not a view). // Returns false in case of memory allocation error. WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); // Compute PSNR or SSIM distortion between two pictures. // Result is in dB, stores in result[] in the Y/U/V/Alpha/All order. // Returns false in case of error (pic1 and pic2 don't have same dimension, ...) // Warning: this function is rather CPU-intensive. WEBP_EXTERN(int) WebPPictureDistortion( const WebPPicture* pic1, const WebPPicture* pic2, int metric_type, // 0 = PSNR, 1 = SSIM float result[5]); // self-crops a picture to the rectangle defined by top/left/width/height. // Returns false in case of memory allocation error, or if the rectangle is // outside of the source picture. // The rectangle for the view is defined by the top-left corner pixel // coordinates (left, top) as well as its width and height. This rectangle // must be fully be comprised inside the 'src' source picture. If the source // picture uses the YUV420 colorspace, the top and left coordinates will be // snapped to even values. WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture, int left, int top, int width, int height); // Extracts a view from 'src' picture into 'dst'. The rectangle for the view // is defined by the top-left corner pixel coordinates (left, top) as well // as its width and height. This rectangle must be fully be comprised inside // the 'src' source picture. If the source picture uses the YUV420 colorspace, // the top and left coordinates will be snapped to even values. // Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed // ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, // the original dimension will be lost). // Returns false in case of memory allocation error or invalid parameters. WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src, int left, int top, int width, int height, WebPPicture* dst); // Returns true if the 'picture' is actually a view and therefore does // not own the memory for pixels. WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture); // Rescale a picture to new dimension width x height. // Now gamma correction is applied. // Returns false in case of error (invalid parameter or insufficient memory). WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height); // Colorspace conversion function to import RGB samples. // Previous buffer will be free'd, if any. // *rgb buffer should have a size of at least height * rgb_stride. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureImportRGB( WebPPicture* picture, const uint8_t* rgb, int rgb_stride); // Same, but for RGBA buffer. WEBP_EXTERN(int) WebPPictureImportRGBA( WebPPicture* picture, const uint8_t* rgba, int rgba_stride); // Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format // input buffer ignoring the alpha channel. Avoids needing to copy the data // to a temporary 24-bit RGB buffer to import the RGB only. WEBP_EXTERN(int) WebPPictureImportRGBX( WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); // Variants of the above, but taking BGR(A|X) input. WEBP_EXTERN(int) WebPPictureImportBGR( WebPPicture* picture, const uint8_t* bgr, int bgr_stride); WEBP_EXTERN(int) WebPPictureImportBGRA( WebPPicture* picture, const uint8_t* bgra, int bgra_stride); WEBP_EXTERN(int) WebPPictureImportBGRX( WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); // Converts picture->argb data to the YUVA format specified by 'colorspace'. // Upon return, picture->use_argb is set to false. The presence of real // non-opaque transparent values is detected, and 'colorspace' will be // adjusted accordingly. Note that this method is lossy. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace); // Converts picture->yuv to picture->argb and sets picture->use_argb to true. // The input format must be YUV_420 or YUV_420A. // Note that the use of this method is discouraged if one has access to the // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the // conversion from YUV420 to ARGB incurs a small loss too. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); // Helper function: given a width x height plane of YUV(A) samples // (with stride 'stride'), clean-up the YUV samples under fully transparent // area, to help compressibility (no guarantee, though). WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); // Scan the picture 'picture' for the presence of non fully opaque alpha values. // Returns true in such case. Otherwise returns false (indicating that the // alpha plane can be ignored altogether e.g.). WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); //------------------------------------------------------------------------------ // Main call // Main encoding call, after config and picture have been initialized. // 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), // and the 'config' object must be a valid one. // Returns false in case of error, true otherwise. // In case of error, picture->error_code is updated accordingly. // 'picture' can hold the source samples in both YUV(A) or ARGB input, depending // on the value of 'picture->use_argb'. It is highly recommended to use // the former for lossy encoding, and the latter for lossless encoding // (when config.lossless is true). Automatic conversion from one format to // another is provided but they both incur some loss. WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_ENCODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/ios/types.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Common types // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_TYPES_H_ #define WEBP_WEBP_TYPES_H_ #include // for size_t #ifndef _MSC_VER #include #ifdef __STRICT_ANSI__ #define WEBP_INLINE #else /* __STRICT_ANSI__ */ #define WEBP_INLINE inline #endif #else typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef unsigned long long int uint64_t; typedef long long int int64_t; #define WEBP_INLINE __forceinline #endif /* _MSC_VER */ #ifndef WEBP_EXTERN // This explicitly marks library functions and allows for changing the // signature for e.g., Windows DLL builds. #define WEBP_EXTERN(type) extern type #endif /* WEBP_EXTERN */ // Macro to check ABI compatibility (same major revision number) #define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8)) #endif /* WEBP_WEBP_TYPES_H_ */ ================================================ FILE: cocos2d/external/webp/include/linux/decode.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Main decoding functions for WebP images. // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_DECODE_H_ #define WEBP_WEBP_DECODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_DECODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the decoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetDecoderVersion(void); // Retrieve basic header information: width, height. // This function will also validate the header and return 0 in // case of formatting error. // Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size, int* width, int* height); // Decodes WebP images pointed to by 'data' and returns RGBA samples, along // with the dimensions in *width and *height. The ordering of samples in // memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). // The returned pointer should be deleted calling free(). // Returns NULL in case of error. WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. // If the bitstream contains transparency, it is ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size, int* width, int* height); // Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer // returned is the Y samples buffer. Upon return, *u and *v will point to // the U and V chroma data. These U and V buffers need NOT be free()'d, // unlike the returned Y luma one. The dimension of the U and V planes // are both (*width + 1) / 2 and (*height + 1)/ 2. // Upon return, the Y buffer has a stride returned as '*stride', while U and V // have a common stride returned as '*uv_stride'. // Return NULL in case of error. // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size, int* width, int* height, uint8_t** u, uint8_t** v, int* stride, int* uv_stride); // These five functions are variants of the above ones, that decode the image // directly into a pre-allocated buffer 'output_buffer'. The maximum storage // available in this buffer is indicated by 'output_buffer_size'. If this // storage is not sufficient (or an error occurred), NULL is returned. // Otherwise, output_buffer is returned, for convenience. // The parameter 'output_stride' specifies the distance (in bytes) // between scanlines. Hence, output_buffer_size is expected to be at least // output_stride x picture-height. WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // RGB and BGR variants. Here too the transparency information, if present, // will be dropped and ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly // into pre-allocated luma/chroma plane buffers. This function requires the // strides to be passed: one for the luma plane and one for each of the // chroma ones. The size of each plane buffer is passed as 'luma_size', // 'u_size' and 'v_size' respectively. // Pointer to the luma plane ('*luma') is returned or NULL if an error occurred // during decoding (or because some buffers were found to be too small). WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto( const uint8_t* data, size_t data_size, uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); //------------------------------------------------------------------------------ // Output colorspaces and buffer // Colorspaces // Note: the naming describes the byte-ordering of packed samples in memory. // For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,... // Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels. // RGB-565 and RGBA-4444 are also endian-agnostic and byte-oriented. typedef enum { MODE_RGB = 0, MODE_RGBA = 1, MODE_BGR = 2, MODE_BGRA = 3, MODE_ARGB = 4, MODE_RGBA_4444 = 5, MODE_RGB_565 = 6, // RGB-premultiplied transparent modes (alpha value is preserved) MODE_rgbA = 7, MODE_bgrA = 8, MODE_Argb = 9, MODE_rgbA_4444 = 10, // YUV modes must come after RGB ones. MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0 MODE_LAST = 13 } WEBP_CSP_MODE; // Some useful macros: static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) { return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb || mode == MODE_rgbA_4444); } static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) { return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB || mode == MODE_RGBA_4444 || mode == MODE_YUVA || WebPIsPremultipliedMode(mode)); } static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) { return (mode < MODE_YUV); } //------------------------------------------------------------------------------ // WebPDecBuffer: Generic structure for describing the output sample buffer. typedef struct { // view as RGBA uint8_t* rgba; // pointer to RGBA samples int stride; // stride in bytes from one scanline to the next. size_t size; // total size of the *rgba buffer. } WebPRGBABuffer; typedef struct { // view as YUVA uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples int y_stride; // luma stride int u_stride, v_stride; // chroma strides int a_stride; // alpha stride size_t y_size; // luma plane size size_t u_size, v_size; // chroma planes size size_t a_size; // alpha-plane size } WebPYUVABuffer; // Output buffer typedef struct { WEBP_CSP_MODE colorspace; // Colorspace. int width, height; // Dimensions. int is_external_memory; // If true, 'internal_memory' pointer is not used. union { WebPRGBABuffer RGBA; WebPYUVABuffer YUVA; } u; // Nameless union of buffer parameters. uint32_t pad[4]; // padding for later use uint8_t* private_memory; // Internally allocated memory (only when // is_external_memory is false). Should not be used // externally, but accessed via the buffer union. } WebPDecBuffer; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int); // Initialize the structure as empty. Must be called before any other use. // Returns false in case of version mismatch static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) { return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION); } // Free any memory associated with the buffer. Must always be called last. // Note: doesn't free the 'buffer' structure itself. WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer); //------------------------------------------------------------------------------ // Enumeration of the status codes typedef enum { VP8_STATUS_OK = 0, VP8_STATUS_OUT_OF_MEMORY, VP8_STATUS_INVALID_PARAM, VP8_STATUS_BITSTREAM_ERROR, VP8_STATUS_UNSUPPORTED_FEATURE, VP8_STATUS_SUSPENDED, VP8_STATUS_USER_ABORT, VP8_STATUS_NOT_ENOUGH_DATA } VP8StatusCode; //------------------------------------------------------------------------------ // Incremental decoding // // This API allows streamlined decoding of partial data. // Picture can be incrementally decoded as data become available thanks to the // WebPIDecoder object. This object can be left in a SUSPENDED state if the // picture is only partially decoded, pending additional input. // Code example: // // WebPInitDecBuffer(&buffer); // buffer.colorspace = mode; // ... // WebPIDecoder* idec = WebPINewDecoder(&buffer); // while (has_more_data) { // // ... (get additional data) // status = WebPIAppend(idec, new_data, new_data_size); // if (status != VP8_STATUS_SUSPENDED || // break; // } // // // The above call decodes the current available buffer. // // Part of the image can now be refreshed by calling to // // WebPIDecGetRGB()/WebPIDecGetYUVA() etc. // } // WebPIDelete(idec); typedef struct WebPIDecoder WebPIDecoder; // Creates a new incremental decoder with the supplied buffer parameter. // This output_buffer can be passed NULL, in which case a default output buffer // is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' // is kept, which means that the lifespan of 'output_buffer' must be larger than // that of the returned WebPIDecoder object. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer); // This function allocates and initializes an incremental-decoder object, which // will output the RGB/A samples specified by 'csp' into a preallocated // buffer 'output_buffer'. The size of this buffer is at least // 'output_buffer_size' and the stride (distance in bytes between two scanlines) // is specified by 'output_stride'. Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewRGB( WEBP_CSP_MODE csp, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // This function allocates and initializes an incremental-decoder object, which // will output the raw luma/chroma samples into a preallocated planes. The luma // plane is specified by its pointer 'luma', its size 'luma_size' and its stride // 'luma_stride'. Similarly, the chroma-u plane is specified by the 'u', // 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v' // and 'v_size'. And same for the alpha-plane. The 'a' pointer can be pass // NULL in case one is not interested in the transparency plane. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewYUVA( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride, uint8_t* a, size_t a_size, int a_stride); // Deprecated version of the above, without the alpha plane. // Kept for backward compatibility. WEBP_EXTERN(WebPIDecoder*) WebPINewYUV( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); // Deletes the WebPIDecoder object and associated memory. Must always be called // if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded. WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec); // Copies and decodes the next available data. Returns VP8_STATUS_OK when // the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more // data is expected. Returns error in other cases. WEBP_EXTERN(VP8StatusCode) WebPIAppend( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // A variant of the above function to be used when data buffer contains // partial data from the beginning. In this case data buffer is not copied // to the internal memory. // Note that the value of the 'data' pointer can change between calls to // WebPIUpdate, for instance when the data buffer is resized to fit larger data. WEBP_EXTERN(VP8StatusCode) WebPIUpdate( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // Returns the RGB/A image decoded so far. Returns NULL if output params // are not initialized yet. The RGB/A output type corresponds to the colorspace // specified during call to WebPINewDecoder() or WebPINewRGB(). // *last_y is the index of last decoded row in raster scan order. Some pointers // (*last_y, *width etc.) can be NULL if corresponding information is not // needed. WEBP_EXTERN(uint8_t*) WebPIDecGetRGB( const WebPIDecoder* idec, int* last_y, int* width, int* height, int* stride); // Same as above function to get a YUVA image. Returns pointer to the luma // plane or NULL in case of error. If there is no alpha information // the alpha pointer '*a' will be returned NULL. WEBP_EXTERN(uint8_t*) WebPIDecGetYUVA( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, uint8_t** a, int* width, int* height, int* stride, int* uv_stride, int* a_stride); // Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the // alpha information (if present). Kept for backward compatibility. static WEBP_INLINE uint8_t* WebPIDecGetYUV( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, int* width, int* height, int* stride, int* uv_stride) { return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height, stride, uv_stride, NULL); } // Generic call to retrieve information about the displayable area. // If non NULL, the left/right/width/height pointers are filled with the visible // rectangular area so far. // Returns NULL in case the incremental decoder object is in an invalid state. // Otherwise returns the pointer to the internal representation. This structure // is read-only, tied to WebPIDecoder's lifespan and should not be modified. WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea( const WebPIDecoder* idec, int* left, int* top, int* width, int* height); //------------------------------------------------------------------------------ // Advanced decoding parametrization // // Code sample for using the advanced decoding API /* // A) Init a configuration object WebPDecoderConfig config; CHECK(WebPInitDecoderConfig(&config)); // B) optional: retrieve the bitstream's features. CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK); // C) Adjust 'config', if needed config.no_fancy = 1; config.output.colorspace = MODE_BGRA; // etc. // Note that you can also make config.output point to an externally // supplied memory buffer, provided it's big enough to store the decoded // picture. Otherwise, config.output will just be used to allocate memory // and store the decoded picture. // D) Decode! CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK); // E) Decoded image is now in config.output (and config.output.u.RGBA) // F) Reclaim memory allocated in config's object. It's safe to call // this function even if the memory is external and wasn't allocated // by WebPDecode(). WebPFreeDecBuffer(&config.output); */ // Features gathered from the bitstream typedef struct { int width; // Width in pixels, as read from the bitstream. int height; // Height in pixels, as read from the bitstream. int has_alpha; // True if the bitstream contains an alpha channel. // Unused for now: int bitstream_version; // should be 0 for now. TODO(later) int no_incremental_decoding; // if true, using incremental decoding is not // recommended. int rotate; // TODO(later) int uv_sampling; // should be 0 for now. TODO(later) uint32_t pad[3]; // padding for later use } WebPBitstreamFeatures; // Internal, version-checked, entry point WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal( const uint8_t*, size_t, WebPBitstreamFeatures*, int); // Retrieve features from the bitstream. The *features structure is filled // with information gathered from the bitstream. // Returns false in case of error or version mismatch. // In case of error, features->bitstream_status will reflect the error code. static WEBP_INLINE VP8StatusCode WebPGetFeatures( const uint8_t* data, size_t data_size, WebPBitstreamFeatures* features) { return WebPGetFeaturesInternal(data, data_size, features, WEBP_DECODER_ABI_VERSION); } // Decoding options typedef struct { int bypass_filtering; // if true, skip the in-loop filtering int no_fancy_upsampling; // if true, use faster pointwise upsampler int use_cropping; // if true, cropping is applied _first_ int crop_left, crop_top; // top-left position for cropping. // Will be snapped to even values. int crop_width, crop_height; // dimension of the cropping area int use_scaling; // if true, scaling is applied _afterward_ int scaled_width, scaled_height; // final resolution int use_threads; // if true, use multi-threaded decoding // Unused for now: int force_rotation; // forced rotation (to be applied _last_) int no_enhancement; // if true, discard enhancement layer uint32_t pad[6]; // padding for later use } WebPDecoderOptions; // Main object storing the configuration for advanced decoding. typedef struct { WebPBitstreamFeatures input; // Immutable bitstream features (optional) WebPDecBuffer output; // Output buffer (can point to external mem) WebPDecoderOptions options; // Decoding options } WebPDecoderConfig; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int); // Initialize the configuration as empty. This function must always be // called first, unless WebPGetFeatures() is to be called. // Returns false in case of mismatched version. static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) { return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION); } // Instantiate a new incremental decoder object with the requested // configuration. The bitstream can be passed using 'data' and 'data_size' // parameter, in which case the features will be parsed and stored into // config->input. Otherwise, 'data' can be NULL and no parsing will occur. // Note that 'config' can be NULL too, in which case a default configuration // is used. // The return WebPIDecoder object must always be deleted calling WebPIDelete(). // Returns NULL in case of error (and config->status will then reflect // the error condition). WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); // Non-incremental version. This version decodes the full data at once, taking // 'config' into account. Returns decoding status (which should be VP8_STATUS_OK // if the decoding was successful). WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_DECODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/linux/encode.h ================================================ // Copyright 2011 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // WebP encoder: main interface // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_ENCODE_H_ #define WEBP_WEBP_ENCODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_ENCODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the encoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetEncoderVersion(void); //------------------------------------------------------------------------------ // One-stop-shop call! No questions asked: // Returns the size of the compressed data (pointed to by *output), or 0 if // an error occurred. The compressed data must be released by the caller // using the call 'free(*output)'. // These functions compress using the lossy format, and the quality_factor // can go from 0 (smaller output, lower quality) to 100 (best quality, // larger output). WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride, float quality_factor, uint8_t** output); // These functions are the equivalent of the above, but compressing in a // lossless manner. Files are usually larger than lossy format, but will // not suffer any compression loss. WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height, int stride, uint8_t** output); //------------------------------------------------------------------------------ // Coding parameters // Image characteristics hint for the underlying encoder. typedef enum { WEBP_HINT_DEFAULT = 0, // default preset. WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). WEBP_HINT_LAST } WebPImageHint; typedef struct { int lossless; // Lossless encoding (0=lossy(default), 1=lossless). float quality; // between 0 (smallest file) and 100 (biggest) int method; // quality/speed trade-off (0=fast, 6=slower-better) WebPImageHint image_hint; // Hint for image type (lossless only for now). // Parameters related to lossy compression only: int target_size; // if non-zero, set the desired target size in bytes. // Takes precedence over the 'compression' parameter. float target_PSNR; // if non-zero, specifies the minimal distortion to // try to achieve. Takes precedence over target_size. int segments; // maximum number of segments to use, in [1..4] int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum. int filter_strength; // range: [0 = off .. 100 = strongest] int filter_sharpness; // range: [0 = off .. 7 = least sharp] int filter_type; // filtering type: 0 = simple, 1 = strong (only used // if filter_strength > 0 or autofilter > 0) int autofilter; // Auto adjust filter's strength [0 = off, 1 = on] int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, // 1 = compressed with WebP lossless). Default is 1. int alpha_filtering; // Predictive filtering method for alpha plane. // 0: none, 1: fast, 2: best. Default if 1. int alpha_quality; // Between 0 (smallest size) and 100 (lossless). // Default is 100. int pass; // number of entropy-analysis passes (in [1..10]). int show_compressed; // if true, export the compressed picture back. // In-loop filtering is not applied. int preprocessing; // preprocessing filter (0=none, 1=segment-smooth) int partitions; // log2(number of token partitions) in [0..3]. Default // is set to 0 for easier progressive decoding. int partition_limit; // quality degradation allowed to fit the 512k limit // on prediction modes coding (0: no degradation, // 100: maximum possible degradation). uint32_t pad[8]; // padding for later use } WebPConfig; // Enumerate some predefined settings for WebPConfig, depending on the type // of source picture. These presets are used when calling WebPConfigPreset(). typedef enum { WEBP_PRESET_DEFAULT = 0, // default preset. WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details WEBP_PRESET_ICON, // small-sized colorful images WEBP_PRESET_TEXT // text-like } WebPPreset; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int); // Should always be called, to initialize a fresh WebPConfig structure before // modification. Returns false in case of version mismatch. WebPConfigInit() // must have succeeded before using the 'config' object. // Note that the default values are lossless=0 and quality=75. static WEBP_INLINE int WebPConfigInit(WebPConfig* config) { return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, WEBP_ENCODER_ABI_VERSION); } // This function will initialize the configuration according to a predefined // set of parameters (referred to by 'preset') and a given quality factor. // This function can be called as a replacement to WebPConfigInit(). Will // return false in case of error. static WEBP_INLINE int WebPConfigPreset(WebPConfig* config, WebPPreset preset, float quality) { return WebPConfigInitInternal(config, preset, quality, WEBP_ENCODER_ABI_VERSION); } // Returns true if 'config' is non-NULL and all configuration parameters are // within their valid ranges. WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config); //------------------------------------------------------------------------------ // Input / Output typedef struct WebPPicture WebPPicture; // main structure for I/O // Structure for storing auxiliary statistics (mostly for lossy encoding). typedef struct { int coded_size; // final size float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha int block_count[3]; // number of intra4/intra16/skipped macroblocks int header_bytes[2]; // approximate number of bytes spent for header // and mode-partition #0 int residual_bytes[3][4]; // approximate number of bytes spent for // DC/AC/uv coefficients for each (0..3) segments. int segment_size[4]; // number of macroblocks in each segments int segment_quant[4]; // quantizer values for each segments int segment_level[4]; // filtering strength for each segments [0..63] int alpha_data_size; // size of the transparency data int layer_data_size; // size of the enhancement layer data // lossless encoder statistics uint32_t lossless_features; // bit0:predictor bit1:cross-color transform // bit2:subtract-green bit3:color indexing int histogram_bits; // number of precision bits of histogram int transform_bits; // precision bits for transform int cache_bits; // number of bits for color cache lookup int palette_size; // number of color in palette, if used int lossless_size; // final lossless size uint32_t pad[4]; // padding for later use } WebPAuxStats; // Signature for output function. Should return true if writing was successful. // data/data_size is the segment of data to write, and 'picture' is for // reference (and so one can make use of picture->custom_ptr). typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size, const WebPPicture* picture); // WebPMemoryWrite: a special WebPWriterFunction that writes to memory using // the following WebPMemoryWriter object (to be set as a custom_ptr). typedef struct { uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). size_t size; // final size size_t max_size; // total capacity uint32_t pad[1]; // padding for later use } WebPMemoryWriter; // The following must be called first before any use. WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer); // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon // completion, writer.mem and writer.size will hold the coded data. WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, const WebPPicture* picture); // Progress hook, called from time to time to report progress. It can return // false to request an abort of the encoding process, or true otherwise if // everything is OK. typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture); typedef enum { // chroma sampling WEBP_YUV420 = 0, // 4:2:0 WEBP_YUV422 = 1, // 4:2:2 WEBP_YUV444 = 2, // 4:4:4 WEBP_YUV400 = 3, // grayscale WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors // alpha channel variants WEBP_YUV420A = 4, WEBP_YUV422A = 5, WEBP_YUV444A = 6, WEBP_YUV400A = 7, // grayscale + alpha WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present } WebPEncCSP; // Encoding error conditions. typedef enum { VP8_ENC_OK = 0, VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G VP8_ENC_ERROR_USER_ABORT, // abort request by user VP8_ENC_ERROR_LAST // list terminator. always last. } WebPEncodingError; // maximum width/height allowed (inclusive), in pixels #define WEBP_MAX_DIMENSION 16383 // Main exchange structure (input samples, output bytes, statistics) struct WebPPicture { // INPUT ////////////// // Main flag for encoder selecting between ARGB or YUV input. // It is recommended to use ARGB input (*argb, argb_stride) for lossless // compression, and YUV input (*y, *u, *v, etc.) for lossy compression // since these are the respective native colorspace for these formats. int use_argb; // YUV input (mostly used for input to lossy compression) WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION) uint8_t *y, *u, *v; // pointers to luma/chroma planes. int y_stride, uv_stride; // luma/chroma strides. uint8_t* a; // pointer to the alpha plane int a_stride; // stride of the alpha plane uint32_t pad1[2]; // padding for later use // ARGB input (mostly used for input to lossless compression) uint32_t* argb; // Pointer to argb (32 bit) plane. int argb_stride; // This is stride in pixels units, not bytes. uint32_t pad2[3]; // padding for later use // OUTPUT /////////////// // Byte-emission hook, to store compressed bytes as they are ready. WebPWriterFunction writer; // can be NULL void* custom_ptr; // can be used by the writer. // map for extra information (only for lossy compression mode) int extra_info_type; // 1: intra type, 2: segment, 3: quant // 4: intra-16 prediction mode, // 5: chroma prediction mode, // 6: bit cost, 7: distortion uint8_t* extra_info; // if not NULL, points to an array of size // ((width + 15) / 16) * ((height + 15) / 16) that // will be filled with a macroblock map, depending // on extra_info_type. // STATS AND REPORTS /////////////////////////// // Pointer to side statistics (updated only if not NULL) WebPAuxStats* stats; // Error code for the latest error encountered during encoding WebPEncodingError error_code; // If not NULL, report progress during encoding. WebPProgressHook progress_hook; void* user_data; // this field is free to be set to any value and // used during callbacks (like progress-report e.g.). uint32_t pad3[3]; // padding for later use // Unused for now: original samples (for non-YUV420 modes) uint8_t *u0, *v0; int uv0_stride; uint32_t pad4[7]; // padding for later use // PRIVATE FIELDS //////////////////// void* memory_; // row chunk of memory for yuva planes void* memory_argb_; // and for argb too. void* pad5[2]; // padding for later use }; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int); // Should always be called, to initialize the structure. Returns false in case // of version mismatch. WebPPictureInit() must have succeeded before using the // 'picture' object. // Note that, by default, use_argb is false and colorspace is WEBP_YUV420. static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) { return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); } //------------------------------------------------------------------------------ // WebPPicture utils // Convenience allocation / deallocation based on picture->width/height: // Allocate y/u/v buffers as per colorspace/width/height specification. // Note! This function will free the previous buffer if needed. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture); // Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). // Note that this function does _not_ free the memory used by the 'picture' // object itself. // Besides memory (which is reclaimed) all other fields of 'picture' are // preserved. WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture); // Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, // *dst will fully own the copied pixels (this is not a view). // Returns false in case of memory allocation error. WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); // Compute PSNR or SSIM distortion between two pictures. // Result is in dB, stores in result[] in the Y/U/V/Alpha/All order. // Returns false in case of error (pic1 and pic2 don't have same dimension, ...) // Warning: this function is rather CPU-intensive. WEBP_EXTERN(int) WebPPictureDistortion( const WebPPicture* pic1, const WebPPicture* pic2, int metric_type, // 0 = PSNR, 1 = SSIM float result[5]); // self-crops a picture to the rectangle defined by top/left/width/height. // Returns false in case of memory allocation error, or if the rectangle is // outside of the source picture. // The rectangle for the view is defined by the top-left corner pixel // coordinates (left, top) as well as its width and height. This rectangle // must be fully be comprised inside the 'src' source picture. If the source // picture uses the YUV420 colorspace, the top and left coordinates will be // snapped to even values. WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture, int left, int top, int width, int height); // Extracts a view from 'src' picture into 'dst'. The rectangle for the view // is defined by the top-left corner pixel coordinates (left, top) as well // as its width and height. This rectangle must be fully be comprised inside // the 'src' source picture. If the source picture uses the YUV420 colorspace, // the top and left coordinates will be snapped to even values. // Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed // ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, // the original dimension will be lost). // Returns false in case of memory allocation error or invalid parameters. WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src, int left, int top, int width, int height, WebPPicture* dst); // Returns true if the 'picture' is actually a view and therefore does // not own the memory for pixels. WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture); // Rescale a picture to new dimension width x height. // Now gamma correction is applied. // Returns false in case of error (invalid parameter or insufficient memory). WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height); // Colorspace conversion function to import RGB samples. // Previous buffer will be free'd, if any. // *rgb buffer should have a size of at least height * rgb_stride. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureImportRGB( WebPPicture* picture, const uint8_t* rgb, int rgb_stride); // Same, but for RGBA buffer. WEBP_EXTERN(int) WebPPictureImportRGBA( WebPPicture* picture, const uint8_t* rgba, int rgba_stride); // Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format // input buffer ignoring the alpha channel. Avoids needing to copy the data // to a temporary 24-bit RGB buffer to import the RGB only. WEBP_EXTERN(int) WebPPictureImportRGBX( WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); // Variants of the above, but taking BGR(A|X) input. WEBP_EXTERN(int) WebPPictureImportBGR( WebPPicture* picture, const uint8_t* bgr, int bgr_stride); WEBP_EXTERN(int) WebPPictureImportBGRA( WebPPicture* picture, const uint8_t* bgra, int bgra_stride); WEBP_EXTERN(int) WebPPictureImportBGRX( WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); // Converts picture->argb data to the YUVA format specified by 'colorspace'. // Upon return, picture->use_argb is set to false. The presence of real // non-opaque transparent values is detected, and 'colorspace' will be // adjusted accordingly. Note that this method is lossy. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace); // Converts picture->yuv to picture->argb and sets picture->use_argb to true. // The input format must be YUV_420 or YUV_420A. // Note that the use of this method is discouraged if one has access to the // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the // conversion from YUV420 to ARGB incurs a small loss too. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); // Helper function: given a width x height plane of YUV(A) samples // (with stride 'stride'), clean-up the YUV samples under fully transparent // area, to help compressibility (no guarantee, though). WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); // Scan the picture 'picture' for the presence of non fully opaque alpha values. // Returns true in such case. Otherwise returns false (indicating that the // alpha plane can be ignored altogether e.g.). WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); //------------------------------------------------------------------------------ // Main call // Main encoding call, after config and picture have been initialized. // 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), // and the 'config' object must be a valid one. // Returns false in case of error, true otherwise. // In case of error, picture->error_code is updated accordingly. // 'picture' can hold the source samples in both YUV(A) or ARGB input, depending // on the value of 'picture->use_argb'. It is highly recommended to use // the former for lossy encoding, and the latter for lossless encoding // (when config.lossless is true). Automatic conversion from one format to // another is provided but they both incur some loss. WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_ENCODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/linux/types.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Common types // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_TYPES_H_ #define WEBP_WEBP_TYPES_H_ #include // for size_t #ifndef _MSC_VER #include #ifdef __STRICT_ANSI__ #define WEBP_INLINE #else /* __STRICT_ANSI__ */ #define WEBP_INLINE inline #endif #else typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef unsigned long long int uint64_t; typedef long long int int64_t; #define WEBP_INLINE __forceinline #endif /* _MSC_VER */ #ifndef WEBP_EXTERN // This explicitly marks library functions and allows for changing the // signature for e.g., Windows DLL builds. #define WEBP_EXTERN(type) extern type #endif /* WEBP_EXTERN */ // Macro to check ABI compatibility (same major revision number) #define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8)) #endif /* WEBP_WEBP_TYPES_H_ */ ================================================ FILE: cocos2d/external/webp/include/mac/decode.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Main decoding functions for WebP images. // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_DECODE_H_ #define WEBP_WEBP_DECODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_DECODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the decoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetDecoderVersion(void); // Retrieve basic header information: width, height. // This function will also validate the header and return 0 in // case of formatting error. // Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size, int* width, int* height); // Decodes WebP images pointed to by 'data' and returns RGBA samples, along // with the dimensions in *width and *height. The ordering of samples in // memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). // The returned pointer should be deleted calling free(). // Returns NULL in case of error. WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. // If the bitstream contains transparency, it is ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size, int* width, int* height); // Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer // returned is the Y samples buffer. Upon return, *u and *v will point to // the U and V chroma data. These U and V buffers need NOT be free()'d, // unlike the returned Y luma one. The dimension of the U and V planes // are both (*width + 1) / 2 and (*height + 1)/ 2. // Upon return, the Y buffer has a stride returned as '*stride', while U and V // have a common stride returned as '*uv_stride'. // Return NULL in case of error. // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size, int* width, int* height, uint8_t** u, uint8_t** v, int* stride, int* uv_stride); // These five functions are variants of the above ones, that decode the image // directly into a pre-allocated buffer 'output_buffer'. The maximum storage // available in this buffer is indicated by 'output_buffer_size'. If this // storage is not sufficient (or an error occurred), NULL is returned. // Otherwise, output_buffer is returned, for convenience. // The parameter 'output_stride' specifies the distance (in bytes) // between scanlines. Hence, output_buffer_size is expected to be at least // output_stride x picture-height. WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // RGB and BGR variants. Here too the transparency information, if present, // will be dropped and ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly // into pre-allocated luma/chroma plane buffers. This function requires the // strides to be passed: one for the luma plane and one for each of the // chroma ones. The size of each plane buffer is passed as 'luma_size', // 'u_size' and 'v_size' respectively. // Pointer to the luma plane ('*luma') is returned or NULL if an error occurred // during decoding (or because some buffers were found to be too small). WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto( const uint8_t* data, size_t data_size, uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); //------------------------------------------------------------------------------ // Output colorspaces and buffer // Colorspaces // Note: the naming describes the byte-ordering of packed samples in memory. // For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,... // Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels. // RGB-565 and RGBA-4444 are also endian-agnostic and byte-oriented. typedef enum { MODE_RGB = 0, MODE_RGBA = 1, MODE_BGR = 2, MODE_BGRA = 3, MODE_ARGB = 4, MODE_RGBA_4444 = 5, MODE_RGB_565 = 6, // RGB-premultiplied transparent modes (alpha value is preserved) MODE_rgbA = 7, MODE_bgrA = 8, MODE_Argb = 9, MODE_rgbA_4444 = 10, // YUV modes must come after RGB ones. MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0 MODE_LAST = 13 } WEBP_CSP_MODE; // Some useful macros: static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) { return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb || mode == MODE_rgbA_4444); } static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) { return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB || mode == MODE_RGBA_4444 || mode == MODE_YUVA || WebPIsPremultipliedMode(mode)); } static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) { return (mode < MODE_YUV); } //------------------------------------------------------------------------------ // WebPDecBuffer: Generic structure for describing the output sample buffer. typedef struct { // view as RGBA uint8_t* rgba; // pointer to RGBA samples int stride; // stride in bytes from one scanline to the next. size_t size; // total size of the *rgba buffer. } WebPRGBABuffer; typedef struct { // view as YUVA uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples int y_stride; // luma stride int u_stride, v_stride; // chroma strides int a_stride; // alpha stride size_t y_size; // luma plane size size_t u_size, v_size; // chroma planes size size_t a_size; // alpha-plane size } WebPYUVABuffer; // Output buffer typedef struct { WEBP_CSP_MODE colorspace; // Colorspace. int width, height; // Dimensions. int is_external_memory; // If true, 'internal_memory' pointer is not used. union { WebPRGBABuffer RGBA; WebPYUVABuffer YUVA; } u; // Nameless union of buffer parameters. uint32_t pad[4]; // padding for later use uint8_t* private_memory; // Internally allocated memory (only when // is_external_memory is false). Should not be used // externally, but accessed via the buffer union. } WebPDecBuffer; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int); // Initialize the structure as empty. Must be called before any other use. // Returns false in case of version mismatch static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) { return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION); } // Free any memory associated with the buffer. Must always be called last. // Note: doesn't free the 'buffer' structure itself. WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer); //------------------------------------------------------------------------------ // Enumeration of the status codes typedef enum { VP8_STATUS_OK = 0, VP8_STATUS_OUT_OF_MEMORY, VP8_STATUS_INVALID_PARAM, VP8_STATUS_BITSTREAM_ERROR, VP8_STATUS_UNSUPPORTED_FEATURE, VP8_STATUS_SUSPENDED, VP8_STATUS_USER_ABORT, VP8_STATUS_NOT_ENOUGH_DATA } VP8StatusCode; //------------------------------------------------------------------------------ // Incremental decoding // // This API allows streamlined decoding of partial data. // Picture can be incrementally decoded as data become available thanks to the // WebPIDecoder object. This object can be left in a SUSPENDED state if the // picture is only partially decoded, pending additional input. // Code example: // // WebPInitDecBuffer(&buffer); // buffer.colorspace = mode; // ... // WebPIDecoder* idec = WebPINewDecoder(&buffer); // while (has_more_data) { // // ... (get additional data) // status = WebPIAppend(idec, new_data, new_data_size); // if (status != VP8_STATUS_SUSPENDED || // break; // } // // // The above call decodes the current available buffer. // // Part of the image can now be refreshed by calling to // // WebPIDecGetRGB()/WebPIDecGetYUVA() etc. // } // WebPIDelete(idec); typedef struct WebPIDecoder WebPIDecoder; // Creates a new incremental decoder with the supplied buffer parameter. // This output_buffer can be passed NULL, in which case a default output buffer // is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' // is kept, which means that the lifespan of 'output_buffer' must be larger than // that of the returned WebPIDecoder object. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer); // This function allocates and initializes an incremental-decoder object, which // will output the RGB/A samples specified by 'csp' into a preallocated // buffer 'output_buffer'. The size of this buffer is at least // 'output_buffer_size' and the stride (distance in bytes between two scanlines) // is specified by 'output_stride'. Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewRGB( WEBP_CSP_MODE csp, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // This function allocates and initializes an incremental-decoder object, which // will output the raw luma/chroma samples into a preallocated planes. The luma // plane is specified by its pointer 'luma', its size 'luma_size' and its stride // 'luma_stride'. Similarly, the chroma-u plane is specified by the 'u', // 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v' // and 'v_size'. And same for the alpha-plane. The 'a' pointer can be pass // NULL in case one is not interested in the transparency plane. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewYUVA( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride, uint8_t* a, size_t a_size, int a_stride); // Deprecated version of the above, without the alpha plane. // Kept for backward compatibility. WEBP_EXTERN(WebPIDecoder*) WebPINewYUV( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); // Deletes the WebPIDecoder object and associated memory. Must always be called // if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded. WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec); // Copies and decodes the next available data. Returns VP8_STATUS_OK when // the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more // data is expected. Returns error in other cases. WEBP_EXTERN(VP8StatusCode) WebPIAppend( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // A variant of the above function to be used when data buffer contains // partial data from the beginning. In this case data buffer is not copied // to the internal memory. // Note that the value of the 'data' pointer can change between calls to // WebPIUpdate, for instance when the data buffer is resized to fit larger data. WEBP_EXTERN(VP8StatusCode) WebPIUpdate( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // Returns the RGB/A image decoded so far. Returns NULL if output params // are not initialized yet. The RGB/A output type corresponds to the colorspace // specified during call to WebPINewDecoder() or WebPINewRGB(). // *last_y is the index of last decoded row in raster scan order. Some pointers // (*last_y, *width etc.) can be NULL if corresponding information is not // needed. WEBP_EXTERN(uint8_t*) WebPIDecGetRGB( const WebPIDecoder* idec, int* last_y, int* width, int* height, int* stride); // Same as above function to get a YUVA image. Returns pointer to the luma // plane or NULL in case of error. If there is no alpha information // the alpha pointer '*a' will be returned NULL. WEBP_EXTERN(uint8_t*) WebPIDecGetYUVA( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, uint8_t** a, int* width, int* height, int* stride, int* uv_stride, int* a_stride); // Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the // alpha information (if present). Kept for backward compatibility. static WEBP_INLINE uint8_t* WebPIDecGetYUV( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, int* width, int* height, int* stride, int* uv_stride) { return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height, stride, uv_stride, NULL); } // Generic call to retrieve information about the displayable area. // If non NULL, the left/right/width/height pointers are filled with the visible // rectangular area so far. // Returns NULL in case the incremental decoder object is in an invalid state. // Otherwise returns the pointer to the internal representation. This structure // is read-only, tied to WebPIDecoder's lifespan and should not be modified. WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea( const WebPIDecoder* idec, int* left, int* top, int* width, int* height); //------------------------------------------------------------------------------ // Advanced decoding parametrization // // Code sample for using the advanced decoding API /* // A) Init a configuration object WebPDecoderConfig config; CHECK(WebPInitDecoderConfig(&config)); // B) optional: retrieve the bitstream's features. CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK); // C) Adjust 'config', if needed config.no_fancy = 1; config.output.colorspace = MODE_BGRA; // etc. // Note that you can also make config.output point to an externally // supplied memory buffer, provided it's big enough to store the decoded // picture. Otherwise, config.output will just be used to allocate memory // and store the decoded picture. // D) Decode! CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK); // E) Decoded image is now in config.output (and config.output.u.RGBA) // F) Reclaim memory allocated in config's object. It's safe to call // this function even if the memory is external and wasn't allocated // by WebPDecode(). WebPFreeDecBuffer(&config.output); */ // Features gathered from the bitstream typedef struct { int width; // Width in pixels, as read from the bitstream. int height; // Height in pixels, as read from the bitstream. int has_alpha; // True if the bitstream contains an alpha channel. // Unused for now: int bitstream_version; // should be 0 for now. TODO(later) int no_incremental_decoding; // if true, using incremental decoding is not // recommended. int rotate; // TODO(later) int uv_sampling; // should be 0 for now. TODO(later) uint32_t pad[3]; // padding for later use } WebPBitstreamFeatures; // Internal, version-checked, entry point WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal( const uint8_t*, size_t, WebPBitstreamFeatures*, int); // Retrieve features from the bitstream. The *features structure is filled // with information gathered from the bitstream. // Returns false in case of error or version mismatch. // In case of error, features->bitstream_status will reflect the error code. static WEBP_INLINE VP8StatusCode WebPGetFeatures( const uint8_t* data, size_t data_size, WebPBitstreamFeatures* features) { return WebPGetFeaturesInternal(data, data_size, features, WEBP_DECODER_ABI_VERSION); } // Decoding options typedef struct { int bypass_filtering; // if true, skip the in-loop filtering int no_fancy_upsampling; // if true, use faster pointwise upsampler int use_cropping; // if true, cropping is applied _first_ int crop_left, crop_top; // top-left position for cropping. // Will be snapped to even values. int crop_width, crop_height; // dimension of the cropping area int use_scaling; // if true, scaling is applied _afterward_ int scaled_width, scaled_height; // final resolution int use_threads; // if true, use multi-threaded decoding // Unused for now: int force_rotation; // forced rotation (to be applied _last_) int no_enhancement; // if true, discard enhancement layer uint32_t pad[6]; // padding for later use } WebPDecoderOptions; // Main object storing the configuration for advanced decoding. typedef struct { WebPBitstreamFeatures input; // Immutable bitstream features (optional) WebPDecBuffer output; // Output buffer (can point to external mem) WebPDecoderOptions options; // Decoding options } WebPDecoderConfig; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int); // Initialize the configuration as empty. This function must always be // called first, unless WebPGetFeatures() is to be called. // Returns false in case of mismatched version. static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) { return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION); } // Instantiate a new incremental decoder object with the requested // configuration. The bitstream can be passed using 'data' and 'data_size' // parameter, in which case the features will be parsed and stored into // config->input. Otherwise, 'data' can be NULL and no parsing will occur. // Note that 'config' can be NULL too, in which case a default configuration // is used. // The return WebPIDecoder object must always be deleted calling WebPIDelete(). // Returns NULL in case of error (and config->status will then reflect // the error condition). WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); // Non-incremental version. This version decodes the full data at once, taking // 'config' into account. Returns decoding status (which should be VP8_STATUS_OK // if the decoding was successful). WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_DECODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/mac/encode.h ================================================ // Copyright 2011 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // WebP encoder: main interface // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_ENCODE_H_ #define WEBP_WEBP_ENCODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_ENCODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the encoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetEncoderVersion(void); //------------------------------------------------------------------------------ // One-stop-shop call! No questions asked: // Returns the size of the compressed data (pointed to by *output), or 0 if // an error occurred. The compressed data must be released by the caller // using the call 'free(*output)'. // These functions compress using the lossy format, and the quality_factor // can go from 0 (smaller output, lower quality) to 100 (best quality, // larger output). WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride, float quality_factor, uint8_t** output); // These functions are the equivalent of the above, but compressing in a // lossless manner. Files are usually larger than lossy format, but will // not suffer any compression loss. WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height, int stride, uint8_t** output); //------------------------------------------------------------------------------ // Coding parameters // Image characteristics hint for the underlying encoder. typedef enum { WEBP_HINT_DEFAULT = 0, // default preset. WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). WEBP_HINT_LAST } WebPImageHint; typedef struct { int lossless; // Lossless encoding (0=lossy(default), 1=lossless). float quality; // between 0 (smallest file) and 100 (biggest) int method; // quality/speed trade-off (0=fast, 6=slower-better) WebPImageHint image_hint; // Hint for image type (lossless only for now). // Parameters related to lossy compression only: int target_size; // if non-zero, set the desired target size in bytes. // Takes precedence over the 'compression' parameter. float target_PSNR; // if non-zero, specifies the minimal distortion to // try to achieve. Takes precedence over target_size. int segments; // maximum number of segments to use, in [1..4] int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum. int filter_strength; // range: [0 = off .. 100 = strongest] int filter_sharpness; // range: [0 = off .. 7 = least sharp] int filter_type; // filtering type: 0 = simple, 1 = strong (only used // if filter_strength > 0 or autofilter > 0) int autofilter; // Auto adjust filter's strength [0 = off, 1 = on] int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, // 1 = compressed with WebP lossless). Default is 1. int alpha_filtering; // Predictive filtering method for alpha plane. // 0: none, 1: fast, 2: best. Default if 1. int alpha_quality; // Between 0 (smallest size) and 100 (lossless). // Default is 100. int pass; // number of entropy-analysis passes (in [1..10]). int show_compressed; // if true, export the compressed picture back. // In-loop filtering is not applied. int preprocessing; // preprocessing filter (0=none, 1=segment-smooth) int partitions; // log2(number of token partitions) in [0..3]. Default // is set to 0 for easier progressive decoding. int partition_limit; // quality degradation allowed to fit the 512k limit // on prediction modes coding (0: no degradation, // 100: maximum possible degradation). uint32_t pad[8]; // padding for later use } WebPConfig; // Enumerate some predefined settings for WebPConfig, depending on the type // of source picture. These presets are used when calling WebPConfigPreset(). typedef enum { WEBP_PRESET_DEFAULT = 0, // default preset. WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details WEBP_PRESET_ICON, // small-sized colorful images WEBP_PRESET_TEXT // text-like } WebPPreset; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int); // Should always be called, to initialize a fresh WebPConfig structure before // modification. Returns false in case of version mismatch. WebPConfigInit() // must have succeeded before using the 'config' object. // Note that the default values are lossless=0 and quality=75. static WEBP_INLINE int WebPConfigInit(WebPConfig* config) { return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, WEBP_ENCODER_ABI_VERSION); } // This function will initialize the configuration according to a predefined // set of parameters (referred to by 'preset') and a given quality factor. // This function can be called as a replacement to WebPConfigInit(). Will // return false in case of error. static WEBP_INLINE int WebPConfigPreset(WebPConfig* config, WebPPreset preset, float quality) { return WebPConfigInitInternal(config, preset, quality, WEBP_ENCODER_ABI_VERSION); } // Returns true if 'config' is non-NULL and all configuration parameters are // within their valid ranges. WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config); //------------------------------------------------------------------------------ // Input / Output typedef struct WebPPicture WebPPicture; // main structure for I/O // Structure for storing auxiliary statistics (mostly for lossy encoding). typedef struct { int coded_size; // final size float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha int block_count[3]; // number of intra4/intra16/skipped macroblocks int header_bytes[2]; // approximate number of bytes spent for header // and mode-partition #0 int residual_bytes[3][4]; // approximate number of bytes spent for // DC/AC/uv coefficients for each (0..3) segments. int segment_size[4]; // number of macroblocks in each segments int segment_quant[4]; // quantizer values for each segments int segment_level[4]; // filtering strength for each segments [0..63] int alpha_data_size; // size of the transparency data int layer_data_size; // size of the enhancement layer data // lossless encoder statistics uint32_t lossless_features; // bit0:predictor bit1:cross-color transform // bit2:subtract-green bit3:color indexing int histogram_bits; // number of precision bits of histogram int transform_bits; // precision bits for transform int cache_bits; // number of bits for color cache lookup int palette_size; // number of color in palette, if used int lossless_size; // final lossless size uint32_t pad[4]; // padding for later use } WebPAuxStats; // Signature for output function. Should return true if writing was successful. // data/data_size is the segment of data to write, and 'picture' is for // reference (and so one can make use of picture->custom_ptr). typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size, const WebPPicture* picture); // WebPMemoryWrite: a special WebPWriterFunction that writes to memory using // the following WebPMemoryWriter object (to be set as a custom_ptr). typedef struct { uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). size_t size; // final size size_t max_size; // total capacity uint32_t pad[1]; // padding for later use } WebPMemoryWriter; // The following must be called first before any use. WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer); // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon // completion, writer.mem and writer.size will hold the coded data. WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, const WebPPicture* picture); // Progress hook, called from time to time to report progress. It can return // false to request an abort of the encoding process, or true otherwise if // everything is OK. typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture); typedef enum { // chroma sampling WEBP_YUV420 = 0, // 4:2:0 WEBP_YUV422 = 1, // 4:2:2 WEBP_YUV444 = 2, // 4:4:4 WEBP_YUV400 = 3, // grayscale WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors // alpha channel variants WEBP_YUV420A = 4, WEBP_YUV422A = 5, WEBP_YUV444A = 6, WEBP_YUV400A = 7, // grayscale + alpha WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present } WebPEncCSP; // Encoding error conditions. typedef enum { VP8_ENC_OK = 0, VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G VP8_ENC_ERROR_USER_ABORT, // abort request by user VP8_ENC_ERROR_LAST // list terminator. always last. } WebPEncodingError; // maximum width/height allowed (inclusive), in pixels #define WEBP_MAX_DIMENSION 16383 // Main exchange structure (input samples, output bytes, statistics) struct WebPPicture { // INPUT ////////////// // Main flag for encoder selecting between ARGB or YUV input. // It is recommended to use ARGB input (*argb, argb_stride) for lossless // compression, and YUV input (*y, *u, *v, etc.) for lossy compression // since these are the respective native colorspace for these formats. int use_argb; // YUV input (mostly used for input to lossy compression) WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION) uint8_t *y, *u, *v; // pointers to luma/chroma planes. int y_stride, uv_stride; // luma/chroma strides. uint8_t* a; // pointer to the alpha plane int a_stride; // stride of the alpha plane uint32_t pad1[2]; // padding for later use // ARGB input (mostly used for input to lossless compression) uint32_t* argb; // Pointer to argb (32 bit) plane. int argb_stride; // This is stride in pixels units, not bytes. uint32_t pad2[3]; // padding for later use // OUTPUT /////////////// // Byte-emission hook, to store compressed bytes as they are ready. WebPWriterFunction writer; // can be NULL void* custom_ptr; // can be used by the writer. // map for extra information (only for lossy compression mode) int extra_info_type; // 1: intra type, 2: segment, 3: quant // 4: intra-16 prediction mode, // 5: chroma prediction mode, // 6: bit cost, 7: distortion uint8_t* extra_info; // if not NULL, points to an array of size // ((width + 15) / 16) * ((height + 15) / 16) that // will be filled with a macroblock map, depending // on extra_info_type. // STATS AND REPORTS /////////////////////////// // Pointer to side statistics (updated only if not NULL) WebPAuxStats* stats; // Error code for the latest error encountered during encoding WebPEncodingError error_code; // If not NULL, report progress during encoding. WebPProgressHook progress_hook; void* user_data; // this field is free to be set to any value and // used during callbacks (like progress-report e.g.). uint32_t pad3[3]; // padding for later use // Unused for now: original samples (for non-YUV420 modes) uint8_t *u0, *v0; int uv0_stride; uint32_t pad4[7]; // padding for later use // PRIVATE FIELDS //////////////////// void* memory_; // row chunk of memory for yuva planes void* memory_argb_; // and for argb too. void* pad5[2]; // padding for later use }; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int); // Should always be called, to initialize the structure. Returns false in case // of version mismatch. WebPPictureInit() must have succeeded before using the // 'picture' object. // Note that, by default, use_argb is false and colorspace is WEBP_YUV420. static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) { return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); } //------------------------------------------------------------------------------ // WebPPicture utils // Convenience allocation / deallocation based on picture->width/height: // Allocate y/u/v buffers as per colorspace/width/height specification. // Note! This function will free the previous buffer if needed. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture); // Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). // Note that this function does _not_ free the memory used by the 'picture' // object itself. // Besides memory (which is reclaimed) all other fields of 'picture' are // preserved. WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture); // Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, // *dst will fully own the copied pixels (this is not a view). // Returns false in case of memory allocation error. WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); // Compute PSNR or SSIM distortion between two pictures. // Result is in dB, stores in result[] in the Y/U/V/Alpha/All order. // Returns false in case of error (pic1 and pic2 don't have same dimension, ...) // Warning: this function is rather CPU-intensive. WEBP_EXTERN(int) WebPPictureDistortion( const WebPPicture* pic1, const WebPPicture* pic2, int metric_type, // 0 = PSNR, 1 = SSIM float result[5]); // self-crops a picture to the rectangle defined by top/left/width/height. // Returns false in case of memory allocation error, or if the rectangle is // outside of the source picture. // The rectangle for the view is defined by the top-left corner pixel // coordinates (left, top) as well as its width and height. This rectangle // must be fully be comprised inside the 'src' source picture. If the source // picture uses the YUV420 colorspace, the top and left coordinates will be // snapped to even values. WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture, int left, int top, int width, int height); // Extracts a view from 'src' picture into 'dst'. The rectangle for the view // is defined by the top-left corner pixel coordinates (left, top) as well // as its width and height. This rectangle must be fully be comprised inside // the 'src' source picture. If the source picture uses the YUV420 colorspace, // the top and left coordinates will be snapped to even values. // Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed // ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, // the original dimension will be lost). // Returns false in case of memory allocation error or invalid parameters. WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src, int left, int top, int width, int height, WebPPicture* dst); // Returns true if the 'picture' is actually a view and therefore does // not own the memory for pixels. WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture); // Rescale a picture to new dimension width x height. // Now gamma correction is applied. // Returns false in case of error (invalid parameter or insufficient memory). WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height); // Colorspace conversion function to import RGB samples. // Previous buffer will be free'd, if any. // *rgb buffer should have a size of at least height * rgb_stride. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureImportRGB( WebPPicture* picture, const uint8_t* rgb, int rgb_stride); // Same, but for RGBA buffer. WEBP_EXTERN(int) WebPPictureImportRGBA( WebPPicture* picture, const uint8_t* rgba, int rgba_stride); // Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format // input buffer ignoring the alpha channel. Avoids needing to copy the data // to a temporary 24-bit RGB buffer to import the RGB only. WEBP_EXTERN(int) WebPPictureImportRGBX( WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); // Variants of the above, but taking BGR(A|X) input. WEBP_EXTERN(int) WebPPictureImportBGR( WebPPicture* picture, const uint8_t* bgr, int bgr_stride); WEBP_EXTERN(int) WebPPictureImportBGRA( WebPPicture* picture, const uint8_t* bgra, int bgra_stride); WEBP_EXTERN(int) WebPPictureImportBGRX( WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); // Converts picture->argb data to the YUVA format specified by 'colorspace'. // Upon return, picture->use_argb is set to false. The presence of real // non-opaque transparent values is detected, and 'colorspace' will be // adjusted accordingly. Note that this method is lossy. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace); // Converts picture->yuv to picture->argb and sets picture->use_argb to true. // The input format must be YUV_420 or YUV_420A. // Note that the use of this method is discouraged if one has access to the // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the // conversion from YUV420 to ARGB incurs a small loss too. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); // Helper function: given a width x height plane of YUV(A) samples // (with stride 'stride'), clean-up the YUV samples under fully transparent // area, to help compressibility (no guarantee, though). WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); // Scan the picture 'picture' for the presence of non fully opaque alpha values. // Returns true in such case. Otherwise returns false (indicating that the // alpha plane can be ignored altogether e.g.). WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); //------------------------------------------------------------------------------ // Main call // Main encoding call, after config and picture have been initialized. // 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), // and the 'config' object must be a valid one. // Returns false in case of error, true otherwise. // In case of error, picture->error_code is updated accordingly. // 'picture' can hold the source samples in both YUV(A) or ARGB input, depending // on the value of 'picture->use_argb'. It is highly recommended to use // the former for lossy encoding, and the latter for lossless encoding // (when config.lossless is true). Automatic conversion from one format to // another is provided but they both incur some loss. WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_ENCODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/mac/types.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Common types // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_TYPES_H_ #define WEBP_WEBP_TYPES_H_ #include // for size_t #ifndef _MSC_VER #include #ifdef __STRICT_ANSI__ #define WEBP_INLINE #else /* __STRICT_ANSI__ */ #define WEBP_INLINE inline #endif #else typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef unsigned long long int uint64_t; typedef long long int int64_t; #define WEBP_INLINE __forceinline #endif /* _MSC_VER */ #ifndef WEBP_EXTERN // This explicitly marks library functions and allows for changing the // signature for e.g., Windows DLL builds. #define WEBP_EXTERN(type) extern type #endif /* WEBP_EXTERN */ // Macro to check ABI compatibility (same major revision number) #define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8)) #endif /* WEBP_WEBP_TYPES_H_ */ ================================================ FILE: cocos2d/external/webp/include/win32/decode.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Main decoding functions for WebP images. // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_DECODE_H_ #define WEBP_WEBP_DECODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_DECODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the decoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetDecoderVersion(void); // Retrieve basic header information: width, height. // This function will also validate the header and return 0 in // case of formatting error. // Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size, int* width, int* height); // Decodes WebP images pointed to by 'data' and returns RGBA samples, along // with the dimensions in *width and *height. The ordering of samples in // memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). // The returned pointer should be deleted calling free(). // Returns NULL in case of error. WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. // If the bitstream contains transparency, it is ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size, int* width, int* height); // Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data. WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size, int* width, int* height); // Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer // returned is the Y samples buffer. Upon return, *u and *v will point to // the U and V chroma data. These U and V buffers need NOT be free()'d, // unlike the returned Y luma one. The dimension of the U and V planes // are both (*width + 1) / 2 and (*height + 1)/ 2. // Upon return, the Y buffer has a stride returned as '*stride', while U and V // have a common stride returned as '*uv_stride'. // Return NULL in case of error. // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size, int* width, int* height, uint8_t** u, uint8_t** v, int* stride, int* uv_stride); // These five functions are variants of the above ones, that decode the image // directly into a pre-allocated buffer 'output_buffer'. The maximum storage // available in this buffer is indicated by 'output_buffer_size'. If this // storage is not sufficient (or an error occurred), NULL is returned. // Otherwise, output_buffer is returned, for convenience. // The parameter 'output_stride' specifies the distance (in bytes) // between scanlines. Hence, output_buffer_size is expected to be at least // output_stride x picture-height. WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // RGB and BGR variants. Here too the transparency information, if present, // will be dropped and ignored. WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto( const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly // into pre-allocated luma/chroma plane buffers. This function requires the // strides to be passed: one for the luma plane and one for each of the // chroma ones. The size of each plane buffer is passed as 'luma_size', // 'u_size' and 'v_size' respectively. // Pointer to the luma plane ('*luma') is returned or NULL if an error occurred // during decoding (or because some buffers were found to be too small). WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto( const uint8_t* data, size_t data_size, uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); //------------------------------------------------------------------------------ // Output colorspaces and buffer // Colorspaces // Note: the naming describes the byte-ordering of packed samples in memory. // For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,... // Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels. // RGB-565 and RGBA-4444 are also endian-agnostic and byte-oriented. typedef enum { MODE_RGB = 0, MODE_RGBA = 1, MODE_BGR = 2, MODE_BGRA = 3, MODE_ARGB = 4, MODE_RGBA_4444 = 5, MODE_RGB_565 = 6, // RGB-premultiplied transparent modes (alpha value is preserved) MODE_rgbA = 7, MODE_bgrA = 8, MODE_Argb = 9, MODE_rgbA_4444 = 10, // YUV modes must come after RGB ones. MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0 MODE_LAST = 13 } WEBP_CSP_MODE; // Some useful macros: static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) { return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb || mode == MODE_rgbA_4444); } static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) { return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB || mode == MODE_RGBA_4444 || mode == MODE_YUVA || WebPIsPremultipliedMode(mode)); } static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) { return (mode < MODE_YUV); } //------------------------------------------------------------------------------ // WebPDecBuffer: Generic structure for describing the output sample buffer. typedef struct { // view as RGBA uint8_t* rgba; // pointer to RGBA samples int stride; // stride in bytes from one scanline to the next. size_t size; // total size of the *rgba buffer. } WebPRGBABuffer; typedef struct { // view as YUVA uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples int y_stride; // luma stride int u_stride, v_stride; // chroma strides int a_stride; // alpha stride size_t y_size; // luma plane size size_t u_size, v_size; // chroma planes size size_t a_size; // alpha-plane size } WebPYUVABuffer; // Output buffer typedef struct { WEBP_CSP_MODE colorspace; // Colorspace. int width, height; // Dimensions. int is_external_memory; // If true, 'internal_memory' pointer is not used. union { WebPRGBABuffer RGBA; WebPYUVABuffer YUVA; } u; // Nameless union of buffer parameters. uint32_t pad[4]; // padding for later use uint8_t* private_memory; // Internally allocated memory (only when // is_external_memory is false). Should not be used // externally, but accessed via the buffer union. } WebPDecBuffer; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int); // Initialize the structure as empty. Must be called before any other use. // Returns false in case of version mismatch static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) { return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION); } // Free any memory associated with the buffer. Must always be called last. // Note: doesn't free the 'buffer' structure itself. WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer); //------------------------------------------------------------------------------ // Enumeration of the status codes typedef enum { VP8_STATUS_OK = 0, VP8_STATUS_OUT_OF_MEMORY, VP8_STATUS_INVALID_PARAM, VP8_STATUS_BITSTREAM_ERROR, VP8_STATUS_UNSUPPORTED_FEATURE, VP8_STATUS_SUSPENDED, VP8_STATUS_USER_ABORT, VP8_STATUS_NOT_ENOUGH_DATA } VP8StatusCode; //------------------------------------------------------------------------------ // Incremental decoding // // This API allows streamlined decoding of partial data. // Picture can be incrementally decoded as data become available thanks to the // WebPIDecoder object. This object can be left in a SUSPENDED state if the // picture is only partially decoded, pending additional input. // Code example: // // WebPInitDecBuffer(&buffer); // buffer.colorspace = mode; // ... // WebPIDecoder* idec = WebPINewDecoder(&buffer); // while (has_more_data) { // // ... (get additional data) // status = WebPIAppend(idec, new_data, new_data_size); // if (status != VP8_STATUS_SUSPENDED || // break; // } // // // The above call decodes the current available buffer. // // Part of the image can now be refreshed by calling to // // WebPIDecGetRGB()/WebPIDecGetYUVA() etc. // } // WebPIDelete(idec); typedef struct WebPIDecoder WebPIDecoder; // Creates a new incremental decoder with the supplied buffer parameter. // This output_buffer can be passed NULL, in which case a default output buffer // is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' // is kept, which means that the lifespan of 'output_buffer' must be larger than // that of the returned WebPIDecoder object. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer); // This function allocates and initializes an incremental-decoder object, which // will output the RGB/A samples specified by 'csp' into a preallocated // buffer 'output_buffer'. The size of this buffer is at least // 'output_buffer_size' and the stride (distance in bytes between two scanlines) // is specified by 'output_stride'. Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewRGB( WEBP_CSP_MODE csp, uint8_t* output_buffer, size_t output_buffer_size, int output_stride); // This function allocates and initializes an incremental-decoder object, which // will output the raw luma/chroma samples into a preallocated planes. The luma // plane is specified by its pointer 'luma', its size 'luma_size' and its stride // 'luma_stride'. Similarly, the chroma-u plane is specified by the 'u', // 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v' // and 'v_size'. And same for the alpha-plane. The 'a' pointer can be pass // NULL in case one is not interested in the transparency plane. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewYUVA( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride, uint8_t* a, size_t a_size, int a_stride); // Deprecated version of the above, without the alpha plane. // Kept for backward compatibility. WEBP_EXTERN(WebPIDecoder*) WebPINewYUV( uint8_t* luma, size_t luma_size, int luma_stride, uint8_t* u, size_t u_size, int u_stride, uint8_t* v, size_t v_size, int v_stride); // Deletes the WebPIDecoder object and associated memory. Must always be called // if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded. WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec); // Copies and decodes the next available data. Returns VP8_STATUS_OK when // the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more // data is expected. Returns error in other cases. WEBP_EXTERN(VP8StatusCode) WebPIAppend( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // A variant of the above function to be used when data buffer contains // partial data from the beginning. In this case data buffer is not copied // to the internal memory. // Note that the value of the 'data' pointer can change between calls to // WebPIUpdate, for instance when the data buffer is resized to fit larger data. WEBP_EXTERN(VP8StatusCode) WebPIUpdate( WebPIDecoder* idec, const uint8_t* data, size_t data_size); // Returns the RGB/A image decoded so far. Returns NULL if output params // are not initialized yet. The RGB/A output type corresponds to the colorspace // specified during call to WebPINewDecoder() or WebPINewRGB(). // *last_y is the index of last decoded row in raster scan order. Some pointers // (*last_y, *width etc.) can be NULL if corresponding information is not // needed. WEBP_EXTERN(uint8_t*) WebPIDecGetRGB( const WebPIDecoder* idec, int* last_y, int* width, int* height, int* stride); // Same as above function to get a YUVA image. Returns pointer to the luma // plane or NULL in case of error. If there is no alpha information // the alpha pointer '*a' will be returned NULL. WEBP_EXTERN(uint8_t*) WebPIDecGetYUVA( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, uint8_t** a, int* width, int* height, int* stride, int* uv_stride, int* a_stride); // Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the // alpha information (if present). Kept for backward compatibility. static WEBP_INLINE uint8_t* WebPIDecGetYUV( const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, int* width, int* height, int* stride, int* uv_stride) { return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height, stride, uv_stride, NULL); } // Generic call to retrieve information about the displayable area. // If non NULL, the left/right/width/height pointers are filled with the visible // rectangular area so far. // Returns NULL in case the incremental decoder object is in an invalid state. // Otherwise returns the pointer to the internal representation. This structure // is read-only, tied to WebPIDecoder's lifespan and should not be modified. WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea( const WebPIDecoder* idec, int* left, int* top, int* width, int* height); //------------------------------------------------------------------------------ // Advanced decoding parametrization // // Code sample for using the advanced decoding API /* // A) Init a configuration object WebPDecoderConfig config; CHECK(WebPInitDecoderConfig(&config)); // B) optional: retrieve the bitstream's features. CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK); // C) Adjust 'config', if needed config.no_fancy = 1; config.output.colorspace = MODE_BGRA; // etc. // Note that you can also make config.output point to an externally // supplied memory buffer, provided it's big enough to store the decoded // picture. Otherwise, config.output will just be used to allocate memory // and store the decoded picture. // D) Decode! CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK); // E) Decoded image is now in config.output (and config.output.u.RGBA) // F) Reclaim memory allocated in config's object. It's safe to call // this function even if the memory is external and wasn't allocated // by WebPDecode(). WebPFreeDecBuffer(&config.output); */ // Features gathered from the bitstream typedef struct { int width; // Width in pixels, as read from the bitstream. int height; // Height in pixels, as read from the bitstream. int has_alpha; // True if the bitstream contains an alpha channel. // Unused for now: int bitstream_version; // should be 0 for now. TODO(later) int no_incremental_decoding; // if true, using incremental decoding is not // recommended. int rotate; // TODO(later) int uv_sampling; // should be 0 for now. TODO(later) uint32_t pad[3]; // padding for later use } WebPBitstreamFeatures; // Internal, version-checked, entry point WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal( const uint8_t*, size_t, WebPBitstreamFeatures*, int); // Retrieve features from the bitstream. The *features structure is filled // with information gathered from the bitstream. // Returns false in case of error or version mismatch. // In case of error, features->bitstream_status will reflect the error code. static WEBP_INLINE VP8StatusCode WebPGetFeatures( const uint8_t* data, size_t data_size, WebPBitstreamFeatures* features) { return WebPGetFeaturesInternal(data, data_size, features, WEBP_DECODER_ABI_VERSION); } // Decoding options typedef struct { int bypass_filtering; // if true, skip the in-loop filtering int no_fancy_upsampling; // if true, use faster pointwise upsampler int use_cropping; // if true, cropping is applied _first_ int crop_left, crop_top; // top-left position for cropping. // Will be snapped to even values. int crop_width, crop_height; // dimension of the cropping area int use_scaling; // if true, scaling is applied _afterward_ int scaled_width, scaled_height; // final resolution int use_threads; // if true, use multi-threaded decoding // Unused for now: int force_rotation; // forced rotation (to be applied _last_) int no_enhancement; // if true, discard enhancement layer uint32_t pad[6]; // padding for later use } WebPDecoderOptions; // Main object storing the configuration for advanced decoding. typedef struct { WebPBitstreamFeatures input; // Immutable bitstream features (optional) WebPDecBuffer output; // Output buffer (can point to external mem) WebPDecoderOptions options; // Decoding options } WebPDecoderConfig; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int); // Initialize the configuration as empty. This function must always be // called first, unless WebPGetFeatures() is to be called. // Returns false in case of mismatched version. static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) { return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION); } // Instantiate a new incremental decoder object with the requested // configuration. The bitstream can be passed using 'data' and 'data_size' // parameter, in which case the features will be parsed and stored into // config->input. Otherwise, 'data' can be NULL and no parsing will occur. // Note that 'config' can be NULL too, in which case a default configuration // is used. // The return WebPIDecoder object must always be deleted calling WebPIDelete(). // Returns NULL in case of error (and config->status will then reflect // the error condition). WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); // Non-incremental version. This version decodes the full data at once, taking // 'config' into account. Returns decoding status (which should be VP8_STATUS_OK // if the decoding was successful). WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size, WebPDecoderConfig* config); #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_DECODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/win32/encode.h ================================================ // Copyright 2011 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // WebP encoder: main interface // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_ENCODE_H_ #define WEBP_WEBP_ENCODE_H_ #include "./types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif #define WEBP_ENCODER_ABI_VERSION 0x0200 // MAJOR(8b) + MINOR(8b) // Return the encoder's version number, packed in hexadecimal using 8bits for // each of major/minor/revision. E.g: v2.5.7 is 0x020507. WEBP_EXTERN(int) WebPGetEncoderVersion(void); //------------------------------------------------------------------------------ // One-stop-shop call! No questions asked: // Returns the size of the compressed data (pointed to by *output), or 0 if // an error occurred. The compressed data must be released by the caller // using the call 'free(*output)'. // These functions compress using the lossy format, and the quality_factor // can go from 0 (smaller output, lower quality) to 100 (best quality, // larger output). WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride, float quality_factor, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride, float quality_factor, uint8_t** output); // These functions are the equivalent of the above, but compressing in a // lossless manner. Files are usually larger than lossy format, but will // not suffer any compression loss. WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height, int stride, uint8_t** output); WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height, int stride, uint8_t** output); //------------------------------------------------------------------------------ // Coding parameters // Image characteristics hint for the underlying encoder. typedef enum { WEBP_HINT_DEFAULT = 0, // default preset. WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). WEBP_HINT_LAST } WebPImageHint; typedef struct { int lossless; // Lossless encoding (0=lossy(default), 1=lossless). float quality; // between 0 (smallest file) and 100 (biggest) int method; // quality/speed trade-off (0=fast, 6=slower-better) WebPImageHint image_hint; // Hint for image type (lossless only for now). // Parameters related to lossy compression only: int target_size; // if non-zero, set the desired target size in bytes. // Takes precedence over the 'compression' parameter. float target_PSNR; // if non-zero, specifies the minimal distortion to // try to achieve. Takes precedence over target_size. int segments; // maximum number of segments to use, in [1..4] int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum. int filter_strength; // range: [0 = off .. 100 = strongest] int filter_sharpness; // range: [0 = off .. 7 = least sharp] int filter_type; // filtering type: 0 = simple, 1 = strong (only used // if filter_strength > 0 or autofilter > 0) int autofilter; // Auto adjust filter's strength [0 = off, 1 = on] int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, // 1 = compressed with WebP lossless). Default is 1. int alpha_filtering; // Predictive filtering method for alpha plane. // 0: none, 1: fast, 2: best. Default if 1. int alpha_quality; // Between 0 (smallest size) and 100 (lossless). // Default is 100. int pass; // number of entropy-analysis passes (in [1..10]). int show_compressed; // if true, export the compressed picture back. // In-loop filtering is not applied. int preprocessing; // preprocessing filter (0=none, 1=segment-smooth) int partitions; // log2(number of token partitions) in [0..3]. Default // is set to 0 for easier progressive decoding. int partition_limit; // quality degradation allowed to fit the 512k limit // on prediction modes coding (0: no degradation, // 100: maximum possible degradation). uint32_t pad[8]; // padding for later use } WebPConfig; // Enumerate some predefined settings for WebPConfig, depending on the type // of source picture. These presets are used when calling WebPConfigPreset(). typedef enum { WEBP_PRESET_DEFAULT = 0, // default preset. WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details WEBP_PRESET_ICON, // small-sized colorful images WEBP_PRESET_TEXT // text-like } WebPPreset; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int); // Should always be called, to initialize a fresh WebPConfig structure before // modification. Returns false in case of version mismatch. WebPConfigInit() // must have succeeded before using the 'config' object. // Note that the default values are lossless=0 and quality=75. static WEBP_INLINE int WebPConfigInit(WebPConfig* config) { return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, WEBP_ENCODER_ABI_VERSION); } // This function will initialize the configuration according to a predefined // set of parameters (referred to by 'preset') and a given quality factor. // This function can be called as a replacement to WebPConfigInit(). Will // return false in case of error. static WEBP_INLINE int WebPConfigPreset(WebPConfig* config, WebPPreset preset, float quality) { return WebPConfigInitInternal(config, preset, quality, WEBP_ENCODER_ABI_VERSION); } // Returns true if 'config' is non-NULL and all configuration parameters are // within their valid ranges. WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config); //------------------------------------------------------------------------------ // Input / Output typedef struct WebPPicture WebPPicture; // main structure for I/O // Structure for storing auxiliary statistics (mostly for lossy encoding). typedef struct { int coded_size; // final size float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha int block_count[3]; // number of intra4/intra16/skipped macroblocks int header_bytes[2]; // approximate number of bytes spent for header // and mode-partition #0 int residual_bytes[3][4]; // approximate number of bytes spent for // DC/AC/uv coefficients for each (0..3) segments. int segment_size[4]; // number of macroblocks in each segments int segment_quant[4]; // quantizer values for each segments int segment_level[4]; // filtering strength for each segments [0..63] int alpha_data_size; // size of the transparency data int layer_data_size; // size of the enhancement layer data // lossless encoder statistics uint32_t lossless_features; // bit0:predictor bit1:cross-color transform // bit2:subtract-green bit3:color indexing int histogram_bits; // number of precision bits of histogram int transform_bits; // precision bits for transform int cache_bits; // number of bits for color cache lookup int palette_size; // number of color in palette, if used int lossless_size; // final lossless size uint32_t pad[4]; // padding for later use } WebPAuxStats; // Signature for output function. Should return true if writing was successful. // data/data_size is the segment of data to write, and 'picture' is for // reference (and so one can make use of picture->custom_ptr). typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size, const WebPPicture* picture); // WebPMemoryWrite: a special WebPWriterFunction that writes to memory using // the following WebPMemoryWriter object (to be set as a custom_ptr). typedef struct { uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). size_t size; // final size size_t max_size; // total capacity uint32_t pad[1]; // padding for later use } WebPMemoryWriter; // The following must be called first before any use. WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer); // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon // completion, writer.mem and writer.size will hold the coded data. WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, const WebPPicture* picture); // Progress hook, called from time to time to report progress. It can return // false to request an abort of the encoding process, or true otherwise if // everything is OK. typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture); typedef enum { // chroma sampling WEBP_YUV420 = 0, // 4:2:0 WEBP_YUV422 = 1, // 4:2:2 WEBP_YUV444 = 2, // 4:4:4 WEBP_YUV400 = 3, // grayscale WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors // alpha channel variants WEBP_YUV420A = 4, WEBP_YUV422A = 5, WEBP_YUV444A = 6, WEBP_YUV400A = 7, // grayscale + alpha WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present } WebPEncCSP; // Encoding error conditions. typedef enum { VP8_ENC_OK = 0, VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G VP8_ENC_ERROR_USER_ABORT, // abort request by user VP8_ENC_ERROR_LAST // list terminator. always last. } WebPEncodingError; // maximum width/height allowed (inclusive), in pixels #define WEBP_MAX_DIMENSION 16383 // Main exchange structure (input samples, output bytes, statistics) struct WebPPicture { // INPUT ////////////// // Main flag for encoder selecting between ARGB or YUV input. // It is recommended to use ARGB input (*argb, argb_stride) for lossless // compression, and YUV input (*y, *u, *v, etc.) for lossy compression // since these are the respective native colorspace for these formats. int use_argb; // YUV input (mostly used for input to lossy compression) WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION) uint8_t *y, *u, *v; // pointers to luma/chroma planes. int y_stride, uv_stride; // luma/chroma strides. uint8_t* a; // pointer to the alpha plane int a_stride; // stride of the alpha plane uint32_t pad1[2]; // padding for later use // ARGB input (mostly used for input to lossless compression) uint32_t* argb; // Pointer to argb (32 bit) plane. int argb_stride; // This is stride in pixels units, not bytes. uint32_t pad2[3]; // padding for later use // OUTPUT /////////////// // Byte-emission hook, to store compressed bytes as they are ready. WebPWriterFunction writer; // can be NULL void* custom_ptr; // can be used by the writer. // map for extra information (only for lossy compression mode) int extra_info_type; // 1: intra type, 2: segment, 3: quant // 4: intra-16 prediction mode, // 5: chroma prediction mode, // 6: bit cost, 7: distortion uint8_t* extra_info; // if not NULL, points to an array of size // ((width + 15) / 16) * ((height + 15) / 16) that // will be filled with a macroblock map, depending // on extra_info_type. // STATS AND REPORTS /////////////////////////// // Pointer to side statistics (updated only if not NULL) WebPAuxStats* stats; // Error code for the latest error encountered during encoding WebPEncodingError error_code; // If not NULL, report progress during encoding. WebPProgressHook progress_hook; void* user_data; // this field is free to be set to any value and // used during callbacks (like progress-report e.g.). uint32_t pad3[3]; // padding for later use // Unused for now: original samples (for non-YUV420 modes) uint8_t *u0, *v0; int uv0_stride; uint32_t pad4[7]; // padding for later use // PRIVATE FIELDS //////////////////// void* memory_; // row chunk of memory for yuva planes void* memory_argb_; // and for argb too. void* pad5[2]; // padding for later use }; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int); // Should always be called, to initialize the structure. Returns false in case // of version mismatch. WebPPictureInit() must have succeeded before using the // 'picture' object. // Note that, by default, use_argb is false and colorspace is WEBP_YUV420. static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) { return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); } //------------------------------------------------------------------------------ // WebPPicture utils // Convenience allocation / deallocation based on picture->width/height: // Allocate y/u/v buffers as per colorspace/width/height specification. // Note! This function will free the previous buffer if needed. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture); // Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). // Note that this function does _not_ free the memory used by the 'picture' // object itself. // Besides memory (which is reclaimed) all other fields of 'picture' are // preserved. WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture); // Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, // *dst will fully own the copied pixels (this is not a view). // Returns false in case of memory allocation error. WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); // Compute PSNR or SSIM distortion between two pictures. // Result is in dB, stores in result[] in the Y/U/V/Alpha/All order. // Returns false in case of error (pic1 and pic2 don't have same dimension, ...) // Warning: this function is rather CPU-intensive. WEBP_EXTERN(int) WebPPictureDistortion( const WebPPicture* pic1, const WebPPicture* pic2, int metric_type, // 0 = PSNR, 1 = SSIM float result[5]); // self-crops a picture to the rectangle defined by top/left/width/height. // Returns false in case of memory allocation error, or if the rectangle is // outside of the source picture. // The rectangle for the view is defined by the top-left corner pixel // coordinates (left, top) as well as its width and height. This rectangle // must be fully be comprised inside the 'src' source picture. If the source // picture uses the YUV420 colorspace, the top and left coordinates will be // snapped to even values. WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture, int left, int top, int width, int height); // Extracts a view from 'src' picture into 'dst'. The rectangle for the view // is defined by the top-left corner pixel coordinates (left, top) as well // as its width and height. This rectangle must be fully be comprised inside // the 'src' source picture. If the source picture uses the YUV420 colorspace, // the top and left coordinates will be snapped to even values. // Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed // ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, // the original dimension will be lost). // Returns false in case of memory allocation error or invalid parameters. WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src, int left, int top, int width, int height, WebPPicture* dst); // Returns true if the 'picture' is actually a view and therefore does // not own the memory for pixels. WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture); // Rescale a picture to new dimension width x height. // Now gamma correction is applied. // Returns false in case of error (invalid parameter or insufficient memory). WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height); // Colorspace conversion function to import RGB samples. // Previous buffer will be free'd, if any. // *rgb buffer should have a size of at least height * rgb_stride. // Returns false in case of memory error. WEBP_EXTERN(int) WebPPictureImportRGB( WebPPicture* picture, const uint8_t* rgb, int rgb_stride); // Same, but for RGBA buffer. WEBP_EXTERN(int) WebPPictureImportRGBA( WebPPicture* picture, const uint8_t* rgba, int rgba_stride); // Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format // input buffer ignoring the alpha channel. Avoids needing to copy the data // to a temporary 24-bit RGB buffer to import the RGB only. WEBP_EXTERN(int) WebPPictureImportRGBX( WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); // Variants of the above, but taking BGR(A|X) input. WEBP_EXTERN(int) WebPPictureImportBGR( WebPPicture* picture, const uint8_t* bgr, int bgr_stride); WEBP_EXTERN(int) WebPPictureImportBGRA( WebPPicture* picture, const uint8_t* bgra, int bgra_stride); WEBP_EXTERN(int) WebPPictureImportBGRX( WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); // Converts picture->argb data to the YUVA format specified by 'colorspace'. // Upon return, picture->use_argb is set to false. The presence of real // non-opaque transparent values is detected, and 'colorspace' will be // adjusted accordingly. Note that this method is lossy. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace); // Converts picture->yuv to picture->argb and sets picture->use_argb to true. // The input format must be YUV_420 or YUV_420A. // Note that the use of this method is discouraged if one has access to the // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the // conversion from YUV420 to ARGB incurs a small loss too. // Returns false in case of error. WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); // Helper function: given a width x height plane of YUV(A) samples // (with stride 'stride'), clean-up the YUV samples under fully transparent // area, to help compressibility (no guarantee, though). WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); // Scan the picture 'picture' for the presence of non fully opaque alpha values. // Returns true in such case. Otherwise returns false (indicating that the // alpha plane can be ignored altogether e.g.). WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); //------------------------------------------------------------------------------ // Main call // Main encoding call, after config and picture have been initialized. // 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), // and the 'config' object must be a valid one. // Returns false in case of error, true otherwise. // In case of error, picture->error_code is updated accordingly. // 'picture' can hold the source samples in both YUV(A) or ARGB input, depending // on the value of 'picture->use_argb'. It is highly recommended to use // the former for lossy encoding, and the latter for lossless encoding // (when config.lossless is true). Automatic conversion from one format to // another is provided but they both incur some loss. WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" #endif #endif /* WEBP_WEBP_ENCODE_H_ */ ================================================ FILE: cocos2d/external/webp/include/win32/types.h ================================================ // Copyright 2010 Google Inc. All Rights Reserved. // // This code is licensed under the same terms as WebM: // Software License Agreement: http://www.webmproject.org/license/software/ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // // Common types // // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_WEBP_TYPES_H_ #define WEBP_WEBP_TYPES_H_ #include // for size_t #ifndef _MSC_VER #include #ifdef __STRICT_ANSI__ #define WEBP_INLINE #else /* __STRICT_ANSI__ */ #define WEBP_INLINE inline #endif #else typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef unsigned long long int uint64_t; typedef long long int int64_t; #define WEBP_INLINE __forceinline #endif /* _MSC_VER */ #ifndef WEBP_EXTERN // This explicitly marks library functions and allows for changing the // signature for e.g., Windows DLL builds. #define WEBP_EXTERN(type) extern type #endif /* WEBP_EXTERN */ // Macro to check ABI compatibility (same major revision number) #define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8)) #endif /* WEBP_WEBP_TYPES_H_ */ ================================================ FILE: cocos2d/external/webp/prebuilt/android/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos_webp_static LOCAL_MODULE_FILENAME := webp LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libwebp.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android LOCAL_WHOLE_STATIC_LIBRARIES := cpufeatures ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) LOCAL_CFLAGS := -DHAVE_NEON=1 endif include $(PREBUILT_STATIC_LIBRARY) $(call import-module, android/cpufeatures) ================================================ FILE: cocos2d/external/websockets/include/android/libwebsockets.h ================================================ /* * 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 ================================================ FILE: cocos2d/external/websockets/include/ios/libwebsockets.h ================================================ /* * 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 ================================================ FILE: cocos2d/external/websockets/include/mac/libwebsockets.h ================================================ /* * 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 ================================================ FILE: cocos2d/external/websockets/include/win32/libwebsockets.h ================================================ /* * 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 "win32helpers/websock-w32.h" //#include "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 ================================================ FILE: cocos2d/external/websockets/include/win32/win32helpers/gettimeofday.h ================================================ #ifndef _GET_TIME_OF_DAY_H #define _GET_TIME_OF_DAY_H #ifdef __MINGW64__ #else #ifdef __MINGW32__ #else #include < time.h > #endif #endif #include //I've ommited context line. #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 #else #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL #endif struct timezone { int tz_minuteswest; /* minutes W of Greenwich */ int tz_dsttime; /* type of dst correction */ }; int gettimeofday(struct timeval *tv, struct timezone *tz); #endif ================================================ FILE: cocos2d/external/websockets/include/win32/win32helpers/websock-w32.h ================================================ #ifndef __WEB_SOCK_W32_H__ #define __WEB_SOCK_W32_H__ // Windows uses _DEBUG and NDEBUG #ifdef _DEBUG #undef DEBUG #define DEBUG 1 #endif #pragma warning(disable : 4996) #define bzero(b,len) (memset((b), '\0', (len)), (void) 0) #define MSG_NOSIGNAL 0 #define SHUT_RDWR SD_BOTH #define SOL_TCP IPPROTO_TCP #define random rand #define usleep _sleep #ifdef __MINGW64__ #define DEF_POLL_STUFF #endif #ifdef __MINGW32__ #define DEF_POLL_STUFF #endif #ifdef DEF_POLL_STUFF #include typedef struct pollfd { SOCKET fd; short events; short revents; } WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; #define POLLIN 0x0001 /* any readable data available */ #define POLLOUT 0x0004 /* file descriptor is writeable */ #define POLLERR 0x0008 /* some poll error occurred */ #define POLLHUP 0x0010 /* file descriptor was "hung up" */ #define POLLNVAL 0x0020 /* requested events "invalid" */ #endif typedef INT (WSAAPI *PFNWSAPOLL)(LPWSAPOLLFD fdarray, ULONG nfds, INT timeout); extern PFNWSAPOLL poll; extern INT WSAAPI emulated_poll(LPWSAPOLLFD fdarray, ULONG nfds, INT timeout); /* override configure because we are not using Makefiles */ #define LWS_NO_FORK /* windows can't cope with this idea, needs assets in cwd */ #ifndef INSTALL_DATADIR #define INSTALL_DATADIR "." #endif #endif ================================================ FILE: cocos2d/external/websockets/prebuilt/android/Android.mk ================================================ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := websockets_static LOCAL_MODULE_FILENAME := libwebsockets_static LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libwebsockets.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../include/android LOCAL_CPPFLAGS := -D__STDC_LIMIT_MACROS=1 LOCAL_EXPORT_CPPFLAGS := -D__STDC_LIMIT_MACROS=1 include $(PREBUILT_STATIC_LIBRARY) ================================================ FILE: cocos2d/external/win32-specific/gles/include/OGLES/GL/glew.h ================================================ /* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2002-2008, Milan Ikits ** Copyright (C) 2002-2008, Marcelo E. Magallon ** Copyright (C) 2002, Lev Povalahev ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** ** * Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** * 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. ** * 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ /* * Mesa 3-D graphics library * Version: 7.0 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * 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 * BRIAN PAUL 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. */ /* ** Copyright (c) 2007 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ #ifndef __glew_h__ #define __glew_h__ #define __GLEW_H__ #if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H) #error gl.h included before glew.h #endif #if defined(__glext_h_) || defined(__GLEXT_H_) #error glext.h included before glew.h #endif #if defined(__gl_ATI_h_) #error glATI.h included before glew.h #endif #define __gl_h_ #define __GL_H__ #define __X_GL_H #define __glext_h_ #define __GLEXT_H_ #define __gl_ATI_h_ #if defined(_WIN32) /* * GLEW does not include to avoid name space pollution. * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t * defined properly. */ /* */ #ifndef APIENTRY #define GLEW_APIENTRY_DEFINED # if defined(__MINGW32__) || defined(__CYGWIN__) # define APIENTRY __stdcall # elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) # define APIENTRY __stdcall # else # define APIENTRY # endif #endif #ifndef GLAPI # if defined(__MINGW32__) || defined(__CYGWIN__) # define GLAPI extern # endif #endif /* */ #ifndef CALLBACK #define GLEW_CALLBACK_DEFINED # if defined(__MINGW32__) || defined(__CYGWIN__) # define CALLBACK __attribute__ ((__stdcall__)) # elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) # define CALLBACK __stdcall # else # define CALLBACK # endif #endif /* and */ #ifndef WINGDIAPI #define GLEW_WINGDIAPI_DEFINED #define WINGDIAPI __declspec(dllimport) #endif /* */ #if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED) typedef unsigned short wchar_t; # define _WCHAR_T_DEFINED #endif /* */ #if !defined(_W64) # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && defined(_MSC_VER) && _MSC_VER >= 1300 # define _W64 __w64 # else # define _W64 # endif #endif #if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) && !defined(__MINGW64__) # ifdef _WIN64 typedef __int64 ptrdiff_t; # else typedef _W64 int ptrdiff_t; # endif # define _PTRDIFF_T_DEFINED # define _PTRDIFF_T_ #endif #ifndef GLAPI # if defined(__MINGW32__) || defined(__CYGWIN__) # define GLAPI extern # else # define GLAPI WINGDIAPI # endif #endif #ifndef GLAPIENTRY #define GLAPIENTRY APIENTRY #endif /* * GLEW_STATIC is defined for static library. * GLEW_BUILD is defined for building the DLL library. */ #ifdef GLEW_STATIC # define GLEWAPI extern #else # ifdef GLEW_BUILD # define GLEWAPI extern __declspec(dllexport) # else # define GLEWAPI extern __declspec(dllimport) # endif #endif #else /* _UNIX */ /* * Needed for ptrdiff_t in turn needed by VBO. This is defined by ISO * C. On my system, this amounts to _3 lines_ of included code, all of * them pretty much harmless. If you know of a way of detecting 32 vs * 64 _targets_ at compile time you are free to replace this with * something that's portable. For now, _this_ is the portable solution. * (mem, 2004-01-04) */ #include /* SGI MIPSPro doesn't like stdint.h in C++ mode */ /* ID: 3376260 Solaris 9 has inttypes.h, but not stdint.h */ #if (defined(__sgi) || defined(__sun)) && !defined(__GNUC__) #include #else #include #endif #define GLEW_APIENTRY_DEFINED #define APIENTRY /* * GLEW_STATIC is defined for static library. */ #ifdef GLEW_STATIC # define GLEWAPI extern #else # if defined(__GNUC__) && __GNUC__>=4 # define GLEWAPI extern __attribute__ ((visibility("default"))) # elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) # define GLEWAPI extern __global # else # define GLEWAPI extern # endif #endif /* */ #ifndef GLAPI #define GLAPI extern #endif #ifndef GLAPIENTRY #define GLAPIENTRY #endif #endif /* _WIN32 */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------- GL_VERSION_1_1 ---------------------------- */ #ifndef GL_VERSION_1_1 #define GL_VERSION_1_1 1 typedef unsigned int GLenum; typedef unsigned int GLbitfield; typedef unsigned int GLuint; typedef int GLint; typedef int GLsizei; typedef unsigned char GLboolean; typedef signed char GLbyte; typedef short GLshort; typedef unsigned char GLubyte; typedef unsigned short GLushort; typedef unsigned long GLulong; typedef float GLfloat; typedef float GLclampf; typedef double GLdouble; typedef double GLclampd; typedef void GLvoid; #if defined(_MSC_VER) && _MSC_VER < 1400 typedef __int64 GLint64EXT; typedef unsigned __int64 GLuint64EXT; #elif defined(_MSC_VER) || defined(__BORLANDC__) typedef signed long long GLint64EXT; typedef unsigned long long GLuint64EXT; #else # if defined(__MINGW32__) || defined(__CYGWIN__) #include # endif typedef int64_t GLint64EXT; typedef uint64_t GLuint64EXT; #endif typedef GLint64EXT GLint64; typedef GLuint64EXT GLuint64; typedef struct __GLsync *GLsync; typedef char GLchar; #define GL_ZERO 0 #define GL_FALSE 0 #define GL_LOGIC_OP 0x0BF1 #define GL_NONE 0 #define GL_TEXTURE_COMPONENTS 0x1003 #define GL_NO_ERROR 0 #define GL_POINTS 0x0000 #define GL_CURRENT_BIT 0x00000001 #define GL_TRUE 1 #define GL_ONE 1 #define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 #define GL_LINES 0x0001 #define GL_LINE_LOOP 0x0002 #define GL_POINT_BIT 0x00000002 #define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 #define GL_LINE_STRIP 0x0003 #define GL_LINE_BIT 0x00000004 #define GL_TRIANGLES 0x0004 #define GL_TRIANGLE_STRIP 0x0005 #define GL_TRIANGLE_FAN 0x0006 #define GL_QUADS 0x0007 #define GL_QUAD_STRIP 0x0008 #define GL_POLYGON_BIT 0x00000008 #define GL_POLYGON 0x0009 #define GL_POLYGON_STIPPLE_BIT 0x00000010 #define GL_PIXEL_MODE_BIT 0x00000020 #define GL_LIGHTING_BIT 0x00000040 #define GL_FOG_BIT 0x00000080 #define GL_DEPTH_BUFFER_BIT 0x00000100 #define GL_ACCUM 0x0100 #define GL_LOAD 0x0101 #define GL_RETURN 0x0102 #define GL_MULT 0x0103 #define GL_ADD 0x0104 #define GL_NEVER 0x0200 #define GL_ACCUM_BUFFER_BIT 0x00000200 #define GL_LESS 0x0201 #define GL_EQUAL 0x0202 #define GL_LEQUAL 0x0203 #define GL_GREATER 0x0204 #define GL_NOTEQUAL 0x0205 #define GL_GEQUAL 0x0206 #define GL_ALWAYS 0x0207 #define GL_SRC_COLOR 0x0300 #define GL_ONE_MINUS_SRC_COLOR 0x0301 #define GL_SRC_ALPHA 0x0302 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 #define GL_DST_ALPHA 0x0304 #define GL_ONE_MINUS_DST_ALPHA 0x0305 #define GL_DST_COLOR 0x0306 #define GL_ONE_MINUS_DST_COLOR 0x0307 #define GL_SRC_ALPHA_SATURATE 0x0308 #define GL_STENCIL_BUFFER_BIT 0x00000400 #define GL_FRONT_LEFT 0x0400 #define GL_FRONT_RIGHT 0x0401 #define GL_BACK_LEFT 0x0402 #define GL_BACK_RIGHT 0x0403 #define GL_FRONT 0x0404 #define GL_BACK 0x0405 #define GL_LEFT 0x0406 #define GL_RIGHT 0x0407 #define GL_FRONT_AND_BACK 0x0408 #define GL_AUX0 0x0409 #define GL_AUX1 0x040A #define GL_AUX2 0x040B #define GL_AUX3 0x040C #define GL_INVALID_ENUM 0x0500 #define GL_INVALID_VALUE 0x0501 #define GL_INVALID_OPERATION 0x0502 #define GL_STACK_OVERFLOW 0x0503 #define GL_STACK_UNDERFLOW 0x0504 #define GL_OUT_OF_MEMORY 0x0505 #define GL_2D 0x0600 #define GL_3D 0x0601 #define GL_3D_COLOR 0x0602 #define GL_3D_COLOR_TEXTURE 0x0603 #define GL_4D_COLOR_TEXTURE 0x0604 #define GL_PASS_THROUGH_TOKEN 0x0700 #define GL_POINT_TOKEN 0x0701 #define GL_LINE_TOKEN 0x0702 #define GL_POLYGON_TOKEN 0x0703 #define GL_BITMAP_TOKEN 0x0704 #define GL_DRAW_PIXEL_TOKEN 0x0705 #define GL_COPY_PIXEL_TOKEN 0x0706 #define GL_LINE_RESET_TOKEN 0x0707 #define GL_EXP 0x0800 #define GL_VIEWPORT_BIT 0x00000800 #define GL_EXP2 0x0801 #define GL_CW 0x0900 #define GL_CCW 0x0901 #define GL_COEFF 0x0A00 #define GL_ORDER 0x0A01 #define GL_DOMAIN 0x0A02 #define GL_CURRENT_COLOR 0x0B00 #define GL_CURRENT_INDEX 0x0B01 #define GL_CURRENT_NORMAL 0x0B02 #define GL_CURRENT_TEXTURE_COORDS 0x0B03 #define GL_CURRENT_RASTER_COLOR 0x0B04 #define GL_CURRENT_RASTER_INDEX 0x0B05 #define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 #define GL_CURRENT_RASTER_POSITION 0x0B07 #define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 #define GL_CURRENT_RASTER_DISTANCE 0x0B09 #define GL_POINT_SMOOTH 0x0B10 #define GL_POINT_SIZE 0x0B11 #define GL_POINT_SIZE_RANGE 0x0B12 #define GL_POINT_SIZE_GRANULARITY 0x0B13 #define GL_LINE_SMOOTH 0x0B20 #define GL_LINE_WIDTH 0x0B21 #define GL_LINE_WIDTH_RANGE 0x0B22 #define GL_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_LINE_STIPPLE 0x0B24 #define GL_LINE_STIPPLE_PATTERN 0x0B25 #define GL_LINE_STIPPLE_REPEAT 0x0B26 #define GL_LIST_MODE 0x0B30 #define GL_MAX_LIST_NESTING 0x0B31 #define GL_LIST_BASE 0x0B32 #define GL_LIST_INDEX 0x0B33 #define GL_POLYGON_MODE 0x0B40 #define GL_POLYGON_SMOOTH 0x0B41 #define GL_POLYGON_STIPPLE 0x0B42 #define GL_EDGE_FLAG 0x0B43 #define GL_CULL_FACE 0x0B44 #define GL_CULL_FACE_MODE 0x0B45 #define GL_FRONT_FACE 0x0B46 #define GL_LIGHTING 0x0B50 #define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 #define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 #define GL_LIGHT_MODEL_AMBIENT 0x0B53 #define GL_SHADE_MODEL 0x0B54 #define GL_COLOR_MATERIAL_FACE 0x0B55 #define GL_COLOR_MATERIAL_PARAMETER 0x0B56 #define GL_COLOR_MATERIAL 0x0B57 #define GL_FOG 0x0B60 #define GL_FOG_INDEX 0x0B61 #define GL_FOG_DENSITY 0x0B62 #define GL_FOG_START 0x0B63 #define GL_FOG_END 0x0B64 #define GL_FOG_MODE 0x0B65 #define GL_FOG_COLOR 0x0B66 #define GL_DEPTH_RANGE 0x0B70 #define GL_DEPTH_TEST 0x0B71 #define GL_DEPTH_WRITEMASK 0x0B72 #define GL_DEPTH_CLEAR_VALUE 0x0B73 #define GL_DEPTH_FUNC 0x0B74 #define GL_ACCUM_CLEAR_VALUE 0x0B80 #define GL_STENCIL_TEST 0x0B90 #define GL_STENCIL_CLEAR_VALUE 0x0B91 #define GL_STENCIL_FUNC 0x0B92 #define GL_STENCIL_VALUE_MASK 0x0B93 #define GL_STENCIL_FAIL 0x0B94 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 #define GL_STENCIL_REF 0x0B97 #define GL_STENCIL_WRITEMASK 0x0B98 #define GL_MATRIX_MODE 0x0BA0 #define GL_NORMALIZE 0x0BA1 #define GL_VIEWPORT 0x0BA2 #define GL_MODELVIEW_STACK_DEPTH 0x0BA3 #define GL_PROJECTION_STACK_DEPTH 0x0BA4 #define GL_TEXTURE_STACK_DEPTH 0x0BA5 #define GL_MODELVIEW_MATRIX 0x0BA6 #define GL_PROJECTION_MATRIX 0x0BA7 #define GL_TEXTURE_MATRIX 0x0BA8 #define GL_ATTRIB_STACK_DEPTH 0x0BB0 #define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 #define GL_ALPHA_TEST 0x0BC0 #define GL_ALPHA_TEST_FUNC 0x0BC1 #define GL_ALPHA_TEST_REF 0x0BC2 #define GL_DITHER 0x0BD0 #define GL_BLEND_DST 0x0BE0 #define GL_BLEND_SRC 0x0BE1 #define GL_BLEND 0x0BE2 #define GL_LOGIC_OP_MODE 0x0BF0 #define GL_INDEX_LOGIC_OP 0x0BF1 #define GL_COLOR_LOGIC_OP 0x0BF2 #define GL_AUX_BUFFERS 0x0C00 #define GL_DRAW_BUFFER 0x0C01 #define GL_READ_BUFFER 0x0C02 #define GL_SCISSOR_BOX 0x0C10 #define GL_SCISSOR_TEST 0x0C11 #define GL_INDEX_CLEAR_VALUE 0x0C20 #define GL_INDEX_WRITEMASK 0x0C21 #define GL_COLOR_CLEAR_VALUE 0x0C22 #define GL_COLOR_WRITEMASK 0x0C23 #define GL_INDEX_MODE 0x0C30 #define GL_RGBA_MODE 0x0C31 #define GL_DOUBLEBUFFER 0x0C32 #define GL_STEREO 0x0C33 #define GL_RENDER_MODE 0x0C40 #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 #define GL_POINT_SMOOTH_HINT 0x0C51 #define GL_LINE_SMOOTH_HINT 0x0C52 #define GL_POLYGON_SMOOTH_HINT 0x0C53 #define GL_FOG_HINT 0x0C54 #define GL_TEXTURE_GEN_S 0x0C60 #define GL_TEXTURE_GEN_T 0x0C61 #define GL_TEXTURE_GEN_R 0x0C62 #define GL_TEXTURE_GEN_Q 0x0C63 #define GL_PIXEL_MAP_I_TO_I 0x0C70 #define GL_PIXEL_MAP_S_TO_S 0x0C71 #define GL_PIXEL_MAP_I_TO_R 0x0C72 #define GL_PIXEL_MAP_I_TO_G 0x0C73 #define GL_PIXEL_MAP_I_TO_B 0x0C74 #define GL_PIXEL_MAP_I_TO_A 0x0C75 #define GL_PIXEL_MAP_R_TO_R 0x0C76 #define GL_PIXEL_MAP_G_TO_G 0x0C77 #define GL_PIXEL_MAP_B_TO_B 0x0C78 #define GL_PIXEL_MAP_A_TO_A 0x0C79 #define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 #define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 #define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 #define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 #define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 #define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 #define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 #define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 #define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 #define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 #define GL_UNPACK_SWAP_BYTES 0x0CF0 #define GL_UNPACK_LSB_FIRST 0x0CF1 #define GL_UNPACK_ROW_LENGTH 0x0CF2 #define GL_UNPACK_SKIP_ROWS 0x0CF3 #define GL_UNPACK_SKIP_PIXELS 0x0CF4 #define GL_UNPACK_ALIGNMENT 0x0CF5 #define GL_PACK_SWAP_BYTES 0x0D00 #define GL_PACK_LSB_FIRST 0x0D01 #define GL_PACK_ROW_LENGTH 0x0D02 #define GL_PACK_SKIP_ROWS 0x0D03 #define GL_PACK_SKIP_PIXELS 0x0D04 #define GL_PACK_ALIGNMENT 0x0D05 #define GL_MAP_COLOR 0x0D10 #define GL_MAP_STENCIL 0x0D11 #define GL_INDEX_SHIFT 0x0D12 #define GL_INDEX_OFFSET 0x0D13 #define GL_RED_SCALE 0x0D14 #define GL_RED_BIAS 0x0D15 #define GL_ZOOM_X 0x0D16 #define GL_ZOOM_Y 0x0D17 #define GL_GREEN_SCALE 0x0D18 #define GL_GREEN_BIAS 0x0D19 #define GL_BLUE_SCALE 0x0D1A #define GL_BLUE_BIAS 0x0D1B #define GL_ALPHA_SCALE 0x0D1C #define GL_ALPHA_BIAS 0x0D1D #define GL_DEPTH_SCALE 0x0D1E #define GL_DEPTH_BIAS 0x0D1F #define GL_MAX_EVAL_ORDER 0x0D30 #define GL_MAX_LIGHTS 0x0D31 #define GL_MAX_CLIP_PLANES 0x0D32 #define GL_MAX_TEXTURE_SIZE 0x0D33 #define GL_MAX_PIXEL_MAP_TABLE 0x0D34 #define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 #define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 #define GL_MAX_NAME_STACK_DEPTH 0x0D37 #define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 #define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 #define GL_MAX_VIEWPORT_DIMS 0x0D3A #define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B #define GL_SUBPIXEL_BITS 0x0D50 #define GL_INDEX_BITS 0x0D51 #define GL_RED_BITS 0x0D52 #define GL_GREEN_BITS 0x0D53 #define GL_BLUE_BITS 0x0D54 #define GL_ALPHA_BITS 0x0D55 #define GL_DEPTH_BITS 0x0D56 #define GL_STENCIL_BITS 0x0D57 #define GL_ACCUM_RED_BITS 0x0D58 #define GL_ACCUM_GREEN_BITS 0x0D59 #define GL_ACCUM_BLUE_BITS 0x0D5A #define GL_ACCUM_ALPHA_BITS 0x0D5B #define GL_NAME_STACK_DEPTH 0x0D70 #define GL_AUTO_NORMAL 0x0D80 #define GL_MAP1_COLOR_4 0x0D90 #define GL_MAP1_INDEX 0x0D91 #define GL_MAP1_NORMAL 0x0D92 #define GL_MAP1_TEXTURE_COORD_1 0x0D93 #define GL_MAP1_TEXTURE_COORD_2 0x0D94 #define GL_MAP1_TEXTURE_COORD_3 0x0D95 #define GL_MAP1_TEXTURE_COORD_4 0x0D96 #define GL_MAP1_VERTEX_3 0x0D97 #define GL_MAP1_VERTEX_4 0x0D98 #define GL_MAP2_COLOR_4 0x0DB0 #define GL_MAP2_INDEX 0x0DB1 #define GL_MAP2_NORMAL 0x0DB2 #define GL_MAP2_TEXTURE_COORD_1 0x0DB3 #define GL_MAP2_TEXTURE_COORD_2 0x0DB4 #define GL_MAP2_TEXTURE_COORD_3 0x0DB5 #define GL_MAP2_TEXTURE_COORD_4 0x0DB6 #define GL_MAP2_VERTEX_3 0x0DB7 #define GL_MAP2_VERTEX_4 0x0DB8 #define GL_MAP1_GRID_DOMAIN 0x0DD0 #define GL_MAP1_GRID_SEGMENTS 0x0DD1 #define GL_MAP2_GRID_DOMAIN 0x0DD2 #define GL_MAP2_GRID_SEGMENTS 0x0DD3 #define GL_TEXTURE_1D 0x0DE0 #define GL_TEXTURE_2D 0x0DE1 #define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 #define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 #define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 #define GL_SELECTION_BUFFER_POINTER 0x0DF3 #define GL_SELECTION_BUFFER_SIZE 0x0DF4 #define GL_TEXTURE_WIDTH 0x1000 #define GL_TRANSFORM_BIT 0x00001000 #define GL_TEXTURE_HEIGHT 0x1001 #define GL_TEXTURE_INTERNAL_FORMAT 0x1003 #define GL_TEXTURE_BORDER_COLOR 0x1004 #define GL_TEXTURE_BORDER 0x1005 #define GL_DONT_CARE 0x1100 #define GL_FASTEST 0x1101 #define GL_NICEST 0x1102 #define GL_AMBIENT 0x1200 #define GL_DIFFUSE 0x1201 #define GL_SPECULAR 0x1202 #define GL_POSITION 0x1203 #define GL_SPOT_DIRECTION 0x1204 #define GL_SPOT_EXPONENT 0x1205 #define GL_SPOT_CUTOFF 0x1206 #define GL_CONSTANT_ATTENUATION 0x1207 #define GL_LINEAR_ATTENUATION 0x1208 #define GL_QUADRATIC_ATTENUATION 0x1209 #define GL_COMPILE 0x1300 #define GL_COMPILE_AND_EXECUTE 0x1301 #define GL_BYTE 0x1400 #define GL_UNSIGNED_BYTE 0x1401 #define GL_SHORT 0x1402 #define GL_UNSIGNED_SHORT 0x1403 #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 #define GL_2_BYTES 0x1407 #define GL_3_BYTES 0x1408 #define GL_4_BYTES 0x1409 #define GL_DOUBLE 0x140A #define GL_CLEAR 0x1500 #define GL_AND 0x1501 #define GL_AND_REVERSE 0x1502 #define GL_COPY 0x1503 #define GL_AND_INVERTED 0x1504 #define GL_NOOP 0x1505 #define GL_XOR 0x1506 #define GL_OR 0x1507 #define GL_NOR 0x1508 #define GL_EQUIV 0x1509 #define GL_INVERT 0x150A #define GL_OR_REVERSE 0x150B #define GL_COPY_INVERTED 0x150C #define GL_OR_INVERTED 0x150D #define GL_NAND 0x150E #define GL_SET 0x150F #define GL_EMISSION 0x1600 #define GL_SHININESS 0x1601 #define GL_AMBIENT_AND_DIFFUSE 0x1602 #define GL_COLOR_INDEXES 0x1603 #define GL_MODELVIEW 0x1700 #define GL_PROJECTION 0x1701 #define GL_TEXTURE 0x1702 #define GL_COLOR 0x1800 #define GL_DEPTH 0x1801 #define GL_STENCIL 0x1802 #define GL_COLOR_INDEX 0x1900 #define GL_STENCIL_INDEX 0x1901 #define GL_DEPTH_COMPONENT 0x1902 #define GL_RED 0x1903 #define GL_GREEN 0x1904 #define GL_BLUE 0x1905 #define GL_ALPHA 0x1906 #define GL_RGB 0x1907 #define GL_RGBA 0x1908 #define GL_LUMINANCE 0x1909 #define GL_LUMINANCE_ALPHA 0x190A #define GL_BITMAP 0x1A00 #define GL_POINT 0x1B00 #define GL_LINE 0x1B01 #define GL_FILL 0x1B02 #define GL_RENDER 0x1C00 #define GL_FEEDBACK 0x1C01 #define GL_SELECT 0x1C02 #define GL_FLAT 0x1D00 #define GL_SMOOTH 0x1D01 #define GL_KEEP 0x1E00 #define GL_REPLACE 0x1E01 #define GL_INCR 0x1E02 #define GL_DECR 0x1E03 #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 #define GL_VERSION 0x1F02 #define GL_EXTENSIONS 0x1F03 #define GL_S 0x2000 #define GL_ENABLE_BIT 0x00002000 #define GL_T 0x2001 #define GL_R 0x2002 #define GL_Q 0x2003 #define GL_MODULATE 0x2100 #define GL_DECAL 0x2101 #define GL_TEXTURE_ENV_MODE 0x2200 #define GL_TEXTURE_ENV_COLOR 0x2201 #define GL_TEXTURE_ENV 0x2300 #define GL_EYE_LINEAR 0x2400 #define GL_OBJECT_LINEAR 0x2401 #define GL_SPHERE_MAP 0x2402 #define GL_TEXTURE_GEN_MODE 0x2500 #define GL_OBJECT_PLANE 0x2501 #define GL_EYE_PLANE 0x2502 #define GL_NEAREST 0x2600 #define GL_LINEAR 0x2601 #define GL_NEAREST_MIPMAP_NEAREST 0x2700 #define GL_LINEAR_MIPMAP_NEAREST 0x2701 #define GL_NEAREST_MIPMAP_LINEAR 0x2702 #define GL_LINEAR_MIPMAP_LINEAR 0x2703 #define GL_TEXTURE_MAG_FILTER 0x2800 #define GL_TEXTURE_MIN_FILTER 0x2801 #define GL_TEXTURE_WRAP_S 0x2802 #define GL_TEXTURE_WRAP_T 0x2803 #define GL_CLAMP 0x2900 #define GL_REPEAT 0x2901 #define GL_POLYGON_OFFSET_UNITS 0x2A00 #define GL_POLYGON_OFFSET_POINT 0x2A01 #define GL_POLYGON_OFFSET_LINE 0x2A02 #define GL_R3_G3_B2 0x2A10 #define GL_V2F 0x2A20 #define GL_V3F 0x2A21 #define GL_C4UB_V2F 0x2A22 #define GL_C4UB_V3F 0x2A23 #define GL_C3F_V3F 0x2A24 #define GL_N3F_V3F 0x2A25 #define GL_C4F_N3F_V3F 0x2A26 #define GL_T2F_V3F 0x2A27 #define GL_T4F_V4F 0x2A28 #define GL_T2F_C4UB_V3F 0x2A29 #define GL_T2F_C3F_V3F 0x2A2A #define GL_T2F_N3F_V3F 0x2A2B #define GL_T2F_C4F_N3F_V3F 0x2A2C #define GL_T4F_C4F_N3F_V4F 0x2A2D #define GL_CLIP_PLANE0 0x3000 #define GL_CLIP_PLANE1 0x3001 #define GL_CLIP_PLANE2 0x3002 #define GL_CLIP_PLANE3 0x3003 #define GL_CLIP_PLANE4 0x3004 #define GL_CLIP_PLANE5 0x3005 #define GL_LIGHT0 0x4000 #define GL_COLOR_BUFFER_BIT 0x00004000 #define GL_LIGHT1 0x4001 #define GL_LIGHT2 0x4002 #define GL_LIGHT3 0x4003 #define GL_LIGHT4 0x4004 #define GL_LIGHT5 0x4005 #define GL_LIGHT6 0x4006 #define GL_LIGHT7 0x4007 #define GL_HINT_BIT 0x00008000 #define GL_POLYGON_OFFSET_FILL 0x8037 #define GL_POLYGON_OFFSET_FACTOR 0x8038 #define GL_ALPHA4 0x803B #define GL_ALPHA8 0x803C #define GL_ALPHA12 0x803D #define GL_ALPHA16 0x803E #define GL_LUMINANCE4 0x803F #define GL_LUMINANCE8 0x8040 #define GL_LUMINANCE12 0x8041 #define GL_LUMINANCE16 0x8042 #define GL_LUMINANCE4_ALPHA4 0x8043 #define GL_LUMINANCE6_ALPHA2 0x8044 #define GL_LUMINANCE8_ALPHA8 0x8045 #define GL_LUMINANCE12_ALPHA4 0x8046 #define GL_LUMINANCE12_ALPHA12 0x8047 #define GL_LUMINANCE16_ALPHA16 0x8048 #define GL_INTENSITY 0x8049 #define GL_INTENSITY4 0x804A #define GL_INTENSITY8 0x804B #define GL_INTENSITY12 0x804C #define GL_INTENSITY16 0x804D #define GL_RGB4 0x804F #define GL_RGB5 0x8050 #define GL_RGB8 0x8051 #define GL_RGB10 0x8052 #define GL_RGB12 0x8053 #define GL_RGB16 0x8054 #define GL_RGBA2 0x8055 #define GL_RGBA4 0x8056 #define GL_RGB5_A1 0x8057 #define GL_RGBA8 0x8058 #define GL_RGB10_A2 0x8059 #define GL_RGBA12 0x805A #define GL_RGBA16 0x805B #define GL_TEXTURE_RED_SIZE 0x805C #define GL_TEXTURE_GREEN_SIZE 0x805D #define GL_TEXTURE_BLUE_SIZE 0x805E #define GL_TEXTURE_ALPHA_SIZE 0x805F #define GL_TEXTURE_LUMINANCE_SIZE 0x8060 #define GL_TEXTURE_INTENSITY_SIZE 0x8061 #define GL_PROXY_TEXTURE_1D 0x8063 #define GL_PROXY_TEXTURE_2D 0x8064 #define GL_TEXTURE_PRIORITY 0x8066 #define GL_TEXTURE_RESIDENT 0x8067 #define GL_TEXTURE_BINDING_1D 0x8068 #define GL_TEXTURE_BINDING_2D 0x8069 #define GL_VERTEX_ARRAY 0x8074 #define GL_NORMAL_ARRAY 0x8075 #define GL_COLOR_ARRAY 0x8076 #define GL_INDEX_ARRAY 0x8077 #define GL_TEXTURE_COORD_ARRAY 0x8078 #define GL_EDGE_FLAG_ARRAY 0x8079 #define GL_VERTEX_ARRAY_SIZE 0x807A #define GL_VERTEX_ARRAY_TYPE 0x807B #define GL_VERTEX_ARRAY_STRIDE 0x807C #define GL_NORMAL_ARRAY_TYPE 0x807E #define GL_NORMAL_ARRAY_STRIDE 0x807F #define GL_COLOR_ARRAY_SIZE 0x8081 #define GL_COLOR_ARRAY_TYPE 0x8082 #define GL_COLOR_ARRAY_STRIDE 0x8083 #define GL_INDEX_ARRAY_TYPE 0x8085 #define GL_INDEX_ARRAY_STRIDE 0x8086 #define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 #define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 #define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A #define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C #define GL_VERTEX_ARRAY_POINTER 0x808E #define GL_NORMAL_ARRAY_POINTER 0x808F #define GL_COLOR_ARRAY_POINTER 0x8090 #define GL_INDEX_ARRAY_POINTER 0x8091 #define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 #define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 #define GL_COLOR_INDEX1_EXT 0x80E2 #define GL_COLOR_INDEX2_EXT 0x80E3 #define GL_COLOR_INDEX4_EXT 0x80E4 #define GL_COLOR_INDEX8_EXT 0x80E5 #define GL_COLOR_INDEX12_EXT 0x80E6 #define GL_COLOR_INDEX16_EXT 0x80E7 #define GL_EVAL_BIT 0x00010000 #define GL_LIST_BIT 0x00020000 #define GL_TEXTURE_BIT 0x00040000 #define GL_SCISSOR_BIT 0x00080000 #define GL_ALL_ATTRIB_BITS 0x000fffff #define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); GLAPI void GLAPIENTRY glArrayElement (GLint i); GLAPI void GLAPIENTRY glBegin (GLenum mode); GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); GLAPI void GLAPIENTRY glCallList (GLuint list); GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists); GLAPI void GLAPIENTRY glClear (GLbitfield mask); GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); GLAPI void GLAPIENTRY glClearIndex (GLfloat c); GLAPI void GLAPIENTRY glClearStencil (GLint s); GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); GLAPI void GLAPIENTRY glColor3iv (const GLint *v); GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); GLAPI void GLAPIENTRY glColor4iv (const GLint *v); GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void GLAPIENTRY glCullFace (GLenum mode); GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); GLAPI void GLAPIENTRY glDepthFunc (GLenum func); GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); GLAPI void GLAPIENTRY glDisable (GLenum cap); GLAPI void GLAPIENTRY glDisableClientState (GLenum array); GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer); GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); GLAPI void GLAPIENTRY glEnable (GLenum cap); GLAPI void GLAPIENTRY glEnableClientState (GLenum array); GLAPI void GLAPIENTRY glEnd (void); GLAPI void GLAPIENTRY glEndList (void); GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); GLAPI void GLAPIENTRY glFinish (void); GLAPI void GLAPIENTRY glFlush (void); GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glFrontFace (GLenum mode); GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); GLAPI GLenum GLAPIENTRY glGetError (void); GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, GLvoid* *params); GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); GLAPI void GLAPIENTRY glIndexMask (GLuint mask); GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer); GLAPI void GLAPIENTRY glIndexd (GLdouble c); GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); GLAPI void GLAPIENTRY glIndexf (GLfloat c); GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); GLAPI void GLAPIENTRY glIndexi (GLint c); GLAPI void GLAPIENTRY glIndexiv (const GLint *c); GLAPI void GLAPIENTRY glIndexs (GLshort c); GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); GLAPI void GLAPIENTRY glIndexub (GLubyte c); GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); GLAPI void GLAPIENTRY glInitNames (void); GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer); GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); GLAPI void GLAPIENTRY glLineWidth (GLfloat width); GLAPI void GLAPIENTRY glListBase (GLuint base); GLAPI void GLAPIENTRY glLoadIdentity (void); GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); GLAPI void GLAPIENTRY glLoadName (GLuint name); GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GLAPI void GLAPIENTRY glPassThrough (GLfloat token); GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); GLAPI void GLAPIENTRY glPointSize (GLfloat size); GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); GLAPI void GLAPIENTRY glPopAttrib (void); GLAPI void GLAPIENTRY glPopClientAttrib (void); GLAPI void GLAPIENTRY glPopMatrix (void); GLAPI void GLAPIENTRY glPopName (void); GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); GLAPI void GLAPIENTRY glPushMatrix (void); GLAPI void GLAPIENTRY glPushName (GLuint name); GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); GLAPI void GLAPIENTRY glShadeModel (GLenum mode); GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); GLAPI void GLAPIENTRY glStencilMask (GLuint mask); GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); GLAPI void GLAPIENTRY glTexCoord1i (GLint s); GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); #define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1) #endif /* GL_VERSION_1_1 */ /* ---------------------------------- GLU ---------------------------------- */ #ifndef GLEW_NO_GLU /* this is where we can safely include GLU */ # if defined(__APPLE__) && defined(__MACH__) # include # else # include # endif #endif /* ----------------------------- GL_VERSION_1_2 ---------------------------- */ #ifndef GL_VERSION_1_2 #define GL_VERSION_1_2 1 #define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 #define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 #define GL_UNSIGNED_INT_8_8_8_8 0x8035 #define GL_UNSIGNED_INT_10_10_10_2 0x8036 #define GL_RESCALE_NORMAL 0x803A #define GL_TEXTURE_BINDING_3D 0x806A #define GL_PACK_SKIP_IMAGES 0x806B #define GL_PACK_IMAGE_HEIGHT 0x806C #define GL_UNPACK_SKIP_IMAGES 0x806D #define GL_UNPACK_IMAGE_HEIGHT 0x806E #define GL_TEXTURE_3D 0x806F #define GL_PROXY_TEXTURE_3D 0x8070 #define GL_TEXTURE_DEPTH 0x8071 #define GL_TEXTURE_WRAP_R 0x8072 #define GL_MAX_3D_TEXTURE_SIZE 0x8073 #define GL_BGR 0x80E0 #define GL_BGRA 0x80E1 #define GL_MAX_ELEMENTS_VERTICES 0x80E8 #define GL_MAX_ELEMENTS_INDICES 0x80E9 #define GL_CLAMP_TO_EDGE 0x812F #define GL_TEXTURE_MIN_LOD 0x813A #define GL_TEXTURE_MAX_LOD 0x813B #define GL_TEXTURE_BASE_LEVEL 0x813C #define GL_TEXTURE_MAX_LEVEL 0x813D #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 #define GL_SINGLE_COLOR 0x81F9 #define GL_SEPARATE_SPECULAR_COLOR 0x81FA #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 #define GL_UNSIGNED_SHORT_5_6_5 0x8363 #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_ALIASED_POINT_SIZE_RANGE 0x846D #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); #define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D) #define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements) #define glTexImage3D GLEW_GET_FUN(__glewTexImage3D) #define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D) #define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2) #endif /* GL_VERSION_1_2 */ /* ---------------------------- GL_VERSION_1_2_1 --------------------------- */ #ifndef GL_VERSION_1_2_1 #define GL_VERSION_1_2_1 1 #define GLEW_VERSION_1_2_1 GLEW_GET_VAR(__GLEW_VERSION_1_2_1) #endif /* GL_VERSION_1_2_1 */ /* ----------------------------- GL_VERSION_1_3 ---------------------------- */ #ifndef GL_VERSION_1_3 #define GL_VERSION_1_3 1 #define GL_MULTISAMPLE 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #define GL_SAMPLE_ALPHA_TO_ONE 0x809F #define GL_SAMPLE_COVERAGE 0x80A0 #define GL_SAMPLE_BUFFERS 0x80A8 #define GL_SAMPLES 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE 0x80AA #define GL_SAMPLE_COVERAGE_INVERT 0x80AB #define GL_CLAMP_TO_BORDER 0x812D #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE2 0x84C2 #define GL_TEXTURE3 0x84C3 #define GL_TEXTURE4 0x84C4 #define GL_TEXTURE5 0x84C5 #define GL_TEXTURE6 0x84C6 #define GL_TEXTURE7 0x84C7 #define GL_TEXTURE8 0x84C8 #define GL_TEXTURE9 0x84C9 #define GL_TEXTURE10 0x84CA #define GL_TEXTURE11 0x84CB #define GL_TEXTURE12 0x84CC #define GL_TEXTURE13 0x84CD #define GL_TEXTURE14 0x84CE #define GL_TEXTURE15 0x84CF #define GL_TEXTURE16 0x84D0 #define GL_TEXTURE17 0x84D1 #define GL_TEXTURE18 0x84D2 #define GL_TEXTURE19 0x84D3 #define GL_TEXTURE20 0x84D4 #define GL_TEXTURE21 0x84D5 #define GL_TEXTURE22 0x84D6 #define GL_TEXTURE23 0x84D7 #define GL_TEXTURE24 0x84D8 #define GL_TEXTURE25 0x84D9 #define GL_TEXTURE26 0x84DA #define GL_TEXTURE27 0x84DB #define GL_TEXTURE28 0x84DC #define GL_TEXTURE29 0x84DD #define GL_TEXTURE30 0x84DE #define GL_TEXTURE31 0x84DF #define GL_ACTIVE_TEXTURE 0x84E0 #define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 #define GL_MAX_TEXTURE_UNITS 0x84E2 #define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 #define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 #define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 #define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 #define GL_SUBTRACT 0x84E7 #define GL_COMPRESSED_ALPHA 0x84E9 #define GL_COMPRESSED_LUMINANCE 0x84EA #define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB #define GL_COMPRESSED_INTENSITY 0x84EC #define GL_COMPRESSED_RGB 0x84ED #define GL_COMPRESSED_RGBA 0x84EE #define GL_TEXTURE_COMPRESSION_HINT 0x84EF #define GL_NORMAL_MAP 0x8511 #define GL_REFLECTION_MAP 0x8512 #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C #define GL_COMBINE 0x8570 #define GL_COMBINE_RGB 0x8571 #define GL_COMBINE_ALPHA 0x8572 #define GL_RGB_SCALE 0x8573 #define GL_ADD_SIGNED 0x8574 #define GL_INTERPOLATE 0x8575 #define GL_CONSTANT 0x8576 #define GL_PRIMARY_COLOR 0x8577 #define GL_PREVIOUS 0x8578 #define GL_SOURCE0_RGB 0x8580 #define GL_SOURCE1_RGB 0x8581 #define GL_SOURCE2_RGB 0x8582 #define GL_SOURCE0_ALPHA 0x8588 #define GL_SOURCE1_ALPHA 0x8589 #define GL_SOURCE2_ALPHA 0x858A #define GL_OPERAND0_RGB 0x8590 #define GL_OPERAND1_RGB 0x8591 #define GL_OPERAND2_RGB 0x8592 #define GL_OPERAND0_ALPHA 0x8598 #define GL_OPERAND1_ALPHA 0x8599 #define GL_OPERAND2_ALPHA 0x859A #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 #define GL_TEXTURE_COMPRESSED 0x86A1 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_DOT3_RGB 0x86AE #define GL_DOT3_RGBA 0x86AF #define GL_MULTISAMPLE_BIT 0x20000000 typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLvoid *img); typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); #define glActiveTexture GLEW_GET_FUN(__glewActiveTexture) #define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture) #define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D) #define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D) #define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D) #define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D) #define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D) #define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D) #define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage) #define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd) #define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf) #define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd) #define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf) #define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d) #define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv) #define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f) #define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv) #define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i) #define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv) #define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s) #define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv) #define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d) #define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv) #define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f) #define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv) #define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i) #define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv) #define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s) #define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv) #define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d) #define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv) #define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f) #define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv) #define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i) #define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv) #define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s) #define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv) #define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d) #define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv) #define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f) #define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv) #define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i) #define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv) #define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s) #define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv) #define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage) #define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3) #endif /* GL_VERSION_1_3 */ /* ----------------------------- GL_VERSION_1_4 ---------------------------- */ #ifndef GL_VERSION_1_4 #define GL_VERSION_1_4 1 #define GL_BLEND_DST_RGB 0x80C8 #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_SRC_ALPHA 0x80CB #define GL_POINT_SIZE_MIN 0x8126 #define GL_POINT_SIZE_MAX 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 #define GL_POINT_DISTANCE_ATTENUATION 0x8129 #define GL_GENERATE_MIPMAP 0x8191 #define GL_GENERATE_MIPMAP_HINT 0x8192 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_DEPTH_COMPONENT24 0x81A6 #define GL_DEPTH_COMPONENT32 0x81A7 #define GL_MIRRORED_REPEAT 0x8370 #define GL_FOG_COORDINATE_SOURCE 0x8450 #define GL_FOG_COORDINATE 0x8451 #define GL_FRAGMENT_DEPTH 0x8452 #define GL_CURRENT_FOG_COORDINATE 0x8453 #define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 #define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 #define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 #define GL_FOG_COORDINATE_ARRAY 0x8457 #define GL_COLOR_SUM 0x8458 #define GL_CURRENT_SECONDARY_COLOR 0x8459 #define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A #define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B #define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C #define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D #define GL_SECONDARY_COLOR_ARRAY 0x845E #define GL_MAX_TEXTURE_LOD_BIAS 0x84FD #define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_TEXTURE_LOD_BIAS 0x8501 #define GL_INCR_WRAP 0x8507 #define GL_DECR_WRAP 0x8508 #define GL_TEXTURE_DEPTH_SIZE 0x884A #define GL_DEPTH_TEXTURE_MODE 0x884B #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_COMPARE_R_TO_TEXTURE 0x884E typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); #define glBlendColor GLEW_GET_FUN(__glewBlendColor) #define glBlendEquation GLEW_GET_FUN(__glewBlendEquation) #define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate) #define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer) #define glFogCoordd GLEW_GET_FUN(__glewFogCoordd) #define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv) #define glFogCoordf GLEW_GET_FUN(__glewFogCoordf) #define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv) #define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays) #define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements) #define glPointParameterf GLEW_GET_FUN(__glewPointParameterf) #define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv) #define glPointParameteri GLEW_GET_FUN(__glewPointParameteri) #define glPointParameteriv GLEW_GET_FUN(__glewPointParameteriv) #define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b) #define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv) #define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d) #define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv) #define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f) #define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv) #define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i) #define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv) #define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s) #define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv) #define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub) #define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv) #define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui) #define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv) #define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us) #define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv) #define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer) #define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d) #define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv) #define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f) #define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv) #define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i) #define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv) #define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s) #define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv) #define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d) #define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv) #define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f) #define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv) #define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i) #define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv) #define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s) #define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv) #define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4) #endif /* GL_VERSION_1_4 */ /* ----------------------------- GL_VERSION_1_5 ---------------------------- */ #ifndef GL_VERSION_1_5 #define GL_VERSION_1_5 1 #define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE #define GL_FOG_COORD GL_FOG_COORDINATE #define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY #define GL_SRC0_RGB GL_SOURCE0_RGB #define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER #define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE #define GL_SRC1_ALPHA GL_SOURCE1_ALPHA #define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE #define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE #define GL_SRC0_ALPHA GL_SOURCE0_ALPHA #define GL_SRC1_RGB GL_SOURCE1_RGB #define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING #define GL_SRC2_ALPHA GL_SOURCE2_ALPHA #define GL_SRC2_RGB GL_SOURCE2_RGB #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_QUERY_COUNTER_BITS 0x8864 #define GL_CURRENT_QUERY 0x8865 #define GL_QUERY_RESULT 0x8866 #define GL_QUERY_RESULT_AVAILABLE 0x8867 #define GL_ARRAY_BUFFER 0x8892 #define GL_ELEMENT_ARRAY_BUFFER 0x8893 #define GL_ARRAY_BUFFER_BINDING 0x8894 #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 #define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 #define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 #define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 #define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D #define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F #define GL_READ_ONLY 0x88B8 #define GL_WRITE_ONLY 0x88B9 #define GL_READ_WRITE 0x88BA #define GL_BUFFER_ACCESS 0x88BB #define GL_BUFFER_MAPPED 0x88BC #define GL_BUFFER_MAP_POINTER 0x88BD #define GL_STREAM_DRAW 0x88E0 #define GL_STREAM_READ 0x88E1 #define GL_STREAM_COPY 0x88E2 #define GL_STATIC_DRAW 0x88E4 #define GL_STATIC_READ 0x88E5 #define GL_STATIC_COPY 0x88E6 #define GL_DYNAMIC_DRAW 0x88E8 #define GL_DYNAMIC_READ 0x88E9 #define GL_DYNAMIC_COPY 0x88EA #define GL_SAMPLES_PASSED 0x8914 typedef ptrdiff_t GLintptr; typedef ptrdiff_t GLsizeiptr; typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid** params); typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); typedef GLvoid* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); #define glBeginQuery GLEW_GET_FUN(__glewBeginQuery) #define glBindBuffer GLEW_GET_FUN(__glewBindBuffer) #define glBufferData GLEW_GET_FUN(__glewBufferData) #define glBufferSubData GLEW_GET_FUN(__glewBufferSubData) #define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers) #define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries) #define glEndQuery GLEW_GET_FUN(__glewEndQuery) #define glGenBuffers GLEW_GET_FUN(__glewGenBuffers) #define glGenQueries GLEW_GET_FUN(__glewGenQueries) #define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv) #define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv) #define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData) #define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv) #define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv) #define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv) #define glIsBuffer GLEW_GET_FUN(__glewIsBuffer) #define glIsQuery GLEW_GET_FUN(__glewIsQuery) #define glMapBuffer GLEW_GET_FUN(__glewMapBuffer) #define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer) #define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5) #endif /* GL_VERSION_1_5 */ /* ----------------------------- GL_VERSION_2_0 ---------------------------- */ #ifndef GL_VERSION_2_0 #define GL_VERSION_2_0 1 #define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_CURRENT_VERTEX_ATTRIB 0x8626 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 #define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 #define GL_STENCIL_BACK_FUNC 0x8800 #define GL_STENCIL_BACK_FAIL 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 #define GL_MAX_DRAW_BUFFERS 0x8824 #define GL_DRAW_BUFFER0 0x8825 #define GL_DRAW_BUFFER1 0x8826 #define GL_DRAW_BUFFER2 0x8827 #define GL_DRAW_BUFFER3 0x8828 #define GL_DRAW_BUFFER4 0x8829 #define GL_DRAW_BUFFER5 0x882A #define GL_DRAW_BUFFER6 0x882B #define GL_DRAW_BUFFER7 0x882C #define GL_DRAW_BUFFER8 0x882D #define GL_DRAW_BUFFER9 0x882E #define GL_DRAW_BUFFER10 0x882F #define GL_DRAW_BUFFER11 0x8830 #define GL_DRAW_BUFFER12 0x8831 #define GL_DRAW_BUFFER13 0x8832 #define GL_DRAW_BUFFER14 0x8833 #define GL_DRAW_BUFFER15 0x8834 #define GL_BLEND_EQUATION_ALPHA 0x883D #define GL_POINT_SPRITE 0x8861 #define GL_COORD_REPLACE 0x8862 #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A #define GL_MAX_TEXTURE_COORDS 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A #define GL_MAX_VARYING_FLOATS 0x8B4B #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D #define GL_SHADER_TYPE 0x8B4F #define GL_FLOAT_VEC2 0x8B50 #define GL_FLOAT_VEC3 0x8B51 #define GL_FLOAT_VEC4 0x8B52 #define GL_INT_VEC2 0x8B53 #define GL_INT_VEC3 0x8B54 #define GL_INT_VEC4 0x8B55 #define GL_BOOL 0x8B56 #define GL_BOOL_VEC2 0x8B57 #define GL_BOOL_VEC3 0x8B58 #define GL_BOOL_VEC4 0x8B59 #define GL_FLOAT_MAT2 0x8B5A #define GL_FLOAT_MAT3 0x8B5B #define GL_FLOAT_MAT4 0x8B5C #define GL_SAMPLER_1D 0x8B5D #define GL_SAMPLER_2D 0x8B5E #define GL_SAMPLER_3D 0x8B5F #define GL_SAMPLER_CUBE 0x8B60 #define GL_SAMPLER_1D_SHADOW 0x8B61 #define GL_SAMPLER_2D_SHADOW 0x8B62 #define GL_DELETE_STATUS 0x8B80 #define GL_COMPILE_STATUS 0x8B81 #define GL_LINK_STATUS 0x8B82 #define GL_VALIDATE_STATUS 0x8B83 #define GL_INFO_LOG_LENGTH 0x8B84 #define GL_ATTACHED_SHADERS 0x8B85 #define GL_ACTIVE_UNIFORMS 0x8B86 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 #define GL_SHADER_SOURCE_LENGTH 0x8B88 #define GL_ACTIVE_ATTRIBUTES 0x8B89 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B #define GL_SHADING_LANGUAGE_VERSION 0x8B8C #define GL_CURRENT_PROGRAM 0x8B8D #define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 #define GL_LOWER_LEFT 0x8CA1 #define GL_UPPER_LEFT 0x8CA2 #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLuint obj, GLsizei maxLength, GLsizei* length, GLchar* source); typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar* name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint, GLenum, GLvoid**); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); #define glAttachShader GLEW_GET_FUN(__glewAttachShader) #define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation) #define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate) #define glCompileShader GLEW_GET_FUN(__glewCompileShader) #define glCreateProgram GLEW_GET_FUN(__glewCreateProgram) #define glCreateShader GLEW_GET_FUN(__glewCreateShader) #define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram) #define glDeleteShader GLEW_GET_FUN(__glewDeleteShader) #define glDetachShader GLEW_GET_FUN(__glewDetachShader) #define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray) #define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers) #define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray) #define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib) #define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform) #define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders) #define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation) #define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog) #define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv) #define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog) #define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource) #define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv) #define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation) #define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv) #define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv) #define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv) #define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv) #define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv) #define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv) #define glIsProgram GLEW_GET_FUN(__glewIsProgram) #define glIsShader GLEW_GET_FUN(__glewIsShader) #define glLinkProgram GLEW_GET_FUN(__glewLinkProgram) #define glShaderSource GLEW_GET_FUN(__glewShaderSource) #define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate) #define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate) #define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate) #define glUniform1f GLEW_GET_FUN(__glewUniform1f) #define glUniform1fv GLEW_GET_FUN(__glewUniform1fv) #define glUniform1i GLEW_GET_FUN(__glewUniform1i) #define glUniform1iv GLEW_GET_FUN(__glewUniform1iv) #define glUniform2f GLEW_GET_FUN(__glewUniform2f) #define glUniform2fv GLEW_GET_FUN(__glewUniform2fv) #define glUniform2i GLEW_GET_FUN(__glewUniform2i) #define glUniform2iv GLEW_GET_FUN(__glewUniform2iv) #define glUniform3f GLEW_GET_FUN(__glewUniform3f) #define glUniform3fv GLEW_GET_FUN(__glewUniform3fv) #define glUniform3i GLEW_GET_FUN(__glewUniform3i) #define glUniform3iv GLEW_GET_FUN(__glewUniform3iv) #define glUniform4f GLEW_GET_FUN(__glewUniform4f) #define glUniform4fv GLEW_GET_FUN(__glewUniform4fv) #define glUniform4i GLEW_GET_FUN(__glewUniform4i) #define glUniform4iv GLEW_GET_FUN(__glewUniform4iv) #define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv) #define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv) #define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv) #define glUseProgram GLEW_GET_FUN(__glewUseProgram) #define glValidateProgram GLEW_GET_FUN(__glewValidateProgram) #define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d) #define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv) #define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f) #define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv) #define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s) #define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv) #define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d) #define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv) #define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f) #define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv) #define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s) #define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv) #define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d) #define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv) #define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f) #define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv) #define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s) #define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv) #define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv) #define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv) #define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv) #define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub) #define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv) #define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv) #define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv) #define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv) #define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d) #define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv) #define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f) #define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv) #define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv) #define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s) #define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv) #define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv) #define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv) #define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv) #define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer) #define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0) #endif /* GL_VERSION_2_0 */ /* ----------------------------- GL_VERSION_2_1 ---------------------------- */ #ifndef GL_VERSION_2_1 #define GL_VERSION_2_1 1 #define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_PIXEL_PACK_BUFFER 0x88EB #define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF #define GL_FLOAT_MAT2x3 0x8B65 #define GL_FLOAT_MAT2x4 0x8B66 #define GL_FLOAT_MAT3x2 0x8B67 #define GL_FLOAT_MAT3x4 0x8B68 #define GL_FLOAT_MAT4x2 0x8B69 #define GL_FLOAT_MAT4x3 0x8B6A #define GL_SRGB 0x8C40 #define GL_SRGB8 0x8C41 #define GL_SRGB_ALPHA 0x8C42 #define GL_SRGB8_ALPHA8 0x8C43 #define GL_SLUMINANCE_ALPHA 0x8C44 #define GL_SLUMINANCE8_ALPHA8 0x8C45 #define GL_SLUMINANCE 0x8C46 #define GL_SLUMINANCE8 0x8C47 #define GL_COMPRESSED_SRGB 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA 0x8C49 #define GL_COMPRESSED_SLUMINANCE 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv) #define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv) #define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv) #define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv) #define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv) #define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv) #define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1) #endif /* GL_VERSION_2_1 */ /* ----------------------------- GL_VERSION_3_0 ---------------------------- */ #ifndef GL_VERSION_3_0 #define GL_VERSION_3_0 1 #define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES #define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 #define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 #define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 #define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB #define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 #define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 #define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 #define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS #define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 #define GL_MAJOR_VERSION 0x821B #define GL_MINOR_VERSION 0x821C #define GL_NUM_EXTENSIONS 0x821D #define GL_CONTEXT_FLAGS 0x821E #define GL_DEPTH_BUFFER 0x8223 #define GL_STENCIL_BUFFER 0x8224 #define GL_COMPRESSED_RED 0x8225 #define GL_COMPRESSED_RG 0x8226 #define GL_RGBA32F 0x8814 #define GL_RGB32F 0x8815 #define GL_RGBA16F 0x881A #define GL_RGB16F 0x881B #define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD #define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF #define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 #define GL_CLAMP_VERTEX_COLOR 0x891A #define GL_CLAMP_FRAGMENT_COLOR 0x891B #define GL_CLAMP_READ_COLOR 0x891C #define GL_FIXED_ONLY 0x891D #define GL_TEXTURE_RED_TYPE 0x8C10 #define GL_TEXTURE_GREEN_TYPE 0x8C11 #define GL_TEXTURE_BLUE_TYPE 0x8C12 #define GL_TEXTURE_ALPHA_TYPE 0x8C13 #define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 #define GL_TEXTURE_INTENSITY_TYPE 0x8C15 #define GL_TEXTURE_DEPTH_TYPE 0x8C16 #define GL_UNSIGNED_NORMALIZED 0x8C17 #define GL_TEXTURE_1D_ARRAY 0x8C18 #define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 #define GL_TEXTURE_2D_ARRAY 0x8C1A #define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B #define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C #define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D #define GL_R11F_G11F_B10F 0x8C3A #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B #define GL_RGB9_E5 0x8C3D #define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E #define GL_TEXTURE_SHARED_SIZE 0x8C3F #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 #define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 #define GL_PRIMITIVES_GENERATED 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 #define GL_RASTERIZER_DISCARD 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B #define GL_INTERLEAVED_ATTRIBS 0x8C8C #define GL_SEPARATE_ATTRIBS 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F #define GL_RGBA32UI 0x8D70 #define GL_RGB32UI 0x8D71 #define GL_RGBA16UI 0x8D76 #define GL_RGB16UI 0x8D77 #define GL_RGBA8UI 0x8D7C #define GL_RGB8UI 0x8D7D #define GL_RGBA32I 0x8D82 #define GL_RGB32I 0x8D83 #define GL_RGBA16I 0x8D88 #define GL_RGB16I 0x8D89 #define GL_RGBA8I 0x8D8E #define GL_RGB8I 0x8D8F #define GL_RED_INTEGER 0x8D94 #define GL_GREEN_INTEGER 0x8D95 #define GL_BLUE_INTEGER 0x8D96 #define GL_ALPHA_INTEGER 0x8D97 #define GL_RGB_INTEGER 0x8D98 #define GL_RGBA_INTEGER 0x8D99 #define GL_BGR_INTEGER 0x8D9A #define GL_BGRA_INTEGER 0x8D9B #define GL_SAMPLER_1D_ARRAY 0x8DC0 #define GL_SAMPLER_2D_ARRAY 0x8DC1 #define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 #define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 #define GL_SAMPLER_CUBE_SHADOW 0x8DC5 #define GL_UNSIGNED_INT_VEC2 0x8DC6 #define GL_UNSIGNED_INT_VEC3 0x8DC7 #define GL_UNSIGNED_INT_VEC4 0x8DC8 #define GL_INT_SAMPLER_1D 0x8DC9 #define GL_INT_SAMPLER_2D 0x8DCA #define GL_INT_SAMPLER_3D 0x8DCB #define GL_INT_SAMPLER_CUBE 0x8DCC #define GL_INT_SAMPLER_1D_ARRAY 0x8DCE #define GL_INT_SAMPLER_2D_ARRAY 0x8DCF #define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 #define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 #define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 #define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 #define GL_QUERY_WAIT 0x8E13 #define GL_QUERY_NO_WAIT 0x8E14 #define GL_QUERY_BY_REGION_WAIT 0x8E15 #define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint, GLenum); typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum); typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint, GLuint, const GLchar*); typedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum, GLenum); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum, GLint, GLfloat, GLint); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFVPROC) (GLenum, GLint, const GLfloat*); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERIVPROC) (GLenum, GLint, const GLint*); typedef void (GLAPIENTRY * PFNGLCLEARBUFFERUIVPROC) (GLenum, GLint, const GLuint*); typedef void (GLAPIENTRY * PFNGLCOLORMASKIPROC) (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); typedef void (GLAPIENTRY * PFNGLDISABLEIPROC) (GLenum, GLuint); typedef void (GLAPIENTRY * PFNGLENABLEIPROC) (GLenum, GLuint); typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void); typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void); typedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum, GLuint, GLboolean*); typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint, const GLchar*); typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum, GLuint); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum, GLenum, GLint*); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum, GLenum, GLuint*); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVPROC) (GLuint, GLint, GLuint*); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVPROC) (GLuint, GLenum, GLint*); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint, GLenum, GLuint*); typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum, GLuint); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum, GLenum, const GLint*); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum, GLenum, const GLuint*); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint, GLsizei, const GLchar **, GLenum); typedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint, GLuint); typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint, GLsizei, const GLuint*); typedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint, GLuint, GLuint); typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVPROC) (GLint, GLsizei, const GLuint*); typedef void (GLAPIENTRY * PFNGLUNIFORM3UIPROC) (GLint, GLuint, GLuint, GLuint); typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVPROC) (GLint, GLsizei, const GLuint*); typedef void (GLAPIENTRY * PFNGLUNIFORM4UIPROC) (GLint, GLuint, GLuint, GLuint, GLuint); typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVPROC) (GLint, GLsizei, const GLuint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IPROC) (GLuint, GLint); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVPROC) (GLuint, const GLint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIPROC) (GLuint, GLuint); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVPROC) (GLuint, const GLuint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IPROC) (GLuint, GLint, GLint); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVPROC) (GLuint, const GLint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIPROC) (GLuint, GLuint, GLuint); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVPROC) (GLuint, const GLuint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IPROC) (GLuint, GLint, GLint, GLint); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVPROC) (GLuint, const GLint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIPROC) (GLuint, GLuint, GLuint, GLuint); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVPROC) (GLuint, const GLuint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVPROC) (GLuint, const GLbyte*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IPROC) (GLuint, GLint, GLint, GLint, GLint); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVPROC) (GLuint, const GLint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVPROC) (GLuint, const GLshort*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVPROC) (GLuint, const GLubyte*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIPROC) (GLuint, GLuint, GLuint, GLuint, GLuint); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVPROC) (GLuint, const GLuint*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVPROC) (GLuint, const GLushort*); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint, GLint, GLenum, GLsizei, const GLvoid*); #define glBeginConditionalRender GLEW_GET_FUN(__glewBeginConditionalRender) #define glBeginTransformFeedback GLEW_GET_FUN(__glewBeginTransformFeedback) #define glBindFragDataLocation GLEW_GET_FUN(__glewBindFragDataLocation) #define glClampColor GLEW_GET_FUN(__glewClampColor) #define glClearBufferfi GLEW_GET_FUN(__glewClearBufferfi) #define glClearBufferfv GLEW_GET_FUN(__glewClearBufferfv) #define glClearBufferiv GLEW_GET_FUN(__glewClearBufferiv) #define glClearBufferuiv GLEW_GET_FUN(__glewClearBufferuiv) #define glColorMaski GLEW_GET_FUN(__glewColorMaski) #define glDisablei GLEW_GET_FUN(__glewDisablei) #define glEnablei GLEW_GET_FUN(__glewEnablei) #define glEndConditionalRender GLEW_GET_FUN(__glewEndConditionalRender) #define glEndTransformFeedback GLEW_GET_FUN(__glewEndTransformFeedback) #define glGetBooleani_v GLEW_GET_FUN(__glewGetBooleani_v) #define glGetFragDataLocation GLEW_GET_FUN(__glewGetFragDataLocation) #define glGetStringi GLEW_GET_FUN(__glewGetStringi) #define glGetTexParameterIiv GLEW_GET_FUN(__glewGetTexParameterIiv) #define glGetTexParameterIuiv GLEW_GET_FUN(__glewGetTexParameterIuiv) #define glGetTransformFeedbackVarying GLEW_GET_FUN(__glewGetTransformFeedbackVarying) #define glGetUniformuiv GLEW_GET_FUN(__glewGetUniformuiv) #define glGetVertexAttribIiv GLEW_GET_FUN(__glewGetVertexAttribIiv) #define glGetVertexAttribIuiv GLEW_GET_FUN(__glewGetVertexAttribIuiv) #define glIsEnabledi GLEW_GET_FUN(__glewIsEnabledi) #define glTexParameterIiv GLEW_GET_FUN(__glewTexParameterIiv) #define glTexParameterIuiv GLEW_GET_FUN(__glewTexParameterIuiv) #define glTransformFeedbackVaryings GLEW_GET_FUN(__glewTransformFeedbackVaryings) #define glUniform1ui GLEW_GET_FUN(__glewUniform1ui) #define glUniform1uiv GLEW_GET_FUN(__glewUniform1uiv) #define glUniform2ui GLEW_GET_FUN(__glewUniform2ui) #define glUniform2uiv GLEW_GET_FUN(__glewUniform2uiv) #define glUniform3ui GLEW_GET_FUN(__glewUniform3ui) #define glUniform3uiv GLEW_GET_FUN(__glewUniform3uiv) #define glUniform4ui GLEW_GET_FUN(__glewUniform4ui) #define glUniform4uiv GLEW_GET_FUN(__glewUniform4uiv) #define glVertexAttribI1i GLEW_GET_FUN(__glewVertexAttribI1i) #define glVertexAttribI1iv GLEW_GET_FUN(__glewVertexAttribI1iv) #define glVertexAttribI1ui GLEW_GET_FUN(__glewVertexAttribI1ui) #define glVertexAttribI1uiv GLEW_GET_FUN(__glewVertexAttribI1uiv) #define glVertexAttribI2i GLEW_GET_FUN(__glewVertexAttribI2i) #define glVertexAttribI2iv GLEW_GET_FUN(__glewVertexAttribI2iv) #define glVertexAttribI2ui GLEW_GET_FUN(__glewVertexAttribI2ui) #define glVertexAttribI2uiv GLEW_GET_FUN(__glewVertexAttribI2uiv) #define glVertexAttribI3i GLEW_GET_FUN(__glewVertexAttribI3i) #define glVertexAttribI3iv GLEW_GET_FUN(__glewVertexAttribI3iv) #define glVertexAttribI3ui GLEW_GET_FUN(__glewVertexAttribI3ui) #define glVertexAttribI3uiv GLEW_GET_FUN(__glewVertexAttribI3uiv) #define glVertexAttribI4bv GLEW_GET_FUN(__glewVertexAttribI4bv) #define glVertexAttribI4i GLEW_GET_FUN(__glewVertexAttribI4i) #define glVertexAttribI4iv GLEW_GET_FUN(__glewVertexAttribI4iv) #define glVertexAttribI4sv GLEW_GET_FUN(__glewVertexAttribI4sv) #define glVertexAttribI4ubv GLEW_GET_FUN(__glewVertexAttribI4ubv) #define glVertexAttribI4ui GLEW_GET_FUN(__glewVertexAttribI4ui) #define glVertexAttribI4uiv GLEW_GET_FUN(__glewVertexAttribI4uiv) #define glVertexAttribI4usv GLEW_GET_FUN(__glewVertexAttribI4usv) #define glVertexAttribIPointer GLEW_GET_FUN(__glewVertexAttribIPointer) #define GLEW_VERSION_3_0 GLEW_GET_VAR(__GLEW_VERSION_3_0) #endif /* GL_VERSION_3_0 */ /* ----------------------------- GL_VERSION_3_1 ---------------------------- */ #ifndef GL_VERSION_3_1 #define GL_VERSION_3_1 1 #define GL_TEXTURE_RECTANGLE 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 #define GL_SAMPLER_2D_RECT 0x8B63 #define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 #define GL_TEXTURE_BUFFER 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B #define GL_TEXTURE_BINDING_BUFFER 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D #define GL_TEXTURE_BUFFER_FORMAT 0x8C2E #define GL_SAMPLER_BUFFER 0x8DC2 #define GL_INT_SAMPLER_2D_RECT 0x8DCD #define GL_INT_SAMPLER_BUFFER 0x8DD0 #define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 #define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 #define GL_RED_SNORM 0x8F90 #define GL_RG_SNORM 0x8F91 #define GL_RGB_SNORM 0x8F92 #define GL_RGBA_SNORM 0x8F93 #define GL_R8_SNORM 0x8F94 #define GL_RG8_SNORM 0x8F95 #define GL_RGB8_SNORM 0x8F96 #define GL_RGBA8_SNORM 0x8F97 #define GL_R16_SNORM 0x8F98 #define GL_RG16_SNORM 0x8F99 #define GL_RGB16_SNORM 0x8F9A #define GL_RGBA16_SNORM 0x8F9B #define GL_SIGNED_NORMALIZED 0x8F9C #define GL_PRIMITIVE_RESTART 0x8F9D #define GL_PRIMITIVE_RESTART_INDEX 0x8F9E #define GL_BUFFER_ACCESS_FLAGS 0x911F #define GL_BUFFER_MAP_LENGTH 0x9120 #define GL_BUFFER_MAP_OFFSET 0x9121 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum, GLint, GLsizei, GLsizei); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum, GLsizei, GLenum, const GLvoid*, GLsizei); typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint); typedef void (GLAPIENTRY * PFNGLTEXBUFFERPROC) (GLenum, GLenum, GLuint); #define glDrawArraysInstanced GLEW_GET_FUN(__glewDrawArraysInstanced) #define glDrawElementsInstanced GLEW_GET_FUN(__glewDrawElementsInstanced) #define glPrimitiveRestartIndex GLEW_GET_FUN(__glewPrimitiveRestartIndex) #define glTexBuffer GLEW_GET_FUN(__glewTexBuffer) #define GLEW_VERSION_3_1 GLEW_GET_VAR(__GLEW_VERSION_3_1) #endif /* GL_VERSION_3_1 */ /* ----------------------------- GL_VERSION_3_2 ---------------------------- */ #ifndef GL_VERSION_3_2 #define GL_VERSION_3_2 1 #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 #define GL_LINES_ADJACENCY 0x000A #define GL_LINE_STRIP_ADJACENCY 0x000B #define GL_TRIANGLES_ADJACENCY 0x000C #define GL_TRIANGLE_STRIP_ADJACENCY 0x000D #define GL_PROGRAM_POINT_SIZE 0x8642 #define GL_GEOMETRY_VERTICES_OUT 0x8916 #define GL_GEOMETRY_INPUT_TYPE 0x8917 #define GL_GEOMETRY_OUTPUT_TYPE 0x8918 #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 #define GL_GEOMETRY_SHADER 0x8DD9 #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 #define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 #define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 #define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 #define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 #define GL_CONTEXT_PROFILE_MASK 0x9126 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum, GLenum, GLuint, GLint); typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum, GLenum, GLint64 *); typedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum, GLuint, GLint64 *); #define glFramebufferTexture GLEW_GET_FUN(__glewFramebufferTexture) #define glGetBufferParameteri64v GLEW_GET_FUN(__glewGetBufferParameteri64v) #define glGetInteger64i_v GLEW_GET_FUN(__glewGetInteger64i_v) #define GLEW_VERSION_3_2 GLEW_GET_VAR(__GLEW_VERSION_3_2) #endif /* GL_VERSION_3_2 */ /* ----------------------------- GL_VERSION_3_3 ---------------------------- */ #ifndef GL_VERSION_3_3 #define GL_VERSION_3_3 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE #define GL_ANY_SAMPLES_PASSED 0x8C2F #define GL_TEXTURE_SWIZZLE_R 0x8E42 #define GL_TEXTURE_SWIZZLE_G 0x8E43 #define GL_TEXTURE_SWIZZLE_B 0x8E44 #define GL_TEXTURE_SWIZZLE_A 0x8E45 #define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 #define GL_RGB10_A2UI 0x906F typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); #define glVertexAttribDivisor GLEW_GET_FUN(__glewVertexAttribDivisor) #define GLEW_VERSION_3_3 GLEW_GET_VAR(__GLEW_VERSION_3_3) #endif /* GL_VERSION_3_3 */ /* ----------------------------- GL_VERSION_4_0 ---------------------------- */ #ifndef GL_VERSION_4_0 #define GL_VERSION_4_0 1 #define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F #define GL_SAMPLE_SHADING 0x8C36 #define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 #define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A #define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B #define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C #define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F #define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F #define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A #define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B #define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D #define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); typedef void (GLAPIENTRY * PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGPROC) (GLclampf value); #define glBlendEquationSeparatei GLEW_GET_FUN(__glewBlendEquationSeparatei) #define glBlendEquationi GLEW_GET_FUN(__glewBlendEquationi) #define glBlendFuncSeparatei GLEW_GET_FUN(__glewBlendFuncSeparatei) #define glBlendFunci GLEW_GET_FUN(__glewBlendFunci) #define glMinSampleShading GLEW_GET_FUN(__glewMinSampleShading) #define GLEW_VERSION_4_0 GLEW_GET_VAR(__GLEW_VERSION_4_0) #endif /* GL_VERSION_4_0 */ /* ----------------------------- GL_VERSION_4_1 ---------------------------- */ #ifndef GL_VERSION_4_1 #define GL_VERSION_4_1 1 #define GLEW_VERSION_4_1 GLEW_GET_VAR(__GLEW_VERSION_4_1) #endif /* GL_VERSION_4_1 */ /* ----------------------------- GL_VERSION_4_2 ---------------------------- */ #ifndef GL_VERSION_4_2 #define GL_VERSION_4_2 1 #define GLEW_VERSION_4_2 GLEW_GET_VAR(__GLEW_VERSION_4_2) #endif /* GL_VERSION_4_2 */ /* -------------------------- GL_3DFX_multisample -------------------------- */ #ifndef GL_3DFX_multisample #define GL_3DFX_multisample 1 #define GL_MULTISAMPLE_3DFX 0x86B2 #define GL_SAMPLE_BUFFERS_3DFX 0x86B3 #define GL_SAMPLES_3DFX 0x86B4 #define GL_MULTISAMPLE_BIT_3DFX 0x20000000 #define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample) #endif /* GL_3DFX_multisample */ /* ---------------------------- GL_3DFX_tbuffer ---------------------------- */ #ifndef GL_3DFX_tbuffer #define GL_3DFX_tbuffer 1 typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); #define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX) #define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer) #endif /* GL_3DFX_tbuffer */ /* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */ #ifndef GL_3DFX_texture_compression_FXT1 #define GL_3DFX_texture_compression_FXT1 1 #define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 #define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 #define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1) #endif /* GL_3DFX_texture_compression_FXT1 */ /* ----------------------- GL_AMD_blend_minmax_factor ---------------------- */ #ifndef GL_AMD_blend_minmax_factor #define GL_AMD_blend_minmax_factor 1 #define GL_FACTOR_MIN_AMD 0x901C #define GL_FACTOR_MAX_AMD 0x901D #define GLEW_AMD_blend_minmax_factor GLEW_GET_VAR(__GLEW_AMD_blend_minmax_factor) #endif /* GL_AMD_blend_minmax_factor */ /* ----------------------- GL_AMD_conservative_depth ----------------------- */ #ifndef GL_AMD_conservative_depth #define GL_AMD_conservative_depth 1 #define GLEW_AMD_conservative_depth GLEW_GET_VAR(__GLEW_AMD_conservative_depth) #endif /* GL_AMD_conservative_depth */ /* -------------------------- GL_AMD_debug_output -------------------------- */ #ifndef GL_AMD_debug_output #define GL_AMD_debug_output 1 #define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 #define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 #define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 #define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 #define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 #define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A #define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B #define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C #define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D #define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E #define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F #define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void* userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const char* buf); typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, char* message); #define glDebugMessageCallbackAMD GLEW_GET_FUN(__glewDebugMessageCallbackAMD) #define glDebugMessageEnableAMD GLEW_GET_FUN(__glewDebugMessageEnableAMD) #define glDebugMessageInsertAMD GLEW_GET_FUN(__glewDebugMessageInsertAMD) #define glGetDebugMessageLogAMD GLEW_GET_FUN(__glewGetDebugMessageLogAMD) #define GLEW_AMD_debug_output GLEW_GET_VAR(__GLEW_AMD_debug_output) #endif /* GL_AMD_debug_output */ /* ---------------------- GL_AMD_depth_clamp_separate ---------------------- */ #ifndef GL_AMD_depth_clamp_separate #define GL_AMD_depth_clamp_separate 1 #define GL_DEPTH_CLAMP_NEAR_AMD 0x901E #define GL_DEPTH_CLAMP_FAR_AMD 0x901F #define GLEW_AMD_depth_clamp_separate GLEW_GET_VAR(__GLEW_AMD_depth_clamp_separate) #endif /* GL_AMD_depth_clamp_separate */ /* ----------------------- GL_AMD_draw_buffers_blend ----------------------- */ #ifndef GL_AMD_draw_buffers_blend #define GL_AMD_draw_buffers_blend 1 typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (GLAPIENTRY * PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #define glBlendEquationIndexedAMD GLEW_GET_FUN(__glewBlendEquationIndexedAMD) #define glBlendEquationSeparateIndexedAMD GLEW_GET_FUN(__glewBlendEquationSeparateIndexedAMD) #define glBlendFuncIndexedAMD GLEW_GET_FUN(__glewBlendFuncIndexedAMD) #define glBlendFuncSeparateIndexedAMD GLEW_GET_FUN(__glewBlendFuncSeparateIndexedAMD) #define GLEW_AMD_draw_buffers_blend GLEW_GET_VAR(__GLEW_AMD_draw_buffers_blend) #endif /* GL_AMD_draw_buffers_blend */ /* ----------------------- GL_AMD_multi_draw_indirect ---------------------- */ #ifndef GL_AMD_multi_draw_indirect #define GL_AMD_multi_draw_indirect 1 typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void* indirect, GLsizei primcount, GLsizei stride); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void* indirect, GLsizei primcount, GLsizei stride); #define glMultiDrawArraysIndirectAMD GLEW_GET_FUN(__glewMultiDrawArraysIndirectAMD) #define glMultiDrawElementsIndirectAMD GLEW_GET_FUN(__glewMultiDrawElementsIndirectAMD) #define GLEW_AMD_multi_draw_indirect GLEW_GET_VAR(__GLEW_AMD_multi_draw_indirect) #endif /* GL_AMD_multi_draw_indirect */ /* ------------------------- GL_AMD_name_gen_delete ------------------------ */ #ifndef GL_AMD_name_gen_delete #define GL_AMD_name_gen_delete 1 #define GL_DATA_BUFFER_AMD 0x9151 #define GL_PERFORMANCE_MONITOR_AMD 0x9152 #define GL_QUERY_OBJECT_AMD 0x9153 #define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 #define GL_SAMPLER_OBJECT_AMD 0x9155 typedef void (GLAPIENTRY * PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint* names); typedef void (GLAPIENTRY * PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint* names); typedef GLboolean (GLAPIENTRY * PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); #define glDeleteNamesAMD GLEW_GET_FUN(__glewDeleteNamesAMD) #define glGenNamesAMD GLEW_GET_FUN(__glewGenNamesAMD) #define glIsNameAMD GLEW_GET_FUN(__glewIsNameAMD) #define GLEW_AMD_name_gen_delete GLEW_GET_VAR(__GLEW_AMD_name_gen_delete) #endif /* GL_AMD_name_gen_delete */ /* ----------------------- GL_AMD_performance_monitor ---------------------- */ #ifndef GL_AMD_performance_monitor #define GL_AMD_performance_monitor 1 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 #define GL_COUNTER_TYPE_AMD 0x8BC0 #define GL_COUNTER_RANGE_AMD 0x8BC1 #define GL_UNSIGNED_INT64_AMD 0x8BC2 #define GL_PERCENTAGE_AMD 0x8BC3 #define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 #define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 #define GL_PERFMON_RESULT_AMD 0x8BC6 typedef void (GLAPIENTRY * PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); typedef void (GLAPIENTRY * PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); typedef void (GLAPIENTRY * PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); typedef void (GLAPIENTRY * PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint *bytesWritten); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void* data); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, char *counterString); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint* numCounters, GLint *maxActiveCounters, GLsizei countersSize, GLuint *counters); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei* length, char *groupString); typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint* numGroups, GLsizei groupsSize, GLuint *groups); typedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList); #define glBeginPerfMonitorAMD GLEW_GET_FUN(__glewBeginPerfMonitorAMD) #define glDeletePerfMonitorsAMD GLEW_GET_FUN(__glewDeletePerfMonitorsAMD) #define glEndPerfMonitorAMD GLEW_GET_FUN(__glewEndPerfMonitorAMD) #define glGenPerfMonitorsAMD GLEW_GET_FUN(__glewGenPerfMonitorsAMD) #define glGetPerfMonitorCounterDataAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterDataAMD) #define glGetPerfMonitorCounterInfoAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterInfoAMD) #define glGetPerfMonitorCounterStringAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterStringAMD) #define glGetPerfMonitorCountersAMD GLEW_GET_FUN(__glewGetPerfMonitorCountersAMD) #define glGetPerfMonitorGroupStringAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupStringAMD) #define glGetPerfMonitorGroupsAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupsAMD) #define glSelectPerfMonitorCountersAMD GLEW_GET_FUN(__glewSelectPerfMonitorCountersAMD) #define GLEW_AMD_performance_monitor GLEW_GET_VAR(__GLEW_AMD_performance_monitor) #endif /* GL_AMD_performance_monitor */ /* ------------------------ GL_AMD_sample_positions ------------------------ */ #ifndef GL_AMD_sample_positions #define GL_AMD_sample_positions 1 #define GL_SUBSAMPLE_DISTANCE_AMD 0x883F typedef void (GLAPIENTRY * PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat* val); #define glSetMultisamplefvAMD GLEW_GET_FUN(__glewSetMultisamplefvAMD) #define GLEW_AMD_sample_positions GLEW_GET_VAR(__GLEW_AMD_sample_positions) #endif /* GL_AMD_sample_positions */ /* ------------------ GL_AMD_seamless_cubemap_per_texture ------------------ */ #ifndef GL_AMD_seamless_cubemap_per_texture #define GL_AMD_seamless_cubemap_per_texture 1 #define GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB 0x884F #define GLEW_AMD_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_AMD_seamless_cubemap_per_texture) #endif /* GL_AMD_seamless_cubemap_per_texture */ /* ---------------------- GL_AMD_shader_stencil_export --------------------- */ #ifndef GL_AMD_shader_stencil_export #define GL_AMD_shader_stencil_export 1 #define GLEW_AMD_shader_stencil_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_export) #endif /* GL_AMD_shader_stencil_export */ /* ------------------------ GL_AMD_texture_texture4 ------------------------ */ #ifndef GL_AMD_texture_texture4 #define GL_AMD_texture_texture4 1 #define GLEW_AMD_texture_texture4 GLEW_GET_VAR(__GLEW_AMD_texture_texture4) #endif /* GL_AMD_texture_texture4 */ /* --------------- GL_AMD_transform_feedback3_lines_triangles -------------- */ #ifndef GL_AMD_transform_feedback3_lines_triangles #define GL_AMD_transform_feedback3_lines_triangles 1 #define GLEW_AMD_transform_feedback3_lines_triangles GLEW_GET_VAR(__GLEW_AMD_transform_feedback3_lines_triangles) #endif /* GL_AMD_transform_feedback3_lines_triangles */ /* -------------------- GL_AMD_vertex_shader_tessellator ------------------- */ #ifndef GL_AMD_vertex_shader_tessellator #define GL_AMD_vertex_shader_tessellator 1 #define GL_SAMPLER_BUFFER_AMD 0x9001 #define GL_INT_SAMPLER_BUFFER_AMD 0x9002 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 #define GL_TESSELLATION_MODE_AMD 0x9004 #define GL_TESSELLATION_FACTOR_AMD 0x9005 #define GL_DISCRETE_AMD 0x9006 #define GL_CONTINUOUS_AMD 0x9007 typedef void (GLAPIENTRY * PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); typedef void (GLAPIENTRY * PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); #define glTessellationFactorAMD GLEW_GET_FUN(__glewTessellationFactorAMD) #define glTessellationModeAMD GLEW_GET_FUN(__glewTessellationModeAMD) #define GLEW_AMD_vertex_shader_tessellator GLEW_GET_VAR(__GLEW_AMD_vertex_shader_tessellator) #endif /* GL_AMD_vertex_shader_tessellator */ /* ----------------------- GL_APPLE_aux_depth_stencil ---------------------- */ #ifndef GL_APPLE_aux_depth_stencil #define GL_APPLE_aux_depth_stencil 1 #define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 #define GLEW_APPLE_aux_depth_stencil GLEW_GET_VAR(__GLEW_APPLE_aux_depth_stencil) #endif /* GL_APPLE_aux_depth_stencil */ /* ------------------------ GL_APPLE_client_storage ------------------------ */ #ifndef GL_APPLE_client_storage #define GL_APPLE_client_storage 1 #define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 #define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage) #endif /* GL_APPLE_client_storage */ /* ------------------------- GL_APPLE_element_array ------------------------ */ #ifndef GL_APPLE_element_array #define GL_APPLE_element_array 1 #define GL_ELEMENT_ARRAY_APPLE 0x8A0C #define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D #define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void* pointer); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); #define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE) #define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE) #define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE) #define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE) #define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE) #define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array) #endif /* GL_APPLE_element_array */ /* ----------------------------- GL_APPLE_fence ---------------------------- */ #ifndef GL_APPLE_fence #define GL_APPLE_fence 1 #define GL_DRAW_PIXELS_APPLE 0x8A0A #define GL_FENCE_APPLE 0x8A0B typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); #define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE) #define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE) #define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE) #define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE) #define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE) #define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE) #define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE) #define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE) #define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence) #endif /* GL_APPLE_fence */ /* ------------------------- GL_APPLE_float_pixels ------------------------- */ #ifndef GL_APPLE_float_pixels #define GL_APPLE_float_pixels 1 #define GL_HALF_APPLE 0x140B #define GL_RGBA_FLOAT32_APPLE 0x8814 #define GL_RGB_FLOAT32_APPLE 0x8815 #define GL_ALPHA_FLOAT32_APPLE 0x8816 #define GL_INTENSITY_FLOAT32_APPLE 0x8817 #define GL_LUMINANCE_FLOAT32_APPLE 0x8818 #define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 #define GL_RGBA_FLOAT16_APPLE 0x881A #define GL_RGB_FLOAT16_APPLE 0x881B #define GL_ALPHA_FLOAT16_APPLE 0x881C #define GL_INTENSITY_FLOAT16_APPLE 0x881D #define GL_LUMINANCE_FLOAT16_APPLE 0x881E #define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F #define GL_COLOR_FLOAT_APPLE 0x8A0F #define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels) #endif /* GL_APPLE_float_pixels */ /* ---------------------- GL_APPLE_flush_buffer_range ---------------------- */ #ifndef GL_APPLE_flush_buffer_range #define GL_APPLE_flush_buffer_range 1 #define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 #define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 typedef void (GLAPIENTRY * PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); #define glBufferParameteriAPPLE GLEW_GET_FUN(__glewBufferParameteriAPPLE) #define glFlushMappedBufferRangeAPPLE GLEW_GET_FUN(__glewFlushMappedBufferRangeAPPLE) #define GLEW_APPLE_flush_buffer_range GLEW_GET_VAR(__GLEW_APPLE_flush_buffer_range) #endif /* GL_APPLE_flush_buffer_range */ /* ----------------------- GL_APPLE_object_purgeable ----------------------- */ #ifndef GL_APPLE_object_purgeable #define GL_APPLE_object_purgeable 1 #define GL_BUFFER_OBJECT_APPLE 0x85B3 #define GL_RELEASED_APPLE 0x8A19 #define GL_VOLATILE_APPLE 0x8A1A #define GL_RETAINED_APPLE 0x8A1B #define GL_UNDEFINED_APPLE 0x8A1C #define GL_PURGEABLE_APPLE 0x8A1D typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params); typedef GLenum (GLAPIENTRY * PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); typedef GLenum (GLAPIENTRY * PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); #define glGetObjectParameterivAPPLE GLEW_GET_FUN(__glewGetObjectParameterivAPPLE) #define glObjectPurgeableAPPLE GLEW_GET_FUN(__glewObjectPurgeableAPPLE) #define glObjectUnpurgeableAPPLE GLEW_GET_FUN(__glewObjectUnpurgeableAPPLE) #define GLEW_APPLE_object_purgeable GLEW_GET_VAR(__GLEW_APPLE_object_purgeable) #endif /* GL_APPLE_object_purgeable */ /* ------------------------- GL_APPLE_pixel_buffer ------------------------- */ #ifndef GL_APPLE_pixel_buffer #define GL_APPLE_pixel_buffer 1 #define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 #define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer) #endif /* GL_APPLE_pixel_buffer */ /* ---------------------------- GL_APPLE_rgb_422 --------------------------- */ #ifndef GL_APPLE_rgb_422 #define GL_APPLE_rgb_422 1 #define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB #define GL_RGB_422_APPLE 0x8A1F #define GLEW_APPLE_rgb_422 GLEW_GET_VAR(__GLEW_APPLE_rgb_422) #endif /* GL_APPLE_rgb_422 */ /* --------------------------- GL_APPLE_row_bytes -------------------------- */ #ifndef GL_APPLE_row_bytes #define GL_APPLE_row_bytes 1 #define GL_PACK_ROW_BYTES_APPLE 0x8A15 #define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 #define GLEW_APPLE_row_bytes GLEW_GET_VAR(__GLEW_APPLE_row_bytes) #endif /* GL_APPLE_row_bytes */ /* ------------------------ GL_APPLE_specular_vector ----------------------- */ #ifndef GL_APPLE_specular_vector #define GL_APPLE_specular_vector 1 #define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 #define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector) #endif /* GL_APPLE_specular_vector */ /* ------------------------- GL_APPLE_texture_range ------------------------ */ #ifndef GL_APPLE_texture_range #define GL_APPLE_texture_range 1 #define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 #define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 #define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC #define GL_STORAGE_PRIVATE_APPLE 0x85BD #define GL_STORAGE_CACHED_APPLE 0x85BE #define GL_STORAGE_SHARED_APPLE 0x85BF typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params); typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid *pointer); #define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE) #define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE) #define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range) #endif /* GL_APPLE_texture_range */ /* ------------------------ GL_APPLE_transform_hint ------------------------ */ #ifndef GL_APPLE_transform_hint #define GL_APPLE_transform_hint 1 #define GL_TRANSFORM_HINT_APPLE 0x85B1 #define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint) #endif /* GL_APPLE_transform_hint */ /* ---------------------- GL_APPLE_vertex_array_object --------------------- */ #ifndef GL_APPLE_vertex_array_object #define GL_APPLE_vertex_array_object 1 #define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE) #define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE) #define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE) #define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE) #define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object) #endif /* GL_APPLE_vertex_array_object */ /* ---------------------- GL_APPLE_vertex_array_range ---------------------- */ #ifndef GL_APPLE_vertex_array_range #define GL_APPLE_vertex_array_range 1 #define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D #define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E #define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F #define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 #define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 #define GL_STORAGE_CLIENT_APPLE 0x85B4 #define GL_STORAGE_CACHED_APPLE 0x85BE #define GL_STORAGE_SHARED_APPLE 0x85BF typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); #define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE) #define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE) #define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE) #define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range) #endif /* GL_APPLE_vertex_array_range */ /* ------------------- GL_APPLE_vertex_program_evaluators ------------------ */ #ifndef GL_APPLE_vertex_program_evaluators #define GL_APPLE_vertex_program_evaluators 1 #define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 #define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 #define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 #define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 #define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 #define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 #define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 #define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 #define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 #define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points); typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points); typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points); typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points); #define glDisableVertexAttribAPPLE GLEW_GET_FUN(__glewDisableVertexAttribAPPLE) #define glEnableVertexAttribAPPLE GLEW_GET_FUN(__glewEnableVertexAttribAPPLE) #define glIsVertexAttribEnabledAPPLE GLEW_GET_FUN(__glewIsVertexAttribEnabledAPPLE) #define glMapVertexAttrib1dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1dAPPLE) #define glMapVertexAttrib1fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1fAPPLE) #define glMapVertexAttrib2dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2dAPPLE) #define glMapVertexAttrib2fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2fAPPLE) #define GLEW_APPLE_vertex_program_evaluators GLEW_GET_VAR(__GLEW_APPLE_vertex_program_evaluators) #endif /* GL_APPLE_vertex_program_evaluators */ /* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */ #ifndef GL_APPLE_ycbcr_422 #define GL_APPLE_ycbcr_422 1 #define GL_YCBCR_422_APPLE 0x85B9 #define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB #define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422) #endif /* GL_APPLE_ycbcr_422 */ /* ------------------------ GL_ARB_ES2_compatibility ----------------------- */ #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #define GL_FIXED 0x140C #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B #define GL_LOW_FLOAT 0x8DF0 #define GL_MEDIUM_FLOAT 0x8DF1 #define GL_HIGH_FLOAT 0x8DF2 #define GL_LOW_INT 0x8DF3 #define GL_MEDIUM_INT 0x8DF4 #define GL_HIGH_INT 0x8DF5 #define GL_SHADER_BINARY_FORMATS 0x8DF8 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #define GL_SHADER_COMPILER 0x8DFA #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB #define GL_MAX_VARYING_VECTORS 0x8DFC #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFPROC) (GLclampf d); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); typedef void (GLAPIENTRY * PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint *precision); typedef void (GLAPIENTRY * PFNGLRELEASESHADERCOMPILERPROC) (void); typedef void (GLAPIENTRY * PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint* shaders, GLenum binaryformat, const GLvoid*binary, GLsizei length); #define glClearDepthf GLEW_GET_FUN(__glewClearDepthf) #define glDepthRangef GLEW_GET_FUN(__glewDepthRangef) #define glGetShaderPrecisionFormat GLEW_GET_FUN(__glewGetShaderPrecisionFormat) #define glReleaseShaderCompiler GLEW_GET_FUN(__glewReleaseShaderCompiler) #define glShaderBinary GLEW_GET_FUN(__glewShaderBinary) #define GLEW_ARB_ES2_compatibility GLEW_GET_VAR(__GLEW_ARB_ES2_compatibility) #endif /* GL_ARB_ES2_compatibility */ /* -------------------------- GL_ARB_base_instance ------------------------- */ #ifndef GL_ARB_base_instance #define GL_ARB_base_instance 1 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLuint baseinstance); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); #define glDrawArraysInstancedBaseInstance GLEW_GET_FUN(__glewDrawArraysInstancedBaseInstance) #define glDrawElementsInstancedBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseInstance) #define glDrawElementsInstancedBaseVertexBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertexBaseInstance) #define GLEW_ARB_base_instance GLEW_GET_VAR(__GLEW_ARB_base_instance) #endif /* GL_ARB_base_instance */ /* ----------------------- GL_ARB_blend_func_extended ---------------------- */ #ifndef GL_ARB_blend_func_extended #define GL_ARB_blend_func_extended 1 #define GL_SRC1_COLOR 0x88F9 #define GL_ONE_MINUS_SRC1_COLOR 0x88FA #define GL_ONE_MINUS_SRC1_ALPHA 0x88FB #define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const char * name); typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const char * name); #define glBindFragDataLocationIndexed GLEW_GET_FUN(__glewBindFragDataLocationIndexed) #define glGetFragDataIndex GLEW_GET_FUN(__glewGetFragDataIndex) #define GLEW_ARB_blend_func_extended GLEW_GET_VAR(__GLEW_ARB_blend_func_extended) #endif /* GL_ARB_blend_func_extended */ /* ---------------------------- GL_ARB_cl_event ---------------------------- */ #ifndef GL_ARB_cl_event #define GL_ARB_cl_event 1 #define GL_SYNC_CL_EVENT_ARB 0x8240 #define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 typedef struct _cl_context *cl_context; typedef struct _cl_event *cl_event; typedef GLsync (GLAPIENTRY * PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags); #define glCreateSyncFromCLeventARB GLEW_GET_FUN(__glewCreateSyncFromCLeventARB) #define GLEW_ARB_cl_event GLEW_GET_VAR(__GLEW_ARB_cl_event) #endif /* GL_ARB_cl_event */ /* ----------------------- GL_ARB_color_buffer_float ----------------------- */ #ifndef GL_ARB_color_buffer_float #define GL_ARB_color_buffer_float 1 #define GL_RGBA_FLOAT_MODE_ARB 0x8820 #define GL_CLAMP_VERTEX_COLOR_ARB 0x891A #define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B #define GL_CLAMP_READ_COLOR_ARB 0x891C #define GL_FIXED_ONLY_ARB 0x891D typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); #define glClampColorARB GLEW_GET_FUN(__glewClampColorARB) #define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float) #endif /* GL_ARB_color_buffer_float */ /* -------------------------- GL_ARB_compatibility ------------------------- */ #ifndef GL_ARB_compatibility #define GL_ARB_compatibility 1 #define GLEW_ARB_compatibility GLEW_GET_VAR(__GLEW_ARB_compatibility) #endif /* GL_ARB_compatibility */ /* ---------------- GL_ARB_compressed_texture_pixel_storage ---------------- */ #ifndef GL_ARB_compressed_texture_pixel_storage #define GL_ARB_compressed_texture_pixel_storage 1 #define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 #define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 #define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 #define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A #define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B #define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C #define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D #define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E #define GLEW_ARB_compressed_texture_pixel_storage GLEW_GET_VAR(__GLEW_ARB_compressed_texture_pixel_storage) #endif /* GL_ARB_compressed_texture_pixel_storage */ /* ----------------------- GL_ARB_conservative_depth ----------------------- */ #ifndef GL_ARB_conservative_depth #define GL_ARB_conservative_depth 1 #define GLEW_ARB_conservative_depth GLEW_GET_VAR(__GLEW_ARB_conservative_depth) #endif /* GL_ARB_conservative_depth */ /* --------------------------- GL_ARB_copy_buffer -------------------------- */ #ifndef GL_ARB_copy_buffer #define GL_ARB_copy_buffer 1 #define GL_COPY_READ_BUFFER 0x8F36 #define GL_COPY_WRITE_BUFFER 0x8F37 typedef void (GLAPIENTRY * PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size); #define glCopyBufferSubData GLEW_GET_FUN(__glewCopyBufferSubData) #define GLEW_ARB_copy_buffer GLEW_GET_VAR(__GLEW_ARB_copy_buffer) #endif /* GL_ARB_copy_buffer */ /* -------------------------- GL_ARB_debug_output -------------------------- */ #ifndef GL_ARB_debug_output #define GL_ARB_debug_output 1 #define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 #define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 #define GL_DEBUG_SOURCE_API_ARB 0x8246 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 #define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 #define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 #define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A #define GL_DEBUG_SOURCE_OTHER_ARB 0x824B #define GL_DEBUG_TYPE_ERROR_ARB 0x824C #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E #define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F #define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 #define GL_DEBUG_TYPE_OTHER_ARB 0x8251 #define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 #define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 #define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 #define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, void* userParam); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* buf); typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, char* messageLog); #define glDebugMessageCallbackARB GLEW_GET_FUN(__glewDebugMessageCallbackARB) #define glDebugMessageControlARB GLEW_GET_FUN(__glewDebugMessageControlARB) #define glDebugMessageInsertARB GLEW_GET_FUN(__glewDebugMessageInsertARB) #define glGetDebugMessageLogARB GLEW_GET_FUN(__glewGetDebugMessageLogARB) #define GLEW_ARB_debug_output GLEW_GET_VAR(__GLEW_ARB_debug_output) #endif /* GL_ARB_debug_output */ /* ----------------------- GL_ARB_depth_buffer_float ----------------------- */ #ifndef GL_ARB_depth_buffer_float #define GL_ARB_depth_buffer_float 1 #define GL_DEPTH_COMPONENT32F 0x8CAC #define GL_DEPTH32F_STENCIL8 0x8CAD #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD #define GLEW_ARB_depth_buffer_float GLEW_GET_VAR(__GLEW_ARB_depth_buffer_float) #endif /* GL_ARB_depth_buffer_float */ /* --------------------------- GL_ARB_depth_clamp -------------------------- */ #ifndef GL_ARB_depth_clamp #define GL_ARB_depth_clamp 1 #define GL_DEPTH_CLAMP 0x864F #define GLEW_ARB_depth_clamp GLEW_GET_VAR(__GLEW_ARB_depth_clamp) #endif /* GL_ARB_depth_clamp */ /* -------------------------- GL_ARB_depth_texture ------------------------- */ #ifndef GL_ARB_depth_texture #define GL_ARB_depth_texture 1 #define GL_DEPTH_COMPONENT16_ARB 0x81A5 #define GL_DEPTH_COMPONENT24_ARB 0x81A6 #define GL_DEPTH_COMPONENT32_ARB 0x81A7 #define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B #define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture) #endif /* GL_ARB_depth_texture */ /* -------------------------- GL_ARB_draw_buffers -------------------------- */ #ifndef GL_ARB_draw_buffers #define GL_ARB_draw_buffers 1 #define GL_MAX_DRAW_BUFFERS_ARB 0x8824 #define GL_DRAW_BUFFER0_ARB 0x8825 #define GL_DRAW_BUFFER1_ARB 0x8826 #define GL_DRAW_BUFFER2_ARB 0x8827 #define GL_DRAW_BUFFER3_ARB 0x8828 #define GL_DRAW_BUFFER4_ARB 0x8829 #define GL_DRAW_BUFFER5_ARB 0x882A #define GL_DRAW_BUFFER6_ARB 0x882B #define GL_DRAW_BUFFER7_ARB 0x882C #define GL_DRAW_BUFFER8_ARB 0x882D #define GL_DRAW_BUFFER9_ARB 0x882E #define GL_DRAW_BUFFER10_ARB 0x882F #define GL_DRAW_BUFFER11_ARB 0x8830 #define GL_DRAW_BUFFER12_ARB 0x8831 #define GL_DRAW_BUFFER13_ARB 0x8832 #define GL_DRAW_BUFFER14_ARB 0x8833 #define GL_DRAW_BUFFER15_ARB 0x8834 typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs); #define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB) #define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers) #endif /* GL_ARB_draw_buffers */ /* ----------------------- GL_ARB_draw_buffers_blend ----------------------- */ #ifndef GL_ARB_draw_buffers_blend #define GL_ARB_draw_buffers_blend 1 typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); typedef void (GLAPIENTRY * PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); #define glBlendEquationSeparateiARB GLEW_GET_FUN(__glewBlendEquationSeparateiARB) #define glBlendEquationiARB GLEW_GET_FUN(__glewBlendEquationiARB) #define glBlendFuncSeparateiARB GLEW_GET_FUN(__glewBlendFuncSeparateiARB) #define glBlendFunciARB GLEW_GET_FUN(__glewBlendFunciARB) #define GLEW_ARB_draw_buffers_blend GLEW_GET_VAR(__GLEW_ARB_draw_buffers_blend) #endif /* GL_ARB_draw_buffers_blend */ /* -------------------- GL_ARB_draw_elements_base_vertex ------------------- */ #ifndef GL_ARB_draw_elements_base_vertex #define GL_ARB_draw_elements_base_vertex 1 typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, void* indices, GLint basevertex); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLint basevertex); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, void* indices, GLint basevertex); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei* count, GLenum type, GLvoid**indices, GLsizei primcount, GLint *basevertex); #define glDrawElementsBaseVertex GLEW_GET_FUN(__glewDrawElementsBaseVertex) #define glDrawElementsInstancedBaseVertex GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertex) #define glDrawRangeElementsBaseVertex GLEW_GET_FUN(__glewDrawRangeElementsBaseVertex) #define glMultiDrawElementsBaseVertex GLEW_GET_FUN(__glewMultiDrawElementsBaseVertex) #define GLEW_ARB_draw_elements_base_vertex GLEW_GET_VAR(__GLEW_ARB_draw_elements_base_vertex) #endif /* GL_ARB_draw_elements_base_vertex */ /* -------------------------- GL_ARB_draw_indirect ------------------------- */ #ifndef GL_ARB_draw_indirect #define GL_ARB_draw_indirect 1 #define GL_DRAW_INDIRECT_BUFFER 0x8F3F #define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void* indirect); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void* indirect); #define glDrawArraysIndirect GLEW_GET_FUN(__glewDrawArraysIndirect) #define glDrawElementsIndirect GLEW_GET_FUN(__glewDrawElementsIndirect) #define GLEW_ARB_draw_indirect GLEW_GET_VAR(__GLEW_ARB_draw_indirect) #endif /* GL_ARB_draw_indirect */ /* ------------------------- GL_ARB_draw_instanced ------------------------- */ #ifndef GL_ARB_draw_instanced #define GL_ARB_draw_instanced 1 #define GLEW_ARB_draw_instanced GLEW_GET_VAR(__GLEW_ARB_draw_instanced) #endif /* GL_ARB_draw_instanced */ /* -------------------- GL_ARB_explicit_attrib_location -------------------- */ #ifndef GL_ARB_explicit_attrib_location #define GL_ARB_explicit_attrib_location 1 #define GLEW_ARB_explicit_attrib_location GLEW_GET_VAR(__GLEW_ARB_explicit_attrib_location) #endif /* GL_ARB_explicit_attrib_location */ /* ------------------- GL_ARB_fragment_coord_conventions ------------------- */ #ifndef GL_ARB_fragment_coord_conventions #define GL_ARB_fragment_coord_conventions 1 #define GLEW_ARB_fragment_coord_conventions GLEW_GET_VAR(__GLEW_ARB_fragment_coord_conventions) #endif /* GL_ARB_fragment_coord_conventions */ /* ------------------------ GL_ARB_fragment_program ------------------------ */ #ifndef GL_ARB_fragment_program #define GL_ARB_fragment_program 1 #define GL_FRAGMENT_PROGRAM_ARB 0x8804 #define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 #define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 #define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 #define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 #define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 #define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A #define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B #define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C #define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D #define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E #define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F #define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 #define GL_MAX_TEXTURE_COORDS_ARB 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 #define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program) #endif /* GL_ARB_fragment_program */ /* --------------------- GL_ARB_fragment_program_shadow -------------------- */ #ifndef GL_ARB_fragment_program_shadow #define GL_ARB_fragment_program_shadow 1 #define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow) #endif /* GL_ARB_fragment_program_shadow */ /* ------------------------- GL_ARB_fragment_shader ------------------------ */ #ifndef GL_ARB_fragment_shader #define GL_ARB_fragment_shader 1 #define GL_FRAGMENT_SHADER_ARB 0x8B30 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B #define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader) #endif /* GL_ARB_fragment_shader */ /* ----------------------- GL_ARB_framebuffer_object ----------------------- */ #ifndef GL_ARB_framebuffer_object #define GL_ARB_framebuffer_object 1 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 #define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 #define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 #define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 #define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 #define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 #define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 #define GL_FRAMEBUFFER_DEFAULT 0x8218 #define GL_FRAMEBUFFER_UNDEFINED 0x8219 #define GL_DEPTH_STENCIL_ATTACHMENT 0x821A #define GL_INDEX 0x8222 #define GL_MAX_RENDERBUFFER_SIZE 0x84E8 #define GL_DEPTH_STENCIL 0x84F9 #define GL_UNSIGNED_INT_24_8 0x84FA #define GL_DEPTH24_STENCIL8 0x88F0 #define GL_TEXTURE_STENCIL_SIZE 0x88F1 #define GL_UNSIGNED_NORMALIZED 0x8C17 #define GL_SRGB 0x8C40 #define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 #define GL_FRAMEBUFFER_BINDING 0x8CA6 #define GL_RENDERBUFFER_BINDING 0x8CA7 #define GL_READ_FRAMEBUFFER 0x8CA8 #define GL_DRAW_FRAMEBUFFER 0x8CA9 #define GL_READ_FRAMEBUFFER_BINDING 0x8CAA #define GL_RENDERBUFFER_SAMPLES 0x8CAB #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC #define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD #define GL_MAX_COLOR_ATTACHMENTS 0x8CDF #define GL_COLOR_ATTACHMENT0 0x8CE0 #define GL_COLOR_ATTACHMENT1 0x8CE1 #define GL_COLOR_ATTACHMENT2 0x8CE2 #define GL_COLOR_ATTACHMENT3 0x8CE3 #define GL_COLOR_ATTACHMENT4 0x8CE4 #define GL_COLOR_ATTACHMENT5 0x8CE5 #define GL_COLOR_ATTACHMENT6 0x8CE6 #define GL_COLOR_ATTACHMENT7 0x8CE7 #define GL_COLOR_ATTACHMENT8 0x8CE8 #define GL_COLOR_ATTACHMENT9 0x8CE9 #define GL_COLOR_ATTACHMENT10 0x8CEA #define GL_COLOR_ATTACHMENT11 0x8CEB #define GL_COLOR_ATTACHMENT12 0x8CEC #define GL_COLOR_ATTACHMENT13 0x8CED #define GL_COLOR_ATTACHMENT14 0x8CEE #define GL_COLOR_ATTACHMENT15 0x8CEF #define GL_DEPTH_ATTACHMENT 0x8D00 #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_FRAMEBUFFER 0x8D40 #define GL_RENDERBUFFER 0x8D41 #define GL_RENDERBUFFER_WIDTH 0x8D42 #define GL_RENDERBUFFER_HEIGHT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 #define GL_STENCIL_INDEX1 0x8D46 #define GL_STENCIL_INDEX4 0x8D47 #define GL_STENCIL_INDEX8 0x8D48 #define GL_STENCIL_INDEX16 0x8D49 #define GL_RENDERBUFFER_RED_SIZE 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 #define GL_MAX_SAMPLES 0x8D57 typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #define glBindFramebuffer GLEW_GET_FUN(__glewBindFramebuffer) #define glBindRenderbuffer GLEW_GET_FUN(__glewBindRenderbuffer) #define glBlitFramebuffer GLEW_GET_FUN(__glewBlitFramebuffer) #define glCheckFramebufferStatus GLEW_GET_FUN(__glewCheckFramebufferStatus) #define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers) #define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers) #define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer) #define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D) #define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D) #define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D) #define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer) #define glGenFramebuffers GLEW_GET_FUN(__glewGenFramebuffers) #define glGenRenderbuffers GLEW_GET_FUN(__glewGenRenderbuffers) #define glGenerateMipmap GLEW_GET_FUN(__glewGenerateMipmap) #define glGetFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetFramebufferAttachmentParameteriv) #define glGetRenderbufferParameteriv GLEW_GET_FUN(__glewGetRenderbufferParameteriv) #define glIsFramebuffer GLEW_GET_FUN(__glewIsFramebuffer) #define glIsRenderbuffer GLEW_GET_FUN(__glewIsRenderbuffer) #define glRenderbufferStorage GLEW_GET_FUN(__glewRenderbufferStorage) #define glRenderbufferStorageMultisample GLEW_GET_FUN(__glewRenderbufferStorageMultisample) #define GLEW_ARB_framebuffer_object GLEW_GET_VAR(__GLEW_ARB_framebuffer_object) #endif /* GL_ARB_framebuffer_object */ /* ------------------------ GL_ARB_framebuffer_sRGB ------------------------ */ #ifndef GL_ARB_framebuffer_sRGB #define GL_ARB_framebuffer_sRGB 1 #define GL_FRAMEBUFFER_SRGB 0x8DB9 #define GLEW_ARB_framebuffer_sRGB GLEW_GET_VAR(__GLEW_ARB_framebuffer_sRGB) #endif /* GL_ARB_framebuffer_sRGB */ /* ------------------------ GL_ARB_geometry_shader4 ------------------------ */ #ifndef GL_ARB_geometry_shader4 #define GL_ARB_geometry_shader4 1 #define GL_LINES_ADJACENCY_ARB 0xA #define GL_LINE_STRIP_ADJACENCY_ARB 0xB #define GL_TRIANGLES_ADJACENCY_ARB 0xC #define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0xD #define GL_PROGRAM_POINT_SIZE_ARB 0x8642 #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 #define GL_GEOMETRY_SHADER_ARB 0x8DD9 #define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA #define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB #define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC #define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD #define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); #define glFramebufferTextureARB GLEW_GET_FUN(__glewFramebufferTextureARB) #define glFramebufferTextureFaceARB GLEW_GET_FUN(__glewFramebufferTextureFaceARB) #define glFramebufferTextureLayerARB GLEW_GET_FUN(__glewFramebufferTextureLayerARB) #define glProgramParameteriARB GLEW_GET_FUN(__glewProgramParameteriARB) #define GLEW_ARB_geometry_shader4 GLEW_GET_VAR(__GLEW_ARB_geometry_shader4) #endif /* GL_ARB_geometry_shader4 */ /* ----------------------- GL_ARB_get_program_binary ----------------------- */ #ifndef GL_ARB_get_program_binary #define GL_ARB_get_program_binary 1 #define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 #define GL_PROGRAM_BINARY_LENGTH 0x8741 #define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE #define GL_PROGRAM_BINARY_FORMATS 0x87FF typedef void (GLAPIENTRY * PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLenum *binaryFormat, GLvoid*binary); typedef void (GLAPIENTRY * PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void* binary, GLsizei length); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); #define glGetProgramBinary GLEW_GET_FUN(__glewGetProgramBinary) #define glProgramBinary GLEW_GET_FUN(__glewProgramBinary) #define glProgramParameteri GLEW_GET_FUN(__glewProgramParameteri) #define GLEW_ARB_get_program_binary GLEW_GET_VAR(__GLEW_ARB_get_program_binary) #endif /* GL_ARB_get_program_binary */ /* --------------------------- GL_ARB_gpu_shader5 -------------------------- */ #ifndef GL_ARB_gpu_shader5 #define GL_ARB_gpu_shader5 1 #define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F #define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A #define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B #define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C #define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D #define GL_MAX_VERTEX_STREAMS 0x8E71 #define GLEW_ARB_gpu_shader5 GLEW_GET_VAR(__GLEW_ARB_gpu_shader5) #endif /* GL_ARB_gpu_shader5 */ /* ------------------------- GL_ARB_gpu_shader_fp64 ------------------------ */ #ifndef GL_ARB_gpu_shader_fp64 #define GL_ARB_gpu_shader_fp64 1 #define GL_DOUBLE_MAT2 0x8F46 #define GL_DOUBLE_MAT3 0x8F47 #define GL_DOUBLE_MAT4 0x8F48 #define GL_DOUBLE_MAT2x3 0x8F49 #define GL_DOUBLE_MAT2x4 0x8F4A #define GL_DOUBLE_MAT3x2 0x8F4B #define GL_DOUBLE_MAT3x4 0x8F4C #define GL_DOUBLE_MAT4x2 0x8F4D #define GL_DOUBLE_MAT4x3 0x8F4E #define GL_DOUBLE_VEC2 0x8FFC #define GL_DOUBLE_VEC3 0x8FFD #define GL_DOUBLE_VEC4 0x8FFE typedef void (GLAPIENTRY * PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); typedef void (GLAPIENTRY * PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); #define glGetUniformdv GLEW_GET_FUN(__glewGetUniformdv) #define glProgramUniform1dEXT GLEW_GET_FUN(__glewProgramUniform1dEXT) #define glProgramUniform1dvEXT GLEW_GET_FUN(__glewProgramUniform1dvEXT) #define glProgramUniform2dEXT GLEW_GET_FUN(__glewProgramUniform2dEXT) #define glProgramUniform2dvEXT GLEW_GET_FUN(__glewProgramUniform2dvEXT) #define glProgramUniform3dEXT GLEW_GET_FUN(__glewProgramUniform3dEXT) #define glProgramUniform3dvEXT GLEW_GET_FUN(__glewProgramUniform3dvEXT) #define glProgramUniform4dEXT GLEW_GET_FUN(__glewProgramUniform4dEXT) #define glProgramUniform4dvEXT GLEW_GET_FUN(__glewProgramUniform4dvEXT) #define glProgramUniformMatrix2dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2dvEXT) #define glProgramUniformMatrix2x3dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3dvEXT) #define glProgramUniformMatrix2x4dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4dvEXT) #define glProgramUniformMatrix3dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3dvEXT) #define glProgramUniformMatrix3x2dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2dvEXT) #define glProgramUniformMatrix3x4dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4dvEXT) #define glProgramUniformMatrix4dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4dvEXT) #define glProgramUniformMatrix4x2dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2dvEXT) #define glProgramUniformMatrix4x3dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3dvEXT) #define glUniform1d GLEW_GET_FUN(__glewUniform1d) #define glUniform1dv GLEW_GET_FUN(__glewUniform1dv) #define glUniform2d GLEW_GET_FUN(__glewUniform2d) #define glUniform2dv GLEW_GET_FUN(__glewUniform2dv) #define glUniform3d GLEW_GET_FUN(__glewUniform3d) #define glUniform3dv GLEW_GET_FUN(__glewUniform3dv) #define glUniform4d GLEW_GET_FUN(__glewUniform4d) #define glUniform4dv GLEW_GET_FUN(__glewUniform4dv) #define glUniformMatrix2dv GLEW_GET_FUN(__glewUniformMatrix2dv) #define glUniformMatrix2x3dv GLEW_GET_FUN(__glewUniformMatrix2x3dv) #define glUniformMatrix2x4dv GLEW_GET_FUN(__glewUniformMatrix2x4dv) #define glUniformMatrix3dv GLEW_GET_FUN(__glewUniformMatrix3dv) #define glUniformMatrix3x2dv GLEW_GET_FUN(__glewUniformMatrix3x2dv) #define glUniformMatrix3x4dv GLEW_GET_FUN(__glewUniformMatrix3x4dv) #define glUniformMatrix4dv GLEW_GET_FUN(__glewUniformMatrix4dv) #define glUniformMatrix4x2dv GLEW_GET_FUN(__glewUniformMatrix4x2dv) #define glUniformMatrix4x3dv GLEW_GET_FUN(__glewUniformMatrix4x3dv) #define GLEW_ARB_gpu_shader_fp64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_fp64) #endif /* GL_ARB_gpu_shader_fp64 */ /* ------------------------ GL_ARB_half_float_pixel ------------------------ */ #ifndef GL_ARB_half_float_pixel #define GL_ARB_half_float_pixel 1 #define GL_HALF_FLOAT_ARB 0x140B #define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel) #endif /* GL_ARB_half_float_pixel */ /* ------------------------ GL_ARB_half_float_vertex ----------------------- */ #ifndef GL_ARB_half_float_vertex #define GL_ARB_half_float_vertex 1 #define GL_HALF_FLOAT 0x140B #define GLEW_ARB_half_float_vertex GLEW_GET_VAR(__GLEW_ARB_half_float_vertex) #endif /* GL_ARB_half_float_vertex */ /* ----------------------------- GL_ARB_imaging ---------------------------- */ #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_BLEND_COLOR 0x8005 #define GL_FUNC_ADD 0x8006 #define GL_MIN 0x8007 #define GL_MAX 0x8008 #define GL_BLEND_EQUATION 0x8009 #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 #define GL_CONVOLUTION_BORDER_MODE 0x8013 #define GL_CONVOLUTION_FILTER_SCALE 0x8014 #define GL_CONVOLUTION_FILTER_BIAS 0x8015 #define GL_REDUCE 0x8016 #define GL_CONVOLUTION_FORMAT 0x8017 #define GL_CONVOLUTION_WIDTH 0x8018 #define GL_CONVOLUTION_HEIGHT 0x8019 #define GL_MAX_CONVOLUTION_WIDTH 0x801A #define GL_MAX_CONVOLUTION_HEIGHT 0x801B #define GL_POST_CONVOLUTION_RED_SCALE 0x801C #define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D #define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E #define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F #define GL_POST_CONVOLUTION_RED_BIAS 0x8020 #define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 #define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 #define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 #define GL_HISTOGRAM 0x8024 #define GL_PROXY_HISTOGRAM 0x8025 #define GL_HISTOGRAM_WIDTH 0x8026 #define GL_HISTOGRAM_FORMAT 0x8027 #define GL_HISTOGRAM_RED_SIZE 0x8028 #define GL_HISTOGRAM_GREEN_SIZE 0x8029 #define GL_HISTOGRAM_BLUE_SIZE 0x802A #define GL_HISTOGRAM_ALPHA_SIZE 0x802B #define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C #define GL_HISTOGRAM_SINK 0x802D #define GL_MINMAX 0x802E #define GL_MINMAX_FORMAT 0x802F #define GL_MINMAX_SINK 0x8030 #define GL_TABLE_TOO_LARGE 0x8031 #define GL_COLOR_MATRIX 0x80B1 #define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 #define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 #define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 #define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 #define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 #define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 #define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 #define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 #define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA #define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB #define GL_COLOR_TABLE 0x80D0 #define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 #define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 #define GL_PROXY_COLOR_TABLE 0x80D3 #define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 #define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 #define GL_COLOR_TABLE_SCALE 0x80D6 #define GL_COLOR_TABLE_BIAS 0x80D7 #define GL_COLOR_TABLE_FORMAT 0x80D8 #define GL_COLOR_TABLE_WIDTH 0x80D9 #define GL_COLOR_TABLE_RED_SIZE 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF #define GL_IGNORE_BORDER 0x8150 #define GL_CONSTANT_BORDER 0x8151 #define GL_WRAP_BORDER 0x8152 #define GL_REPLICATE_BORDER 0x8153 #define GL_CONVOLUTION_BORDER_COLOR 0x8154 typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); typedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values); typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); typedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); typedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); #define glColorSubTable GLEW_GET_FUN(__glewColorSubTable) #define glColorTable GLEW_GET_FUN(__glewColorTable) #define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv) #define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv) #define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D) #define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D) #define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf) #define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv) #define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri) #define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv) #define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable) #define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable) #define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D) #define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D) #define glGetColorTable GLEW_GET_FUN(__glewGetColorTable) #define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv) #define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv) #define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter) #define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv) #define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv) #define glGetHistogram GLEW_GET_FUN(__glewGetHistogram) #define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv) #define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv) #define glGetMinmax GLEW_GET_FUN(__glewGetMinmax) #define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv) #define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv) #define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter) #define glHistogram GLEW_GET_FUN(__glewHistogram) #define glMinmax GLEW_GET_FUN(__glewMinmax) #define glResetHistogram GLEW_GET_FUN(__glewResetHistogram) #define glResetMinmax GLEW_GET_FUN(__glewResetMinmax) #define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D) #define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging) #endif /* GL_ARB_imaging */ /* ------------------------ GL_ARB_instanced_arrays ------------------------ */ #ifndef GL_ARB_instanced_arrays #define GL_ARB_instanced_arrays 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); #define glDrawArraysInstancedARB GLEW_GET_FUN(__glewDrawArraysInstancedARB) #define glDrawElementsInstancedARB GLEW_GET_FUN(__glewDrawElementsInstancedARB) #define glVertexAttribDivisorARB GLEW_GET_FUN(__glewVertexAttribDivisorARB) #define GLEW_ARB_instanced_arrays GLEW_GET_VAR(__GLEW_ARB_instanced_arrays) #endif /* GL_ARB_instanced_arrays */ /* ---------------------- GL_ARB_internalformat_query ---------------------- */ #ifndef GL_ARB_internalformat_query #define GL_ARB_internalformat_query 1 #define GL_NUM_SAMPLE_COUNTS 0x9380 typedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params); #define glGetInternalformativ GLEW_GET_FUN(__glewGetInternalformativ) #define GLEW_ARB_internalformat_query GLEW_GET_VAR(__GLEW_ARB_internalformat_query) #endif /* GL_ARB_internalformat_query */ /* ---------------------- GL_ARB_map_buffer_alignment ---------------------- */ #ifndef GL_ARB_map_buffer_alignment #define GL_ARB_map_buffer_alignment 1 #define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC #define GLEW_ARB_map_buffer_alignment GLEW_GET_VAR(__GLEW_ARB_map_buffer_alignment) #endif /* GL_ARB_map_buffer_alignment */ /* ------------------------ GL_ARB_map_buffer_range ------------------------ */ #ifndef GL_ARB_map_buffer_range #define GL_ARB_map_buffer_range 1 #define GL_MAP_READ_BIT 0x0001 #define GL_MAP_WRITE_BIT 0x0002 #define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 #define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 #define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 #define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); #define glFlushMappedBufferRange GLEW_GET_FUN(__glewFlushMappedBufferRange) #define glMapBufferRange GLEW_GET_FUN(__glewMapBufferRange) #define GLEW_ARB_map_buffer_range GLEW_GET_VAR(__GLEW_ARB_map_buffer_range) #endif /* GL_ARB_map_buffer_range */ /* ------------------------- GL_ARB_matrix_palette ------------------------- */ #ifndef GL_ARB_matrix_palette #define GL_ARB_matrix_palette 1 #define GL_MATRIX_PALETTE_ARB 0x8840 #define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 #define GL_MAX_PALETTE_MATRICES_ARB 0x8842 #define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 #define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 #define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 #define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 #define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 #define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 #define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 typedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); typedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices); typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices); typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices); #define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB) #define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB) #define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB) #define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB) #define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB) #define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette) #endif /* GL_ARB_matrix_palette */ /* --------------------------- GL_ARB_multisample -------------------------- */ #ifndef GL_ARB_multisample #define GL_ARB_multisample 1 #define GL_MULTISAMPLE_ARB 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F #define GL_SAMPLE_COVERAGE_ARB 0x80A0 #define GL_SAMPLE_BUFFERS_ARB 0x80A8 #define GL_SAMPLES_ARB 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA #define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB #define GL_MULTISAMPLE_BIT_ARB 0x20000000 typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); #define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB) #define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample) #endif /* GL_ARB_multisample */ /* -------------------------- GL_ARB_multitexture -------------------------- */ #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 #define GL_TEXTURE2_ARB 0x84C2 #define GL_TEXTURE3_ARB 0x84C3 #define GL_TEXTURE4_ARB 0x84C4 #define GL_TEXTURE5_ARB 0x84C5 #define GL_TEXTURE6_ARB 0x84C6 #define GL_TEXTURE7_ARB 0x84C7 #define GL_TEXTURE8_ARB 0x84C8 #define GL_TEXTURE9_ARB 0x84C9 #define GL_TEXTURE10_ARB 0x84CA #define GL_TEXTURE11_ARB 0x84CB #define GL_TEXTURE12_ARB 0x84CC #define GL_TEXTURE13_ARB 0x84CD #define GL_TEXTURE14_ARB 0x84CE #define GL_TEXTURE15_ARB 0x84CF #define GL_TEXTURE16_ARB 0x84D0 #define GL_TEXTURE17_ARB 0x84D1 #define GL_TEXTURE18_ARB 0x84D2 #define GL_TEXTURE19_ARB 0x84D3 #define GL_TEXTURE20_ARB 0x84D4 #define GL_TEXTURE21_ARB 0x84D5 #define GL_TEXTURE22_ARB 0x84D6 #define GL_TEXTURE23_ARB 0x84D7 #define GL_TEXTURE24_ARB 0x84D8 #define GL_TEXTURE25_ARB 0x84D9 #define GL_TEXTURE26_ARB 0x84DA #define GL_TEXTURE27_ARB 0x84DB #define GL_TEXTURE28_ARB 0x84DC #define GL_TEXTURE29_ARB 0x84DD #define GL_TEXTURE30_ARB 0x84DE #define GL_TEXTURE31_ARB 0x84DF #define GL_ACTIVE_TEXTURE_ARB 0x84E0 #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB) #define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB) #define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB) #define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB) #define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB) #define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB) #define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB) #define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB) #define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB) #define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB) #define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB) #define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB) #define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB) #define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB) #define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB) #define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB) #define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB) #define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB) #define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB) #define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB) #define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB) #define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB) #define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB) #define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB) #define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB) #define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB) #define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB) #define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB) #define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB) #define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB) #define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB) #define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB) #define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB) #define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB) #define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture) #endif /* GL_ARB_multitexture */ /* ------------------------- GL_ARB_occlusion_query ------------------------ */ #ifndef GL_ARB_occlusion_query #define GL_ARB_occlusion_query 1 #define GL_QUERY_COUNTER_BITS_ARB 0x8864 #define GL_CURRENT_QUERY_ARB 0x8865 #define GL_QUERY_RESULT_ARB 0x8866 #define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 #define GL_SAMPLES_PASSED_ARB 0x8914 typedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); #define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB) #define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB) #define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB) #define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB) #define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB) #define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB) #define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB) #define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB) #define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query) #endif /* GL_ARB_occlusion_query */ /* ------------------------ GL_ARB_occlusion_query2 ------------------------ */ #ifndef GL_ARB_occlusion_query2 #define GL_ARB_occlusion_query2 1 #define GL_ANY_SAMPLES_PASSED 0x8C2F #define GLEW_ARB_occlusion_query2 GLEW_GET_VAR(__GLEW_ARB_occlusion_query2) #endif /* GL_ARB_occlusion_query2 */ /* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ #ifndef GL_ARB_pixel_buffer_object #define GL_ARB_pixel_buffer_object 1 #define GL_PIXEL_PACK_BUFFER_ARB 0x88EB #define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF #define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object) #endif /* GL_ARB_pixel_buffer_object */ /* ------------------------ GL_ARB_point_parameters ------------------------ */ #ifndef GL_ARB_point_parameters #define GL_ARB_point_parameters 1 #define GL_POINT_SIZE_MIN_ARB 0x8126 #define GL_POINT_SIZE_MAX_ARB 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 #define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat* params); #define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB) #define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB) #define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters) #endif /* GL_ARB_point_parameters */ /* -------------------------- GL_ARB_point_sprite -------------------------- */ #ifndef GL_ARB_point_sprite #define GL_ARB_point_sprite 1 #define GL_POINT_SPRITE_ARB 0x8861 #define GL_COORD_REPLACE_ARB 0x8862 #define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite) #endif /* GL_ARB_point_sprite */ /* ------------------------ GL_ARB_provoking_vertex ------------------------ */ #ifndef GL_ARB_provoking_vertex #define GL_ARB_provoking_vertex 1 #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C #define GL_FIRST_VERTEX_CONVENTION 0x8E4D #define GL_LAST_VERTEX_CONVENTION 0x8E4E #define GL_PROVOKING_VERTEX 0x8E4F typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXPROC) (GLenum mode); #define glProvokingVertex GLEW_GET_FUN(__glewProvokingVertex) #define GLEW_ARB_provoking_vertex GLEW_GET_VAR(__GLEW_ARB_provoking_vertex) #endif /* GL_ARB_provoking_vertex */ /* --------------------------- GL_ARB_robustness --------------------------- */ #ifndef GL_ARB_robustness #define GL_ARB_robustness 1 #define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 #define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 #define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 #define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 #define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 #define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 #define GL_NO_RESET_NOTIFICATION_ARB 0x8261 typedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); typedef void (GLAPIENTRY * PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* table); typedef void (GLAPIENTRY * PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void* img); typedef void (GLAPIENTRY * PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* image); typedef void (GLAPIENTRY * PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values); typedef void (GLAPIENTRY * PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble* v); typedef void (GLAPIENTRY * PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat* v); typedef void (GLAPIENTRY * PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint* v); typedef void (GLAPIENTRY * PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values); typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat* values); typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint* values); typedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort* values); typedef void (GLAPIENTRY * PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte* pattern); typedef void (GLAPIENTRY * PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void* row, GLsizei columnBufSize, GLvoid*column, GLvoid*span); typedef void (GLAPIENTRY * PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* img); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params); typedef void (GLAPIENTRY * PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void* data); #define glGetGraphicsResetStatusARB GLEW_GET_FUN(__glewGetGraphicsResetStatusARB) #define glGetnColorTableARB GLEW_GET_FUN(__glewGetnColorTableARB) #define glGetnCompressedTexImageARB GLEW_GET_FUN(__glewGetnCompressedTexImageARB) #define glGetnConvolutionFilterARB GLEW_GET_FUN(__glewGetnConvolutionFilterARB) #define glGetnHistogramARB GLEW_GET_FUN(__glewGetnHistogramARB) #define glGetnMapdvARB GLEW_GET_FUN(__glewGetnMapdvARB) #define glGetnMapfvARB GLEW_GET_FUN(__glewGetnMapfvARB) #define glGetnMapivARB GLEW_GET_FUN(__glewGetnMapivARB) #define glGetnMinmaxARB GLEW_GET_FUN(__glewGetnMinmaxARB) #define glGetnPixelMapfvARB GLEW_GET_FUN(__glewGetnPixelMapfvARB) #define glGetnPixelMapuivARB GLEW_GET_FUN(__glewGetnPixelMapuivARB) #define glGetnPixelMapusvARB GLEW_GET_FUN(__glewGetnPixelMapusvARB) #define glGetnPolygonStippleARB GLEW_GET_FUN(__glewGetnPolygonStippleARB) #define glGetnSeparableFilterARB GLEW_GET_FUN(__glewGetnSeparableFilterARB) #define glGetnTexImageARB GLEW_GET_FUN(__glewGetnTexImageARB) #define glGetnUniformdvARB GLEW_GET_FUN(__glewGetnUniformdvARB) #define glGetnUniformfvARB GLEW_GET_FUN(__glewGetnUniformfvARB) #define glGetnUniformivARB GLEW_GET_FUN(__glewGetnUniformivARB) #define glGetnUniformuivARB GLEW_GET_FUN(__glewGetnUniformuivARB) #define glReadnPixelsARB GLEW_GET_FUN(__glewReadnPixelsARB) #define GLEW_ARB_robustness GLEW_GET_VAR(__GLEW_ARB_robustness) #endif /* GL_ARB_robustness */ /* ------------------------- GL_ARB_sample_shading ------------------------- */ #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 #define GL_SAMPLE_SHADING_ARB 0x8C36 #define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); #define glMinSampleShadingARB GLEW_GET_FUN(__glewMinSampleShadingARB) #define GLEW_ARB_sample_shading GLEW_GET_VAR(__GLEW_ARB_sample_shading) #endif /* GL_ARB_sample_shading */ /* ------------------------- GL_ARB_sampler_objects ------------------------ */ #ifndef GL_ARB_sampler_objects #define GL_ARB_sampler_objects 1 #define GL_SAMPLER_BINDING 0x8919 typedef void (GLAPIENTRY * PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); typedef void (GLAPIENTRY * PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint * samplers); typedef void (GLAPIENTRY * PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint* samplers); typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISSAMPLERPROC) (GLuint sampler); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint* params); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint* params); #define glBindSampler GLEW_GET_FUN(__glewBindSampler) #define glDeleteSamplers GLEW_GET_FUN(__glewDeleteSamplers) #define glGenSamplers GLEW_GET_FUN(__glewGenSamplers) #define glGetSamplerParameterIiv GLEW_GET_FUN(__glewGetSamplerParameterIiv) #define glGetSamplerParameterIuiv GLEW_GET_FUN(__glewGetSamplerParameterIuiv) #define glGetSamplerParameterfv GLEW_GET_FUN(__glewGetSamplerParameterfv) #define glGetSamplerParameteriv GLEW_GET_FUN(__glewGetSamplerParameteriv) #define glIsSampler GLEW_GET_FUN(__glewIsSampler) #define glSamplerParameterIiv GLEW_GET_FUN(__glewSamplerParameterIiv) #define glSamplerParameterIuiv GLEW_GET_FUN(__glewSamplerParameterIuiv) #define glSamplerParameterf GLEW_GET_FUN(__glewSamplerParameterf) #define glSamplerParameterfv GLEW_GET_FUN(__glewSamplerParameterfv) #define glSamplerParameteri GLEW_GET_FUN(__glewSamplerParameteri) #define glSamplerParameteriv GLEW_GET_FUN(__glewSamplerParameteriv) #define GLEW_ARB_sampler_objects GLEW_GET_VAR(__GLEW_ARB_sampler_objects) #endif /* GL_ARB_sampler_objects */ /* ------------------------ GL_ARB_seamless_cube_map ----------------------- */ #ifndef GL_ARB_seamless_cube_map #define GL_ARB_seamless_cube_map 1 #define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F #define GLEW_ARB_seamless_cube_map GLEW_GET_VAR(__GLEW_ARB_seamless_cube_map) #endif /* GL_ARB_seamless_cube_map */ /* --------------------- GL_ARB_separate_shader_objects -------------------- */ #ifndef GL_ARB_separate_shader_objects #define GL_ARB_separate_shader_objects 1 #define GL_VERTEX_SHADER_BIT 0x00000001 #define GL_FRAGMENT_SHADER_BIT 0x00000002 #define GL_GEOMETRY_SHADER_BIT 0x00000004 #define GL_TESS_CONTROL_SHADER_BIT 0x00000008 #define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 #define GL_PROGRAM_SEPARABLE 0x8258 #define GL_ACTIVE_PROGRAM 0x8259 #define GL_PROGRAM_PIPELINE_BINDING 0x825A #define GL_ALL_SHADER_BITS 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); typedef void (GLAPIENTRY * PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const char ** strings); typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint* pipelines); typedef void (GLAPIENTRY * PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines); typedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei* length, char *infoLog); typedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint x, GLuint y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); #define glActiveShaderProgram GLEW_GET_FUN(__glewActiveShaderProgram) #define glBindProgramPipeline GLEW_GET_FUN(__glewBindProgramPipeline) #define glCreateShaderProgramv GLEW_GET_FUN(__glewCreateShaderProgramv) #define glDeleteProgramPipelines GLEW_GET_FUN(__glewDeleteProgramPipelines) #define glGenProgramPipelines GLEW_GET_FUN(__glewGenProgramPipelines) #define glGetProgramPipelineInfoLog GLEW_GET_FUN(__glewGetProgramPipelineInfoLog) #define glGetProgramPipelineiv GLEW_GET_FUN(__glewGetProgramPipelineiv) #define glIsProgramPipeline GLEW_GET_FUN(__glewIsProgramPipeline) #define glProgramUniform1d GLEW_GET_FUN(__glewProgramUniform1d) #define glProgramUniform1dv GLEW_GET_FUN(__glewProgramUniform1dv) #define glProgramUniform1f GLEW_GET_FUN(__glewProgramUniform1f) #define glProgramUniform1fv GLEW_GET_FUN(__glewProgramUniform1fv) #define glProgramUniform1i GLEW_GET_FUN(__glewProgramUniform1i) #define glProgramUniform1iv GLEW_GET_FUN(__glewProgramUniform1iv) #define glProgramUniform1ui GLEW_GET_FUN(__glewProgramUniform1ui) #define glProgramUniform1uiv GLEW_GET_FUN(__glewProgramUniform1uiv) #define glProgramUniform2d GLEW_GET_FUN(__glewProgramUniform2d) #define glProgramUniform2dv GLEW_GET_FUN(__glewProgramUniform2dv) #define glProgramUniform2f GLEW_GET_FUN(__glewProgramUniform2f) #define glProgramUniform2fv GLEW_GET_FUN(__glewProgramUniform2fv) #define glProgramUniform2i GLEW_GET_FUN(__glewProgramUniform2i) #define glProgramUniform2iv GLEW_GET_FUN(__glewProgramUniform2iv) #define glProgramUniform2ui GLEW_GET_FUN(__glewProgramUniform2ui) #define glProgramUniform2uiv GLEW_GET_FUN(__glewProgramUniform2uiv) #define glProgramUniform3d GLEW_GET_FUN(__glewProgramUniform3d) #define glProgramUniform3dv GLEW_GET_FUN(__glewProgramUniform3dv) #define glProgramUniform3f GLEW_GET_FUN(__glewProgramUniform3f) #define glProgramUniform3fv GLEW_GET_FUN(__glewProgramUniform3fv) #define glProgramUniform3i GLEW_GET_FUN(__glewProgramUniform3i) #define glProgramUniform3iv GLEW_GET_FUN(__glewProgramUniform3iv) #define glProgramUniform3ui GLEW_GET_FUN(__glewProgramUniform3ui) #define glProgramUniform3uiv GLEW_GET_FUN(__glewProgramUniform3uiv) #define glProgramUniform4d GLEW_GET_FUN(__glewProgramUniform4d) #define glProgramUniform4dv GLEW_GET_FUN(__glewProgramUniform4dv) #define glProgramUniform4f GLEW_GET_FUN(__glewProgramUniform4f) #define glProgramUniform4fv GLEW_GET_FUN(__glewProgramUniform4fv) #define glProgramUniform4i GLEW_GET_FUN(__glewProgramUniform4i) #define glProgramUniform4iv GLEW_GET_FUN(__glewProgramUniform4iv) #define glProgramUniform4ui GLEW_GET_FUN(__glewProgramUniform4ui) #define glProgramUniform4uiv GLEW_GET_FUN(__glewProgramUniform4uiv) #define glProgramUniformMatrix2dv GLEW_GET_FUN(__glewProgramUniformMatrix2dv) #define glProgramUniformMatrix2fv GLEW_GET_FUN(__glewProgramUniformMatrix2fv) #define glProgramUniformMatrix2x3dv GLEW_GET_FUN(__glewProgramUniformMatrix2x3dv) #define glProgramUniformMatrix2x3fv GLEW_GET_FUN(__glewProgramUniformMatrix2x3fv) #define glProgramUniformMatrix2x4dv GLEW_GET_FUN(__glewProgramUniformMatrix2x4dv) #define glProgramUniformMatrix2x4fv GLEW_GET_FUN(__glewProgramUniformMatrix2x4fv) #define glProgramUniformMatrix3dv GLEW_GET_FUN(__glewProgramUniformMatrix3dv) #define glProgramUniformMatrix3fv GLEW_GET_FUN(__glewProgramUniformMatrix3fv) #define glProgramUniformMatrix3x2dv GLEW_GET_FUN(__glewProgramUniformMatrix3x2dv) #define glProgramUniformMatrix3x2fv GLEW_GET_FUN(__glewProgramUniformMatrix3x2fv) #define glProgramUniformMatrix3x4dv GLEW_GET_FUN(__glewProgramUniformMatrix3x4dv) #define glProgramUniformMatrix3x4fv GLEW_GET_FUN(__glewProgramUniformMatrix3x4fv) #define glProgramUniformMatrix4dv GLEW_GET_FUN(__glewProgramUniformMatrix4dv) #define glProgramUniformMatrix4fv GLEW_GET_FUN(__glewProgramUniformMatrix4fv) #define glProgramUniformMatrix4x2dv GLEW_GET_FUN(__glewProgramUniformMatrix4x2dv) #define glProgramUniformMatrix4x2fv GLEW_GET_FUN(__glewProgramUniformMatrix4x2fv) #define glProgramUniformMatrix4x3dv GLEW_GET_FUN(__glewProgramUniformMatrix4x3dv) #define glProgramUniformMatrix4x3fv GLEW_GET_FUN(__glewProgramUniformMatrix4x3fv) #define glUseProgramStages GLEW_GET_FUN(__glewUseProgramStages) #define glValidateProgramPipeline GLEW_GET_FUN(__glewValidateProgramPipeline) #define GLEW_ARB_separate_shader_objects GLEW_GET_VAR(__GLEW_ARB_separate_shader_objects) #endif /* GL_ARB_separate_shader_objects */ /* --------------------- GL_ARB_shader_atomic_counters --------------------- */ #ifndef GL_ARB_shader_atomic_counters #define GL_ARB_shader_atomic_counters 1 #define GL_ATOMIC_COUNTER_BUFFER 0x92C0 #define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 #define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 #define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 #define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 #define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 #define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB #define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE #define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF #define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 #define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 #define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 #define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 #define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 #define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 #define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 #define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 #define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA #define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB #define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC typedef void (GLAPIENTRY * PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint* params); #define glGetActiveAtomicCounterBufferiv GLEW_GET_FUN(__glewGetActiveAtomicCounterBufferiv) #define GLEW_ARB_shader_atomic_counters GLEW_GET_VAR(__GLEW_ARB_shader_atomic_counters) #endif /* GL_ARB_shader_atomic_counters */ /* ----------------------- GL_ARB_shader_bit_encoding ---------------------- */ #ifndef GL_ARB_shader_bit_encoding #define GL_ARB_shader_bit_encoding 1 #define GLEW_ARB_shader_bit_encoding GLEW_GET_VAR(__GLEW_ARB_shader_bit_encoding) #endif /* GL_ARB_shader_bit_encoding */ /* --------------------- GL_ARB_shader_image_load_store -------------------- */ #ifndef GL_ARB_shader_image_load_store #define GL_ARB_shader_image_load_store 1 #define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 #define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 #define GL_UNIFORM_BARRIER_BIT 0x00000004 #define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 #define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 #define GL_COMMAND_BARRIER_BIT 0x00000040 #define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 #define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 #define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 #define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 #define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 #define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 #define GL_MAX_IMAGE_UNITS 0x8F38 #define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 #define GL_IMAGE_BINDING_NAME 0x8F3A #define GL_IMAGE_BINDING_LEVEL 0x8F3B #define GL_IMAGE_BINDING_LAYERED 0x8F3C #define GL_IMAGE_BINDING_LAYER 0x8F3D #define GL_IMAGE_BINDING_ACCESS 0x8F3E #define GL_IMAGE_1D 0x904C #define GL_IMAGE_2D 0x904D #define GL_IMAGE_3D 0x904E #define GL_IMAGE_2D_RECT 0x904F #define GL_IMAGE_CUBE 0x9050 #define GL_IMAGE_BUFFER 0x9051 #define GL_IMAGE_1D_ARRAY 0x9052 #define GL_IMAGE_2D_ARRAY 0x9053 #define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 #define GL_IMAGE_2D_MULTISAMPLE 0x9055 #define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 #define GL_INT_IMAGE_1D 0x9057 #define GL_INT_IMAGE_2D 0x9058 #define GL_INT_IMAGE_3D 0x9059 #define GL_INT_IMAGE_2D_RECT 0x905A #define GL_INT_IMAGE_CUBE 0x905B #define GL_INT_IMAGE_BUFFER 0x905C #define GL_INT_IMAGE_1D_ARRAY 0x905D #define GL_INT_IMAGE_2D_ARRAY 0x905E #define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F #define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 #define GL_UNSIGNED_INT_IMAGE_1D 0x9062 #define GL_UNSIGNED_INT_IMAGE_2D 0x9063 #define GL_UNSIGNED_INT_IMAGE_3D 0x9064 #define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 #define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 #define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C #define GL_MAX_IMAGE_SAMPLES 0x906D #define GL_IMAGE_BINDING_FORMAT 0x906E #define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 #define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 #define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 #define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA #define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB #define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC #define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD #define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE #define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF #define GL_ALL_BARRIER_BITS 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); typedef void (GLAPIENTRY * PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); #define glBindImageTexture GLEW_GET_FUN(__glewBindImageTexture) #define glMemoryBarrier GLEW_GET_FUN(__glewMemoryBarrier) #define GLEW_ARB_shader_image_load_store GLEW_GET_VAR(__GLEW_ARB_shader_image_load_store) #endif /* GL_ARB_shader_image_load_store */ /* ------------------------- GL_ARB_shader_objects ------------------------- */ #ifndef GL_ARB_shader_objects #define GL_ARB_shader_objects 1 #define GL_PROGRAM_OBJECT_ARB 0x8B40 #define GL_SHADER_OBJECT_ARB 0x8B48 #define GL_OBJECT_TYPE_ARB 0x8B4E #define GL_OBJECT_SUBTYPE_ARB 0x8B4F #define GL_FLOAT_VEC2_ARB 0x8B50 #define GL_FLOAT_VEC3_ARB 0x8B51 #define GL_FLOAT_VEC4_ARB 0x8B52 #define GL_INT_VEC2_ARB 0x8B53 #define GL_INT_VEC3_ARB 0x8B54 #define GL_INT_VEC4_ARB 0x8B55 #define GL_BOOL_ARB 0x8B56 #define GL_BOOL_VEC2_ARB 0x8B57 #define GL_BOOL_VEC3_ARB 0x8B58 #define GL_BOOL_VEC4_ARB 0x8B59 #define GL_FLOAT_MAT2_ARB 0x8B5A #define GL_FLOAT_MAT3_ARB 0x8B5B #define GL_FLOAT_MAT4_ARB 0x8B5C #define GL_SAMPLER_1D_ARB 0x8B5D #define GL_SAMPLER_2D_ARB 0x8B5E #define GL_SAMPLER_3D_ARB 0x8B5F #define GL_SAMPLER_CUBE_ARB 0x8B60 #define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 #define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 #define GL_SAMPLER_2D_RECT_ARB 0x8B63 #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 #define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 #define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 #define GL_OBJECT_LINK_STATUS_ARB 0x8B82 #define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 #define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 #define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 #define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 #define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 #define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 typedef char GLcharARB; typedef unsigned int GLhandleARB; typedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); typedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); typedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); typedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); typedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); typedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); typedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj); typedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); typedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog); typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source); typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params); typedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); typedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length); typedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); #define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB) #define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB) #define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB) #define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB) #define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB) #define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB) #define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB) #define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB) #define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB) #define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB) #define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB) #define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB) #define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB) #define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB) #define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB) #define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB) #define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB) #define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB) #define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB) #define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB) #define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB) #define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB) #define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB) #define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB) #define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB) #define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB) #define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB) #define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB) #define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB) #define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB) #define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB) #define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB) #define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB) #define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB) #define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB) #define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB) #define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB) #define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB) #define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB) #define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects) #endif /* GL_ARB_shader_objects */ /* ------------------------ GL_ARB_shader_precision ------------------------ */ #ifndef GL_ARB_shader_precision #define GL_ARB_shader_precision 1 #define GLEW_ARB_shader_precision GLEW_GET_VAR(__GLEW_ARB_shader_precision) #endif /* GL_ARB_shader_precision */ /* ---------------------- GL_ARB_shader_stencil_export --------------------- */ #ifndef GL_ARB_shader_stencil_export #define GL_ARB_shader_stencil_export 1 #define GLEW_ARB_shader_stencil_export GLEW_GET_VAR(__GLEW_ARB_shader_stencil_export) #endif /* GL_ARB_shader_stencil_export */ /* ------------------------ GL_ARB_shader_subroutine ----------------------- */ #ifndef GL_ARB_shader_subroutine #define GL_ARB_shader_subroutine 1 #define GL_ACTIVE_SUBROUTINES 0x8DE5 #define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 #define GL_MAX_SUBROUTINES 0x8DE7 #define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 #define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 #define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 #define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 #define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A #define GL_COMPATIBLE_SUBROUTINES 0x8E4B typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, char *name); typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, char *name); typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint* values); typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint* values); typedef GLuint (GLAPIENTRY * PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const char* name); typedef GLint (GLAPIENTRY * PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const char* name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint* params); typedef void (GLAPIENTRY * PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint* indices); #define glGetActiveSubroutineName GLEW_GET_FUN(__glewGetActiveSubroutineName) #define glGetActiveSubroutineUniformName GLEW_GET_FUN(__glewGetActiveSubroutineUniformName) #define glGetActiveSubroutineUniformiv GLEW_GET_FUN(__glewGetActiveSubroutineUniformiv) #define glGetProgramStageiv GLEW_GET_FUN(__glewGetProgramStageiv) #define glGetSubroutineIndex GLEW_GET_FUN(__glewGetSubroutineIndex) #define glGetSubroutineUniformLocation GLEW_GET_FUN(__glewGetSubroutineUniformLocation) #define glGetUniformSubroutineuiv GLEW_GET_FUN(__glewGetUniformSubroutineuiv) #define glUniformSubroutinesuiv GLEW_GET_FUN(__glewUniformSubroutinesuiv) #define GLEW_ARB_shader_subroutine GLEW_GET_VAR(__GLEW_ARB_shader_subroutine) #endif /* GL_ARB_shader_subroutine */ /* ----------------------- GL_ARB_shader_texture_lod ----------------------- */ #ifndef GL_ARB_shader_texture_lod #define GL_ARB_shader_texture_lod 1 #define GLEW_ARB_shader_texture_lod GLEW_GET_VAR(__GLEW_ARB_shader_texture_lod) #endif /* GL_ARB_shader_texture_lod */ /* ---------------------- GL_ARB_shading_language_100 ---------------------- */ #ifndef GL_ARB_shading_language_100 #define GL_ARB_shading_language_100 1 #define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C #define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100) #endif /* GL_ARB_shading_language_100 */ /* -------------------- GL_ARB_shading_language_420pack -------------------- */ #ifndef GL_ARB_shading_language_420pack #define GL_ARB_shading_language_420pack 1 #define GLEW_ARB_shading_language_420pack GLEW_GET_VAR(__GLEW_ARB_shading_language_420pack) #endif /* GL_ARB_shading_language_420pack */ /* -------------------- GL_ARB_shading_language_include -------------------- */ #ifndef GL_ARB_shading_language_include #define GL_ARB_shading_language_include 1 #define GL_SHADER_INCLUDE_ARB 0x8DAE #define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 #define GL_NAMED_STRING_TYPE_ARB 0x8DEA typedef void (GLAPIENTRY * PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const char ** path, const GLint *length); typedef void (GLAPIENTRY * PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const char* name); typedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const char* name, GLsizei bufSize, GLint *stringlen, char *string); typedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const char* name, GLenum pname, GLint *params); typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const char* name); typedef void (GLAPIENTRY * PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const char* name, GLint stringlen, const char *string); #define glCompileShaderIncludeARB GLEW_GET_FUN(__glewCompileShaderIncludeARB) #define glDeleteNamedStringARB GLEW_GET_FUN(__glewDeleteNamedStringARB) #define glGetNamedStringARB GLEW_GET_FUN(__glewGetNamedStringARB) #define glGetNamedStringivARB GLEW_GET_FUN(__glewGetNamedStringivARB) #define glIsNamedStringARB GLEW_GET_FUN(__glewIsNamedStringARB) #define glNamedStringARB GLEW_GET_FUN(__glewNamedStringARB) #define GLEW_ARB_shading_language_include GLEW_GET_VAR(__GLEW_ARB_shading_language_include) #endif /* GL_ARB_shading_language_include */ /* -------------------- GL_ARB_shading_language_packing -------------------- */ #ifndef GL_ARB_shading_language_packing #define GL_ARB_shading_language_packing 1 #define GLEW_ARB_shading_language_packing GLEW_GET_VAR(__GLEW_ARB_shading_language_packing) #endif /* GL_ARB_shading_language_packing */ /* ----------------------------- GL_ARB_shadow ----------------------------- */ #ifndef GL_ARB_shadow #define GL_ARB_shadow 1 #define GL_TEXTURE_COMPARE_MODE_ARB 0x884C #define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D #define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E #define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow) #endif /* GL_ARB_shadow */ /* ------------------------- GL_ARB_shadow_ambient ------------------------- */ #ifndef GL_ARB_shadow_ambient #define GL_ARB_shadow_ambient 1 #define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF #define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient) #endif /* GL_ARB_shadow_ambient */ /* ------------------------------ GL_ARB_sync ------------------------------ */ #ifndef GL_ARB_sync #define GL_ARB_sync 1 #define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 #define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 #define GL_OBJECT_TYPE 0x9112 #define GL_SYNC_CONDITION 0x9113 #define GL_SYNC_STATUS 0x9114 #define GL_SYNC_FLAGS 0x9115 #define GL_SYNC_FENCE 0x9116 #define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 #define GL_UNSIGNALED 0x9118 #define GL_SIGNALED 0x9119 #define GL_ALREADY_SIGNALED 0x911A #define GL_TIMEOUT_EXPIRED 0x911B #define GL_CONDITION_SATISFIED 0x911C #define GL_WAIT_FAILED 0x911D #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF typedef GLenum (GLAPIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout); typedef void (GLAPIENTRY * PFNGLDELETESYNCPROC) (GLsync GLsync); typedef GLsync (GLAPIENTRY * PFNGLFENCESYNCPROC) (GLenum condition,GLbitfield flags); typedef void (GLAPIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64* params); typedef void (GLAPIENTRY * PFNGLGETSYNCIVPROC) (GLsync GLsync,GLenum pname,GLsizei bufSize,GLsizei* length, GLint *values); typedef GLboolean (GLAPIENTRY * PFNGLISSYNCPROC) (GLsync GLsync); typedef void (GLAPIENTRY * PFNGLWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout); #define glClientWaitSync GLEW_GET_FUN(__glewClientWaitSync) #define glDeleteSync GLEW_GET_FUN(__glewDeleteSync) #define glFenceSync GLEW_GET_FUN(__glewFenceSync) #define glGetInteger64v GLEW_GET_FUN(__glewGetInteger64v) #define glGetSynciv GLEW_GET_FUN(__glewGetSynciv) #define glIsSync GLEW_GET_FUN(__glewIsSync) #define glWaitSync GLEW_GET_FUN(__glewWaitSync) #define GLEW_ARB_sync GLEW_GET_VAR(__GLEW_ARB_sync) #endif /* GL_ARB_sync */ /* ----------------------- GL_ARB_tessellation_shader ---------------------- */ #ifndef GL_ARB_tessellation_shader #define GL_ARB_tessellation_shader 1 #define GL_PATCHES 0xE #define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 #define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 #define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C #define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D #define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E #define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F #define GL_PATCH_VERTICES 0x8E72 #define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 #define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 #define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 #define GL_TESS_GEN_MODE 0x8E76 #define GL_TESS_GEN_SPACING 0x8E77 #define GL_TESS_GEN_VERTEX_ORDER 0x8E78 #define GL_TESS_GEN_POINT_MODE 0x8E79 #define GL_ISOLINES 0x8E7A #define GL_FRACTIONAL_ODD 0x8E7B #define GL_FRACTIONAL_EVEN 0x8E7C #define GL_MAX_PATCH_VERTICES 0x8E7D #define GL_MAX_TESS_GEN_LEVEL 0x8E7E #define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F #define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 #define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 #define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 #define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 #define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 #define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 #define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 #define GL_TESS_EVALUATION_SHADER 0x8E87 #define GL_TESS_CONTROL_SHADER 0x8E88 #define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 #define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat* values); typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); #define glPatchParameterfv GLEW_GET_FUN(__glewPatchParameterfv) #define glPatchParameteri GLEW_GET_FUN(__glewPatchParameteri) #define GLEW_ARB_tessellation_shader GLEW_GET_VAR(__GLEW_ARB_tessellation_shader) #endif /* GL_ARB_tessellation_shader */ /* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ #ifndef GL_ARB_texture_border_clamp #define GL_ARB_texture_border_clamp 1 #define GL_CLAMP_TO_BORDER_ARB 0x812D #define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp) #endif /* GL_ARB_texture_border_clamp */ /* ---------------------- GL_ARB_texture_buffer_object --------------------- */ #ifndef GL_ARB_texture_buffer_object #define GL_ARB_texture_buffer_object 1 #define GL_TEXTURE_BUFFER_ARB 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B #define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D #define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E typedef void (GLAPIENTRY * PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); #define glTexBufferARB GLEW_GET_FUN(__glewTexBufferARB) #define GLEW_ARB_texture_buffer_object GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object) #endif /* GL_ARB_texture_buffer_object */ /* ------------------- GL_ARB_texture_buffer_object_rgb32 ------------------ */ #ifndef GL_ARB_texture_buffer_object_rgb32 #define GL_ARB_texture_buffer_object_rgb32 1 #define GLEW_ARB_texture_buffer_object_rgb32 GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object_rgb32) #endif /* GL_ARB_texture_buffer_object_rgb32 */ /* ----------------------- GL_ARB_texture_compression ---------------------- */ #ifndef GL_ARB_texture_compression #define GL_ARB_texture_compression 1 #define GL_COMPRESSED_ALPHA_ARB 0x84E9 #define GL_COMPRESSED_LUMINANCE_ARB 0x84EA #define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB #define GL_COMPRESSED_INTENSITY_ARB 0x84EC #define GL_COMPRESSED_RGB_ARB 0x84ED #define GL_COMPRESSED_RGBA_ARB 0x84EE #define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 #define GL_TEXTURE_COMPRESSED_ARB 0x86A1 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void* img); #define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB) #define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB) #define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB) #define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB) #define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB) #define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB) #define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB) #define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression) #endif /* GL_ARB_texture_compression */ /* -------------------- GL_ARB_texture_compression_bptc -------------------- */ #ifndef GL_ARB_texture_compression_bptc #define GL_ARB_texture_compression_bptc 1 #define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C #define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F #define GLEW_ARB_texture_compression_bptc GLEW_GET_VAR(__GLEW_ARB_texture_compression_bptc) #endif /* GL_ARB_texture_compression_bptc */ /* -------------------- GL_ARB_texture_compression_rgtc -------------------- */ #ifndef GL_ARB_texture_compression_rgtc #define GL_ARB_texture_compression_rgtc 1 #define GL_COMPRESSED_RED_RGTC1 0x8DBB #define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC #define GL_COMPRESSED_RG_RGTC2 0x8DBD #define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE #define GLEW_ARB_texture_compression_rgtc GLEW_GET_VAR(__GLEW_ARB_texture_compression_rgtc) #endif /* GL_ARB_texture_compression_rgtc */ /* ------------------------ GL_ARB_texture_cube_map ------------------------ */ #ifndef GL_ARB_texture_cube_map #define GL_ARB_texture_cube_map 1 #define GL_NORMAL_MAP_ARB 0x8511 #define GL_REFLECTION_MAP_ARB 0x8512 #define GL_TEXTURE_CUBE_MAP_ARB 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C #define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map) #endif /* GL_ARB_texture_cube_map */ /* --------------------- GL_ARB_texture_cube_map_array --------------------- */ #ifndef GL_ARB_texture_cube_map_array #define GL_ARB_texture_cube_map_array 1 #define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A #define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B #define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D #define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F #define GLEW_ARB_texture_cube_map_array GLEW_GET_VAR(__GLEW_ARB_texture_cube_map_array) #endif /* GL_ARB_texture_cube_map_array */ /* ------------------------- GL_ARB_texture_env_add ------------------------ */ #ifndef GL_ARB_texture_env_add #define GL_ARB_texture_env_add 1 #define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add) #endif /* GL_ARB_texture_env_add */ /* ----------------------- GL_ARB_texture_env_combine ---------------------- */ #ifndef GL_ARB_texture_env_combine #define GL_ARB_texture_env_combine 1 #define GL_SUBTRACT_ARB 0x84E7 #define GL_COMBINE_ARB 0x8570 #define GL_COMBINE_RGB_ARB 0x8571 #define GL_COMBINE_ALPHA_ARB 0x8572 #define GL_RGB_SCALE_ARB 0x8573 #define GL_ADD_SIGNED_ARB 0x8574 #define GL_INTERPOLATE_ARB 0x8575 #define GL_CONSTANT_ARB 0x8576 #define GL_PRIMARY_COLOR_ARB 0x8577 #define GL_PREVIOUS_ARB 0x8578 #define GL_SOURCE0_RGB_ARB 0x8580 #define GL_SOURCE1_RGB_ARB 0x8581 #define GL_SOURCE2_RGB_ARB 0x8582 #define GL_SOURCE0_ALPHA_ARB 0x8588 #define GL_SOURCE1_ALPHA_ARB 0x8589 #define GL_SOURCE2_ALPHA_ARB 0x858A #define GL_OPERAND0_RGB_ARB 0x8590 #define GL_OPERAND1_RGB_ARB 0x8591 #define GL_OPERAND2_RGB_ARB 0x8592 #define GL_OPERAND0_ALPHA_ARB 0x8598 #define GL_OPERAND1_ALPHA_ARB 0x8599 #define GL_OPERAND2_ALPHA_ARB 0x859A #define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine) #endif /* GL_ARB_texture_env_combine */ /* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */ #ifndef GL_ARB_texture_env_crossbar #define GL_ARB_texture_env_crossbar 1 #define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar) #endif /* GL_ARB_texture_env_crossbar */ /* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */ #ifndef GL_ARB_texture_env_dot3 #define GL_ARB_texture_env_dot3 1 #define GL_DOT3_RGB_ARB 0x86AE #define GL_DOT3_RGBA_ARB 0x86AF #define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3) #endif /* GL_ARB_texture_env_dot3 */ /* -------------------------- GL_ARB_texture_float ------------------------- */ #ifndef GL_ARB_texture_float #define GL_ARB_texture_float 1 #define GL_RGBA32F_ARB 0x8814 #define GL_RGB32F_ARB 0x8815 #define GL_ALPHA32F_ARB 0x8816 #define GL_INTENSITY32F_ARB 0x8817 #define GL_LUMINANCE32F_ARB 0x8818 #define GL_LUMINANCE_ALPHA32F_ARB 0x8819 #define GL_RGBA16F_ARB 0x881A #define GL_RGB16F_ARB 0x881B #define GL_ALPHA16F_ARB 0x881C #define GL_INTENSITY16F_ARB 0x881D #define GL_LUMINANCE16F_ARB 0x881E #define GL_LUMINANCE_ALPHA16F_ARB 0x881F #define GL_TEXTURE_RED_TYPE_ARB 0x8C10 #define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 #define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 #define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 #define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 #define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 #define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 #define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 #define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float) #endif /* GL_ARB_texture_float */ /* ------------------------- GL_ARB_texture_gather ------------------------- */ #ifndef GL_ARB_texture_gather #define GL_ARB_texture_gather 1 #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F #define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F #define GLEW_ARB_texture_gather GLEW_GET_VAR(__GLEW_ARB_texture_gather) #endif /* GL_ARB_texture_gather */ /* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */ #ifndef GL_ARB_texture_mirrored_repeat #define GL_ARB_texture_mirrored_repeat 1 #define GL_MIRRORED_REPEAT_ARB 0x8370 #define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat) #endif /* GL_ARB_texture_mirrored_repeat */ /* ----------------------- GL_ARB_texture_multisample ---------------------- */ #ifndef GL_ARB_texture_multisample #define GL_ARB_texture_multisample 1 #define GL_SAMPLE_POSITION 0x8E50 #define GL_SAMPLE_MASK 0x8E51 #define GL_SAMPLE_MASK_VALUE 0x8E52 #define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 #define GL_TEXTURE_2D_MULTISAMPLE 0x9100 #define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 #define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 #define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 #define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 #define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 #define GL_TEXTURE_SAMPLES 0x9106 #define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 #define GL_SAMPLER_2D_MULTISAMPLE 0x9108 #define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A #define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B #define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D #define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E #define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F #define GL_MAX_INTEGER_SAMPLES 0x9110 typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat* val); typedef void (GLAPIENTRY * PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); #define glGetMultisamplefv GLEW_GET_FUN(__glewGetMultisamplefv) #define glSampleMaski GLEW_GET_FUN(__glewSampleMaski) #define glTexImage2DMultisample GLEW_GET_FUN(__glewTexImage2DMultisample) #define glTexImage3DMultisample GLEW_GET_FUN(__glewTexImage3DMultisample) #define GLEW_ARB_texture_multisample GLEW_GET_VAR(__GLEW_ARB_texture_multisample) #endif /* GL_ARB_texture_multisample */ /* -------------------- GL_ARB_texture_non_power_of_two -------------------- */ #ifndef GL_ARB_texture_non_power_of_two #define GL_ARB_texture_non_power_of_two 1 #define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two) #endif /* GL_ARB_texture_non_power_of_two */ /* ------------------------ GL_ARB_texture_query_lod ----------------------- */ #ifndef GL_ARB_texture_query_lod #define GL_ARB_texture_query_lod 1 #define GLEW_ARB_texture_query_lod GLEW_GET_VAR(__GLEW_ARB_texture_query_lod) #endif /* GL_ARB_texture_query_lod */ /* ------------------------ GL_ARB_texture_rectangle ----------------------- */ #ifndef GL_ARB_texture_rectangle #define GL_ARB_texture_rectangle 1 #define GL_TEXTURE_RECTANGLE_ARB 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 #define GL_SAMPLER_2D_RECT_ARB 0x8B63 #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 #define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle) #endif /* GL_ARB_texture_rectangle */ /* --------------------------- GL_ARB_texture_rg --------------------------- */ #ifndef GL_ARB_texture_rg #define GL_ARB_texture_rg 1 #define GL_RED 0x1903 #define GL_COMPRESSED_RED 0x8225 #define GL_COMPRESSED_RG 0x8226 #define GL_RG 0x8227 #define GL_RG_INTEGER 0x8228 #define GL_R8 0x8229 #define GL_R16 0x822A #define GL_RG8 0x822B #define GL_RG16 0x822C #define GL_R16F 0x822D #define GL_R32F 0x822E #define GL_RG16F 0x822F #define GL_RG32F 0x8230 #define GL_R8I 0x8231 #define GL_R8UI 0x8232 #define GL_R16I 0x8233 #define GL_R16UI 0x8234 #define GL_R32I 0x8235 #define GL_R32UI 0x8236 #define GL_RG8I 0x8237 #define GL_RG8UI 0x8238 #define GL_RG16I 0x8239 #define GL_RG16UI 0x823A #define GL_RG32I 0x823B #define GL_RG32UI 0x823C #define GLEW_ARB_texture_rg GLEW_GET_VAR(__GLEW_ARB_texture_rg) #endif /* GL_ARB_texture_rg */ /* ----------------------- GL_ARB_texture_rgb10_a2ui ----------------------- */ #ifndef GL_ARB_texture_rgb10_a2ui #define GL_ARB_texture_rgb10_a2ui 1 #define GL_RGB10_A2UI 0x906F #define GLEW_ARB_texture_rgb10_a2ui GLEW_GET_VAR(__GLEW_ARB_texture_rgb10_a2ui) #endif /* GL_ARB_texture_rgb10_a2ui */ /* ------------------------- GL_ARB_texture_storage ------------------------ */ #ifndef GL_ARB_texture_storage #define GL_ARB_texture_storage 1 #define GL_ALPHA8_EXT 0x803C #define GL_LUMINANCE8_EXT 0x8040 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045 #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F typedef void (GLAPIENTRY * PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #define glTexStorage1D GLEW_GET_FUN(__glewTexStorage1D) #define glTexStorage2D GLEW_GET_FUN(__glewTexStorage2D) #define glTexStorage3D GLEW_GET_FUN(__glewTexStorage3D) #define glTextureStorage1DEXT GLEW_GET_FUN(__glewTextureStorage1DEXT) #define glTextureStorage2DEXT GLEW_GET_FUN(__glewTextureStorage2DEXT) #define glTextureStorage3DEXT GLEW_GET_FUN(__glewTextureStorage3DEXT) #define GLEW_ARB_texture_storage GLEW_GET_VAR(__GLEW_ARB_texture_storage) #endif /* GL_ARB_texture_storage */ /* ------------------------- GL_ARB_texture_swizzle ------------------------ */ #ifndef GL_ARB_texture_swizzle #define GL_ARB_texture_swizzle 1 #define GL_TEXTURE_SWIZZLE_R 0x8E42 #define GL_TEXTURE_SWIZZLE_G 0x8E43 #define GL_TEXTURE_SWIZZLE_B 0x8E44 #define GL_TEXTURE_SWIZZLE_A 0x8E45 #define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 #define GLEW_ARB_texture_swizzle GLEW_GET_VAR(__GLEW_ARB_texture_swizzle) #endif /* GL_ARB_texture_swizzle */ /* --------------------------- GL_ARB_timer_query -------------------------- */ #ifndef GL_ARB_timer_query #define GL_ARB_timer_query 1 #define GL_TIME_ELAPSED 0x88BF #define GL_TIMESTAMP 0x8E28 typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64* params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64* params); typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); #define glGetQueryObjecti64v GLEW_GET_FUN(__glewGetQueryObjecti64v) #define glGetQueryObjectui64v GLEW_GET_FUN(__glewGetQueryObjectui64v) #define glQueryCounter GLEW_GET_FUN(__glewQueryCounter) #define GLEW_ARB_timer_query GLEW_GET_VAR(__GLEW_ARB_timer_query) #endif /* GL_ARB_timer_query */ /* ----------------------- GL_ARB_transform_feedback2 ---------------------- */ #ifndef GL_ARB_transform_feedback2 #define GL_ARB_transform_feedback2 1 #define GL_TRANSFORM_FEEDBACK 0x8E22 #define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 #define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 #define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids); typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); #define glBindTransformFeedback GLEW_GET_FUN(__glewBindTransformFeedback) #define glDeleteTransformFeedbacks GLEW_GET_FUN(__glewDeleteTransformFeedbacks) #define glDrawTransformFeedback GLEW_GET_FUN(__glewDrawTransformFeedback) #define glGenTransformFeedbacks GLEW_GET_FUN(__glewGenTransformFeedbacks) #define glIsTransformFeedback GLEW_GET_FUN(__glewIsTransformFeedback) #define glPauseTransformFeedback GLEW_GET_FUN(__glewPauseTransformFeedback) #define glResumeTransformFeedback GLEW_GET_FUN(__glewResumeTransformFeedback) #define GLEW_ARB_transform_feedback2 GLEW_GET_VAR(__GLEW_ARB_transform_feedback2) #endif /* GL_ARB_transform_feedback2 */ /* ----------------------- GL_ARB_transform_feedback3 ---------------------- */ #ifndef GL_ARB_transform_feedback3 #define GL_ARB_transform_feedback3 1 #define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 #define GL_MAX_VERTEX_STREAMS 0x8E71 typedef void (GLAPIENTRY * PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); typedef void (GLAPIENTRY * PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); typedef void (GLAPIENTRY * PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); #define glBeginQueryIndexed GLEW_GET_FUN(__glewBeginQueryIndexed) #define glDrawTransformFeedbackStream GLEW_GET_FUN(__glewDrawTransformFeedbackStream) #define glEndQueryIndexed GLEW_GET_FUN(__glewEndQueryIndexed) #define glGetQueryIndexediv GLEW_GET_FUN(__glewGetQueryIndexediv) #define GLEW_ARB_transform_feedback3 GLEW_GET_VAR(__GLEW_ARB_transform_feedback3) #endif /* GL_ARB_transform_feedback3 */ /* ------------------ GL_ARB_transform_feedback_instanced ------------------ */ #ifndef GL_ARB_transform_feedback_instanced #define GL_ARB_transform_feedback_instanced 1 typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); #define glDrawTransformFeedbackInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackInstanced) #define glDrawTransformFeedbackStreamInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackStreamInstanced) #define GLEW_ARB_transform_feedback_instanced GLEW_GET_VAR(__GLEW_ARB_transform_feedback_instanced) #endif /* GL_ARB_transform_feedback_instanced */ /* ------------------------ GL_ARB_transpose_matrix ------------------------ */ #ifndef GL_ARB_transpose_matrix #define GL_ARB_transpose_matrix 1 #define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 #define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 #define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 #define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); #define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB) #define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB) #define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB) #define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB) #define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix) #endif /* GL_ARB_transpose_matrix */ /* ---------------------- GL_ARB_uniform_buffer_object --------------------- */ #ifndef GL_ARB_uniform_buffer_object #define GL_ARB_uniform_buffer_object 1 #define GL_UNIFORM_BUFFER 0x8A11 #define GL_UNIFORM_BUFFER_BINDING 0x8A28 #define GL_UNIFORM_BUFFER_START 0x8A29 #define GL_UNIFORM_BUFFER_SIZE 0x8A2A #define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B #define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E #define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 #define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 #define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 #define GL_UNIFORM_TYPE 0x8A37 #define GL_UNIFORM_SIZE 0x8A38 #define GL_UNIFORM_NAME_LENGTH 0x8A39 #define GL_UNIFORM_BLOCK_INDEX 0x8A3A #define GL_UNIFORM_OFFSET 0x8A3B #define GL_UNIFORM_ARRAY_STRIDE 0x8A3C #define GL_UNIFORM_MATRIX_STRIDE 0x8A3D #define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E #define GL_UNIFORM_BLOCK_BINDING 0x8A3F #define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 #define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 #define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 #define GL_INVALID_INDEX 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, char* uniformBlockName); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, char* uniformName); typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint* data); typedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const char* uniformBlockName); typedef void (GLAPIENTRY * PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const char** uniformNames, GLuint* uniformIndices); typedef void (GLAPIENTRY * PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase) #define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange) #define glGetActiveUniformBlockName GLEW_GET_FUN(__glewGetActiveUniformBlockName) #define glGetActiveUniformBlockiv GLEW_GET_FUN(__glewGetActiveUniformBlockiv) #define glGetActiveUniformName GLEW_GET_FUN(__glewGetActiveUniformName) #define glGetActiveUniformsiv GLEW_GET_FUN(__glewGetActiveUniformsiv) #define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v) #define glGetUniformBlockIndex GLEW_GET_FUN(__glewGetUniformBlockIndex) #define glGetUniformIndices GLEW_GET_FUN(__glewGetUniformIndices) #define glUniformBlockBinding GLEW_GET_FUN(__glewUniformBlockBinding) #define GLEW_ARB_uniform_buffer_object GLEW_GET_VAR(__GLEW_ARB_uniform_buffer_object) #endif /* GL_ARB_uniform_buffer_object */ /* ------------------------ GL_ARB_vertex_array_bgra ----------------------- */ #ifndef GL_ARB_vertex_array_bgra #define GL_ARB_vertex_array_bgra 1 #define GL_BGRA 0x80E1 #define GLEW_ARB_vertex_array_bgra GLEW_GET_VAR(__GLEW_ARB_vertex_array_bgra) #endif /* GL_ARB_vertex_array_bgra */ /* ----------------------- GL_ARB_vertex_array_object ---------------------- */ #ifndef GL_ARB_vertex_array_object #define GL_ARB_vertex_array_object 1 #define GL_VERTEX_ARRAY_BINDING 0x85B5 typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYPROC) (GLuint array); typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array); #define glBindVertexArray GLEW_GET_FUN(__glewBindVertexArray) #define glDeleteVertexArrays GLEW_GET_FUN(__glewDeleteVertexArrays) #define glGenVertexArrays GLEW_GET_FUN(__glewGenVertexArrays) #define glIsVertexArray GLEW_GET_FUN(__glewIsVertexArray) #define GLEW_ARB_vertex_array_object GLEW_GET_VAR(__GLEW_ARB_vertex_array_object) #endif /* GL_ARB_vertex_array_object */ /* ----------------------- GL_ARB_vertex_attrib_64bit ---------------------- */ #ifndef GL_ARB_vertex_attrib_64bit #define GL_ARB_vertex_attrib_64bit 1 #define GL_DOUBLE_MAT2 0x8F46 #define GL_DOUBLE_MAT3 0x8F47 #define GL_DOUBLE_MAT4 0x8F48 #define GL_DOUBLE_VEC2 0x8FFC #define GL_DOUBLE_VEC3 0x8FFD #define GL_DOUBLE_VEC4 0x8FFE typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); #define glGetVertexAttribLdv GLEW_GET_FUN(__glewGetVertexAttribLdv) #define glVertexAttribL1d GLEW_GET_FUN(__glewVertexAttribL1d) #define glVertexAttribL1dv GLEW_GET_FUN(__glewVertexAttribL1dv) #define glVertexAttribL2d GLEW_GET_FUN(__glewVertexAttribL2d) #define glVertexAttribL2dv GLEW_GET_FUN(__glewVertexAttribL2dv) #define glVertexAttribL3d GLEW_GET_FUN(__glewVertexAttribL3d) #define glVertexAttribL3dv GLEW_GET_FUN(__glewVertexAttribL3dv) #define glVertexAttribL4d GLEW_GET_FUN(__glewVertexAttribL4d) #define glVertexAttribL4dv GLEW_GET_FUN(__glewVertexAttribL4dv) #define glVertexAttribLPointer GLEW_GET_FUN(__glewVertexAttribLPointer) #define GLEW_ARB_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_64bit) #endif /* GL_ARB_vertex_attrib_64bit */ /* -------------------------- GL_ARB_vertex_blend -------------------------- */ #ifndef GL_ARB_vertex_blend #define GL_ARB_vertex_blend 1 #define GL_MODELVIEW0_ARB 0x1700 #define GL_MODELVIEW1_ARB 0x850A #define GL_MAX_VERTEX_UNITS_ARB 0x86A4 #define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 #define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 #define GL_VERTEX_BLEND_ARB 0x86A7 #define GL_CURRENT_WEIGHT_ARB 0x86A8 #define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 #define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA #define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB #define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC #define GL_WEIGHT_ARRAY_ARB 0x86AD #define GL_MODELVIEW2_ARB 0x8722 #define GL_MODELVIEW3_ARB 0x8723 #define GL_MODELVIEW4_ARB 0x8724 #define GL_MODELVIEW5_ARB 0x8725 #define GL_MODELVIEW6_ARB 0x8726 #define GL_MODELVIEW7_ARB 0x8727 #define GL_MODELVIEW8_ARB 0x8728 #define GL_MODELVIEW9_ARB 0x8729 #define GL_MODELVIEW10_ARB 0x872A #define GL_MODELVIEW11_ARB 0x872B #define GL_MODELVIEW12_ARB 0x872C #define GL_MODELVIEW13_ARB 0x872D #define GL_MODELVIEW14_ARB 0x872E #define GL_MODELVIEW15_ARB 0x872F #define GL_MODELVIEW16_ARB 0x8730 #define GL_MODELVIEW17_ARB 0x8731 #define GL_MODELVIEW18_ARB 0x8732 #define GL_MODELVIEW19_ARB 0x8733 #define GL_MODELVIEW20_ARB 0x8734 #define GL_MODELVIEW21_ARB 0x8735 #define GL_MODELVIEW22_ARB 0x8736 #define GL_MODELVIEW23_ARB 0x8737 #define GL_MODELVIEW24_ARB 0x8738 #define GL_MODELVIEW25_ARB 0x8739 #define GL_MODELVIEW26_ARB 0x873A #define GL_MODELVIEW27_ARB 0x873B #define GL_MODELVIEW28_ARB 0x873C #define GL_MODELVIEW29_ARB 0x873D #define GL_MODELVIEW30_ARB 0x873E #define GL_MODELVIEW31_ARB 0x873F typedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); typedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); typedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights); typedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights); #define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB) #define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB) #define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB) #define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB) #define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB) #define glWeightivARB GLEW_GET_FUN(__glewWeightivARB) #define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB) #define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB) #define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB) #define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB) #define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend) #endif /* GL_ARB_vertex_blend */ /* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */ #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 #define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_USAGE_ARB 0x8765 #define GL_ARRAY_BUFFER_ARB 0x8892 #define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 #define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 #define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 #define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 #define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 #define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D #define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F #define GL_READ_ONLY_ARB 0x88B8 #define GL_WRITE_ONLY_ARB 0x88B9 #define GL_READ_WRITE_ARB 0x88BA #define GL_BUFFER_ACCESS_ARB 0x88BB #define GL_BUFFER_MAPPED_ARB 0x88BC #define GL_BUFFER_MAP_POINTER_ARB 0x88BD #define GL_STREAM_DRAW_ARB 0x88E0 #define GL_STREAM_READ_ARB 0x88E1 #define GL_STREAM_COPY_ARB 0x88E2 #define GL_STATIC_DRAW_ARB 0x88E4 #define GL_STATIC_READ_ARB 0x88E5 #define GL_STATIC_COPY_ARB 0x88E6 #define GL_DYNAMIC_DRAW_ARB 0x88E8 #define GL_DYNAMIC_READ_ARB 0x88E9 #define GL_DYNAMIC_COPY_ARB 0x88EA typedef ptrdiff_t GLintptrARB; typedef ptrdiff_t GLsizeiptrARB; typedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage); typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data); typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers); typedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers); typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid** params); typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data); typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); #define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB) #define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB) #define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB) #define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB) #define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB) #define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB) #define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB) #define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB) #define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB) #define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB) #define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB) #define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object) #endif /* GL_ARB_vertex_buffer_object */ /* ------------------------- GL_ARB_vertex_program ------------------------- */ #ifndef GL_ARB_vertex_program #define GL_ARB_vertex_program 1 #define GL_COLOR_SUM_ARB 0x8458 #define GL_VERTEX_PROGRAM_ARB 0x8620 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 #define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 #define GL_PROGRAM_LENGTH_ARB 0x8627 #define GL_PROGRAM_STRING_ARB 0x8628 #define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E #define GL_MAX_PROGRAM_MATRICES_ARB 0x862F #define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 #define GL_CURRENT_MATRIX_ARB 0x8641 #define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 #define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 #define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 #define GL_PROGRAM_ERROR_POSITION_ARB 0x864B #define GL_PROGRAM_BINDING_ARB 0x8677 #define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A #define GL_PROGRAM_ERROR_STRING_ARB 0x8874 #define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 #define GL_PROGRAM_FORMAT_ARB 0x8876 #define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 #define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 #define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 #define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 #define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 #define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 #define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 #define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 #define GL_PROGRAM_PARAMETERS_ARB 0x88A8 #define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 #define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA #define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB #define GL_PROGRAM_ATTRIBS_ARB 0x88AC #define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD #define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE #define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF #define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 #define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 #define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 #define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 #define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 #define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 #define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 #define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 #define GL_MATRIX0_ARB 0x88C0 #define GL_MATRIX1_ARB 0x88C1 #define GL_MATRIX2_ARB 0x88C2 #define GL_MATRIX3_ARB 0x88C3 #define GL_MATRIX4_ARB 0x88C4 #define GL_MATRIX5_ARB 0x88C5 #define GL_MATRIX6_ARB 0x88C6 #define GL_MATRIX7_ARB 0x88C7 #define GL_MATRIX8_ARB 0x88C8 #define GL_MATRIX9_ARB 0x88C9 #define GL_MATRIX10_ARB 0x88CA #define GL_MATRIX11_ARB 0x88CB #define GL_MATRIX12_ARB 0x88CC #define GL_MATRIX13_ARB 0x88CD #define GL_MATRIX14_ARB 0x88CE #define GL_MATRIX15_ARB 0x88CF #define GL_MATRIX16_ARB 0x88D0 #define GL_MATRIX17_ARB 0x88D1 #define GL_MATRIX18_ARB 0x88D2 #define GL_MATRIX19_ARB 0x88D3 #define GL_MATRIX20_ARB 0x88D4 #define GL_MATRIX21_ARB 0x88D5 #define GL_MATRIX22_ARB 0x88D6 #define GL_MATRIX23_ARB 0x88D7 #define GL_MATRIX24_ARB 0x88D8 #define GL_MATRIX25_ARB 0x88D9 #define GL_MATRIX26_ARB 0x88DA #define GL_MATRIX27_ARB 0x88DB #define GL_MATRIX28_ARB 0x88DC #define GL_MATRIX29_ARB 0x88DD #define GL_MATRIX30_ARB 0x88DE #define GL_MATRIX31_ARB 0x88DF typedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs); typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void* string); typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid** pointer); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void* string); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); #define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB) #define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB) #define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB) #define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB) #define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB) #define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB) #define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB) #define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB) #define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB) #define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB) #define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB) #define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB) #define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB) #define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB) #define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB) #define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB) #define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB) #define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB) #define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB) #define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB) #define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB) #define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB) #define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB) #define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB) #define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB) #define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB) #define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB) #define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB) #define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB) #define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB) #define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB) #define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB) #define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB) #define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB) #define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB) #define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB) #define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB) #define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB) #define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB) #define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB) #define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB) #define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB) #define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB) #define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB) #define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB) #define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB) #define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB) #define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB) #define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB) #define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB) #define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB) #define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB) #define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB) #define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB) #define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB) #define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB) #define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB) #define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB) #define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB) #define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB) #define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB) #define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB) #define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program) #endif /* GL_ARB_vertex_program */ /* -------------------------- GL_ARB_vertex_shader ------------------------- */ #ifndef GL_ARB_vertex_shader #define GL_ARB_vertex_shader 1 #define GL_VERTEX_SHADER_ARB 0x8B31 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A #define GL_MAX_VARYING_FLOATS_ARB 0x8B4B #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D #define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 #define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name); typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); #define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB) #define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB) #define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB) #define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader) #endif /* GL_ARB_vertex_shader */ /* ------------------- GL_ARB_vertex_type_2_10_10_10_rev ------------------- */ #ifndef GL_ARB_vertex_type_2_10_10_10_rev #define GL_ARB_vertex_type_2_10_10_10_rev 1 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_INT_2_10_10_10_REV 0x8D9F typedef void (GLAPIENTRY * PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); typedef void (GLAPIENTRY * PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint* color); typedef void (GLAPIENTRY * PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); typedef void (GLAPIENTRY * PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint* color); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint* color); typedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); typedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint* coords); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint* value); typedef void (GLAPIENTRY * PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); typedef void (GLAPIENTRY * PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint* value); #define glColorP3ui GLEW_GET_FUN(__glewColorP3ui) #define glColorP3uiv GLEW_GET_FUN(__glewColorP3uiv) #define glColorP4ui GLEW_GET_FUN(__glewColorP4ui) #define glColorP4uiv GLEW_GET_FUN(__glewColorP4uiv) #define glMultiTexCoordP1ui GLEW_GET_FUN(__glewMultiTexCoordP1ui) #define glMultiTexCoordP1uiv GLEW_GET_FUN(__glewMultiTexCoordP1uiv) #define glMultiTexCoordP2ui GLEW_GET_FUN(__glewMultiTexCoordP2ui) #define glMultiTexCoordP2uiv GLEW_GET_FUN(__glewMultiTexCoordP2uiv) #define glMultiTexCoordP3ui GLEW_GET_FUN(__glewMultiTexCoordP3ui) #define glMultiTexCoordP3uiv GLEW_GET_FUN(__glewMultiTexCoordP3uiv) #define glMultiTexCoordP4ui GLEW_GET_FUN(__glewMultiTexCoordP4ui) #define glMultiTexCoordP4uiv GLEW_GET_FUN(__glewMultiTexCoordP4uiv) #define glNormalP3ui GLEW_GET_FUN(__glewNormalP3ui) #define glNormalP3uiv GLEW_GET_FUN(__glewNormalP3uiv) #define glSecondaryColorP3ui GLEW_GET_FUN(__glewSecondaryColorP3ui) #define glSecondaryColorP3uiv GLEW_GET_FUN(__glewSecondaryColorP3uiv) #define glTexCoordP1ui GLEW_GET_FUN(__glewTexCoordP1ui) #define glTexCoordP1uiv GLEW_GET_FUN(__glewTexCoordP1uiv) #define glTexCoordP2ui GLEW_GET_FUN(__glewTexCoordP2ui) #define glTexCoordP2uiv GLEW_GET_FUN(__glewTexCoordP2uiv) #define glTexCoordP3ui GLEW_GET_FUN(__glewTexCoordP3ui) #define glTexCoordP3uiv GLEW_GET_FUN(__glewTexCoordP3uiv) #define glTexCoordP4ui GLEW_GET_FUN(__glewTexCoordP4ui) #define glTexCoordP4uiv GLEW_GET_FUN(__glewTexCoordP4uiv) #define glVertexAttribP1ui GLEW_GET_FUN(__glewVertexAttribP1ui) #define glVertexAttribP1uiv GLEW_GET_FUN(__glewVertexAttribP1uiv) #define glVertexAttribP2ui GLEW_GET_FUN(__glewVertexAttribP2ui) #define glVertexAttribP2uiv GLEW_GET_FUN(__glewVertexAttribP2uiv) #define glVertexAttribP3ui GLEW_GET_FUN(__glewVertexAttribP3ui) #define glVertexAttribP3uiv GLEW_GET_FUN(__glewVertexAttribP3uiv) #define glVertexAttribP4ui GLEW_GET_FUN(__glewVertexAttribP4ui) #define glVertexAttribP4uiv GLEW_GET_FUN(__glewVertexAttribP4uiv) #define glVertexP2ui GLEW_GET_FUN(__glewVertexP2ui) #define glVertexP2uiv GLEW_GET_FUN(__glewVertexP2uiv) #define glVertexP3ui GLEW_GET_FUN(__glewVertexP3ui) #define glVertexP3uiv GLEW_GET_FUN(__glewVertexP3uiv) #define glVertexP4ui GLEW_GET_FUN(__glewVertexP4ui) #define glVertexP4uiv GLEW_GET_FUN(__glewVertexP4uiv) #define GLEW_ARB_vertex_type_2_10_10_10_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_2_10_10_10_rev) #endif /* GL_ARB_vertex_type_2_10_10_10_rev */ /* ------------------------- GL_ARB_viewport_array ------------------------- */ #ifndef GL_ARB_viewport_array #define GL_ARB_viewport_array 1 #define GL_DEPTH_RANGE 0x0B70 #define GL_VIEWPORT 0x0BA2 #define GL_SCISSOR_BOX 0x0C10 #define GL_SCISSOR_TEST 0x0C11 #define GL_MAX_VIEWPORTS 0x825B #define GL_VIEWPORT_SUBPIXEL_BITS 0x825C #define GL_VIEWPORT_BOUNDS_RANGE 0x825D #define GL_LAYER_PROVOKING_VERTEX 0x825E #define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F #define GL_UNDEFINED_VERTEX 0x8260 #define GL_FIRST_VERTEX_CONVENTION 0x8E4D #define GL_LAST_VERTEX_CONVENTION 0x8E4E #define GL_PROVOKING_VERTEX 0x8E4F typedef void (GLAPIENTRY * PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd * v); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); typedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble* data); typedef void (GLAPIENTRY * PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat* data); typedef void (GLAPIENTRY * PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint * v); typedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint * v); typedef void (GLAPIENTRY * PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat * v); typedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); typedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat * v); #define glDepthRangeArrayv GLEW_GET_FUN(__glewDepthRangeArrayv) #define glDepthRangeIndexed GLEW_GET_FUN(__glewDepthRangeIndexed) #define glGetDoublei_v GLEW_GET_FUN(__glewGetDoublei_v) #define glGetFloati_v GLEW_GET_FUN(__glewGetFloati_v) #define glScissorArrayv GLEW_GET_FUN(__glewScissorArrayv) #define glScissorIndexed GLEW_GET_FUN(__glewScissorIndexed) #define glScissorIndexedv GLEW_GET_FUN(__glewScissorIndexedv) #define glViewportArrayv GLEW_GET_FUN(__glewViewportArrayv) #define glViewportIndexedf GLEW_GET_FUN(__glewViewportIndexedf) #define glViewportIndexedfv GLEW_GET_FUN(__glewViewportIndexedfv) #define GLEW_ARB_viewport_array GLEW_GET_VAR(__GLEW_ARB_viewport_array) #endif /* GL_ARB_viewport_array */ /* --------------------------- GL_ARB_window_pos --------------------------- */ #ifndef GL_ARB_window_pos #define GL_ARB_window_pos 1 typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p); #define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB) #define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB) #define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB) #define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB) #define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB) #define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB) #define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB) #define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB) #define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB) #define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB) #define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB) #define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB) #define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB) #define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB) #define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB) #define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB) #define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos) #endif /* GL_ARB_window_pos */ /* ------------------------- GL_ATIX_point_sprites ------------------------- */ #ifndef GL_ATIX_point_sprites #define GL_ATIX_point_sprites 1 #define GL_TEXTURE_POINT_MODE_ATIX 0x60B0 #define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1 #define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2 #define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3 #define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4 #define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5 #define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites) #endif /* GL_ATIX_point_sprites */ /* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */ #ifndef GL_ATIX_texture_env_combine3 #define GL_ATIX_texture_env_combine3 1 #define GL_MODULATE_ADD_ATIX 0x8744 #define GL_MODULATE_SIGNED_ADD_ATIX 0x8745 #define GL_MODULATE_SUBTRACT_ATIX 0x8746 #define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3) #endif /* GL_ATIX_texture_env_combine3 */ /* ----------------------- GL_ATIX_texture_env_route ----------------------- */ #ifndef GL_ATIX_texture_env_route #define GL_ATIX_texture_env_route 1 #define GL_SECONDARY_COLOR_ATIX 0x8747 #define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748 #define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749 #define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route) #endif /* GL_ATIX_texture_env_route */ /* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */ #ifndef GL_ATIX_vertex_shader_output_point_size #define GL_ATIX_vertex_shader_output_point_size 1 #define GL_OUTPUT_POINT_SIZE_ATIX 0x610E #define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size) #endif /* GL_ATIX_vertex_shader_output_point_size */ /* -------------------------- GL_ATI_draw_buffers -------------------------- */ #ifndef GL_ATI_draw_buffers #define GL_ATI_draw_buffers 1 #define GL_MAX_DRAW_BUFFERS_ATI 0x8824 #define GL_DRAW_BUFFER0_ATI 0x8825 #define GL_DRAW_BUFFER1_ATI 0x8826 #define GL_DRAW_BUFFER2_ATI 0x8827 #define GL_DRAW_BUFFER3_ATI 0x8828 #define GL_DRAW_BUFFER4_ATI 0x8829 #define GL_DRAW_BUFFER5_ATI 0x882A #define GL_DRAW_BUFFER6_ATI 0x882B #define GL_DRAW_BUFFER7_ATI 0x882C #define GL_DRAW_BUFFER8_ATI 0x882D #define GL_DRAW_BUFFER9_ATI 0x882E #define GL_DRAW_BUFFER10_ATI 0x882F #define GL_DRAW_BUFFER11_ATI 0x8830 #define GL_DRAW_BUFFER12_ATI 0x8831 #define GL_DRAW_BUFFER13_ATI 0x8832 #define GL_DRAW_BUFFER14_ATI 0x8833 #define GL_DRAW_BUFFER15_ATI 0x8834 typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs); #define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI) #define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers) #endif /* GL_ATI_draw_buffers */ /* -------------------------- GL_ATI_element_array ------------------------- */ #ifndef GL_ATI_element_array #define GL_ATI_element_array 1 #define GL_ELEMENT_ARRAY_ATI 0x8768 #define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 #define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void* pointer); #define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI) #define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI) #define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI) #define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array) #endif /* GL_ATI_element_array */ /* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */ #ifndef GL_ATI_envmap_bumpmap #define GL_ATI_envmap_bumpmap 1 #define GL_BUMP_ROT_MATRIX_ATI 0x8775 #define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 #define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 #define GL_BUMP_TEX_UNITS_ATI 0x8778 #define GL_DUDV_ATI 0x8779 #define GL_DU8DV8_ATI 0x877A #define GL_BUMP_ENVMAP_ATI 0x877B #define GL_BUMP_TARGET_ATI 0x877C typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); #define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI) #define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI) #define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI) #define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI) #define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap) #endif /* GL_ATI_envmap_bumpmap */ /* ------------------------- GL_ATI_fragment_shader ------------------------ */ #ifndef GL_ATI_fragment_shader #define GL_ATI_fragment_shader 1 #define GL_RED_BIT_ATI 0x00000001 #define GL_2X_BIT_ATI 0x00000001 #define GL_4X_BIT_ATI 0x00000002 #define GL_GREEN_BIT_ATI 0x00000002 #define GL_COMP_BIT_ATI 0x00000002 #define GL_BLUE_BIT_ATI 0x00000004 #define GL_8X_BIT_ATI 0x00000004 #define GL_NEGATE_BIT_ATI 0x00000004 #define GL_BIAS_BIT_ATI 0x00000008 #define GL_HALF_BIT_ATI 0x00000008 #define GL_QUARTER_BIT_ATI 0x00000010 #define GL_EIGHTH_BIT_ATI 0x00000020 #define GL_SATURATE_BIT_ATI 0x00000040 #define GL_FRAGMENT_SHADER_ATI 0x8920 #define GL_REG_0_ATI 0x8921 #define GL_REG_1_ATI 0x8922 #define GL_REG_2_ATI 0x8923 #define GL_REG_3_ATI 0x8924 #define GL_REG_4_ATI 0x8925 #define GL_REG_5_ATI 0x8926 #define GL_CON_0_ATI 0x8941 #define GL_CON_1_ATI 0x8942 #define GL_CON_2_ATI 0x8943 #define GL_CON_3_ATI 0x8944 #define GL_CON_4_ATI 0x8945 #define GL_CON_5_ATI 0x8946 #define GL_CON_6_ATI 0x8947 #define GL_CON_7_ATI 0x8948 #define GL_MOV_ATI 0x8961 #define GL_ADD_ATI 0x8963 #define GL_MUL_ATI 0x8964 #define GL_SUB_ATI 0x8965 #define GL_DOT3_ATI 0x8966 #define GL_DOT4_ATI 0x8967 #define GL_MAD_ATI 0x8968 #define GL_LERP_ATI 0x8969 #define GL_CND_ATI 0x896A #define GL_CND0_ATI 0x896B #define GL_DOT2_ADD_ATI 0x896C #define GL_SECONDARY_INTERPOLATOR_ATI 0x896D #define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E #define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F #define GL_NUM_PASSES_ATI 0x8970 #define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 #define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 #define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 #define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 #define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 #define GL_SWIZZLE_STR_ATI 0x8976 #define GL_SWIZZLE_STQ_ATI 0x8977 #define GL_SWIZZLE_STR_DR_ATI 0x8978 #define GL_SWIZZLE_STQ_DQ_ATI 0x8979 #define GL_SWIZZLE_STRQ_ATI 0x897A #define GL_SWIZZLE_STRQ_DQ_ATI 0x897B typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); typedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); typedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); typedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); typedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); typedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); typedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); typedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value); #define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI) #define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI) #define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI) #define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI) #define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI) #define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI) #define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI) #define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI) #define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI) #define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI) #define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI) #define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI) #define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI) #define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI) #define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader) #endif /* GL_ATI_fragment_shader */ /* ------------------------ GL_ATI_map_object_buffer ----------------------- */ #ifndef GL_ATI_map_object_buffer #define GL_ATI_map_object_buffer 1 typedef void* (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); #define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI) #define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI) #define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer) #endif /* GL_ATI_map_object_buffer */ /* ----------------------------- GL_ATI_meminfo ---------------------------- */ #ifndef GL_ATI_meminfo #define GL_ATI_meminfo 1 #define GL_VBO_FREE_MEMORY_ATI 0x87FB #define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC #define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD #define GLEW_ATI_meminfo GLEW_GET_VAR(__GLEW_ATI_meminfo) #endif /* GL_ATI_meminfo */ /* -------------------------- GL_ATI_pn_triangles -------------------------- */ #ifndef GL_ATI_pn_triangles #define GL_ATI_pn_triangles 1 #define GL_PN_TRIANGLES_ATI 0x87F0 #define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 #define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 #define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 #define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 #define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 #define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 #define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 #define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 typedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); #define glPNTrianglesfATI GLEW_GET_FUN(__glewPNTrianglesfATI) #define glPNTrianglesiATI GLEW_GET_FUN(__glewPNTrianglesiATI) #define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles) #endif /* GL_ATI_pn_triangles */ /* ------------------------ GL_ATI_separate_stencil ------------------------ */ #ifndef GL_ATI_separate_stencil #define GL_ATI_separate_stencil 1 #define GL_STENCIL_BACK_FUNC_ATI 0x8800 #define GL_STENCIL_BACK_FAIL_ATI 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); #define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI) #define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI) #define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil) #endif /* GL_ATI_separate_stencil */ /* ----------------------- GL_ATI_shader_texture_lod ----------------------- */ #ifndef GL_ATI_shader_texture_lod #define GL_ATI_shader_texture_lod 1 #define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod) #endif /* GL_ATI_shader_texture_lod */ /* ---------------------- GL_ATI_text_fragment_shader ---------------------- */ #ifndef GL_ATI_text_fragment_shader #define GL_ATI_text_fragment_shader 1 #define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 #define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader) #endif /* GL_ATI_text_fragment_shader */ /* --------------------- GL_ATI_texture_compression_3dc -------------------- */ #ifndef GL_ATI_texture_compression_3dc #define GL_ATI_texture_compression_3dc 1 #define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 #define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc) #endif /* GL_ATI_texture_compression_3dc */ /* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */ #ifndef GL_ATI_texture_env_combine3 #define GL_ATI_texture_env_combine3 1 #define GL_MODULATE_ADD_ATI 0x8744 #define GL_MODULATE_SIGNED_ADD_ATI 0x8745 #define GL_MODULATE_SUBTRACT_ATI 0x8746 #define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3) #endif /* GL_ATI_texture_env_combine3 */ /* -------------------------- GL_ATI_texture_float ------------------------- */ #ifndef GL_ATI_texture_float #define GL_ATI_texture_float 1 #define GL_RGBA_FLOAT32_ATI 0x8814 #define GL_RGB_FLOAT32_ATI 0x8815 #define GL_ALPHA_FLOAT32_ATI 0x8816 #define GL_INTENSITY_FLOAT32_ATI 0x8817 #define GL_LUMINANCE_FLOAT32_ATI 0x8818 #define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 #define GL_RGBA_FLOAT16_ATI 0x881A #define GL_RGB_FLOAT16_ATI 0x881B #define GL_ALPHA_FLOAT16_ATI 0x881C #define GL_INTENSITY_FLOAT16_ATI 0x881D #define GL_LUMINANCE_FLOAT16_ATI 0x881E #define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F #define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float) #endif /* GL_ATI_texture_float */ /* ----------------------- GL_ATI_texture_mirror_once ---------------------- */ #ifndef GL_ATI_texture_mirror_once #define GL_ATI_texture_mirror_once 1 #define GL_MIRROR_CLAMP_ATI 0x8742 #define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 #define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once) #endif /* GL_ATI_texture_mirror_once */ /* ----------------------- GL_ATI_vertex_array_object ---------------------- */ #ifndef GL_ATI_vertex_array_object #define GL_ATI_vertex_array_object 1 #define GL_STATIC_ATI 0x8760 #define GL_DYNAMIC_ATI 0x8761 #define GL_PRESERVE_ATI 0x8762 #define GL_DISCARD_ATI 0x8763 #define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 #define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 #define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 #define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 typedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); typedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); typedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void* pointer, GLenum usage); typedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve); typedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); #define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI) #define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI) #define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI) #define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI) #define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI) #define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI) #define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI) #define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI) #define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI) #define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI) #define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI) #define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI) #define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object) #endif /* GL_ATI_vertex_array_object */ /* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */ #ifndef GL_ATI_vertex_attrib_array_object #define GL_ATI_vertex_attrib_array_object 1 typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); #define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI) #define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI) #define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI) #define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object) #endif /* GL_ATI_vertex_attrib_array_object */ /* ------------------------- GL_ATI_vertex_streams ------------------------- */ #ifndef GL_ATI_vertex_streams #define GL_ATI_vertex_streams 1 #define GL_MAX_VERTEX_STREAMS_ATI 0x876B #define GL_VERTEX_SOURCE_ATI 0x876C #define GL_VERTEX_STREAM0_ATI 0x876D #define GL_VERTEX_STREAM1_ATI 0x876E #define GL_VERTEX_STREAM2_ATI 0x876F #define GL_VERTEX_STREAM3_ATI 0x8770 #define GL_VERTEX_STREAM4_ATI 0x8771 #define GL_VERTEX_STREAM5_ATI 0x8772 #define GL_VERTEX_STREAM6_ATI 0x8773 #define GL_VERTEX_STREAM7_ATI 0x8774 typedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *v); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *v); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *v); #define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI) #define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI) #define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI) #define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI) #define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI) #define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI) #define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI) #define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI) #define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI) #define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI) #define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI) #define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI) #define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI) #define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI) #define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI) #define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI) #define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI) #define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI) #define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI) #define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI) #define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI) #define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI) #define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI) #define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI) #define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI) #define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI) #define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI) #define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI) #define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI) #define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI) #define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI) #define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI) #define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI) #define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI) #define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI) #define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI) #define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI) #define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams) #endif /* GL_ATI_vertex_streams */ /* --------------------------- GL_EXT_422_pixels --------------------------- */ #ifndef GL_EXT_422_pixels #define GL_EXT_422_pixels 1 #define GL_422_EXT 0x80CC #define GL_422_REV_EXT 0x80CD #define GL_422_AVERAGE_EXT 0x80CE #define GL_422_REV_AVERAGE_EXT 0x80CF #define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels) #endif /* GL_EXT_422_pixels */ /* ---------------------------- GL_EXT_Cg_shader --------------------------- */ #ifndef GL_EXT_Cg_shader #define GL_EXT_Cg_shader 1 #define GL_CG_VERTEX_SHADER_EXT 0x890E #define GL_CG_FRAGMENT_SHADER_EXT 0x890F #define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader) #endif /* GL_EXT_Cg_shader */ /* ------------------------------ GL_EXT_abgr ------------------------------ */ #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #define GL_ABGR_EXT 0x8000 #define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr) #endif /* GL_EXT_abgr */ /* ------------------------------ GL_EXT_bgra ------------------------------ */ #ifndef GL_EXT_bgra #define GL_EXT_bgra 1 #define GL_BGR_EXT 0x80E0 #define GL_BGRA_EXT 0x80E1 #define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra) #endif /* GL_EXT_bgra */ /* ------------------------ GL_EXT_bindable_uniform ------------------------ */ #ifndef GL_EXT_bindable_uniform #define GL_EXT_bindable_uniform 1 #define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 #define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 #define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 #define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED #define GL_UNIFORM_BUFFER_EXT 0x8DEE #define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); typedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); typedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); #define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT) #define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT) #define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT) #define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform) #endif /* GL_EXT_bindable_uniform */ /* --------------------------- GL_EXT_blend_color -------------------------- */ #ifndef GL_EXT_blend_color #define GL_EXT_blend_color 1 #define GL_CONSTANT_COLOR_EXT 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 #define GL_CONSTANT_ALPHA_EXT 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 #define GL_BLEND_COLOR_EXT 0x8005 typedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); #define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT) #define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color) #endif /* GL_EXT_blend_color */ /* --------------------- GL_EXT_blend_equation_separate -------------------- */ #ifndef GL_EXT_blend_equation_separate #define GL_EXT_blend_equation_separate 1 #define GL_BLEND_EQUATION_RGB_EXT 0x8009 #define GL_BLEND_EQUATION_ALPHA_EXT 0x883D typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); #define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT) #define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate) #endif /* GL_EXT_blend_equation_separate */ /* ----------------------- GL_EXT_blend_func_separate ---------------------- */ #ifndef GL_EXT_blend_func_separate #define GL_EXT_blend_func_separate 1 #define GL_BLEND_DST_RGB_EXT 0x80C8 #define GL_BLEND_SRC_RGB_EXT 0x80C9 #define GL_BLEND_DST_ALPHA_EXT 0x80CA #define GL_BLEND_SRC_ALPHA_EXT 0x80CB typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT) #define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate) #endif /* GL_EXT_blend_func_separate */ /* ------------------------- GL_EXT_blend_logic_op ------------------------- */ #ifndef GL_EXT_blend_logic_op #define GL_EXT_blend_logic_op 1 #define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op) #endif /* GL_EXT_blend_logic_op */ /* -------------------------- GL_EXT_blend_minmax -------------------------- */ #ifndef GL_EXT_blend_minmax #define GL_EXT_blend_minmax 1 #define GL_FUNC_ADD_EXT 0x8006 #define GL_MIN_EXT 0x8007 #define GL_MAX_EXT 0x8008 #define GL_BLEND_EQUATION_EXT 0x8009 typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT) #define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax) #endif /* GL_EXT_blend_minmax */ /* ------------------------- GL_EXT_blend_subtract ------------------------- */ #ifndef GL_EXT_blend_subtract #define GL_EXT_blend_subtract 1 #define GL_FUNC_SUBTRACT_EXT 0x800A #define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B #define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract) #endif /* GL_EXT_blend_subtract */ /* ------------------------ GL_EXT_clip_volume_hint ------------------------ */ #ifndef GL_EXT_clip_volume_hint #define GL_EXT_clip_volume_hint 1 #define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 #define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint) #endif /* GL_EXT_clip_volume_hint */ /* ------------------------------ GL_EXT_cmyka ----------------------------- */ #ifndef GL_EXT_cmyka #define GL_EXT_cmyka 1 #define GL_CMYK_EXT 0x800C #define GL_CMYKA_EXT 0x800D #define GL_PACK_CMYK_HINT_EXT 0x800E #define GL_UNPACK_CMYK_HINT_EXT 0x800F #define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka) #endif /* GL_EXT_cmyka */ /* ------------------------- GL_EXT_color_subtable ------------------------- */ #ifndef GL_EXT_color_subtable #define GL_EXT_color_subtable 1 typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void* data); typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT) #define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT) #define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable) #endif /* GL_EXT_color_subtable */ /* ---------------------- GL_EXT_compiled_vertex_array --------------------- */ #ifndef GL_EXT_compiled_vertex_array #define GL_EXT_compiled_vertex_array 1 #define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 #define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 typedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); #define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT) #define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT) #define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array) #endif /* GL_EXT_compiled_vertex_array */ /* --------------------------- GL_EXT_convolution -------------------------- */ #ifndef GL_EXT_convolution #define GL_EXT_convolution 1 #define GL_CONVOLUTION_1D_EXT 0x8010 #define GL_CONVOLUTION_2D_EXT 0x8011 #define GL_SEPARABLE_2D_EXT 0x8012 #define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 #define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 #define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 #define GL_REDUCE_EXT 0x8016 #define GL_CONVOLUTION_FORMAT_EXT 0x8017 #define GL_CONVOLUTION_WIDTH_EXT 0x8018 #define GL_CONVOLUTION_HEIGHT_EXT 0x8019 #define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A #define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B #define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C #define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D #define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E #define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F #define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 #define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 #define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 #define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* image); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* image); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* image); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* row, void* column, void* span); typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* row, const void* column); #define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT) #define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT) #define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT) #define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT) #define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT) #define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT) #define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT) #define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT) #define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT) #define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT) #define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT) #define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT) #define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT) #define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution) #endif /* GL_EXT_convolution */ /* ------------------------ GL_EXT_coordinate_frame ------------------------ */ #ifndef GL_EXT_coordinate_frame #define GL_EXT_coordinate_frame 1 #define GL_TANGENT_ARRAY_EXT 0x8439 #define GL_BINORMAL_ARRAY_EXT 0x843A #define GL_CURRENT_TANGENT_EXT 0x843B #define GL_CURRENT_BINORMAL_EXT 0x843C #define GL_TANGENT_ARRAY_TYPE_EXT 0x843E #define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F #define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 #define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 #define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 #define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 #define GL_MAP1_TANGENT_EXT 0x8444 #define GL_MAP2_TANGENT_EXT 0x8445 #define GL_MAP1_BINORMAL_EXT 0x8446 #define GL_MAP2_BINORMAL_EXT 0x8447 typedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); typedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); #define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT) #define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT) #define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame) #endif /* GL_EXT_coordinate_frame */ /* -------------------------- GL_EXT_copy_texture -------------------------- */ #ifndef GL_EXT_copy_texture #define GL_EXT_copy_texture 1 typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT) #define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT) #define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT) #define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT) #define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT) #define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture) #endif /* GL_EXT_copy_texture */ /* --------------------------- GL_EXT_cull_vertex -------------------------- */ #ifndef GL_EXT_cull_vertex #define GL_EXT_cull_vertex 1 #define GL_CULL_VERTEX_EXT 0x81AA #define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB #define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); #define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT) #define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT) #define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex) #endif /* GL_EXT_cull_vertex */ /* ------------------------ GL_EXT_depth_bounds_test ----------------------- */ #ifndef GL_EXT_depth_bounds_test #define GL_EXT_depth_bounds_test 1 #define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 #define GL_DEPTH_BOUNDS_EXT 0x8891 typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); #define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT) #define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test) #endif /* GL_EXT_depth_bounds_test */ /* ----------------------- GL_EXT_direct_state_access ---------------------- */ #ifndef GL_EXT_direct_state_access #define GL_EXT_direct_state_access 1 #define GL_PROGRAM_MATRIX_EXT 0x8E2D #define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E #define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F typedef void (GLAPIENTRY * PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); typedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); typedef void (GLAPIENTRY * PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (GLAPIENTRY * PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, void* img); typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, void* img); typedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void* pixels); typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void** params); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void* data); typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void* string); typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid** params); typedef void (GLAPIENTRY * PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, GLvoid** params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void* pixels); typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint* param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLvoid** param); typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, GLvoid** param); typedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); typedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (GLAPIENTRY * PFNGLMATRIXFRUSTUMEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); typedef void (GLAPIENTRY * PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum matrixMode); typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXLOADDEXTPROC) (GLenum matrixMode, const GLdouble* m); typedef void (GLAPIENTRY * PFNGLMATRIXLOADFEXTPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTDEXTPROC) (GLenum matrixMode, const GLdouble* m); typedef void (GLAPIENTRY * PFNGLMATRIXMULTFEXTPROC) (GLenum matrixMode, const GLfloat* m); typedef void (GLAPIENTRY * PFNGLMATRIXORTHOEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); typedef void (GLAPIENTRY * PFNGLMATRIXPOPEXTPROC) (GLenum matrixMode); typedef void (GLAPIENTRY * PFNGLMATRIXPUSHEXTPROC) (GLenum matrixMode); typedef void (GLAPIENTRY * PFNGLMATRIXROTATEDEXTPROC) (GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLMATRIXROTATEFEXTPROC) (GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLMATRIXSCALEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLMATRIXSCALEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void* pointer); typedef void (GLAPIENTRY * PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); typedef void (GLAPIENTRY * PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint* params); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* param); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* param); typedef void (GLAPIENTRY * PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void* data, GLenum usage); typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void* data); typedef void (GLAPIENTRY * PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint* params); typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void* string); typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint* params); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat* param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* param); typedef void (GLAPIENTRY * PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); #define glBindMultiTextureEXT GLEW_GET_FUN(__glewBindMultiTextureEXT) #define glCheckNamedFramebufferStatusEXT GLEW_GET_FUN(__glewCheckNamedFramebufferStatusEXT) #define glClientAttribDefaultEXT GLEW_GET_FUN(__glewClientAttribDefaultEXT) #define glCompressedMultiTexImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage1DEXT) #define glCompressedMultiTexImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage2DEXT) #define glCompressedMultiTexImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage3DEXT) #define glCompressedMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage1DEXT) #define glCompressedMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage2DEXT) #define glCompressedMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage3DEXT) #define glCompressedTextureImage1DEXT GLEW_GET_FUN(__glewCompressedTextureImage1DEXT) #define glCompressedTextureImage2DEXT GLEW_GET_FUN(__glewCompressedTextureImage2DEXT) #define glCompressedTextureImage3DEXT GLEW_GET_FUN(__glewCompressedTextureImage3DEXT) #define glCompressedTextureSubImage1DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage1DEXT) #define glCompressedTextureSubImage2DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage2DEXT) #define glCompressedTextureSubImage3DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage3DEXT) #define glCopyMultiTexImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexImage1DEXT) #define glCopyMultiTexImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexImage2DEXT) #define glCopyMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage1DEXT) #define glCopyMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage2DEXT) #define glCopyMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage3DEXT) #define glCopyTextureImage1DEXT GLEW_GET_FUN(__glewCopyTextureImage1DEXT) #define glCopyTextureImage2DEXT GLEW_GET_FUN(__glewCopyTextureImage2DEXT) #define glCopyTextureSubImage1DEXT GLEW_GET_FUN(__glewCopyTextureSubImage1DEXT) #define glCopyTextureSubImage2DEXT GLEW_GET_FUN(__glewCopyTextureSubImage2DEXT) #define glCopyTextureSubImage3DEXT GLEW_GET_FUN(__glewCopyTextureSubImage3DEXT) #define glDisableClientStateIndexedEXT GLEW_GET_FUN(__glewDisableClientStateIndexedEXT) #define glDisableClientStateiEXT GLEW_GET_FUN(__glewDisableClientStateiEXT) #define glDisableVertexArrayAttribEXT GLEW_GET_FUN(__glewDisableVertexArrayAttribEXT) #define glDisableVertexArrayEXT GLEW_GET_FUN(__glewDisableVertexArrayEXT) #define glEnableClientStateIndexedEXT GLEW_GET_FUN(__glewEnableClientStateIndexedEXT) #define glEnableClientStateiEXT GLEW_GET_FUN(__glewEnableClientStateiEXT) #define glEnableVertexArrayAttribEXT GLEW_GET_FUN(__glewEnableVertexArrayAttribEXT) #define glEnableVertexArrayEXT GLEW_GET_FUN(__glewEnableVertexArrayEXT) #define glFlushMappedNamedBufferRangeEXT GLEW_GET_FUN(__glewFlushMappedNamedBufferRangeEXT) #define glFramebufferDrawBufferEXT GLEW_GET_FUN(__glewFramebufferDrawBufferEXT) #define glFramebufferDrawBuffersEXT GLEW_GET_FUN(__glewFramebufferDrawBuffersEXT) #define glFramebufferReadBufferEXT GLEW_GET_FUN(__glewFramebufferReadBufferEXT) #define glGenerateMultiTexMipmapEXT GLEW_GET_FUN(__glewGenerateMultiTexMipmapEXT) #define glGenerateTextureMipmapEXT GLEW_GET_FUN(__glewGenerateTextureMipmapEXT) #define glGetCompressedMultiTexImageEXT GLEW_GET_FUN(__glewGetCompressedMultiTexImageEXT) #define glGetCompressedTextureImageEXT GLEW_GET_FUN(__glewGetCompressedTextureImageEXT) #define glGetDoubleIndexedvEXT GLEW_GET_FUN(__glewGetDoubleIndexedvEXT) #define glGetDoublei_vEXT GLEW_GET_FUN(__glewGetDoublei_vEXT) #define glGetFloatIndexedvEXT GLEW_GET_FUN(__glewGetFloatIndexedvEXT) #define glGetFloati_vEXT GLEW_GET_FUN(__glewGetFloati_vEXT) #define glGetFramebufferParameterivEXT GLEW_GET_FUN(__glewGetFramebufferParameterivEXT) #define glGetMultiTexEnvfvEXT GLEW_GET_FUN(__glewGetMultiTexEnvfvEXT) #define glGetMultiTexEnvivEXT GLEW_GET_FUN(__glewGetMultiTexEnvivEXT) #define glGetMultiTexGendvEXT GLEW_GET_FUN(__glewGetMultiTexGendvEXT) #define glGetMultiTexGenfvEXT GLEW_GET_FUN(__glewGetMultiTexGenfvEXT) #define glGetMultiTexGenivEXT GLEW_GET_FUN(__glewGetMultiTexGenivEXT) #define glGetMultiTexImageEXT GLEW_GET_FUN(__glewGetMultiTexImageEXT) #define glGetMultiTexLevelParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterfvEXT) #define glGetMultiTexLevelParameterivEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterivEXT) #define glGetMultiTexParameterIivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIivEXT) #define glGetMultiTexParameterIuivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIuivEXT) #define glGetMultiTexParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexParameterfvEXT) #define glGetMultiTexParameterivEXT GLEW_GET_FUN(__glewGetMultiTexParameterivEXT) #define glGetNamedBufferParameterivEXT GLEW_GET_FUN(__glewGetNamedBufferParameterivEXT) #define glGetNamedBufferPointervEXT GLEW_GET_FUN(__glewGetNamedBufferPointervEXT) #define glGetNamedBufferSubDataEXT GLEW_GET_FUN(__glewGetNamedBufferSubDataEXT) #define glGetNamedFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameterivEXT) #define glGetNamedProgramLocalParameterIivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIivEXT) #define glGetNamedProgramLocalParameterIuivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIuivEXT) #define glGetNamedProgramLocalParameterdvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterdvEXT) #define glGetNamedProgramLocalParameterfvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterfvEXT) #define glGetNamedProgramStringEXT GLEW_GET_FUN(__glewGetNamedProgramStringEXT) #define glGetNamedProgramivEXT GLEW_GET_FUN(__glewGetNamedProgramivEXT) #define glGetNamedRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetNamedRenderbufferParameterivEXT) #define glGetPointerIndexedvEXT GLEW_GET_FUN(__glewGetPointerIndexedvEXT) #define glGetPointeri_vEXT GLEW_GET_FUN(__glewGetPointeri_vEXT) #define glGetTextureImageEXT GLEW_GET_FUN(__glewGetTextureImageEXT) #define glGetTextureLevelParameterfvEXT GLEW_GET_FUN(__glewGetTextureLevelParameterfvEXT) #define glGetTextureLevelParameterivEXT GLEW_GET_FUN(__glewGetTextureLevelParameterivEXT) #define glGetTextureParameterIivEXT GLEW_GET_FUN(__glewGetTextureParameterIivEXT) #define glGetTextureParameterIuivEXT GLEW_GET_FUN(__glewGetTextureParameterIuivEXT) #define glGetTextureParameterfvEXT GLEW_GET_FUN(__glewGetTextureParameterfvEXT) #define glGetTextureParameterivEXT GLEW_GET_FUN(__glewGetTextureParameterivEXT) #define glGetVertexArrayIntegeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayIntegeri_vEXT) #define glGetVertexArrayIntegervEXT GLEW_GET_FUN(__glewGetVertexArrayIntegervEXT) #define glGetVertexArrayPointeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayPointeri_vEXT) #define glGetVertexArrayPointervEXT GLEW_GET_FUN(__glewGetVertexArrayPointervEXT) #define glMapNamedBufferEXT GLEW_GET_FUN(__glewMapNamedBufferEXT) #define glMapNamedBufferRangeEXT GLEW_GET_FUN(__glewMapNamedBufferRangeEXT) #define glMatrixFrustumEXT GLEW_GET_FUN(__glewMatrixFrustumEXT) #define glMatrixLoadIdentityEXT GLEW_GET_FUN(__glewMatrixLoadIdentityEXT) #define glMatrixLoadTransposedEXT GLEW_GET_FUN(__glewMatrixLoadTransposedEXT) #define glMatrixLoadTransposefEXT GLEW_GET_FUN(__glewMatrixLoadTransposefEXT) #define glMatrixLoaddEXT GLEW_GET_FUN(__glewMatrixLoaddEXT) #define glMatrixLoadfEXT GLEW_GET_FUN(__glewMatrixLoadfEXT) #define glMatrixMultTransposedEXT GLEW_GET_FUN(__glewMatrixMultTransposedEXT) #define glMatrixMultTransposefEXT GLEW_GET_FUN(__glewMatrixMultTransposefEXT) #define glMatrixMultdEXT GLEW_GET_FUN(__glewMatrixMultdEXT) #define glMatrixMultfEXT GLEW_GET_FUN(__glewMatrixMultfEXT) #define glMatrixOrthoEXT GLEW_GET_FUN(__glewMatrixOrthoEXT) #define glMatrixPopEXT GLEW_GET_FUN(__glewMatrixPopEXT) #define glMatrixPushEXT GLEW_GET_FUN(__glewMatrixPushEXT) #define glMatrixRotatedEXT GLEW_GET_FUN(__glewMatrixRotatedEXT) #define glMatrixRotatefEXT GLEW_GET_FUN(__glewMatrixRotatefEXT) #define glMatrixScaledEXT GLEW_GET_FUN(__glewMatrixScaledEXT) #define glMatrixScalefEXT GLEW_GET_FUN(__glewMatrixScalefEXT) #define glMatrixTranslatedEXT GLEW_GET_FUN(__glewMatrixTranslatedEXT) #define glMatrixTranslatefEXT GLEW_GET_FUN(__glewMatrixTranslatefEXT) #define glMultiTexBufferEXT GLEW_GET_FUN(__glewMultiTexBufferEXT) #define glMultiTexCoordPointerEXT GLEW_GET_FUN(__glewMultiTexCoordPointerEXT) #define glMultiTexEnvfEXT GLEW_GET_FUN(__glewMultiTexEnvfEXT) #define glMultiTexEnvfvEXT GLEW_GET_FUN(__glewMultiTexEnvfvEXT) #define glMultiTexEnviEXT GLEW_GET_FUN(__glewMultiTexEnviEXT) #define glMultiTexEnvivEXT GLEW_GET_FUN(__glewMultiTexEnvivEXT) #define glMultiTexGendEXT GLEW_GET_FUN(__glewMultiTexGendEXT) #define glMultiTexGendvEXT GLEW_GET_FUN(__glewMultiTexGendvEXT) #define glMultiTexGenfEXT GLEW_GET_FUN(__glewMultiTexGenfEXT) #define glMultiTexGenfvEXT GLEW_GET_FUN(__glewMultiTexGenfvEXT) #define glMultiTexGeniEXT GLEW_GET_FUN(__glewMultiTexGeniEXT) #define glMultiTexGenivEXT GLEW_GET_FUN(__glewMultiTexGenivEXT) #define glMultiTexImage1DEXT GLEW_GET_FUN(__glewMultiTexImage1DEXT) #define glMultiTexImage2DEXT GLEW_GET_FUN(__glewMultiTexImage2DEXT) #define glMultiTexImage3DEXT GLEW_GET_FUN(__glewMultiTexImage3DEXT) #define glMultiTexParameterIivEXT GLEW_GET_FUN(__glewMultiTexParameterIivEXT) #define glMultiTexParameterIuivEXT GLEW_GET_FUN(__glewMultiTexParameterIuivEXT) #define glMultiTexParameterfEXT GLEW_GET_FUN(__glewMultiTexParameterfEXT) #define glMultiTexParameterfvEXT GLEW_GET_FUN(__glewMultiTexParameterfvEXT) #define glMultiTexParameteriEXT GLEW_GET_FUN(__glewMultiTexParameteriEXT) #define glMultiTexParameterivEXT GLEW_GET_FUN(__glewMultiTexParameterivEXT) #define glMultiTexRenderbufferEXT GLEW_GET_FUN(__glewMultiTexRenderbufferEXT) #define glMultiTexSubImage1DEXT GLEW_GET_FUN(__glewMultiTexSubImage1DEXT) #define glMultiTexSubImage2DEXT GLEW_GET_FUN(__glewMultiTexSubImage2DEXT) #define glMultiTexSubImage3DEXT GLEW_GET_FUN(__glewMultiTexSubImage3DEXT) #define glNamedBufferDataEXT GLEW_GET_FUN(__glewNamedBufferDataEXT) #define glNamedBufferSubDataEXT GLEW_GET_FUN(__glewNamedBufferSubDataEXT) #define glNamedCopyBufferSubDataEXT GLEW_GET_FUN(__glewNamedCopyBufferSubDataEXT) #define glNamedFramebufferRenderbufferEXT GLEW_GET_FUN(__glewNamedFramebufferRenderbufferEXT) #define glNamedFramebufferTexture1DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture1DEXT) #define glNamedFramebufferTexture2DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture2DEXT) #define glNamedFramebufferTexture3DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture3DEXT) #define glNamedFramebufferTextureEXT GLEW_GET_FUN(__glewNamedFramebufferTextureEXT) #define glNamedFramebufferTextureFaceEXT GLEW_GET_FUN(__glewNamedFramebufferTextureFaceEXT) #define glNamedFramebufferTextureLayerEXT GLEW_GET_FUN(__glewNamedFramebufferTextureLayerEXT) #define glNamedProgramLocalParameter4dEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dEXT) #define glNamedProgramLocalParameter4dvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dvEXT) #define glNamedProgramLocalParameter4fEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fEXT) #define glNamedProgramLocalParameter4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fvEXT) #define glNamedProgramLocalParameterI4iEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4iEXT) #define glNamedProgramLocalParameterI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4ivEXT) #define glNamedProgramLocalParameterI4uiEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uiEXT) #define glNamedProgramLocalParameterI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uivEXT) #define glNamedProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameters4fvEXT) #define glNamedProgramLocalParametersI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4ivEXT) #define glNamedProgramLocalParametersI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4uivEXT) #define glNamedProgramStringEXT GLEW_GET_FUN(__glewNamedProgramStringEXT) #define glNamedRenderbufferStorageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageEXT) #define glNamedRenderbufferStorageMultisampleCoverageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleCoverageEXT) #define glNamedRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleEXT) #define glProgramUniform1fEXT GLEW_GET_FUN(__glewProgramUniform1fEXT) #define glProgramUniform1fvEXT GLEW_GET_FUN(__glewProgramUniform1fvEXT) #define glProgramUniform1iEXT GLEW_GET_FUN(__glewProgramUniform1iEXT) #define glProgramUniform1ivEXT GLEW_GET_FUN(__glewProgramUniform1ivEXT) #define glProgramUniform1uiEXT GLEW_GET_FUN(__glewProgramUniform1uiEXT) #define glProgramUniform1uivEXT GLEW_GET_FUN(__glewProgramUniform1uivEXT) #define glProgramUniform2fEXT GLEW_GET_FUN(__glewProgramUniform2fEXT) #define glProgramUniform2fvEXT GLEW_GET_FUN(__glewProgramUniform2fvEXT) #define glProgramUniform2iEXT GLEW_GET_FUN(__glewProgramUniform2iEXT) #define glProgramUniform2ivEXT GLEW_GET_FUN(__glewProgramUniform2ivEXT) #define glProgramUniform2uiEXT GLEW_GET_FUN(__glewProgramUniform2uiEXT) #define glProgramUniform2uivEXT GLEW_GET_FUN(__glewProgramUniform2uivEXT) #define glProgramUniform3fEXT GLEW_GET_FUN(__glewProgramUniform3fEXT) #define glProgramUniform3fvEXT GLEW_GET_FUN(__glewProgramUniform3fvEXT) #define glProgramUniform3iEXT GLEW_GET_FUN(__glewProgramUniform3iEXT) #define glProgramUniform3ivEXT GLEW_GET_FUN(__glewProgramUniform3ivEXT) #define glProgramUniform3uiEXT GLEW_GET_FUN(__glewProgramUniform3uiEXT) #define glProgramUniform3uivEXT GLEW_GET_FUN(__glewProgramUniform3uivEXT) #define glProgramUniform4fEXT GLEW_GET_FUN(__glewProgramUniform4fEXT) #define glProgramUniform4fvEXT GLEW_GET_FUN(__glewProgramUniform4fvEXT) #define glProgramUniform4iEXT GLEW_GET_FUN(__glewProgramUniform4iEXT) #define glProgramUniform4ivEXT GLEW_GET_FUN(__glewProgramUniform4ivEXT) #define glProgramUniform4uiEXT GLEW_GET_FUN(__glewProgramUniform4uiEXT) #define glProgramUniform4uivEXT GLEW_GET_FUN(__glewProgramUniform4uivEXT) #define glProgramUniformMatrix2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2fvEXT) #define glProgramUniformMatrix2x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3fvEXT) #define glProgramUniformMatrix2x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4fvEXT) #define glProgramUniformMatrix3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3fvEXT) #define glProgramUniformMatrix3x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2fvEXT) #define glProgramUniformMatrix3x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4fvEXT) #define glProgramUniformMatrix4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4fvEXT) #define glProgramUniformMatrix4x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2fvEXT) #define glProgramUniformMatrix4x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3fvEXT) #define glPushClientAttribDefaultEXT GLEW_GET_FUN(__glewPushClientAttribDefaultEXT) #define glTextureBufferEXT GLEW_GET_FUN(__glewTextureBufferEXT) #define glTextureImage1DEXT GLEW_GET_FUN(__glewTextureImage1DEXT) #define glTextureImage2DEXT GLEW_GET_FUN(__glewTextureImage2DEXT) #define glTextureImage3DEXT GLEW_GET_FUN(__glewTextureImage3DEXT) #define glTextureParameterIivEXT GLEW_GET_FUN(__glewTextureParameterIivEXT) #define glTextureParameterIuivEXT GLEW_GET_FUN(__glewTextureParameterIuivEXT) #define glTextureParameterfEXT GLEW_GET_FUN(__glewTextureParameterfEXT) #define glTextureParameterfvEXT GLEW_GET_FUN(__glewTextureParameterfvEXT) #define glTextureParameteriEXT GLEW_GET_FUN(__glewTextureParameteriEXT) #define glTextureParameterivEXT GLEW_GET_FUN(__glewTextureParameterivEXT) #define glTextureRenderbufferEXT GLEW_GET_FUN(__glewTextureRenderbufferEXT) #define glTextureSubImage1DEXT GLEW_GET_FUN(__glewTextureSubImage1DEXT) #define glTextureSubImage2DEXT GLEW_GET_FUN(__glewTextureSubImage2DEXT) #define glTextureSubImage3DEXT GLEW_GET_FUN(__glewTextureSubImage3DEXT) #define glUnmapNamedBufferEXT GLEW_GET_FUN(__glewUnmapNamedBufferEXT) #define glVertexArrayColorOffsetEXT GLEW_GET_FUN(__glewVertexArrayColorOffsetEXT) #define glVertexArrayEdgeFlagOffsetEXT GLEW_GET_FUN(__glewVertexArrayEdgeFlagOffsetEXT) #define glVertexArrayFogCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayFogCoordOffsetEXT) #define glVertexArrayIndexOffsetEXT GLEW_GET_FUN(__glewVertexArrayIndexOffsetEXT) #define glVertexArrayMultiTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayMultiTexCoordOffsetEXT) #define glVertexArrayNormalOffsetEXT GLEW_GET_FUN(__glewVertexArrayNormalOffsetEXT) #define glVertexArraySecondaryColorOffsetEXT GLEW_GET_FUN(__glewVertexArraySecondaryColorOffsetEXT) #define glVertexArrayTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayTexCoordOffsetEXT) #define glVertexArrayVertexAttribIOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIOffsetEXT) #define glVertexArrayVertexAttribOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribOffsetEXT) #define glVertexArrayVertexOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexOffsetEXT) #define GLEW_EXT_direct_state_access GLEW_GET_VAR(__GLEW_EXT_direct_state_access) #endif /* GL_EXT_direct_state_access */ /* -------------------------- GL_EXT_draw_buffers2 ------------------------- */ #ifndef GL_EXT_draw_buffers2 #define GL_EXT_draw_buffers2 1 typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a); typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum value, GLuint index, GLboolean* data); typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum value, GLuint index, GLint* data); typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); #define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT) #define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT) #define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT) #define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT) #define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT) #define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT) #define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2) #endif /* GL_EXT_draw_buffers2 */ /* ------------------------- GL_EXT_draw_instanced ------------------------- */ #ifndef GL_EXT_draw_instanced #define GL_EXT_draw_instanced 1 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); #define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT) #define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT) #define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced) #endif /* GL_EXT_draw_instanced */ /* ----------------------- GL_EXT_draw_range_elements ---------------------- */ #ifndef GL_EXT_draw_range_elements #define GL_EXT_draw_range_elements 1 #define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 #define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); #define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT) #define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements) #endif /* GL_EXT_draw_range_elements */ /* ---------------------------- GL_EXT_fog_coord --------------------------- */ #ifndef GL_EXT_fog_coord #define GL_EXT_fog_coord 1 #define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 #define GL_FOG_COORDINATE_EXT 0x8451 #define GL_FRAGMENT_DEPTH_EXT 0x8452 #define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 #define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 #define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 #define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 #define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); typedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); #define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT) #define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT) #define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT) #define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT) #define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT) #define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord) #endif /* GL_EXT_fog_coord */ /* ------------------------ GL_EXT_fragment_lighting ----------------------- */ #ifndef GL_EXT_fragment_lighting #define GL_EXT_fragment_lighting 1 #define GL_FRAGMENT_LIGHTING_EXT 0x8400 #define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401 #define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402 #define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403 #define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404 #define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405 #define GL_CURRENT_RASTER_NORMAL_EXT 0x8406 #define GL_LIGHT_ENV_MODE_EXT 0x8407 #define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408 #define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409 #define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A #define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B #define GL_FRAGMENT_LIGHT0_EXT 0x840C #define GL_FRAGMENT_LIGHT7_EXT 0x8413 typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param); #define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT) #define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT) #define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT) #define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT) #define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT) #define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT) #define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT) #define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT) #define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT) #define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT) #define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT) #define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT) #define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT) #define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT) #define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT) #define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT) #define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT) #define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT) #define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting) #endif /* GL_EXT_fragment_lighting */ /* ------------------------ GL_EXT_framebuffer_blit ------------------------ */ #ifndef GL_EXT_framebuffer_blit #define GL_EXT_framebuffer_blit 1 #define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 #define GL_READ_FRAMEBUFFER_EXT 0x8CA8 #define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 #define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT) #define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit) #endif /* GL_EXT_framebuffer_blit */ /* --------------------- GL_EXT_framebuffer_multisample -------------------- */ #ifndef GL_EXT_framebuffer_multisample #define GL_EXT_framebuffer_multisample 1 #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 #define GL_MAX_SAMPLES_EXT 0x8D57 typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT) #define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample) #endif /* GL_EXT_framebuffer_multisample */ /* --------------- GL_EXT_framebuffer_multisample_blit_scaled -------------- */ #ifndef GL_EXT_framebuffer_multisample_blit_scaled #define GL_EXT_framebuffer_multisample_blit_scaled 1 #define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA #define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB #define GLEW_EXT_framebuffer_multisample_blit_scaled GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample_blit_scaled) #endif /* GL_EXT_framebuffer_multisample_blit_scaled */ /* ----------------------- GL_EXT_framebuffer_object ----------------------- */ #ifndef GL_EXT_framebuffer_object #define GL_EXT_framebuffer_object 1 #define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 #define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 #define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 #define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 #define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC #define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD #define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 #define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 #define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 #define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 #define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 #define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 #define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 #define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 #define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 #define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 #define GL_COLOR_ATTACHMENT10_EXT 0x8CEA #define GL_COLOR_ATTACHMENT11_EXT 0x8CEB #define GL_COLOR_ATTACHMENT12_EXT 0x8CEC #define GL_COLOR_ATTACHMENT13_EXT 0x8CED #define GL_COLOR_ATTACHMENT14_EXT 0x8CEE #define GL_COLOR_ATTACHMENT15_EXT 0x8CEF #define GL_DEPTH_ATTACHMENT_EXT 0x8D00 #define GL_STENCIL_ATTACHMENT_EXT 0x8D20 #define GL_FRAMEBUFFER_EXT 0x8D40 #define GL_RENDERBUFFER_EXT 0x8D41 #define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 #define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 #define GL_STENCIL_INDEX1_EXT 0x8D46 #define GL_STENCIL_INDEX4_EXT 0x8D47 #define GL_STENCIL_INDEX8_EXT 0x8D48 #define GL_STENCIL_INDEX16_EXT 0x8D49 #define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); #define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT) #define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT) #define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT) #define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT) #define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT) #define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT) #define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT) #define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT) #define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT) #define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT) #define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT) #define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT) #define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT) #define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT) #define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT) #define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT) #define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT) #define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object) #endif /* GL_EXT_framebuffer_object */ /* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */ #ifndef GL_EXT_framebuffer_sRGB #define GL_EXT_framebuffer_sRGB 1 #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 #define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA #define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB) #endif /* GL_EXT_framebuffer_sRGB */ /* ------------------------ GL_EXT_geometry_shader4 ------------------------ */ #ifndef GL_EXT_geometry_shader4 #define GL_EXT_geometry_shader4 1 #define GL_LINES_ADJACENCY_EXT 0xA #define GL_LINE_STRIP_ADJACENCY_EXT 0xB #define GL_TRIANGLES_ADJACENCY_EXT 0xC #define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD #define GL_PROGRAM_POINT_SIZE_EXT 0x8642 #define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 #define GL_GEOMETRY_SHADER_EXT 0x8DD9 #define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA #define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB #define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC #define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD #define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); #define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT) #define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT) #define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT) #define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4) #endif /* GL_EXT_geometry_shader4 */ /* --------------------- GL_EXT_gpu_program_parameters --------------------- */ #ifndef GL_EXT_gpu_program_parameters #define GL_EXT_gpu_program_parameters 1 typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); #define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT) #define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT) #define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters) #endif /* GL_EXT_gpu_program_parameters */ /* --------------------------- GL_EXT_gpu_shader4 -------------------------- */ #ifndef GL_EXT_gpu_shader4 #define GL_EXT_gpu_shader4 1 #define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD #define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 #define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 #define GL_SAMPLER_BUFFER_EXT 0x8DC2 #define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 #define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 #define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 #define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 #define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 #define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 #define GL_INT_SAMPLER_1D_EXT 0x8DC9 #define GL_INT_SAMPLER_2D_EXT 0x8DCA #define GL_INT_SAMPLER_3D_EXT 0x8DCB #define GL_INT_SAMPLER_CUBE_EXT 0x8DCC #define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD #define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE #define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF #define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 #define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 #define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 #define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 #define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 #define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); typedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT) #define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT) #define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT) #define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT) #define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT) #define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT) #define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT) #define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT) #define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT) #define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT) #define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT) #define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT) #define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT) #define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT) #define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT) #define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT) #define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT) #define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT) #define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT) #define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT) #define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT) #define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT) #define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT) #define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT) #define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT) #define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT) #define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT) #define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT) #define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT) #define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT) #define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT) #define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT) #define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT) #define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT) #define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4) #endif /* GL_EXT_gpu_shader4 */ /* ---------------------------- GL_EXT_histogram --------------------------- */ #ifndef GL_EXT_histogram #define GL_EXT_histogram 1 #define GL_HISTOGRAM_EXT 0x8024 #define GL_PROXY_HISTOGRAM_EXT 0x8025 #define GL_HISTOGRAM_WIDTH_EXT 0x8026 #define GL_HISTOGRAM_FORMAT_EXT 0x8027 #define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 #define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 #define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A #define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B #define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C #define GL_HISTOGRAM_SINK_EXT 0x802D #define GL_MINMAX_EXT 0x802E #define GL_MINMAX_FORMAT_EXT 0x802F #define GL_MINMAX_SINK_EXT 0x8030 typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); typedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); #define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT) #define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT) #define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT) #define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT) #define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT) #define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT) #define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT) #define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT) #define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT) #define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT) #define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram) #endif /* GL_EXT_histogram */ /* ----------------------- GL_EXT_index_array_formats ---------------------- */ #ifndef GL_EXT_index_array_formats #define GL_EXT_index_array_formats 1 #define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats) #endif /* GL_EXT_index_array_formats */ /* --------------------------- GL_EXT_index_func --------------------------- */ #ifndef GL_EXT_index_func #define GL_EXT_index_func 1 typedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); #define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT) #define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func) #endif /* GL_EXT_index_func */ /* ------------------------- GL_EXT_index_material ------------------------- */ #ifndef GL_EXT_index_material #define GL_EXT_index_material 1 typedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); #define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT) #define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material) #endif /* GL_EXT_index_material */ /* -------------------------- GL_EXT_index_texture ------------------------- */ #ifndef GL_EXT_index_texture #define GL_EXT_index_texture 1 #define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture) #endif /* GL_EXT_index_texture */ /* -------------------------- GL_EXT_light_texture ------------------------- */ #ifndef GL_EXT_light_texture #define GL_EXT_light_texture 1 #define GL_FRAGMENT_MATERIAL_EXT 0x8349 #define GL_FRAGMENT_NORMAL_EXT 0x834A #define GL_FRAGMENT_COLOR_EXT 0x834C #define GL_ATTENUATION_EXT 0x834D #define GL_SHADOW_ATTENUATION_EXT 0x834E #define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F #define GL_TEXTURE_LIGHT_EXT 0x8350 #define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 #define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 #define GL_FRAGMENT_DEPTH_EXT 0x8452 typedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); typedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); typedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); #define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT) #define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT) #define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT) #define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture) #endif /* GL_EXT_light_texture */ /* ------------------------- GL_EXT_misc_attribute ------------------------- */ #ifndef GL_EXT_misc_attribute #define GL_EXT_misc_attribute 1 #define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute) #endif /* GL_EXT_misc_attribute */ /* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */ #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const GLvoid **indices, GLsizei primcount); #define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT) #define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT) #define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays) #endif /* GL_EXT_multi_draw_arrays */ /* --------------------------- GL_EXT_multisample -------------------------- */ #ifndef GL_EXT_multisample #define GL_EXT_multisample 1 #define GL_MULTISAMPLE_EXT 0x809D #define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F #define GL_SAMPLE_MASK_EXT 0x80A0 #define GL_1PASS_EXT 0x80A1 #define GL_2PASS_0_EXT 0x80A2 #define GL_2PASS_1_EXT 0x80A3 #define GL_4PASS_0_EXT 0x80A4 #define GL_4PASS_1_EXT 0x80A5 #define GL_4PASS_2_EXT 0x80A6 #define GL_4PASS_3_EXT 0x80A7 #define GL_SAMPLE_BUFFERS_EXT 0x80A8 #define GL_SAMPLES_EXT 0x80A9 #define GL_SAMPLE_MASK_VALUE_EXT 0x80AA #define GL_SAMPLE_MASK_INVERT_EXT 0x80AB #define GL_SAMPLE_PATTERN_EXT 0x80AC #define GL_MULTISAMPLE_BIT_EXT 0x20000000 typedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); #define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT) #define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT) #define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample) #endif /* GL_EXT_multisample */ /* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */ #ifndef GL_EXT_packed_depth_stencil #define GL_EXT_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_EXT 0x84F9 #define GL_UNSIGNED_INT_24_8_EXT 0x84FA #define GL_DEPTH24_STENCIL8_EXT 0x88F0 #define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 #define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil) #endif /* GL_EXT_packed_depth_stencil */ /* -------------------------- GL_EXT_packed_float -------------------------- */ #ifndef GL_EXT_packed_float #define GL_EXT_packed_float 1 #define GL_R11F_G11F_B10F_EXT 0x8C3A #define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B #define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C #define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float) #endif /* GL_EXT_packed_float */ /* -------------------------- GL_EXT_packed_pixels ------------------------- */ #ifndef GL_EXT_packed_pixels #define GL_EXT_packed_pixels 1 #define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 #define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 #define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 #define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels) #endif /* GL_EXT_packed_pixels */ /* ------------------------ GL_EXT_paletted_texture ------------------------ */ #ifndef GL_EXT_paletted_texture #define GL_EXT_paletted_texture 1 #define GL_TEXTURE_1D 0x0DE0 #define GL_TEXTURE_2D 0x0DE1 #define GL_PROXY_TEXTURE_1D 0x8063 #define GL_PROXY_TEXTURE_2D 0x8064 #define GL_TEXTURE_3D_EXT 0x806F #define GL_PROXY_TEXTURE_3D_EXT 0x8070 #define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 #define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 #define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF #define GL_COLOR_INDEX1_EXT 0x80E2 #define GL_COLOR_INDEX2_EXT 0x80E3 #define GL_COLOR_INDEX4_EXT 0x80E4 #define GL_COLOR_INDEX8_EXT 0x80E5 #define GL_COLOR_INDEX12_EXT 0x80E6 #define GL_COLOR_INDEX16_EXT 0x80E7 #define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED #define GL_TEXTURE_CUBE_MAP_ARB 0x8513 #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B typedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void* data); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void* data); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); #define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT) #define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT) #define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT) #define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT) #define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture) #endif /* GL_EXT_paletted_texture */ /* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */ #ifndef GL_EXT_pixel_buffer_object #define GL_EXT_pixel_buffer_object 1 #define GL_PIXEL_PACK_BUFFER_EXT 0x88EB #define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF #define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object) #endif /* GL_EXT_pixel_buffer_object */ /* ------------------------- GL_EXT_pixel_transform ------------------------ */ #ifndef GL_EXT_pixel_transform #define GL_EXT_pixel_transform 1 #define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 #define GL_PIXEL_MAG_FILTER_EXT 0x8331 #define GL_PIXEL_MIN_FILTER_EXT 0x8332 #define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 #define GL_CUBIC_EXT 0x8334 #define GL_AVERAGE_EXT 0x8335 #define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 #define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 #define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param); typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param); typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); #define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT) #define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT) #define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT) #define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT) #define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT) #define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT) #define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform) #endif /* GL_EXT_pixel_transform */ /* ------------------- GL_EXT_pixel_transform_color_table ------------------ */ #ifndef GL_EXT_pixel_transform_color_table #define GL_EXT_pixel_transform_color_table 1 #define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table) #endif /* GL_EXT_pixel_transform_color_table */ /* ------------------------ GL_EXT_point_parameters ------------------------ */ #ifndef GL_EXT_point_parameters #define GL_EXT_point_parameters 1 #define GL_POINT_SIZE_MIN_EXT 0x8126 #define GL_POINT_SIZE_MAX_EXT 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 #define GL_DISTANCE_ATTENUATION_EXT 0x8129 typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat* params); #define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT) #define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT) #define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters) #endif /* GL_EXT_point_parameters */ /* ------------------------- GL_EXT_polygon_offset ------------------------- */ #ifndef GL_EXT_polygon_offset #define GL_EXT_polygon_offset 1 #define GL_POLYGON_OFFSET_EXT 0x8037 #define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 #define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); #define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT) #define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset) #endif /* GL_EXT_polygon_offset */ /* ------------------------ GL_EXT_provoking_vertex ------------------------ */ #ifndef GL_EXT_provoking_vertex #define GL_EXT_provoking_vertex 1 #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C #define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D #define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E #define GL_PROVOKING_VERTEX_EXT 0x8E4F typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); #define glProvokingVertexEXT GLEW_GET_FUN(__glewProvokingVertexEXT) #define GLEW_EXT_provoking_vertex GLEW_GET_VAR(__GLEW_EXT_provoking_vertex) #endif /* GL_EXT_provoking_vertex */ /* ------------------------- GL_EXT_rescale_normal ------------------------- */ #ifndef GL_EXT_rescale_normal #define GL_EXT_rescale_normal 1 #define GL_RESCALE_NORMAL_EXT 0x803A #define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal) #endif /* GL_EXT_rescale_normal */ /* -------------------------- GL_EXT_scene_marker -------------------------- */ #ifndef GL_EXT_scene_marker #define GL_EXT_scene_marker 1 typedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void); typedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void); #define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT) #define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT) #define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker) #endif /* GL_EXT_scene_marker */ /* ------------------------- GL_EXT_secondary_color ------------------------ */ #ifndef GL_EXT_secondary_color #define GL_EXT_secondary_color 1 #define GL_COLOR_SUM_EXT 0x8458 #define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 #define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A #define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B #define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C #define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D #define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT) #define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT) #define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT) #define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT) #define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT) #define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT) #define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT) #define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT) #define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT) #define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT) #define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT) #define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT) #define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT) #define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT) #define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT) #define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT) #define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT) #define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color) #endif /* GL_EXT_secondary_color */ /* --------------------- GL_EXT_separate_shader_objects -------------------- */ #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8B8D typedef void (GLAPIENTRY * PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const char* string); typedef void (GLAPIENTRY * PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); #define glActiveProgramEXT GLEW_GET_FUN(__glewActiveProgramEXT) #define glCreateShaderProgramEXT GLEW_GET_FUN(__glewCreateShaderProgramEXT) #define glUseShaderProgramEXT GLEW_GET_FUN(__glewUseShaderProgramEXT) #define GLEW_EXT_separate_shader_objects GLEW_GET_VAR(__GLEW_EXT_separate_shader_objects) #endif /* GL_EXT_separate_shader_objects */ /* --------------------- GL_EXT_separate_specular_color -------------------- */ #ifndef GL_EXT_separate_specular_color #define GL_EXT_separate_specular_color 1 #define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 #define GL_SINGLE_COLOR_EXT 0x81F9 #define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA #define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color) #endif /* GL_EXT_separate_specular_color */ /* --------------------- GL_EXT_shader_image_load_store -------------------- */ #ifndef GL_EXT_shader_image_load_store #define GL_EXT_shader_image_load_store 1 #define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 #define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 #define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 #define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 #define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 #define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 #define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 #define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 #define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 #define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 #define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 #define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 #define GL_MAX_IMAGE_UNITS_EXT 0x8F38 #define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 #define GL_IMAGE_BINDING_NAME_EXT 0x8F3A #define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B #define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C #define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D #define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E #define GL_IMAGE_1D_EXT 0x904C #define GL_IMAGE_2D_EXT 0x904D #define GL_IMAGE_3D_EXT 0x904E #define GL_IMAGE_2D_RECT_EXT 0x904F #define GL_IMAGE_CUBE_EXT 0x9050 #define GL_IMAGE_BUFFER_EXT 0x9051 #define GL_IMAGE_1D_ARRAY_EXT 0x9052 #define GL_IMAGE_2D_ARRAY_EXT 0x9053 #define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 #define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 #define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 #define GL_INT_IMAGE_1D_EXT 0x9057 #define GL_INT_IMAGE_2D_EXT 0x9058 #define GL_INT_IMAGE_3D_EXT 0x9059 #define GL_INT_IMAGE_2D_RECT_EXT 0x905A #define GL_INT_IMAGE_CUBE_EXT 0x905B #define GL_INT_IMAGE_BUFFER_EXT 0x905C #define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D #define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E #define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F #define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 #define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 #define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 #define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 #define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 #define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 #define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C #define GL_MAX_IMAGE_SAMPLES_EXT 0x906D #define GL_IMAGE_BINDING_FORMAT_EXT 0x906E #define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); typedef void (GLAPIENTRY * PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); #define glBindImageTextureEXT GLEW_GET_FUN(__glewBindImageTextureEXT) #define glMemoryBarrierEXT GLEW_GET_FUN(__glewMemoryBarrierEXT) #define GLEW_EXT_shader_image_load_store GLEW_GET_VAR(__GLEW_EXT_shader_image_load_store) #endif /* GL_EXT_shader_image_load_store */ /* -------------------------- GL_EXT_shadow_funcs -------------------------- */ #ifndef GL_EXT_shadow_funcs #define GL_EXT_shadow_funcs 1 #define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs) #endif /* GL_EXT_shadow_funcs */ /* --------------------- GL_EXT_shared_texture_palette --------------------- */ #ifndef GL_EXT_shared_texture_palette #define GL_EXT_shared_texture_palette 1 #define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB #define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette) #endif /* GL_EXT_shared_texture_palette */ /* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */ #ifndef GL_EXT_stencil_clear_tag #define GL_EXT_stencil_clear_tag 1 #define GL_STENCIL_TAG_BITS_EXT 0x88F2 #define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 #define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag) #endif /* GL_EXT_stencil_clear_tag */ /* ------------------------ GL_EXT_stencil_two_side ------------------------ */ #ifndef GL_EXT_stencil_two_side #define GL_EXT_stencil_two_side 1 #define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 #define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 typedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); #define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT) #define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side) #endif /* GL_EXT_stencil_two_side */ /* -------------------------- GL_EXT_stencil_wrap -------------------------- */ #ifndef GL_EXT_stencil_wrap #define GL_EXT_stencil_wrap 1 #define GL_INCR_WRAP_EXT 0x8507 #define GL_DECR_WRAP_EXT 0x8508 #define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap) #endif /* GL_EXT_stencil_wrap */ /* --------------------------- GL_EXT_subtexture --------------------------- */ #ifndef GL_EXT_subtexture #define GL_EXT_subtexture 1 typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); #define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT) #define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT) #define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT) #define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture) #endif /* GL_EXT_subtexture */ /* ----------------------------- GL_EXT_texture ---------------------------- */ #ifndef GL_EXT_texture #define GL_EXT_texture 1 #define GL_ALPHA4_EXT 0x803B #define GL_ALPHA8_EXT 0x803C #define GL_ALPHA12_EXT 0x803D #define GL_ALPHA16_EXT 0x803E #define GL_LUMINANCE4_EXT 0x803F #define GL_LUMINANCE8_EXT 0x8040 #define GL_LUMINANCE12_EXT 0x8041 #define GL_LUMINANCE16_EXT 0x8042 #define GL_LUMINANCE4_ALPHA4_EXT 0x8043 #define GL_LUMINANCE6_ALPHA2_EXT 0x8044 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045 #define GL_LUMINANCE12_ALPHA4_EXT 0x8046 #define GL_LUMINANCE12_ALPHA12_EXT 0x8047 #define GL_LUMINANCE16_ALPHA16_EXT 0x8048 #define GL_INTENSITY_EXT 0x8049 #define GL_INTENSITY4_EXT 0x804A #define GL_INTENSITY8_EXT 0x804B #define GL_INTENSITY12_EXT 0x804C #define GL_INTENSITY16_EXT 0x804D #define GL_RGB2_EXT 0x804E #define GL_RGB4_EXT 0x804F #define GL_RGB5_EXT 0x8050 #define GL_RGB8_EXT 0x8051 #define GL_RGB10_EXT 0x8052 #define GL_RGB12_EXT 0x8053 #define GL_RGB16_EXT 0x8054 #define GL_RGBA2_EXT 0x8055 #define GL_RGBA4_EXT 0x8056 #define GL_RGB5_A1_EXT 0x8057 #define GL_RGBA8_EXT 0x8058 #define GL_RGB10_A2_EXT 0x8059 #define GL_RGBA12_EXT 0x805A #define GL_RGBA16_EXT 0x805B #define GL_TEXTURE_RED_SIZE_EXT 0x805C #define GL_TEXTURE_GREEN_SIZE_EXT 0x805D #define GL_TEXTURE_BLUE_SIZE_EXT 0x805E #define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F #define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 #define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 #define GL_REPLACE_EXT 0x8062 #define GL_PROXY_TEXTURE_1D_EXT 0x8063 #define GL_PROXY_TEXTURE_2D_EXT 0x8064 #define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture) #endif /* GL_EXT_texture */ /* ---------------------------- GL_EXT_texture3D --------------------------- */ #ifndef GL_EXT_texture3D #define GL_EXT_texture3D 1 #define GL_PACK_SKIP_IMAGES_EXT 0x806B #define GL_PACK_IMAGE_HEIGHT_EXT 0x806C #define GL_UNPACK_SKIP_IMAGES_EXT 0x806D #define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E #define GL_TEXTURE_3D_EXT 0x806F #define GL_PROXY_TEXTURE_3D_EXT 0x8070 #define GL_TEXTURE_DEPTH_EXT 0x8071 #define GL_TEXTURE_WRAP_R_EXT 0x8072 #define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); #define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT) #define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D) #endif /* GL_EXT_texture3D */ /* -------------------------- GL_EXT_texture_array ------------------------- */ #ifndef GL_EXT_texture_array #define GL_EXT_texture_array 1 #define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E #define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF #define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 #define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 #define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A #define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B #define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C #define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); #define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT) #define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array) #endif /* GL_EXT_texture_array */ /* ---------------------- GL_EXT_texture_buffer_object --------------------- */ #ifndef GL_EXT_texture_buffer_object #define GL_EXT_texture_buffer_object 1 #define GL_TEXTURE_BUFFER_EXT 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B #define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D #define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E typedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); #define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT) #define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object) #endif /* GL_EXT_texture_buffer_object */ /* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */ #ifndef GL_EXT_texture_compression_dxt1 #define GL_EXT_texture_compression_dxt1 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1) #endif /* GL_EXT_texture_compression_dxt1 */ /* -------------------- GL_EXT_texture_compression_latc -------------------- */ #ifndef GL_EXT_texture_compression_latc #define GL_EXT_texture_compression_latc 1 #define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 #define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 #define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 #define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 #define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc) #endif /* GL_EXT_texture_compression_latc */ /* -------------------- GL_EXT_texture_compression_rgtc -------------------- */ #ifndef GL_EXT_texture_compression_rgtc #define GL_EXT_texture_compression_rgtc 1 #define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB #define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC #define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD #define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE #define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc) #endif /* GL_EXT_texture_compression_rgtc */ /* -------------------- GL_EXT_texture_compression_s3tc -------------------- */ #ifndef GL_EXT_texture_compression_s3tc #define GL_EXT_texture_compression_s3tc 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 #define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc) #endif /* GL_EXT_texture_compression_s3tc */ /* ------------------------ GL_EXT_texture_cube_map ------------------------ */ #ifndef GL_EXT_texture_cube_map #define GL_EXT_texture_cube_map 1 #define GL_NORMAL_MAP_EXT 0x8511 #define GL_REFLECTION_MAP_EXT 0x8512 #define GL_TEXTURE_CUBE_MAP_EXT 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C #define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map) #endif /* GL_EXT_texture_cube_map */ /* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */ #ifndef GL_EXT_texture_edge_clamp #define GL_EXT_texture_edge_clamp 1 #define GL_CLAMP_TO_EDGE_EXT 0x812F #define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp) #endif /* GL_EXT_texture_edge_clamp */ /* --------------------------- GL_EXT_texture_env -------------------------- */ #ifndef GL_EXT_texture_env #define GL_EXT_texture_env 1 #define GL_TEXTURE_ENV0_EXT 0 #define GL_ENV_BLEND_EXT 0 #define GL_TEXTURE_ENV_SHIFT_EXT 0 #define GL_ENV_REPLACE_EXT 0 #define GL_ENV_ADD_EXT 0 #define GL_ENV_SUBTRACT_EXT 0 #define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0 #define GL_ENV_REVERSE_SUBTRACT_EXT 0 #define GL_ENV_REVERSE_BLEND_EXT 0 #define GL_ENV_COPY_EXT 0 #define GL_ENV_MODULATE_EXT 0 #define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env) #endif /* GL_EXT_texture_env */ /* ------------------------- GL_EXT_texture_env_add ------------------------ */ #ifndef GL_EXT_texture_env_add #define GL_EXT_texture_env_add 1 #define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add) #endif /* GL_EXT_texture_env_add */ /* ----------------------- GL_EXT_texture_env_combine ---------------------- */ #ifndef GL_EXT_texture_env_combine #define GL_EXT_texture_env_combine 1 #define GL_COMBINE_EXT 0x8570 #define GL_COMBINE_RGB_EXT 0x8571 #define GL_COMBINE_ALPHA_EXT 0x8572 #define GL_RGB_SCALE_EXT 0x8573 #define GL_ADD_SIGNED_EXT 0x8574 #define GL_INTERPOLATE_EXT 0x8575 #define GL_CONSTANT_EXT 0x8576 #define GL_PRIMARY_COLOR_EXT 0x8577 #define GL_PREVIOUS_EXT 0x8578 #define GL_SOURCE0_RGB_EXT 0x8580 #define GL_SOURCE1_RGB_EXT 0x8581 #define GL_SOURCE2_RGB_EXT 0x8582 #define GL_SOURCE0_ALPHA_EXT 0x8588 #define GL_SOURCE1_ALPHA_EXT 0x8589 #define GL_SOURCE2_ALPHA_EXT 0x858A #define GL_OPERAND0_RGB_EXT 0x8590 #define GL_OPERAND1_RGB_EXT 0x8591 #define GL_OPERAND2_RGB_EXT 0x8592 #define GL_OPERAND0_ALPHA_EXT 0x8598 #define GL_OPERAND1_ALPHA_EXT 0x8599 #define GL_OPERAND2_ALPHA_EXT 0x859A #define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine) #endif /* GL_EXT_texture_env_combine */ /* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */ #ifndef GL_EXT_texture_env_dot3 #define GL_EXT_texture_env_dot3 1 #define GL_DOT3_RGB_EXT 0x8740 #define GL_DOT3_RGBA_EXT 0x8741 #define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3) #endif /* GL_EXT_texture_env_dot3 */ /* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */ #ifndef GL_EXT_texture_filter_anisotropic #define GL_EXT_texture_filter_anisotropic 1 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF #define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic) #endif /* GL_EXT_texture_filter_anisotropic */ /* ------------------------- GL_EXT_texture_integer ------------------------ */ #ifndef GL_EXT_texture_integer #define GL_EXT_texture_integer 1 #define GL_RGBA32UI_EXT 0x8D70 #define GL_RGB32UI_EXT 0x8D71 #define GL_ALPHA32UI_EXT 0x8D72 #define GL_INTENSITY32UI_EXT 0x8D73 #define GL_LUMINANCE32UI_EXT 0x8D74 #define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 #define GL_RGBA16UI_EXT 0x8D76 #define GL_RGB16UI_EXT 0x8D77 #define GL_ALPHA16UI_EXT 0x8D78 #define GL_INTENSITY16UI_EXT 0x8D79 #define GL_LUMINANCE16UI_EXT 0x8D7A #define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B #define GL_RGBA8UI_EXT 0x8D7C #define GL_RGB8UI_EXT 0x8D7D #define GL_ALPHA8UI_EXT 0x8D7E #define GL_INTENSITY8UI_EXT 0x8D7F #define GL_LUMINANCE8UI_EXT 0x8D80 #define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 #define GL_RGBA32I_EXT 0x8D82 #define GL_RGB32I_EXT 0x8D83 #define GL_ALPHA32I_EXT 0x8D84 #define GL_INTENSITY32I_EXT 0x8D85 #define GL_LUMINANCE32I_EXT 0x8D86 #define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 #define GL_RGBA16I_EXT 0x8D88 #define GL_RGB16I_EXT 0x8D89 #define GL_ALPHA16I_EXT 0x8D8A #define GL_INTENSITY16I_EXT 0x8D8B #define GL_LUMINANCE16I_EXT 0x8D8C #define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D #define GL_RGBA8I_EXT 0x8D8E #define GL_RGB8I_EXT 0x8D8F #define GL_ALPHA8I_EXT 0x8D90 #define GL_INTENSITY8I_EXT 0x8D91 #define GL_LUMINANCE8I_EXT 0x8D92 #define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 #define GL_RED_INTEGER_EXT 0x8D94 #define GL_GREEN_INTEGER_EXT 0x8D95 #define GL_BLUE_INTEGER_EXT 0x8D96 #define GL_ALPHA_INTEGER_EXT 0x8D97 #define GL_RGB_INTEGER_EXT 0x8D98 #define GL_RGBA_INTEGER_EXT 0x8D99 #define GL_BGR_INTEGER_EXT 0x8D9A #define GL_BGRA_INTEGER_EXT 0x8D9B #define GL_LUMINANCE_INTEGER_EXT 0x8D9C #define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D #define GL_RGBA_INTEGER_MODE_EXT 0x8D9E typedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); typedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); #define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT) #define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT) #define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT) #define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT) #define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT) #define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT) #define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer) #endif /* GL_EXT_texture_integer */ /* ------------------------ GL_EXT_texture_lod_bias ------------------------ */ #ifndef GL_EXT_texture_lod_bias #define GL_EXT_texture_lod_bias 1 #define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD #define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 #define GL_TEXTURE_LOD_BIAS_EXT 0x8501 #define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias) #endif /* GL_EXT_texture_lod_bias */ /* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */ #ifndef GL_EXT_texture_mirror_clamp #define GL_EXT_texture_mirror_clamp 1 #define GL_MIRROR_CLAMP_EXT 0x8742 #define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 #define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 #define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp) #endif /* GL_EXT_texture_mirror_clamp */ /* ------------------------- GL_EXT_texture_object ------------------------- */ #ifndef GL_EXT_texture_object #define GL_EXT_texture_object 1 #define GL_TEXTURE_PRIORITY_EXT 0x8066 #define GL_TEXTURE_RESIDENT_EXT 0x8067 #define GL_TEXTURE_1D_BINDING_EXT 0x8068 #define GL_TEXTURE_2D_BINDING_EXT 0x8069 #define GL_TEXTURE_3D_BINDING_EXT 0x806A typedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences); typedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); typedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures); typedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures); typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); typedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities); #define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT) #define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT) #define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT) #define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT) #define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT) #define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT) #define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object) #endif /* GL_EXT_texture_object */ /* --------------------- GL_EXT_texture_perturb_normal --------------------- */ #ifndef GL_EXT_texture_perturb_normal #define GL_EXT_texture_perturb_normal 1 #define GL_PERTURB_EXT 0x85AE #define GL_TEXTURE_NORMAL_EXT 0x85AF typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); #define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT) #define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal) #endif /* GL_EXT_texture_perturb_normal */ /* ------------------------ GL_EXT_texture_rectangle ----------------------- */ #ifndef GL_EXT_texture_rectangle #define GL_EXT_texture_rectangle 1 #define GL_TEXTURE_RECTANGLE_EXT 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 #define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle) #endif /* GL_EXT_texture_rectangle */ /* -------------------------- GL_EXT_texture_sRGB -------------------------- */ #ifndef GL_EXT_texture_sRGB #define GL_EXT_texture_sRGB 1 #define GL_SRGB_EXT 0x8C40 #define GL_SRGB8_EXT 0x8C41 #define GL_SRGB_ALPHA_EXT 0x8C42 #define GL_SRGB8_ALPHA8_EXT 0x8C43 #define GL_SLUMINANCE_ALPHA_EXT 0x8C44 #define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 #define GL_SLUMINANCE_EXT 0x8C46 #define GL_SLUMINANCE8_EXT 0x8C47 #define GL_COMPRESSED_SRGB_EXT 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 #define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B #define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F #define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB) #endif /* GL_EXT_texture_sRGB */ /* ----------------------- GL_EXT_texture_sRGB_decode ---------------------- */ #ifndef GL_EXT_texture_sRGB_decode #define GL_EXT_texture_sRGB_decode 1 #define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 #define GL_DECODE_EXT 0x8A49 #define GL_SKIP_DECODE_EXT 0x8A4A #define GLEW_EXT_texture_sRGB_decode GLEW_GET_VAR(__GLEW_EXT_texture_sRGB_decode) #endif /* GL_EXT_texture_sRGB_decode */ /* --------------------- GL_EXT_texture_shared_exponent -------------------- */ #ifndef GL_EXT_texture_shared_exponent #define GL_EXT_texture_shared_exponent 1 #define GL_RGB9_E5_EXT 0x8C3D #define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E #define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F #define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent) #endif /* GL_EXT_texture_shared_exponent */ /* -------------------------- GL_EXT_texture_snorm ------------------------- */ #ifndef GL_EXT_texture_snorm #define GL_EXT_texture_snorm 1 #define GL_RED_SNORM 0x8F90 #define GL_RG_SNORM 0x8F91 #define GL_RGB_SNORM 0x8F92 #define GL_RGBA_SNORM 0x8F93 #define GL_R8_SNORM 0x8F94 #define GL_RG8_SNORM 0x8F95 #define GL_RGB8_SNORM 0x8F96 #define GL_RGBA8_SNORM 0x8F97 #define GL_R16_SNORM 0x8F98 #define GL_RG16_SNORM 0x8F99 #define GL_RGB16_SNORM 0x8F9A #define GL_RGBA16_SNORM 0x8F9B #define GL_SIGNED_NORMALIZED 0x8F9C #define GL_ALPHA_SNORM 0x9010 #define GL_LUMINANCE_SNORM 0x9011 #define GL_LUMINANCE_ALPHA_SNORM 0x9012 #define GL_INTENSITY_SNORM 0x9013 #define GL_ALPHA8_SNORM 0x9014 #define GL_LUMINANCE8_SNORM 0x9015 #define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 #define GL_INTENSITY8_SNORM 0x9017 #define GL_ALPHA16_SNORM 0x9018 #define GL_LUMINANCE16_SNORM 0x9019 #define GL_LUMINANCE16_ALPHA16_SNORM 0x901A #define GL_INTENSITY16_SNORM 0x901B #define GLEW_EXT_texture_snorm GLEW_GET_VAR(__GLEW_EXT_texture_snorm) #endif /* GL_EXT_texture_snorm */ /* ------------------------- GL_EXT_texture_swizzle ------------------------ */ #ifndef GL_EXT_texture_swizzle #define GL_EXT_texture_swizzle 1 #define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 #define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 #define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 #define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 #define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 #define GLEW_EXT_texture_swizzle GLEW_GET_VAR(__GLEW_EXT_texture_swizzle) #endif /* GL_EXT_texture_swizzle */ /* --------------------------- GL_EXT_timer_query -------------------------- */ #ifndef GL_EXT_timer_query #define GL_EXT_timer_query 1 #define GL_TIME_ELAPSED_EXT 0x88BF typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); #define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT) #define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT) #define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query) #endif /* GL_EXT_timer_query */ /* ----------------------- GL_EXT_transform_feedback ----------------------- */ #ifndef GL_EXT_transform_feedback #define GL_EXT_transform_feedback 1 #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 #define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 #define GL_PRIMITIVES_GENERATED_EXT 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 #define GL_RASTERIZER_DISCARD_EXT 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B #define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C #define GL_SEPARATE_ATTRIBS_EXT 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei *size, GLenum *type, char *name); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const char ** varyings, GLenum bufferMode); #define glBeginTransformFeedbackEXT GLEW_GET_FUN(__glewBeginTransformFeedbackEXT) #define glBindBufferBaseEXT GLEW_GET_FUN(__glewBindBufferBaseEXT) #define glBindBufferOffsetEXT GLEW_GET_FUN(__glewBindBufferOffsetEXT) #define glBindBufferRangeEXT GLEW_GET_FUN(__glewBindBufferRangeEXT) #define glEndTransformFeedbackEXT GLEW_GET_FUN(__glewEndTransformFeedbackEXT) #define glGetTransformFeedbackVaryingEXT GLEW_GET_FUN(__glewGetTransformFeedbackVaryingEXT) #define glTransformFeedbackVaryingsEXT GLEW_GET_FUN(__glewTransformFeedbackVaryingsEXT) #define GLEW_EXT_transform_feedback GLEW_GET_VAR(__GLEW_EXT_transform_feedback) #endif /* GL_EXT_transform_feedback */ /* -------------------------- GL_EXT_vertex_array -------------------------- */ #ifndef GL_EXT_vertex_array #define GL_EXT_vertex_array 1 #define GL_DOUBLE_EXT 0x140A #define GL_VERTEX_ARRAY_EXT 0x8074 #define GL_NORMAL_ARRAY_EXT 0x8075 #define GL_COLOR_ARRAY_EXT 0x8076 #define GL_INDEX_ARRAY_EXT 0x8077 #define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 #define GL_EDGE_FLAG_ARRAY_EXT 0x8079 #define GL_VERTEX_ARRAY_SIZE_EXT 0x807A #define GL_VERTEX_ARRAY_TYPE_EXT 0x807B #define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C #define GL_VERTEX_ARRAY_COUNT_EXT 0x807D #define GL_NORMAL_ARRAY_TYPE_EXT 0x807E #define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F #define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 #define GL_COLOR_ARRAY_SIZE_EXT 0x8081 #define GL_COLOR_ARRAY_TYPE_EXT 0x8082 #define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 #define GL_COLOR_ARRAY_COUNT_EXT 0x8084 #define GL_INDEX_ARRAY_TYPE_EXT 0x8085 #define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 #define GL_INDEX_ARRAY_COUNT_EXT 0x8087 #define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 #define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 #define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A #define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B #define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C #define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D #define GL_VERTEX_ARRAY_POINTER_EXT 0x808E #define GL_NORMAL_ARRAY_POINTER_EXT 0x808F #define GL_COLOR_ARRAY_POINTER_EXT 0x8090 #define GL_INDEX_ARRAY_POINTER_EXT 0x8091 #define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 #define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 typedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); typedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); typedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer); typedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); typedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); #define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT) #define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT) #define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT) #define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT) #define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT) #define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT) #define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT) #define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT) #define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array) #endif /* GL_EXT_vertex_array */ /* ------------------------ GL_EXT_vertex_array_bgra ----------------------- */ #ifndef GL_EXT_vertex_array_bgra #define GL_EXT_vertex_array_bgra 1 #define GL_BGRA 0x80E1 #define GLEW_EXT_vertex_array_bgra GLEW_GET_VAR(__GLEW_EXT_vertex_array_bgra) #endif /* GL_EXT_vertex_array_bgra */ /* ----------------------- GL_EXT_vertex_attrib_64bit ---------------------- */ #ifndef GL_EXT_vertex_attrib_64bit #define GL_EXT_vertex_attrib_64bit 1 #define GL_DOUBLE_MAT2_EXT 0x8F46 #define GL_DOUBLE_MAT3_EXT 0x8F47 #define GL_DOUBLE_MAT4_EXT 0x8F48 #define GL_DOUBLE_MAT2x3_EXT 0x8F49 #define GL_DOUBLE_MAT2x4_EXT 0x8F4A #define GL_DOUBLE_MAT3x2_EXT 0x8F4B #define GL_DOUBLE_MAT3x4_EXT 0x8F4C #define GL_DOUBLE_MAT4x2_EXT 0x8F4D #define GL_DOUBLE_MAT4x3_EXT 0x8F4E #define GL_DOUBLE_VEC2_EXT 0x8FFC #define GL_DOUBLE_VEC3_EXT 0x8FFD #define GL_DOUBLE_VEC4_EXT 0x8FFE typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); #define glGetVertexAttribLdvEXT GLEW_GET_FUN(__glewGetVertexAttribLdvEXT) #define glVertexArrayVertexAttribLOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLOffsetEXT) #define glVertexAttribL1dEXT GLEW_GET_FUN(__glewVertexAttribL1dEXT) #define glVertexAttribL1dvEXT GLEW_GET_FUN(__glewVertexAttribL1dvEXT) #define glVertexAttribL2dEXT GLEW_GET_FUN(__glewVertexAttribL2dEXT) #define glVertexAttribL2dvEXT GLEW_GET_FUN(__glewVertexAttribL2dvEXT) #define glVertexAttribL3dEXT GLEW_GET_FUN(__glewVertexAttribL3dEXT) #define glVertexAttribL3dvEXT GLEW_GET_FUN(__glewVertexAttribL3dvEXT) #define glVertexAttribL4dEXT GLEW_GET_FUN(__glewVertexAttribL4dEXT) #define glVertexAttribL4dvEXT GLEW_GET_FUN(__glewVertexAttribL4dvEXT) #define glVertexAttribLPointerEXT GLEW_GET_FUN(__glewVertexAttribLPointerEXT) #define GLEW_EXT_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_EXT_vertex_attrib_64bit) #endif /* GL_EXT_vertex_attrib_64bit */ /* -------------------------- GL_EXT_vertex_shader ------------------------- */ #ifndef GL_EXT_vertex_shader #define GL_EXT_vertex_shader 1 #define GL_VERTEX_SHADER_EXT 0x8780 #define GL_VERTEX_SHADER_BINDING_EXT 0x8781 #define GL_OP_INDEX_EXT 0x8782 #define GL_OP_NEGATE_EXT 0x8783 #define GL_OP_DOT3_EXT 0x8784 #define GL_OP_DOT4_EXT 0x8785 #define GL_OP_MUL_EXT 0x8786 #define GL_OP_ADD_EXT 0x8787 #define GL_OP_MADD_EXT 0x8788 #define GL_OP_FRAC_EXT 0x8789 #define GL_OP_MAX_EXT 0x878A #define GL_OP_MIN_EXT 0x878B #define GL_OP_SET_GE_EXT 0x878C #define GL_OP_SET_LT_EXT 0x878D #define GL_OP_CLAMP_EXT 0x878E #define GL_OP_FLOOR_EXT 0x878F #define GL_OP_ROUND_EXT 0x8790 #define GL_OP_EXP_BASE_2_EXT 0x8791 #define GL_OP_LOG_BASE_2_EXT 0x8792 #define GL_OP_POWER_EXT 0x8793 #define GL_OP_RECIP_EXT 0x8794 #define GL_OP_RECIP_SQRT_EXT 0x8795 #define GL_OP_SUB_EXT 0x8796 #define GL_OP_CROSS_PRODUCT_EXT 0x8797 #define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 #define GL_OP_MOV_EXT 0x8799 #define GL_OUTPUT_VERTEX_EXT 0x879A #define GL_OUTPUT_COLOR0_EXT 0x879B #define GL_OUTPUT_COLOR1_EXT 0x879C #define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D #define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E #define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F #define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 #define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 #define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 #define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 #define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 #define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 #define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 #define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 #define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 #define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 #define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA #define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB #define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC #define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD #define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE #define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF #define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 #define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 #define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 #define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 #define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 #define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 #define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 #define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 #define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 #define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 #define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA #define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB #define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC #define GL_OUTPUT_FOG_EXT 0x87BD #define GL_SCALAR_EXT 0x87BE #define GL_VECTOR_EXT 0x87BF #define GL_MATRIX_EXT 0x87C0 #define GL_VARIANT_EXT 0x87C1 #define GL_INVARIANT_EXT 0x87C2 #define GL_LOCAL_CONSTANT_EXT 0x87C3 #define GL_LOCAL_EXT 0x87C4 #define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 #define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 #define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 #define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 #define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 #define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA #define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB #define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC #define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD #define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE #define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF #define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 #define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 #define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 #define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 #define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 #define GL_X_EXT 0x87D5 #define GL_Y_EXT 0x87D6 #define GL_Z_EXT 0x87D7 #define GL_W_EXT 0x87D8 #define GL_NEGATIVE_X_EXT 0x87D9 #define GL_NEGATIVE_Y_EXT 0x87DA #define GL_NEGATIVE_Z_EXT 0x87DB #define GL_NEGATIVE_W_EXT 0x87DC #define GL_ZERO_EXT 0x87DD #define GL_ONE_EXT 0x87DE #define GL_NEGATIVE_ONE_EXT 0x87DF #define GL_NORMALIZED_RANGE_EXT 0x87E0 #define GL_FULL_RANGE_EXT 0x87E1 #define GL_CURRENT_VERTEX_EXT 0x87E2 #define GL_MVP_MATRIX_EXT 0x87E3 #define GL_VARIANT_VALUE_EXT 0x87E4 #define GL_VARIANT_DATATYPE_EXT 0x87E5 #define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 #define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 #define GL_VARIANT_ARRAY_EXT 0x87E8 #define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 #define GL_INVARIANT_VALUE_EXT 0x87EA #define GL_INVARIANT_DATATYPE_EXT 0x87EB #define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC #define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED typedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); typedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); typedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); typedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); typedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); typedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); typedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); typedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); typedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components); typedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); typedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); typedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); typedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data); typedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); typedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); typedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); typedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); typedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); typedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); typedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); typedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); typedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, GLvoid *addr); typedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr); typedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr); typedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr); typedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr); typedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr); typedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr); typedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr); typedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr); typedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); #define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT) #define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT) #define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT) #define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT) #define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT) #define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT) #define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT) #define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT) #define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT) #define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT) #define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT) #define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT) #define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT) #define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT) #define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT) #define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT) #define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT) #define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT) #define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT) #define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT) #define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT) #define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT) #define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT) #define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT) #define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT) #define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT) #define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT) #define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT) #define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT) #define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT) #define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT) #define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT) #define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT) #define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT) #define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT) #define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT) #define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT) #define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT) #define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT) #define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT) #define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT) #define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT) #define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader) #endif /* GL_EXT_vertex_shader */ /* ------------------------ GL_EXT_vertex_weighting ------------------------ */ #ifndef GL_EXT_vertex_weighting #define GL_EXT_vertex_weighting 1 #define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 #define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 #define GL_MODELVIEW0_EXT 0x1700 #define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 #define GL_MODELVIEW1_MATRIX_EXT 0x8506 #define GL_VERTEX_WEIGHTING_EXT 0x8509 #define GL_MODELVIEW1_EXT 0x850A #define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B #define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C #define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D #define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E #define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F #define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void* pointer); typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight); #define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT) #define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT) #define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT) #define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting) #endif /* GL_EXT_vertex_weighting */ /* ------------------------- GL_EXT_x11_sync_object ------------------------ */ #ifndef GL_EXT_x11_sync_object #define GL_EXT_x11_sync_object 1 #define GL_SYNC_X11_FENCE_EXT 0x90E1 typedef GLsync (GLAPIENTRY * PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); #define glImportSyncEXT GLEW_GET_FUN(__glewImportSyncEXT) #define GLEW_EXT_x11_sync_object GLEW_GET_VAR(__GLEW_EXT_x11_sync_object) #endif /* GL_EXT_x11_sync_object */ /* ---------------------- GL_GREMEDY_frame_terminator ---------------------- */ #ifndef GL_GREMEDY_frame_terminator #define GL_GREMEDY_frame_terminator 1 typedef void (GLAPIENTRY * PFNGLFRAMETERMINATORGREMEDYPROC) (void); #define glFrameTerminatorGREMEDY GLEW_GET_FUN(__glewFrameTerminatorGREMEDY) #define GLEW_GREMEDY_frame_terminator GLEW_GET_VAR(__GLEW_GREMEDY_frame_terminator) #endif /* GL_GREMEDY_frame_terminator */ /* ------------------------ GL_GREMEDY_string_marker ----------------------- */ #ifndef GL_GREMEDY_string_marker #define GL_GREMEDY_string_marker 1 typedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void* string); #define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY) #define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker) #endif /* GL_GREMEDY_string_marker */ /* --------------------- GL_HP_convolution_border_modes -------------------- */ #ifndef GL_HP_convolution_border_modes #define GL_HP_convolution_border_modes 1 #define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes) #endif /* GL_HP_convolution_border_modes */ /* ------------------------- GL_HP_image_transform ------------------------- */ #ifndef GL_HP_image_transform #define GL_HP_image_transform 1 typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); #define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP) #define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP) #define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP) #define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP) #define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP) #define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP) #define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform) #endif /* GL_HP_image_transform */ /* -------------------------- GL_HP_occlusion_test ------------------------- */ #ifndef GL_HP_occlusion_test #define GL_HP_occlusion_test 1 #define GL_OCCLUSION_TEST_HP 0x8165 #define GL_OCCLUSION_TEST_RESULT_HP 0x8166 #define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test) #endif /* GL_HP_occlusion_test */ /* ------------------------- GL_HP_texture_lighting ------------------------ */ #ifndef GL_HP_texture_lighting #define GL_HP_texture_lighting 1 #define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting) #endif /* GL_HP_texture_lighting */ /* --------------------------- GL_IBM_cull_vertex -------------------------- */ #ifndef GL_IBM_cull_vertex #define GL_IBM_cull_vertex 1 #define GL_CULL_VERTEX_IBM 103050 #define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex) #endif /* GL_IBM_cull_vertex */ /* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */ #ifndef GL_IBM_multimode_draw_arrays #define GL_IBM_multimode_draw_arrays 1 typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const GLvoid * const *indices, GLsizei primcount, GLint modestride); #define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM) #define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM) #define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays) #endif /* GL_IBM_multimode_draw_arrays */ /* ------------------------- GL_IBM_rasterpos_clip ------------------------- */ #ifndef GL_IBM_rasterpos_clip #define GL_IBM_rasterpos_clip 1 #define GL_RASTER_POSITION_UNCLIPPED_IBM 103010 #define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip) #endif /* GL_IBM_rasterpos_clip */ /* --------------------------- GL_IBM_static_data -------------------------- */ #ifndef GL_IBM_static_data #define GL_IBM_static_data 1 #define GL_ALL_STATIC_DATA_IBM 103060 #define GL_STATIC_VERTEX_ARRAY_IBM 103061 #define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data) #endif /* GL_IBM_static_data */ /* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */ #ifndef GL_IBM_texture_mirrored_repeat #define GL_IBM_texture_mirrored_repeat 1 #define GL_MIRRORED_REPEAT_IBM 0x8370 #define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat) #endif /* GL_IBM_texture_mirrored_repeat */ /* ----------------------- GL_IBM_vertex_array_lists ----------------------- */ #ifndef GL_IBM_vertex_array_lists #define GL_IBM_vertex_array_lists 1 #define GL_VERTEX_ARRAY_LIST_IBM 103070 #define GL_NORMAL_ARRAY_LIST_IBM 103071 #define GL_COLOR_ARRAY_LIST_IBM 103072 #define GL_INDEX_ARRAY_LIST_IBM 103073 #define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 #define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 #define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 #define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 #define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 #define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 #define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 #define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 #define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 #define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 #define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 #define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 typedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); #define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM) #define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM) #define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM) #define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM) #define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM) #define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM) #define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM) #define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM) #define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists) #endif /* GL_IBM_vertex_array_lists */ /* -------------------------- GL_INGR_color_clamp -------------------------- */ #ifndef GL_INGR_color_clamp #define GL_INGR_color_clamp 1 #define GL_RED_MIN_CLAMP_INGR 0x8560 #define GL_GREEN_MIN_CLAMP_INGR 0x8561 #define GL_BLUE_MIN_CLAMP_INGR 0x8562 #define GL_ALPHA_MIN_CLAMP_INGR 0x8563 #define GL_RED_MAX_CLAMP_INGR 0x8564 #define GL_GREEN_MAX_CLAMP_INGR 0x8565 #define GL_BLUE_MAX_CLAMP_INGR 0x8566 #define GL_ALPHA_MAX_CLAMP_INGR 0x8567 #define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp) #endif /* GL_INGR_color_clamp */ /* ------------------------- GL_INGR_interlace_read ------------------------ */ #ifndef GL_INGR_interlace_read #define GL_INGR_interlace_read 1 #define GL_INTERLACE_READ_INGR 0x8568 #define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read) #endif /* GL_INGR_interlace_read */ /* ------------------------ GL_INTEL_parallel_arrays ----------------------- */ #ifndef GL_INTEL_parallel_arrays #define GL_INTEL_parallel_arrays 1 #define GL_PARALLEL_ARRAYS_INTEL 0x83F4 #define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 #define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 #define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 #define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 typedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); typedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); #define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL) #define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL) #define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL) #define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL) #define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays) #endif /* GL_INTEL_parallel_arrays */ /* ------------------------ GL_INTEL_texture_scissor ----------------------- */ #ifndef GL_INTEL_texture_scissor #define GL_INTEL_texture_scissor 1 typedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); typedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); #define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL) #define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL) #define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor) #endif /* GL_INTEL_texture_scissor */ /* -------------------------- GL_KTX_buffer_region ------------------------- */ #ifndef GL_KTX_buffer_region #define GL_KTX_buffer_region 1 #define GL_KTX_FRONT_REGION 0x0 #define GL_KTX_BACK_REGION 0x1 #define GL_KTX_Z_REGION 0x2 #define GL_KTX_STENCIL_REGION 0x3 typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDPROC) (void); typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONPROC) (GLenum region); typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONPROC) (GLenum region); typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); #define glBufferRegionEnabled GLEW_GET_FUN(__glewBufferRegionEnabled) #define glDeleteBufferRegion GLEW_GET_FUN(__glewDeleteBufferRegion) #define glDrawBufferRegion GLEW_GET_FUN(__glewDrawBufferRegion) #define glNewBufferRegion GLEW_GET_FUN(__glewNewBufferRegion) #define glReadBufferRegion GLEW_GET_FUN(__glewReadBufferRegion) #define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region) #endif /* GL_KTX_buffer_region */ /* ------------------------- GL_MESAX_texture_stack ------------------------ */ #ifndef GL_MESAX_texture_stack #define GL_MESAX_texture_stack 1 #define GL_TEXTURE_1D_STACK_MESAX 0x8759 #define GL_TEXTURE_2D_STACK_MESAX 0x875A #define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B #define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C #define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D #define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E #define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack) #endif /* GL_MESAX_texture_stack */ /* -------------------------- GL_MESA_pack_invert -------------------------- */ #ifndef GL_MESA_pack_invert #define GL_MESA_pack_invert 1 #define GL_PACK_INVERT_MESA 0x8758 #define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert) #endif /* GL_MESA_pack_invert */ /* ------------------------- GL_MESA_resize_buffers ------------------------ */ #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 typedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); #define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA) #define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers) #endif /* GL_MESA_resize_buffers */ /* --------------------------- GL_MESA_window_pos -------------------------- */ #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p); #define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA) #define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA) #define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA) #define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA) #define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA) #define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA) #define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA) #define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA) #define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA) #define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA) #define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA) #define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA) #define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA) #define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA) #define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA) #define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA) #define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA) #define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA) #define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA) #define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA) #define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA) #define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA) #define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA) #define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA) #define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos) #endif /* GL_MESA_window_pos */ /* ------------------------- GL_MESA_ycbcr_texture ------------------------- */ #ifndef GL_MESA_ycbcr_texture #define GL_MESA_ycbcr_texture 1 #define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB #define GL_YCBCR_MESA 0x8757 #define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture) #endif /* GL_MESA_ycbcr_texture */ /* ------------------------- GL_NVX_gpu_memory_info ------------------------ */ #ifndef GL_NVX_gpu_memory_info #define GL_NVX_gpu_memory_info 1 #define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 #define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 #define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 #define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A #define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B #define GLEW_NVX_gpu_memory_info GLEW_GET_VAR(__GLEW_NVX_gpu_memory_info) #endif /* GL_NVX_gpu_memory_info */ /* --------------------------- GL_NV_blend_square -------------------------- */ #ifndef GL_NV_blend_square #define GL_NV_blend_square 1 #define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square) #endif /* GL_NV_blend_square */ /* ------------------------ GL_NV_conditional_render ----------------------- */ #ifndef GL_NV_conditional_render #define GL_NV_conditional_render 1 #define GL_QUERY_WAIT_NV 0x8E13 #define GL_QUERY_NO_WAIT_NV 0x8E14 #define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 #define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVPROC) (void); #define glBeginConditionalRenderNV GLEW_GET_FUN(__glewBeginConditionalRenderNV) #define glEndConditionalRenderNV GLEW_GET_FUN(__glewEndConditionalRenderNV) #define GLEW_NV_conditional_render GLEW_GET_VAR(__GLEW_NV_conditional_render) #endif /* GL_NV_conditional_render */ /* ----------------------- GL_NV_copy_depth_to_color ----------------------- */ #ifndef GL_NV_copy_depth_to_color #define GL_NV_copy_depth_to_color 1 #define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E #define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F #define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color) #endif /* GL_NV_copy_depth_to_color */ /* ---------------------------- GL_NV_copy_image --------------------------- */ #ifndef GL_NV_copy_image #define GL_NV_copy_image 1 typedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #define glCopyImageSubDataNV GLEW_GET_FUN(__glewCopyImageSubDataNV) #define GLEW_NV_copy_image GLEW_GET_VAR(__GLEW_NV_copy_image) #endif /* GL_NV_copy_image */ /* ------------------------ GL_NV_depth_buffer_float ----------------------- */ #ifndef GL_NV_depth_buffer_float #define GL_NV_depth_buffer_float 1 #define GL_DEPTH_COMPONENT32F_NV 0x8DAB #define GL_DEPTH32F_STENCIL8_NV 0x8DAC #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD #define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF typedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); #define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV) #define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV) #define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV) #define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float) #endif /* GL_NV_depth_buffer_float */ /* --------------------------- GL_NV_depth_clamp --------------------------- */ #ifndef GL_NV_depth_clamp #define GL_NV_depth_clamp 1 #define GL_DEPTH_CLAMP_NV 0x864F #define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp) #endif /* GL_NV_depth_clamp */ /* ---------------------- GL_NV_depth_range_unclamped ---------------------- */ #ifndef GL_NV_depth_range_unclamped #define GL_NV_depth_range_unclamped 1 #define GL_SAMPLE_COUNT_BITS_NV 0x8864 #define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865 #define GL_QUERY_RESULT_NV 0x8866 #define GL_QUERY_RESULT_AVAILABLE_NV 0x8867 #define GL_SAMPLE_COUNT_NV 0x8914 #define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped) #endif /* GL_NV_depth_range_unclamped */ /* ---------------------------- GL_NV_evaluators --------------------------- */ #ifndef GL_NV_evaluators #define GL_NV_evaluators 1 #define GL_EVAL_2D_NV 0x86C0 #define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 #define GL_MAP_TESSELLATION_NV 0x86C2 #define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 #define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 #define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 #define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 #define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 #define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 #define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 #define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA #define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB #define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC #define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD #define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE #define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF #define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 #define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 #define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 #define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 #define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 #define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 #define GL_MAX_MAP_TESSELLATION_NV 0x86D6 #define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 typedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void* points); typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void* points); typedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params); #define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV) #define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV) #define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV) #define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV) #define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV) #define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV) #define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV) #define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV) #define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV) #define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators) #endif /* GL_NV_evaluators */ /* ----------------------- GL_NV_explicit_multisample ---------------------- */ #ifndef GL_NV_explicit_multisample #define GL_NV_explicit_multisample 1 #define GL_SAMPLE_POSITION_NV 0x8E50 #define GL_SAMPLE_MASK_NV 0x8E51 #define GL_SAMPLE_MASK_VALUE_NV 0x8E52 #define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 #define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 #define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 #define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 #define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 #define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 #define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat* val); typedef void (GLAPIENTRY * PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); typedef void (GLAPIENTRY * PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); #define glGetMultisamplefvNV GLEW_GET_FUN(__glewGetMultisamplefvNV) #define glSampleMaskIndexedNV GLEW_GET_FUN(__glewSampleMaskIndexedNV) #define glTexRenderbufferNV GLEW_GET_FUN(__glewTexRenderbufferNV) #define GLEW_NV_explicit_multisample GLEW_GET_VAR(__GLEW_NV_explicit_multisample) #endif /* GL_NV_explicit_multisample */ /* ------------------------------ GL_NV_fence ------------------------------ */ #ifndef GL_NV_fence #define GL_NV_fence 1 #define GL_ALL_COMPLETED_NV 0x84F2 #define GL_FENCE_STATUS_NV 0x84F3 #define GL_FENCE_CONDITION_NV 0x84F4 typedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences); typedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); typedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences); typedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence); typedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); #define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV) #define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV) #define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV) #define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV) #define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV) #define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV) #define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV) #define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence) #endif /* GL_NV_fence */ /* --------------------------- GL_NV_float_buffer -------------------------- */ #ifndef GL_NV_float_buffer #define GL_NV_float_buffer 1 #define GL_FLOAT_R_NV 0x8880 #define GL_FLOAT_RG_NV 0x8881 #define GL_FLOAT_RGB_NV 0x8882 #define GL_FLOAT_RGBA_NV 0x8883 #define GL_FLOAT_R16_NV 0x8884 #define GL_FLOAT_R32_NV 0x8885 #define GL_FLOAT_RG16_NV 0x8886 #define GL_FLOAT_RG32_NV 0x8887 #define GL_FLOAT_RGB16_NV 0x8888 #define GL_FLOAT_RGB32_NV 0x8889 #define GL_FLOAT_RGBA16_NV 0x888A #define GL_FLOAT_RGBA32_NV 0x888B #define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C #define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D #define GL_FLOAT_RGBA_MODE_NV 0x888E #define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer) #endif /* GL_NV_float_buffer */ /* --------------------------- GL_NV_fog_distance -------------------------- */ #ifndef GL_NV_fog_distance #define GL_NV_fog_distance 1 #define GL_FOG_DISTANCE_MODE_NV 0x855A #define GL_EYE_RADIAL_NV 0x855B #define GL_EYE_PLANE_ABSOLUTE_NV 0x855C #define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance) #endif /* GL_NV_fog_distance */ /* ------------------------- GL_NV_fragment_program ------------------------ */ #ifndef GL_NV_fragment_program #define GL_NV_fragment_program 1 #define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 #define GL_FRAGMENT_PROGRAM_NV 0x8870 #define GL_MAX_TEXTURE_COORDS_NV 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 #define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 #define GL_PROGRAM_ERROR_STRING_NV 0x8874 typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params); typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]); typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]); #define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV) #define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV) #define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV) #define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV) #define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV) #define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV) #define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program) #endif /* GL_NV_fragment_program */ /* ------------------------ GL_NV_fragment_program2 ------------------------ */ #ifndef GL_NV_fragment_program2 #define GL_NV_fragment_program2 1 #define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 #define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 #define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 #define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 #define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 #define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2) #endif /* GL_NV_fragment_program2 */ /* ------------------------ GL_NV_fragment_program4 ------------------------ */ #ifndef GL_NV_fragment_program4 #define GL_NV_fragment_program4 1 #define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4) #endif /* GL_NV_fragment_program4 */ /* --------------------- GL_NV_fragment_program_option --------------------- */ #ifndef GL_NV_fragment_program_option #define GL_NV_fragment_program_option 1 #define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option) #endif /* GL_NV_fragment_program_option */ /* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */ #ifndef GL_NV_framebuffer_multisample_coverage #define GL_NV_framebuffer_multisample_coverage 1 #define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB #define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 #define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 #define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); #define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV) #define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage) #endif /* GL_NV_framebuffer_multisample_coverage */ /* ------------------------ GL_NV_geometry_program4 ------------------------ */ #ifndef GL_NV_geometry_program4 #define GL_NV_geometry_program4 1 #define GL_GEOMETRY_PROGRAM_NV 0x8C26 #define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 #define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 typedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); #define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV) #define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4) #endif /* GL_NV_geometry_program4 */ /* ------------------------- GL_NV_geometry_shader4 ------------------------ */ #ifndef GL_NV_geometry_shader4 #define GL_NV_geometry_shader4 1 #define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4) #endif /* GL_NV_geometry_shader4 */ /* --------------------------- GL_NV_gpu_program4 -------------------------- */ #ifndef GL_NV_gpu_program4 #define GL_NV_gpu_program4 1 #define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 #define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 #define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 #define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 #define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 #define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 #define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); #define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV) #define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV) #define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV) #define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV) #define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV) #define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV) #define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV) #define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV) #define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV) #define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV) #define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV) #define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV) #define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4) #endif /* GL_NV_gpu_program4 */ /* --------------------------- GL_NV_gpu_program5 -------------------------- */ #ifndef GL_NV_gpu_program5 #define GL_NV_gpu_program5 1 #define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A #define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B #define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C #define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F #define GLEW_NV_gpu_program5 GLEW_GET_VAR(__GLEW_NV_gpu_program5) #endif /* GL_NV_gpu_program5 */ /* ------------------------- GL_NV_gpu_program_fp64 ------------------------ */ #ifndef GL_NV_gpu_program_fp64 #define GL_NV_gpu_program_fp64 1 #define GLEW_NV_gpu_program_fp64 GLEW_GET_VAR(__GLEW_NV_gpu_program_fp64) #endif /* GL_NV_gpu_program_fp64 */ /* --------------------------- GL_NV_gpu_shader5 --------------------------- */ #ifndef GL_NV_gpu_shader5 #define GL_NV_gpu_shader5 1 #define GL_INT64_NV 0x140E #define GL_UNSIGNED_INT64_NV 0x140F #define GL_INT8_NV 0x8FE0 #define GL_INT8_VEC2_NV 0x8FE1 #define GL_INT8_VEC3_NV 0x8FE2 #define GL_INT8_VEC4_NV 0x8FE3 #define GL_INT16_NV 0x8FE4 #define GL_INT16_VEC2_NV 0x8FE5 #define GL_INT16_VEC3_NV 0x8FE6 #define GL_INT16_VEC4_NV 0x8FE7 #define GL_INT64_VEC2_NV 0x8FE9 #define GL_INT64_VEC3_NV 0x8FEA #define GL_INT64_VEC4_NV 0x8FEB #define GL_UNSIGNED_INT8_NV 0x8FEC #define GL_UNSIGNED_INT8_VEC2_NV 0x8FED #define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE #define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF #define GL_UNSIGNED_INT16_NV 0x8FF0 #define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 #define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 #define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 #define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 #define GL_FLOAT16_NV 0x8FF8 #define GL_FLOAT16_VEC2_NV 0x8FF9 #define GL_FLOAT16_VEC3_NV 0x8FFA #define GL_FLOAT16_VEC4_NV 0x8FFB typedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); typedef void (GLAPIENTRY * PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); typedef void (GLAPIENTRY * PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (GLAPIENTRY * PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (GLAPIENTRY * PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); #define glGetUniformi64vNV GLEW_GET_FUN(__glewGetUniformi64vNV) #define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV) #define glProgramUniform1i64NV GLEW_GET_FUN(__glewProgramUniform1i64NV) #define glProgramUniform1i64vNV GLEW_GET_FUN(__glewProgramUniform1i64vNV) #define glProgramUniform1ui64NV GLEW_GET_FUN(__glewProgramUniform1ui64NV) #define glProgramUniform1ui64vNV GLEW_GET_FUN(__glewProgramUniform1ui64vNV) #define glProgramUniform2i64NV GLEW_GET_FUN(__glewProgramUniform2i64NV) #define glProgramUniform2i64vNV GLEW_GET_FUN(__glewProgramUniform2i64vNV) #define glProgramUniform2ui64NV GLEW_GET_FUN(__glewProgramUniform2ui64NV) #define glProgramUniform2ui64vNV GLEW_GET_FUN(__glewProgramUniform2ui64vNV) #define glProgramUniform3i64NV GLEW_GET_FUN(__glewProgramUniform3i64NV) #define glProgramUniform3i64vNV GLEW_GET_FUN(__glewProgramUniform3i64vNV) #define glProgramUniform3ui64NV GLEW_GET_FUN(__glewProgramUniform3ui64NV) #define glProgramUniform3ui64vNV GLEW_GET_FUN(__glewProgramUniform3ui64vNV) #define glProgramUniform4i64NV GLEW_GET_FUN(__glewProgramUniform4i64NV) #define glProgramUniform4i64vNV GLEW_GET_FUN(__glewProgramUniform4i64vNV) #define glProgramUniform4ui64NV GLEW_GET_FUN(__glewProgramUniform4ui64NV) #define glProgramUniform4ui64vNV GLEW_GET_FUN(__glewProgramUniform4ui64vNV) #define glUniform1i64NV GLEW_GET_FUN(__glewUniform1i64NV) #define glUniform1i64vNV GLEW_GET_FUN(__glewUniform1i64vNV) #define glUniform1ui64NV GLEW_GET_FUN(__glewUniform1ui64NV) #define glUniform1ui64vNV GLEW_GET_FUN(__glewUniform1ui64vNV) #define glUniform2i64NV GLEW_GET_FUN(__glewUniform2i64NV) #define glUniform2i64vNV GLEW_GET_FUN(__glewUniform2i64vNV) #define glUniform2ui64NV GLEW_GET_FUN(__glewUniform2ui64NV) #define glUniform2ui64vNV GLEW_GET_FUN(__glewUniform2ui64vNV) #define glUniform3i64NV GLEW_GET_FUN(__glewUniform3i64NV) #define glUniform3i64vNV GLEW_GET_FUN(__glewUniform3i64vNV) #define glUniform3ui64NV GLEW_GET_FUN(__glewUniform3ui64NV) #define glUniform3ui64vNV GLEW_GET_FUN(__glewUniform3ui64vNV) #define glUniform4i64NV GLEW_GET_FUN(__glewUniform4i64NV) #define glUniform4i64vNV GLEW_GET_FUN(__glewUniform4i64vNV) #define glUniform4ui64NV GLEW_GET_FUN(__glewUniform4ui64NV) #define glUniform4ui64vNV GLEW_GET_FUN(__glewUniform4ui64vNV) #define GLEW_NV_gpu_shader5 GLEW_GET_VAR(__GLEW_NV_gpu_shader5) #endif /* GL_NV_gpu_shader5 */ /* ---------------------------- GL_NV_half_float --------------------------- */ #ifndef GL_NV_half_float #define GL_NV_half_float 1 #define GL_HALF_FLOAT_NV 0x140B typedef unsigned short GLhalf; typedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); typedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha); typedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog); typedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q); typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz); typedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s); typedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t); typedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r); typedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q); typedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y); typedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z); typedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w); typedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight); typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight); #define glColor3hNV GLEW_GET_FUN(__glewColor3hNV) #define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV) #define glColor4hNV GLEW_GET_FUN(__glewColor4hNV) #define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV) #define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV) #define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV) #define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV) #define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV) #define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV) #define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV) #define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV) #define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV) #define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV) #define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV) #define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV) #define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV) #define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV) #define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV) #define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV) #define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV) #define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV) #define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV) #define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV) #define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV) #define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV) #define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV) #define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV) #define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV) #define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV) #define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV) #define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV) #define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV) #define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV) #define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV) #define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV) #define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV) #define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV) #define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV) #define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV) #define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV) #define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV) #define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV) #define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV) #define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV) #define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV) #define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV) #define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float) #endif /* GL_NV_half_float */ /* ------------------------ GL_NV_light_max_exponent ----------------------- */ #ifndef GL_NV_light_max_exponent #define GL_NV_light_max_exponent 1 #define GL_MAX_SHININESS_NV 0x8504 #define GL_MAX_SPOT_EXPONENT_NV 0x8505 #define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent) #endif /* GL_NV_light_max_exponent */ /* ----------------------- GL_NV_multisample_coverage ---------------------- */ #ifndef GL_NV_multisample_coverage #define GL_NV_multisample_coverage 1 #define GL_COVERAGE_SAMPLES_NV 0x80A9 #define GL_COLOR_SAMPLES_NV 0x8E20 #define GLEW_NV_multisample_coverage GLEW_GET_VAR(__GLEW_NV_multisample_coverage) #endif /* GL_NV_multisample_coverage */ /* --------------------- GL_NV_multisample_filter_hint --------------------- */ #ifndef GL_NV_multisample_filter_hint #define GL_NV_multisample_filter_hint 1 #define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 #define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint) #endif /* GL_NV_multisample_filter_hint */ /* ------------------------- GL_NV_occlusion_query ------------------------- */ #ifndef GL_NV_occlusion_query #define GL_NV_occlusion_query 1 #define GL_PIXEL_COUNTER_BITS_NV 0x8864 #define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 #define GL_PIXEL_COUNT_NV 0x8866 #define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 typedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); typedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params); typedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); #define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV) #define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV) #define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV) #define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV) #define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV) #define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV) #define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV) #define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query) #endif /* GL_NV_occlusion_query */ /* ----------------------- GL_NV_packed_depth_stencil ---------------------- */ #ifndef GL_NV_packed_depth_stencil #define GL_NV_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_NV 0x84F9 #define GL_UNSIGNED_INT_24_8_NV 0x84FA #define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil) #endif /* GL_NV_packed_depth_stencil */ /* --------------------- GL_NV_parameter_buffer_object --------------------- */ #ifndef GL_NV_parameter_buffer_object #define GL_NV_parameter_buffer_object 1 #define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 #define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 #define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 #define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 #define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); #define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV) #define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV) #define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV) #define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object) #endif /* GL_NV_parameter_buffer_object */ /* --------------------- GL_NV_parameter_buffer_object2 -------------------- */ #ifndef GL_NV_parameter_buffer_object2 #define GL_NV_parameter_buffer_object2 1 #define GLEW_NV_parameter_buffer_object2 GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object2) #endif /* GL_NV_parameter_buffer_object2 */ /* -------------------------- GL_NV_path_rendering ------------------------- */ #ifndef GL_NV_path_rendering #define GL_NV_path_rendering 1 #define GL_CLOSE_PATH_NV 0x00 #define GL_BOLD_BIT_NV 0x01 #define GL_GLYPH_WIDTH_BIT_NV 0x01 #define GL_MOVE_TO_NV 0x02 #define GL_GLYPH_HEIGHT_BIT_NV 0x02 #define GL_ITALIC_BIT_NV 0x02 #define GL_RELATIVE_MOVE_TO_NV 0x03 #define GL_LINE_TO_NV 0x04 #define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 #define GL_RELATIVE_LINE_TO_NV 0x05 #define GL_HORIZONTAL_LINE_TO_NV 0x06 #define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 #define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 #define GL_VERTICAL_LINE_TO_NV 0x08 #define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 #define GL_QUADRATIC_CURVE_TO_NV 0x0A #define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B #define GL_CUBIC_CURVE_TO_NV 0x0C #define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D #define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E #define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F #define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 #define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 #define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 #define GL_SMALL_CCW_ARC_TO_NV 0x12 #define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 #define GL_SMALL_CW_ARC_TO_NV 0x14 #define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 #define GL_LARGE_CCW_ARC_TO_NV 0x16 #define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 #define GL_LARGE_CW_ARC_TO_NV 0x18 #define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 #define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 #define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 #define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 #define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 #define GL_CIRCULAR_CW_ARC_TO_NV 0xFA #define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC #define GL_ARC_TO_NV 0xFE #define GL_RELATIVE_ARC_TO_NV 0xFF #define GL_GLYPH_HAS_KERNING_NV 0x100 #define GL_PRIMARY_COLOR_NV 0x852C #define GL_SECONDARY_COLOR_NV 0x852D #define GL_PRIMARY_COLOR 0x8577 #define GL_PATH_FORMAT_SVG_NV 0x9070 #define GL_PATH_FORMAT_PS_NV 0x9071 #define GL_STANDARD_FONT_NAME_NV 0x9072 #define GL_SYSTEM_FONT_NAME_NV 0x9073 #define GL_FILE_NAME_NV 0x9074 #define GL_PATH_STROKE_WIDTH_NV 0x9075 #define GL_PATH_END_CAPS_NV 0x9076 #define GL_PATH_INITIAL_END_CAP_NV 0x9077 #define GL_PATH_TERMINAL_END_CAP_NV 0x9078 #define GL_PATH_JOIN_STYLE_NV 0x9079 #define GL_PATH_MITER_LIMIT_NV 0x907A #define GL_PATH_DASH_CAPS_NV 0x907B #define GL_PATH_INITIAL_DASH_CAP_NV 0x907C #define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D #define GL_PATH_DASH_OFFSET_NV 0x907E #define GL_PATH_CLIENT_LENGTH_NV 0x907F #define GL_PATH_FILL_MODE_NV 0x9080 #define GL_PATH_FILL_MASK_NV 0x9081 #define GL_PATH_FILL_COVER_MODE_NV 0x9082 #define GL_PATH_STROKE_COVER_MODE_NV 0x9083 #define GL_PATH_STROKE_MASK_NV 0x9084 #define GL_COUNT_UP_NV 0x9088 #define GL_COUNT_DOWN_NV 0x9089 #define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A #define GL_CONVEX_HULL_NV 0x908B #define GL_BOUNDING_BOX_NV 0x908D #define GL_TRANSLATE_X_NV 0x908E #define GL_TRANSLATE_Y_NV 0x908F #define GL_TRANSLATE_2D_NV 0x9090 #define GL_TRANSLATE_3D_NV 0x9091 #define GL_AFFINE_2D_NV 0x9092 #define GL_AFFINE_3D_NV 0x9094 #define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 #define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 #define GL_UTF8_NV 0x909A #define GL_UTF16_NV 0x909B #define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C #define GL_PATH_COMMAND_COUNT_NV 0x909D #define GL_PATH_COORD_COUNT_NV 0x909E #define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F #define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 #define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 #define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 #define GL_SQUARE_NV 0x90A3 #define GL_ROUND_NV 0x90A4 #define GL_TRIANGULAR_NV 0x90A5 #define GL_BEVEL_NV 0x90A6 #define GL_MITER_REVERT_NV 0x90A7 #define GL_MITER_TRUNCATE_NV 0x90A8 #define GL_SKIP_MISSING_GLYPH_NV 0x90A9 #define GL_USE_MISSING_GLYPH_NV 0x90AA #define GL_PATH_ERROR_POSITION_NV 0x90AB #define GL_PATH_FOG_GEN_MODE_NV 0x90AC #define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD #define GL_ADJACENT_PAIRS_NV 0x90AE #define GL_FIRST_TO_REST_NV 0x90AF #define GL_PATH_GEN_MODE_NV 0x90B0 #define GL_PATH_GEN_COEFF_NV 0x90B1 #define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 #define GL_PATH_GEN_COMPONENTS_NV 0x90B3 #define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 #define GL_MOVE_TO_RESETS_NV 0x90B5 #define GL_MOVE_TO_CONTINUES_NV 0x90B6 #define GL_PATH_STENCIL_FUNC_NV 0x90B7 #define GL_PATH_STENCIL_REF_NV 0x90B8 #define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 #define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD #define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE #define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF #define GL_FONT_X_MIN_BOUNDS_NV 0x00010000 #define GL_FONT_Y_MIN_BOUNDS_NV 0x00020000 #define GL_FONT_X_MAX_BOUNDS_NV 0x00040000 #define GL_FONT_Y_MAX_BOUNDS_NV 0x00080000 #define GL_FONT_UNITS_PER_EM_NV 0x00100000 #define GL_FONT_ASCENDER_NV 0x00200000 #define GL_FONT_DESCENDER_NV 0x00400000 #define GL_FONT_HEIGHT_NV 0x00800000 #define GL_FONT_MAX_ADVANCE_WIDTH_NV 0x01000000 #define GL_FONT_MAX_ADVANCE_HEIGHT_NV 0x02000000 #define GL_FONT_UNDERLINE_POSITION_NV 0x04000000 #define GL_FONT_UNDERLINE_THICKNESS_NV 0x08000000 #define GL_FONT_HAS_KERNING_NV 0x10000000 typedef void (GLAPIENTRY * PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); typedef void (GLAPIENTRY * PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHNVPROC) (GLuint name, GLenum coverMode); typedef void (GLAPIENTRY * PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); typedef GLuint (GLAPIENTRY * PFNGLGENPATHSNVPROC) (GLsizei range); typedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat* value); typedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint* value); typedef void (GLAPIENTRY * PFNGLGETPATHCOMMANDSNVPROC) (GLuint name, GLubyte* commands); typedef void (GLAPIENTRY * PFNGLGETPATHCOORDSNVPROC) (GLuint name, GLfloat* coords); typedef void (GLAPIENTRY * PFNGLGETPATHDASHARRAYNVPROC) (GLuint name, GLfloat* dashArray); typedef GLfloat (GLAPIENTRY * PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); typedef void (GLAPIENTRY * PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint fistPathName, GLsizei numPaths, GLsizei stride, GLfloat* metrics); typedef void (GLAPIENTRY * PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); typedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERFVNVPROC) (GLuint name, GLenum param, GLfloat* value); typedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERIVNVPROC) (GLuint name, GLenum param, GLint* value); typedef void (GLAPIENTRY * PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); typedef void (GLAPIENTRY * PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat* value); typedef void (GLAPIENTRY * PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint* value); typedef void (GLAPIENTRY * PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); typedef GLboolean (GLAPIENTRY * PFNGLISPATHNVPROC) (GLuint path); typedef GLboolean (GLAPIENTRY * PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); typedef GLboolean (GLAPIENTRY * PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat* coeffs); typedef void (GLAPIENTRY * PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const GLvoid*coords); typedef void (GLAPIENTRY * PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void* coords); typedef void (GLAPIENTRY * PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum zfunc); typedef void (GLAPIENTRY * PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat* dashArray); typedef void (GLAPIENTRY * PFNGLPATHFOGGENNVPROC) (GLenum genMode); typedef void (GLAPIENTRY * PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void* fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (GLAPIENTRY * PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void* fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid*charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (GLAPIENTRY * PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); typedef void (GLAPIENTRY * PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat* value); typedef void (GLAPIENTRY * PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); typedef void (GLAPIENTRY * PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint* value); typedef void (GLAPIENTRY * PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLint units); typedef void (GLAPIENTRY * PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); typedef void (GLAPIENTRY * PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void* pathString); typedef void (GLAPIENTRY * PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const GLvoid*coords); typedef void (GLAPIENTRY * PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void* coords); typedef void (GLAPIENTRY * PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat* coeffs); typedef GLboolean (GLAPIENTRY * PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat* x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); typedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); typedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); typedef void (GLAPIENTRY * PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat* transformValues); typedef void (GLAPIENTRY * PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint paths[], const GLfloat weights[]); #define glCopyPathNV GLEW_GET_FUN(__glewCopyPathNV) #define glCoverFillPathInstancedNV GLEW_GET_FUN(__glewCoverFillPathInstancedNV) #define glCoverFillPathNV GLEW_GET_FUN(__glewCoverFillPathNV) #define glCoverStrokePathInstancedNV GLEW_GET_FUN(__glewCoverStrokePathInstancedNV) #define glCoverStrokePathNV GLEW_GET_FUN(__glewCoverStrokePathNV) #define glDeletePathsNV GLEW_GET_FUN(__glewDeletePathsNV) #define glGenPathsNV GLEW_GET_FUN(__glewGenPathsNV) #define glGetPathColorGenfvNV GLEW_GET_FUN(__glewGetPathColorGenfvNV) #define glGetPathColorGenivNV GLEW_GET_FUN(__glewGetPathColorGenivNV) #define glGetPathCommandsNV GLEW_GET_FUN(__glewGetPathCommandsNV) #define glGetPathCoordsNV GLEW_GET_FUN(__glewGetPathCoordsNV) #define glGetPathDashArrayNV GLEW_GET_FUN(__glewGetPathDashArrayNV) #define glGetPathLengthNV GLEW_GET_FUN(__glewGetPathLengthNV) #define glGetPathMetricRangeNV GLEW_GET_FUN(__glewGetPathMetricRangeNV) #define glGetPathMetricsNV GLEW_GET_FUN(__glewGetPathMetricsNV) #define glGetPathParameterfvNV GLEW_GET_FUN(__glewGetPathParameterfvNV) #define glGetPathParameterivNV GLEW_GET_FUN(__glewGetPathParameterivNV) #define glGetPathSpacingNV GLEW_GET_FUN(__glewGetPathSpacingNV) #define glGetPathTexGenfvNV GLEW_GET_FUN(__glewGetPathTexGenfvNV) #define glGetPathTexGenivNV GLEW_GET_FUN(__glewGetPathTexGenivNV) #define glInterpolatePathsNV GLEW_GET_FUN(__glewInterpolatePathsNV) #define glIsPathNV GLEW_GET_FUN(__glewIsPathNV) #define glIsPointInFillPathNV GLEW_GET_FUN(__glewIsPointInFillPathNV) #define glIsPointInStrokePathNV GLEW_GET_FUN(__glewIsPointInStrokePathNV) #define glPathColorGenNV GLEW_GET_FUN(__glewPathColorGenNV) #define glPathCommandsNV GLEW_GET_FUN(__glewPathCommandsNV) #define glPathCoordsNV GLEW_GET_FUN(__glewPathCoordsNV) #define glPathCoverDepthFuncNV GLEW_GET_FUN(__glewPathCoverDepthFuncNV) #define glPathDashArrayNV GLEW_GET_FUN(__glewPathDashArrayNV) #define glPathFogGenNV GLEW_GET_FUN(__glewPathFogGenNV) #define glPathGlyphRangeNV GLEW_GET_FUN(__glewPathGlyphRangeNV) #define glPathGlyphsNV GLEW_GET_FUN(__glewPathGlyphsNV) #define glPathParameterfNV GLEW_GET_FUN(__glewPathParameterfNV) #define glPathParameterfvNV GLEW_GET_FUN(__glewPathParameterfvNV) #define glPathParameteriNV GLEW_GET_FUN(__glewPathParameteriNV) #define glPathParameterivNV GLEW_GET_FUN(__glewPathParameterivNV) #define glPathStencilDepthOffsetNV GLEW_GET_FUN(__glewPathStencilDepthOffsetNV) #define glPathStencilFuncNV GLEW_GET_FUN(__glewPathStencilFuncNV) #define glPathStringNV GLEW_GET_FUN(__glewPathStringNV) #define glPathSubCommandsNV GLEW_GET_FUN(__glewPathSubCommandsNV) #define glPathSubCoordsNV GLEW_GET_FUN(__glewPathSubCoordsNV) #define glPathTexGenNV GLEW_GET_FUN(__glewPathTexGenNV) #define glPointAlongPathNV GLEW_GET_FUN(__glewPointAlongPathNV) #define glStencilFillPathInstancedNV GLEW_GET_FUN(__glewStencilFillPathInstancedNV) #define glStencilFillPathNV GLEW_GET_FUN(__glewStencilFillPathNV) #define glStencilStrokePathInstancedNV GLEW_GET_FUN(__glewStencilStrokePathInstancedNV) #define glStencilStrokePathNV GLEW_GET_FUN(__glewStencilStrokePathNV) #define glTransformPathNV GLEW_GET_FUN(__glewTransformPathNV) #define glWeightPathsNV GLEW_GET_FUN(__glewWeightPathsNV) #define GLEW_NV_path_rendering GLEW_GET_VAR(__GLEW_NV_path_rendering) #endif /* GL_NV_path_rendering */ /* ------------------------- GL_NV_pixel_data_range ------------------------ */ #ifndef GL_NV_pixel_data_range #define GL_NV_pixel_data_range 1 #define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 #define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 #define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A #define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B #define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C #define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D typedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void* pointer); #define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV) #define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV) #define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range) #endif /* GL_NV_pixel_data_range */ /* --------------------------- GL_NV_point_sprite -------------------------- */ #ifndef GL_NV_point_sprite #define GL_NV_point_sprite 1 #define GL_POINT_SPRITE_NV 0x8861 #define GL_COORD_REPLACE_NV 0x8862 #define GL_POINT_SPRITE_R_MODE_NV 0x8863 typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params); #define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV) #define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV) #define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite) #endif /* GL_NV_point_sprite */ /* -------------------------- GL_NV_present_video -------------------------- */ #ifndef GL_NV_present_video #define GL_NV_present_video 1 #define GL_FRAME_NV 0x8E26 #define GL_FIELDS_NV 0x8E27 #define GL_CURRENT_TIME_NV 0x8E28 #define GL_NUM_FILL_STREAMS_NV 0x8E29 #define GL_PRESENT_TIME_NV 0x8E2A #define GL_PRESENT_DURATION_NV 0x8E2B typedef void (GLAPIENTRY * PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint* params); typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); #define glGetVideoi64vNV GLEW_GET_FUN(__glewGetVideoi64vNV) #define glGetVideoivNV GLEW_GET_FUN(__glewGetVideoivNV) #define glGetVideoui64vNV GLEW_GET_FUN(__glewGetVideoui64vNV) #define glGetVideouivNV GLEW_GET_FUN(__glewGetVideouivNV) #define glPresentFrameDualFillNV GLEW_GET_FUN(__glewPresentFrameDualFillNV) #define glPresentFrameKeyedNV GLEW_GET_FUN(__glewPresentFrameKeyedNV) #define GLEW_NV_present_video GLEW_GET_VAR(__GLEW_NV_present_video) #endif /* GL_NV_present_video */ /* ------------------------ GL_NV_primitive_restart ------------------------ */ #ifndef GL_NV_primitive_restart #define GL_NV_primitive_restart 1 #define GL_PRIMITIVE_RESTART_NV 0x8558 #define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); #define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV) #define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV) #define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart) #endif /* GL_NV_primitive_restart */ /* ------------------------ GL_NV_register_combiners ----------------------- */ #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 #define GL_REGISTER_COMBINERS_NV 0x8522 #define GL_VARIABLE_A_NV 0x8523 #define GL_VARIABLE_B_NV 0x8524 #define GL_VARIABLE_C_NV 0x8525 #define GL_VARIABLE_D_NV 0x8526 #define GL_VARIABLE_E_NV 0x8527 #define GL_VARIABLE_F_NV 0x8528 #define GL_VARIABLE_G_NV 0x8529 #define GL_CONSTANT_COLOR0_NV 0x852A #define GL_CONSTANT_COLOR1_NV 0x852B #define GL_PRIMARY_COLOR_NV 0x852C #define GL_SECONDARY_COLOR_NV 0x852D #define GL_SPARE0_NV 0x852E #define GL_SPARE1_NV 0x852F #define GL_DISCARD_NV 0x8530 #define GL_E_TIMES_F_NV 0x8531 #define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 #define GL_UNSIGNED_IDENTITY_NV 0x8536 #define GL_UNSIGNED_INVERT_NV 0x8537 #define GL_EXPAND_NORMAL_NV 0x8538 #define GL_EXPAND_NEGATE_NV 0x8539 #define GL_HALF_BIAS_NORMAL_NV 0x853A #define GL_HALF_BIAS_NEGATE_NV 0x853B #define GL_SIGNED_IDENTITY_NV 0x853C #define GL_SIGNED_NEGATE_NV 0x853D #define GL_SCALE_BY_TWO_NV 0x853E #define GL_SCALE_BY_FOUR_NV 0x853F #define GL_SCALE_BY_ONE_HALF_NV 0x8540 #define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 #define GL_COMBINER_INPUT_NV 0x8542 #define GL_COMBINER_MAPPING_NV 0x8543 #define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 #define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 #define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 #define GL_COMBINER_MUX_SUM_NV 0x8547 #define GL_COMBINER_SCALE_NV 0x8548 #define GL_COMBINER_BIAS_NV 0x8549 #define GL_COMBINER_AB_OUTPUT_NV 0x854A #define GL_COMBINER_CD_OUTPUT_NV 0x854B #define GL_COMBINER_SUM_OUTPUT_NV 0x854C #define GL_MAX_GENERAL_COMBINERS_NV 0x854D #define GL_NUM_GENERAL_COMBINERS_NV 0x854E #define GL_COLOR_SUM_CLAMP_NV 0x854F #define GL_COMBINER0_NV 0x8550 #define GL_COMBINER1_NV 0x8551 #define GL_COMBINER2_NV 0x8552 #define GL_COMBINER3_NV 0x8553 #define GL_COMBINER4_NV 0x8554 #define GL_COMBINER5_NV 0x8555 #define GL_COMBINER6_NV 0x8556 #define GL_COMBINER7_NV 0x8557 typedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); typedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params); #define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV) #define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV) #define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV) #define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV) #define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV) #define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV) #define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV) #define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV) #define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV) #define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV) #define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV) #define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV) #define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV) #define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners) #endif /* GL_NV_register_combiners */ /* ----------------------- GL_NV_register_combiners2 ----------------------- */ #ifndef GL_NV_register_combiners2 #define GL_NV_register_combiners2 1 #define GL_PER_STAGE_CONSTANTS_NV 0x8535 typedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params); #define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV) #define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV) #define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2) #endif /* GL_NV_register_combiners2 */ /* ------------------------ GL_NV_shader_buffer_load ----------------------- */ #ifndef GL_NV_shader_buffer_load #define GL_NV_shader_buffer_load 1 #define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D #define GL_GPU_ADDRESS_NV 0x8F34 #define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT* result); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT* params); typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); typedef void (GLAPIENTRY * PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); typedef void (GLAPIENTRY * PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); typedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); #define glGetBufferParameterui64vNV GLEW_GET_FUN(__glewGetBufferParameterui64vNV) #define glGetIntegerui64vNV GLEW_GET_FUN(__glewGetIntegerui64vNV) #define glGetNamedBufferParameterui64vNV GLEW_GET_FUN(__glewGetNamedBufferParameterui64vNV) #define glIsBufferResidentNV GLEW_GET_FUN(__glewIsBufferResidentNV) #define glIsNamedBufferResidentNV GLEW_GET_FUN(__glewIsNamedBufferResidentNV) #define glMakeBufferNonResidentNV GLEW_GET_FUN(__glewMakeBufferNonResidentNV) #define glMakeBufferResidentNV GLEW_GET_FUN(__glewMakeBufferResidentNV) #define glMakeNamedBufferNonResidentNV GLEW_GET_FUN(__glewMakeNamedBufferNonResidentNV) #define glMakeNamedBufferResidentNV GLEW_GET_FUN(__glewMakeNamedBufferResidentNV) #define glProgramUniformui64NV GLEW_GET_FUN(__glewProgramUniformui64NV) #define glProgramUniformui64vNV GLEW_GET_FUN(__glewProgramUniformui64vNV) #define glUniformui64NV GLEW_GET_FUN(__glewUniformui64NV) #define glUniformui64vNV GLEW_GET_FUN(__glewUniformui64vNV) #define GLEW_NV_shader_buffer_load GLEW_GET_VAR(__GLEW_NV_shader_buffer_load) #endif /* GL_NV_shader_buffer_load */ /* ---------------------- GL_NV_tessellation_program5 ---------------------- */ #ifndef GL_NV_tessellation_program5 #define GL_NV_tessellation_program5 1 #define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 #define GL_TESS_CONTROL_PROGRAM_NV 0x891E #define GL_TESS_EVALUATION_PROGRAM_NV 0x891F #define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 #define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 #define GLEW_NV_tessellation_program5 GLEW_GET_VAR(__GLEW_NV_tessellation_program5) #endif /* GL_NV_tessellation_program5 */ /* -------------------------- GL_NV_texgen_emboss -------------------------- */ #ifndef GL_NV_texgen_emboss #define GL_NV_texgen_emboss 1 #define GL_EMBOSS_LIGHT_NV 0x855D #define GL_EMBOSS_CONSTANT_NV 0x855E #define GL_EMBOSS_MAP_NV 0x855F #define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss) #endif /* GL_NV_texgen_emboss */ /* ------------------------ GL_NV_texgen_reflection ------------------------ */ #ifndef GL_NV_texgen_reflection #define GL_NV_texgen_reflection 1 #define GL_NORMAL_MAP_NV 0x8511 #define GL_REFLECTION_MAP_NV 0x8512 #define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection) #endif /* GL_NV_texgen_reflection */ /* ------------------------- GL_NV_texture_barrier ------------------------- */ #ifndef GL_NV_texture_barrier #define GL_NV_texture_barrier 1 typedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERNVPROC) (void); #define glTextureBarrierNV GLEW_GET_FUN(__glewTextureBarrierNV) #define GLEW_NV_texture_barrier GLEW_GET_VAR(__GLEW_NV_texture_barrier) #endif /* GL_NV_texture_barrier */ /* --------------------- GL_NV_texture_compression_vtc --------------------- */ #ifndef GL_NV_texture_compression_vtc #define GL_NV_texture_compression_vtc 1 #define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc) #endif /* GL_NV_texture_compression_vtc */ /* ----------------------- GL_NV_texture_env_combine4 ---------------------- */ #ifndef GL_NV_texture_env_combine4 #define GL_NV_texture_env_combine4 1 #define GL_COMBINE4_NV 0x8503 #define GL_SOURCE3_RGB_NV 0x8583 #define GL_SOURCE3_ALPHA_NV 0x858B #define GL_OPERAND3_RGB_NV 0x8593 #define GL_OPERAND3_ALPHA_NV 0x859B #define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4) #endif /* GL_NV_texture_env_combine4 */ /* ---------------------- GL_NV_texture_expand_normal ---------------------- */ #ifndef GL_NV_texture_expand_normal #define GL_NV_texture_expand_normal 1 #define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F #define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal) #endif /* GL_NV_texture_expand_normal */ /* ----------------------- GL_NV_texture_multisample ----------------------- */ #ifndef GL_NV_texture_multisample #define GL_NV_texture_multisample 1 #define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 #define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); #define glTexImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage2DMultisampleCoverageNV) #define glTexImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage3DMultisampleCoverageNV) #define glTextureImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage2DMultisampleCoverageNV) #define glTextureImage2DMultisampleNV GLEW_GET_FUN(__glewTextureImage2DMultisampleNV) #define glTextureImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage3DMultisampleCoverageNV) #define glTextureImage3DMultisampleNV GLEW_GET_FUN(__glewTextureImage3DMultisampleNV) #define GLEW_NV_texture_multisample GLEW_GET_VAR(__GLEW_NV_texture_multisample) #endif /* GL_NV_texture_multisample */ /* ------------------------ GL_NV_texture_rectangle ------------------------ */ #ifndef GL_NV_texture_rectangle #define GL_NV_texture_rectangle 1 #define GL_TEXTURE_RECTANGLE_NV 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 #define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle) #endif /* GL_NV_texture_rectangle */ /* -------------------------- GL_NV_texture_shader ------------------------- */ #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 #define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C #define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D #define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E #define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 #define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA #define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB #define GL_DSDT_MAG_INTENSITY_NV 0x86DC #define GL_SHADER_CONSISTENT_NV 0x86DD #define GL_TEXTURE_SHADER_NV 0x86DE #define GL_SHADER_OPERATION_NV 0x86DF #define GL_CULL_MODES_NV 0x86E0 #define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 #define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 #define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 #define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 #define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 #define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 #define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 #define GL_CONST_EYE_NV 0x86E5 #define GL_PASS_THROUGH_NV 0x86E6 #define GL_CULL_FRAGMENT_NV 0x86E7 #define GL_OFFSET_TEXTURE_2D_NV 0x86E8 #define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 #define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA #define GL_DOT_PRODUCT_NV 0x86EC #define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED #define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE #define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 #define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 #define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 #define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 #define GL_HILO_NV 0x86F4 #define GL_DSDT_NV 0x86F5 #define GL_DSDT_MAG_NV 0x86F6 #define GL_DSDT_MAG_VIB_NV 0x86F7 #define GL_HILO16_NV 0x86F8 #define GL_SIGNED_HILO_NV 0x86F9 #define GL_SIGNED_HILO16_NV 0x86FA #define GL_SIGNED_RGBA_NV 0x86FB #define GL_SIGNED_RGBA8_NV 0x86FC #define GL_SIGNED_RGB_NV 0x86FE #define GL_SIGNED_RGB8_NV 0x86FF #define GL_SIGNED_LUMINANCE_NV 0x8701 #define GL_SIGNED_LUMINANCE8_NV 0x8702 #define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 #define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 #define GL_SIGNED_ALPHA_NV 0x8705 #define GL_SIGNED_ALPHA8_NV 0x8706 #define GL_SIGNED_INTENSITY_NV 0x8707 #define GL_SIGNED_INTENSITY8_NV 0x8708 #define GL_DSDT8_NV 0x8709 #define GL_DSDT8_MAG8_NV 0x870A #define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B #define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C #define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D #define GL_HI_SCALE_NV 0x870E #define GL_LO_SCALE_NV 0x870F #define GL_DS_SCALE_NV 0x8710 #define GL_DT_SCALE_NV 0x8711 #define GL_MAGNITUDE_SCALE_NV 0x8712 #define GL_VIBRANCE_SCALE_NV 0x8713 #define GL_HI_BIAS_NV 0x8714 #define GL_LO_BIAS_NV 0x8715 #define GL_DS_BIAS_NV 0x8716 #define GL_DT_BIAS_NV 0x8717 #define GL_MAGNITUDE_BIAS_NV 0x8718 #define GL_VIBRANCE_BIAS_NV 0x8719 #define GL_TEXTURE_BORDER_VALUES_NV 0x871A #define GL_TEXTURE_HI_SIZE_NV 0x871B #define GL_TEXTURE_LO_SIZE_NV 0x871C #define GL_TEXTURE_DS_SIZE_NV 0x871D #define GL_TEXTURE_DT_SIZE_NV 0x871E #define GL_TEXTURE_MAG_SIZE_NV 0x871F #define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader) #endif /* GL_NV_texture_shader */ /* ------------------------- GL_NV_texture_shader2 ------------------------- */ #ifndef GL_NV_texture_shader2 #define GL_NV_texture_shader2 1 #define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA #define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB #define GL_DSDT_MAG_INTENSITY_NV 0x86DC #define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF #define GL_HILO_NV 0x86F4 #define GL_DSDT_NV 0x86F5 #define GL_DSDT_MAG_NV 0x86F6 #define GL_DSDT_MAG_VIB_NV 0x86F7 #define GL_HILO16_NV 0x86F8 #define GL_SIGNED_HILO_NV 0x86F9 #define GL_SIGNED_HILO16_NV 0x86FA #define GL_SIGNED_RGBA_NV 0x86FB #define GL_SIGNED_RGBA8_NV 0x86FC #define GL_SIGNED_RGB_NV 0x86FE #define GL_SIGNED_RGB8_NV 0x86FF #define GL_SIGNED_LUMINANCE_NV 0x8701 #define GL_SIGNED_LUMINANCE8_NV 0x8702 #define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 #define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 #define GL_SIGNED_ALPHA_NV 0x8705 #define GL_SIGNED_ALPHA8_NV 0x8706 #define GL_SIGNED_INTENSITY_NV 0x8707 #define GL_SIGNED_INTENSITY8_NV 0x8708 #define GL_DSDT8_NV 0x8709 #define GL_DSDT8_MAG8_NV 0x870A #define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B #define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C #define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D #define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2) #endif /* GL_NV_texture_shader2 */ /* ------------------------- GL_NV_texture_shader3 ------------------------- */ #ifndef GL_NV_texture_shader3 #define GL_NV_texture_shader3 1 #define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 #define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 #define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 #define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 #define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 #define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 #define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 #define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 #define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 #define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 #define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A #define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B #define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C #define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D #define GL_HILO8_NV 0x885E #define GL_SIGNED_HILO8_NV 0x885F #define GL_FORCE_BLUE_TO_ONE_NV 0x8860 #define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3) #endif /* GL_NV_texture_shader3 */ /* ------------------------ GL_NV_transform_feedback ----------------------- */ #ifndef GL_NV_transform_feedback #define GL_NV_transform_feedback 1 #define GL_BACK_PRIMARY_COLOR_NV 0x8C77 #define GL_BACK_SECONDARY_COLOR_NV 0x8C78 #define GL_TEXTURE_COORD_NV 0x8C79 #define GL_CLIP_DISTANCE_NV 0x8C7A #define GL_VERTEX_ID_NV 0x8C7B #define GL_PRIMITIVE_ID_NV 0x8C7C #define GL_GENERIC_ATTRIB_NV 0x8C7D #define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 #define GL_ACTIVE_VARYINGS_NV 0x8C81 #define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 #define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 #define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 #define GL_PRIMITIVES_GENERATED_NV 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 #define GL_RASTERIZER_DISCARD_NV 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B #define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C #define GL_SEPARATE_ATTRIBS_NV 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F typedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); typedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); typedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); #define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV) #define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV) #define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV) #define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV) #define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV) #define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV) #define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV) #define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV) #define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV) #define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV) #define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV) #define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback) #endif /* GL_NV_transform_feedback */ /* ----------------------- GL_NV_transform_feedback2 ----------------------- */ #ifndef GL_NV_transform_feedback2 #define GL_NV_transform_feedback2 1 #define GL_TRANSFORM_FEEDBACK_NV 0x8E22 #define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 #define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 #define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint* ids); typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); #define glBindTransformFeedbackNV GLEW_GET_FUN(__glewBindTransformFeedbackNV) #define glDeleteTransformFeedbacksNV GLEW_GET_FUN(__glewDeleteTransformFeedbacksNV) #define glDrawTransformFeedbackNV GLEW_GET_FUN(__glewDrawTransformFeedbackNV) #define glGenTransformFeedbacksNV GLEW_GET_FUN(__glewGenTransformFeedbacksNV) #define glIsTransformFeedbackNV GLEW_GET_FUN(__glewIsTransformFeedbackNV) #define glPauseTransformFeedbackNV GLEW_GET_FUN(__glewPauseTransformFeedbackNV) #define glResumeTransformFeedbackNV GLEW_GET_FUN(__glewResumeTransformFeedbackNV) #define GLEW_NV_transform_feedback2 GLEW_GET_VAR(__GLEW_NV_transform_feedback2) #endif /* GL_NV_transform_feedback2 */ /* -------------------------- GL_NV_vdpau_interop -------------------------- */ #ifndef GL_NV_vdpau_interop #define GL_NV_vdpau_interop 1 #define GL_SURFACE_STATE_NV 0x86EB #define GL_SURFACE_REGISTERED_NV 0x86FD #define GL_SURFACE_MAPPED_NV 0x8700 #define GL_WRITE_DISCARD_NV 0x88BE typedef GLintptr GLvdpauSurfaceNV; typedef void (GLAPIENTRY * PFNGLVDPAUFININVPROC) (void); typedef void (GLAPIENTRY * PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei* length, GLint *values); typedef void (GLAPIENTRY * PFNGLVDPAUINITNVPROC) (const void* vdpDevice, const GLvoid*getProcAddress); typedef void (GLAPIENTRY * PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); typedef void (GLAPIENTRY * PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV* surfaces); typedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef void (GLAPIENTRY * PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); typedef void (GLAPIENTRY * PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV* surfaces); typedef void (GLAPIENTRY * PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); #define glVDPAUFiniNV GLEW_GET_FUN(__glewVDPAUFiniNV) #define glVDPAUGetSurfaceivNV GLEW_GET_FUN(__glewVDPAUGetSurfaceivNV) #define glVDPAUInitNV GLEW_GET_FUN(__glewVDPAUInitNV) #define glVDPAUIsSurfaceNV GLEW_GET_FUN(__glewVDPAUIsSurfaceNV) #define glVDPAUMapSurfacesNV GLEW_GET_FUN(__glewVDPAUMapSurfacesNV) #define glVDPAURegisterOutputSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterOutputSurfaceNV) #define glVDPAURegisterVideoSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterVideoSurfaceNV) #define glVDPAUSurfaceAccessNV GLEW_GET_FUN(__glewVDPAUSurfaceAccessNV) #define glVDPAUUnmapSurfacesNV GLEW_GET_FUN(__glewVDPAUUnmapSurfacesNV) #define glVDPAUUnregisterSurfaceNV GLEW_GET_FUN(__glewVDPAUUnregisterSurfaceNV) #define GLEW_NV_vdpau_interop GLEW_GET_VAR(__GLEW_NV_vdpau_interop) #endif /* GL_NV_vdpau_interop */ /* ------------------------ GL_NV_vertex_array_range ----------------------- */ #ifndef GL_NV_vertex_array_range #define GL_NV_vertex_array_range 1 #define GL_VERTEX_ARRAY_RANGE_NV 0x851D #define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E #define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F #define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 #define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* pointer); #define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV) #define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV) #define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range) #endif /* GL_NV_vertex_array_range */ /* ----------------------- GL_NV_vertex_array_range2 ----------------------- */ #ifndef GL_NV_vertex_array_range2 #define GL_NV_vertex_array_range2 1 #define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 #define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2) #endif /* GL_NV_vertex_array_range2 */ /* ------------------- GL_NV_vertex_attrib_integer_64bit ------------------- */ #ifndef GL_NV_vertex_attrib_integer_64bit #define GL_NV_vertex_attrib_integer_64bit 1 #define GL_INT64_NV 0x140E #define GL_UNSIGNED_INT64_NV 0x140F typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); #define glGetVertexAttribLi64vNV GLEW_GET_FUN(__glewGetVertexAttribLi64vNV) #define glGetVertexAttribLui64vNV GLEW_GET_FUN(__glewGetVertexAttribLui64vNV) #define glVertexAttribL1i64NV GLEW_GET_FUN(__glewVertexAttribL1i64NV) #define glVertexAttribL1i64vNV GLEW_GET_FUN(__glewVertexAttribL1i64vNV) #define glVertexAttribL1ui64NV GLEW_GET_FUN(__glewVertexAttribL1ui64NV) #define glVertexAttribL1ui64vNV GLEW_GET_FUN(__glewVertexAttribL1ui64vNV) #define glVertexAttribL2i64NV GLEW_GET_FUN(__glewVertexAttribL2i64NV) #define glVertexAttribL2i64vNV GLEW_GET_FUN(__glewVertexAttribL2i64vNV) #define glVertexAttribL2ui64NV GLEW_GET_FUN(__glewVertexAttribL2ui64NV) #define glVertexAttribL2ui64vNV GLEW_GET_FUN(__glewVertexAttribL2ui64vNV) #define glVertexAttribL3i64NV GLEW_GET_FUN(__glewVertexAttribL3i64NV) #define glVertexAttribL3i64vNV GLEW_GET_FUN(__glewVertexAttribL3i64vNV) #define glVertexAttribL3ui64NV GLEW_GET_FUN(__glewVertexAttribL3ui64NV) #define glVertexAttribL3ui64vNV GLEW_GET_FUN(__glewVertexAttribL3ui64vNV) #define glVertexAttribL4i64NV GLEW_GET_FUN(__glewVertexAttribL4i64NV) #define glVertexAttribL4i64vNV GLEW_GET_FUN(__glewVertexAttribL4i64vNV) #define glVertexAttribL4ui64NV GLEW_GET_FUN(__glewVertexAttribL4ui64NV) #define glVertexAttribL4ui64vNV GLEW_GET_FUN(__glewVertexAttribL4ui64vNV) #define glVertexAttribLFormatNV GLEW_GET_FUN(__glewVertexAttribLFormatNV) #define GLEW_NV_vertex_attrib_integer_64bit GLEW_GET_VAR(__GLEW_NV_vertex_attrib_integer_64bit) #endif /* GL_NV_vertex_attrib_integer_64bit */ /* ------------------- GL_NV_vertex_buffer_unified_memory ------------------ */ #ifndef GL_NV_vertex_buffer_unified_memory #define GL_NV_vertex_buffer_unified_memory 1 #define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E #define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F #define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 #define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 #define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 #define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 #define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 #define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 #define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 #define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 #define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 #define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 #define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A #define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B #define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C #define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D #define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E #define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F #define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 #define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 #define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 #define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 #define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 #define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 #define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 typedef void (GLAPIENTRY * PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); typedef void (GLAPIENTRY * PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); typedef void (GLAPIENTRY * PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT result[]); typedef void (GLAPIENTRY * PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); typedef void (GLAPIENTRY * PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); #define glBufferAddressRangeNV GLEW_GET_FUN(__glewBufferAddressRangeNV) #define glColorFormatNV GLEW_GET_FUN(__glewColorFormatNV) #define glEdgeFlagFormatNV GLEW_GET_FUN(__glewEdgeFlagFormatNV) #define glFogCoordFormatNV GLEW_GET_FUN(__glewFogCoordFormatNV) #define glGetIntegerui64i_vNV GLEW_GET_FUN(__glewGetIntegerui64i_vNV) #define glIndexFormatNV GLEW_GET_FUN(__glewIndexFormatNV) #define glNormalFormatNV GLEW_GET_FUN(__glewNormalFormatNV) #define glSecondaryColorFormatNV GLEW_GET_FUN(__glewSecondaryColorFormatNV) #define glTexCoordFormatNV GLEW_GET_FUN(__glewTexCoordFormatNV) #define glVertexAttribFormatNV GLEW_GET_FUN(__glewVertexAttribFormatNV) #define glVertexAttribIFormatNV GLEW_GET_FUN(__glewVertexAttribIFormatNV) #define glVertexFormatNV GLEW_GET_FUN(__glewVertexFormatNV) #define GLEW_NV_vertex_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_vertex_buffer_unified_memory) #endif /* GL_NV_vertex_buffer_unified_memory */ /* -------------------------- GL_NV_vertex_program ------------------------- */ #ifndef GL_NV_vertex_program #define GL_NV_vertex_program 1 #define GL_VERTEX_PROGRAM_NV 0x8620 #define GL_VERTEX_STATE_PROGRAM_NV 0x8621 #define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 #define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 #define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 #define GL_CURRENT_ATTRIB_NV 0x8626 #define GL_PROGRAM_LENGTH_NV 0x8627 #define GL_PROGRAM_STRING_NV 0x8628 #define GL_MODELVIEW_PROJECTION_NV 0x8629 #define GL_IDENTITY_NV 0x862A #define GL_INVERSE_NV 0x862B #define GL_TRANSPOSE_NV 0x862C #define GL_INVERSE_TRANSPOSE_NV 0x862D #define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E #define GL_MAX_TRACK_MATRICES_NV 0x862F #define GL_MATRIX0_NV 0x8630 #define GL_MATRIX1_NV 0x8631 #define GL_MATRIX2_NV 0x8632 #define GL_MATRIX3_NV 0x8633 #define GL_MATRIX4_NV 0x8634 #define GL_MATRIX5_NV 0x8635 #define GL_MATRIX6_NV 0x8636 #define GL_MATRIX7_NV 0x8637 #define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 #define GL_CURRENT_MATRIX_NV 0x8641 #define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 #define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 #define GL_PROGRAM_PARAMETER_NV 0x8644 #define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 #define GL_PROGRAM_TARGET_NV 0x8646 #define GL_PROGRAM_RESIDENT_NV 0x8647 #define GL_TRACK_MATRIX_NV 0x8648 #define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 #define GL_VERTEX_PROGRAM_BINDING_NV 0x864A #define GL_PROGRAM_ERROR_POSITION_NV 0x864B #define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 #define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 #define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 #define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 #define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 #define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 #define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 #define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 #define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 #define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 #define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A #define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B #define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C #define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D #define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E #define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F #define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 #define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 #define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 #define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 #define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 #define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 #define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 #define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 #define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 #define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 #define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A #define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B #define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C #define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D #define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E #define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F #define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 #define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 #define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 #define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 #define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 #define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 #define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 #define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 #define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 #define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 #define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A #define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B #define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C #define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D #define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E #define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F typedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences); typedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids); typedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program); typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid** pointer); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params); typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); typedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids); typedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v); #define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV) #define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV) #define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV) #define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV) #define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV) #define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV) #define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV) #define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV) #define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV) #define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV) #define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV) #define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV) #define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV) #define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV) #define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV) #define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV) #define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV) #define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV) #define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV) #define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV) #define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV) #define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV) #define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV) #define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV) #define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV) #define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV) #define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV) #define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV) #define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV) #define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV) #define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV) #define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV) #define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV) #define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV) #define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV) #define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV) #define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV) #define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV) #define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV) #define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV) #define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV) #define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV) #define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV) #define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV) #define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV) #define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV) #define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV) #define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV) #define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV) #define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV) #define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV) #define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV) #define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV) #define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV) #define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV) #define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV) #define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV) #define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV) #define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV) #define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV) #define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV) #define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV) #define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV) #define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV) #define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program) #endif /* GL_NV_vertex_program */ /* ------------------------ GL_NV_vertex_program1_1 ------------------------ */ #ifndef GL_NV_vertex_program1_1 #define GL_NV_vertex_program1_1 1 #define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1) #endif /* GL_NV_vertex_program1_1 */ /* ------------------------- GL_NV_vertex_program2 ------------------------- */ #ifndef GL_NV_vertex_program2 #define GL_NV_vertex_program2 1 #define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2) #endif /* GL_NV_vertex_program2 */ /* ---------------------- GL_NV_vertex_program2_option --------------------- */ #ifndef GL_NV_vertex_program2_option #define GL_NV_vertex_program2_option 1 #define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 #define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 #define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option) #endif /* GL_NV_vertex_program2_option */ /* ------------------------- GL_NV_vertex_program3 ------------------------- */ #ifndef GL_NV_vertex_program3 #define GL_NV_vertex_program3 1 #define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C #define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3) #endif /* GL_NV_vertex_program3 */ /* ------------------------- GL_NV_vertex_program4 ------------------------- */ #ifndef GL_NV_vertex_program4 #define GL_NV_vertex_program4 1 #define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD #define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4) #endif /* GL_NV_vertex_program4 */ /* -------------------------- GL_NV_video_capture -------------------------- */ #ifndef GL_NV_video_capture #define GL_NV_video_capture 1 #define GL_VIDEO_BUFFER_NV 0x9020 #define GL_VIDEO_BUFFER_BINDING_NV 0x9021 #define GL_FIELD_UPPER_NV 0x9022 #define GL_FIELD_LOWER_NV 0x9023 #define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 #define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 #define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 #define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 #define GL_VIDEO_BUFFER_PITCH_NV 0x9028 #define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 #define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A #define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B #define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C #define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D #define GL_PARTIAL_SUCCESS_NV 0x902E #define GL_SUCCESS_NV 0x902F #define GL_FAILURE_NV 0x9030 #define GL_YCBYCR8_422_NV 0x9031 #define GL_YCBAYCR8A_4224_NV 0x9032 #define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 #define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 #define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 #define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 #define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 #define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 #define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 #define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A #define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B #define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C typedef void (GLAPIENTRY * PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); typedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); typedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); typedef void (GLAPIENTRY * PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint* params); typedef GLenum (GLAPIENTRY * PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint* sequence_num, GLuint64EXT *capture_time); typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble* params); typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint* params); #define glBeginVideoCaptureNV GLEW_GET_FUN(__glewBeginVideoCaptureNV) #define glBindVideoCaptureStreamBufferNV GLEW_GET_FUN(__glewBindVideoCaptureStreamBufferNV) #define glBindVideoCaptureStreamTextureNV GLEW_GET_FUN(__glewBindVideoCaptureStreamTextureNV) #define glEndVideoCaptureNV GLEW_GET_FUN(__glewEndVideoCaptureNV) #define glGetVideoCaptureStreamdvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamdvNV) #define glGetVideoCaptureStreamfvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamfvNV) #define glGetVideoCaptureStreamivNV GLEW_GET_FUN(__glewGetVideoCaptureStreamivNV) #define glGetVideoCaptureivNV GLEW_GET_FUN(__glewGetVideoCaptureivNV) #define glVideoCaptureNV GLEW_GET_FUN(__glewVideoCaptureNV) #define glVideoCaptureStreamParameterdvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterdvNV) #define glVideoCaptureStreamParameterfvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterfvNV) #define glVideoCaptureStreamParameterivNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterivNV) #define GLEW_NV_video_capture GLEW_GET_VAR(__GLEW_NV_video_capture) #endif /* GL_NV_video_capture */ /* ------------------------ GL_OES_byte_coordinates ------------------------ */ #ifndef GL_OES_byte_coordinates #define GL_OES_byte_coordinates 1 #define GL_BYTE 0x1400 #define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates) #endif /* GL_OES_byte_coordinates */ /* ------------------- GL_OES_compressed_paletted_texture ------------------ */ #ifndef GL_OES_compressed_paletted_texture #define GL_OES_compressed_paletted_texture 1 #define GL_PALETTE4_RGB8_OES 0x8B90 #define GL_PALETTE4_RGBA8_OES 0x8B91 #define GL_PALETTE4_R5_G6_B5_OES 0x8B92 #define GL_PALETTE4_RGBA4_OES 0x8B93 #define GL_PALETTE4_RGB5_A1_OES 0x8B94 #define GL_PALETTE8_RGB8_OES 0x8B95 #define GL_PALETTE8_RGBA8_OES 0x8B96 #define GL_PALETTE8_R5_G6_B5_OES 0x8B97 #define GL_PALETTE8_RGBA4_OES 0x8B98 #define GL_PALETTE8_RGB5_A1_OES 0x8B99 #define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture) #endif /* GL_OES_compressed_paletted_texture */ /* --------------------------- GL_OES_read_format -------------------------- */ #ifndef GL_OES_read_format #define GL_OES_read_format 1 #define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B #define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format) #endif /* GL_OES_read_format */ /* ------------------------ GL_OES_single_precision ------------------------ */ #ifndef GL_OES_single_precision #define GL_OES_single_precision 1 typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampd depth); typedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation); typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); typedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation); typedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); #define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES) #define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES) #define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES) #define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES) #define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES) #define glOrthofOES GLEW_GET_FUN(__glewOrthofOES) #define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision) #endif /* GL_OES_single_precision */ /* ---------------------------- GL_OML_interlace --------------------------- */ #ifndef GL_OML_interlace #define GL_OML_interlace 1 #define GL_INTERLACE_OML 0x8980 #define GL_INTERLACE_READ_OML 0x8981 #define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace) #endif /* GL_OML_interlace */ /* ---------------------------- GL_OML_resample ---------------------------- */ #ifndef GL_OML_resample #define GL_OML_resample 1 #define GL_PACK_RESAMPLE_OML 0x8984 #define GL_UNPACK_RESAMPLE_OML 0x8985 #define GL_RESAMPLE_REPLICATE_OML 0x8986 #define GL_RESAMPLE_ZERO_FILL_OML 0x8987 #define GL_RESAMPLE_AVERAGE_OML 0x8988 #define GL_RESAMPLE_DECIMATE_OML 0x8989 #define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample) #endif /* GL_OML_resample */ /* ---------------------------- GL_OML_subsample --------------------------- */ #ifndef GL_OML_subsample #define GL_OML_subsample 1 #define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 #define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 #define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample) #endif /* GL_OML_subsample */ /* --------------------------- GL_PGI_misc_hints --------------------------- */ #ifndef GL_PGI_misc_hints #define GL_PGI_misc_hints 1 #define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 #define GL_CONSERVE_MEMORY_HINT_PGI 107005 #define GL_RECLAIM_MEMORY_HINT_PGI 107006 #define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 #define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 #define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 #define GL_ALWAYS_FAST_HINT_PGI 107020 #define GL_ALWAYS_SOFT_HINT_PGI 107021 #define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 #define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 #define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 #define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 #define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 #define GL_STRICT_LIGHTING_HINT_PGI 107031 #define GL_STRICT_SCISSOR_HINT_PGI 107032 #define GL_FULL_STIPPLE_HINT_PGI 107033 #define GL_CLIP_NEAR_HINT_PGI 107040 #define GL_CLIP_FAR_HINT_PGI 107041 #define GL_WIDE_LINE_HINT_PGI 107042 #define GL_BACK_NORMALS_HINT_PGI 107043 #define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints) #endif /* GL_PGI_misc_hints */ /* -------------------------- GL_PGI_vertex_hints -------------------------- */ #ifndef GL_PGI_vertex_hints #define GL_PGI_vertex_hints 1 #define GL_VERTEX23_BIT_PGI 0x00000004 #define GL_VERTEX4_BIT_PGI 0x00000008 #define GL_COLOR3_BIT_PGI 0x00010000 #define GL_COLOR4_BIT_PGI 0x00020000 #define GL_EDGEFLAG_BIT_PGI 0x00040000 #define GL_INDEX_BIT_PGI 0x00080000 #define GL_MAT_AMBIENT_BIT_PGI 0x00100000 #define GL_VERTEX_DATA_HINT_PGI 107050 #define GL_VERTEX_CONSISTENT_HINT_PGI 107051 #define GL_MATERIAL_SIDE_HINT_PGI 107052 #define GL_MAX_VERTEX_HINT_PGI 107053 #define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 #define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 #define GL_MAT_EMISSION_BIT_PGI 0x00800000 #define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 #define GL_MAT_SHININESS_BIT_PGI 0x02000000 #define GL_MAT_SPECULAR_BIT_PGI 0x04000000 #define GL_NORMAL_BIT_PGI 0x08000000 #define GL_TEXCOORD1_BIT_PGI 0x10000000 #define GL_TEXCOORD2_BIT_PGI 0x20000000 #define GL_TEXCOORD3_BIT_PGI 0x40000000 #define GL_TEXCOORD4_BIT_PGI 0x80000000 #define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints) #endif /* GL_PGI_vertex_hints */ /* ----------------------- GL_REND_screen_coordinates ---------------------- */ #ifndef GL_REND_screen_coordinates #define GL_REND_screen_coordinates 1 #define GL_SCREEN_COORDINATES_REND 0x8490 #define GL_INVERTED_SCREEN_W_REND 0x8491 #define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates) #endif /* GL_REND_screen_coordinates */ /* ------------------------------- GL_S3_s3tc ------------------------------ */ #ifndef GL_S3_s3tc #define GL_S3_s3tc 1 #define GL_RGB_S3TC 0x83A0 #define GL_RGB4_S3TC 0x83A1 #define GL_RGBA_S3TC 0x83A2 #define GL_RGBA4_S3TC 0x83A3 #define GL_RGBA_DXT5_S3TC 0x83A4 #define GL_RGBA4_DXT5_S3TC 0x83A5 #define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc) #endif /* GL_S3_s3tc */ /* -------------------------- GL_SGIS_color_range -------------------------- */ #ifndef GL_SGIS_color_range #define GL_SGIS_color_range 1 #define GL_EXTENDED_RANGE_SGIS 0x85A5 #define GL_MIN_RED_SGIS 0x85A6 #define GL_MAX_RED_SGIS 0x85A7 #define GL_MIN_GREEN_SGIS 0x85A8 #define GL_MAX_GREEN_SGIS 0x85A9 #define GL_MIN_BLUE_SGIS 0x85AA #define GL_MAX_BLUE_SGIS 0x85AB #define GL_MIN_ALPHA_SGIS 0x85AC #define GL_MAX_ALPHA_SGIS 0x85AD #define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range) #endif /* GL_SGIS_color_range */ /* ------------------------- GL_SGIS_detail_texture ------------------------ */ #ifndef GL_SGIS_detail_texture #define GL_SGIS_detail_texture 1 typedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); typedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points); #define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS) #define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS) #define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture) #endif /* GL_SGIS_detail_texture */ /* -------------------------- GL_SGIS_fog_function ------------------------- */ #ifndef GL_SGIS_fog_function #define GL_SGIS_fog_function 1 typedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points); typedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points); #define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS) #define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS) #define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function) #endif /* GL_SGIS_fog_function */ /* ------------------------ GL_SGIS_generate_mipmap ------------------------ */ #ifndef GL_SGIS_generate_mipmap #define GL_SGIS_generate_mipmap 1 #define GL_GENERATE_MIPMAP_SGIS 0x8191 #define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 #define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap) #endif /* GL_SGIS_generate_mipmap */ /* -------------------------- GL_SGIS_multisample -------------------------- */ #ifndef GL_SGIS_multisample #define GL_SGIS_multisample 1 #define GL_MULTISAMPLE_SGIS 0x809D #define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F #define GL_SAMPLE_MASK_SGIS 0x80A0 #define GL_1PASS_SGIS 0x80A1 #define GL_2PASS_0_SGIS 0x80A2 #define GL_2PASS_1_SGIS 0x80A3 #define GL_4PASS_0_SGIS 0x80A4 #define GL_4PASS_1_SGIS 0x80A5 #define GL_4PASS_2_SGIS 0x80A6 #define GL_4PASS_3_SGIS 0x80A7 #define GL_SAMPLE_BUFFERS_SGIS 0x80A8 #define GL_SAMPLES_SGIS 0x80A9 #define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA #define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB #define GL_SAMPLE_PATTERN_SGIS 0x80AC #define GL_MULTISAMPLE_BIT_EXT 0x20000000 typedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); #define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS) #define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS) #define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample) #endif /* GL_SGIS_multisample */ /* ------------------------- GL_SGIS_pixel_texture ------------------------- */ #ifndef GL_SGIS_pixel_texture #define GL_SGIS_pixel_texture 1 #define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture) #endif /* GL_SGIS_pixel_texture */ /* ----------------------- GL_SGIS_point_line_texgen ----------------------- */ #ifndef GL_SGIS_point_line_texgen #define GL_SGIS_point_line_texgen 1 #define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 #define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 #define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 #define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 #define GL_EYE_POINT_SGIS 0x81F4 #define GL_OBJECT_POINT_SGIS 0x81F5 #define GL_EYE_LINE_SGIS 0x81F6 #define GL_OBJECT_LINE_SGIS 0x81F7 #define GLEW_SGIS_point_line_texgen GLEW_GET_VAR(__GLEW_SGIS_point_line_texgen) #endif /* GL_SGIS_point_line_texgen */ /* ------------------------ GL_SGIS_sharpen_texture ------------------------ */ #ifndef GL_SGIS_sharpen_texture #define GL_SGIS_sharpen_texture 1 typedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points); typedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); #define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS) #define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS) #define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture) #endif /* GL_SGIS_sharpen_texture */ /* --------------------------- GL_SGIS_texture4D --------------------------- */ #ifndef GL_SGIS_texture4D #define GL_SGIS_texture4D 1 typedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void* pixels); typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void* pixels); #define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS) #define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS) #define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D) #endif /* GL_SGIS_texture4D */ /* ---------------------- GL_SGIS_texture_border_clamp --------------------- */ #ifndef GL_SGIS_texture_border_clamp #define GL_SGIS_texture_border_clamp 1 #define GL_CLAMP_TO_BORDER_SGIS 0x812D #define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp) #endif /* GL_SGIS_texture_border_clamp */ /* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */ #ifndef GL_SGIS_texture_edge_clamp #define GL_SGIS_texture_edge_clamp 1 #define GL_CLAMP_TO_EDGE_SGIS 0x812F #define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp) #endif /* GL_SGIS_texture_edge_clamp */ /* ------------------------ GL_SGIS_texture_filter4 ------------------------ */ #ifndef GL_SGIS_texture_filter4 #define GL_SGIS_texture_filter4 1 typedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights); typedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights); #define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS) #define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS) #define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4) #endif /* GL_SGIS_texture_filter4 */ /* -------------------------- GL_SGIS_texture_lod -------------------------- */ #ifndef GL_SGIS_texture_lod #define GL_SGIS_texture_lod 1 #define GL_TEXTURE_MIN_LOD_SGIS 0x813A #define GL_TEXTURE_MAX_LOD_SGIS 0x813B #define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C #define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D #define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod) #endif /* GL_SGIS_texture_lod */ /* ------------------------- GL_SGIS_texture_select ------------------------ */ #ifndef GL_SGIS_texture_select #define GL_SGIS_texture_select 1 #define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select) #endif /* GL_SGIS_texture_select */ /* ----------------------------- GL_SGIX_async ----------------------------- */ #ifndef GL_SGIX_async #define GL_SGIX_async 1 #define GL_ASYNC_MARKER_SGIX 0x8329 typedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); typedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); typedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp); typedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); typedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); typedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp); #define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX) #define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX) #define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX) #define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX) #define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX) #define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX) #define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async) #endif /* GL_SGIX_async */ /* ------------------------ GL_SGIX_async_histogram ------------------------ */ #ifndef GL_SGIX_async_histogram #define GL_SGIX_async_histogram 1 #define GL_ASYNC_HISTOGRAM_SGIX 0x832C #define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D #define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram) #endif /* GL_SGIX_async_histogram */ /* -------------------------- GL_SGIX_async_pixel -------------------------- */ #ifndef GL_SGIX_async_pixel #define GL_SGIX_async_pixel 1 #define GL_ASYNC_TEX_IMAGE_SGIX 0x835C #define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D #define GL_ASYNC_READ_PIXELS_SGIX 0x835E #define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F #define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 #define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 #define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel) #endif /* GL_SGIX_async_pixel */ /* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */ #ifndef GL_SGIX_blend_alpha_minmax #define GL_SGIX_blend_alpha_minmax 1 #define GL_ALPHA_MIN_SGIX 0x8320 #define GL_ALPHA_MAX_SGIX 0x8321 #define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax) #endif /* GL_SGIX_blend_alpha_minmax */ /* ---------------------------- GL_SGIX_clipmap ---------------------------- */ #ifndef GL_SGIX_clipmap #define GL_SGIX_clipmap 1 #define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap) #endif /* GL_SGIX_clipmap */ /* ---------------------- GL_SGIX_convolution_accuracy --------------------- */ #ifndef GL_SGIX_convolution_accuracy #define GL_SGIX_convolution_accuracy 1 #define GL_CONVOLUTION_HINT_SGIX 0x8316 #define GLEW_SGIX_convolution_accuracy GLEW_GET_VAR(__GLEW_SGIX_convolution_accuracy) #endif /* GL_SGIX_convolution_accuracy */ /* ------------------------- GL_SGIX_depth_texture ------------------------- */ #ifndef GL_SGIX_depth_texture #define GL_SGIX_depth_texture 1 #define GL_DEPTH_COMPONENT16_SGIX 0x81A5 #define GL_DEPTH_COMPONENT24_SGIX 0x81A6 #define GL_DEPTH_COMPONENT32_SGIX 0x81A7 #define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture) #endif /* GL_SGIX_depth_texture */ /* -------------------------- GL_SGIX_flush_raster ------------------------- */ #ifndef GL_SGIX_flush_raster #define GL_SGIX_flush_raster 1 typedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); #define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX) #define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster) #endif /* GL_SGIX_flush_raster */ /* --------------------------- GL_SGIX_fog_offset -------------------------- */ #ifndef GL_SGIX_fog_offset #define GL_SGIX_fog_offset 1 #define GL_FOG_OFFSET_SGIX 0x8198 #define GL_FOG_OFFSET_VALUE_SGIX 0x8199 #define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset) #endif /* GL_SGIX_fog_offset */ /* -------------------------- GL_SGIX_fog_texture -------------------------- */ #ifndef GL_SGIX_fog_texture #define GL_SGIX_fog_texture 1 #define GL_TEXTURE_FOG_SGIX 0 #define GL_FOG_PATCHY_FACTOR_SGIX 0 #define GL_FRAGMENT_FOG_SGIX 0 typedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname); #define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX) #define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture) #endif /* GL_SGIX_fog_texture */ /* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */ #ifndef GL_SGIX_fragment_specular_lighting #define GL_SGIX_fragment_specular_lighting 1 typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param); typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data); typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data); #define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX) #define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX) #define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX) #define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX) #define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX) #define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX) #define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX) #define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX) #define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX) #define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX) #define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX) #define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX) #define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX) #define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX) #define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX) #define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX) #define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX) #define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting) #endif /* GL_SGIX_fragment_specular_lighting */ /* --------------------------- GL_SGIX_framezoom --------------------------- */ #ifndef GL_SGIX_framezoom #define GL_SGIX_framezoom 1 typedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); #define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX) #define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom) #endif /* GL_SGIX_framezoom */ /* --------------------------- GL_SGIX_interlace --------------------------- */ #ifndef GL_SGIX_interlace #define GL_SGIX_interlace 1 #define GL_INTERLACE_SGIX 0x8094 #define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace) #endif /* GL_SGIX_interlace */ /* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */ #ifndef GL_SGIX_ir_instrument1 #define GL_SGIX_ir_instrument1 1 #define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1) #endif /* GL_SGIX_ir_instrument1 */ /* ------------------------- GL_SGIX_list_priority ------------------------- */ #ifndef GL_SGIX_list_priority #define GL_SGIX_list_priority 1 #define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority) #endif /* GL_SGIX_list_priority */ /* ------------------------- GL_SGIX_pixel_texture ------------------------- */ #ifndef GL_SGIX_pixel_texture #define GL_SGIX_pixel_texture 1 typedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); #define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX) #define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture) #endif /* GL_SGIX_pixel_texture */ /* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */ #ifndef GL_SGIX_pixel_texture_bits #define GL_SGIX_pixel_texture_bits 1 #define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits) #endif /* GL_SGIX_pixel_texture_bits */ /* ------------------------ GL_SGIX_reference_plane ------------------------ */ #ifndef GL_SGIX_reference_plane #define GL_SGIX_reference_plane 1 typedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation); #define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX) #define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane) #endif /* GL_SGIX_reference_plane */ /* ---------------------------- GL_SGIX_resample --------------------------- */ #ifndef GL_SGIX_resample #define GL_SGIX_resample 1 #define GL_PACK_RESAMPLE_SGIX 0x842E #define GL_UNPACK_RESAMPLE_SGIX 0x842F #define GL_RESAMPLE_DECIMATE_SGIX 0x8430 #define GL_RESAMPLE_REPLICATE_SGIX 0x8433 #define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 #define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample) #endif /* GL_SGIX_resample */ /* ----------------------------- GL_SGIX_shadow ---------------------------- */ #ifndef GL_SGIX_shadow #define GL_SGIX_shadow 1 #define GL_TEXTURE_COMPARE_SGIX 0x819A #define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B #define GL_TEXTURE_LEQUAL_R_SGIX 0x819C #define GL_TEXTURE_GEQUAL_R_SGIX 0x819D #define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow) #endif /* GL_SGIX_shadow */ /* ------------------------- GL_SGIX_shadow_ambient ------------------------ */ #ifndef GL_SGIX_shadow_ambient #define GL_SGIX_shadow_ambient 1 #define GL_SHADOW_AMBIENT_SGIX 0x80BF #define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient) #endif /* GL_SGIX_shadow_ambient */ /* ----------------------------- GL_SGIX_sprite ---------------------------- */ #ifndef GL_SGIX_sprite #define GL_SGIX_sprite 1 typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params); #define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX) #define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX) #define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX) #define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX) #define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite) #endif /* GL_SGIX_sprite */ /* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */ #ifndef GL_SGIX_tag_sample_buffer #define GL_SGIX_tag_sample_buffer 1 typedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); #define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX) #define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer) #endif /* GL_SGIX_tag_sample_buffer */ /* ------------------------ GL_SGIX_texture_add_env ------------------------ */ #ifndef GL_SGIX_texture_add_env #define GL_SGIX_texture_add_env 1 #define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env) #endif /* GL_SGIX_texture_add_env */ /* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */ #ifndef GL_SGIX_texture_coordinate_clamp #define GL_SGIX_texture_coordinate_clamp 1 #define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 #define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A #define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B #define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp) #endif /* GL_SGIX_texture_coordinate_clamp */ /* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */ #ifndef GL_SGIX_texture_lod_bias #define GL_SGIX_texture_lod_bias 1 #define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias) #endif /* GL_SGIX_texture_lod_bias */ /* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */ #ifndef GL_SGIX_texture_multi_buffer #define GL_SGIX_texture_multi_buffer 1 #define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E #define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer) #endif /* GL_SGIX_texture_multi_buffer */ /* ------------------------- GL_SGIX_texture_range ------------------------- */ #ifndef GL_SGIX_texture_range #define GL_SGIX_texture_range 1 #define GL_RGB_SIGNED_SGIX 0x85E0 #define GL_RGBA_SIGNED_SGIX 0x85E1 #define GL_ALPHA_SIGNED_SGIX 0x85E2 #define GL_LUMINANCE_SIGNED_SGIX 0x85E3 #define GL_INTENSITY_SIGNED_SGIX 0x85E4 #define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5 #define GL_RGB16_SIGNED_SGIX 0x85E6 #define GL_RGBA16_SIGNED_SGIX 0x85E7 #define GL_ALPHA16_SIGNED_SGIX 0x85E8 #define GL_LUMINANCE16_SIGNED_SGIX 0x85E9 #define GL_INTENSITY16_SIGNED_SGIX 0x85EA #define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB #define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC #define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED #define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE #define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF #define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0 #define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1 #define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2 #define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3 #define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4 #define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5 #define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6 #define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7 #define GL_MIN_LUMINANCE_SGIS 0x85F8 #define GL_MAX_LUMINANCE_SGIS 0x85F9 #define GL_MIN_INTENSITY_SGIS 0x85FA #define GL_MAX_INTENSITY_SGIS 0x85FB #define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range) #endif /* GL_SGIX_texture_range */ /* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */ #ifndef GL_SGIX_texture_scale_bias #define GL_SGIX_texture_scale_bias 1 #define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 #define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A #define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B #define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C #define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias) #endif /* GL_SGIX_texture_scale_bias */ /* ------------------------- GL_SGIX_vertex_preclip ------------------------ */ #ifndef GL_SGIX_vertex_preclip #define GL_SGIX_vertex_preclip 1 #define GL_VERTEX_PRECLIP_SGIX 0x83EE #define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF #define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip) #endif /* GL_SGIX_vertex_preclip */ /* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */ #ifndef GL_SGIX_vertex_preclip_hint #define GL_SGIX_vertex_preclip_hint 1 #define GL_VERTEX_PRECLIP_SGIX 0x83EE #define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF #define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint) #endif /* GL_SGIX_vertex_preclip_hint */ /* ----------------------------- GL_SGIX_ycrcb ----------------------------- */ #ifndef GL_SGIX_ycrcb #define GL_SGIX_ycrcb 1 #define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb) #endif /* GL_SGIX_ycrcb */ /* -------------------------- GL_SGI_color_matrix -------------------------- */ #ifndef GL_SGI_color_matrix #define GL_SGI_color_matrix 1 #define GL_COLOR_MATRIX_SGI 0x80B1 #define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 #define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 #define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 #define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 #define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 #define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 #define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 #define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 #define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA #define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB #define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix) #endif /* GL_SGI_color_matrix */ /* --------------------------- GL_SGI_color_table -------------------------- */ #ifndef GL_SGI_color_table #define GL_SGI_color_table 1 #define GL_COLOR_TABLE_SGI 0x80D0 #define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 #define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 #define GL_PROXY_COLOR_TABLE_SGI 0x80D3 #define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 #define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 #define GL_COLOR_TABLE_SCALE_SGI 0x80D6 #define GL_COLOR_TABLE_BIAS_SGI 0x80D7 #define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 #define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 #define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params); typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params); typedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* table); typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params); typedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void* table); #define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI) #define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI) #define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI) #define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI) #define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI) #define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI) #define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI) #define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table) #endif /* GL_SGI_color_table */ /* ----------------------- GL_SGI_texture_color_table ---------------------- */ #ifndef GL_SGI_texture_color_table #define GL_SGI_texture_color_table 1 #define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC #define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD #define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table) #endif /* GL_SGI_texture_color_table */ /* ------------------------- GL_SUNX_constant_data ------------------------- */ #ifndef GL_SUNX_constant_data #define GL_SUNX_constant_data 1 #define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 #define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 typedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); #define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX) #define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data) #endif /* GL_SUNX_constant_data */ /* -------------------- GL_SUN_convolution_border_modes -------------------- */ #ifndef GL_SUN_convolution_border_modes #define GL_SUN_convolution_border_modes 1 #define GL_WRAP_BORDER_SUN 0x81D4 #define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes) #endif /* GL_SUN_convolution_border_modes */ /* -------------------------- GL_SUN_global_alpha -------------------------- */ #ifndef GL_SUN_global_alpha #define GL_SUN_global_alpha 1 #define GL_GLOBAL_ALPHA_SUN 0x81D9 #define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); #define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN) #define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN) #define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN) #define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN) #define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN) #define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN) #define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN) #define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN) #define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha) #endif /* GL_SUN_global_alpha */ /* --------------------------- GL_SUN_mesh_array --------------------------- */ #ifndef GL_SUN_mesh_array #define GL_SUN_mesh_array 1 #define GL_QUAD_MESH_SUN 0x8614 #define GL_TRIANGLE_MESH_SUN 0x8615 #define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array) #endif /* GL_SUN_mesh_array */ /* ------------------------ GL_SUN_read_video_pixels ----------------------- */ #ifndef GL_SUN_read_video_pixels #define GL_SUN_read_video_pixels 1 typedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); #define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN) #define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels) #endif /* GL_SUN_read_video_pixels */ /* --------------------------- GL_SUN_slice_accum -------------------------- */ #ifndef GL_SUN_slice_accum #define GL_SUN_slice_accum 1 #define GL_SLICE_ACCUM_SUN 0x85CC #define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum) #endif /* GL_SUN_slice_accum */ /* -------------------------- GL_SUN_triangle_list ------------------------- */ #ifndef GL_SUN_triangle_list #define GL_SUN_triangle_list 1 #define GL_RESTART_SUN 0x01 #define GL_REPLACE_MIDDLE_SUN 0x02 #define GL_REPLACE_OLDEST_SUN 0x03 #define GL_TRIANGLE_LIST_SUN 0x81D7 #define GL_REPLACEMENT_CODE_SUN 0x81D8 #define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 #define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 #define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 #define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 #define GL_R1UI_V3F_SUN 0x85C4 #define GL_R1UI_C4UB_V3F_SUN 0x85C5 #define GL_R1UI_C3F_V3F_SUN 0x85C6 #define GL_R1UI_N3F_V3F_SUN 0x85C7 #define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 #define GL_R1UI_T2F_V3F_SUN 0x85C9 #define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA #define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void* pointer); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code); #define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN) #define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN) #define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN) #define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN) #define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN) #define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN) #define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN) #define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list) #endif /* GL_SUN_triangle_list */ /* ----------------------------- GL_SUN_vertex ----------------------------- */ #ifndef GL_SUN_vertex #define GL_SUN_vertex 1 typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v); #define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN) #define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN) #define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN) #define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN) #define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN) #define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN) #define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN) #define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN) #define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN) #define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN) #define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN) #define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN) #define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN) #define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN) #define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN) #define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN) #define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN) #define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN) #define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) #define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) #define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) #define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) #define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN) #define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN) #define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN) #define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN) #define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN) #define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN) #define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN) #define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN) #define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN) #define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN) #define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN) #define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN) #define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN) #define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN) #define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN) #define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN) #define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN) #define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN) #define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex) #endif /* GL_SUN_vertex */ /* -------------------------- GL_WIN_phong_shading ------------------------- */ #ifndef GL_WIN_phong_shading #define GL_WIN_phong_shading 1 #define GL_PHONG_WIN 0x80EA #define GL_PHONG_HINT_WIN 0x80EB #define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading) #endif /* GL_WIN_phong_shading */ /* -------------------------- GL_WIN_specular_fog -------------------------- */ #ifndef GL_WIN_specular_fog #define GL_WIN_specular_fog 1 #define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC #define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog) #endif /* GL_WIN_specular_fog */ /* ---------------------------- GL_WIN_swap_hint --------------------------- */ #ifndef GL_WIN_swap_hint #define GL_WIN_swap_hint 1 typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); #define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN) #define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint) #endif /* GL_WIN_swap_hint */ /* ------------------------------------------------------------------------- */ #if defined(GLEW_MX) && defined(_WIN32) #define GLEW_FUN_EXPORT #else #define GLEW_FUN_EXPORT GLEWAPI #endif /* GLEW_MX */ #if defined(GLEW_MX) #define GLEW_VAR_EXPORT #else #define GLEW_VAR_EXPORT GLEWAPI #endif /* GLEW_MX */ #if defined(GLEW_MX) && defined(_WIN32) struct GLEWContextStruct { #endif /* GLEW_MX */ GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D; GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture; GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv; GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage; GLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate; GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer; GLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd; GLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv; GLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf; GLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIPROC __glewPointParameteri; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv; GLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery; GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer; GLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData; GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData; GLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers; GLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries; GLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery; GLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers; GLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv; GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv; GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv; GLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv; GLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer; GLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery; GLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer; GLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer; GLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader; GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate; GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader; GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram; GLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader; GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram; GLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader; GLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray; GLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers; GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray; GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform; GLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders; GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation; GLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog; GLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv; GLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog; GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource; GLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv; GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation; GLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv; GLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv; GLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram; GLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader; GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram; GLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource; GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate; GLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate; GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate; GLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f; GLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv; GLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i; GLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv; GLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f; GLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv; GLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i; GLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv; GLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f; GLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv; GLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i; GLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv; GLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f; GLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv; GLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i; GLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv; GLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram; GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv; GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender; GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback; GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation; GLEW_FUN_EXPORT PFNGLCLAMPCOLORPROC __glewClampColor; GLEW_FUN_EXPORT PFNGLCLEARBUFFERFIPROC __glewClearBufferfi; GLEW_FUN_EXPORT PFNGLCLEARBUFFERFVPROC __glewClearBufferfv; GLEW_FUN_EXPORT PFNGLCLEARBUFFERIVPROC __glewClearBufferiv; GLEW_FUN_EXPORT PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv; GLEW_FUN_EXPORT PFNGLCOLORMASKIPROC __glewColorMaski; GLEW_FUN_EXPORT PFNGLDISABLEIPROC __glewDisablei; GLEW_FUN_EXPORT PFNGLENABLEIPROC __glewEnablei; GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender; GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback; GLEW_FUN_EXPORT PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v; GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation; GLEW_FUN_EXPORT PFNGLGETSTRINGIPROC __glewGetStringi; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying; GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv; GLEW_FUN_EXPORT PFNGLISENABLEDIPROC __glewIsEnabledi; GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv; GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings; GLEW_FUN_EXPORT PFNGLUNIFORM1UIPROC __glewUniform1ui; GLEW_FUN_EXPORT PFNGLUNIFORM1UIVPROC __glewUniform1uiv; GLEW_FUN_EXPORT PFNGLUNIFORM2UIPROC __glewUniform2ui; GLEW_FUN_EXPORT PFNGLUNIFORM2UIVPROC __glewUniform2uiv; GLEW_FUN_EXPORT PFNGLUNIFORM3UIPROC __glewUniform3ui; GLEW_FUN_EXPORT PFNGLUNIFORM3UIVPROC __glewUniform3uiv; GLEW_FUN_EXPORT PFNGLUNIFORM4UIPROC __glewUniform4ui; GLEW_FUN_EXPORT PFNGLUNIFORM4UIVPROC __glewUniform4uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced; GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex; GLEW_FUN_EXPORT PFNGLTEXBUFFERPROC __glewTexBuffer; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v; GLEW_FUN_EXPORT PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORPROC __glewVertexAttribDivisor; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIPROC __glewBlendEquationi; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei; GLEW_FUN_EXPORT PFNGLBLENDFUNCIPROC __glewBlendFunci; GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGPROC __glewMinSampleShading; GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKAMDPROC __glewDebugMessageCallbackAMD; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEENABLEAMDPROC __glewDebugMessageEnableAMD; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTAMDPROC __glewDebugMessageInsertAMD; GLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGAMDPROC __glewGetDebugMessageLogAMD; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD; GLEW_FUN_EXPORT PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC __glewMultiDrawArraysIndirectAMD; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC __glewMultiDrawElementsIndirectAMD; GLEW_FUN_EXPORT PFNGLDELETENAMESAMDPROC __glewDeleteNamesAMD; GLEW_FUN_EXPORT PFNGLGENNAMESAMDPROC __glewGenNamesAMD; GLEW_FUN_EXPORT PFNGLISNAMEAMDPROC __glewIsNameAMD; GLEW_FUN_EXPORT PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD; GLEW_FUN_EXPORT PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD; GLEW_FUN_EXPORT PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD; GLEW_FUN_EXPORT PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD; GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD; GLEW_FUN_EXPORT PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD; GLEW_FUN_EXPORT PFNGLSETMULTISAMPLEFVAMDPROC __glewSetMultisamplefvAMD; GLEW_FUN_EXPORT PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD; GLEW_FUN_EXPORT PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD; GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE; GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE; GLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE; GLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE; GLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE; GLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE; GLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE; GLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE; GLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE; GLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE; GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE; GLEW_FUN_EXPORT PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE; GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE; GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE; GLEW_FUN_EXPORT PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE; GLEW_FUN_EXPORT PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE; GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE; GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE; GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE; GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE; GLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE; GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE; GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE; GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE; GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE; GLEW_FUN_EXPORT PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE; GLEW_FUN_EXPORT PFNGLCLEARDEPTHFPROC __glewClearDepthf; GLEW_FUN_EXPORT PFNGLDEPTHRANGEFPROC __glewDepthRangef; GLEW_FUN_EXPORT PFNGLGETSHADERPRECISIONFORMATPROC __glewGetShaderPrecisionFormat; GLEW_FUN_EXPORT PFNGLRELEASESHADERCOMPILERPROC __glewReleaseShaderCompiler; GLEW_FUN_EXPORT PFNGLSHADERBINARYPROC __glewShaderBinary; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC __glewDrawArraysInstancedBaseInstance; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC __glewDrawElementsInstancedBaseInstance; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC __glewDrawElementsInstancedBaseVertexBaseInstance; GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed; GLEW_FUN_EXPORT PFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex; GLEW_FUN_EXPORT PFNGLCREATESYNCFROMCLEVENTARBPROC __glewCreateSyncFromCLeventARB; GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; GLEW_FUN_EXPORT PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKARBPROC __glewDebugMessageCallbackARB; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLARBPROC __glewDebugMessageControlARB; GLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTARBPROC __glewDebugMessageInsertARB; GLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGARBPROC __glewGetDebugMessageLogARB; GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB; GLEW_FUN_EXPORT PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect; GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer; GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer; GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer; GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus; GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers; GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer; GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers; GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers; GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap; GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv; GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv; GLEW_FUN_EXPORT PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer; GLEW_FUN_EXPORT PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMBINARYPROC __glewGetProgramBinary; GLEW_FUN_EXPORT PFNGLPROGRAMBINARYPROC __glewProgramBinary; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIPROC __glewProgramParameteri; GLEW_FUN_EXPORT PFNGLGETUNIFORMDVPROC __glewGetUniformdv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DEXTPROC __glewProgramUniform1dEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DVEXTPROC __glewProgramUniform1dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DEXTPROC __glewProgramUniform2dEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DVEXTPROC __glewProgramUniform2dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DEXTPROC __glewProgramUniform3dEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DVEXTPROC __glewProgramUniform3dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DEXTPROC __glewProgramUniform4dEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DVEXTPROC __glewProgramUniform4dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC __glewProgramUniformMatrix2dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC __glewProgramUniformMatrix2x3dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC __glewProgramUniformMatrix2x4dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC __glewProgramUniformMatrix3dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC __glewProgramUniformMatrix3x2dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC __glewProgramUniformMatrix3x4dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC __glewProgramUniformMatrix4dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC __glewProgramUniformMatrix4x2dvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC __glewProgramUniformMatrix4x3dvEXT; GLEW_FUN_EXPORT PFNGLUNIFORM1DPROC __glewUniform1d; GLEW_FUN_EXPORT PFNGLUNIFORM1DVPROC __glewUniform1dv; GLEW_FUN_EXPORT PFNGLUNIFORM2DPROC __glewUniform2d; GLEW_FUN_EXPORT PFNGLUNIFORM2DVPROC __glewUniform2dv; GLEW_FUN_EXPORT PFNGLUNIFORM3DPROC __glewUniform3d; GLEW_FUN_EXPORT PFNGLUNIFORM3DVPROC __glewUniform3dv; GLEW_FUN_EXPORT PFNGLUNIFORM4DPROC __glewUniform4d; GLEW_FUN_EXPORT PFNGLUNIFORM4DVPROC __glewUniform4dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2DVPROC __glewUniformMatrix2dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3DVPROC __glewUniformMatrix2x3dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4DVPROC __glewUniformMatrix2x4dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3DVPROC __glewUniformMatrix3dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2DVPROC __glewUniformMatrix3x2dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4DVPROC __glewUniformMatrix3x4dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4DVPROC __glewUniformMatrix4dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2DVPROC __glewUniformMatrix4x2dv; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3DVPROC __glewUniformMatrix4x3dv; GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable; GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable; GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv; GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv; GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D; GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv; GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable; GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable; GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D; GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv; GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax; GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv; GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv; GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter; GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram; GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax; GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram; GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax; GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB; GLEW_FUN_EXPORT PFNGLGETINTERNALFORMATIVPROC __glewGetInternalformativ; GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange; GLEW_FUN_EXPORT PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange; GLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB; GLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB; GLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB; GLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB; GLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB; GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB; GLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB; GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB; GLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB; GLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB; GLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB; GLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB; GLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB; GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB; GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex; GLEW_FUN_EXPORT PFNGLGETGRAPHICSRESETSTATUSARBPROC __glewGetGraphicsResetStatusARB; GLEW_FUN_EXPORT PFNGLGETNCOLORTABLEARBPROC __glewGetnColorTableARB; GLEW_FUN_EXPORT PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC __glewGetnCompressedTexImageARB; GLEW_FUN_EXPORT PFNGLGETNCONVOLUTIONFILTERARBPROC __glewGetnConvolutionFilterARB; GLEW_FUN_EXPORT PFNGLGETNHISTOGRAMARBPROC __glewGetnHistogramARB; GLEW_FUN_EXPORT PFNGLGETNMAPDVARBPROC __glewGetnMapdvARB; GLEW_FUN_EXPORT PFNGLGETNMAPFVARBPROC __glewGetnMapfvARB; GLEW_FUN_EXPORT PFNGLGETNMAPIVARBPROC __glewGetnMapivARB; GLEW_FUN_EXPORT PFNGLGETNMINMAXARBPROC __glewGetnMinmaxARB; GLEW_FUN_EXPORT PFNGLGETNPIXELMAPFVARBPROC __glewGetnPixelMapfvARB; GLEW_FUN_EXPORT PFNGLGETNPIXELMAPUIVARBPROC __glewGetnPixelMapuivARB; GLEW_FUN_EXPORT PFNGLGETNPIXELMAPUSVARBPROC __glewGetnPixelMapusvARB; GLEW_FUN_EXPORT PFNGLGETNPOLYGONSTIPPLEARBPROC __glewGetnPolygonStippleARB; GLEW_FUN_EXPORT PFNGLGETNSEPARABLEFILTERARBPROC __glewGetnSeparableFilterARB; GLEW_FUN_EXPORT PFNGLGETNTEXIMAGEARBPROC __glewGetnTexImageARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMDVARBPROC __glewGetnUniformdvARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMFVARBPROC __glewGetnUniformfvARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMIVARBPROC __glewGetnUniformivARB; GLEW_FUN_EXPORT PFNGLGETNUNIFORMUIVARBPROC __glewGetnUniformuivARB; GLEW_FUN_EXPORT PFNGLREADNPIXELSARBPROC __glewReadnPixelsARB; GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB; GLEW_FUN_EXPORT PFNGLBINDSAMPLERPROC __glewBindSampler; GLEW_FUN_EXPORT PFNGLDELETESAMPLERSPROC __glewDeleteSamplers; GLEW_FUN_EXPORT PFNGLGENSAMPLERSPROC __glewGenSamplers; GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv; GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv; GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv; GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv; GLEW_FUN_EXPORT PFNGLISSAMPLERPROC __glewIsSampler; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri; GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv; GLEW_FUN_EXPORT PFNGLACTIVESHADERPROGRAMPROC __glewActiveShaderProgram; GLEW_FUN_EXPORT PFNGLBINDPROGRAMPIPELINEPROC __glewBindProgramPipeline; GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMVPROC __glewCreateShaderProgramv; GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPIPELINESPROC __glewDeleteProgramPipelines; GLEW_FUN_EXPORT PFNGLGENPROGRAMPIPELINESPROC __glewGenProgramPipelines; GLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEINFOLOGPROC __glewGetProgramPipelineInfoLog; GLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEIVPROC __glewGetProgramPipelineiv; GLEW_FUN_EXPORT PFNGLISPROGRAMPIPELINEPROC __glewIsProgramPipeline; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DPROC __glewProgramUniform1d; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DVPROC __glewProgramUniform1dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FPROC __glewProgramUniform1f; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVPROC __glewProgramUniform1fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IPROC __glewProgramUniform1i; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVPROC __glewProgramUniform1iv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIPROC __glewProgramUniform1ui; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVPROC __glewProgramUniform1uiv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DPROC __glewProgramUniform2d; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DVPROC __glewProgramUniform2dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FPROC __glewProgramUniform2f; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVPROC __glewProgramUniform2fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IPROC __glewProgramUniform2i; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVPROC __glewProgramUniform2iv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIPROC __glewProgramUniform2ui; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVPROC __glewProgramUniform2uiv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DPROC __glewProgramUniform3d; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DVPROC __glewProgramUniform3dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FPROC __glewProgramUniform3f; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVPROC __glewProgramUniform3fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IPROC __glewProgramUniform3i; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVPROC __glewProgramUniform3iv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIPROC __glewProgramUniform3ui; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVPROC __glewProgramUniform3uiv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DPROC __glewProgramUniform4d; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DVPROC __glewProgramUniform4dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FPROC __glewProgramUniform4f; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVPROC __glewProgramUniform4fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IPROC __glewProgramUniform4i; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVPROC __glewProgramUniform4iv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIPROC __glewProgramUniform4ui; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVPROC __glewProgramUniform4uiv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2DVPROC __glewProgramUniformMatrix2dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVPROC __glewProgramUniformMatrix2fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC __glewProgramUniformMatrix2x3dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC __glewProgramUniformMatrix2x3fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC __glewProgramUniformMatrix2x4dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC __glewProgramUniformMatrix2x4fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3DVPROC __glewProgramUniformMatrix3dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVPROC __glewProgramUniformMatrix3fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC __glewProgramUniformMatrix3x2dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC __glewProgramUniformMatrix3x2fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC __glewProgramUniformMatrix3x4dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC __glewProgramUniformMatrix3x4fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4DVPROC __glewProgramUniformMatrix4dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVPROC __glewProgramUniformMatrix4fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC __glewProgramUniformMatrix4x2dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC __glewProgramUniformMatrix4x2fv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC __glewProgramUniformMatrix4x3dv; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC __glewProgramUniformMatrix4x3fv; GLEW_FUN_EXPORT PFNGLUSEPROGRAMSTAGESPROC __glewUseProgramStages; GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPIPELINEPROC __glewValidateProgramPipeline; GLEW_FUN_EXPORT PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC __glewGetActiveAtomicCounterBufferiv; GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREPROC __glewBindImageTexture; GLEW_FUN_EXPORT PFNGLMEMORYBARRIERPROC __glewMemoryBarrier; GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; GLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB; GLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB; GLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB; GLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB; GLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB; GLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB; GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB; GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB; GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB; GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB; GLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB; GLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB; GLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB; GLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB; GLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB; GLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB; GLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB; GLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB; GLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB; GLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB; GLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB; GLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB; GLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB; GLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB; GLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB; GLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB; GLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB; GLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB; GLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB; GLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB; GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName; GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName; GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv; GLEW_FUN_EXPORT PFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv; GLEW_FUN_EXPORT PFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex; GLEW_FUN_EXPORT PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation; GLEW_FUN_EXPORT PFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv; GLEW_FUN_EXPORT PFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv; GLEW_FUN_EXPORT PFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB; GLEW_FUN_EXPORT PFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB; GLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB; GLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB; GLEW_FUN_EXPORT PFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB; GLEW_FUN_EXPORT PFNGLNAMEDSTRINGARBPROC __glewNamedStringARB; GLEW_FUN_EXPORT PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync; GLEW_FUN_EXPORT PFNGLDELETESYNCPROC __glewDeleteSync; GLEW_FUN_EXPORT PFNGLFENCESYNCPROC __glewFenceSync; GLEW_FUN_EXPORT PFNGLGETINTEGER64VPROC __glewGetInteger64v; GLEW_FUN_EXPORT PFNGLGETSYNCIVPROC __glewGetSynciv; GLEW_FUN_EXPORT PFNGLISSYNCPROC __glewIsSync; GLEW_FUN_EXPORT PFNGLWAITSYNCPROC __glewWaitSync; GLEW_FUN_EXPORT PFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv; GLEW_FUN_EXPORT PFNGLPATCHPARAMETERIPROC __glewPatchParameteri; GLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB; GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv; GLEW_FUN_EXPORT PFNGLSAMPLEMASKIPROC __glewSampleMaski; GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample; GLEW_FUN_EXPORT PFNGLTEXSTORAGE1DPROC __glewTexStorage1D; GLEW_FUN_EXPORT PFNGLTEXSTORAGE2DPROC __glewTexStorage2D; GLEW_FUN_EXPORT PFNGLTEXSTORAGE3DPROC __glewTexStorage3D; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE1DEXTPROC __glewTextureStorage1DEXT; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DEXTPROC __glewTextureStorage2DEXT; GLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DEXTPROC __glewTextureStorage3DEXT; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v; GLEW_FUN_EXPORT PFNGLQUERYCOUNTERPROC __glewQueryCounter; GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback; GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback; GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks; GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback; GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback; GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback; GLEW_FUN_EXPORT PFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream; GLEW_FUN_EXPORT PFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed; GLEW_FUN_EXPORT PFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC __glewDrawTransformFeedbackInstanced; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC __glewDrawTransformFeedbackStreamInstanced; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB; GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase; GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName; GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv; GLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v; GLEW_FUN_EXPORT PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex; GLEW_FUN_EXPORT PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices; GLEW_FUN_EXPORT PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding; GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray; GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays; GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays; GLEW_FUN_EXPORT PFNGLISVERTEXARRAYPROC __glewIsVertexArray; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVPROC __glewGetVertexAttribLdv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DPROC __glewVertexAttribL1d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVPROC __glewVertexAttribL1dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DPROC __glewVertexAttribL2d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVPROC __glewVertexAttribL2dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DPROC __glewVertexAttribL3d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVPROC __glewVertexAttribL3dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DPROC __glewVertexAttribL4d; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVPROC __glewVertexAttribL4dv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTERPROC __glewVertexAttribLPointer; GLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB; GLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB; GLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB; GLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB; GLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB; GLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB; GLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB; GLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB; GLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB; GLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB; GLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB; GLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB; GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB; GLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB; GLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB; GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB; GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB; GLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB; GLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB; GLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB; GLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB; GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB; GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB; GLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB; GLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB; GLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB; GLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB; GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; GLEW_FUN_EXPORT PFNGLCOLORP3UIPROC __glewColorP3ui; GLEW_FUN_EXPORT PFNGLCOLORP3UIVPROC __glewColorP3uiv; GLEW_FUN_EXPORT PFNGLCOLORP4UIPROC __glewColorP4ui; GLEW_FUN_EXPORT PFNGLCOLORP4UIVPROC __glewColorP4uiv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv; GLEW_FUN_EXPORT PFNGLNORMALP3UIPROC __glewNormalP3ui; GLEW_FUN_EXPORT PFNGLNORMALP3UIVPROC __glewNormalP3uiv; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv; GLEW_FUN_EXPORT PFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui; GLEW_FUN_EXPORT PFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv; GLEW_FUN_EXPORT PFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui; GLEW_FUN_EXPORT PFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv; GLEW_FUN_EXPORT PFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui; GLEW_FUN_EXPORT PFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv; GLEW_FUN_EXPORT PFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui; GLEW_FUN_EXPORT PFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv; GLEW_FUN_EXPORT PFNGLVERTEXP2UIPROC __glewVertexP2ui; GLEW_FUN_EXPORT PFNGLVERTEXP2UIVPROC __glewVertexP2uiv; GLEW_FUN_EXPORT PFNGLVERTEXP3UIPROC __glewVertexP3ui; GLEW_FUN_EXPORT PFNGLVERTEXP3UIVPROC __glewVertexP3uiv; GLEW_FUN_EXPORT PFNGLVERTEXP4UIPROC __glewVertexP4ui; GLEW_FUN_EXPORT PFNGLVERTEXP4UIVPROC __glewVertexP4uiv; GLEW_FUN_EXPORT PFNGLDEPTHRANGEARRAYVPROC __glewDepthRangeArrayv; GLEW_FUN_EXPORT PFNGLDEPTHRANGEINDEXEDPROC __glewDepthRangeIndexed; GLEW_FUN_EXPORT PFNGLGETDOUBLEI_VPROC __glewGetDoublei_v; GLEW_FUN_EXPORT PFNGLGETFLOATI_VPROC __glewGetFloati_v; GLEW_FUN_EXPORT PFNGLSCISSORARRAYVPROC __glewScissorArrayv; GLEW_FUN_EXPORT PFNGLSCISSORINDEXEDPROC __glewScissorIndexed; GLEW_FUN_EXPORT PFNGLSCISSORINDEXEDVPROC __glewScissorIndexedv; GLEW_FUN_EXPORT PFNGLVIEWPORTARRAYVPROC __glewViewportArrayv; GLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFPROC __glewViewportIndexedf; GLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFVPROC __glewViewportIndexedfv; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB; GLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI; GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI; GLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI; GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI; GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI; GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI; GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI; GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI; GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI; GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI; GLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI; GLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI; GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI; GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI; GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI; GLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI; GLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI; GLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI; GLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI; GLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI; GLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI; GLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI; GLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI; GLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glewPNTrianglesfATI; GLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glewPNTrianglesiATI; GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI; GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI; GLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI; GLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI; GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI; GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI; GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI; GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI; GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI; GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI; GLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI; GLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI; GLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI; GLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI; GLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI; GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI; GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI; GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI; GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI; GLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT; GLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT; GLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT; GLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT; GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT; GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT; GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT; GLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT; GLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT; GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT; GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT; GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT; GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT; GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT; GLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT; GLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT; GLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT; GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT; GLEW_FUN_EXPORT PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT; GLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT; GLEW_FUN_EXPORT PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT; GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT; GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT; GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT; GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT; GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT; GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT; GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT; GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT; GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT; GLEW_FUN_EXPORT PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT; GLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT; GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT; GLEW_FUN_EXPORT PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT; GLEW_FUN_EXPORT PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT; GLEW_FUN_EXPORT PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT; GLEW_FUN_EXPORT PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT; GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT; GLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT; GLEW_FUN_EXPORT PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT; GLEW_FUN_EXPORT PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT; GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT; GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT; GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT; GLEW_FUN_EXPORT PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT; GLEW_FUN_EXPORT PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT; GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT; GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT; GLEW_FUN_EXPORT PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT; GLEW_FUN_EXPORT PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT; GLEW_FUN_EXPORT PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT; GLEW_FUN_EXPORT PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT; GLEW_FUN_EXPORT PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT; GLEW_FUN_EXPORT PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT; GLEW_FUN_EXPORT PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT; GLEW_FUN_EXPORT PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT; GLEW_FUN_EXPORT PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT; GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT; GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT; GLEW_FUN_EXPORT PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT; GLEW_FUN_EXPORT PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT; GLEW_FUN_EXPORT PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT; GLEW_FUN_EXPORT PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT; GLEW_FUN_EXPORT PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT; GLEW_FUN_EXPORT PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT; GLEW_FUN_EXPORT PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT; GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT; GLEW_FUN_EXPORT PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT; GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT; GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT; GLEW_FUN_EXPORT PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT; GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT; GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT; GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT; GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT; GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT; GLEW_FUN_EXPORT PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT; GLEW_FUN_EXPORT PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT; GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT; GLEW_FUN_EXPORT PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT; GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT; GLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT; GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT; GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT; GLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT; GLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT; GLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT; GLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT; GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT; GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT; GLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT; GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT; GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT; GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT; GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT; GLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT; GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT; GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT; GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT; GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT; GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT; GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT; GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT; GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT; GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT; GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT; GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT; GLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT; GLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT; GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT; GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT; GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT; GLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT; GLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT; GLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT; GLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT; GLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT; GLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT; GLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT; GLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT; GLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT; GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT; GLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT; GLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT; GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT; GLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT; GLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT; GLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT; GLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT; GLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT; GLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT; GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT; GLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT; GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT; GLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT; GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT; GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT; GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT; GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT; GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT; GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT; GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT; GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT; GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT; GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT; GLEW_FUN_EXPORT PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT; GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT; GLEW_FUN_EXPORT PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT; GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT; GLEW_FUN_EXPORT PFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT; GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT; GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT; GLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT; GLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT; GLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT; GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT; GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT; GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT; GLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT; GLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT; GLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT; GLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT; GLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT; GLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT; GLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT; GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT; GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT; GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT; GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT; GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT; GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT; GLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT; GLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT; GLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT; GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT; GLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT; GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT; GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT; GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; GLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT; GLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT; GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT; GLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT; GLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT; GLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT; GLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT; GLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT; GLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT; GLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT; GLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT; GLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT; GLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT; GLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT; GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT; GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT; GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT; GLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT; GLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT; GLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT; GLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT; GLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT; GLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT; GLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT; GLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT; GLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT; GLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT; GLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT; GLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT; GLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT; GLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT; GLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT; GLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT; GLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT; GLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT; GLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT; GLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT; GLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT; GLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT; GLEW_FUN_EXPORT PFNGLIMPORTSYNCEXTPROC __glewImportSyncEXT; GLEW_FUN_EXPORT PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY; GLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY; GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP; GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP; GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP; GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP; GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP; GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP; GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM; GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM; GLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM; GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM; GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM; GLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM; GLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM; GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM; GLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM; GLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL; GLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL; GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL; GLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL; GLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL; GLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL; GLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDPROC __glewBufferRegionEnabled; GLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONPROC __glewDeleteBufferRegion; GLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONPROC __glewDrawBufferRegion; GLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONPROC __glewNewBufferRegion; GLEW_FUN_EXPORT PFNGLREADBUFFERREGIONPROC __glewReadBufferRegion; GLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA; GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA; GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV; GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV; GLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV; GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV; GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV; GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV; GLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV; GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV; GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV; GLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV; GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV; GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV; GLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV; GLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV; GLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV; GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV; GLEW_FUN_EXPORT PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV; GLEW_FUN_EXPORT PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV; GLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV; GLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV; GLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV; GLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV; GLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV; GLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV; GLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV; GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV; GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV; GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV; GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV; GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; GLEW_FUN_EXPORT PFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV; GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM1I64NVPROC __glewUniform1i64NV; GLEW_FUN_EXPORT PFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV; GLEW_FUN_EXPORT PFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM2I64NVPROC __glewUniform2i64NV; GLEW_FUN_EXPORT PFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV; GLEW_FUN_EXPORT PFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM3I64NVPROC __glewUniform3i64NV; GLEW_FUN_EXPORT PFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV; GLEW_FUN_EXPORT PFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM4I64NVPROC __glewUniform4i64NV; GLEW_FUN_EXPORT PFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV; GLEW_FUN_EXPORT PFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV; GLEW_FUN_EXPORT PFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV; GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; GLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV; GLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV; GLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV; GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV; GLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV; GLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV; GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV; GLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV; GLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV; GLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV; GLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV; GLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV; GLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV; GLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV; GLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV; GLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV; GLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV; GLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV; GLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV; GLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV; GLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV; GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV; GLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV; GLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV; GLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV; GLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV; GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV; GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV; GLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV; GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV; GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV; GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV; GLEW_FUN_EXPORT PFNGLCOPYPATHNVPROC __glewCopyPathNV; GLEW_FUN_EXPORT PFNGLCOVERFILLPATHINSTANCEDNVPROC __glewCoverFillPathInstancedNV; GLEW_FUN_EXPORT PFNGLCOVERFILLPATHNVPROC __glewCoverFillPathNV; GLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHINSTANCEDNVPROC __glewCoverStrokePathInstancedNV; GLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHNVPROC __glewCoverStrokePathNV; GLEW_FUN_EXPORT PFNGLDELETEPATHSNVPROC __glewDeletePathsNV; GLEW_FUN_EXPORT PFNGLGENPATHSNVPROC __glewGenPathsNV; GLEW_FUN_EXPORT PFNGLGETPATHCOLORGENFVNVPROC __glewGetPathColorGenfvNV; GLEW_FUN_EXPORT PFNGLGETPATHCOLORGENIVNVPROC __glewGetPathColorGenivNV; GLEW_FUN_EXPORT PFNGLGETPATHCOMMANDSNVPROC __glewGetPathCommandsNV; GLEW_FUN_EXPORT PFNGLGETPATHCOORDSNVPROC __glewGetPathCoordsNV; GLEW_FUN_EXPORT PFNGLGETPATHDASHARRAYNVPROC __glewGetPathDashArrayNV; GLEW_FUN_EXPORT PFNGLGETPATHLENGTHNVPROC __glewGetPathLengthNV; GLEW_FUN_EXPORT PFNGLGETPATHMETRICRANGENVPROC __glewGetPathMetricRangeNV; GLEW_FUN_EXPORT PFNGLGETPATHMETRICSNVPROC __glewGetPathMetricsNV; GLEW_FUN_EXPORT PFNGLGETPATHPARAMETERFVNVPROC __glewGetPathParameterfvNV; GLEW_FUN_EXPORT PFNGLGETPATHPARAMETERIVNVPROC __glewGetPathParameterivNV; GLEW_FUN_EXPORT PFNGLGETPATHSPACINGNVPROC __glewGetPathSpacingNV; GLEW_FUN_EXPORT PFNGLGETPATHTEXGENFVNVPROC __glewGetPathTexGenfvNV; GLEW_FUN_EXPORT PFNGLGETPATHTEXGENIVNVPROC __glewGetPathTexGenivNV; GLEW_FUN_EXPORT PFNGLINTERPOLATEPATHSNVPROC __glewInterpolatePathsNV; GLEW_FUN_EXPORT PFNGLISPATHNVPROC __glewIsPathNV; GLEW_FUN_EXPORT PFNGLISPOINTINFILLPATHNVPROC __glewIsPointInFillPathNV; GLEW_FUN_EXPORT PFNGLISPOINTINSTROKEPATHNVPROC __glewIsPointInStrokePathNV; GLEW_FUN_EXPORT PFNGLPATHCOLORGENNVPROC __glewPathColorGenNV; GLEW_FUN_EXPORT PFNGLPATHCOMMANDSNVPROC __glewPathCommandsNV; GLEW_FUN_EXPORT PFNGLPATHCOORDSNVPROC __glewPathCoordsNV; GLEW_FUN_EXPORT PFNGLPATHCOVERDEPTHFUNCNVPROC __glewPathCoverDepthFuncNV; GLEW_FUN_EXPORT PFNGLPATHDASHARRAYNVPROC __glewPathDashArrayNV; GLEW_FUN_EXPORT PFNGLPATHFOGGENNVPROC __glewPathFogGenNV; GLEW_FUN_EXPORT PFNGLPATHGLYPHRANGENVPROC __glewPathGlyphRangeNV; GLEW_FUN_EXPORT PFNGLPATHGLYPHSNVPROC __glewPathGlyphsNV; GLEW_FUN_EXPORT PFNGLPATHPARAMETERFNVPROC __glewPathParameterfNV; GLEW_FUN_EXPORT PFNGLPATHPARAMETERFVNVPROC __glewPathParameterfvNV; GLEW_FUN_EXPORT PFNGLPATHPARAMETERINVPROC __glewPathParameteriNV; GLEW_FUN_EXPORT PFNGLPATHPARAMETERIVNVPROC __glewPathParameterivNV; GLEW_FUN_EXPORT PFNGLPATHSTENCILDEPTHOFFSETNVPROC __glewPathStencilDepthOffsetNV; GLEW_FUN_EXPORT PFNGLPATHSTENCILFUNCNVPROC __glewPathStencilFuncNV; GLEW_FUN_EXPORT PFNGLPATHSTRINGNVPROC __glewPathStringNV; GLEW_FUN_EXPORT PFNGLPATHSUBCOMMANDSNVPROC __glewPathSubCommandsNV; GLEW_FUN_EXPORT PFNGLPATHSUBCOORDSNVPROC __glewPathSubCoordsNV; GLEW_FUN_EXPORT PFNGLPATHTEXGENNVPROC __glewPathTexGenNV; GLEW_FUN_EXPORT PFNGLPOINTALONGPATHNVPROC __glewPointAlongPathNV; GLEW_FUN_EXPORT PFNGLSTENCILFILLPATHINSTANCEDNVPROC __glewStencilFillPathInstancedNV; GLEW_FUN_EXPORT PFNGLSTENCILFILLPATHNVPROC __glewStencilFillPathNV; GLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC __glewStencilStrokePathInstancedNV; GLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHNVPROC __glewStencilStrokePathNV; GLEW_FUN_EXPORT PFNGLTRANSFORMPATHNVPROC __glewTransformPathNV; GLEW_FUN_EXPORT PFNGLWEIGHTPATHSNVPROC __glewWeightPathsNV; GLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV; GLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV; GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV; GLEW_FUN_EXPORT PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV; GLEW_FUN_EXPORT PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV; GLEW_FUN_EXPORT PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV; GLEW_FUN_EXPORT PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV; GLEW_FUN_EXPORT PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV; GLEW_FUN_EXPORT PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV; GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV; GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV; GLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV; GLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV; GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV; GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV; GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV; GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV; GLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV; GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV; GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV; GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV; GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV; GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV; GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV; GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV; GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV; GLEW_FUN_EXPORT PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV; GLEW_FUN_EXPORT PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV; GLEW_FUN_EXPORT PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV; GLEW_FUN_EXPORT PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV; GLEW_FUN_EXPORT PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV; GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV; GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV; GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV; GLEW_FUN_EXPORT PFNGLUNIFORMUI64NVPROC __glewUniformui64NV; GLEW_FUN_EXPORT PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV; GLEW_FUN_EXPORT PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV; GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTexImage2DMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTexImage3DMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTextureImage2DMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC __glewTextureImage2DMultisampleNV; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTextureImage3DMultisampleCoverageNV; GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC __glewTextureImage3DMultisampleNV; GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV; GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV; GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV; GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV; GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV; GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV; GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV; GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV; GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV; GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV; GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV; GLEW_FUN_EXPORT PFNGLVDPAUFININVPROC __glewVDPAUFiniNV; GLEW_FUN_EXPORT PFNGLVDPAUGETSURFACEIVNVPROC __glewVDPAUGetSurfaceivNV; GLEW_FUN_EXPORT PFNGLVDPAUINITNVPROC __glewVDPAUInitNV; GLEW_FUN_EXPORT PFNGLVDPAUISSURFACENVPROC __glewVDPAUIsSurfaceNV; GLEW_FUN_EXPORT PFNGLVDPAUMAPSURFACESNVPROC __glewVDPAUMapSurfacesNV; GLEW_FUN_EXPORT PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC __glewVDPAURegisterOutputSurfaceNV; GLEW_FUN_EXPORT PFNGLVDPAUREGISTERVIDEOSURFACENVPROC __glewVDPAURegisterVideoSurfaceNV; GLEW_FUN_EXPORT PFNGLVDPAUSURFACEACCESSNVPROC __glewVDPAUSurfaceAccessNV; GLEW_FUN_EXPORT PFNGLVDPAUUNMAPSURFACESNVPROC __glewVDPAUUnmapSurfacesNV; GLEW_FUN_EXPORT PFNGLVDPAUUNREGISTERSURFACENVPROC __glewVDPAUUnregisterSurfaceNV; GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV; GLEW_FUN_EXPORT PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV; GLEW_FUN_EXPORT PFNGLCOLORFORMATNVPROC __glewColorFormatNV; GLEW_FUN_EXPORT PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV; GLEW_FUN_EXPORT PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV; GLEW_FUN_EXPORT PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV; GLEW_FUN_EXPORT PFNGLINDEXFORMATNVPROC __glewIndexFormatNV; GLEW_FUN_EXPORT PFNGLNORMALFORMATNVPROC __glewNormalFormatNV; GLEW_FUN_EXPORT PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV; GLEW_FUN_EXPORT PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV; GLEW_FUN_EXPORT PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV; GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV; GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV; GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV; GLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV; GLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV; GLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV; GLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV; GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV; GLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV; GLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV; GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV; GLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV; GLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV; GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV; GLEW_FUN_EXPORT PFNGLBEGINVIDEOCAPTURENVPROC __glewBeginVideoCaptureNV; GLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC __glewBindVideoCaptureStreamBufferNV; GLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC __glewBindVideoCaptureStreamTextureNV; GLEW_FUN_EXPORT PFNGLENDVIDEOCAPTURENVPROC __glewEndVideoCaptureNV; GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMDVNVPROC __glewGetVideoCaptureStreamdvNV; GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMFVNVPROC __glewGetVideoCaptureStreamfvNV; GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMIVNVPROC __glewGetVideoCaptureStreamivNV; GLEW_FUN_EXPORT PFNGLGETVIDEOCAPTUREIVNVPROC __glewGetVideoCaptureivNV; GLEW_FUN_EXPORT PFNGLVIDEOCAPTURENVPROC __glewVideoCaptureNV; GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC __glewVideoCaptureStreamParameterdvNV; GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC __glewVideoCaptureStreamParameterfvNV; GLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC __glewVideoCaptureStreamParameterivNV; GLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES; GLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES; GLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES; GLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES; GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES; GLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES; GLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS; GLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS; GLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS; GLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS; GLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS; GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS; GLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS; GLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS; GLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS; GLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS; GLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS; GLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX; GLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX; GLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX; GLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX; GLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX; GLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX; GLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX; GLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX; GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX; GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX; GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX; GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX; GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX; GLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX; GLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX; GLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX; GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX; GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX; GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX; GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX; GLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX; GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI; GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI; GLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI; GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI; GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI; GLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI; GLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN; GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN; GLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN; GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN; GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN; GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN; GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN; GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN; GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN; GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN; GLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN; #if defined(GLEW_MX) && !defined(_WIN32) struct GLEWContextStruct { #endif /* GLEW_MX */ GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_2; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_3; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_0; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_2; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_blend_minmax_factor; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_conservative_depth; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_debug_output; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_depth_clamp_separate; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_draw_buffers_blend; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_multi_draw_indirect; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_name_gen_delete; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_performance_monitor; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_sample_positions; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_seamless_cubemap_per_texture; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_export; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_texture_texture4; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_transform_feedback3_lines_triangles; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_tessellator; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_aux_depth_stencil; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_flush_buffer_range; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_object_purgeable; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_rgb_422; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_row_bytes; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_program_evaluators; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES2_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_base_instance; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_blend_func_extended; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_cl_event; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compressed_texture_pixel_storage; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_conservative_depth; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_debug_output; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers_blend; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_elements_base_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_indirect; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_attrib_location; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_coord_conventions; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_sRGB; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_geometry_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_get_program_binary; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader5; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_fp64; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_instanced_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_alignment; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_range; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query2; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_provoking_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_shading; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sampler_objects; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cube_map; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_separate_shader_objects; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_atomic_counters; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_bit_encoding; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_load_store; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_precision; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_stencil_export; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_subroutine; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_lod; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_420pack; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_include; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_packing; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sync; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_tessellation_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object_rgb32; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_bptc; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map_array; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_gather; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_lod; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rgb10_a2ui; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_swizzle; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_timer_query; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback2; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback3; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback_instanced; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_uniform_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_bgra; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_64bit; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_viewport_array; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_meminfo; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_direct_state_access; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample_blit_scaled; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_provoking_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_shader_objects; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_store; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB_decode; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_snorm; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_swizzle; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array_bgra; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_attrib_64bit; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_x11_sync_object; GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_frame_terminator; GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker; GLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes; GLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform; GLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test; GLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat; GLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists; GLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read; GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays; GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor; GLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region; GLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack; GLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert; GLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers; GLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos; GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture; GLEW_VAR_EXPORT GLboolean __GLEW_NVX_gpu_memory_info; GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square; GLEW_VAR_EXPORT GLboolean __GLEW_NV_conditional_render; GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color; GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_image; GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float; GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped; GLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators; GLEW_VAR_EXPORT GLboolean __GLEW_NV_explicit_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fence; GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option; GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program_fp64; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_shader5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_coverage; GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query; GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil; GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_path_rendering; GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range; GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite; GLEW_VAR_EXPORT GLboolean __GLEW_NV_present_video; GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_buffer_load; GLEW_VAR_EXPORT GLboolean __GLEW_NV_tessellation_program5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_barrier; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3; GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vdpau_interop; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_attrib_integer_64bit; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_buffer_unified_memory; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_video_capture; GLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates; GLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture; GLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format; GLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision; GLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace; GLEW_VAR_EXPORT GLboolean __GLEW_OML_resample; GLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample; GLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints; GLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints; GLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates; GLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_point_line_texgen; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod; GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_convolution_accuracy; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint; GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb; GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix; GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table; GLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table; GLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list; GLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading; GLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog; GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; #ifdef GLEW_MX }; /* GLEWContextStruct */ #endif /* GLEW_MX */ /* ------------------------------------------------------------------------- */ /* error codes */ #define GLEW_OK 0 #define GLEW_NO_ERROR 0 #define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ #define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* Need at least OpenGL 1.1 */ #define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* Need at least GLX 1.2 */ /* string codes */ #define GLEW_VERSION 1 #define GLEW_VERSION_MAJOR 2 #define GLEW_VERSION_MINOR 3 #define GLEW_VERSION_MICRO 4 /* API */ #ifdef GLEW_MX typedef struct GLEWContextStruct GLEWContext; GLEWAPI GLenum glewContextInit (GLEWContext* ctx); GLEWAPI GLboolean glewContextIsSupported (const GLEWContext* ctx, const char* name); #define glewInit() glewContextInit(glewGetContext()) #define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x) #define glewIsExtensionSupported(x) glewIsSupported(x) #define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x)) #ifdef _WIN32 # define GLEW_GET_FUN(x) glewGetContext()->x #else # define GLEW_GET_FUN(x) x #endif #else /* GLEW_MX */ GLEWAPI GLenum glewInit (); GLEWAPI GLboolean glewIsSupported (const char* name); #define glewIsExtensionSupported(x) glewIsSupported(x) #define GLEW_GET_VAR(x) (*(const GLboolean*)&x) #define GLEW_GET_FUN(x) x #endif /* GLEW_MX */ GLEWAPI GLboolean glewExperimental; GLEWAPI GLboolean glewGetExtension (const char* name); GLEWAPI const GLubyte* glewGetErrorString (GLenum error); GLEWAPI const GLubyte* glewGetString (GLenum name); #ifdef __cplusplus } #endif #ifdef GLEW_APIENTRY_DEFINED #undef GLEW_APIENTRY_DEFINED #undef APIENTRY #undef GLAPIENTRY #define GLAPIENTRY #endif #ifdef GLEW_CALLBACK_DEFINED #undef GLEW_CALLBACK_DEFINED #undef CALLBACK #endif #ifdef GLEW_WINGDIAPI_DEFINED #undef GLEW_WINGDIAPI_DEFINED #undef WINGDIAPI #endif #undef GLAPI /* #undef GLEWAPI */ #endif /* __glew_h__ */ ================================================ FILE: cocos2d/external/win32-specific/gles/include/OGLES/GL/glxew.h ================================================ /* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2002-2008, Milan Ikits ** Copyright (C) 2002-2008, Marcelo E. Magallon ** Copyright (C) 2002, Lev Povalahev ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** ** * Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** * 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. ** * 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ /* * Mesa 3-D graphics library * Version: 7.0 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * 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 * BRIAN PAUL 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. */ /* ** Copyright (c) 2007 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ #ifndef __glxew_h__ #define __glxew_h__ #define __GLXEW_H__ #ifdef __glxext_h_ #error glxext.h included before glxew.h #endif #if defined(GLX_H) || defined(__GLX_glx_h__) || defined(__glx_h__) #error glx.h included before glxew.h #endif #define __glxext_h_ #define GLX_H #define __GLX_glx_h__ #define __glx_h__ #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* ---------------------------- GLX_VERSION_1_0 --------------------------- */ #ifndef GLX_VERSION_1_0 #define GLX_VERSION_1_0 1 #define GLX_USE_GL 1 #define GLX_BUFFER_SIZE 2 #define GLX_LEVEL 3 #define GLX_RGBA 4 #define GLX_DOUBLEBUFFER 5 #define GLX_STEREO 6 #define GLX_AUX_BUFFERS 7 #define GLX_RED_SIZE 8 #define GLX_GREEN_SIZE 9 #define GLX_BLUE_SIZE 10 #define GLX_ALPHA_SIZE 11 #define GLX_DEPTH_SIZE 12 #define GLX_STENCIL_SIZE 13 #define GLX_ACCUM_RED_SIZE 14 #define GLX_ACCUM_GREEN_SIZE 15 #define GLX_ACCUM_BLUE_SIZE 16 #define GLX_ACCUM_ALPHA_SIZE 17 #define GLX_BAD_SCREEN 1 #define GLX_BAD_ATTRIBUTE 2 #define GLX_NO_EXTENSION 3 #define GLX_BAD_VISUAL 4 #define GLX_BAD_CONTEXT 5 #define GLX_BAD_VALUE 6 #define GLX_BAD_ENUM 7 typedef XID GLXDrawable; typedef XID GLXPixmap; #ifdef __sun typedef struct __glXContextRec *GLXContext; #else typedef struct __GLXcontextRec *GLXContext; #endif typedef unsigned int GLXVideoDeviceNV; extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase); extern Bool glXQueryVersion (Display *dpy, int *major, int *minor); extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value); extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList); extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap); extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix); extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); extern void glXDestroyContext (Display *dpy, GLXContext ctx); extern Bool glXIsDirect (Display *dpy, GLXContext ctx); extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask); extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx); extern GLXContext glXGetCurrentContext (void); extern GLXDrawable glXGetCurrentDrawable (void); extern void glXWaitGL (void); extern void glXWaitX (void); extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable); extern void glXUseXFont (Font font, int first, int count, int listBase); #define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0) #endif /* GLX_VERSION_1_0 */ /* ---------------------------- GLX_VERSION_1_1 --------------------------- */ #ifndef GLX_VERSION_1_1 #define GLX_VERSION_1_1 #define GLX_VENDOR 0x1 #define GLX_VERSION 0x2 #define GLX_EXTENSIONS 0x3 extern const char* glXQueryExtensionsString (Display *dpy, int screen); extern const char* glXGetClientString (Display *dpy, int name); extern const char* glXQueryServerString (Display *dpy, int screen, int name); #define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1) #endif /* GLX_VERSION_1_1 */ /* ---------------------------- GLX_VERSION_1_2 ---------------------------- */ #ifndef GLX_VERSION_1_2 #define GLX_VERSION_1_2 1 typedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void); #define glXGetCurrentDisplay GLXEW_GET_FUN(__glewXGetCurrentDisplay) #define GLXEW_VERSION_1_2 GLXEW_GET_VAR(__GLXEW_VERSION_1_2) #endif /* GLX_VERSION_1_2 */ /* ---------------------------- GLX_VERSION_1_3 ---------------------------- */ #ifndef GLX_VERSION_1_3 #define GLX_VERSION_1_3 1 #define GLX_RGBA_BIT 0x00000001 #define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 #define GLX_WINDOW_BIT 0x00000001 #define GLX_COLOR_INDEX_BIT 0x00000002 #define GLX_PIXMAP_BIT 0x00000002 #define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 #define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 #define GLX_PBUFFER_BIT 0x00000004 #define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 #define GLX_AUX_BUFFERS_BIT 0x00000010 #define GLX_CONFIG_CAVEAT 0x20 #define GLX_DEPTH_BUFFER_BIT 0x00000020 #define GLX_X_VISUAL_TYPE 0x22 #define GLX_TRANSPARENT_TYPE 0x23 #define GLX_TRANSPARENT_INDEX_VALUE 0x24 #define GLX_TRANSPARENT_RED_VALUE 0x25 #define GLX_TRANSPARENT_GREEN_VALUE 0x26 #define GLX_TRANSPARENT_BLUE_VALUE 0x27 #define GLX_TRANSPARENT_ALPHA_VALUE 0x28 #define GLX_STENCIL_BUFFER_BIT 0x00000040 #define GLX_ACCUM_BUFFER_BIT 0x00000080 #define GLX_NONE 0x8000 #define GLX_SLOW_CONFIG 0x8001 #define GLX_TRUE_COLOR 0x8002 #define GLX_DIRECT_COLOR 0x8003 #define GLX_PSEUDO_COLOR 0x8004 #define GLX_STATIC_COLOR 0x8005 #define GLX_GRAY_SCALE 0x8006 #define GLX_STATIC_GRAY 0x8007 #define GLX_TRANSPARENT_RGB 0x8008 #define GLX_TRANSPARENT_INDEX 0x8009 #define GLX_VISUAL_ID 0x800B #define GLX_SCREEN 0x800C #define GLX_NON_CONFORMANT_CONFIG 0x800D #define GLX_DRAWABLE_TYPE 0x8010 #define GLX_RENDER_TYPE 0x8011 #define GLX_X_RENDERABLE 0x8012 #define GLX_FBCONFIG_ID 0x8013 #define GLX_RGBA_TYPE 0x8014 #define GLX_COLOR_INDEX_TYPE 0x8015 #define GLX_MAX_PBUFFER_WIDTH 0x8016 #define GLX_MAX_PBUFFER_HEIGHT 0x8017 #define GLX_MAX_PBUFFER_PIXELS 0x8018 #define GLX_PRESERVED_CONTENTS 0x801B #define GLX_LARGEST_PBUFFER 0x801C #define GLX_WIDTH 0x801D #define GLX_HEIGHT 0x801E #define GLX_EVENT_MASK 0x801F #define GLX_DAMAGED 0x8020 #define GLX_SAVED 0x8021 #define GLX_WINDOW 0x8022 #define GLX_PBUFFER 0x8023 #define GLX_PBUFFER_HEIGHT 0x8040 #define GLX_PBUFFER_WIDTH 0x8041 #define GLX_PBUFFER_CLOBBER_MASK 0x08000000 #define GLX_DONT_CARE 0xFFFFFFFF typedef XID GLXFBConfigID; typedef XID GLXPbuffer; typedef XID GLXWindow; typedef struct __GLXFBConfigRec *GLXFBConfig; typedef struct { int event_type; int draw_type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; unsigned int buffer_mask; unsigned int aux_buffer; int x, y; int width, height; int count; } GLXPbufferClobberEvent; typedef union __GLXEvent { GLXPbufferClobberEvent glxpbufferclobber; long pad[24]; } GLXEvent; typedef GLXFBConfig* ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); typedef GLXFBConfig* ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx); typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); #define glXChooseFBConfig GLXEW_GET_FUN(__glewXChooseFBConfig) #define glXCreateNewContext GLXEW_GET_FUN(__glewXCreateNewContext) #define glXCreatePbuffer GLXEW_GET_FUN(__glewXCreatePbuffer) #define glXCreatePixmap GLXEW_GET_FUN(__glewXCreatePixmap) #define glXCreateWindow GLXEW_GET_FUN(__glewXCreateWindow) #define glXDestroyPbuffer GLXEW_GET_FUN(__glewXDestroyPbuffer) #define glXDestroyPixmap GLXEW_GET_FUN(__glewXDestroyPixmap) #define glXDestroyWindow GLXEW_GET_FUN(__glewXDestroyWindow) #define glXGetCurrentReadDrawable GLXEW_GET_FUN(__glewXGetCurrentReadDrawable) #define glXGetFBConfigAttrib GLXEW_GET_FUN(__glewXGetFBConfigAttrib) #define glXGetFBConfigs GLXEW_GET_FUN(__glewXGetFBConfigs) #define glXGetSelectedEvent GLXEW_GET_FUN(__glewXGetSelectedEvent) #define glXGetVisualFromFBConfig GLXEW_GET_FUN(__glewXGetVisualFromFBConfig) #define glXMakeContextCurrent GLXEW_GET_FUN(__glewXMakeContextCurrent) #define glXQueryContext GLXEW_GET_FUN(__glewXQueryContext) #define glXQueryDrawable GLXEW_GET_FUN(__glewXQueryDrawable) #define glXSelectEvent GLXEW_GET_FUN(__glewXSelectEvent) #define GLXEW_VERSION_1_3 GLXEW_GET_VAR(__GLXEW_VERSION_1_3) #endif /* GLX_VERSION_1_3 */ /* ---------------------------- GLX_VERSION_1_4 ---------------------------- */ #ifndef GLX_VERSION_1_4 #define GLX_VERSION_1_4 1 #define GLX_SAMPLE_BUFFERS 100000 #define GLX_SAMPLES 100001 extern void ( * glXGetProcAddress (const GLubyte *procName)) (void); #define GLXEW_VERSION_1_4 GLXEW_GET_VAR(__GLXEW_VERSION_1_4) #endif /* GLX_VERSION_1_4 */ /* -------------------------- GLX_3DFX_multisample ------------------------- */ #ifndef GLX_3DFX_multisample #define GLX_3DFX_multisample 1 #define GLX_SAMPLE_BUFFERS_3DFX 0x8050 #define GLX_SAMPLES_3DFX 0x8051 #define GLXEW_3DFX_multisample GLXEW_GET_VAR(__GLXEW_3DFX_multisample) #endif /* GLX_3DFX_multisample */ /* ------------------------ GLX_AMD_gpu_association ------------------------ */ #ifndef GLX_AMD_gpu_association #define GLX_AMD_gpu_association 1 #define GLX_GPU_VENDOR_AMD 0x1F00 #define GLX_GPU_RENDERER_STRING_AMD 0x1F01 #define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 #define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 #define GLX_GPU_RAM_AMD 0x21A3 #define GLX_GPU_CLOCK_AMD 0x21A4 #define GLX_GPU_NUM_PIPES_AMD 0x21A5 #define GLX_GPU_NUM_SIMD_AMD 0x21A6 #define GLX_GPU_NUM_RB_AMD 0x21A7 #define GLX_GPU_NUM_SPI_AMD 0x21A8 #define GLXEW_AMD_gpu_association GLXEW_GET_VAR(__GLXEW_AMD_gpu_association) #endif /* GLX_AMD_gpu_association */ /* ------------------------- GLX_ARB_create_context ------------------------ */ #ifndef GLX_ARB_create_context #define GLX_ARB_create_context 1 #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 #define GLX_CONTEXT_FLAGS_ARB 0x2094 typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); #define glXCreateContextAttribsARB GLXEW_GET_FUN(__glewXCreateContextAttribsARB) #define GLXEW_ARB_create_context GLXEW_GET_VAR(__GLXEW_ARB_create_context) #endif /* GLX_ARB_create_context */ /* --------------------- GLX_ARB_create_context_profile -------------------- */ #ifndef GLX_ARB_create_context_profile #define GLX_ARB_create_context_profile 1 #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 #define GLXEW_ARB_create_context_profile GLXEW_GET_VAR(__GLXEW_ARB_create_context_profile) #endif /* GLX_ARB_create_context_profile */ /* ------------------- GLX_ARB_create_context_robustness ------------------- */ #ifndef GLX_ARB_create_context_robustness #define GLX_ARB_create_context_robustness 1 #define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 #define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 #define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 #define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 #define GLXEW_ARB_create_context_robustness GLXEW_GET_VAR(__GLXEW_ARB_create_context_robustness) #endif /* GLX_ARB_create_context_robustness */ /* ------------------------- GLX_ARB_fbconfig_float ------------------------ */ #ifndef GLX_ARB_fbconfig_float #define GLX_ARB_fbconfig_float 1 #define GLX_RGBA_FLOAT_BIT 0x00000004 #define GLX_RGBA_FLOAT_TYPE 0x20B9 #define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float) #endif /* GLX_ARB_fbconfig_float */ /* ------------------------ GLX_ARB_framebuffer_sRGB ----------------------- */ #ifndef GLX_ARB_framebuffer_sRGB #define GLX_ARB_framebuffer_sRGB 1 #define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 #define GLXEW_ARB_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_ARB_framebuffer_sRGB) #endif /* GLX_ARB_framebuffer_sRGB */ /* ------------------------ GLX_ARB_get_proc_address ----------------------- */ #ifndef GLX_ARB_get_proc_address #define GLX_ARB_get_proc_address 1 extern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void); #define GLXEW_ARB_get_proc_address GLXEW_GET_VAR(__GLXEW_ARB_get_proc_address) #endif /* GLX_ARB_get_proc_address */ /* -------------------------- GLX_ARB_multisample -------------------------- */ #ifndef GLX_ARB_multisample #define GLX_ARB_multisample 1 #define GLX_SAMPLE_BUFFERS_ARB 100000 #define GLX_SAMPLES_ARB 100001 #define GLXEW_ARB_multisample GLXEW_GET_VAR(__GLXEW_ARB_multisample) #endif /* GLX_ARB_multisample */ /* ---------------------- GLX_ARB_vertex_buffer_object --------------------- */ #ifndef GLX_ARB_vertex_buffer_object #define GLX_ARB_vertex_buffer_object 1 #define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095 #define GLXEW_ARB_vertex_buffer_object GLXEW_GET_VAR(__GLXEW_ARB_vertex_buffer_object) #endif /* GLX_ARB_vertex_buffer_object */ /* ----------------------- GLX_ATI_pixel_format_float ---------------------- */ #ifndef GLX_ATI_pixel_format_float #define GLX_ATI_pixel_format_float 1 #define GLX_RGBA_FLOAT_ATI_BIT 0x00000100 #define GLXEW_ATI_pixel_format_float GLXEW_GET_VAR(__GLXEW_ATI_pixel_format_float) #endif /* GLX_ATI_pixel_format_float */ /* ------------------------- GLX_ATI_render_texture ------------------------ */ #ifndef GLX_ATI_render_texture #define GLX_ATI_render_texture 1 #define GLX_BIND_TO_TEXTURE_RGB_ATI 0x9800 #define GLX_BIND_TO_TEXTURE_RGBA_ATI 0x9801 #define GLX_TEXTURE_FORMAT_ATI 0x9802 #define GLX_TEXTURE_TARGET_ATI 0x9803 #define GLX_MIPMAP_TEXTURE_ATI 0x9804 #define GLX_TEXTURE_RGB_ATI 0x9805 #define GLX_TEXTURE_RGBA_ATI 0x9806 #define GLX_NO_TEXTURE_ATI 0x9807 #define GLX_TEXTURE_CUBE_MAP_ATI 0x9808 #define GLX_TEXTURE_1D_ATI 0x9809 #define GLX_TEXTURE_2D_ATI 0x980A #define GLX_MIPMAP_LEVEL_ATI 0x980B #define GLX_CUBE_MAP_FACE_ATI 0x980C #define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E #define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810 #define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811 #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812 #define GLX_FRONT_LEFT_ATI 0x9813 #define GLX_FRONT_RIGHT_ATI 0x9814 #define GLX_BACK_LEFT_ATI 0x9815 #define GLX_BACK_RIGHT_ATI 0x9816 #define GLX_AUX0_ATI 0x9817 #define GLX_AUX1_ATI 0x9818 #define GLX_AUX2_ATI 0x9819 #define GLX_AUX3_ATI 0x981A #define GLX_AUX4_ATI 0x981B #define GLX_AUX5_ATI 0x981C #define GLX_AUX6_ATI 0x981D #define GLX_AUX7_ATI 0x981E #define GLX_AUX8_ATI 0x981F #define GLX_AUX9_ATI 0x9820 #define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI 0x9821 #define GLX_BIND_TO_TEXTURE_INTENSITY_ATI 0x9822 typedef void ( * PFNGLXBINDTEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); typedef void ( * PFNGLXDRAWABLEATTRIBATIPROC) (Display *dpy, GLXDrawable draw, const int *attrib_list); typedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); #define glXBindTexImageATI GLXEW_GET_FUN(__glewXBindTexImageATI) #define glXDrawableAttribATI GLXEW_GET_FUN(__glewXDrawableAttribATI) #define glXReleaseTexImageATI GLXEW_GET_FUN(__glewXReleaseTexImageATI) #define GLXEW_ATI_render_texture GLXEW_GET_VAR(__GLXEW_ATI_render_texture) #endif /* GLX_ATI_render_texture */ /* ------------------- GLX_EXT_create_context_es2_profile ------------------ */ #ifndef GLX_EXT_create_context_es2_profile #define GLX_EXT_create_context_es2_profile 1 #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 #define GLXEW_EXT_create_context_es2_profile GLXEW_GET_VAR(__GLXEW_EXT_create_context_es2_profile) #endif /* GLX_EXT_create_context_es2_profile */ /* --------------------- GLX_EXT_fbconfig_packed_float --------------------- */ #ifndef GLX_EXT_fbconfig_packed_float #define GLX_EXT_fbconfig_packed_float 1 #define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 #define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 #define GLXEW_EXT_fbconfig_packed_float GLXEW_GET_VAR(__GLXEW_EXT_fbconfig_packed_float) #endif /* GLX_EXT_fbconfig_packed_float */ /* ------------------------ GLX_EXT_framebuffer_sRGB ----------------------- */ #ifndef GLX_EXT_framebuffer_sRGB #define GLX_EXT_framebuffer_sRGB 1 #define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 #define GLXEW_EXT_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_EXT_framebuffer_sRGB) #endif /* GLX_EXT_framebuffer_sRGB */ /* ------------------------- GLX_EXT_import_context ------------------------ */ #ifndef GLX_EXT_import_context #define GLX_EXT_import_context 1 #define GLX_SHARE_CONTEXT_EXT 0x800A #define GLX_VISUAL_ID_EXT 0x800B #define GLX_SCREEN_EXT 0x800C typedef XID GLXContextID; typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display* dpy, GLXContext context); typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display* dpy, GLXContextID contextID); typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context, int attribute,int *value); #define glXFreeContextEXT GLXEW_GET_FUN(__glewXFreeContextEXT) #define glXGetContextIDEXT GLXEW_GET_FUN(__glewXGetContextIDEXT) #define glXImportContextEXT GLXEW_GET_FUN(__glewXImportContextEXT) #define glXQueryContextInfoEXT GLXEW_GET_FUN(__glewXQueryContextInfoEXT) #define GLXEW_EXT_import_context GLXEW_GET_VAR(__GLXEW_EXT_import_context) #endif /* GLX_EXT_import_context */ /* -------------------------- GLX_EXT_scene_marker ------------------------- */ #ifndef GLX_EXT_scene_marker #define GLX_EXT_scene_marker 1 #define GLXEW_EXT_scene_marker GLXEW_GET_VAR(__GLXEW_EXT_scene_marker) #endif /* GLX_EXT_scene_marker */ /* -------------------------- GLX_EXT_swap_control ------------------------- */ #ifndef GLX_EXT_swap_control #define GLX_EXT_swap_control 1 #define GLX_SWAP_INTERVAL_EXT 0x20F1 #define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 typedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable, int interval); #define glXSwapIntervalEXT GLXEW_GET_FUN(__glewXSwapIntervalEXT) #define GLXEW_EXT_swap_control GLXEW_GET_VAR(__GLXEW_EXT_swap_control) #endif /* GLX_EXT_swap_control */ /* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */ #ifndef GLX_EXT_texture_from_pixmap #define GLX_EXT_texture_from_pixmap 1 #define GLX_TEXTURE_1D_BIT_EXT 0x00000001 #define GLX_TEXTURE_2D_BIT_EXT 0x00000002 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 #define GLX_Y_INVERTED_EXT 0x20D4 #define GLX_TEXTURE_FORMAT_EXT 0x20D5 #define GLX_TEXTURE_TARGET_EXT 0x20D6 #define GLX_MIPMAP_TEXTURE_EXT 0x20D7 #define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 #define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 #define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA #define GLX_TEXTURE_1D_EXT 0x20DB #define GLX_TEXTURE_2D_EXT 0x20DC #define GLX_TEXTURE_RECTANGLE_EXT 0x20DD #define GLX_FRONT_LEFT_EXT 0x20DE #define GLX_FRONT_RIGHT_EXT 0x20DF #define GLX_BACK_LEFT_EXT 0x20E0 #define GLX_BACK_RIGHT_EXT 0x20E1 #define GLX_AUX0_EXT 0x20E2 #define GLX_AUX1_EXT 0x20E3 #define GLX_AUX2_EXT 0x20E4 #define GLX_AUX3_EXT 0x20E5 #define GLX_AUX4_EXT 0x20E6 #define GLX_AUX5_EXT 0x20E7 #define GLX_AUX6_EXT 0x20E8 #define GLX_AUX7_EXT 0x20E9 #define GLX_AUX8_EXT 0x20EA #define GLX_AUX9_EXT 0x20EB typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer, const int *attrib_list); typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer); #define glXBindTexImageEXT GLXEW_GET_FUN(__glewXBindTexImageEXT) #define glXReleaseTexImageEXT GLXEW_GET_FUN(__glewXReleaseTexImageEXT) #define GLXEW_EXT_texture_from_pixmap GLXEW_GET_VAR(__GLXEW_EXT_texture_from_pixmap) #endif /* GLX_EXT_texture_from_pixmap */ /* -------------------------- GLX_EXT_visual_info -------------------------- */ #ifndef GLX_EXT_visual_info #define GLX_EXT_visual_info 1 #define GLX_X_VISUAL_TYPE_EXT 0x22 #define GLX_TRANSPARENT_TYPE_EXT 0x23 #define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 #define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 #define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 #define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 #define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 #define GLX_NONE_EXT 0x8000 #define GLX_TRUE_COLOR_EXT 0x8002 #define GLX_DIRECT_COLOR_EXT 0x8003 #define GLX_PSEUDO_COLOR_EXT 0x8004 #define GLX_STATIC_COLOR_EXT 0x8005 #define GLX_GRAY_SCALE_EXT 0x8006 #define GLX_STATIC_GRAY_EXT 0x8007 #define GLX_TRANSPARENT_RGB_EXT 0x8008 #define GLX_TRANSPARENT_INDEX_EXT 0x8009 #define GLXEW_EXT_visual_info GLXEW_GET_VAR(__GLXEW_EXT_visual_info) #endif /* GLX_EXT_visual_info */ /* ------------------------- GLX_EXT_visual_rating ------------------------- */ #ifndef GLX_EXT_visual_rating #define GLX_EXT_visual_rating 1 #define GLX_VISUAL_CAVEAT_EXT 0x20 #define GLX_SLOW_VISUAL_EXT 0x8001 #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D #define GLXEW_EXT_visual_rating GLXEW_GET_VAR(__GLXEW_EXT_visual_rating) #endif /* GLX_EXT_visual_rating */ /* -------------------------- GLX_INTEL_swap_event ------------------------- */ #ifndef GLX_INTEL_swap_event #define GLX_INTEL_swap_event 1 #define GLX_EXCHANGE_COMPLETE_INTEL 0x8180 #define GLX_COPY_COMPLETE_INTEL 0x8181 #define GLX_FLIP_COMPLETE_INTEL 0x8182 #define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 #define GLXEW_INTEL_swap_event GLXEW_GET_VAR(__GLXEW_INTEL_swap_event) #endif /* GLX_INTEL_swap_event */ /* -------------------------- GLX_MESA_agp_offset -------------------------- */ #ifndef GLX_MESA_agp_offset #define GLX_MESA_agp_offset 1 typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void* pointer); #define glXGetAGPOffsetMESA GLXEW_GET_FUN(__glewXGetAGPOffsetMESA) #define GLXEW_MESA_agp_offset GLXEW_GET_VAR(__GLXEW_MESA_agp_offset) #endif /* GLX_MESA_agp_offset */ /* ------------------------ GLX_MESA_copy_sub_buffer ----------------------- */ #ifndef GLX_MESA_copy_sub_buffer #define GLX_MESA_copy_sub_buffer 1 typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display* dpy, GLXDrawable drawable, int x, int y, int width, int height); #define glXCopySubBufferMESA GLXEW_GET_FUN(__glewXCopySubBufferMESA) #define GLXEW_MESA_copy_sub_buffer GLXEW_GET_VAR(__GLXEW_MESA_copy_sub_buffer) #endif /* GLX_MESA_copy_sub_buffer */ /* ------------------------ GLX_MESA_pixmap_colormap ----------------------- */ #ifndef GLX_MESA_pixmap_colormap #define GLX_MESA_pixmap_colormap 1 typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); #define glXCreateGLXPixmapMESA GLXEW_GET_FUN(__glewXCreateGLXPixmapMESA) #define GLXEW_MESA_pixmap_colormap GLXEW_GET_VAR(__GLXEW_MESA_pixmap_colormap) #endif /* GLX_MESA_pixmap_colormap */ /* ------------------------ GLX_MESA_release_buffers ----------------------- */ #ifndef GLX_MESA_release_buffers #define GLX_MESA_release_buffers 1 typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display* dpy, GLXDrawable d); #define glXReleaseBuffersMESA GLXEW_GET_FUN(__glewXReleaseBuffersMESA) #define GLXEW_MESA_release_buffers GLXEW_GET_VAR(__GLXEW_MESA_release_buffers) #endif /* GLX_MESA_release_buffers */ /* ------------------------- GLX_MESA_set_3dfx_mode ------------------------ */ #ifndef GLX_MESA_set_3dfx_mode #define GLX_MESA_set_3dfx_mode 1 #define GLX_3DFX_WINDOW_MODE_MESA 0x1 #define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 typedef GLboolean ( * PFNGLXSET3DFXMODEMESAPROC) (GLint mode); #define glXSet3DfxModeMESA GLXEW_GET_FUN(__glewXSet3DfxModeMESA) #define GLXEW_MESA_set_3dfx_mode GLXEW_GET_VAR(__GLXEW_MESA_set_3dfx_mode) #endif /* GLX_MESA_set_3dfx_mode */ /* ------------------------- GLX_MESA_swap_control ------------------------- */ #ifndef GLX_MESA_swap_control #define GLX_MESA_swap_control 1 typedef int ( * PFNGLXGETSWAPINTERVALMESAPROC) (void); typedef int ( * PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval); #define glXGetSwapIntervalMESA GLXEW_GET_FUN(__glewXGetSwapIntervalMESA) #define glXSwapIntervalMESA GLXEW_GET_FUN(__glewXSwapIntervalMESA) #define GLXEW_MESA_swap_control GLXEW_GET_VAR(__GLXEW_MESA_swap_control) #endif /* GLX_MESA_swap_control */ /* --------------------------- GLX_NV_copy_image --------------------------- */ #ifndef GLX_NV_copy_image #define GLX_NV_copy_image 1 typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #define glXCopyImageSubDataNV GLXEW_GET_FUN(__glewXCopyImageSubDataNV) #define GLXEW_NV_copy_image GLXEW_GET_VAR(__GLXEW_NV_copy_image) #endif /* GLX_NV_copy_image */ /* -------------------------- GLX_NV_float_buffer -------------------------- */ #ifndef GLX_NV_float_buffer #define GLX_NV_float_buffer 1 #define GLX_FLOAT_COMPONENTS_NV 0x20B0 #define GLXEW_NV_float_buffer GLXEW_GET_VAR(__GLXEW_NV_float_buffer) #endif /* GLX_NV_float_buffer */ /* ---------------------- GLX_NV_multisample_coverage ---------------------- */ #ifndef GLX_NV_multisample_coverage #define GLX_NV_multisample_coverage 1 #define GLX_COLOR_SAMPLES_NV 0x20B3 #define GLX_COVERAGE_SAMPLES_NV 100001 #define GLXEW_NV_multisample_coverage GLXEW_GET_VAR(__GLXEW_NV_multisample_coverage) #endif /* GLX_NV_multisample_coverage */ /* -------------------------- GLX_NV_present_video ------------------------- */ #ifndef GLX_NV_present_video #define GLX_NV_present_video 1 #define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display* dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); typedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements); #define glXBindVideoDeviceNV GLXEW_GET_FUN(__glewXBindVideoDeviceNV) #define glXEnumerateVideoDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoDevicesNV) #define GLXEW_NV_present_video GLXEW_GET_VAR(__GLXEW_NV_present_video) #endif /* GLX_NV_present_video */ /* --------------------------- GLX_NV_swap_group --------------------------- */ #ifndef GLX_NV_swap_group #define GLX_NV_swap_group 1 typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display* dpy, GLuint group, GLuint barrier); typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint group); typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display* dpy, int screen, GLuint *count); typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display* dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display* dpy, int screen); #define glXBindSwapBarrierNV GLXEW_GET_FUN(__glewXBindSwapBarrierNV) #define glXJoinSwapGroupNV GLXEW_GET_FUN(__glewXJoinSwapGroupNV) #define glXQueryFrameCountNV GLXEW_GET_FUN(__glewXQueryFrameCountNV) #define glXQueryMaxSwapGroupsNV GLXEW_GET_FUN(__glewXQueryMaxSwapGroupsNV) #define glXQuerySwapGroupNV GLXEW_GET_FUN(__glewXQuerySwapGroupNV) #define glXResetFrameCountNV GLXEW_GET_FUN(__glewXResetFrameCountNV) #define GLXEW_NV_swap_group GLXEW_GET_VAR(__GLXEW_NV_swap_group) #endif /* GLX_NV_swap_group */ /* ----------------------- GLX_NV_vertex_array_range ----------------------- */ #ifndef GLX_NV_vertex_array_range #define GLX_NV_vertex_array_range 1 typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); typedef void ( * PFNGLXFREEMEMORYNVPROC) (void *pointer); #define glXAllocateMemoryNV GLXEW_GET_FUN(__glewXAllocateMemoryNV) #define glXFreeMemoryNV GLXEW_GET_FUN(__glewXFreeMemoryNV) #define GLXEW_NV_vertex_array_range GLXEW_GET_VAR(__GLXEW_NV_vertex_array_range) #endif /* GLX_NV_vertex_array_range */ /* -------------------------- GLX_NV_video_capture ------------------------- */ #ifndef GLX_NV_video_capture #define GLX_NV_video_capture 1 #define GLX_DEVICE_ID_NV 0x20CD #define GLX_UNIQUE_ID_NV 0x20CE #define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF typedef XID GLXVideoCaptureDeviceNV; typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display* dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display* dpy, int screen, int *nelements); typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device); typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device); #define glXBindVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXBindVideoCaptureDeviceNV) #define glXEnumerateVideoCaptureDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoCaptureDevicesNV) #define glXLockVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXLockVideoCaptureDeviceNV) #define glXQueryVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXQueryVideoCaptureDeviceNV) #define glXReleaseVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoCaptureDeviceNV) #define GLXEW_NV_video_capture GLXEW_GET_VAR(__GLXEW_NV_video_capture) #endif /* GLX_NV_video_capture */ /* -------------------------- GLX_NV_video_output -------------------------- */ #ifndef GLX_NV_video_output #define GLX_NV_video_output 1 #define GLX_VIDEO_OUT_COLOR_NV 0x20C3 #define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 #define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 #define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 #define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 #define GLX_VIDEO_OUT_FRAME_NV 0x20C8 #define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 #define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA #define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB #define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display* dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display* dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice); typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display* dpy, GLXPbuffer pbuf); typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); #define glXBindVideoImageNV GLXEW_GET_FUN(__glewXBindVideoImageNV) #define glXGetVideoDeviceNV GLXEW_GET_FUN(__glewXGetVideoDeviceNV) #define glXGetVideoInfoNV GLXEW_GET_FUN(__glewXGetVideoInfoNV) #define glXReleaseVideoDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoDeviceNV) #define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV) #define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV) #define GLXEW_NV_video_output GLXEW_GET_VAR(__GLXEW_NV_video_output) #endif /* GLX_NV_video_output */ /* -------------------------- GLX_OML_swap_method -------------------------- */ #ifndef GLX_OML_swap_method #define GLX_OML_swap_method 1 #define GLX_SWAP_METHOD_OML 0x8060 #define GLX_SWAP_EXCHANGE_OML 0x8061 #define GLX_SWAP_COPY_OML 0x8062 #define GLX_SWAP_UNDEFINED_OML 0x8063 #define GLXEW_OML_swap_method GLXEW_GET_VAR(__GLXEW_OML_swap_method) #endif /* GLX_OML_swap_method */ /* -------------------------- GLX_OML_sync_control ------------------------- */ #ifndef GLX_OML_sync_control #define GLX_OML_sync_control 1 typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator); typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc); typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc); typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc); #define glXGetMscRateOML GLXEW_GET_FUN(__glewXGetMscRateOML) #define glXGetSyncValuesOML GLXEW_GET_FUN(__glewXGetSyncValuesOML) #define glXSwapBuffersMscOML GLXEW_GET_FUN(__glewXSwapBuffersMscOML) #define glXWaitForMscOML GLXEW_GET_FUN(__glewXWaitForMscOML) #define glXWaitForSbcOML GLXEW_GET_FUN(__glewXWaitForSbcOML) #define GLXEW_OML_sync_control GLXEW_GET_VAR(__GLXEW_OML_sync_control) #endif /* GLX_OML_sync_control */ /* ------------------------ GLX_SGIS_blended_overlay ----------------------- */ #ifndef GLX_SGIS_blended_overlay #define GLX_SGIS_blended_overlay 1 #define GLX_BLENDED_RGBA_SGIS 0x8025 #define GLXEW_SGIS_blended_overlay GLXEW_GET_VAR(__GLXEW_SGIS_blended_overlay) #endif /* GLX_SGIS_blended_overlay */ /* -------------------------- GLX_SGIS_color_range ------------------------- */ #ifndef GLX_SGIS_color_range #define GLX_SGIS_color_range 1 #define GLX_MIN_RED_SGIS 0 #define GLX_MAX_GREEN_SGIS 0 #define GLX_MIN_BLUE_SGIS 0 #define GLX_MAX_ALPHA_SGIS 0 #define GLX_MIN_GREEN_SGIS 0 #define GLX_MIN_ALPHA_SGIS 0 #define GLX_MAX_RED_SGIS 0 #define GLX_EXTENDED_RANGE_SGIS 0 #define GLX_MAX_BLUE_SGIS 0 #define GLXEW_SGIS_color_range GLXEW_GET_VAR(__GLXEW_SGIS_color_range) #endif /* GLX_SGIS_color_range */ /* -------------------------- GLX_SGIS_multisample ------------------------- */ #ifndef GLX_SGIS_multisample #define GLX_SGIS_multisample 1 #define GLX_SAMPLE_BUFFERS_SGIS 100000 #define GLX_SAMPLES_SGIS 100001 #define GLXEW_SGIS_multisample GLXEW_GET_VAR(__GLXEW_SGIS_multisample) #endif /* GLX_SGIS_multisample */ /* ---------------------- GLX_SGIS_shared_multisample ---------------------- */ #ifndef GLX_SGIS_shared_multisample #define GLX_SGIS_shared_multisample 1 #define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 #define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 #define GLXEW_SGIS_shared_multisample GLXEW_GET_VAR(__GLXEW_SGIS_shared_multisample) #endif /* GLX_SGIS_shared_multisample */ /* --------------------------- GLX_SGIX_fbconfig --------------------------- */ #ifndef GLX_SGIX_fbconfig #define GLX_SGIX_fbconfig 1 #define GLX_WINDOW_BIT_SGIX 0x00000001 #define GLX_RGBA_BIT_SGIX 0x00000001 #define GLX_PIXMAP_BIT_SGIX 0x00000002 #define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 #define GLX_SCREEN_EXT 0x800C #define GLX_DRAWABLE_TYPE_SGIX 0x8010 #define GLX_RENDER_TYPE_SGIX 0x8011 #define GLX_X_RENDERABLE_SGIX 0x8012 #define GLX_FBCONFIG_ID_SGIX 0x8013 #define GLX_RGBA_TYPE_SGIX 0x8014 #define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 typedef XID GLXFBConfigIDSGIX; typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; typedef GLXFBConfigSGIX* ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, Pixmap pixmap); typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display* dpy, GLXFBConfigSGIX config, int attribute, int *value); typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display* dpy, XVisualInfo *vis); typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfig config); #define glXChooseFBConfigSGIX GLXEW_GET_FUN(__glewXChooseFBConfigSGIX) #define glXCreateContextWithConfigSGIX GLXEW_GET_FUN(__glewXCreateContextWithConfigSGIX) #define glXCreateGLXPixmapWithConfigSGIX GLXEW_GET_FUN(__glewXCreateGLXPixmapWithConfigSGIX) #define glXGetFBConfigAttribSGIX GLXEW_GET_FUN(__glewXGetFBConfigAttribSGIX) #define glXGetFBConfigFromVisualSGIX GLXEW_GET_FUN(__glewXGetFBConfigFromVisualSGIX) #define glXGetVisualFromFBConfigSGIX GLXEW_GET_FUN(__glewXGetVisualFromFBConfigSGIX) #define GLXEW_SGIX_fbconfig GLXEW_GET_VAR(__GLXEW_SGIX_fbconfig) #endif /* GLX_SGIX_fbconfig */ /* --------------------------- GLX_SGIX_hyperpipe -------------------------- */ #ifndef GLX_SGIX_hyperpipe #define GLX_SGIX_hyperpipe 1 #define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 #define GLX_PIPE_RECT_SGIX 0x00000001 #define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 #define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 #define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 #define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 #define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 #define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 #define GLX_BAD_HYPERPIPE_SGIX 92 #define GLX_HYPERPIPE_ID_SGIX 0x8030 typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int networkId; } GLXHyperpipeNetworkSGIX; typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int XOrigin; int YOrigin; int maxHeight; int maxWidth; } GLXPipeRectLimits; typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int channel; unsigned int participationType; int timeSlice; } GLXHyperpipeConfigSGIX; typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int srcXOrigin; int srcYOrigin; int srcWidth; int srcHeight; int destXOrigin; int destYOrigin; int destWidth; int destHeight; } GLXPipeRect; typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); #define glXBindHyperpipeSGIX GLXEW_GET_FUN(__glewXBindHyperpipeSGIX) #define glXDestroyHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXDestroyHyperpipeConfigSGIX) #define glXHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXHyperpipeAttribSGIX) #define glXHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXHyperpipeConfigSGIX) #define glXQueryHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeAttribSGIX) #define glXQueryHyperpipeBestAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeBestAttribSGIX) #define glXQueryHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeConfigSGIX) #define glXQueryHyperpipeNetworkSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeNetworkSGIX) #define GLXEW_SGIX_hyperpipe GLXEW_GET_VAR(__GLXEW_SGIX_hyperpipe) #endif /* GLX_SGIX_hyperpipe */ /* ---------------------------- GLX_SGIX_pbuffer --------------------------- */ #ifndef GLX_SGIX_pbuffer #define GLX_SGIX_pbuffer 1 #define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 #define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 #define GLX_PBUFFER_BIT_SGIX 0x00000004 #define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 #define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 #define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 #define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 #define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 #define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 #define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 #define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 #define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 #define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 #define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 #define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A #define GLX_PRESERVED_CONTENTS_SGIX 0x801B #define GLX_LARGEST_PBUFFER_SGIX 0x801C #define GLX_WIDTH_SGIX 0x801D #define GLX_HEIGHT_SGIX 0x801E #define GLX_EVENT_MASK_SGIX 0x801F #define GLX_DAMAGED_SGIX 0x8020 #define GLX_SAVED_SGIX 0x8021 #define GLX_WINDOW_SGIX 0x8022 #define GLX_PBUFFER_SGIX 0x8023 #define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 typedef XID GLXPbufferSGIX; typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX; typedef GLXPbuffer ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display* dpy, GLXFBConfig config, unsigned int width, unsigned int height, int *attrib_list); typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf); typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long *mask); typedef void ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf, int attribute, unsigned int *value); typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long mask); #define glXCreateGLXPbufferSGIX GLXEW_GET_FUN(__glewXCreateGLXPbufferSGIX) #define glXDestroyGLXPbufferSGIX GLXEW_GET_FUN(__glewXDestroyGLXPbufferSGIX) #define glXGetSelectedEventSGIX GLXEW_GET_FUN(__glewXGetSelectedEventSGIX) #define glXQueryGLXPbufferSGIX GLXEW_GET_FUN(__glewXQueryGLXPbufferSGIX) #define glXSelectEventSGIX GLXEW_GET_FUN(__glewXSelectEventSGIX) #define GLXEW_SGIX_pbuffer GLXEW_GET_VAR(__GLXEW_SGIX_pbuffer) #endif /* GLX_SGIX_pbuffer */ /* ------------------------- GLX_SGIX_swap_barrier ------------------------- */ #ifndef GLX_SGIX_swap_barrier #define GLX_SGIX_swap_barrier 1 typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); #define glXBindSwapBarrierSGIX GLXEW_GET_FUN(__glewXBindSwapBarrierSGIX) #define glXQueryMaxSwapBarriersSGIX GLXEW_GET_FUN(__glewXQueryMaxSwapBarriersSGIX) #define GLXEW_SGIX_swap_barrier GLXEW_GET_VAR(__GLXEW_SGIX_swap_barrier) #endif /* GLX_SGIX_swap_barrier */ /* -------------------------- GLX_SGIX_swap_group -------------------------- */ #ifndef GLX_SGIX_swap_group #define GLX_SGIX_swap_group 1 typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); #define glXJoinSwapGroupSGIX GLXEW_GET_FUN(__glewXJoinSwapGroupSGIX) #define GLXEW_SGIX_swap_group GLXEW_GET_VAR(__GLXEW_SGIX_swap_group) #endif /* GLX_SGIX_swap_group */ /* ------------------------- GLX_SGIX_video_resize ------------------------- */ #ifndef GLX_SGIX_video_resize #define GLX_SGIX_video_resize 1 #define GLX_SYNC_FRAME_SGIX 0x00000000 #define GLX_SYNC_SWAP_SGIX 0x00000001 typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display* display, int screen, int channel, Window window); typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int x, int y, int w, int h); typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display* display, int screen, int channel, GLenum synctype); typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display* display, int screen, int channel, int *x, int *y, int *w, int *h); typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); #define glXBindChannelToWindowSGIX GLXEW_GET_FUN(__glewXBindChannelToWindowSGIX) #define glXChannelRectSGIX GLXEW_GET_FUN(__glewXChannelRectSGIX) #define glXChannelRectSyncSGIX GLXEW_GET_FUN(__glewXChannelRectSyncSGIX) #define glXQueryChannelDeltasSGIX GLXEW_GET_FUN(__glewXQueryChannelDeltasSGIX) #define glXQueryChannelRectSGIX GLXEW_GET_FUN(__glewXQueryChannelRectSGIX) #define GLXEW_SGIX_video_resize GLXEW_GET_VAR(__GLXEW_SGIX_video_resize) #endif /* GLX_SGIX_video_resize */ /* ---------------------- GLX_SGIX_visual_select_group --------------------- */ #ifndef GLX_SGIX_visual_select_group #define GLX_SGIX_visual_select_group 1 #define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 #define GLXEW_SGIX_visual_select_group GLXEW_GET_VAR(__GLXEW_SGIX_visual_select_group) #endif /* GLX_SGIX_visual_select_group */ /* ---------------------------- GLX_SGI_cushion ---------------------------- */ #ifndef GLX_SGI_cushion #define GLX_SGI_cushion 1 typedef void ( * PFNGLXCUSHIONSGIPROC) (Display* dpy, Window window, float cushion); #define glXCushionSGI GLXEW_GET_FUN(__glewXCushionSGI) #define GLXEW_SGI_cushion GLXEW_GET_VAR(__GLXEW_SGI_cushion) #endif /* GLX_SGI_cushion */ /* ----------------------- GLX_SGI_make_current_read ----------------------- */ #ifndef GLX_SGI_make_current_read #define GLX_SGI_make_current_read 1 typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); #define glXGetCurrentReadDrawableSGI GLXEW_GET_FUN(__glewXGetCurrentReadDrawableSGI) #define glXMakeCurrentReadSGI GLXEW_GET_FUN(__glewXMakeCurrentReadSGI) #define GLXEW_SGI_make_current_read GLXEW_GET_VAR(__GLXEW_SGI_make_current_read) #endif /* GLX_SGI_make_current_read */ /* -------------------------- GLX_SGI_swap_control ------------------------- */ #ifndef GLX_SGI_swap_control #define GLX_SGI_swap_control 1 typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); #define glXSwapIntervalSGI GLXEW_GET_FUN(__glewXSwapIntervalSGI) #define GLXEW_SGI_swap_control GLXEW_GET_VAR(__GLXEW_SGI_swap_control) #endif /* GLX_SGI_swap_control */ /* --------------------------- GLX_SGI_video_sync -------------------------- */ #ifndef GLX_SGI_video_sync #define GLX_SGI_video_sync 1 typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int* count); typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int* count); #define glXGetVideoSyncSGI GLXEW_GET_FUN(__glewXGetVideoSyncSGI) #define glXWaitVideoSyncSGI GLXEW_GET_FUN(__glewXWaitVideoSyncSGI) #define GLXEW_SGI_video_sync GLXEW_GET_VAR(__GLXEW_SGI_video_sync) #endif /* GLX_SGI_video_sync */ /* --------------------- GLX_SUN_get_transparent_index --------------------- */ #ifndef GLX_SUN_get_transparent_index #define GLX_SUN_get_transparent_index 1 typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display* dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex); #define glXGetTransparentIndexSUN GLXEW_GET_FUN(__glewXGetTransparentIndexSUN) #define GLXEW_SUN_get_transparent_index GLXEW_GET_VAR(__GLXEW_SUN_get_transparent_index) #endif /* GLX_SUN_get_transparent_index */ /* -------------------------- GLX_SUN_video_resize ------------------------- */ #ifndef GLX_SUN_video_resize #define GLX_SUN_video_resize 1 #define GLX_VIDEO_RESIZE_SUN 0x8171 #define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD typedef int ( * PFNGLXGETVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float* factor); typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float factor); #define glXGetVideoResizeSUN GLXEW_GET_FUN(__glewXGetVideoResizeSUN) #define glXVideoResizeSUN GLXEW_GET_FUN(__glewXVideoResizeSUN) #define GLXEW_SUN_video_resize GLXEW_GET_VAR(__GLXEW_SUN_video_resize) #endif /* GLX_SUN_video_resize */ /* ------------------------------------------------------------------------- */ #ifdef GLEW_MX #define GLXEW_EXPORT #else #define GLXEW_EXPORT extern #endif /* GLEW_MX */ extern PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay; extern PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig; extern PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext; extern PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer; extern PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap; extern PFNGLXCREATEWINDOWPROC __glewXCreateWindow; extern PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer; extern PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap; extern PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow; extern PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable; extern PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib; extern PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs; extern PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent; extern PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig; extern PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent; extern PFNGLXQUERYCONTEXTPROC __glewXQueryContext; extern PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable; extern PFNGLXSELECTEVENTPROC __glewXSelectEvent; extern PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB; extern PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI; extern PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI; extern PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI; extern PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT; extern PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT; extern PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT; extern PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT; extern PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT; extern PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT; extern PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT; extern PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA; extern PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA; extern PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA; extern PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA; extern PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA; extern PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA; extern PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA; extern PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV; extern PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV; extern PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV; extern PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV; extern PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV; extern PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV; extern PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV; extern PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV; extern PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV; extern PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV; extern PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV; extern PFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV; extern PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV; extern PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV; extern PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV; extern PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV; extern PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV; extern PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV; extern PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV; extern PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV; extern PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV; extern PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV; extern PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML; extern PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML; extern PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML; extern PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML; extern PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML; extern PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX; extern PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX; extern PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX; extern PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX; extern PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX; extern PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX; extern PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX; extern PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX; extern PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX; extern PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX; extern PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX; extern PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX; extern PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX; extern PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX; extern PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX; extern PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX; extern PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX; extern PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX; extern PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX; extern PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX; extern PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX; extern PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX; extern PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX; extern PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX; extern PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX; extern PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX; extern PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX; extern PFNGLXCUSHIONSGIPROC __glewXCushionSGI; extern PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI; extern PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI; extern PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI; extern PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI; extern PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI; extern PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN; extern PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN; extern PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN; #if defined(GLEW_MX) struct GLXEWContextStruct { #endif /* GLEW_MX */ GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_0; GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_1; GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_2; GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_3; GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_4; GLXEW_EXPORT GLboolean __GLXEW_3DFX_multisample; GLXEW_EXPORT GLboolean __GLXEW_AMD_gpu_association; GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context; GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_profile; GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_robustness; GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float; GLXEW_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB; GLXEW_EXPORT GLboolean __GLXEW_ARB_get_proc_address; GLXEW_EXPORT GLboolean __GLXEW_ARB_multisample; GLXEW_EXPORT GLboolean __GLXEW_ARB_vertex_buffer_object; GLXEW_EXPORT GLboolean __GLXEW_ATI_pixel_format_float; GLXEW_EXPORT GLboolean __GLXEW_ATI_render_texture; GLXEW_EXPORT GLboolean __GLXEW_EXT_create_context_es2_profile; GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float; GLXEW_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB; GLXEW_EXPORT GLboolean __GLXEW_EXT_import_context; GLXEW_EXPORT GLboolean __GLXEW_EXT_scene_marker; GLXEW_EXPORT GLboolean __GLXEW_EXT_swap_control; GLXEW_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap; GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_info; GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_rating; GLXEW_EXPORT GLboolean __GLXEW_INTEL_swap_event; GLXEW_EXPORT GLboolean __GLXEW_MESA_agp_offset; GLXEW_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer; GLXEW_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap; GLXEW_EXPORT GLboolean __GLXEW_MESA_release_buffers; GLXEW_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode; GLXEW_EXPORT GLboolean __GLXEW_MESA_swap_control; GLXEW_EXPORT GLboolean __GLXEW_NV_copy_image; GLXEW_EXPORT GLboolean __GLXEW_NV_float_buffer; GLXEW_EXPORT GLboolean __GLXEW_NV_multisample_coverage; GLXEW_EXPORT GLboolean __GLXEW_NV_present_video; GLXEW_EXPORT GLboolean __GLXEW_NV_swap_group; GLXEW_EXPORT GLboolean __GLXEW_NV_vertex_array_range; GLXEW_EXPORT GLboolean __GLXEW_NV_video_capture; GLXEW_EXPORT GLboolean __GLXEW_NV_video_output; GLXEW_EXPORT GLboolean __GLXEW_OML_swap_method; GLXEW_EXPORT GLboolean __GLXEW_OML_sync_control; GLXEW_EXPORT GLboolean __GLXEW_SGIS_blended_overlay; GLXEW_EXPORT GLboolean __GLXEW_SGIS_color_range; GLXEW_EXPORT GLboolean __GLXEW_SGIS_multisample; GLXEW_EXPORT GLboolean __GLXEW_SGIS_shared_multisample; GLXEW_EXPORT GLboolean __GLXEW_SGIX_fbconfig; GLXEW_EXPORT GLboolean __GLXEW_SGIX_hyperpipe; GLXEW_EXPORT GLboolean __GLXEW_SGIX_pbuffer; GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_barrier; GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_group; GLXEW_EXPORT GLboolean __GLXEW_SGIX_video_resize; GLXEW_EXPORT GLboolean __GLXEW_SGIX_visual_select_group; GLXEW_EXPORT GLboolean __GLXEW_SGI_cushion; GLXEW_EXPORT GLboolean __GLXEW_SGI_make_current_read; GLXEW_EXPORT GLboolean __GLXEW_SGI_swap_control; GLXEW_EXPORT GLboolean __GLXEW_SGI_video_sync; GLXEW_EXPORT GLboolean __GLXEW_SUN_get_transparent_index; GLXEW_EXPORT GLboolean __GLXEW_SUN_video_resize; #ifdef GLEW_MX }; /* GLXEWContextStruct */ #endif /* GLEW_MX */ /* ------------------------------------------------------------------------ */ #ifdef GLEW_MX typedef struct GLXEWContextStruct GLXEWContext; extern GLenum glxewContextInit (GLXEWContext* ctx); extern GLboolean glxewContextIsSupported (const GLXEWContext* ctx, const char* name); #define glxewInit() glxewContextInit(glxewGetContext()) #define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x) #define GLXEW_GET_VAR(x) (*(const GLboolean*)&(glxewGetContext()->x)) #define GLXEW_GET_FUN(x) x #else /* GLEW_MX */ #define GLXEW_GET_VAR(x) (*(const GLboolean*)&x) #define GLXEW_GET_FUN(x) x extern GLboolean glxewIsSupported (const char* name); #endif /* GLEW_MX */ extern GLboolean glxewGetExtension (const char* name); #ifdef __cplusplus } #endif #endif /* __glxew_h__ */ ================================================ FILE: cocos2d/external/win32-specific/gles/include/OGLES/GL/wglew.h ================================================ /* ** The OpenGL Extension Wrangler Library ** Copyright (C) 2002-2008, Milan Ikits ** Copyright (C) 2002-2008, Marcelo E. Magallon ** Copyright (C) 2002, Lev Povalahev ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** ** * Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** * 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. ** * 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. */ /* ** Copyright (c) 2007 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ #ifndef __wglew_h__ #define __wglew_h__ #define __WGLEW_H__ #ifdef __wglext_h_ #error wglext.h included before wglew.h #endif #define __wglext_h_ #if !defined(WINAPI) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 # endif #include # undef WIN32_LEAN_AND_MEAN #endif /* * GLEW_STATIC needs to be set when using the static version. * GLEW_BUILD is set when building the DLL version. */ #ifdef GLEW_STATIC # define GLEWAPI extern #else # ifdef GLEW_BUILD # define GLEWAPI extern __declspec(dllexport) # else # define GLEWAPI extern __declspec(dllimport) # endif #endif #ifdef __cplusplus extern "C" { #endif /* -------------------------- WGL_3DFX_multisample ------------------------- */ #ifndef WGL_3DFX_multisample #define WGL_3DFX_multisample 1 #define WGL_SAMPLE_BUFFERS_3DFX 0x2060 #define WGL_SAMPLES_3DFX 0x2061 #define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample) #endif /* WGL_3DFX_multisample */ /* ------------------------- WGL_3DL_stereo_control ------------------------ */ #ifndef WGL_3DL_stereo_control #define WGL_3DL_stereo_control 1 #define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 #define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 #define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 #define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); #define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL) #define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control) #endif /* WGL_3DL_stereo_control */ /* ------------------------ WGL_AMD_gpu_association ------------------------ */ #ifndef WGL_AMD_gpu_association #define WGL_AMD_gpu_association 1 #define WGL_GPU_VENDOR_AMD 0x1F00 #define WGL_GPU_RENDERER_STRING_AMD 0x1F01 #define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 #define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 #define WGL_GPU_RAM_AMD 0x21A3 #define WGL_GPU_CLOCK_AMD 0x21A4 #define WGL_GPU_NUM_PIPES_AMD 0x21A5 #define WGL_GPU_NUM_SIMD_AMD 0x21A6 #define WGL_GPU_NUM_RB_AMD 0x21A7 #define WGL_GPU_NUM_SPI_AMD 0x21A8 typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList); typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids); typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data); typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); #define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD) #define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD) #define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD) #define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD) #define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD) #define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD) #define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD) #define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD) #define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD) #define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association) #endif /* WGL_AMD_gpu_association */ /* ------------------------- WGL_ARB_buffer_region ------------------------- */ #ifndef WGL_ARB_buffer_region #define WGL_ARB_buffer_region 1 #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 #define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 #define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 #define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); #define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB) #define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB) #define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB) #define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB) #define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region) #endif /* WGL_ARB_buffer_region */ /* ------------------------- WGL_ARB_create_context ------------------------ */ #ifndef WGL_ARB_create_context #define WGL_ARB_create_context 1 #define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 #define WGL_CONTEXT_FLAGS_ARB 0x2094 #define ERROR_INVALID_VERSION_ARB 0x2095 #define ERROR_INVALID_PROFILE_ARB 0x2096 typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); #define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB) #define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context) #endif /* WGL_ARB_create_context */ /* --------------------- WGL_ARB_create_context_profile -------------------- */ #ifndef WGL_ARB_create_context_profile #define WGL_ARB_create_context_profile 1 #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 #define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile) #endif /* WGL_ARB_create_context_profile */ /* ------------------- WGL_ARB_create_context_robustness ------------------- */ #ifndef WGL_ARB_create_context_robustness #define WGL_ARB_create_context_robustness 1 #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 #define WGLEW_ARB_create_context_robustness WGLEW_GET_VAR(__WGLEW_ARB_create_context_robustness) #endif /* WGL_ARB_create_context_robustness */ /* ----------------------- WGL_ARB_extensions_string ----------------------- */ #ifndef WGL_ARB_extensions_string #define WGL_ARB_extensions_string 1 typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); #define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB) #define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string) #endif /* WGL_ARB_extensions_string */ /* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */ #ifndef WGL_ARB_framebuffer_sRGB #define WGL_ARB_framebuffer_sRGB 1 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 #define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB) #endif /* WGL_ARB_framebuffer_sRGB */ /* ----------------------- WGL_ARB_make_current_read ----------------------- */ #ifndef WGL_ARB_make_current_read #define WGL_ARB_make_current_read 1 #define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID); typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); #define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB) #define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB) #define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read) #endif /* WGL_ARB_make_current_read */ /* -------------------------- WGL_ARB_multisample -------------------------- */ #ifndef WGL_ARB_multisample #define WGL_ARB_multisample 1 #define WGL_SAMPLE_BUFFERS_ARB 0x2041 #define WGL_SAMPLES_ARB 0x2042 #define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample) #endif /* WGL_ARB_multisample */ /* ---------------------------- WGL_ARB_pbuffer ---------------------------- */ #ifndef WGL_ARB_pbuffer #define WGL_ARB_pbuffer 1 #define WGL_DRAW_TO_PBUFFER_ARB 0x202D #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 #define WGL_PBUFFER_LARGEST_ARB 0x2033 #define WGL_PBUFFER_WIDTH_ARB 0x2034 #define WGL_PBUFFER_HEIGHT_ARB 0x2035 #define WGL_PBUFFER_LOST_ARB 0x2036 DECLARE_HANDLE(HPBUFFERARB); typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); #define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB) #define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB) #define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB) #define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB) #define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB) #define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer) #endif /* WGL_ARB_pbuffer */ /* -------------------------- WGL_ARB_pixel_format ------------------------- */ #ifndef WGL_ARB_pixel_format #define WGL_ARB_pixel_format 1 #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 #define WGL_DRAW_TO_WINDOW_ARB 0x2001 #define WGL_DRAW_TO_BITMAP_ARB 0x2002 #define WGL_ACCELERATION_ARB 0x2003 #define WGL_NEED_PALETTE_ARB 0x2004 #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 #define WGL_SWAP_METHOD_ARB 0x2007 #define WGL_NUMBER_OVERLAYS_ARB 0x2008 #define WGL_NUMBER_UNDERLAYS_ARB 0x2009 #define WGL_TRANSPARENT_ARB 0x200A #define WGL_SHARE_DEPTH_ARB 0x200C #define WGL_SHARE_STENCIL_ARB 0x200D #define WGL_SHARE_ACCUM_ARB 0x200E #define WGL_SUPPORT_GDI_ARB 0x200F #define WGL_SUPPORT_OPENGL_ARB 0x2010 #define WGL_DOUBLE_BUFFER_ARB 0x2011 #define WGL_STEREO_ARB 0x2012 #define WGL_PIXEL_TYPE_ARB 0x2013 #define WGL_COLOR_BITS_ARB 0x2014 #define WGL_RED_BITS_ARB 0x2015 #define WGL_RED_SHIFT_ARB 0x2016 #define WGL_GREEN_BITS_ARB 0x2017 #define WGL_GREEN_SHIFT_ARB 0x2018 #define WGL_BLUE_BITS_ARB 0x2019 #define WGL_BLUE_SHIFT_ARB 0x201A #define WGL_ALPHA_BITS_ARB 0x201B #define WGL_ALPHA_SHIFT_ARB 0x201C #define WGL_ACCUM_BITS_ARB 0x201D #define WGL_ACCUM_RED_BITS_ARB 0x201E #define WGL_ACCUM_GREEN_BITS_ARB 0x201F #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 #define WGL_DEPTH_BITS_ARB 0x2022 #define WGL_STENCIL_BITS_ARB 0x2023 #define WGL_AUX_BUFFERS_ARB 0x2024 #define WGL_NO_ACCELERATION_ARB 0x2025 #define WGL_GENERIC_ACCELERATION_ARB 0x2026 #define WGL_FULL_ACCELERATION_ARB 0x2027 #define WGL_SWAP_EXCHANGE_ARB 0x2028 #define WGL_SWAP_COPY_ARB 0x2029 #define WGL_SWAP_UNDEFINED_ARB 0x202A #define WGL_TYPE_RGBA_ARB 0x202B #define WGL_TYPE_COLORINDEX_ARB 0x202C #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues); #define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB) #define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB) #define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB) #define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format) #endif /* WGL_ARB_pixel_format */ /* ----------------------- WGL_ARB_pixel_format_float ---------------------- */ #ifndef WGL_ARB_pixel_format_float #define WGL_ARB_pixel_format_float 1 #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 #define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float) #endif /* WGL_ARB_pixel_format_float */ /* ------------------------- WGL_ARB_render_texture ------------------------ */ #ifndef WGL_ARB_render_texture #define WGL_ARB_render_texture 1 #define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 #define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 #define WGL_TEXTURE_FORMAT_ARB 0x2072 #define WGL_TEXTURE_TARGET_ARB 0x2073 #define WGL_MIPMAP_TEXTURE_ARB 0x2074 #define WGL_TEXTURE_RGB_ARB 0x2075 #define WGL_TEXTURE_RGBA_ARB 0x2076 #define WGL_NO_TEXTURE_ARB 0x2077 #define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 #define WGL_TEXTURE_1D_ARB 0x2079 #define WGL_TEXTURE_2D_ARB 0x207A #define WGL_MIPMAP_LEVEL_ARB 0x207B #define WGL_CUBE_MAP_FACE_ARB 0x207C #define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 #define WGL_FRONT_LEFT_ARB 0x2083 #define WGL_FRONT_RIGHT_ARB 0x2084 #define WGL_BACK_LEFT_ARB 0x2085 #define WGL_BACK_RIGHT_ARB 0x2086 #define WGL_AUX0_ARB 0x2087 #define WGL_AUX1_ARB 0x2088 #define WGL_AUX2_ARB 0x2089 #define WGL_AUX3_ARB 0x208A #define WGL_AUX4_ARB 0x208B #define WGL_AUX5_ARB 0x208C #define WGL_AUX6_ARB 0x208D #define WGL_AUX7_ARB 0x208E #define WGL_AUX8_ARB 0x208F #define WGL_AUX9_ARB 0x2090 typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList); #define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB) #define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB) #define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB) #define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture) #endif /* WGL_ARB_render_texture */ /* ----------------------- WGL_ATI_pixel_format_float ---------------------- */ #ifndef WGL_ATI_pixel_format_float #define WGL_ATI_pixel_format_float 1 #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 #define GL_RGBA_FLOAT_MODE_ATI 0x8820 #define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 #define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float) #endif /* WGL_ATI_pixel_format_float */ /* -------------------- WGL_ATI_render_texture_rectangle ------------------- */ #ifndef WGL_ATI_render_texture_rectangle #define WGL_ATI_render_texture_rectangle 1 #define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 #define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle) #endif /* WGL_ATI_render_texture_rectangle */ /* ------------------- WGL_EXT_create_context_es2_profile ------------------ */ #ifndef WGL_EXT_create_context_es2_profile #define WGL_EXT_create_context_es2_profile 1 #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 #define WGLEW_EXT_create_context_es2_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es2_profile) #endif /* WGL_EXT_create_context_es2_profile */ /* -------------------------- WGL_EXT_depth_float -------------------------- */ #ifndef WGL_EXT_depth_float #define WGL_EXT_depth_float 1 #define WGL_DEPTH_FLOAT_EXT 0x2040 #define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float) #endif /* WGL_EXT_depth_float */ /* ---------------------- WGL_EXT_display_color_table ---------------------- */ #ifndef WGL_EXT_display_color_table #define WGL_EXT_display_color_table 1 typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length); #define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT) #define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT) #define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT) #define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT) #define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table) #endif /* WGL_EXT_display_color_table */ /* ----------------------- WGL_EXT_extensions_string ----------------------- */ #ifndef WGL_EXT_extensions_string #define WGL_EXT_extensions_string 1 typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); #define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT) #define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string) #endif /* WGL_EXT_extensions_string */ /* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */ #ifndef WGL_EXT_framebuffer_sRGB #define WGL_EXT_framebuffer_sRGB 1 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 #define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB) #endif /* WGL_EXT_framebuffer_sRGB */ /* ----------------------- WGL_EXT_make_current_read ----------------------- */ #ifndef WGL_EXT_make_current_read #define WGL_EXT_make_current_read 1 #define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID); typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); #define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT) #define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT) #define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read) #endif /* WGL_EXT_make_current_read */ /* -------------------------- WGL_EXT_multisample -------------------------- */ #ifndef WGL_EXT_multisample #define WGL_EXT_multisample 1 #define WGL_SAMPLE_BUFFERS_EXT 0x2041 #define WGL_SAMPLES_EXT 0x2042 #define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample) #endif /* WGL_EXT_multisample */ /* ---------------------------- WGL_EXT_pbuffer ---------------------------- */ #ifndef WGL_EXT_pbuffer #define WGL_EXT_pbuffer 1 #define WGL_DRAW_TO_PBUFFER_EXT 0x202D #define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E #define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F #define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 #define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 #define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 #define WGL_PBUFFER_LARGEST_EXT 0x2033 #define WGL_PBUFFER_WIDTH_EXT 0x2034 #define WGL_PBUFFER_HEIGHT_EXT 0x2035 DECLARE_HANDLE(HPBUFFEREXT); typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); #define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT) #define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT) #define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT) #define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT) #define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT) #define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer) #endif /* WGL_EXT_pbuffer */ /* -------------------------- WGL_EXT_pixel_format ------------------------- */ #ifndef WGL_EXT_pixel_format #define WGL_EXT_pixel_format 1 #define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 #define WGL_DRAW_TO_WINDOW_EXT 0x2001 #define WGL_DRAW_TO_BITMAP_EXT 0x2002 #define WGL_ACCELERATION_EXT 0x2003 #define WGL_NEED_PALETTE_EXT 0x2004 #define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 #define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 #define WGL_SWAP_METHOD_EXT 0x2007 #define WGL_NUMBER_OVERLAYS_EXT 0x2008 #define WGL_NUMBER_UNDERLAYS_EXT 0x2009 #define WGL_TRANSPARENT_EXT 0x200A #define WGL_TRANSPARENT_VALUE_EXT 0x200B #define WGL_SHARE_DEPTH_EXT 0x200C #define WGL_SHARE_STENCIL_EXT 0x200D #define WGL_SHARE_ACCUM_EXT 0x200E #define WGL_SUPPORT_GDI_EXT 0x200F #define WGL_SUPPORT_OPENGL_EXT 0x2010 #define WGL_DOUBLE_BUFFER_EXT 0x2011 #define WGL_STEREO_EXT 0x2012 #define WGL_PIXEL_TYPE_EXT 0x2013 #define WGL_COLOR_BITS_EXT 0x2014 #define WGL_RED_BITS_EXT 0x2015 #define WGL_RED_SHIFT_EXT 0x2016 #define WGL_GREEN_BITS_EXT 0x2017 #define WGL_GREEN_SHIFT_EXT 0x2018 #define WGL_BLUE_BITS_EXT 0x2019 #define WGL_BLUE_SHIFT_EXT 0x201A #define WGL_ALPHA_BITS_EXT 0x201B #define WGL_ALPHA_SHIFT_EXT 0x201C #define WGL_ACCUM_BITS_EXT 0x201D #define WGL_ACCUM_RED_BITS_EXT 0x201E #define WGL_ACCUM_GREEN_BITS_EXT 0x201F #define WGL_ACCUM_BLUE_BITS_EXT 0x2020 #define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 #define WGL_DEPTH_BITS_EXT 0x2022 #define WGL_STENCIL_BITS_EXT 0x2023 #define WGL_AUX_BUFFERS_EXT 0x2024 #define WGL_NO_ACCELERATION_EXT 0x2025 #define WGL_GENERIC_ACCELERATION_EXT 0x2026 #define WGL_FULL_ACCELERATION_EXT 0x2027 #define WGL_SWAP_EXCHANGE_EXT 0x2028 #define WGL_SWAP_COPY_EXT 0x2029 #define WGL_SWAP_UNDEFINED_EXT 0x202A #define WGL_TYPE_RGBA_EXT 0x202B #define WGL_TYPE_COLORINDEX_EXT 0x202C typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); #define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT) #define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT) #define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT) #define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format) #endif /* WGL_EXT_pixel_format */ /* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */ #ifndef WGL_EXT_pixel_format_packed_float #define WGL_EXT_pixel_format_packed_float 1 #define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 #define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float) #endif /* WGL_EXT_pixel_format_packed_float */ /* -------------------------- WGL_EXT_swap_control ------------------------- */ #ifndef WGL_EXT_swap_control #define WGL_EXT_swap_control 1 typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); #define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT) #define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT) #define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control) #endif /* WGL_EXT_swap_control */ /* --------------------- WGL_I3D_digital_video_control --------------------- */ #ifndef WGL_I3D_digital_video_control #define WGL_I3D_digital_video_control 1 #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 #define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 #define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); #define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D) #define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D) #define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control) #endif /* WGL_I3D_digital_video_control */ /* ----------------------------- WGL_I3D_gamma ----------------------------- */ #ifndef WGL_I3D_gamma #define WGL_I3D_gamma 1 #define WGL_GAMMA_TABLE_SIZE_I3D 0x204E #define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue); typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); #define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D) #define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D) #define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D) #define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D) #define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma) #endif /* WGL_I3D_gamma */ /* ---------------------------- WGL_I3D_genlock ---------------------------- */ #ifndef WGL_I3D_genlock #define WGL_I3D_genlock 1 #define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 #define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 #define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 #define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 #define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 #define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 #define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A #define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B #define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource); typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag); typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay); #define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D) #define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D) #define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D) #define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D) #define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D) #define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D) #define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D) #define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D) #define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D) #define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D) #define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D) #define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D) #define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock) #endif /* WGL_I3D_genlock */ /* -------------------------- WGL_I3D_image_buffer ------------------------- */ #ifndef WGL_I3D_image_buffer #define WGL_I3D_image_buffer 1 #define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 #define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count); typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count); #define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D) #define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D) #define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D) #define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D) #define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer) #endif /* WGL_I3D_image_buffer */ /* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */ #ifndef WGL_I3D_swap_frame_lock #define WGL_I3D_swap_frame_lock 1 typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID); typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID); typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag); typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag); #define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D) #define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D) #define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D) #define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D) #define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock) #endif /* WGL_I3D_swap_frame_lock */ /* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */ #ifndef WGL_I3D_swap_frame_usage #define WGL_I3D_swap_frame_usage 1 typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage); typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); #define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D) #define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D) #define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D) #define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D) #define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage) #endif /* WGL_I3D_swap_frame_usage */ /* --------------------------- WGL_NV_DX_interop --------------------------- */ #ifndef WGL_NV_DX_interop #define WGL_NV_DX_interop 1 #define WGL_ACCESS_READ_ONLY_NV 0x0000 #define WGL_ACCESS_READ_WRITE_NV 0x0001 #define WGL_ACCESS_WRITE_DISCARD_NV 0x0002 typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice); typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access); typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle); typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); #define wglDXCloseDeviceNV WGLEW_GET_FUN(__wglewDXCloseDeviceNV) #define wglDXLockObjectsNV WGLEW_GET_FUN(__wglewDXLockObjectsNV) #define wglDXObjectAccessNV WGLEW_GET_FUN(__wglewDXObjectAccessNV) #define wglDXOpenDeviceNV WGLEW_GET_FUN(__wglewDXOpenDeviceNV) #define wglDXRegisterObjectNV WGLEW_GET_FUN(__wglewDXRegisterObjectNV) #define wglDXSetResourceShareHandleNV WGLEW_GET_FUN(__wglewDXSetResourceShareHandleNV) #define wglDXUnlockObjectsNV WGLEW_GET_FUN(__wglewDXUnlockObjectsNV) #define wglDXUnregisterObjectNV WGLEW_GET_FUN(__wglewDXUnregisterObjectNV) #define WGLEW_NV_DX_interop WGLEW_GET_VAR(__WGLEW_NV_DX_interop) #endif /* WGL_NV_DX_interop */ /* --------------------------- WGL_NV_copy_image --------------------------- */ #ifndef WGL_NV_copy_image #define WGL_NV_copy_image 1 typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV) #define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image) #endif /* WGL_NV_copy_image */ /* -------------------------- WGL_NV_float_buffer -------------------------- */ #ifndef WGL_NV_float_buffer #define WGL_NV_float_buffer 1 #define WGL_FLOAT_COMPONENTS_NV 0x20B0 #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 #define WGL_TEXTURE_FLOAT_R_NV 0x20B5 #define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 #define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 #define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 #define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer) #endif /* WGL_NV_float_buffer */ /* -------------------------- WGL_NV_gpu_affinity -------------------------- */ #ifndef WGL_NV_gpu_affinity #define WGL_NV_gpu_affinity 1 #define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 #define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 DECLARE_HANDLE(HGPUNV); typedef struct _GPU_DEVICE { DWORD cb; CHAR DeviceName[32]; CHAR DeviceString[128]; DWORD Flags; RECT rcVirtualScreen; } GPU_DEVICE, *PGPU_DEVICE; typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); #define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV) #define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV) #define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV) #define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV) #define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV) #define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity) #endif /* WGL_NV_gpu_affinity */ /* ---------------------- WGL_NV_multisample_coverage ---------------------- */ #ifndef WGL_NV_multisample_coverage #define WGL_NV_multisample_coverage 1 #define WGL_COVERAGE_SAMPLES_NV 0x2042 #define WGL_COLOR_SAMPLES_NV 0x20B9 #define WGLEW_NV_multisample_coverage WGLEW_GET_VAR(__WGLEW_NV_multisample_coverage) #endif /* WGL_NV_multisample_coverage */ /* -------------------------- WGL_NV_present_video ------------------------- */ #ifndef WGL_NV_present_video #define WGL_NV_present_video 1 #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList); typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList); typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue); #define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV) #define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV) #define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV) #define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video) #endif /* WGL_NV_present_video */ /* ---------------------- WGL_NV_render_depth_texture ---------------------- */ #ifndef WGL_NV_render_depth_texture #define WGL_NV_render_depth_texture 1 #define WGL_NO_TEXTURE_ARB 0x2077 #define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 #define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 #define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 #define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 #define WGL_DEPTH_COMPONENT_NV 0x20A7 #define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture) #endif /* WGL_NV_render_depth_texture */ /* -------------------- WGL_NV_render_texture_rectangle -------------------- */ #ifndef WGL_NV_render_texture_rectangle #define WGL_NV_render_texture_rectangle 1 #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 #define WGL_TEXTURE_RECTANGLE_NV 0x20A2 #define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle) #endif /* WGL_NV_render_texture_rectangle */ /* --------------------------- WGL_NV_swap_group --------------------------- */ #ifndef WGL_NV_swap_group #define WGL_NV_swap_group 1 typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count); typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers); typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier); typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); #define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV) #define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV) #define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV) #define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV) #define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV) #define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV) #define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group) #endif /* WGL_NV_swap_group */ /* ----------------------- WGL_NV_vertex_array_range ----------------------- */ #ifndef WGL_NV_vertex_array_range #define WGL_NV_vertex_array_range 1 typedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); #define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV) #define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV) #define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range) #endif /* WGL_NV_vertex_array_range */ /* -------------------------- WGL_NV_video_capture ------------------------- */ #ifndef WGL_NV_video_capture #define WGL_NV_video_capture 1 #define WGL_UNIQUE_ID_NV 0x20CE #define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF DECLARE_HANDLE(HVIDEOINPUTDEVICENV); typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV* phDeviceList); typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int* piValue); typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); #define wglBindVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewBindVideoCaptureDeviceNV) #define wglEnumerateVideoCaptureDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoCaptureDevicesNV) #define wglLockVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewLockVideoCaptureDeviceNV) #define wglQueryVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewQueryVideoCaptureDeviceNV) #define wglReleaseVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoCaptureDeviceNV) #define WGLEW_NV_video_capture WGLEW_GET_VAR(__WGLEW_NV_video_capture) #endif /* WGL_NV_video_capture */ /* -------------------------- WGL_NV_video_output -------------------------- */ #ifndef WGL_NV_video_output #define WGL_NV_video_output 1 #define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 #define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 #define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 #define WGL_VIDEO_OUT_COLOR_NV 0x20C3 #define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 #define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 #define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 #define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 #define WGL_VIDEO_OUT_FRAME 0x20C8 #define WGL_VIDEO_OUT_FIELD_1 0x20C9 #define WGL_VIDEO_OUT_FIELD_2 0x20CA #define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB #define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC DECLARE_HANDLE(HPVIDEODEV); typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice); typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock); #define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV) #define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV) #define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV) #define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV) #define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV) #define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV) #define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output) #endif /* WGL_NV_video_output */ /* -------------------------- WGL_OML_sync_control ------------------------- */ #ifndef WGL_OML_sync_control #define WGL_OML_sync_control 1 typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator); typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc); typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc); typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc); #define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML) #define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML) #define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML) #define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML) #define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML) #define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML) #define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control) #endif /* WGL_OML_sync_control */ /* ------------------------------------------------------------------------- */ #ifdef GLEW_MX #define WGLEW_EXPORT #else #define WGLEW_EXPORT GLEWAPI #endif /* GLEW_MX */ #ifdef GLEW_MX struct WGLEWContextStruct { #endif /* GLEW_MX */ WGLEW_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; WGLEW_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD; WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD; WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD; WGLEW_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD; WGLEW_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD; WGLEW_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD; WGLEW_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD; WGLEW_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD; WGLEW_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD; WGLEW_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; WGLEW_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB; WGLEW_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB; WGLEW_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB; WGLEW_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB; WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB; WGLEW_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB; WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB; WGLEW_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB; WGLEW_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB; WGLEW_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB; WGLEW_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB; WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB; WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB; WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB; WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB; WGLEW_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB; WGLEW_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB; WGLEW_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB; WGLEW_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT; WGLEW_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT; WGLEW_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT; WGLEW_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT; WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT; WGLEW_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT; WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT; WGLEW_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT; WGLEW_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT; WGLEW_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT; WGLEW_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT; WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT; WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT; WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT; WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT; WGLEW_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT; WGLEW_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT; WGLEW_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D; WGLEW_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D; WGLEW_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D; WGLEW_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D; WGLEW_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D; WGLEW_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D; WGLEW_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D; WGLEW_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D; WGLEW_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D; WGLEW_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D; WGLEW_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D; WGLEW_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D; WGLEW_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D; WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D; WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D; WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D; WGLEW_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D; WGLEW_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D; WGLEW_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D; WGLEW_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D; WGLEW_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D; WGLEW_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D; WGLEW_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D; WGLEW_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D; WGLEW_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D; WGLEW_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D; WGLEW_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D; WGLEW_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D; WGLEW_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D; WGLEW_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D; WGLEW_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV; WGLEW_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV; WGLEW_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV; WGLEW_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV; WGLEW_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV; WGLEW_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV; WGLEW_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV; WGLEW_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV; WGLEW_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV; WGLEW_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV; WGLEW_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV; WGLEW_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV; WGLEW_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV; WGLEW_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV; WGLEW_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV; WGLEW_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV; WGLEW_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV; WGLEW_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV; WGLEW_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV; WGLEW_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV; WGLEW_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV; WGLEW_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV; WGLEW_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV; WGLEW_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV; WGLEW_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV; WGLEW_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV; WGLEW_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV; WGLEW_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV; WGLEW_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV; WGLEW_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV; WGLEW_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV; WGLEW_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV; WGLEW_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV; WGLEW_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV; WGLEW_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV; WGLEW_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV; WGLEW_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML; WGLEW_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML; WGLEW_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML; WGLEW_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML; WGLEW_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML; WGLEW_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML; WGLEW_EXPORT GLboolean __WGLEW_3DFX_multisample; WGLEW_EXPORT GLboolean __WGLEW_3DL_stereo_control; WGLEW_EXPORT GLboolean __WGLEW_AMD_gpu_association; WGLEW_EXPORT GLboolean __WGLEW_ARB_buffer_region; WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context; WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_profile; WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_robustness; WGLEW_EXPORT GLboolean __WGLEW_ARB_extensions_string; WGLEW_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB; WGLEW_EXPORT GLboolean __WGLEW_ARB_make_current_read; WGLEW_EXPORT GLboolean __WGLEW_ARB_multisample; WGLEW_EXPORT GLboolean __WGLEW_ARB_pbuffer; WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format; WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format_float; WGLEW_EXPORT GLboolean __WGLEW_ARB_render_texture; WGLEW_EXPORT GLboolean __WGLEW_ATI_pixel_format_float; WGLEW_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle; WGLEW_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile; WGLEW_EXPORT GLboolean __WGLEW_EXT_depth_float; WGLEW_EXPORT GLboolean __WGLEW_EXT_display_color_table; WGLEW_EXPORT GLboolean __WGLEW_EXT_extensions_string; WGLEW_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB; WGLEW_EXPORT GLboolean __WGLEW_EXT_make_current_read; WGLEW_EXPORT GLboolean __WGLEW_EXT_multisample; WGLEW_EXPORT GLboolean __WGLEW_EXT_pbuffer; WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format; WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float; WGLEW_EXPORT GLboolean __WGLEW_EXT_swap_control; WGLEW_EXPORT GLboolean __WGLEW_I3D_digital_video_control; WGLEW_EXPORT GLboolean __WGLEW_I3D_gamma; WGLEW_EXPORT GLboolean __WGLEW_I3D_genlock; WGLEW_EXPORT GLboolean __WGLEW_I3D_image_buffer; WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock; WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage; WGLEW_EXPORT GLboolean __WGLEW_NV_DX_interop; WGLEW_EXPORT GLboolean __WGLEW_NV_copy_image; WGLEW_EXPORT GLboolean __WGLEW_NV_float_buffer; WGLEW_EXPORT GLboolean __WGLEW_NV_gpu_affinity; WGLEW_EXPORT GLboolean __WGLEW_NV_multisample_coverage; WGLEW_EXPORT GLboolean __WGLEW_NV_present_video; WGLEW_EXPORT GLboolean __WGLEW_NV_render_depth_texture; WGLEW_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle; WGLEW_EXPORT GLboolean __WGLEW_NV_swap_group; WGLEW_EXPORT GLboolean __WGLEW_NV_vertex_array_range; WGLEW_EXPORT GLboolean __WGLEW_NV_video_capture; WGLEW_EXPORT GLboolean __WGLEW_NV_video_output; WGLEW_EXPORT GLboolean __WGLEW_OML_sync_control; #ifdef GLEW_MX }; /* WGLEWContextStruct */ #endif /* GLEW_MX */ /* ------------------------------------------------------------------------- */ #ifdef GLEW_MX typedef struct WGLEWContextStruct WGLEWContext; GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx); GLEWAPI GLboolean wglewContextIsSupported (const WGLEWContext* ctx, const char* name); #define wglewInit() wglewContextInit(wglewGetContext()) #define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x) #define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x)) #define WGLEW_GET_FUN(x) wglewGetContext()->x #else /* GLEW_MX */ #define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) #define WGLEW_GET_FUN(x) x GLEWAPI GLboolean wglewIsSupported (const char* name); #endif /* GLEW_MX */ GLEWAPI GLboolean wglewGetExtension (const char* name); #ifdef __cplusplus } #endif #undef GLEWAPI #endif /* __wglew_h__ */ ================================================ FILE: cocos2d/external/win32-specific/icon/include/iconv.h ================================================ /* Copyright (C) 1999-2003 Free Software Foundation, Inc. This file is part of the GNU LIBICONV Library. The GNU LIBICONV Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU LIBICONV 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU LIBICONV Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* When installed, this file is called "iconv.h". */ #ifndef _LIBICONV_H #define _LIBICONV_H #define _LIBICONV_VERSION 0x0109 /* version number: (major<<8) + minor */ extern int _libiconv_version; /* Likewise */ /* We would like to #include any system header file which could define iconv_t, 1. in order to eliminate the risk that the user gets compilation errors because some other system header file includes /usr/include/iconv.h which defines iconv_t or declares iconv after this file, 2. when compiling for LIBICONV_PLUG, we need the proper iconv_t type in order to produce binary compatible code. But gcc's #include_next is not portable. Thus, once libiconv's iconv.h has been installed in /usr/local/include, there is no way any more to include the original /usr/include/iconv.h. We simply have to get away without it. Ad 1. The risk that a system header file does #include "iconv.h" or #include_next "iconv.h" is small. They all do #include . Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It has to be a scalar type because (iconv_t)(-1) is a possible return value from iconv_open().) */ /* Define iconv_t ourselves. */ #undef iconv_t #define iconv_t libiconv_t typedef void* iconv_t; /* Get size_t declaration. */ #include /* Get errno declaration and values. */ #include /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, have EILSEQ in a different header. On these systems, define EILSEQ ourselves. */ #ifndef EILSEQ /* Igor: called upon EILSEQ from glibc, since autogeneration of this header on Windows didn't do the job. */ /* #define EILSEQ @EILSEQ@ */ #define EILSEQ 84 #endif #ifdef __cplusplus extern "C" { #endif /* Allocates descriptor for code conversion from encoding `fromcode' to encoding `tocode'. */ #ifndef LIBICONV_PLUG #define iconv_open libiconv_open #endif extern iconv_t iconv_open (const char* tocode, const char* fromcode); /* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes starting at `*inbuf', writing at most `*outbytesleft' bytes starting at `*outbuf'. Decrements `*inbytesleft' and increments `*inbuf' by the same amount. Decrements `*outbytesleft' and increments `*outbuf' by the same amount. */ #ifndef LIBICONV_PLUG #define iconv libiconv #endif extern size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); /* Frees resources allocated for conversion descriptor `cd'. */ #ifndef LIBICONV_PLUG #define iconv_close libiconv_close #endif extern int iconv_close (iconv_t cd); #ifndef LIBICONV_PLUG /* Nonstandard extensions. */ /* Control of attributes. */ #define iconvctl libiconvctl extern int iconvctl (iconv_t cd, int request, void* argument); /* Requests for iconvctl. */ #define ICONV_TRIVIALP 0 /* int *argument */ #define ICONV_GET_TRANSLITERATE 1 /* int *argument */ #define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ #define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ #define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ /* Listing of locale independent encodings. */ #define iconvlist libiconvlist extern void iconvlist (int (*do_one) (unsigned int namescount, const char * const * names, void* data), void* data); /* Support for relocatable packages. */ /* Sets the original and the current installation prefix of the package. Relocation simply replaces a pathname starting with the original prefix by the corresponding pathname with the current prefix instead. Both prefixes should be directory names without trailing slash (i.e. use "" instead of "/"). */ extern void libiconv_set_relocation_prefix (const char *orig_prefix, const char *curr_prefix); #endif #ifdef __cplusplus } #endif #endif /* _LIBICONV_H */ ================================================ FILE: cocos2d/external/win32-specific/zlib/include/zconf.h ================================================ /* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2010 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #ifndef ZCONF_H #define ZCONF_H /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. * Even better than compiling with -DZ_PREFIX would be to use configure to set * this permanently in zconf.h using "./configure --zprefix". */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ /* all linked symbols */ # define _dist_code z__dist_code # define _length_code z__length_code # define _tr_align z__tr_align # define _tr_flush_block z__tr_flush_block # define _tr_init z__tr_init # define _tr_stored_block z__tr_stored_block # define _tr_tally z__tr_tally # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 # define deflate z_deflate # define deflateBound z_deflateBound # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset # define deflateSetDictionary z_deflateSetDictionary # define deflateSetHeader z_deflateSetHeader # define deflateTune z_deflateTune # define deflate_copyright z_deflate_copyright # define get_crc_table z_get_crc_table # define gz_error z_gz_error # define gz_intmax z_gz_intmax # define gz_strwinerror z_gz_strwinerror # define gzbuffer z_gzbuffer # define gzclearerr z_gzclearerr # define gzclose z_gzclose # define gzclose_r z_gzclose_r # define gzclose_w z_gzclose_w # define gzdirect z_gzdirect # define gzdopen z_gzdopen # define gzeof z_gzeof # define gzerror z_gzerror # define gzflush z_gzflush # define gzgetc z_gzgetc # define gzgets z_gzgets # define gzoffset z_gzoffset # define gzoffset64 z_gzoffset64 # define gzopen z_gzopen # define gzopen64 z_gzopen64 # define gzprintf z_gzprintf # define gzputc z_gzputc # define gzputs z_gzputs # define gzread z_gzread # define gzrewind z_gzrewind # define gzseek z_gzseek # define gzseek64 z_gzseek64 # define gzsetparams z_gzsetparams # define gztell z_gztell # define gztell64 z_gztell64 # define gzungetc z_gzungetc # define gzwrite z_gzwrite # define inflate z_inflate # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define inflateBackInit_ z_inflateBackInit_ # define inflateCopy z_inflateCopy # define inflateEnd z_inflateEnd # define inflateGetHeader z_inflateGetHeader # define inflateInit2_ z_inflateInit2_ # define inflateInit_ z_inflateInit_ # define inflateMark z_inflateMark # define inflatePrime z_inflatePrime # define inflateReset z_inflateReset # define inflateReset2 z_inflateReset2 # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # define uncompress z_uncompress # define zError z_zError # define zcalloc z_zcalloc # define zcfree z_zcfree # define zlibCompileFlags z_zlibCompileFlags # define zlibVersion z_zlibVersion /* all zlib typedefs in zlib.h and zconf.h */ # define Byte z_Byte # define Bytef z_Bytef # define alloc_func z_alloc_func # define charf z_charf # define free_func z_free_func # define gzFile z_gzFile # define gz_header z_gz_header # define gz_headerp z_gz_headerp # define in_func z_in_func # define intf z_intf # define out_func z_out_func # define uInt z_uInt # define uIntf z_uIntf # define uLong z_uLong # define uLongf z_uLongf # define voidp z_voidp # define voidpc z_voidpc # define voidpf z_voidpf /* all zlib structs in zlib.h and zconf.h */ # define gz_header_s z_gz_header_s # define internal_state z_internal_state #endif #if defined(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) # define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) # ifndef WIN32 # define WIN32 # endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) # ifndef SYS16BIT # define SYS16BIT # endif # endif #endif /* * Compile with -DMAXSEG_64K if the alloc function cannot allocate more * than 64k bytes at a time (needed on systems with 16-bit int). */ #ifdef SYS16BIT # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #ifdef __STDC_VERSION__ # ifndef STDC # define STDC # endif # if __STDC_VERSION__ >= 199901L # ifndef STDC99 # define STDC99 # endif # endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif #endif /* Some Mac compilers merge all .h files incorrectly: */ #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) # define NO_DUMMY_DECL #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ #ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): (1 << (windowBits+2)) + (1 << (memLevel+9)) that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) plus a few kilobytes for small objects. For example, if you want to reduce the default memory requirements from 256K to 128K, compile with make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus a few kilobytes for small objects. */ /* Type declarations */ #ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ # ifdef ZLIB_DLL # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # ifdef ZLIB_INTERNAL # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif # endif # endif /* ZLIB_DLL */ /* If building or using zlib with the WINAPI/WINAPIV calling convention, * define ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. */ # ifdef ZLIB_WINAPI # ifdef FAR # undef FAR # endif # include /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR CDECL # endif # endif #endif #if defined (__BEOS__) # ifdef ZLIB_DLL # ifdef ZLIB_INTERNAL # define ZEXPORT __declspec(dllexport) # define ZEXPORTVA __declspec(dllexport) # else # define ZEXPORT __declspec(dllimport) # define ZEXPORTVA __declspec(dllimport) # endif # endif #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef FAR # define FAR #endif #if !defined(__MACTYPES__) typedef unsigned char Byte; /* 8 bits */ #endif typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ #ifdef SMALL_MEDIUM /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte FAR Bytef; #endif typedef char FAR charf; typedef int FAR intf; typedef uInt FAR uIntf; typedef uLong FAR uLongf; #ifdef STDC typedef void const *voidpc; typedef void FAR *voidpf; typedef void *voidp; #else typedef Byte const *voidpc; typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif #ifdef STDC # include /* for off_t */ #endif /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even * though the former does not conform to the LFS document), but considering * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as * equivalently requesting no 64-bit operations */ #if -_LARGEFILE64_SOURCE - -1 == 1 # undef _LARGEFILE64_SOURCE #endif #if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) # include /* for SEEK_* and off_t */ # ifdef VMS # include /* for off_t */ # endif # ifndef z_off_t # define z_off_t off_t # endif #endif #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long #endif #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 # define z_off64_t off64_t #else # define z_off64_t z_off_t #endif #if defined(__OS400__) # define NO_vsnprintf #endif #if defined(__MVS__) # define NO_vsnprintf #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") #pragma map(deflateInit2_,"DEIN2") #pragma map(deflateEnd,"DEEND") #pragma map(deflateBound,"DEBND") #pragma map(inflateInit_,"ININ") #pragma map(inflateInit2_,"ININ2") #pragma map(inflateEnd,"INEND") #pragma map(inflateSync,"INSY") #pragma map(inflateSetDictionary,"INSEDI") #pragma map(compressBound,"CMBND") #pragma map(inflate_table,"INTABL") #pragma map(inflate_fast,"INFA") #pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */ ================================================ FILE: cocos2d/external/win32-specific/zlib/include/zlib.h ================================================ /* zlib.h -- interface of the 'zlib' general purpose compression library version 1.2.5, April 19th, 2010 Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). */ #ifndef ZLIB_H #define ZLIB_H #include "zconf.h" #ifdef __cplusplus extern "C" { #endif #define ZLIB_VERSION "1.2.5" #define ZLIB_VERNUM 0x1250 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 2 #define ZLIB_VER_REVISION 5 #define ZLIB_VER_SUBREVISION 0 /* The 'zlib' compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method (deflation) but other algorithms will be added later and will have the same stream interface. Compression can be done in a single step if the buffers are large enough, or can be done by repeated calls of the compression function. In the latter case, the application must provide more input and/or consume the output (providing more output space) before each call. The compressed data format used by default by the in-memory functions is the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped around a deflate stream, which is itself documented in RFC 1951. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. This library can optionally read and write gzip streams in memory as well. The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input. */ typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); typedef void (*free_func) OF((voidpf opaque, voidpf address)); struct internal_state; typedef struct z_stream_s { Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total nb of input bytes read so far */ Bytef *next_out; /* next output byte should be put there */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total nb of bytes output so far */ char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ int data_type; /* best guess about the data type: binary or text */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; /* gzip header information passed to and from zlib routines. See RFC 1952 for more details on the meanings of these fields. */ typedef struct gz_header_s { int text; /* true if compressed data believed to be text */ uLong time; /* modification time */ int xflags; /* extra flags (not used when writing a gzip file) */ int os; /* operating system */ Bytef *extra; /* pointer to extra field or Z_NULL if none */ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ uInt extra_max; /* space at extra (only when reading header) */ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ uInt name_max; /* space at name (only when reading header) */ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ uInt comm_max; /* space at comment (only when reading header) */ int hcrc; /* true if there was or will be a header crc */ int done; /* true when done reading gzip header (not used when writing a gzip file) */ } gz_header; typedef gz_header FAR *gz_headerp; /* The application must update next_in and avail_in when avail_in has dropped to zero. It must update next_out and avail_out when avail_out has dropped to zero. The application must initialize zalloc, zfree and opaque before calling the init function. All other fields are set by the compression library and must not be updated by the application. The opaque value provided by the application will be passed as the first parameter for calls of zalloc and zfree. This can be useful for custom memory management. The compression library attaches no meaning to the opaque value. zalloc must return Z_NULL if there is not enough memory for the object. If zlib is used in a multi-threaded application, zalloc and zfree must be thread safe. On 16-bit systems, the functions zalloc and zfree must be able to allocate exactly 65536 bytes, but will not be required to allocate more than this if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers returned by zalloc for objects of exactly 65536 bytes *must* have their offset normalized to zero. The default allocation function provided by this library ensures this (see zutil.c). To reduce memory requirements and avoid any allocation of 64K objects, at the expense of compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). The fields total_in and total_out can be used for statistics or progress reports. After compression, total_in holds the total size of the uncompressed data and may be saved for use in the decompressor (particularly if the decompressor wants to decompress everything in a single step). */ /* constants */ #define Z_NO_FLUSH 0 #define Z_PARTIAL_FLUSH 1 #define Z_SYNC_FLUSH 2 #define Z_FULL_FLUSH 3 #define Z_FINISH 4 #define Z_BLOCK 5 #define Z_TREES 6 /* Allowed flush values; see deflate() and inflate() below for details */ #define Z_OK 0 #define Z_STREAM_END 1 #define Z_NEED_DICT 2 #define Z_ERRNO (-1) #define Z_STREAM_ERROR (-2) #define Z_DATA_ERROR (-3) #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) /* Return codes for the compression/decompression functions. Negative values * are errors, positive values are used for special but normal events. */ #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) /* compression levels */ #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_RLE 3 #define Z_FIXED 4 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 #define Z_TEXT 1 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ #define Z_UNKNOWN 2 /* Possible values of the data_type field (though see inflate()) */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ #define zlib_version zlibVersion() /* for compatibility with versions < 1.0.2 */ /* basic functions */ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check is automatically made by deflateInit and inflateInit. */ /* ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default allocation functions. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6). deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if level is not a valid compression level, or Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. deflate performs one or both of the following actions: - Compress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call of deflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter should be set only when necessary (in interactive applications). Some output may be provided even if flush is not set. Before the call of deflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating avail_in or avail_out accordingly; avail_out should never be zero before the call. The application can consume the compressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to decide how much data to accumulate before producing output, in order to maximize compression. If the parameter flush is set to Z_SYNC_FLUSH, all pending output is flushed to the output buffer and the output is aligned on a byte boundary, so that the decompressor can get all input data available so far. (In particular avail_in is zero after the call if enough output space has been provided before the call.) Flushing may degrade compression for some compression algorithms and so it should be used only when necessary. This completes the current deflate block and follows it with an empty stored block that is three bits plus filler bits to the next byte, followed by four bytes (00 00 ff ff). If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the output buffer, but the output is not aligned to a byte boundary. All of the input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. This completes the current deflate block and follows it with an empty fixed codes block that is 10 bits long. This assures that enough bytes are output in order for the decompressor to finish the block before the empty fixed code block. If flush is set to Z_BLOCK, a deflate block is completed and emitted, as for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to seven bits of the current block are held to be written as the next byte after the next deflate block is completed. In this case, the decompressor may not be provided enough bits at this point in order to complete decompression of the data provided so far to the compressor. It may need to wait for the next block to be emitted. This is for advanced applications that need to control the emission of deflate blocks. If flush is set to Z_FULL_FLUSH, all output is flushed as with Z_SYNC_FLUSH, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if random access is desired. Using Z_FULL_FLUSH too often can seriously degrade compression. If deflate returns with avail_out == 0, this function must be called again with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out is greater than six to avoid repeated flush markers due to avail_out == 0 on return. If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was enough output space; if deflate returns with Z_OK, this function must be called again with Z_FINISH and more output space (updated avail_out) but no more input data, until it returns with Z_STREAM_END or an error. After deflate has returned Z_STREAM_END, the only possible operations on the stream are deflateReset or deflateEnd. Z_FINISH can be used immediately after deflateInit if all the compression is to be done in a single step. In this case, avail_out must be at least the value returned by deflateBound (see below). If deflate does not return Z_STREAM_END, then it must be called again as described above. deflate() sets strm->adler to the adler32 checksum of all input read so far (that is, total_in bytes). deflate() may update strm->data_type if it can make a good guess about the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered binary. This field is only for information purposes and does not affect the compression algorithm in any manner. deflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and deflate() can be called again with more input and more output space to continue compressing. */ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent, Z_DATA_ERROR if the stream was freed prematurely (some input or output was discarded). In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. If next_in is not Z_NULL and avail_in is large enough (the exact value depends on the compression method), inflateInit determines the compression method from the zlib header and allocates all data structures accordingly; otherwise the allocation will be deferred to the first call of inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to use default allocation functions. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller, or Z_STREAM_ERROR if the parameters are invalid, such as a null pointer to the structure. msg is set to null if there is no error message. inflateInit does not perform any decompression apart from possibly reading the zlib header if present: actual decompression will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unused and unchanged.) The current implementation of inflateInit() does not process any header information -- that is deferred until inflate() is called. */ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. inflate performs one or both of the following actions: - Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in is updated and processing will resume at this point for the next call of inflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. inflate() provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the flush parameter). Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of inflate(). If inflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much output as possible to the output buffer. Z_BLOCK requests that inflate() stop if and when it gets to the next deflate block boundary. When decoding the zlib or gzip format, this will cause inflate() to return immediately after the header and before the first block. When doing a raw inflate, inflate() will go ahead and process the first block, and will return when it gets to the end of that block, or when it runs out of data. The Z_BLOCK option assists in appending to or combining deflate streams. Also to assist in this, on return inflate() will set strm->data_type to the number of unused bits in the last byte taken from strm->next_in, plus 64 if inflate() is currently decoding the last block in the deflate stream, plus 128 if inflate() returned immediately after decoding an end-of-block code or decoding the complete header up to just before the first byte of the deflate stream. The end-of-block will not be indicated until all of the uncompressed data from that block has been written to strm->next_out. The number of unused bits may in general be greater than seven, except when bit 7 of data_type is set, in which case the number of unused bits will be less than eight. data_type is set as noted here every time inflate() returns for all flush options, and so can be used to determine the amount of currently consumed input in bits. The Z_TREES option behaves as Z_BLOCK does, but it also returns when the end of each deflate block header is reached, before any actual data in that block is decoded. This allows the caller to determine the length of the deflate block header for later use in random access within a deflate block. 256 is added to the value of strm->data_type when inflate() returns immediately after reaching the end of the deflate block header. inflate() should normally be called until it returns Z_STREAM_END or an error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; avail_out must be large enough to hold all the uncompressed data. (The size of the uncompressed data may have been saved by the compressor for this purpose.) The next operation on this stream must be inflateEnd to deallocate the decompression state. The use of Z_FINISH is never required, but can be used to inform inflate that a faster approach may be used for the single inflate() call. In this implementation, inflate() always flushes as much output as possible to the output buffer, and always uses the faster approach on the first call. So the only effect of the flush parameter in this implementation is on the return value of inflate(), as noted below, or when it returns early because Z_BLOCK or Z_TREES is used. If a preset dictionary is needed after this call (see inflateSetDictionary below), inflate sets strm->adler to the adler32 checksum of the dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described below. At the end of the stream, inflate() checks that its computed adler32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. inflate() can decompress and check either zlib-wrapped or gzip-wrapped deflate data. The header type is detected automatically, if requested when initializing with inflateInit2(). Any information contained in the gzip header is not retained, so applications that need that information should instead use raw inflate, see inflateInit2() below, or inflateBack() and perform their own processing of the gzip header and trailer. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect check value), Z_STREAM_ERROR if the stream structure was inconsistent (for example next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress is possible or if there was not enough room in the output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and inflate() can be called again with more input and more output space to continue decompressing. If Z_DATA_ERROR is returned, the application may then call inflateSync() to look for a good compression block if a partial recovery of the data is desired. */ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* Advanced functions */ /* The following functions are needed only in some special applications. */ /* ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy)); This is another version of deflateInit with more compression options. The fields next_in, zalloc, zfree and opaque must be initialized before by the caller. The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. The windowBits parameter is the base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. windowBits can also be -8..-15 for raw deflate. In this case, -windowBits determines the window size. deflate() will then generate raw deflate data with no zlib header or trailer, and will not compute an adler32 check value. windowBits can also be greater than 15 for optional gzip encoding. Add 16 to windowBits to write a simple gzip header and trailer around the compressed data instead of a zlib wrapper. The gzip header will have no file name, no extra data, no comment, no modification time (set to zero), no header crc, and the operating system will be set to 255 (unknown). If a gzip stream is being written, strm->adler is a crc32 instead of an adler32. The memLevel parameter specifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed. The default value is 8. See zconf.h for total memory usage as a function of windowBits and memLevel. The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no string match), or Z_RLE to limit match distances to one (run-length encoding). Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of Z_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit2 does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called immediately after deflateInit, deflateInit2 or deflateReset, before any call of deflate. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary. Depending on the size of the compression data structures selected by deflateInit or deflateInit2, a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size provided in deflateInit or deflateInit2. Thus the strings most likely to be useful should be put at the end of the dictionary, not at the front. In addition, the current implementation of deflate will use at most the window size minus 262 bytes of the provided dictionary. Upon return of this function, strm->adler is set to the adler32 value of the dictionary; the decompressor may later use this value to determine which dictionary has been used by the compressor. (The adler32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) If a raw deflate was requested, then the adler32 value is not computed and strm->adler is not set. deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent (for example if deflate has already been called for this stream or if the compression method is bsort). deflateSetDictionary does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source)); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input data with a filter. The streams that will be discarded should then be freed by calling deflateEnd. Note that deflateCopy duplicates the internal compression state which can be quite large, so this strategy is slow and can consume lots of memory. deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being Z_NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate all the internal compression state. The stream will keep the same compression level and any other attributes that may have been set by deflateInit2. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy)); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2. This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression level is changed, the input available so far is compressed with the old level (and may be flushed); the new level will take effect only at the next call of deflate(). Before the call of deflateParams, the stream state must be set as for a call of deflate(), since the currently available input may have to be compressed and flushed. In particular, strm->avail_out must be non-zero. deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if strm->avail_out was zero. */ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for searching for the best matching string, and even then only by the most fanatic optimizer trying to squeeze out the last compressed bit for their specific input data. Read the deflate.c source code for the meaning of the max_lazy, good_length, nice_length, and max_chain parameters. deflateTune() can be called after deflateInit() or deflateInit2(), and returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or deflateInit2(), and after deflateSetHeader(), if used. This would be used to allocate an output buffer for deflation in a single pass, and so would be called before deflate(). */ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value)); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits leftover from a previous deflate stream when appending to it. As such, this function can only be used for raw deflate, and must be used before the first deflate() call after a deflateInit2() or deflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the output. deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head)); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called after deflateInit2() or deflateReset() and before the first call of deflate(). The text, time, os, extra field, name, and comment information in the provided gz_header structure are written to the gzip header (xflag is ignored -- the extra flags are set according to the compression level). The caller must assure that, if not Z_NULL, name and comment are terminated with a zero byte, and that if extra is not Z_NULL, that extra_len bytes are available there. If hcrc is true, a gzip header crc is included. Note that the current versions of the command-line version of gzip (up through version 1.3.x) do not support header crc's, and will report that it is a "multi-part gzip file" and give up. If deflateSetHeader is not used, the default gzip header has text false, the time set to zero, and os set to 255, with no extra, name, or comment fields. The gzip header is returned to the default state by deflateReset(). deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, int windowBits)); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. The windowBits parameter is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. The default value is 15 if inflateInit is used instead. windowBits must be greater than or equal to the windowBits value provided to deflateInit2() while compressing, or it must be equal to 15 if deflateInit2() was not used. If a compressed stream with a larger window size is given as input, inflate() will return with the error code Z_DATA_ERROR instead of trying to allocate a larger window. windowBits can also be zero to request that inflate use the window size in the zlib header of the compressed stream. windowBits can also be -8..-15 for raw inflate. In this case, -windowBits determines the window size. inflate() will then process raw deflate data, not looking for a zlib or gzip header, not generating a check value, and not looking for any check values for comparison at the end of the stream. This is for use with other formats that use the deflate compressed data format such as zip. Those formats provide their own check values. If a custom format is developed using the raw deflate format for compressed data, it is recommended that a check value such as an adler32 or a crc32 be applied to the uncompressed data as is done in the zlib, gzip, and zip formats. For most applications, the zlib format should be used as is. Note that comments above on the use in deflateInit2() applies to the magnitude of windowBits. windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a crc32 instead of an adler32. inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller, or Z_STREAM_ERROR if the parameters are invalid, such as a null pointer to the structure. msg is set to null if there is no error message. inflateInit2 does not perform any decompression apart from possibly reading the zlib header if present: actual decompression will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unused and unchanged.) The current implementation of inflateInit2() does not process any header information -- that is deferred until inflate() is called. */ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, if that call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the adler32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). For raw inflate, this function can be called immediately after inflateInit2() or inflateReset() and before any call of inflate() to set the dictionary. The application must insure that the dictionary that was used for compression is provided. inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect adler32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate(). */ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); /* Skips invalid compressed data until a full flush point (see above the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. No output is provided. inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the success case, the application may save the current current value of total_in which indicates where valid compressed data was found. In the error case, the application may repeatedly call inflateSync, providing more input each time, until success or end of the input data. */ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, z_streamp source)); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when randomly accessing a large stream. The first pass through the stream can periodically record the inflate state, allowing restarting inflate at those points when randomly accessing the stream. inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being Z_NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate all the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, int windowBits)); /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted the same as it is for inflateInit2. inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL), or if the windowBits parameter is invalid. */ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value)); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the middle of a byte. The provided bits will be used before any bytes are used from next_in. This function should only be used with raw inflate, and should be used before the first inflate() call after inflateInit2() or inflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the input. If bits is negative, then the input stream bit buffer is emptied. Then inflatePrime() can be called again to put bits in the buffer. This is used to clear out bits leftover after feeding inflate a block description prior to feeding inflate codes. inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); /* This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the return value down 16 bits. If the upper value is -1 and the lower value is zero, then inflate() is currently decoding information outside of a block. If the upper value is -1 and the lower value is non-zero, then inflate is in the middle of a stored block, with the lower value equaling the number of bytes from the input remaining to copy. If the upper value is not -1, then it is the number of bits back from the current bit position in the input of the code (literal or length/distance pair) currently being processed. In that case the lower value is the number of bytes already emitted for that code. A code is being processed if inflate is waiting for more input to complete decoding of the code, or if it has completed decoding but is waiting for more output space to write the literal or match data. inflateMark() is used to mark locations in the input data for random access, which may be at bit positions, and to note those cases where the output of a code may span boundaries of random access blocks. The current location in the input stream can be determined from avail_in and data_type as noted in the description for the Z_BLOCK flush parameter for inflate. inflateMark returns the value noted above or -1 << 16 if the provided source stream state was inconsistent. */ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head)); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after inflateInit2() or inflateReset(), and before the first call of inflate(). As inflate() processes the gzip stream, head->done is zero until the header is completed, at which time head->done is set to one. If a zlib stream is being decoded, then head->done is set to -1 to indicate that there will be no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be used to force inflate() to return immediately after header processing is complete and before any actual data is decompressed. The text, time, xflags, and os fields are filled in with the gzip header contents. hcrc is set to true if there is a header CRC. (The header CRC was valid if done is set to one.) If extra is not Z_NULL, then extra_max contains the maximum number of bytes to write to extra. Once done is true, extra_len contains the actual extra field length, and extra contains the extra field, or that field truncated if extra_max is less than extra_len. If name is not Z_NULL, then up to name_max characters are written there, terminated with a zero unless the length is greater than name_max. If comment is not Z_NULL, then up to comm_max characters are written there, terminated with a zero unless the length is greater than comm_max. When any of extra, name, or comment are not Z_NULL and the respective field is not present in the header, then that field is set to Z_NULL to signal its absence. This allows the use of deflateSetHeader() with the returned structure to duplicate the header. However if those fields are set to allocated memory, then the application will need to save those pointers elsewhere so that they can be eventually freed. If inflateGetHeader is not used, then the header information is simply discarded. The header is always checked for validity, including the header CRC if present. inflateReset() will reset the process to discard the header information. The application would need to call inflateGetHeader() again to retrieve the header from the next gzip stream. inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, unsigned char FAR *window)); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized before the call. If zalloc and zfree are Z_NULL, then the default library- derived memory allocation routines are used. windowBits is the base two logarithm of the window size, in the range 8..15. window is a caller supplied buffer of that size. Except for special applications where it is assured that deflate was used with small window sizes, windowBits must be 15 and a 32K byte window must be supplied to be able to decompress general deflate streams. See inflateBack() for the usage of these routines. inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of the paramaters are invalid, Z_MEM_ERROR if the internal state could not be allocated, or Z_VERSION_ERROR if the version of the library does not match the version of the header file. */ typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is more efficient than inflate() for file i/o applications in that it avoids copying between the output and the sliding window by simply making the window itself the output buffer. This function trusts the application to not change the output buffer passed by the output function, at least until inflateBack() returns. inflateBackInit() must be called first to allocate the internal state and to initialize the state with the user-provided window buffer. inflateBack() may then be used multiple times to inflate a complete, raw deflate stream with each call. inflateBackEnd() is then called to free the allocated state. A raw deflate stream is one with no zlib or gzip header or trailer. This routine would normally be used in a utility that reads zip or gzip files and writes out uncompressed files. The utility would decode the header and process the trailer on its own, hence this routine expects only the raw deflate stream to decompress. This is different from the normal behavior of inflate(), which expects either a zlib or gzip header and trailer around the deflate stream. inflateBack() uses two subroutines supplied by the caller that are then called by inflateBack() for input and output. inflateBack() calls those routines until it reads a complete deflate stream and writes out all of the uncompressed data, or until it encounters an error. The function's parameters and return types are defined above in the in_func and out_func typedefs. inflateBack() will call in(in_desc, &buf) which should return the number of bytes of provided input, and a pointer to that input in buf. If there is no input available, in() must return zero--buf is ignored in that case--and inflateBack() will return a buffer error. inflateBack() will call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() should return zero on success, or non-zero on failure. If out() returns non-zero, inflateBack() will return with an error. Neither in() nor out() are permitted to change the contents of the window provided to inflateBackInit(), which is also the buffer that out() uses to write from. The length written by out() will be at most the window size. Any non-zero amount of input may be provided by in(). For convenience, inflateBack() can be provided input on the first call by setting strm->next_in and strm->avail_in. If that input is exhausted, then in() will be called. Therefore strm->next_in must be initialized before calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in must also be initialized, and then if strm->avail_in is not zero, input will initially be taken from strm->next_in[0 .. strm->avail_in - 1]. The in_desc and out_desc parameters of inflateBack() is passed as the first parameter of in() and out() respectively when they are called. These descriptors can be optionally used to pass any information that the caller- supplied in() and out() functions need to do their job. On return, inflateBack() will set strm->next_in and strm->avail_in to pass back any unused input that was provided by the last in() call. The return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR if in() or out() returned an error, Z_DATA_ERROR if there was a format error in the deflate stream (in which case strm->msg is set to indicate the nature of the error), or Z_STREAM_ERROR if the stream was not properly initialized. In the case of Z_BUF_ERROR, an input or output error can be distinguished using strm->next_in which will be Z_NULL only if in() returned an error. If strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning non-zero. (in() will always be called before out(), so strm->next_in is assured to be defined if out() returns non-zero.) Note that inflateBack() cannot return Z_OK. */ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); /* All memory allocated by inflateBackInit() is freed. inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream state was inconsistent. */ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: 1.0: size of uInt 3.2: size of uLong 5.4: size of voidpf (pointer) 7.6: size of z_off_t Compiler, assembler, and debug options: 8: DEBUG 9: ASMV or ASMINF -- use ASM code 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention 11: 0 (reserved) One-time table building (smaller code, but not thread-safe if true): 12: BUILDFIXED -- build static block decoding tables when needed 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 14,15: 0 (reserved) Library content (indicates missing functionality): 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking deflate code when not needed) 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect and decode gzip streams (to avoid linking crc code) 18-19: 0 (reserved) Operation variations (changes in library functionality): 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate 21: FASTEST -- deflate algorithm with only one, lowest compression level 22,23: 0 (reserved) The sprintf variant used by gzprintf (zero is best): 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! 26: 0 = returns value, 1 = void -- 1 means inferred string length returned Remainder: 27-31: 0 (reserved) */ /* utility functions */ /* The following utility functions are implemented on top of the basic stream-oriented functions. To simplify the interface, some default options are assumed (compression level and memory usage, standard memory allocation functions). The source code of these utility functions can be modified if you need special options. */ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer. */ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the uncompressed buffer. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. */ /* gzip file access functions */ /* This library supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio, using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. */ typedef voidp gzFile; /* opaque gzip file descriptor */ /* ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression as in "wb9F". (See the description of deflateInit2 for more information about the strategy parameter.) Also "a" can be used instead of "w" to request that the gzip stream that will be written be appended to the file. "+" will result in an error, since reading and writing to the same gzip file is not supported. gzopen can be used to read a file which is not in gzip format; in this case gzread will directly read from the file without decompression. gzopen returns NULL if the file could not be opened, if there was insufficient memory to allocate the gzFile state, or if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). errno can be checked to determine if the reason gzopen failed was that the file could not be opened. */ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); /* gzdopen associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (if the file has been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, mode);. The duplicated descriptor should be saved to avoid a leak, since gzdopen does not close fd if it fails. gzdopen returns NULL if there was insufficient memory to allocate the gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided), or if fd is -1. The file descriptor is not used until the next gz* read, write, seek, or close operation, so gzdopen will not detect if fd is invalid (unless fd is -1). */ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); /* Set the internal buffer size used by this library's functions. The default buffer size is 8192 bytes. This function must be called after gzopen() or gzdopen(), and before any other calls that read or write the file. The buffer memory allocation is always deferred to the first read or write. Two buffers are allocated, either both of the specified size when writing, or one of the specified size and the other twice that size when reading. A larger buffer size of, for example, 64K or 128K bytes will noticeably increase the speed of decompression (reading). The new buffer size also affects the maximum length for gzprintf(). gzbuffer() returns 0 on success, or -1 on failure, such as being called too late. */ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); /* Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not opened for writing. */ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); /* Reads the given number of uncompressed bytes from the compressed file. If the input file was not in gzip format, gzread copies the given number of bytes into the buffer. After reaching the end of a gzip stream in the input, gzread will continue to read, looking for another gzip stream, or failing that, reading the rest of the input file directly without decompression. The entire input file will be read if gzread is called until it returns less than the requested len. gzread returns the number of uncompressed bytes actually read, less than len for end of file, or -1 for error. */ ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes written or 0 in case of error. */ ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); /* Converts, formats, and writes the arguments to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of uncompressed bytes actually written, or 0 in case of error. The number of uncompressed bytes written is limited to 8191, or one less than the buffer size given to gzbuffer(). The caller should assure that this limit is not exceeded. If it is exceeded, then gzprintf() will return an error (0) with nothing written. In this case, there may also be a buffer overflow with unpredictable consequences, which is possible only if zlib was compiled with the insecure functions sprintf() or vsprintf() because the secure snprintf() or vsnprintf() functions were not available. This can be determined using zlibCompileFlags(). */ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); /* Writes the given null-terminated string to the compressed file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); /* Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file condition is encountered. If any characters are read or if len == 1, the string is terminated with a null character. If no characters are read due to an end-of-file or len < 1, then the buffer is left untouched. gzgets returns buf which is a null-terminated string, or it returns NULL for end-of-file or in case of error. If there was an error, the contents at buf are indeterminate. */ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); /* Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); /* Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. */ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); /* Push one character back onto the stream to be read as the first character on the next read. At least one character of push-back is allowed. gzungetc() returns the character pushed, or -1 on failure. gzungetc() will fail if c is -1, and may fail if a character has been pushed but not read yet. If gzungetc is used immediately after gzopen or gzdopen, at least the output buffer size of pushed characters is allowed. (See gzbuffer above.) The pushed character will be discarded if the stream is repositioned with gzseek() or gzrewind(). */ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); /* Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function gzerror below). gzflush is only permitted when writing. If the flush parameter is Z_FINISH, the remaining data is written and the gzip stream is completed in the output. If gzwrite() is called again, a new gzip stream will be started in the output. gzread() is able to read such concatented gzip streams. gzflush should be called only when strictly necessary because it will degrade compression if called too often. */ /* ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, z_off_t offset, int whence)); Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes up to the new starting position. gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position. */ ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); /* Rewinds the given file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ /* ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the uncompressed data stream, and is zero when starting, even if appending or reading a gzip stream from the middle of a file using gzdopen(). gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ /* ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); Returns the current offset in the file being read or written. This offset includes the count of bytes that precede the gzip stream, for example when appending or when using gzdopen() for reading. When reading, the offset does not include as yet unused buffered input. This information can be used for a progress indicator. On error, gzoffset() returns -1. */ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); /* Returns true (1) if the end-of-file indicator has been set while reading, false (0) otherwise. Note that the end-of-file indicator is set only if the read tried to go past the end of the input, but came up short. Therefore, just like feof(), gzeof() may return false even if there is no more data to read, in the event that the last read request was for the exact number of bytes remaining in the input file. This will happen if the input file size is an exact multiple of the buffer size. If gzeof() returns true, then the read functions will return no more data, unless the end-of-file indicator is reset by gzclearerr() and the input file has grown since the previous end of file was detected. */ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); /* Returns true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. This state can change from false to true while reading the input file if the end of a gzip stream is reached, but is followed by data that is not another gzip stream. If the input file is empty, gzdirect() will return true, since the input does not contain a gzip stream. If gzdirect() is used immediately after gzopen() or gzdopen() it will cause buffers to be allocated to allow reading the file to determine if it is a gzip file. Therefore if gzbuffer() is used, it should be called before gzdirect(). */ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); /* Flushes all pending output if necessary, closes the compressed file and deallocates the (de)compression state. Note that once file is closed, you cannot call gzerror with file, since its structures have been deallocated. gzclose must not be called more than once on the same file, just as free must not be called more than once on the same allocation. gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a file operation error, or Z_OK on success. */ ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); /* Same as gzclose(), but gzclose_r() is only for use when reading, and gzclose_w() is only for use when writing or appending. The advantage to using these instead of gzclose() is that they avoid linking in zlib compression or decompression code that is not used when only reading or only writing respectively. If gzclose() is used, then both compression and decompression code will be included the application when linking to a static zlib library. */ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); /* Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an error occurred in the file system and not in the compression library, errnum is set to Z_ERRNO and the application may consult errno to get the exact error code. The application must not modify the returned string. Future calls to this function may invalidate the previously returned string. If file is closed, then the string previously returned by gzerror will no longer be available. gzerror() should be used to distinguish errors from end-of-file for those functions above that do not distinguish those cases in their return values. */ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); /* Clears the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip file that is being written concurrently. */ /* checksum functions */ /* These functions are not related to compression but are exported anyway because they might be useful in applications using the compression library. */ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is Z_NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much faster. Usage example: uLong adler = adler32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { adler = adler32(adler, buffer, length); } if (adler != original_adler) error(); */ /* ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, z_off_t len2)); Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. */ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is Z_NULL, this function returns the required initial value for the for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application. Usage example: uLong crc = crc32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { crc = crc32(crc, buffer, length); } if (crc != original_crc) error(); */ /* ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and len2. */ /* various hacks, don't look :) */ /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size)); ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)); #define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) #define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, sizeof(z_stream)) /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if * both are true, the application gets the *64 functions, and the regular * functions are changed to 64 bits) -- in case these are set on systems * without large file support, _LFS64_LARGEFILE must also be true */ #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); #endif #if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 # define gzopen gzopen64 # define gzseek gzseek64 # define gztell gztell64 # define gzoffset gzoffset64 # define adler32_combine adler32_combine64 # define crc32_combine crc32_combine64 # ifdef _LARGEFILE64_SOURCE ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); # endif #else ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); #endif /* hack for buggy compilers */ #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; #endif /* undocumented functions */ ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); #ifdef __cplusplus } #endif #endif /* ZLIB_H */ ================================================ FILE: cocos2d/licenses/LICENSE_CCBReader.txt ================================================ CocosBuilder Reader: http://www.cocosbuilder.com Copyright (c) 2010-2011 - Viktor Lidholt Copyright (c) 2011-2012 - Zynga Inc. and contributors (see each file to see the different copyright owners) 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. ================================================ FILE: cocos2d/licenses/LICENSE_CCControlExtension.txt ================================================ /* * * Copyright 2012 Yannick Loriot. * http://yannickloriot.com * * 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. * */ ================================================ FILE: cocos2d/licenses/LICENSE_JSON4Lua.txt ================================================ The MIT License Copyright (c) 2009 Craig Mason-Jones 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 ================================================ FILE: cocos2d/licenses/LICENSE_Kazmath.txt ================================================ Kazmath is a 3D math library aimed at game programming. It is released under the modified BSD license. Authors Luke Benstead Carsten Haubold License Copyright (c) 2008, Luke Benstead. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. ================================================ FILE: cocos2d/licenses/LICENSE_SpiderMonkey.txt ================================================ SpiderMonkey is Mozilla's JavaScript engine written in C/C++. It is used in various Mozilla products, including Firefox, and is available under MPL/GPL/LGPL tri-license. (from https://developer.mozilla.org/en/SpiderMonkey) -------- Please see the file toolkit/content/license.html for the copyright licensing conditions attached to this codebase, including copies of the licenses concerned. You are not granted rights or licenses to the trademarks of the Mozilla Foundation or any party, including without limitation the Firefox name or logo. For more information, see: http://www.mozilla.org/foundation/licensing.html ================================================ FILE: cocos2d/licenses/LICENSE_artwork.txt ================================================ GROSSINI AND FRIENDS -------------------- Resources/Images/grossini*.png From: http://www.stortroopers.com/ LICENSE: Attribution-NonCommercial-ShareAlike 2.0 SPRITE SHEETS ------------- Resoruces/Images/spritesheet* LICENSE: unsure... don't use them in your project. TILES & TILEMAP: ---------------- 'Barbie Seahorse' tiles: Resources/Images/tiles.png Resources/Images/levelmap.tga Resources/Images/background.png From 'Barbie Seahorse' game: http://www.imitationpickles.org/barbie/ LICENSE: GNU GPL v2 'Hex tiles' Resources/Images/tilemap/hexa-tiles.png From 'Pioneers' game: http://pio.sourceforge.net/ LICENSE: GNU GPL v2 'Planet Cute' tiles: Resources/Images/tilemap/ortho-test1.png From Lost Garden: http://lostgarden.com/2007/05/dancs-miraculously-flexible-game.html LICENSE: http://lostgarden.com/2007/03/lost-garden-license.html 'Spritelib GPL': Resources/Images/tilemap/fixed-ortho-test2.png Resources/Images/tilemap/ortho-test2.png From 'SpriteLib GPL': http://www.flyingyogi.com/fun/spritelib.html LICENSE: Common Public License http://www.opensource.org/licenses/cpl.php 'Tiled examples': Resources/Images/tilemap/iso_test.png Resources/Images/tilemap/iso_test2.png Resources/Images/tilemap/tmw_desert_spacing.png From 'Tiled' editor. http://www.mapeditor.og LICENSE: GNU GPL v2 FONTS: ------ TTF fonts: Resources/Fonts/*.ttf From: http://www.webpagepublicity.com/free-fonts.html LICENSE: For personal Use. SpriteSheet fonts: Resources/Images/tuffy_bold_italic-charmap.png From: http://tulrich.com/fonts/ LICENSE: Public Domain ================================================ FILE: cocos2d/licenses/LICENSE_box2d.txt ================================================ Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ================================================ FILE: cocos2d/licenses/LICENSE_chipmunk.txt ================================================ Copyright (c) 2007 Scott Lembcke and Howling Moon Software 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. ================================================ FILE: cocos2d/licenses/LICENSE_cocos2d-iphone.txt ================================================ cocos2d for iPhone: http://www.cocos2d-iphone.org Copyright (c) 2011 - Zynga Inc. and contributors (see each file to see the different copyright owners) 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. ================================================ FILE: cocos2d/licenses/LICENSE_cocos2d-x.txt ================================================ cocos2d-x http://www.cocos2d-x.org Copyright (c) 2010-2011 - cocos2d-x community (see each file to see the different copyright owners) 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. ================================================ FILE: cocos2d/licenses/LICENSE_cocosdenshion.txt ================================================ CocosDenshion Sound Engine Copyright (c) 2010 Steve Oldmeadow 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. ================================================ FILE: cocos2d/licenses/LICENSE_curl.txt ================================================ COPYRIGHT AND PERMISSION NOTICE Copyright (c) 1996 - 2011, Daniel Stenberg, . All rights reserved. Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 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 OF THIRD PARTY RIGHTS. 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. Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. ================================================ FILE: cocos2d/licenses/LICENSE_js.txt ================================================ cocos2d-x-js http://www.cocos2d-x.org Copyright (c) 2010-2011 - cocos2d-x community (see each file to see the different copyright owners) 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. ================================================ FILE: cocos2d/licenses/LICENSE_jsoncpp.txt ================================================ The JsonCpp library's source code, including accompanying documentation, tests and demonstration applications, are licensed under the following conditions... The author (Baptiste Lepilleur) explicitly disclaims copyright in all jurisdictions which recognize such a disclaimer. In such jurisdictions, this software is released into the Public Domain. In jurisdictions which do not recognize Public Domain property (e.g. Germany as of 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is released under the terms of the MIT License (see below). In jurisdictions which recognize Public Domain property, the user of this software may choose to accept it either as 1) Public Domain, 2) under the conditions of the MIT License (see below), or 3) under the terms of dual Public Domain/MIT License conditions described here, as they choose. The MIT License is about as close to Public Domain as a license can get, and is described in clear, concise terms at: http://en.wikipedia.org/wiki/MIT_License The full text of the MIT License follows: ======================================================================== Copyright (c) 2007-2010 Baptiste Lepilleur 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. ======================================================================== (END LICENSE TEXT) The MIT license is compatible with both the GPL and commercial software, affording one all of the rights of Public Domain with the minor nuisance of being required to keep the above copyright notice and license text in the source code. Note also that by accepting the Public Domain "license" you can re-license your copy using whatever license you like. ================================================ FILE: cocos2d/licenses/LICENSE_libjpeg.txt ================================================ LEGAL ISSUES ============ In plain English: 1. We don't promise that this software works. (But if you find any bugs, please let us know!) 2. You can use this software for whatever you want. You don't have to pay us. 3. You may not pretend that you wrote this software. If you use it in a program, you must acknowledge somewhere in your documentation that you've used the IJG code. In legalese: The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy. This software is copyright (C) 1991-2011, Thomas G. Lane, Guido Vollbeding. All Rights Reserved except as specified below. Permission is hereby granted to use, copy, modify, and distribute this software (or portions thereof) for any purpose, without fee, subject to these conditions: (1) If any part of the source code for this software is distributed, then this README file must be included, with this copyright and no-warranty notice unaltered; and any additions, deletions, or changes to the original files must be clearly indicated in accompanying documentation. (2) If only executable code is distributed, then the accompanying documentation must state that "this software is based in part on the work of the Independent JPEG Group". (3) Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind. These conditions apply to any software derived from or based on the IJG code, not just to the unmodified library. If you use our work, you ought to acknowledge us. Permission is NOT granted for the use of any IJG author's name or company name in advertising or publicity relating to this software or products derived from it. This software may be referred to only as "the Independent JPEG Group's software". We specifically permit and encourage the use of this software as the basis of commercial products, provided that all warranty or liability claims are assumed by the product vendor. ================================================ FILE: cocos2d/licenses/LICENSE_libpng.txt ================================================ This copy of the libpng notices is provided for your convenience. In case of any discrepancy between this copy and the notices in the file png.h that is included in the libpng distribution, the latter shall prevail. COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: If you modify libpng you may insert additional notices immediately following this sentence. This code is released under the libpng license. libpng versions 1.2.6, August 15, 2004, through 1.2.38, July 16, 2009, are Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors Cosmin Truta libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.0.6 with the following individuals added to the list of Contributing Authors Simon-Pierre Cadieux Eric S. Raymond Gilles Vollant and with the following additions to the disclaimer: There is no warranty against interference with your enjoyment of the library or against infringement. There is no warranty that our efforts or the library will fulfill any of your particular purposes or needs. This library is provided with all faults, and the entire risk of satisfactory quality, performance, accuracy, and effort is with the user. libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-0.96, with the following individuals added to the list of Contributing Authors: Tom Lane Glenn Randers-Pehrson Willem van Schaik libpng versions 0.89, June 1996, through 0.96, May 1997, are Copyright (c) 1996, 1997 Andreas Dilger Distributed according to the same disclaimer and license as libpng-0.88, with the following individuals added to the list of Contributing Authors: John Bowler Kevin Bracey Sam Bushell Magnus Holmgren Greg Roelofs Tom Tanner libpng versions 0.5, May 1995, through 0.88, January 1996, are Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. For the purposes of this copyright and license, "Contributing Authors" is defined as the following set of individuals: Andreas Dilger Dave Martindale Guy Eric Schalnat Paul Schmidt Tim Wegner The PNG Reference Library is supplied "AS IS". The Contributing Authors and Group 42, Inc. disclaim all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. The Contributing Authors and Group 42, Inc. assume no liability for direct, indirect, incidental, special, exemplary, or consequential damages, which may result from the use of the PNG Reference Library, even if advised of the possibility of such damage. Permission is hereby granted to use, copy, modify, and distribute this source code, or portions hereof, for any purpose, without fee, subject to the following restrictions: 1. The origin of this source code must not be misrepresented. 2. Altered versions must be plainly marked as such and must not be misrepresented as being the original source. 3. This Copyright notice may not be removed or altered from any source or altered source distribution. The Contributing Authors and Group 42, Inc. specifically permit, without fee, and encourage the use of this source code as a component to supporting the PNG file format in commercial products. If you use this source code in a product, acknowledgment is not required but would be appreciated. A "png_get_copyright" function is available, for convenient use in "about" boxes and the like: printf("%s",png_get_copyright(NULL)); Also, the PNG logo (in PNG format, of course) is supplied in the files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net July 16, 2009 ================================================ FILE: cocos2d/licenses/LICENSE_libtiff.txt ================================================ Copyright (c) 1988-1997 Sam Leffler Copyright (c) 1991-1997 Silicon Graphics, Inc. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) the above copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of Sam Leffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permission of Sam Leffler and Silicon Graphics. THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ================================================ FILE: cocos2d/licenses/LICENSE_libwebsockets.txt ================================================ Libwebsockets and included programs are provided under the terms of the GNU Library General Public License (LGPL) 2.1, with the following exceptions: 1) Static linking of programs with the libwebsockets library does not constitute a derivative work and does not require the author to provide source code for the program, use the shared libwebsockets libraries, or link their program against a user-supplied version of libwebsockets. If you link the program to a modified version of libwebsockets, then the changes to libwebsockets must be provided under the terms of the LGPL in sections 1, 2, and 4. 2) You do not have to provide a copy of the libwebsockets license with programs that are linked to the libwebsockets library, nor do you have to identify the libwebsockets license in your program or documentation as required by section 6 of the LGPL. However, programs must still identify their use of libwebsockets. The following example statement can be included in user documentation to satisfy this requirement: "[program] is based in part on the work of the libwebsockets project (http://libwebsockets.org)" GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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; either version 2.1 of the License, or (at your option) any later version. 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 Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! ================================================ FILE: cocos2d/licenses/LICENSE_libxml2.txt ================================================ Except where otherwise noted in the source code (e.g. the files hash.c, list.c and the trio files, which are covered by a similar licence but with different Copyright notices) all the files are: Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. 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 fur- nished 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, FIT- NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of Daniel Veillard shall not be used in advertising or otherwise to promote the sale, use or other deal- ings in this Software without prior written authorization from him. ================================================ FILE: cocos2d/licenses/LICENSE_lua.txt ================================================ License for Lua 5.0 and later versions http://www.lua.org/license.html Copyright 19942011 Lua.org, PUC-Rio. 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. ================================================ FILE: cocos2d/licenses/LICENSE_ogg_vorbis.txt ================================================ Copyright (c) 2002-2008 Xiph.org Foundation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 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. - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``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 FOUNDATION OR CONTRIBUTORS 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. ================================================ FILE: cocos2d/licenses/LICENSE_tolua++.txt ================================================ tolua++ License --------------- tolua++ is based on toLua (www.tecgraf.puc-rio.br/~celes/tolua), and it's licensed under the terms of the MIT license reproduced below. This means that Lua is free software and can be used for both academic and commercial purposes at absolutely no cost. =============================================================================== Copyright (C) 2009 Ariel Manzur. 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. =============================================================================== (end of COPYRIGHT) ================================================ FILE: cocos2d/licenses/LICENSE_zlib.txt ================================================ Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler ================================================ FILE: cocos2d/plugin/.gitignore ================================================ # Ignore thumbnails created by windows Thumbs.db # Ignore files build by Visual Studio *.obj *.exe *.pdb *.aps *.vcproj.*.user *.vspscc *_i.c *.i *.icf *_p.c *.ncb *.suo *.tlb *.tlh *.bak *.cache *.ilk *.log [Bb]in [Dd]ebug*/ *.sbr *.sdf obj/ [Rr]elease*/ _ReSharper*/ [Tt]est[Rr]esult* ipch/ *.opensdf # Ignore files build by ndk and eclipse libs/ bin/ obj/ gen/ assets/ local.properties # Ignore files built by NaCl samples/Cpp/HelloCpp/proj.nacl/Resources/ samples/Cpp/TestCpp/proj.nacl/Resources/ samples/Cpp/TestCpp/proj.nacl/out/ samples/Cpp/SimpleGame/proj.nacl/Resources/ samples/Lua/HelloLua/proj.nacl/Resources/ samples/Lua/TestLua/proj.nacl/Resources/ # Ignore python compiled files *.pyc # Ignore files build by airplay and marmalade build_*_xcode/ build_*_vc10/ # Ignore files build by xcode *.mode*v* *.pbxuser *.xcbkptlist *.xcscheme *.xcworkspacedata *.xcuserstate xcschememanagement.plist build/ .DS_Store ._.* xcuserdata/ DerivedData/ # Ignore files built by bada .Simulator-Debug/ .Target-Debug/ .Target-Release/ # Ignore files built by blackberry Simulator/ Device-Debug/ Device-Release/ # Ignore vim swaps *.swp # Ignore config files in javascript bindings generator tools/tojs/user.cfg # ... userconf.ini generated if running from tools/tojs tools/tojs/userconf.ini # ... userconf.ini generated if running from tools/jenkins_scripts/mac/android/ tools/jenkins_scripts/mac/android/userconf.ini # Ignore files built by plugin publish/* tools/toolsForPublish/environment.sh .settings plugins/china* plugins/punchbox* plugins/touchpay* samplesPrivate* ================================================ FILE: cocos2d/plugin/README.md ================================================ plugin-x ======== ================================================ FILE: cocos2d/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.cpp ================================================ #include "jsb_pluginx_protocols_auto.hpp" #include "jsb_pluginx_spidermonkey_specifics.h" #include "jsb_pluginx_basic_conversions.h" using namespace pluginx; #include "PluginManager.h" #include "ProtocolAnalytics.h" #include "ProtocolIAP.h" #include "ProtocolAds.h" #include "ProtocolShare.h" #include "ProtocolSocial.h" #include "ProtocolUser.h" template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedValue initializing(cx); JSBool isNewValid = JS_TRUE; if (isNewValid) { TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JSObject *_tmp = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); T* cobj = new T(); js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); JS_AddObjectRoot(cx, &pp->obj); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(_tmp)); return JS_TRUE; } return JS_FALSE; } static JSBool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { return JS_FALSE; } JSClass *jsb_cocos2d_plugin_PluginProtocol_class; JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; JSBool js_pluginx_protocols_PluginProtocol_getPluginName(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_PluginProtocol_getPluginName : Invalid Native Object"); if (argc == 0) { const char* ret = cobj->getPluginName(); jsval jsret; jsret = c_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_PluginProtocol_getPluginName : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_PluginProtocol_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_PluginProtocol_getPluginVersion : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getPluginVersion(); jsval jsret; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_PluginProtocol_getPluginVersion : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_PluginProtocol_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_PluginProtocol_getSDKVersion : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getSDKVersion(); jsval jsret; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_PluginProtocol_getSDKVersion : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_PluginProtocol_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_PluginProtocol_setDebugMode : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_PluginProtocol_setDebugMode : Error processing arguments"); cobj->setDebugMode(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_PluginProtocol_setDebugMode : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } void js_cocos2d_plugin_PluginProtocol_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PluginProtocol)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); // cocos2d::plugin::PluginProtocol *nobj = static_cast(nproxy->ptr); // if (nobj) // delete nobj; jsb_remove_proxy(nproxy, jsproxy); } } void js_register_pluginx_protocols_PluginProtocol(JSContext *cx, JSObject *global) { jsb_cocos2d_plugin_PluginProtocol_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_plugin_PluginProtocol_class->name = "PluginProtocol"; jsb_cocos2d_plugin_PluginProtocol_class->addProperty = JS_PropertyStub; jsb_cocos2d_plugin_PluginProtocol_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_plugin_PluginProtocol_class->getProperty = JS_PropertyStub; jsb_cocos2d_plugin_PluginProtocol_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_plugin_PluginProtocol_class->enumerate = JS_EnumerateStub; jsb_cocos2d_plugin_PluginProtocol_class->resolve = JS_ResolveStub; jsb_cocos2d_plugin_PluginProtocol_class->convert = JS_ConvertStub; jsb_cocos2d_plugin_PluginProtocol_class->finalize = js_cocos2d_plugin_PluginProtocol_finalize; jsb_cocos2d_plugin_PluginProtocol_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("getPluginName", js_pluginx_protocols_PluginProtocol_getPluginName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPluginVersion", js_pluginx_protocols_PluginProtocol_getPluginVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSDKVersion", js_pluginx_protocols_PluginProtocol_getSDKVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDebugMode", js_pluginx_protocols_PluginProtocol_setDebugMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_plugin_PluginProtocol_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_plugin_PluginProtocol_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "PluginProtocol", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_plugin_PluginProtocol_class; p->proto = jsb_cocos2d_plugin_PluginProtocol_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_plugin_PluginManager_class; JSObject *jsb_cocos2d_plugin_PluginManager_prototype; JSBool js_pluginx_protocols_PluginManager_unloadPlugin(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::PluginManager* cobj = (cocos2d::plugin::PluginManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_PluginManager_unloadPlugin : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_PluginManager_unloadPlugin : Error processing arguments"); cobj->unloadPlugin(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_PluginManager_unloadPlugin : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_PluginManager_loadPlugin(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::PluginManager* cobj = (cocos2d::plugin::PluginManager *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_PluginManager_loadPlugin : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_PluginManager_loadPlugin : Error processing arguments"); cocos2d::plugin::PluginProtocol* ret = cobj->loadPlugin(arg0); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_PluginManager_loadPlugin : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_PluginManager_end(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::plugin::PluginManager::end(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_PluginManager_end : wrong number of arguments"); return JS_FALSE; } JSBool js_pluginx_protocols_PluginManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { cocos2d::plugin::PluginManager* ret = cocos2d::plugin::PluginManager::getInstance(); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_PluginManager_getInstance : wrong number of arguments"); return JS_FALSE; } void js_cocos2d_plugin_PluginManager_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PluginManager)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); // cocos2d::plugin::PluginManager *nobj = static_cast(nproxy->ptr); // if (nobj) // delete nobj; jsb_remove_proxy(nproxy, jsproxy); } } void js_register_pluginx_protocols_PluginManager(JSContext *cx, JSObject *global) { jsb_cocos2d_plugin_PluginManager_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_plugin_PluginManager_class->name = "PluginManager"; jsb_cocos2d_plugin_PluginManager_class->addProperty = JS_PropertyStub; jsb_cocos2d_plugin_PluginManager_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_plugin_PluginManager_class->getProperty = JS_PropertyStub; jsb_cocos2d_plugin_PluginManager_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_plugin_PluginManager_class->enumerate = JS_EnumerateStub; jsb_cocos2d_plugin_PluginManager_class->resolve = JS_ResolveStub; jsb_cocos2d_plugin_PluginManager_class->convert = JS_ConvertStub; jsb_cocos2d_plugin_PluginManager_class->finalize = js_cocos2d_plugin_PluginManager_finalize; jsb_cocos2d_plugin_PluginManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("unloadPlugin", js_pluginx_protocols_PluginManager_unloadPlugin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadPlugin", js_pluginx_protocols_PluginManager_loadPlugin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { JS_FN("end", js_pluginx_protocols_PluginManager_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getInstance", js_pluginx_protocols_PluginManager_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; jsb_cocos2d_plugin_PluginManager_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_cocos2d_plugin_PluginManager_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "PluginManager", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_plugin_PluginManager_class; p->proto = jsb_cocos2d_plugin_PluginManager_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_plugin_ProtocolAnalytics_class; JSObject *jsb_cocos2d_plugin_ProtocolAnalytics_prototype; JSBool js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin : Error processing arguments"); cobj->logTimedEventBegin(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAnalytics_logError(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logError : Invalid Native Object"); if (argc == 2) { const char* arg0; const char* arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logError : Error processing arguments"); cobj->logError(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_logError : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException : Invalid Native Object"); if (argc == 1) { JSBool arg0; ok &= JS_ValueToBoolean(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException : Error processing arguments"); cobj->setCaptureUncaughtException(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis : Invalid Native Object"); if (argc == 1) { long arg0; ok &= jsval_to_long(cx, argv[0], (long *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis : Error processing arguments"); cobj->setSessionContinueMillis(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAnalytics_logEvent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logEvent : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logEvent : Error processing arguments"); cobj->logEvent(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { const char* arg0; cocos2d::plugin::LogEventParamMap* arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); LogEventParamMap arg1_tmp; do { ok &= jsval_to_LogEventParamMap(cx, argv[1], &arg1); if (ok) { arg1_tmp = *arg1; delete arg1; arg1 = &arg1_tmp; } else { arg1 = NULL; } } while(0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logEvent : Error processing arguments"); cobj->logEvent(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_logEvent : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAnalytics_startSession(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_startSession : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_startSession : Error processing arguments"); cobj->startSession(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_startSession : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAnalytics_stopSession(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_stopSession : Invalid Native Object"); if (argc == 0) { cobj->stopSession(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_stopSession : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAnalytics* cobj = (cocos2d::plugin::ProtocolAnalytics *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd : Error processing arguments"); cobj->logTimedEventEnd(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; void js_cocos2d_plugin_ProtocolAnalytics_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolAnalytics)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); // cocos2d::plugin::ProtocolAnalytics *nobj = static_cast(nproxy->ptr); // if (nobj) // delete nobj; jsb_remove_proxy(nproxy, jsproxy); } } void js_register_pluginx_protocols_ProtocolAnalytics(JSContext *cx, JSObject *global) { jsb_cocos2d_plugin_ProtocolAnalytics_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_plugin_ProtocolAnalytics_class->name = "ProtocolAnalytics"; jsb_cocos2d_plugin_ProtocolAnalytics_class->addProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolAnalytics_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_plugin_ProtocolAnalytics_class->getProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolAnalytics_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_plugin_ProtocolAnalytics_class->enumerate = JS_EnumerateStub; jsb_cocos2d_plugin_ProtocolAnalytics_class->resolve = JS_ResolveStub; jsb_cocos2d_plugin_ProtocolAnalytics_class->convert = JS_ConvertStub; jsb_cocos2d_plugin_ProtocolAnalytics_class->finalize = js_cocos2d_plugin_ProtocolAnalytics_finalize; jsb_cocos2d_plugin_ProtocolAnalytics_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); JSPropertySpec *properties = NULL; static JSFunctionSpec funcs[] = { JS_FN("logTimedEventBegin", js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("logError", js_pluginx_protocols_ProtocolAnalytics_logError, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCaptureUncaughtException", js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSessionContinueMillis", js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("logEvent", js_pluginx_protocols_ProtocolAnalytics_logEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("startSession", js_pluginx_protocols_ProtocolAnalytics_startSession, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopSession", js_pluginx_protocols_ProtocolAnalytics_stopSession, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("logTimedEventEnd", js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_plugin_ProtocolAnalytics_prototype = JS_InitClass( cx, global, jsb_cocos2d_plugin_PluginProtocol_prototype, jsb_cocos2d_plugin_ProtocolAnalytics_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProtocolAnalytics", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_plugin_ProtocolAnalytics_class; p->proto = jsb_cocos2d_plugin_ProtocolAnalytics_prototype; p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_plugin_ProtocolIAP_class; JSObject *jsb_cocos2d_plugin_ProtocolIAP_prototype; JSBool js_pluginx_protocols_ProtocolIAP_payForProduct(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolIAP_payForProduct : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TProductInfo arg0; ok &= jsval_to_TProductInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolIAP_payForProduct : Error processing arguments"); cobj->payForProduct(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolIAP_payForProduct : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolIAP_onPayResult(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolIAP_onPayResult : Invalid Native Object"); if (argc == 2) { cocos2d::plugin::PayResultCode arg0; const char* arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolIAP_onPayResult : Error processing arguments"); cobj->onPayResult(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolIAP_onPayResult : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolIAP_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolIAP_configDeveloperInfo : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TIAPDeveloperInfo arg0; ok &= jsval_to_TIAPDeveloperInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolIAP_configDeveloperInfo : Error processing arguments"); cobj->configDeveloperInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolIAP_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; void js_cocos2d_plugin_ProtocolIAP_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolIAP)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); // cocos2d::plugin::ProtocolIAP *nobj = static_cast(nproxy->ptr); // if (nobj) // delete nobj; jsb_remove_proxy(nproxy, jsproxy); } } void js_register_pluginx_protocols_ProtocolIAP(JSContext *cx, JSObject *global) { jsb_cocos2d_plugin_ProtocolIAP_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_plugin_ProtocolIAP_class->name = "ProtocolIAP"; jsb_cocos2d_plugin_ProtocolIAP_class->addProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolIAP_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_plugin_ProtocolIAP_class->getProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolIAP_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_plugin_ProtocolIAP_class->enumerate = JS_EnumerateStub; jsb_cocos2d_plugin_ProtocolIAP_class->resolve = JS_ResolveStub; jsb_cocos2d_plugin_ProtocolIAP_class->convert = JS_ConvertStub; jsb_cocos2d_plugin_ProtocolIAP_class->finalize = js_cocos2d_plugin_ProtocolIAP_finalize; jsb_cocos2d_plugin_ProtocolIAP_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("payForProduct", js_pluginx_protocols_ProtocolIAP_payForProduct, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onPayResult", js_pluginx_protocols_ProtocolIAP_onPayResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolIAP_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_plugin_ProtocolIAP_prototype = JS_InitClass( cx, global, jsb_cocos2d_plugin_PluginProtocol_prototype, jsb_cocos2d_plugin_ProtocolIAP_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProtocolIAP", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_plugin_ProtocolIAP_class; p->proto = jsb_cocos2d_plugin_ProtocolIAP_prototype; p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_plugin_ProtocolAds_class; JSObject *jsb_cocos2d_plugin_ProtocolAds_prototype; JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_showAds : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TAdsInfo arg0; ok &= jsval_to_TAdsInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_showAds : Error processing arguments"); cobj->showAds(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } if (argc == 2) { cocos2d::plugin::TAdsInfo arg0; cocos2d::plugin::ProtocolAds::AdsPos arg1; ok &= jsval_to_TAdsInfo(cx, argv[0], &arg0); ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_showAds : Error processing arguments"); cobj->showAds(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_showAds : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_hideAds : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TAdsInfo arg0; ok &= jsval_to_TAdsInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_hideAds : Error processing arguments"); cobj->hideAds(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_hideAds : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAds_queryPoints(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_queryPoints : Invalid Native Object"); if (argc == 0) { cobj->queryPoints(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_queryPoints : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_spendPoints : Invalid Native Object"); if (argc == 1) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_spendPoints : Error processing arguments"); cobj->spendPoints(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_spendPoints : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_configDeveloperInfo : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TAdsDeveloperInfo arg0; ok &= jsval_to_TAdsDeveloperInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_configDeveloperInfo : Error processing arguments"); cobj->configDeveloperInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAds_getAdsListener(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolAds_getAdsListener : Invalid Native Object"); if (argc == 0) { cocos2d::plugin::AdsListener* ret = cobj->getAdsListener(); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolAds_getAdsListener : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; void js_cocos2d_plugin_ProtocolAds_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolAds)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); // cocos2d::plugin::ProtocolAds *nobj = static_cast(nproxy->ptr); // if (nobj) // delete nobj; jsb_remove_proxy(nproxy, jsproxy); } } void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global) { jsb_cocos2d_plugin_ProtocolAds_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_plugin_ProtocolAds_class->name = "ProtocolAds"; jsb_cocos2d_plugin_ProtocolAds_class->addProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolAds_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_plugin_ProtocolAds_class->getProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolAds_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_plugin_ProtocolAds_class->enumerate = JS_EnumerateStub; jsb_cocos2d_plugin_ProtocolAds_class->resolve = JS_ResolveStub; jsb_cocos2d_plugin_ProtocolAds_class->convert = JS_ConvertStub; jsb_cocos2d_plugin_ProtocolAds_class->finalize = js_cocos2d_plugin_ProtocolAds_finalize; jsb_cocos2d_plugin_ProtocolAds_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("showAds", js_pluginx_protocols_ProtocolAds_showAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hideAds", js_pluginx_protocols_ProtocolAds_hideAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("queryPoints", js_pluginx_protocols_ProtocolAds_queryPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("spendPoints", js_pluginx_protocols_ProtocolAds_spendPoints, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolAds_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAdsListener", js_pluginx_protocols_ProtocolAds_getAdsListener, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_plugin_ProtocolAds_prototype = JS_InitClass( cx, global, jsb_cocos2d_plugin_PluginProtocol_prototype, jsb_cocos2d_plugin_ProtocolAds_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProtocolAds", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_plugin_ProtocolAds_class; p->proto = jsb_cocos2d_plugin_ProtocolAds_prototype; p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_plugin_ProtocolShare_class; JSObject *jsb_cocos2d_plugin_ProtocolShare_prototype; JSBool js_pluginx_protocols_ProtocolShare_onShareResult(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolShare_onShareResult : Invalid Native Object"); if (argc == 2) { cocos2d::plugin::ShareResultCode arg0; const char* arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolShare_onShareResult : Error processing arguments"); cobj->onShareResult(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolShare_onShareResult : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolShare_share(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolShare_share : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TShareInfo arg0; ok &= jsval_to_TShareInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolShare_share : Error processing arguments"); cobj->share(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolShare_share : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolShare_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolShare_configDeveloperInfo : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TShareDeveloperInfo arg0; ok &= jsval_to_TShareDeveloperInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolShare_configDeveloperInfo : Error processing arguments"); cobj->configDeveloperInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolShare_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; void js_cocos2d_plugin_ProtocolShare_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolShare)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); // cocos2d::plugin::ProtocolShare *nobj = static_cast(nproxy->ptr); // if (nobj) // delete nobj; jsb_remove_proxy(nproxy, jsproxy); } } void js_register_pluginx_protocols_ProtocolShare(JSContext *cx, JSObject *global) { jsb_cocos2d_plugin_ProtocolShare_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_plugin_ProtocolShare_class->name = "ProtocolShare"; jsb_cocos2d_plugin_ProtocolShare_class->addProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolShare_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_plugin_ProtocolShare_class->getProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolShare_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_plugin_ProtocolShare_class->enumerate = JS_EnumerateStub; jsb_cocos2d_plugin_ProtocolShare_class->resolve = JS_ResolveStub; jsb_cocos2d_plugin_ProtocolShare_class->convert = JS_ConvertStub; jsb_cocos2d_plugin_ProtocolShare_class->finalize = js_cocos2d_plugin_ProtocolShare_finalize; jsb_cocos2d_plugin_ProtocolShare_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("onShareResult", js_pluginx_protocols_ProtocolShare_onShareResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("share", js_pluginx_protocols_ProtocolShare_share, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolShare_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_plugin_ProtocolShare_prototype = JS_InitClass( cx, global, jsb_cocos2d_plugin_PluginProtocol_prototype, jsb_cocos2d_plugin_ProtocolShare_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProtocolShare", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_plugin_ProtocolShare_class; p->proto = jsb_cocos2d_plugin_ProtocolShare_prototype; p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_plugin_ProtocolSocial_class; JSObject *jsb_cocos2d_plugin_ProtocolSocial_prototype; JSBool js_pluginx_protocols_ProtocolSocial_showLeaderboard(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_showLeaderboard : Invalid Native Object"); if (argc == 1) { const char* arg0; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_showLeaderboard : Error processing arguments"); cobj->showLeaderboard(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_showLeaderboard : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolSocial_showAchievements(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_showAchievements : Invalid Native Object"); if (argc == 0) { cobj->showAchievements(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_showAchievements : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolSocial_submitScore(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_submitScore : Invalid Native Object"); if (argc == 2) { const char* arg0; long arg1; std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); ok &= jsval_to_long(cx, argv[1], (long *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_submitScore : Error processing arguments"); cobj->submitScore(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_submitScore : wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_configDeveloperInfo : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TSocialDeveloperInfo arg0; ok &= jsval_to_TSocialDeveloperInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_configDeveloperInfo : Error processing arguments"); cobj->configDeveloperInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolSocial_unlockAchievement(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_unlockAchievement : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TAchievementInfo arg0; ok &= jsval_to_TAchievementInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolSocial_unlockAchievement : Error processing arguments"); cobj->unlockAchievement(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolSocial_unlockAchievement : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; void js_cocos2d_plugin_ProtocolSocial_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolSocial)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); // cocos2d::plugin::ProtocolSocial *nobj = static_cast(nproxy->ptr); // if (nobj) // delete nobj; jsb_remove_proxy(nproxy, jsproxy); } } void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global) { jsb_cocos2d_plugin_ProtocolSocial_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_plugin_ProtocolSocial_class->name = "ProtocolSocial"; jsb_cocos2d_plugin_ProtocolSocial_class->addProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolSocial_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_plugin_ProtocolSocial_class->getProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolSocial_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_plugin_ProtocolSocial_class->enumerate = JS_EnumerateStub; jsb_cocos2d_plugin_ProtocolSocial_class->resolve = JS_ResolveStub; jsb_cocos2d_plugin_ProtocolSocial_class->convert = JS_ConvertStub; jsb_cocos2d_plugin_ProtocolSocial_class->finalize = js_cocos2d_plugin_ProtocolSocial_finalize; jsb_cocos2d_plugin_ProtocolSocial_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("showLeaderboard", js_pluginx_protocols_ProtocolSocial_showLeaderboard, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("showAchievements", js_pluginx_protocols_ProtocolSocial_showAchievements, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("submitScore", js_pluginx_protocols_ProtocolSocial_submitScore, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolSocial_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("unlockAchievement", js_pluginx_protocols_ProtocolSocial_unlockAchievement, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_plugin_ProtocolSocial_prototype = JS_InitClass( cx, global, jsb_cocos2d_plugin_PluginProtocol_prototype, jsb_cocos2d_plugin_ProtocolSocial_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProtocolSocial", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_plugin_ProtocolSocial_class; p->proto = jsb_cocos2d_plugin_ProtocolSocial_prototype; p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSClass *jsb_cocos2d_plugin_ProtocolUser_class; JSObject *jsb_cocos2d_plugin_ProtocolUser_prototype; JSBool js_pluginx_protocols_ProtocolUser_isLogined(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolUser_isLogined : Invalid Native Object"); if (argc == 0) { JSBool ret = cobj->isLogined(); jsval jsret; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_isLogined : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolUser_logout(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolUser_logout : Invalid Native Object"); if (argc == 0) { cobj->logout(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_logout : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolUser_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolUser_configDeveloperInfo : Invalid Native Object"); if (argc == 1) { cocos2d::plugin::TUserDeveloperInfo arg0; ok &= jsval_to_TUserDeveloperInfo(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "js_pluginx_protocols_ProtocolUser_configDeveloperInfo : Error processing arguments"); cobj->configDeveloperInfo(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_configDeveloperInfo : wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolUser_login(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolUser_login : Invalid Native Object"); if (argc == 0) { cobj->login(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_login : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolUser_getSessionID(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "js_pluginx_protocols_ProtocolUser_getSessionID : Invalid Native Object"); if (argc == 0) { std::string ret = cobj->getSessionID(); jsval jsret; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "js_pluginx_protocols_ProtocolUser_getSessionID : wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; void js_cocos2d_plugin_ProtocolUser_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolUser)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { nproxy = jsb_get_native_proxy(jsproxy->ptr); // cocos2d::plugin::ProtocolUser *nobj = static_cast(nproxy->ptr); // if (nobj) // delete nobj; jsb_remove_proxy(nproxy, jsproxy); } } void js_register_pluginx_protocols_ProtocolUser(JSContext *cx, JSObject *global) { jsb_cocos2d_plugin_ProtocolUser_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_plugin_ProtocolUser_class->name = "ProtocolUser"; jsb_cocos2d_plugin_ProtocolUser_class->addProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolUser_class->delProperty = JS_DeletePropertyStub; jsb_cocos2d_plugin_ProtocolUser_class->getProperty = JS_PropertyStub; jsb_cocos2d_plugin_ProtocolUser_class->setProperty = JS_StrictPropertyStub; jsb_cocos2d_plugin_ProtocolUser_class->enumerate = JS_EnumerateStub; jsb_cocos2d_plugin_ProtocolUser_class->resolve = JS_ResolveStub; jsb_cocos2d_plugin_ProtocolUser_class->convert = JS_ConvertStub; jsb_cocos2d_plugin_ProtocolUser_class->finalize = js_cocos2d_plugin_ProtocolUser_finalize; jsb_cocos2d_plugin_ProtocolUser_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; static JSFunctionSpec funcs[] = { JS_FN("isLogined", js_pluginx_protocols_ProtocolUser_isLogined, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("logout", js_pluginx_protocols_ProtocolUser_logout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolUser_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("login", js_pluginx_protocols_ProtocolUser_login, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSessionID", js_pluginx_protocols_ProtocolUser_getSessionID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_plugin_ProtocolUser_prototype = JS_InitClass( cx, global, jsb_cocos2d_plugin_PluginProtocol_prototype, jsb_cocos2d_plugin_ProtocolUser_class, empty_constructor, 0, properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "ProtocolUser", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_cocos2d_plugin_ProtocolUser_class; p->proto = jsb_cocos2d_plugin_ProtocolUser_prototype; p->parentProto = jsb_cocos2d_plugin_PluginProtocol_prototype; _js_global_type_map.insert(std::make_pair(typeName, p)); } } void register_all_pluginx_protocols(JSContext* cx, JSObject* obj) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, obj, "plugin", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, obj, "plugin", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } obj = ns; js_register_pluginx_protocols_PluginProtocol(cx, obj); js_register_pluginx_protocols_ProtocolUser(cx, obj); js_register_pluginx_protocols_ProtocolShare(cx, obj); js_register_pluginx_protocols_ProtocolIAP(cx, obj); js_register_pluginx_protocols_ProtocolSocial(cx, obj); js_register_pluginx_protocols_ProtocolAnalytics(cx, obj); js_register_pluginx_protocols_ProtocolAds(cx, obj); js_register_pluginx_protocols_PluginManager(cx, obj); } ================================================ FILE: cocos2d/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.hpp ================================================ #ifndef __pluginx_protocols_h__ #define __pluginx_protocols_h__ #include "jsapi.h" #include "jsfriendapi.h" extern JSClass *jsb_cocos2d_plugin_PluginProtocol_class; extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; JSBool js_pluginx_protocols_PluginProtocol_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_PluginProtocol_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_PluginProtocol(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_PluginProtocol_getPluginName(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_PluginProtocol_getPluginVersion(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_PluginProtocol_getSDKVersion(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_PluginProtocol_setDebugMode(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_plugin_PluginManager_class; extern JSObject *jsb_cocos2d_plugin_PluginManager_prototype; JSBool js_pluginx_protocols_PluginManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_PluginManager_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_PluginManager(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_PluginManager_unloadPlugin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_PluginManager_loadPlugin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_PluginManager_end(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_PluginManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_plugin_ProtocolAnalytics_class; extern JSObject *jsb_cocos2d_plugin_ProtocolAnalytics_prototype; JSBool js_pluginx_protocols_ProtocolAnalytics_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_ProtocolAnalytics_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_ProtocolAnalytics(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_ProtocolAnalytics_logTimedEventBegin(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAnalytics_logError(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAnalytics_setCaptureUncaughtException(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAnalytics_setSessionContinueMillis(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAnalytics_logEvent(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAnalytics_startSession(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAnalytics_stopSession(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAnalytics_logTimedEventEnd(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_plugin_ProtocolIAP_class; extern JSObject *jsb_cocos2d_plugin_ProtocolIAP_prototype; JSBool js_pluginx_protocols_ProtocolIAP_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_ProtocolIAP_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_ProtocolIAP(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_ProtocolIAP_payForProduct(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolIAP_onPayResult(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolIAP_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_plugin_ProtocolAds_class; extern JSObject *jsb_cocos2d_plugin_ProtocolAds_prototype; JSBool js_pluginx_protocols_ProtocolAds_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_ProtocolAds_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_queryPoints(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_getAdsListener(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_plugin_ProtocolShare_class; extern JSObject *jsb_cocos2d_plugin_ProtocolShare_prototype; JSBool js_pluginx_protocols_ProtocolShare_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_ProtocolShare_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_ProtocolShare(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_ProtocolShare_onShareResult(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolShare_share(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolShare_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_plugin_ProtocolSocial_class; extern JSObject *jsb_cocos2d_plugin_ProtocolSocial_prototype; JSBool js_pluginx_protocols_ProtocolSocial_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_ProtocolSocial_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_ProtocolSocial_showLeaderboard(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolSocial_showAchievements(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolSocial_submitScore(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolSocial_unlockAchievement(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_plugin_ProtocolUser_class; extern JSObject *jsb_cocos2d_plugin_ProtocolUser_prototype; JSBool js_pluginx_protocols_ProtocolUser_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_ProtocolUser_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_ProtocolUser(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_ProtocolUser_isLogined(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolUser_logout(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolUser_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolUser_login(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolUser_getSessionID(JSContext *cx, uint32_t argc, jsval *vp); #endif ================================================ FILE: cocos2d/plugin/jsbindings/auto/jsb_pluginx_protocols_auto_api.js ================================================ /** * @module pluginx_protocols */ var plugin = plugin || {}; /** * @class PluginProtocol */ plugin.PluginProtocol = { /** * @method getPluginName * @return A value converted from C/C++ "const char*" */ getPluginName : function () {}, /** * @method getPluginVersion * @return A value converted from C/C++ "std::string" */ getPluginVersion : function () {}, /** * @method getSDKVersion * @return A value converted from C/C++ "std::string" */ getSDKVersion : function () {}, /** * @method setDebugMode * @param {bool} */ setDebugMode : function () {}, }; /** * @class PluginManager */ plugin.PluginManager = { /** * @method unloadPlugin * @param {const char*} */ unloadPlugin : function () {}, /** * @method loadPlugin * @return A value converted from C/C++ "cocos2d::plugin::PluginProtocol*" * @param {const char*} */ loadPlugin : function () {}, /** * @method end */ end : function () {}, /** * @method getInstance * @return A value converted from C/C++ "cocos2d::plugin::PluginManager*" */ getInstance : function () {}, }; /** * @class ProtocolAnalytics */ plugin.ProtocolAnalytics = { /** * @method logTimedEventBegin * @param {const char*} */ logTimedEventBegin : function () {}, /** * @method logError * @param {const char*} * @param {const char*} */ logError : function () {}, /** * @method setCaptureUncaughtException * @param {bool} */ setCaptureUncaughtException : function () {}, /** * @method setSessionContinueMillis * @param {long} */ setSessionContinueMillis : function () {}, /** * @method logEvent * @param {const char*} * @param {cocos2d::plugin::LogEventParamMap*} */ logEvent : function () {}, /** * @method startSession * @param {const char*} */ startSession : function () {}, /** * @method stopSession */ stopSession : function () {}, /** * @method logTimedEventEnd * @param {const char*} */ logTimedEventEnd : function () {}, }; /** * @class ProtocolIAP */ plugin.ProtocolIAP = { /** * @method payForProduct * @param {cocos2d::plugin::TProductInfo} */ payForProduct : function () {}, /** * @method onPayResult * @param {cocos2d::plugin::PayResultCode} * @param {const char*} */ onPayResult : function () {}, /** * @method configDeveloperInfo * @param {cocos2d::plugin::TIAPDeveloperInfo} */ configDeveloperInfo : function () {}, }; /** * @class ProtocolAds */ plugin.ProtocolAds = { /** * @method showAds * @param {cocos2d::plugin::TAdsInfo} * @param {cocos2d::plugin::ProtocolAds::AdsPos} */ showAds : function () {}, /** * @method hideAds * @param {cocos2d::plugin::TAdsInfo} */ hideAds : function () {}, /** * @method queryPoints */ queryPoints : function () {}, /** * @method spendPoints * @param {int} */ spendPoints : function () {}, /** * @method configDeveloperInfo * @param {cocos2d::plugin::TAdsDeveloperInfo} */ configDeveloperInfo : function () {}, /** * @method getAdsListener * @return A value converted from C/C++ "cocos2d::plugin::AdsListener*" */ getAdsListener : function () {}, }; /** * @class ProtocolShare */ plugin.ProtocolShare = { /** * @method onShareResult * @param {cocos2d::plugin::ShareResultCode} * @param {const char*} */ onShareResult : function () {}, /** * @method share * @param {cocos2d::plugin::TShareInfo} */ share : function () {}, /** * @method configDeveloperInfo * @param {cocos2d::plugin::TShareDeveloperInfo} */ configDeveloperInfo : function () {}, }; /** * @class ProtocolSocial */ plugin.ProtocolSocial = { /** * @method showLeaderboard * @param {const char*} */ showLeaderboard : function () {}, /** * @method showAchievements */ showAchievements : function () {}, /** * @method submitScore * @param {const char*} * @param {long} */ submitScore : function () {}, /** * @method configDeveloperInfo * @param {cocos2d::plugin::TSocialDeveloperInfo} */ configDeveloperInfo : function () {}, /** * @method unlockAchievement * @param {cocos2d::plugin::TAchievementInfo} */ unlockAchievement : function () {}, }; /** * @class ProtocolUser */ plugin.ProtocolUser = { /** * @method isLogined * @return A value converted from C/C++ "bool" */ isLogined : function () {}, /** * @method logout */ logout : function () {}, /** * @method configDeveloperInfo * @param {cocos2d::plugin::TUserDeveloperInfo} */ configDeveloperInfo : function () {}, /** * @method login */ login : function () {}, /** * @method getSessionID * @return A value converted from C/C++ "std::string" */ getSessionID : function () {}, }; ================================================ FILE: cocos2d/plugin/jsbindings/js/jsb_pluginx.js ================================================ plugin = plugin || {}; plugin.PluginParam.ParamType = {}; plugin.PluginParam.ParamType.TypeInt = 1; plugin.PluginParam.ParamType.TypeFloat = 2; plugin.PluginParam.ParamType.TypeBool = 3; plugin.PluginParam.ParamType.TypeString = 4; plugin.PluginParam.ParamType.TypeStringMap = 5; plugin.ProtocolAds.AdsResultCode = {}; plugin.ProtocolAds.AdsResultCode.AdsReceived = 0; plugin.ProtocolAds.AdsResultCode.FullScreenViewShown = 1; plugin.ProtocolAds.AdsResultCode.FullScreenViewDismissed = 2; plugin.ProtocolAds.AdsResultCode.PointsSpendSucceed = 3; plugin.ProtocolAds.AdsResultCode.PointsSpendFailed = 4; plugin.ProtocolAds.AdsResultCode.NetworkError = 5; plugin.ProtocolAds.AdsResultCode.UnknownError = 6; plugin.ProtocolAds.AdsPos = {}; plugin.ProtocolAds.AdsPos.PosCenter = 0; plugin.ProtocolAds.AdsPos.PosTop = 1; plugin.ProtocolAds.AdsPos.PosTopLeft = 2; plugin.ProtocolAds.AdsPos.PosTopRight = 3; plugin.ProtocolAds.AdsPos.PosBottom = 4; plugin.ProtocolAds.AdsPos.PosBottomLeft = 5; plugin.ProtocolAds.AdsPos.PosBottomRight = 6; plugin.ProtocolIAP.PayResultCode = {}; plugin.ProtocolIAP.PayResultCode.PaySuccess = 0; plugin.ProtocolIAP.PayResultCode.PayFail = 1; plugin.ProtocolIAP.PayResultCode.PayCancel = 2; plugin.ProtocolIAP.PayResultCode.PayTimeOut = 3; plugin.ProtocolShare.ShareResultCode = {}; plugin.ProtocolShare.ShareResultCode.ShareSuccess = 0; plugin.ProtocolShare.ShareResultCode.ShareFail = 1; plugin.ProtocolShare.ShareResultCode.ShareCancel = 2; plugin.ProtocolShare.ShareResultCode.ShareTimeOut = 3; plugin.ProtocolSocial.SocialRetCode = {}; plugin.ProtocolSocial.SocialRetCode.ScoreSubmitSuccess = 1; plugin.ProtocolSocial.SocialRetCode.ScoreSubmitFailed = 2; plugin.ProtocolSocial.SocialRetCode.AchUnlockSuccess = 3; plugin.ProtocolSocial.SocialRetCode.AchUnlockFailed = 4; plugin.ProtocolUser.UserActionResultCode = {}; plugin.ProtocolUser.UserActionResultCode.LoginSucceed = 0; plugin.ProtocolUser.UserActionResultCode.LoginFailed = 1; plugin.ProtocolUser.UserActionResultCode.LogoutSucceed = 2; ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_basic_conversions.cpp ================================================ #include "jsb_pluginx_basic_conversions.h" #include #include "jsb_pluginx_spidermonkey_specifics.h" #include "pluginxUTF8.h" namespace pluginx { // just a simple utility to avoid mem leaking when using JSString class JSStringWrapper { JSString* string; const char* buffer; JSContext* cx; public: JSStringWrapper() { buffer = NULL; } JSStringWrapper(JSString* str, JSContext* cx) { set(str, cx); } JSStringWrapper(jsval val, JSContext* cx) { set(val, cx); } ~JSStringWrapper() { if (buffer) { // delete[] buffer; // buffer = NULL; JS_free(cx, (void*)buffer); } } void set(jsval val, JSContext* cx) { if (val.isString()) { this->set(val.toString(), cx); } else { buffer = NULL; } } void set(JSString* str, JSContext* cx) { this->cx = cx; string = str; // Not suppored in SpiderMonkey v19 //buffer = JS_EncodeString(cx, string); const jschar *chars = JS_GetStringCharsZ(cx, string); size_t l = JS_GetStringLength(string); char* pUTF8Str = cc_utf16_to_utf8((const unsigned short*)chars, l, NULL, NULL); buffer = pUTF8Str; } std::string get() { return buffer; } operator std::string() { return std::string(buffer); } operator char*() { return (char*)buffer; } }; JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *outval ) { JSBool ok = JS_TRUE; double dp; ok &= JS_ValueToNumber(cx, vp, &dp); if (!ok) { LOGD("jsval_to_int32: the argument is not a number"); return JS_FALSE; } ok &= !isnan(dp); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); *outval = (int32_t)dp; return ok; } JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *outval ) { JSBool ok = JS_TRUE; double dp; ok &= JS_ValueToNumber(cx, vp, &dp); if (!ok) { LOGD("jsval_to_uint32: the argument is not a number"); return JS_FALSE; } ok &= !isnan(dp); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); *outval = (uint32_t)dp; return ok; } JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *outval ) { JSBool ok = JS_TRUE; double dp; ok &= JS_ValueToNumber(cx, vp, &dp); if (!ok) { LOGD("jsval_to_uint16: the argument is not a number"); return JS_FALSE; } ok &= !isnan(dp); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); *outval = (uint16_t)dp; return ok; } JSBool jsval_to_long_long(JSContext *cx, jsval vp, long long* r) { JSObject *tmp_arg; JSBool ok = JS_ValueToObject( cx, vp, &tmp_arg ); if (!ok) { LOGD("jsval_to_long_long: Error converting value to object"); return JS_FALSE; } JSB_PRECONDITION2( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, JS_FALSE, "Not a TypedArray object"); JSB_PRECONDITION2( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long long), cx, JS_FALSE, "Invalid Typed Array length"); uint32_t* arg_array = (uint32_t*)JS_GetArrayBufferViewData( tmp_arg ); long long ret = arg_array[0]; ret = ret << 32; ret |= arg_array[1]; *r = ret; return JS_TRUE; } JSBool jsval_to_long(JSContext *cx, jsval vp, long* ret) { JSBool ok = JS_TRUE; double dp; ok &= JS_ValueToNumber(cx, vp, &dp); if (!ok) { LOGD("jsval_to_long: the argument is not a number"); return JS_FALSE; } ok &= !isnan(dp); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); *ret = (long)dp; return ok; } JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret) { JSString *tmp = JS_ValueToString(cx, v); if (!tmp) { LOGD("jsval_to_std_string: the jsval is not a string."); return JS_FALSE; } JSStringWrapper str(tmp, cx); *ret = str.get(); return JS_TRUE; } JSBool jsval_to_TProductInfo(JSContext *cx, jsval v, TProductInfo* ret) { JSObject* tmp = JSVAL_TO_OBJECT(v); if (!tmp) { LOGD("jsval_to_TProductInfo: the jsval is not an object."); return JS_FALSE; } JSObject* it = JS_NewPropertyIterator(cx, tmp); while (true) { jsid idp; jsval key; if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key)) return JS_FALSE; // error if (key == JSVAL_VOID) break; // end of iteration if (! JSVAL_IS_STRING(key)) continue; // ignore integer properties JS::RootedValue value(cx); JS_GetPropertyById(cx, tmp, idp, &value); if (! JSVAL_IS_STRING(value)) continue; // ignore integer properties JSStringWrapper strWrapper(JSVAL_TO_STRING(key), cx); JSStringWrapper strWrapper2(JSVAL_TO_STRING(value), cx); (*ret)[strWrapper.get()] = strWrapper2.get(); LOGD("iterate object: key = %s, value = %s", strWrapper.get().c_str(), strWrapper2.get().c_str()); } return JS_TRUE; } JSBool jsval_to_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_TAdsInfo(JSContext *cx, jsval v, TAdsInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_TPaymentInfo(JSContext *cx, jsval v, std::map* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_TAchievementInfo(JSContext *cx, jsval v, TAchievementInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_TUserDeveloperInfo(JSContext *cx, jsval v, TUserDeveloperInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); } JSBool jsval_to_LogEventParamMap(JSContext *cx, jsval v, LogEventParamMap** ret) { JSBool jsret = JS_FALSE; if (v.isObject()) { LogEventParamMap* tmp = new LogEventParamMap(); jsret = jsval_to_TProductInfo(cx, v, tmp); if (jsret) { *ret = tmp; } } return jsret; } JSBool jsval_to_StringMap(JSContext *cx, jsval v, StringMap* ret) { return jsval_to_TProductInfo(cx, v, ret); } // From native type to jsval jsval int32_to_jsval( JSContext *cx, int32_t number ) { return INT_TO_JSVAL(number); } jsval uint32_to_jsval( JSContext *cx, uint32_t number ) { return UINT_TO_JSVAL(number); } jsval long_long_to_jsval(JSContext* cx, long long v) { JSObject *tmp = JS_NewUint32Array(cx, 2); uint32_t *data = (uint32_t *)JS_GetArrayBufferViewData(tmp); data[0] = ((uint32_t *)(&v))[0]; data[1] = ((uint32_t *)(&v))[1]; return OBJECT_TO_JSVAL(tmp); } jsval long_to_jsval(JSContext* cx, long v) { return INT_TO_JSVAL(v); } jsval std_string_to_jsval(JSContext* cx, const std::string& v) { return c_string_to_jsval(cx, v.c_str()); } jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length /* = -1 */) { if (v == NULL) { return JSVAL_NULL; } jsval ret = JSVAL_NULL; int utf16_size = 0; jschar* strUTF16 = (jschar*)cc_utf8_to_utf16(v, length, &utf16_size); if (strUTF16 && utf16_size > 0) { JSString* str = JS_NewUCStringCopyN(cx, strUTF16, utf16_size); if (str) { ret = STRING_TO_JSVAL(str); } delete[] strUTF16; } return ret; } jsval TProductInfo_to_jsval(JSContext *cx, TProductInfo& ret) { JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); if (!tmp) return JSVAL_NULL; for (TProductInfo::iterator it = ret.begin(); it != ret.end(); ++it) { JS_DefineProperty(cx, tmp, it->first.c_str(), std_string_to_jsval(cx, it->second), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); } return OBJECT_TO_JSVAL(tmp); } jsval LogEventParamMap_to_jsval(JSContext *cx, LogEventParamMap*& ret) {// TODO: return JSVAL_NULL; } }// namespace pluginx { ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_basic_conversions.h ================================================ #ifndef __JS_BASIC_CONVERSIONS_H__ #define __JS_BASIC_CONVERSIONS_H__ #include "jsapi.h" #include "jsfriendapi.h" #include "ProtocolIAP.h" #include "ProtocolAnalytics.h" #include "ProtocolAds.h" #include "ProtocolShare.h" #include "ProtocolSocial.h" #include "ProtocolUser.h" #ifndef CCLOGINFO #define CCLOGINFO(...) #endif using namespace cocos2d::plugin; namespace pluginx { // to native JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *ret ); JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *ret ); JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *ret ); JSBool jsval_to_long(JSContext *cx, jsval v, long* ret); JSBool jsval_to_long_long(JSContext *cx, jsval v, long long* ret); JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret); JSBool jsval_to_TProductInfo(JSContext *cx, jsval v, TProductInfo* ret); JSBool jsval_to_TIAPDeveloperInfo(JSContext *cx, jsval v, TIAPDeveloperInfo* ret); JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret); JSBool jsval_to_TAdsInfo(JSContext *cx, jsval v, TAdsInfo* ret); JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret); JSBool jsval_to_TShareInfo(JSContext *cx, jsval v, TShareInfo* ret); JSBool jsval_to_TSocialDeveloperInfo(JSContext *cx, jsval v, TSocialDeveloperInfo* ret); JSBool jsval_to_TAchievementInfo(JSContext *cx, jsval v, TAchievementInfo* ret); JSBool jsval_to_TPaymentInfo(JSContext *cx, jsval v, std::map* ret); JSBool jsval_to_TUserDeveloperInfo(JSContext *cx, jsval v, TUserDeveloperInfo* ret); JSBool jsval_to_LogEventParamMap(JSContext *cx, jsval v, LogEventParamMap** ret); JSBool jsval_to_StringMap(JSContext *cx, jsval v, StringMap* ret); // from native jsval int32_to_jsval( JSContext *cx, int32_t l); jsval uint32_to_jsval( JSContext *cx, uint32_t number ); jsval long_long_to_jsval(JSContext* cx, long long v); jsval long_to_jsval(JSContext* cx, long v); jsval std_string_to_jsval(JSContext* cx, const std::string& v); jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length = -1); jsval TProductInfo_to_jsval(JSContext *cx, TProductInfo& ret); jsval LogEventParamMap_to_jsval(JSContext *cx, LogEventParamMap*& ret); } // namespace pluginx { #endif /* __JS_BASIC_CONVERSIONS_H__ */ ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_extension_registration.cpp ================================================ #include "jsb_pluginx_extension_registration.h" #include "jsb_pluginx_manual_callback.h" #include "jsb_pluginx_manual_protocols.h" static jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string) { jsval out; if (JS_EvaluateScript(cx, thisObj, string, strlen(string), "(string)", 1, &out) == JS_TRUE) { return out; } return JSVAL_VOID; } extern JSObject *jsb_cocos2d_plugin_ProtocolIAP_prototype; extern JSObject *jsb_cocos2d_plugin_ProtocolAds_prototype; extern JSObject *jsb_cocos2d_plugin_ProtocolShare_prototype; extern JSObject *jsb_cocos2d_plugin_PluginProtocol_prototype; extern JSObject *jsb_cocos2d_plugin_ProtocolSocial_prototype; extern JSObject *jsb_cocos2d_plugin_ProtocolUser_prototype; void register_pluginx_js_extensions(JSContext* cx, JSObject* global) { // first, try to get the ns JS::RootedValue nsval(cx); JSObject *ns; JS_GetProperty(cx, global, "plugin", &nsval); if (nsval == JSVAL_VOID) { ns = JS_NewObject(cx, NULL, NULL, NULL); nsval = OBJECT_TO_JSVAL(ns); JS_SetProperty(cx, global, "plugin", nsval); } else { JS_ValueToObject(cx, nsval, &ns); } JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolIAP_prototype, "setResultListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolAds_prototype, "setAdsListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolShare_prototype, "setResultListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolSocial_prototype, "setListener", js_pluginx_ProtocolSocial_setListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_ProtocolUser_prototype, "setActionListener", js_pluginx_ProtocolUser_setActionListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callFloatFuncWithParam", js_pluginx_PluginProtocol_callFloatFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_plugin_PluginProtocol_prototype, "callBoolFuncWithParam", js_pluginx_PluginProtocol_callBoolFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); global = ns; js_register_pluginx_protocols_PluginParam(cx, global); } ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_extension_registration.h ================================================ #ifndef __JS_EXTENSION_REGISTRATION_H__ #define __JS_EXTENSION_REGISTRATION_H__ #include "jsapi.h" #include "jsfriendapi.h" void register_pluginx_js_extensions(JSContext* cx, JSObject* global); #endif /* __JS_EXTENSION_REGISTRATION_H__ */ ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_manual_callback.cpp ================================================ #include "jsb_pluginx_manual_callback.h" #include "jsb_pluginx_basic_conversions.h" #include "jsb_pluginx_spidermonkey_specifics.h" #include "ProtocolAds.h" using namespace pluginx; static JSContext* s_cx = NULL; class Pluginx_PurchaseResult : public cocos2d::plugin::PayResultListener { public: virtual void onPayResult(cocos2d::plugin::PayResultCode ret, const char* msg, cocos2d::plugin::TProductInfo info) { char goodInfo[1024] = { 0 }; sprintf(goodInfo, "商品名称:%s\n商品价格:%s\n商品描述:%s", info.find("productName")->second.c_str(), info.find("productPrice")->second.c_str(), info.find("productDesc")->second.c_str()); LOGD(goodInfo); JSContext* cx = s_cx; JSBool hasAction; jsval retval; JS::RootedValue temp_retval(cx); jsval dataVal[3]; dataVal[0] = INT_TO_JSVAL(ret); std::string strMsgInfo = msg; dataVal[1] = std_string_to_jsval(cx, strMsgInfo); dataVal[2] = TProductInfo_to_jsval(cx, info); JSObject* obj = _JSDelegate; if (JS_HasProperty(cx, obj, "onPayResult", &hasAction) && hasAction) { if(!JS_GetProperty(cx, obj, "onPayResult", &temp_retval)) { return; } if(temp_retval == JSVAL_VOID) { return; } JSAutoCompartment ac(cx, obj); JS_CallFunctionName(cx, obj, "onPayResult", 3, dataVal, &retval); } } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; } private: JSObject* _JSDelegate; }; JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp) { s_cx = cx; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::ProtocolIAP* cobj = (cocos2d::plugin::ProtocolIAP *)(proxy ? proxy->ptr : NULL); JSBool ok = JS_TRUE; if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); Pluginx_PurchaseResult* nativeDelegate = new Pluginx_PurchaseResult(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setResultListener(nativeDelegate); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } class Pluginx_AdsListener : public cocos2d::plugin::AdsListener { public: virtual void onAdsResult(AdsResultCode code, const char* msg) { JSContext* cx = s_cx; JSBool hasAction; jsval retval; JS::RootedValue temp_retval(cx); jsval dataVal[2]; dataVal[0] = INT_TO_JSVAL(code); std::string strMsgInfo = msg; dataVal[1] = std_string_to_jsval(cx, strMsgInfo); JSObject* obj = _JSDelegate; JSBool bRet = JS_HasProperty(cx, obj, "onAdsResult", &hasAction); if (bRet && hasAction) { if(!JS_GetProperty(cx, obj, "onAdsResult", &temp_retval)) { return; } if(temp_retval == JSVAL_VOID) { return; } JSAutoCompartment ac(cx, obj); JS_CallFunctionName(cx, obj, "onAdsResult", 2, dataVal, &retval); } } virtual void onPlayerGetPoints(ProtocolAds* pAdsPlugin, int points) { JSContext* cx = s_cx; JSBool hasAction; jsval retval; JS::RootedValue temp_retval(cx); js_proxy_t * p; JS_GET_PROXY(p, pAdsPlugin); if (! p) return; jsval dataVal[2]; jsval arg = OBJECT_TO_JSVAL(p->obj); dataVal[0] = arg; dataVal[1] = INT_TO_JSVAL(points); JSObject* obj = _JSDelegate; JSBool bRet = JS_HasProperty(cx, obj, "onPlayerGetPoints", &hasAction); if (bRet && hasAction) { if(!JS_GetProperty(cx, obj, "onPlayerGetPoints", &temp_retval)) { return; } if(temp_retval == JSVAL_VOID) { return; } JSAutoCompartment ac(cx, obj); JS_CallFunctionName(cx, obj, "onPlayerGetPoints", 2, NULL, &retval); } } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; } private: JSObject* _JSDelegate; }; JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp) { s_cx = cx; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSBool ok = JS_TRUE; if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); Pluginx_AdsListener* nativeDelegate = new Pluginx_AdsListener(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setAdsListener(nativeDelegate); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } class Pluginx_ShareResult : public cocos2d::plugin::ShareResultListener { public: virtual void onShareResult(cocos2d::plugin::ShareResultCode ret, const char* msg) { JSContext* cx = s_cx; JSBool hasAction; jsval retval; JS::RootedValue temp_retval(cx); jsval dataVal[2]; dataVal[0] = INT_TO_JSVAL(ret); std::string strMsgInfo = msg; dataVal[1] = std_string_to_jsval(cx, strMsgInfo); JSObject* obj = _JSDelegate; if (JS_HasProperty(cx, obj, "onShareResult", &hasAction) && hasAction) { if(!JS_GetProperty(cx, obj, "onShareResult", &temp_retval)) { return; } if(temp_retval == JSVAL_VOID) { return; } JSAutoCompartment ac(cx, obj); JS_CallFunctionName(cx, obj, "onShareResult", 2, dataVal, &retval); } } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; } private: JSObject* _JSDelegate; }; JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, jsval *vp) { s_cx = cx; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::ProtocolShare* cobj = (cocos2d::plugin::ProtocolShare *)(proxy ? proxy->ptr : NULL); JSBool ok = JS_TRUE; if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); Pluginx_ShareResult* nativeDelegate = new Pluginx_ShareResult(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setResultListener(nativeDelegate); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } class Pluginx_SocialResult : public cocos2d::plugin::SocialListener { public: virtual void onSocialResult(cocos2d::plugin::SocialRetCode ret, const char* msg) { JSContext* cx = s_cx; JSBool hasAction; jsval retval; JS::RootedValue temp_retval(cx); jsval dataVal[2]; dataVal[0] = INT_TO_JSVAL(ret); std::string strMsgInfo = msg; dataVal[1] = std_string_to_jsval(cx, strMsgInfo); JSObject* obj = _JSDelegate; if (JS_HasProperty(cx, obj, "onSocialResult", &hasAction) && hasAction) { if(!JS_GetProperty(cx, obj, "onSocialResult", &temp_retval)) { return; } if(temp_retval == JSVAL_VOID) { return; } JSAutoCompartment ac(cx, obj); JS_CallFunctionName(cx, obj, "onSocialResult", 2, dataVal, &retval); } } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; } private: JSObject* _JSDelegate; }; JSBool js_pluginx_ProtocolSocial_setListener(JSContext *cx, uint32_t argc, jsval *vp) { s_cx = cx; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); JSBool ok = JS_TRUE; if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); Pluginx_SocialResult* nativeDelegate = new Pluginx_SocialResult(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setListener(nativeDelegate); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } class Pluginx_UserActionListener : public cocos2d::plugin::UserActionListener { public: virtual void onActionResult(ProtocolUser* userPlugin, cocos2d::plugin::UserActionResultCode ret, const char* msg) { JSContext* cx = s_cx; JSBool hasAction; jsval retval; JS::RootedValue temp_retval(cx); js_proxy_t * p; JS_GET_PROXY(p, userPlugin); if (! p) return; jsval dataVal[3]; jsval arg1 = OBJECT_TO_JSVAL(p->obj); dataVal[0] = arg1; dataVal[1] = INT_TO_JSVAL(ret); std::string strMsgInfo = msg; dataVal[2] = std_string_to_jsval(cx, strMsgInfo); JSObject* obj = _JSDelegate; if (JS_HasProperty(cx, obj, "onActionResult", &hasAction) && hasAction) { if(!JS_GetProperty(cx, obj, "onActionResult", &temp_retval)) { return; } if(temp_retval == JSVAL_VOID) { return; } JSAutoCompartment ac(cx, obj); JS_CallFunctionName(cx, obj, "onActionResult", 3, dataVal, &retval); } } void setJSDelegate(JSObject* pJSDelegate) { _JSDelegate = pJSDelegate; } private: JSObject* _JSDelegate; }; JSBool js_pluginx_ProtocolUser_setActionListener(JSContext *cx, uint32_t argc, jsval *vp) { s_cx = cx; jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); JSBool ok = JS_TRUE; if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); Pluginx_UserActionListener* nativeDelegate = new Pluginx_UserActionListener(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setActionListener(nativeDelegate); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_manual_callback.h ================================================ #ifndef __JS_MANUAL_CALLBACK_H__ #define __JS_MANUAL_CALLBACK_H__ #include "jsapi.h" #include "jsfriendapi.h" JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolSocial_setListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolUser_setActionListener(JSContext *cx, uint32_t argc, jsval *vp); #endif /* __JS_MANUAL_CALLBACK_H__ */ ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_manual_protocols.cpp ================================================ #include "jsb_pluginx_manual_protocols.h" #include "jsb_pluginx_basic_conversions.h" #include "jsb_pluginx_spidermonkey_specifics.h" #include #include #include "PluginProtocol.h" using namespace pluginx; JSClass *jsb_PluginParam_class; JSObject *jsb_PluginParam_prototype; JSBool js_pluginx_protocols_PluginParam_constructor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; JSObject *obj = NULL; cocos2d::plugin::PluginParam* cobj = NULL; do { if (argc == 2) { int arg0; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); if (!ok) { ok = JS_TRUE; break; } switch (arg0) { case cocos2d::plugin::PluginParam::kParamTypeInt: { int arg1; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); if (ok) { cobj = new cocos2d::plugin::PluginParam(arg1); } } break; case cocos2d::plugin::PluginParam::kParamTypeFloat: { double arg1; ok &= JS_ValueToNumber(cx, argv[1], &arg1); if (ok) { float tempArg = arg1; cobj = new cocos2d::plugin::PluginParam(tempArg); } } break; case cocos2d::plugin::PluginParam::kParamTypeBool: { JSBool arg1; ok &= JS_ValueToBoolean(cx, argv[1], &arg1); if (ok) { cobj = new cocos2d::plugin::PluginParam(arg1); } } break; case cocos2d::plugin::PluginParam::kParamTypeString: { const char* arg1; std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); if (ok) { cobj = new cocos2d::plugin::PluginParam(arg1); } } break; case cocos2d::plugin::PluginParam::kParamTypeStringMap: { StringMap arg1; ok &= jsval_to_StringMap(cx, argv[1], &arg1); if (ok) { cobj = new cocos2d::plugin::PluginParam(arg1); } } break; default: break; } if (!ok || NULL == cobj) { ok = JS_TRUE; break; } TypeTest t; js_type_class_t *typeClass; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); assert(typeMapIter != _js_global_type_map.end()); typeClass = typeMapIter->second; assert(typeClass); obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); js_proxy_t *proxy; JS_NEW_PROXY(proxy, cobj, obj); } } while (0); if (cobj) { JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } void js_pluginx_protocols_PluginParam_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PluginParam)", obj); js_proxy_t* nproxy; js_proxy_t* jsproxy; JS_GET_NATIVE_PROXY(jsproxy, obj); if (jsproxy) { JS_GET_PROXY(nproxy, jsproxy->ptr); cocos2d::plugin::PluginParam *nobj = static_cast(nproxy->ptr); if (nobj) delete nobj; JS_REMOVE_PROXY(nproxy, jsproxy); } } static JSBool js_pluginx_protocols_PluginParam_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); cocos2d::plugin::PluginParam *nobj = new cocos2d::plugin::PluginParam(); js_proxy_t* p; JS_NEW_PROXY(p, nobj, obj); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } void js_register_pluginx_protocols_PluginParam(JSContext *cx, JSObject *global) { jsb_PluginParam_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_PluginParam_class->name = "PluginParam"; jsb_PluginParam_class->addProperty = JS_PropertyStub; jsb_PluginParam_class->delProperty = JS_DeletePropertyStub; jsb_PluginParam_class->getProperty = JS_PropertyStub; jsb_PluginParam_class->setProperty = JS_StrictPropertyStub; jsb_PluginParam_class->enumerate = JS_EnumerateStub; jsb_PluginParam_class->resolve = JS_ResolveStub; jsb_PluginParam_class->convert = JS_ConvertStub; jsb_PluginParam_class->finalize = js_pluginx_protocols_PluginParam_finalize; jsb_PluginParam_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} }; JSFunctionSpec *funcs = NULL; JSFunctionSpec *st_funcs = NULL; jsb_PluginParam_prototype = JS_InitClass( cx, global, NULL, // parent proto jsb_PluginParam_class, js_pluginx_protocols_PluginParam_constructor, 0, // constructor properties, funcs, NULL, // no static properties st_funcs); // make the class enumerable in the registered namespace JSBool found; JS_SetPropertyAttributes(cx, global, "PluginParam", JSPROP_ENUMERATE | JSPROP_READONLY, &found); // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); if (typeMapIter == _js_global_type_map.end()) { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); p->jsclass = jsb_PluginParam_class; p->proto = jsb_PluginParam_prototype; p->parentProto = NULL; _js_global_type_map.insert(std::make_pair(typeName, p)); } } JSBool js_pluginx_PluginProtocol_callFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc > 0) { std::string strName; ok &= jsval_to_std_string(cx, argv[0], &strName); std::vector params; uint32_t i = 1; while (i < argc) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); if (tmpObj == NULL) break; JS_GET_NATIVE_PROXY(proxy, tmpObj); cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL); JS_TEST_NATIVE_OBJECT(cx, item) params.push_back(item); i++; } JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); cobj->callFuncWithParam(strName.c_str(), params); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_pluginx_PluginProtocol_callStringFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc > 0) { std::string strName; ok &= jsval_to_std_string(cx, argv[0], &strName); std::vector params; uint32_t i = 1; while (i < argc) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); if (tmpObj == NULL) break; JS_GET_NATIVE_PROXY(proxy, tmpObj); cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL); JS_TEST_NATIVE_OBJECT(cx, item) params.push_back(item); i++; } JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); std::string ret = cobj->callStringFuncWithParam(strName.c_str(), params); jsval jsret; jsret = std_string_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_pluginx_PluginProtocol_callIntFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc > 0) { std::string strName; ok &= jsval_to_std_string(cx, argv[0], &strName); std::vector params; uint32_t i = 1; while (i < argc) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); if (tmpObj == NULL) break; JS_GET_NATIVE_PROXY(proxy, tmpObj); cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL); JS_TEST_NATIVE_OBJECT(cx, item) params.push_back(item); i++; } JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); int ret = cobj->callIntFuncWithParam(strName.c_str(), params); jsval jsret; jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_pluginx_PluginProtocol_callFloatFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc > 0) { std::string strName; ok &= jsval_to_std_string(cx, argv[0], &strName); std::vector params; uint32_t i = 1; while (i < argc) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); if (tmpObj == NULL) break; JS_GET_NATIVE_PROXY(proxy, tmpObj); cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL); JS_TEST_NATIVE_OBJECT(cx, item) params.push_back(item); i++; } JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); float ret = cobj->callFloatFuncWithParam(strName.c_str(), params); jsval jsret; jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } JSBool js_pluginx_PluginProtocol_callBoolFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; jsval *argv = JS_ARGV(cx, vp); if (argc > 0) { std::string strName; ok &= jsval_to_std_string(cx, argv[0], &strName); std::vector params; uint32_t i = 1; while (i < argc) { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[i]); if (tmpObj == NULL) break; JS_GET_NATIVE_PROXY(proxy, tmpObj); cocos2d::plugin::PluginParam* item = (cocos2d::plugin::PluginParam*)(proxy ? proxy->ptr : NULL); JS_TEST_NATIVE_OBJECT(cx, item) params.push_back(item); i++; } JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); cocos2d::plugin::PluginProtocol* cobj = (cocos2d::plugin::PluginProtocol *)(proxy ? proxy->ptr : NULL); bool ret = cobj->callBoolFuncWithParam(strName.c_str(), params); jsval jsret; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; } ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_manual_protocols.h ================================================ #ifndef __JS_MANUAL_PROTOCOLS_H__ #define __JS_MANUAL_PROTOCOLS_H__ #include "jsapi.h" #include "jsfriendapi.h" extern JSClass *jsb_PluginParam_class; extern JSObject *jsb_PluginParam_prototype; JSBool js_pluginx_protocols_PluginParam_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_pluginx_protocols_PluginParam_finalize(JSContext *cx, JSObject *obj); void js_register_pluginx_protocols_PluginParam(JSContext *cx, JSObject *global); void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_PluginParam_PluginParam(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_PluginProtocol_callFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_PluginProtocol_callStringFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_PluginProtocol_callIntFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_PluginProtocol_callFloatFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_PluginProtocol_callBoolFuncWithParam(JSContext *cx, uint32_t argc, jsval *vp); #endif /* __JS_MANUAL_PROTOCOLS_H__ */ ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_spidermonkey_specifics.cpp ================================================ #include "jsb_pluginx_spidermonkey_specifics.h" namespace pluginx { js_proxy_t *_native_js_global_ht = NULL; js_proxy_t *_js_native_global_ht = NULL; std::unordered_map _js_global_type_map; unsigned int getHashCodeByString(const char *key) { unsigned int len = strlen(key); const char *end=key+len; unsigned int hash; for (hash = 0; key < end; key++) { hash *= 16777619; hash ^= (unsigned int) (unsigned char) toupper(*key); } return (hash); } js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj) { js_proxy_t* p; JS_NEW_PROXY(p, nativeObj, jsObj); return p; } js_proxy_t* jsb_get_native_proxy(void* nativeObj) { js_proxy_t* p; JS_GET_PROXY(p, nativeObj); return p; } js_proxy_t* jsb_get_js_proxy(JSObject* jsObj) { js_proxy_t* p; JS_GET_NATIVE_PROXY(p, jsObj); return p; } void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy) { JS_REMOVE_PROXY(nativeProxy, jsProxy); } } // namespace pluginx { ================================================ FILE: cocos2d/plugin/jsbindings/manual/jsb_pluginx_spidermonkey_specifics.h ================================================ #ifndef __JS_PLUGINX_SPIDERMONKEY_SPECIFICS_H__ #define __JS_PLUGINX_SPIDERMONKEY_SPECIFICS_H__ #include #include #include #include #include "jsapi.h" #include "uthash.h" #include #ifdef ANDROID #include #endif #ifndef CCASSERT #define CCASSERT(a,b) assert(a) #endif #define PLUGINX_JSB_DEBUG 0 namespace pluginx { #if PLUGINX_JSB_DEBUG #ifdef ANDROID #define LOG_TAG "jsb_pluginx" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #else #define LOGD(...) printf(__VA_ARGS__) #endif #else #define LOGD(...) do {} while (0) #endif #define JSB_PRECONDITION( condition, ...) do { \ if( ! (condition) ) { \ LOGD("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ LOGD(__VA_ARGS__); \ JSContext* globalContext = ScriptingCore::getInstance()->getGlobalContext(); \ if( ! JS_IsExceptionPending( globalContext ) ) { \ JS_ReportError( globalContext, __VA_ARGS__ ); \ } \ return JS_FALSE; \ } \ } while(0) #define JSB_PRECONDITION2( condition, context, ret_value, ...) do { \ if( ! (condition) ) { \ LOGD("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ LOGD(__VA_ARGS__); \ if( ! JS_IsExceptionPending( context ) ) { \ JS_ReportError( context, __VA_ARGS__ ); \ } \ return ret_value; \ } \ } while(0) typedef struct js_proxy { void *ptr; JSObject *obj; UT_hash_handle hh; } js_proxy_t; extern js_proxy_t *_native_js_global_ht; extern js_proxy_t *_js_native_global_ht; typedef struct js_type_class { JSClass *jsclass; JSObject *proto; JSObject *parentProto; } js_type_class_t; extern std::unordered_map _js_global_type_map; unsigned int getHashCodeByString(const char *key); template< typename DERIVED > class TypeTest { public: static int s_id() { // return id unique for DERIVED // NOT SURE IT WILL BE REALLY UNIQUE FOR EACH CLASS!! /* Commented by James Chen Using 'getHashCodeByString(typeid(*native_obj).name())' instead of 'reinterpret_cast(typeid(*native_obj).name());'. Since on win32 platform, 'reinterpret_cast(typeid(*native_obj).name());' invoking in cocos2d.dll and outside cocos2d.dll(in TestJavascript.exe) will return different address. But the return string from typeid(*native_obj).name() is the same string, so we must convert the string to hash id to make sure we can get unique id. */ // static const long id = reinterpret_cast(typeid( DERIVED ).name()); static const long id = getHashCodeByString(typeid( DERIVED ).name()); return id; } static const char* s_name() { // return id unique for DERIVED // ALWAYS VALID BUT STRING, NOT INT - BUT VALID AND CROSS-PLATFORM/CROSS-VERSION COMPATBLE // AS FAR AS YOU KEEP THE CLASS NAME return typeid( DERIVED ).name(); } }; #define JS_NEW_PROXY(p, native_obj, js_obj) \ do { \ p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ assert(p); \ js_proxy_t* native_obj##js_obj##tmp = NULL; \ HASH_FIND_PTR(_native_js_global_ht, &native_obj, native_obj##js_obj##tmp); \ assert(!native_obj##js_obj##tmp); \ p->ptr = native_obj; \ p->obj = js_obj; \ HASH_ADD_PTR(_native_js_global_ht, ptr, p); \ p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ assert(p); \ native_obj##js_obj##tmp = NULL; \ HASH_FIND_PTR(_js_native_global_ht, &js_obj, native_obj##js_obj##tmp); \ assert(!native_obj##js_obj##tmp); \ p->ptr = native_obj; \ p->obj = js_obj; \ HASH_ADD_PTR(_js_native_global_ht, obj, p); \ } while(0) \ #define JS_GET_PROXY(p, native_obj) \ do { \ HASH_FIND_PTR(_native_js_global_ht, &native_obj, p); \ } while (0) #define JS_GET_NATIVE_PROXY(p, js_obj) \ do { \ HASH_FIND_PTR(_js_native_global_ht, &js_obj, p); \ } while (0) #define JS_REMOVE_PROXY(nproxy, jsproxy) \ do { \ if (nproxy) { HASH_DEL(_native_js_global_ht, nproxy); free(nproxy); } \ if (jsproxy) { HASH_DEL(_js_native_global_ht, jsproxy); free(jsproxy); } \ } while (0) #define JS_TEST_NATIVE_OBJECT(cx, native_obj) \ if (!native_obj) { \ JS_ReportError(cx, "Invalid Native Object"); \ return JS_FALSE; \ } js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj); js_proxy_t* jsb_get_native_proxy(void* nativeObj); js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy); /** * You don't need to manage the returned pointer. They live for the whole life of * the app. */ template inline js_type_class_t *js_get_type_from_native(T* native_obj) { bool found = false; std::string typeName = typeid(*native_obj).name(); auto typeProxyIter = _js_global_type_map.find(typeName); if (typeProxyIter == _js_global_type_map.end()) { typeName = typeid(T).name(); typeProxyIter = _js_global_type_map.find(typeName); if (typeProxyIter != _js_global_type_map.end()) { found = true; } } else { found = true; } return found ? typeProxyIter->second : nullptr; } /** * The returned pointer should be deleted using JS_REMOVE_PROXY. Most of the * time you do that in the C++ destructor. */ template inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) { js_proxy_t *proxy; HASH_FIND_PTR(_native_js_global_ht, &native_obj, proxy); if (!proxy) { js_type_class_t *typeProxy = js_get_type_from_native(native_obj); assert(typeProxy); JSObject* js_obj = JS_NewObject(cx, typeProxy->jsclass, typeProxy->proto, typeProxy->parentProto); JS_NEW_PROXY(proxy, native_obj, js_obj); //#ifdef COCOS2D_JAVASCRIPT // #ifdef DEBUG // JS_AddNamedObjectRoot(cx, &proxy->obj, typeid(*native_obj).name()); // #else // JS_AddObjectRoot(cx, &proxy->obj); // #endif //#endif return proxy; } else { return proxy; } return NULL; } } // namespace pluginx { #endif /* __JS_PLUGINX_SPIDERMONKEY_SPECIFICS_H__ */ ================================================ FILE: cocos2d/plugin/jsbindings/manual/pluginxUTF8.cpp ================================================ /* * This file uses some implementations of gutf8.c in glib. * * gutf8.c - Operations on UTF-8 strings. * * Copyright (C) 1999 Tom Tromey * Copyright (C) 2000 Red Hat, Inc. * * 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; either * version 2 of the License, or (at your option) any later version. * * 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "pluginxUTF8.h" namespace pluginx { #define CCLOGERROR(...) do {} while(0) #ifndef NULL #define NULL 0 #endif int cc_wcslen(const unsigned short* str) { int i=0; while(*str++) i++; return i; } /* Code from GLIB gutf8.c starts here. */ #define UTF8_COMPUTE(Char, Mask, Len) \ if (Char < 128) \ { \ Len = 1; \ Mask = 0x7f; \ } \ else if ((Char & 0xe0) == 0xc0) \ { \ Len = 2; \ Mask = 0x1f; \ } \ else if ((Char & 0xf0) == 0xe0) \ { \ Len = 3; \ Mask = 0x0f; \ } \ else if ((Char & 0xf8) == 0xf0) \ { \ Len = 4; \ Mask = 0x07; \ } \ else if ((Char & 0xfc) == 0xf8) \ { \ Len = 5; \ Mask = 0x03; \ } \ else if ((Char & 0xfe) == 0xfc) \ { \ Len = 6; \ Mask = 0x01; \ } \ else \ Len = -1; #define UTF8_LENGTH(Char) \ ((Char) < 0x80 ? 1 : \ ((Char) < 0x800 ? 2 : \ ((Char) < 0x10000 ? 3 : \ ((Char) < 0x200000 ? 4 : \ ((Char) < 0x4000000 ? 5 : 6))))) #define UTF8_GET(Result, Chars, Count, Mask, Len) \ (Result) = (Chars)[0] & (Mask); \ for ((Count) = 1; (Count) < (Len); ++(Count)) \ { \ if (((Chars)[(Count)] & 0xc0) != 0x80) \ { \ (Result) = -1; \ break; \ } \ (Result) <<= 6; \ (Result) |= ((Chars)[(Count)] & 0x3f); \ } #define UNICODE_VALID(Char) \ ((Char) < 0x110000 && \ (((Char) & 0xFFFFF800) != 0xD800) && \ ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ ((Char) & 0xFFFE) != 0xFFFE) static const char utf8_skip_data[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1 }; static const char *const g_utf8_skip = utf8_skip_data; #define cc_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(unsigned char *)(p)]) /* * @str: the string to search through. * @c: the character to find. * * Returns the index of the first occurrence of the character, if found. Otherwise -1 is returned. * * Return value: the index of the first occurrence of the character if found or -1 otherwise. * */ static unsigned int cc_utf8_find_char(std::vector str, unsigned short c) { unsigned int len = str.size(); for (unsigned int i = 0; i < len; ++i) if (str[i] == c) return i; return -1; } /* * @str: the string to search through. * @c: the character to not look for. * * Return value: the index of the last character that is not c. * */ unsigned int cc_utf8_find_last_not_char(std::vector str, unsigned short c) { int len = str.size(); int i = len - 1; for (; i >= 0; --i) if (str[i] != c) return i; return i; } /* * @str: the string to trim * @index: the index to start trimming from. * * Trims str st str=[0, index) after the operation. * * Return value: the trimmed string. * */ static void cc_utf8_trim_from(std::vector* str, int index) { int size = str->size(); if (index >= size || index < 0) return; str->erase(str->begin() + index, str->begin() + size); } /* * @ch is the unicode character whitespace? * * Reference: http://en.wikipedia.org/wiki/Whitespace_character#Unicode * * Return value: weather the character is a whitespace character. * */ bool isspace_unicode(unsigned short ch) { return (ch >= 0x0009 && ch <= 0x000D) || ch == 0x0020 || ch == 0x0085 || ch == 0x00A0 || ch == 0x1680 || (ch >= 0x2000 && ch <= 0x200A) || ch == 0x2028 || ch == 0x2029 || ch == 0x202F || ch == 0x205F || ch == 0x3000; } void cc_utf8_trim_ws(std::vector* str) { int len = str->size(); if ( len <= 0 ) return; int last_index = len - 1; // Only start trimming if the last character is whitespace.. if (isspace_unicode((*str)[last_index])) { for (int i = last_index - 1; i >= 0; --i) { if (isspace_unicode((*str)[i])) last_index = i; else break; } cc_utf8_trim_from(str, last_index); } } /* * cc_utf8_strlen: * @p: pointer to the start of a UTF-8 encoded string. * @max: the maximum number of bytes to examine. If @max * is less than 0, then the string is assumed to be * null-terminated. If @max is 0, @p will not be examined and * may be %NULL. * * Returns the length of the string in characters. * * Return value: the length of the string in characters **/ long cc_utf8_strlen (const char * p, int max) { long len = 0; const char *start = p; if (!(p != NULL || max == 0)) { return 0; } if (max < 0) { while (*p) { p = cc_utf8_next_char (p); ++len; } } else { if (max == 0 || !*p) return 0; p = cc_utf8_next_char (p); while (p - start < max && *p) { ++len; p = cc_utf8_next_char (p); } /* only do the last len increment if we got a complete * char (don't count partial chars) */ if (p - start == max) ++len; } return len; } /* * g_utf8_get_char: * @p: a pointer to Unicode character encoded as UTF-8 * * Converts a sequence of bytes encoded as UTF-8 to a Unicode character. * If @p does not point to a valid UTF-8 encoded character, results are * undefined. If you are not sure that the bytes are complete * valid Unicode characters, you should use g_utf8_get_char_validated() * instead. * * Return value: the resulting character **/ static unsigned int cc_utf8_get_char (const char * p) { int i, mask = 0, len; unsigned int result; unsigned char c = (unsigned char) *p; UTF8_COMPUTE (c, mask, len); if (len == -1) return (unsigned int) - 1; UTF8_GET (result, p, i, mask, len); return result; } unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1 */, int* rUtf16Size/* = NULL */) { int len = cc_utf8_strlen(str_old, length); if (rUtf16Size != NULL) { *rUtf16Size = len; } unsigned short* str_new = new unsigned short[len + 1]; str_new[len] = 0; for (int i = 0; i < len; ++i) { str_new[i] = cc_utf8_get_char(str_old); str_old = cc_utf8_next_char(str_old); } return str_new; } std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str) { int len = cc_wcslen(str); std::vector str_new; for (int i = 0; i < len; ++i) { str_new.push_back(str[i]); } return str_new; } /** * cc_unichar_to_utf8: * @c: a ISO10646 character code * @outbuf: output buffer, must have at least 6 bytes of space. * If %NULL, the length will be computed and returned * and nothing will be written to @outbuf. * * Converts a single character to UTF-8. * * Return value: number of bytes written **/ int cc_unichar_to_utf8 (unsigned short c, char *outbuf) { unsigned int len = 0; int first; int i; if (c < 0x80) { first = 0; len = 1; } else if (c < 0x800) { first = 0xc0; len = 2; } else if (c < 0x10000) { first = 0xe0; len = 3; } else if (c < 0x200000) { first = 0xf0; len = 4; } else if (c < 0x4000000) { first = 0xf8; len = 5; } else { first = 0xfc; len = 6; } if (outbuf) { for (i = len - 1; i > 0; --i) { outbuf[i] = (c & 0x3f) | 0x80; c >>= 6; } outbuf[0] = c | first; } return len; } #define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000) /** * cc_utf16_to_utf8: * @str: a UTF-16 encoded string * @len: the maximum length of @str to use. If @len < 0, then * the string is terminated with a 0 character. * @items_read: location to store number of words read, or %NULL. * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be * returned in case @str contains a trailing partial * character. If an error occurs then the index of the * invalid input is stored here. * @items_written: location to store number of bytes written, or %NULL. * The value stored here does not include the trailing * 0 byte. * @error: location to store the error occuring, or %NULL to ignore * errors. Any of the errors in #GConvertError other than * %G_CONVERT_ERROR_NO_CONVERSION may occur. * * Convert a string from UTF-16 to UTF-8. The result will be * terminated with a 0 byte. * * Return value: a pointer to a newly allocated UTF-8 string. * This value must be freed with free(). If an * error occurs, %NULL will be returned and * @error set. **/ char * cc_utf16_to_utf8 (const unsigned short *str, long len, long *items_read, long *items_written) { /* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ * are marked. */ const unsigned short *in; char *out; char *result = NULL; int n_bytes; unsigned short high_surrogate; if (str == 0) return NULL; n_bytes = 0; in = str; high_surrogate = 0; while ((len < 0 || in - str < len) && *in) { unsigned short c = *in; unsigned short wc; if (c >= 0xdc00 && c < 0xe000) /* low surrogate */ { if (high_surrogate) { wc = SURROGATE_VALUE (high_surrogate, c); high_surrogate = 0; } else { CCLOGERROR("Invalid sequence in conversion input"); goto err_out; } } else { if (high_surrogate) { CCLOGERROR("Invalid sequence in conversion input"); goto err_out; } if (c >= 0xd800 && c < 0xdc00) /* high surrogate */ { high_surrogate = c; goto next1; } else wc = c; } /********** DIFFERENT for UTF8/UCS4 **********/ n_bytes += UTF8_LENGTH (wc); next1: in++; } if (high_surrogate && !items_read) { CCLOGERROR("Partial character sequence at end of input"); goto err_out; } /* At this point, everything is valid, and we just need to convert */ /********** DIFFERENT for UTF8/UCS4 **********/ result = new char[n_bytes + 1]; high_surrogate = 0; out = result; in = str; while (out < result + n_bytes) { unsigned short c = *in; unsigned short wc; if (c >= 0xdc00 && c < 0xe000) /* low surrogate */ { wc = SURROGATE_VALUE (high_surrogate, c); high_surrogate = 0; } else if (c >= 0xd800 && c < 0xdc00) /* high surrogate */ { high_surrogate = c; goto next2; } else wc = c; /********** DIFFERENT for UTF8/UCS4 **********/ out += cc_unichar_to_utf8 (wc, out); next2: in++; } /********** DIFFERENT for UTF8/UCS4 **********/ *out = '\0'; if (items_written) /********** DIFFERENT for UTF8/UCS4 **********/ *items_written = out - result; err_out: if (items_read) *items_read = in - str; return result; } }// namespace pluginx { ================================================ FILE: cocos2d/plugin/jsbindings/manual/pluginxUTF8.h ================================================ // // ccUTF8.h // cocos2dx // // Created by James Chen on 2/27/13. // #ifndef __pluginx__ccUTF8__ #define __pluginx__ccUTF8__ #include namespace pluginx { int cc_wcslen(const unsigned short* str); void cc_utf8_trim_ws(std::vector* str); /* * @ch is the unicode character whitespace? * * Reference: http://en.wikipedia.org/wiki/Whitespace_character#Unicode * * Return value: weather the character is a whitespace character. * */ bool isspace_unicode(unsigned short ch); /* * cc_utf8_strlen: * @p: pointer to the start of a UTF-8 encoded string. * @max: the maximum number of bytes to examine. If @max * is less than 0, then the string is assumed to be * null-terminated. If @max is 0, @p will not be examined and * may be %NULL. * * Returns the length of the string in characters. * * Return value: the length of the string in characters **/ long cc_utf8_strlen (const char * p, int max); /* * @str: the string to search through. * @c: the character to not look for. * * Return value: the index of the last character that is not c. * */ unsigned int cc_utf8_find_last_not_char(std::vector str, unsigned short c); std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str); /* * cc_utf8_to_utf16: * @str_old: pointer to the start of a C string. * * Creates a utf8 string from a cstring. * * Return value: the newly created utf8 string. * */ unsigned short* cc_utf8_to_utf16(const char* str_old, int length = -1, int* rUtf16Size = 0); /** * cc_utf16_to_utf8: * @str: a UTF-16 encoded string * @len: the maximum length of @str to use. If @len < 0, then * the string is terminated with a 0 character. * @items_read: location to store number of words read, or %NULL. * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be * returned in case @str contains a trailing partial * character. If an error occurs then the index of the * invalid input is stored here. * @items_written: location to store number of bytes written, or %NULL. * The value stored here does not include the trailing * 0 byte. * @error: location to store the error occuring, or %NULL to ignore * errors. Any of the errors in #GConvertError other than * %G_CONVERT_ERROR_NO_CONVERSION may occur. * * Convert a string from UTF-16 to UTF-8. The result will be * terminated with a 0 byte. * * Return value: a pointer to a newly allocated UTF-8 string. * This value must be freed with free(). If an * error occurs, %NULL will be returned and * @error set. **/ char * cc_utf16_to_utf8 (const unsigned short *str, long len, long *items_read, long *items_written); } // namespace pluginx { #endif /* defined(__cocos2dx__ccUTF8__) */ ================================================ FILE: cocos2d/plugin/jsbindings/manual/uthash.h ================================================ /* Copyright (c) 2003-2013, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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 UTHASH_H #define UTHASH_H #include /* memcmp,strlen */ #include /* ptrdiff_t */ #include /* exit() */ /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed or, for VS2008 where neither is available, uses casting workarounds. */ #ifdef _MSC_VER /* MS compiler */ #if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */ #define DECLTYPE(x) (decltype(x)) #else /* VS2008 or older (or VS2010 in C mode) */ #define NO_DECLTYPE #define DECLTYPE(x) #endif #else /* GNU, Sun and other compilers */ #define DECLTYPE(x) (__typeof(x)) #endif #ifdef NO_DECLTYPE #define DECLTYPE_ASSIGN(dst,src) \ do { \ char **_da_dst = (char**)(&(dst)); \ *_da_dst = (char*)(src); \ } while(0) #else #define DECLTYPE_ASSIGN(dst,src) \ do { \ (dst) = DECLTYPE(dst)(src); \ } while(0) #endif /* a number of the hash function use uint32_t which isn't defined on win32 */ #ifdef _MSC_VER typedef unsigned int uint32_t; typedef unsigned char uint8_t; #else #include /* uint32_t */ #endif #define UTHASH_VERSION 1.9.8 #ifndef uthash_fatal #define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ #endif #ifndef uthash_malloc #define uthash_malloc(sz) malloc(sz) /* malloc fcn */ #endif #ifndef uthash_free #define uthash_free(ptr,sz) free(ptr) /* free fcn */ #endif #ifndef uthash_noexpand_fyi #define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ #endif #ifndef uthash_expand_fyi #define uthash_expand_fyi(tbl) /* can be defined to log expands */ #endif /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS 32 /* initial number of buckets */ #define HASH_INITIAL_NUM_BUCKETS_LOG2 5 /* lg2 of initial number of buckets */ #define HASH_BKT_CAPACITY_THRESH 10 /* expand when bucket count reaches */ /* calculate the element whose hash handle address is hhe */ #define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) #define HASH_FIND(hh,head,keyptr,keylen,out) \ do { \ unsigned _hf_bkt,_hf_hashv; \ out=NULL; \ if (head) { \ HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \ if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \ HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \ keyptr,keylen,out); \ } \ } \ } while (0) #ifdef HASH_BLOOM #define HASH_BLOOM_BITLEN (1ULL << HASH_BLOOM) #define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8) + ((HASH_BLOOM_BITLEN%8) ? 1:0) #define HASH_BLOOM_MAKE(tbl) \ do { \ (tbl)->bloom_nbits = HASH_BLOOM; \ (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \ memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \ (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ } while (0) #define HASH_BLOOM_FREE(tbl) \ do { \ uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \ } while (0) #define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8))) #define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8))) #define HASH_BLOOM_ADD(tbl,hashv) \ HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) #define HASH_BLOOM_TEST(tbl,hashv) \ HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) #else #define HASH_BLOOM_MAKE(tbl) #define HASH_BLOOM_FREE(tbl) #define HASH_BLOOM_ADD(tbl,hashv) #define HASH_BLOOM_TEST(tbl,hashv) (1) #define HASH_BLOOM_BYTELEN 0 #endif #define HASH_MAKE_TABLE(hh,head) \ do { \ (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \ sizeof(UT_hash_table)); \ if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \ memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \ (head)->hh.tbl->tail = &((head)->hh); \ (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \ memset((head)->hh.tbl->buckets, 0, \ HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ HASH_BLOOM_MAKE((head)->hh.tbl); \ (head)->hh.tbl->signature = HASH_SIGNATURE; \ } while(0) #define HASH_ADD(hh,head,fieldname,keylen_in,add) \ HASH_ADD_KEYPTR(hh,head,&((add)->fieldname),keylen_in,add) #define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \ do { \ replaced=NULL; \ HASH_FIND(hh,head,&((add)->fieldname),keylen_in,replaced); \ if (replaced!=NULL) { \ HASH_DELETE(hh,head,replaced); \ }; \ HASH_ADD(hh,head,fieldname,keylen_in,add); \ } while(0) #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ do { \ unsigned _ha_bkt; \ (add)->hh.next = NULL; \ (add)->hh.key = (char*)keyptr; \ (add)->hh.keylen = (unsigned)keylen_in; \ if (!(head)) { \ head = (add); \ (head)->hh.prev = NULL; \ HASH_MAKE_TABLE(hh,head); \ } else { \ (head)->hh.tbl->tail->next = (add); \ (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ (head)->hh.tbl->tail = &((add)->hh); \ } \ (head)->hh.tbl->num_items++; \ (add)->hh.tbl = (head)->hh.tbl; \ HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \ (add)->hh.hashv, _ha_bkt); \ HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \ HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \ HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \ HASH_FSCK(hh,head); \ } while(0) #define HASH_TO_BKT( hashv, num_bkts, bkt ) \ do { \ bkt = ((hashv) & ((num_bkts) - 1)); \ } while(0) /* delete "delptr" from the hash table. * "the usual" patch-up process for the app-order doubly-linked-list. * The use of _hd_hh_del below deserves special explanation. * These used to be expressed using (delptr) but that led to a bug * if someone used the same symbol for the head and deletee, like * HASH_DELETE(hh,users,users); * We want that to work, but by changing the head (users) below * we were forfeiting our ability to further refer to the deletee (users) * in the patch-up process. Solution: use scratch space to * copy the deletee pointer, then the latter references are via that * scratch pointer rather than through the repointed (users) symbol. */ #define HASH_DELETE(hh,head,delptr) \ do { \ unsigned _hd_bkt; \ struct UT_hash_handle *_hd_hh_del; \ if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \ uthash_free((head)->hh.tbl->buckets, \ (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \ HASH_BLOOM_FREE((head)->hh.tbl); \ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ head = NULL; \ } else { \ _hd_hh_del = &((delptr)->hh); \ if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \ (head)->hh.tbl->tail = \ (UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \ (head)->hh.tbl->hho); \ } \ if ((delptr)->hh.prev) { \ ((UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \ (head)->hh.tbl->hho))->next = (delptr)->hh.next; \ } else { \ DECLTYPE_ASSIGN(head,(delptr)->hh.next); \ } \ if (_hd_hh_del->next) { \ ((UT_hash_handle*)((ptrdiff_t)_hd_hh_del->next + \ (head)->hh.tbl->hho))->prev = \ _hd_hh_del->prev; \ } \ HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ (head)->hh.tbl->num_items--; \ } \ HASH_FSCK(hh,head); \ } while (0) /* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ #define HASH_FIND_STR(head,findstr,out) \ HASH_FIND(hh,head,findstr,strlen(findstr),out) #define HASH_ADD_STR(head,strfield,add) \ HASH_ADD(hh,head,strfield,strlen(add->strfield),add) #define HASH_REPLACE_STR(head,strfield,add,replaced) \ HASH_REPLACE(hh,head,strfield,strlen(add->strfield),add,replaced) #define HASH_FIND_INT(head,findint,out) \ HASH_FIND(hh,head,findint,sizeof(int),out) #define HASH_ADD_INT(head,intfield,add) \ HASH_ADD(hh,head,intfield,sizeof(int),add) #define HASH_REPLACE_INT(head,intfield,add,replaced) \ HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced) #define HASH_FIND_PTR(head,findptr,out) \ HASH_FIND(hh,head,findptr,sizeof(void *),out) #define HASH_ADD_PTR(head,ptrfield,add) \ HASH_ADD(hh,head,ptrfield,sizeof(void *),add) #define HASH_REPLACE_PTR(head,ptrfield,add) \ HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced) #define HASH_DEL(head,delptr) \ HASH_DELETE(hh,head,delptr) /* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined. * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. */ #ifdef HASH_DEBUG #define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) #define HASH_FSCK(hh,head) \ do { \ unsigned _bkt_i; \ unsigned _count, _bkt_count; \ char *_prev; \ struct UT_hash_handle *_thh; \ if (head) { \ _count = 0; \ for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \ _bkt_count = 0; \ _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ _prev = NULL; \ while (_thh) { \ if (_prev != (char*)(_thh->hh_prev)) { \ HASH_OOPS("invalid hh_prev %p, actual %p\n", \ _thh->hh_prev, _prev ); \ } \ _bkt_count++; \ _prev = (char*)(_thh); \ _thh = _thh->hh_next; \ } \ _count += _bkt_count; \ if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ HASH_OOPS("invalid bucket count %d, actual %d\n", \ (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ } \ } \ if (_count != (head)->hh.tbl->num_items) { \ HASH_OOPS("invalid hh item count %d, actual %d\n", \ (head)->hh.tbl->num_items, _count ); \ } \ /* traverse hh in app order; check next/prev integrity, count */ \ _count = 0; \ _prev = NULL; \ _thh = &(head)->hh; \ while (_thh) { \ _count++; \ if (_prev !=(char*)(_thh->prev)) { \ HASH_OOPS("invalid prev %p, actual %p\n", \ _thh->prev, _prev ); \ } \ _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \ _thh = ( _thh->next ? (UT_hash_handle*)((char*)(_thh->next) + \ (head)->hh.tbl->hho) : NULL ); \ } \ if (_count != (head)->hh.tbl->num_items) { \ HASH_OOPS("invalid app item count %d, actual %d\n", \ (head)->hh.tbl->num_items, _count ); \ } \ } \ } while (0) #else #define HASH_FSCK(hh,head) #endif /* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to * the descriptor to which this macro is defined for tuning the hash function. * The app can #include to get the prototype for write(2). */ #ifdef HASH_EMIT_KEYS #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ do { \ unsigned _klen = fieldlen; \ write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ write(HASH_EMIT_KEYS, keyptr, fieldlen); \ } while (0) #else #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) #endif /* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ #ifdef HASH_FUNCTION #define HASH_FCN HASH_FUNCTION #else #define HASH_FCN HASH_JEN #endif /* The Bernstein hash function, used in Perl prior to v5.6 */ #define HASH_BER(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _hb_keylen=keylen; \ char *_hb_key=(char*)(key); \ (hashv) = 0; \ while (_hb_keylen--) { (hashv) = ((hashv) * 33) + *_hb_key++; } \ bkt = (hashv) & (num_bkts-1); \ } while (0) /* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ #define HASH_SAX(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _sx_i; \ char *_hs_key=(char*)(key); \ hashv = 0; \ for(_sx_i=0; _sx_i < keylen; _sx_i++) \ hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ bkt = hashv & (num_bkts-1); \ } while (0) #define HASH_FNV(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _fn_i; \ char *_hf_key=(char*)(key); \ hashv = 2166136261UL; \ for(_fn_i=0; _fn_i < keylen; _fn_i++) \ hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \ bkt = hashv & (num_bkts-1); \ } while(0) #define HASH_OAT(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _ho_i; \ char *_ho_key=(char*)(key); \ hashv = 0; \ for(_ho_i=0; _ho_i < keylen; _ho_i++) { \ hashv += _ho_key[_ho_i]; \ hashv += (hashv << 10); \ hashv ^= (hashv >> 6); \ } \ hashv += (hashv << 3); \ hashv ^= (hashv >> 11); \ hashv += (hashv << 15); \ bkt = hashv & (num_bkts-1); \ } while(0) #define HASH_JEN_MIX(a,b,c) \ do { \ a -= b; a -= c; a ^= ( c >> 13 ); \ b -= c; b -= a; b ^= ( a << 8 ); \ c -= a; c -= b; c ^= ( b >> 13 ); \ a -= b; a -= c; a ^= ( c >> 12 ); \ b -= c; b -= a; b ^= ( a << 16 ); \ c -= a; c -= b; c ^= ( b >> 5 ); \ a -= b; a -= c; a ^= ( c >> 3 ); \ b -= c; b -= a; b ^= ( a << 10 ); \ c -= a; c -= b; c ^= ( b >> 15 ); \ } while (0) #define HASH_JEN(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned _hj_i,_hj_j,_hj_k; \ unsigned char *_hj_key=(unsigned char*)(key); \ hashv = 0xfeedbeef; \ _hj_i = _hj_j = 0x9e3779b9; \ _hj_k = (unsigned)keylen; \ while (_hj_k >= 12) { \ _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \ + ( (unsigned)_hj_key[2] << 16 ) \ + ( (unsigned)_hj_key[3] << 24 ) ); \ _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \ + ( (unsigned)_hj_key[6] << 16 ) \ + ( (unsigned)_hj_key[7] << 24 ) ); \ hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \ + ( (unsigned)_hj_key[10] << 16 ) \ + ( (unsigned)_hj_key[11] << 24 ) ); \ \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ \ _hj_key += 12; \ _hj_k -= 12; \ } \ hashv += keylen; \ switch ( _hj_k ) { \ case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); \ case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); \ case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); \ case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); \ case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); \ case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); \ case 5: _hj_j += _hj_key[4]; \ case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); \ case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); \ case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); \ case 1: _hj_i += _hj_key[0]; \ } \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ bkt = hashv & (num_bkts-1); \ } while(0) /* The Paul Hsieh hash function */ #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) #define get16bits(d) (*((const uint16_t *) (d))) #endif #if !defined (get16bits) #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \ +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif #define HASH_SFH(key,keylen,num_bkts,hashv,bkt) \ do { \ unsigned char *_sfh_key=(unsigned char*)(key); \ uint32_t _sfh_tmp, _sfh_len = keylen; \ \ int _sfh_rem = _sfh_len & 3; \ _sfh_len >>= 2; \ hashv = 0xcafebabe; \ \ /* Main loop */ \ for (;_sfh_len > 0; _sfh_len--) { \ hashv += get16bits (_sfh_key); \ _sfh_tmp = (uint32_t)(get16bits (_sfh_key+2)) << 11 ^ hashv; \ hashv = (hashv << 16) ^ _sfh_tmp; \ _sfh_key += 2*sizeof (uint16_t); \ hashv += hashv >> 11; \ } \ \ /* Handle end cases */ \ switch (_sfh_rem) { \ case 3: hashv += get16bits (_sfh_key); \ hashv ^= hashv << 16; \ hashv ^= (uint32_t)(_sfh_key[sizeof (uint16_t)] << 18); \ hashv += hashv >> 11; \ break; \ case 2: hashv += get16bits (_sfh_key); \ hashv ^= hashv << 11; \ hashv += hashv >> 17; \ break; \ case 1: hashv += *_sfh_key; \ hashv ^= hashv << 10; \ hashv += hashv >> 1; \ } \ \ /* Force "avalanching" of final 127 bits */ \ hashv ^= hashv << 3; \ hashv += hashv >> 5; \ hashv ^= hashv << 4; \ hashv += hashv >> 17; \ hashv ^= hashv << 25; \ hashv += hashv >> 6; \ bkt = hashv & (num_bkts-1); \ } while(0) #ifdef HASH_USING_NO_STRICT_ALIASING /* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. * MurmurHash uses the faster approach only on CPU's where we know it's safe. * * Note the preprocessor built-in defines can be emitted using: * * gcc -m64 -dM -E - < /dev/null (on gcc) * cc -## a.c (where a.c is a simple test file) (Sun Studio) */ #if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)) #define MUR_GETBLOCK(p,i) p[i] #else /* non intel */ #define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 0x3) == 0) #define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 0x3) == 1) #define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 0x3) == 2) #define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 0x3) == 3) #define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) #if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) #define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) #define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) #define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) #else /* assume little endian non-intel */ #define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) #define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) #define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) #endif #define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \ (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ MUR_ONE_THREE(p)))) #endif #define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) #define MUR_FMIX(_h) \ do { \ _h ^= _h >> 16; \ _h *= 0x85ebca6b; \ _h ^= _h >> 13; \ _h *= 0xc2b2ae35l; \ _h ^= _h >> 16; \ } while(0) #define HASH_MUR(key,keylen,num_bkts,hashv,bkt) \ do { \ const uint8_t *_mur_data = (const uint8_t*)(key); \ const int _mur_nblocks = (keylen) / 4; \ uint32_t _mur_h1 = 0xf88D5353; \ uint32_t _mur_c1 = 0xcc9e2d51; \ uint32_t _mur_c2 = 0x1b873593; \ uint32_t _mur_k1 = 0; \ const uint8_t *_mur_tail; \ const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+_mur_nblocks*4); \ int _mur_i; \ for(_mur_i = -_mur_nblocks; _mur_i; _mur_i++) { \ _mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \ _mur_k1 *= _mur_c1; \ _mur_k1 = MUR_ROTL32(_mur_k1,15); \ _mur_k1 *= _mur_c2; \ \ _mur_h1 ^= _mur_k1; \ _mur_h1 = MUR_ROTL32(_mur_h1,13); \ _mur_h1 = _mur_h1*5+0xe6546b64; \ } \ _mur_tail = (const uint8_t*)(_mur_data + _mur_nblocks*4); \ _mur_k1=0; \ switch((keylen) & 3) { \ case 3: _mur_k1 ^= _mur_tail[2] << 16; \ case 2: _mur_k1 ^= _mur_tail[1] << 8; \ case 1: _mur_k1 ^= _mur_tail[0]; \ _mur_k1 *= _mur_c1; \ _mur_k1 = MUR_ROTL32(_mur_k1,15); \ _mur_k1 *= _mur_c2; \ _mur_h1 ^= _mur_k1; \ } \ _mur_h1 ^= (keylen); \ MUR_FMIX(_mur_h1); \ hashv = _mur_h1; \ bkt = hashv & (num_bkts-1); \ } while(0) #endif /* HASH_USING_NO_STRICT_ALIASING */ /* key comparison function; return 0 if keys equal */ #define HASH_KEYCMP(a,b,len) memcmp(a,b,len) /* iterate over items in a known bucket to find desired item */ #define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \ do { \ if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \ else out=NULL; \ while (out) { \ if ((out)->hh.keylen == keylen_in) { \ if ((HASH_KEYCMP((out)->hh.key,keyptr,keylen_in)) == 0) break; \ } \ if ((out)->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,(out)->hh.hh_next)); \ else out = NULL; \ } \ } while(0) /* add an item to a bucket */ #define HASH_ADD_TO_BKT(head,addhh) \ do { \ head.count++; \ (addhh)->hh_next = head.hh_head; \ (addhh)->hh_prev = NULL; \ if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \ (head).hh_head=addhh; \ if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \ && (addhh)->tbl->noexpand != 1) { \ HASH_EXPAND_BUCKETS((addhh)->tbl); \ } \ } while(0) /* remove an item from a given bucket */ #define HASH_DEL_IN_BKT(hh,head,hh_del) \ (head).count--; \ if ((head).hh_head == hh_del) { \ (head).hh_head = hh_del->hh_next; \ } \ if (hh_del->hh_prev) { \ hh_del->hh_prev->hh_next = hh_del->hh_next; \ } \ if (hh_del->hh_next) { \ hh_del->hh_next->hh_prev = hh_del->hh_prev; \ } /* Bucket expansion has the effect of doubling the number of buckets * and redistributing the items into the new buckets. Ideally the * items will distribute more or less evenly into the new buckets * (the extent to which this is true is a measure of the quality of * the hash function as it applies to the key domain). * * With the items distributed into more buckets, the chain length * (item count) in each bucket is reduced. Thus by expanding buckets * the hash keeps a bound on the chain length. This bounded chain * length is the essence of how a hash provides constant time lookup. * * The calculation of tbl->ideal_chain_maxlen below deserves some * explanation. First, keep in mind that we're calculating the ideal * maximum chain length based on the *new* (doubled) bucket count. * In fractions this is just n/b (n=number of items,b=new num buckets). * Since the ideal chain length is an integer, we want to calculate * ceil(n/b). We don't depend on floating point arithmetic in this * hash, so to calculate ceil(n/b) with integers we could write * * ceil(n/b) = (n/b) + ((n%b)?1:0) * * and in fact a previous version of this hash did just that. * But now we have improved things a bit by recognizing that b is * always a power of two. We keep its base 2 log handy (call it lb), * so now we can write this with a bit shift and logical AND: * * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) * */ #define HASH_EXPAND_BUCKETS(tbl) \ do { \ unsigned _he_bkt; \ unsigned _he_bkt_i; \ struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ if (!_he_new_buckets) { uthash_fatal( "out of memory"); } \ memset(_he_new_buckets, 0, \ 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ tbl->ideal_chain_maxlen = \ (tbl->num_items >> (tbl->log2_num_buckets+1)) + \ ((tbl->num_items & ((tbl->num_buckets*2)-1)) ? 1 : 0); \ tbl->nonideal_items = 0; \ for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \ { \ _he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \ while (_he_thh) { \ _he_hh_nxt = _he_thh->hh_next; \ HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \ _he_newbkt = &(_he_new_buckets[ _he_bkt ]); \ if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \ tbl->nonideal_items++; \ _he_newbkt->expand_mult = _he_newbkt->count / \ tbl->ideal_chain_maxlen; \ } \ _he_thh->hh_prev = NULL; \ _he_thh->hh_next = _he_newbkt->hh_head; \ if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \ _he_thh; \ _he_newbkt->hh_head = _he_thh; \ _he_thh = _he_hh_nxt; \ } \ } \ uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \ tbl->num_buckets *= 2; \ tbl->log2_num_buckets++; \ tbl->buckets = _he_new_buckets; \ tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \ (tbl->ineff_expands+1) : 0; \ if (tbl->ineff_expands > 1) { \ tbl->noexpand=1; \ uthash_noexpand_fyi(tbl); \ } \ uthash_expand_fyi(tbl); \ } while(0) /* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ /* Note that HASH_SORT assumes the hash handle name to be hh. * HASH_SRT was added to allow the hash handle name to be passed in. */ #define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) #define HASH_SRT(hh,head,cmpfcn) \ do { \ unsigned _hs_i; \ unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \ struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ if (head) { \ _hs_insize = 1; \ _hs_looping = 1; \ _hs_list = &((head)->hh); \ while (_hs_looping) { \ _hs_p = _hs_list; \ _hs_list = NULL; \ _hs_tail = NULL; \ _hs_nmerges = 0; \ while (_hs_p) { \ _hs_nmerges++; \ _hs_q = _hs_p; \ _hs_psize = 0; \ for ( _hs_i = 0; _hs_i < _hs_insize; _hs_i++ ) { \ _hs_psize++; \ _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ ((void*)((char*)(_hs_q->next) + \ (head)->hh.tbl->hho)) : NULL); \ if (! (_hs_q) ) break; \ } \ _hs_qsize = _hs_insize; \ while ((_hs_psize > 0) || ((_hs_qsize > 0) && _hs_q )) { \ if (_hs_psize == 0) { \ _hs_e = _hs_q; \ _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ ((void*)((char*)(_hs_q->next) + \ (head)->hh.tbl->hho)) : NULL); \ _hs_qsize--; \ } else if ( (_hs_qsize == 0) || !(_hs_q) ) { \ _hs_e = _hs_p; \ _hs_p = (UT_hash_handle*)((_hs_p->next) ? \ ((void*)((char*)(_hs_p->next) + \ (head)->hh.tbl->hho)) : NULL); \ _hs_psize--; \ } else if (( \ cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \ DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \ ) <= 0) { \ _hs_e = _hs_p; \ _hs_p = (UT_hash_handle*)((_hs_p->next) ? \ ((void*)((char*)(_hs_p->next) + \ (head)->hh.tbl->hho)) : NULL); \ _hs_psize--; \ } else { \ _hs_e = _hs_q; \ _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ ((void*)((char*)(_hs_q->next) + \ (head)->hh.tbl->hho)) : NULL); \ _hs_qsize--; \ } \ if ( _hs_tail ) { \ _hs_tail->next = ((_hs_e) ? \ ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \ } else { \ _hs_list = _hs_e; \ } \ _hs_e->prev = ((_hs_tail) ? \ ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \ _hs_tail = _hs_e; \ } \ _hs_p = _hs_q; \ } \ _hs_tail->next = NULL; \ if ( _hs_nmerges <= 1 ) { \ _hs_looping=0; \ (head)->hh.tbl->tail = _hs_tail; \ DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ } \ _hs_insize *= 2; \ } \ HASH_FSCK(hh,head); \ } \ } while (0) /* This function selects items from one hash into another hash. * The end result is that the selected items have dual presence * in both hashes. There is no copy of the items made; rather * they are added into the new hash through a secondary hash * hash handle that must be present in the structure. */ #define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ do { \ unsigned _src_bkt, _dst_bkt; \ void *_last_elt=NULL, *_elt; \ UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \ ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \ if (src) { \ for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \ _src_hh; \ _src_hh = _src_hh->hh_next) { \ _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ if (cond(_elt)) { \ _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ _dst_hh->key = _src_hh->key; \ _dst_hh->keylen = _src_hh->keylen; \ _dst_hh->hashv = _src_hh->hashv; \ _dst_hh->prev = _last_elt; \ _dst_hh->next = NULL; \ if (_last_elt_hh) { _last_elt_hh->next = _elt; } \ if (!dst) { \ DECLTYPE_ASSIGN(dst,_elt); \ HASH_MAKE_TABLE(hh_dst,dst); \ } else { \ _dst_hh->tbl = (dst)->hh_dst.tbl; \ } \ HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \ (dst)->hh_dst.tbl->num_items++; \ _last_elt = _elt; \ _last_elt_hh = _dst_hh; \ } \ } \ } \ } \ HASH_FSCK(hh_dst,dst); \ } while (0) #define HASH_CLEAR(hh,head) \ do { \ if (head) { \ uthash_free((head)->hh.tbl->buckets, \ (head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \ HASH_BLOOM_FREE((head)->hh.tbl); \ uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \ (head)=NULL; \ } \ } while(0) #define HASH_OVERHEAD(hh,head) \ (size_t)((((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \ ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \ (sizeof(UT_hash_table)) + \ (HASH_BLOOM_BYTELEN))) #ifdef NO_DECLTYPE #define HASH_ITER(hh,head,el,tmp) \ for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \ el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL)) #else #define HASH_ITER(hh,head,el,tmp) \ for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \ el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)->hh.next:NULL)) #endif /* obtain a count of items in the hash */ #define HASH_COUNT(head) HASH_CNT(hh,head) #define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0) typedef struct UT_hash_bucket { struct UT_hash_handle *hh_head; unsigned count; /* expand_mult is normally set to 0. In this situation, the max chain length * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If * the bucket's chain exceeds this length, bucket expansion is triggered). * However, setting expand_mult to a non-zero value delays bucket expansion * (that would be triggered by additions to this particular bucket) * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. * (The multiplier is simply expand_mult+1). The whole idea of this * multiplier is to reduce bucket expansions, since they are expensive, in * situations where we know that a particular bucket tends to be overused. * It is better to let its chain length grow to a longer yet-still-bounded * value, than to do an O(n) bucket expansion too often. */ unsigned expand_mult; } UT_hash_bucket; /* random signature used only to find hash tables in external analysis */ #define HASH_SIGNATURE 0xa0111fe1 #define HASH_BLOOM_SIGNATURE 0xb12220f2 typedef struct UT_hash_table { UT_hash_bucket *buckets; unsigned num_buckets, log2_num_buckets; unsigned num_items; struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ /* in an ideal situation (all buckets used equally), no bucket would have * more than ceil(#items/#buckets) items. that's the ideal chain length. */ unsigned ideal_chain_maxlen; /* nonideal_items is the number of items in the hash whose chain position * exceeds the ideal chain maxlen. these items pay the penalty for an uneven * hash distribution; reaching them in a chain traversal takes >ideal steps */ unsigned nonideal_items; /* ineffective expands occur when a bucket doubling was performed, but * afterward, more than half the items in the hash had nonideal chain * positions. If this happens on two consecutive expansions we inhibit any * further expansion, as it's not helping; this happens when the hash * function isn't a good fit for the key domain. When expansion is inhibited * the hash will still work, albeit no longer in constant time. */ unsigned ineff_expands, noexpand; uint32_t signature; /* used only to find hash tables in external analysis */ #ifdef HASH_BLOOM uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ uint8_t *bloom_bv; char bloom_nbits; #endif } UT_hash_table; typedef struct UT_hash_handle { struct UT_hash_table *tbl; void *prev; /* prev element in app order */ void *next; /* next element in app order */ struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ struct UT_hash_handle *hh_next; /* next hh in bucket order */ void *key; /* ptr to enclosing struct's key */ unsigned keylen; /* enclosing struct's key len */ unsigned hashv; /* result of hash-fcn(key) */ } UT_hash_handle; #endif /* UTHASH_H */ ================================================ FILE: cocos2d/plugin/plugins/admob/proj.android/.classpath ================================================ ================================================ FILE: cocos2d/plugin/plugins/admob/proj.android/.project ================================================ libPluginAdmob 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 ================================================ FILE: cocos2d/plugin/plugins/admob/proj.android/AndroidManifest.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/admob/proj.android/ForManifest.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/admob/proj.android/build.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/admob/proj.android/project.properties ================================================ # 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-7 android.library=true android.library.reference.1=../../../protocols/proj.android ================================================ FILE: cocos2d/plugin/plugins/admob/proj.android/res/.gitignore ================================================ ================================================ FILE: cocos2d/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java ================================================ /**************************************************************************** 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. ****************************************************************************/ package org.cocos2dx.plugin; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.Set; import com.google.ads.*; import com.google.ads.AdRequest.ErrorCode; import android.app.Activity; import android.content.Context; import android.util.Log; import android.view.WindowManager; public class AdsAdmob implements InterfaceAds { private static final String LOG_TAG = "AdsAdmob"; private static Activity mContext = null; private static boolean bDebug = false; private static AdsAdmob mAdapter = null; private AdView adView = null; private String mPublishID = ""; private Set mTestDevices = null; private WindowManager mWm = null; private static final int ADMOB_SIZE_BANNER = 1; private static final int ADMOB_SIZE_IABMRect = 2; private static final int ADMOB_SIZE_IABBanner = 3; private static final int ADMOB_SIZE_IABLeaderboard = 4; private static final int ADMOB_SIZE_Skyscraper = 5; private static final int ADMOB_TYPE_BANNER = 1; private static final int ADMOB_TYPE_FULLSCREEN = 2; protected static void LogE(String msg, Exception e) { Log.e(LOG_TAG, msg, e); e.printStackTrace(); } protected static void LogD(String msg) { if (bDebug) { Log.d(LOG_TAG, msg); } } public AdsAdmob(Context context) { mContext = (Activity) context; mAdapter = this; } @Override public void setDebugMode(boolean debug) { bDebug = debug; } @Override public String getSDKVersion() { return "6.3.1"; } @Override public void configDeveloperInfo(Hashtable devInfo) { try { mPublishID = devInfo.get("AdmobID"); LogD("init AppInfo : " + mPublishID); } catch (Exception e) { LogE("initAppInfo, The format of appInfo is wrong", e); } } @Override public void showAds(Hashtable info, int pos) { try { String strType = info.get("AdmobType"); int adsType = Integer.parseInt(strType); switch (adsType) { case ADMOB_TYPE_BANNER: { String strSize = info.get("AdmobSizeEnum"); int sizeEnum = Integer.parseInt(strSize); showBannerAd(sizeEnum, pos); break; } case ADMOB_TYPE_FULLSCREEN: LogD("Now not support full screen view in Admob"); break; default: break; } } catch (Exception e) { LogE("Error when show Ads ( " + info.toString() + " )", e); } } @Override public void spendPoints(int points) { LogD("Admob not support spend points!"); } @Override public void hideAds(Hashtable info) { try { String strType = info.get("AdmobType"); int adsType = Integer.parseInt(strType); switch (adsType) { case ADMOB_TYPE_BANNER: hideBannerAd(); break; case ADMOB_TYPE_FULLSCREEN: LogD("Now not support full screen view in Admob"); break; default: break; } } catch (Exception e) { LogE("Error when hide Ads ( " + info.toString() + " )", e); } } private void showBannerAd(int sizeEnum, int pos) { final int curPos = pos; final int curSize = sizeEnum; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { // destory the ad view before if (null != adView) { if (null != mWm) { mWm.removeView(adView); } adView.destroy(); adView = null; } AdSize size = AdSize.BANNER; switch (curSize) { case AdsAdmob.ADMOB_SIZE_BANNER: size = AdSize.BANNER; break; case AdsAdmob.ADMOB_SIZE_IABMRect: size = AdSize.IAB_MRECT; break; case AdsAdmob.ADMOB_SIZE_IABBanner: size = AdSize.IAB_BANNER; break; case AdsAdmob.ADMOB_SIZE_IABLeaderboard: size = AdSize.IAB_LEADERBOARD; break; case AdsAdmob.ADMOB_SIZE_Skyscraper: size = AdSize.IAB_WIDE_SKYSCRAPER; break; default: break; } adView = new AdView(mContext, size, mPublishID); AdRequest req = new AdRequest(); try { if (mTestDevices != null) { Iterator ir = mTestDevices.iterator(); while(ir.hasNext()) { req.addTestDevice(ir.next()); } } } catch (Exception e) { LogE("Error during add test device", e); } adView.loadAd(req); adView.setAdListener(new AdmobAdsListener()); if (null == mWm) { mWm = (WindowManager) mContext.getSystemService("window"); } AdsWrapper.addAdView(mWm, adView, curPos); } }); } private void hideBannerAd() { PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { if (null != adView) { if (null != mWm) { mWm.removeView(adView); } adView.destroy(); adView = null; } } }); } public void addTestDevice(String deviceID) { LogD("addTestDevice invoked : " + deviceID); if (null == mTestDevices) { mTestDevices = new HashSet(); } mTestDevices.add(deviceID); } private class AdmobAdsListener implements AdListener { @Override public void onDismissScreen(Ad arg0) { LogD("onDismissScreen invoked"); AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsDismissed, "Ads view dismissed!"); } @Override public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) { int errorNo = AdsWrapper.RESULT_CODE_UnknownError; String errorMsg = "Unknow error"; switch (arg1) { case NETWORK_ERROR: errorNo = AdsWrapper.RESULT_CODE_NetworkError; errorMsg = "Network error"; break; case INVALID_REQUEST: errorNo = AdsWrapper.RESULT_CODE_NetworkError; errorMsg = "The ad request is invalid"; break; case NO_FILL: errorMsg = "The ad request is successful, but no ad was returned due to lack of ad inventory."; break; default: break; } LogD("failed to receive ad : " + errorNo + " , " + errorMsg); AdsWrapper.onAdsResult(mAdapter, errorNo, errorMsg); } @Override public void onLeaveApplication(Ad arg0) { LogD("onLeaveApplication invoked"); } @Override public void onPresentScreen(Ad arg0) { LogD("onPresentScreen invoked"); AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsShown, "Ads view shown!"); } @Override public void onReceiveAd(Ad arg0) { LogD("onReceiveAd invoked"); AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsReceived, "Ads request received success!"); } } @Override public String getPluginVersion() { return "0.2.0"; } @Override public void queryPoints() { LogD("Admob not support query points!"); } } ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADAdMobExtras.h ================================================ // // GADAdMobExtras.h // Google Ads iOS SDK // // Copyright (c) 2012 Google Inc. All rights reserved. // // The additional parameters publishers may send to the AdMob network. // #import #import "GADAdNetworkExtras.h" @interface GADAdMobExtras : NSObject @property (nonatomic, retain) NSDictionary *additionalParameters; @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADAdNetworkExtras.h ================================================ // // GADAdNetworkExtras.h // Google Ads iOS SDK // // Copyright (c) 2012 Google Inc. All rights reserved. // // An object implementing this protocol contains information set by the // publisher on the client device for a particular ad network. // // Ad networks should create an 'extras' object implementing this protocol for // their publishers to use. // #import @protocol GADAdNetworkExtras @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADAdSize.h ================================================ // // GADAdSize.h // Google Ads iOS SDK // // Copyright 2012 Google Inc. All rights reserved. // // A valid GADAdSize is considered to be one of the predefined GADAdSize // constants or a GADAdSize constructed by GADAdSizeFromCGSize, // GADAdSizeFullWidthPortraitWithHeight, GADAdSizeFullWidthLandscapeWithHeight. // #import // Do not create a GADAdSize manually. Use one of the kGADAdSize constants. // Treat GADAdSize as an opaque type. Do not access any fields directly. To // obtain a concrete CGSize, use the function CGSizeFromGADAdSize(). typedef struct GADAdSize { CGSize size; NSUInteger flags; } GADAdSize; #pragma mark Standard Sizes // iPhone and iPod Touch ad size. Typically 320x50. extern GADAdSize const kGADAdSizeBanner; // Medium Rectangle size for the iPad (especially in a UISplitView's left pane). // Typically 300x250. extern GADAdSize const kGADAdSizeMediumRectangle; // Full Banner size for the iPad (especially in a UIPopoverController or in // UIModalPresentationFormSheet). Typically 468x60. extern GADAdSize const kGADAdSizeFullBanner; // Leaderboard size for the iPad. Typically 728x90. extern GADAdSize const kGADAdSizeLeaderboard; // Skyscraper size for the iPad. Mediation only. AdMob/Google does not offer // this size. Typically 120x600. extern GADAdSize const kGADAdSizeSkyscraper; // An ad size that spans the full width of the application in portrait // orientation. The height is typically 50 pixels on an iPhone/iPod UI, and 90 // pixels tall on an iPad UI. extern GADAdSize const kGADAdSizeSmartBannerPortrait; // An ad size that spans the full width of the application in landscape // orientation. The height is typically 32 pixels on an iPhone/iPod UI, and 90 // pixels tall on an iPad UI. extern GADAdSize const kGADAdSizeSmartBannerLandscape; // Invalid ad size marker. extern GADAdSize const kGADAdSizeInvalid; #pragma mark Custom Sizes // Given a CGSize, return a custom GADAdSize. Use this only if you require a // non-standard size, otherwise, use one of the standard size constants above. GADAdSize GADAdSizeFromCGSize(CGSize size); // Get a custom GADAdSize that spans the full width of the application in // portrait orientation with the height provided. GADAdSize GADAdSizeFullWidthPortraitWithHeight(CGFloat height); // Get a custom GADAdSize that spans the full width of the application in // landscape orientation with the height provided. GADAdSize GADAdSizeFullWidthLandscapeWithHeight(CGFloat height); #pragma mark Convenience Functions // Checks whether the two GADAdSizes are equal. BOOL GADAdSizeEqualToSize(GADAdSize size1, GADAdSize size2); // Given a GADAdSize constant, returns a CGSize. If the GADAdSize is unknown, // returns CGSizeZero. CGSize CGSizeFromGADAdSize(GADAdSize size); // Determines if |size| is one of the predefined constants, or a custom // GADAdSize generated by FromCGSize. BOOL IsGADAdSizeValid(GADAdSize size); // Given a GADAdSize constant, returns a NSString describing the GADAdSize. NSString *NSStringFromGADAdSize(GADAdSize size); #pragma mark Deprecated Macros #define GAD_SIZE_320x50 CGSizeFromGADAdSize(kGADAdSizeBanner) #define GAD_SIZE_300x250 CGSizeFromGADAdSize(kGADAdSizeMediumRectangle) #define GAD_SIZE_468x60 CGSizeFromGADAdSize(kGADAdSizeFullBanner) #define GAD_SIZE_728x90 CGSizeFromGADAdSize(kGADAdSizeLeaderboard) #define GAD_SIZE_120x600 CGSizeFromGADAdSize(kGADAdSizeSkyscraper) ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADBannerView.h ================================================ // // GADBannerView.h // Google AdMob Ads SDK // // Copyright 2011 Google Inc. All rights reserved. // #import #import "GADAdSize.h" #import "GADRequest.h" #import "GADRequestError.h" #import "GADBannerViewDelegate.h" // The view that displays banner ads. A minimum implementation to get an ad // from within a UIViewController class is: // // // Create and setup the ad view, specifying the size and origin at {0, 0}. // GADBannerView *adView = // [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; // adView.rootViewController = self; // adView.adUnitID = @"ID created when registering my app"; // // // Place the ad view onto the screen. // [self.view addSubview:adView]; // [adView release]; // // // Request an ad without any additional targeting information. // [adView loadRequest:nil]; // @interface GADBannerView : UIView #pragma mark Initialization // Initializes a GADBannerView and sets it to the specified size, and specifies // its placement within its superview bounds. If |size| is invalid, an // instance of GADBannerView is not created and nil is returned instead. - (id)initWithAdSize:(GADAdSize)size origin:(CGPoint)origin; // Initializes a GADBannerView and sets it to the specified size, and specifies // its placement at the top left of its superview. If |size| is invalid, an // instance of GADBannerView is not created and nil is returned instead. - (id)initWithAdSize:(GADAdSize)size; #pragma mark Pre-Request // Required value created in the AdSense website. Create a new ad unit for // every unique placement of an ad in your application. Set this to the ID // assigned for this placement. Ad units are important for targeting and stats. // Example values for different request types: // AdMob: a0123456789ABCD // DFP: /0123/ca-pub-0123456789012345/my-ad-identifier // AdSense: ca-mb-app-pub-0123456789012345/my-ad-identifier // Mediation: AB123456789ABCDE @property (nonatomic, copy) NSString *adUnitID; // Required reference to the current root view controller. For example the root // view controller in tab-based application would be the UITabViewController. @property (nonatomic, assign) UIViewController *rootViewController; // Required to set this banner view to a proper size. Never create your own // GADAdSize directly. Use one of the predefined standard ad sizes // (such as kGADAdSizeBanner), or create one using the GADAdSizeFromCGSize // method. If not using mediation, then changing the adSize after an ad has // been shown will cause a new request (for an ad of the new size) to be sent. // If using mediation, then a new request may not be sent. @property (nonatomic) GADAdSize adSize; // Optional delegate object that receives state change notifications from this // GADBannerView. Typically this is a UIViewController, however, if you are // unfamiliar with the delegate pattern it is recommended you subclass this // GADBannerView and make it the delegate. That avoids any chance of your // application crashing if you forget to nil out the delegate. For example: // // @interface MyAdView : GADBannerView // @end // // @implementation MyAdView // - (id)initWithFrame:(CGRect)frame { // if ((self = [super initWithFrame:frame])) { // self.delegate = self; // } // return self; // } // // - (void)dealloc { // self.delegate = nil; // [super dealloc]; // } // // @end // @property (nonatomic, assign) NSObject *delegate; #pragma mark Making an Ad Request // Makes an ad request. Additional targeting options can be supplied with a // request object. Refresh the ad by calling this method again. - (void)loadRequest:(GADRequest *)request; #pragma mark Ad Request // YES, if the currently displayed ad (or most recent failure) was a result of // auto refreshing as specified on server. This will be set to NO after each // loadRequest: method. @property (nonatomic, readonly) BOOL hasAutoRefreshed; #pragma mark Mediation // Gets the underlying ad view of the mediated ad network. // You may use this to find out the actual size of the ad and adjust // GADBannerView to fit the underlying ad view. @property (nonatomic, readonly) UIView *mediatedAdView; @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADBannerViewDelegate.h ================================================ // // GADBannerViewDelegate.h // Google AdMob Ads SDK // // Copyright 2011 Google Inc. All rights reserved. // #import @class GADRequestError; @class GADBannerView; // Delegate for receiving state change messages from a GADBannerView such as ad // requests succeeding/failing or when an ad has been clicked. @protocol GADBannerViewDelegate @optional #pragma mark Ad Request Lifecycle Notifications // Sent when an ad request loaded an ad. This is a good opportunity to add this // view to the hierarchy if it has not yet been added. If the ad was received // as a part of the server-side auto refreshing, you can examine the // hasAutoRefreshed property of the view. - (void)adViewDidReceiveAd:(GADBannerView *)view; // Sent when an ad request failed. Normally this is because no network // connection was available or no ads were available (i.e. no fill). If the // error was received as a part of the server-side auto refreshing, you can // examine the hasAutoRefreshed property of the view. - (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error; #pragma mark Click-Time Lifecycle Notifications // Sent just before presenting the user a full screen view, such as a browser, // in response to clicking on an ad. Use this opportunity to stop animations, // time sensitive interactions, etc. // // Normally the user looks at the ad, dismisses it, and control returns to your // application by calling adViewDidDismissScreen:. However if the user hits the // Home button or clicks on an App Store link your application will end. On iOS // 4.0+ the next method called will be applicationWillResignActive: of your // UIViewController (UIApplicationWillResignActiveNotification). Immediately // after that adViewWillLeaveApplication: is called. - (void)adViewWillPresentScreen:(GADBannerView *)adView; // Sent just before dismissing a full screen view. - (void)adViewWillDismissScreen:(GADBannerView *)adView; // Sent just after dismissing a full screen view. Use this opportunity to // restart anything you may have stopped as part of adViewWillPresentScreen:. - (void)adViewDidDismissScreen:(GADBannerView *)adView; // Sent just before the application will background or terminate because the // user clicked on an ad that will launch another application (such as the App // Store). The normal UIApplicationDelegate methods, like // applicationDidEnterBackground:, will be called immediately before this. - (void)adViewWillLeaveApplication:(GADBannerView *)adView; @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADInterstitial.h ================================================ // // GADInterstitial.h // Google AdMob Ads SDK // // Copyright 2011 Google Inc. All rights reserved. // #import #import "GADInterstitialDelegate.h" #import "GADRequest.h" #import "GADRequestError.h" // An interstitial ad. This is a full-screen advertisement shown at natural // transition points in your application such as between game levels or news // stories. // // Interstitials are shown sparingly. Expect low to no fill. @interface GADInterstitial : NSObject #pragma mark Pre-Request // Required value created in the AdSense website. Create a new ad unit for // every unique placement of an ad in your application. Set this to the ID // assigned for this placement. Ad units are important for targeting and stats. // Example values for different request types: // AdMob: a0123456789ABCD // DFP: /0123/ca-pub-0123456789012345/my-ad-identifier // AdSense: ca-mb-app-pub-0123456789012345/my-ad-identifier @property (nonatomic, copy) NSString *adUnitID; // Optional delegate object that receives state change notifications from this // GADInterstitalAd. Remember to nil the delegate before deallocating this // object. @property (nonatomic, assign) NSObject *delegate; #pragma mark Making an Ad Request // Makes an interstitial ad request. Additional targeting options can be // supplied with a request object. Only one interstitial request is allowed at // a time. // // This is best to do several seconds before the interstitial is needed to // preload its content. Then when transitioning between view controllers show // the interstital with presentFromViewController. - (void)loadRequest:(GADRequest *)request; #pragma mark Request at Application Launch // The |window| will be shown with the |image| displayed until either the // |request| interstitial is shown or a timeout occurs. The delegate will // receive an interstitialDidDismissScreen: callback to indicate that your app // should continue when the interstitial has finished. - (void)loadAndDisplayRequest:(GADRequest *)request usingWindow:(UIWindow *)window initialImage:(UIImage *)image; #pragma mark Post-Request // Returns YES if the interstitial is ready to be displayed. The delegate's // interstitialAdDidReceiveAd: will be called when this switches from NO to YES. @property (nonatomic, readonly) BOOL isReady; // Returns YES if the interstitial object has already shown an interstitial. // Note that an interstitial object can only be used once even with different // requests. @property (nonatomic, readonly) BOOL hasBeenUsed; // Presents the interstitial ad which takes over the entire screen until the // user dismisses it. This has no effect unless isReady returns YES and/or the // delegate's interstitialDidReceiveAd: has been received. // // Set rootViewController to the current view controller at the time this method // is called. If your application does not use view controllers pass in nil and // your views will be removed from the window to show the interstitial and // restored when done. After the interstitial has been removed, the delegate's // interstitialDidDismissScreen: will be called. - (void)presentFromRootViewController:(UIViewController *)rootViewController; @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADInterstitialDelegate.h ================================================ // // GADInterstitialDelegate.h // Google AdMob Ads SDK // // Copyright 2011 Google Inc. All rights reserved. // #import @class GADInterstitial; @class GADRequestError; // Delegate for receiving state change messages from a GADInterstitial such as // interstitial ad requests succeeding/failing. @protocol GADInterstitialDelegate @optional #pragma mark Ad Request Lifecycle Notifications // Sent when an interstitial ad request succeeded. Show it at the next // transition point in your application such as when transitioning between view // controllers. - (void)interstitialDidReceiveAd:(GADInterstitial *)ad; // Sent when an interstitial ad request completed without an interstitial to // show. This is common since interstitials are shown sparingly to users. - (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error; #pragma mark Display-Time Lifecycle Notifications // Sent just before presenting an interstitial. After this method finishes the // interstitial will animate onto the screen. Use this opportunity to stop // animations and save the state of your application in case the user leaves // while the interstitial is on screen (e.g. to visit the App Store from a link // on the interstitial). - (void)interstitialWillPresentScreen:(GADInterstitial *)ad; // Sent before the interstitial is to be animated off the screen. - (void)interstitialWillDismissScreen:(GADInterstitial *)ad; // Sent just after dismissing an interstitial and it has animated off the // screen. - (void)interstitialDidDismissScreen:(GADInterstitial *)ad; // Sent just before the application will background or terminate because the // user clicked on an ad that will launch another application (such as the App // Store). The normal UIApplicationDelegate methods, like // applicationDidEnterBackground:, will be called immediately before this. - (void)interstitialWillLeaveApplication:(GADInterstitial *)ad; @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADRequest.h ================================================ // // GADRequest.h // Google AdMob Ads SDK // // Copyright 2011 Google Inc. All rights reserved. // #import #import @protocol GADAdNetworkExtras; // Constant for getting test ads on the simulator using the testDevices method. #define GAD_SIMULATOR_ID @"Simulator" // Genders to help deliver more relevant ads. typedef enum { kGADGenderUnknown, kGADGenderMale, kGADGenderFemale } GADGender; // Specifies optional parameters for ad requests. @interface GADRequest : NSObject // Creates an autoreleased GADRequest. + (GADRequest *)request; #pragma mark Additional Parameters For Ad Networks // Ad networks may have additional parameters they accept. To pass these // parameters to them, create the ad network extras object for that network, // fill in the parameters, and register it here. The ad network should have a // header defining the interface for the 'extras' object to create. All // networks will have access to the basic settings you've set in this GADRequest // (gender, birthday, testing mode, etc.). If you register an extras object // that is the same class as one you have registered before, the previous // extras will be overwritten. - (void)registerAdNetworkExtras:(id)extras; // Get the network extras defined for an ad network. - (id)adNetworkExtrasFor:(Class)clazz; // Unsets the extras for an ad network. |clazz| is the class which represents // that network's extras type. - (void)removeAdNetworkExtrasFor:(Class)clazz; // Extras sent to the mediation server (if using Mediation). For future use. @property (nonatomic, retain) NSDictionary *mediationExtras; #pragma mark Collecting SDK Information // Returns the version of the SDK. + (NSString *)sdkVersion; #pragma mark Testing // Add the device's identifier into this array for testing purposes. @property (nonatomic, retain) NSArray *testDevices; #pragma mark User Information // The user's gender may be used to deliver more relevant ads. @property (nonatomic, assign) GADGender gender; // The user's birthday may be used to deliver more relevant ads. @property (nonatomic, retain) NSDate *birthday; - (void)setBirthdayWithMonth:(NSInteger)m day:(NSInteger)d year:(NSInteger)y; // The user's current location may be used to deliver more relevant ads. // However do not use Core Location just for advertising, make sure it is used // for more beneficial reasons as well. It is both a good idea and part of // Apple's guidelines. - (void)setLocationWithLatitude:(CGFloat)latitude longitude:(CGFloat)longitude accuracy:(CGFloat)accuracyInMeters; // When Core Location isn't available but the user's location is known supplying // it here may deliver more relevant ads. It can be any free-form text such as // @"Champs-Elysees Paris" or @"94041 US". - (void)setLocationWithDescription:(NSString *)locationDescription; #pragma mark Contextual Information // A keyword is a word or phrase describing the current activity of the user // such as @"Sports Scores". Each keyword is an NSString in the NSArray. To // clear the keywords set this to nil. @property (nonatomic, retain) NSMutableArray *keywords; // Convenience method for adding keywords one at a time such as @"Sports Scores" // and then @"Football". - (void)addKeyword:(NSString *)keyword; #pragma mark - #pragma mark Deprecated Methods // Accesses the additionalParameters for the "GoogleAdmob" ad network. Please // use -registerAdNetworkExtras: method above and pass an instance of // GADAdMobExtras instead. @property (nonatomic, retain) NSDictionary *additionalParameters; // This property has been deprecated with the latest SDK releases. Please use // testDevices. @property (nonatomic, getter=isTesting) BOOL testing; @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/GADRequestError.h ================================================ // // GADRequestError.h // Google AdMob Ads SDK // // Copyright 2011 Google Inc. All rights reserved. // #import @class GADRequest; extern NSString *kGADErrorDomain; // NSError codes for GAD error domain. typedef enum { // The ad request is invalid. The localizedFailureReason error description // will have more details. Typically this is because the ad did not have the // ad unit ID or root view controller set. kGADErrorInvalidRequest, // The ad request was successful, but no ad was returned. kGADErrorNoFill, // There was an error loading data from the network. kGADErrorNetworkError, // The ad server experienced a failure processing the request. kGADErrorServerError, // The current device's OS is below the minimum required version. kGADErrorOSVersionTooLow, // The request was unable to be loaded before being timed out. kGADErrorTimeout, // Will not send request because the interstitial object has already been // used. kGADErrorInterstitialAlreadyUsed, // The mediation response was invalid. kGADErrorMediationDataError, // Error finding or creating a mediation ad network adapter. kGADErrorMediationAdapterError, // The mediation request was successful, but no ad was returned from any // ad networks. kGADErrorMediationNoFill, // Attempting to pass an invalid ad size to an adapter. kGADErrorMediationInvalidAdSize, } GADErrorCode; // This class represents the error generated due to invalid request parameters. @interface GADRequestError : NSError @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/Admob/libGoogleAdMobAds.a ================================================ [File too large to display: 15.2 MB] ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/AdsAdmob.h ================================================ /**************************************************************************** Copyright (c) 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 #import "InterfaceAds.h" #import "GADBannerView.h" #import "GADBannerViewDelegate.h" typedef enum { kSizeBanner = 1, kSizeIABMRect, kSizeIABBanner, kSizeIABLeaderboard, kSizeSkyscraper, } AdmobSizeEnum; typedef enum { kTypeBanner = 1, kTypeFullScreen, } AdmobType; @interface AdsAdmob : NSObject { } @property BOOL debug; @property (copy, nonatomic) NSString* strPublishID; @property (assign, nonatomic) GADBannerView* bannerView; @property (assign, nonatomic) NSMutableArray* testDeviceIDs; /** interfaces from InterfaceAds */ - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; - (void) showAds: (NSMutableDictionary*) info position:(int) pos; - (void) hideAds: (NSMutableDictionary*) info; - (void) queryPoints; - (void) spendPoints: (int) points; - (void) setDebugMode: (BOOL) isDebugMode; - (NSString*) getSDKVersion; - (NSString*) getPluginVersion; /** interface for Admob SDK */ - (void) addTestDevice: (NSString*) deviceID; @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/AdsAdmob.m ================================================ /**************************************************************************** Copyright (c) 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 "AdsAdmob.h" #import "AdsWrapper.h" #define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__); @implementation AdsAdmob @synthesize debug = __debug; @synthesize strPublishID = __PublishID; @synthesize testDeviceIDs = __TestDeviceIDs; - (void) dealloc { if (self.bannerView != nil) { [self.bannerView release]; self.bannerView = nil; } if (self.testDeviceIDs != nil) { [self.testDeviceIDs release]; self.testDeviceIDs = nil; } [super dealloc]; } #pragma mark InterfaceAds impl - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo { self.strPublishID = (NSString*) [devInfo objectForKey:@"AdmobID"]; } - (void) showAds: (NSMutableDictionary*) info position:(int) pos { if (self.strPublishID == nil || [self.strPublishID length] == 0) { OUTPUT_LOG(@"configDeveloperInfo() not correctly invoked in Admob!"); return; } NSString* strType = [info objectForKey:@"AdmobType"]; int type = [strType intValue]; switch (type) { case kTypeBanner: { NSString* strSize = [info objectForKey:@"AdmobSizeEnum"]; int sizeEnum = [strSize intValue]; [self showBanner:sizeEnum atPos:pos]; break; } case kTypeFullScreen: OUTPUT_LOG(@"Now not support full screen view in Admob"); break; default: OUTPUT_LOG(@"The value of 'AdmobType' is wrong (should be 1 or 2)"); break; } } - (void) hideAds: (NSMutableDictionary*) info { NSString* strType = [info objectForKey:@"AdmobType"]; int type = [strType intValue]; switch (type) { case kTypeBanner: { if (nil != self.bannerView) { [self.bannerView removeFromSuperview]; [self.bannerView release]; self.bannerView = nil; } break; } case kTypeFullScreen: OUTPUT_LOG(@"Now not support full screen view in Admob"); break; default: OUTPUT_LOG(@"The value of 'AdmobType' is wrong (should be 1 or 2)"); break; } } - (void) queryPoints { OUTPUT_LOG(@"Admob not support query points!"); } - (void) spendPoints: (int) points { OUTPUT_LOG(@"Admob not support spend points!"); } - (void) setDebugMode: (BOOL) isDebugMode { self.debug = isDebugMode; } - (NSString*) getSDKVersion { return @"6.4.2"; } - (NSString*) getPluginVersion { return @"0.2.0"; } - (void) showBanner: (int) sizeEnum atPos:(int) pos { GADAdSize size = kGADAdSizeBanner; switch (sizeEnum) { case kSizeBanner: size = kGADAdSizeBanner; break; case kSizeIABMRect: size = kGADAdSizeMediumRectangle; break; case kSizeIABBanner: size = kGADAdSizeFullBanner; break; case kSizeIABLeaderboard: size = kGADAdSizeLeaderboard; break; case kSizeSkyscraper: size = kGADAdSizeSkyscraper; break; default: break; } if (nil != self.bannerView) { [self.bannerView removeFromSuperview]; [self.bannerView release]; self.bannerView = nil; } self.bannerView = [[GADBannerView alloc] initWithAdSize:size]; self.bannerView.adUnitID = self.strPublishID; self.bannerView.delegate = self; [self.bannerView setRootViewController:[AdsWrapper getCurrentRootViewController]]; [AdsWrapper addAdView:self.bannerView atPos:pos]; GADRequest* request = [GADRequest request]; request.testDevices = [NSArray arrayWithArray:self.testDeviceIDs]; [self.bannerView loadRequest:request]; } #pragma mark interface for Admob SDK - (void) addTestDevice: (NSString*) deviceID { if (nil == self.testDeviceIDs) { self.testDeviceIDs = [NSMutableArray alloc]; [self.testDeviceIDs addObject:GAD_SIMULATOR_ID]; } [self.testDeviceIDs addObject:deviceID]; } #pragma mark GADBannerViewDelegate impl // Since we've received an ad, let's go ahead and set the frame to display it. - (void)adViewDidReceiveAd:(GADBannerView *)adView { NSLog(@"Received ad"); [AdsWrapper onAdsResult:self withRet:kAdsReceived withMsg:@"Ads request received success!"]; } - (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error { NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]); int errorNo = kUnknownError; switch ([error code]) { case kGADErrorNetworkError: errorNo = kNetworkError; break; default: break; } [AdsWrapper onAdsResult:self withRet:errorNo withMsg:[error localizedDescription]]; } @end ================================================ FILE: cocos2d/plugin/plugins/admob/proj.ios/PluginAdmob.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ FADC44AB176EA82000B2D5ED /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FADC44AA176EA82000B2D5ED /* Foundation.framework */; }; FADC44C5176EA84500B2D5ED /* libGoogleAdMobAds.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */; }; FADC44C6176EA84500B2D5ED /* AdsAdmob.m in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C4176EA84500B2D5ED /* AdsAdmob.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ FADC44A5176EA82000B2D5ED /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = "include/${PRODUCT_NAME}"; dstSubfolderSpec = 16; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginAdmob.a; sourceTree = BUILT_PRODUCTS_DIR; }; FADC44AA176EA82000B2D5ED /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; FADC44B9176EA84500B2D5ED /* GADAdMobExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdMobExtras.h; sourceTree = ""; }; FADC44BA176EA84500B2D5ED /* GADAdNetworkExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdNetworkExtras.h; sourceTree = ""; }; FADC44BB176EA84500B2D5ED /* GADAdSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdSize.h; sourceTree = ""; }; FADC44BC176EA84500B2D5ED /* GADBannerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADBannerView.h; sourceTree = ""; }; FADC44BD176EA84500B2D5ED /* GADBannerViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADBannerViewDelegate.h; sourceTree = ""; }; FADC44BE176EA84500B2D5ED /* GADInterstitial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADInterstitial.h; sourceTree = ""; }; FADC44BF176EA84500B2D5ED /* GADInterstitialDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADInterstitialDelegate.h; sourceTree = ""; }; FADC44C0176EA84500B2D5ED /* GADRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADRequest.h; sourceTree = ""; }; FADC44C1176EA84500B2D5ED /* GADRequestError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADRequestError.h; sourceTree = ""; }; FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libGoogleAdMobAds.a; sourceTree = ""; }; FADC44C3176EA84500B2D5ED /* AdsAdmob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsAdmob.h; sourceTree = ""; }; FADC44C4176EA84500B2D5ED /* AdsAdmob.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdsAdmob.m; sourceTree = ""; }; FADC44C7176EA85F00B2D5ED /* PluginAdmob-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PluginAdmob-Prefix.pch"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ FADC44A4176EA82000B2D5ED /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( FADC44AB176EA82000B2D5ED /* Foundation.framework in Frameworks */, FADC44C5176EA84500B2D5ED /* libGoogleAdMobAds.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ FADC449E176EA82000B2D5ED = { isa = PBXGroup; children = ( FADC44C7176EA85F00B2D5ED /* PluginAdmob-Prefix.pch */, FADC44B8176EA84500B2D5ED /* Admob */, FADC44C3176EA84500B2D5ED /* AdsAdmob.h */, FADC44C4176EA84500B2D5ED /* AdsAdmob.m */, FADC44A9176EA82000B2D5ED /* Frameworks */, FADC44A8176EA82000B2D5ED /* Products */, ); sourceTree = ""; }; FADC44A8176EA82000B2D5ED /* Products */ = { isa = PBXGroup; children = ( FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */, ); name = Products; sourceTree = ""; }; FADC44A9176EA82000B2D5ED /* Frameworks */ = { isa = PBXGroup; children = ( FADC44AA176EA82000B2D5ED /* Foundation.framework */, ); name = Frameworks; sourceTree = ""; }; FADC44B8176EA84500B2D5ED /* Admob */ = { isa = PBXGroup; children = ( FADC44B9176EA84500B2D5ED /* GADAdMobExtras.h */, FADC44BA176EA84500B2D5ED /* GADAdNetworkExtras.h */, FADC44BB176EA84500B2D5ED /* GADAdSize.h */, FADC44BC176EA84500B2D5ED /* GADBannerView.h */, FADC44BD176EA84500B2D5ED /* GADBannerViewDelegate.h */, FADC44BE176EA84500B2D5ED /* GADInterstitial.h */, FADC44BF176EA84500B2D5ED /* GADInterstitialDelegate.h */, FADC44C0176EA84500B2D5ED /* GADRequest.h */, FADC44C1176EA84500B2D5ED /* GADRequestError.h */, FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */, ); path = Admob; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ FADC44A6176EA82000B2D5ED /* PluginAdmob */ = { isa = PBXNativeTarget; buildConfigurationList = FADC44B5176EA82000B2D5ED /* Build configuration list for PBXNativeTarget "PluginAdmob" */; buildPhases = ( FADC44A3176EA82000B2D5ED /* Sources */, FADC44A4176EA82000B2D5ED /* Frameworks */, FADC44A5176EA82000B2D5ED /* CopyFiles */, ); buildRules = ( ); dependencies = ( ); name = PluginAdmob; productName = PluginAdmob; productReference = FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */; productType = "com.apple.product-type.library.static"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ FADC449F176EA82000B2D5ED /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0460; ORGANIZATIONNAME = "cocos2d-x"; }; buildConfigurationList = FADC44A2176EA82000B2D5ED /* Build configuration list for PBXProject "PluginAdmob" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); mainGroup = FADC449E176EA82000B2D5ED; productRefGroup = FADC44A8176EA82000B2D5ED /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( FADC44A6176EA82000B2D5ED /* PluginAdmob */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ FADC44A3176EA82000B2D5ED /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( FADC44C6176EA84500B2D5ED /* AdsAdmob.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ FADC44B3176EA82000B2D5ED /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++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 = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.1; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; name = Debug; }; FADC44B4176EA82000B2D5ED /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++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 = gnu99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.1; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; name = Release; }; 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"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/Admob\"", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; name = Debug; }; 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"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/Admob\"", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ FADC44A2176EA82000B2D5ED /* Build configuration list for PBXProject "PluginAdmob" */ = { isa = XCConfigurationList; buildConfigurations = ( FADC44B3176EA82000B2D5ED /* Debug */, FADC44B4176EA82000B2D5ED /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; FADC44B5176EA82000B2D5ED /* Build configuration list for PBXNativeTarget "PluginAdmob" */ = { isa = XCConfigurationList; buildConfigurations = ( FADC44B6176EA82000B2D5ED /* Debug */, FADC44B7176EA82000B2D5ED /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = FADC449F176EA82000B2D5ED /* Project object */; } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/.classpath ================================================ ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/.project ================================================ libPluginAlipay 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 ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/AndroidManifest.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/ForManifest.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/build.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/project.properties ================================================ # 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-7 android.library=true android.library.reference.1=../../../protocols/proj.android ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/res/.gitignore ================================================ ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/AlixId.java ================================================ /* * Copyright (C) 2010 The MobileSecurePay Project * All right reserved. * author: shiqun.shi@alipay.com */ package org.cocos2dx.plugin; public final class AlixId { public static final int BASE_ID = 0; public static final int RQF_PAY = BASE_ID + 1; public static final int RQF_INSTALL_CHECK = RQF_PAY + 1; } final class AlixDefine { public static final String IMEI = "imei"; public static final String IMSI = "imsi"; public static final String KEY = "key"; public static final String USER_AGENT = "user_agent"; public static final String VERSION = "version"; public static final String DEVICE = "device"; public static final String SID = "sid"; public static final String partner = "partner"; public static final String charset = "charset"; public static final String sign_type = "sign_type"; public static final String sign = "sign"; public static final String URL = "URL"; public static final String split = "&"; public static final String AlixPay = "AlixPay"; public static final String action = "action"; public static final String actionUpdate= "update"; public static final String data = "data"; public static final String platform = "platform"; } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/Base64.java ================================================ /* * Copyright (C) 2010 The MobileSecurePay Project * All right reserved. * author: shiqun.shi@alipay.com */ package org.cocos2dx.plugin; /** * Base64 工具类 * */ public final class Base64 { static private final int BASELENGTH = 128; static private final int LOOKUPLENGTH = 64; static private final int TWENTYFOURBITGROUP = 24; static private final int EIGHTBIT = 8; static private final int SIXTEENBIT = 16; static private final int FOURBYTE = 4; static private final int SIGN = -128; static private final char PAD = '='; static private final boolean fDebug = false; static final private byte[] base64Alphabet = new byte[BASELENGTH]; static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH]; static { for (int i = 0; i < BASELENGTH; ++i) { base64Alphabet[i] = -1; } for (int i = 'Z'; i >= 'A'; i--) { base64Alphabet[i] = (byte) (i - 'A'); } for (int i = 'z'; i >= 'a'; i--) { base64Alphabet[i] = (byte) (i - 'a' + 26); } for (int i = '9'; i >= '0'; i--) { base64Alphabet[i] = (byte) (i - '0' + 52); } base64Alphabet['+'] = 62; base64Alphabet['/'] = 63; for (int i = 0; i <= 25; i++) { lookUpBase64Alphabet[i] = (char) ('A' + i); } for (int i = 26, j = 0; i <= 51; i++, j++) { lookUpBase64Alphabet[i] = (char) ('a' + j); } for (int i = 52, j = 0; i <= 61; i++, j++) { lookUpBase64Alphabet[i] = (char) ('0' + j); } lookUpBase64Alphabet[62] = (char) '+'; lookUpBase64Alphabet[63] = (char) '/'; } private static boolean isWhiteSpace(char octect) { return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9); } private static boolean isPad(char octect) { return (octect == PAD); } private static boolean isData(char octect) { return (octect < BASELENGTH && base64Alphabet[octect] != -1); } /** * Encodes hex octects into Base64 * * @param binaryData * Array containing binaryData * @return Encoded Base64 array */ public static String encode(byte[] binaryData) { if (binaryData == null) { return null; } int lengthDataBits = binaryData.length * EIGHTBIT; if (lengthDataBits == 0) { return ""; } int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP; int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets; char encodedData[] = null; encodedData = new char[numberQuartet * 4]; byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0; int encodedIndex = 0; int dataIndex = 0; if (fDebug) { System.out.println("number of triplets = " + numberTriplets); } for (int i = 0; i < numberTriplets; i++) { b1 = binaryData[dataIndex++]; b2 = binaryData[dataIndex++]; b3 = binaryData[dataIndex++]; if (fDebug) { System.out.println("b1= " + b1 + ", b2= " + b2 + ", b3= " + b3); } l = (byte) (b2 & 0x0f); k = (byte) (b1 & 0x03); byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc); if (fDebug) { System.out.println("val2 = " + val2); System.out.println("k4 = " + (k << 4)); System.out.println("vak = " + (val2 | (k << 4))); } encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)]; encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3]; encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f]; } // form integral number of 6-bit groups if (fewerThan24bits == EIGHTBIT) { b1 = binaryData[dataIndex]; k = (byte) (b1 & 0x03); if (fDebug) { System.out.println("b1=" + b1); System.out.println("b1<<2 = " + (b1 >> 2)); } byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4]; encodedData[encodedIndex++] = PAD; encodedData[encodedIndex++] = PAD; } else if (fewerThan24bits == SIXTEENBIT) { b1 = binaryData[dataIndex]; b2 = binaryData[dataIndex + 1]; l = (byte) (b2 & 0x0f); k = (byte) (b1 & 0x03); byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); encodedData[encodedIndex++] = lookUpBase64Alphabet[val1]; encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)]; encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2]; encodedData[encodedIndex++] = PAD; } return new String(encodedData); } /** * Decodes Base64 data into octects * * @param encoded * string containing Base64 data * @return Array containind decoded data. */ public static byte[] decode(String encoded) { if (encoded == null) { return null; } char[] base64Data = encoded.toCharArray(); // remove white spaces int len = removeWhiteSpace(base64Data); if (len % FOURBYTE != 0) { return null;// should be divisible by four } int numberQuadruple = (len / FOURBYTE); if (numberQuadruple == 0) { return new byte[0]; } byte decodedData[] = null; byte b1 = 0, b2 = 0, b3 = 0, b4 = 0; char d1 = 0, d2 = 0, d3 = 0, d4 = 0; int i = 0; int encodedIndex = 0; int dataIndex = 0; decodedData = new byte[(numberQuadruple) * 3]; for (; i < numberQuadruple - 1; i++) { if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])) || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) { return null; }// if found "no data" just return null b1 = base64Alphabet[d1]; b2 = base64Alphabet[d2]; b3 = base64Alphabet[d3]; b4 = base64Alphabet[d4]; decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); } if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) { return null;// if found "no data" just return null } b1 = base64Alphabet[d1]; b2 = base64Alphabet[d2]; d3 = base64Data[dataIndex++]; d4 = base64Data[dataIndex++]; if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters if (isPad(d3) && isPad(d4)) { if ((b2 & 0xf) != 0)// last 4 bits should be zero { return null; } byte[] tmp = new byte[i * 3 + 1]; System.arraycopy(decodedData, 0, tmp, 0, i * 3); tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4); return tmp; } else if (!isPad(d3) && isPad(d4)) { b3 = base64Alphabet[d3]; if ((b3 & 0x3) != 0)// last 2 bits should be zero { return null; } byte[] tmp = new byte[i * 3 + 2]; System.arraycopy(decodedData, 0, tmp, 0, i * 3); tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); return tmp; } else { return null; } } else { // No PAD e.g 3cQl b3 = base64Alphabet[d3]; b4 = base64Alphabet[d4]; decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4); decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); decodedData[encodedIndex++] = (byte) (b3 << 6 | b4); } return decodedData; } /** * remove WhiteSpace from MIME containing encoded Base64 data. * * @param data * the byte array of base64 data (with WS) * @return the new length */ private static int removeWhiteSpace(char[] data) { if (data == null) { return 0; } // count characters that's not whitespace int newSize = 0; int len = data.length; for (int i = 0; i < len; i++) { if (!isWhiteSpace(data[i])) { data[newSize++] = data[i]; } } return newSize; } } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/BaseHelper.java ================================================ /* * Copyright (C) 2010 The MobileSecurePay Project * All right reserved. * author: shiqun.shi@alipay.com */ package org.cocos2dx.plugin; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.json.JSONObject; import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; /** * 工具类 * */ public class BaseHelper { /** * 流转字符串方法 * * @param is * @return */ public static String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line); } } catch (IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } return sb.toString(); } /** * 显示dialog * * @param context * 环境 * @param strTitle * 标题 * @param strText * 内容 * @param icon * 图标 */ public static void showDialog(Activity context, String strTitle, String strText, int icon) { AlertDialog.Builder tDialog = new AlertDialog.Builder(context); tDialog.setIcon(icon); tDialog.setTitle(strTitle); tDialog.setMessage(strText); tDialog.setPositiveButton("确定", null); tDialog.show(); } /** * 打印信息 * * @param tag * 标签 * @param info * 信息 */ public static void log(String tag, String info) { // Log.d(tag, info); } /** * 获取权限 * * @param permission * 权限 * @param path * 路径 */ public static void chmod(String permission, String path) { try { String command = "chmod " + permission + " " + path; Runtime runtime = Runtime.getRuntime(); runtime.exec(command); } catch (IOException e) { e.printStackTrace(); } } // // show the progress bar. /** * 显示进度条 * * @param context * 环境 * @param title * 标题 * @param message * 信息 * @param indeterminate * 确定性 * @param cancelable * 可撤销 * @return */ public static ProgressDialog showProgress(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable) { ProgressDialog dialog = new ProgressDialog(context); dialog.setTitle(title); dialog.setMessage(message); dialog.setIndeterminate(indeterminate); dialog.setCancelable(false); // dialog.setDefaultButton(false); dialog.setOnCancelListener(new IAPAlipay.AlixOnCancelListener( (Activity) context)); dialog.show(); return dialog; } /** * 字符串转json对象 * @param str * @param split * @return */ public static JSONObject string2JSON(String str, String split) { JSONObject json = new JSONObject(); try { String[] arrStr = str.split(split); for (int i = 0; i < arrStr.length; i++) { String[] arrKeyValue = arrStr[i].split("="); json.put(arrKeyValue[0], arrStr[i].substring(arrKeyValue[0].length() + 1)); } } catch (Exception e) { e.printStackTrace(); } return json; } } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/IAPAlipay.java ================================================ /**************************************************************************** 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. ****************************************************************************/ package org.cocos2dx.plugin; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Hashtable; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.KeyEvent; public class IAPAlipay implements InterfaceIAP { private static final String LOG_TAG = "IAPAlipay"; private static Activity mContext = null; private static boolean bDebug = false; private static Handler mHandler = null; private static IAPAlipay mAdapter = null; protected static void LogE(String msg, Exception e) { Log.e(LOG_TAG, msg, e); e.printStackTrace(); } protected static void LogD(String msg) { if (bDebug) { Log.d(LOG_TAG, msg); } } public IAPAlipay(Context context) { mContext = (Activity) context; mAdapter = this; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { initUIHandle(); } }); } @Override public void configDeveloperInfo(Hashtable cpInfo) { LogD("initDeveloperInfo invoked " + cpInfo.toString()); try { PartnerConfig.PARTNER = cpInfo.get("AlipayPartner"); PartnerConfig.SELLER = cpInfo.get("AlipaySeller"); PartnerConfig.RSA_PRIVATE = cpInfo.get("AlipayRsaPrivate"); PartnerConfig.RSA_ALIPAY_PUBLIC = cpInfo.get("AlipayPublic"); PartnerConfig.ALIPAY_PLUGIN_NAME = cpInfo.get("AlipayPluginName"); strPayAccount = cpInfo.get("AlipayRoyPayAccount"); strReceiveAccount = cpInfo.get("AlipayRoyReceiveAccount"); fPayPercent = ((cpInfo.get("AlipayRoyPercent") == null) ? 0.0f : Float.parseFloat(cpInfo.get("AlipayRoyPercent"))); strRoyTip = cpInfo.get("AlipayRoyTip"); strNotifyUrl = ((null == cpInfo.get("AlipayNotifyUrl")) ? "" : cpInfo.get("AlipayNotifyUrl")); } catch (Exception e) { LogE("Developer info is wrong!", e); } } @Override public void payForProduct(Hashtable info) { LogD("payForProduct invoked " + info.toString()); if (! networkReachable()) { payResult(IAPWrapper.PAYRESULT_FAIL, "网络不可用"); return; } final Hashtable productInfo = info; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { MobileSecurePayHelper mspHelper = new MobileSecurePayHelper(mContext); boolean bInstalled = mspHelper.detectMobile_sp(); if (! bInstalled) { payResult(IAPWrapper.PAYRESULT_FAIL, "未安装支付宝插件"); return; } // start pay for this order. // 根据订单信息开始进行支付 try { // prepare the order info. // 准备订单信息 String orderInfo = getOrderInfo(productInfo); // 这里根据签名方式对订单信息进行签名 String signType = getSignType(); String strsign = sign(signType, orderInfo); // 对签名进行编码 strsign = URLEncoder.encode(strsign); // 组装好参数 String info = orderInfo + "&sign=" + "\"" + strsign + "\"" + "&" + getSignType(); LogD("pay info : " + info); // start the pay. // 调用pay方法进行支付 MobileSecurePayer msp = new MobileSecurePayer(); boolean bRet = msp.pay(info, mHandler, AlixId.RQF_PAY, mContext); if (bRet) { // show the progress bar to indicate that we have started // paying. // 显示“正在支付”进度条 closeProgress(); mProgress = BaseHelper.showProgress(mContext, null, "正在支付", false, true); } else { payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败"); return; } } catch (Exception ex) { LogE("Remote call failed", ex); payResult(IAPWrapper.PAYRESULT_FAIL, "remote call failed"); return; } } }); } @Override public void setDebugMode(boolean debug) { bDebug = debug; } @Override public String getSDKVersion() { return "Unknown version"; } static class AlixOnCancelListener implements DialogInterface.OnCancelListener { Activity mcontext; AlixOnCancelListener(Activity context) { mcontext = context; } public void onCancel(DialogInterface dialog) { mcontext.onKeyDown(KeyEvent.KEYCODE_BACK, null); } } private static void initUIHandle() { // // the handler use to receive the pay result. // 这里接收支付结果,支付宝手机端同步通知 mHandler = new Handler() { public void handleMessage(Message msg) { try { String strRet = (String) msg.obj; LogD("handle msg : " + msg.toString()); switch (msg.what) { case AlixId.RQF_PAY: { LogD("msg.what is RQF_PAY"); mAdapter.closeProgress(); // 从通知中获取参数 try { // 获取交易状态,具体状态代码请参看文档 String memo = "memo="; int imemoStart = strRet.indexOf("memo="); imemoStart += memo.length(); int imemoEnd = strRet.indexOf(";result="); memo = strRet.substring(imemoStart, imemoEnd); // 对通知进行验签 ResultChecker resultChecker = new ResultChecker(strRet); int retVal = resultChecker.checkSign(); // 返回验签结果以及交易状态 if (retVal == ResultChecker.RESULT_CHECK_SIGN_FAILED) { payResult(IAPWrapper.PAYRESULT_FAIL, "签名验证失败"); } else if (retVal == ResultChecker.RESULT_CHECK_SIGN_SUCCEED && resultChecker.isPayOk()) { payResult(IAPWrapper.PAYRESULT_SUCCESS, "支付成功"); } else { payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败"); } } catch (Exception e) { e.printStackTrace(); payResult(IAPWrapper.PAYRESULT_FAIL, "结果解析失败"); } } break; default: mAdapter.closeProgress(); payResult(IAPWrapper.PAYRESULT_FAIL, "支付失败"); break; } super.handleMessage(msg); } catch (Exception e) { e.printStackTrace(); } } }; } /** * get the selected order info for pay. 获取商品订单信息 * * @param position * 商品在列表中的位置 * @return */ private static String strPayAccount = ""; private static String strReceiveAccount = ""; private static float fPayPercent = 0.0f; private static String strRoyTip = ""; private static String strNotifyUrl = ""; private String getOrderInfo(Hashtable info) { String strRet = null; try { float price = Float.parseFloat(info.get("productPrice"));//IAPProducts.getProductPrice(productID); String productName = info.get("productName"); String productDesc = info.get("productDesc"); String royParam = ""; if (fPayPercent > 0 ) { float royValue = fPayPercent * price; royParam = strPayAccount + "^" + strReceiveAccount + "^" + royValue + "^"+ strRoyTip; royParam = "&royalty_parameters=\""+ royParam + "\"" + "&royalty_type=\"10" + "\""; } strRet = "partner=\"" + PartnerConfig.PARTNER + "\"" + "&seller=\"" + PartnerConfig.SELLER + "\"" + "&out_trade_no=\"" + getOutTradeNo() + "\"" + "&subject=\"" + productName + "\"" + "&body=\"" + productDesc + "\"" + "&total_fee=\"" + price + "\"" + "¬ify_url=\"" + strNotifyUrl + "\"" + royParam; } catch (Exception e) { LogE("Product info parse error", e); } LogD("order info : " + strRet); return strRet; } /** * get the out_trade_no for an order. * 获取外部订单号 * * @return */ String getOutTradeNo() { SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = new Date(); String strKey = format.format(date); java.util.Random r = new java.util.Random(); strKey = strKey + r.nextInt(10000); return strKey; } // // /** * sign the order info. * 对订单信息进行签名 * * @param signType 签名方式 * @param content 待签名订单信息 * @return */ private String sign(String signType, String content) { LogD("sign params :"); LogD("type : " + signType + ", content : " + content + ", private : " + PartnerConfig.RSA_PRIVATE); return Rsa.sign(content, PartnerConfig.RSA_PRIVATE); } /** * get the sign type we use. * 获取签名方式 * * @return */ private String getSignType() { String getSignType = "sign_type=" + "\"" + "RSA" + "\""; return getSignType; } private ProgressDialog mProgress = null; void closeProgress() { try { if (mProgress != null) { mProgress.dismiss(); mProgress = null; } } catch (Exception e) { e.printStackTrace(); } } private boolean networkReachable() { boolean bRet = false; try { ConnectivityManager conn = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = conn.getActiveNetworkInfo(); bRet = (null == netInfo) ? false : netInfo.isAvailable(); } catch (Exception e) { LogE("Fail to check network status", e); } LogD("NetWork reachable : " + bRet); return bRet; } private static void payResult(int ret, String msg) { IAPWrapper.onPayResult(mAdapter, ret, msg); LogD("Alipay result : " + ret + " msg : " + msg); } @Override public String getPluginVersion() { return "0.2.0"; } } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/MobileSecurePayHelper.java ================================================ /* * Copyright (C) 2010 The MobileSecurePay Project * All right reserved. * author: shiqun.shi@alipay.com */ package org.cocos2dx.plugin; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.List; import org.json.JSONException; import org.json.JSONObject; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Handler; import android.os.Message; /** * 检测安全支付服务是否正确安装,如果没有安装进行本地安装,或者下载安装, 检测安全支付服务版本,有新版本时进行下载。 * */ public class MobileSecurePayHelper { static final String TAG = "MobileSecurePayHelper"; private ProgressDialog mProgress = null; Context mContext = null; public MobileSecurePayHelper(Context context) { this.mContext = context; } /** * 检测安全支付服务是否安装 * * @return */ public boolean detectMobile_sp() { boolean isMobile_spExist = isMobile_spExist(); if (!isMobile_spExist) { // // get the cacheDir. // 获取系统缓冲绝对路径 获取/data/data//cache目录 File cacheDir = mContext.getCacheDir(); final String cachePath = cacheDir.getAbsolutePath() + "/temp.apk"; // // 捆绑安装 retrieveApkFromAssets(mContext, PartnerConfig.ALIPAY_PLUGIN_NAME, cachePath); mProgress = BaseHelper.showProgress(mContext, null, "正在检测安全支付服务版本", false, true); // 实例新线程检测是否有新版本进行下载 new Thread(new Runnable() { public void run() { // // 检测是否有新的版本。 PackageInfo apkInfo = getApkInfo(mContext, cachePath); String newApkdlUrl = checkNewUpdate(apkInfo); // // 动态下载 if (newApkdlUrl != null) retrieveApkFromNet(mContext, newApkdlUrl, cachePath); // send the result back to caller. // 发送结果 Message msg = new Message(); msg.what = AlixId.RQF_INSTALL_CHECK; msg.obj = cachePath; mHandler.sendMessage(msg); } }).start(); } // else ok. return isMobile_spExist; } /** * 显示确认安装的提示 * * @param context * 上下文环境 * @param cachePath * 安装文件路径 */ public void showInstallConfirmDialog(final Context context, final String cachePath) { AlertDialog.Builder tDialog = new AlertDialog.Builder(context); tDialog.setTitle("安装提示"); tDialog.setMessage("为保证您的交易安全,需要您安装支付宝安全支付服务,才能进行付款。\n\n点击确定,立即安装。"); tDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // // 修改apk权限 BaseHelper.chmod("777", cachePath); // // install the apk. // 安装安全支付服务APK Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.parse("file://" + cachePath), "application/vnd.android.package-archive"); context.startActivity(intent); } }); tDialog.setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); tDialog.show(); } /** * 遍历程序列表,判断是否安装安全支付服务 * * @return */ public boolean isMobile_spExist() { PackageManager manager = mContext.getPackageManager(); List pkgList = manager.getInstalledPackages(0); for (int i = 0; i < pkgList.size(); i++) { PackageInfo pI = pkgList.get(i); if (pI.packageName.equalsIgnoreCase("com.alipay.android.app")) return true; } return false; } /** * 安装安全支付服务,安装assets文件夹下的apk * * @param context * 上下文环境 * @param fileName * apk名称 * @param path * 安装路径 * @return */ public boolean retrieveApkFromAssets(Context context, String fileName, String path) { boolean bRet = false; try { InputStream is = context.getAssets().open(fileName); File file = new File(path); file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); byte[] temp = new byte[1024]; int i = 0; while ((i = is.read(temp)) > 0) { fos.write(temp, 0, i); } fos.close(); is.close(); bRet = true; } catch (IOException e) { e.printStackTrace(); } return bRet; } /** * 获取未安装的APK信息 * * @param context * @param archiveFilePath * APK文件的路径。如:/sdcard/download/XX.apk */ public static PackageInfo getApkInfo(Context context, String archiveFilePath) { PackageManager pm = context.getPackageManager(); PackageInfo apkInfo = pm.getPackageArchiveInfo(archiveFilePath, PackageManager.GET_META_DATA); return apkInfo; } /** * 检查是否有新版本,如果有,返回apk下载地址 * * @param packageInfo * {@link PackageInfo} * @return */ public String checkNewUpdate(PackageInfo packageInfo) { String url = null; try { JSONObject resp = sendCheckNewUpdate(packageInfo.versionName); // JSONObject resp = sendCheckNewUpdate("1.0.0"); if (resp.getString("needUpdate").equalsIgnoreCase("true")) { url = resp.getString("updateUrl"); } // else ok. } catch (Exception e) { e.printStackTrace(); } return url; } /** * 发送当前版本信息,返回是否需要升级 如果需要升级返回更新apk地址 * * @param versionName * 当前版本号 * @return */ public JSONObject sendCheckNewUpdate(String versionName) { JSONObject objResp = null; try { JSONObject req = new JSONObject(); req.put(AlixDefine.action, AlixDefine.actionUpdate); JSONObject data = new JSONObject(); data.put(AlixDefine.platform, "android"); data.put(AlixDefine.VERSION, versionName); data.put(AlixDefine.partner, ""); req.put(AlixDefine.data, data); objResp = sendRequest(req.toString()); } catch (JSONException e) { e.printStackTrace(); } return objResp; } /** * 发送json数据 * * @param content * @return */ public final static String server_url = "https://msp.alipay.com/x.htm"; public JSONObject sendRequest(final String content) { NetworkManager nM = new NetworkManager(this.mContext); // JSONObject jsonResponse = null; try { String response = null; synchronized (nM) { // response = nM.SendAndWaitResponse(content, server_url); } jsonResponse = new JSONObject(response); } catch (Exception e) { e.printStackTrace(); } // if (jsonResponse != null) BaseHelper.log(TAG, jsonResponse.toString()); return jsonResponse; } /** * 动态下载apk * * @param context * 上下文环境 * @param strurl * 下载地址 * @param filename * 文件名称 * @return */ public boolean retrieveApkFromNet(Context context, String strurl, String filename) { boolean bRet = false; try { NetworkManager nM = new NetworkManager(this.mContext); bRet = nM.urlDownloadToFile(context, strurl, filename); } catch (Exception e) { e.printStackTrace(); } return bRet; } // // close the progress bar void closeProgress() { try { if (mProgress != null) { mProgress.dismiss(); mProgress = null; } } catch (Exception e) { e.printStackTrace(); } } // // the handler use to receive the install check result. // 此处接收安装检测结果 private Handler mHandler = new Handler() { public void handleMessage(Message msg) { try { switch (msg.what) { case AlixId.RQF_INSTALL_CHECK: { // closeProgress(); String cachePath = (String) msg.obj; showInstallConfirmDialog(mContext, cachePath); } break; } super.handleMessage(msg); } catch (Exception e) { e.printStackTrace(); } } }; } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/MobileSecurePayer.java ================================================ /* * Copyright (C) 2010 The MobileSecurePay Project * All right reserved. * author: shiqun.shi@alipay.com */ package org.cocos2dx.plugin; import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.RemoteException; import com.alipay.android.app.IAlixPay; import com.alipay.android.app.IRemoteServiceCallback; /** * 和安全支付服务通信,发送订单信息进行支付,接收支付宝返回信息 * */ public class MobileSecurePayer { static String TAG = "MobileSecurePayer"; Integer lock = 0; IAlixPay mAlixPay = null; boolean mbPaying = false; Activity mActivity = null; // 和安全支付服务建立连接 private ServiceConnection mAlixPayConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { // // wake up the binder to continue. // 获得通信通道 synchronized (lock) { mAlixPay = IAlixPay.Stub.asInterface(service); lock.notify(); } } public void onServiceDisconnected(ComponentName className) { mAlixPay = null; } }; /** * 向支付宝发送支付请求 * * @param strOrderInfo * 订单信息 * @param callback * 回调handler * @param myWhat * 回调信息 * @param activity * 目标activity * @return */ public boolean pay(final String strOrderInfo, final Handler callback, final int myWhat, final Activity activity) { if (mbPaying) return false; mbPaying = true; // mActivity = activity; // bind the service. // 绑定服务 if (mAlixPay == null) { // 绑定安全支付服务需要获取上下文环境, // 如果绑定不成功使用mActivity.getApplicationContext().bindService // 解绑时同理 mActivity.getApplicationContext().bindService( new Intent(IAlixPay.class.getName()), mAlixPayConnection, Context.BIND_AUTO_CREATE); } // else ok. // 实例一个线程来进行支付 new Thread(new Runnable() { public void run() { try { // wait for the service bind operation to completely // finished. // Note: this is important,otherwise the next mAlixPay.Pay() // will fail. // 等待安全支付服务绑定操作结束 // 注意:这里很重要,否则mAlixPay.Pay()方法会失败 synchronized (lock) { if (mAlixPay == null) lock.wait(); } // register a Callback for the service. // 为安全支付服务注册一个回调 mAlixPay.registerCallback(mCallback); // call the MobileSecurePay service. // 调用安全支付服务的pay方法 String strRet = mAlixPay.Pay(strOrderInfo); BaseHelper.log(TAG, "After Pay: " + strRet); // set the flag to indicate that we have finished. // unregister the Callback, and unbind the service. // 将mbPaying置为false,表示支付结束 // 移除回调的注册,解绑安全支付服务 mbPaying = false; mAlixPay.unregisterCallback(mCallback); mActivity.getApplicationContext().unbindService( mAlixPayConnection); // send the result back to caller. // 发送交易结果 Message msg = new Message(); msg.what = myWhat; msg.obj = strRet; callback.sendMessage(msg); } catch (Exception e) { e.printStackTrace(); // send the result back to caller. // 发送交易结果 Message msg = new Message(); msg.what = myWhat; msg.obj = e.toString(); callback.sendMessage(msg); } } }).start(); return true; } /** * This implementation is used to receive callbacks from the remote service. * 实现安全支付的回调 */ private IRemoteServiceCallback mCallback = new IRemoteServiceCallback.Stub() { /** * This is called by the remote service regularly to tell us about new * values. Note that IPC calls are dispatched through a thread pool * running in each process, so the code executing here will NOT be * running in our main thread like most other things -- so, to update * the UI, we need to use a Handler to hop over there. * 通过IPC机制启动安全支付服务 */ public void startActivity(String packageName, String className, int iCallingPid, Bundle bundle) throws RemoteException { Intent intent = new Intent(Intent.ACTION_MAIN, null); if (bundle == null) bundle = new Bundle(); // else ok. try { bundle.putInt("CallingPid", iCallingPid); intent.putExtras(bundle); } catch (Exception e) { e.printStackTrace(); } intent.setClassName(packageName, className); mActivity.startActivity(intent); } }; } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/NetworkManager.java ================================================ /* * Copyright (C) 2010 The MobileSecurePay Project * All right reserved. * author: shiqun.shi@alipay.com */ package org.cocos2dx.plugin; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URL; import java.util.ArrayList; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.message.BasicNameValuePair; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; /** * 网络连接工具类 * */ public class NetworkManager { static final String TAG = "NetworkManager"; private int connectTimeout = 30 * 1000; private int readTimeout = 30 * 1000; Proxy mProxy = null; Context mContext; public NetworkManager(Context context) { this.mContext = context; setDefaultHostnameVerifier(); } /** * 检查代理,是否cnwap接入 */ private void detectProxy() { ConnectivityManager cm = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.isAvailable() && ni.getType() == ConnectivityManager.TYPE_MOBILE) { String proxyHost = android.net.Proxy.getDefaultHost(); int port = android.net.Proxy.getDefaultPort(); if (proxyHost != null) { final InetSocketAddress sa = new InetSocketAddress(proxyHost, port); mProxy = new Proxy(Proxy.Type.HTTP, sa); } } } private void setDefaultHostnameVerifier() { // HostnameVerifier hv = new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }; HttpsURLConnection.setDefaultHostnameVerifier(hv); } /** * 发送和接收数据 * * @param strReqData * 请求数据 * @param strUrl * 请求地址 * @return */ public String SendAndWaitResponse(String strReqData, String strUrl) { // detectProxy(); String strResponse = null; ArrayList pairs = new ArrayList(); pairs.add(new BasicNameValuePair("requestData", strReqData)); HttpURLConnection httpConnect = null; UrlEncodedFormEntity p_entity; try { p_entity = new UrlEncodedFormEntity(pairs, "utf-8"); URL url = new URL(strUrl); if (mProxy != null) { httpConnect = (HttpURLConnection) url.openConnection(mProxy); } else { httpConnect = (HttpURLConnection) url.openConnection(); } httpConnect.setConnectTimeout(connectTimeout); httpConnect.setReadTimeout(readTimeout); httpConnect.setDoOutput(true); httpConnect.addRequestProperty("Content-type", "application/x-www-form-urlencoded;charset=utf-8"); httpConnect.connect(); OutputStream os = httpConnect.getOutputStream(); p_entity.writeTo(os); os.flush(); InputStream content = httpConnect.getInputStream(); strResponse = BaseHelper.convertStreamToString(content); BaseHelper.log(TAG, "response " + strResponse); } catch (IOException e) { e.printStackTrace(); } finally { httpConnect.disconnect(); } return strResponse; } /** * 下载文件 * * @param context * 上下文环境 * @param strurl * 下载地址 * @param path * 下载路径 * @return */ public boolean urlDownloadToFile(Context context, String strurl, String path) { boolean bRet = false; // detectProxy(); try { URL url = new URL(strurl); HttpURLConnection conn = null; if (mProxy != null) { conn = (HttpURLConnection) url.openConnection(mProxy); } else { conn = (HttpURLConnection) url.openConnection(); } conn.setConnectTimeout(connectTimeout); conn.setReadTimeout(readTimeout); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); File file = new File(path); file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); byte[] temp = new byte[1024]; int i = 0; while ((i = is.read(temp)) > 0) { fos.write(temp, 0, i); } fos.close(); is.close(); bRet = true; } catch (IOException e) { e.printStackTrace(); } return bRet; } } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/PartnerConfig.java ================================================ package org.cocos2dx.plugin; public class PartnerConfig { // 合作商户ID。用签约支付宝账号登录ms.alipay.com后,在账户信息页面获取。 public static String PARTNER = ""; // 商户收款的支付宝账号 public static String SELLER = ""; // 商户(RSA)私钥 public static String RSA_PRIVATE = ""; // 支付宝(RSA)公钥 用签约支付宝账号登录ms.alipay.com后,在密钥管理页面获取。 public static String RSA_ALIPAY_PUBLIC = ""; // 支付宝安全支付服务apk的名称,必须与assets目录下的apk名称一致 public static String ALIPAY_PLUGIN_NAME = ""; } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/ResultChecker.java ================================================ package org.cocos2dx.plugin; import org.json.JSONObject; /** * 对签名进行验签 * */ public class ResultChecker { public static final int RESULT_INVALID_PARAM = 0; public static final int RESULT_CHECK_SIGN_FAILED = 1; public static final int RESULT_CHECK_SIGN_SUCCEED = 2; String mContent; public ResultChecker(String content) { this.mContent = content; } /** * 从验签内容中获取成功状态 * * @return */ private String getSuccess() { String success = null; try { JSONObject objContent = BaseHelper.string2JSON(this.mContent, ";"); String result = objContent.getString("result"); result = result.substring(1, result.length() - 1); JSONObject objResult = BaseHelper.string2JSON(result, "&"); success = objResult.getString("success"); success = success.replace("\"", ""); } catch (Exception e) { e.printStackTrace(); } return success; } /** * 对签名进行验签 * * @return */ int checkSign() { int retVal = RESULT_CHECK_SIGN_SUCCEED; try { JSONObject objContent = BaseHelper.string2JSON(this.mContent, ";"); String result = objContent.getString("result"); result = result.substring(1, result.length() - 1); // 获取待签名数据 int iSignContentEnd = result.indexOf("&sign_type="); String signContent = result.substring(0, iSignContentEnd); // 获取签名 JSONObject objResult = BaseHelper.string2JSON(result, "&"); String signType = objResult.getString("sign_type"); signType = signType.replace("\"", ""); String sign = objResult.getString("sign"); sign = sign.replace("\"", ""); // 进行验签 返回验签结果 if (signType.equalsIgnoreCase("RSA")) { if (!Rsa.doCheck(signContent, sign, PartnerConfig.RSA_ALIPAY_PUBLIC)) retVal = RESULT_CHECK_SIGN_FAILED; } } catch (Exception e) { retVal = RESULT_INVALID_PARAM; e.printStackTrace(); } return retVal; } int getResultStatus() { int ret = 9000; try { JSONObject objContent = BaseHelper.string2JSON(this.mContent, ";"); String result = objContent.getString("resultStatus"); result = result.substring(1, result.length() - 1); ret = Integer.parseInt(result); } catch (Exception e) { e.printStackTrace(); ret = 4001; } return ret; } private static final int PAY_SUCCESS_STATUS_CODE = 9000; public boolean isPayOk() { boolean isPayOk = false; String success = getSuccess(); if (success.equalsIgnoreCase("true") && checkSign() == RESULT_CHECK_SIGN_SUCCEED && PAY_SUCCESS_STATUS_CODE == getResultStatus()) { isPayOk = true; } return isPayOk; } } ================================================ FILE: cocos2d/plugin/plugins/alipay/proj.android/src/org/cocos2dx/plugin/Rsa.java ================================================ /* * Copyright (C) 2010 The MobileSecurePay Project * All right reserved. * author: shiqun.shi@alipay.com */ package org.cocos2dx.plugin; import java.security.KeyFactory; import java.security.PrivateKey; import java.security.PublicKey; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; /** * RSA工具类 * */ public class Rsa { // private static final String ALGORITHM = "RSA"; // private static PublicKey getPublicKeyFromX509(String algorithm, // String bysKey) throws NoSuchAlgorithmException, Exception { // byte[] decodedKey = Base64.decode(bysKey); // X509EncodedKeySpec x509 = new X509EncodedKeySpec(decodedKey); // // KeyFactory keyFactory = KeyFactory.getInstance(algorithm); // return keyFactory.generatePublic(x509); // } // public static String encrypt(String content, String key) { // try { // PublicKey pubkey = getPublicKeyFromX509(ALGORITHM, key); // // Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); // cipher.init(Cipher.ENCRYPT_MODE, pubkey); // // byte plaintext[] = content.getBytes("UTF-8"); // byte[] output = cipher.doFinal(plaintext); // // String s = new String(Base64.encode(output)); // // return s; // // } catch (Exception e) { // e.printStackTrace(); // return null; // } // } public static final String SIGN_ALGORITHMS = "SHA1WithRSA"; public static String sign(String content, String privateKey) { String charset = "utf-8"; try { PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec( Base64.decode(privateKey)); KeyFactory keyf = KeyFactory.getInstance("RSA"); PrivateKey priKey = keyf.generatePrivate(priPKCS8); java.security.Signature signature = java.security.Signature .getInstance(SIGN_ALGORITHMS); signature.initSign(priKey); signature.update(content.getBytes(charset)); byte[] signed = signature.sign(); return Base64.encode(signed); } catch (Exception e) { e.printStackTrace(); } return null; } public static boolean doCheck(String content, String sign, String publicKey) { try { KeyFactory keyFactory = KeyFactory.getInstance("RSA"); byte[] encodedKey = Base64.decode(publicKey); PublicKey pubKey = keyFactory .generatePublic(new X509EncodedKeySpec(encodedKey)); java.security.Signature signature = java.security.Signature .getInstance(SIGN_ALGORITHMS); signature.initVerify(pubKey); signature.update(content.getBytes("utf-8")); boolean bverify = signature.verify(Base64.decode(sign)); return bverify; } catch (Exception e) { e.printStackTrace(); } return false; } } ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/.classpath ================================================ ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/.project ================================================ libPluginFlurry 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 ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/AndroidManifest.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/ForManifest.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/build.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/project.properties ================================================ # 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-7 android.library=true android.library.reference.1=../../../protocols/proj.android ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/res/.gitignore ================================================ ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/src/org/cocos2dx/plugin/AdsFlurry.java ================================================ /**************************************************************************** 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. ****************************************************************************/ package org.cocos2dx.plugin; import java.util.Hashtable; import android.content.Context; import android.text.TextUtils; import android.util.Log; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.FrameLayout; import com.flurry.android.FlurryAdListener; import com.flurry.android.FlurryAdSize; import com.flurry.android.FlurryAdType; import com.flurry.android.FlurryAds; import com.flurry.android.FlurryAgent; public class AdsFlurry implements InterfaceAds, FlurryAdListener { private Context mContext = null; protected static String TAG = "AdsFlurry"; private FrameLayout mBannerView = null; private WindowManager mWm = null; private AdsFlurry mAdapter = null; protected static void LogE(String msg, Exception e) { Log.e(TAG, msg, e); e.printStackTrace(); } private static boolean isDebug = false; protected static void LogD(String msg) { if (isDebug) { Log.d(TAG, msg); } } public AdsFlurry(Context context) { mContext = context; mAdapter = this; } @Override public void setDebugMode(boolean isDebugMode) { isDebug = isDebugMode; final boolean curDebug = isDebug; PluginWrapper.runOnMainThread(new Runnable(){ @Override public void run() { FlurryAgent.setLogEnabled(curDebug); if (curDebug) { FlurryAgent.setLogLevel(Log.DEBUG); } } }); } @Override public String getSDKVersion() { return "3.2.1"; } @Override public String getPluginVersion() { return "0.2.0"; } @Override public void configDeveloperInfo(Hashtable devInfo) { final Hashtable curInfo = devInfo; PluginWrapper.runOnMainThread(new Runnable(){ @Override public void run() { try { String appKey = curInfo.get("FlurryAppKey"); FlurryAgent.onStartSession(mContext, appKey); FlurryAds.setAdListener(mAdapter); FlurryAds.initializeAds(mContext); } catch (Exception e) { LogE("Error during configDeveloperInfo.", e); } } }); } @Override public void showAds(Hashtable adsInfo, int pos) { final Hashtable curInfo = adsInfo; final int curPos = pos; PluginWrapper.runOnMainThread(new Runnable(){ @Override public void run() { try { String spaceID = curInfo.get("FlurryAdsID"); if (null == spaceID || TextUtils.isEmpty(spaceID)) { LogD("Value of 'FlurryAdsID' should not be empty"); return; } String strSize = curInfo.get("FlurryAdsSize"); int size = Integer.parseInt(strSize); if (size != 1 && size != 2 && size != 3) { LogD("Valur of 'FlurryAdsSize' should be one of '1', '2', '3'"); return; } FlurryAdSize eSize = FlurryAdSize.BANNER_TOP; switch (size) { case 1: eSize = FlurryAdSize.BANNER_TOP; break; case 2: eSize = FlurryAdSize.BANNER_BOTTOM; break; case 3: eSize = FlurryAdSize.FULLSCREEN; break; default: break; } if (null == mWm) { mWm = (WindowManager) mContext.getSystemService("window"); } if (null != mBannerView) { mWm.removeView(mBannerView); mBannerView = null; } mBannerView = new FrameLayout(mContext); AdsWrapper.addAdView(mWm, mBannerView, curPos); FlurryAds.fetchAd(mContext, spaceID, mBannerView, eSize); } catch (Exception e) { LogE("Error during showAds", e); } } }); } @Override public void hideAds(Hashtable adsInfo) { final Hashtable curInfo = adsInfo; PluginWrapper.runOnMainThread(new Runnable(){ @Override public void run() { try { String spaceID = curInfo.get("FlurryAdsID"); if (null == spaceID || TextUtils.isEmpty(spaceID)) { LogD("Value of 'FlurryAdsID' should not be empty"); return; } FlurryAds.removeAd(mContext, spaceID, (ViewGroup) mBannerView); } catch (Exception e) { LogE("Error during hideAds", e); } } }); } @Override public void queryPoints() { // TODO Auto-generated method stub } @Override public void spendPoints(int points) { // TODO Auto-generated method stub } @Override public void onAdClicked(String arg0) { // TODO Auto-generated method stub } @Override public void onAdClosed(String arg0) { AdsWrapper.onAdsResult(this, AdsWrapper.RESULT_CODE_AdsDismissed, "Ads will be dismissed"); } @Override public void onAdOpened(String arg0) { // TODO Auto-generated method stub } @Override public void onApplicationExit(String arg0) { // TODO Auto-generated method stub } @Override public void onRenderFailed(String arg0) { // TODO Auto-generated method stub } @Override public void onVideoCompleted(String arg0) { // TODO Auto-generated method stub } @Override public boolean shouldDisplayAd(String arg0, FlurryAdType arg1) { AdsWrapper.onAdsResult(this, AdsWrapper.RESULT_CODE_AdsShown, "Ads will be shown"); return true; } @Override public void spaceDidFailToReceiveAd(String arg0) { LogD("param : " + arg0); AdsWrapper.onAdsResult(this, AdsWrapper.RESULT_CODE_UnknownError, "Failed to receive Ads of flurry"); } @Override public void spaceDidReceiveAd(String arg0) { AdsWrapper.onAdsResult(this, AdsWrapper.RESULT_CODE_AdsReceived, "Ads of flurry received"); } } ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.android/src/org/cocos2dx/plugin/AnalyticsFlurry.java ================================================ /**************************************************************************** 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. ****************************************************************************/ package org.cocos2dx.plugin; import java.util.Hashtable; import java.util.Iterator; import org.json.JSONObject; import android.content.Context; import android.util.Log; import com.flurry.android.Constants; import com.flurry.android.FlurryAgent; public class AnalyticsFlurry implements InterfaceAnalytics { private Context mContext = null; protected static String TAG = "AnalyticsFlurry"; protected static void LogE(String msg, Exception e) { Log.e(TAG, msg, e); e.printStackTrace(); } private static boolean isDebug = false; protected static void LogD(String msg) { if (isDebug) { Log.d(TAG, msg); } } public AnalyticsFlurry(Context context) { mContext = context; } @Override public void startSession(String appKey) { LogD("startSession invoked!"); final String curKey = appKey; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try { Class.forName("android.os.AsyncTask"); } catch (ClassNotFoundException e) { e.printStackTrace(); } FlurryAgent.onStartSession(mContext, curKey); } }); } @Override public void stopSession() { LogD("stopSession invoked!"); PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.onEndSession(mContext); } }); } @Override public void setSessionContinueMillis(int millis) { LogD("setSessionContinueMillis invoked!"); final int curMillis = millis; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.setContinueSessionMillis(curMillis); } }); } @Override public void setCaptureUncaughtException(boolean isEnabled) { LogD("setCaptureUncaughtException invoked!"); final boolean curEnable = isEnabled; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.setCaptureUncaughtExceptions(curEnable); } }); } @Override public void setDebugMode(boolean isDebugMode) { isDebug = isDebugMode; final boolean curDebugMode = isDebug; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.setLogEnabled(curDebugMode); if (curDebugMode) { FlurryAgent.setLogLevel(Log.DEBUG); } } }); } @Override public void logError(String errorId, String message) { LogD("logError invoked!"); final String curID = errorId; final String curMsg = message; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.onError(curID, curMsg, ""); } }); } @Override public void logEvent(String eventId) { LogD("logEvent(eventId) invoked!"); final String curId = eventId; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.logEvent(curId); } }); } @Override public void logEvent(String eventId, Hashtable paramMap) { LogD("logEvent(eventId, paramMap) invoked!"); final String curId = eventId; final Hashtable curParam = paramMap; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.logEvent(curId, curParam); } }); } @Override public void logTimedEventBegin(String eventId) { LogD("logTimedEventBegin invoked!"); final String curId = eventId; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.logEvent(curId, true); } }); } @Override public void logTimedEventEnd(String eventId) { LogD("logTimedEventEnd invoked!"); final String curId = eventId; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { FlurryAgent.endTimedEvent(curId); } }); } @Override public String getSDKVersion() { return "3.2.1"; } protected void logTimedEventBeginWithParams(JSONObject eventInfo) { LogD("logTimedEventBegin invoked!"); final JSONObject curInfo = eventInfo; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try{ String eventId = curInfo.getString("Param1"); if (curInfo.has("Param2")) { JSONObject params = curInfo.getJSONObject("Param2"); @SuppressWarnings("rawtypes") Iterator it = params.keys(); Hashtable paramMap = new Hashtable(); while (it.hasNext()) { String key = (String) it.next(); String value = params.getString(key); paramMap.put(key, value); } FlurryAgent.logEvent(eventId, paramMap, true); } else { FlurryAgent.logEvent(eventId, true); } } catch(Exception e){ LogE("Exception in logTimedEventBegin", e); } } }); } protected void setReportLocation(boolean enabled) { LogD("setReportLocation invoked!"); final boolean curEnable = enabled; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try{ FlurryAgent.setReportLocation(curEnable); } catch(Exception e){ LogE("Exception in setReportLocation", e); } } }); } protected void logPageView() { LogD("logPageView invoked!"); PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try{ FlurryAgent.onPageView(); } catch(Exception e){ LogE("Exception in logPageView", e); } } }); } protected void setVersionName(String versionName) { LogD("setVersionName invoked!"); final String curVer = versionName; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try { FlurryAgent.setVersionName(curVer); } catch(Exception e){ LogE("Exception in setVersionName", e); } } }); } protected void setAge(int age) { LogD("setAge invoked!"); final int curAge = age; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try { FlurryAgent.setAge(curAge); } catch(Exception e){ LogE("Exception in setAge", e); } } }); } protected void setGender(int gender) { LogD("setGender invoked!"); final int curGender = gender; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try { byte bGender; if (1 == curGender) { bGender = Constants.MALE; } else { bGender = Constants.FEMALE; } FlurryAgent.setGender(bGender); } catch(Exception e){ LogE("Exception in setGender", e); } } }); } protected void setUserId(String userId) { LogD("setUserId invoked!"); final String curUser = userId; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try { FlurryAgent.setUserId(curUser); } catch(Exception e){ LogE("Exception in setUserId", e); } } }); } protected void setUseHttps(boolean useHttps) { LogD("setUseHttps invoked!"); final boolean curCfg = useHttps; PluginWrapper.runOnMainThread(new Runnable() { @Override public void run() { try { FlurryAgent.setUseHttps(curCfg); } catch(Exception e){ LogE("Exception in setUseHttps", e); } } }); } @Override public String getPluginVersion() { return "0.2.0"; } } ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.ios/AdsFlurry.h ================================================ /**************************************************************************** Copyright (c) 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 "InterfaceAds.h" #import "FlurryAdDelegate.h" @interface AdsFlurry : NSObject { } @property BOOL debug; /** interfaces of protocol : InterfaceAds */ - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; - (void) showAds: (NSMutableDictionary*) info position:(int) pos; - (void) hideAds: (NSMutableDictionary*) info; - (void) queryPoints; - (void) spendPoints: (int) points; - (void) setDebugMode: (BOOL) isDebugMode; - (NSString*) getSDKVersion; - (NSString*) getPluginVersion; /** interfaces of protocol : FlurryAdDelegate */ - (void) spaceDidReceiveAd:(NSString*)adSpace; - (void) spaceDidFailToReceiveAd:(NSString*)adSpace error:(NSError *)error; - (BOOL) spaceShouldDisplay:(NSString*)adSpace interstitial:(BOOL)interstitial; @end ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.ios/AdsFlurry.m ================================================ /**************************************************************************** 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 "AdsFlurry.h" #import "Flurry.h" #import "FlurryAds.h" #import "AdsWrapper.h" #define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__); @implementation AdsFlurry @synthesize debug = __debug; #pragma mark Interfaces for ProtocolAds impl - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo { NSString* appKey = [devInfo objectForKey:@"FlurryAppKey"]; if (appKey) { [Flurry startSession:appKey]; } [FlurryAds initialize:[AdsWrapper getCurrentRootViewController]]; [FlurryAds setAdDelegate:self]; } - (void) showAds: (NSMutableDictionary*) info position:(int) pos { NSString* strSpaceID = [info objectForKey:@"FlurryAdsID"]; if (! strSpaceID || [strSpaceID length] == 0) { OUTPUT_LOG(@"Value of 'FlurryAdsID' should not be empty"); return; } NSString* strSize = [info objectForKey:@"FlurryAdsSize"]; int size = [strSize intValue]; if (size != 1 && size != 2 && size != 3) { OUTPUT_LOG(@"Value of 'FlurryAdsSize' should be one of '1', '2', '3' "); return; } UIViewController* controller = [AdsWrapper getCurrentRootViewController]; if (controller) { [FlurryAds fetchAndDisplayAdForSpace:strSpaceID view:controller.view size:size]; } } - (void) hideAds: (NSMutableDictionary*) info { NSString* strSpaceID = [info objectForKey:@"FlurryAdsID"]; if (! strSpaceID || [strSpaceID length] == 0) { OUTPUT_LOG(@"Value of 'FlurryAdsID' should not be empty"); return; } [FlurryAds removeAdFromSpace:strSpaceID]; } - (void) queryPoints { } - (void) spendPoints: (int) points { } - (void) setDebugMode: (BOOL) isDebugMode { OUTPUT_LOG(@"Flurry setDebugMode invoked(%d)", isDebugMode); self.debug = isDebugMode; [Flurry setDebugLogEnabled:isDebugMode]; if (self.debug) { [FlurryAds enableTestAds:YES]; } } - (NSString*) getSDKVersion { return @"4.2.1"; } - (NSString*) getPluginVersion { return @"0.2.0"; } #pragma mark Interfaces for FlurryAdDelegate impl - (void) spaceDidReceiveAd:(NSString*)adSpace { [AdsWrapper onAdsResult:self withRet:kAdsReceived withMsg:@"Ads of flurry received"]; } - (void) spaceDidFailToReceiveAd:(NSString*)adSpace error:(NSError *)error { NSString* strMsg = [[error userInfo] objectForKey:@"NSLocalizedDescription"]; if (! strMsg) { strMsg = @"Failed to receive ads"; } [AdsWrapper onAdsResult:self withRet:kUnknownError withMsg:strMsg]; } - (BOOL) spaceShouldDisplay:(NSString*)adSpace interstitial:(BOOL)interstitial { [AdsWrapper onAdsResult:self withRet:kAdsShown withMsg:@"Ads will be shown"]; return YES; } - (void) spaceWillDismiss:(NSString *)adSpace { [AdsWrapper onAdsResult:self withRet:kAdsDismissed withMsg:@"Ads will be dismissed"]; } @end ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.ios/AnalyticsFlurry.h ================================================ /**************************************************************************** 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 "InterfaceAnalytics.h" @interface AnalyticsFlurry : NSObject { } @property BOOL debug; /** interfaces of protocol : InterfaceAnalytics */ - (void) startSession: (NSString*) appKey; - (void) stopSession; - (void) setSessionContinueMillis: (long) millis; - (void) setCaptureUncaughtException: (BOOL) isEnabled; - (void) setDebugMode: (BOOL) isDebugMode; - (void) logError: (NSString*) errorId withMsg:(NSString*) message; - (void) logEvent: (NSString*) eventId; - (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap; - (void) logTimedEventBegin: (NSString*) eventId; - (void) logTimedEventEnd: (NSString*) eventId; - (NSString*) getSDKVersion; - (NSString*) getPluginVersion; /** interfaces of flurry SDK */ - (void) setAge: (NSNumber*) age; - (void) setGender: (NSNumber*) gender; - (void) setUserId: (NSString*) userId; - (void) setUseHttps: (NSNumber*) enabled; - (void) logPageView; - (void) setVersionName: (NSString*) versionName; - (void) logTimedEventBeginWithParams: (NSMutableDictionary*) params; - (void) logTimedEventEndWithParams: (NSMutableDictionary*) params; @end ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.ios/AnalyticsFlurry.m ================================================ /**************************************************************************** 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 "AnalyticsFlurry.h" #import "Flurry.h" #define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__); @implementation AnalyticsFlurry @synthesize debug = __debug; - (void) startSession: (NSString*) appKey { [Flurry startSession:appKey]; } - (void) stopSession { OUTPUT_LOG(@"Flurry stopSession in flurry not available on iOS"); } - (void) setSessionContinueMillis: (long) millis { OUTPUT_LOG(@"Flurry setSessionContinueMillis invoked(%ld)", millis); int seconds = (int)(millis / 1000); [Flurry setSessionContinueSeconds:seconds]; } - (void) setCaptureUncaughtException: (BOOL) isEnabled { OUTPUT_LOG(@"Flurry setCaptureUncaughtException in flurry not available on iOS"); } - (void) setDebugMode: (BOOL) isDebugMode { OUTPUT_LOG(@"Flurry setDebugMode invoked(%d)", isDebugMode); self.debug = isDebugMode; [Flurry setDebugLogEnabled:isDebugMode]; } - (void) logError: (NSString*) errorId withMsg:(NSString*) message { OUTPUT_LOG(@"Flurry logError invoked(%@, %@)", errorId, message); NSString* msg = nil; if (nil == message) { msg = @""; } else { msg = message; } [Flurry logError:errorId message:msg exception:nil]; } - (void) logEvent: (NSString*) eventId { OUTPUT_LOG(@"Flurry logEvent invoked(%@)", eventId); [Flurry logEvent:eventId]; } - (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap { OUTPUT_LOG(@"Flurry logEventWithParams invoked (%@, %@)", eventId, [paramMap debugDescription]); [Flurry logEvent:eventId withParameters:paramMap]; } - (void) logTimedEventBegin: (NSString*) eventId { OUTPUT_LOG(@"Flurry logTimedEventBegin invoked (%@)", eventId); [Flurry logEvent:eventId timed:YES]; } - (void) logTimedEventEnd: (NSString*) eventId { OUTPUT_LOG(@"Flurry logTimedEventEnd invoked (%@)", eventId); [Flurry endTimedEvent:eventId withParameters:nil]; } - (NSString*) getSDKVersion { return @"4.2.1"; } - (NSString*) getPluginVersion { return @"0.2.0"; } - (void) setAge: (NSNumber*) age { int nAge = [age integerValue]; OUTPUT_LOG(@"Flurry setAge invoked (%d)", nAge); [Flurry setAge:nAge]; } - (void) setGender: (NSNumber*) gender { OUTPUT_LOG(@"Flurry setGender invoked (%@)", gender); int nValue = [gender intValue]; NSString* strGender; if (nValue == 1) { strGender = @"m"; } else { strGender = @"f"; } [Flurry setGender:strGender]; } - (void) setUserId: (NSString*) userId { OUTPUT_LOG(@"Flurry setUserId invoked (%@)", userId); [Flurry setUserID:userId]; } - (void) setUseHttps: (NSNumber*) enabled { BOOL bEnabled = [enabled boolValue]; OUTPUT_LOG(@"Flurry setUseHttps invoked (%@)", enabled); [Flurry setSecureTransportEnabled:bEnabled]; } - (void) logPageView { OUTPUT_LOG(@"Flurry logPageView invoked"); [Flurry logPageView]; } - (void) setVersionName: (NSString*) versionName { OUTPUT_LOG(@"Flurry setVersionName invoked (%@)", versionName); [Flurry setAppVersion:versionName]; } - (void) logTimedEventBeginWithParams: (NSMutableDictionary*) paramMap { OUTPUT_LOG(@"Flurry logTimedEventBeginWithParams invoked (%@)", [paramMap debugDescription]); NSString* eventId = (NSString*) [paramMap objectForKey:@"Param1"]; NSMutableDictionary* params = (NSMutableDictionary*) [paramMap objectForKey:@"Param2"]; if (params) { [Flurry logEvent:eventId withParameters:paramMap timed:YES]; } else { [Flurry logEvent:eventId timed:YES]; } } - (void) logTimedEventEndWithParams: (NSMutableDictionary*) paramMap { OUTPUT_LOG(@"Flurry logTimedEventEndWithParams invoked (%@)", [paramMap debugDescription]); NSString* eventId = (NSString*) [paramMap objectForKey:@"Param1"]; NSMutableDictionary* params = (NSMutableDictionary*) [paramMap objectForKey:@"Param2"]; [Flurry endTimedEvent:eventId withParameters:params]; } @end ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.ios/Flurry.h ================================================ // // Flurry.h // Flurry iOS Analytics Agent // // Copyright 2009-2012 Flurry, Inc. All rights reserved. // // Methods in this header file are for use with Flurry Analytics #import /*! * @brief Provides all available methods for defining and reporting Analytics from use * of your app. * * Set of methods that allow developers to capture detailed, aggregate information * regarding the use of their app by end users. * * @note This class provides methods necessary for correct function of FlurryAds.h. * For information on how to use Flurry's Ads SDK to * attract high-quality users and monetize your user base see Support Center - Publishers. * * @author 2009 - 2012 Flurry, Inc. All Rights Reserved. * @version 4.2.0 * */ @interface Flurry : NSObject { } /** @name Pre-Session Calls * Optional sdk settings that should be called before start session. */ //@{ /*! * @brief Explicitly specifies the App Version that Flurry will use to group Analytics data. * @since 2.7 * * This is an optional method that overrides the App Version Flurry uses for reporting. Flurry will * use the CFBundleVersion in your info.plist file when this method is not invoked. * * @note There is a maximum of 605 versions allowed for a single app. \n * This method must be called prior to invoking #startSession:. * * @param version The custom version name. */ + (void)setAppVersion:(NSString *)version; /*! * @brief Retrieves the Flurry Agent Build Version. * @since 2.7 * * This is an optional method that retrieves the Flurry Agent Version the app is running under. * It is most often used if reporting an unexpected behavior of the SDK to * Flurry Support * * @note This method must be called prior to invoking #startSession:. \n * FAQ for the iPhone SDK is located at * Support Center - iPhone FAQ. * * @see #setDebugLogEnabled: for information on how to view debugging information on your console. * * @return The agent version of the Flurry SDK. * */ + (NSString *)getFlurryAgentVersion; /*! * @brief Displays an exception in the debug log if thrown during a Session. * @since 2.7 * * This is an optional method that augments the debug logs with exceptions that occur during the session. * You must both capture exceptions to Flurry and set debug logging to enabled for this method to * display information to the console. The default setting for this method is @c NO. * * @note This method must be called prior to invoking #startSession:. * * @see #setDebugLogEnabled: for information on how to view debugging information on your console. \n * #logError:message:exception: for details on logging exceptions. \n * #logError:message:error: for details on logging errors. * * @param value @c YES to show errors in debug logs, @c NO to omit errors in debug logs. */ + (void)setShowErrorInLogEnabled:(BOOL)value; /*! * @brief Generates debug logs to console. * @since 2.7 * * This is an optional method that displays debug information related to the Flurry SDK. * display information to the console. The default setting for this method is @c NO. * * @note This method must be called prior to invoking #startSession:. * * @param value @c YES to show debug logs, @c NO to omit debug logs. * */ + (void)setDebugLogEnabled:(BOOL)value; /*! * @brief Set the timeout for expiring a Flurry session. * @since 2.7 * * This is an optional method that sets the time the app may be in the background before * starting a new session upon resume. The default value for the session timeout is 10 * seconds in the background. * * @note This method must be called prior to invoking #startSession:. * * @param seconds The time in seconds to set the session timeout to. */ + (void)setSessionContinueSeconds:(int)seconds; /*! * @brief Send data over a secure transport. * @since 3.0 * * This is an optional method that sends data over an SSL connection when enabled. The * default value is @c NO. * * @note This method must be called prior to invoking #startSession:. * * @param value @c YES to send data over secure connection. */ + (void)setSecureTransportEnabled:(BOOL)value; /*! * @brief Enable automatic collection of crash reports. * @since 4.1 * * This is an optional method that collects crash reports when enabled. The * default value is @c NO. * * @note This method must be called prior to invoking #startSession:. * * @param value @c YES to enable collection of crash reports. */ + (void)setCrashReportingEnabled:(BOOL)value; //@} /*! * @brief Start a Flurry session for the project denoted by @c apiKey. * @since 2.6 * * This method serves as the entry point to Flurry Analytics collection. It must be * called in the scope of @c applicationDidFinishLaunching. The session will continue * for the period the app is in the foreground until your app is backgrounded for the * time specified in #setSessionContinueSeconds:. If the app is resumed in that period * the session will continue, otherwise a new session will begin. * * Crash reporting will not be enabled. See #startSession:enableCrashReporting: for * more information. * * @note If testing on a simulator, please be sure to send App to background via home * button. Flurry depends on the iOS lifecycle to be complete for full reporting. * * @see #setSessionContinueSeconds: for details on setting a custom session timeout. * * @code * - (void)applicationDidFinishLaunching:(UIApplication *)application { // Optional Flurry startup methods [Flurry startSession:@"YOUR_API_KEY"]; // .... } * @endcode * * @param apiKey The API key for this project. */ + (void)startSession:(NSString *)apiKey; /*! * @brief Start a Flurry session for the project denoted by @c apiKey. * @since 4.0.8 * * This method serves as the entry point to Flurry Analytics collection. It must be * called in the scope of @c applicationDidFinishLaunching passing in the launchOptions param. * The session will continue * for the period the app is in the foreground until your app is backgrounded for the * time specified in #setSessionContinueSeconds:. If the app is resumed in that period * the session will continue, otherwise a new session will begin. * * @note If testing on a simulator, please be sure to send App to background via home * button. Flurry depends on the iOS lifecycle to be complete for full reporting. * * @see #setSessionContinueSeconds: for details on setting a custom session timeout. * * @code * - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Optional Flurry startup methods [Flurry startSession:@"YOUR_API_KEY" withOptions:launchOptions]; // .... } * @endcode * * @param apiKey The API key for this project. * @param options passed launchOptions from the applicatin's didFinishLaunchingWithOptions:(NSDictionary *)launchOptions */ + (void) startSession:(NSString *)apiKey withOptions:(id)options; /** @name Event and Error Logging * Methods for reporting custom events and errors during the session. */ //@{ /*! * @brief Records a custom event specified by @c eventName. * @since 2.8.4 * * This method allows you to specify custom events within your app. As a general rule * you should capture events related to user navigation within your app, any action * around monetization, and other events as they are applicable to tracking progress * towards your business goals. * * @note You should not pass private or confidential information about your users in a * custom event. \n * Where applicable, you should make a concerted effort to use timed events with * parameters (#logEvent:withParameters:timed:) or events with parameters * (#logEvent:withParameters:). This provides valuable information around the time the user * spends within an action (e.g. - time spent on a level or viewing a page) or characteristics * of an action (e.g. - Buy Event that has a Parameter of Widget with Value Golden Sword). * * @see #logEvent:withParameters: for details on storing events with parameters. \n * #logEvent:timed: for details on storing timed events. \n * #logEvent:withParameters:timed: for details on storing timed events with parameters. \n * #endTimedEvent:withParameters: for details on stopping a timed event and (optionally) updating * parameters. * * @code * - (void)interestingAppAction { [Flurry logEvent:@"Interesting_Action"]; // Perform interesting action } * @endcode * * @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme * that can be easily understood by non-technical people in your business domain. */ + (void)logEvent:(NSString *)eventName; /*! * @brief Records a custom parameterized event specified by @c eventName with @c parameters. * @since 2.8.4 * * This method overrides #logEvent to allow you to associate parameters with an event. Parameters * are extremely valuable as they allow you to store characteristics of an action. For example, * if a user purchased an item it may be helpful to know what level that user was on. * By setting this parameter you will be able to view a distribution of levels for the purcahsed * event on the Flurrly Dev Portal. * * @note You should not pass private or confidential information about your users in a * custom event. \n * A maximum of 10 parameter names may be associated with any event. Sending * over 10 parameter names with a single event will result in no parameters being logged * for that event. You may specify an infinite number of Parameter values. For example, * a Search Box would have 1 parameter name (e.g. - Search Box) and many values, which would * allow you to see what values users look for the most in your app. \n * Where applicable, you should make a concerted effort to use timed events with * parameters (#logEvent:withParameters:timed:). This provides valuable information * around the time the user spends within an action (e.g. - time spent on a level or * viewing a page). * * @see #logEvent:withParameters:timed: for details on storing timed events with parameters. \n * #endTimedEvent:withParameters: for details on stopping a timed event and (optionally) updating * parameters. * * @code * - (void)userPurchasedSomethingCool { NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"Cool Item", // Parameter Value @"Item Purchased", // Parameter Name nil]; [Flurry logEvent:@"Something Cool Purchased" withParameters:params]; // Give user cool item } * @endcode * * @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme * that can be easily understood by non-technical people in your business domain. * @param parameters A map containing Name-Value pairs of parameters. */ + (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters; /*! * @brief Records an app exception. Commonly used to catch unhandled exceptions. * @since 2.7 * * This method captures an exception for reporting to Flurry. We recommend adding an uncaught * exception listener to capture any exceptions that occur during usage that is not * anticipated by your app. * * @see #logError:message:error: for details on capturing errors. * * @code * - (void) uncaughtExceptionHandler(NSException *exception) { [Flurry logError:@"Uncaught" message:@"Crash!" exception:exception]; } - (void)applicationDidFinishLaunching:(UIApplication *)application { NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); [Flurry startSession:@"YOUR_API_KEY"]; // .... } * @endcode * * @param errorID Name of the error. * @param message The message to associate with the error. * @param exception The exception object to report. */ + (void)logError:(NSString *)errorID message:(NSString *)message exception:(NSException *)exception; /*! * @brief Records an app error. * @since 2.7 * * This method captures an error for reporting to Flurry. * * @see #logError:message:exception: for details on capturing exceptions. * * @code * - (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { [Flurry logError:@"WebView No Load" message:[error localizedDescription] error:error]; } * @endcode * * @param errorID Name of the error. * @param message The message to associate with the error. * @param error The error object to report. */ + (void)logError:(NSString *)errorID message:(NSString *)message error:(NSError *)error; /*! * @brief Records a timed event specified by @c eventName. * @since 2.8.4 * * This method overrides #logEvent to allow you to capture the length of an event. This can * be extremely valuable to understand the level of engagement with a particular action. For * example, you can capture how long a user spends on a level or reading an article. * * @note You should not pass private or confidential information about your users in a * custom event. \n * Where applicable, you should make a concerted effort to use parameters with your timed * events (#logEvent:withParameters:timed:). This provides valuable information * around the characteristics of an action (e.g. - Buy Event that has a Parameter of Widget with * Value Golden Sword). * * @see #logEvent:withParameters:timed: for details on storing timed events with parameters. \n * #endTimedEvent:withParameters: for details on stopping a timed event and (optionally) updating * parameters. * * @code * - (void)startLevel { [Flurry logEvent:@"Level Played" timed:YES]; // Start user on level } - (void)endLevel { [Flurry endTimedEvent:@"Level Played" withParameters:nil]; // User done with level } * @endcode * * @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme * that can be easily understood by non-technical people in your business domain. * @param timed Specifies the event will be timed. */ + (void)logEvent:(NSString *)eventName timed:(BOOL)timed; /*! * @brief Records a custom parameterized timed event specified by @c eventName with @c parameters. * @since 2.8.4 * * This method overrides #logEvent to allow you to capture the length of an event with parameters. * This can be extremely valuable to understand the level of engagement with a particular action * and the characteristics associated with that action. For example, you can capture how long a user * spends on a level or reading an article. Parameters can be used to capture, for example, the * author of an article or if something was purchased while on the level. * * @note You should not pass private or confidential information about your users in a * custom event. * * @see #endTimedEvent:withParameters: for details on stopping a timed event and (optionally) updating * parameters. * * @code * - (void)startLevel { NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"100", // Parameter Value @"Current Points", // Parameter Name nil]; [Flurry logEvent:@"Level Played" withParameters:params timed:YES]; // Start user on level } - (void)endLevel { // User gained additional 100 points in Level NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"200", // Parameter Value @"Current Points", // Parameter Name nil]; [Flurry endTimedEvent:@"Level Played" withParameters:params]; // User done with level } * @endcode * * @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme * that can be easily understood by non-technical people in your business domain. * @param parameters A map containing Name-Value pairs of parameters. * @param timed Specifies the event will be timed. */ + (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters timed:(BOOL)timed; /*! * @brief Ends a timed event specified by @c eventName and optionally updates parameters with @c parameters. * @since 2.8.4 * * This method ends an existing timed event. If parameters are provided, this will overwrite existing * parameters with the same name or create new parameters if the name does not exist in the parameter * map set by #logEvent:withParameters:timed:. * * @note You should not pass private or confidential information about your users in a * custom event. \n * If the app is backgrounded prior to ending a timed event, the Flurry SDK will automatically * end the timer on the event. \n * #endTimedEvent:withParameters: is ignored if called on a previously * terminated event. * * @see #logEvent:withParameters:timed: for details on starting a timed event with parameters. * * @code * - (void)startLevel { NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"100", // Parameter Value @"Current Points", // Parameter Name nil]; [Flurry logEvent:@"Level Played" withParameters:params timed:YES]; // Start user on level } - (void)endLevel { // User gained additional 100 points in Level NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"200", // Parameter Value @"Current Points", // Parameter Name nil]; [Flurry endTimedEvent:@"Level Played" withParameters:params]; // User done with level } * @endcode * * @param eventName Name of the event. For maximum effectiveness, we recommend using a naming scheme * that can be easily understood by non-technical people in your business domain. * @param parameters A map containing Name-Value pairs of parameters. */ + (void)endTimedEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters; // non-nil parameters will update the parameters //@} /** @name Page View Methods * Count page views. */ //@{ /*! * @brief Automatically track page views on a @c UINavigationController or @c UITabBarController. * @since 2.7 * * This method increments the page view count for a session based on traversing a UINavigationController * or UITabBarController. The page view count is only a counter for the number of transitions in your * app. It does not associate a name with the page count. To associate a name with a count of occurences * see #logEvent:. * * @note Please make sure you assign the Tab and Navigation controllers to the view controllers before * passing them to this method. * * @see #logPageView for details on explictly incrementing page view count. * * @code * -(void) trackViewsFromTabBar:(UITabBarController*) tabBar { [Flurry logAllPageViews:tabBar]; } * @endcode * * @param target The navigation or tab bar controller. */ + (void)logAllPageViews:(id)target; /*! * @brief Explicitly track a page view during a session. * @since 2.7 * * This method increments the page view count for a session when invoked. It does not associate a name * with the page count. To associate a name with a count of occurences see #logEvent:. * * @see #logAllPageViews for details on automatically incrementing page view count based on user * traversing navigation or tab bar controller. * * @code * -(void) trackView { [Flurry logPageView]; } * @endcode * */ + (void)logPageView; //@} /** @name User Info * Methods to set user information. */ //@{ /*! * @brief Assign a unique id for a user in your app. * @since 2.7 * * @note Please be sure not to use this method to pass any private or confidential information * about the user. * * @param userID The app id for a user. */ + (void)setUserID:(NSString *)userID; /*! * @brief Set your user's age in years. * @since 2.7 * * Use this method to capture the age of your user. Only use this method if you collect this * information explictly from your user (i.e. - there is no need to set a default value). * * @note The age is aggregated across all users of your app and not available on a per user * basis. * * @param age Reported age of user. * */ + (void)setAge:(int)age; /*! * @brief Set your user's gender. * @since 2.7 * * Use this method to capture the gender of your user. Only use this method if you collect this * information explictly from your user (i.e. - there is no need to set a default value). Allowable * values are @c @"M" or @c @"F" * * @note The gender is aggregated across all users of your app and not available on a per user * basis. * * @param gender Reported gender of user. * */ + (void)setGender:(NSString *)gender; // user's gender m or f //@} /** @name Location Reporting * Methods for setting location information. */ //@{ /*! * @brief Set the location of the session. * @since 2.7 * * Use information from the CLLocationManager to specify the location of the session. Flurry does not * automatically track this information or include the CLLocation framework. * * @note Only the last location entered is captured per session. \n * Regardless of accuracy specified, the Flurry SDK will only report location at city level or higher. \n * Location is aggregated across all users of your app and not available on a per user basis. \n * This information should only be captured if it is germaine to the use of your app. * * @code CLLocationManager *locationManager = [[CLLocationManager alloc] init]; [locationManager startUpdatingLocation]; * @endcode * * After starting the location manager, you can set the location with Flurry. You can implement * CLLocationManagerDelegate to be aware of when the location is updated. Below is an example * of how to use this method, after you have recieved a location update from the locationManager. * * @code CLLocation *location = locationManager.location; [Flurry setLatitude:location.coordinate.latitude longitude:location.coordinate.longitude horizontalAccuracy:location.horizontalAccuracy verticalAccuracy:location.verticalAccuracy]; * @endcode * @param latitude The latitude. * @param longitude The longitude. * @param horizontalAccuracy The radius of uncertainty for the location in meters. * @param verticalAccuracy The accuracy of the altitude value in meters. * */ + (void)setLatitude:(double)latitude longitude:(double)longitude horizontalAccuracy:(float)horizontalAccuracy verticalAccuracy:(float)verticalAccuracy; //@} /** @name Session Reporting Calls * Optional methods that can be called at any point to control session reporting. */ //@{ /*! * @brief Set session to report when app closes. * @since 2.7 * * Use this method report session data when the app is closed. The default value is @c YES. * * @note This method is rarely invoked in iOS >= 3.2 due to the updated iOS lifecycle. * * @see #setSessionReportsOnPauseEnabled: * * @param sendSessionReportsOnClose YES to send on close, NO to omit reporting on close. * */ + (void)setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose; /*! * @brief Set session to report when app is sent to the background. * @since 2.7 * * Use this method report session data when the app is paused. The default value is @c YES. * * @param setSessionReportsOnPauseEnabled YES to send on pause, NO to omit reporting on pause. * */ + (void)setSessionReportsOnPauseEnabled:(BOOL)setSessionReportsOnPauseEnabled; /*! * @brief Enable custom event logging. * @since 2.7 * * Use this method to allow the capture of custom events. The default value is @c YES. * * @param value YES to enable event logging, NO to stop custom logging. * */ + (void)setEventLoggingEnabled:(BOOL)value; /*! * @brief Set device push token. * @since 2.7 * * After the device has successfully registered with APNS, call this method to set the push token received from APNS. * * */ + (void)setPushToken:(NSString *)pushToken; //@} @end ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.ios/FlurryAds/FlurryAdDelegate.h ================================================ // // FlurryAdDelegate.h // Flurry // // Copyright 2010 - 2012 Flurry, Inc. All rights reserved. // // Methods in this header file are for use with Flurry // #import typedef enum { WEB_BANNER = 1, WEB_TAKEOVER = 2, VIDEO_TAKEOVER = 3, AD_BANNER = 4, AD_TAKEOVER = 5, NETWORK_BANNER = 6, NETWORK_TAKEOVER = 7 } FlurryAdType; /*! * @brief Provides all available delegates for receiving callbacks related to Ad Serving. * * Set of methods that allow developers to manage and take actions within * different phases of App ad display. * * @note This class serves as a delegate for FlurryAds. \n * For additional information on how to use Flurry's Ads SDK to * attract high-quality users and monetize your user base see Support Center - Publisher. * @author 2010 - 2012 Flurry, Inc. All Rights Reserved. * @version 4.2.0 * */ @protocol FlurryAdDelegate @optional /*! * @brief Invoked when an ad is received for the specified @c adSpace. * @since 4.1 * * This method informs the app that an ad has been received and is available for display. * * @see FlurryAds#fetchAdForSpace:frame:size: for details on the method that will invoke this delegate. * * @param adSpace The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. */ - (void) spaceDidReceiveAd:(NSString*)adSpace; /*! * @brief Invoked when an ad can not be retrieved for the specified @c adSpace. * @since 4.1 * * This method informs the app that an ad has failed to be received for the given adSpace. * * @see FlurryAds#fetchAdForSpace:frame:size: for details on the method that will invoke this delegate. * * @param adSpace The placement of an ad in your app, where placement may * @param error The error, if known, that caused ads not to be received. * be splash screen for SPLASH_AD. */ - (void) spaceDidFailToReceiveAd:(NSString*)adSpace error:(NSError *)error; /*! * @brief Invoked when an ad is about to display on the specified @c adSpace. * @since 4.1.0 * * This method informs the app that an ad is about to be displayed. You can decide at this point not to show this ad by simply returning NO. * * @see FlurryAds#displayAdForSpace:view: for details on the method that will invoke this delegate. \n * FlurryAds#fetchAndDisplayAdForSpace:view:size: for details on the method that will invoke this delegate. * * @param adSpace The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. * @param interstitial YES/NO if the space to display will be an interstitial. */ - (BOOL) spaceShouldDisplay:(NSString*)adSpace interstitial:(BOOL)interstitial; /*! * @brief [Deprecated] This method is deprecated. -[spaceShouldDisplay:interstitial:] should be used. */ - (BOOL)spaceShouldDisplay:(NSString*)adSpace forType:(FlurryAdType)type; /*! * @brief Invoked when an ad fails to render. * @since 4.0.0 * * This method informs the user an ad was retrieved, however, was unsuccessful in displaying to the user (could be lost network connectivity for example). * * @see FlurryAds#displayAdForSpace:view: for details on the method that will invoke this delegate. \n * FlurryAds#fetchAndDisplayAdForSpace:view:size: for details on the method that will invoke this delegate. * * @param adSpace The placement of an ad in your app, where placement may * @param error The error, if known, that caused ads not to be rendered. * be splash screen for SPLASH_AD. */ - (void) spaceDidFailToRender:(NSString *)space error:(NSError *)error; /*! * @brief Invoked when the ad will be removed. * @since 4.1 * * This method informs the app that an ad will be removed. * * @param adSpace The placement of an ad in your app, where placement may be splash screen for SPLASH_AD. * @param interstitial YES/NO indicates if space being removed is an interstitial * */ - (void)spaceWillDismiss:(NSString *)adSpace interstitial:(BOOL)interstitial; /*! * @brief Invoked when the ad has been removed. * @since 4.0.0 * * This method informs the app that an ad has closed. You can use this to resume app * states. * * @param adSpace The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. * @param interstitial YES/NO indicates if space being removed is an interstitial */ - (void)spaceDidDismiss:(NSString *)adSpace interstitial:(BOOL)interstitial; /*! * @brief Invoked when the ad has been selected that will take the user out of the app. * @since 4.0.0 * * This method informs the app that an ad has been clicked and the user is about to be taken outside the app. * * @param adSpace The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. */ - (void)spaceWillLeaveApplication:(NSString *)adSpace; /*! * @brief Invoked when a space will be expanded. * @since 4.1 * * This method informs the app an ad space (typcially a banner) will be expanded. Apps should pause their state when they receive this notification * * @param adSpace The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. */ - (void) spaceWillExpand:(NSString *)adSpace; /*! * @brief Invoked when a space will be collapsed. * @since 4.1 * * This method informs the app an ad space (typcially a banner) will be collapsed. * * @param adSpace The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. */ - (void) spaceWillCollapse:(NSString *)adSpace; /*! * @brief Invoked when a space has been collapsed. * @since 4.1 * * This method informs the app an ad space (typcially a banner) has been collapsed. Apps should resume their state when they receive this notification * * @param adSpace The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. */ - (void) spaceDidCollapse:(NSString *)adSpace; /*! * @brief Informational callback invoked when an ad is clicked for the specified @c adSpace. * @since 4.1 * * This method informs the app that an ad has been clicked. This should not be used to adjust state of an app. It is only intended for informational purposes. * * @param adSpace The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. */ - (void) spaceDidReceiveClick:(NSString*)adSpace; /*! * @brief Invoked when a video finishes playing * @since 4.2.0 * * This method informs the app that a video associated with an ad has finished playing * * @param adSpace The placement of an ad in your app, where placement may be splash screen for SPLASH_AD. * */ - (void)videoDidFinish:(NSString *)adSpace; @optional #pragma mark App Keys /** @name Third party network Calls * Optional calls to pass information needed to display ads through 3rd parties. */ //@{ /*! * @brief The Millennial APID. * @since 4.0.0 * * This is the id for your app as set in Millennial, found here: https://developer.millennialmedia.com/Application/index.php#manageApps. */ - (NSString *)appSpotMillennialAppKey; //your millennial APID, found here: https://developer.millennialmedia.com/Application/index.php#manageApps /*! * @brief The Millennial APID for interstitials. * @since 4.0.0 * * This is the id for your app as set in Millennial, found here: https://developer.millennialmedia.com/Application/index.php#manageApps. */ - (NSString *)appSpotMillennialInterstitalAppKey; /*! * @brief The InMobi APID. * @since 4.0.0 * * This is the id for your app as set in InMobi, found here: https://www.inmobi.com/pub/mysite.html?platFormType=all */ - (NSString *)appSpotInMobiAppKey; /*! * @brief The AdMob Publisher Id. * @since 4.0.0 * * This is the id for your app as set in AdMob, found here: http://www.admob.com/my_sites/ (click manage settings) */ - (NSString *)appSpotAdMobPublisherID; /*! * @brief The Mobclix Application Id. * @since 4.0.0 * * This is the id for your app as set in Mobclix */ - (NSString *)appSpotMobclixApplicationID; /*! * @brief The Jumptap Publisher Id. * @since 4.1.2 * * This is the pub id for your app as set in Jumptap */ - (NSString *)appSpotJumptapPublisherID; /*! * @brief The Jumptap Site Id. * @since 4.1.2 * * This is the site id for your app as set in Jumptap. It is an optional parameter. */ - (NSString *)appSpotJumptapSiteID; /*! * @brief Jumptap Banner Ad Spot ID * @since 4.1.2 * * This is the ad spot id for a Banner (320x50) ad spot set in JumpTap */ - (NSString *)appSpotJumptapBannerAdSpotID; /*! * @brief Jumptap Leaderboard Ad Spot ID * @since 4.1.2 * * This is the ad spot id for a Leaderboard (720x90) ad spot set in JumpTap */ - (NSString *)appSpotJumptapLeaderboardAdSpotID; /*! * @brief Jumptap Medium Rectange Ad Spot ID * @since 4.1.2 * * This is the ad spot id for a Medium Rectangle (320x50) ad spot set in JumpTap. * The Medium Rectangle Ad Spot ID will be used whenever the ad frame can fit it * (e.g. interstitial ads). */ - (NSString *)appSpotJumptapMediumRectangleAdSpotID; /*! * @brief The Greystripe Application Id. * @since 4.0.0 * * This is the id for your app as set in Greystripe */ - (NSString *)appSpotGreystripeApplicationID; #pragma mark Information #pragma mark Callbacks /*! * @brief [Deprecated] Allow you to set your rootViewController. * @since 4.0.0 * @deprecated * * This method has been deprecated. Please call FlurryAds#initialze: instead. * */ - (id)appSpotRootViewController; #pragma mark Optional settings /** Some networks support accelerometer-enabled ads. */ /*! * @brief For networks that support accelerometer-enabled ads. * @since 4.0.0 * * This method allows you to enable accelerometer based ads for networks that support this setting via the client sdk. Set to NO if your app uses the accelerometer to avoid conflict. Set to YES if you want the special ads. Default is NO. */ - (BOOL)appSpotAccelerometerEnabled; //@} @end ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.ios/FlurryAds/FlurryAds.h ================================================ // // FlurryAds.h // Flurry iOS Analytics Agent // // Copyright 2009-2012 Flurry, Inc. All rights reserved. // // Methods in this header file are for use by Flurry Publishers #import typedef enum { BANNER_TOP = 1, BANNER_BOTTOM = 2, FULLSCREEN = 3, } FlurryAdSize; @protocol FlurryCustomAdNetwork; @protocol FlurryCustomAdNetworkProperties; /*! * @brief Provides all available methods for displaying ads. * * Set of methods that allow publishers to configure, target, and deliver ads to their customers. * * @note This class depends on Flurry.h. * For information on how to use Flurry's Ads SDK to * attract high-quality users and monetize your user base see Support Center - Publishers. * * @author 2009 - 2012 Flurry, Inc. All Rights Reserved. * @version 4.2.0 * */ @interface FlurryAds : NSObject { } /*! * @brief Retrieves an ad for the given @c space. * @since 4.1.0 * * This method will attempt to retrieve ads for the given space from the Flurry server. * * @note The @c space simply represents the placement of the ad in your app and should be * unique for each placement. For example, if you are displaying a full screen ad on your * splash screen and after level completeion, you may have the following spaces * @c @"SPLASH_AD" and @c @"LEVEL_AD". * * @see #removeAdFromSpace: for details on manually removing an ad from a view. \n * FlurryAdDelegate#spaceDidReceiveAd: for details on the notification of ads being received. * FlurryAdDelegate#spaceDidFailToReceiveAd:error: for details on notification of failure to receive ads from this request. * #displayAdForSpace: for details on displaying an available ad. * * @code * - (void)fetchAd:(NSString *)placement { // Placement may be SPLASH_AD as noted above [FlurryAds fetchAdForSpace:placement view:self.view.frame size:FULLSCREEN]; } // Show whenever delegate is invoked - (void) spaceDidReceiveAd:(NSString *)adSpace { // Received Ad [FlurryAds displayAdForSpace:adSpace]; } // Alternatively, try to display at a certain point in the app - (void) levelComplete { if([FlurryAds adReadyForSpace:adSpace]) { [FlurryAds displayAdForSpace:adSpace]; } } * @endcode * * @param space The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. * @param frame The frame of the view that will be used for the ad container. Note: for fullscreen ads, this value is not used (you can pass in bounds of window). * @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values. */ +(void) fetchAdForSpace:(NSString*)space frame:(CGRect)frame size:(FlurryAdSize)size; /*! * @brief Returns if an ad is currently ready to display for a given @c space. * @since 4.1.0 * * This method will verify if there is an ad is currently available for this * user. If an ad is not available, you may call #fetchAdForSpace:view:size: to load a new ad. * * @note If this method returns YES, an ad will be available when you attempt to display an ad. However, it is still advisable to listen to the delegate FlurryAdsDelegate#spaceDidFailToRender:. \n The @c space simply represents the placement of the ad in your app and should be * unique for each placement. For example, if you are displaying a full screen ad on your * splash screen and after level completeion, you may have the following spaces * @c @"SPLASH_AD" and @c @"LEVEL_AD". * * @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n #displayAdForSpace: for details on displaying the available ad. * * @code * - (void)showButtonForAd:(NSString *)placement { // Placement may be SPLASH_AD as noted above if([FlurryAds adReadyForSpace:placement]) { // Show button that ads are available. } } * @endcode * * @param space The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. * * @return YES/NO to indicate if an ad is ready to be displayed. */ +(BOOL) adReadyForSpace:(NSString*)space; /*! * @brief Display an ad for the given @c space. * @since 4.1.0 * * This method will display an ad if one is ready for display on the device. * * @note The @c space simply represents the placement of the ad in your app and should be * unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your * splash screen and after level completeion, you may have the following spaces * @c @"SPLASH_AD" and @c @"LEVEL_AD". * * @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n #adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n * #removeAdFromSpace: for details on manually removing an ad from a view. \n * FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user. * FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request. * * @code * - (void)showFullscreenAd:(NSString *)placement { // Placement may be SPLASH_AD as noted above if([FlurryAds adReadyForSpace:placement]) { [FlurryAds displayAdForSpace:placement onView:view]; } } * @endcode * * @param space The placement of an ad in your app, where placement may * @param view The view to place the ad. The view frame should be identical to the view frame passed in #fetchAdForSpace:frame:size. Note view is not used for interstitials. * be splash screen for SPLASH_AD. */ + (void)displayAdForSpace:(NSString*)space onView:(UIView *)view; /*! * @brief Display an ad for the given interstitial @c space. * @since 4.1.0 * * This method will display an interstitial ad if one is ready for display on the device for specified UIViewController instance * * @note The @c space simply represents the placement of the ad in your app and should be * unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your * splash screen and after level completeion, you may have the following spaces * @c @"SPLASH_AD" and @c @"LEVEL_AD". * * @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n #adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n * #removeAdFromSpace: for details on manually removing an ad from a view. \n * FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user. * FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request. * * @code * in UIViewController based class: * - (void)showFullscreenAd:(NSString *)placement { // Placement may be SPLASH_AD as noted above if([FlurryAds adReadyForSpace:placement]) { [FlurryAds displayAdForSpace:placement modallyForViewController:self]; } } * @endcode * * @param space The placement of an ad in your app, where placement may * @param viewController The viewController to show the fullscreen ad modally. * Note this method should not be used for banners. */ + (void)displayAdForSpace:(NSString*)space modallyForViewController:(UIViewController *)viewController; /*! * @brief [Deprecated] Check if an ad is available for the given @c space. * @since 4.0.0 * @deprecated * * [Deprecated] This method will verify with the Flurry server if an ad is currently available for this * user. If an ad is not available, we recommend not providing the user the * option to view. For example, you may have a button that reads "See other great apps!". * That button should only be displayed if this method returns YES. * * @note This method has been deprecated. * * @see #fetchAdForSpace:view:size: for replacement method.\n * * @param space The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. * @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container. * @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values. * @param timeout The maximum amount of time to wait for the server to return a result. Set this to 0 to check the cache and return immediately. * * @return YES/NO to indicate if an ad is available. */ +(BOOL) isAdAvailableForSpace:(NSString*)space view:(UIView *)view size:(FlurryAdSize)size timeout:(int64_t)timeout; /*! * @brief [Deprecated] Display an ad for the given @c space. * @since 4.0.0 * @deprecated * * [Deprecated] This method will display an ad if one is available from the Flurry server for this * user. * * @note This method has been deprecated. * * @see #fetchAndDisplayAdForSpace:view:size:timeout: for replacement method * * @param space The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. * @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container. * @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values. * @param timeout The maximum amount of time to wait for the server to return a valid ad. Set this to 0 to display an ad in the background (e.g. - for showing banners). * * @return YES/NO to indicate if an ad is available. */ + (BOOL)showAdForSpace:(NSString*)space view:(UIView *)viewContainer size:(FlurryAdSize)size timeout:(int64_t)timeout; /*! * @brief Fetch and Display an ad for the given @c space. * @since 4.0.0 * * This method will display an ad if one is available from the Flurry server for this * user. * * @note If this method returns YES, an ad is available for the space within @c timeout. \n * This is a blocking method that allows you to change the user experience based on availability of an ad. If you would like to display an ad asynchronously, just set timeout to 0. This is useful in the case of banners for instance where the user should not wait for its display. If you are loading async with timeout set to 0, ignore the return value of this method and rely exclusively on the relevant delegate methods listed below\n * The @c space simply represents the placement of the ad in your app and should be * unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your * splash screen and after level completeion, you may have the following spaces * @c @"SPLASH_AD" and @c @"LEVEL_AD". * * @see #adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n * #removeAdFromSpace: for details on manually removing an ad from a view. \n * FlurryAdDelegate#spaceDidReceiveAd: for details on the notification of ads being received. * FlurryAdDelegate#spaceDidFailToReceiveAd:error: for details on notification of failure to receive ads from this request. * FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user. * FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request. * * @code * - (void)showFullscreenAd:(NSString *)placement { // Placement may be SPLASH_AD as noted above [FlurryAds fetchAndDisplayAdForSpace:placement view:self.view size:FULLSCREEN timeout:3000]; } - (void)viewWillAppear:(BOOL)animated { // Show a banner whenever this view appears // Display banner ad completely asyncrhonously by providing timeout == 0 [FlurryAds fetchAndDisplayAdForSpace:@"VIEW_XYZ_BANNER_AD" view:self.view size:BANNER_BOTTOM timeout:0]; } * @endcode * * @param space The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. * @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container. * @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values. */ + (void)fetchAndDisplayAdForSpace:(NSString*)space view:(UIView *)viewContainer size:(FlurryAdSize)size; /*! * @brief Removes an ad for the given @c space. * @since 4.0.0 * * This method will remove an ad if one is currently displaying. * * @note The @c space simply represents the placement of the ad in your app and should be * unique for each placement. Only one ad will show at a time for any given ad space. * * @see #isAdAvailableForSpace:view:size:timeout: for details on displaying an available ad. \n * #removeAdFromSpace: for details on manually removing an ad from a view. \n * FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user. * * @code * - (void)viewDidUnload { // Remove a banner whenever this view dissapears [FlurryAds removeAdFromSpace:@"VIEW_XYZ_BANNER_AD"]; } * @endcode * * @param space The placement of an ad in your app, where placement may * be splash screen for SPLASH_AD. */ + (void) removeAdFromSpace:(NSString*)space; /*! * @brief Initializes the ad serving system. * @since 4.0 * * This method initializes the ad serving system and can be used to pre-cache ads from the server (this is done when ad spaces are configured on the server). * * @note This method must be called sometime after Flurry#startSession:. * * @code * - (void)applicationDidFinishLaunching:(UIApplication *)application { // Optional Flurry startup methods [Flurry startSession:@"YOUR_API_KEY"]; [FlurryAds setAdDelegate:self]; [FlurryAds initialize:myWindow.rootViewController]; // .... } * @endcode * * @param rvc The primary root view controller of your app. * */ + (void) initialize: (UIViewController *)rvc; /*! * @brief Sets the object to receive various delegate methods. * @since 4.0 * * This method allows you to register an object that will receive * notifications at different phases of ad serving. * * @see FlurryAdDelegate.h for details on delegates available. * * @code * - (void)applicationDidFinishLaunching:(UIApplication *)application { // Optional Flurry startup methods [Flurry startSession:@"YOUR_API_KEY"]; [FlurryAds setAdDelegate:self]; // .... } * @endcode * * @param delegate The object to receive notifications of various ad actions. * */ + (void)setAdDelegate:(id)delegate; /*! * @brief Informs server to send test ads. * @since 4.0 * * This method allows you to request test ads from the server. These ads do not generate revenue so it is CRITICAL this call is removed prior to app submission. * * * @code * - (void)applicationDidFinishLaunching:(UIApplication *)application { // Optional Flurry startup methods [Flurry startSession:@"YOUR_API_KEY"]; [FlurryAds enableTestAds:YES]; // .... } * @endcode * * @param enable YES to receive test ads to the device. Not including this method is equivalent to passing NO. * */ + (void)enableTestAds:(BOOL)enable; /*! * @brief Sets a dictionary of key/value pairs, which will be transmitted to Flurry servers when a user clicks on an ad. * @since 4.0.0 * * UserCookies allow the developer to specify information on a user executing an ad action. There is one UserCookie object, and on each ad click that UserCookie is transmitted to the Flurry servers. The UserCookie key/value pairs will be transmitted back to the developer via the app callback if one is set. This is useful for rewarded inventory, to identify which of your users should be rewarded when a reward callback is sent. * * @note Calling this method with a nil or empty dictionary has no effect. Calling this method a second time with a valid dictionary will replace the previous entries. To clear previously set userCookies, you must call #clearUserCookies. * @see #clearUserCookies for details on removing user cookies set through this method. * * @code * - (void)applicationDidFinishLaunching:(UIApplication *)application { // Optional Flurry startup methods [Flurry startSession:@"YOUR_API_KEY"]; NSDictionary *cookies = [NSDictionary dictionaryWithObjectsAndKeys:@"xyz123", // Parameter Value @"UserCharacterId", // Parameter Name nil]; [FlurryAds setUserCookies:cookies]; // .... } * @endcode * * @param userCookies The information about the user executing ad actions. Note: do not transmit personally identifiable information in the user cookies. */ + (void) setUserCookies:(NSDictionary *) userCookies; /*! * @brief Removes a previously set dictionary of key/value pairs. * @since 4.0.0 * * This method removes information from the one UserCookie object. * * @see #setUserCookies: for details on setting user cookies. * */ + (void) clearUserCookies; /*! * @brief Sets a dictionary of key/value pairs, which will be transmitted to Flurry servers when an ad is requested. * @since 4.0.0 * * Keywords allow the developer to specify information on a user executing an ad action for the purposes of targeting. There is one keywords object that is transmitted to the Flurry servers on each ad request. If corresponding keywords are matched on the ad server, a subset of targeted ads will be delivered. This allows partners to supply information they track internally, which is not available to Flurry's targeting system. * * @note Calling this method with a nil or empty dictionary has no effect. Calling this method a second time with a valid dictionary will replace the previous entries. To clear previously set keywords, you must call #clearKeywords. * @see #clearKeywords for details on removing keywords set through this method. * * @code * - (void)applicationDidFinishLaunching:(UIApplication *)application { // Optional Flurry startup methods [Flurry startSession:@"YOUR_API_KEY"]; // Specify that user loves vacations NSDictionary *keywords = [NSDictionary dictionaryWithObjectsAndKeys:@"vacation", // Parameter Value @"UserPreference", // Parameter Name nil]; [FlurryAds setKeywords:keywords]; // .... } * @endcode * * @param keywords The information about the user to be used in targeting an ad. Note: do not transmit personally identifiable information in keywords. */ + (void) setKeywordsForTargeting:(NSDictionary*) keywords; /*! * @brief Removes a previously set dictionary of key/value pairs. * @since 4.0.0 * * This method removes information from the one keywords object. * * @see #setKeywords: for details on setting keywords. * */ + (void) clearKeywords; /*! * @brief Method to add a custom ad network to be served through the standard Flurry ad system. * @since 4.0.0 * * This method adds a network with the necessary publisher supplied properties to the Flurry sdk. * * @see @c FlurryCustomAdNetwork and @c FlurryCustomAdNetworkProperties for details. * */ + (void) addCustomAdNetwork:(Class)adNetworkClass withProperties:(id)adNetworkProperties; @end ================================================ FILE: cocos2d/plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ FA09A376168AFD41008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A375168AFD41008C1C7B /* Foundation.framework */; }; FA73FC9117A11B84007E23C2 /* AdsFlurry.m in Sources */ = {isa = PBXBuildFile; fileRef = FA73FC8F17A11B84007E23C2 /* AdsFlurry.m */; }; FA73FC9617A11E24007E23C2 /* libFlurryAds.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73FC9517A11E24007E23C2 /* libFlurryAds.a */; }; FAB6DFDD1756F22200C90D89 /* libFlurry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAB6DFDB1756F22200C90D89 /* libFlurry.a */; }; FAB6DFE01756F29800C90D89 /* AnalyticsFlurry.m in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DFDF1756F29800C90D89 /* AnalyticsFlurry.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ FA09A370168AFD41008C1C7B /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = "include/${PRODUCT_NAME}"; dstSubfolderSpec = 16; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ FA09A372168AFD41008C1C7B /* libPluginFlurry.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginFlurry.a; sourceTree = BUILT_PRODUCTS_DIR; }; FA09A375168AFD41008C1C7B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; FA73FC8E17A11B84007E23C2 /* AdsFlurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsFlurry.h; sourceTree = ""; }; FA73FC8F17A11B84007E23C2 /* AdsFlurry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdsFlurry.m; sourceTree = ""; }; FA73FC9017A11B84007E23C2 /* PluginFlurry-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PluginFlurry-Prefix.pch"; sourceTree = ""; }; FA73FC9317A11E24007E23C2 /* FlurryAdDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlurryAdDelegate.h; sourceTree = ""; }; FA73FC9417A11E24007E23C2 /* FlurryAds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlurryAds.h; sourceTree = ""; }; FA73FC9517A11E24007E23C2 /* libFlurryAds.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libFlurryAds.a; sourceTree = ""; }; FA86650E168BE22D0073E055 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; FAB6DFD81756F22200C90D89 /* Flurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Flurry.h; sourceTree = ""; }; FAB6DFDB1756F22200C90D89 /* libFlurry.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libFlurry.a; sourceTree = ""; }; FAB6DFDE1756F29800C90D89 /* AnalyticsFlurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnalyticsFlurry.h; sourceTree = ""; }; FAB6DFDF1756F29800C90D89 /* AnalyticsFlurry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnalyticsFlurry.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ FA09A36F168AFD41008C1C7B /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( FA09A376168AFD41008C1C7B /* Foundation.framework in Frameworks */, FAB6DFDD1756F22200C90D89 /* libFlurry.a in Frameworks */, FA73FC9617A11E24007E23C2 /* libFlurryAds.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ FA09A367168AFD41008C1C7B = { isa = PBXGroup; children = ( FA73FC8E17A11B84007E23C2 /* AdsFlurry.h */, FA73FC8F17A11B84007E23C2 /* AdsFlurry.m */, FA73FC9017A11B84007E23C2 /* PluginFlurry-Prefix.pch */, FAB6DFDE1756F29800C90D89 /* AnalyticsFlurry.h */, FAB6DFDF1756F29800C90D89 /* AnalyticsFlurry.m */, FAB6DFD81756F22200C90D89 /* Flurry.h */, FAB6DFDB1756F22200C90D89 /* libFlurry.a */, FA73FC9217A11E24007E23C2 /* FlurryAds */, FA09A374168AFD41008C1C7B /* Frameworks */, FA09A373168AFD41008C1C7B /* Products */, ); sourceTree = ""; }; FA09A373168AFD41008C1C7B /* Products */ = { isa = PBXGroup; children = ( FA09A372168AFD41008C1C7B /* libPluginFlurry.a */, ); name = Products; sourceTree = ""; }; FA09A374168AFD41008C1C7B /* Frameworks */ = { isa = PBXGroup; children = ( FA86650E168BE22D0073E055 /* SystemConfiguration.framework */, FA09A375168AFD41008C1C7B /* Foundation.framework */, ); name = Frameworks; sourceTree = ""; }; FA73FC9217A11E24007E23C2 /* FlurryAds */ = { isa = PBXGroup; children = ( FA73FC9317A11E24007E23C2 /* FlurryAdDelegate.h */, FA73FC9417A11E24007E23C2 /* FlurryAds.h */, FA73FC9517A11E24007E23C2 /* libFlurryAds.a */, ); path = FlurryAds; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ FA09A371168AFD41008C1C7B /* PluginFlurry */ = { isa = PBXNativeTarget; buildConfigurationList = FA09A380168AFD41008C1C7B /* Build configuration list for PBXNativeTarget "PluginFlurry" */; buildPhases = ( FA09A36E168AFD41008C1C7B /* Sources */, FA09A36F168AFD41008C1C7B /* Frameworks */, FA09A370168AFD41008C1C7B /* CopyFiles */, ); buildRules = ( ); dependencies = ( ); name = PluginFlurry; productName = libPluginFlurry; productReference = FA09A372168AFD41008C1C7B /* libPluginFlurry.a */; productType = "com.apple.product-type.library.static"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ FA09A369168AFD41008C1C7B /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0460; ORGANIZATIONNAME = zhangbin; }; buildConfigurationList = FA09A36C168AFD41008C1C7B /* Build configuration list for PBXProject "PluginFlurry" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); mainGroup = FA09A367168AFD41008C1C7B; productRefGroup = FA09A373168AFD41008C1C7B /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( FA09A371168AFD41008C1C7B /* PluginFlurry */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ FA09A36E168AFD41008C1C7B /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( FAB6DFE01756F29800C90D89 /* AnalyticsFlurry.m in Sources */, FA73FC9117A11B84007E23C2 /* AdsFlurry.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ FA09A37E168AFD41008C1C7B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; 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; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; }; name = Debug; }; FA09A37F168AFD41008C1C7B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; 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; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; name = Release; }; FA09A381168AFD41008C1C7B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { 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"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../platform/ios\"", "\"$(SRCROOT)\"", "\"$(SRCROOT)/FlurryAds\"", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = PluginFlurry; SKIP_INSTALL = YES; }; name = Debug; }; FA09A382168AFD41008C1C7B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { 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"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../platform/ios\"", "\"$(SRCROOT)\"", "\"$(SRCROOT)/FlurryAds\"", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = PluginFlurry; SKIP_INSTALL = YES; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ FA09A36C168AFD41008C1C7B /* Build configuration list for PBXProject "PluginFlurry" */ = { isa = XCConfigurationList; buildConfigurations = ( FA09A37E168AFD41008C1C7B /* Debug */, FA09A37F168AFD41008C1C7B /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; FA09A380168AFD41008C1C7B /* Build configuration list for PBXNativeTarget "PluginFlurry" */ = { isa = XCConfigurationList; buildConfigurations = ( FA09A381168AFD41008C1C7B /* Debug */, FA09A382168AFD41008C1C7B /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = FA09A369168AFD41008C1C7B /* Project object */; } ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/.classpath ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/.project ================================================ libPluginNd91 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 ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/AndroidManifest.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/.classpath ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/.project ================================================ 91SDK_LibProject_complete 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 ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/AndroidManifest.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/project.properties ================================================ # 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-16 android.library=true ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipin.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipin_reverse.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipout.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/anim/nd_flipout_reverse.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_background_xml.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_02.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_action.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_logout.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_old.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_button_x.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_checkbox_button.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_friend_del_button.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_image_48_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_input_gray.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_message_item_1_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_message_item_2_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_pay_checkbox_button.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_progress_large.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_left_btn_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_middle_btn_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_rank_choice_right_btn_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_regist_checked.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_round_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_square_checkbox_button.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_title_bar_action_btn_xml.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_title_bar_return_btn_xml.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd3_user_item_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_blue.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_add.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_buy.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_button_action_reduce.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_c_blur.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_download.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_green.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_leaderboard_left_btn_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_leaderboard_right_btn_bg.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_list_btn_delete_selector.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_login_btn_land_selector.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_login_btn_portrait_selector.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_register_btn_portrait_selector.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_h.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_h_expand.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_v.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_slider_handle_v_expand.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/drawable/nd_white_btn.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_bind_bind.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_bind_register.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_email_item.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_item.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_land.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_other_item.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_login_portrait.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_oauth_bind.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_official.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_account_official_landscape.xml ================================================  ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_fangle.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_fangle_ext.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_item.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_item_divider.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_message.xml ================================================ ================================================ FILE: cocos2d/plugin/plugins/nd91/proj.android/DependProject/res/layout/nd3_user_message_switcher.xml ================================================